From 82e2f1ca4552723477f4b48898438a48fa463873 Mon Sep 17 00:00:00 2001 From: Jorge Ferreira Date: Tue, 6 Oct 2026 20:57:57 +0000 Subject: [PATCH 1/8] web: replace Leaflet with deck.gl in the layout viewer Signed-off-by: Jorge Ferreira --- src/web/BUILD | 7 +- src/web/README.md | 6 +- src/web/dist/THIRD_PARTY_LICENSES.txt | 1900 ++++- src/web/dist/app.min.js | 6973 ++++++++++++++++- src/web/dist/index.html | 4 +- src/web/dist/report.min.js | 6485 ++++++++++++++- src/web/docs/server-api.md | 44 +- src/web/esbuild.config.mjs | 26 +- src/web/package.json | 4 +- src/web/pnpm-lock.yaml | 342 +- src/web/src/capture.js | 220 +- src/web/src/color.h | 11 + src/web/src/context-menu.js | 15 +- src/web/src/coordinates.js | 33 +- src/web/src/deck-global.js | 21 + src/web/src/device-pixels.js | 185 - src/web/src/display-controls.js | 433 +- src/web/src/display-state.js | 3 + src/web/src/drc-widget.js | 20 +- src/web/src/entry-app.js | 2 +- src/web/src/entry-report.js | 2 +- src/web/src/inspector.js | 373 +- src/web/src/label-manager.js | 131 +- src/web/src/layer-extents.js | 4 +- src/web/src/layout-view.js | 1222 +++ src/web/src/leaflet-global.js | 7 - src/web/src/main.js | 798 +- src/web/src/menu-bar.js | 18 +- src/web/src/merged-tile-layer.js | 293 - src/web/src/request_handler.cpp | 243 +- src/web/src/request_handler.h | 8 +- src/web/src/ruler.js | 390 +- src/web/src/search-nav.js | 30 +- src/web/src/selection-browser.js | 8 +- src/web/src/style.css | 178 +- src/web/src/tile-grid.js | 281 + src/web/src/tile-merge.js | 290 +- src/web/src/tile-request.js | 143 +- src/web/src/tile-sources.js | 315 + src/web/src/tile_generator.cpp | 225 +- src/web/src/tile_generator.h | 47 +- src/web/src/ui-utils.js | 142 +- src/web/src/vendor.css | 1 - src/web/src/view-input.js | 312 + src/web/src/view-math.js | 195 + src/web/src/web.cpp | 2 +- src/web/src/websocket-manager.js | 62 +- src/web/src/websocket-tile-layer.js | 299 - src/web/src/zoom-swap.js | 166 + src/web/test/BUILD | 82 +- src/web/test/bundle_test.py | 10 +- src/web/test/cpp/TestRequestHandler.cpp | 213 +- src/web/test/cpp/TestSaveImage.cpp | 6 +- src/web/test/cpp/TestSaveReport.cpp | 22 +- src/web/test/cpp/TestTileGenerator.cpp | 209 +- src/web/test/js/fake-deck.js | 83 + src/web/test/js/fake-view.js | 181 + src/web/test/js/test-capture.js | 63 +- src/web/test/js/test-context-menu.js | 49 +- src/web/test/js/test-coordinates.js | 91 +- src/web/test/js/test-device-pixels.js | 316 - src/web/test/js/test-display-controls.js | 268 +- src/web/test/js/test-display-state.js | 4 + src/web/test/js/test-dpr.js | 83 +- src/web/test/js/test-drc-widget.js | 25 +- .../test/js/test-imports-without-globals.js | 34 + src/web/test/js/test-inspector.js | 150 +- src/web/test/js/test-label-manager.js | 149 +- src/web/test/js/test-layout-view.js | 902 +++ src/web/test/js/test-menu-bar.js | 43 + src/web/test/js/test-merged-tile-layer.js | 1008 --- src/web/test/js/test-options-dialogs.js | 2 +- src/web/test/js/test-ruler.js | 236 +- src/web/test/js/test-schematic-widget.js | 4 +- src/web/test/js/test-search-nav.js | 54 +- src/web/test/js/test-selection-browser.js | 15 +- src/web/test/js/test-tile-grid.js | 423 + src/web/test/js/test-tile-merge.js | 499 +- src/web/test/js/test-tile-sources.js | 479 ++ src/web/test/js/test-ui-utils.js | 225 +- src/web/test/js/test-view-input.js | 371 + src/web/test/js/test-view-math.js | 230 + src/web/test/js/test-websocket-manager.js | 110 +- src/web/test/js/test-websocket-tile-layer.js | 585 -- src/web/test/js/test-zoom-swap.js | 221 + 85 files changed, 23954 insertions(+), 6410 deletions(-) create mode 100644 src/web/src/deck-global.js delete mode 100644 src/web/src/device-pixels.js create mode 100644 src/web/src/layout-view.js delete mode 100644 src/web/src/leaflet-global.js delete mode 100644 src/web/src/merged-tile-layer.js create mode 100644 src/web/src/tile-grid.js create mode 100644 src/web/src/tile-sources.js create mode 100644 src/web/src/view-input.js create mode 100644 src/web/src/view-math.js delete mode 100644 src/web/src/websocket-tile-layer.js create mode 100644 src/web/src/zoom-swap.js create mode 100644 src/web/test/js/fake-deck.js create mode 100644 src/web/test/js/fake-view.js delete mode 100644 src/web/test/js/test-device-pixels.js create mode 100644 src/web/test/js/test-imports-without-globals.js create mode 100644 src/web/test/js/test-layout-view.js delete mode 100644 src/web/test/js/test-merged-tile-layer.js create mode 100644 src/web/test/js/test-tile-grid.js create mode 100644 src/web/test/js/test-tile-sources.js create mode 100644 src/web/test/js/test-view-input.js create mode 100644 src/web/test/js/test-view-math.js delete mode 100644 src/web/test/js/test-websocket-tile-layer.js create mode 100644 src/web/test/js/test-zoom-swap.js diff --git a/src/web/BUILD b/src/web/BUILD index bcaa5a2cd12..7c16b5e150e 100644 --- a/src/web/BUILD +++ b/src/web/BUILD @@ -42,8 +42,10 @@ npm_link_all_packages(name = "node_modules") # What the bundle carries, with their dependencies, and so whose licences ship # with it. _BUNDLED_PACKAGES = [":node_modules/" + p for p in [ + "@deck.gl/core", + "@deck.gl/extensions", + "@deck.gl/layers", "golden-layout", - "leaflet", "lit", "netlistsvg", "three", @@ -58,13 +60,12 @@ js_library( deps = _BUNDLED_PACKAGES, ) -# The stylesheets import Golden Layout's and Leaflet's CSS. +# The stylesheets import Golden Layout's CSS. js_library( name = "css", srcs = glob(["src/*.css"]), deps = [ ":node_modules/golden-layout", - ":node_modules/leaflet", ], ) diff --git a/src/web/README.md b/src/web/README.md index 93260c3e971..bd861ba6bbc 100644 --- a/src/web/README.md +++ b/src/web/README.md @@ -544,8 +544,8 @@ The module has two parts: Tiles are rendered from ODB geometry and encoded as PNG using lodepng. - **JavaScript frontend** (`src/main.js`, `src/index.html`, `src/style.css`) — - A single-page application using Leaflet.js for the map and GoldenLayout for - resizable panels. Communicates with the server over a binary WebSocket + A single-page application using deck.gl (WebGL) for the layout view and + GoldenLayout for resizable panels. Communicates with the server over a binary WebSocket protocol. ## Browser libraries @@ -559,7 +559,7 @@ the result, so the browser only talks to the OpenROAD process. | Package | Used for | | --- | --- | -| `leaflet` | the tiled layout view | +| `@deck.gl/core`, `@deck.gl/layers`, `@deck.gl/extensions` | the layout view, drawn with WebGL through `deck-global.js` | | `golden-layout` | the dockable panel layout | | `netlistsvg` | the schematic, laid out by its own `elkjs` | | `three` | the 3D viewer, through `three-subset.js` | diff --git a/src/web/dist/THIRD_PARTY_LICENSES.txt b/src/web/dist/THIRD_PARTY_LICENSES.txt index a90a3d77c71..2de889fd87d 100644 --- a/src/web/dist/THIRD_PARTY_LICENSES.txt +++ b/src/web/dist/THIRD_PARTY_LICENSES.txt @@ -3,46 +3,1307 @@ Third-party software in the OpenROAD web viewer The viewer's browser bundle includes the npm packages below. Their licences follow. +============================================================================== +@deck.gl/core 9.4.0 (MIT) +Source: https://github.com/visgl/deck.gl +============================================================================== + +Copyright Vis.gl contributors. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +============================================================================== +@deck.gl/extensions 9.4.0 (MIT) +Source: https://github.com/visgl/deck.gl +============================================================================== + +Copyright Vis.gl contributors. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +============================================================================== +@deck.gl/layers 9.4.0 (MIT) +Source: https://github.com/visgl/deck.gl +============================================================================== + +Copyright Vis.gl contributors. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + ============================================================================== @lit-labs/ssr-dom-shim 1.6.0 (BSD-3-Clause) Source: https://github.com/lit/lit ============================================================================== -Licensed under BSD-3-Clause (declared in package.json). +Licensed under BSD-3-Clause (declared in package.json). + +============================================================================== +@lit/reactive-element 2.1.2 (BSD-3-Clause) +Source: https://github.com/lit/lit +============================================================================== + +BSD 3-Clause License + +Copyright (c) 2017 Google LLC. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +============================================================================== +@loaders.gl/core 4.5.4 (MIT) +Source: https://github.com/visgl/loaders.gl +============================================================================== + +loaders.gl is licensed under the MIT license + +Copyright (c) vis.gl contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +--- + +Copyright (c) 2015 Uber Technologies, Inc. + +loaders.gl includes certain files from Cesium (https://github.com/AnalyticalGraphicsInc/cesium) +under the Apache 2 License (found in the submodule: modules/3d-tiles):) + +Copyright 2011-2018 CesiumJS Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and limitations under the License. + +============================================================================== +@loaders.gl/images 4.5.4 (MIT) +Source: https://github.com/visgl/loaders.gl +============================================================================== + +loaders.gl is licensed under the MIT license + +Copyright (c) vis.gl contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +--- + +Copyright (c) 2015 Uber Technologies, Inc. + +loaders.gl includes certain files from Cesium (https://github.com/AnalyticalGraphicsInc/cesium) +under the Apache 2 License (found in the submodule: modules/3d-tiles):) + +Copyright 2011-2018 CesiumJS Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and limitations under the License. + +============================================================================== +@loaders.gl/loader-utils 4.5.4 (MIT) +Source: https://github.com/visgl/loaders.gl +============================================================================== + +loaders.gl is licensed under the MIT license + +Copyright (c) vis.gl contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +--- + +Copyright (c) 2015 Uber Technologies, Inc. + +loaders.gl includes certain files from Cesium (https://github.com/AnalyticalGraphicsInc/cesium) +under the Apache 2 License (found in the submodule: modules/3d-tiles):) + +Copyright 2011-2018 CesiumJS Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and limitations under the License. + +============================================================================== +@loaders.gl/schema 4.5.4 (MIT) +Source: https://github.com/visgl/loaders.gl +============================================================================== + +loaders.gl is licensed under the MIT license + +Copyright (c) vis.gl contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +--- + +Copyright (c) 2015 Uber Technologies, Inc. + +loaders.gl includes certain files from Cesium (https://github.com/AnalyticalGraphicsInc/cesium) +under the Apache 2 License (found in the submodule: modules/3d-tiles):) + +Copyright 2011-2018 CesiumJS Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and limitations under the License. + +============================================================================== +@loaders.gl/schema-utils 4.5.4 (MIT) +Source: https://github.com/visgl/loaders.gl +============================================================================== + +loaders.gl is licensed under the MIT license + +Copyright (c) vis.gl contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +--- + +Copyright (c) 2015 Uber Technologies, Inc. + +loaders.gl includes certain files from Cesium (https://github.com/AnalyticalGraphicsInc/cesium) +under the Apache 2 License (found in the submodule: modules/3d-tiles):) + +Copyright 2011-2018 CesiumJS Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and limitations under the License. + +============================================================================== +@loaders.gl/worker-utils 4.5.4 (MIT) +Source: https://github.com/visgl/loaders.gl +============================================================================== + +loaders.gl is licensed under the MIT license + +Copyright (c) vis.gl contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +--- + +Copyright (c) 2015 Uber Technologies, Inc. + +loaders.gl includes certain files from Cesium (https://github.com/AnalyticalGraphicsInc/cesium) +under the Apache 2 License (found in the submodule: modules/3d-tiles):) + +Copyright 2011-2018 CesiumJS Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and limitations under the License. + +============================================================================== +@luma.gl/core 9.4.2 (MIT) +Source: https://github.com/visgl/luma.gl +============================================================================== + +luma.gl is provided under the MIT license + +Copyright (c) 2020 vis.gl contributors + +This software includes parts initially developed by Uber and open sourced under MIT license. +Copyright (c) 2015 Uber Technologies, Inc. + +This software includes parts of PhiloGL (https://github.com/philogb/philogl) +under MIT license. PhiloGL parts Copyright © 2013 Sencha Labs. + +This software includes adaptations of some postprocessing code from +THREE.js (https://github.com/mrdoob/three.js/) under MIT license. +THREE.js parts Copyright © 2010-2018 three.js authors. + +This software includes adaptations of Gaussian-splat rendering and +level-of-detail behavior from Spark (https://github.com/sparkjsdev/spark) +under MIT license. +Spark parts Copyright © 2025 WORLD LABS TECHNOLOGIES, INC. + +Additional attribution given in specific source files. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +============================================================================== +@luma.gl/engine 9.4.2 (MIT) +Source: https://github.com/visgl/luma.gl +============================================================================== + +luma.gl is provided under the MIT license + +Copyright (c) 2020 vis.gl contributors + +This software includes parts initially developed by Uber and open sourced under MIT license. +Copyright (c) 2015 Uber Technologies, Inc. + +This software includes parts of PhiloGL (https://github.com/philogb/philogl) +under MIT license. PhiloGL parts Copyright © 2013 Sencha Labs. + +This software includes adaptations of some postprocessing code from +THREE.js (https://github.com/mrdoob/three.js/) under MIT license. +THREE.js parts Copyright © 2010-2018 three.js authors. + +This software includes adaptations of Gaussian-splat rendering and +level-of-detail behavior from Spark (https://github.com/sparkjsdev/spark) +under MIT license. +Spark parts Copyright © 2025 WORLD LABS TECHNOLOGIES, INC. + +Additional attribution given in specific source files. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +============================================================================== +@luma.gl/gpgpu 9.4.2 (MIT) +Source: https://github.com/visgl/luma.gl +============================================================================== + +luma.gl is provided under the MIT license + +Copyright (c) 2020 vis.gl contributors + +This software includes parts initially developed by Uber and open sourced under MIT license. +Copyright (c) 2015 Uber Technologies, Inc. + +This software includes parts of PhiloGL (https://github.com/philogb/philogl) +under MIT license. PhiloGL parts Copyright © 2013 Sencha Labs. + +This software includes adaptations of some postprocessing code from +THREE.js (https://github.com/mrdoob/three.js/) under MIT license. +THREE.js parts Copyright © 2010-2018 three.js authors. + +This software includes adaptations of Gaussian-splat rendering and +level-of-detail behavior from Spark (https://github.com/sparkjsdev/spark) +under MIT license. +Spark parts Copyright © 2025 WORLD LABS TECHNOLOGIES, INC. + +Additional attribution given in specific source files. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +============================================================================== +@luma.gl/shadertools 9.4.2 (MIT) +Source: https://github.com/visgl/luma.gl +============================================================================== + +luma.gl is provided under the MIT license + +Copyright (c) 2020 vis.gl contributors + +This software includes parts initially developed by Uber and open sourced under MIT license. +Copyright (c) 2015 Uber Technologies, Inc. + +This software includes parts of PhiloGL (https://github.com/philogb/philogl) +under MIT license. PhiloGL parts Copyright © 2013 Sencha Labs. + +This software includes adaptations of some postprocessing code from +THREE.js (https://github.com/mrdoob/three.js/) under MIT license. +THREE.js parts Copyright © 2010-2018 three.js authors. + +This software includes adaptations of Gaussian-splat rendering and +level-of-detail behavior from Spark (https://github.com/sparkjsdev/spark) +under MIT license. +Spark parts Copyright © 2025 WORLD LABS TECHNOLOGIES, INC. + +Additional attribution given in specific source files. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +============================================================================== +@luma.gl/webgl 9.4.2 (MIT) +Source: https://github.com/visgl/luma.gl +============================================================================== + +luma.gl is provided under the MIT license + +Copyright (c) 2020 vis.gl contributors + +This software includes parts initially developed by Uber and open sourced under MIT license. +Copyright (c) 2015 Uber Technologies, Inc. + +This software includes parts of PhiloGL (https://github.com/philogb/philogl) +under MIT license. PhiloGL parts Copyright © 2013 Sencha Labs. + +This software includes adaptations of some postprocessing code from +THREE.js (https://github.com/mrdoob/three.js/) under MIT license. +THREE.js parts Copyright © 2010-2018 three.js authors. + +This software includes adaptations of Gaussian-splat rendering and +level-of-detail behavior from Spark (https://github.com/sparkjsdev/spark) +under MIT license. +Spark parts Copyright © 2025 WORLD LABS TECHNOLOGIES, INC. + +Additional attribution given in specific source files. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +============================================================================== +@luma.gl/webgpu 9.4.2 (MIT) +Source: https://github.com/visgl/luma.gl +============================================================================== + +luma.gl is provided under the MIT license + +Copyright (c) 2020 vis.gl contributors + +This software includes parts initially developed by Uber and open sourced under MIT license. +Copyright (c) 2015 Uber Technologies, Inc. + +This software includes parts of PhiloGL (https://github.com/philogb/philogl) +under MIT license. PhiloGL parts Copyright © 2013 Sencha Labs. + +This software includes adaptations of some postprocessing code from +THREE.js (https://github.com/mrdoob/three.js/) under MIT license. +THREE.js parts Copyright © 2010-2018 three.js authors. + +This software includes adaptations of Gaussian-splat rendering and +level-of-detail behavior from Spark (https://github.com/sparkjsdev/spark) +under MIT license. +Spark parts Copyright © 2025 WORLD LABS TECHNOLOGIES, INC. + +Additional attribution given in specific source files. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +============================================================================== +@mapbox/tiny-sdf 2.3.0 (BSD-2-Clause) +Source: https://github.com/mapbox/tiny-sdf +============================================================================== + +BSD-2-Clause +Copyright (c) 2016-2024 Mapbox, Inc. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +============================================================================== +@math.gl/core 4.1.0 (MIT) +Source: https://github.com/visgl/math.gl +============================================================================== + +MIT License + +Copyright (c) 2017 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +--- + +math.gl builds on docs and code from "gl-matrix", which is MIT licensed as follows: + +Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +-- + +math.gl builds on docs and code from THREE.js, which is MIT licensed as follows: + +The MIT License + +Copyright © 2010-2017 three.js authors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +--- + +math.gl includes certain files from Cesium (https://github.com/AnalyticalGraphicsInc/cesium) under the Apache 2 License: + +Copyright 2011-2018 CesiumJS Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and limitations under the License. + +Cesium-derived code can be found in the submodule: modules/3d-tiles + +============================================================================== +@math.gl/polygon 4.1.0 (MIT) +Source: https://github.com/visgl/math.gl +============================================================================== + +MIT License + +Copyright (c) 2017 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +--- + +math.gl builds on docs and code from "gl-matrix", which is MIT licensed as follows: + +Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +-- + +math.gl builds on docs and code from THREE.js, which is MIT licensed as follows: + +The MIT License + +Copyright © 2010-2017 three.js authors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +--- + +math.gl includes certain files from Cesium (https://github.com/AnalyticalGraphicsInc/cesium) under the Apache 2 License: + +Copyright 2011-2018 CesiumJS Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and limitations under the License. + +Cesium-derived code can be found in the submodule: modules/3d-tiles + +============================================================================== +@math.gl/sun 4.1.0 (MIT) +Source: https://github.com/visgl/math.gl +============================================================================== + +MIT License + +Copyright (c) 2017 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +--- + +math.gl builds on docs and code from "gl-matrix", which is MIT licensed as follows: + +Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +-- + +math.gl builds on docs and code from THREE.js, which is MIT licensed as follows: + +The MIT License + +Copyright © 2010-2017 three.js authors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +--- + +math.gl includes certain files from Cesium (https://github.com/AnalyticalGraphicsInc/cesium) under the Apache 2 License: + +Copyright 2011-2018 CesiumJS Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and limitations under the License. + +Cesium-derived code can be found in the submodule: modules/3d-tiles + +============================================================================== +@math.gl/types 4.1.0 (MIT) +Source: https://github.com/visgl/math.gl +============================================================================== + +MIT License + +Copyright (c) 2017 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +--- + +math.gl builds on docs and code from "gl-matrix", which is MIT licensed as follows: + +Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +-- + +math.gl builds on docs and code from THREE.js, which is MIT licensed as follows: + +The MIT License + +Copyright © 2010-2017 three.js authors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +--- + +math.gl includes certain files from Cesium (https://github.com/AnalyticalGraphicsInc/cesium) under the Apache 2 License: + +Copyright 2011-2018 CesiumJS Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and limitations under the License. + +Cesium-derived code can be found in the submodule: modules/3d-tiles + +============================================================================== +@math.gl/web-mercator 4.1.0 (MIT) +Source: https://github.com/visgl/math.gl +============================================================================== + +MIT License + +Copyright (c) 2017 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +--- + +math.gl builds on docs and code from "gl-matrix", which is MIT licensed as follows: + +Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +-- + +math.gl builds on docs and code from THREE.js, which is MIT licensed as follows: + +The MIT License + +Copyright © 2010-2017 three.js authors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +--- + +math.gl includes certain files from Cesium (https://github.com/AnalyticalGraphicsInc/cesium) under the Apache 2 License: + +Copyright 2011-2018 CesiumJS Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and limitations under the License. + +Cesium-derived code can be found in the submodule: modules/3d-tiles + +============================================================================== +@probe.gl/env 4.1.2 (MIT) +Source: https://github.com/visgl/probe.gl +============================================================================== + +Copyright Vis.gl contributors. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +============================================================================== +@probe.gl/log 4.1.2 (MIT) +Source: https://github.com/visgl/probe.gl +============================================================================== + +Copyright Vis.gl contributors. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +============================================================================== +@probe.gl/stats 4.1.2 (MIT) +Source: https://github.com/visgl/probe.gl +============================================================================== + +Copyright Vis.gl contributors. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. ============================================================================== -@lit/reactive-element 2.1.2 (BSD-3-Clause) -Source: https://github.com/lit/lit +@types/geojson 7946.0.16 (MIT) +Source: https://github.com/DefinitelyTyped/DefinitelyTyped ============================================================================== -BSD 3-Clause License +MIT License -Copyright (c) 2017 Google LLC. All rights reserved. + Copyright (c) Microsoft Corporation. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE -3. Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. +============================================================================== +@types/node 25.9.9 (MIT) +Source: https://github.com/DefinitelyTyped/DefinitelyTyped +============================================================================== -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +MIT License + + Copyright (c) Microsoft Corporation. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE + +============================================================================== +@types/offscreencanvas 2019.7.3 (MIT) +Source: https://github.com/DefinitelyTyped/DefinitelyTyped +============================================================================== + +MIT License + + Copyright (c) Microsoft Corporation. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE ============================================================================== @types/trusted-types 2.0.7 (MIT) @@ -71,6 +1332,245 @@ MIT License OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE +============================================================================== +@webgpu/types 0.1.74 (BSD-3-Clause) +Source: https://github.com/gpuweb/types +============================================================================== + +Copyright 2022 WebGPU Developers + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +============================================================================== +apache-arrow 21.2.0 (Apache-2.0) +Source: https://github.com/apache/arrow-js +============================================================================== + +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============================================================================== clone 2.1.2 (MIT) Source: https://github.com/pvorb/node-clone @@ -95,6 +1595,27 @@ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +============================================================================== +earcut 2.2.4 (ISC) +Source: https://github.com/mapbox/earcut +============================================================================== + +ISC License + +Copyright (c) 2016, Mapbox + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + ============================================================================== elkjs 0.3.0 (EPL-1.0) Source: https://github.com/OpenKieler/elkjs @@ -304,6 +1825,220 @@ Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. +============================================================================== +flatbuffers 25.9.23 (Apache-2.0) +Source: https://github.com/google/flatbuffers +============================================================================== + +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +============================================================================== +gl-matrix 3.4.4 (MIT) +Source: https://github.com/toji/gl-matrix +============================================================================== + +Licensed under MIT (declared in package.json). + ============================================================================== golden-layout 2.6.0 (MIT) Source: https://github.com/golden-layout/golden-layout @@ -332,36 +2067,31 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ============================================================================== -leaflet 1.9.4 (BSD-2-Clause) -Source: https://github.com/Leaflet/Leaflet +json-with-bigint 3.5.12 (MIT) +Source: https://github.com/Ivan-Korolenko/json-with-bigint ============================================================================== -BSD 2-Clause License - -Copyright (c) 2010-2023, Volodymyr Agafonkin -Copyright (c) 2010-2011, CloudMade -All rights reserved. +MIT License -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: +Copyright (c) 2023 Ivan Korolenko -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. ============================================================================== lit 3.3.3 (BSD-3-Clause) @@ -518,6 +2248,33 @@ maintained libraries used by this software which have their own licenses; we recommend you read them, as their terms may differ from the terms above. +============================================================================== +mjolnir.js 3.1.1 (MIT) +Source: https://github.com/visgl/mjolnir.js +============================================================================== + +MIT License + +Copyright (c) 2017 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + ============================================================================== netlistsvg 1.0.2 (MIT) Source: https://github.com/nturley/netlistsvg @@ -659,3 +2416,48 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +============================================================================== +tslib 2.8.1 (0BSD) +Source: https://github.com/Microsoft/tslib +============================================================================== + +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + +============================================================================== +undici-types 7.24.6 (MIT) +Source: https://github.com/nodejs/undici +============================================================================== + +MIT License + +Copyright (c) Matteo Collina and Undici contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/web/dist/app.min.js b/src/web/dist/app.min.js index c42e9a5113d..c05a5be4a4d 100644 --- a/src/web/dist/app.min.js +++ b/src/web/dist/app.min.js @@ -1,71 +1,6428 @@ -(()=>{var Y3e=Object.create;var T_t=Object.defineProperty;var K3e=Object.getOwnPropertyDescriptor;var J3e=Object.getOwnPropertyNames;var Q3e=Object.getPrototypeOf,tMe=Object.prototype.hasOwnProperty;var TI=(d=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(d,{get:(s,h)=>(typeof require<"u"?require:s)[h]}):d)(function(d){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+d+'" is not supported')});var Ld=(d,s)=>()=>(s||d((s={exports:{}}).exports,s),s.exports),eMe=(d,s)=>{for(var h in s)T_t(d,h,{get:s[h],enumerable:!0})},nMe=(d,s,h,p)=>{if(s&&typeof s=="object"||typeof s=="function")for(let m of J3e(s))!tMe.call(d,m)&&m!==h&&T_t(d,m,{get:()=>s[m],enumerable:!(p=K3e(s,m))||p.enumerable});return d};var IXt=(d,s,h)=>(h=d!=null?Y3e(Q3e(d)):{},nMe(s||!d||!d.__esModule?T_t(h,"default",{value:d,enumerable:!0}):h,d));var DXt=Ld((gtt,RXt)=>{(function(d,s){typeof gtt=="object"&&typeof RXt<"u"?s(gtt):typeof define=="function"&&define.amd?define(["exports"],s):(d=typeof globalThis<"u"?globalThis:d||self,s(d.leaflet={}))})(gtt,function(d){"use strict";var s="1.9.4";function h(w){var E,D,q,st;for(D=1,q=arguments.length;D"u"||!L||!L.Mixin)){w=X(w)?w:[w];for(var E=0;E0?Math.floor(w):Math.ceil(w)};re.prototype={clone:function(){return new re(this.x,this.y)},add:function(w){return this.clone()._add(Se(w))},_add:function(w){return this.x+=w.x,this.y+=w.y,this},subtract:function(w){return this.clone()._subtract(Se(w))},_subtract:function(w){return this.x-=w.x,this.y-=w.y,this},divideBy:function(w){return this.clone()._divideBy(w)},_divideBy:function(w){return this.x/=w,this.y/=w,this},multiplyBy:function(w){return this.clone()._multiplyBy(w)},_multiplyBy:function(w){return this.x*=w,this.y*=w,this},scaleBy:function(w){return new re(this.x*w.x,this.y*w.y)},unscaleBy:function(w){return new re(this.x/w.x,this.y/w.y)},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.clone()._ceil()},_ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},trunc:function(){return this.clone()._trunc()},_trunc:function(){return this.x=hn(this.x),this.y=hn(this.y),this},distanceTo:function(w){w=Se(w);var E=w.x-this.x,D=w.y-this.y;return Math.sqrt(E*E+D*D)},equals:function(w){return w=Se(w),w.x===this.x&&w.y===this.y},contains:function(w){return w=Se(w),Math.abs(w.x)<=Math.abs(this.x)&&Math.abs(w.y)<=Math.abs(this.y)},toString:function(){return"Point("+B(this.x)+", "+B(this.y)+")"}};function Se(w,E,D){return w instanceof re?w:X(w)?new re(w[0],w[1]):w==null?w:typeof w=="object"&&"x"in w&&"y"in w?new re(w.x,w.y):new re(w,E,D)}function ke(w,E){if(w)for(var D=E?[w,E]:w,q=0,st=D.length;q=this.min.x&&D.x<=this.max.x&&E.y>=this.min.y&&D.y<=this.max.y},intersects:function(w){w=mn(w);var E=this.min,D=this.max,q=w.min,st=w.max,vt=st.x>=E.x&&q.x<=D.x,$t=st.y>=E.y&&q.y<=D.y;return vt&&$t},overlaps:function(w){w=mn(w);var E=this.min,D=this.max,q=w.min,st=w.max,vt=st.x>E.x&&q.xE.y&&q.y=E.lat&&st.lat<=D.lat&&q.lng>=E.lng&&st.lng<=D.lng},intersects:function(w){w=Qn(w);var E=this._southWest,D=this._northEast,q=w.getSouthWest(),st=w.getNorthEast(),vt=st.lat>=E.lat&&q.lat<=D.lat,$t=st.lng>=E.lng&&q.lng<=D.lng;return vt&&$t},overlaps:function(w){w=Qn(w);var E=this._southWest,D=this._northEast,q=w.getSouthWest(),st=w.getNorthEast(),vt=st.lat>E.lat&&q.latE.lng&&q.lng1,oi=function(){var w=!1;try{var E=Object.defineProperty({},"passive",{get:function(){w=!0}});window.addEventListener("testPassiveEventSupport",N,E),window.removeEventListener("testPassiveEventSupport",N,E)}catch{}return w}(),Jr=function(){return!!document.createElement("canvas").getContext}(),Bs=!!(document.createElementNS&&ut("svg").createSVGRect),Oc=!!Bs&&function(){var w=document.createElement("div");return w.innerHTML="",(w.firstChild&&w.firstChild.namespaceURI)==="http://www.w3.org/2000/svg"}(),ru=!Bs&&function(){try{var w=document.createElement("div");w.innerHTML='';var E=w.firstChild;return E.style.behavior="url(#default#VML)",E&&typeof E.adj=="object"}catch{return!1}}(),fc=navigator.platform.indexOf("Mac")===0,il=navigator.platform.indexOf("Linux")===0;function va(w){return navigator.userAgent.toLowerCase().indexOf(w)>=0}var Mr={ie,ielt9:rn,edge:Pn,webkit:Tt,android:yt,android23:ue,androidStock:An,opera:zn,chrome:Li,gecko:xi,safari:Jt,phantom:nn,opera12:vn,win:he,ie3d:Mn,webkit3d:Sn,gecko3d:gn,any3d:Ce,mobile:dn,mobileWebkit:jn,mobileWebkit3d:ar,msPointer:gr,pointer:tr,touch:Qt,touchNative:Ln,mobileOpera:Mi,mobileGecko:sn,retina:Zn,passiveEvents:oi,canvas:Jr,svg:Bs,vml:ru,inlineSvg:Oc,mac:fc,linux:il},tv=Mr.msPointer?"MSPointerDown":"pointerdown",O0=Mr.msPointer?"MSPointerMove":"pointermove",ev=Mr.msPointer?"MSPointerUp":"pointerup",B0=Mr.msPointer?"MSPointerCancel":"pointercancel",F0={touchstart:tv,touchmove:O0,touchend:ev,touchcancel:B0},nv={touchstart:Pr,touchmove:Hi,touchend:Hi,touchcancel:Hi},wg={},iv=!1;function o3(w,E,D){return E==="touchstart"&&Ze(),nv[E]?(D=nv[E].bind(this,D),w.addEventListener(F0[E],D,!1),D):(console.warn("wrong event specified:",E),N)}function Rt(w,E,D){if(!F0[E]){console.warn("wrong event specified:",E);return}w.removeEventListener(F0[E],D,!1)}function ve(w){wg[w.pointerId]=w}function Je(w){wg[w.pointerId]&&(wg[w.pointerId]=w)}function tn(w){delete wg[w.pointerId]}function Ze(){iv||(document.addEventListener(tv,ve,!0),document.addEventListener(O0,Je,!0),document.addEventListener(ev,tn,!0),document.addEventListener(B0,tn,!0),iv=!0)}function Hi(w,E){if(E.pointerType!==(E.MSPOINTER_TYPE_MOUSE||"mouse")){E.touches=[];for(var D in wg)E.touches.push(wg[D]);E.changedTouches=[E],w(E)}}function Pr(w,E){E.MSPOINTER_TYPE_TOUCH&&E.pointerType===E.MSPOINTER_TYPE_TOUCH&&sl(E),Hi(w,E)}function Gr(w){var E={},D,q;for(q in w)D=w[q],E[q]=D&&D.bind?D.bind(w):D;return w=E,E.type="dblclick",E.detail=2,E.isTrusted=!1,E._simulated=!0,E}var hs=200;function Fs(w,E){w.addEventListener("dblclick",E);var D=0,q;function st(vt){if(vt.detail!==1){q=vt.detail;return}if(!(vt.pointerType==="mouse"||vt.sourceCapabilities&&!vt.sourceCapabilities.firesTouchEvents)){var $t=Bc(vt);if(!($t.some(function(Ye){return Ye instanceof HTMLLabelElement&&Ye.attributes.for})&&!$t.some(function(Ye){return Ye instanceof HTMLInputElement||Ye instanceof HTMLSelectElement}))){var _e=Date.now();_e-D<=hs?(q++,q===2&&E(Gr(vt))):q=1,D=_e}}}return w.addEventListener("click",st),{dblclick:E,simDblclick:st}}function Ms(w,E){w.removeEventListener("dblclick",E.dblclick),w.removeEventListener("click",E.simDblclick)}var bs=a1(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),Tc=a1(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),rl=Tc==="webkitTransition"||Tc==="OTransition"?Tc+"End":"transitionend";function Oa(w){return typeof w=="string"?document.getElementById(w):w}function wh(w,E){var D=w.style[E]||w.currentStyle&&w.currentStyle[E];if((!D||D==="auto")&&document.defaultView){var q=document.defaultView.getComputedStyle(w,null);D=q?q[E]:null}return D==="auto"?null:D}function Nr(w,E,D){var q=document.createElement(w);return q.className=E||"",D&&D.appendChild(q),q}function mr(w){var E=w.parentNode;E&&E.removeChild(w)}function c1(w){for(;w.firstChild;)w.removeChild(w.firstChild)}function dc(w){var E=w.parentNode;E&&E.lastChild!==w&&E.appendChild(w)}function vh(w){var E=w.parentNode;E&&E.firstChild!==w&&E.insertBefore(w,E.firstChild)}function vg(w,E){if(w.classList!==void 0)return w.classList.contains(E);var D=ff(w);return D.length>0&&new RegExp("(^|\\s)"+E+"(\\s|$)").test(D)}function ws(w,E){if(w.classList!==void 0)for(var D=U(E),q=0,st=D.length;q0?2*window.devicePixelRatio:1;function _S(w){return Mr.edge?w.wheelDeltaY/2:w.deltaY&&w.deltaMode===0?-w.deltaY/wk:w.deltaY&&w.deltaMode===1?-w.deltaY*20:w.deltaY&&w.deltaMode===2?-w.deltaY*60:w.deltaX||w.deltaZ?0:w.wheelDelta?(w.wheelDeltaY||w.wheelDelta)/2:w.detail&&Math.abs(w.detail)<32765?-w.detail*20:w.detail?w.detail/-32765*60:0}function f3(w,E){var D=E.relatedTarget;if(!D)return!0;try{for(;D&&D!==w;)D=D.parentNode}catch{return!1}return D!==w}var vk={__proto__:null,on:As,off:Vc,stopPropagation:j0,disableScrollPropagation:h3,disableClickPropagation:cv,preventDefault:sl,stop:rc,getPropagationPath:Bc,getMousePosition:vS,getWheelDelta:_S,isExternalTarget:f3,addListener:As,removeListener:Vc},yS=xe.extend({run:function(w,E,D,q){this.stop(),this._el=w,this._inProgress=!0,this._duration=D||.25,this._easeOutPower=1/Math.max(q||.5,.2),this._startPos=_g(w),this._offset=E.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=ot(this._animate,this),this._step()},_step:function(w){var E=+new Date-this._startTime,D=this._duration*1e3;Ethis.options.maxZoom)?this.setZoom(w):this},panInsideBounds:function(w,E){this._enforcingBounds=!0;var D=this.getCenter(),q=this._limitCenter(D,this._zoom,Qn(w));return D.equals(q)||this.panTo(q,E),this._enforcingBounds=!1,this},panInside:function(w,E){E=E||{};var D=Se(E.paddingTopLeft||E.padding||[0,0]),q=Se(E.paddingBottomRight||E.padding||[0,0]),st=this.project(this.getCenter()),vt=this.project(w),$t=this.getPixelBounds(),_e=mn([$t.min.add(D),$t.max.subtract(q)]),Ye=_e.getSize();if(!_e.contains(vt)){this._enforcingBounds=!0;var Un=vt.subtract(_e.getCenter()),Ji=_e.extend(vt).getSize().subtract(Ye);st.x+=Un.x<0?-Ji.x:Ji.x,st.y+=Un.y<0?-Ji.y:Ji.y,this.panTo(this.unproject(st),E),this._enforcingBounds=!1}return this},invalidateSize:function(w){if(!this._loaded)return this;w=h({animate:!1,pan:!0},w===!0?{animate:!0}:w);var E=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var D=this.getSize(),q=E.divideBy(2).round(),st=D.divideBy(2).round(),vt=q.subtract(st);return!vt.x&&!vt.y?this:(w.animate&&w.pan?this.panBy(vt):(w.pan&&this._rawPanBy(vt),this.fire("move"),w.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(m(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:E,newSize:D}))},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(w){if(w=this._locateOptions=h({timeout:1e4,watch:!1},w),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var E=m(this._handleGeolocationResponse,this),D=m(this._handleGeolocationError,this);return w.watch?this._locationWatchId=navigator.geolocation.watchPosition(E,D,w):navigator.geolocation.getCurrentPosition(E,D,w),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(w){if(this._container._leaflet_id){var E=w.code,D=w.message||(E===1?"permission denied":E===2?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:E,message:"Geolocation error: "+D+"."})}},_handleGeolocationResponse:function(w){if(this._container._leaflet_id){var E=w.coords.latitude,D=w.coords.longitude,q=new ge(E,D),st=q.toBounds(w.coords.accuracy*2),vt=this._locateOptions;if(vt.setView){var $t=this.getBoundsZoom(st);this.setView(q,vt.maxZoom?Math.min($t,vt.maxZoom):$t)}var _e={latlng:q,bounds:st,timestamp:w.timestamp};for(var Ye in w.coords)typeof w.coords[Ye]=="number"&&(_e[Ye]=w.coords[Ye]);this.fire("locationfound",_e)}},addHandler:function(w,E){if(!E)return this;var D=this[w]=new E(this);return this._handlers.push(D),this.options[w]&&D.enable(),this},remove:function(){if(this._initEvents(!0),this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch{this._container._leaflet_id=void 0,this._containerId=void 0}this._locationWatchId!==void 0&&this.stopLocate(),this._stop(),mr(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(Lt(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload");var w;for(w in this._layers)this._layers[w].remove();for(w in this._panes)mr(this._panes[w]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(w,E){var D="leaflet-pane"+(w?" leaflet-"+w.replace("Pane","")+"-pane":""),q=Nr("div",D,E||this._mapPane);return w&&(this._panes[w]=q),q},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var w=this.getPixelBounds(),E=this.unproject(w.getBottomLeft()),D=this.unproject(w.getTopRight());return new en(E,D)},getMinZoom:function(){return this.options.minZoom===void 0?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return this.options.maxZoom===void 0?this._layersMaxZoom===void 0?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(w,E,D){w=Qn(w),D=Se(D||[0,0]);var q=this.getZoom()||0,st=this.getMinZoom(),vt=this.getMaxZoom(),$t=w.getNorthWest(),_e=w.getSouthEast(),Ye=this.getSize().subtract(D),Un=mn(this.project(_e,q),this.project($t,q)).getSize(),Ji=Mr.any3d?this.options.zoomSnap:1,Qr=Ye.x/Un.x,Is=Ye.y/Un.y,ol=E?Math.max(Qr,Is):Math.min(Qr,Is);return q=this.getScaleZoom(ol,q),Ji&&(q=Math.round(q/(Ji/100))*(Ji/100),q=E?Math.ceil(q/Ji)*Ji:Math.floor(q/Ji)*Ji),Math.max(st,Math.min(vt,q))},getSize:function(){return(!this._size||this._sizeChanged)&&(this._size=new re(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(w,E){var D=this._getTopLeftPoint(w,E);return new ke(D,D.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(w){return this.options.crs.getProjectedBounds(w===void 0?this.getZoom():w)},getPane:function(w){return typeof w=="string"?this._panes[w]:w},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(w,E){var D=this.options.crs;return E=E===void 0?this._zoom:E,D.scale(w)/D.scale(E)},getScaleZoom:function(w,E){var D=this.options.crs;E=E===void 0?this._zoom:E;var q=D.zoom(w*D.scale(E));return isNaN(q)?1/0:q},project:function(w,E){return E=E===void 0?this._zoom:E,this.options.crs.latLngToPoint(Pe(w),E)},unproject:function(w,E){return E=E===void 0?this._zoom:E,this.options.crs.pointToLatLng(Se(w),E)},layerPointToLatLng:function(w){var E=Se(w).add(this.getPixelOrigin());return this.unproject(E)},latLngToLayerPoint:function(w){var E=this.project(Pe(w))._round();return E._subtract(this.getPixelOrigin())},wrapLatLng:function(w){return this.options.crs.wrapLatLng(Pe(w))},wrapLatLngBounds:function(w){return this.options.crs.wrapLatLngBounds(Qn(w))},distance:function(w,E){return this.options.crs.distance(Pe(w),Pe(E))},containerPointToLayerPoint:function(w){return Se(w).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(w){return Se(w).add(this._getMapPanePos())},containerPointToLatLng:function(w){var E=this.containerPointToLayerPoint(Se(w));return this.layerPointToLatLng(E)},latLngToContainerPoint:function(w){return this.layerPointToContainerPoint(this.latLngToLayerPoint(Pe(w)))},mouseEventToContainerPoint:function(w){return vS(w,this._container)},mouseEventToLayerPoint:function(w){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(w))},mouseEventToLatLng:function(w){return this.layerPointToLatLng(this.mouseEventToLayerPoint(w))},_initContainer:function(w){var E=this._container=Oa(w);if(E){if(E._leaflet_id)throw new Error("Map container is already initialized.")}else throw new Error("Map container not found.");As(E,"scroll",this._onScroll,this),this._containerId=S(E)},_initLayout:function(){var w=this._container;this._fadeAnimated=this.options.fadeAnimation&&Mr.any3d,ws(w,"leaflet-container"+(Mr.touch?" leaflet-touch":"")+(Mr.retina?" leaflet-retina":"")+(Mr.ielt9?" leaflet-oldie":"")+(Mr.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var E=wh(w,"position");E!=="absolute"&&E!=="relative"&&E!=="fixed"&&E!=="sticky"&&(w.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var w=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),ya(this._mapPane,new re(0,0)),this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(ws(w.markerPane,"leaflet-zoom-hide"),ws(w.shadowPane,"leaflet-zoom-hide"))},_resetView:function(w,E,D){ya(this._mapPane,new re(0,0));var q=!this._loaded;this._loaded=!0,E=this._limitZoom(E),this.fire("viewprereset");var st=this._zoom!==E;this._moveStart(st,D)._move(w,E)._moveEnd(st),this.fire("viewreset"),q&&this.fire("load")},_moveStart:function(w,E){return w&&this.fire("zoomstart"),E||this.fire("movestart"),this},_move:function(w,E,D,q){E===void 0&&(E=this._zoom);var st=this._zoom!==E;return this._zoom=E,this._lastCenter=w,this._pixelOrigin=this._getNewPixelOrigin(w),q?D&&D.pinch&&this.fire("zoom",D):((st||D&&D.pinch)&&this.fire("zoom",D),this.fire("move",D)),this},_moveEnd:function(w){return w&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return Lt(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(w){ya(this._mapPane,this._getMapPanePos().subtract(w))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(w){this._targets={},this._targets[S(this._container)]=this;var E=w?Vc:As;E(this._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&E(window,"resize",this._onResize,this),Mr.any3d&&this.options.transform3DLimit&&(w?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){Lt(this._resizeRequest),this._resizeRequest=ot(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var w=this._getMapPanePos();Math.max(Math.abs(w.x),Math.abs(w.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(w,E){for(var D=[],q,st=E==="mouseout"||E==="mouseover",vt=w.target||w.srcElement,$t=!1;vt;){if(q=this._targets[S(vt)],q&&(E==="click"||E==="preclick")&&this._draggableMoved(q)){$t=!0;break}if(q&&q.listens(E,!0)&&(st&&!f3(vt,w)||(D.push(q),st))||vt===this._container)break;vt=vt.parentNode}return!D.length&&!$t&&!st&&this.listens(E,!0)&&(D=[this]),D},_isClickDisabled:function(w){for(;w&&w!==this._container;){if(w._leaflet_disable_click)return!0;w=w.parentNode}},_handleDOMEvent:function(w){var E=w.target||w.srcElement;if(!(!this._loaded||E._leaflet_disable_events||w.type==="click"&&this._isClickDisabled(E))){var D=w.type;D==="mousedown"&&Ty(E),this._fireDOMEvent(w,D)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(w,E,D){if(w.type==="click"){var q=h({},w);q.type="preclick",this._fireDOMEvent(q,q.type,D)}var st=this._findEventTargets(w,E);if(D){for(var vt=[],$t=0;$t0?Math.round(w-E)/2:Math.max(0,Math.ceil(w))-Math.max(0,Math.floor(E))},_limitZoom:function(w){var E=this.getMinZoom(),D=this.getMaxZoom(),q=Mr.any3d?this.options.zoomSnap:1;return q&&(w=Math.round(w/q)*q),Math.max(E,Math.min(D,w))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){$c(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(w,E){var D=this._getCenterOffset(w)._trunc();return(E&&E.animate)!==!0&&!this.getSize().contains(D)?!1:(this.panBy(D,E),!0)},_createAnimProxy:function(){var w=this._proxy=Nr("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(w),this.on("zoomanim",function(E){var D=bs,q=this._proxy.style[D];Nd(this._proxy,this.project(E.center,E.zoom),this.getZoomScale(E.zoom,1)),q===this._proxy.style[D]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",this._animMoveEnd,this),this._on("unload",this._destroyAnimProxy,this)},_destroyAnimProxy:function(){mr(this._proxy),this.off("load moveend",this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var w=this.getCenter(),E=this.getZoom();Nd(this._proxy,this.project(w,E),this.getZoomScale(E,1))},_catchTransitionEnd:function(w){this._animatingZoom&&w.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(w,E,D){if(this._animatingZoom)return!0;if(D=D||{},!this._zoomAnimated||D.animate===!1||this._nothingToAnimate()||Math.abs(E-this._zoom)>this.options.zoomAnimationThreshold)return!1;var q=this.getZoomScale(E),st=this._getCenterOffset(w)._divideBy(1-1/q);return D.animate!==!0&&!this.getSize().contains(st)?!1:(ot(function(){this._moveStart(!0,D.noMoveStart||!1)._animateZoom(w,E,!0)},this),!0)},_animateZoom:function(w,E,D,q){this._mapPane&&(D&&(this._animatingZoom=!0,this._animateToCenter=w,this._animateToZoom=E,ws(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:w,zoom:E,noUpdate:q}),this._tempFireZoomEvent||(this._tempFireZoomEvent=this._zoom!==this._animateToZoom),this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(m(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&$c(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire("zoom"),delete this._tempFireZoomEvent,this.fire("move"),this._moveEnd(!0))}});function _k(w,E){return new Co(w,E)}var Cc=ln.extend({options:{position:"topright"},initialize:function(w){j(this,w)},getPosition:function(){return this.options.position},setPosition:function(w){var E=this._map;return E&&E.removeControl(this),this.options.position=w,E&&E.addControl(this),this},getContainer:function(){return this._container},addTo:function(w){this.remove(),this._map=w;var E=this._container=this.onAdd(w),D=this.getPosition(),q=w._controlCorners[D];return ws(E,"leaflet-control"),D.indexOf("bottom")!==-1?q.insertBefore(E,q.firstChild):q.appendChild(E),this._map.on("unload",this.remove,this),this},remove:function(){return this._map?(mr(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null,this):this},_refocusOnMap:function(w){this._map&&w&&w.screenX>0&&w.screenY>0&&this._map.getContainer().focus()}}),H0=function(w){return new Cc(w)};Co.include({addControl:function(w){return w.addTo(this),this},removeControl:function(w){return w.remove(),this},_initControlPos:function(){var w=this._controlCorners={},E="leaflet-",D=this._controlContainer=Nr("div",E+"control-container",this._container);function q(st,vt){var $t=E+st+" "+E+vt;w[st+vt]=Nr("div",$t,D)}q("top","left"),q("top","right"),q("bottom","left"),q("bottom","right")},_clearControlPos:function(){for(var w in this._controlCorners)mr(this._controlCorners[w]);mr(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var xg=Cc.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(w,E,D,q){return D1,this._baseLayersList.style.display=w?"":"none"),this._separator.style.display=E&&w?"":"none",this},_onLayerChange:function(w){this._handlingClick||this._update();var E=this._getLayer(S(w.target)),D=E.overlay?w.type==="add"?"overlayadd":"overlayremove":w.type==="add"?"baselayerchange":null;D&&this._map.fire(D,E)},_createRadioElement:function(w,E){var D='",q=document.createElement("div");return q.innerHTML=D,q.firstChild},_addItem:function(w){var E=document.createElement("label"),D=this._map.hasLayer(w.layer),q;w.overlay?(q=document.createElement("input"),q.type="checkbox",q.className="leaflet-control-layers-selector",q.defaultChecked=D):q=this._createRadioElement("leaflet-base-layers_"+S(this),D),this._layerControlInputs.push(q),q.layerId=S(w.layer),As(q,"click",this._onInputClick,this);var st=document.createElement("span");st.innerHTML=" "+w.name;var vt=document.createElement("span");E.appendChild(vt),vt.appendChild(q),vt.appendChild(st);var $t=w.overlay?this._overlaysList:this._baseLayersList;return $t.appendChild(E),this._checkDisabledLayers(),E},_onInputClick:function(){if(!this._preventClick){var w=this._layerControlInputs,E,D,q=[],st=[];this._handlingClick=!0;for(var vt=w.length-1;vt>=0;vt--)E=w[vt],D=this._getLayer(E.layerId).layer,E.checked?q.push(D):E.checked||st.push(D);for(vt=0;vt=0;st--)E=w[st],D=this._getLayer(E.layerId).layer,E.disabled=D.options.minZoom!==void 0&&qD.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expandSafely:function(){var w=this._section;this._preventClick=!0,As(w,"click",sl),this.expand();var E=this;setTimeout(function(){Vc(w,"click",sl),E._preventClick=!1})}}),xS=function(w,E,D){return new xg(w,E,D)},av=Cc.extend({options:{position:"topleft",zoomInText:'',zoomInTitle:"Zoom in",zoomOutText:'',zoomOutTitle:"Zoom out"},onAdd:function(w){var E="leaflet-control-zoom",D=Nr("div",E+" leaflet-bar"),q=this.options;return this._zoomInButton=this._createButton(q.zoomInText,q.zoomInTitle,E+"-in",D,this._zoomIn),this._zoomOutButton=this._createButton(q.zoomOutText,q.zoomOutTitle,E+"-out",D,this._zoomOut),this._updateDisabled(),w.on("zoomend zoomlevelschange",this._updateDisabled,this),D},onRemove:function(w){w.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(w){!this._disabled&&this._map._zoomthis._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(w.shiftKey?3:1))},_createButton:function(w,E,D,q,st){var vt=Nr("a",D,q);return vt.innerHTML=w,vt.href="#",vt.title=E,vt.setAttribute("role","button"),vt.setAttribute("aria-label",E),cv(vt),As(vt,"click",rc),As(vt,"click",st,this),As(vt,"click",this._refocusOnMap,this),vt},_updateDisabled:function(){var w=this._map,E="leaflet-disabled";$c(this._zoomInButton,E),$c(this._zoomOutButton,E),this._zoomInButton.setAttribute("aria-disabled","false"),this._zoomOutButton.setAttribute("aria-disabled","false"),(this._disabled||w._zoom===w.getMinZoom())&&(ws(this._zoomOutButton,E),this._zoomOutButton.setAttribute("aria-disabled","true")),(this._disabled||w._zoom===w.getMaxZoom())&&(ws(this._zoomInButton,E),this._zoomInButton.setAttribute("aria-disabled","true"))}});Co.mergeOptions({zoomControl:!0}),Co.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new av,this.addControl(this.zoomControl))});var Xf=function(w){return new av(w)},d3=Cc.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(w){var E="leaflet-control-scale",D=Nr("div",E),q=this.options;return this._addScales(q,E+"-line",D),w.on(q.updateWhenIdle?"moveend":"move",this._update,this),w.whenReady(this._update,this),D},onRemove:function(w){w.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(w,E,D){w.metric&&(this._mScale=Nr("div",E,D)),w.imperial&&(this._iScale=Nr("div",E,D))},_update:function(){var w=this._map,E=w.getSize().y/2,D=w.distance(w.containerPointToLatLng([0,E]),w.containerPointToLatLng([this.options.maxWidth,E]));this._updateScales(D)},_updateScales:function(w){this.options.metric&&w&&this._updateMetric(w),this.options.imperial&&w&&this._updateImperial(w)},_updateMetric:function(w){var E=this._getRoundNum(w),D=E<1e3?E+" m":E/1e3+" km";this._updateScale(this._mScale,D,E/w)},_updateImperial:function(w){var E=w*3.2808399,D,q,st;E>5280?(D=E/5280,q=this._getRoundNum(D),this._updateScale(this._iScale,q+" mi",q/D)):(st=this._getRoundNum(E),this._updateScale(this._iScale,st+" ft",st/E))},_updateScale:function(w,E,D){w.style.width=Math.round(this.options.maxWidth*D)+"px",w.innerHTML=E},_getRoundNum:function(w){var E=Math.pow(10,(Math.floor(w)+"").length-1),D=w/E;return D=D>=10?10:D>=5?5:D>=3?3:D>=2?2:1,E*D}}),MS=function(w){return new d3(w)},ES='',Cy=Cc.extend({options:{position:"bottomright",prefix:''+(Mr.inlineSvg?ES+" ":"")+"Leaflet"},initialize:function(w){j(this,w),this._attributions={}},onAdd:function(w){w.attributionControl=this,this._container=Nr("div","leaflet-control-attribution"),cv(this._container);for(var E in w._layers)w._layers[E].getAttribution&&this.addAttribution(w._layers[E].getAttribution());return this._update(),w.on("layeradd",this._addAttribution,this),this._container},onRemove:function(w){w.off("layeradd",this._addAttribution,this)},_addAttribution:function(w){w.layer.getAttribution&&(this.addAttribution(w.layer.getAttribution()),w.layer.once("remove",function(){this.removeAttribution(w.layer.getAttribution())},this))},setPrefix:function(w){return this.options.prefix=w,this._update(),this},addAttribution:function(w){return w?(this._attributions[w]||(this._attributions[w]=0),this._attributions[w]++,this._update(),this):this},removeAttribution:function(w){return w?(this._attributions[w]&&(this._attributions[w]--,this._update()),this):this},_update:function(){if(this._map){var w=[];for(var E in this._attributions)this._attributions[E]&&w.push(E);var D=[];this.options.prefix&&D.push(this.options.prefix),w.length&&D.push(w.join(", ")),this._container.innerHTML=D.join(' ')}}});Co.mergeOptions({attributionControl:!0}),Co.addInitHook(function(){this.options.attributionControl&&new Cy().addTo(this)});var SS=function(w){return new Cy(w)};Cc.Layers=xg,Cc.Zoom=av,Cc.Scale=d3,Cc.Attribution=Cy,H0.layers=xS,H0.zoom=Xf,H0.scale=MS,H0.attribution=SS;var Od=ln.extend({initialize:function(w){this._map=w},enable:function(){return this._enabled?this:(this._enabled=!0,this.addHooks(),this)},disable:function(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this},enabled:function(){return!!this._enabled}});Od.addTo=function(w,E){return w.addHandler(E,this),this};var df={Events:ne},TS=Mr.touch?"touchstart mousedown":"mousedown",su=xe.extend({options:{clickTolerance:3},initialize:function(w,E,D,q){j(this,q),this._element=w,this._dragStartTarget=E||w,this._preventOutline=D},enable:function(){this._enabled||(As(this._dragStartTarget,TS,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(su._dragging===this&&this.finishDrag(!0),Vc(this._dragStartTarget,TS,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(w){if(this._enabled&&(this._moved=!1,!vg(this._element,"leaflet-zoom-anim"))){if(w.touches&&w.touches.length!==1){su._dragging===this&&this.finishDrag();return}if(!(su._dragging||w.shiftKey||w.which!==1&&w.button!==1&&!w.touches)&&(su._dragging=this,this._preventOutline&&Ty(this._element),Ey(),U0(),!this._moving)){this.fire("down");var E=w.touches?w.touches[0]:w,D=bS(this._element);this._startPoint=new re(E.clientX,E.clientY),this._startPos=_g(this._element),this._parentScale=a3(D);var q=w.type==="mousedown";As(document,q?"mousemove":"touchmove",this._onMove,this),As(document,q?"mouseup":"touchend touchcancel",this._onUp,this)}}},_onMove:function(w){if(this._enabled){if(w.touches&&w.touches.length>1){this._moved=!0;return}var E=w.touches&&w.touches.length===1?w.touches[0]:w,D=new re(E.clientX,E.clientY)._subtract(this._startPoint);!D.x&&!D.y||Math.abs(D.x)+Math.abs(D.y)vt&&($t=_e,vt=Ye);vt>D&&(E[$t]=1,m3(w,E,D,q,$t),m3(w,E,D,$t,st))}function b3(w,E){for(var D=[w[0]],q=1,st=0,vt=w.length;qE&&(D.push(w[q]),st=q);return stE.max.x&&(D|=2),w.yE.max.y&&(D|=8),D}function Py(w,E){var D=E.x-w.x,q=E.y-w.y;return D*D+q*q}function vp(w,E,D,q){var st=E.x,vt=E.y,$t=D.x-st,_e=D.y-vt,Ye=$t*$t+_e*_e,Un;return Ye>0&&(Un=((w.x-st)*$t+(w.y-vt)*_e)/Ye,Un>1?(st=D.x,vt=D.y):Un>0&&(st+=$t*Un,vt+=_e*Un)),$t=w.x-st,_e=w.y-vt,q?$t*$t+_e*_e:new re(st,vt)}function Zf(w){return!X(w[0])||typeof w[0][0]!="object"&&typeof w[0][0]<"u"}function w3(w){return console.warn("Deprecated use of _flat, please use L.LineUtil.isFlat instead."),Zf(w)}function v3(w,E){var D,q,st,vt,$t,_e,Ye,Un;if(!w||w.length===0)throw new Error("latlngs not passed");Zf(w)||(console.warn("latlngs are not flat! Only the first ring will be used"),w=w[0]);var Ji=Pe([0,0]),Qr=Qn(w),Is=Qr.getNorthWest().distanceTo(Qr.getSouthWest())*Qr.getNorthEast().distanceTo(Qr.getNorthWest());Is<1700&&(Ji=wp(w));var ol=w.length,xa=[];for(D=0;Dq){Ye=(vt-q)/st,Un=[_e.x-Ye*(_e.x-$t.x),_e.y-Ye*(_e.y-$t.y)];break}var Uu=E.unproject(Se(Un));return Pe([Uu.lat+Ji.lat,Uu.lng+Ji.lng])}var _3={__proto__:null,simplify:ky,pointToSegmentDistance:ea,closestPointOnSegment:Mg,clipSegment:kS,_getEdgeIntersection:Ly,_getBitCode:Eg,_sqClosestPointOnSegment:vp,isFlat:Zf,_flat:w3,polylineCenter:v3},uv={project:function(w){return new re(w.lng,w.lat)},unproject:function(w){return new ge(w.y,w.x)},bounds:new ke([-180,-90],[180,90])},Iy={R:6378137,R_MINOR:6356752314245179e-9,bounds:new ke([-2003750834279e-5,-1549657073972e-5],[2003750834279e-5,1876465623138e-5]),project:function(w){var E=Math.PI/180,D=this.R,q=w.lat*E,st=this.R_MINOR/D,vt=Math.sqrt(1-st*st),$t=vt*Math.sin(q),_e=Math.tan(Math.PI/4-q/2)/Math.pow((1-$t)/(1+$t),vt/2);return q=-D*Math.log(Math.max(_e,1e-10)),new re(w.lng*E*D,q)},unproject:function(w){for(var E=180/Math.PI,D=this.R,q=this.R_MINOR/D,st=Math.sqrt(1-q*q),vt=Math.exp(-w.y/D),$t=Math.PI/2-2*Math.atan(vt),_e=0,Ye=.1,Un;_e<15&&Math.abs(Ye)>1e-7;_e++)Un=st*Math.sin($t),Un=Math.pow((1-Un)/(1+Un),st/2),Ye=Math.PI/2-2*Math.atan(vt*Un)-$t,$t+=Ye;return new ge($t*E,w.x*E/D)}},yk={__proto__:null,LonLat:uv,Mercator:Iy,SphericalMercator:lr},y3=h({},Yi,{code:"EPSG:3395",projection:Iy,transformation:function(){var w=.5/(Math.PI*Iy.R);return Kt(w,.5,-w,.5)}()}),Ry=h({},Yi,{code:"EPSG:4326",projection:uv,transformation:Kt(1/180,1,-1/180,.5)}),xk=h({},ti,{projection:uv,transformation:Kt(1,0,-1,0),scale:function(w){return Math.pow(2,w)},zoom:function(w){return Math.log(w)/Math.LN2},distance:function(w,E){var D=E.lng-w.lng,q=E.lat-w.lat;return Math.sqrt(D*D+q*q)},infinite:!0});ti.Earth=Yi,ti.EPSG3395=y3,ti.EPSG3857=wn,ti.EPSG900913=it,ti.EPSG4326=Ry,ti.Simple=xk;var Yf=xe.extend({options:{pane:"overlayPane",attribution:null,bubblingMouseEvents:!0},addTo:function(w){return w.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(w){return w&&w.removeLayer(this),this},getPane:function(w){return this._map.getPane(w?this.options[w]||w:this.options.pane)},addInteractiveTarget:function(w){return this._map._targets[S(w)]=this,this},removeInteractiveTarget:function(w){return delete this._map._targets[S(w)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(w){var E=w.target;if(E.hasLayer(this)){if(this._map=E,this._zoomAnimated=E._zoomAnimated,this.getEvents){var D=this.getEvents();E.on(D,this),this.once("remove",function(){E.off(D,this)},this)}this.onAdd(E),this.fire("add"),E.fire("layeradd",{layer:this})}}});Co.include({addLayer:function(w){if(!w._layerAdd)throw new Error("The provided object is not a Layer.");var E=S(w);return this._layers[E]?this:(this._layers[E]=w,w._mapToAdd=this,w.beforeAdd&&w.beforeAdd(this),this.whenReady(w._layerAdd,w),this)},removeLayer:function(w){var E=S(w);return this._layers[E]?(this._loaded&&w.onRemove(this),delete this._layers[E],this._loaded&&(this.fire("layerremove",{layer:w}),w.fire("remove")),w._map=w._mapToAdd=null,this):this},hasLayer:function(w){return S(w)in this._layers},eachLayer:function(w,E){for(var D in this._layers)w.call(E,this._layers[D]);return this},_addLayers:function(w){w=w?X(w)?w:[w]:[];for(var E=0,D=w.length;Ethis._layersMaxZoom&&this.setZoom(this._layersMaxZoom),this.options.minZoom===void 0&&this._layersMinZoom&&this.getZoom()=2&&E[0]instanceof ge&&E[0].equals(E[D-1])&&E.pop(),E},_setLatLngs:function(w){Fl.prototype._setLatLngs.call(this,w),Zf(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return Zf(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var w=this._renderer._bounds,E=this.options.weight,D=new re(E,E);if(w=new ke(w.min.subtract(D),w.max.add(D)),this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(w))){if(this.options.noClip){this._parts=this._rings;return}for(var q=0,st=this._rings.length,vt;qw.y!=st.y>w.y&&w.x<(st.x-q.x)*(w.y-q.y)/(st.y-q.y)+q.x&&(E=!E);return E||Fl.prototype._containsPoint.call(this,w,!0)}});function Tk(w,E){return new bb(w,E)}var u1=pf.extend({initialize:function(w,E){j(this,E),this._layers={},w&&this.addData(w)},addData:function(w){var E=X(w)?w:w.features,D,q,st;if(E){for(D=0,q=E.length;D0&&st.push(st[0].slice()),st}function wb(w,E){return w.feature?h({},w.feature,{geometry:E}):zy(E)}function zy(w){return w.type==="Feature"||w.type==="FeatureCollection"?w:{type:"Feature",properties:{},geometry:w}}var Bd={toGeoJSON:function(w){return wb(this,{type:"Point",coordinates:M3(this.getLatLng(),w)})}};Dy.include(Bd),hv.include(Bd),Ny.include(Bd),Fl.include({toGeoJSON:function(w){var E=!Zf(this._latlngs),D=Uy(this._latlngs,E?1:0,!1,w);return wb(this,{type:(E?"Multi":"")+"LineString",coordinates:D})}}),bb.include({toGeoJSON:function(w){var E=!Zf(this._latlngs),D=E&&!Zf(this._latlngs[0]),q=Uy(this._latlngs,D?2:E?1:0,!0,w);return E||(q=[q]),wb(this,{type:(D?"Multi":"")+"Polygon",coordinates:q})}}),Fu.include({toMultiPoint:function(w){var E=[];return this.eachLayer(function(D){E.push(D.toGeoJSON(w).geometry.coordinates)}),wb(this,{type:"MultiPoint",coordinates:E})},toGeoJSON:function(w){var E=this.feature&&this.feature.geometry&&this.feature.geometry.type;if(E==="MultiPoint")return this.toMultiPoint(w);var D=E==="GeometryCollection",q=[];return this.eachLayer(function(st){if(st.toGeoJSON){var vt=st.toGeoJSON(w);if(D)q.push(vt.geometry);else{var $t=zy(vt);$t.type==="FeatureCollection"?q.push.apply(q,$t.features):q.push($t)}}}),D?wb(this,{geometries:q,type:"GeometryCollection"}):{type:"FeatureCollection",features:q}}});function oe(w,E){return new u1(w,E)}var _n=oe,$e=Yf.extend({options:{opacity:1,alt:"",interactive:!1,crossOrigin:!1,errorOverlayUrl:"",zIndex:1,className:""},initialize:function(w,E,D){this._url=w,this._bounds=Qn(E),j(this,D)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(ws(this._image,"leaflet-interactive"),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){mr(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(w){return this.options.opacity=w,this._image&&this._updateOpacity(),this},setStyle:function(w){return w.opacity&&this.setOpacity(w.opacity),this},bringToFront:function(){return this._map&&dc(this._image),this},bringToBack:function(){return this._map&&vh(this._image),this},setUrl:function(w){return this._url=w,this._image&&(this._image.src=w),this},setBounds:function(w){return this._bounds=Qn(w),this._map&&this._reset(),this},getEvents:function(){var w={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(w.zoomanim=this._animateZoom),w},setZIndex:function(w){return this.options.zIndex=w,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var w=this._url.tagName==="IMG",E=this._image=w?this._url:Nr("img");if(ws(E,"leaflet-image-layer"),this._zoomAnimated&&ws(E,"leaflet-zoom-animated"),this.options.className&&ws(E,this.options.className),E.onselectstart=N,E.onmousemove=N,E.onload=m(this.fire,this,"load"),E.onerror=m(this._overlayOnError,this,"error"),(this.options.crossOrigin||this.options.crossOrigin==="")&&(E.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),w){this._url=E.src;return}E.src=this._url,E.alt=this.options.alt},_animateZoom:function(w){var E=this._map.getZoomScale(w.zoom),D=this._map._latLngBoundsToNewLayerBounds(this._bounds,w.zoom,w.center).min;Nd(this._image,D,E)},_reset:function(){var w=this._image,E=new ke(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),D=E.getSize();ya(w,E.min),w.style.width=D.x+"px",w.style.height=D.y+"px"},_updateOpacity:function(){Bl(this._image,this.options.opacity)},_updateZIndex:function(){this._image&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._image.style.zIndex=this.options.zIndex)},_overlayOnError:function(){this.fire("error");var w=this.options.errorOverlayUrl;w&&this._url!==w&&(this._url=w,this._image.src=w)},getCenter:function(){return this._bounds.getCenter()}}),er=function(w,E,D){return new $e(w,E,D)},vs=$e.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0},_initImage:function(){var w=this._url.tagName==="VIDEO",E=this._image=w?this._url:Nr("video");if(ws(E,"leaflet-image-layer"),this._zoomAnimated&&ws(E,"leaflet-zoom-animated"),this.options.className&&ws(E,this.options.className),E.onselectstart=N,E.onmousemove=N,E.onloadeddata=m(this.fire,this,"load"),w){for(var D=E.getElementsByTagName("source"),q=[],st=0;st0?q:[E.src];return}X(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(E.style,"objectFit")&&(E.style.objectFit="fill"),E.autoplay=!!this.options.autoplay,E.loop=!!this.options.loop,E.muted=!!this.options.muted,E.playsInline=!!this.options.playsInline;for(var vt=0;vtst?(E.height=st+"px",ws(w,vt)):$c(w,vt),this._containerWidth=this._container.offsetWidth},_animateZoom:function(w){var E=this._map._latLngToNewLayerPoint(this._latlng,w.zoom,w.center),D=this._getAnchor();ya(this._container,E.add(D))},_adjustPan:function(){if(this.options.autoPan){if(this._map._panAnim&&this._map._panAnim.stop(),this._autopanning){this._autopanning=!1;return}var w=this._map,E=parseInt(wh(this._container,"marginBottom"),10)||0,D=this._container.offsetHeight+E,q=this._containerWidth,st=new re(this._containerLeft,-D-this._containerBottom);st._add(_g(this._container));var vt=w.layerPointToContainerPoint(st),$t=Se(this.options.autoPanPadding),_e=Se(this.options.autoPanPaddingTopLeft||$t),Ye=Se(this.options.autoPanPaddingBottomRight||$t),Un=w.getSize(),Ji=0,Qr=0;vt.x+q+Ye.x>Un.x&&(Ji=vt.x+q-Un.x+Ye.x),vt.x-Ji-_e.x<0&&(Ji=vt.x-_e.x),vt.y+D+Ye.y>Un.y&&(Qr=vt.y+D-Un.y+Ye.y),vt.y-Qr-_e.y<0&&(Qr=vt.y-_e.y),(Ji||Qr)&&(this.options.keepInView&&(this._autopanning=!0),w.fire("autopanstart").panBy([Ji,Qr]))}},_getAnchor:function(){return Se(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}),Jf=function(w,E){return new jy(w,E)};Co.mergeOptions({closePopupOnClick:!0}),Co.include({openPopup:function(w,E,D){return this._initOverlay(jy,w,E,D).openOn(this),this},closePopup:function(w){return w=arguments.length?w:this._popup,w&&w.close(),this}}),Yf.include({bindPopup:function(w,E){return this._popup=this._initOverlay(jy,this._popup,w,E),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(w){return this._popup&&(this instanceof pf||(this._popup._source=this),this._popup._prepareOpen(w||this._latlng)&&this._popup.openOn(this._map)),this},closePopup:function(){return this._popup&&this._popup.close(),this},togglePopup:function(){return this._popup&&this._popup.toggle(this),this},isPopupOpen:function(){return this._popup?this._popup.isOpen():!1},setPopupContent:function(w){return this._popup&&this._popup.setContent(w),this},getPopup:function(){return this._popup},_openPopup:function(w){if(!(!this._popup||!this._map)){rc(w);var E=w.layer||w.target;if(this._popup._source===E&&!(E instanceof gf)){this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(w.latlng);return}this._popup._source=E,this.openPopup(w.latlng)}},_movePopup:function(w){this._popup.setLatLng(w.latlng)},_onKeyPress:function(w){w.originalEvent.keyCode===13&&this._openPopup(w)}});var W0=mf.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:.9},onAdd:function(w){mf.prototype.onAdd.call(this,w),this.setOpacity(this.options.opacity),w.fire("tooltipopen",{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0))},onRemove:function(w){mf.prototype.onRemove.call(this,w),w.fire("tooltipclose",{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0))},getEvents:function(){var w=mf.prototype.getEvents.call(this);return this.options.permanent||(w.preclick=this.close),w},_initLayout:function(){var w="leaflet-tooltip",E=w+" "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=Nr("div",E),this._container.setAttribute("role","tooltip"),this._container.setAttribute("id","leaflet-tooltip-"+S(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(w){var E,D,q=this._map,st=this._container,vt=q.latLngToContainerPoint(q.getCenter()),$t=q.layerPointToContainerPoint(w),_e=this.options.direction,Ye=st.offsetWidth,Un=st.offsetHeight,Ji=Se(this.options.offset),Qr=this._getAnchor();_e==="top"?(E=Ye/2,D=Un):_e==="bottom"?(E=Ye/2,D=0):_e==="center"?(E=Ye/2,D=Un/2):_e==="right"?(E=0,D=Un/2):_e==="left"?(E=Ye,D=Un/2):$t.xthis.options.maxZoom||Dq?this._retainParent(st,vt,$t,q):!1)},_retainChildren:function(w,E,D,q){for(var st=2*w;st<2*w+2;st++)for(var vt=2*E;vt<2*E+2;vt++){var $t=new re(st,vt);$t.z=D+1;var _e=this._tileCoordsToKey($t),Ye=this._tiles[_e];if(Ye&&Ye.active){Ye.retain=!0;continue}else Ye&&Ye.loaded&&(Ye.retain=!0);D+1this.options.maxZoom||this.options.minZoom!==void 0&&st1){this._setView(w,D);return}for(var Qr=st.min.y;Qr<=st.max.y;Qr++)for(var Is=st.min.x;Is<=st.max.x;Is++){var ol=new re(Is,Qr);if(ol.z=this._tileZoom,!!this._isValidTile(ol)){var xa=this._tiles[this._tileCoordsToKey(ol)];xa?xa.current=!0:$t.push(ol)}}if($t.sort(function(Uu,f1){return Uu.distanceTo(vt)-f1.distanceTo(vt)}),$t.length!==0){this._loading||(this._loading=!0,this.fire("loading"));var Ul=document.createDocumentFragment();for(Is=0;Is<$t.length;Is++)this._addTile($t[Is],Ul);this._level.el.appendChild(Ul)}}}},_isValidTile:function(w){var E=this._map.options.crs;if(!E.infinite){var D=this._globalTileRange;if(!E.wrapLng&&(w.xD.max.x)||!E.wrapLat&&(w.yD.max.y))return!1}if(!this.options.bounds)return!0;var q=this._tileCoordsToBounds(w);return Qn(this.options.bounds).overlaps(q)},_keyToBounds:function(w){return this._tileCoordsToBounds(this._keyToTileCoords(w))},_tileCoordsToNwSe:function(w){var E=this._map,D=this.getTileSize(),q=w.scaleBy(D),st=q.add(D),vt=E.unproject(q,w.z),$t=E.unproject(st,w.z);return[vt,$t]},_tileCoordsToBounds:function(w){var E=this._tileCoordsToNwSe(w),D=new en(E[0],E[1]);return this.options.noWrap||(D=this._map.wrapLatLngBounds(D)),D},_tileCoordsToKey:function(w){return w.x+":"+w.y+":"+w.z},_keyToTileCoords:function(w){var E=w.split(":"),D=new re(+E[0],+E[1]);return D.z=+E[2],D},_removeTile:function(w){var E=this._tiles[w];E&&(mr(E.el),delete this._tiles[w],this.fire("tileunload",{tile:E.el,coords:this._keyToTileCoords(w)}))},_initTile:function(w){ws(w,"leaflet-tile");var E=this.getTileSize();w.style.width=E.x+"px",w.style.height=E.y+"px",w.onselectstart=N,w.onmousemove=N,Mr.ielt9&&this.options.opacity<1&&Bl(w,this.options.opacity)},_addTile:function(w,E){var D=this._getTilePos(w),q=this._tileCoordsToKey(w),st=this.createTile(this._wrapCoords(w),m(this._tileReady,this,w));this._initTile(st),this.createTile.length<2&&ot(m(this._tileReady,this,w,null,st)),ya(st,D),this._tiles[q]={el:st,coords:w,current:!0},E.appendChild(st),this.fire("tileloadstart",{tile:st,coords:w})},_tileReady:function(w,E,D){E&&this.fire("tileerror",{error:E,tile:D,coords:w});var q=this._tileCoordsToKey(w);D=this._tiles[q],D&&(D.loaded=+new Date,this._map._fadeAnimated?(Bl(D.el,0),Lt(this._fadeFrame),this._fadeFrame=ot(this._updateOpacity,this)):(D.active=!0,this._pruneTiles()),E||(ws(D.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:D.el,coords:w})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),Mr.ielt9||!this._map._fadeAnimated?ot(this._pruneTiles,this):setTimeout(m(this._pruneTiles,this),250)))},_getTilePos:function(w){return w.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(w){var E=new re(this._wrapX?I(w.x,this._wrapX):w.x,this._wrapY?I(w.y,this._wrapY):w.y);return E.z=w.z,E},_pxBoundsToTileRange:function(w){var E=this.getTileSize();return new ke(w.min.unscaleBy(E).floor(),w.max.unscaleBy(E).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var w in this._tiles)if(!this._tiles[w].loaded)return!1;return!0}});function pc(w){return new Sg(w)}var vb=Sg.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(w,E){this._url=w,E=j(this,E),E.detectRetina&&Mr.retina&&E.maxZoom>0?(E.tileSize=Math.floor(E.tileSize/2),E.zoomReverse?(E.zoomOffset--,E.minZoom=Math.min(E.maxZoom,E.minZoom+1)):(E.zoomOffset++,E.maxZoom=Math.max(E.minZoom,E.maxZoom-1)),E.minZoom=Math.max(0,E.minZoom)):E.zoomReverse?E.minZoom=Math.min(E.maxZoom,E.minZoom):E.maxZoom=Math.max(E.minZoom,E.maxZoom),typeof E.subdomains=="string"&&(E.subdomains=E.subdomains.split("")),this.on("tileunload",this._onTileRemove)},setUrl:function(w,E){return this._url===w&&E===void 0&&(E=!0),this._url=w,E||this.redraw(),this},createTile:function(w,E){var D=document.createElement("img");return As(D,"load",m(this._tileOnLoad,this,E,D)),As(D,"error",m(this._tileOnError,this,E,D)),(this.options.crossOrigin||this.options.crossOrigin==="")&&(D.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),typeof this.options.referrerPolicy=="string"&&(D.referrerPolicy=this.options.referrerPolicy),D.alt="",D.src=this.getTileUrl(w),D},getTileUrl:function(w){var E={r:Mr.retina?"@2x":"",s:this._getSubdomain(w),x:w.x,y:w.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var D=this._globalTileRange.max.y-w.y;this.options.tms&&(E.y=D),E["-y"]=D}return Q(this._url,h(E,this.options))},_tileOnLoad:function(w,E){Mr.ielt9?setTimeout(m(w,this,null,E),0):w(null,E)},_tileOnError:function(w,E,D){var q=this.options.errorTileUrl;q&&E.getAttribute("src")!==q&&(E.src=q),w(D,E)},_onTileRemove:function(w){w.tile.onload=null},_getZoomForUrl:function(){var w=this._tileZoom,E=this.options.maxZoom,D=this.options.zoomReverse,q=this.options.zoomOffset;return D&&(w=E-w),w+q},_getSubdomain:function(w){var E=Math.abs(w.x+w.y)%this.options.subdomains.length;return this.options.subdomains[E]},_abortLoading:function(){var w,E;for(w in this._tiles)if(this._tiles[w].coords.z!==this._tileZoom&&(E=this._tiles[w].el,E.onload=N,E.onerror=N,!E.complete)){E.src=ft;var D=this._tiles[w].coords;mr(E),delete this._tiles[w],this.fire("tileabort",{tile:E,coords:D})}},_removeTile:function(w){var E=this._tiles[w];if(E)return E.el.setAttribute("src",ft),Sg.prototype._removeTile.call(this,w)},_tileReady:function(w,E,D){if(!(!this._map||D&&D.getAttribute("src")===ft))return Sg.prototype._tileReady.call(this,w,E,D)}});function E3(w,E){return new vb(w,E)}var fv=vb.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(w,E){this._url=w;var D=h({},this.defaultWmsParams);for(var q in E)q in this.options||(D[q]=E[q]);E=j(this,E);var st=E.detectRetina&&Mr.retina?2:1,vt=this.getTileSize();D.width=vt.x*st,D.height=vt.y*st,this.wmsParams=D},onAdd:function(w){this._crs=this.options.crs||w.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var E=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[E]=this._crs.code,vb.prototype.onAdd.call(this,w)},getTileUrl:function(w){var E=this._tileCoordsToNwSe(w),D=this._crs,q=mn(D.project(E[0]),D.project(E[1])),st=q.min,vt=q.max,$t=(this._wmsVersion>=1.3&&this._crs===Ry?[st.y,st.x,vt.y,vt.x]:[st.x,st.y,vt.x,vt.y]).join(","),_e=vb.prototype.getTileUrl.call(this,w);return _e+V(this.wmsParams,_e,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+$t},setParams:function(w,E){return h(this.wmsParams,w),E||this.redraw(),this}});function Ak(w,E){return new fv(w,E)}vb.WMS=fv,E3.wms=Ak;var h1=Yf.extend({options:{padding:.1},initialize:function(w){j(this,w),S(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),ws(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){this.off("update",this._updatePaths,this),this._destroyContainer()},getEvents:function(){var w={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(w.zoomanim=this._onAnimZoom),w},_onAnimZoom:function(w){this._updateTransform(w.center,w.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(w,E){var D=this._map.getZoomScale(E,this._zoom),q=this._map.getSize().multiplyBy(.5+this.options.padding),st=this._map.project(this._center,E),vt=q.multiplyBy(-D).add(st).subtract(this._map._getNewPixelOrigin(w,E));Mr.any3d?Nd(this._container,vt,D):ya(this._container,vt)},_reset:function(){this._update(),this._updateTransform(this._center,this._zoom);for(var w in this._layers)this._layers[w]._reset()},_onZoomEnd:function(){for(var w in this._layers)this._layers[w]._project()},_updatePaths:function(){for(var w in this._layers)this._layers[w]._update()},_update:function(){var w=this.options.padding,E=this._map.getSize(),D=this._map.containerPointToLayerPoint(E.multiplyBy(-w)).round();this._bounds=new ke(D,D.add(E.multiplyBy(1+w*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),RS=h1.extend({options:{tolerance:0},getEvents:function(){var w=h1.prototype.getEvents.call(this);return w.viewprereset=this._onViewPreReset,w},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){h1.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var w=this._container=document.createElement("canvas");As(w,"mousemove",this._onMouseMove,this),As(w,"click dblclick mousedown mouseup contextmenu",this._onClick,this),As(w,"mouseout",this._handleMouseOut,this),w._leaflet_disable_events=!0,this._ctx=w.getContext("2d")},_destroyContainer:function(){Lt(this._redrawRequest),delete this._ctx,mr(this._container),Vc(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){var w;this._redrawBounds=null;for(var E in this._layers)w=this._layers[E],w._update();this._redraw()}},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){h1.prototype._update.call(this);var w=this._bounds,E=this._container,D=w.getSize(),q=Mr.retina?2:1;ya(E,w.min),E.width=q*D.x,E.height=q*D.y,E.style.width=D.x+"px",E.style.height=D.y+"px",Mr.retina&&this._ctx.scale(2,2),this._ctx.translate(-w.min.x,-w.min.y),this.fire("update")}},_reset:function(){h1.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(w){this._updateDashArray(w),this._layers[S(w)]=w;var E=w._order={layer:w,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=E),this._drawLast=E,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(w){this._requestRedraw(w)},_removePath:function(w){var E=w._order,D=E.next,q=E.prev;D?D.prev=q:this._drawLast=q,q?q.next=D:this._drawFirst=D,delete w._order,delete this._layers[S(w)],this._requestRedraw(w)},_updatePath:function(w){this._extendRedrawBounds(w),w._project(),w._update(),this._requestRedraw(w)},_updateStyle:function(w){this._updateDashArray(w),this._requestRedraw(w)},_updateDashArray:function(w){if(typeof w.options.dashArray=="string"){var E=w.options.dashArray.split(/[, ]+/),D=[],q,st;for(st=0;st')}}catch{}return function(w){return document.createElement("<"+w+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}(),Gy={_initContainer:function(){this._container=Nr("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(h1.prototype._update.call(this),this.fire("update"))},_initPath:function(w){var E=w._container=Qf("shape");ws(E,"leaflet-vml-shape "+(this.options.className||"")),E.coordsize="1 1",w._path=Qf("path"),E.appendChild(w._path),this._updateStyle(w),this._layers[S(w)]=w},_addPath:function(w){var E=w._container;this._container.appendChild(E),w.options.interactive&&w.addInteractiveTarget(E)},_removePath:function(w){var E=w._container;mr(E),w.removeInteractiveTarget(E),delete this._layers[S(w)]},_updateStyle:function(w){var E=w._stroke,D=w._fill,q=w.options,st=w._container;st.stroked=!!q.stroke,st.filled=!!q.fill,q.stroke?(E||(E=w._stroke=Qf("stroke")),st.appendChild(E),E.weight=q.weight+"px",E.color=q.color,E.opacity=q.opacity,q.dashArray?E.dashStyle=X(q.dashArray)?q.dashArray.join(" "):q.dashArray.replace(/( *, *)/g," "):E.dashStyle="",E.endcap=q.lineCap.replace("butt","flat"),E.joinstyle=q.lineJoin):E&&(st.removeChild(E),w._stroke=null),q.fill?(D||(D=w._fill=Qf("fill")),st.appendChild(D),D.color=q.fillColor||q.color,D.opacity=q.fillOpacity):D&&(st.removeChild(D),w._fill=null)},_updateCircle:function(w){var E=w._point.round(),D=Math.round(w._radius),q=Math.round(w._radiusY||D);this._setPath(w,w._empty()?"M0 0":"AL "+E.x+","+E.y+" "+D+","+q+" 0,"+65535*360)},_setPath:function(w,E){w._path.v=E},_bringToFront:function(w){dc(w._container)},_bringToBack:function(w){vh(w._container)}},pv=Mr.vml?Qf:ut,Tg=h1.extend({_initContainer:function(){this._container=pv("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=pv("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){mr(this._container),Vc(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){h1.prototype._update.call(this);var w=this._bounds,E=w.getSize(),D=this._container;(!this._svgSize||!this._svgSize.equals(E))&&(this._svgSize=E,D.setAttribute("width",E.x),D.setAttribute("height",E.y)),ya(D,w.min),D.setAttribute("viewBox",[w.min.x,w.min.y,E.x,E.y].join(" ")),this.fire("update")}},_initPath:function(w){var E=w._path=pv("path");w.options.className&&ws(E,w.options.className),w.options.interactive&&ws(E,"leaflet-interactive"),this._updateStyle(w),this._layers[S(w)]=w},_addPath:function(w){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(w._path),w.addInteractiveTarget(w._path)},_removePath:function(w){mr(w._path),w.removeInteractiveTarget(w._path),delete this._layers[S(w)]},_updatePath:function(w){w._project(),w._update()},_updateStyle:function(w){var E=w._path,D=w.options;E&&(D.stroke?(E.setAttribute("stroke",D.color),E.setAttribute("stroke-opacity",D.opacity),E.setAttribute("stroke-width",D.weight),E.setAttribute("stroke-linecap",D.lineCap),E.setAttribute("stroke-linejoin",D.lineJoin),D.dashArray?E.setAttribute("stroke-dasharray",D.dashArray):E.removeAttribute("stroke-dasharray"),D.dashOffset?E.setAttribute("stroke-dashoffset",D.dashOffset):E.removeAttribute("stroke-dashoffset")):E.setAttribute("stroke","none"),D.fill?(E.setAttribute("fill",D.fillColor||D.color),E.setAttribute("fill-opacity",D.fillOpacity),E.setAttribute("fill-rule",D.fillRule||"evenodd")):E.setAttribute("fill","none"))},_updatePoly:function(w,E){this._setPath(w,kt(w._parts,E))},_updateCircle:function(w){var E=w._point,D=Math.max(Math.round(w._radius),1),q=Math.max(Math.round(w._radiusY),1)||D,st="a"+D+","+q+" 0 1,0 ",vt=w._empty()?"M0 0":"M"+(E.x-D)+","+E.y+st+D*2+",0 "+st+-D*2+",0 ";this._setPath(w,vt)},_setPath:function(w,E){w._path.setAttribute("d",E)},_bringToFront:function(w){dc(w._path)},_bringToBack:function(w){vh(w._path)}});Mr.vml&&Tg.include(Gy);function S3(w){return Mr.svg||Mr.vml?new Tg(w):null}Co.include({getRenderer:function(w){var E=w.options.renderer||this._getPaneRenderer(w.options.pane)||this.options.renderer||this._renderer;return E||(E=this._renderer=this._createRenderer()),this.hasLayer(E)||this.addLayer(E),E},_getPaneRenderer:function(w){if(w==="overlayPane"||w===void 0)return!1;var E=this._paneRenderers[w];return E===void 0&&(E=this._createRenderer({pane:w}),this._paneRenderers[w]=E),E},_createRenderer:function(w){return this.options.preferCanvas&&dv(w)||S3(w)}});var T3=bb.extend({initialize:function(w,E){bb.prototype.initialize.call(this,this._boundsToLatLngs(w),E)},setBounds:function(w){return this.setLatLngs(this._boundsToLatLngs(w))},_boundsToLatLngs:function(w){return w=Qn(w),[w.getSouthWest(),w.getNorthWest(),w.getNorthEast(),w.getSouthEast()]}});function Wy(w,E){return new T3(w,E)}Tg.create=pv,Tg.pointsToPath=kt,u1.geometryToLayer=l1,u1.coordsToLatLng=By,u1.coordsToLatLngs=Fy,u1.latLngToCoords=M3,u1.latLngsToCoords=Uy,u1.getFeature=wb,u1.asFeature=zy,Co.mergeOptions({boxZoom:!0});var C3=Od.extend({initialize:function(w){this._map=w,this._container=w._container,this._pane=w._panes.overlayPane,this._resetStateTimeout=0,w.on("unload",this._destroy,this)},addHooks:function(){As(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){Vc(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){mr(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){this._resetStateTimeout!==0&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(w){if(!w.shiftKey||w.which!==1&&w.button!==1)return!1;this._clearDeferredResetState(),this._resetState(),U0(),Ey(),this._startPoint=this._map.mouseEventToContainerPoint(w),As(document,{contextmenu:rc,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(w){this._moved||(this._moved=!0,this._box=Nr("div","leaflet-zoom-box",this._container),ws(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(w);var E=new ke(this._point,this._startPoint),D=E.getSize();ya(this._box,E.min),this._box.style.width=D.x+"px",this._box.style.height=D.y+"px"},_finish:function(){this._moved&&(mr(this._box),$c(this._container,"leaflet-crosshair")),z0(),c3(),Vc(document,{contextmenu:rc,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(w){if(!(w.which!==1&&w.button!==1)&&(this._finish(),!!this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(m(this._resetState,this),0);var E=new en(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(E).fire("boxzoomend",{boxZoomBounds:E})}},_onKeyDown:function(w){w.keyCode===27&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});Co.addInitHook("addHandler","boxZoom",C3),Co.mergeOptions({doubleClickZoom:!0});var _b=Od.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(w){var E=this._map,D=E.getZoom(),q=E.options.zoomDelta,st=w.originalEvent.shiftKey?D-q:D+q;E.options.doubleClickZoom==="center"?E.setZoom(st):E.setZoomAround(w.containerPoint,st)}});Co.addInitHook("addHandler","doubleClickZoom",_b),Co.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var Cg=Od.extend({addHooks:function(){if(!this._draggable){var w=this._map;this._draggable=new su(w._mapPane,w._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),w.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),w.on("zoomend",this._onZoomEnd,this),w.whenReady(this._onZoomEnd,this))}ws(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){$c(this._map._container,"leaflet-grab"),$c(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var w=this._map;if(w._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var E=Qn(this._map.options.maxBounds);this._offsetLimit=mn(this._map.latLngToContainerPoint(E.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(E.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;w.fire("movestart").fire("dragstart"),w.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(w){if(this._map.options.inertia){var E=this._lastTime=+new Date,D=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(D),this._times.push(E),this._prunePositions(E)}this._map.fire("move",w).fire("drag",w)},_prunePositions:function(w){for(;this._positions.length>1&&w-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var w=this._map.getSize().divideBy(2),E=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=E.subtract(w).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(w,E){return w-(w-E)*this._viscosity},_onPreDragLimit:function(){if(!(!this._viscosity||!this._offsetLimit)){var w=this._draggable._newPos.subtract(this._draggable._startPos),E=this._offsetLimit;w.xE.max.x&&(w.x=this._viscousLimit(w.x,E.max.x)),w.y>E.max.y&&(w.y=this._viscousLimit(w.y,E.max.y)),this._draggable._newPos=this._draggable._startPos.add(w)}},_onPreDragWrap:function(){var w=this._worldWidth,E=Math.round(w/2),D=this._initialWorldOffset,q=this._draggable._newPos.x,st=(q-E+D)%w+E-D,vt=(q+E+D)%w-E-D,$t=Math.abs(st+D)0?vt:-vt))-E;this._delta=0,this._startTime=null,$t&&(w.options.scrollWheelZoom==="center"?w.setZoom(E+$t):w.setZoomAround(this._lastMousePos,E+$t))}});Co.addInitHook("addHandler","scrollWheelZoom",DS);var kk=600;Co.mergeOptions({tapHold:Mr.touchNative&&Mr.safari&&Mr.mobile,tapTolerance:15});var NS=Od.extend({addHooks:function(){As(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){Vc(this._map._container,"touchstart",this._onDown,this)},_onDown:function(w){if(clearTimeout(this._holdTimeout),w.touches.length===1){var E=w.touches[0];this._startPos=this._newPos=new re(E.clientX,E.clientY),this._holdTimeout=setTimeout(m(function(){this._cancel(),this._isTapValid()&&(As(document,"touchend",sl),As(document,"touchend touchcancel",this._cancelClickPrevent),this._simulateEvent("contextmenu",E))},this),kk),As(document,"touchend touchcancel contextmenu",this._cancel,this),As(document,"touchmove",this._onMove,this)}},_cancelClickPrevent:function w(){Vc(document,"touchend",sl),Vc(document,"touchend touchcancel",w)},_cancel:function(){clearTimeout(this._holdTimeout),Vc(document,"touchend touchcancel contextmenu",this._cancel,this),Vc(document,"touchmove",this._onMove,this)},_onMove:function(w){var E=w.touches[0];this._newPos=new re(E.clientX,E.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_simulateEvent:function(w,E){var D=new MouseEvent(w,{bubbles:!0,cancelable:!0,view:window,screenX:E.screenX,screenY:E.screenY,clientX:E.clientX,clientY:E.clientY});D._simulated=!0,E.target.dispatchEvent(D)}});Co.addInitHook("addHandler","tapHold",NS),Co.mergeOptions({touchZoom:Mr.touch,bounceAtZoomLimits:!0});var mv=Od.extend({addHooks:function(){ws(this._map._container,"leaflet-touch-zoom"),As(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){$c(this._map._container,"leaflet-touch-zoom"),Vc(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(w){var E=this._map;if(!(!w.touches||w.touches.length!==2||E._animatingZoom||this._zooming)){var D=E.mouseEventToContainerPoint(w.touches[0]),q=E.mouseEventToContainerPoint(w.touches[1]);this._centerPoint=E.getSize()._divideBy(2),this._startLatLng=E.containerPointToLatLng(this._centerPoint),E.options.touchZoom!=="center"&&(this._pinchStartLatLng=E.containerPointToLatLng(D.add(q)._divideBy(2))),this._startDist=D.distanceTo(q),this._startZoom=E.getZoom(),this._moved=!1,this._zooming=!0,E._stop(),As(document,"touchmove",this._onTouchMove,this),As(document,"touchend touchcancel",this._onTouchEnd,this),sl(w)}},_onTouchMove:function(w){if(!(!w.touches||w.touches.length!==2||!this._zooming)){var E=this._map,D=E.mouseEventToContainerPoint(w.touches[0]),q=E.mouseEventToContainerPoint(w.touches[1]),st=D.distanceTo(q)/this._startDist;if(this._zoom=E.getScaleZoom(st,this._startZoom),!E.options.bounceAtZoomLimits&&(this._zoomE.getMaxZoom()&&st>1)&&(this._zoom=E._limitZoom(this._zoom)),E.options.touchZoom==="center"){if(this._center=this._startLatLng,st===1)return}else{var vt=D._add(q)._divideBy(2)._subtract(this._centerPoint);if(st===1&&vt.x===0&&vt.y===0)return;this._center=E.unproject(E.project(this._pinchStartLatLng,this._zoom).subtract(vt),this._zoom)}this._moved||(E._moveStart(!0,!1),this._moved=!0),Lt(this._animRequest);var $t=m(E._move,E,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=ot($t,this,!0),sl(w)}},_onTouchEnd:function(){if(!this._moved||!this._zooming){this._zooming=!1;return}this._zooming=!1,Lt(this._animRequest),Vc(document,"touchmove",this._onTouchMove,this),Vc(document,"touchend touchcancel",this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom))}});Co.addInitHook("addHandler","touchZoom",mv),Co.BoxZoom=C3,Co.DoubleClickZoom=_b,Co.Drag=Cg,Co.Keyboard=gv,Co.ScrollWheelZoom=DS,Co.TapHold=NS,Co.TouchZoom=mv,d.Bounds=ke,d.Browser=Mr,d.CRS=ti,d.Canvas=RS,d.Circle=hv,d.CircleMarker=Ny,d.Class=ln,d.Control=Cc,d.DivIcon=$0,d.DivOverlay=mf,d.DomEvent=vk,d.DomUtil=bk,d.Draggable=su,d.Evented=xe,d.FeatureGroup=pf,d.GeoJSON=u1,d.GridLayer=Sg,d.Handler=Od,d.Icon=G0,d.ImageOverlay=$e,d.LatLng=ge,d.LatLngBounds=en,d.Layer=Yf,d.LayerGroup=Fu,d.LineUtil=_3,d.Map=Co,d.Marker=Dy,d.Mixin=df,d.Path=gf,d.Point=re,d.PolyUtil=Ay,d.Polygon=bb,d.Polyline=Fl,d.Popup=jy,d.PosAnimation=yS,d.Projection=yk,d.Rectangle=T3,d.Renderer=h1,d.SVG=Tg,d.SVGOverlay=Wa,d.TileLayer=vb,d.Tooltip=W0,d.Transformation=pr,d.Util=be,d.VideoOverlay=vs,d.bind=m,d.bounds=mn,d.canvas=dv,d.circle=IS,d.circleMarker=Sk,d.control=H0,d.divIcon=Hy,d.extend=h,d.featureGroup=LS,d.geoJSON=oe,d.geoJson=_n,d.gridLayer=pc,d.icon=Mk,d.imageOverlay=er,d.latLng=Pe,d.latLngBounds=Qn,d.layerGroup=x3,d.map=_k,d.marker=Ek,d.point=Se,d.polygon=Tk,d.polyline=Oy,d.popup=Jf,d.rectangle=Wy,d.setOptions=j,d.stamp=S,d.svg=S3,d.svgOverlay=Fc,d.tileLayer=E3,d.tooltip=Ck,d.transformation=Kt,d.version=s,d.videoOverlay=Wo;var $y=window.L;d.noConflict=function(){return window.L=$y,this},window.L=d})});var OXt=Ld((NXt,C_t)=>{(function(d){if(typeof NXt=="object"&&typeof C_t<"u")C_t.exports=d();else if(typeof define=="function"&&define.amd)define([],d);else{var s;typeof window<"u"?s=window:typeof global<"u"?s=global:typeof self<"u"?s=self:s=this,s.ELK=d()}})(function(){var d,s,h;return function p(m,_,S){function y(B,P){if(!_[B]){if(!m[B]){var U=typeof TI=="function"&&TI;if(!P&&U)return U(B,!0);if(I)return I(B,!0);var j=new Error("Cannot find module '"+B+"'");throw j.code="MODULE_NOT_FOUND",j}var V=_[B]={exports:{}};m[B][0].call(V.exports,function(et){var Q=m[B][1][et];return y(Q||et)},V,V.exports,p,m,_,S)}return _[B].exports}for(var I=typeof TI=="function"&&TI,N=0;N0&&arguments[0]!==void 0?arguments[0]:{},j=U.defaultLayoutOptions,V=j===void 0?{}:j,et=U.algorithms,Q=et===void 0?["layered","stress","mrtree","radial","force","disco"]:et,X=U.workerFactory,gt=U.workerUrl;if(y(this,B),this.defaultLayoutOptions=V,this.initialized=!1,typeof gt>"u"&&typeof X>"u")throw new Error("Cannot construct an ELK without both 'workerUrl' and 'workerFactory'.");var ft=X;typeof gt<"u"&&typeof X>"u"&&(ft=function(Dt){return new Worker(Dt)});var xt=ft(gt);if(typeof xt.postMessage!="function")throw new TypeError("Created worker does not provide the required 'postMessage' function.");this.worker=new N(xt),this.worker.postMessage({cmd:"register",algorithms:Q}).then(function(Bt){return P.initialized=!0}).catch(console.err)}return S(B,[{key:"layout",value:function(U){var j=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},V=j.layoutOptions,et=V===void 0?this.defaultLayoutOptions:V;return U?this.worker.postMessage({cmd:"layout",graph:U,options:et}):Promise.reject(new Error("Missing mandatory parameter 'graph'."))}},{key:"knownLayoutAlgorithms",value:function(){return this.worker.postMessage({cmd:"algorithms"})}},{key:"knownLayoutOptions",value:function(){return this.worker.postMessage({cmd:"options"})}},{key:"knownLayoutCategories",value:function(){return this.worker.postMessage({cmd:"categories"})}},{key:"terminateWorker",value:function(){this.worker.terminate()}}]),B}();_.default=I;var N=function(){function B(P){var U=this;if(y(this,B),P===void 0)throw new Error("Missing mandatory parameter 'worker'.");this.resolvers={},this.worker=P,this.worker.onmessage=function(j){setTimeout(function(){U.receive(U,j)},0)}}return S(B,[{key:"postMessage",value:function(U){var j=this.id||0;this.id=j+1,U.id=j;var V=this;return new Promise(function(et,Q){V.resolvers[j]=function(X,gt){X?Q(X):et(gt)},V.worker.postMessage(U)})}},{key:"receive",value:function(U,j){var V=j.data,et=U.resolvers[V.id];et&&(delete U.resolvers[V.id],V.error?et(V.error):et(null,V.data))}},{key:"terminate",value:function(){this.worker.terminate&&this.worker.terminate()}}]),B}()},{}],2:[function(p,m,_){(function(S){var y;typeof window<"u"?y=window:typeof S<"u"?y=S:typeof self<"u"&&(y=self);var I,N;function B(){}function P(){}function U(){}function j(){}function V(){}function et(){}function Q(){}function X(){}function gt(){}function ft(){}function xt(){}function Bt(){}function Dt(){}function Pt(){}function se(){}function ot(){}function Lt(){}function be(){}function ln(){}function Fn(){}function ne(){}function xe(){}function re(){}function hn(){}function Se(){}function ke(){}function mn(){}function en(){}function Qn(){}function ge(){}function Pe(){}function ti(){}function Yi(){}function ki(){}function lr(){}function pr(){}function Kt(){}function wn(){}function it(){}function ut(){}function kt(){}function Ot(){}function ie(){}function rn(){}function Pn(){}function Tt(){}function yt(){}function ue(){}function fn(){}function An(){}function zn(){}function Li(){}function xi(){}function Jt(){}function nn(){}function vn(){}function he(){}function Mn(){}function Sn(){}function gn(){}function Ce(){}function dn(){}function jn(){}function ar(){}function gr(){}function tr(){}function Ln(){}function Qt(){}function Mi(){}function sn(){}function Zn(){}function oi(){}function Jr(){}function Bs(){}function Oc(){}function ru(){}function fc(){}function il(){}function va(){}function Mr(){}function tv(){}function O0(){}function ev(){}function B0(){}function F0(){}function nv(){}function wg(){}function iv(){}function o3(){}function Rt(){}function ve(){}function Je(){}function tn(){}function Ze(){}function Hi(){}function Pr(){}function Gr(){}function hs(){}function Fs(){}function Ms(){}function bs(){}function Tc(){}function rl(){}function Oa(){}function wh(){}function Nr(){}function mr(){}function c1(){}function dc(){}function vh(){}function vg(){}function ws(){}function $c(){}function _a(){}function ff(){}function Bl(){}function _h(){}function a1(){}function Nd(){}function ya(){}function _g(){}function U0(){}function z0(){}function yg(){}function mb(){}function Ey(){}function c3(){}function rv(){}function Sy(){}function Ty(){}function sv(){}function bS(){}function a3(){}function bk(){}function As(){}function bp(){}function Vc(){}function wS(){}function u3(){}function ov(){}function l3(){}function j0(){}function h3(){}function cv(){}function sl(){}function rc(){}function Bc(){}function vS(){}function wk(){}function _S(){}function f3(){}function vk(){}function yS(){}function Co(){}function _k(){}function Cc(){}function H0(){}function xg(){}function xS(){}function av(){}function Xf(){}function d3(){}function MS(){}function ES(){}function Cy(){}function SS(){}function Od(){}function df(){}function TS(){}function su(){}function CS(){}function p3(){}function wp(){}function Ay(){}function ky(){}function ea(){}function Mg(){}function g3(){}function m3(){}function b3(){}function AS(){}function kS(){}function Ly(){}function Eg(){}function Py(){}function vp(){}function Zf(){}function w3(){}function v3(){}function _3(){}function uv(){}function Iy(){}function yk(){}function y3(){}function Ry(){}function xk(){}function Yf(){}function Fu(){}function x3(){}function pf(){}function LS(){}function G0(){}function Mk(){}function lv(){}function PS(){}function Dy(){}function Ek(){}function gf(){}function Ny(){}function Sk(){}function hv(){}function IS(){}function Fl(){}function Oy(){}function bb(){}function Tk(){}function u1(){}function l1(){}function Kf(){}function By(){}function Fy(){}function M3(){}function Uy(){}function wb(){}function zy(){}function Bd(){}function oe(){}function _n(){}function $e(){}function er(){}function vs(){}function Wo(){}function Wa(){}function Fc(){}function mf(){}function jy(){}function Jf(){}function W0(){}function Ck(){}function $0(){}function Hy(){}function Sg(){}function pc(){}function vb(){}function E3(){}function fv(){}function Ak(){}function h1(){}function RS(){}function dv(){}function Qf(){}function Gy(){}function pv(){}function Tg(){}function S3(){}function T3(){}function Wy(){}function C3(){}function _b(){}function Cg(){}function gv(){}function DS(){}function kk(){}function NS(){}function mv(){}function $y(){}function w(){}function E(){}function D(){}function q(){}function st(){}function vt(){}function $t(){}function _e(){}function Ye(){}function Un(){}function Ji(){}function Qr(){}function Is(){}function ol(){}function xa(){}function Ul(){}function Uu(){}function f1(){}function yb(){}function Lk(){}function Pk(){}function OS(){}function Ik(){}function BS(){}function Ma(){}function Ag(){}function FS(){}function Mt(){}function xb(){}function Mb(){}function bf(){}function po(){}function $U(){}function VU(){}function qU(){}function bv(){}function V0(){}function Eb(){}function _R(){}function XU(){}function ZU(){}function q0(){}function YU(){}function KU(){}function JU(){}function QU(){}function tz(){}function X0(){}function ez(){}function nz(){}function iz(){}function rz(){}function sz(){}function wv(){}function oz(){}function cz(){}function d1(){}function az(){}function uz(){}function lz(){}function hz(){}function Ie(){}function yR(){}function xR(){}function fz(){}function dz(){}function Rk(){}function A3(){}function k3(){}function pz(){}function MR(){}function gz(){}function kg(){}function Dk(){}function vv(){}function _p(){}function mz(){}function ER(){}function SR(){}function L3(){}function Sb(){}function TR(){}function bz(){}function US(){}function wz(){}function P3(){}function yh(){}function zS(){}function I3(){}function Lg(){}function jS(){}function HS(){}function Z0(){}function CR(){}function zl(){}function Nk(){}function vz(){}function _z(){}function yz(){}function Vy(){}function xz(){}function R3(){}function AR(){}function Mz(){}function kR(){}function D3(){}function Ok(){}function LR(){}function Bk(){}function PR(){}function Ez(){}function Sz(){}function Tz(){}function IR(){}function Fk(){}function Cz(){}function Uk(){}function RR(){}function DR(){}function NR(){}function GS(){}function Az(){}function OR(){}function Tb(){}function zk(){}function BR(){}function kz(){}function jk(){}function FR(){}function Hk(){}function Lz(){}function Gk(){}function oo(){}function Pz(){}function Iz(){}function N3(){}function UR(){}function Rz(){}function Dz(){}function yp(){}function Nz(){}function WS(){}function Wk(){}function zR(){}function jR(){}function Fd(){}function Cb(){}function $k(){}function HR(){}function $S(){}function GR(){}function Vk(){}function WR(){}function qk(){}function Xk(){}function Ab(){}function Oz(){}function kb(){}function $R(){}function VR(){}function Zk(){}function Bz(){}function Fz(){}function Uz(){}function qR(){}function XR(){}function zz(){}function ZR(){}function YR(){}function td(){}function Pg(){}function jz(){}function Hz(){}function VS(){}function qy(){}function KR(){}function JR(){}function Gz(){}function QR(){}function Xy(){}function O3(){}function Wz(){}function t8(){}function e8(){}function qS(){}function n8(){}function XS(){}function Yk(){}function ZS(){}function $z(){}function i8(){}function YS(){}function r8(){}function Kk(){}function Vz(){}function s8(){}function Y0(){}function o8(){}function c8(){}function qz(){}function a8(){}function Xz(){}function Zz(){}function K0(){}function Jk(){}function Qk(){}function t5(){}function KS(){}function Zy(){}function cs(){}function JS(){}function e5(){}function _v(){}function Yz(){}function n5(){}function u8(){}function zh(){}function Kz(){}function Jz(){}function l8(){}function Qz(){}function h8(){}function tj(){}function ej(){}function nj(){}function J0(){}function jh(){}function i5(){}function ij(){}function rj(t){}function rxt(t){}function r5(){Wr()}function B3(){p7()}function f8(){sq()}function d8(){FC()}function sj(){Yht()}function oj(){dlt()}function cj(){BL()}function aj(){Ph()}function p8(){Nut()}function g8(){L5()}function uj(){cL()}function s5(){S5t()}function m8(){WRt()}function F3(){y3t()}function o5(){Hit()}function b8(){qt()}function w8(){rAt()}function QS(){GLt()}function v8(){cAt()}function p1(){RRt()}function yv(){aAt()}function lj(){vat()}function _8(){p6t()}function hj(){nw()}function fj(){uAt()}function dj(){P5t()}function pj(){fNt()}function gj(){x3t()}function mj(){Flt()}function bj(){Kb()}function wf(){yTt()}function wj(){w7()}function vj(){dr()}function y8(){H7()}function x8(){ON()}function M8(){lut()}function c5(){HV()}function _j(){Mht()}function yj(t){this.a=t}function xj(t){this.a=t}function U3(t){this.a=t}function Mj(t){this.a=t}function Ej(t){this.a=t}function Sj(t){this.a=t}function E8(t){this.a=t}function Tj(t){this.a=t}function S8(t){this.a=t}function Ud(t){this.a=t}function Cj(t){this.a=t}function a5(t){this.a=t}function Aj(t){this.a=t}function T8(t){this.a=t}function kj(t){this.a=t}function Lj(t){this.a=t}function Pj(t){this.a=t}function Ij(t){this.a=t}function u5(t){this.a=t}function l5(t){this.b=t}function Rj(t){this.a=t}function Dj(t){this.a=t}function Nj(t){this.a=t}function Oj(t){this.a=t}function Bj(t){this.a=t}function C8(t){this.a=t}function A8(t){this.a=t}function h5(t){this.a=t}function tT(t){this.a=t}function z3(t){this.a=t}function Fj(t){this.a=t}function k8(t){this.a=t}function Lb(t){this.a=t}function L8(t){this.a=t}function P8(t){this.a=t}function I8(t){this.a=t}function xp(t){this.a=t}function xv(t){this.a=t}function f5(t){this.a=t}function vf(t){this.a=t}function Q0(t){this.a=t}function j3(t){this.d=t}function Ig(){this.a=[]}function vi(){uu(this)}function Tnt(t,e){t.i=e}function Cnt(t,e){t.g=e}function Ant(t,e){t.b=e}function knt(t,e){t.b=e}function Lnt(t,e){t.a=e}function R8(t,e){t.a=e}function Pnt(t,e){t.c=e}function d5(t,e){t.c=e}function Int(t,e){t.b=e}function Rnt(t,e){t.d=e}function Dnt(t,e){t.d=e}function jl(t,e){t.j=e}function Nnt(t,e){t.a=e}function Ont(t,e){t.f=e}function Bnt(t,e){t.f=e}function Uj(t,e){t.e=e}function D8(t,e){t.k=e}function Fnt(t,e){t.a=e}function Unt(t,e){t.b=e}function N8(t,e){t.g=e}function O8(t,e){t.j=e}function znt(t,e){t.n=e}function jnt(t,e){t.a=e}function Hnt(t,e){t.a=e}function zj(t,e){t.c=e}function jj(t,e){t.c=e}function Gnt(t,e){t.d=e}function Wnt(t,e){t.e=e}function $nt(t,e){t.g=e}function Vnt(t,e){t.a=e}function p5(t,e){t.c=e}function qnt(t,e){t.d=e}function Xnt(t,e){t.e=e}function Znt(t,e){t.f=e}function Ynt(t,e){t.j=e}function Knt(t,e){t.a=e}function Jnt(t,e){t.a=e}function Qnt(t,e){t.b=e}function Hj(t){t.b=t.a}function Gj(t){t.c=t.d.d}function Wj(t){hi(si(t))}function B8(t){this.b=t}function Mv(t){this.a=t}function eT(t){this.a=t}function nT(t){this.a=t}function Pb(t){this.b=t}function Rg(t){this.b=t}function F8(t){this.a=t}function U8(t){this.a=t}function _r(t){this.a=t}function z8(t){this.a=t}function j8(t){this.a=t}function $j(t){this.a=t}function H8(t){this.a=t}function Yy(t){this.a=t}function iT(t){this.a=t}function Vj(t){this.a=t}function qj(t){this.a=t}function g5(t){this.a=t}function G8(t){this.a=t}function Xj(t){this.a=t}function Zj(t){this.a=t}function Yj(t){this.a=t}function Kj(t){this.a=t}function Jj(t){this.a=t}function Qj(t){this.a=t}function tH(t){this.a=t}function eH(t){this.a=t}function nH(t){this.a=t}function iH(t){this.a=t}function rH(t){this.a=t}function Ev(t){this.a=t}function g1(t){this.a=t}function sH(t){this.a=t}function oH(t){this.a=t}function Sv(t){this.a=t}function Us(t){this.a=t}function W8(t){this.a=t}function xh(t){this.a=t}function H(t){this.c=t}function rT(t){this.e=t}function zd(t){this.a=t}function cH(t){this.a=t}function Tv(t){this.a=t}function $8(t){this.a=t}function aH(t){this.a=t}function uH(t){this.a=t}function m5(t){this.a=t}function lH(t){this.a=t}function tm(t){this.a=t}function V8(t){this.a=t}function sT(t){this.a=t}function $a(t){this.a=t}function ou(t){this.a=t}function q8(t){this.a=t}function b5(t){this.a=t}function hH(t){this.a=t}function fH(t){this.a=t}function dH(t){this.a=t}function pH(t){this.a=t}function gH(t){this.a=t}function X8(t){this.a=t}function H3(t){this.a=t}function Ib(t){this.a=t}function mH(t){this.a=t}function Z8(t){this.a=t}function oT(t){this.a=t}function jd(t){this.a=t}function Ky(t){this.a=t}function bH(t){this.a=t}function wH(t){this.a=t}function vH(t){this.a=t}function _H(t){this.a=t}function yH(t){this.a=t}function Y8(t){this.a=t}function em(t){this.a=t}function Ys(t){this.a=t}function K8(t){this.a=t}function Mp(t){this.a=t}function J8(t){this.a=t}function xH(t){this.b=t}function Ac(t){this.a=t}function MH(t){this.a=t}function Q8(t){this.a=t}function t9(t){this.c=t}function w5(t){this.a=t}function EH(t){this.a=t}function SH(t){this.a=t}function TH(t){this.a=t}function CH(t){this.a=t}function AH(t){this.a=t}function kH(t){this.a=t}function LH(t){this.a=t}function PH(t){this.a=t}function IH(t){this.a=t}function RH(t){this.a=t}function DH(t){this.a=t}function NH(t){this.a=t}function v5(t){this.a=t}function OH(t){this.a=t}function _5(t){this.a=t}function BH(t){this.a=t}function FH(t){this.a=t}function UH(t){this.a=t}function Hl(t){this.a=t}function ed(t){this.a=t}function Hd(t){this.a=t}function Rb(t){this.a=t}function zH(t){this.a=t}function e9(t){this.a=t}function jH(t){this.a=t}function HH(t){this.a=t}function cT(t){this.a=t}function n9(t){this.f=t}function GH(t){this.i=t}function y5(t){this.a=t}function WH(t){this.a=t}function i9(t){this.a=t}function r9(t){this.a=t}function $H(t){this.a=t}function VH(t){this.a=t}function qH(t){this.a=t}function XH(t){this.a=t}function Jy(t){this.a=t}function ZH(t){this.a=t}function YH(t){this.a=t}function KH(t){this.a=t}function JH(t){this.a=t}function QH(t){this.a=t}function s9(t){this.a=t}function o9(t){this.a=t}function tG(t){this.a=t}function eG(t){this.a=t}function nG(t){this.a=t}function iG(t){this.a=t}function rG(t){this.a=t}function sG(t){this.a=t}function oG(t){this.a=t}function cG(t){this.a=t}function aG(t){this.a=t}function uG(t){this.a=t}function lG(t){this.a=t}function hG(t){this.a=t}function fG(t){this.a=t}function dG(t){this.a=t}function pG(t){this.a=t}function c9(t){this.a=t}function kr(t){this.b=t}function gG(t){this.a=t}function mG(t){this.a=t}function bG(t){this.a=t}function wG(t){this.a=t}function vG(t){this.a=t}function _G(t){this.a=t}function yG(t){this.a=t}function xG(t){this.b=t}function x5(t){this.a=t}function Qy(t){this.a=t}function a9(t){this.a=t}function aT(t){this.a=t}function uT(t){this.a=t}function M5(t){this.a=t}function E5(t){this.a=t}function MG(t){this.d=t}function u9(t){this.c=t}function lT(t){this.e=t}function Ba(t){this.e=t}function hT(t){this.a=t}function l9(t){this.a=t}function G3(){this.a=0}function W3(){GEt(this)}function Nt(){kW(this)}function $3(){a4t(this)}function tit(){kit(),Uxe()}function h9(){return null}function eit(){return null}function nit(t){return t.a}function iit(t){return t.a}function rit(t){return t.a}function EG(t){return t.a}function sit(t){return t.a}function K(t){return t.e}function m1(){this.c=Zvt}function S5(){this.a=this}function fT(t){this.a=Cle(t)}function f9(){Ep.call(this)}function V3(){Ep.call(this)}function na(){Ep.call(this)}function d9(){Ep.call(this)}function T5(){Ep.call(this)}function p9(){CSt.call(this)}function Ep(){CSt.call(this)}function t2(){Ep.call(this)}function Oi(){Ep.call(this)}function g9(){d9.call(this)}function oit(t){t.b.Te(t.e)}function SG(t,e){e.jd(t.a)}function e2(t,e){t.a=e-t.a}function n2(t,e){t.b=e-t.b}function TG(t,e){t.b+=e}function cit(t,e){t.d.b.$b(e)}function q3(t,e){t.e=e,e.b=t}function CG(t,e){t.length=e}function m9(t){t.a=new Fr}function b9(){b9=P,new vi}function AG(){this.b=new Jit}function x(){this.Bb|=256}function C(){Ep.call(this)}function F(){Ep.call(this)}function J(){Ep.call(this)}function mt(){Ep.call(this)}function St(t){E7(t.c,t.b)}function Vt(t,e){blt(t.c,e)}function ee(t,e){h7(t.a,e)}function fe(t,e){_q(t.a,e)}function Cn(t,e){Ut(t.a,e)}function kn(t,e){Ir(t.b,e)}function Wn(t,e){Bi(t.e,e)}function Ki(t){xM(),yK.Rd(t)}function Er(){Er=P,d1t=new et}function Wr(){Wr=P,mK=new j}function no(){no=P,f1t=new U}function Zr(){Zr=P,bK=new Qxt}function co(){co=P,wK=new t3t}function $o(){$o=P,xzt=new ot}function Hh(){Hh=P,R4=new Lt}function _f(){_f=P,Azt=new Fn}function $r(){this.a=new vi}function _u(){this.a=new kAt}function nd(){this.a=new Nt}function nm(){this.a=new Nt}function w9(){this.a=new Nt}function sxt(){this.a=new Nt}function oxt(){this.a=new Nt}function cxt(){this.a=new $r}function ait(){this.a=new J3t}function uit(){this.a=new bAt}function lit(){this.a=new sTt}function hit(){this.a=new tv}function cl(){this.a=new Jf}function kG(){this.a=new Nt}function fit(){this.a=new Nt}function axt(){this.b=new Nt}function dit(){this.f=new Nt}function uxt(){this.d=new Nt}function lxt(){this.a=new Nt}function Dg(){this.a=new e5t}function pit(){this.a=new Mt}function hxt(){this.j=new Nt}function Va(){Fr.call(this)}function fxt(){Nt.call(this)}function LG(){nd.call(this)}function git(){i2.call(this)}function i2(){wh.call(this)}function r2(){wh.call(this)}function mit(){r2.call(this)}function dxt(){vi.call(this)}function pxt(){vi.call(this)}function gxt(){vi.call(this)}function mxt(){H4t.call(this)}function bxt(){H4t.call(this)}function wxt(){mD.call(this)}function vxt(){Nxt.call(this)}function _xt(){Nxt.call(this)}function bit(){yh.call(this)}function wit(){yh.call(this)}function PG(){Grt.call(this)}function IG(){Grt.call(this)}function RG(){XLt.call(this)}function vit(){zl.call(this)}function yxt(){zl.call(this)}function xxt(){vit.call(this)}function Mxt(){x.call(this)}function Ext(){$r.call(this)}function _it(){vi.call(this)}function DG(){vi.call(this)}function Sxt(){vi.call(this)}function Txt(){jh.call(this)}function wQt(t){$3t.call(this,t)}function yit(t){$3t.call(this,t)}function vQt(t){yit.call(this,t)}function Cxt(t){dPt.call(this,t)}function Axt(t){dPt.call(this,t)}function kxt(t){Ast.call(this,t)}function xit(t){XG.call(this,t)}function Mit(t){Q4t.call(this,t)}function Cv(t){eM.call(this,t)}function sc(t){FCt.call(this,t)}function Lxt(t){sc.call(this,t)}function v9(t){sc.call(this,t)}function Uc(t){sc.call(this,t)}function Pxt(t){sc.call(this,t)}function NG(t){FCt.call(this,t)}function Eit(t){Uc.call(this,t)}function dT(t){sc.call(this,t)}function yn(t){sc.call(this,t)}function yc(t){sc.call(this,t)}function Ixt(t){sc.call(this,t)}function pT(t){sc.call(this,t)}function yf(t){yn.call(this,t)}function gT(){tT.call(this,{})}function Sp(){z3.call(this,"")}function mT(){z3.call(this,"")}function im(){z3.call(this,"")}function Db(){z3.call(this,"")}function Rxt(t){Uc.call(this,t)}function Tp(t){sc.call(this,t)}function Sit(t){V7t(),wxe(this,t)}function OG(t){aM(),this.a=t}function C5(t){t.b=null,t.c=0}function _Qt(t,e){t.a=e,d0e(t)}function yQt(t,e){return t*t/e}function X3(t){return t<0?-t:t}function BG(t){MPt(),this.a=t}function FG(t){p$(),this.f=t}function UG(t){p$(),this.f=t}function zG(t,e,n){t.a[e.g]=n}function xQt(t,e,n){Vpe(n,t,e)}function MQt(t,e,n){a2e(n,t,e)}function EQt(t,e,n){ade(t,n,e)}function Dxt(){this.d=new Nt}function Nxt(){this.a=new xz}function Oxt(){throw K(new Oi)}function Tit(){throw K(new Oi)}function SQt(){throw K(new Oi)}function TQt(){throw K(new Oi)}function CQt(){throw K(new Oi)}function Bxt(){throw K(new Oi)}function A5(t){this.c=hi(si(t))}function AQt(t){return new h5(t)}function kQt(t){return new _2(t)}function Z(t,e){return nAt(t,e)}function LQt(t,e){return t.a-e.a}function PQt(t,e){return t.a-e.a}function IQt(t,e){return t.a-e.a}function Fxt(t,e){return t.g-e.g}function Mh(t,e){return t>e?t:e}function rm(t,e){return t0}function $G(t,e){return Pc(t,e)<0}function J3(t){return t.d.c+t.e.c}function go(){this.a=0,this.b=0}function M9(t){yD.call(this,t)}function b1(t){Qv.call(this,t)}function g3t(t){U$.call(this,t)}function m3t(t){U$.call(this,t)}function E9(t){r6t.call(this,t,0)}function b3t(t){this.c=(En(t),t)}function S9(t){this.a=new E9(t)}function Ob(t){this.a=new m$(t)}function JQt(){throw K(new J)}function QQt(){throw K(new J)}function Q3(){Q3=P,z1t=new bEt}function Lv(){Lv=P,$_=new re}function w3t(){w3t=P,Gzt=new fn}function T9(){T9=P,IK=new NSt}function Uit(){Uit=P,Rjt=new nv}function v3t(){v3t=P,Djt=new Rt}function zit(){zit=P,Njt=new CCt}function jit(){jit=P,Ogt=new Hi}function _3t(){_3t=P,Gjt=new rl}function _T(){_T=P,Jjt=new zy}function y3t(){y3t=P,Kjt=new xS}function Hit(){Hit=P,T0t=new m3}function L5(){L5=P,Vjt=new go}function x3t(){x3t=P,D$t=new as}function M3t(){this.b=new TX(Hbt)}function E3t(){this.a=new TX(nwt)}function S3t(){this.a=(Js(),Ff)}function T3t(){this.a=(Js(),Ff)}function C9(t){this.a=0,this.b=t}function A9(t){return t.b!=t.d.c}function C3t(t,e){return t.d[e.o]}function A3t(t,e){for(;t.sd(e););}function Git(t,e,n){t.splice(e,n)}function tte(t,e,n){tc(t.d,e.f,n)}function ete(t,e){wX(Et(t.a),e)}function nte(t,e){wX(Et(t.a),e)}function k3t(t){t.c?QDt(t):tNt(t)}function L3t(){L3t=P,Eqt=new AR}function P3t(){P3t=P,Fqt=new pxt}function I3t(){I3t=P,Uqt=new gxt}function w1(){w1=P,Nl=new _it}function Wit(){Wit=P,qvt=new Sxt}function k9(){k9=P,GF=new vi}function $it(){$it=P,r_t=new Nt}function v1(){v1=P,lg=new ij}function yT(){yT=P,stt=new eSt}function Ap(){Ap=P,wI=new nSt}function VG(){VG=P,Kqt=new Pg}function Jo(){Jo=P,Qqt=new jz}function P5(t){this.a=new K3t(t)}function R3t(t){this.a=a(si(t),13)}function D3t(t,e){this.b=t,this.c=e}function N3t(t,e){this.b=t,this.a=e}function Vit(t,e){this.b=t,this.d=e}function tM(t,e){this.e=t,this.d=e}function qit(t,e){this.b=t,this.c=e}function O3t(t,e){this.a=t,this.b=e}function B3t(t,e){this.a=t,this.b=e}function F3t(t,e){this.a=t,this.b=e}function U3t(t,e){this.a=t,this.b=e}function z3t(t,e){this.b=t,this.a=e}function l2(t,e){lM.call(this,t,e)}function Pv(t,e){l2.call(this,t,e)}function j3t(t,e){this.b=t,this.a=e}function H3t(t,e){this.a=t,this.b=e}function I5(t,e){this.g=t,this.i=e}function G3t(t,e){this.b=t,this.a=e}function qG(t,e){this.a=t,this.b=e}function W3t(t,e){this.a=t,this.f=e}function $3t(t){RW(t.Wb()),this.c=t}function V3t(t,e){this.b=t,this.c=e}function Gi(t,e){this.f=t,this.g=e}function q3t(t,e){Gi.call(this,t,e)}function X3t(t,e){this.e=t,this.c=e}function XG(t){this.b=a(si(t),43)}function Z3t(t){this.a=a(si(t),15)}function eM(t){this.a=a(si(t),15)}function Xit(t,e){this.a=t,this.b=e}function ite(t,e){return t>e&&e0?t:e}function kEt(t){return ia(t.l,t.m,t.h)}function SW(t){return t<10?"0"+t:""+t}function Fte(t){return t==$m||t==mw}function Ute(t){return t==$m||t==gw}function ql(t){return nc(t.b.b,t,0)}function LEt(t){this.a=UMt(),this.b=t}function PEt(t){this.a=UMt(),this.b=t}function m2(t){this.a=t,r5.call(this)}function IEt(t){this.a=t,r5.call(this)}function Art(t,e){IL(t,0,t.length,e)}function REt(t,e){return Ut(t.a,e),e}function zte(t,e){return Ut(t.c,e),t}function DEt(t,e){return pa(t.a,e),t}function jte(t,e){return Zl(),e.a+=t}function Hte(t,e){return Zl(),e.c+=t}function Gte(t,e){return Zl(),e.a+=t}function NEt(t){return t==ey||t==ty}function Bv(t){return t==ah||t==uh}function q5(t){return t==og||t==fp}function Gd(t){return t!=dp&&t!=ib}function Xl(t){return t.eg()&&t.fg()}function Q9(t){return pa(new as,t)}function OEt(){OEt=P,iQ=new IC(jQ)}function qa(){H8.call(this,new vm)}function BEt(){qD.call(this,0,0,0,0)}function oM(){qh.call(this,0,0,0,0)}function krt(t){uEt.call(this,t,!0)}function Oo(t){this.a=t.a,this.b=t.b}function Wd(t,e,n){th(t,e),eh(t,n)}function tD(t,e,n){i_(t,e),n_(t,n)}function Lrt(t,e,n){LV(t,e),PV(t,n)}function TW(t,e,n){wC(t,e),bC(t,n)}function CW(t,e,n){vC(t,e),_C(t,n)}function AW(t,e){lq(t,e),IV(t,t.D)}function FEt(t,e){return new DM(e,t)}function Wte(t,e){return new DM(e,t)}function Lp(t,e){return te?1:0}function FT(t){return mot(t.b.tc(),t.a)}function id(t){return ZT(t.a.tc(),t.b)}function UEt(t){return ml(t,0,t.length)}function eD(t){return t!=null?Yr(t):0}function $d(t){Q4t.call(this,new Mit(t))}function zEt(){D9.call(this,"Head",1)}function jEt(){D9.call(this,"Tail",3)}function Prt(t,e,n){qW.call(this,t,e,n)}function $te(t,e,n){R8(t,e.le(t.a,n))}function HEt(t,e){return parseInt(t,e)}function Vte(t,e){return gC(e,Tf(t))}function qte(t,e){return gC(e,Tf(t))}function b2(t){qD.call(this,t,t,t,t)}function kW(t){t.c=dt(un,te,1,0,5,1)}function GEt(t){t.a=dt(un,te,1,8,5,1)}function Irt(t){return t.b&&WX(t),t.a}function Rrt(t){return t.b&&WX(t),t.c}function LW(t){return t.d&&fX(t),t.c}function PW(t){return t.d&&fX(t),t.b}function Drt(t){return t.d&&fX(t),t.a}function Nrt(t,e,n){return Vr(t,e,n),n}function WEt(t,e,n){Vr(t.c[e.g],e.g,n)}function Xte(t,e,n){return wr(t.g,n,e)}function Zte(t,e,n){return wr(t.k,n,e)}function Yte(t,e,n){Wd(n,n.i+t,n.j+e)}function xc(t,e){es.call(this,t.b,e)}function UT(t){Ai(),Ba.call(this,t)}function ju(){ju=P,ug=(L3t(),Eqt)}function Kn(){Kn=P,new $Et,new Nt}function $Et(){new vi,new vi,new vi}function Ao(){Ao=P,vzt=new xt,h1t=new Bt}function Fv(){Fv=P,h6=new oMt,f6=new SEt}function al(){al=P,a1t=Tee(new A5(Rc))}function ts(){ts=P,new Wj((al(),"="))}function nD(t){t.j=dt(T1t,wt,287,0,0,1)}function VEt(t){this.a=t,jst.call(this,t)}function Kte(t){return t==null?0:Yr(t)}function zT(t){return t==null?tu:Yc(t)}function bo(t,e){return t.charCodeAt(e)}function cM(t,e,n){return Frt(t,Ca(e),n)}function ia(t,e,n){return{l:t,m:e,h:n}}function Qo(t){return t.ae-1?0:e-1}function bee(t,e,n){return n?e!=0:e!=t-1}function OW(t,e,n){return t.a[e.g][n.g]}function wee(t,e){return t.e[e.c.o][e.o]}function vee(t,e){return t.a[e.c.o][e.o]}function Wh(t,e){return t.a[e.c.o][e.o]}function _ee(t,e){return t.j[e.o]=Yme(e)}function yee(t,e){return ro(t.c.d,e.c.d)}function xee(t,e){return ro(t.c.c,e.c.c)}function Mee(t,e,n){U2e(t.a,t.b,t.c,e,n)}function Eee(t,e,n,i){Vr(t.a[e.g],n.g,i)}function GT(t,e,n){return Vr(t.g,e,n),n}function hl(t,e){return t.a*=e,t.b*=e,t}function See(t,e){t.q.setHours(e),n4(t,e)}function Ss(t,e,n){aL.call(this,t,e,n)}function sD(t,e,n){Ss.call(this,t,e,n)}function Hu(t,e,n){Ss.call(this,t,e,n)}function lSt(t,e,n){sD.call(this,t,e,n)}function jrt(t,e,n){TD.call(this,t,e,n)}function hSt(t,e,n){TD.call(this,t,e,n)}function fSt(t,e,n){jrt.call(this,t,e,n)}function dSt(t,e,n){Hrt.call(this,t,e,n)}function Hrt(t,e,n){aL.call(this,t,e,n)}function uM(t,e,n){aL.call(this,t,e,n)}function lM(t,e){this.a=t,YG.call(this,e)}function $n(t){this.i=t,this.f=this.i.j}function y1(t){this.c=t,this.a=this.c.a}function Grt(){this.Bb|=256,this.Bb|=512}function pSt(t,e){this.a=t,XG.call(this,e)}function gSt(t,e){this.a=e,XG.call(this,t)}function Wrt(t){this.b=t,this.a=this.b.a.e}function mSt(t){t.b.jc(),--t.d.f.d,zD(t.d)}function bSt(t){t.a=a(an(t.b.a,4),116)}function wSt(t){t.a=a(an(t.b.a,4),116)}function vSt(t){a5.call(this,a(si(t),34))}function _St(t){a5.call(this,a(si(t),34))}function Tee(t){return si(tu),new ZTt(t,t)}function ySt(t,e){return new J8t(t.a,t.b,e)}function $h(t,e,n){return t.substr(e,n-e)}function Cee(t){return t==null?null:t.name}function Aee(t){return t.l+t.m*Q2+t.h*s0}function zb(t){return typeof t=="number"}function Vo(t){return typeof t=="number"}function Pp(t,e){return!!e&&t.b[e.g]==e}function $rt(t,e){var n;n=t[P_],e[P_]=n}function oD(t){Pb.call(this,t),this.a=t}function Vrt(t){Rg.call(this,t),this.a=t}function Z5(t){Av.call(this,t),this.a=t}function qrt(t){H8.call(this,new Ict(t))}function xSt(t){if(!t)throw K(new C)}function Hn(t){if(!t)throw K(new J)}function Vd(t){t.o==null&&Cme(t)}function BW(t){return Hn(t.a!=null),t.a}function MSt(t,e){return Ut(e.a,t.a),t.a}function ESt(t,e){return Ut(e.b,t.a),t.a}function kee(t,e){e&&(t.a=(Vv(e),e.a))}function Xrt(t,e){return nC(t.a,e)!=null}function fa(t,e){return a(rr(t.a,e),15)}function FW(t){return t.b=a(g4t(t.a),38)}function cm(t){return t.$H||(t.$H=++L3e)}function UW(t){return Qo(t.a)||Qo(t.b)}function jb(t,e){return!!t.p&&lm(t.p,e)}function Lee(t,e){return t.k.b=(En(e),e)}function Pee(t,e){return t.k.b=(En(e),e)}function cD(t,e){return++t.b,Ut(t.a,e)}function Zrt(t,e){return++t.b,Lc(t.a,e)}function Iee(t,e,n){return skt(t,e,n,t.b)}function Yrt(t,e,n){return skt(t,e,n,t.c)}function Krt(t,e){vut.call(this,t,e,null)}function SSt(t,e){this.a=e,XG.call(this,t)}function Y5(t){this.a=t,B8.call(this,t)}function TSt(){_T(),this.b=new Ky(this)}function zW(t,e){p$(),this.f=e,this.d=t}function CSt(){nD(this),ZD(this),this.Pd()}function WT(t){this.d=t,$n.call(this,t)}function w2(t){this.c=t,$n.call(this,t)}function K5(t){this.c=t,WT.call(this,t)}function Ree(t,e,n){_q(t.a,n),h7(t.a,e)}function Jrt(t,e,n){a(PL(t,e),19).nc(n)}function am(t,e){return Ut(e.a,t.a),t.a}function sd(t){var e;e=t.a,t.a=t.b,t.b=e}function J5(t,e){yT(),this.a=t,this.b=e}function aD(t,e){Ap(),this.b=t,this.c=e}function ASt(t,e,n,i){lot.call(this,t,e,n,i)}function uD(t,e,n){var i;i=t.fd(e),i.Bc(n)}function kSt(t,e,n){try{t[e]=n}catch{}}function lD(){lD=P,NF=new es(EBt,0)}function $T(){$T=P,uA=new kr("root")}function VT(){VT=P,bI=new _xt,new vxt}function Dee(t){return++Ar,new qb(3,t)}function od(t){return Ah(t,Y2),new Vu(t)}function Qrt(t){return Ao(),si(t),new CTt(t)}function Nee(t){return Fv(),$i((MAt(),yzt),t)}function LSt(t){return xM(),parseInt(t)||-1}function Oee(t,e){return me(),t==e?0:t?1:-1}function Bee(t){return t==null?null:Yc(t)}function Fee(t){return t==null?null:Yc(t)}function Q5(t){return t.f!=null?t.f:""+t.g}function jW(t){return Eot(t.c,t.c.length)}function PSt(t){t.b=new DSt(t),t.c=new vi}function tst(t){this.q=new y.Date(EM(t))}function ISt(t){this.c=t,this.a=1,this.b=1}function est(t){Q3(),this.b=t,this.a=!0}function RSt(){this.a=new Iv,this.b=new Iv}function DSt(t){Wst.call(this,t,null,null)}function NSt(){Gi.call(this,"POLYOMINO",0)}function tL(t){ct(t,142)&&a(t,142).Xg()}function HW(t){return Hn(t.b!=0),t.a.a.c}function hD(t){return Hn(t.b!=0),t.c.b.c}function Gu(t,e,n){return t.a+=e,t.b+=n,t}function Uee(t,e,n){return t.a*=e,t.b*=n,t}function eL(t,e,n){return t.a-=e,t.b-=n,t}function OSt(t,e,n){return t.a+=ml(e,0,n),t}function GW(t){return t.a=-t.a,t.b=-t.b,t}function WW(t){return X3(t.d.e-t.e.e)-t.a}function zee(t,e){return t.c.nc(a(e,134))}function jee(t,e,n){return Ut(e,fIt(t,n))}function Hee(t,e){return t>0?e*e/t:e*e*100}function Gee(t,e){return t>0?e/(t*t):e*100}function Wee(t,e,n){YL(kc(t.a),e,yAt(n))}function $ee(t,e,n){YL(Ya(t.a),e,xAt(n))}function xu(t,e,n){lu.call(this,t,e,n,2)}function BSt(t,e){yT(),J5.call(this,t,e)}function nst(t,e){Ap(),aD.call(this,t,e)}function FSt(t,e){Ap(),aD.call(this,t,e)}function USt(t,e){Ap(),nst.call(this,t,e)}function $W(t,e){ju(),DD.call(this,t,e)}function ist(t,e){ju(),DD.call(this,t,e)}function zSt(t,e){ju(),$W.call(this,t,e)}function rst(t,e){ju(),$W.call(this,t,e)}function jSt(t,e){ju(),rst.call(this,t,e)}function HSt(t,e){ju(),ist.call(this,t,e)}function GSt(t,e){ju(),DD.call(this,t,e)}function Vee(t,e,n){return e.ak(t.e,t.c,n)}function qee(t,e,n){return e.bk(t.e,t.c,n)}function sst(t,e,n){return W7(DL(t,e),n)}function VW(t,e){return O1(t.e,a(e,42))}function Xee(t){return t==null?null:J2e(t)}function Zee(t){return t==null?null:Age(t)}function WSt(t){this.c=t,th(t,0),eh(t,0)}function hM(t,e){this.c=t,tM.call(this,t,e)}function qT(t,e){this.a=t,hM.call(this,t,e)}function ost(t){this.a=t,this.b=ZCt(this.a.d)}function Yee(t,e){this.d=t,Gj(this),this.b=e}function cst(){XLt.call(this),this.Bb|=ao}function fD(){the.call(this,new vm,new vi)}function qW(t,e,n){EL.call(this,t,e,n,null)}function ast(t,e,n){EL.call(this,t,e,n,null)}function cd(t,e){t.a.bd(t.b,e),++t.b,t.c=-1}function ust(t,e){var n;return n=t.e,t.e=e,n}function de(t){return HT(t==null||Ub(t)),t}function Yt(t){return HT(t==null||zb(t)),t}function hi(t){return HT(t==null||Es(t)),t}function Kee(t,e){return si(t),si(e),yC(t,e)}function $St(t){return t>8?0:t+1}function VSt(t){uu(t.c),t.b.b=t.b,t.b.a=t.b}function qSt(t,e){L5t.call(this,t),this.a=e}function gi(t,e){L5t.call(this,t),this.a=e}function Jee(t){hut.call(this,0,0),this.f=t}function XW(t){var e;e=t[P_]|0,t[P_]=e+1}function Qee(t,e,n){return t.Ld(e,n)<=0?n:e}function tne(t,e){return a(P2(t.b,e),180)}function ene(t,e){return a(P2(t.c,e),199)}function ZW(t){return a(Ee(t.a,t.b),269)}function XSt(t){return new We(t.c,t.d+t.a)}function lst(t){return D1(Gre(Vo(t)?gl(t):t))}function ZSt(t){return Mu(),NEt(a(t,179))}function Bg(){Bg=P,Pvt=qe((Ku(),M0))}function dD(){dD=P,y.Math.pow(2,-65)}function nL(t,e,n){++t.j,t.Yh(),fV(t,e,n)}function YSt(t,e,n){++t.j,t.Vh(e,t.Ch(e,n))}function hst(t,e,n){return n=ku(t,e,3,n),n}function fst(t,e,n){return n=ku(t,e,6,n),n}function dst(t,e,n){return n=ku(t,e,9,n),n}function qd(t,e){return T$(e,_pt),t.f=e,t}function pst(t,e){return(e&qi)%t.d.length}function nne(t,e){return L5(),HM(e.d.g,t)}function KSt(t,e){return wr(t.a,e,"")==null}function JSt(t,e,n){return Iht(t.c,t.b,e,n)}function ine(t,e,n){var i;i=t.fd(e),i.Bc(n)}function QSt(t,e){this.a=t,xG.call(this,e)}function iL(t,e){this.a=t,xG.call(this,e)}function tTt(t,e){this.c=t,Qv.call(this,e)}function eTt(t){this.b=t,this.a=this.b.b.Tb()}function gst(t,e){u9.call(this,t),this.a=e}function YW(t,e){u9.call(this,t),this.a=e}function es(t,e){kr.call(this,t),this.a=e}function jv(t,e){Uc.call(this,M4+t+kO+e)}function pD(){wQt.call(this,new vi),this.a=3}function rL(t){return!t.a&&(t.a=new ln),t.a}function gD(t){t.b?gD(t.b):t.f.c.Zb(t.e,t.d)}function nTt(t){this.a=(we(),new nT(si(t)))}function x1(t,e){if(!t)throw K(new yc(e))}function mst(t,e){if(!t)throw K(new yn(e))}function bst(t,e,n){return t.lastIndexOf(e,n)}function rne(t,e,n){return t.apply(e,n);var i}function KW(t,e,n){return v2(t,a(e,23),n)}function sne(t,e){return WG(FIt(t.a,e,!0))}function one(t,e){return WG(UIt(t.a,e,!0))}function iTt(t){return new b3t((Vv(t),t.a))}function JW(t){return String.fromCharCode(t)}function cne(t){return t==null?null:t.message}function ane(t,e){t.e=e,e!=null&&kSt(e,dZ,t)}function une(t,e,n){return ro(t[e.b],t[n.b])}function wst(t,e,n,i){qD.call(this,t,e,n,i)}function sL(t){mle.call(this,t,(vN(),CK))}function lne(t,e){return t.k.a=(En(e),e+10)}function hne(t,e){return t.k.a=(En(e),e+10)}function fne(t,e){return L5(),!HM(e.d.g,t)}function rTt(){rTt=P,y1t=dt(Io,wt,21,256,0,1)}function me(){me=P,Hm=(me(),!1),xE=!0}function sTt(){this.b=new go,this.c=new Nt}function vst(){this.d=new go,this.e=new go}function _st(){this.k=new go,this.n=new go}function oTt(){this.b=new M3t,this.a=new _e}function cTt(){this.b=new vi,this.a=new vi}function aTt(){this.b=new $r,this.a=new $r}function uTt(){this.a=new Nt,this.d=new Nt}function lTt(){this.a=new Nt,this.b=new Nt}function hTt(){this.a=new tv,this.b=new AG}function fTt(){this.a=new w9,this.c=new bs}function mD(){this.n=new r2,this.i=new oM}function dTt(){mD.call(this),this.a=new go}function yst(t,e,n){return n=ku(t,e,11,n),n}function sr(t,e){return t.a+=e.a,t.b+=e.b,t}function za(t,e){return t.a-=e.a,t.b-=e.b,t}function dne(t,e){var n;return n=e.Yg(t.a),n}function xst(t,e){return a(t.b.cd(e),190).a}function pne(t,e){return e==t||WC(I7(e),t)}function gne(t){return t<100?null:new b1(t)}function mne(t,e,n){n!=null&&aat(e,Vq(t,n))}function bne(t,e,n){n!=null&&uat(e,Vq(t,n))}function fM(t,e,n,i){Wt.call(this,t,e,n,i)}function Mst(t,e,n,i){Wt.call(this,t,e,n,i)}function pTt(t,e,n,i){Mst.call(this,t,e,n,i)}function gTt(t,e,n,i){GD.call(this,t,e,n,i)}function QW(t,e,n,i){GD.call(this,t,e,n,i)}function Est(t,e,n,i){GD.call(this,t,e,n,i)}function mTt(t,e,n,i){QW.call(this,t,e,n,i)}function Sst(t,e,n,i){QW.call(this,t,e,n,i)}function pn(t,e,n,i){Est.call(this,t,e,n,i)}function bTt(t,e,n,i){Sst.call(this,t,e,n,i)}function wTt(t,e,n,i){got.call(this,t,e,n,i)}function vTt(t,e,n){this.a=t,Vit.call(this,e,n)}function wne(t,e,n){return t.d=a(e.Kb(n),206)}function _Tt(t,e){return t.Pi().dh().Zg(t,e)}function Tst(t,e){return t.Pi().dh()._g(t,e)}function t$(t,e){return Ao(),zle(t.tc(),e)!=-1}function vne(t,e){return ts(),new SSt(t.tc(),e)}function bD(t){return Ao(),t.hc()?t.ic():null}function Cst(t){return zb(t)?(En(t),t):t.$d()}function wD(t){return!isNaN(t)&&!isFinite(t)}function Ast(t){Hb(),this.b=(we(),new Av(t))}function Hb(){Hb=P,new Aj((we(),we(),fo))}function yTt(){yTt=P,Vqt=dt(un,te,1,0,5,1)}function kst(){kst=P,qqt=dt(un,te,1,0,5,1)}function xTt(){xTt=P,Lqt=dt(un,te,1,0,5,1)}function MTt(){MTt=P,v1t=dt(ux,wt,192,256,0,1)}function ETt(){ETt=P,x1t=dt(Gm,wt,149,256,0,1)}function STt(){STt=P,S1t=dt(Wm,wt,168,256,0,1)}function TTt(){TTt=P,_1t=dt(D4,wt,159,128,0,1)}function CTt(t){this.b=t,this.a=(Ao(),Ao(),h1t)}function ATt(t){this.b=t,K9.call(this,Q7,0)}function kTt(t){this.c=t,K9.call(this,Q7,0)}function LTt(t){return t.c?nc(t.c.a,t,0):-1}function e$(t,e){return WG(UIt(t.a,e,!1))}function n$(t,e){return WG(FIt(t.a,e,!1))}function Hv(t,e){return t.b.sd(new ert(t,e))}function PTt(t,e){return t.b.sd(new fMt(t,e))}function vD(t,e){if(!t)throw K(new yn(e))}function Lst(t,e){if(!t)throw K(new Pxt(e))}function Pst(t,e){m9(this),this.e=t,this.f=e}function Ist(){m9(this),this.e=0,this.f=!0}function Rst(t,e){this.c=t,x$.call(this,t,e)}function ITt(t,e){return ct(e,15)&&JDt(t.c,e)}function _D(t,e,n){return a(t.c,64).yj(e,n)}function _ne(t,e,n){return a(t.c,64).xj(e,n)}function yne(t,e,n){return Vee(t,a(e,311),n)}function Dst(t,e,n){return qee(t,a(e,311),n)}function xne(t,e,n){return f8t(t,a(e,311),n)}function RTt(t,e,n){return cge(t,a(e,311),n)}function Mne(t,e){return rd(),ni(Et(t.a),e)}function Ene(t,e){return rd(),ni(Et(t.a),e)}function Sne(t){return Ao(),A9(t.a)?lkt(t):null}function DTt(t,e){return t.b.Qb(e)?r4t(t,e):null}function oL(t,e){return t.substr(e,t.length-e)}function NTt(t){return a(t,11).f.c.length!=0}function OTt(t){return a(t,11).d.c.length!=0}function XT(t){return t==Lx||t==Sd||t==Gc}function BTt(t){Th(t.a),A5t(t.c,t.b),t.b=null}function Eh(t){kW(this),Vst(this.c,0,t.yc())}function yD(t){ZEt(this),ld(this),yo(this,t)}function FTt(t,e,n){this.d=t,this.b=n,this.a=e}function ja(t,e,n){this.a=t,this.b=e,this.c=n}function UTt(t,e,n){this.a=t,this.b=e,this.c=n}function zTt(t,e,n){this.c=t,this.a=e,this.b=n}function Tne(t,e,n,i){t.d.b.$b(n),t.d.b.Zb(i,e)}function ZT(t,e){return Ao(),si(e),new gSt(t,e)}function Cne(t){return o7(),$i((bkt(),qzt),t)}function Ane(t){return xN(),$i((wkt(),Xzt),t)}function kne(t){return vN(),$i((z5t(),jzt),t)}function Lne(t){return U1(),$i((Zkt(),Hzt),t)}function Pne(t){return B7(),$i((HPt(),Zzt),t)}function Ine(t){return z2(),$i((G5t(),Kzt),t)}function Rne(t){return zC(),$i((W5t(),Qzt),t)}function Dne(t){return T9(),$i(($At(),tjt),t)}function Nne(t){return EN(),$i((vkt(),bjt),t)}function One(t){return dC(),$i((f5t(),Ajt),t)}function Bne(t){return Mo(),$i((hLt(),Ijt),t)}function Fne(t){return BM(),$i((H5t(),Bjt),t)}function Une(t){return Ke(),$i((mPt(),$jt),t)}function i$(t){qD.call(this,t.d,t.c,t.a,t.b)}function Nst(t){qD.call(this,t.d,t.c,t.a,t.b)}function zne(t){return AC(),$i((d5t(),Zjt),t)}function jne(t){return Po(),$i((jMt(),Yjt),t)}function Hne(t){return GC(),$i((uLt(),iHt),t)}function Gne(t){return pN(),$i((_kt(),rHt),t)}function Wne(t){return qM(),$i((ULt(),sHt),t)}function $ne(t){return C2(),$i((ykt(),oHt),t)}function Vne(t){return CN(),$i((i5t(),cHt),t)}function qne(t){return IN(),$i((n5t(),aHt),t)}function Xne(t){return o_(),$i((r5t(),lHt),t)}function Zne(t){return x7(),$i((OLt(),hHt),t)}function Yne(t){return dP(),$i((BLt(),fHt),t)}function Kne(t){return ZM(),$i((FLt(),dHt),t)}function Jne(t){return So(),$i((d6t(),pHt),t)}function Qne(t){return RM(),$i((l5t(),gHt),t)}function tie(t){return tp(),$i((h5t(),bHt),t)}function eie(t){return aN(),$i((xkt(),wHt),t)}function nie(t){return bl(),$i((lLt(),_Ht),t)}function iie(t){return v7(),$i((zLt(),ZGt),t)}function rie(t){return Qb(),$i((j5t(),YGt),t)}function sie(t){return UC(),$i((aLt(),KGt),t)}function oie(t){return x_(),$i((LPt(),JGt),t)}function cie(t){return Fo(),$i((s5t(),tWt),t)}function aie(t){return t7(),$i((o5t(),eWt),t)}function uie(t){return LN(),$i((c5t(),nWt),t)}function lie(t){return D2(),$i((u5t(),iWt),t)}function hie(t){return UN(),$i((a5t(),rWt),t)}function Ost(t,e){for(;t.b.sd(new ert(t,e)););}function xD(t,e,n){this.b=t,this.a=e,this.c=n}function Bst(t,e,n){this.a=t,this.b=e,this.c=n}function jTt(t,e,n){this.a=t,this.b=e,this.c=n}function MD(t,e,n){this.e=e,this.b=t,this.d=n}function r$(t){var e;return e=new W0,e.e=t,e}function fie(t){return!t.e&&(t.e=new Nt),t.e}function Zl(){Zl=P,Qjt=new Sk,tHt=new hv}function s$(){s$=P,F1t=new Pn,zzt=new Tt}function cL(){cL=P,hB=new Bc,fB=new vS}function die(t){return uC(),$i((Pkt(),EWt),t)}function pie(t){return Mm(),$i((p5t(),_Wt),t)}function gie(t){return $M(),$i(($5t(),w$t),t)}function mie(t){return qC(),$i((RLt(),_$t),t)}function bie(t){return Sf(),$i((Ekt(),PWt),t)}function wie(t){return Zh(),$i((Mkt(),RWt),t)}function vie(t){return LL(),$i((Skt(),NWt),t)}function _ie(t){return mu(),$i((HMt(),u$t),t)}function yie(t){return ZL(),$i((m5t(),U$t),t)}function xie(t){return wN(),$i((Lkt(),F$t),t)}function Mie(t){return mm(),$i((Tkt(),b$t),t)}function Eie(t){return tN(),$i((Akt(),k$t),t)}function Sie(t){return nN(),$i((kkt(),L$t),t)}function Tie(t){return AN(),$i((Ckt(),N$t),t)}function Cie(t){return QN(),$i((g5t(),B$t),t)}function Aie(t){return f7(),$i((V5t(),Z$t),t)}function kie(t){return RN(),$i((b5t(),Y$t),t)}function Lie(t){return Qg(),$i((dLt(),J$t),t)}function Pie(t){return n0(),$i((PPt(),tVt),t)}function Iie(t){return md(),$i((DLt(),eVt),t)}function Rie(t){return Kh(),$i((w5t(),kVt),t)}function Die(t){return Ht(),$i((tLt(),LVt),t)}function Nie(t){return Ls(),$i((SLt(),AVt),t)}function Oie(t){return Yg(),$i((_5t(),SVt),t)}function Bie(t){return i0(),$i((WPt(),TVt),t)}function Fie(t){return H1(),$i((fLt(),CVt),t)}function Uie(t){return Js(),$i((pLt(),_Vt),t)}function zie(t){return ip(),$i((q5t(),yVt),t)}function jie(t){return gd(),$i((X5t(),xVt),t)}function Hie(t){return _7(),$i((NLt(),MVt),t)}function Gie(t){return Ku(),$i((Z5t(),NVt),t)}function Wie(t){return ma(),$i((GPt(),OVt),t)}function $ie(t){return i7(),$i((K5t(),BVt),t)}function Vie(t){return Tu(),$i((J5t(),zVt),t)}function qie(t){return Ch(),$i((v5t(),HVt),t)}function Xie(t){return hu(),$i((y5t(),WVt),t)}function Zie(t){return Ha(),$i((x5t(),VVt),t)}function Yie(t){return X7(),$i((xEt(),gqt),t)}function Kie(t){return Sm(),$i((Y5t(),bqt),t)}function Jie(t){return KM(),$i((IPt(),kqt),t)}function o$(t,e,n){return t=e)throw K(new g9)}function Sre(t,e){var n;for(n=0;n0?1:0}function iot(t){return!Array.isArray(t)&&t.sl===B}function ECt(t){return t!=null&&v$(t)&&t.sl!==B}function rot(t,e){return ct(e,23)&&Pp(t,a(e,23))}function SCt(t,e){return ct(e,23)&&Tue(t,a(e,23))}function kre(t,e){return t.a.get(e)!==void 0}function sot(t){return pu(t,26)*a4+pu(t,27)*u4}function TCt(t,e){return Oue(new ie,new Vj(t),e)}function oot(t,e){if(t==null)throw K(new pT(e))}function v2(t,e,n){return Su(t.a,e),bot(t,e.g,n)}function BD(t,e,n){C6t(0,e,t.length),IL(t,0,e,n)}function hm(t,e,n){Yv(e,t.c.length),B5(t.c,e,n)}function Lre(t,e,n){tDt(n,t,1),Ut(e,new MMt(n,t))}function Pre(t,e,n){jC(n,t,1),Ut(e,new _Mt(n,t))}function cot(){this.d=new xi,this.e=new z4t(this)}function CCt(){this.b=new tn,this.c=new U4t(this)}function ACt(){sAt(),this.e=new Fr,this.d=new Fr}function d$(t,e){this.b=new Fr,this.a=t,this.c=e}function Wv(t,e,n){$1(),this.e=t,this.d=e,this.a=n}function FD(t,e,n){var i;t&&(i=t.i,i.d=e,i.a=n)}function UD(t,e,n){var i;t&&(i=t.i,i.c=e,i.b=n)}function kCt(t,e,n){var i;for(i=0;i0?y.Math.log(t/e):-100}function qre(t,e){return ro(t.c.c+t.c.b,e.c.c+e.c.b)}function x$(t,e){this.d=t,$n.call(this,t),this.e=e}function Wb(t,e,n){return Wle(t,e.g,n),Su(t.c,e),t}function Xre(t){return T_(t,(Js(),ah)),t.d=!0,t}function si(t){if(t==null)throw K(new t2);return t}function _2(t){if(t==null)throw K(new t2);this.a=t}function M$(t){t.a=null,t.e=null,uu(t.b),t.d=0,++t.c}function E$(t){return!t.j&&Ynt(t,mve(t.g,t.b)),t.j}function Zre(t){return t.b.k.a+=t.a.f*(t.a.a-1),null}function QT(t){zv(t.b!=-1),ym(t.c,t.a=t.b),t.b=-1}function HCt(t){GEt(this),CG(this.a,Eat(8>t?8:t)<<1)}function yot(t,e){Ba.call(this,1),this.a=t,this.b=e}function S$(t,e,n){this.a=t,rV(n,e),this.c=e,this.b=n}function GCt(t,e){this.a=t,this.b=e,this.c=this.b.lc()}function dL(t,e){sSt(t,ct(e,184)?e:a(e,1630).rk())}function WCt(t){return si(t),ct(t,476)?a(t,476):Yc(t)}function xot(t,e){return e?yo(t,e):!1}function pM(t,e){return t.a+=String.fromCharCode(e),t}function E1(t,e){return t.a+=String.fromCharCode(e),t}function Yre(t,e,n,i){return t.a+=""+e.substr(n,i-n),t}function Kre(t,e,n){var i;return i=I2(t,e),Ikt(t,e,n),i}function Jre(t,e,n){var i;for(i=0;i=t.g}function dse(t,e){return S2(),t==e0(e)?Pm(e):e0(e)}function wr(t,e,n){return Es(e)?tc(t,e,n):Cu(t.d,e,n)}function k$(t,e,n){var i;return i=BV(t,e,n),dht(t,i)}function eC(t,e){var n;return n=t.a._b(),ice(e,n),n-1-e}function Cot(t,e){var n;return n=new yL(t),nut(n,e),n}function Vr(t,e,n){return lee(n==null||Kve(t,n)),t[e]=n}function x2(t,e){var n;n=t.a.length,I2(t,n),Ikt(t,n,e)}function JCt(t,e){var n;++t.j,n=t.hi(),t.Wh(t.Ch(n,e))}function pse(t,e){x2(t,new _2(e.f!=null?e.f:""+e.g))}function gse(t,e){x2(t,new _2(e.f!=null?e.f:""+e.g))}function QCt(t){this.b=new Nt,this.a=new Nt,this.c=t}function dl(t){this.c=new go,this.a=new Nt,this.b=t}function t4t(t){vst.call(this),this.a=new go,this.c=t}function Aot(t,e,n){lT.call(this,e),this.a=t,this.b=n}function kot(t,e,n){Ba.call(this,t),this.a=e,this.b=n}function Lot(t,e,n){this.a=t,u9.call(this,e),this.b=n}function e4t(t,e,n){this.a=t,uct.call(this,8,e,null,n)}function n4t(t){this.c=t,this.a=new Fr,this.b=new Fr}function i4t(t){this.c=t,this.b=this.c.a,this.a=this.c.e}function mse(t){this.a=(En(ui),ui),this.b=t,new _it}function dm(t){return!t.d&&(t.d=new Ss(Do,t,1)),t.d}function r4t(t,e){var n;return n=t.b.$b(e),t.d.b.$b(n),n}function Pot(t,e){for(;e-- >0;)t=t<<1|(t<0?1:0);return t}function Rp(t,e){return zt(t)===zt(e)||t!=null&&Fi(t,e)}function pm(t,e){return KT(e,t.a.c.length),Ee(t.a,e)}function L$(t){return y.Math.sqrt(t.a*t.a+t.b*t.b)}function bse(t){return String.fromCharCode.apply(null,t)}function Dp(t){return ct(t,13)?a(t,13)._b():lC(t.tc())}function s4t(t){return ct(t,543)?t:new sMt(t)}function Mc(t){return!t.a&&t.c?t.c.b:t.a}function P$(t){t.c?P$(t.c):(t.d=!0,zbe(t))}function Vv(t){t.c?Vv(t.c):(jM(t),t.d=!0)}function o4t(t){gL(t.a),t.b=dt(un,te,1,t.b.length,5,1)}function I$(t){this.c=t,this.b=t.a.b.a,$rt(t.a.c,this)}function wse(t,e){t.c<0||t.b.b0?new Pst(t-1,e):new Pst(t,e)}function d4t(t,e){return SD(),new xut(new _St(t),new vSt(e))}function wM(t){if(du(t.d),t.d.d!=t.c)throw K(new C)}function Cse(t,e){var n;return n=t.a.get(e),n??[]}function Ase(t,e){var n;return n=zi(t.f,e),wat(e,n),null}function _i(t,e,n,i){return XPt(t,e,n,!1),qat(t,i),t}function kse(t,e){return t.a=$h(t.a,0,e)+""+oL(t.a,e+1),t}function Lse(t){return t.j.c=dt(un,te,1,0,5,1),t.a=-1,t}function Pse(t){return!t.c&&(t.c=new pn(Si,t,5,8)),t.c}function Ise(t){return!t.b&&(t.b=new pn(Si,t,4,7)),t.b}function N$(t){return!t.n&&(t.n=new Wt(ic,t,1,7)),t.n}function Oot(t){return!t.c&&(t.c=new Wt(Rl,t,9,9)),t.c}function vM(t){return t.e==vE&&Xnt(t,qfe(t.g,t.b)),t.e}function pL(t){return t.f==vE&&Znt(t,ype(t.g,t.b)),t.f}function p4t(t){return HT(t==null||v$(t)&&t.sl!==B),t}function Bot(t,e){if(t==null)throw K(new pT(e));return t}function $b(t){var e;return e=t.b,!e&&(t.b=e=new Nj(t)),e}function Fot(t){var e;return e=t.Gh(t.f),ni(t,e),e.hc()}function gL(t){var e;for(e=t.tc();e.hc();)e.ic(),e.jc()}function g4t(t){return Hn(t.bi&&++i,i}function Kd(t){var e,n;return n=(e=new m1,e),mC(n,t),n}function F$(t){var e,n;return n=(e=new m1,e),T8t(n,t),n}function Bse(t){if(t.p!=5)throw K(new na);return or(t.f)}function Fse(t){if(t.p!=5)throw K(new na);return or(t.k)}function S4t(t){return t?t.Wb():!null.tc().hc()}function ZD(t){return t.n&&(t.e!==TOt&&t.Pd(),t.j=null),t}function Use(t){return t!=null&&MT(WF,t.toLowerCase())}function U$(t){this.f=t,this.c=this.f.e,t.f>0&&ZRt(this)}function zg(t,e,n,i){this.e=t,this.a=e,this.c=n,this.d=i}function T4t(t,e,n,i){ju(),Kkt.call(this,e,n,i),this.a=t}function C4t(t,e,n,i){ju(),Kkt.call(this,e,n,i),this.a=t}function A4t(t,e,n,i){this.b=t,this.c=i,K9.call(this,e,n)}function k4t(t,e){this.a=t,Yee.call(this,t,a(t.d,15).fd(e))}function ld(t){t.a.a=t.c,t.c.b=t.a,t.a.b=t.c.a=null,t.b=0}function zot(t,e){return t.b=e.b,t.c=e.c,t.d=e.d,t.a=e.a,t}function zse(t,e,n){t.i=0,t.e=0,e!=n&&w6t(t,e,n)}function jse(t,e,n){t.i=0,t.e=0,e!=n&&v6t(t,e,n)}function L4t(t,e){var n;return n=wV(e),a(zi(t.c,n),21).a}function Hse(t,e,n){return n>=0&&le(t.substr(n,e.length),e)}function z$(t,e){return e==null?!!Ea(t.d,null):kre(t.e,e)}function P4t(t,e){t.d&&!t.d.a&&(TG(t.d,e),P4t(t.d,e))}function I4t(t,e){t.e&&!t.e.a&&(TG(t.e,e),I4t(t.e,e))}function R4t(t,e){this.g=t,this.d=Y(Z(Cl,1),Ih,8,0,[e])}function jot(t,e){new Fr,this.a=new Va,this.b=t,this.c=e}function D4t(){glt(this,new y8),this.wb=(S1(),Ae),Z3()}function N4t(t,e){return ct(e,166)&&le(t.b,a(e,166).Lf())}function Gse(t,e){return fu(t),fu(e),Fxt(a(t,23),a(e,23))}function Hot(t,e,n,i,r,c){U5t.call(this,t,e,n,i,r,c?-2:-1)}function O4t(t,e,n,i){Mrt.call(this,e,n),this.b=t,this.a=i}function B4t(t,e){vQt.call(this,new m$(t)),this.a=t,this.b=e}function Got(t){this.b=t,this.c=t,t.e=null,t.c=null,this.a=1}function F4t(t,e){var n;return n=Ng(t.ql),e==null?n:n+": "+e}function ns(t,e){return D1(Nre(Vo(t)?gl(t):t,Vo(e)?gl(e):e))}function Xh(t,e){return D1(Ore(Vo(t)?gl(t):t,Vo(e)?gl(e):e))}function Wse(t,e){return D1(Bre(Vo(t)?gl(t):t,Vo(e)?gl(e):e))}function Wot(t){return t&&t.hashCode?t.hashCode():cm(t)}function _M(t){return we(),ct(t,49)?new HG(t):new oD(t)}function we(){we=P,fo=new xe,ap=new hn,JO=new Se}function yM(){yM=P,O1t=new ke,Nzt=new ke,B1t=new mn}function $ot(){$ot=P,Wzt=new An,Vzt=new cot,$zt=new zn}function xM(){xM=P;var t,e;e=!Lfe(),t=new ft,yK=e?new Q:t}function U4t(t){this.c=t,this.b=new Ob(a(si(new Je),65))}function z4t(t){this.c=t,this.b=new Ob(a(si(new Li),65))}function Np(){this.a=new Va,this.b=(Ah(3,Y2),new Vu(3))}function j$(t,e,n){this.a=t,this.e=!1,this.d=e,this.c=n}function j4t(t,e,n){return t.f?t.f.re(e,n):!1}function Et(t){return!t.s&&(t.s=new Wt(Ra,t,21,17)),t.s}function Wi(t){return!t.q&&(t.q=new Wt(ph,t,11,10)),t.q}function Vot(t){return!t.a&&(t.a=new Wt(zr,t,10,11)),t.a}function $se(t,e){var n;return n=Urt(t.a,e),n&&(e.d=null),n}function qv(t,e,n,i){Vr(t.c[e.g],n.g,i),Vr(t.c[n.g],e.g,i)}function YD(t,e,n,i){Vr(t.c[e.g],e.g,n),Vr(t.b[e.g],e.g,i)}function M2(t,e,n){lN(),t&&wr(ett,t,e),t&&wr(gI,t,n)}function Vse(t,e){aSt(t,or(ns(M1(e,24),eO)),or(ns(e,eO)))}function da(t){var e;return e=a(an(t,16),24),e||t.Rg()}function qse(t){if(t.p!=0)throw K(new na);return xT(t.f,0)}function Xse(t){if(t.p!=0)throw K(new na);return xT(t.k,0)}function Bo(t){return t.u||(pl(t),t.u=new QSt(t,t)),t.u}function Zse(t){return t==hp||t==Zp}function Yse(t){y9(),y.setTimeout(function(){throw t},0)}function H$(t){this.c=t.c,this.d=t.d,this.b=t.b,this.a=t.a}function Op(t,e){this.e=t,this.a=un,this.b=gNt(e),this.c=e}function H4t(){this.b=new $r,this.c=new Fr,this.d=new LG}function Sf(){Sf=P,Ym=new frt(hE,0),Xp=new frt(lE,1)}function mm(){mm=P,rg=new brt(lE,0),iy=new brt(hE,1)}function G4t(){G4t=P,Hb(),l1t=($o(),xzt),wzt=new Dot(new Ob(l1t))}function Kse(t){return G4t(),si(t),l1t==t?wzt:new Dot(new Ob(t))}function jg(t,e,n,i,r,c,l){return new nV(t.e,e,n,i,r,c,l)}function W4t(t,e,n,i,r,c){this.a=t,DV.call(this,e,n,i,r,c)}function $4t(t,e,n,i,r,c){this.a=t,DV.call(this,e,n,i,r,c)}function qot(t){this.e=t,this.b=this.e.a.entries(),this.a=[]}function Xot(t){t.d=t.d-15,t.b=t.b-15,t.c=t.c+15,t.a=t.a+15}function V4t(t,e){var n;n=a(Uct(t.e,e),249),n&&(t.d=!0)}function Zc(t,e){return e==null?Ua(Ea(t.d,null)):AT(t.e,e)}function Ea(t,e){return y6t(t,e,Cse(t,e==null?0:t.b.he(e)))}function q4t(t,e){return e===t?"(this Map)":e==null?tu:Yc(e)}function Jse(t,e){return t.a?e.pg().tc():a(e.pg(),64).oh()}function bL(t,e,n){return t.a=$h(t.a,0,e)+(""+n)+oL(t.a,e),t}function Hg(t,e){if(e==null)throw K(new t2);return Ufe(t,e)}function Qse(){return o7(),Y(Z(Y1t,1),jt,391,0,[kK,Z1t])}function toe(){return xN(),Y(Z(J1t,1),jt,390,0,[K1t,LK])}function eoe(){return EN(),Y(Z(xgt,1),jt,387,0,[BK,oB])}function noe(){return pN(),Y(Z(P0t,1),jt,386,0,[L0t,fJ])}function ioe(){return C2(),Y(Z(D0t,1),jt,317,0,[M6,x6])}function roe(){return aN(),Y(Z(Q0t,1),jt,383,0,[CJ,J0t])}function soe(){return nN(),Y(Z(ewt,1),jt,388,0,[pQ,twt])}function ooe(){return tN(),Y(Z(Qbt,1),jt,438,0,[dQ,Jbt])}function coe(){return AN(),Y(Z(nwt,1),jt,447,0,[pF,NE])}function aoe(){return LL(),Y(Z(zbt,1),jt,437,0,[Ubt,sF])}function uoe(){return Sf(),Y(Z(LWt,1),jt,466,0,[Ym,Xp])}function loe(){return Zh(),Y(Z(IWt,1),jt,465,0,[y0,rf])}function hoe(){return mm(),Y(Z(m$t,1),jt,417,0,[rg,iy])}function foe(){return uC(),Y(Z(MWt,1),jt,472,0,[nA,eA])}function doe(){return wN(),Y(Z(rwt,1),jt,389,0,[iwt,wQ])}function KD(t,e,n,i){return n>=0?t.Dg(e,n,i):t.lg(null,n,i)}function poe(t,e){var n;n=a(cn(e,($T(),uA)),35),t7t(t,n)}function G$(t){var e;return e=fl(t.b),yo(e,t.c),yo(e,t.i),e}function Zot(t){return zt(t.a)===zt((HV(),rtt))&&Lye(t),t.a}function X4t(t){return t.b.b==0?t.a.Be():u$(t.b)}function Yot(t){var e;return e=t.g,a(e||(t.g=new E8(t)),15)}function Zh(){Zh=P,y0=new drt(PY,0),rf=new drt("UP",1)}function W$(t,e){Fnt(this,new We(t.a,t.b)),Unt(this,fl(e))}function Z4t(t,e){mD.call(this),Kct(this),this.a=t,this.c=e}function Kot(t,e,n){ju(),lT.call(this,e),this.a=t,this.b=n}function $$(t,e,n){Ai(),Ba.call(this,t),this.b=e,this.a=n}function goe(t,e){var n=_K[t.charCodeAt(0)];return n??t}function moe(t,e){var n;return n=wue(t.f,e),sr(GW(n),t.f.d)}function Y4t(t){var e;e=t.c.b.b,t.b=e,t.a=t.c.b,e.a=t.c.b.b=t}function boe(t){return t.b==0?null:(Hn(t.b!=0),Ql(t,t.a.a))}function woe(t){return so(Yd(Ka(pu(t,32)),32),Ka(pu(t,32)))}function K4t(t){return ct(t,62)&&(a(a(t,17),62).Bb&ca)!=0}function Tr(t){return Math.max(Math.min(t,qi),-2147483648)|0}function JD(t,e){return hct(e),Wae(t,dt(Gn,pi,22,e,15,1),e)}function voe(t,e){return S2(),t==io(e0(e))||t==io(Pm(e))}function J4t(t){var e;return e=dN(t),"n_"+(e??""+t.o)}function Q4t(t){this.b=(Ao(),Ao(),Ao(),vzt),this.a=a(si(t),43)}function tAt(t){mD.call(this),Kct(this),this.a=t,this.c=!0}function eAt(t,e,n){this.d=t,this.b=new Nt,this.c=e,this.a=n}function V$(t,e,n,i){var r;r=new dTt,e.a[n.g]=r,v2(t.b,i,r)}function nAt(t,e){var n=t.a=t.a||[];return n[e]||(n[e]=t._d(e))}function wL(t,e){var n;n=t.q.getHours(),t.q.setDate(e),n4(t,n)}function iAt(t){var e;return e=new S9(XV(t.length)),$L(e,t),e}function _oe(t){function e(){}return e.prototype=t||{},new e}function yoe(t,e){return KPt(t,e)?(ZLt(t),!0):!1}function QD(t){return t.Db>>16!=3?null:a(t.Cb,35)}function Tf(t){return t.Db>>16!=9?null:a(t.Cb,35)}function xoe(t){if(t.p!=2)throw K(new na);return or(t.f)&qr}function Moe(t){if(t.p!=2)throw K(new na);return or(t.k)&qr}function tN(){tN=P,dQ=new wrt(jBt,0),Jbt=new wrt("FAN",1)}function q$(t,e,n){var i;i=b6t(t,e,n),t.b=new FV(i.c.length)}function tc(t,e,n){return e==null?Cu(t.d,null,n):Tm(t.e,e,n)}function Jot(t,e){return Jg(so(Jg(a(t,149).a).a,a(e,149).a))}function rAt(){rAt=P,Fbt=d4t(Xt(1),Xt(4)),Bbt=d4t(Xt(1),Xt(2))}function sAt(){sAt=P,oWt=Xa(new as,(Mo(),Yo),(Po(),yB))}function oAt(){oAt=P,sWt=Xa(new as,(Mo(),Yo),(Po(),yB))}function cAt(){cAt=P,SWt=Ni(new as,(Mo(),Yo),(Po(),U4))}function Mu(){Mu=P,AWt=Ni(new as,(Mo(),Yo),(Po(),U4))}function aAt(){aAt=P,kWt=Ni(new as,(Mo(),Yo),(Po(),U4))}function X$(){X$=P,DWt=Ni(new as,(Mo(),Yo),(Po(),U4))}function uAt(){uAt=P,P$t=Xa(new as,($M(),sA),(qC(),rQ))}function lAt(t){return t.Db>>16!=6?null:a(t.Cb,105)}function hAt(t){return t.Db>>16!=7?null:a(t.Cb,207)}function fAt(t){return t.Db>>16!=7?null:a(t.Cb,253)}function io(t){return t.Db>>16!=11?null:a(t.Cb,35)}function Vb(t){return t.Db>>16!=17?null:a(t.Cb,24)}function dAt(t){return t.Db>>16!=3?null:a(t.Cb,139)}function MM(t){return t.Db>>16!=6?null:a(t.Cb,207)}function rC(t,e,n,i,r,c){return new Qd(t.e,e,t.pi(),n,i,r,c)}function Qot(t,e){return SCt(t.a,e)?bot(t,a(e,23).g,null):null}function Eoe(t,e){return MCt(Ka(t.q.getTime()),Ka(e.q.getTime()))}function Soe(t,e){var n;n=t.q.getHours(),t.q.setMonth(e),n4(t,n)}function Hs(t,e){t.c&&Lc(t.c.f,t),t.c=e,t.c&&Ut(t.c.f,t)}function Ks(t,e){t.c&&Lc(t.c.a,t),t.c=e,t.c&&Ut(t.c.a,t)}function Ts(t,e){t.d&&Lc(t.d.d,t),t.d=e,t.d&&Ut(t.d.d,t)}function ds(t,e){t.g&&Lc(t.g.i,t),t.g=e,t.g&&Ut(t.g.i,t)}function pAt(t,e){return t.b+=e.b,t.c+=e.c,t.d+=e.d,t.a+=e.a,t}function tct(t){return rD(t.c),t.e=t.a=t.c,t.c=t.c.c,++t.d,t.a.f}function gAt(t){return rD(t.e),t.c=t.a=t.e,t.e=t.e.e,--t.d,t.a.f}function mAt(t,e){var n;return n=new dl(t),e.c[e.c.length]=n,n}function Toe(t,e){var n,i;n=e.c,i=n!=null,i&&x2(t,new _2(e.c))}function Coe(t){var e;e=pfe(a(cn(t,(Kb(),_Q)),349)),e.Ef(t)}function Z$(t,e){ct(t.Cb,96)&&YC(pl(a(t.Cb,96)),4),kh(t,e)}function eN(t,e){ct(t.Cb,248)&&(a(t.Cb,248).tb=null),kh(t,e)}function Aoe(t,e){sIt(t,e),ct(t.Cb,96)&&YC(pl(a(t.Cb,96)),2)}function koe(t,e){nD(this),this.f=e,this.g=t,ZD(this),this.Pd()}function E2(t){this.c=new Fr,this.b=t.b,this.d=t.c,this.a=t.a}function bAt(){this.a=new qa,this.e=new $r,this.g=0,this.i=0}function T1(t,e,n){j6t(e,n,t._b()),this.c=t,this.a=e,this.b=n-e}function Gs(t,e){this.a=t,j3.call(this,t),Yv(e,t._b()),this.b=e}function wAt(t){this.a=t,this.b=dt(yWt,wt,1637,t.e.length,0,2)}function Xv(t){this.a=y.Math.cos(t),this.b=y.Math.sin(t)}function Ei(t,e){this.b=(En(t),t),this.a=e&Bm?e:e|64|Lf}function vAt(t,e,n){var i;j6t(e,n,t.c.length),i=n-e,Git(t.c,e,i)}function _At(t,e){var n;return n=a(WM(fm(t.a),e),13),n?n._b():0}function yAt(t){var e,n;return n=(Z3(),e=new m1,e),mC(n,t),n}function xAt(t){var e,n;return n=(Z3(),e=new m1,e),mC(n,t),n}function Zv(t){return _T(),ct(t.g,8)?a(t.g,8):null}function Loe(t,e){var n;n=a(zi(t.g,e),57),pd(e.d,new TMt(t,n))}function Za(t,e){return Jo(),$ct(e)?new LD(e,t):new $5(e,t)}function Yl(t){return zo(Y(Z(ss,1),wt,9,0,[t.g.k,t.k,t.a]))}function Poe(){return AC(),Y(Z(Xjt,1),jt,412,0,[KK,JK,YK])}function Ioe(){return U1(),Y(Z(tf,1),jt,150,0,[V1t,Qh,pw])}function Roe(){return tp(),Y(Z(mHt,1),jt,280,0,[T6,Y_,dx])}function Doe(){return RM(),Y(Z(K0t,1),jt,318,0,[SJ,TJ,IB])}function Noe(){return CN(),Y(Z(O0t,1),jt,319,0,[N0t,TB,pJ])}function Ooe(){return IN(),Y(Z(F0t,1),jt,384,0,[gJ,B0t,mJ])}function Boe(){return o_(),Y(Z(uHt,1),jt,406,0,[bJ,E6,z4])}function Foe(){return Fo(),Y(Z(QGt,1),jt,410,0,[tF,Ga,ba])}function Uoe(){return t7(),Y(Z(Pbt,1),jt,345,0,[kbt,QJ,Lbt])}function zoe(){return LN(),Y(Z(Dbt,1),jt,347,0,[Rbt,tQ,Ibt])}function joe(){return UN(),Y(Z(Obt,1),jt,346,0,[eQ,nQ,W6])}function Hoe(){return D2(),Y(Z(Nbt,1),jt,385,0,[G6,j6,H6])}function Goe(){return dC(),Y(Z(Dgt,1),jt,348,0,[jK,zK,HK])}function Woe(){return ZL(),Y(Z(cwt,1),jt,349,0,[gF,swt,owt])}function $oe(){return QN(),Y(Z(O$t,1),jt,401,0,[bQ,gQ,mQ])}function Voe(){return Mm(),Y(Z(vWt,1),jt,413,0,[eF,tA,nF])}function qoe(){return hu(),Y(Z(GVt,1),jt,419,0,[jf,cb,fh])}function Xoe(){return Ha(),Y(Z($Vt,1),jt,420,0,[Fh,ab,dh])}function Zoe(){return Kh(),Y(Z(Mvt,1),jt,275,0,[cy,rb,kF])}function Yoe(){return RN(),Y(Z(_wt,1),jt,277,0,[xQ,vwt,wwt])}function Koe(){return Ch(),Y(Z(Pw,1),jt,203,0,[lc,ta,hc])}function Joe(){return Yg(),Y(Z(vvt,1),jt,316,0,[AF,kx,mA])}function MAt(){MAt=P,yzt=Vi((Fv(),Y(Z(vK,1),jt,350,0,[h6,f6])))}function nN(){nN=P,pQ=new vrt("DFS",0),twt=new vrt("BFS",1)}function S2(){S2=P,sB=new Nt,OK=(ts(),new vi),NK=new Nt}function EAt(t,e,n){var i;i=new q,i.b=e,i.a=n,++e.b,Ut(t.d,i)}function SAt(t,e,n){Ba.call(this,25),this.b=t,this.a=e,this.c=n}function Eu(t){Ai(),Ba.call(this,t),this.c=!1,this.a=!1}function Qoe(t){return t.a==(CM(),XF)&&Vnt(t,Ube(t.g,t.b)),t.a}function sC(t){return t.d==(CM(),XF)&&qnt(t,$ve(t.g,t.b)),t.d}function tce(t,e){var n;return n=(En(t),t).g,zrt(!!n),En(e),n(e)}function Y$(t,e){var n,i;return i=dM(t,e),n=t.a.fd(i),new V3t(t,n)}function EM(t){var e;return Vo(t)?(e=t,e==-0?0:e):fue(t)}function ece(t){return t.Db>>16!=6?null:a(vX(t),207)}function G(t){return Hn(t.a=e)throw K(new Uc(a0e(t,e)));return t}function TAt(t,e,n){if(t<0||en)throw K(new Uc(Uge(t,e,n)))}function rce(t){return Ao(),E1(Zat((al(),a1t),E1(new im,91),t),93).a}function iN(t){return si(t),Xq((Ao(),new $d(id(Zd(t.a,new X)))))}function rN(t){return new Vu((Ah(t,hZ),NL(so(so(5,t),t/10|0))))}function ect(t,e){return t&&t.equals?t.equals(e):zt(t)===zt(e)}function nct(t,e){return e==0?!!t.o&&t.o.f!=0:Oq(t,e)}function sce(t,e){var n;n=lt(Yt(t.a.xe((dr(),TF)))),tOt(t,e,n)}function CAt(t,e,n){var i;i=xr(t.d,e),i>=0?T7(t,i,n):Xlt(t,e,n)}function J$(t,e,n){var i;i=t.d[e.o],t.d[e.o]=t.d[n.o],t.d[n.o]=i}function AAt(t,e){var n;for(n=t+"";n.length0&&t.a[--t.d]==0;);t.a[t.d++]==0&&(t.e=0)}function oce(t){return!!t.u&&kc(t.u.a).i!=0&&!(t.n&&Hq(t.n))}function oN(t){tC(),this.a=(we(),ct(t,49)?new HG(t):new oD(t))}function kAt(){this.c=new QEt,this.a=new fTt,this.b=new wEt,_3t()}function LAt(t,e,n){this.d=t,this.j=e,this.e=n,this.o=-1,this.p=3}function PAt(t,e,n){this.d=t,this.k=e,this.f=n,this.o=-1,this.p=5}function IAt(t,e,n,i,r,c){Qct.call(this,t,e,n,i,r),c&&(this.o=-2)}function RAt(t,e,n,i,r,c){tat.call(this,t,e,n,i,r),c&&(this.o=-2)}function DAt(t,e,n,i,r,c){xct.call(this,t,e,n,i,r),c&&(this.o=-2)}function NAt(t,e,n,i,r,c){iat.call(this,t,e,n,i,r),c&&(this.o=-2)}function OAt(t,e,n,i,r,c){Mct.call(this,t,e,n,i,r),c&&(this.o=-2)}function BAt(t,e,n,i,r,c){eat.call(this,t,e,n,i,r),c&&(this.o=-2)}function FAt(t,e,n,i,r,c){nat.call(this,t,e,n,i,r),c&&(this.o=-2)}function UAt(t,e,n,i,r,c){Ect.call(this,t,e,n,i,r),c&&(this.o=-2)}function zAt(t,e,n,i){lT.call(this,n),this.b=t,this.c=e,this.d=i}function jAt(t,e){this.f=t,this.a=(CM(),qF),this.c=qF,this.b=e}function HAt(t,e){this.g=t,this.d=(CM(),XF),this.a=XF,this.b=e}function GAt(t,e){!t.c&&(t.c=new _s(t,0)),ZX(t.c,(fr(),yI),e)}function oc(t,e,n,i,r,c){return XPt(t,e,n,c),Z6t(t,i),Y6t(t,r),t}function WAt(t,e){return ct(e,38)?qq(t.a,a(e,38)):!1}function cce(t){if(!("stack"in t))try{throw t}catch{}return t}function ace(t){if(t.p!=1)throw K(new na);return or(t.f)<<24>>24}function uce(t){if(t.p!=1)throw K(new na);return or(t.k)<<24>>24}function lce(t){if(t.p!=7)throw K(new na);return or(t.k)<<16>>16}function hce(t){if(t.p!=7)throw K(new na);return or(t.f)<<16>>16}function cN(t){rlt(),aSt(this,or(ns(M1(t,24),eO)),or(ns(t,eO)))}function $At(){$At=P,tjt=Vi((T9(),Y(Z(ggt,1),jt,439,0,[IK])))}function aN(){aN=P,CJ=new lrt(m4,0),J0t=new lrt("TOP_LEFT",1)}function VAt(t,e){var n;t.e=new pit,n=iw(e),gc(n,t.c),ZDt(t,n,0)}function pe(t,e,n,i){var r;r=new _R,r.a=e,r.b=n,r.c=i,Xi(t.b,r)}function Sa(t,e,n,i){var r;r=new _R,r.a=e,r.b=n,r.c=i,Xi(t.a,r)}function fce(t,e,n){var i;return i=a(t.Hc().Vb(e),13),!!i&&i.pc(n)}function qAt(t,e,n){var i;return i=a(t.Hc().Vb(e),13),!!i&&i.vc(n)}function XAt(t,e){var n;return n=1-e,t.a[n]=kN(t.a[n],n),kN(t,e)}function SM(t){return Hn(t.b.b!=t.d.a),t.c=t.b=t.b.b,--t.a,t.c.c}function ZAt(t){return kD(t),rD(t.c),t.e=t.a=t.c,t.c=t.c.b,++t.d,t.a}function YAt(t){return kD(t),rD(t.e),t.c=t.a=t.e,t.e=t.e.d,--t.d,t.a}function In(t){if(!Jn(t))throw K(new J);return t.c=t.b,t.b.ic()}function KAt(t,e){return ct(e,38)?qq(t.a,a(e,38)):!1}function JAt(t,e){return ct(e,38)?qq(t.a,a(e,38)):!1}function QAt(t){var e;return Vv(t),e=new en,Ost(t.a,new Yj(e)),e}function rct(){var t,e,n;return e=(n=(t=new m1,t),n),Ut(r_t,e),e}function dce(t){var e;return e=(mu(),mu(),ZWt),t.d&&fX(t),SQt(),e}function sct(t){return t.j.c=dt(un,te,1,0,5,1),gL(t.c),Lse(t.a),t}function as(){hxt.call(this),this.j.c=dt(un,te,1,0,5,1),this.a=-1}function tkt(t,e,n){this.b=new Q8(this),this.c=t,this.f=e,this.d=n}function pce(t,e,n){t.d&&Lc(t.d.d,t),t.d=e,t.d&&hm(t.d.d,n,t)}function gce(t){return!!t.a&&Ya(t.a.a).i!=0&&!(t.b&&Gq(t.b))}function mce(t){return Mu(),!ec(t)&&!(!ec(t)&&t.c.g.c==t.d.g.c)}function bce(t){return lN(),lm(ett,t)?a(zi(ett,t),337).Mf():null}function cC(t){return ct(t,13)?new lL((al(),a(t,13))):Qie(t.tc())}function wce(t,e,n){return n.f.c.length>0?vot(t.a,e,n):vot(t.b,e,n)}function ekt(t,e,n){var i;return i=RC(n),wr(t.b,i,e),wr(t.c,e,n),e}function bm(t,e){var n,i;return n=Hg(t,e),i=null,n&&(i=n.Vd()),i}function vL(t,e){var n,i;return n=Hg(t,e),i=null,n&&(i=n.Yd()),i}function TM(t,e){var n,i;return n=I2(t,e),i=null,n&&(i=n.Yd()),i}function Jd(t,e){var n,i;return n=Hg(t,e),i=null,n&&(i=V8t(n)),i}function oct(t){var e;return e=t.Fh(t.i),t.i>0&&Aa(t.g,0,e,0,t.i),e}function _L(t){var e;return e=(si(t),new Eh((al(),t))),XC(e),eq(e)}function kc(t){return t.n||(pl(t),t.n=new iSt(Do,t),Bo(t)),t.n}function nkt(t,e){var n;return n=new Db,t.wd(n),n.a+="..",e.xd(n),n.a}function ikt(t,e){k9();var n;return n=a(zi(GF,t),47),!n||n.Li(e)}function wm(t){return ct(t,13)?a(t,13).Wb():!t.tc().hc()}function vce(t){if(t.ee())return null;var e=t.n,n=VO[e];return n}function Yn(t){return Hn(t.b!=t.d.c),t.c=t.b,t.b=t.b.a,++t.a,t.c.c}function cct(t,e){En(e),Vr(t.a,t.c,e),t.c=t.c+1&t.a.length-1,aRt(t)}function aC(t,e){En(e),t.b=t.b-1&t.a.length-1,Vr(t.a,t.b,e),aRt(t)}function rkt(t){var e;e=t.pg(),this.a=ct(e,64)?a(e,64).oh():e.tc()}function _ce(t,e,n){var i;i=kfe();try{return rne(t,e,n)}finally{aae(i)}}function act(t,e,n,i){return ct(n,49)?new ASt(t,e,n,i):new lot(t,e,n,i)}function yce(){return vN(),Y(Z(QO,1),jt,278,0,[CK,G1t,W1t,$1t])}function xce(){return BM(),Y(Z(Ojt,1),jt,373,0,[$m,mw,gw,V_])}function Mce(){return z2(),Y(Z(Yzt,1),jt,304,0,[p6,d6,g6,m6])}function Ece(){return zC(),Y(Z(Jzt,1),jt,362,0,[b6,nB,iB,w6])}function Sce(t){return lt(de(z(t,(Ft(),bw))))&&z(t,li)!=null}function Tce(t){return lt(de(z(t,(Ft(),bw))))&&z(t,li)!=null}function T2(t){return _T(),ct(t.g,153)?a(t.g,153):null}function Cce(t,e,n){var i;i=a(zi(t.g,n),57),Ut(t.a.c,new zs(e,i))}function skt(t,e,n,i){var r;return r=i[e.g][n.g],lt(Yt(z(t.a,r)))}function okt(t,e,n,i){this.e=i,this.d=null,this.c=t,this.a=e,this.b=n}function uct(t,e,n,i){this.d=t,this.n=e,this.g=n,this.o=i,this.p=-1}function ckt(t,e,n,i,r){this.c=t,this.e=e,this.d=n,this.b=i,this.a=r}function lct(t,e,n,i,r){this.i=t,this.a=e,this.e=n,this.j=i,this.f=r}function C1(t,e,n,i,r){Gi.call(this,t,e),this.a=n,this.b=i,this.c=r}function uC(){uC=P,nA=new hrt("UPPER",0),eA=new hrt("LOWER",1)}function Ace(){return $M(),Y(Z(Hbt,1),jt,360,0,[cF,rA,$6,sA])}function kce(){return f7(),Y(Z(bwt,1),jt,320,0,[yQ,gwt,mwt,pwt])}function Lce(){return ip(),Y(Z(avt,1),jt,226,0,[CF,dA,Ax,pA])}function Pce(){return gd(),Y(Z(jQ,1),jt,197,0,[zQ,UQ,UE,eb])}function Ice(){return Ku(),Y(Z(vA,1),jt,344,0,[cI,M0,oI,ob])}function Rce(){return Sm(),Y(Z(mqt,1),jt,374,0,[hI,lI,ZQ,YQ])}function Dce(){return i7(),Y(Z(Lvt,1),jt,288,0,[VQ,Cvt,kvt,Avt])}function Nce(){return Tu(),Y(Z(UVt,1),jt,265,0,[uI,kd,cg,aI])}function Oce(){return Qb(),Y(Z(YJ,1),jt,179,0,[KB,ZJ,ey,ty])}function $u(t,e,n){return e<0?gX(t,n):a(n,61).aj().fj(t,t.Qg(),e)}function akt(t,e){var n;for(n=t.j.c.length;n=0&&t.a[n]===e[n];n--);return n<0}function pct(t,e){var n;n=t.q.getHours(),t.q.setFullYear(e+Nm),n4(t,n)}function A2(t,e){return e==0||t.e==0?t:e>0?EIt(t,e):PDt(t,-e)}function gct(t,e){return e==0||t.e==0?t:e>0?PDt(t,e):EIt(t,-e)}function mct(t){t.b!=t.c&&(t.a=dt(un,te,1,8,5,1),t.b=0,t.c=0)}function k2(t){return Hn(t.a0;)i+=t.a[n],n-=n&-n;return i}function Nkt(t,e){var n;for(n=e;n;)Gu(t,-n.i,-n.j),n=io(n);return t}function Wg(t,e){return t.a?Ii(t.a,t.b):t.a=new ll(t.d),f2(t.a,e),t}function Okt(t,e){for(En(e);t.a||(t.a=Hv(t.c,t)),t.a;)e.ie(uN(t))}function iV(t){return t.c&&t.d?ict(t.c)+"->"+ict(t.d):"e_"+cm(t)}function Gce(t,e,n){return a(e==null?Cu(t.d,null,n):Tm(t.e,e,n),261)}function Wce(t,e,n){var i,r;i=Hg(t,n),r=null,i&&(r=V8t(i)),F0e(e,n,r)}function $ce(t,e){var n;n=new gT,Ug(n,"x",e.a),Ug(n,"y",e.b),x2(t,n)}function Vce(t,e){var n;n=new gT,Ug(n,"x",e.a),Ug(n,"y",e.b),x2(t,n)}function qce(t,e){return Wme(t,e,ct(e,62)&&(a(a(e,17),62).Bb&ao)!=0)}function fd(t){return si(t),ct(t,13)?new Eh((al(),a(t,13))):a$(t.tc())}function Xce(){return Ht(),Y(Z(Ia,1),jt,69,0,[Wc,Tn,Qe,fi,on])}function Zce(t){return y9(),function(){return _ce(t,this,arguments);var e}}function Yce(){return Date.now?Date.now():new Date().getTime()}function wct(t){if(!t.c.Cc())throw K(new J);return t.a=!0,t.c.Ec()}function rV(t,e){if(t<0||t>e)throw K(new Uc(vlt(t,e,"index")));return t}function vct(t,e){return ct(e,180)?le(t.c,a(e,180).c):!1}function Kce(t){return t.d=3,t.c=Nue(t),t.d!=2?(t.d=0,!0):!1}function Bkt(t,e){var n,i;return n=(i=t.slice(0,e),fC(i,t)),n.length=e,n}function Kl(t,e,n){var i;return i=(mi(e,t.c.length),t.c[e]),t.c[e]=n,i}function sV(t,e,n,i){var r;return r=dt(Gn,pi,22,e,15,1),a1e(r,t,e,n,i),r}function Fkt(t,e,n,i){this.e=t,this.b=new Nt,this.d=e,this.a=n,this.c=i}function _m(t,e){this.b=Rc,this.d=t,this.e=e,this.c=this.d+(""+this.e)}function Ukt(){kW(this),this.b=new We(is,is),this.a=new We(Ps,Ps)}function CM(){CM=P;var t,e;qF=(Z3(),e=new x,e),XF=(t=new RG,t)}function zkt(){bN(),this.b=(ts(),new vi),this.a=new vi,this.c=new Nt}function uu(t){var e;t.d=new LEt(t),t.e=new PEt(t),e=t[P_]|0,t[P_]=e+1}function hN(t,e){return(jM(t),Iat(new gi(t,new Rct(e,t.a)))).a!=null}function Jce(){return Mo(),Y(Z(Ngt,1),jt,328,0,[Of,fx,aa,ua,Yo])}function Qce(){return GC(),Y(Z(k0t,1),jt,276,0,[lJ,hJ,aJ,A0t,uJ])}function tae(){return bl(),Y(Z(lmt,1),jt,178,0,[_x,P6,vw,W4,Xm])}function eae(){return UC(),Y(Z(Mbt,1),jt,292,0,[xbt,KJ,JJ,B6,F6])}function nae(){return H1(),Y(Z(wA,1),jt,225,0,[nb,GQ,_vt,bA,yvt])}function iae(){return Qg(),Y(Z(Jp,1),jt,163,0,[On,vc,Md,tb,sg])}function rae(){return Js(),Y(Z(fA,1),jt,110,0,[Ff,uh,ah,fp,og])}function sae(t,e){var n;return n=e!=null?Zc(t,e):Ua(Ea(t.d,null)),sM(n)}function oae(t,e){var n;return n=e!=null?Zc(t,e):Ua(Ea(t.d,null)),sM(n)}function _ct(t,e){var n;return n=a(P2(t.d,e),27),n||a(P2(t.e,e),27)}function yct(t,e){var n;return n=0,t&&(n+=t.f.a/2),e&&(n+=e.f.a/2),n}function pl(t){return t.t||(t.t=new _G(t),YL(new Uxt(t),0,t.t)),t.t}function jkt(t){var e;return t.c||(e=t.r,ct(e,96)&&(t.c=a(e,24))),t.c}function Hkt(t,e){return lm(t.a,e)?(AM(t.a,e),!0):!1}function ec(t){return!t.c||!t.d?!1:!!t.c.g&&t.c.g==t.d.g}function cae(t){return Ah(t,"size"),or($G(Xg(t,8),X2)?Xg(t,8):X2),new Db}function Bp(t,e){return TEt((tC(),new oN(iIt(Y(Z(un,1),te,1,5,[t,e])))))}function aae(t){t&&gue((Er(),d1t)),--qO,t&&XO!=-1&&(lte(XO),XO=-1)}function uae(t,e){var n,i;n=a(Gfe(t.c,e),13),n&&(i=n._b(),n.Pb(),t.d-=i)}function lC(t){Ao();var e;for(e=0;t.hc();)t.ic(),e=so(e,1);return NL(e)}function oV(t){var e,n,i;return e=t&eu,n=t>>22&eu,i=t<0?sp:0,ia(e,n,i)}function Gkt(t,e){var n,i;return n=e.kc(),i=Rat(t,n),!!i&&au(i.e,e.lc())}function Wkt(t){var e;return e=t.e+t.f,isNaN(e)&&wD(t.d)?t.d:e}function $kt(t){this.b=t,$n.call(this,t),this.a=a(an(this.b.a,4),116)}function Vkt(t){this.b=t,w2.call(this,t),this.a=a(an(this.b.a,4),116)}function Jl(t,e,n,i,r){Jkt.call(this,e,i,r),this.c=t,this.b=n}function xct(t,e,n,i,r){LAt.call(this,e,i,r),this.c=t,this.a=n}function Mct(t,e,n,i,r){PAt.call(this,e,i,r),this.c=t,this.a=n}function Ect(t,e,n,i,r){Jkt.call(this,e,i,r),this.c=t,this.a=n}function qkt(t,e){this.d=new i2,this.a=t,this.b=e,this.e=new Oo(e.Qe())}function Fp(t,e){$1(),this.e=t,this.d=1,this.a=Y(Z(Gn,1),pi,22,15,[e])}function AM(t,e){return Es(e)?e==null?Nlt(t.d,null):JPt(t.e,e):Nlt(t.d,e)}function Sct(t,e,n){var i;return i=t.rg(e),i>=0?t.ug(i,n,!0):W2(t,e,n)}function lae(t,e,n){var i;i=(si(t),new Eh((al(),t))),n1e(new gkt(i,e,n))}function xL(t,e,n){var i;i=(si(t),new Eh((al(),t))),dpe(new mkt(i,e,n))}function hae(t,e,n){var i;return i=RC(n),$C(t.d,i,e,!1),wr(t.e,e,n),e}function fae(t,e,n){var i;return i=RC(n),$C(t.j,i,e,!1),wr(t.k,e,n),e}function Xkt(t,e,n){var i;i=new Brt(t.a),GV(i,t.a.a),Cu(i.d,e,n),t.a.a=i}function cV(t){var e;return e=new Np,Uo(e,t),Ct(e,(qt(),Ro),null),e}function $g(t){var e,n;return si(t),e=hse(t.length),n=new Vu(e),$L(n,t),n}function hC(t){var e,n;++t.j,e=t.g,n=t.i,t.g=null,t.i=0,t.uh(n,e),t.th()}function ML(t,e){t.Eh(t.i+1),GT(t,t.i,t.Ch(t.i,e)),t.sh(t.i++,e),t.th()}function ym(t,e){var n;return n=(mi(e,t.c.length),t.c[e]),Git(t.c,e,1),n}function aV(t,e,n,i){var r;return r=dt(Gn,pi,22,e+1,15,1),Hve(r,t,e,n,i),r}function Tct(t,e,n,i){var r;for(r=0;re.o?-1:0}function Yv(t,e){if(t<0||t>e)throw K(new Uc("Index: "+t+", Size: "+e))}function Pct(t,e,n){if(t<0||e>n||e=e)throw K(new Uc("Index: "+t+", Size: "+e))}function bae(t,e){var n;n=t.q.getHours()+(e/60|0),t.q.setMinutes(e),n4(t,n)}function gN(t,e,n){this.a=t,this.b=e,this.c=n,Ut(t.q,this),Ut(e.g,this)}function EL(t,e,n,i){this.f=t,this.e=e,this.d=n,this.b=i,this.c=i?i.d:null}function Ict(t){r6t.call(this,t,0),PSt(this),this.b.b=this.b,this.b.a=this.b}function Rct(t,e){K9.call(this,e.rd(),e.qd()&-65),En(t),this.a=t,this.c=e}function E5t(t,e,n){this.d=(En(t),t),this.a=n&Bm?n:n|64|Lf,this.c=e}function mN(){this.b=new Fr,this.a=new Fr,this.b=new Fr,this.a=new Fr}function S5t(){S5t=P,cWt=Xa(Ni(new as,(Mo(),Of),(Po(),nJ)),Yo,yB)}function T5t(){T5t=P,aWt=Ni(Ni(new as,(Mo(),Of),(Po(),F4)),aa,CE)}function lV(t,e){return!t.o&&(t.o=new lu((Ic(),pp),ag,t,0)),Cq(t.o,e)}function wae(t,e){di(e,"Label management",1),sM(z(t,(uV(),Z6))),Vn(e)}function vae(t,e){var n;return n=t.c,e>0?a(Ee(n.a,e-1),8):null}function hV(t){var e;return e=t.b,e.b==0?null:a(j1(e,0),170).b}function Dct(t){var e,n,i,r;r=t.d,e=t.a,n=t.b,i=t.c,t.d=n,t.a=i,t.b=r,t.c=e}function _ae(t,e){var n;t.A&&(n=a(js(t.b,e),114).n,n.d=t.A.d,n.a=t.A.a)}function fV(t,e,n){var i,r;if(n!=null)for(i=0;i=0,"Initial capacity must not be negative")}function k5t(t){this.b=(ts(),new vi),this.c=new vi,this.d=new vi,this.a=t}function L5t(t){t?(this.c=t,this.b=null):(this.c=null,this.b=new Nt)}function dV(t,e){R9.call(this,t,e),this.a=dt(C3e,te,398,2,0,1),this.b=!0}function pV(t,e,n){return HX(t,e,n,ct(e,62)&&(a(a(e,17),62).Bb&ao)!=0)}function Pae(t,e,n){return i4(t,e,n,ct(e,62)&&(a(a(e,17),62).Bb&ao)!=0)}function Iae(t,e,n){return $me(t,e,n,ct(e,62)&&(a(a(e,17),62).Bb&ao)!=0)}function Rae(t,e){return ro(lt(Yt(z(t,(Ft(),qm)))),lt(Yt(z(e,qm))))}function Dae(){return qM(),Y(Z(dJ,1),jt,290,0,[R0t,SB,EB,I0t,xB,MB])}function Nae(){return x7(),Y(Z(U0t,1),jt,241,0,[vJ,wJ,yJ,_J,xJ,CB])}function Oae(){return dP(),Y(Z(W0t,1),jt,255,0,[AB,j0t,G0t,z0t,H0t,MJ])}function Bae(){return ZM(),Y(Z(Y0t,1),jt,256,0,[j4,V0t,Z0t,X0t,q0t,$0t])}function Fae(){return v7(),Y(Z(ybt,1),jt,291,0,[XJ,vbt,qJ,wbt,_bt,YB])}function Uae(){return Ls(),Y(Z(xvt,1),jt,83,0,[ib,dp,Px,Lx,Sd,Gc])}function zae(){return qC(),Y(Z(v$t,1),jt,308,0,[aF,sQ,cQ,oQ,aQ,rQ])}function jae(){return md(),Y(Z(Ewt,1),jt,224,0,[EQ,Y6,K6,_F,wF,vF])}function Hae(){return _7(),Y(Z(pvt,1),jt,289,0,[HQ,hvt,dvt,uvt,fvt,lvt])}function P5t(){P5t=P,I$t=DC(DC(Yit(new as,($M(),rA)),(qC(),aF)),sQ)}function bN(){bN=P,new kr("org.eclipse.elk.addLayoutConfig"),K$t=new xb}function I5t(){I5t=P,H7(),f_t=is,mXt=Ps,d_t=new Lb(is),bXt=new Lb(Ps)}function R5t(t,e,n){Ai();var i;return i=X1(t,e),n&&i&&lse(t)&&(i=null),i}function dt(t,e,n,i,r,c){var l;return l=ARt(r,i),r!=10&&Y(Z(t,c),e,n,r,l),l}function Gae(t,e,n){return TEt((tC(),new oN(iIt(Y(Z(un,1),te,1,5,[t,e,n])))))}function D5t(t,e){var n;return n=e.kc(),ts(),new I5(n,KRt(t.e,n,a(e.lc(),13)))}function N5t(t,e){var n,i;return n=t.a-e.a,i=t.b-e.b,y.Math.sqrt(n*n+i*i)}function Nct(t,e,n){var i;i=t.b[n.c.o][n.o],i.b+=e.b,i.c+=e.c,i.a+=e.a,++i.a}function Wae(t,e,n){var i,r;return r=t.length,i=n=t.i)throw K(new MW(e,t.i));return t.g[e]}function B5t(t,e,n){if(SC(t,n),n!=null&&!t.Li(n))throw K(new T5);return n}function Cf(t,e){return T$(e,"Horizontal alignment cannot be null"),t.b=e,t}function TL(t,e){var n;return n=t.rg(e),n>=0?t.ug(n,!0,!0):W2(t,e,!0)}function CL(t,e,n){var i,r;return r=(i=JM(t.b,e),i),r?W7(DL(t,r),n):null}function $ae(t){return ct(t,159)?""+a(t,159).a:t==null?null:Yc(t)}function Vae(t){return ct(t,159)?""+a(t,159).a:t==null?null:Yc(t)}function LM(t){var e;return Vo(t)&&(e=0-t,!isNaN(e))?e:D1(OM(t))}function qae(t){var e;return t=t>2?t:2,e=Eat(t),t>e?(e<<=1,e>0?e:X2):e}function AL(t){var e,n;return e=t+128,n=(MTt(),v1t)[e],!n&&(n=v1t[e]=new Fj(t)),n}function fC(t,e){return OL(e)!=10&&Y(fu(e),e.rl,e.__elementTypeId$,OL(e),t),t}function Kv(t,e){return e.e==0||t.e==0?EE:(YM(),EX(t,e))}function Xae(t){for(;!t.a;)if(!Xct(t.b,new Kj(t)))return!1;return!0}function Zae(t){for(;!t.a;)if(!PTt(t.c,new tH(t)))return!1;return!0}function F5t(t,e){if(e.a)throw K(new sc(jOt));Ir(t.a,e),e.a=t,!t.j&&(t.j=e)}function gV(t,e,n,i,r,c){uct.call(this,e,i,r,c),this.c=t,this.b=n}function U5t(t,e,n,i,r,c){uct.call(this,e,i,r,c),this.c=t,this.a=n}function lu(t,e,n,i){this.Gi(),this.a=e,this.b=t,this.c=new got(this,e,n,i)}function kL(t,e){this.e=e,this.a=hPt(t),this.a<54?this.f=EM(t):this.c=iP(t)}function Yae(t,e){t.a.Ld(e.d,t.b)>0&&(Ut(t.c,new $st(e.c,e.d,t.d)),t.b=e.d)}function mV(t){t.a=dt(Gn,pi,22,t.b+1,15,1),t.c=dt(Gn,pi,22,t.b,15,1),t.d=0}function z5t(){z5t=P,jzt=Vi((vN(),Y(Z(QO,1),jt,278,0,[CK,G1t,W1t,$1t])))}function j5t(){j5t=P,YGt=Vi((Qb(),Y(Z(YJ,1),jt,179,0,[KB,ZJ,ey,ty])))}function H5t(){H5t=P,Bjt=Vi((BM(),Y(Z(Ojt,1),jt,373,0,[$m,mw,gw,V_])))}function G5t(){G5t=P,Kzt=Vi((z2(),Y(Z(Yzt,1),jt,304,0,[p6,d6,g6,m6])))}function W5t(){W5t=P,Qzt=Vi((zC(),Y(Z(Jzt,1),jt,362,0,[b6,nB,iB,w6])))}function $5t(){$5t=P,w$t=Vi(($M(),Y(Z(Hbt,1),jt,360,0,[cF,rA,$6,sA])))}function V5t(){V5t=P,Z$t=Vi((f7(),Y(Z(bwt,1),jt,320,0,[yQ,gwt,mwt,pwt])))}function q5t(){q5t=P,yVt=Vi((ip(),Y(Z(avt,1),jt,226,0,[CF,dA,Ax,pA])))}function X5t(){X5t=P,xVt=Vi((gd(),Y(Z(jQ,1),jt,197,0,[zQ,UQ,UE,eb])))}function Z5t(){Z5t=P,NVt=Vi((Ku(),Y(Z(vA,1),jt,344,0,[cI,M0,oI,ob])))}function Y5t(){Y5t=P,bqt=Vi((Sm(),Y(Z(mqt,1),jt,374,0,[hI,lI,ZQ,YQ])))}function K5t(){K5t=P,BVt=Vi((i7(),Y(Z(Lvt,1),jt,288,0,[VQ,Cvt,kvt,Avt])))}function J5t(){J5t=P,zVt=Vi((Tu(),Y(Z(UVt,1),jt,265,0,[uI,kd,cg,aI])))}function hu(){hu=P,jf=new yW(lE,0),cb=new yW(m4,1),fh=new yW(hE,2)}function LL(){LL=P,Ubt=new prt(Fm,0),sF=new prt("IMPROVE_STRAIGHTNESS",1)}function wN(){wN=P,iwt=new mrt("LEAF_NUMBER",0),wQ=new mrt("NODE_SIZE",1)}function vN(){vN=P,CK=new D9("All",0),G1t=new zEt,W1t=new KEt,$1t=new jEt}function Ya(t){return t.b||(t.b=new rSt(Do,t),!t.a&&(t.a=new iL(t,t))),t.b}function PL(t,e){if(e<0)throw K(new Uc(ZBt+e));return akt(t,e+1),Ee(t.j,e)}function L2(t){var e;if(!s_(t))throw K(new J);return t.d=1,e=t.c,t.c=null,e}function _N(t){var e,n;return n=t.length,e=dt(el,Pf,22,n,15,1),UCt(t,0,n,e,0),e}function bV(t,e){var n;this.f=t,this.b=e,n=a(zi(t.b,e),264),this.c=n?n.b:null}function Kae(t,e,n){var i;return i=b6t(t,e,n),t.b=new FV(i.c.length),rht(t,i)}function Jae(t,e){var n;return n=a(WM(t.d,e),13),n?KRt(t.e,e,n):null}function Uct(t,e){var n;return n=a(AM(t.c,e),353),n?(Zst(n),n.e):null}function Qae(t){var e,n;if(!t.b)return null;for(n=t.b;e=n.a[0];)n=e;return n}function tue(t,e,n){var i;return i=RC(n),$C(t.g,i,e,!1),$C(t.i,e,n,!1),e}function IL(t,e,n,i){var r;i=(yM(),i||O1t),r=t.slice(e,n),Mlt(r,t,e,n,-e,i)}function qu(t,e,n,i,r){return e<0?W2(t,n,i):a(n,61).aj().cj(t,t.Qg(),e,i,r)}function eue(t,e){return e0?qi:Pc(t,Vs)<0?Vs:or(t)}function oue(t,e){if(!t)throw K(new yn(wbe("Enum constant undefined: %s",e)))}function yN(t){nD(this),this.g=t?F4t(t,t.Od()):null,this.f=t,ZD(this),this.Pd()}function Qd(t,e,n,i,r,c,l){DV.call(this,e,i,r,c,l),this.c=t,this.b=n}function dd(t,e,n){var i,r;for(i=10,r=0;r=0?(t.gd(n),!0):!1}function EV(t,e){var n;return n=xr(t.d,e),n>=0?l7(t,n,!0,!0):W2(t,e,!0)}function lue(t,e){var n;for(n=0;t.e!=t.i._b();)Mee(e,ci(t),Xt(n)),n!=qi&&++n}function eLt(t,e){var n,i,r;for(r=0,i=t.tc();i.hc();)n=i.ic(),Vr(e,r++,n);return e}function L1(t,e,n){var i;if(e==null)throw K(new t2);return i=Hg(t,e),Bce(t,e,n),i}function P1(t){if(t<0)throw K(new yn("tolerance ("+t+") must be >= 0"));return t}function SV(t){var e;return e=t.b.c.length==0?null:Ee(t.b,0),e!=null&&fat(t,0),e}function nLt(t,e){var n,i,r;for(i=0,r=e.length;i=t.a.c.length;)Ut(t.a,new Fr);return a(Ee(t.a,e),15)}function fue(t){return Wut(t,(PM(),b1t))<0?-Aee(OM(t)):t.l+t.m*Q2+t.h*s0}function iLt(t){var e,n;return e=t/60|0,n=t%60,n==0?""+e:""+e+":"+(""+n)}function due(t,e){var n;return n=ife(t.e.c,e.e.c),n==0?ro(t.e.d,e.e.d):n}function I2(t,e){var n=t.a[e],i=(oq(),xK)[typeof n];return i?i(n):Hat(typeof n)}function rLt(t,e){return e==(s$(),s$(),zzt)?t.toLocaleLowerCase():t.toLowerCase()}function OL(t){return t.__elementTypeCategory$==null?10:t.__elementTypeCategory$}function Vct(t){return(t.i&2?"interface ":t.i&1?"":"class ")+(Vd(t),t.o)}function pue(t,e,n){var i;return i=t.a.e[a(e.a,8).o]-t.a.e[a(n.a,8).o],Tr(tCt(i))}function sLt(t,e){var n;for(++t.d,++t.c[e],n=e+1;n=0&&et||t>e)throw K(new Eit("fromIndex: 0, toIndex: "+t+dft+e))}function TN(t,e){var n,i;for(i=t.tc();i.hc();)n=a(i.ic(),68),Ct(n,(Ft(),bx),e)}function _ue(t,e,n){var i;i=y.Math.max(0,t.b/2-.5),jC(n,i,1),Ut(e,new yMt(n,i))}function yue(t){var e;return e=lt(Yt(z(t,(qt(),up)))),e<0&&(e=0,Ct(t,up,e)),e}function t_(t){dD();var e,n;for(n=npt,e=0;en&&(n=t[e]);return n}function xue(){Jxt();for(var t=gK,e=0;e=t.i)throw K(new MW(e,t.i));return t.zh(e,t.g[e])}function CLt(t,e,n){if(SC(t,n),!t.Nj()&&n!=null&&!t.Li(n))throw K(new T5);return n}function gC(t,e){var n;for(n=t;io(n);)if(n=io(n),n==e)return!0;return!1}function Tue(t,e){return e&&t.b[e.g]==e?(Vr(t.b,e.g,null),--t.c,!0):!1}function Ql(t,e){var n;return n=e.c,e.a.b=e.b,e.b.a=e.a,e.a=e.b=null,e.c=null,--t.b,n}function pd(t,e){var n,i,r,c;for(En(e),i=t.c,r=0,c=i.length;r>5,r=e&31,i=ns(Gv(t.n[n][c],or(Yd(r,1))),3),i}function ALt(t,e){for(;e[0]=0;)++e[0]}function kLt(t,e){mD.call(this),Kct(this),this.a=t,this.c=!0,this.b=e.d,this.f=e.e}function LLt(t,e){return Ef(),P1(Z1),y.Math.abs(t-e)<=Z1||t==e||isNaN(t)&&isNaN(e)}function Yct(t){return t.a<54?t.f<0?-1:t.f>0?1:0:(!t.c&&(t.c=XL(t.f)),t.c).e}function PLt(t){return t.c&&t.d?t.c.g+"("+t.c+")->"+t.d.g+"("+t.d+")":"e_"+cm(t)}function ILt(t,e,n){var i,r;i=e;do r=lt(t.p[i.o])+n,t.p[i.o]=r,i=t.a[i.o];while(i!=e)}function Aue(t,e,n){var i,r,c;for(r=e[n],i=0;i=14&&e<=16))),t}function AV(t,e){Ao();var n;for(si(t),si(e),n=!1;e.hc();)n=n|t.nc(e.ic());return n}function Ah(t,e){if(t<0)throw K(new yn(e+" cannot be negative but was: "+t));return t}function kV(t,e){var n,i;for(i=new H(t);i.an)throw K(new jv(e,n));return new Rst(t,e)}function r_(t,e){var n;n=t.s,t.s=e,t.Db&4&&!(t.Db&1)&&Bi(t,new eV(t,4,n,t.s))}function IM(t,e){var n;n=t.t,t.t=e,t.Db&4&&!(t.Db&1)&&Bi(t,new eV(t,5,n,t.t))}function Jct(t,e){var n;n=t.d,t.d=e,t.Db&4&&!(t.Db&1)&&Bi(t,new eV(t,2,n,t.d))}function IV(t,e){var n;n=t.F,t.F=e,t.Db&4&&!(t.Db&1)&&Bi(t,new fs(t,1,5,n,e))}function Lue(t,e){var n,i,r;return n=(i=(sm(),r=new jS,r),e&&TDt(i,e),i),JLt(n,t),n}function Mm(){Mm=P,eF=new dW("BARYCENTER",0),tA=new dW(wBt,1),nF=new dW(vBt,2)}function CN(){CN=P,N0t=new iW("ARD",0),TB=new iW("MSD",1),pJ=new iW("MANUAL",2)}function Fo(){Fo=P,tF=new aW(nx,0),Ga=new aW("INPUT",1),ba=new aW("OUTPUT",2)}function jLt(){Zl(),this.b=(ts(),new vi),this.f=new vi,this.g=new vi,this.e=new vi}function Qct(t,e,n,i,r){this.d=e,this.k=i,this.f=r,this.o=-1,this.p=1,this.c=t,this.a=n}function tat(t,e,n,i,r){this.d=e,this.k=i,this.f=r,this.o=-1,this.p=2,this.c=t,this.a=n}function eat(t,e,n,i,r){this.d=e,this.k=i,this.f=r,this.o=-1,this.p=6,this.c=t,this.a=n}function nat(t,e,n,i,r){this.d=e,this.k=i,this.f=r,this.o=-1,this.p=7,this.c=t,this.a=n}function iat(t,e,n,i,r){this.d=e,this.j=i,this.e=r,this.o=-1,this.p=4,this.c=t,this.a=n}function rat(t,e){return Ef(),P1(Z1),y.Math.abs(t-e)<=Z1||t==e||isNaN(t)&&isNaN(e)}function Pue(){return B7(),Y(Z(pgt,1),jt,228,0,[dgt,ugt,lgt,agt,PK,fgt,hgt,cgt,ogt])}function Iue(){return i0(),Y(Z(to,1),jt,86,0,[kl,Uf,Pl,Bh,hh,lh,Du,Il,Ll])}function Rue(){return ma(),Y(Z(Tvt,1),jt,239,0,[zE,_A,PF,yA,IF,RF,Rx,$Q,LF])}function HLt(){HLt=P,Lzt=Y(Z(Gn,1),pi,22,15,[0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15])}function GLt(){GLt=P,bWt=Xa(Ni(Ni(new as,(Mo(),aa),(Po(),sJ)),ua,iJ),Yo,rJ)}function RV(){return MQ||(MQ=new oNt,xC(MQ,Y(Z(O4,1),te,154,0,[new vj]))),MQ}function _o(t,e,n){return UM(t,e),kh(t,n),r_(t,0),IM(t,1),u_(t,!0),a_(t,!0),t}function WLt(t,e){var n;return ct(e,38)?t.c.vc(e):(n=Cq(t,e),sP(t,e),n)}function vr(t){var e;return ct(t,78)?t:(e=t&&t[dZ],e||(e=new dIt(t),Ki(e)),e)}function sat(t){var e,n;if(t==0)return 32;for(n=0,e=1;!(e&t);e<<=1)++n;return n}function Due(t,e){var n;return n=t.c,e=0),Vfe(t.d,t.c)<0&&(t.a=t.a-1&t.d.a.length-1,t.b=t.d.c),t.c=-1}function NV(t,e){t.j>0&&t.c0&&t.e!=0&&NV(t.g,e/t.j*t.g.d))}function YLt(t,e){var n;n=t.c,t.c=e,t.Db&4&&!(t.Db&1)&&Bi(t,new fs(t,1,1,n,t.c))}function KLt(t,e){var n;n=t.b,t.b=e,t.Db&4&&!(t.Db&1)&&Bi(t,new fs(t,1,0,n,t.b))}function zL(t,e){var n;n=t.k,t.k=e,t.Db&4&&!(t.Db&1)&&Bi(t,new fs(t,1,2,n,t.k))}function aat(t,e){var n;n=t.f,t.f=e,t.Db&4&&!(t.Db&1)&&Bi(t,new fs(t,1,8,n,t.f))}function uat(t,e){var n;n=t.i,t.i=e,t.Db&4&&!(t.Db&1)&&Bi(t,new fs(t,1,7,n,t.i))}function JLt(t,e){var n;n=t.a,t.a=e,t.Db&4&&!(t.Db&1)&&Bi(t,new fs(t,1,8,n,t.a))}function QLt(t,e){var n;n=t.d,t.d=e,t.Db&4&&!(t.Db&1)&&Bi(t,new fs(t,1,1,n,t.d))}function tPt(t,e){var n;n=t.c,t.c=e,t.Db&4&&!(t.Db&1)&&Bi(t,new fs(t,1,1,n,t.c))}function lat(t,e){var n;n=t.c,t.c=e,t.Db&4&&!(t.Db&1)&&Bi(t,new fs(t,1,4,n,t.c))}function OV(t,e){var n;n=t.D,t.D=e,t.Db&4&&!(t.Db&1)&&Bi(t,new fs(t,1,2,n,t.D))}function ePt(t,e){var n;n=t.b,t.b=e,t.Db&4&&!(t.Db&1)&&Bi(t,new fs(t,1,0,n,t.b))}function Uue(t,e,n){var i;t.b=e,t.a=n,i=(t.a&512)==512?new Txt:new jh,t.c=ywe(i,t.b,t.a)}function nPt(t,e){return Rm(t.e,e)?(Jo(),$ct(e)?new LD(e,t):new $5(e,t)):new mEt(e,t)}function yC(t,e){return me(),Es(t)?not(t,hi(e)):zb(t)?pCt(t,Yt(e)):Ub(t)?Mre(t,de(e)):t.vd(e)}function zue(t){var e=/function(?:\s+([\w$]+))?\s*\(/,n=e.exec(t);return n&&n[1]||pZ}function jue(t,e){var n,i;return n=t.o+t.p,i=e.o+e.p,n>>31;i!=0&&(t[n]=i)}function hPt(t){var e;return Pc(t,0)<0&&(t=lst(t)),e=or(M1(t,32)),64-(e!=0?_P(e):_P(or(t))+32)}function que(t){var e,n;for(n=t.c.a.Xb().tc();n.hc();)e=a(n.ic(),204),Nnt(e,new DCt(e.f))}function fPt(t){var e,n;for(n=t.c.a.Xb().tc();n.hc();)e=a(n.ic(),204),Ont(e,new u8t(e.e))}function dPt(t){this.d=t,this.c=t.c.Tb().tc(),this.b=null,this.a=null,this.e=(Ao(),Ao(),h1t)}function pPt(t){this.e=t,this.d=new S9(XV(fot(this.e)._b())),this.c=this.e.a,this.b=this.e.c}function FV(t){this.b=t,this.a=dt(Gn,pi,22,t+1,15,1),this.c=dt(Gn,pi,22,t,15,1),this.d=0}function Xue(t){t.a=null,t.e=null,t.b.c=dt(un,te,1,0,5,1),t.f.c=dt(un,te,1,0,5,1),t.c=null}function nr(t,e){var n,i;i=(n=new cst,n),i.n=e,ni((!t.s&&(t.s=new Wt(Ra,t,21,17)),t.s),i)}function Cr(t,e){var n,i;n=(i=new RG,i),n.n=e,ni((!t.s&&(t.s=new Wt(Ra,t,21,17)),t.s),n)}function kh(t,e){var n;n=t.zb,t.zb=e,t.Db&4&&!(t.Db&1)&&Bi(t,new fs(t,1,1,n,t.zb))}function UV(t,e){var n;n=t.xb,t.xb=e,t.Db&4&&!(t.Db&1)&&Bi(t,new fs(t,1,3,n,t.xb))}function zV(t,e){var n;n=t.yb,t.yb=e,t.Db&4&&!(t.Db&1)&&Bi(t,new fs(t,1,2,n,t.yb))}function jV(t,e,n){var i,r,c;return r=bm(e,"labels"),i=new QMt(t,n),c=(Twe(i.a,i.b,r),r),c}function Rr(t,e,n,i,r,c,l,f,g,b,v,M,k){return e9t(t,e,n,i,r,c,l,f,g,b,v,M,k),Jat(t,!1),t}function yo(t,e){var n,i,r;for(En(e),n=!1,r=e.tc();r.hc();)i=r.ic(),n=n|t.nc(i);return n}function gPt(t){if(t){if(t.Wb())throw K(new J);return t.cd(t._b()-1)}return lkt(null.tc())}function Zue(t){if(En(t),t.length==0)throw K(new yf("Zero length BigInteger"));Owe(this,t)}function LN(){LN=P,Rbt=new lW("NO",0),tQ=new lW("GREEDY",1),Ibt=new lW("LOOK_BACK",2)}function HV(){HV=P,TA=new Ext,rtt=Y(Z(Ra,1),j_,158,0,[]),Xqt=Y(Z(ph,1),qpt,53,0,[])}function mPt(){mPt=P,$jt=Vi((Ke(),Y(Z(qK,1),jt,232,0,[gs,Hr,rs,uc,bu,Jc,ef])))}function Yue(){return So(),Y(Z(EJ,1),jt,233,0,[kB,Al,H4,LB,X_,Z_,S6,AE,kE,PB])}function Kue(t,e){return BM(),t==$m&&e==mw||t==mw&&e==$m||t==V_&&e==gw||t==gw&&e==V_}function Jue(t,e){return BM(),t==$m&&e==gw||t==$m&&e==V_||t==mw&&e==V_||t==mw&&e==gw}function bPt(t,e){return lt(Yt(BW(QL(Vh(new gi(null,new Ei(t.c.b,16)),new K8(t)),e))))}function gat(t,e){return lt(Yt(BW(QL(Vh(new gi(null,new Ei(t.c.b,16)),new Ys(t)),e))))}function wPt(t,e){e?t.B==null&&(t.B=t.D,t.D=null):t.B!=null&&(t.D=t.B,t.B=null)}function Que(t){var e;return ct(t,182)?(e=a(t,182),new Mit(e.a)):(Ao(),new l5(t))}function vPt(t){var e;return e=QAt(t),Bb(e.a,0)?(Q3(),Q3(),z1t):(Q3(),new est(e.b))}function _Pt(t){var e;return e=QAt(t),Bb(e.a,0)?(Q3(),Q3(),z1t):(Q3(),new est(e.c))}function yPt(t){cot.call(this),this.b=lt(Yt(z(t,(qt(),nf)))),this.a=a(z(t,ng),197)}function xPt(){this.c=new C9(0),this.b=new C9(UBt),this.d=new C9(FBt),this.a=new C9(JZ)}function PN(t){this.b=(si(t),new Eh((al(),t))),this.a=new Nt,this.d=new Nt,this.e=new go}function ep(){ep=P,ZK=new Nr,XK=new mr,zgt=new c1,Ugt=new dc,jgt=new vh,Hgt=new vg}function IN(){IN=P,gJ=new rW("GREEDY",0),B0t=new rW("DEPTH_FIRST",1),mJ=new rW(sY,2)}function Kh(){Kh=P,cy=new vW("OUTSIDE",0),rb=new vW("INSIDE",1),kF=new vW("FIXED",2)}function MPt(){MPt=P,wWt=DC(Ite(Ni(Ni(new as,(Mo(),aa),(Po(),sJ)),ua,iJ),Yo),rJ)}function tle(t){return t.b.c.g.j==(Ke(),rs)?a(z(t.b.c.g,(Ft(),li)),11):t.b.c}function EPt(t){return t.b.d.g.j==(Ke(),rs)?a(z(t.b.d.g,(Ft(),li)),11):t.b.d}function SPt(t){var e;if(t.b==-2){if(t.e==0)e=-1;else for(e=0;t.a[e]==0;e++);t.b=e}return t.b}function TPt(t){var e,n,i;for(e=0,i=t.tc();i.hc();)n=i.ic(),e+=n!=null?Yr(n):0,e=~~e;return e}function mat(t,e,n){var i,r;for(r=qn(t,0);r.b!=r.d.c;)i=a(Yn(r),9),i.a+=e,i.b+=n;return t}function jL(t){var e,n,i;for(e=0,i=t.tc();i.hc();)n=Yt(i.ic()),e+=(En(n),n);return e/t._b()}function CPt(t){var e;return t==0?"UTC":(t<0?(t=-t,e="UTC+"):e="UTC-",e+iLt(t))}function ele(t,e){we();var n,i;for(i=new Nt,n=0;n0&&(this.g=this.Fh(this.i+(this.i/8|0)+1),t.zc(this.g))}function kPt(t,e){return Ef(),P1(yd),y.Math.abs(0-e)<=yd||e==0||isNaN(0)&&isNaN(e)?0:t/e}function _s(t,e){TD.call(this,Zqt,t,e),this.b=this,this.a=gu(t.mg(),Ve(this.e.mg(),this.c))}function HL(t,e){var n,i;for(i=e.length,n=0;nr&&e.ac&&e.b1||t.hc())return++t.a,t.g=0,e=t.i,t.hc(),e;throw K(new J)}function zPt(t){var e;t.d==null?(++t.e,t.f=0,F6t(null)):(++t.e,e=t.d,t.d=null,t.f=0,F6t(e))}function NN(t,e){var n;ct(e,109)?(a(t.c,81).ij(),n=a(e,109),rPt(t,n)):a(t.c,81).Gc(e)}function Em(t){return ct(t,193)?_L(a(t,193)):ct(t,160)?a(t,160).a:ct(t,49)?new Cv(t):new eM(t)}function hle(t,e,n){return t==(Mm(),nF)?new Qf:pu(e,1)!=0?new Dit(n.length):new a3t(n.length)}function Bi(t,e){var n,i,r;if(n=t.cg(),n!=null&&t.fg())for(i=0,r=n.length;i=128?!1:t<64?xT(ns(Yd(1,t),n),0):xT(ns(Yd(1,t-64),e),0)}function wle(t){var e;return e=a(z(t,(Ft(),wc)),69),t.j==(Ke(),rs)&&(e==(Ht(),on)||e==Qe)}function qV(t,e){var n;return ct(e,13)?(n=(al(),a(e,13)),t.oc(n)):AV(t,a(si(e),20).tc())}function vle(t){OEt();var e;return lMt(iQ,t)||(e=new vt,e.a=t,KW(iQ,t,e)),a(js(iQ,t),573)}function XV(t){return ts(),t<3?(Ah(t,"expectedSize"),t+1):t>22),r=t.h+e.h+(i>>22),ia(n&eu,i&eu,r&sp)}function YPt(t,e){var n,i,r;return n=t.l-e.l,i=t.m-e.m+(n>>22),r=t.h-e.h+(i>>22),ia(n&eu,i&eu,r&sp)}function YV(t,e,n,i){return n==1?(!t.n&&(t.n=new Wt(ic,t,1,7)),$s(t.n,e,i)):plt(t,e,n,i)}function KPt(t,e){if(e==null)return!1;for(;t.a!=t.b;)if(Fi(e,GN(t)))return!0;return!1}function yat(t){return t.a.hc()?!0:t.a!=t.d?!1:(t.a=new qot(t.e.d),t.a.hc())}function Or(t,e){var n,i;return n=e.yc(),i=n.length,i==0?!1:(Vst(t.c,t.c.length,n),!0)}function Ele(t,e,n){var i,r;for(r=e.Tb().tc();r.hc();)i=a(r.ic(),38),t.Yb(i.kc(),i.lc(),n);return t}function JPt(t,e){var n;return n=t.a.get(e),n===void 0?++t.d:(t.a[BZ](e),--t.c,XW(t.b)),n}function DM(t,e){this.b=t,this.e=e,this.d=e.j,this.f=(Jo(),a(t,61).bj()),this.k=gu(e.e.mg(),t)}function QPt(t){this.o=t,this.g=new Nt,this.j=new Fr,this.n=new Fr,this.e=new Nt,this.b=new Nt}function t6t(t){this.a=dt(gWt,wt,1704,t.length,0,2),this.b=dt(mWt,wt,1705,t.length,0,2),this.c=new SIt}function Sle(t,e){t.d==(Js(),ah)||t.d==og?a(e.a,57).c.nc(a(e.b,57)):a(e.b,57).c.nc(a(e.a,57))}function e6t(t,e){var n,i;for(i=new H(t.b);i.ae?1:t==e?0:isNaN(t)?isNaN(e)?0:1:-1}function i6t(t,e){return!t||!e||t==e?!1:zIt(t.d.c,e.d.c+e.d.b)&&zIt(e.d.c,t.d.c+t.d.b)}function r6t(t,e){vD(t>=0,"Negative initial capacity"),vD(e>=0,"Non-positive load factor"),uu(this)}function s6t(t){var e,n;return n=(e=new zk,e),kh(n,"T"),ni((!t.d&&(t.d=new Hu(wu,t,11)),t.d),n),n}function o6t(t,e){var n;return n=od(e.a._b()),qc(xLt(new gi(null,new Ei(e,1)),t.i),new ZMt(t,n)),n}function xat(t){var e,n,i;for(e=new Fr,i=qn(t.d,0);i.b!=i.d.c;)n=a(Yn(i),170),Xi(e,n.c);return e}function Mat(t){var e,n,i,r;for(e=1,n=0,r=t._b();n>=1);return e}function Cle(t){var e;return e=ew(t),e>uft?is:e<-34028234663852886e22?Ps:e}function Y(t,e,n,i,r){return r.ql=t,r.rl=e,r.sl=B,r.__elementTypeId$=n,r.__elementTypeCategory$=i,r}function NM(t,e,n,i,r){var c,l;for(l=n;l<=r;l++)for(c=e;c<=i;c++)h_(t,c,l)||F7(t,c,l,!0,!1)}function Ale(t){var e,n,i,r;for(n=t.a,i=0,r=n.length;it.f,n=t.u+t.e[t.o.o]*t.d>t.f*t.s*t.d,e||n}function zN(t,e,n){var i,r;return i=new dV(e,n),r=new it,t.b=zDt(t,t.b,i,r),r.b||++t.c,t.b.b=!1,r.d}function Aat(t){var e;return(!t.c||!(t.Bb&1)&&t.c.Db&64)&&(e=wl(t),ct(e,96)&&(t.c=a(e,24))),t.c}function B1(t){var e,n;for(n=new H(t.a.b);n.a=0&&t[i]===e[i];i--);return i<0?0:$G(ns(t[i],uo),ns(e[i],uo))?-1:1}function Ule(t){var e;return t==null?!0:(e=t.length,e>0&&t.charCodeAt(e-1)==58&&!iq(t,EA,SA))}function CC(t){switch(t.g){case 1:return FBt;default:case 2:return 0;case 3:return JZ;case 4:return UBt}}function eq(t){switch(t._b()){case 0:return u1t;case 1:return new nTt(t.tc().ic());default:return new oN(t)}}function zle(t,e){Ao();var n,i;for(Bot(e,"predicate"),i=0;t.hc();i++)if(n=t.ic(),e.Mb(n))return i;return-1}function jle(t,e,n){if(si(e),n.hc())for(Qit(e,t.Lb(n.ic()));n.hc();)Qit(e,t.c),Qit(e,t.Lb(n.ic()));return e}function nq(t,e){var n;return e===t?!0:ct(e,238)?(n=a(e,238),Fi(t.Hc(),n.Hc())):!1}function Pc(t,e){var n;return Vo(t)&&Vo(e)&&(n=t-e,!isNaN(n))?n:Wut(Vo(t)?gl(t):t,Vo(e)?gl(e):e)}function XL(t){return $1(),t<0?t!=-1?new yut(-1,-t):SK:t<=10?N1t[Tr(t)]:new yut(1,t)}function Hle(){Ai();var t;return ltt||(t=Dee(X1("M",!0)),t=OD(X1("M",!1),t),ltt=t,ltt)}function c_(t,e,n){var i,r;return r=(i=new PG,i),_o(r,e,n),ni((!t.q&&(t.q=new Wt(ph,t,11,10)),t.q),r),r}function iq(t,e,n){var i,r;for(i=0,r=t.length;i=t.b.c.length||(Oat(t,2*e+1),n=2*e+2,ne)throw K(new yn(nO+t+FOt+e));if(t<0||e>n)throw K(new Eit(nO+t+pft+e+dft+n))}function Wle(t,e,n){if(e<0)throw K(new Uc(ZBt+e));e0)return KT(e-1,t.a.c.length),ym(t.a,e-1);throw K(new F)}function k6t(t,e){var n;if(e.c.length!=0){for(;flt(t,e);)A7(t,e,!1);n=FN(e),t.a&&(t.a.If(n),k6t(t,n))}}function Xle(t,e){var n,i;for(i=qn(t,0);i.b!=i.d.c;)n=a(Yn(i),204),n.e.length>0&&(e.td(n),n.i&&The(n))}function uq(t,e,n){var i,r,c;for(i=new Fr,c=qn(n,0);c.b!=c.d.c;)r=a(Yn(c),9),Xi(i,new Oo(r));_he(t,e,i)}function L6t(t,e){var n;return n=new LX((t.f&256)!=0,t.i,t.a,t.d,(t.f&16)!=0,t.j,t.g,e),t.e!=null||(n.c=t),n}function Zle(t,e){var n,i;return n=a(t.d.$b(e),13),n?(i=t.e.Oc(),i.oc(n),t.e.d-=n._b(),n.Pb(),i):null}function jN(t){var e,n,i,r;for(r=0,n=0,i=t.length;n1||e>=0&&t.b<3)}function Yb(t){var e;++t.j,t.i==0?t.g=null:t.i>>0).toString(16):t.toString()}function lq(t,e){t.D==null&&t.B!=null&&(t.D=t.B,t.B=null),OV(t,e==null?null:(En(e),e)),t.C&&t.Kj(null)}function Jle(t,e){var n,i;for(n=t.a.length-1,t.c=t.c-1&n;e!=t.c;)i=e+1&n,Vr(t.a,e,t.a[i]),e=i;Vr(t.a,t.c,null)}function Qle(t,e){var n,i;for(n=t.a.length-1;e!=t.b;)i=e-1&n,Vr(t.a,e,t.a[i]),e=i;Vr(t.a,t.b,null),t.b=t.b+1&n}function the(t,e){iD(!this.b),iD(!this.d),RW(J3(t.c)==0),RW(e.d.c+e.e.c==0),RW(!0),this.b=t,this.d=this.ec(e)}function R6t(t,e,n,i,r){i?zpe(t,e):(e1e(t,e,r),d2e(t,e,n)),e.c.length>1&&(we(),gc(e,t.b),hve(t.c,e))}function ehe(t,e,n,i,r){e==0||i==0||(e==1?r[i]=wut(r,n,i,t[0]):i==1?r[e]=wut(r,t,e,n[0]):z0e(t,n,r,e,i))}function nhe(t){var e,n;if(t==null)return null;for(e=0,n=t.length;e=t.c.b:t.a<=t.c.b))throw K(new J);return e=t.a,t.a+=t.c.c,++t.b,Xt(e)}function FM(t){var e,n;return t>-129&&t<128?(e=t+128,n=(STt(),S1t)[e],!n&&(n=S1t[e]=new I8(t)),n):new I8(t)}function Xt(t){var e,n;return t>-129&&t<128?(e=t+128,n=(rTt(),y1t)[e],!n&&(n=y1t[e]=new L8(t)),n):new L8(t)}function fq(t,e){return!t||e&&!t.j||ct(t,114)&&a(t,114).a.b==0?0:t.Pf()}function HN(t,e){return!t||e&&!t.k||ct(t,114)&&a(t,114).a.a==0?0:t.Qf()}function Fi(t,e){return Es(t)?le(t,e):zb(t)||Ub(t)?(En(t),t===e):iot(t)?t.Fb(e):Jst(t)?t===e:ect(t,e)}function Yr(t){return Es(t)?z1(t):zb(t)?Tr((En(t),t)):Ub(t)?(En(t),t?1231:1237):iot(t)?t.Hb():Jst(t)?cm(t):Wot(t)}function fu(t){return Es(t)?At:zb(t)?To:Ub(t)?ho:iot(t)||Jst(t)?t.ql:t.ql||Array.isArray(t)&&Z(Ezt,1)||Ezt}function she(t){return t?t.i&1?t==Ol?ho:t==Gn?Io:t==zw?ME:t==Os?To:t==A0?Gm:t==my?Wm:t==Da?ux:D4:t:null}function Kb(){Kb=P,q$t=(dr(),Cx),X$t=oy,vQ=(Flt(),z$t),_Q=j$t,fwt=H$t,mF=G$t,bF=W$t,q6=$$t,dwt=V$t}function dq(){dq=P,WK=iAt(Y(Z(fA,1),jt,110,0,[(Js(),ah),uh])),$K=iAt(Y(Z(fA,1),jt,110,0,[og,fp]))}function AC(){AC=P,KK=new nW("MIRROR_X",0),JK=new nW("TRANSPOSE",1),YK=new nW("MIRROR_AND_TRANSPOSE",2)}function ohe(t){var e;return e=new mLt(t),xL(t.a,Hjt,new zu(Y(Z(_6,1),te,341,0,[e]))),e.d&&Ut(e.f,e.d),e.f}function che(t){var e,n;for(n=new H(t.r);n.a=48&&t<58?t-48:t>=97&&t<97?t-97+10:t>=65&&t<65?t-65+10:-1}function ahe(t){var e,n;if(t==null)return!1;for(e=0,n=t.length;elw?t-n>lw:n-t>lw}function so(t,e){var n;return Vo(t)&&Vo(e)&&(n=t+e,zPi)throw K(new jv(e,i));if(t.xh()&&t.pc(n))throw K(new yn(i6));t.mh(e,n)}function j6t(t,e,n){if(t<0||e>n)throw K(new Uc(nO+t+pft+e+", size: "+n));if(t>e)throw K(new yn(nO+t+FOt+e))}function Hat(t){throw oq(),K(new Lxt("Unexpected typeof result '"+t+"'; please report this bug to the GWT team"))}function zp(t){switch(Hb(),t.c){case 0:return bM(),I4;case 1:return new s2(Ame(new nM(t)));default:return new kxt(t)}}function H6t(t){var e;return t.Db&64?nh(t):(e=new ul(nh(t)),e.a+=" (source: ",mo(e,t.d),e.a+=")",e.a)}function Ct(t,e,n){return n==null?(!t.p&&(t.p=(ts(),new vi)),AM(t.p,e)):(!t.p&&(t.p=(ts(),new vi)),wr(t.p,e,n)),t}function KL(t,e,n){return n==null?(!t.p&&(t.p=(ts(),new vi)),AM(t.p,e)):(!t.p&&(t.p=(ts(),new vi)),wr(t.p,e,n)),t}function JL(t,e,n){var i;t.Eh(t.i+1),i=t.Ch(e,n),e!=t.i&&Aa(t.g,e,t.g,e+1,t.i-e),Vr(t.g,e,i),++t.i,t.sh(e,n),t.th()}function mq(t,e,n){var i,r,c;for(i=0,c=qn(t,0);c.b!=c.d.c&&(r=lt(Yt(Yn(c))),!(r>n));)r>=e&&++i;return i}function bq(t,e){var n,i,r;for(n=0,r=ac(t,e).tc();r.hc();)i=a(r.ic(),11),n+=z(i,(Ft(),Ru))!=null?1:0;return n}function ghe(t){var e;return e=a(P2(t.c.c,""),199),e||(e=new E2(K3(Y3(new Eb,""),"Other")),Am(t.c.c,"",e)),e}function G6t(t){this.a=new qa,this.d=new qa,this.b=new qa,this.c=new qa,this.g=new qa,this.i=new qa,this.f=t}function Js(){Js=P,Ff=new H5(nx,0),uh=new H5(hE,1),ah=new H5(lE,2),fp=new H5(PY,3),og=new H5("UP",4)}function Yg(){Yg=P,AF=new wW("INHERIT",0),kx=new wW("INCLUDE_CHILDREN",1),mA=new wW("SEPARATE_CHILDREN",2)}function mhe(t,e,n){var i,r;return i=new Qd(t.e,3,13,null,(r=e.c,r||(ye(),Hf)),Hp(t,e),!1),n?n.Sh(i):n=i,n}function bhe(t,e,n){var i,r;return i=new Qd(t.e,4,13,(r=e.c,r||(ye(),Hf)),null,Hp(t,e),!1),n?n.Sh(i):n=i,n}function Gat(t,e,n){var i,r;return r=t.sb,t.sb=e,t.Db&4&&!(t.Db&1)&&(i=new fs(t,1,4,r,e),n?n.Sh(i):n=i),n}function Wat(t,e,n){var i,r;return r=t.r,t.r=e,t.Db&4&&!(t.Db&1)&&(i=new fs(t,1,8,r,t.r),n?n.Sh(i):n=i),n}function jp(t,e){var n,i;return n=a(e,614),i=n.Hj(),!i&&n.Ij(i=ct(e,96)?new fEt(t,a(e,24)):new jAt(t,a(e,140))),i}function $at(t,e){var n;return t===e?!0:ct(e,89)?(n=a(e,89),t.e==n.e&&t.d==n.d&&Uce(t,n.a)):!1}function whe(t,e){var n;if(n=EP(t,e),ct(n,335))return a(n,29);throw K(new yn(U_+e+"' is not a valid attribute"))}function QL(t,e){var n;return n=new ue,t.a.sd(n)?(aM(),new OG(En(Q5t(t,n.a,e)))):(Vv(t),aM(),aM(),U1t)}function W6t(t,e){var n;t.c.length!=0&&(n=a(xo(t,dt(Cl,Ih,8,t.c.length,0,1)),123),Art(n,new h3),A9t(n,e))}function $6t(t,e){var n;t.c.length!=0&&(n=a(xo(t,dt(Cl,Ih,8,t.c.length,0,1)),123),Art(n,new cv),A9t(n,e))}function zM(t,e){switch(e.g){case 2:case 1:return ac(t,e);case 3:case 4:return Em(ac(t,e))}return we(),we(),fo}function Vat(t,e,n,i){switch(e){case 1:return!t.n&&(t.n=new Wt(ic,t,1,7)),t.n;case 2:return t.k}return Dut(t,e,n,i)}function vhe(t,e,n,i,r,c,l,f){var g;for(g=n;c=i||e=65&&t<=70?t-65+10:t>=97&&t<=102?t-97+10:t>=48&&t<=57?t-48:0}function X6t(t){return t-=t>>1&1431655765,t=(t>>2&858993459)+(t&858993459),t=(t>>4)+t&252645135,t+=t>>8,t+=t>>16,t&63}function a_(t,e){var n;n=(t.Bb&256)!=0,e?t.Bb|=256:t.Bb&=-257,t.Db&4&&!(t.Db&1)&&Bi(t,new Jl(t,1,2,n,e))}function Z6t(t,e){var n;n=(t.Bb&256)!=0,e?t.Bb|=256:t.Bb&=-257,t.Db&4&&!(t.Db&1)&&Bi(t,new Jl(t,1,8,n,e))}function qat(t,e){var n;n=(t.Bb&256)!=0,e?t.Bb|=256:t.Bb&=-257,t.Db&4&&!(t.Db&1)&&Bi(t,new Jl(t,1,8,n,e))}function Y6t(t,e){var n;n=(t.Bb&512)!=0,e?t.Bb|=512:t.Bb&=-513,t.Db&4&&!(t.Db&1)&&Bi(t,new Jl(t,1,9,n,e))}function u_(t,e){var n;n=(t.Bb&512)!=0,e?t.Bb|=512:t.Bb&=-513,t.Db&4&&!(t.Db&1)&&Bi(t,new Jl(t,1,3,n,e))}function LC(t,e){var n;return t.b==-1&&t.a&&(n=t.a.Vi(),t.b=n?t.c.qg(t.a.pi(),n):xr(t.c.mg(),t.a)),t.c.hg(t.b,e)}function xhe(t,e,n){var i,r;return r=t.a,t.a=e,t.Db&4&&!(t.Db&1)&&(i=new fs(t,1,5,r,t.a),n?elt(n,i):n=i),n}function Mhe(t,e){var n;if(n=kp(t.i,e),n==null)throw K(new xf("Node did not exist in input."));return wat(e,n),null}function Ehe(t,e){var n;if(n=zi(t.k,e),n==null)throw K(new xf("Port did not exist in input."));return wat(e,n),null}function jM(t){if(t.c)jM(t.c);else if(t.d)throw K(new yc("Stream already terminated, can't be modified or used"))}function She(t){var e;if(!t.a)throw K(new yc("Cannot offset an unassigned cut."));e=t.c-t.b,t.b+=e,P4t(t,e),I4t(t,e)}function The(t){var e;t.g&&(e=t.c.pf()?t.f:t.a,iht(e.a,t.o,!0),iht(e.a,t.o,!1),Ct(t.o,(qt(),Qi),(Ls(),Lx)))}function Che(t){var e,n,i;for(e=a(z(t,(mc(),Gbt)),15),i=e.tc();i.hc();)n=a(i.ic(),170),Xi(n.b.d,n),Xi(n.c.b,n)}function K6t(t){var e,n,i;for(i=0,n=(Ao(),new $d(id(Zd(t.a,new X))));Jn(n);)e=a(In(n),14),e.c.g==e.d.g||++i;return i}function J6t(t,e){var n,i;for(i=new $n(t);i.e!=i.i._b();)if(n=a(ci(i),24),zt(e)===zt(n))return!0;return!1}function Q6t(t,e){var n,i;for(i=new $n(t);i.e!=i.i._b();)if(n=a(ci(i),133),zt(e)===zt(n))return!0;return!1}function Ahe(t,e,n){var i,r,c;return c=(r=JM(t.b,e),r),c&&(i=a(W7(DL(t,c),""),24),i)?Wlt(t,i,e,n):null}function wq(t,e,n){var i,r,c;return c=(r=JM(t.b,e),r),c&&(i=a(W7(DL(t,c),""),24),i)?$lt(t,i,e,n):null}function Xat(t){var e,n;return e=t.j,e==(Ke(),rs)?(n=a(z(t,(Ft(),wc)),69),n==(Ht(),Tn)||n==fi):!1}function tIt(t){var e;return e=new im,e.a+="VerticalSegment ",Fa(e,t.e),e.a+=" ",Ii(e,DW(new A5(Rc),new H(t.k))),e.a}function khe(t){var e,n,i;for(e=new Nt,i=new H(t.b);i.a0&&(i+=r,++n);return n>1&&(i+=t.d*(n-1)),i}function zhe(t,e,n){var i,r;for(r=t.a.Xb().tc();r.hc();)if(i=a(r.ic(),8),N1(n,a(Ee(e,i.o),13)))return i;return null}function xq(t,e,n,i){var r;if(r=t.length,e>=r)return r;for(e=e>0?e:0;e=1?uh:fp):n}function Hhe(t){var e,n,i;for(e=0,i=new H(t.c.a);i.a=64&&e<128&&(r=Xh(r,Yd(1,e-64)));return r}function cIt(t,e,n){var i,r,c;for(r=Rn(e?Rs(t):br(t));Jn(r);)i=a(In(r),14),c=e?i.c.g:i.d.g,c.j==(Ke(),bu)&&Ks(c,n)}function Ghe(t,e,n){var i;i=new qkt(t,e),cr(t.r,e.ef(),i),n&&t.t!=(Kh(),kF)&&(i.c=new tAt(t.d),pd(e.We(),new WH(i)))}function aIt(t,e,n){var i,r;return i=(sm(),r=new P3,r),LV(i,e),PV(i,n),t&&ni((!t.a&&(t.a=new Ss(sf,t,5)),t.a),i),i}function Vn(t){if(t.i==null)throw K(new yc("The task has not begun yet."));t.b||(t.c0&&e.charCodeAt(0)==43?e.substr(1,e.length-1):e))}function qhe(t){var e;return t==null?null:new _1((e=Hc(t,!0),e.length>0&&e.charCodeAt(0)==43?e.substr(1,e.length-1):e))}function tut(t){var e;return e=dt(el,Pf,22,2,15,1),t-=ao,e[0]=(t>>10)+jP&qr,e[1]=(t&1023)+56320&qr,ml(e,0,e.length)}function Xhe(t){var e,n;for(n=Pme(Xu(Vb(t))).tc();n.hc();)if(e=hi(n.ic()),e4(t,e))return oae((I3t(),Uqt),e);return null}function ml(t,e,n){var i,r,c,l;for(c=e+n,Pct(e,c,t.length),l="",r=e;re&&i.Ld(t[c-1],t[c])>0;--c)l=t[c],Vr(t,c,t[c-1]),Vr(t,c-1,l)}function Yhe(t,e){var n;t.c=e,t.a=rfe(e),t.a<54&&(t.f=(n=e.d>1?Xh(Yd(e.a[1],32),ns(e.a[0],uo)):ns(e.a[0],uo),EM(Xg(e.e,n))))}function Mq(){rlt();var t,e,n;n=T3e+++dae(),t=Tr(y.Math.floor(n*GP))&eO,e=Tr(n-t*fft),this.a=t^1502,this.b=e^FZ}function Khe(t,e,n){t.n=Gb(A0,[wt,lft],[378,22],14,[n,Tr(y.Math.ceil(e/32))],2),t.o=e,t.p=n,t.j=e-1>>1,t.k=n-1>>1}function Jhe(t,e){var n,i,r;i=Zv(e),r=lt(Yt(GM(i,(qt(),nf)))),n=y.Math.max(0,r/2-.5),jC(e,n,1),Ut(t,new xMt(e,n))}function uIt(t,e){var n,i;for(n=qn(t,0);n.b!=n.d.c;){if(i=lt(Yt(Yn(n))),i==e)return;if(i>e){SM(n);break}}gM(n,e)}function He(t,e){var n,i,r,c,l;if(n=e.f,Am(t.c.d,n,e),e.g!=null)for(r=e.g,c=0,l=r.length;ce?1:J9(isNaN(t),isNaN(e))}function dIt(t){no(),nD(this),ZD(this),this.e=t,t!=null&&kSt(t,dZ,this),this.g=t==null?tu:Yc(t),this.a="",this.b=t,this.a=""}function IC(t){var e;this.a=(e=a(t.e&&t.e(),10),new ja(e,a(cu(e,e.length),10),0)),this.b=dt(un,te,1,this.a.a.length,5,1)}function JN(t,e){var n,i;return n=t._b(),e.lengthn&&Vr(e,n,null),e}function iut(t){var e,n,i;for(i=new Sp,i.a+="[",e=0,n=t._b();e>5,e=t&31,i=dt(Gn,pi,22,n+1,15,1),i[n]=1<c?e:c;return Xt(e)}function afe(t,e){var n,i;for(i=t.e.a.Xb().tc();i.hc();)if(n=a(i.ic(),247),mge(e,n.d)||_0e(e,n.d))return!0;return!1}function pIt(t,e){var n,i,r,c;for(c=t.g.ed(),n=0;c.hc();){if(i=lt(Yt(c.ic())),r=i-e,r>N_)return n;r>yO&&++n}return n}function gIt(t,e){var n,i,r;r=e.d.g,i=r.j,!(i==(Ke(),gs)||i==Jc||i==ef)&&(n=Rn(br(r)),Jn(n)&&wr(t.k,e,a(In(n),14)))}function mIt(t,e){var n,i;n=e==(GC(),uJ),i=sut(t),n&&!i||!n&&i?Ct(t,(qt(),Bf),(md(),K6)):Ct(t,(qt(),Bf),(md(),Y6))}function gd(){gd=P,zQ=new G9(nx,0),UQ=new G9("POLYLINE",1),UE=new G9("ORTHOGONAL",2),eb=new G9("SPLINES",3)}function QN(){QN=P,bQ=new mW("OVERLAP_REMOVAL",0),gQ=new mW("COMPACTION",1),mQ=new mW("GRAPH_SIZE_CALCULATION",2)}function t7(){t7=P,kbt=new uW("EQUALLY_DISTRIBUTED",0),QJ=new uW("NORTH_STACKED",1),Lbt=new uW("NORTH_SEQUENCE",2)}function ufe(t){var e,n,i,r,c;return c=slt(t),n=P9(t.c),i=!n,i&&(r=new Ig,L1(c,"knownLayouters",r),e=new dG(r),vo(t.c,e)),c}function lfe(t,e,n){var i,r;for(r=ct(e,62)&&a(a(e,17),62).Bb&ao?new EW(e,t):new DM(e,t),i=0;i3;)r*=10,--c;t=(t+(r>>1))/r|0}return i.i=t,!0}function O2(t,e,n){var i,r;for(r=t.tc();r.hc();)if(i=r.ic(),zt(e)===zt(i)||e!=null&&Fi(e,i))return n&&r.jc(),!0;return!1}function MIt(t,e){var n,i;if(e){for(n=0;n0&&(e.lengtht.i&&Vr(e,t.i,null),e}function EIt(t,e){var n,i,r,c;return n=e>>5,e&=31,r=t.d+n+(e==0?0:1),i=dt(Gn,pi,22,r,15,1),O1e(i,t.a,n,e),c=new Wv(t.e,r,i),oC(c),c}function n7(t,e){grt();var n,i;return n=rL((Hh(),Hh(),R4)),i=null,e==n&&(i=a(Zc(p1t,t),556)),i||(i=new YCt(t),e==n&&tc(p1t,t,i)),i}function xr(t,e){var n,i,r;if(n=(t.i==null&&V1(t),t.i),i=e.pi(),i!=-1){for(r=n.length;i=0;--i)for(e=n[i],r=0;r0&&Pc(t,128)<0?(e=or(t)+128,n=(ETt(),x1t)[e],!n&&(n=x1t[e]=new P8(t)),n):new P8(t)}function iP(t){return $1(),Pc(t,0)<0?Pc(t,-1)!=0?new $ut(-1,LM(t)):SK:Pc(t,10)<=0?N1t[or(t)]:new $ut(1,t)}function SIt(){yit.call(this,new Ict(16)),Ah(2,"expectedValuesPerKey"),this.b=2,this.a=new Rot(null,null,0,null),q3(this.a,this.a)}function i7(){i7=P,VQ=new $9("SIMPLE",0),Cvt=new $9("GROUP_DEC",1),kvt=new $9("GROUP_MIXED",2),Avt=new $9("GROUP_INC",3)}function lut(){lut=P,Svt=new b2(15),IVt=new xc((dr(),sy),Svt),DVt=new xc(oy,15),RVt=new xc(OQ,Xt(0)),PVt=new xc(BE,aE)}function Tq(){Tq=P,ott=new Fk,Yvt=new Cz,Kvt=new Uk,Jvt=new RR,Qvt=new DR,t_t=new NR,e_t=new GS,n_t=new Az,i_t=new OR}function TIt(t){this.e=dt(Gn,pi,22,t.length,15,1),this.c=dt(Ol,c0,22,t.length,16,1),this.b=dt(Ol,c0,22,t.length,16,1),this.f=0}function hut(t,e){this.n=Gb(A0,[wt,lft],[378,22],14,[e,Tr(y.Math.ceil(t/32))],2),this.o=t,this.p=e,this.j=t-1>>1,this.k=e-1>>1}function CIt(t,e,n){TLt(),wxt.call(this),this.a=Gb(jVt,[wt,Fft],[537,171],0,[DF,qQ],2),this.c=new oM,this.g=t,this.f=e,this.d=n}function Kc(t,e,n){var i,r,c;return t.ti()?(i=t.i,c=t.ui(),JL(t,i,e),r=t.mi(3,null,e,i,c),n?n.Sh(r):n=r):JL(t,t.i,e),n}function Lh(t,e){var n,i,r;return t.f>0&&(t.Fi(),i=e==null?0:Yr(e),r=(i&qi)%t.d.length,n=klt(t,r,i,e),n)?n.lc():null}function Cq(t,e){var n,i,r;return t.f>0?(t.Fi(),i=e==null?0:Yr(e),r=(i&qi)%t.d.length,n=rDt(t,r,i,e),n!=-1):!1}function rP(t,e){var n,i,r,c;for(c=gu(t.e.mg(),e),n=a(t.g,124),r=0;r2e3&&(Szt=t,XO=y.setTimeout(_te,10))),qO++==0?(mue((Er(),d1t)),!0):!1}function Lfe(){return Error.stackTraceLimit>0?(y.Error.stackTraceLimit=Error.stackTraceLimit=64,!0):"stack"in new Error}function RIt(t,e){return t.e>e.e?1:t.ee.d?t.e:t.d=0?c=c.a[1]:(r=c,c=c.a[0])}return r}function UIt(t,e,n){var i,r,c;for(r=null,c=t.b;c;){if(i=t.a.Ld(e,c.d),n&&i==0)return c;i<=0?c=c.a[0]:(r=c,c=c.a[1])}return r}function Rfe(t,e,n,i){var r,c,l;return r=!1,Jye(t.f,n,i)&&(Zfe(t.f,t.a[e][n],t.a[e][i]),c=t.a[e],l=c[i],c[i]=c[n],c[n]=l,r=!0),r}function put(t,e){var n,i,r;for(r=t.g.ed();r.hc();)if(n=lt(Yt(r.ic())),i=y.Math.abs(n-e),ie?1:J9(isNaN(t),isNaN(e)))>0}function mut(t,e){return Ef(),Ef(),P1(Z1),(y.Math.abs(t-e)<=Z1||t==e||isNaN(t)&&isNaN(e)?0:te?1:J9(isNaN(t),isNaN(e)))<0}function zIt(t,e){return Ef(),Ef(),P1(Z1),(y.Math.abs(t-e)<=Z1||t==e||isNaN(t)&&isNaN(e)?0:te?1:J9(isNaN(t),isNaN(e)))<=0}function Ofe(t,e){if(e.c==t)return e.d;if(e.d==t)return e.c;throw K(new yn("Input edge is not connected to the input port."))}function r7(t,e){return En(t),e==null?!1:le(t,e)?!0:t.length==e.length&&le(t.toLowerCase(),e.toLowerCase())}function jIt(t){var e,n,i,r,c;if(t==null)return null;for(c=new Nt,n=rq(t),i=0,r=n.length;ie.e?1:t.fe.f?1:Yr(t)-Yr(e)}function WM(t,e){ts(),si(t);try{return t.Vb(e)}catch(n){if(n=vr(n),ct(n,177))return null;if(ct(n,169))return null;throw K(n)}}function Gfe(t,e){ts(),si(t);try{return t.$b(e)}catch(n){if(n=vr(n),ct(n,177))return null;if(ct(n,169))return null;throw K(n)}}function XIt(t){$1(),t.length==0?(this.e=0,this.d=1,this.a=Y(Z(Gn,1),pi,22,15,[0])):(this.e=1,this.d=t.length,this.a=t,oC(this))}function wut(t,e,n,i){YM();var r,c;for(r=0,c=0;c=c?(Jle(t,e),-1):(Qle(t,e),1)}function ZIt(t,e){var n,i,r;++t.j,i=t.g==null?0:t.g.length,e>i&&(r=t.g,n=i+(i/2|0)+4,nNZ)return n.zg();if(i=n.sg(),i||n==t)break}return i}function YIt(t,e){var n,i;return n=e.Yg(t.a),n&&(i=hi(Lh((!n.b&&(n.b=new xu((ye(),Ho),Dc,n)),n.b),Ti)),i!=null)?i:e.be()}function qfe(t,e){var n,i;return n=e.Yg(t.a),n&&(i=hi(Lh((!n.b&&(n.b=new xu((ye(),Ho),Dc,n)),n.b),Ti)),i!=null)?i:e.be()}function Xe(t){var e;if(ct(t.a,4)){if(e=NIt(t.a),e==null)throw K(new yc(YBt+t.b+"'. "+dpt+(Vd(mI),mI.k)+ppt));return e}else return t.a}function Xfe(t){var e;if(t==null)return null;if(e=Vme(Hc(t,!0)),e==null)throw K(new jG("Invalid hexBinary value: '"+t+"'"));return e}function KIt(t,e){var n,i,r;if(Ut(sB,t),e.nc(t),n=a(zi(OK,t),19),n)for(r=n.tc();r.hc();)i=a(r.ic(),35),nc(sB,i,0)!=-1||KIt(i,e)}function Zfe(t,e,n){var i,r;oX(t.e,e,n,(Ht(),on)),oX(t.i,e,n,Qe),t.a&&(r=a(z(e,(Ft(),li)),11),i=a(z(n,li),11),J$(t.g,r,i))}function JIt(t){var e;zt(cn(t,(dr(),ry)))===zt((Yg(),AF))&&(io(t)?(e=a(cn(io(t),ry),316),ga(t,ry,e)):ga(t,ry,mA))}function vut(t,e,n){this.c=t,this.f=new Nt,this.e=new go,this.j=new eot,this.n=new eot,this.b=e,this.g=new qh(e.c,e.d,e.b,e.a),this.a=n}function _ut(t,e,n,i,r,c){Ort(this),this.e=t,this.f=e,this.d=n,this.c=i,this.g=r,this.b=c,this.j=lt(Yt(r.tc().ic())),this.i=lt(Yt(gPt(r)))}function Yfe(t){var e;for(e=a(In(Rn(Rs(t))),14).c.g;e.j==(Ke(),Hr);)Ct(e,(Ft(),k6),(me(),me(),!0)),e=a(In(Rn(Rs(e))),14).c.g}function Kfe(t,e,n){var i,r,c,l;return c=e.i,l=n.i,c!=l?c.g-l.g:(i=t.f[e.o],r=t.f[n.o],i==0&&r==0?0:i==0?-1:r==0?1:ro(i,r))}function ci(t){var e;try{return e=t.i.cd(t.e),t.Bi(),t.g=t.e++,e}catch(n){throw n=vr(n),ct(n,79)?(t.Bi(),K(new J)):K(n)}}function Iq(t){var e;try{return e=t.c.yh(t.e),t.Bi(),t.g=t.e++,e}catch(n){throw n=vr(n),ct(n,79)?(t.Bi(),K(new J)):K(n)}}function j1(t,e){var n;n=t.fd(e);try{return n.ic()}catch(i){throw i=vr(i),ct(i,101)?K(new Uc("Can't get element "+e)):K(i)}}function QIt(t,e){al(),si(t);try{return t.pc(e)}catch(n){if(n=vr(n),ct(n,177))return!1;if(ct(n,169))return!1;throw K(n)}}function Jfe(t,e){ts(),si(t);try{return t.Qb(e)}catch(n){if(n=vr(n),ct(n,177))return!1;if(ct(n,169))return!1;throw K(n)}}function tRt(t,e,n){return new qh(y.Math.min(t.a,e.a)-n/2,y.Math.min(t.b,e.b)-n/2,y.Math.abs(t.a-e.a)+n,y.Math.abs(t.b-e.b)+n)}function eRt(t,e){var n,i,r,c;for(n=0,r=new H(e.a);r.a0),e.a.cd(e.c=--e.b))}function Qg(){Qg=P,On=new j5("PARENTS",0),vc=new j5("NODES",1),Md=new j5("EDGES",2),tb=new j5("PORTS",3),sg=new j5("LABELS",4)}function H1(){H1=P,nb=new G5("DISTRIBUTED",0),GQ=new G5("JUSTIFIED",1),_vt=new G5("BEGIN",2),bA=new G5(m4,3),yvt=new G5("END",4)}function BC(t,e,n){wxt.call(this),this.a=dt(jVt,Fft,171,(Ch(),Y(Z(Pw,1),jt,203,0,[lc,ta,hc])).length,0,1),this.b=t,this.d=e,this.c=n}function cP(t,e){var n,i;if(++t.j,e!=null&&(n=(i=t.a.Cb,ct(i,92)?a(i,92).cg():null),tme(e,n))){NC(t.a,4,n);return}NC(t.a,4,a(e,116))}function Qfe(t,e){var n,i;return e!=null&&tw(e).length!=0&&(n=ght(t,e),n)?n:Nn.length!=0&&(i=ght(t,Nn),i)?i:null}function tde(t){var e,n;if(t.j==(Ke(),Hr)){for(n=Rn(Kg(t));Jn(n);)if(e=a(In(n),14),!ec(e)&&t.c==Qq(e,t).c)return!0}return!1}function o7(){o7=P,kK=new irt("NUM_OF_EXTERNAL_SIDES_THAN_NUM_OF_EXTENSIONS_LAST",0),Z1t=new irt("CORNER_CASES_THAN_SINGLE_SIDE_LAST",1)}function Rq(){return X7(),Y(Z(pqt,1),jt,147,0,[fqt,hqt,dqt,iqt,nqt,rqt,cqt,oqt,sqt,lqt,uqt,aqt,tqt,QVt,eqt,KVt,YVt,JVt,XVt,qVt,ZVt,XQ])}function Dq(t,e){var n;switch(n=!t.v.pc((Ku(),M0))||t.q==(Ls(),Gc),t.t.g){case 1:n?vxe(t,e):W7t(t,e);break;case 0:n?O2e(t,e):z7t(t,e)}}function ede(t,e,n){var i;switch(i=n.q.getFullYear()-Nm+Nm,i<0&&(i=-i),e){case 1:t.a+=i;break;case 2:dd(t,i%100,2);break;default:dd(t,i,e)}}function nde(t){var e;switch(e=t.Mh(null),e){case 10:return 0;case 15:return 1;case 14:return 2;case 11:return 3;case 21:return 4}return-1}function Nq(t){switch(t.g){case 1:return Js(),og;case 4:return Js(),ah;case 2:return Js(),uh;case 3:return Js(),fp}return Js(),Ff}function ide(t,e,n,i){var r,c,l;return r=new Qd(t.e,1,13,(l=e.c,l||(ye(),Hf)),(c=n.c,c||(ye(),Hf)),Hp(t,e),!1),i?i.Sh(r):i=r,i}function qn(t,e){var n,i;if(Yv(e,t.b),e>=t.b>>1)for(i=t.c,n=t.b;n>e;--n)i=i.b;else for(i=t.a.a,n=0;n=0?t.Fg(r):gX(t,i)):n<0?gX(t,i):a(i,61).aj().fj(t,t.Qg(),n)}function iRt(t){var e,n,i;for(i=(!t.o&&(t.o=new lu((Ic(),pp),ag,t,0)),t.o),n=i.c.tc();n.e!=n.i._b();)e=a(n.Ci(),38),e.lc();return SL(i)}function ude(t){var e,n,i,r;for(i=dt(_3e,te,144,t.c.length,0,1),r=0,n=new H(t);n.a0&&(Ut(t.b,new QTt(e.a,n)),i=e.a.length,0i&&(e.a+=UEt(dt(el,Pf,22,-i,15,1))))}function a7(t){switch(jit(),this.c=new Nt,this.d=t,t.g){case 0:case 2:this.a=Not(Ogt),this.b=is;break;case 3:case 1:this.a=Ogt,this.b=Ps}}function yut(t,e){this.e=t,e.5&&c<50;)r=wDt(i),n=j2(i,r,!0),e=y.Math.abs(n.b),++c;return j2(t,r,!1)}function oRt(t){var e,n,i,r,c;for(i=VX(t),e=is,c=0,r=0;e>.5&&c<50;)r=bDt(i),n=j2(i,r,!0),e=y.Math.abs(n.a),++c;return j2(t,r,!1)}function dde(t,e){var n,i,r,c;for(c=0,i=qn(t,0);i.b!=i.d.c;)n=a(Yn(i),35),c+=y.Math.pow(n.g*n.f-e,2);return r=y.Math.sqrt(c/(t.b-1)),r}function cRt(t,e){var n,i,r;for(n=t.o,r=a(a(rr(t.r,e),19),60).tc();r.hc();)i=a(r.ic(),111),i.e.a=ape(i,n.a),i.e.b=n.b*lt(Yt(i.b.xe(NF)))}function B2(t,e,n,i){var r;return n>=0?t.Bg(e,n,i):(t.yg()&&(i=(r=t.og(),r>=0?t.jg(i):t.yg().Cg(t,-1-r,null,i))),t.lg(e,n,i))}function F2(t,e,n){var i,r;if(r=t._b(),e>=r)throw K(new jv(e,r));if(t.xh()&&(i=t.dd(n),i>=0&&i!=e))throw K(new yn(i6));return t.Ah(e,n)}function pde(t,e,n){var i,r,c,l;return i=t.dd(e),i!=-1&&(t.ti()?(c=t.ui(),l=PD(t,i),r=t.mi(4,l,null,i,c),n?n.Sh(r):n=r):PD(t,i)),n}function $s(t,e,n){var i,r,c,l;return i=t.dd(e),i!=-1&&(t.ti()?(c=t.ui(),l=U2(t,i),r=t.mi(4,l,null,i,c),n?n.Sh(r):n=r):U2(t,i)),n}function aRt(t){var e,n,i;t.b==t.c&&(i=t.a.length,n=Eat(8>i?8:i)<<1,t.b!=0?(e=cu(t.a,n),lPt(t,e,i),t.a=e,t.b=0):CG(t.a,n),t.c=i)}function gde(t){var e,n;e=new Nt,n=t;do n=a(In(Rn(br(n))),14).d.g,n.j==(Ke(),Hr)&&(e.c[e.c.length]=n);while(n.j==(Ke(),Hr));return e}function uRt(t){var e,n;for(this.b=new Nt,this.c=t,this.a=!1,n=new H(t.a);n.a0||t==(Zr(),bK)||e==(co(),wK))throw K(new yn("Invalid range: "+nkt(t,e)))}function mde(t){switch(t.g){case 1:return Sm(),hI;case 3:return Sm(),lI;case 2:return Sm(),YQ;case 4:return Sm(),ZQ;default:return null}}function Fq(t){switch(t.g){case 0:return null;case 1:return new xPt;case 2:return new pit;default:throw K(new yn(NY+(t.f!=null?t.f:""+t.g)))}}function bde(t,e,n){if(t.e)switch(t.b){case 1:zse(t.c,e,n);break;case 0:jse(t.c,e,n)}else hkt(t.c,e,n);t.a[e.o][n.o]=t.c.i,t.a[n.o][e.o]=t.c.e}function Qb(){Qb=P,KB=new U9(Fm,0),ZJ=new U9("PORT_POSITION",1),ey=new U9("NODE_SIZE_WHERE_SPACE_PERMITS",2),ty=new U9("NODE_SIZE",3)}function fRt(t){var e,n,i;for(n=new H(t.a);n.a=0?t.ug(l,n,!0):W2(t,c,n)):a(c,61).aj().cj(t,t.Qg(),r,n,i)}function wde(t,e){var n,i,r,c;return c=t.o,n=t.p,c=0)return r;if(t.Rj()){for(i=0;ir&&Vr(e,r,null),e}function dRt(t,e){var n,i,r;for(r=t.a.length,e.lengthr&&Vr(e,r,null),e}function h_(t,e,n){try{return Bb(TV(t,e,n),1)}catch(i){throw i=vr(i),ct(i,305)?K(new Uc($Z+t.o+"*"+t.p+VZ+e+Rc+n+qZ)):K(i)}}function pRt(t,e,n){try{return Bb(TV(t,e,n),0)}catch(i){throw i=vr(i),ct(i,305)?K(new Uc($Z+t.o+"*"+t.p+VZ+e+Rc+n+qZ)):K(i)}}function gRt(t,e,n){try{return Bb(TV(t,e,n),2)}catch(i){throw i=vr(i),ct(i,305)?K(new Uc($Z+t.o+"*"+t.p+VZ+e+Rc+n+qZ)):K(i)}}function mRt(t,e,n){var i;try{return h_(t,e+t.j,n+t.k)}catch(r){throw r=vr(r),ct(r,79)?(i=r,K(new Uc(i.g+rO+e+Rc+n+")."))):K(r)}}function vde(t,e,n){var i;try{return pRt(t,e+t.j,n+t.k)}catch(r){throw r=vr(r),ct(r,79)?(i=r,K(new Uc(i.g+rO+e+Rc+n+")."))):K(r)}}function _de(t,e,n){var i;try{return gRt(t,e+t.j,n+t.k)}catch(r){throw r=vr(r),ct(r,79)?(i=r,K(new Uc(i.g+rO+e+Rc+n+")."))):K(r)}}function bRt(t,e){if(t.g==-1)throw K(new na);t.Bi();try{t.d.hd(t.g,e),t.f=t.d.j}catch(n){throw n=vr(n),ct(n,79)?K(new C):K(n)}}function wRt(t,e,n){di(n,"Compound graph preprocessor",1),t.a=new Iv,j7t(t,e,null),J_e(t,e),Mbe(t),Ct(e,(Ft(),rmt),t.a),t.a=null,uu(t.b),Vn(n)}function Uq(t,e){var n,i;if(zrt(e>0),(e&-e)==e)return Tr(e*pu(t,31)*4656612873077393e-25);do n=pu(t,31),i=n%e;while(n-i+(e-1)<0);return Tr(i)}function yde(t,e,n){switch(n.g){case 1:t.a=e.a/2,t.b=0;break;case 2:t.a=e.a,t.b=e.b/2;break;case 3:t.a=e.a/2,t.b=e.b;break;case 4:t.a=0,t.b=e.b/2}}function xde(t){var e,n;for(n=a(z(t,(Ft(),UB)),15).tc();n.hc();)if(e=a(n.ic(),68),jb(e,(qt(),GB)))return a(z(e,GB),276);return null}function Mde(t,e){var n,i,r;for(n=am(new Dg,t),r=new H(e);r.a1&&(c=Mde(t,e)),c}function Cde(t,e){var n,i,r,c;for(c=new H(e.a);c.a102?-1:t<=57?t-48:t<65?-1:t<=70?t-65+10:t<97?-1:t-97+10}function MRt(t,e){var n,i,r;for(t.b[e.g]=1,i=qn(e.d,0);i.b!=i.d.c;)n=a(Yn(i),170),r=n.c,t.b[r.g]==1?Xi(t.a,n):t.b[r.g]==2?t.b[r.g]=1:MRt(t,r)}function ERt(t,e){var n;return n=Y(Z(Os,1),Xo,22,15,[fq(t.a[0],e),fq(t.a[1],e),fq(t.a[2],e)]),t.d&&(n[0]=y.Math.max(n[0],n[2]),n[2]=n[0]),n}function SRt(t,e){var n;return n=Y(Z(Os,1),Xo,22,15,[HN(t.a[0],e),HN(t.a[1],e),HN(t.a[2],e)]),t.d&&(n[0]=y.Math.max(n[0],n[2]),n[2]=n[0]),n}function Ade(t){var e,n,i;for(C5(t.b.a),t.a=dt(eB,te,57,t.c.c.a.b.c.length,0,1),e=0,i=new H(t.c.c.a.b);i.ai&&t.charCodeAt(e-1)<=32;)--e;return i>0||ec&&Vr(e,c,null),e}function Xq(t){Ao();var e;if(e=Kle(t),!Jn(t))throw K(new Uc("position (0) must be less than the number of elements that remained ("+e+")"));return In(t)}function Xde(t){var e;return e=(HLt(),Lzt),e[t>>>28]|e[t>>24&15]<<4|e[t>>20&15]<<8|e[t>>16&15]<<12|e[t>>12&15]<<16|e[t>>8&15]<<20|e[t>>4&15]<<24|e[t&15]<<28}function kRt(t){var e,n,i;for(i=t.f,t.k=dt(Os,Xo,22,i,15,1),t.d=dt(Os,Xo,22,i,15,1),e=0;e0&&(r.b+=e),r}function d7(t,e){var n,i,r;for(r=new go,i=t.tc();i.hc();)n=a(i.ic(),31),TP(n,0,r.b),r.b+=n.e.b+e,r.a=y.Math.max(r.a,n.e.a);return r.a>0&&(r.a+=e),r}function Qde(t,e){var n,i;if(e<0||e>=t._b())return null;for(n=e;n=t.i)throw K(new MW(e,t.i));return++t.j,n=t.g[e],i=t.i-e-1,i>0&&Aa(t.g,e+1,t.g,e,i),Vr(t.g,--t.i,null),t.vh(e,n),t.th(),n}function Yq(t,e){var n,i;return t.Db>>16==6?t.Cb.Cg(t,5,of,e):(i=jo(a(Ve((n=a(an(t,16),24),n||t.Rg()),t.Db>>16),17)),t.Cb.Cg(t,i.n,i.f,e))}function Iut(t,e){var n,i;n=t.fd(e);try{return i=n.ic(),n.jc(),i}catch(r){throw r=vr(r),ct(r,101)?K(new Uc("Can't remove element "+e)):K(r)}}function rpe(t,e){var n,i,r;return r=new Ei(new zu(Y(Z(k3e,1),te,1700,0,[t,e])),16),i=new ATt(r),n=new gi(null,i),Mot(n,new Jj(t)),Mot(n,new Qj(e)),n}function Rut(t,e,n,i,r,c){var l,f,g;for(zt(t)===zt(n)&&(t=t.slice(e,e+r),e=0),f=e,g=e+r;f>22),r+=i>>22,r<0)?!1:(t.l=n&eu,t.m=i&eu,t.h=r&sp,!0)}function hpe(t,e,n,i,r,c,l){var f,g;return!(e.je()&&(g=t.a.Ld(n,i),g<0||!r&&g==0)||e.ke()&&(f=t.a.Ld(n,c),f>0||!l&&f==0))}function z2(){z2=P,p6=new O9("NORTH",0),d6=new O9("EAST",1),g6=new O9("SOUTH",2),m6=new O9("WEST",3),p6.a=!1,d6.a=!0,g6.a=!1,m6.a=!0}function zC(){zC=P,b6=new B9("NORTH",0),nB=new B9("EAST",1),iB=new B9("SOUTH",2),w6=new B9("WEST",3),b6.a=!1,nB.a=!0,iB.a=!1,w6.a=!0}function Tu(){Tu=P,uI=new V9("UNKNOWN",0),kd=new V9("ABOVE",1),cg=new V9("BELOW",2),aI=new V9("INLINE",3),new es("org.eclipse.elk.labelSide",uI)}function G1(t,e,n){if(n&&(e<0||e>n.a.c.length))throw K(new yn("index must be >= 0 and <= layer node count"));t.c&&Lc(t.c.a,t),t.c=n,n&&hm(n.a,e,t)}function ORt(t){switch(t.g){case 0:return wJ;case 1:return vJ;case 2:return _J;case 3:return yJ;case 4:return CB;case 5:return xJ;default:return null}}function $M(){$M=P,cF=new z9("P1_TREEIFICATION",0),rA=new z9("P2_NODE_ORDERING",1),$6=new z9("P3_NODE_PLACEMENT",2),sA=new z9("P4_EDGE_ROUTING",3)}function Lo(t,e,n){var i,r;return i=(r=new IG,UM(r,e),kh(r,n),ni((!t.c&&(t.c=new Wt(Nw,t,12,10)),t.c),r),r),r_(i,0),IM(i,1),u_(i,!0),a_(i,!0),i}function BRt(t,e){var n,i;return t.Db>>16==17?t.Cb.Cg(t,21,Dl,e):(i=jo(a(Ve((n=a(an(t,16),24),n||t.Rg()),t.Db>>16),17)),t.Cb.Cg(t,i.n,i.f,e))}function fpe(t,e){var n,i,r;if(i=new N9,r=new Tat(i.q.getFullYear()-Nm,i.q.getMonth(),i.q.getDate()),n=k_e(t,e,r),n==0||n>16==6?t.Cb.Cg(t,6,Xs,e):(i=jo(a(Ve((n=a(an(t,16),24),n||(Ic(),OF)),t.Db>>16),17)),t.Cb.Cg(t,i.n,i.f,e))}function Fut(t,e){var n,i;return t.Db>>16==7?t.Cb.Cg(t,1,fI,e):(i=jo(a(Ve((n=a(an(t,16),24),n||(Ic(),Rvt)),t.Db>>16),17)),t.Cb.Cg(t,i.n,i.f,e))}function Uut(t,e){var n,i;return t.Db>>16==9?t.Cb.Cg(t,9,zr,e):(i=jo(a(Ve((n=a(an(t,16),24),n||(Ic(),Nvt)),t.Db>>16),17)),t.Cb.Cg(t,i.n,i.f,e))}function zut(t,e){var n,i;return t.Db>>16==3?t.Cb.Cg(t,12,zr,e):(i=jo(a(Ve((n=a(an(t,16),24),n||(Ic(),Ivt)),t.Db>>16),17)),t.Cb.Cg(t,i.n,i.f,e))}function jut(t,e){var n,i;return t.Db>>16==3?t.Cb.Cg(t,0,pI,e):(i=jo(a(Ve((n=a(an(t,16),24),n||(ye(),E0)),t.Db>>16),17)),t.Cb.Cg(t,i.n,i.f,e))}function URt(t,e){var n,i;return t.Db>>16==7?t.Cb.Cg(t,6,of,e):(i=jo(a(Ve((n=a(an(t,16),24),n||(ye(),C0)),t.Db>>16),17)),t.Cb.Cg(t,i.n,i.f,e))}function zRt(t,e){var n,i;return t.Db>>16==5?t.Cb.Cg(t,9,$F,e):(i=jo(a(Ve((n=a(an(t,16),24),n||(ye(),S0)),t.Db>>16),17)),t.Cb.Cg(t,i.n,i.f,e))}function VM(t,e){var n,i;if(e){if(e==t)return!0;for(n=0,i=a(e,42).yg();i&&i!=e;i=i.yg()){if(++n>NZ)return VM(t,i);if(i==t)return!0}}return!1}function Spe(t){var e,n;e=a(z(t,(Ph(),_jt)),21),e?(n=e.a,n==0?Ct(t,(I1(),uB),new Mq):Ct(t,(I1(),uB),new cN(n))):Ct(t,(I1(),uB),new cN(1))}function Tpe(t,e){var n;switch(n=t.g,e.g){case 1:return-(t.k.b+t.n.b);case 2:return t.k.a-n.n.a;case 3:return t.k.b-n.n.b;case 4:return-(t.k.a+t.n.a)}return 0}function Hut(t,e,n,i){var r,c,l;if(t.a[e.o]==-1)for(t.a[e.o]=n,t.b[e.o]=i,c=Rn(br(e));Jn(c);)r=a(In(c),14),!ec(r)&&(l=r.d.g,Hut(t,l,n+1,i))}function Cpe(t){switch(lD(),t.q.g){case 5:x9t(t,(Ht(),Tn)),x9t(t,fi);break;case 4:hDt(t,(Ht(),Tn)),hDt(t,fi);break;default:X7t(t,(Ht(),Tn)),X7t(t,fi)}}function Ape(t){switch(lD(),t.q.g){case 5:R9t(t,(Ht(),Qe)),R9t(t,on);break;case 4:cRt(t,(Ht(),Qe)),cRt(t,on);break;default:Z7t(t,(Ht(),Qe)),Z7t(t,on)}}function wl(t){var e;return!(t.Bb&1)&&t.r&&t.r.Eg()&&(e=a(t.r,42),t.r=a(O1(t,e),133),t.r!=e&&t.Db&4&&!(t.Db&1)&&Bi(t,new fs(t,9,8,e,t.r))),t.r}function jC(t,e,n){var i,r;i=e*n,ct(t.g,153)?(r=T2(t),r.f.d?r.f.a||(t.d.a+=i+yd):(t.d.d-=i+yd,t.d.a+=i+yd)):ct(t.g,8)&&(t.d.d-=i,t.d.a+=2*i)}function jRt(){D7(),this.c=new Nt,this.i=new Nt,this.e=new qa,this.f=new qa,this.g=new qa,this.j=new Nt,this.a=new Nt,this.b=(ts(),new vi),this.k=new vi}function kpe(t,e){var n,i,r,c;for(di(e,"Dull edge routing",1),c=qn(t.b,0);c.b!=c.d.c;)for(r=a(Yn(c),76),i=qn(r.d,0);i.b!=i.d.c;)n=a(Yn(i),170),ld(n.a)}function Jq(t,e,n){var i;return i=Y(Z(Os,1),Xo,22,15,[llt(t,(Ch(),lc),e,n),llt(t,ta,e,n),llt(t,hc,e,n)]),t.f&&(i[0]=y.Math.max(i[0],i[2]),i[2]=i[0]),i}function Lpe(){H7();var t,e;try{if(e=a(tlt((w1(),Nl),bE),1698),e)return e}catch(n){if(n=vr(n),ct(n,104))t=n,Hst((Kn(),t));else throw K(n)}return new Lg}function Ppe(){H7();var t,e;try{if(e=a(tlt((w1(),Nl),xl),1635),e)return e}catch(n){if(n=vr(n),ct(n,104))t=n,Hst((Kn(),t));else throw K(n)}return new BR}function Ipe(){I5t();var t,e;try{if(e=a(tlt((w1(),Nl),g0),1710),e)return e}catch(n){if(n=vr(n),ct(n,104))t=n,Hst((Kn(),t));else throw K(n)}return new VS}function Gut(t,e){var n,i;return t.Db>>16==11?t.Cb.Cg(t,10,zr,e):(i=jo(a(Ve((n=a(an(t,16),24),n||(Ic(),Dvt)),t.Db>>16),17)),t.Cb.Cg(t,i.n,i.f,e))}function HRt(t,e){var n,i;return t.Db>>16==10?t.Cb.Cg(t,11,Dl,e):(i=jo(a(Ve((n=a(an(t,16),24),n||(ye(),T0)),t.Db>>16),17)),t.Cb.Cg(t,i.n,i.f,e))}function GRt(t,e){var n,i;return t.Db>>16==10?t.Cb.Cg(t,12,ph,e):(i=jo(a(Ve((n=a(an(t,16),24),n||(ye(),Bw)),t.Db>>16),17)),t.Cb.Cg(t,i.n,i.f,e))}function Rpe(t,e){var n,i,r,c,l;if(e)for(r=e.a.length,n=new Fg(r),l=(n.b-n.a)*n.c<0?(v1(),lg):new y1(n);l.hc();)c=a(l.ic(),21),i=TM(e,c.a),i&&Q9t(t,i)}function Dpe(){$it();var t,e;for(o3e((S1(),Ae)),Qxe(Ae),Kq(Ae),Zvt=(ye(),Hf),e=new H(r_t);e.a>19,b=e.h>>19,g!=b?b-g:(r=t.h,f=e.h,r!=f?r-f:(i=t.m,l=e.m,i!=l?i-l:(n=t.l,c=e.l,n-c)))}function Npe(t,e){var n,i,r;if(i=t.b.d.d,t.a||(i+=t.b.d.a),r=e.b.d.d,e.a||(r+=e.b.d.a),n=ro(i,r),n==0){if(!t.a&&e.a)return-1;if(!e.a&&t.a)return 1}return n}function Ope(t,e){var n,i,r;if(i=t.b.g.d,t.a||(i+=t.b.g.a),r=e.b.g.d,e.a||(r+=e.b.g.a),n=ro(i,r),n==0){if(!t.a&&e.a)return-1;if(!e.a&&t.a)return 1}return n}function Bpe(t,e,n,i){var r,c,l,f;for(r=0;rl&&(f=l/i),r>c&&(g=c/r),hl(t,y.Math.min(f,g)),t}function Upe(t,e,n){var i,r;return r=t.e,t.e=e,t.Db&4&&!(t.Db&1)&&(i=new fs(t,1,4,r,e),n?n.Sh(i):n=i),r!=e&&(e?n=iE(t,P7(t,e),n):n=iE(t,t.a,n)),n}function qRt(){N9.call(this),this.e=-1,this.a=!1,this.p=Vs,this.k=-1,this.c=-1,this.b=-1,this.g=!1,this.f=-1,this.j=-1,this.n=-1,this.i=-1,this.d=-1,this.o=Vs}function zpe(t,e){var n,i;for(i=new H(e);i.a=0?(n=lP(t,tO),i=eP(t,tO)):(e=Gv(t,1),n=lP(e,5e8),i=eP(e,5e8),i=so(Yd(i,1),ns(t,1))),Xh(Yd(i,32),ns(n,uo))}function p7(){p7=P,sgt=(B7(),PK),rgt=new bn(gft,sgt),igt=(xN(),LK),ngt=new bn(mft,igt),egt=(o7(),kK),tgt=new bn(bft,egt),Q1t=new bn(wft,(me(),me(),!0))}function Qq(t,e){if(e==t.c.g)return t.d.g;if(e==t.d.g)return t.c.g;throw K(new yn("'node' must either be the source node or target node of the edge."))}function Wpe(t,e,n){var i,r;for(di(n,"Interactive node placement",1),t.a=a(z(e,(Ft(),ww)),266),r=new H(e.b);r.a0&&(l=(c&qi)%t.d.length,r=klt(t,l,c,e),r)?(f=r.mc(n),f):(i=t.Ii(c,e,n),t.c.nc(i),null)}function Xut(t,e){var n,i,r,c;switch(jp(t,e).lk()){case 3:case 2:{for(n=S_(e),r=0,c=n.i;r=0;i--)if(le(t[i].d,e)||le(t[i].d,n)){t.length>=i+1&&t.splice(0,i+1);break}return t}function Zut(t,e,n){this.b=new pD,this.i=new Nt,this.d=new $a(this),this.g=t,this.a=e.c.length,this.c=e,this.e=a(Ee(this.c,this.c.c.length-1),8),this.f=n,I_e(this)}function JRt(){this.a=new vz,this.g=new fD,this.j=new fD,this.b=(ts(),new vi),this.d=new fD,this.i=new fD,this.k=new vi,this.c=new vi,this.e=new vi,this.f=new vi}function Qpe(t){var e,n,i,r,c;for(i=new Vg(new xp(t.b).a);i.b;)n=xm(i),e=a(n.kc(),8),c=a(a(n.lc(),48).a,8),r=a(a(n.lc(),48).b,9),sr(Gh(e.k),sr(Xc(c.k),r))}function GC(){GC=P,lJ=new F5("MEDIAN_LAYER",0),hJ=new F5("WIDEST_LAYER",1),aJ=new F5("CENTER_LAYER",2),A0t=new F5("TAIL_LAYER",3),uJ=new F5("HEAD_LAYER",4)}function t1e(t){var e,n,i;for(n=new H(t.p);n.an);return r}function Kut(t,e,n){switch(e){case 1:!t.n&&(t.n=new Wt(ic,t,1,7)),Dr(t.n),!t.n&&(t.n=new Wt(ic,t,1,7)),Lr(t.n,a(n,13));return;case 2:zL(t,hi(n));return}Pat(t,e,n)}function Jut(t,e,n){switch(e){case 3:n_(t,lt(Yt(n)));return;case 4:i_(t,lt(Yt(n)));return;case 5:th(t,lt(Yt(n)));return;case 6:eh(t,lt(Yt(n)));return}Kut(t,e,n)}function m7(t,e,n){var i,r,c;c=(i=new IG,i),r=W1(c,e,null),r&&r.Th(),kh(c,n),ni((!t.c&&(t.c=new Wt(Nw,t,12,10)),t.c),c),r_(c,0),IM(c,1),u_(c,!0),a_(c,!0)}function Qut(t){var e;return t.Db&64?e7(t):(e=new ul(e7(t)),e.a+=" (abstract: ",Cp(e,(t.Bb&256)!=0),e.a+=", interface: ",Cp(e,(t.Bb&512)!=0),e.a+=")",e.a)}function tlt(t,e){var n,i,r;return n=AT(t.e,e),ct(n,207)?(r=a(n,207),r.gh()==null,r.dh()):ct(n,456)?(i=a(n,1631),r=i.b,r):null}function n8t(t,e){var n;if(this.f=t,this.b=this.f.c,n=t.d,rV(e,n),e>=(n/2|0))for(this.e=t.e,this.d=n;e++0;)ZAt(this);this.a=null}function i8t(t,e,n,i,r,c,l){var f,g,b,v,M;if(v=r[c],b=c==l-1,f=b?i:0,M=ARt(f,v),i!=10&&Y(Z(t,l-c),e[c],n[c],f,M),!b)for(++c,g=0;g0&&bo(t,t.length-1)==33)try{return e=E9t($h(t,0,t.length-1)),e.e==null}catch(n){if(n=vr(n),!ct(n,30))throw K(n)}return!1}function h1e(t,e,n){var i,r,c,l;for(n=B2(e,t.e,-1-t.c,n),l=Iot(t.a),c=(i=new Vg(new xp(l.a).a),new uT(i));c.a.b;)r=a(xm(c.a).kc(),84),n=iE(r,P7(r,t.a),n);return n}function f1e(t,e,n){var i,r,c,l;for(n=KD(e,t.e,-1-t.c,n),l=Iot(t.a),c=(i=new Vg(new xp(l.a).a),new uT(i));c.a.b;)r=a(xm(c.a).kc(),84),n=iE(r,P7(r,t.a),n);return n}function r8t(t){var e,n,i;if(t==null)return null;if(n=a(t,15),n.Wb())return"";for(i=new Sp,e=n.tc();e.hc();)mo(i,(fr(),hi(e.ic()))),i.a+=" ";return I9(i,i.a.length-1)}function s8t(t){var e,n,i;if(t==null)return null;if(n=a(t,15),n.Wb())return"";for(i=new Sp,e=n.tc();e.hc();)mo(i,(fr(),hi(e.ic()))),i.a+=" ";return I9(i,i.a.length-1)}function d1e(t,e){YM();var n,i;for(i=($1(),YO),n=t;e>1;e>>=1)e&1&&(i=Kv(i,n)),n.d==1?n=Kv(n,n):n=new XIt(yNt(n.a,n.d,dt(Gn,pi,22,n.d<<1,15,1)));return i=Kv(i,n),i}function VC(t,e){return t.b.a=y.Math.min(t.b.a,e.c),t.b.b=y.Math.min(t.b.b,e.d),t.a.a=y.Math.max(t.a.a,e.c),t.a.b=y.Math.max(t.a.b,e.d),t.c[t.c.length]=e,!0}function p1e(t){var e,n,i,r;for(r=-1,i=0,n=new H(t);n.a=0&&le(t.substr(e,3),"GMT")||e>=0&&le(t.substr(e,3),"UTC"))&&(n[0]=e+3),yht(t,n,i)}function rlt(){rlt=P;var t,e,n,i;for(j1t=dt(Os,Xo,22,25,15,1),H1t=dt(Os,Xo,22,33,15,1),i=152587890625e-16,e=32;e>=0;e--)H1t[e]=i,i*=.5;for(n=1,t=24;t>=0;t--)j1t[t]=n,n*=.5}function h8t(t,e,n){var i,r;switch(i=(Hn(e.b!=0),a(Ql(e,e.a.a),9)),n.g){case 0:i.b=0;break;case 2:i.b=t.f;break;case 3:i.a=0;break;default:i.a=t.g}return r=qn(e,0),gM(r,i),e}function v7(){v7=P,XJ=new RT(RBt,0),vbt=new RT("LONGEST_PATH",1),qJ=new RT("COFFMAN_GRAHAM",2),wbt=new RT(sY,3),_bt=new RT("STRETCH_WIDTH",4),YB=new RT("MIN_WIDTH",5)}function R1e(t,e){var n,i,r,c;for(n=0,i=0,c=new H(e.b);c.an;c--)t[c]|=e[c-n-1]>>>l,t[c-1]=e[c-n-1]<=t.f)break;c.c[c.c.length]=n}return c}function F1e(t,e,n){var i,r,c;return c=0,i=n[e],e>4&15,c=t[i]&15,l[r++]=Ovt[n],l[r++]=Ovt[c];return ml(l,0,l.length)}function p8t(t,e,n){var i,r,c,l,f;for(i=n._b(),ZIt(t,t.i+i),f=t.i-e,f>0&&Aa(t.g,e,t.g,e+i,f),l=n.tc(),t.i+=i,r=0;r=ao?(e=jP+(t-ao>>10&1023)&qr,n=56320+(t-ao&1023)&qr,String.fromCharCode(e)+(""+String.fromCharCode(n))):String.fromCharCode(t&qr)}function $1e(t){var e,n,i;for(i=t.e.c.length,t.a=Gb(Gn,[wt,pi],[37,22],15,[i,i],2),n=new H(t.c);n.a0&&DRt(this,this.c-1,(Ht(),Qe)),this.c1&&(e.c[e.c.length]=c))}function q1e(t){var e,n,i;for(n=new $n((!t.a&&(t.a=new Wt(zr,t,10,11)),t.a));n.e!=n.i._b();)if(e=a(ci(n),35),i=xP(e),!Jn((Ao(),new $d(id(Zd(i.a,new X))))))return e;return null}function g8t(t,e,n){var i,r;for(r=new $n((!t.a&&(t.a=new Wt(zr,t,10,11)),t.a));r.e!=r.i._b();)i=a(ci(r),35),Wd(i,i.i+e,i.j+n);vo((!t.b&&(t.b=new Wt(Xs,t,12,3)),t.b),new GMt(e,n))}function m8t(t,e,n,i,r){var c,l,f;for(c=$Dt(t,e,n,i,r),f=!1;!c;)A7(t,r,!0),f=!0,c=$Dt(t,e,n,i,r);f&&A7(t,r,!1),l=FN(r),l.c.length!=0&&(t.d&&t.d.If(l),m8t(t,r,n,i,l))}function ult(t,e){var n;n=Zc((w1(),Nl),t),ct(n,456)?tc(Nl,t,new lEt(this,e)):tc(Nl,t,this),glt(this,e),e==(Z3(),Xvt)?(this.wb=a(this,1633),a(e,1635)):this.wb=(S1(),Ae)}function X1e(t){var e,n,i;if(t==null)return null;for(e=null,n=0;n0;){if(n=i,i=(i-1)/2|0,t.a.Ld(Ee(t.b,i),e)<=0)return Kl(t.b,n,e),!0;Kl(t.b,n,Ee(t.b,i))}return Kl(t.b,i,e),!0}function Q1e(t){for(var e,n,i,r;t.o.a.c.length!=0;)n=a(Bat(t.o),48),i=a(n.a,113),e=a(n.b,189),r=KN(e,i),e.e==i?(cD(r.g,e),i.e=r.e+e.a):(cD(r.b,e),i.e=r.e-e.a),Ut(t.e.a,i)}function llt(t,e,n,i){var r,c;if(r=0,n)r=HN(t.a[n.g][e.g],i);else for(c=0;cNZ)return _8t(n);if(i=n,n==t)throw K(new yc("There is a cycle in the containment hierarchy of "+t))}return i}function y8t(){y8t=P,Ozt=Y(Z(At,1),wt,2,6,["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]),Bzt=Y(Z(At,1),wt,2,6,["Jan","Feb","Mar","Apr",K2,"Jun","Jul","Aug","Sep","Oct","Nov","Dec"])}function ege(t,e,n,i){var r,c;for(c=e,r=c.d==null||t.a.Ld(n.d,c.d)>0?1:0;c.a[r]!=n;)c=c.a[r],r=t.a.Ld(n.d,c.d)>0?1:0;c.a[r]=i,i.b=n.b,i.a[0]=n.a[0],i.a[1]=n.a[1],n.a[0]=null,n.a[1]=null}function Mo(){Mo=P,Of=new O5("P1_CYCLE_BREAKING",0),fx=new O5("P2_LAYERING",1),aa=new O5("P3_NODE_ORDERING",2),ua=new O5("P4_NODE_PLACEMENT",3),Yo=new O5("P5_EDGE_ROUTING",4)}function x8t(t){var e,n;return n=y.Math.sqrt(t.f*(t.i==null&&(t.i=gat(t,new Wo)),lt(t.i))/(t.b*(t.g==null&&(t.g=bPt(t,new Wa)),lt(t.g)))),e=or(Ka(y.Math.round(n))),e=rm(e,t.f),e}function M8t(t){var e,n;n=t.k,e=sr(new We(n.a,n.b),t.n),this.d=y.Math.min(n.b,e.b),this.a=y.Math.max(n.b,e.b),this.b=y.Math.min(n.a,e.a),this.c=y.Math.max(n.a,e.a)}function nge(t){var e,n;if(t.a>=t.c.c.length)return bM(),I4;if(n=G(t),t.a>=t.c.c.length)return new s2(n);e=new qa,Ir(e,si(n));do Ir(e,si(G(t)));while(t.a0&&ANt((mi(0,n.c.length),a(n.c[0],26)),t),n.c.length>1&&ANt(a(Ee(n,n.c.length-1),26),t),Vn(e)}function sge(t,e,n,i){var r,c,l,f,g;return l=NRt(t.a,e,n),f=a(l.a,21).a,c=a(l.b,21).a,i&&(g=a(z(e,(Ft(),Ru)),8),r=a(z(n,Ru),8),g&&r&&(hkt(t.b,g,r),f+=t.b.i,c+=t.b.e)),f>c}function S8t(t,e){var n,i,r;if(flt(t,e))return!0;for(i=new H(e);i.ac&&Are(b,rLt(n[f],F1t))&&(r=f,c=g);return r>=0&&(i[0]=e+c),r}function y7(t,e){var n,i,r;if(r=0,i=e[0],i>=t.length)return-1;for(n=t.charCodeAt(i);n>=48&&n<=57&&(r=r*10+(n-48),++i,!(i>=t.length));)n=t.charCodeAt(i);return i>e[0]?e[0]=i:r=-1,r}function age(t,e){var n,i,r;return i=(zC(),b6),r=y.Math.abs(t.b),n=y.Math.abs(e.f-t.b),nZW(t.d).c?(t.i+=t.g.c,kq(t.d)):ZW(t.d).c>ZW(t.g).c?(t.e+=t.d.c,kq(t.g)):(t.i+=bCt(t.g),t.e+=bCt(t.d),kq(t.g),kq(t.d))}function ZM(){ZM=P,j4=new IT(Fm,0),V0t=new IT(lE,1),Z0t=new IT(hE,2),X0t=new IT("LEFT_RIGHT_CONSTRAINT_LOCKING",3),q0t=new IT("LEFT_RIGHT_CONNECTION_LOCKING",4),$0t=new IT(xBt,5)}function hge(t){var e,n,i,r,c,l;for(i=TNt(VX(t)),e=is,c=0,r=0;e>.5&&c<50;)r=wDt(i),n=j2(i,r,!0),e=y.Math.abs(n.b),++c;return l=Yt(j1(fl(t.g),fl(t.g).b-1)),j2(t,(En(l),l-r),!1)}function fge(t){var e,n,i,r,c,l;for(i=TNt(VX(t)),e=is,c=0,r=0;e>.5&&c<50;)r=bDt(i),n=j2(i,r,!0),e=y.Math.abs(n.a),++c;return l=Yt(j1(fl(t.g),fl(t.g).b-1)),j2(t,(En(l),l-r),!1)}function A8t(t,e,n,i){t.a.d=y.Math.min(e,n),t.a.a=y.Math.max(e,i)-t.a.d,ef&&(g=f/i),r>c&&(b=c/r),l=y.Math.min(g,b),t.a+=l*(e.a-t.a),t.b+=l*(e.b-t.b)}function mge(t,e){dD();var n,i,r,c;if(e.b<2)return!1;for(c=qn(e,0),n=a(Yn(c),9),i=n;c.b!=c.d.c;){if(r=a(Yn(c),9),pDt(t,i,r))return!0;i=r}return!!pDt(t,i,n)}function plt(t,e,n,i){var r,c;return n==0?(!t.o&&(t.o=new lu((Ic(),pp),ag,t,0)),_D(t.o,e,i)):(c=a(Ve((r=a(an(t,16),24),r||t.Rg()),n),61),c.aj().ej(t,ra(t),n-ei(t.Rg()),e,i))}function bge(t,e){var n;e!=t.a?(n=null,t.a&&(n=a(t.a,42).Cg(t,4,of,null)),e&&(n=a(e,42).Ag(t,4,of,n)),n=jat(t,e,n),n&&n.Th()):t.Db&4&&!(t.Db&1)&&Bi(t,new fs(t,1,1,e,e))}function P8t(t){var e;return t.Db&64?cX(t):(e=new ll(xpt),!t.a||Ii(Ii((e.a+=' "',e),t.a),'"'),Ii(om(Ii(om(Ii(om(Ii(om((e.a+=" (",e),t.i),","),t.j)," | "),t.g),","),t.f),")"),e.a)}function wge(t){var e,n,i,r,c,l,f,g,b;return b=slt(t),n=t.e,c=n!=null,c&&YT(b,TO,t.e),f=t.k,l=!!f,l&&YT(b,"type",Q5(t.k)),i=P9(t.j),r=!i,r&&(g=new Ig,L1(b,XY,g),e=new pG(g),vo(t.j,e)),b}function vge(t,e){var n;if(e!=null&&!t.c.jj().Li(e))throw n=ct(e,51)?a(e,51).mg().zb:Ng(fu(e)),K(new dT(U_+t.c.be()+"'s type '"+t.c.jj().be()+"' does not permit a value of type '"+n+"'"))}function _ge(t,e){var n,i,r,c;if(En(e),c=t.a._b(),c>22-e,r=t.h<>22-e):e<44?(n=0,i=t.l<>44-e):(n=0,i=0,r=t.l<>>r|n[l+i+1]<>>r,++l}return c}function R8t(t){Aut();var e,n,i,r;return i=a(z(t,(qt(),HB)),318),r=lt(de(z(t,UJ)))||zt(z(t,IE))===zt((C2(),x6)),e=a(z(t,Dmt),21).a,n=t.a.c.length,!r&&i!=(RM(),IB)&&(e==0||e>n)}function Ege(t,e,n){var i,r;for(r=new Gs(t.b,0);r.b=l)return rn.a._b()?a(Ee(i,r-n.a._b()-1),8):null;return null}function glt(t,e){var n;e!=t.sb?(n=null,t.sb&&(n=a(t.sb,42).Cg(t,1,xA,null)),e&&(n=a(e,42).Ag(t,1,xA,n)),n=Gat(t,e,n),n&&n.Th()):t.Db&4&&!(t.Db&1)&&Bi(t,new fs(t,1,4,e,e))}function Cge(t,e,n){var i,r,c,l,f;if(n)for(r=n.a.length,i=new Fg(r),f=(i.b-i.a)*i.c<0?(v1(),lg):new y1(i);f.hc();)l=a(f.ic(),21),c=TM(n,l.a),Apt in c.a||XY in c.a?Ywe(t,c,e):e3e(t,c,e)}function N8t(t){switch(t.g){case 0:return new BG((Mm(),eF));case 1:return new QS;default:throw K(new yn("No implementation is available for the crossing minimizer "+(t.f!=null?t.f:""+t.g)))}}function Age(t){sht();var e,n,i,r,c;if(t==null)return null;for(i=t.length,r=i*2,e=dt(el,Pf,22,r,15,1),n=0;n>4],e[n*2+1]=JF[c&15];return ml(e,0,e.length)}function Eo(){ep(),_st.call(this),this.i=(Ht(),Wc),this.a=new go,new git,this.e=(Ah(2,Y2),new Vu(2)),this.d=(Ah(4,Y2),new Vu(4)),this.f=(Ah(4,Y2),new Vu(4)),this.c=new gMt(this.d,this.f)}function kge(t,e){var n,i;return!(lt(de(z(e,(Ft(),tg))))||t==(bl(),P6)&&(i=e.c.g,i.j==(Ke(),bu)||(n=a(z(i,(qt(),la)),178),n==vw)))}function Lge(t,e){var n,i;return!(lt(de(z(e,(Ft(),tg))))||t==(bl(),W4)&&(i=e.d.g,i.j==(Ke(),bu)||(n=a(z(i,(qt(),la)),178),n==Xm)))}function Pge(t,e){var n,i,r;n=ire(e,t.e),i=a(zi(t.g.f,n),21).a,r=t.a.c.length-1,t.a.c.length!=0&&a(Ee(t.a,r),269).c==i?(++a(Ee(t.a,r),269).a,++a(Ee(t.a,r),269).b):Ut(t.a,new ISt(i))}function O8t(t,e,n,i,r){if(ii&&(t.a=i),t.br&&(t.b=r),t}function Ige(t){if(ct(t,180))return Tbe(a(t,180));if(ct(t,199))return ufe(a(t,199));if(ct(t,27))return wge(a(t,27));throw K(new yn(Npt+Gp(new zu(Y(Z(un,1),te,1,5,[t])))))}function Ja(t,e){switch(e.g){case 1:return Xd(t.i,(ep(),zgt));case 2:return Xd(t.i,(ep(),Ugt));case 3:return Xd(t.i,(ep(),jgt));case 4:return Xd(t.i,(ep(),Hgt));default:return we(),we(),fo}}function B8t(t){var e;this.a=t,e=(Ke(),Y(Z(qK,1),jt,232,0,[gs,Hr,rs,uc,bu,Jc,ef])).length,this.b=Gb(ywt,[wt,DBt],[616,166],0,[e,e],2),this.c=Gb(ywt,[wt,DBt],[616,166],0,[e,e],2),U_e(this)}function Rge(t){var e,n;return n=a(z(t,(Ft(),Qc)),19),e=new as,(n.pc((So(),X_))||lt(de(z(t,(qt(),I6)))))&&(pa(e,$Wt),n.pc(Z_)&&pa(e,VWt)),n.pc(AE)&&pa(e,GWt),n.pc(kE)&&pa(e,WWt),e}function F8t(t,e,n){var i,r,c,l;if(e.b!=0){for(i=new Fr,l=qn(e,0);l.b!=l.d.c;)c=a(Yn(l),76),yo(i,xat(c)),r=c.e,r.a=a(z(c,(mc(),fQ)),21).a,r.b=a(z(c,Wbt),21).a;F8t(t,i,Ta(n,i.b/t.a|0))}}function pP(t){var e,n,i;for(i=new Va,Xi(i,new We(t.j,t.k)),n=new $n((!t.a&&(t.a=new Ss(sf,t,5)),t.a));n.e!=n.i._b();)e=a(ci(n),531),Xi(i,new We(e.a,e.b));return Xi(i,new We(t.b,t.c)),i}function Dge(t,e,n,i,r){var c,l,f,g,b,v;if(r)for(g=r.a.length,c=new Fg(g),v=(c.b-c.a)*c.c<0?(v1(),lg):new y1(c);v.hc();)b=a(v.ic(),21),f=TM(r,b.a),l=new x4t(t,e,n,i),Dve(l.a,l.b,l.c,l.d,f)}function v_(t){Hb();var e,n,i;for(i=new qa,$L(i,t),n=i.a.Xb().tc();n.hc();)e=n.ic(),si(e);switch(i.a._b()){case 0:return bM(),I4;case 1:return new s2(i.a.Xb().tc().ic());default:return new KG(i)}}function mlt(t,e){var n,i,r;for(r=qi,i=new H(l_(e));i.a1&&(t.e.b+=t.a)):(t.e.a+=n.a,t.e.b=y.Math.max(t.e.b,n.b),t.d.c.length>1&&(t.e.a+=t.a))}function U8t(t,e,n){var i,r,c,l;if(c=a(an(t.a,8),1629),c!=null)for(i=0,r=c.length;i1)throw K(new yn("In straight spline segments there may be only one edge."));i=t.a.c,n=t.a.c+t.a.b,Xi(a(e.a.Xb().tc().ic(),14).a,new We(i+(n-i)/2,t.b))}function z8t(t,e,n,i){var r;this.b=i,this.e=t==(Mm(),tA),r=e[n],this.d=Gb(Ol,[wt,c0],[221,22],16,[r.length,r.length],2),this.a=Gb(Gn,[wt,pi],[37,22],15,[r.length,r.length],2),this.c=new clt(e,n)}function uX(t){var e,n,i;if(t.a==null)for(t.a=dt(Ol,c0,22,t.c.b.c.length,16,1),t.a[0]=!1,i=new H(t.c.b),i.a>>e,r=t.m>>e|n<<22-e,i=t.l>>e|t.m<<22-e):e<44?(c=0,r=n>>>e-22,i=t.m>>e-22|t.h<<44-e):(c=0,r=0,i=n>>>e-44),ia(i&eu,r&eu,c&sp)}function H8t(t,e,n){var i,r,c,l,f;for(f=gu(t.e.mg(),e),r=a(t.g,124),i=0,l=0;ln?vlt(t,n,"start index"):e<0||e>n?vlt(e,n,"end index"):yP("end index (%s) must not be less than start index (%s)",Y(Z(un,1),te,1,5,[Xt(e),Xt(t)]))}function G8t(t,e){var n,i,r;if(e===t)return!0;if(!ct(e,109)||(r=a(e,109),t._b()!=r._b()))return!1;for(i=r.Tb().tc();i.hc();)if(n=a(i.ic(),38),!t.Wc(n))return!1;return!0}function W8t(t,e){var n,i,r,c;for(i=0,r=t.length;i0?f[l-1]:dt(Cl,Ih,8,0,0,1),r=f[l],b=l0&&Z8t(t,c,n));e.o=0}function Zge(t,e){var n,i,r;for(r=new H(e.f);r.ae)throw K(new yn("Top must be smaller or equal to bottom."));if(0>t)throw K(new yn("Left must be smaller or equal to right."));this.d=0,this.c=t,this.a=e,this.b=0}function K8t(t,e){var n,i,r;if(e.c.length!=0){for(n=S8t(t,e),r=!1;!n;)A7(t,e,!0),r=!0,n=S8t(t,e);r&&A7(t,e,!1),i=FN(e),t.b&&t.b.If(i),t.a=B6t(t,(mi(0,e.c.length),a(e.c[0],35))),K8t(t,i)}}function De(t){var e;this.c=new Fr,this.f=t.e,this.e=t.d,this.i=t.g,this.d=t.c,this.b=t.b,this.k=t.j,this.a=t.a,t.i?this.j=t.i:this.j=(e=a(yu(Jp),10),new ja(e,a(cu(e,e.length),10),0)),this.g=t.f}function n0(){n0=P,xwt=new p2(nx,0),Ec=new p2("BOOLEAN",1),Pa=new p2("INT",2),X6=new p2("STRING",3),ha=new p2("DOUBLE",4),xs=new p2("ENUM",5),OE=new p2("ENUMSET",6),Ed=new p2("OBJECT",7)}function Qa(){Qa=P,c_t=Y(Z(At,1),wt,2,6,[Ypt,o6,BO,HUt,FO,rK,TO]),o_t=Y(Z(At,1),wt,2,6,[Ypt,"empty",o6,s6,"elementOnly"]),a_t=Y(Z(At,1),wt,2,6,[Ypt,"preserve","replace",Nh]),eo=new rCt}function rr(t,e){var n;return n=a(t.c.Vb(e),13),!n&&(n=t.Pc(e)),ct(n,196)?new Prt(t,e,a(n,196)):ct(n,60)?new qW(t,e,a(n,60)):ct(n,19)?new ast(t,e,a(n,19)):ct(n,15)?act(t,e,a(n,15),null):new EL(t,e,n,null)}function z(t,e){var n,i;return i=(!t.p&&(t.p=(ts(),new vi)),zi(t.p,e)),i??(n=e.Of(),ct(n,4)&&(n==null?(!t.p&&(t.p=(ts(),new vi)),AM(t.p,e)):(!t.p&&(t.p=(ts(),new vi)),wr(t.p,e,n))),n)}function Yge(t,e){var n,i,r,c;if(t.e.c.length==0)return null;for(c=new oM,i=new H(t.e);i.a=(r/2|0))for(this.e=i?i.c:null,this.d=r;n++0;)tct(this);this.b=e,this.a=null}function t0e(t){var e,n,i,r,c;return r=a(t.a,21).a,c=a(t.b,21).a,e=(r<0?-r:r)>(c<0?-c:c)?r<0?-r:r:c<0?-c:c,r<=0&&r==c?(n=0,i=c-1):r==-e&&c!=e?(n=c,i=r,c>=0&&++n):(n=-c,i=r),new zs(Xt(n),Xt(i))}function e0e(t,e){var n;return t.c.length==0?!1:(n=kIt((mi(0,t.c.length),a(t.c[0],14)).c.g),Mu(),n==(Qb(),ey)||n==ty?!0:hN(Vh(new gi(null,new Ei(t,16)),new E3),new IH(e)))}function _lt(t,e,n){var i,r,c;if(!t.b[e.g]){for(t.b[e.g]=!0,i=n,!n&&(i=new mN),Xi(i.b,e),c=t.a[e.g].tc();c.hc();)r=a(c.ic(),170),r.b!=e&&_lt(t,r.b,i),r.c!=e&&_lt(t,r.c,i),Xi(i.a,r);return i}return null}function n0e(t){switch(t.g){case 0:case 1:case 2:return Ht(),Tn;case 3:case 4:case 5:return Ht(),fi;case 6:case 7:case 8:return Ht(),on;case 9:case 10:case 11:return Ht(),Qe;default:return Ht(),Wc}}function i0e(t){var e,n,i,r;for(e=0,i=t.length,r=i-4,n=0;n0)try{r=Au(e,Vs,qi)}catch(c){throw c=vr(c),ct(c,118)?(i=c,K(new yN(i))):K(c)}return n=(!t.a&&(t.a=new M5(t)),t.a),r=0?a(at(n,r),51):null}function h0e(t,e,n,i){var r;return r=w_(t,n,Y(Z(At,1),wt,2,6,[TZ,CZ,AZ,kZ,LZ,PZ,IZ]),e),r<0&&(r=w_(t,n,Y(Z(At,1),wt,2,6,["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]),e)),r<0?!1:(i.d=r,!0)}function f0e(t,e,n,i){var r;return r=w_(t,n,Y(Z(At,1),wt,2,6,[TZ,CZ,AZ,kZ,LZ,PZ,IZ]),e),r<0&&(r=w_(t,n,Y(Z(At,1),wt,2,6,["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]),e)),r<0?!1:(i.d=r,!0)}function d0e(t){var e,n,i;for(Xme(t),i=new Nt,n=new H(t.a.a.b);n.a>1),Mlt(e,t,g,b,-r,c),Mlt(e,t,b,f,-r,c),c.Ld(t[b-1],t[b])<=0){for(;n=0?(e||(e=new mT,i>0&&mo(e,t.substr(0,i))),e.a+="\\",pM(e,n&qr)):e&&pM(e,n&qr);return e?e.a:t}function m0e(t,e,n){var i,r,c,l;c=t.c,l=t.d,r=(zo(Y(Z(ss,1),wt,9,0,[c.g.k,c.k,c.a])).b+zo(Y(Z(ss,1),wt,9,0,[l.g.k,l.k,l.a])).b)/2,c.i==(Ht(),Qe)?i=new We(e+c.g.c.c.a+n,r):i=new We(e-n,r),uD(t.a,0,i)}function r9t(t,e){var n,i;return sct(t.a),Wb(t.a,(AN(),pF),pF),Wb(t.a,NE,NE),i=new as,Ni(i,NE,(QN(),bQ)),zt(cn(e,(Kb(),_Q)))!==zt((ZL(),gF))&&Ni(i,NE,gQ),Ni(i,NE,mQ),DEt(t.a,i),n=Nht(t.a,e),n}function s9t(t){if(!t)return _f(),Azt;var e=t.valueOf?t.valueOf():t;if(e!==t){var n=xK[typeof e];return n?n(e):Hat(typeof e)}else return t instanceof Array||t instanceof y.Array?new C8(t):new tT(t)}function bP(t,e){var n;if(e<0)throw K(new v9("Negative exponent"));if(e==0)return YO;if(e==1||$at(t,YO)||$at(t,EE))return t;if(!U9t(t,0)){for(n=1;!U9t(t,n);)++n;return Kv(sfe(n*e),bP(gct(t,n),e))}return d1e(t,e)}function b0e(t,e){var n,i,r;return ct(e.g,8)&&a(e.g,8).j==(Ke(),rs)?is:(r=T2(e),r?y.Math.max(0,t.b/2-.5):(n=Zv(e),n?(i=lt(Yt(GM(n,(qt(),lp)))),y.Math.max(0,i/2-.5)):is))}function w0e(t,e){var n,i,r;return ct(e.g,8)&&a(e.g,8).j==(Ke(),rs)?is:(r=T2(e),r?y.Math.max(0,t.b/2-.5):(n=Zv(e),n?(i=lt(Yt(GM(n,(qt(),lp)))),y.Math.max(0,i/2-.5)):is))}function v0e(t,e){var n,i,r,c,l;if(!e.Wb()){if(r=a(e.cd(0),125),e._b()==1){EDt(t,r,r,1,0,e);return}for(n=1;nc.a&&!e&&(r.b=c.a),r.c=-(r.b-c.a)/2,n.g){case 1:r.d=-r.a;break;case 3:r.d=c.b}zX(i),jX(i)}function u9t(t,e,n){var i,r,c;switch(c=t.o,i=a(js(t.p,n),219),r=i.i,r.b=vP(i),r.a=wP(i),r.a=y.Math.max(r.a,c.b),r.a>c.b&&!e&&(r.a=c.b),r.d=-(r.a-c.b)/2,n.g){case 4:r.c=-r.b;break;case 2:r.c=c.a}zX(i),jX(i)}function YC(t,e){hNt(t,e),t.b&1&&(t.a.a=null),t.b&2&&(t.a.f=null),t.b&4&&(t.a.g=null,t.a.i=null),t.b&16&&(t.a.d=null,t.a.e=null),t.b&8&&(t.a.b=null),t.b&32&&(t.a.j=null,t.a.c=null)}function l9t(t){var e,n,i,r;if(n=a(t,42).Kg(),n)try{if(i=null,e=JM((w1(),Nl),INt(dfe(n))),e&&(r=e.Lg(),r&&(i=r.gk(hi(lt(n.e))))),i&&i!=t)return l9t(i)}catch(c){if(c=vr(c),!ct(c,54))throw K(c)}return t}function h9t(t,e){var n;e.d?e.d.b=e.b:t.a=e.b,e.b?e.b.d=e.d:t.e=e.d,!e.e&&!e.c?(n=a(AM(t.b,e.a),264),n.a=0,++t.c):(n=a(zi(t.b,e.a),264),--n.a,e.e?e.e.c=e.c:n.b=e.c,e.c?e.c.e=e.e:n.c=e.e),--t.d}function Slt(t){var e,n;return t>-0x800000000000&&t<0x800000000000?t==0?0:(e=t<0,e&&(t=-t),n=Tr(y.Math.floor(y.Math.log(t)/.6931471805599453)),(!e||t!=y.Math.pow(2,n))&&++n,n):hPt(Ka(t))}function f9t(t,e){var n,i,r,c,l,f;for(n=t.b.c.length,r=Ee(t.b,e);e*2+10)for(l=t.c.d,f=t.d.d,r=hl(za(new We(f.a,f.b),l),1/(i+1)),c=new We(l.a,l.b),n=new H(t.a);n.a0&&(l+=n,++e);e>1&&(l+=t.c*(e-1))}else l=e3t(vPt(mL(wo(_ot(t.a),new Dk),new vv)));return l>0?l+t.n.d+t.n.a:0}function vP(t){var e,n,i,r,c,l;if(l=0,t.b==0)l=e3t(vPt(mL(wo(_ot(t.a),new gz),new kg)));else{for(c=SRt(t,!0),e=0,i=0,r=c.length;i0&&(l+=n,++e);e>1&&(l+=t.c*(e-1))}return l>0?l+t.n.b+t.n.c:0}function x0e(t){var e,n;return n=-t.a,e=Y(Z(el,1),Pf,22,15,[43,48,48,48,48]),n<0&&(e[0]=45,n=-n),e[1]=e[1]+((n/60|0)/10|0)&qr,e[2]=e[2]+(n/60|0)%10&qr,e[3]=e[3]+(n%60/10|0)&qr,e[4]=e[4]+n%10&qr,ml(e,0,e.length)}function M0e(t){var e,n,i,r,c,l;for(l=zM(t.d,t.e),c=l.tc();c.hc();)for(r=a(c.ic(),11),i=t.e==(Ht(),on)?r.d:r.f,n=new H(i);n.a=0;c+=n?1:-1)l=l|e.c.qf(g,c,n,i),l=l|e.q.xf(g,c,n),l=l|LNt(t,g[c],n,i);return Ir(t.c,e),l}function g9t(t,e){var n,i,r,c,l,f;for(c=new H(t.b);c.a=0&&i0;){if(e=a(t.k.cd(t.n-1),75),n=e.nj(),ct(n,62)&&a(a(n,17),62).Bb&ca&&(!t.e||n.Vi()!=jE||n.pi()!=0)&&e.lc()!=null)return!0;--t.n}return!1}else return t.n>0}function Tlt(t,e){var n,i,r,c;if(Ci(t),t.c!=0||t.a!=123)throw K(new ri(ai((Kn(),ZFt))));if(c=e==112,i=t.d,n=cM(t.i,125,i),n<0)throw K(new ri(ai((Kn(),YFt))));return r=$h(t.i,i,n),t.d=n+1,R5t(r,c,(t.e&512)==512)}function T0e(t){var e,n;return n=-t.a,e=Y(Z(el,1),Pf,22,15,[43,48,48,58,48,48]),n<0&&(e[0]=45,n=-n),e[1]=e[1]+((n/60|0)/10|0)&qr,e[2]=e[2]+(n/60|0)%10&qr,e[4]=e[4]+(n%60/10|0)&qr,e[5]=e[5]+n%10&qr,ml(e,0,e.length)}function C0e(t){var e;return e=Y(Z(el,1),Pf,22,15,[71,77,84,45,48,48,58,48,48]),t<=0&&(e[3]=43,t=-t),e[4]=e[4]+((t/60|0)/10|0)&qr,e[5]=e[5]+(t/60|0)%10&qr,e[7]=e[7]+(t%60/10|0)&qr,e[8]=e[8]+t%10&qr,ml(e,0,e.length)}function w9t(t,e){var n,i,r;return i=new Jh(t),Uo(i,e),Ct(i,(Ft(),BB),e),Ct(i,(qt(),Qi),(Ls(),Gc)),Ct(i,Bf,(md(),vF)),jl(i,(Ke(),rs)),n=new Eo,ds(n,i),yr(n,(Ht(),on)),r=new Eo,ds(r,i),yr(r,Qe),i}function v9t(t,e){var n,i,r,c,l;for(t.c[e.o]=!0,Ut(t.a,e),l=new H(e.i);l.a0&&(r=n),l=new H(t.f.e);l.a=c)l.Pb();else for(r=l.tc(),i=0;i0?Tit():l<0&&Alt(t,e,-l),!0):!1}function I0e(t){var e,n,i,r,c,l,f,g,b,v;for(n=t.o,e=t.p,l=qi,r=Vs,f=qi,c=Vs,b=0;bb?r:b,f=fv?c:v);return g=r-l+1,i=c-f+1,new w4t(Xt(l),Xt(f),Xt(g),Xt(i))}function R0e(t,e){var n,i,r;return n=a(z(e,(Ph(),SE)),21).a-a(z(t,SE),21).a,n==0?(i=za(Xc(a(z(t,(I1(),v6)),9)),a(z(t,B4),9)),r=za(Xc(a(z(e,v6),9)),a(z(e,B4),9)),ro(i.a*i.b,r.a*r.b)):n}function D0e(t,e){var n,i,r;return n=a(z(e,(nw(),dF)),21).a-a(z(t,dF),21).a,n==0?(i=za(Xc(a(z(t,(mc(),V6)),9)),a(z(t,oA),9)),r=za(Xc(a(z(e,V6),9)),a(z(e,oA),9)),ro(i.a*i.b,r.a*r.b)):n}function N0e(t,e,n){var i,r,c,l,f,g;if(!t||t.c.length==0)return null;for(c=new Z4t(e,!n),r=new H(t);r.a0)switch(e.g){case 2:c.n.c=t.s;break;case 4:c.n.b=t.s}}function gX(t,e){var n,i,r;if(r=nE((Qa(),eo),t.mg(),e),r)return Jo(),a(r,61).bj()||(r=sC(qo(eo,r))),i=(n=t.rg(r),a(n>=0?t.ug(n,!0,!0):W2(t,r,!0),184)),a(i,237).wk(e);throw K(new yn(U_+e.be()+Spt))}function F0e(t,e,n){var i,r,c,l;return c=x7t(RV(),e),i=null,c&&(l=m7t(c,n),r=null,l!=null&&(r=(l==null?(!t.o&&(t.o=new lu((Ic(),pp),ag,t,0)),sP(t.o,c)):(!t.o&&(t.o=new lu((Ic(),pp),ag,t,0)),fP(t.o,c,l)),t)),i=r),i}function klt(t,e,n,i){var r,c,l,f,g;if(r=t.d[e],r){if(c=r.g,g=r.i,i!=null){for(f=0;f1||n==-1?(t.b=-1,!0):(e=wl(t),e&&(Jo(),e.Ri()==CUt)?(t.b=-1,!0):(t.b=1,!1));default:case 1:return!1}}function U0e(t,e){var n,i,r,c,l;for(i=(!e.s&&(e.s=new Wt(Ra,e,21,17)),e.s),c=null,r=0,l=i.i;rr)?(Hn(c.a!=null),a(c.a,8)):null}function G0e(t,e){Zl();var n,i,r,c,l,f;for(n=null,l=e.tc();l.hc();)c=a(l.ic(),125),!c.k&&(i=see(c.a),r=rre(c.a),f=new r4(i,r,null,a(c.d.a.Xb().tc().ic(),14)),Ut(f.c,c.a),t.c[t.c.length]=f,n&&Ut(n.d,f),n=f)}function W0e(t,e,n){var i,r,c,l,f,g;for(i=a(rr(t.c,e),15),r=a(rr(t.c,n),15),c=i.fd(i._b()),l=r.fd(r._b());c.Cc()&&l.Cc();)if(f=a(c.Ec(),21),g=a(l.Ec(),21),f!=g)return Lp(f.a,g.a);return!c.hc()&&!l.hc()?0:c.hc()?1:-1}function KC(t,e,n,i,r){var c,l,f,g;return g=VW(t,a(r,51)),zt(g)!==zt(r)?(f=a(t.g[n],75),c=A1(e,g),GT(t,n,rX(t,n,c)),Xl(t.e)&&(l=jg(t,9,c.nj(),r,g,i,!1),elt(l,new Qd(t.e,9,t.c,f,c,i,!1)),vV(l)),g):r}function $0e(t,e,n){var i,r,c,l;for(r=n,c=iTt(mL(a(a(rr(t.r,e),19),60).xc(),new Sb)),l=0;c.a||(c.a=Hv(c.c,c)),c.a;)if(r){uN(c),r=!1;continue}else i=uN(c),c.a||(c.a=Hv(c.c,c)),c.a&&(l=y.Math.max(l,i));return l}function cr(t,e,n){var i;if(i=a(t.c.Vb(e),13),i)return i.nc(n)?(++t.d,!0):!1;if(i=t.Pc(e),i.nc(n))return++t.d,t.c.Zb(e,i),!0;throw K(new Q$("New Collection violated the Collection spec"))}function V0e(t){var e,n,i,r,c,l;for(r=0,t.q=new Nt,e=new $r,l=new H(t.p);l.a>16),e=i>>16&16,n=16-e,t=t>>e,i=t-256,e=i>>16&8,n+=e,t<<=e,i=t-Bm,e=i>>16&4,n+=e,t<<=e,i=t-Lf,e=i>>16&2,n+=e,t<<=e,i=t>>14,e=i&~(i>>1),n+2-e)}function X0e(t,e,n,i){var r,c,l,f,g,b;for(r=0;r=0&&b>=0&&g=0?t.ug(i,!0,!0):W2(t,c,!0),184)),a(r,237).sk(e,n);throw K(new yn(U_+e.be()+Spt))}function S9t(t){var e,n;if(Gd(a(z(t,(qt(),Qi)),83)))for(n=new H(t.i);n.a>24;return l}function Q0e(t,e){var n,i,r,c,l;if(n=a(an(t.a,4),116),l=n==null?0:n.length,e>=l)throw K(new jv(e,l));return r=n[e],l==1?i=null:(i=dt(ntt,nK,380,l-1,0,1),Aa(n,0,i,0,e),c=l-e-1,c>0&&Aa(n,e+1,i,e,c)),cP(t,i),U8t(t,e,r),r}function tme(t,e){var n,i,r;if(zt(t)===zt(e))return!0;if(t==null||e==null||t.length!=e.length)return!1;for(n=0;n=null.tl()?(k7(t),Rlt(t)):e.hc()}function mX(t){var e,n;if(wm(t))throw K(new yn(BBt));for(n=qn(t,0);n.b!=n.d.c;)e=a(Yn(n),9),this.d=y.Math.min(this.d,e.b),this.c=y.Math.max(this.c,e.a),this.a=y.Math.max(this.a,e.b),this.b=y.Math.min(this.b,e.a)}function ime(t){var e,n;return e=new as,pa(e,l$t),n=a(z(t,(Ft(),Qc)),19),n.pc((So(),S6))&&pa(e,g$t),n.pc(AE)&&pa(e,h$t),(n.pc(X_)||lt(de(z(t,(qt(),I6)))))&&(pa(e,d$t),n.pc(Z_)&&pa(e,p$t)),n.pc(kE)&&pa(e,f$t),e}function bX(t){var e,n;if(e=hi(cn(t,(dr(),Lwt))),n=Qfe(RV(),e),!n)throw e==null||e.length==0?K(new k5("No layout algorithm has been specified ("+t+").")):K(new k5("Layout algorithm not found: "+e));return n}function $2(){$2=P,Bx=a(at(Et((Lit(),_c).qb),6),29),Ox=a(at(Et(_c.qb),3),29),att=a(at(Et(_c.qb),4),29),utt=a(at(Et(_c.qb),5),17),b7(Bx),b7(Ox),b7(att),b7(utt),tXt=new zu(Y(Z(Ra,1),j_,158,0,[Bx,Ox]))}function P9t(t){var e=(!_K&&(_K=Lxe()),_K),n=t.replace(/[\x00-\x1f\xad\u0600-\u0603\u06dd\u070f\u17b4\u17b5\u200b-\u200f\u2028-\u202e\u2060-\u2064\u206a-\u206f\ufeff\ufff9-\ufffb"\\]/g,function(i){return goe(i,e)});return'"'+n+'"'}function rme(t){var e,n,i,r,c,l;for(r=t.e.c.length,i=dt(Sl,uw,15,r,0,1),l=new H(t.e);l.a=0;)i=n[c],l.Bk(i.nj())&&ni(r,i);!Rxe(t,r)&&Xl(t.e)&&Wn(t,e.lj()?jg(t,6,e,(we(),fo),null,-1,!1):jg(t,e.Zi()?2:1,e,null,null,-1,!1))}function ume(t,e){var n,i,r,c,l;return t.a==(ZM(),j4)?!0:(c=e.a.c,n=e.a.c+e.a.b,!(e.i&&(i=e.u,l=i.c.c.a-i.n.a/2,r=c-(i.k.a+i.n.a),r>l)||e.n&&(i=e.v,l=i.c.c.a-i.n.a/2,r=i.k.a-n,r>l)))}function N9t(t,e,n){var i,r,c,l,f,g;for(i=0,g=n,e||(i=n*(t.c.length-1),g*=-1),c=new H(t);c.a1?t.e*=lt(t.a):t.f/=lt(t.a),uhe(t),jfe(t),Zwe(t),Ct(t.b,(FC(),rB),t.g)}function hme(t){S2();var e,n,i,r;for(sB=new Nt,OK=(ts(),new vi),NK=new Nt,e=(!t.a&&(t.a=new Wt(zr,t,10,11)),t.a),bxe(e),r=new $n(e);r.e!=r.i._b();)i=a(ci(r),35),nc(sB,i,0)==-1&&(n=new Nt,Ut(NK,n),KIt(i,n));return NK}function fme(t,e){var n,i,r,c,l,f,g;if(i=X6t(t.Db&254),i==1)t.Eb=null;else if(c=e_(t.Eb),i==2)r=Zq(t,e),t.Eb=c[r==0?1:0];else{for(l=dt(un,te,1,i-1,5,1),n=2,f=0,g=0;n<=128;n<<=1)n==e?++f:t.Db&n&&(l[g++]=c[f++]);t.Eb=l}t.Db&=~e}function F9t(t,e,n){var i,r,c;t.ti()?(c=t.ui(),JL(t,e,n),i=t.mi(3,null,n,e,c),t.qi()?(r=t.ri(n,null),t.xi()&&(r=t.yi(n,r)),r?(r.Sh(i),r.Th()):t.ni(i)):t.ni(i)):(JL(t,e,n),t.qi()&&(r=t.ri(n,null),r&&r.Th()))}function wX(t,e){var n,i,r,c;t.ti()?(n=t.i,c=t.ui(),ML(t,e),i=t.mi(3,null,e,n,c),t.qi()?(r=t.ri(e,null),t.xi()&&(r=t.yi(e,r)),r?(r.Sh(i),r.Th()):t.ni(i)):t.ni(i)):(ML(t,e),t.qi()&&(r=t.ri(e,null),r&&r.Th()))}function Olt(t,e){var n,i,r,c,l;if(e===t)return!0;if(!ct(e,15)||(l=a(e,15),t._b()!=l._b()))return!1;for(c=l.tc(),i=t.tc();i.hc();)if(n=i.ic(),r=c.ic(),!(zt(n)===zt(r)||n!=null&&Fi(n,r)))return!1;return!0}function U9t(t,e){var n,i,r;if(e==0)return(t.a[0]&1)!=0;if(e<0)throw K(new v9("Negative bit address"));if(r=e>>5,r>=t.d)return t.e<0;if(n=t.a[r],e=1<<(e&31),t.e<0){if(i=SPt(t),r=0?t.jg(null):t.yg().Cg(t,-1-e,null,null)),t.kg(a(r,42),n),i&&i.Th(),t.eg()&&t.fg()&&n>-1&&Bi(t,new fs(t,9,n,c,r)),r):c}function KM(){KM=P,ttt=new g2(MBt,0),zF=new g2("INSIDE_SELF_LOOPS",1),jF=new g2("MULTI_EDGES",2),UF=new g2("EDGE_LABELS",3),QQ=new g2("PORTS",4),FF=new g2("COMPOUND",5),BF=new g2("CLUSTERS",6),JQ=new g2("DISCONNECTED",7)}function z9t(t){var e,n;if(t.f){for(;t.n>16)),15).dd(c),f0&&(!(Bv(t.a.c)&&e.n.d)&&!(q5(t.a.c)&&e.n.b)&&(e.g.d+=y.Math.max(0,i/2-.5)),!(Bv(t.a.c)&&e.n.a)&&!(q5(t.a.c)&&e.n.c)&&(e.g.a-=i-1))}function V9t(t,e,n){var i,r,c,l,f,g;c=a(Ee(e.d,0),14).c,i=c.g,r=i.j,g=a(Ee(n.f,0),14).d,l=g.g,f=l.j,r==(Ke(),Hr)?Ct(t,(Ft(),Pu),a(z(i,Pu),11)):Ct(t,(Ft(),Pu),c),f==Hr?Ct(t,(Ft(),Iu),a(z(l,Iu),11)):Ct(t,(Ft(),Iu),g)}function _X(t){var e,n,i;if(t.length==0)throw K(new yn(BBt));for(n=0,i=t.length;n>e,c=t.m>>e|n<<22-e,r=t.l>>e|t.m<<22-e):e<44?(l=i?sp:0,c=n>>e-22,r=t.m>>e-22|n<<44-e):(l=i?sp:0,c=i?eu:0,r=n>>e-44),ia(r&eu,c&eu,l&sp)}function yX(t){var e,n,i,r,c,l;for(this.c=new Nt,this.d=t,i=is,r=is,e=Ps,n=Ps,l=qn(t,0);l.b!=l.d.c;)c=a(Yn(l),9),i=y.Math.min(i,c.a),r=y.Math.min(r,c.b),e=y.Math.max(e,c.a),n=y.Math.max(n,c.b);this.a=new qh(i,r,e-i,n-r)}function jlt(t){var e,n,i;this.c=t,i=a(z(t,(qt(),ch)),110),e=lt(Yt(z(t,zB))),n=lt(Yt(z(t,lbt))),i==(Js(),ah)||i==uh||i==Ff?this.b=e*n:this.b=1/(e*n),this.j=lt(Yt(z(t,Sw))),this.e=lt(Yt(z(t,lp))),this.f=t.b.c.length}function q9t(t){switch(t.g){case 0:return new yv;case 1:return new v8;case 2:return new p1;case 3:return new BMt;case 4:return new y4t;default:throw K(new yn("No implementation is available for the node placer "+(t.f!=null?t.f:""+t.g)))}}function nh(t){var e;return e=new ll(Ng(t.ql)),e.a+="@",Ii(e,(Yr(t)>>>0).toString(16)),t.Eg()?(e.a+=" (eProxyURI: ",Fa(e,t.Kg()),t.tg()&&(e.a+=" eClass: ",Fa(e,t.tg())),e.a+=")"):t.tg()&&(e.a+=" (eClass: ",Fa(e,t.tg()),e.a+=")"),e.a}function X9t(t,e){var n,i,r,c,l,f,g,b,v;if(t.a.f>0&&ct(e,38)&&(t.a.Fi(),b=a(e,38),g=b.kc(),c=g==null?0:Yr(g),l=pst(t.a,c),n=t.a.d[l],n)){for(i=a(n.g,339),v=n.i,f=0;f0&&r0):r<0&&-r0):!1}function S7(t,e,n,i,r){var c,l,f,g,b,v;for(c=i,b=a(a(rr(t.r,e),19),60).tc();b.hc();){if(g=a(b.ic(),111),c){c=!1;continue}l=0,r>0?l=r:g.c&&(l=CD(g.c)),l>0&&(n?(v=g.b.Re().a,l>v&&(f=(l-v)/2,g.d.b=f,g.d.c=f)):g.d.c=t.s+l)}}function Hlt(t,e,n){switch(e){case 7:!t.e&&(t.e=new pn(Xs,t,7,4)),Dr(t.e),!t.e&&(t.e=new pn(Xs,t,7,4)),Lr(t.e,a(n,13));return;case 8:!t.d&&(t.d=new pn(Xs,t,8,5)),Dr(t.d),!t.d&&(t.d=new pn(Xs,t,8,5)),Lr(t.d,a(n,13));return}Jut(t,e,n)}function _me(t){var e,n;if(t.c.length!=2)throw K(new yc("Order only allowed for two paths."));e=(mi(0,t.c.length),a(t.c[0],14)),n=(mi(1,t.c.length),a(t.c[1],14)),e.d.g!=n.c.g&&(t.c=dt(un,te,1,0,5,1),t.c[t.c.length]=n,t.c[t.c.length]=e)}function yme(t){var e,n,i,r;if(t==null)return null;if(i=Hc(t,!0),r=a6.length,le(i.substr(i.length-r,r),a6)){if(n=i.length,n==4){if(e=i.charCodeAt(0),e==43)return f_t;if(e==45)return mXt}else if(n==3)return f_t}return ew(i)}function xme(t,e,n){var i;i=null,e&&(i=e.d),VC(t,new rM(e.k.a-i.b+n.a,e.k.b-i.d+n.b)),VC(t,new rM(e.k.a-i.b+n.a,e.k.b+e.n.b+i.a+n.b)),VC(t,new rM(e.k.a+e.n.a+i.c+n.a,e.k.b-i.d+n.b)),VC(t,new rM(e.k.a+e.n.a+i.c+n.a,e.k.b+e.n.b+i.a+n.b))}function Mme(t,e){var n,i,r,c,l;for(di(e,"Port side processing",1),l=new H(t.a);l.ag-n&&f=t.c.a.length)return e;for(i=Fa(Ii(new im,"expected one element but was: <"),e),n=0;n<4&&t.a=0?t.Mg(c,n):Xlt(t,r,n);else throw K(new yn(U_+r.be()+zY));else throw K(new yn("The feature ID"+e+" is not a valid feature ID"));else Yu(t,i,r,n)}function xX(t,e,n,i,r){var c,l,f,g,b,v,M,k,R;return l=n-t,f=i-e,c=y.Math.atan2(l,f),g=c+JZ,b=c-JZ,v=r*y.Math.sin(g)+t,k=r*y.Math.cos(g)+e,M=r*y.Math.sin(b)+t,R=r*y.Math.cos(b)+e,$g(Y(Z(ss,1),wt,9,0,[new We(v,k),new We(M,R)]))}function eDt(t){var e,n,i,r,c,l,f;for(c=0,r=t.f.e,n=0;n=0)return r;for(c=1,f=new H(e.i);f.ag+1?c:g+1);return mfe(t,e,c),c}function i0(){i0=P,kl=new Dv("H_LEFT",0),Uf=new Dv("H_CENTER",1),Pl=new Dv("H_RIGHT",2),Bh=new Dv("V_TOP",3),hh=new Dv("V_CENTER",4),lh=new Dv("V_BOTTOM",5),Du=new Dv("INSIDE",6),Il=new Dv("OUTSIDE",7),Ll=new Dv("H_PRIORITY",8)}function cn(t,e){var n,i;return i=(!t.o&&(t.o=new lu((Ic(),pp),ag,t,0)),Lh(t.o,e)),i??(n=e.Of(),ct(n,4)&&(n==null?(!t.o&&(t.o=new lu((Ic(),pp),ag,t,0)),sP(t.o,e)):(!t.o&&(t.o=new lu((Ic(),pp),ag,t,0)),fP(t.o,e,n))),n)}function Pme(t){var e,n,i,r,c,l,f;if(e=t.Yg(xl),e&&(f=hi(Lh((!e.b&&(e.b=new xu((ye(),Ho),Dc,e)),e.b),"settingDelegates")),f!=null)){for(n=new Nt,r=V2(f,"\\w+"),c=0,l=r.length;c0?(e-=1,n-=1):i>=0&&r<0?(e+=1,n+=1):i>0&&r>=0?(e-=1,n+=1):(e+=1,n-=1),new zs(Xt(e),Xt(n))}function Glt(t,e,n){var i,r,c;if(e!=n){i=e;do sr(t,i.c),r=a(z(i,(Ft(),Q1)),8),r&&(c=i.d,Gu(t,c.b,c.d),sr(t,r.k),i=Mc(r));while(r);i=n;do za(t,i.c),r=a(z(i,(Ft(),Q1)),8),r&&(c=i.d,eL(t,c.b,c.d),za(t,r.k),i=Mc(r));while(r)}}function Dme(t,e,n){var i,r,c,l,f,g;i=new Nt,i.c[i.c.length]=e,g=e,f=0;do g=oxe(t,g),g&&(i.c[i.c.length]=g),++f;while(g);for(l=(n-(i.c.length-1)*t.d.d)/i.c.length,c=new H(i);c.ae.c?1:t.be.b?1:t.a!=e.a?Yr(t.a)-Yr(e.a):t.d==(uC(),nA)&&e.d==eA?-1:t.d==eA&&e.d==nA?1:0}function MX(t){var e,n,i,r,c,l,f,g;for(r=is,i=Ps,n=new H(t.e.b);n.a=0;e-=2)for(n=0;n<=e;n+=2)(t.b[n]>t.b[n+2]||t.b[n]===t.b[n+2]&&t.b[n+1]>t.b[n+3])&&(i=t.b[n+2],t.b[n+2]=t.b[n],t.b[n]=i,i=t.b[n+3],t.b[n+3]=t.b[n+1],t.b[n+1]=i);t.c=!0}}function oDt(t,e){var n,i,r,c,l,f,g,b;for(l=e==1?$K:WK,c=l.a.Xb().tc();c.hc();)for(r=a(c.ic(),110),g=a(rr(t.f.c,r),19).tc();g.hc();)switch(f=a(g.ic(),48),i=a(f.b,80),b=a(f.a,172),n=b.c,r.g){case 2:case 1:i.g.d+=n;break;case 4:case 3:i.g.c+=n}}function Vme(t){sht();var e,n,i,r,c,l,f;if(t==null||(r=t.length,r%2!=0))return null;for(e=_N(t),c=r/2|0,n=dt(Da,z_,22,c,15,1),i=0;i>24}return n}function JM(t,e){var n,i,r;return n=e==null?Ua(Ea(t.d,null)):AT(t.e,e),ct(n,207)?(r=a(n,207),r.gh()==null,r):ct(n,456)?(i=a(n,1631),r=i.a,r&&(r.yb==null||(e==null?Cu(t.d,null,r):Tm(t.e,e,r))),r):null}function qme(t,e){var n,i,r,c,l;if(i=e.nj(),Rm(t.e,i)){if(i.xh()&&pV(t,i,e.lc()))return!1}else for(l=gu(t.e.mg(),i),n=a(t.g,124),r=0;r0&&(!(Bv(t.a.c)&&e.n.d)&&!(q5(t.a.c)&&e.n.b)&&(e.g.d-=y.Math.max(0,i/2-.5)),!(Bv(t.a.c)&&e.n.a)&&!(q5(t.a.c)&&e.n.c)&&(e.g.a+=y.Math.max(0,i-1)))}function cDt(t,e,n){var i,r;if((t.c-t.b&t.a.length-1)==2)e==(Ht(),Tn)||e==Qe?(TN(a(EC(t),15),(Tu(),kd)),TN(a(EC(t),15),cg)):(TN(a(EC(t),15),(Tu(),cg)),TN(a(EC(t),15),kd));else for(r=new iC(t);r.a!=r.b;)i=a(GN(r),15),TN(i,n)}function aDt(t){var e,n,i,r,c,l,f;if(t&&(e=t.Yg(xl),e&&(l=hi(Lh((!e.b&&(e.b=new xu((ye(),Ho),Dc,e)),e.b),"conversionDelegates")),l!=null))){for(f=new Nt,i=V2(l,"\\w+"),r=0,c=i.length;r=2147483648&&(i-=OZ),i)}function uDt(t,e,n){var i,r,c,l;L4t(t,e)>L4t(t,n)?(i=ac(n,(Ht(),Qe)),t.d=i.Wb()?0:uL(a(i.cd(0),11)),l=ac(e,on),t.b=l.Wb()?0:uL(a(l.cd(0),11))):(r=ac(n,(Ht(),on)),t.d=r.Wb()?0:uL(a(r.cd(0),11)),c=ac(e,Qe),t.b=c.Wb()?0:uL(a(c.cd(0),11)))}function Zme(t){var e,n,i,r,c,l;if(r=a(Ee(t.i,0),11),r.d.c.length+r.f.c.length==0)t.k.a=0;else{for(l=0,i=Rn(Bp(new zd(r),new Tv(r)));Jn(i);)n=a(In(i),11),l+=n.g.k.a+n.k.a+n.a.a;e=a(z(t,(qt(),xw)),9),c=e?e.a:0,t.k.a=l/(r.d.c.length+r.f.c.length)-c}}function lDt(t){switch(t.g){case 0:return new JEt;case 1:return new m8;case 2:return new OMt;case 3:return new $0;case 4:return new aTt;case 5:return new w8;default:throw K(new yn("No implementation is available for the layerer "+(t.f!=null?t.f:""+t.g)))}}function hDt(t,e){var n,i,r,c;for(n=t.o.a,c=a(a(rr(t.r,e),19),60).tc();c.hc();)r=a(c.ic(),111),r.e.a=n*lt(Yt(r.b.xe(NF))),r.e.b=(i=r.b,i.ye((dr(),nu))?i.ef()==(Ht(),Tn)?-i.Re().b-lt(Yt(i.xe(nu))):lt(Yt(i.xe(nu))):i.ef()==(Ht(),Tn)?-i.Re().b:0)}function EX(t,e){YM();var n,i,r,c,l,f,g,b,v;return e.d>t.d&&(f=t,t=e,e=f),e.d<63?$be(t,e):(l=(t.d&-2)<<4,b=gct(t,l),v=gct(e,l),i=UX(t,A2(b,l)),r=UX(e,A2(v,l)),g=EX(b,v),n=EX(i,r),c=EX(UX(b,i),UX(r,v)),c=qX(qX(c,g),n),c=A2(c,l),g=A2(g,l<<1),qX(qX(g,c),n))}function fDt(t,e,n){var i,r,c;for(Jee.call(this,new Nt),this.a=e,this.b=n,this.e=t,i=(t.b&&WX(t),t.a),this.d=E4t(i.a,this.a),this.c=E4t(i.b,this.b),Khe(this,this.d,this.c),k0e(this),c=this.e.e.a.Xb().tc();c.hc();)r=a(c.ic(),247),r.c.c.length>0&&Cye(this,r)}function Yme(t){var e,n,i,r;for(e=0,n=0,r=new H(t.i);r.a1||n>1)return 2;return e+n==1?2:0}function Kme(t,e,n){var i,r,c,l,f,g,b;i=n,r=e;do r=t.a[r.o],l=(b=t.g[r.o],lt(t.p[b.o])+lt(t.d[r.o])-r.d.d),f=vae(r,r.c?nc(r.c.a,r,0):-1),f&&(c=(g=t.g[f.o],lt(t.p[g.o])+lt(t.d[f.o])+f.n.b+f.d.a),i=y.Math.min(i,l-(c+Uv(t.k,r,f))));while(e!=r);return i}function Jme(t,e,n){var i,r,c,l,f,g,b;i=n,r=e;do r=t.a[r.o],c=(b=t.g[r.o],lt(t.p[b.o])+lt(t.d[r.o])+r.n.b+r.d.a),f=Due(r,r.c?nc(r.c.a,r,0):-1),f&&(l=(g=t.g[f.o],lt(t.p[g.o])+lt(t.d[f.o])-f.d.d),i=y.Math.min(i,l-(c+Uv(t.k,r,f))));while(e!=r);return i}function Qme(t,e,n){var i,r,c,l;for(r=n,c=iTt(mL(a(a(rr(t.r,e),19),60).xc(),new _p)),l=0;c.a||(c.a=Hv(c.c,c)),c.a;)if(r){Hn((c.a||(c.a=Hv(c.c,c)),c.a)),c.a=!1,r=!1;continue}else i=uN(c),c.a||(c.a=Hv(c.c,c)),c.a&&(l=y.Math.max(l,i));return l}function tbe(t,e,n){var i,r,c,l,f,g,b,v;if(n)for(c=n.a.length,i=new Fg(c),f=(i.b-i.a)*i.c<0?(v1(),lg):new y1(i);f.hc();)l=a(f.ic(),21),r=TM(n,l.a),r&&(g=fae(t,(b=(sm(),v=new wit,v),e&&_Dt(b,e),b),r),zL(g,Jd(r,Df)),g7(r,g),wlt(r,g),jV(t,r,g))}function ebe(t){var e,n,i;return n=a(t.a,21).a,i=a(t.b,21).a,e=(n<0?-n:n)>(i<0?-i:i)?n<0?-n:n:i<0?-i:i,n=-e&&i==e?new zs(Xt(n-1),Xt(i)):new zs(Xt(n),Xt(i-1))}function dDt(t){var e,n,i,r,c,l;for(l=a(xo(t.a,dt(Cl,Ih,8,t.a.c.length,0,1)),123),Art(l,new l3),n=null,r=0,c=l.length;ri.o?yr(r,fi):r.i==fi&&i.o>t.o&&yr(r,Tn);break}return i}function Vlt(t,e,n){var i,r,c;for(c=new H(t.e);c.a0&&(i.b.c-=i.c,i.b.c<=0&&i.b.f>0&&Xi(e,i.b));for(r=new H(t.b);r.a0&&(i.a.f-=i.c,i.a.f<=0&&i.a.c>0&&Xi(n,i.a))}function qlt(t,e,n){var i,r,c;for(c=new H(t.q);c.a0&&(i.b.j-=i.c,i.b.j<=0&&i.b.r>0&&Xi(e,i.b));for(r=new H(t.g);r.a0&&(i.a.r-=i.c,i.a.r<=0&&i.a.j>0&&Xi(n,i.a))}function k7(t){var e,n,i,r,c;if(t.g==null&&(t.d=t.Gh(t.f),ni(t,t.d),t.c))return c=t.f,c;if(e=a(t.g[t.i-1],43),r=e.ic(),t.e=e,n=t.Gh(r),n.hc())t.d=n,ni(t,n);else for(t.d=null;!e.hc()&&(Vr(t.g,--t.i,null),t.i!=0);)i=a(t.g[t.i-1],43),e=i;return r}function yP(t,e){var n,i,r,c;for(t=t,n=new Db,c=0,i=0;i=0?t.ug(i,!0,!0):W2(t,c,!0),184)),a(r,237).xk(e,n)}else throw K(new yn(U_+e.be()+zY))}function Zlt(t,e,n){switch(n.g){case 1:return new We(e.a,y.Math.min(t.d.b,e.b));case 2:return new We(y.Math.max(t.c.a,e.a),e.b);case 3:return new We(e.a,y.Math.max(t.c.b,e.b));case 4:return new We(y.Math.min(e.a,t.d.a),e.b)}return new We(e.a,e.b)}function xP(t){var e,n,i;for(e=od(1+(!t.c&&(t.c=new Wt(Rl,t,9,9)),t.c).i),Ut(e,(!t.d&&(t.d=new pn(Xs,t,8,5)),t.d)),i=new $n((!t.c&&(t.c=new Wt(Rl,t,9,9)),t.c));i.e!=i.i._b();)n=a(ci(i),121),Ut(e,(!n.d&&(n.d=new pn(Xs,n,8,5)),n.d));return si(e),new m2(e)}function Af(t){var e,n,i;for(e=od(1+(!t.c&&(t.c=new Wt(Rl,t,9,9)),t.c).i),Ut(e,(!t.e&&(t.e=new pn(Xs,t,7,4)),t.e)),i=new $n((!t.c&&(t.c=new Wt(Rl,t,9,9)),t.c));i.e!=i.i._b();)n=a(ci(i),121),Ut(e,(!n.e&&(n.e=new pn(Xs,n,7,4)),n.e));return si(e),new m2(e)}function obe(t,e){var n,i,r,c,l;if(di(e,"Breaking Point Processor",1),R2e(t),lt(de(z(t,(qt(),gbt))))){for(r=new H(t.b);r.a3&&dd(t,0,e-3))}function ube(t){var e,n,i;return n=t.l,n&n-1||(i=t.m,i&i-1)||(e=t.h,e&e-1)||e==0&&i==0&&n==0?-1:e==0&&i==0&&n!=0?sat(n):e==0&&i!=0&&n==0?sat(i)+22:e!=0&&i==0&&n==0?sat(e)+44:-1}function lbe(t,e){var n,i,r,c,l;for(di(e,"Edge joining",1),n=lt(de(z(t,(qt(),$J)))),r=new H(t.b);r.a0),c.a.cd(c.c=--c.b),cd(c,r),Hn(c.bN_,g=vN_,g=vN_,g=vN_,g=v=0){if(e==n)return new zs(Xt(-e-1),Xt(-e-1));if(e==-n)return new zs(Xt(-e),Xt(n+1))}return(e<0?-e:e)>(n<0?-n:n)?e<0?new zs(Xt(-e),Xt(n)):new zs(Xt(-e),Xt(n+1)):new zs(Xt(e+1),Xt(n))}function bbe(t,e,n){var i,r,c,l,f;return r=a(cn(e,(w7(),kwt)),21),!r&&(r=Xt(0)),c=a(cn(n,kwt),21),!c&&(c=Xt(0)),r.a>c.a?-1:r.a1)for(e=am((n=new Dg,++t.b,n),t.d),f=qn(c,0);f.b!=f.d.c;)l=a(Yn(f),113),ih($l(Wl(Vl(Gl(new cl,1),0),e),l))}function ybe(t,e,n){var i,r,c,l,f;for(di(n,"Breaking Point Removing",1),t.a=a(z(e,(qt(),ng)),197),c=new H(e.b);c.a>16!=6&&e){if(VM(t,e))throw K(new yn(y4+T9t(t)));i=null,t.Cb&&(i=(n=t.Db>>16,n>=0?But(t,null):t.Cb.Cg(t,-1-n,null,null))),e&&(i=B2(e,t,6,i)),i=fst(t,e,i),i&&i.Th()}else t.Db&4&&!(t.Db&1)&&Bi(t,new fs(t,1,6,e,e))}function vDt(t,e){var n,i;if(e!=t.Cb||t.Db>>16!=3&&e){if(VM(t,e))throw K(new yn(y4+s7t(t)));i=null,t.Cb&&(i=(n=t.Db>>16,n>=0?zut(t,null):t.Cb.Cg(t,-1-n,null,null))),e&&(i=B2(e,t,12,i)),i=hst(t,e,i),i&&i.Th()}else t.Db&4&&!(t.Db&1)&&Bi(t,new fs(t,1,3,e,e))}function _Dt(t,e){var n,i;if(e!=t.Cb||t.Db>>16!=9&&e){if(VM(t,e))throw K(new yn(y4+pNt(t)));i=null,t.Cb&&(i=(n=t.Db>>16,n>=0?Uut(t,null):t.Cb.Cg(t,-1-n,null,null))),e&&(i=B2(e,t,9,i)),i=dst(t,e,i),i&&i.Th()}else t.Db&4&&!(t.Db&1)&&Bi(t,new fs(t,1,9,e,e))}function yDt(t,e){var n,i;if(e!=t.Cb||t.Db>>16!=11&&e){if(VM(t,e))throw K(new yn(y4+pht(t)));i=null,t.Cb&&(i=(n=t.Db>>16,n>=0?Gut(t,null):t.Cb.Cg(t,-1-n,null,null))),e&&(i=B2(e,t,10,i)),i=yst(t,e,i),i&&i.Th()}else t.Db&4&&!(t.Db&1)&&Bi(t,new fs(t,1,11,e,e))}function Sbe(t,e){if(ct(e,246))return Mhe(t,a(e,35));if(ct(e,187))return Ehe(t,a(e,121));if(ct(e,263))return Ase(t,a(e,137));if(ct(e,183))return Uwe(t,a(e,105));if(e)return null;throw K(new yn(Npt+Gp(new zu(Y(Z(un,1),te,1,5,[null])))))}function Tbe(t){var e,n,i,r,c,l,f,g,b,v,M;return M=slt(t),e=t.a,g=e!=null,g&&YT(M,"category",t.a),r=P9(new xv(t.d)),l=!r,l&&(b=new Ig,L1(M,"knownOptions",b),n=new hG(b),vo(new xv(t.d),n)),c=P9(t.g),f=!c,f&&(v=new Ig,L1(M,"supportedFeatures",v),i=new fG(v),vo(t.g,i)),M}function Cbe(t,e,n){var i,r,c;for(r=new H(t.a.b);r.ag){for(v=t.d,t.d=dt(Fvt,$pt,55,2*g+4,0,1),c=0;c=9223372036854776e3?(PM(),g1t):(r=!1,t<0&&(r=!0,t=-t),i=0,t>=s0&&(i=Tr(t/s0),t-=i*s0),n=0,t>=Q2&&(n=Tr(t/Q2),t-=n*Q2),e=Tr(t),c=ia(e,n,i),r&&JV(c),c)}function xDt(t,e,n){var i,r,c,l,f,g;if(!wm(e)){for(g=Ta(n,(ct(e,13)?a(e,13)._b():lC(e.tc()))/t.a|0),di(g,zBt,1),f=new ol,l=0,c=e.tc();c.hc();)i=a(c.ic(),76),f=Bp(f,new Hd(i)),llw,c=i-llw,(r||c)&&(g=a(e.e,249).b,l=a(e.e,249).a,f=a(e.d,129),g==0&&l==0)))return f;return f}function MDt(t,e,n,i){var r,c,l,f;return l=new Jh(t),jl(l,(Ke(),Hr)),Ct(l,(Ft(),li),e),Ct(l,(qt(),Qi),(Ls(),Gc)),Ct(l,Pu,n),Ct(l,Iu,i),c=new Eo,yr(c,(Ht(),on)),ds(c,l),f=new Eo,yr(f,Qe),ds(f,l),Ts(e,c),r=new Np,Uo(r,e),Ct(r,Ro,null),Hs(r,f),Ts(r,i),l}function Nbe(t,e,n,i,r){var c,l;(!ec(e)&&e.c.g.c==e.d.g.c||!aPt(zo(Y(Z(ss,1),wt,9,0,[r.g.k,r.k,r.a])),n))&&(e.c==r?uD(e.a,0,new Oo(n)):Xi(e.a,new Oo(n)),i&&!ET(t.a,n)&&(l=a(z(e,(qt(),Ro)),74),l||(l=new Va,Ct(e,Ro,l)),c=new Oo(n),Ws(l,c,l.c.b,l.c),Ir(t.a,c)))}function Obe(t,e){var n,i;if(i=jD(t.b,e.b),!i)throw K(new yc("Invalid hitboxes for scanline constraint calculation."));(i6t(e.b,a(one(t.b,e.b),57))||i6t(e.b,a(sne(t.b,e.b),57)))&&(rd(),e.b+""),t.a[e.b.f]=a(e$(t.b,e.b),57),n=a(n$(t.b,e.b),57),n&&(t.a[n.f]=e.b)}function EDt(t,e,n,i,r,c){var l,f,g,b,v,M,k,R,O,$,W,nt;for(v=i,e.i&&e.k?(R=a(zi(t.f,e.u),57),$=R.d.c+R.d.b,--v):$=e.a.c+e.a.b,M=r,n.n&&n.k?(R=a(zi(t.f,n.v),57),b=R.d.c,++M):b=n.a.c,W=b-$,g=2>M-v?2:M-v,f=W/g,O=$+f,k=v;k>16!=7&&e){if(VM(t,e))throw K(new yn(y4+P8t(t)));i=null,t.Cb&&(i=(n=t.Db>>16,n>=0?Fut(t,null):t.Cb.Cg(t,-1-n,null,null))),e&&(i=a(e,42).Ag(t,1,fI,i)),i=aot(t,e,i),i&&i.Th()}else t.Db&4&&!(t.Db&1)&&Bi(t,new fs(t,1,7,e,e))}function Bbe(t,e){var n,i;if(e!=t.Cb||t.Db>>16!=3&&e){if(VM(t,e))throw K(new yn(y4+H6t(t)));i=null,t.Cb&&(i=(n=t.Db>>16,n>=0?jut(t,null):t.Cb.Cg(t,-1-n,null,null))),e&&(i=a(e,42).Ag(t,0,pI,i)),i=uot(t,e,i),i&&i.Th()}else t.Db&4&&!(t.Db&1)&&Bi(t,new fs(t,1,3,e,e))}function CDt(t){var e,n,i,r,c,l,f;for(c=new H(t.a.a);c.a0&&c>0?l.o=e++:i>0?l.o=n++:c>0?l.o=r++:l.o=n++}we(),gc(t.i,new Mg)}function ADt(t,e){var n,i,r;for(r=(!e.a&&(e.a=new Wt(zr,e,10,11)),e.a).i,i=new $n((!e.a&&(e.a=new Wt(zr,e,10,11)),e.a));i.e!=i.i._b();)n=a(ci(i),35),zt(cn(n,(dr(),ry)))!==zt((Yg(),mA))&&vct(bX(e),bX(n))&&((!n.a&&(n.a=new Wt(zr,n,10,11)),n.a).i==0||(r+=ADt(t,n)));return r}function Ube(t,e){var n,i,r;return n=e.Yg(t.a),n&&(r=hi(Lh((!n.b&&(n.b=new xu((ye(),Ho),Dc,n)),n.b),"affiliation")),r!=null)?(i=NW(r,Ca(35)),i==-1?wq(t,JT(t,Xu(e.Wi())),r):i==0?wq(t,null,r.substr(1,r.length-1)):wq(t,r.substr(0,i),r.substr(i+1,r.length-(i+1)))):null}function zbe(t){var e,n,i,r,c;if(c=new Nt,pd(t.b,new iH(c)),t.b.c=dt(un,te,1,0,5,1),c.c.length!=0){for(e=(mi(0,c.c.length),a(c.c[0],78)),n=1,i=c.c.length;n=t.a||!ilt(e,n))return-1;if(wm(a(i.Kb(e),20)))return 1;for(r=0,l=a(i.Kb(e),20).tc();l.hc();)if(c=a(l.ic(),14),g=c.c.g==e?c.d.g:c.c.g,f=Qlt(t,g,n,i),f==-1||(r=r>f?r:f,r>t.c-1))return-1;return r+1}function jbe(t,e,n,i){var r,c,l,f,g,b,v,M,k;for(M=i?(Ht(),on):(Ht(),Qe),r=!1,g=e[n],b=0,v=g.length;b>5,e&=31,i>=t.d)return t.e<0?($1(),SK):($1(),EE);if(c=t.d-i,r=dt(Gn,pi,22,c+1,15,1),Mge(r,c,t.a,i,e),t.e<0){for(n=0;n0&&t.a[n]<<32-e){for(n=0;n0&&(c=a(Ee(this.b,0),157),r+=c.o,i+=c.p),r*=2,i*=2,e>1?r=Tr(y.Math.ceil(r*e)):i=Tr(y.Math.ceil(i/e)),this.a=new hut(r,i)}function nht(t,e,n,i,r,c){var l,f,g,b,v,M;for(b=n.c.length,c&&(t.c=dt(Gn,pi,22,e.length,15,1)),l=r?0:e.length-1;r?l=0;l+=r?1:-1){for(f=e[l],g=i==(Ht(),Qe)?r?ac(f,i):Em(ac(f,i)):r?Em(ac(f,i)):ac(f,i),c&&(t.c[f.o]=g._b()),M=g.tc();M.hc();)v=a(M.ic(),11),t.d[v.o]=b++;Or(n,g)}}function ODt(t,e,n){var i,r,c,l,f,g,b,v;for(c=lt(Yt(t.b.tc().ic())),b=lt(Yt(gPt(e.b))),i=hl(Xc(t.a),b-n),r=hl(Xc(e.a),n-c),v=sr(i,r),hl(v,1/(b-c)),this.a=v,this.b=new Nt,f=!0,l=t.b.tc(),l.ic();l.hc();)g=lt(Yt(l.ic())),f&&g-n>N_&&(this.b.nc(n),f=!1),this.b.nc(g);f&&this.b.nc(n)}function Qbe(t){var e,n,i,r;if(ive(t,t.n),t.d.c.length>0){for(bT(t.c);Dlt(t,a(G(new H(t.e.a)),113))=r&&(t.c=!1,t.a=!1),t.b[i++]=r,t.b[i]=c,t.c||__(t)}}function BDt(t){var e,n,i,r;return r=Tf(t),n=new g1(r),i=new sH(r),e=new Nt,Or(e,(!t.d&&(t.d=new pn(Xs,t,8,5)),t.d)),Or(e,(!t.e&&(t.e=new pn(Xs,t,7,4)),t.e)),a(hd(Vh(wo(new gi(null,new Ei(e,16)),n),i),Jv(new ti,new Qn,new Kt,new kt,Y(Z(tf,1),jt,150,0,[(U1(),pw),Qh]))),19)}function FDt(t){var e,n,i;if(n=a(z(t,(Ft(),Ru)),8),n?yr(t,a(z(n,wc),69)):t.d.c.length-t.f.c.length<0?yr(t,(Ht(),Qe)):yr(t,(Ht(),on)),!t.b)switch(i=t.n,e=t.a,t.i.g){case 1:e.a=i.a/2,e.b=0;break;case 2:e.a=i.a,e.b=i.b/2;break;case 3:e.a=i.a/2,e.b=i.b;break;case 4:e.a=0,e.b=i.b/2}}function twe(t,e,n){var i,r,c,l,f;for(di(n,"Longest path layering",1),t.a=e,f=t.a.a,t.b=dt(Gn,pi,22,f.c.length,15,1),i=0,l=new H(f);l.a=0?!1:(n=nE((Qa(),eo),r,e),n?(i=n.kj(),(i>1||i==-1)&&gm(qo(eo,n))!=3):!0)):!1}function ewe(t,e){var n;switch(n=a(z(t,(qt(),q4)),241),di(e,"Label side selection ("+n+")",1),n.g){case 0:g9t(t,(Tu(),kd));break;case 1:g9t(t,(Tu(),cg));break;case 2:kNt(t,(Tu(),kd));break;case 3:kNt(t,(Tu(),cg));break;case 4:VDt(t,(Tu(),kd));break;case 5:VDt(t,(Tu(),cg))}Vn(e)}function iht(t,e,n){var i,r,c,l,f,g;if(i=GQt(n,t.length),l=t[i],l[0].j==(Ke(),rs))for(c=r3t(n,l.length),g=e.i,r=0;r0&&(n[0]+=t.d,l-=n[0]),n[2]>0&&(n[2]+=t.d,l-=n[2]),c=y.Math.max(0,l),n[1]=y.Math.max(n[1],l),Tct(t,ta,r.c+i.b+n[0]-(n[1]-l)/2,n),e==ta&&(t.c.b=c,t.c.c=r.c+i.b+(c-l)/2)}function cwe(t,e){var n,i,r,c,l,f,g;for(n=Ps,f=(Ke(),gs),r=new H(e.a);r.a0?l=n:g.c&&(l=h$(g.c)),l>0&&(i&&(Bg(),g.a.B&&(!lt(de(g.a.e.xe((dr(),eI))))||g.b.ff()))?g.d.a=t.s+l:(v=g.b.Re().b,l>v&&(f=(l-v)/2,g.d.d=f,g.d.a=f)))}}function lwe(t,e){var n,i,r,c,l;return r=e.Yg(t.a),r&&(i=(!r.b&&(r.b=new xu((ye(),Ho),Dc,r)),r.b),n=hi(Lh(i,Ns)),n!=null&&(c=n.lastIndexOf("#"),l=c==-1?sst(t,e.Pi(),n):c==0?CL(t,null,n.substr(1,n.length-1)):CL(t,n.substr(0,c),n.substr(c+1,n.length-(c+1))),ct(l,140)))?a(l,140):null}function hwe(t,e){var n,i,r,c,l;return i=e.Yg(t.a),i&&(n=(!i.b&&(i.b=new xu((ye(),Ho),Dc,i)),i.b),c=hi(Lh(n,sK)),c!=null&&(r=c.lastIndexOf("#"),l=r==-1?sst(t,e.Pi(),c):r==0?CL(t,null,c.substr(1,c.length-1)):CL(t,c.substr(0,r),c.substr(r+1,c.length-(r+1))),ct(l,140)))?a(l,140):null}function $Dt(t,e,n,i,r){var c,l,f,g,b,v;if(t.d&&t.d.If(r),c=a(r.cd(0),35),yRt(t,n,c,!1)||(l=a(r.cd(r._b()-1),35),yRt(t,i,l,!0))||flt(t,r))return!0;for(v=r.tc();v.hc();)for(b=a(v.ic(),35),g=e.tc();g.hc();)if(f=a(g.ic(),35),O7(t,b,f))return!0;return!1}function fwe(t,e,n){var i,r,c,l,f,g,b,v,M,k;k=e.c.length,M=(b=t.rg(n),a(b>=0?t.ug(b,!1,!0):W2(t,n,!1),52));t:for(c=M.tc();c.hc();){for(r=a(c.ic(),51),v=0;vt.d[l.o]&&(n+=Dkt(t.b,c),aC(t.a,Xt(c)));for(;!Cit(t.a);)sLt(t.b,a(y$(t.a),21).a)}return n}function M_(t,e,n){var i,r;if((!t.a&&(t.a=new Wt(os,t,6,6)),t.a).i==0)return u6t(t);if(i=a(at((!t.a&&(t.a=new Wt(os,t,6,6)),t.a),0),270),e&&(Dr((!i.a&&(i.a=new Ss(sf,i,5)),i.a)),vC(i,0),_C(i,0),wC(i,0),bC(i,0)),n)for(r=(!t.a&&(t.a=new Wt(os,t,6,6)),t.a);r.i>1;)rw(r,r.i-1);return i}function mwe(t,e){var n,i,r,c;if(c=SNt(e),r=a(z(c,(Ft(),Qc)),19),p2e(e,r),r.pc((So(),Al)))for(i=new $n((!e.c&&(e.c=new Wt(Rl,e,9,9)),e.c));i.e!=i.i._b();)n=a(ci(i),121),M2e(t,e,c,n);return qbe(e,c),lt(de(z(c,(qt(),ibt))))&&r.nc(PB),zt(cn(e,X4))===zt((Yg(),kx))?kxe(t,e,c):x2e(t,e,c),c}function So(){So=P,kB=new Fb("COMMENTS",0),Al=new Fb("EXTERNAL_PORTS",1),H4=new Fb("HYPEREDGES",2),LB=new Fb("HYPERNODES",3),X_=new Fb("NON_FREE_PORTS",4),Z_=new Fb("NORTH_SOUTH_PORTS",5),S6=new Fb(MBt,6),AE=new Fb("CENTER_LABELS",7),kE=new Fb("END_LABELS",8),PB=new Fb("PARTITIONS",9)}function qDt(t,e,n){var i,r,c,l;for(c=(!e.a&&(e.a=new Wt(zr,e,10,11)),e.a).i,r=new $n((!e.a&&(e.a=new Wt(zr,e,10,11)),e.a));r.e!=r.i._b();)i=a(ci(r),35),(!i.a&&(i.a=new Wt(zr,i,10,11)),i.a).i==0||(c+=qDt(t,i,!1));if(n)for(l=io(e);l;)c+=(!l.a&&(l.a=new Wt(zr,l,10,11)),l.a).i,l=io(l);return c}function rw(t,e){var n,i,r,c;return t.ti()?(i=null,r=t.ui(),t.xi()&&(i=t.zi(t.Dh(e),null)),n=t.mi(4,c=U2(t,e),null,e,r),t.qi()&&c!=null&&(i=t.si(c,i)),i?(i.Sh(n),i.Th()):t.ni(n),c):(c=U2(t,e),t.qi()&&c!=null&&(i=t.si(c,null),i&&i.Th()),c)}function bwe(t){var e,n,i,r,c,l,f,g,b;for(l=is,g=is,f=null,n=new I$(new Yy(t.e));n.b!=n.c.a.b;)if(e=Bct(n),(zt(e.d)===zt((mu(),Zp))||zt(e.d)===zt(Cw))&&(i=a(e.e,249).a,b=a(e.e,249).b,r=l-i>lw,c=i-llw,(r||c)&&(g=a(e.e,249).b,l=a(e.e,249).a,f=a(e.d,129),g==0&&l==0)))return f;return f}function wwe(t){var e,n,i,r,c,l,f,g,b,v;for(c=t.a,e=new $r,b=0,i=new H(t.d);i.ag.d&&(v=g.d+g.a+c));n.c.d=v,e.a.Zb(n,e),b=y.Math.max(b,n.c.d+n.c.a)}return b}function vwe(t,e,n,i,r){return i<0?(i=w_(t,r,Y(Z(At,1),wt,2,6,[gZ,mZ,bZ,wZ,K2,vZ,_Z,yZ,xZ,MZ,EZ,SZ]),e),i<0&&(i=w_(t,r,Y(Z(At,1),wt,2,6,["Jan","Feb","Mar","Apr",K2,"Jun","Jul","Aug","Sep","Oct","Nov","Dec"]),e)),i<0?!1:(n.k=i,!0)):i>0?(n.k=i-1,!0):!1}function _we(t,e,n,i,r){return i<0?(i=w_(t,r,Y(Z(At,1),wt,2,6,[gZ,mZ,bZ,wZ,K2,vZ,_Z,yZ,xZ,MZ,EZ,SZ]),e),i<0&&(i=w_(t,r,Y(Z(At,1),wt,2,6,["Jan","Feb","Mar","Apr",K2,"Jun","Jul","Aug","Sep","Oct","Nov","Dec"]),e)),i<0?!1:(n.k=i,!0)):i>0?(n.k=i-1,!0):!1}function ywe(t,e,n){var i,r,c;if(t.e=n,t.d=0,t.b=0,t.f=1,t.i=e,(t.e&16)==16&&(t.i=Vwe(t.i)),t.j=t.i.length,Ci(t),c=Cm(t),t.d!=t.j)throw K(new ri(ai((Kn(),zFt))));if(t.g){for(i=0;iVBt?gc(g,t.b):i<=VBt&&i>qBt?gc(g,t.d):i<=qBt&&i>XBt?gc(g,t.c):i<=XBt&&gc(g,t.a),c=ZDt(t,g,c);return r}function YDt(t){h2(t,new b_(u2(o2(a2(c2(new V0,EO),"Randomizer"),'Distributes the nodes randomly on the plane, leading to very obfuscating layouts. Can be useful to demonstrate the power of "real" layout algorithms.'),new fz))),pe(t,EO,ex,Svt),pe(t,EO,uE,15),pe(t,EO,cO,Xt(0)),pe(t,EO,cE,aE)}function Mwe(t,e){var n,i,r,c,l,f,g,b,v,M;for(g=e.a.length,f=Tr(y.Math.ceil(g/t.a)),M=e.a,l=0,b=f,c=0;cl?0:l)l?0:l:g,(0>(bl?0:l)l?0:l:g)),l=b,b+=f,i=a(Ee(t.c,c),8),n=new IW(v),n.n.b=e.n.b,cr(t.b,e,n),Ut(i.b,n);Lc(t.g.b,e),Ut(t.i,(r=new bMt(t,e),r))}function KDt(t,e,n){var i,r,c,l,f,g,b,v,M;for(e.o=1,c=e.c,M=Jb(e,(Fo(),ba)).tc();M.hc();)for(v=a(M.ic(),11),r=new H(v.f);r.a=t.length||(f=t.charCodeAt(e[0]),f!=43&&f!=45)||(++e[0],i=y7(t,e),i<0))return!1;f==45&&(i=-i)}return f==32&&e[0]-n==2&&r.b==2&&(g=new N9,b=g.q.getFullYear()-Nm+Nm-80,l=b%100,c.a=i==l,i+=(b/100|0)*100+(i0){if(t.Fi(),e!=null){for(c=0;c=48;n--)CA[n]=n-48<<24>>24;for(i=70;i>=65;i--)CA[i]=i-65+10<<24>>24;for(r=102;r>=97;r--)CA[r]=r-97+10<<24>>24;for(c=0;c<10;c++)JF[c]=48+c&qr;for(t=10;t<=15;t++)JF[t]=65+t-10&qr}function nNt(t){var e,n,i,r;n=lt(Yt(z(t.a,(Ph(),xjt)))),i=t.a.c.d,r=t.a.d.d,e=t.d,i.a>=r.a?i.b>=r.b?(e.a=r.a+(i.a-r.a)/2+n,e.b=r.b+(i.b-r.b)/2-n):(e.a=r.a+(i.a-r.a)/2+n,e.b=i.b+(r.b-i.b)/2+n):i.b>=r.b?(e.a=i.a+(r.a-i.a)/2+n,e.b=r.b+(i.b-r.b)/2+n):(e.a=i.a+(r.a-i.a)/2+n,e.b=i.b+(r.b-i.b)/2-n)}function kwe(t,e,n,i){var r,c,l,f,g;return f=zc(a(at((!e.b&&(e.b=new pn(Si,e,4,7)),e.b),0),97)),g=zc(a(at((!e.c&&(e.c=new pn(Si,e,5,8)),e.c),0),97)),io(f)==io(g)||gC(g,f)?null:(l=QD(e),l==n?i:(c=a(zi(t.a,l),8),c&&(r=a(z(c,(Ft(),xd)),31),r)?r:null))}function Lwe(t,e,n,i){var r,c,l,f,g;for(c=t.i.c.length,g=dt(W3e,Fft,267,c,0,1),l=0;lk+g&&i.jc();for(l=new H(R);l.a>19)return"-"+rNt(OM(t));for(n=t,i="";!(n.l==0&&n.m==0&&n.h==0);){if(r=oV(tO),n=Bht(n,r,!0),e=""+p3t(J1),!(n.l==0&&n.m==0&&n.h==0))for(c=9-e.length;c>0;c--)e="0"+e;i=e+i}return i}function Au(t,e,n){var i,r,c,l,f;if(t==null)throw K(new yf(tu));for(c=t.length,l=c>0&&(t.charCodeAt(0)==45||t.charCodeAt(0)==43)?1:0,i=l;in)throw K(new yf(Om+t+'"'));return f}function Iwe(){if(!Object.create||!Object.getOwnPropertyNames)return!1;var t="__proto__",e=Object.create(null);if(e[t]!==void 0)return!1;var n=Object.getOwnPropertyNames(e);return!(n.length!=0||(e[t]=42,e[t]!==42)||Object.getOwnPropertyNames(e).length==0)}function Rwe(t,e){var n,i,r,c;for(di(e,"Resize child graph to fit parent.",1),i=new H(t.b);i.a>24;case 97:case 98:case 99:case 100:case 101:case 102:return t-97+10<<24>>24;case 65:case 66:case 67:case 68:case 69:case 70:return t-65+10<<24>>24;default:throw K(new yf("Invalid hexadecimal"))}}function Uwe(t,e){var n,i,r,c,l,f,g,b,v;if(b=a(zi(t.c,e),191),!b)throw K(new xf("Edge did not exist in input."));return l=RC(b),v=new Ig,n=new HTt(t,l,v),yte((!e.a&&(e.a=new Wt(os,e,6,6)),e.a),n),L1(b,kpt,v),f=a(cn(e,(dr(),Tx)),74),r=!f||S4t(f),c=!r,c&&(g=new Ig,i=new KH(g),vo(f,i),L1(b,"junctionPoints",g)),null}function zwe(t,e,n){var i,r,c,l;di(n,"Orthogonally routing hierarchical port edges",1),t.a=0,i=eye(e),e2e(e,i),Tye(t,e,i),uxe(e),r=a(z(e,(qt(),Qi)),83),c=e.b,H7t((mi(0,c.c.length),a(c.c[0],26)),r,e),H7t(a(Ee(c,c.c.length-1),26),r,e),l=e.b,ZNt((mi(0,l.c.length),a(l.c[0],26))),ZNt(a(Ee(l,l.c.length-1),26)),Vn(n)}function jwe(t){var e,n,i;switch(e=a(z(t.d,(qt(),ng)),197),e.g){case 2:n=Fxe(t);break;case 3:n=(i=new Nt,qc(wo(Vh(Yh(Yh(new gi(null,new Ei(t.d.b,16)),new By),new Fy),new M3),new Ny),new em(i)),i);break;default:throw K(new yc("Compaction not supported for "+e+" edges."))}bye(t,n),vo(new xv(t.g),new vH(t))}function Hwe(t,e,n,i){var r,c,l,f,g;for(r=!1,c=!1,f=new H(i.i);f.a1&&(n?l=ql(e.c)+1:l=ql(b.c)-1,f=a(Ee(t.a.b,l),26),Ks(b,f)),aht(t,b,n));return e}function sNt(t,e,n,i,r,c){if(this.b=n,this.d=r,t>=e.length)throw K(new Uc("Greedy SwitchDecider: Free layer not in graph."));this.c=e[t],this.e=new X5(i),BV(this.e,this.c,(Ht(),on)),this.i=new X5(i),BV(this.i,this.c,Qe),this.f=new _Ct(this.c),this.a=!c&&r.i&&!r.s&&this.c[0].j==(Ke(),rs),this.a&&Vge(this,t,e.length)}function Gwe(t,e,n){var i,r,c,l;for(di(n,"Processor order nodes",2),t.a=lt(Yt(z(e,(nw(),Kbt)))),r=new Fr,l=qn(e.b,0);l.b!=l.d.c;)c=a(Yn(l),76),lt(de(z(c,(mc(),Lw))))&&Ws(r,c,r.c.b,r.c);i=(Hn(r.b!=0),a(r.a.a.c,76)),c7t(t,i),!n.b&&NV(n,1),fht(t,i,0-lt(Yt(z(i,(mc(),hF))))/2,0),!n.b&&NV(n,1),Vn(n)}function oNt(){this.b=(ts(),new vm),this.d=new vm,this.e=new vm,this.c=new vm,this.a=new vi,this.f=new vi,M2(ss,new XU,new ZU),M2(Mwt,new nz,new iz),M2(Bgt,new rz,new sz),M2(Fgt,new wv,new oz),M2(x3e,new cz,new hz),M2(S3e,new q0,new YU),M2(M3e,new KU,new JU),M2(E3e,new QU,new tz),M2(A3e,new X0,new ez)}function cNt(t,e,n,i){var r,c,l,f,g,b;for(g=nX(t,n),b=nX(e,n),r=!1;g&&b&&(i||tpe(g,b,n));)l=nX(g,n),f=nX(b,n),RL(e),RL(t),c=g.c,eZ(g,!1),eZ(b,!1),n?(G1(e,b.o,c),e.o=b.o,G1(t,g.o+1,c),t.o=g.o):(G1(t,g.o,c),t.o=g.o,G1(e,b.o+1,c),e.o=b.o),Ks(g,null),Ks(b,null),g=l,b=f,r=!0;return r}function LX(t,e,n,i,r,c,l,f){var g,b,v;for(g=0,e!=null&&(g^=z1(e.toLowerCase())),n!=null&&(g^=z1(n)),i!=null&&(g^=z1(i)),l!=null&&(g^=z1(l)),f!=null&&(g^=z1(f)),b=0,v=c.length;bg?new SN(e,t,f-g):f>0&&g>0&&(new SN(t,e,0),new SN(e,t,0)))}function aNt(t){h2(t,new b_(u2(o2(a2(c2(new V0,e6),vFt),"Keeps the current layout as it is, without any automatic modification. Optional coordinates can be given for nodes and edge bend points."),new xR))),pe(t,e6,ex,wvt),pe(t,e6,_O,Xe(gA)),pe(t,e6,bpt,Xe(gvt)),pe(t,e6,wO,Xe(mvt)),pe(t,e6,vO,Xe(bvt))}function uNt(t){var e,n,i;i=a(z(t,(qt(),Oh)),19),!i.Wb()&&(n=(e=a(yu(to),10),new ja(e,a(cu(e,e.length),10),0)),i.pc((i0(),Du))?Su(n,Du):Su(n,Il),i.pc(Ll)||Su(n,Ll),i.pc(kl)?Su(n,Bh):i.pc(Uf)?Su(n,hh):i.pc(Pl)&&Su(n,lh),i.pc(Bh)?Su(n,kl):i.pc(hh)?Su(n,Uf):i.pc(lh)&&Su(n,Pl),Ct(t,Oh,n))}function uht(t,e){var n,i,r,c;if(0<(ct(t,13)?a(t,13)._b():lC(t.tc()))){if(r=e,1=t.o)throw K(new g9);f=e>>5,l=e&31,c=Yd(1,or(Yd(l,1))),r?t.n[n][f]=Xh(t.n[n][f],c):t.n[n][f]=ns(t.n[n][f],lst(c)),c=Yd(c,1),i?t.n[n][f]=Xh(t.n[n][f],c):t.n[n][f]=ns(t.n[n][f],lst(c))}catch(g){throw g=vr(g),ct(g,305)?K(new Uc($Z+t.o+"*"+t.p+VZ+e+Rc+n+qZ)):K(g)}}function PX(t,e){var n,i,r,c,l,f,g;for(r=new Nt,g=new Nt,n=a(js(q_,t),15).tc();n.hc();)i=a(n.ic(),151),VIt(r,i.b),VIt(r,LIt(i)),n.hc()&&(i=a(n.ic(),151),Or(g,LIt(i)),Or(g,i.b));for(kV(r,t.b),kV(g,t.a),f=new H(r);f.at.d[f.o]&&(n+=Dkt(t.b,c),aC(t.a,Xt(c)))):++l;for(n+=t.b.d*l;!Cit(t.a);)sLt(t.b,a(y$(t.a),21).a)}return n}function Jwe(t){var e,n,i,r,c,l;if(r=t.g.ed(),i=t.b.ed(),t.e)for(n=0;nN_;){for(c=e,l=0;y.Math.abs(e-c)0&&(i=(!t.n&&(t.n=new Wt(ic,t,1,7)),a(a(at(t.n,0),137),263)).a,!i||Ii(Ii((e.a+=' "',e),i),'"'))),Ii(om(Ii(om(Ii(om(Ii(om((e.a+=" (",e),t.i),","),t.j)," | "),t.g),","),t.f),")"),e.a)}function pNt(t){var e,n,i;return t.Db&64?cX(t):(e=new ll(Ept),n=t.k,n?Ii(Ii((e.a+=' "',e),n),'"'):(!t.n&&(t.n=new Wt(ic,t,1,7)),t.n.i>0&&(i=(!t.n&&(t.n=new Wt(ic,t,1,7)),a(a(at(t.n,0),137),263)).a,!i||Ii(Ii((e.a+=' "',e),i),'"'))),Ii(om(Ii(om(Ii(om(Ii(om((e.a+=" (",e),t.i),","),t.j)," | "),t.g),","),t.f),")"),e.a)}function gNt(t){var e,n,i,r,c,l;return c=0,e=wl(t),e.Qi()&&(c|=4),t.Bb&La&&(c|=2),ct(t,62)?(n=a(t,17),r=jo(n),n.Bb&ca&&(c|=32),r&&(ei(Vb(r)),c|=8,l=r.t,(l>1||l==-1)&&(c|=16),r.Bb&ca&&(c|=64)),n.Bb&ao&&(c|=dw),c|=oh):ct(e,425)?c|=512:(i=e.Qi(),i&&i.i&1&&(c|=256)),t.Bb&512&&(c|=128),c}function ght(t,e){var n,i,r,c,l,f,g;if(e==null||e.length==0)return null;if(r=a(Zc(t.a,e),180),!r){for(i=(f=new vf(t.b).a.Tb().tc(),new Q0(f));i.a.hc();)if(n=(c=a(i.a.ic(),38),a(c.lc(),180)),l=n.c,g=e.length,le(l.substr(l.length-g,g),e)&&(e.length==l.length||bo(l,l.length-e.length-1)==46)){if(r)return null;r=n}r&&tc(t.a,e,r)}return r}function tve(t,e){var n;return t.f==ctt?(n=gm(qo((Qa(),eo),e)),t.e?n==4&&e!=($2(),Bx)&&e!=($2(),Ox)&&e!=($2(),att)&&e!=($2(),utt):n==2):t.d&&(t.d.pc(e)||t.d.pc(sC(qo((Qa(),eo),e)))||t.d.pc(nE((Qa(),eo),t.b,e)))?!0:t.f&&Klt((Qa(),t.f),pL(qo(eo,e)))?(n=gm(qo(eo,e)),t.e?n==4:n==2):!1}function eve(t,e,n,i){var r,c,l,f,g,b,v,M;return l=a(cn(n,(dr(),Cx)),9),g=l.a,v=l.b+t,r=y.Math.atan2(v,g),r<0&&(r+=sx),r+=e,r>sx&&(r-=sx),f=a(cn(i,Cx),9),b=f.a,M=f.b+t,c=y.Math.atan2(M,b),c<0&&(c+=sx),c+=e,c>sx&&(c-=sx),Ef(),P1(1e-10),y.Math.abs(r-c)<=1e-10||r==c||isNaN(r)&&isNaN(c)?0:rc?1:J9(isNaN(r),isNaN(c))}function nve(t,e,n,i){var r,c;for(Bpe(t,e,n,i),Cnt(e,t.j-e.j+n),Tnt(e,t.k-e.k+i),c=new H(e.f);c.an.k&&fb&&i>b)b=lt(n.p[f.o])+lt(n.d[f.o])+f.n.b+f.d.a;else{r=!1,t.a&&rd();break}if(!r)break}return t.a&&rd(),r}function pve(t,e){var n,i,r,c,l;for(t.c==null||t.c.lengthc*2?(v=new PN(M),b=Wu(l)/Sh(l),g=iZ(v,e,new r2,n,i,r,b),sr(Gh(v.e),g),M.c=dt(un,te,1,0,5,1),M.c[M.c.length]=v,M.c[M.c.length]=l,c=Wu(v)*Sh(v)+Wu(l)*Sh(l)):(M.c[M.c.length]=l,c+=Wu(l)*Sh(l));return M}function tE(t){switch(t){case 100:return A_(P4,!0);case 68:return A_(P4,!1);case 119:return A_(lK,!0);case 87:return A_(lK,!1);case 115:return A_(hK,!0);case 83:return A_(hK,!1);case 99:return A_(fK,!0);case 67:return A_(fK,!1);case 105:return A_(dK,!0);case 73:return A_(dK,!1);default:throw K(new sc(szt+t.toString(16)))}}function ENt(t,e,n){var i,r,c,l,f,g,b,v;if(e.o==0){for(e.o=1,l=n,n||(r=new Nt,c=(i=a(yu(Ia),10),new ja(i,a(cu(i,i.length),10),0)),l=new zs(r,c)),a(l.a,15).nc(e),e.j==(Ke(),rs)&&a(l.b,19).nc(a(z(e,(Ft(),wc)),69)),g=new H(e.i);g.af&&(f=r,v.c=dt(un,te,1,0,5,1)),r==f&&Ut(v,new zs(n.c.g,n)));we(),gc(v,t.c),hm(t.b,g.o,v)}}function Sve(t,e){var n,i,r,c,l,f,g,b,v;for(l=new H(e.b);l.af&&(f=r,v.c=dt(un,te,1,0,5,1)),r==f&&Ut(v,new zs(n.d.g,n)));we(),gc(v,t.c),hm(t.f,g.o,v)}}function Tve(t,e,n,i){var r,c,l,f,g,b,v,M,k;for(g=new We(n,i),za(g,a(z(e,(I1(),B4)),9)),k=new H(e.e);k.a=40,l&&s_e(t),Z_e(t),Qbe(t),n=eIt(t),i=0;n&&i0&&Xi(t.e,c)):(t.c[l]-=b+1,t.c[l]<=0&&t.a[l]>0&&Xi(t.d,c))))}function TNt(t){var e,n,i,r,c,l,f,g,b,v,M;for(f=new Nt,c=lt(Yt(t.g.cd(t.g._b()-1))),M=t.g.tc();M.hc();)v=Yt(M.ic()),hm(f,0,c-(En(v),v));for(l=TC($V(t)),b=new Nt,r=new H(f),g=new Nt,e=0;e1)&&e==1&&a(t.a[t.b],8).j==(Ke(),bu)?q2(a(t.a[t.b],8),(Tu(),kd)):i&&(!n||(t.c-t.b&t.a.length-1)>1)&&e==1&&a(t.a[t.c-1&t.a.length-1],8).j==(Ke(),bu)?q2(a(t.a[t.c-1&t.a.length-1],8),(Tu(),cg)):(t.c-t.b&t.a.length-1)==2?(q2(a(EC(t),8),(Tu(),kd)),q2(a(EC(t),8),cg)):nbe(t,r),mct(t)}function kve(t){var e,n;if(!t.Wb()){for(n=a(t.cd(0),151).f,new Eht(t),e=new Gs(n.i,0),m_((mu(),hp),e),d_(ny,e),oP((Ht(),Tn),e),PX(ig,e),d_(Qm,e),y_(Tw,e),m_(Zp,e),oP(Qe,e),PX(Km,e),m_(Cw,e),y_(Jm,e),m_(Qm,e),oP(fi,e),PX(Yp,e),m_(ny,e),y_(kw,e),d_(Cw,e);e.b=0&&(f=lpe(t,l),!(f&&(b<22?g.l|=1<>>1,l.m=v>>>1|(M&1)<<21,l.l=k>>>1|(v&1)<<21,--b;return n&&JV(g),c&&(i?(J1=OM(t),r&&(J1=YPt(J1,(PM(),m1t)))):J1=ia(t.l,t.m,t.h)),g}function RNt(t,e,n,i){var r,c,l,f,g,b,v,M;if(Aue(t,e,n),c=e[n],M=i?(Ht(),on):(Ht(),Qe),bee(e.length,n,i)){for(r=e[i?n-1:n+1],Lct(t,r,i?(Fo(),ba):(Fo(),Ga)),g=0,v=c.length;g0){for(r=f.length;r>0&&f[r-1]=="";)--r;r=0&&f!=n&&(c=new fs(t,1,f,l,null),i?i.Sh(c):i=c),n>=0&&(c=new fs(t,1,n,f==n?l:null,e),i?i.Sh(c):i=c)),i}function jve(t,e,n,i){var r,c,l,f,g,b,v;if(X0e(t,e,n,i))return!0;for(l=new H(e.f);l.a=r){for(l=1;l0){if(r=a(t.Ab.g,1627),e==null){for(c=0;c1)for(i=new H(r);i.ae.f?1:0:(i=t.e-e.e,n=(t.d>0?t.d:y.Math.floor((t.a-1)*ROt)+1)-(e.d>0?e.d:y.Math.floor((e.a-1)*ROt)+1),n>i+1?r:n0&&(l=Kv(l,qNt(i))),RIt(c,l))):rg+O&&($=M.i+k.i,k.a=(k.i*k.a+M.i*M.a)/$,k.i=$,M.g=k,n=!0)),c=f,M=k;return n}function FNt(t,e){var n,i,r,c,l,f,g,b,v;if(r=t.g,l=r.n.a,c=r.n.b,l<=0&&c<=0)return Ht(),Wc;switch(b=t.k.a,v=t.k.b,f=t.n.a,n=t.n.b,e.g){case 2:case 1:if(b<0)return Ht(),on;if(b+f>l)return Ht(),Qe;break;case 4:case 3:if(v<0)return Ht(),Tn;if(v+n>c)return Ht(),fi}return g=(b+f/2)/l,i=(v+n/2)/c,g+i<=1&&g-i<=0?(Ht(),on):g+i>=1&&g-i>=0?(Ht(),Qe):i<.5?(Ht(),Tn):(Ht(),fi)}function yht(t,e,n){var i,r,c,l;if(e[0]>=t.length)return n.o=0,!0;switch(t.charCodeAt(e[0])){case 43:r=1;break;case 45:r=-1;break;default:return n.o=0,!0}if(++e[0],c=e[0],l=y7(t,e),l==0&&e[0]==c)return!1;if(e[0]=14&&n<=16));case 11:return e!=null&&typeof e===sZ;case 12:return e!=null&&(typeof e===NP||typeof e==sZ);case 0:return Bq(e,t.__elementTypeId$);case 2:return v$(e)&&e.sl!==B;case 1:return v$(e)&&e.sl!==B||Bq(e,t.__elementTypeId$);default:return!0}}function q2(t,e){var n,i,r,c,l,f;if(t.j==(Ke(),bu)&&(n=Iat(wo(a(z(t,(Ft(),UB)),15).xc(),new j8(new SS))).a==null?(Tu(),aI):e,Ct(t,bx,n),n!=(Tu(),cg)))for(i=a(z(t,li),14),f=lt(Yt(z(i,(qt(),up)))),l=0,n==kd?l=t.n.b-y.Math.ceil(f/2):n==aI&&(t.n.b-=lt(Yt(z(Mc(t),N6))),l=(t.n.b-y.Math.ceil(f))/2),c=new H(t.i);c.a0&&(qL(g,!1,(Js(),ah)),qL(g,!0,uh)),pd(e.g,new CMt(t,n)),wr(t.g,e,n)}function Qve(t,e){var n,i,r,c,l,f,g;for(c=0,f=0,g=0,r=new H(t.f.e);r.a0&&t.d!=(dC(),HK)&&(f+=l*(i.d.a+t.a[e.b][i.b]*(e.d.a-i.d.a)/n)),n>0&&t.d!=(dC(),zK)&&(g+=l*(i.d.b+t.a[e.b][i.b]*(e.d.b-i.d.b)/n)));switch(t.d.g){case 1:return new We(f/c,e.d.b);case 2:return new We(e.d.a,g/c);default:return new We(f/c,g/c)}}function Eht(t){S6t();var e,n,i,r,c,l,f,g,b,v;for(this.b=new v3,this.c=new Nt,this.a=new Nt,g=KV(),b=0,v=g.length;b0){for(l=0;l>16==-15&&t.Cb.Hg()&&vV(new gV(t.Cb,9,13,n,t.c,Hp(Ya(a(t.Cb,53)),t))):ct(t.Cb,96)&&t.Db>>16==-23&&t.Cb.Hg()&&(e=t.c,ct(e,96)||(e=(ye(),gh)),ct(n,96)||(n=(ye(),gh)),vV(new gV(t.Cb,9,10,n,e,Hp(kc(a(t.Cb,24)),t)))))),t.c}function sw(t){Ai();var e,n,i,r,c;if(t.e!=4&&t.e!=5)throw K(new yn("Token#complementRanges(): must be RANGE: "+t.e));for(__(t),o4(t),i=t.b.length+2,t.b[0]==0&&(i-=2),n=t.b[t.b.length-1],n==_E&&(i-=2),r=(++Ar,new Eu(4)),r.b=dt(Gn,pi,22,i,15,1),c=0,t.b[0]>0&&(r.b[c++]=0,r.b[c++]=t.b[0]-1),e=1;e=65;n--)af[n]=n-65<<24>>24;for(i=122;i>=97;i--)af[i]=i-97+26<<24>>24;for(r=57;r>=48;r--)af[r]=r-48+52<<24>>24;for(af[43]=62,af[47]=63,c=0;c<=25;c++)t1[c]=65+c&qr;for(l=26,g=0;l<=51;++l,g++)t1[l]=97+g&qr;for(t=52,f=0;t<=61;++t,f++)t1[t]=48+f&qr;t1[62]=43,t1[63]=47}function r_e(t,e){var n,i,r,c,l,f,g,b,v,M;if(l=t.d,v=a(z(t,(Ft(),vx)),15),M=0,v){for(g=0,c=v.tc();c.hc();)r=a(c.ic(),8),g=y.Math.max(g,r.n.b),M+=r.n.a;M+=e/2*(v._b()-1),l.d+=g+e}if(n=a(z(t,px),15),i=0,n){for(g=0,c=n.tc();c.hc();)r=a(c.ic(),8),g=y.Math.max(g,r.n.b),i+=r.n.a;i+=e/2*(n._b()-1),l.a+=g+e}f=y.Math.max(M,i),f>t.n.a&&(b=(f-t.n.a)/2,l.b=y.Math.max(l.b,b),l.c=y.Math.max(l.c,b))}function s_e(t){var e,n,i,r,c,l,f;for(t.o=new LG,i=new Fr,l=new H(t.e.a);l.a0,f=KN(e,c),Zrt(n?f.b:f.g,e),l_(f).c.length==1&&Ws(i,f,i.c.b,i.c),r=new zs(c,e),REt(t.o,r),Lc(t.e.a,c))}function GNt(t,e){var n,i,r,c,l;for(e.d?r=t.a.c==(Sf(),Ym)?Rs(e.b):br(e.b):r=t.a.c==(Sf(),Xp)?Rs(e.b):br(e.b),c=!1,i=(Ao(),new $d(id(Zd(r.a,new X))));Jn(i);)if(n=a(In(i),14),l=lt(t.a.f[t.a.g[e.b.o].o]),!(!l&&!ec(n)&&n.c.g.c==n.d.g.c)&&!(lt(t.a.n[t.a.g[e.b.o].o])||lt(t.a.n[t.a.g[e.b.o].o]))&&(c=!0,ET(t.b,t.a.g[Fde(n,e.b).o])))return e.c=!0,e.a=n,e;return e.c=c,e.a=null,e}function Aht(t,e){var n,i,r,c,l,f,g;if(!Tf(t))throw K(new yc(_Ft));if(i=Tf(t),c=i.g,r=i.f,c<=0&&r<=0)return Ht(),Wc;switch(f=t.i,g=t.j,e.g){case 2:case 1:if(f<0)return Ht(),on;if(f+t.g>c)return Ht(),Qe;break;case 4:case 3:if(g<0)return Ht(),Tn;if(g+t.f>r)return Ht(),fi}return l=(f+t.g/2)/c,n=(g+t.f/2)/r,l+n<=1&&l-n<=0?(Ht(),on):l+n>=1&&l-n>=0?(Ht(),Qe):n<.5?(Ht(),Tn):(Ht(),fi)}function o_e(t,e){var n,i,r,c,l,f,g,b,v,M,k,R;if(t.Wb())return new go;for(b=0,M=0,r=t.tc();r.hc();)i=a(r.ic(),31),c=i.e,b=y.Math.max(b,c.a),M+=c.a*c.b;for(b=y.Math.max(b,y.Math.sqrt(M)*lt(Yt(z(a(t.tc().ic(),31),(qt(),zB))))),k=0,R=0,g=0,n=e,f=t.tc();f.hc();)l=a(f.ic(),31),v=l.e,k+v.a>b&&(k=0,R+=g+e,g=0),TP(l,k,R),n=y.Math.max(n,k+v.a),g=y.Math.max(g,v.b),k+=v.a+e;return new We(n+e,R+g+e)}function FX(t,e,n){var i,r,c,l,f,g,b,v;if(i=n._b(),i==0)return!1;if(t.ti())if(b=t.ui(),p8t(t,e,n),l=i==1?t.mi(3,null,n.tc().ic(),e,b):t.mi(5,null,n,e,b),t.qi()){for(f=i<100?null:new b1(i),c=e+i,r=e;r1)for(i=qn(r,0);i.b!=i.d.c;)for(n=a(Yn(i),202),c=0,g=new H(n.e);g.af?1:-1:Dat(t.a,e.a,c),r==-1)M=-g,v=l==g?sV(e.a,f,t.a,c):aV(e.a,f,t.a,c);else if(M=l,l==g){if(r==0)return $1(),EE;v=sV(t.a,c,e.a,f)}else v=aV(t.a,c,e.a,f);return b=new Wv(M,v.length,v),oC(b),b}function qNt(t){YM();var e,n,i,r;if(e=Tr(t),t1e6)throw K(new v9("power of ten too big"));if(t<=qi)return A2(bP(lx[1],e),e);for(i=bP(lx[1],qi),r=i,n=Ka(t-qi),e=Tr(t%qi);Pc(n,qi)>0;)r=Kv(r,i),n=Zg(n,qi);for(r=Kv(r,bP(lx[1],e)),r=A2(r,qi),n=Ka(t-qi);Pc(n,qi)>0;)r=A2(r,qi),n=Zg(n,qi);return r=A2(r,e),r}function l_e(t,e){var n,i,r,c,l,f,g,b,v,M,k,R,O,$,W;n=am(new Dg,t.f),b=t.i[e.c.g.o],R=t.i[e.d.g.o],g=e.c,k=e.d,f=g.a.b,M=k.a.b,b.b||(f+=g.k.b),R.b||(M+=k.k.b),v=Tr(y.Math.max(0,f-M)),l=Tr(y.Math.max(0,M-f)),O=($=Mh(1,a(z(e,(qt(),xx)),21).a),W=dct(e.c.g.j,e.d.g.j),$*W),r=ih($l(Wl(Gl(Vl(new cl,O),l),n),a(zi(t.k,e.c),113))),c=ih($l(Wl(Gl(Vl(new cl,O),v),n),a(zi(t.k,e.d),113))),i=new kMt(r,c),t.c[e.o]=i}function zX(t){var e,n,i,r,c,l,f,g,b,v,M,k,R;if(n=t.i,e=t.n,t.b==0)for(R=n.c+e.b,k=n.b-e.b-e.c,l=t.a,g=0,v=l.length;g0&&(M-=i[0]+t.c,i[0]+=t.c),i[2]>0&&(M-=i[2]+t.c),i[1]=y.Math.max(i[1],M),UD(t.a[1],n.c+e.b+i[0]-(i[1]-M)/2,i[1]);for(c=t.a,f=0,b=c.length;f0&&(e[0]+=t.c,M-=e[0]),e[2]>0&&(M-=e[2]+t.c),e[1]=y.Math.max(e[1],M),FD(t.a[1],i.d+n.d+e[0]-(e[1]-M)/2,e[1]);else for(O=i.d+n.d,R=i.a-n.d-n.a,l=t.a,g=0,v=l.length;g>>0).toString(16),n="\\x"+$h(e,e.length-2,e.length)):t>=ao?(e="0"+(t>>>0).toString(16),n="\\v"+$h(e,e.length-6,e.length)):n=""+String.fromCharCode(t&qr)}return n}function kht(t){var e,n,i,r,c,l;for(Ort(this),n=t._b()-1;n<3;n++)t.bd(0,a(t.cd(0),9));if(t._b()<4)throw K(new yn("At (least dimension + 1) control points are necessary!"));for(this.c=3,this.e=!0,this.f=!0,this.d=!1,Bme(this,t._b()+this.c-1),l=new Nt,c=this.g.tc(),e=0;e=0&&c!=n))throw K(new yn(i6));for(r=0,g=0;glt(Wh(l.g,l.d[0]).a)?(Hn(g.b>0),g.a.cd(g.c=--g.b),cd(g,l),r=!0):f.e&&f.e._b()>0&&(c=(!f.e&&(f.e=new Nt),f.e).vc(e),b=(!f.e&&(f.e=new Nt),f.e).vc(n),(c||b)&&((!f.e&&(f.e=new Nt),f.e).nc(l),++l.c));r||(i.c[i.c.length]=l)}function g_e(t,e,n){var i,r,c,l,f,g;for(i=0,c=new $n((!t.a&&(t.a=new Wt(zr,t,10,11)),t.a));c.e!=c.i._b();)r=a(ci(c),35),l="",(!r.n&&(r.n=new Wt(ic,r,1,7)),r.n).i==0||(l=a(a(at((!r.n&&(r.n=new Wt(ic,r,1,7)),r.n),0),137),263).a),f=new t4t(l),Uo(f,r),Ct(f,(I1(),hx),r),f.b=i++,f.d.a=r.i+r.g/2,f.d.b=r.j+r.f/2,f.e.a=y.Math.max(r.g,1),f.e.b=y.Math.max(r.f,1),Ut(e.e,f),Cu(n.d,r,f),g=a(cn(r,(Ph(),Tgt)),83),g==(Ls(),ib)}function m_e(t,e,n,i){var r,c,l,f,g,b,v;if(n.c.g!=e.g)for(r=new Jh(t),jl(r,(Ke(),Hr)),Ct(r,(Ft(),li),n),Ct(r,(qt(),Qi),(Ls(),Gc)),i.c[i.c.length]=r,l=new Eo,ds(l,r),yr(l,(Ht(),on)),f=new Eo,ds(f,r),yr(f,Qe),Ts(n,l),c=new Np,Uo(c,n),Ct(c,Ro,null),Hs(c,f),Ts(c,e),V9t(r,l,f),b=new Gs(n.b,0);b.b0&&(g=f/60|0,b=f%60,r=t.q.getDate(),n=t.q.getHours(),n+g>=24&&++r,c=new y.Date(t.q.getFullYear(),t.q.getMonth(),r,e+g,t.q.getMinutes()+b,t.q.getSeconds(),t.q.getMilliseconds()),t.q.setTime(c.getTime()))),l=t.q.getTime(),t.q.setTime(l+36e5),t.q.getHours()!=e&&t.q.setTime(l)}function b_e(t,e){var n,i,r,c,l,f,g,b,v;for(di(e,"Layer constraint edge reversal",1),l=new H(t.b);l.an){Vn(e);return}switch(a(z(t,(qt(),VJ)),319).g){case 2:c=new Fc;break;case 0:c=new Bd;break;default:c=new mf}if(i=c.sf(t,r),!c.tf())switch(a(z(t,mbt),347).g){case 2:i=W_e(r,i);break;case 1:i=B1e(r,i)}aye(t,r,i),Vn(e)}function YNt(t,e,n){var i,r,c,l;return t.ti()?(r=null,c=t.ui(),i=t.mi(1,l=xV(t,e,n),n,e,c),t.qi()&&!(t.Bh()&&l!=null?Fi(l,n):zt(l)===zt(n))?(l!=null&&(r=t.si(l,null)),r=t.ri(n,r),t.xi()&&(r=t.Ai(l,n,r)),r?(r.Sh(i),r.Th()):t.ni(i)):(t.xi()&&(r=t.Ai(l,n,null)),r?(r.Sh(i),r.Th()):t.ni(i)),l):(l=xV(t,e,n),t.qi()&&!(t.Bh()&&l!=null?Fi(l,n):zt(l)===zt(n))&&(r=null,l!=null&&(r=t.si(l,null)),r=t.ri(n,r),r&&r.Th()),l)}function GX(t){var e,n,i,r,c,l,f;if(!t.d){if(f=new PR,e=TA,c=e.a.Zb(t,e),c==null){for(i=new $n(Bo(t));i.e!=i.i._b();)n=a(ci(i),24),Lr(f,GX(n));e.a.$b(t)!=null,e.a._b()==0}for(l=f.i,r=(!t.q&&(t.q=new Wt(ph,t,11,10)),new $n(t.q));r.e!=r.i._b();++l)a(ci(r),371);Lr(f,(!t.q&&(t.q=new Wt(ph,t,11,10)),t.q)),Yb(f),t.d=new Ov((a(at(Et((S1(),Ae).o),9),17),f.i),f.g),t.e=a(f.g,611),t.e==null&&(t.e=Xqt),pl(t).b&=-17}return t.d}function i4(t,e,n,i){var r,c,l,f,g,b;if(b=gu(t.e.mg(),e),g=0,r=a(t.g,124),Jo(),a(e,61).bj()){for(l=0;l1&&(g>Wu(f)*Sh(f)/2||l.b==0)&&(M=new PN(k),v=Wu(f)/Sh(f),b=iZ(M,e,new r2,n,i,r,v),sr(Gh(M.e),b),f=M,R.c[R.c.length]=M,g=0,k.c=dt(un,te,1,0,5,1)));return Or(R,k),R}function y_e(t,e){var n,i,r,c,l,f,g,b,v;for(di(e,"Hierarchical port dummy size processing",1),g=new Nt,v=new Nt,i=lt(Yt(z(t,(qt(),Mx)))),n=i*2,c=new H(t.b);c.a=W&&t.e[g.o]>O*t.b||pt>=n*W)&&(k.c[k.c.length]=f,f=new Nt,yo(l,c),c.a.Pb(),b-=v,R=y.Math.max(R,b*t.b+$),b+=pt,rt=pt,pt=0,v=0,$=0);return new zs(R,k)}function E_e(t){var e,n,i,r,c,l,f,g,b,v,M,k;for(e=W9t(t),v=(f=new xv(e).a.Tb().tc(),new f5(f));v.a.hc();){for(b=(r=a(v.a.ic(),38),a(r.kc(),8)),M=b.d.d,k=b.n.b+b.d.a,t.d[b.o]=0,n=b;(c=t.a[n.o])!=b;)i=phe(n,c),t.c==(Sf(),Xp)?g=i.d.k.b+i.d.a.b-i.c.k.b-i.c.a.b:g=i.c.k.b+i.c.a.b-i.d.k.b-i.d.a.b,l=lt(t.d[n.o])+g,t.d[c.o]=l,M=y.Math.max(M,c.d.d-l),k=y.Math.max(k,l+c.n.b+c.d.a),n=c;n=b;do t.d[n.o]=lt(t.d[n.o])+M,n=t.a[n.o];while(n!=b);t.b[b.o]=M+k}}function Lht(t,e,n){var i,r,c,l,f,g,b,v,M,k;for(_6t(this),n==(mm(),rg)?Ir(this.o,t):Ir(this.t,t),v=is,b=Ps,l=e.a.Xb().tc();l.hc();)r=a(l.ic(),48),f=a(r.a,417),i=a(r.b,14),g=i.c,g==t&&(g=i.d),f==rg?Ir(this.o,g):Ir(this.t,g),k=zo(Y(Z(ss,1),wt,9,0,[g.g.k,g.k,g.a])).b,v=y.Math.min(v,k),b=y.Math.max(b,k);for(M=zo(Y(Z(ss,1),wt,9,0,[t.g.k,t.k,t.a])).b,A8t(this,M,v,b),c=e.a.Xb().tc();c.hc();)r=a(c.ic(),48),I9t(this,a(r.b,14));this.k=!1}function S_e(t){var e,n,i,r;if(i=rZ((!t.c&&(t.c=XL(t.f)),t.c),0),t.e==0||t.a==0&&t.f!=-1&&t.e<0)return i;if(e=Yct(t)<0?1:0,n=t.e,r=(i.length+1+X3(Tr(t.e)),new Db),e==1&&(r.a+="-"),t.e>0)if(n-=i.length-e,n>=0){for(r.a+="0.";n>m0.length;n-=m0.length)JTt(r,m0);OSt(r,m0,Tr(n)),Ii(r,i.substr(e,i.length-e))}else n=e-n,Ii(r,$h(i,e,Tr(n))),r.a+=".",Ii(r,oL(i,Tr(n)));else{for(Ii(r,i.substr(e,i.length-e));n<-m0.length;n+=m0.length)JTt(r,m0);OSt(r,m0,Tr(-n))}return r.a}function Hc(t,e){var n,i,r,c,l,f,g;if(t==null)return null;if(c=t.length,c==0)return"";for(g=dt(el,Pf,22,c,15,1),Pct(0,c,t.length),Pct(0,c,g.length),UCt(t,0,c,g,0),n=null,f=e,r=0,l=0;r0?$h(n.a,0,c-1):""):t.substr(0,c-1):n?n.a:t}function T_e(t){var e,n,i,r,c,l,f,g,b,v,M,k,R;for(n=(b=new vf(t.c.b).a.Tb().tc(),new Q0(b));n.a.hc();)e=(f=a(n.a.ic(),38),a(f.lc(),180)),r=e.a,r==null&&(r=""),i=ene(t.c,r),!i&&r.length==0&&(i=ghe(t)),i&&!O2(i.c,e,!1)&&Xi(i.c,e);for(l=qn(t.a,0);l.b!=l.d.c;)c=a(Yn(l),436),v=_ct(t.c,c.a),R=_ct(t.c,c.b),v&&R&&Xi(v.c,new zs(R,c.c));for(ld(t.a),k=qn(t.b,0);k.b!=k.d.c;)M=a(Yn(k),436),e=tne(t.c,M.a),g=_ct(t.c,M.b),e&&g&&tte(e,g,M.c);ld(t.b)}function C_e(t,e,n){var i,r,c,l,f,g,b,v,M;for(g=n+e.c.c.a,M=new H(e.i);M.a1,f=new Up(v.c);Qo(f.a)||Qo(f.b);)l=a(Qo(f.a)?G(f.a):G(f.b),14),b=l.c==v?l.d:l.c,y.Math.abs(zo(Y(Z(ss,1),wt,9,0,[b.g.k,b.k,b.a])).b-c.b)>1&&Nbe(t,l,c,r,v)}}function s4(t){var e,n,i,r,c,l,f,g;if(!t.f){if(g=new LR,f=new LR,e=TA,l=e.a.Zb(t,e),l==null){for(c=new $n(Bo(t));c.e!=c.i._b();)r=a(ci(c),24),Lr(g,s4(r));e.a.$b(t)!=null,e.a._b()==0}for(i=(!t.s&&(t.s=new Wt(Ra,t,21,17)),new $n(t.s));i.e!=i.i._b();)n=a(ci(i),158),ct(n,62)&&ni(f,a(n,17));Yb(f),t.r=new iCt(t,(a(at(Et((S1(),Ae).o),6),17),f.i),f.g),Lr(g,t.r),Yb(g),t.f=new Ov((a(at(Et(Ae.o),5),17),g.i),g.g),pl(t).b&=-3}return t.f}function A_e(t){var e,n,i,r,c,l,f,g,b,v,M,k,R,O;for(l=t.o,i=dt(Gn,pi,22,l,15,1),r=dt(Gn,pi,22,l,15,1),n=t.p,e=dt(Gn,pi,22,n,15,1),c=dt(Gn,pi,22,n,15,1),b=0;b=0&&!h_(t,v,M);)--M;r[v]=M}for(R=0;R=0&&!h_(t,f,O);)--f;c[O]=f}for(g=0;ge[k]&&ki[g]&&F7(t,g,k,!1,!0)}function H7(){H7=P,Ovt=Y(Z(el,1),Pf,22,15,[48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70]),Sqt=new RegExp(`[ -\r\f]+`);try{MA=Y(Z(q3e,1),te,1699,0,[new Qy((grt(),n7("yyyy-MM-dd'T'HH:mm:ss'.'SSSZ",rL((Hh(),Hh(),R4))))),new Qy(n7("yyyy-MM-dd'T'HH:mm:ss'.'SSS",rL(R4))),new Qy(n7("yyyy-MM-dd'T'HH:mm:ss",rL(R4))),new Qy(n7("yyyy-MM-dd'T'HH:mm",rL(R4))),new Qy(n7("yyyy-MM-dd",rL(R4)))])}catch(t){if(t=vr(t),!ct(t,78))throw K(t)}}function KNt(t,e){var n,i,r,c,l;switch(c=new Va,t.a.g){case 1:case 3:yo(c,e.e.a),Xi(c,e.i.k),yo(c,Em(e.j.a)),Xi(c,e.a.k),yo(c,e.f.a);break;default:yo(c,e.e.a),yo(c,Em(e.j.a)),yo(c,e.f.a)}ld(e.f.a),yo(e.f.a,c),Hs(e.f,e.e.c),n=a(z(e.e,(qt(),Ro)),74),r=a(z(e.j,Ro),74),i=a(z(e.f,Ro),74),(n||r||i)&&(l=new Va,xot(l,i),xot(l,r),xot(l,n),Ct(e.f,Ro,l)),Hs(e.j,null),Ts(e.j,null),Hs(e.e,null),Ts(e.e,null),Ks(e.a,null),Ks(e.i,null),e.g&&KNt(t,e.g)}function JNt(t){h2(t,new b_(u2(o2(a2(c2(new V0,o0),"ELK DisCo"),"Layouter for arranging unconnected subgraphs. The subgraphs themselves are, by default, not laid out."),new Bs))),pe(t,o0,YZ,Xe(_gt)),pe(t,o0,KZ,Xe(DK)),pe(t,o0,cE,Xe(rjt)),pe(t,o0,ex,Xe(vgt)),pe(t,o0,mft,Xe(ajt)),pe(t,o0,bft,Xe(cjt)),pe(t,o0,gft,Xe(ujt)),pe(t,o0,wft,Xe(ojt)),pe(t,o0,_ft,Xe(sjt)),pe(t,o0,yft,Xe(RK)),pe(t,o0,xft,Xe(wgt)),pe(t,o0,Mft,Xe(rB))}function k_e(t,e,n){var i,r,c,l,f,g,b,v,M;for(l=new qRt,b=Y(Z(Gn,1),pi,22,15,[0]),r=-1,c=0,i=0,g=0;g0){if(r<0&&v.a&&(r=g,c=b[0],i=0),r>=0){if(f=v.b,g==r&&(f-=i++,f==0))return 0;if(!Q7t(e,b,v,f,l)){g=r-1,b[0]=c;continue}}else if(r=-1,!Q7t(e,b,v,0,l))return 0}else{if(r=-1,v.c.charCodeAt(0)==32){if(M=b[0],ALt(e,b),b[0]>M)continue}else if(Hse(e,v.c,b[0])){b[0]+=v.c.length;continue}return 0}return exe(l,n)?b[0]:0}function L_e(t,e,n){var i,r,c,l,f;if(i=a(z(t,(qt(),FJ)),19),n.a>e.a&&(i.pc((qM(),xB))?t.c.a+=(n.a-e.a)/2:i.pc(MB)&&(t.c.a+=n.a-e.a)),n.b>e.b&&(i.pc((qM(),SB))?t.c.b+=(n.b-e.b)/2:i.pc(EB)&&(t.c.b+=n.b-e.b)),a(z(t,(Ft(),Qc)),19).pc((So(),Al))&&(n.a>e.a||n.b>e.b))for(f=new H(t.a);f.ae.a&&(i.pc((qM(),xB))?t.c.a+=(n.a-e.a)/2:i.pc(MB)&&(t.c.a+=n.a-e.a)),n.b>e.b&&(i.pc((qM(),SB))?t.c.b+=(n.b-e.b)/2:i.pc(EB)&&(t.c.b+=n.b-e.b)),a(z(t,(Ft(),Qc)),19).pc((So(),Al))&&(n.a>e.a||n.b>e.b))for(l=new H(t.a);l.aR||i+r>b)throw K(new d9);if(!(M.i&1)&&k!=g)if(v=e_(t),c=e_(n),zt(t)===zt(n)&&ei;)Vr(c,f,v[--e]);else for(f=i+r;i0&&Rut(t,e,n,i,r,!0)}function R_e(t,e,n){var i,r,c,l,f,g,b,v,M,k;for(v=new HD(new Sv(n)),f=dt(Ol,c0,22,t.f.e.c.length,16,1),wot(f,f.length),n[e.b]=0,b=new H(t.f.e);b.a=t.b.length?(c[r++]=l.b[i++],c[r++]=l.b[i++]):i>=l.b.length?(c[r++]=t.b[n++],c[r++]=t.b[n++]):l.b[i]=f?aV(t.a,c,e.a,f):aV(e.a,f,t.a,c);else{if(r=c!=f?c>f?1:-1:Dat(t.a,e.a,c),r==0)return $1(),EE;r==1?(k=l,M=sV(t.a,c,e.a,f)):(k=g,M=sV(e.a,f,t.a,c))}return b=new Wv(k,M.length,M),oC(b),b}function e7t(t,e){var n,i,r,c,l,f;for(l=new Vg(new xp(t.f.b).a);l.b;){if(c=xm(l),r=a(c.kc(),536),e==1){if(r.Je()!=(Js(),og)&&r.Je()!=fp)continue}else if(r.Je()!=(Js(),ah)&&r.Je()!=uh)continue;switch(i=a(a(c.lc(),48).b,80),f=a(a(c.lc(),48).a,172),n=f.c,r.Je().g){case 2:i.g.c=t.e.a,i.g.b=y.Math.max(1,i.g.b+n);break;case 1:i.g.c=i.g.c+n,i.g.b=y.Math.max(1,i.g.b-n);break;case 4:i.g.d=t.e.b,i.g.a=y.Math.max(1,i.g.a+n);break;case 3:i.g.d=i.g.d+n,i.g.a=y.Math.max(1,i.g.a-n)}}}function n7t(t,e,n,i){var r,c,l,f,g,b,v;if(c=ZN(i),f=lt(de(z(i,(qt(),Kmt)))),(f||lt(de(z(t,$B))))&&!Gd(a(z(t,Qi),83)))r=nP(c),g=xht(t,n,n==(Fo(),ba)?r:tP(r));else switch(g=new Eo,ds(g,t),e?(v=g.k,v.a=e.a-t.k.a,v.b=e.b-t.k.b,O8t(v,0,0,t.n.a,t.n.b),yr(g,FNt(g,c))):(r=nP(c),yr(g,n==(Fo(),ba)?r:tP(r))),l=a(z(i,(Ft(),Qc)),19),b=g.i,c.g){case 2:case 1:(b==(Ht(),Tn)||b==fi)&&l.nc((So(),Z_));break;case 4:case 3:(b==(Ht(),Qe)||b==on)&&l.nc((So(),Z_))}return g}function B_e(t,e){var n,i,r,c,l,f,g,b,v,M,k,R,O,$;for(f=dt(Gn,pi,22,e.b.c.length,15,1),b=dt(qK,jt,232,e.b.c.length,0,1),g=dt(Cl,Ih,8,e.b.c.length,0,1),M=t.a,k=0,R=M.length;k0&&g[i]&&(O=Uv(t.b,g[i],r)),$=y.Math.max($,r.c.c.b+O);for(c=new H(v.f);c.a"}g!=null&&(e.a+=""+g)}else t.e?(f=t.e.zb,f!=null&&(e.a+=""+f)):(e.a+="?",t.b?(e.a+=" super ",XX(t.b,e)):t.f&&(e.a+=" extends ",XX(t.f,e)))}function F_e(t,e){var n,i,r,c,l,f,g,b;for(t.f=e,t.d=a(z(t.f,(BL(),kgt)),348),t.g=a(z(t.f,Rgt),21).a,t.e=lt(Yt(z(t.f,Lgt))),t.c=lt(Yt(z(t.f,lB))),M$(t.b),i=new H(t.f.c);i.a=0)return!1;if(n.e&&r==(Ke(),Jc)&&r!=n.e)return!1;if(e.o=n.b,Ut(n.f,e),n.e=r,r==(Ke(),Hr)||r==uc||r==Jc){for(l=new H(e.i);l.a0&&i<=r?(b-=i,c=f,l=f):(t.a==null&&uX(t),t.a[l]&&(b+=r,c=l)),c>0){Ut(M,Xt(c)),f=-1,v=!1;do if(n.hc())g=Xt(a(n.ic(),21).a+b);else break t;while(g.a<=l)}}else if(t.a==null&&uX(t),t.a[l]&&(f=l),l==g.a)if(t.a==null&&uX(t),t.a[l])if(M.c[M.c.length]=g,f=-1,n.hc())g=Xt(a(n.ic(),21).a+b);else break;else v=!0;++l}return M}function s7t(t){var e,n,i,r;return t.Db&64?vq(t):(e=new ll(ypt),i=t.k,i?Ii(Ii((e.a+=' "',e),i),'"'):(!t.n&&(t.n=new Wt(ic,t,1,7)),t.n.i>0&&(r=(!t.n&&(t.n=new Wt(ic,t,1,7)),a(a(at(t.n,0),137),263)).a,!r||Ii(Ii((e.a+=' "',e),r),'"'))),n=(!t.b&&(t.b=new pn(Si,t,4,7)),!(t.b.i<=1&&(!t.c&&(t.c=new pn(Si,t,5,8)),t.c.i<=1))),n?e.a+=" [":e.a+=" ",Ii(e,DW(new A5(Rc),new $n(t.b))),n&&(e.a+="]"),e.a+=" -> ",n&&(e.a+="["),Ii(e,DW(new A5(Rc),new $n(t.c))),n&&(e.a+="]"),e.a)}function $_e(t){var e,n,i,r,c,l;for(r=new Nt,l=new H(t.c.i);l.at.n.b||(n=ac(t,Qe),f=e.d+e.a+(n._b()-1)*l,f>t.n.b)))}function JX(t,e,n){var i,r,c,l,f,g,b,v;return i=t.a.o==(Zh(),rf)?is:Ps,f=GNt(t,new DMt(e,n)),!f.a&&f.c?(Xi(t.c,f),i):f.a?(r=f.a.c,g=f.a.d,n?(b=t.a.c==(Sf(),Ym)?g:r,c=t.a.c==Ym?r:g,l=t.a.g[c.g.o],v=lt(t.a.p[l.o])+lt(t.a.d[c.g.o])+c.k.b+c.a.b-lt(t.a.d[b.g.o])-b.k.b-b.a.b):(b=t.a.c==(Sf(),Xp)?g:r,c=t.a.c==Xp?r:g,v=lt(t.a.p[t.a.g[c.g.o].o])+lt(t.a.d[c.g.o])+c.k.b+c.a.b-lt(t.a.d[b.g.o])-b.k.b-b.a.b),t.a.n[t.a.g[r.g.o].o]=(me(),me(),!0),t.a.n[t.a.g[g.g.o].o]=!0,v):i}function QX(t,e,n,i,r,c,l){var f,g,b,v,M,k,R;return M=lt(de(z(e,(qt(),Jmt)))),k=null,c==(Fo(),Ga)&&i.c.g==n?k=i.c:c==ba&&i.d.g==n&&(k=i.d),b=l,!l||!M||k?(v=(Ht(),Wc),k?v=k.i:Gd(a(z(n,Qi),83))&&(v=c==Ga?on:Qe),g=sye(t,e,n,c,v,i),f=cV((Mc(n),i)),c==Ga?(Hs(f,a(Ee(g.i,0),11)),Ts(f,r)):(Hs(f,r),Ts(f,a(Ee(g.i,0),11))),b=new V6t(i,f,g,a(z(g,(Ft(),li)),11),c,!k)):(Ut(l.e,i),R=y.Math.max(lt(Yt(z(l.d,up))),lt(Yt(z(i,up)))),Ct(l.d,up,R)),cr(t.a,i,new xD(b.d,e,c)),b}function c7t(t,e){var n,i,r,c,l,f,g,b,v,M;if(Ct(e,(mc(),DE),0),g=a(z(e,lF),76),e.d.b==0)g?(v=lt(Yt(z(g,Kp)))+t.a+yct(g,e),Ct(e,Kp,v)):Ct(e,Kp,0);else{for(i=(c=qn(new Hd(e).a.d,0),new Rb(c));A9(i.a);)n=a(Yn(i.a),170).c,c7t(t,n);f=a(bD((l=qn(new Hd(e).a.d,0),new Rb(l))),76),M=a(Sne((r=qn(new Hd(e).a.d,0),new Rb(r))),76),b=(lt(Yt(z(M,Kp)))+lt(Yt(z(f,Kp))))/2,g?(v=lt(Yt(z(g,Kp)))+t.a+yct(g,e),Ct(e,Kp,v),Ct(e,DE,lt(Yt(z(e,Kp)))-b),Kye(t,e)):Ct(e,Kp,b)}}function X_e(t,e){var n,i,r,c,l,f,g,b,v;if(b=a(z(t,(Ft(),wc)),69),i=a(Ee(t.i,0),11),b==(Ht(),Tn)?yr(i,fi):b==fi&&yr(i,Tn),a(z(e,(qt(),yw)),185).pc((Ku(),M0))){if(g=lt(Yt(z(t,J4))),l=lt(Yt(z(t,Ex))),f=a(z(e,yx),275),f==(Kh(),rb))for(n=g,v=t.n.a/2-i.k.a,c=new H(i.e);c.a0&&i>=-6?i>=0?bL(c,n-Tr(t.e),"."):(c.a=$h(c.a,0,e-1)+"0."+oL(c.a,e-1),bL(c,e+1,ml(m0,0,-Tr(i)-1))):(n-e>=1&&(bL(c,e,"."),++n),bL(c,n,"E"),i>0&&bL(c,++n,"+"),bL(c,++n,""+ID(Ka(i)))),t.g=c.a,t.g))}function u7t(t,e,n){var i,r,c,l;this.j=t,this.e=Elt(t),this.o=a(z(this.j,(Ft(),Q1)),8),this.i=!!this.o,this.p=this.i?a(Ee(n,Mc(this.o).o),204):null,r=a(z(t,Qc),19),this.g=r.pc((So(),Al)),this.b=new Nt,this.d=new TIt(this.e),l=a(z(this.j,PE),214),this.q=hle(e,l,this.e),this.k=new wAt(this),c=$g(Y(Z(eHt,1),te,208,0,[this,this.d,this.k,this.q])),e==(Mm(),eF)?(i=new t6t(this.e),c.c[c.c.length]=i,this.c=new tkt(i,l,a(this.q,422))):this.c=new AMt(e,this),Ut(c,this.c),o7t(c,this.e),this.s=Pxe(this.k)}function Y_e(t,e){var n,i,r,c;return n=new vn,i=a(hd(Vh(new gi(null,new Ei(t.f,16)),n),Jv(new ti,new Qn,new Kt,new kt,Y(Z(tf,1),jt,150,0,[(U1(),pw),Qh]))),19),r=i._b(),r=r==2?1:0,r==1&&Bb(eP(a(hd(wo(i.uc(),new he),RPt(Jg(0),new ki)),149).a,2),0)&&(r=0),i=a(hd(Vh(new gi(null,new Ei(e.f,16)),n),Jv(new ti,new Qn,new Kt,new kt,Y(Z(tf,1),jt,150,0,[pw,Qh]))),19),c=i._b(),c=c==2?1:0,c==1&&Bb(eP(a(hd(wo(i.uc(),new Mn),RPt(Jg(0),new ki)),149).a,2),0)&&(c=0),r=t.b[r+1])r+=2;else if(n0)for(i=new Eh(a(rr(t.a,c),19)),we(),gc(i,new W8(e)),r=new Gs(c.b,0);r.b=ao?mo(n,tut(i)):pM(n,i&qr),l=(++Ar,new $$(10,null,0)),$re(t.a,l,f-1)):(n=(l.ll().length+c,new mT),mo(n,l.ll())),e.e==0?(i=e.jl(),i>=ao?mo(n,tut(i)):pM(n,i&qr)):mo(n,e.ll()),a(l,474).b=n.a}}function nye(t,e){var n,i,r,c,l,f,g,b,v,M,k,R;if(di(e,"Edge splitting",1),t.b.c.length<=2){Vn(e);return}for(c=new Gs(t.b,0),l=(Hn(c.bIt)?(g=2,l=qi):g==0?(g=1,l=Zt):(g=0,l=Zt)):(R=Zt>=l||l-Zt0?(r=i+(O-1)*n,M&&(r+=i),r0){c7(t,n,0),n.a+=String.fromCharCode(i),r=xle(e,c),c7(t,n,r),c+=r-1;continue}i==39?c+10){if(e=new xrt(t.i,t.g),n=t.i,c=n<100?null:new b1(n),t.xi())for(i=0;i0){for(f=t.g,b=t.i,hC(t),c=b<100?null:new b1(b),i=0;i0)if(e=new bat(t.Uh()),r=g<100?null:new b1(g),nL(t,g,e.g),i=g==1?t.mi(4,at(e,0),null,0,f):t.mi(6,e,null,-1,f),t.qi()){for(n=new $n(e);n.e!=n.i._b();)r=t.si(ci(n),r);r?(r.Sh(i),r.Th()):t.ni(i)}else r?(r.Sh(i),r.Th()):t.ni(i);else nL(t,t.hi(),t.ii()),t.ni(t.mi(6,(we(),fo),null,-1,f));else if(t.qi())if(g=t.hi(),g>0){for(l=t.ii(),nL(t,g,l),r=g<100?null:new b1(g),n=0;n>13|(t.m&15)<<9,r=t.m>>4&8191,c=t.m>>17|(t.h&255)<<5,l=(t.h&1048320)>>8,f=e.l&8191,g=e.l>>13|(e.m&15)<<9,b=e.m>>4&8191,v=e.m>>17|(e.h&255)<<5,M=(e.h&1048320)>>8,ce=n*f,ae=i*f,Te=r*f,Me=c*f,Bn=l*f,g!=0&&(ae+=n*g,Te+=i*g,Me+=r*g,Bn+=c*g),b!=0&&(Te+=n*b,Me+=i*b,Bn+=r*b),v!=0&&(Me+=n*v,Bn+=i*v),M!=0&&(Bn+=n*M),R=ce&eu,O=(ae&511)<<13,k=R+O,W=ce>>22,nt=ae>>9,rt=(Te&262143)<<4,pt=(Me&31)<<17,$=W+nt+rt+pt,It=Te>>18,Gt=Me>>5,Zt=(Bn&4095)<<8,_t=It+Gt+Zt,$+=k>>22,k&=eu,_t+=$>>22,$&=eu,_t&=sp,ia(k,$,_t)}function f7t(t,e){var n,i,r,c,l;n=lt(Yt(z(e,(qt(),nf)))),n<2&&Ct(e,nf,2),i=a(z(e,ch),110),i==(Js(),Ff)&&Ct(e,ch,ZN(e)),r=a(z(e,qGt),21),r.a==0?Ct(e,(Ft(),PE),new Mq):Ct(e,(Ft(),PE),new cN(r.a)),c=de(z(e,Z4)),c==null&&Ct(e,Z4,(me(),zt(z(e,ng))===zt((gd(),UE)))),l=new B8t(e),Ct(e,(Ft(),ww),l),sct(t.a),Wb(t.a,(Mo(),Of),a(z(e,Omt),285)),Wb(t.a,fx,a(z(e,Ymt),285)),Wb(t.a,aa,a(z(e,IE),285)),Wb(t.a,ua,a(z(e,qB),285)),Wb(t.a,Yo,vle(a(z(e,ng),197))),DEt(t.a,Oxe(e)),Ct(e,RJ,Nht(t.a,e))}function d7t(t,e){var n,i,r,c,l,f,g,b,v,M;if(g=e.length-1,f=e.charCodeAt(g),f==93){if(l=Mf(e,Ca(91)),l>=0)return r=jhe(t,e.substr(1,l-1)),v=e.substr(l+1,g-(l+1)),xxe(t,v,r)}else{if(n=-1,/\d/.test(String.fromCharCode(f))&&(n=bst(e,Ca(46),g-1),n>=0)){i=a(Sct(t,wLt(t,e.substr(1,n-1)),!1),52);try{b=Au(e.substr(n+1,e.length-(n+1)),Vs,qi)}catch(k){throw k=vr(k),ct(k,118)?(c=k,K(new yN(c))):K(k)}if(b4)if(t.Li(e)){if(t.Dj()){if(r=a(e,42),i=r.ng(),g=i==t.e&&(t.Pj()?r.hg(r.og(),t.Lj())==t.Mj():-1-r.og()==t.pi()),t.Qj()&&!g&&!i&&r.sg()){for(c=0;c=W-1)return null;for(r=new Nt,r.c[r.c.length]=e,_t=e,l=n,O=-1,f=a(Ee(t.d.c.b,n),26),R=0;R1&&l0&&(b=t.k.a/c);break;case 2:case 4:r=t.g.n.b,r>0&&(b=t.k.b/r)}Ct(t,(Ft(),qm),b)}if(g=t.n,l=t.a,i)l.a=i.a,l.b=i.b,t.b=!0;else if(e!=dp&&e!=ib&&f!=Wc)switch(f.g){case 1:l.a=g.a/2;break;case 2:l.a=g.a,l.b=g.b/2;break;case 3:l.a=g.a/2,l.b=g.b;break;case 4:l.b=g.b/2}else l.a=g.a/2,l.b=g.b/2}function _ye(t,e,n){var i,r,c,l,f,g,b,v,M,k,R,O;for(di(n,bBt,1),t.c=e,k=t.c.a,c=0,b=new H(k);b.aO){for(R=1,r=f.n.a;r>l;)++R,r=(f.n.a-(R-1)*t.d)/R;Ut(i,new Fkt(t,f,R,r))}for(g=new H(i);g.a1&&Wu(l)*Sh(l)/2>f[0]){for(c=0;c<$.c.length-1&&Wu(l)*Sh(l)/2>f[c];)++c;O=new T1($,0,c+1),M=new PN(O),v=Wu(l)/Sh(l),g=iZ(M,e,new r2,n,i,r,v),sr(Gh(M.e),g),kM(XM(k,M)),R=new T1($,c+1,$.c.length),qct(k,R),$.c=dt(un,te,1,0,5,1),b=0,kCt(f,f.length,0)}else W=k.b.c.length==0?null:Ee(k.b,0),W!=null&&fat(k,0),b>0&&(f[b]=f[b-1]),f[b]+=Wu(l)*Sh(l),++b,$.c[$.c.length]=l;return $}function Nht(t,e){var n,i,r,c,l,f,g,b,v,M,k;if(t.e&&t.c.c.5?nt-=l*2*(O-.5):O<.5&&(nt+=c*2*(.5-O)),r=f.d.b,ntW.a-$-v&&(nt=W.a-$-v),f.k.a=e+nt}}function g7t(t,e){var n,i,r,c,l;for(l=new H(t.i);l.a0&&Z8t(t,f,M);for(r=new H(M);r.a0&&(t.a=g+(R-1)*c,e.c.b+=t.a,e.e.b+=t.a)),O.a._b()!=0&&(k=new aX(1,c),R=Pht(k,e,O,$,e.e.b+g-e.c.b),R>0&&(e.e.b+=g+(R-1)*c))}function Bht(t,e,n){var i,r,c,l,f,g;if(e.l==0&&e.m==0&&e.h==0)throw K(new v9("divide by zero"));if(t.l==0&&t.m==0&&t.h==0)return n&&(J1=ia(0,0,0)),ia(0,0,0);if(e.h==UP&&e.m==0&&e.l==0)return tfe(t,n);if(g=!1,e.h>>19&&(e=OM(e),g=!0),l=ube(e),c=!1,r=!1,i=!1,t.h==UP&&t.m==0&&t.l==0)if(r=!0,c=!0,l==-1)t=kEt((PM(),g1t)),i=!0,g=!g;else return f=zlt(t,l),g&&JV(f),n&&(J1=ia(0,0,0)),f;else t.h>>19&&(c=!0,t=OM(t),i=!0,g=!g);return l!=-1?Ole(t,l,g,c,n):Wut(t,e)<0?(n&&(c?J1=OM(t):J1=ia(t.l,t.m,t.h)),ia(0,0,0)):Rve(i?t:ia(t.l,t.m,t.h),e,g,c,r,n)}function Cye(t,e){var n,i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt;for(b=e.c,r=Rrt(t.e),M=hl(eL(Xc(Irt(t.e)),t.d*t.a,t.c*t.b),-.5),n=r.a-M.a,i=r.b-M.b,l=e.a,n=l.c-n,i=l.d-i,g=new H(b);g.a=0)return n;switch(gm(qo(t,n))){case 2:{if(le("",jp(t,n.Wi()).be())){if(g=pL(qo(t,n)),f=vM(qo(t,n)),v=Wlt(t,e,g,f),v)return v;for(r=bht(t,e),l=0,M=r._b();le.e||e.f>t.e)){for(n=0,i=0,l=t.t.a.Xb().tc();l.hc();)r=a(l.ic(),11),gq(zo(Y(Z(ss,1),wt,9,0,[r.g.k,r.k,r.a])).b,e.f,e.e)&&++n;for(f=t.o.a.Xb().tc();f.hc();)r=a(f.ic(),11),gq(zo(Y(Z(ss,1),wt,9,0,[r.g.k,r.k,r.a])).b,e.f,e.e)&&--n;for(g=e.t.a.Xb().tc();g.hc();)r=a(g.ic(),11),gq(zo(Y(Z(ss,1),wt,9,0,[r.g.k,r.k,r.a])).b,t.f,t.e)&&++i;for(c=e.o.a.Xb().tc();c.hc();)r=a(c.ic(),11),gq(zo(Y(Z(ss,1),wt,9,0,[r.g.k,r.k,r.a])).b,t.f,t.e)&&--i;n0&&n.charCodeAt(0)!=47))throw K(new yn("invalid opaquePart: "+n));if(t&&!(e!=null&&MT(WF,e.toLowerCase()))&&!(n==null||!iq(n,EA,SA)))throw K(new yn(gUt+n));if(t&&e!=null&&MT(WF,e.toLowerCase())&&!l1e(n))throw K(new yn(gUt+n));if(!Ule(i))throw K(new yn("invalid device: "+i));if(!ahe(r))throw l=r==null?"invalid segments: null":"invalid segment: "+nhe(r),K(new yn(l));if(!(c==null||Mf(c,Ca(35))==-1))throw K(new yn("invalid query: "+c))}function m7t(t,e){var n;if(e==null||le(e,tu)||e.length==0&&t.k!=(n0(),OE))return null;switch(t.k.g){case 1:return r7(e,dE)?(me(),xE):r7(e,FY)?(me(),Hm):null;case 2:try{return Xt(Au(e,Vs,qi))}catch(i){if(i=vr(i),ct(i,118))return null;throw K(i)}case 4:try{return ew(e)}catch(i){if(i=vr(i),ct(i,118))return null;throw K(i)}case 3:return e;case 5:return T6t(t),m9t(t,e);case 6:return T6t(t),Hme(t,t.a,e);case 7:try{return n=cme(t),n.gf(e),n}catch(i){if(i=vr(i),ct(i,30))return null;throw K(i)}default:throw K(new yc("Invalid type set for this layout option."))}}function Iye(t){var e,n,i,r,c,l,f,g,b,v,M;for(l=new H(t.d.b);l.a0&&qL(b,!0,(Js(),uh)),f.j==(Ke(),rs)&&a4t(b),wr(t.f,f,e)}}function Rye(t,e,n){var i,r,c,l,f,g,b,v;if(n._b()==0)return!1;if(f=(Jo(),a(e,61).bj()),c=f?n:new Qv(n._b()),Rm(t.e,e)){if(e.xh())for(b=n.tc();b.hc();)g=b.ic(),HX(t,e,g,ct(e,62)&&(a(a(e,17),62).Bb&ao)!=0)||(r=A1(e,g),c.pc(r)||c.nc(r));else if(!f)for(b=n.tc();b.hc();)g=b.ic(),r=A1(e,g),c.nc(r)}else{if(n._b()>1)throw K(new yn(cK));for(v=gu(t.e.mg(),e),i=a(t.g,124),l=0;l1&&l>1;)v=$Nt(t,_t),f=a(Ee(t.d.c.b,l),26),M=a(Ee(t.d.c.b,l-1),26),Gt=a($.cd(k++),21).a,nt=rm(Gt,M.a.c.length),G1(_t,nt,M),G1(v,pt,f),pt=nt,_t&&(r.c[r.c.length]=_t),_t=v,--It,++c,--l;for(rt=(i-(r.c.length-1)*t.d.d)/r.c.length,b=new H(r);b.a0&&S7(t,e,!1,!1,r),M=tX(t,e,!0,!1)):(S7(t,e,!1,g,0),M=tX(t,e,!0,!1)):v?(f=a(a(rr(t.r,e),19),60)._b(),c=w1e(t,e),M=c*f+t.u*(f-1),c>0&&S7(t,e,!0,!1,c)):(S7(t,e,!0,!1,0),M=tX(t,e,!0,!0)),CX(t,e)==(H1(),nb)&&(M+=2*t.u),n.a.a=M}function v7t(t,e){var n,i,r,c,l,f,g,b,v,M;if(n=a(js(t.b,e),114),a(a(rr(t.r,e),19),60).Wb()){n.n.d=0,n.n.a=0;return}n.n.d=t.A.d,n.n.a=t.A.a,r=t.v.pc((Ku(),M0)),v=a(a(rr(t.r,e),19),60)._b()==2,f=t.t==(Kh(),cy),b=t.w.pc((ma(),Rx)),M=t.w.pc(RF),i=0,!r||v&&f?i=eX(t,e,!1,!1):f?M?(c=$0e(t,e,b),c>0&&N7(t,e,c,!1,!1),i=eX(t,e,!0,!1)):(N7(t,e,0,!1,b),i=eX(t,e,!0,!1)):M?(g=a(a(rr(t.r,e),19),60)._b(),l=xbe(t,e),i=l*g+t.u*(g-1),l>0&&N7(t,e,l,!0,!1)):(N7(t,e,0,!0,!1),i=eX(t,e,!0,!0)),CX(t,e)==(H1(),nb)&&(i+=2*t.u),n.a.b=i}function fr(){fr=P,h_t=(Lit(),_c).b,iXt=a(at(Et(_c.b),0),29),Fw=a(at(Et(_c.b),1),29),nXt=a(at(Et(_c.b),2),29),GE=_c.bb,a(at(Et(_c.bb),0),29),a(at(Et(_c.bb),1),29),WE=_c.fb,yI=a(at(Et(_c.fb),0),29),a(at(Et(_c.fb),1),29),a(at(Et(_c.fb),2),17),py=_c.qb,gXt=a(at(Et(_c.qb),0),29),a(at(Et(_c.qb),1),17),a(at(Et(_c.qb),2),17),YF=a(at(Et(_c.qb),3),29),KF=a(at(Et(_c.qb),4),29),MI=a(at(Et(_c.qb),6),29),xI=a(at(Et(_c.qb),5),17),rXt=_c.j,sXt=_c.k,oXt=_c.q,cXt=_c.w,aXt=_c.B,uXt=_c.A,lXt=_c.C,hXt=_c.D,fXt=_c._,dXt=_c.cb,pXt=_c.hb}function Nye(t,e,n){var i,r,c,l,f,g,b,v,M,k,R;t.c=0,t.b=0,i=2*e.c.a.c.length+1;t:for(M=n.tc();M.hc();){if(v=a(M.ic(),11),f=v.i==(Ht(),Tn)||v.i==fi,R=0,f){if(k=a(z(v,(Ft(),Ru)),8),!k)continue;R+=Hwe(t,i,v,k)}else{for(b=new H(v.f);b.a0?(t.f[v.o]=R/(v.d.c.length+v.f.c.length),t.c=y.Math.min(t.c,t.f[v.o]),t.b=y.Math.max(t.b,t.f[v.o])):f&&(t.f[v.o]=R)}}function Oye(t){t.b=null,t.bb=null,t.fb=null,t.qb=null,t.a=null,t.c=null,t.d=null,t.e=null,t.f=null,t.n=null,t.M=null,t.L=null,t.Q=null,t.R=null,t.K=null,t.db=null,t.eb=null,t.g=null,t.i=null,t.j=null,t.k=null,t.gb=null,t.o=null,t.p=null,t.q=null,t.r=null,t.$=null,t.ib=null,t.S=null,t.T=null,t.t=null,t.s=null,t.u=null,t.v=null,t.w=null,t.B=null,t.A=null,t.C=null,t.D=null,t.F=null,t.G=null,t.H=null,t.I=null,t.J=null,t.P=null,t.Z=null,t.U=null,t.V=null,t.W=null,t.X=null,t.Y=null,t._=null,t.ab=null,t.cb=null,t.hb=null,t.nb=null,t.lb=null,t.mb=null,t.ob=null,t.pb=null,t.jb=null,t.kb=null,t.N=!1,t.O=!1}function Bye(t,e){var n,i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt;if($=e.b.c.length,!($<3)){for(R=dt(Gn,pi,22,$,15,1),M=0,v=new H(e.b);v.al)&&Ir(t.c,a(W.b,14));++f}c=l}}}function Fht(t){var e;switch(t.d){case 1:{if(t.wi())return t.o!=-2;break}case 2:{if(t.wi())return t.o==-2;break}case 3:case 5:case 4:case 6:case 7:return t.o>-2;default:return!1}switch(e=t.vi(),t.p){case 0:return e!=null&<(de(e))!=xT(t.k,0);case 1:return e!=null&&a(e,192).a!=or(t.k)<<24>>24;case 2:return e!=null&&a(e,159).a!=(or(t.k)&qr);case 6:return e!=null&&xT(a(e,149).a,t.k);case 5:return e!=null&&a(e,21).a!=or(t.k);case 7:return e!=null&&a(e,168).a!=or(t.k)<<16>>16;case 3:return e!=null&<(Yt(e))!=t.j;case 4:return e!=null&&a(e,126).a!=t.j;default:return e==null?t.n!=null:!Fi(e,t.n)}}function tZ(t,e){var n,i,r,c;c=t.F,e==null?(t.F=null,lq(t,null)):(t.F=(En(e),e),i=Mf(e,Ca(60)),i!=-1?(r=e.substr(0,i),Mf(e,Ca(46))==-1&&!le(r,rE)&&!le(r,E4)&&!le(r,LO)&&!le(r,S4)&&!le(r,T4)&&!le(r,C4)&&!le(r,A4)&&!le(r,k4)&&(r=AUt),n=NW(e,Ca(62)),n!=-1&&(r+=""+e.substr(n+1,e.length-(n+1))),lq(t,r)):(r=e,Mf(e,Ca(46))==-1&&(i=Mf(e,Ca(91)),i!=-1&&(r=e.substr(0,i)),!le(r,rE)&&!le(r,E4)&&!le(r,LO)&&!le(r,S4)&&!le(r,T4)&&!le(r,C4)&&!le(r,A4)&&!le(r,k4)?(r=AUt,i!=-1&&(r+=""+e.substr(i,e.length-i))):r=e),lq(t,r),r==e&&(t.F=t.D))),t.Db&4&&!(t.Db&1)&&Bi(t,new fs(t,1,5,c,e))}function Fye(t){pC();var e,n,i,r,c,l,f;for(f=new nm,n=new H(t);n.a=f.b.c)&&(f.b=e),(!f.c||e.c<=f.c.c)&&(f.d=f.c,f.c=e),(!f.e||e.d>=f.e.d)&&(f.e=e),(!f.f||e.d<=f.f.d)&&(f.f=e);return i=new a7((BM(),$m)),xL(t,jjt,new zu(Y(Z(_6,1),te,341,0,[i]))),l=new a7(mw),xL(t,zjt,new zu(Y(Z(_6,1),te,341,0,[l]))),r=new a7(gw),xL(t,Ujt,new zu(Y(Z(_6,1),te,341,0,[r]))),c=new a7(V_),xL(t,Fjt,new zu(Y(Z(_6,1),te,341,0,[c]))),SX(i.c,$m),SX(r.c,gw),SX(c.c,V_),SX(l.c,mw),f.a.c=dt(un,te,1,0,5,1),Or(f.a,i.c),Or(f.a,Em(r.c)),Or(f.a,c.c),Or(f.a,Em(l.c)),f}function RP(t,e,n){var i,r,c,l;return t.Rj()&&t.Qj()&&(l=b$(t,a(n,51)),zt(l)!==zt(n))?(t.ai(e),t.gi(e,B5t(t,e,l)),t.Dj()&&(c=(r=a(n,42),t.Pj()?t.Nj()?r.Cg(t.b,jo(a(Ve(da(t.b),t.pi()),17)).n,a(Ve(da(t.b),t.pi()).jj(),24).Qi(),null):r.Cg(t.b,xr(r.mg(),jo(a(Ve(da(t.b),t.pi()),17))),null,null):r.Cg(t.b,-1-t.pi(),null,null)),!a(l,42).yg()&&(c=(i=a(l,42),t.Pj()?t.Nj()?i.Ag(t.b,jo(a(Ve(da(t.b),t.pi()),17)).n,a(Ve(da(t.b),t.pi()).jj(),24).Qi(),c):i.Ag(t.b,xr(i.mg(),jo(a(Ve(da(t.b),t.pi()),17))),null,c):i.Ag(t.b,-1-t.pi(),null,c))),c&&c.Th()),Xl(t.b)&&t.ni(t.mi(9,n,l,e,!1)),l):n}function _7t(t,e,n){var i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t;for(v=lt(Yt(z(t,(qt(),_0)))),i=lt(Yt(z(t,ubt))),k=new Rk,Ct(k,_0,v+i),b=e,nt=e.d,$=e.c.g,rt=e.d.g,W=ql($.c),pt=ql(rt.c),r=new Nt,M=W;M<=pt;M++)f=new Jh(t),jl(f,(Ke(),Hr)),Ct(f,(Ft(),li),b),Ct(f,Qi,(Ls(),Gc)),Ct(f,ZB,k),R=a(Ee(t.b,M),26),M==W?G1(f,R.a.c.length-n,R):Ks(f,R),_t=lt(Yt(z(b,up))),_t<0&&(_t=0,Ct(b,up,_t)),f.n.b=_t,O=y.Math.floor(_t/2),l=new Eo,yr(l,(Ht(),on)),ds(l,f),l.k.b=O,g=new Eo,yr(g,Qe),ds(g,f),g.k.b=O,Ts(b,l),c=new Np,Uo(c,b),Ct(c,Ro,null),Hs(c,g),Ts(c,nt),Fpe(f,b,c),r.c[r.c.length]=c,b=c;return r}function Uye(t,e){var n,i,r,c,l,f,g,b,v,M;for(t.a=new QCt(lle(fA)),i=new H(e.a);i.a0;){for($=(mi(0,g.c.length),a(g.c[0],14)),r=(mi(0,R.c.length),a(R.c[0],14)),rt=r.d.d,c=nc(rt,r,0),pce($,r.d,c),Hs(r,null),Ts(r,null),O=$.a,e&&Xi(O,new Oo(pt)),i=qn(r.a,0);i.b!=i.d.c;)n=a(Yn(i),9),Xi(O,new Oo(n));for(nt=$.b,k=new H(r.b);k.a0?CV(this,this.f/this.a):Wh(e.g,e.d[0]).a!=null&&Wh(n.g,n.d[0]).a!=null?CV(this,(lt(Wh(e.g,e.d[0]).a)+lt(Wh(n.g,n.d[0]).a))/2):Wh(e.g,e.d[0]).a!=null?CV(this,Wh(e.g,e.d[0]).a):Wh(n.g,n.d[0]).a!=null&&CV(this,Wh(n.g,n.d[0]).a)}function Uht(t){var e;this.r=Rse(new MR,new pz),this.b=(ts(),new IC(a(si(Ia),274))),this.p=new IC(a(si(Ia),274)),this.i=new IC(a(si(pqt),274)),this.e=t,this.o=new Oo(t.Re()),this.B=t.bf()||lt(de(t.xe((dr(),yF)))),this.v=a(t.xe((dr(),FE)),19),this.w=a(t.xe(EF),19),this.q=a(t.xe(tI),83),this.t=a(t.xe(NQ),275),this.j=a(t.xe(MF),19),this.n=a(uP(t,dVt),119),this.k=lt(Yt(uP(t,TF))),this.d=lt(Yt(uP(t,ivt))),this.u=lt(Yt(uP(t,cvt))),this.s=lt(Yt(uP(t,rvt))),this.A=a(uP(t,svt),135),this.c=2*this.d,e=!this.w.pc((ma(),LF)),this.f=new BC(0,e,0),this.g=new BC(1,e,0),zG(this.f,(Ch(),ta),this.g)}function x7t(t,e){var n,i,r,c,l,f,g,b,v,M,k,R;if(e==null||e.length==0)return null;if(c=a(Zc(t.f,e),27),!c){for(r=(k=new vf(t.d).a.Tb().tc(),new Q0(k));r.a.hc();)if(n=(l=a(r.a.ic(),38),a(l.lc(),27)),f=n.f,R=e.length,le(f.substr(f.length-R,R),e)&&(e.length==f.length||bo(f,f.length-e.length-1)==46)){if(c)return null;c=n}if(!c){for(i=(M=new vf(t.d).a.Tb().tc(),new Q0(M));i.a.hc();)if(n=(l=a(i.a.ic(),38),a(l.lc(),27)),v=n.g,v!=null){for(g=0,b=v.length;g=1&&(W-l>0&&M>=0?(g.k.a+=$,g.k.b+=c*l):W-l<0&&v>=0&&(g.k.a+=$*W,g.k.b+=c));t.n.a=e.a,t.n.b=e.b,Ct(t,(qt(),yw),(Ku(),i=a(yu(vA),10),new ja(i,a(cu(i,i.length),10),0)))}function S7t(t,e){var n,i,r,c,l,f,g,b,v,M;for(g=!0,r=0,b=t.f[e.o],v=e.n.b+t.n,n=t.c[e.o][2],Kl(t.a,b,Xt(a(Ee(t.a,b),21).a-1+n)),Kl(t.b,b,lt(Yt(Ee(t.b,b)))-v+n*t.e),++b,b>=t.i?(++t.i,Ut(t.a,Xt(1)),Ut(t.b,v)):(i=t.c[e.o][1],Kl(t.a,b,Xt(a(Ee(t.a,b),21).a+1-i)),Kl(t.b,b,lt(Yt(Ee(t.b,b)))+v-i*t.e)),(t.q==(x_(),U6)&&(a(Ee(t.a,b),21).a>t.j||a(Ee(t.a,b-1),21).a>t.j)||t.q==z6&&(lt(Yt(Ee(t.b,b)))>t.k||lt(Yt(Ee(t.b,b-1)))>t.k))&&(g=!1),l=Rn(Rs(e));Jn(l);)c=a(In(l),14),f=c.c.g,t.f[f.o]==b&&(M=S7t(t,f),r=r+a(M.a,21).a,g=g&<(de(M.b)));return t.f[e.o]=b,r=r+t.c[e.o][0],new zs(Xt(r),(me(),!!g))}function Hye(t){var e,n,i,r,c,l,f,g,b,v;for(b=new Fr,f=new Fr,c=new H(t);c.a-1){for(r=qn(f,0);r.b!=r.d.c;)i=a(Yn(r),125),i.s=l;for(;f.b!=0;)for(i=a(Iut(f,0),125),n=new H(i.g);n.a-1){for(c=new H(f);c.a0)&&(g.i=rm(g.i,r.i-1),--g.f,g.f==0&&(f.c[f.c.length]=g))}}function C7t(t,e){var n,i,r,c,l,f,g,b;if(!(e.b==null||t.b==null)){for(__(t),o4(t),__(e),o4(e),n=dt(Gn,pi,22,t.b.length+e.b.length,15,1),b=0,i=0,l=0;i=f&&r<=g)f<=r&&c<=g?(n[b++]=r,n[b++]=c,i+=2):f<=r?(n[b++]=r,n[b++]=g,t.b[i]=g+1,l+=2):c<=g?(n[b++]=f,n[b++]=c,i+=2):(n[b++]=f,n[b++]=g,t.b[i]=g+1);else if(gt.j&&(t.q=U6,eE(t,c));break;case 4:for(t.q=(x_(),QB),eE(t,c),b=0,r=new H(t.b);r.at.k&&(t.q=z6,eE(t,c));break;case 6:k=Tr(y.Math.ceil(t.f.length*v/100)),eE(t,new X8(k));break;case 5:M=Tr(y.Math.ceil(t.d*v/100)),eE(t,new H3(M));break;default:eE(t,c)}gwe(t,e),Vn(n)}function qye(t){var e,n,i,r,c,l,f;for(e=new Nt,t.g=new Nt,t.d=new Nt,l=new Vg(new xp(t.f.b).a);l.b;)c=xm(l),Ut(e,a(a(c.lc(),48).b,80)),Bv(a(c.kc(),536).Je())?Ut(t.d,a(c.lc(),48)):Ut(t.g,a(c.lc(),48));for(Sq(t,t.d),Sq(t,t.g),t.c=new k9t(t.b),FQt(t.c,(Uit(),Rjt)),yq(t,t.d),yq(t,t.g),Or(e,t.c.a.b),t.e=new We(is,is),t.a=new We(Ps,Ps),i=new H(e);i.aZ1)&&f<10);Pit(t.c,new o3),A7t(t),Xre(t.c),zye(t.f)}function A7t(t){var e,n,i,r,c,l,f;for(e=0,c=new H(t.b.a);c.a=2){for(g=qn(n,0),l=a(Yn(g),9),f=a(Yn(g),9);f.a0&&(f=y.Math.max(f,kPt(t.A.b+i.d.b,r))),M=i,k=r,R=c;t.A&&t.A.c>0&&(O=R+t.A.c,v&&(O+=M.d.c),f=y.Math.max(f,(Ef(),P1(yd),y.Math.abs(k-1)<=yd||k==1||isNaN(k)&&isNaN(1)?0:O/(1-k)))),n.n.b=0,n.a.a=f}function L7t(t,e){var n,i,r,c,l,f,g,b,v,M,k,R,O,$;if(n=a(js(t.b,e),114),b=a(a(rr(t.r,e),19),60),b.Wb()){n.n.d=0,n.n.a=0;return}for(l=t.v.pc((Ku(),M0)),$=t.w.pc((ma(),Rx)),v=t.t==(Kh(),rb),f=0,g=b.tc(),M=null,R=0,k=0;g.hc();)i=a(g.ic(),111),c=lt(Yt(i.b.xe((lD(),NF)))),r=i.b.Re().b,l&&N7(t,e,0,v,!v&&$),M?(O=k+M.d.a+t.u+i.d.d,f=y.Math.max(f,(Ef(),P1(yd),y.Math.abs(R-c)<=yd||R==c||isNaN(R)&&isNaN(c)?0:O/(c-R)))):t.A&&t.A.d>0&&(f=y.Math.max(f,kPt(t.A.d+i.d.d,c))),M=i,R=c,k=r;t.A&&t.A.a>0&&(O=k+t.A.a,v&&(O+=M.d.a),f=y.Math.max(f,(Ef(),P1(yd),y.Math.abs(R-1)<=yd||R==1||isNaN(R)&&isNaN(1)?0:O/(1-R)))),n.n.d=0,n.a.b=f}function Jye(t,e,n){var i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It,Gt;return k=t.c[e],R=t.c[n],O=a(z(k,(Ft(),mx)),15),!!O&&O._b()!=0&&O.pc(R)||($=k.j!=(Ke(),Hr)&&R.j!=Hr,W=a(z(k,LE),8),nt=a(z(R,LE),8),rt=W!=nt,pt=!!W&&W!=k||!!nt&&nt!=R,_t=$q(k,(Ht(),Tn)),It=$q(R,fi),pt=pt|($q(k,fi)||$q(R,Tn)),Gt=pt&&rt||_t||It,$&&Gt)||k.j==(Ke(),uc)&&R.j==gs||R.j==(Ke(),uc)&&k.j==gs?!1:(v=t.c[e],c=t.c[n],r=VRt(t.e,v,c,(Ht(),on)),g=VRt(t.i,v,c,Qe),Lbe(t.f,v,c),b=A6t(t.b,v,c)+a(r.a,21).a+a(g.a,21).a+t.f.d,f=A6t(t.b,c,v)+a(r.b,21).a+a(g.b,21).a+t.f.b,t.a&&(M=a(z(v,li),11),l=a(z(c,li),11),i=NRt(t.g,M,l),b+=a(i.a,21).a,f+=a(i.b,21).a),b>f)}function P7t(t,e,n){var i,r,c,l,f,g,b,v,M;if(t.a!=e.Pi())throw K(new yn(mE+e.be()+zm));if(i=jp((Qa(),eo),e).kk(),i)return i.Pi().dh().Zg(i,n);if(l=jp(eo,e).mk(),l){if(n==null)return null;if(f=a(n,15),f.Wb())return"";for(M=new Sp,c=f.tc();c.hc();)r=c.ic(),mo(M,l.Pi().dh().Zg(l,r)),M.a+=" ";return I9(M,M.a.length-1)}if(v=jp(eo,e).nk(),!v.Wb()){for(b=v.tc();b.hc();)if(g=a(b.ic(),140),g.Li(n))try{if(M=g.Pi().dh().Zg(g,n),M!=null)return M}catch(k){if(k=vr(k),!ct(k,104))throw K(k)}throw K(new yn("Invalid value: '"+n+"' for datatype :"+e.be()))}return a(e,737).Ui(),n==null?null:ct(n,159)?""+a(n,159).a:fu(n)==ZO?tSt(MA[0],a(n,181)):Yc(n)}function Qye(t,e,n){var i,r,c,l,f,g,b,v,M,k,R,O,$,W;for(di(n,bBt,1),qjt=lt(de(z(e,(qt(),V4)))),t.c=e,O=new Nt,f=new H(e.b);f.aW){for($=1,r=b.n.a;r>g;)++$,r=(b.n.a-($-1)*t.d)/$;Ut(i,new eAt(t,b,$))}for(v=new H(i);v.ab?0:b),1),l),t.c[i.a.d])),ih($l(Wl(Vl(Gl(new cl,0>-b?0:-b),1),l),t.c[f.a.d]))):(k=1,(ct(i.g,153)&&ct(f.g,8)||ct(f.g,153)&&ct(i.g,8))&&(k=2),ih($l(Wl(Vl(Gl(new cl,Tr(c)),k),t.c[i.a.d]),t.c[f.a.d]))))}function e2e(t,e){var n,i,r,c,l,f,g,b,v,M,k,R,O,$;for(n=a(z(t,(qt(),Qi)),83),l=t.e,c=t.d,f=l.a+c.b+c.c,g=0-c.d-t.c.b,v=l.b+c.d+c.a-t.c.b,b=new Nt,M=new Nt,r=new H(e);r.a0),a(v.a.cd(v.c=--v.b),14));c!=i&&v.b>0;)t.a[c.o]=!0,t.a[i.o]=!0,c=(Hn(v.b>0),a(v.a.cd(v.c=--v.b),14));v.b>0&&Th(v)}}function i2e(t){t.q||(t.q=!0,t.p=cc(t,0),t.a=cc(t,1),nr(t.a,0),t.f=cc(t,2),nr(t.f,1),Cr(t.f,2),t.n=cc(t,3),Cr(t.n,3),Cr(t.n,4),Cr(t.n,5),Cr(t.n,6),t.g=cc(t,4),nr(t.g,7),Cr(t.g,8),t.c=cc(t,5),nr(t.c,7),nr(t.c,8),t.i=cc(t,6),nr(t.i,9),nr(t.i,10),nr(t.i,11),nr(t.i,12),Cr(t.i,13),t.j=cc(t,7),nr(t.j,9),t.d=cc(t,8),nr(t.d,3),nr(t.d,4),nr(t.d,5),nr(t.d,6),Cr(t.d,7),Cr(t.d,8),Cr(t.d,9),Cr(t.d,10),t.b=cc(t,9),Cr(t.b,0),Cr(t.b,1),t.e=cc(t,10),Cr(t.e,1),Cr(t.e,2),Cr(t.e,3),Cr(t.e,4),nr(t.e,5),nr(t.e,6),nr(t.e,7),nr(t.e,8),nr(t.e,9),nr(t.e,10),Cr(t.e,11),t.k=cc(t,11),Cr(t.k,0),Cr(t.k,1),t.o=yi(t,12),t.s=yi(t,13))}function r2e(t,e){var n,i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt;for(di(e,"Interactive crossing minimization",1),l=0,c=new H(t.b);c.a0&&(n+=g.k.a+g.n.a/2,++M),O=new H(g.i);O.a=f&&r<=g)f<=r&&c<=g?i+=2:f<=r?(t.b[i]=g+1,l+=2):c<=g?(n[b++]=r,n[b++]=f-1,i+=2):(n[b++]=r,n[b++]=f-1,t.b[i]=g+1,l+=2);else if(g0),l.a.cd(l.c=--l.b),cd(l,i),gM(b,i),C7(i,g.i),SM(b),SM(b),r.a.$b(i)!=null}}function c2e(t,e){var n,i,r,c,l,f,g,b,v,M,k,R,O,$,W;for(di(e,"Spline SelfLoop pre-processing.",1),b=new qa,M=new H(t.a);M.a0?r-=864e5:r+=864e5,g=new tst(so(Ka(e.q.getTime()),r))),v=new Db,b=t.a.length,c=0;c=97&&i<=122||i>=65&&i<=90){for(l=c+1;l=b)throw K(new yn("Missing trailing '"));l+1=14&&b<=16))?e.a.Qb(i)?(n.a?Ii(n.a,n.b):n.a=new ll(n.d),f2(n.a,"[...]")):(l=e_(i),g=new lL(e),Wg(n,R7t(l,g))):ct(i,221)?Wg(n,$ge(a(i,221))):ct(i,173)?Wg(n,zge(a(i,173))):ct(i,176)?Wg(n,J1e(a(i,176))):ct(i,1697)?Wg(n,Wge(a(i,1697))):ct(i,37)?Wg(n,Gge(a(i,37))):ct(i,378)?Wg(n,Jge(a(i,378))):ct(i,736)?Wg(n,Hge(a(i,736))):ct(i,106)&&Wg(n,jge(a(i,106))):Wg(n,i==null?tu:Yc(i));return n.a?n.e.length==0?n.a.a:n.a.a+(""+n.e):n.c}function l2e(t,e,n){var i,r,c,l,f,g,b,v,M,k,R,O,$;if(lt(de(z(n,(qt(),J_)))))for(f=new H(n.i);f.a1))););(f>0||k==(Kh(),rb)&&(!c.n&&(c.n=new Wt(ic,c,1,7)),c.n).i>0)&&(g=!0),f>1&&(b=!0)}g&&e.nc((So(),Al)),b&&e.nc((So(),H4))}function D7t(t,e,n){var i,r,c;return r=new Uht(t),vbe(r,n),lNt(r,!1),pd(r.e.We(),new yrt(r,!1)),V$(r,r.f,(Ch(),lc),(Ht(),Tn)),V$(r,r.f,hc,fi),V$(r,r.g,lc,on),V$(r,r.g,hc,Qe),lIt(r,Tn),lIt(r,fi),qCt(r,Qe),qCt(r,on),Bg(),i=r.v.pc((Ku(),ob))&&r.w.pc((ma(),_A))?fut(r):null,i&&YQt(r.a,i),Ewe(r),npe(r),ipe(r),f2e(r),Qwe(r),Cpe(r),Dq(r,Tn),Dq(r,fi),Kwe(r),O_e(r),e&&(hfe(r),Ape(r),Dq(r,Qe),Dq(r,on),c=r.w.pc((ma(),yA)),a9t(r,c,Tn),a9t(r,c,fi),u9t(r,c,Qe),u9t(r,c,on),qc(new gi(null,new Ei(new vf(r.i),0)),new mz),qc(wo(new gi(null,Tot(r.r).wc()),new ER),new SR),k1e(r),r.e.Ue(r.o),qc(new gi(null,Tot(r.r).wc()),new L3)),r.o}function g2e(t,e){var n,i,r,c,l,f,g,b,v,M,k,R,O;for(di(e,"Spline SelfLoop positioning",1),v=a(z(t,(qt(),zmt)),345),b=new H(t.b);b.a2?(v=new Nt,Or(v,new T1(nt,1,nt.b)),c=uOt(v,pt+t.a),rt=new yX(c),Uo(rt,e),n.c[n.c.length]=rt):i?rt=a(zi(t.b,e0(e)),247):rt=a(zi(t.b,Pm(e)),247),g=e0(e),i&&(g=Pm(e)),l=age(W,g),b=pt+t.a,l.a?(b+=y.Math.abs(W.b-M.b),$=new We(M.a,(M.b+W.b)/2)):(b+=y.Math.abs(W.a-M.a),$=new We((M.a+W.a)/2,M.b)),i?wr(t.d,e,new kut(rt,l,$,b)):wr(t.c,e,new kut(rt,l,$,b)),wr(t.b,e,rt),O=(!e.n&&(e.n=new Wt(ic,e,1,7)),e.n),R=new $n(O);R.e!=R.i._b();)k=a(ci(R),137),r=SP(t,k,!0,0,0),n.c[n.c.length]=r}function b2e(){bi(hy,new Rz),bi(Ui,new HR),bi(Dl,new VR),bi(cf,new XR),bi(itt,new zz),bi($F,new ZR),bi(Qp,new YR),bi(xA,new td),bi(pI,new jk),bi(KQ,new FR),bi(Iw,new Hk),bi(ph,new Lz),bi(of,new Gk),bi(Nw,new oo),bi(Ow,new Pz),bi(Ra,new Iz),bi(Dw,new N3),bi(Dc,new UR),bi(Do,new Dz),bi(wu,new yp),bi(ho,new Nz),bi(Z(Da,1),new WS),bi(ux,new Wk),bi(D4,new zR),bi(ZO,new jR),bi(x_t,new Fd),bi(To,new Cb),bi(Bvt,new $k),bi(zvt,new $S),bi(u_t,new GR),bi(VF,new Vk),bi(ME,new WR),bi(Io,new qk),bi(o1t,new Xk),bi(Gm,new Ab),bi(c1t,new Oz),bi(s_t,new kb),bi(M_t,new $R),bi(Wm,new Zk),bi(At,new Bz),bi(Uvt,new Fz),bi(E_t,new Uz)}function w2e(t){var e,n,i,r,c,l,f,g;for(e=null,i=new H(t);i.a0&&n.c==0&&(!e&&(e=new Nt),e.c[e.c.length]=n);if(e)for(;e.c.length!=0;){if(n=a(ym(e,0),205),n.b&&n.b.c.length>0){for(c=(!n.b&&(n.b=new Nt),new H(n.b));c.anc(t,n,0))return new zs(r,n)}else if(lt(Wh(r.g,r.d[0]).a)>lt(Wh(n.g,n.d[0]).a))return new zs(r,n)}for(f=(!n.e&&(n.e=new Nt),n.e).tc();f.hc();)l=a(f.ic(),205),g=(!l.b&&(l.b=new Nt),l.b),Yv(0,g.c.length),B5(g.c,0,n),l.c==g.c.length&&(e.c[e.c.length]=l)}return null}function v2e(t,e){var n,i,r,c,l,f,g,b,v,M,k,R,O,$;for(di(e,"Label dummy insertions",1),M=new Nt,l=lt(Yt(z(t,(qt(),N6)))),b=lt(Yt(z(t,Ex))),v=a(z(t,ch),110),R=new H(t.a);R.a>16==-10?n=a(t.Cb,268).zj(e,n):t.Db>>16==-15&&(!e&&(e=(ye(),Hf)),!b&&(b=(ye(),Hf)),t.Cb.Hg()&&(g=new Qd(t.Cb,1,13,b,e,Hp(Ya(a(t.Cb,53)),t),!1),n?n.Sh(g):n=g));else if(ct(t.Cb,96))t.Db>>16==-23&&(ct(e,96)||(e=(ye(),gh)),ct(b,96)||(b=(ye(),gh)),t.Cb.Hg()&&(g=new Qd(t.Cb,1,10,b,e,Hp(kc(a(t.Cb,24)),t),!1),n?n.Sh(g):n=g));else if(ct(t.Cb,411))for(f=a(t.Cb,742),l=(!f.b&&(f.b=new aT(new DG)),f.b),c=(i=new Vg(new xp(l.a).a),new uT(i));c.a.b;)r=a(xm(c.a).kc(),84),n=iE(r,P7(r,f),n)}return n}function y2e(t,e,n){var i,r,c,l,f,g,b,v,M,k,R,O,$,W;for(di(n,"Depth-first cycle removal",1),v=e.a,$=v.c.length,t.a=dt(Gn,pi,22,$,15,1),zxt(t.a),t.b=dt(Gn,pi,22,$,15,1),zxt(t.b),l=0,b=new H(v);b.a=0){for(g=null,f=new Gs(v.a,b+1);f.b=b.c.c.length?v=dct((Ke(),gs),Hr):v=dct((Ke(),Hr),Hr),v*=2,c=n.a.g,n.a.g=y.Math.max(c,c+(v-c)),l=n.b.g,n.b.g=y.Math.max(l,l+(v-l)),r=e}}function z7t(t,e){var n,i,r,c,l,f,g,b,v;for(l=a(a(rr(t.r,e),19),60),v=l._b()==2||l._b()>2&&t.w.pc((ma(),Rx)),c=l.tc();c.hc();)if(r=a(c.ic(),111),!(!r.c||r.c.d.c.length<=0)){switch(b=r.b.Re(),f=r.c,g=f.i,g.b=(i=f.n,f.e.a+i.b+i.c),g.a=(n=f.n,f.e.b+n.d+n.a),e.g){case 1:v?(g.c=-g.b-t.s,Cf(f,(hu(),fh))):(g.c=b.a+t.s,Cf(f,(hu(),jf))),g.d=-g.a-t.s,qd(f,(Ha(),dh));break;case 3:v?(g.c=-g.b-t.s,Cf(f,(hu(),fh))):(g.c=b.a+t.s,Cf(f,(hu(),jf))),g.d=b.b+t.s,qd(f,(Ha(),Fh));break;case 2:g.c=b.a+t.s,v?(g.d=-g.a-t.s,qd(f,(Ha(),dh))):(g.d=b.b+t.s,qd(f,(Ha(),Fh))),Cf(f,(hu(),jf));break;case 4:g.c=-g.b-t.s,v?(g.d=-g.a-t.s,qd(f,(Ha(),dh))):(g.d=b.b+t.s,qd(f,(Ha(),Fh))),Cf(f,(hu(),fh))}v=!1}}function V7(t,e){var n;if(t.e)throw K(new yc((Vd(AK),jZ+AK.k+HZ)));if(!vte(t.a,e))throw K(new sc(GOt+e+WOt));if(e==t.d)return t;switch(n=t.d,t.d=e,n.g){case 0:switch(e.g){case 2:Lm(t);break;case 1:B1(t),Lm(t);break;case 4:p_(t),Lm(t);break;case 3:p_(t),B1(t),Lm(t)}break;case 2:switch(e.g){case 1:B1(t),RX(t);break;case 4:p_(t),Lm(t);break;case 3:p_(t),B1(t),Lm(t)}break;case 1:switch(e.g){case 2:B1(t),RX(t);break;case 4:B1(t),p_(t),Lm(t);break;case 3:B1(t),p_(t),B1(t),Lm(t)}break;case 4:switch(e.g){case 2:p_(t),Lm(t);break;case 1:p_(t),B1(t),Lm(t);break;case 3:B1(t),RX(t)}break;case 3:switch(e.g){case 2:B1(t),p_(t),Lm(t);break;case 1:B1(t),p_(t),B1(t),Lm(t);break;case 4:B1(t),RX(t)}}return t}function T_(t,e){var n;if(t.d)throw K(new yc((Vd(VK),jZ+VK.k+HZ)));if(!wte(t.a,e))throw K(new sc(GOt+e+WOt));if(e==t.c)return t;switch(n=t.c,t.c=e,n.g){case 0:switch(e.g){case 2:qg(t);break;case 1:F1(t),qg(t);break;case 4:g_(t),qg(t);break;case 3:g_(t),F1(t),qg(t)}break;case 2:switch(e.g){case 1:F1(t),DX(t);break;case 4:g_(t),qg(t);break;case 3:g_(t),F1(t),qg(t)}break;case 1:switch(e.g){case 2:F1(t),DX(t);break;case 4:F1(t),g_(t),qg(t);break;case 3:F1(t),g_(t),F1(t),qg(t)}break;case 4:switch(e.g){case 2:g_(t),qg(t);break;case 1:g_(t),F1(t),qg(t);break;case 3:F1(t),DX(t)}break;case 3:switch(e.g){case 2:F1(t),g_(t),qg(t);break;case 1:F1(t),g_(t),F1(t),qg(t);break;case 4:F1(t),DX(t)}}return t}function j7t(t,e,n){var i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt;for(r=new Nt,O=new H(e.a);O.ant?g:nt,pt=new H(v.i);pt.a=b&&It>=W&&(k+=O.k.b+$.k.b+$.a.b-_t,++f));if(n)for(l=new H(rt.d);l.a=b&&It>=W&&(k+=O.k.b+$.k.b+$.a.b-_t,++f))}f>0&&(Gt+=k/f,++R)}R>0?(e.a=r*Gt/R,e.i=R):(e.a=0,e.i=0)}function I2e(t,e){var n,i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It,Gt,Zt;for(t.e=e,f=hme(e),Gt=new Nt,i=new H(f);i.a0&&(M.d+=b.n.d,M.d+=b.d),M.a>0&&(M.a+=b.n.a,M.a+=b.d),M.b>0&&(M.b+=b.n.b,M.b+=b.d),M.c>0&&(M.c+=b.n.c,M.c+=b.d),M}function F2e(t,e,n){var i;if(di(n,"StretchWidth layering",1),e.a.c.length==0){Vn(n);return}for(t.c=e,t.t=0,t.u=0,t.i=is,t.g=Ps,t.d=lt(Yt(z(e,(qt(),nf)))),Lde(t),V0e(t),oge(t),t1e(t),Tfe(t),t.i=y.Math.max(1,t.i),t.g=y.Math.max(1,t.g),t.d=t.d/t.i,t.f=t.g/t.i,t.s=Hhe(t),i=new dl(t.c),Ut(t.c.b,i),t.r=fd(t.p),t.n=JD(t.k,t.k.length);t.r.c.length!=0;)t.o=che(t),!t.o||m6t(t)&&t.b.a._b()!=0?($de(t,i),i=new dl(t.c),Ut(t.c.b,i),yo(t.a,t.b),t.b.a.Pb(),t.t=t.u,t.u=0):m6t(t)?(t.c.b.c=dt(un,te,1,0,5,1),i=new dl(t.c),Ut(t.c.b,i),t.t=0,t.u=0,t.b.a.Pb(),t.a.a.Pb(),++t.f,t.r=fd(t.p),t.n=JD(t.k,t.k.length)):(Ks(t.o,i),Lc(t.r,t.o),Ir(t.b,t.o),t.t=t.t-t.k[t.o.o]*t.d+t.j[t.o.o],t.u+=t.e[t.o.o]*t.d);e.a.c=dt(un,te,1,0,5,1),XC(e.b),Vn(n)}function G7t(t){var e,n,i,r,c,l,f,g,b,v,M,k,R,O,$,W;for(O=new H(t);O.a0&&(t.a[e.c.o][e.o].d+=pu(t.f,24)*GP*.07000000029802322-.03500000014901161,t.a[e.c.o][e.o].a=t.a[e.c.o][e.o].d/t.a[e.c.o][e.o].b)}}function U2e(t,e,n,i,r){var c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It,Gt,Zt,ce,ae,Te,Me,Bn;Te=zi(t.e,i),Te==null&&(Te=new gT,R=a(Te,191),rt=e+"_s",pt=rt+r,k=new _2(pt),L1(R,Df,k)),ae=a(Te,191),x2(n,ae),Bn=new gT,Ug(Bn,"x",i.j),Ug(Bn,"y",i.k),L1(ae,NFt,Bn),Zt=new gT,Ug(Zt,"x",i.b),Ug(Zt,"y",i.c),L1(ae,"endPoint",Zt),M=P9((!i.a&&(i.a=new Ss(sf,i,5)),i.a)),O=!M,O&&(Gt=new Ig,c=new cG(Gt),vo((!i.a&&(i.a=new Ss(sf,i,5)),i.a),c),L1(ae,ZY,Gt)),g=zq(i),_t=!!g,_t&&alt(t.a,ae,Ppt,hX(t,zq(i))),nt=jq(i),It=!!nt,It&&alt(t.a,ae,Lpt,hX(t,jq(i))),b=(!i.e&&(i.e=new pn(os,i,10,9)),i.e).i==0,$=!b,$&&(ce=new Ig,l=new eEt(t,ce),vo((!i.e&&(i.e=new pn(os,i,10,9)),i.e),l),L1(ae,Rpt,ce)),v=(!i.g&&(i.g=new pn(os,i,9,10)),i.g).i==0,W=!v,W&&(Me=new Ig,f=new nEt(t,Me),vo((!i.g&&(i.g=new pn(os,i,9,10)),i.g),f),L1(ae,Ipt,Me))}function q7(t){var e,n,i,r,c,l,f,g,b,v,M;if(t==null)throw K(new yf(tu));if(b=t,c=t.length,g=!1,c>0&&(e=t.charCodeAt(0),(e==45||e==43)&&(t=t.substr(1,t.length-1),--c,g=e==45)),c==0)throw K(new yf(Om+b+'"'));for(;t.length>0&&t.charCodeAt(0)==48;)t=t.substr(1,t.length-1),--c;if(c>(ONt(),Pzt)[10])throw K(new yf(Om+b+'"'));for(r=0;r0&&(M=-HEt(t.substr(0,i),10),t=t.substr(i,t.length-i),c-=i,n=!1);c>=l;){if(i=HEt(t.substr(0,l),10),t=t.substr(l,t.length-l),c-=l,n)n=!1;else{if(Pc(M,f)<0)throw K(new yf(Om+b+'"'));M=Xg(M,v)}M=Zg(M,i)}if(Pc(M,0)>0)throw K(new yf(Om+b+'"'));if(!g&&(M=LM(M),Pc(M,0)<0))throw K(new yf(Om+b+'"'));return M}function z2e(t,e,n,i,r){var c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It,Gt,Zt,ce,ae,Te;for(pt=0,O=0,R=0,k=1,rt=new $n((!t.a&&(t.a=new Wt(zr,t,10,11)),t.a));rt.e!=rt.i._b();)W=a(ci(rt),35),k+=Dp(Af(W)),ce=W.g,O=y.Math.max(O,ce),M=W.f,R=y.Math.max(R,M),pt+=ce*M;for($=(!t.a&&(t.a=new Wt(zr,t,10,11)),t.a).i,l=pt+2*i*i*k*$,c=y.Math.sqrt(l),g=y.Math.max(c*n,O),f=y.Math.max(c/n,R),nt=new $n((!t.a&&(t.a=new Wt(zr,t,10,11)),t.a));nt.e!=nt.i._b();)W=a(ci(nt),35),ae=r.b+(pu(e,26)*a4+pu(e,27)*u4)*(g-W.g),Te=r.b+(pu(e,26)*a4+pu(e,27)*u4)*(f-W.f),th(W,ae),eh(W,Te);for(Zt=g+(r.b+r.c),Gt=f+(r.d+r.a),It=new $n((!t.a&&(t.a=new Wt(zr,t,10,11)),t.a));It.e!=It.i._b();)for(_t=a(ci(It),35),v=Rn(Af(_t));Jn(v);)b=a(In(v),105),ZC(b)||n3e(b,e,Zt,Gt);Zt+=r.b+r.c,Gt+=r.d+r.a,C_(t,Zt,Gt,!1,!0)}function j2e(t,e,n,i){var r,c,l,f,g,b,v,M,k,R,O,$,W,nt;if($=t.k,W=t.n,k=t.d,e){for(M=i/2*(e._b()-1),R=0,b=e.tc();b.hc();)f=a(b.ic(),8),M+=f.n.a,R=y.Math.max(R,f.n.b);for(nt=$.a-(M-W.a)/2,l=$.b-k.d+R,r=W.a/(e._b()+1),c=r,g=e.tc();g.hc();)f=a(g.ic(),8),f.k.a=nt,f.k.b=l-f.n.b,nt+=f.n.a+i/2,v=gDt(f),v.k.a=f.n.a/2-v.a.a,v.k.b=f.n.b,O=a(z(f,(Ft(),RB)),11),O.d.c.length+O.f.c.length==1&&(O.k.a=c-O.a.a,O.k.b=0,ds(O,t)),c+=r}if(n){for(M=i/2*(n._b()-1),R=0,b=n.tc();b.hc();)f=a(b.ic(),8),M+=f.n.a,R=y.Math.max(R,f.n.b);for(nt=$.a-(M-W.a)/2,l=$.b+W.b+k.a-R,r=W.a/(n._b()+1),c=r,g=n.tc();g.hc();)f=a(g.ic(),8),f.k.a=nt,f.k.b=l,nt+=f.n.a+i/2,v=gDt(f),v.k.a=f.n.a/2-v.a.a,v.k.b=0,O=a(z(f,(Ft(),RB)),11),O.d.c.length+O.f.c.length==1&&(O.k.a=c-O.a.a,O.k.b=W.b,ds(O,t)),c+=r}}function H2e(t,e){var n,i,r,c,l,f,g,b,v,M,k;for(r=new H(t.a.b);r.aPs||e.o==y0&&v0&&th(nt,_t*Gt),It>0&&eh(nt,It*Zt);for(WV(t.b,new Mr),e=new Nt,f=new Vg(new xp(t.c).a);f.b;)l=xm(f),i=a(l.kc(),105),n=a(l.lc(),363).a,r=M_(i,!1,!1),M=h8t(e0(i),pP(r),n),LP(M,r),pt=w8t(i),pt&&nc(e,pt,0)==-1&&(e.c[e.c.length]=pt,m4t(pt,(Hn(M.b!=0),a(M.a.a.c,9)),n));for(W=new Vg(new xp(t.d).a);W.b;)$=xm(W),i=a($.kc(),105),n=a($.lc(),363).a,r=M_(i,!1,!1),M=h8t(Pm(i),TC(pP(r)),n),M=TC(M),LP(M,r),pt=v8t(i),pt&&nc(e,pt,0)==-1&&(e.c[e.c.length]=pt,m4t(pt,(Hn(M.b!=0),a(M.c.b.c,9)),n))}function q2e(t,e){var n,i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt;for(di(e,"Inverted port preprocessing",1),b=t.b,g=new Gs(b,0),n=null,rt=new Nt;g.b0&&(a(js(t.b,e),114).a.b=n)}function X2e(t,e,n,i,r){var c,l,f,g,b,v,M,k,R,O,$,W,nt;switch(k=CC(t.i),O=CC(e.i),R=sr(Xc(t.k),t.a),$=sr(Xc(e.k),e.a),g=sr(new We(R.a,R.b),hl(new Xv(k),1.3*n)),W=sr(new We($.a,$.b),hl(new Xv(O),1.3*i)),f=y.Math.abs(g.a-W.a),fr+2&&VV(t.charCodeAt(r+1),Hvt,Gvt)&&VV(t.charCodeAt(r+2),Hvt,Gvt))if(n=cre(t.charCodeAt(r+1),t.charCodeAt(r+2)),r+=2,i>0?(n&192)==128?e[f++]=n<<24>>24:i=0:n>=128&&((n&224)==192?(e[f++]=n<<24>>24,i=2):(n&240)==224?(e[f++]=n<<24>>24,i=3):(n&248)==240&&(e[f++]=n<<24>>24,i=4)),i>0){if(f==i){switch(f){case 2:{E1(g,((e[0]&31)<<6|e[1]&63)&qr);break}case 3:{E1(g,((e[0]&15)<<12|(e[1]&63)<<6|e[2]&63)&qr);break}}f=0,i=0}}else{for(c=0;c0&&Ut(t.p,v),Ut(t.o,v);e-=i,R=g+e,b+=e*t.e,Kl(t.a,f,Xt(R)),Kl(t.b,f,b),t.j=Mh(t.j,R),t.k=y.Math.max(t.k,b),t.d+=e,e+=$}}function V7t(){V7t=P;var t,e,n;for(new kL(1,0),new kL(10,0),new kL(0,0),Izt=dt(EK,wt,216,11,0,1),m0=dt(el,Pf,22,100,15,1),k1t=Y(Z(Os,1),Xo,22,15,[1,5,25,125,625,3125,15625,78125,390625,1953125,9765625,48828125,244140625,1220703125,6103515625,30517578125,152587890625,762939453125,3814697265625,19073486328125,95367431640625,476837158203125,0x878678326eac9]),L1t=dt(Gn,pi,22,k1t.length,15,1),P1t=Y(Z(Os,1),Xo,22,15,[1,10,100,aw,HP,NZ,1e6,1e7,1e8,tO,1e10,1e11,1e12,1e13,1e14,1e15,1e16]),I1t=dt(Gn,pi,22,P1t.length,15,1),R1t=dt(EK,wt,216,11,0,1),t=0;t1)for(R=new Lht(O,pt,i),vo(pt,new VMt(t,R)),l.c[l.c.length]=R,M=pt.a.Xb().tc();M.hc();)v=a(M.ic(),48),Lc(c,v.b);if(f.a._b()>1)for(R=new Lht(O,f,i),vo(f,new qMt(t,R)),l.c[l.c.length]=R,M=f.a.Xb().tc();M.hc();)v=a(M.ic(),48),Lc(c,v.b)}}function K2e(t,e){var n,i,r,c,l,f,g,b,v,M,k,R,O;for(di(e,"Label dummy switching",1),M=a(z(t,(qt(),GB)),276),i=a(hd(wo(Yh(new gi(null,new Ei(t.b,16)),new d3),new MS),PC(new Pe,new ge,new pr,Y(Z(tf,1),jt,150,0,[(U1(),Qh)]))),15),l=M==(GC(),hJ)||M==aJ?Zde(t):null,c=i.tc();c.hc();){switch(r=a(c.ic(),8),n=xde(r),!n&&(n=M),f=Wde(r),v=gde(r),k=null,n.g){case 2:k=Tge(r,l,f,v);break;case 0:k=(R=f.a._b()+v.c.length+1,O=(R-1)/2|0,Of.a._b()?a(Ee(v,O-f.a._b()-1),8):null);break;case 1:k=H0e(r,l,f,v);break;case 4:mIt(r,n),k=(b=sut(r),b?f.a._b()==0?null:a(f.a.cd(eC(f,0)),8):v.c.length==0?null:a(Ee(v,v.c.length-1),8));break;case 3:mIt(r,n),k=(g=sut(r),g?v.c.length==0?null:a(Ee(v,v.c.length-1),8):f.a._b()==0?null:a(f.a.cd(eC(f,0)),8))}k&&xye(r,k),Yfe(r)}Vn(e)}function Ght(t,e){var n,i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt;if(k=e.length,k>0&&(g=e.charCodeAt(0),g!=64)){if(g==37&&(M=e.lastIndexOf("%"),b=!1,M!=0&&(M==k-1||(b=e.charCodeAt(M+1)==46)))){if(l=e.substr(1,M-1),pt=le("%",l)?null:Hht(l),i=0,b)try{i=Au(e.substr(M+2,e.length-(M+2)),Vs,qi)}catch(_t){throw _t=vr(_t),ct(_t,118)?(f=_t,K(new yN(f))):K(_t)}for(W=pat(t.pg());W.hc();)if(O=DN(W),ct(O,469)&&(r=a(O,609),rt=r.d,(pt==null?rt==null:le(pt,rt))&&i--==0))return r;return null}if(v=e.lastIndexOf("."),R=v==-1?e:e.substr(0,v),n=0,v!=-1)try{n=Au(e.substr(v+1,e.length-(v+1)),Vs,qi)}catch(_t){if(_t=vr(_t),ct(_t,118))R=e;else throw K(_t)}for(R=le("%",R)?null:Hht(R),$=pat(t.pg());$.hc();)if(O=DN($),ct(O,174)&&(c=a(O,174),nt=c.be(),(R==null?nt==null:le(R,nt))&&n--==0))return c;return null}return d7t(t,e)}function J2e(t){Cht();var e,n,i,r,c,l,f,g,b,v,M,k,R,O,$,W;if(t==null)return null;if(M=t.length*8,M==0)return"";for(f=M%24,R=M/24|0,k=f!=0?R+1:R,c=dt(el,Pf,22,k*4,15,1),l=0,r=0,g=0;g>24,b=(e&3)<<24>>24,O=e&-128?(e>>2^192)<<24>>24:e>>2<<24>>24,$=n&-128?(n>>4^240)<<24>>24:n>>4<<24>>24,W=i&-128?(i>>6^252)<<24>>24:i>>6<<24>>24,c[l++]=t1[O],c[l++]=t1[$|b<<4],c[l++]=t1[v<<2|W],c[l++]=t1[i&63];return f==8?(e=t[r],b=(e&3)<<24>>24,O=e&-128?(e>>2^192)<<24>>24:e>>2<<24>>24,c[l++]=t1[O],c[l++]=t1[b<<4],c[l++]=61,c[l++]=61):f==16&&(e=t[r],n=t[r+1],v=(n&15)<<24>>24,b=(e&3)<<24>>24,O=e&-128?(e>>2^192)<<24>>24:e>>2<<24>>24,$=n&-128?(n>>4^240)<<24>>24:n>>4<<24>>24,c[l++]=t1[O],c[l++]=t1[$|b<<4],c[l++]=t1[v<<2],c[l++]=61),ml(c,0,c.length)}function Q2e(t,e){var n,i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It,Gt,Zt,ce,ae,Te;for(Gt=e.a.c,b=e.a.c+e.a.b,pt=t.c&&ume(t,e),i=pt?(Gt+b)/2:Gt+(e.s+1)*t.b,f=e.d.a.Xb().tc();f.hc();)if(l=a(f.ic(),14),g=a(zi(e.c,l),589),ae=g.f,Te=g.a,It=new We(i,ae),ce=new We(i,Te),_t=new We(Gt-10,ae),Zt=new We(b,Te),M=!1,k=!1,g.b&&(M=!0,_t.a=b),g.c&&(k=!0,Zt.a=Gt-10),R=g.d,O=g.e,!pt||!(R||O)||k||M)e.d.a._b()==1?MN(l.a,Y(Z(ss,1),wt,9,0,[_t,It,ce,Zt])):(n=new We(i,e.b),MN(l.a,Y(Z(ss,1),wt,9,0,[_t,It,n,ce,Zt])));else if(R&&O){for(v=0,$=0,rt=new H(l.d.g.i);rt.a=0&&lR&&(c&&(Og(_t,k),Og(Gt,Xt(b.a-1))),Me=n.b,Bn+=k+e,k=0,v=y.Math.max(v,n.b+n.c+Te)),th(f,Me),eh(f,Bn),v=y.Math.max(v,Me+Te+n.c),k=y.Math.max(k,M),Me+=Te+e;if(v=y.Math.max(v,i),ae=Bn+k+n.a,ae0&&(t.p=-(t.p-1)),t.p>Vs&&pct(e,t.p-Nm),l=e.q.getDate(),wL(e,1),t.k>=0&&Soe(e,t.k),t.c>=0?wL(e,t.c):t.k>=0?(g=new Tat(e.q.getFullYear()-Nm,e.q.getMonth(),35),i=35-g.q.getDate(),wL(e,i0&&t.f<12&&(t.f+=12),See(e,t.f==24&&t.g?0:t.f),t.j>=0&&bae(e,t.j),t.n>=0&&kae(e,t.n),t.i>=0&&cMt(e,so(Xg(lP(Ka(e.q.getTime()),aw),aw),t.i)),t.a&&(r=new N9,pct(r,r.q.getFullYear()-Nm-80),$G(Ka(e.q.getTime()),Ka(r.q.getTime()))&&pct(e,r.q.getFullYear()-Nm+100)),t.d>=0){if(t.c==-1)n=(7+t.d-e.q.getDay())%7,n>3&&(n-=7),f=e.q.getMonth(),wL(e,e.q.getDate()+n),e.q.getMonth()!=f&&wL(e,e.q.getDate()+(n>0?-7:7));else if(e.q.getDay()!=t.d)return!1}return t.o>Vs&&(c=e.q.getTimezoneOffset(),cMt(e,so(Ka(e.q.getTime()),(t.o-c)*60*aw))),!0}function q7t(){q7t=P,ps=new Iv,cr(ps,(Ht(),sI),Ad),cr(ps,nI,Td),cr(ps,iI,Cd),cr(ps,rI,zf),cr(ps,x0,sb),cr(ps,x0,Cd),cr(ps,x0,zf),cr(ps,sb,x0),cr(ps,sb,Ad),cr(ps,sb,Td),cr(ps,Ix,Ix),cr(ps,Ix,Cd),cr(ps,Ix,Ad),cr(ps,uy,uy),cr(ps,uy,Cd),cr(ps,uy,Td),cr(ps,ly,ly),cr(ps,ly,zf),cr(ps,ly,Ad),cr(ps,ay,ay),cr(ps,ay,zf),cr(ps,ay,Td),cr(ps,Cd,iI),cr(ps,Cd,x0),cr(ps,Cd,Ix),cr(ps,Cd,uy),cr(ps,Cd,Cd),cr(ps,Cd,Ad),cr(ps,Cd,Td),cr(ps,zf,rI),cr(ps,zf,x0),cr(ps,zf,ly),cr(ps,zf,ay),cr(ps,zf,zf),cr(ps,zf,Ad),cr(ps,zf,Td),cr(ps,Ad,sI),cr(ps,Ad,sb),cr(ps,Ad,Ix),cr(ps,Ad,ly),cr(ps,Ad,Cd),cr(ps,Ad,zf),cr(ps,Ad,Ad),cr(ps,Td,nI),cr(ps,Td,sb),cr(ps,Td,uy),cr(ps,Td,ay),cr(ps,Td,Cd),cr(ps,Td,zf),cr(ps,Td,Td)}function nxe(){bi(vI,new n8),bi(ZF,new Y0),bi(_I,new KS),bi(l_t,new Jz),bi(At,new tj),bi(Z(Da,1),new ej),bi(ho,new nj),bi(ux,new J0),bi(At,new KR),bi(At,new JR),bi(At,new Gz),bi(To,new QR),bi(At,new Xy),bi(Sl,new O3),bi(Sl,new Wz),bi(At,new t8),bi(ME,new e8),bi(At,new qS),bi(At,new XS),bi(At,new Yk),bi(At,new ZS),bi(At,new $z),bi(Z(Da,1),new i8),bi(At,new YS),bi(At,new r8),bi(Sl,new Kk),bi(Sl,new Vz),bi(At,new s8),bi(Io,new o8),bi(At,new c8),bi(Gm,new qz),bi(At,new a8),bi(At,new Xz),bi(At,new Zz),bi(At,new K0),bi(Sl,new Jk),bi(Sl,new Qk),bi(At,new t5),bi(At,new Zy),bi(At,new cs),bi(At,new JS),bi(At,new e5),bi(At,new _v),bi(Wm,new Yz),bi(At,new n5),bi(At,new u8),bi(At,new zh),bi(Wm,new Kz),bi(Gm,new l8),bi(At,new Qz),bi(Io,new h8)}function ixe(t,e){var n,i,r,c,l,f,g,b,v,M,k,R;for(i=a(z(t,(Ft(),li)),35),th(i,t.k.a+e.a),eh(i,t.k.b+e.b),(a(cn(i,(qt(),yw)),185)._b()!=0||z(t,xd)!=null||zt(z(Mc(t),qB))===zt((UC(),F6))&&NEt((Qb(),(t.p?t.p:(we(),we(),ap)).Qb(Zm)?M=a(z(t,Zm),179):M=a(z(Mc(t),Y4),179),M)))&&(i_(i,t.n.a),n_(i,t.n.b)),v=new H(t.i);v.a1;)e=y.Math.min(c,t.c),b=(M=new Jh(t.e.c),jl(M,(Ke(),Jc)),Ct(M,(qt(),Qi),a(z(b,Qi),83)),Ct(M,Oh,a(z(b,Oh),185)),M.o=t.e.b++,Ut(t.b,M),M.n.b=b.n.b,M.n.a=e,k=new Eo,yr(k,(Ht(),Qe)),ds(k,b),k.k.a=M.n.a,k.k.b=M.n.b/2,R=new Eo,yr(R,on),ds(R,M),R.k.b=M.n.b/2,R.k.a=-R.n.a,O=new Np,Hs(O,k),Ts(O,R),M),Ut(t.e.c.a,b),--v,c-=t.c+t.e.d;for(new Zut(t.d,t.b,t.c),f=new H(r);f.a=e.length)return{done:!0};var r=e[i++];return{value:[r,n.get(r)],done:!1}}}},Iwe()||(t.prototype.createObject=function(){return{}},t.prototype.get=function(e){return this.obj[":"+e]},t.prototype.set=function(e,n){this.obj[":"+e]=n},t.prototype[BZ]=function(e){delete this.obj[":"+e]},t.prototype.keys=function(){var e=[];for(var n in this.obj)n.charCodeAt(0)==58&&e.push(n.substring(1));return e}),t}function oxe(t,e){var n,i,r,c,l,f,g,b,v;if(Dp(Rs(e))!=1||a(iN(Rs(e)),14).c.g.j!=(Ke(),Hr))return null;for(n=a(iN(Rs(e)),14),i=n.c.g,jl(i,(Ke(),gs)),Ct(i,(Ft(),Pu),null),Ct(i,Iu,null),Ct(i,C6,a(z(e,C6),126)),Ct(i,bw,(me(),me(),!0)),Ct(i,li,z(e,li)),i.n.b=e.n.b,c=z(n.d,li),l=null,b=Ja(i,(Ht(),on)).tc();b.hc();)if(f=a(b.ic(),11),f.d.c.length!=0){Ct(f,li,c),v=n.d,f.n.a=v.n.a,f.n.b=v.n.b,f.a.a=v.a.a,f.a.b=v.a.b,Or(f.e,v.e),v.e.c=dt(un,te,1,0,5,1),l=f;break}if(Ct(n.d,li,null),Dp(Ja(e,on))>1)for(g=qn(fl(Ja(e,on)),0);g.b!=g.d.c;)f=a(Yn(g),11),f.d.c.length==0?(r=new Eo,yr(r,on),r.n.a=f.n.a,r.n.b=f.n.b,ds(r,i),Ct(r,li,z(f,li)),ds(f,null)):ds(l,i);return Ct(e,li,null),Ct(e,bw,!1),jl(e,Jc),Ct(i,(qt(),Qi),a(z(e,Qi),83)),Ct(i,Oh,a(z(e,Oh),185)),hm(t.b,0,i),i}function cxe(t,e,n){var i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt;for(di(n,"Polyline edge routing",1),R=lt(Yt(z(e,(qt(),Sw)))),r=lt(Yt(z(e,Mx))),i=y.Math.min(1,r/R),rt=0,e.b.c.length!=0&&(pt=$9t(a(Ee(e.b,0),26)),rt=.4*i*pt),f=new Gs(e.b,0);f.b0&&(rt-=R),Oht(l,rt),v=0,k=new H(l.a);k.a0),f.a.cd(f.c=--f.b)),g=.4*i*v,!c&&f.b0||v.i==on&&v.d.c.length-v.f.c.length<0)){n=!1;break}if(v.i==on){for(r=new H(v.f);r.a=f){Hn(W.b>0),W.a.cd(W.c=--W.b);break}else O.a>g&&(r?(Or(r.b,O.b),r.a=y.Math.max(r.a,O.a),Th(W)):(Ut(O.b,v),O.c=y.Math.min(O.c,g),O.a=y.Math.max(O.a,f),r=O));r||(r=new axt,r.c=g,r.a=f,cd(W,r),Ut(r.b,v))}for(l=e.b,b=0,$=new H(i);$.a<$.c.c.length;)for(O=a(G($),511),c=new dl(e),c.o=b++,l.c[l.c.length]=c,R=new H(O.b);R.a0&&Pc(i,-6)>=0){if(Pc(i,0)>=0){for(r=n+or(i),l=17;l>=r;l--)b[l+1]=b[l];return b[++r]=46,f&&(b[--n]=45),ml(b,n,18-n+1)}for(c=2;$G(c,so(LM(i),1));c++)b[--n]=48;return b[--n]=46,b[--n]=48,f&&(b[--n]=45),ml(b,n,18-n)}return k=n+1,v=new Db,f&&(v.a+="-"),18-k>=1?(E1(v,b[n]),v.a+=".",v.a+=ml(b,n+1,18-n-1)):v.a+=ml(b,n,18-n),v.a+="E",Pc(i,0)>0&&(v.a+="+"),v.a+=""+ID(i),v.a}function J7t(t){var e,n,i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It,Gt,Zt,ce,ae,Te,Me,Bn,Pi,ls;for(M=a(z(t,(I1(),hx)),35),nt=qi,rt=qi,$=Vs,W=Vs,_t=new H(t.e);_t.a<_t.c.c.length;)pt=a(G(_t),146),ae=pt.d,Te=pt.e,nt=y.Math.min(nt,ae.a-Te.a/2),rt=y.Math.min(rt,ae.b-Te.b/2),$=y.Math.max($,ae.a+Te.a/2),W=y.Math.max(W,ae.b+Te.b/2);for(ce=a(cn(M,(Ph(),vjt)),119),Zt=new We(ce.b-nt,ce.d-rt),f=new H(t.e);f.ae.d.c){if(R=t.c[e.a.d],W=t.c[M.a.d],R==W)continue;ih($l(Wl(Vl(Gl(new cl,1),100),R),W))}}}}}function dxe(t,e,n,i,r,c){var l,f,g,b,v,M;for(b=new Eo,Uo(b,e),yr(b,a(cn(e,(qt(),K4)),69)),Ct(b,(Ft(),li),e),ds(b,n),M=b.n,M.a=e.g,M.b=e.f,v=b.k,v.a=e.i,v.b=e.j,wr(t.a,e,b),l=hN(Vh(Yh(new gi(null,(!e.e&&(e.e=new pn(Xs,e,7,4)),new Ei(e.e,16))),new _a),new $c),new aH(e)),l||(l=hN(Vh(Yh(new gi(null,(!e.d&&(e.d=new pn(Xs,e,8,5)),new Ei(e.d,16))),new ff),new ws),new uH(e))),l||(l=hN(new gi(null,(!e.e&&(e.e=new pn(Xs,e,7,4)),new Ei(e.e,16))),new Bl)),Ct(b,A6,(me(),!!l)),vye(b,c,r,a(cn(e,xw),9)),g=new $n((!e.n&&(e.n=new Wt(ic,e,1,7)),e.n));g.e!=g.i._b();)f=a(ci(g),137),!lt(de(cn(f,w0)))&&f.a&&Ut(b.e,pq(f));switch((!e.d&&(e.d=new pn(Xs,e,8,5)),e.d).i+(!e.e&&(e.e=new pn(Xs,e,7,4)),e.e).i>1&&i.nc((So(),H4)),r.g){case 2:case 1:(b.i==(Ht(),Tn)||b.i==fi)&&i.nc((So(),Z_));break;case 4:case 3:(b.i==(Ht(),Qe)||b.i==on)&&i.nc((So(),Z_))}return b}function X1(t,e){Ai();var n,i,r,c,l,f,g,b,v,M,k,R,O;if(J3(VE)==0){for(M=dt(X3e,wt,112,vXt.length,0,1),l=0;lb&&(i.a+=UEt(dt(el,Pf,22,-b,15,1))),i.a+="Is",Mf(g,Ca(32))>=0)for(r=0;r0){if(l+i>t.length)return!1;f=y7(t.substr(0,l+i),e)}else f=y7(t,e);switch(c){case 71:return f=w_(t,l,Y(Z(At,1),wt,2,6,[COt,AOt]),e),r.e=f,!0;case 77:return vwe(t,e,r,f,l);case 76:return _we(t,e,r,f,l);case 69:return h0e(t,e,l,r);case 99:return f0e(t,e,l,r);case 97:return f=w_(t,l,Y(Z(At,1),wt,2,6,["AM","PM"]),e),r.b=f,!0;case 121:return Cwe(t,e,l,f,n,r);case 100:return f<=0?!1:(r.c=f,!0);case 83:return f<0?!1:yfe(f,l,e[0],r);case 104:f==12&&(f=0);case 75:case 72:return f<0?!1:(r.f=f,r.g=!1,!0);case 107:return f<0?!1:(r.f=f,r.g=!0,!0);case 109:return f<0?!1:(r.j=f,!0);case 115:return f<0?!1:(r.n=f,!0);case 90:if(lce[g]&&(W=g),M=new H(t.b.b);M.a0?k=nP(f):k=tP(nP(f)),t.ze(K4,k)),k.g){case 4:Ct(v,la,(bl(),vw)),Ct(v,kJ,(o_(),z4)),v.n.b=l.b,yr(M,(Ht(),Qe)),M.k.b=b.b;break;case 2:Ct(v,la,(bl(),Xm)),Ct(v,kJ,(o_(),E6)),v.n.b=l.b,yr(M,(Ht(),on)),M.k.b=b.b;break;case 1:Ct(v,b0,(tp(),Y_)),v.n.a=l.a,yr(M,(Ht(),fi)),M.k.a=b.a;break;case 3:Ct(v,b0,(tp(),dx)),v.n.a=l.a,yr(M,(Ht(),Tn)),M.k.a=b.a}if(e==Lx||e==Sd||e==Gc){if(R=0,e==Lx&&t.ye(v0))switch(k.g){case 1:case 2:R=a(t.xe(v0),21).a;break;case 3:case 4:R=-a(t.xe(v0),21).a}else switch(k.g){case 4:case 2:R=c.b,e==Sd&&(R/=r.b);break;case 1:case 3:R=c.a,e==Sd&&(R/=r.a)}Ct(v,qm,R)}return Ct(v,wc,k),v}function vxe(t,e){var n,i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It,Gt;if(k=a(a(rr(t.r,e),19),60),e==(Ht(),Qe)||e==on){W7t(t,e);return}for(c=e==Tn?(Sm(),lI):(Sm(),hI),_t=e==Tn?(Ha(),Fh):(Ha(),dh),n=a(js(t.b,e),114),i=n.i,r=i.c+t_(Y(Z(Os,1),Xo,22,15,[n.n.b,t.A.b,t.k])),nt=i.c+i.b-t_(Y(Z(Os,1),Xo,22,15,[n.n.c,t.A.c,t.k])),l=Oit(Gst(c),t.s),rt=e==Tn?RY:ix,M=k.tc();M.hc();)b=a(M.ic(),111),!(!b.c||b.c.d.c.length<=0)&&(W=b.b.Re(),$=b.e,R=b.c,O=R.i,O.b=(g=R.n,R.e.a+g.b+g.c),O.a=(f=R.n,R.e.b+f.d+f.a),T$(_t,_pt),R.f=_t,Cf(R,(hu(),fh)),O.c=$.a-(O.b-W.a)/2,It=y.Math.min(r,$.a),Gt=y.Math.max(nt,$.a+W.a),O.cGt&&(O.c=Gt-O.b),Ut(l.d,new d$(O,Yat(l,O))),rt=e==Tn?y.Math.max(rt,$.b+b.b.Re().b):y.Math.min(rt,$.b));for(rt+=e==Tn?t.s:-t.s,pt=aut((l.e=rt,l)),pt>0&&(a(js(t.b,e),114).a.b=pt),v=k.tc();v.hc();)b=a(v.ic(),111),!(!b.c||b.c.d.c.length<=0)&&(O=b.c.i,O.c-=b.e.a,O.d-=b.e.b)}function tOt(t,e,n){var i,r,c,l,f,g,b,v,M,k;if(i=new qh(e.Qe().a,e.Qe().b,e.Re().a,e.Re().b),r=new oM,t.c)for(l=new H(e.We());l.a=2){if((!t.a&&(t.a=new Wt(os,t,6,6)),t.a).i==0)n=(sm(),r=new I3,r),ni((!t.a&&(t.a=new Wt(os,t,6,6)),t.a),n);else if((!t.a&&(t.a=new Wt(os,t,6,6)),t.a).i>1)for(k=new WT((!t.a&&(t.a=new Wt(os,t,6,6)),t.a));k.e!=k.i._b();)HC(k);LP(e,a(at((!t.a&&(t.a=new Wt(os,t,6,6)),t.a),0),270))}if(M)for(i=new $n((!t.a&&(t.a=new Wt(os,t,6,6)),t.a));i.e!=i.i._b();)for(n=a(ci(i),270),b=new $n((!n.a&&(n.a=new Ss(sf,n,5)),n.a));b.e!=b.i._b();)g=a(ci(b),531),f.a=y.Math.max(f.a,g.a),f.b=y.Math.max(f.b,g.b);for(l=new $n((!t.n&&(t.n=new Wt(ic,t,1,7)),t.n));l.e!=l.i._b();)c=a(ci(l),137),v=a(cn(c,gA),9),v&&Wd(c,v.a,v.b),M&&(f.a=y.Math.max(f.a,c.i+c.g),f.b=y.Math.max(f.b,c.j+c.f));return f}function _xe(t,e,n){var i,r,c,l,f,g,b,v,M,k,R;if(t.e.a.Pb(),t.f.a.Pb(),t.c.c=dt(un,te,1,0,5,1),t.i.c=dt(un,te,1,0,5,1),t.g.a.Pb(),e)for(l=new H(e.a);l.a>4)<<24>>24,M[k++]=((n&15)<<4|i>>2&15)<<24>>24,M[k++]=(i<<6|r)<<24>>24}return!R5(l=c[v++])||!R5(f=c[v++])?null:(e=af[l],n=af[f],g=c[v++],b=c[v++],af[g]==-1||af[b]==-1?g==61&&b==61?n&15?null:(W=dt(Da,z_,22,R*3+1,15,1),Aa(M,0,W,0,R*3),W[k]=(e<<2|n>>4)<<24>>24,W):g!=61&&b==61?(i=af[g],i&3?null:(W=dt(Da,z_,22,R*3+2,15,1),Aa(M,0,W,0,R*3),W[k++]=(e<<2|n>>4)<<24>>24,W[k]=((n&15)<<4|i>>2&15)<<24>>24,W)):null:(i=af[g],r=af[b],M[k++]=(e<<2|n>>4)<<24>>24,M[k++]=((n&15)<<4|i>>2&15)<<24>>24,M[k++]=(i<<6|r)<<24>>24,M))}function xxe(t,e,n){var i,r,c,l,f,g,b,v,M,k;for(g=new Nt,M=e.length,l=Aat(n),b=0;bf&&(pt=0,_t+=l+nt,l=0),Tve($,n,pt,_t),e=y.Math.max(e,pt+W.a),l=y.Math.max(l,W.b),pt+=W.a+nt;return $}function Mxe(t,e,n){var i,r,c,l,f;switch(i=e.i,c=t.g.n,r=t.g.d,f=t.k,l=zo(Y(Z(ss,1),wt,9,0,[f,t.a])),t.i.g){case 1:qd(e,(Ha(),dh)),i.d=-r.d-n-i.a,a(a(_M(e.d).a.cd(0),271).xe((Ft(),bx)),265)==(Tu(),kd)?(Cf(e,(hu(),fh)),i.c=l.a-lt(Yt(z(t,K_)))-n-i.b):(Cf(e,(hu(),jf)),i.c=l.a+lt(Yt(z(t,K_)))+n);break;case 2:Cf(e,(hu(),jf)),i.c=c.a+r.c+n,a(a(_M(e.d).a.cd(0),271).xe((Ft(),bx)),265)==(Tu(),kd)?(qd(e,(Ha(),dh)),i.d=l.b-lt(Yt(z(t,K_)))-n-i.a):(qd(e,(Ha(),Fh)),i.d=l.b+lt(Yt(z(t,K_)))+n);break;case 3:qd(e,(Ha(),Fh)),i.d=c.b+r.a+n,a(a(_M(e.d).a.cd(0),271).xe((Ft(),bx)),265)==(Tu(),kd)?(Cf(e,(hu(),fh)),i.c=l.a-lt(Yt(z(t,K_)))-n-i.b):(Cf(e,(hu(),jf)),i.c=l.a+lt(Yt(z(t,K_)))+n);break;case 4:Cf(e,(hu(),fh)),i.c=-r.b-n-i.b,a(a(_M(e.d).a.cd(0),271).xe((Ft(),bx)),265)==(Tu(),kd)?(qd(e,(Ha(),dh)),i.d=l.b-lt(Yt(z(t,K_)))-n-i.a):(qd(e,(Ha(),Fh)),i.d=l.b+lt(Yt(z(t,K_)))+n)}}function iOt(t,e){var n,i,r,c,l,f,g,b,v,M,k,R,O;switch(l=new fCt(t),f=fd(Xd(e,l)),we(),gc(f,new Iy),r=t.b,r.c){case 2:g=new Ib(r.a),n=FT(Xd(f,g)),s_(n)?b=a(L2(n),188).b:b=15,g=new Ib(Lut(r)),n=FT(Xd(f,g)),s_(n)?c=a(L2(n),188).b:c=15,g=new Ib(r.b),n=FT(Xd(f,g)),s_(n)?v=a(L2(n),188).b:v=15,i=dbe(t,b,c,v),Ir(e,new QC(i,t.c,t.e,t.a.c.g,r.a)),Ir(e,new QC(i,t.c,t.e,t.a.c.g,Lut(r))),Ir(e,new QC(i,t.c,t.e,t.a.c.g,r.b));break;case 1:g=new Ib(r.a),n=FT(Xd(f,g)),s_(n)?b=a(L2(n),188).b:b=15,g=new Ib(r.b),n=FT(Xd(f,g)),s_(n)?v=a(L2(n),188).b:v=15,i=ibe(t,b,v),Ir(e,new QC(i,t.c,t.e,t.a.c.g,r.a)),Ir(e,new QC(i,t.c,t.e,t.a.c.g,r.b));break;case 0:g=new Ib(r.a),n=FT(Xd(f,g)),s_(n)?b=a(L2(n),188).b:b=15,i=(M=t.b,k=Fve(t.a.c,t.a.d,b),yo(t.a.a,Pq(k)),R=hlt(t.a.b,k.a,M),O=new yL((!k.k&&(k.k=new mX($V(k))),k.k)),Xot(O),R?Cot(O,R):O),Ir(e,new QC(i,t.c,t.e,t.a.c.g,r.a));break;default:throw K(new yn("The loopside must be defined."))}return i}function Exe(t,e){var n,i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It,Gt,Zt,ce,ae;for(di(e,"Compound graph postprocessor",1),n=lt(de(z(t,(qt(),$J)))),f=a(z(t,(Ft(),rmt)),238),v=new $r,nt=f.Xb().tc();nt.hc();){for(W=a(nt.ic(),14),l=new Eh(f.Mc(W)),we(),gc(l,new W8(t)),It=tle((mi(0,l.c.length),a(l.c[0],234))),Zt=EPt(a(Ee(l,l.c.length-1),234)),pt=It.g,HM(Zt.g,pt)?rt=a(z(pt,xd),31):rt=Mc(pt),M=hde(W,l),ld(W.a),k=null,c=new H(l);c.aop,ae=y.Math.abs(k.b-O.b)>op,(!n&&ce&&ae||n&&(ce||ae))&&Xi(W.a,_t)),yo(W.a,i),i.b==0?k=_t:k=(Hn(i.b!=0),a(i.c.b.c,9)),yle(R,M,$),EPt(r)==Zt&&(Mc(Zt.g)!=r.a&&($=new go,Glt($,Mc(Zt.g),rt)),Ct(W,OJ,$)),Ege(R,W,rt),v.a.Zb(R,v);Hs(W,It),Ts(W,Zt)}for(b=v.a.Xb().tc();b.hc();)g=a(b.ic(),14),Hs(g,null),Ts(g,null);Vn(e)}function Sxe(t,e){var n,i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It,Gt,Zt,ce,ae,Te,Me,Bn,Pi;for(rt=new Gs(t.b,0),v=e.tc(),O=0,b=a(v.ic(),21).a,It=0,n=new $r,Zt=new qa;rt.b=t.a&&(i=zve(t,rt),v=Mh(v,i.b),_t=Mh(_t,i.d),Ut(f,new zs(rt,i)));for(ce=new Nt,b=0;b0),W.a.cd(W.c=--W.b),ae=new dl(t.b),cd(W,ae),Hn(W.b=i.n.b/2}else rt=!M;rt?(nt=a(z(i,(Ft(),vx)),15),nt?k?c=nt:(r=a(z(i,px),15),r?nt._b()<=r._b()?c=nt:c=r:(c=new Nt,Ct(i,px,c))):(c=new Nt,Ct(i,vx,c))):(r=a(z(i,(Ft(),px)),15),r?M?c=r:(nt=a(z(i,vx),15),nt?r._b()<=nt._b()?c=r:c=nt:(c=new Nt,Ct(i,vx,c))):(c=new Nt,Ct(i,px,c))),c.nc(t),Ct(t,(Ft(),RB),n),e.d==n?(Ts(e,null),n.d.c.length+n.f.c.length==0&&ds(n,null),Gle(n)):(Hs(e,null),n.d.c.length+n.f.c.length==0&&ds(n,null)),ld(e.a)}function Axe(t){var e,n,i,r,c,l,f,g,b,v,M,k,R,O;if(zt(z(t.c,(qt(),Qi)))===zt((Ls(),Sd))||zt(z(t.c,Qi))===zt(Gc)){for(v=new H(t.c.i);v.a0&&(r=a(Ee(W.c.a,Gt-1),8),l=t.i[r.o],ce=y.Math.ceil(Uv(t.n,r,W)),c=It.a.e-W.d.d-(l.a.e+r.n.b+r.d.a)-ce),b=is,Gt0&&Zt.a.e.e-Zt.a.a-(Zt.b.e.e-Zt.b.a)<0,O=pt.a.e.e-pt.a.a-(pt.b.e.e-pt.b.a)<0&&Zt.a.e.e-Zt.a.a-(Zt.b.e.e-Zt.b.a)>0,R=pt.a.e.e+pt.b.aZt.b.e.e+Zt.a.a,_t=0,!$&&!O&&(k?c+M>0?_t=M:b-i>0&&(_t=i):R&&(c+f>0?_t=f:b-rt>0&&(_t=rt))),It.a.e+=_t,It.b&&(It.d.e+=_t),!1))}function Lxe(){var t=["\\u0000","\\u0001","\\u0002","\\u0003","\\u0004","\\u0005","\\u0006","\\u0007","\\b","\\t","\\n","\\u000B","\\f","\\r","\\u000E","\\u000F","\\u0010","\\u0011","\\u0012","\\u0013","\\u0014","\\u0015","\\u0016","\\u0017","\\u0018","\\u0019","\\u001A","\\u001B","\\u001C","\\u001D","\\u001E","\\u001F"];return t[34]='\\"',t[92]="\\\\",t[173]="\\u00ad",t[1536]="\\u0600",t[1537]="\\u0601",t[1538]="\\u0602",t[1539]="\\u0603",t[1757]="\\u06dd",t[1807]="\\u070f",t[6068]="\\u17b4",t[6069]="\\u17b5",t[8203]="\\u200b",t[8204]="\\u200c",t[8205]="\\u200d",t[8206]="\\u200e",t[8207]="\\u200f",t[8232]="\\u2028",t[8233]="\\u2029",t[8234]="\\u202a",t[8235]="\\u202b",t[8236]="\\u202c",t[8237]="\\u202d",t[8238]="\\u202e",t[8288]="\\u2060",t[8289]="\\u2061",t[8290]="\\u2062",t[8291]="\\u2063",t[8292]="\\u2064",t[8298]="\\u206a",t[8299]="\\u206b",t[8300]="\\u206c",t[8301]="\\u206d",t[8302]="\\u206e",t[8303]="\\u206f",t[65279]="\\ufeff",t[65529]="\\ufff9",t[65530]="\\ufffa",t[65531]="\\ufffb",t}function mu(){mu=P,ig=new C1("N",0,(Ht(),Tn),Tn,0),Tw=new C1("EN",1,Qe,Tn,1),Km=new C1("E",2,Qe,Qe,0),Jm=new C1("SE",3,fi,Qe,1),Yp=new C1("S",4,fi,fi,0),kw=new C1("WS",5,on,fi,1),Aw=new C1("W",6,on,on,0),hp=new C1("NW",7,Tn,on,1),Zp=new C1("ENW",8,Qe,on,2),Cw=new C1("ESW",9,Qe,on,2),Qm=new C1("SEN",10,fi,Tn,2),ny=new C1("SWN",11,fi,Tn,2),Sx=new C1(nx,12,Wc,Wc,3),qWt=Wfe(ig,Tw,Km,Jm,Yp,kw,Y(Z(iA,1),jt,129,0,[Aw,hp,Zp,Cw,Qm,ny])),ZWt=(Hb(),v_(Y(Z(un,1),te,1,5,[ig,Km,Yp,Aw]))),XWt=v_(Y(Z(un,1),te,1,5,[Tw,Jm,kw,hp])),t$t=new s2(Tn),KWt=v_(Y(Z(un,1),te,1,5,[Qe,Tn])),YWt=new s2(Qe),i$t=v_(Y(Z(un,1),te,1,5,[fi,Qe])),n$t=new s2(fi),a$t=v_(Y(Z(un,1),te,1,5,[on,fi])),c$t=new s2(on),e$t=v_(Y(Z(un,1),te,1,5,[Tn,on])),JWt=v_(Y(Z(un,1),te,1,5,[Qe,Tn,on])),QWt=v_(Y(Z(un,1),te,1,5,[Qe,fi,on])),s$t=v_(Y(Z(un,1),te,1,5,[fi,on,Tn])),r$t=v_(Y(Z(un,1),te,1,5,[fi,Qe,Tn])),o$t=(bM(),I4)}function Pxe(t){var e,n,i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It,Gt,Zt,ce;if(n=lt(Yt(z(t.a.j,(qt(),Nmt)))),n<-1||!t.a.i||XT(a(z(t.a.o,Qi),83))||ac(t.a.o,(Ht(),Qe))._b()<2&&ac(t.a.o,on)._b()<2)return!0;if(t.a.c.pf())return!1;for(_t=0,pt=0,rt=new Nt,g=t.a.e,b=0,v=g.length;b=n}function Ixe(t,e){var n,i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t;for(di(e,yBt,1),R=a(z(t,(qt(),ng)),197),r=new H(t.b);r.a=2){for(O=!0,M=new H(c.i),n=a(G(M),11);M.a0){for(k=v<100?null:new b1(v),b=new bat(e),O=b.g,nt=dt(Gn,pi,22,v,15,1),i=0,_t=new Qv(v),r=0;r=0;)if(f!=null?Fi(f,O[g]):O[g]==null){nt.length<=i&&(W=nt,nt=dt(Gn,pi,22,2*nt.length,15,1),Aa(W,0,nt,0,i)),nt[i++]=r,ni(_t,O[g]);break t}if(zt(f)===zt(f))break}}if(O=_t.g,i>nt.length&&(W=nt,nt=dt(Gn,pi,22,i,15,1),Aa(W,0,nt,0,i)),i>0){for(pt=!0,c=0;c=0;)U2(t,nt[l]);if(i!=i){for(r=i;--r>=i;)U2(_t,r);W=nt,nt=dt(Gn,pi,22,i,15,1),Aa(W,0,nt,0,i)}e=_t}}}else for(e=cpe(t,e),r=t.i;--r>=0;)e.pc(t.g[r])&&(U2(t,r),pt=!0);if(pt){if(nt!=null){for(n=e._b(),M=n==1?rC(t,4,e.tc().ic(),null,nt[0],$):rC(t,6,e,nt,nt[0],$),k=n<100?null:new b1(n),r=e.tc();r.hc();)R=r.ic(),k=Dst(t,a(R,75),k);k?(k.Sh(M),k.Th()):Bi(t.e,M)}else{for(k=gne(e._b()),r=e.tc();r.hc();)R=r.ic(),k=Dst(t,a(R,75),k);k&&k.Th()}return!0}else return!1}function Dxe(t,e,n){var i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It,Gt,Zt,ce,ae,Te,Me,Bn,Pi,ls;for(di(n,"MinWidth layering",1),R=e.b,Zt=e.a,ls=a(z(e,(qt(),qmt)),21).a,f=a(z(e,Xmt),21).a,t.b=lt(Yt(z(e,nf))),t.d=is,_t=new H(Zt);_t.a<_t.c.c.length;)rt=a(G(_t),8),rt.j==(Ke(),gs)&&(Te=rt.n.b,t.d=y.Math.min(t.d,Te));for(t.d=y.Math.max(1,t.d),ce=Zt.c.length,t.c=dt(Gn,pi,22,ce,15,1),t.f=dt(Gn,pi,22,ce,15,1),t.e=dt(Os,Xo,22,ce,15,1),b=0,t.a=0,It=new H(Zt);It.a0||n.o==rf&&r0?(M=a(Ee(k.c.a,l-1),8),ce=Uv(t.b,k,M),W=k.k.b-k.d.d-(M.k.b+M.n.b+M.d.a+ce)):W=k.k.b-k.d.d,b=y.Math.min(W,b),l=1&&(ce-b>0&&O>=0?(th(M,M.i+Zt),eh(M,M.j+g*b)):ce-b<0&&R>=0&&(th(M,M.i+Zt*ce),eh(M,M.j+g)));return ga(t,FE,(c=a(yu(vA),10),new ja(c,a(cu(c,c.length),10),0))),new We(ae,v)}function Fxe(t){var e,n,i,r,c,l,f,g,b,v,M,k,R,O,$,W;for($=new Nt,k=new H(t.d.b);k.ar.d.d+r.d.a?v.f.d=!0:(v.f.d=!0,v.f.a=!0))),i.b!=i.d.c&&(e=n);v&&(c=a(zi(t.f,l.d.g),57),e.bc.d.d+c.d.a?v.f.d=!0:(v.f.d=!0,v.f.a=!0))}for(f=Rn(Rs(R));Jn(f);)l=a(In(f),14),l.a.b!=0&&(e=a(hD(l.a),9),l.d.i==(Ht(),Tn)&&(W=new r4(e,new We(e.a,r.d.d),r,l),W.f.a=!0,W.a=l.d,$.c[$.c.length]=W),l.d.i==fi&&(W=new r4(e,new We(e.a,r.d.d+r.d.a),r,l),W.f.d=!0,W.a=l.d,$.c[$.c.length]=W))}return $}function Uxe(){kit();function t(i){var r=this;this.dispatch=function(c){var l=c.data;switch(l.cmd){case"algorithms":var f=cut((we(),new Pb(new vf(Rw.b))));i.postMessage({id:l.id,data:f});break;case"categories":var g=cut((we(),new Pb(new vf(Rw.c))));i.postMessage({id:l.id,data:g});break;case"options":var b=cut((we(),new Pb(new vf(Rw.d))));i.postMessage({id:l.id,data:b});break;case"register":tye(l.algorithms),i.postMessage({id:l.id});break;case"layout":pbe(l.graph,l.options||{}),i.postMessage({id:l.id,data:l.graph});break}},this.saveDispatch=function(c){try{r.dispatch(c)}catch(l){delete l[dZ],i.postMessage({id:c.data.id,error:l.message})}}}function e(i){var r=this;this.dispatcher=new t({postMessage:function(c){r.onmessage({data:c})}}),this.postMessage=function(c){setTimeout(function(){r.dispatcher.saveDispatch({data:c})},0)}}if(typeof document===Bpt&&typeof self!==Bpt){var n=new t(self);self.onmessage=n.saveDispatch}else typeof m!==Bpt&&m.exports&&(Object.defineProperty(_,"__esModule",{value:!0}),m.exports={default:e,Worker:e})}function oOt(t,e){var n,i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t;if(rt=0,e.e.a==0)for(W=new H(t);W.a50?nt.c[nt.c.length]=r:r.k>0?rt.c[rt.c.length]=r:pt.c[pt.c.length]=r;if(rt.c.length==1&&nt.c.length==0&&(Or(nt,rt),rt.c=dt(un,te,1,0,5,1)),nt.c.length!=0&&Pp(PW(t.a),(mu(),ig))&&Pp(PW(t.a),(mu(),Yp))?efe(t,nt):Or(rt,nt),rt.c.length==0||nfe(t,rt),pt.c.length!=0){if(n=LW(t.a),n.c!=0)for(v=new H(pt),g=(si(n),Qrt(new IEt(n).a));v.a1&&($=a(hat(g),129),OC(r,$,!0),QT(v),V4t(t.a,$))}for(k=pt.c.length,i=sve(t),R=new Nt,l=k/Drt(t.a).c|0,f=0;f3&&(Or(R,(mu(),mu(),XWt)),O-=4),O){case 3:Ut(R,MP(i));case 2:W=L7(MP(i));do W=L7(W);while(!Pp(PW(t.a),W));R.c[R.c.length]=W,W=Ylt(MP(i));do W=Ylt(W);while(!Pp(PW(t.a),W));R.c[R.c.length]=W;break;case 1:Ut(R,MP(i))}for(M=new H(R),b=new H(pt);M.a$&&(c&&(Og(Gt,R),Og(ce,Xt(v.b-1)),Ut(t.d,O),f.c=dt(un,te,1,0,5,1)),Pi=n.b,ls+=R+e,R=0,M=y.Math.max(M,n.b+n.c+Bn)),f.c[f.c.length]=g,rRt(g,Pi,ls),M=y.Math.max(M,Pi+Bn+n.c),R=y.Math.max(R,k),Pi+=Bn+e,O=g;if(Or(t.a,f),Ut(t.d,a(Ee(f,f.c.length-1),145)),M=y.Math.max(M,i),Me=ls+R+n.a,Me1&&(l=y.Math.min(l,y.Math.abs(a(j1(f.a,1),9).b-v.b)))));else for($=new H(e.i);$.a<$.c.c.length;)for(O=a(G($),11),g=new H(O.d);g.ar&&(c=k.a-r,l=qi,i.c=dt(un,te,1,0,5,1),r=k.a),k.a>=r&&(i.c[i.c.length]=f,f.a.b>1&&(l=y.Math.min(l,y.Math.abs(a(j1(f.a,f.a.b-2),9).b-k.b)))));if(i.c.length!=0&&c>e.n.a/2&&l>e.n.b/2){for(R=new Eo,ds(R,e),yr(R,(Ht(),Tn)),R.k.a=e.n.a/2,nt=new Eo,ds(nt,e),yr(nt,fi),nt.k.a=e.n.a/2,nt.k.b=e.n.b,g=new H(i);g.a=b.b?Hs(f,nt):Hs(f,R)):(b=a(ere(f.a),9),W=f.a.b==0?Yl(f.c):a(hD(f.a),9),W.b>=b.b?Ts(f,nt):Ts(f,R)),M=a(z(f,(qt(),Ro)),74),M&&O2(M,b,!0);e.k.a=r-e.n.a/2}}function $xe(t,e,n){var i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It;for(f=new H(t.a.b);f.a0)if(i=M._b(),b=Tr(y.Math.floor((i+1)/2))-1,r=Tr(y.Math.ceil((i+1)/2))-1,e.o==rf)for(v=r;v>=b;v--)e.a[_t.o]==_t&&($=a(M.cd(v),48),O=a($.a,8),!ET(n,$.b)&&R>t.b.e[O.o]&&(e.a[O.o]=_t,e.g[_t.o]=e.g[O.o],e.a[_t.o]=e.g[_t.o],e.f[e.g[_t.o].o]=(me(),!!(lt(e.f[e.g[_t.o].o])&_t.j==(Ke(),Hr))),R=t.b.e[O.o]));else for(v=b;v<=r;v++)e.a[_t.o]==_t&&(nt=a(M.cd(v),48),W=a(nt.a,8),!ET(n,nt.b)&&R=48&&e<=57){for(i=e-48;r=48&&e<=57;)if(i=i*10+e-48,i<0)throw K(new ri(ai((Kn(),Gpt))))}else throw K(new ri(ai((Kn(),oUt))));if(n=i,e==44){if(r>=t.j)throw K(new ri(ai((Kn(),aUt))));if((e=bo(t.i,r++))>=48&&e<=57){for(n=e-48;r=48&&e<=57;)if(n=n*10+e-48,n<0)throw K(new ri(ai((Kn(),Gpt))));if(i>n)throw K(new ri(ai((Kn(),uUt))))}else n=-1}if(e!=125)throw K(new ri(ai((Kn(),cUt))));t.Ck(r)?(c=(Ai(),Ai(),++Ar,new qb(9,c)),t.d=r+1):(c=(Ai(),Ai(),++Ar,new qb(3,c)),t.d=r),c.nl(i),c.ml(n),Ci(t)}}return c}function Vxe(t,e){var n,i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It,Gt,Zt,ce,ae,Te;return M=o_e(fa(t,(Ht(),Evt)),e),O=f_(fa(t,iI),e),_t=f_(fa(t,rI),e),ce=d7(fa(t,sI),e),k=d7(fa(t,nI),e),rt=f_(fa(t,Ix),e),$=f_(fa(t,uy),e),Gt=f_(fa(t,ly),e),It=f_(fa(t,ay),e),ae=d7(fa(t,sb),e),nt=f_(fa(t,x0),e),pt=f_(fa(t,Cd),e),Zt=f_(fa(t,zf),e),Te=d7(fa(t,Ad),e),R=d7(fa(t,Td),e),W=f_(fa(t,WQ),e),n=t_(Y(Z(Os,1),Xo,22,15,[rt.a,ce.a,Gt.a,Te.a])),i=t_(Y(Z(Os,1),Xo,22,15,[O.a,M.a,_t.a,W.a])),r=nt.a,c=t_(Y(Z(Os,1),Xo,22,15,[$.a,k.a,It.a,R.a])),b=t_(Y(Z(Os,1),Xo,22,15,[rt.b,O.b,$.b,pt.b])),g=t_(Y(Z(Os,1),Xo,22,15,[ce.b,M.b,k.b,W.b])),v=ae.b,f=t_(Y(Z(Os,1),Xo,22,15,[Gt.b,_t.b,It.b,Zt.b])),k1(fa(t,Evt),n+r,b+v),k1(fa(t,WQ),n+r,b+v),k1(fa(t,iI),n+r,0),k1(fa(t,rI),n+r,b+v+g),k1(fa(t,sI),0,b+v),k1(fa(t,nI),n+r+i,b+v),k1(fa(t,uy),n+r+i,0),k1(fa(t,ly),0,b+v+g),k1(fa(t,ay),n+r+i,b+v+g),k1(fa(t,sb),0,b),k1(fa(t,x0),n,0),k1(fa(t,zf),0,b+v+g),k1(fa(t,Td),n+r+i,0),l=new go,l.a=t_(Y(Z(Os,1),Xo,22,15,[n+i+r+c,ae.a,pt.a,Zt.a])),l.b=t_(Y(Z(Os,1),Xo,22,15,[b+g+v+f,nt.b,Te.b,R.b])),l}function Ic(){Ic=P,Yxt(),Mqt=ms.a,a(at(Et(ms.a),0),17),yqt=ms.f,a(at(Et(ms.f),0),17),a(at(Et(ms.f),1),29),xqt=ms.n,a(at(Et(ms.n),0),29),a(at(Et(ms.n),1),29),a(at(Et(ms.n),2),29),a(at(Et(ms.n),3),29),Rvt=ms.g,a(at(Et(ms.g),0),17),a(at(Et(ms.g),1),29),_qt=ms.c,a(at(Et(ms.c),0),17),a(at(Et(ms.c),1),17),Dvt=ms.i,a(at(Et(ms.i),0),17),a(at(Et(ms.i),1),17),a(at(Et(ms.i),2),17),a(at(Et(ms.i),3),17),a(at(Et(ms.i),4),29),Nvt=ms.j,a(at(Et(ms.j),0),17),Ivt=ms.d,a(at(Et(ms.d),0),17),a(at(Et(ms.d),1),17),a(at(Et(ms.d),2),17),a(at(Et(ms.d),3),17),a(at(Et(ms.d),4),29),a(at(Et(ms.d),5),29),a(at(Et(ms.d),6),29),a(at(Et(ms.d),7),29),vqt=ms.b,a(at(Et(ms.b),0),29),a(at(Et(ms.b),1),29),OF=ms.e,a(at(Et(ms.e),0),29),a(at(Et(ms.e),1),29),a(at(Et(ms.e),2),29),a(at(Et(ms.e),3),29),a(at(Et(ms.e),4),17),a(at(Et(ms.e),5),17),a(at(Et(ms.e),6),17),a(at(Et(ms.e),7),17),a(at(Et(ms.e),8),17),a(at(Et(ms.e),9),17),a(at(Et(ms.e),10),29),pp=ms.k,a(at(Et(ms.k),0),29),a(at(Et(ms.k),1),29)}function qxe(t,e){var n,i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It,Gt,Zt,ce,ae,Te,Me;for(ae=new Fr,Gt=new Fr,W=-1,g=new H(t);g.a=O&&(rt>O&&(R.c=dt(un,te,1,0,5,1),O=rt),R.c[R.c.length]=l);R.c.length!=0&&(k=a(Ee(R,Uq(e,R.c.length)),125),Me.a.$b(k)!=null,k.p=$++,qlt(k,ae,Gt),R.c=dt(un,te,1,0,5,1))}for(_t=t.c.length+1,f=new H(t);f.aTe.p&&(Th(n),Lc(Te.g,i),i.c>0&&(i.a=Te,Ut(Te.q,i),i.b=Zt,Ut(Zt.g,i)))}function Xxe(t,e,n){var i,r,c,l,f,g,b,v,M;if(di(n,"Network simplex node placement",1),t.e=e,t.n=a(z(e,(Ft(),ww)),266),K_e(t),y1e(t),qc(Yh(new gi(null,new Ei(t.e.b,16)),new Ak),new DH(t)),qc(wo(Yh(wo(Yh(new gi(null,new Ei(t.e.b,16)),new mv),new $y),new w),new E),new RH(t)),lt(de(z(t.e,(qt(),Z4))))&&(l=Ta(n,1),di(l,"Straight Edges Pre-Processing",1),L2e(t),Vn(l)),Tde(t.f),c=a(z(e,O6),21).a*t.f.a.c.length,OX(Iit(Rit(r$(t.f),c),!1),Ta(n,1)),t.d.a._b()!=0){for(l=Ta(n,1),di(l,"Flexible Where Space Processing",1),f=a(BW(QL(Vh(new gi(null,new Ei(t.f.a,16)),new h1),(En(new Sg),new wn))),21).a,g=a(BW(zCt(Vh(new gi(null,new Ei(t.f.a,16)),new RS),new pc)),21).a,b=g-f,v=am(new Dg,t.f),M=am(new Dg,t.f),ih($l(Wl(Gl(Vl(new cl,2e4),b),v),M)),qc(wo(wo(_ot(t.i),new S3),new T3),new b4t(f,v,b,M)),r=t.d.a.Xb().tc();r.hc();)i=a(r.ic(),189),i.g=1;OX(Iit(Rit(r$(t.f),c),!1),Ta(l,1)),Vn(l)}lt(de(z(e,Z4)))&&(l=Ta(n,1),di(l,"Straight Edges Post-Processing",1),Kge(t),Vn(l)),h2e(t),t.e=null,t.f=null,t.i=null,t.c=null,uu(t.k),t.j=null,t.a=null,t.o=null,t.d.a.Pb(),Vn(n)}function cOt(t,e,n,i,r){var c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It,Gt,Zt,ce,ae,Te,Me;for($=new Vu(e.b),_t=new Vu(e.b),k=new Vu(e.b),ce=new Vu(e.b),W=new Vu(e.b),Zt=qn(e,0);Zt.b!=Zt.d.c;)for(It=a(Yn(Zt),11),f=new H(It.f);f.a0,nt=It.f.c.length>0,b&&nt?k.c[k.c.length]=It:b?$.c[$.c.length]=It:nt&&(_t.c[_t.c.length]=It);for(O=new H($);O.a=0&&le(t.substr(f,2),"//")?(f+=2,g=xq(t,f,EA,SA),i=t.substr(f,g-f),f=g):M!=null&&(f==t.length||t.charCodeAt(f)!=47)&&(l=!1,g=Frt(t,Ca(35),f),g==-1&&(g=t.length),i=t.substr(f,g-f),f=g);if(!n&&f0&&bo(v,v.length-1)==58&&(r=v,f=g)),f=k&&(_t>k&&(M.c=dt(un,te,1,0,5,1),k=_t),M.c[M.c.length]=W);M.c.length!=0&&(v=a(Ee(M,Uq(e,M.c.length)),165),nC(Pi.a,v)!=null,v.d=R++,Vlt(v,Me,ce),M.c=dt(un,te,1,0,5,1))}for(Gt=t.c.length+1,nt=new H(t);nt.aBn.d&&(Th(n),Lc(Bn.b,i),i.c>0&&(i.a=Bn,Ut(Bn.e,i),i.b=ae,Ut(ae.b,i)))}function Jxe(t,e,n){var i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It,Gt,Zt,ce,ae,Te,Me;for(rt=new Iv,pt=new Iv,v=bm(e,kpt),i=new M4t(t,n,rt,pt),Dge(i.a,i.b,i.c,i.d,v),g=(Gt=rt.i,Gt||(rt.i=ct(rt.c,122)?new Pv(rt,a(rt.c,122)):ct(rt.c,115)?new l2(rt,a(rt.c,115)):new lM(rt,rt.c))),ce=g.tc();ce.hc();)for(Zt=a(ce.ic(),270),r=a(rr(rt,Zt),19),$=r.tc();$.hc();)if(O=$.ic(),_t=a(kp(t.d,O),270),_t)f=(!Zt.e&&(Zt.e=new pn(os,Zt,10,9)),Zt.e),ni(f,_t);else throw l=Jd(e,Df),k=BFt+O+FFt+l,R=k+wE,K(new xf(R));for(b=(It=pt.i,It||(pt.i=ct(pt.c,122)?new Pv(pt,a(pt.c,122)):ct(pt.c,115)?new l2(pt,a(pt.c,115)):new lM(pt,pt.c))),Te=b.tc();Te.hc();)for(ae=a(Te.ic(),270),c=a(rr(pt,ae),19),nt=c.tc();nt.hc();)if(W=nt.ic(),_t=a(kp(t.d,W),270),_t)M=(!ae.g&&(ae.g=new pn(os,ae,9,10)),ae.g),ni(M,_t);else throw l=Jd(e,Df),k=BFt+W+FFt+l,R=k+wE,K(new xf(R));!n.b&&(n.b=new pn(Si,n,4,7)),n.b.i!=0&&(!n.c&&(n.c=new pn(Si,n,5,8)),n.c.i!=0)&&(!n.b&&(n.b=new pn(Si,n,4,7)),n.b.i<=1&&(!n.c&&(n.c=new pn(Si,n,5,8)),n.c.i<=1))&&(!n.a&&(n.a=new Wt(os,n,6,6)),n.a).i==1&&(Me=a(at((!n.a&&(n.a=new Wt(os,n,6,6)),n.a),0),270),!zq(Me)&&!jq(Me)&&(aat(Me,a(at((!n.b&&(n.b=new pn(Si,n,4,7)),n.b),0),97)),uat(Me,a(at((!n.c&&(n.c=new pn(Si,n,5,8)),n.c),0),97))))}function aOt(t,e,n){var i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It,Gt,Zt,ce;for(t.d=new We(is,is),t.c=new We(Ps,Ps),k=e.tc();k.hc();)for(v=a(k.ic(),31),pt=new H(v.a);pt.a=It||!ihe(nt,i))&&(i=mAt(e,v)),Ks(nt,i),c=Rn(Rs(nt));Jn(c);)r=a(In(c),14),!t.a[r.o]&&($=r.c.g,--t.e[$.o],t.e[$.o]==0&&kM(XM(R,$)));for(b=v.c.length-1;b>=0;--b)Ut(e.b,(mi(b,v.c.length),a(v.c[b],26)));e.a.c=dt(un,te,1,0,5,1),Vn(n)}function e3e(t,e,n){var i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It,Gt,Zt,ce,ae,Te,Me,Bn,Pi,ls,iu,wa,e1,Nu,hg,k0,uf,mh;if(Me=ekt(t,ukt(n),e),zL(Me,Jd(e,Df)),Bn=a(kp(t.g,H2(Hg(e,GY))),35),k=Hg(e,"sourcePort"),i=null,k&&(i=H2(k)),Pi=a(kp(t.j,i),121),!Bn)throw f=RC(e),O="An edge must have a source node (edge id: '"+f,$=O+wE,K(new xf($));if(Pi&&!Rp(Tf(Pi),Bn))throw g=Jd(e,Df),W="The source port of an edge must be a port of the edge's source node (edge id: '"+g,nt=W+wE,K(new xf(nt));if(ce=(!Me.b&&(Me.b=new pn(Si,Me,4,7)),Me.b),Pi?c=Pi:c=Bn,ni(ce,c),ls=a(kp(t.g,H2(Hg(e,Opt))),35),R=Hg(e,"targetPort"),r=null,R&&(r=H2(R)),iu=a(kp(t.j,r),121),!ls)throw M=RC(e),rt="An edge must have a target node (edge id: '"+M,pt=rt+wE,K(new xf(pt));if(iu&&!Rp(Tf(iu),ls))throw b=Jd(e,Df),_t="The target port of an edge must be a port of the edge's target node (edge id: '"+b,It=_t+wE,K(new xf(It));if(ae=(!Me.c&&(Me.c=new pn(Si,Me,5,8)),Me.c),iu?l=iu:l=ls,ni(ae,l),(!Me.b&&(Me.b=new pn(Si,Me,4,7)),Me.b).i==0||(!Me.c&&(Me.c=new pn(Si,Me,5,8)),Me.c).i==0)throw v=Jd(e,Df),Gt=OFt+v,Zt=Gt+wE,K(new xf(Zt));return g7(e,Me),wa=M_(Me,!0,!0),e1=vL(e,"sourcePoint"),Nu=new iG(wa),bfe(Nu.a,e1),hg=vL(e,"targetPoint"),k0=new aG(wa),wfe(k0.a,hg),uf=bm(e,ZY),mh=new uG(wa),_1e(mh.a,uf),Te=jV(t,e,Me),Te}function rZ(t,e){$X();var n,i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It,Gt,Zt,ce,ae,Te,Me,Bn;if(Zt=t.e,R=t.d,r=t.a,Zt==0)switch(e){case 0:return"0";case 1:return oE;case 2:return"0.00";case 3:return"0.000";case 4:return"0.0000";case 5:return"0.00000";case 6:return"0.000000";default:return It=new im,e<0?It.a+="0E+":It.a+="0E",It.a+=-e,It.a}if(rt=R*10+1+7,pt=dt(el,Pf,22,rt+1,15,1),n=rt,R==1)if(l=r[0],l<0){Bn=ns(l,uo);do O=Bn,Bn=lP(Bn,10),pt[--n]=48+or(Zg(O,Xg(Bn,10)))&qr;while(Pc(Bn,0)!=0)}else{Bn=l;do O=Bn,Bn=Bn/10|0,pt[--n]=48+(O-Bn*10)&qr;while(Bn!=0)}else{ae=dt(Gn,pi,22,R,15,1),Me=R,Aa(r,0,ae,0,R);t:for(;;){for(Gt=0,g=Me-1;g>=0;g--)Te=so(Yd(Gt,32),ns(ae[g],uo)),W=Gpe(Te),ae[g]=or(W),Gt=or(M1(W,32));nt=or(Gt),$=n;do pt[--n]=48+nt%10&qr;while((nt=nt/10|0)!=0&&n!=0);for(i=9-$+n,f=0;f0;f++)pt[--n]=48;for(v=Me-1;ae[v]==0;v--)if(v==0)break t;Me=v+1}for(;pt[n]==48;)++n}if(k=Zt<0,c=rt-n-e-1,e==0)return k&&(pt[--n]=45),ml(pt,n,rt-n);if(e>0&&c>=-6){if(c>=0){for(b=n+c,M=rt-1;M>=b;M--)pt[M+1]=pt[M];return pt[++b]=46,k&&(pt[--n]=45),ml(pt,n,rt-n+1)}for(v=2;v<-c+1;v++)pt[--n]=48;return pt[--n]=46,pt[--n]=48,k&&(pt[--n]=45),ml(pt,n,rt-n)}return ce=n+1,_t=new Db,k&&(_t.a+="-"),rt-ce>=1?(E1(_t,pt[n]),_t.a+=".",_t.a+=ml(pt,n+1,rt-n-1)):_t.a+=ml(pt,n,rt-n),_t.a+="E",c>0&&(_t.a+="+"),_t.a+=""+c,_t.a}function n3e(t,e,n,i){var r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It,Gt,Zt,ce,ae,Te,Me,Bn,Pi,ls,iu,wa,e1,Nu,hg,k0,uf;if(pt=a(at((!t.b&&(t.b=new pn(Si,t,4,7)),t.b),0),97),It=pt.Yf(),Gt=pt.Zf(),_t=pt.Xf()/2,$=pt.Wf()/2,ct(pt,187)&&(rt=a(pt,121),It+=Tf(rt).i,It+=Tf(rt).i),It+=_t,Gt+=$,Me=a(at((!t.b&&(t.b=new pn(Si,t,4,7)),t.b),0),97),Pi=Me.Yf(),ls=Me.Zf(),Bn=Me.Xf()/2,Zt=Me.Wf()/2,ct(Me,187)&&(Te=a(Me,121),Pi+=Tf(Te).i,Pi+=Tf(Te).i),Pi+=Bn,ls+=Zt,(!t.a&&(t.a=new Wt(os,t,6,6)),t.a).i==0)f=(sm(),b=new I3,b),ni((!t.a&&(t.a=new Wt(os,t,6,6)),t.a),f);else if((!t.a&&(t.a=new Wt(os,t,6,6)),t.a).i>1)for(O=new WT((!t.a&&(t.a=new Wt(os,t,6,6)),t.a));O.e!=O.i._b();)HC(O);for(l=a(at((!t.a&&(t.a=new Wt(os,t,6,6)),t.a),0),270),W=Pi,Pi>It+_t?W=It+_t:PiGt+$?nt=Gt+$:lsIt-_t&&WGt-$&&ntPi+Bn?ce=Pi+Bn:Itls+Zt?ae=ls+Zt:GtPi-Bn&&cels-Zt&&aen&&(k=n-1),R=hg+pu(e,24)*GP*M-M/2,R<0?R=1:R>i&&(R=i-1),r=(sm(),g=new P3,g),LV(r,k),PV(r,R),ni((!l.a&&(l.a=new Ss(sf,l,5)),l.a),r)}function uOt(t,e){var n,i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt;for(i=new Nt,f=new Nt,W=e/2,R=t._b(),r=a(t.cd(0),9),nt=a(t.cd(1),9),O=xX(r.a,r.b,nt.a,nt.b,W),Ut(i,(mi(0,O.c.length),a(O.c[0],9))),Ut(f,(mi(1,O.c.length),a(O.c[1],9))),b=2;b=0;g--)Xi(n,(mi(g,l.c.length),a(l.c[g],9)));return n}function i3e(t){var e,n,i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It,Gt,Zt,ce,ae,Te,Me,Bn;if(Zt=a(z(t,(qt(),Qi)),83),Zt!=(Ls(),dp)&&Zt!=ib){for(O=t.b,R=O.c.length,v=new Vu((Ah(R+2,hZ),NL(so(so(5,R+2),(R+2)/10|0)))),$=new Vu((Ah(R+2,hZ),NL(so(so(5,R+2),(R+2)/10|0)))),Ut(v,new vi),Ut(v,new vi),Ut($,new Nt),Ut($,new Nt),Gt=new Nt,e=0;eMe?M:Me;for(i=new H(ae.f);i.aMe?ce:Me}Ct(_t,iF,Xt(M)),Ct(_t,rF,Xt(ce))}for(nt=0,R=new H(e.b);R.a=t.j){t.a=-1,t.c=1;return}if(e=bo(t.i,t.d++),t.a=e,t.b==1){switch(e){case 92:if(i=10,t.d>=t.j)throw K(new ri(ai((Kn(),CO))));t.a=bo(t.i,t.d++);break;case 45:(t.e&512)==512&&t.d=t.j||bo(t.i,t.d)!=63)break;if(++t.d>=t.j)throw K(new ri(ai((Kn(),QY))));switch(e=bo(t.i,t.d++),e){case 58:i=13;break;case 61:i=14;break;case 33:i=15;break;case 91:i=19;break;case 62:i=18;break;case 60:if(t.d>=t.j)throw K(new ri(ai((Kn(),QY))));if(e=bo(t.i,t.d++),e==61)i=16;else if(e==33)i=17;else throw K(new ri(ai((Kn(),HFt))));break;case 35:for(;t.d=t.j)throw K(new ri(ai((Kn(),CO))));t.a=bo(t.i,t.d++);break;default:i=0}t.c=i}function lOt(t){var e,n,i,r,c,l,f,g,b;for(t.b=1,Ci(t),e=null,t.c==0&&t.a==94?(Ci(t),e=(Ai(),Ai(),++Ar,new Eu(4)),jc(e,0,_E),f=(++Ar,new Eu(4))):f=(Ai(),Ai(),++Ar,new Eu(4)),r=!0;(b=t.c)!=1;){if(b==0&&t.a==93&&!r){e&&(c4(e,f),f=e);break}if(n=t.a,i=!1,b==10)switch(n){case 100:case 68:case 119:case 87:case 115:case 83:ow(f,tE(n)),i=!0;break;case 105:case 73:case 99:case 67:n=(ow(f,tE(n)),-1),i=!0;break;case 112:case 80:if(g=Tlt(t,n),!g)throw K(new ri(ai((Kn(),tK))));ow(f,g),i=!0;break;default:n=oht(t)}else if(b==24&&!r){if(e&&(c4(e,f),f=e),c=lOt(t),c4(f,c),t.c!=0||t.a!=93)throw K(new ri(ai((Kn(),JFt))));break}if(Ci(t),!i){if(b==0){if(n==91)throw K(new ri(ai((Kn(),jpt))));if(n==93)throw K(new ri(ai((Kn(),Hpt))));if(n==45&&!r&&t.a!=93)throw K(new ri(ai((Kn(),eK))))}if(t.c!=0||t.a!=45||n==45&&r)jc(f,n,n);else{if(Ci(t),(b=t.c)==1)throw K(new ri(ai((Kn(),AO))));if(b==0&&t.a==93)jc(f,n,n),jc(f,45,45);else{if(b==0&&t.a==93||b==24)throw K(new ri(ai((Kn(),eK))));if(l=t.a,b==0){if(l==91)throw K(new ri(ai((Kn(),jpt))));if(l==93)throw K(new ri(ai((Kn(),Hpt))));if(l==45)throw K(new ri(ai((Kn(),eK))))}else b==10&&(l=oht(t));if(Ci(t),n>l)throw K(new ri(ai((Kn(),eUt))));jc(f,n,l)}}}r=!1}if(t.c==1)throw K(new ri(ai((Kn(),AO))));return __(f),o4(f),t.b=0,Ci(t),f}function s3e(t,e,n){var i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It,Gt,Zt,ce,ae,Te,Me,Bn,Pi,ls,iu,wa;for(di(n,"Greedy cycle removal",1),rt=e.a,wa=rt.c.length,t.a=dt(Gn,pi,22,wa,15,1),t.c=dt(Gn,pi,22,wa,15,1),t.b=dt(Gn,pi,22,wa,15,1),g=0,W=new H(rt);W.a0?Te+1:1);for(c=new H(It.f);c.a0?Te+1:1)}t.c[g]==0?Xi(t.d,O):t.a[g]==0&&Xi(t.e,O),++g}for(R=-1,k=1,v=new Nt,Me=a(z(e,(Ft(),PE)),214);wa>0;){for(;t.d.b!=0;)Pi=a(u$(t.d),8),t.b[Pi.o]=R--,_ht(t,Pi),--wa;for(;t.e.b!=0;)ls=a(u$(t.e),8),t.b[ls.o]=k++,_ht(t,ls),--wa;if(wa>0){for(M=Vs,nt=new H(rt);nt.a=M&&(pt>M&&(v.c=dt(un,te,1,0,5,1),M=pt),v.c[v.c.length]=O));b=a(Ee(v,Uq(Me,v.c.length)),8),t.b[b.o]=k++,_ht(t,b),--wa}}for(Bn=rt.c.length+1,g=0;gt.b[iu]&&(q1(i,!0),Ct(e,NB,(me(),me(),!0)));t.a=null,t.c=null,t.b=null,ld(t.e),ld(t.d),Vn(n)}function o3e(t){Xn(t.c,ui,Y(Z(At,1),wt,2,6,[Ns,"http://www.w3.org/2001/XMLSchema#decimal"])),Xn(t.d,ui,Y(Z(At,1),wt,2,6,[Ns,"http://www.w3.org/2001/XMLSchema#integer"])),Xn(t.e,ui,Y(Z(At,1),wt,2,6,[Ns,"http://www.w3.org/2001/XMLSchema#boolean"])),Xn(t.f,ui,Y(Z(At,1),wt,2,6,[Ns,"EBoolean",Ti,"EBoolean:Object"])),Xn(t.i,ui,Y(Z(At,1),wt,2,6,[Ns,"http://www.w3.org/2001/XMLSchema#byte"])),Xn(t.g,ui,Y(Z(At,1),wt,2,6,[Ns,"http://www.w3.org/2001/XMLSchema#hexBinary"])),Xn(t.j,ui,Y(Z(At,1),wt,2,6,[Ns,"EByte",Ti,"EByte:Object"])),Xn(t.n,ui,Y(Z(At,1),wt,2,6,[Ns,"EChar",Ti,"EChar:Object"])),Xn(t.t,ui,Y(Z(At,1),wt,2,6,[Ns,"http://www.w3.org/2001/XMLSchema#double"])),Xn(t.u,ui,Y(Z(At,1),wt,2,6,[Ns,"EDouble",Ti,"EDouble:Object"])),Xn(t.F,ui,Y(Z(At,1),wt,2,6,[Ns,"http://www.w3.org/2001/XMLSchema#float"])),Xn(t.G,ui,Y(Z(At,1),wt,2,6,[Ns,"EFloat",Ti,"EFloat:Object"])),Xn(t.I,ui,Y(Z(At,1),wt,2,6,[Ns,"http://www.w3.org/2001/XMLSchema#int"])),Xn(t.J,ui,Y(Z(At,1),wt,2,6,[Ns,"EInt",Ti,"EInt:Object"])),Xn(t.N,ui,Y(Z(At,1),wt,2,6,[Ns,"http://www.w3.org/2001/XMLSchema#long"])),Xn(t.O,ui,Y(Z(At,1),wt,2,6,[Ns,"ELong",Ti,"ELong:Object"])),Xn(t.Z,ui,Y(Z(At,1),wt,2,6,[Ns,"http://www.w3.org/2001/XMLSchema#short"])),Xn(t.$,ui,Y(Z(At,1),wt,2,6,[Ns,"EShort",Ti,"EShort:Object"])),Xn(t._,ui,Y(Z(At,1),wt,2,6,[Ns,"http://www.w3.org/2001/XMLSchema#string"]))}function qht(t,e,n,i){var r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It,Gt,Zt,ce,ae,Te,Me,Bn,Pi;if(mNt(e),g=a(at((!e.b&&(e.b=new pn(Si,e,4,7)),e.b),0),97),v=a(at((!e.c&&(e.c=new pn(Si,e,5,8)),e.c),0),97),f=zc(g),b=zc(v),l=(!e.a&&(e.a=new Wt(os,e,6,6)),e.a).i==0?null:a(at((!e.a&&(e.a=new Wt(os,e,6,6)),e.a),0),270),Zt=a(zi(t.a,f),8),Me=a(zi(t.a,b),8),ce=null,Bn=null,ct(g,187)&&(Gt=a(zi(t.a,g),279),ct(Gt,11)?ce=a(Gt,11):ct(Gt,8)&&(Zt=a(Gt,8),ce=a(Ee(Zt.i,0),11))),ct(v,187)&&(Te=a(zi(t.a,v),279),ct(Te,11)?Bn=a(Te,11):ct(Te,8)&&(Me=a(Te,8),Bn=a(Ee(Me.i,0),11))),!Zt||!Me)return null;for($=new Np,Uo($,e),Ct($,(Ft(),li),e),Ct($,(qt(),Ro),null),R=a(z(i,Qc),19),Zt==Me&&R.nc((So(),S6)),ce||(It=(Fo(),ba),ae=null,l&&Gd(a(z(Zt,Qi),83))&&(ae=new We(l.j,l.k),dkt(ae,QD(e)),Nkt(ae,n),gC(b,f)&&(It=Ga,sr(ae,Zt.k))),ce=n7t(Zt,ae,It,i)),Bn||(It=(Fo(),Ga),Pi=null,l&&Gd(a(z(Me,Qi),83))&&(Pi=new We(l.b,l.c),dkt(Pi,QD(e)),Nkt(Pi,n)),Bn=n7t(Me,Pi,It,Mc(Me))),Hs($,ce),Ts($,Bn),k=new $n((!e.n&&(e.n=new Wt(ic,e,1,7)),e.n));k.e!=k.i._b();)if(M=a(ci(k),137),!lt(de(cn(M,w0)))&&M.a)switch(W=pq(M),Ut($.b,W),a(z(W,eg),226).g){case 2:case 3:R.nc((So(),kE));break;case 1:case 0:R.nc((So(),AE)),Ct(W,eg,(ip(),dA))}if(c=a(z(i,IE),317),nt=a(z(i,qB),292),r=c==(C2(),x6)||nt==(UC(),KJ),l&&(!l.a&&(l.a=new Ss(sf,l,5)),l.a).i!=0&&r){for(rt=pP(l),O=new Va,_t=qn(rt,0);_t.b!=_t.d.c;)pt=a(Yn(_t),9),Xi(O,new Oo(pt));Ct($,omt,O)}return $}function Xht(t,e,n,i,r,c){var l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It,Gt,Zt,ce,ae,Te,Me,Bn,Pi;for(f=a(Ee(t.d.c.b,i),26),Me=new $r,R=new $r,k=0;kn&&(ce=R.a.Zb(nt,R),ce==null);for(Bn=new $r,O=new $r,pt=Me.a.Xb().tc();pt.hc();)for(nt=a(pt.ic(),8),l=e==1?br(nt):Rs(nt),b=(Ao(),new $d(id(Zd(l.a,new X))));Jn(b);)g=a(In(b),14),ql(nt.c)!=ql(g.d.g.c)&&Ir(Bn,g.d.g);for(_t=R.a.Xb().tc();_t.hc();)for(nt=a(_t.ic(),8),l=e==1?br(nt):Rs(nt),b=(Ao(),new $d(id(Zd(l.a,new X))));Jn(b);)g=a(In(b),14),ql(nt.c)!=ql(g.d.g.c)&&Ir(O,g.d.g);for(qjt&&rd(),Zt=a(Ee(t.d.c.b,i+(e==1?1:-1)),26),$=Vs,W=qi,M=0;MM?$:M:O.a.Qb(nt)&&(W=WM&&(Me=0,Bn+=v+Zt,v=0),Abe(It,l,Me,Bn),e=y.Math.max(e,Me+Gt.a),v=y.Math.max(v,Gt.b),Me+=Gt.a+Zt;for(_t=new vi,n=new vi,ae=new H(t);ae.a=2){for(k=!0,rt=(mi(1,M.c.length),a(M.c[1],26)),$=new H(l.a);$.a<$.c.c.length;){if(R=a(G($),8),zt(z(R,(qt(),la)))===zt((bl(),_x))){k=!1;break}for(r=Rn(br(R));Jn(r);)if(i=a(In(r),14),i.d.g.c==rt){k=!1;break}if(!k)break}if(k){for(nt=a(xo(l.a,dt(Cl,Ih,8,l.a.c.length,0,1)),123),O=0,W=nt.length;O=2){for(k=!0,pt=a(Ee(M,M.c.length-2),26),$=new H(g.a);$.a<$.c.c.length;){if(R=a(G($),8),zt(z(R,(qt(),la)))===zt((bl(),_x))){k=!1;break}for(r=Rn(Rs(R));Jn(r);)if(i=a(In(r),14),i.c.g.c==pt){k=!1;break}if(!k)break}if(k){for(nt=a(xo(g.a,dt(Cl,Ih,8,g.a.c.length,0,1)),123),O=0,W=nt.length;OMX(c))&&(M=c);for(!M&&(M=(mi(0,W.c.length),a(W.c[0],164))),$=new H(e.b);$.a<$.c.c.length;)for(O=a(G($),26),_t=new H(O.a);_t.a<_t.c.c.length;)pt=a(G(_t),8),pt.k.b=lt(M.p[pt.o])+lt(M.d[pt.o]);for(t.a&&(rd(),""+W9t(M),""+qge(M)),l=new H(W);l.a0?(O=(It+1)*t.d,O=0&&(bh+=(It+2)*t.d)}pt=Te,f=g}while(Te);for(r=new H(t.j);r.a=-1900?1:0,n>=4?Ii(t,Y(Z(At,1),wt,2,6,[COt,AOt])[f]):Ii(t,Y(Z(At,1),wt,2,6,["BC","AD"])[f]);break;case 121:ede(t,n,i);break;case 77:vve(t,n,i);break;case 107:g=r.q.getHours(),g==0?dd(t,24,n):dd(t,g,n);break;case 83:abe(t,n,r);break;case 69:v=i.q.getDay(),n==5?Ii(t,Y(Z(At,1),wt,2,6,["S","M","T","W","T","F","S"])[v]):n==4?Ii(t,Y(Z(At,1),wt,2,6,[TZ,CZ,AZ,kZ,LZ,PZ,IZ])[v]):Ii(t,Y(Z(At,1),wt,2,6,["Sun","Mon","Tue","Wed","Thu","Fri","Sat"])[v]);break;case 97:r.q.getHours()>=12&&r.q.getHours()<24?Ii(t,Y(Z(At,1),wt,2,6,["AM","PM"])[1]):Ii(t,Y(Z(At,1),wt,2,6,["AM","PM"])[0]);break;case 104:M=r.q.getHours()%12,M==0?dd(t,12,n):dd(t,M,n);break;case 75:k=r.q.getHours()%12,dd(t,k,n);break;case 72:R=r.q.getHours(),dd(t,R,n);break;case 99:O=i.q.getDay(),n==5?Ii(t,Y(Z(At,1),wt,2,6,["S","M","T","W","T","F","S"])[O]):n==4?Ii(t,Y(Z(At,1),wt,2,6,[TZ,CZ,AZ,kZ,LZ,PZ,IZ])[O]):n==3?Ii(t,Y(Z(At,1),wt,2,6,["Sun","Mon","Tue","Wed","Thu","Fri","Sat"])[O]):dd(t,O,1);break;case 76:$=i.q.getMonth(),n==5?Ii(t,Y(Z(At,1),wt,2,6,["J","F","M","A","M","J","J","A","S","O","N","D"])[$]):n==4?Ii(t,Y(Z(At,1),wt,2,6,[gZ,mZ,bZ,wZ,K2,vZ,_Z,yZ,xZ,MZ,EZ,SZ])[$]):n==3?Ii(t,Y(Z(At,1),wt,2,6,["Jan","Feb","Mar","Apr",K2,"Jun","Jul","Aug","Sep","Oct","Nov","Dec"])[$]):dd(t,$+1,n);break;case 81:W=i.q.getMonth()/3|0,n<4?Ii(t,Y(Z(At,1),wt,2,6,["Q1","Q2","Q3","Q4"])[W]):Ii(t,Y(Z(At,1),wt,2,6,["1st quarter","2nd quarter","3rd quarter","4th quarter"])[W]);break;case 100:nt=i.q.getDate(),dd(t,nt,n);break;case 109:b=r.q.getMinutes(),dd(t,b,n);break;case 115:l=r.q.getSeconds(),dd(t,l,n);break;case 122:n<4?Ii(t,c.c[0]):Ii(t,c.c[1]);break;case 118:Ii(t,c.b);break;case 90:n<3?Ii(t,x0e(c)):n==3?Ii(t,T0e(c)):Ii(t,C0e(c.a));break;default:return!1}return!0}function Yht(){Yht=P;var t;dmt=(t=a(yu(dJ),10),new ja(t,a(cu(t,t.length),10),0)),EHt=new bn(Hft,dmt),UHt=new bn(Gft,(me(),me(),!1)),_mt=(aN(),CJ),GHt=new bn(hO,_mt),iGt=new bn(Wft,!1),rGt=new bn($ft,!0),Xt(1),EGt=new bn(Vft,Xt(7)),SGt=new bn(qft,!1),bGt=new bn(Xft,!1),mmt=(IN(),gJ),LHt=new bn(oY,mmt),Mmt=(v7(),XJ),eGt=new bn(QP,Mmt),ymt=(bl(),_x),XHt=new bn(Zft,ymt),Emt=(D2(),G6),nGt=new bn(Yft,Emt),Xt(-1),ZHt=new bn(cY,Xt(4)),Xt(-1),KHt=new bn(aY,Xt(2)),xmt=(x_(),JB),tGt=new bn(uY,xmt),Xt(0),QHt=new bn(lY,Xt(0)),VHt=new bn(hY,Xt(qi)),gmt=(C2(),M6),kHt=new bn(fY,gmt),CHt=new bn(Kft,.1),AHt=new bn(Jft,!1),Xt(0),SHt=new bn(Qft,Xt(40)),pmt=(RM(),TJ),THt=new bn(tdt,pmt),Amt=(UC(),B6),mGt=new bn(fE,Amt),uGt=new kr(dY),Smt=(LL(),sF),sGt=new bn(pY,Smt),Tmt=(dP(),AB),cGt=new bn(gY,Tmt),new G3,hGt=new bn(mY,.3),dGt=new kr(bY),Cmt=(Qb(),KB),pGt=new bn(edt,Cmt),vmt=(t7(),QJ),RHt=new bn(wY,vmt),BHt=new bn(fO,!0),NHt=new bn(dO,.4),xGt=new bn(ndt,10),yGt=new bn(idt,10),MGt=new bn(rdt,20),Xt(0),wGt=new bn(sdt,Xt(0)),Xt(0),vGt=new bn(odt,Xt(0)),Xt(0),_Gt=new bn(cdt,Xt(0)),yHt=new bn(vY,!1),fmt=(ZM(),j4),MHt=new bn(adt,fmt),hmt=(pN(),fJ),xHt=new bn(udt,hmt),jHt=new bn(pO,!1),Xt(0),zHt=new bn(_Y,Xt(16)),Xt(0),HHt=new bn(yY,Xt(5)),Imt=(UN(),eQ),jGt=new bn(b4,Imt),TGt=new bn(ldt,10),CGt=new bn(hdt,1),Lmt=(CN(),TB),IGt=new bn(gO,Lmt),AGt=new kr(xY),kmt=Xt(1),Xt(0),LGt=new bn(MY,kmt),Pmt=(LN(),tQ),UGt=new bn(EY,Pmt),NGt=new bn(mO,!0),RGt=new bn(bO,2),BGt=new bn(SY,!0),wmt=(x7(),CB),IHt=new bn(fdt,wmt),bmt=(GC(),lJ),PHt=new bn(ddt,bmt),$Ht=mJ,WHt=x6,YHt=YB,JHt=YB,qHt=qJ,lGt=F6,oGt=B6,aGt=B6,fGt=JJ,gGt=F6,DHt=(gd(),eb),FHt=eb,OHt=eb,kGt=pJ,PGt=TB,zGt=nQ,OGt=W6,DGt=W6,FGt=W6}function dr(){dr=P;var t,e;Lwt=new kr(JBt),Pwt=(md(),EQ),oVt=new bn(Pdt,Pwt),new G3,BE=new bn(cE,null),cVt=new kr(bpt),CQ=new bn(CY,(me(),me(),!1)),Rwt=(Js(),Ff),lA=new bn(kY,Rwt),Owt=(gd(),zQ),Nwt=new bn(t6,Owt),hVt=new bn(gpt,!1),Uwt=(Yg(),AF),ry=new bn(Idt,Uwt),qwt=new b2(12),sy=new bn(ex,qwt),kQ=new bn(aO,!1),Jwt=(Ls(),ib),tI=new bn(nY,Jwt),Cx=new kr(_O),SF=new kr(qP),OQ=new kr(cO),BQ=new kr(XP),zwt=new Va,Tx=new bn(Gdt,zwt),uVt=new bn(qdt,!1),fVt=new bn(Xdt,!1),new kr(QBt),jwt=new i2,xF=new bn(Jdt,jwt),LQ=new bn(kdt,!1),new G3,bVt=new bn(tFt,1),new bn(eFt,!0),Xt(0),new bn(nFt,Xt(100)),new bn(iFt,!1),Xt(0),new bn(rFt,Xt(4e3)),Xt(0),new bn(sFt,Xt(400)),new bn(oFt,!1),new bn(cFt,!0),new bn(aFt,!1),Iwt=(i7(),VQ),aVt=new bn(mpt,Iwt),evt=new bn(YZ,12),wVt=new bn(ydt,10),nvt=new bn(eY,2),vVt=new bn(xdt,10),ivt=new bn(Mdt,0),TF=new bn(Sdt,5),rvt=new bn(Edt,1),oy=new bn(uE,20),cvt=new bn(Tdt,10),FQ=new kr(Cdt),ovt=new BEt,svt=new bn(Qdt,ovt),gVt=new kr(Kdt),Xwt=!1,pVt=new bn(Ydt,Xwt),Hwt=new b2(5),dVt=new bn(uFt,Hwt),Gwt=(i0(),e=a(yu(to),10),new ja(e,a(cu(e,e.length),10),0)),MF=new bn(Ndt,Gwt),Ywt=(H1(),nb),Zwt=new bn(Fdt,Ywt),IQ=new kr(Udt),RQ=new kr(zdt),DQ=new kr(jdt),PQ=new kr(Hdt),Wwt=(t=a(yu(vA),10),new ja(t,a(cu(t,t.length),10),0)),FE=new bn(wO,Wwt),Vwt=qe((ma(),zE)),EF=new bn(AY,Vwt),$wt=new We(0,0),Q6=new bn(vO,$wt),Dwt=(ip(),CF),J6=new bn(Wdt,Dwt),lVt=new bn($dt,!1),new kr(lFt),Xt(1),new bn(hFt,null),Kwt=new kr(Zdt),mVt=new kr(Vdt),tvt=(Ht(),Wc),hA=new bn(Ldt,tvt),nu=new kr(Adt),Qwt=(Kh(),cy),NQ=new bn(Odt,Qwt),eI=new bn(Bdt,!1),yF=new bn(Rdt,!1),AQ=new bn(Ddt,!1),Bwt=new bn(KZ,1),Fwt=(_7(),HQ),new bn(fFt,Fwt)}function f3e(t){t.gb||(t.gb=!0,t.b=cc(t,0),Cr(t.b,18),nr(t.b,19),t.a=cc(t,1),Cr(t.a,1),nr(t.a,2),nr(t.a,3),nr(t.a,4),nr(t.a,5),t.o=cc(t,2),Cr(t.o,8),Cr(t.o,9),nr(t.o,10),nr(t.o,11),nr(t.o,12),nr(t.o,13),nr(t.o,14),nr(t.o,15),nr(t.o,16),nr(t.o,17),nr(t.o,18),nr(t.o,19),nr(t.o,20),nr(t.o,21),nr(t.o,22),nr(t.o,23),ko(t.o),ko(t.o),ko(t.o),ko(t.o),ko(t.o),ko(t.o),ko(t.o),ko(t.o),ko(t.o),ko(t.o),t.p=cc(t,3),Cr(t.p,2),Cr(t.p,3),Cr(t.p,4),Cr(t.p,5),nr(t.p,6),nr(t.p,7),ko(t.p),ko(t.p),t.q=cc(t,4),Cr(t.q,8),t.v=cc(t,5),nr(t.v,9),ko(t.v),ko(t.v),ko(t.v),t.w=cc(t,6),Cr(t.w,2),Cr(t.w,3),Cr(t.w,4),nr(t.w,5),t.B=cc(t,7),nr(t.B,1),ko(t.B),ko(t.B),ko(t.B),t.Q=cc(t,8),nr(t.Q,0),ko(t.Q),t.R=cc(t,9),Cr(t.R,1),t.S=cc(t,10),ko(t.S),ko(t.S),ko(t.S),ko(t.S),ko(t.S),ko(t.S),ko(t.S),ko(t.S),ko(t.S),ko(t.S),ko(t.S),ko(t.S),ko(t.S),ko(t.S),ko(t.S),t.T=cc(t,11),nr(t.T,10),nr(t.T,11),nr(t.T,12),nr(t.T,13),nr(t.T,14),ko(t.T),ko(t.T),t.U=cc(t,12),Cr(t.U,2),Cr(t.U,3),nr(t.U,4),nr(t.U,5),nr(t.U,6),nr(t.U,7),ko(t.U),t.V=cc(t,13),nr(t.V,10),t.W=cc(t,14),Cr(t.W,18),Cr(t.W,19),Cr(t.W,20),nr(t.W,21),nr(t.W,22),nr(t.W,23),t.bb=cc(t,15),Cr(t.bb,10),Cr(t.bb,11),Cr(t.bb,12),Cr(t.bb,13),Cr(t.bb,14),Cr(t.bb,15),Cr(t.bb,16),nr(t.bb,17),ko(t.bb),ko(t.bb),t.eb=cc(t,16),Cr(t.eb,2),Cr(t.eb,3),Cr(t.eb,4),Cr(t.eb,5),Cr(t.eb,6),Cr(t.eb,7),nr(t.eb,8),nr(t.eb,9),t.ab=cc(t,17),Cr(t.ab,0),Cr(t.ab,1),t.H=cc(t,18),nr(t.H,0),nr(t.H,1),nr(t.H,2),nr(t.H,3),nr(t.H,4),nr(t.H,5),ko(t.H),t.db=cc(t,19),nr(t.db,2),t.c=yi(t,20),t.d=yi(t,21),t.e=yi(t,22),t.f=yi(t,23),t.i=yi(t,24),t.g=yi(t,25),t.j=yi(t,26),t.k=yi(t,27),t.n=yi(t,28),t.r=yi(t,29),t.s=yi(t,30),t.t=yi(t,31),t.u=yi(t,32),t.fb=yi(t,33),t.A=yi(t,34),t.C=yi(t,35),t.D=yi(t,36),t.F=yi(t,37),t.G=yi(t,38),t.I=yi(t,39),t.J=yi(t,40),t.L=yi(t,41),t.M=yi(t,42),t.N=yi(t,43),t.O=yi(t,44),t.P=yi(t,45),t.X=yi(t,46),t.Y=yi(t,47),t.Z=yi(t,48),t.$=yi(t,49),t._=yi(t,50),t.cb=yi(t,51),t.K=yi(t,52))}function Ft(){Ft=P;var t,e;li=new kr(Lft),imt=new kr("coordinateOrigin"),RJ=new kr("processors"),nmt=new es("compoundNode",(me(),me(),!1)),A6=new es("insideConnections",!1),xd=new kr("nestedLGraph"),Q1=new kr("parentLNode"),omt=new kr("originalBendpoints"),cmt=new kr("originalDummyNodePosition"),amt=new kr("originalLabelEdge"),UB=new kr("representedLabels"),OB=new kr("endLabels"),bx=new es("labelSide",(Tu(),uI)),K_=new es("maxEdgeThickness",0),tg=new es("reversed",!1),PE=new kr(Pft),Pu=new es("longEdgeSource",null),Iu=new es("longEdgeTarget",null),wx=new es("longEdgeHasLabelDummies",!1),k6=new es("longEdgeBeforeLabelDummy",!1),kJ=new es("edgeConstraint",(o_(),bJ)),LE=new kr("inLayerLayoutUnit"),b0=new es("inLayerConstraint",(tp(),T6)),mx=new es("inLayerSuccessorConstraint",new Nt),Ru=new kr("portDummy"),DB=new es("crossingHint",Xt(0)),Qc=new es("graphProperties",(e=a(yu(EJ),10),new ja(e,a(cu(e,e.length),10),0))),wc=new es("externalPortSide",(Ht(),Wc)),smt=new es("externalPortSize",new go),LJ=new kr("externalPortReplacedDummies"),BB=new kr("externalPortReplacedDummy"),gx=new es("externalPortConnections",(t=a(yu(Ia),10),new ja(t,a(cu(t,t.length),10),0))),qm=new es(EBt,0),tmt=new kr("barycenterAssociates"),vx=new kr("TopSideComments"),px=new kr("BottomSideComments"),RB=new kr("CommentConnectionPort"),PJ=new es("inputCollect",!1),IJ=new es("outputCollect",!1),NB=new es("cyclic",!1),C6=new es("bigNodeOriginalSize",new Lb(0)),bw=new es("bigNodeInitial",!1),emt=new es("org.eclipse.elk.alg.layered.bigNodeLabels",new Nt),AJ=new es("org.eclipse.elk.alg.layered.postProcess",null),rmt=new kr("crossHierarchyMap"),OJ=new kr("targetOffset"),vHt=new es("splineLabelSize",new go),L6=new es("splineLoopSide",(mu(),Sx)),NJ=new es("splineSelfLoopComponents",new Nt),umt=new es("splineSelfLoopMargins",new i2),ww=new kr("spacings"),FB=new es("partitionConstraint",!1),Vm=new kr("breakingPoint.info"),G4=new kr("splines.route.start"),DJ=new kr("splines.edgeChain")}function Po(){Po=P,h0t=new Ur("LEFT_DIR_PREPROCESSOR",0),Kgt=new Ur("DOWN_DIR_PREPROCESSOR",1),S0t=new Ur("UP_DIR_PREPROCESSOR",2),Zgt=new Ur("COMMENT_PREPROCESSOR",3),F4=new Ur("EDGE_AND_LAYER_CONSTRAINT_EDGE_REVERSER",4),y0t=new Ur("SPLINE_SELF_LOOP_PREPROCESSOR",5),nJ=new Ur("INTERACTIVE_EXTERNAL_PORT_POSITIONER",6),m0t=new Ur("PARTITION_PREPROCESSOR",7),tJ=new Ur("BIG_NODES_PREPROCESSOR",8),mB=new Ur("LABEL_DUMMY_INSERTER",9),r0t=new Ur("HIGH_DEGREE_NODE_LAYER_PROCESSOR",10),g0t=new Ur("PARTITION_POSTPROCESSOR",11),d0t=new Ur("NODE_PROMOTION",12),CE=new Ur("LAYER_CONSTRAINT_PROCESSOR",13),e0t=new Ur("HIERARCHICAL_PORT_CONSTRAINT_PROCESSOR",14),QK=new Ur("BIG_NODES_INTERMEDIATEPROCESSOR",15),w0t=new Ur("SEMI_INTERACTIVE_CROSSMIN_PROCESSOR",16),Wgt=new Ur("BREAKING_POINT_INSERTER",17),sJ=new Ur("LONG_EDGE_SPLITTER",18),cJ=new Ur("PORT_SIDE_PROCESSOR",19),gB=new Ur("INVERTED_PORT_PROCESSOR",20),b0t=new Ur("SELF_LOOP_PROCESSOR",21),oJ=new Ur("PORT_LIST_SORTER",22),_B=new Ur("NORTH_SOUTH_PORT_PREPROCESSOR",23),$gt=new Ur("BREAKING_POINT_PROCESSOR",24),p0t=new Ur(wBt,25),M0t=new Ur(vBt,26),_0t=new Ur("SPLINE_SELF_LOOP_POSITIONER",27),v0t=new Ur("SINGLE_EDGE_GRAPH_WRAPPER",28),iJ=new Ur("IN_LAYER_CONSTRAINT_PROCESSOR",29),eJ=new Ur("BIG_NODES_SPLITTER",30),Jgt=new Ur("END_NODE_PORT_LABEL_MANAGEMENT_PROCESSOR",31),a0t=new Ur("LABEL_AND_NODE_SIZE_PROCESSOR",32),x0t=new Ur("SPLINE_SELF_LOOP_ROUTER",33),f0t=new Ur("NODE_MARGIN_CALCULATOR",34),pB=new Ur("END_LABEL_PREPROCESSOR",35),wB=new Ur("LABEL_DUMMY_SWITCHER",36),qgt=new Ur("CENTER_LABEL_MANAGEMENT_PROCESSOR",37),TE=new Ur("LABEL_SIDE_SELECTOR",38),o0t=new Ur("HYPEREDGE_DUMMY_MERGER",39),n0t=new Ur("HIERARCHICAL_PORT_DUMMY_SIZE_PROCESSOR",40),u0t=new Ur("LAYER_SIZE_AND_GRAPH_HEIGHT_CALCULATOR",41),U4=new Ur("HIERARCHICAL_PORT_POSITION_PROCESSOR",42),y6=new Ur("BIG_NODES_POSTPROCESSOR",43),Xgt=new Ur("COMMENT_POSTPROCESSOR",44),c0t=new Ur("HYPERNODE_PROCESSOR",45),i0t=new Ur("HIERARCHICAL_PORT_ORTHOGONAL_EDGE_ROUTER",46),rJ=new Ur("LONG_EDGE_JOINER",47),Vgt=new Ur("BREAKING_POINT_REMOVER",48),vB=new Ur("NORTH_SOUTH_PORT_POSTPROCESSOR",49),s0t=new Ur("HORIZONTAL_COMPACTOR",50),bB=new Ur("LABEL_DUMMY_REMOVER",51),Qgt=new Ur("FINAL_SPLINE_BENDPOINTS_CALCULATOR",52),yB=new Ur("REVERSED_EDGE_RESTORER",53),dB=new Ur("END_LABEL_POSTPROCESSOR",54),t0t=new Ur("HIERARCHICAL_NODE_RESIZER",55),l0t=new Ur("LEFT_DIR_POSTPROCESSOR",56),Ygt=new Ur("DOWN_DIR_POSTPROCESSOR",57),E0t=new Ur("UP_DIR_POSTPROCESSOR",58)}function d3e(t,e,n){var i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It,Gt,Zt,ce,ae,Te,Me,Bn,Pi,ls,iu,wa,e1,Nu,hg,k0,uf,mh,bh,XE,EI,SI,Ux,ftt,LA,LXt,S_t,fb,PA,dtt,zx,IA,jw,RA,ptt,PXt;for(S_t=0,Bn=0,iu=e.length;Bn0&&(t.a[mh.o]=S_t++)}for(IA=0,Pi=0,wa=n.length;Pi0;){for(mh=(Hn(SI.b>0),a(SI.a.cd(SI.c=--SI.b),11)),EI=0,f=new H(mh.d);f.a0&&(mh.i==(Ht(),Tn)?(t.a[mh.o]=IA,++IA):(t.a[mh.o]=IA+e1+hg,++hg))}IA+=hg}for(XE=(ts(),new vi),R=new qa,Me=0,ls=e.length;Meb.b&&(b.b=Ux)):mh.g.c==LXt&&(Uxb.c&&(b.c=Ux));for(IL(O,0,O.length,null),zx=dt(Gn,pi,22,O.length,15,1),i=dt(Gn,pi,22,IA+1,15,1),W=0;W0;)Gt%2>0&&(r+=ptt[Gt+1]),Gt=(Gt-1)/2|0,++ptt[Gt];for(ce=dt(xWt,te,336,O.length*2,0,1),pt=0;pt'?":le(HFt,t)?"'(?<' or '(? toIndex: ",pft=", toIndex: ",UOt="org.eclipse.elk.alg.common.compaction",zOt="Scanline/EventHandler",vd="org.eclipse.elk.alg.common.compaction.oned",jOt="CNode belongs to another CGroup.",HOt="ISpacingsHandler/1",jZ="The ",HZ=" instance has been finished already.",GOt="The direction ",WOt=" is not supported by the CGraph instance.",$Ot="OneDimensionalCompactor",VOt="OneDimensionalCompactor/lambda$0$Type",qOt="Quadruplet",XOt="ScanlineConstraintCalculator",ZOt="ScanlineConstraintCalculator/ConstraintsScanlineHandler",YOt="ScanlineConstraintCalculator/ConstraintsScanlineHandler/lambda$0$Type",KOt="ScanlineConstraintCalculator/Timestamp",JOt="ScanlineConstraintCalculator/lambda$0$Type",sh={138:1,56:1},GZ="org.eclipse.elk.alg.common.compaction.options",sa="org.eclipse.elk.core.data",gft="org.eclipse.elk.polyomino.traversalStrategy",mft="org.eclipse.elk.polyomino.lowLevelSort",bft="org.eclipse.elk.polyomino.highLevelSort",wft="org.eclipse.elk.polyomino.fill",_d={154:1},WZ="polyomino",If="org.eclipse.elk.alg.common.compaction.polyomino",iO="org.eclipse.elk.alg.common.compaction.polyomino.structures",vft="Direction",$Z="Grid is only of size ",VZ=". Requested point (",qZ=") is out of bounds.",rO=" Given center based coordinates were (",$P="org.eclipse.elk.graph.properties",QOt="IPropertyHolder",XZ={3:1,93:1,131:1},I_={244:1},l4="org.eclipse.elk.core",tBt="Connected Components Compaction",eBt="org.eclipse.elk.alg.disco",sO="org.eclipse.elk.alg.disco.graph",ZZ="org.eclipse.elk.alg.disco.options",nBt="CompactionStrategy",_ft="org.eclipse.elk.disco.componentCompaction.strategy",yft="org.eclipse.elk.disco.componentCompaction.componentLayoutAlgorithm",xft="org.eclipse.elk.disco.debug.discoGraph",Mft="org.eclipse.elk.disco.debug.discoPolys",iBt="componentCompaction",o0="org.eclipse.elk.disco",YZ="org.eclipse.elk.spacing.componentComponent",KZ="org.eclipse.elk.edge.thickness",cE="org.eclipse.elk.aspectRatio",ex="org.eclipse.elk.padding",R_="org.eclipse.elk.alg.disco.transform",JZ=1.5707963267948966,uw={3:1,4:1,5:1,175:1},c0={221:1,3:1,4:1},Eft={3:1,6:1,4:1,5:1,63:1,73:1},Sft="org.eclipse.elk.alg.force",Tft="ComponentsProcessor",rBt="ComponentsProcessor/1",VP="org.eclipse.elk.alg.force.graph",sBt="Component Layout",Cft="org.eclipse.elk.alg.force.model",yd=.01,oO="org.eclipse.elk.force.model",Aft="org.eclipse.elk.force.iterations",kft="org.eclipse.elk.force.repulsivePower",QZ="org.eclipse.elk.force.temperature",op=.001,tY="org.eclipse.elk.force.repulsion",h4="org.eclipse.elk.alg.force.options",aE=1.600000023841858,Rf="org.eclipse.elk.force",qP="org.eclipse.elk.priority",uE="org.eclipse.elk.spacing.nodeNode",eY="org.eclipse.elk.spacing.edgeLabel",cO="org.eclipse.elk.randomSeed",XP="org.eclipse.elk.separateConnectedComponents",aO="org.eclipse.elk.interactive",nY="org.eclipse.elk.portConstraints",Lft="origin",Pft="random",oBt="boundingBox.upLeft",cBt="boundingBox.lowRight",Ift="org.eclipse.elk.stress.fixed",Rft="org.eclipse.elk.stress.desiredEdgeLength",Dft="org.eclipse.elk.stress.dimension",Nft="org.eclipse.elk.stress.epsilon",Oft="org.eclipse.elk.stress.iterationLimit",f4="org.eclipse.elk.stress",aBt="ELK Stress",iY="org.eclipse.elk.alg.force.stress",uBt="Layered layout",ZP="org.eclipse.elk.alg.layered",YP="org.eclipse.elk.alg.layered.compaction.components",d4="org.eclipse.elk.alg.layered.compaction.oned",uO="org.eclipse.elk.alg.layered.compaction.oned.algs",a0="org.eclipse.elk.alg.layered.compaction.recthull",Y1="org.eclipse.elk.alg.layered.components",lBt={3:1,6:1,4:1,5:1,85:1,63:1,73:1},lO="org.eclipse.elk.alg.layered.compound",_l={3:1,6:1,4:1,5:1,99:1,85:1,63:1,73:1},Br={50:1},oa="org.eclipse.elk.alg.layered.graph",Ih={3:1,6:1,4:1,5:1,85:1,123:1,148:1,63:1,73:1},hBt="Not supported by LGraph",fBt=`([{"' \r -`,dBt=`)]}"' \r -`,pBt="The given string contains parts that cannot be parsed as numbers.",KP="org.eclipse.elk.core.math",gBt={3:1,4:1,135:1,211:1,428:1},mBt={3:1,4:1,119:1,211:1,428:1},u0="org.eclipse.elk.alg.layered.graph.transform",Dn="org.eclipse.elk.alg.layered.intermediate",bBt="Big nodes pre-processing",Bft={3:1,6:1,4:1,5:1,85:1,619:1,148:1,63:1,73:1},Fft={3:1,4:1,5:1,537:1},wBt="ONE_SIDED_GREEDY_SWITCH",vBt="TWO_SIDED_GREEDY_SWITCH",rY="No implementation is available for the layout processor ",Uft="IntermediateProcessorStrategy",zft="Node '",_Bt="NodeMarginCalculator",yBt="Odd port side processing",lw=1e-8,Kr="org.eclipse.elk.alg.layered.intermediate.compaction",p4="org.eclipse.elk.alg.layered.intermediate.greedyswitch",l0="org.eclipse.elk.alg.layered.p3order.counting",JP={208:1},cp="org.eclipse.elk.alg.layered.intermediate.wrapping",g4="org.eclipse.elk.alg.layered.networksimplex",ka="org.eclipse.elk.alg.layered.options",sY="INTERACTIVE",Fm="NONE",lE="LEFT",hE="RIGHT",xBt="EDGE_LENGTH",MBt="SELF_LOOPS",jft="BOTTOM",m4="CENTER",EBt="portRatioOrPosition",Hft="org.eclipse.elk.layered.contentAlignment",Gft="org.eclipse.elk.layered.feedbackEdges",hO="org.eclipse.elk.layered.interactiveReferencePoint",Wft="org.eclipse.elk.layered.mergeEdges",$ft="org.eclipse.elk.layered.mergeHierarchyEdges",Vft="org.eclipse.elk.layered.thoroughness",qft="org.eclipse.elk.layered.unnecessaryBendpoints",Xft="org.eclipse.elk.layered.northOrSouthPort",oY="org.eclipse.elk.layered.cycleBreaking.strategy",QP="org.eclipse.elk.layered.layering.strategy",Zft="org.eclipse.elk.layered.layering.layerConstraint",Yft="org.eclipse.elk.layered.layering.wideNodesOnMultipleLayers",cY="org.eclipse.elk.layered.layering.minWidth.upperBoundOnWidth",aY="org.eclipse.elk.layered.layering.minWidth.upperLayerEstimationScalingFactor",uY="org.eclipse.elk.layered.layering.nodePromotion.strategy",lY="org.eclipse.elk.layered.layering.nodePromotion.maxIterations",hY="org.eclipse.elk.layered.layering.coffmanGraham.layerBound",fY="org.eclipse.elk.layered.crossingMinimization.strategy",Kft="org.eclipse.elk.layered.crossingMinimization.hierarchicalSweepiness",Jft="org.eclipse.elk.layered.crossingMinimization.semiInteractive",Qft="org.eclipse.elk.layered.crossingMinimization.greedySwitch.activationThreshold",tdt="org.eclipse.elk.layered.crossingMinimization.greedySwitch.type",fE="org.eclipse.elk.layered.nodePlacement.strategy",dY="org.eclipse.elk.layered.nodePlacement.favorStraightEdges",pY="org.eclipse.elk.layered.nodePlacement.bk.edgeStraightening",gY="org.eclipse.elk.layered.nodePlacement.bk.fixedAlignment",mY="org.eclipse.elk.layered.nodePlacement.linearSegments.deflectionDampening",bY="org.eclipse.elk.layered.nodePlacement.networkSimplex.nodeFlexibility",edt="org.eclipse.elk.layered.nodePlacement.networkSimplex.nodeFlexibility.default",wY="org.eclipse.elk.layered.edgeRouting.selfLoopPlacement",fO="org.eclipse.elk.layered.edgeRouting.sloppySplineRouting",dO="org.eclipse.elk.layered.edgeRouting.sloppySplineLayerSpacing",ndt="org.eclipse.elk.layered.spacing.edgeNodeBetweenLayers",idt="org.eclipse.elk.layered.spacing.edgeEdgeBetweenLayers",rdt="org.eclipse.elk.layered.spacing.nodeNodeBetweenLayers",sdt="org.eclipse.elk.layered.priority.direction",odt="org.eclipse.elk.layered.priority.shortness",cdt="org.eclipse.elk.layered.priority.straightness",vY="org.eclipse.elk.layered.compaction.connectedComponents",adt="org.eclipse.elk.layered.compaction.postCompaction.strategy",udt="org.eclipse.elk.layered.compaction.postCompaction.constraints",pO="org.eclipse.elk.layered.highDegreeNodes.treatment",_Y="org.eclipse.elk.layered.highDegreeNodes.threshold",yY="org.eclipse.elk.layered.highDegreeNodes.treeHeight",b4="org.eclipse.elk.layered.wrapping.strategy",ldt="org.eclipse.elk.layered.wrapping.additionalEdgeSpacing",hdt="org.eclipse.elk.layered.wrapping.correctionFactor",gO="org.eclipse.elk.layered.wrapping.cutting.strategy",xY="org.eclipse.elk.layered.wrapping.cutting.cuts",MY="org.eclipse.elk.layered.wrapping.cutting.msd.freedom",EY="org.eclipse.elk.layered.wrapping.singleEdge.validify.strategy",mO="org.eclipse.elk.layered.wrapping.multiEdge.improveCuts",bO="org.eclipse.elk.layered.wrapping.multiEdge.distancePenalty",SY="org.eclipse.elk.layered.wrapping.multiEdge.improveWrappedEdges",fdt="org.eclipse.elk.layered.edgeLabels.sideSelection",ddt="org.eclipse.elk.layered.edgeLabels.centerLabelPlacementStrategy",pdt="layering",SBt="layering.minWidth",TBt="layering.nodePromotion",gdt="crossingMinimization",CBt="crossingMinimization.greedySwitch",ABt="nodePlacement",kBt="nodePlacement.bk",mdt="edgeRouting",t6="org.eclipse.elk.edgeRouting",K1="spacing",bdt="priority",LBt="compaction.postCompaction",PBt="Specifies whether and how post-process compaction is applied.",wdt="highDegreeNodes",vdt="wrapping",IBt="wrapping.cutting",_dt="wrapping.multiEdge",TY="edgeLabels",Nn="org.eclipse.elk.layered",ydt="org.eclipse.elk.spacing.edgeEdge",xdt="org.eclipse.elk.spacing.edgeNode",Mdt="org.eclipse.elk.spacing.labelLabel",Edt="org.eclipse.elk.spacing.labelPort",Sdt="org.eclipse.elk.spacing.labelNode",Tdt="org.eclipse.elk.spacing.portPort",Cdt="org.eclipse.elk.spacing.individualOverride",Adt="org.eclipse.elk.port.borderOffset",kdt="org.eclipse.elk.noLayout",Ldt="org.eclipse.elk.port.side",CY="org.eclipse.elk.debugMode",Pdt="org.eclipse.elk.alignment",Idt="org.eclipse.elk.hierarchyHandling",Rdt="org.eclipse.elk.insideSelfLoops.activate",Ddt="org.eclipse.elk.insideSelfLoops.yo",wO="org.eclipse.elk.nodeSize.constraints",AY="org.eclipse.elk.nodeSize.options",kY="org.eclipse.elk.direction",Ndt="org.eclipse.elk.nodeLabels.placement",Odt="org.eclipse.elk.portLabels.placement",Bdt="org.eclipse.elk.portLabels.nextToPortIfPossible",Fdt="org.eclipse.elk.portAlignment.default",Udt="org.eclipse.elk.portAlignment.north",zdt="org.eclipse.elk.portAlignment.south",jdt="org.eclipse.elk.portAlignment.west",Hdt="org.eclipse.elk.portAlignment.east",vO="org.eclipse.elk.nodeSize.minimum",Gdt="org.eclipse.elk.junctionPoints",Wdt="org.eclipse.elk.edgeLabels.placement",$dt="org.eclipse.elk.edgeLabels.inline",Vdt="org.eclipse.elk.port.index",qdt="org.eclipse.elk.commentBox",Xdt="org.eclipse.elk.hypernode",Zdt="org.eclipse.elk.port.anchor",Ydt="org.eclipse.elk.partitioning.activate",Kdt="org.eclipse.elk.partitioning.partition",_O="org.eclipse.elk.position",Jdt="org.eclipse.elk.margins",Qdt="org.eclipse.elk.spacing.portsSurrounding",RBt="NETWORK_SIMPLEX",nx="UNDEFINED",DBt={3:1,4:1,5:1,616:1},Lu={141:1,50:1},tpt="org.eclipse.elk.alg.layered.p1cycles",hw="org.eclipse.elk.alg.layered.p2layers",ept={422:1,208:1},NBt={736:1,3:1,4:1},Ju="org.eclipse.elk.alg.layered.p3order",lo="org.eclipse.elk.alg.layered.p4nodes",OBt={3:1,4:1,5:1,745:1},LY=1e-5,PY="DOWN",$p="org.eclipse.elk.alg.layered.p4nodes.bk",ix=17976931348623157e292,D_="org.eclipse.elk.alg.layered.p5edges",h0="org.eclipse.elk.alg.layered.p5edges.splines",N_=1e-6,yO=-1e-6,BBt="The list of vectors may not be empty.",npt=-17976931348623157e292,IY=.09999999999999998,FBt=4.71238898038469,UBt=3.141592653589793,w4="org.eclipse.elk.alg.mrtree",v4="org.eclipse.elk.alg.mrtree.graph",rx="org.eclipse.elk.alg.mrtree.intermediate",zBt="Set neighbors in level",jBt="DESCENDANTS",ipt="org.eclipse.elk.mrtree.weighting",rpt="org.eclipse.elk.mrtree.searchOrder",xO="org.eclipse.elk.alg.mrtree.options",O_="org.eclipse.elk.mrtree",HBt="org.eclipse.elk.tree",spt="org.eclipse.elk.alg.radial",sx=6.283185307179586,RY=5e-324,GBt="org.eclipse.elk.alg.radial.intermediate",DY="org.eclipse.elk.alg.radial.intermediate.compaction",WBt={3:1,4:1,5:1,63:1},opt="org.eclipse.elk.alg.radial.intermediate.optimization",NY="No implementation is available for the layout option ",_4="org.eclipse.elk.alg.radial.options",cpt="org.eclipse.elk.radial.orderId",apt="org.eclipse.elk.radial.radius",OY="org.eclipse.elk.radial.compactor",BY="org.eclipse.elk.radial.compactionStepSize",upt="org.eclipse.elk.radial.sorter",lpt="org.eclipse.elk.radial.wedgeCriteria",hpt="org.eclipse.elk.radial.optimizationCriteria",Um="org.eclipse.elk.radial",$Bt="org.eclipse.elk.alg.radial.p1position.wedge",fpt="org.eclipse.elk.alg.radial.sorting",VBt=5.497787143782138,qBt=3.9269908169872414,XBt=2.356194490192345,Rh="org.eclipse.elk.core.util",ZBt="Invalid index: ",ox="org.eclipse.elk.core.alg",cx={337:1},B_={284:1},dpt="Make sure it's type is registered with the ",ppt=" utility class.",dE="true",FY="false",YBt="Couldn't clone property '",Dh="org.eclipse.elk.core.options",KBt=1.2999999523162842,fw="org.eclipse.elk.box",gpt="org.eclipse.elk.expandNodes",mpt="org.eclipse.elk.box.packingMode",JBt="org.eclipse.elk.algorithm",bpt="org.eclipse.elk.bendPoints",QBt="org.eclipse.elk.labelManager",tFt="org.eclipse.elk.scaleFactor",eFt="org.eclipse.elk.animate",nFt="org.eclipse.elk.animTimeFactor",iFt="org.eclipse.elk.layoutAncestors",rFt="org.eclipse.elk.maxAnimTime",sFt="org.eclipse.elk.minAnimTime",oFt="org.eclipse.elk.progressBar",cFt="org.eclipse.elk.validateOptions",aFt="org.eclipse.elk.zoomToFit",uFt="org.eclipse.elk.nodeLabels.padding",lFt="org.eclipse.elk.font.name",hFt="org.eclipse.elk.font.size",fFt="org.eclipse.elk.edge.type",dFt="de.cau.cs.kieler.labelSpacing",pFt="partitioning",gFt="nodeLabels",MO="portAlignment",wpt="nodeSize",UY="port",mFt="portLabels",bFt="insideSelfLoops",wFt="de.cau.cs.kieler.selfLoopInside",e6="org.eclipse.elk.fixed",vFt="Fixed Layout",EO="org.eclipse.elk.random",_Ft="port must have a parent node to calculate the port side",n6="org.eclipse.elk.core.util.adapters",vpt="org.eclipse.elk.core.util.nodespacing",f0="org.eclipse.elk.core.util.nodespacing.cellsystem",yFt={171:1,307:1},_pt="Vertical alignment cannot be null",SO="org.eclipse.elk.core.util.nodespacing.internal",pE="org.eclipse.elk.core.util.nodespacing.internal.algorithm",gE="org.eclipse.elk.core.util.overlaps",Qu="org.eclipse.emf.ecore",F_="org.eclipse.elk.graph",xFt="EMapPropertyHolder",MFt="ElkBendPoint",EFt="ElkGraphElement",SFt="ElkConnectableShape",ypt="ElkEdge",TFt="ElkEdgeSection",CFt="EModelElement",AFt="ENamedElement",xpt="ElkLabel",Mpt="ElkNode",Ept="ElkPort",kFt={91:1,87:1},ax="org.eclipse.emf.common.notify.impl",U_="The feature '",zY="' is not a valid changeable feature",LFt="Expecting null",Spt="' is not a valid feature",ca=32768,PFt={95:1,91:1,87:1,51:1,42:1,92:1},Re="org.eclipse.emf.ecore.impl",d0="org.eclipse.elk.graph.impl",y4="Recursive containment not allowed for ",mE="The datatype '",zm="' is not a valid classifier",jY="The value '",z_={173:1,3:1,4:1},HY="The class '",bE="http://www.eclipse.org/elk/ElkGraph",Tpt="property",x4="value",GY="source",IFt="properties",RFt="identifier",WY="height",$Y="width",VY="parent",qY="text",Cpt="children",DFt="hierarchical",Apt="sources",XY="targets",kpt="sections",ZY="bendPoints",Lpt="outgoingShape",Ppt="incomingShape",Ipt="outgoingSections",Rpt="incomingSections",qs="org.eclipse.emf.common.util",Dpt="Severe implementation error in the Json to ElkGraph importer.",Df="id",Ds="org.eclipse.elk.graph.json",Npt="Unhandled parameter types: ",NFt="startPoint",OFt="An edge must have at least one source and one target (edge id: '",wE="').",BFt="Referenced edge section does not exist: ",FFt=" (edge id: '",Opt="target",TO="group",Ti="name",UFt="connectableShape cannot be null",YY="Passed edge is not 'simple'.",i6="The 'no duplicates' constraint is violated",Nf={3:1,4:1,20:1,25:1,41:1,13:1,15:1,49:1,59:1,55:1,52:1},KY={3:1,4:1,20:1,25:1,41:1,13:1,43:1,15:1,49:1,59:1,55:1,52:1,532:1},JY="org.eclipse.elk.graph.util",Bpt="undefined",zFt="parser.parse.1",jFt="parser.parse.2",CO="parser.next.1",QY="parser.next.2",HFt="parser.next.3",GFt="parser.next.4",p0="parser.factor.1",Fpt="parser.factor.2",WFt="parser.factor.3",$Ft="parser.factor.4",VFt="parser.factor.5",qFt="parser.factor.6",XFt="parser.atom.1",ZFt="parser.atom.2",YFt="parser.atom.3",Upt="parser.atom.4",tK="parser.atom.5",zpt="parser.cc.1",AO="parser.cc.2",KFt="parser.cc.3",JFt="parser.cc.5",jpt="parser.cc.6",Hpt="parser.cc.7",eK="parser.cc.8",QFt="parser.ope.1",tUt="parser.ope.2",eUt="parser.ope.3",Vp="parser.descape.1",nUt="parser.descape.2",iUt="parser.descape.3",rUt="parser.descape.4",sUt="parser.descape.5",tl="parser.process.1",oUt="parser.quantifier.1",cUt="parser.quantifier.2",aUt="parser.quantifier.3",uUt="parser.quantifier.4",Gpt="parser.quantifier.5",lUt="org.eclipse.emf.common.notify",Wpt={380:1,610:1},hUt={3:1,4:1,20:1,25:1,41:1,13:1,15:1,59:1,52:1},r6={338:1,136:1},M4="index=",kO=", size=",nK={3:1,4:1,5:1,116:1},fUt={3:1,4:1,20:1,25:1,41:1,13:1,15:1,49:1,59:1,52:1},$pt={3:1,6:1,4:1,5:1,175:1},dUt={3:1,4:1,5:1,339:1},pUt=";/?:@&=+$,",gUt="invalid authority: ",mUt="EAnnotation",bUt="ETypedElement",wUt="EStructuralFeature",vUt="EAttribute",_Ut="EClassifier",yUt="EEnumLiteral",xUt="EGenericType",MUt="EOperation",EUt="EParameter",SUt="EReference",TUt="ETypeParameter",hr="org.eclipse.emf.ecore.util",Vpt={3:1,20:1,13:1,15:1,52:1,533:1,81:1,64:1},CUt="org.eclipse.emf.ecore.util.FeatureMap$Entry",oh=1024,La=8192,dw=2048,E4="byte",LO="char",S4="double",T4="float",C4="int",A4="long",k4="short",AUt="java.lang.Object",j_={3:1,4:1,5:1,222:1},qpt={3:1,4:1,5:1,611:1},kUt={3:1,4:1,20:1,25:1,41:1,13:1,15:1,49:1,59:1,55:1,52:1,64:1},Zo={3:1,4:1,20:1,25:1,41:1,13:1,15:1,49:1,59:1,55:1,52:1,81:1,64:1},s6="mixed",ui="http:///org/eclipse/emf/ecore/util/ExtendedMetaData",yl="kind",LUt={3:1,4:1,5:1,612:1},Xpt={3:1,4:1,20:1,25:1,41:1,13:1,15:1,59:1,52:1,81:1,64:1},PO={20:1,25:1,41:1,13:1,15:1,52:1,64:1},IO={43:1,120:1,260:1},RO={75:1,311:1},DO="The value of type '",NO="' must be of type '",H_=1365,xl="http://www.eclipse.org/emf/2002/Ecore",OO=-32768,jm="constraints",Ns="baseType",PUt="getEStructuralFeature",IUt="getFeatureID",L4="feature",RUt="getOperationID",Zpt="operation",DUt="defaultValue",NUt="eTypeParameters",OUt="isInstance",BUt="getEEnumLiteral",FUt="eContainingClass",wi={47:1},UUt={3:1,4:1,5:1,124:1},zUt="org.eclipse.emf.ecore.resource",jUt={91:1,87:1,534:1,1628:1},iK="org.eclipse.emf.ecore.resource.impl",Ypt="unspecified",o6="simple",BO="attribute",HUt="attributeWildcard",FO="element",rK="elementWildcard",Nh="collapse",sK="itemType",UO="namespace",c6="##targetNamespace",Ml="whiteSpace",Kpt="wildcards",g0="http://www.eclipse.org/emf/2003/XMLType",oK="##any",vE="uninitialized",cK="The multiplicity constraint is violated",zO="org.eclipse.emf.ecore.xml.type",GUt="ProcessingInstruction",WUt="SimpleAnyType",$Ut="XMLTypeDocumentRoot",Xr="org.eclipse.emf.ecore.xml.type.impl",a6="INF",VUt="processing",qUt="ENTITIES_._base",Jpt="minLength",Qpt="ENTITY",jO="NCName",XUt="IDREFS_._base",t1t="integer",aK="token",uK="pattern",ZUt="[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*",e1t="\\i\\c*",YUt="[\\i-[:]][\\c-[:]]*",KUt="nonPositiveInteger",u6="maxInclusive",n1t="NMTOKEN",JUt="NMTOKENS_._base",i1t="nonNegativeInteger",l6="minInclusive",QUt="normalizedString",tzt="unsignedByte",ezt="unsignedInt",nzt="18446744073709551615",izt="unsignedShort",rzt="processingInstruction",qp="org.eclipse.emf.ecore.xml.type.internal",_E=1114111,szt="Internal Error: shorthands: \\u",P4="xml:isDigit",lK="xml:isWord",hK="xml:isSpace",fK="xml:isNameChar",dK="xml:isInitialNameChar",ozt="09\u0660\u0669\u06F0\u06F9\u0966\u096F\u09E6\u09EF\u0A66\u0A6F\u0AE6\u0AEF\u0B66\u0B6F\u0BE7\u0BEF\u0C66\u0C6F\u0CE6\u0CEF\u0D66\u0D6F\u0E50\u0E59\u0ED0\u0ED9\u0F20\u0F29",czt="AZaz\xC0\xD6\xD8\xF6\xF8\u0131\u0134\u013E\u0141\u0148\u014A\u017E\u0180\u01C3\u01CD\u01F0\u01F4\u01F5\u01FA\u0217\u0250\u02A8\u02BB\u02C1\u0386\u0386\u0388\u038A\u038C\u038C\u038E\u03A1\u03A3\u03CE\u03D0\u03D6\u03DA\u03DA\u03DC\u03DC\u03DE\u03DE\u03E0\u03E0\u03E2\u03F3\u0401\u040C\u040E\u044F\u0451\u045C\u045E\u0481\u0490\u04C4\u04C7\u04C8\u04CB\u04CC\u04D0\u04EB\u04EE\u04F5\u04F8\u04F9\u0531\u0556\u0559\u0559\u0561\u0586\u05D0\u05EA\u05F0\u05F2\u0621\u063A\u0641\u064A\u0671\u06B7\u06BA\u06BE\u06C0\u06CE\u06D0\u06D3\u06D5\u06D5\u06E5\u06E6\u0905\u0939\u093D\u093D\u0958\u0961\u0985\u098C\u098F\u0990\u0993\u09A8\u09AA\u09B0\u09B2\u09B2\u09B6\u09B9\u09DC\u09DD\u09DF\u09E1\u09F0\u09F1\u0A05\u0A0A\u0A0F\u0A10\u0A13\u0A28\u0A2A\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59\u0A5C\u0A5E\u0A5E\u0A72\u0A74\u0A85\u0A8B\u0A8D\u0A8D\u0A8F\u0A91\u0A93\u0AA8\u0AAA\u0AB0\u0AB2\u0AB3\u0AB5\u0AB9\u0ABD\u0ABD\u0AE0\u0AE0\u0B05\u0B0C\u0B0F\u0B10\u0B13\u0B28\u0B2A\u0B30\u0B32\u0B33\u0B36\u0B39\u0B3D\u0B3D\u0B5C\u0B5D\u0B5F\u0B61\u0B85\u0B8A\u0B8E\u0B90\u0B92\u0B95\u0B99\u0B9A\u0B9C\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8\u0BAA\u0BAE\u0BB5\u0BB7\u0BB9\u0C05\u0C0C\u0C0E\u0C10\u0C12\u0C28\u0C2A\u0C33\u0C35\u0C39\u0C60\u0C61\u0C85\u0C8C\u0C8E\u0C90\u0C92\u0CA8\u0CAA\u0CB3\u0CB5\u0CB9\u0CDE\u0CDE\u0CE0\u0CE1\u0D05\u0D0C\u0D0E\u0D10\u0D12\u0D28\u0D2A\u0D39\u0D60\u0D61\u0E01\u0E2E\u0E30\u0E30\u0E32\u0E33\u0E40\u0E45\u0E81\u0E82\u0E84\u0E84\u0E87\u0E88\u0E8A\u0E8A\u0E8D\u0E8D\u0E94\u0E97\u0E99\u0E9F\u0EA1\u0EA3\u0EA5\u0EA5\u0EA7\u0EA7\u0EAA\u0EAB\u0EAD\u0EAE\u0EB0\u0EB0\u0EB2\u0EB3\u0EBD\u0EBD\u0EC0\u0EC4\u0F40\u0F47\u0F49\u0F69\u10A0\u10C5\u10D0\u10F6\u1100\u1100\u1102\u1103\u1105\u1107\u1109\u1109\u110B\u110C\u110E\u1112\u113C\u113C\u113E\u113E\u1140\u1140\u114C\u114C\u114E\u114E\u1150\u1150\u1154\u1155\u1159\u1159\u115F\u1161\u1163\u1163\u1165\u1165\u1167\u1167\u1169\u1169\u116D\u116E\u1172\u1173\u1175\u1175\u119E\u119E\u11A8\u11A8\u11AB\u11AB\u11AE\u11AF\u11B7\u11B8\u11BA\u11BA\u11BC\u11C2\u11EB\u11EB\u11F0\u11F0\u11F9\u11F9\u1E00\u1E9B\u1EA0\u1EF9\u1F00\u1F15\u1F18\u1F1D\u1F20\u1F45\u1F48\u1F4D\u1F50\u1F57\u1F59\u1F59\u1F5B\u1F5B\u1F5D\u1F5D\u1F5F\u1F7D\u1F80\u1FB4\u1FB6\u1FBC\u1FBE\u1FBE\u1FC2\u1FC4\u1FC6\u1FCC\u1FD0\u1FD3\u1FD6\u1FDB\u1FE0\u1FEC\u1FF2\u1FF4\u1FF6\u1FFC\u2126\u2126\u212A\u212B\u212E\u212E\u2180\u2182\u3007\u3007\u3021\u3029\u3041\u3094\u30A1\u30FA\u3105\u312C\u4E00\u9FA5\uAC00\uD7A3",azt="Private Use",pK="ASSIGNED",uzt="\0\x7F\x80\xFF\u0100\u017F\u0180\u024F\u0250\u02AF\u02B0\u02FF\u0300\u036F\u0370\u03FF\u0400\u04FF\u0530\u058F\u0590\u05FF\u0600\u06FF\u0700\u074F\u0780\u07BF\u0900\u097F\u0980\u09FF\u0A00\u0A7F\u0A80\u0AFF\u0B00\u0B7F\u0B80\u0BFF\u0C00\u0C7F\u0C80\u0CFF\u0D00\u0D7F\u0D80\u0DFF\u0E00\u0E7F\u0E80\u0EFF\u0F00\u0FFF\u1000\u109F\u10A0\u10FF\u1100\u11FF\u1200\u137F\u13A0\u13FF\u1400\u167F\u1680\u169F\u16A0\u16FF\u1780\u17FF\u1800\u18AF\u1E00\u1EFF\u1F00\u1FFF\u2000\u206F\u2070\u209F\u20A0\u20CF\u20D0\u20FF\u2100\u214F\u2150\u218F\u2190\u21FF\u2200\u22FF\u2300\u23FF\u2400\u243F\u2440\u245F\u2460\u24FF\u2500\u257F\u2580\u259F\u25A0\u25FF\u2600\u26FF\u2700\u27BF\u2800\u28FF\u2E80\u2EFF\u2F00\u2FDF\u2FF0\u2FFF\u3000\u303F\u3040\u309F\u30A0\u30FF\u3100\u312F\u3130\u318F\u3190\u319F\u31A0\u31BF\u3200\u32FF\u3300\u33FF\u3400\u4DB5\u4E00\u9FFF\uA000\uA48F\uA490\uA4CF\uAC00\uD7A3\uE000\uF8FF\uF900\uFAFF\uFB00\uFB4F\uFB50\uFDFF\uFE20\uFE2F\uFE30\uFE4F\uFE50\uFE6F\uFE70\uFEFE\uFEFF\uFEFF\uFF00\uFFEF",r1t="UNASSIGNED",yE={3:1,112:1},lzt="org.eclipse.emf.ecore.xml.type.util",HO={3:1,4:1,5:1,342:1},s1t="org.eclipse.xtext.xbase.lib",hzt="Cannot add elements to a Range",fzt="Cannot set elements in a Range",dzt="Cannot remove elements from a Range",GO="locale",WO="default",$O="user.agent",u,VO,gK,w3e=-1;ffe(),T(1,null,{},U),u.Fb=function(e){return this===e},u.Gb=function(){return this.ql},u.Hb=function(){return cm(this)},u.Ib=function(){return Ng(fu(this))+"@"+(Yr(this)>>>0).toString(16)},u.equals=function(t){return this.Fb(t)},u.hashCode=function(){return this.Hb()},u.toString=function(){return this.Ib()};var pzt,gzt,mzt;T(274,1,{274:1,1712:1},Cat),u._d=function(e){var n;return n=new Cat,n.i=4,e>1?n.c=nAt(this,e-1):n.c=this,n},u.ae=function(){return Vd(this),this.b},u.be=function(){return Ng(this)},u.ce=function(){return Vd(this),this.k},u.de=function(){return(this.i&4)!=0},u.ee=function(){return(this.i&1)!=0},u.Ib=function(){return Vct(this)},u.i=0;var v3e=1,un=A(bc,"Object",1),o1t=A(bc,"Class",274);T(1692,1,{3:1});var lLe=A(k_,"Optional",1692);T(1060,1692,{3:1},j),u.Fb=function(e){return e===this},u.Hb=function(){return 2040732332},u.Ib=function(){return"Optional.absent()"},u.Jb=function(e){return si(e),Wr(),mK};var mK,hLe=A(k_,"Absent",1060),_3e=Sr(k_,"Function");T(393,1,{},A5),u.Lb=function(e){return WCt(e)};var fLe=A(k_,"Joiner",393);T(875,393,{},ZTt),u.Lb=function(e){return e==null?this.b:WCt(e)};var dLe=A(k_,"Joiner/1",875);T(874,1,{},Wj);var pLe=A(k_,"Joiner/MapJoiner",874),y3e=Sr(k_,"Predicate"),bzt;T(494,1,{138:1,494:1,3:1,56:1},xj),u.Nb=function(e){return this.Mb(e)},u.Mb=function(e){var n;for(n=0;n0},u.ic=function(){if(this.b>=this.c)throw K(new J);return d3t(this,this.b++)},u.Dc=function(){return this.b},u.Ec=function(){if(this.b<=0)throw K(new J);return d3t(this,--this.b)},u.Fc=function(){return this.b-1},u.b=0,u.c=0;var ILe=A(Le,"AbstractIndexedListIterator",847);T(949,257,J7),u.hc=function(){return s_(this)},u.ic=function(){return L2(this)},u.d=1;var RLe=A(Le,"AbstractIterator",949);T(1677,1,{238:1}),u.Hc=function(){var e;return e=this.f,e||(this.f=this.Ic())},u.Jc=function(){return new YG(this.Hc())},u.Lc=function(){return new E5t(this.Kc(),this._b(),ct(this,475)?1:0)},u.Fb=function(e){return nq(this,e)},u.Hb=function(){return Yr(this.Hc())},u.Wb=function(){return this._b()==0},u.Xb=function(){return fot(this)},u.Ib=function(){return Yc(this.Hc())};var DLe=A(Le,"AbstractMultimap",1677);T(654,1677,cZ),u.Pb=function(){oat(this)},u.Qb=function(e){return this.c.Qb(e)},u.Ic=function(){return ct(this.c,122)?new qT(this,a(this.c,122)):ct(this.c,115)?new hM(this,a(this.c,115)):new tM(this,this.c)},u.Pc=function(e){return this.Oc()},u.Jc=function(){return ct(this.c,122)?new Pv(this,a(this.c,122)):ct(this.c,115)?new l2(this,a(this.c,115)):new lM(this,this.c)},u.Qc=function(){return upe(this.Oc())},u.Kc=function(){return new Axt(this)},u.Lc=function(){return olt(this.c.Tb().wc(),new gt,64,this.d)},u.Mc=function(e){return rr(this,e)},u.Nc=function(e){return JC(this,e)},u._b=function(){return this.d},u.Rc=function(){return new Cxt(this)},u.Sc=function(){return olt(this.c.ac().wc(),new V,64,this.d)},u.d=0;var NLe=A(Le,"AbstractMapBasedMultimap",654);T(1483,654,cZ),u.Oc=function(){return new Vu(this.a)},u.Qc=function(){return tC(),tC(),u1t},u.Mc=function(e){return a(rr(this,e),15)},u.Nc=function(e){return a(JC(this,e),15)},u.Hc=function(){var e;return e=this.f,e||(this.f=ct(this.c,122)?new qT(this,a(this.c,122)):ct(this.c,115)?new hM(this,a(this.c,115)):new tM(this,this.c))},u.Fb=function(e){return nq(this,e)},u.Tc=function(e){return a(rr(this,e),15)},u.Uc=function(e){return a(JC(this,e),15)};var OLe=A(Le,"AbstractListMultimap",1483);T(661,1,Cs),u.gc=function(e){ks(this,e)},u.hc=function(){return this.c.hc()||this.e.hc()},u.ic=function(){var e;return this.e.hc()||(e=a(this.c.ic(),38),this.b=e.kc(),this.a=a(e.lc(),13),this.e=this.a.tc()),this.Vc(this.b,this.e.ic())},u.jc=function(){this.e.jc(),this.a.Wb()&&this.c.jc(),--this.d.d};var BLe=A(Le,"AbstractMapBasedMultimap/Itr",661);T(970,661,Cs,Cxt),u.Vc=function(e,n){return n};var FLe=A(Le,"AbstractMapBasedMultimap/1",970);T(971,1,ys,V),u.Kb=function(e){return a(e,13).wc()};var ULe=A(Le,"AbstractMapBasedMultimap/1methodref$spliterator$Type",971);T(972,661,Cs,Axt),u.Vc=function(e,n){return ts(),new I5(e,n)};var zLe=A(Le,"AbstractMapBasedMultimap/2",972);T(1666,1,sE),u.Ub=function(e){WV(this,e)},u.Yb=function(e,n,i){return Qat(this,e,n,i)},u.Pb=function(){this.Tb().Pb()},u.Wc=function(e){return qq(this,e)},u.Qb=function(e){return!!nlt(this,e,!1)},u.Rb=function(e){var n,i,r;for(i=this.Tb().tc();i.hc();)if(n=a(i.ic(),38),r=n.lc(),zt(e)===zt(r)||e!=null&&Fi(e,r))return!0;return!1},u.Fb=function(e){return G8t(this,e)},u.Vb=function(e){return Ua(nlt(this,e,!1))},u.Hb=function(){return Sat(this.Tb())},u.Wb=function(){return this._b()==0},u.Xb=function(){return new xv(this)},u.Zb=function(e,n){throw K(new Tp("Put not supported on this map"))},u.$b=function(e){return Ua(nlt(this,e,!0))},u._b=function(){return this.Tb()._b()},u.Ib=function(){var e,n,i;for(i=new _m("{","}"),n=this.Tb().tc();n.hc();)e=a(n.ic(),38),Wg(i,q4t(this,e.kc())+"="+q4t(this,e.lc()));return i.a?i.e.length==0?i.a.a:i.a.a+(""+i.e):i.c},u.ac=function(){return new vf(this)};var jLe=A(ii,"AbstractMap",1666);T(1678,1666,sE),u.Jc=function(){return new YG(this)},u.Tb=function(){return hot(this)},u.Xb=function(){var e;return e=this.g,e||(this.g=this.Jc())},u.ac=function(){var e;return e=this.i,e||(this.i=new rMt(this))};var HLe=A(Le,"Maps/ViewCachingAbstractMap",1678);T(357,1678,sE,tM),u.Vb=function(e){return Jae(this,e)},u.$b=function(e){return Zle(this,e)},u.Pb=function(){this.d==this.e.c?this.e.Pb():VD(new Qst(this))},u.Qb=function(e){return Jfe(this.d,e)},u.Yc=function(){return new Mj(this)},u.Xc=function(){return this.Yc()},u.Fb=function(e){return this===e||Fi(this.d,e)},u.Hb=function(){return Yr(this.d)},u.Xb=function(){return this.e.Xb()},u._b=function(){return this.d._b()},u.Ib=function(){return Yc(this.d)};var GLe=A(Le,"AbstractMapBasedMultimap/AsMap",357);T(25,1,L_),u.sc=function(e){vo(this,e)},u.uc=function(){return new gi(null,this.wc())},u.wc=function(){return new Ei(this,0)},u.xc=function(){return new gi(null,this.wc())},u.nc=function(e){throw K(new Tp("Add not supported on this collection"))},u.oc=function(e){return yo(this,e)},u.Pb=function(){gL(this)},u.pc=function(e){return O2(this,e,!1)},u.qc=function(e){return N1(this,e)},u.Wb=function(){return this._b()==0},u.vc=function(e){return O2(this,e,!0)},u.yc=function(){return g$(this)},u.zc=function(e){return aP(this,e)},u.Ib=function(){return Gp(this)};var WLe=A(ii,"AbstractCollection",25);T(bd,25,vl),u.wc=function(){return new Ei(this,1)},u.Fb=function(e){return yIt(this,e)},u.Hb=function(){return Sat(this)};var $Le=A(ii,"AbstractSet",bd);T(1660,bd,vl);var VLe=A(Le,"Sets/ImprovedAbstractSet",1660);T(1679,1660,vl),u.Pb=function(){this.Zc().Pb()},u.pc=function(e){return AIt(this,e)},u.Wb=function(){return this.Zc().Wb()},u.vc=function(e){var n;return this.pc(e)?(n=a(e,38),this.Zc().Xb().vc(n.kc())):!1},u._b=function(){return this.Zc()._b()};var qLe=A(Le,"Maps/EntrySet",1679);T(968,1679,vl,Mj),u.pc=function(e){return QIt(this.a.d.Tb(),e)},u.tc=function(){return new Qst(this.a)},u.Zc=function(){return this.a},u.vc=function(e){var n;return QIt(this.a.d.Tb(),e)?(n=a(e,38),uae(this.a.e,n.kc()),!0):!1},u.wc=function(){return l$(this.a.d.Tb().wc(),new Ej(this.a))};var XLe=A(Le,"AbstractMapBasedMultimap/AsMap/AsMapEntries",968);T(969,1,ys,Ej),u.Kb=function(e){return D5t(this.a,a(e,38))};var ZLe=A(Le,"AbstractMapBasedMultimap/AsMap/AsMapEntries/0methodref$wrapEntry$Type",969);T(659,1,Cs,Qst),u.gc=function(e){ks(this,e)},u.ic=function(){var e;return e=a(this.b.ic(),38),this.a=a(e.lc(),13),D5t(this.c,e)},u.hc=function(){return this.b.hc()},u.jc=function(){this.b.jc(),this.c.e.d-=this.a._b(),this.a.Pb()};var YLe=A(Le,"AbstractMapBasedMultimap/AsMap/AsMapIterator",659);T(541,1660,vl,YG),u.Pb=function(){this.b.Pb()},u.pc=function(e){return this.b.Qb(e)},u.sc=function(e){si(e),this.b.Ub(new kj(e))},u.Wb=function(){return this.b.Wb()},u.tc=function(){return ts(),ZT(this.b.Tb().tc(),(Fv(),h6))},u.vc=function(e){return this.b.Qb(e)?(this.b.$b(e),!0):!1},u._b=function(){return this.b._b()};var KLe=A(Le,"Maps/KeySet",541);T(356,541,vl,lM),u.Pb=function(){var e;VD((e=this.b.Tb().tc(),new qit(this,e)))},u.qc=function(e){return this.b.Xb().qc(e)},u.Fb=function(e){return this===e||Fi(this.b.Xb(),e)},u.Hb=function(){return Yr(this.b.Xb())},u.tc=function(){var e;return e=this.b.Tb().tc(),new qit(this,e)},u.vc=function(e){var n,i;return i=0,n=a(this.b.$b(e),13),n&&(i=n._b(),n.Pb(),this.a.d-=i),i>0},u.wc=function(){return this.b.Xb().wc()};var JLe=A(Le,"AbstractMapBasedMultimap/KeySet",356);T(660,1,Cs,qit),u.gc=function(e){ks(this,e)},u.hc=function(){return this.c.hc()},u.ic=function(){return this.a=a(this.c.ic(),38),this.a.kc()},u.jc=function(){var e;x1(!!this.a,cw),e=a(this.a.lc(),13),this.c.jc(),this.b.a.d-=e._b(),e.Pb()};var QLe=A(Le,"AbstractMapBasedMultimap/KeySet/1",660);T(358,357,{109:1,115:1},hM),u.Jc=function(){return this.$c()},u.Xb=function(){return this._c()},u.$c=function(){return new l2(this.c,this.ad())},u._c=function(){var e;return e=this.b,e||(this.b=this.$c())},u.ad=function(){return a(this.d,115)};var tPe=A(Le,"AbstractMapBasedMultimap/SortedAsMap",358);T(396,358,wOt,qT),u.$c=function(){return new Pv(this.a,a(a(this.d,115),122))},u.Xb=function(){var e;return e=this.b,a(e||(this.b=new Pv(this.a,a(a(this.d,115),122))),196)},u._c=function(){var e;return e=this.b,a(e||(this.b=new Pv(this.a,a(a(this.d,115),122))),196)},u.ad=function(){return a(a(this.d,115),122)};var ePe=A(Le,"AbstractMapBasedMultimap/NavigableAsMap",396);T(327,356,vOt,l2),u.wc=function(){return this.b.Xb().wc()};var nPe=A(Le,"AbstractMapBasedMultimap/SortedKeySet",327);T(299,327,Qht,Pv);var iPe=A(Le,"AbstractMapBasedMultimap/NavigableKeySet",299);T(448,25,L_,EL),u.nc=function(e){var n,i;return du(this),i=this.d.Wb(),n=this.d.nc(e),n&&(++this.f.d,i&&gD(this)),n},u.oc=function(e){var n,i,r;return e.Wb()?!1:(r=(du(this),this.d._b()),n=this.d.oc(e),n&&(i=this.d._b(),this.f.d+=i-r,r==0&&gD(this)),n)},u.Pb=function(){var e;e=(du(this),this.d._b()),e!=0&&(this.d.Pb(),this.f.d-=e,zD(this))},u.pc=function(e){return du(this),this.d.pc(e)},u.qc=function(e){return du(this),this.d.qc(e)},u.Fb=function(e){return e===this?!0:(du(this),Fi(this.d,e))},u.Hb=function(){return du(this),Yr(this.d)},u.tc=function(){return du(this),new jst(this)},u.vc=function(e){var n;return du(this),n=this.d.vc(e),n&&(--this.f.d,zD(this)),n},u._b=function(){return MEt(this)},u.wc=function(){return du(this),this.d.wc()},u.Ib=function(){return du(this),Yc(this.d)};var rPe=A(Le,"AbstractMapBasedMultimap/WrappedCollection",448),Sl=Sr(ii,"List");T(657,448,{20:1,25:1,13:1,15:1},lot),u.jd=function(e){R1(this,e)},u.wc=function(){return du(this),this.d.wc()},u.bd=function(e,n){var i;du(this),i=this.d.Wb(),a(this.d,15).bd(e,n),++this.a.d,i&&gD(this)},u.cd=function(e){return du(this),a(this.d,15).cd(e)},u.dd=function(e){return du(this),a(this.d,15).dd(e)},u.ed=function(){return du(this),new VEt(this)},u.fd=function(e){return du(this),new k4t(this,e)},u.gd=function(e){var n;return du(this),n=a(this.d,15).gd(e),--this.a.d,zD(this),n},u.hd=function(e,n){return du(this),a(this.d,15).hd(e,n)},u.kd=function(e,n){return du(this),act(this.a,this.e,a(this.d,15).kd(e,n),this.b?this.b:this)};var sPe=A(Le,"AbstractMapBasedMultimap/WrappedList",657);T(967,657,{20:1,25:1,13:1,15:1,49:1},ASt);var oPe=A(Le,"AbstractMapBasedMultimap/RandomAccessWrappedList",967);T(558,1,Cs,jst),u.gc=function(e){ks(this,e)},u.hc=function(){return wM(this),this.b.hc()},u.ic=function(){return wM(this),this.b.ic()},u.jc=function(){mSt(this)};var cPe=A(Le,"AbstractMapBasedMultimap/WrappedCollection/WrappedIterator",558);T(658,558,kf,VEt,k4t),u.jc=function(){mSt(this)},u.Bc=function(e){var n;n=MEt(this.a)==0,(wM(this),a(this.b,120)).Bc(e),++this.a.a.d,n&&gD(this.a)},u.Cc=function(){return(wM(this),a(this.b,120)).Cc()},u.Dc=function(){return(wM(this),a(this.b,120)).Dc()},u.Ec=function(){return(wM(this),a(this.b,120)).Ec()},u.Fc=function(){return(wM(this),a(this.b,120)).Fc()},u.Gc=function(e){(wM(this),a(this.b,120)).Gc(e)};var aPe=A(Le,"AbstractMapBasedMultimap/WrappedList/WrappedListIterator",658);T(559,448,vOt,qW),u.wc=function(){return du(this),this.d.wc()};var uPe=A(Le,"AbstractMapBasedMultimap/WrappedSortedSet",559);T(656,559,Qht,Prt);var lPe=A(Le,"AbstractMapBasedMultimap/WrappedNavigableSet",656);T(655,448,vl,ast),u.wc=function(){return du(this),this.d.wc()};var hPe=A(Le,"AbstractMapBasedMultimap/WrappedSet",655);T(974,1,ys,gt),u.Kb=function(e){var n,i;return n=e.kc(),i=a(e.lc(),13),l$(i.wc(),new Sj(n))};var fPe=A(Le,"AbstractMapBasedMultimap/lambda$0$Type",974);T(973,1,ys,Sj),u.Kb=function(e){return uee(this.a,e)};var dPe=A(Le,"AbstractMapBasedMultimap/lambda$2$Type",973);T(392,1,aZ),u.Fb=function(e){var n;return ct(e,38)?(n=a(e,38),Rp(this.kc(),n.kc())&&Rp(this.lc(),n.lc())):!1},u.Hb=function(){var e,n;return e=this.kc(),n=this.lc(),(e==null?0:Yr(e))^(n==null?0:Yr(n))},u.mc=function(e){throw K(new Oi)},u.Ib=function(){return this.kc()+"="+this.lc()};var pPe=A(Le,_Ot,392);T(1680,25,L_),u.Pb=function(){this.ld().Pb()},u.pc=function(e){var n;return ct(e,38)?(n=a(e,38),fce(this.ld(),n.kc(),n.lc())):!1},u.vc=function(e){var n;return ct(e,38)?(n=a(e,38),qAt(this.ld(),n.kc(),n.lc())):!1},u._b=function(){return this.ld()._b()};var gPe=A(Le,"Multimaps/Entries",1680);T(975,1680,L_),u.tc=function(){return this.a.Kc()},u.ld=function(){return this.a},u.wc=function(){return this.a.Lc()};var mPe=A(Le,"AbstractMultimap/Entries",975);T(662,975,vl,S8),u.wc=function(){return this.a.Lc()},u.Fb=function(e){return t9t(this,e)},u.Hb=function(){return TPt(this)};var bPe=A(Le,"AbstractMultimap/EntrySet",662);T(663,25,L_,Ud),u.Pb=function(){this.a.Pb()},u.pc=function(e){return $le(this.a,e)},u.tc=function(){return this.a.Rc()},u._b=function(){return this.a.d},u.wc=function(){return this.a.Sc()};var wPe=A(Le,"AbstractMultimap/Values",663);T(1681,25,{738:1,20:1,25:1,13:1}),u.sc=function(e){si(e),$b(this).sc(new Bj(e))},u.wc=function(){var e;return e=$b(this).wc(),olt(e,new se,64|e.qd()&1296,hq(this))},u.nc=function(e){return Tit(),!0},u.oc=function(e){return K1e(this,e)},u.Pb=function(){VD(new xit(hot(fm(this.a)).tc()))},u.pc=function(e){var n;return n=a(WM(fm(this.a),e),13),(n?n._b():0)>0},u.Fb=function(e){return zme(this,e)},u.Hb=function(){return Yr($b(this))},u.Wb=function(){return $b(this).Wb()},u.tc=function(){return new X3t(this,$b(this).tc())},u.vc=function(e){return Alt(this,e,1)>0},u._b=function(){return hq(this)},u.Ib=function(){return Yc($b(this))};var vPe=A(Le,"AbstractMultiset",1681);T(557,654,OP),u.Oc=function(){return this.md()},u.Qc=function(){return this.nd()},u.Mc=function(e){return this.od(e)},u.Nc=function(e){return this.pd(e)},u.Hc=function(){var e;return e=this.f,e||(this.f=ct(this.c,122)?new qT(this,a(this.c,122)):ct(this.c,115)?new hM(this,a(this.c,115)):new tM(this,this.c))},u.nd=function(){return Hb(),bM(),I4},u.Fb=function(e){return nq(this,e)},u.od=function(e){return a(rr(this,e),19)},u.pd=function(e){return a(JC(this,e),19)};var _Pe=A(Le,"AbstractSetMultimap",557);T(1413,557,OP),u.md=function(){return new Ob(this.b)},u.nd=function(){var e;return e=this.b,e?Kse(this.b):(we(),new Z5(new Ob(this.b)))},u.Mc=function(e){return a(a(rr(this,e),19),60)},u.od=function(e){return a(a(rr(this,e),19),60)},u.Nc=function(e){return a(a(JC(this,e),19),60)},u.pd=function(e){return a(a(JC(this,e),19),60)},u.Hc=function(){var e;return e=this.f,e||(this.f=ct(this.c,122)?new qT(this,a(this.c,122)):ct(this.c,115)?new hM(this,a(this.c,115)):new tM(this,this.c))};var yPe=A(Le,"AbstractSortedSetMultimap",1413);T(1414,1413,OP),u.Hc=function(){var e;return e=this.f,a(a(e||(this.f=ct(this.c,122)?new qT(this,a(this.c,122)):ct(this.c,115)?new hM(this,a(this.c,115)):new tM(this,this.c)),115),122)},u.Xb=function(){var e;return e=this.i,a(a(e||(this.i=ct(this.c,122)?new Pv(this,a(this.c,122)):ct(this.c,115)?new l2(this,a(this.c,115)):new lM(this,this.c)),60),196)};var xPe=A(Le,"AbstractSortedKeySortedSetMultimap",1414);T(521,1483,cZ,pD),u.a=0;var MPe=A(Le,"ArrayListMultimap",521);T(1156,1,Wp,O3t),u.qd=function(){return this.a.qd()&-262},u.rd=function(){return this.a.rd()},u.gc=function(e){this.a.gc(new F3t(e,this.b))},u.sd=function(e){return this.a.sd(new B3t(e,this.b))};var EPe=A(Le,"CollectSpliterators/1",1156);T(1157,1,{},B3t),u.td=function(e){this.a.td(this.b.Kb(e))};var SPe=A(Le,"CollectSpliterators/1/lambda$0$Type",1157);T(1158,1,{},F3t),u.td=function(e){this.a.td(this.b.Kb(e))};var TPe=A(Le,"CollectSpliterators/1/lambda$1$Type",1158);T(1159,1,Wp,okt),u.qd=function(){return this.a},u.rd=function(){return this.d&&(this.b=AEt(this.b,this.d.rd())),AEt(this.b,0)},u.gc=function(e){this.d&&(this.d.gc(e),this.d=null),this.c.gc(new z3t(this.e,e)),this.b=0},u.sd=function(e){for(;;){if(this.d&&this.d.sd(e))return xT(this.b,Q7)&&(this.b=Zg(this.b,1)),!0;if(this.d=null,!this.c.sd(new U3t(this,this.e)))return!1}},u.a=0,u.b=0;var CPe=A(Le,"CollectSpliterators/1FlatMapSpliterator",1159);T(1160,1,{},U3t),u.td=function(e){wne(this.a,this.b,e)};var APe=A(Le,"CollectSpliterators/1FlatMapSpliterator/lambda$0$Type",1160);T(1161,1,{},z3t),u.td=function(e){dee(this.b,this.a,e)};var kPe=A(Le,"CollectSpliterators/1FlatMapSpliterator/lambda$1$Type",1161),a1t;T(844,1,rh,Cj),u.Fb=function(e){return this===e},u.Kb=function(e){return zt(e)===zt(this.a)?bOt:e};var LPe=A(Le,"Collections2/1",844);T(220,1,uZ),u.vd=function(e){return this.ud(a(e,220))},u.ud=function(e){var n;return e==(co(),wK)?1:e==(Zr(),bK)?-1:(n=(SD(),yC(this.a,e.a)),n!=0?n:ct(this,467)==ct(e,467)?0:ct(this,467)?1:-1)},u.yd=function(){return this.a},u.Fb=function(e){return dut(this,e)};var PPe=A(Le,"Cut",220);T(1508,220,uZ,Qxt),u.ud=function(e){return e==this?0:1},u.wd=function(e){throw K(new p9)},u.xd=function(e){e.a+="+\u221E)"},u.yd=function(){throw K(new yc(yOt))},u.zd=function(e){return!1},u.Ib=function(){return"+\u221E"};var bK,IPe=A(Le,"Cut/AboveAll",1508);T(467,220,{220:1,467:1,3:1,34:1},vSt),u.wd=function(e){Fa((e.a+="(",e),this.a)},u.xd=function(e){E1(Fa(e,this.a),93)},u.Hb=function(){return~Yr(this.a)},u.zd=function(e){return SD(),yC(this.a,e)<0},u.Ib=function(){return"/"+this.a+"\\"};var RPe=A(Le,"Cut/AboveValue",467);T(1507,220,uZ,t3t),u.ud=function(e){return e==this?0:-1},u.wd=function(e){e.a+="(-\u221E"},u.xd=function(e){throw K(new p9)},u.yd=function(){throw K(new yc(yOt))},u.zd=function(e){return!0},u.Ib=function(){return"-\u221E"};var wK,DPe=A(Le,"Cut/BelowAll",1507);T(1509,220,uZ,_St),u.wd=function(e){Fa((e.a+="[",e),this.a)},u.xd=function(e){E1(Fa(e,this.a),41)},u.Hb=function(){return Yr(this.a)},u.zd=function(e){return SD(),yC(this.a,e)<=0},u.Ib=function(){return"\\"+this.a+"/"};var NPe=A(Le,"Cut/BelowValue",1509);T(482,1,wd),u.sc=function(e){vo(this,e)},u.Ib=function(){return rce(a(Bot(this,"use Optional.orNull() instead of Optional.or(null)"),20).tc())};var OPe=A(Le,"FluentIterable",482);T(325,482,wd,m2),u.tc=function(){return Rn(this)};var BPe=A(Le,"FluentIterable/2",325);T(1670,25,xOt),u.tc=function(){return this.Ad()},u.nc=function(e){throw K(new Oi)},u.oc=function(e){throw K(new Oi)},u.Pb=function(){throw K(new Oi)},u.pc=function(e){return e!=null&&O2(this,e,!1)},u.vc=function(e){throw K(new Oi)};var FPe=A(Le,"ImmutableCollection",1670);T(912,1670,xOt,Aj),u.tc=function(){return R2((we(),Lv(),$_))},u.pc=function(e){return!1},u.qc=function(e){return N1(this.a,e)},u.Wb=function(){return!0},u.Ad=function(){return R2((we(),Lv(),$_))},u._b=function(){return 0},u.yc=function(){return g$(this.a)},u.zc=function(e){return aP(this.a,e)},u.Ib=function(){return Gp(this.a)};var UPe=A(Le,"ForwardingImmutableCollection",912);T(193,1670,lZ),u.tc=function(){return this.Ad()},u.ed=function(){return new S$(this,this._b(),0)},u.fd=function(e){return new S$(this,this._b(),e)},u.jd=function(e){R1(this,e)},u.wc=function(){return new Ei(this,16)},u.kd=function(e,n){return this.Bd(e,n)},u.bd=function(e,n){throw K(new Oi)},u.Fb=function(e){return Tme(this,e)},u.Hb=function(){return ble(this)},u.dd=function(e){return e==null?-1:Hde(this,e)},u.Ad=function(){return new S$(this,this._b(),0)},u.gd=function(e){throw K(new Oi)},u.hd=function(e,n){throw K(new Oi)},u.Bd=function(e,n){var i;return eq((i=new Z3t(this),new T1(i,e,n)))};var u1t,zPe=A(Le,"ImmutableList",193);T(1675,193,lZ),u.tc=function(){return R2(this.Cd().tc())},u.kd=function(e,n){return eq(this.Cd().kd(e,n))},u.pc=function(e){return e!=null&&this.Cd().pc(e)},u.qc=function(e){return this.Cd().qc(e)},u.Fb=function(e){return Fi(this.Cd(),e)},u.cd=function(e){return this.Cd().cd(e)},u.Hb=function(){return Yr(this.Cd())},u.dd=function(e){return this.Cd().dd(e)},u.Wb=function(){return this.Cd().Wb()},u.Ad=function(){return R2(this.Cd().tc())},u._b=function(){return this.Cd()._b()},u.Bd=function(e,n){return eq(this.Cd().kd(e,n))},u.yc=function(){return this.Cd().zc(dt(un,te,1,this.Cd()._b(),5,1))},u.zc=function(e){return this.Cd().zc(e)},u.Ib=function(){return Yc(this.Cd())};var jPe=A(Le,"ForwardingImmutableList",1675);T(1671,1670,BP),u.tc=function(){return this.Ad()},u.wc=function(){return new Ei(this,1)},u.Fb=function(e){return t9t(this,e)},u.Hb=function(){return TPt(this)};var HPe=A(Le,"ImmutableSet",1671);T(550,1671,BP),u.tc=function(){return this.Ad()},u.pc=function(e){return e!=null&&MT(this.b,e)},u.qc=function(e){return Zit(this.b,e)},u.Hb=function(){return Yr(this.b.b)},u.Wb=function(){return this.b.b.Wb()},u.Ad=function(){return R2(new Rg(this.b.b.tc()))},u._b=function(){return this.b.b._b()},u.yc=function(){return this.b.b.yc()},u.zc=function(e){return Y3t(this.b,e)},u.Ib=function(){return Yc(this.b.b)};var GPe=A(Le,"ForwardingImmutableSet",550);T(1664,1663,MOt),u.Ac=function(){return we(),new Z5(this.a)},u.wc=function(){return new N5(this)};var WPe=A(Le,"ForwardingSortedSet",1664);T(481,632,Z7,fD),u.ec=function(e){return new vTt(this,e,this)},u.Zb=function(e,n){return $C(this,e,n,!1)};var $Pe=A(Le,"HashBiMap",481);T(892,633,Z7,vTt),u.dc=function(){return new pSt(this,this.a.b.Tb().tc())};var VPe=A(Le,"HashBiMap/1",892);T(479,1,Cs),u.gc=function(e){ks(this,e)},u.hc=function(){return this.b.hc()},u.ic=function(){return gEt(this)},u.jc=function(){this.b.jc()};var qPe=A(Le,"TransformedIterator",479);T(893,479,Cs,pSt),u.Ed=function(e){return new GCt(this,a(e,38))},u.Dd=function(t){return this.Ed(t)};var XPe=A(Le,"HashBiMap/1/1",893);T(894,392,aZ,GCt),u.kc=function(){return this.c},u.lc=function(){return this.a.a.b.Vb(this.c)},u.mc=function(e){var n;return x1(Bit($D(this.a.a),this),Jht),n=this.a.a.b.Vb(this.c),zt(e)===zt(n)||e!=null&&Fi(e,n)?e:($C(this.a.a,this.c,e,!0),n)};var ZPe=A(Le,"HashBiMap/1/1/1",894);T(298,557,OP,Iv),u.md=function(){return new S9(XV(this.a))},u.a=2;var YPe=A(Le,"HashMultimap",298);T(372,392,{392:1,372:1,3:1,38:1},I5),u.kc=function(){return this.g},u.lc=function(){return this.i},u.mc=function(e){throw K(new Oi)};var KPe=A(Le,"ImmutableEntry",372);T(903,550,BP,kxt);var JPe=A(Le,"ImmutableEnumSet",903);T(544,847,oZ,S$);var QPe=A(Le,"ImmutableList/1",544);T(1561,550,EOt),u.tc=function(){return R2(new Rg(this.b.b.tc()))},u.wc=function(){return new N5(this)},u.pc=function(e){try{return e!=null&&MT(this.a,e)}catch(n){if(n=vr(n),ct(n,177))return!1;throw K(n)}},u.qc=function(e){var n,i;for(i=e.tc();i.hc();)if(n=i.ic(),n==null)return!1;try{return Zit(this.a,e)}catch(r){if(r=vr(r),ct(r,177))return!1;throw K(r)}},u.Ad=function(){return R2(new Rg(this.b.b.tc()))},u.yc=function(){return eLt(this,dt(un,te,1,this.b.b._b(),5,1))},u.zc=function(e){return JN(this,e)};var wzt,l1t,t6e=A(Le,"ImmutableSortedSet",1561);T(904,482,wd,IEt),u.tc=function(){return Qrt(this.a)},u.Ib=function(){return Gp(this.a)+" (cycled)"};var e6e=A(Le,"Iterables/1",904);T(200,1,rh,X),u.Kb=function(e){return a(e,20).tc()},u.Fb=function(e){return this===e};var n6e=A(Le,"Iterables/12",200);T(905,482,wd,cCt),u.sc=function(e){si(e),this.b.sc(new j3t(this.a,e))},u.tc=function(){return FT(this)};var i6e=A(Le,"Iterables/4",905);T(906,1,{},j3t),u.td=function(e){hte(this.b,this.a,e)};var r6e=A(Le,"Iterables/4/lambda$0$Type",906);T(907,482,wd,aCt),u.sc=function(e){si(e),this.a.sc(new H3t(e,this.b))},u.tc=function(){return id(this)};var s6e=A(Le,"Iterables/5",907);T(908,1,{},H3t),u.td=function(e){this.a.td(this.b.Kb(e))};var o6e=A(Le,"Iterables/5/lambda$0$Type",908),vzt,h1t;T(945,1665,oZ,xt),u.hc=function(){return!1},u.Cc=function(){return!1},u.ic=function(){throw K(new J)},u.Dc=function(){return 0},u.Ec=function(){throw K(new J)},u.Fc=function(){return-1};var c6e=A(Le,"Iterators/1",945);T(555,257,J7,l5),u.hc=function(){return!this.a},u.ic=function(){if(this.a)throw K(new J);return this.a=!0,this.b},u.a=!1;var a6e=A(Le,"Iterators/11",555);T(946,1,Cs,Bt),u.gc=function(e){ks(this,e)},u.hc=function(){return!1},u.ic=function(){throw K(new J)},u.jc=function(){x1(!1,cw)};var u6e=A(Le,"Iterators/2",946);T(947,257,J7,u5),u.hc=function(){return this.a.hc()},u.ic=function(){return this.a.ic()};var l6e=A(Le,"Iterators/3",947);T(948,1,Cs,CTt),u.gc=function(e){ks(this,e)},u.hc=function(){return this.a.hc()||this.b.tc().hc()},u.ic=function(){return hat(this)},u.jc=function(){this.a.jc()};var h6e=A(Le,"Iterators/4",948);T(950,949,J7,G3t);var f6e=A(Le,"Iterators/6",950);T(951,479,Cs,gSt),u.Dd=function(e){return this.a.Kb(e)};var d6e=A(Le,"Iterators/7",951);T(647,1,Cs),u.gc=function(e){ks(this,e)},u.hc=function(){return Jn(this)},u.ic=function(){return In(this)},u.jc=function(){x1(!!this.c,cw),this.c.jc(),this.c=null};var p6e=A(Le,"MultitransformedIterator",647);T(182,647,{182:1,43:1},$d),u.Fd=function(e){return a(e,43)};var g6e=A(Le,"Iterators/ConcatenatedIterator",182);T(648,647,Cs,Mit),u.Fd=function(e){return Que(a(e,43))};var m6e=A(Le,"Iterators/ConcatenatedIterator/1",648);T(1540,557,OP,SIt),u.Pb=function(){oat(this),q3(this.a,this.a)},u.md=function(){return new qrt(this.b)},u.Pc=function(e){return new E6t(this,e,this.b)},u.Kc=function(){return new Wrt(this)},u.Lc=function(){var e;return new Ei((e=this.g,a(e||(this.g=new S8(this)),19)),17)},u.Xb=function(){var e;return e=this.i,e||(this.i=ct(this.c,122)?new Pv(this,a(this.c,122)):ct(this.c,115)?new l2(this,a(this.c,115)):new lM(this,this.c))},u.Rc=function(){return ts(),ZT(new Wrt(this),(Fv(),f6))},u.Sc=function(){var e;return l$(new Ei((e=this.g,a(e||(this.g=new S8(this)),19)),17),new Dt)},u.b=2;var b6e=A(Le,"LinkedHashMultimap",1540);T(1543,1,ys,Dt),u.Kb=function(e){return a(e,38).lc()};var w6e=A(Le,"LinkedHashMultimap/0methodref$getValue$Type",1543);T(728,1,Cs,Wrt),u.gc=function(e){ks(this,e)},u.ic=function(){return bue(this)},u.hc=function(){return this.a!=this.b.a},u.jc=function(){x1(!!this.c,cw),qAt(this.b,this.c.g,this.c.i),this.c=null};var v6e=A(Le,"LinkedHashMultimap/1",728);T(310,372,{392:1,372:1,310:1,1706:1,3:1,38:1},Rot),u.Gd=function(){return this.f},u.Hd=function(e){this.c=e},u.Id=function(e){this.f=e},u.d=0;var _zt=A(Le,"LinkedHashMultimap/ValueEntry",310);T(1541,1660,{1706:1,20:1,25:1,13:1,19:1},E6t),u.nc=function(e){var n,i,r,c,l;for(l=tft*Pot((e==null?0:Yr(e))*eft,15),n=l&this.b.length-1,c=this.b[n],i=c;i;i=i.a)if(i.d==l&&Rp(i.i,e))return!1;return r=new Rot(this.c,e,l,c),s3t(this.d,r),r.f=this,this.d=r,q3(this.g.a.b,r),q3(r,this.g.a),this.b[n]=r,++this.f,++this.e,Kpe(this),!0},u.Pb=function(){var e,n;for(JG(this.b,null),this.f=0,e=this.a;e!=this;e=e.Gd())n=a(e,310),q3(n.b,n.e);this.a=this,this.d=this,++this.e},u.pc=function(e){var n,i;for(i=tft*Pot((e==null?0:Yr(e))*eft,15),n=this.b[i&this.b.length-1];n;n=n.a)if(n.d==i&&Rp(n.i,e))return!0;return!1},u.sc=function(e){var n;for(si(e),n=this.a;n!=this;n=n.Gd())e.td(a(n,310).i)},u.Gd=function(){return this.a},u.tc=function(){return new i4t(this)},u.vc=function(e){return M9t(this,e)},u.Hd=function(e){this.d=e},u.Id=function(e){this.a=e},u._b=function(){return this.f},u.e=0,u.f=0;var _6e=A(Le,"LinkedHashMultimap/ValueSet",1541);T(1542,1,Cs,i4t),u.gc=function(e){ks(this,e)},u.hc=function(){return Yst(this),this.b!=this.c},u.ic=function(){var e,n;if(Yst(this),this.b==this.c)throw K(new J);return e=a(this.b,310),n=e.i,this.d=e,this.b=e.f,n},u.jc=function(){Yst(this),x1(!!this.d,cw),M9t(this.c,this.d.i),this.a=this.c.e,this.d=null},u.a=0;var y6e=A(Le,"LinkedHashMultimap/ValueSet/1",1542);T(689,1677,cZ,Jit),u.Hc=function(){return fm(this)},u.Fb=function(e){return nq(this,e)},u.Mc=function(e){return new qG(this,e)},u.Nc=function(e){return tV(this,e)},u.Pb=function(){M$(this)},u.Qb=function(e){return Fit(this,e)},u.Ic=function(){return new Kit(this)},u.Jc=function(){return new Tj(this)},u.Kc=function(){throw K(new Q$("should never be called"))},u.Tc=function(e){return new qG(this,e)},u.Wb=function(){return!this.a},u.Uc=function(e){return tV(this,e)},u._b=function(){return this.d},u.c=0,u.d=0;var x6e=A(Le,"LinkedListMultimap",689);T(41,25,Z2),u.jd=function(e){R1(this,e)},u.wc=function(){return new Ei(this,16)},u.bd=function(e,n){throw K(new Tp("Add not supported on this list"))},u.nc=function(e){return this.bd(this._b(),e),!0},u.Pb=function(){this.Jd(0,this._b())},u.Fb=function(e){return Olt(this,e)},u.Hb=function(){return Lat(this)},u.dd=function(e){return $Lt(this,e)},u.tc=function(){return new j3(this)},u.ed=function(){return this.fd(0)},u.fd=function(e){return new Gs(this,e)},u.gd=function(e){throw K(new Tp("Remove not supported on this list"))},u.Jd=function(e,n){var i,r;for(r=this.fd(e),i=e;i0||this.c.hc()},u.ic=function(){if(!(this.d>0||this.c.hc()))throw K(new J);return this.d==0&&(this.b=a(this.c.ic(),312),this.f=this.d=a(this.b.a.lc(),13)._b()),--this.d,this.a=!0,this.b.a.kc()},u.jc=function(){x1(this.a,cw),this.f==1?this.c.jc():Alt(this.e,this.b.a.kc(),1)>0,--this.f,this.a=!1},u.a=!1,u.d=0,u.f=0;var rIe=A(Le,"Multisets/MultisetIteratorImpl",981);T(667,1,ys,se),u.Kb=function(e){return new Ei(ele(a(a(e,300).a.lc(),13)._b(),a(e,300).a.kc()),16)};var sIe=A(Le,"Multisets/lambda$0$Type",667);T(1684,1,jr),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)};var oIe=A(Le,"Ordering",1684);T(1565,1684,fZ,ot),u.Ld=function(e,n){return Kee(a(e,34),a(n,34))},u.Ib=function(){return"Ordering.natural()"};var xzt,cIe=A(Le,"NaturalOrdering",1565);T(464,1,{138:1,464:1,3:1,56:1},xut),u.Mb=function(e){return Rre(this,a(e,34))},u.Nb=function(e){return this.Mb(e)},u.Fb=function(e){var n;return ct(e,464)?(n=a(e,464),dut(this.a,n.a)&&dut(this.b,n.b)):!1},u.Hb=function(){return Yr(this.a)*31+Yr(this.b)},u.Ib=function(){return nkt(this.a,this.b)};var aIe=A(Le,"Range",464);T(485,1675,lZ,oN),u.Cd=function(){return this.a};var uIe=A(Le,"RegularImmutableList",485);T(554,550,BP,KG);var I4,lIe=A(Le,"RegularImmutableSet",554);T(729,1561,EOt,Dot);var hIe=A(Le,"RegularImmutableSortedSet",729);T(543,1664,{543:1,3:1,20:1,13:1,196:1,19:1,60:1},sMt);var fIe=A(Le,"Sets/UnmodifiableNavigableSet",543);T(1165,1675,lZ,nTt),u.Cd=function(){return this.a};var dIe=A(Le,"SingletonImmutableList",1165);T(326,1671,BP,s2),u.tc=function(){return Ao(),new l5(this.a)},u.pc=function(e){return Fi(this.a,e)},u.Ad=function(){return Ao(),new l5(this.a)},u._b=function(){return 1};var pIe=A(Le,"SingletonImmutableSet",326);T(1415,1414,OP,B4t),u.Hc=function(){var e;return e=this.f,a(a(e||(this.f=ct(this.c,122)?new qT(this,a(this.c,122)):ct(this.c,115)?new hM(this,a(this.c,115)):new tM(this,this.c)),115),122)},u.Xb=function(){var e;return e=this.i,a(a(e||(this.i=ct(this.c,122)?new Pv(this,a(this.c,122)):ct(this.c,115)?new l2(this,a(this.c,115)):new lM(this,this.c)),60),196)},u.Pc=function(e){return e==null&&this.a.Ld(null,null),new Ob(this.b)};var gIe=A(Le,"TreeMultimap",1415);T(78,1,{3:1,78:1}),u.Nd=function(e){return new y.Error(e)},u.Od=function(){return this.g},u.Pd=function(){var e,n,i;i=this.g==null?null:this.g.replace(new y.RegExp(` -`,"g")," "),n=(e=Ng(this.ql),i==null?e:e+": "+i),ane(this,cce(this.Nd(n))),Ki(this)},u.Ib=function(){return F4t(this,this.Od())},u.e=TOt,u.i=!1,u.n=!0;var Mzt=A(bc,"Throwable",78);T(104,78,{3:1,104:1,78:1});var mIe=A(bc,"Exception",104);T(54,104,rp,Ep,sc);var bIe=A(bc,"RuntimeException",54);T(539,54,rp);var wIe=A(bc,"JsException",539);T(760,539,rp);var vIe=A(FP,"JavaScriptExceptionBase",760);T(435,760,{435:1,3:1,104:1,54:1,78:1},dIt),u.Od=function(){return g1e(this),this.c},u.Qd=function(){return zt(this.b)===zt(f1t)?null:this.b};var f1t,_Ie=A(rft,"JavaScriptException",435),Ezt=A(rft,"JavaScriptObject$",0),_K;T(1640,1,{});var yIe=A(rft,"Scheduler",1640),qO=0,Szt=0,XO=-1;T(787,1640,{},et);var d1t,xIe=A(FP,"SchedulerImpl",787),yK;T(1653,1,{});var MIe=A(FP,"StackTraceCreator/Collector",1653);T(761,1653,{},Q),u.Rd=function(e){var n={},i,r=[];e[sft]=r;for(var c=arguments.callee.caller;c;){var l=(xM(),c.name||(c.name=zue(c.toString())));r.push(l);var f=":"+l,g=n[f];if(g){var b,v;for(b=0,v=g.length;b=0?"+":"")+(i/60|0),n=(i<0?-i:i)%60<10?"0"+(i<0?-i:i)%60:""+(i<0?-i:i)%60,(y8t(),Ozt)[this.q.getDay()]+" "+Bzt[this.q.getMonth()]+" "+SW(this.q.getDate())+" "+SW(this.q.getHours())+":"+SW(this.q.getMinutes())+":"+SW(this.q.getSeconds())+" GMT"+e+n+" "+this.q.getFullYear()};var ZO=A(ii,"Date",181);T(1622,181,POt,qRt),u.a=!1,u.b=0,u.c=0,u.d=0,u.e=0,u.f=0,u.g=!1,u.i=0,u.j=0,u.k=0,u.n=0,u.o=0,u.p=0;var NIe=A("com.google.gwt.i18n.shared.impl","DateRecord",1622);T(1659,1,{}),u.Vd=function(){return null},u.Wd=function(){return null},u.Xd=function(){return null},u.Yd=function(){return null},u.Zd=function(){return null};var OIe=A(J2,"JSONValue",1659);T(209,1659,{209:1},Ig,C8),u.Fb=function(e){return ct(e,209)?ect(this.a,a(e,209).a):!1},u.Ud=function(){return iit},u.Hb=function(){return Wot(this.a)},u.Vd=function(){return this},u.Ib=function(){var e,n,i;for(i=new ll("["),n=0,e=this.a.length;n0&&(i.a+=","),Fa(i,I2(this,n));return i.a+="]",i.a};var BIe=A(J2,"JSONArray",209);T(443,1659,{443:1},A8),u.Ud=function(){return rit},u.Wd=function(){return this},u.Ib=function(){return me(),""+this.a},u.a=!1;var Tzt,Czt,FIe=A(J2,"JSONBoolean",443);T(877,54,rp,Lxt);var UIe=A(J2,"JSONException",877);T(913,1659,{},Fn),u.Ud=function(){return h9},u.Ib=function(){return tu};var Azt,zIe=A(J2,"JSONNull",913);T(259,1659,{259:1},h5),u.Fb=function(e){return ct(e,259)?this.a==a(e,259).a:!1},u.Ud=function(){return EG},u.Hb=function(){return Tr(lt(this.a))},u.Xd=function(){return this},u.Ib=function(){return this.a+""},u.a=0;var jIe=A(J2,"JSONNumber",259);T(191,1659,{191:1},gT,tT),u.Fb=function(e){return ct(e,191)?ect(this.a,a(e,191).a):!1},u.Ud=function(){return sit},u.Hb=function(){return Wot(this.a)},u.Yd=function(){return this},u.Ib=function(){var e,n,i,r,c,l;for(l=new ll("{"),e=!0,c=dat(this,dt(At,wt,2,0,6,1)),i=0,r=c.length;i=0?":"+this.c:"")+")"},u.c=0;var T1t=A(bc,"StackTraceElement",287);mzt={3:1,476:1,34:1,2:1};var At=A(bc,ift,2);T(100,381,{476:1},Sp,mT,ul);var aRe=A(bc,"StringBuffer",100);T(98,381,{476:1},im,Db,ll);var uRe=A(bc,"StringBuilder",98);T(763,79,DZ,Rxt);var lRe=A(bc,"StringIndexOutOfBoundsException",763);T(1722,1,{});var C1t,A1t;T(46,54,{3:1,104:1,54:1,78:1,46:1},Oi,Tp);var hRe=A(bc,"UnsupportedOperationException",46);T(216,210,{3:1,34:1,210:1,216:1},kL,Sit),u.vd=function(e){return BNt(this,a(e,216))},u.$d=function(){return ew(a7t(this))},u.Fb=function(e){var n;return this===e?!0:ct(e,216)?(n=a(e,216),this.e==n.e&&BNt(this,n)==0):!1},u.Hb=function(){var e;return this.b!=0?this.b:this.a<54?(e=Ka(this.f),this.b=or(ns(e,-1)),this.b=33*this.b+or(ns(M1(e,32),-1)),this.b=17*this.b+Tr(this.e),this.b):(this.b=17*D6t(this.c)+Tr(this.e),this.b)},u.Ib=function(){return a7t(this)},u.a=0,u.b=0,u.d=0,u.e=0,u.f=0;var Izt,m0,k1t,L1t,P1t,I1t,R1t,D1t,EK=A("java.math","BigDecimal",216);T(89,210,{3:1,34:1,210:1,89:1},yut,Fp,Wv,$ut,XIt,_1),u.vd=function(e){return RIt(this,a(e,89))},u.$d=function(){return ew(rZ(this,0))},u.Fb=function(e){return $at(this,e)},u.Hb=function(){return D6t(this)},u.Ib=function(){return rZ(this,0)},u.b=-2,u.c=0,u.d=0,u.e=0;var SK,YO,N1t,TK,KO,EE,W_=A("java.math","BigInteger",89),Rzt,Dzt,lx,N4;T(441,1666,sE),u.Pb=function(){uu(this)},u.Qb=function(e){return lm(this,e)},u.Rb=function(e){return x6t(this,e,this.e)||x6t(this,e,this.d)},u.Tb=function(){return new xp(this)},u.Vb=function(e){return zi(this,e)},u.Zb=function(e,n){return wr(this,e,n)},u.$b=function(e){return AM(this,e)},u._b=function(){return J3(this)};var fRe=A(ii,"AbstractHashMap",441);T(242,bd,vl,xp),u.Pb=function(){this.a.Pb()},u.pc=function(e){return WAt(this,e)},u.tc=function(){return new Vg(this.a)},u.vc=function(e){var n;return WAt(this,e)?(n=a(e,38).kc(),this.a.$b(n),!0):!1},u._b=function(){return this.a._b()};var dRe=A(ii,"AbstractHashMap/EntrySet",242);T(243,1,Cs,Vg),u.gc=function(e){ks(this,e)},u.ic=function(){return xm(this)},u.hc=function(){return this.b},u.jc=function(){C5t(this)},u.b=!1;var pRe=A(ii,"AbstractHashMap/EntrySetIterator",243);T(433,1,Cs,j3),u.gc=function(e){ks(this,e)},u.hc=function(){return L9(this)},u.ic=function(){return g4t(this)},u.jc=function(){Th(this)},u.b=0,u.c=-1;var gRe=A(ii,"AbstractList/IteratorImpl",433);T(94,433,kf,Gs),u.jc=function(){Th(this)},u.Bc=function(e){cd(this,e)},u.Cc=function(){return this.b>0},u.Dc=function(){return this.b},u.Ec=function(){return Hn(this.b>0),this.a.cd(this.c=--this.b)},u.Fc=function(){return this.b-1},u.Gc=function(e){zv(this.c!=-1),this.a.hd(this.c,e)};var mRe=A(ii,"AbstractList/ListIteratorImpl",94);T(227,41,Z2,T1),u.bd=function(e,n){Yv(e,this.b),this.c.bd(this.a+e,n),++this.b},u.cd=function(e){return mi(e,this.b),this.c.cd(this.a+e)},u.gd=function(e){var n;return mi(e,this.b),n=this.c.gd(this.a+e),--this.b,n},u.hd=function(e,n){return mi(e,this.b),this.c.hd(this.a+e,n)},u._b=function(){return this.b},u.a=0,u.b=0;var bRe=A(ii,"AbstractList/SubList",227);T(352,bd,vl,xv),u.Pb=function(){this.a.Pb()},u.pc=function(e){return this.a.Qb(e)},u.tc=function(){var e;return e=this.a.Tb().tc(),new f5(e)},u.vc=function(e){return this.a.Qb(e)?(this.a.$b(e),!0):!1},u._b=function(){return this.a._b()};var wRe=A(ii,"AbstractMap/1",352);T(542,1,Cs,f5),u.gc=function(e){ks(this,e)},u.hc=function(){return this.a.hc()},u.ic=function(){var e;return e=a(this.a.ic(),38),e.kc()},u.jc=function(){this.a.jc()};var vRe=A(ii,"AbstractMap/1/1",542);T(223,25,L_,vf),u.Pb=function(){this.a.Pb()},u.pc=function(e){return this.a.Rb(e)},u.tc=function(){var e;return e=this.a.Tb().tc(),new Q0(e)},u._b=function(){return this.a._b()};var _Re=A(ii,"AbstractMap/2",223);T(321,1,Cs,Q0),u.gc=function(e){ks(this,e)},u.hc=function(){return this.a.hc()},u.ic=function(){var e;return e=a(this.a.ic(),38),e.lc()},u.jc=function(){this.a.jc()};var yRe=A(ii,"AbstractMap/2/1",321);T(440,1,{440:1,38:1}),u.Fb=function(e){var n;return ct(e,38)?(n=a(e,38),au(this.d,n.kc())&&au(this.e,n.lc())):!1},u.kc=function(){return this.d},u.lc=function(){return this.e},u.Hb=function(){return eD(this.d)^eD(this.e)},u.mc=function(e){return ust(this,e)},u.Ib=function(){return this.d+"="+this.e};var xRe=A(ii,"AbstractMap/AbstractEntry",440);T(351,440,{440:1,351:1,38:1},R9);var MRe=A(ii,"AbstractMap/SimpleEntry",351);T(1672,1,Y7),u.Fb=function(e){var n;return ct(e,38)?(n=a(e,38),au(this.kc(),n.kc())&&au(this.lc(),n.lc())):!1},u.Hb=function(){return eD(this.kc())^eD(this.lc())},u.Ib=function(){return this.kc()+"="+this.lc()};var ERe=A(ii,_Ot,1672);T(1685,1666,wOt),u.Wc=function(e){return Gkt(this,e)},u.Qb=function(e){return QG(this,e)},u.Tb=function(){return new B8(this)},u.Vb=function(e){return Ua(Rat(this,e))},u.Xb=function(){return new Mv(this)};var SRe=A(ii,"AbstractNavigableMap",1685);T(668,bd,vl,B8),u.pc=function(e){return ct(e,38)&&Gkt(this.b,a(e,38))},u.tc=function(){return new sL(this.b)},u.vc=function(e){var n;return ct(e,38)?(n=a(e,38),A5t(this.b,n)):!1},u._b=function(){return this.b.c};var TRe=A(ii,"AbstractNavigableMap/EntrySet",668);T(488,bd,Qht,Mv),u.wc=function(){return new N5(this)},u.Pb=function(){C5(this.a)},u.pc=function(e){return QG(this.a,e)},u.tc=function(){var e;return e=new sL(new Y5(this.a).b),new eT(e)},u.vc=function(e){return QG(this.a,e)?(nC(this.a,e),!0):!1},u._b=function(){return this.a.c};var CRe=A(ii,"AbstractNavigableMap/NavigableKeySet",488);T(489,1,Cs,eT),u.gc=function(e){ks(this,e)},u.hc=function(){return L9(this.a.a)},u.ic=function(){var e;return e=FW(this.a),e.kc()},u.jc=function(){BTt(this.a)};var ARe=A(ii,"AbstractNavigableMap/NavigableKeySet/1",489);T(1693,25,L_),u.nc=function(e){return kM(XM(this,e)),!0},u.oc=function(e){return En(e),vD(e!=this,"Can't add a queue to itself"),yo(this,e)},u.Pb=function(){for(;SV(this)!=null;);};var kRe=A(ii,"AbstractQueue",1693);T(407,25,{4:1,20:1,25:1,13:1},W3,HCt),u.nc=function(e){return cct(this,e),!0},u.Pb=function(){mct(this)},u.pc=function(e){return KPt(new iC(this),e)},u.Wb=function(){return Cit(this)},u.tc=function(){return new iC(this)},u.vc=function(e){return yoe(new iC(this),e)},u._b=function(){return this.c-this.b&this.a.length-1},u.wc=function(){return new Ei(this,272)},u.zc=function(e){var n,i;return i=this.c-this.b&this.a.length-1,e.lengthi&&Vr(e,i,null),e},u.b=0,u.c=0;var LRe=A(ii,"ArrayDeque",407);T(408,1,Cs,iC),u.gc=function(e){ks(this,e)},u.hc=function(){return this.a!=this.b},u.ic=function(){return GN(this)},u.jc=function(){ZLt(this)},u.a=0,u.b=0,u.c=-1;var PRe=A(ii,"ArrayDeque/IteratorImpl",408);T(12,41,DOt,Nt,Vu,Eh),u.bd=function(e,n){hm(this,e,n)},u.nc=function(e){return Ut(this,e)},u.oc=function(e){return Or(this,e)},u.Pb=function(){this.c=dt(un,te,1,0,5,1)},u.pc=function(e){return nc(this,e,0)!=-1},u.sc=function(e){pd(this,e)},u.cd=function(e){return Ee(this,e)},u.dd=function(e){return nc(this,e,0)},u.Wb=function(){return this.c.length==0},u.tc=function(){return new H(this)},u.gd=function(e){return ym(this,e)},u.vc=function(e){return Lc(this,e)},u.Jd=function(e,n){vAt(this,e,n)},u.hd=function(e,n){return Kl(this,e,n)},u._b=function(){return this.c.length},u.jd=function(e){gc(this,e)},u.yc=function(){return jW(this)},u.zc=function(e){return xo(this,e)};var x3e=A(ii,"ArrayList",12);T(7,1,Cs,H),u.gc=function(e){ks(this,e)},u.hc=function(){return Qo(this)},u.ic=function(){return G(this)},u.jc=function(){QT(this)},u.a=0,u.b=-1;var IRe=A(ii,"ArrayList/1",7);T(155,41,NOt,zu),u.pc=function(e){return $Lt(this,e)!=-1},u.sc=function(e){var n,i,r,c;for(En(e),i=this.a,r=0,c=i.length;r=0},u.qc=function(e){return N1(this.b,e)},u.tc=function(){return new Rg(_M(this.b).b.tc())},u.vc=function(e){return uPt(this,e)},u._b=function(){return this.b.c.length},u.wc=function(){return new Ei(this,256)},u.yc=function(){return jW(this.b)},u.zc=function(e){return xo(this.b,e)};var M8e=A(ii,"PriorityQueue",453);T(214,1,{214:1},Mq,cN),u.a=0,u.b=0;var j1t,H1t,T3e=0,E8e=A(ii,"Random",214);T(39,1,Wp,Ei,y2,E5t),u.qd=function(){return this.a},u.rd=function(){return dot(this),this.c},u.gc=function(e){dot(this),this.d.gc(e)},u.sd=function(e){return Xct(this,e)},u.a=0,u.c=0;var S8e=A(ii,"Spliterators/IteratorSpliterator",39);T(382,39,Wp,N5);var T8e=A(ii,"SortedSet/1",382);T(625,1,{},F8),u.ie=function(e){this.a.td(e)};var C8e=A(ii,"Spliterator/OfDouble/0methodref$accept$Type",625);T(626,1,{},U8),u.ie=function(e){this.a.td(e)};var A8e=A(ii,"Spliterator/OfDouble/1methodref$accept$Type",626);T(642,1,Wp),u.gc=function(e){A3t(this,e)},u.qd=function(){return this.d},u.rd=function(){return this.e},u.d=0,u.e=0;var k8e=A(ii,"Spliterators/BaseSpliterator",642);T(929,642,Wp),u.gc=function(e){ct(e,273)?Ost(this,a(e,273)):Ost(this,new U8(e))},u.sd=function(e){return ct(e,273)?Hv(this,a(e,273)):Hv(this,new F8(e))};var L8e=A(ii,"Spliterators/AbstractDoubleSpliterator",929);T(446,642,Wp);var P8e=A(ii,"Spliterators/AbstractSpliterator",446);T(790,1,Wp),u.gc=function(e){A3t(this,e)},u.qd=function(){return this.b},u.rd=function(){return this.d-this.c},u.b=0,u.c=0,u.d=0;var I8e=A(ii,"Spliterators/BaseArraySpliterator",790);T(791,790,Wp,v4t),u.gc=function(e){_se(this,e)},u.sd=function(e){return Lae(this,e)};var R8e=A(ii,"Spliterators/ArraySpliterator",791);T(789,1,Cs,b3t),u.gc=function(e){ct(e,273)?Okt(this,a(e,273)):Okt(this,new iT(e))},u.ic=function(){return uN(this)},u.jc=function(){Bxt()},u.ie=function(e){this.b=e},u.hc=function(){return this.a||(this.a=Hv(this.c,this)),this.a},u.a=!1,u.b=0;var D8e=A(ii,"Spliterators/DoubleConsumerIterator",789);T(523,41,BOt,nd),u.bd=function(e,n){KT(e,this.a.c.length+1),hm(this.a,e,n)},u.nc=function(e){return Ut(this.a,e)},u.oc=function(e){return Or(this.a,e)},u.Pb=function(){this.a.c=dt(un,te,1,0,5,1)},u.pc=function(e){return nc(this.a,e,0)!=-1},u.qc=function(e){return N1(this.a,e)},u.sc=function(e){pd(this.a,e)},u.cd=function(e){return KT(e,this.a.c.length),Ee(this.a,e)},u.dd=function(e){return nc(this.a,e,0)},u.Wb=function(){return this.a.c.length==0},u.tc=function(){return new H(this.a)},u.gd=function(e){return KT(e,this.a.c.length),ym(this.a,e)},u.Jd=function(e,n){vAt(this.a,e,n)},u.hd=function(e,n){return KT(e,this.a.c.length),Kl(this.a,e,n)},u._b=function(){return this.a.c.length},u.jd=function(e){gc(this.a,e)},u.kd=function(e,n){return new T1(this.a,e,n)},u.yc=function(){return jW(this.a)},u.zc=function(e){return xo(this.a,e)},u.Ib=function(){return Gp(this.a)};var N8e=A(ii,"Vector",523);T(596,523,BOt,LG);var O8e=A(ii,"Stack",596);T(254,1,{},_m),u.Ib=function(){return this.a?this.e.length==0?this.a.a:this.a.a+(""+this.e):this.c};var B8e=A(ii,"StringJoiner",254);T(487,1685,{3:1,109:1,122:1,115:1},J3t,m$),u.Pb=function(){C5(this)},u.Tb=function(){return new Y5(this)},u.Zb=function(e,n){return zN(this,e,n)},u.$b=function(e){return nC(this,e)},u._b=function(){return this.c},u.c=0;var F8e=A(ii,"TreeMap",487);T(397,1,Cs,sL),u.gc=function(e){ks(this,e)},u.ic=function(){return FW(this)},u.hc=function(){return L9(this.a)},u.jc=function(){BTt(this)};var U8e=A(ii,"TreeMap/EntryIterator",397);T(449,668,vl,Y5),u.Pb=function(){C5(this.a)};var z8e=A(ii,"TreeMap/EntrySet",449);T(398,351,{440:1,351:1,38:1,398:1},dV),u.b=!1;var C3e=A(ii,"TreeMap/Node",398);T(560,1,{},it),u.Ib=function(){return"State: mv="+this.c+" value="+this.d+" done="+this.a+" found="+this.b},u.a=!1,u.b=!1,u.c=!1;var j8e=A(ii,"TreeMap/State",560);T(278,23,UZ,D9),u.je=function(){return!1},u.ke=function(){return!1};var CK,G1t,W1t,$1t,QO=Ri(ii,"TreeMap/SubMapType",278,ji,yce,kne);T(982,278,UZ,zEt),u.ke=function(){return!0};var H8e=Ri(ii,"TreeMap/SubMapType/1",982,QO,null,null);T(983,278,UZ,KEt),u.je=function(){return!0},u.ke=function(){return!0};var G8e=Ri(ii,"TreeMap/SubMapType/2",983,QO,null,null);T(984,278,UZ,jEt),u.je=function(){return!0};var W8e=Ri(ii,"TreeMap/SubMapType/3",984,QO,null,null),jzt;T(212,bd,{3:1,20:1,25:1,13:1,196:1,19:1,60:1,212:1},ait,Ob),u.wc=function(){return new N5(this)},u.nc=function(e){return jD(this,e)},u.Pb=function(){C5(this.a)},u.pc=function(e){return QG(this.a,e)},u.tc=function(){var e;return e=new sL(new Y5(new Mv(this.a).a).b),new eT(e)},u.vc=function(e){return Xrt(this,e)},u._b=function(){return this.a.c};var A3e=A(ii,"TreeSet",212);T(845,1,{},$j),u.le=function(e,n){return Qee(this.a,e,n)};var $8e=A(zZ,"BinaryOperator/lambda$0$Type",845);T(846,1,{},wn),u.le=function(e,n){return Lp(a(e,21).a,a(n,21).a)<=0?e:n};var V8e=A(zZ,"BinaryOperator/lambda$1$Type",846);T(843,1,ys,ut),u.Kb=function(e){return e};var q8e=A(zZ,"Function/lambda$0$Type",843);T(627,1,us,j8),u.Nb=function(e){return!this.a.Nb(e)};var X8e=A(zZ,"Predicate/lambda$0$Type",627);T(150,23,{3:1,34:1,23:1,150:1},tW);var V1t,Qh,pw,tf=Ri(Qs,"Collector/Characteristics",150,ji,Ioe,Lne),Hzt;T(684,1,{},zTt,o8t);var Z8e=A(Qs,"Collector/CollectorImpl",684);T(1053,1,ys,Vj),u.Kb=function(e){return me(),!!fct(e)};var Y8e=A(Qs,"Collectors/12methodref$test$Type",1053);T(365,1,{},ge),u.Kd=function(e,n){a(e,13).nc(n)};var K8e=A(Qs,"Collectors/20methodref$add$Type",365);T(367,1,{},Pe),u.ne=function(){return new Nt};var J8e=A(Qs,"Collectors/21methodref$ctor$Type",367);T(331,1,{},ti),u.ne=function(){return new $r};var Q8e=A(Qs,"Collectors/23methodref$ctor$Type",331);T(332,1,{},Qn),u.Kd=function(e,n){Ir(a(e,67),n)};var t9e=A(Qs,"Collectors/24methodref$add$Type",332);T(1050,1,{},Yi),u.le=function(e,n){return Q3t(a(e,15),a(n,13))};var e9e=A(Qs,"Collectors/4methodref$addAll$Type",1050);T(683,1,{},ki),u.le=function(e,n){return Jot(e,n)};var n9e=A(Qs,"Collectors/lambda$1$Type",683);T(1055,1,{},qj),u.ne=function(){return Y(Z(un,1),te,1,5,[this.a])};var i9e=A(Qs,"Collectors/lambda$10$Type",1055);T(1056,1,{},g5),u.Kd=function(e,n){fre(this.a,e)};var r9e=A(Qs,"Collectors/lambda$11$Type",1056);T(1057,1,{},G8),u.le=function(e,n){return Fre(this.a,e,n)};var s9e=A(Qs,"Collectors/lambda$12$Type",1057);T(1058,1,ys,lr),u.Kb=function(e){return e_(e)[0]};var o9e=A(Qs,"Collectors/lambda$13$Type",1058);T(366,1,{},pr),u.le=function(e,n){return a(e,13).oc(a(n,13)),a(e,13)};var c9e=A(Qs,"Collectors/lambda$21$Type",366);T(333,1,{},Kt),u.le=function(e,n){return yo(a(e,67),a(n,67)),a(e,67)};var a9e=A(Qs,"Collectors/lambda$25$Type",333);T(334,1,ys,kt),u.Kb=function(e){return a(e,67)};var u9e=A(Qs,"Collectors/lambda$26$Type",334);T(1049,1,{},Xj),u.Kd=function(e,n){Fle(this.a,e,n)};var l9e=A(Qs,"Collectors/lambda$3$Type",1049);T(1051,1,{},Ot),u.le=function(e,n){return Ele(a(e,109),a(n,109),new Yi)};var h9e=A(Qs,"Collectors/lambda$4$Type",1051);T(1052,1,ys,Zj),u.Kb=function(e){return $he(this.a,e)};var f9e=A(Qs,"Collectors/lambda$5$Type",1052);T(1054,1,{},ie),u.ne=function(){var e;return e=new vm,Am(e,(me(),me(),!1),new Nt),Am(e,!0,new Nt),e};var d9e=A(Qs,"Collectors/lambda$8$Type",1054);T(645,1,{}),u.d=!1;var p9e=A(Qs,"TerminatableStream",645);T(1416,645,{607:1,1701:1},qSt);var g9e=A(Qs,"DoubleStream/DoubleStreamSource",1416);T(1417,1,{},Yj),u.ie=function(e){IIt(this.a,e)};var m9e=A(Qs,"DoubleStream/DoubleStreamSource/lambda$2$Type",1417),k3e=Sr(Qs,"Stream");T(940,446,Wp,ATt),u.sd=function(e){for(;Xae(this);){if(this.a.sd(e))return!0;this.a=null}return!1};var b9e=A(Qs,"Stream/2",940);T(941,1,{},Kj),u.td=function(e){kee(this.a,e)};var w9e=A(Qs,"Stream/2/lambda$0$Type",941);T(942,1,WP,Jj),u.fe=function(){P$(this.a)};var v9e=A(Qs,"Stream/3methodref$close$Type",942);T(943,1,WP,Qj),u.fe=function(){P$(this.a)};var _9e=A(Qs,"Stream/4methodref$close$Type",943);T(644,446,Wp,Rct),u.sd=function(e){for(this.b=!1;!this.b&&this.c.sd(new hMt(this,e)););return this.b},u.b=!1;var y9e=A(Qs,"Stream/FilterSpliterator",644);T(932,1,{},hMt),u.td=function(e){Ure(this.a,this.b,e)};var x9e=A(Qs,"Stream/FilterSpliterator/lambda$0$Type",932);T(930,929,Wp,Ykt);var M9e=A(Qs,"Stream/MapToDoubleSpliterator",930);T(646,1,{},ert),u.td=function(e){mte(this.a,this.b,e)};var E9e=A(Qs,"Stream/MapToDoubleSpliterator/lambda$0$Type",646);T(643,446,Wp,Act),u.sd=function(e){return PTt(this,e)};var S9e=A(Qs,"Stream/MapToObjSpliterator",643);T(931,1,{},fMt),u.td=function(e){bte(this.a,this.b,e)};var T9e=A(Qs,"Stream/MapToObjSpliterator/lambda$0$Type",931);T(45,645,{607:1,1701:1,1700:1},gi);var C9e=A(Qs,"Stream/StreamSource",45);T(936,446,Wp,kTt),u.sd=function(e){for(;Zae(this);){if(this.a.sd(e))return!0;P$(this.b),this.b=null,this.a=null}return!1};var A9e=A(Qs,"Stream/StreamSource/1",936);T(937,1,{},tH),u.td=function(e){nre(this.a,e)};var k9e=A(Qs,"Stream/StreamSource/1/lambda$0$Type",937);T(938,446,Wp,A4t),u.sd=function(e){var n;return this.a||(n=new Nt,this.b.a.gc(new eH(n)),we(),gc(n,this.c),this.a=new Ei(n,16)),Xct(this.a,e)},u.a=null;var L9e=A(Qs,"Stream/StreamSource/5",938);T(939,1,{},eH),u.td=function(e){Ut(this.a,e)};var P9e=A(Qs,"Stream/StreamSource/5/2methodref$add$Type",939);T(933,1,{},yt),u.td=function(e){};var I9e=A(Qs,"Stream/StreamSource/lambda$0$Type",933);T(934,1,{},nH),u.le=function(e,n){return fee(this.a,e,n)};var R9e=A(Qs,"Stream/StreamSource/lambda$3$Type",934);T(935,1,{},dMt),u.td=function(e){$te(this.b,this.a,e)};var D9e=A(Qs,"Stream/StreamSource/lambda$4$Type",935);T(553,1,{},ue),u.td=function(e){R8(this,e)};var N9e=A(Qs,"Stream/ValueConsumer",553);T(944,1,{},iH),u.td=function(e){Lle(this.a,e)};var O9e=A(Qs,"TerminatableStream/lambda$0$Type",944),L3e=0,q1t,X1t=0,tB;T(1480,1,{},gkt);var B9e=A(UOt,"Scanline",1480),P3e=Sr(UOt,zOt);T(1450,1,{},gLt);var F9e=A(vd,"CGraph",1450);T(309,1,{309:1},bAt),u.b=0,u.c=0,u.d=0,u.g=0,u.i=0,u.k=Ps;var U9e=A(vd,"CGroup",309);T(723,1,{},uit);var z9e=A(vd,"CGroup/CGroupBuilder",723);T(57,1,{57:1},sTt),u.Ib=function(){return this.j?hi(this.j.Kb(this)):(Vd(eB),eB.o+"@"+(cm(this)>>>0).toString(16))},u.f=0,u.i=Ps;var eB=A(vd,"CNode",57);T(722,1,{},lit);var j9e=A(vd,"CNode/CNodeBuilder",722),Gzt;T(1236,1,{},fn),u.se=function(e,n){return 0},u.te=function(e,n){return 0};var H9e=A(vd,HOt,1236);T(1505,1,{},An),u.pe=function(e){var n,i,r,c,l,f,g,b,v,M,k,R,O,$,W;for(v=is,r=new H(e.a.b);r.ar.d.c||r.d.c==l.d.c&&r.d.b=0?"b"+e+"["+iV(this.a)+"]":"b["+iV(this.a)+"]"):"b_"+cm(this)};var ZDe=A(VP,"FBendpoint",497);T(262,131,{3:1,262:1,93:1,131:1},lTt),u.Ib=function(){return iV(this)};var YDe=A(VP,"FEdge",262);T(202,131,{3:1,202:1,93:1,131:1},fN);var R3e=A(VP,"FGraph",202);T(454,329,{3:1,454:1,329:1,93:1,131:1},pkt),u.Ib=function(){return this.b==null||this.b.length==0?"l["+iV(this.a)+"]":"l_"+this.b};var KDe=A(VP,"FLabel",454);T(146,329,{3:1,146:1,329:1,93:1,131:1},t4t),u.Ib=function(){return ict(this)},u.b=0;var JDe=A(VP,"FNode",146);T(1691,1,{}),u.Ee=function(e){Tht(this,e)},u.Fe=function(){LRt(this)},u.d=0;var QDe=A(Cft,"AbstractForceModel",1691);T(568,1691,{568:1},jPt),u.De=function(e,n){var i,r,c,l,f;return p9t(this.f,e,n),c=za(Xc(n.d),e.d),f=y.Math.sqrt(c.a*c.a+c.b*c.b),r=y.Math.max(0,f-L$(e.e)/2-L$(n.e)/2),i=ZPt(this.e,e,n),i>0?l=-Vre(r,this.c)*i:l=Gee(r,this.b)*a(z(e,(Ph(),SE)),21).a,hl(c,l/f),c},u.Ee=function(e){Tht(this,e),this.a=a(z(e,(Ph(),cB)),21).a,this.c=lt(Yt(z(e,aB))),this.b=lt(Yt(z(e,FK)))},u.Ge=function(e){return e0&&(l-=yQt(r,this.a)*i),hl(c,l*this.b/f),c},u.Ee=function(e){var n,i,r,c,l,f,g;for(Tht(this,e),this.b=lt(Yt(z(e,(Ph(),UK)))),this.c=this.b/a(z(e,cB),21).a,r=e.e.c.length,l=0,c=0,g=new H(e.e);g.a0},u.a=0,u.b=0,u.c=0;var eNe=A(Cft,"FruchtermanReingoldModel",569);T(748,1,_d,oj),u.ue=function(e){He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,oO),""),"Force Model"),"Determines the model for force calculation."),ygt),(n0(),xs)),xgt),qe((Qg(),On))))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Aft),""),"Iterations"),"The number of iterations on the force model."),Xt(300)),Pa),Io),qe(On)))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,kft),""),"Repulsive Power"),"Determines how many bend points are added to the edge; such bend points are regarded as repelling particles in the force model"),Xt(0)),Pa),Io),qe(Md)))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,QZ),""),"FR Temperature"),"The temperature is used as a scaling factor for particle displacements."),op),ha),To),qe(On)))),Sa(e,QZ,oO,mjt),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,tY),""),"Eades Repulsion"),"Factor for repulsive forces in Eades' model."),5),ha),To),qe(On)))),Sa(e,tY,oO,djt),F7t((new aj,e))};var ljt,hjt,ygt,fjt,djt,pjt,gjt,mjt,nNe=A(h4,"ForceMetaDataProvider",748);T(387,23,{3:1,34:1,23:1,387:1},ort);var BK,oB,xgt=Ri(h4,"ForceModelStrategy",387,ji,eoe,Nne),bjt;T(880,1,_d,aj),u.ue=function(e){F7t(e)};var wjt,Mgt,cB,Egt,vjt,Sgt,Tgt,SE,_jt,FK,Cgt,yjt,xjt,aB,UK,iNe=A(h4,"ForceOptions",880);T(881,1,{},ev),u.Be=function(){var e;return e=new hit,e},u.Ce=function(e){};var rNe=A(h4,"ForceOptions/ForceFactory",881),v6,B4,hx,uB;T(749,1,_d,p8),u.ue=function(e){He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Ift),""),"Fixed Position"),"Prevent that the node is moved by the layout algorithm."),(me(),me(),!1)),(n0(),Ec)),ho),qe((Qg(),vc))))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Rft),""),"Desired Edge Length"),"Either specified for parent nodes or for individual edges, where the latter takes higher precedence."),100),ha),To),ur(On,Y(Z(Jp,1),jt,163,0,[Md]))))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Dft),""),"Layout Dimension"),"Dimensions that are permitted to be altered during layout."),Agt),xs),Dgt),qe(On)))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Nft),""),"Stress Epsilon"),"Termination criterion for the iterative process."),op),ha),To),qe(On)))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Oft),""),"Iteration Limit"),"Maximum number of performed iterations. Takes higher precedence than 'epsilon'."),Xt(qi)),Pa),Io),qe(On)))),i7t((new cj,e))};var Mjt,Ejt,Agt,Sjt,Tjt,Cjt,sNe=A(h4,"StressMetaDataProvider",749);T(884,1,_d,cj),u.ue=function(e){i7t(e)};var lB,kgt,Lgt,Pgt,Igt,Rgt,oNe=A(h4,"StressOptions",884);T(885,1,{},B0),u.Be=function(){var e;return e=new hTt,e},u.Ce=function(e){};var cNe=A(h4,"StressOptions/StressFactory",885);T(959,244,I_,hTt),u.Ae=function(e,n){var i,r,c,l;for(di(n,aBt,1),lt(de(cn(e,(BL(),Igt))))||X8t(new hit,e,Ta(n,1)),r=f6t(e),i=WNt(this.a,r),l=i.tc();l.hc();)c=a(l.ic(),202),F_e(this.b,c),L0e(this.b);r=nOt(i),J7t(r),Vn(n)};var aNe=A(iY,"StressLayoutProvider",959);T(882,1,{},AG),u.c=0,u.e=0,u.g=0;var uNe=A(iY,"StressMajorization",882);T(348,23,{3:1,34:1,23:1,348:1},eW);var zK,jK,HK,Dgt=Ri(iY,"StressMajorization/Dimension",348,ji,Goe,One),Ajt;T(883,1,jr,Sv),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return une(this.a,e,n)};var lNe=A(iY,"StressMajorization/lambda$0$Type",883);T(985,1,{},kAt);var hNe=A(ZP,"ElkLayered",985);T(986,1,{},Us),u.td=function(e){cue(this.a,e)};var fNe=A(ZP,"ElkLayered/lambda$0$Type",986);T(987,1,{},F0),u.td=function(e){Ct(a(e,31),(qt(),HB),(RM(),IB))};var dNe=A(ZP,"ElkLayered/lambda$1$Type",987);T(1033,1,{},QEt);var kjt,Ljt,Pjt,pNe=A(ZP,"GraphConfigurator",1033);T(958,244,I_,_u),u.Ae=function(e,n){var i;i=mwe(new vEt,e),zt(cn(e,(qt(),X4)))===zt((Yg(),kx))?Rhe(this.a,i,n):j0e(this.a,i,n),K7t(new g8,i)};var gNe=A(ZP,"LayeredLayoutProvider",958);T(328,23,{3:1,34:1,23:1,328:1},O5);var Of,fx,aa,ua,Yo,Ngt=Ri(ZP,"LayeredPhases",328,ji,Jce,Bne),Ijt;T(1407,1,{},DPt),u.i=0;var Rjt,mNe=A(YP,"ComponentsToCGraphTransformer",1407),Djt;T(1408,1,{},nv),u.He=function(e,n){return y.Math.min(e.a!=null?lt(e.a):e.c.i,n.a!=null?lt(n.a):n.c.i)},u.Ie=function(e,n){return y.Math.min(e.a!=null?lt(e.a):e.c.i,n.a!=null?lt(n.a):n.c.i)};var bNe=A(YP,"ComponentsToCGraphTransformer/1",1408);T(80,1,{80:1}),u.i=0,u.k=!0,u.o=Ps;var GK=A(d4,"CNode",80);T(282,80,{282:1,80:1},Krt,vut),u.Ib=function(){return""};var wNe=A(YP,"ComponentsToCGraphTransformer/CRectNode",282);T(1391,1,{},wg);var WK,$K,vNe=A(YP,"OneDimensionalComponentsCompaction",1391);T(1392,1,rh,iv),u.Fb=function(e){return this===e},u.Kb=function(e){return dq(),me(),a(a(e,48).a,80).d.e!=0};var _Ne=A(YP,"OneDimensionalComponentsCompaction/lambda$0$Type",1392);T(1393,1,rh,o3),u.Fb=function(e){return this===e},u.Kb=function(e){return dq(),me(),!!(hIt(a(a(e,48).a,80).j,a(a(e,48).b,110))||a(a(e,48).a,80).d.e!=0&&hIt(a(a(e,48).a,80).j,a(a(e,48).b,110)))};var yNe=A(YP,"OneDimensionalComponentsCompaction/lambda$1$Type",1393);T(1410,1,{},QCt);var xNe=A(d4,"CGraph",1410);T(172,1,{172:1},Aq),u.b=0,u.c=0,u.e=0,u.g=!0,u.i=Ps;var MNe=A(d4,"CGroup",172);T(1409,1,{},Rt),u.He=function(e,n){return y.Math.max(e.a!=null?lt(e.a):e.c.i,n.a!=null?lt(n.a):n.c.i)},u.Ie=function(e,n){return y.Math.max(e.a!=null?lt(e.a):e.c.i,n.a!=null?lt(n.a):n.c.i)};var ENe=A(d4,HOt,1409);T(1411,1,{},k9t),u.d=!1;var Njt,VK=A(d4,$Ot,1411);T(1412,1,rh,ve),u.Fb=function(e){return this===e},u.Kb=function(e){return zit(),me(),a(a(e,48).a,80).d.e!=0};var SNe=A(d4,VOt,1412);T(726,1,{},eot),u.a=!1,u.b=!1,u.c=!1,u.d=!1;var TNe=A(d4,qOt,726);T(1521,1,{},CCt);var CNe=A(uO,XOt,1521),_6=Sr(a0,zOt);T(1522,1,{341:1},U4t),u.Ne=function(e){rwe(this,a(e,524))};var ANe=A(uO,ZOt,1522);T(1523,1,jr,Je),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return ro(a(e,282).g.c+a(e,282).g.b/2,a(n,282).g.c+a(n,282).g.b/2)};var kNe=A(uO,YOt,1523);T(524,1,{524:1},crt),u.a=!1;var LNe=A(uO,KOt,524);T(1524,1,jr,tn),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return Ope(e,n)};var PNe=A(uO,JOt,1524);T(102,1,{102:1},rM,$st),u.Fb=function(e){var n;return e==null||D3e!=fu(e)?!1:(n=a(e,102),au(this.c,n.c)&&au(this.d,n.d))},u.Hb=function(){return QV(Y(Z(un,1),te,1,5,[this.c,this.d]))},u.Ib=function(){return"("+this.c+Rc+this.d+(this.a?"cx":"")+this.b+")"},u.a=!0,u.c=0,u.d=0;var D3e=A(a0,"Point",102);T(373,23,{3:1,34:1,23:1,373:1},F9);var $m,gw,V_,mw,Ojt=Ri(a0,"Point/Quadrant",373,ji,xce,Fne),Bjt;T(1398,1,{},nm),u.b=null,u.c=null,u.d=null,u.e=null,u.f=null;var Fjt,Ujt,zjt,jjt,Hjt,INe=A(a0,"RectilinearConvexHull",1398);T(516,1,{341:1},a7),u.Ne=function(e){Yae(this,a(e,102))},u.b=0;var Ogt,RNe=A(a0,"RectilinearConvexHull/MaximalElementsEventHandler",516);T(1400,1,jr,Hi),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return jit(),ro(lt(Yt(e)),lt(Yt(n)))};var DNe=A(a0,"RectilinearConvexHull/MaximalElementsEventHandler/lambda$0$Type",1400);T(1399,1,{341:1},mLt),u.Ne=function(e){Ibe(this,a(e,102))},u.a=0,u.b=null,u.c=null,u.d=null,u.e=null;var NNe=A(a0,"RectilinearConvexHull/RectangleEventHandler",1399);T(1401,1,jr,Pr),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return pC(),a(e,102).c==a(n,102).c?ro(a(n,102).d,a(e,102).d):ro(a(e,102).c,a(n,102).c)};var ONe=A(a0,"RectilinearConvexHull/lambda$0$Type",1401);T(1402,1,jr,Gr),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return pC(),a(e,102).c==a(n,102).c?ro(a(e,102).d,a(n,102).d):ro(a(e,102).c,a(n,102).c)};var BNe=A(a0,"RectilinearConvexHull/lambda$1$Type",1402);T(1403,1,jr,Ze),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return pC(),a(e,102).c==a(n,102).c?ro(a(n,102).d,a(e,102).d):ro(a(n,102).c,a(e,102).c)};var FNe=A(a0,"RectilinearConvexHull/lambda$2$Type",1403);T(1404,1,jr,hs),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return pC(),a(e,102).c==a(n,102).c?ro(a(e,102).d,a(n,102).d):ro(a(n,102).c,a(e,102).c)};var UNe=A(a0,"RectilinearConvexHull/lambda$3$Type",1404);T(1405,1,jr,Fs),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return tge(e,n)};var zNe=A(a0,"RectilinearConvexHull/lambda$4$Type",1405);T(1406,1,{},mkt);var jNe=A(a0,"Scanline",1406);T(1694,1,{});var HNe=A(Y1,"AbstractGraphPlacer",1694);T(458,1,{458:1},oCt);var ps,GNe=A(Y1,"ComponentGroup",458);T(1076,1694,{},w9),u.Oe=function(e,n){var i,r,c,l,f,g,b,v,M,k,R,O,$;if(this.a.c=dt(un,te,1,0,5,1),n.a.c=dt(un,te,1,0,5,1),e.Wb()){n.e.a=0,n.e.b=0;return}for(f=a(e.cd(0),31),Uo(n,f),c=e.tc();c.hc();)r=a(c.ic(),31),Bhe(this,r);for($=new go,l=lt(Yt(z(f,(qt(),GJ)))),v=new H(this.a);v.aO&&(Gt=0,Zt+=R+c,R=0),nt=f.c,TP(f,Gt+nt.a,Zt+nt.b),Gh(nt),i=y.Math.max(i,Gt+pt.a),R=y.Math.max(R,pt.b),Gt+=pt.a+c;if(n.e.a=i,n.e.b=Zt+R,lt(de(z(l,BJ)))){for(r=new Ms,aOt(r,e,c),k=e.tc();k.hc();)M=a(k.ic(),31),sr(Gh(M.c),r.e);sr(Gh(n.e),r.a)}O5t(n,e)};var t7e=A(Y1,"SimpleRowGraphPlacer",1074);T(1075,1,jr,Tc),u.Ld=function(e,n){return dle(a(e,31),a(n,31))},u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)};var e7e=A(Y1,"SimpleRowGraphPlacer/1",1075),Gjt;T(1032,1,sh,rl),u.Mb=function(e){var n;return n=a(z(a(e,234).b,(qt(),Ro)),74),!!n&&n.b!=0},u.Fb=function(e){return this===e},u.Nb=function(e){return this.Mb(e)};var n7e=A(lO,"CompoundGraphPostprocessor/1",1032);T(1031,1,Br,wEt),u.Pe=function(e,n){wRt(this,a(e,31),n)};var i7e=A(lO,"CompoundGraphPreprocessor",1031);T(400,1,{400:1},V6t),u.c=!1;var r7e=A(lO,"CompoundGraphPreprocessor/ExternalPort",400);T(234,1,{234:1},xD),u.Ib=function(){return Q5(this.c)+":"+PLt(this.b)};var s7e=A(lO,"CrossHierarchyEdge",234);T(687,1,jr,W8),u.Ld=function(e,n){return vpe(this,a(e,234),a(n,234))},u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)};var o7e=A(lO,"CrossHierarchyEdgeComparator",687);T(279,131,{3:1,279:1,93:1,131:1}),u.o=0;var c7e=A(oa,"LGraphElement",279);T(14,279,{3:1,14:1,279:1,93:1,131:1},Np),u.Ib=function(){return PLt(this)};var Tl=A(oa,"LEdge",14);T(31,279,{3:1,20:1,31:1,279:1,93:1,131:1},cat),u.sc=function(e){vo(this,e)},u.tc=function(){return new H(this.b)},u.Ib=function(){return this.b.c.length==0?"G-unlayered"+Gp(this.a):this.a.c.length==0?"G-layered"+Gp(this.b):"G[layerless"+Gp(this.a)+", layers"+Gp(this.b)+"]"};var Wjt=A(oa,"LGraph",31);T(591,1,{}),u.Qe=function(){return this.e.k},u.xe=function(e){return z(this.e,e)},u.Re=function(){return this.e.n},u.Se=function(){return this.e.o},u.ye=function(e){return jb(this.e,e)},u.Te=function(e){this.e.k.a=e.a,this.e.k.b=e.b},u.Ue=function(e){this.e.n.a=e.a,this.e.n.b=e.b},u.Ve=function(e){this.e.o=e};var a7e=A(oa,"LGraphAdapters/AbstractLShapeAdapter",591);T(520,1,{741:1},xh),u.We=function(){var e,n;if(!this.b)for(this.b=od(this.a.b.c.length),n=new H(this.a.b);n.a0&&FPt(e.charCodeAt(n-1),dBt);)--n;if(l "+this.a+" "+Q5(this.c)},u.a=0,u.b=0,u.d=0;var zBe=A(Dn,"SplineSelfLoopRouter/LoopPadding",188);T(1294,1,sh,fCt),u.Mb=function(e){return sde(this,a(e,188))},u.Fb=function(e){return this===e},u.Nb=function(e){return this.Mb(e)},u.a=0,u.c=0;var jBe=A(Dn,"SplineSelfLoopRouter/LoopPadding/EnclosingPredicate",1294);T(1293,1,jr,Iy),u.Ld=function(e,n){return Cte(a(e,188),a(n,188))},u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)};var HBe=A(Dn,"SplineSelfLoopRouter/LoopPadding/MarginComparator",1293);T(415,1,sh,Ib),u.Mb=function(e){return a(e,188).c==this.a},u.Fb=function(e){return this===e},u.Nb=function(e){return this.Mb(e)};var GBe=A(Dn,"SplineSelfLoopRouter/LoopPadding/PortSidePredicate",415);T(414,1,{414:1},ckt),u.c=0,u.d=0,u.e=0;var WBe=A(Dn,"SplineSelfLoopRouter/SelfLoopEdge",414);T(1292,1,jr,yk),u.Ld=function(e,n){return jQt(a(e,414),a(n,414))},u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)};var $Be=A(Dn,"SplineSelfLoopRouter/SelfLoopEdge/StepSizeComparator",1292);T(1451,715,{},yPt),u.qe=function(e){var n,i,r,c;switch(this.c=e,this.a.g){case 2:n=new Nt,qc(wo(new gi(null,new Ei(this.c.a.b,16)),new Dy),new SMt(this,n)),mP(this,new Ek),pd(n,new xk),n.c=dt(un,te,1,0,5,1),qc(wo(new gi(null,new Ei(this.c.a.b,16)),new Yf),new Z8(n)),mP(this,new Fu),pd(n,new x3),n.c=dt(un,te,1,0,5,1),i=XEt(_Pt(mL(new gi(null,new Ei(this.c.a.b,16)),new oT(this))),new pf),qc(new gi(null,new Ei(this.c.a.a,16)),new vMt(i,n)),mP(this,new LS),pd(n,new G0),n.c=dt(un,te,1,0,5,1);break;case 3:r=new Nt,mP(this,new Ry),c=XEt(_Pt(mL(new gi(null,new Ei(this.c.a.b,16)),new mH(this))),new Mk),qc(wo(new gi(null,new Ei(this.c.a.b,16)),new y3),new EMt(c,r)),mP(this,new lv),pd(r,new PS),r.c=dt(un,te,1,0,5,1);break;default:throw K(new mt)}},u.b=0;var VBe=A(Kr,"EdgeAwareScanlineConstraintCalculation",1451);T(1452,1,sh,Ry),u.Fb=function(e){return this===e},u.Nb=function(e){return this.Mb(e)},u.Mb=function(e){return ct(a(e,57).g,153)};var qBe=A(Kr,"EdgeAwareScanlineConstraintCalculation/lambda$0$Type",1452);T(1453,1,{},mH),u.oe=function(e){return b0e(this.a,e)};var XBe=A(Kr,"EdgeAwareScanlineConstraintCalculation/lambda$1$Type",1453);T(1464,1,{},xk),u.td=function(e){a(e,340).fe()};var ZBe=A(Kr,"EdgeAwareScanlineConstraintCalculation/lambda$10$Type",1464);T(1465,1,us,Yf),u.Nb=function(e){return ct(a(e,57).g,8)};var YBe=A(Kr,"EdgeAwareScanlineConstraintCalculation/lambda$11$Type",1465);T(1467,1,{},Z8),u.td=function(e){Jhe(this.a,e)};var KBe=A(Kr,"EdgeAwareScanlineConstraintCalculation/lambda$12$Type",1467);T(1468,1,sh,Fu),u.Fb=function(e){return this===e},u.Nb=function(e){return this.Mb(e)},u.Mb=function(e){return ct(a(e,57).g,8)};var JBe=A(Kr,"EdgeAwareScanlineConstraintCalculation/lambda$13$Type",1468);T(1469,1,{},x3),u.td=function(e){a(e,340).fe()};var QBe=A(Kr,"EdgeAwareScanlineConstraintCalculation/lambda$14$Type",1469);T(1470,1,{},oT),u.oe=function(e){return w0e(this.a,e)};var tFe=A(Kr,"EdgeAwareScanlineConstraintCalculation/lambda$15$Type",1470);T(1471,1,{},pf),u.me=function(){return 0};var eFe=A(Kr,"EdgeAwareScanlineConstraintCalculation/lambda$16$Type",1471);T(1473,1,{},vMt),u.td=function(e){Lre(this.a,this.b,e)},u.a=0;var nFe=A(Kr,"EdgeAwareScanlineConstraintCalculation/lambda$17$Type",1473);T(1474,1,sh,LS),u.Fb=function(e){return this===e},u.Nb=function(e){return this.Mb(e)},u.Mb=function(e){return!0};var iFe=A(Kr,"EdgeAwareScanlineConstraintCalculation/lambda$18$Type",1474);T(1475,1,{},G0),u.td=function(e){a(e,340).fe()};var rFe=A(Kr,"EdgeAwareScanlineConstraintCalculation/lambda$19$Type",1475);T(1454,1,{},Mk),u.me=function(){return 0};var sFe=A(Kr,"EdgeAwareScanlineConstraintCalculation/lambda$2$Type",1454);T(1456,1,WP,_Mt),u.fe=function(){jC(this.b,this.a,-1)},u.a=0;var oFe=A(Kr,"EdgeAwareScanlineConstraintCalculation/lambda$20$Type",1456);T(1461,1,WP,yMt),u.fe=function(){jC(this.a,this.b,-1)},u.b=0;var cFe=A(Kr,"EdgeAwareScanlineConstraintCalculation/lambda$21$Type",1461);T(1466,1,WP,xMt),u.fe=function(){jC(this.b,this.a,-1)},u.a=0;var aFe=A(Kr,"EdgeAwareScanlineConstraintCalculation/lambda$22$Type",1466);T(1472,1,WP,MMt),u.fe=function(){tDt(this.a,this.b,-1)},u.b=0;var uFe=A(Kr,"EdgeAwareScanlineConstraintCalculation/lambda$23$Type",1472);T(1455,1,us,y3),u.Nb=function(e){return ct(a(e,57).g,8)};var lFe=A(Kr,"EdgeAwareScanlineConstraintCalculation/lambda$3$Type",1455);T(1457,1,{},EMt),u.td=function(e){Pre(this.a,this.b,e)},u.a=0;var hFe=A(Kr,"EdgeAwareScanlineConstraintCalculation/lambda$4$Type",1457);T(1458,1,sh,lv),u.Fb=function(e){return this===e},u.Nb=function(e){return this.Mb(e)},u.Mb=function(e){return!0};var fFe=A(Kr,"EdgeAwareScanlineConstraintCalculation/lambda$5$Type",1458);T(1459,1,{},PS),u.td=function(e){a(e,340).fe()};var dFe=A(Kr,"EdgeAwareScanlineConstraintCalculation/lambda$6$Type",1459);T(1460,1,us,Dy),u.Nb=function(e){return ct(a(e,57).g,153)};var pFe=A(Kr,"EdgeAwareScanlineConstraintCalculation/lambda$7$Type",1460);T(1462,1,{},SMt),u.td=function(e){_ue(this.a,this.b,e)};var gFe=A(Kr,"EdgeAwareScanlineConstraintCalculation/lambda$8$Type",1462);T(1463,1,sh,Ek),u.Fb=function(e){return this===e},u.Nb=function(e){return this.Mb(e)},u.Mb=function(e){return ct(a(e,57).g,153)};var mFe=A(Kr,"EdgeAwareScanlineConstraintCalculation/lambda$9$Type",1463);T(1232,1,Br,TSt),u.Pe=function(e,n){uye(this,a(e,31),n)};var Jjt,bFe=A(Kr,"HorizontalGraphCompactor",1232);T(1233,1,{},Ky),u.se=function(e,n){var i,r,c;return zt(z(this.a.a,(qt(),ng)))===zt((gd(),eb))&&(ct(e.g,153)&&ct(n.g,8)||ct(n.g,153)&&ct(e.g,8))?lt(de(z(this.a.a,WB)))?0:10:jct(e,n)||(i=Zv(e),r=Zv(n),i&&i.j==(Ke(),rs)||r&&r.j==(Ke(),rs))?0:(c=a(z(this.a.a,(Ft(),ww)),266),Iee(c,i?i.j:(Ke(),Hr),r?r.j:(Ke(),Hr)))},u.te=function(e,n){var i,r,c;return jct(e,n)?1:(i=Zv(e),r=Zv(n),c=a(z(this.a.a,(Ft(),ww)),266),Yrt(c,i?i.j:(Ke(),Hr),r?r.j:(Ke(),Hr)))};var wFe=A(Kr,"HorizontalGraphCompactor/1",1233);T(1234,1,{},gf),u.re=function(e,n){return _T(),e.a.i==0};var vFe=A(Kr,"HorizontalGraphCompactor/lambda$0$Type",1234);T(1235,1,{},jd),u.re=function(e,n){return Ose(this.a,e,n)};var _Fe=A(Kr,"HorizontalGraphCompactor/lambda$1$Type",1235);T(1422,1,{},jLt);var Qjt,tHt,yFe=A(Kr,"LGraphToCGraphTransformer",1422);T(1430,1,us,Ny),u.Nb=function(e){return e!=null};var xFe=A(Kr,"LGraphToCGraphTransformer/0methodref$nonNull$Type",1430);T(1423,1,ys,Sk),u.Kb=function(e){return Zl(),Yc(z(a(a(e,57).g,8),(Ft(),li)))};var MFe=A(Kr,"LGraphToCGraphTransformer/lambda$0$Type",1423);T(1424,1,ys,hv),u.Kb=function(e){return Zl(),tIt(a(a(e,57).g,153))};var EFe=A(Kr,"LGraphToCGraphTransformer/lambda$1$Type",1424);T(1435,1,us,IS),u.Nb=function(e){return Zl(),ct(a(e,57).g,153)};var SFe=A(Kr,"LGraphToCGraphTransformer/lambda$10$Type",1435);T(1439,1,{},Fl),u.td=function(e){var n,i;Zl(),n=e.d.c-e.e.c,i=a(e.g,153),pd(i.b,new _H(n)),pd(i.c,new yH(n)),vo(i.i,new Y8(n))};var TFe=A(Kr,"LGraphToCGraphTransformer/lambda$11$Type",1439);T(1440,1,ys,Oy),u.Kb=function(e){return Zl(),new gi(null,new y2(Rn(br(a(e,8)))))};var CFe=A(Kr,"LGraphToCGraphTransformer/lambda$12$Type",1440);T(1441,1,us,bb),u.Nb=function(e){return Zl(),ec(a(e,14))};var AFe=A(Kr,"LGraphToCGraphTransformer/lambda$13$Type",1441);T(1442,1,{},bH),u.td=function(e){aue(this.a,e)};var kFe=A(Kr,"LGraphToCGraphTransformer/lambda$14$Type",1442);T(1443,1,ys,Tk),u.Kb=function(e){return Zl(),new gi(null,new Ei(a(e,26).a,16))};var LFe=A(Kr,"LGraphToCGraphTransformer/lambda$15$Type",1443);T(1444,1,ys,u1),u.Kb=function(e){return Zl(),new gi(null,new y2(Rn(br(a(e,8)))))};var PFe=A(Kr,"LGraphToCGraphTransformer/lambda$16$Type",1444);T(1445,1,ys,l1),u.Kb=function(e){return Zl(),a(z(a(e,14),(Ft(),G4)),15)};var IFe=A(Kr,"LGraphToCGraphTransformer/lambda$17$Type",1445);T(1446,1,us,Kf),u.Nb=function(e){return Zl(),!!a(e,15)&&!a(e,15).Wb()};var RFe=A(Kr,"LGraphToCGraphTransformer/lambda$18$Type",1446);T(1447,1,{},wH),u.td=function(e){v0e(this.a,a(e,15))};var DFe=A(Kr,"LGraphToCGraphTransformer/lambda$19$Type",1447);T(1426,1,{},vH),u.td=function(e){Loe(this.a,e)};var NFe=A(Kr,"LGraphToCGraphTransformer/lambda$2$Type",1426);T(1425,1,{},TMt),u.td=function(e){Cce(this.a,this.b,e)};var OFe=A(Kr,"LGraphToCGraphTransformer/lambda$20$Type",1425);T(1436,1,{},_H),u.td=function(e){jte(this.a,e)},u.a=0;var BFe=A(Kr,"LGraphToCGraphTransformer/lambda$21$Type",1436);T(1437,1,{},yH),u.td=function(e){Hte(this.a,e)},u.a=0;var FFe=A(Kr,"LGraphToCGraphTransformer/lambda$22$Type",1437);T(1438,1,{},Y8),u.td=function(e){Gte(this.a,e)},u.a=0;var UFe=A(Kr,"LGraphToCGraphTransformer/lambda$23$Type",1438);T(1427,1,ys,By),u.Kb=function(e){return Zl(),new gi(null,new Ei(a(e,26).a,16))};var zFe=A(Kr,"LGraphToCGraphTransformer/lambda$3$Type",1427);T(1428,1,ys,Fy),u.Kb=function(e){return Zl(),new gi(null,new y2(Rn(br(a(e,8)))))};var jFe=A(Kr,"LGraphToCGraphTransformer/lambda$4$Type",1428);T(1429,1,ys,M3),u.Kb=function(e){return Zl(),a(z(a(e,14),(Ft(),G4)),15)};var HFe=A(Kr,"LGraphToCGraphTransformer/lambda$5$Type",1429);T(1431,1,{},em),u.td=function(e){G0e(this.a,e)};var GFe=A(Kr,"LGraphToCGraphTransformer/lambda$6$Type",1431);T(1432,1,{},CMt),u.td=function(e){Xte(this.a,this.b,e)};var WFe=A(Kr,"LGraphToCGraphTransformer/lambda$7$Type",1432);T(1433,1,us,Uy),u.Nb=function(e){return Zl(),ct(a(e,57).g,8)};var $Fe=A(Kr,"LGraphToCGraphTransformer/lambda$8$Type",1433);T(1434,1,{},wb),u.td=function(e){var n;Zl(),n=a(e.g,8),n.k.a=e.d.c+n.d.b};var VFe=A(Kr,"LGraphToCGraphTransformer/lambda$9$Type",1434);T(1421,1,{},zy),u.pe=function(e){var n,i,r,c,l;for(this.a=e,this.d=new kG,this.c=dt(C0t,te,113,this.a.a.a.c.length,0,1),this.b=0,i=new H(this.a.a.a);i.ac-f?0:c-f;R<=rm(n.f-1,c+f);R++){if(W=rt/(R+1),nt=0,M=1,l=new Nt,pt=Ps,k=0,g=0,$=b[0],R==0)pt=rt,g=(n.g==null&&(n.g=bPt(n,new Wa)),lt(n.g));else{for(;M=W&&(Ut(l,Xt(M)),pt=y.Math.max(pt,_t[M-1]-k),g+=$,nt+=_t[M-1]-nt,k=_t[M-1],$=b[M]),$=y.Math.max($,b[M]),++M;g+=$}O=y.Math.min(1/pt,1/n.b/g),O>r&&(r=O,i=l)}return i},u.tf=function(){return!1};var mUe=A(cp,"MSDCutIndexHeuristic",714);T(1279,1,Br,jy),u.Pe=function(e,n){w_e(a(e,31),n)};var bUe=A(cp,"SingleEdgeGraphWrapper",1279);T(189,1,{189:1},Jf),u.Ib=function(){return"NEdge[id="+this.b+" w="+this.g+" d="+this.a+"]"},u.a=1,u.b=0,u.c=0,u.f=!1,u.g=0;var nHt=A(g4,"NEdge",189);T(162,1,{},cl);var wUe=A(g4,"NEdge/NEdgeBuilder",162);T(592,1,{},kG);var vUe=A(g4,"NGraph",592);T(113,1,{113:1},e5t),u.c=-1,u.d=0,u.e=0,u.i=-1,u.j=!1;var C0t=A(g4,"NNode",113);T(717,1,OOt,fit),u.sc=function(e){vo(this,e)},u.uc=function(){return this.xc()},u.jd=function(e){R1(this,e)},u.wc=function(){return new Ei(this,16)},u.xc=function(){return new gi(null,this.wc())},u.bd=function(e,n){++this.b,hm(this.a,e,n)},u.nc=function(e){return cD(this,e)},u.oc=function(e){return++this.b,Or(this.a,e)},u.Pb=function(){++this.b,this.a.c=dt(un,te,1,0,5,1)},u.pc=function(e){return nc(this.a,e,0)!=-1},u.qc=function(e){return N1(this.a,e)},u.cd=function(e){return Ee(this.a,e)},u.dd=function(e){return nc(this.a,e,0)},u.Wb=function(){return this.a.c.length==0},u.tc=function(){return R2(new H(this.a))},u.ed=function(){throw K(new Oi)},u.fd=function(e){throw K(new Oi)},u.gd=function(e){return++this.b,ym(this.a,e)},u.vc=function(e){return Zrt(this,e)},u.hd=function(e,n){return++this.b,Kl(this.a,e,n)},u._b=function(){return this.a.c.length},u.kd=function(e,n){return new T1(this.a,e,n)},u.yc=function(){return jW(this.a)},u.zc=function(e){return xo(this.a,e)},u.b=0;var _Ue=A(g4,"NNode/ChangeAwareArrayList",717);T(251,1,{},Dg);var yUe=A(g4,"NNode/NNodeBuilder",251);T(1482,1,{},W0),u.a=!1,u.f=qi,u.j=0;var xUe=A(g4,"NetworkSimplex",1482);T(276,23,{3:1,34:1,23:1,276:1},F5);var aJ,uJ,lJ,A0t,hJ,k0t=Ri(ka,"CenterEdgeLabelPlacementStrategy",276,ji,Qce,Hne),iHt;T(386,23,{3:1,34:1,23:1,386:1},art);var L0t,fJ,P0t=Ri(ka,"ConstraintCalculationStrategy",386,ji,noe,Gne),rHt;T(290,23,{3:1,34:1,23:1,290:1},kT);var xB,I0t,MB,EB,SB,R0t,dJ=Ri(ka,"ContentAlignment",290,ji,Dae,Wne),sHt;T(317,23,{3:1,34:1,23:1,317:1,285:1,286:1},urt),u.hf=function(){return N8t(this)},u.uf=function(){return N8t(this)};var x6,M6,D0t=Ri(ka,"CrossingMinimizationStrategy",317,ji,ioe,$ne),oHt;T(319,23,{3:1,34:1,23:1,319:1},iW);var N0t,pJ,TB,O0t=Ri(ka,"CuttingStrategy",319,ji,Noe,Vne),cHt;T(384,23,{3:1,34:1,23:1,384:1,285:1,286:1},rW),u.hf=function(){return j8t(this)},u.uf=function(){return j8t(this)};var B0t,gJ,mJ,F0t=Ri(ka,"CycleBreakingStrategy",384,ji,Ooe,qne),aHt;T(406,23,{3:1,34:1,23:1,406:1},sW);var E6,bJ,z4,uHt=Ri(ka,"EdgeConstraint",406,ji,Boe,Xne),lHt;T(241,23,{3:1,34:1,23:1,241:1},LT);var wJ,vJ,_J,yJ,CB,xJ,U0t=Ri(ka,"EdgeLabelSideSelection",241,ji,Nae,Zne),hHt;T(255,23,{3:1,34:1,23:1,255:1},PT);var MJ,z0t,j0t,AB,H0t,G0t,W0t=Ri(ka,"FixedAlignment",255,ji,Oae,Yne),fHt;T(256,23,{3:1,34:1,23:1,256:1},IT);var $0t,V0t,q0t,X0t,j4,Z0t,Y0t=Ri(ka,"GraphCompactionStrategy",256,ji,Bae,Kne),dHt;T(233,23,{3:1,34:1,23:1,233:1},Fb);var AE,kB,kE,Al,H4,LB,X_,Z_,PB,S6,EJ=Ri(ka,"GraphProperties",233,ji,Yue,Jne),pHt;T(318,23,{3:1,34:1,23:1,318:1},oW);var IB,SJ,TJ,K0t=Ri(ka,"GreedySwitchType",318,ji,Doe,Qne),gHt;T(280,23,{3:1,34:1,23:1,280:1},cW);var dx,T6,Y_,mHt=Ri(ka,"InLayerConstraint",280,ji,Roe,tie),bHt;T(383,23,{3:1,34:1,23:1,383:1},lrt);var CJ,J0t,Q0t=Ri(ka,"InteractiveReferencePoint",383,ji,roe,eie),wHt,tmt,emt,AJ,bw,C6,px,Vm,RB,nmt,imt,DB,rmt,NB,kJ,OB,gx,LJ,BB,wc,smt,Qc,PJ,A6,b0,LE,mx,bx,k6,wx,Pu,Iu,K_,xd,li,omt,cmt,amt,IJ,Q1,FB,Ru,qm,RJ,PE,UB,tg,ww,DJ,vHt,L6,G4,NJ,umt,OJ,vx;T(178,23,{3:1,34:1,23:1,178:1},U5);var P6,vw,W4,Xm,_x,lmt=Ri(ka,"LayerConstraint",178,ji,tae,nie),_Ht;T(747,1,_d,sj),u.ue=function(e){He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Hft),""),"Content Alignment"),"Specifies how the content of compound nodes is to be aligned, e.g. top-left."),dmt),(n0(),OE)),dJ),qe((Qg(),On))),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.contentAlignment"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Gft),""),"Feedback Edges"),"Whether feedback edges should be highlighted by routing around the nodes."),(me(),me(),!1)),Ec),ho),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.feedBackEdges"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,hO),""),"Interactive Reference Point"),"Determines which point of a node is considered by interactive layout phases."),_mt),xs),Q0t),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.interactiveReferencePoint"])))),Sa(e,hO,oY,$Ht),Sa(e,hO,fY,WHt),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Wft),""),"Merge Edges"),"Edges that have no ports are merged so they touch the connected nodes at the same points. When this option is disabled, one port is created for each edge directly connected to a node. When it is enabled, all such incoming edges share an input port, and all outgoing edges share an output port."),!1),Ec),ho),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.mergeEdges"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,$ft),""),"Merge Hierarchy-Crossing Edges"),"If hierarchical layout is active, hierarchy-crossing edges use as few hierarchical ports as possible. They are broken by the algorithm, with hierarchical ports inserted as required. Usually, one such port is created for each edge at each hierarchy crossing point. With this option set to true, we try to create as few hierarchical ports as possible in the process. In particular, all edges that form a hyperedge can share a port."),!0),Ec),ho),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.mergeHierarchyEdges"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Vft),""),"Thoroughness"),"How much effort should be spent to produce a nice layout."),Xt(7)),Pa),Io),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.thoroughness"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,qft),""),"Add Unnecessary Bendpoints"),"Adds bend points even if an edge does not change direction. If true, each long edge dummy will contribute a bend point to its edges and hierarchy-crossing edges will always get a bend point where they cross hierarchy boundaries. By default, bend points are only added where an edge changes direction."),!1),Ec),ho),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.unnecessaryBendpoints"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Xft),""),"North or South Port"),"Specifies that this port can either be placed on the north side of a node or on the south side (if port constraints permit)"),!1),Ec),ho),qe(tb)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.northOrSouthPort"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,oY),"cycleBreaking"),"Cycle Breaking Strategy"),"Strategy for cycle breaking. Cycle breaking looks for cycles in the graph and determines which edges to reverse to break the cycles. Reversed edges will end up pointing to the opposite direction of regular edges (that is, reversed edges will point left if edges usually point right)."),mmt),xs),F0t),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.cycleBreaking"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,QP),pdt),"Node Layering Strategy"),"Strategy for node layering."),Mmt),xs),ybt),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.nodeLayering"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Zft),pdt),"Layer Constraint"),"Determines a constraint on the placement of the node regarding the layering."),ymt),xs),lmt),qe(vc)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.layerConstraint"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Yft),pdt),"Wide Nodes on Multiple Layers"),"Strategy to distribute wide nodes over multiple layers."),Emt),xs),Nbt),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.wideNodesOnMultipleLayers"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,cY),SBt),"Upper Bound On Width [MinWidth Layerer]"),"Defines a loose upper bound on the width of the MinWidth layerer. If set to '-1' multiple values are tested and the best result is selected."),Xt(4)),Pa),Io),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.minWidthUpperBoundOnWidth"])))),Sa(e,cY,QP,YHt),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,aY),SBt),"Upper Layer Estimation Scaling Factor [MinWidth Layerer]"),"Multiplied with Upper Bound On Width for defining an upper bound on the width of layers which haven't been determined yet, but whose maximum width had been (roughly) estimated by the MinWidth algorithm. Compensates for too high estimations. If set to '-1' multiple values are tested and the best result is selected."),Xt(2)),Pa),Io),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.minWidthUpperLayerEstimationScalingFactor"])))),Sa(e,aY,QP,JHt),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,uY),TBt),"Node Promotion Strategy"),"Reduces number of dummy nodes after layering phase (if possible)."),xmt),xs),Abt),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.nodePromotion"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,lY),TBt),"Max Node Promotion Iterations"),"Limits the number of iterations for node promotion."),Xt(0)),Pa),Io),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.nodePromotionBoundary"])))),Sa(e,lY,uY,null),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,hY),"layering.coffmanGraham"),"Layer Bound"),"The maximum number of nodes allowed per layer."),Xt(qi)),Pa),Io),qe(On)))),Sa(e,hY,QP,qHt),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,fY),gdt),"Crossing Minimization Strategy"),"Strategy for crossing minimization."),gmt),xs),D0t),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.crossMin"])))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Kft),gdt),"Hierarchical Sweepiness"),"How likely it is to use cross-hierarchy (1) vs bottom-up (-1)."),.1),ha),To),qe(On)))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Jft),gdt),"Semi-Interactive Crossing Minimization"),"Preserves the order of nodes within a layer but still minimizes crossings between edges connecting long edge dummies. Derives the desired order from positions specified by the 'org.eclipse.elk.position' layout option. Requires a crossing minimization strategy that is able to process 'in-layer' constraints."),!1),Ec),ho),qe(On)))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Qft),CBt),"Greedy Switch Activation Threshold"),"By default it is decided automatically if the greedy switch is activated or not. The decision is based on whether the size of the input graph (without dummy nodes) is smaller than the value of this option. A '0' enforces the activation."),Xt(40)),Pa),Io),qe(On)))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,tdt),CBt),"Greedy Switch Crossing Minimization"),"Greedy Switch strategy for crossing minimization. The greedy switch heuristic is executed after the regular layer sweep as a post-processor."),pmt),xs),K0t),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.greedySwitch"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,fE),ABt),"Node Placement Strategy"),"Strategy for node placement."),Amt),xs),Mbt),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.nodePlace"])))),He(e,new De(ze(Ue(je(Ne(Fe(Oe(Be(new Ie,dY),ABt),"Favor Straight Edges Over Balancing"),"Favor straight edges over a balanced node placement. The default behavior is determined automatically based on the used 'edgeRouting'. For an orthogonal style it is set to true, for all other styles to false."),Ec),ho),qe(On)))),Sa(e,dY,fE,lGt),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,pY),kBt),"BK Edge Straightening"),"Specifies whether the Brandes Koepf node placer tries to increase the number of straight edges at the expense of diagram size. There is a subtle difference to the 'favorStraightEdges' option, which decides whether a balanced placement of the nodes is desired, or not. In bk terms this means combining the four alignments into a single balanced one, or not. This option on the other hand tries to straighten additional edges during the creation of each of the four alignments."),Smt),xs),zbt),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.nodeplace.compactionStrategy"])))),Sa(e,pY,fE,oGt),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,gY),kBt),"BK Fixed Alignment"),"Tells the BK node placer to use a certain alignment (out of its four) instead of the one producing the smallest height, or the combination of all four."),Tmt),xs),W0t),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.fixedAlignment"])))),Sa(e,gY,fE,aGt),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,mY),"nodePlacement.linearSegments"),"Linear Segments Deflection Dampening"),"Dampens the movement of nodes to keep the diagram from getting too large."),.3),ha),To),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.linearSegmentsDeflectionDampening"])))),Sa(e,mY,fE,fGt),He(e,new De(ze(Ue(je(Ne(Fe(Oe(Be(new Ie,bY),"nodePlacement.networkSimplex"),"Node Flexibility"),"Aims at shorter and straighter edges. Two configurations are possible: (a) allow ports to move freely on the side they are assigned to (the order is always defined beforehand), (b) additionally allow to enlarge a node wherever it helps. If this option is not configured for a node, the 'nodeFlexibility.default' value is used, which is specified for the node's parent."),xs),YJ),qe(vc)))),Sa(e,bY,fE,gGt),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,edt),"nodePlacement.networkSimplex.nodeFlexibility"),"Node Flexibility Default"),"Default value of the 'nodeFlexibility' option for the children of a hierarchical node."),Cmt),xs),YJ),qe(On)))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,wY),mdt),"Spline Self-Loop Placement"),null),vmt),xs),Pbt),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.splines.selfLoopPlacement"])))),Sa(e,wY,t6,DHt),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,fO),mdt),"Sloppy Spline Routing"),"Use less spline control points at the start and end of an edge. Might lead to crossings edge/node overlap."),!0),Ec),ho),qe(On)))),Sa(e,fO,t6,FHt),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,dO),mdt),"Sloppy Spline Layer Spacing Factor"),"Spacing factor for routing area between layers when using sloppy spline routing."),.4),ha),To),qe(On)))),Sa(e,dO,t6,OHt),Sa(e,dO,fO,!0),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,ndt),K1),"Edge Node Between Layers Spacing"),"The spacing to be preserved between nodes and edges that are routed next to the node's layer. For the spacing between nodes and edges that cross the node's layer 'spacing.edgeNode' is used."),10),ha),To),qe(On)))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,idt),K1),"Edge Edge Between Layer Spacing"),"Spacing to be preserved between pairs of edges that are routed between the same pair of layers. Note that 'spacing.edgeEdge' is used for the spacing between pairs of edges crossing the same layer."),10),ha),To),qe(On)))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,rdt),K1),"Node Node Between Layers Spacing"),"The spacing to be preserved between any pair of nodes of two adjacent layers. Note that 'spacing.nodeNode' is used for the spacing between nodes within the layer itself."),20),ha),To),qe(On)))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,sdt),bdt),"Direction Priority"),"Defines how important it is to have a certain edge point into the direction of the overall layout. This option is evaluated during the cycle breaking phase."),Xt(0)),Pa),Io),qe(Md)))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,odt),bdt),"Shortness Priority"),"Defines how important it is to keep an edge as short as possible. This option is evaluated during the layering phase."),Xt(0)),Pa),Io),qe(Md)))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,cdt),bdt),"Straightness Priority"),"Defines how important it is to keep an edge straight, i.e. aligned with one of the two axes. This option is evaluated during node placement."),Xt(0)),Pa),Io),qe(Md)))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,vY),"compaction"),tBt),"Tries to further compact components (disconnected sub-graphs)."),!1),Ec),ho),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.components.compact"])))),Sa(e,vY,XP,!0),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,adt),LBt),"Post Compaction Strategy"),PBt),fmt),xs),Y0t),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.postCompaction"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,udt),LBt),"Post Compaction Constraint Calculation"),PBt),hmt),xs),P0t),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.postCompaction.constraints"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,pO),wdt),"High Degree Node Treatment"),"Makes room around high degree nodes to place leafs and trees."),!1),Ec),ho),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.highDegreeNode.treatment"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,_Y),wdt),"High Degree Node Threshold"),"Whether a node is considered to have a high degree."),Xt(16)),Pa),Io),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.highDegreeNode.threshold"])))),Sa(e,_Y,pO,!0),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,yY),wdt),"High Degree Node Maximum Tree Height"),"Maximum height of a subtree connected to a high degree node to be moved to separate layers."),Xt(5)),Pa),Io),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.highDegreeNode.treeHeight"])))),Sa(e,yY,pO,!0),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,b4),vdt),"Graph Wrapping Strategy"),"For certain graphs and certain prescribed drawing areas it may be desirable to split the laid out graph into chunks that are placed side by side. The edges that connect different chunks are 'wrapped' around from the end of one chunk to the start of the other chunk. The points between the chunks are referred to as 'cuts'."),Imt),xs),Obt),qe(On)))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,ldt),vdt),"Additional Wrapped Edges Spacing"),"To visually separate edges that are wrapped from regularly routed edges an additional spacing value can be specified in form of this layout option. The spacing is added to the regular edgeNode spacing."),10),ha),To),qe(On)))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,hdt),vdt),"Correction factor for the wrapping"),"At times and for certain types of graphs the executed wrapping may produce results that are consistently biased in the same fashion: either wrapping to often or to rarely. This factor can be used to correct the bias. Internally, it is simplay multiplied with the 'aspect ratio' layout option."),1),ha),To),qe(On)))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,gO),IBt),"Cutting Strategy"),"The strategy by which the layer indexes are determined at which the layering crumbles into chunks."),Lmt),xs),O0t),qe(On)))),He(e,new De(ze(Ue(je(Ne(Fe(Oe(Be(new Ie,xY),IBt),"Manually Specified Cuts"),"Allows the user to specify her own cuts for a certain graph."),Ed),Sl),qe(On)))),Sa(e,xY,gO,kGt),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,MY),"wrapping.cutting.msd"),"MSD Freedom"),"The MSD cutting strategy starts with an initial guess on the number of chunks the graph should be split into. The freedom specifies how much the strategy may deviate from this guess. E.g. if an initial number of 3 is computed, a freedom of 1 allows 2, 3, and 4 cuts."),kmt),Pa),Io),qe(On)))),Sa(e,MY,gO,PGt),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,EY),"wrapping.singleEdge.validify"),"Path-Like Validify Strategy"),"When wrapping path-like graphs, the graph must not be split between any pair of layers. The validify strategy makes sure every computed split point is allowed."),Pmt),xs),Dbt),qe(On)))),Sa(e,EY,b4,zGt),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,mO),_dt),"Improve Cuts"),"For general graphs it is important that not too many edges wrap backwards. Thus a compromise between evenly-distributed cuts and the total number of cut edges is sought."),!0),Ec),ho),qe(On)))),Sa(e,mO,b4,OGt),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,bO),_dt),"Distance Penalty When Improving Cuts"),null),2),ha),To),qe(On)))),Sa(e,bO,b4,DGt),Sa(e,bO,mO,!0),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,SY),_dt),"Improve Wrapped Edges"),"The initial wrapping is performed in a very simple way. As a consequence, edges that wrap from one chunk to another may be unnecessarily long. Activating this option tries to shorten such edges."),!0),Ec),ho),qe(On)))),Sa(e,SY,b4,FGt),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,fdt),TY),"Edge Label Side Selection"),"Method to decide on edge label sides."),wmt),xs),U0t),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.klay.layered.edgeLabelSideSelection"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,ddt),TY),"Edge Center Label Placement Strategy"),"Determines in which layer center labels of long edges should be placed."),bmt),xs),k0t),ur(On,Y(Z(Jp,1),jt,163,0,[sg]))),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.edgeLabelPlacementStrategy"])))),hOt((new b8,e))};var yHt,xHt,hmt,MHt,fmt,EHt,dmt,SHt,THt,pmt,CHt,AHt,kHt,gmt,LHt,mmt,PHt,bmt,IHt,wmt,RHt,vmt,DHt,NHt,OHt,BHt,FHt,UHt,zHt,jHt,HHt,GHt,_mt,WHt,$Ht,VHt,qHt,XHt,ymt,ZHt,YHt,KHt,JHt,QHt,tGt,xmt,eGt,Mmt,nGt,Emt,iGt,rGt,sGt,Smt,oGt,cGt,Tmt,aGt,uGt,lGt,hGt,fGt,dGt,pGt,Cmt,gGt,mGt,Amt,bGt,wGt,vGt,_Gt,yGt,xGt,MGt,EGt,SGt,TGt,CGt,AGt,kGt,LGt,kmt,PGt,IGt,Lmt,RGt,DGt,NGt,OGt,BGt,FGt,UGt,Pmt,zGt,jGt,Imt,MUe=A(ka,"LayeredMetaDataProvider",747);T(878,1,_d,b8),u.ue=function(e){hOt(e)};var Bf,zB,$4,BJ,Rmt,jB,FJ,Dmt,HB,Nmt,UJ,IE,Omt,V4,ch,Bmt,GB,Fmt,eg,q4,ng,Umt,zmt,jmt,WB,up,I6,X4,Hmt,Gmt,Wmt,$B,J_,_w,$mt,Ro,Vmt,la,qmt,Xmt,Zmt,zJ,Ymt,R6,VB,Kmt,Jmt,Oh,Qmt,jJ,Z4,tbt,Zm,Y4,qB,yw,RE,XB,HJ,w0,ebt,nbt,ibt,rbt,sbt,HGt,GGt,WGt,$Gt,xw,Mw,Qi,v0,obt,yx,K4,Ew,VGt,D6,cbt,xx,qGt,XGt,GJ,nf,Mx,N6,_0,Q_,ZB,Ex,abt,J4,lp,Sw,WJ,Q4,O6,$J,ubt,lbt,hbt,fbt,VJ,dbt,pbt,gbt,mbt,bbt,EUe=A(ka,"LayeredOptions",878);T(879,1,{},Ck),u.Be=function(){var e;return e=new _u,e},u.Ce=function(e){};var SUe=A(ka,"LayeredOptions/LayeredFactory",879);T(291,23,{3:1,34:1,23:1,291:1,285:1,286:1},RT),u.hf=function(){return lDt(this)},u.uf=function(){return lDt(this)};var qJ,wbt,vbt,YB,XJ,_bt,ybt=Ri(ka,"LayeringStrategy",291,ji,Fae,iie),ZGt;T(179,23,{3:1,34:1,23:1,179:1},U9);var ty,ey,KB,ZJ,YJ=Ri(ka,"NodeFlexibility",179,ji,Oce,rie),YGt;T(292,23,{3:1,34:1,23:1,292:1,285:1,286:1},z5),u.hf=function(){return q9t(this)},u.uf=function(){return q9t(this)};var B6,KJ,JJ,F6,xbt,Mbt=Ri(ka,"NodePlacementStrategy",292,ji,eae,sie),KGt;T(240,23,{3:1,34:1,23:1,240:1},d2);var Ebt,U6,Sbt,Tbt,z6,Cbt,JB,QB,Abt=Ri(ka,"NodePromotionStrategy",240,ji,Mue,oie),JGt;T(410,23,{3:1,34:1,23:1,410:1},aW);var Ga,ba,tF,QGt=Ri(ka,"PortType",410,ji,Foe,cie),tWt;T(345,23,{3:1,34:1,23:1,345:1},uW);var kbt,Lbt,QJ,Pbt=Ri(ka,"SelfLoopPlacement",345,ji,Uoe,aie),eWt;T(266,1,{266:1},B8t);var TUe=A(ka,"Spacings",266);T(347,23,{3:1,34:1,23:1,347:1},lW);var tQ,Ibt,Rbt,Dbt=Ri(ka,"ValidifyStrategy",347,ji,zoe,uie),nWt;T(385,23,{3:1,34:1,23:1,385:1},hW);var j6,H6,G6,Nbt=Ri(ka,"WideNodesStrategy",385,ji,Hoe,lie),iWt;T(346,23,{3:1,34:1,23:1,346:1},fW);var W6,eQ,nQ,Obt=Ri(ka,"WrappingStrategy",346,ji,joe,hie),rWt;T(1296,1,Lu,NMt),u.vf=function(e){return a(e,31),sWt},u.Pe=function(e,n){y2e(this,a(e,31),n)};var sWt,CUe=A(tpt,"DepthFirstCycleBreaker",1296);T(1295,1,Lu,ACt),u.vf=function(e){return a(e,31),oWt},u.Pe=function(e,n){s3e(this,a(e,31),n)};var oWt,AUe=A(tpt,"GreedyCycleBreaker",1295);T(1297,1,Lu,s5),u.vf=function(e){return a(e,31),cWt},u.Pe=function(e,n){Sye(this,a(e,31),n)};var cWt,kUe=A(tpt,"InteractiveCycleBreaker",1297);T(1300,1,Lu,OMt),u.vf=function(e){return a(e,31),aWt},u.Pe=function(e,n){t3e(this,a(e,31),n)};var aWt,LUe=A(hw,"CoffmanGrahamLayerer",1300);T(1301,1,jr,Mp),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return W0e(this.a,a(e,8),a(n,8))};var PUe=A(hw,"CoffmanGrahamLayerer/lambda$0$Type",1301);T(1302,1,jr,J8),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return Tre(this.a,e,n)};var IUe=A(hw,"CoffmanGrahamLayerer/lambda$1$Type",1302);T(1303,1,Lu,$0),u.vf=function(e){return a(e,31),Ni(Ni(new as,(Mo(),Of),(Po(),nJ)),aa,CE)},u.Pe=function(e,n){lxe(this,a(e,31),n)};var RUe=A(hw,"InteractiveLayerer",1303);T(511,1,{511:1},axt),u.a=0,u.c=0;var DUe=A(hw,"InteractiveLayerer/LayerSpan",511);T(1299,1,Lu,m8),u.vf=function(e){return Sfe(a(e,31))},u.Pe=function(e,n){twe(this,a(e,31),n)};var uWt,lWt,hWt,NUe=A(hw,"LongestPathLayerer",1299);T(1306,1,Lu,w8),u.vf=function(e){return a(e,31),Ni(Ni(new as,(Mo(),Of),(Po(),F4)),aa,CE)},u.Pe=function(e,n){Dxe(this,a(e,31),n)},u.a=0,u.b=0,u.d=0;var Bbt,Fbt,OUe=A(hw,"MinWidthLayerer",1306);T(1307,1,jr,Ac),u.Ld=function(e,n){return ple(this,a(e,8),a(n,8))},u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)};var BUe=A(hw,"MinWidthLayerer/MinOutgoingEdgesComparator",1307);T(1298,1,Lu,JEt),u.vf=function(e){return Epe(this,a(e,31))},u.Pe=function(e,n){V_e(this,a(e,31),n)};var fWt,dWt,pWt,FUe=A(hw,"NetworkSimplexLayerer",1298);T(1304,1,Lu,aTt),u.vf=function(e){return a(e,31),Ni(Ni(new as,(Mo(),Of),(Po(),F4)),aa,CE)},u.Pe=function(e,n){F2e(this,a(e,31),n)},u.d=0,u.f=0,u.g=0,u.i=0,u.s=0,u.t=0,u.u=0;var UUe=A(hw,"StretchWidthLayerer",1304);T(1305,1,jr,dv),u.Ld=function(e,n){return mae(a(e,8),a(n,8))},u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)};var zUe=A(hw,"StretchWidthLayerer/1",1305);T(422,1,ept),u.lf=function(e,n,i,r,c,l){},u.xf=function(e,n,i){return RNt(this,e,n,i)},u.kf=function(){this.g=dt(zw,NBt,22,this.d,15,1),this.f=dt(zw,NBt,22,this.d,15,1)},u.mf=function(e,n){this.e[e]=dt(Gn,pi,22,n[e].length,15,1)},u.nf=function(e,n,i){var r;r=i[e][n],r.o=n,this.e[e][n]=n},u.of=function(e,n,i,r){a(Ee(r[e][n].i,i),11).o=this.d++},u.b=0,u.c=0,u.d=0;var jUe=A(Ju,"AbstractBarycenterPortDistributor",422);T(1484,1,jr,MH),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return Kfe(this.a,e,n)};var HUe=A(Ju,"AbstractBarycenterPortDistributor/lambda$0$Type",1484);T(1532,1,JP,tkt),u.lf=function(e,n,i,r,c,l){},u.nf=function(e,n,i){},u.of=function(e,n,i,r){},u.jf=function(){return!1},u.kf=function(){this.a=this.c.a,this.e=this.d.g},u.mf=function(e,n){n[e][0].c.o=e},u.pf=function(){return!1},u.qf=function(e,n,i,r){var c,l,f,g,b,v,M;for(n!=uSt(i,e.length)&&(l=e[n-(i?1:-1)],Lct(this.d,l,i?(Fo(),ba):(Fo(),Ga))),c=e[n][0],M=!r||c.j==(Ke(),rs),v=$g(e[n]),R6t(this,v,M,!1,i),f=0,b=new H(v);b.a"),e0?q$(this.a,e[n-1],e[n]):!i&&n1&&(c.i==(Ht(),Qe)?this.b[e]=!0:c.i==on&&e>0&&(this.b[e-1]=!0))},u.f=0;var oze=A(l0,"AllCrossingsCounter",1528);T(602,1,{},FV),u.b=0,u.d=0;var cze=A(l0,"BinaryIndexedTree",602);T(473,1,{},X5);var aze=A(l0,"CrossingsCounter",473);T(1557,1,jr,CH),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return pre(this.a,e,n)};var uze=A(l0,"CrossingsCounter/lambda$0$Type",1557);T(1558,1,jr,AH),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return gre(this.a,e,n)};var lze=A(l0,"CrossingsCounter/lambda$1$Type",1558);T(1559,1,jr,kH),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return mre(this.a,e,n)};var hze=A(l0,"CrossingsCounter/lambda$2$Type",1559);T(1560,1,jr,LH),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return bre(this.a,e,n)};var fze=A(l0,"CrossingsCounter/lambda$3$Type",1560);T(1555,1,{},PH);var dze=A(l0,"HyperedgeCrossingsCounter",1555);T(426,1,{34:1,426:1},uTt),u.vd=function(e){return Hfe(this,a(e,426))},u.b=0,u.c=0,u.e=0,u.f=0;var B3e=A(l0,"HyperedgeCrossingsCounter/Hyperedge",426);T(336,1,{34:1,336:1},XD),u.vd=function(e){return jme(this,a(e,336))},u.b=0,u.c=0;var xWt=A(l0,"HyperedgeCrossingsCounter/HyperedgeCorner",336);T(472,23,{3:1,34:1,23:1,472:1},hrt);var eA,nA,MWt=Ri(l0,"HyperedgeCrossingsCounter/HyperedgeCorner/Type",472,ji,foe,die),EWt;T(1556,1,{},GH),u.e=!0,u.f=0,u.g=0;var pze=A(l0,"NorthSouthEdgeAllCrossingsCounter",1556);T(1311,1,Lu,v8),u.vf=function(e){return a(z(a(e,31),(Ft(),Qc)),19).pc((So(),Al))?SWt:null},u.Pe=function(e,n){Wpe(this,a(e,31),n)};var SWt,gze=A(lo,"InteractiveNodePlacer",1311);T(1312,1,Lu,p1),u.vf=function(e){return a(z(a(e,31),(Ft(),Qc)),19).pc((So(),Al))?TWt:null},u.Pe=function(e,n){jde(this,a(e,31),n)};var TWt,iF,rF,mze=A(lo,"LinearSegmentsNodePlacer",1312);T(235,1,{34:1,235:1},dit),u.vd=function(e){return WQt(this,a(e,235))},u.Fb=function(e){var n;return ct(e,235)?(n=a(e,235),this.b==n.b):!1},u.Hb=function(){return this.b},u.Ib=function(){return"ls"+Gp(this.f)},u.a=0,u.b=0,u.c=-1,u.d=-1,u.i=0;var CWt=A(lo,"LinearSegmentsNodePlacer/LinearSegment",235);T(1314,1,Lu,y4t),u.vf=function(e){return a(z(a(e,31),(Ft(),Qc)),19).pc((So(),Al))?AWt:null},u.Pe=function(e,n){Xxe(this,a(e,31),n)},u.b=0,u.g=0;var AWt,bze=A(lo,"NetworkSimplexPlacer",1314);T(1333,1,jr,Sg),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return Lp(a(e,21).a,a(n,21).a)};var wze=A(lo,"NetworkSimplexPlacer/0methodref$compare$Type",1333);T(1335,1,jr,pc),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return Lp(a(e,21).a,a(n,21).a)};var vze=A(lo,"NetworkSimplexPlacer/1methodref$compare$Type",1335);T(584,1,{584:1},kMt);var F3e=A(lo,"NetworkSimplexPlacer/EdgeRep",584);T(416,1,{416:1},Uot),u.b=!1;var U3e=A(lo,"NetworkSimplexPlacer/NodeRep",416);T(460,12,{3:1,4:1,20:1,25:1,41:1,12:1,13:1,15:1,49:1,460:1},fxt);var _ze=A(lo,"NetworkSimplexPlacer/Path",460);T(1315,1,ys,vb),u.Kb=function(e){return a(e,14).d.g.j};var yze=A(lo,"NetworkSimplexPlacer/Path/lambda$0$Type",1315);T(1316,1,us,Hy),u.Nb=function(e){return a(e,232)==(Ke(),Hr)};var xze=A(lo,"NetworkSimplexPlacer/Path/lambda$1$Type",1316);T(1317,1,ys,E3),u.Kb=function(e){return a(e,14).d.g};var Mze=A(lo,"NetworkSimplexPlacer/Path/lambda$2$Type",1317);T(1318,1,us,IH),u.Nb=function(e){return ZSt(kIt(a(e,8)))};var Eze=A(lo,"NetworkSimplexPlacer/Path/lambda$3$Type",1318);T(1319,1,us,fv),u.Nb=function(e){return Mu(),(Ht(),sb).pc(a(e,11).i)};var Sze=A(lo,"NetworkSimplexPlacer/lambda$0$Type",1319);T(1320,1,{},LMt),u.td=function(e){Zte(this.a,this.b,e)};var Tze=A(lo,"NetworkSimplexPlacer/lambda$1$Type",1320);T(1329,1,{},RH),u.td=function(e){y0e(this.a,e)};var Cze=A(lo,"NetworkSimplexPlacer/lambda$10$Type",1329);T(1330,1,ys,Ak),u.Kb=function(e){return Mu(),new gi(null,new Ei(a(e,26).a,16))};var Aze=A(lo,"NetworkSimplexPlacer/lambda$11$Type",1330);T(1331,1,{},DH),u.td=function(e){Pwe(this.a,e)};var kze=A(lo,"NetworkSimplexPlacer/lambda$12$Type",1331);T(1332,1,ys,h1),u.Kb=function(e){return Mu(),Xt(a(e,113).e)};var Lze=A(lo,"NetworkSimplexPlacer/lambda$13$Type",1332);T(1334,1,ys,RS),u.Kb=function(e){return Mu(),Xt(a(e,113).e)};var Pze=A(lo,"NetworkSimplexPlacer/lambda$14$Type",1334);T(1336,1,us,S3),u.Nb=function(e){return Mu(),a(e,416).c.j==(Ke(),gs)};var Ize=A(lo,"NetworkSimplexPlacer/lambda$15$Type",1336);T(1337,1,us,T3),u.Nb=function(e){return Mu(),a(e,416).c.i.c.length>1};var Rze=A(lo,"NetworkSimplexPlacer/lambda$16$Type",1337);T(1338,1,{},b4t),u.td=function(e){vfe(this.c,this.b,this.d,this.a,e)},u.c=0,u.d=0;var Dze=A(lo,"NetworkSimplexPlacer/lambda$17$Type",1338);T(1339,1,{},NH),u.td=function(e){aee(this.a,e)},u.a=0;var Nze=A(lo,"NetworkSimplexPlacer/lambda$18$Type",1339);T(1340,1,ys,Wy),u.Kb=function(e){return Mu(),new gi(null,new Ei(a(e,26).a,16))};var Oze=A(lo,"NetworkSimplexPlacer/lambda$19$Type",1340);T(1321,1,ys,C3),u.Kb=function(e){return Mu(),new gi(null,new Ei(a(e,26).a,16))};var Bze=A(lo,"NetworkSimplexPlacer/lambda$2$Type",1321);T(1341,1,{},v5),u.td=function(e){_ee(this.a,e)};var Fze=A(lo,"NetworkSimplexPlacer/lambda$20$Type",1341);T(1342,1,us,_b),u.Nb=function(e){return ZSt(e)};var Uze=A(lo,"NetworkSimplexPlacer/lambda$21$Type",1342);T(1343,1,ys,Cg),u.Kb=function(e){return Mu(),new gi(null,new Ei(a(e,26).a,16))};var zze=A(lo,"NetworkSimplexPlacer/lambda$22$Type",1343);T(1344,1,us,OH),u.Nb=function(e){return Pte(this.a,e)};var jze=A(lo,"NetworkSimplexPlacer/lambda$23$Type",1344);T(1345,1,{},PMt),u.td=function(e){V1e(this.a,this.b,e)};var Hze=A(lo,"NetworkSimplexPlacer/lambda$24$Type",1345);T(1346,1,us,gv),u.Nb=function(e){return Mu(),!ec(a(e,14))};var Gze=A(lo,"NetworkSimplexPlacer/lambda$25$Type",1346);T(1347,1,us,DS),u.Nb=function(e){return Mu(),!ec(a(e,14))};var Wze=A(lo,"NetworkSimplexPlacer/lambda$26$Type",1347);T(1348,1,{},_5),u.le=function(e,n){return cee(this.a,e,n)};var $ze=A(lo,"NetworkSimplexPlacer/lambda$27$Type",1348);T(1322,1,ys,kk),u.Kb=function(e){return Mu(),new gi(null,new y2(Rn(br(a(e,8)))))};var Vze=A(lo,"NetworkSimplexPlacer/lambda$3$Type",1322);T(1323,1,us,NS),u.Nb=function(e){return Mu(),mce(a(e,14))};var qze=A(lo,"NetworkSimplexPlacer/lambda$4$Type",1323);T(1324,1,{},BH),u.td=function(e){l_e(this.a,a(e,14))};var Xze=A(lo,"NetworkSimplexPlacer/lambda$5$Type",1324);T(1325,1,ys,mv),u.Kb=function(e){return Mu(),new gi(null,new Ei(a(e,26).a,16))};var Zze=A(lo,"NetworkSimplexPlacer/lambda$6$Type",1325);T(1326,1,us,$y),u.Nb=function(e){return Mu(),a(e,8).j==(Ke(),gs)};var Yze=A(lo,"NetworkSimplexPlacer/lambda$7$Type",1326);T(1327,1,ys,w),u.Kb=function(e){return Mu(),new gi(null,new y2(Rn(Kg(a(e,8)))))};var Kze=A(lo,"NetworkSimplexPlacer/lambda$8$Type",1327);T(1328,1,us,E),u.Nb=function(e){return Mu(),hre(a(e,14))};var Jze=A(lo,"NetworkSimplexPlacer/lambda$9$Type",1328);T(1310,1,Lu,yv),u.vf=function(e){return a(z(a(e,31),(Ft(),Qc)),19).pc((So(),Al))?kWt:null},u.Pe=function(e,n){j_e(a(e,31),n)};var kWt,Qze=A(lo,"SimpleNodePlacer",1310);T(164,1,{164:1},E_),u.Ib=function(){var e;return e="",this.c==(Sf(),Ym)?e+=hE:this.c==Xp&&(e+=lE),this.o==(Zh(),y0)?e+=PY:this.o==rf?e+="UP":e+="BALANCED",e};var tje=A($p,"BKAlignedLayout",164);T(466,23,{3:1,34:1,23:1,466:1},frt);var Xp,Ym,LWt=Ri($p,"BKAlignedLayout/HDirection",466,ji,uoe,bie),PWt;T(465,23,{3:1,34:1,23:1,465:1},drt);var y0,rf,IWt=Ri($p,"BKAlignedLayout/VDirection",465,ji,loe,wie),RWt;T(1485,1,{},IMt);var eje=A($p,"BKAligner",1485);T(1488,1,{},YRt);var nje=A($p,"BKCompactor",1488);T(593,1,{593:1},q),u.a=0;var ije=A($p,"BKCompactor/ClassEdge",593);T(423,1,{423:1},uxt),u.a=null,u.b=0;var rje=A($p,"BKCompactor/ClassNode",423);T(1313,1,Lu,BMt),u.vf=function(e){return a(z(a(e,31),(Ft(),Qc)),19).pc((So(),Al))?DWt:null},u.Pe=function(e,n){u3e(this,a(e,31),n)},u.a=!1,u.e=!1;var DWt,sje=A($p,"BKNodePlacer",1313);T(437,23,{3:1,34:1,23:1,437:1},prt);var sF,Ubt,zbt=Ri($p,"EdgeStraighteningStrategy",437,ji,aoe,vie),NWt;T(1486,1,{},st),u.d=0;var oje=A($p,"NeighborhoodInformation",1486);T(1487,1,jr,FH),u.Ld=function(e,n){return pue(this,a(e,48),a(n,48))},u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)};var cje=A($p,"NeighborhoodInformation/NeighborComparator",1487);T(724,1,{});var aje=A($p,"ThresholdStrategy",724);T(1510,724,{},mxt),u.yf=function(e,n,i){return this.a.o==(Zh(),rf)?is:Ps},u.zf=function(){};var uje=A($p,"ThresholdStrategy/NullThresholdStrategy",1510);T(522,1,{522:1},DMt),u.c=!1,u.d=!1;var lje=A($p,"ThresholdStrategy/Postprocessable",522);T(1511,724,{},bxt),u.yf=function(e,n,i){var r,c,l;return c=n==i,r=this.a.a[i.o]==n,c||r?(l=e,this.a.c==(Sf(),Ym)?(c&&(l=JX(this,n,!0)),!isNaN(l)&&!isFinite(l)&&r&&(l=JX(this,i,!1))):(c&&(l=JX(this,n,!0)),!isNaN(l)&&!isFinite(l)&&r&&(l=JX(this,i,!1))),l):e},u.zf=function(){for(var e,n,i,r,c;this.c.b!=0;)c=a(boe(this.c),522),r=GNt(this,c),r.a&&(e=r.a,i=lt(this.a.f[this.a.g[c.b.o].o]),!(!i&&!ec(e)&&e.c.g.c==e.d.g.c)&&(n=Y9t(this,c),n||REt(this.d,c)));for(;this.d.a.c.length!=0;)Y9t(this,a(Bat(this.d),522))};var hje=A($p,"ThresholdStrategy/SimpleThresholdStrategy",1511);T(573,1,{573:1,285:1,286:1},vt),u.hf=function(){return VPt(this)},u.uf=function(){return VPt(this)};var iQ,fje=A(D_,"EdgeRouterFactory",573);T(1356,1,Lu,pj),u.vf=function(e){return owe(a(e,31))},u.Pe=function(e,n){oye(a(e,31),n)};var OWt,BWt,FWt,UWt,zWt,jbt,jWt,HWt,dje=A(D_,"OrthogonalEdgeRouter",1356);T(594,1,{},aX),u.a=0,u.c=0;var pje=A(D_,"OrthogonalRoutingGenerator",594);T(252,1,{252:1},SN),u.Ib=function(){return this.a+"->"+this.b},u.c=0;var gje=A(D_,"OrthogonalRoutingGenerator/Dependency",252);T(165,1,{34:1,165:1},QPt),u.vd=function(e){return $Qt(this,a(e,165))},u.Fb=function(e){var n;return ct(e,165)?(n=a(e,165),this.d==n.d):!1},u.Hb=function(){return this.d},u.Ib=function(){var e,n,i,r;for(e=new ll("{"),r=new H(this.g);r.aop&&(c=new We(b,k),Xi(i.a,c),CP(this.a,i,e,c,!1),l=new We(M,k),Xi(i.a,l),CP(this.a,i,e,l,!1))},u.Bf=function(e){return e.g.k.a+e.k.a+e.a.a},u.Cf=function(){return Ht(),fi},u.Df=function(){return Ht(),Tn};var bje=A(D_,"OrthogonalRoutingGenerator/NorthToSouthRoutingStrategy",1490);T(1491,1,{},Hl),u.Af=function(e,n){var i,r,c,l,f,g,b,v,M,k;for(k=n-e.i*this.a.c,g=new H(e.g);g.aop&&(c=new We(b,k),Xi(i.a,c),CP(this.a,i,e,c,!1),l=new We(M,k),Xi(i.a,l),CP(this.a,i,e,l,!1))},u.Bf=function(e){return e.g.k.a+e.k.a+e.a.a},u.Cf=function(){return Ht(),Tn},u.Df=function(){return Ht(),fi};var wje=A(D_,"OrthogonalRoutingGenerator/SouthToNorthRoutingStrategy",1491);T(1489,1,{},ed),u.Af=function(e,n){var i,r,c,l,f,g,b,v,M,k;for(k=n+e.i*this.a.c,g=new H(e.g);g.aop&&(c=new We(k,b),Xi(i.a,c),CP(this.a,i,e,c,!0),l=new We(k,M),Xi(i.a,l),CP(this.a,i,e,l,!0))},u.Bf=function(e){return e.g.k.b+e.k.b+e.a.b},u.Cf=function(){return Ht(),Qe},u.Df=function(){return Ht(),on};var vje=A(D_,"OrthogonalRoutingGenerator/WestToEastRoutingStrategy",1489);T(1351,1,Lu,FMt),u.vf=function(e){return Rge(a(e,31))},u.Pe=function(e,n){cxe(this,a(e,31),n)};var GWt,WWt,$Wt,VWt,oF,_je=A(D_,"PolylineEdgeRouter",1351);T(1352,1,sh,D),u.Mb=function(e){return wle(a(e,8))},u.Fb=function(e){return this===e},u.Nb=function(e){return this.Mb(e)};var yje=A(D_,"PolylineEdgeRouter/1",1352);T(151,1,{151:1},G6t),u.Ib=function(){var e,n,i,r;for(i=new im,this.e&&Ii(Ii(i,Q5(this.e)),": "),n=qn(G$(this),0);n.b!=n.d.c;)e=a(Yn(n),11),Ii(Ii(E1(Ii(i,(r=Qkt(e),r==null?"p_"+e.o:"p_"+r)),32),Q5(e.i))," / ");return I9(i,i.a.length-2-1)},u.j=0,u.k=0;var xje=A(h0,"ConnectedSelfLoopComponent",151);T(129,23,{3:1,34:1,23:1,129:1},C1),u.c=0;var qWt,XWt,ZWt,Km,Tw,Zp,Cw,ig,hp,Yp,Jm,Qm,YWt,KWt,JWt,QWt,t$t,e$t,n$t,i$t,r$t,s$t,o$t,c$t,a$t,ny,Sx,Aw,kw,iA=Ri(h0,"LoopSide",129,ji,KV,_ie),u$t;T(424,1,{},PIt,kht,_ut),u.Ib=function(){return this.b.Ib()},u.c=0,u.d=!1,u.e=!1,u.f=!1,u.i=0,u.j=0;var Mje=A(h0,"NubSpline",424);T(190,1,{190:1},ODt,W$);var Eje=A(h0,"NubSpline/PolarCP",190);T(599,424,{},O$);var Sje=A(h0,"NubsSelfLoop",599);T(236,1,{},Y8t,mX,M8t,yL,_X),u.a=npt,u.b=ix,u.c=npt,u.d=ix;var Tje=A(h0,"Rectangle",236);T(1353,1,Lu,jRt),u.vf=function(e){return ime(a(e,31))},u.Pe=function(e,n){l3e(this,a(e,31),n)},u.d=3;var l$t,h$t,f$t,d$t,p$t,g$t,Cje=A(h0,"SplineEdgeRouter",1353);T(250,1,{250:1},gN),u.Ib=function(){return this.a+" ->("+this.c+") "+this.b},u.c=0;var Aje=A(h0,"SplineEdgeRouter/Dependency",250);T(417,23,{3:1,34:1,23:1,417:1},brt);var rg,iy,m$t=Ri(h0,"SplineEdgeRouter/SideToProcess",417,ji,hoe,Mie),b$t;T(1354,1,{},VMt),u.td=function(e){sre(this.a,this.b,e)};var kje=A(h0,"SplineEdgeRouter/lambda$0$Type",1354);T(1355,1,{},qMt),u.td=function(e){ore(this.a,this.b,e)};var Lje=A(h0,"SplineEdgeRouter/lambda$1$Type",1355);T(125,1,{34:1,125:1},c9t,Lht),u.vd=function(e){return VQt(this,a(e,125))},u.b=0,u.e=0,u.f=0,u.i=!1,u.j=0,u.k=!1,u.n=!1,u.p=0,u.r=0,u.s=0;var Pje=A(h0,"SplineSegment",125);T(589,1,{589:1},$t),u.a=0,u.b=!1,u.c=!1,u.d=!1,u.e=!1,u.f=0;var Ije=A(h0,"SplineSegment/EdgeInformation",589);T(990,1,{},_e);var Rje=A(w4,Tft,990);T(991,1,jr,Ye),u.Ld=function(e,n){return D0e(a(e,128),a(n,128))},u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)};var Dje=A(w4,rBt,991);T(989,1,{},M3t);var Nje=A(w4,"MrTree",989);T(360,23,{3:1,34:1,23:1,360:1,285:1,286:1},z9),u.hf=function(){return y9t(this)},u.uf=function(){return y9t(this)};var cF,rA,$6,sA,Hbt=Ri(w4,"TreeLayoutPhases",360,ji,Ace,gie),w$t;T(960,244,I_,oTt),u.Ae=function(e,n){var i,r,c,l,f,g;for(l=(f=new mN,Uo(f,e),Ct(f,(mc(),aA),e),g=new vi,Wve(e,f,g),Ive(e,f,g),f),c=qve(this.a,l),r=new H(c);r.a"+sN(this.c):"e_"+Yr(this)};var zje=A(v4,"TEdge",170);T(128,131,{3:1,128:1,93:1,131:1},mN),u.Ib=function(){var e,n,i,r,c;for(c=null,r=qn(this.b,0);r.b!=r.d.c;)i=a(Yn(r),76),c+=(i.c==null||i.c.length==0?"n_"+i.g:"n_"+i.c)+` -`;for(n=qn(this.a,0);n.b!=n.d.c;)e=a(Yn(n),170),c+=(e.b&&e.c?sN(e.b)+"->"+sN(e.c):"e_"+Yr(e))+` -`;return c};var z3e=A(v4,"TGraph",128);T(570,452,{3:1,452:1,570:1,93:1,131:1});var jje=A(v4,"TShape",570);T(76,570,{3:1,452:1,76:1,570:1,93:1,131:1},tq),u.Ib=function(){return sN(this)};var j3e=A(v4,"TNode",76);T(231,1,wd,Hd),u.sc=function(e){vo(this,e)},u.tc=function(){var e;return e=qn(this.a.d,0),new Rb(e)};var Hje=A(v4,"TNode/2",231);T(330,1,Cs,Rb),u.gc=function(e){ks(this,e)},u.ic=function(){return a(Yn(this.a),170).c},u.hc=function(){return A9(this.a)},u.jc=function(){Zct(this.a)};var Gje=A(v4,"TNode/2/1",330);T(1545,1,Br,cTt),u.Pe=function(e,n){i_e(this,a(e,128),n)};var Wje=A(rx,"FanProcessor",1545);T(308,23,{3:1,34:1,23:1,308:1,286:1},DT),u.hf=function(){switch(this.g){case 0:return new lxt;case 1:return new cTt;case 2:return new xa;case 3:return new Is;case 4:return new Qr;case 5:return new Uu;default:throw K(new yn(rY+(this.f!=null?this.f:""+this.g)))}};var rQ,sQ,oQ,cQ,aQ,aF,v$t=Ri(rx,Uft,308,ji,zae,mie),_$t;T(1548,1,Br,Is),u.Pe=function(e,n){Ume(this,a(e,128),n)},u.a=0;var $je=A(rx,"LevelHeightProcessor",1548);T(1549,1,wd,ol),u.sc=function(e){vo(this,e)},u.tc=function(){return we(),Lv(),$_};var Vje=A(rx,"LevelHeightProcessor/1",1549);T(1546,1,Br,xa),u.Pe=function(e,n){o0e(this,a(e,128),n)},u.a=0;var qje=A(rx,"NeighborsProcessor",1546);T(1547,1,wd,Ul),u.sc=function(e){vo(this,e)},u.tc=function(){return we(),Lv(),$_};var Xje=A(rx,"NeighborsProcessor/1",1547);T(1550,1,Br,Qr),u.Pe=function(e,n){Fme(this,a(e,128),n)},u.a=0;var Zje=A(rx,"NodePositionProcessor",1550);T(1544,1,Br,lxt),u.Pe=function(e,n){Mye(this,a(e,128))};var Yje=A(rx,"RootProcessor",1544);T(1551,1,Br,Uu),u.Pe=function(e,n){Che(a(e,128))};var Kje=A(rx,"Untreeifyer",1551),V6,oA,y$t,uQ,uF,cA,lQ,lF,hF,DE,aA,fF,Kp,Gbt,x$t,hQ,Lw,fQ,Wbt;T(750,1,_d,lj),u.ue=function(e){He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,ipt),""),"Weighting of Nodes"),"Which weighting to use when computing a node order."),Vbt),(n0(),xs)),Qbt),qe((Qg(),On))))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,rpt),""),"Search Order"),"Which search order to use when computing a spanning tree."),$bt),xs),ewt),qe(On)))),l7t((new hj,e))};var M$t,$bt,E$t,Vbt,Jje=A(xO,"MrTreeMetaDataProvider",750);T(886,1,_d,hj),u.ue=function(e){l7t(e)};var S$t,qbt,Xbt,T$t,Zbt,dF,Ybt,C$t,Kbt,A$t,Qje=A(xO,"MrTreeOptions",886);T(887,1,{},BS),u.Be=function(){var e;return e=new oTt,e},u.Ce=function(e){};var tHe=A(xO,"MrTreeOptions/MrtreeFactory",887);T(438,23,{3:1,34:1,23:1,438:1},wrt);var dQ,Jbt,Qbt=Ri(xO,"OrderWeighting",438,ji,ooe,Eie),k$t;T(388,23,{3:1,34:1,23:1,388:1},vrt);var twt,pQ,ewt=Ri(xO,"TreeifyingOrder",388,ji,soe,Sie),L$t;T(1357,1,Lu,fj),u.vf=function(e){return a(e,128),P$t},u.Pe=function(e,n){ile(this,a(e,128),n)};var P$t,eHe=A("org.eclipse.elk.alg.mrtree.p1treeify","DFSTreeifyer",1357);T(1358,1,Lu,dj),u.vf=function(e){return a(e,128),I$t},u.Pe=function(e,n){c0e(this,a(e,128),n)};var I$t,nHe=A("org.eclipse.elk.alg.mrtree.p2order","NodeOrderer",1358);T(1359,1,Lu,_8),u.vf=function(e){return a(e,128),R$t},u.Pe=function(e,n){Gwe(this,a(e,128),n)},u.a=0;var R$t,iHe=A("org.eclipse.elk.alg.mrtree.p3place","NodePlacer",1359);T(1360,1,Lu,gj),u.vf=function(e){return a(e,128),D$t},u.Pe=function(e,n){kpe(a(e,128),n)};var D$t,rHe=A("org.eclipse.elk.alg.mrtree.p4route","EdgeRouter",1360),uA;T(447,23,{3:1,34:1,23:1,447:1,285:1,286:1},_rt),u.hf=function(){return bIt(this)},u.uf=function(){return bIt(this)};var pF,NE,nwt=Ri(spt,"RadialLayoutPhases",447,ji,coe,Tie),N$t;T(961,244,I_,E3t),u.Ae=function(e,n){var i,r,c,l,f,g,b;if(r=r9t(this,e),di(n,"Radial layout",r.c.length),b=q1e(e),ga(e,($T(),uA),b),!b)throw K(new yn("The given graph is not a tree!"));for(l=lt(Yt(cn(e,(Kb(),bF)))),l==0&&(l=_9t(e)),ga(e,bF,l),i=new FG(e),pd(PRt(i),new k3),c=new y5(i),vIt(c),g=new H(r9t(this,e));g.a0&&UPt(e.charCodeAt(n-1),dBt);)--n;if(r>=n)throw K(new yn("The given string does not contain any numbers."));if(c=V2(e.substr(r,n-r),`,|;|\r| -`),c.length!=2)throw K(new yn("Exactly two numbers are expected, "+c.length+" were found."));try{this.a=ew(tw(c[0])),this.b=ew(tw(c[1]))}catch(l){throw l=vr(l),ct(l,118)?(i=l,K(new yn(pBt+i))):K(l)}},u.Ib=function(){return"("+this.a+","+this.b+")"},u.a=0,u.b=0;var ss=A(KP,"KVector",9);T(74,66,{3:1,4:1,20:1,25:1,41:1,13:1,66:1,15:1,74:1,428:1},Va,M9),u.gf=function(e){var n,i,r,c,l,f;r=V2(e,`,|;|\\(|\\)|\\[|\\]|\\{|\\}| | | -`),ld(this);try{for(i=0,l=0,c=0,f=0;i0&&(l%2==0?c=ew(r[i]):f=ew(r[i]),l>0&&l%2!=0&&Xi(this,new We(c,f)),++l),++i}catch(g){throw g=vr(g),ct(g,118)?(n=g,K(new yn("The given string does not match the expected format for vectors."+n))):K(g)}},u.Ib=function(){var e,n,i;for(e=new ll("("),n=qn(this,0);n.b!=n.d.c;)i=a(Yn(n),9),Ii(e,i.a+","+i.b),n.b!=n.d.c&&(e.a+="; ");return(e.a+=")",e).a};var Mwt=A(KP,"KVectorChain",74);T(224,23,{3:1,34:1,23:1,224:1},NT);var EQ,wF,vF,Y6,K6,_F,Ewt=Ri(Dh,"Alignment",224,ji,jae,Iie),eVt;T(855,1,_d,wj),u.ue=function(e){CNt(e)};var Swt,SQ,Twt,Cwt,nVt,TQ,iVt,rVt,Awt,kwt,sVt,gGe=A(Dh,"BoxLayouterOptions",855);T(856,1,{},yR),u.Be=function(){var e;return e=new dz,e},u.Ce=function(e){};var mGe=A(Dh,"BoxLayouterOptions/BoxFactory",856);T(785,1,_d,vj),u.ue=function(e){He(e,new De(ze(Ue(je(Ne(Fe(Oe(Be(new Ie,JBt),""),"Layout Algorithm"),"Select a specific layout algorithm."),(n0(),X6)),At),qe((Qg(),On))))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Pdt),""),"Alignment"),"Alignment of the selected node relative to other nodes, the exact meaning depends on the used algorithm."),Pwt),xs),Ewt),qe(vc)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.alignment"])))),He(e,new De(Di(ze(Ue(je(Ne(Fe(Oe(Be(new Ie,cE),""),"Aspect Ratio"),"The desired aspect ratio of the drawing, that is the quotient of width by height."),ha),To),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.aspectRatio"])))),He(e,new De(Di(ze(Ue(je(Ne(Fe(Oe(Be(new Ie,bpt),""),"Bend Points"),"A fixed list of bend points for the edge. This is used by the 'Fixed Layout' algorithm to specify a pre-defined routing for an edge. The vector chain must include the source point, any bend points, and the target point, so it must have at least two points."),Ed),Mwt),qe(Md)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.bendPoints"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,CY),""),"Debug Mode"),"Whether additional debug information shall be generated."),(me(),me(),!1)),Ec),ho),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.debugMode"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,kY),""),vft),"Overall direction of edges: horizontal (right / left) or vertical (down / up)."),Rwt),xs),fA),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.direction"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,t6),""),"Edge Routing"),"What kind of edge routing style should be applied for the content of a parent node. Algorithms may also set this option to single edges in order to mark them as splines. The bend point list of edges with this option set to SPLINES must be interpreted as control points for a piecewise cubic spline."),Owt),xs),jQ),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.edgeRouting"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,gpt),""),"Expand Nodes"),"If active, nodes are expanded to fill the area of their parent."),!1),Ec),ho),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.expandNodes"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Idt),""),"Hierarchy Handling"),"If this option is set to SEPARATE_CHILDREN, each hierarchy level of the graph is processed independently, possibly by different layout algorithms, beginning with the lowest level. If it is set to INCLUDE_CHILDREN, the algorithm is responsible to process all hierarchy levels that are contained in the associated parent node. If the root node is set to inherit (or not set at all), the default behavior is SEPARATE_CHILDREN."),Uwt),xs),vvt),ur(On,Y(Z(Jp,1),jt,163,0,[vc]))),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.hierarchyHandling"])))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,ex),""),"Padding"),"The padding to be left to a parent element's border when placing child elements. This can also serve as an output option of a layout algorithm if node size calculation is setup appropriately."),qwt),Ed),Fgt),ur(On,Y(Z(Jp,1),jt,163,0,[vc]))))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,aO),""),"Interactive"),"Whether the algorithm should be run in interactive mode for the content of a parent node. What this means exactly depends on how the specific algorithm interprets this option. Usually in the interactive mode algorithms try to modify the current layout as little as possible."),!1),Ec),ho),qe(On)))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,nY),""),"Port Constraints"),"Defines constraints of the position of the ports of a node."),Jwt),xs),xvt),qe(vc)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.portConstraints"])))),He(e,new De(Di(ze(Ue(je(Ne(Fe(Oe(Be(new Ie,_O),""),"Position"),"The position of a node, port, or label. This is used by the 'Fixed Layout' algorithm to specify a pre-defined position."),Ed),ss),ur(vc,Y(Z(Jp,1),jt,163,0,[tb,sg]))),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.position"])))),He(e,new De(Di(ze(Ue(je(Ne(Fe(Oe(Be(new Ie,qP),""),"Priority"),"Defines the priority of an object; its meaning depends on the specific layout algorithm and the context where it is used."),Pa),Io),ur(vc,Y(Z(Jp,1),jt,163,0,[Md]))),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.priority"])))),He(e,new De(Di(ze(Ue(je(Ne(Fe(Oe(Be(new Ie,cO),""),"Randomization Seed"),"Seed used for pseudo-random number generators to control the layout algorithm. If the value is 0, the seed shall be determined pseudo-randomly (e.g. from the system time)."),Pa),Io),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.randomSeed"])))),He(e,new De(Di(ze(Ue(je(Ne(Fe(Oe(Be(new Ie,XP),""),"Separate Connected Components"),"Whether each connected component should be processed separately."),Ec),ho),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.separateConnComp"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Gdt),""),"Junction Points"),"This option is not used as option, but as output of the layout algorithms. It is attached to edges and determines the points where junction symbols should be drawn in order to represent hyperedges with orthogonal routing. Whether such points are computed depends on the chosen layout algorithm and edge routing style. The points are put into the vector chain with no specific order."),zwt),Ed),Mwt),qe(Md)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.junctionPoints"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,qdt),""),"Comment Box"),"Whether the node should be regarded as a comment box instead of a regular node. In that case its placement should be similar to how labels are handled. Any edges incident to a comment box specify to which graph elements the comment is related."),!1),Ec),ho),qe(vc)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.commentBox"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Xdt),""),"Hypernode"),"Whether the node should be handled as a hypernode."),!1),Ec),ho),qe(vc)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.hypernode"])))),He(e,new De(ze(Ue(je(Ne(Fe(Oe(Be(new Ie,QBt),""),"Label Manager"),"Label managers can shorten labels upon a layout algorithm's request."),Ed),Z3e),ur(On,Y(Z(Jp,1),jt,163,0,[sg]))))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Jdt),""),"Margins"),"Margins define additional space around the actual bounds of a graph element. For instance, ports or labels being placed on the outside of a node's border might introduce such a margin. The margin is used to guarantee non-overlap of other graph elements with those ports or labels."),jwt),Ed),Bgt),qe(vc)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.margins"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,kdt),""),"No Layout"),"No layout is done for the associated element. This is used to mark parts of a diagram to avoid their inclusion in the layout graph, or to mark parts of the layout graph to prevent layout engines from processing them. If you wish to exclude the contents of a compound node from automatic layout, while the node itself is still considered on its own layer, use the 'Fixed Layout' algorithm for that node."),!1),Ec),ho),ur(vc,Y(Z(Jp,1),jt,163,0,[Md,tb,sg]))),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.noLayout"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,tFt),""),"Scale Factor"),"The scaling factor to be applied to the corresponding node in recursive layout. It causes the corresponding node's size to be adjusted, and its ports and labels to be sized and placed accordingly after the layout of that node has been determined (and before the node itself and its siblings are arranged). The scaling is not reverted afterwards, so the resulting layout graph contains the adjusted size and position data. This option is currently not supported if 'Layout Hierarchy' is set."),1),ha),To),qe(vc)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.scaleFactor"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,eFt),""),"Animate"),"Whether the shift from the old layout to the new computed layout shall be animated."),!0),Ec),ho),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.animate"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,nFt),""),"Animation Time Factor"),"Factor for computation of animation time. The higher the value, the longer the animation time. If the value is 0, the resulting time is always equal to the minimum defined by 'Minimal Animation Time'."),Xt(100)),Pa),Io),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.animTimeFactor"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,iFt),""),"Layout Ancestors"),"Whether the hierarchy levels on the path from the selected element to the root of the diagram shall be included in the layout process."),!1),Ec),ho),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.layoutAncestors"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,rFt),""),"Maximal Animation Time"),"The maximal time for animations, in milliseconds."),Xt(4e3)),Pa),Io),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.maxAnimTime"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,sFt),""),"Minimal Animation Time"),"The minimal time for animations, in milliseconds."),Xt(400)),Pa),Io),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.minAnimTime"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,oFt),""),"Progress Bar"),"Whether a progress bar shall be displayed during layout computations."),!1),Ec),ho),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.progressBar"])))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,cFt),""),"Validate Options"),"Whether layout options shall be validated before any layout algorithm is applied. If this option is enabled and at least one error is found, the layout process is aborted and a message is shown to the user."),!0),Ec),ho),qe(On)))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,aFt),""),"Zoom to Fit"),"Whether the zoom level shall be set to view the whole diagram after layout."),!1),Ec),ho),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.zoomToFit"])))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,mpt),"box"),"Box Layout Mode"),"Configures the packing mode used by the {@link BoxLayoutProvider}. If SIMPLE is not required (neither priorities are used nor the interactive mode), GROUP_DEC can improve the packing and decrease the area. GROUP_MIXED and GROUP_INC may, in very specific scenarios, work better."),Iwt),xs),Lvt),qe(On)))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,YZ),K1),"Components Spacing"),"Spacing to be preserved between pairs of connected components. This option is only relevant if 'separateConnectedComponents' is activated."),12),ha),To),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.borderSpacing"])))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,ydt),K1),"Edge Spacing"),"Spacing to be preserved between any two edges. Note that while this can somewhat easily be satisfied for the segments of orthogonally drawn edges, it is harder for general polylines or splines."),10),ha),To),qe(On)))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,eY),K1),"Edge Label Spacing"),"The minimal distance to be preserved between a label and the edge it is associated with. Note that the placement of a label is influenced by the 'edgelabels.placement' option."),2),ha),To),qe(On)))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,xdt),K1),"Edge Node Spacing"),"Spacing to be preserved between nodes and edges."),10),ha),To),qe(On)))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Mdt),K1),"Label Spacing"),"Determines the amount of space to be left between two labels of the same graph element."),0),ha),To),qe(On)),Y(Z(At,1),wt,2,6,[dFt])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Sdt),K1),"Label Node Spacing"),"Spacing to be preserved between labels and the border of node they are associated with. Note that the placement of a label is influenced by the 'nodelabels.placement' option."),5),ha),To),qe(On)),Y(Z(At,1),wt,2,6,[dFt])))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Edt),K1),"Label Port Spacing"),"Spacing to be preserved between labels and the ports they are associated with. Note that the placement of a label is influenced by the 'portlabels.placement' option."),1),ha),To),qe(On)))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,uE),K1),"Node Spacing"),"The minimal distance to be preserved between each two nodes."),20),ha),To),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.spacing"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Tdt),K1),"Port Spacing"),"Spacing between pairs of ports of the same node."),10),ha),To),ur(On,Y(Z(Jp,1),jt,163,0,[vc]))),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.portSpacing"])))),He(e,new De(ze(Ue(je(Ne(Fe(Oe(Be(new Ie,Cdt),K1),"Individual Spacing Override"),"In general spacing values apply to the children of the hierarchical node (possibly the root node) for which the values are actually specified. Hereby, the children include ports, edges, and labels."),Ed),G3e),ur(vc,Y(Z(Jp,1),jt,163,0,[Md,tb,sg]))))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Qdt),K1),"Additional Port Space"),"Additional space around the sets of ports on each node side. For each side of a node, this option can reserve additional space before and after the ports on each side. For example, a top spacing of 20 makes sure that the first port on the western and eastern side is 20 units away from the northern border."),ovt),Ed),Bgt),qe(On)))),He(e,new De(Di(ze(Ue(je(Ne(Fe(Oe(Be(new Ie,Kdt),pFt),"Layout Partition"),"Partition to which the node belongs to. If 'layoutPartitions' is true, all nodes are expected to have a partition."),Pa),Io),ur(On,Y(Z(Jp,1),jt,163,0,[vc]))),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.partition"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Ydt),pFt),"Layout Partitioning"),"Whether to activate partitioned layout."),Xwt),Ec),ho),qe(On)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.layoutPartitions"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,uFt),gFt),"Node Label Padding"),"Define padding for node labels that are placed inside of a node."),Hwt),Ed),Fgt),qe(vc)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.nodeLabelInset"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Ndt),gFt),"Node Label Placement"),"Hints for where node labels are to be placed; if empty, the node label's position is not modified."),Gwt),OE),to),ur(vc,Y(Z(Jp,1),jt,163,0,[sg]))),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.nodeLabelPlacement"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Fdt),MO),"Port Alignment"),"Defines the default port distribution for a node. May be overridden for each side individually."),Ywt),xs),wA),qe(vc)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.portAlignment"])))),He(e,new De(Di(ze(Ue(je(Ne(Fe(Oe(Be(new Ie,Udt),MO),"Port Alignment (North)"),"Defines how ports on the northern side are placed, overriding the node's general port alignment."),xs),wA),qe(vc)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.portAlignment.north"])))),He(e,new De(Di(ze(Ue(je(Ne(Fe(Oe(Be(new Ie,zdt),MO),"Port Alignment (South)"),"Defines how ports on the southern side are placed, overriding the node's general port alignment."),xs),wA),qe(vc)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.portAlignment.south"])))),He(e,new De(Di(ze(Ue(je(Ne(Fe(Oe(Be(new Ie,jdt),MO),"Port Alignment (West)"),"Defines how ports on the western side are placed, overriding the node's general port alignment."),xs),wA),qe(vc)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.portAlignment.west"])))),He(e,new De(Di(ze(Ue(je(Ne(Fe(Oe(Be(new Ie,Hdt),MO),"Port Alignment (East)"),"Defines how ports on the eastern side are placed, overriding the node's general port alignment."),xs),wA),qe(vc)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.portAlignment.east"])))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,wO),wpt),"Node Size Constraints"),"Constraints for determining node sizes. Each member of the set specifies something that should be taken into account when calculating node sizes. The empty set corresponds to node sizes being fixed."),Wwt),OE),vA),qe(vc)))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,AY),wpt),"Node Size Options"),"Options modifying the behavior of the size constraints set on a node. Each member of the set specifies something that should be taken into account when calculating node sizes. The empty set corresponds to no further modifications."),Vwt),OE),Tvt),qe(vc)))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,vO),wpt),"Node Size Minimum"),"The minimal size to which a node can be reduced."),$wt),Ed),ss),qe(vc)))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Wdt),TY),"Edge Label Placement"),"Gives a hint on where to put edge labels."),Dwt),xs),avt),qe(sg)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.edgeLabelPlacement"])))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,$dt),TY),"Inline Edge Labels"),"If true, an edge label is placed directly on its edge. May only apply to center edge labels. This kind of label placement is only advisable if the label's rendering is such that it is not crossed by its edge and thus stays legible."),!1),Ec),ho),qe(sg)))),He(e,new De(Di(ze(Ue(je(Ne(Fe(Oe(Be(new Ie,lFt),"font"),"Font Name"),"Font name used for a label."),X6),At),qe(sg)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.fontName"])))),He(e,new De(Di(ze(Ue(je(Ne(Fe(Oe(Be(new Ie,hFt),"font"),"Font Size"),"Font size used for a label."),Pa),Io),qe(sg)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.fontSize"])))),He(e,new De(Di(ze(Ue(je(Ne(Fe(Oe(Be(new Ie,Zdt),UY),"Port Anchor Offset"),"The offset to the port position where connections shall be attached."),Ed),ss),qe(tb)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.portAnchor"])))),He(e,new De(Di(ze(Ue(je(Ne(Fe(Oe(Be(new Ie,Vdt),UY),"Port Index"),"The index of a port in the fixed order around a node. The order is assumed as clockwise, starting with the leftmost port on the top side. This option must be set if 'Port Constraints' is set to FIXED_ORDER and no specific positions are given for the ports. Additionally, the option 'Port Side' must be defined in this case."),Pa),Io),qe(tb)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.portIndex"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Ldt),UY),"Port Side"),"The side of a node on which a port is situated. This option must be set if 'Port Constraints' is set to FIXED_SIDE or FIXED_ORDER and no specific positions are given for the ports."),tvt),xs),Ia),qe(tb)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.portSide"])))),He(e,new De(Di(ze(Ue(je(Ne(Fe(Oe(Be(new Ie,Adt),UY),"Port Border Offset"),"The offset of ports on the node border. With a positive offset the port is moved outside of the node, while with a negative offset the port is moved towards the inside. An offset of 0 means that the port is placed directly on the node border, i.e. if the port side is north, the port's south border touches the nodes's north border; if the port side is east, the port's west border touches the nodes's east border; if the port side is south, the port's north border touches the node's south border; if the port side is west, the port's east border touches the node's west border."),ha),To),qe(tb)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.offset"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Odt),mFt),"Port Label Placement"),"Decides on a placement method for port labels."),Qwt),xs),Mvt),qe(vc)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.portLabelPlacement"])))),He(e,new De(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Bdt),mFt),"Port Labels Next to Port"),"Usually, inside port labels of hierarchical nodes are placed not next to their port, but with an offset to avoid edge-label crossings. The offset is not necessary if the port has no connections that would cross the label, but is usually applied anyway to keep things uniform. Setting this option to true places labels next to their ports if they won't be crossed by edges."),!1),Ec),ho),qe(vc)))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Rdt),bFt),"Activate Inside Self Loops"),"Whether this node allows to route self loops inside of it instead of around it. If set to true, this will make the node a compound node if it isn't already, and will require the layout algorithm to support compound nodes with hierarchical ports."),!1),Ec),ho),qe(vc)),Y(Z(At,1),wt,2,6,[wFt])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,Ddt),bFt),"Inside Self Loop"),"Whether a self loop should be routed inside a node instead of around that node."),!1),Ec),ho),qe(Md)),Y(Z(At,1),wt,2,6,[wFt])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,KZ),"edge"),"Edge Thickness"),"The thickness of an edge. This is a hint on the line width used to draw an edge, possibly requiring more space to be reserved for it."),1),ha),To),qe(Md)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.thickness"])))),He(e,new De(Di(ze(Ue(je(xn(Ne(Fe(Oe(Be(new Ie,fFt),"edge"),"Edge Type"),"The type of an edge. This is usually used for UML class diagrams, where associations must be handled differently from generalizations."),Fwt),xs),pvt),qe(Md)),Y(Z(At,1),wt,2,6,["de.cau.cs.kieler.edgeType"])))),TT(e,new E2(vT(K3(Y3(new Eb,Nn),"Layered"),'The layer-based method was introduced by Sugiyama, Tagawa and Toda in 1981. It emphasizes the direction of edges by pointing as many edges as possible into the same direction. The nodes are arranged in layers, which are sometimes called "hierarchies", and then reordered such that the number of edge crossings is minimized. Afterwards, concrete coordinates are computed for the nodes and edge bend points.'))),TT(e,new E2(vT(K3(Y3(new Eb,"org.eclipse.elk.orthogonal"),"Orthogonal"),`Orthogonal methods that follow the "topology-shape-metrics" approach by Batini, Nardelli and Tamassia '86. The first phase determines the topology of the drawing by applying a planarization technique, which results in a planar representation of the graph. The orthogonal shape is computed in the second phase, which aims at minimizing the number of edge bends, and is called orthogonalization. The third phase leads to concrete coordinates for nodes and edge bend points by applying a compaction method, thus defining the metrics.`))),TT(e,new E2(vT(K3(Y3(new Eb,Rf),"Force"),"Layout algorithms that follow physical analogies by simulating a system of attractive and repulsive forces. The first successful method of this kind was proposed by Eades in 1984."))),TT(e,new E2(vT(K3(Y3(new Eb,"org.eclipse.elk.circle"),"Circle"),"Circular layout algorithms emphasize cycles or biconnected components of a graph by arranging them in circles. This is useful if a drawing is desired where such components are clearly grouped, or where cycles are shown as prominent OPTIONS of the graph."))),TT(e,new E2(vT(K3(Y3(new Eb,HBt),"Tree"),"Specialized layout methods for trees, i.e. acyclic graphs. The regular structure of graphs that have no undirected cycles can be emphasized using an algorithm of this type."))),TT(e,new E2(vT(K3(Y3(new Eb,"org.eclipse.elk.planar"),"Planar"),"Algorithms that require a planar or upward planar graph. Most of these algorithms are theoretically interesting, but not practically usable."))),TT(e,new E2(vT(K3(Y3(new Eb,Um),"Radial"),"Radial layout algorithms usually position the nodes of the graph on concentric circles."))),aNt((new x8,e)),CNt((new wj,e)),YDt((new M8,e))};var Lwt,oVt,Pwt,BE,cVt,aVt,Iwt,uVt,CQ,lA,Rwt,lVt,J6,Dwt,Nwt,Owt,Bwt,Fwt,hVt,ry,Uwt,fVt,yF,AQ,kQ,Tx,zwt,xF,jwt,dVt,Hwt,MF,Gwt,FE,Wwt,Q6,$wt,EF,Vwt,LQ,sy,qwt,pVt,Xwt,gVt,Zwt,Ywt,PQ,IQ,RQ,DQ,Kwt,nu,tI,Jwt,mVt,eI,NQ,Qwt,hA,tvt,Cx,SF,OQ,bVt,BQ,evt,wVt,nvt,vVt,FQ,ivt,TF,rvt,oy,svt,ovt,cvt,bGe=A(Dh,"CoreOptions",785);T(110,23,{3:1,34:1,23:1,110:1},H5);var fp,ah,uh,Ff,og,fA=Ri(Dh,vft,110,ji,rae,Uie),_Vt;T(226,23,{3:1,34:1,23:1,226:1},H9);var dA,Ax,pA,CF,avt=Ri(Dh,"EdgeLabelPlacement",226,ji,Lce,zie),yVt;T(197,23,{3:1,34:1,23:1,197:1},G9);var UE,UQ,eb,zQ,jQ=Ri(Dh,"EdgeRouting",197,ji,Pce,jie),xVt;T(289,23,{3:1,34:1,23:1,289:1},OT);var uvt,lvt,hvt,fvt,HQ,dvt,pvt=Ri(Dh,"EdgeType",289,ji,Hae,Hie),MVt;T(853,1,_d,x8),u.ue=function(e){aNt(e)};var gvt,mvt,bvt,EVt,wvt,gA,wGe=A(Dh,"FixedLayouterOptions",853);T(854,1,{},xR),u.Be=function(){var e;return e=new d1,e},u.Ce=function(e){};var vGe=A(Dh,"FixedLayouterOptions/FixedFactory",854);T(316,23,{3:1,34:1,23:1,316:1},wW);var kx,AF,mA,vvt=Ri(Dh,"HierarchyHandling",316,ji,Joe,Oie),SVt;T(86,23,{3:1,34:1,23:1,86:1},Dv);var Uf,kl,Ll,Pl,Du,Il,lh,hh,Bh,to=Ri(Dh,"NodeLabelPlacement",86,ji,Iue,Bie),TVt;T(225,23,{3:1,34:1,23:1,225:1},G5);var _vt,bA,nb,yvt,GQ,wA=Ri(Dh,"PortAlignment",225,ji,nae,Fie),CVt;T(83,23,{3:1,34:1,23:1,83:1},BT);var Lx,Gc,Sd,Px,dp,ib,xvt=Ri(Dh,"PortConstraints",83,ji,Uae,Nie),AVt;T(275,23,{3:1,34:1,23:1,275:1},vW);var kF,rb,cy,Mvt=Ri(Dh,"PortLabelPlacement",275,ji,Zoe,Rie),kVt;T(69,23,{3:1,34:1,23:1,69:1},W5);var Qe,Tn,nI,ay,zf,sb,Evt,iI,uy,Td,WQ,Cd,x0,Ad,Ix,rI,ly,sI,fi,Wc,on,Ia=Ri(Dh,"PortSide",69,ji,Xce,Die),LVt;T(857,1,_d,M8),u.ue=function(e){YDt(e)};var PVt,IVt,Svt,RVt,DVt,_Ge=A(Dh,"RandomLayouterOptions",857);T(858,1,{},fz),u.Be=function(){var e;return e=new A3,e},u.Ce=function(e){};var yGe=A(Dh,"RandomLayouterOptions/RandomFactory",858);T(344,23,{3:1,34:1,23:1,344:1},W9);var ob,oI,cI,M0,vA=Ri(Dh,"SizeConstraint",344,ji,Ice,Gie),NVt;T(239,23,{3:1,34:1,23:1,239:1},Nv);var LF,PF,zE,$Q,_A,yA,IF,Rx,RF,Tvt=Ri(Dh,"SizeOptions",239,ji,Rue,Wie),OVt;T(313,1,{},ED,Ist,Pst),u.b=!1,u.c=0,u.d=-1,u.e=0,u.f=!1,u.j=0;var xGe=A(Rh,"BasicProgressMonitor",313);T(848,244,I_,dz),u.Ae=function(e,n){var i,r,c,l,f,g,b,v,M,k;switch(di(n,"Box layout",2),l=lt(Yt(cn(e,(w7(),sVt)))),f=a(cn(e,rVt),119),i=lt(de(cn(e,Twt))),r=lt(de(cn(e,Cwt))),c=a(cn(e,SQ),288),c.g){case 0:g=(b=new yD((!e.a&&(e.a=new Wt(zr,e,10,11)),e.a)),we(),R1(b,new jH(r)),b),v=a(cn(e,TQ),9),v.a=y.Math.max(v.a-f.b-f.c,0),v.b=y.Math.max(v.b-f.d-f.a,0),M=Yt(cn(e,Swt)),(M==null||(En(M),M<=0))&&(M=1.3),k=txe(g,l,f,v.a,v.b,i,(En(M),M)),C_(e,k.a,k.b,!1,!0);break;default:hye(e,l,f,i)}Vn(n)};var MGe=A(Rh,"BoxLayoutProvider",848);T(849,1,jr,jH),u.Ld=function(e,n){return bbe(this,a(e,35),a(n,35))},u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.a=!1;var EGe=A(Rh,"BoxLayoutProvider/1",849);T(145,1,{145:1},PN,WSt),u.Ib=function(){return this.c?pht(this.c):Gp(this.b)};var SGe=A(Rh,"BoxLayoutProvider/Group",145);T(288,23,{3:1,34:1,23:1,288:1},$9);var Cvt,Avt,kvt,VQ,Lvt=Ri(Rh,"BoxLayoutProvider/PackingMode",288,ji,Dce,$ie),BVt;T(850,1,jr,az),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return-ro(V5(a(e,145)),V5(a(n,145)))};var TGe=A(Rh,"BoxLayoutProvider/lambda$0$Type",850);T(851,1,jr,uz),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return ro(V5(a(e,145)),V5(a(n,145)))};var CGe=A(Rh,"BoxLayoutProvider/lambda$1$Type",851);T(852,1,jr,lz),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return ro(V5(a(e,145)),V5(a(n,145)))};var AGe=A(Rh,"BoxLayoutProvider/lambda$2$Type",852);T(833,1,{},GMt),u.td=function(e){K0e(this.a,this.b,e)},u.a=0,u.b=0;var kGe=A(Rh,"ElkUtil/lambda$0$Type",833);T(834,1,{},WMt),u.td=function(e){xQt(this.a,this.b,e)},u.a=0,u.b=0;var LGe=A(Rh,"ElkUtil/lambda$1$Type",834);T(835,1,{},$Mt),u.td=function(e){Yte(this.a,this.b,e)},u.a=0,u.b=0;var PGe=A(Rh,"ElkUtil/lambda$2$Type",835);T(322,1,{34:1,322:1},G3),u.vd=function(e){return iee(this,a(e,210))},u.Fb=function(e){var n;return ct(e,322)?(n=a(e,322),this.a==n.a):!1},u.Hb=function(){return Tr(this.a)},u.Ib=function(){return this.a+" (exclusive)"},u.a=0;var IGe=A(Rh,"ExclusiveBounds/ExclusiveLowerBound",322);T(963,244,I_,d1),u.Ae=function(e,n){var i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt,pt,_t,It,Gt,Zt,ce,ae,Te;for(di(n,vFt,1),l=a(cn(e,(dr(),Nwt)),197),R=0,O=0,_t=new $n((!e.a&&(e.a=new Wt(zr,e,10,11)),e.a));_t.e!=_t.i._b();){for(rt=a(ci(_t),35),Te=a(cn(rt,(ON(),gA)),9),Te&&(Wd(rt,Te.a,Te.b),a(cn(rt,mvt),185).pc((Ku(),ob))&&($=a(cn(rt,bvt),9),$.a>0&&$.b>0&&C_(rt,$.a,$.b,!0,!0))),R=y.Math.max(R,rt.i+rt.g),O=y.Math.max(O,rt.j+rt.f),M=new $n((!rt.n&&(rt.n=new Wt(ic,rt,1,7)),rt.n));M.e!=M.i._b();)b=a(ci(M),137),Te=a(cn(b,gA),9),Te&&Wd(b,Te.a,Te.b),R=y.Math.max(R,rt.i+b.i+b.g),O=y.Math.max(O,rt.j+b.j+b.f);for(Zt=new $n((!rt.c&&(rt.c=new Wt(Rl,rt,9,9)),rt.c));Zt.e!=Zt.i._b();)for(Gt=a(ci(Zt),121),Te=a(cn(Gt,gA),9),Te&&Wd(Gt,Te.a,Te.b),ce=rt.i+Gt.i,ae=rt.j+Gt.j,R=y.Math.max(R,ce+Gt.g),O=y.Math.max(O,ae+Gt.f),v=new $n((!Gt.n&&(Gt.n=new Wt(ic,Gt,1,7)),Gt.n));v.e!=v.i._b();)b=a(ci(v),137),Te=a(cn(b,gA),9),Te&&Wd(b,Te.a,Te.b),R=y.Math.max(R,ce+b.i+b.g),O=y.Math.max(O,ae+b.j+b.f);for(c=Rn(Af(rt));Jn(c);)i=a(In(c),105),k=eOt(i),R=y.Math.max(R,k.a),O=y.Math.max(O,k.b);for(r=Rn(xP(rt));Jn(r);)i=a(In(r),105),zc(a(at((!i.b&&(i.b=new pn(Si,i,4,7)),i.b),0),97))!=e&&(k=eOt(i),R=y.Math.max(R,k.a),O=y.Math.max(O,k.b))}if(l==(gd(),UE))for(pt=new $n((!e.a&&(e.a=new Wt(zr,e,10,11)),e.a));pt.e!=pt.i._b();)for(rt=a(ci(pt),35),r=Rn(Af(rt));Jn(r);)i=a(In(r),105),g=(f=new Va,f),g.b==0?ga(i,Tx,null):ga(i,Tx,g);It=a(cn(e,(ON(),EVt)),119),nt=R+It.b+It.c,W=O+It.d+It.a,C_(e,nt,W,!0,!0),Vn(n)};var RGe=A(Rh,"FixedLayoutProvider",963);T(786,131,XZ,Rk);var G3e=A(Rh,"IndividualSpacings",786);T(635,1,{},yCt),u.c=0;var DGe=A(Rh,"InstancePool",635);T(48,1,{20:1,48:1},zs),u.sc=function(e){vo(this,e)},u.Fb=function(e){var n,i,r;return ct(e,48)?(i=a(e,48),n=this.a==null?i.a==null:Fi(this.a,i.a),r=this.b==null?i.b==null:Fi(this.b,i.b),n&&r):!1},u.Hb=function(){var e,n,i,r,c,l;return i=this.a==null?0:Yr(this.a),e=i&qr,n=i&-65536,l=this.b==null?0:Yr(this.b),r=l&qr,c=l&-65536,e^c>>16&qr|n^r<<16},u.tc=function(){return new HH(this)},u.Ib=function(){return this.a==null&&this.b==null?"pair(null,null)":this.a==null?"pair(null,"+Yc(this.b)+")":this.b==null?"pair("+Yc(this.a)+",null)":"pair("+Yc(this.a)+","+Yc(this.b)+")"};var NGe=A(Rh,"Pair",48);T(859,1,Cs,HH),u.gc=function(e){ks(this,e)},u.hc=function(){return!this.c&&(!this.b&&this.a.a!=null||this.a.b!=null)},u.ic=function(){if(!this.c&&!this.b&&this.a.a!=null)return this.b=!0,this.a.a;if(!this.c&&this.a.b!=null)return this.c=!0,this.a.b;throw K(new J)},u.jc=function(){throw this.c&&this.a.b!=null?this.a.b=null:this.b&&this.a.a!=null&&(this.a.a=null),K(new na)},u.b=!1,u.c=!1;var OGe=A(Rh,"Pair/1",859);T(404,1,{404:1},w4t),u.Fb=function(e){return au(this.a,a(e,404).a)&&au(this.c,a(e,404).c)&&au(this.d,a(e,404).d)&&au(this.b,a(e,404).b)},u.Hb=function(){return QV(Y(Z(un,1),te,1,5,[this.a,this.c,this.d,this.b]))},u.Ib=function(){return"("+this.a+Rc+this.c+Rc+this.d+Rc+this.b+")"};var BGe=A(Rh,"Quadruple",404);T(957,244,I_,A3),u.Ae=function(e,n){var i,r,c,l,f;if(di(n,"Random Layout",1),(!e.a&&(e.a=new Wt(zr,e,10,11)),e.a).i==0){Vn(n);return}l=a(cn(e,(lut(),RVt)),21),l&&l.a!=0?c=new cN(l.a):c=new Mq,i=lt(Yt(cn(e,PVt))),f=lt(Yt(cn(e,DVt))),r=a(cn(e,IVt),119),z2e(e,c,i,f,r),Vn(n)};var FGe=A(Rh,"RandomLayoutProvider",957);T(490,1,{}),u.Qe=function(){return new We(this.f.i,this.f.j)},u.xe=function(e){return N4t(e,(dr(),nu))?cn(this.f,FVt):cn(this.f,e)},u.Re=function(){return new We(this.f.g,this.f.f)},u.Se=function(){return this.g},u.ye=function(e){return lV(this.f,e)},u.Te=function(e){th(this.f,e.a),eh(this.f,e.b)},u.Ue=function(e){i_(this.f,e.a),n_(this.f,e.b)},u.Ve=function(e){this.g=e},u.g=0;var FVt,UGe=A(n6,"ElkGraphAdapters/AbstractElkGraphElementAdapter",490);T(491,1,{741:1},cT),u.We=function(){var e,n;if(!this.b)for(this.b=rN(N$(this.a).i),n=new $n(N$(this.a));n.e!=n.i._b();)e=a(ci(n),137),Ut(this.b,new UG(e));return this.b},u.b=null;var zGe=A(n6,"ElkGraphAdapters/ElkEdgeAdapter",491);T(562,490,{},FG),u.Xe=function(){return PRt(this)},u.a=null;var jGe=A(n6,"ElkGraphAdapters/ElkGraphAdapter",562);T(564,490,{271:1},UG);var HGe=A(n6,"ElkGraphAdapters/ElkLabelAdapter",564);T(563,490,{739:1},zW),u.We=function(){return Kde(this)},u.$e=function(){var e;return e=a(cn(this.f,(dr(),xF)),135),!e&&(e=new i2),e},u.af=function(){return Jde(this)},u.cf=function(e){var n;n=new i$(e),ga(this.f,(dr(),xF),n)},u.df=function(e){ga(this.f,(dr(),sy),new Nst(e))},u.Ye=function(){return this.d},u.Ze=function(){var e,n;if(!this.a)for(this.a=new Nt,n=Rn(xP(a(this.f,35)));Jn(n);)e=a(In(n),105),Ut(this.a,new cT(e));return this.a},u._e=function(){var e,n;if(!this.c)for(this.c=new Nt,n=Rn(Af(a(this.f,35)));Jn(n);)e=a(In(n),105),Ut(this.c,new cT(e));return this.c},u.bf=function(){return Vot(a(this.f,35)).i!=0||lt(de(a(this.f,35).xe((dr(),yF))))},u.a=null,u.b=null,u.c=null,u.d=null,u.e=null;var GGe=A(n6,"ElkGraphAdapters/ElkNodeAdapter",563);T(997,490,{740:1},n9),u.We=function(){return ope(this)},u.Ze=function(){var e,n;if(!this.a)for(this.a=od(a(this.f,121).Tf().i),n=new $n(a(this.f,121).Tf());n.e!=n.i._b();)e=a(ci(n),105),Ut(this.a,new cT(e));return this.a},u._e=function(){var e,n;if(!this.c)for(this.c=od(a(this.f,121).Uf().i),n=new $n(a(this.f,121).Uf());n.e!=n.i._b();)e=a(ci(n),105),Ut(this.c,new cT(e));return this.c},u.ef=function(){return a(a(this.f,121).xe((dr(),hA)),69)},u.ff=function(){var e,n,i,r,c,l,f,g;for(r=Tf(a(this.f,121)),i=new $n(a(this.f,121).Uf());i.e!=i.i._b();)for(e=a(ci(i),105),g=new $n((!e.c&&(e.c=new pn(Si,e,5,8)),e.c));g.e!=g.i._b();){if(f=a(ci(g),97),gC(zc(f),r))return!0;if(zc(f)==r&<(de(cn(e,(dr(),AQ)))))return!0}for(n=new $n(a(this.f,121).Tf());n.e!=n.i._b();)for(e=a(ci(n),105),l=new $n((!e.b&&(e.b=new pn(Si,e,4,7)),e.b));l.e!=l.i._b();)if(c=a(ci(l),97),gC(zc(c),r))return!0;return!1},u.a=null,u.b=null,u.c=null;var WGe=A(n6,"ElkGraphAdapters/ElkPortAdapter",997);T(265,23,{3:1,34:1,23:1,265:1},V9);var kd,cg,aI,uI,UVt=Ri(vpt,"LabelSide",265,ji,Nce,Vie),zVt;T(676,1,{},k3),u.td=function(e){D7t(a(e,739),!0,!1)};var $Ge=A(vpt,"NodeLabelAndSizeCalculator/lambda$0$Type",676);T(571,1,{},y5),u.b=!0,u.c=!0,u.d=!0,u.e=!0;var VGe=A(vpt,_Bt,571);T(171,1,{171:1}),u.j=!1,u.k=!1;var jVt=A(f0,"Cell",171);T(114,171,{114:1,171:1},dTt),u.Pf=function(){return AD(this)},u.Qf=function(){var e;return e=this.n,this.a.a+e.b+e.c};var qGe=A(f0,"AtomicCell",114);T(203,23,{3:1,34:1,23:1,203:1},_W);var lc,ta,hc,Pw=Ri(f0,"ContainerArea",203,ji,Koe,qie),HVt;T(307,171,yFt);var XGe=A(f0,"ContainerCell",307);T(1179,307,yFt,CIt),u.Pf=function(){var e;return e=0,this.e?this.b?e=this.b.b:this.a[1][1]&&(e=this.a[1][1].Pf()):e=Kat(this,IRt(this,!0)),e>0?e+this.n.d+this.n.a:0},u.Qf=function(){var e,n,i,r,c;if(c=0,this.e)this.b?c=this.b.a:this.a[1][1]&&(c=this.a[1][1].Qf());else if(this.g)c=Kat(this,Jq(this,null,!0));else for(n=(Ch(),Y(Z(Pw,1),jt,203,0,[lc,ta,hc])),i=0,r=n.length;i0?c+this.n.b+this.n.c:0},u.Rf=function(){var e,n,i,r,c;if(this.g)for(e=Jq(this,null,!1),i=(Ch(),Y(Z(Pw,1),jt,203,0,[lc,ta,hc])),r=0,c=i.length;r0&&(r[0]+=this.d,i-=r[0]),r[2]>0&&(r[2]+=this.d,i-=r[2]),this.c.a=y.Math.max(0,i),this.c.d=n.d+e.d+(this.c.a-i)/2,r[1]=y.Math.max(r[1],i),Cct(this,ta,n.d+e.d+r[0]-(r[1]-i)/2,r)},u.b=null,u.d=0,u.e=!1,u.f=!1,u.g=!1;var qQ=0,DF=0,ZGe=A(f0,"GridContainerCell",1179);T(419,23,{3:1,34:1,23:1,419:1},yW);var cb,jf,fh,GVt=Ri(f0,"HorizontalLabelAlignment",419,ji,qoe,Xie),WVt;T(267,171,{171:1,267:1},tAt,kLt,Z4t),u.Pf=function(){return h$(this)},u.Qf=function(){return CD(this)},u.a=0,u.c=!1;var W3e=A(f0,"LabelCell",267);T(219,307,{171:1,307:1,219:1},BC),u.Pf=function(){return wP(this)},u.Qf=function(){return vP(this)},u.Rf=function(){zX(this)},u.Sf=function(){jX(this)},u.b=0,u.c=0,u.d=!1;var YGe=A(f0,"StripContainerCell",219);T(1394,1,us,gz),u.Nb=function(e){return!!a(e,171)&&a(e,171).k};var KGe=A(f0,"StripContainerCell/lambda$0$Type",1394);T(1395,1,{},kg),u.oe=function(e){return a(e,171).Qf()};var JGe=A(f0,"StripContainerCell/lambda$1$Type",1395);T(1396,1,us,Dk),u.Nb=function(e){return!!a(e,171)&&a(e,171).j};var QGe=A(f0,"StripContainerCell/lambda$2$Type",1396);T(1397,1,{},vv),u.oe=function(e){return a(e,171).Pf()};var tWe=A(f0,"StripContainerCell/lambda$3$Type",1397);T(420,23,{3:1,34:1,23:1,420:1},xW);var dh,ab,Fh,$Vt=Ri(f0,"VerticalLabelAlignment",420,ji,Xoe,Zie),VVt;T(697,1,{},Uht),u.c=0,u.d=0,u.k=0,u.s=0,u.u=0,u.B=!1;var eWe=A(SO,"NodeContext",697);T(1177,1,jr,MR),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return yEt(a(e,69),a(n,69))};var nWe=A(SO,"NodeContext/0methodref$comparePortSides$Type",1177);T(1178,1,jr,pz),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return z1e(a(e,111),a(n,111))};var iWe=A(SO,"NodeContext/1methodref$comparePortContexts$Type",1178);T(147,23,{3:1,34:1,23:1,147:1},Zu);var qVt,XVt,ZVt,YVt,KVt,JVt,QVt,tqt,eqt,nqt,iqt,rqt,sqt,oqt,cqt,aqt,uqt,lqt,hqt,fqt,dqt,XQ,pqt=Ri(SO,"NodeLabelLocation",147,ji,Rq,Yie),gqt;T(111,1,{111:1},qkt);var rWe=A(SO,"PortContext",111);T(1182,1,{},_p),u.oe=function(e){return a(e,111).c?CD(a(e,111).c):0};var sWe=A(pE,"HorizontalPortPlacementSizeCalculator/lambda$0$Type",1182);T(1184,1,{},mz),u.td=function(e){k3t(a(e,267))};var oWe=A(pE,"LabelPlacer/lambda$0$Type",1184);T(1185,1,us,ER),u.Nb=function(e){return!!a(e,111).c};var cWe=A(pE,"LabelPlacer/lambda$1$Type",1185);T(1186,1,{},SR),u.td=function(e){k3t(a(e,111).c)};var aWe=A(pE,"LabelPlacer/lambda$2$Type",1186),Pvt;T(1181,1,{},L3),u.td=function(e){Bg(),oit(a(e,111))};var uWe=A(pE,"NodeLabelAndSizeUtilities/lambda$0$Type",1181);T(698,1,{},yrt),u.td=function(e){EQt(this.a,this.b,e)},u.b=!1;var lWe=A(pE,"NodeLabelCellCreator/lambda$0$Type",698);T(1180,1,{},WH),u.td=function(e){Vt(this.a,e)};var hWe=A(pE,"PortContextCreator/lambda$0$Type",1180),NF;T(1183,1,{},Sb),u.oe=function(e){return a(e,111).c?h$(a(e,111).c):0};var fWe=A(pE,"VerticalPortPlacementSizeCalculator/lambda$0$Type",1183);T(1525,1,{},TR);var dWe=A(gE,"GreedyRectangleStripOverlapRemover",1525);T(1526,1,jr,bz),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return yee(a(e,194),a(n,194))};var pWe=A(gE,"GreedyRectangleStripOverlapRemover/0methodref$compareByYCoordinate$Type",1526);T(1497,1,{},Dxt),u.a=5,u.e=0;var gWe=A(gE,"RectangleStripOverlapRemover",1497);T(1498,1,jr,US),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return xee(a(e,194),a(n,194))};var mWe=A(gE,"RectangleStripOverlapRemover/0methodref$compareLeftRectangleBorders$Type",1498);T(1500,1,jr,wz),u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)},u.Ld=function(e,n){return qre(a(e,194),a(n,194))};var bWe=A(gE,"RectangleStripOverlapRemover/1methodref$compareRightRectangleBorders$Type",1500);T(374,23,{3:1,34:1,23:1,374:1},q9);var lI,ZQ,YQ,hI,mqt=Ri(gE,"RectangleStripOverlapRemover/OverlapRemovalDirection",374,ji,Rce,Kie),bqt;T(194,1,{194:1},d$);var wWe=A(gE,"RectangleStripOverlapRemover/RectangleNode",194);T(1499,1,{},i9),u.td=function(e){qde(this.a,a(e,194))};var vWe=A(gE,"RectangleStripOverlapRemover/lambda$0$Type",1499),Iw=Sr(Qu,"EObject"),jE=Sr(F_,xFt),sf=Sr(F_,MFt),fI=Sr(F_,EFt),dI=Sr(F_,"ElkShape"),Si=Sr(F_,SFt),Xs=Sr(F_,ypt),os=Sr(F_,TFt),pI=Sr(Qu,CFt),xA=Sr(Qu,"EFactory"),wqt,KQ=Sr(Qu,AFt),of=Sr(Qu,"EPackage"),ms,vqt,_qt,Ivt,OF,yqt,Rvt,Dvt,Nvt,pp,xqt,Mqt,ic=Sr(F_,xpt),zr=Sr(F_,Mpt),Rl=Sr(F_,Ept);T(87,1,kFt),u.cg=function(){return this.dg(),null},u.dg=function(){return null},u.eg=function(){return this.dg(),!1},u.fg=function(){return!1},u.gg=function(e){Bi(this,e)};var _We=A(ax,"BasicNotifierImpl",87);T(92,87,PFt),u.Hg=function(){return Xl(this)},u.hg=function(e,n){return e},u.ig=function(){throw K(new Oi)},u.jg=function(e){var n;return n=jo(a(Ve(this.mg(),this.og()),17)),this.yg().Cg(this,n.n,n.f,e)},u.kg=function(e,n){throw K(new Oi)},u.lg=function(e,n,i){return ku(this,e,n,i)},u.mg=function(){var e;return this.ig()&&(e=this.ig().pj(),e)?e:this.Rg()},u.ng=function(){return vX(this)},u.og=function(){throw K(new Oi)},u.pg=function(){var e,n;return n=this.Jg().qj(),!n&&this.ig().vj(n=(yT(),e=Zot(V1(this.mg())),e==null?stt:new J5(this,e))),n},u.qg=function(e,n){return e},u.rg=function(e){var n;return n=e.Vi(),n?e.pi():xr(this.mg(),e)},u.sg=function(){var e;return e=this.ig(),e?e.sj():null},u.tg=function(){return this.ig()?this.ig().pj():null},u.ug=function(e,n,i){return l7(this,e,n,i)},u.vg=function(e){return TL(this,e)},u.wg=function(e,n){return Sct(this,e,n)},u.xg=function(){var e;return e=this.ig(),!!e&&e.tj()},u.yg=function(){throw K(new Oi)},u.zg=function(){return s7(this)},u.Ag=function(e,n,i,r){return B2(this,e,n,r)},u.Bg=function(e,n,i){var r;return r=a(Ve(this.mg(),n),61),r.aj().dj(this,this.Qg(),n-this.Sg(),e,i)},u.Cg=function(e,n,i,r){return KD(this,e,n,r)},u.Dg=function(e,n,i){var r;return r=a(Ve(this.mg(),n),61),r.aj().ej(this,this.Qg(),n-this.Sg(),e,i)},u.Eg=function(){return!!this.ig()&&(this.ig().rj(),!1)},u.Fg=function(e){return Oq(this,e)},u.Gg=function(e){var n;return n=this.rg(e),n>=0?this.Fg(n):gX(this,e)},u.Ig=function(e){return d7t(this,e)},u.Jg=function(){throw K(new Oi)},u.Kg=function(){return this.ig()?this.ig().rj():null},u.Lg=function(){return s7(this)},u.Mg=function(e,n){T7(this,e,n)},u.Ng=function(e){this.Jg().uj(e)},u.Og=function(e){this.Jg().wj(e)},u.Pg=function(e,n){var i,r,c,l;return l=this.sg(),l&&e&&(n=$s(l.fk(),this,n),l.jk(this)),r=this.yg(),r&&(IX(this,this.yg(),this.og()).Bb&ao?(c=r.zg(),c&&(e?!l&&c.jk(this):c.ik(this))):(n=(i=this.og(),i>=0?this.jg(n):this.yg().Cg(this,-1-i,null,n)),n=this.lg(null,-1,n))),this.Og(e),n},u.Qg=function(){return Wct(this)},u.Rg=function(){return(S1(),Ae).S},u.Sg=function(){return ei(this.Rg())},u.Ib=function(){return nh(this)};var yWe=A(Re,"BasicEObjectImpl",92),Eqt;T(107,92,{95:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1}),u.Tg=function(e){var n;return n=Gct(this),n[e]},u.Ug=function(e,n){var i;i=Gct(this),Vr(i,e,n)},u.Vg=function(e){var n;n=Gct(this),Vr(n,e,null)},u.cg=function(){return a(an(this,4),116)},u.dg=function(){throw K(new Oi)},u.eg=function(){return(this.Db&4)!=0},u.ig=function(){throw K(new Oi)},u.Wg=function(e){NC(this,2,e)},u.kg=function(e,n){this.Db=n<<16|this.Db&255,this.Wg(e)},u.mg=function(){return da(this)},u.og=function(){return this.Db>>16},u.pg=function(){var e,n;return yT(),n=Zot(V1((e=a(an(this,16),24),e||this.Rg()))),n==null?stt:new J5(this,n)},u.fg=function(){return(this.Db&1)==0},u.sg=function(){return a(an(this,128),1628)},u.tg=function(){return a(an(this,16),24)},u.xg=function(){return(this.Db&32)!=0},u.yg=function(){return a(an(this,2),42)},u.Eg=function(){return(this.Db&64)!=0},u.Jg=function(){throw K(new Oi)},u.Kg=function(){return a(an(this,64),261)},u.Ng=function(e){NC(this,16,e)},u.Og=function(e){NC(this,128,e)},u.Qg=function(){return ra(this)},u.Db=0;var xWe=A(Re,"MinimalEObjectImpl",107);T(108,107,{95:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1}),u.Wg=function(e){this.Cb=e},u.yg=function(){return this.Cb};var MWe=A(Re,"MinimalEObjectImpl/Container",108);T(1676,108,{95:1,379:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1}),u.ve=function(e){return!this.o&&(this.o=new lu((Ic(),pp),ag,this,0)),rPt(this.o,e.p?e.p:(we(),we(),ap)),this},u.ug=function(e,n,i){return Dut(this,e,n,i)},u.Dg=function(e,n,i){return plt(this,e,n,i)},u.Fg=function(e){return nct(this,e)},u.Mg=function(e,n){Pat(this,e,n)},u.Rg=function(){return Ic(),Mqt},u.we=function(){return iRt(this)},u.xe=function(e){return cn(this,e)},u.ye=function(e){return lV(this,e)},u.ze=function(e,n){return ga(this,e,n)};var EWe=A(d0,"EMapPropertyHolderImpl",1676);T(502,108,{95:1,531:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1},P3),u.ug=function(e,n,i){switch(e){case 0:return this.a;case 1:return this.b}return l7(this,e,n,i)},u.Fg=function(e){switch(e){case 0:return this.a!=0;case 1:return this.b!=0}return Oq(this,e)},u.Mg=function(e,n){switch(e){case 0:LV(this,lt(Yt(n)));return;case 1:PV(this,lt(Yt(n)));return}T7(this,e,n)},u.Rg=function(){return Ic(),vqt},u.Ib=function(){var e;return this.Db&64?nh(this):(e=new ul(nh(this)),e.a+=" (x: ",kv(e,this.a),e.a+=", y: ",kv(e,this.b),e.a+=")",e.a)},u.a=0,u.b=0;var SWe=A(d0,"ElkBendPointImpl",502);T(651,1676,{95:1,379:1,253:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1}),u.ug=function(e,n,i){return Vat(this,e,n,i)},u.Bg=function(e,n,i){return sX(this,e,n,i)},u.Dg=function(e,n,i){return YV(this,e,n,i)},u.Fg=function(e){return _at(this,e)},u.Mg=function(e,n){Kut(this,e,n)},u.Rg=function(){return Ic(),yqt},u.Vf=function(){return N$(this)},u.Ib=function(){return vq(this)},u.k=null;var TWe=A(d0,"ElkGraphElementImpl",651);T(652,651,{95:1,379:1,253:1,429:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1}),u.ug=function(e,n,i){return eut(this,e,n,i)},u.Fg=function(e){return out(this,e)},u.Mg=function(e,n){Jut(this,e,n)},u.Rg=function(){return Ic(),xqt},u.Wf=function(){return this.f},u.Xf=function(){return this.g},u.Yf=function(){return this.i},u.Zf=function(){return this.j},u.$f=function(e,n){tD(this,e,n)},u._f=function(e,n){Wd(this,e,n)},u.ag=function(e){th(this,e)},u.bg=function(e){eh(this,e)},u.Ib=function(){return cX(this)},u.f=0,u.g=0,u.i=0,u.j=0;var CWe=A(d0,"ElkShapeImpl",652);T(653,652,{95:1,379:1,97:1,253:1,429:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1}),u.ug=function(e,n,i){return Tut(this,e,n,i)},u.Bg=function(e,n,i){return Vut(this,e,n,i)},u.Dg=function(e,n,i){return qut(this,e,n,i)},u.Fg=function(e){return kat(this,e)},u.Mg=function(e,n){Hlt(this,e,n)},u.Rg=function(){return Ic(),_qt},u.Tf=function(){return!this.d&&(this.d=new pn(Xs,this,8,5)),this.d},u.Uf=function(){return!this.e&&(this.e=new pn(Xs,this,7,4)),this.e};var AWe=A(d0,"ElkConnectableShapeImpl",653);T(183,651,{95:1,379:1,105:1,253:1,183:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1},zS),u.jg=function(e){return zut(this,e)},u.ug=function(e,n,i){switch(e){case 3:return QD(this);case 4:return!this.b&&(this.b=new pn(Si,this,4,7)),this.b;case 5:return!this.c&&(this.c=new pn(Si,this,5,8)),this.c;case 6:return!this.a&&(this.a=new Wt(os,this,6,6)),this.a;case 7:return me(),!this.b&&(this.b=new pn(Si,this,4,7)),!(this.b.i<=1&&(!this.c&&(this.c=new pn(Si,this,5,8)),this.c.i<=1));case 8:return me(),!!ZC(this);case 9:return me(),!!Im(this);case 10:return me(),!this.b&&(this.b=new pn(Si,this,4,7)),this.b.i!=0&&(!this.c&&(this.c=new pn(Si,this,5,8)),this.c.i!=0)}return Vat(this,e,n,i)},u.Bg=function(e,n,i){var r;switch(n){case 3:return this.Cb&&(i=(r=this.Db>>16,r>=0?zut(this,i):this.Cb.Cg(this,-1-r,null,i))),hst(this,a(e,35),i);case 4:return!this.b&&(this.b=new pn(Si,this,4,7)),Kc(this.b,e,i);case 5:return!this.c&&(this.c=new pn(Si,this,5,8)),Kc(this.c,e,i);case 6:return!this.a&&(this.a=new Wt(os,this,6,6)),Kc(this.a,e,i)}return sX(this,e,n,i)},u.Dg=function(e,n,i){switch(n){case 3:return hst(this,null,i);case 4:return!this.b&&(this.b=new pn(Si,this,4,7)),$s(this.b,e,i);case 5:return!this.c&&(this.c=new pn(Si,this,5,8)),$s(this.c,e,i);case 6:return!this.a&&(this.a=new Wt(os,this,6,6)),$s(this.a,e,i)}return YV(this,e,n,i)},u.Fg=function(e){switch(e){case 3:return!!QD(this);case 4:return!!this.b&&this.b.i!=0;case 5:return!!this.c&&this.c.i!=0;case 6:return!!this.a&&this.a.i!=0;case 7:return!this.b&&(this.b=new pn(Si,this,4,7)),!(this.b.i<=1&&(!this.c&&(this.c=new pn(Si,this,5,8)),this.c.i<=1));case 8:return ZC(this);case 9:return Im(this);case 10:return!this.b&&(this.b=new pn(Si,this,4,7)),this.b.i!=0&&(!this.c&&(this.c=new pn(Si,this,5,8)),this.c.i!=0)}return _at(this,e)},u.Mg=function(e,n){switch(e){case 3:vDt(this,a(n,35));return;case 4:!this.b&&(this.b=new pn(Si,this,4,7)),Dr(this.b),!this.b&&(this.b=new pn(Si,this,4,7)),Lr(this.b,a(n,13));return;case 5:!this.c&&(this.c=new pn(Si,this,5,8)),Dr(this.c),!this.c&&(this.c=new pn(Si,this,5,8)),Lr(this.c,a(n,13));return;case 6:!this.a&&(this.a=new Wt(os,this,6,6)),Dr(this.a),!this.a&&(this.a=new Wt(os,this,6,6)),Lr(this.a,a(n,13));return}Kut(this,e,n)},u.Rg=function(){return Ic(),Ivt},u.Ib=function(){return s7t(this)};var kWe=A(d0,"ElkEdgeImpl",183);T(405,1676,{95:1,379:1,270:1,405:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1},I3),u.jg=function(e){return But(this,e)},u.ug=function(e,n,i){switch(e){case 1:return this.j;case 2:return this.k;case 3:return this.b;case 4:return this.c;case 5:return!this.a&&(this.a=new Ss(sf,this,5)),this.a;case 6:return lAt(this);case 7:return n?jq(this):this.i;case 8:return n?zq(this):this.f;case 9:return!this.g&&(this.g=new pn(os,this,9,10)),this.g;case 10:return!this.e&&(this.e=new pn(os,this,10,9)),this.e;case 11:return this.d}return Dut(this,e,n,i)},u.Bg=function(e,n,i){var r,c,l;switch(n){case 6:return this.Cb&&(i=(c=this.Db>>16,c>=0?But(this,i):this.Cb.Cg(this,-1-c,null,i))),fst(this,a(e,105),i);case 9:return!this.g&&(this.g=new pn(os,this,9,10)),Kc(this.g,e,i);case 10:return!this.e&&(this.e=new pn(os,this,10,9)),Kc(this.e,e,i)}return l=a(Ve((r=a(an(this,16),24),r||(Ic(),OF)),n),61),l.aj().dj(this,ra(this),n-ei((Ic(),OF)),e,i)},u.Dg=function(e,n,i){switch(n){case 5:return!this.a&&(this.a=new Ss(sf,this,5)),$s(this.a,e,i);case 6:return fst(this,null,i);case 9:return!this.g&&(this.g=new pn(os,this,9,10)),$s(this.g,e,i);case 10:return!this.e&&(this.e=new pn(os,this,10,9)),$s(this.e,e,i)}return plt(this,e,n,i)},u.Fg=function(e){switch(e){case 1:return this.j!=0;case 2:return this.k!=0;case 3:return this.b!=0;case 4:return this.c!=0;case 5:return!!this.a&&this.a.i!=0;case 6:return!!lAt(this);case 7:return!!this.i;case 8:return!!this.f;case 9:return!!this.g&&this.g.i!=0;case 10:return!!this.e&&this.e.i!=0;case 11:return this.d!=null}return nct(this,e)},u.Mg=function(e,n){switch(e){case 1:vC(this,lt(Yt(n)));return;case 2:_C(this,lt(Yt(n)));return;case 3:wC(this,lt(Yt(n)));return;case 4:bC(this,lt(Yt(n)));return;case 5:!this.a&&(this.a=new Ss(sf,this,5)),Dr(this.a),!this.a&&(this.a=new Ss(sf,this,5)),Lr(this.a,a(n,13));return;case 6:Ebe(this,a(n,105));return;case 7:uat(this,a(n,97));return;case 8:aat(this,a(n,97));return;case 9:!this.g&&(this.g=new pn(os,this,9,10)),Dr(this.g),!this.g&&(this.g=new pn(os,this,9,10)),Lr(this.g,a(n,13));return;case 10:!this.e&&(this.e=new pn(os,this,10,9)),Dr(this.e),!this.e&&(this.e=new pn(os,this,10,9)),Lr(this.e,a(n,13));return;case 11:sPt(this,hi(n));return}Pat(this,e,n)},u.Rg=function(){return Ic(),OF},u.Ib=function(){return T9t(this)},u.b=0,u.c=0,u.d=null,u.j=0,u.k=0;var LWe=A(d0,"ElkEdgeSectionImpl",405);T(142,108,{95:1,91:1,87:1,139:1,51:1,103:1,42:1,92:1,142:1,107:1,108:1}),u.ug=function(e,n,i){var r;return e==0?(!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),this.Ab):qu(this,e-ei(this.Rg()),Ve((r=a(an(this,16),24),r||this.Rg()),e),n,i)},u.Bg=function(e,n,i){var r,c;return n==0?(!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Kc(this.Ab,e,i)):(c=a(Ve((r=a(an(this,16),24),r||this.Rg()),n),61),c.aj().dj(this,ra(this),n-ei(this.Rg()),e,i))},u.Dg=function(e,n,i){var r,c;return n==0?(!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),$s(this.Ab,e,i)):(c=a(Ve((r=a(an(this,16),24),r||this.Rg()),n),61),c.aj().ej(this,ra(this),n-ei(this.Rg()),e,i))},u.Fg=function(e){var n;return e==0?!!this.Ab&&this.Ab.i!=0:$u(this,e-ei(this.Rg()),Ve((n=a(an(this,16),24),n||this.Rg()),e))},u.Ig=function(e){return Ght(this,e)},u.Mg=function(e,n){var i;switch(e){case 0:!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Dr(this.Ab),!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Lr(this.Ab,a(n,13));return}Yu(this,e-ei(this.Rg()),Ve((i=a(an(this,16),24),i||this.Rg()),e),n)},u.Og=function(e){NC(this,128,e)},u.Rg=function(){return ye(),Hqt},u.Xg=function(){this.Bb|=1},u.Yg=function(e){return e4(this,e)},u.Bb=0;var PWe=A(Re,"EModelElementImpl",142);T(638,142,{95:1,91:1,87:1,430:1,139:1,51:1,103:1,42:1,92:1,142:1,107:1,108:1},y8),u.Zg=function(e,n){return P7t(this,e,n)},u.$g=function(e){var n,i,r,c,l;if(this.a!=Xu(e)||e.Bb&256)throw K(new yn(HY+e.zb+zm));for(r=Bo(e);kc(r.a).i!=0;){if(i=a(RP(r,0,(n=a(at(kc(r.a),0),84),l=n.c,ct(l,96)?a(l,24):(ye(),gh))),24),km(i))return c=Xu(i).dh().$g(i),a(c,42).Ng(e),c;r=Bo(i)}return(e.D!=null?e.D:e.B)=="java.util.Map$Entry"?new dCt(e):new qst(e)},u._g=function(e,n){return Dm(this,e,n)},u.ug=function(e,n,i){var r;switch(e){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),this.Ab;case 1:return this.a}return qu(this,e-ei((ye(),hb)),Ve((r=a(an(this,16),24),r||hb),e),n,i)},u.Bg=function(e,n,i){var r,c;switch(n){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Kc(this.Ab,e,i);case 1:return this.a&&(i=a(this.a,42).Cg(this,4,of,i)),jat(this,a(e,207),i)}return c=a(Ve((r=a(an(this,16),24),r||(ye(),hb)),n),61),c.aj().dj(this,ra(this),n-ei((ye(),hb)),e,i)},u.Dg=function(e,n,i){var r,c;switch(n){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),$s(this.Ab,e,i);case 1:return jat(this,null,i)}return c=a(Ve((r=a(an(this,16),24),r||(ye(),hb)),n),61),c.aj().ej(this,ra(this),n-ei((ye(),hb)),e,i)},u.Fg=function(e){var n;switch(e){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return!!this.a}return $u(this,e-ei((ye(),hb)),Ve((n=a(an(this,16),24),n||hb),e))},u.Mg=function(e,n){var i;switch(e){case 0:!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Dr(this.Ab),!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Lr(this.Ab,a(n,13));return;case 1:bge(this,a(n,207));return}Yu(this,e-ei((ye(),hb)),Ve((i=a(an(this,16),24),i||hb),e),n)},u.Rg=function(){return ye(),hb};var MA,Ovt,Sqt,IWe=A(Re,"EFactoryImpl",638);T(914,638,{95:1,1698:1,91:1,87:1,430:1,139:1,51:1,103:1,42:1,92:1,142:1,107:1,108:1},Lg),u.Zg=function(e,n){switch(e.Ni()){case 12:return a(n,166).Lf();case 13:return Yc(n);default:throw K(new yn(mE+e.be()+zm))}},u.$g=function(e){var n,i,r,c,l,f,g,b;switch(e.G==-1&&(e.G=(n=Xu(e),n?Hp(n.bh(),e):-1)),e.G){case 4:return l=new jS,l;case 6:return f=new bit,f;case 7:return g=new wit,g;case 8:return r=new zS,r;case 9:return i=new P3,i;case 10:return c=new I3,c;case 11:return b=new Nk,b;default:throw K(new yn(HY+e.zb+zm))}},u._g=function(e,n){switch(e.Ni()){case 13:case 12:return null;default:throw K(new yn(mE+e.be()+zm))}};var RWe=A(d0,"ElkGraphFactoryImpl",914);T(399,142,{95:1,91:1,87:1,139:1,174:1,51:1,103:1,42:1,92:1,142:1,107:1,108:1}),u.pg=function(){var e,n;return n=(e=a(an(this,16),24),Zot(V1(e||this.Rg()))),n==null?(yT(),yT(),stt):new BSt(this,n)},u.ug=function(e,n,i){var r;switch(e){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),this.Ab;case 1:return this.be()}return qu(this,e-ei(this.Rg()),Ve((r=a(an(this,16),24),r||this.Rg()),e),n,i)},u.Fg=function(e){var n;switch(e){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null}return $u(this,e-ei(this.Rg()),Ve((n=a(an(this,16),24),n||this.Rg()),e))},u.Mg=function(e,n){var i;switch(e){case 0:!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Dr(this.Ab),!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Lr(this.Ab,a(n,13));return;case 1:this.ah(hi(n));return}Yu(this,e-ei(this.Rg()),Ve((i=a(an(this,16),24),i||this.Rg()),e),n)},u.Rg=function(){return ye(),Gqt},u.be=function(){return this.zb},u.ah=function(e){kh(this,e)},u.Ib=function(){return kC(this)},u.zb=null;var DWe=A(Re,"ENamedElementImpl",399);T(248,399,{95:1,91:1,87:1,139:1,174:1,51:1,207:1,103:1,42:1,92:1,142:1,248:1,107:1,108:1,613:1},D4t),u.jg=function(e){return URt(this,e)},u.ug=function(e,n,i){var r;switch(e){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),this.Ab;case 1:return this.zb;case 2:return this.yb;case 3:return this.xb;case 4:return this.sb;case 5:return!this.rb&&(this.rb=new $v(this,cf,this)),this.rb;case 6:return!this.vb&&(this.vb=new fM(of,this,6,7)),this.vb;case 7:return n?this.Db>>16==7?a(this.Cb,207):null:hAt(this)}return qu(this,e-ei((ye(),C0)),Ve((r=a(an(this,16),24),r||C0),e),n,i)},u.Bg=function(e,n,i){var r,c,l;switch(n){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Kc(this.Ab,e,i);case 4:return this.sb&&(i=a(this.sb,42).Cg(this,1,xA,i)),Gat(this,a(e,430),i);case 5:return!this.rb&&(this.rb=new $v(this,cf,this)),Kc(this.rb,e,i);case 6:return!this.vb&&(this.vb=new fM(of,this,6,7)),Kc(this.vb,e,i);case 7:return this.Cb&&(i=(c=this.Db>>16,c>=0?URt(this,i):this.Cb.Cg(this,-1-c,null,i))),ku(this,e,7,i)}return l=a(Ve((r=a(an(this,16),24),r||(ye(),C0)),n),61),l.aj().dj(this,ra(this),n-ei((ye(),C0)),e,i)},u.Dg=function(e,n,i){var r,c;switch(n){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),$s(this.Ab,e,i);case 4:return Gat(this,null,i);case 5:return!this.rb&&(this.rb=new $v(this,cf,this)),$s(this.rb,e,i);case 6:return!this.vb&&(this.vb=new fM(of,this,6,7)),$s(this.vb,e,i);case 7:return ku(this,null,7,i)}return c=a(Ve((r=a(an(this,16),24),r||(ye(),C0)),n),61),c.aj().ej(this,ra(this),n-ei((ye(),C0)),e,i)},u.Fg=function(e){var n;switch(e){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.yb!=null;case 3:return this.xb!=null;case 4:return!!this.sb;case 5:return!!this.rb&&this.rb.i!=0;case 6:return!!this.vb&&this.vb.i!=0;case 7:return!!hAt(this)}return $u(this,e-ei((ye(),C0)),Ve((n=a(an(this,16),24),n||C0),e))},u.Ig=function(e){var n;return n=Rbe(this,e),n||Ght(this,e)},u.Mg=function(e,n){var i;switch(e){case 0:!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Dr(this.Ab),!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Lr(this.Ab,a(n,13));return;case 1:kh(this,hi(n));return;case 2:zV(this,hi(n));return;case 3:UV(this,hi(n));return;case 4:glt(this,a(n,430));return;case 5:!this.rb&&(this.rb=new $v(this,cf,this)),Dr(this.rb),!this.rb&&(this.rb=new $v(this,cf,this)),Lr(this.rb,a(n,13));return;case 6:!this.vb&&(this.vb=new fM(of,this,6,7)),Dr(this.vb),!this.vb&&(this.vb=new fM(of,this,6,7)),Lr(this.vb,a(n,13));return}Yu(this,e-ei((ye(),C0)),Ve((i=a(an(this,16),24),i||C0),e),n)},u.Rg=function(){return ye(),C0},u.Xg=function(){Kq(this)},u.bh=function(){return!this.rb&&(this.rb=new $v(this,cf,this)),this.rb},u.dh=function(){return this.sb},u.eh=function(){return this.ub},u.fh=function(){return this.xb},u.gh=function(){return this.yb},u.hh=function(e){this.ub=e},u.Ib=function(){var e;return this.Db&64?kC(this):(e=new ul(kC(this)),e.a+=" (nsURI: ",mo(e,this.yb),e.a+=", nsPrefix: ",mo(e,this.xb),e.a+=")",e.a)},u.xb=null,u.yb=null;var Tqt,NWe=A(Re,"EPackageImpl",248);T(506,248,{95:1,1702:1,506:1,91:1,87:1,139:1,174:1,51:1,207:1,103:1,42:1,92:1,142:1,248:1,107:1,108:1,613:1},j9t),u.q=!1,u.r=!1;var Cqt=!1,OWe=A(d0,"ElkGraphPackageImpl",506);T(263,652,{95:1,379:1,253:1,137:1,429:1,263:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1},jS),u.jg=function(e){return Fut(this,e)},u.ug=function(e,n,i){switch(e){case 7:return fAt(this);case 8:return this.a}return eut(this,e,n,i)},u.Bg=function(e,n,i){var r;switch(n){case 7:return this.Cb&&(i=(r=this.Db>>16,r>=0?Fut(this,i):this.Cb.Cg(this,-1-r,null,i))),aot(this,a(e,253),i)}return sX(this,e,n,i)},u.Dg=function(e,n,i){return n==7?aot(this,null,i):YV(this,e,n,i)},u.Fg=function(e){switch(e){case 7:return!!fAt(this);case 8:return!le("",this.a)}return out(this,e)},u.Mg=function(e,n){switch(e){case 7:TDt(this,a(n,253));return;case 8:JLt(this,hi(n));return}Jut(this,e,n)},u.Rg=function(){return Ic(),Rvt},u.Ib=function(){return P8t(this)},u.a="";var BWe=A(d0,"ElkLabelImpl",263);T(246,653,{95:1,379:1,97:1,253:1,35:1,429:1,246:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1},bit),u.jg=function(e){return Gut(this,e)},u.ug=function(e,n,i){switch(e){case 9:return!this.c&&(this.c=new Wt(Rl,this,9,9)),this.c;case 10:return!this.a&&(this.a=new Wt(zr,this,10,11)),this.a;case 11:return io(this);case 12:return!this.b&&(this.b=new Wt(Xs,this,12,3)),this.b;case 13:return me(),!this.a&&(this.a=new Wt(zr,this,10,11)),this.a.i>0}return Tut(this,e,n,i)},u.Bg=function(e,n,i){var r;switch(n){case 9:return!this.c&&(this.c=new Wt(Rl,this,9,9)),Kc(this.c,e,i);case 10:return!this.a&&(this.a=new Wt(zr,this,10,11)),Kc(this.a,e,i);case 11:return this.Cb&&(i=(r=this.Db>>16,r>=0?Gut(this,i):this.Cb.Cg(this,-1-r,null,i))),yst(this,a(e,35),i);case 12:return!this.b&&(this.b=new Wt(Xs,this,12,3)),Kc(this.b,e,i)}return Vut(this,e,n,i)},u.Dg=function(e,n,i){switch(n){case 9:return!this.c&&(this.c=new Wt(Rl,this,9,9)),$s(this.c,e,i);case 10:return!this.a&&(this.a=new Wt(zr,this,10,11)),$s(this.a,e,i);case 11:return yst(this,null,i);case 12:return!this.b&&(this.b=new Wt(Xs,this,12,3)),$s(this.b,e,i)}return qut(this,e,n,i)},u.Fg=function(e){switch(e){case 9:return!!this.c&&this.c.i!=0;case 10:return!!this.a&&this.a.i!=0;case 11:return!!io(this);case 12:return!!this.b&&this.b.i!=0;case 13:return!this.a&&(this.a=new Wt(zr,this,10,11)),this.a.i>0}return kat(this,e)},u.Mg=function(e,n){switch(e){case 9:!this.c&&(this.c=new Wt(Rl,this,9,9)),Dr(this.c),!this.c&&(this.c=new Wt(Rl,this,9,9)),Lr(this.c,a(n,13));return;case 10:!this.a&&(this.a=new Wt(zr,this,10,11)),Dr(this.a),!this.a&&(this.a=new Wt(zr,this,10,11)),Lr(this.a,a(n,13));return;case 11:yDt(this,a(n,35));return;case 12:!this.b&&(this.b=new Wt(Xs,this,12,3)),Dr(this.b),!this.b&&(this.b=new Wt(Xs,this,12,3)),Lr(this.b,a(n,13));return}Hlt(this,e,n)},u.Rg=function(){return Ic(),Dvt},u.Ib=function(){return pht(this)};var FWe=A(d0,"ElkNodeImpl",246);T(187,653,{95:1,379:1,97:1,253:1,121:1,429:1,187:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1},wit),u.jg=function(e){return Uut(this,e)},u.ug=function(e,n,i){return e==9?Tf(this):Tut(this,e,n,i)},u.Bg=function(e,n,i){var r;switch(n){case 9:return this.Cb&&(i=(r=this.Db>>16,r>=0?Uut(this,i):this.Cb.Cg(this,-1-r,null,i))),dst(this,a(e,35),i)}return Vut(this,e,n,i)},u.Dg=function(e,n,i){return n==9?dst(this,null,i):qut(this,e,n,i)},u.Fg=function(e){return e==9?!!Tf(this):kat(this,e)},u.Mg=function(e,n){switch(e){case 9:_Dt(this,a(n,35));return}Hlt(this,e,n)},u.Rg=function(){return Ic(),Nvt},u.Ib=function(){return pNt(this)};var UWe=A(d0,"ElkPortImpl",187),Aqt=Sr(qs,"BasicEMap/Entry");T(966,108,{95:1,38:1,91:1,87:1,134:1,51:1,103:1,42:1,92:1,107:1,108:1},Nk),u.Fb=function(e){return this===e},u.kc=function(){return this.b},u.Hb=function(){return cm(this)},u.kh=function(e){KLt(this,a(e,166))},u.ug=function(e,n,i){switch(e){case 0:return this.b;case 1:return this.c}return l7(this,e,n,i)},u.Fg=function(e){switch(e){case 0:return!!this.b;case 1:return this.c!=null}return Oq(this,e)},u.Mg=function(e,n){switch(e){case 0:KLt(this,a(n,166));return;case 1:YLt(this,n);return}T7(this,e,n)},u.Rg=function(){return Ic(),pp},u.ih=function(){var e;return this.a==-1&&(e=this.b,this.a=e?Yr(e):0),this.a},u.lc=function(){return this.c},u.jh=function(e){this.a=e},u.mc=function(e){var n;return n=this.c,YLt(this,e),n},u.Ib=function(){var e;return this.Db&64?nh(this):(e=new im,Ii(Ii(Ii(e,this.b?this.b.Lf():tu)," -> "),zT(this.c)),e.a)},u.a=-1,u.c=null;var ag=A(d0,"ElkPropertyToValueMapEntryImpl",966);T(876,1,{},vz);var zWe=A(Ds,"JsonAdapter",876);T(186,54,rp,xf);var jWe=A(Ds,"JsonImportException",186);T(754,1,{},JRt);var HWe=A(Ds,"JsonImporter",754);T(792,1,{},YMt);var GWe=A(Ds,"JsonImporter/lambda$0$Type",792);T(793,1,{},KMt);var WWe=A(Ds,"JsonImporter/lambda$1$Type",793);T(816,1,{},r9);var $We=A(Ds,"JsonImporter/lambda$10$Type",816);T(818,1,{},$H);var VWe=A(Ds,"JsonImporter/lambda$11$Type",818);T(819,1,{},JMt),u.td=function(e){Wce(this.b,this.a,e)};var qWe=A(Ds,"JsonImporter/lambda$12$Type",819);T(820,1,{},QMt);var XWe=A(Ds,"JsonImporter/lambda$13$Type",820);T(821,1,{},tEt);var ZWe=A(Ds,"JsonImporter/lambda$14$Type",821);T(822,1,{},VH);var YWe=A(Ds,"JsonImporter/lambda$15$Type",822);T(823,1,{},qH);var KWe=A(Ds,"JsonImporter/lambda$16$Type",823);T(824,1,{},XH);var JWe=A(Ds,"JsonImporter/lambda$17$Type",824);T(825,1,{},Jy);var QWe=A(Ds,"JsonImporter/lambda$18$Type",825);T(756,1,{},ZH);var t$e=A(Ds,"JsonImporter/lambda$19$Type",756);T(794,1,{},YH);var e$e=A(Ds,"JsonImporter/lambda$2$Type",794);T(829,1,{},HTt);var n$e=A(Ds,"JsonImporter/lambda$20$Type",829);T(830,1,{},KH),u.td=function(e){$ce(this.a,e)};var i$e=A(Ds,"JsonImporter/lambda$21$Type",830);T(795,1,{},JH);var r$e=A(Ds,"JsonImporter/lambda$22$Type",795);T(796,1,{},QH);var s$e=A(Ds,"JsonImporter/lambda$23$Type",796);T(798,1,{},s9);var o$e=A(Ds,"JsonImporter/lambda$24$Type",798);T(799,1,{},o9);var c$e=A(Ds,"JsonImporter/lambda$25$Type",799);T(801,1,{},tG);var a$e=A(Ds,"JsonImporter/lambda$26$Type",801);T(809,1,{},x4t);var u$e=A(Ds,"JsonImporter/lambda$27$Type",809);T(811,1,{},eG);var l$e=A(Ds,"JsonImporter/lambda$28$Type",811);T(812,1,{},nG);var h$e=A(Ds,"JsonImporter/lambda$29$Type",812);T(797,1,{},iG);var f$e=A(Ds,"JsonImporter/lambda$3$Type",797);T(814,1,{},rG);var d$e=A(Ds,"JsonImporter/lambda$30$Type",814);T(815,1,{},sG);var p$e=A(Ds,"JsonImporter/lambda$31$Type",815);T(817,1,{},oG);var g$e=A(Ds,"JsonImporter/lambda$32$Type",817);T(826,1,{},cG),u.td=function(e){Vce(this.a,e)};var m$e=A(Ds,"JsonImporter/lambda$33$Type",826);T(827,1,{},eEt),u.td=function(e){xte(this.a,this.b,e)};var b$e=A(Ds,"JsonImporter/lambda$34$Type",827);T(828,1,{},nEt),u.td=function(e){Mte(this.a,this.b,e)};var w$e=A(Ds,"JsonImporter/lambda$35$Type",828);T(805,1,{},iEt);var v$e=A(Ds,"JsonImporter/lambda$36$Type",805);T(806,1,{},rEt);var _$e=A(Ds,"JsonImporter/lambda$37$Type",806);T(807,1,{},cEt);var y$e=A(Ds,"JsonImporter/lambda$38$Type",807);T(808,1,{},aEt);var x$e=A(Ds,"JsonImporter/lambda$39$Type",808);T(800,1,{},aG);var M$e=A(Ds,"JsonImporter/lambda$4$Type",800);T(802,1,{},uG);var E$e=A(Ds,"JsonImporter/lambda$5$Type",802);T(803,1,{},sEt);var S$e=A(Ds,"JsonImporter/lambda$6$Type",803);T(804,1,{},oEt);var T$e=A(Ds,"JsonImporter/lambda$7$Type",804);T(810,1,{},M4t);var C$e=A(Ds,"JsonImporter/lambda$8$Type",810);T(813,1,{},lG);var A$e=A(Ds,"JsonImporter/lambda$9$Type",813);T(864,1,{},hG),u.td=function(e){x2(this.a,new _2(hi(e)))};var k$e=A(Ds,"JsonMetaDataConverter/lambda$0$Type",864);T(865,1,{},fG),u.td=function(e){gse(this.a,e)};var L$e=A(Ds,"JsonMetaDataConverter/lambda$1$Type",865);T(866,1,{},dG),u.td=function(e){Toe(this.a,e)};var P$e=A(Ds,"JsonMetaDataConverter/lambda$2$Type",866);T(867,1,{},pG),u.td=function(e){pse(this.a,e)};var I$e=A(Ds,"JsonMetaDataConverter/lambda$3$Type",867);T(229,23,{3:1,34:1,23:1,229:1},g2);var BF,FF,JQ,UF,zF,jF,QQ,ttt,HF=Ri($P,"GraphFeature",229,ji,Sue,Jie),kqt;T(16,1,{34:1,166:1},kr,es,bn,xc),u.vd=function(e){return nee(this,a(e,166))},u.Fb=function(e){return N4t(this,e)},u.Of=function(){return Xe(this)},u.Lf=function(){return this.b},u.Hb=function(){return z1(this.b)},u.Ib=function(){return this.b};var R$e=A($P,"Property",16);T(727,1,jr,c9),u.Ld=function(e,n){return Ihe(this,a(e,93),a(n,93))},u.Fb=function(e){return this===e},u.Md=function(){return new _r(this)};var D$e=A($P,"PropertyHolderComparator",727),Bvt=Sr(qs,"EList");T(59,41,{20:1,25:1,41:1,13:1,15:1,59:1,52:1}),u.bd=function(e,n){YL(this,e,n)},u.nc=function(e){return ni(this,e)},u.oc=function(e){return Lr(this,e)},u.oh=function(){return new w2(this)},u.ph=function(){return new K5(this)},u.qh=function(e){return UL(this,e)},u.rh=function(){return!0},u.sh=function(e,n){},u.th=function(){},u.uh=function(e,n){fV(this,e,n)},u.vh=function(e,n){},u.wh=function(e,n,i){},u.Fb=function(e){return JDt(this,e)},u.Hb=function(){return Mat(this)},u.xh=function(){return!1},u.tc=function(){return new $n(this)},u.ed=function(){return new WT(this)},u.fd=function(e){var n;if(n=this._b(),e<0||e>n)throw K(new jv(e,n));return new x$(this,e)},u.vc=function(e){return MV(this,e)},u.zh=function(e,n){return n},u.hd=function(e,n){return F2(this,e,n)},u.Ib=function(){return iut(this)},u.Bh=function(){return!0},u.Ch=function(e,n){return SC(this,n)};var N$e=A(qs,"AbstractEList",59);T(55,59,Nf,Z0,Qv,bat),u.lh=function(e){return TRt(this,e)},u.mh=function(e,n){JL(this,e,n)},u.nh=function(e){ML(this,e)},u.Dh=function(e){return Fct(this,e)},u.Pb=function(){hC(this)},u.pc=function(e){return WC(this,e)},u.cd=function(e){return at(this,e)},u.Eh=function(e){ZIt(this,e)},u.dd=function(e){return FRt(this,e)},u.Wb=function(){return this.i==0},u.Fh=function(e){return dt(un,te,1,e,5,1)},u.yh=function(e){return this.g[e]},u.gd=function(e){return U2(this,e)},u.Ah=function(e,n){return xV(this,e,n)},u._b=function(){return this.i},u.yc=function(){return oct(this)},u.zc=function(e){return uut(this,e)},u.i=0;var Fvt=A(qs,"BasicEList",55),Uvt=Sr(qs,"TreeIterator");T(629,55,KY),u.gc=function(e){ks(this,e)},u.hc=function(){return this.g==null&&!this.c?Fot(this):this.g==null||this.i!=0&&a(this.g[this.i-1],43).hc()},u.ic=function(){return k7(this)},u.jc=function(){if(!this.e)throw K(new yc("There is no valid object to remove."));this.e.jc()},u.c=!1;var O$e=A(qs,"AbstractTreeIterator",629);T(621,629,KY,krt),u.Gh=function(e){var n;return n=a(e,51).pg().tc(),ct(n,260)&&a(n,260).Zj(new CR),n};var B$e=A(JY,"ElkGraphUtil/PropertiesSkippingTreeIterator",621);T(868,1,{},CR);var F$e=A(JY,"ElkGraphUtil/PropertiesSkippingTreeIterator/1",868),gI,ett,mI=A(JY,"ElkReflect",null);T(784,1,B_,HS),u.Nf=function(e){return lN(),Aae(a(e,185))};var U$e=A(JY,"ElkReflect/lambda$0$Type",784),Rw,z$e=Sr(qs,"ResourceLocator");T(953,1,{});var j$e=A(qs,"DelegatingResourceLocator",953);T(954,953,{});var H$e=A("org.eclipse.emf.common","EMFPlugin",954),ntt=Sr(lUt,"Adapter"),$3e=Sr(lUt,"Notification");T(1016,1,Wpt),u.Hh=function(){return this.d},u.Ih=function(e){},u.Jh=function(e){this.d=e},u.Kh=function(e){this.d==e&&(this.d=null)},u.d=null;var G$e=A(ax,"AdapterImpl",1016);T(1688,59,hUt),u.lh=function(e){var n,i,r;if(++this.j,e.Wb())return!1;for(n=this.hi(),r=e.tc();r.hc();)i=r.ic(),this.Wh(this.Ch(n,i)),++n;return!0},u.mh=function(e,n){YSt(this,e,n)},u.nh=function(e){JCt(this,e)},u.Uh=function(){return this.Xh()},u.Pb=function(){nL(this,this.hi(),this.ii())},u.pc=function(e){return this.Zh(e)},u.qc=function(e){return this.$h(e)},u.Vh=function(e,n){this.ei().tl()},u.Wh=function(e){this.ei().tl()},u.Xh=function(){return this.ei()},u.Yh=function(){this.ei().tl()},u.Zh=function(e){return this.ei().tl()},u.$h=function(e){return this.ei().tl()},u._h=function(e){return this.ei().tl()},u.ai=function(e){return this.ei().tl()},u.bi=function(){return this.ei().tl()},u.ci=function(e){return this.ei().tl()},u.di=function(){return this.ei().tl()},u.fi=function(e){return this.ei().tl()},u.gi=function(e,n){return this.ei().tl()},u.hi=function(){return this.ei().tl()},u.ii=function(){return this.ei().tl()},u.ji=function(e){return this.ei().tl()},u.ki=function(){return this.ei().tl()},u.Fb=function(e){return this._h(e)},u.cd=function(e){return this.zh(e,this.ai(e))},u.Hb=function(){return this.bi()},u.dd=function(e){return this.ci(e)},u.Wb=function(){return this.di()},u.yh=function(e){return this.ai(e)},u.gd=function(e){return PD(this,e)},u.vc=function(e){var n;return n=this.dd(e),n>=0?(this.gd(n),!0):!1},u.Ah=function(e,n){return this.gi(e,this.Ch(e,n))},u._b=function(){return this.hi()},u.yc=function(){return this.ii()},u.zc=function(e){return this.ji(e)},u.Ib=function(){return this.ki()};var W$e=A(qs,"DelegatingEList",1688);T(1689,1688,hUt),u.li=function(e,n){return Sht(this,e,n)},u.lh=function(e){return this.li(this.hi(),e)},u.mh=function(e,n){H9t(this,e,n)},u.nh=function(e){D9t(this,e)},u.rh=function(){return!this.qi()},u.Pb=function(){$7(this)},u.mi=function(e,n,i,r,c){return new W4t(this,e,n,i,r,c)},u.ni=function(e){Bi(this.Oh(),e)},u.oi=function(){return null},u.pi=function(){return-1},u.Oh=function(){return null},u.qi=function(){return!1},u.ri=function(e,n){return n},u.si=function(e,n){return n},u.ti=function(){return!1},u.ui=function(){return!this.di()},u.gd=function(e){var n,i,r,c;return this.ti()?(r=this.ui(),n=this.mi(4,c=PD(this,e),null,e,r),this.qi()&&c?(i=this.si(c,null),i?(i.Sh(n),i.Th()):this.ni(n)):this.ni(n),c):(c=PD(this,e),this.qi()&&c&&(i=this.si(c,null),i&&i.Th()),c)},u.Ah=function(e,n){return DNt(this,e,n)};var $$e=A(ax,"DelegatingNotifyingListImpl",1689);T(136,1,r6),u.Sh=function(e){return elt(this,e)},u.Th=function(){vV(this)},u.Lh=function(){return this.d},u.oi=function(){return null},u.vi=function(){return null},u.Mh=function(e){return-1},u.Nh=function(){return LDt(this)},u.Oh=function(){return null},u.Ph=function(){return tht(this)},u.Qh=function(){return this.o<0?this.o<-2?-2-this.o-1:-1:this.o},u.wi=function(){return!1},u.Rh=function(e){var n,i,r,c,l,f,g,b,v,M,k;switch(this.d){case 1:case 2:switch(c=e.Lh(),c){case 1:case 2:if(l=e.Oh(),zt(l)===zt(this.Oh())&&this.Mh(null)==e.Mh(null))return this.g=e.Nh(),e.Lh()==1&&(this.d=1),!0}case 4:{switch(c=e.Lh(),c){case 4:{if(l=e.Oh(),zt(l)===zt(this.Oh())&&this.Mh(null)==e.Mh(null))return v=Fht(this),b=this.o<0?this.o<-2?-2-this.o-1:-1:this.o,f=e.Qh(),this.d=6,k=new Qv(2),b<=f?(ni(k,this.n),ni(k,e.Ph()),this.g=Y(Z(Gn,1),pi,22,15,[this.o=b,f+1])):(ni(k,e.Ph()),ni(k,this.n),this.g=Y(Z(Gn,1),pi,22,15,[this.o=f,b])),this.n=k,v||(this.o=-2-this.o-1),!0;break}}break}case 6:{switch(c=e.Lh(),c){case 4:{if(l=e.Oh(),zt(l)===zt(this.Oh())&&this.Mh(null)==e.Mh(null)){for(v=Fht(this),f=e.Qh(),M=a(this.g,37),r=dt(Gn,pi,22,M.length+1,15,1),n=0;n>>0).toString(16)),i.a+=" (eventType: ",this.d){case 1:{i.a+="SET";break}case 2:{i.a+="UNSET";break}case 3:{i.a+="ADD";break}case 5:{i.a+="ADD_MANY";break}case 4:{i.a+="REMOVE";break}case 6:{i.a+="REMOVE_MANY";break}case 7:{i.a+="MOVE";break}case 8:{i.a+="REMOVING_ADAPTER";break}case 9:{i.a+="RESOLVE";break}default:{GG(i,this.d);break}}if(_Nt(this)&&(i.a+=", touch: true"),i.a+=", position: ",GG(i,this.o<0?this.o<-2?-2-this.o-1:-1:this.o),i.a+=", notifier: ",CT(i,this.Oh()),i.a+=", feature: ",CT(i,this.oi()),i.a+=", oldValue: ",CT(i,tht(this)),i.a+=", newValue: ",this.d==6&&ct(this.g,37)){for(n=a(this.g,37),i.a+="[",e=0;e10?((!this.b||this.c.j!=this.a)&&(this.b=new lL(this),this.a=this.j),ET(this.b,e)):WC(this,e)},u.Bh=function(){return!0},u.a=0;var J$e=A(qs,"AbstractEList/1",869);T(295,79,DZ,jv);var Q$e=A(qs,"AbstractEList/BasicIndexOutOfBoundsException",295);T(36,1,Cs,$n),u.gc=function(e){ks(this,e)},u.Bi=function(){if(this.i.j!=this.f)throw K(new C)},u.Ci=function(){return ci(this)},u.hc=function(){return this.e!=this.i._b()},u.ic=function(){return this.Ci()},u.jc=function(){HC(this)},u.e=0,u.f=0,u.g=-1;var tVe=A(qs,"AbstractEList/EIterator",36);T(296,36,kf,WT,x$),u.jc=function(){HC(this)},u.Bc=function(e){_It(this,e)},u.Di=function(){var e;try{return e=this.d.cd(--this.e),this.Bi(),this.g=this.e,e}catch(n){throw n=vr(n),ct(n,79)?(this.Bi(),K(new J)):K(n)}},u.Ei=function(e){bRt(this,e)},u.Cc=function(){return this.e!=0},u.Dc=function(){return this.e},u.Ec=function(){return this.Di()},u.Fc=function(){return this.e-1},u.Gc=function(e){this.Ei(e)};var eVe=A(qs,"AbstractEList/EListIterator",296);T(324,36,Cs,w2),u.Ci=function(){return Iq(this)},u.jc=function(){throw K(new Oi)};var nVe=A(qs,"AbstractEList/NonResolvingEIterator",324);T(355,296,kf,K5,Rst),u.Bc=function(e){throw K(new Oi)},u.Ci=function(){var e;try{return e=this.c.yh(this.e),this.Bi(),this.g=this.e++,e}catch(n){throw n=vr(n),ct(n,79)?(this.Bi(),K(new J)):K(n)}},u.Di=function(){var e;try{return e=this.c.yh(--this.e),this.Bi(),this.g=this.e,e}catch(n){throw n=vr(n),ct(n,79)?(this.Bi(),K(new J)):K(n)}},u.jc=function(){throw K(new Oi)},u.Gc=function(e){throw K(new Oi)};var iVe=A(qs,"AbstractEList/NonResolvingEListIterator",355);T(1673,59,fUt),u.lh=function(e){var n,i,r,c,l,f,g,b,v;if(r=e._b(),r!=0){for(b=(i=a(an(this.a,4),116),i==null?0:i.length),v=b+r,n=Nat(this,v),g=e.tc(),l=b;li)throw K(new jv(e,i));return new l4t(this,e)},u.Pb=function(){var e,n;++this.j,e=a(an(this.a,4),116),n=e==null?0:e.length,cP(this,null),fV(this,n,e)},u.pc=function(e){var n,i,r,c;if(n=a(an(this.a,4),116),n!=null){if(e!=null){for(r=0,c=n.length;r=i)throw K(new jv(e,i));return n[e]},u.dd=function(e){var n,i,r;if(n=a(an(this.a,4),116),n!=null){if(e!=null){for(i=0,r=n.length;ii)throw K(new jv(e,i));return new u4t(this,e)},u.yh=function(e){return a(an(this.a,4),116)[e]},u.gd=function(e){return Q0e(this,e)},u.Ah=function(e,n){var i,r;return i=Ffe(this),r=i[e],Nrt(i,e,SC(this,n)),cP(this,i),r},u._b=function(){var e;return e=a(an(this.a,4),116),e==null?0:e.length},u.yc=function(){var e,n,i;return e=a(an(this.a,4),116),i=e==null?0:e.length,n=dt(ntt,nK,380,i,0,1),i>0&&Aa(e,0,n,0,i),n},u.zc=function(e){var n,i,r;return n=a(an(this.a,4),116),r=n==null?0:n.length,r>0&&(e.lengthr&&Vr(e,r,null),e};var Lqt,rVe=A(qs,"ArrayDelegatingEList",1673);T(927,36,Cs,$kt),u.Bi=function(){if(this.b.j!=this.f||zt(a(an(this.b.a,4),116))!==zt(this.a))throw K(new C)},u.jc=function(){HC(this),this.a=a(an(this.b.a,4),116)};var sVe=A(qs,"ArrayDelegatingEList/EIterator",927);T(640,296,kf,NCt,u4t),u.Bi=function(){if(this.b.j!=this.f||zt(a(an(this.b.a,4),116))!==zt(this.a))throw K(new C)},u.Ei=function(e){bRt(this,e),this.a=a(an(this.b.a,4),116)},u.jc=function(){HC(this),this.a=a(an(this.b.a,4),116)};var oVe=A(qs,"ArrayDelegatingEList/EListIterator",640);T(928,324,Cs,Vkt),u.Bi=function(){if(this.b.j!=this.f||zt(a(an(this.b.a,4),116))!==zt(this.a))throw K(new C)};var cVe=A(qs,"ArrayDelegatingEList/NonResolvingEIterator",928);T(641,355,kf,OCt,l4t),u.Bi=function(){if(this.b.j!=this.f||zt(a(an(this.b.a,4),116))!==zt(this.a))throw K(new C)};var aVe=A(qs,"ArrayDelegatingEList/NonResolvingEListIterator",641);T(549,295,DZ,MW);var uVe=A(qs,"BasicEList/BasicIndexOutOfBoundsException",549);T(630,55,Nf,xrt),u.bd=function(e,n){throw K(new Oi)},u.nc=function(e){throw K(new Oi)},u.oc=function(e){throw K(new Oi)},u.Pb=function(){throw K(new Oi)},u.Eh=function(e){throw K(new Oi)},u.tc=function(){return this.oh()},u.ed=function(){return this.ph()},u.fd=function(e){return this.qh(e)},u.gd=function(e){throw K(new Oi)},u.vc=function(e){throw K(new Oi)},u.hd=function(e,n){throw K(new Oi)};var lVe=A(qs,"BasicEList/UnmodifiableEList",630);T(639,1,{3:1,20:1,13:1,15:1,52:1,533:1}),u.bd=function(e,n){oee(this,e,a(n,38))},u.nc=function(e){return zee(this,a(e,38))},u.sc=function(e){vo(this,e)},u.cd=function(e){return a(at(this.c,e),134)},u.uc=function(){return this.xc()},u.gd=function(e){return a(this.c.gd(e),38)},u.hd=function(e,n){return ase(this,e,a(n,38))},u.jd=function(e){R1(this,e)},u.wc=function(){return new Ei(this,16)},u.xc=function(){return new gi(null,this.wc())},u.oc=function(e){return this.c.oc(e)},u.Pb=function(){this.c.Pb()},u.pc=function(e){return this.c.pc(e)},u.qc=function(e){return N1(this.c,e)},u.Fi=function(){var e,n,i;if(this.d==null){for(this.d=dt(Fvt,$pt,55,2*this.f+1,0,1),i=this.e,this.f=0,n=this.c.tc();n.e!=n.i._b();)e=a(n.Ci(),134),h7(this,e);this.e=i}},u.Fb=function(e){return ITt(this,e)},u.Hb=function(){return Mat(this.c)},u.dd=function(e){return this.c.dd(e)},u.Gi=function(){this.c=new gG(this)},u.Wb=function(){return this.f==0},u.tc=function(){return this.c.tc()},u.ed=function(){return this.c.ed()},u.fd=function(e){return this.c.fd(e)},u.Hi=function(){return SL(this)},u.Ii=function(e,n,i){return new GTt(e,n,i)},u.Ji=function(){return new yz},u.vc=function(e){return WLt(this,e)},u._b=function(){return this.f},u.kd=function(e,n){return new T1(this.c,e,n)},u.yc=function(){return this.c.yc()},u.zc=function(e){return this.c.zc(e)},u.Ib=function(){return iut(this.c)},u.e=0,u.f=0;var hVe=A(qs,"BasicEMap",639);T(922,55,Nf,gG),u.sh=function(e,n){ee(this,a(n,134))},u.vh=function(e,n){fe(this,a(n,134))},u.wh=function(e,n,i){Ree(this,a(n,134),a(i,134))},u.uh=function(e,n){zPt(this.a)};var fVe=A(qs,"BasicEMap/1",922);T(923,55,Nf,yz),u.Fh=function(e){return dt(V3e,dUt,551,e,0,1)};var dVe=A(qs,"BasicEMap/2",923);T(924,bd,vl,mG),u.Pb=function(){this.a.c.Pb()},u.pc=function(e){return Cq(this.a,e)},u.tc=function(){return this.a.f==0?(VT(),bI.a):new g3t(this.a)},u.vc=function(e){var n;return n=this.a.f,sP(this.a,e),this.a.f!=n},u._b=function(){return this.a.f};var pVe=A(qs,"BasicEMap/3",924);T(925,25,L_,bG),u.Pb=function(){this.a.c.Pb()},u.pc=function(e){return eNt(this.a,e)},u.tc=function(){return this.a.f==0?(VT(),bI.a):new m3t(this.a)},u._b=function(){return this.a.f};var gVe=A(qs,"BasicEMap/4",925);T(926,bd,vl,wG),u.Pb=function(){this.a.c.Pb()},u.pc=function(e){var n,i,r,c,l,f,g,b,v;if(this.a.f>0&&ct(e,38)&&(this.a.Fi(),b=a(e,38),g=b.kc(),c=g==null?0:Yr(g),l=pst(this.a,c),n=this.a.d[l],n)){for(i=a(n.g,339),v=n.i,f=0;f"+this.c},u.a=0;var V3e=A(qs,"BasicEMap/EntryImpl",551);T(484,1,{},Vy);var yVe=A(qs,"BasicEMap/View",484),bI;T(695,1,{}),u.Fb=function(e){return Olt((we(),fo),e)},u.Hb=function(){return Lat((we(),fo))},u.Ib=function(){return Gp((we(),fo))};var xVe=A(qs,"ECollections/BasicEmptyUnmodifiableEList",695);T(1164,1,kf,xz),u.gc=function(e){ks(this,e)},u.Bc=function(e){throw K(new Oi)},u.hc=function(){return!1},u.Cc=function(){return!1},u.ic=function(){throw K(new J)},u.Dc=function(){return 0},u.Ec=function(){throw K(new J)},u.Fc=function(){return-1},u.jc=function(){throw K(new Oi)},u.Gc=function(e){throw K(new Oi)};var MVe=A(qs,"ECollections/BasicEmptyUnmodifiableEList/1",1164);T(1162,695,{20:1,13:1,15:1,52:1},_xt),u.bd=function(e,n){Hxt()},u.nc=function(e){return Gxt()},u.oc=function(e){return Wxt()},u.Pb=function(){$xt()},u.pc=function(e){return!1},u.qc=function(e){return!1},u.sc=function(e){vo(this,e)},u.cd=function(e){return Crt((we(),e)),null},u.dd=function(e){return-1},u.Wb=function(){return!0},u.tc=function(){return this.a},u.ed=function(){return this.a},u.fd=function(e){return this.a},u.uc=function(){return this.xc()},u.gd=function(e){return Vxt()},u.vc=function(e){return qxt()},u.hd=function(e,n){return Xxt()},u._b=function(){return 0},u.jd=function(e){R1(this,e)},u.wc=function(){return new Ei(this,16)},u.xc=function(){return new gi(null,this.wc())},u.kd=function(e,n){return we(),new T1(fo,e,n)},u.yc=function(){return g$((we(),fo))},u.zc=function(e){return we(),aP(fo,e)};var EVe=A(qs,"ECollections/EmptyUnmodifiableEList",1162);T(1163,695,{20:1,13:1,15:1,52:1,533:1},vxt),u.bd=function(e,n){Hxt()},u.nc=function(e){return Gxt()},u.oc=function(e){return Wxt()},u.Pb=function(){$xt()},u.pc=function(e){return!1},u.qc=function(e){return!1},u.sc=function(e){vo(this,e)},u.cd=function(e){return Crt((we(),e)),null},u.dd=function(e){return-1},u.Wb=function(){return!0},u.tc=function(){return this.a},u.ed=function(){return this.a},u.fd=function(e){return this.a},u.uc=function(){return this.xc()},u.gd=function(e){return Vxt()},u.vc=function(e){return qxt()},u.hd=function(e,n){return Xxt()},u._b=function(){return 0},u.jd=function(e){R1(this,e)},u.wc=function(){return new Ei(this,16)},u.xc=function(){return new gi(null,this.wc())},u.kd=function(e,n){return we(),new T1(fo,e,n)},u.yc=function(){return g$((we(),fo))},u.zc=function(e){return we(),aP(fo,e)},u.Hi=function(){return we(),we(),ap};var SVe=A(qs,"ECollections/EmptyUnmodifiableEMap",1163),zvt=Sr(qs,"Enumerator"),GF;T(261,1,{261:1},LX),u.Fb=function(e){var n;return this===e?!0:ct(e,261)?(n=a(e,261),this.f==n.f&&vre(this.i,n.i)&&f$(this.a,this.f&256?n.f&256?n.a:null:n.f&256?null:n.a)&&f$(this.d,n.d)&&f$(this.g,n.g)&&f$(this.e,n.e)&&cde(this,n)):!1},u.Hb=function(){return this.f},u.Ib=function(){return INt(this)},u.f=0;var Pqt=0,Iqt=0,Rqt=0,Dqt=0,jvt=0,Hvt=0,Gvt=0,Wvt=0,$vt=0,Nqt,EA=0,SA=0,Oqt=0,Bqt=0,WF,Vvt,TVe=A(qs,"URI",261);T(965,44,tx,dxt),u.Zb=function(e,n){return a(tc(this,hi(e),a(n,261)),261)};var CVe=A(qs,"URI/URICache",965);T(451,55,Nf,R3,RD),u.xh=function(){return!0};var AVe=A(qs,"UniqueEList",451);T(526,54,rp,yN);var kVe=A(qs,"WrappedException",526),Ui=Sr(Qu,mUt),Dw=Sr(Qu,bUt),Ra=Sr(Qu,wUt),hy=Sr(Qu,vUt),cf=Sr(Qu,_Ut),Dl=Sr(Qu,"EClass"),itt=Sr(Qu,"EDataType"),Fqt;T(1096,44,tx,pxt),u.Vb=function(e){return Es(e)?Zc(this,e):Ua(Ea(this.d,e))};var LVe=A(Qu,"EDataType/Internal/ConversionDelegate/Factory/Registry/Impl",1096),$F=Sr(Qu,"EEnum"),Qp=Sr(Qu,yUt),Do=Sr(Qu,xUt),ph=Sr(Qu,MUt),Nl,Nw=Sr(Qu,EUt),Ow=Sr(Qu,SUt);T(918,1,{},AR),u.Ib=function(){return"NIL"};var PVe=A(Qu,"EStructuralFeature/Internal/DynamicValueHolder/1",918),Uqt;T(917,44,tx,gxt),u.Vb=function(e){return Es(e)?Zc(this,e):Ua(Ea(this.d,e))};var IVe=A(Qu,"EStructuralFeature/Internal/SettingDelegate/Factory/Registry/Impl",917),wu=Sr(Qu,TUt),Dx=Sr(Qu,"EValidator/PatternMatcher"),qvt,Xvt,Ae,E0,Nx,ub,zqt,jqt,lb,S0,hb,fy,Hf,Hqt,Gqt,gh,T0,C0,Bw,HE,Ho,Wqt,$qt,dy,VF=Sr(hr,"FeatureMap/Entry");T(483,1,{75:1},X9),u.nj=function(){return this.a},u.lc=function(){return this.b};var RVe=A(Re,"BasicEObjectImpl/1",483);T(1674,1,{103:1}),u.oj=function(e){this.e=e==0?Vqt:dt(un,te,1,e,5,1)},u.Tg=function(e){return this.e[e]},u.Ug=function(e,n){this.e[e]=n},u.Vg=function(e){this.e[e]=null},u.pj=function(){return this.c},u.qj=function(){throw K(new Oi)},u.rj=function(){throw K(new Oi)},u.sj=function(){return this.d},u.tj=function(){return this.e!=null},u.uj=function(e){this.c=e},u.vj=function(e){throw K(new Oi)},u.wj=function(e){this.d=e};var Vqt,DVe=A(Re,"BasicEObjectImpl/EPropertiesHolderBaseImpl",1674);T(201,1674,{103:1},wf),u.qj=function(){return this.a},u.rj=function(){return this.b},u.vj=function(e){this.a=e};var NVe=A(Re,"BasicEObjectImpl/EPropertiesHolderImpl",201);T(463,92,PFt,zl),u.dg=function(){return this.f},u.ig=function(){return this.k},u.kg=function(e,n){this.g=e,this.i=n},u.mg=function(){return this.j&2?this.Jg().pj():this.Rg()},u.og=function(){return this.i},u.fg=function(){return(this.j&1)!=0},u.yg=function(){return this.g},u.Eg=function(){return(this.j&4)!=0},u.Jg=function(){return!this.k&&(this.k=new wf),this.k},u.Ng=function(e){this.Jg().uj(e),e?this.j|=2:this.j&=-3},u.Rg=function(){return(S1(),Ae).S},u.i=0,u.j=1;var OVe=A(Re,"EObjectImpl",463);T(710,463,{95:1,91:1,87:1,51:1,103:1,42:1,92:1},qst),u.Tg=function(e){return this.e[e]},u.Ug=function(e,n){this.e[e]=n},u.Vg=function(e){this.e[e]=null},u.mg=function(){return this.d},u.rg=function(e){return xr(this.d,e)},u.tg=function(){return this.d},u.xg=function(){return this.e!=null},u.Jg=function(){return!this.k&&(this.k=new Mz),this.k},u.Ng=function(e){this.d=e},u.Qg=function(){var e;return this.e==null&&(e=ei(this.d),this.e=e==0?qqt:dt(un,te,1,e,5,1)),this},u.Sg=function(){return 0};var qqt,BVe=A(Re,"DynamicEObjectImpl",710);T(1389,710,{95:1,38:1,91:1,87:1,134:1,51:1,103:1,42:1,92:1},dCt),u.Fb=function(e){return this===e},u.Hb=function(){return cm(this)},u.Ng=function(e){this.d=e,this.b=EP(e,"key"),this.c=EP(e,x4)},u.ih=function(){var e;return this.a==-1&&(e=EV(this,this.b),this.a=e==null?0:Yr(e)),this.a},u.kc=function(){return EV(this,this.b)},u.lc=function(){return EV(this,this.c)},u.jh=function(e){this.a=e},u.kh=function(e){CAt(this,this.b,e)},u.mc=function(e){var n;return n=EV(this,this.c),CAt(this,this.c,e),n},u.a=0;var FVe=A(Re,"DynamicEObjectImpl/BasicEMapEntry",1389);T(1390,1,{103:1},Mz),u.oj=function(e){throw K(new Oi)},u.Tg=function(e){throw K(new Oi)},u.Ug=function(e,n){throw K(new Oi)},u.Vg=function(e){throw K(new Oi)},u.pj=function(){throw K(new Oi)},u.qj=function(){return this.a},u.rj=function(){return this.b},u.sj=function(){return this.c},u.tj=function(){throw K(new Oi)},u.uj=function(e){throw K(new Oi)},u.vj=function(e){this.a=e},u.wj=function(e){this.c=e};var UVe=A(Re,"DynamicEObjectImpl/DynamicEPropertiesHolderImpl",1390);T(469,142,{95:1,91:1,87:1,609:1,139:1,51:1,103:1,42:1,92:1,469:1,142:1,107:1,108:1},kR),u.jg=function(e){return jut(this,e)},u.ug=function(e,n,i){var r;switch(e){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),this.Ab;case 1:return this.d;case 2:return i?(!this.b&&(this.b=new xu((ye(),Ho),Dc,this)),this.b):(!this.b&&(this.b=new xu((ye(),Ho),Dc,this)),SL(this.b));case 3:return dAt(this);case 4:return!this.a&&(this.a=new Ss(Iw,this,4)),this.a;case 5:return!this.c&&(this.c=new uM(Iw,this,5)),this.c}return qu(this,e-ei((ye(),E0)),Ve((r=a(an(this,16),24),r||E0),e),n,i)},u.Bg=function(e,n,i){var r,c,l;switch(n){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Kc(this.Ab,e,i);case 3:return this.Cb&&(i=(c=this.Db>>16,c>=0?jut(this,i):this.Cb.Cg(this,-1-c,null,i))),uot(this,a(e,139),i)}return l=a(Ve((r=a(an(this,16),24),r||(ye(),E0)),n),61),l.aj().dj(this,ra(this),n-ei((ye(),E0)),e,i)},u.Dg=function(e,n,i){var r,c;switch(n){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),$s(this.Ab,e,i);case 2:return!this.b&&(this.b=new xu((ye(),Ho),Dc,this)),_D(this.b,e,i);case 3:return uot(this,null,i);case 4:return!this.a&&(this.a=new Ss(Iw,this,4)),$s(this.a,e,i)}return c=a(Ve((r=a(an(this,16),24),r||(ye(),E0)),n),61),c.aj().ej(this,ra(this),n-ei((ye(),E0)),e,i)},u.Fg=function(e){var n;switch(e){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.d!=null;case 2:return!!this.b&&this.b.f!=0;case 3:return!!dAt(this);case 4:return!!this.a&&this.a.i!=0;case 5:return!!this.c&&this.c.i!=0}return $u(this,e-ei((ye(),E0)),Ve((n=a(an(this,16),24),n||E0),e))},u.Mg=function(e,n){var i;switch(e){case 0:!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Dr(this.Ab),!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Lr(this.Ab,a(n,13));return;case 1:_re(this,hi(n));return;case 2:!this.b&&(this.b=new xu((ye(),Ho),Dc,this)),NN(this.b,n);return;case 3:Bbe(this,a(n,139));return;case 4:!this.a&&(this.a=new Ss(Iw,this,4)),Dr(this.a),!this.a&&(this.a=new Ss(Iw,this,4)),Lr(this.a,a(n,13));return;case 5:!this.c&&(this.c=new uM(Iw,this,5)),Dr(this.c),!this.c&&(this.c=new uM(Iw,this,5)),Lr(this.c,a(n,13));return}Yu(this,e-ei((ye(),E0)),Ve((i=a(an(this,16),24),i||E0),e),n)},u.Rg=function(){return ye(),E0},u.Ib=function(){return H6t(this)},u.d=null;var zVe=A(Re,"EAnnotationImpl",469);T(143,639,Vpt,lu),u.xj=function(e,n){return _ne(this,a(e,38),n)},u.Dh=function(e){return a(a(this.c,64).Dh(e),134)},u.oh=function(){return a(this.c,64).oh()},u.ph=function(){return a(this.c,64).ph()},u.qh=function(e){return a(this.c,64).qh(e)},u.yj=function(e,n){return _D(this,e,n)},u.hj=function(e){return a(this.c,81).hj(e)},u.Gi=function(){},u.ui=function(){return a(this.c,81).ui()},u.Ii=function(e,n,i){var r;return r=a(Xu(this.b).dh().$g(this.b),134),r.jh(e),r.kh(n),r.mc(i),r},u.Ji=function(){return new hT(this)},u.Gc=function(e){NN(this,e)},u.ij=function(){a(this.c,81).ij()};var jVe=A(hr,"EcoreEMap",143);T(152,143,Vpt,xu),u.Fi=function(){var e,n,i,r,c,l;if(this.d==null){for(l=dt(Fvt,$pt,55,2*this.f+1,0,1),i=this.c.tc();i.e!=i.i._b();)n=a(i.Ci(),134),r=n.ih(),c=(r&qi)%l.length,e=l[c],!e&&(e=l[c]=new hT(this)),e.nc(n);this.d=l}};var HVe=A(Re,"EAnnotationImpl/1",152);T(268,399,{95:1,91:1,87:1,139:1,174:1,51:1,103:1,431:1,42:1,92:1,142:1,268:1,107:1,108:1}),u.ug=function(e,n,i){var r,c;switch(e){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),this.Ab;case 1:return this.zb;case 2:return me(),!!(this.Bb&256);case 3:return me(),!!(this.Bb&512);case 4:return Xt(this.s);case 5:return Xt(this.t);case 6:return me(),!!this.lj();case 7:return me(),c=this.s,c>=1;case 8:return n?wl(this):this.r;case 9:return this.q}return qu(this,e-ei(this.Rg()),Ve((r=a(an(this,16),24),r||this.Rg()),e),n,i)},u.Dg=function(e,n,i){var r,c;switch(n){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),$s(this.Ab,e,i);case 9:return C$(this,i)}return c=a(Ve((r=a(an(this,16),24),r||this.Rg()),n),61),c.aj().ej(this,ra(this),n-ei(this.Rg()),e,i)},u.Fg=function(e){var n,i;switch(e){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return(this.Bb&256)==0;case 3:return(this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return this.lj();case 7:return i=this.s,i>=1;case 8:return!!this.r&&!this.q.e&&dm(this.q).i==0;case 9:return!!this.q&&!(this.r&&!this.q.e&&dm(this.q).i==0)}return $u(this,e-ei(this.Rg()),Ve((n=a(an(this,16),24),n||this.Rg()),e))},u.Mg=function(e,n){var i,r;switch(e){case 0:!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Dr(this.Ab),!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Lr(this.Ab,a(n,13));return;case 1:this.ah(hi(n));return;case 2:a_(this,lt(de(n)));return;case 3:u_(this,lt(de(n)));return;case 4:r_(this,a(n,21).a);return;case 5:this.Aj(a(n,21).a);return;case 8:UM(this,a(n,133));return;case 9:r=W1(this,a(n,84),null),r&&r.Th();return}Yu(this,e-ei(this.Rg()),Ve((i=a(an(this,16),24),i||this.Rg()),e),n)},u.Rg=function(){return ye(),$qt},u.Xg=function(){wl(this),this.Bb|=1},u.jj=function(){return wl(this)},u.kj=function(){return this.t},u.lj=function(){var e;return e=this.t,e>1||e==-1},u.xh=function(){return(this.Bb&512)!=0},u.zj=function(e,n){return Wat(this,e,n)},u.Aj=function(e){IM(this,e)},u.Ib=function(){return Ilt(this)},u.s=0,u.t=1;var GVe=A(Re,"ETypedElementImpl",268);T(418,268,{95:1,91:1,87:1,139:1,174:1,51:1,158:1,61:1,103:1,431:1,42:1,92:1,142:1,418:1,268:1,107:1,108:1,615:1}),u.jg=function(e){return BRt(this,e)},u.ug=function(e,n,i){var r,c;switch(e){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),this.Ab;case 1:return this.zb;case 2:return me(),!!(this.Bb&256);case 3:return me(),!!(this.Bb&512);case 4:return Xt(this.s);case 5:return Xt(this.t);case 6:return me(),!!this.lj();case 7:return me(),c=this.s,c>=1;case 8:return n?wl(this):this.r;case 9:return this.q;case 10:return me(),!!(this.Bb&oh);case 11:return me(),!!(this.Bb&dw);case 12:return me(),!!(this.Bb&Bm);case 13:return this.j;case 14:return QM(this);case 15:return me(),!!(this.Bb&La);case 16:return me(),!!(this.Bb&Lf);case 17:return Vb(this)}return qu(this,e-ei(this.Rg()),Ve((r=a(an(this,16),24),r||this.Rg()),e),n,i)},u.Bg=function(e,n,i){var r,c,l;switch(n){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Kc(this.Ab,e,i);case 17:return this.Cb&&(i=(c=this.Db>>16,c>=0?BRt(this,i):this.Cb.Cg(this,-1-c,null,i))),ku(this,e,17,i)}return l=a(Ve((r=a(an(this,16),24),r||this.Rg()),n),61),l.aj().dj(this,ra(this),n-ei(this.Rg()),e,i)},u.Dg=function(e,n,i){var r,c;switch(n){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),$s(this.Ab,e,i);case 9:return C$(this,i);case 17:return ku(this,null,17,i)}return c=a(Ve((r=a(an(this,16),24),r||this.Rg()),n),61),c.aj().ej(this,ra(this),n-ei(this.Rg()),e,i)},u.Fg=function(e){var n,i;switch(e){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return(this.Bb&256)==0;case 3:return(this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return this.lj();case 7:return i=this.s,i>=1;case 8:return!!this.r&&!this.q.e&&dm(this.q).i==0;case 9:return!!this.q&&!(this.r&&!this.q.e&&dm(this.q).i==0);case 10:return(this.Bb&oh)==0;case 11:return(this.Bb&dw)!=0;case 12:return(this.Bb&Bm)!=0;case 13:return this.j!=null;case 14:return QM(this)!=null;case 15:return(this.Bb&La)!=0;case 16:return(this.Bb&Lf)!=0;case 17:return!!Vb(this)}return $u(this,e-ei(this.Rg()),Ve((n=a(an(this,16),24),n||this.Rg()),e))},u.Mg=function(e,n){var i,r;switch(e){case 0:!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Dr(this.Ab),!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Lr(this.Ab,a(n,13));return;case 1:Z$(this,hi(n));return;case 2:a_(this,lt(de(n)));return;case 3:u_(this,lt(de(n)));return;case 4:r_(this,a(n,21).a);return;case 5:this.Aj(a(n,21).a);return;case 8:UM(this,a(n,133));return;case 9:r=W1(this,a(n,84),null),r&&r.Th();return;case 10:$N(this,lt(de(n)));return;case 11:WN(this,lt(de(n)));return;case 12:qN(this,lt(de(n)));return;case 13:Srt(this,hi(n));return;case 15:VN(this,lt(de(n)));return;case 16:XN(this,lt(de(n)));return}Yu(this,e-ei(this.Rg()),Ve((i=a(an(this,16),24),i||this.Rg()),e),n)},u.Rg=function(){return ye(),Wqt},u.Xg=function(){vM(qo((Qa(),eo),this)),wl(this),this.Bb|=1},u.Vi=function(){return this.f},u.Oi=function(){return QM(this)},u.Wi=function(){return Vb(this)},u.$i=function(){return null},u.Bj=function(){return this.k},u.pi=function(){return this.n},u._i=function(){return b7(this)},u.aj=function(){var e,n,i,r,c,l,f,g,b;return this.p||(i=Vb(this),(i.i==null&&V1(i),i.i).length,r=this.$i(),r&&ei(Vb(r)),c=wl(this),f=c.Qi(),e=f?f.i&1?f==Ol?ho:f==Gn?Io:f==zw?ME:f==Os?To:f==A0?Gm:f==my?Wm:f==Da?ux:D4:f:null,n=QM(this),g=c.Oi(),Xhe(this),this.Bb&Lf&&((l=Xut((Qa(),eo),i))&&l!=this||(l=sC(qo(eo,this))))?this.p=new hEt(this,l):this.lj()?this.Dj()?r?this.Bb&La?e?this.Ej()?this.p=new zg(47,e,this,r):this.p=new zg(5,e,this,r):this.Ej()?this.p=new Gg(46,this,r):this.p=new Gg(4,this,r):e?this.Ej()?this.p=new zg(49,e,this,r):this.p=new zg(7,e,this,r):this.Ej()?this.p=new Gg(48,this,r):this.p=new Gg(6,this,r):this.Bb&La?e?e==G_?this.p=new Ip(50,Aqt,this):this.Ej()?this.p=new Ip(43,e,this):this.p=new Ip(1,e,this):this.Ej()?this.p=new Op(42,this):this.p=new Op(0,this):e?e==G_?this.p=new Ip(41,Aqt,this):this.Ej()?this.p=new Ip(45,e,this):this.p=new Ip(3,e,this):this.Ej()?this.p=new Op(44,this):this.p=new Op(2,this):ct(c,140)?e==VF?this.p=new Op(40,this):this.Bb&512?this.Bb&La?e?this.p=new Ip(9,e,this):this.p=new Op(8,this):e?this.p=new Ip(11,e,this):this.p=new Op(10,this):this.Bb&La?e?this.p=new Ip(13,e,this):this.p=new Op(12,this):e?this.p=new Ip(15,e,this):this.p=new Op(14,this):r?(b=r.t,b>1||b==-1?this.Ej()?this.Bb&La?e?this.p=new zg(25,e,this,r):this.p=new Gg(24,this,r):e?this.p=new zg(27,e,this,r):this.p=new Gg(26,this,r):this.Bb&La?e?this.p=new zg(29,e,this,r):this.p=new Gg(28,this,r):e?this.p=new zg(31,e,this,r):this.p=new Gg(30,this,r):this.Ej()?this.Bb&La?e?this.p=new zg(33,e,this,r):this.p=new Gg(32,this,r):e?this.p=new zg(35,e,this,r):this.p=new Gg(34,this,r):this.Bb&La?e?this.p=new zg(37,e,this,r):this.p=new Gg(36,this,r):e?this.p=new zg(39,e,this,r):this.p=new Gg(38,this,r)):this.Ej()?this.Bb&La?e?this.p=new Ip(17,e,this):this.p=new Op(16,this):e?this.p=new Ip(19,e,this):this.p=new Op(18,this):this.Bb&La?e?this.p=new Ip(21,e,this):this.p=new Op(20,this):e?this.p=new Ip(23,e,this):this.p=new Op(22,this):this.Cj()?this.Ej()?this.p=new WTt(a(c,24),this,r):this.p=new Kot(a(c,24),this,r):ct(c,140)?e==VF?this.p=new Op(40,this):this.Bb&La?e?this.p=new PCt(n,g,this,(Tq(),f==Gn?e_t:f==Ol?Yvt:f==A0?n_t:f==zw?t_t:f==Os?Qvt:f==my?i_t:f==Da?Kvt:f==el?Jvt:ott)):this.p=new C4t(a(c,140),n,g,this):e?this.p=new LCt(n,g,this,(Tq(),f==Gn?e_t:f==Ol?Yvt:f==A0?n_t:f==zw?t_t:f==Os?Qvt:f==my?i_t:f==Da?Kvt:f==el?Jvt:ott)):this.p=new T4t(a(c,140),n,g,this):this.Dj()?r?this.Bb&La?this.Ej()?this.p=new VTt(a(c,24),this,r):this.p=new Ust(a(c,24),this,r):this.Ej()?this.p=new $Tt(a(c,24),this,r):this.p=new c$(a(c,24),this,r):this.Bb&La?this.Ej()?this.p=new jSt(a(c,24),this):this.p=new rst(a(c,24),this):this.Ej()?this.p=new zSt(a(c,24),this):this.p=new $W(a(c,24),this):this.Ej()?r?this.Bb&La?this.p=new qTt(a(c,24),this,r):this.p=new Fst(a(c,24),this,r):this.Bb&La?this.p=new HSt(a(c,24),this):this.p=new ist(a(c,24),this):r?this.Bb&La?this.p=new XTt(a(c,24),this,r):this.p=new zst(a(c,24),this,r):this.Bb&La?this.p=new GSt(a(c,24),this):this.p=new DD(a(c,24),this)),this.p},u.Xi=function(){return(this.Bb&oh)!=0},u.Cj=function(){return!1},u.Dj=function(){return!1},u.Yi=function(){return(this.Bb&Lf)!=0},u.bj=function(){return $ct(this)},u.Ej=function(){return!1},u.Zi=function(){return(this.Bb&La)!=0},u.Fj=function(e){this.k=e},u.ah=function(e){Z$(this,e)},u.Ib=function(){return U7(this)},u.e=!1,u.n=0;var WVe=A(Re,"EStructuralFeatureImpl",418);T(335,418,{95:1,91:1,87:1,29:1,139:1,174:1,51:1,158:1,61:1,103:1,431:1,42:1,92:1,335:1,142:1,418:1,268:1,107:1,108:1,615:1},RG),u.ug=function(e,n,i){var r,c;switch(e){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),this.Ab;case 1:return this.zb;case 2:return me(),!!(this.Bb&256);case 3:return me(),!!(this.Bb&512);case 4:return Xt(this.s);case 5:return Xt(this.t);case 6:return me(),!!Llt(this);case 7:return me(),c=this.s,c>=1;case 8:return n?wl(this):this.r;case 9:return this.q;case 10:return me(),!!(this.Bb&oh);case 11:return me(),!!(this.Bb&dw);case 12:return me(),!!(this.Bb&Bm);case 13:return this.j;case 14:return QM(this);case 15:return me(),!!(this.Bb&La);case 16:return me(),!!(this.Bb&Lf);case 17:return Vb(this);case 18:return me(),!!(this.Bb&ca);case 19:return n?ZV(this):M5t(this)}return qu(this,e-ei((ye(),Nx)),Ve((r=a(an(this,16),24),r||Nx),e),n,i)},u.Fg=function(e){var n,i;switch(e){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return(this.Bb&256)==0;case 3:return(this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return Llt(this);case 7:return i=this.s,i>=1;case 8:return!!this.r&&!this.q.e&&dm(this.q).i==0;case 9:return!!this.q&&!(this.r&&!this.q.e&&dm(this.q).i==0);case 10:return(this.Bb&oh)==0;case 11:return(this.Bb&dw)!=0;case 12:return(this.Bb&Bm)!=0;case 13:return this.j!=null;case 14:return QM(this)!=null;case 15:return(this.Bb&La)!=0;case 16:return(this.Bb&Lf)!=0;case 17:return!!Vb(this);case 18:return(this.Bb&ca)!=0;case 19:return!!M5t(this)}return $u(this,e-ei((ye(),Nx)),Ve((n=a(an(this,16),24),n||Nx),e))},u.Mg=function(e,n){var i,r;switch(e){case 0:!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Dr(this.Ab),!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Lr(this.Ab,a(n,13));return;case 1:Z$(this,hi(n));return;case 2:a_(this,lt(de(n)));return;case 3:u_(this,lt(de(n)));return;case 4:r_(this,a(n,21).a);return;case 5:h3t(this,a(n,21).a);return;case 8:UM(this,a(n,133));return;case 9:r=W1(this,a(n,84),null),r&&r.Th();return;case 10:$N(this,lt(de(n)));return;case 11:WN(this,lt(de(n)));return;case 12:qN(this,lt(de(n)));return;case 13:Srt(this,hi(n));return;case 15:VN(this,lt(de(n)));return;case 16:XN(this,lt(de(n)));return;case 18:Jat(this,lt(de(n)));return}Yu(this,e-ei((ye(),Nx)),Ve((i=a(an(this,16),24),i||Nx),e),n)},u.Rg=function(){return ye(),Nx},u.Xg=function(){ZV(this),vM(qo((Qa(),eo),this)),wl(this),this.Bb|=1},u.lj=function(){return Llt(this)},u.zj=function(e,n){return this.b=0,this.a=null,Wat(this,e,n)},u.Aj=function(e){h3t(this,e)},u.Ib=function(){var e;return this.Db&64?U7(this):(e=new ul(U7(this)),e.a+=" (iD: ",Cp(e,(this.Bb&ca)!=0),e.a+=")",e.a)},u.b=0;var $Ve=A(Re,"EAttributeImpl",335);T(672,399,{95:1,91:1,87:1,133:1,139:1,174:1,51:1,103:1,42:1,92:1,142:1,107:1,108:1,614:1}),u.Gj=function(e){return e.mg()==this},u.jg=function(e){return Yq(this,e)},u.kg=function(e,n){this.w=null,this.Db=n<<16|this.Db&255,this.Cb=e},u.ug=function(e,n,i){var r;switch(e){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),this.Ab;case 1:return this.zb;case 2:return this.D!=null?this.D:this.B;case 3:return km(this);case 4:return this.Oi();case 5:return this.F;case 6:return n?Xu(this):MM(this);case 7:return!this.A&&(this.A=new Hu(wu,this,7)),this.A}return qu(this,e-ei(this.Rg()),Ve((r=a(an(this,16),24),r||this.Rg()),e),n,i)},u.Bg=function(e,n,i){var r,c,l;switch(n){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Kc(this.Ab,e,i);case 6:return this.Cb&&(i=(c=this.Db>>16,c>=0?Yq(this,i):this.Cb.Cg(this,-1-c,null,i))),ku(this,e,6,i)}return l=a(Ve((r=a(an(this,16),24),r||this.Rg()),n),61),l.aj().dj(this,ra(this),n-ei(this.Rg()),e,i)},u.Dg=function(e,n,i){var r,c;switch(n){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),$s(this.Ab,e,i);case 6:return ku(this,null,6,i);case 7:return!this.A&&(this.A=new Hu(wu,this,7)),$s(this.A,e,i)}return c=a(Ve((r=a(an(this,16),24),r||this.Rg()),n),61),c.aj().ej(this,ra(this),n-ei(this.Rg()),e,i)},u.Fg=function(e){var n;switch(e){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.D!=null&&this.D==this.F;case 3:return!!km(this);case 4:return this.Oi()!=null;case 5:return this.F!=null&&this.F!=this.D&&this.F!=this.B;case 6:return!!MM(this);case 7:return!!this.A&&this.A.i!=0}return $u(this,e-ei(this.Rg()),Ve((n=a(an(this,16),24),n||this.Rg()),e))},u.Mg=function(e,n){var i;switch(e){case 0:!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Dr(this.Ab),!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Lr(this.Ab,a(n,13));return;case 1:eN(this,hi(n));return;case 2:AW(this,hi(n));return;case 5:tZ(this,hi(n));return;case 7:!this.A&&(this.A=new Hu(wu,this,7)),Dr(this.A),!this.A&&(this.A=new Hu(wu,this,7)),Lr(this.A,a(n,13));return}Yu(this,e-ei(this.Rg()),Ve((i=a(an(this,16),24),i||this.Rg()),e),n)},u.Rg=function(){return ye(),zqt},u.Ni=function(){var e;return this.G==-1&&(this.G=(e=Xu(this),e?Hp(e.bh(),this):-1)),this.G},u.Oi=function(){return null},u.Pi=function(){return Xu(this)},u.Hj=function(){return this.v},u.Qi=function(){return km(this)},u.Ri=function(){return this.D!=null?this.D:this.B},u.Si=function(){return this.F},u.Li=function(e){return BX(this,e)},u.Ij=function(e){this.v=e},u.Jj=function(e){wPt(this,e)},u.Kj=function(e){this.C=e},u.ah=function(e){eN(this,e)},u.Ib=function(){return e7(this)},u.C=null,u.D=null,u.G=-1;var VVe=A(Re,"EClassifierImpl",672);T(96,672,{95:1,91:1,87:1,24:1,133:1,139:1,174:1,51:1,103:1,42:1,92:1,96:1,142:1,432:1,107:1,108:1,614:1},c5),u.Gj=function(e){return pne(this,e.mg())},u.ug=function(e,n,i){var r;switch(e){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),this.Ab;case 1:return this.zb;case 2:return this.D!=null?this.D:this.B;case 3:return km(this);case 4:return null;case 5:return this.F;case 6:return n?Xu(this):MM(this);case 7:return!this.A&&(this.A=new Hu(wu,this,7)),this.A;case 8:return me(),!!(this.Bb&256);case 9:return me(),!!(this.Bb&512);case 10:return Bo(this);case 11:return!this.q&&(this.q=new Wt(ph,this,11,10)),this.q;case 12:return S_(this);case 13:return s4(this);case 14:return s4(this),this.r;case 15:return S_(this),this.k;case 16:return ylt(this);case 17:return GX(this);case 18:return V1(this);case 19:return I7(this);case 20:return S_(this),this.o;case 21:return!this.s&&(this.s=new Wt(Ra,this,21,17)),this.s;case 22:return kc(this);case 23:return kX(this)}return qu(this,e-ei((ye(),ub)),Ve((r=a(an(this,16),24),r||ub),e),n,i)},u.Bg=function(e,n,i){var r,c,l;switch(n){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Kc(this.Ab,e,i);case 6:return this.Cb&&(i=(c=this.Db>>16,c>=0?Yq(this,i):this.Cb.Cg(this,-1-c,null,i))),ku(this,e,6,i);case 11:return!this.q&&(this.q=new Wt(ph,this,11,10)),Kc(this.q,e,i);case 21:return!this.s&&(this.s=new Wt(Ra,this,21,17)),Kc(this.s,e,i)}return l=a(Ve((r=a(an(this,16),24),r||(ye(),ub)),n),61),l.aj().dj(this,ra(this),n-ei((ye(),ub)),e,i)},u.Dg=function(e,n,i){var r,c;switch(n){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),$s(this.Ab,e,i);case 6:return ku(this,null,6,i);case 7:return!this.A&&(this.A=new Hu(wu,this,7)),$s(this.A,e,i);case 11:return!this.q&&(this.q=new Wt(ph,this,11,10)),$s(this.q,e,i);case 21:return!this.s&&(this.s=new Wt(Ra,this,21,17)),$s(this.s,e,i);case 22:return $s(kc(this),e,i)}return c=a(Ve((r=a(an(this,16),24),r||(ye(),ub)),n),61),c.aj().ej(this,ra(this),n-ei((ye(),ub)),e,i)},u.Fg=function(e){var n;switch(e){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.D!=null&&this.D==this.F;case 3:return!!km(this);case 4:return!1;case 5:return this.F!=null&&this.F!=this.D&&this.F!=this.B;case 6:return!!MM(this);case 7:return!!this.A&&this.A.i!=0;case 8:return(this.Bb&256)!=0;case 9:return(this.Bb&512)!=0;case 10:return!!this.u&&kc(this.u.a).i!=0&&!(this.n&&Hq(this.n));case 11:return!!this.q&&this.q.i!=0;case 12:return S_(this).i!=0;case 13:return s4(this).i!=0;case 14:return s4(this),this.r.i!=0;case 15:return S_(this),this.k.i!=0;case 16:return ylt(this).i!=0;case 17:return GX(this).i!=0;case 18:return V1(this).i!=0;case 19:return I7(this).i!=0;case 20:return S_(this),!!this.o;case 21:return!!this.s&&this.s.i!=0;case 22:return!!this.n&&Hq(this.n);case 23:return kX(this).i!=0}return $u(this,e-ei((ye(),ub)),Ve((n=a(an(this,16),24),n||ub),e))},u.Ig=function(e){var n;return n=this.i==null||this.q&&this.q.i!=0?null:EP(this,e),n||Ght(this,e)},u.Mg=function(e,n){var i;switch(e){case 0:!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Dr(this.Ab),!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Lr(this.Ab,a(n,13));return;case 1:eN(this,hi(n));return;case 2:AW(this,hi(n));return;case 5:tZ(this,hi(n));return;case 7:!this.A&&(this.A=new Hu(wu,this,7)),Dr(this.A),!this.A&&(this.A=new Hu(wu,this,7)),Lr(this.A,a(n,13));return;case 8:Z6t(this,lt(de(n)));return;case 9:Y6t(this,lt(de(n)));return;case 10:$7(Bo(this)),Lr(Bo(this),a(n,13));return;case 11:!this.q&&(this.q=new Wt(ph,this,11,10)),Dr(this.q),!this.q&&(this.q=new Wt(ph,this,11,10)),Lr(this.q,a(n,13));return;case 21:!this.s&&(this.s=new Wt(Ra,this,21,17)),Dr(this.s),!this.s&&(this.s=new Wt(Ra,this,21,17)),Lr(this.s,a(n,13));return;case 22:Dr(kc(this)),Lr(kc(this),a(n,13));return}Yu(this,e-ei((ye(),ub)),Ve((i=a(an(this,16),24),i||ub),e),n)},u.Rg=function(){return ye(),ub},u.Xg=function(){var e,n;if(S_(this),s4(this),ylt(this),GX(this),V1(this),I7(this),kX(this),hC(tre(pl(this))),this.s)for(e=0,n=this.s.i;e=0;--e)at(this,e);return oct(this)},u.zc=function(e){var n;if(this.Qj())for(n=this.i-1;n>=0;--n)at(this,n);return uut(this,e)},u.ij=function(){Dr(this)},u.Ch=function(e,n){return CLt(this,e,n)};var ZVe=A(hr,"EcoreEList",565);T(450,565,Zo,aL),u.rh=function(){return!1},u.pi=function(){return this.c},u.qi=function(){return!1},u.Rj=function(){return!0},u.xh=function(){return!0},u.zh=function(e,n){return n},u.Bh=function(){return!1},u.c=0;var YVe=A(hr,"EObjectEList",450);T(88,450,Zo,Ss),u.qi=function(){return!0},u.Pj=function(){return!1},u.Dj=function(){return!0};var KVe=A(hr,"EObjectContainmentEList",88);T(493,88,Zo,sD),u.th=function(){this.a=!0},u.ui=function(){return this.a},u.ij=function(){var e;Dr(this),Xl(this.e)?(e=this.a,this.a=!1,Bi(this.e,new Jl(this.e,2,this.c,e,!1))):this.a=!1},u.a=!1;var JVe=A(hr,"EObjectContainmentEList/Unsettable",493);T(1003,493,Zo,iSt),u.yi=function(e,n){return Efe(this,a(e,84),n)},u.zi=function(e,n){return Mfe(this,a(e,84),n)},u.Ai=function(e,n,i){return c1e(this,a(e,84),a(n,84),i)},u.mi=function(e,n,i,r,c){switch(e){case 3:return rC(this,3,n,i,r,this.i>1);case 5:return rC(this,5,n,i,r,this.i-a(i,15)._b()>0);default:return new Qd(this.e,e,this.c,n,i,r,!0)}},u.xi=function(){return!0},u.ui=function(){return Hq(this)},u.ij=function(){Dr(this)};var QVe=A(Re,"EClassImpl/1",1003);T(1017,1016,Wpt),u.Ih=function(e){var n,i,r,c,l,f,g;if(i=e.Lh(),i!=8){if(r=nde(e),r==0)switch(i){case 1:case 9:{g=e.Ph(),g!=null&&(n=pl(a(g,432)),!n.c&&(n.c=new Tb),MV(n.c,e.Oh())),f=e.Nh(),f!=null&&(c=a(f,432),c.Bb&1||(n=pl(c),!n.c&&(n.c=new Tb),ni(n.c,a(e.Oh(),24))));break}case 3:{f=e.Nh(),f!=null&&(c=a(f,432),c.Bb&1||(n=pl(c),!n.c&&(n.c=new Tb),ni(n.c,a(e.Oh(),24))));break}case 5:{if(f=e.Nh(),f!=null)for(l=a(f,13).tc();l.hc();)c=a(l.ic(),432),c.Bb&1||(n=pl(c),!n.c&&(n.c=new Tb),ni(n.c,a(e.Oh(),24)));break}case 4:{g=e.Ph(),g!=null&&(c=a(g,432),c.Bb&1||(n=pl(c),!n.c&&(n.c=new Tb),MV(n.c,e.Oh())));break}case 6:{if(g=e.Ph(),g!=null)for(l=a(g,13).tc();l.hc();)c=a(l.ic(),432),c.Bb&1||(n=pl(c),!n.c&&(n.c=new Tb),MV(n.c,e.Oh()));break}}this.Tj(r)}},u.Tj=function(e){hNt(this,e)},u.b=63;var tqe=A(Re,"ESuperAdapter",1017);T(1018,1017,Wpt,_G),u.Tj=function(e){YC(this,e)};var eqe=A(Re,"EClassImpl/10",1018);T(1007,630,Zo),u.lh=function(e){return TRt(this,e)},u.mh=function(e,n){JL(this,e,n)},u.nh=function(e){ML(this,e)},u.Dh=function(e){return Fct(this,e)},u.Ah=function(e,n){return xV(this,e,n)},u.xj=function(e,n){throw K(new Oi)},u.oh=function(){return new w2(this)},u.ph=function(){return new K5(this)},u.qh=function(e){return UL(this,e)},u.yj=function(e,n){throw K(new Oi)},u.hj=function(e){return this},u.ui=function(){return this.i!=0},u.Gc=function(e){throw K(new Oi)},u.ij=function(){throw K(new Oi)};var nqe=A(hr,"EcoreEList/UnmodifiableEList",1007);T(301,1007,Zo,Ov),u.Bh=function(){return!1};var iqe=A(hr,"EcoreEList/UnmodifiableEList/FastCompare",301);T(1010,301,Zo,g6t),u.dd=function(e){var n,i,r;if(ct(e,158)&&(n=a(e,158),i=n.pi(),i!=-1)){for(r=this.i;i4)if(this.Li(e)){if(this.Dj()){if(r=a(e,42),i=r.ng(),g=i==this.b&&(this.Pj()?r.hg(r.og(),a(Ve(da(this.b),this.pi()).jj(),24).Qi())==jo(a(Ve(da(this.b),this.pi()),17)).n:-1-r.og()==this.pi()),this.Qj()&&!g&&!i&&r.sg()){for(c=0;c1||r==-1)):!1},u.Pj=function(){var e,n,i;return n=Ve(da(this.b),this.pi()),ct(n,62)?(e=a(n,17),i=jo(e),!!i):!1},u.Qj=function(){var e,n;return n=Ve(da(this.b),this.pi()),ct(n,62)?(e=a(n,17),(e.Bb&ao)!=0):!1},u.dd=function(e){var n,i,r,c;if(r=this.ci(e),r>=0)return r;if(this.Rj()){for(i=0,c=this.hi();i=0;--e)RP(this,e,this.ai(e));return this.ii()},u.zc=function(e){var n;if(this.Qj())for(n=this.hi()-1;n>=0;--n)RP(this,n,this.ai(n));return this.ji(e)},u.ij=function(){$7(this)},u.Ch=function(e,n){return B5t(this,e,n)};var gqe=A(hr,"DelegatingEcoreEList",674);T(1013,674,Xpt,QSt),u.Vh=function(e,n){Wee(this,e,a(n,24))},u.Wh=function(e){Jte(this,a(e,24))},u.ai=function(e){var n,i;return n=a(at(kc(this.a),e),84),i=n.c,ct(i,96)?a(i,24):(ye(),gh)},u.fi=function(e){var n,i;return n=a(rw(kc(this.a),e),84),i=n.c,ct(i,96)?a(i,24):(ye(),gh)},u.gi=function(e,n){return Ode(this,e,a(n,24))},u.rh=function(){return!1},u.mi=function(e,n,i,r,c){return null},u.Xh=function(){return new x5(this)},u.Yh=function(){Dr(kc(this.a))},u.Zh=function(e){return J6t(this,e)},u.$h=function(e){var n,i;for(i=e.tc();i.hc();)if(n=i.ic(),!J6t(this,n))return!1;return!0},u._h=function(e){var n,i,r;if(ct(e,15)&&(r=a(e,15),r._b()==kc(this.a).i)){for(n=r.tc(),i=new $n(this);n.hc();)if(zt(n.ic())!==zt(ci(i)))return!1;return!0}return!1},u.bi=function(){var e,n,i,r,c;for(i=1,n=new $n(kc(this.a));n.e!=n.i._b();)e=a(ci(n),84),r=(c=e.c,ct(c,96)?a(c,24):(ye(),gh)),i=31*i+(r?cm(r):0);return i},u.ci=function(e){var n,i,r,c;for(r=0,i=new $n(kc(this.a));i.e!=i.i._b();){if(n=a(ci(i),84),zt(e)===zt((c=n.c,ct(c,96)?a(c,24):(ye(),gh))))return r;++r}return-1},u.di=function(){return kc(this.a).i==0},u.ei=function(){return null},u.hi=function(){return kc(this.a).i},u.ii=function(){var e,n,i,r,c,l;for(l=kc(this.a).i,c=dt(un,te,1,l,5,1),i=0,n=new $n(kc(this.a));n.e!=n.i._b();)e=a(ci(n),84),c[i++]=(r=e.c,ct(r,96)?a(r,24):(ye(),gh));return c},u.ji=function(e){var n,i,r,c,l,f,g;for(g=kc(this.a).i,e.lengthg&&Vr(e,g,null),r=0,i=new $n(kc(this.a));i.e!=i.i._b();)n=a(ci(i),84),l=(f=n.c,ct(f,96)?a(f,24):(ye(),gh)),Vr(e,r++,l);return e},u.ki=function(){var e,n,i,r,c;for(c=new Sp,c.a+="[",e=kc(this.a),n=0,r=kc(this.a).i;n>16,c>=0?Yq(this,i):this.Cb.Cg(this,-1-c,null,i))),ku(this,e,6,i);case 9:return!this.a&&(this.a=new Wt(Qp,this,9,5)),Kc(this.a,e,i)}return l=a(Ve((r=a(an(this,16),24),r||(ye(),lb)),n),61),l.aj().dj(this,ra(this),n-ei((ye(),lb)),e,i)},u.Dg=function(e,n,i){var r,c;switch(n){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),$s(this.Ab,e,i);case 6:return ku(this,null,6,i);case 7:return!this.A&&(this.A=new Hu(wu,this,7)),$s(this.A,e,i);case 9:return!this.a&&(this.a=new Wt(Qp,this,9,5)),$s(this.a,e,i)}return c=a(Ve((r=a(an(this,16),24),r||(ye(),lb)),n),61),c.aj().ej(this,ra(this),n-ei((ye(),lb)),e,i)},u.Fg=function(e){var n;switch(e){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.D!=null&&this.D==this.F;case 3:return!!km(this);case 4:return!!Uat(this);case 5:return this.F!=null&&this.F!=this.D&&this.F!=this.B;case 6:return!!MM(this);case 7:return!!this.A&&this.A.i!=0;case 8:return(this.Bb&256)==0;case 9:return!!this.a&&this.a.i!=0}return $u(this,e-ei((ye(),lb)),Ve((n=a(an(this,16),24),n||lb),e))},u.Mg=function(e,n){var i;switch(e){case 0:!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Dr(this.Ab),!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Lr(this.Ab,a(n,13));return;case 1:eN(this,hi(n));return;case 2:AW(this,hi(n));return;case 5:tZ(this,hi(n));return;case 7:!this.A&&(this.A=new Hu(wu,this,7)),Dr(this.A),!this.A&&(this.A=new Hu(wu,this,7)),Lr(this.A,a(n,13));return;case 8:qat(this,lt(de(n)));return;case 9:!this.a&&(this.a=new Wt(Qp,this,9,5)),Dr(this.a),!this.a&&(this.a=new Wt(Qp,this,9,5)),Lr(this.a,a(n,13));return}Yu(this,e-ei((ye(),lb)),Ve((i=a(an(this,16),24),i||lb),e),n)},u.Rg=function(){return ye(),lb},u.Xg=function(){var e,n;if(this.a)for(e=0,n=this.a.i;e>16==5?a(this.Cb,608):null}return qu(this,e-ei((ye(),S0)),Ve((r=a(an(this,16),24),r||S0),e),n,i)},u.Bg=function(e,n,i){var r,c,l;switch(n){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Kc(this.Ab,e,i);case 5:return this.Cb&&(i=(c=this.Db>>16,c>=0?zRt(this,i):this.Cb.Cg(this,-1-c,null,i))),ku(this,e,5,i)}return l=a(Ve((r=a(an(this,16),24),r||(ye(),S0)),n),61),l.aj().dj(this,ra(this),n-ei((ye(),S0)),e,i)},u.Dg=function(e,n,i){var r,c;switch(n){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),$s(this.Ab,e,i);case 5:return ku(this,null,5,i)}return c=a(Ve((r=a(an(this,16),24),r||(ye(),S0)),n),61),c.aj().ej(this,ra(this),n-ei((ye(),S0)),e,i)},u.Fg=function(e){var n;switch(e){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.d!=0;case 3:return!!this.b;case 4:return this.c!=null;case 5:return!!(this.Db>>16==5&&a(this.Cb,608))}return $u(this,e-ei((ye(),S0)),Ve((n=a(an(this,16),24),n||S0),e))},u.Mg=function(e,n){var i;switch(e){case 0:!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Dr(this.Ab),!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Lr(this.Ab,a(n,13));return;case 1:kh(this,hi(n));return;case 2:Jct(this,a(n,21).a);return;case 3:nme(this,a(n,1634));return;case 4:lat(this,hi(n));return}Yu(this,e-ei((ye(),S0)),Ve((i=a(an(this,16),24),i||S0),e),n)},u.Rg=function(){return ye(),S0},u.Ib=function(){var e;return e=this.c,e??this.zb},u.b=null,u.c=null,u.d=0;var xqe=A(Re,"EEnumLiteralImpl",525),q3e=Sr(Re,"EFactoryImpl/InternalEDateTimeFormat");T(445,1,{1699:1},Qy);var Mqe=A(Re,"EFactoryImpl/1ClientInternalEDateTimeFormat",445);T(217,108,{95:1,91:1,87:1,84:1,51:1,103:1,42:1,92:1,217:1,107:1,108:1},m1),u.lg=function(e,n,i){var r;return i=ku(this,e,n,i),this.e&&ct(e,158)&&(r=P7(this,this.e),r!=this.c&&(i=iE(this,r,i))),i},u.ug=function(e,n,i){var r;switch(e){case 0:return this.f;case 1:return!this.d&&(this.d=new Ss(Do,this,1)),this.d;case 2:return n?j7(this):this.c;case 3:return this.b;case 4:return this.e;case 5:return n?Wq(this):this.a}return qu(this,e-ei((ye(),fy)),Ve((r=a(an(this,16),24),r||fy),e),n,i)},u.Dg=function(e,n,i){var r,c;switch(n){case 0:return z6t(this,null,i);case 1:return!this.d&&(this.d=new Ss(Do,this,1)),$s(this.d,e,i);case 3:return U6t(this,null,i)}return c=a(Ve((r=a(an(this,16),24),r||(ye(),fy)),n),61),c.aj().ej(this,ra(this),n-ei((ye(),fy)),e,i)},u.Fg=function(e){var n;switch(e){case 0:return!!this.f;case 1:return!!this.d&&this.d.i!=0;case 2:return!!this.c;case 3:return!!this.b;case 4:return!!this.e;case 5:return!!this.a}return $u(this,e-ei((ye(),fy)),Ve((n=a(an(this,16),24),n||fy),e))},u.Mg=function(e,n){var i;switch(e){case 0:L1e(this,a(n,84));return;case 1:!this.d&&(this.d=new Ss(Do,this,1)),Dr(this.d),!this.d&&(this.d=new Ss(Do,this,1)),Lr(this.d,a(n,13));return;case 3:a8t(this,a(n,84));return;case 4:T8t(this,a(n,742));return;case 5:mC(this,a(n,133));return}Yu(this,e-ei((ye(),fy)),Ve((i=a(an(this,16),24),i||fy),e),n)},u.Rg=function(){return ye(),fy},u.Ib=function(){var e;return e=new ll(nh(this)),e.a+=" (expression: ",XX(this,e),e.a+=")",e.a};var Zvt,Eqe=A(Re,"EGenericTypeImpl",217);T(1667,1657,PO),u.xj=function(e,n){return ine(this,this._b(),e),n},u.Dh=function(e){return j1(this.Uh(),e)},u.oh=function(){return this.ph()},u.Uh=function(){return new E5(this)},u.ph=function(){return this.qh(0)},u.qh=function(e){return this.Uh().fd(e)},u.yj=function(e,n){return O2(this,e,!0),n};var Sqe=A(hr,"AbstractSequentialInternalEList",1667);T(444,1667,PO,J5),u.Dh=function(e){return j1(this.Uh(),e)},u.oh=function(){return this.b==null?(Ap(),Ap(),wI):this.Vj()},u.Uh=function(){return new EEt(this.a,this.b)},u.ph=function(){return this.b==null?(Ap(),Ap(),wI):this.Vj()},u.qh=function(e){var n,i;if(this.b==null){if(e<0||e>1)throw K(new Uc(M4+e+", size=0"));return Ap(),Ap(),wI}for(i=this.Vj(),n=0;n0;)if(n=this.c[--this.d],(!this.e||n.Vi()!=jE||n.pi()!=0)&&(!this.Yj()||this.b.Gg(n))){if(l=this.b.wg(n,this.Xj()),this.f=(Jo(),a(n,61).bj()),this.f||n.lj()){if(this.Xj()?(r=a(l,15),this.k=r):(r=a(l,64),this.k=this.j=r),ct(this.k,49)?(this.o=this.k._b(),this.n=this.o):this.p=this.j?this.j.qh(this.k._b()):this.k.fd(this.k._b()),this.p?i9t(this,this.p):b9t(this))return c=this.p?this.p.Ec():this.j?this.j.Dh(--this.n):this.k.cd(--this.n),this.f?(e=a(c,75),e.nj(),i=e.lc(),this.i=i):this.i=c,this.g=-3,!0}else if(l!=null)return this.k=null,this.p=null,this.i=l,this.g=-2,!0}return this.k=null,this.p=null,this.g=-1,!1}else return c=this.p?this.p.Ec():this.j?this.j.Dh(--this.n):this.k.cd(--this.n),this.f?(e=a(c,75),e.nj(),i=e.lc(),this.i=i):this.i=c,this.g=-3,!0}},u.ic=function(){return DN(this)},u.Dc=function(){return this.a},u.Ec=function(){var e;if(this.g<-1||this.Cc())return--this.a,this.g=0,e=this.i,this.Cc(),e;throw K(new J)},u.Fc=function(){return this.a-1},u.jc=function(){throw K(new Oi)},u.Xj=function(){return!1},u.Gc=function(e){throw K(new Oi)},u.Yj=function(){return!0},u.a=0,u.d=0,u.f=!1,u.g=0,u.n=0,u.o=0;var wI,Aqe=A(hr,"EContentsEList/FeatureIteratorImpl",260);T(631,260,IO,nst),u.Xj=function(){return!0};var kqe=A(hr,"EContentsEList/ResolvingFeatureIteratorImpl",631);T(1020,631,IO,USt),u.Yj=function(){return!1};var Lqe=A(Re,"ENamedElementImpl/1/1",1020);T(1021,260,IO,FSt),u.Yj=function(){return!1};var Pqe=A(Re,"ENamedElementImpl/1/2",1021);T(32,136,r6,Xb,eV,fs,gV,Qd,Jl,Qct,IAt,tat,RAt,xct,DAt,iat,NAt,Mct,OAt,eat,BAt,fL,Hot,nat,FAt,Ect,UAt),u.oi=function(){return Oct(this)},u.vi=function(){var e;return e=Oct(this),e?e.Oi():null},u.Mh=function(e){return this.b==-1&&this.a&&(this.b=this.c.qg(this.a.pi(),this.a.Vi())),this.c.hg(this.b,e)},u.Oh=function(){return this.c},u.wi=function(){var e;return e=Oct(this),e?e.Zi():!1},u.b=-1;var Iqe=A(Re,"ENotificationImpl",32);T(371,268,{95:1,91:1,87:1,139:1,174:1,51:1,53:1,103:1,431:1,42:1,92:1,142:1,371:1,268:1,107:1,108:1},PG),u.jg=function(e){return HRt(this,e)},u.ug=function(e,n,i){var r,c,l;switch(e){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),this.Ab;case 1:return this.zb;case 2:return me(),!!(this.Bb&256);case 3:return me(),!!(this.Bb&512);case 4:return Xt(this.s);case 5:return Xt(this.t);case 6:return me(),l=this.t,l>1||l==-1;case 7:return me(),c=this.s,c>=1;case 8:return n?wl(this):this.r;case 9:return this.q;case 10:return this.Db>>16==10?a(this.Cb,24):null;case 11:return!this.d&&(this.d=new Hu(wu,this,11)),this.d;case 12:return!this.c&&(this.c=new Wt(Nw,this,12,10)),this.c;case 13:return!this.a&&(this.a=new iL(this,this)),this.a;case 14:return Ya(this)}return qu(this,e-ei((ye(),T0)),Ve((r=a(an(this,16),24),r||T0),e),n,i)},u.Bg=function(e,n,i){var r,c,l;switch(n){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Kc(this.Ab,e,i);case 10:return this.Cb&&(i=(c=this.Db>>16,c>=0?HRt(this,i):this.Cb.Cg(this,-1-c,null,i))),ku(this,e,10,i);case 12:return!this.c&&(this.c=new Wt(Nw,this,12,10)),Kc(this.c,e,i)}return l=a(Ve((r=a(an(this,16),24),r||(ye(),T0)),n),61),l.aj().dj(this,ra(this),n-ei((ye(),T0)),e,i)},u.Dg=function(e,n,i){var r,c;switch(n){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),$s(this.Ab,e,i);case 9:return C$(this,i);case 10:return ku(this,null,10,i);case 11:return!this.d&&(this.d=new Hu(wu,this,11)),$s(this.d,e,i);case 12:return!this.c&&(this.c=new Wt(Nw,this,12,10)),$s(this.c,e,i);case 14:return $s(Ya(this),e,i)}return c=a(Ve((r=a(an(this,16),24),r||(ye(),T0)),n),61),c.aj().ej(this,ra(this),n-ei((ye(),T0)),e,i)},u.Fg=function(e){var n,i,r;switch(e){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return(this.Bb&256)==0;case 3:return(this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return r=this.t,r>1||r==-1;case 7:return i=this.s,i>=1;case 8:return!!this.r&&!this.q.e&&dm(this.q).i==0;case 9:return!!this.q&&!(this.r&&!this.q.e&&dm(this.q).i==0);case 10:return!!(this.Db>>16==10&&a(this.Cb,24));case 11:return!!this.d&&this.d.i!=0;case 12:return!!this.c&&this.c.i!=0;case 13:return!!this.a&&Ya(this.a.a).i!=0&&!(this.b&&Gq(this.b));case 14:return!!this.b&&Gq(this.b)}return $u(this,e-ei((ye(),T0)),Ve((n=a(an(this,16),24),n||T0),e))},u.Mg=function(e,n){var i,r;switch(e){case 0:!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Dr(this.Ab),!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Lr(this.Ab,a(n,13));return;case 1:kh(this,hi(n));return;case 2:a_(this,lt(de(n)));return;case 3:u_(this,lt(de(n)));return;case 4:r_(this,a(n,21).a);return;case 5:IM(this,a(n,21).a);return;case 8:UM(this,a(n,133));return;case 9:r=W1(this,a(n,84),null),r&&r.Th();return;case 11:!this.d&&(this.d=new Hu(wu,this,11)),Dr(this.d),!this.d&&(this.d=new Hu(wu,this,11)),Lr(this.d,a(n,13));return;case 12:!this.c&&(this.c=new Wt(Nw,this,12,10)),Dr(this.c),!this.c&&(this.c=new Wt(Nw,this,12,10)),Lr(this.c,a(n,13));return;case 13:!this.a&&(this.a=new iL(this,this)),$7(this.a),!this.a&&(this.a=new iL(this,this)),Lr(this.a,a(n,13));return;case 14:Dr(Ya(this)),Lr(Ya(this),a(n,13));return}Yu(this,e-ei((ye(),T0)),Ve((i=a(an(this,16),24),i||T0),e),n)},u.Rg=function(){return ye(),T0},u.Xg=function(){var e,n;if(this.c)for(e=0,n=this.c.i;eg&&Vr(e,g,null),r=0,i=new $n(Ya(this.a));i.e!=i.i._b();)n=a(ci(i),84),l=(f=n.c,f||(ye(),Hf)),Vr(e,r++,l);return e},u.ki=function(){var e,n,i,r,c;for(c=new Sp,c.a+="[",e=Ya(this.a),n=0,r=Ya(this.a).i;n1);case 5:return rC(this,5,n,i,r,this.i-a(i,15)._b()>0);default:return new Qd(this.e,e,this.c,n,i,r,!0)}},u.xi=function(){return!0},u.ui=function(){return Gq(this)},u.ij=function(){Dr(this)};var Oqe=A(Re,"EOperationImpl/2",1388);T(456,1,{1631:1,456:1},lEt);var Bqe=A(Re,"EPackageImpl/1",456);T(18,88,Zo,Wt),u.Lj=function(){return this.d},u.Mj=function(){return this.b},u.Pj=function(){return!0},u.b=0;var Fqe=A(hr,"EObjectContainmentWithInverseEList",18);T(364,18,Zo,fM),u.Qj=function(){return!0},u.zh=function(e,n){return G2(this,e,a(n,51))};var Uqe=A(hr,"EObjectContainmentWithInverseEList/Resolving",364);T(303,364,Zo,$v),u.th=function(){this.a.tb=null};var zqe=A(Re,"EPackageImpl/2",303);T(1155,1,{},Tz);var jqe=A(Re,"EPackageImpl/3",1155);T(650,44,tx,_it),u.Qb=function(e){return Es(e)?z$(this,e):!!Ea(this.d,e)};var Hqe=A(Re,"EPackageRegistryImpl",650);T(468,268,{95:1,91:1,87:1,139:1,174:1,51:1,1703:1,103:1,431:1,42:1,92:1,142:1,468:1,268:1,107:1,108:1},IG),u.jg=function(e){return GRt(this,e)},u.ug=function(e,n,i){var r,c,l;switch(e){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),this.Ab;case 1:return this.zb;case 2:return me(),!!(this.Bb&256);case 3:return me(),!!(this.Bb&512);case 4:return Xt(this.s);case 5:return Xt(this.t);case 6:return me(),l=this.t,l>1||l==-1;case 7:return me(),c=this.s,c>=1;case 8:return n?wl(this):this.r;case 9:return this.q;case 10:return this.Db>>16==10?a(this.Cb,53):null}return qu(this,e-ei((ye(),Bw)),Ve((r=a(an(this,16),24),r||Bw),e),n,i)},u.Bg=function(e,n,i){var r,c,l;switch(n){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Kc(this.Ab,e,i);case 10:return this.Cb&&(i=(c=this.Db>>16,c>=0?GRt(this,i):this.Cb.Cg(this,-1-c,null,i))),ku(this,e,10,i)}return l=a(Ve((r=a(an(this,16),24),r||(ye(),Bw)),n),61),l.aj().dj(this,ra(this),n-ei((ye(),Bw)),e,i)},u.Dg=function(e,n,i){var r,c;switch(n){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),$s(this.Ab,e,i);case 9:return C$(this,i);case 10:return ku(this,null,10,i)}return c=a(Ve((r=a(an(this,16),24),r||(ye(),Bw)),n),61),c.aj().ej(this,ra(this),n-ei((ye(),Bw)),e,i)},u.Fg=function(e){var n,i,r;switch(e){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return(this.Bb&256)==0;case 3:return(this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return r=this.t,r>1||r==-1;case 7:return i=this.s,i>=1;case 8:return!!this.r&&!this.q.e&&dm(this.q).i==0;case 9:return!!this.q&&!(this.r&&!this.q.e&&dm(this.q).i==0);case 10:return!!(this.Db>>16==10&&a(this.Cb,53))}return $u(this,e-ei((ye(),Bw)),Ve((n=a(an(this,16),24),n||Bw),e))},u.Rg=function(){return ye(),Bw};var Gqe=A(Re,"EParameterImpl",468);T(62,418,{95:1,91:1,87:1,139:1,174:1,51:1,17:1,158:1,61:1,103:1,431:1,42:1,92:1,142:1,62:1,418:1,268:1,107:1,108:1,615:1},cst),u.ug=function(e,n,i){var r,c,l,f;switch(e){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),this.Ab;case 1:return this.zb;case 2:return me(),!!(this.Bb&256);case 3:return me(),!!(this.Bb&512);case 4:return Xt(this.s);case 5:return Xt(this.t);case 6:return me(),f=this.t,f>1||f==-1;case 7:return me(),c=this.s,c>=1;case 8:return n?wl(this):this.r;case 9:return this.q;case 10:return me(),!!(this.Bb&oh);case 11:return me(),!!(this.Bb&dw);case 12:return me(),!!(this.Bb&Bm);case 13:return this.j;case 14:return QM(this);case 15:return me(),!!(this.Bb&La);case 16:return me(),!!(this.Bb&Lf);case 17:return Vb(this);case 18:return me(),!!(this.Bb&ca);case 19:return me(),l=jo(this),!!(l&&l.Bb&ca);case 20:return me(),!!(this.Bb&ao);case 21:return n?jo(this):this.b;case 22:return n?Aat(this):jkt(this);case 23:return!this.a&&(this.a=new uM(hy,this,23)),this.a}return qu(this,e-ei((ye(),HE)),Ve((r=a(an(this,16),24),r||HE),e),n,i)},u.Fg=function(e){var n,i,r,c;switch(e){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return(this.Bb&256)==0;case 3:return(this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return c=this.t,c>1||c==-1;case 7:return i=this.s,i>=1;case 8:return!!this.r&&!this.q.e&&dm(this.q).i==0;case 9:return!!this.q&&!(this.r&&!this.q.e&&dm(this.q).i==0);case 10:return(this.Bb&oh)==0;case 11:return(this.Bb&dw)!=0;case 12:return(this.Bb&Bm)!=0;case 13:return this.j!=null;case 14:return QM(this)!=null;case 15:return(this.Bb&La)!=0;case 16:return(this.Bb&Lf)!=0;case 17:return!!Vb(this);case 18:return(this.Bb&ca)!=0;case 19:return r=jo(this),!!r&&(r.Bb&ca)!=0;case 20:return(this.Bb&ao)==0;case 21:return!!this.b;case 22:return!!jkt(this);case 23:return!!this.a&&this.a.i!=0}return $u(this,e-ei((ye(),HE)),Ve((n=a(an(this,16),24),n||HE),e))},u.Mg=function(e,n){var i,r;switch(e){case 0:!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Dr(this.Ab),!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Lr(this.Ab,a(n,13));return;case 1:Z$(this,hi(n));return;case 2:a_(this,lt(de(n)));return;case 3:u_(this,lt(de(n)));return;case 4:r_(this,a(n,21).a);return;case 5:IM(this,a(n,21).a);return;case 8:UM(this,a(n,133));return;case 9:r=W1(this,a(n,84),null),r&&r.Th();return;case 10:$N(this,lt(de(n)));return;case 11:WN(this,lt(de(n)));return;case 12:qN(this,lt(de(n)));return;case 13:Srt(this,hi(n));return;case 15:VN(this,lt(de(n)));return;case 16:XN(this,lt(de(n)));return;case 18:Aoe(this,lt(de(n)));return;case 20:oIt(this,lt(de(n)));return;case 21:cPt(this,a(n,17));return;case 23:!this.a&&(this.a=new uM(hy,this,23)),Dr(this.a),!this.a&&(this.a=new uM(hy,this,23)),Lr(this.a,a(n,13));return}Yu(this,e-ei((ye(),HE)),Ve((i=a(an(this,16),24),i||HE),e),n)},u.Rg=function(){return ye(),HE},u.Xg=function(){Aat(this),vM(qo((Qa(),eo),this)),wl(this),this.Bb|=1},u.$i=function(){return jo(this)},u.Cj=function(){var e;return e=jo(this),!!e&&(e.Bb&ca)!=0},u.Dj=function(){return(this.Bb&ca)!=0},u.Ej=function(){return(this.Bb&ao)!=0},u.zj=function(e,n){return this.c=null,Wat(this,e,n)},u.Ib=function(){var e;return this.Db&64?U7(this):(e=new ul(U7(this)),e.a+=" (containment: ",Cp(e,(this.Bb&ca)!=0),e.a+=", resolveProxies: ",Cp(e,(this.Bb&ao)!=0),e.a+=")",e.a)};var Wqe=A(Re,"EReferenceImpl",62);T(505,108,{95:1,38:1,91:1,87:1,134:1,51:1,103:1,42:1,92:1,505:1,107:1,108:1},IR),u.Fb=function(e){return this===e},u.kc=function(){return this.b},u.lc=function(){return this.c},u.Hb=function(){return cm(this)},u.kh=function(e){yre(this,hi(e))},u.mc=function(e){return lre(this,hi(e))},u.ug=function(e,n,i){var r;switch(e){case 0:return this.b;case 1:return this.c}return qu(this,e-ei((ye(),Ho)),Ve((r=a(an(this,16),24),r||Ho),e),n,i)},u.Fg=function(e){var n;switch(e){case 0:return this.b!=null;case 1:return this.c!=null}return $u(this,e-ei((ye(),Ho)),Ve((n=a(an(this,16),24),n||Ho),e))},u.Mg=function(e,n){var i;switch(e){case 0:xre(this,hi(n));return;case 1:tPt(this,hi(n));return}Yu(this,e-ei((ye(),Ho)),Ve((i=a(an(this,16),24),i||Ho),e),n)},u.Rg=function(){return ye(),Ho},u.ih=function(){var e;return this.a==-1&&(e=this.b,this.a=e==null?0:z1(e)),this.a},u.jh=function(e){this.a=e},u.Ib=function(){var e;return this.Db&64?nh(this):(e=new ul(nh(this)),e.a+=" (key: ",mo(e,this.b),e.a+=", value: ",mo(e,this.c),e.a+=")",e.a)},u.a=-1,u.b=null,u.c=null;var Dc=A(Re,"EStringToStringMapEntryImpl",505),Zqt=Sr(hr,"FeatureMap/Entry/Internal");T(514,1,RO),u.$j=function(e){return this._j(a(e,42))},u._j=function(e){return this.$j(e)},u.Fb=function(e){var n,i;return this===e?!0:ct(e,75)?(n=a(e,75),n.nj()==this.c?(i=this.lc(),i==null?n.lc()==null:Fi(i,n.lc())):!1):!1},u.nj=function(){return this.c},u.Hb=function(){var e;return e=this.lc(),Yr(this.c)^(e==null?0:Yr(e))},u.Ib=function(){var e,n;return e=this.c,n=Xu(e.Wi()).fh(),e.be(),(n!=null&&n.length!=0?n+":"+e.be():e.be())+"="+this.lc()};var $qe=A(Re,"EStructuralFeatureImpl/BasicFeatureMapEntry",514);T(709,514,RO,gst),u._j=function(e){return new gst(this.c,e)},u.lc=function(){return this.a},u.ak=function(e,n,i){return ole(this,e,this.a,n,i)},u.bk=function(e,n,i){return cle(this,e,this.a,n,i)};var Vqe=A(Re,"EStructuralFeatureImpl/ContainmentUpdatingFeatureMapEntry",709);T(1363,1,{},hEt),u.cj=function(e,n,i,r,c){var l;return l=a(TL(e,this.b),237),l.yk(this.a).hj(r)},u.dj=function(e,n,i,r,c){var l;return l=a(TL(e,this.b),237),l.pk(this.a,r,c)},u.ej=function(e,n,i,r,c){var l;return l=a(TL(e,this.b),237),l.qk(this.a,r,c)},u.fj=function(e,n,i){var r;return r=a(TL(e,this.b),237),r.yk(this.a).ui()},u.gj=function(e,n,i,r){var c;c=a(TL(e,this.b),237),c.yk(this.a).Gc(r)};var qqe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateFeatureMapDelegator",1363);T(82,1,{},Ip,zg,Op,Gg),u.cj=function(e,n,i,r,c){var l;if(l=n.Tg(i),l==null&&n.Ug(i,l=Zht(this,e)),!c)switch(this.e){case 50:case 41:return a(l,533).Hi();case 40:return a(l,237).vk()}return l},u.dj=function(e,n,i,r,c){var l,f;return f=n.Tg(i),f==null&&n.Ug(i,f=Zht(this,e)),l=a(f,64).xj(r,c),l},u.ej=function(e,n,i,r,c){var l;return l=n.Tg(i),l!=null&&(c=a(l,64).yj(r,c)),c},u.fj=function(e,n,i){var r;return r=n.Tg(i),r!=null&&a(r,81).ui()},u.gj=function(e,n,i,r){var c;c=a(n.Tg(i),81),!c&&n.Ug(i,c=Zht(this,e)),c.Gc(r)},u.b=0,u.e=0;var Xqe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateMany",82);T(461,1,{}),u.dj=function(e,n,i,r,c){throw K(new Oi)},u.ej=function(e,n,i,r,c){throw K(new Oi)};var ug,Zqe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingle",461);T(702,461,{},Kot),u.cj=function(e,n,i,r,c){return IX(e,e.yg(),e.og())==this.b?this.Ej()&&r?vX(e):e.yg():null},u.dj=function(e,n,i,r,c){var l,f;return e.yg()&&(c=(l=e.og(),l>=0?e.jg(c):e.yg().Cg(e,-1-l,null,c))),f=xr(e.mg(),this.e),e.lg(r,f,c)},u.ej=function(e,n,i,r,c){var l;return l=xr(e.mg(),this.e),e.lg(null,l,c)},u.fj=function(e,n,i){var r;return r=xr(e.mg(),this.e),!!e.yg()&&e.og()==r},u.gj=function(e,n,i,r){var c,l,f,g,b;if(r!=null&&!BX(this.a,r))throw K(new dT(DO+(ct(r,51)?Qut(a(r,51).mg()):Vct(fu(r)))+NO+this.a+"'"));if(c=e.yg(),f=xr(e.mg(),this.e),zt(r)!==zt(c)||e.og()!=f&&r!=null){if(VM(e,a(r,51)))throw K(new yn(y4+e.Ib()));b=null,c&&(b=(l=e.og(),l>=0?e.jg(null):e.yg().Cg(e,-1-l,null,null))),g=a(r,42),g&&(b=g.Ag(e,xr(g.mg(),this.b),null,b)),b=e.lg(g,f,b),b&&b.Th()}else e.eg()&&e.fg()&&Bi(e,new fs(e,1,f,r,r))},u.Ej=function(){return!1};var Yqe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleContainer",702);T(1364,702,{},WTt),u.Ej=function(){return!0};var Kqe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleContainerResolving",1364);T(512,461,{}),u.cj=function(e,n,i,r,c){var l;return l=n.Tg(i),l==null?this.b:zt(l)===zt(ug)?null:l},u.fj=function(e,n,i){var r;return r=n.Tg(i),r!=null&&(zt(r)===zt(ug)||!Fi(r,this.b))},u.gj=function(e,n,i,r){var c,l;e.eg()&&e.fg()?(c=(l=n.Tg(i),l==null?this.b:zt(l)===zt(ug)?null:l),r==null?this.c!=null?(n.Ug(i,null),r=this.b):this.b!=null?n.Ug(i,ug):n.Ug(i,null):(this.ck(r),n.Ug(i,r)),Bi(e,this.d.dk(e,1,this.e,c,r))):r==null?this.c!=null?n.Ug(i,null):this.b!=null?n.Ug(i,ug):n.Ug(i,null):(this.ck(r),n.Ug(i,r))},u.ck=function(e){throw K(new f9)};var Jqe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleData",512);T(H_,1,{},Fk),u.dk=function(e,n,i,r,c){return new fL(e,n,i,r,c)},u.ek=function(e,n,i,r,c,l){return new Hot(e,n,i,r,c,l)};var Yvt,Kvt,Jvt,Qvt,t_t,e_t,n_t,ott,i_t,Qqe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator",H_);T(1379,H_,{},Cz),u.dk=function(e,n,i,r,c){return new Ect(e,n,i,lt(de(r)),lt(de(c)))},u.ek=function(e,n,i,r,c,l){return new UAt(e,n,i,lt(de(r)),lt(de(c)),l)};var tXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/1",1379);T(1380,H_,{},Uk),u.dk=function(e,n,i,r,c){return new Qct(e,n,i,a(r,192).a,a(c,192).a)},u.ek=function(e,n,i,r,c,l){return new IAt(e,n,i,a(r,192).a,a(c,192).a,l)};var eXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/2",1380);T(1381,H_,{},RR),u.dk=function(e,n,i,r,c){return new tat(e,n,i,a(r,159).a,a(c,159).a)},u.ek=function(e,n,i,r,c,l){return new RAt(e,n,i,a(r,159).a,a(c,159).a,l)};var nXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/3",1381);T(1382,H_,{},DR),u.dk=function(e,n,i,r,c){return new xct(e,n,i,lt(Yt(r)),lt(Yt(c)))},u.ek=function(e,n,i,r,c,l){return new DAt(e,n,i,lt(Yt(r)),lt(Yt(c)),l)};var iXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/4",1382);T(1383,H_,{},NR),u.dk=function(e,n,i,r,c){return new iat(e,n,i,a(r,126).a,a(c,126).a)},u.ek=function(e,n,i,r,c,l){return new NAt(e,n,i,a(r,126).a,a(c,126).a,l)};var rXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/5",1383);T(1384,H_,{},GS),u.dk=function(e,n,i,r,c){return new Mct(e,n,i,a(r,21).a,a(c,21).a)},u.ek=function(e,n,i,r,c,l){return new OAt(e,n,i,a(r,21).a,a(c,21).a,l)};var sXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/6",1384);T(1385,H_,{},Az),u.dk=function(e,n,i,r,c){return new eat(e,n,i,a(r,149).a,a(c,149).a)},u.ek=function(e,n,i,r,c,l){return new BAt(e,n,i,a(r,149).a,a(c,149).a,l)};var oXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/7",1385);T(1386,H_,{},OR),u.dk=function(e,n,i,r,c){return new nat(e,n,i,a(r,168).a,a(c,168).a)},u.ek=function(e,n,i,r,c,l){return new FAt(e,n,i,a(r,168).a,a(c,168).a,l)};var cXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/8",1386);T(1366,512,{},T4t),u.ck=function(e){if(!this.a.Li(e))throw K(new dT(DO+fu(e)+NO+this.a+"'"))};var aXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleDataDynamic",1366);T(1367,512,{},LCt),u.ck=function(e){};var uXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleDataStatic",1367);T(703,512,{}),u.fj=function(e,n,i){var r;return r=n.Tg(i),r!=null},u.gj=function(e,n,i,r){var c,l;e.eg()&&e.fg()?(c=!0,l=n.Tg(i),l==null?(c=!1,l=this.b):zt(l)===zt(ug)&&(l=null),r==null?this.c!=null?(n.Ug(i,null),r=this.b):n.Ug(i,ug):(this.ck(r),n.Ug(i,r)),Bi(e,this.d.ek(e,1,this.e,l,r,!c))):r==null?this.c!=null?n.Ug(i,null):n.Ug(i,ug):(this.ck(r),n.Ug(i,r))};var lXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleDataUnsettable",703);T(1368,703,{},C4t),u.ck=function(e){if(!this.a.Li(e))throw K(new dT(DO+fu(e)+NO+this.a+"'"))};var hXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleDataUnsettableDynamic",1368);T(1369,703,{},PCt),u.ck=function(e){};var fXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleDataUnsettableStatic",1369);T(370,461,{},DD),u.cj=function(e,n,i,r,c){var l,f,g,b,v;if(v=n.Tg(i),this.Zi()&&zt(v)===zt(ug))return null;if(this.Ej()&&r&&v!=null){if(g=a(v,42),g.Eg()&&(b=O1(e,g),g!=b)){if(!BX(this.a,b))throw K(new dT(DO+fu(b)+NO+this.a+"'"));n.Ug(i,v=b),this.Dj()&&(l=a(b,42),f=g.Cg(e,this.b?xr(g.mg(),this.b):-1-xr(e.mg(),this.e),null,null),!l.yg()&&(f=l.Ag(e,this.b?xr(l.mg(),this.b):-1-xr(e.mg(),this.e),null,f)),f&&f.Th()),e.eg()&&e.fg()&&Bi(e,new fL(e,9,this.e,g,b))}return v}else return v},u.dj=function(e,n,i,r,c){var l,f;return f=n.Tg(i),zt(f)===zt(ug)&&(f=null),n.Ug(i,r),this.qi()?zt(f)!==zt(r)&&f!=null&&(l=a(f,42),c=l.Cg(e,xr(l.mg(),this.b),null,c)):this.Dj()&&f!=null&&(c=a(f,42).Cg(e,-1-xr(e.mg(),this.e),null,c)),e.eg()&&e.fg()&&(!c&&(c=new b1(4)),c.Sh(new fL(e,1,this.e,f,r))),c},u.ej=function(e,n,i,r,c){var l;return l=n.Tg(i),zt(l)===zt(ug)&&(l=null),n.Vg(i),e.eg()&&e.fg()&&(!c&&(c=new b1(4)),this.Zi()?c.Sh(new fL(e,2,this.e,l,null)):c.Sh(new fL(e,1,this.e,l,null))),c},u.fj=function(e,n,i){var r;return r=n.Tg(i),r!=null},u.gj=function(e,n,i,r){var c,l,f,g,b;if(r!=null&&!BX(this.a,r))throw K(new dT(DO+(ct(r,51)?Qut(a(r,51).mg()):Vct(fu(r)))+NO+this.a+"'"));b=n.Tg(i),g=b!=null,this.Zi()&&zt(b)===zt(ug)&&(b=null),f=null,this.qi()?zt(b)!==zt(r)&&(b!=null&&(c=a(b,42),f=c.Cg(e,xr(c.mg(),this.b),null,null)),r!=null&&(c=a(r,42),f=c.Ag(e,xr(c.mg(),this.b),null,f))):this.Dj()&&zt(b)!==zt(r)&&(b!=null&&(f=a(b,42).Cg(e,-1-xr(e.mg(),this.e),null,null)),r!=null&&(f=a(r,42).Ag(e,-1-xr(e.mg(),this.e),null,f))),r==null&&this.Zi()?n.Ug(i,ug):n.Ug(i,r),e.eg()&&e.fg()?(l=new Hot(e,1,this.e,b,r,this.Zi()&&!g),f?(f.Sh(l),f.Th()):Bi(e,l)):f&&f.Th()},u.qi=function(){return!1},u.Dj=function(){return!1},u.Ej=function(){return!1},u.Zi=function(){return!1};var dXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObject",370);T(513,370,{},$W),u.Dj=function(){return!0};var pXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainment",513);T(1372,513,{},zSt),u.Ej=function(){return!0};var gXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentResolving",1372);T(705,513,{},rst),u.Zi=function(){return!0};var mXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentUnsettable",705);T(1374,705,{},jSt),u.Ej=function(){return!0};var bXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentUnsettableResolving",1374);T(585,513,{},c$),u.qi=function(){return!0};var wXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverse",585);T(1373,585,{},$Tt),u.Ej=function(){return!0};var vXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverseResolving",1373);T(706,585,{},Ust),u.Zi=function(){return!0};var _Xe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverseUnsettable",706);T(1375,706,{},VTt),u.Ej=function(){return!0};var yXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverseUnsettableResolving",1375);T(586,370,{},ist),u.Ej=function(){return!0};var xXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolving",586);T(1376,586,{},HSt),u.Zi=function(){return!0};var MXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolvingUnsettable",1376);T(707,586,{},Fst),u.qi=function(){return!0};var EXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolvingWithInverse",707);T(1377,707,{},qTt),u.Zi=function(){return!0};var SXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolvingWithInverseUnsettable",1377);T(1370,370,{},GSt),u.Zi=function(){return!0};var TXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectUnsettable",1370);T(704,370,{},zst),u.qi=function(){return!0};var CXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectWithInverse",704);T(1371,704,{},XTt),u.Zi=function(){return!0};var AXe=A(Re,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectWithInverseUnsettable",1371);T(708,514,RO,Lot),u._j=function(e){return new Lot(this.a,this.c,e)},u.lc=function(){return this.b},u.ak=function(e,n,i){return xae(this,e,this.b,i)},u.bk=function(e,n,i){return Mae(this,e,this.b,i)};var kXe=A(Re,"EStructuralFeatureImpl/InverseUpdatingFeatureMapEntry",708);T(1378,514,RO,Rkt),u.$j=function(e){return new YW((fr(),MI),this.b.Zg(this.a,e))},u.lc=function(){return null},u.ak=function(e,n,i){return i},u.bk=function(e,n,i){return i};var LXe=A(Re,"EStructuralFeatureImpl/SimpleContentFeatureMapEntry",1378);T(587,514,RO,YW),u.$j=function(e){return new YW(this.c,e)},u.lc=function(){return this.a},u.ak=function(e,n,i){return i},u.bk=function(e,n,i){return i};var PXe=A(Re,"EStructuralFeatureImpl/SimpleFeatureMapEntry",587);T(361,451,Nf,Tb),u.Fh=function(e){return dt(Dl,te,24,e,0,1)},u.Bh=function(){return!1};var IXe=A(Re,"ESuperAdapter/1",361);T(411,399,{95:1,91:1,87:1,139:1,174:1,51:1,103:1,742:1,42:1,92:1,142:1,411:1,107:1,108:1},zk),u.ug=function(e,n,i){var r;switch(e){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),this.Ab;case 1:return this.zb;case 2:return!this.a&&(this.a=new hL(this,Do,this)),this.a}return qu(this,e-ei((ye(),dy)),Ve((r=a(an(this,16),24),r||dy),e),n,i)},u.Dg=function(e,n,i){var r,c;switch(n){case 0:return!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),$s(this.Ab,e,i);case 2:return!this.a&&(this.a=new hL(this,Do,this)),$s(this.a,e,i)}return c=a(Ve((r=a(an(this,16),24),r||(ye(),dy)),n),61),c.aj().ej(this,ra(this),n-ei((ye(),dy)),e,i)},u.Fg=function(e){var n;switch(e){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return!!this.a&&this.a.i!=0}return $u(this,e-ei((ye(),dy)),Ve((n=a(an(this,16),24),n||dy),e))},u.Mg=function(e,n){var i;switch(e){case 0:!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Dr(this.Ab),!this.Ab&&(this.Ab=new Wt(Ui,this,0,3)),Lr(this.Ab,a(n,13));return;case 1:kh(this,hi(n));return;case 2:!this.a&&(this.a=new hL(this,Do,this)),Dr(this.a),!this.a&&(this.a=new hL(this,Do,this)),Lr(this.a,a(n,13));return}Yu(this,e-ei((ye(),dy)),Ve((i=a(an(this,16),24),i||dy),e),n)},u.Rg=function(){return ye(),dy};var RXe=A(Re,"ETypeParameterImpl",411);T(457,88,Zo,hL),u.ri=function(e,n){return h1e(this,a(e,84),n)},u.si=function(e,n){return f1e(this,a(e,84),n)};var DXe=A(Re,"ETypeParameterImpl/1",457);T(579,44,tx,DG),u.Xb=function(){return new aT(this)};var NXe=A(Re,"ETypeParameterImpl/2",579);T(508,bd,vl,aT),u.nc=function(e){return KSt(this,a(e,84))},u.oc=function(e){var n,i,r;for(r=!1,i=e.tc();i.hc();)n=a(i.ic(),84),wr(this.a,n,"")==null&&(r=!0);return r},u.Pb=function(){uu(this.a)},u.pc=function(e){return lm(this.a,e)},u.tc=function(){var e;return e=new Vg(new xp(this.a).a),new uT(e)},u.vc=function(e){return Hkt(this,e)},u._b=function(){return J3(this.a)};var OXe=A(Re,"ETypeParameterImpl/2/1",508);T(509,1,Cs,uT),u.gc=function(e){ks(this,e)},u.ic=function(){return a(xm(this.a).kc(),84)},u.hc=function(){return this.a.b},u.jc=function(){C5t(this.a)};var BXe=A(Re,"ETypeParameterImpl/2/1/1",509);T(1169,44,tx,Sxt),u.Qb=function(e){return Es(e)?z$(this,e):!!Ea(this.d,e)},u.Vb=function(e){var n,i;return n=Es(e)?Zc(this,e):Ua(Ea(this.d,e)),ct(n,743)?(i=a(n,743),n=i.mj(),wr(this,a(e,207),n),n):n??(e==null?(VG(),Kqt):null)};var FXe=A(Re,"EValidatorRegistryImpl",1169);T(1362,638,{95:1,91:1,87:1,430:1,139:1,51:1,103:1,1635:1,42:1,92:1,142:1,107:1,108:1},BR),u.Zg=function(e,n){switch(e.Ni()){case 21:case 22:case 23:case 24:case 26:case 31:case 32:case 37:case 38:case 39:case 40:case 43:case 44:case 48:case 49:case 20:return n==null?null:Yc(n);case 25:return kue(n);case 27:return $ae(n);case 28:return Vae(n);case 29:return n==null?null:tSt(MA[0],a(n,181));case 41:return n==null?"":Ng(a(n,274));case 42:return Yc(n);case 50:return hi(n);default:throw K(new yn(mE+e.be()+zm))}},u.$g=function(e){var n,i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt;switch(e.G==-1&&(e.G=(R=Xu(e),R?Hp(R.bh(),e):-1)),e.G){case 0:return i=new RG,i;case 1:return n=new kR,n;case 2:return r=new c5,r;case 4:return c=new x,c;case 5:return l=new Mxt,l;case 6:return f=new S5,f;case 7:return g=new y8,g;case 10:return v=new zl,v;case 11:return M=new PG,M;case 12:return k=new D4t,k;case 13:return O=new IG,O;case 14:return $=new cst,$;case 17:return W=new IR,W;case 18:return b=new m1,b;case 19:return nt=new zk,nt;default:throw K(new yn(HY+e.zb+zm))}},u._g=function(e,n){switch(e.Ni()){case 20:return n==null?null:new Sit(n);case 21:return n==null?null:new _1(n);case 23:case 22:return n==null?null:_fe(n);case 26:case 24:return n==null?null:AL(Au(n,-128,127)<<24>>24);case 25:return J0e(n);case 27:return Ede(n);case 28:return Sde(n);case 29:return X1e(n);case 32:case 31:return n==null?null:ew(n);case 38:case 37:return n==null?null:new fT(n);case 40:case 39:return n==null?null:Xt(Au(n,Vs,qi));case 41:return null;case 42:return n==null,null;case 44:case 43:return n==null?null:Jg(q7(n));case 49:case 48:return n==null?null:FM(Au(n,OO,32767)<<16>>16);case 50:return n;default:throw K(new yn(mE+e.be()+zm))}};var UXe=A(Re,"EcoreFactoryImpl",1362);T(504,248,{95:1,91:1,87:1,139:1,174:1,51:1,207:1,103:1,1633:1,42:1,92:1,142:1,248:1,504:1,107:1,108:1,613:1},f4t),u.gb=!1,u.hb=!1;var r_t,Yqt=!1,zXe=A(Re,"EcorePackageImpl",504);T(1111,1,{743:1},kz),u.mj=function(){return cSt(),Jqt};var jXe=A(Re,"EcorePackageImpl/1",1111);T(1120,1,wi,jk),u.Li=function(e){return ct(e,139)},u.Mi=function(e){return dt(pI,te,139,e,0,1)};var HXe=A(Re,"EcorePackageImpl/10",1120);T(1121,1,wi,FR),u.Li=function(e){return ct(e,174)},u.Mi=function(e){return dt(KQ,te,174,e,0,1)};var GXe=A(Re,"EcorePackageImpl/11",1121);T(1122,1,wi,Hk),u.Li=function(e){return ct(e,51)},u.Mi=function(e){return dt(Iw,te,51,e,0,1)};var WXe=A(Re,"EcorePackageImpl/12",1122);T(1123,1,wi,Lz),u.Li=function(e){return ct(e,371)},u.Mi=function(e){return dt(ph,qpt,53,e,0,1)};var $Xe=A(Re,"EcorePackageImpl/13",1123);T(1124,1,wi,Gk),u.Li=function(e){return ct(e,207)},u.Mi=function(e){return dt(of,te,207,e,0,1)};var VXe=A(Re,"EcorePackageImpl/14",1124);T(1125,1,wi,oo),u.Li=function(e){return ct(e,468)},u.Mi=function(e){return dt(Nw,te,1703,e,0,1)};var qXe=A(Re,"EcorePackageImpl/15",1125);T(1126,1,wi,Pz),u.Li=function(e){return ct(e,62)},u.Mi=function(e){return dt(Ow,j_,17,e,0,1)};var XXe=A(Re,"EcorePackageImpl/16",1126);T(1127,1,wi,Iz),u.Li=function(e){return ct(e,158)},u.Mi=function(e){return dt(Ra,j_,158,e,0,1)};var ZXe=A(Re,"EcorePackageImpl/17",1127);T(1128,1,wi,N3),u.Li=function(e){return ct(e,431)},u.Mi=function(e){return dt(Dw,te,431,e,0,1)};var YXe=A(Re,"EcorePackageImpl/18",1128);T(1129,1,wi,UR),u.Li=function(e){return ct(e,505)},u.Mi=function(e){return dt(Dc,dUt,505,e,0,1)};var KXe=A(Re,"EcorePackageImpl/19",1129);T(1112,1,wi,Rz),u.Li=function(e){return ct(e,335)},u.Mi=function(e){return dt(hy,j_,29,e,0,1)};var JXe=A(Re,"EcorePackageImpl/2",1112);T(1130,1,wi,Dz),u.Li=function(e){return ct(e,217)},u.Mi=function(e){return dt(Do,LUt,84,e,0,1)};var QXe=A(Re,"EcorePackageImpl/20",1130);T(1131,1,wi,yp),u.Li=function(e){return ct(e,411)},u.Mi=function(e){return dt(wu,te,742,e,0,1)};var tZe=A(Re,"EcorePackageImpl/21",1131);T(1132,1,wi,Nz),u.Li=function(e){return Ub(e)},u.Mi=function(e){return dt(ho,wt,434,e,8,1)};var eZe=A(Re,"EcorePackageImpl/22",1132);T(1133,1,wi,WS),u.Li=function(e){return ct(e,173)},u.Mi=function(e){return dt(Da,wt,173,e,0,2)};var nZe=A(Re,"EcorePackageImpl/23",1133);T(1134,1,wi,Wk),u.Li=function(e){return ct(e,192)},u.Mi=function(e){return dt(ux,wt,192,e,0,1)};var iZe=A(Re,"EcorePackageImpl/24",1134);T(1135,1,wi,zR),u.Li=function(e){return ct(e,159)},u.Mi=function(e){return dt(D4,wt,159,e,0,1)};var rZe=A(Re,"EcorePackageImpl/25",1135);T(1136,1,wi,jR),u.Li=function(e){return ct(e,181)},u.Mi=function(e){return dt(ZO,wt,181,e,0,1)};var sZe=A(Re,"EcorePackageImpl/26",1136);T(1137,1,wi,Fd),u.Li=function(e){return!1},u.Mi=function(e){return dt(x_t,te,1787,e,0,1)};var oZe=A(Re,"EcorePackageImpl/27",1137);T(1138,1,wi,Cb),u.Li=function(e){return zb(e)},u.Mi=function(e){return dt(To,wt,315,e,7,1)};var cZe=A(Re,"EcorePackageImpl/28",1138);T(1139,1,wi,$k),u.Li=function(e){return ct(e,52)},u.Mi=function(e){return dt(Bvt,uw,52,e,0,1)};var aZe=A(Re,"EcorePackageImpl/29",1139);T(1113,1,wi,HR),u.Li=function(e){return ct(e,469)},u.Mi=function(e){return dt(Ui,{3:1,4:1,5:1,1627:1},609,e,0,1)};var uZe=A(Re,"EcorePackageImpl/3",1113);T(1140,1,wi,$S),u.Li=function(e){return ct(e,525)},u.Mi=function(e){return dt(zvt,te,1634,e,0,1)};var lZe=A(Re,"EcorePackageImpl/30",1140);T(1141,1,wi,GR),u.Li=function(e){return ct(e,184)},u.Mi=function(e){return dt(u_t,uw,184,e,0,1)};var hZe=A(Re,"EcorePackageImpl/31",1141);T(1142,1,wi,Vk),u.Li=function(e){return ct(e,75)},u.Mi=function(e){return dt(VF,UUt,75,e,0,1)};var fZe=A(Re,"EcorePackageImpl/32",1142);T(1143,1,wi,WR),u.Li=function(e){return ct(e,126)},u.Mi=function(e){return dt(ME,wt,126,e,0,1)};var dZe=A(Re,"EcorePackageImpl/33",1143);T(1144,1,wi,qk),u.Li=function(e){return ct(e,21)},u.Mi=function(e){return dt(Io,wt,21,e,0,1)};var pZe=A(Re,"EcorePackageImpl/34",1144);T(1145,1,wi,Xk),u.Li=function(e){return ct(e,274)},u.Mi=function(e){return dt(o1t,te,274,e,0,1)};var gZe=A(Re,"EcorePackageImpl/35",1145);T(1146,1,wi,Ab),u.Li=function(e){return ct(e,149)},u.Mi=function(e){return dt(Gm,wt,149,e,0,1)};var mZe=A(Re,"EcorePackageImpl/36",1146);T(1147,1,wi,Oz),u.Li=function(e){return ct(e,109)},u.Mi=function(e){return dt(c1t,te,109,e,0,1)};var bZe=A(Re,"EcorePackageImpl/37",1147);T(1148,1,wi,kb),u.Li=function(e){return ct(e,534)},u.Mi=function(e){return dt(s_t,te,534,e,0,1)};var wZe=A(Re,"EcorePackageImpl/38",1148);T(1149,1,wi,$R),u.Li=function(e){return!1},u.Mi=function(e){return dt(M_t,te,1788,e,0,1)};var vZe=A(Re,"EcorePackageImpl/39",1149);T(1114,1,wi,VR),u.Li=function(e){return ct(e,96)},u.Mi=function(e){return dt(Dl,te,24,e,0,1)};var _Ze=A(Re,"EcorePackageImpl/4",1114);T(1150,1,wi,Zk),u.Li=function(e){return ct(e,168)},u.Mi=function(e){return dt(Wm,wt,168,e,0,1)};var yZe=A(Re,"EcorePackageImpl/40",1150);T(1151,1,wi,Bz),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var xZe=A(Re,"EcorePackageImpl/41",1151);T(1152,1,wi,Fz),u.Li=function(e){return ct(e,532)},u.Mi=function(e){return dt(Uvt,te,532,e,0,1)};var MZe=A(Re,"EcorePackageImpl/42",1152);T(1153,1,wi,Uz),u.Li=function(e){return!1},u.Mi=function(e){return dt(E_t,wt,1789,e,0,1)};var EZe=A(Re,"EcorePackageImpl/43",1153);T(1154,1,wi,qR),u.Li=function(e){return ct(e,38)},u.Mi=function(e){return dt(G_,te,38,e,0,1)};var SZe=A(Re,"EcorePackageImpl/44",1154);T(1115,1,wi,XR),u.Li=function(e){return ct(e,133)},u.Mi=function(e){return dt(cf,te,133,e,0,1)};var TZe=A(Re,"EcorePackageImpl/5",1115);T(1116,1,wi,zz),u.Li=function(e){return ct(e,140)},u.Mi=function(e){return dt(itt,te,140,e,0,1)};var CZe=A(Re,"EcorePackageImpl/6",1116);T(1117,1,wi,ZR),u.Li=function(e){return ct(e,425)},u.Mi=function(e){return dt($F,te,608,e,0,1)};var AZe=A(Re,"EcorePackageImpl/7",1117);T(1118,1,wi,YR),u.Li=function(e){return ct(e,525)},u.Mi=function(e){return dt(Qp,te,617,e,0,1)};var kZe=A(Re,"EcorePackageImpl/8",1118);T(1119,1,wi,td),u.Li=function(e){return ct(e,430)},u.Mi=function(e){return dt(xA,te,430,e,0,1)};var LZe=A(Re,"EcorePackageImpl/9",1119);T(915,1673,fUt,Uxt),u.sh=function(e,n){Yle(this,a(n,380))},u.vh=function(e,n){U8t(this,e,a(n,380))};var PZe=A(Re,"MinimalEObjectImpl/1ArrayDelegatingAdapterList",915);T(916,136,r6,e4t),u.Oh=function(){return this.a.a};var IZe=A(Re,"MinimalEObjectImpl/1ArrayDelegatingAdapterList/1",916);T(955,954,{},$Et);var RZe=A("org.eclipse.emf.ecore.plugin","EcorePlugin",955),s_t=Sr(zUt,"Resource");T(719,1492,jUt),u.ik=function(e){},u.jk=function(e){},u.fk=function(){return!this.a&&(this.a=new M5(this)),this.a},u.gk=function(e){var n,i,r,c,l;if(r=e.length,r>0)if(e.charCodeAt(0)==47){for(l=new Vu(4),c=1,n=1;n0&&(e=e.substr(0,i)));return A0e(this,e)},u.hk=function(){return this.c},u.Ib=function(){return Ng(this.ql)+"@"+(Yr(this)>>>0).toString(16)+" uri='"+this.d+"'"},u.b=!1;var DZe=A(iK,"ResourceImpl",719);T(1493,719,jUt,MG);var NZe=A(iK,"BinaryResourceImpl",1493);T(1048,629,KY),u.Gh=function(e){return ct(e,51)?Jse(this,a(e,51)):ct(e,534)?new $n(a(e,534).fk()):zt(e)===zt(this.f)?a(e,13).tc():(VT(),bI.a)},u.hc=function(){return Rlt(this)},u.a=!1;var OZe=A(hr,"EcoreUtil/ContentTreeIterator",1048);T(1494,1048,KY,BCt),u.Gh=function(e){return zt(e)===zt(this.f)?a(e,15).tc():new rkt(a(e,51))};var BZe=A(iK,"ResourceImpl/5",1494);T(595,1687,kUt,M5),u.pc=function(e){return this.i<=4?WC(this,e):ct(e,42)&&a(e,42).sg()==this.a},u.sh=function(e,n){e==this.i-1&&(this.a.b||(this.a.b=!0))},u.uh=function(e,n){e==0?this.a.b||(this.a.b=!0):fV(this,e,n)},u.vh=function(e,n){},u.wh=function(e,n,i){},u.pi=function(){return 2},u.Oh=function(){return this.a},u.qi=function(){return!0},u.ri=function(e,n){var i;return i=a(e,42),n=i.Pg(this.a,n),n},u.si=function(e,n){var i;return i=a(e,42),i.Pg(null,n)},u.ti=function(){return!1},u.xh=function(){return!0},u.Fh=function(e){return dt(Iw,te,51,e,0,1)},u.Bh=function(){return!1};var FZe=A(iK,"ResourceImpl/ContentsEList",595);T(873,1657,Z2,E5),u.fd=function(e){return this.a.qh(e)},u._b=function(){return this.a._b()};var UZe=A(hr,"AbstractSequentialInternalEList/1",873),o_t,c_t,eo,a_t;T(567,1,{},rCt);var qF,XF,zZe=A(hr,"BasicExtendedMetaData",567);T(1023,1,{},fEt),u.kk=function(){return null},u.lk=function(){return this.a==-2&&jnt(this,Z1e(this.d,this.b)),this.a},u.mk=function(){return null},u.nk=function(){return we(),we(),fo},u.be=function(){return this.c==vE&&zj(this,YIt(this.d,this.b)),this.c},u.ok=function(){return 0},u.a=-2,u.c=vE;var jZe=A(hr,"BasicExtendedMetaData/EClassExtendedMetaDataImpl",1023);T(oh,1,{},jAt),u.kk=function(){return this.a==(CM(),qF)&&Hnt(this,lwe(this.f,this.b)),this.a},u.lk=function(){return 0},u.mk=function(){return this.c==(CM(),qF)&&jj(this,hwe(this.f,this.b)),this.c},u.nk=function(){return!this.d&&Gnt(this,Gve(this.f,this.b)),this.d},u.be=function(){return this.e==vE&&Wnt(this,YIt(this.f,this.b)),this.e},u.ok=function(){return this.g==-2&&$nt(this,E1e(this.f,this.b)),this.g},u.e=vE,u.g=-2;var HZe=A(hr,"BasicExtendedMetaData/EDataTypeExtendedMetaDataImpl",oh);T(1022,1,{},dEt),u.b=!1,u.c=!1;var GZe=A(hr,"BasicExtendedMetaData/EPackageExtendedMetaDataImpl",1022);T(1025,1,{},HAt),u.c=-2,u.e=vE,u.f=vE;var WZe=A(hr,"BasicExtendedMetaData/EStructuralFeatureExtendedMetaDataImpl",1025);T(529,565,Zo,TD),u.pi=function(){return this.c},u.Rj=function(){return!1},u.zh=function(e,n){return n},u.c=0;var $Ze=A(hr,"EDataTypeEList",529),u_t=Sr(hr,"FeatureMap");T(90,529,{3:1,4:1,20:1,25:1,41:1,13:1,15:1,49:1,59:1,55:1,52:1,81:1,184:1,237:1,1630:1,64:1},_s),u.bd=function(e,n){fbe(this,e,a(n,75))},u.nc=function(e){return qme(this,a(e,75))},u.nh=function(e){use(this,a(e,75))},u.ri=function(e,n){return yne(this,a(e,75),n)},u.si=function(e,n){return Dst(this,a(e,75),n)},u.zh=function(e,n){return jye(this,e,a(n,75))},u.hd=function(e,n){return Hbe(this,e,a(n,75))},u.yi=function(e,n){return xne(this,a(e,75),n)},u.zi=function(e,n){return RTt(this,a(e,75),n)},u.Ai=function(e,n,i){return D1e(this,a(e,75),a(n,75),i)},u.Ch=function(e,n){return rX(this,e,a(n,75))},u.oc=function(e){var n,i,r,c,l,f,g,b,v;for(b=new Qv(e._b()),r=e.tc();r.hc();)if(i=a(r.ic(),75),c=i.nj(),Rm(this.e,c))(!c.xh()||!pV(this,c,i.lc())&&!WC(b,i))&&ni(b,i);else{for(v=gu(this.e.mg(),c),n=a(this.g,124),l=!0,f=0;f=0;)if(n=e[this.c],this.k.Bk(n.nj()))return this.j=this.f?n:n.lc(),this.i=-2,!0;return this.i=-1,this.g=-1,!1};var XZe=A(hr,"BasicFeatureMap/FeatureEIterator",377);T(601,377,kf,EW),u.Xj=function(){return!0};var ZZe=A(hr,"BasicFeatureMap/ResolvingFeatureEIterator",601);T(871,444,PO,eSt),u.Uh=function(){return this};var YZe=A(hr,"EContentsEList/1",871);T(872,444,PO,EEt),u.Xj=function(){return!1};var KZe=A(hr,"EContentsEList/2",872);T(870,260,IO,nSt),u.Zj=function(e){},u.hc=function(){return!1},u.Cc=function(){return!1};var JZe=A(hr,"EContentsEList/FeatureIteratorImpl/1",870);T(734,529,Zo,jrt),u.th=function(){this.a=!0},u.ui=function(){return this.a},u.ij=function(){var e;Dr(this),Xl(this.e)?(e=this.a,this.a=!1,Bi(this.e,new Jl(this.e,2,this.c,e,!1))):this.a=!1},u.a=!1;var QZe=A(hr,"EDataTypeEList/Unsettable",734);T(1566,529,Zo,hSt),u.xh=function(){return!0};var tYe=A(hr,"EDataTypeUniqueEList",1566);T(1567,734,Zo,fSt),u.xh=function(){return!0};var eYe=A(hr,"EDataTypeUniqueEList/Unsettable",1567);T(156,88,Zo,Hu),u.Qj=function(){return!0},u.zh=function(e,n){return G2(this,e,a(n,51))};var nYe=A(hr,"EObjectContainmentEList/Resolving",156);T(1026,493,Zo,lSt),u.Qj=function(){return!0},u.zh=function(e,n){return G2(this,e,a(n,51))};var iYe=A(hr,"EObjectContainmentEList/Unsettable/Resolving",1026);T(679,18,Zo,Mst),u.th=function(){this.a=!0},u.ui=function(){return this.a},u.ij=function(){var e;Dr(this),Xl(this.e)?(e=this.a,this.a=!1,Bi(this.e,new Jl(this.e,2,this.c,e,!1))):this.a=!1},u.a=!1;var rYe=A(hr,"EObjectContainmentWithInverseEList/Unsettable",679);T(1044,679,Zo,pTt),u.Qj=function(){return!0},u.zh=function(e,n){return G2(this,e,a(n,51))};var sYe=A(hr,"EObjectContainmentWithInverseEList/Unsettable/Resolving",1044);T(675,450,Zo,Hrt),u.th=function(){this.a=!0},u.ui=function(){return this.a},u.ij=function(){var e;Dr(this),Xl(this.e)?(e=this.a,this.a=!1,Bi(this.e,new Jl(this.e,2,this.c,e,!1))):this.a=!1},u.a=!1;var oYe=A(hr,"EObjectEList/Unsettable",675);T(376,450,Zo,uM),u.Qj=function(){return!0},u.zh=function(e,n){return G2(this,e,a(n,51))};var cYe=A(hr,"EObjectResolvingEList",376);T(1554,675,Zo,dSt),u.Qj=function(){return!0},u.zh=function(e,n){return G2(this,e,a(n,51))};var aYe=A(hr,"EObjectResolvingEList/Unsettable",1554);T(1495,1,{},Pg);var Kqt,uYe=A(hr,"EObjectValidator",1495);T(496,450,Zo,GD),u.Lj=function(){return this.d},u.Mj=function(){return this.b},u.qi=function(){return!0},u.Pj=function(){return!0},u.b=0;var lYe=A(hr,"EObjectWithInverseEList",496);T(1047,496,Zo,gTt),u.Oj=function(){return!0};var hYe=A(hr,"EObjectWithInverseEList/ManyInverse",1047);T(572,496,Zo,QW),u.th=function(){this.a=!0},u.ui=function(){return this.a},u.ij=function(){var e;Dr(this),Xl(this.e)?(e=this.a,this.a=!1,Bi(this.e,new Jl(this.e,2,this.c,e,!1))):this.a=!1},u.a=!1;var fYe=A(hr,"EObjectWithInverseEList/Unsettable",572);T(1046,572,Zo,mTt),u.Oj=function(){return!0};var dYe=A(hr,"EObjectWithInverseEList/Unsettable/ManyInverse",1046);T(680,496,Zo,Est),u.Qj=function(){return!0},u.zh=function(e,n){return G2(this,e,a(n,51))};var pYe=A(hr,"EObjectWithInverseResolvingEList",680);T(33,680,Zo,pn),u.Oj=function(){return!0};var gYe=A(hr,"EObjectWithInverseResolvingEList/ManyInverse",33);T(681,572,Zo,Sst),u.Qj=function(){return!0},u.zh=function(e,n){return G2(this,e,a(n,51))};var mYe=A(hr,"EObjectWithInverseResolvingEList/Unsettable",681);T(1045,681,Zo,bTt),u.Oj=function(){return!0};var bYe=A(hr,"EObjectWithInverseResolvingEList/Unsettable/ManyInverse",1045);T(1027,565,Zo),u.rh=function(){return(this.b&1792)==0},u.th=function(){this.b|=1},u.Nj=function(){return(this.b&4)!=0},u.qi=function(){return(this.b&40)!=0},u.Oj=function(){return(this.b&16)!=0},u.Pj=function(){return(this.b&8)!=0},u.Qj=function(){return(this.b&dw)!=0},u.Dj=function(){return(this.b&32)!=0},u.Rj=function(){return(this.b&oh)!=0},u.Li=function(e){return this.d?ikt(this.d,e):this.nj().jj().Li(e)},u.ui=function(){return this.b&2?(this.b&1)!=0:this.i!=0},u.xh=function(){return(this.b&128)!=0},u.ij=function(){var e;Dr(this),this.b&2&&(Xl(this.e)?(e=(this.b&1)!=0,this.b&=-2,Wn(this,new Jl(this.e,2,xr(this.e.mg(),this.nj()),e,!1))):this.b&=-2)},u.Bh=function(){return(this.b&1536)==0},u.b=0;var wYe=A(hr,"EcoreEList/Generic",1027);T(1028,1027,Zo,O4t),u.nj=function(){return this.a};var vYe=A(hr,"EcoreEList/Dynamic",1028);T(678,55,Nf,hT),u.Fh=function(e){return FL(this.a.a,e)};var _Ye=A(hr,"EcoreEMap/1",678);T(677,88,Zo,got),u.sh=function(e,n){h7(this.b,a(n,134))},u.uh=function(e,n){zPt(this.b)},u.vh=function(e,n){_q(this.b,a(n,134))},u.wh=function(e,n,i){_q(this.b,a(i,134)),zt(i)===zt(n)&&a(i,134).jh(Kte(a(n,134).kc())),h7(this.b,a(n,134))};var yYe=A(hr,"EcoreEMap/DelegateEObjectContainmentEList",677);T(1042,143,Vpt,qLt);var xYe=A(hr,"EcoreEMap/Unsettable",1042);T(1043,677,Zo,wTt),u.th=function(){this.a=!0},u.ui=function(){return this.a},u.ij=function(){var e;Dr(this),Xl(this.e)?(e=this.a,this.a=!1,Bi(this.e,new Jl(this.e,2,this.c,e,!1))):this.a=!1},u.a=!1;var MYe=A(hr,"EcoreEMap/Unsettable/UnsettableDelegateEObjectContainmentEList",1043);T(682,1,Cs,rkt),u.gc=function(e){ks(this,e)},u.hc=function(){return DIt(this)},u.ic=function(){var e;return DIt(this),e=this.b,this.b=null,e},u.jc=function(){this.a.jc()};var EYe=A(hr,"EcoreUtil/ProperContentIterator",682);T(1496,1495,{},_j);var Jqt,SYe=A(hr,"EcoreValidator",1496),Qqt,TYe=Sr(hr,"FeatureMapUtil/Validator");T(1095,1,{1632:1},jz),u.Bk=function(e){return!0};var CYe=A(hr,"FeatureMapUtil/1",1095);T(692,1,{1632:1},Wht),u.Bk=function(e){var n;return this.c==e?!0:(n=de(zi(this.a,e)),n==null?tve(this,e)?(Xkt(this.a,e,(me(),xE)),!0):(Xkt(this.a,e,(me(),Hm)),!1):n==(me(),xE))},u.e=!1;var ctt,AYe=A(hr,"FeatureMapUtil/BasicValidator",692);T(693,44,tx,Brt);var kYe=A(hr,"FeatureMapUtil/BasicValidator/Cache",693);T(455,41,{20:1,25:1,41:1,13:1,15:1,52:1,81:1,64:1},$5),u.bd=function(e,n){HDt(this.c,this.b,e,n)},u.nc=function(e){return Cve(this.c,this.b,e)},u.oc=function(e){return jT(this,e)},u.xj=function(e,n){return mht(this.c,this.b,e,n)},u.Dh=function(e){return G7(this.c,this.b,e,!1)},u.oh=function(){return FEt(this.c,this.b)},u.ph=function(){return Wte(this.c,this.b)},u.qh=function(e){return yae(this.c,this.b,e)},u.yj=function(e,n){return JSt(this,e,n)},u.Pb=function(){St(this)},u.pc=function(e){return pV(this.c,this.b,e)},u.qc=function(e){return rle(this.c,this.b,e)},u.cd=function(e){return G7(this.c,this.b,e,!0)},u.hj=function(e){return this},u.dd=function(e){return Pae(this.c,this.b,e)},u.Wb=function(){return Z9(this)},u.ui=function(){return!rP(this.c,this.b)},u.tc=function(){return Bue(this.c,this.b)},u.ed=function(){return Fue(this.c,this.b)},u.fd=function(e){return lfe(this.c,this.b,e)},u.gd=function(e){return H8t(this.c,this.b,e)},u.vc=function(e){return bve(this.c,this.b,e)},u.hd=function(e,n){return XNt(this.c,this.b,e,n)},u.Gc=function(e){E7(this.c,this.b),jT(this,a(e,15))},u._b=function(){return Dhe(this.c,this.b)},u.yc=function(){return qce(this.c,this.b)},u.zc=function(e){return Iae(this.c,this.b,e)},u.Ib=function(){var e,n;for(n=new Sp,n.a+="[",e=FEt(this.c,this.b);cq(e);)mo(n,zT(u7(e))),cq(e)&&(n.a+=Rc);return n.a+="]",n.a},u.ij=function(){E7(this.c,this.b)};var LYe=A(hr,"FeatureMapUtil/FeatureEList",455);T(575,32,r6,nV),u.Mh=function(e){return LC(this,e)},u.Rh=function(e){var n,i,r,c,l,f,g;switch(this.d){case 1:case 2:{if(l=e.Oh(),zt(l)===zt(this.c)&&LC(this,null)==e.Mh(null))return this.g=e.Nh(),e.Lh()==1&&(this.d=1),!0;break}case 3:{switch(c=e.Lh(),c){case 3:{if(l=e.Oh(),zt(l)===zt(this.c)&&LC(this,null)==e.Mh(null))return this.d=5,n=new Qv(2),ni(n,this.g),ni(n,e.Nh()),this.g=n,!0;break}}break}case 5:{switch(c=e.Lh(),c){case 3:{if(l=e.Oh(),zt(l)===zt(this.c)&&LC(this,null)==e.Mh(null))return i=a(this.g,13),i.nc(e.Nh()),!0;break}}break}case 4:{switch(c=e.Lh(),c){case 3:{if(l=e.Oh(),zt(l)===zt(this.c)&&LC(this,null)==e.Mh(null))return this.d=1,this.g=e.Nh(),!0;break}case 4:{if(l=e.Oh(),zt(l)===zt(this.c)&&LC(this,null)==e.Mh(null))return this.d=6,g=new Qv(2),ni(g,this.n),ni(g,e.Ph()),this.n=g,f=Y(Z(Gn,1),pi,22,15,[this.o,e.Qh()]),this.g=f,!0;break}}break}case 6:{switch(c=e.Lh(),c){case 4:{if(l=e.Oh(),zt(l)===zt(this.c)&&LC(this,null)==e.Mh(null))return i=a(this.n,13),i.nc(e.Ph()),f=a(this.g,37),r=dt(Gn,pi,22,f.length+1,15,1),Aa(f,0,r,0,f.length),r[f.length]=e.Qh(),this.g=r,!0;break}}break}}return!1};var PYe=A(hr,"FeatureMapUtil/FeatureENotificationImpl",575);T(501,455,{20:1,25:1,41:1,13:1,15:1,52:1,81:1,184:1,237:1,1630:1,64:1},LD),u.pk=function(e,n,i){return mht(this.c,e,n,i)},u.qk=function(e,n,i){return Iht(this.c,e,n,i)},u.rk=function(){return this},u.sk=function(e,n){return IP(this.c,e,n)},u.tk=function(e){return a(G7(this.c,this.b,e,!1),75).nj()},u.uk=function(e){return a(G7(this.c,this.b,e,!1),75).lc()},u.vk=function(){return this.a},u.wk=function(e){return!rP(this.c,e)},u.xk=function(e,n){ZX(this.c,e,n)},u.yk=function(e){return nPt(this.c,e)};var IYe=A(hr,"FeatureMapUtil/FeatureFeatureMap",501);T(1094,1,{81:1},mEt),u.hj=function(e){return G7(this.b,this.a,-1,e)},u.ui=function(){return!rP(this.b,this.a)},u.Gc=function(e){ZX(this.b,this.a,e)},u.ij=function(){E7(this.b,this.a)};var RYe=A(hr,"FeatureMapUtil/FeatureValue",1094),Ox,att,utt,Bx,tXt,vI=Sr(zO,"AnyType");T(603,54,rp,jG);var DYe=A(zO,"InvalidDatatypeValueException",603),ZF=Sr(zO,GUt),_I=Sr(zO,WUt),l_t=Sr(zO,$Ut),eXt,_c,h_t,Fw,nXt,iXt,rXt,sXt,oXt,cXt,aXt,uXt,lXt,hXt,fXt,GE,dXt,WE,yI,pXt,py,YF,KF,gXt,xI,MI;T(735,463,{95:1,91:1,87:1,51:1,42:1,92:1,746:1},vit),u.ug=function(e,n,i){switch(e){case 0:return i?(!this.c&&(this.c=new _s(this,0)),this.c):(!this.c&&(this.c=new _s(this,0)),this.c.b);case 1:return i?(!this.c&&(this.c=new _s(this,0)),a(Za(this.c,(fr(),Fw)),184)):(!this.c&&(this.c=new _s(this,0)),a(a(Za(this.c,(fr(),Fw)),184),237)).vk();case 2:return i?(!this.b&&(this.b=new _s(this,2)),this.b):(!this.b&&(this.b=new _s(this,2)),this.b.b)}return qu(this,e-ei(this.Rg()),Ve(this.j&2?(!this.k&&(this.k=new wf),this.k).pj():this.Rg(),e),n,i)},u.Dg=function(e,n,i){var r;switch(n){case 0:return!this.c&&(this.c=new _s(this,0)),kP(this.c,e,i);case 1:return(!this.c&&(this.c=new _s(this,0)),a(a(Za(this.c,(fr(),Fw)),184),64)).yj(e,i);case 2:return!this.b&&(this.b=new _s(this,2)),kP(this.b,e,i)}return r=a(Ve(this.j&2?(!this.k&&(this.k=new wf),this.k).pj():this.Rg(),n),61),r.aj().ej(this,Wct(this),n-ei(this.Rg()),e,i)},u.Fg=function(e){switch(e){case 0:return!!this.c&&this.c.i!=0;case 1:return!(!this.c&&(this.c=new _s(this,0)),a(Za(this.c,(fr(),Fw)),184)).Wb();case 2:return!!this.b&&this.b.i!=0}return $u(this,e-ei(this.Rg()),Ve(this.j&2?(!this.k&&(this.k=new wf),this.k).pj():this.Rg(),e))},u.Mg=function(e,n){switch(e){case 0:!this.c&&(this.c=new _s(this,0)),dL(this.c,n);return;case 1:(!this.c&&(this.c=new _s(this,0)),a(a(Za(this.c,(fr(),Fw)),184),237)).Gc(n);return;case 2:!this.b&&(this.b=new _s(this,2)),dL(this.b,n);return}Yu(this,e-ei(this.Rg()),Ve(this.j&2?(!this.k&&(this.k=new wf),this.k).pj():this.Rg(),e),n)},u.Rg=function(){return fr(),h_t},u.Ib=function(){var e;return this.j&4?nh(this):(e=new ul(nh(this)),e.a+=" (mixed: ",CT(e,this.c),e.a+=", anyAttribute: ",CT(e,this.b),e.a+=")",e.a)};var NYe=A(Xr,"AnyTypeImpl",735);T(604,463,{95:1,91:1,87:1,51:1,42:1,92:1,1707:1,604:1},Hz),u.ug=function(e,n,i){switch(e){case 0:return this.a;case 1:return this.b}return qu(this,e-ei((fr(),GE)),Ve(this.j&2?(!this.k&&(this.k=new wf),this.k).pj():GE,e),n,i)},u.Fg=function(e){switch(e){case 0:return this.a!=null;case 1:return this.b!=null}return $u(this,e-ei((fr(),GE)),Ve(this.j&2?(!this.k&&(this.k=new wf),this.k).pj():GE,e))},u.Mg=function(e,n){switch(e){case 0:Knt(this,hi(n));return;case 1:Qnt(this,hi(n));return}Yu(this,e-ei((fr(),GE)),Ve(this.j&2?(!this.k&&(this.k=new wf),this.k).pj():GE,e),n)},u.Rg=function(){return fr(),GE},u.Ib=function(){var e;return this.j&4?nh(this):(e=new ul(nh(this)),e.a+=" (data: ",mo(e,this.a),e.a+=", target: ",mo(e,this.b),e.a+=")",e.a)},u.a=null,u.b=null;var OYe=A(Xr,"ProcessingInstructionImpl",604);T(605,735,{95:1,91:1,87:1,51:1,42:1,92:1,746:1,1708:1,605:1},xxt),u.ug=function(e,n,i){switch(e){case 0:return i?(!this.c&&(this.c=new _s(this,0)),this.c):(!this.c&&(this.c=new _s(this,0)),this.c.b);case 1:return i?(!this.c&&(this.c=new _s(this,0)),a(Za(this.c,(fr(),Fw)),184)):(!this.c&&(this.c=new _s(this,0)),a(a(Za(this.c,(fr(),Fw)),184),237)).vk();case 2:return i?(!this.b&&(this.b=new _s(this,2)),this.b):(!this.b&&(this.b=new _s(this,2)),this.b.b);case 3:return!this.c&&(this.c=new _s(this,0)),hi(IP(this.c,(fr(),yI),!0));case 4:return Tst(this.a,(!this.c&&(this.c=new _s(this,0)),hi(IP(this.c,(fr(),yI),!0))));case 5:return this.a}return qu(this,e-ei((fr(),WE)),Ve(this.j&2?(!this.k&&(this.k=new wf),this.k).pj():WE,e),n,i)},u.Fg=function(e){switch(e){case 0:return!!this.c&&this.c.i!=0;case 1:return!(!this.c&&(this.c=new _s(this,0)),a(Za(this.c,(fr(),Fw)),184)).Wb();case 2:return!!this.b&&this.b.i!=0;case 3:return!this.c&&(this.c=new _s(this,0)),hi(IP(this.c,(fr(),yI),!0))!=null;case 4:return Tst(this.a,(!this.c&&(this.c=new _s(this,0)),hi(IP(this.c,(fr(),yI),!0))))!=null;case 5:return!!this.a}return $u(this,e-ei((fr(),WE)),Ve(this.j&2?(!this.k&&(this.k=new wf),this.k).pj():WE,e))},u.Mg=function(e,n){switch(e){case 0:!this.c&&(this.c=new _s(this,0)),dL(this.c,n);return;case 1:(!this.c&&(this.c=new _s(this,0)),a(a(Za(this.c,(fr(),Fw)),184),237)).Gc(n);return;case 2:!this.b&&(this.b=new _s(this,2)),dL(this.b,n);return;case 3:GAt(this,hi(n));return;case 4:GAt(this,_Tt(this.a,n));return;case 5:Jnt(this,a(n,140));return}Yu(this,e-ei((fr(),WE)),Ve(this.j&2?(!this.k&&(this.k=new wf),this.k).pj():WE,e),n)},u.Rg=function(){return fr(),WE};var BYe=A(Xr,"SimpleAnyTypeImpl",605);T(606,463,{95:1,91:1,87:1,51:1,42:1,92:1,1709:1,606:1},yxt),u.ug=function(e,n,i){switch(e){case 0:return i?(!this.a&&(this.a=new _s(this,0)),this.a):(!this.a&&(this.a=new _s(this,0)),this.a.b);case 1:return i?(!this.b&&(this.b=new lu((ye(),Ho),Dc,this,1)),this.b):(!this.b&&(this.b=new lu((ye(),Ho),Dc,this,1)),SL(this.b));case 2:return i?(!this.c&&(this.c=new lu((ye(),Ho),Dc,this,2)),this.c):(!this.c&&(this.c=new lu((ye(),Ho),Dc,this,2)),SL(this.c));case 3:return!this.a&&(this.a=new _s(this,0)),Za(this.a,(fr(),YF));case 4:return!this.a&&(this.a=new _s(this,0)),Za(this.a,(fr(),KF));case 5:return!this.a&&(this.a=new _s(this,0)),Za(this.a,(fr(),xI));case 6:return!this.a&&(this.a=new _s(this,0)),Za(this.a,(fr(),MI))}return qu(this,e-ei((fr(),py)),Ve(this.j&2?(!this.k&&(this.k=new wf),this.k).pj():py,e),n,i)},u.Dg=function(e,n,i){var r;switch(n){case 0:return!this.a&&(this.a=new _s(this,0)),kP(this.a,e,i);case 1:return!this.b&&(this.b=new lu((ye(),Ho),Dc,this,1)),_D(this.b,e,i);case 2:return!this.c&&(this.c=new lu((ye(),Ho),Dc,this,2)),_D(this.c,e,i);case 5:return!this.a&&(this.a=new _s(this,0)),JSt(Za(this.a,(fr(),xI)),e,i)}return r=a(Ve(this.j&2?(!this.k&&(this.k=new wf),this.k).pj():(fr(),py),n),61),r.aj().ej(this,Wct(this),n-ei((fr(),py)),e,i)},u.Fg=function(e){switch(e){case 0:return!!this.a&&this.a.i!=0;case 1:return!!this.b&&this.b.f!=0;case 2:return!!this.c&&this.c.f!=0;case 3:return!this.a&&(this.a=new _s(this,0)),!Z9(Za(this.a,(fr(),YF)));case 4:return!this.a&&(this.a=new _s(this,0)),!Z9(Za(this.a,(fr(),KF)));case 5:return!this.a&&(this.a=new _s(this,0)),!Z9(Za(this.a,(fr(),xI)));case 6:return!this.a&&(this.a=new _s(this,0)),!Z9(Za(this.a,(fr(),MI)))}return $u(this,e-ei((fr(),py)),Ve(this.j&2?(!this.k&&(this.k=new wf),this.k).pj():py,e))},u.Mg=function(e,n){switch(e){case 0:!this.a&&(this.a=new _s(this,0)),dL(this.a,n);return;case 1:!this.b&&(this.b=new lu((ye(),Ho),Dc,this,1)),NN(this.b,n);return;case 2:!this.c&&(this.c=new lu((ye(),Ho),Dc,this,2)),NN(this.c,n);return;case 3:!this.a&&(this.a=new _s(this,0)),St(Za(this.a,(fr(),YF))),!this.a&&(this.a=new _s(this,0)),jT(Za(this.a,YF),a(n,13));return;case 4:!this.a&&(this.a=new _s(this,0)),St(Za(this.a,(fr(),KF))),!this.a&&(this.a=new _s(this,0)),jT(Za(this.a,KF),a(n,13));return;case 5:!this.a&&(this.a=new _s(this,0)),St(Za(this.a,(fr(),xI))),!this.a&&(this.a=new _s(this,0)),jT(Za(this.a,xI),a(n,13));return;case 6:!this.a&&(this.a=new _s(this,0)),St(Za(this.a,(fr(),MI))),!this.a&&(this.a=new _s(this,0)),jT(Za(this.a,MI),a(n,13));return}Yu(this,e-ei((fr(),py)),Ve(this.j&2?(!this.k&&(this.k=new wf),this.k).pj():py,e),n)},u.Rg=function(){return fr(),py},u.Ib=function(){var e;return this.j&4?nh(this):(e=new ul(nh(this)),e.a+=" (mixed: ",CT(e,this.a),e.a+=")",e.a)};var FYe=A(Xr,"XMLTypeDocumentRootImpl",606);T(1626,638,{95:1,91:1,87:1,430:1,139:1,51:1,103:1,42:1,92:1,142:1,107:1,108:1,1710:1},VS),u.Zg=function(e,n){switch(e.Ni()){case 7:case 8:case 9:case 10:case 16:case 22:case 23:case 24:case 25:case 26:case 32:case 33:case 34:case 36:case 37:case 44:case 45:case 50:case 51:case 53:case 55:case 56:case 57:case 58:case 60:case 61:case 4:return n==null?null:Yc(n);case 19:case 28:case 29:case 35:case 38:case 39:case 41:case 46:case 52:case 54:case 5:return hi(n);case 6:return Xee(a(n,173));case 12:case 47:case 49:case 11:return P7t(this,e,n);case 13:return n==null?null:S_e(a(n,216));case 15:case 14:return n==null?null:tse(lt(Yt(n)));case 17:return r8t((fr(),n));case 18:return r8t(n);case 21:case 20:return n==null?null:ese(a(n,126).a);case 27:return Zee(a(n,173));case 30:return CRt((fr(),a(n,15)));case 31:return CRt(a(n,15));case 40:return Fee((fr(),n));case 42:return s8t((fr(),n));case 43:return s8t(n);case 59:case 48:return Bee((fr(),n));default:throw K(new yn(mE+e.be()+zm))}},u.$g=function(e){var n,i,r,c,l;switch(e.G==-1&&(e.G=(i=Xu(e),i?Hp(i.bh(),e):-1)),e.G){case 0:return n=new vit,n;case 1:return r=new Hz,r;case 2:return c=new xxt,c;case 3:return l=new yxt,l;default:throw K(new yn(HY+e.zb+zm))}},u._g=function(e,n){var i,r,c,l,f,g,b,v,M,k,R,O,$,W,nt,rt;switch(e.Ni()){case 5:case 52:case 4:return n;case 6:return lde(n);case 8:case 7:return n==null?null:Zpe(n);case 9:return n==null?null:AL(Au((r=Hc(n,!0),r.length>0&&r.charCodeAt(0)==43?r.substr(1,r.length-1):r),-128,127)<<24>>24);case 10:return n==null?null:AL(Au((c=Hc(n,!0),c.length>0&&c.charCodeAt(0)==43?c.substr(1,c.length-1):c),-128,127)<<24>>24);case 11:return hi(Dm(this,(fr(),rXt),n));case 12:return hi(Dm(this,(fr(),sXt),n));case 13:return n==null?null:new Sit(Hc(n,!0));case 15:case 14:return yme(n);case 16:return hi(Dm(this,(fr(),oXt),n));case 17:return jIt((fr(),n));case 18:return jIt(n);case 28:case 29:case 35:case 38:case 39:case 41:case 54:case 19:return Hc(n,!0);case 21:case 20:return Ime(n);case 22:return hi(Dm(this,(fr(),cXt),n));case 23:return hi(Dm(this,(fr(),aXt),n));case 24:return hi(Dm(this,(fr(),uXt),n));case 25:return hi(Dm(this,(fr(),lXt),n));case 26:return hi(Dm(this,(fr(),hXt),n));case 27:return Xfe(n);case 30:return HIt((fr(),n));case 31:return HIt(n);case 32:return n==null?null:Xt(Au((M=Hc(n,!0),M.length>0&&M.charCodeAt(0)==43?M.substr(1,M.length-1):M),Vs,qi));case 33:return n==null?null:new _1((k=Hc(n,!0),k.length>0&&k.charCodeAt(0)==43?k.substr(1,k.length-1):k));case 34:return n==null?null:Xt(Au((R=Hc(n,!0),R.length>0&&R.charCodeAt(0)==43?R.substr(1,R.length-1):R),Vs,qi));case 36:return n==null?null:Jg(q7((O=Hc(n,!0),O.length>0&&O.charCodeAt(0)==43?O.substr(1,O.length-1):O)));case 37:return n==null?null:Jg(q7(($=Hc(n,!0),$.length>0&&$.charCodeAt(0)==43?$.substr(1,$.length-1):$)));case 40:return qhe((fr(),n));case 42:return GIt((fr(),n));case 43:return GIt(n);case 44:return n==null?null:new _1((W=Hc(n,!0),W.length>0&&W.charCodeAt(0)==43?W.substr(1,W.length-1):W));case 45:return n==null?null:new _1((nt=Hc(n,!0),nt.length>0&&nt.charCodeAt(0)==43?nt.substr(1,nt.length-1):nt));case 46:return Hc(n,!1);case 47:return hi(Dm(this,(fr(),fXt),n));case 59:case 48:return Vhe((fr(),n));case 49:return hi(Dm(this,(fr(),dXt),n));case 50:return n==null?null:FM(Au((rt=Hc(n,!0),rt.length>0&&rt.charCodeAt(0)==43?rt.substr(1,rt.length-1):rt),OO,32767)<<16>>16);case 51:return n==null?null:FM(Au((l=Hc(n,!0),l.length>0&&l.charCodeAt(0)==43?l.substr(1,l.length-1):l),OO,32767)<<16>>16);case 53:return hi(Dm(this,(fr(),pXt),n));case 55:return n==null?null:FM(Au((f=Hc(n,!0),f.length>0&&f.charCodeAt(0)==43?f.substr(1,f.length-1):f),OO,32767)<<16>>16);case 56:return n==null?null:FM(Au((g=Hc(n,!0),g.length>0&&g.charCodeAt(0)==43?g.substr(1,g.length-1):g),OO,32767)<<16>>16);case 57:return n==null?null:Jg(q7((b=Hc(n,!0),b.length>0&&b.charCodeAt(0)==43?b.substr(1,b.length-1):b)));case 58:return n==null?null:Jg(q7((v=Hc(n,!0),v.length>0&&v.charCodeAt(0)==43?v.substr(1,v.length-1):v)));case 60:return n==null?null:Xt(Au((i=Hc(n,!0),i.length>0&&i.charCodeAt(0)==43?i.substr(1,i.length-1):i),Vs,qi));case 61:return n==null?null:Xt(Au(Hc(n,!0),Vs,qi));default:throw K(new yn(mE+e.be()+zm))}};var mXt,f_t,bXt,d_t,UYe=A(Xr,"XMLTypeFactoryImpl",1626);T(530,248,{95:1,91:1,87:1,139:1,174:1,51:1,207:1,103:1,42:1,92:1,142:1,248:1,107:1,108:1,613:1,1639:1,530:1},h4t),u.N=!1,u.O=!1;var wXt=!1,zYe=A(Xr,"XMLTypePackageImpl",530);T(1569,1,{743:1},qy),u.mj=function(){return Mht(),CXt};var jYe=A(Xr,"XMLTypePackageImpl/1",1569);T(1578,1,wi,KR),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var HYe=A(Xr,"XMLTypePackageImpl/10",1578);T(1579,1,wi,JR),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var GYe=A(Xr,"XMLTypePackageImpl/11",1579);T(1580,1,wi,Gz),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var WYe=A(Xr,"XMLTypePackageImpl/12",1580);T(1581,1,wi,QR),u.Li=function(e){return zb(e)},u.Mi=function(e){return dt(To,wt,315,e,7,1)};var $Ye=A(Xr,"XMLTypePackageImpl/13",1581);T(1582,1,wi,Xy),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var VYe=A(Xr,"XMLTypePackageImpl/14",1582);T(1583,1,wi,O3),u.Li=function(e){return ct(e,15)},u.Mi=function(e){return dt(Sl,uw,15,e,0,1)};var qYe=A(Xr,"XMLTypePackageImpl/15",1583);T(1584,1,wi,Wz),u.Li=function(e){return ct(e,15)},u.Mi=function(e){return dt(Sl,uw,15,e,0,1)};var XYe=A(Xr,"XMLTypePackageImpl/16",1584);T(1585,1,wi,t8),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var ZYe=A(Xr,"XMLTypePackageImpl/17",1585);T(1586,1,wi,e8),u.Li=function(e){return ct(e,126)},u.Mi=function(e){return dt(ME,wt,126,e,0,1)};var YYe=A(Xr,"XMLTypePackageImpl/18",1586);T(1587,1,wi,qS),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var KYe=A(Xr,"XMLTypePackageImpl/19",1587);T(1570,1,wi,n8),u.Li=function(e){return ct(e,746)},u.Mi=function(e){return dt(vI,te,746,e,0,1)};var JYe=A(Xr,"XMLTypePackageImpl/2",1570);T(1588,1,wi,XS),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var QYe=A(Xr,"XMLTypePackageImpl/20",1588);T(1589,1,wi,Yk),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var tKe=A(Xr,"XMLTypePackageImpl/21",1589);T(1590,1,wi,ZS),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var eKe=A(Xr,"XMLTypePackageImpl/22",1590);T(1591,1,wi,$z),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var nKe=A(Xr,"XMLTypePackageImpl/23",1591);T(1592,1,wi,i8),u.Li=function(e){return ct(e,173)},u.Mi=function(e){return dt(Da,wt,173,e,0,2)};var iKe=A(Xr,"XMLTypePackageImpl/24",1592);T(1593,1,wi,YS),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var rKe=A(Xr,"XMLTypePackageImpl/25",1593);T(1594,1,wi,r8),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var sKe=A(Xr,"XMLTypePackageImpl/26",1594);T(1595,1,wi,Kk),u.Li=function(e){return ct(e,15)},u.Mi=function(e){return dt(Sl,uw,15,e,0,1)};var oKe=A(Xr,"XMLTypePackageImpl/27",1595);T(1596,1,wi,Vz),u.Li=function(e){return ct(e,15)},u.Mi=function(e){return dt(Sl,uw,15,e,0,1)};var cKe=A(Xr,"XMLTypePackageImpl/28",1596);T(1597,1,wi,s8),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var aKe=A(Xr,"XMLTypePackageImpl/29",1597);T(1571,1,wi,Y0),u.Li=function(e){return ct(e,604)},u.Mi=function(e){return dt(ZF,te,1707,e,0,1)};var uKe=A(Xr,"XMLTypePackageImpl/3",1571);T(1598,1,wi,o8),u.Li=function(e){return ct(e,21)},u.Mi=function(e){return dt(Io,wt,21,e,0,1)};var lKe=A(Xr,"XMLTypePackageImpl/30",1598);T(1599,1,wi,c8),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var hKe=A(Xr,"XMLTypePackageImpl/31",1599);T(1600,1,wi,qz),u.Li=function(e){return ct(e,149)},u.Mi=function(e){return dt(Gm,wt,149,e,0,1)};var fKe=A(Xr,"XMLTypePackageImpl/32",1600);T(1601,1,wi,a8),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var dKe=A(Xr,"XMLTypePackageImpl/33",1601);T(1602,1,wi,Xz),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var pKe=A(Xr,"XMLTypePackageImpl/34",1602);T(1603,1,wi,Zz),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var gKe=A(Xr,"XMLTypePackageImpl/35",1603);T(1604,1,wi,K0),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var mKe=A(Xr,"XMLTypePackageImpl/36",1604);T(1605,1,wi,Jk),u.Li=function(e){return ct(e,15)},u.Mi=function(e){return dt(Sl,uw,15,e,0,1)};var bKe=A(Xr,"XMLTypePackageImpl/37",1605);T(1606,1,wi,Qk),u.Li=function(e){return ct(e,15)},u.Mi=function(e){return dt(Sl,uw,15,e,0,1)};var wKe=A(Xr,"XMLTypePackageImpl/38",1606);T(1607,1,wi,t5),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var vKe=A(Xr,"XMLTypePackageImpl/39",1607);T(1572,1,wi,KS),u.Li=function(e){return ct(e,605)},u.Mi=function(e){return dt(_I,te,1708,e,0,1)};var _Ke=A(Xr,"XMLTypePackageImpl/4",1572);T(1608,1,wi,Zy),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var yKe=A(Xr,"XMLTypePackageImpl/40",1608);T(1609,1,wi,cs),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var xKe=A(Xr,"XMLTypePackageImpl/41",1609);T(1610,1,wi,JS),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var MKe=A(Xr,"XMLTypePackageImpl/42",1610);T(1611,1,wi,e5),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var EKe=A(Xr,"XMLTypePackageImpl/43",1611);T(1612,1,wi,_v),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var SKe=A(Xr,"XMLTypePackageImpl/44",1612);T(1613,1,wi,Yz),u.Li=function(e){return ct(e,168)},u.Mi=function(e){return dt(Wm,wt,168,e,0,1)};var TKe=A(Xr,"XMLTypePackageImpl/45",1613);T(1614,1,wi,n5),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var CKe=A(Xr,"XMLTypePackageImpl/46",1614);T(1615,1,wi,u8),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var AKe=A(Xr,"XMLTypePackageImpl/47",1615);T(1616,1,wi,zh),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var kKe=A(Xr,"XMLTypePackageImpl/48",1616);T(1617,1,wi,Kz),u.Li=function(e){return ct(e,168)},u.Mi=function(e){return dt(Wm,wt,168,e,0,1)};var LKe=A(Xr,"XMLTypePackageImpl/49",1617);T(1573,1,wi,Jz),u.Li=function(e){return ct(e,606)},u.Mi=function(e){return dt(l_t,te,1709,e,0,1)};var PKe=A(Xr,"XMLTypePackageImpl/5",1573);T(1618,1,wi,l8),u.Li=function(e){return ct(e,149)},u.Mi=function(e){return dt(Gm,wt,149,e,0,1)};var IKe=A(Xr,"XMLTypePackageImpl/50",1618);T(1619,1,wi,Qz),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var RKe=A(Xr,"XMLTypePackageImpl/51",1619);T(1620,1,wi,h8),u.Li=function(e){return ct(e,21)},u.Mi=function(e){return dt(Io,wt,21,e,0,1)};var DKe=A(Xr,"XMLTypePackageImpl/52",1620);T(1574,1,wi,tj),u.Li=function(e){return Es(e)},u.Mi=function(e){return dt(At,wt,2,e,6,1)};var NKe=A(Xr,"XMLTypePackageImpl/6",1574);T(1575,1,wi,ej),u.Li=function(e){return ct(e,173)},u.Mi=function(e){return dt(Da,wt,173,e,0,2)};var OKe=A(Xr,"XMLTypePackageImpl/7",1575);T(1576,1,wi,nj),u.Li=function(e){return Ub(e)},u.Mi=function(e){return dt(ho,wt,434,e,8,1)};var BKe=A(Xr,"XMLTypePackageImpl/8",1576);T(1577,1,wi,J0),u.Li=function(e){return ct(e,192)},u.Mi=function(e){return dt(ux,wt,192,e,0,1)};var FKe=A(Xr,"XMLTypePackageImpl/9",1577),af,t1,CA,JF,tt;T(40,54,rp,ri);var UKe=A(qp,"RegEx/ParseException",40);T(730,1,{},jh),u.Ck=function(e){return ei*16)throw K(new ri(ai((Kn(),nUt))));i=i*16+c}while(!0);if(this.a!=125)throw K(new ri(ai((Kn(),iUt))));if(i>_E)throw K(new ri(ai((Kn(),rUt))));e=i}else{if(c=0,this.c!=0||(c=t0(this.a))<0)throw K(new ri(ai((Kn(),Vp))));if(i=c,Ci(this),this.c!=0||(c=t0(this.a))<0)throw K(new ri(ai((Kn(),Vp))));i=i*16+c,e=i}break;case 117:if(r=0,Ci(this),this.c!=0||(r=t0(this.a))<0)throw K(new ri(ai((Kn(),Vp))));if(n=r,Ci(this),this.c!=0||(r=t0(this.a))<0)throw K(new ri(ai((Kn(),Vp))));if(n=n*16+r,Ci(this),this.c!=0||(r=t0(this.a))<0)throw K(new ri(ai((Kn(),Vp))));if(n=n*16+r,Ci(this),this.c!=0||(r=t0(this.a))<0)throw K(new ri(ai((Kn(),Vp))));n=n*16+r,e=n;break;case 118:if(Ci(this),this.c!=0||(r=t0(this.a))<0)throw K(new ri(ai((Kn(),Vp))));if(n=r,Ci(this),this.c!=0||(r=t0(this.a))<0)throw K(new ri(ai((Kn(),Vp))));if(n=n*16+r,Ci(this),this.c!=0||(r=t0(this.a))<0)throw K(new ri(ai((Kn(),Vp))));if(n=n*16+r,Ci(this),this.c!=0||(r=t0(this.a))<0)throw K(new ri(ai((Kn(),Vp))));if(n=n*16+r,Ci(this),this.c!=0||(r=t0(this.a))<0)throw K(new ri(ai((Kn(),Vp))));if(n=n*16+r,Ci(this),this.c!=0||(r=t0(this.a))<0)throw K(new ri(ai((Kn(),Vp))));if(n=n*16+r,n>_E)throw K(new ri(ai((Kn(),"parser.descappe.4"))));e=n;break;case 65:case 90:case 122:throw K(new ri(ai((Kn(),sUt))))}return e},u.Ek=function(e){var n;switch(e){case 100:n=(this.e&32)==32?X1("Nd",!0):(Ai(),QF);break;case 68:n=(this.e&32)==32?X1("Nd",!1):(Ai(),v_t);break;case 119:n=(this.e&32)==32?X1("IsWord",!0):(Ai(),qE);break;case 87:n=(this.e&32)==32?X1("IsWord",!1):(Ai(),y_t);break;case 115:n=(this.e&32)==32?X1("IsSpace",!0):(Ai(),Fx);break;case 83:n=(this.e&32)==32?X1("IsSpace",!1):(Ai(),__t);break;default:throw K(new sc(szt+e.toString(16)))}return n},u.Fk=function(e){var n,i,r,c,l,f,g,b,v,M,k,R;for(this.b=1,Ci(this),n=null,this.c==0&&this.a==94?(Ci(this),e?M=(Ai(),Ai(),++Ar,new Eu(5)):(n=(Ai(),Ai(),++Ar,new Eu(4)),jc(n,0,_E),M=(++Ar,new Eu(4)))):M=(Ai(),Ai(),++Ar,new Eu(4)),c=!0;(R=this.c)!=1&&!(R==0&&this.a==93&&!c);){if(c=!1,i=this.a,r=!1,R==10)switch(i){case 100:case 68:case 119:case 87:case 115:case 83:ow(M,this.Ek(i)),r=!0;break;case 105:case 73:case 99:case 67:i=this.Vk(M,i),i<0&&(r=!0);break;case 112:case 80:if(k=Tlt(this,i),!k)throw K(new ri(ai((Kn(),tK))));ow(M,k),r=!0;break;default:i=this.Dk()}else if(R==20){if(f=cM(this.i,58,this.d),f<0)throw K(new ri(ai((Kn(),zpt))));if(g=!0,bo(this.i,this.d)==94&&(++this.d,g=!1),l=$h(this.i,this.d,f),b=R5t(l,g,(this.e&512)==512),!b)throw K(new ri(ai((Kn(),KFt))));if(ow(M,b),r=!0,f+1>=this.j||bo(this.i,f+1)!=93)throw K(new ri(ai((Kn(),zpt))));this.d=f+2}if(Ci(this),!r)if(this.c!=0||this.a!=45)jc(M,i,i);else{if(Ci(this),(R=this.c)==1)throw K(new ri(ai((Kn(),AO))));R==0&&this.a==93?(jc(M,i,i),jc(M,45,45)):(v=this.a,R==10&&(v=this.Dk()),Ci(this),jc(M,i,v))}(this.e&oh)==oh&&this.c==0&&this.a==44&&Ci(this)}if(this.c==1)throw K(new ri(ai((Kn(),AO))));return n&&(c4(n,M),M=n),__(M),o4(M),this.b=0,Ci(this),M},u.Gk=function(){var e,n,i,r;for(i=this.Fk(!1);(r=this.c)!=7;)if(e=this.a,r==0&&(e==45||e==38)||r==4){if(Ci(this),this.c!=9)throw K(new ri(ai((Kn(),QFt))));if(n=this.Fk(!1),r==4)ow(i,n);else if(e==45)c4(i,n);else if(e==38)C7t(i,n);else throw K(new sc("ASSERT"))}else throw K(new ri(ai((Kn(),tUt))));return Ci(this),i},u.Hk=function(){var e,n;return e=this.a-48,n=(Ai(),Ai(),++Ar,new $$(12,null,e)),!this.g&&(this.g=new nd),Cn(this.g,new l9(e)),Ci(this),n},u.Ik=function(){return Ci(this),Ai(),yXt},u.Jk=function(){return Ci(this),Ai(),_Xt},u.Kk=function(){throw K(new ri(ai((Kn(),tl))))},u.Lk=function(){throw K(new ri(ai((Kn(),tl))))},u.Mk=function(){return Ci(this),Hle()},u.Nk=function(){return Ci(this),Ai(),MXt},u.Ok=function(){return Ci(this),Ai(),SXt},u.Pk=function(){var e;if(this.d>=this.j||((e=bo(this.i,this.d++))&65504)!=64)throw K(new ri(ai((Kn(),XFt))));return Ci(this),Ai(),Ai(),++Ar,new ud(0,e-64)},u.Qk=function(){return Ci(this),u_e()},u.Rk=function(){return Ci(this),Ai(),TXt},u.Sk=function(){var e;return e=(Ai(),Ai(),++Ar,new ud(0,105)),Ci(this),e},u.Tk=function(){return Ci(this),Ai(),EXt},u.Uk=function(){return Ci(this),Ai(),xXt},u.Vk=function(e,n){return this.Dk()},u.Wk=function(){return Ci(this),Ai(),b_t},u.Xk=function(){var e,n,i,r,c;if(this.d+1>=this.j)throw K(new ri(ai((Kn(),$Ft))));if(r=-1,n=null,e=bo(this.i,this.d),49<=e&&e<=57){if(r=e-48,!this.g&&(this.g=new nd),Cn(this.g,new l9(r)),++this.d,bo(this.i,this.d)!=41)throw K(new ri(ai((Kn(),p0))));++this.d}else switch(e==63&&--this.d,Ci(this),n=Vht(this),n.e){case 20:case 21:case 22:case 23:break;case 8:if(this.c!=7)throw K(new ri(ai((Kn(),p0))));break;default:throw K(new ri(ai((Kn(),VFt))))}if(Ci(this),c=Cm(this),i=null,c.e==2){if(c.ol()!=2)throw K(new ri(ai((Kn(),qFt))));i=c.kl(1),c=c.kl(0)}if(this.c!=7)throw K(new ri(ai((Kn(),p0))));return Ci(this),Ai(),Ai(),++Ar,new oLt(r,n,c,i)},u.Yk=function(){return Ci(this),Ai(),w_t},u.Zk=function(){var e;if(Ci(this),e=WD(24,Cm(this)),this.c!=7)throw K(new ri(ai((Kn(),p0))));return Ci(this),e},u.$k=function(){var e;if(Ci(this),e=WD(20,Cm(this)),this.c!=7)throw K(new ri(ai((Kn(),p0))));return Ci(this),e},u._k=function(){var e;if(Ci(this),e=WD(22,Cm(this)),this.c!=7)throw K(new ri(ai((Kn(),p0))));return Ci(this),e},u.al=function(){var e,n,i,r,c;for(e=0,i=0,n=-1;this.d=this.j)throw K(new ri(ai((Kn(),Fpt))));if(n==45){for(++this.d;this.d=this.j)throw K(new ri(ai((Kn(),Fpt))))}if(n==58){if(++this.d,Ci(this),r=XCt(Cm(this),e,i),this.c!=7)throw K(new ri(ai((Kn(),p0))));Ci(this)}else if(n==41)++this.d,Ci(this),r=XCt(Cm(this),e,i);else throw K(new ri(ai((Kn(),WFt))));return r},u.bl=function(){var e;if(Ci(this),e=WD(21,Cm(this)),this.c!=7)throw K(new ri(ai((Kn(),p0))));return Ci(this),e},u.cl=function(){var e;if(Ci(this),e=WD(23,Cm(this)),this.c!=7)throw K(new ri(ai((Kn(),p0))));return Ci(this),e},u.dl=function(){var e,n;if(Ci(this),e=this.f++,n=w$(Cm(this),e),this.c!=7)throw K(new ri(ai((Kn(),p0))));return Ci(this),n},u.el=function(){var e;if(Ci(this),e=w$(Cm(this),0),this.c!=7)throw K(new ri(ai((Kn(),p0))));return Ci(this),e},u.fl=function(e){return Ci(this),this.c==5?(Ci(this),OD(e,(Ai(),Ai(),++Ar,new qb(9,e)))):OD(e,(Ai(),Ai(),++Ar,new qb(3,e)))},u.gl=function(e){var n;return Ci(this),n=(Ai(),Ai(),++Ar,new UT(2)),this.c==5?(Ci(this),r0(n,kA),r0(n,e)):(r0(n,e),r0(n,kA)),n},u.hl=function(e){return Ci(this),this.c==5?(Ci(this),Ai(),Ai(),++Ar,new qb(9,e)):(Ai(),Ai(),++Ar,new qb(3,e))},u.a=0,u.b=0,u.c=0,u.d=0,u.e=0,u.f=1,u.g=null,u.j=0;var zKe=A(qp,"RegEx/RegexParser",730);T(1564,730,{},Txt),u.Ck=function(e){return!1},u.Dk=function(){return oht(this)},u.Ek=function(e){return tE(e)},u.Fk=function(e){return lOt(this)},u.Gk=function(){throw K(new ri(ai((Kn(),tl))))},u.Hk=function(){throw K(new ri(ai((Kn(),tl))))},u.Ik=function(){throw K(new ri(ai((Kn(),tl))))},u.Jk=function(){throw K(new ri(ai((Kn(),tl))))},u.Kk=function(){return Ci(this),tE(67)},u.Lk=function(){return Ci(this),tE(73)},u.Mk=function(){throw K(new ri(ai((Kn(),tl))))},u.Nk=function(){throw K(new ri(ai((Kn(),tl))))},u.Ok=function(){throw K(new ri(ai((Kn(),tl))))},u.Pk=function(){return Ci(this),tE(99)},u.Qk=function(){throw K(new ri(ai((Kn(),tl))))},u.Rk=function(){throw K(new ri(ai((Kn(),tl))))},u.Sk=function(){return Ci(this),tE(105)},u.Tk=function(){throw K(new ri(ai((Kn(),tl))))},u.Uk=function(){throw K(new ri(ai((Kn(),tl))))},u.Vk=function(e,n){return ow(e,tE(n)),-1},u.Wk=function(){return Ci(this),Ai(),Ai(),++Ar,new ud(0,94)},u.Xk=function(){throw K(new ri(ai((Kn(),tl))))},u.Yk=function(){return Ci(this),Ai(),Ai(),++Ar,new ud(0,36)},u.Zk=function(){throw K(new ri(ai((Kn(),tl))))},u.$k=function(){throw K(new ri(ai((Kn(),tl))))},u._k=function(){throw K(new ri(ai((Kn(),tl))))},u.al=function(){throw K(new ri(ai((Kn(),tl))))},u.bl=function(){throw K(new ri(ai((Kn(),tl))))},u.cl=function(){throw K(new ri(ai((Kn(),tl))))},u.dl=function(){var e;if(Ci(this),e=w$(Cm(this),0),this.c!=7)throw K(new ri(ai((Kn(),p0))));return Ci(this),e},u.el=function(){throw K(new ri(ai((Kn(),tl))))},u.fl=function(e){return Ci(this),OD(e,(Ai(),Ai(),++Ar,new qb(3,e)))},u.gl=function(e){var n;return Ci(this),n=(Ai(),Ai(),++Ar,new UT(2)),r0(n,e),r0(n,kA),n},u.hl=function(e){return Ci(this),Ai(),Ai(),++Ar,new qb(3,e)};var gy=null,$E=null,jKe=A(qp,"RegEx/ParserForXMLSchema",1564);T(112,1,yE,Ba),u.il=function(e){throw K(new sc("Not supported."))},u.jl=function(){return-1},u.kl=function(e){return null},u.ll=function(){return null},u.ml=function(e){},u.nl=function(e){},u.ol=function(){return 0},u.Ib=function(){return this.pl(0)},u.pl=function(e){return this.e==11?".":""},u.e=0;var p_t,VE,AA,vXt,g_t,Uw=null,QF,ltt=null,m_t,kA,htt=null,b_t,w_t,v_t,__t,y_t,_Xt,Fx,yXt,xXt,MXt,EXt,qE,SXt,TXt,Ar=0,X3e=A(qp,"RegEx/Token",112);T(130,112,{3:1,130:1,112:1},Eu),u.pl=function(e){var n,i,r;if(this.e==4)if(this==m_t)i=".";else if(this==QF)i="\\d";else if(this==qE)i="\\w";else if(this==Fx)i="\\s";else{for(r=new Sp,r.a+="[",n=0;n0&&(r.a+=","),this.b[n]===this.b[n+1]?mo(r,PP(this.b[n])):(mo(r,PP(this.b[n])),r.a+="-",mo(r,PP(this.b[n+1])));r.a+="]",i=r.a}else if(this==v_t)i="\\D";else if(this==y_t)i="\\W";else if(this==__t)i="\\S";else{for(r=new Sp,r.a+="[^",n=0;n0&&(r.a+=","),this.b[n]===this.b[n+1]?mo(r,PP(this.b[n])):(mo(r,PP(this.b[n])),r.a+="-",mo(r,PP(this.b[n+1])));r.a+="]",i=r.a}return i},u.a=!1,u.c=!1;var HKe=A(qp,"RegEx/RangeToken",130);T(528,1,{528:1},l9),u.a=0;var GKe=A(qp,"RegEx/RegexParser/ReferencePosition",528);T(527,1,{3:1,527:1},K3t),u.Fb=function(e){var n;return e==null||!ct(e,527)?!1:(n=a(e,527),le(this.b,n.b)&&this.a==n.a)},u.Hb=function(){return z1(this.b+"/"+eht(this.a))},u.Ib=function(){return this.c.pl(this.a)},u.a=0;var WKe=A(qp,"RegEx/RegularExpression",527);T(195,112,yE,ud),u.jl=function(){return this.a},u.pl=function(e){var n,i;switch(this.e){case 0:switch(this.a){case 124:case 42:case 43:case 63:case 40:case 41:case 46:case 91:case 123:case 92:i="\\"+JW(this.a&qr);break;case 12:i="\\f";break;case 10:i="\\n";break;case 13:i="\\r";break;case 9:i="\\t";break;case 27:i="\\e";break;default:this.a>=ao?(n="0"+(this.a>>>0).toString(16),i="\\v"+$h(n,n.length-6,n.length)):i=""+JW(this.a&qr)}break;case 8:this==b_t||this==w_t?i=""+JW(this.a&qr):i="\\"+JW(this.a&qr);break;default:i=null}return i},u.a=0;var $Ke=A(qp,"RegEx/Token/CharToken",195);T(283,112,yE,qb),u.kl=function(e){return this.a},u.ml=function(e){this.b=e},u.nl=function(e){this.c=e},u.ol=function(){return 1},u.pl=function(e){var n;if(this.e==3)if(this.c<0&&this.b<0)n=this.a.pl(e)+"*";else if(this.c==this.b)n=this.a.pl(e)+"{"+this.c+"}";else if(this.c>=0&&this.b>=0)n=this.a.pl(e)+"{"+this.c+","+this.b+"}";else if(this.c>=0&&this.b<0)n=this.a.pl(e)+"{"+this.c+",}";else throw K(new sc("Token#toString(): CLOSURE "+this.c+Rc+this.b));else if(this.c<0&&this.b<0)n=this.a.pl(e)+"*?";else if(this.c==this.b)n=this.a.pl(e)+"{"+this.c+"}?";else if(this.c>=0&&this.b>=0)n=this.a.pl(e)+"{"+this.c+","+this.b+"}?";else if(this.c>=0&&this.b<0)n=this.a.pl(e)+"{"+this.c+",}?";else throw K(new sc("Token#toString(): NONGREEDYCLOSURE "+this.c+Rc+this.b));return n},u.b=0,u.c=0;var VKe=A(qp,"RegEx/Token/ClosureToken",283);T(731,112,yE,yot),u.kl=function(e){return e==0?this.a:this.b},u.ol=function(){return 2},u.pl=function(e){var n;return this.b.e==3&&this.b.kl(0)==this.a?n=this.a.pl(e)+"+":this.b.e==9&&this.b.kl(0)==this.a?n=this.a.pl(e)+"+?":n=this.a.pl(e)+(""+this.b.pl(e)),n};var qKe=A(qp,"RegEx/Token/ConcatToken",731);T(1562,112,yE,oLt),u.kl=function(e){if(e==0)return this.d;if(e==1)return this.b;throw K(new sc("Internal Error: "+e))},u.ol=function(){return this.b?2:1},u.pl=function(e){var n;return this.c>0?n="(?("+this.c+")":this.a.e==8?n="(?("+this.a+")":n="(?"+this.a,this.b?n+=this.d+"|"+this.b+")":n+=this.d+")",n},u.c=0;var XKe=A(qp,"RegEx/Token/ConditionToken",1562);T(1563,112,yE,SAt),u.kl=function(e){return this.b},u.ol=function(){return 1},u.pl=function(e){return"(?"+(this.a==0?"":eht(this.a))+(this.c==0?"":eht(this.c))+":"+this.b.pl(e)+")"},u.a=0,u.c=0;var ZKe=A(qp,"RegEx/Token/ModifierToken",1563);T(732,112,yE,kot),u.kl=function(e){return this.a},u.ol=function(){return 1},u.pl=function(e){var n;switch(n=null,this.e){case 6:this.b==0?n="(?:"+this.a.pl(e)+")":n="("+this.a.pl(e)+")";break;case 20:n="(?="+this.a.pl(e)+")";break;case 21:n="(?!"+this.a.pl(e)+")";break;case 22:n="(?<="+this.a.pl(e)+")";break;case 23:n="(?"+this.a.pl(e)+")"}return n},u.b=0;var YKe=A(qp,"RegEx/Token/ParenToken",732);T(474,112,{3:1,112:1,474:1},$$),u.ll=function(){return this.b},u.pl=function(e){return this.e==12?"\\"+this.a:g0e(this.b)},u.a=0;var KKe=A(qp,"RegEx/Token/StringToken",474);T(427,112,yE,UT),u.il=function(e){r0(this,e)},u.kl=function(e){return a(pm(this.a,e),112)},u.ol=function(){return this.a?this.a.a.c.length:0},u.pl=function(e){var n,i,r,c,l;if(this.e==1){if(this.a.a.c.length==2)n=a(pm(this.a,0),112),i=a(pm(this.a,1),112),i.e==3&&i.kl(0)==n?c=n.pl(e)+"+":i.e==9&&i.kl(0)==n?c=n.pl(e)+"+?":c=n.pl(e)+(""+i.pl(e));else{for(l=new Sp,r=0;r=this.c.b:this.a<=this.c.b},u.Cc=function(){return this.b>0},u.Dc=function(){return this.b},u.Fc=function(){return this.b-1},u.jc=function(){throw K(new Tp(dzt))},u.a=0,u.b=0;var iJe=A(s1t,"ExclusiveRange/RangeIterator",230),el=mM(LO,"C"),Gn=mM(C4,"I"),Ol=mM(rE,"Z"),A0=mM(A4,"J"),Da=mM(E4,"B"),Os=mM(S4,"D"),zw=mM(T4,"F"),my=mM(k4,"S"),Z3e=Sr("org.eclipse.elk.core.labels","ILabelManager"),x_t=Sr(qs,"DiagnosticChain"),M_t=Sr(zUt,"ResourceSet"),E_t=A(qs,"InvocationTargetException",null),AXt=(y9(),Zce),kXt=kXt=r1e;xue(tit),$ue("permProps",[[[GO,WO],[$O,"gecko1_8"]],[[GO,WO],[$O,"ie10"]],[[GO,WO],[$O,"ie8"]],[[GO,WO],[$O,"ie9"]],[[GO,WO],[$O,"safari"]]]),kXt(null,"elk",null)}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],3:[function(p,m,_){"use strict";function S(P,U){if(!(P instanceof U))throw new TypeError("Cannot call a class as a function")}function y(P,U){if(!P)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return U&&(typeof U=="object"||typeof U=="function")?U:P}function I(P,U){if(typeof U!="function"&&U!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof U);P.prototype=Object.create(U&&U.prototype,{constructor:{value:P,enumerable:!1,writable:!0,configurable:!0}}),U&&(Object.setPrototypeOf?Object.setPrototypeOf(P,U):P.__proto__=U)}var N=p("./elk-api.js").default,B=function(P){I(U,P);function U(){var j=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};S(this,U);var V=Object.assign({},j),et=!1;try{p.resolve("webworker-threads"),et=!0}catch{}if(j.workerUrl)if(et){var Q=p("webworker-threads"),X=Q.Worker;V.workerFactory=function(xt){return new X(xt)}}else console.warn(`Web worker requested but 'webworker-threads' package not installed. +(()=>{var CVt=Object.create;var bPe=Object.defineProperty;var AVt=Object.getOwnPropertyDescriptor;var PVt=Object.getOwnPropertyNames;var LVt=Object.getPrototypeOf,kVt=Object.prototype.hasOwnProperty;var AD=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(n,r)=>(typeof require<"u"?require:n)[r]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var Ve=(s,n)=>()=>(s&&(n=s(s=0)),n);var Ed=(s,n)=>()=>(n||s((n={exports:{}}).exports,n),n.exports),Oy=(s,n)=>{for(var r in n)bPe(s,r,{get:n[r],enumerable:!0})},RVt=(s,n,r,c)=>{if(n&&typeof n=="object"||typeof n=="function")for(let u of PVt(n))!kVt.call(s,u)&&u!==r&&bPe(s,u,{get:()=>n[u],enumerable:!(c=AVt(n,u))||c.enumerable});return s};var Uut=(s,n,r)=>(r=s!=null?CVt(LVt(s)):{},RVt(n||!s||!s.__esModule?bPe(r,"default",{value:s,enumerable:!0}):r,s));var Wj,FVt,Vae,UVt,Gut,wPe=Ve(()=>{Wj=globalThis,FVt=globalThis.document||{},Vae=globalThis.process||{},UVt=globalThis.console,Gut=globalThis.navigator||{}});function Wae(s){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&process.versions?.electron)return!0;let n=typeof navigator<"u"&&navigator.userAgent,r=s||n;return!!(r&&r.indexOf("Electron")>=0)}var vPe=Ve(()=>{});function D1(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Wae()}var _Pe=Ve(()=>{vPe()});function yPe(s){return!s&&!D1()?"Node":Wae(s)?"Electron":(s||Gut.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var jut=Ve(()=>{_Pe();vPe();wPe()});var xPe,VL=Ve(()=>{wPe();_Pe();jut();xPe="4.1.2"});function PD(s,n){if(!s)throw new Error(n||"Assertion failed")}var EPe=Ve(()=>{});function SPe(s){if(!s)return 0;let n;switch(typeof s){case"number":n=s;break;case"object":n=s.logLevel||s.priority||0;break;default:return 0}return PD(Number.isFinite(n)&&n>=0),n}function $ut(s){let{logLevel:n,message:r}=s;s.logLevel=SPe(n);let c=s.args?Array.from(s.args):[];for(;c.length&&c.shift()!==r;);switch(typeof n){case"string":case"function":r!==void 0&&c.unshift(r),s.message=n;break;case"object":Object.assign(s,n);break;default:}typeof s.message=="function"&&(s.message=s.message());let u=typeof s.message;return PD(u==="string"||u==="object"),Object.assign(s,{args:c},s.opts)}var Vut=Ve(()=>{EPe()});var WL,Hae,Wut=Ve(()=>{Vut();WL=()=>{},Hae=class{constructor({level:n=0}={}){this.userData={},this._onceCache=new Set,this._level=n}set level(n){this.setLevel(n)}get level(){return this.getLevel()}setLevel(n){return this._level=n,this}getLevel(){return this._level}warn(n,...r){return this._log("warn",0,n,r,{once:!0})}error(n,...r){return this._log("error",0,n,r)}log(n,r,...c){return this._log("log",n,r,c)}info(n,r,...c){return this._log("info",n,r,c)}once(n,r,...c){return this._log("once",n,r,c,{once:!0})}_log(n,r,c,u,d={}){let b=$ut({logLevel:r,message:c,args:this._buildArgs(r,c,u),opts:d});return this._createLogFunction(n,b,d)}_buildArgs(n,r,c){return[n,r,...c]}_createLogFunction(n,r,c){if(!this._shouldLog(r.logLevel))return WL;let u=this._getOnceTag(c.tag??r.tag??r.message);if((c.once||r.once)&&u!==void 0){if(this._onceCache.has(u))return WL;this._onceCache.add(u)}return this._emit(n,r)}_shouldLog(n){return this.getLevel()>=SPe(n)}_getOnceTag(n){if(n!==void 0)try{return typeof n=="string"?n:String(n)}catch{return}}}});function GVt(s){try{let n=window[s],r="__storage_test__";return n.setItem(r,r),n.removeItem(r),n}catch{return null}}var qae,Hut=Ve(()=>{qae=class{constructor(n,r,c="sessionStorage"){this.storage=GVt(c),this.id=n,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(n){if(Object.assign(this.config,n),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let n={};if(this.storage){let r=this.storage.getItem(this.id);n=r?JSON.parse(r):{}}return Object.assign(this.config,n),this}}});function qut(s){let n;return s<10?n=`${s.toFixed(2)}ms`:s<100?n=`${s.toFixed(1)}ms`:s<1e3?n=`${s.toFixed(0)}ms`:n=`${(s/1e3).toFixed(2)}s`,n}function Xut(s,n=8){let r=Math.max(n-s.length,0);return`${" ".repeat(r)}${s}`}var Yut=Ve(()=>{});function Zut(s){return typeof s!="string"?s:(s=s.toUpperCase(),Xae[s]||Xae.WHITE)}function Kut(s,n,r){return!D1&&typeof s=="string"&&(n&&(s=`\x1B[${Zut(n)}m${s}\x1B[39m`),r&&(s=`\x1B[${Zut(r)+jVt}m${s}\x1B[49m`)),s}var Xae,jVt,Jut=Ve(()=>{VL();(function(s){s[s.BLACK=30]="BLACK",s[s.RED=31]="RED",s[s.GREEN=32]="GREEN",s[s.YELLOW=33]="YELLOW",s[s.BLUE=34]="BLUE",s[s.MAGENTA=35]="MAGENTA",s[s.CYAN=36]="CYAN",s[s.WHITE=37]="WHITE",s[s.BRIGHT_BLACK=90]="BRIGHT_BLACK",s[s.BRIGHT_RED=91]="BRIGHT_RED",s[s.BRIGHT_GREEN=92]="BRIGHT_GREEN",s[s.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",s[s.BRIGHT_BLUE=94]="BRIGHT_BLUE",s[s.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",s[s.BRIGHT_CYAN=96]="BRIGHT_CYAN",s[s.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Xae||(Xae={}));jVt=10});function Qut(s,n=["constructor"]){let r=Object.getPrototypeOf(s),c=Object.getOwnPropertyNames(r),u=s;for(let d of c){let b=u[d];typeof b=="function"&&(n.find(w=>d===w)||(u[d]=b.bind(s)))}}var eft=Ve(()=>{});var Yae,Fy,MPe=Ve(()=>{VL();Yae=class{getHighResolutionTimer(){let n;if(D1()&&Wj.performance)n=Wj?.performance?.now?.();else if("hrtime"in Vae){let r=Vae?.hrtime?.();n=r[0]*1e3+r[1]/1e6}else n=Date.now();return n}getMemoryUsageMB(){let r=Wj?.performance?.memory?.usedJSHeapSize;return r==null?null:Math.trunc(r/1024/1024)}},Fy=new Yae;globalThis.Probe=Yae;globalThis.probe=Fy});function $Vt(s,n,r){if(typeof n=="string"){let c=r.time?Xut(qut(r.total)):"";n=r.time?`${s}: ${c} ${n}`:`${s}: ${n}`,n=Kut(n,r.color,r.background)}return n}function VVt(s){for(let n in s)for(let r in s[n])return r||"untitled";return"empty"}var LD,TPe,ng,CPe=Ve(()=>{VL();Wut();Hut();Yut();Jut();eft();EPe();MPe();LD={debug:D1()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},TPe={enabled:!0,level:0},ng=class extends Hae{constructor({id:n}={id:""}){super({level:0}),this.VERSION=xPe,this._startTs=Fy.getHighResolutionTimer(),this._deltaTs=Fy.getHighResolutionTimer(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=n,this.userData={},this._storage=new qae(`__probe-${this.id}__`,{[this.id]:TPe}),this.timeStamp(`${this.id} started`),Qut(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((Fy.getHighResolutionTimer()-this._startTs).toPrecision(10))}getDelta(){return Number((Fy.getHighResolutionTimer()-this._deltaTs).toPrecision(10))}set priority(n){this.level=n}get priority(){return this.level}getPriority(){return this.level}enable(n=!0){return this._updateConfiguration({enabled:n}),this}setLevel(n){return this._updateConfiguration({level:n}),this}get(n){return this._getConfiguration()[n]}set(n,r){this._updateConfiguration({[n]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(n,r){if(!n)throw new Error(r||"Assertion failed")}warn(n,...r){return this._log("warn",0,n,r,{method:LD.warn,once:!0})}error(n,...r){return this._log("error",0,n,r,{method:LD.error})}deprecated(n,r){return this.warn(`\`${n}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(n,r){return this.error(`\`${n}\` has been removed. Use \`${r}\` instead`)}probe(n,r,...c){let u=Fy.getMemoryUsageMB();if(u!==null){let d=`${u}MB `;typeof r=="function"?r=()=>`${d}${r()}`:typeof r=="string"&&(r=`${d}${r}`)}return this._log("log",n,r,c,{method:LD.log,time:!0,once:!0})}log(n,r,...c){return this._log("log",n,r,c,{method:LD.debug})}info(n,r,...c){return this._log("info",n,r,c,{method:console.info})}once(n,r,...c){return this._log("once",n,r,c,{method:LD.debug||LD.info,once:!0})}table(n,r,c){return r?this._log("table",n,r,c&&[c]||[],{method:console.table||WL,tag:VVt(r)}):WL}time(n,r){return this._log("time",n,r,[],{method:console.time?console.time:console.info})}timeEnd(n,r){return this._log("time",n,r,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(n,r){return this._log("time",n,r,[],{method:console.timeStamp||WL})}group(n,r,c={collapsed:!1}){let u=(c.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",n,r,[],{method:u})}groupCollapsed(n,r,c={}){return this.group(n,r,Object.assign({},c,{collapsed:!0}))}groupEnd(n){return this._log("groupEnd",n,"",[],{method:console.groupEnd||WL})}withGroup(n,r,c){this.group(n,r)();try{c()}finally{this.groupEnd(n)()}}trace(){console.trace&&console.trace()}_shouldLog(n){return this.isEnabled()&&super._shouldLog(n)}_emit(n,r){let c=r.method;PD(c),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=Fy.getHighResolutionTimer();let u=$Vt(this.id,r.message,r);return c.bind(console,u,...r.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(TPe),this._storage.config[this.id]}_updateConfiguration(n){let r=this._storage.config[this.id]||{...TPe};this._storage.setConfiguration({[this.id]:{...r,...n}})}};ng.VERSION=xPe});var tft=Ve(()=>{MPe();globalThis.probe||(globalThis.probe=Fy)});var DDn,Hj=Ve(()=>{CPe();CPe();tft();DDn=new ng({id:"@probe.gl/log"})});function Zj(){let s;if(typeof window<"u"&&window.performance)s=window.performance.now();else if(typeof process<"u"&&process.hrtime){let n=process.hrtime();s=n[0]*1e3+n[1]/1e6}else s=Date.now();return s}var VPe=Ve(()=>{});var qL,WPe=Ve(()=>{VPe();qL=class{constructor(n,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=n,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(n){return this.sampleSize=n,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(n){return this._count+=n,this._samples++,this._checkSampling(),this}subtractCount(n){return this._count-=n,this._samples++,this._checkSampling(),this}addTime(n){return this._time+=n,this.lastTiming=n,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Zj(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Zj()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}});var yb,pft=Ve(()=>{WPe();yb=class{constructor(n){this.stats={},this.id=n.id,this.stats={},this._initializeStats(n.stats),Object.seal(this)}get(n,r="count"){return this._getOrCreate({name:n,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let n of Object.values(this.stats))n.reset();return this}forEach(n){for(let r of Object.values(this.stats))n(r)}getTable(){let n={};return this.forEach(r=>{n[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),n}_initializeStats(n=[]){n.forEach(r=>this._getOrCreate(r))}_getOrCreate(n){let{name:r,type:c}=n,u=this.stats[r];return u||(n instanceof qL?u=n:u=new qL(r,c),this.stats[r]=u),u}}});var Kj=Ve(()=>{pft();WPe();VPe()});function Vft(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Wft(s){return Array.isArray(s)?s.length===0||typeof s[0]=="number":!1}function r$(s){return Vft(s)||Wft(s)}var Hft=Ve(()=>{});var sLe=Ve(()=>{Hft()});function ND(s){let n=s.split(""),r=0,c=0,u=!1,d=!1,b=!1;for(;r0){if(w==="/"&&_==="*"){n[r]=" ",n[r+1]=" ",c++,r+=2;continue}if(w==="*"&&_==="/"){n[r]=" ",n[r+1]=" ",c--,r+=2;continue}w!==` +`&&w!=="\r"&&(n[r]=" "),r++;continue}if(w==='"'){d=!0,r++;continue}if(w==="/"&&_==="/"){n[r]=" ",n[r+1]=" ",u=!0,r+=2;continue}if(w==="/"&&_==="*"){n[r]=" ",n[r+1]=" ",c=1,r+=2;continue}r++}return n.join("")}function YL(s,n){let r=ND(s),c=[];for(let u of n){u.lastIndex=0;let d;for(d=u.exec(r);d;){let b=u===n[0],w=d.index,_=d[0].length;c.push({match:s.slice(w,w+_),index:w,length:_,bindingToken:d[b?1:2],groupToken:d[b?2:1],accessDeclaration:d[3]?.trim(),name:d[4]}),d=u.exec(r)}}return c.sort((u,d)=>u.index-d.index)}function hLe(s,n,r){let c=YL(s,n);if(!c.length)return s;let u="",d=0;for(let b of c)u+=s.slice(d,b.index),u+=r(b),d=b.index+b.length;return u+=s.slice(d),u}function dLe(s){return/@binding\(\s*auto\s*\)/.test(ND(s))}function aht(s,n){return YL(s,n===OD||n===lce?aHt:n).find(c=>c.bindingToken==="auto")}var N1,xb,OD,lce,oht,aHt,uce=Ve(()=>{N1="(?:var<\\s*(uniform|storage(?:\\s*,\\s*[A-Za-z_][A-Za-z0-9_]*)?)\\s*>|var)\\s+([A-Za-z_][A-Za-z0-9_]*)",xb="\\s*",OD=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${xb}@group\\(\\s*(\\d+)\\s*\\)${xb}${N1}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${xb}@binding\\(\\s*(auto|\\d+)\\s*\\)${xb}${N1}`,"g")],lce=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${xb}@group\\(\\s*(\\d+)\\s*\\)${xb}${N1}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${xb}@binding\\(\\s*(auto|\\d+)\\s*\\)${xb}${N1}`,"g")],oht=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)${xb}@group\\(\\s*(\\d+)\\s*\\)${xb}${N1}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${xb}@binding\\(\\s*(\\d+)\\s*\\)${xb}${N1}`,"g")],aHt=[new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${N1}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)\\s*${N1}`,"g"),new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${N1}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${N1}`,"g")]});function hce(s,n={}){let r=cht(s),c=cHt(r);if(!c)return null;let u=lHt(r,c);if(!u)return null;let d=fHt(r,c,u);if(!d)return null;if(n.scanVertexAttributes===!1)return{attributes:[],bindings:d};let b=uHt(r,c);if(!b)return null;let w=mHt(r,c,u,b,n.vertexEntryPoint);return w?{attributes:w,bindings:d}:null}function cht(s){let n=ND(s),r=/[A-Za-z_][A-Za-z0-9_]*|(?:0[xX][0-9A-Fa-f]+|\d+)|[@(){}<>\[\]:,;=]/g,c=[],u=r.exec(n);for(;u;)c.push({value:u[0],index:u.index}),u=r.exec(n);return c}function cHt(s){let n=[],r=0;for(let c of s){if(c.value==="}"&&r===0)return null;n.push(r),c.value==="{"?r++:c.value==="}"&&r--}return r===0?n:null}function lHt(s,n){let r=new Map;for(let c=0;c");if(Z<0)return null;let H=dce(s.slice(M+1,Z),",");if(!H)return null;L=H.map(fce),M=Z+1}let I=s[M]?.value;if(!a$(I)||s[M+1]?.value!==":")return null;let D=fht(s,n,M+2,";");if(D<0||D===M+2)return null;let F=mLe(fce(s.slice(M+2,D)),r);if(!F)return null;let O=hHt({name:I,group:x,location:T,addressSpace:L,resourceType:F}),z=`${x}:${T}`;if(!O||u.has(z)||d.has(I))return null;c.push(O),u.add(z),d.add(I),b=D}return gHt(c),c.sort((b,w)=>b.group-w.group||b.location-w.location||b.name.localeCompare(w.name))}function hHt(s){let{name:n,group:r,location:c,addressSpace:u,resourceType:d}=s,b={name:n,group:r,location:c};if(u[0]==="uniform"&&u.length===1)return{...b,type:"uniform"};if(u[0]==="storage"&&u.length<=2){let w=u[1]||"read";return w==="read"?{...b,type:"read-only-storage"}:w==="read_write"?{...b,type:"storage"}:null}return u.length>0?null:d==="sampler"||d==="sampler_comparison"?{...b,type:"sampler",...d==="sampler_comparison"?{samplerType:"comparison"}:{}}:d==="texture_external"?{...b,type:"external-texture"}:dHt(b,d)||pHt(b,d)}function dHt(s,n){let r=/^texture_storage_(1d|2d|2d_array|3d)<([A-Za-z0-9_]+),(read|write|read_write)>$/.exec(n);if(!r)return null;let c={read:"read-only",write:"write-only",read_write:"read-write"}[r[3]];return{...s,type:"storage",format:r[2],access:c,viewDimension:gLe(r[1])}}function pHt(s,n){let r=/^texture_(multisampled_)?(1d|2d|2d_array|cube|cube_array|3d)<(f32|i32|u32)>$/.exec(n);if(r){if(r[1]&&r[2]!=="2d")return null;let u={f32:"float",i32:"sint",u32:"uint"}[r[3]];return{...s,type:"texture",viewDimension:gLe(r[2]),sampleType:u,multisampled:!!r[1]}}let c=/^texture_depth_(multisampled_)?(2d|2d_array|cube|cube_array)$/.exec(n);return!c||c[1]&&c[2]!=="2d"?null:{...s,type:"texture",viewDimension:gLe(c[2]),sampleType:"depth",multisampled:!!c[1]}}function gHt(s){for(let n of s){if(n.type!=="sampler"||n.samplerType||!n.name.endsWith("Sampler"))continue;let r=n.name.slice(0,-7);s.find(u=>u.type==="texture"&&u.name===r&&u.group===n.group)?.sampleType==="depth"&&(n.samplerType="non-filtering")}}function mHt(s,n,r,c,u){let d=bHt(s,n);if(!d)return null;let b=d.filter(I=>I.vertex),w=u?b.find(I=>I.name===u):b.length===1?b[0]:void 0;if(!w)return b.length===0&&!u?[]:null;let _=dce(w.parameters,",");if(!_)return null;let x=[],T=new Set,M=new Set,L=new Set;for(let I of _)if(I.length>0&&!lht({declaration:I,aliases:r,structures:c,attributes:x,attributeLocations:T,attributeNames:M,visitedStructures:L}))return null;return x.sort((I,D)=>I.location-D.location||I.name.localeCompare(D.name))}function bHt(s,n){let r=[],c=new Set;for(let u=0;u0&&!lht({...s,declaration:F}))return!1;return w.delete(L),!0}function mLe(s,n,r=new Set){let c=cht(s),u="";for(let d of c){let b=n.get(d.value);if(!b){u+=wHt(d.value);continue}if(r.has(d.value))return null;let w=new Set(r);w.add(d.value);let _=mLe(b,n,w);if(!_)return null;u+=_}return u}function wHt(s){let n=/^(vec[234]|mat[234]x[234])([fiuh])$/.exec(s);if(!n)return s;let r={f:"f32",i:"i32",u:"u32",h:"f16"}[n[2]];return`${n[1]}<${r}>`}function vHt(s){return/^(?:i32|u32|f32|f16|vec[234]<(?:i32|u32|f32|f16)>)$/.test(s)?s:null}function pLe(s,n){let r;for(let c=0;cr.value==="@"&&s[c+1]?.value===n)}function gLe(s){return s.replace("_","-")}function bLe(s,n,r,c){let u=0;for(let d=n;d":"<","]":"[","}":"{"};for(let w=0;wu[x]===0)){r.push(s.slice(c,w)),c=w+1;continue}if(_ in u)u[_]++;else if(_ in b){let x=b[_];if(u[x]--,u[x]<0)return null}}return d.every(w=>u[w]===0)?(r.push(s.slice(c)),r):null}function _Ht(s,n){let r=dce(s,n);return r&&r.length===2?r[0].length:-1}function fht(s,n,r,c){for(let u=r;u=0;c--)if(s[c].value===";"&&n[c]===0||s[c].value==="}"&&n[c]===1)return c+1;return 0}function yHt(s){for(let n=s.length-1;n>=0;n--)if(a$(s[n].value))return s[n].value;return null}function fce(s){return s.map(n=>n.value).join("")}function a$(s){return!!(s&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(s))}var wLe=Ve(()=>{uce()});function T3(s,n){if(!s){let r=new Error(n||"shadertools: assertion failed.");throw Error.captureStackTrace?.(r,T3),r}}var pce=Ve(()=>{});function pht(s){let n={};for(let[r,c]of Object.entries(s))n[r]=xHt(c);return n}function xHt(s){let n=dht(s);if(n!=="object")return{value:s,...vLe[n],type:n};if(typeof s=="object")return s?s.type!==void 0?{...s,...vLe[s.type],type:s.type}:s.value===void 0?{type:"object",value:s}:(n=dht(s.value),{...s,...vLe[n],type:n}):{type:"object",value:null};throw new Error("props")}function dht(s){return Array.isArray(s)||ArrayBuffer.isView(s)?"array":typeof s}var vLe,ght=Ve(()=>{vLe={number:{type:"number",validate(s,n){return Number.isFinite(s)&&typeof n=="object"&&(n.max===void 0||s<=n.max)&&(n.min===void 0||s>=n.min)}},array:{type:"array",validate(s,n){return Array.isArray(s)||ArrayBuffer.isView(s)}}}});var mht,bht,wht=Ve(()=>{mht=`#ifdef MODULE_LOGDEPTH + logdepth_adjustPosition(gl_Position); +#endif +`,bht=`#ifdef MODULE_MATERIAL + fragColor = material_filterColor(fragColor); +#endif + +#ifdef MODULE_LIGHTING + fragColor = lighting_filterColor(fragColor); +#endif + +#ifdef MODULE_FOG + fragColor = fog_filterColor(fragColor); +#endif + +#ifdef MODULE_PICKING + fragColor = picking_filterHighlightColor(fragColor); + fragColor = picking_filterPickingColor(fragColor); +#endif + +#ifdef MODULE_LOGDEPTH + logdepth_setFragDepth(); +#endif +`});function yht(s){let n={vertex:{},fragment:{}};for(let r in s){let c=s[r],u=SHt(r);typeof c=="string"&&(c={order:0,injection:c}),n[u][r]=c}return n}function SHt(s){let n=s.slice(0,2);switch(n){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(n)}}function l$(s,n,r,c=!1,u="glsl",d={}){let b=n==="vertex";for(let w in r){let _=r[w];_.sort((T,M)=>T.order-M.order),_Le.length=_.length;for(let T=0,M=_.length;TT+x));break;case"vs:#main-end":(u==="wgsl"||b)&&(s=u==="wgsl"?gce(s,"vertex",x,"end",d.vertex):s.replace(_ht,T=>x+T));break;case"fs:#decl":(u==="wgsl"||!b)&&(s=s.replace(c$,x));break;case"fs:#main-start":(u==="wgsl"||!b)&&(s=u==="wgsl"?gce(s,"fragment",x,"start",d.fragment):s.replace(vht,T=>T+x));break;case"fs:#main-end":(u==="wgsl"||!b)&&(s=u==="wgsl"?gce(s,"fragment",x,"end",d.fragment):s.replace(_ht,T=>x+T));break;default:s=s.replace(w,T=>T+x)}}return s=s.replace(c$,""),c&&(s=s.replace(/\}\s*$/,w=>w+EHt[n])),s}function gce(s,n,r,c,u){let d=MHt(s,n,u);if(!d)return s;if(c==="start"){let b=d.openBraceIndex+1;return`${s.slice(0,b)} +${r}${s.slice(b)}`}return`${s.slice(0,d.closeBraceIndex)}${r}${s.slice(d.closeBraceIndex)}`}function MHt(s,n,r){let c=n==="vertex"?"@vertex":"@fragment",u=s.indexOf(c);if(u<0)return null;let d=r?s.search(new RegExp(`\\bfn\\s+${THt(r)}\\s*\\(`)):s.indexOf("fn",u);if(d<0)return null;let b=s.indexOf("{",d);if(b<0)return null;let w=0;for(let _=b;_{wht();EHt={vertex:mht,fragment:bht},vht=/void\s+main\s*\([^)]*\)\s*\{\n?/,_ht=/}\n?[^{}]*$/,_Le=[],c$="__LUMA_INJECT_DECLARATIONS__"});function FD(s){s.map(n=>CHt(n))}function CHt(s){if(s.instance)return;FD(s.dependencies||[]);let{propTypes:n={},deprecations:r=[],inject:c={}}=s,u={normalizedInjections:yht(c),parsedDeprecations:AHt(r)};n&&(u.propValidators=pht(n)),s.instance=u;let d={};n&&(d=Object.entries(n).reduce((b,[w,_])=>{let x=_?.value;return x&&(b[w]=x),b},{})),s.defaultUniforms={...s.defaultUniforms,...d}}function xLe(s,n,r){s.deprecations?.forEach(c=>{c.regex?.test(n)&&(c.deprecated?r.deprecated(c.old,c.new)():r.removed(c.old,c.new)())})}function AHt(s){return s.forEach(n=>{switch(n.type){case"function":n.regex=new RegExp(`\\b${n.old}\\(`);break;default:n.regex=new RegExp(`${n.type} ${n.old};`)}}),s}var mce=Ve(()=>{ght();yLe()});function ZL(s){FD(s);let n={},r={};xht({modules:s,level:0,moduleMap:n,moduleDepth:r});let c=Object.keys(r).sort((u,d)=>r[d]-r[u]).map(u=>n[u]);return FD(c),c}function xht(s){let{modules:n,level:r,moduleMap:c,moduleDepth:u}=s;if(r>=5)throw new Error("Possible loop in shader dependency graph");for(let d of n)c[d.name]=d,(u[d.name]===void 0||u[d.name]{mce()});var Qt,rg=Ve(()=>{Hj();Qt=new ng({id:"luma.gl"})});function PHt(s,n){return s!=null?!!s:n!==void 0?n!=="production":!1}function LHt(){return PHt(Qt.get("debug"),kHt())}function kHt(){let s=globalThis.process;if(s?.env)return s.env.NODE_ENV}var bce,SLe=Ve(()=>{rg();bce={id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,featureLevel:void 0,optionalFeatures:[],xrCompatible:!1,createCanvasContext:void 0,webgl:{},onError:(s,n)=>{},onResize:(s,n)=>{let[r,c]=s.getDevicePixelSize();Qt.log(1,`${s} resized => ${r}x${c}px`)()},onPositionChange:(s,n)=>{let[r,c]=s.getPosition();Qt.log(1,`${s} repositioned => ${r},${c}`)()},onVisibilityChange:s=>Qt.log(1,`${s} Visibility changed ${s.isVisible}`)(),onDevicePixelRatioChange:(s,n)=>Qt.log(1,`${s} DPR changed ${n.oldRatio} => ${s.devicePixelRatio}`)(),debug:LHt(),debugGPUTime:!1,debugShaders:Qt.get("debug-shaders")||void 0,debugFramebuffers:!!Qt.get("debug-framebuffers"),debugFactories:!!Qt.get("debug-factories"),debugWebGL:!!Qt.get("debug-webgl"),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0}});function DHt(s,n){let r=s.stats,c=!1;for(let _ of n)r[_]||(s.get(_),c=!0);let u=Object.keys(r).length,d=Eht.get(s);if(!c&&d?.orderedStatNames===n&&d.statCount===u)return;let b={},w=Sht.get(n);w||(w=new Set(n),Sht.set(n,w));for(let _ of n)r[_]&&(b[_]=r[_]);for(let[_,x]of Object.entries(r))w.has(_)||(b[_]=x);for(let _ of Object.keys(r))delete r[_];Object.assign(r,b),Eht.set(s,{orderedStatNames:n,statCount:u})}var RHt,IHt,Eht,Sht,MLe,wce,TLe=Ve(()=>{Kj();RHt="GPU Time and Memory",IHt=["Adapter","GPU","GPU Type","GPU Backend","Frame Rate","CPU Time","GPU Time","GPU Memory","Buffer Memory","Texture Memory","External Buffer Memory","External Texture Memory","Swap Chain Texture"],Eht=new WeakMap,Sht=new WeakMap,MLe=class{stats=new Map;getStats(n){return this.get(n)}get(n){this.stats.has(n)||this.stats.set(n,new yb({id:n}));let r=this.stats.get(n);return n===RHt&&DHt(r,IHt),r}},wce=new MLe});var BHt,Mht,CLe,UD,Tht=Ve(()=>{SLe();TLe();rg();BHt="set luma.log.level=1 (or higher) to trace rendering",Mht="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",CLe=class s{static defaultProps={...bce,type:"best-available",adapters:void 0,waitForPageLoad:!0};stats=wce;log=Qt;VERSION="9.4.2";spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw Qt.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),Qt.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");Qt.error("This version of luma.gl has already been initialized")()}Qt.log(1,`${this.VERSION} - ${BHt}`)(),globalThis.luma=this}async createDevice(n={}){let r={...s.defaultProps,...n},c=this.selectAdapter(r.type,r.adapters);if(!c)throw new Error(Mht);return r.waitForPageLoad&&await c.pageLoaded,await c.create(r)}async attachDevice(n,r){let c=this._getTypeFromHandle(n,r.adapters),u=c&&this.selectAdapter(c,r.adapters);if(!u)throw new Error(Mht);return await u?.attach?.(n,r)}registerAdapters(n){for(let r of n)this.preregisteredAdapters.set(r.type,r)}getSupportedAdapters(n=[]){let r=this._getAdapterMap(n);return Array.from(r).map(([,c])=>c).filter(c=>c.isSupported?.()).map(c=>c.type)}getBestAvailableAdapterType(n=[]){let r=["webgpu","webgl","null"],c=this._getAdapterMap(n);for(let u of r)if(c.get(u)?.isSupported?.())return u;return null}selectAdapter(n,r=[]){let c=n;n==="best-available"&&(c=this.getBestAvailableAdapterType(r));let u=this._getAdapterMap(r);return c&&u.get(c)||null}enforceWebGL2(n=!0,r=[]){let u=this._getAdapterMap(r).get("webgl");u||Qt.warn("enforceWebGL2: webgl adapter not found")(),u?.enforceWebGL2?.(n)}setDefaultDeviceProps(n){Object.assign(s.defaultProps,n)}_getAdapterMap(n=[]){let r=new Map(this.preregisteredAdapters);for(let c of n)r.set(c.type,c);return r}_getTypeFromHandle(n,r=[]){return n instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&n instanceof GPUDevice||n?.queue?"webgpu":n===null?"null":(n instanceof WebGLRenderingContext?Qt.warn("WebGL1 is not supported",n)():Qt.warn("Unknown handle type",n)(),null)}},UD=new CLe});function FHt(){return vce||(NHt()||typeof window>"u"?vce=Promise.resolve():vce=new Promise(s=>window.addEventListener("load",()=>s()))),vce}var u$,OHt,NHt,vce,Cht=Ve(()=>{VL();u$=class{get pageLoaded(){return FHt()}},OHt=D1()&&typeof document<"u",NHt=()=>OHt&&document.readyState==="complete",vce=null});function $y(s="id"){ALe[s]=ALe[s]||1;let n=ALe[s]++;return`${s}-${n}`}var ALe,zD=Ve(()=>{ALe={}});function VHt(s,n){let r={...n};for(let c in s)s[c]!==void 0&&(r[c]=s[c]);return r}function Iht(s,n){let r=s.stats,c=!1;for(let _ of n)r[_]||(s.get(_),c=!0);let u=Object.keys(r).length,d=kht.get(s);if(!c&&d?.orderedStatNames===n&&d.statCount===u)return;let b={},w=Rht.get(n);w||(w=new Set(n),Rht.set(n,w));for(let _ of n)r[_]&&(b[_]=r[_]);for(let[_,x]of Object.entries(r))w.has(_)||(b[_]=x);for(let _ of Object.keys(r))delete r[_];Object.assign(r,b),kht.set(s,{orderedStatNames:n,statCount:u})}function Dht(s){return s.type==="webgl"?$Ht:jHt}function f$(s){let n=s.userData[UHt];return n?.enabled?n:null}function BM(){return globalThis.performance?.now?.()??Date.now()}function WHt(s,n){let r=f$(s);if(!(!r||!r.activeDefaultFramebufferAcquireDepth))switch(r.transientCanvasResourceCreates=(r.transientCanvasResourceCreates||0)+1,n){case"Texture":r.transientCanvasTextureCreates=(r.transientCanvasTextureCreates||0)+1;break;case"TextureView":r.transientCanvasTextureViewCreates=(r.transientCanvasTextureViewCreates||0)+1;break;case"Sampler":r.transientCanvasSamplerCreates=(r.transientCanvasSamplerCreates||0)+1;break;case"Framebuffer":r.transientCanvasFramebufferCreates=(r.transientCanvasFramebufferCreates||0)+1;break;default:break}}function HHt(s){let n=Object.getPrototypeOf(s);for(;n;){let r=Object.getPrototypeOf(n);if(!r||r===ns.prototype)return qHt(n)||s[Symbol.toStringTag]||s.constructor.name;n=r}return s[Symbol.toStringTag]||s.constructor.name}function qHt(s){let n=Object.getOwnPropertyDescriptor(s,Symbol.toStringTag);return typeof n?.get=="function"?n.get.call(s):typeof n?.value=="string"?n.value:null}var UHt,Aht,Pht,Lht,zHt,GHt,jHt,$Ht,kht,Rht,ns,zh=Ve(()=>{zD();UHt="cpu-hotspot-profiler",Aht="GPU Resource Counts",Pht="Resource Counts",Lht="GPU Time and Memory",zHt=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","RenderBundleEncoders","RenderBundles","ComputePasss","CommandEncoders","CommandBuffers"],GHt=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","SharedRenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","RenderBundleEncoders","RenderBundles","ComputePasss","CommandEncoders","CommandBuffers"],jHt=zHt.flatMap(s=>[`${s} Created`,`${s} Active`]),$Ht=GHt.flatMap(s=>[`${s} Created`,`${s} Active`]),kht=new WeakMap,Rht=new WeakMap,ns=class{static defaultProps={id:"undefined",handle:void 0,_isHandleBorrowed:!1,userData:void 0};toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}toJSON(){return this.toString()}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;allocatedBytesName=null;_attachedResources=new Set;get ownsHandle(){return(this.props.handle===void 0||this.props.handle===null)&&!this.isHandleBorrowed}get isHandleBorrowed(){return!!this.props._isHandleBorrowed}constructor(n,r,c){if(!n)throw new Error("no device");this._device=n,this.props=VHt(r,c);let u=this.props.id!=="undefined"?this.props.id:$y(this[Symbol.toStringTag]);this.props.id=u,this.id=u,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyed||this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(n){this._attachedResources.add(n)}detachResource(n){this._attachedResources.delete(n)}destroyAttachedResource(n){this._attachedResources.delete(n)&&n.destroy()}destroyAttachedResources(){for(let n of this._attachedResources)n.destroy();this._attachedResources=new Set}destroyResource(){this.destroyed||(this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0)}removeStats(){let n=f$(this._device),r=n?BM():0,c=[this._device.statsManager.getStats(Aht),this._device.statsManager.getStats(Pht)],u=Dht(this._device);for(let b of c)Iht(b,u);let d=this.getStatsName();for(let b of c)b.get("Resources Active").decrementCount(),b.get(`${d}s Active`).decrementCount();n&&(n.statsBookkeepingCalls=(n.statsBookkeepingCalls||0)+1,n.statsBookkeepingTimeMs=(n.statsBookkeepingTimeMs||0)+(BM()-r))}trackAllocatedMemory(n,r=this.getStatsName()){let c=f$(this._device),u=c?BM():0,d=this._device.statsManager.getStats(Lht);this.allocatedBytes>0&&this.allocatedBytesName&&(d.get("GPU Memory").subtractCount(this.allocatedBytes),d.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes)),d.get("GPU Memory").addCount(n),d.get(`${r} Memory`).addCount(n),c&&(c.statsBookkeepingCalls=(c.statsBookkeepingCalls||0)+1,c.statsBookkeepingTimeMs=(c.statsBookkeepingTimeMs||0)+(BM()-u)),this.allocatedBytes=n,this.allocatedBytesName=r}trackReferencedMemory(n,r=this.getStatsName()){this.trackAllocatedMemory(n,`External ${r}`)}trackDeallocatedMemory(n=this.getStatsName()){if(this.allocatedBytes===0){this.allocatedBytesName=null;return}let r=f$(this._device),c=r?BM():0,u=this._device.statsManager.getStats(Lht);u.get("GPU Memory").subtractCount(this.allocatedBytes),u.get(`${this.allocatedBytesName||n} Memory`).subtractCount(this.allocatedBytes),r&&(r.statsBookkeepingCalls=(r.statsBookkeepingCalls||0)+1,r.statsBookkeepingTimeMs=(r.statsBookkeepingTimeMs||0)+(BM()-c)),this.allocatedBytes=0,this.allocatedBytesName=null}trackDeallocatedReferencedMemory(n=this.getStatsName()){this.trackDeallocatedMemory(`Referenced ${n}`)}addStats(){let n=this.getStatsName(),r=f$(this._device),c=r?BM():0,u=[this._device.statsManager.getStats(Aht),this._device.statsManager.getStats(Pht)],d=Dht(this._device);for(let b of u)Iht(b,d);for(let b of u)b.get("Resources Created").incrementCount(),b.get("Resources Active").incrementCount(),b.get(`${n}s Created`).incrementCount(),b.get(`${n}s Active`).incrementCount();r&&(r.statsBookkeepingCalls=(r.statsBookkeepingCalls||0)+1,r.statsBookkeepingTimeMs=(r.statsBookkeepingTimeMs||0)+(BM()-c)),WHt(this._device,n)}getStatsName(){return HHt(this)}}});var as,_ce=Ve(()=>{zh();as=class s extends ns{static INDEX=16;static VERTEX=32;static UNIFORM=64;static STORAGE=128;static INDIRECT=256;static QUERY_RESOLVE=512;static MAP_READ=1;static MAP_WRITE=2;static COPY_SRC=4;static COPY_DST=8;get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(n,r){let c={...r};(r.usage||0)&s.INDEX&&!r.indexType&&(r.data instanceof Uint32Array?c.indexType="uint32":r.data instanceof Uint16Array?c.indexType="uint16":r.data instanceof Uint8Array&&(c.indexType="uint8")),delete c.data,super(n,c,s.defaultProps),this.usage=c.usage||0,this.indexType=c.indexType,this.updateTimestamp=n.incrementTimestamp()}clone(n){return this.device.createBuffer({...this.props,...n})}static DEBUG_DATA_MAX_LENGTH=32;debugData=new ArrayBuffer(0);_setDebugData(n,r,c){if(!this.device.props.debug)return;let u=null,d;ArrayBuffer.isView(n)?(u=n,d=n.buffer):d=n;let b=Math.min(n?n.byteLength:c,s.DEBUG_DATA_MAX_LENGTH);if(d===null)this.debugData=new ArrayBuffer(b);else{let w=Math.min(u?.byteOffset||0,d.byteLength),_=Math.max(0,d.byteLength-w),x=Math.min(b,_);this.debugData=new Uint8Array(d,w,x).slice().buffer}}static defaultProps={...ns.defaultProps,handle:void 0,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0}}});function Bht(){return PLe??Uint16Array}function Oht(s){return!!(PLe&&s===PLe)}var PLe,Nht=Ve(()=>{PLe=globalThis.Float16Array});function Fht(s){let n=s.includes("norm"),r=!n&&!s.startsWith("float"),c=s.startsWith("s"),u=LLe[s],[d,b,w]=u||["uint8 ","i32",1];return{signedType:d,primitiveType:b,byteLength:w,normalized:n,integer:r,signed:c}}function Uht(s){let n=s;switch(n){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return n}}function Eb(s,n){switch(n){case 1:return s;case 2:return s+s%2;default:return s+(4-s%4)%4}}function yce(s){let n=ArrayBuffer.isView(s)?s.constructor:s;if(Oht(n))return"float16";if(n===Uint8ClampedArray)return"uint8";let r=Object.values(LLe).find(c=>n===c[4]);if(!r)throw new Error(n.name);return r[0]}function zht(s){return yce(s)}function KL(s){if(s==="float16")return Bht();let n=LLe[s];if(!n)throw new Error(s);let[,,,,r]=n;return r}function JL(s){return KL(s)}var LLe,xce=Ve(()=>{Nht();LLe={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]}});var kLe,Sd,Ece=Ve(()=>{xce();kLe=class{getDataTypeInfo(n){return Fht(n)}getNormalizedDataType(n){return Uht(n)}alignTo(n,r){return Eb(n,r)}getDataType(n){return zht(n)}getTypedArrayConstructor(n){return JL(n)}},Sd=new kLe});function XHt(s,n){try{return Sd.getDataTypeInfo(n)}catch{throw new Error(`Unsupported vertex format: ${s}`)}}function YHt(s,n){if(!n)return 1;let r=Number(n);if(r===2||r===3||r===4)return r;throw new Error(`Unsupported vertex format: ${s}`)}function ZHt(s,n,r){if(r!==3)throw new Error(`Unsupported vertex format: ${s}`);switch(n){case"uint8":case"sint8":case"unorm8":case"snorm8":case"uint16":case"sint16":case"unorm16":case"snorm16":return`${n}x3-webgl`;default:throw new Error(`Unsupported vertex format: ${s}`)}}var RLe,fl,h$=Ve(()=>{Ece();RLe=class{getVertexFormatInfo(n){if(n==="unorm10-10-10-2")return{type:"unorm8",components:4,byteLength:4,integer:!1,signed:!1,normalized:!0};let r=n==="unorm8x4-bgra"?"unorm8x4":n,c;r.endsWith("-webgl")&&(r=r.slice(0,-6),c=!0);let u=r.split("x");if(u.length>2)throw new Error(`Unsupported vertex format: ${n}`);let[d,b]=u,w=d,_=YHt(n,b),x=XHt(n,w),T;try{T=c?ZHt(n,w,_):this.makeVertexFormat(x.signedType,_,x.normalized)}catch{throw new Error(`Unsupported vertex format: ${n}`)}if(T!==(c?n:r))throw new Error(`Unsupported vertex format: ${n}`);let M={type:w,components:_,byteLength:x.byteLength*_,integer:x.integer,signed:x.signed,normalized:x.normalized};return c&&(M.webglOnly=!0),M}makeVertexFormat(n,r,c){let u=c?Sd.getNormalizedDataType(n):n;switch(u){case"unorm8":return r===1?"unorm8":r===3?"unorm8x3-webgl":`${u}x${r}`;case"snorm8":return r===1?"snorm8":r===3?"snorm8x3-webgl":`${u}x${r}`;case"uint8":case"sint8":if(r===3)throw new Error(`size: ${r}`);return r===1?u:`${u}x${r}`;case"uint16":return r===1?"uint16":r===3?"uint16x3-webgl":`${u}x${r}`;case"sint16":return r===1?"sint16":r===3?"sint16x3-webgl":`${u}x${r}`;case"unorm16":return r===1?"unorm16":r===3?"unorm16x3-webgl":`${u}x${r}`;case"snorm16":return r===1?"snorm16":r===3?"snorm16x3-webgl":`${u}x${r}`;case"float16":if(r===3)throw new Error(`size: ${r}`);return r===1?u:`${u}x${r}`;default:return r===1?u:`${u}x${r}`}}getVertexFormatFromAttribute(n,r,c){if(!r||r>4)throw new Error(`size ${r}`);let u=r,d=Sd.getDataType(n);return this.makeVertexFormat(d,u,c)}getCompatibleVertexFormat(n){let r;switch(n.primitiveType){case"f32":r="float32";break;case"i32":r="sint32";break;case"u32":r="uint32";break;case"f16":return n.components<=2?"float16x2":"float16x4"}return n.components===1?r:`${r}x${n.components}`}},fl=new RLe});function Cce(s){let n=$ht[s];if(!n)throw new Error(`Unsupported texture format ${s}`);return n}function jht(){return $ht}var op,Mc,Vy,KHt,Sce,ILe,Mce,DLe,JHt,BLe,OM,OLe,NLe,Tce,Ght,QHt,eqt,$ht,FLe=Ve(()=>{op="texture-compression-bc",Mc="texture-compression-astc",Vy="texture-compression-etc2",KHt="texture-compression-etc1-webgl",Sce="texture-compression-pvrtc-webgl",ILe="texture-compression-atc-webgl",Mce="float32-renderable-webgl",DLe="float16-renderable-webgl",JHt="rgb9e5ufloat-renderable-webgl",BLe="snorm8-renderable-webgl",OM="norm16-webgl",OLe="norm16-renderable-webgl",NLe="snorm16-renderable-webgl",Tce="float32-filterable",Ght="float16-filterable-webgl";QHt={r8unorm:{webgpu:527},rg8unorm:{webgpu:527},"rgb8unorm-webgl":{},rgba8unorm:{webgpu:31},"rgba8unorm-srgb":{webgpu:15},r8snorm:{render:BLe,webgpu:837},rg8snorm:{render:BLe,webgpu:837},"rgb8snorm-webgl":{},rgba8snorm:{render:BLe,webgpu:341},r8uint:{webgpu:515},rg8uint:{webgpu:515},rgba8uint:{webgpu:19},r8sint:{webgpu:515},rg8sint:{webgpu:515},rgba8sint:{webgpu:19},bgra8unorm:{webgpu:15},"bgra8unorm-srgb":{webgpu:15360},r16unorm:{f:OM,render:OLe,webgpu:992},rg16unorm:{f:OM,render:OLe,webgpu:992},"rgb16unorm-webgl":{f:OM,render:!1},rgba16unorm:{f:OM,render:OLe,webgpu:992},r16snorm:{f:OM,render:NLe,webgpu:992},rg16snorm:{f:OM,render:NLe,webgpu:992},"rgb16snorm-webgl":{f:OM,render:!1},rgba16snorm:{f:OM,render:NLe,webgpu:992},r16uint:{webgpu:515},rg16uint:{webgpu:515},rgba16uint:{webgpu:19},r16sint:{webgpu:515},rg16sint:{webgpu:515},rgba16sint:{webgpu:19},r16float:{render:DLe,filter:"float16-filterable-webgl",webgpu:527},rg16float:{render:DLe,filter:Ght,webgpu:527},rgba16float:{render:DLe,filter:Ght,webgpu:31},r32uint:{webgpu:19},rg32uint:{webgpu:16387},rgba32uint:{webgpu:19},r32sint:{webgpu:19},rg32sint:{webgpu:16387},rgba32sint:{webgpu:19},r32float:{render:Mce,filter:Tce,webgpu:19},rg32float:{render:!1,filter:Tce,webgpu:16387},"rgb32float-webgl":{render:Mce,filter:Tce},rgba32float:{render:Mce,filter:Tce,webgpu:19},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:JHt,webgpu:5},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:Mce,webgpu:517},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:527},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:515},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8",webgpu:3},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16",webgpu:3},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32",webgpu:3},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32",webgpu:3},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0,webgpu:3},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0,f:"depth32float-stencil8",webgpu:3}},eqt={"bc1-rgb-unorm-webgl":{f:op},"bc1-rgb-unorm-srgb-webgl":{f:op},"bc1-rgba-unorm":{f:op},"bc1-rgba-unorm-srgb":{f:op},"bc2-rgba-unorm":{f:op},"bc2-rgba-unorm-srgb":{f:op},"bc3-rgba-unorm":{f:op},"bc3-rgba-unorm-srgb":{f:op},"bc4-r-unorm":{f:op},"bc4-r-snorm":{f:op},"bc5-rg-unorm":{f:op},"bc5-rg-snorm":{f:op},"bc6h-rgb-ufloat":{f:op},"bc6h-rgb-float":{f:op},"bc7-rgba-unorm":{f:op},"bc7-rgba-unorm-srgb":{f:op},"etc2-rgb8unorm":{f:Vy},"etc2-rgb8unorm-srgb":{f:Vy},"etc2-rgb8a1unorm":{f:Vy},"etc2-rgb8a1unorm-srgb":{f:Vy},"etc2-rgba8unorm":{f:Vy},"etc2-rgba8unorm-srgb":{f:Vy},"eac-r11unorm":{f:Vy},"eac-r11snorm":{f:Vy},"eac-rg11unorm":{f:Vy},"eac-rg11snorm":{f:Vy},"astc-4x4-unorm":{f:Mc},"astc-4x4-unorm-srgb":{f:Mc},"astc-5x4-unorm":{f:Mc},"astc-5x4-unorm-srgb":{f:Mc},"astc-5x5-unorm":{f:Mc},"astc-5x5-unorm-srgb":{f:Mc},"astc-6x5-unorm":{f:Mc},"astc-6x5-unorm-srgb":{f:Mc},"astc-6x6-unorm":{f:Mc},"astc-6x6-unorm-srgb":{f:Mc},"astc-8x5-unorm":{f:Mc},"astc-8x5-unorm-srgb":{f:Mc},"astc-8x6-unorm":{f:Mc},"astc-8x6-unorm-srgb":{f:Mc},"astc-8x8-unorm":{f:Mc},"astc-8x8-unorm-srgb":{f:Mc},"astc-10x5-unorm":{f:Mc},"astc-10x5-unorm-srgb":{f:Mc},"astc-10x6-unorm":{f:Mc},"astc-10x6-unorm-srgb":{f:Mc},"astc-10x8-unorm":{f:Mc},"astc-10x8-unorm-srgb":{f:Mc},"astc-10x10-unorm":{f:Mc},"astc-10x10-unorm-srgb":{f:Mc},"astc-12x10-unorm":{f:Mc},"astc-12x10-unorm-srgb":{f:Mc},"astc-12x12-unorm":{f:Mc},"astc-12x12-unorm-srgb":{f:Mc},"pvrtc-rgb4unorm-webgl":{f:Sce},"pvrtc-rgba4unorm-webgl":{f:Sce},"pvrtc-rgb2unorm-webgl":{f:Sce},"pvrtc-rgba2unorm-webgl":{f:Sce},"etc1-rbg-unorm-webgl":{f:KHt},"atc-rgb-unorm-webgl":{f:ILe},"atc-rgba-unorm-webgl":{f:ILe},"atc-rgbai-unorm-webgl":{f:ILe}},$ht={...QHt,...eqt}});function oqt({format:s,width:n,height:r,depth:c,byteAlignment:u}){let d=sg.getInfo(s),{bytesPerPixel:b,bytesPerBlock:w=b,blockWidth:_=1,blockHeight:x=1,compressed:T=!1}=d,M=T?Math.ceil(n/_):n,L=T?Math.ceil(r/x):r,I=M*w,D=Math.ceil(I/u)*u,F=L,O=D*F*c;return{bytesPerPixel:b,bytesPerRow:D,rowsPerImage:F,depthOrArrayLayers:c,bytesPerImage:D*F,byteLength:O}}function aqt(s){let n=Cce(s),r={format:s,create:n.f??!0,render:n.render??!0,filter:n.filter??!0,blend:n.blend??!0,store:n.store??!0},c=Vht(s),u=s.startsWith("depth")||s.startsWith("stencil"),d=c?.signed,b=c?.integer,w=c?.webgl,_=!!c?.compressed;return r.render&&=!u&&!_,r.filter&&=!u&&!d&&!b&&!w,r}function Vht(s){let n=cqt(s);if(sg.isCompressed(s)){n.channels="rgb",n.components=3,n.bytesPerPixel=1,n.srgb=!1,n.compressed=!0,n.bytesPerBlock=uqt(s);let c=lqt(s);c&&(n.blockWidth=c.blockWidth,n.blockHeight=c.blockHeight)}let r=n.packed?null:tqt.exec(s);if(r){let[,c,u,d,b,w]=r,_=`${d}${u}`,x=Sd.getDataTypeInfo(_),T=x.byteLength*8,M=c?.length??1,L=[T,M>=2?T:0,M>=3?T:0,M>=4?T:0];n={format:s,attachment:n.attachment,dataType:x.signedType,components:M,channels:c,integer:x.integer,signed:x.signed,normalized:x.normalized,bitsPerChannel:L,bytesPerPixel:x.byteLength*M,packed:n.packed,srgb:n.srgb},w==="-webgl"&&(n.webgl=!0),b==="-srgb"&&(n.srgb=!0)}return s.endsWith("-webgl")&&(n.webgl=!0),s.endsWith("-srgb")&&(n.srgb=!0),n}function cqt(s){let n={...Cce(s)},r=n.bytesPerPixel||1,c=n.bitsPerChannel||[8,8,8,8];return delete n.bitsPerChannel,delete n.bytesPerPixel,delete n.f,delete n.render,delete n.filter,delete n.blend,delete n.store,delete n.webgpu,{...n,format:s,attachment:n.attachment||"color",channels:n.channels||"r",components:n.components||n.channels?.length||1,bytesPerPixel:r,bitsPerChannel:c,dataType:n.dataType||"uint8",srgb:n.srgb??!1,packed:n.packed??!1,webgl:n.webgl??!1,integer:n.integer??!1,signed:n.signed??!1,normalized:n.normalized??!1,compressed:n.compressed??!1}}function lqt(s){let r=/.*-(\d+)x(\d+)-.*/.exec(s);if(r){let[,c,u]=r;return{blockWidth:Number(c),blockHeight:Number(u)}}return s.startsWith("bc")||s.startsWith("etc1")||s.startsWith("etc2")||s.startsWith("eac")||s.startsWith("atc")?{blockWidth:4,blockHeight:4}:s.startsWith("pvrtc-rgb4")||s.startsWith("pvrtc-rgba4")?{blockWidth:4,blockHeight:4}:s.startsWith("pvrtc-rgb2")||s.startsWith("pvrtc-rgba2")?{blockWidth:8,blockHeight:4}:null}function uqt(s){return s.startsWith("bc1")||s.startsWith("bc4")||s.startsWith("etc1")||s.startsWith("etc2-rgb8")||s.startsWith("etc2-rgb8a1")||s.startsWith("eac-r11")||s==="atc-rgb-unorm-webgl"?8:s.startsWith("bc2")||s.startsWith("bc3")||s.startsWith("bc5")||s.startsWith("bc6h")||s.startsWith("bc7")||s.startsWith("etc2-rgba8")||s.startsWith("eac-rg11")||s.startsWith("astc")||s==="atc-rgba-unorm-webgl"||s==="atc-rgbai-unorm-webgl"?16:s.startsWith("pvrtc")?8:16}var tqt,nqt,iqt,rqt,sqt,ULe,sg,Ace=Ve(()=>{Ece();FLe();tqt=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,nqt=["rgb","rgba","bgra"],iqt=["depth","stencil"],rqt=5,sqt=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],ULe=class{isColor(n){return nqt.some(r=>n.startsWith(r))}isDepthStencil(n){return iqt.some(r=>n.startsWith(r))}isCompressed(n){return sqt.some(r=>n.startsWith(r))}getInfo(n){return Vht(n)}getCapabilities(n){return aqt(n)}getWebGPUCapabilities(n){let r=Cce(n);return r.webgpu!==void 0?r.webgpu:this.isCompressed(n)&&!n.endsWith("-webgl")?rqt:0}computeMemoryLayout(n){return oqt(n)}},sg=new ULe});function Wht(s){return typeof ImageData<"u"&&s instanceof ImageData||typeof ImageBitmap<"u"&&s instanceof ImageBitmap||typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&s instanceof HTMLVideoElement||typeof VideoFrame<"u"&&s instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas}function Hht(s){if(typeof ImageData<"u"&&s instanceof ImageData||typeof ImageBitmap<"u"&&s instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas)return{width:s.width,height:s.height};if(typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement)return{width:s.naturalWidth,height:s.naturalHeight};if(typeof HTMLVideoElement<"u"&&s instanceof HTMLVideoElement)return{width:s.videoWidth,height:s.videoHeight};if(typeof VideoFrame<"u"&&s instanceof VideoFrame)return{width:s.displayWidth,height:s.displayHeight};throw new Error("Unknown image type")}var qht=Ve(()=>{});function fqt(s,n){let r=zLe(s),c=n.map(zLe).filter(u=>u!==void 0);return[r,...c].filter(u=>u!==void 0)}function zLe(s){if(s!==void 0){if(s===null||typeof s=="string"||typeof s=="number"||typeof s=="boolean")return s;if(s instanceof Error)return s.message;if(Array.isArray(s))return s.map(zLe);if(typeof s=="object"){if(hqt(s)){let n=String(s);if(n!=="[object Object]")return n}return dqt(s)?pqt(s):s.constructor?.name||"Object"}return String(s)}}function hqt(s){return"toString"in s&&typeof s.toString=="function"&&s.toString!==Object.prototype.toString}function dqt(s){return"message"in s&&"type"in s}function pqt(s){let n=typeof s.type=="string"?s.type:"message",r=typeof s.message=="string"?s.message:"",c=typeof s.lineNum=="number"?s.lineNum:null,u=typeof s.linePos=="number"?s.linePos:null,d=c!==null&&u!==null?` @ ${c}:${u}`:c!==null?` @ ${c}`:"";return`${n}${d}: ${r}`.trim()}function GLe(){if(typeof HTMLCanvasElement>"u")return!1;let s=HTMLCanvasElement.prototype;return"layoutSubtree"in s&&typeof s.requestPaint=="function"}var d$,p$,C3,Xht=Ve(()=>{TLe();rg();zD();_ce();h$();Ace();qht();FLe();SLe();d$=class{};p$=class{features;disabledFeatures;constructor(n=[],r){this.features=new Set(n),this.disabledFeatures=r||{}}*[Symbol.iterator](){yield*this.features}has(n){return!this.disabledFeatures?.[n]&&this.features.has(n)}};C3=class s{static defaultProps={...bce};get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}toJSON(){return this.toString()}id;props;userData={};statsManager=wce;_factories={};timestamp=0;_reused=!1;_moduleData={};wgslLanguageFeatures=new Set;_textureCaps={};_debugGPUTimeQuery=null;constructor(n){this.props={...s.defaultProps,...n},this.id=this.props.id||$y(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(n){return fl.getVertexFormatInfo(n)}isVertexFormatSupported(n){return!0}getTextureFormatInfo(n){return sg.getInfo(n)}getTextureFormatCapabilities(n){let r=this._textureCaps[n];if(!r){let c=this._getDeviceTextureFormatCapabilities(n);r=this._getDeviceSpecificTextureFormatCapabilities(c),this._textureCaps[n]=r}return r}getMipLevelCount(n,r,c=1){let u=Math.max(n,r,c);return 1+Math.floor(Math.log2(u))}isExternalImage(n){return Wht(n)}getExternalImageSize(n){return Hht(n)}isTextureFormatSupported(n){return this.getTextureFormatCapabilities(n).create}isTextureFormatFilterable(n){return this.getTextureFormatCapabilities(n).filter}isTextureFormatRenderable(n){return this.getTextureFormatCapabilities(n).render}isTextureFormatCompressed(n){return sg.isCompressed(n)}getSupportedCompressedTextureFormats(){let n=[];for(let r of Object.keys(jht()))this.isTextureFormatCompressed(r)&&this.isTextureFormatSupported(r)&&n.push(r);return n}pushDebugGroup(n){this.commandEncoder.pushDebugGroup(n)}popDebugGroup(){this.commandEncoder?.popDebugGroup()}insertDebugMarker(n){this.commandEncoder?.insertDebugMarker(n)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(n,r,...c){if(!this.props.onError(n,r)){let d=fqt(r,c);return Qt.error(this.type==="webgl"?"%cWebGL":"%cWebGPU","color: white; background: red; padding: 2px 6px; border-radius: 3px;",n.message,...d)}return()=>{}}debug(){if(this.props.debug)debugger;else{let n=`'Type luma.log.set({debug: true}) in console to enable debug breakpoints', +or create a device with the 'debug: true' prop.`;Qt.once(0,n)()}}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}createFence(){throw new Error("createFence() not implemented")}beginRenderPass(n){return this.commandEncoder.beginRenderPass(n)}beginComputePass(n){return this.commandEncoder.beginComputePass(n)}writeBufferViaCommandEncoder(n,r,c,u=0){throw new Error("writeBufferViaCommandEncoder() not implemented")}generateMipmapsWebGPU(n){throw new Error("not implemented")}_createSharedRenderPipelineWebGL(n){throw new Error("_createSharedRenderPipelineWebGL() not implemented")}_createBindGroupLayoutWebGPU(n,r){throw new Error("_createBindGroupLayoutWebGPU() not implemented")}_createBindGroupWebGPU(n,r,c,u,d){throw new Error("_createBindGroupWebGPU() not implemented")}_supportsDebugGPUTime(){return this.features.has("timestamp-query")&&!!(this.props.debug||this.props.debugGPUTime)}_enableDebugGPUTime(n=256){if(!this._supportsDebugGPUTime())return null;if(this._debugGPUTimeQuery)return this._debugGPUTimeQuery;try{this._debugGPUTimeQuery=this.createQuerySet({type:"timestamp",count:n}),this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id,timeProfilingQuerySet:this._debugGPUTimeQuery})}catch{this._debugGPUTimeQuery=null}return this._debugGPUTimeQuery}_disableDebugGPUTime(){this._debugGPUTimeQuery&&(this.commandEncoder.getTimeProfilingQuerySet()===this._debugGPUTimeQuery&&(this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id})),this._debugGPUTimeQuery.destroy(),this._debugGPUTimeQuery=null)}_isDebugGPUTimeEnabled(){return this._debugGPUTimeQuery!==null}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(n,r){throw new Error("not implemented")}readPixelsToBufferWebGL(n,r){throw new Error("not implemented")}setParametersWebGL(n){throw new Error("not implemented")}getParametersWebGL(n){throw new Error("not implemented")}withParametersWebGL(n,r){throw new Error("not implemented")}clearWebGL(n){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}getModuleData(n){return this._moduleData[n]||={},this._moduleData[n]}static _getCanvasContextProps(n){return n.createCanvasContext===!0?{}:n.createCanvasContext}_getDeviceTextureFormatCapabilities(n){let r=sg.getCapabilities(n),c=d=>(typeof d=="string"?this.features.has(d):d)??!0,u=c(r.create);return{format:n,create:u,render:u&&c(r.render),filter:u&&c(r.filter),blend:u&&c(r.blend),store:u&&c(r.store)}}_normalizeBufferProps(n){(n instanceof ArrayBuffer||ArrayBuffer.isView(n))&&(n={data:n});let r={...n};if((n.usage||0)&as.INDEX&&(n.indexType||(n.data instanceof Uint32Array?r.indexType="uint32":n.data instanceof Uint16Array?r.indexType="uint16":n.data instanceof Uint8Array&&(r.data=new Uint16Array(n.data),r.indexType="uint16")),!r.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return r}}});var Pce,Yht=Ve(()=>{Pce=class{props;_resizeObserver;_intersectionObserver;_observeDevicePixelRatioTimeout=null;_observeDevicePixelRatioMediaQuery=null;_handleDevicePixelRatioChange=()=>this._refreshDevicePixelRatio();_trackPositionInterval=null;_started=!1;get started(){return this._started}constructor(n){this.props=n}start(){if(this._started||!this.props.canvas)return;this._started=!0,this._intersectionObserver||=new IntersectionObserver(r=>this.props.onIntersection(r)),this._resizeObserver||=new ResizeObserver(r=>this.props.onResize(r)),this._intersectionObserver.observe(this.props.canvas);let n=this.props.resizeObserverBox;try{this._resizeObserver.observe(this.props.canvas,{box:n})}catch{this._resizeObserver.observe(this.props.canvas,{box:"content-box"})}this._observeDevicePixelRatioTimeout=setTimeout(()=>this._refreshDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}stop(){this._started&&(this._started=!1,this._observeDevicePixelRatioTimeout&&(clearTimeout(this._observeDevicePixelRatioTimeout),this._observeDevicePixelRatioTimeout=null),this._observeDevicePixelRatioMediaQuery&&(this._observeDevicePixelRatioMediaQuery.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=null),this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null),this._resizeObserver?.disconnect(),this._intersectionObserver?.disconnect())}_refreshDevicePixelRatio(){this._started&&(this.props.onDevicePixelRatioChange(),this._observeDevicePixelRatioMediaQuery?.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._observeDevicePixelRatioMediaQuery.addEventListener("change",this._handleDevicePixelRatioChange,{once:!0}))}_trackPosition(n=100){this._trackPositionInterval||(this._trackPositionInterval=setInterval(()=>{this._started?this.props.onPositionChange():this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null)},n))}}});function Zht(){let s,n;return{promise:new Promise((c,u)=>{s=c,n=u}),resolve:s,reject:n}}var Kht=Ve(()=>{});function NM(s,n){if(!s){let r=new Error(n??"luma.gl assertion failed.");throw Error.captureStackTrace?.(r,NM),r}}function FM(s,n){return NM(s,n),s}var jLe=Ve(()=>{});function gqt(s){if(typeof s=="string"){let n=document.getElementById(s);if(!n)throw new Error(`${s} is not an HTML element`);return n}return s||document.body}function mqt(s){let n=document.getElementById(s);if(!UM.isHTMLCanvas(n))throw new Error("Object is not a canvas element");return n}function bqt(s){let{width:n,height:r}=s,c=document.createElement("canvas");c.id=$y("lumagl-auto-created-canvas"),c.width=n||1,c.height=r||1,c.style.width=Number.isFinite(n)?`${n}px`:"100%",c.style.height=Number.isFinite(r)?`${r}px`:"100%",s?.visible||(c.style.visibility="hidden");let u=gqt(s?.container||null);return u.insertBefore(c,u.firstChild),c}function wqt(s,n,r,c,u){let d=s,b=Jht(d[0],n,r),w=Qht(d[1],n,c,u),_=Jht(d[0]+1,n,r),x=_===r-1?_:_-1;_=Qht(d[1]+1,n,c,u);let T;return u?(_=_===0?_:_+1,T=w,w=_):T=_===c-1?_:_-1,{x:b,y:w,width:Math.max(x-b+1,1),height:Math.max(T-w+1,1)}}function Jht(s,n,r){return Math.min(Math.round(s*n),r-1)}function Qht(s,n,r,c){return c?Math.max(0,r-1-Math.round(s*n)):Math.min(Math.round(s*n),r-1)}var UM,$Le=Ve(()=>{VL();Yht();zD();Kht();jLe();UM=class s{static isHTMLCanvas(n){return typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement}static isOffscreenCanvas(n){return typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas}static defaultProps={id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,pixelSizeSource:"exact",autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",colorFormat:void 0,toneMapping:"standard",trackPosition:!1};id;props;canvas;htmlCanvas;offscreenCanvas;type;initialized;isInitialized=!1;isVisible=!0;cssWidth;cssHeight;devicePixelRatio;devicePixelWidth;devicePixelHeight;drawingBufferWidth;drawingBufferHeight;_initializedResolvers=Zht();_canvasObserver;_position=[0,0];destroyed=!1;_needsDrawingBufferResize=!0;_configuredDrawingBufferSize=[0,0];toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(n){this.props={...s.defaultProps,...n},n=this.props,this.initialized=this._initializedResolvers.promise,D1()?n.canvas?typeof n.canvas=="string"?this.canvas=mqt(n.canvas):this.canvas=n.canvas:this.canvas=bqt(n):this.canvas={width:n.width||1,height:n.height||1},s.isHTMLCanvas(this.canvas)?(this.id=n.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):s.isOffscreenCanvas(this.canvas)?(this.id=n.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=n.id||"node-canvas-context",this.type="node"),this.cssWidth=this.htmlCanvas?.clientWidth||this.canvas.width,this.cssHeight=this.htmlCanvas?.clientHeight||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this._configuredDrawingBufferSize=[this.canvas.width,this.canvas.height],this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],this._canvasObserver=new Pce({canvas:this.htmlCanvas,trackPosition:this.props.trackPosition,resizeObserverBox:this.props.pixelSizeSource==="css-dpr"?"content-box":"device-pixel-content-box",onResize:r=>this._handleResize(r),onIntersection:r=>this._handleIntersection(r),onDevicePixelRatioChange:()=>this._observeDevicePixelRatio(),onPositionChange:()=>this.updatePosition()})}destroy(){this.destroyed||(this.destroyed=!0,this._stopObservers(),this.device=null)}setProps(n){return"useDevicePixels"in n&&(this.props.useDevicePixels=n.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCurrentFramebuffer(n){return this._resizeDrawingBufferIfNeeded(),this._getCurrentFramebuffer(n)}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){let n=this.device.limits.maxTextureDimension2D;return[n,n]}setDrawingBufferSize(n,r){n=Math.floor(n),r=Math.floor(r),!(this.drawingBufferWidth===n&&this.drawingBufferHeight===r)&&(this.drawingBufferWidth=n,this.drawingBufferHeight=r,this._needsDrawingBufferResize=!0)}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(n,r=!0){let c=this.cssToDeviceRatio(),[u,d]=this.getDrawingBufferSize();return wqt(n,c,u,d,r)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){let[n,r]=this.getDrawingBufferSize();return n>0&&r>0?n/r:1}cssToDeviceRatio(){try{let[n]=this.getDrawingBufferSize(),[r]=this.getCSSSize();return r?n/r:1}catch{return 1}}resize(n){this.setDrawingBufferSize(n.width,n.height)}_setAutoCreatedCanvasId(n){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=n)}_startObservers(){this.destroyed||this._canvasObserver.start()}_stopObservers(){this._canvasObserver.stop()}_handleIntersection(n){if(this.destroyed)return;let r=n.find(u=>u.target===this.canvas);if(!r)return;let c=r.isIntersecting;this.isVisible!==c&&(this.isVisible=c,this.device.props.onVisibilityChange(this))}_handleResize(n){if(this.destroyed)return;let r=n.find(d=>d.target===this.canvas);if(!r)return;let c=FM(r.contentBoxSize?.[0]);this.cssWidth=c.inlineSize,this.cssHeight=c.blockSize;let u=this.getDevicePixelSize();this._setDevicePixelSize(this._getDevicePixelSizeFromResizeEntry(r)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:u})}_updateDrawingBufferSize(){if(this.props.autoResize)if(typeof this.props.useDevicePixels=="number"){let n=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*n,this.cssHeight*n)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_getDevicePixelSizeFromResizeEntry(n){let r=FM(n.contentBoxSize?.[0]);return this.props.pixelSizeSource==="css-dpr"?this._getDevicePixelSizeFromCSSSize(r.inlineSize,r.blockSize):{devicePixelWidth:n.devicePixelContentBoxSize?.[0]?.inlineSize||r.inlineSize*devicePixelRatio,devicePixelHeight:n.devicePixelContentBoxSize?.[0]?.blockSize||r.blockSize*devicePixelRatio}}_getDevicePixelSizeFromCSSSize(n,r){let c=this.getDevicePixelRatio();return{devicePixelWidth:Math.floor(n*c),devicePixelHeight:Math.floor(r*c)}}_setDevicePixelSize({devicePixelWidth:n,devicePixelHeight:r}){let[c,u]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(n,c)),this.devicePixelHeight=Math.max(1,Math.min(r,u))}_resizeDrawingBufferIfNeeded(){if(this._needsDrawingBufferResize){this._needsDrawingBufferResize=!1,(this.drawingBufferWidth!==this.canvas.width||this.drawingBufferHeight!==this.canvas.height)&&(this.canvas.width=this.drawingBufferWidth,this.canvas.height=this.drawingBufferHeight);let[r,c]=this._configuredDrawingBufferSize;(this.drawingBufferWidth!==r||this.drawingBufferHeight!==c)&&(this._configureDevice(),this._configuredDrawingBufferSize=[this.drawingBufferWidth,this.drawingBufferHeight])}}_observeDevicePixelRatio(){if(this.destroyed||!this._canvasObserver.started)return;let n=this.devicePixelRatio;if(this.devicePixelRatio=window.devicePixelRatio,this.props.pixelSizeSource==="css-dpr"){let r=this.getDevicePixelSize();this._setDevicePixelSize(this._getDevicePixelSizeFromCSSSize(this.cssWidth,this.cssHeight)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:r})}this.updatePosition(),this.device.props.onDevicePixelRatioChange?.(this,{oldRatio:n})}updatePosition(){if(this.destroyed)return;let n=this.htmlCanvas?.getBoundingClientRect();if(n){let r=[n.left,n.top];if(this._position??=r,r[0]!==this._position[0]||r[1]!==this._position[1]){let u=this._position;this._position=r,this.device.props.onPositionChange?.(this,{oldPosition:u})}}}}});var g$,edt=Ve(()=>{$Le();g$=class extends UM{static defaultProps=UM.defaultProps}});var m$,tdt=Ve(()=>{$Le();m$=class extends UM{}});var QL,VLe=Ve(()=>{zh();QL=class s extends ns{static defaultProps={...ns.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1};get[Symbol.toStringTag](){return"Sampler"}constructor(n,r){r=s.normalizeProps(n,r),super(n,r,s.defaultProps)}static normalizeProps(n,r){return r}}});var vqt,Aa,WLe=Ve(()=>{zh();VLe();rg();Ace();vqt={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},Aa=class s extends ns{static SAMPLE=4;static STORAGE=8;static RENDER=16;static COPY_SRC=1;static COPY_DST=2;static TEXTURE=4;static RENDER_ATTACHMENT=16;dimension;baseDimension;format;width;height;depth;mipLevels;samples;byteAlignment;ready=Promise.resolve(this);isReady=!0;updateTimestamp;get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(n,r,c){if(r=s.normalizeProps(n,r),super(n,r,s.defaultProps),this.dimension=this.props.dimension,this.baseDimension=vqt[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.samples=this.props.samples||1,this.dimension==="cube"&&(this.depth=6),this.props.width===void 0||this.props.height===void 0)if(n.isExternalImage(r.data)){let u=n.getExternalImageSize(r.data);this.width=u?.width||1,this.height=u?.height||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&Qt.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=c?.byteAlignment||1,this.updateTimestamp=n.incrementTimestamp()}clone(n){return this.device.createTexture({...this.props,...n})}setSampler(n){this.sampler=n instanceof QL?n:this.device.createSampler(n)}copyImageData(n){let{data:r,depth:c,...u}=n;this.writeData(r,{...u,depthOrArrayLayers:u.depthOrArrayLayers??c})}computeMemoryLayout(n={}){let r=this._normalizeTextureReadOptions(n),{width:c=this.width,height:u=this.height,depthOrArrayLayers:d=this.depth}=r,{format:b,byteAlignment:w}=this;return sg.computeMemoryLayout({format:b,width:c,height:u,depth:d,byteAlignment:w})}readBuffer(n,r){throw new Error("readBuffer not implemented")}readDataAsync(n){throw new Error("readBuffer not implemented")}writeBuffer(n,r){throw new Error("readBuffer not implemented")}writeData(n,r){throw new Error("readBuffer not implemented")}readDataSyncWebGL(n){throw new Error("readDataSyncWebGL not available")}generateMipmapsWebGL(){throw new Error("generateMipmapsWebGL not available")}static normalizeProps(n,r){let c={...r},{width:u,height:d}=c;return typeof u=="number"&&(c.width=Math.max(1,Math.ceil(u))),typeof d=="number"&&(c.height=Math.max(1,Math.ceil(d))),c}_initializeData(n){this.device.isExternalImage(n)?this.copyExternalImage({image:n,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):n&&this.copyImageData({data:n,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(n){let{data:r,depth:c,...u}=n,d=this._normalizeTextureWriteOptions({...u,depthOrArrayLayers:u.depthOrArrayLayers??c});return{data:r,depth:d.depthOrArrayLayers,...d}}_normalizeCopyExternalImageOptions(n){let r=s._omitUndefined(n),c=r.mipLevel??0,u=this._getMipLevelSize(c),d=this.device.getExternalImageSize(n.image),b={...s.defaultCopyExternalImageOptions,...u,...d,...r};return b.width=Math.min(b.width,u.width-b.x),b.height=Math.min(b.height,u.height-b.y),b.depth=Math.min(b.depth,u.depthOrArrayLayers-b.z),b}_normalizeCopyElementImageOptions(n){let r=s._omitUndefined(n),c=r.mipLevel??0,u=this._getMipLevelSize(c),d={...s.defaultCopyElementImageOptions,...u,...r};return d.width=Math.min(d.width,u.width-d.x),d.height=Math.min(d.height,u.height-d.y),d.depth=Math.min(d.depth,u.depthOrArrayLayers-d.z),d}_normalizeTextureReadOptions(n){let r=s._omitUndefined(n),c=r.mipLevel??0,u=this._getMipLevelSize(c),d={...s.defaultTextureReadOptions,...u,...r};return d.width=Math.min(d.width,u.width-d.x),d.height=Math.min(d.height,u.height-d.y),d.depthOrArrayLayers=Math.min(d.depthOrArrayLayers,u.depthOrArrayLayers-d.z),d}_getSupportedColorReadOptions(n){let r=this._normalizeTextureReadOptions(n),c=sg.getInfo(this.format);switch(this._validateColorReadAspect(r),this._validateColorReadFormat(c),this.dimension){case"2d":case"cube":case"cube-array":case"2d-array":case"3d":return r;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}}_validateColorReadAspect(n){if(n.aspect!=="all")throw new Error(`${this} color readback only supports aspect 'all'`)}_validateColorReadFormat(n){if(n.compressed)throw new Error(`${this} color readback does not support compressed formats (${this.format})`);switch(n.attachment){case"color":return;case"depth":throw new Error(`${this} color readback does not support depth formats (${this.format})`);case"stencil":throw new Error(`${this} color readback does not support stencil formats (${this.format})`);case"depth-stencil":throw new Error(`${this} color readback does not support depth-stencil formats (${this.format})`);default:throw new Error(`${this} color readback does not support format ${this.format}`)}}_normalizeTextureWriteOptions(n){let r=s._omitUndefined(n),c=r.mipLevel??0,u=this._getMipLevelSize(c),d={...s.defaultTextureWriteOptions,...u,...r};d.width=Math.min(d.width,u.width-d.x),d.height=Math.min(d.height,u.height-d.y),d.depthOrArrayLayers=Math.min(d.depthOrArrayLayers,u.depthOrArrayLayers-d.z);let b=sg.computeMemoryLayout({format:this.format,width:d.width,height:d.height,depth:d.depthOrArrayLayers,byteAlignment:this.byteAlignment}),w=b.bytesPerPixel*d.width;if(d.bytesPerRow=r.bytesPerRow??b.bytesPerRow,d.rowsPerImage=r.rowsPerImage??d.height,d.bytesPerRow>n),c=this.baseDimension==="1d"?1:Math.max(1,this.height>>n),u=this.dimension==="3d"?Math.max(1,this.depth>>n):this.depth;return{width:r,height:c,depthOrArrayLayers:u}}getAllocatedByteLength(){let n=0;for(let r=0;rr!==void 0))}static defaultProps={...ns.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:s.SAMPLE|s.RENDER|s.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0};static defaultCopyDataOptions={data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,width:void 0,height:void 0,depthOrArrayLayers:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all"};static defaultCopyExternalImageOptions={image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultCopyElementImageOptions={element:void 0,width:void 0,height:void 0,sourceX:0,sourceY:0,sourceWidth:void 0,sourceHeight:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultTextureReadOptions={x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"};static defaultTextureWriteOptions={byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"}}});var e4,ndt=Ve(()=>{zh();e4=class s extends ns{get[Symbol.toStringTag](){return"TextureView"}constructor(n,r){super(n,r,s.defaultProps)}static defaultProps={...ns.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0}}});var b$,idt=Ve(()=>{zh();b$=class s extends ns{width;height;updateTimestamp;get[Symbol.toStringTag](){return"ExternalTexture"}constructor(n,r){super(n,r,s.defaultProps);let c=this.props.source?n.getExternalImageSize(this.props.source):null;this.width=this.props.width||c?.width||0,this.height=this.props.height||c?.height||0,this.updateTimestamp=n.incrementTimestamp()}static defaultProps={...ns.defaultProps,source:void 0,width:0,height:0,colorSpace:"srgb",sampler:{}}}});function rdt(s,n,r){let c="",u=n.split(/\r?\n/),d=s.slice().sort((b,w)=>b.lineNum-w.lineNum);switch(r?.showSourceCode||"no"){case"all":let b=0;for(let w=1;w<=u.length;w++){let _=u[w-1],x=d[b];for(_&&x&&(c+=sdt(_,w,r));d.length>b&&x.lineNum===w;){let T=d[b++];T&&(c+=HLe(T,u,T.lineNum,{...r,inlineSource:!1}))}}for(;d.length>b;){let w=d[b++];w&&(c+=HLe(w,[],0,{...r,inlineSource:!1}))}return c;case"issues":case"no":for(let w of s)c+=HLe(w,u,w.lineNum,{inlineSource:r?.showSourceCode!=="no"});return c}}function HLe(s,n,r,c){if(c?.inlineSource){let d=_qt(n,r),b=s.linePos>0?`${" ".repeat(s.linePos+5)}^^^ +`:"";return` +${d}${b}${s.type.toUpperCase()}: ${s.message} + +`}let u=s.type==="error"?"red":"orange";return c?.html?`
${s.type.toUpperCase()}: ${s.message}
`:`${s.type.toUpperCase()}: ${s.message}`}function _qt(s,n,r){let c="";for(let u=n-2;u<=n;u++){let d=s[u-1];d!==void 0&&(c+=sdt(d,n,r))}return c}function sdt(s,n,r){let c=r?.html?xqt(s):s;return`${yqt(String(n),4)}: ${c}${r?.html?"
":` +`}`}function yqt(s,n){let r="";for(let c=s.length;c",">").replaceAll('"',""").replaceAll("'","'")}var odt=Ve(()=>{});function Eqt(s){return Sqt(s.source)||s.id||$y(`unnamed ${s.stage}-shader`)}function Sqt(s,n="unnamed"){return/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(s)?.[1]??n}var t4,qLe=Ve(()=>{zh();rg();zD();odt();t4=class s extends ns{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(n,r){r={...r,debugShaders:r.debugShaders||n.props.debugShaders||"errors"},super(n,{id:Eqt(r),...r},s.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(){let n=this.props.debugShaders;switch(n){case"never":return;case"errors":if(this.compilationStatus==="success")return;break;case"warnings":case"always":break}try{let r=await this.getCompilationInfo();if(n==="warnings"&&r?.length===0)return;this._displayShaderLog(r,this.id)}catch(r){Qt.warn(`Shader ${this.id}: failed to fetch compilation info during debug logging`,r)()}}_displayShaderLog(n,r){if(typeof document>"u"||!document?.createElement)return;let c=r,u=`${this.stage} shader "${c}"`,d=rdt(n,this.source,{showSourceCode:"all",html:!0}),b=this.getTranslatedSource(),w=document.createElement("div");w.innerHTML=`

Compilation error in ${u}

+
+
+ +
+
${d}
`,b&&(w.innerHTML+=`

Translated Source



${b}
`),w.style.top="0",w.style.left="0",w.style.background="white",w.style.position="fixed",w.style.zIndex="9999",w.style.maxWidth="100vw",w.style.maxHeight="100vh",w.style.overflowY="auto",document.body.appendChild(w),w.querySelector(".luma-compiler-log-error")?.scrollIntoView(),w.querySelector("button#close").onclick=()=>{w.remove()},w.querySelector("button#copy").onclick=()=>{navigator.clipboard.writeText(this.source)}}static defaultProps={...ns.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0}}});var n4,adt=Ve(()=>{zh();WLe();rg();n4=class s extends ns{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(n,r={}){super(n,r,s.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(n){let r=this.colorAttachments.map(u=>u.texture.clone(n)),c=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(n);return this.device.createFramebuffer({...this.props,...n,colorAttachments:r,depthStencilAttachment:c})}resize(n){let r=!n;if(n){let[c,u]=Array.isArray(n)?n:[n.width,n.height];r=r||u!==this.height||c!==this.width,this.width=c,this.height=u}r&&(Qt.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map((r,c)=>{if(typeof r=="string"){let u=this.createColorTexture(r,c);return this.attachResource(u),u.view}return r instanceof Aa?r.view:r});let n=this.props.depthStencilAttachment;if(n)if(typeof n=="string"){let r=this.createDepthStencilTexture(n);this.attachResource(r),this.depthStencilAttachment=r.view}else n instanceof Aa?this.depthStencilAttachment=n.view:this.depthStencilAttachment=n}createColorTexture(n,r){return this.device.createTexture({id:`${this.id}-color-attachment-${r}`,usage:Aa.RENDER_ATTACHMENT,format:n,width:this.width,height:this.height,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(n){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:Aa.RENDER_ATTACHMENT|Aa.SAMPLE,format:n,width:this.width,height:this.height})}resizeAttachments(n,r){if(this.colorAttachments.forEach((c,u)=>{let d=c.texture.clone({width:n,height:r});this.destroyAttachedResource(c),this.colorAttachments[u]=d.view,this.attachResource(d.view)}),this.depthStencilAttachment){let c=this.depthStencilAttachment.texture.clone({width:n,height:r});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=c.view,this.attachResource(c)}this.updateAttachments()}static defaultProps={...ns.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null}}});var Sb,XLe=Ve(()=>{zh();Sb=class s extends ns{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";sharedRenderPipeline=null;get isPending(){return this.linkStatus==="pending"||this.vs.compilationStatus==="pending"||this.fs?.compilationStatus==="pending"}get isErrored(){return this.linkStatus==="error"||this.vs.compilationStatus==="error"||this.fs?.compilationStatus==="error"}constructor(n,r){super(n,r,s.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[],this.sharedRenderPipeline=this.props._sharedRenderPipeline||null}static defaultProps={...ns.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},varyings:void 0,bufferMode:void 0,disableWarnings:!1,_sharedRenderPipeline:void 0,_uniformBlockLayouts:[],bindings:void 0,bindGroups:void 0}}});var w$,cdt=Ve(()=>{zh();w$=class extends ns{get[Symbol.toStringTag](){return"SharedRenderPipeline"}constructor(n,r){super(n,r,{...ns.defaultProps,handle:void 0,vs:void 0,fs:void 0,varyings:void 0,bufferMode:void 0})}}});var zM,YLe=Ve(()=>{zh();zM=class s extends ns{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(n,r){super(n,r,s.defaultProps),this.shaderLayout=r.shaderLayout}static defaultProps={...ns.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0}}});var i4,ldt=Ve(()=>{YLe();XLe();rg();zD();i4=class s{static defaultProps={...Sb.defaultProps};static getDefaultPipelineFactory(n){let r=n.getModuleData("@luma.gl/core");return r.defaultPipelineFactory||=new s(n),r.defaultPipelineFactory}device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};_sharedRenderPipelineCache={};get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}constructor(n){this.device=n}createRenderPipeline(n){if(!this.device.props._cachePipelines)return this.device.createRenderPipeline(n);let r={...Sb.defaultProps,...n},c=this._renderPipelineCache,u=this._hashRenderPipeline(r),d=c[u]?.resource;if(d)c[u].useCount++,this.device.props.debugFactories&&Qt.log(3,`${this}: ${c[u].resource} reused, count=${c[u].useCount}, (id=${n.id})`)();else{let b=this.device.type==="webgl"&&this.device.props._sharePipelines?this.createSharedRenderPipeline(r):void 0;d=this.device.createRenderPipeline({...r,id:r.id?`${r.id}-cached`:$y("unnamed-cached"),_sharedRenderPipeline:b}),d.hash=u,c[u]={resource:d,useCount:1},this.device.props.debugFactories&&Qt.log(3,`${this}: ${d} created, count=${c[u].useCount}`)()}return d}createComputePipeline(n){if(!this.device.props._cachePipelines)return this.device.createComputePipeline(n);let r={...zM.defaultProps,...n},c=this._computePipelineCache,u=this._hashComputePipeline(r),d=c[u]?.resource;return d?(c[u].useCount++,this.device.props.debugFactories&&Qt.log(3,`${this}: ${c[u].resource} reused, count=${c[u].useCount}, (id=${n.id})`)()):(d=this.device.createComputePipeline({...r,id:r.id?`${r.id}-cached`:void 0}),d.hash=u,c[u]={resource:d,useCount:1},this.device.props.debugFactories&&Qt.log(3,`${this}: ${d} created, count=${c[u].useCount}`)()),d}release(n){if(!this.device.props._cachePipelines){n.destroy();return}let r=this._getCache(n),c=n.hash;r[c].useCount--,r[c].useCount===0?(this._destroyPipeline(n),this.device.props.debugFactories&&Qt.log(3,`${this}: ${n} released and destroyed`)()):r[c].useCount<0?(Qt.error(`${this}: ${n} released, useCount < 0, resetting`)(),r[c].useCount=0):this.device.props.debugFactories&&Qt.log(3,`${this}: ${n} released, count=${r[c].useCount}`)()}createSharedRenderPipeline(n){let r=this._hashSharedRenderPipeline(n),c=this._sharedRenderPipelineCache[r];return c||(c={resource:this.device._createSharedRenderPipelineWebGL(n),useCount:0},this._sharedRenderPipelineCache[r]=c),c.useCount++,c.resource}releaseSharedRenderPipeline(n){if(!n.sharedRenderPipeline)return;let r=this._hashSharedRenderPipeline(n.sharedRenderPipeline.props),c=this._sharedRenderPipelineCache[r];c&&(c.useCount--,c.useCount===0&&(c.resource.destroy(),delete this._sharedRenderPipelineCache[r]))}_destroyPipeline(n){let r=this._getCache(n);return this.device.props._destroyPipelines?(delete r[n.hash],n.destroy(),n instanceof Sb&&this.releaseSharedRenderPipeline(n),!0):!1}_getCache(n){let r;if(n instanceof zM&&(r=this._computePipelineCache),n instanceof Sb&&(r=this._renderPipelineCache),!r)throw new Error(`${this}`);if(!r[n.hash])throw new Error(`${this}: ${n} matched incorrect entry`);return r}_hashComputePipeline(n){let{type:r}=this.device,c=this._getHash(n.shader.source),u=this._getHash(JSON.stringify(n.shaderLayout));return`${r}/C/${c}SL${u}`}_hashRenderPipeline(n){let r=n.vs?this._getHash(n.vs.source):0,c=n.fs?this._getHash(n.fs.source):0,u=this._getWebGLVaryingHash(n),d=this._getHash(JSON.stringify(n.shaderLayout)),b=this._getHash(JSON.stringify(n._uniformBlockLayouts)),w=this._getHash(JSON.stringify(n.bufferLayout)),{type:_}=this.device;switch(_){case"webgl":let x=this._getHash(JSON.stringify(n.parameters));return`${_}/R/${r}/${c}V${u}T${n.topology}P${x}SL${d}UBL${b}BL${w}`;case"webgpu":default:let T=this._getHash(JSON.stringify({vertexEntryPoint:n.vertexEntryPoint,fragmentEntryPoint:n.fragmentEntryPoint})),M=this._getHash(JSON.stringify(n.parameters)),L=this._getWebGPUAttachmentHash(n);return`${_}/R/${r}/${c}V${u}T${n.topology}EP${T}P${M}SL${d}BL${w}A${L}`}}_hashSharedRenderPipeline(n){let r=n.vs?this._getHash(n.vs.source):0,c=n.fs?this._getHash(n.fs.source):0,u=this._getWebGLVaryingHash(n);return`webgl/S/${r}/${c}V${u}`}_getHash(n){return this._hashes[n]===void 0&&(this._hashes[n]=this._hashCounter++),this._hashes[n]}_getWebGLVaryingHash(n){let{varyings:r=[],bufferMode:c=null}=n;return this._getHash(JSON.stringify({varyings:r,bufferMode:c}))}_getWebGPUAttachmentHash(n){let r=n.colorAttachmentFormats??[this.device.preferredColorFormat],c=n.depthStencilAttachmentFormat??(n.parameters?.depthWriteEnabled?this.device.preferredDepthFormat:null);return this._getHash(JSON.stringify({colorAttachmentFormats:r,depthStencilAttachmentFormat:c}))}}});var r4,udt=Ve(()=>{qLe();rg();r4=class s{static defaultProps={...t4.defaultProps};static getDefaultShaderFactory(n){let r=n.getModuleData("@luma.gl/core");return r.defaultShaderFactory||=new s(n),r.defaultShaderFactory}device;_cache={};get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}constructor(n){this.device=n}createShader(n){if(!this.device.props._cacheShaders)return this.device.createShader(n);let r=this._hashShader(n),c=this._cache[r];if(c)c.useCount++,this.device.props.debugFactories&&Qt.log(3,`${this}: Reusing shader ${c.resource.id} count=${c.useCount}`)();else{let u=this.device.createShader({...n,id:n.id?`${n.id}-cached`:void 0});this._cache[r]=c={resource:u,useCount:1},this.device.props.debugFactories&&Qt.log(3,`${this}: Created new shader ${u.id}`)()}return c.resource}release(n){if(!this.device.props._cacheShaders){n.destroy();return}let r=this._hashShader(n),c=this._cache[r];if(c)if(c.useCount--,c.useCount===0)this.device.props._destroyShaders&&(delete this._cache[r],c.resource.destroy(),this.device.props.debugFactories&&Qt.log(3,`${this}: Releasing shader ${n.id}, destroyed`)());else{if(c.useCount<0)throw new Error(`ShaderFactory: Shader ${n.id} released too many times`);this.device.props.debugFactories&&Qt.log(3,`${this}: Releasing shader ${n.id} count=${c.useCount}`)()}}_hashShader(n){return`${n.stage}:${n.source}`}}});function Lce(s,n,r){let c=s.bindings.find(u=>u.name===n||`${u.name.toLocaleLowerCase()}uniforms`===n.toLocaleLowerCase());return!c&&!r?.ignoreWarnings&&Qt.warn(`Binding ${n} not set: Not found in shader layout.`)(),c||null}function s4(s,n){if(!n)return{};if(Mqt(n))return Object.fromEntries(Object.entries(n).map(([u,d])=>[Number(u),{...d}]));let r={};for(let[c,u]of Object.entries(n)){let b=Lce(s,c)?.group??0;r[b]||={},r[b][c]=u}return r}function GD(s){let n={};for(let r of Object.values(s))Object.assign(n,r);return n}function Mqt(s){let n=Object.keys(s);return n.length>0&&n.every(r=>/^\d+$/.test(r))}var fdt=Ve(()=>{rg()});var v$,hdt=Ve(()=>{zh();v$=class s extends ns{static defaultClearColor=[0,0,0,1];static defaultClearDepth=1;static defaultClearStencil=0;get[Symbol.toStringTag](){return"RenderPass"}constructor(n,r,c=s.defaultProps){r=s.normalizeProps(n,r),super(n,r,c)}static normalizeProps(n,r){return r}static defaultProps={...ns.defaultProps,framebuffer:null,resolveTargets:void 0,parameters:void 0,clearColor:s.defaultClearColor,clearColors:void 0,clearDepth:s.defaultClearDepth,clearStencil:s.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0}}});var _$,ddt=Ve(()=>{zh();_$=class s extends ns{get[Symbol.toStringTag](){return"CommandEncoder"}_timeProfilingQuerySet=null;_timeProfilingSlotCount=0;_gpuTimeMs;constructor(n,r){super(n,r,s.defaultProps),this._timeProfilingQuerySet=r.timeProfilingQuerySet??null,this._timeProfilingSlotCount=0,this._gpuTimeMs=void 0}async resolveTimeProfilingQuerySet(){if(this._gpuTimeMs=void 0,!this._timeProfilingQuerySet)return;let n=Math.floor(this._timeProfilingSlotCount/2);if(n<=0)return;let r=n*2,c=await this._timeProfilingQuerySet.readResults({firstQuery:0,queryCount:r}),u=0n;for(let d=0;d=this._timeProfilingQuerySet.props.count?r:(this._timeProfilingSlotCount+=2,{...r,timestampQuerySet:this._timeProfilingQuerySet,beginTimestampIndex:c,endTimestampIndex:c+1})}_supportsTimestampQueries(){return this.device.features.has("timestamp-query")}static defaultProps={...ns.defaultProps,measureExecutionTime:void 0,timeProfilingQuerySet:void 0}}});var y$,pdt=Ve(()=>{zh();y$=class s extends ns{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(n,r){super(n,r,s.defaultProps)}static defaultProps={...ns.defaultProps}}});var x$,gdt=Ve(()=>{zh();x$=class s extends ns{static defaultProps={...ns.defaultProps,shaderLayout:void 0,bufferLayout:[]};get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;indexBuffer=null;attributes;constructor(n,r){super(n,r,s.defaultProps),this.maxVertexAttributes=n.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null)}getBufferSlot(n){return null}getDrawValidationError(){return null}setConstantWebGL(n,r){this.device.reportError(new Error("constant attributes not supported"),this)()}}});var E$,mdt=Ve(()=>{zh();E$=class s extends ns{static defaultProps={...ns.defaultProps,layout:void 0,buffers:{}};get[Symbol.toStringTag](){return"TransformFeedback"}constructor(n,r){super(n,r,s.defaultProps)}}});var S$,bdt=Ve(()=>{zh();S$=class s extends ns{get[Symbol.toStringTag](){return"QuerySet"}constructor(n,r){super(n,r,s.defaultProps)}static defaultProps={...ns.defaultProps,type:void 0,count:void 0}}});var M$,wdt=Ve(()=>{zh();M$=class s extends ns{static defaultProps={...ns.defaultProps};get[Symbol.toStringTag](){return"Fence"}constructor(n,r={}){super(n,r,s.defaultProps)}}});function jD(s){let n=kce(s),r=Pqt[n];if(!r)throw new Error(`Unsupported variable shader type: ${s}`);return r}function vdt(s){let n=_dt(s),r=Aqt[n];if(!r)throw new Error(`Unsupported attribute shader type: ${s}`);let[c,u]=r,d=c==="i32"||c==="u32",b=c!=="u32",w=Cqt[c]*u;return{primitiveType:c,components:u,byteLength:w,integer:d,signed:b}}function Tqt(s,n){return n===1?s:`vec${n}<${s}>`}function _dt(s){return Lqt[s]||s}function kce(s){return kqt[s]||s}var ZLe,F1,Cqt,Aqt,Pqt,Lqt,kqt,T$=Ve(()=>{ZLe=class{getVariableShaderTypeInfo(n){return jD(n)}getAttributeShaderTypeInfo(n){return vdt(n)}makeShaderAttributeType(n,r){return Tqt(n,r)}resolveAttributeShaderTypeAlias(n){return _dt(n)}resolveVariableShaderTypeAlias(n){return kce(n)}};F1=new ZLe,Cqt={f32:4,f16:2,i32:4,u32:4},Aqt={f32:["f32",1],"vec2":["f32",2],"vec3":["f32",3],"vec4":["f32",4],f16:["f16",1],"vec2":["f16",2],"vec3":["f16",3],"vec4":["f16",4],i32:["i32",1],"vec2":["i32",2],"vec3":["i32",3],"vec4":["i32",4],u32:["u32",1],"vec2":["u32",2],"vec3":["u32",3],"vec4":["u32",4]},Pqt={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2":{type:"f32",components:2},"vec3":{type:"f32",components:3},"vec4":{type:"f32",components:4},"vec2":{type:"f16",components:2},"vec3":{type:"f16",components:3},"vec4":{type:"f16",components:4},"vec2":{type:"i32",components:2},"vec3":{type:"i32",components:3},"vec4":{type:"i32",components:4},"vec2":{type:"u32",components:2},"vec3":{type:"u32",components:3},"vec4":{type:"u32",components:4},"mat2x2":{type:"f32",components:4},"mat2x3":{type:"f32",components:6},"mat2x4":{type:"f32",components:8},"mat3x2":{type:"f32",components:6},"mat3x3":{type:"f32",components:9},"mat3x4":{type:"f32",components:12},"mat4x2":{type:"f32",components:8},"mat4x3":{type:"f32",components:12},"mat4x4":{type:"f32",components:16},"mat2x2":{type:"f16",components:4},"mat2x3":{type:"f16",components:6},"mat2x4":{type:"f16",components:8},"mat3x2":{type:"f16",components:6},"mat3x3":{type:"f16",components:9},"mat3x4":{type:"f16",components:12},"mat4x2":{type:"f16",components:8},"mat4x3":{type:"f16",components:12},"mat4x4":{type:"f16",components:16},"mat2x2":{type:"i32",components:4},"mat2x3":{type:"i32",components:6},"mat2x4":{type:"i32",components:8},"mat3x2":{type:"i32",components:6},"mat3x3":{type:"i32",components:9},"mat3x4":{type:"i32",components:12},"mat4x2":{type:"i32",components:8},"mat4x3":{type:"i32",components:12},"mat4x4":{type:"i32",components:16},"mat2x2":{type:"u32",components:4},"mat2x3":{type:"u32",components:6},"mat2x4":{type:"u32",components:8},"mat3x2":{type:"u32",components:6},"mat3x3":{type:"u32",components:9},"mat3x4":{type:"u32",components:12},"mat4x2":{type:"u32",components:8},"mat4x3":{type:"u32",components:12},"mat4x4":{type:"u32",components:16}},Lqt={vec2i:"vec2",vec3i:"vec3",vec4i:"vec4",vec2u:"vec2",vec3u:"vec3",vec4u:"vec4",vec2f:"vec2",vec3f:"vec3",vec4f:"vec4",vec2h:"vec2",vec3h:"vec3",vec4h:"vec4"},kqt={vec2i:"vec2",vec3i:"vec3",vec4i:"vec4",vec2u:"vec2",vec3u:"vec3",vec4u:"vec4",vec2f:"vec2",vec3f:"vec3",vec4f:"vec4",vec2h:"vec2",vec3h:"vec3",vec4h:"vec4",mat2x2f:"mat2x2",mat2x3f:"mat2x3",mat2x4f:"mat2x4",mat3x2f:"mat3x2",mat3x3f:"mat3x3",mat3x4f:"mat3x4",mat4x2f:"mat4x2",mat4x3f:"mat4x3",mat4x4f:"mat4x4",mat2x2i:"mat2x2",mat2x3i:"mat2x3",mat2x4i:"mat2x4",mat3x2i:"mat3x2",mat3x3i:"mat3x3",mat3x4i:"mat3x4",mat4x2i:"mat4x2",mat4x3i:"mat4x3",mat4x4i:"mat4x4",mat2x2u:"mat2x2",mat2x3u:"mat2x3",mat2x4u:"mat2x4",mat3x2u:"mat3x2",mat3x3u:"mat3x3",mat3x4u:"mat3x4",mat4x2u:"mat4x2",mat4x3u:"mat4x3",mat4x4u:"mat4x4",mat2x2h:"mat2x2",mat2x3h:"mat2x3",mat2x4h:"mat2x4",mat3x2h:"mat3x2",mat3x3h:"mat3x3",mat3x4h:"mat3x4",mat4x2h:"mat4x2",mat4x3h:"mat4x3",mat4x4h:"mat4x4"}});function o4(s,n={}){let r={...s},c=n.layout??"std140",u={},d=0;for(let[b,w]of Object.entries(r))d=KLe(u,b,w,d,c);return d=Eb(d,GM(r,c)),{layout:c,byteLength:d*4,uniformTypes:r,fields:u}}function C$(s,n){let r=kce(s),c=jD(r),u=/^mat(\d)x(\d)<.+>$/.exec(r);if(u){let b=Number(u[1]),w=Number(u[2]),_=ydt(w,r,c.type,n),x=Iqt(_.size,_.alignment,n);return{alignment:_.alignment,size:b*x,components:b*w,columns:b,rows:w,columnStride:x,shaderType:r,type:c.type}}let d=/^vec(\d)<.+>$/.exec(r);return d?ydt(Number(d[1]),r,c.type,n):{alignment:1,size:1,components:1,columns:1,rows:1,columnStride:1,shaderType:r,type:c.type}}function JLe(s){return!!s&&typeof s=="object"&&!Array.isArray(s)}function KLe(s,n,r,c,u){if(typeof r=="string"){let d=C$(r,u),b=Eb(c,d.alignment);return s[n]={offset:b,...d},b+d.size}if(Array.isArray(r)){if(Array.isArray(r[0]))throw new Error(`Nested arrays are not supported for ${n}`);let d=r[0],b=r[1],w=Edt(d,u),_=Eb(c,GM(r,u));for(let x=0;x{xce();T$()});function QLe(s){return(!Ice||Ice.byteLength{});function Bqt(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function $D(s){return Array.isArray(s)?s.length===0||typeof s[0]=="number":Bqt(s)}var n4e=Ve(()=>{});function Oqt(s){return!!s&&typeof s=="object"&&!Array.isArray(s)&&!ArrayBuffer.isView(s)}function Nqt(s,n,r){return Array.prototype.slice.call(s,n,r)}var Dce,Mdt=Ve(()=>{t4e();n4e();rg();Rce();Dce=class{layout;constructor(n){this.layout=n}has(n){return!!this.layout.fields[n]}get(n){let r=this.layout.fields[n];return r?{offset:r.offset,size:r.size}:void 0}getFlatUniformValues(n){let r={};for(let[c,u]of Object.entries(n)){let d=this.layout.uniformTypes[c];d?this._flattenCompositeValue(r,c,d,u):this.layout.fields[c]&&(r[c]=u)}return r}getData(n){let r=QLe(this.layout.byteLength);new Uint8Array(r,0,this.layout.byteLength).fill(0);let c={i32:new Int32Array(r),u32:new Uint32Array(r),f32:new Float32Array(r),f16:new Uint16Array(r)},u=this.getFlatUniformValues(n);for(let[d,b]of Object.entries(u))this._writeLeafValue(c,d,b);return new Uint8Array(r,0,this.layout.byteLength)}_flattenCompositeValue(n,r,c,u){if(u!==void 0){if(typeof c=="string"||this.layout.fields[r]){n[r]=u;return}if(Array.isArray(c)){let d=c[0],b=c[1];if(Array.isArray(d))throw new Error(`Nested arrays are not supported for ${r}`);if(typeof d=="string"&&$D(u)){this._flattenPackedArray(n,r,d,b,u);return}if(!Array.isArray(u)){Qt.warn(`Unsupported uniform array value for ${r}:`,u)();return}for(let w=0;w=b.length)break;_===1?n[`${r}[${x}]`]=Number(b[T]):n[`${r}[${x}]`]=Nqt(d,T,T+_)}}_writeLeafValue(n,r,c){let u=this.layout.fields[r];if(!u){Qt.warn(`Uniform ${r} not found in layout`)();return}let{type:d,components:b,columns:w,rows:_,offset:x,columnStride:T}=u,M=n[d];if(b===1){M[x]=Number(c);return}let L=c;if(w===1){for(let D=0;Dd)return!1;for(let b=0;b{n4e();Fqt=128});var Bce,Pdt=Ve(()=>{Adt();Bce=class{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(n){if(this.name=n?.name||"unnamed",n?.name&&n?.shaderLayout){let r=n?.shaderLayout.bindings?.find(u=>u.type==="uniform"&&u.name===n?.name);if(!r)throw new Error(n?.name);let c=r;for(let u of c.uniforms||[])this.bindingLayout[u.name]=u}}setUniforms(n){for(let[r,c]of Object.entries(n))this._setUniform(r,c)&&!this.needsRedraw&&this.setNeedsRedraw(`${this.name}.${r}=${c}`)}setNeedsRedraw(n){this.needsRedraw=this.needsRedraw||n}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(n,r){return Tdt(this.uniforms[n],r)?!1:(this.uniforms[n]=Cdt(r),this.modifiedUniforms[n]=!0,this.modified=!0,!0)}}});function zqt(s){return s.type==="webgpu"?"wgsl-uniform":"std140"}var Uqt,a4,Ldt=Ve(()=>{_ce();rg();Rce();Pdt();Mdt();Uqt=1024,a4=class{device;uniformBlocks=new Map;shaderBlockLayouts=new Map;shaderBlockWriters=new Map;uniformBuffers=new Map;constructor(n,r){this.device=n;for(let[c,u]of Object.entries(r)){let d=c,b=o4(u.uniformTypes??{},{layout:u.layout??zqt(n)}),w=new Dce(b);this.shaderBlockLayouts.set(d,b),this.shaderBlockWriters.set(d,w);let _=new Bce({name:c});_.setUniforms(w.getFlatUniformValues(u.defaultUniforms||{})),this.uniformBlocks.set(d,_)}}destroy(){for(let n of this.uniformBuffers.values())n.destroy()}setUniforms(n,r){for(let[c,u]of Object.entries(n)){let d=c,w=this.shaderBlockWriters.get(d)?.getFlatUniformValues(u||{});this.uniformBlocks.get(d)?.setUniforms(w||{})}this.updateUniformBuffers(r)}getUniformBufferByteLength(n){let r=this.shaderBlockLayouts.get(n)?.byteLength||0;return Math.max(r,Uqt)}getUniformBufferData(n){let r=this.uniformBlocks.get(n)?.getAllUniforms()||{};return this.shaderBlockWriters.get(n)?.getData(r)||new Uint8Array(0)}createUniformBuffer(n,r){r&&this.setUniforms(r);let c=this.getUniformBufferByteLength(n),u=this.device.createBuffer({usage:as.UNIFORM|as.COPY_DST,byteLength:c}),d=this.getUniformBufferData(n);return u.write(d),u}getManagedUniformBuffer(n){if(!this.uniformBuffers.get(n)){let r=this.getUniformBufferByteLength(n),c=this.device.createBuffer({usage:as.UNIFORM|as.COPY_DST,byteLength:r});this.uniformBuffers.set(n,c)}return this.uniformBuffers.get(n)}updateUniformBuffers(n){let r=!1;for(let c of this.uniformBlocks.keys()){let u=this.updateUniformBuffer(c,n);r||=u}return r&&Qt.log(3,`UniformStore.updateUniformBuffers(): ${r}`)(),r}updateUniformBuffer(n,r){let c=this.uniformBlocks.get(n),u=this.uniformBuffers.get(n),d=!1;if(u&&c?.needsRedraw){d||=c.needsRedraw;let b=this.getUniformBufferData(n);if(u=this.uniformBuffers.get(n),u&&(r?this.device.writeBufferViaCommandEncoder(r,u,b):u.write(b)),Qt.level>=4){let w=this.uniformBlocks.get(n)?.getAllUniforms();Qt.log(4,`Writing to uniform buffer ${String(n)}`,b,w)()}}return d}}});function VD(s){return s.attributes?s.attributes.map(n=>n.attribute):[s.name]}function i4e(s){return Object.fromEntries(s.attributes.map(n=>[n.name,n.location]))}function Oce(s){let n=1/0;for(let r of s)r!==void 0&&(n=Math.min(n,r));return n}function r4e(s,n,r){Gqt(n);let c=new Map;for(let u of n){let d=jqt(u);if(u.attributes)for(let b of u.attributes)c.has(b.attribute)||c.set(b.attribute,{bufferName:u.name,stepMode:u.stepMode,vertexFormat:b.format,byteOffset:b.byteOffset,byteStride:d});else u.format&&!c.has(u.name)&&c.set(u.name,{bufferName:u.name,stepMode:u.stepMode,vertexFormat:u.format,byteOffset:0,byteStride:d})}return s.attributes.map(u=>{let d=c.get(u.name);!d&&r?.warnOnMissingBufferLayout&&Qt.warn(`layout for attribute "${u.name}" not present in buffer layout`)();let b=F1.getAttributeShaderTypeInfo(u.type),w=d?.vertexFormat||fl.getCompatibleVertexFormat(b);return{attributeName:u.name,bufferName:d?.bufferName||u.name,location:u.location,vertexFormat:w,byteOffset:d?.byteOffset??0,byteStride:d?.byteStride??fl.getVertexFormatInfo(w).byteLength,stepMode:d?.stepMode||u.stepMode||(u.name.startsWith("instance")?"instance":"vertex")}}).sort((u,d)=>u.location-d.location)}function Gqt(s){for(let n of s)(n.attributes&&n.format||!n.attributes&&!n.format)&&Qt.warn(`BufferLayout ${n.name} must have either 'attributes' or 'format' field`)()}function jqt(s){if(typeof s.byteStride=="number")return s.byteStride;if(s.attributes){let n=0;for(let r of s.attributes)n+=fl.getVertexFormatInfo(r.format).byteLength;return n}return fl.getVertexFormatInfo(s.format).byteLength}var s4e=Ve(()=>{rg();T$();h$()});function A$(s,n){let r={},c=r4e(s,n,{warnOnMissingBufferLayout:!0});for(let u of c){let d=$qt(s,u);r[u.attributeName]=d}return r}function $qt(s,n){let r=Vqt(s,n.attributeName),c=F1.getAttributeShaderTypeInfo(r.type),u=n.vertexFormat,d=fl.getVertexFormatInfo(u);return{attributeName:n.attributeName,bufferName:n.bufferName,location:r.location,shaderType:r.type,primitiveType:c.primitiveType,shaderComponents:c.components,vertexFormat:u,bufferDataType:d.type,bufferComponents:d.components,normalized:d.normalized,integer:c.integer,stepMode:n.stepMode,byteOffset:n.byteOffset,byteStride:n.byteStride}}function Vqt(s,n){let r=s.attributes.find(c=>c.name===n);return r||Qt.warn(`shader layout attribute "${n}" not present in shader`)(),r||null}var kdt=Ve(()=>{rg();T$();h$();s4e()});var $r=Ve(()=>{Tht();Cht();Xht();edt();tdt();_ce();WLe();ndt();idt();qLe();VLe();adt();XLe();cdt();ldt();udt();hdt();YLe();ddt();pdt();gdt();mdt();bdt();wdt();Rce();Ldt();Ece();xce();T$();h$();Ace();rg();fdt();jLe();t4e();kdt();s4e()});function P$(s=[],n){let r=[],c={},u={},d={},b={};for(let w of s)Rdt({modules:r,defines:c,injections:u,vertexInputs:d,varyings:b},w),Rdt({modules:r,defines:c,injections:u,vertexInputs:d,varyings:b},w[n]);for(let w of Object.keys(b))if(d[w])throw new Error(`ShaderPlugin name "${w}" cannot be both a vertex input and a varying`);return{modules:r,defines:c,injections:u,vertexInputs:d,varyings:b}}function L$(s=[],n=[]){let r=[...s],c=new Set(r.map(u=>u.name));for(let u of n)c.has(u.name)||(r.push(u),c.add(u.name));return r}function Rdt(s,n){if(n){n.modules?.length&&s.modules.push(...n.modules),n.defines&&Object.assign(s.defines,n.defines);for(let[r,c]of Object.entries(n.vertexInputs||{})){Idt(r,"vertex input");let u=s.vertexInputs[r];if(u&&u!==c)throw new Error(`ShaderPlugin vertex input "${r}" has conflicting types "${u}" and "${c}"`);s.vertexInputs[r]=c}for(let[r,c]of Object.entries(n.varyings||{})){Idt(r,"varying");let u=Hqt(r,c),d=s.varyings[r];if(d&&(d.type!==u.type||d.interpolation!==u.interpolation))throw new Error(`ShaderPlugin varying "${r}" has conflicting declarations "${d.type}/${d.interpolation}" and "${u.type}/${u.interpolation}"`);s.varyings[r]=u}for(let r of n.injections||[])qqt(r.target),s.injections[r.target]||(s.injections[r.target]=[]),s.injections[r.target].push({injection:r.injection,order:r.order??0})}}function Idt(s,n){if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(s)||s.startsWith("_luma_"))throw new Error(`ShaderPlugin ${n} "${s}" must be a valid non-reserved identifier`)}function Hqt(s,n){let{primitiveType:r}=F1.getAttributeShaderTypeInfo(n.type),c=r==="i32"||r==="u32",u=n.interpolation||(c?"flat":"smooth");if(c&&u==="smooth")throw new Error(`ShaderPlugin integer varying "${s}" must use flat interpolation`);return{type:n.type,interpolation:u}}function qqt(s){if(!Wqt.test(s))throw new Error(`ShaderPlugin injection target "${s}" must be a named shader anchor or hook`)}var Wqt,Ddt=Ve(()=>{$r();Wqt=/^(vs|fs):(?:#(?:decl|main-start|main-end)|[A-Za-z_][\w-]*)$/});function k$(s){return`${s.name}Uniforms`}function Odt(s,n){let r=n==="wgsl"?s.source:n==="vertex"?s.vs:s.fs;if(!r)return null;let c=k$(s);return Zqt(r,n==="wgsl"?"wgsl":"glsl",c)}function Ndt(s,n){let r=Object.keys(s.uniformTypes||{});if(!r.length)return null;let c=Odt(s,n);return c?{moduleName:s.name,uniformBlockName:k$(s),stage:n,expectedUniformNames:r,actualUniformNames:c,matches:Qqt(r,c)}:null}function o4e(s,n,r={}){let c=Ndt(s,n);if(!c||c.matches)return c;let u=eXt(c);return r.log?.error?.(u,c)(),r.throwOnError!==!1&&T3(!1,u),c}function R$(s){let n=[],r=tXt(s);for(let c of r.matchAll(Yqt)){let u=c[1]?.trim()||null;n.push({blockName:c[2],body:c[3],instanceName:c[4]||null,layoutQualifier:u,hasLayoutQualifier:!!u,isStd140:!!(u&&/\blayout\s*\([^)]*\bstd140\b[^)]*\)/.exec(u))})}return n}function a4e(s,n,r,c){let u=R$(s).filter(b=>!b.isStd140),d=new Set;for(let b of u){if(d.has(b.blockName))continue;d.add(b.blockName);let w=c?.label?`${c.label} `:"",_=b.hasLayoutQualifier?`declares ${nXt(b.layoutQualifier)} instead of layout(std140)`:"does not declare layout(std140)",x=`${w}${n} shader uniform block ${b.blockName} ${_}. luma.gl host-side shader block packing assumes explicit layout(std140) for GLSL uniform blocks. Add \`layout(std140)\` to the block declaration.`;r?.warn?.(x,b)()}return u}function Zqt(s,n,r){let c=n==="wgsl"?Kqt(s,r):Jqt(s,r);if(!c)return null;let u=[];for(let d of c.split(` +`)){let b=d.replace(/\/\/.*$/,"").trim();if(!b||b.startsWith("#"))continue;let w=n==="wgsl"?b.match(/^([A-Za-z0-9_]+)\s*:/):b.match(Xqt);w&&u.push(w[1])}return u}function Kqt(s,n){let r=new RegExp(`\\bstruct\\s+${n}\\b`,"m").exec(s);if(!r)return null;let c=s.indexOf("{",r.index);if(c<0)return null;let u=0;for(let d=c;dc.blockName===n)?.body||null}function Qqt(s,n){if(s.length!==n.length)return!1;for(let r=0;r!r.includes(w)),u=r.filter(w=>!n.includes(w)),d=[`Expected ${n.length} fields, found ${r.length}.`],b=iXt(n,r);return b&&d.push(b),c.length&&d.push(`Missing from shader block (${c.length}): ${Bdt(c)}.`),u.length&&d.push(`Unexpected in shader block (${u.length}): ${Bdt(u)}.`),n.length<=12&&r.length<=12&&(c.length||u.length)&&(d.push(`Expected: ${n.join(", ")}.`),d.push(`Actual: ${r.join(", ")}.`)),`${s.moduleName}: ${s.stage} shader uniform block ${s.uniformBlockName} does not match module.uniformTypes. ${d.join(" ")}`}function tXt(s){return s.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"")}function nXt(s){return s.replace(/\s+/g," ").trim()}function iXt(s,n){let r=Math.min(s.length,n.length);for(let c=0;cn.length?`Shader block ends after field ${n.length}; expected next field ${s[n.length]}.`:n.length>s.length?`Shader block has extra field ${n.length}: ${n[s.length]}.`:null}function Bdt(s,n=8){if(s.length<=n)return s.join(", ");let r=s.length-n;return`${s.slice(0,n).join(", ")}, ... (${r} more)`}var Xqt,Yqt,c4e=Ve(()=>{pce();Xqt=/^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/,Yqt=/((?:layout\s*\([^)]*\)\s*)*)uniform\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([\s\S]*?)\}\s*([A-Za-z_][A-Za-z0-9_]*)?\s*;/g});function Fdt(s){switch(s?.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU +// Apple optimizes away the calculation necessary for emulated fp64 +#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 +#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 +// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow +#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 +`;case"nvidia":return`#define NVIDIA_GPU +// Nvidia optimizes away the calculation necessary for emulated fp64 +#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 +`;case"intel":return`#define INTEL_GPU +// Intel optimizes away the calculation necessary for emulated fp64 +#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 +// Intel's built-in 'tan' function doesn't have acceptable precision +#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 +// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow +#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 +`;case"amd":return`#define AMD_GPU +`;default:return`#define DEFAULT_GPU +// Prevent driver from optimizing away the calculation necessary for emulated fp64 +#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 +// Headless Chrome's software shader 'tan' function doesn't have acceptable precision +#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 +// If the GPU doesn't have full 32 bits precision, will causes overflow +#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 +`}}var Udt=Ve(()=>{});function Gdt(s,n){if(Number(s.match(/^#version[ \t]+(\d+)/m)?.[1]||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(n){case"vertex":return s=zdt(s,rXt),s;case"fragment":return s=zdt(s,sXt),s;default:throw new Error(n)}}function zdt(s,n){for(let[r,c]of n)s=s.replace(r,c);return s}function l4e(s){return new RegExp(`\\b${s}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}var jdt,rXt,sXt,$dt=Ve(()=>{jdt=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es +`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],rXt=[...jdt,[l4e("attribute"),"in $1"],[l4e("varying"),"out $1"]],sXt=[...jdt,[l4e("varying"),"in $1"]]});function Nce(s,n,r="glsl"){let c="";for(let u in s){let d=s[u];if(c+=`${r==="wgsl"?"fn":"void"} ${d.signature} { +`,d.header&&(c+=` ${d.header}`),n[u]){let w=n[u];w.sort((_,x)=>_.order-x.order);for(let _ of w)c+=` ${_.injection} +`}d.footer&&(c+=` ${d.footer}`),c+=`} +`}return c}function u4e(s){let n={vertex:{},fragment:{}};for(let r of s){let c,u;typeof r!="string"?(c=r,u=c.hook):(c={},u=r),u=u.trim();let d=u.indexOf(":"),b=u.slice(0,d),w=u.slice(d+1),_=u.replace(/\(.+/,""),x=Object.assign(c,{signature:w});switch(b){case"vs":n.vertex[_]=x;break;case"fs":n.fragment[_]=x;break;default:throw new Error(b)}}return n}var Vdt=Ve(()=>{});function Wdt(s,n){return{name:oXt(s,n),language:"glsl",version:aXt(s)}}function oXt(s,n="unnamed"){let c=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(s);return c?c[1]:n}function aXt(s){let n=100,r=s.match(/[^\s]+/g);if(r&&r.length>=2&&r[0]==="#version"){let c=parseInt(r[1],10);Number.isFinite(c)&&(n=c)}if(n!==100&&n!==300)throw new Error(`Invalid GLSL version ${n}`);return n}var Hdt=Ve(()=>{});function Fce(s,n=[]){let r=ND(s),c=new Map;for(let d of n)c.set(Xdt(d.name,d.group,d.location),d.moduleName);let u=[];for(let d of qdt){d.lastIndex=0;let b;for(b=d.exec(r);b;){let w=d===qdt[0],_=Number(b[w?1:2]),x=Number(b[w?2:1]),T=b[3]?.trim(),M=b[4],L=b[5].trim(),I=c.get(Xdt(M,x,_));u.push(cXt({name:M,group:x,binding:_,owner:I?"module":"application",moduleName:I,accessDeclaration:T,resourceType:L})),b=d.exec(r)}}return u.sort((d,b)=>d.group!==b.group?d.group-b.group:d.binding!==b.binding?d.binding-b.binding:d.name.localeCompare(b.name))}function cXt(s){let n={name:s.name,group:s.group,binding:s.binding,owner:s.owner,kind:"unknown",moduleName:s.moduleName,resourceType:s.resourceType};if(s.accessDeclaration){let r=s.accessDeclaration.split(",").map(c=>c.trim());if(r[0]==="uniform")return{...n,kind:"uniform",access:"uniform"};if(r[0]==="storage"){let c=r[1]||"read_write";return{...n,kind:c==="read"?"read-only-storage":"storage",access:c}}}return s.resourceType==="sampler"||s.resourceType==="sampler_comparison"?{...n,kind:"sampler",samplerKind:s.resourceType==="sampler_comparison"?"comparison":"filtering"}:s.resourceType.startsWith("texture_storage_")?{...n,kind:"storage-texture",access:uXt(s.resourceType),viewDimension:Ydt(s.resourceType)}:s.resourceType.startsWith("texture_")?{...n,kind:"texture",viewDimension:Ydt(s.resourceType),sampleType:lXt(s.resourceType),multisampled:s.resourceType.startsWith("texture_multisampled_")}:n}function Xdt(s,n,r){return`${n}:${r}:${s}`}function Ydt(s){if(s.includes("cube_array"))return"cube-array";if(s.includes("2d_array"))return"2d-array";if(s.includes("cube"))return"cube";if(s.includes("3d"))return"3d";if(s.includes("2d"))return"2d";if(s.includes("1d"))return"1d"}function lXt(s){if(s.startsWith("texture_depth_"))return"depth";if(s.includes(""))return"sint";if(s.includes(""))return"uint";if(s.includes(""))return"float"}function uXt(s){return/,\s*([A-Za-z_][A-Za-z0-9_]*)\s*>$/.exec(s)?.[1]}var qdt,f4e=Ve(()=>{uce();qdt=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${N1}\\s*:\\s*([^;]+);`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(\\d+)\\s*\\)\\s*${N1}\\s*:\\s*([^;]+);`,"g")]});function l4(s,n){let r=s.split(` +`),c=[],u=[],d=!0;for(let b of r){let w=b.match(fXt),_=b.match(mXt)||b.match(hXt),x=b.match(dXt),T=b.match(pXt),M=b.match(bXt)||b.match(gXt);if(w){let L=wXt(w[1],n?.defines||{}),I=d&&L;u.push({parentActive:d,branchTaken:L,active:I}),d=I}else if(_||x){let L=(_||x)?.[1],I=!!n?.defines?.[L],D=_?I:!I,F=d&&D;u.push({parentActive:d,branchTaken:D,active:F}),d=F}else if(T){let L=u[u.length-1];if(!L)throw new Error("Encountered #else without matching #if, #ifdef or #ifndef");L.active=L.parentActive&&!L.branchTaken,L.branchTaken=!0,d=L.active}else M?(u.pop(),d=u.length?u[u.length-1].active:!0):d&&c.push(b)}if(u.length>0)throw new Error("Unterminated conditional block in shader source");return c.join(` +`)}function wXt(s,n){let r=s.trim();if(/^[+-]?\d+(?:\.\d+)?$/.test(r))return Number(r)!==0;if(r==="true")return!0;if(r==="false")return!1;let c=r.match(new RegExp(`^!\\s*${c4}$`));if(c)return!n[c[1]];let u=r.match(new RegExp(`^${c4}$`));if(u)return!!n[u[1]];let d=r.match(new RegExp(`^defined\\s*\\(\\s*${c4}\\s*\\)$`));if(d)return n[d[1]]!==void 0;let b=r.match(new RegExp(`^!\\s*defined\\s*\\(\\s*${c4}\\s*\\)$`));if(b)return n[b[1]]===void 0;throw new Error(`Unsupported #if expression "${s}"`)}var c4,fXt,hXt,dXt,pXt,gXt,mXt,bXt,h4e=Ve(()=>{c4="([a-zA-Z_][a-zA-Z0-9_]*)",fXt=/^\s*\#\s*if\s+(.+?)\s*(?:\/\/.*)?$/,hXt=new RegExp(`^\\s*\\#\\s*ifdef\\s*${c4}\\s*$`),dXt=new RegExp(`^\\s*\\#\\s*ifndef\\s*${c4}\\s*(?:\\/\\/.*)?$`),pXt=/^\s*\#\s*else\s*(?:\/\/.*)?$/,gXt=/^\s*\#\s*endif\s*$/,mXt=new RegExp(`^\\s*\\#\\s*ifdef\\s*${c4}\\s*(?:\\/\\/.*)?$`),bXt=/^\s*\#\s*endif\s*(?:\/\/.*)?$/});function Jdt(s,n){let r=[];for(let[c,u]of Object.entries(n))vXt(s,c),r.push(`in ${Uce(u)} ${c};`);return r.join(` +`)}function Qdt(s,n,r){let c=Object.entries(r);if(c.length===0)return{source:s,declarations:"",initialization:""};let u=_Xt(s,n),d=s.slice(u.openParenthesis+1,u.closeParenthesis),b=yXt(s,d),w=new Set(b.locations),_=[],x=[],T=[];for(let[F,O]of c){if(b.names.has(F)||SXt(s,F))throw new Error(`ShaderPlugin vertex input "${F}" conflicts with an existing WGSL shader input or variable`);let z=MXt(w);w.add(z);let Z=`_luma_${F}`;_.push(`@location(${z}) ${Z}: ${O}`),x.push(`var ${F}: ${O};`),T.push(`${F} = ${Z};`)}let M=d.trim()?`, + `:` + `,L=d.trim()?"":` +`,I=`${d}${M}${_.join(`, + `)}${L}`;return{source:s.slice(0,u.openParenthesis+1)+I+s.slice(u.closeParenthesis),declarations:x.join(` +`),initialization:T.join(` +`)}}function Uce(s){let{primitiveType:n,components:r}=F1.getAttributeShaderTypeInfo(s),c=n==="i32"?"int":n==="u32"?"uint":"float";return r===1?c:`${c==="int"?"i":c==="uint"?"u":""}vec${r}`}function vXt(s,n){let r=zce(n);if(new RegExp(`\\b(?:in|attribute)\\s+(?:(?:lowp|mediump|highp)\\s+)?[A-Za-z_][A-Za-z0-9_]*\\s+${r}\\s*(?:\\[|;)`).test(s))throw new Error(`ShaderPlugin vertex input "${n}" conflicts with an existing GLSL input`)}function _Xt(s,n){let c=new RegExp(`\\bfn\\s+${zce(n)}\\s*\\(`,"g").exec(s);if(!c)throw new Error(`ShaderPlugin vertex inputs require WGSL vertex entry point "${n}"`);let u=s.indexOf("(",c.index),d=ept(s,u,"(",")");if(d<0)throw new Error(`Unable to parse WGSL vertex entry point "${n}" parameters`);return{openParenthesis:u,closeParenthesis:d}}function yXt(s,n){let r=Zdt(n),c=new Set(Kdt(n)),u=xXt(n);for(let d of u){let b=EXt(s,d);if(b!==null){r.push(...Zdt(b));for(let w of Kdt(b))c.add(w)}}return{locations:r,names:c}}function Zdt(s){let n=[],r=/@location\s*\(\s*(\d+)\s*\)/g,c=r.exec(s);for(;c;)n.push(Number(c[1])),c=r.exec(s);return n}function Kdt(s){let n=[],r=/(?:^|,)\s*(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:/gm,c=r.exec(s);for(;c;)n.push(c[1]),c=r.exec(s);return n}function xXt(s){let n=[],r=/:\s*([A-Za-z_][\w]*)\b/g,c=r.exec(s);for(;c;)n.push(c[1]),c=r.exec(s);return n}function EXt(s,n){let c=new RegExp(`\\bstruct\\s+${zce(n)}\\s*\\{`,"g").exec(s);if(!c)return null;let u=s.indexOf("{",c.index),d=ept(s,u,"{","}");return d<0?null:s.slice(u+1,d)}function SXt(s,n){let r=zce(n),c=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${r}\\b`,"g"),u=c.exec(s);for(;u;){if(TXt(s,u.index)===0)return!0;u=c.exec(s)}return!1}function MXt(s){let n=0;for(;s.has(n);)n++;return n}function ept(s,n,r,c){let u=0,d=0,b=!1;for(let w=n;w0){_==="/"&&x==="*"?(d++,w++):_==="*"&&x==="/"&&(d--,w++);continue}if(_==="/"&&x==="/"){b=!0,w++;continue}if(_==="/"&&x==="*"){d=1,w++;continue}if(_===r&&u++,_===c&&--u===0)return w}return-1}function TXt(s,n){let r=0,c=0,u=!1;for(let d=0;d0){b==="/"&&w==="*"?(c++,d++):b==="*"&&w==="/"&&(c--,d++);continue}b==="/"&&w==="/"?(u=!0,d++):b==="/"&&w==="*"?(c=1,d++):b==="{"?r++:b==="}"&&r--}return r}function zce(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var d4e=Ve(()=>{$r()});function npt(s,n,r){let c=[],u=[];for(let[d,b]of Object.entries(r)){UXt(s,d);let w=b.interpolation==="flat"?"flat ":"",_=n==="vertex"?"out":"in";c.push(`${w}${_} ${Uce(b.type)} ${d};`),n==="vertex"&&u.push(`${d} = ${NXt(b.type)};`)}return{declarations:c.join(` +`),initialization:u.join(` +`)}}function ipt(s,n,r,c){let u=Object.entries(c);if(u.length===0)return{source:s,declarations:"",vertexInitialization:"",fragmentInitialization:""};let d=s,b=Gce(d,n,"vertex"),w=CXt(d,b),_=Gce(d,r,"fragment"),x=AXt(d,_),T=p4e(d,w),M=p4e(d,x.type),L=new Set([...jce(b.parameters),...jce(T.body),...jce(_.parameters),...jce(M.body)]),I=new Set([...tpt(T.body),...tpt(M.body)]),D=[],F=[],O=[],z=[];for(let[se,ne]of u){if(L.has(se)||BXt(d,se))throw new Error(`ShaderPlugin varying "${se}" conflicts with existing WGSL stage I/O or a module variable`);let ue=OXt(I);I.add(ue);let Ce=ne.interpolation==="flat"?" @interpolate(flat)":"";D.push(` @location(${ue})${Ce} ${se}: ${ne.type},`),F.push(`var ${se}: ${ne.type};`),O.push(`${se} = ${FXt(ne.type)};`),z.push(`${se} = ${x.name}.${se};`)}PXt(d,w,b.openBrace,b.closeBrace),d=LXt(d,w,b,u.map(([se])=>se)),b=Gce(d,n,"vertex"),d=kXt(d,b,u.map(([se])=>se));let H=(w===x.type?[w]:[w,x.type]).map(se=>p4e(d,se).closeBrace).sort((se,ne)=>ne-se);for(let se of H)d=d.slice(0,se)+`${D.join(` +`)} +`+d.slice(se);if(_=Gce(d,r,"fragment"),!new RegExp(`\\b${u4(x.name)}\\s*:`).test(_.parameters))throw new Error(`Unable to preserve WGSL fragment input "${x.name}"`);return{source:d,declarations:F.join(` +`),vertexInitialization:O.join(` +`),fragmentInitialization:z.join(` +`)}}function Gce(s,n,r){let u=new RegExp(`\\bfn\\s+${u4(n)}\\s*\\(`,"g").exec(s);if(!u)throw new Error(`ShaderPlugin varyings require WGSL ${r} entry point "${n}"`);let d=s.indexOf("(",u.index),b=$ce(s,d,"(",")"),w=s.indexOf("{",b),_=$ce(s,w,"{","}");if(b<0||w<0||_<0)throw new Error(`Unable to parse WGSL ${r} entry point "${n}"`);return{openParenthesis:d,closeParenthesis:b,openBrace:w,closeBrace:_,parameters:s.slice(d+1,b)}}function CXt(s,n){let r=s.slice(n.closeParenthesis+1,n.openBrace),c=/->\s*([A-Za-z_][\w]*)\s*$/.exec(r.trim());if(!c||g4e(s,c[1])===null)throw new Error("ShaderPlugin varyings require the WGSL vertex entry point to return a named struct");return c[1]}function AXt(s,n){let r=[];for(let c of DXt(n.parameters,",")){let u=/(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:\s*([A-Za-z_][\w]*)\s*$/.exec(c.trim());u&&g4e(s,u[2])&&r.push({name:u[1],type:u[2]})}if(r.length!==1)throw new Error(`ShaderPlugin varyings require exactly one named WGSL fragment input struct; found ${r.length}`);return r[0]}function p4e(s,n){let r=g4e(s,n);if(!r)throw new Error(`Unable to find WGSL stage I/O struct "${n}"`);return r}function g4e(s,n){let c=new RegExp(`\\bstruct\\s+${u4(n)}\\s*\\{`,"g").exec(s);if(!c)return null;let u=s.indexOf("{",c.index),d=$ce(s,u,"{","}");return d<0?null:{openBrace:u,closeBrace:d,body:s.slice(u+1,d)}}function PXt(s,n,r,c){let u=new RegExp(`\\b${u4(n)}\\s*\\(`,"g"),d=u.exec(s);for(;d;){if(d.indexc)throw new Error(`ShaderPlugin varying output struct "${n}" is constructed outside the selected vertex entry point`);d=u.exec(s)}}function LXt(s,n,r,c){let u=new RegExp(`\\b${u4(n)}\\s*\\(`,"g"),d=[],b=u.exec(s);for(;b;){if(b.index>r.openBrace&&b.indexr.closeBrace)throw new Error(`Unable to parse WGSL output constructor "${n}"`);d.push({openParenthesis:w,closeParenthesis:_})}b=u.exec(s)}for(let w of d.sort((_,x)=>x.closeParenthesis-_.closeParenthesis)){let x=s.slice(w.openParenthesis+1,w.closeParenthesis).trim()?", ":"";s=s.slice(0,w.closeParenthesis)+x+c.join(", ")+s.slice(w.closeParenthesis)}return s}function kXt(s,n,r){let c=RXt(s,n.openBrace+1,n.closeBrace);for(let u=c.length-1;u>=0;u--){let d=c[u],b=s.slice(d.expressionStart,d.semicolon).trim();if(!b)throw new Error("ShaderPlugin varying vertex entry point cannot use an empty return");let w=`_luma_vertexOutput${u}`,_=r.map(T=>`${w}.${T} = ${T};`).join(` +`),x=`{ +var ${w} = ${b}; +${_} +return ${w}; +}`;s=s.slice(0,d.start)+x+s.slice(d.semicolon+1)}return s}function RXt(s,n,r){let c=[],u=n;for(;ur?r:u+1}if(s[c]==="/"&&s[c+1]==="*"){let u=1;for(c+=2;c0;)s[c]==="/"&&s[c+1]==="*"?(u++,c+=2):s[c]==="*"&&s[c+1]==="/"?(u--,c+=2):c++}return c}function DXt(s,n){let r=[],c=0,u=0,d=0;for(let b=0;b"&&d--,w===n&&u===0&&d===0&&(r.push(s.slice(c,b)),c=b+1)}return r.push(s.slice(c)),r}function tpt(s){let n=[],r=/@location\s*\(\s*(\d+)\s*\)/g,c=r.exec(s);for(;c;)n.push(Number(c[1])),c=r.exec(s);return n}function jce(s){let n=[],r=/(?:^|,)\s*(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:/gm,c=r.exec(s);for(;c;)n.push(c[1]),c=r.exec(s);return n}function BXt(s,n){let r=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${u4(n)}\\b`,"g"),c=r.exec(s);for(;c;){if(zXt(s,c.index)===0)return!0;c=r.exec(s)}return!1}function OXt(s){let n=0;for(;s.has(n);)n++;return n}function NXt(s){let{primitiveType:n,components:r}=F1.getAttributeShaderTypeInfo(s),c=n==="u32"?"0u":n==="i32"?"0":"0.0";return r===1?c:`${Uce(s)}(${c})`}function FXt(s){let{primitiveType:n,components:r}=F1.getAttributeShaderTypeInfo(s),c=`${n}(0)`;return r===1?c:`${s}(${c})`}function UXt(s,n){if(new RegExp(`\\b(?:flat\\s+|smooth\\s+)?(?:in|out|varying)\\s+(?:(?:lowp|mediump|highp)\\s+)?[A-Za-z_][A-Za-z0-9_]*\\s+${u4(n)}\\s*(?:\\[|;)`).test(s))throw new Error(`ShaderPlugin varying "${n}" conflicts with existing GLSL stage I/O`)}function $ce(s,n,r,c){let u=0,d=0,b=!1;for(let w=n;w0){_==="/"&&x==="*"?(d++,w++):_==="*"&&x==="/"&&(d--,w++);continue}if(_==="/"&&x==="/"){b=!0,w++;continue}if(_==="/"&&x==="*"){d=1,w++;continue}if(_===r&&u++,_===c&&--u===0)return w}return-1}function zXt(s,n){let r=0;for(let c=0;c{$r();d4e()});function apt(s){let n=ZL(s.modules||[]),{source:r,bindingAssignments:c}=jXt(s.platformInfo,{...s,source:s.source,stage:"vertex",modules:n});return{source:r,getUniforms:lpt(n),bindingAssignments:c,bindingTable:Fce(r,c),shaderLayout:hce(r,{vertexEntryPoint:s.vertexEntryPoint,scanVertexAttributes:s.scanVertexAttributes})}}function cpt(s){let{vs:n,fs:r}=s,c=ZL(s.modules||[]);return{vs:spt(s.platformInfo,{...s,source:n,stage:"vertex",modules:c}),fs:spt(s.platformInfo,{...s,source:r,stage:"fragment",modules:c}),getUniforms:lpt(c)}}function jXt(s,n){let{source:r,stage:c,modules:u,defines:d={},hookFunctions:b=[],inject:w={},pluginInjections:_={},pluginVertexInputs:x={},pluginVaryings:T={},vertexEntryPoint:M="vertexMain",fragmentEntryPoint:L="fragmentMain",log:I}=n;T3(typeof r=="string","shader source must be a string");let D=l4(r,{defines:d}),F=Qdt(D,M,x),O=ipt(F.source,M,L,T),z=O.source,Z="",H=u4e(b),te={},se={},ne={};upt(_,te,se,ne);for(let st in w){let at=typeof w[st]=="string"?{injection:w[st],order:0}:w[st],Ne=/^(v|f)s:(#)?([\w-]+)$/.exec(st);if(Ne){let Qe=Ne[2],ot=Ne[3];Qe?ot==="decl"?se[st]=[at]:ne[st]=[at]:te[st]=[at]}else ne[st]=[at]}$Xt(F.declarations,F.initialization,se,ne),VXt(O,se,ne);let ue=u,Ce=ZXt(z),Q=YXt(Ce.source),me=eYt(ue,n._bindingRegistry,Q,d),tt=[];for(let st of ue){I&&xLe(st,z,I);let at=l4(fpt(st,"wgsl",I),{defines:d}),Ne=KXt(at,st,{usedBindingsByGroup:Q,bindingRegistry:n._bindingRegistry,reservedBindingKeysByGroup:me});tt.push(...Ne.bindingAssignments);let Qe=Ne.source;Z+=Qe;let ot=WXt(st);for(let xt in ot){let fn=/^(v|f)s:#([\w-]+)$/.exec(xt);if(fn){let wn=fn[2]==="decl"?se:ne;wn[xt]=wn[xt]||[],wn[xt].push(ot[xt])}else te[xt]=te[xt]||[],te[xt].push(ot[xt])}}return Z+=b4e,Z=l$(Z,c,HXt(se),!1,"wgsl",{vertex:M,fragment:L}),Z+=qXt(H,te),Z+=oYt(tt),Z+=Ce.source,Z=l$(Z,c,ne,!1,"wgsl",{vertex:M,fragment:L}),sYt(Z),{source:Z,bindingAssignments:tt}}function spt(s,n){let{source:r,stage:c,language:u="glsl",modules:d,defines:b={},hookFunctions:w=[],inject:_={},pluginInjections:x={},pluginVertexInputs:T={},pluginVaryings:M={},prologue:L=!0,log:I}=n;T3(typeof r=="string","shader source must be a string");let D=u==="glsl"?Wdt(r).version:-1,F=s.shaderLanguageVersion,O=D===100?"#version 100":"#version 300 es",Z=r.split(` +`).slice(1).join(` +`),H={};d.forEach(me=>{Object.assign(H,me.defines)}),Object.assign(H,b);let te="";switch(u){case"wgsl":break;case"glsl":te=L?`${O} + +// ----- PROLOGUE ------------------------- +${`#define SHADER_TYPE_${c.toUpperCase()}`} + +${Fdt(s)} +${c==="fragment"?GXt:""} + +// ----- APPLICATION DEFINES ------------------------- + +${XXt(H)} + +`:`${O} +`;break}let se=u4e(w),ne={},ue={},Ce={};upt(x,ne,ue,Ce);for(let me in _){let tt=typeof _[me]=="string"?{injection:_[me],order:0}:_[me],st=/^(v|f)s:(#)?([\w-]+)$/.exec(me);if(st){let at=st[2],Ne=st[3];at?Ne==="decl"?ue[me]=[tt]:Ce[me]=[tt]:ne[me]=[tt]}else Ce[me]=[tt]}if(c==="vertex"){let me=Jdt(Z,T);me&&(ue["vs:#decl"]=ue["vs:#decl"]||[],ue["vs:#decl"].push({injection:me,order:Number.MIN_SAFE_INTEGER}))}let Q=npt(Z,c,M);if(Q.declarations){let me=c==="vertex"?"vs:#decl":"fs:#decl";ue[me]=ue[me]||[],ue[me].push({injection:Q.declarations,order:Number.MIN_SAFE_INTEGER})}Q.initialization&&(Ce["vs:#main-start"]=Ce["vs:#main-start"]||[],Ce["vs:#main-start"].push({injection:Q.initialization,order:Number.MIN_SAFE_INTEGER}));for(let me of d){I&&xLe(me,Z,I);let tt=fpt(me,c,I);te+=tt;let st=me.instance?.normalizedInjections[c]||{};for(let at in st){let Ne=/^(v|f)s:#([\w-]+)$/.exec(at);if(Ne){let ot=Ne[2]==="decl"?ue:Ce;ot[at]=ot[at]||[],ot[at].push(st[at])}else ne[at]=ne[at]||[],ne[at].push(st[at])}}return te+="// ----- MAIN SHADER SOURCE -------------------------",te+=b4e,te=l$(te,c,ue),te+=Nce(se[c],ne),te+=Z,te=l$(te,c,Ce),u==="glsl"&&D!==F&&(te=Gdt(te,c)),u==="glsl"&&a4e(te,c,I),te.trim()}function lpt(s){return function(r){let c={};for(let u of s){let d=u.getUniforms?.(r,c);Object.assign(c,d)}return c}}function upt(s,n,r,c){for(let u in s){let d=/^(v|f)s:(#)?([\w-]+)$/.exec(u);if(d){let b=d[2],w=d[3],_=b?w==="decl"?r:c:n;_[u]=_[u]||[],_[u].push(...s[u])}else c[u]=c[u]||[],c[u].push(...s[u])}}function $Xt(s,n,r,c){s&&(r["vs:#decl"]=r["vs:#decl"]||[],r["vs:#decl"].push({injection:s,order:Number.MIN_SAFE_INTEGER})),n&&(c["vs:#main-start"]=c["vs:#main-start"]||[],c["vs:#main-start"].push({injection:n,order:Number.MIN_SAFE_INTEGER}))}function VXt(s,n,r){s.declarations&&(n["vs:#decl"]=n["vs:#decl"]||[],n["vs:#decl"].push({injection:s.declarations,order:Number.MIN_SAFE_INTEGER})),s.vertexInitialization&&(r["vs:#main-start"]=r["vs:#main-start"]||[],r["vs:#main-start"].push({injection:s.vertexInitialization,order:Number.MIN_SAFE_INTEGER})),s.fragmentInitialization&&(r["fs:#main-start"]=r["fs:#main-start"]||[],r["fs:#main-start"].push({injection:s.fragmentInitialization,order:Number.MIN_SAFE_INTEGER}))}function WXt(s){return{...s.instance?.normalizedInjections.vertex||{},...s.instance?.normalizedInjections.fragment||{}}}function HXt(s){let n=[...s["vs:#decl"]||[],...s["fs:#decl"]||[]];return n.length?{"vs:#decl":n}:{}}function qXt(s,n){return Nce(s.vertex,n,"wgsl")+Nce(s.fragment,n,"wgsl")}function XXt(s={}){let n="";for(let r in s){let c=s[r];(c||Number.isFinite(c))&&(n+=`#define ${r.toUpperCase()} ${s[r]} +`)}return n}function fpt(s,n,r){let c;switch(n){case"vertex":c=s.vs||"";break;case"fragment":c=s.fs||"";break;case"wgsl":c=s.source||"";break;default:T3(!1)}if(!s.name)throw new Error("Shader module must have a name");o4e(s,n,{log:r});let u=s.name.toUpperCase().replace(/[^0-9a-z]/gi,"_"),d=`// ----- MODULE ${s.name} --------------- + +`;return n!=="wgsl"&&(d+=`#define MODULE_${u} +`),d+=`${c} +`,d}function YXt(s){let n=new Map;for(let r of YL(s,oht)){let c=Number(r.bindingToken),u=Number(r.groupToken);w4e(u,c,r.name),WD(n,u,c,`application binding "${r.name}"`)}return n}function ZXt(s){let n=YL(s,lce),r=new Map;for(let d of n){if(d.bindingToken==="auto")continue;let b=Number(d.bindingToken),w=Number(d.groupToken);w4e(w,b,d.name),WD(r,w,b,`application binding "${d.name}"`)}let c={sawSupportedBindingDeclaration:n.length>0},u=hLe(s,lce,d=>QXt(d,r,c));if(dLe(s)&&!c.sawSupportedBindingDeclaration)throw new Error('Unsupported @binding(auto) declaration form in application WGSL. Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.');return{source:u}}function KXt(s,n,r){let c=[],d={sawSupportedBindingDeclaration:YL(s,OD).length>0,nextHintedBindingLocation:typeof n.firstBindingSlot=="number"?n.firstBindingSlot:null},b=hLe(s,OD,w=>JXt(w,{module:n,context:r,bindingAssignments:c,relocationState:d}));if(dLe(s)&&!d.sawSupportedBindingDeclaration)throw new Error(`Unsupported @binding(auto) declaration form in module "${n.name}". Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.`);return{source:b,bindingAssignments:c}}function JXt(s,n){let{module:r,context:c,bindingAssignments:u,relocationState:d}=n,{match:b,bindingToken:w,groupToken:_,name:x}=s,T=Number(_);if(w==="auto"){let L=hpt(T,r.name,x),I=c.bindingRegistry?.get(L),D=I!==void 0?I:iYt(T,c.usedBindingsByGroup,r.name,d.nextHintedBindingLocation??void 0,c.bindingRegistry);return opt(r.name,T,D,x),I!==void 0&&tYt(c.reservedBindingKeysByGroup,T,D,L)?(u.push({moduleName:r.name,name:x,group:T,location:D}),b.replace(/@binding\(\s*auto\s*\)/,`@binding(${D})`)):(WD(c.usedBindingsByGroup,T,D,`module "${r.name}" binding "${x}"`),c.bindingRegistry?.set(L,D),u.push({moduleName:r.name,name:x,group:T,location:D}),d.nextHintedBindingLocation!==null&&I===void 0&&(d.nextHintedBindingLocation=D+1),b.replace(/@binding\(\s*auto\s*\)/,`@binding(${D})`))}let M=Number(w);return opt(r.name,T,M,x),WD(c.usedBindingsByGroup,T,M,`module "${r.name}" binding "${x}"`),u.push({moduleName:r.name,name:x,group:T,location:M}),b}function QXt(s,n,r){let{match:c,bindingToken:u,groupToken:d,name:b}=s,w=Number(d);if(u==="auto"){let _=rYt(w,n);return w4e(w,_,b),WD(n,w,_,`application binding "${b}"`),c.replace(/@binding\(\s*auto\s*\)/,`@binding(${_})`)}return r.sawSupportedBindingDeclaration=!0,c}function eYt(s,n,r,c){let u=new Map;if(!n)return u;for(let d of s)for(let b of nYt(d,c)){let w=hpt(b.group,d.name,b.name),_=n.get(w);if(_!==void 0){let x=u.get(b.group)||new Map,T=x.get(_);if(T&&T!==w)throw new Error(`Duplicate WGSL binding reservation for modules "${T}" and "${w}": group ${b.group}, binding ${_}.`);WD(r,b.group,_,`registered module binding "${w}"`),x.set(_,w),u.set(b.group,x)}}return u}function tYt(s,n,r,c){let u=s.get(n);if(!u)return!1;let d=u.get(r);if(!d)return!1;if(d!==c)throw new Error(`Registered module binding "${c}" collided with "${d}": group ${n}, binding ${r}.`);return!0}function nYt(s,n){let r=[],c=l4(s.source||"",{defines:n});for(let u of YL(c,OD))r.push({name:u.name,group:Number(u.groupToken)});return r}function w4e(s,n,r){if(s===0&&n>=I$)throw new Error(`Application binding "${r}" in group 0 uses reserved binding ${n}. Application-owned explicit group-0 bindings must stay below ${I$}.`)}function opt(s,n,r,c){if(n===0&&r0?Math.max(...d)+1:0);for(;d.has(x)||b.has(x);)x++;for(let[T,M]of u||[])M===x&&T.startsWith(w)&&u?.delete(T);return x}function rYt(s,n){let r=n.get(s)||new Set,c=0;for(;r.has(c);)c++;return c}function sYt(s){let n=aht(s,OD);if(!n)return;let r=aYt(s,n.index);throw r?new Error(`Unresolved @binding(auto) for module "${r}" binding "${n.name}" remained in assembled WGSL source.`):cYt(s,n.index)?new Error(`Unresolved @binding(auto) for application binding "${n.name}" remained in assembled WGSL source.`):new Error(`Unresolved @binding(auto) remained in assembled WGSL source near "${lYt(n.match)}".`)}function oYt(s){if(s.length===0)return"";let n=`// ----- MODULE WGSL BINDING ASSIGNMENTS --------------- +`;for(let r of s)n+=`// ${r.moduleName}.${r.name} -> @group(${r.group}) @binding(${r.location}) +`;return n+=` +`,n}function hpt(s,n,r){return`${s}:${n}:${r}`}function aYt(s,n){let r=/^\/\/ ----- MODULE ([^\n]+) ---------------$/gm,c,u;for(u=r.exec(s);u&&u.index<=n;)c=u[1],u=r.exec(s);return c}function cYt(s,n){let r=s.indexOf(b4e);return r>=0?n>r:!0}function lYt(s){return s.replace(/\s+/g," ").trim()}var b4e,I$,GXt,dpt=Ve(()=>{ELe();Udt();yLe();$dt();mce();c4e();Vdt();pce();Hdt();f4e();wLe();h4e();d4e();rpt();uce();b4e=` + +${c$} +`,I$=100,GXt=`precision highp float; +`});var Mb,HD,jM,ppt=Ve(()=>{mce();dpt();f4e();h4e();wLe();pce();Mb=class s{static defaultShaderAssemblers={};_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(n){return T3(n==="glsl"||n==="wgsl"),n==="wgsl"?(s.defaultShaderAssemblers.wgsl=s.defaultShaderAssemblers.wgsl||new jM,s.defaultShaderAssemblers.wgsl):(s.defaultShaderAssemblers.glsl=s.defaultShaderAssemblers.glsl||new HD,s.defaultShaderAssemblers.glsl)}addDefaultModule(n){this._defaultModules.find(r=>r.name===(typeof n=="string"?n:n.name))||this._defaultModules.push(n)}removeDefaultModule(n){let r=typeof n=="string"?n:n.name;this._defaultModules=this._defaultModules.filter(c=>c.name!==r)}addShaderHook(n,r){r&&(n=Object.assign(r,{hook:n})),this._hookFunctions.push(n)}_getModuleList(n=[]){let r=new Array(this._defaultModules.length+n.length),c={},u=0;for(let d=0,b=this._defaultModules.length;d(Object.assign(c,u.defines),c),{}),...n.defines}}static getPlatformPreprocessorDefines(n){let r=n.limits||{};return{LUMA_SUPPORTS_VERTEX_STORAGE_BUFFERS:n.type==="webgpu"&&(r.maxStorageBuffersInVertexStage||0)>0,LUMA_FP32_TAN_PRECISION_WORKAROUND:n.type==="webgpu"&&n.gpu.toLowerCase()!=="nvidia"&&n.gpu.toLowerCase()!=="amd",LUMA_FP64_INTEGER_ARITHMETIC:n.type==="webgpu"&&n.gpu.toLowerCase()==="apple"}}}});function v4e(s){let{input:n,inputChannels:r,output:c}=s||{};if(!n)return fYt;if(!r)throw new Error("inputChannels");let u=hYt(r),d=gpt(n,r);return`#version 300 es +in ${u} ${n}; +out vec4 ${c}; +void main() { + ${c} = ${d}; +}`}function hYt(s){switch(s){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${s}`)}}function gpt(s,n){switch(n){case 1:return`vec4(${s}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${s}, 0.0, 1.0)`;case 3:return`vec4(${s}, 1.0)`;case 4:return s;default:throw new Error(`invalid channels: ${n}`)}}var uYt,fYt,mpt=Ve(()=>{uYt=`out vec4 transform_output; +void main() { + transform_output = vec4(0); +}`,fYt=`#version 300 es +${uYt}`});function _4e(s,{precision:n=Gh.precision}={}){return s=pYt(s),`${parseFloat(s.toPrecision(n))}`}function A3(s){return Array.isArray(s)||ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Zl(s,n,r){return mYt(s,c=>Math.max(n,Math.min(r,c)))}function av(s,n,r){return A3(s)?s.map((c,u)=>av(c,n[u],r)):r*n+(1-r)*s}function Wy(s,n,r){let c=Gh.EPSILON;r&&(Gh.EPSILON=r);try{if(s===n)return!0;if(A3(s)&&A3(n)){if(s.length!==n.length)return!1;for(let u=0;u{X7n=1/Math.PI*180,Y7n=1/180*Math.PI,dYt={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...dYt}};Gh=globalThis.mathgl.config});var XD,y4e=Ve(()=>{qD();XD=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(n,r=0){for(let c=0;c0?", ":"")+_4e(this[c],n);return`${n.printTypes?this.constructor.name:""}[${r}]`}equals(n){if(!n||this.length!==n.length)return!1;for(let r=0;r{qD()});function x4e(s,n){if(!s)throw new Error(`math.gl assertion ${n}`)}var bpt=Ve(()=>{});var Wce,wpt=Ve(()=>{y4e();D$();bpt();Wce=class extends XD{get x(){return this[0]}set x(n){this[0]=ap(n)}get y(){return this[1]}set y(n){this[1]=ap(n)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let n=0;for(let r=0;r=0&&n=0&&n=0?Math.round(s):s%.5===0?Math.floor(s):Math.round(s)}var Tc,Hy,ozn,f4=Ve(()=>{Tc=typeof Float32Array<"u"?Float32Array:Array,Hy=Math.random;ozn=Math.PI/180});var og={};Oy(og,{add:()=>xYt,angle:()=>GYt,ceil:()=>EYt,clone:()=>wYt,copy:()=>_Yt,create:()=>vpt,cross:()=>DYt,dist:()=>ZYt,distance:()=>Ept,div:()=>YYt,divide:()=>xpt,dot:()=>IYt,equals:()=>WYt,exactEquals:()=>VYt,floor:()=>SYt,forEach:()=>QYt,fromValues:()=>vYt,inverse:()=>kYt,len:()=>HYt,length:()=>Mpt,lerp:()=>BYt,max:()=>TYt,min:()=>MYt,mul:()=>XYt,multiply:()=>ypt,negate:()=>LYt,normalize:()=>RYt,random:()=>OYt,rotate:()=>zYt,round:()=>CYt,scale:()=>AYt,scaleAndAdd:()=>PYt,set:()=>yYt,sqrDist:()=>KYt,sqrLen:()=>JYt,squaredDistance:()=>Spt,squaredLength:()=>Tpt,str:()=>$Yt,sub:()=>qYt,subtract:()=>_pt,transformMat2:()=>NYt,transformMat2d:()=>FYt,transformMat3:()=>UYt,transformMat4:()=>E4e,zero:()=>jYt});function vpt(){let s=new Tc(2);return Tc!=Float32Array&&(s[0]=0,s[1]=0),s}function wYt(s){let n=new Tc(2);return n[0]=s[0],n[1]=s[1],n}function vYt(s,n){let r=new Tc(2);return r[0]=s,r[1]=n,r}function _Yt(s,n){return s[0]=n[0],s[1]=n[1],s}function yYt(s,n,r){return s[0]=n,s[1]=r,s}function xYt(s,n,r){return s[0]=n[0]+r[0],s[1]=n[1]+r[1],s}function _pt(s,n,r){return s[0]=n[0]-r[0],s[1]=n[1]-r[1],s}function ypt(s,n,r){return s[0]=n[0]*r[0],s[1]=n[1]*r[1],s}function xpt(s,n,r){return s[0]=n[0]/r[0],s[1]=n[1]/r[1],s}function EYt(s,n){return s[0]=Math.ceil(n[0]),s[1]=Math.ceil(n[1]),s}function SYt(s,n){return s[0]=Math.floor(n[0]),s[1]=Math.floor(n[1]),s}function MYt(s,n,r){return s[0]=Math.min(n[0],r[0]),s[1]=Math.min(n[1],r[1]),s}function TYt(s,n,r){return s[0]=Math.max(n[0],r[0]),s[1]=Math.max(n[1],r[1]),s}function CYt(s,n){return s[0]=Tb(n[0]),s[1]=Tb(n[1]),s}function AYt(s,n,r){return s[0]=n[0]*r,s[1]=n[1]*r,s}function PYt(s,n,r,c){return s[0]=n[0]+r[0]*c,s[1]=n[1]+r[1]*c,s}function Ept(s,n){let r=n[0]-s[0],c=n[1]-s[1];return Math.sqrt(r*r+c*c)}function Spt(s,n){let r=n[0]-s[0],c=n[1]-s[1];return r*r+c*c}function Mpt(s){let n=s[0],r=s[1];return Math.sqrt(n*n+r*r)}function Tpt(s){let n=s[0],r=s[1];return n*n+r*r}function LYt(s,n){return s[0]=-n[0],s[1]=-n[1],s}function kYt(s,n){return s[0]=1/n[0],s[1]=1/n[1],s}function RYt(s,n){let r=n[0],c=n[1],u=r*r+c*c;return u>0&&(u=1/Math.sqrt(u)),s[0]=n[0]*u,s[1]=n[1]*u,s}function IYt(s,n){return s[0]*n[0]+s[1]*n[1]}function DYt(s,n,r){let c=n[0]*r[1]-n[1]*r[0];return s[0]=s[1]=0,s[2]=c,s}function BYt(s,n,r,c){let u=n[0],d=n[1];return s[0]=u+c*(r[0]-u),s[1]=d+c*(r[1]-d),s}function OYt(s,n){n=n===void 0?1:n;let r=Hy()*2*Math.PI;return s[0]=Math.cos(r)*n,s[1]=Math.sin(r)*n,s}function NYt(s,n,r){let c=n[0],u=n[1];return s[0]=r[0]*c+r[2]*u,s[1]=r[1]*c+r[3]*u,s}function FYt(s,n,r){let c=n[0],u=n[1];return s[0]=r[0]*c+r[2]*u+r[4],s[1]=r[1]*c+r[3]*u+r[5],s}function UYt(s,n,r){let c=n[0],u=n[1];return s[0]=r[0]*c+r[3]*u+r[6],s[1]=r[1]*c+r[4]*u+r[7],s}function E4e(s,n,r){let c=n[0],u=n[1];return s[0]=r[0]*c+r[4]*u+r[12],s[1]=r[1]*c+r[5]*u+r[13],s}function zYt(s,n,r,c){let u=n[0]-r[0],d=n[1]-r[1],b=Math.sin(c),w=Math.cos(c);return s[0]=u*w-d*b+r[0],s[1]=u*b+d*w+r[1],s}function GYt(s,n){let r=s[0],c=s[1],u=n[0],d=n[1],b=Math.sqrt((r*r+c*c)*(u*u+d*d)),w=b&&(r*u+c*d)/b;return Math.acos(Math.min(Math.max(w,-1),1))}function jYt(s){return s[0]=0,s[1]=0,s}function $Yt(s){return`vec2(${s[0]}, ${s[1]})`}function VYt(s,n){return s[0]===n[0]&&s[1]===n[1]}function WYt(s,n){let r=s[0],c=s[1],u=n[0],d=n[1];return Math.abs(r-u)<=1e-6*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(c-d)<=1e-6*Math.max(1,Math.abs(c),Math.abs(d))}var HYt,qYt,XYt,YYt,ZYt,KYt,JYt,QYt,S4e=Ve(()=>{f4();HYt=Mpt,qYt=_pt,XYt=ypt,YYt=xpt,ZYt=Ept,KYt=Spt,JYt=Tpt,QYt=function(){let s=vpt();return function(n,r,c,u,d,b){let w,_;for(r||(r=2),c||(c=0),u?_=Math.min(u*r+c,n.length):_=n.length,w=c;w<_;w+=r)s[0]=n[w],s[1]=n[w+1],d(s,s,b),n[w]=s[0],n[w+1]=s[1];return n}}()});function Cpt(s,n,r){let c=n[0],u=n[1],d=r[3]*c+r[7]*u||1;return s[0]=(r[0]*c+r[4]*u)/d,s[1]=(r[1]*c+r[5]*u)/d,s}function Hce(s,n,r){let c=n[0],u=n[1],d=n[2],b=r[3]*c+r[7]*u+r[11]*d||1;return s[0]=(r[0]*c+r[4]*u+r[8]*d)/b,s[1]=(r[1]*c+r[5]*u+r[9]*d)/b,s[2]=(r[2]*c+r[6]*u+r[10]*d)/b,s}function Apt(s,n,r){let c=n[0],u=n[1];return s[0]=r[0]*c+r[2]*u,s[1]=r[1]*c+r[3]*u,s[2]=n[2],s}var M4e=Ve(()=>{});var wm={};Oy(wm,{add:()=>iZt,angle:()=>R4e,bezier:()=>mZt,ceil:()=>rZt,clone:()=>eZt,copy:()=>tZt,create:()=>qce,cross:()=>h4,dist:()=>MZt,distance:()=>Ipt,div:()=>SZt,divide:()=>Rpt,dot:()=>B$,equals:()=>yZt,exactEquals:()=>_Zt,floor:()=>sZt,forEach:()=>AZt,fromValues:()=>Xce,hermite:()=>gZt,inverse:()=>hZt,len:()=>I4e,length:()=>Ppt,lerp:()=>dZt,max:()=>aZt,min:()=>oZt,mul:()=>EZt,multiply:()=>kpt,negate:()=>fZt,normalize:()=>T4e,random:()=>bZt,rotateX:()=>P4e,rotateY:()=>L4e,rotateZ:()=>k4e,round:()=>cZt,scale:()=>lZt,scaleAndAdd:()=>uZt,set:()=>nZt,slerp:()=>pZt,sqrDist:()=>TZt,sqrLen:()=>CZt,squaredDistance:()=>Dpt,squaredLength:()=>Bpt,str:()=>vZt,sub:()=>xZt,subtract:()=>Lpt,transformMat3:()=>C4e,transformMat4:()=>O$,transformQuat:()=>A4e,zero:()=>wZt});function qce(){let s=new Tc(3);return Tc!=Float32Array&&(s[0]=0,s[1]=0,s[2]=0),s}function eZt(s){let n=new Tc(3);return n[0]=s[0],n[1]=s[1],n[2]=s[2],n}function Ppt(s){let n=s[0],r=s[1],c=s[2];return Math.sqrt(n*n+r*r+c*c)}function Xce(s,n,r){let c=new Tc(3);return c[0]=s,c[1]=n,c[2]=r,c}function tZt(s,n){return s[0]=n[0],s[1]=n[1],s[2]=n[2],s}function nZt(s,n,r,c){return s[0]=n,s[1]=r,s[2]=c,s}function iZt(s,n,r){return s[0]=n[0]+r[0],s[1]=n[1]+r[1],s[2]=n[2]+r[2],s}function Lpt(s,n,r){return s[0]=n[0]-r[0],s[1]=n[1]-r[1],s[2]=n[2]-r[2],s}function kpt(s,n,r){return s[0]=n[0]*r[0],s[1]=n[1]*r[1],s[2]=n[2]*r[2],s}function Rpt(s,n,r){return s[0]=n[0]/r[0],s[1]=n[1]/r[1],s[2]=n[2]/r[2],s}function rZt(s,n){return s[0]=Math.ceil(n[0]),s[1]=Math.ceil(n[1]),s[2]=Math.ceil(n[2]),s}function sZt(s,n){return s[0]=Math.floor(n[0]),s[1]=Math.floor(n[1]),s[2]=Math.floor(n[2]),s}function oZt(s,n,r){return s[0]=Math.min(n[0],r[0]),s[1]=Math.min(n[1],r[1]),s[2]=Math.min(n[2],r[2]),s}function aZt(s,n,r){return s[0]=Math.max(n[0],r[0]),s[1]=Math.max(n[1],r[1]),s[2]=Math.max(n[2],r[2]),s}function cZt(s,n){return s[0]=Tb(n[0]),s[1]=Tb(n[1]),s[2]=Tb(n[2]),s}function lZt(s,n,r){return s[0]=n[0]*r,s[1]=n[1]*r,s[2]=n[2]*r,s}function uZt(s,n,r,c){return s[0]=n[0]+r[0]*c,s[1]=n[1]+r[1]*c,s[2]=n[2]+r[2]*c,s}function Ipt(s,n){let r=n[0]-s[0],c=n[1]-s[1],u=n[2]-s[2];return Math.sqrt(r*r+c*c+u*u)}function Dpt(s,n){let r=n[0]-s[0],c=n[1]-s[1],u=n[2]-s[2];return r*r+c*c+u*u}function Bpt(s){let n=s[0],r=s[1],c=s[2];return n*n+r*r+c*c}function fZt(s,n){return s[0]=-n[0],s[1]=-n[1],s[2]=-n[2],s}function hZt(s,n){return s[0]=1/n[0],s[1]=1/n[1],s[2]=1/n[2],s}function T4e(s,n){let r=n[0],c=n[1],u=n[2],d=r*r+c*c+u*u;return d>0&&(d=1/Math.sqrt(d)),s[0]=n[0]*d,s[1]=n[1]*d,s[2]=n[2]*d,s}function B$(s,n){return s[0]*n[0]+s[1]*n[1]+s[2]*n[2]}function h4(s,n,r){let c=n[0],u=n[1],d=n[2],b=r[0],w=r[1],_=r[2];return s[0]=u*_-d*w,s[1]=d*b-c*_,s[2]=c*w-u*b,s}function dZt(s,n,r,c){let u=n[0],d=n[1],b=n[2];return s[0]=u+c*(r[0]-u),s[1]=d+c*(r[1]-d),s[2]=b+c*(r[2]-b),s}function pZt(s,n,r,c){let u=Math.acos(Math.min(Math.max(B$(n,r),-1),1)),d=Math.sin(u),b=Math.sin((1-c)*u)/d,w=Math.sin(c*u)/d;return s[0]=b*n[0]+w*r[0],s[1]=b*n[1]+w*r[1],s[2]=b*n[2]+w*r[2],s}function gZt(s,n,r,c,u,d){let b=d*d,w=b*(2*d-3)+1,_=b*(d-2)+d,x=b*(d-1),T=b*(3-2*d);return s[0]=n[0]*w+r[0]*_+c[0]*x+u[0]*T,s[1]=n[1]*w+r[1]*_+c[1]*x+u[1]*T,s[2]=n[2]*w+r[2]*_+c[2]*x+u[2]*T,s}function mZt(s,n,r,c,u,d){let b=1-d,w=b*b,_=d*d,x=w*b,T=3*d*w,M=3*_*b,L=_*d;return s[0]=n[0]*x+r[0]*T+c[0]*M+u[0]*L,s[1]=n[1]*x+r[1]*T+c[1]*M+u[1]*L,s[2]=n[2]*x+r[2]*T+c[2]*M+u[2]*L,s}function bZt(s,n){n=n===void 0?1:n;let r=Hy()*2*Math.PI,c=Hy()*2-1,u=Math.sqrt(1-c*c)*n;return s[0]=Math.cos(r)*u,s[1]=Math.sin(r)*u,s[2]=c*n,s}function O$(s,n,r){let c=n[0],u=n[1],d=n[2],b=r[3]*c+r[7]*u+r[11]*d+r[15];return b=b||1,s[0]=(r[0]*c+r[4]*u+r[8]*d+r[12])/b,s[1]=(r[1]*c+r[5]*u+r[9]*d+r[13])/b,s[2]=(r[2]*c+r[6]*u+r[10]*d+r[14])/b,s}function C4e(s,n,r){let c=n[0],u=n[1],d=n[2];return s[0]=c*r[0]+u*r[3]+d*r[6],s[1]=c*r[1]+u*r[4]+d*r[7],s[2]=c*r[2]+u*r[5]+d*r[8],s}function A4e(s,n,r){let c=r[0],u=r[1],d=r[2],b=r[3],w=n[0],_=n[1],x=n[2],T=u*x-d*_,M=d*w-c*x,L=c*_-u*w,I=u*L-d*M,D=d*T-c*L,F=c*M-u*T,O=b*2;return T*=O,M*=O,L*=O,I*=2,D*=2,F*=2,s[0]=w+T+I,s[1]=_+M+D,s[2]=x+L+F,s}function P4e(s,n,r,c){let u=[],d=[];return u[0]=n[0]-r[0],u[1]=n[1]-r[1],u[2]=n[2]-r[2],d[0]=u[0],d[1]=u[1]*Math.cos(c)-u[2]*Math.sin(c),d[2]=u[1]*Math.sin(c)+u[2]*Math.cos(c),s[0]=d[0]+r[0],s[1]=d[1]+r[1],s[2]=d[2]+r[2],s}function L4e(s,n,r,c){let u=[],d=[];return u[0]=n[0]-r[0],u[1]=n[1]-r[1],u[2]=n[2]-r[2],d[0]=u[2]*Math.sin(c)+u[0]*Math.cos(c),d[1]=u[1],d[2]=u[2]*Math.cos(c)-u[0]*Math.sin(c),s[0]=d[0]+r[0],s[1]=d[1]+r[1],s[2]=d[2]+r[2],s}function k4e(s,n,r,c){let u=[],d=[];return u[0]=n[0]-r[0],u[1]=n[1]-r[1],u[2]=n[2]-r[2],d[0]=u[0]*Math.cos(c)-u[1]*Math.sin(c),d[1]=u[0]*Math.sin(c)+u[1]*Math.cos(c),d[2]=u[2],s[0]=d[0]+r[0],s[1]=d[1]+r[1],s[2]=d[2]+r[2],s}function R4e(s,n){let r=s[0],c=s[1],u=s[2],d=n[0],b=n[1],w=n[2],_=Math.sqrt((r*r+c*c+u*u)*(d*d+b*b+w*w)),x=_&&B$(s,n)/_;return Math.acos(Math.min(Math.max(x,-1),1))}function wZt(s){return s[0]=0,s[1]=0,s[2]=0,s}function vZt(s){return`vec3(${s[0]}, ${s[1]}, ${s[2]})`}function _Zt(s,n){return s[0]===n[0]&&s[1]===n[1]&&s[2]===n[2]}function yZt(s,n){let r=s[0],c=s[1],u=s[2],d=n[0],b=n[1],w=n[2];return Math.abs(r-d)<=1e-6*Math.max(1,Math.abs(r),Math.abs(d))&&Math.abs(c-b)<=1e-6*Math.max(1,Math.abs(c),Math.abs(b))&&Math.abs(u-w)<=1e-6*Math.max(1,Math.abs(u),Math.abs(w))}var xZt,EZt,SZt,MZt,TZt,I4e,CZt,AZt,N$=Ve(()=>{f4();xZt=Lpt,EZt=kpt,SZt=Rpt,MZt=Ipt,TZt=Dpt,I4e=Ppt,CZt=Bpt,AZt=function(){let s=qce();return function(n,r,c,u,d,b){let w,_;for(r||(r=3),c||(c=0),u?_=Math.min(u*r+c,n.length):_=n.length,w=c;w<_;w+=r)s[0]=n[w],s[1]=n[w+1],s[2]=n[w+2],d(s,s,b),n[w]=s[0],n[w+1]=s[1],n[w+2]=s[2];return n}}()});var D4e,Yce,cp,Opt=Ve(()=>{wpt();qD();D$();N$();M4e();D4e=[0,0,0],cp=class s extends Wce{static get ZERO(){return Yce||(Yce=new s(0,0,0),Object.freeze(Yce)),Yce}constructor(n=0,r=0,c=0){super(-0,-0,-0),arguments.length===1&&A3(n)?this.copy(n):(Gh.debug&&(ap(n),ap(r),ap(c)),this[0]=n,this[1]=r,this[2]=c)}set(n,r,c){return this[0]=n,this[1]=r,this[2]=c,this.check()}copy(n){return this[0]=n[0],this[1]=n[1],this[2]=n[2],this.check()}fromObject(n){return Gh.debug&&(ap(n.x),ap(n.y),ap(n.z)),this[0]=n.x,this[1]=n.y,this[2]=n.z,this.check()}toObject(n){return n.x=this[0],n.y=this[1],n.z=this[2],n}get ELEMENTS(){return 3}get z(){return this[2]}set z(n){this[2]=ap(n)}angle(n){return R4e(this,n)}cross(n){return h4(this,this,n),this.check()}rotateX({radians:n,origin:r=D4e}){return P4e(this,this,r,n),this.check()}rotateY({radians:n,origin:r=D4e}){return L4e(this,this,r,n),this.check()}rotateZ({radians:n,origin:r=D4e}){return k4e(this,this,r,n),this.check()}transform(n){return this.transformAsPoint(n)}transformAsPoint(n){return O$(this,this,n),this.check()}transformAsVector(n){return Hce(this,this,n),this.check()}transformByMatrix3(n){return C4e(this,this,n),this.check()}transformByMatrix2(n){return Apt(this,this,n),this.check()}transformByQuaternion(n){return A4e(this,this,n),this.check()}}});var Zce,Npt=Ve(()=>{y4e();D$();qD();Zce=class extends XD{toString(){let n="[";if(Gh.printRowMajor){n+="row-major:";for(let r=0;r{f4()});var uh={};Oy(uh,{add:()=>QZt,adjoint:()=>DZt,clone:()=>LZt,copy:()=>kZt,create:()=>PZt,decompose:()=>VZt,determinant:()=>F4e,equals:()=>iKt,exactEquals:()=>nKt,frob:()=>JZt,fromQuat:()=>W4e,fromQuat2:()=>GZt,fromRotation:()=>NZt,fromRotationTranslation:()=>Gpt,fromRotationTranslationScale:()=>WZt,fromRotationTranslationScaleOrigin:()=>HZt,fromScaling:()=>OZt,fromTranslation:()=>BZt,fromValues:()=>RZt,fromXRotation:()=>FZt,fromYRotation:()=>UZt,fromZRotation:()=>zZt,frustum:()=>H4e,getRotation:()=>$Zt,getScaling:()=>jpt,getTranslation:()=>jZt,identity:()=>zpt,invert:()=>N4e,lookAt:()=>Y4e,mul:()=>rKt,multiply:()=>F$,multiplyScalar:()=>eKt,multiplyScalarAndAdd:()=>tKt,ortho:()=>X4e,orthoNO:()=>Vpt,orthoZO:()=>YZt,perspective:()=>q4e,perspectiveFromFieldOfView:()=>XZt,perspectiveNO:()=>$pt,perspectiveZO:()=>qZt,rotate:()=>G4e,rotateX:()=>j4e,rotateY:()=>$4e,rotateZ:()=>V4e,scale:()=>z4e,set:()=>IZt,str:()=>KZt,sub:()=>sKt,subtract:()=>Wpt,targetTo:()=>ZZt,translate:()=>U4e,transpose:()=>O4e});function PZt(){let s=new Tc(16);return Tc!=Float32Array&&(s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[11]=0,s[12]=0,s[13]=0,s[14]=0),s[0]=1,s[5]=1,s[10]=1,s[15]=1,s}function LZt(s){let n=new Tc(16);return n[0]=s[0],n[1]=s[1],n[2]=s[2],n[3]=s[3],n[4]=s[4],n[5]=s[5],n[6]=s[6],n[7]=s[7],n[8]=s[8],n[9]=s[9],n[10]=s[10],n[11]=s[11],n[12]=s[12],n[13]=s[13],n[14]=s[14],n[15]=s[15],n}function kZt(s,n){return s[0]=n[0],s[1]=n[1],s[2]=n[2],s[3]=n[3],s[4]=n[4],s[5]=n[5],s[6]=n[6],s[7]=n[7],s[8]=n[8],s[9]=n[9],s[10]=n[10],s[11]=n[11],s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15],s}function RZt(s,n,r,c,u,d,b,w,_,x,T,M,L,I,D,F){let O=new Tc(16);return O[0]=s,O[1]=n,O[2]=r,O[3]=c,O[4]=u,O[5]=d,O[6]=b,O[7]=w,O[8]=_,O[9]=x,O[10]=T,O[11]=M,O[12]=L,O[13]=I,O[14]=D,O[15]=F,O}function IZt(s,n,r,c,u,d,b,w,_,x,T,M,L,I,D,F,O){return s[0]=n,s[1]=r,s[2]=c,s[3]=u,s[4]=d,s[5]=b,s[6]=w,s[7]=_,s[8]=x,s[9]=T,s[10]=M,s[11]=L,s[12]=I,s[13]=D,s[14]=F,s[15]=O,s}function zpt(s){return s[0]=1,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=1,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=1,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function O4e(s,n){if(s===n){let r=n[1],c=n[2],u=n[3],d=n[6],b=n[7],w=n[11];s[1]=n[4],s[2]=n[8],s[3]=n[12],s[4]=r,s[6]=n[9],s[7]=n[13],s[8]=c,s[9]=d,s[11]=n[14],s[12]=u,s[13]=b,s[14]=w}else s[0]=n[0],s[1]=n[4],s[2]=n[8],s[3]=n[12],s[4]=n[1],s[5]=n[5],s[6]=n[9],s[7]=n[13],s[8]=n[2],s[9]=n[6],s[10]=n[10],s[11]=n[14],s[12]=n[3],s[13]=n[7],s[14]=n[11],s[15]=n[15];return s}function N4e(s,n){let r=n[0],c=n[1],u=n[2],d=n[3],b=n[4],w=n[5],_=n[6],x=n[7],T=n[8],M=n[9],L=n[10],I=n[11],D=n[12],F=n[13],O=n[14],z=n[15],Z=r*w-c*b,H=r*_-u*b,te=r*x-d*b,se=c*_-u*w,ne=c*x-d*w,ue=u*x-d*_,Ce=T*F-M*D,Q=T*O-L*D,me=T*z-I*D,tt=M*O-L*F,st=M*z-I*F,at=L*z-I*O,Ne=Z*at-H*st+te*tt+se*me-ne*Q+ue*Ce;return Ne?(Ne=1/Ne,s[0]=(w*at-_*st+x*tt)*Ne,s[1]=(u*st-c*at-d*tt)*Ne,s[2]=(F*ue-O*ne+z*se)*Ne,s[3]=(L*ne-M*ue-I*se)*Ne,s[4]=(_*me-b*at-x*Q)*Ne,s[5]=(r*at-u*me+d*Q)*Ne,s[6]=(O*te-D*ue-z*H)*Ne,s[7]=(T*ue-L*te+I*H)*Ne,s[8]=(b*st-w*me+x*Ce)*Ne,s[9]=(c*me-r*st-d*Ce)*Ne,s[10]=(D*ne-F*te+z*Z)*Ne,s[11]=(M*te-T*ne-I*Z)*Ne,s[12]=(w*Q-b*tt-_*Ce)*Ne,s[13]=(r*tt-c*Q+u*Ce)*Ne,s[14]=(F*H-D*se-O*Z)*Ne,s[15]=(T*se-M*H+L*Z)*Ne,s):null}function DZt(s,n){let r=n[0],c=n[1],u=n[2],d=n[3],b=n[4],w=n[5],_=n[6],x=n[7],T=n[8],M=n[9],L=n[10],I=n[11],D=n[12],F=n[13],O=n[14],z=n[15],Z=r*w-c*b,H=r*_-u*b,te=r*x-d*b,se=c*_-u*w,ne=c*x-d*w,ue=u*x-d*_,Ce=T*F-M*D,Q=T*O-L*D,me=T*z-I*D,tt=M*O-L*F,st=M*z-I*F,at=L*z-I*O;return s[0]=w*at-_*st+x*tt,s[1]=u*st-c*at-d*tt,s[2]=F*ue-O*ne+z*se,s[3]=L*ne-M*ue-I*se,s[4]=_*me-b*at-x*Q,s[5]=r*at-u*me+d*Q,s[6]=O*te-D*ue-z*H,s[7]=T*ue-L*te+I*H,s[8]=b*st-w*me+x*Ce,s[9]=c*me-r*st-d*Ce,s[10]=D*ne-F*te+z*Z,s[11]=M*te-T*ne-I*Z,s[12]=w*Q-b*tt-_*Ce,s[13]=r*tt-c*Q+u*Ce,s[14]=F*H-D*se-O*Z,s[15]=T*se-M*H+L*Z,s}function F4e(s){let n=s[0],r=s[1],c=s[2],u=s[3],d=s[4],b=s[5],w=s[6],_=s[7],x=s[8],T=s[9],M=s[10],L=s[11],I=s[12],D=s[13],F=s[14],O=s[15],z=n*b-r*d,Z=n*w-c*d,H=r*w-c*b,te=x*D-T*I,se=x*F-M*I,ne=T*F-M*D,ue=n*ne-r*se+c*te,Ce=d*ne-b*se+w*te,Q=x*H-T*Z+M*z,me=I*H-D*Z+F*z;return _*ue-u*Ce+O*Q-L*me}function F$(s,n,r){let c=n[0],u=n[1],d=n[2],b=n[3],w=n[4],_=n[5],x=n[6],T=n[7],M=n[8],L=n[9],I=n[10],D=n[11],F=n[12],O=n[13],z=n[14],Z=n[15],H=r[0],te=r[1],se=r[2],ne=r[3];return s[0]=H*c+te*w+se*M+ne*F,s[1]=H*u+te*_+se*L+ne*O,s[2]=H*d+te*x+se*I+ne*z,s[3]=H*b+te*T+se*D+ne*Z,H=r[4],te=r[5],se=r[6],ne=r[7],s[4]=H*c+te*w+se*M+ne*F,s[5]=H*u+te*_+se*L+ne*O,s[6]=H*d+te*x+se*I+ne*z,s[7]=H*b+te*T+se*D+ne*Z,H=r[8],te=r[9],se=r[10],ne=r[11],s[8]=H*c+te*w+se*M+ne*F,s[9]=H*u+te*_+se*L+ne*O,s[10]=H*d+te*x+se*I+ne*z,s[11]=H*b+te*T+se*D+ne*Z,H=r[12],te=r[13],se=r[14],ne=r[15],s[12]=H*c+te*w+se*M+ne*F,s[13]=H*u+te*_+se*L+ne*O,s[14]=H*d+te*x+se*I+ne*z,s[15]=H*b+te*T+se*D+ne*Z,s}function U4e(s,n,r){let c=r[0],u=r[1],d=r[2],b,w,_,x,T,M,L,I,D,F,O,z;return n===s?(s[12]=n[0]*c+n[4]*u+n[8]*d+n[12],s[13]=n[1]*c+n[5]*u+n[9]*d+n[13],s[14]=n[2]*c+n[6]*u+n[10]*d+n[14],s[15]=n[3]*c+n[7]*u+n[11]*d+n[15]):(b=n[0],w=n[1],_=n[2],x=n[3],T=n[4],M=n[5],L=n[6],I=n[7],D=n[8],F=n[9],O=n[10],z=n[11],s[0]=b,s[1]=w,s[2]=_,s[3]=x,s[4]=T,s[5]=M,s[6]=L,s[7]=I,s[8]=D,s[9]=F,s[10]=O,s[11]=z,s[12]=b*c+T*u+D*d+n[12],s[13]=w*c+M*u+F*d+n[13],s[14]=_*c+L*u+O*d+n[14],s[15]=x*c+I*u+z*d+n[15]),s}function z4e(s,n,r){let c=r[0],u=r[1],d=r[2];return s[0]=n[0]*c,s[1]=n[1]*c,s[2]=n[2]*c,s[3]=n[3]*c,s[4]=n[4]*u,s[5]=n[5]*u,s[6]=n[6]*u,s[7]=n[7]*u,s[8]=n[8]*d,s[9]=n[9]*d,s[10]=n[10]*d,s[11]=n[11]*d,s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15],s}function G4e(s,n,r,c){let u=c[0],d=c[1],b=c[2],w=Math.sqrt(u*u+d*d+b*b),_,x,T,M,L,I,D,F,O,z,Z,H,te,se,ne,ue,Ce,Q,me,tt,st,at,Ne,Qe;return w<1e-6?null:(w=1/w,u*=w,d*=w,b*=w,x=Math.sin(r),_=Math.cos(r),T=1-_,M=n[0],L=n[1],I=n[2],D=n[3],F=n[4],O=n[5],z=n[6],Z=n[7],H=n[8],te=n[9],se=n[10],ne=n[11],ue=u*u*T+_,Ce=d*u*T+b*x,Q=b*u*T-d*x,me=u*d*T-b*x,tt=d*d*T+_,st=b*d*T+u*x,at=u*b*T+d*x,Ne=d*b*T-u*x,Qe=b*b*T+_,s[0]=M*ue+F*Ce+H*Q,s[1]=L*ue+O*Ce+te*Q,s[2]=I*ue+z*Ce+se*Q,s[3]=D*ue+Z*Ce+ne*Q,s[4]=M*me+F*tt+H*st,s[5]=L*me+O*tt+te*st,s[6]=I*me+z*tt+se*st,s[7]=D*me+Z*tt+ne*st,s[8]=M*at+F*Ne+H*Qe,s[9]=L*at+O*Ne+te*Qe,s[10]=I*at+z*Ne+se*Qe,s[11]=D*at+Z*Ne+ne*Qe,n!==s&&(s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15]),s)}function j4e(s,n,r){let c=Math.sin(r),u=Math.cos(r),d=n[4],b=n[5],w=n[6],_=n[7],x=n[8],T=n[9],M=n[10],L=n[11];return n!==s&&(s[0]=n[0],s[1]=n[1],s[2]=n[2],s[3]=n[3],s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15]),s[4]=d*u+x*c,s[5]=b*u+T*c,s[6]=w*u+M*c,s[7]=_*u+L*c,s[8]=x*u-d*c,s[9]=T*u-b*c,s[10]=M*u-w*c,s[11]=L*u-_*c,s}function $4e(s,n,r){let c=Math.sin(r),u=Math.cos(r),d=n[0],b=n[1],w=n[2],_=n[3],x=n[8],T=n[9],M=n[10],L=n[11];return n!==s&&(s[4]=n[4],s[5]=n[5],s[6]=n[6],s[7]=n[7],s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15]),s[0]=d*u-x*c,s[1]=b*u-T*c,s[2]=w*u-M*c,s[3]=_*u-L*c,s[8]=d*c+x*u,s[9]=b*c+T*u,s[10]=w*c+M*u,s[11]=_*c+L*u,s}function V4e(s,n,r){let c=Math.sin(r),u=Math.cos(r),d=n[0],b=n[1],w=n[2],_=n[3],x=n[4],T=n[5],M=n[6],L=n[7];return n!==s&&(s[8]=n[8],s[9]=n[9],s[10]=n[10],s[11]=n[11],s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15]),s[0]=d*u+x*c,s[1]=b*u+T*c,s[2]=w*u+M*c,s[3]=_*u+L*c,s[4]=x*u-d*c,s[5]=T*u-b*c,s[6]=M*u-w*c,s[7]=L*u-_*c,s}function BZt(s,n){return s[0]=1,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=1,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=1,s[11]=0,s[12]=n[0],s[13]=n[1],s[14]=n[2],s[15]=1,s}function OZt(s,n){return s[0]=n[0],s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=n[1],s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=n[2],s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function NZt(s,n,r){let c=r[0],u=r[1],d=r[2],b=Math.sqrt(c*c+u*u+d*d),w,_,x;return b<1e-6?null:(b=1/b,c*=b,u*=b,d*=b,_=Math.sin(n),w=Math.cos(n),x=1-w,s[0]=c*c*x+w,s[1]=u*c*x+d*_,s[2]=d*c*x-u*_,s[3]=0,s[4]=c*u*x-d*_,s[5]=u*u*x+w,s[6]=d*u*x+c*_,s[7]=0,s[8]=c*d*x+u*_,s[9]=u*d*x-c*_,s[10]=d*d*x+w,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s)}function FZt(s,n){let r=Math.sin(n),c=Math.cos(n);return s[0]=1,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=c,s[6]=r,s[7]=0,s[8]=0,s[9]=-r,s[10]=c,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function UZt(s,n){let r=Math.sin(n),c=Math.cos(n);return s[0]=c,s[1]=0,s[2]=-r,s[3]=0,s[4]=0,s[5]=1,s[6]=0,s[7]=0,s[8]=r,s[9]=0,s[10]=c,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function zZt(s,n){let r=Math.sin(n),c=Math.cos(n);return s[0]=c,s[1]=r,s[2]=0,s[3]=0,s[4]=-r,s[5]=c,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=1,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function Gpt(s,n,r){let c=n[0],u=n[1],d=n[2],b=n[3],w=c+c,_=u+u,x=d+d,T=c*w,M=c*_,L=c*x,I=u*_,D=u*x,F=d*x,O=b*w,z=b*_,Z=b*x;return s[0]=1-(I+F),s[1]=M+Z,s[2]=L-z,s[3]=0,s[4]=M-Z,s[5]=1-(T+F),s[6]=D+O,s[7]=0,s[8]=L+z,s[9]=D-O,s[10]=1-(T+I),s[11]=0,s[12]=r[0],s[13]=r[1],s[14]=r[2],s[15]=1,s}function GZt(s,n){let r=new Tc(3),c=-n[0],u=-n[1],d=-n[2],b=n[3],w=n[4],_=n[5],x=n[6],T=n[7],M=c*c+u*u+d*d+b*b;return M>0?(r[0]=(w*b+T*c+_*d-x*u)*2/M,r[1]=(_*b+T*u+x*c-w*d)*2/M,r[2]=(x*b+T*d+w*u-_*c)*2/M):(r[0]=(w*b+T*c+_*d-x*u)*2,r[1]=(_*b+T*u+x*c-w*d)*2,r[2]=(x*b+T*d+w*u-_*c)*2),Gpt(s,n,r),s}function jZt(s,n){return s[0]=n[12],s[1]=n[13],s[2]=n[14],s}function jpt(s,n){let r=n[0],c=n[1],u=n[2],d=n[4],b=n[5],w=n[6],_=n[8],x=n[9],T=n[10];return s[0]=Math.sqrt(r*r+c*c+u*u),s[1]=Math.sqrt(d*d+b*b+w*w),s[2]=Math.sqrt(_*_+x*x+T*T),s}function $Zt(s,n){let r=new Tc(3);jpt(r,n);let c=1/r[0],u=1/r[1],d=1/r[2],b=n[0]*c,w=n[1]*u,_=n[2]*d,x=n[4]*c,T=n[5]*u,M=n[6]*d,L=n[8]*c,I=n[9]*u,D=n[10]*d,F=b+T+D,O=0;return F>0?(O=Math.sqrt(F+1)*2,s[3]=.25*O,s[0]=(M-I)/O,s[1]=(L-_)/O,s[2]=(w-x)/O):b>T&&b>D?(O=Math.sqrt(1+b-T-D)*2,s[3]=(M-I)/O,s[0]=.25*O,s[1]=(w+x)/O,s[2]=(L+_)/O):T>D?(O=Math.sqrt(1+T-b-D)*2,s[3]=(L-_)/O,s[0]=(w+x)/O,s[1]=.25*O,s[2]=(M+I)/O):(O=Math.sqrt(1+D-b-T)*2,s[3]=(w-x)/O,s[0]=(L+_)/O,s[1]=(M+I)/O,s[2]=.25*O),s}function VZt(s,n,r,c){n[0]=c[12],n[1]=c[13],n[2]=c[14];let u=c[0],d=c[1],b=c[2],w=c[4],_=c[5],x=c[6],T=c[8],M=c[9],L=c[10];r[0]=Math.sqrt(u*u+d*d+b*b),r[1]=Math.sqrt(w*w+_*_+x*x),r[2]=Math.sqrt(T*T+M*M+L*L);let I=1/r[0],D=1/r[1],F=1/r[2],O=u*I,z=d*D,Z=b*F,H=w*I,te=_*D,se=x*F,ne=T*I,ue=M*D,Ce=L*F,Q=O+te+Ce,me=0;return Q>0?(me=Math.sqrt(Q+1)*2,s[3]=.25*me,s[0]=(se-ue)/me,s[1]=(ne-Z)/me,s[2]=(z-H)/me):O>te&&O>Ce?(me=Math.sqrt(1+O-te-Ce)*2,s[3]=(se-ue)/me,s[0]=.25*me,s[1]=(z+H)/me,s[2]=(ne+Z)/me):te>Ce?(me=Math.sqrt(1+te-O-Ce)*2,s[3]=(ne-Z)/me,s[0]=(z+H)/me,s[1]=.25*me,s[2]=(se+ue)/me):(me=Math.sqrt(1+Ce-O-te)*2,s[3]=(z-H)/me,s[0]=(ne+Z)/me,s[1]=(se+ue)/me,s[2]=.25*me),s}function WZt(s,n,r,c){let u=n[0],d=n[1],b=n[2],w=n[3],_=u+u,x=d+d,T=b+b,M=u*_,L=u*x,I=u*T,D=d*x,F=d*T,O=b*T,z=w*_,Z=w*x,H=w*T,te=c[0],se=c[1],ne=c[2];return s[0]=(1-(D+O))*te,s[1]=(L+H)*te,s[2]=(I-Z)*te,s[3]=0,s[4]=(L-H)*se,s[5]=(1-(M+O))*se,s[6]=(F+z)*se,s[7]=0,s[8]=(I+Z)*ne,s[9]=(F-z)*ne,s[10]=(1-(M+D))*ne,s[11]=0,s[12]=r[0],s[13]=r[1],s[14]=r[2],s[15]=1,s}function HZt(s,n,r,c,u){let d=n[0],b=n[1],w=n[2],_=n[3],x=d+d,T=b+b,M=w+w,L=d*x,I=d*T,D=d*M,F=b*T,O=b*M,z=w*M,Z=_*x,H=_*T,te=_*M,se=c[0],ne=c[1],ue=c[2],Ce=u[0],Q=u[1],me=u[2],tt=(1-(F+z))*se,st=(I+te)*se,at=(D-H)*se,Ne=(I-te)*ne,Qe=(1-(L+z))*ne,ot=(O+Z)*ne,xt=(D+H)*ue,fn=(O-Z)*ue,Xt=(1-(L+F))*ue;return s[0]=tt,s[1]=st,s[2]=at,s[3]=0,s[4]=Ne,s[5]=Qe,s[6]=ot,s[7]=0,s[8]=xt,s[9]=fn,s[10]=Xt,s[11]=0,s[12]=r[0]+Ce-(tt*Ce+Ne*Q+xt*me),s[13]=r[1]+Q-(st*Ce+Qe*Q+fn*me),s[14]=r[2]+me-(at*Ce+ot*Q+Xt*me),s[15]=1,s}function W4e(s,n){let r=n[0],c=n[1],u=n[2],d=n[3],b=r+r,w=c+c,_=u+u,x=r*b,T=c*b,M=c*w,L=u*b,I=u*w,D=u*_,F=d*b,O=d*w,z=d*_;return s[0]=1-M-D,s[1]=T+z,s[2]=L-O,s[3]=0,s[4]=T-z,s[5]=1-x-D,s[6]=I+F,s[7]=0,s[8]=L+O,s[9]=I-F,s[10]=1-x-M,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function H4e(s,n,r,c,u,d,b){let w=1/(r-n),_=1/(u-c),x=1/(d-b);return s[0]=d*2*w,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=d*2*_,s[6]=0,s[7]=0,s[8]=(r+n)*w,s[9]=(u+c)*_,s[10]=(b+d)*x,s[11]=-1,s[12]=0,s[13]=0,s[14]=b*d*2*x,s[15]=0,s}function $pt(s,n,r,c,u){let d=1/Math.tan(n/2);if(s[0]=d/r,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=d,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[11]=-1,s[12]=0,s[13]=0,s[15]=0,u!=null&&u!==1/0){let b=1/(c-u);s[10]=(u+c)*b,s[14]=2*u*c*b}else s[10]=-1,s[14]=-2*c;return s}function qZt(s,n,r,c,u){let d=1/Math.tan(n/2);if(s[0]=d/r,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=d,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[11]=-1,s[12]=0,s[13]=0,s[15]=0,u!=null&&u!==1/0){let b=1/(c-u);s[10]=u*b,s[14]=u*c*b}else s[10]=-1,s[14]=-c;return s}function XZt(s,n,r,c){let u=Math.tan(n.upDegrees*Math.PI/180),d=Math.tan(n.downDegrees*Math.PI/180),b=Math.tan(n.leftDegrees*Math.PI/180),w=Math.tan(n.rightDegrees*Math.PI/180),_=2/(b+w),x=2/(u+d);return s[0]=_,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=x,s[6]=0,s[7]=0,s[8]=-((b-w)*_*.5),s[9]=(u-d)*x*.5,s[10]=c/(r-c),s[11]=-1,s[12]=0,s[13]=0,s[14]=c*r/(r-c),s[15]=0,s}function Vpt(s,n,r,c,u,d,b){let w=1/(n-r),_=1/(c-u),x=1/(d-b);return s[0]=-2*w,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=-2*_,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=2*x,s[11]=0,s[12]=(n+r)*w,s[13]=(u+c)*_,s[14]=(b+d)*x,s[15]=1,s}function YZt(s,n,r,c,u,d,b){let w=1/(n-r),_=1/(c-u),x=1/(d-b);return s[0]=-2*w,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=-2*_,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=x,s[11]=0,s[12]=(n+r)*w,s[13]=(u+c)*_,s[14]=d*x,s[15]=1,s}function Y4e(s,n,r,c){let u,d,b,w,_,x,T,M,L,I,D=n[0],F=n[1],O=n[2],z=c[0],Z=c[1],H=c[2],te=r[0],se=r[1],ne=r[2];return Math.abs(D-te)<1e-6&&Math.abs(F-se)<1e-6&&Math.abs(O-ne)<1e-6?zpt(s):(M=D-te,L=F-se,I=O-ne,u=1/Math.sqrt(M*M+L*L+I*I),M*=u,L*=u,I*=u,d=Z*I-H*L,b=H*M-z*I,w=z*L-Z*M,u=Math.sqrt(d*d+b*b+w*w),u?(u=1/u,d*=u,b*=u,w*=u):(d=0,b=0,w=0),_=L*w-I*b,x=I*d-M*w,T=M*b-L*d,u=Math.sqrt(_*_+x*x+T*T),u?(u=1/u,_*=u,x*=u,T*=u):(_=0,x=0,T=0),s[0]=d,s[1]=_,s[2]=M,s[3]=0,s[4]=b,s[5]=x,s[6]=L,s[7]=0,s[8]=w,s[9]=T,s[10]=I,s[11]=0,s[12]=-(d*D+b*F+w*O),s[13]=-(_*D+x*F+T*O),s[14]=-(M*D+L*F+I*O),s[15]=1,s)}function ZZt(s,n,r,c){let u=n[0],d=n[1],b=n[2],w=c[0],_=c[1],x=c[2],T=u-r[0],M=d-r[1],L=b-r[2],I=T*T+M*M+L*L;I>0&&(I=1/Math.sqrt(I),T*=I,M*=I,L*=I);let D=_*L-x*M,F=x*T-w*L,O=w*M-_*T;return I=D*D+F*F+O*O,I>0&&(I=1/Math.sqrt(I),D*=I,F*=I,O*=I),s[0]=D,s[1]=F,s[2]=O,s[3]=0,s[4]=M*O-L*F,s[5]=L*D-T*O,s[6]=T*F-M*D,s[7]=0,s[8]=T,s[9]=M,s[10]=L,s[11]=0,s[12]=u,s[13]=d,s[14]=b,s[15]=1,s}function KZt(s){return`mat4(${s[0]}, ${s[1]}, ${s[2]}, ${s[3]}, ${s[4]}, ${s[5]}, ${s[6]}, ${s[7]}, ${s[8]}, ${s[9]}, ${s[10]}, ${s[11]}, ${s[12]}, ${s[13]}, ${s[14]}, ${s[15]})`}function JZt(s){return Math.sqrt(s[0]*s[0]+s[1]*s[1]+s[2]*s[2]+s[3]*s[3]+s[4]*s[4]+s[5]*s[5]+s[6]*s[6]+s[7]*s[7]+s[8]*s[8]+s[9]*s[9]+s[10]*s[10]+s[11]*s[11]+s[12]*s[12]+s[13]*s[13]+s[14]*s[14]+s[15]*s[15])}function QZt(s,n,r){return s[0]=n[0]+r[0],s[1]=n[1]+r[1],s[2]=n[2]+r[2],s[3]=n[3]+r[3],s[4]=n[4]+r[4],s[5]=n[5]+r[5],s[6]=n[6]+r[6],s[7]=n[7]+r[7],s[8]=n[8]+r[8],s[9]=n[9]+r[9],s[10]=n[10]+r[10],s[11]=n[11]+r[11],s[12]=n[12]+r[12],s[13]=n[13]+r[13],s[14]=n[14]+r[14],s[15]=n[15]+r[15],s}function Wpt(s,n,r){return s[0]=n[0]-r[0],s[1]=n[1]-r[1],s[2]=n[2]-r[2],s[3]=n[3]-r[3],s[4]=n[4]-r[4],s[5]=n[5]-r[5],s[6]=n[6]-r[6],s[7]=n[7]-r[7],s[8]=n[8]-r[8],s[9]=n[9]-r[9],s[10]=n[10]-r[10],s[11]=n[11]-r[11],s[12]=n[12]-r[12],s[13]=n[13]-r[13],s[14]=n[14]-r[14],s[15]=n[15]-r[15],s}function eKt(s,n,r){return s[0]=n[0]*r,s[1]=n[1]*r,s[2]=n[2]*r,s[3]=n[3]*r,s[4]=n[4]*r,s[5]=n[5]*r,s[6]=n[6]*r,s[7]=n[7]*r,s[8]=n[8]*r,s[9]=n[9]*r,s[10]=n[10]*r,s[11]=n[11]*r,s[12]=n[12]*r,s[13]=n[13]*r,s[14]=n[14]*r,s[15]=n[15]*r,s}function tKt(s,n,r,c){return s[0]=n[0]+r[0]*c,s[1]=n[1]+r[1]*c,s[2]=n[2]+r[2]*c,s[3]=n[3]+r[3]*c,s[4]=n[4]+r[4]*c,s[5]=n[5]+r[5]*c,s[6]=n[6]+r[6]*c,s[7]=n[7]+r[7]*c,s[8]=n[8]+r[8]*c,s[9]=n[9]+r[9]*c,s[10]=n[10]+r[10]*c,s[11]=n[11]+r[11]*c,s[12]=n[12]+r[12]*c,s[13]=n[13]+r[13]*c,s[14]=n[14]+r[14]*c,s[15]=n[15]+r[15]*c,s}function nKt(s,n){return s[0]===n[0]&&s[1]===n[1]&&s[2]===n[2]&&s[3]===n[3]&&s[4]===n[4]&&s[5]===n[5]&&s[6]===n[6]&&s[7]===n[7]&&s[8]===n[8]&&s[9]===n[9]&&s[10]===n[10]&&s[11]===n[11]&&s[12]===n[12]&&s[13]===n[13]&&s[14]===n[14]&&s[15]===n[15]}function iKt(s,n){let r=s[0],c=s[1],u=s[2],d=s[3],b=s[4],w=s[5],_=s[6],x=s[7],T=s[8],M=s[9],L=s[10],I=s[11],D=s[12],F=s[13],O=s[14],z=s[15],Z=n[0],H=n[1],te=n[2],se=n[3],ne=n[4],ue=n[5],Ce=n[6],Q=n[7],me=n[8],tt=n[9],st=n[10],at=n[11],Ne=n[12],Qe=n[13],ot=n[14],xt=n[15];return Math.abs(r-Z)<=1e-6*Math.max(1,Math.abs(r),Math.abs(Z))&&Math.abs(c-H)<=1e-6*Math.max(1,Math.abs(c),Math.abs(H))&&Math.abs(u-te)<=1e-6*Math.max(1,Math.abs(u),Math.abs(te))&&Math.abs(d-se)<=1e-6*Math.max(1,Math.abs(d),Math.abs(se))&&Math.abs(b-ne)<=1e-6*Math.max(1,Math.abs(b),Math.abs(ne))&&Math.abs(w-ue)<=1e-6*Math.max(1,Math.abs(w),Math.abs(ue))&&Math.abs(_-Ce)<=1e-6*Math.max(1,Math.abs(_),Math.abs(Ce))&&Math.abs(x-Q)<=1e-6*Math.max(1,Math.abs(x),Math.abs(Q))&&Math.abs(T-me)<=1e-6*Math.max(1,Math.abs(T),Math.abs(me))&&Math.abs(M-tt)<=1e-6*Math.max(1,Math.abs(M),Math.abs(tt))&&Math.abs(L-st)<=1e-6*Math.max(1,Math.abs(L),Math.abs(st))&&Math.abs(I-at)<=1e-6*Math.max(1,Math.abs(I),Math.abs(at))&&Math.abs(D-Ne)<=1e-6*Math.max(1,Math.abs(D),Math.abs(Ne))&&Math.abs(F-Qe)<=1e-6*Math.max(1,Math.abs(F),Math.abs(Qe))&&Math.abs(O-ot)<=1e-6*Math.max(1,Math.abs(O),Math.abs(ot))&&Math.abs(z-xt)<=1e-6*Math.max(1,Math.abs(z),Math.abs(xt))}var q4e,X4e,rKt,sKt,Z4e=Ve(()=>{f4();q4e=$pt;X4e=Vpt;rKt=F$,sKt=Wpt});var U1={};Oy(U1,{add:()=>Kpt,ceil:()=>oKt,clone:()=>qpt,copy:()=>Ypt,create:()=>Hpt,cross:()=>pKt,dist:()=>EKt,distance:()=>ngt,div:()=>xKt,divide:()=>egt,dot:()=>rgt,equals:()=>vKt,exactEquals:()=>ogt,floor:()=>aKt,forEach:()=>CKt,fromValues:()=>Xpt,inverse:()=>dKt,len:()=>MKt,length:()=>K4e,lerp:()=>sgt,max:()=>lKt,min:()=>cKt,mul:()=>yKt,multiply:()=>Qpt,negate:()=>hKt,normalize:()=>Q4e,random:()=>gKt,round:()=>uKt,scale:()=>tgt,scaleAndAdd:()=>fKt,set:()=>Zpt,sqrDist:()=>SKt,sqrLen:()=>TKt,squaredDistance:()=>igt,squaredLength:()=>J4e,str:()=>wKt,sub:()=>_Kt,subtract:()=>Jpt,transformMat4:()=>eke,transformQuat:()=>mKt,zero:()=>bKt});function Hpt(){let s=new Tc(4);return Tc!=Float32Array&&(s[0]=0,s[1]=0,s[2]=0,s[3]=0),s}function qpt(s){let n=new Tc(4);return n[0]=s[0],n[1]=s[1],n[2]=s[2],n[3]=s[3],n}function Xpt(s,n,r,c){let u=new Tc(4);return u[0]=s,u[1]=n,u[2]=r,u[3]=c,u}function Ypt(s,n){return s[0]=n[0],s[1]=n[1],s[2]=n[2],s[3]=n[3],s}function Zpt(s,n,r,c,u){return s[0]=n,s[1]=r,s[2]=c,s[3]=u,s}function Kpt(s,n,r){return s[0]=n[0]+r[0],s[1]=n[1]+r[1],s[2]=n[2]+r[2],s[3]=n[3]+r[3],s}function Jpt(s,n,r){return s[0]=n[0]-r[0],s[1]=n[1]-r[1],s[2]=n[2]-r[2],s[3]=n[3]-r[3],s}function Qpt(s,n,r){return s[0]=n[0]*r[0],s[1]=n[1]*r[1],s[2]=n[2]*r[2],s[3]=n[3]*r[3],s}function egt(s,n,r){return s[0]=n[0]/r[0],s[1]=n[1]/r[1],s[2]=n[2]/r[2],s[3]=n[3]/r[3],s}function oKt(s,n){return s[0]=Math.ceil(n[0]),s[1]=Math.ceil(n[1]),s[2]=Math.ceil(n[2]),s[3]=Math.ceil(n[3]),s}function aKt(s,n){return s[0]=Math.floor(n[0]),s[1]=Math.floor(n[1]),s[2]=Math.floor(n[2]),s[3]=Math.floor(n[3]),s}function cKt(s,n,r){return s[0]=Math.min(n[0],r[0]),s[1]=Math.min(n[1],r[1]),s[2]=Math.min(n[2],r[2]),s[3]=Math.min(n[3],r[3]),s}function lKt(s,n,r){return s[0]=Math.max(n[0],r[0]),s[1]=Math.max(n[1],r[1]),s[2]=Math.max(n[2],r[2]),s[3]=Math.max(n[3],r[3]),s}function uKt(s,n){return s[0]=Tb(n[0]),s[1]=Tb(n[1]),s[2]=Tb(n[2]),s[3]=Tb(n[3]),s}function tgt(s,n,r){return s[0]=n[0]*r,s[1]=n[1]*r,s[2]=n[2]*r,s[3]=n[3]*r,s}function fKt(s,n,r,c){return s[0]=n[0]+r[0]*c,s[1]=n[1]+r[1]*c,s[2]=n[2]+r[2]*c,s[3]=n[3]+r[3]*c,s}function ngt(s,n){let r=n[0]-s[0],c=n[1]-s[1],u=n[2]-s[2],d=n[3]-s[3];return Math.sqrt(r*r+c*c+u*u+d*d)}function igt(s,n){let r=n[0]-s[0],c=n[1]-s[1],u=n[2]-s[2],d=n[3]-s[3];return r*r+c*c+u*u+d*d}function K4e(s){let n=s[0],r=s[1],c=s[2],u=s[3];return Math.sqrt(n*n+r*r+c*c+u*u)}function J4e(s){let n=s[0],r=s[1],c=s[2],u=s[3];return n*n+r*r+c*c+u*u}function hKt(s,n){return s[0]=-n[0],s[1]=-n[1],s[2]=-n[2],s[3]=-n[3],s}function dKt(s,n){return s[0]=1/n[0],s[1]=1/n[1],s[2]=1/n[2],s[3]=1/n[3],s}function Q4e(s,n){let r=n[0],c=n[1],u=n[2],d=n[3],b=r*r+c*c+u*u+d*d;return b>0&&(b=1/Math.sqrt(b)),s[0]=r*b,s[1]=c*b,s[2]=u*b,s[3]=d*b,s}function rgt(s,n){return s[0]*n[0]+s[1]*n[1]+s[2]*n[2]+s[3]*n[3]}function pKt(s,n,r,c){let u=r[0]*c[1]-r[1]*c[0],d=r[0]*c[2]-r[2]*c[0],b=r[0]*c[3]-r[3]*c[0],w=r[1]*c[2]-r[2]*c[1],_=r[1]*c[3]-r[3]*c[1],x=r[2]*c[3]-r[3]*c[2],T=n[0],M=n[1],L=n[2],I=n[3];return s[0]=M*x-L*_+I*w,s[1]=-(T*x)+L*b-I*d,s[2]=T*_-M*b+I*u,s[3]=-(T*w)+M*d-L*u,s}function sgt(s,n,r,c){let u=n[0],d=n[1],b=n[2],w=n[3];return s[0]=u+c*(r[0]-u),s[1]=d+c*(r[1]-d),s[2]=b+c*(r[2]-b),s[3]=w+c*(r[3]-w),s}function gKt(s,n){n=n===void 0?1:n;let r,c,u,d,b,w;do r=Hy()*2-1,c=Hy()*2-1,b=r*r+c*c;while(b>=1);do u=Hy()*2-1,d=Hy()*2-1,w=u*u+d*d;while(w>=1);let _=Math.sqrt((1-b)/w);return s[0]=n*r,s[1]=n*c,s[2]=n*u*_,s[3]=n*d*_,s}function eke(s,n,r){let c=n[0],u=n[1],d=n[2],b=n[3];return s[0]=r[0]*c+r[4]*u+r[8]*d+r[12]*b,s[1]=r[1]*c+r[5]*u+r[9]*d+r[13]*b,s[2]=r[2]*c+r[6]*u+r[10]*d+r[14]*b,s[3]=r[3]*c+r[7]*u+r[11]*d+r[15]*b,s}function mKt(s,n,r){let c=n[0],u=n[1],d=n[2],b=r[0],w=r[1],_=r[2],x=r[3],T=x*c+w*d-_*u,M=x*u+_*c-b*d,L=x*d+b*u-w*c,I=-b*c-w*u-_*d;return s[0]=T*x+I*-b+M*-_-L*-w,s[1]=M*x+I*-w+L*-b-T*-_,s[2]=L*x+I*-_+T*-w-M*-b,s[3]=n[3],s}function bKt(s){return s[0]=0,s[1]=0,s[2]=0,s[3]=0,s}function wKt(s){return`vec4(${s[0]}, ${s[1]}, ${s[2]}, ${s[3]})`}function ogt(s,n){return s[0]===n[0]&&s[1]===n[1]&&s[2]===n[2]&&s[3]===n[3]}function vKt(s,n){let r=s[0],c=s[1],u=s[2],d=s[3],b=n[0],w=n[1],_=n[2],x=n[3];return Math.abs(r-b)<=1e-6*Math.max(1,Math.abs(r),Math.abs(b))&&Math.abs(c-w)<=1e-6*Math.max(1,Math.abs(c),Math.abs(w))&&Math.abs(u-_)<=1e-6*Math.max(1,Math.abs(u),Math.abs(_))&&Math.abs(d-x)<=1e-6*Math.max(1,Math.abs(d),Math.abs(x))}var _Kt,yKt,xKt,EKt,SKt,MKt,TKt,CKt,Kce=Ve(()=>{f4();_Kt=Jpt,yKt=Qpt,xKt=egt,EKt=ngt,SKt=igt,MKt=K4e,TKt=J4e,CKt=function(){let s=Hpt();return function(n,r,c,u,d,b){let w,_;for(r||(r=4),c||(c=0),u?_=Math.min(u*r+c,n.length):_=n.length,w=c;w<_;w+=r)s[0]=n[w],s[1]=n[w+1],s[2]=n[w+2],s[3]=n[w+3],d(s,s,b),n[w]=s[0],n[w+1]=s[1],n[w+2]=s[2],n[w+3]=s[3];return n}}()});function kKt(){return Jce||(Jce=new Df([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Jce)),Jce}function RKt(){return Qce||(Qce=new Df,Object.freeze(Qce)),Qce}function agt(s){if(s>Math.PI*2)throw Error("expected radians")}function IKt(s,n,r,c,u,d){let b=2*d/(r-n),w=2*d/(u-c),_=(r+n)/(r-n),x=(u+c)/(u-c),T=-1,M=-1,L=-2*d;return s[0]=b,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=w,s[6]=0,s[7]=0,s[8]=_,s[9]=x,s[10]=T,s[11]=M,s[12]=0,s[13]=0,s[14]=L,s[15]=0,s}var ike,AKt,PKt,tke,nke,LKt,Df,Jce,Qce,cgt=Ve(()=>{Npt();D$();M4e();Z4e();S4e();N$();Kce();(function(s){s[s.COL0ROW0=0]="COL0ROW0",s[s.COL0ROW1=1]="COL0ROW1",s[s.COL0ROW2=2]="COL0ROW2",s[s.COL0ROW3=3]="COL0ROW3",s[s.COL1ROW0=4]="COL1ROW0",s[s.COL1ROW1=5]="COL1ROW1",s[s.COL1ROW2=6]="COL1ROW2",s[s.COL1ROW3=7]="COL1ROW3",s[s.COL2ROW0=8]="COL2ROW0",s[s.COL2ROW1=9]="COL2ROW1",s[s.COL2ROW2=10]="COL2ROW2",s[s.COL2ROW3=11]="COL2ROW3",s[s.COL3ROW0=12]="COL3ROW0",s[s.COL3ROW1=13]="COL3ROW1",s[s.COL3ROW2=14]="COL3ROW2",s[s.COL3ROW3=15]="COL3ROW3"})(ike||(ike={}));AKt=45*Math.PI/180,PKt=1,tke=.1,nke=500,LKt=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),Df=class extends Zce{static get IDENTITY(){return RKt()}static get ZERO(){return kKt()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return ike}constructor(n){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(n)?this.copy(n):this.identity()}copy(n){return this[0]=n[0],this[1]=n[1],this[2]=n[2],this[3]=n[3],this[4]=n[4],this[5]=n[5],this[6]=n[6],this[7]=n[7],this[8]=n[8],this[9]=n[9],this[10]=n[10],this[11]=n[11],this[12]=n[12],this[13]=n[13],this[14]=n[14],this[15]=n[15],this.check()}set(n,r,c,u,d,b,w,_,x,T,M,L,I,D,F,O){return this[0]=n,this[1]=r,this[2]=c,this[3]=u,this[4]=d,this[5]=b,this[6]=w,this[7]=_,this[8]=x,this[9]=T,this[10]=M,this[11]=L,this[12]=I,this[13]=D,this[14]=F,this[15]=O,this.check()}setRowMajor(n,r,c,u,d,b,w,_,x,T,M,L,I,D,F,O){return this[0]=n,this[1]=d,this[2]=x,this[3]=I,this[4]=r,this[5]=b,this[6]=T,this[7]=D,this[8]=c,this[9]=w,this[10]=M,this[11]=F,this[12]=u,this[13]=_,this[14]=L,this[15]=O,this.check()}toRowMajor(n){return n[0]=this[0],n[1]=this[4],n[2]=this[8],n[3]=this[12],n[4]=this[1],n[5]=this[5],n[6]=this[9],n[7]=this[13],n[8]=this[2],n[9]=this[6],n[10]=this[10],n[11]=this[14],n[12]=this[3],n[13]=this[7],n[14]=this[11],n[15]=this[15],n}identity(){return this.copy(LKt)}fromObject(n){return this.check()}fromQuaternion(n){return W4e(this,n),this.check()}frustum(n){let{left:r,right:c,bottom:u,top:d,near:b=tke,far:w=nke}=n;return w===1/0?IKt(this,r,c,u,d,b):H4e(this,r,c,u,d,b,w),this.check()}lookAt(n){let{eye:r,center:c=[0,0,0],up:u=[0,1,0]}=n;return Y4e(this,r,c,u),this.check()}ortho(n){let{left:r,right:c,bottom:u,top:d,near:b=tke,far:w=nke}=n;return X4e(this,r,c,u,d,b,w),this.check()}orthographic(n){let{fovy:r=AKt,aspect:c=PKt,focalDistance:u=1,near:d=tke,far:b=nke}=n;agt(r);let w=r/2,_=u*Math.tan(w),x=_*c;return this.ortho({left:-x,right:x,bottom:-_,top:_,near:d,far:b})}perspective(n){let{fovy:r=45*Math.PI/180,aspect:c=1,near:u=.1,far:d=500}=n;return agt(r),q4e(this,r,c,u,d),this.check()}determinant(){return F4e(this)}getScale(n=[-0,-0,-0]){return n[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),n[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),n[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),n}getTranslation(n=[-0,-0,-0]){return n[0]=this[12],n[1]=this[13],n[2]=this[14],n}getRotation(n,r){n=n||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let c=this.getScale(r),u=1/c[0],d=1/c[1],b=1/c[2];return n[0]=this[0]*u,n[1]=this[1]*d,n[2]=this[2]*b,n[3]=0,n[4]=this[4]*u,n[5]=this[5]*d,n[6]=this[6]*b,n[7]=0,n[8]=this[8]*u,n[9]=this[9]*d,n[10]=this[10]*b,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}getRotationMatrix3(n,r){n=n||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let c=this.getScale(r),u=1/c[0],d=1/c[1],b=1/c[2];return n[0]=this[0]*u,n[1]=this[1]*d,n[2]=this[2]*b,n[3]=this[4]*u,n[4]=this[5]*d,n[5]=this[6]*b,n[6]=this[8]*u,n[7]=this[9]*d,n[8]=this[10]*b,n}transpose(){return O4e(this,this),this.check()}invert(){return N4e(this,this),this.check()}multiplyLeft(n){return F$(this,n,this),this.check()}multiplyRight(n){return F$(this,this,n),this.check()}rotateX(n){return j4e(this,this,n),this.check()}rotateY(n){return $4e(this,this,n),this.check()}rotateZ(n){return V4e(this,this,n),this.check()}rotateXYZ(n){return this.rotateX(n[0]).rotateY(n[1]).rotateZ(n[2])}rotateAxis(n,r){return G4e(this,this,n,r),this.check()}scale(n){return z4e(this,this,Array.isArray(n)?n:[n,n,n]),this.check()}translate(n){return U4e(this,this,n),this.check()}transform(n,r){return n.length===4?(r=eke(r||[-0,-0,-0,-0],n,this),Vce(r,4),r):this.transformAsPoint(n,r)}transformAsPoint(n,r){let{length:c}=n,u;switch(c){case 2:u=E4e(r||[-0,-0],n,this);break;case 3:u=O$(r||[-0,-0,-0],n,this);break;default:throw new Error("Illegal vector")}return Vce(u,n.length),u}transformAsVector(n,r){let c;switch(n.length){case 2:c=Cpt(r||[-0,-0],n,this);break;case 3:c=Hce(r||[-0,-0,-0],n,this);break;default:throw new Error("Illegal vector")}return Vce(c,n.length),c}transformPoint(n,r){return this.transformAsPoint(n,r)}transformVector(n,r){return this.transformAsPoint(n,r)}transformDirection(n,r){return this.transformAsVector(n,r)}makeRotationX(n){return this.identity().rotateX(n)}makeTranslation(n,r,c){return this.identity().translate([n,r,c])}}});function lgt(){let s=new Tc(4);return Tc!=Float32Array&&(s[0]=0,s[1]=0,s[2]=0),s[3]=1,s}function DKt(s,n,r){r=r*.5;let c=Math.sin(r);return s[0]=c*n[0],s[1]=c*n[1],s[2]=c*n[2],s[3]=Math.cos(r),s}function rke(s,n,r,c){let u=n[0],d=n[1],b=n[2],w=n[3],_=r[0],x=r[1],T=r[2],M=r[3],L,I,D,F,O;return L=u*_+d*x+b*T+w*M,L<0&&(L=-L,_=-_,x=-x,T=-T,M=-M),1-L>1e-6?(I=Math.acos(L),O=Math.sin(I),D=Math.sin((1-c)*I)/O,F=Math.sin(c*I)/O):(D=1-c,F=c),s[0]=D*u+F*_,s[1]=D*d+F*x,s[2]=D*b+F*T,s[3]=D*w+F*M,s}function BKt(s,n){let r=n[0]+n[4]+n[8],c;if(r>0)c=Math.sqrt(r+1),s[3]=.5*c,c=.5/c,s[0]=(n[5]-n[7])*c,s[1]=(n[6]-n[2])*c,s[2]=(n[1]-n[3])*c;else{let u=0;n[4]>n[0]&&(u=1),n[8]>n[u*3+u]&&(u=2);let d=(u+1)%3,b=(u+2)%3;c=Math.sqrt(n[u*3+u]-n[d*3+d]-n[b*3+b]+1),s[u]=.5*c,c=.5/c,s[3]=(n[d*3+b]-n[b*3+d])*c,s[d]=(n[d*3+u]+n[u*3+d])*c,s[b]=(n[b*3+u]+n[u*3+b])*c}return s}var ugt,Tzn,Czn,Azn,fgt=Ve(()=>{f4();B4e();N$();Kce();ugt=Q4e,Tzn=function(){let s=qce(),n=Xce(1,0,0),r=Xce(0,1,0);return function(c,u,d){let b=B$(u,d);return b<-.999999?(h4(s,n,u),I4e(s)<1e-6&&h4(s,r,u),T4e(s,s),DKt(c,s,Math.PI),c):b>.999999?(c[0]=0,c[1]=0,c[2]=0,c[3]=1,c):(h4(s,u,d),c[0]=s[0],c[1]=s[1],c[2]=s[2],c[3]=1+b,ugt(c,c))}}(),Czn=function(){let s=lgt(),n=lgt();return function(r,c,u,d,b,w){return rke(s,c,b,w),rke(n,u,d,w),rke(r,s,n,2*w*(1-w)),r}}(),Azn=function(){let s=Fpt();return function(n,r,c,u){return s[0]=c[0],s[3]=c[1],s[6]=c[2],s[1]=u[0],s[4]=u[1],s[7]=u[2],s[2]=-r[0],s[5]=-r[1],s[8]=-r[2],ugt(n,BKt(n,s))}}()});var Pzn,Lzn,kzn,Rzn,hgt=Ve(()=>{Pzn=Math.PI/2,Lzn=Math.PI/4,kzn=Math.PI/6,Rzn=Math.PI*2});var Bf=Ve(()=>{Opt();cgt();hgt();qD();B4e();Z4e();fgt();S4e();N$();Kce()});function ske(s,n=[],r=0){let c=Math.fround(s),u=s-c;return n[r]=c,n[r+1]=u,n}function dgt(s){return s-Math.fround(s)}function pgt(s){let n=new Float32Array(32);for(let r=0;r<4;++r)for(let c=0;c<4;++c){let u=r*4+c;ske(s[c*4+r],n,u*2)}return n}var ggt=Ve(()=>{});function ele(s,n=!0){return s??n}function oke(s=[0,0,0],n=!0){return n?s.map(r=>r/255):[...s]}function mgt(s,n=!0){let r=oke(s.slice(0,3),n),c=Number.isFinite(s[3]),u=c?s[3]:1;return[r[0],r[1],r[2],n&&c?u/255:u]}var ake=Ve(()=>{});var FKt,UKt,d4,bgt=Ve(()=>{FKt=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND + +// All these functions are for substituting tan() function from Intel GPU only +const float TWO_PI = 6.2831854820251465; +const float PI_2 = 1.5707963705062866; +const float PI_16 = 0.1963495463132858; + +const float SIN_TABLE_0 = 0.19509032368659973; +const float SIN_TABLE_1 = 0.3826834261417389; +const float SIN_TABLE_2 = 0.5555702447891235; +const float SIN_TABLE_3 = 0.7071067690849304; + +const float COS_TABLE_0 = 0.9807852506637573; +const float COS_TABLE_1 = 0.9238795042037964; +const float COS_TABLE_2 = 0.8314695954322815; +const float COS_TABLE_3 = 0.7071067690849304; + +const float INVERSE_FACTORIAL_3 = 1.666666716337204e-01; // 1/3! +const float INVERSE_FACTORIAL_5 = 8.333333767950535e-03; // 1/5! +const float INVERSE_FACTORIAL_7 = 1.9841270113829523e-04; // 1/7! +const float INVERSE_FACTORIAL_9 = 2.75573188446287533e-06; // 1/9! + +float sin_taylor_fp32(float a) { + float r, s, t, x; + + if (a == 0.0) { + return 0.0; + } + + x = -a * a; + s = a; + r = a; + + r = r * x; + t = r * INVERSE_FACTORIAL_3; + s = s + t; + + r = r * x; + t = r * INVERSE_FACTORIAL_5; + s = s + t; + + r = r * x; + t = r * INVERSE_FACTORIAL_7; + s = s + t; + + r = r * x; + t = r * INVERSE_FACTORIAL_9; + s = s + t; + + return s; +} + +void sincos_taylor_fp32(float a, out float sin_t, out float cos_t) { + if (a == 0.0) { + sin_t = 0.0; + cos_t = 1.0; + } + sin_t = sin_taylor_fp32(a); + cos_t = sqrt(1.0 - sin_t * sin_t); +} + +float tan_taylor_fp32(float a) { + float sin_a; + float cos_a; + + if (a == 0.0) { + return 0.0; + } + + // 2pi range reduction + float z = floor(a / TWO_PI); + float r = a - TWO_PI * z; + + float t; + float q = floor(r / PI_2 + 0.5); + int j = int(q); + + if (j < -2 || j > 2) { + return 1.0 / 0.0; + } + + t = r - PI_2 * q; + + q = floor(t / PI_16 + 0.5); + int k = int(q); + int abs_k = int(abs(float(k))); + + if (abs_k > 4) { + return 1.0 / 0.0; + } else { + t = t - PI_16 * q; + } + + float u = 0.0; + float v = 0.0; + + float sin_t, cos_t; + float s, c; + sincos_taylor_fp32(t, sin_t, cos_t); + + if (k == 0) { + s = sin_t; + c = cos_t; + } else { + if (abs(float(abs_k) - 1.0) < 0.5) { + u = COS_TABLE_0; + v = SIN_TABLE_0; + } else if (abs(float(abs_k) - 2.0) < 0.5) { + u = COS_TABLE_1; + v = SIN_TABLE_1; + } else if (abs(float(abs_k) - 3.0) < 0.5) { + u = COS_TABLE_2; + v = SIN_TABLE_2; + } else if (abs(float(abs_k) - 4.0) < 0.5) { + u = COS_TABLE_3; + v = SIN_TABLE_3; + } + if (k > 0) { + s = u * sin_t + v * cos_t; + c = u * cos_t - v * sin_t; + } else { + s = u * sin_t - v * cos_t; + c = u * cos_t + v * sin_t; + } + } + + if (j == 0) { + sin_a = s; + cos_a = c; + } else if (j == 1) { + sin_a = c; + cos_a = -s; + } else if (j == -1) { + sin_a = -c; + cos_a = s; + } else { + sin_a = -s; + cos_a = -c; + } + return sin_a / cos_a; +} +#endif + +float tan_fp32(float a) { +#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND + return tan_taylor_fp32(a); +#else + return tan(a); +#endif +} +`,UKt=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND +const FP32_TWO_PI: f32 = 6.2831854820251465; +const FP32_PI_2: f32 = 1.5707963705062866; +const FP32_PI_16: f32 = 0.1963495463132858; + +const FP32_SIN_TABLE_0: f32 = 0.19509032368659973; +const FP32_SIN_TABLE_1: f32 = 0.3826834261417389; +const FP32_SIN_TABLE_2: f32 = 0.5555702447891235; +const FP32_SIN_TABLE_3: f32 = 0.7071067690849304; + +const FP32_COS_TABLE_0: f32 = 0.9807852506637573; +const FP32_COS_TABLE_1: f32 = 0.9238795042037964; +const FP32_COS_TABLE_2: f32 = 0.8314695954322815; +const FP32_COS_TABLE_3: f32 = 0.7071067690849304; + +const FP32_INVERSE_FACTORIAL_3: f32 = 1.666666716337204e-01; +const FP32_INVERSE_FACTORIAL_5: f32 = 8.333333767950535e-03; +const FP32_INVERSE_FACTORIAL_7: f32 = 1.9841270113829523e-04; +const FP32_INVERSE_FACTORIAL_9: f32 = 2.75573188446287533e-06; +const FP32_OVERFLOW: f32 = 3.402823466e+38; + +fn sin_taylor_fp32(a: f32) -> f32 { + if (a == 0.0) { + return 0.0; + } + + let x = -a * a; + var sum = a; + var term = a; + + term = term * x; + sum = sum + term * FP32_INVERSE_FACTORIAL_3; + term = term * x; + sum = sum + term * FP32_INVERSE_FACTORIAL_5; + term = term * x; + sum = sum + term * FP32_INVERSE_FACTORIAL_7; + term = term * x; + sum = sum + term * FP32_INVERSE_FACTORIAL_9; + + return sum; +} + +fn tan_taylor_fp32(a: f32) -> f32 { + if (a == 0.0) { + return 0.0; + } + + let z = floor(a / FP32_TWO_PI); + let reduced = a - FP32_TWO_PI * z; + + var quadrantValue = floor(reduced / FP32_PI_2 + 0.5); + let quadrant = i32(quadrantValue); + if (quadrant < -2 || quadrant > 2) { + return FP32_OVERFLOW; + } + + var angle = reduced - FP32_PI_2 * quadrantValue; + quadrantValue = floor(angle / FP32_PI_16 + 0.5); + let tableIndex = i32(quadrantValue); + let absoluteTableIndex = abs(tableIndex); + if (absoluteTableIndex > 4) { + return FP32_OVERFLOW; + } + + angle = angle - FP32_PI_16 * quadrantValue; + let sinAngle = sin_taylor_fp32(angle); + let cosAngle = sqrt(1.0 - sinAngle * sinAngle); + + var tableCos = 0.0; + var tableSin = 0.0; + if (absoluteTableIndex == 1) { + tableCos = FP32_COS_TABLE_0; + tableSin = FP32_SIN_TABLE_0; + } else if (absoluteTableIndex == 2) { + tableCos = FP32_COS_TABLE_1; + tableSin = FP32_SIN_TABLE_1; + } else if (absoluteTableIndex == 3) { + tableCos = FP32_COS_TABLE_2; + tableSin = FP32_SIN_TABLE_2; + } else if (absoluteTableIndex == 4) { + tableCos = FP32_COS_TABLE_3; + tableSin = FP32_SIN_TABLE_3; + } + + var sinReduced = sinAngle; + var cosReduced = cosAngle; + if (tableIndex > 0) { + sinReduced = tableCos * sinAngle + tableSin * cosAngle; + cosReduced = tableCos * cosAngle - tableSin * sinAngle; + } else if (tableIndex < 0) { + sinReduced = tableCos * sinAngle - tableSin * cosAngle; + cosReduced = tableCos * cosAngle + tableSin * sinAngle; + } + + var sinValue = 0.0; + var cosValue = 0.0; + if (quadrant == 0) { + sinValue = sinReduced; + cosValue = cosReduced; + } else if (quadrant == 1) { + sinValue = cosReduced; + cosValue = -sinReduced; + } else if (quadrant == -1) { + sinValue = -cosReduced; + cosValue = sinReduced; + } else { + sinValue = -sinReduced; + cosValue = -cosReduced; + } + + return sinValue / cosValue; +} + +fn tan_fp32(a: f32) -> f32 { + return tan_taylor_fp32(a); +} +#else +fn tan_fp32(a: f32) -> f32 { + return tan(a); +} +#endif +`,d4={name:"fp32",source:UKt,vs:FKt}});var cke,wgt=Ve(()=>{cke=` +layout(std140) uniform fp64arithmeticUniforms { + uniform float ONE; + uniform float SPLIT; +} fp64; + +/* +About LUMA_FP64_CODE_ELIMINATION_WORKAROUND + +The purpose of this workaround is to prevent shader compilers from +optimizing away necessary arithmetic operations by swapping their sequences +or transform the equation to some 'equivalent' form. + +These helpers implement Dekker/Veltkamp-style error tracking. If the compiler +folds constants or reassociates the arithmetic, the high/low split can stop +tracking the rounding error correctly. That failure mode tends to look fine in +simple coordinate setup, but then breaks down inside iterative arithmetic such +as fp64 Mandelbrot loops. + +The method is to multiply an artifical variable, ONE, which will be known to +the compiler to be 1 only at runtime. The whole expression is then represented +as a polynomial with respective to ONE. In the coefficients of all terms, only one a +and one b should appear + +err = (a + b) * ONE^6 - a * ONE^5 - (a + b) * ONE^4 + a * ONE^3 - b - (a + b) * ONE^2 + a * ONE +*/ + +float prevent_fp64_optimization(float value) { +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) + return value + fp64.ONE * 0.0; +#else + return value; +#endif +} + +// Divide float number to high and low floats to extend fraction bits +vec2 split(float a) { + // Keep SPLIT as a runtime uniform so the compiler cannot fold the Dekker + // split into a constant expression and reassociate the recovery steps. + float split = prevent_fp64_optimization(fp64.SPLIT); + float t = prevent_fp64_optimization(a * split); + float temp = t - a; + float a_hi = t - temp; + float a_lo = a - a_hi; + return vec2(a_hi, a_lo); +} + +// Divide float number again when high float uses too many fraction bits +vec2 split2(vec2 a) { + vec2 b = split(a.x); + b.y += a.y; + return b; +} + +// Special sum operation when a > b +vec2 quickTwoSum(float a, float b) { +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) + float sum = (a + b) * fp64.ONE; + float err = b - (sum - a) * fp64.ONE; +#else + float sum = a + b; + float err = b - (sum - a); +#endif + return vec2(sum, err); +} + +// General sum operation +vec2 twoSum(float a, float b) { + float s = (a + b); +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) + float v = (s * fp64.ONE - a) * fp64.ONE; + float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE + (b - v); +#else + float v = s - a; + float err = (a - (s - v)) + (b - v); +#endif + return vec2(s, err); +} + +vec2 twoSub(float a, float b) { + float s = (a - b); +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) + float v = (s * fp64.ONE - a) * fp64.ONE; + float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE - (b + v); +#else + float v = s - a; + float err = (a - (s - v)) - (b + v); +#endif + return vec2(s, err); +} + +vec2 twoSqr(float a) { + float prod = a * a; + vec2 a_fp64 = split(a); +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) + float err = ((a_fp64.x * a_fp64.x - prod) * fp64.ONE + 2.0 * a_fp64.x * + a_fp64.y * fp64.ONE * fp64.ONE) + a_fp64.y * a_fp64.y * fp64.ONE * fp64.ONE * fp64.ONE; +#else + float err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y; +#endif + return vec2(prod, err); +} + +vec2 twoProd(float a, float b) { + float prod = a * b; + vec2 a_fp64 = split(a); + vec2 b_fp64 = split(b); + // twoProd is especially sensitive because mul_fp64 and div_fp64 both depend + // on the split terms and cross terms staying in the original evaluation + // order. If the compiler folds or reassociates them, the low part tends to + // collapse to zero or NaN on some drivers. + float highProduct = prevent_fp64_optimization(a_fp64.x * b_fp64.x); + float crossProduct1 = prevent_fp64_optimization(a_fp64.x * b_fp64.y); + float crossProduct2 = prevent_fp64_optimization(a_fp64.y * b_fp64.x); + float lowProduct = prevent_fp64_optimization(a_fp64.y * b_fp64.y); +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) + float err1 = (highProduct - prod) * fp64.ONE; + float err2 = crossProduct1 * fp64.ONE * fp64.ONE; + float err3 = crossProduct2 * fp64.ONE * fp64.ONE * fp64.ONE; + float err4 = lowProduct * fp64.ONE * fp64.ONE * fp64.ONE * fp64.ONE; +#else + float err1 = highProduct - prod; + float err2 = crossProduct1; + float err3 = crossProduct2; + float err4 = lowProduct; +#endif + float err = ((err1 + err2) + err3) + err4; + return vec2(prod, err); +} + +vec2 sum_fp64(vec2 a, vec2 b) { + vec2 s, t; + s = twoSum(a.x, b.x); + t = twoSum(a.y, b.y); + s.y += t.x; + s = quickTwoSum(s.x, s.y); + s.y += t.y; + s = quickTwoSum(s.x, s.y); + return s; +} + +vec2 sub_fp64(vec2 a, vec2 b) { + vec2 s, t; + s = twoSub(a.x, b.x); + t = twoSub(a.y, b.y); + s.y += t.x; + s = quickTwoSum(s.x, s.y); + s.y += t.y; + s = quickTwoSum(s.x, s.y); + return s; +} + +vec2 mul_fp64(vec2 a, vec2 b) { + vec2 prod = twoProd(a.x, b.x); + // y component is for the error + prod.y += a.x * b.y; +#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) + prod = split2(prod); +#endif + prod = quickTwoSum(prod.x, prod.y); + prod.y += a.y * b.x; +#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) + prod = split2(prod); +#endif + prod = quickTwoSum(prod.x, prod.y); + return prod; +} + +vec2 div_fp64(vec2 a, vec2 b) { + float xn = 1.0 / b.x; +#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) + vec2 yn = mul_fp64(a, vec2(xn, 0)); +#else + vec2 yn = a * xn; +#endif + float diff = (sub_fp64(a, mul_fp64(b, yn))).x; + vec2 prod = twoProd(xn, diff); + return sum_fp64(yn, prod); +} + +vec2 sqrt_fp64(vec2 a) { + if (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0); + if (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0); + + float x = 1.0 / sqrt(a.x); + float yn = a.x * x; +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) + vec2 yn_sqr = twoSqr(yn) * fp64.ONE; +#else + vec2 yn_sqr = twoSqr(yn); +#endif + float diff = sub_fp64(a, yn_sqr).x; + vec2 prod = twoProd(x * 0.5, diff); +#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) + return sum_fp64(split(yn), prod); +#else + return sum_fp64(vec2(yn, 0.0), prod); +#endif +} +`});var vgt,_gt=Ve(()=>{vgt=`struct Fp64F32Bits { + sign: u32, + baseExponent: i32, + significand: u32, + isZero: bool, + isInf: bool, + isNan: bool, +}; + +// Decode an f32 as (-1)^sign * significand * 2^baseExponent. +fn fp64_decode_f32_bits(bits: u32) -> Fp64F32Bits { + let sign = bits >> 31u; + let exponentBits = (bits >> 23u) & 0xffu; + let fraction = bits & 0x7fffffu; + + if (exponentBits == 0xffu) { + return Fp64F32Bits(sign, 0, 0u, false, fraction == 0u, fraction != 0u); + } + if (exponentBits == 0u) { + return Fp64F32Bits(sign, -149, fraction, fraction == 0u, false, false); + } + return Fp64F32Bits(sign, i32(exponentBits) - 150, 0x800000u | fraction, false, false, false); +} + +fn fp64_f32_magnitude_compare(aBits: u32, bBits: u32) -> i32 { + let aMagnitude = aBits & 0x7fffffffu; + let bMagnitude = bBits & 0x7fffffffu; + if (aMagnitude == bMagnitude) { + return 0; + } + return select(-1, 1, aMagnitude > bMagnitude); +} + +fn fp64_make_residual_f32_bits( + exactSign: u32, + exactMagnitude: vec2u, + exactBaseExponent: i32, + highBits: u32 +) -> u32 { + if (fp64_u64_is_zero(exactMagnitude)) { + return 0u; + } + + let high = fp64_decode_f32_bits(highBits); + if (high.isInf || high.isNan) { + return exactSign << 31u; + } + if (high.isZero) { + return fp64_make_f32_bits_from_u64(exactSign, exactMagnitude, exactBaseExponent); + } + + let commonBaseExponent = min(exactBaseExponent, high.baseExponent); + let exactShift = exactBaseExponent - commonBaseExponent; + let highShift = high.baseExponent - commonBaseExponent; + + // A normal two-sum/two-product residual never needs a shift this large. + // This guard gives deterministic underflow behavior outside that contract. + if (exactShift >= 64 || highShift >= 64) { + return exactSign << 31u; + } + + let exactAligned = fp64_u64_shift_left(exactMagnitude, u32(exactShift)); + let highAligned = fp64_u64_shift_left(vec2u(0u, high.significand), u32(highShift)); + let comparison = fp64_u64_compare(exactAligned, highAligned); + if (comparison == 0) { + return 0u; + } + + var residualSign = exactSign; + var residualMagnitude: vec2u; + if (comparison > 0) { + residualMagnitude = fp64_u64_sub(exactAligned, highAligned); + } else { + residualSign = exactSign ^ 1u; + residualMagnitude = fp64_u64_sub(highAligned, exactAligned); + } + return fp64_make_f32_bits_from_u64( + residualSign, + residualMagnitude, + commonBaseExponent + ); +} + +fn fp64_split_accumulator_bits( + sign: u32, + magnitude: vec2u, + baseExponent: i32 +) -> vec2u { + let highBits = fp64_make_f32_bits_from_u64(sign, magnitude, baseExponent); + let lowBits = fp64_make_residual_f32_bits(sign, magnitude, baseExponent, highBits); + return vec2u(highBits, lowBits); +} + +fn fp64_two_sum_integer_bits(aBits: u32, bBits: u32) -> vec2u { + let a = fp64_decode_f32_bits(aBits); + let b = fp64_decode_f32_bits(bBits); + + if (a.isNan || b.isNan) { + return vec2u(0x7fc00000u, 0u); + } + if (a.isInf || b.isInf) { + if (a.isInf && b.isInf && a.sign != b.sign) { + return vec2u(0x7fc00000u, 0u); + } + return select(vec2u(bBits, 0u), vec2u(aBits, 0u), a.isInf); + } + if (a.isZero && b.isZero) { + return vec2u((a.sign & b.sign) << 31u, 0u); + } + if (a.isZero) { + return vec2u(bBits, 0u); + } + if (b.isZero) { + return vec2u(aBits, 0u); + } + + let exponentDifference = select( + b.baseExponent - a.baseExponent, + a.baseExponent - b.baseExponent, + a.baseExponent >= b.baseExponent + ); + + // Beyond half an ulp, rounding cannot change the larger operand. Returning + // the smaller operand intact also avoids an unbounded integer alignment. + // At a power-of-two boundary the spacing below the larger operand is half + // the spacing above it, so an opposite-sign gap-25 operand can still change + // the rounded high limb. Gap 26 is the first universally safe early-out. + if (exponentDifference > 25) { + if (fp64_f32_magnitude_compare(aBits, bBits) >= 0) { + return vec2u(aBits, bBits); + } + return vec2u(bBits, aBits); + } + + let commonBaseExponent = min(a.baseExponent, b.baseExponent); + let aMagnitude = fp64_u64_shift_left( + vec2u(0u, a.significand), + u32(a.baseExponent - commonBaseExponent) + ); + let bMagnitude = fp64_u64_shift_left( + vec2u(0u, b.significand), + u32(b.baseExponent - commonBaseExponent) + ); + + var resultSign = a.sign; + var resultMagnitude: vec2u; + if (a.sign == b.sign) { + resultMagnitude = fp64_u64_add(aMagnitude, bMagnitude); + } else { + let comparison = fp64_u64_compare(aMagnitude, bMagnitude); + if (comparison == 0) { + return vec2u(0u, 0u); + } + if (comparison > 0) { + resultMagnitude = fp64_u64_sub(aMagnitude, bMagnitude); + } else { + resultSign = b.sign; + resultMagnitude = fp64_u64_sub(bMagnitude, aMagnitude); + } + } + + return fp64_split_accumulator_bits(resultSign, resultMagnitude, commonBaseExponent); +} + +fn fp64_two_sum_integer(a: f32, b: f32) -> vec2f { + let resultBits = fp64_two_sum_integer_bits(bitcast(a), bitcast(b)); + return vec2f(bitcast(resultBits.x), bitcast(resultBits.y)); +} + +fn fp64_multiply_significands(a: u32, b: u32) -> vec2u { + let aLow = a & 0xffffu; + let aHigh = a >> 16u; + let bLow = b & 0xffffu; + let bHigh = b >> 16u; + let lowProduct = aLow * bLow; + let crossProduct = aLow * bHigh + aHigh * bLow; + let highProduct = aHigh * bHigh; + + var result = vec2u(0u, lowProduct); + result = fp64_u64_add( + result, + fp64_u64_shift_left(vec2u(0u, crossProduct), 16u) + ); + result = fp64_u64_add(result, vec2u(highProduct, 0u)); + return result; +} + +fn fp64_two_prod_integer_bits(aBits: u32, bBits: u32) -> vec2u { + let a = fp64_decode_f32_bits(aBits); + let b = fp64_decode_f32_bits(bBits); + let resultSign = a.sign ^ b.sign; + + if (a.isNan || b.isNan || ((a.isZero || b.isZero) && (a.isInf || b.isInf))) { + return vec2u(0x7fc00000u, 0u); + } + if (a.isInf || b.isInf) { + return vec2u((resultSign << 31u) | 0x7f800000u, resultSign << 31u); + } + if (a.isZero || b.isZero) { + return vec2u(resultSign << 31u, resultSign << 31u); + } + + let magnitude = fp64_multiply_significands(a.significand, b.significand); + return fp64_split_accumulator_bits( + resultSign, + magnitude, + a.baseExponent + b.baseExponent + ); +} + +fn fp64_two_prod_integer(a: f32, b: f32) -> vec2f { + let resultBits = fp64_two_prod_integer_bits(bitcast(a), bitcast(b)); + return vec2f(bitcast(resultBits.x), bitcast(resultBits.y)); +} + +fn fp64_round_add_integer(a: f32, b: f32) -> f32 { + return fp64_two_sum_integer(a, b).x; +} + +fn fp64_round_mul_integer(a: f32, b: f32) -> f32 { + return fp64_two_prod_integer(a, b).x; +} + +#ifndef LUMA_FP64_PREDICATE_ONLY +fn fp64_f32_finite_exponent(value: Fp64F32Bits) -> i32 { + let mostSignificantBit = 31u - countLeadingZeros(value.significand); + return value.baseExponent + i32(mostSignificantBit); +} + +fn fp64_scale_f32_integer(value: f32, exponent: i32) -> f32 { + let decoded = fp64_decode_f32_bits(bitcast(value)); + if (decoded.isZero || decoded.isInf || decoded.isNan) { + return value; + } + let resultBits = fp64_make_f32_bits_from_u64( + decoded.sign, + vec2u(0u, decoded.significand), + decoded.baseExponent + exponent + ); + return bitcast(resultBits); +} + +// Divide normalized significands so the hardware operation cannot overflow, +// underflow, or flush a subnormal result. Reapply the exponent with integer +// packing, which also produces subnormal correction limbs without relying on +// floating-point arithmetic to preserve them. +fn fp64_divide_f32_integer(aValue: f32, bValue: f32) -> f32 { + let a = fp64_decode_f32_bits(bitcast(aValue)); + let b = fp64_decode_f32_bits(bitcast(bValue)); + if (a.isZero || b.isZero || a.isInf || b.isInf || a.isNan || b.isNan) { + return aValue / bValue; + } + + let aMostSignificantBit = 31u - countLeadingZeros(a.significand); + let bMostSignificantBit = 31u - countLeadingZeros(b.significand); + let normalizedABits = fp64_make_f32_bits_from_u64( + a.sign, + vec2u(0u, a.significand), + -i32(aMostSignificantBit) + ); + let normalizedBBits = fp64_make_f32_bits_from_u64( + b.sign, + vec2u(0u, b.significand), + -i32(bMostSignificantBit) + ); + let normalizedQuotient = bitcast(normalizedABits) / bitcast(normalizedBBits); + let quotient = fp64_decode_f32_bits(bitcast(normalizedQuotient)); + let exponentShift = + a.baseExponent + i32(aMostSignificantBit) - + b.baseExponent - i32(bMostSignificantBit); + let quotientBits = fp64_make_f32_bits_from_u64( + quotient.sign, + vec2u(0u, quotient.significand), + quotient.baseExponent + exponentShift + ); + return bitcast(quotientBits); +} +#endif + +#ifndef LUMA_FP64_PREDICATE_ONLY +fn split(a: f32) -> vec2f { + let aBits = bitcast(a); + let decoded = fp64_decode_f32_bits(aBits); + if (decoded.isZero || decoded.isInf || decoded.isNan) { + return vec2f(a, 0.0); + } + + var roundedHigh = decoded.significand >> 12u; + let remainder = decoded.significand & 0xfffu; + if (remainder > 0x800u || (remainder == 0x800u && (roundedHigh & 1u) == 1u)) { + roundedHigh = roundedHigh + 1u; + } + var highMagnitude = vec2u(0u, roundedHigh << 12u); + var highBits = fp64_make_f32_bits_from_u64( + decoded.sign, + highMagnitude, + decoded.baseExponent + ); + // Rounding the high limb of a maximum-exponent value can overflow even + // though the original value is finite. Truncate only in that boundary case + // so split remains an exact finite decomposition. + if (fp64_decode_f32_bits(highBits).isInf) { + roundedHigh = decoded.significand >> 12u; + highMagnitude = vec2u(0u, roundedHigh << 12u); + highBits = fp64_make_f32_bits_from_u64( + decoded.sign, + highMagnitude, + decoded.baseExponent + ); + } + let lowBits = fp64_make_residual_f32_bits( + decoded.sign, + vec2u(0u, decoded.significand), + decoded.baseExponent, + highBits + ); + return vec2f(bitcast(highBits), bitcast(lowBits)); +} + +fn split2(a: vec2f) -> vec2f { + var result = split(a.x); + result.y = fp64_round_add_integer(result.y, a.y); + return result; +} +#endif + +#ifndef LUMA_FP64_PREDICATE_ONLY +fn quickTwoSum(a: f32, b: f32) -> vec2f { + return fp64_two_sum_integer(a, b); +} +#endif + +fn twoSum(a: f32, b: f32) -> vec2f { + return fp64_two_sum_integer(a, b); +} + +fn twoSub(a: f32, b: f32) -> vec2f { + let bBits = bitcast(b) ^ 0x80000000u; + let resultBits = fp64_two_sum_integer_bits(bitcast(a), bBits); + return vec2f(bitcast(resultBits.x), bitcast(resultBits.y)); +} + +#ifndef LUMA_FP64_PREDICATE_ONLY +fn twoSqr(a: f32) -> vec2f { + return fp64_two_prod_integer(a, a); +} + +fn twoProd(a: f32, b: f32) -> vec2f { + return fp64_two_prod_integer(a, b); +} +#endif + +fn sum_fp64(a: vec2f, b: vec2f) -> vec2f { + var sum = fp64_two_sum_integer(a.x, b.x); + let lowSum = fp64_two_sum_integer(a.y, b.y); + sum.y = fp64_round_add_integer(sum.y, lowSum.x); + sum = fp64_two_sum_integer(sum.x, sum.y); + sum.y = fp64_round_add_integer(sum.y, lowSum.y); + return fp64_two_sum_integer(sum.x, sum.y); +} + +fn sub_fp64(a: vec2f, b: vec2f) -> vec2f { + let negatedB = vec2f( + bitcast(bitcast(b.x) ^ 0x80000000u), + bitcast(bitcast(b.y) ^ 0x80000000u) + ); + return sum_fp64(a, negatedB); +} + +fn mul_fp64(a: vec2f, b: vec2f) -> vec2f { + var product = fp64_two_prod_integer(a.x, b.x); + let crossProduct1 = fp64_round_mul_integer(a.x, b.y); + product.y = fp64_round_add_integer(product.y, crossProduct1); + product = fp64_two_sum_integer(product.x, product.y); + let crossProduct2 = fp64_round_mul_integer(a.y, b.x); + product.y = fp64_round_add_integer(product.y, crossProduct2); + return fp64_two_sum_integer(product.x, product.y); +} + +#ifndef LUMA_FP64_PREDICATE_ONLY +fn fp64_scale_fp64_integer(value: vec2f, exponent: i32) -> vec2f { + let high = fp64_scale_f32_integer(value.x, exponent); + let low = fp64_scale_f32_integer(value.y, exponent); + return sum_fp64(vec2f(high, 0.0), vec2f(low, 0.0)); +} + +fn fp64_div_fp64_normalized(a: vec2f, b: vec2f) -> vec2f { + let quotientHigh = fp64_divide_f32_integer(a.x, b.x); + var quotient = vec2f(quotientHigh, 0.0); + + let remainder = sub_fp64(a, mul_fp64(b, quotient)); + let quotientLow = fp64_divide_f32_integer(remainder.x, b.x); + quotient = sum_fp64(quotient, vec2f(quotientLow, 0.0)); + + let secondRemainder = sub_fp64(a, mul_fp64(b, quotient)); + let correction = fp64_divide_f32_integer(secondRemainder.x, b.x); + return sum_fp64(quotient, vec2f(correction, 0.0)); +} + +fn div_fp64(a: vec2f, b: vec2f) -> vec2f { + let decodedA = fp64_decode_f32_bits(bitcast(a.x)); + let decodedB = fp64_decode_f32_bits(bitcast(b.x)); + if ( + decodedA.isZero || decodedB.isZero || + decodedA.isInf || decodedB.isInf || + decodedA.isNan || decodedB.isNan + ) { + return fp64_div_fp64_normalized(a, b); + } + + let exponentA = fp64_f32_finite_exponent(decodedA); + let exponentB = fp64_f32_finite_exponent(decodedB); + // Correct the quotient near unity so b * q and the remainder stay clear of + // both f32 underflow and overflow. The exponent difference is applied once. + let normalizedA = fp64_scale_fp64_integer(a, -exponentA); + let normalizedB = fp64_scale_fp64_integer(b, -exponentB); + let normalizedQuotient = fp64_div_fp64_normalized(normalizedA, normalizedB); + return fp64_scale_fp64_integer(normalizedQuotient, exponentA - exponentB); +} + +fn fp64_sqrt_fp64_normalized(a: vec2f) -> vec2f { + let estimate = sqrt(a.x); + let difference = sub_fp64(a, fp64_two_prod_integer(estimate, estimate)).x; + let denominator = fp64_round_add_integer(estimate, estimate); + let correction = fp64_divide_f32_integer(difference, denominator); + return sum_fp64(vec2f(estimate, 0.0), vec2f(correction, 0.0)); +} + +fn sqrt_fp64(a: vec2f) -> vec2f { + let decoded = fp64_decode_f32_bits(bitcast(a.x)); + let decodedLow = fp64_decode_f32_bits(bitcast(a.y)); + if (decoded.isZero && decodedLow.isZero) { + return vec2f(0.0, 0.0); + } + if (decoded.sign == 1u) { + let nanValue = fp64_nan(a.x); + return vec2f(nanValue, nanValue); + } + + if (decoded.isInf || decoded.isNan) { + return fp64_sqrt_fp64_normalized(a); + } + let exponent = fp64_f32_finite_exponent(decoded); + // An even scale lets the final square-root rescale use an integer exponent. + let evenExponent = exponent - (exponent & 1); + let normalizedA = fp64_scale_fp64_integer(a, -evenExponent); + let normalizedRoot = fp64_sqrt_fp64_normalized(normalizedA); + return fp64_scale_fp64_integer(normalizedRoot, evenExponent / 2); +} +#endif +`});var ygt,xgt=Ve(()=>{_gt();ygt=`struct Fp64ArithmeticUniforms { + ONE: f32, + SPLIT: f32, +}; + +@group(0) @binding(auto) var fp64arithmetic : Fp64ArithmeticUniforms; + +#ifndef LUMA_FP64_F32_INPUT_ONLY +struct Fp64Bits { + sign: u32, + exponent: i32, + significand: vec2u, + isZero: bool, + isInf: bool, + isNan: bool, +}; +#endif + +#ifndef LUMA_FP64_PREDICATE_ONLY +fn fp64_nan(seed: f32) -> f32 { + let nanBits = 0x7fc00000u | select(0u, 1u, seed < 0.0); + return bitcast(nanBits); +} +#endif + +fn fp64_u64_is_zero(value: vec2u) -> bool { + return value.x == 0u && value.y == 0u; +} + +fn fp64_u64_compare(a: vec2u, b: vec2u) -> i32 { + if (a.x != b.x) { + return select(-1, 1, a.x > b.x); + } + if (a.y != b.y) { + return select(-1, 1, a.y > b.y); + } + return 0; +} + +fn fp64_u64_add(a: vec2u, b: vec2u) -> vec2u { + let low = a.y + b.y; + let carry = select(0u, 1u, low < a.y); + return vec2u(a.x + b.x + carry, low); +} + +fn fp64_u64_sub(a: vec2u, b: vec2u) -> vec2u { + let borrow = select(0u, 1u, a.y < b.y); + return vec2u(a.x - b.x - borrow, a.y - b.y); +} + +fn fp64_u64_shift_left(value: vec2u, shift: u32) -> vec2u { + if (shift == 0u) { + return value; + } + if (shift < 32u) { + return vec2u((value.x << shift) | (value.y >> (32u - shift)), value.y << shift); + } + if (shift == 32u) { + return vec2u(value.y, 0u); + } + if (shift < 64u) { + return vec2u(value.y << (shift - 32u), 0u); + } + return vec2u(0u); +} + +fn fp64_u64_shift_right(value: vec2u, shift: u32) -> vec2u { + if (shift == 0u) { + return value; + } + if (shift < 32u) { + return vec2u(value.x >> shift, (value.y >> shift) | (value.x << (32u - shift))); + } + if (shift == 32u) { + return vec2u(0u, value.x); + } + if (shift < 64u) { + return vec2u(0u, value.x >> (shift - 32u)); + } + return vec2u(0u); +} + +fn fp64_u64_get_bit(value: vec2u, bitIndex: u32) -> bool { + if (bitIndex >= 64u) { + return false; + } + if (bitIndex >= 32u) { + return ((value.x >> (bitIndex - 32u)) & 1u) != 0u; + } + return ((value.y >> bitIndex) & 1u) != 0u; +} + +fn fp64_u64_has_bits_below(value: vec2u, bitCount: u32) -> bool { + if (bitCount == 0u) { + return false; + } + if (bitCount >= 64u) { + return !fp64_u64_is_zero(value); + } + if (bitCount > 32u) { + let highBitCount = bitCount - 32u; + let highMask = (1u << highBitCount) - 1u; + return value.y != 0u || (value.x & highMask) != 0u; + } + if (bitCount == 32u) { + return value.y != 0u; + } + let lowMask = (1u << bitCount) - 1u; + return (value.y & lowMask) != 0u; +} + +#ifndef LUMA_FP64_F32_INPUT_ONLY +fn fp64_u64_shift_right_sticky(value: vec2u, shift: u32) -> vec2u { + var shifted = fp64_u64_shift_right(value, shift); + if (fp64_u64_has_bits_below(value, shift)) { + shifted.y = shifted.y | 1u; + } + return shifted; +} +#endif + +fn fp64_u64_count_leading_zeros(value: vec2u) -> u32 { + if (value.x != 0u) { + return countLeadingZeros(value.x); + } + return 32u + countLeadingZeros(value.y); +} + +fn fp64_round_shift_right_to_u32(value: vec2u, shift: u32) -> u32 { + if (shift == 0u) { + return value.y; + } + + let truncated = fp64_u64_shift_right(value, shift); + var rounded = truncated.y; + let guard = fp64_u64_get_bit(value, shift - 1u); + let hasTrailingBits = fp64_u64_has_bits_below(value, shift - 1u); + if (guard && (hasTrailingBits || (rounded & 1u) == 1u)) { + rounded = rounded + 1u; + } + return rounded; +} + +#ifndef LUMA_FP64_F32_INPUT_ONLY +fn fp64_round_shift_right(value: vec2u, shift: u32) -> vec2u { + if (shift == 0u) { + return value; + } + + var rounded = fp64_u64_shift_right(value, shift); + let guard = fp64_u64_get_bit(value, shift - 1u); + let hasTrailingBits = fp64_u64_has_bits_below(value, shift - 1u); + if (guard && (hasTrailingBits || (rounded.y & 1u) == 1u)) { + rounded = fp64_u64_add(rounded, vec2u(0u, 1u)); + } + return rounded; +} +#endif + +fn fp64_make_f32_bits_from_u64(sign: u32, significand: vec2u, baseExponent: i32) -> u32 { + if (fp64_u64_is_zero(significand)) { + return sign << 31u; + } + + let leadingZeros = fp64_u64_count_leading_zeros(significand); + let mostSignificantBit = 63u - leadingZeros; + var exponent = baseExponent + i32(mostSignificantBit); + + if (exponent > 127) { + return (sign << 31u) | 0x7f800000u; + } + + if (exponent >= -126) { + let shift = i32(mostSignificantBit) - 23; + var significand24: u32; + if (shift > 0) { + significand24 = fp64_round_shift_right_to_u32(significand, u32(shift)); + } else { + significand24 = fp64_u64_shift_left(significand, u32(-shift)).y; + } + + if (significand24 >= 0x1000000u) { + significand24 = significand24 >> 1u; + exponent = exponent + 1; + if (exponent > 127) { + return (sign << 31u) | 0x7f800000u; + } + } + + return (sign << 31u) | (u32(exponent + 127) << 23u) | (significand24 & 0x7fffffu); + } + + let scaleExponent = baseExponent + 149; + var mantissa: u32; + if (scaleExponent >= 0) { + mantissa = fp64_u64_shift_left(significand, u32(scaleExponent)).y; + } else { + mantissa = fp64_round_shift_right_to_u32(significand, u32(-scaleExponent)); + } + + if (mantissa >= 0x800000u) { + return (sign << 31u) | 0x00800000u; + } + return (sign << 31u) | mantissa; +} + +#ifndef LUMA_FP64_F32_INPUT_ONLY +fn fp64_decode_bits(bits: vec2u) -> Fp64Bits { + let sign = bits.x >> 31u; + let exponentBits = (bits.x >> 20u) & 0x7ffu; + let fractionHigh = bits.x & 0xfffffu; + let fractionLow = bits.y; + let fraction = vec2u(fractionHigh, fractionLow); + + if (exponentBits == 0x7ffu) { + let isInf = fp64_u64_is_zero(fraction); + return Fp64Bits(sign, 0, vec2u(0u), false, isInf, !isInf); + } + + if (exponentBits == 0u) { + let isZero = fp64_u64_is_zero(fraction); + return Fp64Bits(sign, -1022, fraction, isZero, false, false); + } + + return Fp64Bits(sign, i32(exponentBits) - 1023, vec2u((1u << 20u) | fractionHigh, fractionLow), false, false, false); +} + +fn fp64_finite_magnitude_compare(a: Fp64Bits, b: Fp64Bits) -> i32 { + if (a.exponent != b.exponent) { + return select(-1, 1, a.exponent > b.exponent); + } + return fp64_u64_compare(a.significand, b.significand); +} +#endif + +#ifndef LUMA_FP64_F32_INPUT_ONLY +struct Fp64RawF32Bits { + sign: u32, + baseExponent: i32, + significand: u32, + isZero: bool, + isInf: bool, + isNan: bool, +}; + +// Decode an f32 as (-1)^sign * significand * 2^baseExponent. This shared +// integer representation lets normalization remain independent of the +// selected double-single arithmetic implementation. +fn fp64_decode_raw_f32_bits(bits: u32) -> Fp64RawF32Bits { + let sign = bits >> 31u; + let exponentBits = (bits >> 23u) & 0xffu; + let fraction = bits & 0x7fffffu; + + if (exponentBits == 0xffu) { + return Fp64RawF32Bits(sign, 0, 0u, false, fraction == 0u, fraction != 0u); + } + if (exponentBits == 0u) { + return Fp64RawF32Bits(sign, -149, fraction, fraction == 0u, false, false); + } + return Fp64RawF32Bits( + sign, + i32(exponentBits) - 150, + 0x800000u | fraction, + false, + false, + false + ); +} + +fn fp64_raw_f32_magnitude_compare(aBits: u32, bBits: u32) -> i32 { + let aMagnitude = aBits & 0x7fffffffu; + let bMagnitude = bBits & 0x7fffffffu; + if (aMagnitude == bMagnitude) { + return 0; + } + return select(-1, 1, aMagnitude > bMagnitude); +} + +fn fp64_make_raw_residual_f32_bits( + exactSign: u32, + exactMagnitude: vec2u, + exactBaseExponent: i32, + highBits: u32 +) -> u32 { + if (fp64_u64_is_zero(exactMagnitude)) { + return 0u; + } + + let high = fp64_decode_raw_f32_bits(highBits); + if (high.isInf || high.isNan) { + return 0u; + } + if (high.isZero) { + return fp64_make_f32_bits_from_u64(exactSign, exactMagnitude, exactBaseExponent); + } + + let commonBaseExponent = min(exactBaseExponent, high.baseExponent); + let exactShift = exactBaseExponent - commonBaseExponent; + let highShift = high.baseExponent - commonBaseExponent; + if (exactShift >= 64 || highShift >= 64) { + return 0u; + } + + let exactAligned = fp64_u64_shift_left(exactMagnitude, u32(exactShift)); + let highAligned = fp64_u64_shift_left(vec2u(0u, high.significand), u32(highShift)); + let comparison = fp64_u64_compare(exactAligned, highAligned); + if (comparison == 0) { + return 0u; + } + + var residualSign = exactSign; + var residualMagnitude: vec2u; + if (comparison > 0) { + residualMagnitude = fp64_u64_sub(exactAligned, highAligned); + } else { + residualSign = exactSign ^ 1u; + residualMagnitude = fp64_u64_sub(highAligned, exactAligned); + } + return fp64_make_f32_bits_from_u64( + residualSign, + residualMagnitude, + commonBaseExponent + ); +} + +fn fp64_split_raw_accumulator_bits( + sign: u32, + magnitude: vec2u, + baseExponent: i32 +) -> vec2u { + if (fp64_u64_is_zero(magnitude)) { + return vec2u(0u); + } + let highBits = fp64_make_f32_bits_from_u64(sign, magnitude, baseExponent); + let rawLowBits = fp64_make_raw_residual_f32_bits(sign, magnitude, baseExponent, highBits); + let lowBits = select(rawLowBits, 0u, (rawLowBits & 0x7fffffffu) == 0u); + if ((highBits & 0x7fffffffu) == 0u && (lowBits & 0x7fffffffu) == 0u) { + return vec2u(0u); + } + return vec2u(highBits, lowBits); +} +#endif + +#ifndef LUMA_FP64_F32_INPUT_ONLY +// Round an arithmetic accumulator to binary64 before splitting it. The +// aligned add/subtract paths retain three guard bits plus a sticky bit, which +// is sufficient for round-to-nearest-even at the binary64 boundary. +fn fp64_split_binary64_accumulator_bits( + sign: u32, + magnitude: vec2u, + baseExponent: i32 +) -> vec2u { + if (fp64_u64_is_zero(magnitude)) { + return vec2u(0u); + } + + let mostSignificantBit = 63u - fp64_u64_count_leading_zeros(magnitude); + let exponent = baseExponent + i32(mostSignificantBit); + if (exponent > 1023) { + return vec2u((sign << 31u) | 0x7f800000u, 0u); + } + + var roundedMagnitude = magnitude; + var roundedBaseExponent = baseExponent; + if (exponent >= -1022) { + if (mostSignificantBit > 52u) { + let shift = mostSignificantBit - 52u; + roundedMagnitude = fp64_round_shift_right(magnitude, shift); + roundedBaseExponent = baseExponent + i32(shift); + } + } else { + let shift = -1074 - baseExponent; + if (shift > 0) { + roundedMagnitude = fp64_round_shift_right(magnitude, u32(shift)); + roundedBaseExponent = -1074; + } + } + + if (fp64_u64_is_zero(roundedMagnitude)) { + return vec2u(0u); + } + return fp64_split_raw_accumulator_bits(sign, roundedMagnitude, roundedBaseExponent); +} +#endif + +#ifndef LUMA_FP64_PREDICATE_ONLY +fn fp64_add_raw_f32_bits(aBits: u32, bBits: u32) -> vec2u { + let a = fp64_decode_raw_f32_bits(aBits); + let b = fp64_decode_raw_f32_bits(bBits); + + if (a.isNan || b.isNan) { + return vec2u(0x7fc00000u, 0u); + } + if (a.isInf || b.isInf) { + if (a.isInf && b.isInf && a.sign != b.sign) { + return vec2u(0x7fc00000u, 0u); + } + return select(vec2u(bBits, 0u), vec2u(aBits, 0u), a.isInf); + } + if (a.isZero && b.isZero) { + return vec2u(0u); + } + if (a.isZero) { + return vec2u(bBits, 0u); + } + if (b.isZero) { + return vec2u(aBits, 0u); + } + + let exponentDifference = abs(a.baseExponent - b.baseExponent); + if (exponentDifference > 25) { + if (fp64_raw_f32_magnitude_compare(aBits, bBits) >= 0) { + return vec2u(aBits, bBits); + } + return vec2u(bBits, aBits); + } + + let commonBaseExponent = min(a.baseExponent, b.baseExponent); + let aMagnitude = fp64_u64_shift_left( + vec2u(0u, a.significand), + u32(a.baseExponent - commonBaseExponent) + ); + let bMagnitude = fp64_u64_shift_left( + vec2u(0u, b.significand), + u32(b.baseExponent - commonBaseExponent) + ); + + var resultSign = a.sign; + var resultMagnitude: vec2u; + if (a.sign == b.sign) { + resultMagnitude = fp64_u64_add(aMagnitude, bMagnitude); + } else { + let comparison = fp64_u64_compare(aMagnitude, bMagnitude); + if (comparison == 0) { + return vec2u(0u); + } + if (comparison > 0) { + resultMagnitude = fp64_u64_sub(aMagnitude, bMagnitude); + } else { + resultSign = b.sign; + resultMagnitude = fp64_u64_sub(bMagnitude, aMagnitude); + } + } + + return fp64_split_raw_accumulator_bits( + resultSign, + resultMagnitude, + commonBaseExponent + ); +} +#endif + +#ifndef LUMA_FP64_F32_INPUT_ONLY +fn fp64_add_aligned_magnitudes_to_fp64_bits( + sign: u32, + larger: Fp64Bits, + smaller: Fp64Bits +) -> vec2u { + let largeSignificand = fp64_u64_shift_left(larger.significand, 3u); + let smallSignificand = fp64_u64_shift_right_sticky( + fp64_u64_shift_left(smaller.significand, 3u), + u32(larger.exponent - smaller.exponent) + ); + let resultSignificand = fp64_u64_add(largeSignificand, smallSignificand); + return fp64_split_binary64_accumulator_bits( + sign, + resultSignificand, + larger.exponent - 55 + ); +} + +fn fp64_sub_aligned_magnitudes_to_fp64_bits( + sign: u32, + larger: Fp64Bits, + smaller: Fp64Bits +) -> vec2u { + let largeSignificand = fp64_u64_shift_left(larger.significand, 3u); + let smallSignificand = fp64_u64_shift_right_sticky( + fp64_u64_shift_left(smaller.significand, 3u), + u32(larger.exponent - smaller.exponent) + ); + let resultSignificand = fp64_u64_sub(largeSignificand, smallSignificand); + return fp64_split_binary64_accumulator_bits( + sign, + resultSignificand, + larger.exponent - 55 + ); +} + +fn fp64_add_aligned_magnitudes_to_f32_bits(sign: u32, larger: Fp64Bits, smaller: Fp64Bits) -> u32 { + let largeSignificand = fp64_u64_shift_left(larger.significand, 3u); + let smallSignificand = fp64_u64_shift_right_sticky( + fp64_u64_shift_left(smaller.significand, 3u), + u32(larger.exponent - smaller.exponent) + ); + let resultSignificand = fp64_u64_add(largeSignificand, smallSignificand); + return fp64_make_f32_bits_from_u64(sign, resultSignificand, larger.exponent - 55); +} + +fn fp64_sub_aligned_magnitudes_to_f32_bits(sign: u32, larger: Fp64Bits, smaller: Fp64Bits) -> u32 { + let largeSignificand = fp64_u64_shift_left(larger.significand, 3u); + let smallSignificand = fp64_u64_shift_right_sticky( + fp64_u64_shift_left(smaller.significand, 3u), + u32(larger.exponent - smaller.exponent) + ); + let resultSignificand = fp64_u64_sub(largeSignificand, smallSignificand); + return fp64_make_f32_bits_from_u64(sign, resultSignificand, larger.exponent - 55); +} + +// Subtract two raw binary64 values and round the exact result once to f32. +// The input words are canonical high/low words: .x contains sign/exponent/high +// fraction bits, and .y contains the low 32 fraction bits. +fn sub_fp64u32_to_f32_bits(aBits: vec2u, bBits: vec2u) -> u32 { + let a = fp64_decode_bits(aBits); + let b = fp64_decode_bits(bBits); + let bSubtractionSign = b.sign ^ 1u; + + if (a.isNan || b.isNan) { + return 0x7fc00000u; + } + if (a.isInf && b.isInf) { + if (a.sign == bSubtractionSign) { + return (a.sign << 31u) | 0x7f800000u; + } + return 0x7fc00000u; + } + if (a.isInf) { + return (a.sign << 31u) | 0x7f800000u; + } + if (b.isInf) { + return (bSubtractionSign << 31u) | 0x7f800000u; + } + if (a.isZero && b.isZero) { + return select(0u, 0x80000000u, a.sign == 1u && b.sign == 0u); + } + + let magnitudeComparison = fp64_finite_magnitude_compare(a, b); + if (a.sign == bSubtractionSign) { + if (magnitudeComparison >= 0) { + return fp64_add_aligned_magnitudes_to_f32_bits(a.sign, a, b); + } + return fp64_add_aligned_magnitudes_to_f32_bits(a.sign, b, a); + } + + if (magnitudeComparison == 0) { + return 0u; + } + if (magnitudeComparison > 0) { + return fp64_sub_aligned_magnitudes_to_f32_bits(a.sign, a, b); + } + return fp64_sub_aligned_magnitudes_to_f32_bits(bSubtractionSign, b, a); +} + +fn sub_fp64u32_to_f32(aBits: vec2u, bBits: vec2u) -> f32 { + return bitcast(sub_fp64u32_to_f32_bits(aBits, bBits)); +} + +// Subtract two raw binary64 values, round once to binary64, then split the +// result into normalized f32 limbs. Finite results must fit within the f32 +// exponent range; larger magnitudes map to infinity and smaller magnitudes +// map to zero. The input words use canonical high/low word order. +fn sub_fp64u32_to_fp64_bits(aBits: vec2u, bBits: vec2u) -> vec2u { + let a = fp64_decode_bits(aBits); + let b = fp64_decode_bits(bBits); + let bSubtractionSign = b.sign ^ 1u; + + if (a.isNan || b.isNan) { + return vec2u(0x7fc00000u, 0u); + } + if (a.isInf && b.isInf) { + if (a.sign == bSubtractionSign) { + return vec2u((a.sign << 31u) | 0x7f800000u, 0u); + } + return vec2u(0x7fc00000u, 0u); + } + if (a.isInf) { + return vec2u((a.sign << 31u) | 0x7f800000u, 0u); + } + if (b.isInf) { + return vec2u((bSubtractionSign << 31u) | 0x7f800000u, 0u); + } + if (a.isZero && b.isZero) { + return vec2u(0u); + } + + let magnitudeComparison = fp64_finite_magnitude_compare(a, b); + if (a.sign == bSubtractionSign) { + if (magnitudeComparison >= 0) { + return fp64_add_aligned_magnitudes_to_fp64_bits(a.sign, a, b); + } + return fp64_add_aligned_magnitudes_to_fp64_bits(a.sign, b, a); + } + + if (magnitudeComparison == 0) { + return vec2u(0u); + } + if (magnitudeComparison > 0) { + return fp64_sub_aligned_magnitudes_to_fp64_bits(a.sign, a, b); + } + return fp64_sub_aligned_magnitudes_to_fp64_bits(bSubtractionSign, b, a); +} + +fn sub_fp64u32_to_fp64(aBits: vec2u, bBits: vec2u) -> vec2f { + let resultBits = sub_fp64u32_to_fp64_bits(aBits, bBits); + return vec2f(bitcast(resultBits.x), bitcast(resultBits.y)); +} +#endif + +#ifndef LUMA_FP64_PREDICATE_ONLY +fn fp64_runtime_zero() -> f32 { + return fp64arithmetic.ONE * 0.0; +} + +fn prevent_fp64_optimization(value: f32) -> f32 { +#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND + return value + fp64_runtime_zero(); +#else + return value; +#endif +} +#endif + +#ifdef LUMA_FP64_INTEGER_ARITHMETIC +${vgt} +#else +fn split(a: f32) -> vec2f { + let splitValue = prevent_fp64_optimization(fp64arithmetic.SPLIT + fp64_runtime_zero()); + let t = prevent_fp64_optimization(a * splitValue); + let temp = prevent_fp64_optimization(t - a); + let aHi = prevent_fp64_optimization(t - temp); + let aLo = prevent_fp64_optimization(a - aHi); + return vec2f(aHi, aLo); +} + +fn split2(a: vec2f) -> vec2f { + var b = split(a.x); + b.y = b.y + a.y; + return b; +} + +fn quickTwoSum(a: f32, b: f32) -> vec2f { +#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND + let sum = prevent_fp64_optimization((a + b) * fp64arithmetic.ONE); + let err = prevent_fp64_optimization(b - (sum - a) * fp64arithmetic.ONE); +#else + let sum = prevent_fp64_optimization(a + b); + let err = prevent_fp64_optimization(b - (sum - a)); +#endif + return vec2f(sum, err); +} + +fn twoSum(a: f32, b: f32) -> vec2f { + let s = prevent_fp64_optimization(a + b); +#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND + let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE); + let err = + prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) * + fp64arithmetic.ONE * + fp64arithmetic.ONE * + fp64arithmetic.ONE) + + prevent_fp64_optimization(b - v); +#else + let v = prevent_fp64_optimization(s - a); + let err = prevent_fp64_optimization(a - (s - v)) + prevent_fp64_optimization(b - v); +#endif + return vec2f(s, err); +} + +fn twoSub(a: f32, b: f32) -> vec2f { + let s = prevent_fp64_optimization(a - b); +#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND + let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE); + let err = + prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) * + fp64arithmetic.ONE * + fp64arithmetic.ONE * + fp64arithmetic.ONE) - + prevent_fp64_optimization(b + v); +#else + let v = prevent_fp64_optimization(s - a); + let err = prevent_fp64_optimization(a - (s - v)) - prevent_fp64_optimization(b + v); +#endif + return vec2f(s, err); +} + +fn twoSqr(a: f32) -> vec2f { + let prod = prevent_fp64_optimization(a * a); + let aFp64 = split(a); + let highProduct = prevent_fp64_optimization(aFp64.x * aFp64.x); + let crossProduct = prevent_fp64_optimization(2.0 * aFp64.x * aFp64.y); + let lowProduct = prevent_fp64_optimization(aFp64.y * aFp64.y); +#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND + let err = + (prevent_fp64_optimization(highProduct - prod) * fp64arithmetic.ONE + + crossProduct * fp64arithmetic.ONE * fp64arithmetic.ONE) + + lowProduct * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE; +#else + let err = ((prevent_fp64_optimization(highProduct - prod) + crossProduct) + lowProduct); +#endif + return vec2f(prod, err); +} + +fn twoProd(a: f32, b: f32) -> vec2f { + let prod = prevent_fp64_optimization(a * b); + let aFp64 = split(a); + let bFp64 = split(b); + let highProduct = prevent_fp64_optimization(aFp64.x * bFp64.x); + let crossProduct1 = prevent_fp64_optimization(aFp64.x * bFp64.y); + let crossProduct2 = prevent_fp64_optimization(aFp64.y * bFp64.x); + let lowProduct = prevent_fp64_optimization(aFp64.y * bFp64.y); +#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND + let err1 = (highProduct - prod) * fp64arithmetic.ONE; + let err2 = crossProduct1 * fp64arithmetic.ONE * fp64arithmetic.ONE; + let err3 = crossProduct2 * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE; + let err4 = + lowProduct * + fp64arithmetic.ONE * + fp64arithmetic.ONE * + fp64arithmetic.ONE * + fp64arithmetic.ONE; +#else + let err1 = highProduct - prod; + let err2 = crossProduct1; + let err3 = crossProduct2; + let err4 = lowProduct; +#endif + let err12InputA = prevent_fp64_optimization(err1); + let err12InputB = prevent_fp64_optimization(err2); + let err12 = prevent_fp64_optimization(err12InputA + err12InputB); + let err123InputA = prevent_fp64_optimization(err12); + let err123InputB = prevent_fp64_optimization(err3); + let err123 = prevent_fp64_optimization(err123InputA + err123InputB); + let err1234InputA = prevent_fp64_optimization(err123); + let err1234InputB = prevent_fp64_optimization(err4); + let err = prevent_fp64_optimization(err1234InputA + err1234InputB); + return vec2f(prod, err); +} + +fn sum_fp64(a: vec2f, b: vec2f) -> vec2f { + var s = twoSum(a.x, b.x); + let t = twoSum(a.y, b.y); + s.y = prevent_fp64_optimization(s.y + t.x); + s = quickTwoSum(s.x, s.y); + s.y = prevent_fp64_optimization(s.y + t.y); + s = quickTwoSum(s.x, s.y); + return s; +} + +fn sub_fp64(a: vec2f, b: vec2f) -> vec2f { + var s = twoSub(a.x, b.x); + let t = twoSub(a.y, b.y); + s.y = prevent_fp64_optimization(s.y + t.x); + s = quickTwoSum(s.x, s.y); + s.y = prevent_fp64_optimization(s.y + t.y); + s = quickTwoSum(s.x, s.y); + return s; +} + +fn mul_fp64(a: vec2f, b: vec2f) -> vec2f { + var prod = twoProd(a.x, b.x); + let crossProduct1 = prevent_fp64_optimization(a.x * b.y); + prod.y = prevent_fp64_optimization(prod.y + crossProduct1); +#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND + prod = split2(prod); +#endif + prod = quickTwoSum(prod.x, prod.y); + let crossProduct2 = prevent_fp64_optimization(a.y * b.x); + prod.y = prevent_fp64_optimization(prod.y + crossProduct2); +#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND + prod = split2(prod); +#endif + prod = quickTwoSum(prod.x, prod.y); + return prod; +} + +#ifndef LUMA_FP64_PREDICATE_ONLY +fn div_fp64(a: vec2f, b: vec2f) -> vec2f { + let xn = prevent_fp64_optimization(1.0 / b.x); + let yn = mul_fp64(a, vec2f(xn, fp64_runtime_zero())); + let diff = prevent_fp64_optimization(sub_fp64(a, mul_fp64(b, yn)).x); + let prod = twoProd(xn, diff); + return sum_fp64(yn, prod); +} + +fn sqrt_fp64(a: vec2f) -> vec2f { + if (a.x == 0.0 && a.y == 0.0) { + return vec2f(0.0, 0.0); + } + if (a.x < 0.0) { + let nanValue = fp64_nan(a.x); + return vec2f(nanValue, nanValue); + } + + let x = prevent_fp64_optimization(1.0 / sqrt(a.x)); + let yn = prevent_fp64_optimization(a.x * x); +#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND + let ynSqr = twoSqr(yn) * fp64arithmetic.ONE; +#else + let ynSqr = twoSqr(yn); +#endif + let diff = prevent_fp64_optimization(sub_fp64(a, ynSqr).x); + let prod = twoProd(prevent_fp64_optimization(x * 0.5), diff); +#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND + return sum_fp64(split(yn), prod); +#else + return sum_fp64(vec2f(yn, 0.0), prod); +#endif +} +#endif +#endif + +#ifndef LUMA_FP64_PREDICATE_ONLY +fn fp64_f32_bits_is_nan(bits: u32) -> bool { + return (bits & 0x7fffffffu) > 0x7f800000u; +} + +fn fp64_f32_bits_is_inf(bits: u32) -> bool { + return (bits & 0x7fffffffu) == 0x7f800000u; +} + +fn fp64_compare_f32_bits(aBits: u32, bBits: u32) -> i32 { + let aMagnitude = aBits & 0x7fffffffu; + let bMagnitude = bBits & 0x7fffffffu; + if (aMagnitude == 0u && bMagnitude == 0u) { + return 0; + } + let aSign = aBits >> 31u; + let bSign = bBits >> 31u; + if (aSign != bSign) { + return select(1, -1, aSign == 1u); + } + if (aMagnitude == bMagnitude) { + return 0; + } + let magnitudeComparison = select(-1, 1, aMagnitude > bMagnitude); + return select(magnitudeComparison, -magnitudeComparison, aSign == 1u); +} + +// Normalize an arbitrary pair of finite f32 limbs with integer accumulation. +// This is independent of LUMA_FP64_INTEGER_ARITHMETIC and canonicalizes every +// representation of zero to vec2f(+0.0, +0.0). +fn normalize_fp64(value: vec2f) -> vec2f { + let resultBits = fp64_add_raw_f32_bits(bitcast(value.x), bitcast(value.y)); + return vec2f(bitcast(resultBits.x), bitcast(resultBits.y)); +} + +fn is_nan_fp64(value: vec2f) -> bool { + let normalized = normalize_fp64(value); + return fp64_f32_bits_is_nan(bitcast(normalized.x)) || + fp64_f32_bits_is_nan(bitcast(normalized.y)); +} + +fn is_finite_fp64(value: vec2f) -> bool { + let normalized = normalize_fp64(value); + let highBits = bitcast(normalized.x); + let lowBits = bitcast(normalized.y); + return !fp64_f32_bits_is_nan(highBits) && !fp64_f32_bits_is_nan(lowBits) && + !fp64_f32_bits_is_inf(highBits) && !fp64_f32_bits_is_inf(lowBits); +} + +// Returns -1, 0, or 1. NaN is unordered and returns 0; call is_nan_fp64 or +// is_finite_fp64 first when 0 must mean a finite zero. +fn sign_fp64(value: vec2f) -> i32 { + let normalized = normalize_fp64(value); + let highBits = bitcast(normalized.x); + let lowBits = bitcast(normalized.y); + if (fp64_f32_bits_is_nan(highBits) || fp64_f32_bits_is_nan(lowBits)) { + return 0; + } + if ((highBits & 0x7fffffffu) != 0u) { + return select(1, -1, (highBits >> 31u) == 1u); + } + if ((lowBits & 0x7fffffffu) != 0u) { + return select(1, -1, (lowBits >> 31u) == 1u); + } + return 0; +} + +// Compares double-single values and returns -1, 0, or 1. NaN is unordered +// and returns 0; callers that require equality semantics must first check +// is_nan_fp64 or is_finite_fp64. +fn compare_fp64(a: vec2f, b: vec2f) -> i32 { + let normalizedA = normalize_fp64(a); + let normalizedB = normalize_fp64(b); + let aHighBits = bitcast(normalizedA.x); + let aLowBits = bitcast(normalizedA.y); + let bHighBits = bitcast(normalizedB.x); + let bLowBits = bitcast(normalizedB.y); + if (fp64_f32_bits_is_nan(aHighBits) || fp64_f32_bits_is_nan(aLowBits) || + fp64_f32_bits_is_nan(bHighBits) || fp64_f32_bits_is_nan(bLowBits)) { + return 0; + } + let highComparison = fp64_compare_f32_bits(aHighBits, bHighBits); + if (highComparison != 0) { + return highComparison; + } + return fp64_compare_f32_bits(aLowBits, bLowBits); +} +#endif +`});var zKt,lke,Egt=Ve(()=>{ggt();wgt();xgt();zKt={ONE:1,SPLIT:4097},lke={name:"fp64arithmetic",source:ygt,fs:cke,vs:cke,defaultUniforms:zKt,uniformTypes:{ONE:"f32",SPLIT:"f32"},fp64ify:ske,fp64LowPart:dgt,fp64ifyMatrix4:pgt}});function Mgt(s){return`layout(std140) uniform ${s}Uniforms { + float useByteColors; +} ${s}; + +vec3 ${s}_normalize(vec3 inputColor) { + return ${s}.useByteColors > 0.5 ? inputColor / 255.0 : inputColor; +} + +vec4 ${s}_normalize(vec4 inputColor) { + return ${s}.useByteColors > 0.5 ? inputColor / 255.0 : inputColor; +} + +vec4 ${s}_premultiplyAlpha(vec4 inputColor) { + return vec4(inputColor.rgb * inputColor.a, inputColor.a); +} + +vec4 ${s}_unpremultiplyAlpha(vec4 inputColor) { + return inputColor.a > 0.0 ? vec4(inputColor.rgb / inputColor.a, inputColor.a) : vec4(0.0); +} + +vec4 ${s}_premultiply_alpha(vec4 inputColor) { + return ${s}_premultiplyAlpha(inputColor); +} + +vec4 ${s}_unpremultiply_alpha(vec4 inputColor) { + return ${s}_unpremultiplyAlpha(inputColor); +} +`}function Tgt(s){return`struct ${s}Uniforms { + useByteColors: f32 +}; + +@group(0) @binding(auto) var ${s} : ${s}Uniforms; + +fn ${s}_normalize(inputColor: vec3) -> vec3 { + return select(inputColor, inputColor / 255.0, ${s}.useByteColors > 0.5); +} + +fn ${s}_normalize4(inputColor: vec4) -> vec4 { + return select(inputColor, inputColor / 255.0, ${s}.useByteColors > 0.5); +} + +fn ${s}_premultiplyAlpha(inputColor: vec4) -> vec4 { + return vec4(inputColor.rgb * inputColor.a, inputColor.a); +} + +fn ${s}_unpremultiplyAlpha(inputColor: vec4) -> vec4 { + return select( + vec4(0.0), + vec4(inputColor.rgb / inputColor.a, inputColor.a), + inputColor.a > 0.0 + ); +} + +fn ${s}_premultiply_alpha(inputColor: vec4) -> vec4 { + return ${s}_premultiplyAlpha(inputColor); +} + +fn ${s}_unpremultiply_alpha(inputColor: vec4) -> vec4 { + return ${s}_unpremultiplyAlpha(inputColor); +} +`}var P3,GKt,jKt,cGn,lGn,$Kt,VKt,uGn,fGn,Sgt,hGn,WKt,dGn,Cgt,Agt=Ve(()=>{P3={RGBA8UNORM:0,RGBA16FLOAT:1,RGBA32FLOAT:2},GKt={rgba8unorm:4,rgba16float:8,rgba32float:16},jKt={...GKt},cGn={rgba8unorm:P3.RGBA8UNORM,rgba16float:P3.RGBA16FLOAT,rgba32float:P3.RGBA32FLOAT},lGn={[P3.RGBA8UNORM]:"rgba8unorm",[P3.RGBA16FLOAT]:"rgba16float",[P3.RGBA32FLOAT]:"rgba32float"},$Kt={useByteColors:"f32"},VKt={useByteColors:!0},uGn={format:P3.RGBA8UNORM,wordStride:jKt.rgba8unorm/Uint32Array.BYTES_PER_ELEMENT,wordOffset:0,_padding:0},fGn=Mgt("colors"),Sgt=Mgt("floatColors"),hGn=Tgt("colors"),WKt=Tgt("floatColors"),dGn=`struct storageColorsUniforms { + format: u32, + wordStride: u32, + wordOffset: u32, + _padding: u32 +}; + +@group(0) @binding(auto) var storageColors : storageColorsUniforms; +@group(0) @binding(auto) var storageColorsBuffer : array; + +const STORAGE_COLOR_FORMAT_RGBA8UNORM : u32 = ${P3.RGBA8UNORM}u; +const STORAGE_COLOR_FORMAT_RGBA16FLOAT : u32 = ${P3.RGBA16FLOAT}u; + +fn storageColors_getWordIndex(rowIndex: u32) -> u32 { + return storageColors.wordOffset + rowIndex * storageColors.wordStride; +} + +fn storageColors_readRgba8UnormColor(wordIndex: u32) -> vec4 { + return unpack4x8unorm(storageColorsBuffer[wordIndex]); +} + +fn storageColors_readRgba16FloatColor(wordIndex: u32) -> vec4 { + let redGreen = unpack2x16float(storageColorsBuffer[wordIndex]); + let blueAlpha = unpack2x16float(storageColorsBuffer[wordIndex + 1u]); + return vec4(redGreen.x, redGreen.y, blueAlpha.x, blueAlpha.y); +} + +fn storageColors_readRgba32FloatColor(wordIndex: u32) -> vec4 { + return vec4( + bitcast(storageColorsBuffer[wordIndex]), + bitcast(storageColorsBuffer[wordIndex + 1u]), + bitcast(storageColorsBuffer[wordIndex + 2u]), + bitcast(storageColorsBuffer[wordIndex + 3u]) + ); +} + +fn storageColors_readColor(rowIndex: u32) -> vec4 { + let wordIndex = storageColors_getWordIndex(rowIndex); + if (storageColors.format == STORAGE_COLOR_FORMAT_RGBA8UNORM) { + return storageColors_readRgba8UnormColor(wordIndex); + } + if (storageColors.format == STORAGE_COLOR_FORMAT_RGBA16FLOAT) { + return storageColors_readRgba16FloatColor(wordIndex); + } + return storageColors_readRgba32FloatColor(wordIndex); +} +`;Cgt={name:"floatColors",props:{},uniforms:{},vs:Sgt,fs:Sgt,source:WKt,uniformTypes:$Kt,defaultUniforms:VKt}});function YKt(s={},n){let r={},c=ele(s.useByteColors,!0);if(s.highlightedObjectColor!==void 0)if(s.highlightedObjectColor===null)r.isHighlightActive=!1;else{r.isHighlightActive=!0;let u=s.highlightedObjectColor.slice(0,3);r.highlightedObjectColor=u}return s.highlightColor&&(r.highlightColor=mgt(s.highlightColor,c)),s.isActive!==void 0&&(r.isActive=!!s.isActive,r.isAttribute=!!s.isAttribute),s.useByteColors!==void 0&&(r.useByteColors=!!s.useByteColors),r}var HKt,qKt,XKt,$M,Pgt=Ve(()=>{ake();HKt=[0,1,1,1],qKt=`layout(std140) uniform pickingUniforms { + float isActive; + float isAttribute; + float isHighlightActive; + float useByteColors; + vec3 highlightedObjectColor; + vec4 highlightColor; +} picking; + +out vec4 picking_vRGBcolor_Avalid; + +// Normalize unsigned byte color to 0-1 range +vec3 picking_normalizeColor(vec3 color) { + return picking.useByteColors > 0.5 ? color / 255.0 : color; +} + +// Normalize unsigned byte color to 0-1 range +vec4 picking_normalizeColor(vec4 color) { + return picking.useByteColors > 0.5 ? color / 255.0 : color; +} + +bool picking_isColorZero(vec3 color) { + return dot(color, vec3(1.0)) < 0.00001; +} + +bool picking_isColorValid(vec3 color) { + return dot(color, vec3(1.0)) > 0.00001; +} + +// Check if this vertex is highlighted +bool isVertexHighlighted(vec3 vertexColor) { + vec3 highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor); + return + bool(picking.isHighlightActive) && picking_isColorZero(abs(vertexColor - highlightedObjectColor)); +} + +// Set the current picking color +void picking_setPickingColor(vec3 pickingColor) { + pickingColor = picking_normalizeColor(pickingColor); + + if (bool(picking.isActive)) { + // Use alpha as the validity flag. If pickingColor is [0, 0, 0] fragment is non-pickable + picking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor)); + + if (!bool(picking.isAttribute)) { + // Stores the picking color so that the fragment shader can render it during picking + picking_vRGBcolor_Avalid.rgb = pickingColor; + } + } else { + // Do the comparison with selected item color in vertex shader as it should mean fewer compares + picking_vRGBcolor_Avalid.a = float(isVertexHighlighted(pickingColor)); + } +} + +void picking_setPickingAttribute(float value) { + if (bool(picking.isAttribute)) { + picking_vRGBcolor_Avalid.r = value; + } +} + +void picking_setPickingAttribute(vec2 value) { + if (bool(picking.isAttribute)) { + picking_vRGBcolor_Avalid.rg = value; + } +} + +void picking_setPickingAttribute(vec3 value) { + if (bool(picking.isAttribute)) { + picking_vRGBcolor_Avalid.rgb = value; + } +} +`,XKt=`layout(std140) uniform pickingUniforms { + float isActive; + float isAttribute; + float isHighlightActive; + float useByteColors; + vec3 highlightedObjectColor; + vec4 highlightColor; +} picking; + +in vec4 picking_vRGBcolor_Avalid; + +/* + * Returns highlight color if this item is selected. + */ +vec4 picking_filterHighlightColor(vec4 color) { + // If we are still picking, we don't highlight + if (picking.isActive > 0.5) { + return color; + } + + bool selected = bool(picking_vRGBcolor_Avalid.a); + + if (selected) { + // Blend in highlight color based on its alpha value + float highLightAlpha = picking.highlightColor.a; + float blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha); + float highLightRatio = highLightAlpha / blendedAlpha; + + vec3 blendedRGB = mix(color.rgb, picking.highlightColor.rgb, highLightRatio); + return vec4(blendedRGB, blendedAlpha); + } else { + return color; + } +} + +/* + * Returns picking color if picking enabled else unmodified argument. + */ +vec4 picking_filterPickingColor(vec4 color) { + if (bool(picking.isActive)) { + if (picking_vRGBcolor_Avalid.a == 0.0) { + discard; + } + return picking_vRGBcolor_Avalid; + } + return color; +} + +/* + * Returns picking color if picking is enabled if not + * highlight color if this item is selected, otherwise unmodified argument. + */ +vec4 picking_filterColor(vec4 color) { + vec4 highlightColor = picking_filterHighlightColor(color); + return picking_filterPickingColor(highlightColor); +} +`,$M={props:{},uniforms:{},name:"picking",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useByteColors:"f32",highlightedObjectColor:"vec3",highlightColor:"vec4"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useByteColors:!0,highlightedObjectColor:[0,0,0],highlightColor:HKt},vs:qKt,fs:XKt,getUniforms:YKt}});var uke,Lgt=Ve(()=>{uke=`precision highp int; + +// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) +struct AmbientLight { + vec3 color; +}; + +struct PointLight { + vec3 color; + vec3 position; + vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential +}; + +struct SpotLight { + vec3 color; + vec3 position; + vec3 direction; + vec3 attenuation; + vec2 coneCos; +}; + +struct DirectionalLight { + vec3 color; + vec3 direction; +}; + +struct UniformLight { + vec3 color; + vec3 position; + vec3 direction; + vec3 attenuation; + vec2 coneCos; +}; + +layout(std140) uniform lightingUniforms { + int enabled; + int directionalLightCount; + int pointLightCount; + int spotLightCount; + vec3 ambientColor; + UniformLight lights[5]; +} lighting; + +PointLight lighting_getPointLight(int index) { + UniformLight light = lighting.lights[index]; + return PointLight(light.color, light.position, light.attenuation); +} + +SpotLight lighting_getSpotLight(int index) { + UniformLight light = lighting.lights[lighting.pointLightCount + index]; + return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos); +} + +DirectionalLight lighting_getDirectionalLight(int index) { + UniformLight light = + lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index]; + return DirectionalLight(light.color, light.direction); +} + +float getPointLightAttenuation(PointLight pointLight, float distance) { + return pointLight.attenuation.x + + pointLight.attenuation.y * distance + + pointLight.attenuation.z * distance * distance; +} + +float getSpotLightAttenuation(SpotLight spotLight, vec3 positionWorldspace) { + vec3 light_direction = normalize(positionWorldspace - spotLight.position); + float coneFactor = smoothstep( + spotLight.coneCos.y, + spotLight.coneCos.x, + dot(normalize(spotLight.direction), light_direction) + ); + float distanceAttenuation = getPointLightAttenuation( + PointLight(spotLight.color, spotLight.position, spotLight.attenuation), + distance(spotLight.position, positionWorldspace) + ); + return distanceAttenuation / max(coneFactor, 0.0001); +} + +// #endif +`});var kgt,Rgt=Ve(()=>{kgt=`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) +const MAX_LIGHTS: i32 = 5; + +struct AmbientLight { + color: vec3, +}; + +struct PointLight { + color: vec3, + position: vec3, + attenuation: vec3, // 2nd order x:Constant-y:Linear-z:Exponential +}; + +struct SpotLight { + color: vec3, + position: vec3, + direction: vec3, + attenuation: vec3, + coneCos: vec2, +}; + +struct DirectionalLight { + color: vec3, + direction: vec3, +}; + +struct UniformLight { + color: vec3, + position: vec3, + direction: vec3, + attenuation: vec3, + coneCos: vec2, +}; + +struct lightingUniforms { + enabled: i32, + directionalLightCount: i32, + pointLightCount: i32, + spotLightCount: i32, + ambientColor: vec3, + lights: array, +}; + +@group(2) @binding(auto) var lighting : lightingUniforms; + +fn lighting_getPointLight(index: i32) -> PointLight { + let light = lighting.lights[index]; + return PointLight(light.color, light.position, light.attenuation); +} + +fn lighting_getSpotLight(index: i32) -> SpotLight { + let light = lighting.lights[lighting.pointLightCount + index]; + return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos); +} + +fn lighting_getDirectionalLight(index: i32) -> DirectionalLight { + let light = lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index]; + return DirectionalLight(light.color, light.direction); +} + +fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 { + return pointLight.attenuation.x + + pointLight.attenuation.y * distance + + pointLight.attenuation.z * distance * distance; +} + +fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3) -> f32 { + let lightDirection = normalize(positionWorldspace - spotLight.position); + let coneFactor = smoothstep( + spotLight.coneCos.y, + spotLight.coneCos.x, + dot(normalize(spotLight.direction), lightDirection) + ); + let distanceAttenuation = getPointLightAttenuation( + PointLight(spotLight.color, spotLight.position, spotLight.attenuation), + distance(spotLight.position, positionWorldspace) + ); + return distanceAttenuation / max(coneFactor, 0.0001); +} +`});function KKt(s,n={}){if(s=s&&{...s},!s)return nle();s.lights&&(s={...s,...QKt(s.lights),lights:void 0});let{useByteColors:r,ambientLight:c,pointLights:u,spotLights:d,directionalLights:b}=s||{};if(!(c||u&&u.length>0||d&&d.length>0||b&&b.length>0))return{...nle(),enabled:0};let _={...nle(),...JKt({useByteColors:r,ambientLight:c,pointLights:u,spotLights:d,directionalLights:b})};return s.enabled!==void 0&&(_.enabled=s.enabled?1:0),_}function JKt({useByteColors:s,ambientLight:n,pointLights:r=[],spotLights:c=[],directionalLights:u=[]}){let d=Dgt(),b=0,w=0,_=0,x=0;for(let T of r){if(b>=p4)break;d[b]={...d[b],color:tle(T,s),position:T.position,attenuation:T.attenuation||[1,0,0]},b++,w++}for(let T of c){if(b>=p4)break;d[b]={...d[b],color:tle(T,s),position:T.position,direction:T.direction,attenuation:T.attenuation||[1,0,0],coneCos:tJt(T)},b++,_++}for(let T of u){if(b>=p4)break;d[b]={...d[b],color:tle(T,s),direction:T.direction},b++,x++}return r.length+c.length+u.length>p4&&Qt.warn(`MAX_LIGHTS exceeded, truncating to ${p4}`)(),{ambientColor:tle(n,s),directionalLightCount:x,pointLightCount:w,spotLightCount:_,lights:d}}function QKt(s){let n={pointLights:[],spotLights:[],directionalLights:[]};for(let r of s||[])switch(r.type){case"ambient":n.ambientLight=r;break;case"directional":n.directionalLights?.push(r);break;case"point":n.pointLights?.push(r);break;case"spot":n.spotLights?.push(r);break;default:}return n}function tle(s={},n){let{color:r=[0,0,0],intensity:c=1}=s;return oke(r,ele(n,!0)).map(d=>d*c)}function nle(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:Dgt()}}function Dgt(){return Array.from({length:p4},()=>eJt())}function eJt(){return{color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}}function tJt(s){let n=s.innerConeAngle??0,r=s.outerConeAngle??Math.PI/4;return[Math.cos(n),Math.cos(r)]}var p4,ZKt,Igt,Bgt=Ve(()=>{$r();Lgt();Rgt();ake();p4=5,ZKt={color:"vec3",position:"vec3",direction:"vec3",attenuation:"vec3",coneCos:"vec2"},Igt={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",directionalLightCount:"i32",pointLightCount:"i32",spotLightCount:"i32",ambientColor:"vec3",lights:[ZKt,p4]},defaultUniforms:nle(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:kgt,vs:uke,fs:uke,getUniforms:KKt}});var Ogt,Ngt,Fgt=Ve(()=>{Ogt=`layout(std140) uniform phongMaterialUniforms { + uniform bool unlit; + uniform float ambient; + uniform float diffuse; + uniform float shininess; + uniform vec3 specularColor; +} material; +`,Ngt=`layout(std140) uniform phongMaterialUniforms { + uniform bool unlit; + uniform float ambient; + uniform float diffuse; + uniform float shininess; + uniform vec3 specularColor; +} material; + +vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) { + vec3 halfway_direction = normalize(light_direction + view_direction); + float lambertian = dot(light_direction, normal_worldspace); + float specular = 0.0; + if (lambertian > 0.0) { + float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0); + specular = pow(specular_angle, material.shininess); + } + lambertian = max(lambertian, 0.0); + return (lambertian * material.diffuse * surfaceColor + specular * floatColors_normalize(material.specularColor)) * color; +} + +vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) { + vec3 lightColor = surfaceColor; + + if (material.unlit) { + return surfaceColor; + } + + if (lighting.enabled == 0) { + return lightColor; + } + + vec3 view_direction = normalize(cameraPosition - position_worldspace); + lightColor = material.ambient * surfaceColor * lighting.ambientColor; + + for (int i = 0; i < lighting.pointLightCount; i++) { + PointLight pointLight = lighting_getPointLight(i); + vec3 light_position_worldspace = pointLight.position; + vec3 light_direction = normalize(light_position_worldspace - position_worldspace); + float light_attenuation = getPointLightAttenuation(pointLight, distance(light_position_worldspace, position_worldspace)); + lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation); + } + + for (int i = 0; i < lighting.spotLightCount; i++) { + SpotLight spotLight = lighting_getSpotLight(i); + vec3 light_position_worldspace = spotLight.position; + vec3 light_direction = normalize(light_position_worldspace - position_worldspace); + float light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace); + lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, spotLight.color / light_attenuation); + } + + for (int i = 0; i < lighting.directionalLightCount; i++) { + DirectionalLight directionalLight = lighting_getDirectionalLight(i); + lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); + } + + return lightColor; +} +`});var Ugt,zgt=Ve(()=>{Ugt=`struct phongMaterialUniforms { + unlit: u32, + ambient: f32, + diffuse: f32, + shininess: f32, + specularColor: vec3, +}; + +@group(3) @binding(auto) var phongMaterial : phongMaterialUniforms; + +fn lighting_getLightColor(surfaceColor: vec3, light_direction: vec3, view_direction: vec3, normal_worldspace: vec3, color: vec3) -> vec3 { + let halfway_direction: vec3 = normalize(light_direction + view_direction); + var lambertian: f32 = dot(light_direction, normal_worldspace); + var specular: f32 = 0.0; + if (lambertian > 0.0) { + let specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0); + specular = pow(specular_angle, phongMaterial.shininess); + } + lambertian = max(lambertian, 0.0); + return ( + lambertian * phongMaterial.diffuse * surfaceColor + + specular * floatColors_normalize(phongMaterial.specularColor) + ) * color; +} + +fn lighting_getLightColor2(surfaceColor: vec3, cameraPosition: vec3, position_worldspace: vec3, normal_worldspace: vec3) -> vec3 { + var lightColor: vec3 = surfaceColor; + + if (phongMaterial.unlit != 0u) { + return surfaceColor; + } + + if (lighting.enabled == 0) { + return lightColor; + } + + let view_direction: vec3 = normalize(cameraPosition - position_worldspace); + lightColor = phongMaterial.ambient * surfaceColor * lighting.ambientColor; + + for (var i: i32 = 0; i < lighting.pointLightCount; i++) { + let pointLight: PointLight = lighting_getPointLight(i); + let light_position_worldspace: vec3 = pointLight.position; + let light_direction: vec3 = normalize(light_position_worldspace - position_worldspace); + let light_attenuation = getPointLightAttenuation( + pointLight, + distance(light_position_worldspace, position_worldspace) + ); + lightColor += lighting_getLightColor( + surfaceColor, + light_direction, + view_direction, + normal_worldspace, + pointLight.color / light_attenuation + ); + } + + for (var i: i32 = 0; i < lighting.spotLightCount; i++) { + let spotLight: SpotLight = lighting_getSpotLight(i); + let light_position_worldspace: vec3 = spotLight.position; + let light_direction: vec3 = normalize(light_position_worldspace - position_worldspace); + let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace); + lightColor += lighting_getLightColor( + surfaceColor, + light_direction, + view_direction, + normal_worldspace, + spotLight.color / light_attenuation + ); + } + + for (var i: i32 = 0; i < lighting.directionalLightCount; i++) { + let directionalLight: DirectionalLight = lighting_getDirectionalLight(i); + lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); + } + + return lightColor; +} + +fn lighting_getSpecularLightColor(cameraPosition: vec3, position_worldspace: vec3, normal_worldspace: vec3) -> vec3{ + var lightColor = vec3(0, 0, 0); + let surfaceColor = vec3(0, 0, 0); + + if (lighting.enabled != 0) { + let view_direction = normalize(cameraPosition - position_worldspace); + + for (var i: i32 = 0; i < lighting.pointLightCount; i++) { + let pointLight: PointLight = lighting_getPointLight(i); + let light_position_worldspace: vec3 = pointLight.position; + let light_direction: vec3 = normalize(light_position_worldspace - position_worldspace); + let light_attenuation = getPointLightAttenuation( + pointLight, + distance(light_position_worldspace, position_worldspace) + ); + lightColor += lighting_getLightColor( + surfaceColor, + light_direction, + view_direction, + normal_worldspace, + pointLight.color / light_attenuation + ); + } + + for (var i: i32 = 0; i < lighting.spotLightCount; i++) { + let spotLight: SpotLight = lighting_getSpotLight(i); + let light_position_worldspace: vec3 = spotLight.position; + let light_direction: vec3 = normalize(light_position_worldspace - position_worldspace); + let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace); + lightColor += lighting_getLightColor( + surfaceColor, + light_direction, + view_direction, + normal_worldspace, + spotLight.color / light_attenuation + ); + } + + for (var i: i32 = 0; i < lighting.directionalLightCount; i++) { + let directionalLight: DirectionalLight = lighting_getDirectionalLight(i); + lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); + } + } + return lightColor; +} +`});var nJt,ZD,Ggt=Ve(()=>{Agt();Bgt();Fgt();zgt();nJt=[38.25,38.25,38.25],ZD={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:Ngt.replace("phongMaterial","gouraudMaterial"),fs:Ogt.replace("phongMaterial","gouraudMaterial"),source:Ugt.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[Igt,Cgt],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:nJt},getUniforms(s){return{...ZD.defaultUniforms,...s}}}});var vm=Ve(()=>{ELe();Ddt();c4e();ppt();mpt();bgt();Egt();Pgt();Ggt()});function Qy(s="id"){Ike[s]=Ike[s]||1;let n=Ike[s]++;return`${s}-${n}`}var Ike,hB=Ve(()=>{Ike={}});function y4(s){switch(s){case"POSITION":return"positions";case"NORMAL":return"normals";case"TEXCOORD_0":return"texCoords";case"TEXCOORD_1":return"texCoords1";case"COLOR_0":return"colors";default:return s}}function JQt(s){let n=[];for(let[r,c]of Object.entries(s)){if(!c)continue;let{value:u,size:d,normalized:b}=c;if(d===void 0)throw new Error(`Attribute ${r} is missing a size`);n.push({name:y4(r),format:fl.getVertexFormatFromAttribute(u,d,b)})}return n}var Pb,Sle=Ve(()=>{$r();hB();Pb=class{id;topology;vertexCount;indices;attributes;bufferLayout;userData={};constructor(n){let{attributes:r={},indices:c=null,vertexCount:u=null}=n;this.id=n.id||Qy("geometry"),this.topology=n.topology,c&&(this.indices=ArrayBuffer.isView(c)?{value:c,size:1}:c),this.attributes={};for(let[d,b]of Object.entries(r)){let w=ArrayBuffer.isView(b)?{value:b}:b;if(!ArrayBuffer.isView(w.value))throw new Error(`${this._print(d)}: must be typed array or object with value as typed array`);if((d==="POSITION"||d==="positions")&&!w.size&&(w.size=3),d==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=w}else{let _=y4(d),x=Object.keys(this.attributes).find(T=>y4(T)===_);x&&delete this.attributes[x],this.attributes[d]=w}}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=u||this._calculateVertexCount(this.attributes,this.indices),this.bufferLayout=n.bufferLayout||JQt(this.attributes)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(n){return`Geometry ${this.id} attribute ${n}`}_setAttributes(n,r){return this}_calculateVertexCount(n,r){if(r)return r.value.length;let c=1/0;for(let u of Object.values(n)){if(!u)continue;let{value:d,size:b,constant:w}=u;!w&&d&&b!==void 0&&b>=1&&(c=Math.min(c,d.length/b))}return c}}});function Omt(s,n={}){let r=n.bufferName||"geometry";if(QQt(s,r))return s;let c=n.minAttributeAlignment||4,u=een(s,n.attributes),d=[],b=0,w=1/0;for(let[T,M]of u){if(!M)continue;if(M.constant)throw new Error(`Attribute ${T} is constant`);let{value:L,size:I,normalized:D}=M;if(!ArrayBuffer.isView(L))throw new Error(`Attribute ${T} is missing typed array data`);if(I===void 0)throw new Error(`Attribute ${T} is missing a size`);let F=fl.getVertexFormatFromAttribute(L,I,D),O=fl.getVertexFormatInfo(F);b=Bmt(b,c),d.push({sourceName:T,attributeName:y4(T),value:L,size:I,format:F,byteOffset:b,byteLength:O.byteLength}),b+=O.byteLength;let z=L.length/I;if(!Number.isInteger(z))throw new Error(`Attribute ${T} length is not divisible by size`);w=Math.min(w,z)}if(d.length===0||!Number.isFinite(w))throw new Error(`Geometry ${s.id} has no interleavable attributes`);let _=Bmt(b,c),x=new ArrayBuffer(w*_);for(let T of d)ten(x,w,_,T);return new Pb({id:s.id,topology:s.topology||"triangle-list",vertexCount:s.vertexCount,indices:s.indices,attributes:{[r]:{value:new Uint8Array(x),size:_,byteStride:_}},bufferLayout:[{name:r,stepMode:"vertex",byteStride:_,attributes:d.map(T=>({attribute:T.attributeName,format:T.format,byteOffset:T.byteOffset}))}]})}function QQt(s,n){if(s.bufferLayout.length!==1)return!1;let r=s.bufferLayout[0];return r.name===n&&!!r.attributes?.length&&!!s.attributes[n]}function een(s,n){return n?n.map(r=>[r,s.attributes[r]]):Object.entries(s.attributes)}function ten(s,n,r,c){let u=c.value.constructor,d=u.BYTES_PER_ELEMENT;if(c.byteOffset%d!==0||r%d!==0)throw new Error(`Attribute ${c.sourceName} is not aligned to its component type`);let b=new u(s),w=c.value,_=c.byteOffset/d,x=r/d;for(let T=0;T{$r();Sle()});var nen,ien,x4,Fmt=Ve(()=>{nen=1,ien=1,x4=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(n){let{delay:r=0,duration:c=Number.POSITIVE_INFINITY,rate:u=1,repeat:d=1}=n,b=nen++,w={time:0,delay:r,duration:c,rate:u,repeat:d};return this._setChannelTime(w,this.time),this.channels.set(b,w),b}removeChannel(n){this.channels.delete(n);for(let[r,c]of this.animations)c.channel===n&&this.detachAnimation(r)}isFinished(n){let r=this.channels.get(n);return r===void 0?!1:this.time>=r.delay+r.duration*r.repeat}getTime(n){if(n===void 0)return this.time;let r=this.channels.get(n);return r===void 0?-1:r.time}setTime(n){this.time=Math.max(0,n);let r=this.channels.values();for(let u of r)this._setChannelTime(u,this.time);let c=this.animations.values();for(let u of c){let{animation:d,channel:b}=u;d.setTime(this.getTime(b))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(n,r){let c=ien++;return this.animations.set(c,{animation:n,channel:r}),n.setTime(this.getTime(r)),c}detachAnimation(n){this.animations.delete(n)}update(n){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=n),this.setTime(this.time+(n-this.lastEngineTime)),this.lastEngineTime=n)}_setChannelTime(n,r){let c=r-n.delay,u=n.duration*n.repeat;c>=u?n.time=n.duration*n.rate:(n.time=Math.max(0,c)%n.duration,n.time*=n.rate)}}});function Umt(s){let n=typeof window<"u"?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame:null;return n?n.call(window,s):setTimeout(()=>s(typeof performance<"u"?performance.now():Date.now()),1e3/60)}function zmt(s){let n=typeof window<"u"?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame:null;if(n){n.call(window,s);return}clearTimeout(s)}var Gmt=Ve(()=>{});var ren,sen,jmt,iV,$mt=Ve(()=>{$r();Gmt();Kj();ren=0,sen="Animation Loop",jmt={requestAnimationFrame:s=>Umt(s),cancelAnimationFrame:s=>zmt(s)},iV=class s{static defaultAnimationLoopProps={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:n=>{console.error(n)},stats:void 0,autoResizeViewport:!1,animationFrameProvider:jmt};device=null;canvas=null;props;animationProps=null;timeline=null;stats;sharedStats;cpuTime;gpuTime;frameRate;display;_needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;_lastFrameTime=0;constructor(n){if(this.props={...s.defaultAnimationLoopProps,...n},n=this.props,!n.device)throw new Error("No device provided");this.stats=n.stats||new yb({id:`animation-loop-${ren++}`}),this.sharedStats=UD.stats.get(sen),this.frameRate=this.stats.get("Frame Rate"),this.frameRate.setSampleSize(1),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.setProps({autoResizeViewport:n.autoResizeViewport,animationFrameProvider:n.animationFrameProvider}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null),this.device?._disableDebugGPUTime()}delete(){this.destroy()}reportError(n){this._error=n,this.props.onError(n),this.props.onError===s.defaultAnimationLoopProps.onError&&typeof window<"u"&&typeof ErrorEvent<"u"&&window.dispatchEvent(new ErrorEvent("error",{error:n,message:n.message}))}setNeedsRedraw(n){return this._needsRedraw=this._needsRedraw||n,this}needsRedraw(){let n=this._needsRedraw;return this._needsRedraw=!1,n}setProps(n){if("autoResizeViewport"in n&&(this.props.autoResizeViewport=n.autoResizeViewport||!1),"animationFrameProvider"in n){let r=n.animationFrameProvider||jmt;if(r!==this.props.animationFrameProvider){let c=this._animationFrameId!==null;c&&this._cancelAnimationFrame(),this.props.animationFrameProvider=r,c&&this._requestAnimationFrame()}}return this}async start(){if(this._running)return this;this._running=!0;try{let n;if(!this._initialized){if(this._initialized=!0,await this._initDevice(),this._initialize(),!this._running)return null;await this.props.onInitialize(this._getAnimationProps())}return this._running?(n!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(n){let r=n instanceof Error?n:new Error("Unknown error");throw this.props.onError(r),r}}stop(){if(this._running){let n=this.animationProps;this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1,this._lastFrameTime=0,n&&this.props.onFinalize(n)}return this}redraw(n,r=null){return this.device?.isLost||this._error?this:(this._beginFrameTimers(n),this._setupFrame(),this.animationProps&&(this.animationProps.animationFrame=r),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(n){return this.timeline=n,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(n=>{this._resolveNextFrame=n})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeViewport(),this.device?._enableDebugGPUTime()}_setDisplay(n){this.display&&(this.display.destroy(),this.display.animationLoop=null),n&&(n.animationLoop=this),this.display=n}_requestAnimationFrame(){this._running&&(this._animationFrameId=this.props.animationFrameProvider.requestAnimationFrame(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(this.props.animationFrameProvider.cancelAnimationFrame(this._animationFrameId),this._animationFrameId=null)}_animationFrame(n,r){if(this._running)try{this.redraw(n,r??null),this._requestAnimationFrame()}catch(c){let u=c instanceof Error?c:new Error(String(c));this.reportError(u),this.stop()}}_renderFrame(n){if(this.display){this.display._renderFrame(n);return}let r=this.props.onRender(this._getAnimationProps());this.device&&r!==!1&&this.device.submit()}_clearNeedsRedraw(){this._needsRedraw=!1}_setupFrame(){this._resizeViewport()}_initializeAnimationProps(){let n=this.device?.getDefaultCanvasContext();if(!this.device||!n)throw new Error("loop");let r=n?.canvas,c=n.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:n,canvas:r,useDevicePixels:c,timeline:this.timeline,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,animationFrame:null,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:n,height:r,aspect:c}=this._getSizeAndAspect();(n!==this.animationProps.width||r!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),c!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=n,this.animationProps.height=r,this.animationProps.aspect=c,this.animationProps.needsRedraw=this._needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.getDefaultCanvasContext().canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let n=document.createElement("div");document.body.appendChild(n),n.style.position="relative";let r=document.createElement("div");r.style.position="absolute",r.style.left="10px",r.style.bottom="10px",r.style.width="300px",r.style.background="white",this.canvas instanceof HTMLCanvasElement&&n.appendChild(this.canvas),n.appendChild(r);let c=this.props.onAddHTML(r);c&&(r.innerHTML=c)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[n,r]=this.device.getDefaultCanvasContext().getDrawingBufferSize(),c=n>0&&r>0?n/r:1;return{width:n,height:r,aspect:c}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(n){let r=n??(typeof performance<"u"?performance.now():Date.now());if(this._lastFrameTime){let c=r-this._lastFrameTime;c>0&&this.frameRate.addTime(c)}this._lastFrameTime=r,this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeStart()}_endFrameTimers(){this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeEnd(),this._updateSharedStats()}_consumeEncodedGpuTime(){if(!this.device)return;let n=this.device.commandEncoder._gpuTimeMs;n!==void 0&&(this.gpuTime.addTime(n),this.device.commandEncoder._gpuTimeMs=void 0)}_updateSharedStats(){if(this.stats!==this.sharedStats){for(let n of Object.keys(this.sharedStats.stats))this.stats.stats[n]||delete this.sharedStats.stats[n];this.stats.forEach(n=>{let r=this.sharedStats.get(n.name,n.type);r.sampleSize=n.sampleSize,r.time=n.time,r.count=n.count,r.samples=n.samples,r.lastTiming=n.lastTiming,r.lastSampleTime=n.lastSampleTime,r.lastSampleCount=n.lastSampleCount,r._count=n._count,r._time=n._time,r._samples=n._samples,r._startTime=n._startTime,r._timerPending=n._timerPending})}}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(n){n instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[n.offsetX,n.offsetY])}_onMouseleave(n){this._getAnimationProps()._mousePosition=null}}});function Vmt(s,n){if(n instanceof Mle)return n;let r=Omt(n),c=oen(s,r),{attributes:u,bufferLayout:d}=aen(s,r);return new Mle({topology:r.topology||"triangle-list",bufferLayout:d,vertexCount:r.vertexCount,indices:c,attributes:u})}function oen(s,n){if(!n.indices)return;let r=n.indices.value;return s.createBuffer({usage:as.INDEX,data:r})}function aen(s,n){let r={};for(let[c,u]of Object.entries(n.attributes)){let d=n.bufferLayout.find(b=>b.name===c)?.name||y4(c);u&&(r[d]=s.createBuffer({data:u.value,id:`${c}-buffer`}))}return{attributes:r,bufferLayout:n.bufferLayout,vertexCount:n.vertexCount}}var Mle,Wmt=Ve(()=>{$r();Sle();Nmt();hB();Mle=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(n){if(this.id=n.id||Qy("geometry"),this.topology=n.topology,this.indices=n.indices||null,this.attributes=n.attributes,this.vertexCount=n.vertexCount,this.bufferLayout=n.bufferLayout||[],this.indices&&!(this.indices.usage&as.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){this.indices?.destroy();for(let n of Object.values(this.attributes))n.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(n){return n.byteLength/12}}});function Hmt(s,n){let r={},c="Values";if(s.attributes.length===0&&!s.varyings?.length)return{"No attributes or varyings":{[c]:"N/A"}};for(let u of s.attributes)if(u){let d=`${u.location} ${u.name}: ${u.type}`;r[`in ${d}`]={[c]:u.stepMode||"vertex"}}for(let u of s.varyings||[]){let d=`${u.location} ${u.name}`;r[`out ${d}`]={[c]:JSON.stringify(u)}}return r}var qmt=Ve(()=>{});function Zmt(s,n,r){if(s.device.type!=="webgl")return;let c=uen(s.device);if(!c.flushing){if(hen(s)){cen(s,r,c);return}n&&fen(n)&&n.handle!==null&&(c.queuedFramebuffers.includes(n)||c.queuedFramebuffers.push(n))}}function cen(s,n,r){if(r.queuedFramebuffers.length===0)return;let c=s.device,{gl:u}=c,d=u.getParameter(36010),b=u.getParameter(36006),[w,_]=s.device.getDefaultCanvasContext().getDrawingBufferSize(),x=Ymt(n.top,8),T=Ymt(n.left,8);r.flushing=!0;try{for(let M of r.queuedFramebuffers){let[L,I,D,F,O]=len({framebuffer:M,targetWidth:w,targetHeight:_,topPx:x,leftPx:T,minimap:n.minimap});u.bindFramebuffer(36008,M.handle),u.bindFramebuffer(36009,null),u.blitFramebuffer(0,0,M.width,M.height,L,I,D,F,16384,9728),x+=O+8}}finally{u.bindFramebuffer(36008,d),u.bindFramebuffer(36009,b),r.flushing=!1}}function len(s){let{framebuffer:n,targetWidth:r,targetHeight:c,topPx:u,leftPx:d,minimap:b}=s,w=b?Math.max(Math.floor(r/4),1):r,_=b?Math.max(Math.floor(c/4),1):c,x=Math.min(w/n.width,_/n.height),T=Math.max(Math.floor(n.width*x),1),M=Math.max(Math.floor(n.height*x),1),L=d,I=Math.max(c-u-M,0),D=L+T,F=I+M;return[L,I,D,F,M]}function uen(s){return s.userData[Xmt]||={flushing:!1,queuedFramebuffers:[]},s.userData[Xmt]}function fen(s){return"colorAttachments"in s}function hen(s){let n=s.props.framebuffer;return!n||n.handle===null}function Ymt(s,n){if(!s)return n;let r=Number.parseInt(s,10);return Number.isFinite(r)?r:n}var Xmt,Kmt=Ve(()=>{Xmt="__debugFramebufferState"});function dB(s,n,r){if(s===n)return!0;if(!r||!s||!n)return!1;if(Array.isArray(s)){if(!Array.isArray(n)||s.length!==n.length)return!1;for(let c=0;c{});var pB,Qmt=Ve(()=>{$r();pB=class{bufferLayouts;constructor(n){this.bufferLayouts=n}getBufferLayout(n){return this.bufferLayouts.find(r=>r.name===n)||null}getAttributeNamesForBuffer(n){return VD(n)}mergeBufferLayouts(n,r){let c=[...n];for(let u of r){let d=c.findIndex(b=>b.name===u.name);d<0?c.push(u):c[d]=u}return c}}});function e1t(s,n){let r=i4e(s),c=n.slice();return c.sort((u,d)=>{let b=Oce(VD(u).map(_=>r[_])),w=Oce(VD(d).map(_=>r[_]));return b-w}),c}var t1t=Ve(()=>{$r()});function gB(s,n){if(!s||!n.some(c=>c.bindingLayout?.length))return s;let r={...s,bindings:s.bindings.map(c=>({...c}))};"attributes"in(s||{})&&(r.attributes=s?.attributes||[]);for(let c of n)for(let u of c.bindingLayout||[])for(let d of den(u.name)){let b=r.bindings.find(w=>w.name===d);b?.group===0&&(b.group=u.group),b&&u.visibility!==void 0&&(b.visibility=u.visibility)}return r}function n1t(s,n,r=[]){return s?n?{...s,attributes:s.attributes.length?men(s.attributes,n.attributes.filter(c=>r.includes(c.name))):n.attributes,bindings:gen(s.bindings,n.bindings)}:s:n}function rV(s){return!!(s.uniformTypes&&!pen(s.uniformTypes))}function i1t(s){let n=[];for(let r of s){let c=k$(r),u=new Set([r.vs,r.fs].flatMap(b=>b?R$(b).filter(w=>w.isStd140).map(w=>w.blockName):[])),d=u.has(c)?c:u.size===1?u.values().next().value:void 0;rV(r)&&d&&n.push({name:d,uniformTypes:r.uniformTypes})}return n}function Tle(s,n){let r=[],c=new Set;for(let u of[...s||[],...n||[]])c.has(u.name)||(c.add(u.name),r.push(u));return r}function den(s){let n=new Set([s,`${s}Uniforms`]);return s.endsWith("Uniforms")||n.add(`${s}Sampler`),[...n]}function pen(s){for(let n in s)return!1;return!0}function gen(s,n){let r=s.map(d=>({...d})),c=new Set(s.map(d=>d.name)),u=new Set(s.map(d=>`${d.group}:${d.location}`));for(let d of n){let b=`${d.group}:${d.location}`;!c.has(d.name)&&!u.has(b)&&r.push({...d})}return r}function men(s,n){let r=s.map(d=>({...d})),c=new Map(s.map(d=>[d.name,d])),u=new Map(s.map(d=>[d.location,d]));for(let d of n){let b=c.get(d.name);if(b){if(b.type!==d.type||b.location!==d.location)throw new Error(`Shader attribute "${d.name}" conflicts with its inferred type or location`);continue}let w=u.get(d.location);if(w)throw new Error(`Shader attributes "${w.name}" and "${d.name}" both use location ${d.location}`);r.push({...d})}return r}var Dke=Ve(()=>{vm()});function ben(s){return r$(s)||typeof s=="number"||typeof s=="boolean"}function r1t(s,n={}){let r={bindings:{},uniforms:{}};return Object.keys(s).forEach(c=>{let u=s[c];Object.prototype.hasOwnProperty.call(n,c)||ben(u)?r.uniforms[c]=u:r.bindings[c]=u}),r}var s1t=Ve(()=>{sLe()});function o1t(s={},n={},r={}){let c={...s};for(let[u,d]of Object.entries(n))d!==void 0&&(c[u]=Bke(s[u],d,r[u]));return c}function Bke(s,n,r){if(!r||typeof r=="string")return sV(n);if(Array.isArray(r)){if(Oke(n)||!Array.isArray(n))return sV(n);let b=Array.isArray(s)&&!Oke(s)?[...s]:[],w=b.slice();for(let _=0;_r===void 0?void 0:sV(r)):Nke(s)?Object.fromEntries(Object.entries(s).map(([n,r])=>[n,r===void 0?void 0:sV(r)])):s}function Oke(s){return ArrayBuffer.isView(s)||Array.isArray(s)&&(s.length===0||typeof s[0]=="number")}function Nke(s){return!!s&&typeof s=="object"&&!Array.isArray(s)&&!ArrayBuffer.isView(s)}function wen(s){return!!s?.dependencies}var mB,Fke=Ve(()=>{$r();vm();s1t();mB=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;directBindings={};constructor(n,r){Object.assign(this.options,r);let c=ZL(Object.values(n).filter(wen));for(let u of c)n[u.name]=u;Qt.log(1,"Creating ShaderInputs with modules",Object.keys(n))(),this.modules=n,this.moduleUniforms={},this.moduleBindings={};for(let[u,d]of Object.entries(n))d&&(this._addModule(d),d.name&&u!==d.name&&!this.options.disableWarnings&&Qt.warn(`Module name: ${u} vs ${d.name}`)())}destroy(){}setProps(n){n.bindings&&Object.assign(this.directBindings,n.bindings);for(let r of Object.keys(n)){if(r==="bindings")continue;let c=r,u=n[c]||{},d=this.modules[c];if(!d)this.options.disableWarnings||Qt.warn(`Module ${r} not found`)();else{let b=this.moduleUniforms[c],w=this.moduleBindings[c],_=d.getUniforms?.(u,b)||u,{uniforms:x,bindings:T}=r1t(_,d.uniformTypes);this.moduleUniforms[c]=o1t(b,x,d.uniformTypes),this.moduleBindings[c]={...w,...T}}}}getModules(){return Object.values(this.modules)}addModules(n){let r=ZL(n);for(let c of r){let u=c.name;this.modules[u]||(this.modules[u]=c,this._addModule(c))}}getUniformValues(){return this.moduleUniforms}getBindingValues(){let n={};for(let r of Object.values(this.moduleBindings))Object.assign(n,r);return Object.assign(n,this.directBindings),n}getModuleBindingValues(n){let r=this.moduleBindings[n];return r?{...r}:{}}getDebugTable(){let n={};for(let[r,c]of Object.entries(this.moduleUniforms))for(let[u,d]of Object.entries(c))n[`${r}.${u}`]={type:this.modules[r].uniformTypes?.[u],value:String(d)};return n}_addModule(n){let r=n.name;this.moduleUniforms[r]=o1t({},n.defaultUniforms||{},n.uniformTypes),this.moduleBindings[r]={}}}});function Uke(s){return s!==null&&typeof s=="object"&&"buffer"in s}function _en(s){return s instanceof lp?s.buffer:s}function a1t(s){return{buffer:_en(s.buffer),offset:s.offset,size:s.size}}var ven,lp,zke=Ve(()=>{$r();hB();ven=as.DEBUG_DATA_MAX_LENGTH,lp=class{device;id;ready;usage;props;isReady=!0;destroyed=!1;generation=0;updateTimestamp;debugData=new ArrayBuffer(0);_debugDataEnabled;_maxDebugDataByteLength;_ownsBuffer;_buffer;get buffer(){return this._buffer}get byteLength(){return this._buffer.byteLength}get[Symbol.toStringTag](){return"DynamicBuffer"}toString(){return`DynamicBuffer:"${this.id}":${this.byteLength}B`}toJSON(){return this.toString()}constructor(n,r){let{debugData:c=!1,buffer:u,ownsBuffer:d=!0,...b}=r;if(u&&u.device!==n)throw new Error("DynamicBuffer adopted buffers must belong to the supplied device");if(u&&(b.byteLength!==void 0||b.data!==void 0))throw new Error("DynamicBuffer cannot combine an adopted buffer with byteLength or data");let w=r.id||u?.id||Qy("dynamic-buffer"),_={...b,id:w,usage:b.usage??u?.usage,indexType:b.indexType??u?.indexType};(_.usage||0)&as.INDEX&&!_.indexType&&(b.data instanceof Uint32Array?_.indexType="uint32":b.data instanceof Uint16Array?_.indexType="uint16":b.data instanceof Uint8Array&&(_.indexType="uint8")),delete _.data,delete _.byteOffset,this.device=n,this.id=w,this.props=_,this.usage=_.usage||0,this._debugDataEnabled=!!c,this._maxDebugDataByteLength=typeof c=="object"&&c.maxByteLength!==void 0?c.maxByteLength:ven,this._ownsBuffer=d,this._buffer=u??this.device.createBuffer({...b,id:w}),this.ready=Promise.resolve(this._buffer),this.updateTimestamp=this._buffer.updateTimestamp,this._resetDebugData(this._buffer.byteLength),b.data&&this._writeDebugData(b.data,b.byteOffset||0)}write(n,r=0){this._buffer.write(n,r),this._touch(),this._writeDebugData(n,r)}async mapAndWriteAsync(n,r=0,c=this.byteLength-r){let u=null;await this._buffer.mapAndWriteAsync(async(d,b)=>{await n(d,b),u=new Uint8Array(d.slice(0,c))},r,c),this._touch(),u&&this._writeDebugData(u,r)}async readAsync(n=0,r=this.byteLength-n){let c=await this._buffer.readAsync(n,r);return this._writeDebugData(c,n)&&this._touch(),c}async mapAndReadAsync(n,r=0,c=this.byteLength-r){let u=null,d=await this._buffer.mapAndReadAsync(async(b,w)=>(u=new Uint8Array(b.slice(0)),await n(b,w)),r,c);return u&&this._writeDebugData(u,r)&&this._touch(),d}resize(n){let{byteLength:r,preserveData:c=!1}=n;if(r===this.byteLength)return!1;let u=Math.min(n.copyByteLength??Math.min(this.byteLength,r),this.byteLength,r),d=this._buffer,b=this.debugData.slice(0),{data:w,byteOffset:_,...x}=this.props,T=this.device.createBuffer({...x,byteLength:r});return c&&u>0&&this._copyBufferContents(d,T,u),this._buffer=T,this._resetDebugData(r),c&&b.byteLength>0&&this._writeDebugData(b,0),this._ownsBuffer&&d.destroy(),this._ownsBuffer=!0,this.generation++,this._touch(),!0}ensureSize(n,r){return n<=this.byteLength?!1:this.resize({byteLength:n,preserveData:r?.preserveData})}getBinding(n){return n?.offset===void 0&&n?.size===void 0?this._buffer:{buffer:this._buffer,offset:n?.offset,size:n?.size}}destroy(){this.destroyed||(this._ownsBuffer&&this._buffer.destroy(),this.destroyed=!0,this.debugData=new ArrayBuffer(0))}_copyBufferContents(n,r,c){let u=this.device.type==="webgpu"?Math.ceil(c/4)*4:c,d=this.device.createCommandEncoder();d.copyBufferToBuffer({sourceBuffer:n,destinationBuffer:r,size:u}),this.device.submit(d.finish())}_touch(){this.updateTimestamp=this.device.incrementTimestamp()}_resetDebugData(n){if(!this._debugDataEnabled){this.debugData=new ArrayBuffer(0);return}this.debugData=new ArrayBuffer(Math.min(n,this._maxDebugDataByteLength))}_writeDebugData(n,r){if(!this._debugDataEnabled||this.debugData.byteLength===0||r>=this.debugData.byteLength)return!1;let c=ArrayBuffer.isView(n)?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n),u=new Uint8Array(this.debugData),d=Math.min(c.byteLength,u.byteLength-r);return u.set(c.subarray(0,d),r),d>0}}});function oV(s){return s!==null&&typeof s=="object"&&"resolveTextureBinding"in s&&typeof s.resolveTextureBinding=="function"}function yen(s){return s?.type==="texture"||s?.type==="external-texture"}function c1t(s,n,r){let c=Lce(s,n,{ignoreWarnings:!0});return yen(c)?c:s.bindings.length===0&&r?.fallbackGroup!==void 0?{type:"texture",name:n,group:r.fallbackGroup,location:0}:null}var l1t=Ve(()=>{$r()});function jke(s,n){return s.shaderLanguage!==void 0&&s.shaderLanguage!==n?!1:n==="glsl"?"assembleGLSLShaderPair"in s&&typeof s.assembleGLSLShaderPair=="function":"assembleWGSLShader"in s&&typeof s.assembleWGSLShader=="function"}function Sen(s,n){return!s||Object.keys(n).length===0?s:{...s,attributes:s.attributes.map(r=>{let c=r.name.startsWith("_luma_")?r.name.slice(6):null;return c&&n[c]?{...r,name:c}:r})}}function Men(s,n,r){if(oV(n)){let c=c1t(r,s,{fallbackGroup:0});return c?n.resolveTextureBinding(c):null}return n instanceof lp?n.buffer:Uke(n)?a1t(n):n}function Ten(s){return s&&!u1t(s)?s:null}function Cen(s){return s&&u1t(s)?s:void 0}function u1t(s){return Een.includes(s)}function Aen(s){return{type:s.type,shaderLanguage:s.info.shadingLanguage,shaderLanguageVersion:s.info.shadingLanguageVersion,gpu:s.info.gpu,limits:s.limits,features:s.features}}var e2,xen,Gke,Een,$h,$ke=Ve(()=>{$r();vm();Wmt();qmt();Kmt();Jmt();Qmt();t1t();Dke();hB();Fke();zke();l1t();e2=2,xen=1e4,Gke="render pipeline initialization failed",Een=["stencil8","depth16unorm","depth24plus","depth24plus-stencil8","depth32float","depth32float-stencil8"],$h=class s{static defaultProps={...Sb.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],plugins:[],geometry:null,indexBuffer:null,indexCount:void 0,firstVertex:0,firstIndex:0,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,material:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:Mb.getDefaultShaderAssembler("glsl"),debugShaders:void 0,disableWarnings:void 0};device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexCount;firstVertex;firstIndex;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;material=null;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_dynamicIndexBufferSource=null;_dynamicAttributeBufferSources={};_colorAttachmentFormats;_depthStencilAttachmentFormat;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_drawBlockedReason=!1;_destroyed=!1;_vertexCountSet=!1;_lastDrawTimestamp=-1;_bindingTable=[];get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(n,r){let c=s.defaultProps.shaderAssembler,u=r.vertexCount!==void 0;this.props={...s.defaultProps,...r,shaderAssembler:r.shaderAssembler??(jke(c,n.info.shadingLanguage)?c:Mb.getDefaultShaderAssembler(n.info.shadingLanguage))},this._vertexCountSet=u,r=this.props,this.id=r.id||Qy("model"),this.device=n,Object.assign(this.userData,r.userData),this.material=r.material||null;let d=Aen(n),b=P$(this.props.plugins,d.shaderLanguage),w=L$(this.props.modules,b.modules),_=Object.fromEntries(w.map(I=>[I.name,I])),x=r.shaderInputs||new mB(_,{disableWarnings:this.props.disableWarnings});r.shaderInputs&&b.modules.length>0&&x.addModules(b.modules),this.setShaderInputs(x);let T=Tle(this.props.modules,x.getModules()),M={...b.defines,...this.props.defines};if(this.device.type==="webgl"&&(this.props._uniformBlockLayouts=i1t(T)),this.props.shaderLayout=gB(this.props.shaderLayout,T)||null,this.device.type==="webgpu"&&this.props.source){let I=this.props.shaderAssembler;NM(jke(I,"wgsl"));let{source:D,getUniforms:F,bindingTable:O,shaderLayout:z}=I.assembleWGSLShader({platformInfo:d,...this.props,modules:T,defines:M,pluginInjections:b.injections,pluginVertexInputs:b.vertexInputs,pluginVaryings:b.varyings});this.source=D,this._getModuleUniforms=F,this._bindingTable=O;let Z=z??n.getShaderLayout?.(this.source),H=Sen(Z,b.vertexInputs),te=n1t(this.props.shaderLayout,H,Object.keys(b.vertexInputs));this.props.shaderLayout=gB(te||null,T)||null}else{let I=this.props.shaderAssembler;NM(jke(I,"glsl"));let{vs:D,fs:F,getUniforms:O}=I.assembleGLSLShaderPair({platformInfo:d,...this.props,modules:T,defines:M,pluginInjections:b.injections,pluginVertexInputs:b.vertexInputs,pluginVaryings:b.varyings});this.vs=D,this.fs=F,this._getModuleUniforms=O,this._bindingTable=[]}this.vertexCount=this.props.vertexCount,this.indexCount=this.props.indexCount,this.firstVertex=this.props.firstVertex,this.firstIndex=this.props.firstIndex,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,this._colorAttachmentFormats=this.props.colorAttachmentFormats,this._depthStencilAttachmentFormat=this.props.depthStencilAttachmentFormat,r.geometry&&this.setGeometry(r.geometry),this.pipelineFactory=r.pipelineFactory||i4.getDefaultPipelineFactory(this.device),this.shaderFactory=r.shaderFactory||r4.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=n.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in r&&(this.isInstanced=r.isInstanced),r.instanceCount&&this.setInstanceCount(r.instanceCount),r.vertexCount&&this.setVertexCount(r.vertexCount),r.indexBuffer&&this.setIndexBuffer(r.indexBuffer),r.attributes&&this.setAttributes(r.attributes),r.constantAttributes&&this.setConstantAttributes(r.constantAttributes),r.bindings&&this.setBindings(r.bindings),r.transformFeedback&&(this.transformFeedback=r.transformFeedback)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let n=this._needsRedraw;return this._needsRedraw=!1,n}setNeedsRedraw(n){this._needsRedraw||=n}getBindingDebugTable(){return this._bindingTable}predraw(n){this._syncDynamicBuffers(),this.updateShaderInputs(n),this.material?.updateShaderInputs(n),this.pipeline=this._updatePipeline()}draw(n){if(this._drawBlockedReason&&!this._pipelineNeedsUpdate)return Qt.info(e2,`>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)(),!1;let r=this._areBindingsLoading();if(r)return Qt.info(e2,`>>> DRAWING ABORTED ${this.id}: ${r} not loaded`)(),!1;this._syncAttachmentFormats(n);try{n.pushDebugGroup(`${this}.predraw(${n})`),this.device.type==="webgpu"?(this.updateShaderInputs(),this.material?.updateShaderInputs(),this._syncDynamicBuffers(),this.pipeline=this._updatePipeline()):this.predraw(this.device.commandEncoder)}finally{n.popDebugGroup()}let c,u=this.pipeline.isErrored;try{if(n.pushDebugGroup(`${this}.draw(${n})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline(),u=this.pipeline.isErrored,u)Qt.info(e2,`>>> DRAWING ABORTED ${this.id}: ${Gke}`)(),c=!1;else{let d=this.vertexArray.getDrawValidationError();if(d)Qt.info(e2,`>>> DRAWING ABORTED ${this.id}: ${d}`)(),this._drawBlockedReason=d,c=!1;else{let b=this._getCurrentShaderLayout(),w=this._getBindings(b),_=this._getBindGroups(b,w),{indexBuffer:x}=this.vertexArray,T=x?this.indexCount??(this._vertexCountSet?this.vertexCount:x.byteLength/(x.indexType==="uint32"?4:2)):void 0;n.setPipeline(this.pipeline),n.setBindings(_,{_bindGroupCacheKeys:this._getBindGroupCacheKeys()}),n.setVertexArray(this.vertexArray),c=this.isInstanced===!0&&this.instanceCount===0?!0:n.draw({isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.isInstanced?this.instanceCount:void 0,indexCount:T,firstVertex:this.firstVertex,firstIndex:this.firstIndex,transformFeedback:this.transformFeedback||void 0,uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}}}finally{n.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(n),c?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):u?(this._needsRedraw=Gke,this._drawBlockedReason=Gke):this._drawBlockedReason?this._needsRedraw=this._drawBlockedReason:this._needsRedraw="waiting for resource initialization",c}setGeometry(n){this._gpuGeometry?.destroy();let r=n&&Vmt(this.device,n);if(r){this.setTopology(r.topology||"triangle-list");let c=new pB(this.bufferLayout);this.bufferLayout=c.mergeBufferLayouts(r.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(r)}this._gpuGeometry=r}setTopology(n){n!==this.topology&&(this.topology=n,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(n){let r=new pB(this.bufferLayout),c=this._gpuGeometry?r.mergeBufferLayouts(n,this._gpuGeometry.bufferLayout):n;dB(c,this.bufferLayout,-1)||(this.bufferLayout=c,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry))}setParameters(n){dB(n,this.parameters,2)||(this.parameters=n,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(n){this.instanceCount=n,this.isInstanced===void 0&&n>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(n){this.vertexCount=n,this._vertexCountSet=!0,this.setNeedsRedraw("vertexCount")}setIndexCount(n){this.indexCount=n,this.setNeedsRedraw("indexCount")}setDrawOffsets({firstVertex:n,firstIndex:r}){this.firstVertex=n,this.firstIndex=r,this.setNeedsRedraw("drawOffsets")}setShaderInputs(n){this.shaderInputs=n,this._uniformStore=new a4(this.device,this.shaderInputs.modules);for(let[r,c]of Object.entries(this.shaderInputs.modules))if(rV(c)&&!this.material?.ownsModule(r)){let u=this._uniformStore.getManagedUniformBuffer(r);this.bindings[`${r}Uniforms`]=u}this.setNeedsRedraw("shaderInputs")}setMaterial(n){this.material=n,this.setNeedsRedraw("material")}updateShaderInputs(n){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),n),this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues())),this.setNeedsRedraw("shaderInputs")}setBindings(n){Object.assign(this.bindings,n),this.setNeedsRedraw("bindings")}setTransformFeedback(n){this.transformFeedback=n,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(n){let r=n instanceof lp?n.buffer:n;this.indexBuffer=r,this._dynamicIndexBufferSource=n instanceof lp?{source:n,generation:n.generation}:null,this.vertexArray.setIndexBuffer(r),this.setNeedsRedraw("indexBuffer")}setAttributes(n,r){this._drawBlockedReason=!1;let c=r?.disableWarnings??this.props.disableWarnings;n.indices&&Qt.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=e1t(this.pipeline.shaderLayout,this.bufferLayout);let u=new pB(this.bufferLayout);for(let[d,b]of Object.entries(n)){let w=b instanceof lp?b.buffer:b,_=u.getBufferLayout(d);if(!_){c||Qt.warn(`Model(${this.id}): Missing layout for buffer "${d}".`)();continue}let x=u.getAttributeNamesForBuffer(_),T=!1;for(let M of x){let L=this._attributeInfos[M];if(L){let I=this.device.type==="webgpu"?this.vertexArray.getBufferSlot(L.bufferName):L.location;if(I===null){c||Qt.warn(`Model(${this.id}): Missing vertex array slot for buffer "${L.bufferName}".`)();continue}this.vertexArray.setBuffer(I,w),b instanceof lp?this._dynamicAttributeBufferSources[I]={source:b,generation:b.generation}:delete this._dynamicAttributeBufferSources[I],T=!0}}!T&&!c&&Qt.warn(`Model(${this.id}): Ignoring buffer "${w.id}" for unknown attribute "${d}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(n,r){for(let[c,u]of Object.entries(n)){let d=this._attributeInfos[c];d?this.vertexArray.setConstantWebGL(d.location,u):(r?.disableWarnings??this.props.disableWarnings)||Qt.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${c}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(let n of Object.values(this.bindings))if(oV(n)&&!n.isReady)return n.id;for(let n of Object.values(this.material?.bindings||{}))if(oV(n)&&!n.isReady)return n.id;return!1}_getBindings(n=this._getCurrentShaderLayout()){let r={};for(let[c,u]of Object.entries(this.bindings)){let d=Men(c,u,n);d&&(r[c]=d)}return r}_getBindGroups(n=this._getCurrentShaderLayout(),r=this._getBindings(n)){let c=n.bindings.length?s4(n,r):{0:r};if(!this.material)return c;for(let[u,d]of Object.entries(this.material.getBindingsByGroup(n))){let b=Number(u);c[b]={...c[b]||{},...d}}return c}_getBindGroupCacheKeys(){let n=this.material?.getBindGroupCacheKey(3);return n?{3:n}:{}}_getBindingsUpdateTimestamp(){let n=0;this._dynamicIndexBufferSource&&(n=Math.max(n,this._dynamicIndexBufferSource.source.updateTimestamp));for(let r of Object.values(this._dynamicAttributeBufferSources))n=Math.max(n,r.source.updateTimestamp);for(let r of Object.values(this.bindings))r instanceof e4?n=Math.max(n,r.texture.updateTimestamp):r instanceof as||r instanceof Aa||r instanceof b$||r instanceof lp?n=Math.max(n,r.updateTimestamp):oV(r)?n=r.isReady?Math.max(n,r.updateTimestamp):1/0:Uke(r)&&(n=Math.max(n,(r.buffer instanceof lp,r.buffer.updateTimestamp)));return Math.max(n,this.material?.getBindingsUpdateTimestamp()||0)}_setGeometryAttributes(n){let r={...n.attributes};for(let[c]of Object.entries(r))!this.pipeline.shaderLayout.attributes.find(u=>u.name===c)&&c!=="positions"&&delete r[c];this.vertexCount=n.vertexCount,this._vertexCountSet=!0,this.setIndexBuffer(n.indices||null),this.setAttributes(n.attributes,{disableWarnings:!0}),this.setAttributes(r,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(n){this._pipelineNeedsUpdate||=n,this._drawBlockedReason=!1,this.setNeedsRedraw(n)}_updatePipeline(){if(this._pipelineNeedsUpdate){let n=null,r=null;this.pipeline&&(Qt.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),n=this.pipeline.vs,r=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let c=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders}),u=null;this.source?u=c:this.fs&&(u=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bindings:void 0,bufferLayout:this.bufferLayout,colorAttachmentFormats:this._colorAttachmentFormats,depthStencilAttachmentFormat:this._depthStencilAttachmentFormat,topology:this.topology,parameters:this.parameters,bindGroups:void 0,vs:c,fs:u}),this._attributeInfos=A$(this.pipeline.shaderLayout,this.bufferLayout),n&&this.shaderFactory.release(n),r&&r!==n&&this.shaderFactory.release(r)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let n=Qt.level>3?0:xen;Qt.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:Qt.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let n=Hmt(this.pipeline.shaderLayout,this.id);Qt.table(e2,n)();let r=this.shaderInputs.getDebugTable();Qt.table(e2,r)();let c=this._getAttributeDebugTable();Qt.table(e2,this._attributeInfos)(),Qt.table(e2,c)(),Qt.groupEnd(e2)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(n){let r=this.device.props.debugFramebuffers;if(this._drawCount++,!r)return;let c=n.props.framebuffer;Zmt(n,c,{id:c?.id||`${this.id}-framebuffer`,minimap:!0})}_getAttributeDebugTable(){let n={};for(let[r,c]of Object.entries(this._attributeInfos)){let u=this.vertexArray.attributes[c.location];n[c.location]={name:r,type:c.shaderType,values:u?this._getBufferOrConstantValues(u,c.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:r}=this.vertexArray,c=r.indexType==="uint32"?new Uint32Array(r.debugData):new Uint16Array(r.debugData);n.indices={name:"indices",type:r.indexType,values:c.toString()}}return n}_getBufferOrConstantValues(n,r){let c=Sd.getTypedArrayConstructor(r);return(n instanceof as?new c(n.debugData):n).toString()}_getNonMaterialBindings(n){if(!this.material)return n;let r={};for(let[c,u]of Object.entries(n))this.material.ownsBinding(c)||(r[c]=u);return r}_getCurrentShaderLayout(){return this.pipeline?.shaderLayout||this.props.shaderLayout||{bindings:[]}}_syncDynamicBuffers(){if(this._dynamicIndexBufferSource&&this._dynamicIndexBufferSource.generation!==this._dynamicIndexBufferSource.source.generation){let n=this._dynamicIndexBufferSource.source.buffer;this.indexBuffer=n,this.vertexArray.setIndexBuffer(n),this._dynamicIndexBufferSource.generation=this._dynamicIndexBufferSource.source.generation,this.setNeedsRedraw("dynamic index buffer")}for(let[n,r]of Object.entries(this._dynamicAttributeBufferSources))r.generation!==r.source.generation&&(this.vertexArray.setBuffer(Number(n),r.source.buffer),r.generation=r.source.generation,this.setNeedsRedraw("dynamic attribute buffer"))}_syncAttachmentFormats(n){if(this.device.type!=="webgpu")return;let r=n.framebuffer||n.props.framebuffer,c=n.props,u=c.colorAttachmentFormats??r?.colorAttachments?.map(b=>Ten(b?.texture?.format)),d=c.depthStencilAttachmentFormat===!1?void 0:c.depthStencilAttachmentFormat??Cen(r?.depthStencilAttachment?.texture?.format);(!dB(this._colorAttachmentFormats,u,1)||this._depthStencilAttachmentFormat!==d)&&(this._colorAttachmentFormats=u,this._depthStencilAttachmentFormat=d,this._setPipelineNeedsUpdate("attachment formats"))}}});var Pen,Len,up,f1t=Ve(()=>{$r();vm();$ke();Pen=35980,Len=35981,up=class s{device;model;transformFeedback;static defaultProps={...$h.defaultProps,feedbackBufferMode:"separate",outputs:void 0,feedbackBuffers:void 0};static isSupported(n){return n?.info?.type==="webgl"}constructor(n,r=s.defaultProps){if(!s.isSupported(n))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=n,this.model=new $h(this.device,{id:r.id||"buffer-transform-model",fs:r.fs||v4e(),topology:r.topology||"point-list",varyings:r.outputs||r.varyings,...r,bufferMode:r.bufferMode||(r.feedbackBufferMode==="interleaved"?Pen:Len)}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:r.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(n){n?.inputBuffers&&this.model.setAttributes(n.inputBuffers),n?.outputBuffers&&this.transformFeedback.setBuffers(n.outputBuffers);let r=this.device.beginRenderPass({discard:!0,...n});this.model.draw(r),r.end()}getBuffer(n){return this.transformFeedback.getBuffer(n)}readAsync(n){let r=this.getBuffer(n);if(!r)throw new Error("BufferTransform#getBuffer");if(r instanceof as)return r.readAsync();let{buffer:c,byteOffset:u=0,byteLength:d=c.byteLength}=r;return c.readAsync(u,d)}}});function Ren(s){return{type:s.type,shaderLanguage:s.info.shadingLanguage,shaderLanguageVersion:s.info.shadingLanguageVersion,gpu:s.info.gpu,limits:s.limits,features:s.features}}var Vke,ken,G1,h1t=Ve(()=>{$r();vm();sLe();Fke();Dke();hB();Vke=2,ken=1e4,G1=class s{static defaultProps={...zM.defaultProps,id:"unnamed",handle:void 0,userData:{},source:"",modules:[],defines:{},plugins:[],bindings:void 0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,shaderAssembler:Mb.getDefaultShaderAssembler("wgsl"),debugShaders:void 0};device;id;pipelineFactory;shaderFactory;userData={};bindings={};pipeline;source;shader;shaderInputs;_uniformStore;_pipelineNeedsUpdate="newly created";_getModuleUniforms;props;_destroyed=!1;constructor(n,r){if(n.type!=="webgpu")throw new Error("Computation is only supported in WebGPU");this.props={...s.defaultProps,...r},r=this.props,this.id=r.id||Qy("model"),this.device=n,Object.assign(this.userData,r.userData);let c=Ren(n),u=P$(this.props.plugins,c.shaderLanguage);if(Object.keys(u.vertexInputs).length>0||Object.keys(u.varyings).length>0)throw new Error("Computation does not support ShaderPlugin vertex inputs or varyings");let d=L$(this.props.modules,u.modules),b=Object.fromEntries(d.map(D=>[D.name,D]));this.shaderInputs=r.shaderInputs||new mB(b),r.shaderInputs&&u.modules.length>0&&this.shaderInputs.addModules(u.modules),this.setShaderInputs(this.shaderInputs);let w=Tle(this.props.modules,this.shaderInputs?.getModules()),_={...u.defines,...this.props.defines};this.props.shaderLayout=gB(this.props.shaderLayout,w)||null,this.pipelineFactory=r.pipelineFactory||i4.getDefaultPipelineFactory(this.device),this.shaderFactory=r.shaderFactory||r4.getDefaultShaderFactory(this.device);let x=this.props.shaderAssembler;NM(x instanceof jM);let{source:T,getUniforms:M,shaderLayout:L}=x.assembleWGSLShader({platformInfo:c,...this.props,modules:w,defines:_,scanVertexAttributes:!1,pluginInjections:u.injections});this.source=T,this._getModuleUniforms=M;let I=L??n.getShaderLayout?.(this.source,{scanVertexAttributes:!1});this.props.shaderLayout=gB(this.props.shaderLayout||I||null,w)||null,this.pipeline=this._updatePipeline(),r.bindings&&this.setBindings(r.bindings)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.shader),this._uniformStore.destroy(),this._destroyed=!0)}predraw(n){this.updateShaderInputs(n)}dispatch(n,r,c,u){try{this._logDrawCallStart(),this._setPipeline(n),n.dispatch(r,c,u)}finally{this._logDrawCallEnd()}}dispatchIndirect(n,r,c=0){try{this._logDrawCallStart(),this._setPipeline(n),n.dispatchIndirect(r,c)}finally{this._logDrawCallEnd()}}_setPipeline(n){this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings),n.setPipeline(this.pipeline),n.setBindings({})}setVertexCount(n){}setInstanceCount(n){}setShaderInputs(n){this.shaderInputs=n,this._uniformStore=new a4(this.device,this.shaderInputs.modules);for(let[r,c]of Object.entries(this.shaderInputs.modules))if(rV(c)){let u=this._uniformStore.getManagedUniformBuffer(r);this.bindings[`${r}Uniforms`]=u}}setShaderModuleProps(n){let r=this._getModuleUniforms(n),c=Object.keys(r).filter(d=>{let b=r[d];return!r$(b)&&typeof b!="number"&&typeof b!="boolean"}),u={};for(let d of c)u[d]=r[d],delete r[d]}updateShaderInputs(n){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),n)}setBindings(n){Object.assign(this.bindings,n)}_setPipelineNeedsUpdate(n){this._pipelineNeedsUpdate=this._pipelineNeedsUpdate||n}_updatePipeline(){if(this._pipelineNeedsUpdate){let n=null;this.pipeline&&(Qt.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),n=this.shader),this._pipelineNeedsUpdate=!1,this.shader=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"compute",source:this.source,debugShaders:this.props.debugShaders}),this.pipeline=this.pipelineFactory.createComputePipeline({...this.props,shader:this.shader}),n&&this.shaderFactory.release(n)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let n=Qt.level>3?0:ken;Qt.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:Qt.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let n=this.shaderInputs.getDebugTable();Qt.table(Vke,n)(),Qt.groupEnd(Vke)(),this._logOpen=!1}}_drawCount=0;_getBufferOrConstantValues(n,r){let c=Sd.getTypedArrayConstructor(r);return(n instanceof as?new c(n.debugData):n).toString()}}});var Jl=Ve(()=>{Fmt();$mt();$ke();f1t();Sle();zke();h1t()});function C1t(s=!0){let n=HTMLCanvasElement.prototype;if(!s&&n.originalGetContext){n.getContext=n.originalGetContext,n.originalGetContext=void 0;return}n.originalGetContext=n.getContext,n.getContext=function(r,c){if(r==="webgl"||r==="experimental-webgl"){let u=this.originalGetContext("webgl2",c);return u instanceof HTMLElement&<n(u),u}return this.originalGetContext(r,c)}}function ltn(s){s.getExtension("EXT_color_buffer_float");let n={...stn,WEBGL_disjoint_timer_query:s.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:otn(s),OES_vertex_array_object:atn(s),ANGLE_instanced_arrays:ctn(s)},r=s.getExtension.bind(s);s.getExtension=function(u){let d=r(u);return d||(u in n?n[u]:null)};let c=s.getSupportedExtensions;s.getSupportedExtensions=function(){return(c.apply(s)||[])?.concat(Object.keys(n))}}var stn,otn,atn,ctn,A1t=Ve(()=>{stn={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},otn=s=>({drawBuffersWEBGL(n){return s.drawBuffers(n)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),atn=s=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return s.createVertexArray()},deleteVertexArrayOES(n){return s.deleteVertexArray(n)},isVertexArrayOES(n){return s.isVertexArray(n)},bindVertexArrayOES(n){return s.bindVertexArray(n)}}),ctn=s=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...n){return s.drawArraysInstanced(...n)},drawElementsInstancedANGLE(...n){return s.drawElementsInstanced(...n)},vertexAttribDivisorANGLE(...n){return s.vertexAttribDivisor(...n)}})});async function L1t(){if(!Dle){tRe();return}await Dle.load()}function k1t(s,n){return Dle?Dle.makeDebugContext(s,n):(tRe(),s)}async function R1t(s){if(!eRe){tRe();return}await eRe.load(s)}function I1t(s){return eRe?.initialize(s)||null}function tRe(){P1t||(P1t=!0,Qt.warn("Import @luma.gl/webgl/debug before enabling WebGL debugging.")())}var Dle,eRe,P1t,nRe=Ve(()=>{$r();Dle=null,eRe=null,P1t=!1});function iRe(s){return Array.isArray(s)||ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Ru(s,n,r){return n[s]!==void 0?n[s]:r[s]}var xV,Of,D1t,j1,B1t,yV,O1t,N1t,rRe,r2,sRe,F1t,oRe=Ve(()=>{xV={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},Of=(s,n,r)=>n?s.enable(r):s.disable(r),D1t=(s,n,r)=>s.hint(r,n),j1=(s,n,r)=>s.pixelStorei(r,n),B1t=(s,n,r)=>{let c=r===36006?36009:36008;return s.bindFramebuffer(c,n)},yV=(s,n,r)=>{let u={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[r];s.bindBuffer(u,n)};O1t={3042:Of,32773:(s,n)=>s.blendColor(...n),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(s,n)=>s.clearColor(...n),3107:(s,n)=>s.colorMask(...n),2884:Of,2885:(s,n)=>s.cullFace(n),2929:Of,2931:(s,n)=>s.clearDepth(n),2932:(s,n)=>s.depthFunc(n),2928:(s,n)=>s.depthRange(...n),2930:(s,n)=>s.depthMask(n),3024:Of,35723:D1t,35725:(s,n)=>s.useProgram(n),36007:(s,n)=>s.bindRenderbuffer(36161,n),36389:(s,n)=>s.bindTransformFeedback?.(36386,n),34229:(s,n)=>s.bindVertexArray(n),36006:B1t,36010:B1t,34964:yV,36662:yV,36663:yV,35053:yV,35055:yV,2886:(s,n)=>s.frontFace(n),33170:D1t,2849:(s,n)=>s.lineWidth(n),32823:Of,32824:"polygonOffset",10752:"polygonOffset",35977:Of,32926:Of,32928:Of,32938:"sampleCoverage",32939:"sampleCoverage",3089:Of,3088:(s,n)=>s.scissor(...n),2960:Of,2961:(s,n)=>s.clearStencil(n),2968:(s,n)=>s.stencilMaskSeparate(1028,n),36005:(s,n)=>s.stencilMaskSeparate(1029,n),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(s,n)=>s.viewport(...n),34383:Of,10754:Of,12288:Of,12289:Of,12290:Of,12291:Of,12292:Of,12293:Of,12294:Of,12295:Of,3333:j1,3317:j1,37440:j1,37441:j1,37443:j1,3330:j1,3332:j1,3331:j1,3314:j1,32878:j1,3316:j1,3315:j1,32877:j1,framebuffer:(s,n)=>{let r=n&&"handle"in n?n.handle:n;return s.bindFramebuffer(36160,r)},blend:(s,n)=>n?s.enable(3042):s.disable(3042),blendColor:(s,n)=>s.blendColor(...n),blendEquation:(s,n)=>{let r=typeof n=="number"?[n,n]:n;s.blendEquationSeparate(...r)},blendFunc:(s,n)=>{let r=n?.length===2?[...n,...n]:n;s.blendFuncSeparate(...r)},clearColor:(s,n)=>s.clearColor(...n),clearDepth:(s,n)=>s.clearDepth(n),clearStencil:(s,n)=>s.clearStencil(n),colorMask:(s,n)=>s.colorMask(...n),cull:(s,n)=>n?s.enable(2884):s.disable(2884),cullFace:(s,n)=>s.cullFace(n),depthTest:(s,n)=>n?s.enable(2929):s.disable(2929),depthFunc:(s,n)=>s.depthFunc(n),depthMask:(s,n)=>s.depthMask(n),depthRange:(s,n)=>s.depthRange(...n),dither:(s,n)=>n?s.enable(3024):s.disable(3024),derivativeHint:(s,n)=>{s.hint(35723,n)},frontFace:(s,n)=>s.frontFace(n),mipmapHint:(s,n)=>s.hint(33170,n),lineWidth:(s,n)=>s.lineWidth(n),polygonOffsetFill:(s,n)=>n?s.enable(32823):s.disable(32823),polygonOffset:(s,n)=>s.polygonOffset(...n),sampleCoverage:(s,n)=>s.sampleCoverage(n[0],n[1]||!1),scissorTest:(s,n)=>n?s.enable(3089):s.disable(3089),scissor:(s,n)=>s.scissor(...n),stencilTest:(s,n)=>n?s.enable(2960):s.disable(2960),stencilMask:(s,n)=>{n=iRe(n)?n:[n,n];let[r,c]=n;s.stencilMaskSeparate(1028,r),s.stencilMaskSeparate(1029,c)},stencilFunc:(s,n)=>{n=iRe(n)&&n.length===3?[...n,...n]:n;let[r,c,u,d,b,w]=n;s.stencilFuncSeparate(1028,r,c,u),s.stencilFuncSeparate(1029,d,b,w)},stencilOp:(s,n)=>{n=iRe(n)&&n.length===3?[...n,...n]:n;let[r,c,u,d,b,w]=n;s.stencilOpSeparate(1028,r,c,u),s.stencilOpSeparate(1029,d,b,w)},viewport:(s,n)=>s.viewport(...n)};N1t={blendEquation:(s,n,r)=>s.blendEquationSeparate(Ru(32777,n,r),Ru(34877,n,r)),blendFunc:(s,n,r)=>s.blendFuncSeparate(Ru(32969,n,r),Ru(32968,n,r),Ru(32971,n,r),Ru(32970,n,r)),polygonOffset:(s,n,r)=>s.polygonOffset(Ru(32824,n,r),Ru(10752,n,r)),sampleCoverage:(s,n,r)=>s.sampleCoverage(Ru(32938,n,r),Ru(32939,n,r)),stencilFuncFront:(s,n,r)=>s.stencilFuncSeparate(1028,Ru(2962,n,r),Ru(2967,n,r),Ru(2963,n,r)),stencilFuncBack:(s,n,r)=>s.stencilFuncSeparate(1029,Ru(34816,n,r),Ru(36003,n,r),Ru(36004,n,r)),stencilOpFront:(s,n,r)=>s.stencilOpSeparate(1028,Ru(2964,n,r),Ru(2965,n,r),Ru(2966,n,r)),stencilOpBack:(s,n,r)=>s.stencilOpSeparate(1029,Ru(34817,n,r),Ru(34818,n,r),Ru(34819,n,r))},rRe={enable:(s,n)=>s({[n]:!0}),disable:(s,n)=>s({[n]:!1}),pixelStorei:(s,n,r)=>s({[n]:r}),hint:(s,n,r)=>s({[n]:r}),useProgram:(s,n)=>s({35725:n}),bindRenderbuffer:(s,n,r)=>s({36007:r}),bindTransformFeedback:(s,n,r)=>s({36389:r}),bindVertexArray:(s,n)=>s({34229:n}),bindFramebuffer:(s,n,r)=>{switch(n){case 36160:return s({36006:r,36010:r});case 36009:return s({36006:r});case 36008:return s({36010:r});default:return null}},bindBuffer:(s,n,r)=>{let c={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[n];return c?s({[c]:r}):{valueChanged:!0}},blendColor:(s,n,r,c,u)=>s({32773:new Float32Array([n,r,c,u])}),blendEquation:(s,n)=>s({32777:n,34877:n}),blendEquationSeparate:(s,n,r)=>s({32777:n,34877:r}),blendFunc:(s,n,r)=>s({32969:n,32968:r,32971:n,32970:r}),blendFuncSeparate:(s,n,r,c,u)=>s({32969:n,32968:r,32971:c,32970:u}),clearColor:(s,n,r,c,u)=>s({3106:new Float32Array([n,r,c,u])}),clearDepth:(s,n)=>s({2931:n}),clearStencil:(s,n)=>s({2961:n}),colorMask:(s,n,r,c,u)=>s({3107:[n,r,c,u]}),cullFace:(s,n)=>s({2885:n}),depthFunc:(s,n)=>s({2932:n}),depthRange:(s,n,r)=>s({2928:new Float32Array([n,r])}),depthMask:(s,n)=>s({2930:n}),frontFace:(s,n)=>s({2886:n}),lineWidth:(s,n)=>s({2849:n}),polygonOffset:(s,n,r)=>s({32824:n,10752:r}),sampleCoverage:(s,n,r)=>s({32938:n,32939:r}),scissor:(s,n,r,c,u)=>s({3088:new Int32Array([n,r,c,u])}),stencilMask:(s,n)=>s({2968:n,36005:n}),stencilMaskSeparate:(s,n,r)=>s({[n===1028?2968:36005]:r}),stencilFunc:(s,n,r,c)=>s({2962:n,2967:r,2963:c,34816:n,36003:r,36004:c}),stencilFuncSeparate:(s,n,r,c,u)=>s({[n===1028?2962:34816]:r,[n===1028?2967:36003]:c,[n===1028?2963:36004]:u}),stencilOp:(s,n,r,c)=>s({2964:n,2965:r,2966:c,34817:n,34818:r,34819:c}),stencilOpSeparate:(s,n,r,c,u)=>s({[n===1028?2964:34817]:r,[n===1028?2965:34818]:c,[n===1028?2966:34819]:u}),viewport:(s,n,r,c,u)=>s({2978:[n,r,c,u]})},r2=(s,n)=>s.isEnabled(n),sRe={3042:r2,2884:r2,2929:r2,3024:r2,32823:r2,32926:r2,32928:r2,3089:r2,2960:r2,35977:r2},F1t=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068])});function gv(s,n){if(utn(n))return;let r={};for(let u in n){let d=Number(u),b=O1t[u];b&&(typeof b=="string"?r[b]=!0:b(s,n[u],d))}let c=s.lumaState?.cache;if(c)for(let u in r){let d=N1t[u];d(s,n,c)}}function Ble(s,n=xV){if(typeof n=="number"){let u=n,d=sRe[u];return d?d(s,u):s.getParameter(u)}let r=Array.isArray(n)?n:Object.keys(n),c={};for(let u of r){let d=sRe[u];c[u]=d?d(s,Number(u)):s.getParameter(Number(u))}return c}function U1t(s){gv(s,xV)}function utn(s){for(let n in s)return!1;return!0}var _B=Ve(()=>{oRe()});function G1t(s,n){if(s===n)return!0;if(z1t(s)&&z1t(n)&&s.length===n.length){for(let r=0;r{});function $1t(s,n){let r=s[n].bind(s);s[n]=function(u){if(u===void 0||F1t.has(u))return r(u);let d=mv.get(s);return u in d.cache||(d.cache[u]=r(u)),d.enable?d.cache[u]:r(u)},Object.defineProperty(s[n],"name",{value:`${n}-from-cache`,configurable:!1})}function ftn(s,n,r){if(!s[n])return;let c=s[n].bind(s);s[n]=function(...d){let b=mv.get(s),{valueChanged:w,oldValue:_}=r(b._updateCache,...d);return w&&c(...d),_},Object.defineProperty(s[n],"name",{value:`${n}-to-cache`,configurable:!1})}function htn(s){let n=s.useProgram.bind(s);s.useProgram=function(c){let u=mv.get(s);u.program!==c&&(n(c),u.program=c)}}var mv,aRe=Ve(()=>{_B();j1t();oRe();mv=class{static get(n){return n.lumaState}gl;program=null;stateStack=[];enable=!0;cache=null;log;initialized=!1;constructor(n,r){this.gl=n,this.log=r?.log||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(n={}){this.stateStack.push({})}pop(){let n=this.stateStack[this.stateStack.length-1];gv(this.gl,n),this.stateStack.pop()}trackState(n,r){if(this.cache=r?.copyState?Ble(n):Object.assign({},xV),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.lumaState=this,htn(n);for(let c in rRe){let u=rRe[c];ftn(n,c,u)}$1t(n,"getParameter"),$1t(n,"isEnabled")}_updateCache(n){let r=!1,c,u=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let d in n){let b=n[d],w=this.cache[d];G1t(b,w)||(r=!0,c=w,u&&!(d in u)&&(u[d]=w),this.cache[d]=b)}return{valueChanged:r,oldValue:c}}}});function EV(s){let n=s.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return n._polyfilled??=!1,n.extensions||={},s.luma=n,n}var cRe=Ve(()=>{});function V1t(s,n,r){let c="",u=_=>{let x=_.statusMessage;x&&(c||=x)};s.addEventListener("webglcontextcreationerror",u,!1);let d=r.failIfMajorPerformanceCaveat!==!0,b={preserveDrawingBuffer:!0,...r,failIfMajorPerformanceCaveat:!0},w=null;try{w||=s.getContext("webgl2",b),!w&&b.failIfMajorPerformanceCaveat&&(c||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.");let _=!1;if(!w&&d&&(b.failIfMajorPerformanceCaveat=!1,w=s.getContext("webgl2",b),_=!0),w||(w=s.getContext("webgl",{}),w&&(w=null,c||="Your browser only supports WebGL1")),!w)throw c||="Your browser does not support WebGL",new Error(`Failed to create WebGL context: ${c}`);let x=EV(w);x.softwareRenderer=_;let{onContextLost:T,onContextRestored:M}=n;return s.addEventListener("webglcontextlost",L=>T(L),!1),s.addEventListener("webglcontextrestored",L=>M(L),!1),w}finally{s.removeEventListener("webglcontextcreationerror",u,!1)}}var W1t=Ve(()=>{cRe()});function bv(s,n,r){return r[n]===void 0&&(r[n]=s.getExtension(n)||null),r[n]}var SV=Ve(()=>{});function H1t(s,n){let r=s.getParameter(7936),c=s.getParameter(7937);bv(s,"WEBGL_debug_renderer_info",n);let u=n.WEBGL_debug_renderer_info,d=s.getParameter(u?u.UNMASKED_VENDOR_WEBGL:7936),b=s.getParameter(u?u.UNMASKED_RENDERER_WEBGL:7937),w=d||r,_=b||c,x=s.getParameter(7938),T=q1t(w,_),M=dtn(w,_),L=ptn(w,_);return{type:"webgl",gpu:T,gpuType:L,gpuBackend:M,vendor:w,renderer:_,version:x,shadingLanguage:"glsl",shadingLanguageVersion:300}}function q1t(s,n){return/NVIDIA/i.exec(s)||/NVIDIA/i.exec(n)?"nvidia":/INTEL/i.exec(s)||/INTEL/i.exec(n)?"intel":/Apple/i.exec(s)||/Apple/i.exec(n)?"apple":/AMD/i.exec(s)||/AMD/i.exec(n)||/ATI/i.exec(s)||/ATI/i.exec(n)?"amd":/SwiftShader/i.exec(s)||/SwiftShader/i.exec(n)?"software":"unknown"}function dtn(s,n){return/Metal/i.exec(s)||/Metal/i.exec(n)?"metal":/ANGLE/i.exec(s)||/ANGLE/i.exec(n)?"opengl":"unknown"}function ptn(s,n){if(/SwiftShader/i.exec(s)||/SwiftShader/i.exec(n))return"cpu";switch(q1t(s,n)){case"apple":return gtn(s,n)?"integrated":"unknown";case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function gtn(s,n){return/Apple (M\d|A\d|GPU)/i.test(`${s} ${n}`)}var X1t=Ve(()=>{SV()});function Ole(s){switch(s){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(s))}var lRe=Ve(()=>{});function K1t(s){return s in Fle}function pRe(s,n,r){return J1t(s,n,r,new Set)}function J1t(s,n,r,c){let u=Fle[n];if(!u||c.has(n))return!1;c.add(n);let d=(u.features||[]).every(b=>J1t(s,b,r,c));return c.delete(n),d?(u.extensions||[]).every(b=>!!bv(s,b,r)):!1}function Q1t(s,n,r){let c=n.create,u=Ule[n.format];u?.gl===void 0&&(c=!1),u?.x&&(c=c&&!!bv(s,u.x,r)),n.format==="stencil8"&&(c=!1);let d=u?.r===!1?!1:u?.r===void 0||pRe(s,u.r,r),b=c&&n.render&&d&&Etn(s,n.format,r);return{format:n.format,create:c&&n.create,render:b,filter:c&&n.filter,blend:c&&n.blend,store:c&&n.store}}function Etn(s,n,r){let c=Ule[n],u=c?.gl;if(u===void 0||c?.x&&!bv(s,c.x,r))return!1;let d=s.getParameter(32873),b=s.getParameter(36006),w=s.createTexture(),_=s.createFramebuffer();if(!w||!_)return!1;let x=0,T=Number(s.getError());for(;T!==x;)T=s.getError();let M=!1;try{if(s.bindTexture(3553,w),s.texStorage2D(3553,1,u,1,1),Number(s.getError())!==x)return!1;s.bindFramebuffer(36160,_),s.framebufferTexture2D(36160,36064,3553,w,0),M=Number(s.checkFramebufferStatus(36160))===36053&&Number(s.getError())===x}finally{s.bindFramebuffer(36160,b),s.deleteFramebuffer(_),s.bindTexture(3553,d),s.deleteTexture(w)}return M}function zle(s){let n=Ule[s],r=Mtn(s),c=sg.getInfo(s);return c.compressed&&(n.dataFormat=r),{internalFormat:r,format:n?.dataFormat||Stn(c.channels,c.integer,c.normalized,r),type:c.dataType?Ole(c.dataType):n?.types?.[0]||5121,compressed:c.compressed||!1}}function e0t(s){switch(sg.getInfo(s).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${s}`)}}function Stn(s,n,r,c){if(c===6408||c===6407)return c;switch(s){case"r":return n&&!r?36244:6403;case"rg":return n&&!r?33320:33319;case"rgb":return n&&!r?36248:6407;case"rgba":return n&&!r?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function Mtn(s){let r=Ule[s]?.gl;if(r===void 0)throw new Error(`Unsupported texture format ${s}`);return r}var MV,TV,yB,xB,mtn,btn,wtn,vtn,_tn,ytn,Y1t,Z1t,uRe,fRe,hRe,dRe,Nle,xtn,Fle,Ule,EB=Ve(()=>{$r();SV();lRe();MV="WEBGL_compressed_texture_s3tc",TV="WEBGL_compressed_texture_s3tc_srgb",yB="EXT_texture_compression_rgtc",xB="EXT_texture_compression_bptc",mtn="WEBGL_compressed_texture_etc",btn="WEBGL_compressed_texture_astc",wtn="WEBGL_compressed_texture_etc1",vtn="WEBGL_compressed_texture_pvrtc",_tn="WEBGL_compressed_texture_atc",ytn="EXT_texture_norm16",Y1t="EXT_render_snorm",Z1t="EXT_color_buffer_float",uRe="snorm8-renderable-webgl",fRe="norm16-renderable-webgl",hRe="snorm16-renderable-webgl",dRe="float16-renderable-webgl",Nle="float32-renderable-webgl",xtn="rgb9e5ufloat-renderable-webgl",Fle={"float32-renderable-webgl":{extensions:[Z1t]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[Y1t]},"norm16-webgl":{extensions:[ytn]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[Y1t]},"float32-filterable":{extensions:["OES_texture_float_linear"]},"float16-filterable-webgl":{extensions:["OES_texture_half_float_linear"]},"texture-filterable-anisotropic-webgl":{extensions:["EXT_texture_filter_anisotropic"]},"texture-blend-float-webgl":{extensions:["EXT_float_blend"]},"texture-compression-bc":{extensions:[MV,TV,yB,xB]},"texture-compression-bc5-webgl":{extensions:[yB]},"texture-compression-bc7-webgl":{extensions:[xB]},"texture-compression-etc2":{extensions:[mtn]},"texture-compression-astc":{extensions:[btn]},"texture-compression-etc1-webgl":{extensions:[wtn]},"texture-compression-pvrtc-webgl":{extensions:[vtn]},"texture-compression-atc-webgl":{extensions:[_tn]}};Ule={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:uRe},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:uRe},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0,r:dRe},r16unorm:{gl:33322,rb:!0,r:fRe},r16snorm:{gl:36760,r:hRe},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759,r:uRe},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:dRe},rg16unorm:{gl:33324,r:fRe},rg16snorm:{gl:36761,r:hRe},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:Nle},rgb9e5ufloat:{gl:35901,r:xtn},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852,r:!1},"rgb16snorm-webgl":{gl:36762,r:!1},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0,r:Nle},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:dRe},rgba16unorm:{gl:32859,rb:!0,r:fRe},rgba16snorm:{gl:36763,r:hRe},"rgb32float-webgl":{gl:34837,x:Z1t,r:Nle,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:Nle},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:MV},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:TV},"bc1-rgba-unorm":{gl:33777,x:MV},"bc1-rgba-unorm-srgb":{gl:35916,x:TV},"bc2-rgba-unorm":{gl:33778,x:MV},"bc2-rgba-unorm-srgb":{gl:35918,x:TV},"bc3-rgba-unorm":{gl:33779,x:MV},"bc3-rgba-unorm-srgb":{gl:35919,x:TV},"bc4-r-unorm":{gl:36283,x:yB},"bc4-r-snorm":{gl:36284,x:yB},"bc5-rg-unorm":{gl:36285,x:yB},"bc5-rg-snorm":{gl:36286,x:yB},"bc6h-rgb-ufloat":{gl:36495,x:xB},"bc6h-rgb-float":{gl:36494,x:xB},"bc7-rgba-unorm":{gl:36492,x:xB},"bc7-rgba-unorm-srgb":{gl:36493,x:xB},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37816},"astc-10x5-unorm-srgb":{gl:37848},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rgb2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}}});var t0t,Gle,n0t=Ve(()=>{$r();SV();EB();t0t={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","html-in-canvas":s=>GLe()&&typeof s.texElementImage2D=="function","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},Gle=class extends p${gl;extensions;testedFeatures=new Set;constructor(n,r,c){super([],c),this.gl=n,this.extensions=r,bv(n,"EXT_color_buffer_float",r)}*[Symbol.iterator](){let n=this.getFeatures();for(let r of n)this.has(r)&&(yield r);return[]}has(n){return this.disabledFeatures?.[n]?!1:(this.testedFeatures.has(n)||(this.testedFeatures.add(n),K1t(n)&&pRe(this.gl,n,this.extensions)&&this.features.add(n),this.getWebGLFeature(n)&&this.features.add(n)),this.features.has(n))}initializeFeatures(){let n=this.getFeatures().filter(r=>r!=="polygon-mode-webgl");for(let r of n)this.has(r)}getFeatures(){return[...Object.keys(t0t),...Object.keys(Fle)]}getWebGLFeature(n){let r=t0t[n];return typeof r=="string"?!!bv(this.gl,r,this.extensions):typeof r=="function"?r(this.gl):!!r}}});var jle,i0t=Ve(()=>{$r();jle=class extends d${get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxBindGroupsPlusVertexBuffers(){return 0}get maxBindingsPerBindGroup(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageBuffersInVertexStage(){return 0}get maxStorageBuffersInFragmentStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxStorageTexturesInVertexStage(){return 0}get maxStorageTexturesInFragmentStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get maxBufferSize(){return Number.MAX_SAFE_INTEGER}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxColorAttachments(){return this.getParameter(36063)}get maxColorAttachmentBytesPerSample(){return 0}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(n){super(),this.gl=n}getParameter(n){return this.limits[n]===void 0&&(this.limits[n]=this.gl.getParameter(n)),this.limits[n]||0}}});function Ttn(s){return s<34069?s+34069:s}function Ctn(s){switch(s){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${s}`}}var s2,$le=Ve(()=>{$r();EB();s2=class extends n4{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(n,r){super(n,r);let c=r.handle,u=c===null;this.device=n,this.gl=n.gl,this.handle=c||u?c:this.gl.createFramebuffer(),u||(n._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),r.handle||(this.autoCreateAttachmentTextures(),this.updateAttachments()))}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&!this.props.handle&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){let n=this.gl.bindFramebuffer(36160,this.handle);for(let r=0;r{$r();$le();Vle=class extends g${device;handle=null;_framebuffer=null;get[Symbol.toStringTag](){return"WebGLCanvasContext"}constructor(n,r){super(r),this.device=n,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._configureDevice()}_configureDevice(){(this.drawingBufferWidth!==this._framebuffer?.width||this.drawingBufferHeight!==this._framebuffer?.height)&&this._framebuffer?.resize([this.drawingBufferWidth,this.drawingBufferHeight])}_getCurrentFramebuffer(){return this._framebuffer||=new s2(this.device,{id:"canvas-context-framebuffer",handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}}});var Wle,s0t=Ve(()=>{$r();Wle=class extends m${device;handle=null;context2d;get[Symbol.toStringTag](){return"WebGLPresentationContext"}constructor(n,r={}){super(r),this.device=n;let c=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw new Error(`${c}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);let d=this.canvas.getContext("2d");if(!d)throw new Error(`${c}: Failed to create 2d presentation context`);this.context2d=d,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();let n=this.device.getDefaultCanvasContext(),[r,c]=n.getDrawingBufferSize();if(!(this.drawingBufferWidth===0||this.drawingBufferHeight===0||r===0||c===0||n.canvas.width===0||n.canvas.height===0)){if(r!==this.drawingBufferWidth||c!==this.drawingBufferHeight||n.canvas.width!==this.drawingBufferWidth||n.canvas.height!==this.drawingBufferHeight)throw new Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${r}x${c} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(n.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(n){let r=this.device.getDefaultCanvasContext();return r.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),r.getCurrentFramebuffer(n)}}});function o0t(s="id"){gRe[s]=gRe[s]||1;let n=gRe[s]++;return`${s}-${n}`}var gRe,a0t=Ve(()=>{gRe={}});function Atn(s){return s&as.INDEX?34963:s&as.VERTEX?34962:s&as.UNIFORM?35345:34962}function Ptn(s){return s&as.INDEX||s&as.VERTEX?35044:s&as.UNIFORM?35048:35044}var wv,Hle=Ve(()=>{$r();wv=class extends as{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength=0;bytesUsed=0;constructor(n,r={}){super(n,r),this.device=n,this.gl=this.device.gl;let c=typeof r=="object"?r.handle:void 0;this.handle=c||this.gl.createBuffer(),n._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=Atn(this.props.usage),this.glUsage=Ptn(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,r.data?this._initWithData(r.data,r.byteOffset,r.byteLength):this._initWithByteLength(r.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Buffer"):(this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle)),this.destroyed=!0,this.handle=null)}_initWithData(n,r=0,c=n.byteLength+r){let u=this.glTarget;this.gl.bindBuffer(u,this.handle),this.gl.bufferData(u,c,this.glUsage),this.gl.bufferSubData(u,r,n),this.gl.bindBuffer(u,null),this.bytesUsed=c,this.byteLength=c,this._setDebugData(n,r,c),this.props.handle?this.trackReferencedMemory(c,"Buffer"):this.trackAllocatedMemory(c)}_initWithByteLength(n){let r=n;n===0&&(r=new Float32Array(0));let c=this.glTarget;return this.gl.bindBuffer(c,this.handle),this.gl.bufferData(c,r,this.glUsage),this.gl.bindBuffer(c,null),this.bytesUsed=n,this.byteLength=n,this._setDebugData(null,0,n),this.props.handle?this.trackReferencedMemory(n,"Buffer"):this.trackAllocatedMemory(n),this}write(n,r=0){let c=ArrayBuffer.isView(n)?n:new Uint8Array(n),u=0,d=void 0,b=36663;this.gl.bindBuffer(b,this.handle),u!==0||d!==void 0?this.gl.bufferSubData(b,r,c,u,d):this.gl.bufferSubData(b,r,c),this.gl.bindBuffer(b,null),this._setDebugData(n,r,n.byteLength)}async mapAndWriteAsync(n,r=0,c=this.byteLength-r){let u=new ArrayBuffer(c);await n(u,"copied"),this.write(u,r)}async readAsync(n=0,r){return this.readSyncWebGL(n,r)}async mapAndReadAsync(n,r=0,c){let u=await this.readAsync(r,c);return await n(u.buffer,"copied")}readSyncWebGL(n=0,r){r=r??this.byteLength-n;let c=new Uint8Array(r),u=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,n,c,u,r),this.gl.bindBuffer(36662,null),this._setDebugData(c,n,r),c}}});function c0t(s){let n=s.split(/\r?\n/),r=[];for(let c of n){if(c.length<=1)continue;let u=c.trim(),d=c.split(":"),b=d[0]?.trim();if(d.length===2){let[I,D]=d;if(!I||!D){r.push({message:u,type:qle(b||"info"),lineNum:0,linePos:0});continue}r.push({message:D.trim(),type:qle(I),lineNum:0,linePos:0});continue}let[w,_,x,...T]=d;if(!w||!_||!x){r.push({message:d.slice(1).join(":").trim()||u,type:qle(b||"info"),lineNum:0,linePos:0});continue}let M=parseInt(x,10);Number.isNaN(M)&&(M=0);let L=parseInt(_,10);Number.isNaN(L)&&(L=0),r.push({message:T.join(":").trim(),type:qle(w),lineNum:M,linePos:L})}return r}function qle(s){let n=["warning","error","info"],r=s.toLowerCase();return n.includes(r)?r:"info"}var l0t=Ve(()=>{});function Ltn(s){return s.split(/\r?\n/).find(n=>n.trim())?.trim()}var Xle,u0t=Ve(()=>{$r();l0t();Xle=class extends t4{device;handle;_compilationInfoLog="";constructor(n,r){super(n,r),this.device=n;let c=this.props.handle;switch(this.props.stage){case"vertex":this.handle=c||this.device.gl.createShader(35633);break;case"fragment":this.handle=c||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}n._setWebGLDebugMetadata(this.handle,this,{spector:this.props});let u=this._compile(this.source);u&&typeof u.catch=="function"&&u.catch(()=>{this.compilationStatus="error"})}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let n=this._getCompilationInfoLog();return n?c0t(n):[]}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)||null}_compile(n){n=n.startsWith("#version ")?n:`#version 300 es +${n}`;let{gl:r}=this.device;if(r.shaderSource(this.handle,n),r.compileShader(this.handle),!this.device.props.debug){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus==="error")throw new Error(this._getCompilationErrorMessage(n));return}return Qt.once(1,"Shader compilation is asynchronous")(),this._waitForCompilationComplete().then(()=>{Qt.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()})}async _waitForCompilationComplete(){let n=async u=>await new Promise(d=>setTimeout(d,u));if(!this.device.features.has("compilation-status-async-webgl")){await n(10);return}let{gl:c}=this.device;for(;;){if(c.getShaderParameter(this.handle,37297))return;await n(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error",this.compilationStatus==="error"&&this._getCompilationInfoLog()}_getCompilationErrorMessage(n){let r=`${this.props.stage} shader ${this.props.id}`,c=Ltn(this._getCompilationInfoLog()),u=this.getCompilationInfoSync(),d=u.find(T=>T.type==="error"&&T.message.trim())||u.find(T=>T.message.trim())||u.find(T=>T.type==="error")||u[0];if(!d)return c?`GLSL compilation errors in ${r}: ${c}`:`GLSL compilation errors in ${r}: WebGL did not provide a shader compiler log`;let b=d.lineNum?n.split(/\r?\n/)[d.lineNum-1]?.trim():void 0,w=d.lineNum?` line ${d.lineNum}`:"",_=b?` +Source: ${b}`:"",x=d.message.trim()||c||"WebGL did not provide a shader compiler log";return`GLSL compilation errors in ${r}:${w}: ${x}${_}`}_getCompilationInfoLog(){let n=this.device.gl.getShaderInfoLog(this.handle)?.trim();return n&&(this._compilationInfoLog=n),this._compilationInfoLog}}});function h0t(s,n,r,c){if(Dtn(n))return c(s);let u=s;u.pushState();try{return ktn(s,n),gv(u.gl,r),c(s)}finally{u.popState()}}function ktn(s,n){let r=s,{gl:c}=r;if(n.cullMode)switch(n.cullMode){case"none":c.disable(2884);break;case"front":c.enable(2884),c.cullFace(1028);break;case"back":c.enable(2884),c.cullFace(1029);break}if(n.frontFace&&c.frontFace(P4("frontFace",n.frontFace,{ccw:2305,cw:2304})),n.unclippedDepth&&s.features.has("depth-clip-control")&&c.enable(34383),n.depthBias!==void 0&&(c.enable(32823),c.polygonOffset(n.depthBias,n.depthBiasSlopeScale||0)),n.provokingVertex&&s.features.has("provoking-vertex-webgl")){let d=r.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,b=P4("provokingVertex",n.provokingVertex,{first:36429,last:36430});d?.provokingVertexWEBGL(b)}if((n.polygonMode||n.polygonOffsetLine)&&s.features.has("polygon-mode-webgl")){if(n.polygonMode){let d=r.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,b=P4("polygonMode",n.polygonMode,{fill:6914,line:6913});d?.polygonModeWEBGL(1028,b),d?.polygonModeWEBGL(1029,b)}n.polygonOffsetLine&&c.enable(10754)}if(s.features.has("shader-clip-cull-distance-webgl")&&(n.clipDistance0&&c.enable(12288),n.clipDistance1&&c.enable(12289),n.clipDistance2&&c.enable(12290),n.clipDistance3&&c.enable(12291),n.clipDistance4&&c.enable(12292),n.clipDistance5&&c.enable(12293),n.clipDistance6&&c.enable(12294),n.clipDistance7&&c.enable(12295)),n.depthWriteEnabled!==void 0&&c.depthMask(Itn("depthWriteEnabled",n.depthWriteEnabled)),n.depthCompare&&(n.depthCompare!=="always"?c.enable(2929):c.disable(2929),c.depthFunc(Zle("depthCompare",n.depthCompare))),n.clearDepth!==void 0&&c.clearDepth(n.clearDepth),n.stencilWriteMask){let u=n.stencilWriteMask;c.stencilMaskSeparate(1028,u),c.stencilMaskSeparate(1029,u)}if(n.stencilReadMask&&Qt.warn("stencilReadMask not supported under WebGL"),n.stencilCompare){let u=n.stencilReadMask||4294967295,d=Zle("depthCompare",n.stencilCompare);n.stencilCompare!=="always"?c.enable(2960):c.disable(2960),c.stencilFuncSeparate(1028,d,0,u),c.stencilFuncSeparate(1029,d,0,u)}if(n.stencilPassOperation&&n.stencilFailOperation&&n.stencilDepthFailOperation){let u=mRe("stencilPassOperation",n.stencilPassOperation),d=mRe("stencilFailOperation",n.stencilFailOperation),b=mRe("stencilDepthFailOperation",n.stencilDepthFailOperation);c.stencilOpSeparate(1028,d,b,u),c.stencilOpSeparate(1029,d,b,u)}switch(n.blend){case!0:c.enable(3042);break;case!1:c.disable(3042);break;default:}if(n.blendColorOperation||n.blendAlphaOperation){let u=f0t("blendColorOperation",n.blendColorOperation||"add"),d=f0t("blendAlphaOperation",n.blendAlphaOperation||"add");c.blendEquationSeparate(u,d);let b=Yle("blendColorSrcFactor",n.blendColorSrcFactor||"one"),w=Yle("blendColorDstFactor",n.blendColorDstFactor||"zero"),_=Yle("blendAlphaSrcFactor",n.blendAlphaSrcFactor||"one"),x=Yle("blendAlphaDstFactor",n.blendAlphaDstFactor||"zero");c.blendFuncSeparate(b,w,_,x)}}function Zle(s,n){return P4(s,n,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function mRe(s,n){return P4(s,n,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function f0t(s,n){return P4(s,n,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function Yle(s,n,r="color"){return P4(s,n,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:r==="color"?32769:32771,"one-minus-constant":r==="color"?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function Rtn(s,n){return`Illegal parameter ${n} for ${s}`}function P4(s,n,r){if(!(n in r))throw new Error(Rtn(s,n));return r[n]}function Itn(s,n){return n}function Dtn(s){let n=!0;for(let r in s){n=!1;break}return n}var bRe=Ve(()=>{$r();_B()});function Kle(s){let n={};return s.addressModeU&&(n[10242]=wRe(s.addressModeU)),s.addressModeV&&(n[10243]=wRe(s.addressModeV)),s.addressModeW&&(n[32882]=wRe(s.addressModeW)),s.magFilter&&(n[10240]=vRe(s.magFilter)),(s.minFilter||s.mipmapFilter)&&(n[10241]=Btn(s.minFilter||"linear",s.mipmapFilter)),s.lodMinClamp!==void 0&&(n[33082]=s.lodMinClamp),s.lodMaxClamp!==void 0&&(n[33083]=s.lodMaxClamp),s.type==="comparison-sampler"&&(n[34892]=34894),s.compare&&(n[34893]=Zle("compare",s.compare)),s.maxAnisotropy&&(n[34046]=s.maxAnisotropy),n}function wRe(s){switch(s){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function vRe(s){switch(s){case"nearest":return 9728;case"linear":return 9729}}function Btn(s,n="none"){if(!n)return vRe(s);switch(n){case"none":return vRe(s);case"nearest":switch(s){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(s){case"nearest":return 9986;case"linear":return 9987}}}var _Re=Ve(()=>{bRe()});var Jle,d0t=Ve(()=>{$r();_Re();Jle=class extends QL{device;handle;parameters;constructor(n,r){super(n,r),this.device=n,this.parameters=Kle(r),this.handle=r.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(n){for(let[r,c]of Object.entries(n)){let u=Number(r);switch(u){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,u,c);break;default:this.device.gl.samplerParameteri(this.handle,u,c);break}}}}});function vv(s,n,r){if(Otn(n))return r(s);let{nocatch:c=!0}=n,u=mv.get(s);u.push(),gv(s,n);let d;if(c)d=r(s),u.pop();else try{d=r(s)}finally{u.pop()}return d}function Otn(s){for(let n in s)return!1;return!0}var Qle=Ve(()=>{_B();aRe()});var o2,yRe=Ve(()=>{$r();o2=class extends e4{device;gl;handle;texture;constructor(n,r){super(n,{...Aa.defaultProps,...r}),this.device=n,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}}});function eue(s){return Ntn[s]}var Ntn,xRe=Ve(()=>{Ntn={5124:"sint32",5125:"uint32",5122:"sint16",5123:"uint16",5120:"sint8",5121:"uint8",5126:"float32",5131:"float16",33635:"uint16",32819:"uint16",32820:"uint16",33640:"uint32",35899:"uint32",35902:"uint32",34042:"uint32",36269:"uint32"}});function Ftn(s,n=0){return n?new s.constructor(s.buffer,s.byteOffset+n,(s.byteLength-n)/s.BYTES_PER_ELEMENT):s}function Utn(s,n){if(n%s.BYTES_PER_ELEMENT!==0)throw new Error(`Texture byteOffset ${n} must align to typed array element size ${s.BYTES_PER_ELEMENT}`);return n/s.BYTES_PER_ELEMENT}function ztn(s){switch(s){case"1d":break;case"2d":return 3553;case"3d":return 32879;case"cube":return 34067;case"2d-array":return 35866;case"cube-array":break}throw new Error(s)}function CV(s,n,r){return n==="cube"?34069+r:s}var a2,tue=Ve(()=>{$r();EB();_Re();Qle();yRe();xRe();a2=class extends Aa{device;gl;handle;sampler=void 0;view;glTarget;glFormat;glType;glInternalFormat;compressed;_textureUnit=0;_framebuffer=null;_framebufferAttachmentKey=null;constructor(n,r){super(n,r,{byteAlignment:1}),this.device=n,this.gl=this.device.gl;let c=zle(this.props.format);if(this.glTarget=ztn(this.props.dimension),this.glInternalFormat=c.internalFormat,this.glFormat=c.format,this.glType=c.type,this.compressed=c.compressed,this.isHandleBorrowed&&this.props.handle===void 0)throw new Error("Borrowed WebGL textures require a texture handle");if(this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),!this.isHandleBorrowed){this.gl.bindTexture(this.glTarget,this.handle);let{dimension:u,width:d,height:b,depth:w,mipLevels:_,glTarget:x,glInternalFormat:T}=this;if(!this.compressed)switch(u){case"2d":case"cube":this.gl.texStorage2D(x,_,T,d,b);break;case"2d-array":case"3d":this.gl.texStorage3D(x,_,T,d,b,w);break;default:throw new Error(u)}this.gl.bindTexture(this.glTarget,null),this._initializeData(r.data)}this.ownsHandle?this.trackAllocatedMemory(this.getAllocatedByteLength(),"Texture"):this.trackReferencedMemory(this.getAllocatedByteLength(),"Texture"),this.isHandleBorrowed||this.setSampler(this.props.sampler),this.view=new o2(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this._framebuffer?.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.ownsHandle?(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory("Texture")):this.trackDeallocatedReferencedMemory("Texture"),this.destroyed=!0)}createView(n){return new o2(this.device,{...n,texture:this})}clone(n){if(this.isHandleBorrowed&&n&&(n.width!==this.width||n.height!==this.height))throw new Error(`Cannot resize borrowed read-only ${this}`);return super.clone(n)}setSampler(n={}){this._assertWritable("set sampler parameters on"),super.setSampler(n);let r=Kle(this.sampler.props);this._setSamplerParameters(r)}copyExternalImage(n){this._assertWritable("copy external image data into");let r=this._normalizeCopyExternalImageOptions(n);if(r.sourceX||r.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");let{glFormat:c,glType:u}=this,{image:d,depth:b,mipLevel:w,x:_,y:x,z:T,width:M,height:L}=r,I=CV(this.glTarget,this.dimension,T),D=r.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),vv(this.gl,D,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(I,w,_,x,M,L,c,u,d);break;case"2d-array":case"3d":this.gl.texSubImage3D(I,w,_,x,T,M,L,b,c,u,d);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:r.width,height:r.height}}copyElementImage(n){this._assertWritable("copy element image data into");let r=this._normalizeCopyElementImageOptions(n),{glFormat:c}=this,{element:u,depth:d,mipLevel:b,sourceX:w,sourceY:_,sourceWidth:x,sourceHeight:T,x:M,y:L,z:I,width:D,height:F}=r,O=CV(this.glTarget,this.dimension,I),z=r.flipY?{37440:!0}:{},Z=this.gl;if(d!==1||this.dimension!=="2d"&&this.dimension!=="cube")throw new Error(`${this} copyElementImage only supports 2d and cube textures on WebGL`);if(b!==0||M!==0||L!==0)throw new Error(`${this} copyElementImage only supports full base-level uploads on WebGL`);if(typeof Z.texElementImage2D!="function")throw new Error(`${this} copyElementImage is not supported by this WebGL implementation`);return this.gl.bindTexture(this.glTarget,this.handle),vv(this.gl,z,()=>{Z.texElementImage2D?.(O,c,u,{sx:w,sy:_,swidth:x??D,sheight:T??F,width:D,height:F})}),this.gl.bindTexture(this.glTarget,null),{width:r.width,height:r.height}}copyImageData(n){super.copyImageData(n)}readBuffer(n={},r){if(!r)throw new Error(`${this} readBuffer requires a destination buffer`);let c=this._getSupportedColorReadOptions(n),u=n.byteOffset??0,d=this.computeMemoryLayout(c);if(r.byteLength{this.gl.readPixels(c.x,c.y,c.width,c.height,this.glFormat,this.glType,u+w)})}finally{this.gl.bindBuffer(35051,null)}return r}async readDataAsync(n={}){throw new Error(`${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`)}writeBuffer(n,r={}){this._assertWritable("write buffer data into");let c=this._normalizeTextureWriteOptions(r),{width:u,height:d,depthOrArrayLayers:b,mipLevel:w,byteOffset:_,x,y:T,z:M}=c,{glFormat:L,glType:I,compressed:D}=this,F=CV(this.glTarget,this.dimension,M);if(D)throw new Error("writeBuffer for compressed textures is not implemented in WebGL");let{bytesPerPixel:O}=this.device.getTextureFormatInfo(this.format),z=O?c.bytesPerRow/O:void 0,Z={3317:this.byteAlignment,...z!==void 0?{3314:z}:{},32878:c.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,n.handle),vv(this.gl,Z,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(F,w,x,T,u,d,L,I,_);break;case"2d-array":case"3d":this.gl.texSubImage3D(F,w,x,T,M,u,d,b,L,I,_);break;default:}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(n,r={}){this._assertWritable("write data into");let c=this._normalizeTextureWriteOptions(r),u=ArrayBuffer.isView(n)?n:new Uint8Array(n),{width:d,height:b,depthOrArrayLayers:w,mipLevel:_,x,y:T,z:M,byteOffset:L}=c,{glFormat:I,glType:D,compressed:F}=this,O=CV(this.glTarget,this.dimension,M),z;if(!F){let{bytesPerPixel:ue}=this.device.getTextureFormatInfo(this.format);ue&&(z=c.bytesPerRow/ue)}let Z=this.compressed?{}:{3317:this.byteAlignment,...z!==void 0?{3314:z}:{},32878:c.rowsPerImage},H=Utn(u,L),te=F?Ftn(u,L):u,se=this._getMipLevelSize(_),ne=x===0&&T===0&&M===0&&d===se.width&&b===se.height&&w===se.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),vv(this.gl,Z,()=>{switch(this.dimension){case"2d":case"cube":F?ne?this.gl.compressedTexImage2D(O,_,I,d,b,0,te):this.gl.compressedTexSubImage2D(O,_,x,T,d,b,I,te):this.gl.texSubImage2D(O,_,x,T,d,b,I,D,u,H);break;case"2d-array":case"3d":F?ne?this.gl.compressedTexImage3D(O,_,I,d,b,w,0,te):this.gl.compressedTexSubImage3D(O,_,x,T,M,d,b,w,I,te):this.gl.texSubImage3D(O,_,x,T,M,d,b,w,I,D,u,H);break;default:}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(n,r){return 1}_getFramebuffer(){return this._framebuffer||=this.device.createFramebuffer({id:`framebuffer-for-${this.id}`,width:this.width,height:this.height,colorAttachments:[this]}),this._framebuffer}readDataSyncWebGL(n={}){let r=this._getSupportedColorReadOptions(n),c=this.computeMemoryLayout(r),u=eue(this.glType),d=JL(u),b=new d(c.byteLength/d.BYTES_PER_ELEMENT);return this._readColorTextureLayers(r,c,w=>{let _=new d(b.buffer,b.byteOffset+w,c.bytesPerImage/d.BYTES_PER_ELEMENT);this.gl.readPixels(r.x,r.y,r.width,r.height,this.glFormat,this.glType,_)}),b.buffer}_readColorTextureLayers(n,r,c){let u=this._getFramebuffer(),d=r.bytesPerRow/r.bytesPerPixel,b={3333:this.byteAlignment,...d!==n.width?{3330:d}:{}},w=this.gl.getParameter(3074),_=this.gl.bindFramebuffer(36160,u.handle);try{this.gl.readBuffer(36064),vv(this.gl,b,()=>{for(let x=0;x=2&&Qt.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(n))(),this.gl.bindTexture(this.glTarget,this.handle);for(let[r,c]of Object.entries(n)){let u=Number(r),d=c;switch(u){case 33082:case 33083:this.gl.texParameterf(this.glTarget,u,d);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,u,d);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,u,d);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,u,d);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,u,d);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(n){let{gl:r}=this;return n!==void 0&&(this._textureUnit=n,r.activeTexture(33984+n)),r.bindTexture(this.glTarget,this.handle),n}_unbind(n){let{gl:r}=this;return n!==void 0&&(this._textureUnit=n,r.activeTexture(33984+n)),r.bindTexture(this.glTarget,null),n}_assertWritable(n){if(this.isHandleBorrowed)throw new Error(`Cannot ${n} borrowed read-only ${this}`)}}});function p0t(s,n,r,c){let u=s,d=c;d===!0&&(d=1),d===!1&&(d=0);let b=typeof d=="number"?[d]:d;switch(r){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof c!="number")throw new Error("samplers must be set to integers");return s.uniform1i(n,c);case 5126:return s.uniform1fv(n,b);case 35664:return s.uniform2fv(n,b);case 35665:return s.uniform3fv(n,b);case 35666:return s.uniform4fv(n,b);case 5124:return s.uniform1iv(n,b);case 35667:return s.uniform2iv(n,b);case 35668:return s.uniform3iv(n,b);case 35669:return s.uniform4iv(n,b);case 35670:return s.uniform1iv(n,b);case 35671:return s.uniform2iv(n,b);case 35672:return s.uniform3iv(n,b);case 35673:return s.uniform4iv(n,b);case 5125:return u.uniform1uiv(n,b,1);case 36294:return u.uniform2uiv(n,b,2);case 36295:return u.uniform3uiv(n,b,3);case 36296:return u.uniform4uiv(n,b,4);case 35674:return s.uniformMatrix2fv(n,!1,b);case 35675:return s.uniformMatrix3fv(n,!1,b);case 35676:return s.uniformMatrix4fv(n,!1,b);case 35685:return u.uniformMatrix2x3fv(n,!1,b);case 35686:return u.uniformMatrix2x4fv(n,!1,b);case 35687:return u.uniformMatrix3x2fv(n,!1,b);case 35688:return u.uniformMatrix3x4fv(n,!1,b);case 35689:return u.uniformMatrix4x2fv(n,!1,b);case 35690:return u.uniformMatrix4x3fv(n,!1,b)}throw new Error("Illegal uniform")}var g0t=Ve(()=>{});function m0t(s){return jtn[s]}function nue(s){return Gtn[s]}function iue(s){return!!w0t[s]}function b0t(s){return w0t[s]}var Gtn,w0t,jtn,rue=Ve(()=>{Gtn={5126:"f32",35664:"vec2",35665:"vec3",35666:"vec4",5124:"i32",35667:"vec2",35668:"vec3",35669:"vec4",5125:"u32",36294:"vec2",36295:"vec3",36296:"vec4",35670:"f32",35671:"vec2",35672:"vec3",35673:"vec4",35674:"mat2x2",35685:"mat2x3",35686:"mat2x4",35687:"mat3x2",35675:"mat3x3",35688:"mat3x4",35689:"mat4x2",35690:"mat4x3",35676:"mat4x4"},w0t={35678:{viewDimension:"2d",sampleType:"float"},35680:{viewDimension:"cube",sampleType:"float"},35679:{viewDimension:"3d",sampleType:"float"},35682:{viewDimension:"3d",sampleType:"depth"},36289:{viewDimension:"2d-array",sampleType:"float"},36292:{viewDimension:"2d-array",sampleType:"depth"},36293:{viewDimension:"cube",sampleType:"float"},36298:{viewDimension:"2d",sampleType:"sint"},36299:{viewDimension:"3d",sampleType:"sint"},36300:{viewDimension:"cube",sampleType:"sint"},36303:{viewDimension:"2d-array",sampleType:"uint"},36306:{viewDimension:"2d",sampleType:"uint"},36307:{viewDimension:"3d",sampleType:"uint"},36308:{viewDimension:"cube",sampleType:"uint"},36311:{viewDimension:"2d-array",sampleType:"uint"}},jtn={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126}});function _0t(s,n,r={}){let c={attributes:[],bindings:[]};c.attributes=$tn(s,n);let u=Htn(s,n,r);for(let _ of u){let x=_.uniforms.map(T=>({name:T.name,format:T.format,byteOffset:T.byteOffset,byteStride:T.byteStride,arrayLength:T.arrayLength}));c.bindings.push({type:"uniform",name:_.name,group:0,location:_.location,visibility:(_.vertex?1:0)|(_.fragment?2:0),minBindingSize:_.byteLength,uniforms:x})}let d=Wtn(s,n),b=0;for(let _ of d)if(iue(_.type)){let{viewDimension:x,sampleType:T}=b0t(_.type);c.bindings.push({type:"texture",name:_.name,group:0,location:b,viewDimension:x,sampleType:T}),_.textureUnit=b,b+=1}d.length&&(c.uniforms=d);let w=Vtn(s,n);return w?.length&&(c.varyings=w),c}function $tn(s,n){let r=[],c=s.getProgramParameter(n,35721);for(let u=0;u=0){let x=nue(w),T=/instance/i.test(b)?"instance":"vertex";r.push({name:b,location:_,stepMode:T,type:x})}}return r.sort((u,d)=>u.location-d.location),r}function Vtn(s,n){let r=[],c=s.getProgramParameter(n,35971);for(let u=0;uu.location-d.location),r}function Wtn(s,n){let r=[],c=s.getProgramParameter(n,35718);for(let u=0;u1)for(let I=0;Ib.location-w.location),c}function qtn(s,n){for(let r of s.uniforms){let c=n.uniforms.find(u=>r.name===u.name||r.name.endsWith(`.${u.name}`));if(!c)throw new Error(`Failed to validate WebGL uniform block "${n.name}": reflected unexpected member "${r.name}"`);if(r.format!==c.format||r.arrayLength!==c.arrayLength||r.byteOffset!==c.byteOffset||r.byteStride!==c.byteStride)throw new Error(`Failed to validate WebGL uniform block "${n.name}": reflected layout for "${r.name}" does not match supplied std140 metadata`)}}function Xtn(s,n,r){let c=new Map;for(let d of r.uniformBlockLayouts||[])c.set(d.name,Ztn(d));for(let d of r.shaderLayout?.bindings||[])Jtn(d)&&c.set(d.name,d);let u=new Map;for(let d of c.values()){let b=Ytn(s,n,d.name);if(!b)continue;let{blockIndex:w,blockName:_}=b;if(u.has(w))throw new Error(`Multiple supplied uniform block layouts resolve to active WebGL block "${_}"`);u.set(w,{name:_,location:w,byteLength:d.minBindingSize,vertex:!!(d.visibility&&d.visibility&1),fragment:!!(d.visibility&&d.visibility&2),uniformCount:d.uniforms.length,uniforms:d.uniforms.map(x=>({...x}))})}return u}function Ytn(s,n,r){let c=r.endsWith("Uniforms")?[r,r.slice(0,-8)]:[r,`${r}Uniforms`];for(let u of c){let d=s.getUniformBlockIndex(n,u);if(d!==4294967295){if(!Number.isInteger(d)||d<0)throw new Error(`Failed to resolve WebGL uniform block "${u}": getUniformBlockIndex returned ${String(d)}`);return{blockIndex:d,blockName:u}}}return null}function v0t(s,n,r,c){let u=c||s.getActiveUniformBlockName(n,r);if(!u)throw new Error(`Failed to reflect WebGL uniform block at index ${r}: missing block name`);let d=(H,te)=>{let se=s.getActiveUniformBlockParameter(n,r,H);if(se==null)throw new Error(`Failed to reflect WebGL uniform block "${u}": ${te} returned null`);return se},b=L4(d(35391,"UNIFORM_BLOCK_BINDING"),u,"UNIFORM_BLOCK_BINDING",0),w=L4(d(35392,"UNIFORM_BLOCK_DATA_SIZE"),u,"UNIFORM_BLOCK_DATA_SIZE",0),_=L4(d(35394,"UNIFORM_BLOCK_ACTIVE_UNIFORMS"),u,"UNIFORM_BLOCK_ACTIVE_UNIFORMS",0),x=y0t(d(35395,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES"),u,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",_),T=AV(s,n,x,35383,"UNIFORM_TYPE",u,_),M=AV(s,n,x,35384,"UNIFORM_SIZE",u,_),L=AV(s,n,x,35386,"UNIFORM_BLOCK_INDEX",u,_),I=AV(s,n,x,35387,"UNIFORM_OFFSET",u,_),D=AV(s,n,x,35388,"UNIFORM_ARRAY_STRIDE",u,_),F=[];for(let H=0;H<_;H++){if(L[H]!==r)throw new Error(`Failed to reflect WebGL uniform block "${u}": active uniform index ${x[H]} belongs to block ${L[H]}, expected ${r}`);let te=x[H],se=s.getActiveUniform(n,te);if(!se)throw new Error(`Failed to reflect WebGL uniform block "${u}": getActiveUniform(${te}) returned null`);let ne=L4(T[H],u,`UNIFORM_TYPE[${H}]`,1),ue=L4(M[H],u,`UNIFORM_SIZE[${H}]`,1),Ce=L4(I[H],u,`UNIFORM_OFFSET[${H}]`,0),Q=L4(D[H],u,`UNIFORM_ARRAY_STRIDE[${H}]`,0);if(se.type!==ne||se.size!==ue)throw new Error(`Failed to reflect WebGL uniform block "${u}": getActiveUniform(${te}) disagrees with getActiveUniforms`);F.push({name:se.name,format:nue(ne),arrayLength:ue,byteOffset:Ce,byteStride:Q})}let O={name:u,location:b,byteLength:w,vertex:!!d(35396,"UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER"),fragment:!!d(35398,"UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER"),uniformCount:_,uniforms:F},z=new Set(O.uniforms.map(H=>H.name.split(".")[0]).filter(H=>!!H)),Z=O.name.replace(/Uniforms$/,"");if(z.size===1&&!z.has(O.name)&&!z.has(Z)){let[H]=z;Qt.warn(`Uniform block "${O.name}" uses GLSL instance "${H}". luma.gl binds uniform buffers by block name ("${O.name}") and alias ("${Z}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}return O}function AV(s,n,r,c,u,d,b){let w=s.getActiveUniforms(n,r,c);if(w===null)throw new Error(`Failed to reflect WebGL uniform block "${d}": ${u} returned null`);return y0t(w,d,u,b)}function y0t(s,n,r,c){if(!Array.isArray(s)&&!ArrayBuffer.isView(s))throw new Error(`Failed to reflect WebGL uniform block "${n}": ${r} returned a non-array value`);let u=Array.from(s);if(u.length!==c||u.some(d=>!Number.isInteger(d)))throw new Error(`Failed to reflect WebGL uniform block "${n}": ${r} returned ${u.length} invalid values, expected ${c}`);return u}function L4(s,n,r,c){if(!Number.isInteger(s)||s{if(typeof b=="string"){let w=n[d];if(!w)throw new Error(`Missing std140 layout field ${d}`);r.push({name:d,format:w.shaderType,arrayLength:1,byteOffset:w.offset*4,byteStride:0});return}if(Array.isArray(b)){u(d,b[0],b[1]);return}for(let[w,_]of Object.entries(b))c(`${d}.${w}`,_)},u=(d,b,w)=>{if(typeof b=="string"){let _=n[`${d}[0]`],x=w>1?n[`${d}[1]`]:void 0;if(!_)throw new Error(`Missing std140 array layout field ${d}[0]`);r.push({name:`${d}[0]`,format:_.shaderType,arrayLength:w,byteOffset:_.offset*4,byteStride:x?(x.offset-_.offset)*4:0});return}if(Array.isArray(b))throw new Error(`Nested uniform arrays are not supported for ${d}`);for(let[_,x]of Object.entries(b)){if(typeof x!="string")throw new Error(`Composite uniform array members are not supported for ${d}`);let T=`${d}[0].${_}`,M=`${d}[1].${_}`,L=n[T],I=w>1?n[M]:void 0;if(!L)throw new Error(`Missing std140 array layout field ${T}`);r.push({name:T,format:L.shaderType,arrayLength:w,byteOffset:L.offset*4,byteStride:I?(I.offset-L.offset)*4:0})}};for(let[d,b]of Object.entries(s))c(d,b);return r}function Jtn(s){return s.type==="uniform"&&Number.isInteger(s.minBindingSize)&&s.minBindingSize>=0&&Array.isArray(s.uniforms)&&s.uniforms.every(n=>typeof n.name=="string"&&typeof n.format=="string"&&Number.isInteger(n.arrayLength)&&n.arrayLength>0&&Number.isInteger(n.byteOffset)&&n.byteOffset>=0&&Number.isInteger(n.byteStride)&&n.byteStride>=0)}function Qtn(s){if(s[s.length-1]!=="]")return{name:s,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(s);return{name:FM(r?.[1],`Failed to parse GLSL uniform name ${s}`),length:r?.[2]?1:0,isArray:!!r?.[2]}}var x0t=Ve(()=>{$r();rue()});function enn(s,n){let r={...s,attributes:s.attributes.map(c=>({...c})),bindings:s.bindings.map(c=>({...c}))};for(let c of n?.attributes||[]){let u=r.attributes.find(d=>d.name===c.name);u?(u.type=c.type||u.type,u.stepMode=c.stepMode||u.stepMode):Qt.warn(`shader layout attribute ${c.name} not present in shader`)}for(let c of n?.bindings||[]){let u=S0t(r,c.name);if(!u){Qt.warn(`shader layout binding ${c.name} not present in shader`);continue}Object.assign(u,c)}return r}function S0t(s,n){return s.bindings.find(r=>r.name===n||r.name===`${n}Uniforms`||`${r.name}Uniforms`===n)}function E0t(s,n){return s[n]||s[`${n}Uniforms`]||s[n.replace(/Uniforms$/,"")]}var sue,M0t=Ve(()=>{$r();g0t();Hle();$le();tue();yRe();x0t();sue=class extends Sb{device;handle;vs;fs;introspectedLayout;bindings={};uniforms={};varyings=null;_uniformCount=0;_uniformSetters={};get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}constructor(n,r){super(n,r),this.device=n;let c=this.sharedRenderPipeline||this.device._createSharedRenderPipelineWebGL(r);this.sharedRenderPipeline=c,this.handle=c.handle,this.vs=c.vs,this.fs=c.fs,this.linkStatus=c.linkStatus,this.introspectedLayout=_0t(this.device.gl,this.handle,{uniformBlockLayouts:r._uniformBlockLayouts,shaderLayout:r.shaderLayout}),this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.shaderLayout=r.shaderLayout?enn(this.introspectedLayout,r.shaderLayout):this.introspectedLayout}destroy(){this.destroyed||(this.sharedRenderPipeline&&!this.props._sharedRenderPipeline&&this.sharedRenderPipeline.destroy(),this.destroyResource())}setBindings(n,r){let c=GD(s4(this.shaderLayout,n));for(let[u,d]of Object.entries(c)){let b=S0t(this.shaderLayout,u);if(b){switch(d||Qt.warn(`Unsetting binding "${u}" in render pipeline "${this.id}"`)(),b.type){case"uniform":if(!(d instanceof wv)&&!(d.buffer instanceof wv))throw new Error("buffer value");break;case"texture":if(!(d instanceof o2||d instanceof a2||d instanceof s2))throw new Error(`${this} Bad texture binding for ${u}`);break;case"sampler":Qt.warn(`Ignoring sampler ${u}`)();break;default:throw new Error(b.type)}this.bindings[u]=d}else{let w=this.shaderLayout.bindings.map(_=>`"${_.name}"`).join(", ");r?.disableWarnings||Qt.warn(`No binding "${u}" in render pipeline "${this.id}", expected one of ${w}`,d)()}}}draw(n){let r=n.renderPass,c=n.bindGroups?GD(n.bindGroups):n.bindings||this.bindings;return r.setPipeline(this),r.setBindings(c),r.setVertexArray(n.vertexArray),r.draw({parameters:n.parameters,topology:n.topology,isInstanced:n.isInstanced,vertexCount:n.vertexCount,indexCount:n.indexCount,instanceCount:n.instanceCount,firstVertex:n.firstVertex,firstIndex:n.firstIndex,firstInstance:n.firstInstance,baseVertex:n.baseVertex,transformFeedback:n.transformFeedback,uniforms:n.uniforms})}_areTexturesRenderable(n){let r=!0;for(let c of this.shaderLayout.bindings)E0t(n,c.name)||(Qt.warn(`Binding ${c.name} not found in ${this.id}`)(),r=!1);return r}_applyBindings(n,r){if(this._syncLinkStatus(),this.linkStatus!=="success")return;let{gl:c}=this.device;c.useProgram(this.handle);let u=0,d=0;for(let b of this.shaderLayout.bindings){let w=E0t(n,b.name);if(!w)throw new Error(`No value for binding ${b.name} in ${this.id}`);switch(b.type){case"uniform":let{name:_}=b,x=c.getUniformBlockIndex(this.handle,_);if(x===4294967295)throw new Error(`Invalid uniform block name ${_}`);if(c.uniformBlockBinding(this.handle,x,d),w instanceof wv)c.bindBufferBase(35345,d,w.handle);else{let M=w;c.bindBufferRange(35345,d,M.buffer.handle,M.offset||0,M.size||M.buffer.byteLength-(M.offset||0))}d+=1;break;case"texture":if(!(w instanceof o2||w instanceof a2||w instanceof s2))throw new Error("texture");let T;if(w instanceof o2)T=w.texture;else if(w instanceof a2)T=w;else if(w instanceof s2&&w.colorAttachments[0]instanceof o2)Qt.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),T=w.colorAttachments[0].texture;else throw new Error("No texture");c.activeTexture(33984+u),c.bindTexture(T.glTarget,T.handle),u+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${b.type}' not supported in WebGL`)}}}_applyUniforms(n){for(let r of this.shaderLayout.uniforms||[]){let{name:c,location:u,type:d,textureUnit:b}=r,w=n[c]??b;w!==void 0&&p0t(this.device.gl,u,d,w)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}}});var T0t,oue,C0t=Ve(()=>{$r();rue();T0t=4,oue=class extends w${device;handle;vs;fs;linkStatus="pending";constructor(n,r){super(n,r),this.device=n,this.handle=r.handle||this.device.gl.createProgram(),this.vs=r.vs,this.fs=r.fs,r.varyings&&r.varyings.length>0&&this.device.gl.transformFeedbackVaryings(this.handle,r.varyings,r.bufferMode||35981),this._linkShaders()}destroy(){this.destroyed||(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.handle.destroyed=!0,this.destroyResource())}async _linkShaders(){let{gl:n}=this.device;if(n.attachShader(this.handle,this.vs.handle),n.attachShader(this.handle,this.fs.handle),Qt.time(T0t,`linkProgram for ${this.id}`)(),n.linkProgram(this.handle),Qt.timeEnd(T0t,`linkProgram for ${this.id}`)(),!this.device.features.has("compilation-status-async-webgl")){let c=this._getLinkStatus();this._reportLinkStatus(c);return}Qt.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),Qt.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let r=this._getLinkStatus();this._reportLinkStatus(r)}async _reportLinkStatus(n){switch(n){case"success":return;default:let r=n==="link-error"?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${r} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader();break;case"success":break}switch(this.fs?.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`${this} ${r} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader();break;case"success":break}let c=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${r} during ${n}: ${c}`),this)(),this.device.debug()}}_getLinkStatus(){let{gl:n}=this.device;return n.getProgramParameter(this.handle,35714)?(this._initializeSamplerUniforms(),n.validateProgram(this.handle),n.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}_initializeSamplerUniforms(){let{gl:n}=this.device;n.useProgram(this.handle);let r=0,c=n.getProgramParameter(this.handle,35718);for(let u=0;u1){let b=Int32Array.from({length:r.size},(w,_)=>u+_);return d.uniform1iv(n,b),u+r.size}return d.uniform1i(n,u),u+1}async _waitForLinkComplete(){let n=async u=>await new Promise(d=>setTimeout(d,u));if(!this.device.features.has("compilation-status-async-webgl")){await n(10);return}let{gl:c}=this.device;for(;;){if(c.getProgramParameter(this.handle,37297))return;await n(10)}}}});function tnn(s,n){let r=n.sourceBuffer,c=n.destinationBuffer;s.gl.bindBuffer(36662,r.handle),s.gl.bindBuffer(36663,c.handle),s.gl.copyBufferSubData(36662,36663,n.sourceOffset??0,n.destinationOffset??0,n.size),s.gl.bindBuffer(36662,null),s.gl.bindBuffer(36663,null)}function nnn(s,n){let{sourceBuffer:r,byteOffset:c=0,destinationTexture:u,mipLevel:d=0,origin:b=[0,0,0],aspect:w="all",bytesPerRow:_,rowsPerImage:x,size:T}=n;if(w!=="all")throw new Error("copyBufferToTexture aspect is not supported in WebGL");u.writeBuffer(r,{byteOffset:c,bytesPerRow:_,rowsPerImage:x,mipLevel:d,x:b[0]??0,y:b[1]??0,z:b[2]??0,width:T[0],height:T[1],depthOrArrayLayers:T[2]})}function inn(s,n){let{sourceTexture:r,mipLevel:c=0,aspect:u="all",width:d=n.sourceTexture.width,height:b=n.sourceTexture.height,depthOrArrayLayers:w,origin:_=[0,0,0],destinationBuffer:x,byteOffset:T=0,bytesPerRow:M,rowsPerImage:L}=n;if(r instanceof Aa){r.readBuffer({x:_[0]??0,y:_[1]??0,z:_[2]??0,width:d,height:b,depthOrArrayLayers:w,mipLevel:c,aspect:u,byteOffset:T},x);return}if(u!=="all")throw new Error("aspect not supported in WebGL");if(c!==0||w!==void 0||M||L)throw new Error("not implemented");let{framebuffer:I,destroyFramebuffer:D}=A0t(r),F;try{let O=x,z=d||I.width,Z=b||I.height,H=FM(I.colorAttachments[0]),te=zle(H.texture.props.format),se=te.format,ne=te.type;s.gl.bindBuffer(35051,O.handle),F=s.gl.bindFramebuffer(36160,I.handle),s.gl.readPixels(_[0],_[1],z,Z,se,ne,T)}finally{s.gl.bindBuffer(35051,null),F!==void 0&&s.gl.bindFramebuffer(36160,F),D&&I.destroy()}}function rnn(s,n){let{sourceTexture:r,destinationMipLevel:c=0,origin:u=[0,0],destinationOrigin:d=[0,0,0],destinationTexture:b}=n,{width:w=n.destinationTexture.width,height:_=n.destinationTexture.height}=n,{framebuffer:x,destroyFramebuffer:T}=A0t(r),[M=0,L=0]=u,[I,D,F]=d,O=s.gl.bindFramebuffer(36160,x.handle),z,Z;if(b instanceof a2)z=b,w=Number.isFinite(w)?w:z.width,_=Number.isFinite(_)?_:z.height,z._bind(0),Z=z.glTarget;else throw new Error("invalid destination");switch(Z){case 3553:case 34067:s.gl.copyTexSubImage2D(Z,c,I,D,M,L,w,_);break;case 35866:case 32879:s.gl.copyTexSubImage3D(Z,c,I,D,F,M,L,w,_);break;default:}z&&z._unbind(),s.gl.bindFramebuffer(36160,O),T&&x.destroy()}function A0t(s){if(s instanceof Aa){let{width:n,height:r,id:c}=s;return{framebuffer:s.device.createFramebuffer({id:`framebuffer-for-${c}`,width:n,height:r,colorAttachments:[s]}),destroyFramebuffer:!0}}return{framebuffer:s,destroyFramebuffer:!1}}var aue,P0t=Ve(()=>{$r();EB();tue();aue=class extends y${device;handle=null;commands=[];constructor(n,r={}){super(n,r),this.device=n}_executeCommands(n=this.commands){for(let r of n)switch(r.name){case"copy-buffer-to-buffer":tnn(this.device,r.options);break;case"copy-buffer-to-texture":nnn(this.device,r.options);break;case"copy-texture-to-buffer":inn(this.device,r.options);break;case"copy-texture-to-texture":rnn(this.device,r.options);break;default:throw new Error(r.name)}}}});function L0t(s){switch(s){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"triangle-list":return 4;case"triangle-strip":return 5;default:throw new Error(s)}}function k0t(s){switch(s){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;default:throw new Error(s)}}var ERe=Ve(()=>{});var snn,cue,R0t=Ve(()=>{$r();Qle();_B();ERe();bRe();snn=[1,2,4,8],cue=class extends v${device;handle=null;glParameters={};pipeline=null;bindings={};bindingsPipeline=null;vertexArray=null;constructor(n,r){super(n,r),this.device=n;let c=this.props.framebuffer,u=!c||c.handle===null;u&&n.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();let d;if(!r?.parameters?.viewport)if(!u&&c){let{width:b,height:w}=c;d=[0,0,b,w]}else{let[b,w]=n.getDefaultCanvasContext().getDrawingBufferSize();d=[0,0,b,w]}if(this.device.pushState(),this.setParameters({viewport:d,...this.props.parameters}),!u&&c?.colorAttachments.length){let b=c.colorAttachments.map((w,_)=>36064+_);this.device.gl.drawBuffers(b)}else u&&this.device.gl.drawBuffers([1029]);this.clear(),this.props.timestampQuerySet&&this.props.beginTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.beginTimestampIndex)}end(){this.destroyed||(this.props.timestampQuerySet&&this.props.endTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.endTimestampIndex),this.device.popState(),this.destroy())}pushDebugGroup(n){}popDebugGroup(){}insertDebugMarker(n){}executeBundles(n){throw new Error("Render bundles are only supported in WebGPU")}setParameters(n={}){let r={...this.glParameters};r.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(r.depthMask=!this.props.depthReadOnly),r.stencilMask=this.props.stencilReadOnly?0:1,r[35977]=this.props.discard,n.viewport&&(n.viewport.length>=6?(r.viewport=n.viewport.slice(0,4),r.depthRange=[n.viewport[4],n.viewport[5]]):r.viewport=n.viewport),n.scissorRect&&(r.scissorTest=!0,r.scissor=n.scissorRect),n.blendConstant&&(r.blendColor=n.blendConstant),n.stencilReference!==void 0&&(r[2967]=n.stencilReference,r[36003]=n.stencilReference),"colorMask"in n&&(r.colorMask=snn.map(c=>!!(c&n.colorMask))),this.glParameters=r,gv(this.device.gl,r)}setPipeline(n){this.pipeline=n}setBindings(n,r){if(!this.pipeline)throw new Error("RenderPass.setPipeline() must be called before setBindings()");this.bindings=GD(s4(this.pipeline.shaderLayout,n)),this.bindingsPipeline=this.pipeline}setVertexArray(n){this.vertexArray=n}draw(n){let r=this.pipeline,c=this.vertexArray;if(!r)throw new Error("RenderPass.setPipeline() must be called before draw()");if(!c)throw new Error("RenderPass.setVertexArray() must be called before draw()");if(r.shaderLayout.bindings.length>0&&this.bindingsPipeline!==r)throw new Error("RenderPass.setBindings() must be called after setPipeline() before draw()");r._syncLinkStatus();let{parameters:u=r.props.parameters,topology:d=r.props.topology,vertexCount:b,indexCount:w,instanceCount:_,isInstanced:x=!1,firstVertex:T=0,transformFeedback:M,uniforms:L=r.uniforms}=n,I=L0t(d),D=!!c.indexBuffer,F=c.indexBuffer?.glIndexType,O=w??b??0;if(r.linkStatus!=="success")return Qt.info(2,`RenderPipeline:${r.id}.draw() aborted - waiting for shader linking`)(),!1;if(!r._areTexturesRenderable(this.bindings))return Qt.info(2,`RenderPipeline:${r.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(r.handle),c.bindBeforeRender(this);let z=M;return z&&z.begin(r.props.topology),r._applyBindings(this.bindings,{disableWarnings:r.props.disableWarnings}),r._applyUniforms(L),h0t(this.device,u,this.glParameters,()=>{D&&x?this.device.gl.drawElementsInstanced(I,O,F,T,_||0):D?this.device.gl.drawElements(I,O,F,T):x?this.device.gl.drawArraysInstanced(I,T,b||0,_||0):this.device.gl.drawArrays(I,T,b||0),z&&z.end()}),c.unbindAfterRender(this),!0}drawIndirect(n,r=0){throw new Error("Indirect drawing is only supported in WebGPU")}drawIndexedIndirect(n,r=0){throw new Error("Indirect drawing is only supported in WebGPU")}beginOcclusionQuery(n){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let n={...this.glParameters},r=0;this.props.clearColors&&this.props.clearColors.forEach((c,u)=>{c&&this.clearColorBuffer(u,c)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(r|=16384,n.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=256,n.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=1024,n.clearStencil=this.props.clearStencil),r!==0&&vv(this.device.gl,n,()=>{this.device.gl.clear(r)})}clearColorBuffer(n=0,r=[0,0,0,0]){vv(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,n,r);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,n,r);break;case Float32Array:this.device.gl.clearBufferfv(6144,n,r);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}});var PV,I0t=Ve(()=>{$r();P0t();R0t();PV=class extends _${device;handle=null;commandBuffer;constructor(n,r){super(n,r),this.device=n,this.commandBuffer=new aue(n,{id:this.id,userData:this.userData})}destroy(){this.destroyResource()}finish(){return this.destroy(),this.commandBuffer}beginRenderPass(n={}){return new cue(this.device,this._applyTimeProfilingToPassProps(n))}beginComputePass(n={}){throw new Error("ComputePass not supported in WebGL")}copyBufferToBuffer(n){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:n})}copyBufferToTexture(n){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:n})}copyTextureToBuffer(n){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:n})}copyTextureToTexture(n){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:n})}pushDebugGroup(n){}popDebugGroup(){}insertDebugMarker(n){}resolveQuerySet(n,r,c){throw new Error("resolveQuerySet is not supported in WebGL")}writeTimestamp(n,r){n.writeTimestamp(r)}}});function D0t(s){let{target:n,source:r,start:c=0,count:u=1}=s,d=r.length,b=u*d,w=0;for(let _=c;w{});function onn(s){return Array.isArray(s)?new Float32Array(s):s}function ann(s,n){if(!s||!n||s.length!==n.length||s.constructor!==n.constructor)return!1;for(let r=0;r{$r();VL();lRe();B0t();lue=class s extends x${get[Symbol.toStringTag](){return"VertexArray"}device;handle;attributeInfosByLocation;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(n){return yPe()==="Chrome"}constructor(n,r){super(n,r),this.device=n,this.handle=this.device.gl.createVertexArray(),this.attributeInfosByLocation=new Array(this.maxVertexAttributes).fill(null);for(let c of Object.values(A$(r.shaderLayout,r.bufferLayout)))this.attributeInfosByLocation[c.location]=c}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(n){let r=n;if(r&&r.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,r?r.handle:null),this.indexBuffer=r,this.device.gl.bindVertexArray(null)}setBuffer(n,r){let c=r;if(c.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:u,type:d,stride:b,offset:w,normalized:_,integer:x,divisor:T}=this._getAccessor(n);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,c.handle),x?this.device.gl.vertexAttribIPointer(n,u,d,b,w):this.device.gl.vertexAttribPointer(n,u,d,_,b,w),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(n),this.device.gl.vertexAttribDivisor(n,T||0),this.attributes[n]=c,this.device.gl.bindVertexArray(null)}setConstantWebGL(n,r){this._enable(n,!1),this.attributes[n]=r}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let n=0;n{$r();fue();ERe();uue=class extends E${device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(n,r){super(n,r),this.device=n,this.gl=n.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,r.buffers&&this.setBuffers(r.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(n="point-list"){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(k0t(n))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(n){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let[r,c]of Object.entries(n))this.setBuffer(r,c)})}setBuffer(n,r){let c=this._getVaryingIndex(n),{buffer:u,byteLength:d,byteOffset:b}=this._getBufferRange(r);if(c<0){this.unusedBuffers[n]=u,Qt.warn(`${this.id} unusedBuffers varying buffer ${n}`)();return}this.buffers[c]={buffer:u,byteLength:d,byteOffset:b},this.bindOnUse||this._bindBuffer(c,u,b,d)}getBuffer(n){if(N0t(n))return this.buffers[n]||null;let r=this._getVaryingIndex(n);return this.buffers[r]??null}bind(n=this.handle){if(typeof n!="function")return this.gl.bindTransformFeedback(36386,n),this;let r;return this._bound?r=n():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,r=n(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),r}unbind(){this.bind(null)}_getBufferRange(n){if(n instanceof wv)return{buffer:n,byteOffset:0,byteLength:n.byteLength};let{buffer:r,byteOffset:c=0,byteLength:u=n.buffer.byteLength}=n;return{buffer:r,byteOffset:c,byteLength:u}}_getVaryingIndex(n){if(N0t(n))return Number(n);for(let r of this.layout.varyings||[])if(n===r.name)return r.location;return-1}_bindBuffers(){for(let[n,r]of Object.entries(this.buffers)){let{buffer:c,byteLength:u,byteOffset:d}=this._getBufferRange(r);this._bindBuffer(Number(n),c,d,u)}}_unbindBuffers(){for(let n in this.buffers)this.gl.bindBufferBase(35982,Number(n),null)}_bindBuffer(n,r,c=0,u){let d=r&&r.handle;!d||u===void 0?this.gl.bindBufferBase(35982,n,d):this.gl.bindBufferRange(35982,n,d,c,u)}}});var hue,U0t=Ve(()=>{$r();hue=class extends S${device;handle;_timestampPairs=[];_pendingReads=new Set;_occlusionQuery=null;_occlusionActive=!1;get[Symbol.toStringTag](){return"QuerySet"}constructor(n,r){if(super(n,r),this.device=n,r.type==="timestamp"){if(r.count<2)throw new Error("Timestamp QuerySet requires at least two query slots");this._timestampPairs=new Array(Math.ceil(r.count/2)).fill(null).map(()=>({activeQuery:null,completedQueries:[]})),this.handle=null}else{if(r.count>1)throw new Error("WebGL occlusion QuerySet can only have one value");let c=this.device.gl.createQuery();if(!c)throw new Error("WebGL query not supported");this.handle=c}Object.seal(this)}destroy(){if(!this.destroyed){this.handle&&this.device.gl.deleteQuery(this.handle);for(let n of this._timestampPairs){n.activeQuery&&(this._cancelPendingQuery(n.activeQuery),this.device.gl.deleteQuery(n.activeQuery.handle));for(let r of n.completedQueries)this._cancelPendingQuery(r),this.device.gl.deleteQuery(r.handle)}this._occlusionQuery&&(this._cancelPendingQuery(this._occlusionQuery),this.device.gl.deleteQuery(this._occlusionQuery.handle));for(let n of Array.from(this._pendingReads))this._cancelPendingQuery(n);this.destroyResource()}}isResultAvailable(n){return this.props.type==="timestamp"?n===void 0?this._timestampPairs.some((r,c)=>this._isTimestampPairAvailable(c)):this._isTimestampPairAvailable(this._getTimestampPairIndex(n)):this._occlusionQuery?this._pollQueryAvailability(this._occlusionQuery):!1}async readResults(n){let r=n?.firstQuery||0,c=n?.queryCount||this.props.count-r;if(this._validateRange(r,c),this.props.type==="timestamp"){let u=new Array(c).fill(0n),d=Math.floor(r/2),b=Math.floor((r+c-1)/2);for(let w=d;w<=b;w++){let _=await this._consumeTimestampPairResult(w),x=w*2,T=x+1;x>=r&&x=r&&T=this.props.count||r<=n)throw new Error("Timestamp duration range is out of bounds");if(n%2!==0||r!==n+1)throw new Error("WebGL timestamp durations require adjacent even/odd query indices");let c=await this._consumeTimestampPairResult(this._getTimestampPairIndex(n));return Number(c)/1e6}beginOcclusionQuery(){if(this.props.type!=="occlusion")throw new Error("Occlusion queries require an occlusion QuerySet");if(!this.handle)throw new Error("WebGL occlusion query is not available");if(this._occlusionActive)throw new Error("Occlusion query is already active");this.device.gl.beginQuery(35887,this.handle),this._occlusionQuery={handle:this.handle,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null},this._occlusionActive=!0}endOcclusionQuery(){if(!this._occlusionActive)throw new Error("Occlusion query is not active");this.device.gl.endQuery(35887),this._occlusionActive=!1}writeTimestamp(n){if(this.props.type!=="timestamp")throw new Error("Timestamp writes require a timestamp QuerySet");let r=this._getTimestampPairIndex(n),c=this._timestampPairs[r];if(n%2===0){if(c.activeQuery)throw new Error("Timestamp query pair is already active");let u=this.device.gl.createQuery();if(!u)throw new Error("WebGL query not supported");let d={handle:u,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null};this.device.gl.beginQuery(35007,u),c.activeQuery=d;return}if(!c.activeQuery)throw new Error("Timestamp query pair was ended before it was started");this.device.gl.endQuery(35007),c.completedQueries.push(c.activeQuery),c.activeQuery=null}_validateRange(n,r){if(n<0||r<0||n+r>this.props.count)throw new Error("Query read range is out of bounds")}_getTimestampPairIndex(n){if(n<0||n>=this.props.count)throw new Error("Query index is out of bounds");return Math.floor(n/2)}_isTimestampPairAvailable(n){let r=this._timestampPairs[n];return!r||r.completedQueries.length===0?!1:this._pollQueryAvailability(r.completedQueries[0])}_pollQueryAvailability(n){if(n.cancelled||this.destroyed)return n.result=0n,!0;if(n.result!==null||n.disjoint)return!0;if(!this.device.gl.getQueryParameter(n.handle,34919))return!1;let c=!!this.device.gl.getParameter(36795);return n.disjoint=c,n.result=c?0n:BigInt(this.device.gl.getQueryParameter(n.handle,34918)),!0}async _consumeTimestampPairResult(n){let r=this._timestampPairs[n];if(!r||r.completedQueries.length===0)throw new Error("Timestamp query pair has no completed result");let c=r.completedQueries.shift();try{return await this._consumeQueryResult(c)}finally{this.device.gl.deleteQuery(c.handle)}}_consumeQueryResult(n){return n.promise||(this._pendingReads.add(n),n.promise=new Promise((r,c)=>{n.resolve=r,n.reject=c;let u=()=>{if(n.pollRequestId=null,n.cancelled||this.destroyed){this._pendingReads.delete(n),n.promise=null,n.resolve=null,n.reject=null,r(0n);return}if(!this._pollQueryAvailability(n)){n.pollRequestId=this._requestAnimationFrame(u);return}this._pendingReads.delete(n),n.promise=null,n.resolve=null,n.reject=null,n.disjoint?c(new Error("GPU timestamp query was invalidated by a disjoint event")):r(n.result||0n)};u()})),n.promise}_cancelPendingQuery(n){if(this._pendingReads.delete(n),n.cancelled=!0,n.pollRequestId!==null&&(this._cancelAnimationFrame(n.pollRequestId),n.pollRequestId=null),n.resolve){let r=n.resolve;n.promise=null,n.resolve=null,n.reject=null,r(0n)}}_requestAnimationFrame(n){return requestAnimationFrame(n)}_cancelAnimationFrame(n){cancelAnimationFrame(n)}}});var due,z0t=Ve(()=>{$r();due=class extends M${device;gl;handle;signaled;_signaled=!1;constructor(n,r={}){super(n,{}),this.device=n,this.gl=n.gl;let c=this.props.handle||this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE,0);if(!c)throw new Error("Failed to create WebGL fence");this.handle=c,this.signaled=new Promise(u=>{let d=()=>{let b=this.gl.clientWaitSync(this.handle,0,0);b===this.gl.ALREADY_SIGNALED||b===this.gl.CONDITION_SATISFIED?(this._signaled=!0,u()):setTimeout(d,1)};d()})}isSignaled(){if(this._signaled)return!0;let n=this.gl.getSyncParameter(this.handle,this.gl.SYNC_STATUS);return this._signaled=n===this.gl.SIGNALED,this._signaled}destroy(){this.destroyed||this.gl.deleteSync(this.handle)}}});function SRe(s){switch(s){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function G0t(s){switch(s){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}var j0t=Ve(()=>{});function $0t(s,n){let{sourceX:r=0,sourceY:c=0,sourceAttachment:u=0}=n||{},{target:d=null,sourceWidth:b,sourceHeight:w,sourceDepth:_,sourceFormat:x,sourceType:T}=n||{},{framebuffer:M,deleteFramebuffer:L}=W0t(s),{gl:I,handle:D}=M;b||=M.width,w||=M.height;let F=M.colorAttachments[u]?.texture;if(!F)throw new Error(`Invalid framebuffer attachment ${u}`);_=F?.depth||1,x||=F?.glFormat||6408,T||=F?.glType||5121,d=lnn(d,T,x,b,w,_);let O=Sd.getDataType(d);T=T||m0t(O);let z=I.bindFramebuffer(36160,D);return I.readBuffer(36064+u),I.readPixels(r,c,b,w,x,T,d),I.readBuffer(36064),I.bindFramebuffer(36160,z||null),L&&M.destroy(),d}function V0t(s,n){let{target:r,sourceX:c=0,sourceY:u=0,sourceFormat:d=6408,targetByteOffset:b=0}=n||{},{sourceWidth:w,sourceHeight:_,sourceType:x}=n||{},{framebuffer:T,deleteFramebuffer:M}=W0t(s);w=w||T.width,_=_||T.height;let L=T;x=x||5121;let I=r;if(!I){let F=SRe(d),O=G0t(x),z=b+w*_*F*O;I=L.device.createBuffer({byteLength:z})}let D=s.device.createCommandEncoder();return D.copyTextureToBuffer({sourceTexture:s,width:w,height:_,origin:[c,u],destinationBuffer:I,byteOffset:b}),D.destroy(),M&&T.destroy(),I}function W0t(s){return s instanceof n4?{framebuffer:s,deleteFramebuffer:!1}:{framebuffer:cnn(s),deleteFramebuffer:!0}}function cnn(s,n){let{device:r,width:c,height:u,id:d}=s;return r.createFramebuffer({...n,id:`framebuffer-for-${d}`,width:c,height:u,colorAttachments:[s]})}function lnn(s,n,r,c,u,d){if(s)return s;n||=5121;let b=eue(n),w=Sd.getTypedArrayConstructor(b),_=SRe(r);return new w(c*u*_)}var H0t=Ve(()=>{$r();rue();j0t();xRe()});function q0t(s){let n=new Map;for(let r in s){let c=s[r];if(r<"a"){let u=n.get(c);n.set(c,u?`${u}, GL.${r}`:`GL.${r}`)}}return n}var X0t=Ve(()=>{});var MRe={};Oy(MRe,{WebGLDevice:()=>ZM});function unn(s,n,r){switch(r.length){case 1:s.gl.vertexAttrib1fv(n,r);break;case 2:s.gl.vertexAttrib2fv(n,r);break;case 3:s.gl.vertexAttrib3fv(n,r);break;case 4:s.gl.vertexAttrib4fv(n,r);break;default:}}function fnn(s,n,r){s.gl.vertexAttribI4iv(n,r)}function hnn(s,n,r){s.gl.vertexAttribI4uiv(n,r)}function dnn(s,n){if(!s||!n||s.length!==n.length||s.constructor!==n.constructor)return!1;for(let r=0;r{$r();aRe();W1t();cRe();X1t();n0t();i0t();r0t();s0t();nRe();EB();a0t();Hle();u0t();d0t();tue();$le();M0t();C0t();I0t();O0t();F0t();U0t();z0t();H0t();_B();Qle();SV();X0t();ZM=class s extends C3{static getDeviceFromContext(n){return n?n.luma?.device??null:null}type="webgl";handle;features;limits;info;canvasContext;preferredColorFormat="rgba8unorm";preferredDepthFormat="depth24plus";commandEncoder;lost;_resolveContextLost;_isLost=!1;gl;_glKeyByValue=null;_constants;extensions;_polyfilled=!1;spectorJS;get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(n){switch(n){case"unorm8x4-bgra":return!1;default:return!0}}constructor(n){super({...n,id:n.id||o0t("webgl-device")});let r=C3._getCanvasContextProps(n);if(!r)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let c=r.canvas?.gl??null,u=s.getDeviceFromContext(c);if(u)throw new Error(`WebGL context already attached to device ${u.id}`);this.canvasContext=new Vle(this,r),this.lost=new Promise(T=>{this._resolveContextLost=T});let d={...n.webgl};r.alphaMode==="premultiplied"&&(d.premultipliedAlpha=!0),n.powerPreference!==void 0&&(d.powerPreference=n.powerPreference),n.failIfMajorPerformanceCaveat!==void 0&&(d.failIfMajorPerformanceCaveat=n.failIfMajorPerformanceCaveat);let w=this.props._handle||V1t(this.canvasContext.canvas,{onContextLost:T=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."}),onContextRestored:T=>{console.log("WebGL context restored")}},d);if(!w)throw new Error("WebGL context creation failed");if(u=s.getDeviceFromContext(w),u){if(n._reuseDevices)return Qt.log(1,`Not creating a new Device, instead returning a reference to Device ${u.id} already attached to WebGL context`,u)(),this.canvasContext.destroy(),u._reused=!0,u;throw new Error(`WebGL context already attached to device ${u.id}`)}this.handle=w,this.gl=w,this.spectorJS=I1t({...this.props,gl:this.handle});let _=EV(this.handle);_.device=this,_.extensions||(_.extensions={}),this.extensions=_.extensions,this.info=H1t(this.gl,this.extensions),this.limits=new jle(this.gl),this.features=new Gle(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new mv(this.gl,{log:(...T)=>Qt.log(1,...T)()}).trackState(this.gl,{copyState:!1}),(n.debug||n.debugWebGL)&&(this.gl=k1t(this.gl,{debugWebGL:!0,traceWebGL:n.debugWebGL}),Qt.warn("WebGL debug mode activated. Performance reduced.")()),n.debugWebGL&&(Qt.level=Math.max(Qt.level,1)),this.commandEncoder=new PV(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}destroy(){if(!this.props._reuseDevices&&!this._reused){this._isLost=!0,this.commandEncoder?.destroy();let n=EV(this.handle);n.device=null}}get isLost(){return this._isLost||this.gl.isContextLost()}createCanvasContext(n){throw new Error("WebGL only supports a single canvas")}createPresentationContext(n){return new Wle(this,n||{})}createBuffer(n){let r=this._normalizeBufferProps(n);return new wv(this,r)}createTexture(n){return new a2(this,n)}createExternalTexture(n){throw new Error("ExternalTexture is not available on WebGL")}createSampler(n){return new Jle(this,n)}createShader(n){return new Xle(this,n)}createFramebuffer(n){return new s2(this,n)}createVertexArray(n){return new lue(this,n)}createTransformFeedback(n){return new uue(this,n)}createQuerySet(n){return new hue(this,n)}createFence(){return new due(this)}createRenderPipeline(n){return new sue(this,n)}_createSharedRenderPipelineWebGL(n){return new oue(this,n)}createComputePipeline(n){throw new Error("ComputePipeline not supported in WebGL")}createRenderBundleEncoder(n){throw new Error("Render bundles are only supported in WebGPU")}createCommandEncoder(n={}){return new PV(this,n)}submit(n){let r=null;n||({submittedCommandEncoder:r,commandBuffer:n}=this._finalizeDefaultCommandEncoderForSubmit());try{n._executeCommands(),r&&r.resolveTimeProfilingQuerySet().then(()=>{this.commandEncoder._gpuTimeMs=r._gpuTimeMs}).catch(()=>{})}finally{n.destroy()}}writeBufferViaCommandEncoder(n,r,c,u=0){r.write(c,u)}_finalizeDefaultCommandEncoderForSubmit(){let n=this.commandEncoder,r=n.finish();return this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:n.props.id,timeProfilingQuerySet:n.getTimeProfilingQuerySet()}),{submittedCommandEncoder:n,commandBuffer:r}}readPixelsToArrayWebGL(n,r){return $0t(n,r)}readPixelsToBufferWebGL(n,r){return V0t(n,r)}setParametersWebGL(n){gv(this.gl,n)}getParametersWebGL(n){return Ble(this.gl,n)}withParametersWebGL(n,r){return vv(this.gl,n,r)}resetWebGL(){Qt.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),U1t(this.gl)}_getDeviceSpecificTextureFormatCapabilities(n){return Q1t(this.gl,n,this.extensions)}loseDevice(){let n=!1,c=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return c&&(n=!0,c.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),n}pushState(){mv.get(this.gl).push()}popState(){mv.get(this.gl).pop()}getGLKey(n,r){let c=this._getGLKeyByValue().get(Number(n));return c||(r?.emptyIfUnknown?"":String(n))}getGLKeys(n){let r={emptyIfUnknown:!0};return Object.entries(n).reduce((c,[u,d])=>(c[`${u}:${this.getGLKey(u,r)}`]=`${d}:${this.getGLKey(d,r)}`,c),{})}_getGLKeyByValue(){return this._glKeyByValue??=q0t(this.gl),this._glKeyByValue}setConstantAttributeWebGL(n,r){let c=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(c).fill(null);let u=this._constants[n];switch(u&&dnn(u,r)&&Qt.info(1,`setConstantAttributeWebGL(${n}) could have been skipped, value unchanged`)(),this._constants[n]=r,r.constructor){case Float32Array:unn(this,n,r);break;case Int32Array:fnn(this,n,r);break;case Uint32Array:hnn(this,n,r);break;default:throw new Error("constant")}}getExtension(n){return bv(this.gl,n,this.extensions),this.extensions}_setWebGLDebugMetadata(n,r,c){n.luma=r;let u={props:c.spector,id:c.spector.id};n.__SPECTOR_Metadata=u}}});function pnn(s){return typeof WebGL2RenderingContext<"u"&&s instanceof WebGL2RenderingContext?!0:!!(s&&typeof s.createVertexArray=="function")}function Y0t(s){return{...s,debug:s.debug??C3.defaultProps.debug,debugWebGL:s.debugWebGL??C3.defaultProps.debugWebGL,debugSpectorJS:s.debugSpectorJS??!!Qt.get("debug-spectorjs")}}async function Z0t(s){let n=[];(s.debugWebGL||s.debug)&&n.push(L1t()),s.debugSpectorJS&&n.push(R1t(s));let r=await Promise.allSettled(n);for(let c of r)c.status==="rejected"&&Qt.error(`Failed to initialize debug libraries ${c.reason}`)()}var LV,TRe,kV,K0t=Ve(()=>{$r();A1t();nRe();LV=1,TRe=class extends u${type="webgl";enforceWebGL2(n){C1t(n)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(n){return typeof WebGL2RenderingContext<"u"&&n instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext&&Qt.warn("WebGL1 is not supported",n)(),!1)}async attach(n,r={}){let{WebGLDevice:c}=await Promise.resolve().then(()=>(pue(),MRe));if(n instanceof c)return n;let u=c.getDeviceFromContext(n);if(u)return u;if(!pnn(n))throw new Error("Invalid WebGL2RenderingContext");r=Y0t(r),await Z0t(r);let d=r.createCanvasContext===!0?{}:r.createCanvasContext;return new c({...r,_handle:n,createCanvasContext:{canvas:n.canvas,autoResize:!1,...d}})}async create(n={}){let{WebGLDevice:r}=await Promise.resolve().then(()=>(pue(),MRe));n=Y0t(n),await Z0t(n);try{let c=new r(n);Qt.groupCollapsed(LV,`WebGLDevice ${c.id} created`)();let u=`${c._reused?"Reusing":"Created"} device with WebGL2 ${c.props.debug?"debug ":""}context: ${c.info.vendor}, ${c.info.renderer} for canvas: ${c.canvasContext.id}`;return Qt.probe(LV,u)(),Qt.table(LV,c.info)(),c}finally{Qt.groupEnd(LV)(),Qt.info(LV,"%cWebGL call tracing: luma.log.set('debug-webgl') ","color: white; background: blue; padding: 2px 6px; border-radius: 3px;")()}}};kV=new TRe});var fue=Ve(()=>{K0t();pue();Hle()});function vue(s){return obt.test(s)}function _ue(s){return abt.test(s)}function cbt(s){let n=obt.exec(s),r=abt.exec(s),c=n?.[1]??r?.[1]??s;try{fl.getVertexFormatInfo(c)}catch{throw new Error(`Unsupported GPUVector format ${s}`)}return c}function B3(s){let n=cbt(s),r=vue(s),c=_ue(s),u=fl.getVertexFormatInfo(n),d=u.type,b=u.normalized,w=vnn(d,b);return{format:s,elementFormat:n,vertexList:r,valueList:c,type:d,signedDataType:_nn(n,d),primitiveType:w,components:u.components,byteLength:u.byteLength,integer:u.integer,signed:u.signed,normalized:b,...u.webglOnly?{webglOnly:!0}:{}}}function vnn(s,n){if(n)return"f32";switch(s){case"float32":return"f32";case"float16":return"f16";case"uint8":case"uint16":case"uint32":return"u32";case"sint8":case"sint16":case"sint32":return"i32";default:throw new Error(`Unsupported GPUVector component type ${s}`)}}function _nn(s,n){if(s==="unorm10-10-10-2")return"uint32";switch(n){case"unorm8":return"uint8";case"snorm8":return"sint8";case"unorm16":return"uint16";case"snorm16":return"sint16";default:return n}}var obt,abt,yue=Ve(()=>{$r();obt=/^vertex-list<([^<>]+)>$/,abt=/^value-list<([^<>]+)>$/});function PRe(s,n){if(!Number.isSafeInteger(s)||s<0)throw new Error(`${n} must be a non-negative safe integer`)}var O3,LRe=Ve(()=>{$r();O3=class{buffer;format;length;byteOffset;byteStride;constructor(n){let r=fl.getVertexFormatInfo(n.format).byteLength,c=n.byteOffset??0,u=n.byteStride??r;if(PRe(n.length,"GPUDataView length"),PRe(c,"GPUDataView byteOffset"),PRe(u,"GPUDataView byteStride"),un.buffer.byteLength)throw new Error("GPUDataView exceeds its backing buffer byte length");this.buffer=n.buffer,this.format=n.format,this.length=n.length,this.byteOffset=c,this.byteStride=u}get elementByteLength(){return fl.getVertexFormatInfo(this.format).byteLength}get byteLength(){return this.length===0?0:(this.length-1)*this.byteStride+this.elementByteLength}}});function Eue(s){return!!(s&&typeof s=="object"&&s.type==="struct")}function ubt(s,n){let r=Object.entries(s);if(r.length===0)throw new Error("GPUData struct format must declare at least one field");return n==="packed"?ynn(r):xnn(r)}function ynn(s){let n=[],r=0,c=0;for(let[u,d]of s){let b=fl.getVertexFormatInfo(d);if(b.webglOnly)throw new Error(`Packed GPUData struct field "${u}" uses WebGL-only format ${d}`);r=lbt(r,Math.min(4,b.byteLength)),n.push([u,Object.freeze({format:d,byteOffset:r,byteLength:b.byteLength})]),r+=b.byteLength,c+=b.components}return Object.freeze({type:"struct",layout:"packed",fields:Object.freeze(Object.fromEntries(n)),components:c,byteStride:lbt(r,4),rowByteLength:r})}function xnn(s){let n=Object.fromEntries(s.map(([b,w])=>[b,Enn(w)])),r=o4(n,{layout:"wgsl-storage"}),c=[],u=0,d=0;for(let[b,w]of s){let _=fl.getVertexFormatInfo(w),x=r.fields[b].offset*4;c.push([b,Object.freeze({format:w,byteOffset:x,byteLength:_.byteLength})]),u=Math.max(u,x+_.byteLength),d+=_.components}return Object.freeze({type:"struct",layout:"wgsl-storage",fields:Object.freeze(Object.fromEntries(c)),components:d,byteStride:r.byteLength,rowByteLength:u})}function Enn(s){let n=fl.getVertexFormatInfo(s);switch(n.type){case"float32":return xue("f32",n.components);case"sint32":return xue("i32",n.components);case"uint32":return xue("u32",n.components);default:{let r=Math.ceil(n.byteLength/4);return xue("u32",r)}}}function xue(s,n){return n===1?s:`vec${n}<${s}>`}function lbt(s,n){return Math.ceil(s/n)*n}var fbt=Ve(()=>{$r()});var kRe,RRe,SB,IRe=Ve(()=>{LRe();fbt();yue();kRe=class{buffer;ownsDataBuffer;constructor(n,r){this.buffer=n,this.ownsDataBuffer=r}get ownsBuffer(){return this.ownsDataBuffer}transferBufferOwnership(n){if(n.buffer!==this.buffer)throw new Error("GPUData ownership can only be transferred to the same buffer");n.ownsDataBuffer=this.ownsDataBuffer,this.ownsDataBuffer=!1}destroy(){this.ownsDataBuffer&&(this.buffer.destroy(),this.ownsDataBuffer=!1)}},RRe=class extends kRe{dataType;format;length;valueLength;stride;byteOffset;byteStride;rowByteLength;readbackMetadata;valueOffsets;nullBitmap;valueByteLength;constructor(n){let{buffer:r,format:c,length:u,valueLength:d,stride:b,byteOffset:w=0,byteStride:_,rowByteLength:x,ownsBuffer:T=!1,readbackMetadata:M,valueOffsets:L,nullBitmap:I,valueByteLength:D,dataType:F}=n;super(r,T);let O;c?typeof c=="string"?O=c:O=ubt(c,n.layout??"wgsl-storage"):O=void 0;let z=Eue(O)?O:void 0,Z=typeof O=="string"?B3(O):void 0;if(this.dataType=F,this.format=O,this.length=u,this.valueLength=d??u,this.stride=b??Z?.components??z?.components??_??x??1,this.byteOffset=w,this.rowByteLength=x??z?.rowByteLength??Z?.byteLength??_??this.stride,this.byteStride=_??z?.byteStride??this.rowByteLength,z){if(this.rowByteLengthc.format!==n))throw new Error("GPUVector data chunks must share the declared format")}var c2,dbt=Ve(()=>{IRe();yue();c2=class{name;dataType;format;length;valueLength;stride;byteOffset;byteStride;rowByteLength;bufferLayout;data=[];device;bufferProps;isAppendable=!1;ownsDataChunks=!0;ownedVectors=[];appendableByteLength=0;constructor(n){switch(n.type){case"buffer":{let{name:r,buffer:c,format:u,length:d,valueLength:b=d,byteOffset:w=0,ownsBuffer:_=!1}=n,{stride:x,byteStride:T,rowByteLength:M}=hbt(n);this.name=r,this.dataType=n.dataType,this.format=u,this.length=d,this.valueLength=b,this.stride=x,this.byteOffset=w,this.byteStride=T,this.rowByteLength=M,this.data.push(new SB({buffer:c,format:u,length:d,valueLength:b,stride:x,byteOffset:w,byteStride:T,rowByteLength:M,ownsBuffer:_,dataType:n.dataType}));return}case"interleaved":{let{name:r,buffer:c,format:u,length:d,valueLength:b=d,byteOffset:w=0,byteStride:_,attributes:x,ownsBuffer:T=!1}=n;this.name=r,this.dataType=n.dataType,this.format=u,this.length=d,this.valueLength=b,this.stride=_,this.byteOffset=w,this.byteStride=_,this.rowByteLength=_,this.bufferLayout={name:r,byteStride:_,attributes:x},this.data.push(new SB({buffer:c,format:u,length:d,valueLength:b,stride:_,byteOffset:w,byteStride:_,rowByteLength:_,ownsBuffer:T,dataType:n.dataType}));return}case"data":{let r=n.format??Snn(n.data),c=r?B3(r):void 0,{name:u,data:d,stride:b=d[0]?.stride??c?.components??1,valueLength:w=d.reduce((L,I)=>L+I.valueLength,0),byteStride:_=d[0]?.byteStride??c?.byteLength,rowByteLength:x=d[0]?.rowByteLength??c?.byteLength,bufferLayout:T,ownsData:M=!1}=n;if(_===void 0||x===void 0)throw new Error("GPUVector requires format or explicit byte layout metadata");r&&Mnn(d,r),this.name=u,this.dataType=n.dataType,this.format=r,this.length=d.reduce((L,I)=>L+I.length,0),this.valueLength=w,this.stride=b,this.byteOffset=d.length===1?d[0].byteOffset:0,this.byteStride=_,this.rowByteLength=x,this.bufferLayout=T,this.ownsDataChunks=M,this.data.push(...d);return}case"appendable":{let{name:r,device:c,format:u,valueLength:d=0,bufferProps:b}=n,{stride:w,byteStride:_,rowByteLength:x}=hbt(n);this.name=r,this.dataType=n.dataType,this.format=u,this.length=0,this.valueLength=d,this.stride=w,this.byteOffset=0,this.byteStride=_,this.rowByteLength=x,this.device=c,this.bufferProps=b,this.isAppendable=!0;return}}}get ownsBuffer(){return this.ownsDataChunks&&this.data.some(n=>n.ownsBuffer)||this.ownedVectors.some(n=>n.ownsBuffer)}get capacityRows(){return this.isAppendable?this.length:void 0}get appendedByteLength(){return this.appendableByteLength}addData(n){if(this.format&&n.format!==this.format)throw new Error("GPUVector.addData() requires matching formats");if(n.byteStride!==this.byteStride)throw new Error("GPUVector.addData() requires matching byteStride");if(n.rowByteLength!==this.rowByteLength)throw new Error("GPUVector.addData() requires matching rowByteLength");return this.data.push(n),this.length+=n.length,this.valueLength+=n.valueLength,this}appendDataChunk(n,r=this.appendableByteLength+n.buffer.byteLength){if(!this.isAppendable)throw new Error("GPUVector.appendDataChunk() requires appendable vector storage");if(this.format&&n.format!==this.format)throw new Error("GPUVector.appendDataChunk() requires matching formats");if(n.byteStride!==this.byteStride||n.rowByteLength!==this.rowByteLength)throw new Error("GPUVector.appendDataChunk() requires matching byte layout metadata");return this.data.push(n),this.length+=n.length,this.valueLength+=n.valueLength,this.appendableByteLength=r,this}resetLastBatch(){if(!this.isAppendable)throw new Error("GPUVector.resetLastBatch() requires appendable vector storage");for(let n of this.data.splice(0))n.destroy();return this.length=0,this.valueLength=0,this.appendableByteLength=0,this}retainOwnedVectors(n){return this.ownedVectors.push(...n),this}transferBufferOwnership(n){let r=this.data[0],c=n.data[0];if(!r||!c||r.buffer!==c.buffer)throw new Error("GPUVector ownership can only be transferred to the same buffer");r.transferBufferOwnership(c)}destroy(){if(this.ownsDataChunks)for(let n of this.data)n.destroy();for(let n of this.ownedVectors.splice(0))n.destroy()}}});var DRe=Ve(()=>{IRe();LRe();dbt();yue()});var BRe,cg,OV=Ve(()=>{$r();BRe=class{poolSize=20;bufferPools;constructor(){this.bufferPools=new Map}createOrReuse(n,r){if(r>n.limits.maxBufferSize)throw new Error(`Buffer pool cannot allocate ${r} bytes: device.limits.maxBufferSize is ${n.limits.maxBufferSize}`);let c=this.bufferPools.get(n),u=c?c.findIndex(b=>b.byteLength>=r):-1;if(u<0)return n.createBuffer({usage:as.VERTEX|as.STORAGE|as.COPY_DST|as.COPY_SRC,byteLength:r});let[d]=c.splice(u,1);return d}recycle(n){let r=n.device;this.bufferPools.has(r)||this.bufferPools.set(r,[]);let c=this.bufferPools.get(r),u=c.findIndex(d=>d.byteLength>n.byteLength);u<0?c.push(n):c.splice(u,0,n),this.purge()}purge(){for(let[n,r]of this.bufferPools){let c=n.isLost?0:this.poolSize;for(;r.length>c;)r.shift().destroy();r.length===0&&this.bufferPools.delete(n)}}},cg=new BRe});function Tnn(s,n,r,c){let{ValueType:u,size:d,offset:b,stride:w}=s,_=w/u.BYTES_PER_ELEMENT,x=b/u.BYTES_PER_ELEMENT,T=c-r;if(_===d){let L=x+r*_;return n.subarray(L,L+T*d)}let M=new u(T*d);for(let L=0;L0)throw new Error(`GPUDataEvaluator requires exactly one GPUData chunk for "${s.name}"`);return n}function Pnn(s){let n=[];return gbt(s,n,{byteOffset:0}),n}function gbt(s,n,r){let c=s.source;if(c&&!(c instanceof uc)&&c.name==="interleave"){for(let u of Object.values(c.inputs))u instanceof uc&&gbt(u,n,r);return}n.push({attribute:s.id??s.toString(),format:mbt(s.type,s.size,s.normalized),byteOffset:r.byteOffset}),r.byteOffset+=s.ValueType.BYTES_PER_ELEMENT*s.size}function mbt(s,n,r=!1){if(n<1||n>4)throw new Error(`Cannot synthesize a GPUVector vertex format with ${n} components`);let c=s;if(r)switch(s){case"uint8":c="unorm8";break;case"sint8":c="snorm8";break;case"uint16":c="unorm16";break;case"sint16":c="snorm16";break;case"float32":c="float32";break;default:throw new Error(`Unsupported normalized vertex format for ${s}`)}return(c==="uint8"||c==="sint8"||c==="uint16"||c==="sint16"||c==="unorm8"||c==="snorm8"||c==="unorm16"||c==="snorm16")&&n===3?`${c}x3-webgl`:`${c}${n===1?"":`x${n}`}`}function Lnn(s,n,r=!1){return n>=1&&n<=4?mbt(s,n,r):void 0}var uc,N3=Ve(()=>{$r();Jl();DRe();OV();uc=class s{static get bufferPoolSize(){return cg.poolSize}static set bufferPoolSize(n){if(!Number.isSafeInteger(n)||n<0)throw new Error("GPUDataEvaluator.bufferPoolSize must be a non-negative safe integer");cg.poolSize=n,cg.purge()}type;size;get offset(){return this._offset}get stride(){return this._stride}normalized;isConstant;length;get byteLength(){return this._byteLength}ValueType;source=null;format;_id;_destroyed=!1;_value;_offset;_stride;_byteLength;_gpuVector;_bufferOwnership="owned";_targetBuffer;static fromArray(n,{type:r,size:c=1,offset:u=0,stride:d=0,normalized:b=!1}){let w=r,_;if(Array.isArray(n)){w=w||"float32";let T=KL(w);_=new T(n)}else n instanceof Float64Array?(w="uint32",c*=2,u*=2,d*=2,_=new Uint32Array(n.buffer,n.byteOffset,n.byteLength/4)):(w=w||yce(n),_=n);let x=`<${w} * ${c}>`;return new s({id:x,type:w,size:c,offset:u,stride:d,normalized:b,value:_})}static fromConstant(n,r="float32"){let c=KL(r),u;return Array.isArray(n)?u=`[${n.join(",")}]`:(u=String(n),n=[n]),new s({id:u,isConstant:!0,type:r,size:n.length,value:new c(n)})}static fromGPUData(n,r={}){Cnn(n);let c=new O3({buffer:n.buffer,format:n.format,length:n.length,byteOffset:n.byteOffset,byteStride:n.byteStride});return new s({...pbt(c),id:r.id,gpuData:n})}static fromGPUDataView(n,r={}){return new s({...pbt(n),id:r.id,buffer:n.buffer})}constructor(n){let{id:r,value:c,buffer:u,gpuData:d,format:b,source:w=null,isConstant:_=!1}=n;if(!w&&!c&&!u&&!d)throw new Error("GPUDataEvaluator must have a value source");let{type:x,size:T,offset:M,stride:L,normalized:I,length:D}=n;if(w instanceof s?(x=x??w.type,T=T??w.size,M=M??w.offset,L=L??w.stride,I=I??w.normalized,D=D??w.length):(T=T??1,M=M??0,I=I??!1,D=_?1:D),!x)throw new Error("GPUDataEvaluator: type not defined");if(this._id=r,this.type=x,this.size=T,this.ValueType=KL(this.type),this._offset=M,this._stride=L||this.ValueType.BYTES_PER_ELEMENT*T,this.normalized=I,this.source=w,this.format=b,D===void 0)if(_)D=1;else{if(!c)throw new Error("GPUDataEvaluator: length not defined");D=Math.ceil(c.byteLength/this.stride)}this.isConstant=_,this.length=D;let F=this.ValueType.BYTES_PER_ELEMENT*this.size;this._byteLength=D===0?0:(D-1)*this.stride+F,this._value=c,this._bufferOwnership=w instanceof s||u||d?"borrowed":"owned",d?this._gpuVector=new c2({type:"data",name:this._id??"data",format:d.format,data:[d],stride:d.stride,byteStride:d.byteStride,rowByteLength:d.rowByteLength}):u&&(this._gpuVector=this.createGPUVectorView({buffer:u,name:this._id,format:this.format}))}get value(){return this._value||(this.source instanceof s?this.source.value:void 0)}get evaluated(){return!!this._gpuVector}get id(){return this._id}get gpuVector(){if(!this._gpuVector)throw new Error(`${this} not evaluated`);return this._gpuVector}get buffer(){return Sue(this.gpuVector)}setTargetBuffer({buffer:n,byteOffset:r=0,byteStride:c=this.stride}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)throw new Error(`GPUDataEvaluator ${this} already evaluated`);if(!this.source||this.source instanceof s)throw new Error("GPUDataEvaluator target buffers require a deferred operation source");this._targetBuffer={buffer:n,byteOffset:r,byteStride:c}}async evaluate(n,r={}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let c;if(this.source instanceof s){let u=await this.source.evaluate(n);return this._gpuVector=this.createGPUVectorView({...r,buffer:Sue(u)}),this._gpuVector}if(c=this._getEvaluationBuffer(n),this._value)c.write(this._value);else{let u=await this.source.execute(n,c);if(!u.success)throw u.error||new Error(`${this.source} evaluation failed`);u.value&&(this._value=u.value)}return this._gpuVector=this.createGPUVectorView({...r,buffer:c}),this._gpuVector}evaluateSync(n,r={}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let c;if(this.source instanceof s){let u=this.source.evaluateSync(n);return this._gpuVector=this.createGPUVectorView({...r,buffer:Sue(u)}),this._gpuVector}if(c=this._getEvaluationBuffer(n),this._value)c.write(this._value);else{let u=this.source.executeSync(n,c);if(!u.success)throw u.error||new Error(`${this.source} evaluation failed`);u.value&&(this._value=u.value)}return this._gpuVector=this.createGPUVectorView({...r,buffer:c}),this._gpuVector}createGPUVectorView(n){let r=n.name??this._id??"vector",c=n.format??this.format??Lnn(this.type,this.size,this.normalized);if(n.interleaved){let u=typeof n.interleaved=="object"&&n.interleaved.attributes?n.interleaved.attributes:Pnn(this);return new c2({type:"interleaved",name:r,buffer:n.buffer,format:n.format??this.format,length:this.length,byteOffset:this.offset,byteStride:this.stride,attributes:u,ownsBuffer:!1})}return new c2({type:"buffer",name:r,buffer:n.buffer,format:c,length:this.length,stride:this.size,byteOffset:this.offset,byteStride:this.stride,rowByteLength:this.ValueType.BYTES_PER_ELEMENT*this.size,ownsBuffer:!1})}_getEvaluationBuffer(n){let r=this._targetBuffer;if(!r)return cg.createOrReuse(n,this.byteLength);if(r.buffer.device!==n)throw new Error("GPUDataEvaluator target buffer belongs to a different device");let c=this.ValueType.BYTES_PER_ELEMENT*this.size,u=this.length===0?0:(this.length-1)*r.byteStride+c;if(r.byteOffset+u>r.buffer.byteLength)throw new Error("GPUDataEvaluator target buffer is too small for the output layout");return this._offset=r.byteOffset,this._stride=r.byteStride,this._byteLength=u,this._bufferOwnership="borrowed",this._targetBuffer=void 0,r.buffer}async readValue(n=0,r){let{ValueType:c}=this,{size:u,offset:d,stride:b,length:w}=this,_=c.BYTES_PER_ELEMENT*u;if(r=r??w,n=Math.max(0,Math.min(w,n)),r=Math.max(n,Math.min(w,r)),this._value)return Tnn(this,this._value,n,r);let x=r-n;if(x===0)return new c(0);let T=d+n*b,M=b===_?x*_:(x-1)*b+_,L=await this.buffer.readAsync(T,M),I=new c(L.buffer,L.byteOffset,L.byteLength/c.BYTES_PER_ELEMENT);if(b===_)return I;let D=new Uint8Array(_*x);for(let F=0;F{MB={add:{arity:2,symbol:"arithmetic_add"},subtract:{arity:2,symbol:"arithmetic_subtract"},multiply:{arity:2,symbol:"arithmetic_multiply"},divide:{arity:2,symbol:"arithmetic_divide"},pow:{arity:2,symbol:"pow"},sqrt:{arity:1,symbol:"sqrt"},abs:{arity:1,symbol:"abs"},sin:{arity:1,symbol:"sin"},cos:{arity:1,symbol:"cos"},tan:{arity:1,symbol:"arithmetic_tan"},exp:{arity:1,symbol:"exp"},log:{arity:1,symbol:"log"}}});function kbt(s,{operations:n,inputs:r}){switch(s.kind){case"input":if(!(s.name in r))throw new Error(`Unknown expression input '${s.name}'`);return;case"literal":if(Array.isArray(s.value)){for(let c of s.value)if(!Number.isFinite(c))throw new Error(`Expression literal array must contain only finite values, got ${c}`)}else if(!Number.isFinite(s.value))throw new Error(`Expression literal must be finite, got ${s.value}`);return;case"call":{let c=n[s.op];if(!c)throw new Error(`Unknown expression op '${s.op}'`);if(s.args.length!==c.arity)throw new Error(`Expression op '${s.op}' expects ${c.arity} args, got ${s.args.length}`);for(let u of s.args)kbt(u,{operations:n,inputs:r});return}default:{let c=s;throw new Error(`Unsupported expression node ${c.kind}`)}}}function Cue(s,n){return kbt(s,n),Rbt(s,n)}function Rbt(s,n){switch(s.kind){case"input":{let r=n.inputs[s.name];return n.laneIndexRbt(u,n));return n.formatCall(r.symbol,c)}default:{let r=s;throw new Error(`Unsupported expression node ${r.kind}`)}}}var URe=Ve(()=>{});function fp(s,n,r=!1){if(r)return n===1?"float":`vec${n}`;switch(s){case"uint8":case"uint16":case"uint32":return n===1?"uint":`uvec${n}`;case"sint8":case"sint16":case"sint32":return n===1?"int":`ivec${n}`;default:return n===1?"float":`vec${n}`}}function Aue(s,n,r=!1){let c;if(r)switch(s){case"uint8":c="unorm8";break;case"sint8":c="snorm8";break;case"uint16":c="unorm16";break;case"sint16":c="snorm16";break;case"float32":c="float32";break;default:throw new Error(`Unsupported normalized vertex format for ${s}`)}else c=s;return n===1?c:n===3&&!c.startsWith("float32")&&!c.endsWith("32")?`${c}x3-webgl`:`${c}x${n}`}function KM(s){switch(s[0]){case"u":return"0u";case"s":return"0";default:return"0."}}function Ibt(s,n){switch(s){case"uint8":case"uint16":case"uint32":return`${Math.trunc(n)}u`;case"sint8":case"sint16":case"sint32":return`${Math.trunc(n)}`;default:return Number.isInteger(n)?`${n}.0`:`${n}`}}function Dbt(s){switch(s){case"uint8":return"r8uint";case"sint8":return"r8sint";case"uint16":return"r16uint";case"sint16":return"r16sint";case"uint32":return"r32uint";case"sint32":return"r32sint";case"float32":return"r32float";default:throw new Error(`Unsupported WebGL gather texture format for ${s}`)}}function Bbt(s){switch(s){case"uint32":return"usampler2D";case"sint32":return"isampler2D";case"float32":return"sampler2D";default:throw new Error(`Unsupported WebGL gather sampler type for ${s}`)}}var CB=Ve(()=>{});function hp({module:s,elementWise:n=!1,expression:r,inputs:c,output:u,operationType:d=u.type,outputBuffer:b}){let w=b.device,_=R4("result",u.type,u.size,u.normalized),x=[s,_],T=[],M={},L=fp(u.type,1,u.normalized),I=fp(d,1,u.normalized),D="",F=null,O={TYPE:I,RESULT_LEN:u.size.toString()},z=Unn(c);for(let[se,ne]of z)x.push(zRe(se,ne.type,ne.size,ne.normalized,d)),T.push(GRe(se,ne)),ne instanceof uc?M[se]=ne.buffer:(F=F||cg.createOrReuse(w,b.byteLength),M[se]=F),D+=`TYPE ${se}[${ne.size}]; get_${se}(${se}); +`,O[`${se.toUpperCase()}_LEN`]=ne.size.toString();let Z="";if(r)for(let se=0;sesese).join(", ")}, result);`;let H=`#version 300 es + +void main() { +${D} +${L} result[${u.size}]; +${Z} +set_result(result); +} + `,te=new up(w,{vs:H,shaderAssembler:Fnn,defines:O,modules:x,bufferLayout:T,vertexCount:1,instanceCount:u.length,attributes:M,feedbackBufferMode:"interleaved",outputs:_.varyings});w.statsManager.getStats(Onn).get(Nnn).incrementCount(),te.run({inputBuffers:M,outputBuffers:{[_.varyings[0]]:u.offset===0?b:{buffer:b,byteOffset:u.offset,byteLength:u.byteLength}}}),F&&cg.recycle(F)}function Unn(s){return Array.isArray(s)?s.map((n,r)=>[`x${r}`,n]):Object.entries(s)}function zRe(s,n,r,c=!1,u=n){let d="",b="";for(let _=0;_1&&(L=`${L}[${M}]`),(c||n!==u)&&(L=`TYPE(${L})`),b+=`v[${_+M}]=${L}; +`}}let w=` +${d} +void get_${s}(out TYPE v[${r}]) { + ${b} +} +`;return{name:s,vs:w}}function GRe(s,n){let r={name:s,stepMode:n.isConstant?"vertex":"instance",byteStride:n.stride,attributes:[]};for(let c=0;c_+I);w+=`${s}_${_} = ${T}(${M.map(L=>`v[${L}]`).join(",")}); +`}return{name:s,varyings:u,vs:` +${b} +void set_${s}(in ${d} v[${r}]) { + ${w} +} +`}}var Onn,Nnn,Fnn,$1=Ve(()=>{Jl();vm();N3();OV();CB();Onn="GPGPU Operation Counts",Nnn="Transform Runs",Fnn=new HD});var znn,Pue,jRe=Ve(()=>{vm();URe();Tue();$1();CB();znn=`TYPE arithmetic_add(TYPE x, TYPE y) { + return x + y; +} + +TYPE arithmetic_subtract(TYPE x, TYPE y) { + return x - y; +} + +TYPE arithmetic_multiply(TYPE x, TYPE y) { + return x * y; +} + +TYPE arithmetic_divide(TYPE x, TYPE y) { + return x / y; +} + +float arithmetic_tan(float x) { + return tan_fp32(x); +} +`,Pue=({inputs:s,output:n,target:r})=>{let c=n.type,u=fp(c,1,n.normalized),d=KM(u),b=s.namedInputs;return hp({module:{name:"arithmetic",dependencies:[d4],vs:znn},inputs:b,output:n,operationType:c,outputBuffer:r,expression:w=>Cue(s.expression,{operations:MB,inputs:b,laneIndex:w,formatInput:_=>`${_}[${w}]`,formatOutOfBoundsInput:_=>b[_].size===1?`${_}[0]`:d,formatLiteral:_=>{let x=Array.isArray(_)?_[w]??0:_;return`${u}(${Ibt(c,x)})`},formatCall:(_,x)=>`${_}(${x.join(", ")})`})}),{success:!0}}});var Gnn,jnn,Nbt,Obt,Fbt=Ve(()=>{$r();Jl();N3();OV();jRe();$1();Gnn="GPGPU Operation Counts",jnn="Transform Runs",Nbt=({inputs:s,output:n,target:r})=>{let{sourceValues:c}=s,u=r.device;if(c.length===0){let M=new n.ValueType(n.length*n.size);return r.write(M),{success:!0,value:M}}if(c.isConstant){let M=c.value,L=new n.ValueType(n.length*n.size);for(let I=0;Ic+Math.ceil(u.size/4),0);if(r>s)throw new Error(`interleave() requires ${r} vertex attributes, exceeding device limit ${s}`)}function Vnn(s,n){if(n.size>s)throw new Error(`interleave() output size ${n.size} exceeds device inter-stage component limit ${s}`)}var Ubt,zbt=Ve(()=>{$1();Ubt=({inputs:s,output:n,target:r})=>{let c=s.map((_,x)=>[`x${x}`,_]);$nn(r.device.limits.maxVertexAttributes,c),Vnn(r.device.limits.maxInterStageShaderVariables,n);let u=c.map(([_,x])=>`in TYPE ${_}[${x.size}]`).join(", "),d=0,b=c.map(([_,x])=>{let T=Array.from({length:x.size},(M,L)=>` result[${d+L}] = ${_}[${L}];`).join(` +`);return d+=x.size,T}).join(` +`),w=`void interleave(${u}, out TYPE result[RESULT_LEN]) { +${b} +} +`;return hp({module:{name:"interleave",vs:w},inputs:s,output:n,outputBuffer:r}),{success:!0}}});function Wnn(){let s=new Uint16Array([255]);return new Uint8Array(s.buffer)[0]>0}var Hnn,Gbt,jbt=Ve(()=>{$1();Hnn=`#define LE ${Wnn()?1:0} +const uint F32_NAN = 0xffffffffu; +const uint F32_INF = 0x7f800000u; + +// Find first set bit using binary search +// https://en.wikipedia.org/wiki/Find_first_set#CLZ +int countLeadingZeros(uint a) { + if (a == 0u) return 32; + int n = 0; + if ((a & 0xffff0000u) == 0u) { n += 16; a = a << 16; } + if ((a & 0xff000000u) == 0u) { n += 8; a = a << 8; } + if ((a & 0xf0000000u) == 0u) { n += 4; a = a << 4; } + if ((a & 0xc0000000u) == 0u) { n += 2; a = a << 2; } + if ((a & 0x80000000u) == 0u) return n + 1; + return n; +} + +uint roundShiftRight(uint value, int shift) { + if (shift <= 0) { + return value << (-shift); + } + + if (shift >= 32) { + if (shift == 32 && value > 0x80000000u) { + return 1u; + } + return 0u; + } + + uint truncated = value >> shift; + uint halfShift = 1u << (shift - 1); + uint remainder = value & ((1u << shift) - 1u); + if (remainder > halfShift || (remainder == halfShift && (truncated & 1u) == 1u)) { + return truncated + 1u; + } + return truncated; +} + +uint makeFloat_(uint sign, int exponent, uint mantissa) { + return (sign << 31) | (uint(exponent + 127) << 23) | (mantissa & 0x7fffffu); +} + +/** + * Assemble a float32 in bit representation according to IEEE 754 + * https://en.wikipedia.org/wiki/Single-precision_floating-point_format + */ +uint makeFloat(uint sign, int exponent, uint significand) { + if (significand == 0u) { + return sign << 31; + } + + // Remove any extra leading zeros for better precision + int lead_zeros = countLeadingZeros(significand); + // Significand is encoded as 1.fraction + int normalizedExponent = exponent + 31 - lead_zeros; + + if (normalizedExponent > 127) { + return (sign << 31) | F32_INF; + } + + uint mantissa; + if (normalizedExponent >= -126) { + mantissa = roundShiftRight(significand, 8 - lead_zeros); + if (mantissa >= 0x1000000u) { + mantissa >>= 1; + normalizedExponent++; + if (normalizedExponent > 127) { + return (sign << 31) | F32_INF; + } + } + return makeFloat_(sign, normalizedExponent, mantissa); + } + + int subnormalShift = -149 - exponent; + mantissa = roundShiftRight(significand, subnormalShift); + if (mantissa >= 0x800000u) { + return (sign << 31) | (1u << 23); + } + return (sign << 31) | mantissa; +} + +/** + * Parse 8-byte memory as a float64 number according to IEEE 754 + * https://en.wikipedia.org/wiki/Double-precision_floating-point_format + * Returns 8-byte memory as 2 float32 numbers, consisting of + * high part: fround(d) + * low part: d - fround(d) + */ +uvec2 parseAsDouble(uvec2 d) { + #if LE + d = d.yx; // to big endian + #endif + + uint sign = (d[0] >> 31) & 1u; // first bit + uint exponentBits = (d[0] >> 20) & 0x7ffu; + int exponent = int(exponentBits) - 1023; // next 11 bits + uint fractionHigh = d[0] & 0xfffffu; + uint fractionLow = d[1]; + + if (exponentBits == 0x7ffu) { + if (fractionHigh == 0u && fractionLow == 0u) { + return uvec2((sign << 31) | F32_INF, F32_NAN); + } + return uvec2(F32_NAN); + } + + if (exponentBits == 0u) { + // All float64 subnormals are too small to survive a float32 split. + return uvec2(sign << 31); + } + + if (exponent > 127) { + return uvec2((sign << 31) | F32_INF, ((1u - sign) << 31) | F32_INF); + } + + uint hi_part; + uint low_part; + + // float64 significand has 52 bits + // float32 significand has 23 bits + // The significand of the high part is the significand of the double, trimmed + uint f_hi = 0x800000u | (fractionHigh << 3) | (fractionLow >> 29); + uint f_low = fractionLow & 0x1fffffffu; + + if (exponent < -126) { + // For tiny normals, the top 24 significand bits still contribute to the float32 + // high part, but they land in the float32 subnormal range. + hi_part = makeFloat(sign, exponent - 23, f_hi); + + // The residual keeps the remaining 29 significand bits at the original double scale. + low_part = makeFloat(sign, exponent - 52, f_low); + return uvec2(hi_part, low_part); + } + + bool roundUp = f_low > 0x10000000u || (f_low == 0x10000000u && (f_hi & 1u) == 1u); + + uint f_rounded = f_hi + (roundUp ? 1u : 0u); + int exponent_hi = exponent; + if (f_rounded == 0x1000000u) { + f_rounded = 0x800000u; + exponent_hi++; + } + + if (exponent_hi > 127) { + // Overflows float32 limit + hi_part = (sign << 31) | F32_INF; + low_part = ((1u - sign) << 31) | F32_INF; + return uvec2(hi_part, low_part); + } + + hi_part = makeFloat_(sign, exponent_hi, f_rounded); + + int remainder = int(f_low); + uint sign_low = sign; + if (roundUp) { + remainder -= 0x20000000; + } + if (remainder < 0) { + sign_low = 1u - sign; + remainder = -remainder; + } + low_part = makeFloat(sign_low, exponent - 52, uint(remainder)); + + return uvec2(hi_part, low_part); +} + +void fround(in uint x[X_LEN], out float result[X_LEN]) { + int n = X_LEN / 2; + for (int i = 0; i < n; i++) { + uvec2 f = parseAsDouble(uvec2(x[i * 2], x[i * 2 + 1])); + result[i] = uintBitsToFloat(f.x); + result[i + n] = uintBitsToFloat(f.y); + } +} +`,Gbt=({inputs:s,output:n,target:r})=>(hp({module:{name:"fround",vs:Hnn},inputs:s,output:n,operationType:"uint32",outputBuffer:r}),{success:!0})});function Lue(s,n,r){let c=Bbt(r),u=fp(n,1),d=Array.from({length:s.size},(b,w)=>` v[${w}] = ${u}(texelFetch(source_values_texture, ivec2(${w}, rowIndex), 0).r);`).join(` +`);return{name:"source_values_texture",vs:` +uniform highp ${c} source_values_texture; +void read_source_values(int rowIndex, out TYPE v[${s.size}]) { +${d} +} +`}}function kue(s,n,r){let c=r.createTexture({width:Math.max(s.size,1),height:s.length,format:Dbt(n),usage:Aa.SAMPLE|Aa.COPY_DST});if(s.length===0)return c;let u=r.createCommandEncoder();return u.copyBufferToTexture({sourceBuffer:s.buffer,destinationTexture:c,byteOffset:s.offset,bytesPerRow:s.stride,rowsPerImage:s.length,size:[s.size,s.length,1]}),r.submit(u.finish()),c}var $Re=Ve(()=>{$r();CB()});function qnn(s,n){let r=fp(s.type,1),c="aids_0";return s.type!==Znn(n)&&(c=`${n}(${c})`),{name:"ids",vs:` +in ${r} aids_0; +void get_ids(out INDEX_TYPE v[1]) { + v[0] = ${c}; +} +`}}function Xnn(s){return{name:"ids",stepMode:s.isConstant?"vertex":"instance",byteStride:s.stride,attributes:[{attribute:"aids_0",format:Aue(s.type,1,s.normalized),byteOffset:s.offset}]}}function Ynn(s){return{name:"gather",vs:` +void zero_result(out TYPE result[RESULT_LEN]) { + for (int i = 0; i < RESULT_LEN; i++) { + result[i] = ${KM(s)}; + } +} + +void gather(in INDEX_TYPE ids[1], out TYPE result[RESULT_LEN]) { + int sourceIndex = int(ids[0]); + if (sourceIndex < 0 || sourceIndex >= SOURCE_VALUES_ROWS) { + zero_result(result); + return; + } + read_source_values(sourceIndex, result); +} +`}}function Znn(s){switch(s){case"uint":return"uint32";case"int":return"sint32";default:return"float32"}}var $bt,Vbt=Ve(()=>{Jl();CB();$1();$Re();$bt=async({inputs:s,output:n,target:r})=>{let{ids:c,sourceValues:u}=s,d=r.device,b=R4("result",n.type,n.size),w=fp(c.type,1),_=fp(n.type,1),x=n.type,T=kue(u,x,d),M=`#version 300 es + +void main() { + INDEX_TYPE ids[1]; + get_ids(ids); + TYPE result[${n.size}]; + gather(ids, result); + set_result(result); +} + `,L=new up(d,{vs:M,defines:{INDEX_TYPE:w,TYPE:_,RESULT_LEN:n.size.toString(),SOURCE_VALUES_ROWS:u.length.toString()},modules:[qnn(c,w),Lue(u,n.type,x),Ynn(n.type),b],bindings:{source_values_texture:T},bufferLayout:[Xnn(c)],vertexCount:1,instanceCount:n.length,feedbackBufferMode:"interleaved",outputs:b.varyings});try{return L.run({inputBuffers:{ids:c.buffer},outputBuffers:{[b.varyings[0]]:r}}),{success:!0}}finally{L.destroy(),T.destroy()}}});var Knn,Wbt,Hbt=Ve(()=>{$1();Knn=`void row_dot(in TYPE x[X_LEN], in TYPE y[Y_LEN], out float result[1]) { + float sum = 0.0; + for (int i = 0; i < X_LEN; i++) { + sum += float(x[i]) * float(y[i]); + } + result[0] = sum; +} +`,Wbt=({inputs:s,output:n,target:r})=>(hp({module:{name:"row_dot",vs:Knn},inputs:s,output:n,operationType:"float32",outputBuffer:r}),{success:!0})});var Jnn,qbt,Xbt=Ve(()=>{$1();Jnn=`void equalAll(in TYPE x[X_LEN], in TYPE y[Y_LEN], out uint result[1]) { + uint allEqual = uint(1); + for (int i = 0; i < X_LEN; i++) { + if (x[i] != y[i]) { + allEqual = uint(0); + break; + } + } + result[0] = allEqual; +} +`,qbt=({inputs:s,output:n,target:r})=>(hp({module:{name:"equalAll",vs:Jnn},inputs:s,output:n,operationType:n.type==="uint32"?s.x.type:n.type,outputBuffer:r}),{success:!0})});var Qnn,Ybt,Zbt=Ve(()=>{$1();Qnn=`void row_length(in TYPE x[X_LEN], out float result[1]) { + float sum = 0.0; + for (int i = 0; i < X_LEN; i++) { + sum += float(x[i]) * float(x[i]); + } + result[0] = sqrt(sum); +} +`,Ybt=({inputs:s,output:n,target:r})=>(hp({module:{name:"row_length",vs:Qnn},inputs:s,output:n,operationType:"float32",outputBuffer:r}),{success:!0})});function ein(){return{name:"segmentedMap",vs:` +uint read_segment_start(int segmentIndex) { + TYPE value[1]; + read_source_values(segmentIndex, value); + return uint(value[0]); +} + +void segmentedMap(out TYPE result[RESULT_LEN]) { + uint vertexIndex = uint(gl_InstanceID); + int low = 0; + int high = SEGMENTS_LENGTH; + + while (low < high) { + int mid = low + (high - low) / 2; + uint midStart = read_segment_start(mid); + if (midStart <= vertexIndex) { + low = mid + 1; + } else { + high = mid; + } + } + + uint segmentIndex = uint(max(low - 1, 0)); + uint segmentStart = read_segment_start(int(segmentIndex)); + result[0] = segmentIndex; + result[1] = vertexIndex - segmentStart; +} +`}}var Kbt,Jbt=Ve(()=>{Jl();$Re();$1();Kbt=async({inputs:s,output:n,target:r})=>{let{segments:c}=s,u=r.device,d=R4("result",n.type,n.size),b=c.type,w=kue(c,b,u),_=new up(u,{vs:`#version 300 es + +void main() { + TYPE result[RESULT_LEN]; + segmentedMap(result); + set_result(result); +} +`,defines:{TYPE:"uint",RESULT_LEN:n.size.toString(),SEGMENTS_LENGTH:c.length.toString()},modules:[Lue(c,n.type,b),ein(),d],bindings:{source_values_texture:w},vertexCount:1,instanceCount:n.length,feedbackBufferMode:"interleaved",outputs:d.varyings});try{return _.run({outputBuffers:{[d.varyings[0]]:r}}),{success:!0}}finally{_.destroy(),w.destroy()}}});function VRe(s,n,r,c){return r{$1();CB();Qbt=async({inputs:s,output:n,target:r})=>{let c=fp(n.type,1,n.normalized),u=KM(c);return hp({module:{name:"select",vs:""},inputs:s,output:n,operationType:n.type,outputBuffer:r,expression:d=>{let b=VRe("condition",s.condition,d,u),w=VRe("whenTrue",s.whenTrue,d,u),_=VRe("whenFalse",s.whenFalse,d,u);return`(${b} != ${u} ? ${w} : ${_})`}}),{success:!0}}});var twt,nwt=Ve(()=>{Jl();$1();twt=({inputs:s,output:n,target:r})=>{let c=R4("result",n.type,n.size),u=new up(r.device,{vs:`#version 300 es + +void main() { + int result[1]; + result[0] = START + gl_InstanceID * STEP; + set_result(result); +} +`,defines:{START:s.start.toString(),STEP:s.step.toString()},modules:[c],vertexCount:1,instanceCount:n.length,feedbackBufferMode:"interleaved",outputs:c.varyings});try{return u.run({outputBuffers:{[c.varyings[0]]:r}}),{success:!0}}finally{u.destroy()}}});var iwt,rwt=Ve(()=>{$1();iwt=({inputs:s,output:n,target:r})=>{let{columns:c}=s;return hp({module:{name:"swizzle",vs:"// swizzle expression handled inline"},expression:u=>`x[${c[u]}]`,inputs:{x:s.x},output:n,outputBuffer:r}),{success:!0}}});var swt={};Oy(swt,{arithmetic:()=>Pue,dot:()=>Wbt,equalAll:()=>qbt,extent:()=>Nbt,fround:()=>Gbt,gather:()=>$bt,interleave:()=>Ubt,length:()=>Ybt,segmentedMap:()=>Kbt,select:()=>Qbt,sequence:()=>twt,swizzle:()=>iwt});var owt=Ve(()=>{jRe();Fbt();zbt();jbt();Vbt();Hbt();Xbt();Zbt();Jbt();ewt();nwt();rwt()});function l2(s,n){let r=tin(n),c=Math.max(1,Math.ceil(s)),u=Math.min(c,r),d=Math.min(Math.ceil(c/u),r),b=Math.ceil(c/u/d);if(b>r)throw new Error(`WebGPU dispatch requires ${c} workgroups, exceeding the 3D dispatch limit of ${r} per dimension`);return{x:u,y:d,z:b}}function WRe(s,n="workgroupId"){return`((${n}.z * ${s.y}u + ${n}.y) * ${s.x}u + ${n}.x)`}function JM(s,n,r="workgroupId",c="localId"){return`(${WRe(s,r)} * ${n}u + ${c}.x)`}function tin(s){return Number.isFinite(s)&&s>0?Math.floor(s):65535}var AB=Ve(()=>{});function QM(s,n){switch(s){case"u32":return`${n}u`;case"f32":return Number.isInteger(n)?`${n}.0`:`${n}`;default:return`${n}`}}function awt(s,n){switch(s){case"uint32":return QM("u32",Math.trunc(n));case"sint32":return`${Math.trunc(n)}`;case"float32":return QM("f32",n);default:throw new Error(`WebGPU operations only support 32-bit output types, got ${s}`)}}function eT(s){switch(s){case"uint32":return"0u";case"sint32":return"0";case"float32":return"0.0";default:throw new Error(`WebGPU operations only support 32-bit output types, got ${s}`)}}function Kc(s){switch(s){case"uint32":return"u32";case"sint32":return"i32";case"float32":return"f32";default:throw new Error(`WebGPU operations only support 32-bit storage types, got ${s}`)}}var I4=Ve(()=>{});function dp({module:s,elementWise:n=!1,expression:r,inputs:c,output:u,operationType:d=u.type,outputBuffer:b}){if(!s.source)throw new Error(`WebGPU computation ${s.name} requires WGSL source`);let w=uin(c),_=w.map(([Z,H])=>({name:Z,input:H})),x=_.filter(({input:Z})=>!Z.isConstant).map((Z,H)=>({...Z,index:H})),T=Kc(d),M=Kc(u.type),L={TYPE:T,RESULT_LEN:u.size.toString()},I=l2(Math.ceil(u.length/HRe),b.device.limits.maxComputeWorkgroupsPerDimension);for(let[Z,H]of w)L[`${Z.toUpperCase()}_LEN`]=H.size.toString();let D=` +${hin(s.source,L)} +${x.map(({name:Z,input:H,index:te})=>sin(Z,H,te)).join(` +`)} +${_.map(({name:Z,input:H})=>oin(Z,H,d)).join(` +`)} +${ain(u,x.length)} +${cin(u)} + +@compute @workgroup_size(${HRe}) fn main( + @builtin(workgroup_id) workgroupId: vec3, + @builtin(local_invocation_id) localId: vec3 +) { + let rowIndex = ${JM(I,HRe)}; + if (rowIndex >= ${u.length}u) { + return; + } + +${_.map(({name:Z})=>` let ${Z} = read_${Z}(rowIndex);`).join(` +`)} + var result: array<${M}, ${u.size}>; +${lin(s.name,w,u,n,r)} + write_result(rowIndex, result); +} +`,F=new G1(b.device,{source:D,modules:s.dependencies,shaderAssembler:rin,shaderLayout:{bindings:[...x.map(({name:Z},H)=>({name:Z,type:"storage",group:0,location:H})),{name:"result",type:"storage",group:0,location:x.length}]}}),O=Object.fromEntries(x.map(({name:Z,input:H})=>[Z,H.buffer]));O.result=b,F.setBindings(O);let z=b.device.beginComputePass({});b.device.statsManager.getStats(nin).get(iin).incrementCount(),F.dispatch(z,I.x,I.y,I.z),z.end(),b.device.submit(),F.destroy()}function sin(s,n,r){if(n.isConstant)return"";let c=Kc(n.type);return`@group(0) @binding(${r}) var ${s}: array<${c}>;`}function oin(s,n,r){let c=Kc(r),u=n.type===r?"":c,d=n.stride/n.ValueType.BYTES_PER_ELEMENT,b=n.offset/n.ValueType.BYTES_PER_ELEMENT;return n.isConstant?`fn read_${s}(_rowIndex: u32) -> array<${c}, ${n.size}> { + return array<${c}, ${n.size}>(${fin(n,u)}); +}`:`fn read_${s}(rowIndex: u32) -> array<${c}, ${n.size}> { + var value: array<${c}, ${n.size}>; + let rowOffset = ${b}u + rowIndex * ${d}u; +${Array.from({length:n.size},(w,_)=>u?` value[${_}] = ${u}(${s}[rowOffset + ${_}u]);`:` value[${_}] = ${s}[rowOffset + ${_}u];`).join(` +`)} + return value; +}`}function ain(s,n){let r=Kc(s.type);return`@group(0) @binding(${n}) var result: array<${r}>;`}function cin(s){let n=s.stride/s.ValueType.BYTES_PER_ELEMENT,r=s.offset/s.ValueType.BYTES_PER_ELEMENT;return`fn write_result(rowIndex: u32, value: array<${Kc(s.type)}, ${s.size}>) { + let rowOffset = ${r}u + rowIndex * ${n}u; +${Array.from({length:s.size},(u,d)=>` result[rowOffset + ${d}u] = value[${d}];`).join(` +`)} +}`}function lin(s,n,r,c,u){let d="";if(u)for(let b=0;b_b).join(", ")});`;return d.trimEnd()}function uin(s){return Array.isArray(s)?s.map((n,r)=>[`x${r}`,n]):Object.entries(s)}function fin(s,n){let r=s.value;if(!r)throw new Error(`Constant input ${s} is missing CPU values`);return Array.from({length:s.size},(c,u)=>QM(n,r[u]??0)).join(", ")}function hin(s,n){for(let r in n)s=s.replaceAll(`{${r}}`,n[r]);return s}var HRe,nin,iin,rin,F3=Ve(()=>{Jl();vm();AB();I4();HRe=64,nin="GPGPU Operation Counts",iin="Computation Runs",rin=new jM});var din,cwt,lwt=Ve(()=>{vm();URe();Tue();F3();I4();din=`fn arithmetic_add(x: {TYPE}, y: {TYPE}) -> {TYPE} { + return x + y; +} + +fn arithmetic_subtract(x: {TYPE}, y: {TYPE}) -> {TYPE} { + return x - y; +} + +fn arithmetic_multiply(x: {TYPE}, y: {TYPE}) -> {TYPE} { + return x * y; +} + +fn arithmetic_divide(x: {TYPE}, y: {TYPE}) -> {TYPE} { + return x / y; +} + +fn arithmetic_tan(x: f32) -> f32 { + return tan_fp32(x); +} +`,cwt=({inputs:s,output:n,target:r})=>{let c=n.type,u=Kc(c),d=eT(c),b=s.namedInputs;return dp({module:{name:"arithmetic",source:din,dependencies:[d4]},inputs:b,output:n,operationType:c,outputBuffer:r,expression:w=>Cue(s.expression,{operations:MB,inputs:b,laneIndex:w,formatInput:_=>`${_}[${w}]`,formatOutOfBoundsInput:_=>b[_].size===1?`${_}[0]`:d,formatLiteral:_=>{let x=Array.isArray(_)?_[w]??0:_;return`${u}(${awt(c,x)})`},formatCall:(_,x)=>`${_}(${x.join(", ")})`})}),{success:!0}}});var pin,uwt,fwt=Ve(()=>{F3();pin=`fn row_dot(x: array<{TYPE}, {X_LEN}>, y: array<{TYPE}, {Y_LEN}>) -> array { + var sum = 0.0; + for (var i = 0u; i < {X_LEN}u; i = i + 1u) { + sum += f32(x[i]) * f32(y[i]); + } + return array(sum); +} +`,uwt=({inputs:s,output:n,target:r})=>(dp({module:{name:"row_dot",source:pin},inputs:s,output:n,operationType:"float32",outputBuffer:r}),{success:!0})});var gin,hwt,dwt=Ve(()=>{F3();gin=`fn equalAll(x: array<{TYPE}, {X_LEN}>, y: array<{TYPE}, {Y_LEN}>) -> array { + var allEqual = 1u; + for (var i = 0u; i < {X_LEN}u; i = i + 1u) { + if (x[i] != y[i]) { + allEqual = 0u; + break; + } + } + return array(allEqual); +} +`,hwt=({inputs:s,output:n,target:r})=>(dp({module:{name:"equalAll",source:gin},inputs:s,output:n,operationType:s.x.type,outputBuffer:r}),{success:!0})});function PB(s,n,r){let c=Kc(n.type);return`@group(0) @binding(${r}) var ${s}: array<${c}>;`}function qRe(s,n,r,c=s){let u=Kc(r);if(n.isConstant){let x=n.value;if(!x)throw new Error(`Constant input ${n} is missing CPU values`);return`fn read_${c}(_sourceIndex: u32) -> array<${u}, ${n.size}> { + return array<${u}, ${n.size}>(${Array.from({length:n.size},(T,M)=>QM(u,x[M]??0)).join(", ")}); +}`}let d=n.stride/n.ValueType.BYTES_PER_ELEMENT,b=n.offset/n.ValueType.BYTES_PER_ELEMENT,_=Kc(n.type)===u?"":`${u}`;return`fn read_${c}(sourceIndex: u32) -> array<${u}, ${n.size}> { + var value: array<${u}, ${n.size}>; + let rowOffset = ${b}u + sourceIndex * ${d}u; +${Array.from({length:n.size},(x,T)=>_?` value[${T}] = ${_}(${s}[rowOffset + ${T}u]);`:` value[${T}] = ${s}[rowOffset + ${T}u];`).join(` +`)} + return value; +}`}function Rue(s,n){return qRe("sourceValues",s,n,"source_values")}function LB(s,n){let r=Kc(s.type);return`@group(0) @binding(${n}) var result: array<${r}>;`}function kB(s){let n=s.stride/s.ValueType.BYTES_PER_ELEMENT,r=s.offset/s.ValueType.BYTES_PER_ELEMENT;return`fn write_result(rowIndex: u32, value: array<${Kc(s.type)}, ${s.size}>) { + let rowOffset = ${r}u + rowIndex * ${n}u; +${Array.from({length:s.size},(u,d)=>` result[rowOffset + ${d}u] = value[${d}];`).join(` +`)} +}`}function pwt(s,n){let r=eT(s);return`fn zero_result() -> array<${Kc(s)}, ${n}> { + var result: array<${Kc(s)}, ${n}>; +${Array.from({length:n},(c,u)=>` result[${u}] = ${r};`).join(` +`)} + return result; +}`}var lg,Iue=Ve(()=>{I4();lg=64});function min({input:s,inputMode:n,inputGroupCount:r,channelCount:c,outputType:u,outputBuffer:d,outputLength:b,outputStride:w,outputOffset:_}){let x=Kc(u),T=l2(b,d.device.limits.maxComputeWorkgroupsPerDimension),M=new uc({buffer:d,type:u,size:2,length:b,stride:w,offset:_}),L=` +${s.isConstant?"":PB("sourceValues",s,0)} +${Rue(s,u)} +${LB(M,s.isConstant?0:1)} +${kB(M)} +${bin(n,u,c,r)} + +var sharedMin: array<${x}, ${lg}>; +var sharedMax: array<${x}, ${lg}>; + +@compute @workgroup_size(${lg}) fn main( + @builtin(workgroup_id) workgroupId: vec3, + @builtin(local_invocation_id) localId: vec3 +) { + let outputRowIndex = ${WRe(T)}; + if (outputRowIndex >= ${b}u) { + return; + } + + let channelIndex = outputRowIndex % ${c}u; + let outputGroupIndex = outputRowIndex / ${c}u; + let inputGroupIndex = outputGroupIndex * ${lg}u + localId.x; + + let result = extent_pass(channelIndex, inputGroupIndex); + sharedMin[localId.x] = result[0]; + sharedMax[localId.x] = result[1]; + workgroupBarrier(); + + var stride = ${Math.floor(lg/2)}u; + loop { + if (stride == 0u) { + break; + } + if (localId.x < stride) { + let compareIndex = localId.x + stride; + if (sharedMin[compareIndex] < sharedMin[localId.x]) { + sharedMin[localId.x] = sharedMin[compareIndex]; + } + if (sharedMax[compareIndex] > sharedMax[localId.x]) { + sharedMax[localId.x] = sharedMax[compareIndex]; + } + } + workgroupBarrier(); + stride = stride / 2u; + } + + if (localId.x == 0u) { + write_result(outputRowIndex, array<${x}, 2>(sharedMin[0], sharedMax[0])); + } +} +`,I=new G1(d.device,{source:L,shaderLayout:{bindings:[...s.isConstant?[]:[{name:"sourceValues",type:"storage",group:0,location:0}],{name:"result",type:"storage",group:0,location:s.isConstant?0:1}]}}),D={result:d};s.isConstant||(D.sourceValues=s.buffer),I.setBindings(D);let F=d.device.beginComputePass({});I.dispatch(F,T.x,T.y,T.z),F.end(),d.device.submit(),I.destroy()}function bin(s,n,r,c){let u=Kc(n),[d,b]=win(n);return s==="raw"?`fn extent_pass(channelIndex: u32, inputGroupIndex: u32) -> array<${u}, 2> { + var result: array<${u}, 2>; + result[0] = ${d}; + result[1] = ${b}; + + if (inputGroupIndex < ${c}u) { + let value = read_source_values(inputGroupIndex); + result[0] = value[channelIndex]; + result[1] = value[channelIndex]; + } + + return result; +}`:`fn extent_pass(channelIndex: u32, inputGroupIndex: u32) -> array<${u}, 2> { + var result: array<${u}, 2>; + result[0] = ${d}; + result[1] = ${b}; + + if (inputGroupIndex < ${c}u) { + let rowIndex = inputGroupIndex * ${r}u + channelIndex; + let value = read_source_values(rowIndex); + result[0] = value[0]; + result[1] = value[1]; + } + + return result; +}`}function win(s){switch(s){case"uint32":return["0xffffffffu","0u"];case"sint32":return["2147483647","-2147483648"];case"float32":return["3.402823e38","-3.402823e38"];default:throw new Error(`Unsupported WebGPU extent type for ${s}`)}}var gwt,mwt=Ve(()=>{Jl();N3();OV();AB();I4();Iue();gwt=({inputs:s,output:n,target:r})=>{let{sourceValues:c}=s;if(c.length===0){let _=new n.ValueType(n.length*n.size);return r.write(_),{success:!0,value:_}}if(c.isConstant){let _=c.value;if(!_)throw new Error(`Constant input ${c} is missing CPU values`);let x=new n.ValueType(n.length*n.size);for(let T=0;T1&&u.push(T),min({input:d,inputMode:b,inputGroupCount:w,channelCount:n.length,outputType:n.type,outputBuffer:T,outputLength:x,outputStride:n.stride,outputOffset:n.offset}),_===1)break;d=new uc({buffer:T,type:n.type,size:2,length:x}),b="partial",w=_}return{success:!0}}finally{for(let _ of u)cg.recycle(_)}}});function vin(){let s=new Uint16Array([255]);return new Uint8Array(s.buffer)[0]>0}var _in,bwt,wwt=Ve(()=>{F3();_in=`const LE: bool = ${vin()?"true":"false"}; +const F32_NAN: u32 = 0xffffffffu; +const F32_INF: u32 = 0x7f800000u; + +fn roundShiftRight(value: u32, shift: i32) -> u32 { + if (shift <= 0) { + return value << u32(-shift); + } + + if (shift >= 32) { + if (shift == 32 && value > 0x80000000u) { + return 1u; + } + return 0u; + } + + let shiftU32 = u32(shift); + let truncated = value >> shiftU32; + let halfShift = 1u << u32(shift - 1); + let remainder = value & ((1u << shiftU32) - 1u); + if (remainder > halfShift || (remainder == halfShift && (truncated & 1u) == 1u)) { + return truncated + 1u; + } + return truncated; +} + +fn makeFloatImmediate(sign: u32, exponent: i32, mantissa: u32) -> u32 { + return (sign << 31u) | (u32(exponent + 127) << 23u) | (mantissa & 0x7fffffu); +} + +fn makeFloat(sign: u32, exponent: i32, significand: u32) -> u32 { + if (significand == 0u) { + return sign << 31u; + } + + let leadingZeros = i32(countLeadingZeros(significand)); + var normalizedExponent = exponent + 31 - leadingZeros; + + if (normalizedExponent > 127) { + return (sign << 31u) | F32_INF; + } + + var mantissa: u32; + if (normalizedExponent >= -126) { + mantissa = roundShiftRight(significand, 8 - leadingZeros); + if (mantissa >= 0x1000000u) { + mantissa = mantissa >> 1u; + normalizedExponent += 1; + if (normalizedExponent > 127) { + return (sign << 31u) | F32_INF; + } + } + return makeFloatImmediate(sign, normalizedExponent, mantissa); + } + + let subnormalShift = -149 - exponent; + mantissa = roundShiftRight(significand, subnormalShift); + if (mantissa >= 0x800000u) { + return (sign << 31u) | (1u << 23u); + } + return (sign << 31u) | mantissa; +} + +fn parseAsDouble(words: vec2) -> vec2 { + var d = words; + if (LE) { + d = d.yx; + } + + let sign = (d.x >> 31u) & 1u; + let exponentBits = (d.x >> 20u) & 0x7ffu; + let exponent = i32(exponentBits) - 1023; + let fractionHigh = d.x & 0xfffffu; + let fractionLow = d.y; + + if (exponentBits == 0x7ffu) { + if (fractionHigh == 0u && fractionLow == 0u) { + return vec2((sign << 31u) | F32_INF, F32_NAN); + } + return vec2(F32_NAN); + } + + if (exponentBits == 0u) { + return vec2(sign << 31u); + } + + if (exponent > 127) { + return vec2((sign << 31u) | F32_INF, ((1u - sign) << 31u) | F32_INF); + } + + let highSignificand = 0x800000u | (fractionHigh << 3u) | (fractionLow >> 29u); + let lowSignificand = fractionLow & 0x1fffffffu; + + if (exponent < -126) { + let highPart = makeFloat(sign, exponent - 23, highSignificand); + let lowPart = makeFloat(sign, exponent - 52, lowSignificand); + return vec2(highPart, lowPart); + } + + let roundUp = lowSignificand > 0x10000000u || + (lowSignificand == 0x10000000u && (highSignificand & 1u) == 1u); + + var roundedSignificand = highSignificand + select(0u, 1u, roundUp); + var highExponent = exponent; + if (roundedSignificand == 0x1000000u) { + roundedSignificand = 0x800000u; + highExponent += 1; + } + + if (highExponent > 127) { + return vec2((sign << 31u) | F32_INF, ((1u - sign) << 31u) | F32_INF); + } + + let highPart = makeFloatImmediate(sign, highExponent, roundedSignificand); + + var remainder = i32(lowSignificand); + var lowSign = sign; + if (roundUp) { + remainder -= 0x20000000; + } + if (remainder < 0) { + lowSign = 1u - sign; + remainder = -remainder; + } + + let lowPart = makeFloat(lowSign, exponent - 52, u32(remainder)); + return vec2(highPart, lowPart); +} + +fn fround(x: array) -> array { + var result: array; + let n = {X_LEN}u / 2u; + for (var i = 0u; i < n; i = i + 1u) { + let parts = parseAsDouble(vec2(x[i * 2u], x[i * 2u + 1u])); + result[i] = bitcast(parts.x); + result[i + n] = bitcast(parts.y); + } + return result; +} +`,bwt=({inputs:s,output:n,target:r})=>(dp({module:{name:"fround",source:_in},inputs:s,output:n,operationType:"uint32",outputBuffer:r}),{success:!0})});function yin(s,n){if(s.isConstant){let u=s.value;if(!u)throw new Error(`Constant input ${s} is missing CPU values`);return`fn read_ids(_rowIndex: u32) -> ${n} { + return ${QM(n,u[0]??0)}; +}`}let r=s.stride/s.ValueType.BYTES_PER_ELEMENT,c=s.offset/s.ValueType.BYTES_PER_ELEMENT;return`fn read_ids(rowIndex: u32) -> ${n} { + let rowOffset = ${c}u + rowIndex * ${r}u; + return ids[rowOffset]; +}`}function xin(s,n,r,c){let u=Kc(s),d=Kc(n);return`fn gather(idsValue: ${u}) -> array<${d}, ${r}> { + let sourceIndex = ${u==="u32"?"i32(idsValue)":u==="i32"?"idsValue":"i32(idsValue)"}; + if (sourceIndex < 0 || sourceIndex >= ${c}) { + return zero_result(); + } + return read_source_values(u32(sourceIndex)); +}`}var vwt,_wt=Ve(()=>{Jl();AB();I4();Iue();vwt=async({inputs:s,output:n,target:r})=>{let{ids:c,sourceValues:u}=s,d=Kc(c.type),b=[];c.isConstant||b.push({name:"ids",input:c,index:b.length}),u.isConstant||b.push({name:"sourceValues",input:u,index:b.length});let w=l2(Math.ceil(n.length/lg),r.device.limits.maxComputeWorkgroupsPerDimension),_=` +${b.map(({name:L,input:I,index:D})=>PB(L,I,D)).join(` +`)} +${yin(c,d)} +${Rue(u,n.type)} +${LB(n,b.length)} +${kB(n)} +${pwt(n.type,n.size)} +${xin(c.type,n.type,n.size,u.length)} + +@compute @workgroup_size(${lg}) fn main( + @builtin(workgroup_id) workgroupId: vec3, + @builtin(local_invocation_id) localId: vec3 +) { + let rowIndex = ${JM(w,lg)}; + if (rowIndex >= ${n.length}u) { + return; + } + + let idsValue = read_ids(rowIndex); + let result = gather(idsValue); + write_result(rowIndex, result); +} +`,x=new G1(r.device,{source:_,shaderLayout:{bindings:[...b.map(({name:L,index:I})=>({name:L,type:"storage",group:0,location:I})),{name:"result",type:"storage",group:0,location:b.length}]}}),T={};c.isConstant||(T.ids=c.buffer),u.isConstant||(T.sourceValues=u.buffer),T.result=r,x.setBindings(T);let M=r.device.beginComputePass({});return x.dispatch(M,w.x,w.y,w.z),M.end(),r.device.submit(),x.destroy(),{success:!0}}});function Ein(s){return`fn segmented_map(vertexIndex: u32) -> array { + var low = 0i; + var high = ${s}i; + while (low < high) { + let mid = low + (high - low) / 2i; + let midStart = read_segments(u32(mid))[0]; + if (midStart <= vertexIndex) { + low = mid + 1i; + } else { + high = mid; + } + } + + let segmentIndex = u32(max(low - 1i, 0i)); + let segmentStart = read_segments(segmentIndex)[0]; + return array(segmentIndex, vertexIndex - segmentStart); +}`}var ywt,xwt=Ve(()=>{Jl();AB();Iue();ywt=async({inputs:s,output:n,target:r})=>{let{segments:c}=s,u=c.isConstant?[]:[{name:"segments",input:c,index:0}],d=l2(Math.ceil(n.length/lg),r.device.limits.maxComputeWorkgroupsPerDimension),b=` +${u.map(({name:T,input:M,index:L})=>PB(T,M,L)).join(` +`)} +${qRe("segments",c,"uint32")} +${LB(n,u.length)} +${kB(n)} +${Ein(c.length)} + +@compute @workgroup_size(${lg}) fn main( + @builtin(workgroup_id) workgroupId: vec3, + @builtin(local_invocation_id) localId: vec3 +) { + let rowIndex = ${JM(d,lg)}; + if (rowIndex >= ${n.length}u) { + return; + } + + let result = segmented_map(rowIndex); + write_result(rowIndex, result); +} +`,w=new G1(r.device,{source:b,shaderLayout:{bindings:[...u.map(({name:T,index:M})=>({name:T,type:"storage",group:0,location:M})),{name:"result",type:"storage",group:0,location:u.length}]}}),_=Object.fromEntries(u.map(({name:T,input:M})=>[T,M.buffer]));_.result=r,w.setBindings(_);let x=r.device.beginComputePass({});return w.dispatch(x,d.x,d.y,d.z),x.end(),r.device.submit(),w.destroy(),{success:!0}}});function Sin(s,n){let c=n.filter(([,u])=>!u.isConstant).length+1;if(c>s.maxStorageBuffersPerShaderStage)throw new Error(`interleave() requires ${c} storage buffers, exceeding device limit ${s.maxStorageBuffersPerShaderStage}`);if(c>s.maxBindingsPerBindGroup)throw new Error(`interleave() requires ${c} bindings, exceeding bind group limit ${s.maxBindingsPerBindGroup}`)}var Due,Ewt=Ve(()=>{F3();Due=({inputs:s,output:n,target:r})=>{let c=s.map((_,x)=>[`x${x}`,_]);Sin(r.device.limits,c);let u=c.map(([_,x])=>`${_}: array<{TYPE}, ${x.size}>`).join(", "),d=0,b=c.map(([_,x])=>{let T=Array.from({length:x.size},(M,L)=>` out[${d+L}] = ${_}[${L}];`).join(` +`);return d+=x.size,T}).join(` +`),w=`fn interleave(${u}) -> array<{TYPE}, {RESULT_LEN}> { + var out: array<{TYPE}, {RESULT_LEN}>; +${b} + return out; +} +`;return dp({module:{name:"interleave",source:w},inputs:s,output:n,outputBuffer:r}),{success:!0}}});var Min,Swt,Mwt=Ve(()=>{F3();Min=`fn row_length(x: array<{TYPE}, {X_LEN}>) -> array { + var sum = 0.0; + for (var i = 0u; i < {X_LEN}u; i = i + 1u) { + sum += f32(x[i]) * f32(x[i]); + } + return array(sqrt(sum)); +} +`,Swt=({inputs:s,output:n,target:r})=>(dp({module:{name:"row_length",source:Min},inputs:s,output:n,operationType:"float32",outputBuffer:r}),{success:!0})});function XRe(s,n,r,c){return r{F3();I4();Twt=async({inputs:s,output:n,target:r})=>{let c=eT(n.type);return dp({module:{name:"select",source:`// inline expression select +`},inputs:s,output:n,operationType:n.type,outputBuffer:r,expression:u=>{let d=XRe("condition",s.condition,u,c),b=XRe("whenTrue",s.whenTrue,u,c);return`select(${XRe("whenFalse",s.whenFalse,u,c)}, ${b}, ${d} != ${c})`}}),{success:!0}}});var YRe,Awt,Pwt=Ve(()=>{Jl();AB();YRe=64,Awt=({inputs:s,output:n,target:r})=>{let c=l2(Math.ceil(n.length/YRe),r.device.limits.maxComputeWorkgroupsPerDimension),u=`@group(0) @binding(0) var result: array; + +@compute @workgroup_size(${YRe}) fn main( + @builtin(workgroup_id) workgroupId: vec3, + @builtin(local_invocation_id) localId: vec3 +) { + let rowIndex = ${JM(c,YRe)}; + if (rowIndex >= ${n.length}u) { + return; + } + + let rowOffset = ${n.offset/n.ValueType.BYTES_PER_ELEMENT}u + rowIndex * ${n.stride/n.ValueType.BYTES_PER_ELEMENT}u; + result[rowOffset] = ${s.start} + i32(rowIndex) * ${s.step}; +} +`,d=new G1(r.device,{source:u,shaderLayout:{bindings:[{name:"result",type:"storage",group:0,location:0}]}});d.setBindings({result:r});let b=r.device.beginComputePass({});return d.dispatch(b,c.x,c.y,c.z),b.end(),r.device.submit(),d.destroy(),{success:!0}}});var Lwt,kwt=Ve(()=>{F3();Lwt=({inputs:s,output:n,target:r})=>{let{columns:c}=s;return dp({module:{name:"swizzle",source:"// swizzle expression handled inline"},expression:u=>`x[${c[u]}]`,inputs:{x:s.x},output:n,outputBuffer:r}),{success:!0}}});var Rwt={};Oy(Rwt,{arithmetic:()=>cwt,dot:()=>uwt,equalAll:()=>hwt,extent:()=>gwt,fround:()=>bwt,gather:()=>vwt,interleave:()=>Due,length:()=>Swt,segmentedMap:()=>ywt,select:()=>Twt,sequence:()=>Awt,swizzle:()=>Lwt});var ZRe=Ve(()=>{lwt();fwt();dwt();mwt();wwt();_wt();xwt();Ewt();Mwt();Cwt();Pwt();kwt()});var zvt=Ed((nai,TIe)=>{"use strict";TIe.exports=Jue;TIe.exports.default=Jue;function Jue(s,n,r){r=r||2;var c=n&&n.length,u=c?n[0]*r:s.length,d=Nvt(s,0,u,r,!0),b=[];if(!d||d.next===d.prev)return b;var w,_,x,T,M,L,I;if(c&&(d=dsn(s,n,d,r)),s.length>80*r){w=x=s[0],_=T=s[1];for(var D=r;Dx&&(x=M),L>T&&(T=L);I=Math.max(x-w,T-_),I=I!==0?32767/I:0}return fW(d,b,r,w,_,I,0),b}function Nvt(s,n,r,c,u){var d,b;if(u===MIe(s,n,r,c)>0)for(d=n;d=n;d-=c)b=Ovt(d,s[d],s[d+1],b);return b&&Que(b,b.next)&&(dW(b),b=b.next),b}function B4(s,n){if(!s)return s;n||(n=s);var r=s,c;do if(c=!1,!r.steiner&&(Que(r,r.next)||Ql(r.prev,r,r.next)===0)){if(dW(r),r=n=r.prev,r===r.next)break;c=!0}else r=r.next;while(c||r!==n);return n}function fW(s,n,r,c,u,d,b){if(s){!b&&d&&wsn(s,c,u,d);for(var w=s,_,x;s.prev!==s.next;){if(_=s.prev,x=s.next,d?usn(s,c,u,d):lsn(s)){n.push(_.i/r|0),n.push(s.i/r|0),n.push(x.i/r|0),dW(s),s=x.next,w=x.next;continue}if(s=x,s===w){b?b===1?(s=fsn(B4(s),n,r),fW(s,n,r,c,u,d,2)):b===2&&hsn(s,n,r,c,u,d):fW(B4(s),n,r,c,u,d,1);break}}}}function lsn(s){var n=s.prev,r=s,c=s.next;if(Ql(n,r,c)>=0)return!1;for(var u=n.x,d=r.x,b=c.x,w=n.y,_=r.y,x=c.y,T=ud?u>b?u:b:d>b?d:b,I=w>_?w>x?w:x:_>x?_:x,D=c.next;D!==n;){if(D.x>=T&&D.x<=L&&D.y>=M&&D.y<=I&&BB(u,w,d,_,b,x,D.x,D.y)&&Ql(D.prev,D,D.next)>=0)return!1;D=D.next}return!0}function usn(s,n,r,c){var u=s.prev,d=s,b=s.next;if(Ql(u,d,b)>=0)return!1;for(var w=u.x,_=d.x,x=b.x,T=u.y,M=d.y,L=b.y,I=w<_?w_?w>x?w:x:_>x?_:x,O=T>M?T>L?T:L:M>L?M:L,z=EIe(I,D,n,r,c),Z=EIe(F,O,n,r,c),H=s.prevZ,te=s.nextZ;H&&H.z>=z&&te&&te.z<=Z;){if(H.x>=I&&H.x<=F&&H.y>=D&&H.y<=O&&H!==u&&H!==b&&BB(w,T,_,M,x,L,H.x,H.y)&&Ql(H.prev,H,H.next)>=0||(H=H.prevZ,te.x>=I&&te.x<=F&&te.y>=D&&te.y<=O&&te!==u&&te!==b&&BB(w,T,_,M,x,L,te.x,te.y)&&Ql(te.prev,te,te.next)>=0))return!1;te=te.nextZ}for(;H&&H.z>=z;){if(H.x>=I&&H.x<=F&&H.y>=D&&H.y<=O&&H!==u&&H!==b&&BB(w,T,_,M,x,L,H.x,H.y)&&Ql(H.prev,H,H.next)>=0)return!1;H=H.prevZ}for(;te&&te.z<=Z;){if(te.x>=I&&te.x<=F&&te.y>=D&&te.y<=O&&te!==u&&te!==b&&BB(w,T,_,M,x,L,te.x,te.y)&&Ql(te.prev,te,te.next)>=0)return!1;te=te.nextZ}return!0}function fsn(s,n,r){var c=s;do{var u=c.prev,d=c.next.next;!Que(u,d)&&Fvt(u,c,c.next,d)&&hW(u,d)&&hW(d,u)&&(n.push(u.i/r|0),n.push(c.i/r|0),n.push(d.i/r|0),dW(c),dW(c.next),c=s=d),c=c.next}while(c!==s);return B4(c)}function hsn(s,n,r,c,u,d){var b=s;do{for(var w=b.next.next;w!==b.prev;){if(b.i!==w.i&&ysn(b,w)){var _=Uvt(b,w);b=B4(b,b.next),_=B4(_,_.next),fW(b,n,r,c,u,d,0),fW(_,n,r,c,u,d,0);return}w=w.next}b=b.next}while(b!==s)}function dsn(s,n,r,c){var u=[],d,b,w,_,x;for(d=0,b=n.length;d=r.next.y&&r.next.y!==r.y){var w=r.x+(u-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(w<=c&&w>d&&(d=w,b=r.x=r.x&&r.x>=x&&c!==r.x&&BB(ub.x||r.x===b.x&&bsn(b,r)))&&(b=r,M=L)),r=r.next;while(r!==_);return b}function bsn(s,n){return Ql(s.prev,s,n.prev)<0&&Ql(n.next,s,s.next)<0}function wsn(s,n,r,c){var u=s;do u.z===0&&(u.z=EIe(u.x,u.y,n,r,c)),u.prevZ=u.prev,u.nextZ=u.next,u=u.next;while(u!==s);u.prevZ.nextZ=null,u.prevZ=null,vsn(u)}function vsn(s){var n,r,c,u,d,b,w,_,x=1;do{for(r=s,s=null,d=null,b=0;r;){for(b++,c=r,w=0,n=0;n0||_>0&&c;)w!==0&&(_===0||!c||r.z<=c.z)?(u=r,r=r.nextZ,w--):(u=c,c=c.nextZ,_--),d?d.nextZ=u:s=u,u.prevZ=d,d=u;r=c}d.nextZ=null,x*=2}while(b>1);return s}function EIe(s,n,r,c,u){return s=(s-r)*u|0,n=(n-c)*u|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,s|n<<1}function _sn(s){var n=s,r=s;do(n.x=(s-b)*(d-w)&&(s-b)*(c-w)>=(r-b)*(n-w)&&(r-b)*(d-w)>=(u-b)*(c-w)}function ysn(s,n){return s.next.i!==n.i&&s.prev.i!==n.i&&!xsn(s,n)&&(hW(s,n)&&hW(n,s)&&Esn(s,n)&&(Ql(s.prev,s,n.prev)||Ql(s,n.prev,n))||Que(s,n)&&Ql(s.prev,s,s.next)>0&&Ql(n.prev,n,n.next)>0)}function Ql(s,n,r){return(n.y-s.y)*(r.x-n.x)-(n.x-s.x)*(r.y-n.y)}function Que(s,n){return s.x===n.x&&s.y===n.y}function Fvt(s,n,r,c){var u=Kue(Ql(s,n,r)),d=Kue(Ql(s,n,c)),b=Kue(Ql(r,c,s)),w=Kue(Ql(r,c,n));return!!(u!==d&&b!==w||u===0&&Zue(s,r,n)||d===0&&Zue(s,c,n)||b===0&&Zue(r,s,c)||w===0&&Zue(r,n,c))}function Zue(s,n,r){return n.x<=Math.max(s.x,r.x)&&n.x>=Math.min(s.x,r.x)&&n.y<=Math.max(s.y,r.y)&&n.y>=Math.min(s.y,r.y)}function Kue(s){return s>0?1:s<0?-1:0}function xsn(s,n){var r=s;do{if(r.i!==s.i&&r.next.i!==s.i&&r.i!==n.i&&r.next.i!==n.i&&Fvt(r,r.next,s,n))return!0;r=r.next}while(r!==s);return!1}function hW(s,n){return Ql(s.prev,s,s.next)<0?Ql(s,n,s.next)>=0&&Ql(s,s.prev,n)>=0:Ql(s,n,s.prev)<0||Ql(s,s.next,n)<0}function Esn(s,n){var r=s,c=!1,u=(s.x+n.x)/2,d=(s.y+n.y)/2;do r.y>d!=r.next.y>d&&r.next.y!==r.y&&u<(r.next.x-r.x)*(d-r.y)/(r.next.y-r.y)+r.x&&(c=!c),r=r.next;while(r!==s);return c}function Uvt(s,n){var r=new SIe(s.i,s.x,s.y),c=new SIe(n.i,n.x,n.y),u=s.next,d=n.prev;return s.next=n,n.prev=s,r.next=u,u.prev=r,c.next=r,r.prev=c,d.next=c,c.prev=d,c}function Ovt(s,n,r,c){var u=new SIe(s,n,r);return c?(u.next=c.next,u.prev=c,c.next.prev=u,c.next=u):(u.prev=u,u.next=u),u}function dW(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function SIe(s,n,r){this.i=s,this.x=n,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Jue.deviation=function(s,n,r,c){var u=n&&n.length,d=u?n[0]*r:s.length,b=Math.abs(MIe(s,0,d,r));if(u)for(var w=0,_=n.length;w<_;w++){var x=n[w]*r,T=w<_-1?n[w+1]*r:s.length;b-=Math.abs(MIe(s,x,T,r))}var M=0;for(w=0;w0&&(c+=s[u-1].length,r.holes.push(c))}return r}});var r_t=Ed((i_t,PIe)=>{(function(s){if(typeof i_t=="object"&&typeof PIe<"u")PIe.exports=s();else if(typeof define=="function"&&define.amd)define([],s);else{var n;typeof window<"u"?n=window:typeof global<"u"?n=global:typeof self<"u"?n=self:n=this,n.ELK=s()}})(function(){var s,n,r;return function c(u,d,b){function w(T,M){if(!d[T]){if(!u[T]){var L=typeof AD=="function"&&AD;if(!M&&L)return L(T,!0);if(_)return _(T,!0);var I=new Error("Cannot find module '"+T+"'");throw I.code="MODULE_NOT_FOUND",I}var D=d[T]={exports:{}};u[T][0].call(D.exports,function(F){var O=u[T][1][F];return w(O||F)},D,D.exports,c,u,d,b)}return d[T].exports}for(var _=typeof AD=="function"&&AD,x=0;x0&&arguments[0]!==void 0?arguments[0]:{},I=L.defaultLayoutOptions,D=I===void 0?{}:I,F=L.algorithms,O=F===void 0?["layered","stress","mrtree","radial","force","disco"]:F,z=L.workerFactory,Z=L.workerUrl;if(w(this,T),this.defaultLayoutOptions=D,this.initialized=!1,typeof Z>"u"&&typeof z>"u")throw new Error("Cannot construct an ELK without both 'workerUrl' and 'workerFactory'.");var H=z;typeof Z<"u"&&typeof z>"u"&&(H=function(ne){return new Worker(ne)});var te=H(Z);if(typeof te.postMessage!="function")throw new TypeError("Created worker does not provide the required 'postMessage' function.");this.worker=new x(te),this.worker.postMessage({cmd:"register",algorithms:O}).then(function(se){return M.initialized=!0}).catch(console.err)}return b(T,[{key:"layout",value:function(L){var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},D=I.layoutOptions,F=D===void 0?this.defaultLayoutOptions:D;return L?this.worker.postMessage({cmd:"layout",graph:L,options:F}):Promise.reject(new Error("Missing mandatory parameter 'graph'."))}},{key:"knownLayoutAlgorithms",value:function(){return this.worker.postMessage({cmd:"algorithms"})}},{key:"knownLayoutOptions",value:function(){return this.worker.postMessage({cmd:"options"})}},{key:"knownLayoutCategories",value:function(){return this.worker.postMessage({cmd:"categories"})}},{key:"terminateWorker",value:function(){this.worker.terminate()}}]),T}();d.default=_;var x=function(){function T(M){var L=this;if(w(this,T),M===void 0)throw new Error("Missing mandatory parameter 'worker'.");this.resolvers={},this.worker=M,this.worker.onmessage=function(I){setTimeout(function(){L.receive(L,I)},0)}}return b(T,[{key:"postMessage",value:function(L){var I=this.id||0;this.id=I+1,L.id=I;var D=this;return new Promise(function(F,O){D.resolvers[I]=function(z,Z){z?O(z):F(Z)},D.worker.postMessage(L)})}},{key:"receive",value:function(L,I){var D=I.data,F=L.resolvers[D.id];F&&(delete L.resolvers[D.id],D.error?F(D.error):F(null,D.data))}},{key:"terminate",value:function(){this.worker.terminate&&this.worker.terminate()}}]),T}()},{}],2:[function(c,u,d){(function(b){var w;typeof window<"u"?w=window:typeof b<"u"?w=b:typeof self<"u"&&(w=self);var _,x;function T(){}function M(){}function L(){}function I(){}function D(){}function F(){}function O(){}function z(){}function Z(){}function H(){}function te(){}function se(){}function ne(){}function ue(){}function Ce(){}function Q(){}function me(){}function tt(){}function st(){}function at(){}function Ne(){}function Qe(){}function ot(){}function xt(){}function fn(){}function Xt(){}function wn(){}function cn(){}function bi(){}function jt(){}function gn(){}function Un(){}function Zi(){}function Hi(){}function yr(){}function Tr(){}function Ei(){}function xr(){}function oe(){}function de(){}function it(){}function We(){}function _n(){}function Er(){}function qi(){}function Te(){}function ve(){}function _t(){}function mn(){}function yn(){}function Sn(){}function yi(){}function hi(){}function ri(){}function Ge(){}function Pe(){}function ke(){}function dt(){}function Ye(){}function ct(){}function Ze(){}function Ke(){}function gt(){}function qn(){}function xi(){}function Bi(){}function xn(){}function Je(){}function ti(){}function Zn(){}function rr(){}function Me(){}function et(){}function ht(){}function on(){}function Ri(){}function di(){}function er(){}function ms(){}function Js(){}function $i(){}function Vs(){}function dh(){}function Lm(){}function mg(){}function kv(){}function Rv(){}function AT(){}function bk(){}function Le(){}function St(){}function Kt(){}function en(){}function Yt(){}function Xi(){}function Rr(){}function qr(){}function bs(){}function Ws(){}function xs(){}function Cs(){}function Pc(){}function Uf(){}function dl(){}function bg(){}function fc(){}function Qs(){}function b2(){}function hc(){}function km(){}function w2(){}function Iv(){}function v2(){}function pl(){}function Rm(){}function iE(){}function ph(){}function _2(){}function rE(){}function PT(){}function kO(){}function wk(){}function vk(){}function y2(){}function RO(){}function IO(){}function uH(){}function DO(){}function BO(){}function OO(){}function NO(){}function fH(){}function hH(){}function dH(){}function FO(){}function pH(){}function gH(){}function mH(){}function bH(){}function _k(){}function wH(){}function vH(){}function _H(){}function yH(){}function xH(){}function dc(){}function nc(){}function EH(){}function SH(){}function MH(){}function TH(){}function CH(){}function AH(){}function UO(){}function PH(){}function Iu(){}function yk(){}function Dv(){}function zO(){}function xk(){}function bp(){}function GO(){}function jO(){}function $O(){}function VO(){}function WO(){}function HO(){}function Td(){}function LH(){}function Cd(){}function kH(){}function qO(){}function Ub(){}function LT(){}function Ek(){}function Lc(){}function zb(){}function Sk(){}function RH(){}function Mk(){}function IH(){}function DH(){}function BH(){}function XO(){}function kT(){}function x2(){}function OH(){}function YO(){}function ZO(){}function Tk(){}function Ck(){}function KO(){}function NH(){}function Ak(){}function Pk(){}function FH(){}function JO(){}function Ad(){}function Lk(){}function sE(){}function QO(){}function eN(){}function UH(){}function zH(){}function GH(){}function jH(){}function $H(){}function E2(){}function VH(){}function WH(){}function kk(){}function tN(){}function Gb(){}function RT(){}function HH(){}function qH(){}function XH(){}function S2(){}function wg(){}function nN(){}function YH(){}function ZH(){}function KH(){}function JH(){}function QH(){}function J1(){}function lt(){}function hn(){}function Jt(){}function sr(){}function Es(){}function ea(){}function Il(){}function Wa(){}function IT(){}function eq(){}function wp(){}function DT(){}function tq(){}function M2(){}function BT(){}function OT(){}function _a(){}function nq(){}function iN(){}function NT(){}function iq(){}function rq(){}function sq(){}function FT(){}function jb(){}function UT(){}function rN(){}function zT(){}function sN(){}function oN(){}function GT(){}function aN(){}function oE(){}function Bv(){}function jT(){}function oq(){}function aq(){}function cq(){}function $T(){}function VT(){}function Rk(){}function lq(){}function cN(){}function uq(){}function fq(){}function tu(){}function zf(){}function hq(){}function dq(){}function lN(){}function pq(){}function Ik(){}function aE(){}function Dk(){}function T2(){}function cE(){}function lE(){}function WT(){}function C2(){}function gq(){}function mq(){}function bq(){}function wq(){}function vq(){}function HT(){}function uE(){}function uN(){}function _e(){}function A2(){}function qT(){}function vp(){}function Ro(){}function _q(){}function yq(){}function xq(){}function Ov(){}function Q1(){}function $b(){}function fN(){}function Eq(){}function Sq(){}function e0(){}function Mq(){}function Tq(){}function Cq(){}function Aq(){}function Pq(){}function t0(){}function Lq(){}function kq(){}function Rq(){}function Iq(){}function Dq(){}function Nv(){}function Bq(){}function Oq(){}function vg(){}function Nq(){}function Fq(){}function Uq(){}function zq(){}function Lt(){}function hN(){}function dN(){}function Gq(){}function jq(){}function Bk(){}function fE(){}function hE(){}function $q(){}function pN(){}function Vq(){}function Im(){}function Ok(){}function Fv(){}function _p(){}function Wq(){}function gN(){}function mN(){}function dE(){}function Vb(){}function bN(){}function Hq(){}function XT(){}function qq(){}function pE(){}function gf(){}function YT(){}function gE(){}function Dm(){}function ZT(){}function KT(){}function n0(){}function wN(){}function Du(){}function Nk(){}function Xq(){}function Yq(){}function Zq(){}function P2(){}function Kq(){}function mE(){}function vN(){}function Jq(){}function _N(){}function bE(){}function Fk(){}function yN(){}function Uk(){}function xN(){}function Qq(){}function eX(){}function tX(){}function EN(){}function zk(){}function nX(){}function Gk(){}function SN(){}function MN(){}function TN(){}function JT(){}function iX(){}function CN(){}function Wb(){}function jk(){}function AN(){}function rX(){}function $k(){}function PN(){}function Vk(){}function sX(){}function Wk(){}function ro(){}function oX(){}function aX(){}function wE(){}function LN(){}function cX(){}function lX(){}function yp(){}function uX(){}function QT(){}function Hk(){}function kN(){}function RN(){}function Pd(){}function Hb(){}function qk(){}function IN(){}function eC(){}function DN(){}function Xk(){}function BN(){}function Yk(){}function Zk(){}function qb(){}function fX(){}function Xb(){}function ON(){}function NN(){}function Kk(){}function hX(){}function dX(){}function pX(){}function FN(){}function UN(){}function gX(){}function zN(){}function GN(){}function qh(){}function Bm(){}function mX(){}function bX(){}function tC(){}function L2(){}function jN(){}function $N(){}function wX(){}function VN(){}function k2(){}function vE(){}function vX(){}function WN(){}function HN(){}function nC(){}function qN(){}function iC(){}function Jk(){}function rC(){}function _X(){}function XN(){}function sC(){}function YN(){}function Qk(){}function yX(){}function ZN(){}function i0(){}function KN(){}function JN(){}function xX(){}function QN(){}function EX(){}function SX(){}function r0(){}function eR(){}function tR(){}function nR(){}function oC(){}function R2(){}function ts(){}function aC(){}function iR(){}function Uv(){}function MX(){}function rR(){}function eF(){}function Gf(){}function TX(){}function CX(){}function tF(){}function AX(){}function nF(){}function PX(){}function LX(){}function kX(){}function s0(){}function jf(){}function sR(){}function RX(){}function IX(e){}function lDe(e){}function oR(){Fr()}function _E(){s7()}function iF(){Dee()}function rF(){qA()}function DX(){G_e()}function BX(){rve()}function OX(){UI()}function NX(){Mf()}function sF(){Twe()}function oF(){RR()}function FX(){lI()}function aR(){LGe()}function aF(){YHe()}function yE(){TBe()}function cR(){Ipe()}function cF(){$e()}function lF(){l7e()}function cC(){Xje()}function uF(){h7e()}function _g(){FHe()}function zv(){d7e()}function UX(){ube()}function fF(){vVe()}function zX(){yw()}function GX(){p7e()}function jX(){OGe()}function $X(){bZe()}function VX(){CBe()}function WX(){Pve()}function HX(){mw()}function gh(){T8e()}function qX(){l7()}function XX(){lr()}function hF(){I7()}function dF(){CU()}function pF(){twe()}function lR(){bee()}function YX(){p_e()}function ZX(e){this.a=e}function KX(e){this.a=e}function xE(e){this.a=e}function JX(e){this.a=e}function QX(e){this.a=e}function eY(e){this.a=e}function gF(e){this.a=e}function tY(e){this.a=e}function mF(e){this.a=e}function Ld(e){this.a=e}function nY(e){this.a=e}function uR(e){this.a=e}function iY(e){this.a=e}function bF(e){this.a=e}function rY(e){this.a=e}function sY(e){this.a=e}function oY(e){this.a=e}function aY(e){this.a=e}function fR(e){this.a=e}function hR(e){this.b=e}function cY(e){this.a=e}function lY(e){this.a=e}function uY(e){this.a=e}function fY(e){this.a=e}function hY(e){this.a=e}function wF(e){this.a=e}function vF(e){this.a=e}function dR(e){this.a=e}function lC(e){this.a=e}function EE(e){this.a=e}function dY(e){this.a=e}function _F(e){this.a=e}function Yb(e){this.a=e}function yF(e){this.a=e}function xF(e){this.a=e}function EF(e){this.a=e}function xp(e){this.a=e}function Gv(e){this.a=e}function pR(e){this.a=e}function mh(e){this.a=e}function o0(e){this.a=e}function SE(e){this.d=e}function Om(){this.a=[]}function li(){tl(this)}function bde(e,t){e.i=t}function wde(e,t){e.g=t}function vde(e,t){e.b=t}function _de(e,t){e.b=t}function yde(e,t){e.a=t}function SF(e,t){e.a=t}function xde(e,t){e.c=t}function gR(e,t){e.c=t}function Ede(e,t){e.b=t}function Sde(e,t){e.d=t}function Mde(e,t){e.d=t}function Bu(e,t){e.j=t}function Tde(e,t){e.a=t}function Cde(e,t){e.f=t}function Ade(e,t){e.f=t}function pY(e,t){e.e=t}function MF(e,t){e.k=t}function Pde(e,t){e.a=t}function Lde(e,t){e.b=t}function TF(e,t){e.g=t}function CF(e,t){e.j=t}function kde(e,t){e.n=t}function Rde(e,t){e.a=t}function Ide(e,t){e.a=t}function gY(e,t){e.c=t}function mY(e,t){e.c=t}function Dde(e,t){e.d=t}function Bde(e,t){e.e=t}function Ode(e,t){e.g=t}function Nde(e,t){e.a=t}function mR(e,t){e.c=t}function Fde(e,t){e.d=t}function Ude(e,t){e.e=t}function zde(e,t){e.f=t}function Gde(e,t){e.j=t}function jde(e,t){e.a=t}function $de(e,t){e.a=t}function Vde(e,t){e.b=t}function bY(e){e.b=e.a}function wY(e){e.c=e.d.d}function vY(e){Qn(Hn(e))}function AF(e){this.b=e}function jv(e){this.a=e}function uC(e){this.a=e}function fC(e){this.a=e}function Zb(e){this.b=e}function Nm(e){this.b=e}function PF(e){this.a=e}function LF(e){this.a=e}function dr(e){this.a=e}function kF(e){this.a=e}function RF(e){this.a=e}function _Y(e){this.a=e}function IF(e){this.a=e}function I2(e){this.a=e}function hC(e){this.a=e}function yY(e){this.a=e}function xY(e){this.a=e}function bR(e){this.a=e}function DF(e){this.a=e}function EY(e){this.a=e}function SY(e){this.a=e}function MY(e){this.a=e}function TY(e){this.a=e}function CY(e){this.a=e}function AY(e){this.a=e}function PY(e){this.a=e}function LY(e){this.a=e}function kY(e){this.a=e}function RY(e){this.a=e}function IY(e){this.a=e}function $v(e){this.a=e}function yg(e){this.a=e}function DY(e){this.a=e}function BY(e){this.a=e}function Vv(e){this.a=e}function Rs(e){this.a=e}function BF(e){this.a=e}function mf(e){this.a=e}function j(e){this.c=e}function dC(e){this.e=e}function kd(e){this.a=e}function OY(e){this.a=e}function Wv(e){this.a=e}function OF(e){this.a=e}function NY(e){this.a=e}function FY(e){this.a=e}function wR(e){this.a=e}function UY(e){this.a=e}function a0(e){this.a=e}function NF(e){this.a=e}function pC(e){this.a=e}function Fc(e){this.a=e}function Jc(e){this.a=e}function FF(e){this.a=e}function vR(e){this.a=e}function zY(e){this.a=e}function GY(e){this.a=e}function jY(e){this.a=e}function $Y(e){this.a=e}function VY(e){this.a=e}function UF(e){this.a=e}function ME(e){this.a=e}function Kb(e){this.a=e}function WY(e){this.a=e}function zF(e){this.a=e}function gC(e){this.a=e}function Rd(e){this.a=e}function D2(e){this.a=e}function HY(e){this.a=e}function qY(e){this.a=e}function XY(e){this.a=e}function YY(e){this.a=e}function ZY(e){this.a=e}function GF(e){this.a=e}function c0(e){this.a=e}function Hs(e){this.a=e}function jF(e){this.a=e}function Ep(e){this.a=e}function $F(e){this.a=e}function KY(e){this.b=e}function ya(e){this.a=e}function JY(e){this.a=e}function VF(e){this.a=e}function WF(e){this.c=e}function _R(e){this.a=e}function QY(e){this.a=e}function eZ(e){this.a=e}function tZ(e){this.a=e}function nZ(e){this.a=e}function iZ(e){this.a=e}function rZ(e){this.a=e}function sZ(e){this.a=e}function oZ(e){this.a=e}function aZ(e){this.a=e}function cZ(e){this.a=e}function lZ(e){this.a=e}function uZ(e){this.a=e}function yR(e){this.a=e}function fZ(e){this.a=e}function xR(e){this.a=e}function hZ(e){this.a=e}function dZ(e){this.a=e}function pZ(e){this.a=e}function Ou(e){this.a=e}function Xh(e){this.a=e}function Id(e){this.a=e}function Jb(e){this.a=e}function gZ(e){this.a=e}function HF(e){this.a=e}function mZ(e){this.a=e}function bZ(e){this.a=e}function mC(e){this.a=e}function qF(e){this.f=e}function wZ(e){this.i=e}function ER(e){this.a=e}function vZ(e){this.a=e}function XF(e){this.a=e}function YF(e){this.a=e}function _Z(e){this.a=e}function yZ(e){this.a=e}function xZ(e){this.a=e}function EZ(e){this.a=e}function B2(e){this.a=e}function SZ(e){this.a=e}function MZ(e){this.a=e}function TZ(e){this.a=e}function CZ(e){this.a=e}function AZ(e){this.a=e}function ZF(e){this.a=e}function KF(e){this.a=e}function PZ(e){this.a=e}function LZ(e){this.a=e}function kZ(e){this.a=e}function RZ(e){this.a=e}function IZ(e){this.a=e}function DZ(e){this.a=e}function BZ(e){this.a=e}function OZ(e){this.a=e}function NZ(e){this.a=e}function FZ(e){this.a=e}function UZ(e){this.a=e}function zZ(e){this.a=e}function GZ(e){this.a=e}function jZ(e){this.a=e}function $Z(e){this.a=e}function JF(e){this.a=e}function Sr(e){this.b=e}function VZ(e){this.a=e}function WZ(e){this.a=e}function HZ(e){this.a=e}function qZ(e){this.a=e}function XZ(e){this.a=e}function YZ(e){this.a=e}function ZZ(e){this.a=e}function KZ(e){this.b=e}function SR(e){this.a=e}function O2(e){this.a=e}function QF(e){this.a=e}function bC(e){this.a=e}function wC(e){this.a=e}function MR(e){this.a=e}function TR(e){this.a=e}function JZ(e){this.d=e}function e8(e){this.c=e}function vC(e){this.e=e}function kc(e){this.e=e}function _C(e){this.a=e}function t8(e){this.a=e}function TE(){this.a=0}function CE(){XNe(this)}function Re(){rJ(this)}function AE(){dUe(this)}function Wde(){_pe(),m$t()}function n8(){return null}function Hde(){return null}function qde(e){return e.a}function Xde(e){return e.a}function Yde(e){return e.a}function QZ(e){return e.a}function Zde(e){return e.a}function Y(e){return e.e}function xg(){this.c=zAe}function CR(){this.a=this}function yC(e){this.a=rIt(e)}function i8(){Sp.call(this)}function PE(){Sp.call(this)}function Ha(){Sp.call(this)}function r8(){Sp.call(this)}function AR(){Sp.call(this)}function s8(){RFe.call(this)}function Sp(){RFe.call(this)}function N2(){Sp.call(this)}function Ai(){Sp.call(this)}function o8(){r8.call(this)}function Kde(e){e.b.Te(e.e)}function eK(e,t){t.jd(e.a)}function F2(e,t){e.a=t-e.a}function U2(e,t){e.b=t-e.b}function tK(e,t){e.b+=t}function Jde(e,t){e.d.b.$b(t)}function LE(e,t){e.e=t,t.b=e}function nK(e,t){e.length=t}function a8(e){e.a=new Ir}function c8(){c8=M,new li}function iK(){this.b=new $pe}function S(){this.Bb|=256}function P(){Sp.call(this)}function U(){Sp.call(this)}function K(){Sp.call(this)}function pe(){Sp.call(this)}function xe(e){g7(e.c,e.b)}function je(e,t){cve(e.c,t)}function rt(e,t){n7(e.a,t)}function mt(e,t){Yee(e.a,t)}function vn(e,t){De(e.a,t)}function En(e,t){Cr(e.b,t)}function In(e,t){Pi(e.e,t)}function Vi(e){sS(),Zre.Rd(e)}function mr(){mr=M,r3e=new F}function Fr(){Fr=M,Wre=new I}function eo(){eo=M,i3e=new L}function Vr(){Vr=M,Hre=new rBe}function so(){so=M,qre=new sBe}function Go(){Go=M,Pnt=new Q}function $f(){$f=M,jP=new me}function bh(){bh=M,Bnt=new at}function Ur(){this.a=new li}function gl(){this.a=new D7e}function Yh(){this.a=new Re}function l0(){this.a=new Re}function l8(){this.a=new Re}function uDe(){this.a=new Re}function fDe(){this.a=new Re}function hDe(){this.a=new Ur}function Qde(){this.a=new iOe}function epe(){this.a=new x7e}function tpe(){this.a=new u8e}function npe(){this.a=new $i}function nu(){this.a=new wp}function rK(){this.a=new Re}function ipe(){this.a=new Re}function dDe(){this.b=new Re}function rpe(){this.f=new Re}function pDe(){this.d=new Re}function gDe(){this.a=new Re}function Fm(){this.a=new oGe}function spe(){this.a=new _e}function mDe(){this.j=new Re}function Uc(){Ir.call(this)}function bDe(){Re.call(this)}function sK(){Yh.call(this)}function ope(){z2.call(this)}function z2(){bg.call(this)}function G2(){bg.call(this)}function ape(){G2.call(this)}function wDe(){li.call(this)}function vDe(){li.call(this)}function _De(){li.call(this)}function yDe(){qUe.call(this)}function xDe(){qUe.call(this)}function EDe(){a9.call(this)}function SDe(){zDe.call(this)}function MDe(){zDe.call(this)}function cpe(){gf.call(this)}function lpe(){gf.call(this)}function oK(){Dge.call(this)}function aK(){Dge.call(this)}function cK(){Qje.call(this)}function upe(){Du.call(this)}function TDe(){Du.call(this)}function CDe(){upe.call(this)}function ADe(){S.call(this)}function PDe(){Ur.call(this)}function fpe(){li.call(this)}function lK(){li.call(this)}function LDe(){li.call(this)}function kDe(){jf.call(this)}function Y3t(e){ZBe.call(this,e)}function hpe(e){ZBe.call(this,e)}function Z3t(e){hpe.call(this,e)}function RDe(e){w$e.call(this,e)}function IDe(e){w$e.call(this,e)}function DDe(e){vme.call(this,e)}function dpe(e){EK.call(this,e)}function ppe(e){r7e.call(this,e)}function Hv(e){FE.call(this,e)}function ta(e){$9e.call(this,e)}function BDe(e){ta.call(this,e)}function u8(e){ta.call(this,e)}function ka(e){ta.call(this,e)}function ODe(e){ta.call(this,e)}function uK(e){$9e.call(this,e)}function gpe(e){ka.call(this,e)}function xC(e){ta.call(this,e)}function un(e){ta.call(this,e)}function ma(e){ta.call(this,e)}function NDe(e){ta.call(this,e)}function EC(e){ta.call(this,e)}function wh(e){un.call(this,e)}function SC(){lC.call(this,{})}function Mp(){EE.call(this,"")}function MC(){EE.call(this,"")}function u0(){EE.call(this,"")}function Qb(){EE.call(this,"")}function FDe(e){ka.call(this,e)}function Tp(e){ta.call(this,e)}function mpe(e){KKe(),Yjt(this,e)}function fK(e){WE(),this.a=e}function PR(e){e.b=null,e.c=0}function K3t(e,t){e.a=t,VNt(e)}function J3t(e,t){return e*e/t}function kE(e){return e<0?-e:e}function hK(e){A$e(),this.a=e}function dK(e){$J(),this.f=e}function pK(e){$J(),this.f=e}function gK(e,t,i){e.a[t.g]=i}function Q3t(e,t,i){EBt(i,e,t)}function eEt(e,t,i){UGt(i,e,t)}function tEt(e,t,i){U5t(e,i,t)}function UDe(){this.d=new Re}function zDe(){this.a=new Kq}function GDe(){throw Y(new Ai)}function bpe(){throw Y(new Ai)}function nEt(){throw Y(new Ai)}function iEt(){throw Y(new Ai)}function rEt(){throw Y(new Ai)}function jDe(){throw Y(new Ai)}function LR(e){this.c=Qn(Hn(e))}function sEt(e){return new dR(e)}function oEt(e){return new ix(e)}function q(e,t){return a7e(e,t)}function aEt(e,t){return e.a-t.a}function cEt(e,t){return e.a-t.a}function lEt(e,t){return e.a-t.a}function $De(e,t){return e.g-t.g}function bf(e,t){return e>t?e:t}function f0(e,t){return e0}function _K(e,t){return Sa(e,t)<0}function BE(e){return e.d.c+e.e.c}function fo(){this.a=0,this.b=0}function p8(e){h9.call(this,e)}function Eg(e){w_.call(this,e)}function _Be(e){pQ.call(this,e)}function yBe(e){pQ.call(this,e)}function g8(e){lVe.call(this,e,0)}function xBe(e){this.c=(pn(e),e)}function m8(e){this.a=new g8(e)}function tw(e){this.a=new WJ(e)}function PEt(){throw Y(new K)}function LEt(){throw Y(new K)}function OE(){OE=M,k3e=new xNe}function Yv(){Yv=M,uy=new ot}function EBe(){EBe=M,Znt=new mn}function b8(){b8=M,ase=new zFe}function Lpe(){Lpe=M,zit=new kv}function SBe(){SBe=M,Git=new Le}function kpe(){kpe=M,jit=new R9e}function Rpe(){Rpe=M,CEe=new Xi}function MBe(){MBe=M,Zit=new Uf}function PC(){PC=M,srt=new QH}function TBe(){TBe=M,rrt=new zO}function Ipe(){Ipe=M,bSe=new RH}function RR(){RR=M,Qit=new fo}function CBe(){CBe=M,Gat=new rs}function ABe(){this.b=new tne(ITe)}function PBe(){this.a=new tne(qTe)}function LBe(){this.a=(Xs(),Bh)}function kBe(){this.a=(Xs(),Bh)}function w8(e){this.a=0,this.b=e}function v8(e){return e.b!=e.d.c}function RBe(e,t){return e.d[t.o]}function IBe(e,t){for(;e.sd(t););}function Dpe(e,t,i){e.splice(t,i)}function kEt(e,t,i){Zo(e.d,t.f,i)}function REt(e,t){qte(ye(e.a),t)}function IEt(e,t){qte(ye(e.a),t)}function DBe(e){e.c?rZe(e):sZe(e)}function BBe(){BBe=M,klt=new vN}function OBe(){OBe=M,Wlt=new vDe}function NBe(){NBe=M,Hlt=new _De}function Sg(){Sg=M,Lu=new fpe}function Bpe(){Bpe=M,FAe=new LDe}function _8(){_8=M,Dj=new li}function Ope(){Ope=M,YAe=new Re}function Mg(){Mg=M,mm=new RX}function LC(){LC=M,Dae=new oFe}function Ap(){Ap=M,_D=new aFe}function yK(){yK=M,rut=new Bm}function Xo(){Xo=M,out=new mX}function IR(e){this.a=new nOe(e)}function FBe(e){this.a=h(Hn(e),13)}function UBe(e,t){this.b=e,this.c=t}function zBe(e,t){this.b=e,this.a=t}function Npe(e,t){this.b=e,this.d=t}function NE(e,t){this.e=e,this.d=t}function Fpe(e,t){this.b=e,this.c=t}function GBe(e,t){this.a=e,this.b=t}function jBe(e,t){this.a=e,this.b=t}function $Be(e,t){this.a=e,this.b=t}function VBe(e,t){this.a=e,this.b=t}function WBe(e,t){this.b=e,this.a=t}function q2(e,t){qE.call(this,e,t)}function Zv(e,t){q2.call(this,e,t)}function HBe(e,t){this.b=e,this.a=t}function qBe(e,t){this.a=e,this.b=t}function DR(e,t){this.g=e,this.i=t}function XBe(e,t){this.b=e,this.a=t}function xK(e,t){this.a=e,this.b=t}function YBe(e,t){this.a=e,this.f=t}function ZBe(e){cJ(e.Wb()),this.c=e}function KBe(e,t){this.b=e,this.c=t}function Oi(e,t){this.f=e,this.g=t}function JBe(e,t){Oi.call(this,e,t)}function QBe(e,t){this.e=e,this.c=t}function EK(e){this.b=h(Hn(e),43)}function eOe(e){this.a=h(Hn(e),15)}function FE(e){this.a=h(Hn(e),15)}function Upe(e,t){this.a=e,this.b=t}function DEt(e,t){return e>t&&t0?e:t}function DNe(e){return qa(e.l,e.m,e.h)}function eJ(e){return e<10?"0"+e:""+e}function gSt(e){return e==J0||e==Bw}function mSt(e){return e==J0||e==Dw}function Gu(e){return Jo(e.b.b,e,0)}function BNe(e){this.a=VOe(),this.b=e}function ONe(e){this.a=VOe(),this.b=e}function Q2(e){this.a=e,oR.call(this)}function NNe(e){this.a=e,oR.call(this)}function vge(e,t){DI(e,0,e.length,t)}function FNe(e,t){return De(e.a,t),t}function bSt(e,t){return De(e.c,t),e}function UNe(e,t){return sc(e.a,t),e}function wSt(e,t){return $u(),t.a+=e}function vSt(e,t){return $u(),t.c+=e}function _St(e,t){return $u(),t.a+=e}function zNe(e){return e==_y||e==vy}function n_(e){return e==nf||e==rf}function YR(e){return e==hm||e==ip}function Dd(e){return e!=rp&&e!=ub}function ju(e){return e.eg()&&e.fg()}function V8(e){return sc(new rs,e)}function GNe(){GNe=M,Roe=new GA(mae)}function zc(){IF.call(this,new T0)}function jNe(){F9.call(this,0,0,0,0)}function $E(){Xf.call(this,0,0,0,0)}function _ge(e){pNe.call(this,e,!0)}function Io(e){this.a=e.a,this.b=e.b}function Bd(e,t,i){Xu(e,t),Yu(e,i)}function W8(e,t,i){x_(e,t),y_(e,i)}function yge(e,t,i){see(e,t),oee(e,i)}function tJ(e,t,i){CA(e,t),TA(e,i)}function nJ(e,t,i){AA(e,t),PA(e,i)}function iJ(e,t){Uee(e,t),aee(e,e.D)}function $Ne(e,t){return new bS(t,e)}function ySt(e,t){return new bS(t,e)}function Lp(e,t){return et?1:0}function qC(e){return a1e(e.b.tc(),e.a)}function Zh(e){return rA(e.a.tc(),e.b)}function VNe(e){return fu(e,0,e.length)}function H8(e){return e!=null?Wr(e):0}function Od(e){r7e.call(this,new ppe(e))}function WNe(){M8.call(this,"Head",1)}function HNe(){M8.call(this,"Tail",3)}function xge(e,t,i){xJ.call(this,e,t,i)}function xSt(e,t,i){SF(e,t.le(e.a,i))}function qNe(e,t){return parseInt(e,t)}function ESt(e,t){return SA(t,Eh(e))}function SSt(e,t){return SA(t,Eh(e))}function ex(e){F9.call(this,e,e,e,e)}function rJ(e){e.c=le(sn,nt,1,0,5,1)}function XNe(e){e.a=le(sn,nt,1,8,5,1)}function Ege(e){return e.b&&vne(e),e.a}function Sge(e){return e.b&&vne(e),e.c}function sJ(e){return e.d&&Gte(e),e.c}function oJ(e){return e.d&&Gte(e),e.b}function Mge(e){return e.d&&Gte(e),e.a}function Tge(e,t,i){return zr(e,t,i),i}function YNe(e,t,i){zr(e.c[t.g],t.g,i)}function MSt(e,t,i){return fr(e.g,i,t)}function TSt(e,t,i){return fr(e.k,i,t)}function CSt(e,t,i){Bd(i,i.i+e,i.j+t)}function ba(e,t){Yr.call(this,e.b,t)}function XC(e){vi(),kc.call(this,e)}function Bl(){Bl=M,gm=(BBe(),klt)}function zn(){zn=M,new ZNe,new Re}function ZNe(){new li,new li,new li}function So(){So=M,Tnt=new te,n3e=new se}function i_(){i_=M,d5=new fOe,p5=new LNe}function iu(){iu=M,Qxe=iMt(new LR(Ta))}function Xr(){Xr=M,new vY((iu(),"="))}function q8(e){e.j=le(b3e,be,287,0,0,1)}function KNe(e){this.a=e,Rme.call(this,e)}function ASt(e){return e==null?0:Wr(e)}function YC(e){return e==null?qc:za(e)}function po(e,t){return e.charCodeAt(t)}function VE(e,t,i){return Pge(e,bc(t),i)}function qa(e,t,i){return{l:e,m:t,h:i}}function Yo(e){return e.at-1?0:t-1}function XSt(e,t,i){return i?t!=0:t!=e-1}function fJ(e,t,i){return e.a[t.g][i.g]}function YSt(e,t){return e.e[t.c.o][t.o]}function ZSt(e,t){return e.a[t.c.o][t.o]}function Wf(e,t){return e.a[t.c.o][t.o]}function KSt(e,t){return e.j[t.o]=C8t(t)}function JSt(e,t){return no(e.c.d,t.c.d)}function QSt(e,t){return no(e.c.c,t.c.c)}function eMt(e,t,i){mjt(e.a,e.b,e.c,t,i)}function tMt(e,t,i,a){zr(e.a[t.g],i.g,a)}function JC(e,t,i){return zr(e.g,t,i),i}function ou(e,t){return e.a*=t,e.b*=t,e}function nMt(e,t){e.q.setHours(t),fP(e,t)}function vs(e,t,i){uI.call(this,e,t,i)}function Z8(e,t,i){vs.call(this,e,t,i)}function Ol(e,t,i){vs.call(this,e,t,i)}function gFe(e,t,i){Z8.call(this,e,t,i)}function Rge(e,t,i){b9.call(this,e,t,i)}function mFe(e,t,i){b9.call(this,e,t,i)}function bFe(e,t,i){Rge.call(this,e,t,i)}function wFe(e,t,i){Ige.call(this,e,t,i)}function Ige(e,t,i){uI.call(this,e,t,i)}function HE(e,t,i){uI.call(this,e,t,i)}function qE(e,t){this.a=e,MK.call(this,t)}function Dn(e){this.i=e,this.f=this.i.j}function Cg(e){this.c=e,this.a=this.c.a}function Dge(){this.Bb|=256,this.Bb|=512}function vFe(e,t){this.a=e,EK.call(this,t)}function _Fe(e,t){this.a=t,EK.call(this,e)}function Bge(e){this.b=e,this.a=this.b.a.e}function yFe(e){e.b.jc(),--e.d.f.d,k9(e.d)}function xFe(e){e.a=h(rn(e.b.a,4),116)}function EFe(e){e.a=h(rn(e.b.a,4),116)}function SFe(e){uR.call(this,h(Hn(e),34))}function MFe(e){uR.call(this,h(Hn(e),34))}function iMt(e){return Hn(qc),new e9e(e,e)}function TFe(e,t){return new iXe(e.a,e.b,t)}function Hf(e,t,i){return e.substr(t,i-t)}function rMt(e){return e==null?null:e.name}function sMt(e){return e.l+e.m*Ox+e.h*l1}function sw(e){return typeof e=="number"}function jo(e){return typeof e=="number"}function kp(e,t){return!!t&&e.b[t.g]==t}function Oge(e,t){var i;i=e[Z_],t[Z_]=i}function K8(e){Zb.call(this,e),this.a=e}function Nge(e){Nm.call(this,e),this.a=e}function KR(e){qv.call(this,e),this.a=e}function Fge(e){IF.call(this,new E0e(e))}function CFe(e){if(!e)throw Y(new P)}function kn(e){if(!e)throw Y(new K)}function Nd(e){e.o==null&&r8t(e)}function hJ(e){return kn(e.a!=null),e.a}function AFe(e,t){return De(t.a,e.a),e.a}function PFe(e,t){return De(t.b,e.a),e.a}function oMt(e,t){t&&(e.a=(f_(t),t.a))}function Uge(e,t){return fA(e.a,t)!=null}function ic(e,t){return h(Qi(e.a,t),15)}function dJ(e){return e.b=h(_Ue(e.a),38)}function p0(e){return e.$H||(e.$H=++aVt)}function pJ(e){return Yo(e.a)||Yo(e.b)}function ow(e,t){return!!e.p&&b0(e.p,t)}function aMt(e,t){return e.k.b=(pn(t),t)}function cMt(e,t){return e.k.b=(pn(t),t)}function J8(e,t){return++e.b,De(e.a,t)}function zge(e,t){return++e.b,Ea(e.a,t)}function lMt(e,t,i){return uze(e,t,i,e.b)}function Gge(e,t,i){return uze(e,t,i,e.c)}function jge(e,t){uwe.call(this,e,t,null)}function LFe(e,t){this.a=t,EK.call(this,e)}function JR(e){this.a=e,AF.call(this,e)}function kFe(){PC(),this.b=new D2(this)}function gJ(e,t){$J(),this.f=t,this.d=e}function RFe(){q8(this),z9(this),this.Pd()}function QC(e){this.d=e,Dn.call(this,e)}function tx(e){this.c=e,Dn.call(this,e)}function QR(e){this.c=e,QC.call(this,e)}function uMt(e,t,i){Yee(e.a,i),n7(e.a,t)}function $ge(e,t,i){h(II(e,t),19).nc(i)}function g0(e,t){return De(t.a,e.a),e.a}function Jh(e){var t;t=e.a,e.a=e.b,e.b=t}function eI(e,t){LC(),this.a=e,this.b=t}function Q8(e,t){Ap(),this.b=e,this.c=t}function IFe(e,t,i,a){t1e.call(this,e,t,i,a)}function e9(e,t,i){var a;a=e.fd(t),a.Bc(i)}function DFe(e,t,i){try{e[t]=i}catch{}}function t9(){t9=M,Tj=new Yr(PQe,0)}function eA(){eA=M,wL=new Sr("root")}function tA(){tA=M,vD=new MDe,new SDe}function fMt(e){return++_r,new hw(3,e)}function Qh(e){return xf(e,Ix),new zl(e)}function Vge(e){return So(),Hn(e),new R8e(e)}function hMt(e){return i_(),Fi((A7e(),Ant),e)}function BFe(e){return sS(),parseInt(e)||-1}function dMt(e,t){return vt(),e==t?0:e?1:-1}function pMt(e){return e==null?null:za(e)}function gMt(e){return e==null?null:za(e)}function tI(e){return e.f!=null?e.f:""+e.g}function mJ(e){return g1e(e.c,e.c.length)}function OFe(e){e.b=new UFe(e),e.c=new li}function Wge(e){this.q=new w.Date(aS(e))}function NFe(e){this.c=e,this.a=1,this.b=1}function Hge(e){OE(),this.b=e,this.a=!0}function FFe(){this.a=new Kv,this.b=new Kv}function UFe(e){Bme.call(this,e,null,null)}function zFe(){Oi.call(this,"POLYOMINO",0)}function nI(e){re(e,142)&&h(e,142).Xg()}function bJ(e){return kn(e.b!=0),e.a.a.c}function n9(e){return kn(e.b!=0),e.c.b.c}function Nl(e,t,i){return e.a+=t,e.b+=i,e}function mMt(e,t,i){return e.a*=t,e.b*=i,e}function iI(e,t,i){return e.a-=t,e.b-=i,e}function GFe(e,t,i){return e.a+=fu(t,0,i),e}function wJ(e){return e.a=-e.a,e.b=-e.b,e}function vJ(e){return kE(e.d.e-e.e.e)-e.a}function bMt(e,t){return e.c.nc(h(t,134))}function wMt(e,t,i){return De(t,bWe(e,i))}function vMt(e,t){return e>0?t*t/e:t*t*100}function _Mt(e,t){return e>0?t/(e*e):t*100}function yMt(e,t,i){JI(xa(e.a),t,T7e(i))}function xMt(e,t,i){JI($c(e.a),t,C7e(i))}function bl(e,t,i){nl.call(this,e,t,i,2)}function jFe(e,t){LC(),eI.call(this,e,t)}function qge(e,t){Ap(),Q8.call(this,e,t)}function $Fe(e,t){Ap(),Q8.call(this,e,t)}function VFe(e,t){Ap(),qge.call(this,e,t)}function _J(e,t){Bl(),M9.call(this,e,t)}function Xge(e,t){Bl(),M9.call(this,e,t)}function WFe(e,t){Bl(),_J.call(this,e,t)}function Yge(e,t){Bl(),_J.call(this,e,t)}function HFe(e,t){Bl(),Yge.call(this,e,t)}function qFe(e,t){Bl(),Xge.call(this,e,t)}function XFe(e,t){Bl(),M9.call(this,e,t)}function EMt(e,t,i){return t.ak(e.e,e.c,i)}function SMt(e,t,i){return t.bk(e.e,e.c,i)}function Zge(e,t,i){return B7(OI(e,t),i)}function yJ(e,t){return jg(e.e,h(t,42))}function MMt(e){return e==null?null:Pjt(e)}function TMt(e){return e==null?null:sNt(e)}function YFe(e){this.c=e,Xu(e,0),Yu(e,0)}function XE(e,t){this.c=e,NE.call(this,e,t)}function nA(e,t){this.a=e,XE.call(this,e,t)}function Kge(e){this.a=e,this.b=eUe(this.a.d)}function CMt(e,t){this.d=e,wY(this),this.b=t}function Jge(){Qje.call(this),this.Bb|=oo}function i9(){kIt.call(this,new T0,new li)}function xJ(e,t,i){TI.call(this,e,t,i,null)}function Qge(e,t,i){TI.call(this,e,t,i,null)}function ed(e,t){e.a.bd(e.b,t),++e.b,e.c=-1}function eme(e,t){var i;return i=e.e,e.e=t,i}function bt(e){return KC(e==null||rw(e)),e}function Xe(e){return KC(e==null||sw(e)),e}function Qn(e){return KC(e==null||ws(e)),e}function AMt(e,t){return Hn(e),Hn(t),LA(e,t)}function ZFe(e){return e>8?0:e+1}function KFe(e){tl(e.c),e.b.b=e.b,e.b.a=e.b}function JFe(e,t){BGe.call(this,e),this.a=t}function si(e,t){BGe.call(this,e),this.a=t}function PMt(e){nwe.call(this,0,0),this.f=e}function EJ(e){var t;t=e[Z_]|0,e[Z_]=t+1}function LMt(e,t,i){return e.Ld(t,i)<=0?i:t}function kMt(e,t){return h(px(e.b,t),180)}function RMt(e,t){return h(px(e.c,t),199)}function SJ(e){return h(Tt(e.a,e.b),269)}function QFe(e){return new $t(e.c,e.d+e.a)}function tme(e){return zg(_At(jo(e)?uu(e):e))}function e8e(e){return wl(),zNe(h(e,179))}function Gm(){Gm=M,xAe=Wt((Wl(),C1))}function r9(){r9=M,w.Math.pow(2,-65)}function rI(e,t,i){++e.j,e.Yh(),GQ(e,t,i)}function t8e(e,t,i){++e.j,e.Vh(t,e.Ch(t,i))}function nme(e,t,i){return i=Sl(e,t,3,i),i}function ime(e,t,i){return i=Sl(e,t,6,i),i}function rme(e,t,i){return i=Sl(e,t,9,i),i}function Fd(e,t){return tQ(t,fxe),e.f=t,e}function sme(e,t){return(t&zi)%e.d.length}function IMt(e,t){return RR(),MS(t.d.g,e)}function n8e(e,t){return fr(e.a,t,"")==null}function i8e(e,t,i){return E_e(e.c,e.b,t,i)}function DMt(e,t,i){var a;a=e.fd(t),a.Bc(i)}function r8e(e,t){this.a=e,KZ.call(this,t)}function sI(e,t){this.a=e,KZ.call(this,t)}function s8e(e,t){this.c=e,w_.call(this,t)}function o8e(e){this.b=e,this.a=this.b.b.Tb()}function ome(e,t){e8.call(this,e),this.a=t}function MJ(e,t){e8.call(this,e),this.a=t}function Yr(e,t){Sr.call(this,e),this.a=t}function o_(e,t){ka.call(this,RP+e+_z+t)}function s9(){Y3t.call(this,new li),this.a=3}function oI(e){return!e.a&&(e.a=new st),e.a}function o9(e){e.b?o9(e.b):e.f.c.Zb(e.e,e.d)}function a8e(e){this.a=(yt(),new fC(Hn(e)))}function Ag(e,t){if(!e)throw Y(new ma(t))}function ame(e,t){if(!e)throw Y(new un(t))}function cme(e,t,i){return e.lastIndexOf(t,i)}function BMt(e,t,i){return e.apply(t,i);var a}function TJ(e,t,i){return nx(e,h(t,23),i)}function OMt(e,t){return vK($We(e.a,t,!0))}function NMt(e,t){return vK(VWe(e.a,t,!0))}function c8e(e){return new xBe((f_(e),e.a))}function CJ(e){return String.fromCharCode(e)}function FMt(e){return e==null?null:e.message}function UMt(e,t){e.e=t,t!=null&&DFe(t,jne,e)}function zMt(e,t,i){return no(e[t.b],e[i.b])}function lme(e,t,i,a){F9.call(this,e,t,i,a)}function aI(e){qRt.call(this,e,(uU(),nse))}function GMt(e,t){return e.k.a=(pn(t),t+10)}function jMt(e,t){return e.k.a=(pn(t),t+10)}function $Mt(e,t){return RR(),!MS(t.d.g,e)}function l8e(){l8e=M,h3e=le(Ao,be,21,256,0,1)}function vt(){vt=M,Y0=(vt(),!1),sM=!0}function u8e(){this.b=new fo,this.c=new Re}function ume(){this.d=new fo,this.e=new fo}function fme(){this.k=new fo,this.n=new fo}function f8e(){this.b=new ABe,this.a=new hq}function h8e(){this.b=new li,this.a=new li}function d8e(){this.b=new Ur,this.a=new Ur}function p8e(){this.a=new Re,this.d=new Re}function g8e(){this.a=new Re,this.b=new Re}function m8e(){this.a=new $i,this.b=new iK}function b8e(){this.a=new l8,this.c=new Cs}function a9(){this.n=new G2,this.i=new $E}function w8e(){a9.call(this),this.a=new fo}function hme(e,t,i){return i=Sl(e,t,11,i),i}function tr(e,t){return e.a+=t.a,e.b+=t.b,e}function Dc(e,t){return e.a-=t.a,e.b-=t.b,e}function VMt(e,t){var i;return i=t.Yg(e.a),i}function dme(e,t){return h(e.b.cd(t),190).a}function WMt(e,t){return t==e||QA(E7(t),e)}function HMt(e){return e<100?null:new Eg(e)}function qMt(e,t,i){i!=null&&Q0e(t,yte(e,i))}function XMt(e,t,i){i!=null&&ebe(t,yte(e,i))}function YE(e,t,i,a){ze.call(this,e,t,i,a)}function pme(e,t,i,a){ze.call(this,e,t,i,a)}function v8e(e,t,i,a){pme.call(this,e,t,i,a)}function _8e(e,t,i,a){D9.call(this,e,t,i,a)}function AJ(e,t,i,a){D9.call(this,e,t,i,a)}function gme(e,t,i,a){D9.call(this,e,t,i,a)}function y8e(e,t,i,a){AJ.call(this,e,t,i,a)}function mme(e,t,i,a){AJ.call(this,e,t,i,a)}function an(e,t,i,a){gme.call(this,e,t,i,a)}function x8e(e,t,i,a){mme.call(this,e,t,i,a)}function E8e(e,t,i,a){o1e.call(this,e,t,i,a)}function S8e(e,t,i){this.a=e,Npe.call(this,t,i)}function YMt(e,t,i){return e.d=h(t.Kb(i),206)}function M8e(e,t){return e.Pi().dh().Zg(e,t)}function bme(e,t){return e.Pi().dh()._g(e,t)}function PJ(e,t){return So(),bIt(e.tc(),t)!=-1}function ZMt(e,t){return Xr(),new LFe(e.tc(),t)}function c9(e){return So(),e.hc()?e.ic():null}function wme(e){return sw(e)?(pn(e),e):e.$d()}function l9(e){return!isNaN(e)&&!isFinite(e)}function vme(e){aw(),this.b=(yt(),new qv(e))}function aw(){aw=M,new iY((yt(),yt(),uo))}function T8e(){T8e=M,Qlt=le(sn,nt,1,0,5,1)}function _me(){_me=M,eut=le(sn,nt,1,0,5,1)}function C8e(){C8e=M,Nlt=le(sn,nt,1,0,5,1)}function A8e(){A8e=M,u3e=le(Hx,be,192,256,0,1)}function P8e(){P8e=M,d3e=le(Z0,be,149,256,0,1)}function L8e(){L8e=M,m3e=le(K0,be,168,256,0,1)}function k8e(){k8e=M,f3e=le($P,be,159,128,0,1)}function R8e(e){this.b=e,this.a=(So(),So(),n3e)}function I8e(e){this.b=e,j8.call(this,V7,0)}function D8e(e){this.c=e,j8.call(this,V7,0)}function B8e(e){return e.c?Jo(e.c.a,e,0):-1}function LJ(e,t){return vK(VWe(e.a,t,!1))}function kJ(e,t){return vK($We(e.a,t,!1))}function a_(e,t){return e.b.sd(new Hpe(e,t))}function O8e(e,t){return e.b.sd(new bOe(e,t))}function u9(e,t){if(!e)throw Y(new un(t))}function yme(e,t){if(!e)throw Y(new ODe(t))}function xme(e,t){a8(this),this.e=e,this.f=t}function Eme(){a8(this),this.e=0,this.f=!0}function Sme(e,t){this.c=e,KJ.call(this,e,t)}function N8e(e,t){return re(t,15)&&iZe(e.c,t)}function f9(e,t,i){return h(e.c,64).yj(t,i)}function KMt(e,t,i){return h(e.c,64).xj(t,i)}function JMt(e,t,i){return EMt(e,h(t,311),i)}function Mme(e,t,i){return SMt(e,h(t,311),i)}function QMt(e,t,i){return bqe(e,h(t,311),i)}function F8e(e,t,i){return FOt(e,h(t,311),i)}function eTt(e,t){return Kh(),$n(ye(e.a),t)}function tTt(e,t){return Kh(),$n(ye(e.a),t)}function nTt(e){return So(),v8(e.a)?gze(e):null}function U8e(e,t){return e.b.Qb(t)?lUe(e,t):null}function cI(e,t){return e.substr(t,e.length-t)}function z8e(e){return h(e,11).f.c.length!=0}function G8e(e){return h(e,11).d.c.length!=0}function iA(e){return e==d3||e==wd||e==Ba}function j8e(e){_f(e.a),IGe(e.c,e.b),e.b=null}function wf(e){rJ(this),Nme(this.c,0,e.yc())}function h9(e){eFe(this),id(this),wo(this,e)}function $8e(e,t,i){this.d=e,this.b=i,this.a=t}function Bc(e,t,i){this.a=e,this.b=t,this.c=i}function V8e(e,t,i){this.a=e,this.b=t,this.c=i}function W8e(e,t,i){this.c=e,this.a=t,this.b=i}function iTt(e,t,i,a){e.d.b.$b(i),e.d.b.Zb(a,t)}function rA(e,t){return So(),Hn(t),new _Fe(e,t)}function rTt(e){return KU(),Fi((xze(),eit),e)}function sTt(e){return dU(),Fi((Eze(),tit),e)}function oTt(e){return uU(),Fi((WGe(),Xnt),e)}function aTt(e){return Wg(),Fi((eGe(),Ynt),e)}function cTt(e){return A7(),Fi((q$e(),nit),e)}function lTt(e){return Ex(),Fi((XGe(),rit),e)}function uTt(e){return YA(),Fi((YGe(),oit),e)}function fTt(e){return b8(),Fi((Z7e(),ait),e)}function hTt(e){return gU(),Fi((Sze(),Sit),e)}function dTt(e){return xA(),Fi((bGe(),Bit),e)}function pTt(e){return _o(),Fi((mje(),Uit),e)}function gTt(e){return _S(),Fi((qGe(),Vit),e)}function mTt(e){return qt(),Fi((y$e(),Jit),e)}function RJ(e){F9.call(this,e.d,e.c,e.a,e.b)}function Tme(e){F9.call(this,e.d,e.c,e.a,e.b)}function bTt(e){return NA(),Fi((wGe(),nrt),e)}function wTt(e){return Co(),Fi((HOe(),irt),e)}function vTt(e){return JA(),Fi((pje(),urt),e)}function _Tt(e){return sU(),Fi((Mze(),frt),e)}function yTt(e){return LS(),Fi((Vje(),hrt),e)}function xTt(e){return ux(),Fi((Tze(),drt),e)}function ETt(e){return wU(),Fi((cGe(),prt),e)}function STt(e){return EU(),Fi((aGe(),grt),e)}function MTt(e){return M_(),Fi((lGe(),brt),e)}function TTt(e){return d7(),Fi((Gje(),wrt),e)}function CTt(e){return g6(),Fi((jje(),vrt),e)}function ATt(e){return RS(),Fi(($je(),_rt),e)}function PTt(e){return xo(),Fi((wVe(),yrt),e)}function LTt(e){return mS(),Fi((gGe(),xrt),e)}function kTt(e){return Wd(),Fi((mGe(),Srt),e)}function RTt(e){return Q9(),Fi((Cze(),Mrt),e)}function ITt(e){return hu(),Fi((gje(),Crt),e)}function DTt(e){return u7(),Fi((Wje(),not),e)}function BTt(e){return ww(),Fi((HGe(),iot),e)}function OTt(e){return XA(),Fi((dje(),rot),e)}function NTt(e){return G_(),Fi((B$e(),sot),e)}function FTt(e){return Bo(),Fi((uGe(),aot),e)}function UTt(e){return WU(),Fi((fGe(),cot),e)}function zTt(e){return yU(),Fi((hGe(),lot),e)}function GTt(e){return bx(),Fi((pGe(),uot),e)}function jTt(e){return LU(),Fi((dGe(),fot),e)}function Cme(e,t){for(;e.b.sd(new Hpe(e,t)););}function d9(e,t,i){this.b=e,this.a=t,this.c=i}function Ame(e,t,i){this.a=e,this.b=t,this.c=i}function H8e(e,t,i){this.a=e,this.b=t,this.c=i}function p9(e,t,i){this.e=t,this.b=e,this.d=i}function IJ(e){var t;return t=new DT,t.e=e,t}function $Tt(e){return!e.e&&(e.e=new Re),e.e}function $u(){$u=M,ort=new WH,art=new kk}function DJ(){DJ=M,P3e=new qi,qnt=new Te}function lI(){lI=M,nG=new nc,iG=new EH}function VTt(e){return wA(),Fi((Oze(),kot),e)}function WTt(e){return L0(),Fi((vGe(),Cot),e)}function HTt(e){return AS(),Fi((ZGe(),Mat),e)}function qTt(e){return nP(),Fi((Fje(),Cat),e)}function XTt(e){return xh(),Fi((Pze(),Fot),e)}function YTt(e){return Zf(),Fi((Aze(),zot),e)}function ZTt(e){return RI(),Fi((Lze(),jot),e)}function KTt(e){return cl(),Fi((qOe(),mat),e)}function JTt(e){return KI(),Fi((yGe(),Hat),e)}function QTt(e){return lU(),Fi((Bze(),Wat),e)}function eCt(e){return E0(),Fi((kze(),Sat),e)}function tCt(e){return W9(),Fi((Ize(),Oat),e)}function nCt(e){return q9(),Fi((Dze(),Nat),e)}function iCt(e){return vU(),Fi((Rze(),jat),e)}function rCt(e){return VU(),Fi((_Ge(),Vat),e)}function sCt(e){return i7(),Fi((KGe(),nct),e)}function oCt(e){return SU(),Fi((xGe(),ict),e)}function aCt(e){return i1(),Fi((wje(),sct),e)}function cCt(e){return o1(),Fi((O$e(),act),e)}function lCt(e){return ld(),Fi((Uje(),cct),e)}function uCt(e){return Jf(),Fi((EGe(),Oct),e)}function fCt(e){return Fe(),Fi((sje(),Nct),e)}function hCt(e){return Ms(),Fi((Lje(),Bct),e)}function dCt(e){return e1(),Fi((MGe(),Rct),e)}function pCt(e){return a1(),Fi((Y$e(),Ict),e)}function gCt(e){return Xg(),Fi((bje(),Dct),e)}function mCt(e){return Xs(),Fi((vje(),Cct),e)}function bCt(e){return Xd(),Fi((JGe(),Act),e)}function wCt(e){return cd(),Fi((QGe(),Pct),e)}function vCt(e){return f7(),Fi((zje(),Lct),e)}function _Ct(e){return Wl(),Fi((eje(),jct),e)}function yCt(e){return ac(),Fi((X$e(),$ct),e)}function xCt(e){return XU(),Fi((nje(),Vct),e)}function ECt(e){return yl(),Fi((ije(),qct),e)}function SCt(e){return yf(),Fi((SGe(),Yct),e)}function MCt(e){return il(),Fi((TGe(),Kct),e)}function TCt(e){return Oc(),Fi((CGe(),Qct),e)}function CCt(e){return U7(),Fi((CNe(),xlt),e)}function ACt(e){return R0(),Fi((tje(),Slt),e)}function PCt(e){return DS(),Fi((N$e(),Olt),e)}function BJ(e,t,i){return e=t)throw Y(new o8)}function nAt(e,t){var i;for(i=0;i0?1:0}function Xme(e){return!Array.isArray(e)&&e.sl===T}function P9e(e){return e!=null&&XJ(e)&&e.sl!==T}function Yme(e,t){return re(t,23)&&kp(e,h(t,23))}function L9e(e,t){return re(t,23)&&iRt(e,h(t,23))}function oAt(e,t){return e.a.get(t)!==void 0}function Zme(e){return ol(e,26)*bP+ol(e,27)*wP}function k9e(e,t){return dRt(new _n,new yY(e),t)}function Kme(e,t){if(e==null)throw Y(new EC(t))}function nx(e,t,i){return _l(e.a,t),c1e(e,t.g,i)}function A9(e,t,i){RVe(0,t,e.length),DI(e,0,t,i)}function w0(e,t,i){g_(t,e.c.length),UR(e.c,t,i)}function aAt(e,t,i){sYe(i,e,1),De(t,new AOe(i,e))}function cAt(e,t,i){ZA(i,e,1),De(t,new MOe(i,e))}function Jme(){this.d=new hi,this.e=new WUe(this)}function R9e(){this.b=new en,this.c=new VUe(this)}function I9e(){u7e(),this.e=new Ir,this.d=new Ir}function jJ(e,t){this.b=new Ir,this.a=e,this.c=t}function l_(e,t,i){Kg(),this.e=e,this.d=t,this.a=i}function P9(e,t,i){var a;e&&(a=e.i,a.d=t,a.a=i)}function L9(e,t,i){var a;e&&(a=e.i,a.c=t,a.b=i)}function D9e(e,t,i){var a;for(a=0;a0?w.Math.log(e/t):-100}function SAt(e,t){return no(e.c.c+e.c.b,t.c.c+t.c.b)}function KJ(e,t){this.d=e,Dn.call(this,e),this.e=t}function lw(e,t,i){return yIt(e,t.g,i),_l(e.c,t),e}function MAt(e){return W_(e,(Xs(),nf)),e.d=!0,e}function Hn(e){if(e==null)throw Y(new N2);return e}function ix(e){if(e==null)throw Y(new N2);this.a=e}function JJ(e){e.a=null,e.e=null,tl(e.b),e.d=0,++e.c}function QJ(e){return!e.j&&Gde(e,qUt(e.g,e.b)),e.j}function TAt(e){return e.b.k.a+=e.a.f*(e.a.a-1),null}function cA(e){s_(e.b!=-1),A0(e.c,e.a=e.b),e.b=-1}function q9e(e){XNe(this),nK(this.a,gbe(8>e?8:e)<<1)}function h1e(e,t){kc.call(this,1),this.a=e,this.b=t}function eQ(e,t,i){this.a=e,IQ(i,t),this.c=t,this.b=i}function X9e(e,t){this.a=e,this.b=t,this.c=this.b.lc()}function gI(e,t){uFe(e,re(t,184)?t:h(t,1630).rk())}function Y9e(e){return Hn(e),re(e,476)?h(e,476):za(e)}function d1e(e,t){return t?wo(e,t):!1}function KE(e,t){return e.a+=String.fromCharCode(t),e}function Lg(e,t){return e.a+=String.fromCharCode(t),e}function CAt(e,t,i,a){return e.a+=""+t.substr(i,a-i),e}function AAt(e,t,i){var a;return a=gx(e,t),Nze(e,t,i),a}function PAt(e,t,i){var a;for(a=0;a=e.g}function VAt(e,t){return cx(),e==s1(t)?F0(t):s1(t)}function fr(e,t,i){return ws(t)?Zo(e,t,i):xl(e.d,t,i)}function rQ(e,t,i){var a;return a=hee(e,t,i),r_e(e,a)}function uA(e,t){var i;return i=e.a._b(),DLt(t,i),i-1-t}function w1e(e,t){var i;return i=new EI(e),qbe(i,t),i}function zr(e,t,i){return GSt(i==null||A7t(e,i)),e[t]=i}function sx(e,t){var i;i=e.a.length,gx(e,i),Nze(e,i,t)}function iUe(e,t){var i;++e.j,i=e.hi(),e.Wh(e.Ch(i,t))}function WAt(e,t){sx(e,new ix(t.f!=null?t.f:""+t.g))}function HAt(e,t){sx(e,new ix(t.f!=null?t.f:""+t.g))}function rUe(e){this.b=new Re,this.a=new Re,this.c=e}function cu(e){this.c=new fo,this.a=new Re,this.b=e}function sUe(e){ume.call(this),this.a=new fo,this.c=e}function v1e(e,t,i){vC.call(this,t),this.a=e,this.b=i}function _1e(e,t,i){kc.call(this,e),this.a=t,this.b=i}function y1e(e,t,i){this.a=e,e8.call(this,t),this.b=i}function oUe(e,t,i){this.a=e,e0e.call(this,8,t,null,i)}function aUe(e){this.c=e,this.a=new Ir,this.b=new Ir}function cUe(e){this.c=e,this.b=this.c.a,this.a=this.c.e}function qAt(e){this.a=(pn(Kn),Kn),this.b=e,new fpe}function _0(e){return!e.d&&(e.d=new vs(Lo,e,1)),e.d}function lUe(e,t){var i;return i=e.b.$b(t),e.d.b.$b(i),i}function x1e(e,t){for(;t-- >0;)e=e<<1|(e<0?1:0);return e}function Ip(e,t){return Be(e)===Be(t)||e!=null&&Li(e,t)}function y0(e,t){return oA(t,e.a.c.length),Tt(e.a,t)}function sQ(e){return w.Math.sqrt(e.a*e.a+e.b*e.b)}function XAt(e){return String.fromCharCode.apply(null,e)}function Dp(e){return re(e,13)?h(e,13)._b():vA(e.tc())}function uUe(e){return re(e,543)?e:new uOe(e)}function wa(e){return!e.a&&e.c?e.c.b:e.a}function oQ(e){e.c?oQ(e.c):(e.d=!0,b9t(e))}function f_(e){e.c?f_(e.c):(SS(e),e.d=!0)}function fUe(e){bI(e.a),e.b=le(sn,nt,1,e.b.length,5,1)}function aQ(e){this.c=e,this.b=e.a.b.a,Oge(e.a.c,this)}function YAt(e,t){e.c<0||e.b.b0?new xme(e-1,t):new xme(e,t)}function wUe(e,t){return m9(),new dwe(new MFe(e),new SFe(t))}function tS(e){if(sl(e.d),e.d.d!=e.c)throw Y(new P)}function rPt(e,t){var i;return i=e.a.get(t),i??[]}function sPt(e,t){var i;return i=Ii(e.f,t),lbe(t,i),null}function ui(e,t,i,a){return Q$e(e,t,i,!1),Fbe(e,a),e}function oPt(e,t){return e.a=Hf(e.a,0,t)+""+cI(e.a,t+1),e}function aPt(e){return e.j.c=le(sn,nt,1,0,5,1),e.a=-1,e}function cPt(e){return!e.c&&(e.c=new an(gi,e,5,8)),e.c}function lPt(e){return!e.b&&(e.b=new an(gi,e,4,7)),e.b}function uQ(e){return!e.n&&(e.n=new ze(Qo,e,1,7)),e.n}function C1e(e){return!e.c&&(e.c=new ze(Au,e,9,9)),e.c}function nS(e){return e.e==nM&&Ude(e,S5t(e.g,e.b)),e.e}function mI(e){return e.f==nM&&zde(e,JDt(e.g,e.b)),e.f}function vUe(e){return KC(e==null||XJ(e)&&e.sl!==T),e}function A1e(e,t){if(e==null)throw Y(new EC(t));return e}function uw(e){var t;return t=e.b,!t&&(e.b=t=new uY(e)),t}function P1e(e){var t;return t=e.Gh(e.f),$n(e,t),t.hc()}function bI(e){var t;for(t=e.tc();t.hc();)t.ic(),t.jc()}function _Ue(e){return kn(e.ba&&++a,a}function jd(e){var t,i;return i=(t=new xg,t),MA(i,e),i}function dQ(e){var t,i;return i=(t=new xg,t),kqe(i,e),i}function pPt(e){if(e.p!=5)throw Y(new Ha);return nr(e.f)}function gPt(e){if(e.p!=5)throw Y(new Ha);return nr(e.k)}function LUe(e){return e?e.Wb():!null.tc().hc()}function z9(e){return e.n&&(e.e!==kJe&&e.Pd(),e.j=null),e}function mPt(e){return e!=null&&RC(Bj,e.toLowerCase())}function pQ(e){this.f=e,this.c=this.f.e,e.f>0&&eqe(this)}function Vm(e,t,i,a){this.e=e,this.a=t,this.c=i,this.d=a}function kUe(e,t,i,a){Bl(),nGe.call(this,t,i,a),this.a=e}function RUe(e,t,i,a){Bl(),nGe.call(this,t,i,a),this.a=e}function IUe(e,t,i,a){this.b=e,this.c=a,j8.call(this,t,i)}function DUe(e,t){this.a=e,CMt.call(this,e,h(e.d,15).fd(t))}function id(e){e.a.a=e.c,e.c.b=e.a,e.a.b=e.c.a=null,e.b=0}function k1e(e,t){return e.b=t.b,e.c=t.c,e.d=t.d,e.a=t.a,e}function bPt(e,t,i){e.i=0,e.e=0,t!=i&&EVe(e,t,i)}function wPt(e,t,i){e.i=0,e.e=0,t!=i&&SVe(e,t,i)}function BUe(e,t){var i;return i=qQ(t),h(Ii(e.c,i),21).a}function vPt(e,t,i){return i>=0&&pt(e.substr(i,t.length),t)}function gQ(e,t){return t==null?!!pc(e.d,null):oAt(e.e,t)}function OUe(e,t){e.d&&!e.d.a&&(tK(e.d,t),OUe(e.d,t))}function NUe(e,t){e.e&&!e.e.a&&(tK(e.e,t),NUe(e.e,t))}function FUe(e,t){this.g=e,this.d=X(q(xu,1),Tf,8,0,[t])}function R1e(e,t){new Ir,this.a=new Uc,this.b=e,this.c=t}function UUe(){ove(this,new hF),this.wb=(kg(),At),RE()}function zUe(e,t){return re(t,166)&&pt(e.b,h(t,166).Lf())}function _Pt(e,t){return rl(e),rl(t),$De(h(e,23),h(t,23))}function I1e(e,t,i,a,l,f){VGe.call(this,e,t,i,a,l,f?-2:-1)}function GUe(e,t,i,a){pge.call(this,t,i),this.b=e,this.a=a}function jUe(e,t){Z3t.call(this,new WJ(e)),this.a=e,this.b=t}function D1e(e){this.b=e,this.c=e,e.e=null,e.c=null,this.a=1}function $Ue(e,t){var i;return i=Um(e.ql),t==null?i:i+": "+t}function Zr(e,t){return zg(hAt(jo(e)?uu(e):e,jo(t)?uu(t):t))}function Yf(e,t){return zg(dAt(jo(e)?uu(e):e,jo(t)?uu(t):t))}function yPt(e,t){return zg(pAt(jo(e)?uu(e):e,jo(t)?uu(t):t))}function B1e(e){return e&&e.hashCode?e.hashCode():p0(e)}function iS(e){return yt(),re(e,49)?new bK(e):new K8(e)}function yt(){yt=M,uo=new Qe,Qd=new xt,$z=new fn}function rS(){rS=M,C3e=new Xt,jnt=new Xt,A3e=new wn}function O1e(){O1e=M,Knt=new yn,Qnt=new Jme,Jnt=new Sn}function sS(){sS=M;var e,t;t=!a5t(),e=new H,Zre=t?new O:e}function VUe(e){this.c=e,this.b=new tw(h(Hn(new Kt),65))}function WUe(e){this.c=e,this.b=new tw(h(Hn(new yi),65))}function Bp(){this.a=new Uc,this.b=(xf(3,Ix),new zl(3))}function mQ(e,t,i){this.a=e,this.e=!1,this.d=t,this.c=i}function HUe(e,t,i){return e.f?e.f.re(t,i):!1}function ye(e){return!e.s&&(e.s=new ze(Ec,e,21,17)),e.s}function Ni(e){return!e.q&&(e.q=new ze(lf,e,11,10)),e.q}function N1e(e){return!e.a&&(e.a=new ze(Br,e,10,11)),e.a}function xPt(e,t){var i;return i=Lge(e.a,t),i&&(t.d=null),i}function h_(e,t,i,a){zr(e.c[t.g],i.g,a),zr(e.c[i.g],t.g,a)}function G9(e,t,i,a){zr(e.c[t.g],t.g,i),zr(e.b[t.g],t.g,a)}function ox(e,t,i){tU(),e&&fr(Lae,e,t),e&&fr(bD,e,i)}function EPt(e,t){dFe(e,nr(Zr(Pg(t,24),H7)),nr(Zr(t,H7)))}function rc(e){var t;return t=h(rn(e,16),24),t||e.Rg()}function SPt(e){if(e.p!=0)throw Y(new Ha);return kC(e.f,0)}function MPt(e){if(e.p!=0)throw Y(new Ha);return kC(e.k,0)}function Do(e){return e.u||(lu(e),e.u=new r8e(e,e)),e.u}function TPt(e){return e==np||e==Yp}function CPt(e){h8(),w.setTimeout(function(){throw e},0)}function bQ(e){this.c=e.c,this.d=e.d,this.b=e.b,this.a=e.a}function Op(e,t){this.e=e,this.a=sn,this.b=_Ze(t),this.c=t}function qUe(){this.b=new Ur,this.c=new Ir,this.d=new sK}function xh(){xh=M,ib=new ige(XS,0),Xp=new ige(qS,1)}function E0(){E0=M,um=new cge(qS,0),xy=new cge(XS,1)}function XUe(){XUe=M,aw(),t3e=(Go(),Pnt),Mnt=new M1e(new tw(t3e))}function APt(e){return XUe(),Hn(e),t3e==e?Mnt:new M1e(new tw(e))}function Wm(e,t,i,a,l,f,g){return new kQ(e.e,t,i,a,l,f,g)}function YUe(e,t,i,a,l,f){this.a=e,lee.call(this,t,i,a,l,f)}function ZUe(e,t,i,a,l,f){this.a=e,lee.call(this,t,i,a,l,f)}function F1e(e){this.e=e,this.b=this.e.a.entries(),this.a=[]}function U1e(e){e.d=e.d-15,e.b=e.b-15,e.c=e.c+15,e.a=e.a+15}function KUe(e,t){var i;i=h(L0e(e.e,t),249),i&&(e.d=!0)}function Ua(e,t){return t==null?Ic(pc(e.d,null)):NC(e.e,t)}function pc(e,t){return TVe(e,t,rPt(e,t==null?0:e.b.he(t)))}function JUe(e,t){return t===e?"(this Map)":t==null?qc:za(t)}function PPt(e,t){return e.a?t.pg().tc():h(t.pg(),64).oh()}function vI(e,t,i){return e.a=Hf(e.a,0,t)+(""+i)+cI(e.a,t),e}function Hm(e,t){if(t==null)throw Y(new N2);return m5t(e,t)}function LPt(){return KU(),X(q(G3e,1),Oe,391,0,[rse,z3e])}function kPt(){return dU(),X(q($3e,1),Oe,390,0,[j3e,sse])}function RPt(){return gU(),X(q(dEe,1),Oe,387,0,[hse,Kz])}function IPt(){return sU(),X(q(xSe,1),Oe,386,0,[ySe,Gse])}function DPt(){return ux(),X(q(MSe,1),Oe,317,0,[M5,S5])}function BPt(){return Q9(),X(q(VSe,1),Oe,383,0,[noe,$Se])}function OPt(){return q9(),X(q(HTe,1),Oe,388,0,[$oe,WTe])}function NPt(){return W9(),X(q(VTe,1),Oe,438,0,[joe,$Te])}function FPt(){return vU(),X(q(qTe,1),Oe,447,0,[sj,wM])}function UPt(){return RI(),X(q(kTe,1),Oe,437,0,[LTe,ZG])}function zPt(){return xh(),X(q(Not,1),Oe,466,0,[ib,Xp])}function GPt(){return Zf(),X(q(Uot,1),Oe,465,0,[M1,rh])}function jPt(){return E0(),X(q(Eat,1),Oe,417,0,[um,xy])}function $Pt(){return wA(),X(q(Lot,1),Oe,472,0,[fL,uL])}function VPt(){return lU(),X(q(YTe,1),Oe,389,0,[XTe,qoe])}function j9(e,t,i,a){return i>=0?e.Dg(t,i,a):e.lg(null,i,a)}function WPt(e,t){var i;i=h(nn(t,(eA(),wL)),35),sKe(e,i)}function wQ(e){var t;return t=au(e.b),wo(t,e.c),wo(t,e.i),t}function z1e(e){return Be(e.a)===Be((bee(),Iae))&&aGt(e),e.a}function QUe(e){return e.b.b==0?e.a.Be():FJ(e.b)}function G1e(e){var t;return t=e.g,h(t||(e.g=new gF(e)),15)}function Zf(){Zf=M,M1=new rge(ore,0),rh=new rge("UP",1)}function vQ(e,t){Pde(this,new $t(e.a,e.b)),Lde(this,au(t))}function e7e(e,t){a9.call(this),j0e(this),this.a=e,this.c=t}function j1e(e,t,i){Bl(),vC.call(this,t),this.a=e,this.b=i}function _Q(e,t,i){vi(),kc.call(this,e),this.b=t,this.a=i}function HPt(e,t){var i=Yre[e.charCodeAt(0)];return i??e}function qPt(e,t){var i;return i=Ykt(e.f,t),tr(wJ(i),e.f.d)}function t7e(e){var t;t=e.c.b.b,e.b=t,e.a=e.c.b,t.a=e.c.b.b=e}function XPt(e){return e.b==0?null:(kn(e.b!=0),qu(e,e.a.a))}function YPt(e){return io(Gd(Vc(ol(e,32)),32),Vc(ol(e,32)))}function n7e(e){return re(e,62)&&(h(h(e,17),62).Bb&Ka)!=0}function wr(e){return Math.max(Math.min(e,zi),-2147483648)|0}function $9(e,t){return n0e(t),ykt(e,le(Rn,ii,22,t,15,1),t)}function ZPt(e,t){return cx(),e==to(s1(t))||e==to(F0(t))}function i7e(e){var t;return t=rU(e),"n_"+(t??""+e.o)}function r7e(e){this.b=(So(),So(),So(),Tnt),this.a=h(Hn(e),43)}function s7e(e){a9.call(this),j0e(this),this.a=e,this.c=!0}function o7e(e,t,i){this.d=e,this.b=new Re,this.c=t,this.a=i}function yQ(e,t,i,a){var l;l=new w8e,t.a[i.g]=l,nx(e.b,a,l)}function a7e(e,t){var i=e.a=e.a||[];return i[t]||(i[t]=e._d(t))}function _I(e,t){var i;i=e.q.getHours(),e.q.setDate(t),fP(e,i)}function c7e(e){var t;return t=new m8(Eee(e.length)),qI(t,e),t}function KPt(e){function t(){}return t.prototype=e||{},new t}function JPt(e,t){return nVe(e,t)?(e$e(e),!0):!1}function V9(e){return e.Db>>16!=3?null:h(e.Cb,35)}function Eh(e){return e.Db>>16!=9?null:h(e.Cb,35)}function QPt(e){if(e.p!=2)throw Y(new Ha);return nr(e.f)&Gr}function eLt(e){if(e.p!=2)throw Y(new Ha);return nr(e.k)&Gr}function W9(){W9=M,joe=new lge(HQe,0),$Te=new lge("FAN",1)}function xQ(e,t,i){var a;a=xVe(e,t,i),e.b=new dee(a.c.length)}function Zo(e,t,i){return t==null?xl(e.d,null,i):I0(e.e,t,i)}function $1e(e,t){return n1(io(n1(h(e,149).a).a,h(t,149).a))}function l7e(){l7e=M,PTe=wUe(He(1),He(4)),ATe=wUe(He(1),He(2))}function u7e(){u7e=M,dot=Gc(new rs,(_o(),Ho),(Co(),hG))}function f7e(){f7e=M,hot=Gc(new rs,(_o(),Ho),(Co(),hG))}function h7e(){h7e=M,Rot=Ci(new rs,(_o(),Ho),(Co(),XP))}function wl(){wl=M,Bot=Ci(new rs,(_o(),Ho),(Co(),XP))}function d7e(){d7e=M,Oot=Ci(new rs,(_o(),Ho),(Co(),XP))}function EQ(){EQ=M,Got=Ci(new rs,(_o(),Ho),(Co(),XP))}function p7e(){p7e=M,Fat=Gc(new rs,(AS(),pL),(nP(),Ioe))}function g7e(e){return e.Db>>16!=6?null:h(e.Cb,105)}function m7e(e){return e.Db>>16!=7?null:h(e.Cb,207)}function b7e(e){return e.Db>>16!=7?null:h(e.Cb,253)}function to(e){return e.Db>>16!=11?null:h(e.Cb,35)}function fw(e){return e.Db>>16!=17?null:h(e.Cb,24)}function w7e(e){return e.Db>>16!=3?null:h(e.Cb,139)}function oS(e){return e.Db>>16!=6?null:h(e.Cb,207)}function dA(e,t,i,a,l,f){return new Vd(e.e,t,e.pi(),i,a,l,f)}function V1e(e,t){return L9e(e.a,t)?c1e(e,h(t,23).g,null):null}function tLt(e,t){return A9e(Vc(e.q.getTime()),Vc(t.q.getTime()))}function nLt(e,t){var i;i=e.q.getHours(),e.q.setMonth(t),fP(e,i)}function Os(e,t){e.c&&Ea(e.c.f,e),e.c=t,e.c&&De(e.c.f,e)}function qs(e,t){e.c&&Ea(e.c.a,e),e.c=t,e.c&&De(e.c.a,e)}function _s(e,t){e.d&&Ea(e.d.d,e),e.d=t,e.d&&De(e.d.d,e)}function ls(e,t){e.g&&Ea(e.g.i,e),e.g=t,e.g&&De(e.g.i,e)}function v7e(e,t){return e.b+=t.b,e.c+=t.c,e.d+=t.d,e.a+=t.a,e}function W1e(e){return Y8(e.c),e.e=e.a=e.c,e.c=e.c.c,++e.d,e.a.f}function _7e(e){return Y8(e.e),e.c=e.a=e.e,e.e=e.e.e,--e.d,e.a.f}function y7e(e,t){var i;return i=new cu(e),t.c[t.c.length]=i,i}function iLt(e,t){var i,a;i=t.c,a=i!=null,a&&sx(e,new ix(t.c))}function rLt(e){var t;t=W6t(h(nn(e,(mw(),Yoe)),349)),t.Ef(e)}function SQ(e,t){re(e.Cb,96)&&sP(lu(h(e.Cb,96)),4),Ef(e,t)}function H9(e,t){re(e.Cb,248)&&(h(e.Cb,248).tb=null),Ef(e,t)}function sLt(e,t){uWe(e,t),re(e.Cb,96)&&sP(lu(h(e.Cb,96)),2)}function oLt(e,t){q8(this),this.f=t,this.g=e,z9(this),this.Pd()}function ax(e){this.c=new Ir,this.b=e.b,this.d=e.c,this.a=e.a}function x7e(){this.a=new zc,this.e=new Ur,this.g=0,this.i=0}function Rg(e,t,i){HVe(t,i,e._b()),this.c=e,this.a=t,this.b=i-t}function Ns(e,t){this.a=e,SE.call(this,e),g_(t,e._b()),this.b=t}function E7e(e){this.a=e,this.b=le(Aot,be,1637,e.e.length,0,2)}function d_(e){this.a=w.Math.cos(e),this.b=w.Math.sin(e)}function pi(e,t){this.b=(pn(e),e),this.a=t&V0?t:t|64|Ch}function S7e(e,t,i){var a;HVe(t,i,e.c.length),a=i-t,Dpe(e.c,t,a)}function M7e(e,t){var i;return i=h(CS(v0(e.a),t),13),i?i._b():0}function T7e(e){var t,i;return i=(RE(),t=new xg,t),MA(i,e),i}function C7e(e){var t,i;return i=(RE(),t=new xg,t),MA(i,e),i}function p_(e){return PC(),re(e.g,8)?h(e.g,8):null}function aLt(e,t){var i;i=h(Ii(e.g,t),57),ad(t.d,new kOe(e,i))}function jc(e,t){return Xo(),O0e(t)?new y9(t,e):new qR(t,e)}function Vu(e){return No(X(q(Qr,1),be,9,0,[e.g.k,e.k,e.a]))}function cLt(){return NA(),X(q(trt,1),Oe,412,0,[Tse,Cse,Mse])}function lLt(){return Wg(),X(q(th,1),Oe,150,0,[N3e,eh,Iw])}function uLt(){return Wd(),X(q(Ert,1),Oe,280,0,[A5,gy,Zx])}function fLt(){return mS(),X(q(jSe,1),Oe,318,0,[eoe,toe,EG])}function hLt(){return wU(),X(q(CSe,1),Oe,319,0,[TSe,bG,$se])}function dLt(){return EU(),X(q(PSe,1),Oe,384,0,[Vse,ASe,Wse])}function pLt(){return M_(),X(q(mrt,1),Oe,406,0,[Hse,T5,YP])}function gLt(){return Bo(),X(q(oot,1),Oe,410,0,[WG,Nc,cc])}function mLt(){return WU(),X(q(xTe,1),Oe,345,0,[_Te,Aoe,yTe])}function bLt(){return yU(),X(q(MTe,1),Oe,347,0,[STe,Poe,ETe])}function wLt(){return LU(),X(q(CTe,1),Oe,346,0,[Loe,koe,H5])}function vLt(){return bx(),X(q(TTe,1),Oe,385,0,[W5,$5,V5])}function _Lt(){return xA(),X(q(MEe,1),Oe,348,0,[mse,gse,bse])}function yLt(){return KI(),X(q(JTe,1),Oe,349,0,[oj,ZTe,KTe])}function xLt(){return VU(),X(q($at,1),Oe,401,0,[Hoe,Voe,Woe])}function ELt(){return L0(),X(q(Tot,1),Oe,413,0,[HG,lL,qG])}function SLt(){return il(),X(q(Zct,1),Oe,419,0,[Fh,pb,af])}function MLt(){return Oc(),X(q(Jct,1),Oe,420,0,[Rf,gb,cf])}function TLt(){return Jf(),X(q(pAe,1),Oe,275,0,[Ty,fb,_j])}function CLt(){return SU(),X(q(fCe,1),Oe,277,0,[Koe,uCe,lCe])}function ALt(){return yf(),X(q(Zw,1),Oe,203,0,[oa,Va,aa])}function PLt(){return e1(),X(q(uAe,1),Oe,316,0,[vj,h3,ML])}function A7e(){A7e=M,Ant=Ui((i_(),X(q(Xre,1),Oe,350,0,[d5,p5])))}function q9(){q9=M,$oe=new uge("DFS",0),WTe=new uge("BFS",1)}function cx(){cx=M,Zz=new Re,fse=(Xr(),new li),use=new Re}function P7e(e,t,i){var a;a=new uq,a.b=t,a.a=i,++t.b,De(e.d,a)}function L7e(e,t,i){kc.call(this,25),this.b=e,this.a=t,this.c=i}function vl(e){vi(),kc.call(this,e),this.c=!1,this.a=!1}function LLt(e){return e.a==(uS(),Uj)&&Nde(e,m9t(e.g,e.b)),e.a}function pA(e){return e.d==(uS(),Uj)&&Fde(e,x7t(e.g,e.b)),e.d}function kLt(e,t){var i;return i=(pn(e),e).g,kge(!!i),pn(t),i(t)}function MQ(e,t){var i,a;return a=ZE(e,t),i=e.a.fd(a),new KBe(e,i)}function aS(e){var t;return jo(e)?(t=e,t==-0?0:t):$kt(e)}function RLt(e){return e.Db>>16!=6?null:h(Xte(e),207)}function $(e){return kn(e.a=t)throw Y(new ka(UNt(e,t)));return e}function k7e(e,t,i){if(e<0||ti)throw Y(new ka(mNt(e,t,i)))}function BLt(e){return So(),Lg(zbe((iu(),Qxe),Lg(new u0,91),e),93).a}function X9(e){return Hn(e),Ete((So(),new Od(Zh(zd(e.a,new z)))))}function Y9(e){return new zl((xf(e,zne),NI(io(io(5,e),e/10|0))))}function H1e(e,t){return e&&e.equals?e.equals(t):Be(e)===Be(t)}function q1e(e,t){return t==0?!!e.o&&e.o.f!=0:fte(e,t)}function OLt(e,t){var i;i=ce(Xe(e.a.xe((lr(),bj)))),sJe(e,t,i)}function R7e(e,t,i){var a;a=gr(e.d,t),a>=0?b7(e,a,i):Uve(e,t,i)}function CQ(e,t,i){var a;a=e.d[t.o],e.d[t.o]=e.d[i.o],e.d[i.o]=a}function I7e(e,t){var i;for(i=e+"";i.length0&&e.a[--e.d]==0;);e.a[e.d++]==0&&(e.e=0)}function NLt(e){return!!e.u&&xa(e.u.a).i!=0&&!(e.n&&bte(e.n))}function K9(e){lA(),this.a=(yt(),re(e,49)?new bK(e):new K8(e))}function D7e(){this.c=new rFe,this.a=new b8e,this.b=new ENe,MBe()}function B7e(e,t,i){this.d=e,this.j=t,this.e=i,this.o=-1,this.p=3}function O7e(e,t,i){this.d=e,this.k=t,this.f=i,this.o=-1,this.p=5}function N7e(e,t,i,a,l,f){V0e.call(this,e,t,i,a,l),f&&(this.o=-2)}function F7e(e,t,i,a,l,f){W0e.call(this,e,t,i,a,l),f&&(this.o=-2)}function U7e(e,t,i,a,l,f){d0e.call(this,e,t,i,a,l),f&&(this.o=-2)}function z7e(e,t,i,a,l,f){X0e.call(this,e,t,i,a,l),f&&(this.o=-2)}function G7e(e,t,i,a,l,f){p0e.call(this,e,t,i,a,l),f&&(this.o=-2)}function j7e(e,t,i,a,l,f){H0e.call(this,e,t,i,a,l),f&&(this.o=-2)}function $7e(e,t,i,a,l,f){q0e.call(this,e,t,i,a,l),f&&(this.o=-2)}function V7e(e,t,i,a,l,f){g0e.call(this,e,t,i,a,l),f&&(this.o=-2)}function W7e(e,t,i,a){vC.call(this,i),this.b=e,this.c=t,this.d=a}function H7e(e,t){this.f=e,this.a=(uS(),Fj),this.c=Fj,this.b=t}function q7e(e,t){this.g=e,this.d=(uS(),Uj),this.a=Uj,this.b=t}function X7e(e,t){!e.c&&(e.c=new ds(e,0)),Sne(e.c,(cr(),ED),t)}function na(e,t,i,a,l,f){return Q$e(e,t,i,f),eWe(e,a),tWe(e,l),e}function Y7e(e,t){return re(t,38)?xte(e.a,h(t,38)):!1}function FLt(e){if(!("stack"in e))try{throw e}catch{}return e}function ULt(e){if(e.p!=1)throw Y(new Ha);return nr(e.f)<<24>>24}function zLt(e){if(e.p!=1)throw Y(new Ha);return nr(e.k)<<24>>24}function GLt(e){if(e.p!=7)throw Y(new Ha);return nr(e.k)<<16>>16}function jLt(e){if(e.p!=7)throw Y(new Ha);return nr(e.f)<<16>>16}function J9(e){Ywe(),dFe(this,nr(Zr(Pg(e,24),H7)),nr(Zr(e,H7)))}function Z7e(){Z7e=M,ait=Ui((b8(),X(q(oEe,1),Oe,439,0,[ase])))}function Q9(){Q9=M,noe=new tge(MP,0),$Se=new tge("TOP_LEFT",1)}function K7e(e,t){var i;e.e=new spe,i=xw(t),ua(i,e.c),eZe(e,i,0)}function wt(e,t,i,a){var l;l=new fN,l.a=t,l.b=i,l.c=a,Gi(e.b,l)}function gc(e,t,i,a){var l;l=new fN,l.a=t,l.b=i,l.c=a,Gi(e.a,l)}function $Lt(e,t,i){var a;return a=h(e.Hc().Vb(t),13),!!a&&a.pc(i)}function J7e(e,t,i){var a;return a=h(e.Hc().Vb(t),13),!!a&&a.vc(i)}function Q7e(e,t){var i;return i=1-t,e.a[i]=_U(e.a[i],i),_U(e,t)}function cS(e){return kn(e.b.b!=e.d.a),e.c=e.b=e.b.b,--e.a,e.c.c}function eze(e){return _9(e),Y8(e.c),e.e=e.a=e.c,e.c=e.c.b,++e.d,e.a}function tze(e){return _9(e),Y8(e.e),e.c=e.a=e.e,e.e=e.e.d,--e.d,e.a}function Mn(e){if(!Gn(e))throw Y(new K);return e.c=e.b,e.b.ic()}function nze(e,t){return re(t,38)?xte(e.a,h(t,38)):!1}function ize(e,t){return re(t,38)?xte(e.a,h(t,38)):!1}function rze(e){var t;return f_(e),t=new cn,Cme(e.a,new MY(t)),t}function Y1e(){var e,t,i;return t=(i=(e=new xg,e),i),De(YAe,t),t}function VLt(e){var t;return t=(cl(),cl(),nat),e.d&&Gte(e),nEt(),t}function Z1e(e){return e.j.c=le(sn,nt,1,0,5,1),bI(e.c),aPt(e.a),e}function rs(){mDe.call(this),this.j.c=le(sn,nt,1,0,5,1),this.a=-1}function sze(e,t,i){this.b=new VF(this),this.c=e,this.f=t,this.d=i}function WLt(e,t,i){e.d&&Ea(e.d.d,e),e.d=t,e.d&&w0(e.d.d,i,e)}function HLt(e){return!!e.a&&$c(e.a.a).i!=0&&!(e.b&&wte(e.b))}function qLt(e){return wl(),!Ko(e)&&!(!Ko(e)&&e.c.g.c==e.d.g.c)}function XLt(e){return tU(),b0(Lae,e)?h(Ii(Lae,e),337).Mf():null}function mA(e){return re(e,13)?new hI((iu(),h(e,13))):LCt(e.tc())}function YLt(e,t,i){return i.f.c.length>0?u1e(e.a,t,i):u1e(e.b,t,i)}function oze(e,t,i){var a;return a=jA(i),fr(e.b,a,t),fr(e.c,t,i),t}function S0(e,t){var i,a;return i=Hm(e,t),a=null,i&&(a=i.Vd()),a}function yI(e,t){var i,a;return i=Hm(e,t),a=null,i&&(a=i.Yd()),a}function lS(e,t){var i,a;return i=gx(e,t),a=null,i&&(a=i.Yd()),a}function $d(e,t){var i,a;return i=Hm(e,t),a=null,i&&(a=Kqe(i)),a}function K1e(e){var t;return t=e.Fh(e.i),e.i>0&&wc(e.g,0,t,0,e.i),t}function xI(e){var t;return t=(Hn(e),new wf((iu(),e))),iP(t),Lee(t)}function xa(e){return e.n||(lu(e),e.n=new cFe(Lo,e),Do(e)),e.n}function aze(e,t){var i;return i=new Qb,e.wd(i),i.a+="..",t.xd(i),i.a}function cze(e,t){_8();var i;return i=h(Ii(Dj,e),47),!i||i.Li(t)}function M0(e){return re(e,13)?h(e,13).Wb():!e.tc().hc()}function ZLt(e){if(e.ee())return null;var t=e.n,i=Nz[t];return i}function Fn(e){return kn(e.b!=e.d.c),e.c=e.b,e.b=e.b.a,++e.a,e.c.c}function J1e(e,t){pn(t),zr(e.a,e.c,t),e.c=e.c+1&e.a.length-1,dHe(e)}function bA(e,t){pn(t),e.b=e.b-1&e.a.length-1,zr(e.a,e.b,t),dHe(e)}function lze(e){var t;t=e.pg(),this.a=re(t,64)?h(t,64).oh():t.tc()}function KLt(e,t,i){var a;a=o5t();try{return BMt(e,t,i)}finally{U4t(a)}}function Q1e(e,t,i,a){return re(i,49)?new IFe(e,t,i,a):new t1e(e,t,i,a)}function JLt(){return uU(),X(q(Vz,1),Oe,278,0,[nse,D3e,B3e,O3e])}function QLt(){return _S(),X(q($it,1),Oe,373,0,[J0,Bw,Dw,fy])}function e4t(){return Ex(),X(q(iit,1),Oe,304,0,[m5,g5,b5,w5])}function t4t(){return YA(),X(q(sit,1),Oe,362,0,[v5,qz,Xz,_5])}function n4t(e){return ce(bt(G(e,(Ie(),Ow))))&&G(e,Jn)!=null}function i4t(e){return ce(bt(G(e,(Ie(),Ow))))&&G(e,Jn)!=null}function lx(e){return PC(),re(e.g,153)?h(e.g,153):null}function r4t(e,t,i){var a;a=h(Ii(e.g,i),57),De(e.a.c,new Is(t,a))}function uze(e,t,i,a){var l;return l=a[t.g][i.g],ce(Xe(G(e.a,l)))}function fze(e,t,i,a){this.e=a,this.d=null,this.c=e,this.a=t,this.b=i}function e0e(e,t,i,a){this.d=e,this.n=t,this.g=i,this.o=a,this.p=-1}function hze(e,t,i,a,l){this.c=e,this.e=t,this.d=i,this.b=a,this.a=l}function t0e(e,t,i,a,l){this.i=e,this.a=t,this.e=i,this.j=a,this.f=l}function Ig(e,t,i,a,l){Oi.call(this,e,t),this.a=i,this.b=a,this.c=l}function wA(){wA=M,fL=new nge("UPPER",0),uL=new nge("LOWER",1)}function s4t(){return AS(),X(q(ITe,1),Oe,360,0,[JG,dL,q5,pL])}function o4t(){return i7(),X(q(cCe,1),Oe,320,0,[Zoe,oCe,aCe,sCe])}function a4t(){return Xd(),X(q(QCe,1),Oe,226,0,[wj,xL,f3,EL])}function c4t(){return cd(),X(q(mae,1),Oe,197,0,[gae,pae,xM,cb])}function l4t(){return Wl(),X(q(AL,1),Oe,344,0,[lD,C1,cD,db])}function u4t(){return R0(),X(q(Elt,1),Oe,374,0,[dD,hD,Sae,Mae])}function f4t(){return XU(),X(q(yAe,1),Oe,288,0,[yae,wAe,_Ae,vAe])}function h4t(){return yl(),X(q(Hct,1),Oe,265,0,[fD,xd,dm,uD])}function d4t(){return ww(),X(q(Moe,1),Oe,179,0,[jG,Soe,_y,vy])}function Ul(e,t,i){return t<0?Vte(e,i):h(i,61).aj().fj(e,e.Qg(),t)}function dze(e,t){var i;for(i=e.j.c.length;i=0&&e.a[i]===t[i];i--);return i<0}function s0e(e,t){var i;i=e.q.getHours(),e.q.setFullYear(t+j0),fP(e,i)}function fx(e,t){return t==0||e.e==0?e:t>0?PWe(e,t):OYe(e,-t)}function o0e(e,t){return t==0||e.e==0?e:t>0?OYe(e,t):PWe(e,-t)}function a0e(e){e.b!=e.c&&(e.a=le(sn,nt,1,8,5,1),e.b=0,e.c=0)}function hx(e){return kn(e.a0;)a+=e.a[i],i-=i&-i;return a}function zze(e,t){var i;for(i=t;i;)Nl(e,-i.i,-i.j),i=to(i);return e}function Xm(e,t){return e.a?Si(e.a,e.b):e.a=new su(e.d),Y2(e.a,t),e}function Gze(e,t){for(pn(t);e.a||(e.a=a_(e.c,e)),e.a;)t.ie(eU(e))}function RQ(e){return e.c&&e.d?X1e(e.c)+"->"+X1e(e.d):"e_"+p0(e)}function _4t(e,t,i){return h(t==null?xl(e.d,null,i):I0(e.e,t,i),261)}function y4t(e,t,i){var a,l;a=Hm(e,i),l=null,a&&(l=Kqe(a)),gFt(t,i,l)}function x4t(e,t){var i;i=new SC,$m(i,"x",t.a),$m(i,"y",t.b),sx(e,i)}function E4t(e,t){var i;i=new SC,$m(i,"x",t.a),$m(i,"y",t.b),sx(e,i)}function S4t(e,t){return y8t(e,t,re(t,62)&&(h(h(t,17),62).Bb&oo)!=0)}function sd(e){return Hn(e),re(e,13)?new wf((iu(),h(e,13))):NJ(e.tc())}function M4t(){return Fe(),X(q(xc,1),Oe,69,0,[Oa,bn,Zt,ei,tn])}function T4t(e){return h8(),function(){return KLt(e,this,arguments);var t}}function C4t(){return Date.now?Date.now():new Date().getTime()}function l0e(e){if(!e.c.Cc())throw Y(new K);return e.a=!0,e.c.Ec()}function IQ(e,t){if(e<0||e>t)throw Y(new ka(uve(e,t,"index")));return e}function u0e(e,t){return re(t,180)?pt(e.c,h(t,180).c):!1}function A4t(e){return e.d=3,e.c=hRt(e),e.d!=2?(e.d=0,!0):!1}function jze(e,t){var i,a;return i=(a=e.slice(0,t),yA(a,e)),i.length=t,i}function Wu(e,t,i){var a;return a=(oi(t,e.c.length),e.c[t]),e.c[t]=i,a}function DQ(e,t,i,a){var l;return l=le(Rn,ii,22,t,15,1),UBt(l,e,t,i,a),l}function $ze(e,t,i,a){this.e=e,this.b=new Re,this.d=t,this.a=i,this.c=a}function C0(e,t){this.b=Ta,this.d=e,this.e=t,this.c=this.d+(""+this.e)}function Vze(){rJ(this),this.b=new $t(Kr,Kr),this.a=new $t(Ts,Ts)}function uS(){uS=M;var e,t;Fj=(RE(),t=new S,t),Uj=(e=new cK,e)}function Wze(){cU(),this.b=(Xr(),new li),this.a=new li,this.c=new Re}function tl(e){var t;e.d=new BNe(e),e.e=new ONe(e),t=e[Z_]|0,e[Z_]=t+1}function nU(e,t){return(SS(e),Ebe(new si(e,new S0e(t,e.a)))).a!=null}function P4t(){return _o(),X(q(TEe,1),Oe,328,0,[Ih,Yx,Ja,Qa,Ho])}function L4t(){return JA(),X(q(_Se,1),Oe,276,0,[Use,zse,Nse,vSe,Fse])}function k4t(){return hu(),X(q(tMe,1),Oe,178,0,[i3,I5,Fw,QP,tb])}function R4t(){return XA(),X(q(pTe,1),Oe,292,0,[dTe,Toe,Coe,U5,z5])}function I4t(){return Xg(),X(q(CL,1),Oe,225,0,[lb,wae,fAe,TL,hAe])}function D4t(){return i1(),X(q(Jp,1),Oe,163,0,[Pn,pa,md,ab,fm])}function B4t(){return Xs(),X(q(yL,1),Oe,110,0,[Bh,rf,nf,ip,hm])}function O4t(e,t){var i;return i=t!=null?Ua(e,t):Ic(pc(e.d,null)),jE(i)}function N4t(e,t){var i;return i=t!=null?Ua(e,t):Ic(pc(e.d,null)),jE(i)}function f0e(e,t){var i;return i=h(px(e.d,t),27),i||h(px(e.e,t),27)}function h0e(e,t){var i;return i=0,e&&(i+=e.f.a/2),t&&(i+=t.f.a/2),i}function lu(e){return e.t||(e.t=new YZ(e),JI(new VDe(e),0,e.t)),e.t}function Hze(e){var t;return e.c||(t=e.r,re(t,96)&&(e.c=h(t,24))),e.c}function qze(e,t){return b0(e.a,t)?(fS(e.a,t),!0):!1}function Ko(e){return!e.c||!e.d?!1:!!e.c.g&&e.c.g==e.d.g}function F4t(e){return xf(e,"size"),nr(_K(Jm(e,8),kx)?Jm(e,8):kx),new Qb}function Np(e,t){return kNe((lA(),new K9(cWe(X(q(sn,1),nt,1,5,[e,t])))))}function U4t(e){e&&Hkt((mr(),r3e)),--Fz,e&&Uz!=-1&&(GEt(Uz),Uz=-1)}function z4t(e,t){var i,a;i=h(_5t(e.c,t),13),i&&(a=i._b(),i.Pb(),e.d-=a)}function vA(e){So();var t;for(t=0;e.hc();)e.ic(),t=io(t,1);return NI(t)}function BQ(e){var t,i,a;return t=e&Xc,i=e>>22&Xc,a=e<0?Zd:0,qa(t,i,a)}function Xze(e,t){var i,a;return i=t.kc(),a=Sbe(e,i),!!a&&el(a.e,t.lc())}function Yze(e){var t;return t=e.e+e.f,isNaN(t)&&l9(e.d)?e.d:t}function Zze(e){this.b=e,Dn.call(this,e),this.a=h(rn(this.b.a,4),116)}function Kze(e){this.b=e,tx.call(this,e),this.a=h(rn(this.b.a,4),116)}function Hu(e,t,i,a,l){iGe.call(this,t,a,l),this.c=e,this.b=i}function d0e(e,t,i,a,l){B7e.call(this,t,a,l),this.c=e,this.a=i}function p0e(e,t,i,a,l){O7e.call(this,t,a,l),this.c=e,this.a=i}function g0e(e,t,i,a,l){iGe.call(this,t,a,l),this.c=e,this.a=i}function Jze(e,t){this.d=new z2,this.a=e,this.b=t,this.e=new Io(t.Qe())}function Fp(e,t){Kg(),this.e=e,this.d=1,this.a=X(q(Rn,1),ii,22,15,[t])}function fS(e,t){return ws(t)?t==null?Tve(e.d,null):iVe(e.e,t):Tve(e.d,t)}function m0e(e,t,i){var a;return a=e.rg(t),a>=0?e.ug(a,i,!0):Cx(e,t,i)}function G4t(e,t,i){var a;a=(Hn(e),new wf((iu(),e))),IBt(new _ze(a,t,i))}function SI(e,t,i){var a;a=(Hn(e),new wf((iu(),e))),VDt(new yze(a,t,i))}function j4t(e,t,i){var a;return a=jA(i),eP(e.d,a,t,!1),fr(e.e,t,i),t}function $4t(e,t,i){var a;return a=jA(i),eP(e.j,a,t,!1),fr(e.k,t,i),t}function Qze(e,t,i){var a;a=new Age(e.a),wee(a,e.a.a),xl(a.d,t,i),e.a.a=a}function OQ(e){var t;return t=new Bp,Oo(t,e),Ee(t,($e(),Po),null),t}function Ym(e){var t,i;return Hn(e),t=jAt(e.length),i=new zl(t),qI(i,e),i}function _A(e){var t,i;++e.j,t=e.g,i=e.i,e.g=null,e.i=0,e.uh(i,t),e.th()}function MI(e,t){e.Eh(e.i+1),JC(e,e.i,e.Ch(e.i,t)),e.sh(e.i++,t),e.th()}function A0(e,t){var i;return i=(oi(t,e.c.length),e.c[t]),Dpe(e.c,t,1),i}function NQ(e,t,i,a){var l;return l=le(Rn,ii,22,t+1,15,1),v7t(l,e,t,i,a),l}function b0e(e,t,i,a){var l;for(l=0;lt.o?-1:0}function g_(e,t){if(e<0||e>t)throw Y(new ka("Index: "+e+", Size: "+t))}function x0e(e,t,i){if(e<0||t>i||t=t)throw Y(new ka("Index: "+e+", Size: "+t))}function X4t(e,t){var i;i=e.q.getHours()+(t/60|0),e.q.setMinutes(t),fP(e,i)}function oU(e,t,i){this.a=e,this.b=t,this.c=i,De(e.q,this),De(t.g,this)}function TI(e,t,i,a){this.f=e,this.e=t,this.d=i,this.b=a,this.c=a?a.d:null}function E0e(e){lVe.call(this,e,0),OFe(this),this.b.b=this.b,this.b.a=this.b}function S0e(e,t){j8.call(this,t.rd(),t.qd()&-65),pn(e),this.a=e,this.c=t}function PGe(e,t,i){this.d=(pn(e),e),this.a=i&V0?i:i|64|Ch,this.c=t}function aU(){this.b=new Ir,this.a=new Ir,this.b=new Ir,this.a=new Ir}function LGe(){LGe=M,pot=Gc(Ci(new rs,(_o(),Ih),(Co(),kse)),Ho,hG)}function kGe(){kGe=M,got=Ci(Ci(new rs,(_o(),Ih),(Co(),qP)),Ja,uM)}function UQ(e,t){return!e.o&&(e.o=new nl((Ma(),sp),pm,e,0)),nte(e.o,t)}function Y4t(e,t){ni(t,"Label management",1),jE(G(e,(FQ(),K5))),Bn(t)}function Z4t(e,t){var i;return i=e.c,t>0?h(Tt(i.a,t-1),8):null}function zQ(e){var t;return t=e.b,t.b==0?null:h(qg(t,0),170).b}function M0e(e){var t,i,a,l;l=e.d,t=e.a,i=e.b,a=e.c,e.d=i,e.a=a,e.b=l,e.c=t}function K4t(e,t){var i;e.A&&(i=h(Ds(e.b,t),114).n,i.d=e.A.d,i.a=e.A.a)}function GQ(e,t,i){var a,l;if(i!=null)for(a=0;a=0,"Initial capacity must not be negative")}function DGe(e){this.b=(Xr(),new li),this.c=new li,this.d=new li,this.a=e}function BGe(e){e?(this.c=e,this.b=null):(this.c=null,this.b=new Re)}function jQ(e,t){S8.call(this,e,t),this.a=le(rVt,nt,398,2,0,1),this.b=!0}function $Q(e,t,i){return bne(e,t,i,re(t,62)&&(h(h(t,17),62).Bb&oo)!=0)}function ckt(e,t,i){return hP(e,t,i,re(t,62)&&(h(h(t,17),62).Bb&oo)!=0)}function lkt(e,t,i){return x8t(e,t,i,re(t,62)&&(h(h(t,17),62).Bb&oo)!=0)}function ukt(e,t){return no(ce(Xe(G(e,(Ie(),eb)))),ce(Xe(G(t,eb))))}function fkt(){return LS(),X(q(jse,1),Oe,290,0,[SSe,mG,gG,ESe,dG,pG])}function hkt(){return d7(),X(q(LSe,1),Oe,241,0,[Xse,qse,Zse,Yse,Kse,wG])}function dkt(){return g6(),X(q(BSe,1),Oe,255,0,[vG,RSe,DSe,kSe,ISe,Jse])}function pkt(){return RS(),X(q(GSe,1),Oe,256,0,[ZP,NSe,zSe,USe,FSe,OSe])}function gkt(){return u7(),X(q(hTe,1),Oe,291,0,[Eoe,uTe,xoe,lTe,fTe,GG])}function mkt(){return Ms(),X(q(dAe,1),Oe,83,0,[ub,rp,p3,d3,wd,Ba])}function bkt(){return nP(),X(q(Tat,1),Oe,308,0,[QG,Doe,Ooe,Boe,Noe,Ioe])}function wkt(){return ld(),X(q(gCe,1),Oe,224,0,[Qoe,J5,Q5,fj,lj,uj])}function vkt(){return f7(),X(q(sAe,1),Oe,289,0,[bae,nAe,rAe,eAe,iAe,tAe])}function OGe(){OGe=M,Uat=$A($A(Gpe(new rs,(AS(),dL)),(nP(),QG)),Doe)}function cU(){cU=M,new Sr("org.eclipse.elk.addLayoutConfig"),rct=new A2}function NGe(){NGe=M,I7(),iPe=Kr,Eut=Ts,rPe=new Yb(Kr),Sut=new Yb(Ts)}function FGe(e,t,i){vi();var a;return a=em(e,t),i&&a&&GAt(e)&&(a=null),a}function le(e,t,i,a,l,f){var g;return g=IHe(l,a),l!=10&&X(q(e,f),t,i,l,g),g}function _kt(e,t,i){return kNe((lA(),new K9(cWe(X(q(sn,1),nt,1,5,[e,t,i])))))}function UGe(e,t){var i;return i=t.kc(),Xr(),new DR(i,nqe(e.e,i,h(t.lc(),13)))}function zGe(e,t){var i,a;return i=e.a-t.a,a=e.b-t.b,w.Math.sqrt(i*i+a*a)}function T0e(e,t,i){var a;a=e.b[i.c.o][i.o],a.b+=t.b,a.c+=t.c,a.a+=t.a,++a.a}function ykt(e,t,i){var a,l;return l=e.length,a=i=e.i)throw Y(new JK(t,e.i));return e.g[t]}function jGe(e,t,i){if(DA(e,i),i!=null&&!e.Li(i))throw Y(new AR);return i}function Sh(e,t){return tQ(t,"Horizontal alignment cannot be null"),e.b=t,e}function AI(e,t){var i;return i=e.rg(t),i>=0?e.ug(i,!0,!0):Cx(e,t,!0)}function PI(e,t,i){var a,l;return l=(a=BS(e.b,t),a),l?B7(OI(e,l),i):null}function xkt(e){return re(e,159)?""+h(e,159).a:e==null?null:za(e)}function Ekt(e){return re(e,159)?""+h(e,159).a:e==null?null:za(e)}function dS(e){var t;return jo(e)&&(t=0-e,!isNaN(t))?t:zg(vS(e))}function Skt(e){var t;return e=e>2?e:2,t=gbe(e),e>t?(t<<=1,t>0?t:kx):t}function LI(e){var t,i;return t=e+128,i=(A8e(),u3e)[t],!i&&(i=u3e[t]=new dY(e)),i}function yA(e,t){return FI(t)!=10&&X(rl(t),t.rl,t.__elementTypeId$,FI(t),e),e}function m_(e,t){return t.e==0||e.e==0?aM:(IS(),Qte(e,t))}function Mkt(e){for(;!e.a;)if(!U0e(e.b,new TY(e)))return!1;return!0}function Tkt(e){for(;!e.a;)if(!O8e(e.c,new PY(e)))return!1;return!0}function $Ge(e,t){if(t.a)throw Y(new ta(HJe));Cr(e.a,t),t.a=e,!e.j&&(e.j=t)}function VQ(e,t,i,a,l,f){e0e.call(this,t,a,l,f),this.c=e,this.b=i}function VGe(e,t,i,a,l,f){e0e.call(this,t,a,l,f),this.c=e,this.a=i}function nl(e,t,i,a){this.Gi(),this.a=t,this.b=e,this.c=new o1e(this,t,i,a)}function kI(e,t){this.e=t,this.a=m$e(e),this.a<54?this.f=aS(e):this.c=s6(e)}function Ckt(e,t){e.a.Ld(t.d,e.b)>0&&(De(e.c,new Ome(t.c,t.d,e.d)),e.b=t.d)}function WQ(e){e.a=le(Rn,ii,22,e.b+1,15,1),e.c=le(Rn,ii,22,e.b,15,1),e.d=0}function WGe(){WGe=M,Xnt=Ui((uU(),X(q(Vz,1),Oe,278,0,[nse,D3e,B3e,O3e])))}function HGe(){HGe=M,iot=Ui((ww(),X(q(Moe,1),Oe,179,0,[jG,Soe,_y,vy])))}function qGe(){qGe=M,Vit=Ui((_S(),X(q($it,1),Oe,373,0,[J0,Bw,Dw,fy])))}function XGe(){XGe=M,rit=Ui((Ex(),X(q(iit,1),Oe,304,0,[m5,g5,b5,w5])))}function YGe(){YGe=M,oit=Ui((YA(),X(q(sit,1),Oe,362,0,[v5,qz,Xz,_5])))}function ZGe(){ZGe=M,Mat=Ui((AS(),X(q(ITe,1),Oe,360,0,[JG,dL,q5,pL])))}function KGe(){KGe=M,nct=Ui((i7(),X(q(cCe,1),Oe,320,0,[Zoe,oCe,aCe,sCe])))}function JGe(){JGe=M,Act=Ui((Xd(),X(q(QCe,1),Oe,226,0,[wj,xL,f3,EL])))}function QGe(){QGe=M,Pct=Ui((cd(),X(q(mae,1),Oe,197,0,[gae,pae,xM,cb])))}function eje(){eje=M,jct=Ui((Wl(),X(q(AL,1),Oe,344,0,[lD,C1,cD,db])))}function tje(){tje=M,Slt=Ui((R0(),X(q(Elt,1),Oe,374,0,[dD,hD,Sae,Mae])))}function nje(){nje=M,Vct=Ui((XU(),X(q(yAe,1),Oe,288,0,[yae,wAe,_Ae,vAe])))}function ije(){ije=M,qct=Ui((yl(),X(q(Hct,1),Oe,265,0,[fD,xd,dm,uD])))}function il(){il=M,Fh=new ZK(qS,0),pb=new ZK(MP,1),af=new ZK(XS,2)}function RI(){RI=M,LTe=new sge(W0,0),ZG=new sge("IMPROVE_STRAIGHTNESS",1)}function lU(){lU=M,XTe=new age("LEAF_NUMBER",0),qoe=new age("NODE_SIZE",1)}function uU(){uU=M,nse=new M8("All",0),D3e=new WNe,B3e=new nFe,O3e=new HNe}function $c(e){return e.b||(e.b=new lFe(Lo,e),!e.a&&(e.a=new sI(e,e))),e.b}function II(e,t){if(t<0)throw Y(new ka(eet+t));return dze(e,t+1),Tt(e.j,t)}function dx(e){var t;if(!S_(e))throw Y(new K);return e.d=1,t=e.c,e.c=null,t}function fU(e){var t,i;return i=e.length,t=le(Yl,Ah,22,i,15,1),V9e(e,0,i,t,0),t}function HQ(e,t){var i;this.f=e,this.b=t,i=h(Ii(e.b,t),264),this.c=i?i.b:null}function Akt(e,t,i){var a;return a=xVe(e,t,i),e.b=new dee(a.c.length),Yve(e,a)}function Pkt(e,t){var i;return i=h(CS(e.d,t),13),i?nqe(e.e,t,i):null}function L0e(e,t){var i;return i=h(fS(e.c,t),353),i?(zme(i),i.e):null}function Lkt(e){var t,i;if(!e.b)return null;for(i=e.b;t=i.a[0];)i=t;return i}function kkt(e,t,i){var a;return a=jA(i),eP(e.g,a,t,!1),eP(e.i,t,i,!1),t}function DI(e,t,i,a){var l;a=(rS(),a||C3e),l=e.slice(t,i),pve(l,e,t,i,-t,a)}function Gl(e,t,i,a,l){return t<0?Cx(e,i,a):h(i,61).aj().cj(e,e.Qg(),t,a,l)}function Rkt(e,t){return t0?zi:Sa(e,zs)<0?zs:nr(e)}function Nkt(e,t){if(!e)throw Y(new un(Y8t("Enum constant undefined: %s",t)))}function hU(e){q8(this),this.g=e?$Ue(e,e.Od()):null,this.f=e,z9(this),this.Pd()}function Vd(e,t,i,a,l,f,g){lee.call(this,t,a,l,f,g),this.c=e,this.b=i}function od(e,t,i){var a,l;for(a=10,l=0;l=0?(e.gd(i),!0):!1}function QQ(e,t){var i;return i=gr(e.d,t),i>=0?t7(e,i,!0,!0):Cx(e,t,!0)}function Gkt(e,t){var i;for(i=0;e.e!=e.i._b();)eMt(t,Xn(e),He(i)),i!=zi&&++i}function oje(e,t){var i,a,l;for(l=0,a=e.tc();a.hc();)i=a.ic(),zr(t,l++,i);return t}function Og(e,t,i){var a;if(t==null)throw Y(new N2);return a=Hm(e,t),p4t(e,t,i),a}function Ng(e){if(e<0)throw Y(new un("tolerance ("+e+") must be >= 0"));return e}function eee(e){var t;return t=e.b.c.length==0?null:Tt(e.b,0),t!=null&&ibe(e,0),t}function aje(e,t){var i,a,l;for(a=0,l=t.length;a=e.a.c.length;)De(e.a,new Ir);return h(Tt(e.a,t),15)}function $kt(e){return Bwe(e,(pS(),c3e))<0?-sMt(vS(e)):e.l+e.m*Ox+e.h*l1}function cje(e){var t,i;return t=e/60|0,i=e%60,i==0?""+t:""+t+":"+(""+i)}function Vkt(e,t){var i;return i=D6t(e.e.c,t.e.c),i==0?no(e.e.d,t.e.d):i}function gx(e,t){var i=e.a[t],a=(Bee(),Kre)[typeof i];return a?a(i):Ibe(typeof i)}function lje(e,t){return t==(DJ(),DJ(),qnt)?e.toLocaleLowerCase():e.toLowerCase()}function FI(e){return e.__elementTypeCategory$==null?10:e.__elementTypeCategory$}function N0e(e){return(e.i&2?"interface ":e.i&1?"":"class ")+(Nd(e),e.o)}function Wkt(e,t,i){var a;return a=e.a.e[h(t.a,8).o]-e.a.e[h(i.a,8).o],wr(s9e(a))}function uje(e,t){var i;for(++e.d,++e.c[t],i=t+1;i=0&&te||e>t)throw Y(new gpe("fromIndex: 0, toIndex: "+e+rye+t))}function bU(e,t){var i,a;for(a=e.tc();a.hc();)i=h(a.ic(),68),Ee(i,(Ie(),e3),t)}function Kkt(e,t,i){var a;a=w.Math.max(0,e.b/2-.5),ZA(i,a,1),De(t,new TOe(i,a))}function Jkt(e){var t;return t=ce(Xe(G(e,($e(),ep)))),t<0&&(t=0,Ee(e,ep,t)),t}function v_(e){r9();var t,i;for(i=q2e,t=0;ti&&(i=e[t]);return i}function Qkt(){iBe();for(var e=Vre,t=0;t=e.i)throw Y(new JK(t,e.i));return e.zh(t,e.g[t])}function Rje(e,t,i){if(DA(e,i),!e.Nj()&&i!=null&&!e.Li(i))throw Y(new AR);return i}function SA(e,t){var i;for(i=e;to(i);)if(i=to(i),i==t)return!0;return!1}function iRt(e,t){return t&&e.b[t.g]==t?(zr(e.b,t.g,null),--e.c,!0):!1}function qu(e,t){var i;return i=t.c,t.a.b=t.b,t.b.a=t.a,t.a=t.b=null,t.c=null,--e.b,i}function ad(e,t){var i,a,l,f;for(pn(t),a=e.c,l=0,f=a.length;l>5,l=t&31,a=Zr(c_(e.n[i][f],nr(Gd(l,1))),3),a}function Ije(e,t){for(;t[0]=0;)++t[0]}function Dje(e,t){a9.call(this),j0e(this),this.a=e,this.c=!0,this.b=t.d,this.f=t.e}function Bje(e,t){return yh(),Ng(tm),w.Math.abs(e-t)<=tm||e==t||isNaN(e)&&isNaN(t)}function G0e(e){return e.a<54?e.f<0?-1:e.f>0?1:0:(!e.c&&(e.c=ZI(e.f)),e.c).e}function Oje(e){return e.c&&e.d?e.c.g+"("+e.c+")->"+e.d.g+"("+e.d+")":"e_"+p0(e)}function Nje(e,t,i){var a,l;a=t;do l=ce(e.p[a.o])+i,e.p[a.o]=l,a=e.a[a.o];while(a!=t)}function sRt(e,t,i){var a,l,f;for(l=t[i],a=0;a=14&&t<=16))),e}function iee(e,t){So();var i;for(Hn(e),Hn(t),i=!1;t.hc();)i=i|e.nc(t.ic());return i}function xf(e,t){if(e<0)throw Y(new un(t+" cannot be negative but was: "+e));return e}function ree(e,t){var i,a;for(a=new j(e);a.ai)throw Y(new o_(t,i));return new Sme(e,t)}function E_(e,t){var i;i=e.s,e.s=t,e.Db&4&&!(e.Db&1)&&Pi(e,new LQ(e,4,i,e.s))}function gS(e,t){var i;i=e.t,e.t=t,e.Db&4&&!(e.Db&1)&&Pi(e,new LQ(e,5,i,e.t))}function $0e(e,t){var i;i=e.d,e.d=t,e.Db&4&&!(e.Db&1)&&Pi(e,new LQ(e,2,i,e.d))}function aee(e,t){var i;i=e.F,e.F=t,e.Db&4&&!(e.Db&1)&&Pi(e,new cs(e,1,5,i,t))}function aRt(e,t){var i,a,l;return i=(a=(h0(),l=new ZT,l),t&&kYe(a,t),a),i$e(i,e),i}function L0(){L0=M,HG=new jK("BARYCENTER",0),lL=new jK(EQe,1),qG=new jK(SQe,2)}function wU(){wU=M,TSe=new RK("ARD",0),bG=new RK("MSD",1),$se=new RK("MANUAL",2)}function Bo(){Bo=M,WG=new NK(Ux,0),Nc=new NK("INPUT",1),cc=new NK("OUTPUT",2)}function Hje(){$u(),this.b=(Xr(),new li),this.f=new li,this.g=new li,this.e=new li}function V0e(e,t,i,a,l){this.d=t,this.k=a,this.f=l,this.o=-1,this.p=1,this.c=e,this.a=i}function W0e(e,t,i,a,l){this.d=t,this.k=a,this.f=l,this.o=-1,this.p=2,this.c=e,this.a=i}function H0e(e,t,i,a,l){this.d=t,this.k=a,this.f=l,this.o=-1,this.p=6,this.c=e,this.a=i}function q0e(e,t,i,a,l){this.d=t,this.k=a,this.f=l,this.o=-1,this.p=7,this.c=e,this.a=i}function X0e(e,t,i,a,l){this.d=t,this.j=a,this.e=l,this.o=-1,this.p=4,this.c=e,this.a=i}function Y0e(e,t){return yh(),Ng(tm),w.Math.abs(e-t)<=tm||e==t||isNaN(e)&&isNaN(t)}function cRt(){return A7(),X(q(sEe,1),Oe,228,0,[rEe,eEe,tEe,Q3e,ose,iEe,nEe,J3e,K3e])}function lRt(){return a1(),X(q(Zs,1),Oe,86,0,[Su,Oh,Tu,kf,of,sf,Pl,Cu,Mu])}function uRt(){return ac(),X(q(bAe,1),Oe,239,0,[EM,PL,xj,LL,Ej,Sj,m3,_ae,yj])}function qje(){qje=M,Nnt=X(q(Rn,1),ii,22,15,[0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15])}function Xje(){Xje=M,Sot=Gc(Ci(Ci(new rs,(_o(),Ja),(Co(),Dse)),Qa,Rse),Ho,Ise)}function cee(){return Joe||(Joe=new fZe,kA(Joe,X(q(WP,1),nt,154,0,[new XX]))),Joe}function bo(e,t,i){return xS(e,t),Ef(e,i),E_(e,0),gS(e,1),A_(e,!0),C_(e,!0),e}function Yje(e,t){var i;return re(t,38)?e.c.vc(t):(i=nte(e,t),a6(e,t),i)}function hr(e){var t;return re(e,78)?e:(t=e&&e[jne],t||(t=new wWe(e),Vi(t)),t)}function Z0e(e){var t,i;if(e==0)return 32;for(i=0,t=1;!(t&e);t<<=1)++i;return i}function fRt(e,t){var i;return i=e.c,t=0),E5t(e.d,e.c)<0&&(e.a=e.a-1&e.d.a.length-1,e.b=e.d.c),e.c=-1}function uee(e,t){e.j>0&&e.c0&&e.e!=0&&uee(e.g,t/e.j*e.g.d))}function t$e(e,t){var i;i=e.c,e.c=t,e.Db&4&&!(e.Db&1)&&Pi(e,new cs(e,1,1,i,e.c))}function n$e(e,t){var i;i=e.b,e.b=t,e.Db&4&&!(e.Db&1)&&Pi(e,new cs(e,1,0,i,e.b))}function jI(e,t){var i;i=e.k,e.k=t,e.Db&4&&!(e.Db&1)&&Pi(e,new cs(e,1,2,i,e.k))}function Q0e(e,t){var i;i=e.f,e.f=t,e.Db&4&&!(e.Db&1)&&Pi(e,new cs(e,1,8,i,e.f))}function ebe(e,t){var i;i=e.i,e.i=t,e.Db&4&&!(e.Db&1)&&Pi(e,new cs(e,1,7,i,e.i))}function i$e(e,t){var i;i=e.a,e.a=t,e.Db&4&&!(e.Db&1)&&Pi(e,new cs(e,1,8,i,e.a))}function r$e(e,t){var i;i=e.d,e.d=t,e.Db&4&&!(e.Db&1)&&Pi(e,new cs(e,1,1,i,e.d))}function s$e(e,t){var i;i=e.c,e.c=t,e.Db&4&&!(e.Db&1)&&Pi(e,new cs(e,1,1,i,e.c))}function tbe(e,t){var i;i=e.c,e.c=t,e.Db&4&&!(e.Db&1)&&Pi(e,new cs(e,1,4,i,e.c))}function fee(e,t){var i;i=e.D,e.D=t,e.Db&4&&!(e.Db&1)&&Pi(e,new cs(e,1,2,i,e.D))}function o$e(e,t){var i;i=e.b,e.b=t,e.Db&4&&!(e.Db&1)&&Pi(e,new cs(e,1,0,i,e.b))}function mRt(e,t,i){var a;e.b=t,e.a=i,a=(e.a&512)==512?new kDe:new jf,e.c=J9t(a,e.b,e.a)}function a$e(e,t){return z0(e.e,t)?(Xo(),O0e(t)?new y9(t,e):new qR(t,e)):new yNe(t,e)}function LA(e,t){return vt(),ws(e)?qme(e,Qn(t)):sw(e)?v9e(e,Xe(t)):rw(e)?eAt(e,bt(t)):e.vd(t)}function bRt(e){var t=/function(?:\s+([\w$]+))?\s*\(/,i=t.exec(e);return i&&i[1]||$ne}function wRt(e,t){var i,a;return i=e.o+e.p,a=t.o+t.p,i>>31;a!=0&&(e[i]=a)}function m$e(e){var t;return Sa(e,0)<0&&(e=tme(e)),t=nr(Pg(e,32)),64-(t!=0?x6(t):x6(nr(e))+32)}function SRt(e){var t,i;for(i=e.c.a.Xb().tc();i.hc();)t=h(i.ic(),204),Tde(t,new U9e(t.f))}function b$e(e){var t,i;for(i=e.c.a.Xb().tc();i.hc();)t=h(i.ic(),204),Cde(t,new pqe(t.e))}function w$e(e){this.d=e,this.c=e.c.Tb().tc(),this.b=null,this.a=null,this.e=(So(),So(),n3e)}function v$e(e){this.e=e,this.d=new m8(Eee(i1e(this.e)._b())),this.c=this.e.a,this.b=this.e.c}function dee(e){this.b=e,this.a=le(Rn,ii,22,e+1,15,1),this.c=le(Rn,ii,22,e,15,1),this.d=0}function MRt(e){e.a=null,e.e=null,e.b.c=le(sn,nt,1,0,5,1),e.f.c=le(sn,nt,1,0,5,1),e.c=null}function Ki(e,t){var i,a;a=(i=new Jge,i),a.n=t,$n((!e.s&&(e.s=new ze(Ec,e,21,17)),e.s),a)}function vr(e,t){var i,a;i=(a=new cK,a),i.n=t,$n((!e.s&&(e.s=new ze(Ec,e,21,17)),e.s),i)}function Ef(e,t){var i;i=e.zb,e.zb=t,e.Db&4&&!(e.Db&1)&&Pi(e,new cs(e,1,1,i,e.zb))}function pee(e,t){var i;i=e.xb,e.xb=t,e.Db&4&&!(e.Db&1)&&Pi(e,new cs(e,1,3,i,e.xb))}function gee(e,t){var i;i=e.yb,e.yb=t,e.Db&4&&!(e.Db&1)&&Pi(e,new cs(e,1,2,i,e.yb))}function mee(e,t,i){var a,l,f;return l=S0(t,"labels"),a=new rNe(e,i),f=(iUt(a.a,a.b,l),l),f}function Ar(e,t,i,a,l,f,g,m,v,y,E,C,R){return oXe(e,t,i,a,l,f,g,m,v,y,E,C,R),$be(e,!1),e}function wo(e,t){var i,a,l;for(pn(t),i=!1,l=t.tc();l.hc();)a=l.ic(),i=i|e.nc(a);return i}function _$e(e){if(e){if(e.Wb())throw Y(new K);return e.cd(e._b()-1)}return gze(null.tc())}function TRt(e){if(pn(e),e.length==0)throw Y(new wh("Zero length BigInteger"));dUt(this,e)}function yU(){yU=M,STe=new UK("NO",0),Poe=new UK("GREEDY",1),ETe=new UK("LOOK_BACK",2)}function bee(){bee=M,BL=new PDe,Iae=X(q(Ec,1),oy,158,0,[]),tut=X(q(lf,1),Fxe,53,0,[])}function y$e(){y$e=M,Jit=Ui((qt(),X(q(xse,1),Oe,232,0,[fs,Nr,Jr,sa,ll,ja,nh])))}function CRt(){return xo(),X(q(Qse,1),Oe,233,0,[_G,Eu,KP,yG,dy,py,C5,fM,hM,xG])}function ARt(e,t){return _S(),e==J0&&t==Bw||e==Bw&&t==J0||e==fy&&t==Dw||e==Dw&&t==fy}function PRt(e,t){return _S(),e==J0&&t==Dw||e==J0&&t==fy||e==Bw&&t==fy||e==Bw&&t==Dw}function x$e(e,t){return ce(Xe(hJ(t6(qf(new si(null,new pi(e.c.b,16)),new jF(e)),t))))}function obe(e,t){return ce(Xe(hJ(t6(qf(new si(null,new pi(e.c.b,16)),new Hs(e)),t))))}function E$e(e,t){t?e.B==null&&(e.B=e.D,e.D=null):e.B!=null&&(e.D=e.B,e.B=null)}function LRt(e){var t;return re(e,182)?(t=h(e,182),new ppe(t.a)):(So(),new hR(e))}function S$e(e){var t;return t=rze(e),nw(t.a,0)?(OE(),OE(),k3e):(OE(),new Hge(t.b))}function M$e(e){var t;return t=rze(e),nw(t.a,0)?(OE(),OE(),k3e):(OE(),new Hge(t.c))}function T$e(e){Jme.call(this),this.b=ce(Xe(G(e,($e(),ih)))),this.a=h(G(e,cm),197)}function C$e(){this.c=new w8(0),this.b=new w8(VQe),this.d=new w8($Qe),this.a=new w8(Cie)}function xU(e){this.b=(Hn(e),new wf((iu(),e))),this.a=new Re,this.d=new Re,this.e=new fo}function Hd(){Hd=M,Sse=new fc,Ese=new Qs,kEe=new b2,LEe=new hc,REe=new km,IEe=new w2}function EU(){EU=M,Vse=new IK("GREEDY",0),ASe=new IK("DEPTH_FIRST",1),Wse=new IK(Die,2)}function Jf(){Jf=M,Ty=new XK("OUTSIDE",0),fb=new XK("INSIDE",1),_j=new XK("FIXED",2)}function A$e(){A$e=M,Mot=$A(lSt(Ci(Ci(new rs,(_o(),Ja),(Co(),Dse)),Qa,Rse),Ho),Ise)}function kRt(e){return e.b.c.g.j==(qt(),Jr)?h(G(e.b.c.g,(Ie(),Jn)),11):e.b.c}function P$e(e){return e.b.d.g.j==(qt(),Jr)?h(G(e.b.d.g,(Ie(),Jn)),11):e.b.d}function L$e(e){var t;if(e.b==-2){if(e.e==0)t=-1;else for(t=0;e.a[t]==0;t++);e.b=t}return e.b}function k$e(e){var t,i,a;for(t=0,a=e.tc();a.hc();)i=a.ic(),t+=i!=null?Wr(i):0,t=~~t;return t}function abe(e,t,i){var a,l;for(l=On(e,0);l.b!=l.d.c;)a=h(Fn(l),9),a.a+=t,a.b+=i;return e}function $I(e){var t,i,a;for(t=0,a=e.tc();a.hc();)i=Xe(a.ic()),t+=(pn(i),i);return t/e._b()}function R$e(e){var t;return e==0?"UTC":(e<0?(e=-e,t="UTC+"):t="UTC-",t+cje(e))}function RRt(e,t){yt();var i,a;for(a=new Re,i=0;i0&&(this.g=this.Fh(this.i+(this.i/8|0)+1),e.zc(this.g))}function D$e(e,t){return yh(),Ng(pd),w.Math.abs(0-t)<=pd||t==0||isNaN(0)&&isNaN(t)?0:e/t}function ds(e,t){b9.call(this,nut,e,t),this.b=this,this.a=al(e.mg(),Vt(this.e.mg(),this.c))}function VI(e,t){var i,a;for(a=t.length,i=0;il&&t.af&&t.b1||e.hc())return++e.a,e.g=0,t=e.i,e.hc(),t;throw Y(new K)}function W$e(e){var t;e.d==null?(++e.e,e.f=0,$Ve(null)):(++e.e,t=e.d,e.d=null,e.f=0,$Ve(t))}function TU(e,t){var i;re(t,109)?(h(e.c,81).ij(),i=h(t,109),l$e(e,i)):h(e.c,81).Gc(t)}function k0(e){return re(e,193)?xI(h(e,193)):re(e,160)?h(e,160).a:re(e,49)?new Hv(e):new FE(e)}function jRt(e,t,i){return e==(L0(),qG)?new jb:ol(t,1)!=0?new Mpe(i.length):new dBe(i.length)}function Pi(e,t){var i,a,l;if(i=e.cg(),i!=null&&e.fg())for(a=0,l=i.length;a=128?!1:e<64?kC(Zr(Gd(1,e),i),0):kC(Zr(Gd(1,e-64),t),0)}function YRt(e){var t;return t=h(G(e,(Ie(),da)),69),e.j==(qt(),Jr)&&(t==(Fe(),tn)||t==Zt)}function xee(e,t){var i;return re(t,13)?(i=(iu(),h(t,13)),e.oc(i)):iee(e,h(Hn(t),20).tc())}function ZRt(e){GNe();var t;return gOe(Roe,e)||(t=new tu,t.a=e,TJ(Roe,e,t)),h(Ds(Roe,e),573)}function Eee(e){return Xr(),e<3?(xf(e,"expectedSize"),e+1):e>22),l=e.h+t.h+(a>>22),qa(i&Xc,a&Xc,l&Zd)}function tVe(e,t){var i,a,l;return i=e.l-t.l,a=e.m-t.m+(i>>22),l=e.h-t.h+(a>>22),qa(i&Xc,a&Xc,l&Zd)}function Mee(e,t,i,a){return i==1?(!e.n&&(e.n=new ze(Qo,e,1,7)),Us(e.n,t,a)):sve(e,t,i,a)}function nVe(e,t){if(t==null)return!1;for(;e.a!=e.b;)if(Li(t,DU(e)))return!0;return!1}function hbe(e){return e.a.hc()?!0:e.a!=e.d?!1:(e.a=new F1e(e.e.d),e.a.hc())}function Lr(e,t){var i,a;return i=t.yc(),a=i.length,a==0?!1:(Nme(e.c,e.c.length,i),!0)}function tIt(e,t,i){var a,l;for(l=t.Tb().tc();l.hc();)a=h(l.ic(),38),e.Yb(a.kc(),a.lc(),i);return e}function iVe(e,t){var i;return i=e.a.get(t),i===void 0?++e.d:(e.a[hie](t),--e.c,EJ(e.b)),i}function bS(e,t){this.b=e,this.e=t,this.d=t.j,this.f=(Xo(),h(e,61).bj()),this.k=al(t.e.mg(),e)}function rVe(e){this.o=e,this.g=new Re,this.j=new Ir,this.n=new Ir,this.e=new Re,this.b=new Re}function sVe(e){this.a=le(xot,be,1704,e.length,0,2),this.b=le(Eot,be,1705,e.length,0,2),this.c=new LWe}function nIt(e,t){e.d==(Xs(),nf)||e.d==hm?h(t.a,57).c.nc(h(t.b,57)):h(t.b,57).c.nc(h(t.a,57))}function oVe(e,t){var i,a;for(a=new j(e.b);a.at?1:e==t?0:isNaN(e)?isNaN(t)?0:1:-1}function cVe(e,t){return!e||!t||e==t?!1:WWe(e.d.c,t.d.c+t.d.b)&&WWe(t.d.c,e.d.c+e.d.b)}function lVe(e,t){u9(e>=0,"Negative initial capacity"),u9(t>=0,"Non-positive load factor"),tl(this)}function uVe(e){var t,i;return i=(t=new jk,t),Ef(i,"T"),$n((!e.d&&(e.d=new Ol(ul,e,11)),e.d),i),i}function fVe(e,t){var i;return i=Qh(t.a._b()),Na(Cje(new si(null,new pi(t,1)),e.i),new eNe(e,i)),i}function dbe(e){var t,i,a;for(t=new Ir,a=On(e.d,0);a.b!=a.d.c;)i=h(Fn(a),170),Gi(t,i.c);return t}function pbe(e){var t,i,a,l;for(t=1,i=0,l=e._b();i>=1);return t}function rIt(e){var t;return t=_w(e),t>eye?Kr:t<-34028234663852886e22?Ts:t}function X(e,t,i,a,l){return l.ql=e,l.rl=t,l.sl=T,l.__elementTypeId$=i,l.__elementTypeCategory$=a,l}function wS(e,t,i,a,l){var f,g;for(g=i;g<=l;g++)for(f=t;f<=a;f++)L_(e,f,g)||P7(e,f,g,!0,!1)}function sIt(e){var t,i,a,l;for(i=e.a,a=0,l=i.length;ae.f,i=e.u+e.e[e.o.o]*e.d>e.f*e.s*e.d,t||i}function kU(e,t,i){var a,l;return a=new jQ(t,i),l=new oe,e.b=WYe(e,e.b,a,l),l.b||++e.c,e.b.b=!1,l.d}function vbe(e){var t;return(!e.c||!(e.Bb&1)&&e.c.Db&64)&&(t=du(e),re(t,96)&&(e.c=h(t,24))),e.c}function $g(e){var t,i;for(i=new j(e.a.b);i.a=0&&e[a]===t[a];a--);return a<0?0:_K(Zr(e[a],ao),Zr(t[a],ao))?-1:1}function mIt(e){var t;return e==null?!0:(t=e.length,t>0&&e.charCodeAt(t-1)==58&&!Ree(e,IL,DL))}function OA(e){switch(e.g){case 1:return $Qe;default:case 2:return 0;case 3:return Cie;case 4:return VQe}}function Lee(e){switch(e._b()){case 0:return e3e;case 1:return new a8e(e.tc().ic());default:return new K9(e)}}function bIt(e,t){So();var i,a;for(A1e(t,"predicate"),a=0;e.hc();a++)if(i=e.ic(),t.Mb(i))return a;return-1}function wIt(e,t,i){if(Hn(t),i.hc())for(Vpe(t,e.Lb(i.ic()));i.hc();)Vpe(t,e.c),Vpe(t,e.Lb(i.ic()));return t}function kee(e,t){var i;return t===e?!0:re(t,238)?(i=h(t,238),Li(e.Hc(),i.Hc())):!1}function Sa(e,t){var i;return jo(e)&&jo(t)&&(i=e-t,!isNaN(i))?i:Bwe(jo(e)?uu(e):e,jo(t)?uu(t):t)}function ZI(e){return Kg(),e<0?e!=-1?new hwe(-1,-e):ese:e<=10?T3e[wr(e)]:new hwe(1,e)}function vIt(){vi();var e;return Uae||(e=fMt(em("M",!0)),e=C9(em("M",!1),e),Uae=e,Uae)}function T_(e,t,i){var a,l;return l=(a=new oK,a),bo(l,t,i),$n((!e.q&&(e.q=new ze(lf,e,11,10)),e.q),l),l}function Ree(e,t,i){var a,l;for(a=0,l=e.length;a=e.b.c.length||(Cbe(e,2*t+1),i=2*t+2,it)throw Y(new un(q7+e+$Je+t));if(e<0||t>i)throw Y(new gpe(q7+e+sye+t+rye+i))}function yIt(e,t,i){if(t<0)throw Y(new ka(eet+t));t0)return oA(t-1,e.a.c.length),A0(e.a,t-1);throw Y(new U)}function DVe(e,t){var i;if(t.c.length!=0){for(;ive(e,t);)v7(e,t,!1);i=PU(t),e.a&&(e.a.If(i),DVe(e,i))}}function MIt(e,t){var i,a;for(a=On(e,0);a.b!=a.d.c;)i=h(Fn(a),204),i.e.length>0&&(t.td(i),i.i&&i6t(i))}function Fee(e,t,i){var a,l,f;for(a=new Ir,f=On(i,0);f.b!=f.d.c;)l=h(Fn(f),9),Gi(a,new Io(l));KIt(e,t,a)}function BVe(e,t){var i;return i=new sne((e.f&256)!=0,e.i,e.a,e.d,(e.f&16)!=0,e.j,e.g,t),e.e!=null||(i.c=e),i}function TIt(e,t){var i,a;return i=h(e.d.$b(t),13),i?(a=e.e.Oc(),a.oc(i),e.e.d-=i._b(),i.Pb(),a):null}function RU(e){var t,i,a,l;for(l=0,i=0,a=e.length;i1||t>=0&&e.b<3)}function gw(e){var t;++e.j,e.i==0?e.g=null:e.i>>0).toString(16):e.toString()}function Uee(e,t){e.D==null&&e.B!=null&&(e.D=e.B,e.B=null),fee(e,t==null?null:(pn(t),t)),e.C&&e.Kj(null)}function PIt(e,t){var i,a;for(i=e.a.length-1,e.c=e.c-1&i;t!=e.c;)a=t+1&i,zr(e.a,t,e.a[a]),t=a;zr(e.a,e.c,null)}function LIt(e,t){var i,a;for(i=e.a.length-1;t!=e.b;)a=t-1&i,zr(e.a,t,e.a[a]),t=a;zr(e.a,e.b,null),e.b=e.b+1&i}function kIt(e,t){X8(!this.b),X8(!this.d),cJ(BE(e.c)==0),cJ(t.d.c+t.e.c==0),cJ(!0),this.b=e,this.d=this.ec(t)}function FVe(e,t,i,a,l){a?bBt(e,t):(RBt(e,t,l),VGt(e,t,i)),t.c.length>1&&(yt(),ua(t,e.b),jUt(e.c,t))}function RIt(e,t,i,a,l){t==0||a==0||(t==1?l[a]=lwe(l,i,a,e[0]):a==1?l[t]=lwe(l,e,t,i[0]):bFt(e,i,l,t,a))}function IIt(e){var t,i;if(e==null)return null;for(t=0,i=e.length;t=e.c.b:e.a<=e.c.b))throw Y(new K);return t=e.a,e.a+=e.c.c,++e.b,He(t)}function yS(e){var t,i;return e>-129&&e<128?(t=e+128,i=(L8e(),m3e)[t],!i&&(i=m3e[t]=new EF(e)),i):new EF(e)}function He(e){var t,i;return e>-129&&e<128?(t=e+128,i=(l8e(),h3e)[t],!i&&(i=h3e[t]=new yF(e)),i):new yF(e)}function Gee(e,t){return!e||t&&!e.j||re(e,114)&&h(e,114).a.b==0?0:e.Pf()}function IU(e,t){return!e||t&&!e.k||re(e,114)&&h(e,114).a.a==0?0:e.Qf()}function Li(e,t){return ws(e)?pt(e,t):sw(e)||rw(e)?(pn(e),e===t):Xme(e)?e.Fb(t):$me(e)?e===t:H1e(e,t)}function Wr(e){return ws(e)?Hg(e):sw(e)?wr((pn(e),e)):rw(e)?(pn(e),e?1231:1237):Xme(e)?e.Hb():$me(e)?p0(e):B1e(e)}function rl(e){return ws(e)?Se:sw(e)?Eo:rw(e)?lo:Xme(e)||$me(e)?e.ql:e.ql||Array.isArray(e)&&q(knt,1)||knt}function OIt(e){return e?e.i&1?e==ku?lo:e==Rn?Ao:e==sv?oM:e==ks?Eo:e==R1?Z0:e==By?K0:e==Sc?Hx:$P:e:null}function mw(){mw=M,ect=(lr(),u3),tct=My,Xoe=(Pve(),qat),Yoe=Xat,iCe=Yat,aj=Zat,cj=Kat,Y5=Jat,rCe=Qat}function jee(){jee=M,vse=c7e(X(q(yL,1),Oe,110,0,[(Xs(),nf),rf])),_se=c7e(X(q(yL,1),Oe,110,0,[hm,ip]))}function NA(){NA=M,Tse=new kK("MIRROR_X",0),Cse=new kK("TRANSPOSE",1),Mse=new kK("MIRROR_AND_TRANSPOSE",2)}function NIt(e){var t;return t=new yje(e),SI(e.a,Yit,new Dl(X(q(x5,1),nt,341,0,[t]))),t.d&&De(t.f,t.d),t.f}function FIt(e){var t,i;for(i=new j(e.r);i.a=48&&e<58?e-48:e>=97&&e<97?e-97+10:e>=65&&e<65?e-65+10:-1}function UIt(e){var t,i;if(e==null)return!1;for(t=0,i=e.length;tPw?e-i>Pw:i-e>Pw}function io(e,t){var i;return jo(e)&&jo(t)&&(i=e+t,j6a)throw Y(new o_(t,a));if(e.xh()&&e.pc(i))throw Y(new un(s5));e.mh(t,i)}function HVe(e,t,i){if(e<0||t>i)throw Y(new ka(q7+e+sye+t+", size: "+i));if(e>t)throw Y(new un(q7+e+$Je+t))}function Ibe(e){throw Bee(),Y(new BDe("Unexpected typeof result '"+e+"'; please report this bug to the GWT team"))}function zp(e){switch(aw(),e.c){case 0:return eS(),GP;case 1:return new j2(s8t(new UE(e)));default:return new DDe(e)}}function qVe(e){var t;return e.Db&64?Zu(e):(t=new ru(Zu(e)),t.a+=" (source: ",ho(t,e.d),t.a+=")",t.a)}function Ee(e,t,i){return i==null?(!e.p&&(e.p=(Xr(),new li)),fS(e.p,t)):(!e.p&&(e.p=(Xr(),new li)),fr(e.p,t,i)),e}function QI(e,t,i){return i==null?(!e.p&&(e.p=(Xr(),new li)),fS(e.p,t)):(!e.p&&(e.p=(Xr(),new li)),fr(e.p,t,i)),e}function e6(e,t,i){var a;e.Eh(e.i+1),a=e.Ch(t,i),t!=e.i&&wc(e.g,t,e.g,t+1,e.i-t),zr(e.g,t,a),++e.i,e.sh(t,i),e.th()}function Wee(e,t,i){var a,l,f;for(a=0,f=On(e,0);f.b!=f.d.c&&(l=ce(Xe(Fn(f))),!(l>i));)l>=t&&++a;return a}function Hee(e,t){var i,a,l;for(i=0,l=ra(e,t).tc();l.hc();)a=h(l.ic(),11),i+=G(a,(Ie(),Al))!=null?1:0;return i}function HIt(e){var t;return t=h(px(e.c.c,""),199),t||(t=new ax(DE(IE(new $b,""),"Other")),B0(e.c.c,"",t)),t}function XVe(e){this.a=new zc,this.d=new zc,this.b=new zc,this.c=new zc,this.g=new zc,this.i=new zc,this.f=e}function Xs(){Xs=M,Bh=new VR(Ux,0),rf=new VR(XS,1),nf=new VR(qS,2),ip=new VR(ore,3),hm=new VR("UP",4)}function e1(){e1=M,vj=new qK("INHERIT",0),h3=new qK("INCLUDE_CHILDREN",1),ML=new qK("SEPARATE_CHILDREN",2)}function qIt(e,t,i){var a,l;return a=new Vd(e.e,3,13,null,(l=t.c,l||(Et(),Uh)),jp(e,t),!1),i?i.Sh(a):i=a,i}function XIt(e,t,i){var a,l;return a=new Vd(e.e,4,13,(l=t.c,l||(Et(),Uh)),null,jp(e,t),!1),i?i.Sh(a):i=a,i}function Dbe(e,t,i){var a,l;return l=e.sb,e.sb=t,e.Db&4&&!(e.Db&1)&&(a=new cs(e,1,4,l,t),i?i.Sh(a):i=a),i}function Bbe(e,t,i){var a,l;return l=e.r,e.r=t,e.Db&4&&!(e.Db&1)&&(a=new cs(e,1,8,l,e.r),i?i.Sh(a):i=a),i}function Gp(e,t){var i,a;return i=h(t,614),a=i.Hj(),!a&&i.Ij(a=re(t,96)?new bNe(e,h(t,24)):new H7e(e,h(t,140))),a}function Obe(e,t){var i;return e===t?!0:re(t,89)?(i=h(t,89),e.e==i.e&&e.d==i.d&&m4t(e,i.a)):!1}function YIt(e,t){var i;if(i=T6(e,t),re(i,335))return h(i,29);throw Y(new un(ry+t+"' is not a valid attribute"))}function t6(e,t){var i;return i=new _t,e.a.sd(i)?(WE(),new fK(pn(rje(e,i.a,t)))):(f_(e),WE(),WE(),L3e)}function YVe(e,t){var i;e.c.length!=0&&(i=h(vo(e,le(xu,Tf,8,e.c.length,0,1)),123),vge(i,new _H),IXe(i,t))}function ZVe(e,t){var i;e.c.length!=0&&(i=h(vo(e,le(xu,Tf,8,e.c.length,0,1)),123),vge(i,new yH),IXe(i,t))}function ES(e,t){switch(t.g){case 2:case 1:return ra(e,t);case 3:case 4:return k0(ra(e,t))}return yt(),yt(),uo}function Nbe(e,t,i,a){switch(t){case 1:return!e.n&&(e.n=new ze(Qo,e,1,7)),e.n;case 2:return e.k}return Mwe(e,t,i,a)}function ZIt(e,t,i,a,l,f,g,m){var v;for(v=i;f=a||t=65&&e<=70?e-65+10:e>=97&&e<=102?e-97+10:e>=48&&e<=57?e-48:0}function QVe(e){return e-=e>>1&1431655765,e=(e>>2&858993459)+(e&858993459),e=(e>>4)+e&252645135,e+=e>>8,e+=e>>16,e&63}function C_(e,t){var i;i=(e.Bb&256)!=0,t?e.Bb|=256:e.Bb&=-257,e.Db&4&&!(e.Db&1)&&Pi(e,new Hu(e,1,2,i,t))}function eWe(e,t){var i;i=(e.Bb&256)!=0,t?e.Bb|=256:e.Bb&=-257,e.Db&4&&!(e.Db&1)&&Pi(e,new Hu(e,1,8,i,t))}function Fbe(e,t){var i;i=(e.Bb&256)!=0,t?e.Bb|=256:e.Bb&=-257,e.Db&4&&!(e.Db&1)&&Pi(e,new Hu(e,1,8,i,t))}function tWe(e,t){var i;i=(e.Bb&512)!=0,t?e.Bb|=512:e.Bb&=-513,e.Db&4&&!(e.Db&1)&&Pi(e,new Hu(e,1,9,i,t))}function A_(e,t){var i;i=(e.Bb&512)!=0,t?e.Bb|=512:e.Bb&=-513,e.Db&4&&!(e.Db&1)&&Pi(e,new Hu(e,1,3,i,t))}function UA(e,t){var i;return e.b==-1&&e.a&&(i=e.a.Vi(),e.b=i?e.c.qg(e.a.pi(),i):gr(e.c.mg(),e.a)),e.c.hg(e.b,t)}function QIt(e,t,i){var a,l;return l=e.a,e.a=t,e.Db&4&&!(e.Db&1)&&(a=new cs(e,1,5,l,e.a),i?Hwe(i,a):i=a),i}function e6t(e,t){var i;if(i=Pp(e.i,t),i==null)throw Y(new vh("Node did not exist in input."));return lbe(t,i),null}function t6t(e,t){var i;if(i=Ii(e.k,t),i==null)throw Y(new vh("Port did not exist in input."));return lbe(t,i),null}function SS(e){if(e.c)SS(e.c);else if(e.d)throw Y(new ma("Stream already terminated, can't be modified or used"))}function n6t(e){var t;if(!e.a)throw Y(new ma("Cannot offset an unassigned cut."));t=e.c-e.b,e.b+=t,OUe(e,t),NUe(e,t)}function i6t(e){var t;e.g&&(t=e.c.pf()?e.f:e.a,Xve(t.a,e.o,!0),Xve(t.a,e.o,!1),Ee(e.o,($e(),Yi),(Ms(),d3)))}function r6t(e){var t,i,a;for(t=h(G(e,(fa(),DTe)),15),a=t.tc();a.hc();)i=h(a.ic(),170),Gi(i.b.d,i),Gi(i.c.b,i)}function nWe(e){var t,i,a;for(a=0,i=(So(),new Od(Zh(zd(e.a,new z))));Gn(i);)t=h(Mn(i),14),t.c.g==t.d.g||++a;return a}function iWe(e,t){var i,a;for(a=new Dn(e);a.e!=a.i._b();)if(i=h(Xn(a),24),Be(t)===Be(i))return!0;return!1}function rWe(e,t){var i,a;for(a=new Dn(e);a.e!=a.i._b();)if(i=h(Xn(a),133),Be(t)===Be(i))return!0;return!1}function s6t(e,t,i){var a,l,f;return f=(l=BS(e.b,t),l),f&&(a=h(B7(OI(e,f),""),24),a)?Bve(e,a,t,i):null}function qee(e,t,i){var a,l,f;return f=(l=BS(e.b,t),l),f&&(a=h(B7(OI(e,f),""),24),a)?Ove(e,a,t,i):null}function Ube(e){var t,i;return t=e.j,t==(qt(),Jr)?(i=h(G(e,(Ie(),da)),69),i==(Fe(),bn)||i==ei):!1}function sWe(e){var t;return t=new u0,t.a+="VerticalSegment ",Rc(t,e.e),t.a+=" ",Si(t,lJ(new LR(Ta),new j(e.k))),t.a}function o6t(e){var t,i,a;for(t=new Re,a=new j(e.b);a.a0&&(a+=l,++i);return i>1&&(a+=e.d*(i-1)),a}function b6t(e,t,i){var a,l;for(l=e.a.Xb().tc();l.hc();)if(a=h(l.ic(),8),Gg(i,h(Tt(t,a.o),13)))return a;return null}function Kee(e,t,i,a){var l;if(l=e.length,t>=l)return l;for(t=t>0?t:0;t=1?rf:ip):i}function v6t(e){var t,i,a;for(t=0,a=new j(e.c.a);a.a=64&&t<128&&(l=Yf(l,Gd(1,t-64)));return l}function hWe(e,t,i){var a,l,f;for(l=Tn(t?As(e):ur(e));Gn(l);)a=h(Mn(l),14),f=t?a.c.g:a.d.g,f.j==(qt(),ll)&&qs(f,i)}function _6t(e,t,i){var a;a=new Jze(e,t),ir(e.r,t.ef(),a),i&&e.t!=(Jf(),_j)&&(a.c=new s7e(e.d),ad(t.We(),new vZ(a)))}function dWe(e,t,i){var a,l;return a=(h0(),l=new pE,l),see(a,t),oee(a,i),e&&$n((!e.a&&(e.a=new vs(sh,e,5)),e.a),a),a}function Bn(e){if(e.i==null)throw Y(new ma("The task has not begun yet."));e.b||(e.c0&&t.charCodeAt(0)==43?t.substr(1,t.length-1):t))}function S6t(e){var t;return e==null?null:new Tg((t=Da(e,!0),t.length>0&&t.charCodeAt(0)==43?t.substr(1,t.length-1):t))}function Wbe(e){var t;return t=le(Yl,Ah,22,2,15,1),e-=oo,t[0]=(e>>10)+$6&Gr,t[1]=(e&1023)+56320&Gr,fu(t,0,t.length)}function M6t(e){var t,i;for(i=c8t(jl(fw(e))).tc();i.hc();)if(t=Qn(i.ic()),uP(e,t))return N4t((NBe(),Hlt),t);return null}function fu(e,t,i){var a,l,f,g;for(f=t+i,x0e(t,f,e.length),g="",l=t;lt&&a.Ld(e[f-1],e[f])>0;--f)g=e[f],zr(e,f,e[f-1]),zr(e,f-1,g)}function C6t(e,t){var i;e.c=t,e.a=B6t(t),e.a<54&&(e.f=(i=t.d>1?Yf(Gd(t.a[1],32),Zr(t.a[0],ao)):Zr(t.a[0],ao),aS(Jm(t.e,i))))}function Jee(){Ywe();var e,t,i;i=iVt+++V4t(),e=wr(w.Math.floor(i*W6))&H7,t=wr(i-e*iye),this.a=e^1502,this.b=t^die}function A6t(e,t,i){e.n=cw(R1,[be,tye],[378,22],14,[i,wr(w.Math.ceil(t/32))],2),e.o=t,e.p=i,e.j=t-1>>1,e.k=i-1>>1}function P6t(e,t){var i,a,l;a=p_(t),l=ce(Xe(TS(a,($e(),ih)))),i=w.Math.max(0,l/2-.5),ZA(t,i,1),De(e,new COe(t,i))}function pWe(e,t){var i,a;for(i=On(e,0);i.b!=i.d.c;){if(a=ce(Xe(Fn(i))),a==t)return;if(a>t){cS(i);break}}JE(i,t)}function zt(e,t){var i,a,l,f,g;if(i=t.f,B0(e.c.d,i,t),t.g!=null)for(l=t.g,f=0,g=l.length;ft?1:$8(isNaN(e),isNaN(t))}function wWe(e){eo(),q8(this),z9(this),this.e=e,e!=null&&DFe(e,jne,this),this.g=e==null?qc:za(e),this.a="",this.b=e,this.a=""}function GA(e){var t;this.a=(t=h(e.e&&e.e(),10),new Bc(t,h(Qc(t,t.length),10),0)),this.b=le(sn,nt,1,this.a.a.length,5,1)}function $U(e,t){var i,a;return i=e._b(),t.lengthi&&zr(t,i,null),t}function Xbe(e){var t,i,a;for(a=new Mp,a.a+="[",t=0,i=e._b();t>5,t=e&31,a=le(Rn,ii,22,i+1,15,1),a[i]=1<f?t:f;return He(t)}function U6t(e,t){var i,a;for(a=e.e.a.Xb().tc();a.hc();)if(i=h(a.ic(),247),qOt(t,i.d)||KNt(t,i.d))return!0;return!1}function vWe(e,t){var i,a,l,f;for(f=e.g.ed(),i=0;f.hc();){if(a=ce(Xe(f.ic())),l=a-t,l>ey)return i;l>hz&&++i}return i}function _We(e,t){var i,a,l;l=t.d.g,a=l.j,!(a==(qt(),fs)||a==ja||a==nh)&&(i=Tn(ur(l)),Gn(i)&&fr(e.k,t,h(Mn(i),14)))}function yWe(e,t){var i,a;i=t==(JA(),Fse),a=Zbe(e),i&&!a||!i&&a?Ee(e,($e(),Dh),(ld(),Q5)):Ee(e,($e(),Dh),(ld(),J5))}function cd(){cd=M,gae=new D8(Ux,0),pae=new D8("POLYLINE",1),xM=new D8("ORTHOGONAL",2),cb=new D8("SPLINES",3)}function VU(){VU=M,Hoe=new WK("OVERLAP_REMOVAL",0),Voe=new WK("COMPACTION",1),Woe=new WK("GRAPH_SIZE_CALCULATION",2)}function WU(){WU=M,_Te=new FK("EQUALLY_DISTRIBUTED",0),Aoe=new FK("NORTH_STACKED",1),yTe=new FK("NORTH_SEQUENCE",2)}function z6t(e){var t,i,a,l,f;return f=Zwe(e),i=x8(e.c),a=!i,a&&(l=new Om,Og(f,"knownLayouters",l),t=new jZ(l),mo(e.c,t)),f}function G6t(e,t,i){var a,l;for(l=re(t,62)&&h(h(t,17),62).Bb&oo?new QK(t,e):new bS(t,e),a=0;a3;)l*=10,--f;e=(e+(l>>1))/l|0}return a.i=e,!0}function vx(e,t,i){var a,l;for(l=e.tc();l.hc();)if(a=l.ic(),Be(t)===Be(a)||t!=null&&Li(t,a))return i&&l.jc(),!0;return!1}function AWe(e,t){var i,a;if(t){for(i=0;i0&&(t.lengthe.i&&zr(t,e.i,null),t}function PWe(e,t){var i,a,l,f;return i=t>>5,t&=31,l=e.d+i+(t==0?0:1),a=le(Rn,ii,22,l,15,1),dOt(a,e.a,i,t),f=new l_(e.e,l,a),gA(f),f}function qU(e,t){oge();var i,a;return i=oI(($f(),$f(),jP)),a=null,t==i&&(a=h(Ua(s3e,e),556)),a||(a=new tUe(e),t==i&&Zo(s3e,e,a)),a}function gr(e,t){var i,a,l;if(i=(e.i==null&&Jg(e),e.i),a=t.pi(),a!=-1){for(l=i.length;a=0;--a)for(t=i[a],l=0;l0&&Sa(e,128)<0?(t=nr(e)+128,i=(P8e(),d3e)[t],!i&&(i=d3e[t]=new xF(e)),i):new xF(e)}function s6(e){return Kg(),Sa(e,0)<0?Sa(e,-1)!=0?new Owe(-1,dS(e)):ese:Sa(e,10)<=0?T3e[nr(e)]:new Owe(1,e)}function LWe(){hpe.call(this,new E0e(16)),xf(2,"expectedValuesPerKey"),this.b=2,this.a=new S1e(null,null,0,null),LE(this.a,this.a)}function XU(){XU=M,yae=new O8("SIMPLE",0),wAe=new O8("GROUP_DEC",1),_Ae=new O8("GROUP_MIXED",2),vAe=new O8("GROUP_INC",3)}function twe(){twe=M,mAe=new ex(15),Uct=new ba((lr(),Sy),mAe),Gct=new ba(My,15),zct=new ba(fae,He(0)),Fct=new ba(_M,WS)}function tte(){tte=M,Bae=new zk,GAe=new nX,jAe=new Gk,$Ae=new SN,VAe=new MN,WAe=new TN,HAe=new JT,qAe=new iX,XAe=new CN}function kWe(e){this.e=le(Rn,ii,22,e.length,15,1),this.c=le(ku,f1,22,e.length,16,1),this.b=le(ku,f1,22,e.length,16,1),this.f=0}function nwe(e,t){this.n=cw(R1,[be,tye],[378,22],14,[t,wr(w.Math.ceil(e/32))],2),this.o=e,this.p=t,this.j=e-1>>1,this.k=t-1>>1}function RWe(e,t,i){kje(),EDe.call(this),this.a=cw(Xct,[be,Pye],[537,171],0,[Mj,xae],2),this.c=new $E,this.g=e,this.f=t,this.d=i}function Ga(e,t,i){var a,l,f;return e.ti()?(a=e.i,f=e.ui(),e6(e,a,t),l=e.mi(3,null,t,a,f),i?i.Sh(l):i=l):e6(e,e.i,t),i}function Sf(e,t){var i,a,l;return e.f>0&&(e.Fi(),a=t==null?0:Wr(t),l=(a&zi)%e.d.length,i=_ve(e,l,a,t),i)?i.lc():null}function nte(e,t){var i,a,l;return e.f>0?(e.Fi(),a=t==null?0:Wr(t),l=(a&zi)%e.d.length,i=lYe(e,l,a,t),i!=-1):!1}function o6(e,t){var i,a,l,f;for(f=al(e.e.mg(),t),i=h(e.g,124),l=0;l2e3&&(Rnt=e,Uz=w.setTimeout(KEt,10))),Fz++==0?(qkt((mr(),r3e)),!0):!1}function a5t(){return Error.stackTraceLimit>0?(w.Error.stackTraceLimit=Error.stackTraceLimit=64,!0):"stack"in new Error}function FWe(e,t){return e.e>t.e?1:e.et.d?e.e:e.d=0?f=f.a[1]:(l=f,f=f.a[0])}return l}function VWe(e,t,i){var a,l,f;for(l=null,f=e.b;f;){if(a=e.a.Ld(t,f.d),i&&a==0)return f;a<=0?f=f.a[0]:(l=f,f=f.a[1])}return l}function u5t(e,t,i,a){var l,f,g;return l=!1,PGt(e.f,i,a)&&(T5t(e.f,e.a[t][i],e.a[t][a]),f=e.a[t],g=f[a],f[a]=f[i],f[i]=g,l=!0),l}function swe(e,t){var i,a,l;for(l=e.g.ed();l.hc();)if(i=ce(Xe(l.ic())),a=w.Math.abs(i-t),at?1:$8(isNaN(e),isNaN(t)))>0}function awe(e,t){return yh(),yh(),Ng(tm),(w.Math.abs(e-t)<=tm||e==t||isNaN(e)&&isNaN(t)?0:et?1:$8(isNaN(e),isNaN(t)))<0}function WWe(e,t){return yh(),yh(),Ng(tm),(w.Math.abs(e-t)<=tm||e==t||isNaN(e)&&isNaN(t)?0:et?1:$8(isNaN(e),isNaN(t)))<=0}function d5t(e,t){if(t.c==e)return t.d;if(t.d==e)return t.c;throw Y(new un("Input edge is not connected to the input port."))}function YU(e,t){return pn(e),t==null?!1:pt(e,t)?!0:e.length==t.length&&pt(e.toLowerCase(),t.toLowerCase())}function HWe(e){var t,i,a,l,f;if(e==null)return null;for(f=new Re,i=Iee(e),a=0,l=i.length;at.e?1:e.ft.f?1:Wr(e)-Wr(t)}function CS(e,t){Xr(),Hn(e);try{return e.Vb(t)}catch(i){if(i=hr(i),re(i,177))return null;if(re(i,169))return null;throw Y(i)}}function _5t(e,t){Xr(),Hn(e);try{return e.$b(t)}catch(i){if(i=hr(i),re(i,177))return null;if(re(i,169))return null;throw Y(i)}}function QWe(e){Kg(),e.length==0?(this.e=0,this.d=1,this.a=X(q(Rn,1),ii,22,15,[0])):(this.e=1,this.d=e.length,this.a=e,gA(this))}function lwe(e,t,i,a){IS();var l,f;for(l=0,f=0;f=f?(PIt(e,t),-1):(LIt(e,t),1)}function eHe(e,t){var i,a,l;++e.j,a=e.g==null?0:e.g.length,t>a&&(l=e.g,i=a+(a/2|0)+4,iuie)return i.zg();if(a=i.sg(),a||i==e)break}return a}function tHe(e,t){var i,a;return i=t.Yg(e.a),i&&(a=Qn(Sf((!i.b&&(i.b=new bl((Et(),Uo),Ca,i)),i.b),mi)),a!=null)?a:t.be()}function S5t(e,t){var i,a;return i=t.Yg(e.a),i&&(a=Qn(Sf((!i.b&&(i.b=new bl((Et(),Uo),Ca,i)),i.b),mi)),a!=null)?a:t.be()}function Ht(e){var t;if(re(e.a,4)){if(t=zWe(e.a),t==null)throw Y(new ma(tet+e.b+"'. "+rxe+(Nd(wD),wD.k)+sxe));return t}else return e.a}function M5t(e){var t;if(e==null)return null;if(t=E8t(Da(e,!0)),t==null)throw Y(new mK("Invalid hexBinary value: '"+e+"'"));return t}function nHe(e,t){var i,a,l;if(De(Zz,e),t.nc(e),i=h(Ii(fse,e),19),i)for(l=i.tc();l.hc();)a=h(l.ic(),35),Jo(Zz,a,0)!=-1||nHe(a,t)}function T5t(e,t,i){var a,l;Bte(e.e,t,i,(Fe(),tn)),Bte(e.i,t,i,Zt),e.a&&(l=h(G(t,(Ie(),Jn)),11),a=h(G(i,Jn),11),CQ(e.g,l,a))}function iHe(e){var t;Be(nn(e,(lr(),Ey)))===Be((e1(),vj))&&(to(e)?(t=h(nn(to(e),Ey),316),oc(e,Ey,t)):oc(e,Ey,ML))}function uwe(e,t,i){this.c=e,this.f=new Re,this.e=new fo,this.j=new Hme,this.n=new Hme,this.b=t,this.g=new Xf(t.c,t.d,t.b,t.a),this.a=i}function fwe(e,t,i,a,l,f){Cge(this),this.e=e,this.f=t,this.d=i,this.c=a,this.g=l,this.b=f,this.j=ce(Xe(l.tc().ic())),this.i=ce(Xe(_$e(l)))}function C5t(e){var t;for(t=h(Mn(Tn(As(e))),14).c.g;t.j==(qt(),Nr);)Ee(t,(Ie(),k5),(vt(),vt(),!0)),t=h(Mn(Tn(As(t))),14).c.g}function A5t(e,t,i){var a,l,f,g;return f=t.i,g=i.i,f!=g?f.g-g.g:(a=e.f[t.o],l=e.f[i.o],a==0&&l==0?0:a==0?-1:l==0?1:no(a,l))}function Xn(e){var t;try{return t=e.i.cd(e.e),e.Bi(),e.g=e.e++,t}catch(i){throw i=hr(i),re(i,79)?(e.Bi(),Y(new K)):Y(i)}}function ate(e){var t;try{return t=e.c.yh(e.e),e.Bi(),e.g=e.e++,t}catch(i){throw i=hr(i),re(i,79)?(e.Bi(),Y(new K)):Y(i)}}function qg(e,t){var i;i=e.fd(t);try{return i.ic()}catch(a){throw a=hr(a),re(a,101)?Y(new ka("Can't get element "+t)):Y(a)}}function rHe(e,t){iu(),Hn(e);try{return e.pc(t)}catch(i){if(i=hr(i),re(i,177))return!1;if(re(i,169))return!1;throw Y(i)}}function P5t(e,t){Xr(),Hn(e);try{return e.Qb(t)}catch(i){if(i=hr(i),re(i,177))return!1;if(re(i,169))return!1;throw Y(i)}}function sHe(e,t,i){return new Xf(w.Math.min(e.a,t.a)-i/2,w.Math.min(e.b,t.b)-i/2,w.Math.abs(e.a-t.a)+i,w.Math.abs(e.b-t.b)+i)}function oHe(e,t){var i,a,l,f;for(i=0,l=new j(t.a);l.a0),t.a.cd(t.c=--t.b))}function i1(){i1=M,Pn=new $R("PARENTS",0),pa=new $R("NODES",1),md=new $R("EDGES",2),ab=new $R("PORTS",3),fm=new $R("LABELS",4)}function Xg(){Xg=M,lb=new WR("DISTRIBUTED",0),wae=new WR("JUSTIFIED",1),fAe=new WR("BEGIN",2),TL=new WR(MP,3),hAe=new WR("END",4)}function HA(e,t,i){EDe.call(this),this.a=le(Xct,Pye,171,(yf(),X(q(Zw,1),Oe,203,0,[oa,Va,aa])).length,0,1),this.b=e,this.d=t,this.c=i}function l6(e,t){var i,a;if(++e.j,t!=null&&(i=(a=e.a.Cb,re(a,92)?h(a,92).cg():null),kFt(t,i))){VA(e.a,4,i);return}VA(e.a,4,h(t,116))}function L5t(e,t){var i,a;return t!=null&&vw(t).length!=0&&(i=o_e(e,t),i)?i:An.length!=0&&(a=o_e(e,An),a)?a:null}function k5t(e){var t,i;if(e.j==(qt(),Nr)){for(i=Tn(t1(e));Gn(i);)if(t=h(Mn(i),14),!Ko(t)&&e.c==Ate(t,e).c)return!0}return!1}function KU(){KU=M,rse=new Xpe("NUM_OF_EXTERNAL_SIDES_THAN_NUM_OF_EXTENSIONS_LAST",0),z3e=new Xpe("CORNER_CASES_THAN_SINGLE_SIDE_LAST",1)}function cte(){return U7(),X(q(ylt,1),Oe,147,0,[vlt,wlt,_lt,ult,llt,flt,plt,dlt,hlt,blt,mlt,glt,alt,olt,clt,rlt,ilt,slt,tlt,elt,nlt,Eae])}function lte(e,t){var i;switch(i=!e.v.pc((Wl(),C1))||e.q==(Ms(),Ba),e.t.g){case 1:i?Zjt(e,t):YKe(e,t);break;case 0:i?djt(e,t):WKe(e,t)}}function R5t(e,t,i){var a;switch(a=i.q.getFullYear()-j0+j0,a<0&&(a=-a),t){case 1:e.a+=a;break;case 2:od(e,a%100,2);break;default:od(e,a,t)}}function I5t(e){var t;switch(t=e.Mh(null),t){case 10:return 0;case 15:return 1;case 14:return 2;case 11:return 3;case 21:return 4}return-1}function ute(e){switch(e.g){case 1:return Xs(),hm;case 4:return Xs(),nf;case 2:return Xs(),rf;case 3:return Xs(),ip}return Xs(),Bh}function D5t(e,t,i,a){var l,f,g;return l=new Vd(e.e,1,13,(g=t.c,g||(Et(),Uh)),(f=i.c,f||(Et(),Uh)),jp(e,t),!1),a?a.Sh(l):a=l,a}function On(e,t){var i,a;if(g_(t,e.b),t>=e.b>>1)for(a=e.c,i=e.b;i>t;--i)a=a.b;else for(a=e.a.a,i=0;i=0?e.Fg(l):Vte(e,a)):i<0?Vte(e,a):h(a,61).aj().fj(e,e.Qg(),i)}function cHe(e){var t,i,a;for(a=(!e.o&&(e.o=new nl((Ma(),sp),pm,e,0)),e.o),i=a.c.tc();i.e!=i.i._b();)t=h(i.Ci(),38),t.lc();return CI(a)}function z5t(e){var t,i,a,l;for(a=le(K$t,nt,144,e.c.length,0,1),l=0,i=new j(e);i.a0&&(De(e.b,new r9e(t.a,i)),a=t.a.length,0a&&(t.a+=VNe(le(Yl,Ah,22,-a,15,1))))}function QU(e){switch(Rpe(),this.c=new Re,this.d=e,e.g){case 0:case 2:this.a=T1e(CEe),this.b=Kr;break;case 3:case 1:this.a=CEe,this.b=Ts}}function hwe(e,t){this.e=e,t.5&&f<50;)l=EYe(a),i=Sx(a,l,!0),t=w.Math.abs(i.b),++f;return Sx(e,l,!1)}function fHe(e){var t,i,a,l,f;for(a=yne(e),t=Kr,f=0,l=0;t>.5&&f<50;)l=xYe(a),i=Sx(a,l,!0),t=w.Math.abs(i.a),++f;return Sx(e,l,!1)}function V5t(e,t){var i,a,l,f;for(f=0,a=On(e,0);a.b!=a.d.c;)i=h(Fn(a),35),f+=w.Math.pow(i.g*i.f-t,2);return l=w.Math.sqrt(f/(e.b-1)),l}function hHe(e,t){var i,a,l;for(i=e.o,l=h(h(Qi(e.r,t),19),60).tc();l.hc();)a=h(l.ic(),111),a.e.a=UDt(a,i.a),a.e.b=i.b*ce(Xe(a.b.xe(Tj)))}function _x(e,t,i,a){var l;return i>=0?e.Bg(t,i,a):(e.yg()&&(a=(l=e.og(),l>=0?e.jg(a):e.yg().Cg(e,-1-l,null,a))),e.lg(t,i,a))}function yx(e,t,i){var a,l;if(l=e._b(),t>=l)throw Y(new o_(t,l));if(e.xh()&&(a=e.dd(i),a>=0&&a!=t))throw Y(new un(s5));return e.Ah(t,i)}function W5t(e,t,i){var a,l,f,g;return a=e.dd(t),a!=-1&&(e.ti()?(f=e.ui(),g=x9(e,a),l=e.mi(4,g,null,a,f),i?i.Sh(l):i=l):x9(e,a)),i}function Us(e,t,i){var a,l,f,g;return a=e.dd(t),a!=-1&&(e.ti()?(f=e.ui(),g=xx(e,a),l=e.mi(4,g,null,a,f),i?i.Sh(l):i=l):xx(e,a)),i}function dHe(e){var t,i,a;e.b==e.c&&(a=e.a.length,i=gbe(8>a?8:a)<<1,e.b!=0?(t=Qc(e.a,i),g$e(e,t,a),e.a=t,e.b=0):nK(e.a,i),e.c=a)}function H5t(e){var t,i;t=new Re,i=e;do i=h(Mn(Tn(ur(i))),14).d.g,i.j==(qt(),Nr)&&(t.c[t.c.length]=i);while(i.j==(qt(),Nr));return t}function pHe(e){var t,i;for(this.b=new Re,this.c=e,this.a=!1,i=new j(e.a);i.a0||e==(Vr(),Hre)||t==(so(),qre))throw Y(new un("Invalid range: "+aze(e,t)))}function q5t(e){switch(e.g){case 1:return R0(),dD;case 3:return R0(),hD;case 2:return R0(),Mae;case 4:return R0(),Sae;default:return null}}function dte(e){switch(e.g){case 0:return null;case 1:return new C$e;case 2:return new spe;default:throw Y(new un(ure+(e.f!=null?e.f:""+e.g)))}}function X5t(e,t,i){if(e.e)switch(e.b){case 1:bPt(e.c,t,i);break;case 0:wPt(e.c,t,i)}else mze(e.c,t,i);e.a[t.o][i.o]=e.c.i,e.a[i.o][t.o]=e.c.e}function ww(){ww=M,jG=new L8(W0,0),Soe=new L8("PORT_POSITION",1),_y=new L8("NODE_SIZE_WHERE_SPACE_PERMITS",2),vy=new L8("NODE_SIZE",3)}function bHe(e){var t,i,a;for(i=new j(e.a);i.a=0?e.ug(g,i,!0):Cx(e,f,i)):h(f,61).aj().cj(e,e.Qg(),l,i,a)}function Y5t(e,t){var i,a,l,f;return f=e.o,i=e.p,f=0)return l;if(e.Rj()){for(a=0;al&&zr(t,l,null),t}function wHe(e,t){var i,a,l;for(l=e.a.length,t.lengthl&&zr(t,l,null),t}function L_(e,t,i){try{return nw(tee(e,t,i),1)}catch(a){throw a=hr(a),re(a,305)?Y(new ka(_ie+e.o+"*"+e.p+yie+t+Ta+i+xie)):Y(a)}}function vHe(e,t,i){try{return nw(tee(e,t,i),0)}catch(a){throw a=hr(a),re(a,305)?Y(new ka(_ie+e.o+"*"+e.p+yie+t+Ta+i+xie)):Y(a)}}function _He(e,t,i){try{return nw(tee(e,t,i),2)}catch(a){throw a=hr(a),re(a,305)?Y(new ka(_ie+e.o+"*"+e.p+yie+t+Ta+i+xie)):Y(a)}}function yHe(e,t,i){var a;try{return L_(e,t+e.j,i+e.k)}catch(l){throw l=hr(l),re(l,79)?(a=l,Y(new ka(a.g+Y7+t+Ta+i+")."))):Y(l)}}function Z5t(e,t,i){var a;try{return vHe(e,t+e.j,i+e.k)}catch(l){throw l=hr(l),re(l,79)?(a=l,Y(new ka(a.g+Y7+t+Ta+i+")."))):Y(l)}}function K5t(e,t,i){var a;try{return _He(e,t+e.j,i+e.k)}catch(l){throw l=hr(l),re(l,79)?(a=l,Y(new ka(a.g+Y7+t+Ta+i+")."))):Y(l)}}function xHe(e,t){if(e.g==-1)throw Y(new Ha);e.Bi();try{e.d.hd(e.g,t),e.f=e.d.j}catch(i){throw i=hr(i),re(i,79)?Y(new P):Y(i)}}function EHe(e,t,i){ni(i,"Compound graph preprocessor",1),e.a=new Kv,HKe(e,t,null),Pzt(e,t),e9t(e),Ee(t,(Ie(),YSe),e.a),e.a=null,tl(e.b),Bn(i)}function pte(e,t){var i,a;if(kge(t>0),(t&-t)==t)return wr(t*ol(e,31)*4656612873077393e-25);do i=ol(e,31),a=i%t;while(i-a+(t-1)<0);return wr(a)}function J5t(e,t,i){switch(i.g){case 1:e.a=t.a/2,e.b=0;break;case 2:e.a=t.a,e.b=t.b/2;break;case 3:e.a=t.a/2,e.b=t.b;break;case 4:e.a=0,e.b=t.b/2}}function Q5t(e){var t,i;for(i=h(G(e,(Ie(),LG)),15).tc();i.hc();)if(t=h(i.ic(),68),ow(t,($e(),DG)))return h(G(t,DG),276);return null}function eDt(e,t){var i,a,l;for(i=g0(new Fm,e),l=new j(t);l.a1&&(f=eDt(e,t)),f}function rDt(e,t){var i,a,l,f;for(f=new j(t.a);f.a102?-1:e<=57?e-48:e<65?-1:e<=70?e-65+10:e<97?-1:e-97+10}function AHe(e,t){var i,a,l;for(e.b[t.g]=1,a=On(t.d,0);a.b!=a.d.c;)i=h(Fn(a),170),l=i.c,e.b[l.g]==1?Gi(e.a,i):e.b[l.g]==2?e.b[l.g]=1:AHe(e,l)}function PHe(e,t){var i;return i=X(q(ks,1),Vo,22,15,[Gee(e.a[0],t),Gee(e.a[1],t),Gee(e.a[2],t)]),e.d&&(i[0]=w.Math.max(i[0],i[2]),i[2]=i[0]),i}function LHe(e,t){var i;return i=X(q(ks,1),Vo,22,15,[IU(e.a[0],t),IU(e.a[1],t),IU(e.a[2],t)]),e.d&&(i[0]=w.Math.max(i[0],i[2]),i[2]=i[0]),i}function sDt(e){var t,i,a;for(PR(e.b.a),e.a=le(Hz,nt,57,e.c.c.a.b.c.length,0,1),t=0,a=new j(e.c.c.a.b);a.aa&&e.charCodeAt(t-1)<=32;)--t;return a>0||tf&&zr(t,f,null),t}function Ete(e){So();var t;if(t=AIt(e),!Gn(e))throw Y(new ka("position (0) must be less than the number of elements that remained ("+t+")"));return Mn(e)}function MDt(e){var t;return t=(qje(),Nnt),t[e>>>28]|t[e>>24&15]<<4|t[e>>20&15]<<8|t[e>>16&15]<<12|t[e>>12&15]<<16|t[e>>8&15]<<20|t[e>>4&15]<<24|t[e&15]<<28}function DHe(e){var t,i,a;for(a=e.f,e.k=le(ks,Vo,22,a,15,1),e.d=le(ks,Vo,22,a,15,1),t=0;t0&&(l.b+=t),l}function r7(e,t){var i,a,l;for(l=new fo,a=e.tc();a.hc();)i=h(a.ic(),31),A6(i,0,l.b),l.b+=i.e.b+t,l.a=w.Math.max(l.a,i.e.a);return l.a>0&&(l.a+=t),l}function LDt(e,t){var i,a;if(t<0||t>=e._b())return null;for(i=t;i=e.i)throw Y(new JK(t,e.i));return++e.j,i=e.g[t],a=e.i-t-1,a>0&&wc(e.g,t+1,e.g,t,a),zr(e.g,--e.i,null),e.vh(t,i),e.th(),i}function Mte(e,t){var i,a;return e.Db>>16==6?e.Cb.Cg(e,5,oh,t):(a=Fo(h(Vt((i=h(rn(e,16),24),i||e.Rg()),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function Ewe(e,t){var i,a;i=e.fd(t);try{return a=i.ic(),i.jc(),a}catch(l){throw l=hr(l),re(l,101)?Y(new ka("Can't remove element "+t)):Y(l)}}function BDt(e,t){var i,a,l;return l=new pi(new Dl(X(q(oVt,1),nt,1700,0,[e,t])),16),a=new I8e(l),i=new si(null,a),p1e(i,new CY(e)),p1e(i,new AY(t)),i}function Swe(e,t,i,a,l,f){var g,m,v;for(Be(e)===Be(i)&&(e=e.slice(t,t+l),t=0),m=t,v=t+l;m>22),l+=a>>22,l<0)?!1:(e.l=i&Xc,e.m=a&Xc,e.h=l&Zd,!0)}function jDt(e,t,i,a,l,f,g){var m,v;return!(t.je()&&(v=e.a.Ld(i,a),v<0||!l&&v==0)||t.ke()&&(m=e.a.Ld(i,f),m>0||!g&&m==0))}function Ex(){Ex=M,m5=new C8("NORTH",0),g5=new C8("EAST",1),b5=new C8("SOUTH",2),w5=new C8("WEST",3),m5.a=!1,g5.a=!0,b5.a=!1,w5.a=!0}function YA(){YA=M,v5=new A8("NORTH",0),qz=new A8("EAST",1),Xz=new A8("SOUTH",2),_5=new A8("WEST",3),v5.a=!1,qz.a=!0,Xz.a=!1,_5.a=!0}function yl(){yl=M,fD=new N8("UNKNOWN",0),xd=new N8("ABOVE",1),dm=new N8("BELOW",2),uD=new N8("INLINE",3),new Yr("org.eclipse.elk.labelSide",fD)}function Yg(e,t,i){if(i&&(t<0||t>i.a.c.length))throw Y(new un("index must be >= 0 and <= layer node count"));e.c&&Ea(e.c.a,e),e.c=i,i&&w0(i.a,t,e)}function GHe(e){switch(e.g){case 0:return qse;case 1:return Xse;case 2:return Yse;case 3:return Zse;case 4:return wG;case 5:return Kse;default:return null}}function AS(){AS=M,JG=new k8("P1_TREEIFICATION",0),dL=new k8("P2_NODE_ORDERING",1),q5=new k8("P3_NODE_PLACEMENT",2),pL=new k8("P4_EDGE_ROUTING",3)}function To(e,t,i){var a,l;return a=(l=new aK,xS(l,t),Ef(l,i),$n((!e.c&&(e.c=new ze(ev,e,12,10)),e.c),l),l),E_(a,0),gS(a,1),A_(a,!0),C_(a,!0),a}function jHe(e,t){var i,a;return e.Db>>16==17?e.Cb.Cg(e,21,Pu,t):(a=Fo(h(Vt((i=h(rn(e,16),24),i||e.Rg()),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function $Dt(e,t){var i,a,l;if(a=new T8,l=new bbe(a.q.getFullYear()-j0,a.q.getMonth(),a.q.getDate()),i=ozt(e,t,l),i==0||i>16==6?e.Cb.Cg(e,6,js,t):(a=Fo(h(Vt((i=h(rn(e,16),24),i||(Ma(),Cj)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function Pwe(e,t){var i,a;return e.Db>>16==7?e.Cb.Cg(e,1,pD,t):(a=Fo(h(Vt((i=h(rn(e,16),24),i||(Ma(),SAe)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function Lwe(e,t){var i,a;return e.Db>>16==9?e.Cb.Cg(e,9,Br,t):(a=Fo(h(Vt((i=h(rn(e,16),24),i||(Ma(),TAe)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function kwe(e,t){var i,a;return e.Db>>16==3?e.Cb.Cg(e,12,Br,t):(a=Fo(h(Vt((i=h(rn(e,16),24),i||(Ma(),EAe)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function Rwe(e,t){var i,a;return e.Db>>16==3?e.Cb.Cg(e,0,mD,t):(a=Fo(h(Vt((i=h(rn(e,16),24),i||(Et(),A1)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function VHe(e,t){var i,a;return e.Db>>16==7?e.Cb.Cg(e,6,oh,t):(a=Fo(h(Vt((i=h(rn(e,16),24),i||(Et(),k1)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function WHe(e,t){var i,a;return e.Db>>16==5?e.Cb.Cg(e,9,Oj,t):(a=Fo(h(Vt((i=h(rn(e,16),24),i||(Et(),P1)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function PS(e,t){var i,a;if(t){if(t==e)return!0;for(i=0,a=h(t,42).yg();a&&a!=t;a=a.yg()){if(++i>uie)return PS(e,a);if(a==e)return!0}}return!1}function nBt(e){var t,i;t=h(G(e,(Mf(),Cit)),21),t?(i=t.a,i==0?Ee(e,(Fg(),eG),new Jee):Ee(e,(Fg(),eG),new J9(i))):Ee(e,(Fg(),eG),new J9(1))}function iBt(e,t){var i;switch(i=e.g,t.g){case 1:return-(e.k.b+e.n.b);case 2:return e.k.a-i.n.a;case 3:return e.k.b-i.n.b;case 4:return-(e.k.a+e.n.a)}return 0}function Iwe(e,t,i,a){var l,f,g;if(e.a[t.o]==-1)for(e.a[t.o]=i,e.b[t.o]=a,f=Tn(ur(t));Gn(f);)l=h(Mn(f),14),!Ko(l)&&(g=l.d.g,Iwe(e,g,i+1,a))}function rBt(e){switch(t9(),e.q.g){case 5:CXe(e,(Fe(),bn)),CXe(e,ei);break;case 4:mYe(e,(Fe(),bn)),mYe(e,ei);break;default:QKe(e,(Fe(),bn)),QKe(e,ei)}}function sBt(e){switch(t9(),e.q.g){case 5:FXe(e,(Fe(),Zt)),FXe(e,tn);break;case 4:hHe(e,(Fe(),Zt)),hHe(e,tn);break;default:eJe(e,(Fe(),Zt)),eJe(e,tn)}}function du(e){var t;return!(e.Bb&1)&&e.r&&e.r.Eg()&&(t=h(e.r,42),e.r=h(jg(e,t),133),e.r!=t&&e.Db&4&&!(e.Db&1)&&Pi(e,new cs(e,9,8,t,e.r))),e.r}function ZA(e,t,i){var a,l;a=t*i,re(e.g,153)?(l=lx(e),l.f.d?l.f.a||(e.d.a+=a+pd):(e.d.d-=a+pd,e.d.a+=a+pd)):re(e.g,8)&&(e.d.d-=a,e.d.a+=2*a)}function HHe(){M7(),this.c=new Re,this.i=new Re,this.e=new zc,this.f=new zc,this.g=new zc,this.j=new Re,this.a=new Re,this.b=(Xr(),new li),this.k=new li}function oBt(e,t){var i,a,l,f;for(ni(t,"Dull edge routing",1),f=On(e.b,0);f.b!=f.d.c;)for(l=h(Fn(f),76),a=On(l.d,0);a.b!=a.d.c;)i=h(Fn(a),170),id(i.a)}function Cte(e,t,i){var a;return a=X(q(ks,1),Vo,22,15,[tve(e,(yf(),oa),t,i),tve(e,Va,t,i),tve(e,aa,t,i)]),e.f&&(a[0]=w.Math.max(a[0],a[2]),a[2]=a[0]),a}function aBt(){I7();var e,t;try{if(t=h(Wwe((Sg(),Lu),eM),1698),t)return t}catch(i){if(i=hr(i),re(i,104))e=i,Ime((zn(),e));else throw Y(i)}return new Dm}function cBt(){I7();var e,t;try{if(t=h(Wwe((Sg(),Lu),bu),1635),t)return t}catch(i){if(i=hr(i),re(i,104))e=i,Ime((zn(),e));else throw Y(i)}return new AN}function lBt(){NGe();var e,t;try{if(t=h(Wwe((Sg(),Lu),v1),1710),t)return t}catch(i){if(i=hr(i),re(i,104))e=i,Ime((zn(),e));else throw Y(i)}return new tC}function Dwe(e,t){var i,a;return e.Db>>16==11?e.Cb.Cg(e,10,Br,t):(a=Fo(h(Vt((i=h(rn(e,16),24),i||(Ma(),MAe)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function qHe(e,t){var i,a;return e.Db>>16==10?e.Cb.Cg(e,11,Pu,t):(a=Fo(h(Vt((i=h(rn(e,16),24),i||(Et(),L1)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function XHe(e,t){var i,a;return e.Db>>16==10?e.Cb.Cg(e,12,lf,t):(a=Fo(h(Vt((i=h(rn(e,16),24),i||(Et(),nv)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function uBt(e,t){var i,a,l,f,g;if(t)for(l=t.a.length,i=new jm(l),g=(i.b-i.a)*i.c<0?(Mg(),mm):new Cg(i);g.hc();)f=h(g.ic(),21),a=lS(t,f.a),a&&rYe(e,a)}function fBt(){Ope();var e,t;for(N$t((kg(),At)),L$t(At),Tte(At),zAe=(Et(),Uh),t=new j(YAe);t.a>19,y=t.h>>19,v!=y?y-v:(l=e.h,m=t.h,l!=m?l-m:(a=e.m,g=t.m,a!=g?a-g:(i=e.l,f=t.l,i-f)))}function hBt(e,t){var i,a,l;if(a=e.b.d.d,e.a||(a+=e.b.d.a),l=t.b.d.d,t.a||(l+=t.b.d.a),i=no(a,l),i==0){if(!e.a&&t.a)return-1;if(!t.a&&e.a)return 1}return i}function dBt(e,t){var i,a,l;if(a=e.b.g.d,e.a||(a+=e.b.g.a),l=t.b.g.d,t.a||(l+=t.b.g.a),i=no(a,l),i==0){if(!e.a&&t.a)return-1;if(!t.a&&e.a)return 1}return i}function pBt(e,t,i,a){var l,f,g,m;for(l=0;lg&&(m=g/a),l>f&&(v=f/l),ou(e,w.Math.min(m,v)),e}function mBt(e,t,i){var a,l;return l=e.e,e.e=t,e.Db&4&&!(e.Db&1)&&(a=new cs(e,1,4,l,t),i?i.Sh(a):i=a),l!=t&&(t?i=zS(e,x7(e,t),i):i=zS(e,e.a,i)),i}function JHe(){T8.call(this),this.e=-1,this.a=!1,this.p=zs,this.k=-1,this.c=-1,this.b=-1,this.g=!1,this.f=-1,this.j=-1,this.n=-1,this.i=-1,this.d=-1,this.o=zs}function bBt(e,t){var i,a;for(a=new j(t);a.a=0?(i=h6(e,W7),a=i6(e,W7)):(t=c_(e,1),i=h6(t,5e8),a=i6(t,5e8),a=io(Gd(a,1),Zr(e,1))),Yf(Gd(a,32),Zr(i,ao))}function s7(){s7=M,Z3e=(A7(),ose),Y3e=new ln(oye,Z3e),X3e=(dU(),sse),q3e=new ln(aye,X3e),H3e=(KU(),rse),W3e=new ln(cye,H3e),V3e=new ln(lye,(vt(),vt(),!0))}function Ate(e,t){if(t==e.c.g)return e.d.g;if(t==e.d.g)return e.c.g;throw Y(new un("'node' must either be the source node or target node of the edge."))}function yBt(e,t,i){var a,l;for(ni(i,"Interactive node placement",1),e.a=h(G(t,(Ie(),Nw)),266),l=new j(t.b);l.a0&&(g=(f&zi)%e.d.length,l=_ve(e,g,f,t),l)?(m=l.mc(i),m):(a=e.Ii(f,t,i),e.c.nc(a),null)}function Uwe(e,t){var i,a,l,f;switch(Gp(e,t).lk()){case 3:case 2:{for(i=V_(t),l=0,f=i.i;l=0;a--)if(pt(e[a].d,t)||pt(e[a].d,i)){e.length>=a+1&&e.splice(0,a+1);break}return e}function zwe(e,t,i){this.b=new s9,this.i=new Re,this.d=new Fc(this),this.g=e,this.a=t.c.length,this.c=t,this.e=h(Tt(this.c,this.c.c.length-1),8),this.f=i,lzt(this)}function iqe(){this.a=new Xq,this.g=new i9,this.j=new i9,this.b=(Xr(),new li),this.d=new i9,this.i=new i9,this.k=new li,this.c=new li,this.e=new li,this.f=new li}function LBt(e){var t,i,a,l,f;for(a=new Zm(new xp(e.b).a);a.b;)i=P0(a),t=h(i.kc(),8),f=h(h(i.lc(),48).a,8),l=h(h(i.lc(),48).b,9),tr(Vf(t.k),tr(Fa(f.k),l))}function JA(){JA=M,Use=new zR("MEDIAN_LAYER",0),zse=new zR("WIDEST_LAYER",1),Nse=new zR("CENTER_LAYER",2),vSe=new zR("TAIL_LAYER",3),Fse=new zR("HEAD_LAYER",4)}function kBt(e){var t,i,a;for(i=new j(e.p);i.ai);return l}function jwe(e,t,i){switch(t){case 1:!e.n&&(e.n=new ze(Qo,e,1,7)),Pr(e.n),!e.n&&(e.n=new ze(Qo,e,1,7)),Mr(e.n,h(i,13));return;case 2:jI(e,Qn(i));return}xbe(e,t,i)}function $we(e,t,i){switch(t){case 3:y_(e,ce(Xe(i)));return;case 4:x_(e,ce(Xe(i)));return;case 5:Xu(e,ce(Xe(i)));return;case 6:Yu(e,ce(Xe(i)));return}jwe(e,t,i)}function a7(e,t,i){var a,l,f;f=(a=new aK,a),l=Zg(f,t,null),l&&l.Th(),Ef(f,i),$n((!e.c&&(e.c=new ze(ev,e,12,10)),e.c),f),E_(f,0),gS(f,1),A_(f,!0),C_(f,!0)}function Vwe(e){var t;return e.Db&64?HU(e):(t=new ru(HU(e)),t.a+=" (abstract: ",Cp(t,(e.Bb&256)!=0),t.a+=", interface: ",Cp(t,(e.Bb&512)!=0),t.a+=")",t.a)}function Wwe(e,t){var i,a,l;return i=NC(e.e,t),re(i,207)?(l=h(i,207),l.gh()==null,l.dh()):re(i,456)?(a=h(i,1631),l=a.b,l):null}function aqe(e,t){var i;if(this.f=e,this.b=this.f.c,i=e.d,IQ(t,i),t>=(i/2|0))for(this.e=e.e,this.d=i;t++0;)eze(this);this.a=null}function cqe(e,t,i,a,l,f,g){var m,v,y,E,C;if(E=l[f],y=f==g-1,m=y?a:0,C=IHe(m,E),a!=10&&X(q(e,g-f),t[f],i[f],m,C),!y)for(++f,v=0;v0&&po(e,e.length-1)==33)try{return t=PXe(Hf(e,0,e.length-1)),t.e==null}catch(i){if(i=hr(i),!re(i,30))throw Y(i)}return!1}function jBt(e,t,i){var a,l,f,g;for(i=_x(t,e.e,-1-e.c,i),g=E1e(e.a),f=(a=new Zm(new xp(g.a).a),new wC(a));f.a.b;)l=h(P0(f.a).kc(),84),i=zS(l,x7(l,e.a),i);return i}function $Bt(e,t,i){var a,l,f,g;for(i=j9(t,e.e,-1-e.c,i),g=E1e(e.a),f=(a=new Zm(new xp(g.a).a),new wC(a));f.a.b;)l=h(P0(f.a).kc(),84),i=zS(l,x7(l,e.a),i);return i}function lqe(e){var t,i,a;if(e==null)return null;if(i=h(e,15),i.Wb())return"";for(a=new Mp,t=i.tc();t.hc();)ho(a,(cr(),Qn(t.ic()))),a.a+=" ";return E8(a,a.a.length-1)}function uqe(e){var t,i,a;if(e==null)return null;if(i=h(e,15),i.Wb())return"";for(a=new Mp,t=i.tc();t.hc();)ho(a,(cr(),Qn(t.ic()))),a.a+=" ";return E8(a,a.a.length-1)}function VBt(e,t){IS();var i,a;for(a=(Kg(),Gz),i=e;t>1;t>>=1)t&1&&(a=m_(a,i)),i.d==1?i=m_(i,i):i=new QWe(TZe(i.a,i.d,le(Rn,ii,22,i.d<<1,15,1)));return a=m_(a,i),a}function tP(e,t){return e.b.a=w.Math.min(e.b.a,t.c),e.b.b=w.Math.min(e.b.b,t.d),e.a.a=w.Math.max(e.a.a,t.c),e.a.b=w.Math.max(e.a.b,t.d),e.c[e.c.length]=t,!0}function WBt(e){var t,i,a,l;for(l=-1,a=0,i=new j(e);i.a=0&&pt(e.substr(t,3),"GMT")||t>=0&&pt(e.substr(t,3),"UTC"))&&(i[0]=t+3),h_e(e,i,a)}function Ywe(){Ywe=M;var e,t,i,a;for(R3e=le(ks,Vo,22,25,15,1),I3e=le(ks,Vo,22,33,15,1),a=152587890625e-16,t=32;t>=0;t--)I3e[t]=a,a*=.5;for(i=1,e=24;e>=0;e--)R3e[e]=i,i*=.5}function mqe(e,t,i){var a,l;switch(a=(kn(t.b!=0),h(qu(t,t.a.a),9)),i.g){case 0:a.b=0;break;case 2:a.b=e.f;break;case 3:a.a=0;break;default:a.a=e.g}return l=On(t,0),JE(l,a),t}function u7(){u7=M,Eoe=new jC(FQe,0),uTe=new jC("LONGEST_PATH",1),xoe=new jC("COFFMAN_GRAHAM",2),lTe=new jC(Die,3),fTe=new jC("STRETCH_WIDTH",4),GG=new jC("MIN_WIDTH",5)}function uOt(e,t){var i,a,l,f;for(i=0,a=0,f=new j(t.b);f.ai;f--)e[f]|=t[f-i-1]>>>g,e[f-1]=t[f-i-1]<=e.f)break;f.c[f.c.length]=i}return f}function gOt(e,t,i){var a,l,f;return f=0,a=i[t],t>4&15,f=e[a]&15,g[l++]=CAe[i],g[l++]=CAe[f];return fu(g,0,g.length)}function vqe(e,t,i){var a,l,f,g,m;for(a=i._b(),eHe(e,e.i+a),m=e.i-t,m>0&&wc(e.g,t,e.g,t+a,m),g=i.tc(),e.i+=a,l=0;l=oo?(t=$6+(e-oo>>10&1023)&Gr,i=56320+(e-oo&1023)&Gr,String.fromCharCode(t)+(""+String.fromCharCode(i))):String.fromCharCode(e&Gr)}function xOt(e){var t,i,a;for(a=e.e.c.length,e.a=cw(Rn,[be,ii],[37,22],15,[a,a],2),i=new j(e.c);i.a0&&UHe(this,this.c-1,(Fe(),Zt)),this.c1&&(t.c[t.c.length]=f))}function SOt(e){var t,i,a;for(i=new Dn((!e.a&&(e.a=new ze(Br,e,10,11)),e.a));i.e!=i.i._b();)if(t=h(Xn(i),35),a=S6(t),!Gn((So(),new Od(Zh(zd(a.a,new z))))))return t;return null}function _qe(e,t,i){var a,l;for(l=new Dn((!e.a&&(e.a=new ze(Br,e,10,11)),e.a));l.e!=l.i._b();)a=h(Xn(l),35),Bd(a,a.i+t,a.j+i);mo((!e.b&&(e.b=new ze(js,e,12,3)),e.b),new XOe(t,i))}function yqe(e,t,i,a,l){var f,g,m;for(f=ZYe(e,t,i,a,l),m=!1;!f;)v7(e,l,!0),m=!0,f=ZYe(e,t,i,a,l);m&&v7(e,l,!1),g=PU(l),g.c.length!=0&&(e.d&&e.d.If(g),yqe(e,l,i,a,g))}function eve(e,t){var i;i=Ua((Sg(),Lu),e),re(i,456)?Zo(Lu,e,new gNe(this,t)):Zo(Lu,e,this),ove(this,t),t==(RE(),UAe)?(this.wb=h(this,1633),h(t,1635)):this.wb=(kg(),At)}function MOt(e){var t,i,a;if(e==null)return null;for(t=null,i=0;i0;){if(i=a,a=(a-1)/2|0,e.a.Ld(Tt(e.b,a),t)<=0)return Wu(e.b,i,t),!0;Wu(e.b,i,Tt(e.b,a))}return Wu(e.b,a,t),!0}function LOt(e){for(var t,i,a,l;e.o.a.c.length!=0;)i=h(Abe(e.o),48),a=h(i.a,113),t=h(i.b,189),l=jU(t,a),t.e==a?(J8(l.g,t),a.e=l.e+t.a):(J8(l.b,t),a.e=l.e-t.a),De(e.e.a,a)}function tve(e,t,i,a){var l,f;if(l=0,i)l=IU(e.a[i.g][t.g],a);else for(f=0;fuie)return Mqe(i);if(a=i,i==e)throw Y(new ma("There is a cycle in the containment hierarchy of "+e))}return a}function Tqe(){Tqe=M,$nt=X(q(Se,1),be,2,6,["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]),Vnt=X(q(Se,1),be,2,6,["Jan","Feb","Mar","Apr",Dx,"Jun","Jul","Aug","Sep","Oct","Nov","Dec"])}function ROt(e,t,i,a){var l,f;for(f=t,l=f.d==null||e.a.Ld(i.d,f.d)>0?1:0;f.a[l]!=i;)f=f.a[l],l=e.a.Ld(i.d,f.d)>0?1:0;f.a[l]=a,a.b=i.b,a.a[0]=i.a[0],a.a[1]=i.a[1],i.a[0]=null,i.a[1]=null}function _o(){_o=M,Ih=new FR("P1_CYCLE_BREAKING",0),Yx=new FR("P2_LAYERING",1),Ja=new FR("P3_NODE_ORDERING",2),Qa=new FR("P4_NODE_PLACEMENT",3),Ho=new FR("P5_EDGE_ROUTING",4)}function Cqe(e){var t,i;return i=w.Math.sqrt(e.f*(e.i==null&&(e.i=obe(e,new ea)),ce(e.i))/(e.b*(e.g==null&&(e.g=x$e(e,new Il)),ce(e.g)))),t=nr(Vc(w.Math.round(i))),t=f0(t,e.f),t}function Aqe(e){var t,i;i=e.k,t=tr(new $t(i.a,i.b),e.n),this.d=w.Math.min(i.b,t.b),this.a=w.Math.max(i.b,t.b),this.b=w.Math.min(i.a,t.a),this.c=w.Math.max(i.a,t.a)}function IOt(e){var t,i;if(e.a>=e.c.c.length)return eS(),GP;if(i=$(e),e.a>=e.c.c.length)return new j2(i);t=new zc,Cr(t,Hn(i));do Cr(t,Hn($(e)));while(e.a0&&IZe((oi(0,i.c.length),h(i.c[0],26)),e),i.c.length>1&&IZe(h(Tt(i,i.c.length-1),26),e),Bn(t)}function OOt(e,t,i,a){var l,f,g,m,v;return g=zHe(e.a,t,i),m=h(g.a,21).a,f=h(g.b,21).a,a&&(v=h(G(t,(Ie(),Al)),8),l=h(G(i,Al),8),v&&l&&(mze(e.b,v,l),m+=e.b.i,f+=e.b.e)),m>f}function Lqe(e,t){var i,a,l;if(ive(e,t))return!0;for(a=new j(t);a.af&&sAt(y,lje(i[m],P3e))&&(l=m,f=v);return l>=0&&(a[0]=t+f),l}function h7(e,t){var i,a,l;if(l=0,a=t[0],a>=e.length)return-1;for(i=e.charCodeAt(a);i>=48&&i<=57&&(l=l*10+(i-48),++a,!(a>=e.length));)i=e.charCodeAt(a);return a>t[0]?t[0]=a:l=-1,l}function UOt(e,t){var i,a,l;return a=(YA(),v5),l=w.Math.abs(e.b),i=w.Math.abs(t.f-e.b),iSJ(e.d).c?(e.i+=e.g.c,rte(e.d)):SJ(e.d).c>SJ(e.g).c?(e.e+=e.d.c,rte(e.g)):(e.i+=x9e(e.g),e.e+=x9e(e.d),rte(e.g),rte(e.d))}function RS(){RS=M,ZP=new GC(W0,0),NSe=new GC(qS,1),zSe=new GC(XS,2),USe=new GC("LEFT_RIGHT_CONSTRAINT_LOCKING",3),FSe=new GC("LEFT_RIGHT_CONNECTION_LOCKING",4),OSe=new GC(CQe,5)}function jOt(e){var t,i,a,l,f,g;for(a=kZe(yne(e)),t=Kr,f=0,l=0;t>.5&&f<50;)l=EYe(a),i=Sx(a,l,!0),t=w.Math.abs(i.b),++f;return g=Xe(qg(au(e.g),au(e.g).b-1)),Sx(e,(pn(g),g-l),!1)}function $Ot(e){var t,i,a,l,f,g;for(a=kZe(yne(e)),t=Kr,f=0,l=0;t>.5&&f<50;)l=xYe(a),i=Sx(a,l,!0),t=w.Math.abs(i.a),++f;return g=Xe(qg(au(e.g),au(e.g).b-1)),Sx(e,(pn(g),g-l),!1)}function Iqe(e,t,i,a){e.a.d=w.Math.min(t,i),e.a.a=w.Math.max(t,a)-e.a.d,tm&&(v=m/a),l>f&&(y=f/l),g=w.Math.min(v,y),e.a+=g*(t.a-e.a),e.b+=g*(t.b-e.b)}function qOt(e,t){r9();var i,a,l,f;if(t.b<2)return!1;for(f=On(t,0),i=h(Fn(f),9),a=i;f.b!=f.d.c;){if(l=h(Fn(f),9),vYe(e,a,l))return!0;a=l}return!!vYe(e,a,i)}function sve(e,t,i,a){var l,f;return i==0?(!e.o&&(e.o=new nl((Ma(),sp),pm,e,0)),f9(e.o,t,a)):(f=h(Vt((l=h(rn(e,16),24),l||e.Rg()),i),61),f.aj().ej(e,Xa(e),i-jn(e.Rg()),t,a))}function XOt(e,t){var i;t!=e.a?(i=null,e.a&&(i=h(e.a,42).Cg(e,4,oh,null)),t&&(i=h(t,42).Ag(e,4,oh,i)),i=Rbe(e,t,i),i&&i.Th()):e.Db&4&&!(e.Db&1)&&Pi(e,new cs(e,1,1,t,t))}function Oqe(e){var t;return e.Db&64?Ote(e):(t=new su(dxe),!e.a||Si(Si((t.a+=' "',t),e.a),'"'),Si(d0(Si(d0(Si(d0(Si(d0((t.a+=" (",t),e.i),","),e.j)," | "),e.g),","),e.f),")"),t.a)}function YOt(e){var t,i,a,l,f,g,m,v,y;return y=Zwe(e),i=e.e,f=i!=null,f&&sA(y,bz,e.e),m=e.k,g=!!m,g&&sA(y,"type",tI(e.k)),a=x8(e.j),l=!a,l&&(v=new Om,Og(y,Ere,v),t=new $Z(v),mo(e.j,t)),y}function ZOt(e,t){var i;if(t!=null&&!e.c.jj().Li(t))throw i=re(t,51)?h(t,51).mg().zb:Um(rl(t)),Y(new xC(ry+e.c.be()+"'s type '"+e.c.jj().be()+"' does not permit a value of type '"+i+"'"))}function KOt(e,t){var i,a,l,f;if(pn(t),f=e.a._b(),f>22-t,l=e.h<>22-t):t<44?(i=0,a=e.l<>44-t):(i=0,a=0,l=e.l<>>l|i[g+a+1]<>>l,++g}return f}function Fqe(e){vwe();var t,i,a,l;return a=h(G(e,($e(),IG)),318),l=ce(bt(G(e,poe)))||Be(G(e,gM))===Be((ux(),S5)),t=h(G(e,MMe),21).a,i=e.a.c.length,!l&&a!=(mS(),EG)&&(t==0||t>i)}function tNt(e,t,i){var a,l;for(l=new Ns(e.b,0);l.b=g)return li.a._b()?h(Tt(a,l-i.a._b()-1),8):null;return null}function ove(e,t){var i;t!=e.sb?(i=null,e.sb&&(i=h(e.sb,42).Cg(e,1,kL,null)),t&&(i=h(t,42).Ag(e,1,kL,i)),i=Dbe(e,t,i),i&&i.Th()):e.Db&4&&!(e.Db&1)&&Pi(e,new cs(e,1,4,t,t))}function rNt(e,t,i){var a,l,f,g,m;if(i)for(l=i.a.length,a=new jm(l),m=(a.b-a.a)*a.c<0?(Mg(),mm):new Cg(a);m.hc();)g=h(m.ic(),21),f=lS(i,g.a),vxe in f.a||Ere in f.a?CUt(e,f,t):R$t(e,f,t)}function zqe(e){switch(e.g){case 0:return new hK((L0(),HG));case 1:return new cC;default:throw Y(new un("No implementation is available for the crossing minimizer "+(e.f!=null?e.f:""+e.g)))}}function sNt(e){Zve();var t,i,a,l,f;if(e==null)return null;for(a=e.length,l=a*2,t=le(Yl,Ah,22,l,15,1),i=0;i>4],t[i*2+1]=$j[f&15];return fu(t,0,t.length)}function yo(){Hd(),fme.call(this),this.i=(Fe(),Oa),this.a=new fo,new ope,this.e=(xf(2,Ix),new zl(2)),this.d=(xf(4,Ix),new zl(4)),this.f=(xf(4,Ix),new zl(4)),this.c=new _Oe(this.d,this.f)}function oNt(e,t){var i,a;return!(ce(bt(G(t,(Ie(),om))))||e==(hu(),I5)&&(a=t.c.g,a.j==(qt(),ll)||(i=h(G(a,($e(),ec)),178),i==Fw)))}function aNt(e,t){var i,a;return!(ce(bt(G(t,(Ie(),om))))||e==(hu(),QP)&&(a=t.d.g,a.j==(qt(),ll)||(i=h(G(a,($e(),ec)),178),i==tb)))}function cNt(e,t){var i,a,l;i=DCt(t,e.e),a=h(Ii(e.g.f,i),21).a,l=e.a.c.length-1,e.a.c.length!=0&&h(Tt(e.a,l),269).c==a?(++h(Tt(e.a,l),269).a,++h(Tt(e.a,l),269).b):De(e.a,new NFe(a))}function Gqe(e,t,i,a,l){if(aa&&(e.a=a),e.bl&&(e.b=l),e}function lNt(e){if(re(e,180))return i9t(h(e,180));if(re(e,199))return z6t(h(e,199));if(re(e,27))return YOt(h(e,27));throw Y(new un(Txe+$p(new Dl(X(q(sn,1),nt,1,5,[e])))))}function Wc(e,t){switch(t.g){case 1:return Ud(e.i,(Hd(),kEe));case 2:return Ud(e.i,(Hd(),LEe));case 3:return Ud(e.i,(Hd(),REe));case 4:return Ud(e.i,(Hd(),IEe));default:return yt(),yt(),uo}}function jqe(e){var t;this.a=e,t=(qt(),X(q(xse,1),Oe,232,0,[fs,Nr,Jr,sa,ll,ja,nh])).length,this.b=cw(hCe,[be,UQe],[616,166],0,[t,t],2),this.c=cw(hCe,[be,UQe],[616,166],0,[t,t],2),mzt(this)}function uNt(e){var t,i;return i=h(G(e,(Ie(),$a)),19),t=new rs,(i.pc((xo(),dy))||ce(bt(G(e,($e(),D5)))))&&(sc(t,Jot),i.pc(py)&&sc(t,Qot)),i.pc(fM)&&sc(t,Zot),i.pc(hM)&&sc(t,Kot),t}function $qe(e,t,i){var a,l,f,g;if(t.b!=0){for(a=new Ir,g=On(t,0);g.b!=g.d.c;)f=h(Fn(g),76),wo(a,dbe(f)),l=f.e,l.a=h(G(f,(fa(),Goe)),21).a,l.b=h(G(f,BTe),21).a;$qe(e,a,mc(i,a.b/e.a|0))}}function m6(e){var t,i,a;for(a=new Uc,Gi(a,new $t(e.j,e.k)),i=new Dn((!e.a&&(e.a=new vs(sh,e,5)),e.a));i.e!=i.i._b();)t=h(Xn(i),531),Gi(a,new $t(t.a,t.b));return Gi(a,new $t(e.b,e.c)),a}function fNt(e,t,i,a,l){var f,g,m,v,y,E;if(l)for(v=l.a.length,f=new jm(v),E=(f.b-f.a)*f.c<0?(Mg(),mm):new Cg(f);E.hc();)y=h(E.ic(),21),m=lS(l,y.a),g=new CUe(e,t,i,a),f7t(g.a,g.b,g.c,g.d,m)}function F_(e){aw();var t,i,a;for(a=new zc,qI(a,e),i=a.a.Xb().tc();i.hc();)t=i.ic(),Hn(t);switch(a.a._b()){case 0:return eS(),GP;case 1:return new j2(a.a.Xb().tc().ic());default:return new TK(a)}}function ave(e,t){var i,a,l;for(l=zi,a=new j(P_(t));a.a1&&(e.e.b+=e.a)):(e.e.a+=i.a,e.e.b=w.Math.max(e.e.b,i.b),e.d.c.length>1&&(e.e.a+=e.a))}function Vqe(e,t,i){var a,l,f,g;if(f=h(rn(e.a,8),1629),f!=null)for(a=0,l=f.length;a1)throw Y(new un("In straight spline segments there may be only one edge."));a=e.a.c,i=e.a.c+e.a.b,Gi(h(t.a.Xb().tc().ic(),14).a,new $t(a+(i-a)/2,e.b))}function Wqe(e,t,i,a){var l;this.b=a,this.e=e==(L0(),lL),l=t[i],this.d=cw(ku,[be,f1],[221,22],16,[l.length,l.length],2),this.a=cw(Rn,[be,ii],[37,22],15,[l.length,l.length],2),this.c=new Jwe(t,i)}function Fte(e){var t,i,a;if(e.a==null)for(e.a=le(ku,f1,22,e.c.b.c.length,16,1),e.a[0]=!1,a=new j(e.c.b),a.a>>t,l=e.m>>t|i<<22-t,a=e.l>>t|e.m<<22-t):t<44?(f=0,l=i>>>t-22,a=e.m>>t-22|e.h<<44-t):(f=0,l=0,a=i>>>t-44),qa(a&Xc,l&Xc,f&Zd)}function qqe(e,t,i){var a,l,f,g,m;for(m=al(e.e.mg(),t),l=h(e.g,124),a=0,g=0;gi?uve(e,i,"start index"):t<0||t>i?uve(t,i,"end index"):E6("end index (%s) must not be less than start index (%s)",X(q(sn,1),nt,1,5,[He(t),He(e)]))}function Xqe(e,t){var i,a,l;if(t===e)return!0;if(!re(t,109)||(l=h(t,109),e._b()!=l._b()))return!1;for(a=l.Tb().tc();a.hc();)if(i=h(a.ic(),38),!e.Wc(i))return!1;return!0}function Yqe(e,t){var i,a,l,f;for(a=0,l=e.length;a0?m[g-1]:le(xu,Tf,8,0,0,1),l=m[g],y=g0&&eXe(e,f,i));t.o=0}function TNt(e,t){var i,a,l;for(l=new j(t.f);l.at)throw Y(new un("Top must be smaller or equal to bottom."));if(0>e)throw Y(new un("Left must be smaller or equal to right."));this.d=0,this.c=e,this.a=t,this.b=0}function nXe(e,t){var i,a,l;if(t.c.length!=0){for(i=Lqe(e,t),l=!1;!i;)v7(e,t,!0),l=!0,i=Lqe(e,t);l&&v7(e,t,!1),a=PU(t),e.b&&e.b.If(a),e.a=jVe(e,(oi(0,t.c.length),h(t.c[0],35))),nXe(e,a)}}function Rt(e){var t;this.c=new Ir,this.f=e.e,this.e=e.d,this.i=e.g,this.d=e.c,this.b=e.b,this.k=e.j,this.a=e.a,e.i?this.j=e.i:this.j=(t=h(ml(Jp),10),new Bc(t,h(Qc(t,t.length),10),0)),this.g=e.f}function o1(){o1=M,dCe=new K2(Ux,0),va=new K2("BOOLEAN",1),yc=new K2("INT",2),Z5=new K2("STRING",3),tc=new K2("DOUBLE",4),gs=new K2("ENUM",5),vM=new K2("ENUMSET",6),bd=new K2("OBJECT",7)}function Hc(){Hc=M,JAe=X(q(Se,1),be,2,6,[Gxe,c5,Az,Ytt,Pz,Ire,bz]),KAe=X(q(Se,1),be,2,6,[Gxe,"empty",c5,a5,"elementOnly"]),QAe=X(q(Se,1),be,2,6,[Gxe,"preserve","replace",Pf]),Ks=new l9e}function Qi(e,t){var i;return i=h(e.c.Vb(t),13),!i&&(i=e.Pc(t)),re(i,196)?new xge(e,t,h(i,196)):re(i,60)?new xJ(e,t,h(i,60)):re(i,19)?new Qge(e,t,h(i,19)):re(i,15)?Q1e(e,t,h(i,15),null):new TI(e,t,i,null)}function G(e,t){var i,a;return a=(!e.p&&(e.p=(Xr(),new li)),Ii(e.p,t)),a??(i=t.Of(),re(i,4)&&(i==null?(!e.p&&(e.p=(Xr(),new li)),fS(e.p,t)):(!e.p&&(e.p=(Xr(),new li)),fr(e.p,t,i))),i)}function CNt(e,t){var i,a,l,f;if(e.e.c.length==0)return null;for(f=new $E,a=new j(e.e);a.a=(l/2|0))for(this.e=a?a.c:null,this.d=l;i++0;)W1e(this);this.b=t,this.a=null}function kNt(e){var t,i,a,l,f;return l=h(e.a,21).a,f=h(e.b,21).a,t=(l<0?-l:l)>(f<0?-f:f)?l<0?-l:l:f<0?-f:f,l<=0&&l==f?(i=0,a=f-1):l==-t&&f!=t?(i=f,a=l,f>=0&&++i):(i=-f,a=l),new Is(He(i),He(a))}function RNt(e,t){var i;return e.c.length==0?!1:(i=DWe((oi(0,e.c.length),h(e.c[0],14)).c.g),wl(),i==(ww(),_y)||i==vy?!0:nU(qf(new si(null,new pi(e,16)),new iN),new aZ(t)))}function fve(e,t,i){var a,l,f;if(!e.b[t.g]){for(e.b[t.g]=!0,a=i,!i&&(a=new aU),Gi(a.b,t),f=e.a[t.g].tc();f.hc();)l=h(f.ic(),170),l.b!=t&&fve(e,l.b,a),l.c!=t&&fve(e,l.c,a),Gi(a.a,l);return a}return null}function INt(e){switch(e.g){case 0:case 1:case 2:return Fe(),bn;case 3:case 4:case 5:return Fe(),ei;case 6:case 7:case 8:return Fe(),tn;case 9:case 10:case 11:return Fe(),Zt;default:return Fe(),Oa}}function DNt(e){var t,i,a,l;for(t=0,a=e.length,l=a-4,i=0;i0)try{l=El(t,zs,zi)}catch(f){throw f=hr(f),re(f,118)?(a=f,Y(new hU(a))):Y(f)}return i=(!e.a&&(e.a=new MR(e)),e.a),l=0?h(ae(i,l),51):null}function jNt(e,t,i,a){var l;return l=N_(e,i,X(q(Se,1),be,2,6,[tie,nie,iie,rie,sie,oie,aie]),t),l<0&&(l=N_(e,i,X(q(Se,1),be,2,6,["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]),t)),l<0?!1:(a.d=l,!0)}function $Nt(e,t,i,a){var l;return l=N_(e,i,X(q(Se,1),be,2,6,[tie,nie,iie,rie,sie,oie,aie]),t),l<0&&(l=N_(e,i,X(q(Se,1),be,2,6,["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]),t)),l<0?!1:(a.d=l,!0)}function VNt(e){var t,i,a;for(M8t(e),a=new Re,i=new j(e.a.a.b);i.a>1),pve(t,e,v,y,-l,f),pve(t,e,y,m,-l,f),f.Ld(e[y-1],e[y])<=0){for(;i=0?(t||(t=new MC,a>0&&ho(t,e.substr(0,a))),t.a+="\\",KE(t,i&Gr)):t&&KE(t,i&Gr);return t?t.a:e}function qNt(e,t,i){var a,l,f,g;f=e.c,g=e.d,l=(No(X(q(Qr,1),be,9,0,[f.g.k,f.k,f.a])).b+No(X(q(Qr,1),be,9,0,[g.g.k,g.k,g.a])).b)/2,f.i==(Fe(),Zt)?a=new $t(t+f.g.c.c.a+i,l):a=new $t(t-i,l),e9(e.a,0,a)}function lXe(e,t){var i,a;return Z1e(e.a),lw(e.a,(vU(),sj),sj),lw(e.a,wM,wM),a=new rs,Ci(a,wM,(VU(),Hoe)),Be(nn(t,(mw(),Yoe)))!==Be((KI(),oj))&&Ci(a,wM,Voe),Ci(a,wM,Woe),UNe(e.a,a),i=T_e(e.a,t),i}function uXe(e){if(!e)return bh(),Bnt;var t=e.valueOf?e.valueOf():e;if(t!==e){var i=Kre[typeof t];return i?i(t):Ibe(typeof t)}else return e instanceof Array||e instanceof w.Array?new wF(e):new lC(e)}function v6(e,t){var i;if(t<0)throw Y(new u8("Negative exponent"));if(t==0)return Gz;if(t==1||Obe(e,Gz)||Obe(e,aM))return e;if(!VXe(e,0)){for(i=1;!VXe(e,i);)++i;return m_(O6t(i*t),v6(o0e(e,i),t))}return VBt(e,t)}function XNt(e,t){var i,a,l;return re(t.g,8)&&h(t.g,8).j==(qt(),Jr)?Kr:(l=lx(t),l?w.Math.max(0,e.b/2-.5):(i=p_(t),i?(a=ce(Xe(TS(i,($e(),tp)))),w.Math.max(0,a/2-.5)):Kr))}function YNt(e,t){var i,a,l;return re(t.g,8)&&h(t.g,8).j==(qt(),Jr)?Kr:(l=lx(t),l?w.Math.max(0,e.b/2-.5):(i=p_(t),i?(a=ce(Xe(TS(i,($e(),tp)))),w.Math.max(0,a/2-.5)):Kr))}function ZNt(e,t){var i,a,l,f,g;if(!t.Wb()){if(l=h(t.cd(0),125),t._b()==1){PYe(e,l,l,1,0,t);return}for(i=1;if.a&&!t&&(l.b=f.a),l.c=-(l.b-f.a)/2,i.g){case 1:l.d=-l.a;break;case 3:l.d=f.b}gne(a),mne(a)}function pXe(e,t,i){var a,l,f;switch(f=e.o,a=h(Ds(e.p,i),219),l=a.i,l.b=y6(a),l.a=_6(a),l.a=w.Math.max(l.a,f.b),l.a>f.b&&!t&&(l.a=f.b),l.d=-(l.a-f.b)/2,i.g){case 4:l.c=-l.b;break;case 2:l.c=f.a}gne(a),mne(a)}function sP(e,t){mZe(e,t),e.b&1&&(e.a.a=null),e.b&2&&(e.a.f=null),e.b&4&&(e.a.g=null,e.a.i=null),e.b&16&&(e.a.d=null,e.a.e=null),e.b&8&&(e.a.b=null),e.b&32&&(e.a.j=null,e.a.c=null)}function gXe(e){var t,i,a,l;if(i=h(e,42).Kg(),i)try{if(a=null,t=BS((Sg(),Lu),NZe(V6t(i))),t&&(l=t.Lg(),l&&(a=l.gk(Qn(ce(i.e))))),a&&a!=e)return gXe(a)}catch(f){if(f=hr(f),!re(f,54))throw Y(f)}return e}function mXe(e,t){var i;t.d?t.d.b=t.b:e.a=t.b,t.b?t.b.d=t.d:e.e=t.d,!t.e&&!t.c?(i=h(fS(e.b,t.a),264),i.a=0,++e.c):(i=h(Ii(e.b,t.a),264),--i.a,t.e?t.e.c=t.c:i.b=t.c,t.c?t.c.e=t.e:i.c=t.e),--e.d}function mve(e){var t,i;return e>-0x800000000000&&e<0x800000000000?e==0?0:(t=e<0,t&&(e=-e),i=wr(w.Math.floor(w.Math.log(e)/.6931471805599453)),(!t||e!=w.Math.pow(2,i))&&++i,i):m$e(Vc(e))}function bXe(e,t){var i,a,l,f,g,m;for(i=e.b.c.length,l=Tt(e.b,t);t*2+10)for(g=e.c.d,m=e.d.d,l=ou(Dc(new $t(m.a,m.b),g),1/(a+1)),f=new $t(g.a,g.b),i=new j(e.a);i.a0&&(g+=i,++t);t>1&&(g+=e.c*(t-1))}else g=oBe(S$e(wI(go(f1e(e.a),new Ok),new Fv)));return g>0?g+e.n.d+e.n.a:0}function y6(e){var t,i,a,l,f,g;if(g=0,e.b==0)g=oBe(S$e(wI(go(f1e(e.a),new Vq),new Im)));else{for(f=LHe(e,!0),t=0,a=0,l=f.length;a0&&(g+=i,++t);t>1&&(g+=e.c*(t-1))}return g>0?g+e.n.b+e.n.c:0}function QNt(e){var t,i;return i=-e.a,t=X(q(Yl,1),Ah,22,15,[43,48,48,48,48]),i<0&&(t[0]=45,i=-i),t[1]=t[1]+((i/60|0)/10|0)&Gr,t[2]=t[2]+(i/60|0)%10&Gr,t[3]=t[3]+(i%60/10|0)&Gr,t[4]=t[4]+i%10&Gr,fu(t,0,t.length)}function eFt(e){var t,i,a,l,f,g;for(g=ES(e.d,e.e),f=g.tc();f.hc();)for(l=h(f.ic(),11),a=e.e==(Fe(),tn)?l.d:l.f,i=new j(a);i.a=0;f+=i?1:-1)g=g|t.c.qf(v,f,i,a),g=g|t.q.xf(v,f,i),g=g|BZe(e,v[f],i,a);return Cr(e.c,t),g}function _Xe(e,t){var i,a,l,f,g,m;for(f=new j(e.b);f.a=0&&a0;){if(t=h(e.k.cd(e.n-1),75),i=t.nj(),re(i,62)&&h(h(i,17),62).Bb&Ka&&(!e.e||i.Vi()!=SM||i.pi()!=0)&&t.lc()!=null)return!0;--e.n}return!1}else return e.n>0}function bve(e,t){var i,a,l,f;if(wi(e),e.c!=0||e.a!=123)throw Y(new Wn(Yn((zn(),ntt))));if(f=t==112,a=e.d,i=VE(e.i,125,a),i<0)throw Y(new Wn(Yn((zn(),itt))));return l=Hf(e.i,a,i),e.d=i+1,FGe(l,f,(e.e&512)==512)}function iFt(e){var t,i;return i=-e.a,t=X(q(Yl,1),Ah,22,15,[43,48,48,58,48,48]),i<0&&(t[0]=45,i=-i),t[1]=t[1]+((i/60|0)/10|0)&Gr,t[2]=t[2]+(i/60|0)%10&Gr,t[4]=t[4]+(i%60/10|0)&Gr,t[5]=t[5]+i%10&Gr,fu(t,0,t.length)}function rFt(e){var t;return t=X(q(Yl,1),Ah,22,15,[71,77,84,45,48,48,58,48,48]),e<=0&&(t[3]=43,e=-e),t[4]=t[4]+((e/60|0)/10|0)&Gr,t[5]=t[5]+(e/60|0)%10&Gr,t[7]=t[7]+(e%60/10|0)&Gr,t[8]=t[8]+e%10&Gr,fu(t,0,t.length)}function EXe(e,t){var i,a,l;return a=new Qf(e),Oo(a,t),Ee(a,(Ie(),AG),t),Ee(a,($e(),Yi),(Ms(),Ba)),Ee(a,Dh,(ld(),uj)),Bu(a,(qt(),Jr)),i=new yo,ls(i,a),pr(i,(Fe(),tn)),l=new yo,ls(l,a),pr(l,Zt),a}function SXe(e,t){var i,a,l,f,g;for(e.c[t.o]=!0,De(e.a,t),g=new j(t.i);g.a0&&(l=i),g=new j(e.f.e);g.a=f)g.Pb();else for(l=g.tc(),a=0;a0?bpe():g<0&&vve(e,t,-g),!0):!1}function lFt(e){var t,i,a,l,f,g,m,v,y,E;for(i=e.o,t=e.p,g=zi,l=zs,m=zi,f=zs,y=0;yy?l:y,m=mE?f:E);return v=l-g+1,a=f-m+1,new EUe(He(g),He(m),He(v),He(a))}function uFt(e,t){var i,a,l;return i=h(G(t,(Mf(),cM)),21).a-h(G(e,cM),21).a,i==0?(a=Dc(Fa(h(G(e,(Fg(),y5)),9)),h(G(e,HP),9)),l=Dc(Fa(h(G(t,y5),9)),h(G(t,HP),9)),no(a.a*a.b,l.a*l.b)):i}function fFt(e,t){var i,a,l;return i=h(G(t,(yw(),rj)),21).a-h(G(e,rj),21).a,i==0?(a=Dc(Fa(h(G(e,(fa(),X5)),9)),h(G(e,gL),9)),l=Dc(Fa(h(G(t,X5),9)),h(G(t,gL),9)),no(a.a*a.b,l.a*l.b)):i}function hFt(e,t,i){var a,l,f,g,m,v;if(!e||e.c.length==0)return null;for(f=new e7e(t,!i),l=new j(e);l.a0)switch(t.g){case 2:f.n.c=e.s;break;case 4:f.n.b=e.s}}function Vte(e,t){var i,a,l;if(l=US((Hc(),Ks),e.mg(),t),l)return Xo(),h(l,61).bj()||(l=pA($o(Ks,l))),a=(i=e.rg(l),h(i>=0?e.ug(i,!0,!0):Cx(e,l,!0),184)),h(a,237).wk(t);throw Y(new un(ry+t.be()+mxe))}function gFt(e,t,i){var a,l,f,g;return f=CKe(cee(),t),a=null,f&&(g=yKe(f,i),l=null,g!=null&&(l=(g==null?(!e.o&&(e.o=new nl((Ma(),sp),pm,e,0)),a6(e.o,f)):(!e.o&&(e.o=new nl((Ma(),sp),pm,e,0)),p6(e.o,f,g)),e)),a=l),a}function _ve(e,t,i,a){var l,f,g,m,v;if(l=e.d[t],l){if(f=l.g,v=l.i,a!=null){for(m=0;m1||i==-1?(e.b=-1,!0):(t=du(e),t&&(Xo(),t.Ri()==Dtt)?(e.b=-1,!0):(e.b=1,!1));default:case 1:return!1}}function mFt(e,t){var i,a,l,f,g;for(a=(!t.s&&(t.s=new ze(Ec,t,21,17)),t.s),f=null,l=0,g=a.i;ll)?(kn(f.a!=null),h(f.a,8)):null}function _Ft(e,t){$u();var i,a,l,f,g,m;for(i=null,g=t.tc();g.hc();)f=h(g.ic(),125),!f.k&&(a=OSt(f.a),l=BCt(f.a),m=new dP(a,l,null,h(f.d.a.Xb().tc().ic(),14)),De(m.c,f.a),e.c[e.c.length]=m,i&&De(i.d,m),i=m)}function yFt(e,t,i){var a,l,f,g,m,v;for(a=h(Qi(e.c,t),15),l=h(Qi(e.c,i),15),f=a.fd(a._b()),g=l.fd(l._b());f.Cc()&&g.Cc();)if(m=h(f.Ec(),21),v=h(g.Ec(),21),m!=v)return Lp(m.a,v.a);return!f.hc()&&!g.hc()?0:f.hc()?1:-1}function oP(e,t,i,a,l){var f,g,m,v;return v=yJ(e,h(l,51)),Be(v)!==Be(l)?(m=h(e.g[i],75),f=Dg(t,v),JC(e,i,Ite(e,i,f)),ju(e.e)&&(g=Wm(e,9,f.nj(),l,v,a,!1),Hwe(g,new Vd(e.e,9,e.c,m,f,a,!1)),XQ(g)),v):l}function xFt(e,t,i){var a,l,f,g;for(l=i,f=c8e(wI(h(h(Qi(e.r,t),19),60).xc(),new Vb)),g=0;f.a||(f.a=a_(f.c,f)),f.a;)if(l){eU(f),l=!1;continue}else a=eU(f),f.a||(f.a=a_(f.c,f)),f.a&&(g=w.Math.max(g,a));return g}function ir(e,t,i){var a;if(a=h(e.c.Vb(t),13),a)return a.nc(i)?(++e.d,!0):!1;if(a=e.Pc(t),a.nc(i))return++e.d,e.c.Zb(t,a),!0;throw Y(new AQ("New Collection violated the Collection spec"))}function EFt(e){var t,i,a,l,f,g;for(l=0,e.q=new Re,t=new Ur,g=new j(e.p);g.a>16),t=a>>16&16,i=16-t,e=e>>t,a=e-256,t=a>>16&8,i+=t,e<<=t,a=e-V0,t=a>>16&4,i+=t,e<<=t,a=e-Ch,t=a>>16&2,i+=t,e<<=t,a=e>>14,t=a&~(a>>1),i+2-t)}function MFt(e,t,i,a){var l,f,g,m,v,y;for(l=0;l=0&&y>=0&&v=0?e.ug(a,!0,!0):Cx(e,f,!0),184)),h(l,237).sk(t,i);throw Y(new un(ry+t.be()+mxe))}function LXe(e){var t,i;if(Dd(h(G(e,($e(),Yi)),83)))for(i=new j(e.i);i.a>24;return g}function LFt(e,t){var i,a,l,f,g;if(i=h(rn(e.a,4),116),g=i==null?0:i.length,t>=g)throw Y(new o_(t,g));return l=i[t],g==1?a=null:(a=le(kae,kre,380,g-1,0,1),wc(i,0,a,0,t),f=g-t-1,f>0&&wc(i,t+1,a,t,f)),l6(e,a),Vqe(e,t,l),l}function kFt(e,t){var i,a,l;if(Be(e)===Be(t))return!0;if(e==null||t==null||e.length!=t.length)return!1;for(i=0;i=null.tl()?(_7(e),Sve(e)):t.hc()}function Wte(e){var t,i;if(M0(e))throw Y(new un(jQe));for(i=On(e,0);i.b!=i.d.c;)t=h(Fn(i),9),this.d=w.Math.min(this.d,t.b),this.c=w.Math.max(this.c,t.a),this.a=w.Math.max(this.a,t.b),this.b=w.Math.min(this.b,t.a)}function DFt(e){var t,i;return t=new rs,sc(t,bat),i=h(G(e,(Ie(),$a)),19),i.pc((xo(),C5))&&sc(t,xat),i.pc(fM)&&sc(t,wat),(i.pc(dy)||ce(bt(G(e,($e(),D5)))))&&(sc(t,_at),i.pc(py)&&sc(t,yat)),i.pc(hM)&&sc(t,vat),t}function Hte(e){var t,i;if(t=Qn(nn(e,(lr(),yCe))),i=L5t(cee(),t),!i)throw t==null||t.length==0?Y(new kR("No layout algorithm has been specified ("+e+").")):Y(new kR("Layout algorithm not found: "+t));return i}function Ax(){Ax=M,_3=h(ae(ye((ype(),ga).qb),6),29),v3=h(ae(ye(ga.qb),3),29),Nae=h(ae(ye(ga.qb),4),29),Fae=h(ae(ye(ga.qb),5),17),c7(_3),c7(v3),c7(Nae),c7(Fae),aut=new Dl(X(q(Ec,1),oy,158,0,[_3,v3]))}function OXe(e){var t=(!Yre&&(Yre=a$t()),Yre),i=e.replace(/[\x00-\x1f\xad\u0600-\u0603\u06dd\u070f\u17b4\u17b5\u200b-\u200f\u2028-\u202e\u2060-\u2064\u206a-\u206f\ufeff\ufff9-\ufffb"\\]/g,function(a){return HPt(a,t)});return'"'+i+'"'}function BFt(e){var t,i,a,l,f,g;for(l=e.e.c.length,a=le(_u,Aw,15,l,0,1),g=new j(e.e);g.a=0;)a=i[f],g.Bk(a.nj())&&$n(l,a);!u$t(e,l)&&ju(e.e)&&In(e,t.lj()?Wm(e,6,t,(yt(),uo),null,-1,!1):Wm(e,t.Zi()?2:1,t,null,null,-1,!1))}function zFt(e,t){var i,a,l,f,g;return e.a==(RS(),ZP)?!0:(f=t.a.c,i=t.a.c+t.a.b,!(t.i&&(a=t.u,g=a.c.c.a-a.n.a/2,l=f-(a.k.a+a.n.a),l>g)||t.n&&(a=t.v,g=a.c.c.a-a.n.a/2,l=a.k.a-i,l>g)))}function zXe(e,t,i){var a,l,f,g,m,v;for(a=0,v=i,t||(a=i*(e.c.length-1),v*=-1),f=new j(e);f.a1?e.e*=ce(e.a):e.f/=ce(e.a),zIt(e),w5t(e),TUt(e),Ee(e.b,(qA(),Yz),e.g)}function jFt(e){cx();var t,i,a,l;for(Zz=new Re,fse=(Xr(),new li),use=new Re,t=(!e.a&&(e.a=new ze(Br,e,10,11)),e.a),Xjt(t),l=new Dn(t);l.e!=l.i._b();)a=h(Xn(l),35),Jo(Zz,a,0)==-1&&(i=new Re,De(use,i),nHe(a,i));return use}function $Ft(e,t){var i,a,l,f,g,m,v;if(a=QVe(e.Db&254),a==1)e.Eb=null;else if(f=__(e.Eb),a==2)l=Ste(e,t),e.Eb=f[l==0?1:0];else{for(g=le(sn,nt,1,a-1,5,1),i=2,m=0,v=0;i<=128;i<<=1)i==t?++m:e.Db&i&&(g[v++]=f[m++]);e.Eb=g}e.Db&=~t}function $Xe(e,t,i){var a,l,f;e.ti()?(f=e.ui(),e6(e,t,i),a=e.mi(3,null,i,t,f),e.qi()?(l=e.ri(i,null),e.xi()&&(l=e.yi(i,l)),l?(l.Sh(a),l.Th()):e.ni(a)):e.ni(a)):(e6(e,t,i),e.qi()&&(l=e.ri(i,null),l&&l.Th()))}function qte(e,t){var i,a,l,f;e.ti()?(i=e.i,f=e.ui(),MI(e,t),a=e.mi(3,null,t,i,f),e.qi()?(l=e.ri(t,null),e.xi()&&(l=e.yi(t,l)),l?(l.Sh(a),l.Th()):e.ni(a)):e.ni(a)):(MI(e,t),e.qi()&&(l=e.ri(t,null),l&&l.Th()))}function Cve(e,t){var i,a,l,f,g;if(t===e)return!0;if(!re(t,15)||(g=h(t,15),e._b()!=g._b()))return!1;for(f=g.tc(),a=e.tc();a.hc();)if(i=a.ic(),l=f.ic(),!(Be(i)===Be(l)||i!=null&&Li(i,l)))return!1;return!0}function VXe(e,t){var i,a,l;if(t==0)return(e.a[0]&1)!=0;if(t<0)throw Y(new u8("Negative bit address"));if(l=t>>5,l>=e.d)return e.e<0;if(i=e.a[l],t=1<<(t&31),e.e<0){if(a=L$e(e),l=0?e.jg(null):e.yg().Cg(e,-1-t,null,null)),e.kg(h(l,42),i),a&&a.Th(),e.eg()&&e.fg()&&i>-1&&Pi(e,new cs(e,9,i,f,l)),l):f}function DS(){DS=M,Pae=new J2(AQe,0),kj=new J2("INSIDE_SELF_LOOPS",1),Rj=new J2("MULTI_EDGES",2),Lj=new J2("EDGE_LABELS",3),Aae=new J2("PORTS",4),Pj=new J2("COMPOUND",5),Aj=new J2("CLUSTERS",6),Cae=new J2("DISCONNECTED",7)}function WXe(e){var t,i;if(e.f){for(;e.n>16)),15).dd(f),m0&&(!(n_(e.a.c)&&t.n.d)&&!(YR(e.a.c)&&t.n.b)&&(t.g.d+=w.Math.max(0,a/2-.5)),!(n_(e.a.c)&&t.n.a)&&!(YR(e.a.c)&&t.n.c)&&(t.g.a-=a-1))}function KXe(e,t,i){var a,l,f,g,m,v;f=h(Tt(t.d,0),14).c,a=f.g,l=a.j,v=h(Tt(i.f,0),14).d,g=v.g,m=g.j,l==(qt(),Nr)?Ee(e,(Ie(),Tl),h(G(a,Tl),11)):Ee(e,(Ie(),Tl),f),m==Nr?Ee(e,(Ie(),Cl),h(G(g,Cl),11)):Ee(e,(Ie(),Cl),v)}function Yte(e){var t,i,a;if(e.length==0)throw Y(new un(jQe));for(i=0,a=e.length;i>t,f=e.m>>t|i<<22-t,l=e.l>>t|e.m<<22-t):t<44?(g=a?Zd:0,f=i>>t-22,l=e.m>>t-22|i<<44-t):(g=a?Zd:0,f=a?Xc:0,l=i>>t-44),qa(l&Xc,f&Xc,g&Zd)}function Zte(e){var t,i,a,l,f,g;for(this.c=new Re,this.d=e,a=Kr,l=Kr,t=Ts,i=Ts,g=On(e,0);g.b!=g.d.c;)f=h(Fn(g),9),a=w.Math.min(a,f.a),l=w.Math.min(l,f.b),t=w.Math.max(t,f.a),i=w.Math.max(i,f.b);this.a=new Xf(a,l,t-a,i-l)}function Rve(e){var t,i,a;this.c=e,a=h(G(e,($e(),tf)),110),t=ce(Xe(G(e,kG))),i=ce(Xe(G(e,tTe))),a==(Xs(),nf)||a==rf||a==Bh?this.b=t*i:this.b=1/(t*i),this.j=ce(Xe(G(e,Vw))),this.e=ce(Xe(G(e,tp))),this.f=e.b.c.length}function JXe(e){switch(e.g){case 0:return new zv;case 1:return new uF;case 2:return new _g;case 3:return new jOe;case 4:return new TUe;default:throw Y(new un("No implementation is available for the node placer "+(e.f!=null?e.f:""+e.g)))}}function Zu(e){var t;return t=new su(Um(e.ql)),t.a+="@",Si(t,(Wr(e)>>>0).toString(16)),e.Eg()?(t.a+=" (eProxyURI: ",Rc(t,e.Kg()),e.tg()&&(t.a+=" eClass: ",Rc(t,e.tg())),t.a+=")"):e.tg()&&(t.a+=" (eClass: ",Rc(t,e.tg()),t.a+=")"),t.a}function QXe(e,t){var i,a,l,f,g,m,v,y,E;if(e.a.f>0&&re(t,38)&&(e.a.Fi(),y=h(t,38),v=y.kc(),f=v==null?0:Wr(v),g=sme(e.a,f),i=e.a.d[g],i)){for(a=h(i.g,339),E=i.i,m=0;m0&&l0):l<0&&-l0):!1}function m7(e,t,i,a,l){var f,g,m,v,y,E;for(f=a,y=h(h(Qi(e.r,t),19),60).tc();y.hc();){if(v=h(y.ic(),111),f){f=!1;continue}g=0,l>0?g=l:v.c&&(g=w9(v.c)),g>0&&(i?(E=v.b.Re().a,g>E&&(m=(g-E)/2,v.d.b=m,v.d.c=m)):v.d.c=e.s+g)}}function Ive(e,t,i){switch(t){case 7:!e.e&&(e.e=new an(js,e,7,4)),Pr(e.e),!e.e&&(e.e=new an(js,e,7,4)),Mr(e.e,h(i,13));return;case 8:!e.d&&(e.d=new an(js,e,8,5)),Pr(e.d),!e.d&&(e.d=new an(js,e,8,5)),Mr(e.d,h(i,13));return}$we(e,t,i)}function KFt(e){var t,i;if(e.c.length!=2)throw Y(new ma("Order only allowed for two paths."));t=(oi(0,e.c.length),h(e.c[0],14)),i=(oi(1,e.c.length),h(e.c[1],14)),t.d.g!=i.c.g&&(e.c=le(sn,nt,1,0,5,1),e.c[e.c.length]=i,e.c[e.c.length]=t)}function JFt(e){var t,i,a,l;if(e==null)return null;if(a=Da(e,!0),l=u5.length,pt(a.substr(a.length-l,l),u5)){if(i=a.length,i==4){if(t=a.charCodeAt(0),t==43)return iPe;if(t==45)return Eut}else if(i==3)return iPe}return _w(a)}function QFt(e,t,i){var a;a=null,t&&(a=t.d),tP(e,new GE(t.k.a-a.b+i.a,t.k.b-a.d+i.b)),tP(e,new GE(t.k.a-a.b+i.a,t.k.b+t.n.b+a.a+i.b)),tP(e,new GE(t.k.a+t.n.a+a.c+i.a,t.k.b-a.d+i.b)),tP(e,new GE(t.k.a+t.n.a+a.c+i.a,t.k.b+t.n.b+a.a+i.b))}function e8t(e,t){var i,a,l,f,g;for(ni(t,"Port side processing",1),g=new j(e.a);g.av-i&&m=e.c.a.length)return t;for(a=Rc(Si(new u0,"expected one element but was: <"),t),i=0;i<4&&e.a=0?e.Mg(f,i):Uve(e,l,i);else throw Y(new un(ry+l.be()+gre));else throw Y(new un("The feature ID"+t+" is not a valid feature ID"));else Vl(e,a,l,i)}function Kte(e,t,i,a,l){var f,g,m,v,y,E,C,R,B;return g=i-e,m=a-t,f=w.Math.atan2(g,m),v=f+Cie,y=f-Cie,E=l*w.Math.sin(v)+e,R=l*w.Math.cos(v)+t,C=l*w.Math.sin(y)+e,B=l*w.Math.cos(y)+t,Ym(X(q(Qr,1),be,9,0,[new $t(E,R),new $t(C,B)]))}function oYe(e){var t,i,a,l,f,g,m;for(f=0,l=e.f.e,i=0;i=0)return l;for(f=1,m=new j(t.i);m.av+1?f:v+1);return q6t(e,t,f),f}function a1(){a1=M,Su=new Qv("H_LEFT",0),Oh=new Qv("H_CENTER",1),Tu=new Qv("H_RIGHT",2),kf=new Qv("V_TOP",3),of=new Qv("V_CENTER",4),sf=new Qv("V_BOTTOM",5),Pl=new Qv("INSIDE",6),Cu=new Qv("OUTSIDE",7),Mu=new Qv("H_PRIORITY",8)}function nn(e,t){var i,a;return a=(!e.o&&(e.o=new nl((Ma(),sp),pm,e,0)),Sf(e.o,t)),a??(i=t.Of(),re(i,4)&&(i==null?(!e.o&&(e.o=new nl((Ma(),sp),pm,e,0)),a6(e.o,t)):(!e.o&&(e.o=new nl((Ma(),sp),pm,e,0)),p6(e.o,t,i))),i)}function c8t(e){var t,i,a,l,f,g,m;if(t=e.Yg(bu),t&&(m=Qn(Sf((!t.b&&(t.b=new bl((Et(),Uo),Ca,t)),t.b),"settingDelegates")),m!=null)){for(i=new Re,l=Px(m,"\\w+"),f=0,g=l.length;f0?(t-=1,i-=1):a>=0&&l<0?(t+=1,i+=1):a>0&&l>=0?(t-=1,i+=1):(t+=1,i-=1),new Is(He(t),He(i))}function Dve(e,t,i){var a,l,f;if(t!=i){a=t;do tr(e,a.c),l=h(G(a,(Ie(),sm)),8),l&&(f=a.d,Nl(e,f.b,f.d),tr(e,l.k),a=wa(l));while(l);a=i;do Dc(e,a.c),l=h(G(a,(Ie(),sm)),8),l&&(f=a.d,iI(e,f.b,f.d),Dc(e,l.k),a=wa(l));while(l)}}function f8t(e,t,i){var a,l,f,g,m,v;a=new Re,a.c[a.c.length]=t,v=t,m=0;do v=Njt(e,v),v&&(a.c[a.c.length]=v),++m;while(v);for(g=(i-(a.c.length-1)*e.d.d)/a.c.length,f=new j(a);f.at.c?1:e.bt.b?1:e.a!=t.a?Wr(e.a)-Wr(t.a):e.d==(wA(),fL)&&t.d==uL?-1:e.d==uL&&t.d==fL?1:0}function Jte(e){var t,i,a,l,f,g,m,v;for(l=Kr,a=Ts,i=new j(e.e.b);i.a=0;t-=2)for(i=0;i<=t;i+=2)(e.b[i]>e.b[i+2]||e.b[i]===e.b[i+2]&&e.b[i+1]>e.b[i+3])&&(a=e.b[i+2],e.b[i+2]=e.b[i],e.b[i]=a,a=e.b[i+3],e.b[i+3]=e.b[i+1],e.b[i+1]=a);e.c=!0}}function fYe(e,t){var i,a,l,f,g,m,v,y;for(g=t==1?_se:vse,f=g.a.Xb().tc();f.hc();)for(l=h(f.ic(),110),v=h(Qi(e.f.c,l),19).tc();v.hc();)switch(m=h(v.ic(),48),a=h(m.b,80),y=h(m.a,172),i=y.c,l.g){case 2:case 1:a.g.d+=i;break;case 4:case 3:a.g.c+=i}}function E8t(e){Zve();var t,i,a,l,f,g,m;if(e==null||(l=e.length,l%2!=0))return null;for(t=fU(e),f=l/2|0,i=le(Sc,sy,22,f,15,1),a=0;a>24}return i}function BS(e,t){var i,a,l;return i=t==null?Ic(pc(e.d,null)):NC(e.e,t),re(i,207)?(l=h(i,207),l.gh()==null,l):re(i,456)?(a=h(i,1631),l=a.a,l&&(l.yb==null||(t==null?xl(e.d,null,l):I0(e.e,t,l))),l):null}function S8t(e,t){var i,a,l,f,g;if(a=t.nj(),z0(e.e,a)){if(a.xh()&&$Q(e,a,t.lc()))return!1}else for(g=al(e.e.mg(),a),i=h(e.g,124),l=0;l0&&(!(n_(e.a.c)&&t.n.d)&&!(YR(e.a.c)&&t.n.b)&&(t.g.d-=w.Math.max(0,a/2-.5)),!(n_(e.a.c)&&t.n.a)&&!(YR(e.a.c)&&t.n.c)&&(t.g.a+=w.Math.max(0,a-1)))}function hYe(e,t,i){var a,l;if((e.c-e.b&e.a.length-1)==2)t==(Fe(),bn)||t==Zt?(bU(h(IA(e),15),(yl(),xd)),bU(h(IA(e),15),dm)):(bU(h(IA(e),15),(yl(),dm)),bU(h(IA(e),15),xd));else for(l=new hA(e);l.a!=l.b;)a=h(DU(l),15),bU(a,i)}function dYe(e){var t,i,a,l,f,g,m;if(e&&(t=e.Yg(bu),t&&(g=Qn(Sf((!t.b&&(t.b=new bl((Et(),Uo),Ca,t)),t.b),"conversionDelegates")),g!=null))){for(m=new Re,a=Px(g,"\\w+"),l=0,f=a.length;l=2147483648&&(a-=fie),a)}function pYe(e,t,i){var a,l,f,g;BUe(e,t)>BUe(e,i)?(a=ra(i,(Fe(),Zt)),e.d=a.Wb()?0:fI(h(a.cd(0),11)),g=ra(t,tn),e.b=g.Wb()?0:fI(h(g.cd(0),11))):(l=ra(i,(Fe(),tn)),e.d=l.Wb()?0:fI(h(l.cd(0),11)),f=ra(t,Zt),e.b=f.Wb()?0:fI(h(f.cd(0),11)))}function T8t(e){var t,i,a,l,f,g;if(l=h(Tt(e.i,0),11),l.d.c.length+l.f.c.length==0)e.k.a=0;else{for(g=0,a=Tn(Np(new kd(l),new Wv(l)));Gn(a);)i=h(Mn(a),11),g+=i.g.k.a+i.k.a+i.a.a;t=h(G(e,($e(),Gw)),9),f=t?t.a:0,e.k.a=g/(l.d.c.length+l.f.c.length)-f}}function gYe(e){switch(e.g){case 0:return new iFe;case 1:return new aF;case 2:return new GOe;case 3:return new M2;case 4:return new d8e;case 5:return new lF;default:throw Y(new un("No implementation is available for the layerer "+(e.f!=null?e.f:""+e.g)))}}function mYe(e,t){var i,a,l,f;for(i=e.o.a,f=h(h(Qi(e.r,t),19),60).tc();f.hc();)l=h(f.ic(),111),l.e.a=i*ce(Xe(l.b.xe(Tj))),l.e.b=(a=l.b,a.ye((lr(),Yc))?a.ef()==(Fe(),bn)?-a.Re().b-ce(Xe(a.xe(Yc))):ce(Xe(a.xe(Yc))):a.ef()==(Fe(),bn)?-a.Re().b:0)}function Qte(e,t){IS();var i,a,l,f,g,m,v,y,E;return t.d>e.d&&(m=e,e=t,t=m),t.d<63?x9t(e,t):(g=(e.d&-2)<<4,y=o0e(e,g),E=o0e(t,g),a=pne(e,fx(y,g)),l=pne(t,fx(E,g)),v=Qte(y,E),i=Qte(a,l),f=Qte(pne(y,a),pne(l,E)),f=xne(xne(f,v),i),f=fx(f,g),v=fx(v,g<<1),xne(xne(v,f),i))}function bYe(e,t,i){var a,l,f;for(PMt.call(this,new Re),this.a=t,this.b=i,this.e=e,a=(e.b&&vne(e),e.a),this.d=PUe(a.a,this.a),this.c=PUe(a.b,this.b),A6t(this,this.d,this.c),oFt(this),f=this.e.e.a.Xb().tc();f.hc();)l=h(f.ic(),247),l.c.c.length>0&&rGt(this,l)}function C8t(e){var t,i,a,l;for(t=0,i=0,l=new j(e.i);l.a1||i>1)return 2;return t+i==1?2:0}function A8t(e,t,i){var a,l,f,g,m,v,y;a=i,l=t;do l=e.a[l.o],g=(y=e.g[l.o],ce(e.p[y.o])+ce(e.d[l.o])-l.d.d),m=Z4t(l,l.c?Jo(l.c.a,l,0):-1),m&&(f=(v=e.g[m.o],ce(e.p[v.o])+ce(e.d[m.o])+m.n.b+m.d.a),a=w.Math.min(a,g-(f+r_(e.k,l,m))));while(t!=l);return a}function P8t(e,t,i){var a,l,f,g,m,v,y;a=i,l=t;do l=e.a[l.o],f=(y=e.g[l.o],ce(e.p[y.o])+ce(e.d[l.o])+l.n.b+l.d.a),m=fRt(l,l.c?Jo(l.c.a,l,0):-1),m&&(g=(v=e.g[m.o],ce(e.p[v.o])+ce(e.d[m.o])-m.d.d),a=w.Math.min(a,g-(f+r_(e.k,l,m))));while(t!=l);return a}function L8t(e,t,i){var a,l,f,g;for(l=i,f=c8e(wI(h(h(Qi(e.r,t),19),60).xc(),new _p)),g=0;f.a||(f.a=a_(f.c,f)),f.a;)if(l){kn((f.a||(f.a=a_(f.c,f)),f.a)),f.a=!1,l=!1;continue}else a=eU(f),f.a||(f.a=a_(f.c,f)),f.a&&(g=w.Math.max(g,a));return g}function k8t(e,t,i){var a,l,f,g,m,v,y,E;if(i)for(f=i.a.length,a=new jm(f),m=(a.b-a.a)*a.c<0?(Mg(),mm):new Cg(a);m.hc();)g=h(m.ic(),21),l=lS(i,g.a),l&&(v=$4t(e,(y=(h0(),E=new lpe,E),t&&MYe(y,t),y),l),jI(v,$d(l,kh)),o7(l,v),lve(l,v),mee(e,l,v))}function R8t(e){var t,i,a;return i=h(e.a,21).a,a=h(e.b,21).a,t=(i<0?-i:i)>(a<0?-a:a)?i<0?-i:i:a<0?-a:a,i=-t&&a==t?new Is(He(i-1),He(a)):new Is(He(i),He(a-1))}function wYe(e){var t,i,a,l,f,g;for(g=h(vo(e.a,le(xu,Tf,8,e.a.c.length,0,1)),123),vge(g,new wH),i=null,l=0,f=g.length;la.o?pr(l,ei):l.i==ei&&a.o>e.o&&pr(l,bn);break}return a}function Nve(e,t,i){var a,l,f;for(f=new j(e.e);f.a0&&(a.b.c-=a.c,a.b.c<=0&&a.b.f>0&&Gi(t,a.b));for(l=new j(e.b);l.a0&&(a.a.f-=a.c,a.a.f<=0&&a.a.c>0&&Gi(i,a.a))}function Fve(e,t,i){var a,l,f;for(f=new j(e.q);f.a0&&(a.b.j-=a.c,a.b.j<=0&&a.b.r>0&&Gi(t,a.b));for(l=new j(e.g);l.a0&&(a.a.r-=a.c,a.a.r<=0&&a.a.j>0&&Gi(i,a.a))}function _7(e){var t,i,a,l,f;if(e.g==null&&(e.d=e.Gh(e.f),$n(e,e.d),e.c))return f=e.f,f;if(t=h(e.g[e.i-1],43),l=t.ic(),e.e=t,i=e.Gh(l),i.hc())e.d=i,$n(e,i);else for(e.d=null;!t.hc()&&(zr(e.g,--e.i,null),e.i!=0);)a=h(e.g[e.i-1],43),t=a;return l}function E6(e,t){var i,a,l,f;for(e=e,i=new Qb,f=0,a=0;a=0?e.ug(a,!0,!0):Cx(e,f,!0),184)),h(l,237).xk(t,i)}else throw Y(new un(ry+t.be()+gre))}function zve(e,t,i){switch(i.g){case 1:return new $t(t.a,w.Math.min(e.d.b,t.b));case 2:return new $t(w.Math.max(e.c.a,t.a),t.b);case 3:return new $t(t.a,w.Math.max(e.c.b,t.b));case 4:return new $t(w.Math.min(t.a,e.d.a),t.b)}return new $t(t.a,t.b)}function S6(e){var t,i,a;for(t=Qh(1+(!e.c&&(e.c=new ze(Au,e,9,9)),e.c).i),De(t,(!e.d&&(e.d=new an(js,e,8,5)),e.d)),a=new Dn((!e.c&&(e.c=new ze(Au,e,9,9)),e.c));a.e!=a.i._b();)i=h(Xn(a),121),De(t,(!i.d&&(i.d=new an(js,i,8,5)),i.d));return Hn(t),new Q2(t)}function Mh(e){var t,i,a;for(t=Qh(1+(!e.c&&(e.c=new ze(Au,e,9,9)),e.c).i),De(t,(!e.e&&(e.e=new an(js,e,7,4)),e.e)),a=new Dn((!e.c&&(e.c=new ze(Au,e,9,9)),e.c));a.e!=a.i._b();)i=h(Xn(a),121),De(t,(!i.e&&(i.e=new an(js,i,7,4)),i.e));return Hn(t),new Q2(t)}function N8t(e,t){var i,a,l,f,g;if(ni(t,"Breaking Point Processor",1),ujt(e),ce(bt(G(e,($e(),oTe))))){for(l=new j(e.b);l.a3&&od(e,0,t-3))}function z8t(e){var t,i,a;return i=e.l,i&i-1||(a=e.m,a&a-1)||(t=e.h,t&t-1)||t==0&&a==0&&i==0?-1:t==0&&a==0&&i!=0?Z0e(i):t==0&&a!=0&&i==0?Z0e(a)+22:t!=0&&a==0&&i==0?Z0e(t)+44:-1}function G8t(e,t){var i,a,l,f,g;for(ni(t,"Edge joining",1),i=ce(bt(G(e,($e(),_oe)))),l=new j(e.b);l.a0),f.a.cd(f.c=--f.b),ed(f,l),kn(f.bey,v=Eey,v=Eey,v=Eey,v=E=0){if(t==i)return new Is(He(-t-1),He(-t-1));if(t==-i)return new Is(He(-t),He(i+1))}return(t<0?-t:t)>(i<0?-i:i)?t<0?new Is(He(-t),He(i)):new Is(He(-t),He(i+1)):new Is(He(t+1),He(i))}function X8t(e,t,i){var a,l,f,g,m;return l=h(nn(t,(l7(),_Ce)),21),!l&&(l=He(0)),f=h(nn(i,_Ce),21),!f&&(f=He(0)),l.a>f.a?-1:l.a1)for(t=g0((i=new Fm,++e.b,i),e.d),m=On(f,0);m.b!=m.d.c;)g=h(Fn(m),113),Ku(Uu(Fu(zu(Nu(new nu,1),0),t),g))}function J8t(e,t,i){var a,l,f,g,m;for(ni(i,"Breaking Point Removing",1),e.a=h(G(t,($e(),cm)),197),f=new j(t.b);f.a>16!=6&&t){if(PS(e,t))throw Y(new un(LP+kXe(e)));a=null,e.Cb&&(a=(i=e.Db>>16,i>=0?Awe(e,null):e.Cb.Cg(e,-1-i,null,null))),t&&(a=_x(t,e,6,a)),a=ime(e,t,a),a&&a.Th()}else e.Db&4&&!(e.Db&1)&&Pi(e,new cs(e,1,6,t,t))}function SYe(e,t){var i,a;if(t!=e.Cb||e.Db>>16!=3&&t){if(PS(e,t))throw Y(new un(LP+uKe(e)));a=null,e.Cb&&(a=(i=e.Db>>16,i>=0?kwe(e,null):e.Cb.Cg(e,-1-i,null,null))),t&&(a=_x(t,e,12,a)),a=nme(e,t,a),a&&a.Th()}else e.Db&4&&!(e.Db&1)&&Pi(e,new cs(e,1,3,t,t))}function MYe(e,t){var i,a;if(t!=e.Cb||e.Db>>16!=9&&t){if(PS(e,t))throw Y(new un(LP+vZe(e)));a=null,e.Cb&&(a=(i=e.Db>>16,i>=0?Lwe(e,null):e.Cb.Cg(e,-1-i,null,null))),t&&(a=_x(t,e,9,a)),a=rme(e,t,a),a&&a.Th()}else e.Db&4&&!(e.Db&1)&&Pi(e,new cs(e,1,9,t,t))}function TYe(e,t){var i,a;if(t!=e.Cb||e.Db>>16!=11&&t){if(PS(e,t))throw Y(new un(LP+s_e(e)));a=null,e.Cb&&(a=(i=e.Db>>16,i>=0?Dwe(e,null):e.Cb.Cg(e,-1-i,null,null))),t&&(a=_x(t,e,10,a)),a=hme(e,t,a),a&&a.Th()}else e.Db&4&&!(e.Db&1)&&Pi(e,new cs(e,1,11,t,t))}function n9t(e,t){if(re(t,246))return e6t(e,h(t,35));if(re(t,187))return t6t(e,h(t,121));if(re(t,263))return sPt(e,h(t,137));if(re(t,183))return mUt(e,h(t,105));if(t)return null;throw Y(new un(Txe+$p(new Dl(X(q(sn,1),nt,1,5,[null])))))}function i9t(e){var t,i,a,l,f,g,m,v,y,E,C;return C=Zwe(e),t=e.a,v=t!=null,v&&sA(C,"category",e.a),l=x8(new Gv(e.d)),g=!l,g&&(y=new Om,Og(C,"knownOptions",y),i=new zZ(y),mo(new Gv(e.d),i)),f=x8(e.g),m=!f,m&&(E=new Om,Og(C,"supportedFeatures",E),a=new GZ(E),mo(e.g,a)),C}function r9t(e,t,i){var a,l,f;for(l=new j(e.a.b);l.av){for(E=e.d,e.d=le(PAe,Oxe,55,2*v+4,0,1),f=0;f=9223372036854776e3?(pS(),o3e):(l=!1,e<0&&(l=!0,e=-e),a=0,e>=l1&&(a=wr(e/l1),e-=a*l1),i=0,e>=Ox&&(i=wr(e/Ox),e-=i*Ox),t=wr(e),f=qa(t,i,a),l&&Cee(f),f)}function CYe(e,t,i){var a,l,f,g,m,v;if(!M0(t)){for(v=mc(i,(re(t,13)?h(t,13)._b():vA(t.tc()))/e.a|0),ni(v,WQe,1),m=new Dk,g=0,f=t.tc();f.hc();)a=h(f.ic(),76),m=Np(m,new Id(a)),gPw,f=a-gPw,(l||f)&&(v=h(t.e,249).b,g=h(t.e,249).a,m=h(t.d,129),v==0&&g==0)))return m;return m}function AYe(e,t,i,a){var l,f,g,m;return g=new Qf(e),Bu(g,(qt(),Nr)),Ee(g,(Ie(),Jn),t),Ee(g,($e(),Yi),(Ms(),Ba)),Ee(g,Tl,i),Ee(g,Cl,a),f=new yo,pr(f,(Fe(),tn)),ls(f,g),m=new yo,pr(m,Zt),ls(m,g),_s(t,f),l=new Bp,Oo(l,t),Ee(l,Po,null),Os(l,m),_s(l,a),g}function h9t(e,t,i,a,l){var f,g;(!Ko(t)&&t.c.g.c==t.d.g.c||!d$e(No(X(q(Qr,1),be,9,0,[l.g.k,l.k,l.a])),i))&&(t.c==l?e9(t.a,0,new Io(i)):Gi(t.a,new Io(i)),a&&!IC(e.a,i)&&(g=h(G(t,($e(),Po)),74),g||(g=new Uc,Ee(t,Po,g)),f=new Io(i),Fs(g,f,g.c.b,g.c),Cr(e.a,f)))}function d9t(e,t){var i,a;if(a=R9(e.b,t.b),!a)throw Y(new ma("Invalid hitboxes for scanline constraint calculation."));(cVe(t.b,h(NMt(e.b,t.b),57))||cVe(t.b,h(OMt(e.b,t.b),57)))&&(Kh(),t.b+""),e.a[t.b.f]=h(LJ(e.b,t.b),57),i=h(kJ(e.b,t.b),57),i&&(e.a[i.f]=t.b)}function PYe(e,t,i,a,l,f){var g,m,v,y,E,C,R,B,N,W,V,ee;for(E=a,t.i&&t.k?(B=h(Ii(e.f,t.u),57),W=B.d.c+B.d.b,--E):W=t.a.c+t.a.b,C=l,i.n&&i.k?(B=h(Ii(e.f,i.v),57),y=B.d.c,++C):y=i.a.c,V=y-W,v=2>C-E?2:C-E,m=V/v,N=W+m,R=E;R>16!=7&&t){if(PS(e,t))throw Y(new un(LP+Oqe(e)));a=null,e.Cb&&(a=(i=e.Db>>16,i>=0?Pwe(e,null):e.Cb.Cg(e,-1-i,null,null))),t&&(a=h(t,42).Ag(e,1,pD,a)),a=Qme(e,t,a),a&&a.Th()}else e.Db&4&&!(e.Db&1)&&Pi(e,new cs(e,1,7,t,t))}function p9t(e,t){var i,a;if(t!=e.Cb||e.Db>>16!=3&&t){if(PS(e,t))throw Y(new un(LP+qVe(e)));a=null,e.Cb&&(a=(i=e.Db>>16,i>=0?Rwe(e,null):e.Cb.Cg(e,-1-i,null,null))),t&&(a=h(t,42).Ag(e,0,mD,a)),a=e1e(e,t,a),a&&a.Th()}else e.Db&4&&!(e.Db&1)&&Pi(e,new cs(e,1,3,t,t))}function RYe(e){var t,i,a,l,f,g,m;for(f=new j(e.a.a);f.a0&&f>0?g.o=t++:a>0?g.o=i++:f>0?g.o=l++:g.o=i++}yt(),ua(e.i,new zb)}function IYe(e,t){var i,a,l;for(l=(!t.a&&(t.a=new ze(Br,t,10,11)),t.a).i,a=new Dn((!t.a&&(t.a=new ze(Br,t,10,11)),t.a));a.e!=a.i._b();)i=h(Xn(a),35),Be(nn(i,(lr(),Ey)))!==Be((e1(),ML))&&u0e(Hte(t),Hte(i))&&((!i.a&&(i.a=new ze(Br,i,10,11)),i.a).i==0||(l+=IYe(e,i)));return l}function m9t(e,t){var i,a,l;return i=t.Yg(e.a),i&&(l=Qn(Sf((!i.b&&(i.b=new bl((Et(),Uo),Ca,i)),i.b),"affiliation")),l!=null)?(a=uJ(l,bc(35)),a==-1?qee(e,aA(e,jl(t.Wi())),l):a==0?qee(e,null,l.substr(1,l.length-1)):qee(e,l.substr(0,a),l.substr(a+1,l.length-(a+1)))):null}function b9t(e){var t,i,a,l,f;if(f=new Re,ad(e.b,new RY(f)),e.b.c=le(sn,nt,1,0,5,1),f.c.length!=0){for(t=(oi(0,f.c.length),h(f.c[0],78)),i=1,a=f.c.length;i=e.a||!Xwe(t,i))return-1;if(M0(h(a.Kb(t),20)))return 1;for(l=0,g=h(a.Kb(t),20).tc();g.hc();)if(f=h(g.ic(),14),v=f.c.g==t?f.d.g:f.c.g,m=Vve(e,v,i,a),m==-1||(l=l>m?l:m,l>e.c-1))return-1;return l+1}function w9t(e,t,i,a){var l,f,g,m,v,y,E,C,R;for(C=a?(Fe(),tn):(Fe(),Zt),l=!1,v=t[i],y=0,E=v.length;y>5,t&=31,a>=e.d)return e.e<0?(Kg(),ese):(Kg(),aM);if(f=e.d-a,l=le(Rn,ii,22,f+1,15,1),eNt(l,f,e.a,a,t),e.e<0){for(i=0;i0&&e.a[i]<<32-t){for(i=0;i0&&(f=h(Tt(this.b,0),157),l+=f.o,a+=f.p),l*=2,a*=2,t>1?l=wr(w.Math.ceil(l*t)):a=wr(w.Math.ceil(a/t)),this.a=new nwe(l,a)}function qve(e,t,i,a,l,f){var g,m,v,y,E,C;for(y=i.c.length,f&&(e.c=le(Rn,ii,22,t.length,15,1)),g=l?0:t.length-1;l?g=0;g+=l?1:-1){for(m=t[g],v=a==(Fe(),Zt)?l?ra(m,a):k0(ra(m,a)):l?k0(ra(m,a)):ra(m,a),f&&(e.c[m.o]=v._b()),C=v.tc();C.hc();)E=h(C.ic(),11),e.d[E.o]=y++;Lr(i,v)}}function GYe(e,t,i){var a,l,f,g,m,v,y,E;for(f=ce(Xe(e.b.tc().ic())),y=ce(Xe(_$e(t.b))),a=ou(Fa(e.a),y-i),l=ou(Fa(t.a),i-f),E=tr(a,l),ou(E,1/(y-f)),this.a=E,this.b=new Re,m=!0,g=e.b.tc(),g.ic();g.hc();)v=ce(Xe(g.ic())),m&&v-i>ey&&(this.b.nc(i),m=!1),this.b.nc(v);m&&this.b.nc(i)}function L9t(e){var t,i,a,l;if(DUt(e,e.n),e.d.c.length>0){for(TC(e.c);Mve(e,h($(new j(e.e.a)),113))=l&&(e.c=!1,e.a=!1),e.b[a++]=l,e.b[a]=f,e.c||U_(e)}}function jYe(e){var t,i,a,l;return l=Eh(e),i=new yg(l),a=new DY(l),t=new Re,Lr(t,(!e.d&&(e.d=new an(js,e,8,5)),e.d)),Lr(t,(!e.e&&(e.e=new an(js,e,7,4)),e.e)),h(rd(qf(go(new si(null,new pi(t,16)),i),a),b_(new Un,new bi,new Ei,new it,X(q(th,1),Oe,150,0,[(Wg(),Iw),eh]))),19)}function $Ye(e){var t,i,a;if(i=h(G(e,(Ie(),Al)),8),i?pr(e,h(G(i,da),69)):e.d.c.length-e.f.c.length<0?pr(e,(Fe(),Zt)):pr(e,(Fe(),tn)),!e.b)switch(a=e.n,t=e.a,e.i.g){case 1:t.a=a.a/2,t.b=0;break;case 2:t.a=a.a,t.b=a.b/2;break;case 3:t.a=a.a/2,t.b=a.b;break;case 4:t.a=0,t.b=a.b/2}}function k9t(e,t,i){var a,l,f,g,m;for(ni(i,"Longest path layering",1),e.a=t,m=e.a.a,e.b=le(Rn,ii,22,m.c.length,15,1),a=0,g=new j(m);g.a=0?!1:(i=US((Hc(),Ks),l,t),i?(a=i.kj(),(a>1||a==-1)&&x0($o(Ks,i))!=3):!0)):!1}function R9t(e,t){var i;switch(i=h(G(e,($e(),nL)),241),ni(t,"Label side selection ("+i+")",1),i.g){case 0:_Xe(e,(yl(),xd));break;case 1:_Xe(e,(yl(),dm));break;case 2:DZe(e,(yl(),xd));break;case 3:DZe(e,(yl(),dm));break;case 4:KYe(e,(yl(),xd));break;case 5:KYe(e,(yl(),dm))}Bn(t)}function Xve(e,t,i){var a,l,f,g,m,v;if(a=_Et(i,e.length),g=e[a],g[0].j==(qt(),Jr))for(f=lBe(i,g.length),v=t.i,l=0;l0&&(i[0]+=e.d,g-=i[0]),i[2]>0&&(i[2]+=e.d,g-=i[2]),f=w.Math.max(0,g),i[1]=w.Math.max(i[1],g),b0e(e,Va,l.c+a.b+i[0]-(i[1]-g)/2,i),t==Va&&(e.c.b=f,e.c.c=l.c+a.b+(f-g)/2)}function F9t(e,t){var i,a,l,f,g,m,v;for(i=Ts,m=(qt(),fs),l=new j(t.a);l.a0?g=i:v.c&&(g=zJ(v.c)),g>0&&(a&&(Gm(),v.a.B&&(!ce(bt(v.a.e.xe((lr(),iD))))||v.b.ff()))?v.d.a=e.s+g:(E=v.b.Re().b,g>E&&(m=(g-E)/2,v.d.d=m,v.d.a=m)))}}function G9t(e,t){var i,a,l,f,g;return l=t.Yg(e.a),l&&(a=(!l.b&&(l.b=new bl((Et(),Uo),Ca,l)),l.b),i=Qn(Sf(a,Ls)),i!=null&&(f=i.lastIndexOf("#"),g=f==-1?Zge(e,t.Pi(),i):f==0?PI(e,null,i.substr(1,i.length-1)):PI(e,i.substr(0,f),i.substr(f+1,i.length-(f+1))),re(g,140)))?h(g,140):null}function j9t(e,t){var i,a,l,f,g;return a=t.Yg(e.a),a&&(i=(!a.b&&(a.b=new bl((Et(),Uo),Ca,a)),a.b),f=Qn(Sf(i,Dre)),f!=null&&(l=f.lastIndexOf("#"),g=l==-1?Zge(e,t.Pi(),f):l==0?PI(e,null,f.substr(1,f.length-1)):PI(e,f.substr(0,l),f.substr(l+1,f.length-(l+1))),re(g,140)))?h(g,140):null}function ZYe(e,t,i,a,l){var f,g,m,v,y,E;if(e.d&&e.d.If(l),f=h(l.cd(0),35),THe(e,i,f,!1)||(g=h(l.cd(l._b()-1),35),THe(e,a,g,!0))||ive(e,l))return!0;for(E=l.tc();E.hc();)for(y=h(E.ic(),35),v=t.tc();v.hc();)if(m=h(v.ic(),35),C7(e,y,m))return!0;return!1}function $9t(e,t,i){var a,l,f,g,m,v,y,E,C,R;R=t.c.length,C=(y=e.rg(i),h(y>=0?e.ug(y,!1,!0):Cx(e,i,!1),52));e:for(f=C.tc();f.hc();){for(l=h(f.ic(),51),E=0;Ee.d[g.o]&&(i+=Uze(e.b,f),bA(e.a,He(f)));for(;!wpe(e.a);)uje(e.b,h(ZJ(e.a),21).a)}return i}function j_(e,t,i){var a,l;if((!e.a&&(e.a=new ze(es,e,6,6)),e.a).i==0)return pVe(e);if(a=h(ae((!e.a&&(e.a=new ze(es,e,6,6)),e.a),0),270),t&&(Pr((!a.a&&(a.a=new vs(sh,a,5)),a.a)),AA(a,0),PA(a,0),CA(a,0),TA(a,0)),i)for(l=(!e.a&&(e.a=new ze(es,e,6,6)),e.a);l.i>1;)Ew(l,l.i-1);return a}function q9t(e,t){var i,a,l,f;if(f=LZe(t),l=h(G(f,(Ie(),$a)),19),WGt(t,l),l.pc((xo(),Eu)))for(a=new Dn((!t.c&&(t.c=new ze(Au,t,9,9)),t.c));a.e!=a.i._b();)i=h(Xn(a),121),ejt(e,t,f,i);return S9t(t,f),ce(bt(G(f,($e(),XMe))))&&l.nc(xG),Be(nn(t,iL))===Be((e1(),h3))?o$t(e,t,f):QGt(e,t,f),f}function xo(){xo=M,_G=new iw("COMMENTS",0),Eu=new iw("EXTERNAL_PORTS",1),KP=new iw("HYPEREDGES",2),yG=new iw("HYPERNODES",3),dy=new iw("NON_FREE_PORTS",4),py=new iw("NORTH_SOUTH_PORTS",5),C5=new iw(AQe,6),fM=new iw("CENTER_LABELS",7),hM=new iw("END_LABELS",8),xG=new iw("PARTITIONS",9)}function JYe(e,t,i){var a,l,f,g;for(f=(!t.a&&(t.a=new ze(Br,t,10,11)),t.a).i,l=new Dn((!t.a&&(t.a=new ze(Br,t,10,11)),t.a));l.e!=l.i._b();)a=h(Xn(l),35),(!a.a&&(a.a=new ze(Br,a,10,11)),a.a).i==0||(f+=JYe(e,a,!1));if(i)for(g=to(t);g;)f+=(!g.a&&(g.a=new ze(Br,g,10,11)),g.a).i,g=to(g);return f}function Ew(e,t){var i,a,l,f;return e.ti()?(a=null,l=e.ui(),e.xi()&&(a=e.zi(e.Dh(t),null)),i=e.mi(4,f=xx(e,t),null,t,l),e.qi()&&f!=null&&(a=e.si(f,a)),a?(a.Sh(i),a.Th()):e.ni(i),f):(f=xx(e,t),e.qi()&&f!=null&&(a=e.si(f,null),a&&a.Th()),f)}function X9t(e){var t,i,a,l,f,g,m,v,y;for(g=Kr,v=Kr,m=null,i=new aQ(new I2(e.e));i.b!=i.c.a.b;)if(t=A0e(i),(Be(t.d)===Be((cl(),Yp))||Be(t.d)===Be(Hw))&&(a=h(t.e,249).a,y=h(t.e,249).b,l=g-a>Pw,f=a-gPw,(l||f)&&(v=h(t.e,249).b,g=h(t.e,249).a,m=h(t.d,129),v==0&&g==0)))return m;return m}function Y9t(e){var t,i,a,l,f,g,m,v,y,E;for(f=e.a,t=new Ur,y=0,a=new j(e.d);a.av.d&&(E=v.d+v.a+f));i.c.d=E,t.a.Zb(i,t),y=w.Math.max(y,i.c.d+i.c.a)}return y}function Z9t(e,t,i,a,l){return a<0?(a=N_(e,l,X(q(Se,1),be,2,6,[Vne,Wne,Hne,qne,Dx,Xne,Yne,Zne,Kne,Jne,Qne,eie]),t),a<0&&(a=N_(e,l,X(q(Se,1),be,2,6,["Jan","Feb","Mar","Apr",Dx,"Jun","Jul","Aug","Sep","Oct","Nov","Dec"]),t)),a<0?!1:(i.k=a,!0)):a>0?(i.k=a-1,!0):!1}function K9t(e,t,i,a,l){return a<0?(a=N_(e,l,X(q(Se,1),be,2,6,[Vne,Wne,Hne,qne,Dx,Xne,Yne,Zne,Kne,Jne,Qne,eie]),t),a<0&&(a=N_(e,l,X(q(Se,1),be,2,6,["Jan","Feb","Mar","Apr",Dx,"Jun","Jul","Aug","Sep","Oct","Nov","Dec"]),t)),a<0?!1:(i.k=a,!0)):a>0?(i.k=a-1,!0):!1}function J9t(e,t,i){var a,l,f;if(e.e=i,e.d=0,e.b=0,e.f=1,e.i=t,(e.e&16)==16&&(e.i=EUt(e.i)),e.j=e.i.length,wi(e),f=D0(e),e.d!=e.j)throw Y(new Wn(Yn((zn(),qet))));if(e.g){for(a=0;aKQe?ua(v,e.b):a<=KQe&&a>JQe?ua(v,e.d):a<=JQe&&a>QQe?ua(v,e.c):a<=QQe&&ua(v,e.a),f=eZe(e,v,f);return l}function tZe(e){X2(e,new O_(H2($2(W2(V2(new Q1,gz),"Randomizer"),'Distributes the nodes randomly on the plane, leading to very obfuscating layouts. Can be useful to demonstrate the power of "real" layout algorithms.'),new Gq))),wt(e,gz,Fx,mAe),wt(e,gz,HS,15),wt(e,gz,J7,He(0)),wt(e,gz,VS,WS)}function eUt(e,t){var i,a,l,f,g,m,v,y,E,C;for(v=t.a.length,m=wr(w.Math.ceil(v/e.a)),C=t.a,g=0,y=m,f=0;fg?0:g)g?0:g:v,(0>(yg?0:g)g?0:g:v)),g=y,y+=m,a=h(Tt(e.c,f),8),i=new aJ(E),i.n.b=t.n.b,ir(e.b,t,i),De(a.b,i);Ea(e.g.b,t),De(e.i,(l=new xOe(e,t),l))}function nZe(e,t,i){var a,l,f,g,m,v,y,E,C;for(t.o=1,f=t.c,C=bw(t,(Bo(),cc)).tc();C.hc();)for(E=h(C.ic(),11),l=new j(E.f);l.a=e.length||(m=e.charCodeAt(t[0]),m!=43&&m!=45)||(++t[0],a=h7(e,t),a<0))return!1;m==45&&(a=-a)}return m==32&&t[0]-i==2&&l.b==2&&(v=new T8,y=v.q.getFullYear()-j0+j0-80,g=y%100,f.a=a==g,a+=(y/100|0)*100+(a0){if(e.Fi(),t!=null){for(f=0;f=48;i--)OL[i]=i-48<<24>>24;for(a=70;a>=65;a--)OL[a]=a-65+10<<24>>24;for(l=102;l>=97;l--)OL[l]=l-97+10<<24>>24;for(f=0;f<10;f++)$j[f]=48+f&Gr;for(e=10;e<=15;e++)$j[e]=65+e-10&Gr}function aZe(e){var t,i,a,l;i=ce(Xe(G(e.a,(Mf(),Pit)))),a=e.a.c.d,l=e.a.d.d,t=e.d,a.a>=l.a?a.b>=l.b?(t.a=l.a+(a.a-l.a)/2+i,t.b=l.b+(a.b-l.b)/2-i):(t.a=l.a+(a.a-l.a)/2+i,t.b=a.b+(l.b-a.b)/2+i):a.b>=l.b?(t.a=a.a+(l.a-a.a)/2+i,t.b=l.b+(a.b-l.b)/2+i):(t.a=a.a+(l.a-a.a)/2+i,t.b=a.b+(l.b-a.b)/2-i)}function oUt(e,t,i,a){var l,f,g,m,v;return m=Ra(h(ae((!t.b&&(t.b=new an(gi,t,4,7)),t.b),0),97)),v=Ra(h(ae((!t.c&&(t.c=new an(gi,t,5,8)),t.c),0),97)),to(m)==to(v)||SA(v,m)?null:(g=V9(t),g==i?a:(f=h(Ii(e.a,g),8),f&&(l=h(G(f,(Ie(),gd)),31),l)?l:null))}function aUt(e,t,i,a){var l,f,g,m,v;for(f=e.i.c.length,v=le(yVt,Pye,267,f,0,1),g=0;gR+v&&a.jc();for(g=new j(B);g.a>19)return"-"+lZe(vS(e));for(i=e,a="";!(i.l==0&&i.m==0&&i.h==0);){if(l=BQ(W7),i=A_e(i,l,!0),t=""+vBe(rm),!(i.l==0&&i.m==0&&i.h==0))for(f=9-t.length;f>0;f--)t="0"+t;a=t+a}return a}function El(e,t,i){var a,l,f,g,m;if(e==null)throw Y(new wh(qc));for(f=e.length,g=f>0&&(e.charCodeAt(0)==45||e.charCodeAt(0)==43)?1:0,a=g;ai)throw Y(new wh($0+e+'"'));return m}function lUt(){if(!Object.create||!Object.getOwnPropertyNames)return!1;var e="__proto__",t=Object.create(null);if(t[e]!==void 0)return!1;var i=Object.getOwnPropertyNames(t);return!(i.length!=0||(t[e]=42,t[e]!==42)||Object.getOwnPropertyNames(t).length==0)}function uUt(e,t){var i,a,l,f;for(ni(t,"Resize child graph to fit parent.",1),a=new j(e.b);a.a>24;case 97:case 98:case 99:case 100:case 101:case 102:return e-97+10<<24>>24;case 65:case 66:case 67:case 68:case 69:case 70:return e-65+10<<24>>24;default:throw Y(new wh("Invalid hexadecimal"))}}function mUt(e,t){var i,a,l,f,g,m,v,y,E;if(y=h(Ii(e.c,t),191),!y)throw Y(new vh("Edge did not exist in input."));return g=jA(y),E=new Om,i=new q8e(e,g,E),JEt((!t.a&&(t.a=new ze(es,t,6,6)),t.a),i),Og(y,_xe,E),m=h(nn(t,(lr(),l3)),74),l=!m||LUe(m),f=!l,f&&(v=new Om,a=new TZ(v),mo(m,a),Og(y,"junctionPoints",v)),null}function bUt(e,t,i){var a,l,f,g;ni(i,"Orthogonally routing hierarchical port edges",1),e.a=0,a=Rzt(t),RGt(t,a),iGt(e,t,a),zjt(t),l=h(G(t,($e(),Yi)),83),f=t.b,qKe((oi(0,f.c.length),h(f.c[0],26)),l,t),qKe(h(Tt(f,f.c.length-1),26),l,t),g=t.b,eKe((oi(0,g.c.length),h(g.c[0],26))),eKe(h(Tt(g,g.c.length-1),26)),Bn(i)}function wUt(e){var t,i,a;switch(t=h(G(e.d,($e(),cm)),197),t.g){case 2:i=g$t(e);break;case 3:i=(a=new Re,Na(go(qf(Kf(Kf(new si(null,new pi(e.d.b,16)),new nN),new YH),new ZH),new VH),new c0(a)),a);break;default:throw Y(new ma("Compaction not supported for "+t+" edges."))}Xzt(e,i),mo(new Gv(e.g),new XY(e))}function vUt(e,t,i,a){var l,f,g,m,v;for(l=!1,f=!1,m=new j(a.i);m.a1&&(i?g=Gu(t.c)+1:g=Gu(y.c)-1,m=h(Tt(e.a.b,g),26),qs(y,m)),Qve(e,y,i));return t}function uZe(e,t,i,a,l,f){if(this.b=i,this.d=l,e>=t.length)throw Y(new ka("Greedy SwitchDecider: Free layer not in graph."));this.c=t[e],this.e=new ZR(a),hee(this.e,this.c,(Fe(),tn)),this.i=new ZR(a),hee(this.i,this.c,Zt),this.f=new M9e(this.c),this.a=!f&&l.i&&!l.s&&this.c[0].j==(qt(),Jr),this.a&&ENt(this,e,t.length)}function _Ut(e,t,i){var a,l,f,g;for(ni(i,"Processor order nodes",2),e.a=ce(Xe(G(t,(yw(),jTe)))),l=new Ir,g=On(t.b,0);g.b!=g.d.c;)f=h(Fn(g),76),ce(bt(G(f,(fa(),Yw))))&&Fs(l,f,l.c.b,l.c);a=(kn(l.b!=0),h(l.a.a.c,76)),hKe(e,a),!i.b&&uee(i,1),i_e(e,a,0-ce(Xe(G(a,(fa(),nj))))/2,0),!i.b&&uee(i,1),Bn(i)}function fZe(){this.b=(Xr(),new T0),this.d=new T0,this.e=new T0,this.c=new T0,this.a=new li,this.f=new li,ox(Qr,new Eq,new Sq),ox(pCe,new kq,new Rq),ox(AEe,new Iq,new Dq),ox(PEe,new Nv,new Bq),ox(Q$t,new Oq,new zq),ox(nVt,new e0,new Mq),ox(eVt,new Tq,new Cq),ox(tVt,new Aq,new Pq),ox(sVt,new t0,new Lq)}function hZe(e,t,i,a){var l,f,g,m,v,y;for(v=kte(e,i),y=kte(t,i),l=!1;v&&y&&(a||kDt(v,y,i));)g=kte(v,i),m=kte(y,i),BI(t),BI(e),f=v.c,Lne(v,!1),Lne(y,!1),i?(Yg(t,y.o,f),t.o=y.o,Yg(e,v.o+1,f),e.o=v.o):(Yg(e,v.o,f),e.o=v.o,Yg(t,y.o+1,f),t.o=y.o),qs(v,null),qs(y,null),v=g,y=m,l=!0;return l}function sne(e,t,i,a,l,f,g,m){var v,y,E;for(v=0,t!=null&&(v^=Hg(t.toLowerCase())),i!=null&&(v^=Hg(i)),a!=null&&(v^=Hg(a)),g!=null&&(v^=Hg(g)),m!=null&&(v^=Hg(m)),y=0,E=f.length;yv?new mU(t,e,m-v):m>0&&v>0&&(new mU(e,t,0),new mU(t,e,0)))}function dZe(e){X2(e,new O_(H2($2(W2(V2(new Q1,i5),Tet),"Keeps the current layout as it is, without any automatic modification. Optional coordinates can be given for nodes and edge bend points."),new dN))),wt(e,i5,Fx,lAe),wt(e,i5,fz,Ht(SL)),wt(e,i5,cxe,Ht(oAe)),wt(e,i5,lz,Ht(aAe)),wt(e,i5,uz,Ht(cAe))}function pZe(e){var t,i,a;a=h(G(e,($e(),Lf)),19),!a.Wb()&&(i=(t=h(ml(Zs),10),new Bc(t,h(Qc(t,t.length),10),0)),a.pc((a1(),Pl))?_l(i,Pl):_l(i,Cu),a.pc(Mu)||_l(i,Mu),a.pc(Su)?_l(i,kf):a.pc(Oh)?_l(i,of):a.pc(Tu)&&_l(i,sf),a.pc(kf)?_l(i,Su):a.pc(of)?_l(i,Oh):a.pc(sf)&&_l(i,Tu),Ee(e,Lf,i))}function e_e(e,t){var i,a,l,f;if(0<(re(e,13)?h(e,13)._b():vA(e.tc()))){if(l=t,1=e.o)throw Y(new o8);m=t>>5,g=t&31,f=Gd(1,nr(Gd(g,1))),l?e.n[i][m]=Yf(e.n[i][m],f):e.n[i][m]=Zr(e.n[i][m],tme(f)),f=Gd(f,1),a?e.n[i][m]=Yf(e.n[i][m],f):e.n[i][m]=Zr(e.n[i][m],tme(f))}catch(v){throw v=hr(v),re(v,305)?Y(new ka(_ie+e.o+"*"+e.p+yie+t+Ta+i+xie)):Y(v)}}function one(e,t){var i,a,l,f,g,m,v;for(l=new Re,v=new Re,i=h(Ds(hy,e),15).tc();i.hc();)a=h(i.ic(),151),KWe(l,a.b),KWe(l,BWe(a)),i.hc()&&(a=h(i.ic(),151),Lr(v,BWe(a)),Lr(v,a.b));for(ree(l,e.b),ree(v,e.a),m=new j(l);m.ae.d[m.o]&&(i+=Uze(e.b,f),bA(e.a,He(f)))):++g;for(i+=e.b.d*g;!wpe(e.a);)uje(e.b,h(ZJ(e.a),21).a)}return i}function PUt(e){var t,i,a,l,f,g;if(l=e.g.ed(),a=e.b.ed(),e.e)for(i=0;iey;){for(f=t,g=0;w.Math.abs(t-f)0&&(a=(!e.n&&(e.n=new ze(Qo,e,1,7)),h(h(ae(e.n,0),137),263)).a,!a||Si(Si((t.a+=' "',t),a),'"'))),Si(d0(Si(d0(Si(d0(Si(d0((t.a+=" (",t),e.i),","),e.j)," | "),e.g),","),e.f),")"),t.a)}function vZe(e){var t,i,a;return e.Db&64?Ote(e):(t=new su(gxe),i=e.k,i?Si(Si((t.a+=' "',t),i),'"'):(!e.n&&(e.n=new ze(Qo,e,1,7)),e.n.i>0&&(a=(!e.n&&(e.n=new ze(Qo,e,1,7)),h(h(ae(e.n,0),137),263)).a,!a||Si(Si((t.a+=' "',t),a),'"'))),Si(d0(Si(d0(Si(d0(Si(d0((t.a+=" (",t),e.i),","),e.j)," | "),e.g),","),e.f),")"),t.a)}function _Ze(e){var t,i,a,l,f,g;return f=0,t=du(e),t.Qi()&&(f|=4),e.Bb&_c&&(f|=2),re(e,62)?(i=h(e,17),l=Fo(i),i.Bb&Ka&&(f|=32),l&&(jn(fw(l)),f|=8,g=l.t,(g>1||g==-1)&&(f|=16),l.Bb&Ka&&(f|=64)),i.Bb&oo&&(f|=Rw),f|=ef):re(t,425)?f|=512:(a=t.Qi(),a&&a.i&1&&(f|=256)),e.Bb&512&&(f|=128),f}function o_e(e,t){var i,a,l,f,g,m,v;if(t==null||t.length==0)return null;if(l=h(Ua(e.a,t),180),!l){for(a=(m=new mh(e.b).a.Tb().tc(),new o0(m));a.a.hc();)if(i=(f=h(a.a.ic(),38),h(f.lc(),180)),g=i.c,v=t.length,pt(g.substr(g.length-v,v),t)&&(t.length==g.length||po(g,g.length-t.length-1)==46)){if(l)return null;l=i}l&&Zo(e.a,t,l)}return l}function kUt(e,t){var i;return e.f==Oae?(i=x0($o((Hc(),Ks),t)),e.e?i==4&&t!=(Ax(),_3)&&t!=(Ax(),v3)&&t!=(Ax(),Nae)&&t!=(Ax(),Fae):i==2):e.d&&(e.d.pc(t)||e.d.pc(pA($o((Hc(),Ks),t)))||e.d.pc(US((Hc(),Ks),e.b,t)))?!0:e.f&&jve((Hc(),e.f),mI($o(Ks,t)))?(i=x0($o(Ks,t)),e.e?i==4:i==2):!1}function RUt(e,t,i,a){var l,f,g,m,v,y,E,C;return g=h(nn(i,(lr(),u3)),9),v=g.a,E=g.b+e,l=w.Math.atan2(E,v),l<0&&(l+=jx),l+=t,l>jx&&(l-=jx),m=h(nn(a,u3),9),y=m.a,C=m.b+e,f=w.Math.atan2(C,y),f<0&&(f+=jx),f+=t,f>jx&&(f-=jx),yh(),Ng(1e-10),w.Math.abs(l-f)<=1e-10||l==f||isNaN(l)&&isNaN(f)?0:lf?1:$8(isNaN(l),isNaN(f))}function IUt(e,t,i,a){var l,f;for(pBt(e,t,i,a),wde(t,e.j-t.j+i),bde(t,e.k-t.k+a),f=new j(t.f);f.ai.k&&my&&a>y)y=ce(i.p[m.o])+ce(i.d[m.o])+m.n.b+m.d.a;else{l=!1,e.a&&Kh();break}if(!l)break}return e.a&&Kh(),l}function WUt(e,t){var i,a,l,f,g;for(e.c==null||e.c.lengthf*2?(E=new xU(C),y=Fl(g)/vf(g),v=Rne(E,t,new G2,i,a,l,y),tr(Vf(E.e),v),C.c=le(sn,nt,1,0,5,1),C.c[C.c.length]=E,C.c[C.c.length]=g,f=Fl(E)*vf(E)+Fl(g)*vf(g)):(C.c[C.c.length]=g,f+=Fl(g)*vf(g));return C}function NS(e){switch(e){case 100:return q_(zP,!0);case 68:return q_(zP,!1);case 119:return q_(Ure,!0);case 87:return q_(Ure,!1);case 115:return q_(zre,!0);case 83:return q_(zre,!1);case 99:return q_(Gre,!0);case 67:return q_(Gre,!1);case 105:return q_(jre,!0);case 73:return q_(jre,!1);default:throw Y(new ta(hnt+e.toString(16)))}}function PZe(e,t,i){var a,l,f,g,m,v,y,E;if(t.o==0){for(t.o=1,g=i,i||(l=new Re,f=(a=h(ml(xc),10),new Bc(a,h(Qc(a,a.length),10),0)),g=new Is(l,f)),h(g.a,15).nc(t),t.j==(qt(),Jr)&&h(g.b,19).nc(h(G(t,(Ie(),da)),69)),v=new j(t.i);v.am&&(m=l,E.c=le(sn,nt,1,0,5,1)),l==m&&De(E,new Is(i.c.g,i)));yt(),ua(E,e.c),w0(e.b,v.o,E)}}function n7t(e,t){var i,a,l,f,g,m,v,y,E;for(g=new j(t.b);g.am&&(m=l,E.c=le(sn,nt,1,0,5,1)),l==m&&De(E,new Is(i.d.g,i)));yt(),ua(E,e.c),w0(e.f,v.o,E)}}function i7t(e,t,i,a){var l,f,g,m,v,y,E,C,R;for(v=new $t(i,a),Dc(v,h(G(t,(Fg(),HP)),9)),R=new j(t.e);R.a=40,g&&O7t(e),Tzt(e),L9t(e),i=oWe(e),a=0;i&&a0&&Gi(e.e,f)):(e.c[g]-=y+1,e.c[g]<=0&&e.a[g]>0&&Gi(e.d,f))))}function kZe(e){var t,i,a,l,f,g,m,v,y,E,C;for(m=new Re,f=ce(Xe(e.g.cd(e.g._b()-1))),C=e.g.tc();C.hc();)E=Xe(C.ic()),w0(m,0,f-(pn(E),E));for(g=BA(_ee(e)),y=new Re,l=new j(m),v=new Re,t=0;t1)&&t==1&&h(e.a[e.b],8).j==(qt(),ll)?Lx(h(e.a[e.b],8),(yl(),xd)):a&&(!i||(e.c-e.b&e.a.length-1)>1)&&t==1&&h(e.a[e.c-1&e.a.length-1],8).j==(qt(),ll)?Lx(h(e.a[e.c-1&e.a.length-1],8),(yl(),dm)):(e.c-e.b&e.a.length-1)==2?(Lx(h(IA(e),8),(yl(),xd)),Lx(h(IA(e),8),dm)):I8t(e,l),a0e(e)}function o7t(e){var t,i;if(!e.Wb()){for(i=h(e.cd(0),151).f,new g_e(e),t=new Ns(i.i,0),B_((cl(),np),t),R_(yy,t),c6((Fe(),bn),t),one(lm,t),R_(ob,t),z_(Ww,t),B_(Yp,t),c6(Zt,t),one(rb,t),B_(Hw,t),z_(sb,t),B_(ob,t),c6(ei,t),one(Zp,t),B_(yy,t),z_(Xw,t),R_(Hw,t);t.b=0&&(m=GDt(e,g),!(m&&(y<22?v.l|=1<>>1,g.m=E>>>1|(C&1)<<21,g.l=R>>>1|(E&1)<<21,--y;return i&&Cee(v),f&&(a?(rm=vS(e),l&&(rm=tVe(rm,(pS(),a3e)))):rm=qa(e.l,e.m,e.h)),v}function FZe(e,t,i,a){var l,f,g,m,v,y,E,C;if(sRt(e,t,i),f=t[i],C=a?(Fe(),tn):(Fe(),Zt),XSt(t.length,i,a)){for(l=t[a?i-1:i+1],y0e(e,l,a?(Bo(),cc):(Bo(),Nc)),v=0,E=f.length;v0){for(l=m.length;l>0&&m[l-1]=="";)--l;l=0&&m!=i&&(f=new cs(e,1,m,g,null),a?a.Sh(f):a=f),i>=0&&(f=new cs(e,1,i,m==i?g:null,t),a?a.Sh(f):a=f)),a}function w7t(e,t,i,a){var l,f,g,m,v,y,E;if(MFt(e,t,i,a))return!0;for(g=new j(t.f);g.a=l){for(g=1;g0){if(l=h(e.Ab.g,1627),t==null){for(f=0;f1)for(a=new j(l);a.at.f?1:0:(a=e.e-t.e,i=(e.d>0?e.d:w.Math.floor((e.a-1)*FJe)+1)-(t.d>0?t.d:w.Math.floor((t.a-1)*FJe)+1),i>a+1?l:i0&&(g=m_(g,JZe(a))),FWe(f,g))):lv+N&&(W=C.i+R.i,R.a=(R.i*R.a+C.i*C.a)/W,R.i=W,C.g=R,i=!0)),f=m,C=R;return i}function $Ze(e,t){var i,a,l,f,g,m,v,y,E;if(l=e.g,g=l.n.a,f=l.n.b,g<=0&&f<=0)return Fe(),Oa;switch(y=e.k.a,E=e.k.b,m=e.n.a,i=e.n.b,t.g){case 2:case 1:if(y<0)return Fe(),tn;if(y+m>g)return Fe(),Zt;break;case 4:case 3:if(E<0)return Fe(),bn;if(E+i>f)return Fe(),ei}return v=(y+m/2)/g,a=(E+i/2)/f,v+a<=1&&v-a<=0?(Fe(),tn):v+a>=1&&v-a>=0?(Fe(),Zt):a<.5?(Fe(),bn):(Fe(),ei)}function h_e(e,t,i){var a,l,f,g;if(t[0]>=e.length)return i.o=0,!0;switch(e.charCodeAt(t[0])){case 43:l=1;break;case 45:l=-1;break;default:return i.o=0,!0}if(++t[0],f=t[0],g=h7(e,t),g==0&&t[0]==f)return!1;if(t[0]=14&&i<=16));case 11:return t!=null&&typeof t===Dne;case 12:return t!=null&&(typeof t===N6||typeof t==Dne);case 0:return hte(t,e.__elementTypeId$);case 2:return XJ(t)&&t.sl!==T;case 1:return XJ(t)&&t.sl!==T||hte(t,e.__elementTypeId$);default:return!0}}function Lx(e,t){var i,a,l,f,g,m;if(e.j==(qt(),ll)&&(i=Ebe(go(h(G(e,(Ie(),LG)),15).xc(),new RF(new WO))).a==null?(yl(),uD):t,Ee(e,e3,i),i!=(yl(),dm)))for(a=h(G(e,Jn),14),m=ce(Xe(G(a,($e(),ep)))),g=0,i==xd?g=e.n.b-w.Math.ceil(m/2):i==uD&&(e.n.b-=ce(Xe(G(wa(e),N5))),g=(e.n.b-w.Math.ceil(m))/2),f=new j(e.i);f.a0&&(YI(v,!1,(Xs(),nf)),YI(v,!0,rf)),ad(t.g,new ROe(e,i)),fr(e.g,t,i)}function L7t(e,t){var i,a,l,f,g,m,v;for(f=0,m=0,v=0,l=new j(e.f.e);l.a0&&e.d!=(xA(),bse)&&(m+=g*(a.d.a+e.a[t.b][a.b]*(t.d.a-a.d.a)/i)),i>0&&e.d!=(xA(),gse)&&(v+=g*(a.d.b+e.a[t.b][a.b]*(t.d.b-a.d.b)/i)));switch(e.d.g){case 1:return new $t(m/f,t.d.b);case 2:return new $t(t.d.a,v/f);default:return new $t(m/f,v/f)}}function g_e(e){LVe();var t,i,a,l,f,g,m,v,y,E;for(this.b=new ZO,this.c=new Re,this.a=new Re,v=Tee(),y=0,E=v.length;y0){for(g=0;g>16==-15&&e.Cb.Hg()&&XQ(new VQ(e.Cb,9,13,i,e.c,jp($c(h(e.Cb,53)),e))):re(e.Cb,96)&&e.Db>>16==-23&&e.Cb.Hg()&&(t=e.c,re(t,96)||(t=(Et(),uf)),re(i,96)||(i=(Et(),uf)),XQ(new VQ(e.Cb,9,10,i,t,jp(xa(h(e.Cb,24)),e)))))),e.c}function Sw(e){vi();var t,i,a,l,f;if(e.e!=4&&e.e!=5)throw Y(new un("Token#complementRanges(): must be RANGE: "+e.e));for(U_(e),gP(e),a=e.b.length+2,e.b[0]==0&&(a-=2),i=e.b[e.b.length-1],i==iM&&(a-=2),l=(++_r,new vl(4)),l.b=le(Rn,ii,22,a,15,1),f=0,e.b[0]>0&&(l.b[f++]=0,l.b[f++]=e.b[0]-1),t=1;t=65;i--)ch[i]=i-65<<24>>24;for(a=122;a>=97;a--)ch[a]=a-97+26<<24>>24;for(l=57;l>=48;l--)ch[l]=l-48+52<<24>>24;for(ch[43]=62,ch[47]=63,f=0;f<=25;f++)eg[f]=65+f&Gr;for(g=26,v=0;g<=51;++g,v++)eg[g]=97+v&Gr;for(e=52,m=0;e<=61;++e,m++)eg[e]=48+m&Gr;eg[62]=43,eg[63]=47}function B7t(e,t){var i,a,l,f,g,m,v,y,E,C;if(g=e.d,E=h(G(e,(Ie(),n3)),15),C=0,E){for(v=0,f=E.tc();f.hc();)l=h(f.ic(),8),v=w.Math.max(v,l.n.b),C+=l.n.a;C+=t/2*(E._b()-1),g.d+=v+t}if(i=h(G(e,Kx),15),a=0,i){for(v=0,f=i.tc();f.hc();)l=h(f.ic(),8),v=w.Math.max(v,l.n.b),a+=l.n.a;a+=t/2*(i._b()-1),g.a+=v+t}m=w.Math.max(C,a),m>e.n.a&&(y=(m-e.n.a)/2,g.b=w.Math.max(g.b,y),g.c=w.Math.max(g.c,y))}function O7t(e){var t,i,a,l,f,g,m;for(e.o=new sK,a=new Ir,g=new j(e.e.a);g.a0,m=jU(t,f),zge(i?m.b:m.g,t),P_(m).c.length==1&&Fs(a,m,a.c.b,a.c),l=new Is(f,t),FNe(e.o,l),Ea(e.e.a,f))}function XZe(e,t){var i,a,l,f,g;for(t.d?l=e.a.c==(xh(),ib)?As(t.b):ur(t.b):l=e.a.c==(xh(),Xp)?As(t.b):ur(t.b),f=!1,a=(So(),new Od(Zh(zd(l.a,new z))));Gn(a);)if(i=h(Mn(a),14),g=ce(e.a.f[e.a.g[t.b.o].o]),!(!g&&!Ko(i)&&i.c.g.c==i.d.g.c)&&!(ce(e.a.n[e.a.g[t.b.o].o])||ce(e.a.n[e.a.g[t.b.o].o]))&&(f=!0,IC(e.b,e.a.g[gDt(i,t.b).o])))return t.c=!0,t.a=i,t;return t.c=f,t.a=null,t}function v_e(e,t){var i,a,l,f,g,m,v;if(!Eh(e))throw Y(new ma(Cet));if(a=Eh(e),f=a.g,l=a.f,f<=0&&l<=0)return Fe(),Oa;switch(m=e.i,v=e.j,t.g){case 2:case 1:if(m<0)return Fe(),tn;if(m+e.g>f)return Fe(),Zt;break;case 4:case 3:if(v<0)return Fe(),bn;if(v+e.f>l)return Fe(),ei}return g=(m+e.g/2)/f,i=(v+e.f/2)/l,g+i<=1&&g-i<=0?(Fe(),tn):g+i>=1&&g-i>=0?(Fe(),Zt):i<.5?(Fe(),bn):(Fe(),ei)}function N7t(e,t){var i,a,l,f,g,m,v,y,E,C,R,B;if(e.Wb())return new fo;for(y=0,C=0,l=e.tc();l.hc();)a=h(l.ic(),31),f=a.e,y=w.Math.max(y,f.a),C+=f.a*f.b;for(y=w.Math.max(y,w.Math.sqrt(C)*ce(Xe(G(h(e.tc().ic(),31),($e(),kG))))),R=0,B=0,v=0,i=t,m=e.tc();m.hc();)g=h(m.ic(),31),E=g.e,R+E.a>y&&(R=0,B+=v+t,v=0),A6(g,R,B),i=w.Math.max(i,R+E.a),v=w.Math.max(v,E.b),R+=E.a+t;return new $t(i+t,B+v+t)}function dne(e,t,i){var a,l,f,g,m,v,y,E;if(a=i._b(),a==0)return!1;if(e.ti())if(y=e.ui(),vqe(e,t,i),g=a==1?e.mi(3,null,i.tc().ic(),t,y):e.mi(5,null,i,t,y),e.qi()){for(m=a<100?null:new Eg(a),f=t+a,l=t;l1)for(a=On(l,0);a.b!=a.d.c;)for(i=h(Fn(a),202),f=0,v=new j(i.e);v.am?1:-1:Mbe(e.a,t.a,f),l==-1)C=-v,E=g==v?DQ(t.a,m,e.a,f):NQ(t.a,m,e.a,f);else if(C=g,g==v){if(l==0)return Kg(),aM;E=DQ(e.a,f,t.a,m)}else E=NQ(e.a,f,t.a,m);return y=new l_(C,E.length,E),gA(y),y}function JZe(e){IS();var t,i,a,l;if(t=wr(e),e1e6)throw Y(new u8("power of ten too big"));if(e<=zi)return fx(v6(qx[1],t),t);for(a=v6(qx[1],zi),l=a,i=Vc(e-zi),t=wr(e%zi);Sa(i,zi)>0;)l=m_(l,a),i=Qm(i,zi);for(l=m_(l,v6(qx[1],t)),l=fx(l,zi),i=Vc(e-zi);Sa(i,zi)>0;)l=fx(l,zi),i=Qm(i,zi);return l=fx(l,t),l}function G7t(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V;i=g0(new Fm,e.f),y=e.i[t.c.g.o],B=e.i[t.d.g.o],v=t.c,R=t.d,m=v.a.b,C=R.a.b,y.b||(m+=v.k.b),B.b||(C+=R.k.b),E=wr(w.Math.max(0,m-C)),g=wr(w.Math.max(0,C-m)),N=(W=bf(1,h(G(t,($e(),s3)),21).a),V=r0e(t.c.g.j,t.d.g.j),W*V),l=Ku(Uu(Fu(Nu(zu(new nu,N),g),i),h(Ii(e.k,t.c),113))),f=Ku(Uu(Fu(Nu(zu(new nu,N),E),i),h(Ii(e.k,t.d),113))),a=new DOe(l,f),e.c[t.o]=a}function gne(e){var t,i,a,l,f,g,m,v,y,E,C,R,B;if(i=e.i,t=e.n,e.b==0)for(B=i.c+t.b,R=i.b-t.b-t.c,g=e.a,v=0,E=g.length;v0&&(C-=a[0]+e.c,a[0]+=e.c),a[2]>0&&(C-=a[2]+e.c),a[1]=w.Math.max(a[1],C),L9(e.a[1],i.c+t.b+a[0]-(a[1]-C)/2,a[1]);for(f=e.a,m=0,y=f.length;m0&&(t[0]+=e.c,C-=t[0]),t[2]>0&&(C-=t[2]+e.c),t[1]=w.Math.max(t[1],C),P9(e.a[1],a.d+i.d+t[0]-(t[1]-C)/2,t[1]);else for(N=a.d+i.d,B=a.a-i.d-i.a,g=e.a,v=0,E=g.length;v>>0).toString(16),i="\\x"+Hf(t,t.length-2,t.length)):e>=oo?(t="0"+(e>>>0).toString(16),i="\\v"+Hf(t,t.length-6,t.length)):i=""+String.fromCharCode(e&Gr)}return i}function __e(e){var t,i,a,l,f,g;for(Cge(this),i=e._b()-1;i<3;i++)e.bd(0,h(e.cd(0),9));if(e._b()<4)throw Y(new un("At (least dimension + 1) control points are necessary!"));for(this.c=3,this.e=!0,this.f=!0,this.d=!1,p8t(this,e._b()+this.c-1),g=new Re,f=this.g.tc(),t=0;t=0&&f!=i))throw Y(new un(s5));for(l=0,v=0;vce(Wf(g.g,g.d[0]).a)?(kn(v.b>0),v.a.cd(v.c=--v.b),ed(v,g),l=!0):m.e&&m.e._b()>0&&(f=(!m.e&&(m.e=new Re),m.e).vc(t),y=(!m.e&&(m.e=new Re),m.e).vc(i),(f||y)&&((!m.e&&(m.e=new Re),m.e).nc(g),++g.c));l||(a.c[a.c.length]=g)}function H7t(e,t,i){var a,l,f,g,m,v;for(a=0,f=new Dn((!e.a&&(e.a=new ze(Br,e,10,11)),e.a));f.e!=f.i._b();)l=h(Xn(f),35),g="",(!l.n&&(l.n=new ze(Qo,l,1,7)),l.n).i==0||(g=h(h(ae((!l.n&&(l.n=new ze(Qo,l,1,7)),l.n),0),137),263).a),m=new sUe(g),Oo(m,l),Ee(m,(Fg(),Xx),l),m.b=a++,m.d.a=l.i+l.g/2,m.d.b=l.j+l.f/2,m.e.a=w.Math.max(l.g,1),m.e.b=w.Math.max(l.f,1),De(t.e,m),xl(i.d,l,m),v=h(nn(l,(Mf(),bEe)),83),v==(Ms(),ub)}function q7t(e,t,i,a){var l,f,g,m,v,y,E;if(i.c.g!=t.g)for(l=new Qf(e),Bu(l,(qt(),Nr)),Ee(l,(Ie(),Jn),i),Ee(l,($e(),Yi),(Ms(),Ba)),a.c[a.c.length]=l,g=new yo,ls(g,l),pr(g,(Fe(),tn)),m=new yo,ls(m,l),pr(m,Zt),_s(i,g),f=new Bp,Oo(f,i),Ee(f,Po,null),Os(f,m),_s(f,t),KXe(l,g,m),y=new Ns(i.b,0);y.b0&&(v=m/60|0,y=m%60,l=e.q.getDate(),i=e.q.getHours(),i+v>=24&&++l,f=new w.Date(e.q.getFullYear(),e.q.getMonth(),l,t+v,e.q.getMinutes()+y,e.q.getSeconds(),e.q.getMilliseconds()),e.q.setTime(f.getTime()))),g=e.q.getTime(),e.q.setTime(g+36e5),e.q.getHours()!=t&&e.q.setTime(g)}function X7t(e,t){var i,a,l,f,g,m,v,y,E;for(ni(t,"Layer constraint edge reversal",1),g=new j(e.b);g.ai){Bn(t);return}switch(h(G(e,($e(),yoe)),319).g){case 2:f=new Wa;break;case 0:f=new J1;break;default:f=new IT}if(a=f.sf(e,l),!f.tf())switch(h(G(e,aTe),347).g){case 2:a=yzt(l,a);break;case 1:a=pOt(l,a)}Uzt(e,l,a),Bn(t)}function tKe(e,t,i){var a,l,f,g;return e.ti()?(l=null,f=e.ui(),a=e.mi(1,g=KQ(e,t,i),i,t,f),e.qi()&&!(e.Bh()&&g!=null?Li(g,i):Be(g)===Be(i))?(g!=null&&(l=e.si(g,null)),l=e.ri(i,l),e.xi()&&(l=e.Ai(g,i,l)),l?(l.Sh(a),l.Th()):e.ni(a)):(e.xi()&&(l=e.Ai(g,i,null)),l?(l.Sh(a),l.Th()):e.ni(a)),g):(g=KQ(e,t,i),e.qi()&&!(e.Bh()&&g!=null?Li(g,i):Be(g)===Be(i))&&(l=null,g!=null&&(l=e.si(g,null)),l=e.ri(i,l),l&&l.Th()),g)}function wne(e){var t,i,a,l,f,g,m;if(!e.d){if(m=new xN,t=BL,f=t.a.Zb(e,t),f==null){for(a=new Dn(Do(e));a.e!=a.i._b();)i=h(Xn(a),24),Mr(m,wne(i));t.a.$b(e)!=null,t.a._b()==0}for(g=m.i,l=(!e.q&&(e.q=new ze(lf,e,11,10)),new Dn(e.q));l.e!=l.i._b();++g)h(Xn(l),371);Mr(m,(!e.q&&(e.q=new ze(lf,e,11,10)),e.q)),gw(m),e.d=new t_((h(ae(ye((kg(),At).o),9),17),m.i),m.g),e.e=h(m.g,611),e.e==null&&(e.e=tut),lu(e).b&=-17}return e.d}function hP(e,t,i,a){var l,f,g,m,v,y;if(y=al(e.e.mg(),t),v=0,l=h(e.g,124),Xo(),h(t,61).bj()){for(g=0;g1&&(v>Fl(m)*vf(m)/2||g.b==0)&&(C=new xU(R),E=Fl(m)/vf(m),y=Rne(C,t,new G2,i,a,l,E),tr(Vf(C.e),y),m=C,B.c[B.c.length]=C,v=0,R.c=le(sn,nt,1,0,5,1)));return Lr(B,R),B}function J7t(e,t){var i,a,l,f,g,m,v,y,E;for(ni(t,"Hierarchical port dummy size processing",1),v=new Re,E=new Re,a=ce(Xe(G(e,($e(),o3)))),i=a*2,f=new j(e.b);f.a=V&&e.e[v.o]>N*e.b||fe>=i*V)&&(R.c[R.c.length]=m,m=new Re,wo(g,f),f.a.Pb(),y-=E,B=w.Math.max(B,y*e.b+W),y+=fe,ie=fe,fe=0,E=0,W=0);return new Is(B,R)}function tzt(e){var t,i,a,l,f,g,m,v,y,E,C,R;for(t=YXe(e),E=(m=new Gv(t).a.Tb().tc(),new pR(m));E.a.hc();){for(y=(l=h(E.a.ic(),38),h(l.kc(),8)),C=y.d.d,R=y.n.b+y.d.a,e.d[y.o]=0,i=y;(f=e.a[i.o])!=y;)a=WIt(i,f),e.c==(xh(),Xp)?v=a.d.k.b+a.d.a.b-a.c.k.b-a.c.a.b:v=a.c.k.b+a.c.a.b-a.d.k.b-a.d.a.b,g=ce(e.d[i.o])+v,e.d[f.o]=g,C=w.Math.max(C,f.d.d-g),R=w.Math.max(R,g+f.n.b+f.d.a),i=f;i=y;do e.d[i.o]=ce(e.d[i.o])+C,i=e.a[i.o];while(i!=y);e.b[y.o]=C+R}}function y_e(e,t,i){var a,l,f,g,m,v,y,E,C,R;for(MVe(this),i==(E0(),um)?Cr(this.o,e):Cr(this.t,e),E=Kr,y=Ts,g=t.a.Xb().tc();g.hc();)l=h(g.ic(),48),m=h(l.a,417),a=h(l.b,14),v=a.c,v==e&&(v=a.d),m==um?Cr(this.o,v):Cr(this.t,v),R=No(X(q(Qr,1),be,9,0,[v.g.k,v.k,v.a])).b,E=w.Math.min(E,R),y=w.Math.max(y,R);for(C=No(X(q(Qr,1),be,9,0,[e.g.k,e.k,e.a])).b,Iqe(this,C,E,y),f=t.a.Xb().tc();f.hc();)l=h(f.ic(),48),NXe(this,h(l.b,14));this.k=!1}function nzt(e){var t,i,a,l;if(a=Ine((!e.c&&(e.c=ZI(e.f)),e.c),0),e.e==0||e.a==0&&e.f!=-1&&e.e<0)return a;if(t=G0e(e)<0?1:0,i=e.e,l=(a.length+1+kE(wr(e.e)),new Qb),t==1&&(l.a+="-"),e.e>0)if(i-=a.length-t,i>=0){for(l.a+="0.";i>_1.length;i-=_1.length)i9e(l,_1);GFe(l,_1,wr(i)),Si(l,a.substr(t,a.length-t))}else i=t-i,Si(l,Hf(a,t,wr(i))),l.a+=".",Si(l,cI(a,wr(i)));else{for(Si(l,a.substr(t,a.length-t));i<-_1.length;i+=_1.length)i9e(l,_1);GFe(l,_1,wr(-i))}return l.a}function Da(e,t){var i,a,l,f,g,m,v;if(e==null)return null;if(f=e.length,f==0)return"";for(v=le(Yl,Ah,22,f,15,1),x0e(0,f,e.length),x0e(0,f,v.length),V9e(e,0,f,v,0),i=null,m=t,l=0,g=0;l0?Hf(i.a,0,f-1):""):e.substr(0,f-1):i?i.a:e}function izt(e){var t,i,a,l,f,g,m,v,y,E,C,R,B;for(i=(y=new mh(e.c.b).a.Tb().tc(),new o0(y));i.a.hc();)t=(m=h(i.a.ic(),38),h(m.lc(),180)),l=t.a,l==null&&(l=""),a=RMt(e.c,l),!a&&l.length==0&&(a=HIt(e)),a&&!vx(a.c,t,!1)&&Gi(a.c,t);for(g=On(e.a,0);g.b!=g.d.c;)f=h(Fn(g),436),E=f0e(e.c,f.a),B=f0e(e.c,f.b),E&&B&&Gi(E.c,new Is(B,f.c));for(id(e.a),R=On(e.b,0);R.b!=R.d.c;)C=h(Fn(R),436),t=kMt(e.c,C.a),v=f0e(e.c,C.b),t&&v&&kEt(t,v,C.c);id(e.b)}function rzt(e,t,i){var a,l,f,g,m,v,y,E,C;for(v=i+t.c.c.a,C=new j(t.i);C.a1,m=new Up(E.c);Yo(m.a)||Yo(m.b);)g=h(Yo(m.a)?$(m.a):$(m.b),14),y=g.c==E?g.d:g.c,w.Math.abs(No(X(q(Qr,1),be,9,0,[y.g.k,y.k,y.a])).b-f.b)>1&&h9t(e,g,f,l,E)}}function pP(e){var t,i,a,l,f,g,m,v;if(!e.f){if(v=new yN,m=new yN,t=BL,g=t.a.Zb(e,t),g==null){for(f=new Dn(Do(e));f.e!=f.i._b();)l=h(Xn(f),24),Mr(v,pP(l));t.a.$b(e)!=null,t.a._b()==0}for(a=(!e.s&&(e.s=new ze(Ec,e,21,17)),new Dn(e.s));a.e!=a.i._b();)i=h(Xn(a),158),re(i,62)&&$n(m,h(i,17));gw(m),e.r=new c9e(e,(h(ae(ye((kg(),At).o),6),17),m.i),m.g),Mr(v,e.r),gw(v),e.f=new t_((h(ae(ye(At.o),5),17),v.i),v.g),lu(e).b&=-3}return e.f}function szt(e){var t,i,a,l,f,g,m,v,y,E,C,R,B,N;for(g=e.o,a=le(Rn,ii,22,g,15,1),l=le(Rn,ii,22,g,15,1),i=e.p,t=le(Rn,ii,22,i,15,1),f=le(Rn,ii,22,i,15,1),y=0;y=0&&!L_(e,E,C);)--C;l[E]=C}for(B=0;B=0&&!L_(e,m,N);)--m;f[N]=m}for(v=0;vt[R]&&Ra[v]&&P7(e,v,R,!1,!0)}function I7(){I7=M,CAe=X(q(Yl,1),Ah,22,15,[48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70]),Rlt=new RegExp(`[ +\r\f]+`);try{RL=X(q(SVt,1),nt,1699,0,[new O2((oge(),qU("yyyy-MM-dd'T'HH:mm:ss'.'SSSZ",oI(($f(),$f(),jP))))),new O2(qU("yyyy-MM-dd'T'HH:mm:ss'.'SSS",oI(jP))),new O2(qU("yyyy-MM-dd'T'HH:mm:ss",oI(jP))),new O2(qU("yyyy-MM-dd'T'HH:mm",oI(jP))),new O2(qU("yyyy-MM-dd",oI(jP)))])}catch(e){if(e=hr(e),!re(e,78))throw Y(e)}}function nKe(e,t){var i,a,l,f,g;switch(f=new Uc,e.a.g){case 1:case 3:wo(f,t.e.a),Gi(f,t.i.k),wo(f,k0(t.j.a)),Gi(f,t.a.k),wo(f,t.f.a);break;default:wo(f,t.e.a),wo(f,k0(t.j.a)),wo(f,t.f.a)}id(t.f.a),wo(t.f.a,f),Os(t.f,t.e.c),i=h(G(t.e,($e(),Po)),74),l=h(G(t.j,Po),74),a=h(G(t.f,Po),74),(i||l||a)&&(g=new Uc,d1e(g,a),d1e(g,l),d1e(g,i),Ee(t.f,Po,g)),Os(t.j,null),_s(t.j,null),Os(t.e,null),_s(t.e,null),qs(t.a,null),qs(t.i,null),t.g&&nKe(e,t.g)}function iKe(e){X2(e,new O_(H2($2(W2(V2(new Q1,u1),"ELK DisCo"),"Layouter for arranging unconnected subgraphs. The subgraphs themselves are, by default, not laid out."),new ht))),wt(e,u1,Mie,Ht(fEe)),wt(e,u1,Tie,Ht(lse)),wt(e,u1,VS,Ht(fit)),wt(e,u1,Fx,Ht(uEe)),wt(e,u1,aye,Ht(git)),wt(e,u1,cye,Ht(pit)),wt(e,u1,oye,Ht(mit)),wt(e,u1,lye,Ht(dit)),wt(e,u1,fye,Ht(hit)),wt(e,u1,hye,Ht(cse)),wt(e,u1,dye,Ht(lEe)),wt(e,u1,pye,Ht(Yz))}function ozt(e,t,i){var a,l,f,g,m,v,y,E,C;for(g=new JHe,y=X(q(Rn,1),ii,22,15,[0]),l=-1,f=0,a=0,v=0;v0){if(l<0&&E.a&&(l=v,f=y[0],a=0),l>=0){if(m=E.b,v==l&&(m-=a++,m==0))return 0;if(!rJe(t,y,E,m,g)){v=l-1,y[0]=f;continue}}else if(l=-1,!rJe(t,y,E,0,g))return 0}else{if(l=-1,E.c.charCodeAt(0)==32){if(C=y[0],Ije(t,y),y[0]>C)continue}else if(vPt(t,E.c,y[0])){y[0]+=E.c.length;continue}return 0}return Rjt(g,i)?y[0]:0}function azt(e,t,i){var a,l,f,g,m;if(a=h(G(e,($e(),doe)),19),i.a>t.a&&(a.pc((LS(),dG))?e.c.a+=(i.a-t.a)/2:a.pc(pG)&&(e.c.a+=i.a-t.a)),i.b>t.b&&(a.pc((LS(),mG))?e.c.b+=(i.b-t.b)/2:a.pc(gG)&&(e.c.b+=i.b-t.b)),h(G(e,(Ie(),$a)),19).pc((xo(),Eu))&&(i.a>t.a||i.b>t.b))for(m=new j(e.a);m.at.a&&(a.pc((LS(),dG))?e.c.a+=(i.a-t.a)/2:a.pc(pG)&&(e.c.a+=i.a-t.a)),i.b>t.b&&(a.pc((LS(),mG))?e.c.b+=(i.b-t.b)/2:a.pc(gG)&&(e.c.b+=i.b-t.b)),h(G(e,(Ie(),$a)),19).pc((xo(),Eu))&&(i.a>t.a||i.b>t.b))for(g=new j(e.a);g.aB||a+l>y)throw Y(new r8);if(!(C.i&1)&&R!=v)if(E=__(e),f=__(i),Be(e)===Be(i)&&ta;)zr(f,m,E[--t]);else for(m=a+l;a0&&Swe(e,t,i,a,l,!0)}function uzt(e,t,i){var a,l,f,g,m,v,y,E,C,R;for(E=new I9(new Vv(i)),m=le(ku,f1,22,e.f.e.c.length,16,1),l1e(m,m.length),i[t.b]=0,y=new j(e.f.e);y.a=e.b.length?(f[l++]=g.b[a++],f[l++]=g.b[a++]):a>=g.b.length?(f[l++]=e.b[i++],f[l++]=e.b[i++]):g.b[a]=m?NQ(e.a,f,t.a,m):NQ(t.a,m,e.a,f);else{if(l=f!=m?f>m?1:-1:Mbe(e.a,t.a,f),l==0)return Kg(),aM;l==1?(R=g,C=DQ(e.a,f,t.a,m)):(R=v,C=DQ(t.a,m,e.a,f))}return y=new l_(R,C.length,C),gA(y),y}function oKe(e,t){var i,a,l,f,g,m;for(g=new Zm(new xp(e.f.b).a);g.b;){if(f=P0(g),l=h(f.kc(),536),t==1){if(l.Je()!=(Xs(),hm)&&l.Je()!=ip)continue}else if(l.Je()!=(Xs(),nf)&&l.Je()!=rf)continue;switch(a=h(h(f.lc(),48).b,80),m=h(h(f.lc(),48).a,172),i=m.c,l.Je().g){case 2:a.g.c=e.e.a,a.g.b=w.Math.max(1,a.g.b+i);break;case 1:a.g.c=a.g.c+i,a.g.b=w.Math.max(1,a.g.b-i);break;case 4:a.g.d=e.e.b,a.g.a=w.Math.max(1,a.g.a+i);break;case 3:a.g.d=a.g.d+i,a.g.a=w.Math.max(1,a.g.a-i)}}}function aKe(e,t,i,a){var l,f,g,m,v,y,E;if(f=zU(a),m=ce(bt(G(a,($e(),jMe)))),(m||ce(bt(G(e,OG))))&&!Dd(h(G(e,Yi),83)))l=r6(f),v=d_e(e,i,i==(Bo(),cc)?l:n6(l));else switch(v=new yo,ls(v,e),t?(E=v.k,E.a=t.a-e.k.a,E.b=t.b-e.k.b,Gqe(E,0,0,e.n.a,e.n.b),pr(v,$Ze(v,f))):(l=r6(f),pr(v,i==(Bo(),cc)?l:n6(l))),g=h(G(a,(Ie(),$a)),19),y=v.i,f.g){case 2:case 1:(y==(Fe(),bn)||y==ei)&&g.nc((xo(),py));break;case 4:case 3:(y==(Fe(),Zt)||y==tn)&&g.nc((xo(),py))}return v}function pzt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W;for(m=le(Rn,ii,22,t.b.c.length,15,1),y=le(xse,Oe,232,t.b.c.length,0,1),v=le(xu,Tf,8,t.b.c.length,0,1),C=e.a,R=0,B=C.length;R0&&v[a]&&(N=r_(e.b,v[a],l)),W=w.Math.max(W,l.c.c.b+N);for(f=new j(E.f);f.a"}v!=null&&(t.a+=""+v)}else e.e?(m=e.e.zb,m!=null&&(t.a+=""+m)):(t.a+="?",e.b?(t.a+=" super ",Ene(e.b,t)):e.f&&(t.a+=" extends ",Ene(e.f,t)))}function gzt(e,t){var i,a,l,f,g,m,v,y;for(e.f=t,e.d=h(G(e.f,(UI(),_Ee)),348),e.g=h(G(e.f,SEe),21).a,e.e=ce(Xe(G(e.f,yEe))),e.c=ce(Xe(G(e.f,tG))),JJ(e.b),a=new j(e.f.c);a.a=0)return!1;if(i.e&&l==(qt(),ja)&&l!=i.e)return!1;if(t.o=i.b,De(i.f,t),i.e=l,l==(qt(),Nr)||l==sa||l==ja){for(g=new j(t.i);g.a0&&a<=l?(y-=a,f=m,g=m):(e.a==null&&Fte(e),e.a[g]&&(y+=l,f=g)),f>0){De(C,He(f)),m=-1,E=!1;do if(i.hc())v=He(h(i.ic(),21).a+y);else break e;while(v.a<=g)}}else if(e.a==null&&Fte(e),e.a[g]&&(m=g),g==v.a)if(e.a==null&&Fte(e),e.a[g])if(C.c[C.c.length]=v,m=-1,i.hc())v=He(h(i.ic(),21).a+y);else break;else E=!0;++g}return C}function uKe(e){var t,i,a,l;return e.Db&64?Xee(e):(t=new su(hxe),a=e.k,a?Si(Si((t.a+=' "',t),a),'"'):(!e.n&&(e.n=new ze(Qo,e,1,7)),e.n.i>0&&(l=(!e.n&&(e.n=new ze(Qo,e,1,7)),h(h(ae(e.n,0),137),263)).a,!l||Si(Si((t.a+=' "',t),l),'"'))),i=(!e.b&&(e.b=new an(gi,e,4,7)),!(e.b.i<=1&&(!e.c&&(e.c=new an(gi,e,5,8)),e.c.i<=1))),i?t.a+=" [":t.a+=" ",Si(t,lJ(new LR(Ta),new Dn(e.b))),i&&(t.a+="]"),t.a+=" -> ",i&&(t.a+="["),Si(t,lJ(new LR(Ta),new Dn(e.c))),i&&(t.a+="]"),t.a)}function xzt(e){var t,i,a,l,f,g;for(l=new Re,g=new j(e.c.i);g.ae.n.b||(i=ra(e,Zt),m=t.d+t.a+(i._b()-1)*g,m>e.n.b)))}function Cne(e,t,i){var a,l,f,g,m,v,y,E;return a=e.a.o==(Zf(),rh)?Kr:Ts,m=XZe(e,new UOe(t,i)),!m.a&&m.c?(Gi(e.c,m),a):m.a?(l=m.a.c,v=m.a.d,i?(y=e.a.c==(xh(),ib)?v:l,f=e.a.c==ib?l:v,g=e.a.g[f.g.o],E=ce(e.a.p[g.o])+ce(e.a.d[f.g.o])+f.k.b+f.a.b-ce(e.a.d[y.g.o])-y.k.b-y.a.b):(y=e.a.c==(xh(),Xp)?v:l,f=e.a.c==Xp?l:v,E=ce(e.a.p[e.a.g[f.g.o].o])+ce(e.a.d[f.g.o])+f.k.b+f.a.b-ce(e.a.d[y.g.o])-y.k.b-y.a.b),e.a.n[e.a.g[l.g.o].o]=(vt(),vt(),!0),e.a.n[e.a.g[v.g.o].o]=!0,E):a}function Ane(e,t,i,a,l,f,g){var m,v,y,E,C,R,B;return C=ce(bt(G(t,($e(),$Me)))),R=null,f==(Bo(),Nc)&&a.c.g==i?R=a.c:f==cc&&a.d.g==i&&(R=a.d),y=g,!g||!C||R?(E=(Fe(),Oa),R?E=R.i:Dd(h(G(i,Yi),83))&&(E=f==Nc?tn:Zt),v=Ozt(e,t,i,f,E,a),m=OQ((wa(i),a)),f==Nc?(Os(m,h(Tt(v.i,0),11)),_s(m,l)):(Os(m,l),_s(m,h(Tt(v.i,0),11))),y=new KVe(a,m,v,h(G(v,(Ie(),Jn)),11),f,!R)):(De(g.e,a),B=w.Math.max(ce(Xe(G(g.d,ep))),ce(Xe(G(a,ep)))),Ee(g.d,ep,B)),ir(e.a,a,new d9(y.d,t,f)),y}function hKe(e,t){var i,a,l,f,g,m,v,y,E,C;if(Ee(t,(fa(),bM),0),v=h(G(t,tj),76),t.d.b==0)v?(E=ce(Xe(G(v,Kp)))+e.a+h0e(v,t),Ee(t,Kp,E)):Ee(t,Kp,0);else{for(a=(f=On(new Id(t).a.d,0),new Jb(f));v8(a.a);)i=h(Fn(a.a),170).c,hKe(e,i);m=h(c9((g=On(new Id(t).a.d,0),new Jb(g))),76),C=h(nTt((l=On(new Id(t).a.d,0),new Jb(l))),76),y=(ce(Xe(G(C,Kp)))+ce(Xe(G(m,Kp))))/2,v?(E=ce(Xe(G(v,Kp)))+e.a+h0e(v,t),Ee(t,Kp,E),Ee(t,bM,ce(Xe(G(t,Kp)))-y),AGt(e,t)):Ee(t,Kp,y)}}function Mzt(e,t){var i,a,l,f,g,m,v,y,E;if(y=h(G(e,(Ie(),da)),69),a=h(Tt(e.i,0),11),y==(Fe(),bn)?pr(a,ei):y==ei&&pr(a,bn),h(G(t,($e(),zw)),185).pc((Wl(),C1))){if(v=ce(Xe(G(e,aL))),g=ce(Xe(G(e,a3))),m=h(G(t,r3),275),m==(Jf(),fb))for(i=v,E=e.n.a/2-a.k.a,f=new j(a.e);f.a0&&a>=-6?a>=0?vI(f,i-wr(e.e),"."):(f.a=Hf(f.a,0,t-1)+"0."+cI(f.a,t-1),vI(f,t+1,fu(_1,0,-wr(a)-1))):(i-t>=1&&(vI(f,t,"."),++i),vI(f,i,"E"),a>0&&vI(f,++i,"+"),vI(f,++i,""+E9(Vc(a)))),e.g=f.a,e.g))}function pKe(e,t,i){var a,l,f,g;this.j=e,this.e=gve(e),this.o=h(G(this.j,(Ie(),sm)),8),this.i=!!this.o,this.p=this.i?h(Tt(i,wa(this.o).o),204):null,l=h(G(e,$a),19),this.g=l.pc((xo(),Eu)),this.b=new Re,this.d=new kWe(this.e),g=h(G(this.j,pM),214),this.q=jRt(t,g,this.e),this.k=new E7e(this),f=Ym(X(q(crt,1),nt,208,0,[this,this.d,this.k,this.q])),t==(L0(),HG)?(a=new sVe(this.e),f.c[f.c.length]=a,this.c=new sze(a,g,h(this.q,422))):this.c=new IOe(t,this),De(f,this.c),fKe(f,this.e),this.s=c$t(this.k)}function Czt(e,t){var i,a,l,f;return i=new Pe,a=h(rd(qf(new si(null,new pi(e.f,16)),i),b_(new Un,new bi,new Ei,new it,X(q(th,1),Oe,150,0,[(Wg(),Iw),eh]))),19),l=a._b(),l=l==2?1:0,l==1&&nw(i6(h(rd(go(a.uc(),new ke),F$e(n1(0),new Hi)),149).a,2),0)&&(l=0),a=h(rd(qf(new si(null,new pi(t.f,16)),i),b_(new Un,new bi,new Ei,new it,X(q(th,1),Oe,150,0,[Iw,eh]))),19),f=a._b(),f=f==2?1:0,f==1&&nw(i6(h(rd(go(a.uc(),new dt),F$e(n1(0),new Hi)),149).a,2),0)&&(f=0),l=e.b[l+1])l+=2;else if(i0)for(a=new wf(h(Qi(e.a,f),19)),yt(),ua(a,new BF(t)),l=new Ns(f.b,0);l.b=oo?ho(i,Wbe(a)):KE(i,a&Gr),g=(++_r,new _Q(10,null,0)),xAt(e.a,g,m-1)):(i=(g.ll().length+f,new MC),ho(i,g.ll())),t.e==0?(a=t.jl(),a>=oo?ho(i,Wbe(a)):KE(i,a&Gr)):ho(i,t.ll()),h(g,474).b=i.a}}function Izt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B;if(ni(t,"Edge splitting",1),e.b.c.length<=2){Bn(t);return}for(f=new Ns(e.b,0),g=(kn(f.bAe)?(v=2,g=zi):v==0?(v=1,g=qe):(v=0,g=qe)):(B=qe>=g||g-qe0?(l=a+(N-1)*i,C&&(l+=a),l0){JU(e,i,0),i.a+=String.fromCharCode(a),l=QRt(t,f),JU(e,i,l),f+=l-1;continue}a==39?f+10){if(t=new dge(e.i,e.g),i=e.i,f=i<100?null:new Eg(i),e.xi())for(a=0;a0){for(m=e.g,y=e.i,_A(e),f=y<100?null:new Eg(y),a=0;a0)if(t=new cbe(e.Uh()),l=v<100?null:new Eg(v),rI(e,v,t.g),a=v==1?e.mi(4,ae(t,0),null,0,m):e.mi(6,t,null,-1,m),e.qi()){for(i=new Dn(t);i.e!=i.i._b();)l=e.si(Xn(i),l);l?(l.Sh(a),l.Th()):e.ni(a)}else l?(l.Sh(a),l.Th()):e.ni(a);else rI(e,e.hi(),e.ii()),e.ni(e.mi(6,(yt(),uo),null,-1,m));else if(e.qi())if(v=e.hi(),v>0){for(g=e.ii(),rI(e,v,g),l=v<100?null:new Eg(v),i=0;i>13|(e.m&15)<<9,l=e.m>>4&8191,f=e.m>>17|(e.h&255)<<5,g=(e.h&1048320)>>8,m=t.l&8191,v=t.l>>13|(t.m&15)<<9,y=t.m>>4&8191,E=t.m>>17|(t.h&255)<<5,C=(t.h&1048320)>>8,ut=i*m,ft=a*m,Ct=l*m,Mt=f*m,Ln=g*m,v!=0&&(ft+=i*v,Ct+=a*v,Mt+=l*v,Ln+=f*v),y!=0&&(Ct+=i*y,Mt+=a*y,Ln+=l*y),E!=0&&(Mt+=i*E,Ln+=a*E),C!=0&&(Ln+=i*C),B=ut&Xc,N=(ft&511)<<13,R=B+N,V=ut>>22,ee=ft>>9,ie=(Ct&262143)<<4,fe=(Mt&31)<<17,W=V+ee+ie+fe,Ae=Ct>>18,Ue=Mt>>5,qe=(Ln&4095)<<8,we=Ae+Ue+qe,W+=R>>22,R&=Xc,we+=W>>22,W&=Xc,we&=Zd,qa(R,W,we)}function bKe(e,t){var i,a,l,f,g;i=ce(Xe(G(t,($e(),ih)))),i<2&&Ee(t,ih,2),a=h(G(t,tf),110),a==(Xs(),Bh)&&Ee(t,tf,zU(t)),l=h(G(t,eot),21),l.a==0?Ee(t,(Ie(),pM),new Jee):Ee(t,(Ie(),pM),new J9(l.a)),f=bt(G(t,rL)),f==null&&Ee(t,rL,(vt(),Be(G(t,cm))===Be((cd(),xM)))),g=new jqe(t),Ee(t,(Ie(),Nw),g),Z1e(e.a),lw(e.a,(_o(),Ih),h(G(t,CMe),285)),lw(e.a,Yx,h(G(t,GMe),285)),lw(e.a,Ja,h(G(t,gM),285)),lw(e.a,Qa,h(G(t,FG),285)),lw(e.a,Ho,ZRt(h(G(t,cm),197))),UNe(e.a,d$t(t)),Ee(t,coe,T_e(e.a,t))}function wKe(e,t){var i,a,l,f,g,m,v,y,E,C;if(v=t.length-1,m=t.charCodeAt(v),m==93){if(g=_h(t,bc(91)),g>=0)return l=w6t(e,t.substr(1,g-1)),E=t.substr(g+1,v-(g+1)),Qjt(e,E,l)}else{if(i=-1,/\d/.test(String.fromCharCode(m))&&(i=cme(t,bc(46),v-1),i>=0)){a=h(m0e(e,Eje(e,t.substr(1,i-1)),!1),52);try{y=El(t.substr(i+1,t.length-(i+1)),zs,zi)}catch(R){throw R=hr(R),re(R,118)?(f=R,Y(new hU(f))):Y(R)}if(y4)if(e.Li(t)){if(e.Dj()){if(l=h(t,42),a=l.ng(),v=a==e.e&&(e.Pj()?l.hg(l.og(),e.Lj())==e.Mj():-1-l.og()==e.pi()),e.Qj()&&!v&&!a&&l.sg()){for(f=0;f=V-1)return null;for(l=new Re,l.c[l.c.length]=t,we=t,g=i,N=-1,m=h(Tt(e.d.c.b,i),26),B=0;B1&&g0&&(y=e.k.a/f);break;case 2:case 4:l=e.g.n.b,l>0&&(y=e.k.b/l)}Ee(e,(Ie(),eb),y)}if(v=e.n,g=e.a,a)g.a=a.a,g.b=a.b,e.b=!0;else if(t!=rp&&t!=ub&&m!=Oa)switch(m.g){case 1:g.a=v.a/2;break;case 2:g.a=v.a,g.b=v.b/2;break;case 3:g.a=v.a/2,g.b=v.b;break;case 4:g.b=v.b/2}else g.a=v.a/2,g.b=v.b/2}function Kzt(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N;for(ni(i,xQe,1),e.c=t,R=e.c.a,f=0,y=new j(R);y.aN){for(B=1,l=m.n.a;l>g;)++B,l=(m.n.a-(B-1)*e.d)/B;De(a,new $ze(e,m,B,l))}for(v=new j(a);v.a1&&Fl(g)*vf(g)/2>m[0]){for(f=0;fm[f];)++f;N=new Rg(W,0,f+1),C=new xU(N),E=Fl(g)/vf(g),v=Rne(C,t,new G2,i,a,l,E),tr(Vf(C.e),v),hS(kS(R,C)),B=new Rg(W,f+1,W.c.length),F0e(R,B),W.c=le(sn,nt,1,0,5,1),y=0,D9e(m,m.length,0)}else V=R.b.c.length==0?null:Tt(R.b,0),V!=null&&ibe(R,0),y>0&&(m[y]=m[y-1]),m[y]+=Fl(g)*vf(g),++y,W.c[W.c.length]=g;return W}function T_e(e,t){var i,a,l,f,g,m,v,y,E,C,R;if(e.e&&e.c.c.5?ee-=g*2*(N-.5):N<.5&&(ee+=f*2*(.5-N)),l=m.d.b,eeV.a-W-E&&(ee=V.a-W-E),m.k.a=t+ee}}function _Ke(e,t){var i,a,l,f,g;for(g=new j(e.i);g.a0&&eXe(e,m,C);for(l=new j(C);l.a0&&(e.a=v+(B-1)*f,t.c.b+=e.a,t.e.b+=e.a)),N.a._b()!=0&&(R=new Nte(1,f),B=x_e(R,t,N,W,t.e.b+v-t.c.b),B>0&&(t.e.b+=v+(B-1)*f))}function A_e(e,t,i){var a,l,f,g,m,v;if(t.l==0&&t.m==0&&t.h==0)throw Y(new u8("divide by zero"));if(e.l==0&&e.m==0&&e.h==0)return i&&(rm=qa(0,0,0)),qa(0,0,0);if(t.h==G6&&t.m==0&&t.l==0)return k6t(e,i);if(v=!1,t.h>>19&&(t=vS(t),v=!0),g=z8t(t),f=!1,l=!1,a=!1,e.h==G6&&e.m==0&&e.l==0)if(l=!0,f=!0,g==-1)e=DNe((pS(),o3e)),a=!0,v=!v;else return m=kve(e,g),v&&Cee(m),i&&(rm=qa(0,0,0)),m;else e.h>>19&&(f=!0,e=vS(e),a=!0,v=!v);return g!=-1?dIt(e,g,v,f,i):Bwe(e,t)<0?(i&&(f?rm=vS(e):rm=qa(e.l,e.m,e.h)),qa(0,0,0)):u7t(a?e:qa(e.l,e.m,e.h),t,v,f,l,i)}function rGt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie;for(y=t.c,l=Sge(e.e),C=ou(iI(Fa(Ege(e.e)),e.d*e.a,e.c*e.b),-.5),i=l.a-C.a,a=l.b-C.b,g=t.a,i=g.c-i,a=g.d-a,v=new j(y);v.a=0)return i;switch(x0($o(e,i))){case 2:{if(pt("",Gp(e,i.Wi()).be())){if(v=mI($o(e,i)),m=nS($o(e,i)),E=Bve(e,t,v,m),E)return E;for(l=c_e(e,t),g=0,C=l._b();gt.e||t.f>e.e)){for(i=0,a=0,g=e.t.a.Xb().tc();g.hc();)l=h(g.ic(),11),Vee(No(X(q(Qr,1),be,9,0,[l.g.k,l.k,l.a])).b,t.f,t.e)&&++i;for(m=e.o.a.Xb().tc();m.hc();)l=h(m.ic(),11),Vee(No(X(q(Qr,1),be,9,0,[l.g.k,l.k,l.a])).b,t.f,t.e)&&--i;for(v=t.t.a.Xb().tc();v.hc();)l=h(v.ic(),11),Vee(No(X(q(Qr,1),be,9,0,[l.g.k,l.k,l.a])).b,e.f,e.e)&&++a;for(f=t.o.a.Xb().tc();f.hc();)l=h(f.ic(),11),Vee(No(X(q(Qr,1),be,9,0,[l.g.k,l.k,l.a])).b,e.f,e.e)&&--a;i0&&i.charCodeAt(0)!=47))throw Y(new un("invalid opaquePart: "+i));if(e&&!(t!=null&&RC(Bj,t.toLowerCase()))&&!(i==null||!Ree(i,IL,DL)))throw Y(new un(xtt+i));if(e&&t!=null&&RC(Bj,t.toLowerCase())&&!GBt(i))throw Y(new un(xtt+i));if(!mIt(a))throw Y(new un("invalid device: "+a));if(!UIt(l))throw g=l==null?"invalid segments: null":"invalid segment: "+IIt(l),Y(new un(g));if(!(f==null||_h(f,bc(35))==-1))throw Y(new un("invalid query: "+f))}function yKe(e,t){var i;if(t==null||pt(t,qc)||t.length==0&&e.k!=(o1(),vM))return null;switch(e.k.g){case 1:return YU(t,ZS)?(vt(),sM):YU(t,dre)?(vt(),Y0):null;case 2:try{return He(El(t,zs,zi))}catch(a){if(a=hr(a),re(a,118))return null;throw Y(a)}case 4:try{return _w(t)}catch(a){if(a=hr(a),re(a,118))return null;throw Y(a)}case 3:return t;case 5:return kVe(e),yXe(e,t);case 6:return kVe(e),v8t(e,e.a,t);case 7:try{return i=FFt(e),i.gf(t),i}catch(a){if(a=hr(a),re(a,30))return null;throw Y(a)}default:throw Y(new ma("Invalid type set for this layout option."))}}function lGt(e){var t,i,a,l,f,g,m,v,y,E,C;for(g=new j(e.d.b);g.a0&&YI(y,!0,(Xs(),rf)),m.j==(qt(),Jr)&&dUe(y),fr(e.f,m,t)}}function uGt(e,t,i){var a,l,f,g,m,v,y,E;if(i._b()==0)return!1;if(m=(Xo(),h(t,61).bj()),f=m?i:new w_(i._b()),z0(e.e,t)){if(t.xh())for(y=i.tc();y.hc();)v=y.ic(),bne(e,t,v,re(t,62)&&(h(h(t,17),62).Bb&oo)!=0)||(l=Dg(t,v),f.pc(l)||f.nc(l));else if(!m)for(y=i.tc();y.hc();)v=y.ic(),l=Dg(t,v),f.nc(l)}else{if(i._b()>1)throw Y(new un(Ore));for(E=al(e.e.mg(),t),a=h(e.g,124),g=0;g1&&g>1;)E=ZZe(e,we),m=h(Tt(e.d.c.b,g),26),C=h(Tt(e.d.c.b,g-1),26),Ue=h(W.cd(R++),21).a,ee=f0(Ue,C.a.c.length),Yg(we,ee,C),Yg(E,fe,m),fe=ee,we&&(l.c[l.c.length]=we),we=E,--Ae,++f,--g;for(ie=(a-(l.c.length-1)*e.d.d)/l.c.length,y=new j(l);y.a0&&m7(e,t,!1,!1,l),C=Pte(e,t,!0,!1)):(m7(e,t,!1,v,0),C=Pte(e,t,!0,!1)):E?(m=h(h(Qi(e.r,t),19),60)._b(),f=YBt(e,t),C=f*m+e.u*(m-1),f>0&&m7(e,t,!0,!1,f)):(m7(e,t,!0,!1,0),C=Pte(e,t,!0,!0)),nne(e,t)==(Xg(),lb)&&(C+=2*e.u),i.a.a=C}function SKe(e,t){var i,a,l,f,g,m,v,y,E,C;if(i=h(Ds(e.b,t),114),h(h(Qi(e.r,t),19),60).Wb()){i.n.d=0,i.n.a=0;return}i.n.d=e.A.d,i.n.a=e.A.a,l=e.v.pc((Wl(),C1)),E=h(h(Qi(e.r,t),19),60)._b()==2,m=e.t==(Jf(),Ty),y=e.w.pc((ac(),m3)),C=e.w.pc(Sj),a=0,!l||E&&m?a=Lte(e,t,!1,!1):m?C?(f=xFt(e,t,y),f>0&&T7(e,t,f,!1,!1),a=Lte(e,t,!0,!1)):(T7(e,t,0,!1,y),a=Lte(e,t,!0,!1)):C?(v=h(h(Qi(e.r,t),19),60)._b(),g=Q8t(e,t),a=g*v+e.u*(v-1),g>0&&T7(e,t,g,!0,!1)):(T7(e,t,0,!0,!1),a=Lte(e,t,!0,!0)),nne(e,t)==(Xg(),lb)&&(a+=2*e.u),i.a.b=a}function cr(){cr=M,nPe=(ype(),ga).b,uut=h(ae(ye(ga.b),0),29),iv=h(ae(ye(ga.b),1),29),lut=h(ae(ye(ga.b),2),29),TM=ga.bb,h(ae(ye(ga.bb),0),29),h(ae(ye(ga.bb),1),29),CM=ga.fb,ED=h(ae(ye(ga.fb),0),29),h(ae(ye(ga.fb),1),29),h(ae(ye(ga.fb),2),17),Iy=ga.qb,xut=h(ae(ye(ga.qb),0),29),h(ae(ye(ga.qb),1),17),h(ae(ye(ga.qb),2),17),Gj=h(ae(ye(ga.qb),3),29),jj=h(ae(ye(ga.qb),4),29),MD=h(ae(ye(ga.qb),6),29),SD=h(ae(ye(ga.qb),5),17),fut=ga.j,hut=ga.k,dut=ga.q,put=ga.w,gut=ga.B,mut=ga.A,but=ga.C,wut=ga.D,vut=ga._,_ut=ga.cb,yut=ga.hb}function hGt(e,t,i){var a,l,f,g,m,v,y,E,C,R,B;e.c=0,e.b=0,a=2*t.c.a.c.length+1;e:for(C=i.tc();C.hc();){if(E=h(C.ic(),11),m=E.i==(Fe(),bn)||E.i==ei,B=0,m){if(R=h(G(E,(Ie(),Al)),8),!R)continue;B+=vUt(e,a,E,R)}else{for(y=new j(E.f);y.a0?(e.f[E.o]=B/(E.d.c.length+E.f.c.length),e.c=w.Math.min(e.c,e.f[E.o]),e.b=w.Math.max(e.b,e.f[E.o])):m&&(e.f[E.o]=B)}}function dGt(e){e.b=null,e.bb=null,e.fb=null,e.qb=null,e.a=null,e.c=null,e.d=null,e.e=null,e.f=null,e.n=null,e.M=null,e.L=null,e.Q=null,e.R=null,e.K=null,e.db=null,e.eb=null,e.g=null,e.i=null,e.j=null,e.k=null,e.gb=null,e.o=null,e.p=null,e.q=null,e.r=null,e.$=null,e.ib=null,e.S=null,e.T=null,e.t=null,e.s=null,e.u=null,e.v=null,e.w=null,e.B=null,e.A=null,e.C=null,e.D=null,e.F=null,e.G=null,e.H=null,e.I=null,e.J=null,e.P=null,e.Z=null,e.U=null,e.V=null,e.W=null,e.X=null,e.Y=null,e._=null,e.ab=null,e.cb=null,e.hb=null,e.nb=null,e.lb=null,e.mb=null,e.ob=null,e.pb=null,e.jb=null,e.kb=null,e.N=!1,e.O=!1}function pGt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe;if(W=t.b.c.length,!(W<3)){for(B=le(Rn,ii,22,W,15,1),C=0,E=new j(t.b);E.ag)&&Cr(e.c,h(V.b,14));++m}f=g}}}function P_e(e){var t;switch(e.d){case 1:{if(e.wi())return e.o!=-2;break}case 2:{if(e.wi())return e.o==-2;break}case 3:case 5:case 4:case 6:case 7:return e.o>-2;default:return!1}switch(t=e.vi(),e.p){case 0:return t!=null&&ce(bt(t))!=kC(e.k,0);case 1:return t!=null&&h(t,192).a!=nr(e.k)<<24>>24;case 2:return t!=null&&h(t,159).a!=(nr(e.k)&Gr);case 6:return t!=null&&kC(h(t,149).a,e.k);case 5:return t!=null&&h(t,21).a!=nr(e.k);case 7:return t!=null&&h(t,168).a!=nr(e.k)<<16>>16;case 3:return t!=null&&ce(Xe(t))!=e.j;case 4:return t!=null&&h(t,126).a!=e.j;default:return t==null?e.n!=null:!Li(t,e.n)}}function Pne(e,t){var i,a,l,f;f=e.F,t==null?(e.F=null,Uee(e,null)):(e.F=(pn(t),t),a=_h(t,bc(60)),a!=-1?(l=t.substr(0,a),_h(t,bc(46))==-1&&!pt(l,GS)&&!pt(l,IP)&&!pt(l,yz)&&!pt(l,DP)&&!pt(l,BP)&&!pt(l,OP)&&!pt(l,NP)&&!pt(l,FP)&&(l=Btt),i=uJ(t,bc(62)),i!=-1&&(l+=""+t.substr(i+1,t.length-(i+1))),Uee(e,l)):(l=t,_h(t,bc(46))==-1&&(a=_h(t,bc(91)),a!=-1&&(l=t.substr(0,a)),!pt(l,GS)&&!pt(l,IP)&&!pt(l,yz)&&!pt(l,DP)&&!pt(l,BP)&&!pt(l,OP)&&!pt(l,NP)&&!pt(l,FP)?(l=Btt,a!=-1&&(l+=""+t.substr(a,t.length-a))):l=t),Uee(e,l),l==t&&(e.F=e.D))),e.Db&4&&!(e.Db&1)&&Pi(e,new cs(e,1,5,f,t))}function gGt(e){EA();var t,i,a,l,f,g,m;for(m=new l0,i=new j(e);i.a=m.b.c)&&(m.b=t),(!m.c||t.c<=m.c.c)&&(m.d=m.c,m.c=t),(!m.e||t.d>=m.e.d)&&(m.e=t),(!m.f||t.d<=m.f.d)&&(m.f=t);return a=new QU((_S(),J0)),SI(e,Xit,new Dl(X(q(x5,1),nt,341,0,[a]))),g=new QU(Bw),SI(e,qit,new Dl(X(q(x5,1),nt,341,0,[g]))),l=new QU(Dw),SI(e,Hit,new Dl(X(q(x5,1),nt,341,0,[l]))),f=new QU(fy),SI(e,Wit,new Dl(X(q(x5,1),nt,341,0,[f]))),ene(a.c,J0),ene(l.c,Dw),ene(f.c,fy),ene(g.c,Bw),m.a.c=le(sn,nt,1,0,5,1),Lr(m.a,a.c),Lr(m.a,k0(l.c)),Lr(m.a,f.c),Lr(m.a,k0(g.c)),m}function B6(e,t,i){var a,l,f,g;return e.Rj()&&e.Qj()&&(g=HJ(e,h(i,51)),Be(g)!==Be(i))?(e.ai(t),e.gi(t,jGe(e,t,g)),e.Dj()&&(f=(l=h(i,42),e.Pj()?e.Nj()?l.Cg(e.b,Fo(h(Vt(rc(e.b),e.pi()),17)).n,h(Vt(rc(e.b),e.pi()).jj(),24).Qi(),null):l.Cg(e.b,gr(l.mg(),Fo(h(Vt(rc(e.b),e.pi()),17))),null,null):l.Cg(e.b,-1-e.pi(),null,null)),!h(g,42).yg()&&(f=(a=h(g,42),e.Pj()?e.Nj()?a.Ag(e.b,Fo(h(Vt(rc(e.b),e.pi()),17)).n,h(Vt(rc(e.b),e.pi()).jj(),24).Qi(),f):a.Ag(e.b,gr(a.mg(),Fo(h(Vt(rc(e.b),e.pi()),17))),null,f):a.Ag(e.b,-1-e.pi(),null,f))),f&&f.Th()),ju(e.b)&&e.ni(e.mi(9,i,g,t,!1)),g):i}function MKe(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we;for(E=ce(Xe(G(e,($e(),S1)))),a=ce(Xe(G(e,eTe))),R=new Bk,Ee(R,S1,E+a),y=t,ee=t.d,W=t.c.g,ie=t.d.g,V=Gu(W.c),fe=Gu(ie.c),l=new Re,C=V;C<=fe;C++)m=new Qf(e),Bu(m,(qt(),Nr)),Ee(m,(Ie(),Jn),y),Ee(m,Yi,(Ms(),Ba)),Ee(m,zG,R),B=h(Tt(e.b,C),26),C==V?Yg(m,B.a.c.length-i,B):qs(m,B),we=ce(Xe(G(y,ep))),we<0&&(we=0,Ee(y,ep,we)),m.n.b=we,N=w.Math.floor(we/2),g=new yo,pr(g,(Fe(),tn)),ls(g,m),g.k.b=N,v=new yo,pr(v,Zt),ls(v,m),v.k.b=N,_s(y,g),f=new Bp,Oo(f,y),Ee(f,Po,null),Os(f,v),_s(f,ee),gBt(m,y,f),l.c[l.c.length]=f,y=f;return l}function mGt(e,t){var i,a,l,f,g,m,v,y,E,C;for(e.a=new rUe(GRt(yL)),a=new j(t.a);a.a0;){for(W=(oi(0,v.c.length),h(v.c[0],14)),l=(oi(0,B.c.length),h(B.c[0],14)),ie=l.d.d,f=Jo(ie,l,0),WLt(W,l.d,f),Os(l,null),_s(l,null),N=W.a,t&&Gi(N,new Io(fe)),a=On(l.a,0);a.b!=a.d.c;)i=h(Fn(a),9),Gi(N,new Io(i));for(ee=W.b,R=new j(l.b);R.a0?nee(this,this.f/this.a):Wf(t.g,t.d[0]).a!=null&&Wf(i.g,i.d[0]).a!=null?nee(this,(ce(Wf(t.g,t.d[0]).a)+ce(Wf(i.g,i.d[0]).a))/2):Wf(t.g,t.d[0]).a!=null?nee(this,Wf(t.g,t.d[0]).a):Wf(i.g,i.d[0]).a!=null&&nee(this,Wf(i.g,i.d[0]).a)}function L_e(e){var t;this.r=uPt(new pN,new $q),this.b=(Xr(),new GA(h(Hn(xc),274))),this.p=new GA(h(Hn(xc),274)),this.i=new GA(h(Hn(ylt),274)),this.e=e,this.o=new Io(e.Re()),this.B=e.bf()||ce(bt(e.xe((lr(),hj)))),this.v=h(e.xe((lr(),yM)),19),this.w=h(e.xe(gj),19),this.q=h(e.xe(nD),83),this.t=h(e.xe(uae),275),this.j=h(e.xe(pj),19),this.n=h(f6(e,_ct),119),this.k=ce(Xe(f6(e,bj))),this.d=ce(Xe(f6(e,XCe))),this.u=ce(Xe(f6(e,JCe))),this.s=ce(Xe(f6(e,YCe))),this.A=h(f6(e,ZCe),135),this.c=2*this.d,t=!this.w.pc((ac(),yj)),this.f=new HA(0,t,0),this.g=new HA(1,t,0),gK(this.f,(yf(),Va),this.g)}function CKe(e,t){var i,a,l,f,g,m,v,y,E,C,R,B;if(t==null||t.length==0)return null;if(f=h(Ua(e.f,t),27),!f){for(l=(R=new mh(e.d).a.Tb().tc(),new o0(R));l.a.hc();)if(i=(g=h(l.a.ic(),38),h(g.lc(),27)),m=i.f,B=t.length,pt(m.substr(m.length-B,B),t)&&(t.length==m.length||po(m,m.length-t.length-1)==46)){if(f)return null;f=i}if(!f){for(a=(C=new mh(e.d).a.Tb().tc(),new o0(C));a.a.hc();)if(i=(g=h(a.a.ic(),38),h(g.lc(),27)),E=i.g,E!=null){for(v=0,y=E.length;v=1&&(V-g>0&&C>=0?(v.k.a+=W,v.k.b+=f*g):V-g<0&&E>=0&&(v.k.a+=W*V,v.k.b+=f));e.n.a=t.a,e.n.b=t.b,Ee(e,($e(),zw),(Wl(),a=h(ml(AL),10),new Bc(a,h(Qc(a,a.length),10),0)))}function LKe(e,t){var i,a,l,f,g,m,v,y,E,C;for(v=!0,l=0,y=e.f[t.o],E=t.n.b+e.n,i=e.c[t.o][2],Wu(e.a,y,He(h(Tt(e.a,y),21).a-1+i)),Wu(e.b,y,ce(Xe(Tt(e.b,y)))-E+i*e.e),++y,y>=e.i?(++e.i,De(e.a,He(1)),De(e.b,E)):(a=e.c[t.o][1],Wu(e.a,y,He(h(Tt(e.a,y),21).a+1-a)),Wu(e.b,y,ce(Xe(Tt(e.b,y)))+E-a*e.e)),(e.q==(G_(),G5)&&(h(Tt(e.a,y),21).a>e.j||h(Tt(e.a,y-1),21).a>e.j)||e.q==j5&&(ce(Xe(Tt(e.b,y)))>e.k||ce(Xe(Tt(e.b,y-1)))>e.k))&&(v=!1),g=Tn(As(t));Gn(g);)f=h(Mn(g),14),m=f.c.g,e.f[m.o]==y&&(C=LKe(e,m),l=l+h(C.a,21).a,v=v&&ce(bt(C.b)));return e.f[t.o]=y,l=l+e.c[t.o][0],new Is(He(l),(vt(),!!v))}function vGt(e){var t,i,a,l,f,g,m,v,y,E;for(y=new Ir,m=new Ir,f=new j(e);f.a-1){for(l=On(m,0);l.b!=l.d.c;)a=h(Fn(l),125),a.s=g;for(;m.b!=0;)for(a=h(Ewe(m,0),125),i=new j(a.g);i.a-1){for(f=new j(m);f.a0)&&(v.i=f0(v.i,l.i-1),--v.f,v.f==0&&(m.c[m.c.length]=v))}}function RKe(e,t){var i,a,l,f,g,m,v,y;if(!(t.b==null||e.b==null)){for(U_(e),gP(e),U_(t),gP(t),i=le(Rn,ii,22,e.b.length+t.b.length,15,1),y=0,a=0,g=0;a=m&&l<=v)m<=l&&f<=v?(i[y++]=l,i[y++]=f,a+=2):m<=l?(i[y++]=l,i[y++]=v,e.b[a]=v+1,g+=2):f<=v?(i[y++]=m,i[y++]=f,a+=2):(i[y++]=m,i[y++]=v,e.b[a]=v+1);else if(ve.j&&(e.q=G5,FS(e,f));break;case 4:for(e.q=(G_(),VG),FS(e,f),y=0,l=new j(e.b);l.ae.k&&(e.q=j5,FS(e,f));break;case 6:R=wr(w.Math.ceil(e.f.length*E/100)),FS(e,new UF(R));break;case 5:C=wr(w.Math.ceil(e.d*E/100)),FS(e,new ME(C));break;default:FS(e,f)}H9t(e,t),Bn(i)}function SGt(e){var t,i,a,l,f,g,m;for(t=new Re,e.g=new Re,e.d=new Re,g=new Zm(new xp(e.f.b).a);g.b;)f=P0(g),De(t,h(h(f.lc(),48).b,80)),n_(h(f.kc(),536).Je())?De(e.d,h(f.lc(),48)):De(e.g,h(f.lc(),48));for(ete(e,e.d),ete(e,e.g),e.c=new DXe(e.b),gEt(e.c,(Lpe(),zit)),Zee(e,e.d),Zee(e,e.g),Lr(t,e.c.a.b),e.e=new $t(Kr,Kr),e.a=new $t(Ts,Ts),a=new j(t);a.atm)&&m<10);xpe(e.c,new bk),IKe(e),MAt(e.c),bGt(e.f)}function IKe(e){var t,i,a,l,f,g,m;for(t=0,f=new j(e.b.a);f.a=2){for(v=On(i,0),g=h(Fn(v),9),m=h(Fn(v),9);m.a0&&(m=w.Math.max(m,D$e(e.A.b+a.d.b,l))),C=a,R=l,B=f;e.A&&e.A.c>0&&(N=B+e.A.c,E&&(N+=C.d.c),m=w.Math.max(m,(yh(),Ng(pd),w.Math.abs(R-1)<=pd||R==1||isNaN(R)&&isNaN(1)?0:N/(1-R)))),i.n.b=0,i.a.a=m}function BKe(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W;if(i=h(Ds(e.b,t),114),y=h(h(Qi(e.r,t),19),60),y.Wb()){i.n.d=0,i.n.a=0;return}for(g=e.v.pc((Wl(),C1)),W=e.w.pc((ac(),m3)),E=e.t==(Jf(),fb),m=0,v=y.tc(),C=null,B=0,R=0;v.hc();)a=h(v.ic(),111),f=ce(Xe(a.b.xe((t9(),Tj)))),l=a.b.Re().b,g&&T7(e,t,0,E,!E&&W),C?(N=R+C.d.a+e.u+a.d.d,m=w.Math.max(m,(yh(),Ng(pd),w.Math.abs(B-f)<=pd||B==f||isNaN(B)&&isNaN(f)?0:N/(f-B)))):e.A&&e.A.d>0&&(m=w.Math.max(m,D$e(e.A.d+a.d.d,f))),C=a,B=f,R=l;e.A&&e.A.a>0&&(N=R+e.A.a,E&&(N+=C.d.a),m=w.Math.max(m,(yh(),Ng(pd),w.Math.abs(B-1)<=pd||B==1||isNaN(B)&&isNaN(1)?0:N/(1-B)))),i.n.d=0,i.a.b=m}function PGt(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae,Ue;return R=e.c[t],B=e.c[i],N=h(G(R,(Ie(),Qx)),15),!!N&&N._b()!=0&&N.pc(B)||(W=R.j!=(qt(),Nr)&&B.j!=Nr,V=h(G(R,dM),8),ee=h(G(B,dM),8),ie=V!=ee,fe=!!V&&V!=R||!!ee&&ee!=B,we=_te(R,(Fe(),bn)),Ae=_te(B,ei),fe=fe|(_te(R,ei)||_te(B,bn)),Ue=fe&&ie||we||Ae,W&&Ue)||R.j==(qt(),sa)&&B.j==fs||B.j==(qt(),sa)&&R.j==fs?!1:(E=e.c[t],f=e.c[i],l=KHe(e.e,E,f,(Fe(),tn)),v=KHe(e.i,E,f,Zt),a9t(e.f,E,f),y=IVe(e.b,E,f)+h(l.a,21).a+h(v.a,21).a+e.f.d,m=IVe(e.b,f,E)+h(l.b,21).a+h(v.b,21).a+e.f.b,e.a&&(C=h(G(E,Jn),11),g=h(G(f,Jn),11),a=zHe(e.g,C,g),y+=h(a.a,21).a,m+=h(a.b,21).a),y>m)}function OKe(e,t,i){var a,l,f,g,m,v,y,E,C;if(e.a!=t.Pi())throw Y(new un(QS+t.be()+q0));if(a=Gp((Hc(),Ks),t).kk(),a)return a.Pi().dh().Zg(a,i);if(g=Gp(Ks,t).mk(),g){if(i==null)return null;if(m=h(i,15),m.Wb())return"";for(C=new Mp,f=m.tc();f.hc();)l=f.ic(),ho(C,g.Pi().dh().Zg(g,l)),C.a+=" ";return E8(C,C.a.length-1)}if(E=Gp(Ks,t).nk(),!E.Wb()){for(y=E.tc();y.hc();)if(v=h(y.ic(),140),v.Li(i))try{if(C=v.Pi().dh().Zg(v,i),C!=null)return C}catch(R){if(R=hr(R),!re(R,104))throw Y(R)}throw Y(new un("Invalid value: '"+i+"' for datatype :"+t.be()))}return h(t,737).Ui(),i==null?null:re(i,159)?""+h(i,159).a:rl(i)==zz?sFe(RL[0],h(i,181)):za(i)}function LGt(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V;for(ni(i,xQe,1),ert=ce(bt(G(t,($e(),tL)))),e.c=t,N=new Re,m=new j(t.b);m.aV){for(W=1,l=y.n.a;l>v;)++W,l=(y.n.a-(W-1)*e.d)/W;De(a,new o7e(e,y,W))}for(E=new j(a);E.ay?0:y),1),g),e.c[a.a.d])),Ku(Uu(Fu(zu(Nu(new nu,0>-y?0:-y),1),g),e.c[m.a.d]))):(R=1,(re(a.g,153)&&re(m.g,8)||re(m.g,153)&&re(a.g,8))&&(R=2),Ku(Uu(Fu(zu(Nu(new nu,wr(f)),R),e.c[a.a.d]),e.c[m.a.d]))))}function RGt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W;for(i=h(G(e,($e(),Yi)),83),g=e.e,f=e.d,m=g.a+f.b+f.c,v=0-f.d-e.c.b,E=g.b+f.d+f.a-e.c.b,y=new Re,C=new Re,l=new j(t);l.a0),h(E.a.cd(E.c=--E.b),14));f!=a&&E.b>0;)e.a[f.o]=!0,e.a[a.o]=!0,f=(kn(E.b>0),h(E.a.cd(E.c=--E.b),14));E.b>0&&_f(E)}}function DGt(e){e.q||(e.q=!0,e.p=ia(e,0),e.a=ia(e,1),Ki(e.a,0),e.f=ia(e,2),Ki(e.f,1),vr(e.f,2),e.n=ia(e,3),vr(e.n,3),vr(e.n,4),vr(e.n,5),vr(e.n,6),e.g=ia(e,4),Ki(e.g,7),vr(e.g,8),e.c=ia(e,5),Ki(e.c,7),Ki(e.c,8),e.i=ia(e,6),Ki(e.i,9),Ki(e.i,10),Ki(e.i,11),Ki(e.i,12),vr(e.i,13),e.j=ia(e,7),Ki(e.j,9),e.d=ia(e,8),Ki(e.d,3),Ki(e.d,4),Ki(e.d,5),Ki(e.d,6),vr(e.d,7),vr(e.d,8),vr(e.d,9),vr(e.d,10),e.b=ia(e,9),vr(e.b,0),vr(e.b,1),e.e=ia(e,10),vr(e.e,1),vr(e.e,2),vr(e.e,3),vr(e.e,4),Ki(e.e,5),Ki(e.e,6),Ki(e.e,7),Ki(e.e,8),Ki(e.e,9),Ki(e.e,10),vr(e.e,11),e.k=ia(e,11),vr(e.k,0),vr(e.k,1),e.o=fi(e,12),e.s=fi(e,13))}function BGt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee;for(ni(t,"Interactive crossing minimization",1),g=0,f=new j(e.b);f.a0&&(i+=v.k.a+v.n.a/2,++C),N=new j(v.i);N.a=m&&l<=v)m<=l&&f<=v?a+=2:m<=l?(e.b[a]=v+1,g+=2):f<=v?(i[y++]=l,i[y++]=m-1,a+=2):(i[y++]=l,i[y++]=m-1,e.b[a]=v+1,g+=2);else if(v0),g.a.cd(g.c=--g.b),ed(g,a),JE(y,a),w7(a,v.i),cS(y),cS(y),l.a.$b(a)!=null}}function FGt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V;for(ni(t,"Spline SelfLoop pre-processing.",1),y=new zc,C=new j(e.a);C.a0?l-=864e5:l+=864e5,v=new Wge(io(Vc(t.q.getTime()),l))),E=new Qb,y=e.a.length,f=0;f=97&&a<=122||a>=65&&a<=90){for(g=f+1;g=y)throw Y(new un("Missing trailing '"));g+1=14&&y<=16))?t.a.Qb(a)?(i.a?Si(i.a,i.b):i.a=new su(i.d),Y2(i.a,"[...]")):(g=__(a),v=new hI(t),Xm(i,FKe(g,v))):re(a,221)?Xm(i,xNt(h(a,221))):re(a,173)?Xm(i,bNt(h(a,173))):re(a,176)?Xm(i,POt(h(a,176))):re(a,1697)?Xm(i,yNt(h(a,1697))):re(a,37)?Xm(i,_Nt(h(a,37))):re(a,378)?Xm(i,PNt(h(a,378))):re(a,736)?Xm(i,vNt(h(a,736))):re(a,106)&&Xm(i,wNt(h(a,106))):Xm(i,a==null?qc:za(a));return i.a?i.e.length==0?i.a.a:i.a.a+(""+i.e):i.c}function GGt(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W;if(ce(bt(G(i,($e(),by)))))for(m=new j(i.i);m.a1))););(m>0||R==(Jf(),fb)&&(!f.n&&(f.n=new ze(Qo,f,1,7)),f.n).i>0)&&(v=!0),m>1&&(y=!0)}v&&t.nc((xo(),Eu)),y&&t.nc((xo(),KP))}function UKe(e,t,i){var a,l,f;return l=new L_e(e),Z8t(l,i),gZe(l,!1),ad(l.e.We(),new hge(l,!1)),yQ(l,l.f,(yf(),oa),(Fe(),bn)),yQ(l,l.f,aa,ei),yQ(l,l.g,oa,tn),yQ(l,l.g,aa,Zt),gWe(l,bn),gWe(l,ei),J9e(l,Zt),J9e(l,tn),Gm(),a=l.v.pc((Wl(),db))&&l.w.pc((ac(),PL))?iwe(l):null,a&&CEt(l.a,a),tUt(l),IDt(l),DDt(l),$Gt(l),LUt(l),rBt(l),lte(l,bn),lte(l,ei),AUt(l),dzt(l),t&&(j6t(l),sBt(l),lte(l,Zt),lte(l,tn),f=l.w.pc((ac(),LL)),dXe(l,f,bn),dXe(l,f,ei),pXe(l,f,Zt),pXe(l,f,tn),Na(new si(null,new pi(new mh(l.i),0)),new Wq),Na(go(new si(null,b1e(l.r).wc()),new gN),new mN),oOt(l),l.e.Ue(l.o),Na(new si(null,b1e(l.r).wc()),new dE)),l.o}function HGt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N;for(ni(t,"Spline SelfLoop positioning",1),E=h(G(e,($e(),kMe)),345),y=new j(e.b);y.a2?(E=new Re,Lr(E,new Rg(ee,1,ee.b)),f=pJe(E,fe+e.a),ie=new Zte(f),Oo(ie,t),i.c[i.c.length]=ie):a?ie=h(Ii(e.b,s1(t)),247):ie=h(Ii(e.b,F0(t)),247),v=s1(t),a&&(v=F0(t)),g=UOt(V,v),y=fe+e.a,g.a?(y+=w.Math.abs(V.b-C.b),W=new $t(C.a,(C.b+V.b)/2)):(y+=w.Math.abs(V.a-C.a),W=new $t((C.a+V.a)/2,C.b)),a?fr(e.d,t,new _we(ie,g,W,y)):fr(e.c,t,new _we(ie,g,W,y)),fr(e.b,t,ie),N=(!t.n&&(t.n=new ze(Qo,t,1,7)),t.n),B=new Dn(N);B.e!=B.i._b();)R=h(Xn(B),137),l=C6(e,R,!0,0,0),i.c[i.c.length]=l}function XGt(){ai(Ly,new cX),ai(ki,new IN),ai(Pu,new NN),ai(ah,new UN),ai(Rae,new gX),ai(Oj,new zN),ai(Qp,new GN),ai(kL,new qh),ai(mD,new $k),ai(Tae,new PN),ai(Kw,new Vk),ai(lf,new sX),ai(oh,new Wk),ai(ev,new ro),ai(tv,new oX),ai(Ec,new aX),ai(Qw,new wE),ai(Ca,new LN),ai(Lo,new lX),ai(ul,new yp),ai(lo,new uX),ai(q(Sc,1),new QT),ai(Hx,new Hk),ai($P,new kN),ai(zz,new RN),ai(dPe,new Pd),ai(Eo,new Hb),ai(AAe,new qk),ai(kAe,new eC),ai(ePe,new DN),ai(Nj,new Xk),ai(oM,new BN),ai(Ao,new Yk),ai(Kxe,new Zk),ai(Z0,new qb),ai(Jxe,new fX),ai(ZAe,new Xb),ai(pPe,new ON),ai(K0,new Kk),ai(Se,new hX),ai(LAe,new dX),ai(gPe,new pX)}function YGt(e){var t,i,a,l,f,g,m,v;for(t=null,a=new j(e);a.a0&&i.c==0&&(!t&&(t=new Re),t.c[t.c.length]=i);if(t)for(;t.c.length!=0;){if(i=h(A0(t,0),205),i.b&&i.b.c.length>0){for(f=(!i.b&&(i.b=new Re),new j(i.b));f.aJo(e,i,0))return new Is(l,i)}else if(ce(Wf(l.g,l.d[0]).a)>ce(Wf(i.g,i.d[0]).a))return new Is(l,i)}for(m=(!i.e&&(i.e=new Re),i.e).tc();m.hc();)g=h(m.ic(),205),v=(!g.b&&(g.b=new Re),g.b),g_(0,v.c.length),UR(v.c,0,i),g.c==v.c.length&&(t.c[t.c.length]=g)}return null}function ZGt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W;for(ni(t,"Label dummy insertions",1),C=new Re,g=ce(Xe(G(e,($e(),N5)))),y=ce(Xe(G(e,a3))),E=h(G(e,tf),110),B=new j(e.a);B.a>16==-10?i=h(e.Cb,268).zj(t,i):e.Db>>16==-15&&(!t&&(t=(Et(),Uh)),!y&&(y=(Et(),Uh)),e.Cb.Hg()&&(v=new Vd(e.Cb,1,13,y,t,jp($c(h(e.Cb,53)),e),!1),i?i.Sh(v):i=v));else if(re(e.Cb,96))e.Db>>16==-23&&(re(t,96)||(t=(Et(),uf)),re(y,96)||(y=(Et(),uf)),e.Cb.Hg()&&(v=new Vd(e.Cb,1,10,y,t,jp(xa(h(e.Cb,24)),e),!1),i?i.Sh(v):i=v));else if(re(e.Cb,411))for(m=h(e.Cb,742),g=(!m.b&&(m.b=new bC(new lK)),m.b),f=(a=new Zm(new xp(g.a).a),new wC(a));f.a.b;)l=h(P0(f.a).kc(),84),i=zS(l,x7(l,m),i)}return i}function JGt(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V;for(ni(i,"Depth-first cycle removal",1),E=t.a,W=E.c.length,e.a=le(Rn,ii,22,W,15,1),WDe(e.a),e.b=le(Rn,ii,22,W,15,1),WDe(e.b),g=0,y=new j(E);y.a=0){for(v=null,m=new Ns(E.a,y+1);m.b=y.c.c.length?E=r0e((qt(),fs),Nr):E=r0e((qt(),Nr),Nr),E*=2,f=i.a.g,i.a.g=w.Math.max(f,f+(E-f)),g=i.b.g,i.b.g=w.Math.max(g,g+(E-g)),l=t}}function WKe(e,t){var i,a,l,f,g,m,v,y,E;for(g=h(h(Qi(e.r,t),19),60),E=g._b()==2||g._b()>2&&e.w.pc((ac(),m3)),f=g.tc();f.hc();)if(l=h(f.ic(),111),!(!l.c||l.c.d.c.length<=0)){switch(y=l.b.Re(),m=l.c,v=m.i,v.b=(a=m.n,m.e.a+a.b+a.c),v.a=(i=m.n,m.e.b+i.d+i.a),t.g){case 1:E?(v.c=-v.b-e.s,Sh(m,(il(),af))):(v.c=y.a+e.s,Sh(m,(il(),Fh))),v.d=-v.a-e.s,Fd(m,(Oc(),cf));break;case 3:E?(v.c=-v.b-e.s,Sh(m,(il(),af))):(v.c=y.a+e.s,Sh(m,(il(),Fh))),v.d=y.b+e.s,Fd(m,(Oc(),Rf));break;case 2:v.c=y.a+e.s,E?(v.d=-v.a-e.s,Fd(m,(Oc(),cf))):(v.d=y.b+e.s,Fd(m,(Oc(),Rf))),Sh(m,(il(),Fh));break;case 4:v.c=-v.b-e.s,E?(v.d=-v.a-e.s,Fd(m,(Oc(),cf))):(v.d=y.b+e.s,Fd(m,(Oc(),Rf))),Sh(m,(il(),af))}E=!1}}function N7(e,t){var i;if(e.e)throw Y(new ma((Nd(ise),mie+ise.k+bie)));if(!ZEt(e.a,t))throw Y(new ta(XJe+t+YJe));if(t==e.d)return e;switch(i=e.d,e.d=t,i.g){case 0:switch(t.g){case 2:N0(e);break;case 1:$g(e),N0(e);break;case 4:I_(e),N0(e);break;case 3:I_(e),$g(e),N0(e)}break;case 2:switch(t.g){case 1:$g(e),cne(e);break;case 4:I_(e),N0(e);break;case 3:I_(e),$g(e),N0(e)}break;case 1:switch(t.g){case 2:$g(e),cne(e);break;case 4:$g(e),I_(e),N0(e);break;case 3:$g(e),I_(e),$g(e),N0(e)}break;case 4:switch(t.g){case 2:I_(e),N0(e);break;case 1:I_(e),$g(e),N0(e);break;case 3:$g(e),cne(e)}break;case 3:switch(t.g){case 2:$g(e),I_(e),N0(e);break;case 1:$g(e),I_(e),$g(e),N0(e);break;case 4:$g(e),cne(e)}}return e}function W_(e,t){var i;if(e.d)throw Y(new ma((Nd(yse),mie+yse.k+bie)));if(!YEt(e.a,t))throw Y(new ta(XJe+t+YJe));if(t==e.c)return e;switch(i=e.c,e.c=t,i.g){case 0:switch(t.g){case 2:Km(e);break;case 1:Vg(e),Km(e);break;case 4:D_(e),Km(e);break;case 3:D_(e),Vg(e),Km(e)}break;case 2:switch(t.g){case 1:Vg(e),lne(e);break;case 4:D_(e),Km(e);break;case 3:D_(e),Vg(e),Km(e)}break;case 1:switch(t.g){case 2:Vg(e),lne(e);break;case 4:Vg(e),D_(e),Km(e);break;case 3:Vg(e),D_(e),Vg(e),Km(e)}break;case 4:switch(t.g){case 2:D_(e),Km(e);break;case 1:D_(e),Vg(e),Km(e);break;case 3:Vg(e),lne(e)}break;case 3:switch(t.g){case 2:Vg(e),D_(e),Km(e);break;case 1:Vg(e),D_(e),Vg(e),Km(e);break;case 4:Vg(e),lne(e)}}return e}function HKe(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee;for(l=new Re,N=new j(t.a);N.aee?v:ee,fe=new j(E.i);fe.a=y&&Ae>=V&&(R+=N.k.b+W.k.b+W.a.b-we,++m));if(i)for(g=new j(ie.d);g.a=y&&Ae>=V&&(R+=N.k.b+W.k.b+W.a.b-we,++m))}m>0&&(Ue+=R/m,++B)}B>0?(t.a=l*Ue/B,t.i=B):(t.a=0,t.i=0)}function ljt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae,Ue,qe;for(e.e=t,m=jFt(t),Ue=new Re,a=new j(m);a.a0&&(C.d+=y.n.d,C.d+=y.d),C.a>0&&(C.a+=y.n.a,C.a+=y.d),C.b>0&&(C.b+=y.n.b,C.b+=y.d),C.c>0&&(C.c+=y.n.c,C.c+=y.d),C}function gjt(e,t,i){var a;if(ni(i,"StretchWidth layering",1),t.a.c.length==0){Bn(i);return}for(e.c=t,e.t=0,e.u=0,e.i=Kr,e.g=Ts,e.d=ce(Xe(G(t,($e(),ih)))),aDt(e),EFt(e),NOt(e),kBt(e),i5t(e),e.i=w.Math.max(1,e.i),e.g=w.Math.max(1,e.g),e.d=e.d/e.i,e.f=e.g/e.i,e.s=v6t(e),a=new cu(e.c),De(e.c.b,a),e.r=sd(e.p),e.n=$9(e.k,e.k.length);e.r.c.length!=0;)e.o=FIt(e),!e.o||yVe(e)&&e.b.a._b()!=0?(xDt(e,a),a=new cu(e.c),De(e.c.b,a),wo(e.a,e.b),e.b.a.Pb(),e.t=e.u,e.u=0):yVe(e)?(e.c.b.c=le(sn,nt,1,0,5,1),a=new cu(e.c),De(e.c.b,a),e.t=0,e.u=0,e.b.a.Pb(),e.a.a.Pb(),++e.f,e.r=sd(e.p),e.n=$9(e.k,e.k.length)):(qs(e.o,a),Ea(e.r,e.o),Cr(e.b,e.o),e.t=e.t-e.k[e.o.o]*e.d+e.j[e.o.o],e.u+=e.e[e.o.o]*e.d);t.a.c=le(sn,nt,1,0,5,1),iP(t.b),Bn(i)}function XKe(e){var t,i,a,l,f,g,m,v,y,E,C,R,B,N,W,V;for(N=new j(e);N.a0&&(e.a[t.c.o][t.o].d+=ol(e.f,24)*W6*.07000000029802322-.03500000014901161,e.a[t.c.o][t.o].a=e.a[t.c.o][t.o].d/e.a[t.c.o][t.o].b)}}function mjt(e,t,i,a,l){var f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae,Ue,qe,ut,ft,Ct,Mt,Ln;Ct=Ii(e.e,a),Ct==null&&(Ct=new SC,B=h(Ct,191),ie=t+"_s",fe=ie+l,R=new ix(fe),Og(B,kh,R)),ft=h(Ct,191),sx(i,ft),Ln=new SC,$m(Ln,"x",a.j),$m(Ln,"y",a.k),Og(ft,jet,Ln),qe=new SC,$m(qe,"x",a.b),$m(qe,"y",a.c),Og(ft,"endPoint",qe),C=x8((!a.a&&(a.a=new vs(sh,a,5)),a.a)),N=!C,N&&(Ue=new Om,f=new OZ(Ue),mo((!a.a&&(a.a=new vs(sh,a,5)),a.a),f),Og(ft,Sre,Ue)),v=gte(a),we=!!v,we&&Qwe(e.a,ft,xxe,zte(e,gte(a))),ee=mte(a),Ae=!!ee,Ae&&Qwe(e.a,ft,yxe,zte(e,mte(a))),y=(!a.e&&(a.e=new an(es,a,10,9)),a.e).i==0,W=!y,W&&(ut=new Om,g=new oNe(e,ut),mo((!a.e&&(a.e=new an(es,a,10,9)),a.e),g),Og(ft,Sxe,ut)),E=(!a.g&&(a.g=new an(es,a,9,10)),a.g).i==0,V=!E,V&&(Mt=new Om,m=new aNe(e,Mt),mo((!a.g&&(a.g=new an(es,a,9,10)),a.g),m),Og(ft,Exe,Mt))}function F7(e){var t,i,a,l,f,g,m,v,y,E,C;if(e==null)throw Y(new wh(qc));if(y=e,f=e.length,v=!1,f>0&&(t=e.charCodeAt(0),(t==45||t==43)&&(e=e.substr(1,e.length-1),--f,v=t==45)),f==0)throw Y(new wh($0+y+'"'));for(;e.length>0&&e.charCodeAt(0)==48;)e=e.substr(1,e.length-1),--f;if(f>(GZe(),Fnt)[10])throw Y(new wh($0+y+'"'));for(l=0;l0&&(C=-qNe(e.substr(0,a),10),e=e.substr(a,e.length-a),f-=a,i=!1);f>=g;){if(a=qNe(e.substr(0,g),10),e=e.substr(g,e.length-g),f-=g,i)i=!1;else{if(Sa(C,m)<0)throw Y(new wh($0+y+'"'));C=Jm(C,E)}C=Qm(C,a)}if(Sa(C,0)>0)throw Y(new wh($0+y+'"'));if(!v&&(C=dS(C),Sa(C,0)<0))throw Y(new wh($0+y+'"'));return C}function bjt(e,t,i,a,l){var f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae,Ue,qe,ut,ft,Ct;for(fe=0,N=0,B=0,R=1,ie=new Dn((!e.a&&(e.a=new ze(Br,e,10,11)),e.a));ie.e!=ie.i._b();)V=h(Xn(ie),35),R+=Dp(Mh(V)),ut=V.g,N=w.Math.max(N,ut),C=V.f,B=w.Math.max(B,C),fe+=ut*C;for(W=(!e.a&&(e.a=new ze(Br,e,10,11)),e.a).i,g=fe+2*a*a*R*W,f=w.Math.sqrt(g),v=w.Math.max(f*i,N),m=w.Math.max(f/i,B),ee=new Dn((!e.a&&(e.a=new ze(Br,e,10,11)),e.a));ee.e!=ee.i._b();)V=h(Xn(ee),35),ft=l.b+(ol(t,26)*bP+ol(t,27)*wP)*(v-V.g),Ct=l.b+(ol(t,26)*bP+ol(t,27)*wP)*(m-V.f),Xu(V,ft),Yu(V,Ct);for(qe=v+(l.b+l.c),Ue=m+(l.d+l.a),Ae=new Dn((!e.a&&(e.a=new ze(Br,e,10,11)),e.a));Ae.e!=Ae.i._b();)for(we=h(Xn(Ae),35),E=Tn(Mh(we));Gn(E);)y=h(Mn(E),105),rP(y)||I$t(y,t,qe,Ue);qe+=l.b+l.c,Ue+=l.d+l.a,H_(e,qe,Ue,!1,!0)}function wjt(e,t,i,a){var l,f,g,m,v,y,E,C,R,B,N,W,V,ee;if(W=e.k,V=e.n,R=e.d,t){for(C=a/2*(t._b()-1),B=0,y=t.tc();y.hc();)m=h(y.ic(),8),C+=m.n.a,B=w.Math.max(B,m.n.b);for(ee=W.a-(C-V.a)/2,g=W.b-R.d+B,l=V.a/(t._b()+1),f=l,v=t.tc();v.hc();)m=h(v.ic(),8),m.k.a=ee,m.k.b=g-m.n.b,ee+=m.n.a+a/2,E=_Ye(m),E.k.a=m.n.a/2-E.a.a,E.k.b=m.n.b,N=h(G(m,(Ie(),SG)),11),N.d.c.length+N.f.c.length==1&&(N.k.a=f-N.a.a,N.k.b=0,ls(N,e)),f+=l}if(i){for(C=a/2*(i._b()-1),B=0,y=i.tc();y.hc();)m=h(y.ic(),8),C+=m.n.a,B=w.Math.max(B,m.n.b);for(ee=W.a-(C-V.a)/2,g=W.b+V.b+R.a-B,l=V.a/(i._b()+1),f=l,v=i.tc();v.hc();)m=h(v.ic(),8),m.k.a=ee,m.k.b=g,ee+=m.n.a+a/2,E=_Ye(m),E.k.a=m.n.a/2-E.a.a,E.k.b=0,N=h(G(m,(Ie(),SG)),11),N.d.c.length+N.f.c.length==1&&(N.k.a=f-N.a.a,N.k.b=V.b,ls(N,e)),f+=l}}function vjt(e,t){var i,a,l,f,g,m,v,y,E,C,R;for(l=new j(e.a.b);l.aTs||t.o==M1&&E0&&Xu(ee,we*Ue),Ae>0&&Yu(ee,Ae*qe);for(vee(e.b,new Js),t=new Re,m=new Zm(new xp(e.c).a);m.b;)g=P0(m),a=h(g.kc(),105),i=h(g.lc(),363).a,l=j_(a,!1,!1),C=mqe(s1(a),m6(l),i),R6(C,l),fe=Eqe(a),fe&&Jo(t,fe,0)==-1&&(t.c[t.c.length]=fe,yUe(fe,(kn(C.b!=0),h(C.a.a.c,9)),i));for(V=new Zm(new xp(e.d).a);V.b;)W=P0(V),a=h(W.kc(),105),i=h(W.lc(),363).a,l=j_(a,!1,!1),C=mqe(F0(a),BA(m6(l)),i),C=BA(C),R6(C,l),fe=Sqe(a),fe&&Jo(t,fe,0)==-1&&(t.c[t.c.length]=fe,yUe(fe,(kn(C.b!=0),h(C.c.b.c,9)),i))}function Sjt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie;for(ni(t,"Inverted port preprocessing",1),y=e.b,v=new Ns(y,0),i=null,ie=new Re;v.b0&&(h(Ds(e.b,t),114).a.b=i)}function Mjt(e,t,i,a,l){var f,g,m,v,y,E,C,R,B,N,W,V,ee;switch(R=OA(e.i),N=OA(t.i),B=tr(Fa(e.k),e.a),W=tr(Fa(t.k),t.a),v=tr(new $t(B.a,B.b),ou(new d_(R),1.3*i)),V=tr(new $t(W.a,W.b),ou(new d_(N),1.3*a)),m=w.Math.abs(v.a-V.a),ml+2&&yee(e.charCodeAt(l+1),IAe,DAe)&&yee(e.charCodeAt(l+2),IAe,DAe))if(i=FCt(e.charCodeAt(l+1),e.charCodeAt(l+2)),l+=2,a>0?(i&192)==128?t[m++]=i<<24>>24:a=0:i>=128&&((i&224)==192?(t[m++]=i<<24>>24,a=2):(i&240)==224?(t[m++]=i<<24>>24,a=3):(i&248)==240&&(t[m++]=i<<24>>24,a=4)),a>0){if(m==a){switch(m){case 2:{Lg(v,((t[0]&31)<<6|t[1]&63)&Gr);break}case 3:{Lg(v,((t[0]&15)<<12|(t[1]&63)<<6|t[2]&63)&Gr);break}}m=0,a=0}}else{for(f=0;f0&&De(e.p,E),De(e.o,E);t-=a,B=v+t,y+=t*e.e,Wu(e.a,m,He(B)),Wu(e.b,m,y),e.j=bf(e.j,B),e.k=w.Math.max(e.k,y),e.d+=t,t+=W}}function KKe(){KKe=M;var e,t,i;for(new kI(1,0),new kI(10,0),new kI(0,0),Unt=le(Qre,be,216,11,0,1),_1=le(Yl,Ah,22,100,15,1),_3e=X(q(ks,1),Vo,22,15,[1,5,25,125,625,3125,15625,78125,390625,1953125,9765625,48828125,244140625,1220703125,6103515625,30517578125,152587890625,762939453125,3814697265625,19073486328125,95367431640625,476837158203125,0x878678326eac9]),y3e=le(Rn,ii,22,_3e.length,15,1),x3e=X(q(ks,1),Vo,22,15,[1,10,100,Cw,V6,uie,1e6,1e7,1e8,W7,1e10,1e11,1e12,1e13,1e14,1e15,1e16]),E3e=le(Rn,ii,22,x3e.length,15,1),S3e=le(Qre,be,216,11,0,1),e=0;e1)for(B=new y_e(N,fe,a),mo(fe,new KOe(e,B)),g.c[g.c.length]=B,C=fe.a.Xb().tc();C.hc();)E=h(C.ic(),48),Ea(f,E.b);if(m.a._b()>1)for(B=new y_e(N,m,a),mo(m,new JOe(e,B)),g.c[g.c.length]=B,C=m.a.Xb().tc();C.hc();)E=h(C.ic(),48),Ea(f,E.b)}}function Ajt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N;for(ni(t,"Label dummy switching",1),C=h(G(e,($e(),DG)),276),a=h(rd(go(Kf(new si(null,new pi(e.b,16)),new GO),new jO),zA(new gn,new jt,new Tr,X(q(th,1),Oe,150,0,[(Wg(),eh)]))),15),g=C==(JA(),zse)||C==Nse?TDt(e):null,f=a.tc();f.hc();){switch(l=h(f.ic(),8),i=Q5t(l),!i&&(i=C),m=yDt(l),E=H5t(l),R=null,i.g){case 2:R=iNt(l,g,m,E);break;case 0:R=(B=m.a._b()+E.c.length+1,N=(B-1)/2|0,Nm.a._b()?h(Tt(E,N-m.a._b()-1),8):null);break;case 1:R=vFt(l,g,m,E);break;case 4:yWe(l,i),R=(y=Zbe(l),y?m.a._b()==0?null:h(m.a.cd(uA(m,0)),8):E.c.length==0?null:h(Tt(E,E.c.length-1),8));break;case 3:yWe(l,i),R=(v=Zbe(l),v?E.c.length==0?null:h(Tt(E,E.c.length-1),8):m.a._b()==0?null:h(m.a.cd(uA(m,0)),8))}R&&Qzt(l,R),C5t(l)}Bn(t)}function D_e(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe;if(R=t.length,R>0&&(v=t.charCodeAt(0),v!=64)){if(v==37&&(C=t.lastIndexOf("%"),y=!1,C!=0&&(C==R-1||(y=t.charCodeAt(C+1)==46)))){if(g=t.substr(1,C-1),fe=pt("%",g)?null:I_e(g),a=0,y)try{a=El(t.substr(C+2,t.length-(C+2)),zs,zi)}catch(we){throw we=hr(we),re(we,118)?(m=we,Y(new hU(m))):Y(we)}for(V=sbe(e.pg());V.hc();)if(N=MU(V),re(N,469)&&(l=h(N,609),ie=l.d,(fe==null?ie==null:pt(fe,ie))&&a--==0))return l;return null}if(E=t.lastIndexOf("."),B=E==-1?t:t.substr(0,E),i=0,E!=-1)try{i=El(t.substr(E+1,t.length-(E+1)),zs,zi)}catch(we){if(we=hr(we),re(we,118))B=t;else throw Y(we)}for(B=pt("%",B)?null:I_e(B),W=sbe(e.pg());W.hc();)if(N=MU(W),re(N,174)&&(f=h(N,174),ee=f.be(),(B==null?ee==null:pt(B,ee))&&i--==0))return f;return null}return wKe(e,t)}function Pjt(e){w_e();var t,i,a,l,f,g,m,v,y,E,C,R,B,N,W,V;if(e==null)return null;if(C=e.length*8,C==0)return"";for(m=C%24,B=C/24|0,R=m!=0?B+1:B,f=le(Yl,Ah,22,R*4,15,1),g=0,l=0,v=0;v>24,y=(t&3)<<24>>24,N=t&-128?(t>>2^192)<<24>>24:t>>2<<24>>24,W=i&-128?(i>>4^240)<<24>>24:i>>4<<24>>24,V=a&-128?(a>>6^252)<<24>>24:a>>6<<24>>24,f[g++]=eg[N],f[g++]=eg[W|y<<4],f[g++]=eg[E<<2|V],f[g++]=eg[a&63];return m==8?(t=e[l],y=(t&3)<<24>>24,N=t&-128?(t>>2^192)<<24>>24:t>>2<<24>>24,f[g++]=eg[N],f[g++]=eg[y<<4],f[g++]=61,f[g++]=61):m==16&&(t=e[l],i=e[l+1],E=(i&15)<<24>>24,y=(t&3)<<24>>24,N=t&-128?(t>>2^192)<<24>>24:t>>2<<24>>24,W=i&-128?(i>>4^240)<<24>>24:i>>4<<24>>24,f[g++]=eg[N],f[g++]=eg[W|y<<4],f[g++]=eg[E<<2],f[g++]=61),fu(f,0,f.length)}function Ljt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae,Ue,qe,ut,ft,Ct;for(Ue=t.a.c,y=t.a.c+t.a.b,fe=e.c&&zFt(e,t),a=fe?(Ue+y)/2:Ue+(t.s+1)*e.b,m=t.d.a.Xb().tc();m.hc();)if(g=h(m.ic(),14),v=h(Ii(t.c,g),589),ft=v.f,Ct=v.a,Ae=new $t(a,ft),ut=new $t(a,Ct),we=new $t(Ue-10,ft),qe=new $t(y,Ct),C=!1,R=!1,v.b&&(C=!0,we.a=y),v.c&&(R=!0,qe.a=Ue-10),B=v.d,N=v.e,!fe||!(B||N)||R||C)t.d.a._b()==1?pU(g.a,X(q(Qr,1),be,9,0,[we,Ae,ut,qe])):(i=new $t(a,t.b),pU(g.a,X(q(Qr,1),be,9,0,[we,Ae,i,ut,qe])));else if(B&&N){for(E=0,W=0,ie=new j(g.d.g.i);ie.a=0&&gB&&(f&&(zm(we,R),zm(Ue,He(y.a-1))),Mt=i.b,Ln+=R+t,R=0,E=w.Math.max(E,i.b+i.c+Ct)),Xu(m,Mt),Yu(m,Ln),E=w.Math.max(E,Mt+Ct+i.c),R=w.Math.max(R,C),Mt+=Ct+t;if(E=w.Math.max(E,a),ft=Ln+R+i.a,ft0&&(e.p=-(e.p-1)),e.p>zs&&s0e(t,e.p-j0),g=t.q.getDate(),_I(t,1),e.k>=0&&nLt(t,e.k),e.c>=0?_I(t,e.c):e.k>=0?(v=new bbe(t.q.getFullYear()-j0,t.q.getMonth(),35),a=35-v.q.getDate(),_I(t,a0&&e.f<12&&(e.f+=12),nMt(t,e.f==24&&e.g?0:e.f),e.j>=0&&X4t(t,e.j),e.n>=0&&okt(t,e.n),e.i>=0&&hOe(t,io(Jm(h6(Vc(t.q.getTime()),Cw),Cw),e.i)),e.a&&(l=new T8,s0e(l,l.q.getFullYear()-j0-80),_K(Vc(t.q.getTime()),Vc(l.q.getTime()))&&s0e(t,l.q.getFullYear()-j0+100)),e.d>=0){if(e.c==-1)i=(7+e.d-t.q.getDay())%7,i>3&&(i-=7),m=t.q.getMonth(),_I(t,t.q.getDate()+i),t.q.getMonth()!=m&&_I(t,t.q.getDate()+(i>0?-7:7));else if(t.q.getDay()!=e.d)return!1}return e.o>zs&&(f=t.q.getTimezoneOffset(),hOe(t,io(Vc(t.q.getTime()),(e.o-f)*60*Cw))),!0}function JKe(){JKe=M,us=new Kv,ir(us,(Fe(),aD),yd),ir(us,rD,vd),ir(us,sD,_d),ir(us,oD,Nh),ir(us,T1,hb),ir(us,T1,_d),ir(us,T1,Nh),ir(us,hb,T1),ir(us,hb,yd),ir(us,hb,vd),ir(us,g3,g3),ir(us,g3,_d),ir(us,g3,yd),ir(us,Ay,Ay),ir(us,Ay,_d),ir(us,Ay,vd),ir(us,Py,Py),ir(us,Py,Nh),ir(us,Py,yd),ir(us,Cy,Cy),ir(us,Cy,Nh),ir(us,Cy,vd),ir(us,_d,sD),ir(us,_d,T1),ir(us,_d,g3),ir(us,_d,Ay),ir(us,_d,_d),ir(us,_d,yd),ir(us,_d,vd),ir(us,Nh,oD),ir(us,Nh,T1),ir(us,Nh,Py),ir(us,Nh,Cy),ir(us,Nh,Nh),ir(us,Nh,yd),ir(us,Nh,vd),ir(us,yd,aD),ir(us,yd,hb),ir(us,yd,g3),ir(us,yd,Py),ir(us,yd,_d),ir(us,yd,Nh),ir(us,yd,yd),ir(us,vd,rD),ir(us,vd,hb),ir(us,vd,Ay),ir(us,vd,Cy),ir(us,vd,_d),ir(us,vd,Nh),ir(us,vd,vd)}function Ijt(){ai(yD,new qN),ai(zj,new i0),ai(xD,new oC),ai(tPe,new CX),ai(Se,new PX),ai(q(Sc,1),new LX),ai(lo,new kX),ai(Hx,new s0),ai(Se,new jN),ai(Se,new $N),ai(Se,new wX),ai(Eo,new VN),ai(Se,new k2),ai(_u,new vE),ai(_u,new vX),ai(Se,new WN),ai(oM,new HN),ai(Se,new nC),ai(Se,new iC),ai(Se,new Jk),ai(Se,new rC),ai(Se,new _X),ai(q(Sc,1),new XN),ai(Se,new sC),ai(Se,new YN),ai(_u,new Qk),ai(_u,new yX),ai(Se,new ZN),ai(Ao,new KN),ai(Se,new JN),ai(Z0,new xX),ai(Se,new QN),ai(Se,new EX),ai(Se,new SX),ai(Se,new r0),ai(_u,new eR),ai(_u,new tR),ai(Se,new nR),ai(Se,new R2),ai(Se,new ts),ai(Se,new aC),ai(Se,new iR),ai(Se,new Uv),ai(K0,new MX),ai(Se,new rR),ai(Se,new eF),ai(Se,new Gf),ai(K0,new TX),ai(Z0,new tF),ai(Se,new AX),ai(Ao,new nF)}function Djt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B;for(a=h(G(e,(Ie(),Jn)),35),Xu(a,e.k.a+t.a),Yu(a,e.k.b+t.b),(h(nn(a,($e(),zw)),185)._b()!=0||G(e,gd)!=null||Be(G(wa(e),FG))===Be((XA(),z5))&&zNe((ww(),(e.p?e.p:(yt(),yt(),Qd)).Qb(nb)?C=h(G(e,nb),179):C=h(G(wa(e),sL),179),C)))&&(x_(a,e.n.a),y_(a,e.n.b)),E=new j(e.i);E.a1;)t=w.Math.min(f,e.c),y=(C=new Qf(e.e.c),Bu(C,(qt(),ja)),Ee(C,($e(),Yi),h(G(y,Yi),83)),Ee(C,Lf,h(G(y,Lf),185)),C.o=e.e.b++,De(e.b,C),C.n.b=y.n.b,C.n.a=t,R=new yo,pr(R,(Fe(),Zt)),ls(R,y),R.k.a=C.n.a,R.k.b=C.n.b/2,B=new yo,pr(B,tn),ls(B,C),B.k.b=C.n.b/2,B.k.a=-B.n.a,N=new Bp,Os(N,R),_s(N,B),C),De(e.e.c.a,y),--E,f-=e.c+e.e.d;for(new zwe(e.d,e.b,e.c),m=new j(l);m.a=t.length)return{done:!0};var l=t[a++];return{value:[l,i.get(l)],done:!1}}}},lUt()||(e.prototype.createObject=function(){return{}},e.prototype.get=function(t){return this.obj[":"+t]},e.prototype.set=function(t,i){this.obj[":"+t]=i},e.prototype[hie]=function(t){delete this.obj[":"+t]},e.prototype.keys=function(){var t=[];for(var i in this.obj)i.charCodeAt(0)==58&&t.push(i.substring(1));return t}),e}function Njt(e,t){var i,a,l,f,g,m,v,y,E;if(Dp(As(t))!=1||h(X9(As(t)),14).c.g.j!=(qt(),Nr))return null;for(i=h(X9(As(t)),14),a=i.c.g,Bu(a,(qt(),fs)),Ee(a,(Ie(),Tl),null),Ee(a,Cl,null),Ee(a,P5,h(G(t,P5),126)),Ee(a,Ow,(vt(),vt(),!0)),Ee(a,Jn,G(t,Jn)),a.n.b=t.n.b,f=G(i.d,Jn),g=null,y=Wc(a,(Fe(),tn)).tc();y.hc();)if(m=h(y.ic(),11),m.d.c.length!=0){Ee(m,Jn,f),E=i.d,m.n.a=E.n.a,m.n.b=E.n.b,m.a.a=E.a.a,m.a.b=E.a.b,Lr(m.e,E.e),E.e.c=le(sn,nt,1,0,5,1),g=m;break}if(Ee(i.d,Jn,null),Dp(Wc(t,tn))>1)for(v=On(au(Wc(t,tn)),0);v.b!=v.d.c;)m=h(Fn(v),11),m.d.c.length==0?(l=new yo,pr(l,tn),l.n.a=m.n.a,l.n.b=m.n.b,ls(l,a),Ee(l,Jn,G(m,Jn)),ls(m,null)):ls(g,a);return Ee(t,Jn,null),Ee(t,Ow,!1),Bu(t,ja),Ee(a,($e(),Yi),h(G(t,Yi),83)),Ee(a,Lf,h(G(t,Lf),185)),w0(e.b,0,a),a}function Fjt(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe;for(ni(i,"Polyline edge routing",1),B=ce(Xe(G(t,($e(),Vw)))),l=ce(Xe(G(t,o3))),a=w.Math.min(1,l/B),ie=0,t.b.c.length!=0&&(fe=ZXe(h(Tt(t.b,0),26)),ie=.4*a*fe),m=new Ns(t.b,0);m.b0&&(ie-=B),C_e(g,ie),E=0,R=new j(g.a);R.a0),m.a.cd(m.c=--m.b)),v=.4*a*E,!f&&m.b0||E.i==tn&&E.d.c.length-E.f.c.length<0)){i=!1;break}if(E.i==tn){for(l=new j(E.f);l.a=m){kn(V.b>0),V.a.cd(V.c=--V.b);break}else N.a>v&&(l?(Lr(l.b,N.b),l.a=w.Math.max(l.a,N.a),_f(V)):(De(N.b,E),N.c=w.Math.min(N.c,v),N.a=w.Math.max(N.a,m),l=N));l||(l=new dDe,l.c=v,l.a=m,ed(V,l),De(l.b,E))}for(g=t.b,y=0,W=new j(a);W.a0&&Sa(a,-6)>=0){if(Sa(a,0)>=0){for(l=i+nr(a),g=17;g>=l;g--)y[g+1]=y[g];return y[++l]=46,m&&(y[--i]=45),fu(y,i,18-i+1)}for(f=2;_K(f,io(dS(a),1));f++)y[--i]=48;return y[--i]=46,y[--i]=48,m&&(y[--i]=45),fu(y,i,18-i)}return R=i+1,E=new Qb,m&&(E.a+="-"),18-R>=1?(Lg(E,y[i]),E.a+=".",E.a+=fu(y,i+1,18-i-1)):E.a+=fu(y,i,18-i),E.a+="E",Sa(a,0)>0&&(E.a+="+"),E.a+=""+E9(a),E.a}function iJe(e){var t,i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae,Ue,qe,ut,ft,Ct,Mt,Ln,_i,os;for(C=h(G(e,(Fg(),Xx)),35),ee=zi,ie=zi,W=zs,V=zs,we=new j(e.e);we.at.d.c){if(B=e.c[t.a.d],V=e.c[C.a.d],B==V)continue;Ku(Uu(Fu(zu(Nu(new nu,1),100),B),V))}}}}}function Vjt(e,t,i,a,l,f){var g,m,v,y,E,C;for(y=new yo,Oo(y,t),pr(y,h(nn(t,($e(),oL)),69)),Ee(y,(Ie(),Jn),t),ls(y,i),C=y.n,C.a=t.g,C.b=t.f,E=y.k,E.a=t.i,E.b=t.j,fr(e.a,t,y),g=nU(qf(Kf(new si(null,(!t.e&&(t.e=new an(js,t,7,4)),new pi(t.e,16))),new pl),new v2),new NY(t)),g||(g=nU(qf(Kf(new si(null,(!t.d&&(t.d=new an(js,t,8,5)),new pi(t.d,16))),new Rm),new Iv),new FY(t))),g||(g=nU(new si(null,(!t.e&&(t.e=new an(js,t,7,4)),new pi(t.e,16))),new iE)),Ee(y,L5,(vt(),!!g)),Zzt(y,f,l,h(nn(t,Gw),9)),v=new Dn((!t.n&&(t.n=new ze(Qo,t,1,7)),t.n));v.e!=v.i._b();)m=h(Xn(v),137),!ce(bt(nn(m,x1)))&&m.a&&De(y.e,$ee(m));switch((!t.d&&(t.d=new an(js,t,8,5)),t.d).i+(!t.e&&(t.e=new an(js,t,7,4)),t.e).i>1&&a.nc((xo(),KP)),l.g){case 2:case 1:(y.i==(Fe(),bn)||y.i==ei)&&a.nc((xo(),py));break;case 4:case 3:(y.i==(Fe(),Zt)||y.i==tn)&&a.nc((xo(),py))}return y}function em(e,t){vi();var i,a,l,f,g,m,v,y,E,C,R,B,N;if(BE(PM)==0){for(C=le(MVt,be,112,Tut.length,0,1),g=0;gy&&(a.a+=VNe(le(Yl,Ah,22,-y,15,1))),a.a+="Is",_h(v,bc(32))>=0)for(l=0;l0){if(g+a>e.length)return!1;m=h7(e.substr(0,g+a),t)}else m=h7(e,t);switch(f){case 71:return m=N_(e,g,X(q(Se,1),be,2,6,[RJe,IJe]),t),l.e=m,!0;case 77:return Z9t(e,t,l,m,g);case 76:return K9t(e,t,l,m,g);case 69:return jNt(e,t,g,l);case 99:return $Nt(e,t,g,l);case 97:return m=N_(e,g,X(q(Se,1),be,2,6,["AM","PM"]),t),l.b=m,!0;case 121:return rUt(e,t,g,m,i,l);case 100:return m<=0?!1:(l.c=m,!0);case 83:return m<0?!1:J6t(m,g,t[0],l);case 104:m==12&&(m=0);case 75:case 72:return m<0?!1:(l.f=m,l.g=!1,!0);case 107:return m<0?!1:(l.f=m,l.g=!0,!0);case 109:return m<0?!1:(l.j=m,!0);case 115:return m<0?!1:(l.n=m,!0);case 90:if(gut[v]&&(V=v),C=new j(e.b.b);C.a0?R=r6(m):R=n6(r6(m)),e.ze(oL,R)),R.g){case 4:Ee(E,ec,(hu(),Fw)),Ee(E,roe,(M_(),YP)),E.n.b=g.b,pr(C,(Fe(),Zt)),C.k.b=y.b;break;case 2:Ee(E,ec,(hu(),tb)),Ee(E,roe,(M_(),T5)),E.n.b=g.b,pr(C,(Fe(),tn)),C.k.b=y.b;break;case 1:Ee(E,y1,(Wd(),gy)),E.n.a=g.a,pr(C,(Fe(),ei)),C.k.a=y.a;break;case 3:Ee(E,y1,(Wd(),Zx)),E.n.a=g.a,pr(C,(Fe(),bn)),C.k.a=y.a}if(t==d3||t==wd||t==Ba){if(B=0,t==d3&&e.ye(E1))switch(R.g){case 1:case 2:B=h(e.xe(E1),21).a;break;case 3:case 4:B=-h(e.xe(E1),21).a}else switch(R.g){case 4:case 2:B=f.b,t==wd&&(B/=l.b);break;case 1:case 3:B=f.a,t==wd&&(B/=l.a)}Ee(E,eb,B)}return Ee(E,da,R),E}function Zjt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae,Ue;if(R=h(h(Qi(e.r,t),19),60),t==(Fe(),Zt)||t==tn){YKe(e,t);return}for(f=t==bn?(R0(),hD):(R0(),dD),we=t==bn?(Oc(),Rf):(Oc(),cf),i=h(Ds(e.b,t),114),a=i.i,l=a.c+v_(X(q(ks,1),Vo,22,15,[i.n.b,e.A.b,e.k])),ee=a.c+a.b-v_(X(q(ks,1),Vo,22,15,[i.n.c,e.A.c,e.k])),g=Cpe(Dme(f),e.s),ie=t==bn?cre:zx,C=R.tc();C.hc();)y=h(C.ic(),111),!(!y.c||y.c.d.c.length<=0)&&(V=y.b.Re(),W=y.e,B=y.c,N=B.i,N.b=(v=B.n,B.e.a+v.b+v.c),N.a=(m=B.n,B.e.b+m.d+m.a),tQ(we,fxe),B.f=we,Sh(B,(il(),af)),N.c=W.a-(N.b-V.a)/2,Ae=w.Math.min(l,W.a),Ue=w.Math.max(ee,W.a+V.a),N.cUe&&(N.c=Ue-N.b),De(g.d,new jJ(N,Gbe(g,N))),ie=t==bn?w.Math.max(ie,W.b+y.b.Re().b):w.Math.min(ie,W.b));for(ie+=t==bn?e.s:-e.s,fe=Qbe((g.e=ie,g)),fe>0&&(h(Ds(e.b,t),114).a.b=fe),E=R.tc();E.hc();)y=h(E.ic(),111),!(!y.c||y.c.d.c.length<=0)&&(N=y.c.i,N.c-=y.e.a,N.d-=y.e.b)}function sJe(e,t,i){var a,l,f,g,m,v,y,E,C,R;if(a=new Xf(t.Qe().a,t.Qe().b,t.Re().a,t.Re().b),l=new $E,e.c)for(g=new j(t.We());g.a=2){if((!e.a&&(e.a=new ze(es,e,6,6)),e.a).i==0)i=(h0(),l=new gE,l),$n((!e.a&&(e.a=new ze(es,e,6,6)),e.a),i);else if((!e.a&&(e.a=new ze(es,e,6,6)),e.a).i>1)for(R=new QC((!e.a&&(e.a=new ze(es,e,6,6)),e.a));R.e!=R.i._b();)KA(R);R6(t,h(ae((!e.a&&(e.a=new ze(es,e,6,6)),e.a),0),270))}if(C)for(a=new Dn((!e.a&&(e.a=new ze(es,e,6,6)),e.a));a.e!=a.i._b();)for(i=h(Xn(a),270),y=new Dn((!i.a&&(i.a=new vs(sh,i,5)),i.a));y.e!=y.i._b();)v=h(Xn(y),531),m.a=w.Math.max(m.a,v.a),m.b=w.Math.max(m.b,v.b);for(g=new Dn((!e.n&&(e.n=new ze(Qo,e,1,7)),e.n));g.e!=g.i._b();)f=h(Xn(g),137),E=h(nn(f,SL),9),E&&Bd(f,E.a,E.b),C&&(m.a=w.Math.max(m.a,f.i+f.g),m.b=w.Math.max(m.b,f.j+f.f));return m}function Kjt(e,t,i){var a,l,f,g,m,v,y,E,C,R,B;if(e.e.a.Pb(),e.f.a.Pb(),e.c.c=le(sn,nt,1,0,5,1),e.i.c=le(sn,nt,1,0,5,1),e.g.a.Pb(),t)for(g=new j(t.a);g.a>4)<<24>>24,C[R++]=((i&15)<<4|a>>2&15)<<24>>24,C[R++]=(a<<6|l)<<24>>24}return!BR(g=f[E++])||!BR(m=f[E++])?null:(t=ch[g],i=ch[m],v=f[E++],y=f[E++],ch[v]==-1||ch[y]==-1?v==61&&y==61?i&15?null:(V=le(Sc,sy,22,B*3+1,15,1),wc(C,0,V,0,B*3),V[R]=(t<<2|i>>4)<<24>>24,V):v!=61&&y==61?(a=ch[v],a&3?null:(V=le(Sc,sy,22,B*3+2,15,1),wc(C,0,V,0,B*3),V[R++]=(t<<2|i>>4)<<24>>24,V[R]=((i&15)<<4|a>>2&15)<<24>>24,V)):null:(a=ch[v],l=ch[y],C[R++]=(t<<2|i>>4)<<24>>24,C[R++]=((i&15)<<4|a>>2&15)<<24>>24,C[R++]=(a<<6|l)<<24>>24,C))}function Qjt(e,t,i){var a,l,f,g,m,v,y,E,C,R;for(v=new Re,C=t.length,g=vbe(i),y=0;ym&&(fe=0,we+=g+ee,g=0),i7t(W,i,fe,we),t=w.Math.max(t,fe+V.a),g=w.Math.max(g,V.b),fe+=V.a+ee;return W}function e$t(e,t,i){var a,l,f,g,m;switch(a=t.i,f=e.g.n,l=e.g.d,m=e.k,g=No(X(q(Qr,1),be,9,0,[m,e.a])),e.i.g){case 1:Fd(t,(Oc(),cf)),a.d=-l.d-i-a.a,h(h(iS(t.d).a.cd(0),271).xe((Ie(),e3)),265)==(yl(),xd)?(Sh(t,(il(),af)),a.c=g.a-ce(Xe(G(e,my)))-i-a.b):(Sh(t,(il(),Fh)),a.c=g.a+ce(Xe(G(e,my)))+i);break;case 2:Sh(t,(il(),Fh)),a.c=f.a+l.c+i,h(h(iS(t.d).a.cd(0),271).xe((Ie(),e3)),265)==(yl(),xd)?(Fd(t,(Oc(),cf)),a.d=g.b-ce(Xe(G(e,my)))-i-a.a):(Fd(t,(Oc(),Rf)),a.d=g.b+ce(Xe(G(e,my)))+i);break;case 3:Fd(t,(Oc(),Rf)),a.d=f.b+l.a+i,h(h(iS(t.d).a.cd(0),271).xe((Ie(),e3)),265)==(yl(),xd)?(Sh(t,(il(),af)),a.c=g.a-ce(Xe(G(e,my)))-i-a.b):(Sh(t,(il(),Fh)),a.c=g.a+ce(Xe(G(e,my)))+i);break;case 4:Sh(t,(il(),af)),a.c=-l.b-i-a.b,h(h(iS(t.d).a.cd(0),271).xe((Ie(),e3)),265)==(yl(),xd)?(Fd(t,(Oc(),cf)),a.d=g.b-ce(Xe(G(e,my)))-i-a.a):(Fd(t,(Oc(),Rf)),a.d=g.b+ce(Xe(G(e,my)))+i)}}function cJe(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N;switch(g=new b9e(e),m=sd(Ud(t,g)),yt(),ua(m,new KO),l=e.b,l.c){case 2:v=new Kb(l.a),i=qC(Ud(m,v)),S_(i)?y=h(dx(i),188).b:y=15,v=new Kb(ywe(l)),i=qC(Ud(m,v)),S_(i)?f=h(dx(i),188).b:f=15,v=new Kb(l.b),i=qC(Ud(m,v)),S_(i)?E=h(dx(i),188).b:E=15,a=V8t(e,y,f,E),Cr(t,new cP(a,e.c,e.e,e.a.c.g,l.a)),Cr(t,new cP(a,e.c,e.e,e.a.c.g,ywe(l))),Cr(t,new cP(a,e.c,e.e,e.a.c.g,l.b));break;case 1:v=new Kb(l.a),i=qC(Ud(m,v)),S_(i)?y=h(dx(i),188).b:y=15,v=new Kb(l.b),i=qC(Ud(m,v)),S_(i)?E=h(dx(i),188).b:E=15,a=D8t(e,y,E),Cr(t,new cP(a,e.c,e.e,e.a.c.g,l.a)),Cr(t,new cP(a,e.c,e.e,e.a.c.g,l.b));break;case 0:v=new Kb(l.a),i=qC(Ud(m,v)),S_(i)?y=h(dx(i),188).b:y=15,a=(C=e.b,R=g7t(e.a.c,e.a.d,y),wo(e.a.a,ote(R)),B=nve(e.a.b,R.a,C),N=new EI((!R.k&&(R.k=new Wte(_ee(R))),R.k)),U1e(N),B?w1e(N,B):N),Cr(t,new cP(a,e.c,e.e,e.a.c.g,l.a));break;default:throw Y(new un("The loopside must be defined."))}return a}function t$t(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae,Ue,qe,ut,ft;for(ni(t,"Compound graph postprocessor",1),i=ce(bt(G(e,($e(),_oe)))),m=h(G(e,(Ie(),YSe)),238),E=new Ur,ee=m.Xb().tc();ee.hc();){for(V=h(ee.ic(),14),g=new wf(m.Mc(V)),yt(),ua(g,new BF(e)),Ae=kRt((oi(0,g.c.length),h(g.c[0],234))),qe=P$e(h(Tt(g,g.c.length-1),234)),fe=Ae.g,MS(qe.g,fe)?ie=h(G(fe,gd),31):ie=wa(fe),C=j5t(V,g),id(V.a),R=null,f=new j(g);f.aKd,ft=w.Math.abs(R.b-N.b)>Kd,(!i&&ut&&ft||i&&(ut||ft))&&Gi(V.a,we)),wo(V.a,a),a.b==0?R=we:R=(kn(a.b!=0),h(a.c.b.c,9)),JRt(B,C,W),P$e(l)==qe&&(wa(qe.g)!=l.a&&(W=new fo,Dve(W,wa(qe.g),ie)),Ee(V,foe,W)),tNt(B,V,ie),E.a.Zb(B,E);Os(V,Ae),_s(V,qe)}for(y=E.a.Xb().tc();y.hc();)v=h(y.ic(),14),Os(v,null),_s(v,null);Bn(t)}function n$t(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae,Ue,qe,ut,ft,Ct,Mt,Ln,_i;for(ie=new Ns(e.b,0),E=t.tc(),N=0,y=h(E.ic(),21).a,Ae=0,i=new Ur,qe=new zc;ie.b=e.a&&(a=b7t(e,ie),E=bf(E,a.b),we=bf(we,a.d),De(m,new Is(ie,a)));for(ut=new Re,y=0;y0),V.a.cd(V.c=--V.b),ft=new cu(e.b),ed(V,ft),kn(V.b=a.n.b/2}else ie=!C;ie?(ee=h(G(a,(Ie(),n3)),15),ee?R?f=ee:(l=h(G(a,Kx),15),l?ee._b()<=l._b()?f=ee:f=l:(f=new Re,Ee(a,Kx,f))):(f=new Re,Ee(a,n3,f))):(l=h(G(a,(Ie(),Kx)),15),l?C?f=l:(ee=h(G(a,n3),15),ee?l._b()<=ee._b()?f=l:f=ee:(f=new Re,Ee(a,n3,f))):(f=new Re,Ee(a,Kx,f))),f.nc(e),Ee(e,(Ie(),SG),i),t.d==i?(_s(t,null),i.d.c.length+i.f.c.length==0&&ls(i,null),_It(i)):(Os(t,null),i.d.c.length+i.f.c.length==0&&ls(i,null)),id(t.a)}function s$t(e){var t,i,a,l,f,g,m,v,y,E,C,R,B,N;if(Be(G(e.c,($e(),Yi)))===Be((Ms(),wd))||Be(G(e.c,Yi))===Be(Ba)){for(E=new j(e.c.i);E.a0&&(l=h(Tt(V.c.a,Ue-1),8),g=e.i[l.o],ut=w.Math.ceil(r_(e.n,l,V)),f=Ae.a.e-V.d.d-(g.a.e+l.n.b+l.d.a)-ut),y=Kr,Ue0&&qe.a.e.e-qe.a.a-(qe.b.e.e-qe.b.a)<0,N=fe.a.e.e-fe.a.a-(fe.b.e.e-fe.b.a)<0&&qe.a.e.e-qe.a.a-(qe.b.e.e-qe.b.a)>0,B=fe.a.e.e+fe.b.aqe.b.e.e+qe.a.a,we=0,!W&&!N&&(R?f+C>0?we=C:y-a>0&&(we=a):B&&(f+m>0?we=m:y-ie>0&&(we=ie))),Ae.a.e+=we,Ae.b&&(Ae.d.e+=we),!1))}function a$t(){var e=["\\u0000","\\u0001","\\u0002","\\u0003","\\u0004","\\u0005","\\u0006","\\u0007","\\b","\\t","\\n","\\u000B","\\f","\\r","\\u000E","\\u000F","\\u0010","\\u0011","\\u0012","\\u0013","\\u0014","\\u0015","\\u0016","\\u0017","\\u0018","\\u0019","\\u001A","\\u001B","\\u001C","\\u001D","\\u001E","\\u001F"];return e[34]='\\"',e[92]="\\\\",e[173]="\\u00ad",e[1536]="\\u0600",e[1537]="\\u0601",e[1538]="\\u0602",e[1539]="\\u0603",e[1757]="\\u06dd",e[1807]="\\u070f",e[6068]="\\u17b4",e[6069]="\\u17b5",e[8203]="\\u200b",e[8204]="\\u200c",e[8205]="\\u200d",e[8206]="\\u200e",e[8207]="\\u200f",e[8232]="\\u2028",e[8233]="\\u2029",e[8234]="\\u202a",e[8235]="\\u202b",e[8236]="\\u202c",e[8237]="\\u202d",e[8238]="\\u202e",e[8288]="\\u2060",e[8289]="\\u2061",e[8290]="\\u2062",e[8291]="\\u2063",e[8292]="\\u2064",e[8298]="\\u206a",e[8299]="\\u206b",e[8300]="\\u206c",e[8301]="\\u206d",e[8302]="\\u206e",e[8303]="\\u206f",e[65279]="\\ufeff",e[65529]="\\ufff9",e[65530]="\\ufffa",e[65531]="\\ufffb",e}function cl(){cl=M,lm=new Ig("N",0,(Fe(),bn),bn,0),Ww=new Ig("EN",1,Zt,bn,1),rb=new Ig("E",2,Zt,Zt,0),sb=new Ig("SE",3,ei,Zt,1),Zp=new Ig("S",4,ei,ei,0),Xw=new Ig("WS",5,tn,ei,1),qw=new Ig("W",6,tn,tn,0),np=new Ig("NW",7,bn,tn,1),Yp=new Ig("ENW",8,Zt,tn,2),Hw=new Ig("ESW",9,Zt,tn,2),ob=new Ig("SEN",10,ei,bn,2),yy=new Ig("SWN",11,ei,bn,2),c3=new Ig(Ux,12,Oa,Oa,3),eat=y5t(lm,Ww,rb,sb,Zp,Xw,X(q(hL,1),Oe,129,0,[qw,np,Yp,Hw,ob,yy])),nat=(aw(),F_(X(q(sn,1),nt,1,5,[lm,rb,Zp,qw]))),tat=F_(X(q(sn,1),nt,1,5,[Ww,sb,Xw,np])),aat=new j2(bn),rat=F_(X(q(sn,1),nt,1,5,[Zt,bn])),iat=new j2(Zt),uat=F_(X(q(sn,1),nt,1,5,[ei,Zt])),lat=new j2(ei),gat=F_(X(q(sn,1),nt,1,5,[tn,ei])),pat=new j2(tn),cat=F_(X(q(sn,1),nt,1,5,[bn,tn])),sat=F_(X(q(sn,1),nt,1,5,[Zt,bn,tn])),oat=F_(X(q(sn,1),nt,1,5,[Zt,ei,tn])),hat=F_(X(q(sn,1),nt,1,5,[ei,tn,bn])),fat=F_(X(q(sn,1),nt,1,5,[ei,Zt,bn])),dat=(eS(),GP)}function c$t(e){var t,i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae,Ue,qe,ut;if(i=ce(Xe(G(e.a.j,($e(),TMe)))),i<-1||!e.a.i||iA(h(G(e.a.o,Yi),83))||ra(e.a.o,(Fe(),Zt))._b()<2&&ra(e.a.o,tn)._b()<2)return!0;if(e.a.c.pf())return!1;for(we=0,fe=0,ie=new Re,v=e.a.e,y=0,E=v.length;y=i}function l$t(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we;for(ni(t,TQe,1),B=h(G(e,($e(),cm)),197),l=new j(e.b);l.a=2){for(N=!0,C=new j(f.i),i=h($(C),11);C.a0){for(R=E<100?null:new Eg(E),y=new cbe(t),N=y.g,ee=le(Rn,ii,22,E,15,1),a=0,we=new w_(E),l=0;l=0;)if(m!=null?Li(m,N[v]):N[v]==null){ee.length<=a&&(V=ee,ee=le(Rn,ii,22,2*ee.length,15,1),wc(V,0,ee,0,a)),ee[a++]=l,$n(we,N[v]);break e}if(Be(m)===Be(m))break}}if(N=we.g,a>ee.length&&(V=ee,ee=le(Rn,ii,22,a,15,1),wc(V,0,ee,0,a)),a>0){for(fe=!0,f=0;f=0;)xx(e,ee[g]);if(a!=a){for(l=a;--l>=a;)xx(we,l);V=ee,ee=le(Rn,ii,22,a,15,1),wc(V,0,ee,0,a)}t=we}}}else for(t=FDt(e,t),l=e.i;--l>=0;)t.pc(e.g[l])&&(xx(e,l),fe=!0);if(fe){if(ee!=null){for(i=t._b(),C=i==1?dA(e,4,t.tc().ic(),null,ee[0],W):dA(e,6,t,ee,ee[0],W),R=i<100?null:new Eg(i),l=t.tc();l.hc();)B=l.ic(),R=Mme(e,h(B,75),R);R?(R.Sh(C),R.Th()):Pi(e.e,C)}else{for(R=HMt(t._b()),l=t.tc();l.hc();)B=l.ic(),R=Mme(e,h(B,75),R);R&&R.Th()}return!0}else return!1}function f$t(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae,Ue,qe,ut,ft,Ct,Mt,Ln,_i,os;for(ni(i,"MinWidth layering",1),B=t.b,qe=t.a,os=h(G(t,($e(),FMe)),21).a,m=h(G(t,UMe),21).a,e.b=ce(Xe(G(t,ih))),e.d=Kr,we=new j(qe);we.a0||i.o==rh&&l0?(C=h(Tt(R.c.a,g-1),8),ut=r_(e.b,R,C),V=R.k.b-R.d.d-(C.k.b+C.n.b+C.d.a+ut)):V=R.k.b-R.d.d,y=w.Math.min(V,y),g=1&&(ut-y>0&&N>=0?(Xu(C,C.i+qe),Yu(C,C.j+v*y)):ut-y<0&&B>=0&&(Xu(C,C.i+qe*ut),Yu(C,C.j+v)));return oc(e,yM,(f=h(ml(AL),10),new Bc(f,h(Qc(f,f.length),10),0))),new $t(ft,E)}function g$t(e){var t,i,a,l,f,g,m,v,y,E,C,R,B,N,W,V;for(W=new Re,R=new j(e.d.b);R.al.d.d+l.d.a?E.f.d=!0:(E.f.d=!0,E.f.a=!0))),a.b!=a.d.c&&(t=i);E&&(f=h(Ii(e.f,g.d.g),57),t.bf.d.d+f.d.a?E.f.d=!0:(E.f.d=!0,E.f.a=!0))}for(m=Tn(As(B));Gn(m);)g=h(Mn(m),14),g.a.b!=0&&(t=h(n9(g.a),9),g.d.i==(Fe(),bn)&&(V=new dP(t,new $t(t.a,l.d.d),l,g),V.f.a=!0,V.a=g.d,W.c[W.c.length]=V),g.d.i==ei&&(V=new dP(t,new $t(t.a,l.d.d+l.d.a),l,g),V.f.d=!0,V.a=g.d,W.c[W.c.length]=V))}return W}function m$t(){_pe();function e(a){var l=this;this.dispatch=function(f){var g=f.data;switch(g.cmd){case"algorithms":var m=Jbe((yt(),new Zb(new mh(Jw.b))));a.postMessage({id:g.id,data:m});break;case"categories":var v=Jbe((yt(),new Zb(new mh(Jw.c))));a.postMessage({id:g.id,data:v});break;case"options":var y=Jbe((yt(),new Zb(new mh(Jw.d))));a.postMessage({id:g.id,data:y});break;case"register":kzt(g.algorithms),a.postMessage({id:g.id});break;case"layout":W8t(g.graph,g.options||{}),a.postMessage({id:g.id,data:g.graph});break}},this.saveDispatch=function(f){try{l.dispatch(f)}catch(g){delete g[jne],a.postMessage({id:f.data.id,error:g.message})}}}function t(a){var l=this;this.dispatcher=new e({postMessage:function(f){l.onmessage({data:f})}}),this.postMessage=function(f){setTimeout(function(){l.dispatcher.saveDispatch({data:f})},0)}}if(typeof document===Axe&&typeof self!==Axe){var i=new e(self);self.onmessage=i.saveDispatch}else typeof u!==Axe&&u.exports&&(Object.defineProperty(d,"__esModule",{value:!0}),u.exports={default:t,Worker:t})}function fJe(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we;if(ie=0,t.e.a==0)for(V=new j(e);V.a50?ee.c[ee.c.length]=l:l.k>0?ie.c[ie.c.length]=l:fe.c[fe.c.length]=l;if(ie.c.length==1&&ee.c.length==0&&(Lr(ee,ie),ie.c=le(sn,nt,1,0,5,1)),ee.c.length!=0&&kp(oJ(e.a),(cl(),lm))&&kp(oJ(e.a),(cl(),Zp))?R6t(e,ee):Lr(ie,ee),ie.c.length==0||I6t(e,ie),fe.c.length!=0){if(i=sJ(e.a),i.c!=0)for(E=new j(fe),v=(Hn(i),Vge(new NNe(i).a));E.a1&&(W=h(nbe(v),129),WA(l,W,!0),cA(E),KUe(e.a,W))}for(R=fe.c.length,a=OUt(e),B=new Re,g=R/Mge(e.a).c|0,m=0;m3&&(Lr(B,(cl(),cl(),tat)),N-=4),N){case 3:De(B,M6(a));case 2:V=y7(M6(a));do V=y7(V);while(!kp(oJ(e.a),V));B.c[B.c.length]=V,V=Gve(M6(a));do V=Gve(V);while(!kp(oJ(e.a),V));B.c[B.c.length]=V;break;case 1:De(B,M6(a))}for(C=new j(B),y=new j(fe);C.aW&&(f&&(zm(Ue,B),zm(ut,He(E.b-1)),De(e.d,N),m.c=le(sn,nt,1,0,5,1)),_i=i.b,os+=B+t,B=0,C=w.Math.max(C,i.b+i.c+Ln)),m.c[m.c.length]=v,lHe(v,_i,os),C=w.Math.max(C,_i+Ln+i.c),B=w.Math.max(B,R),_i+=Ln+t,N=v;if(Lr(e.a,m),De(e.d,h(Tt(m,m.c.length-1),145)),C=w.Math.max(C,a),Mt=os+B+i.a,Mt1&&(g=w.Math.min(g,w.Math.abs(h(qg(m.a,1),9).b-E.b)))));else for(W=new j(t.i);W.al&&(f=R.a-l,g=zi,a.c=le(sn,nt,1,0,5,1),l=R.a),R.a>=l&&(a.c[a.c.length]=m,m.a.b>1&&(g=w.Math.min(g,w.Math.abs(h(qg(m.a,m.a.b-2),9).b-R.b)))));if(a.c.length!=0&&f>t.n.a/2&&g>t.n.b/2){for(B=new yo,ls(B,t),pr(B,(Fe(),bn)),B.k.a=t.n.a/2,ee=new yo,ls(ee,t),pr(ee,ei),ee.k.a=t.n.a/2,ee.k.b=t.n.b,v=new j(a);v.a=y.b?Os(m,ee):Os(m,B)):(y=h(RCt(m.a),9),V=m.a.b==0?Vu(m.c):h(n9(m.a),9),V.b>=y.b?_s(m,ee):_s(m,B)),C=h(G(m,($e(),Po)),74),C&&vx(C,y,!0);t.k.a=l-t.n.a/2}}function x$t(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae;for(m=new j(e.a.b);m.a0)if(a=C._b(),y=wr(w.Math.floor((a+1)/2))-1,l=wr(w.Math.ceil((a+1)/2))-1,t.o==rh)for(E=l;E>=y;E--)t.a[we.o]==we&&(W=h(C.cd(E),48),N=h(W.a,8),!IC(i,W.b)&&B>e.b.e[N.o]&&(t.a[N.o]=we,t.g[we.o]=t.g[N.o],t.a[we.o]=t.g[we.o],t.f[t.g[we.o].o]=(vt(),!!(ce(t.f[t.g[we.o].o])&we.j==(qt(),Nr))),B=e.b.e[N.o]));else for(E=y;E<=l;E++)t.a[we.o]==we&&(ee=h(C.cd(E),48),V=h(ee.a,8),!IC(i,ee.b)&&B=48&&t<=57){for(a=t-48;l=48&&t<=57;)if(a=a*10+t-48,a<0)throw Y(new Wn(Yn((zn(),Dxe))))}else throw Y(new Wn(Yn((zn(),dtt))));if(i=a,t==44){if(l>=e.j)throw Y(new Wn(Yn((zn(),gtt))));if((t=po(e.i,l++))>=48&&t<=57){for(i=t-48;l=48&&t<=57;)if(i=i*10+t-48,i<0)throw Y(new Wn(Yn((zn(),Dxe))));if(a>i)throw Y(new Wn(Yn((zn(),mtt))))}else i=-1}if(t!=125)throw Y(new Wn(Yn((zn(),ptt))));e.Ck(l)?(f=(vi(),vi(),++_r,new hw(9,f)),e.d=l+1):(f=(vi(),vi(),++_r,new hw(3,f)),e.d=l),f.nl(a),f.ml(i),wi(e)}}return f}function E$t(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae,Ue,qe,ut,ft,Ct;return C=N7t(ic(e,(Fe(),gAe)),t),N=k_(ic(e,sD),t),we=k_(ic(e,oD),t),ut=r7(ic(e,aD),t),R=r7(ic(e,rD),t),ie=k_(ic(e,g3),t),W=k_(ic(e,Ay),t),Ue=k_(ic(e,Py),t),Ae=k_(ic(e,Cy),t),ft=r7(ic(e,hb),t),ee=k_(ic(e,T1),t),fe=k_(ic(e,_d),t),qe=k_(ic(e,Nh),t),Ct=r7(ic(e,yd),t),B=r7(ic(e,vd),t),V=k_(ic(e,vae),t),i=v_(X(q(ks,1),Vo,22,15,[ie.a,ut.a,Ue.a,Ct.a])),a=v_(X(q(ks,1),Vo,22,15,[N.a,C.a,we.a,V.a])),l=ee.a,f=v_(X(q(ks,1),Vo,22,15,[W.a,R.a,Ae.a,B.a])),y=v_(X(q(ks,1),Vo,22,15,[ie.b,N.b,W.b,fe.b])),v=v_(X(q(ks,1),Vo,22,15,[ut.b,C.b,R.b,V.b])),E=ft.b,m=v_(X(q(ks,1),Vo,22,15,[Ue.b,we.b,Ae.b,qe.b])),Bg(ic(e,gAe),i+l,y+E),Bg(ic(e,vae),i+l,y+E),Bg(ic(e,sD),i+l,0),Bg(ic(e,oD),i+l,y+E+v),Bg(ic(e,aD),0,y+E),Bg(ic(e,rD),i+l+a,y+E),Bg(ic(e,Ay),i+l+a,0),Bg(ic(e,Py),0,y+E+v),Bg(ic(e,Cy),i+l+a,y+E+v),Bg(ic(e,hb),0,y),Bg(ic(e,T1),i,0),Bg(ic(e,Nh),0,y+E+v),Bg(ic(e,vd),i+l+a,0),g=new fo,g.a=v_(X(q(ks,1),Vo,22,15,[i+a+l+f,ft.a,fe.a,qe.a])),g.b=v_(X(q(ks,1),Vo,22,15,[y+v+E+m,ee.b,Ct.b,B.b])),g}function Ma(){Ma=M,tBe(),Llt=hs.a,h(ae(ye(hs.a),0),17),Alt=hs.f,h(ae(ye(hs.f),0),17),h(ae(ye(hs.f),1),29),Plt=hs.n,h(ae(ye(hs.n),0),29),h(ae(ye(hs.n),1),29),h(ae(ye(hs.n),2),29),h(ae(ye(hs.n),3),29),SAe=hs.g,h(ae(ye(hs.g),0),17),h(ae(ye(hs.g),1),29),Clt=hs.c,h(ae(ye(hs.c),0),17),h(ae(ye(hs.c),1),17),MAe=hs.i,h(ae(ye(hs.i),0),17),h(ae(ye(hs.i),1),17),h(ae(ye(hs.i),2),17),h(ae(ye(hs.i),3),17),h(ae(ye(hs.i),4),29),TAe=hs.j,h(ae(ye(hs.j),0),17),EAe=hs.d,h(ae(ye(hs.d),0),17),h(ae(ye(hs.d),1),17),h(ae(ye(hs.d),2),17),h(ae(ye(hs.d),3),17),h(ae(ye(hs.d),4),29),h(ae(ye(hs.d),5),29),h(ae(ye(hs.d),6),29),h(ae(ye(hs.d),7),29),Tlt=hs.b,h(ae(ye(hs.b),0),29),h(ae(ye(hs.b),1),29),Cj=hs.e,h(ae(ye(hs.e),0),29),h(ae(ye(hs.e),1),29),h(ae(ye(hs.e),2),29),h(ae(ye(hs.e),3),29),h(ae(ye(hs.e),4),17),h(ae(ye(hs.e),5),17),h(ae(ye(hs.e),6),17),h(ae(ye(hs.e),7),17),h(ae(ye(hs.e),8),17),h(ae(ye(hs.e),9),17),h(ae(ye(hs.e),10),29),sp=hs.k,h(ae(ye(hs.k),0),29),h(ae(ye(hs.k),1),29)}function S$t(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae,Ue,qe,ut,ft,Ct,Mt;for(ft=new Ir,Ue=new Ir,V=-1,v=new j(e);v.a=N&&(ie>N&&(B.c=le(sn,nt,1,0,5,1),N=ie),B.c[B.c.length]=g);B.c.length!=0&&(R=h(Tt(B,pte(t,B.c.length)),125),Mt.a.$b(R)!=null,R.p=W++,Fve(R,ft,Ue),B.c=le(sn,nt,1,0,5,1))}for(we=e.c.length+1,m=new j(e);m.aCt.p&&(_f(i),Ea(Ct.g,a),a.c>0&&(a.a=Ct,De(Ct.q,a),a.b=qe,De(qe.g,a)))}function M$t(e,t,i){var a,l,f,g,m,v,y,E,C;if(ni(i,"Network simplex node placement",1),e.e=t,e.n=h(G(t,(Ie(),Nw)),266),Azt(e),JBt(e),Na(Kf(new si(null,new pi(e.e.b,16)),new iq),new lZ(e)),Na(go(Kf(go(Kf(new si(null,new pi(e.e.b,16)),new $T),new VT),new Rk),new lq),new cZ(e)),ce(bt(G(e.e,($e(),rL))))&&(g=mc(i,1),ni(g,"Straight Edges Pre-Processing",1),ajt(e),Bn(g)),iDt(e.f),f=h(G(t,F5),21).a*e.f.a.c.length,fne(Epe(Spe(IJ(e.f),f),!1),mc(i,1)),e.d.a._b()!=0){for(g=mc(i,1),ni(g,"Flexible Where Space Processing",1),m=h(hJ(t6(qf(new si(null,new pi(e.f.a,16)),new rq),(pn(new OT),new xr))),21).a,v=h(hJ(W9e(qf(new si(null,new pi(e.f.a,16)),new sq),new _a)),21).a,y=v-m,E=g0(new Fm,e.f),C=g0(new Fm,e.f),Ku(Uu(Fu(Nu(zu(new nu,2e4),y),E),C)),Na(go(go(f1e(e.i),new sN),new oN),new xUe(m,E,y,C)),l=e.d.a.Xb().tc();l.hc();)a=h(l.ic(),189),a.g=1;fne(Epe(Spe(IJ(e.f),f),!1),mc(g,1)),Bn(g)}ce(bt(G(t,rL)))&&(g=mc(i,1),ni(g,"Straight Edges Post-Processing",1),ANt(e),Bn(g)),jGt(e),e.e=null,e.f=null,e.i=null,e.c=null,tl(e.k),e.j=null,e.a=null,e.o=null,e.d.a.Pb(),Bn(i)}function hJe(e,t,i,a,l){var f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae,Ue,qe,ut,ft,Ct,Mt;for(W=new zl(t.b),we=new zl(t.b),R=new zl(t.b),ut=new zl(t.b),V=new zl(t.b),qe=On(t,0);qe.b!=qe.d.c;)for(Ae=h(Fn(qe),11),m=new j(Ae.f);m.a0,ee=Ae.f.c.length>0,y&&ee?R.c[R.c.length]=Ae:y?W.c[W.c.length]=Ae:ee&&(we.c[we.c.length]=Ae);for(N=new j(W);N.a=0&&pt(e.substr(m,2),"//")?(m+=2,v=Kee(e,m,IL,DL),a=e.substr(m,v-m),m=v):C!=null&&(m==e.length||e.charCodeAt(m)!=47)&&(g=!1,v=Pge(e,bc(35),m),v==-1&&(v=e.length),a=e.substr(m,v-m),m=v);if(!i&&m0&&po(E,E.length-1)==58&&(l=E,m=v)),m=R&&(we>R&&(C.c=le(sn,nt,1,0,5,1),R=we),C.c[C.c.length]=V);C.c.length!=0&&(E=h(Tt(C,pte(t,C.c.length)),165),fA(_i.a,E)!=null,E.d=B++,Nve(E,Mt,ut),C.c=le(sn,nt,1,0,5,1))}for(Ue=e.c.length+1,ee=new j(e);ee.aLn.d&&(_f(i),Ea(Ln.b,a),a.c>0&&(a.a=Ln,De(Ln.e,a),a.b=ft,De(ft.b,a)))}function P$t(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae,Ue,qe,ut,ft,Ct,Mt;for(ie=new Kv,fe=new Kv,E=S0(t,_xe),a=new AUe(e,i,ie,fe),fNt(a.a,a.b,a.c,a.d,E),v=(Ue=ie.i,Ue||(ie.i=re(ie.c,122)?new Zv(ie,h(ie.c,122)):re(ie.c,115)?new q2(ie,h(ie.c,115)):new qE(ie,ie.c))),ut=v.tc();ut.hc();)for(qe=h(ut.ic(),270),l=h(Qi(ie,qe),19),W=l.tc();W.hc();)if(N=W.ic(),we=h(Pp(e.d,N),270),we)m=(!qe.e&&(qe.e=new an(es,qe,10,9)),qe.e),$n(m,we);else throw g=$d(t,kh),R=Vet+N+Wet+g,B=R+tM,Y(new vh(B));for(y=(Ae=fe.i,Ae||(fe.i=re(fe.c,122)?new Zv(fe,h(fe.c,122)):re(fe.c,115)?new q2(fe,h(fe.c,115)):new qE(fe,fe.c))),Ct=y.tc();Ct.hc();)for(ft=h(Ct.ic(),270),f=h(Qi(fe,ft),19),ee=f.tc();ee.hc();)if(V=ee.ic(),we=h(Pp(e.d,V),270),we)C=(!ft.g&&(ft.g=new an(es,ft,9,10)),ft.g),$n(C,we);else throw g=$d(t,kh),R=Vet+V+Wet+g,B=R+tM,Y(new vh(B));!i.b&&(i.b=new an(gi,i,4,7)),i.b.i!=0&&(!i.c&&(i.c=new an(gi,i,5,8)),i.c.i!=0)&&(!i.b&&(i.b=new an(gi,i,4,7)),i.b.i<=1&&(!i.c&&(i.c=new an(gi,i,5,8)),i.c.i<=1))&&(!i.a&&(i.a=new ze(es,i,6,6)),i.a).i==1&&(Mt=h(ae((!i.a&&(i.a=new ze(es,i,6,6)),i.a),0),270),!gte(Mt)&&!mte(Mt)&&(Q0e(Mt,h(ae((!i.b&&(i.b=new an(gi,i,4,7)),i.b),0),97)),ebe(Mt,h(ae((!i.c&&(i.c=new an(gi,i,5,8)),i.c),0),97))))}function dJe(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae,Ue,qe,ut;for(e.d=new $t(Kr,Kr),e.c=new $t(Ts,Ts),R=t.tc();R.hc();)for(E=h(R.ic(),31),fe=new j(E.a);fe.a=Ae||!DIt(ee,a))&&(a=y7e(t,E)),qs(ee,a),f=Tn(As(ee));Gn(f);)l=h(Mn(f),14),!e.a[l.o]&&(W=l.c.g,--e.e[W.o],e.e[W.o]==0&&hS(kS(B,W)));for(y=E.c.length-1;y>=0;--y)De(t.b,(oi(y,E.c.length),h(E.c[y],26)));t.a.c=le(sn,nt,1,0,5,1),Bn(i)}function R$t(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae,Ue,qe,ut,ft,Ct,Mt,Ln,_i,os,Zc,lc,tg,Ll,bm,I1,lh,ff;if(Mt=oze(e,pze(i),t),jI(Mt,$d(t,kh)),Ln=h(Pp(e.g,Mx(Hm(t,wre))),35),R=Hm(t,"sourcePort"),a=null,R&&(a=Mx(R)),_i=h(Pp(e.j,a),121),!Ln)throw m=jA(t),N="An edge must have a source node (edge id: '"+m,W=N+tM,Y(new vh(W));if(_i&&!Ip(Eh(_i),Ln))throw v=$d(t,kh),V="The source port of an edge must be a port of the edge's source node (edge id: '"+v,ee=V+tM,Y(new vh(ee));if(ut=(!Mt.b&&(Mt.b=new an(gi,Mt,4,7)),Mt.b),_i?f=_i:f=Ln,$n(ut,f),os=h(Pp(e.g,Mx(Hm(t,Cxe))),35),B=Hm(t,"targetPort"),l=null,B&&(l=Mx(B)),Zc=h(Pp(e.j,l),121),!os)throw C=jA(t),ie="An edge must have a target node (edge id: '"+C,fe=ie+tM,Y(new vh(fe));if(Zc&&!Ip(Eh(Zc),os))throw y=$d(t,kh),we="The target port of an edge must be a port of the edge's target node (edge id: '"+y,Ae=we+tM,Y(new vh(Ae));if(ft=(!Mt.c&&(Mt.c=new an(gi,Mt,5,8)),Mt.c),Zc?g=Zc:g=os,$n(ft,g),(!Mt.b&&(Mt.b=new an(gi,Mt,4,7)),Mt.b).i==0||(!Mt.c&&(Mt.c=new an(gi,Mt,5,8)),Mt.c).i==0)throw E=$d(t,kh),Ue=$et+E,qe=Ue+tM,Y(new vh(qe));return o7(t,Mt),lc=j_(Mt,!0,!0),tg=yI(t,"sourcePoint"),Ll=new RZ(lc),X6t(Ll.a,tg),bm=yI(t,"targetPoint"),I1=new NZ(lc),Y6t(I1.a,bm),lh=S0(t,Sre),ff=new FZ(lc),KBt(ff.a,lh),Ct=mee(e,t,Mt),Ct}function Ine(e,t){_ne();var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae,Ue,qe,ut,ft,Ct,Mt,Ln;if(qe=e.e,B=e.d,l=e.a,qe==0)switch(t){case 0:return"0";case 1:return $S;case 2:return"0.00";case 3:return"0.000";case 4:return"0.0000";case 5:return"0.00000";case 6:return"0.000000";default:return Ae=new u0,t<0?Ae.a+="0E+":Ae.a+="0E",Ae.a+=-t,Ae.a}if(ie=B*10+1+7,fe=le(Yl,Ah,22,ie+1,15,1),i=ie,B==1)if(g=l[0],g<0){Ln=Zr(g,ao);do N=Ln,Ln=h6(Ln,10),fe[--i]=48+nr(Qm(N,Jm(Ln,10)))&Gr;while(Sa(Ln,0)!=0)}else{Ln=g;do N=Ln,Ln=Ln/10|0,fe[--i]=48+(N-Ln*10)&Gr;while(Ln!=0)}else{ft=le(Rn,ii,22,B,15,1),Mt=B,wc(l,0,ft,0,B);e:for(;;){for(Ue=0,v=Mt-1;v>=0;v--)Ct=io(Gd(Ue,32),Zr(ft[v],ao)),V=_Bt(Ct),ft[v]=nr(V),Ue=nr(Pg(V,32));ee=nr(Ue),W=i;do fe[--i]=48+ee%10&Gr;while((ee=ee/10|0)!=0&&i!=0);for(a=9-W+i,m=0;m0;m++)fe[--i]=48;for(E=Mt-1;ft[E]==0;E--)if(E==0)break e;Mt=E+1}for(;fe[i]==48;)++i}if(R=qe<0,f=ie-i-t-1,t==0)return R&&(fe[--i]=45),fu(fe,i,ie-i);if(t>0&&f>=-6){if(f>=0){for(y=i+f,C=ie-1;C>=y;C--)fe[C+1]=fe[C];return fe[++y]=46,R&&(fe[--i]=45),fu(fe,i,ie-i+1)}for(E=2;E<-f+1;E++)fe[--i]=48;return fe[--i]=46,fe[--i]=48,R&&(fe[--i]=45),fu(fe,i,ie-i)}return ut=i+1,we=new Qb,R&&(we.a+="-"),ie-ut>=1?(Lg(we,fe[i]),we.a+=".",we.a+=fu(fe,i+1,ie-i-1)):we.a+=fu(fe,i,ie-i),we.a+="E",f>0&&(we.a+="+"),we.a+=""+f,we.a}function I$t(e,t,i,a){var l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae,Ue,qe,ut,ft,Ct,Mt,Ln,_i,os,Zc,lc,tg,Ll,bm,I1,lh;if(fe=h(ae((!e.b&&(e.b=new an(gi,e,4,7)),e.b),0),97),Ae=fe.Yf(),Ue=fe.Zf(),we=fe.Xf()/2,W=fe.Wf()/2,re(fe,187)&&(ie=h(fe,121),Ae+=Eh(ie).i,Ae+=Eh(ie).i),Ae+=we,Ue+=W,Mt=h(ae((!e.b&&(e.b=new an(gi,e,4,7)),e.b),0),97),_i=Mt.Yf(),os=Mt.Zf(),Ln=Mt.Xf()/2,qe=Mt.Wf()/2,re(Mt,187)&&(Ct=h(Mt,121),_i+=Eh(Ct).i,_i+=Eh(Ct).i),_i+=Ln,os+=qe,(!e.a&&(e.a=new ze(es,e,6,6)),e.a).i==0)m=(h0(),y=new gE,y),$n((!e.a&&(e.a=new ze(es,e,6,6)),e.a),m);else if((!e.a&&(e.a=new ze(es,e,6,6)),e.a).i>1)for(N=new QC((!e.a&&(e.a=new ze(es,e,6,6)),e.a));N.e!=N.i._b();)KA(N);for(g=h(ae((!e.a&&(e.a=new ze(es,e,6,6)),e.a),0),270),V=_i,_i>Ae+we?V=Ae+we:_iUe+W?ee=Ue+W:osAe-we&&VUe-W&&ee_i+Ln?ut=_i+Ln:Ae<_i-Ln&&(ut=_i-Ln),ft=Ue,Ue>os+qe?ft=os+qe:Ue_i-Ln&&ut<_i+Ln&&ft>os-qe&&fti&&(R=i-1),B=bm+ol(t,24)*W6*C-C/2,B<0?B=1:B>a&&(B=a-1),l=(h0(),v=new pE,v),see(l,R),oee(l,B),$n((!g.a&&(g.a=new vs(sh,g,5)),g.a),l)}function pJe(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee;for(a=new Re,m=new Re,V=t/2,B=e._b(),l=h(e.cd(0),9),ee=h(e.cd(1),9),N=Kte(l.a,l.b,ee.a,ee.b,V),De(a,(oi(0,N.c.length),h(N.c[0],9))),De(m,(oi(1,N.c.length),h(N.c[1],9))),y=2;y=0;v--)Gi(i,(oi(v,g.c.length),h(g.c[v],9)));return i}function D$t(e){var t,i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae,Ue,qe,ut,ft,Ct,Mt,Ln;if(qe=h(G(e,($e(),Yi)),83),qe!=(Ms(),rp)&&qe!=ub){for(N=e.b,B=N.c.length,E=new zl((xf(B+2,zne),NI(io(io(5,B+2),(B+2)/10|0)))),W=new zl((xf(B+2,zne),NI(io(io(5,B+2),(B+2)/10|0)))),De(E,new li),De(E,new li),De(W,new Re),De(W,new Re),Ue=new Re,t=0;tMt?C:Mt;for(a=new j(ft.f);a.aMt?ut:Mt}Ee(we,XG,He(C)),Ee(we,YG,He(ut))}for(ee=0,B=new j(t.b);B.a=e.j){e.a=-1,e.c=1;return}if(t=po(e.i,e.d++),e.a=t,e.b==1){switch(t){case 92:if(a=10,e.d>=e.j)throw Y(new Wn(Yn((zn(),wz))));e.a=po(e.i,e.d++);break;case 45:(e.e&512)==512&&e.d=e.j||po(e.i,e.d)!=63)break;if(++e.d>=e.j)throw Y(new Wn(Yn((zn(),Are))));switch(t=po(e.i,e.d++),t){case 58:a=13;break;case 61:a=14;break;case 33:a=15;break;case 91:a=19;break;case 62:a=18;break;case 60:if(e.d>=e.j)throw Y(new Wn(Yn((zn(),Are))));if(t=po(e.i,e.d++),t==61)a=16;else if(t==33)a=17;else throw Y(new Wn(Yn((zn(),Yet))));break;case 35:for(;e.d=e.j)throw Y(new Wn(Yn((zn(),wz))));e.a=po(e.i,e.d++);break;default:a=0}e.c=a}function gJe(e){var t,i,a,l,f,g,m,v,y;for(e.b=1,wi(e),t=null,e.c==0&&e.a==94?(wi(e),t=(vi(),vi(),++_r,new vl(4)),Ia(t,0,iM),m=(++_r,new vl(4))):m=(vi(),vi(),++_r,new vl(4)),l=!0;(y=e.c)!=1;){if(y==0&&e.a==93&&!l){t&&(mP(t,m),m=t);break}if(i=e.a,a=!1,y==10)switch(i){case 100:case 68:case 119:case 87:case 115:case 83:Mw(m,NS(i)),a=!0;break;case 105:case 73:case 99:case 67:i=(Mw(m,NS(i)),-1),a=!0;break;case 112:case 80:if(v=bve(e,i),!v)throw Y(new Wn(Yn((zn(),Pre))));Mw(m,v),a=!0;break;default:i=Kve(e)}else if(y==24&&!l){if(t&&(mP(t,m),m=t),f=gJe(e),mP(m,f),e.c!=0||e.a!=93)throw Y(new Wn(Yn((zn(),stt))));break}if(wi(e),!a){if(y==0){if(i==91)throw Y(new Wn(Yn((zn(),Rxe))));if(i==93)throw Y(new Wn(Yn((zn(),Ixe))));if(i==45&&!l&&e.a!=93)throw Y(new Wn(Yn((zn(),Lre))))}if(e.c!=0||e.a!=45||i==45&&l)Ia(m,i,i);else{if(wi(e),(y=e.c)==1)throw Y(new Wn(Yn((zn(),vz))));if(y==0&&e.a==93)Ia(m,i,i),Ia(m,45,45);else{if(y==0&&e.a==93||y==24)throw Y(new Wn(Yn((zn(),Lre))));if(g=e.a,y==0){if(g==91)throw Y(new Wn(Yn((zn(),Rxe))));if(g==93)throw Y(new Wn(Yn((zn(),Ixe))));if(g==45)throw Y(new Wn(Yn((zn(),Lre))))}else y==10&&(g=Kve(e));if(wi(e),i>g)throw Y(new Wn(Yn((zn(),ctt))));Ia(m,i,g)}}}l=!1}if(e.c==1)throw Y(new Wn(Yn((zn(),vz))));return U_(m),gP(m),e.b=0,wi(e),m}function O$t(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae,Ue,qe,ut,ft,Ct,Mt,Ln,_i,os,Zc,lc;for(ni(i,"Greedy cycle removal",1),ie=t.a,lc=ie.c.length,e.a=le(Rn,ii,22,lc,15,1),e.c=le(Rn,ii,22,lc,15,1),e.b=le(Rn,ii,22,lc,15,1),v=0,V=new j(ie);V.a0?Ct+1:1);for(f=new j(Ae.f);f.a0?Ct+1:1)}e.c[v]==0?Gi(e.d,N):e.a[v]==0&&Gi(e.e,N),++v}for(B=-1,R=1,E=new Re,Mt=h(G(t,(Ie(),pM)),214);lc>0;){for(;e.d.b!=0;)_i=h(FJ(e.d),8),e.b[_i.o]=B--,f_e(e,_i),--lc;for(;e.e.b!=0;)os=h(FJ(e.e),8),e.b[os.o]=R++,f_e(e,os),--lc;if(lc>0){for(C=zs,ee=new j(ie);ee.a=C&&(fe>C&&(E.c=le(sn,nt,1,0,5,1),C=fe),E.c[E.c.length]=N));y=h(Tt(E,pte(Mt,E.c.length)),8),e.b[y.o]=R++,f_e(e,y),--lc}}for(Ln=ie.c.length+1,v=0;ve.b[Zc]&&(Qg(a,!0),Ee(t,TG,(vt(),vt(),!0)));e.a=null,e.c=null,e.b=null,id(e.e),id(e.d),Bn(i)}function N$t(e){Nn(e.c,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#decimal"])),Nn(e.d,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#integer"])),Nn(e.e,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#boolean"])),Nn(e.f,Kn,X(q(Se,1),be,2,6,[Ls,"EBoolean",mi,"EBoolean:Object"])),Nn(e.i,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#byte"])),Nn(e.g,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#hexBinary"])),Nn(e.j,Kn,X(q(Se,1),be,2,6,[Ls,"EByte",mi,"EByte:Object"])),Nn(e.n,Kn,X(q(Se,1),be,2,6,[Ls,"EChar",mi,"EChar:Object"])),Nn(e.t,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#double"])),Nn(e.u,Kn,X(q(Se,1),be,2,6,[Ls,"EDouble",mi,"EDouble:Object"])),Nn(e.F,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#float"])),Nn(e.G,Kn,X(q(Se,1),be,2,6,[Ls,"EFloat",mi,"EFloat:Object"])),Nn(e.I,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#int"])),Nn(e.J,Kn,X(q(Se,1),be,2,6,[Ls,"EInt",mi,"EInt:Object"])),Nn(e.N,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#long"])),Nn(e.O,Kn,X(q(Se,1),be,2,6,[Ls,"ELong",mi,"ELong:Object"])),Nn(e.Z,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#short"])),Nn(e.$,Kn,X(q(Se,1),be,2,6,[Ls,"EShort",mi,"EShort:Object"])),Nn(e._,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#string"]))}function F_e(e,t,i,a){var l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae,Ue,qe,ut,ft,Ct,Mt,Ln,_i;if(yZe(t),v=h(ae((!t.b&&(t.b=new an(gi,t,4,7)),t.b),0),97),E=h(ae((!t.c&&(t.c=new an(gi,t,5,8)),t.c),0),97),m=Ra(v),y=Ra(E),g=(!t.a&&(t.a=new ze(es,t,6,6)),t.a).i==0?null:h(ae((!t.a&&(t.a=new ze(es,t,6,6)),t.a),0),270),qe=h(Ii(e.a,m),8),Mt=h(Ii(e.a,y),8),ut=null,Ln=null,re(v,187)&&(Ue=h(Ii(e.a,v),279),re(Ue,11)?ut=h(Ue,11):re(Ue,8)&&(qe=h(Ue,8),ut=h(Tt(qe.i,0),11))),re(E,187)&&(Ct=h(Ii(e.a,E),279),re(Ct,11)?Ln=h(Ct,11):re(Ct,8)&&(Mt=h(Ct,8),Ln=h(Tt(Mt.i,0),11))),!qe||!Mt)return null;for(W=new Bp,Oo(W,t),Ee(W,(Ie(),Jn),t),Ee(W,($e(),Po),null),B=h(G(a,$a),19),qe==Mt&&B.nc((xo(),C5)),ut||(Ae=(Bo(),cc),ft=null,g&&Dd(h(G(qe,Yi),83))&&(ft=new $t(g.j,g.k),wze(ft,V9(t)),zze(ft,i),SA(y,m)&&(Ae=Nc,tr(ft,qe.k))),ut=aKe(qe,ft,Ae,a)),Ln||(Ae=(Bo(),Nc),_i=null,g&&Dd(h(G(Mt,Yi),83))&&(_i=new $t(g.b,g.c),wze(_i,V9(t)),zze(_i,i)),Ln=aKe(Mt,_i,Ae,wa(Mt))),Os(W,ut),_s(W,Ln),R=new Dn((!t.n&&(t.n=new ze(Qo,t,1,7)),t.n));R.e!=R.i._b();)if(C=h(Xn(R),137),!ce(bt(nn(C,x1)))&&C.a)switch(V=$ee(C),De(W.b,V),h(G(V,am),226).g){case 2:case 3:B.nc((xo(),hM));break;case 1:case 0:B.nc((xo(),fM)),Ee(V,am,(Xd(),xL))}if(f=h(G(a,gM),317),ee=h(G(a,FG),292),l=f==(ux(),S5)||ee==(XA(),Toe),g&&(!g.a&&(g.a=new vs(sh,g,5)),g.a).i!=0&&l){for(ie=m6(g),N=new Uc,we=On(ie,0);we.b!=we.d.c;)fe=h(Fn(we),9),Gi(N,new Io(fe));Ee(W,KSe,N)}return W}function U_e(e,t,i,a,l,f){var g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae,Ue,qe,ut,ft,Ct,Mt,Ln,_i;for(m=h(Tt(e.d.c.b,a),26),Mt=new Ur,B=new Ur,R=0;Ri&&(ut=B.a.Zb(ee,B),ut==null);for(Ln=new Ur,N=new Ur,fe=Mt.a.Xb().tc();fe.hc();)for(ee=h(fe.ic(),8),g=t==1?ur(ee):As(ee),y=(So(),new Od(Zh(zd(g.a,new z))));Gn(y);)v=h(Mn(y),14),Gu(ee.c)!=Gu(v.d.g.c)&&Cr(Ln,v.d.g);for(we=B.a.Xb().tc();we.hc();)for(ee=h(we.ic(),8),g=t==1?ur(ee):As(ee),y=(So(),new Od(Zh(zd(g.a,new z))));Gn(y);)v=h(Mn(y),14),Gu(ee.c)!=Gu(v.d.g.c)&&Cr(N,v.d.g);for(ert&&Kh(),qe=h(Tt(e.d.c.b,a+(t==1?1:-1)),26),W=zs,V=zi,C=0;CC?W:C:N.a.Qb(ee)&&(V=VC&&(Mt=0,Ln+=E+qe,E=0),s9t(Ae,g,Mt,Ln),t=w.Math.max(t,Mt+Ue.a),E=w.Math.max(E,Ue.b),Mt+=Ue.a+qe;for(we=new li,i=new li,ft=new j(e);ft.a=2){for(R=!0,ie=(oi(1,C.c.length),h(C.c[1],26)),W=new j(g.a);W.a=2){for(R=!0,fe=h(Tt(C,C.c.length-2),26),W=new j(v.a);W.aJte(f))&&(C=f);for(!C&&(C=(oi(0,V.c.length),h(V.c[0],164))),W=new j(t.b);W.a0?(N=(Ae+1)*e.d,N=0&&(hf+=(Ae+2)*e.d)}fe=Ct,m=v}while(Ct);for(l=new j(e.j);l.a=-1900?1:0,i>=4?Si(e,X(q(Se,1),be,2,6,[RJe,IJe])[m]):Si(e,X(q(Se,1),be,2,6,["BC","AD"])[m]);break;case 121:R5t(e,i,a);break;case 77:ZUt(e,i,a);break;case 107:v=l.q.getHours(),v==0?od(e,24,i):od(e,v,i);break;case 83:U8t(e,i,l);break;case 69:E=a.q.getDay(),i==5?Si(e,X(q(Se,1),be,2,6,["S","M","T","W","T","F","S"])[E]):i==4?Si(e,X(q(Se,1),be,2,6,[tie,nie,iie,rie,sie,oie,aie])[E]):Si(e,X(q(Se,1),be,2,6,["Sun","Mon","Tue","Wed","Thu","Fri","Sat"])[E]);break;case 97:l.q.getHours()>=12&&l.q.getHours()<24?Si(e,X(q(Se,1),be,2,6,["AM","PM"])[1]):Si(e,X(q(Se,1),be,2,6,["AM","PM"])[0]);break;case 104:C=l.q.getHours()%12,C==0?od(e,12,i):od(e,C,i);break;case 75:R=l.q.getHours()%12,od(e,R,i);break;case 72:B=l.q.getHours(),od(e,B,i);break;case 99:N=a.q.getDay(),i==5?Si(e,X(q(Se,1),be,2,6,["S","M","T","W","T","F","S"])[N]):i==4?Si(e,X(q(Se,1),be,2,6,[tie,nie,iie,rie,sie,oie,aie])[N]):i==3?Si(e,X(q(Se,1),be,2,6,["Sun","Mon","Tue","Wed","Thu","Fri","Sat"])[N]):od(e,N,1);break;case 76:W=a.q.getMonth(),i==5?Si(e,X(q(Se,1),be,2,6,["J","F","M","A","M","J","J","A","S","O","N","D"])[W]):i==4?Si(e,X(q(Se,1),be,2,6,[Vne,Wne,Hne,qne,Dx,Xne,Yne,Zne,Kne,Jne,Qne,eie])[W]):i==3?Si(e,X(q(Se,1),be,2,6,["Jan","Feb","Mar","Apr",Dx,"Jun","Jul","Aug","Sep","Oct","Nov","Dec"])[W]):od(e,W+1,i);break;case 81:V=a.q.getMonth()/3|0,i<4?Si(e,X(q(Se,1),be,2,6,["Q1","Q2","Q3","Q4"])[V]):Si(e,X(q(Se,1),be,2,6,["1st quarter","2nd quarter","3rd quarter","4th quarter"])[V]);break;case 100:ee=a.q.getDate(),od(e,ee,i);break;case 109:y=l.q.getMinutes(),od(e,y,i);break;case 115:g=l.q.getSeconds(),od(e,g,i);break;case 122:i<4?Si(e,f.c[0]):Si(e,f.c[1]);break;case 118:Si(e,f.b);break;case 90:i<3?Si(e,QNt(f)):i==3?Si(e,iFt(f)):Si(e,rFt(f.a));break;default:return!1}return!0}function G_e(){G_e=M;var e;rMe=(e=h(ml(jse),10),new Bc(e,h(Qc(e,e.length),10),0)),krt=new ln(Iye,rMe),Hrt=new ln(Dye,(vt(),vt(),!1)),fMe=(Q9(),noe),Zrt=new ln(nz,fMe),ust=new ln(Bye,!1),fst=new ln(Oye,!0),He(1),kst=new ln(Nye,He(7)),Rst=new ln(Fye,!1),Sst=new ln(Uye,!1),aMe=(EU(),Vse),Nrt=new ln(Bie,aMe),pMe=(u7(),Eoe),cst=new ln(t5,pMe),hMe=(hu(),i3),tst=new ln(zye,hMe),gMe=(bx(),W5),lst=new ln(Gye,gMe),He(-1),nst=new ln(Oie,He(4)),He(-1),rst=new ln(Nie,He(2)),dMe=(G_(),$G),ast=new ln(Fie,dMe),He(0),ost=new ln(Uie,He(0)),Qrt=new ln(zie,He(zi)),oMe=(ux(),M5),Ort=new ln(Gie,oMe),Drt=new ln(jye,.1),Brt=new ln($ye,!1),He(0),Rrt=new ln(Vye,He(40)),sMe=(mS(),toe),Irt=new ln(Wye,sMe),vMe=(XA(),U5),Est=new ln(YS,vMe),mst=new Sr(jie),mMe=(RI(),ZG),hst=new ln($ie,mMe),bMe=(g6(),vG),pst=new ln(Vie,bMe),new TE,wst=new ln(Wie,.3),_st=new Sr(Hie),wMe=(ww(),jG),yst=new ln(Hye,wMe),uMe=(WU(),Aoe),zrt=new ln(qie,uMe),Vrt=new ln(iz,!0),jrt=new ln(rz,.4),Pst=new ln(qye,10),Ast=new ln(Xye,10),Lst=new ln(Yye,20),He(0),Mst=new ln(Zye,He(0)),He(0),Tst=new ln(Kye,He(0)),He(0),Cst=new ln(Jye,He(0)),Art=new ln(Xie,!1),iMe=(RS(),ZP),Lrt=new ln(Qye,iMe),nMe=(sU(),Gse),Prt=new ln(e2e,nMe),Xrt=new ln(sz,!1),He(0),qrt=new ln(Yie,He(16)),He(0),Yrt=new ln(Zie,He(5)),EMe=(LU(),Loe),Xst=new ln(TP,EMe),Ist=new ln(t2e,10),Dst=new ln(n2e,1),yMe=(wU(),bG),Ust=new ln(oz,yMe),Bst=new Sr(Kie),_Me=He(1),He(0),Nst=new ln(Jie,_Me),xMe=(yU(),Poe),Hst=new ln(Qie,xMe),jst=new ln(az,!0),zst=new ln(cz,2),Vst=new ln(ere,!0),lMe=(d7(),wG),Urt=new ln(i2e,lMe),cMe=(JA(),Use),Frt=new ln(r2e,cMe),Jrt=Wse,Krt=S5,ist=GG,sst=GG,est=xoe,bst=z5,dst=U5,gst=U5,vst=Coe,xst=z5,Grt=(cd(),cb),Wrt=cb,$rt=cb,Ost=$se,Fst=bG,qst=koe,$st=H5,Gst=H5,Wst=H5}function lr(){lr=M;var e,t;yCe=new Sr(iet),xCe=(ld(),Qoe),dct=new ln(x2e,xCe),new TE,_M=new ln(VS,null),pct=new Sr(cxe),nae=new ln(nre,(vt(),vt(),!1)),SCe=(Xs(),Bh),vL=new ln(rre,SCe),CCe=(cd(),gae),TCe=new ln(n5,CCe),wct=new ln(oxe,!1),LCe=(e1(),vj),Ey=new ln(E2e,LCe),FCe=new ex(12),Sy=new ln(Fx,FCe),rae=new ln(Q7,!1),$Ce=(Ms(),ub),nD=new ln(kie,$Ce),u3=new Sr(fz),mj=new Sr(Y6),fae=new Sr(J7),hae=new Sr(Z6),kCe=new Uc,l3=new ln(D2e,kCe),mct=new ln(F2e,!1),vct=new ln(U2e,!1),new Sr(ret),RCe=new z2,dj=new ln($2e,RCe),sae=new ln(_2e,!1),new TE,Sct=new ln(set,1),new ln(oet,!0),He(0),new ln(aet,He(100)),new ln(cet,!1),He(0),new ln(uet,He(4e3)),He(0),new ln(fet,He(400)),new ln(het,!1),new ln(det,!0),new ln(pet,!1),ECe=(XU(),yae),gct=new ln(axe,ECe),HCe=new ln(Mie,12),Mct=new ln(h2e,10),qCe=new ln(Lie,2),Tct=new ln(d2e,10),XCe=new ln(p2e,0),bj=new ln(m2e,5),YCe=new ln(g2e,1),My=new ln(HS,20),JCe=new ln(b2e,10),dae=new Sr(w2e),KCe=new jNe,ZCe=new ln(V2e,KCe),xct=new Sr(j2e),UCe=!1,yct=new ln(G2e,UCe),ICe=new ex(5),_ct=new ln(get,ICe),DCe=(a1(),t=h(ml(Zs),10),new Bc(t,h(Qc(t,t.length),10),0)),pj=new ln(T2e,DCe),GCe=(Xg(),lb),zCe=new ln(P2e,GCe),aae=new Sr(L2e),cae=new Sr(k2e),lae=new Sr(R2e),oae=new Sr(I2e),BCe=(e=h(ml(AL),10),new Bc(e,h(Qc(e,e.length),10),0)),yM=new ln(lz,BCe),NCe=Wt((ac(),EM)),gj=new ln(ire,NCe),OCe=new $t(0,0),tD=new ln(uz,OCe),MCe=(Xd(),wj),eD=new ln(B2e,MCe),bct=new ln(O2e,!1),new Sr(met),He(1),new ln(bet,null),jCe=new Sr(z2e),Ect=new Sr(N2e),WCe=(Fe(),Oa),_L=new ln(y2e,WCe),Yc=new Sr(v2e),VCe=(Jf(),Ty),uae=new ln(C2e,VCe),iD=new ln(A2e,!1),hj=new ln(S2e,!1),iae=new ln(M2e,!1),ACe=new ln(Tie,1),PCe=(f7(),bae),new ln(wet,PCe)}function $$t(e){e.gb||(e.gb=!0,e.b=ia(e,0),vr(e.b,18),Ki(e.b,19),e.a=ia(e,1),vr(e.a,1),Ki(e.a,2),Ki(e.a,3),Ki(e.a,4),Ki(e.a,5),e.o=ia(e,2),vr(e.o,8),vr(e.o,9),Ki(e.o,10),Ki(e.o,11),Ki(e.o,12),Ki(e.o,13),Ki(e.o,14),Ki(e.o,15),Ki(e.o,16),Ki(e.o,17),Ki(e.o,18),Ki(e.o,19),Ki(e.o,20),Ki(e.o,21),Ki(e.o,22),Ki(e.o,23),Mo(e.o),Mo(e.o),Mo(e.o),Mo(e.o),Mo(e.o),Mo(e.o),Mo(e.o),Mo(e.o),Mo(e.o),Mo(e.o),e.p=ia(e,3),vr(e.p,2),vr(e.p,3),vr(e.p,4),vr(e.p,5),Ki(e.p,6),Ki(e.p,7),Mo(e.p),Mo(e.p),e.q=ia(e,4),vr(e.q,8),e.v=ia(e,5),Ki(e.v,9),Mo(e.v),Mo(e.v),Mo(e.v),e.w=ia(e,6),vr(e.w,2),vr(e.w,3),vr(e.w,4),Ki(e.w,5),e.B=ia(e,7),Ki(e.B,1),Mo(e.B),Mo(e.B),Mo(e.B),e.Q=ia(e,8),Ki(e.Q,0),Mo(e.Q),e.R=ia(e,9),vr(e.R,1),e.S=ia(e,10),Mo(e.S),Mo(e.S),Mo(e.S),Mo(e.S),Mo(e.S),Mo(e.S),Mo(e.S),Mo(e.S),Mo(e.S),Mo(e.S),Mo(e.S),Mo(e.S),Mo(e.S),Mo(e.S),Mo(e.S),e.T=ia(e,11),Ki(e.T,10),Ki(e.T,11),Ki(e.T,12),Ki(e.T,13),Ki(e.T,14),Mo(e.T),Mo(e.T),e.U=ia(e,12),vr(e.U,2),vr(e.U,3),Ki(e.U,4),Ki(e.U,5),Ki(e.U,6),Ki(e.U,7),Mo(e.U),e.V=ia(e,13),Ki(e.V,10),e.W=ia(e,14),vr(e.W,18),vr(e.W,19),vr(e.W,20),Ki(e.W,21),Ki(e.W,22),Ki(e.W,23),e.bb=ia(e,15),vr(e.bb,10),vr(e.bb,11),vr(e.bb,12),vr(e.bb,13),vr(e.bb,14),vr(e.bb,15),vr(e.bb,16),Ki(e.bb,17),Mo(e.bb),Mo(e.bb),e.eb=ia(e,16),vr(e.eb,2),vr(e.eb,3),vr(e.eb,4),vr(e.eb,5),vr(e.eb,6),vr(e.eb,7),Ki(e.eb,8),Ki(e.eb,9),e.ab=ia(e,17),vr(e.ab,0),vr(e.ab,1),e.H=ia(e,18),Ki(e.H,0),Ki(e.H,1),Ki(e.H,2),Ki(e.H,3),Ki(e.H,4),Ki(e.H,5),Mo(e.H),e.db=ia(e,19),Ki(e.db,2),e.c=fi(e,20),e.d=fi(e,21),e.e=fi(e,22),e.f=fi(e,23),e.i=fi(e,24),e.g=fi(e,25),e.j=fi(e,26),e.k=fi(e,27),e.n=fi(e,28),e.r=fi(e,29),e.s=fi(e,30),e.t=fi(e,31),e.u=fi(e,32),e.fb=fi(e,33),e.A=fi(e,34),e.C=fi(e,35),e.D=fi(e,36),e.F=fi(e,37),e.G=fi(e,38),e.I=fi(e,39),e.J=fi(e,40),e.L=fi(e,41),e.M=fi(e,42),e.N=fi(e,43),e.O=fi(e,44),e.P=fi(e,45),e.X=fi(e,46),e.Y=fi(e,47),e.Z=fi(e,48),e.$=fi(e,49),e._=fi(e,50),e.cb=fi(e,51),e.K=fi(e,52))}function Ie(){Ie=M;var e,t;Jn=new Sr(yye),XSe=new Sr("coordinateOrigin"),coe=new Sr("processors"),qSe=new Yr("compoundNode",(vt(),vt(),!1)),L5=new Yr("insideConnections",!1),gd=new Sr("nestedLGraph"),sm=new Sr("parentLNode"),KSe=new Sr("originalBendpoints"),JSe=new Sr("originalDummyNodePosition"),QSe=new Sr("originalLabelEdge"),LG=new Sr("representedLabels"),CG=new Sr("endLabels"),e3=new Yr("labelSide",(yl(),fD)),my=new Yr("maxEdgeThickness",0),om=new Yr("reversed",!1),pM=new Sr(xye),Tl=new Yr("longEdgeSource",null),Cl=new Yr("longEdgeTarget",null),t3=new Yr("longEdgeHasLabelDummies",!1),k5=new Yr("longEdgeBeforeLabelDummy",!1),roe=new Yr("edgeConstraint",(M_(),Hse)),dM=new Sr("inLayerLayoutUnit"),y1=new Yr("inLayerConstraint",(Wd(),A5)),Qx=new Yr("inLayerSuccessorConstraint",new Re),Al=new Sr("portDummy"),MG=new Yr("crossingHint",He(0)),$a=new Yr("graphProperties",(t=h(ml(Qse),10),new Bc(t,h(Qc(t,t.length),10),0))),da=new Yr("externalPortSide",(Fe(),Oa)),ZSe=new Yr("externalPortSize",new fo),soe=new Sr("externalPortReplacedDummies"),AG=new Sr("externalPortReplacedDummy"),Jx=new Yr("externalPortConnections",(e=h(ml(xc),10),new Bc(e,h(Qc(e,e.length),10),0))),eb=new Yr(PQe,0),WSe=new Sr("barycenterAssociates"),n3=new Sr("TopSideComments"),Kx=new Sr("BottomSideComments"),SG=new Sr("CommentConnectionPort"),ooe=new Yr("inputCollect",!1),aoe=new Yr("outputCollect",!1),TG=new Yr("cyclic",!1),P5=new Yr("bigNodeOriginalSize",new Yb(0)),Ow=new Yr("bigNodeInitial",!1),HSe=new Yr("org.eclipse.elk.alg.layered.bigNodeLabels",new Re),ioe=new Yr("org.eclipse.elk.alg.layered.postProcess",null),YSe=new Sr("crossHierarchyMap"),foe=new Sr("targetOffset"),Trt=new Yr("splineLabelSize",new fo),R5=new Yr("splineLoopSide",(cl(),c3)),uoe=new Yr("splineSelfLoopComponents",new Re),eMe=new Yr("splineSelfLoopMargins",new z2),Nw=new Sr("spacings"),PG=new Yr("partitionConstraint",!1),Q0=new Sr("breakingPoint.info"),JP=new Sr("splines.route.start"),loe=new Sr("splines.edgeChain")}function Co(){Co=M,nSe=new Dr("LEFT_DIR_PREPROCESSOR",0),jEe=new Dr("DOWN_DIR_PREPROCESSOR",1),mSe=new Dr("UP_DIR_PREPROCESSOR",2),zEe=new Dr("COMMENT_PREPROCESSOR",3),qP=new Dr("EDGE_AND_LAYER_CONSTRAINT_EDGE_REVERSER",4),hSe=new Dr("SPLINE_SELF_LOOP_PREPROCESSOR",5),kse=new Dr("INTERACTIVE_EXTERNAL_PORT_POSITIONER",6),aSe=new Dr("PARTITION_PREPROCESSOR",7),Pse=new Dr("BIG_NODES_PREPROCESSOR",8),aG=new Dr("LABEL_DUMMY_INSERTER",9),YEe=new Dr("HIGH_DEGREE_NODE_LAYER_PROCESSOR",10),oSe=new Dr("PARTITION_POSTPROCESSOR",11),rSe=new Dr("NODE_PROMOTION",12),uM=new Dr("LAYER_CONSTRAINT_PROCESSOR",13),HEe=new Dr("HIERARCHICAL_PORT_CONSTRAINT_PROCESSOR",14),Ase=new Dr("BIG_NODES_INTERMEDIATEPROCESSOR",15),lSe=new Dr("SEMI_INTERACTIVE_CROSSMIN_PROCESSOR",16),BEe=new Dr("BREAKING_POINT_INSERTER",17),Dse=new Dr("LONG_EDGE_SPLITTER",18),Ose=new Dr("PORT_SIDE_PROCESSOR",19),oG=new Dr("INVERTED_PORT_PROCESSOR",20),cSe=new Dr("SELF_LOOP_PROCESSOR",21),Bse=new Dr("PORT_LIST_SORTER",22),fG=new Dr("NORTH_SOUTH_PORT_PREPROCESSOR",23),OEe=new Dr("BREAKING_POINT_PROCESSOR",24),sSe=new Dr(EQe,25),pSe=new Dr(SQe,26),fSe=new Dr("SPLINE_SELF_LOOP_POSITIONER",27),uSe=new Dr("SINGLE_EDGE_GRAPH_WRAPPER",28),Rse=new Dr("IN_LAYER_CONSTRAINT_PROCESSOR",29),Lse=new Dr("BIG_NODES_SPLITTER",30),$Ee=new Dr("END_NODE_PORT_LABEL_MANAGEMENT_PROCESSOR",31),QEe=new Dr("LABEL_AND_NODE_SIZE_PROCESSOR",32),dSe=new Dr("SPLINE_SELF_LOOP_ROUTER",33),iSe=new Dr("NODE_MARGIN_CALCULATOR",34),sG=new Dr("END_LABEL_PREPROCESSOR",35),lG=new Dr("LABEL_DUMMY_SWITCHER",36),FEe=new Dr("CENTER_LABEL_MANAGEMENT_PROCESSOR",37),lM=new Dr("LABEL_SIDE_SELECTOR",38),KEe=new Dr("HYPEREDGE_DUMMY_MERGER",39),qEe=new Dr("HIERARCHICAL_PORT_DUMMY_SIZE_PROCESSOR",40),eSe=new Dr("LAYER_SIZE_AND_GRAPH_HEIGHT_CALCULATOR",41),XP=new Dr("HIERARCHICAL_PORT_POSITION_PROCESSOR",42),E5=new Dr("BIG_NODES_POSTPROCESSOR",43),UEe=new Dr("COMMENT_POSTPROCESSOR",44),JEe=new Dr("HYPERNODE_PROCESSOR",45),XEe=new Dr("HIERARCHICAL_PORT_ORTHOGONAL_EDGE_ROUTER",46),Ise=new Dr("LONG_EDGE_JOINER",47),NEe=new Dr("BREAKING_POINT_REMOVER",48),uG=new Dr("NORTH_SOUTH_PORT_POSTPROCESSOR",49),ZEe=new Dr("HORIZONTAL_COMPACTOR",50),cG=new Dr("LABEL_DUMMY_REMOVER",51),VEe=new Dr("FINAL_SPLINE_BENDPOINTS_CALCULATOR",52),hG=new Dr("REVERSED_EDGE_RESTORER",53),rG=new Dr("END_LABEL_POSTPROCESSOR",54),WEe=new Dr("HIERARCHICAL_NODE_RESIZER",55),tSe=new Dr("LEFT_DIR_POSTPROCESSOR",56),GEe=new Dr("DOWN_DIR_POSTPROCESSOR",57),gSe=new Dr("UP_DIR_POSTPROCESSOR",58)}function V$t(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae,Ue,qe,ut,ft,Ct,Mt,Ln,_i,os,Zc,lc,tg,Ll,bm,I1,lh,ff,hf,kM,TD,CD,x3,Gae,UL,Nut,mPe,vb,zL,jae,E3,GL,ov,jL,$ae,Fut;for(mPe=0,Ln=0,Zc=t.length;Ln0&&(e.a[ff.o]=mPe++)}for(GL=0,_i=0,lc=i.length;_i0;){for(ff=(kn(CD.b>0),h(CD.a.cd(CD.c=--CD.b),11)),TD=0,m=new j(ff.d);m.a0&&(ff.i==(Fe(),bn)?(e.a[ff.o]=GL,++GL):(e.a[ff.o]=GL+tg+bm,++bm))}GL+=bm}for(kM=(Xr(),new li),B=new zc,Mt=0,os=t.length;Mty.b&&(y.b=x3)):ff.g.c==Nut&&(x3y.c&&(y.c=x3));for(DI(N,0,N.length,null),E3=le(Rn,ii,22,N.length,15,1),a=le(Rn,ii,22,GL+1,15,1),V=0;V0;)Ue%2>0&&(l+=$ae[Ue+1]),Ue=(Ue-1)/2|0,++$ae[Ue];for(ut=le(Pot,nt,336,N.length*2,0,1),fe=0;fe'?":pt(Yet,e)?"'(?<' or '(? toIndex: ",sye=", toIndex: ",VJe="org.eclipse.elk.alg.common.compaction",WJe="Scanline/EventHandler",hd="org.eclipse.elk.alg.common.compaction.oned",HJe="CNode belongs to another CGroup.",qJe="ISpacingsHandler/1",mie="The ",bie=" instance has been finished already.",XJe="The direction ",YJe=" is not supported by the CGraph instance.",ZJe="OneDimensionalCompactor",KJe="OneDimensionalCompactor/lambda$0$Type",JJe="Quadruplet",QJe="ScanlineConstraintCalculator",eQe="ScanlineConstraintCalculator/ConstraintsScanlineHandler",tQe="ScanlineConstraintCalculator/ConstraintsScanlineHandler/lambda$0$Type",nQe="ScanlineConstraintCalculator/Timestamp",iQe="ScanlineConstraintCalculator/lambda$0$Type",Qu={138:1,56:1},wie="org.eclipse.elk.alg.common.compaction.options",Ya="org.eclipse.elk.core.data",oye="org.eclipse.elk.polyomino.traversalStrategy",aye="org.eclipse.elk.polyomino.lowLevelSort",cye="org.eclipse.elk.polyomino.highLevelSort",lye="org.eclipse.elk.polyomino.fill",dd={154:1},vie="polyomino",Ph="org.eclipse.elk.alg.common.compaction.polyomino",X7="org.eclipse.elk.alg.common.compaction.polyomino.structures",uye="Direction",_ie="Grid is only of size ",yie=". Requested point (",xie=") is out of bounds.",Y7=" Given center based coordinates were (",q6="org.eclipse.elk.graph.properties",rQe="IPropertyHolder",Eie={3:1,93:1,131:1},K_={244:1},vP="org.eclipse.elk.core",sQe="Connected Components Compaction",oQe="org.eclipse.elk.alg.disco",Z7="org.eclipse.elk.alg.disco.graph",Sie="org.eclipse.elk.alg.disco.options",aQe="CompactionStrategy",fye="org.eclipse.elk.disco.componentCompaction.strategy",hye="org.eclipse.elk.disco.componentCompaction.componentLayoutAlgorithm",dye="org.eclipse.elk.disco.debug.discoGraph",pye="org.eclipse.elk.disco.debug.discoPolys",cQe="componentCompaction",u1="org.eclipse.elk.disco",Mie="org.eclipse.elk.spacing.componentComponent",Tie="org.eclipse.elk.edge.thickness",VS="org.eclipse.elk.aspectRatio",Fx="org.eclipse.elk.padding",J_="org.eclipse.elk.alg.disco.transform",Cie=1.5707963267948966,Aw={3:1,4:1,5:1,175:1},f1={221:1,3:1,4:1},gye={3:1,6:1,4:1,5:1,63:1,73:1},mye="org.eclipse.elk.alg.force",bye="ComponentsProcessor",lQe="ComponentsProcessor/1",X6="org.eclipse.elk.alg.force.graph",uQe="Component Layout",wye="org.eclipse.elk.alg.force.model",pd=.01,K7="org.eclipse.elk.force.model",vye="org.eclipse.elk.force.iterations",_ye="org.eclipse.elk.force.repulsivePower",Aie="org.eclipse.elk.force.temperature",Kd=.001,Pie="org.eclipse.elk.force.repulsion",_P="org.eclipse.elk.alg.force.options",WS=1.600000023841858,Lh="org.eclipse.elk.force",Y6="org.eclipse.elk.priority",HS="org.eclipse.elk.spacing.nodeNode",Lie="org.eclipse.elk.spacing.edgeLabel",J7="org.eclipse.elk.randomSeed",Z6="org.eclipse.elk.separateConnectedComponents",Q7="org.eclipse.elk.interactive",kie="org.eclipse.elk.portConstraints",yye="origin",xye="random",fQe="boundingBox.upLeft",hQe="boundingBox.lowRight",Eye="org.eclipse.elk.stress.fixed",Sye="org.eclipse.elk.stress.desiredEdgeLength",Mye="org.eclipse.elk.stress.dimension",Tye="org.eclipse.elk.stress.epsilon",Cye="org.eclipse.elk.stress.iterationLimit",yP="org.eclipse.elk.stress",dQe="ELK Stress",Rie="org.eclipse.elk.alg.force.stress",pQe="Layered layout",K6="org.eclipse.elk.alg.layered",J6="org.eclipse.elk.alg.layered.compaction.components",xP="org.eclipse.elk.alg.layered.compaction.oned",ez="org.eclipse.elk.alg.layered.compaction.oned.algs",h1="org.eclipse.elk.alg.layered.compaction.recthull",nm="org.eclipse.elk.alg.layered.components",gQe={3:1,6:1,4:1,5:1,85:1,63:1,73:1},tz="org.eclipse.elk.alg.layered.compound",gu={3:1,6:1,4:1,5:1,99:1,85:1,63:1,73:1},kr={50:1},Za="org.eclipse.elk.alg.layered.graph",Tf={3:1,6:1,4:1,5:1,85:1,123:1,148:1,63:1,73:1},mQe="Not supported by LGraph",bQe=`([{"' \r +`,wQe=`)]}"' \r +`,vQe="The given string contains parts that cannot be parsed as numbers.",Q6="org.eclipse.elk.core.math",_Qe={3:1,4:1,135:1,211:1,428:1},yQe={3:1,4:1,119:1,211:1,428:1},d1="org.eclipse.elk.alg.layered.graph.transform",Cn="org.eclipse.elk.alg.layered.intermediate",xQe="Big nodes pre-processing",Aye={3:1,6:1,4:1,5:1,85:1,619:1,148:1,63:1,73:1},Pye={3:1,4:1,5:1,537:1},EQe="ONE_SIDED_GREEDY_SWITCH",SQe="TWO_SIDED_GREEDY_SWITCH",Iie="No implementation is available for the layout processor ",Lye="IntermediateProcessorStrategy",kye="Node '",MQe="NodeMarginCalculator",TQe="Odd port side processing",Pw=1e-8,Hr="org.eclipse.elk.alg.layered.intermediate.compaction",EP="org.eclipse.elk.alg.layered.intermediate.greedyswitch",p1="org.eclipse.elk.alg.layered.p3order.counting",e5={208:1},Jd="org.eclipse.elk.alg.layered.intermediate.wrapping",SP="org.eclipse.elk.alg.layered.networksimplex",vc="org.eclipse.elk.alg.layered.options",Die="INTERACTIVE",W0="NONE",qS="LEFT",XS="RIGHT",CQe="EDGE_LENGTH",AQe="SELF_LOOPS",Rye="BOTTOM",MP="CENTER",PQe="portRatioOrPosition",Iye="org.eclipse.elk.layered.contentAlignment",Dye="org.eclipse.elk.layered.feedbackEdges",nz="org.eclipse.elk.layered.interactiveReferencePoint",Bye="org.eclipse.elk.layered.mergeEdges",Oye="org.eclipse.elk.layered.mergeHierarchyEdges",Nye="org.eclipse.elk.layered.thoroughness",Fye="org.eclipse.elk.layered.unnecessaryBendpoints",Uye="org.eclipse.elk.layered.northOrSouthPort",Bie="org.eclipse.elk.layered.cycleBreaking.strategy",t5="org.eclipse.elk.layered.layering.strategy",zye="org.eclipse.elk.layered.layering.layerConstraint",Gye="org.eclipse.elk.layered.layering.wideNodesOnMultipleLayers",Oie="org.eclipse.elk.layered.layering.minWidth.upperBoundOnWidth",Nie="org.eclipse.elk.layered.layering.minWidth.upperLayerEstimationScalingFactor",Fie="org.eclipse.elk.layered.layering.nodePromotion.strategy",Uie="org.eclipse.elk.layered.layering.nodePromotion.maxIterations",zie="org.eclipse.elk.layered.layering.coffmanGraham.layerBound",Gie="org.eclipse.elk.layered.crossingMinimization.strategy",jye="org.eclipse.elk.layered.crossingMinimization.hierarchicalSweepiness",$ye="org.eclipse.elk.layered.crossingMinimization.semiInteractive",Vye="org.eclipse.elk.layered.crossingMinimization.greedySwitch.activationThreshold",Wye="org.eclipse.elk.layered.crossingMinimization.greedySwitch.type",YS="org.eclipse.elk.layered.nodePlacement.strategy",jie="org.eclipse.elk.layered.nodePlacement.favorStraightEdges",$ie="org.eclipse.elk.layered.nodePlacement.bk.edgeStraightening",Vie="org.eclipse.elk.layered.nodePlacement.bk.fixedAlignment",Wie="org.eclipse.elk.layered.nodePlacement.linearSegments.deflectionDampening",Hie="org.eclipse.elk.layered.nodePlacement.networkSimplex.nodeFlexibility",Hye="org.eclipse.elk.layered.nodePlacement.networkSimplex.nodeFlexibility.default",qie="org.eclipse.elk.layered.edgeRouting.selfLoopPlacement",iz="org.eclipse.elk.layered.edgeRouting.sloppySplineRouting",rz="org.eclipse.elk.layered.edgeRouting.sloppySplineLayerSpacing",qye="org.eclipse.elk.layered.spacing.edgeNodeBetweenLayers",Xye="org.eclipse.elk.layered.spacing.edgeEdgeBetweenLayers",Yye="org.eclipse.elk.layered.spacing.nodeNodeBetweenLayers",Zye="org.eclipse.elk.layered.priority.direction",Kye="org.eclipse.elk.layered.priority.shortness",Jye="org.eclipse.elk.layered.priority.straightness",Xie="org.eclipse.elk.layered.compaction.connectedComponents",Qye="org.eclipse.elk.layered.compaction.postCompaction.strategy",e2e="org.eclipse.elk.layered.compaction.postCompaction.constraints",sz="org.eclipse.elk.layered.highDegreeNodes.treatment",Yie="org.eclipse.elk.layered.highDegreeNodes.threshold",Zie="org.eclipse.elk.layered.highDegreeNodes.treeHeight",TP="org.eclipse.elk.layered.wrapping.strategy",t2e="org.eclipse.elk.layered.wrapping.additionalEdgeSpacing",n2e="org.eclipse.elk.layered.wrapping.correctionFactor",oz="org.eclipse.elk.layered.wrapping.cutting.strategy",Kie="org.eclipse.elk.layered.wrapping.cutting.cuts",Jie="org.eclipse.elk.layered.wrapping.cutting.msd.freedom",Qie="org.eclipse.elk.layered.wrapping.singleEdge.validify.strategy",az="org.eclipse.elk.layered.wrapping.multiEdge.improveCuts",cz="org.eclipse.elk.layered.wrapping.multiEdge.distancePenalty",ere="org.eclipse.elk.layered.wrapping.multiEdge.improveWrappedEdges",i2e="org.eclipse.elk.layered.edgeLabels.sideSelection",r2e="org.eclipse.elk.layered.edgeLabels.centerLabelPlacementStrategy",s2e="layering",LQe="layering.minWidth",kQe="layering.nodePromotion",o2e="crossingMinimization",RQe="crossingMinimization.greedySwitch",IQe="nodePlacement",DQe="nodePlacement.bk",a2e="edgeRouting",n5="org.eclipse.elk.edgeRouting",im="spacing",c2e="priority",BQe="compaction.postCompaction",OQe="Specifies whether and how post-process compaction is applied.",l2e="highDegreeNodes",u2e="wrapping",NQe="wrapping.cutting",f2e="wrapping.multiEdge",tre="edgeLabels",An="org.eclipse.elk.layered",h2e="org.eclipse.elk.spacing.edgeEdge",d2e="org.eclipse.elk.spacing.edgeNode",p2e="org.eclipse.elk.spacing.labelLabel",g2e="org.eclipse.elk.spacing.labelPort",m2e="org.eclipse.elk.spacing.labelNode",b2e="org.eclipse.elk.spacing.portPort",w2e="org.eclipse.elk.spacing.individualOverride",v2e="org.eclipse.elk.port.borderOffset",_2e="org.eclipse.elk.noLayout",y2e="org.eclipse.elk.port.side",nre="org.eclipse.elk.debugMode",x2e="org.eclipse.elk.alignment",E2e="org.eclipse.elk.hierarchyHandling",S2e="org.eclipse.elk.insideSelfLoops.activate",M2e="org.eclipse.elk.insideSelfLoops.yo",lz="org.eclipse.elk.nodeSize.constraints",ire="org.eclipse.elk.nodeSize.options",rre="org.eclipse.elk.direction",T2e="org.eclipse.elk.nodeLabels.placement",C2e="org.eclipse.elk.portLabels.placement",A2e="org.eclipse.elk.portLabels.nextToPortIfPossible",P2e="org.eclipse.elk.portAlignment.default",L2e="org.eclipse.elk.portAlignment.north",k2e="org.eclipse.elk.portAlignment.south",R2e="org.eclipse.elk.portAlignment.west",I2e="org.eclipse.elk.portAlignment.east",uz="org.eclipse.elk.nodeSize.minimum",D2e="org.eclipse.elk.junctionPoints",B2e="org.eclipse.elk.edgeLabels.placement",O2e="org.eclipse.elk.edgeLabels.inline",N2e="org.eclipse.elk.port.index",F2e="org.eclipse.elk.commentBox",U2e="org.eclipse.elk.hypernode",z2e="org.eclipse.elk.port.anchor",G2e="org.eclipse.elk.partitioning.activate",j2e="org.eclipse.elk.partitioning.partition",fz="org.eclipse.elk.position",$2e="org.eclipse.elk.margins",V2e="org.eclipse.elk.spacing.portsSurrounding",FQe="NETWORK_SIMPLEX",Ux="UNDEFINED",UQe={3:1,4:1,5:1,616:1},Ml={141:1,50:1},W2e="org.eclipse.elk.alg.layered.p1cycles",Lw="org.eclipse.elk.alg.layered.p2layers",H2e={422:1,208:1},zQe={736:1,3:1,4:1},Hl="org.eclipse.elk.alg.layered.p3order",co="org.eclipse.elk.alg.layered.p4nodes",GQe={3:1,4:1,5:1,745:1},sre=1e-5,ore="DOWN",Wp="org.eclipse.elk.alg.layered.p4nodes.bk",zx=17976931348623157e292,Q_="org.eclipse.elk.alg.layered.p5edges",g1="org.eclipse.elk.alg.layered.p5edges.splines",ey=1e-6,hz=-1e-6,jQe="The list of vectors may not be empty.",q2e=-17976931348623157e292,are=.09999999999999998,$Qe=4.71238898038469,VQe=3.141592653589793,CP="org.eclipse.elk.alg.mrtree",AP="org.eclipse.elk.alg.mrtree.graph",Gx="org.eclipse.elk.alg.mrtree.intermediate",WQe="Set neighbors in level",HQe="DESCENDANTS",X2e="org.eclipse.elk.mrtree.weighting",Y2e="org.eclipse.elk.mrtree.searchOrder",dz="org.eclipse.elk.alg.mrtree.options",ty="org.eclipse.elk.mrtree",qQe="org.eclipse.elk.tree",Z2e="org.eclipse.elk.alg.radial",jx=6.283185307179586,cre=5e-324,XQe="org.eclipse.elk.alg.radial.intermediate",lre="org.eclipse.elk.alg.radial.intermediate.compaction",YQe={3:1,4:1,5:1,63:1},K2e="org.eclipse.elk.alg.radial.intermediate.optimization",ure="No implementation is available for the layout option ",PP="org.eclipse.elk.alg.radial.options",J2e="org.eclipse.elk.radial.orderId",Q2e="org.eclipse.elk.radial.radius",fre="org.eclipse.elk.radial.compactor",hre="org.eclipse.elk.radial.compactionStepSize",exe="org.eclipse.elk.radial.sorter",txe="org.eclipse.elk.radial.wedgeCriteria",nxe="org.eclipse.elk.radial.optimizationCriteria",H0="org.eclipse.elk.radial",ZQe="org.eclipse.elk.alg.radial.p1position.wedge",ixe="org.eclipse.elk.alg.radial.sorting",KQe=5.497787143782138,JQe=3.9269908169872414,QQe=2.356194490192345,Cf="org.eclipse.elk.core.util",eet="Invalid index: ",$x="org.eclipse.elk.core.alg",Vx={337:1},ny={284:1},rxe="Make sure it's type is registered with the ",sxe=" utility class.",ZS="true",dre="false",tet="Couldn't clone property '",Af="org.eclipse.elk.core.options",net=1.2999999523162842,kw="org.eclipse.elk.box",oxe="org.eclipse.elk.expandNodes",axe="org.eclipse.elk.box.packingMode",iet="org.eclipse.elk.algorithm",cxe="org.eclipse.elk.bendPoints",ret="org.eclipse.elk.labelManager",set="org.eclipse.elk.scaleFactor",oet="org.eclipse.elk.animate",aet="org.eclipse.elk.animTimeFactor",cet="org.eclipse.elk.layoutAncestors",uet="org.eclipse.elk.maxAnimTime",fet="org.eclipse.elk.minAnimTime",het="org.eclipse.elk.progressBar",det="org.eclipse.elk.validateOptions",pet="org.eclipse.elk.zoomToFit",get="org.eclipse.elk.nodeLabels.padding",met="org.eclipse.elk.font.name",bet="org.eclipse.elk.font.size",wet="org.eclipse.elk.edge.type",vet="de.cau.cs.kieler.labelSpacing",_et="partitioning",yet="nodeLabels",pz="portAlignment",lxe="nodeSize",pre="port",xet="portLabels",Eet="insideSelfLoops",Met="de.cau.cs.kieler.selfLoopInside",i5="org.eclipse.elk.fixed",Tet="Fixed Layout",gz="org.eclipse.elk.random",Cet="port must have a parent node to calculate the port side",r5="org.eclipse.elk.core.util.adapters",uxe="org.eclipse.elk.core.util.nodespacing",m1="org.eclipse.elk.core.util.nodespacing.cellsystem",Aet={171:1,307:1},fxe="Vertical alignment cannot be null",mz="org.eclipse.elk.core.util.nodespacing.internal",KS="org.eclipse.elk.core.util.nodespacing.internal.algorithm",JS="org.eclipse.elk.core.util.overlaps",ql="org.eclipse.emf.ecore",iy="org.eclipse.elk.graph",Pet="EMapPropertyHolder",Let="ElkBendPoint",ket="ElkGraphElement",Ret="ElkConnectableShape",hxe="ElkEdge",Iet="ElkEdgeSection",Det="EModelElement",Bet="ENamedElement",dxe="ElkLabel",pxe="ElkNode",gxe="ElkPort",Oet={91:1,87:1},Wx="org.eclipse.emf.common.notify.impl",ry="The feature '",gre="' is not a valid changeable feature",Net="Expecting null",mxe="' is not a valid feature",Ka=32768,Fet={95:1,91:1,87:1,51:1,42:1,92:1},kt="org.eclipse.emf.ecore.impl",b1="org.eclipse.elk.graph.impl",LP="Recursive containment not allowed for ",QS="The datatype '",q0="' is not a valid classifier",mre="The value '",sy={173:1,3:1,4:1},bre="The class '",eM="http://www.eclipse.org/elk/ElkGraph",bxe="property",kP="value",wre="source",Uet="properties",zet="identifier",vre="height",_re="width",yre="parent",xre="text",wxe="children",Get="hierarchical",vxe="sources",Ere="targets",_xe="sections",Sre="bendPoints",yxe="outgoingShape",xxe="incomingShape",Exe="outgoingSections",Sxe="incomingSections",Gs="org.eclipse.emf.common.util",Mxe="Severe implementation error in the Json to ElkGraph importer.",kh="id",Ps="org.eclipse.elk.graph.json",Txe="Unhandled parameter types: ",jet="startPoint",$et="An edge must have at least one source and one target (edge id: '",tM="').",Vet="Referenced edge section does not exist: ",Wet=" (edge id: '",Cxe="target",bz="group",mi="name",Het="connectableShape cannot be null",Mre="Passed edge is not 'simple'.",s5="The 'no duplicates' constraint is violated",Rh={3:1,4:1,20:1,25:1,41:1,13:1,15:1,49:1,59:1,55:1,52:1},Tre={3:1,4:1,20:1,25:1,41:1,13:1,43:1,15:1,49:1,59:1,55:1,52:1,532:1},Cre="org.eclipse.elk.graph.util",Axe="undefined",qet="parser.parse.1",Xet="parser.parse.2",wz="parser.next.1",Are="parser.next.2",Yet="parser.next.3",Zet="parser.next.4",w1="parser.factor.1",Pxe="parser.factor.2",Ket="parser.factor.3",Jet="parser.factor.4",Qet="parser.factor.5",ett="parser.factor.6",ttt="parser.atom.1",ntt="parser.atom.2",itt="parser.atom.3",Lxe="parser.atom.4",Pre="parser.atom.5",kxe="parser.cc.1",vz="parser.cc.2",rtt="parser.cc.3",stt="parser.cc.5",Rxe="parser.cc.6",Ixe="parser.cc.7",Lre="parser.cc.8",ott="parser.ope.1",att="parser.ope.2",ctt="parser.ope.3",Hp="parser.descape.1",ltt="parser.descape.2",utt="parser.descape.3",ftt="parser.descape.4",htt="parser.descape.5",Xl="parser.process.1",dtt="parser.quantifier.1",ptt="parser.quantifier.2",gtt="parser.quantifier.3",mtt="parser.quantifier.4",Dxe="parser.quantifier.5",btt="org.eclipse.emf.common.notify",Bxe={380:1,610:1},wtt={3:1,4:1,20:1,25:1,41:1,13:1,15:1,59:1,52:1},o5={338:1,136:1},RP="index=",_z=", size=",kre={3:1,4:1,5:1,116:1},vtt={3:1,4:1,20:1,25:1,41:1,13:1,15:1,49:1,59:1,52:1},Oxe={3:1,6:1,4:1,5:1,175:1},_tt={3:1,4:1,5:1,339:1},ytt=";/?:@&=+$,",xtt="invalid authority: ",Ett="EAnnotation",Stt="ETypedElement",Mtt="EStructuralFeature",Ttt="EAttribute",Ctt="EClassifier",Att="EEnumLiteral",Ptt="EGenericType",Ltt="EOperation",ktt="EParameter",Rtt="EReference",Itt="ETypeParameter",ar="org.eclipse.emf.ecore.util",Nxe={3:1,20:1,13:1,15:1,52:1,533:1,81:1,64:1},Dtt="org.eclipse.emf.ecore.util.FeatureMap$Entry",ef=1024,_c=8192,Rw=2048,IP="byte",yz="char",DP="double",BP="float",OP="int",NP="long",FP="short",Btt="java.lang.Object",oy={3:1,4:1,5:1,222:1},Fxe={3:1,4:1,5:1,611:1},Ott={3:1,4:1,20:1,25:1,41:1,13:1,15:1,49:1,59:1,55:1,52:1,64:1},Wo={3:1,4:1,20:1,25:1,41:1,13:1,15:1,49:1,59:1,55:1,52:1,81:1,64:1},a5="mixed",Kn="http:///org/eclipse/emf/ecore/util/ExtendedMetaData",mu="kind",Ntt={3:1,4:1,5:1,612:1},Uxe={3:1,4:1,20:1,25:1,41:1,13:1,15:1,59:1,52:1,81:1,64:1},xz={20:1,25:1,41:1,13:1,15:1,52:1,64:1},Ez={43:1,120:1,260:1},Sz={75:1,311:1},Mz="The value of type '",Tz="' must be of type '",ay=1365,bu="http://www.eclipse.org/emf/2002/Ecore",Cz=-32768,X0="constraints",Ls="baseType",Ftt="getEStructuralFeature",Utt="getFeatureID",UP="feature",ztt="getOperationID",zxe="operation",Gtt="defaultValue",jtt="eTypeParameters",$tt="isInstance",Vtt="getEEnumLiteral",Wtt="eContainingClass",ci={47:1},Htt={3:1,4:1,5:1,124:1},qtt="org.eclipse.emf.ecore.resource",Xtt={91:1,87:1,534:1,1628:1},Rre="org.eclipse.emf.ecore.resource.impl",Gxe="unspecified",c5="simple",Az="attribute",Ytt="attributeWildcard",Pz="element",Ire="elementWildcard",Pf="collapse",Dre="itemType",Lz="namespace",l5="##targetNamespace",wu="whiteSpace",jxe="wildcards",v1="http://www.eclipse.org/emf/2003/XMLType",Bre="##any",nM="uninitialized",Ore="The multiplicity constraint is violated",kz="org.eclipse.emf.ecore.xml.type",Ztt="ProcessingInstruction",Ktt="SimpleAnyType",Jtt="XMLTypeDocumentRoot",jr="org.eclipse.emf.ecore.xml.type.impl",u5="INF",Qtt="processing",ent="ENTITIES_._base",$xe="minLength",Vxe="ENTITY",Rz="NCName",tnt="IDREFS_._base",Wxe="integer",Nre="token",Fre="pattern",nnt="[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*",Hxe="\\i\\c*",int="[\\i-[:]][\\c-[:]]*",rnt="nonPositiveInteger",f5="maxInclusive",qxe="NMTOKEN",snt="NMTOKENS_._base",Xxe="nonNegativeInteger",h5="minInclusive",ont="normalizedString",ant="unsignedByte",cnt="unsignedInt",lnt="18446744073709551615",unt="unsignedShort",fnt="processingInstruction",qp="org.eclipse.emf.ecore.xml.type.internal",iM=1114111,hnt="Internal Error: shorthands: \\u",zP="xml:isDigit",Ure="xml:isWord",zre="xml:isSpace",Gre="xml:isNameChar",jre="xml:isInitialNameChar",dnt="09\u0660\u0669\u06F0\u06F9\u0966\u096F\u09E6\u09EF\u0A66\u0A6F\u0AE6\u0AEF\u0B66\u0B6F\u0BE7\u0BEF\u0C66\u0C6F\u0CE6\u0CEF\u0D66\u0D6F\u0E50\u0E59\u0ED0\u0ED9\u0F20\u0F29",pnt="AZaz\xC0\xD6\xD8\xF6\xF8\u0131\u0134\u013E\u0141\u0148\u014A\u017E\u0180\u01C3\u01CD\u01F0\u01F4\u01F5\u01FA\u0217\u0250\u02A8\u02BB\u02C1\u0386\u0386\u0388\u038A\u038C\u038C\u038E\u03A1\u03A3\u03CE\u03D0\u03D6\u03DA\u03DA\u03DC\u03DC\u03DE\u03DE\u03E0\u03E0\u03E2\u03F3\u0401\u040C\u040E\u044F\u0451\u045C\u045E\u0481\u0490\u04C4\u04C7\u04C8\u04CB\u04CC\u04D0\u04EB\u04EE\u04F5\u04F8\u04F9\u0531\u0556\u0559\u0559\u0561\u0586\u05D0\u05EA\u05F0\u05F2\u0621\u063A\u0641\u064A\u0671\u06B7\u06BA\u06BE\u06C0\u06CE\u06D0\u06D3\u06D5\u06D5\u06E5\u06E6\u0905\u0939\u093D\u093D\u0958\u0961\u0985\u098C\u098F\u0990\u0993\u09A8\u09AA\u09B0\u09B2\u09B2\u09B6\u09B9\u09DC\u09DD\u09DF\u09E1\u09F0\u09F1\u0A05\u0A0A\u0A0F\u0A10\u0A13\u0A28\u0A2A\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59\u0A5C\u0A5E\u0A5E\u0A72\u0A74\u0A85\u0A8B\u0A8D\u0A8D\u0A8F\u0A91\u0A93\u0AA8\u0AAA\u0AB0\u0AB2\u0AB3\u0AB5\u0AB9\u0ABD\u0ABD\u0AE0\u0AE0\u0B05\u0B0C\u0B0F\u0B10\u0B13\u0B28\u0B2A\u0B30\u0B32\u0B33\u0B36\u0B39\u0B3D\u0B3D\u0B5C\u0B5D\u0B5F\u0B61\u0B85\u0B8A\u0B8E\u0B90\u0B92\u0B95\u0B99\u0B9A\u0B9C\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8\u0BAA\u0BAE\u0BB5\u0BB7\u0BB9\u0C05\u0C0C\u0C0E\u0C10\u0C12\u0C28\u0C2A\u0C33\u0C35\u0C39\u0C60\u0C61\u0C85\u0C8C\u0C8E\u0C90\u0C92\u0CA8\u0CAA\u0CB3\u0CB5\u0CB9\u0CDE\u0CDE\u0CE0\u0CE1\u0D05\u0D0C\u0D0E\u0D10\u0D12\u0D28\u0D2A\u0D39\u0D60\u0D61\u0E01\u0E2E\u0E30\u0E30\u0E32\u0E33\u0E40\u0E45\u0E81\u0E82\u0E84\u0E84\u0E87\u0E88\u0E8A\u0E8A\u0E8D\u0E8D\u0E94\u0E97\u0E99\u0E9F\u0EA1\u0EA3\u0EA5\u0EA5\u0EA7\u0EA7\u0EAA\u0EAB\u0EAD\u0EAE\u0EB0\u0EB0\u0EB2\u0EB3\u0EBD\u0EBD\u0EC0\u0EC4\u0F40\u0F47\u0F49\u0F69\u10A0\u10C5\u10D0\u10F6\u1100\u1100\u1102\u1103\u1105\u1107\u1109\u1109\u110B\u110C\u110E\u1112\u113C\u113C\u113E\u113E\u1140\u1140\u114C\u114C\u114E\u114E\u1150\u1150\u1154\u1155\u1159\u1159\u115F\u1161\u1163\u1163\u1165\u1165\u1167\u1167\u1169\u1169\u116D\u116E\u1172\u1173\u1175\u1175\u119E\u119E\u11A8\u11A8\u11AB\u11AB\u11AE\u11AF\u11B7\u11B8\u11BA\u11BA\u11BC\u11C2\u11EB\u11EB\u11F0\u11F0\u11F9\u11F9\u1E00\u1E9B\u1EA0\u1EF9\u1F00\u1F15\u1F18\u1F1D\u1F20\u1F45\u1F48\u1F4D\u1F50\u1F57\u1F59\u1F59\u1F5B\u1F5B\u1F5D\u1F5D\u1F5F\u1F7D\u1F80\u1FB4\u1FB6\u1FBC\u1FBE\u1FBE\u1FC2\u1FC4\u1FC6\u1FCC\u1FD0\u1FD3\u1FD6\u1FDB\u1FE0\u1FEC\u1FF2\u1FF4\u1FF6\u1FFC\u2126\u2126\u212A\u212B\u212E\u212E\u2180\u2182\u3007\u3007\u3021\u3029\u3041\u3094\u30A1\u30FA\u3105\u312C\u4E00\u9FA5\uAC00\uD7A3",gnt="Private Use",$re="ASSIGNED",mnt="\0\x7F\x80\xFF\u0100\u017F\u0180\u024F\u0250\u02AF\u02B0\u02FF\u0300\u036F\u0370\u03FF\u0400\u04FF\u0530\u058F\u0590\u05FF\u0600\u06FF\u0700\u074F\u0780\u07BF\u0900\u097F\u0980\u09FF\u0A00\u0A7F\u0A80\u0AFF\u0B00\u0B7F\u0B80\u0BFF\u0C00\u0C7F\u0C80\u0CFF\u0D00\u0D7F\u0D80\u0DFF\u0E00\u0E7F\u0E80\u0EFF\u0F00\u0FFF\u1000\u109F\u10A0\u10FF\u1100\u11FF\u1200\u137F\u13A0\u13FF\u1400\u167F\u1680\u169F\u16A0\u16FF\u1780\u17FF\u1800\u18AF\u1E00\u1EFF\u1F00\u1FFF\u2000\u206F\u2070\u209F\u20A0\u20CF\u20D0\u20FF\u2100\u214F\u2150\u218F\u2190\u21FF\u2200\u22FF\u2300\u23FF\u2400\u243F\u2440\u245F\u2460\u24FF\u2500\u257F\u2580\u259F\u25A0\u25FF\u2600\u26FF\u2700\u27BF\u2800\u28FF\u2E80\u2EFF\u2F00\u2FDF\u2FF0\u2FFF\u3000\u303F\u3040\u309F\u30A0\u30FF\u3100\u312F\u3130\u318F\u3190\u319F\u31A0\u31BF\u3200\u32FF\u3300\u33FF\u3400\u4DB5\u4E00\u9FFF\uA000\uA48F\uA490\uA4CF\uAC00\uD7A3\uE000\uF8FF\uF900\uFAFF\uFB00\uFB4F\uFB50\uFDFF\uFE20\uFE2F\uFE30\uFE4F\uFE50\uFE6F\uFE70\uFEFE\uFEFF\uFEFF\uFF00\uFFEF",Yxe="UNASSIGNED",rM={3:1,112:1},bnt="org.eclipse.emf.ecore.xml.type.util",Iz={3:1,4:1,5:1,342:1},Zxe="org.eclipse.xtext.xbase.lib",wnt="Cannot add elements to a Range",vnt="Cannot set elements in a Range",_nt="Cannot remove elements from a Range",Dz="locale",Bz="default",Oz="user.agent",p,Nz,Vre,Y$t=-1;$6t(),A(1,null,{},L),p.Fb=function(t){return this===t},p.Gb=function(){return this.ql},p.Hb=function(){return p0(this)},p.Ib=function(){return Um(rl(this))+"@"+(Wr(this)>>>0).toString(16)},p.equals=function(e){return this.Fb(e)},p.hashCode=function(){return this.Hb()},p.toString=function(){return this.Ib()};var ynt,xnt,Ent;A(274,1,{274:1,1712:1},wbe),p._d=function(t){var i;return i=new wbe,i.i=4,t>1?i.c=a7e(this,t-1):i.c=this,i},p.ae=function(){return Nd(this),this.b},p.be=function(){return Um(this)},p.ce=function(){return Nd(this),this.k},p.de=function(){return(this.i&4)!=0},p.ee=function(){return(this.i&1)!=0},p.Ib=function(){return N0e(this)},p.i=0;var Z$t=1,sn=k(ha,"Object",1),Kxe=k(ha,"Class",274);A(1692,1,{3:1});var tgn=k(X_,"Optional",1692);A(1060,1692,{3:1},I),p.Fb=function(t){return t===this},p.Hb=function(){return 2040732332},p.Ib=function(){return"Optional.absent()"},p.Jb=function(t){return Hn(t),Fr(),Wre};var Wre,ngn=k(X_,"Absent",1060),K$t=br(X_,"Function");A(393,1,{},LR),p.Lb=function(t){return Y9e(t)};var ign=k(X_,"Joiner",393);A(875,393,{},e9e),p.Lb=function(t){return t==null?this.b:Y9e(t)};var rgn=k(X_,"Joiner/1",875);A(874,1,{},vY);var sgn=k(X_,"Joiner/MapJoiner",874),J$t=br(X_,"Predicate"),Snt;A(494,1,{138:1,494:1,3:1,56:1},KX),p.Nb=function(t){return this.Mb(t)},p.Mb=function(t){var i;for(i=0;i0},p.ic=function(){if(this.b>=this.c)throw Y(new K);return wBe(this,this.b++)},p.Dc=function(){return this.b},p.Ec=function(){if(this.b<=0)throw Y(new K);return wBe(this,--this.b)},p.Fc=function(){return this.b-1},p.b=0,p.c=0;var Egn=k(Pt,"AbstractIndexedListIterator",847);A(949,257,$7),p.hc=function(){return S_(this)},p.ic=function(){return dx(this)},p.d=1;var Sgn=k(Pt,"AbstractIterator",949);A(1677,1,{238:1}),p.Hc=function(){var t;return t=this.f,t||(this.f=this.Ic())},p.Jc=function(){return new MK(this.Hc())},p.Lc=function(){return new PGe(this.Kc(),this._b(),re(this,475)?1:0)},p.Fb=function(t){return kee(this,t)},p.Hb=function(){return Wr(this.Hc())},p.Wb=function(){return this._b()==0},p.Xb=function(){return i1e(this)},p.Ib=function(){return za(this.Hc())};var Mgn=k(Pt,"AbstractMultimap",1677);A(654,1677,One),p.Pb=function(){K0e(this)},p.Qb=function(t){return this.c.Qb(t)},p.Ic=function(){return re(this.c,122)?new nA(this,h(this.c,122)):re(this.c,115)?new XE(this,h(this.c,115)):new NE(this,this.c)},p.Pc=function(t){return this.Oc()},p.Jc=function(){return re(this.c,122)?new Zv(this,h(this.c,122)):re(this.c,115)?new q2(this,h(this.c,115)):new qE(this,this.c)},p.Qc=function(){return zDt(this.Oc())},p.Kc=function(){return new IDe(this)},p.Lc=function(){return Kwe(this.c.Tb().wc(),new Z,64,this.d)},p.Mc=function(t){return Qi(this,t)},p.Nc=function(t){return aP(this,t)},p._b=function(){return this.d},p.Rc=function(){return new RDe(this)},p.Sc=function(){return Kwe(this.c.ac().wc(),new D,64,this.d)},p.d=0;var Tgn=k(Pt,"AbstractMapBasedMultimap",654);A(1483,654,One),p.Oc=function(){return new zl(this.a)},p.Qc=function(){return lA(),lA(),e3e},p.Mc=function(t){return h(Qi(this,t),15)},p.Nc=function(t){return h(aP(this,t),15)},p.Hc=function(){var t;return t=this.f,t||(this.f=re(this.c,122)?new nA(this,h(this.c,122)):re(this.c,115)?new XE(this,h(this.c,115)):new NE(this,this.c))},p.Fb=function(t){return kee(this,t)},p.Tc=function(t){return h(Qi(this,t),15)},p.Uc=function(t){return h(aP(this,t),15)};var Cgn=k(Pt,"AbstractListMultimap",1483);A(661,1,ys),p.gc=function(t){Ss(this,t)},p.hc=function(){return this.c.hc()||this.e.hc()},p.ic=function(){var t;return this.e.hc()||(t=h(this.c.ic(),38),this.b=t.kc(),this.a=h(t.lc(),13),this.e=this.a.tc()),this.Vc(this.b,this.e.ic())},p.jc=function(){this.e.jc(),this.a.Wb()&&this.c.jc(),--this.d.d};var Agn=k(Pt,"AbstractMapBasedMultimap/Itr",661);A(970,661,ys,RDe),p.Vc=function(t,i){return i};var Pgn=k(Pt,"AbstractMapBasedMultimap/1",970);A(971,1,ps,D),p.Kb=function(t){return h(t,13).wc()};var Lgn=k(Pt,"AbstractMapBasedMultimap/1methodref$spliterator$Type",971);A(972,661,ys,IDe),p.Vc=function(t,i){return Xr(),new DR(t,i)};var kgn=k(Pt,"AbstractMapBasedMultimap/2",972);A(1666,1,jS),p.Ub=function(t){vee(this,t)},p.Yb=function(t,i,a){return Vbe(this,t,i,a)},p.Pb=function(){this.Tb().Pb()},p.Wc=function(t){return xte(this,t)},p.Qb=function(t){return!!qwe(this,t,!1)},p.Rb=function(t){var i,a,l;for(a=this.Tb().tc();a.hc();)if(i=h(a.ic(),38),l=i.lc(),Be(t)===Be(l)||t!=null&&Li(t,l))return!0;return!1},p.Fb=function(t){return Xqe(this,t)},p.Vb=function(t){return Ic(qwe(this,t,!1))},p.Hb=function(){return mbe(this.Tb())},p.Wb=function(){return this._b()==0},p.Xb=function(){return new Gv(this)},p.Zb=function(t,i){throw Y(new Tp("Put not supported on this map"))},p.$b=function(t){return Ic(qwe(this,t,!0))},p._b=function(){return this.Tb()._b()},p.Ib=function(){var t,i,a;for(a=new C0("{","}"),i=this.Tb().tc();i.hc();)t=h(i.ic(),38),Xm(a,JUe(this,t.kc())+"="+JUe(this,t.lc()));return a.a?a.e.length==0?a.a.a:a.a.a+(""+a.e):a.c},p.ac=function(){return new mh(this)};var Rgn=k(Vn,"AbstractMap",1666);A(1678,1666,jS),p.Jc=function(){return new MK(this)},p.Tb=function(){return n1e(this)},p.Xb=function(){var t;return t=this.g,t||(this.g=this.Jc())},p.ac=function(){var t;return t=this.i,t||(this.i=new lOe(this))};var Ign=k(Pt,"Maps/ViewCachingAbstractMap",1678);A(357,1678,jS,NE),p.Vb=function(t){return Pkt(this,t)},p.$b=function(t){return TIt(this,t)},p.Pb=function(){this.d==this.e.c?this.e.Pb():N9(new Vme(this))},p.Qb=function(t){return P5t(this.d,t)},p.Yc=function(){return new JX(this)},p.Xc=function(){return this.Yc()},p.Fb=function(t){return this===t||Li(this.d,t)},p.Hb=function(){return Wr(this.d)},p.Xb=function(){return this.e.Xb()},p._b=function(){return this.d._b()},p.Ib=function(){return za(this.d)};var Dgn=k(Pt,"AbstractMapBasedMultimap/AsMap",357);A(25,1,Y_),p.sc=function(t){mo(this,t)},p.uc=function(){return new si(null,this.wc())},p.wc=function(){return new pi(this,0)},p.xc=function(){return new si(null,this.wc())},p.nc=function(t){throw Y(new Tp("Add not supported on this collection"))},p.oc=function(t){return wo(this,t)},p.Pb=function(){bI(this)},p.pc=function(t){return vx(this,t,!1)},p.qc=function(t){return Gg(this,t)},p.Wb=function(){return this._b()==0},p.vc=function(t){return vx(this,t,!0)},p.yc=function(){return VJ(this)},p.zc=function(t){return u6(this,t)},p.Ib=function(){return $p(this)};var Bgn=k(Vn,"AbstractCollection",25);A(ud,25,pu),p.wc=function(){return new pi(this,1)},p.Fb=function(t){return TWe(this,t)},p.Hb=function(){return mbe(this)};var Ogn=k(Vn,"AbstractSet",ud);A(1660,ud,pu);var Ngn=k(Pt,"Sets/ImprovedAbstractSet",1660);A(1679,1660,pu),p.Pb=function(){this.Zc().Pb()},p.pc=function(t){return IWe(this,t)},p.Wb=function(){return this.Zc().Wb()},p.vc=function(t){var i;return this.pc(t)?(i=h(t,38),this.Zc().Xb().vc(i.kc())):!1},p._b=function(){return this.Zc()._b()};var Fgn=k(Pt,"Maps/EntrySet",1679);A(968,1679,pu,JX),p.pc=function(t){return rHe(this.a.d.Tb(),t)},p.tc=function(){return new Vme(this.a)},p.Zc=function(){return this.a},p.vc=function(t){var i;return rHe(this.a.d.Tb(),t)?(i=h(t,38),z4t(this.a.e,i.kc()),!0):!1},p.wc=function(){return UJ(this.a.d.Tb().wc(),new QX(this.a))};var Ugn=k(Pt,"AbstractMapBasedMultimap/AsMap/AsMapEntries",968);A(969,1,ps,QX),p.Kb=function(t){return UGe(this.a,h(t,38))};var zgn=k(Pt,"AbstractMapBasedMultimap/AsMap/AsMapEntries/0methodref$wrapEntry$Type",969);A(659,1,ys,Vme),p.gc=function(t){Ss(this,t)},p.ic=function(){var t;return t=h(this.b.ic(),38),this.a=h(t.lc(),13),UGe(this.c,t)},p.hc=function(){return this.b.hc()},p.jc=function(){this.b.jc(),this.c.e.d-=this.a._b(),this.a.Pb()};var Ggn=k(Pt,"AbstractMapBasedMultimap/AsMap/AsMapIterator",659);A(541,1660,pu,MK),p.Pb=function(){this.b.Pb()},p.pc=function(t){return this.b.Qb(t)},p.sc=function(t){Hn(t),this.b.Ub(new rY(t))},p.Wb=function(){return this.b.Wb()},p.tc=function(){return Xr(),rA(this.b.Tb().tc(),(i_(),d5))},p.vc=function(t){return this.b.Qb(t)?(this.b.$b(t),!0):!1},p._b=function(){return this.b._b()};var jgn=k(Pt,"Maps/KeySet",541);A(356,541,pu,qE),p.Pb=function(){var t;N9((t=this.b.Tb().tc(),new Fpe(this,t)))},p.qc=function(t){return this.b.Xb().qc(t)},p.Fb=function(t){return this===t||Li(this.b.Xb(),t)},p.Hb=function(){return Wr(this.b.Xb())},p.tc=function(){var t;return t=this.b.Tb().tc(),new Fpe(this,t)},p.vc=function(t){var i,a;return a=0,i=h(this.b.$b(t),13),i&&(a=i._b(),i.Pb(),this.a.d-=a),a>0},p.wc=function(){return this.b.Xb().wc()};var $gn=k(Pt,"AbstractMapBasedMultimap/KeySet",356);A(660,1,ys,Fpe),p.gc=function(t){Ss(this,t)},p.hc=function(){return this.c.hc()},p.ic=function(){return this.a=h(this.c.ic(),38),this.a.kc()},p.jc=function(){var t;Ag(!!this.a,Tw),t=h(this.a.lc(),13),this.c.jc(),this.b.a.d-=t._b(),t.Pb()};var Vgn=k(Pt,"AbstractMapBasedMultimap/KeySet/1",660);A(358,357,{109:1,115:1},XE),p.Jc=function(){return this.$c()},p.Xb=function(){return this._c()},p.$c=function(){return new q2(this.c,this.ad())},p._c=function(){var t;return t=this.b,t||(this.b=this.$c())},p.ad=function(){return h(this.d,115)};var Wgn=k(Pt,"AbstractMapBasedMultimap/SortedAsMap",358);A(396,358,EJe,nA),p.$c=function(){return new Zv(this.a,h(h(this.d,115),122))},p.Xb=function(){var t;return t=this.b,h(t||(this.b=new Zv(this.a,h(h(this.d,115),122))),196)},p._c=function(){var t;return t=this.b,h(t||(this.b=new Zv(this.a,h(h(this.d,115),122))),196)},p.ad=function(){return h(h(this.d,115),122)};var Hgn=k(Pt,"AbstractMapBasedMultimap/NavigableAsMap",396);A(327,356,SJe,q2),p.wc=function(){return this.b.Xb().wc()};var qgn=k(Pt,"AbstractMapBasedMultimap/SortedKeySet",327);A(299,327,V_e,Zv);var Xgn=k(Pt,"AbstractMapBasedMultimap/NavigableKeySet",299);A(448,25,Y_,TI),p.nc=function(t){var i,a;return sl(this),a=this.d.Wb(),i=this.d.nc(t),i&&(++this.f.d,a&&o9(this)),i},p.oc=function(t){var i,a,l;return t.Wb()?!1:(l=(sl(this),this.d._b()),i=this.d.oc(t),i&&(a=this.d._b(),this.f.d+=a-l,l==0&&o9(this)),i)},p.Pb=function(){var t;t=(sl(this),this.d._b()),t!=0&&(this.d.Pb(),this.f.d-=t,k9(this))},p.pc=function(t){return sl(this),this.d.pc(t)},p.qc=function(t){return sl(this),this.d.qc(t)},p.Fb=function(t){return t===this?!0:(sl(this),Li(this.d,t))},p.Hb=function(){return sl(this),Wr(this.d)},p.tc=function(){return sl(this),new Rme(this)},p.vc=function(t){var i;return sl(this),i=this.d.vc(t),i&&(--this.f.d,k9(this)),i},p._b=function(){return ANe(this)},p.wc=function(){return sl(this),this.d.wc()},p.Ib=function(){return sl(this),za(this.d)};var Ygn=k(Pt,"AbstractMapBasedMultimap/WrappedCollection",448),_u=br(Vn,"List");A(657,448,{20:1,25:1,13:1,15:1},t1e),p.jd=function(t){Ug(this,t)},p.wc=function(){return sl(this),this.d.wc()},p.bd=function(t,i){var a;sl(this),a=this.d.Wb(),h(this.d,15).bd(t,i),++this.a.d,a&&o9(this)},p.cd=function(t){return sl(this),h(this.d,15).cd(t)},p.dd=function(t){return sl(this),h(this.d,15).dd(t)},p.ed=function(){return sl(this),new KNe(this)},p.fd=function(t){return sl(this),new DUe(this,t)},p.gd=function(t){var i;return sl(this),i=h(this.d,15).gd(t),--this.a.d,k9(this),i},p.hd=function(t,i){return sl(this),h(this.d,15).hd(t,i)},p.kd=function(t,i){return sl(this),Q1e(this.a,this.e,h(this.d,15).kd(t,i),this.b?this.b:this)};var Zgn=k(Pt,"AbstractMapBasedMultimap/WrappedList",657);A(967,657,{20:1,25:1,13:1,15:1,49:1},IFe);var Kgn=k(Pt,"AbstractMapBasedMultimap/RandomAccessWrappedList",967);A(558,1,ys,Rme),p.gc=function(t){Ss(this,t)},p.hc=function(){return tS(this),this.b.hc()},p.ic=function(){return tS(this),this.b.ic()},p.jc=function(){yFe(this)};var Jgn=k(Pt,"AbstractMapBasedMultimap/WrappedCollection/WrappedIterator",558);A(658,558,Th,KNe,DUe),p.jc=function(){yFe(this)},p.Bc=function(t){var i;i=ANe(this.a)==0,(tS(this),h(this.b,120)).Bc(t),++this.a.a.d,i&&o9(this.a)},p.Cc=function(){return(tS(this),h(this.b,120)).Cc()},p.Dc=function(){return(tS(this),h(this.b,120)).Dc()},p.Ec=function(){return(tS(this),h(this.b,120)).Ec()},p.Fc=function(){return(tS(this),h(this.b,120)).Fc()},p.Gc=function(t){(tS(this),h(this.b,120)).Gc(t)};var Qgn=k(Pt,"AbstractMapBasedMultimap/WrappedList/WrappedListIterator",658);A(559,448,SJe,xJ),p.wc=function(){return sl(this),this.d.wc()};var emn=k(Pt,"AbstractMapBasedMultimap/WrappedSortedSet",559);A(656,559,V_e,xge);var tmn=k(Pt,"AbstractMapBasedMultimap/WrappedNavigableSet",656);A(655,448,pu,Qge),p.wc=function(){return sl(this),this.d.wc()};var nmn=k(Pt,"AbstractMapBasedMultimap/WrappedSet",655);A(974,1,ps,Z),p.Kb=function(t){var i,a;return i=t.kc(),a=h(t.lc(),13),UJ(a.wc(),new eY(i))};var imn=k(Pt,"AbstractMapBasedMultimap/lambda$0$Type",974);A(973,1,ps,eY),p.Kb=function(t){return zSt(this.a,t)};var rmn=k(Pt,"AbstractMapBasedMultimap/lambda$2$Type",973);A(392,1,Nne),p.Fb=function(t){var i;return re(t,38)?(i=h(t,38),Ip(this.kc(),i.kc())&&Ip(this.lc(),i.lc())):!1},p.Hb=function(){var t,i;return t=this.kc(),i=this.lc(),(t==null?0:Wr(t))^(i==null?0:Wr(i))},p.mc=function(t){throw Y(new Ai)},p.Ib=function(){return this.kc()+"="+this.lc()};var smn=k(Pt,MJe,392);A(1680,25,Y_),p.Pb=function(){this.ld().Pb()},p.pc=function(t){var i;return re(t,38)?(i=h(t,38),$Lt(this.ld(),i.kc(),i.lc())):!1},p.vc=function(t){var i;return re(t,38)?(i=h(t,38),J7e(this.ld(),i.kc(),i.lc())):!1},p._b=function(){return this.ld()._b()};var omn=k(Pt,"Multimaps/Entries",1680);A(975,1680,Y_),p.tc=function(){return this.a.Kc()},p.ld=function(){return this.a},p.wc=function(){return this.a.Lc()};var amn=k(Pt,"AbstractMultimap/Entries",975);A(662,975,pu,mF),p.wc=function(){return this.a.Lc()},p.Fb=function(t){return sXe(this,t)},p.Hb=function(){return k$e(this)};var cmn=k(Pt,"AbstractMultimap/EntrySet",662);A(663,25,Y_,Ld),p.Pb=function(){this.a.Pb()},p.pc=function(t){return xIt(this.a,t)},p.tc=function(){return this.a.Rc()},p._b=function(){return this.a.d},p.wc=function(){return this.a.Sc()};var lmn=k(Pt,"AbstractMultimap/Values",663);A(1681,25,{738:1,20:1,25:1,13:1}),p.sc=function(t){Hn(t),uw(this).sc(new hY(t))},p.wc=function(){var t;return t=uw(this).wc(),Kwe(t,new Ce,64|t.qd()&1296,zee(this))},p.nc=function(t){return bpe(),!0},p.oc=function(t){return AOt(this,t)},p.Pb=function(){N9(new dpe(n1e(v0(this.a)).tc()))},p.pc=function(t){var i;return i=h(CS(v0(this.a),t),13),(i?i._b():0)>0},p.Fb=function(t){return b8t(this,t)},p.Hb=function(){return Wr(uw(this))},p.Wb=function(){return uw(this).Wb()},p.tc=function(){return new QBe(this,uw(this).tc())},p.vc=function(t){return vve(this,t,1)>0},p._b=function(){return zee(this)},p.Ib=function(){return za(uw(this))};var umn=k(Pt,"AbstractMultiset",1681);A(557,654,F6),p.Oc=function(){return this.md()},p.Qc=function(){return this.nd()},p.Mc=function(t){return this.od(t)},p.Nc=function(t){return this.pd(t)},p.Hc=function(){var t;return t=this.f,t||(this.f=re(this.c,122)?new nA(this,h(this.c,122)):re(this.c,115)?new XE(this,h(this.c,115)):new NE(this,this.c))},p.nd=function(){return aw(),eS(),GP},p.Fb=function(t){return kee(this,t)},p.od=function(t){return h(Qi(this,t),19)},p.pd=function(t){return h(aP(this,t),19)};var fmn=k(Pt,"AbstractSetMultimap",557);A(1413,557,F6),p.md=function(){return new tw(this.b)},p.nd=function(){var t;return t=this.b,t?APt(this.b):(yt(),new KR(new tw(this.b)))},p.Mc=function(t){return h(h(Qi(this,t),19),60)},p.od=function(t){return h(h(Qi(this,t),19),60)},p.Nc=function(t){return h(h(aP(this,t),19),60)},p.pd=function(t){return h(h(aP(this,t),19),60)},p.Hc=function(){var t;return t=this.f,t||(this.f=re(this.c,122)?new nA(this,h(this.c,122)):re(this.c,115)?new XE(this,h(this.c,115)):new NE(this,this.c))};var hmn=k(Pt,"AbstractSortedSetMultimap",1413);A(1414,1413,F6),p.Hc=function(){var t;return t=this.f,h(h(t||(this.f=re(this.c,122)?new nA(this,h(this.c,122)):re(this.c,115)?new XE(this,h(this.c,115)):new NE(this,this.c)),115),122)},p.Xb=function(){var t;return t=this.i,h(h(t||(this.i=re(this.c,122)?new Zv(this,h(this.c,122)):re(this.c,115)?new q2(this,h(this.c,115)):new qE(this,this.c)),60),196)};var dmn=k(Pt,"AbstractSortedKeySortedSetMultimap",1414);A(521,1483,One,s9),p.a=0;var pmn=k(Pt,"ArrayListMultimap",521);A(1156,1,Vp,GBe),p.qd=function(){return this.a.qd()&-262},p.rd=function(){return this.a.rd()},p.gc=function(t){this.a.gc(new $Be(t,this.b))},p.sd=function(t){return this.a.sd(new jBe(t,this.b))};var gmn=k(Pt,"CollectSpliterators/1",1156);A(1157,1,{},jBe),p.td=function(t){this.a.td(this.b.Kb(t))};var mmn=k(Pt,"CollectSpliterators/1/lambda$0$Type",1157);A(1158,1,{},$Be),p.td=function(t){this.a.td(this.b.Kb(t))};var bmn=k(Pt,"CollectSpliterators/1/lambda$1$Type",1158);A(1159,1,Vp,fze),p.qd=function(){return this.a},p.rd=function(){return this.d&&(this.b=INe(this.b,this.d.rd())),INe(this.b,0)},p.gc=function(t){this.d&&(this.d.gc(t),this.d=null),this.c.gc(new WBe(this.e,t)),this.b=0},p.sd=function(t){for(;;){if(this.d&&this.d.sd(t))return kC(this.b,V7)&&(this.b=Qm(this.b,1)),!0;if(this.d=null,!this.c.sd(new VBe(this,this.e)))return!1}},p.a=0,p.b=0;var wmn=k(Pt,"CollectSpliterators/1FlatMapSpliterator",1159);A(1160,1,{},VBe),p.td=function(t){YMt(this.a,this.b,t)};var vmn=k(Pt,"CollectSpliterators/1FlatMapSpliterator/lambda$0$Type",1160);A(1161,1,{},WBe),p.td=function(t){VSt(this.b,this.a,t)};var _mn=k(Pt,"CollectSpliterators/1FlatMapSpliterator/lambda$1$Type",1161),Qxe;A(844,1,Ju,nY),p.Fb=function(t){return this===t},p.Kb=function(t){return Be(t)===Be(this.a)?xJe:t};var ymn=k(Pt,"Collections2/1",844);A(220,1,Fne),p.vd=function(t){return this.ud(h(t,220))},p.ud=function(t){var i;return t==(so(),qre)?1:t==(Vr(),Hre)?-1:(i=(m9(),LA(this.a,t.a)),i!=0?i:re(this,467)==re(t,467)?0:re(this,467)?1:-1)},p.yd=function(){return this.a},p.Fb=function(t){return rwe(this,t)};var xmn=k(Pt,"Cut",220);A(1508,220,Fne,rBe),p.ud=function(t){return t==this?0:1},p.wd=function(t){throw Y(new s8)},p.xd=function(t){t.a+="+\u221E)"},p.yd=function(){throw Y(new ma(TJe))},p.zd=function(t){return!1},p.Ib=function(){return"+\u221E"};var Hre,Emn=k(Pt,"Cut/AboveAll",1508);A(467,220,{220:1,467:1,3:1,34:1},SFe),p.wd=function(t){Rc((t.a+="(",t),this.a)},p.xd=function(t){Lg(Rc(t,this.a),93)},p.Hb=function(){return~Wr(this.a)},p.zd=function(t){return m9(),LA(this.a,t)<0},p.Ib=function(){return"/"+this.a+"\\"};var Smn=k(Pt,"Cut/AboveValue",467);A(1507,220,Fne,sBe),p.ud=function(t){return t==this?0:-1},p.wd=function(t){t.a+="(-\u221E"},p.xd=function(t){throw Y(new s8)},p.yd=function(){throw Y(new ma(TJe))},p.zd=function(t){return!0},p.Ib=function(){return"-\u221E"};var qre,Mmn=k(Pt,"Cut/BelowAll",1507);A(1509,220,Fne,MFe),p.wd=function(t){Rc((t.a+="[",t),this.a)},p.xd=function(t){Lg(Rc(t,this.a),41)},p.Hb=function(){return Wr(this.a)},p.zd=function(t){return m9(),LA(this.a,t)<=0},p.Ib=function(){return"\\"+this.a+"/"};var Tmn=k(Pt,"Cut/BelowValue",1509);A(482,1,fd),p.sc=function(t){mo(this,t)},p.Ib=function(){return BLt(h(A1e(this,"use Optional.orNull() instead of Optional.or(null)"),20).tc())};var Cmn=k(Pt,"FluentIterable",482);A(325,482,fd,Q2),p.tc=function(){return Tn(this)};var Amn=k(Pt,"FluentIterable/2",325);A(1670,25,CJe),p.tc=function(){return this.Ad()},p.nc=function(t){throw Y(new Ai)},p.oc=function(t){throw Y(new Ai)},p.Pb=function(){throw Y(new Ai)},p.pc=function(t){return t!=null&&vx(this,t,!1)},p.vc=function(t){throw Y(new Ai)};var Pmn=k(Pt,"ImmutableCollection",1670);A(912,1670,CJe,iY),p.tc=function(){return mx((yt(),Yv(),uy))},p.pc=function(t){return!1},p.qc=function(t){return Gg(this.a,t)},p.Wb=function(){return!0},p.Ad=function(){return mx((yt(),Yv(),uy))},p._b=function(){return 0},p.yc=function(){return VJ(this.a)},p.zc=function(t){return u6(this.a,t)},p.Ib=function(){return $p(this.a)};var Lmn=k(Pt,"ForwardingImmutableCollection",912);A(193,1670,Une),p.tc=function(){return this.Ad()},p.ed=function(){return new eQ(this,this._b(),0)},p.fd=function(t){return new eQ(this,this._b(),t)},p.jd=function(t){Ug(this,t)},p.wc=function(){return new pi(this,16)},p.kd=function(t,i){return this.Bd(t,i)},p.bd=function(t,i){throw Y(new Ai)},p.Fb=function(t){return i8t(this,t)},p.Hb=function(){return XRt(this)},p.dd=function(t){return t==null?-1:vDt(this,t)},p.Ad=function(){return new eQ(this,this._b(),0)},p.gd=function(t){throw Y(new Ai)},p.hd=function(t,i){throw Y(new Ai)},p.Bd=function(t,i){var a;return Lee((a=new eOe(this),new Rg(a,t,i)))};var e3e,kmn=k(Pt,"ImmutableList",193);A(1675,193,Une),p.tc=function(){return mx(this.Cd().tc())},p.kd=function(t,i){return Lee(this.Cd().kd(t,i))},p.pc=function(t){return t!=null&&this.Cd().pc(t)},p.qc=function(t){return this.Cd().qc(t)},p.Fb=function(t){return Li(this.Cd(),t)},p.cd=function(t){return this.Cd().cd(t)},p.Hb=function(){return Wr(this.Cd())},p.dd=function(t){return this.Cd().dd(t)},p.Wb=function(){return this.Cd().Wb()},p.Ad=function(){return mx(this.Cd().tc())},p._b=function(){return this.Cd()._b()},p.Bd=function(t,i){return Lee(this.Cd().kd(t,i))},p.yc=function(){return this.Cd().zc(le(sn,nt,1,this.Cd()._b(),5,1))},p.zc=function(t){return this.Cd().zc(t)},p.Ib=function(){return za(this.Cd())};var Rmn=k(Pt,"ForwardingImmutableList",1675);A(1671,1670,U6),p.tc=function(){return this.Ad()},p.wc=function(){return new pi(this,1)},p.Fb=function(t){return sXe(this,t)},p.Hb=function(){return k$e(this)};var Imn=k(Pt,"ImmutableSet",1671);A(550,1671,U6),p.tc=function(){return this.Ad()},p.pc=function(t){return t!=null&&RC(this.b,t)},p.qc=function(t){return zpe(this.b,t)},p.Hb=function(){return Wr(this.b.b)},p.Wb=function(){return this.b.b.Wb()},p.Ad=function(){return mx(new Nm(this.b.b.tc()))},p._b=function(){return this.b.b._b()},p.yc=function(){return this.b.b.yc()},p.zc=function(t){return tOe(this.b,t)},p.Ib=function(){return za(this.b.b)};var Dmn=k(Pt,"ForwardingImmutableSet",550);A(1664,1663,AJe),p.Ac=function(){return yt(),new KR(this.a)},p.wc=function(){return new NR(this)};var Bmn=k(Pt,"ForwardingSortedSet",1664);A(481,632,z7,i9),p.ec=function(t){return new S8e(this,t,this)},p.Zb=function(t,i){return eP(this,t,i,!1)};var Omn=k(Pt,"HashBiMap",481);A(892,633,z7,S8e),p.dc=function(){return new vFe(this,this.a.b.Tb().tc())};var Nmn=k(Pt,"HashBiMap/1",892);A(479,1,ys),p.gc=function(t){Ss(this,t)},p.hc=function(){return this.b.hc()},p.ic=function(){return _Ne(this)},p.jc=function(){this.b.jc()};var Fmn=k(Pt,"TransformedIterator",479);A(893,479,ys,vFe),p.Ed=function(t){return new X9e(this,h(t,38))},p.Dd=function(e){return this.Ed(e)};var Umn=k(Pt,"HashBiMap/1/1",893);A(894,392,Nne,X9e),p.kc=function(){return this.c},p.lc=function(){return this.a.a.b.Vb(this.c)},p.mc=function(t){var i;return Ag(Ape(O9(this.a.a),this),$_e),i=this.a.a.b.Vb(this.c),Be(t)===Be(i)||t!=null&&Li(t,i)?t:(eP(this.a.a,this.c,t,!0),i)};var zmn=k(Pt,"HashBiMap/1/1/1",894);A(298,557,F6,Kv),p.md=function(){return new m8(Eee(this.a))},p.a=2;var Gmn=k(Pt,"HashMultimap",298);A(372,392,{392:1,372:1,3:1,38:1},DR),p.kc=function(){return this.g},p.lc=function(){return this.i},p.mc=function(t){throw Y(new Ai)};var jmn=k(Pt,"ImmutableEntry",372);A(903,550,U6,DDe);var $mn=k(Pt,"ImmutableEnumSet",903);A(544,847,Bne,eQ);var Vmn=k(Pt,"ImmutableList/1",544);A(1561,550,PJe),p.tc=function(){return mx(new Nm(this.b.b.tc()))},p.wc=function(){return new NR(this)},p.pc=function(t){try{return t!=null&&RC(this.a,t)}catch(i){if(i=hr(i),re(i,177))return!1;throw Y(i)}},p.qc=function(t){var i,a;for(a=t.tc();a.hc();)if(i=a.ic(),i==null)return!1;try{return zpe(this.a,t)}catch(l){if(l=hr(l),re(l,177))return!1;throw Y(l)}},p.Ad=function(){return mx(new Nm(this.b.b.tc()))},p.yc=function(){return oje(this,le(sn,nt,1,this.b.b._b(),5,1))},p.zc=function(t){return $U(this,t)};var Mnt,t3e,Wmn=k(Pt,"ImmutableSortedSet",1561);A(904,482,fd,NNe),p.tc=function(){return Vge(this.a)},p.Ib=function(){return $p(this.a)+" (cycled)"};var Hmn=k(Pt,"Iterables/1",904);A(200,1,Ju,z),p.Kb=function(t){return h(t,20).tc()},p.Fb=function(t){return this===t};var qmn=k(Pt,"Iterables/12",200);A(905,482,fd,h9e),p.sc=function(t){Hn(t),this.b.sc(new HBe(this.a,t))},p.tc=function(){return qC(this)};var Xmn=k(Pt,"Iterables/4",905);A(906,1,{},HBe),p.td=function(t){jEt(this.b,this.a,t)};var Ymn=k(Pt,"Iterables/4/lambda$0$Type",906);A(907,482,fd,d9e),p.sc=function(t){Hn(t),this.a.sc(new qBe(t,this.b))},p.tc=function(){return Zh(this)};var Zmn=k(Pt,"Iterables/5",907);A(908,1,{},qBe),p.td=function(t){this.a.td(this.b.Kb(t))};var Kmn=k(Pt,"Iterables/5/lambda$0$Type",908),Tnt,n3e;A(945,1665,Bne,te),p.hc=function(){return!1},p.Cc=function(){return!1},p.ic=function(){throw Y(new K)},p.Dc=function(){return 0},p.Ec=function(){throw Y(new K)},p.Fc=function(){return-1};var Jmn=k(Pt,"Iterators/1",945);A(555,257,$7,hR),p.hc=function(){return!this.a},p.ic=function(){if(this.a)throw Y(new K);return this.a=!0,this.b},p.a=!1;var Qmn=k(Pt,"Iterators/11",555);A(946,1,ys,se),p.gc=function(t){Ss(this,t)},p.hc=function(){return!1},p.ic=function(){throw Y(new K)},p.jc=function(){Ag(!1,Tw)};var e1n=k(Pt,"Iterators/2",946);A(947,257,$7,fR),p.hc=function(){return this.a.hc()},p.ic=function(){return this.a.ic()};var t1n=k(Pt,"Iterators/3",947);A(948,1,ys,R8e),p.gc=function(t){Ss(this,t)},p.hc=function(){return this.a.hc()||this.b.tc().hc()},p.ic=function(){return nbe(this)},p.jc=function(){this.a.jc()};var n1n=k(Pt,"Iterators/4",948);A(950,949,$7,XBe);var i1n=k(Pt,"Iterators/6",950);A(951,479,ys,_Fe),p.Dd=function(t){return this.a.Kb(t)};var r1n=k(Pt,"Iterators/7",951);A(647,1,ys),p.gc=function(t){Ss(this,t)},p.hc=function(){return Gn(this)},p.ic=function(){return Mn(this)},p.jc=function(){Ag(!!this.c,Tw),this.c.jc(),this.c=null};var s1n=k(Pt,"MultitransformedIterator",647);A(182,647,{182:1,43:1},Od),p.Fd=function(t){return h(t,43)};var o1n=k(Pt,"Iterators/ConcatenatedIterator",182);A(648,647,ys,ppe),p.Fd=function(t){return LRt(h(t,43))};var a1n=k(Pt,"Iterators/ConcatenatedIterator/1",648);A(1540,557,F6,LWe),p.Pb=function(){K0e(this),LE(this.a,this.a)},p.md=function(){return new Fge(this.b)},p.Pc=function(t){return new PVe(this,t,this.b)},p.Kc=function(){return new Bge(this)},p.Lc=function(){var t;return new pi((t=this.g,h(t||(this.g=new mF(this)),19)),17)},p.Xb=function(){var t;return t=this.i,t||(this.i=re(this.c,122)?new Zv(this,h(this.c,122)):re(this.c,115)?new q2(this,h(this.c,115)):new qE(this,this.c))},p.Rc=function(){return Xr(),rA(new Bge(this),(i_(),p5))},p.Sc=function(){var t;return UJ(new pi((t=this.g,h(t||(this.g=new mF(this)),19)),17),new ne)},p.b=2;var c1n=k(Pt,"LinkedHashMultimap",1540);A(1543,1,ps,ne),p.Kb=function(t){return h(t,38).lc()};var l1n=k(Pt,"LinkedHashMultimap/0methodref$getValue$Type",1543);A(728,1,ys,Bge),p.gc=function(t){Ss(this,t)},p.ic=function(){return Xkt(this)},p.hc=function(){return this.a!=this.b.a},p.jc=function(){Ag(!!this.c,Tw),J7e(this.b,this.c.g,this.c.i),this.c=null};var u1n=k(Pt,"LinkedHashMultimap/1",728);A(310,372,{392:1,372:1,310:1,1706:1,3:1,38:1},S1e),p.Gd=function(){return this.f},p.Hd=function(t){this.c=t},p.Id=function(t){this.f=t},p.d=0;var Cnt=k(Pt,"LinkedHashMultimap/ValueEntry",310);A(1541,1660,{1706:1,20:1,25:1,13:1,19:1},PVe),p.nc=function(t){var i,a,l,f,g;for(g=W_e*x1e((t==null?0:Wr(t))*H_e,15),i=g&this.b.length-1,f=this.b[i],a=f;a;a=a.a)if(a.d==g&&Ip(a.i,t))return!1;return l=new S1e(this.c,t,g,f),uBe(this.d,l),l.f=this,this.d=l,LE(this.g.a.b,l),LE(l,this.g.a),this.b[i]=l,++this.f,++this.e,ABt(this),!0},p.Pb=function(){var t,i;for(CK(this.b,null),this.f=0,t=this.a;t!=this;t=t.Gd())i=h(t,310),LE(i.b,i.e);this.a=this,this.d=this,++this.e},p.pc=function(t){var i,a;for(a=W_e*x1e((t==null?0:Wr(t))*H_e,15),i=this.b[a&this.b.length-1];i;i=i.a)if(i.d==a&&Ip(i.i,t))return!0;return!1},p.sc=function(t){var i;for(Hn(t),i=this.a;i!=this;i=i.Gd())t.td(h(i,310).i)},p.Gd=function(){return this.a},p.tc=function(){return new cUe(this)},p.vc=function(t){return AXe(this,t)},p.Hd=function(t){this.d=t},p.Id=function(t){this.a=t},p._b=function(){return this.f},p.e=0,p.f=0;var f1n=k(Pt,"LinkedHashMultimap/ValueSet",1541);A(1542,1,ys,cUe),p.gc=function(t){Ss(this,t)},p.hc=function(){return Gme(this),this.b!=this.c},p.ic=function(){var t,i;if(Gme(this),this.b==this.c)throw Y(new K);return t=h(this.b,310),i=t.i,this.d=t,this.b=t.f,i},p.jc=function(){Gme(this),Ag(!!this.d,Tw),AXe(this.c,this.d.i),this.a=this.c.e,this.d=null},p.a=0;var h1n=k(Pt,"LinkedHashMultimap/ValueSet/1",1542);A(689,1677,One,$pe),p.Hc=function(){return v0(this)},p.Fb=function(t){return kee(this,t)},p.Mc=function(t){return new xK(this,t)},p.Nc=function(t){return PQ(this,t)},p.Pb=function(){JJ(this)},p.Qb=function(t){return Ppe(this,t)},p.Ic=function(){return new jpe(this)},p.Jc=function(){return new tY(this)},p.Kc=function(){throw Y(new AQ("should never be called"))},p.Tc=function(t){return new xK(this,t)},p.Wb=function(){return!this.a},p.Uc=function(t){return PQ(this,t)},p._b=function(){return this.d},p.c=0,p.d=0;var d1n=k(Pt,"LinkedListMultimap",689);A(41,25,Rx),p.jd=function(t){Ug(this,t)},p.wc=function(){return new pi(this,16)},p.bd=function(t,i){throw Y(new Tp("Add not supported on this list"))},p.nc=function(t){return this.bd(this._b(),t),!0},p.Pb=function(){this.Jd(0,this._b())},p.Fb=function(t){return Cve(this,t)},p.Hb=function(){return ybe(this)},p.dd=function(t){return Zje(this,t)},p.tc=function(){return new SE(this)},p.ed=function(){return this.fd(0)},p.fd=function(t){return new Ns(this,t)},p.gd=function(t){throw Y(new Tp("Remove not supported on this list"))},p.Jd=function(t,i){var a,l;for(l=this.fd(t),a=t;a0||this.c.hc()},p.ic=function(){if(!(this.d>0||this.c.hc()))throw Y(new K);return this.d==0&&(this.b=h(this.c.ic(),312),this.f=this.d=h(this.b.a.lc(),13)._b()),--this.d,this.a=!0,this.b.a.kc()},p.jc=function(){Ag(this.a,Tw),this.f==1?this.c.jc():vve(this.e,this.b.a.kc(),1)>0,--this.f,this.a=!1},p.a=!1,p.d=0,p.f=0;var Y1n=k(Pt,"Multisets/MultisetIteratorImpl",981);A(667,1,ps,Ce),p.Kb=function(t){return new pi(RRt(h(h(t,300).a.lc(),13)._b(),h(t,300).a.kc()),16)};var Z1n=k(Pt,"Multisets/lambda$0$Type",667);A(1684,1,Or),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)};var K1n=k(Pt,"Ordering",1684);A(1565,1684,Gne,Q),p.Ld=function(t,i){return AMt(h(t,34),h(i,34))},p.Ib=function(){return"Ordering.natural()"};var Pnt,J1n=k(Pt,"NaturalOrdering",1565);A(464,1,{138:1,464:1,3:1,56:1},dwe),p.Mb=function(t){return uAt(this,h(t,34))},p.Nb=function(t){return this.Mb(t)},p.Fb=function(t){var i;return re(t,464)?(i=h(t,464),rwe(this.a,i.a)&&rwe(this.b,i.b)):!1},p.Hb=function(){return Wr(this.a)*31+Wr(this.b)},p.Ib=function(){return aze(this.a,this.b)};var Q1n=k(Pt,"Range",464);A(485,1675,Une,K9),p.Cd=function(){return this.a};var e0n=k(Pt,"RegularImmutableList",485);A(554,550,U6,TK);var GP,t0n=k(Pt,"RegularImmutableSet",554);A(729,1561,PJe,M1e);var n0n=k(Pt,"RegularImmutableSortedSet",729);A(543,1664,{543:1,3:1,20:1,13:1,196:1,19:1,60:1},uOe);var i0n=k(Pt,"Sets/UnmodifiableNavigableSet",543);A(1165,1675,Une,a8e),p.Cd=function(){return this.a};var r0n=k(Pt,"SingletonImmutableList",1165);A(326,1671,U6,j2),p.tc=function(){return So(),new hR(this.a)},p.pc=function(t){return Li(this.a,t)},p.Ad=function(){return So(),new hR(this.a)},p._b=function(){return 1};var s0n=k(Pt,"SingletonImmutableSet",326);A(1415,1414,F6,jUe),p.Hc=function(){var t;return t=this.f,h(h(t||(this.f=re(this.c,122)?new nA(this,h(this.c,122)):re(this.c,115)?new XE(this,h(this.c,115)):new NE(this,this.c)),115),122)},p.Xb=function(){var t;return t=this.i,h(h(t||(this.i=re(this.c,122)?new Zv(this,h(this.c,122)):re(this.c,115)?new q2(this,h(this.c,115)):new qE(this,this.c)),60),196)},p.Pc=function(t){return t==null&&this.a.Ld(null,null),new tw(this.b)};var o0n=k(Pt,"TreeMultimap",1415);A(78,1,{3:1,78:1}),p.Nd=function(t){return new w.Error(t)},p.Od=function(){return this.g},p.Pd=function(){var t,i,a;a=this.g==null?null:this.g.replace(new w.RegExp(` +`,"g")," "),i=(t=Um(this.ql),a==null?t:t+": "+a),UMt(this,FLt(this.Nd(i))),Vi(this)},p.Ib=function(){return $Ue(this,this.Od())},p.e=kJe,p.i=!1,p.n=!0;var Lnt=k(ha,"Throwable",78);A(104,78,{3:1,104:1,78:1});var a0n=k(ha,"Exception",104);A(54,104,Yd,Sp,ta);var c0n=k(ha,"RuntimeException",54);A(539,54,Yd);var l0n=k(ha,"JsException",539);A(760,539,Yd);var u0n=k(z6,"JavaScriptExceptionBase",760);A(435,760,{435:1,3:1,104:1,54:1,78:1},wWe),p.Od=function(){return HBt(this),this.c},p.Qd=function(){return Be(this.b)===Be(i3e)?null:this.b};var i3e,f0n=k(Y_e,"JavaScriptException",435),knt=k(Y_e,"JavaScriptObject$",0),Yre;A(1640,1,{});var h0n=k(Y_e,"Scheduler",1640),Fz=0,Rnt=0,Uz=-1;A(787,1640,{},F);var r3e,d0n=k(z6,"SchedulerImpl",787),Zre;A(1653,1,{});var p0n=k(z6,"StackTraceCreator/Collector",1653);A(761,1653,{},O),p.Rd=function(t){var i={},a,l=[];t[Z_e]=l;for(var f=arguments.callee.caller;f;){var g=(sS(),f.name||(f.name=bRt(f.toString())));l.push(g);var m=":"+g,v=i[m];if(v){var y,E;for(y=0,E=v.length;y=0?"+":"")+(a/60|0),i=(a<0?-a:a)%60<10?"0"+(a<0?-a:a)%60:""+(a<0?-a:a)%60,(Tqe(),$nt)[this.q.getDay()]+" "+Vnt[this.q.getMonth()]+" "+eJ(this.q.getDate())+" "+eJ(this.q.getHours())+":"+eJ(this.q.getMinutes())+":"+eJ(this.q.getSeconds())+" GMT"+t+i+" "+this.q.getFullYear()};var zz=k(Vn,"Date",181);A(1622,181,OJe,JHe),p.a=!1,p.b=0,p.c=0,p.d=0,p.e=0,p.f=0,p.g=!1,p.i=0,p.j=0,p.k=0,p.n=0,p.o=0,p.p=0;var T0n=k("com.google.gwt.i18n.shared.impl","DateRecord",1622);A(1659,1,{}),p.Vd=function(){return null},p.Wd=function(){return null},p.Xd=function(){return null},p.Yd=function(){return null},p.Zd=function(){return null};var C0n=k(Bx,"JSONValue",1659);A(209,1659,{209:1},Om,wF),p.Fb=function(t){return re(t,209)?H1e(this.a,h(t,209).a):!1},p.Ud=function(){return Xde},p.Hb=function(){return B1e(this.a)},p.Vd=function(){return this},p.Ib=function(){var t,i,a;for(a=new su("["),i=0,t=this.a.length;i0&&(a.a+=","),Rc(a,gx(this,i));return a.a+="]",a.a};var A0n=k(Bx,"JSONArray",209);A(443,1659,{443:1},vF),p.Ud=function(){return Yde},p.Wd=function(){return this},p.Ib=function(){return vt(),""+this.a},p.a=!1;var Int,Dnt,P0n=k(Bx,"JSONBoolean",443);A(877,54,Yd,BDe);var L0n=k(Bx,"JSONException",877);A(913,1659,{},at),p.Ud=function(){return n8},p.Ib=function(){return qc};var Bnt,k0n=k(Bx,"JSONNull",913);A(259,1659,{259:1},dR),p.Fb=function(t){return re(t,259)?this.a==h(t,259).a:!1},p.Ud=function(){return QZ},p.Hb=function(){return wr(ce(this.a))},p.Xd=function(){return this},p.Ib=function(){return this.a+""},p.a=0;var R0n=k(Bx,"JSONNumber",259);A(191,1659,{191:1},SC,lC),p.Fb=function(t){return re(t,191)?H1e(this.a,h(t,191).a):!1},p.Ud=function(){return Zde},p.Hb=function(){return B1e(this.a)},p.Yd=function(){return this},p.Ib=function(){var t,i,a,l,f,g;for(g=new su("{"),t=!0,f=rbe(this,le(Se,be,2,0,6,1)),a=0,l=f.length;a=0?":"+this.c:"")+")"},p.c=0;var b3e=k(ha,"StackTraceElement",287);Ent={3:1,476:1,34:1,2:1};var Se=k(ha,X_e,2);A(100,381,{476:1},Mp,MC,ru);var Q0n=k(ha,"StringBuffer",100);A(98,381,{476:1},u0,Qb,su);var ebn=k(ha,"StringBuilder",98);A(763,79,lie,FDe);var tbn=k(ha,"StringIndexOutOfBoundsException",763);A(1722,1,{});var w3e,v3e;A(46,54,{3:1,104:1,54:1,78:1,46:1},Ai,Tp);var nbn=k(ha,"UnsupportedOperationException",46);A(216,210,{3:1,34:1,210:1,216:1},kI,mpe),p.vd=function(t){return jZe(this,h(t,216))},p.$d=function(){return _w(dKe(this))},p.Fb=function(t){var i;return this===t?!0:re(t,216)?(i=h(t,216),this.e==i.e&&jZe(this,i)==0):!1},p.Hb=function(){var t;return this.b!=0?this.b:this.a<54?(t=Vc(this.f),this.b=nr(Zr(t,-1)),this.b=33*this.b+nr(Zr(Pg(t,32),-1)),this.b=17*this.b+wr(this.e),this.b):(this.b=17*UVe(this.c)+wr(this.e),this.b)},p.Ib=function(){return dKe(this)},p.a=0,p.b=0,p.d=0,p.e=0,p.f=0;var Unt,_1,_3e,y3e,x3e,E3e,S3e,M3e,Qre=k("java.math","BigDecimal",216);A(89,210,{3:1,34:1,210:1,89:1},hwe,Fp,l_,Owe,QWe,Tg),p.vd=function(t){return FWe(this,h(t,89))},p.$d=function(){return _w(Ine(this,0))},p.Fb=function(t){return Obe(this,t)},p.Hb=function(){return UVe(this)},p.Ib=function(){return Ine(this,0)},p.b=-2,p.c=0,p.d=0,p.e=0;var ese,Gz,T3e,tse,jz,aM,ly=k("java.math","BigInteger",89),znt,Gnt,qx,VP;A(441,1666,jS),p.Pb=function(){tl(this)},p.Qb=function(t){return b0(this,t)},p.Rb=function(t){return CVe(this,t,this.e)||CVe(this,t,this.d)},p.Tb=function(){return new xp(this)},p.Vb=function(t){return Ii(this,t)},p.Zb=function(t,i){return fr(this,t,i)},p.$b=function(t){return fS(this,t)},p._b=function(){return BE(this)};var ibn=k(Vn,"AbstractHashMap",441);A(242,ud,pu,xp),p.Pb=function(){this.a.Pb()},p.pc=function(t){return Y7e(this,t)},p.tc=function(){return new Zm(this.a)},p.vc=function(t){var i;return Y7e(this,t)?(i=h(t,38).kc(),this.a.$b(i),!0):!1},p._b=function(){return this.a._b()};var rbn=k(Vn,"AbstractHashMap/EntrySet",242);A(243,1,ys,Zm),p.gc=function(t){Ss(this,t)},p.ic=function(){return P0(this)},p.hc=function(){return this.b},p.jc=function(){RGe(this)},p.b=!1;var sbn=k(Vn,"AbstractHashMap/EntrySetIterator",243);A(433,1,ys,SE),p.gc=function(t){Ss(this,t)},p.hc=function(){return y8(this)},p.ic=function(){return _Ue(this)},p.jc=function(){_f(this)},p.b=0,p.c=-1;var obn=k(Vn,"AbstractList/IteratorImpl",433);A(94,433,Th,Ns),p.jc=function(){_f(this)},p.Bc=function(t){ed(this,t)},p.Cc=function(){return this.b>0},p.Dc=function(){return this.b},p.Ec=function(){return kn(this.b>0),this.a.cd(this.c=--this.b)},p.Fc=function(){return this.b-1},p.Gc=function(t){s_(this.c!=-1),this.a.hd(this.c,t)};var abn=k(Vn,"AbstractList/ListIteratorImpl",94);A(227,41,Rx,Rg),p.bd=function(t,i){g_(t,this.b),this.c.bd(this.a+t,i),++this.b},p.cd=function(t){return oi(t,this.b),this.c.cd(this.a+t)},p.gd=function(t){var i;return oi(t,this.b),i=this.c.gd(this.a+t),--this.b,i},p.hd=function(t,i){return oi(t,this.b),this.c.hd(this.a+t,i)},p._b=function(){return this.b},p.a=0,p.b=0;var cbn=k(Vn,"AbstractList/SubList",227);A(352,ud,pu,Gv),p.Pb=function(){this.a.Pb()},p.pc=function(t){return this.a.Qb(t)},p.tc=function(){var t;return t=this.a.Tb().tc(),new pR(t)},p.vc=function(t){return this.a.Qb(t)?(this.a.$b(t),!0):!1},p._b=function(){return this.a._b()};var lbn=k(Vn,"AbstractMap/1",352);A(542,1,ys,pR),p.gc=function(t){Ss(this,t)},p.hc=function(){return this.a.hc()},p.ic=function(){var t;return t=h(this.a.ic(),38),t.kc()},p.jc=function(){this.a.jc()};var ubn=k(Vn,"AbstractMap/1/1",542);A(223,25,Y_,mh),p.Pb=function(){this.a.Pb()},p.pc=function(t){return this.a.Rb(t)},p.tc=function(){var t;return t=this.a.Tb().tc(),new o0(t)},p._b=function(){return this.a._b()};var fbn=k(Vn,"AbstractMap/2",223);A(321,1,ys,o0),p.gc=function(t){Ss(this,t)},p.hc=function(){return this.a.hc()},p.ic=function(){var t;return t=h(this.a.ic(),38),t.lc()},p.jc=function(){this.a.jc()};var hbn=k(Vn,"AbstractMap/2/1",321);A(440,1,{440:1,38:1}),p.Fb=function(t){var i;return re(t,38)?(i=h(t,38),el(this.d,i.kc())&&el(this.e,i.lc())):!1},p.kc=function(){return this.d},p.lc=function(){return this.e},p.Hb=function(){return H8(this.d)^H8(this.e)},p.mc=function(t){return eme(this,t)},p.Ib=function(){return this.d+"="+this.e};var dbn=k(Vn,"AbstractMap/AbstractEntry",440);A(351,440,{440:1,351:1,38:1},S8);var pbn=k(Vn,"AbstractMap/SimpleEntry",351);A(1672,1,G7),p.Fb=function(t){var i;return re(t,38)?(i=h(t,38),el(this.kc(),i.kc())&&el(this.lc(),i.lc())):!1},p.Hb=function(){return H8(this.kc())^H8(this.lc())},p.Ib=function(){return this.kc()+"="+this.lc()};var gbn=k(Vn,MJe,1672);A(1685,1666,EJe),p.Wc=function(t){return Xze(this,t)},p.Qb=function(t){return AK(this,t)},p.Tb=function(){return new AF(this)},p.Vb=function(t){return Ic(Sbe(this,t))},p.Xb=function(){return new jv(this)};var mbn=k(Vn,"AbstractNavigableMap",1685);A(668,ud,pu,AF),p.pc=function(t){return re(t,38)&&Xze(this.b,h(t,38))},p.tc=function(){return new aI(this.b)},p.vc=function(t){var i;return re(t,38)?(i=h(t,38),IGe(this.b,i)):!1},p._b=function(){return this.b.c};var bbn=k(Vn,"AbstractNavigableMap/EntrySet",668);A(488,ud,V_e,jv),p.wc=function(){return new NR(this)},p.Pb=function(){PR(this.a)},p.pc=function(t){return AK(this.a,t)},p.tc=function(){var t;return t=new aI(new JR(this.a).b),new uC(t)},p.vc=function(t){return AK(this.a,t)?(fA(this.a,t),!0):!1},p._b=function(){return this.a.c};var wbn=k(Vn,"AbstractNavigableMap/NavigableKeySet",488);A(489,1,ys,uC),p.gc=function(t){Ss(this,t)},p.hc=function(){return y8(this.a.a)},p.ic=function(){var t;return t=dJ(this.a),t.kc()},p.jc=function(){j8e(this.a)};var vbn=k(Vn,"AbstractNavigableMap/NavigableKeySet/1",489);A(1693,25,Y_),p.nc=function(t){return hS(kS(this,t)),!0},p.oc=function(t){return pn(t),u9(t!=this,"Can't add a queue to itself"),wo(this,t)},p.Pb=function(){for(;eee(this)!=null;);};var _bn=k(Vn,"AbstractQueue",1693);A(407,25,{4:1,20:1,25:1,13:1},CE,q9e),p.nc=function(t){return J1e(this,t),!0},p.Pb=function(){a0e(this)},p.pc=function(t){return nVe(new hA(this),t)},p.Wb=function(){return wpe(this)},p.tc=function(){return new hA(this)},p.vc=function(t){return JPt(new hA(this),t)},p._b=function(){return this.c-this.b&this.a.length-1},p.wc=function(){return new pi(this,272)},p.zc=function(t){var i,a;return a=this.c-this.b&this.a.length-1,t.lengtha&&zr(t,a,null),t},p.b=0,p.c=0;var ybn=k(Vn,"ArrayDeque",407);A(408,1,ys,hA),p.gc=function(t){Ss(this,t)},p.hc=function(){return this.a!=this.b},p.ic=function(){return DU(this)},p.jc=function(){e$e(this)},p.a=0,p.b=0,p.c=-1;var xbn=k(Vn,"ArrayDeque/IteratorImpl",408);A(12,41,UJe,Re,zl,wf),p.bd=function(t,i){w0(this,t,i)},p.nc=function(t){return De(this,t)},p.oc=function(t){return Lr(this,t)},p.Pb=function(){this.c=le(sn,nt,1,0,5,1)},p.pc=function(t){return Jo(this,t,0)!=-1},p.sc=function(t){ad(this,t)},p.cd=function(t){return Tt(this,t)},p.dd=function(t){return Jo(this,t,0)},p.Wb=function(){return this.c.length==0},p.tc=function(){return new j(this)},p.gd=function(t){return A0(this,t)},p.vc=function(t){return Ea(this,t)},p.Jd=function(t,i){S7e(this,t,i)},p.hd=function(t,i){return Wu(this,t,i)},p._b=function(){return this.c.length},p.jd=function(t){ua(this,t)},p.yc=function(){return mJ(this)},p.zc=function(t){return vo(this,t)};var Q$t=k(Vn,"ArrayList",12);A(7,1,ys,j),p.gc=function(t){Ss(this,t)},p.hc=function(){return Yo(this)},p.ic=function(){return $(this)},p.jc=function(){cA(this)},p.a=0,p.b=-1;var Ebn=k(Vn,"ArrayList/1",7);A(155,41,zJe,Dl),p.pc=function(t){return Zje(this,t)!=-1},p.sc=function(t){var i,a,l,f;for(pn(t),a=this.a,l=0,f=a.length;l=0},p.qc=function(t){return Gg(this.b,t)},p.tc=function(){return new Nm(iS(this.b).b.tc())},p.vc=function(t){return p$e(this,t)},p._b=function(){return this.b.c.length},p.wc=function(){return new pi(this,256)},p.yc=function(){return mJ(this.b)},p.zc=function(t){return vo(this.b,t)};var pwn=k(Vn,"PriorityQueue",453);A(214,1,{214:1},Jee,J9),p.a=0,p.b=0;var R3e,I3e,iVt=0,gwn=k(Vn,"Random",214);A(39,1,Vp,pi,rx,PGe),p.qd=function(){return this.a},p.rd=function(){return r1e(this),this.c},p.gc=function(t){r1e(this),this.d.gc(t)},p.sd=function(t){return U0e(this,t)},p.a=0,p.c=0;var mwn=k(Vn,"Spliterators/IteratorSpliterator",39);A(382,39,Vp,NR);var bwn=k(Vn,"SortedSet/1",382);A(625,1,{},PF),p.ie=function(t){this.a.td(t)};var wwn=k(Vn,"Spliterator/OfDouble/0methodref$accept$Type",625);A(626,1,{},LF),p.ie=function(t){this.a.td(t)};var vwn=k(Vn,"Spliterator/OfDouble/1methodref$accept$Type",626);A(642,1,Vp),p.gc=function(t){IBe(this,t)},p.qd=function(){return this.d},p.rd=function(){return this.e},p.d=0,p.e=0;var _wn=k(Vn,"Spliterators/BaseSpliterator",642);A(929,642,Vp),p.gc=function(t){re(t,273)?Cme(this,h(t,273)):Cme(this,new LF(t))},p.sd=function(t){return re(t,273)?a_(this,h(t,273)):a_(this,new PF(t))};var ywn=k(Vn,"Spliterators/AbstractDoubleSpliterator",929);A(446,642,Vp);var xwn=k(Vn,"Spliterators/AbstractSpliterator",446);A(790,1,Vp),p.gc=function(t){IBe(this,t)},p.qd=function(){return this.b},p.rd=function(){return this.d-this.c},p.b=0,p.c=0,p.d=0;var Ewn=k(Vn,"Spliterators/BaseArraySpliterator",790);A(791,790,Vp,SUe),p.gc=function(t){KAt(this,t)},p.sd=function(t){return akt(this,t)};var Swn=k(Vn,"Spliterators/ArraySpliterator",791);A(789,1,ys,xBe),p.gc=function(t){re(t,273)?Gze(this,h(t,273)):Gze(this,new hC(t))},p.ic=function(){return eU(this)},p.jc=function(){jDe()},p.ie=function(t){this.b=t},p.hc=function(){return this.a||(this.a=a_(this.c,this)),this.a},p.a=!1,p.b=0;var Mwn=k(Vn,"Spliterators/DoubleConsumerIterator",789);A(523,41,jJe,Yh),p.bd=function(t,i){oA(t,this.a.c.length+1),w0(this.a,t,i)},p.nc=function(t){return De(this.a,t)},p.oc=function(t){return Lr(this.a,t)},p.Pb=function(){this.a.c=le(sn,nt,1,0,5,1)},p.pc=function(t){return Jo(this.a,t,0)!=-1},p.qc=function(t){return Gg(this.a,t)},p.sc=function(t){ad(this.a,t)},p.cd=function(t){return oA(t,this.a.c.length),Tt(this.a,t)},p.dd=function(t){return Jo(this.a,t,0)},p.Wb=function(){return this.a.c.length==0},p.tc=function(){return new j(this.a)},p.gd=function(t){return oA(t,this.a.c.length),A0(this.a,t)},p.Jd=function(t,i){S7e(this.a,t,i)},p.hd=function(t,i){return oA(t,this.a.c.length),Wu(this.a,t,i)},p._b=function(){return this.a.c.length},p.jd=function(t){ua(this.a,t)},p.kd=function(t,i){return new Rg(this.a,t,i)},p.yc=function(){return mJ(this.a)},p.zc=function(t){return vo(this.a,t)},p.Ib=function(){return $p(this.a)};var Twn=k(Vn,"Vector",523);A(596,523,jJe,sK);var Cwn=k(Vn,"Stack",596);A(254,1,{},C0),p.Ib=function(){return this.a?this.e.length==0?this.a.a:this.a.a+(""+this.e):this.c};var Awn=k(Vn,"StringJoiner",254);A(487,1685,{3:1,109:1,122:1,115:1},iOe,WJ),p.Pb=function(){PR(this)},p.Tb=function(){return new JR(this)},p.Zb=function(t,i){return kU(this,t,i)},p.$b=function(t){return fA(this,t)},p._b=function(){return this.c},p.c=0;var Pwn=k(Vn,"TreeMap",487);A(397,1,ys,aI),p.gc=function(t){Ss(this,t)},p.ic=function(){return dJ(this)},p.hc=function(){return y8(this.a)},p.jc=function(){j8e(this)};var Lwn=k(Vn,"TreeMap/EntryIterator",397);A(449,668,pu,JR),p.Pb=function(){PR(this.a)};var kwn=k(Vn,"TreeMap/EntrySet",449);A(398,351,{440:1,351:1,38:1,398:1},jQ),p.b=!1;var rVt=k(Vn,"TreeMap/Node",398);A(560,1,{},oe),p.Ib=function(){return"State: mv="+this.c+" value="+this.d+" done="+this.a+" found="+this.b},p.a=!1,p.b=!1,p.c=!1;var Rwn=k(Vn,"TreeMap/State",560);A(278,23,pie,M8),p.je=function(){return!1},p.ke=function(){return!1};var nse,D3e,B3e,O3e,Vz=Mi(Vn,"TreeMap/SubMapType",278,Di,JLt,oTt);A(982,278,pie,WNe),p.ke=function(){return!0};var Iwn=Mi(Vn,"TreeMap/SubMapType/1",982,Vz,null,null);A(983,278,pie,nFe),p.je=function(){return!0},p.ke=function(){return!0};var Dwn=Mi(Vn,"TreeMap/SubMapType/2",983,Vz,null,null);A(984,278,pie,HNe),p.je=function(){return!0};var Bwn=Mi(Vn,"TreeMap/SubMapType/3",984,Vz,null,null),Xnt;A(212,ud,{3:1,20:1,25:1,13:1,196:1,19:1,60:1,212:1},Qde,tw),p.wc=function(){return new NR(this)},p.nc=function(t){return R9(this,t)},p.Pb=function(){PR(this.a)},p.pc=function(t){return AK(this.a,t)},p.tc=function(){var t;return t=new aI(new JR(new jv(this.a).a).b),new uC(t)},p.vc=function(t){return Uge(this,t)},p._b=function(){return this.a.c};var sVt=k(Vn,"TreeSet",212);A(845,1,{},_Y),p.le=function(t,i){return LMt(this.a,t,i)};var Own=k(gie,"BinaryOperator/lambda$0$Type",845);A(846,1,{},xr),p.le=function(t,i){return Lp(h(t,21).a,h(i,21).a)<=0?t:i};var Nwn=k(gie,"BinaryOperator/lambda$1$Type",846);A(843,1,ps,de),p.Kb=function(t){return t};var Fwn=k(gie,"Function/lambda$0$Type",843);A(627,1,ss,RF),p.Nb=function(t){return!this.a.Nb(t)};var Uwn=k(gie,"Predicate/lambda$0$Type",627);A(150,23,{3:1,34:1,23:1,150:1},PK);var N3e,eh,Iw,th=Mi(Ys,"Collector/Characteristics",150,Di,lLt,aTt),Ynt;A(684,1,{},W8e,fqe);var zwn=k(Ys,"Collector/CollectorImpl",684);A(1053,1,ps,yY),p.Kb=function(t){return vt(),!!i0e(t)};var Gwn=k(Ys,"Collectors/12methodref$test$Type",1053);A(365,1,{},jt),p.Kd=function(t,i){h(t,13).nc(i)};var jwn=k(Ys,"Collectors/20methodref$add$Type",365);A(367,1,{},gn),p.ne=function(){return new Re};var $wn=k(Ys,"Collectors/21methodref$ctor$Type",367);A(331,1,{},Un),p.ne=function(){return new Ur};var Vwn=k(Ys,"Collectors/23methodref$ctor$Type",331);A(332,1,{},bi),p.Kd=function(t,i){Cr(h(t,67),i)};var Wwn=k(Ys,"Collectors/24methodref$add$Type",332);A(1050,1,{},Zi),p.le=function(t,i){return rOe(h(t,15),h(i,13))};var Hwn=k(Ys,"Collectors/4methodref$addAll$Type",1050);A(683,1,{},Hi),p.le=function(t,i){return $1e(t,i)};var qwn=k(Ys,"Collectors/lambda$1$Type",683);A(1055,1,{},xY),p.ne=function(){return X(q(sn,1),nt,1,5,[this.a])};var Xwn=k(Ys,"Collectors/lambda$10$Type",1055);A(1056,1,{},bR),p.Kd=function(t,i){$Ct(this.a,t)};var Ywn=k(Ys,"Collectors/lambda$11$Type",1056);A(1057,1,{},DF),p.le=function(t,i){return gAt(this.a,t,i)};var Zwn=k(Ys,"Collectors/lambda$12$Type",1057);A(1058,1,ps,yr),p.Kb=function(t){return __(t)[0]};var Kwn=k(Ys,"Collectors/lambda$13$Type",1058);A(366,1,{},Tr),p.le=function(t,i){return h(t,13).oc(h(i,13)),h(t,13)};var Jwn=k(Ys,"Collectors/lambda$21$Type",366);A(333,1,{},Ei),p.le=function(t,i){return wo(h(t,67),h(i,67)),h(t,67)};var Qwn=k(Ys,"Collectors/lambda$25$Type",333);A(334,1,ps,it),p.Kb=function(t){return h(t,67)};var evn=k(Ys,"Collectors/lambda$26$Type",334);A(1049,1,{},EY),p.Kd=function(t,i){gIt(this.a,t,i)};var tvn=k(Ys,"Collectors/lambda$3$Type",1049);A(1051,1,{},We),p.le=function(t,i){return tIt(h(t,109),h(i,109),new Zi)};var nvn=k(Ys,"Collectors/lambda$4$Type",1051);A(1052,1,ps,SY),p.Kb=function(t){return x6t(this.a,t)};var ivn=k(Ys,"Collectors/lambda$5$Type",1052);A(1054,1,{},_n),p.ne=function(){var t;return t=new T0,B0(t,(vt(),vt(),!1),new Re),B0(t,!0,new Re),t};var rvn=k(Ys,"Collectors/lambda$8$Type",1054);A(645,1,{}),p.d=!1;var svn=k(Ys,"TerminatableStream",645);A(1416,645,{607:1,1701:1},JFe);var ovn=k(Ys,"DoubleStream/DoubleStreamSource",1416);A(1417,1,{},MY),p.ie=function(t){NWe(this.a,t)};var avn=k(Ys,"DoubleStream/DoubleStreamSource/lambda$2$Type",1417),oVt=br(Ys,"Stream");A(940,446,Vp,I8e),p.sd=function(t){for(;Mkt(this);){if(this.a.sd(t))return!0;this.a=null}return!1};var cvn=k(Ys,"Stream/2",940);A(941,1,{},TY),p.td=function(t){oMt(this.a,t)};var lvn=k(Ys,"Stream/2/lambda$0$Type",941);A(942,1,H6,CY),p.fe=function(){oQ(this.a)};var uvn=k(Ys,"Stream/3methodref$close$Type",942);A(943,1,H6,AY),p.fe=function(){oQ(this.a)};var fvn=k(Ys,"Stream/4methodref$close$Type",943);A(644,446,Vp,S0e),p.sd=function(t){for(this.b=!1;!this.b&&this.c.sd(new mOe(this,t)););return this.b},p.b=!1;var hvn=k(Ys,"Stream/FilterSpliterator",644);A(932,1,{},mOe),p.td=function(t){mAt(this.a,this.b,t)};var dvn=k(Ys,"Stream/FilterSpliterator/lambda$0$Type",932);A(930,929,Vp,tGe);var pvn=k(Ys,"Stream/MapToDoubleSpliterator",930);A(646,1,{},Hpe),p.td=function(t){qEt(this.a,this.b,t)};var gvn=k(Ys,"Stream/MapToDoubleSpliterator/lambda$0$Type",646);A(643,446,Vp,v0e),p.sd=function(t){return O8e(this,t)};var mvn=k(Ys,"Stream/MapToObjSpliterator",643);A(931,1,{},bOe),p.td=function(t){XEt(this.a,this.b,t)};var bvn=k(Ys,"Stream/MapToObjSpliterator/lambda$0$Type",931);A(45,645,{607:1,1701:1,1700:1},si);var wvn=k(Ys,"Stream/StreamSource",45);A(936,446,Vp,D8e),p.sd=function(t){for(;Tkt(this);){if(this.a.sd(t))return!0;oQ(this.b),this.b=null,this.a=null}return!1};var vvn=k(Ys,"Stream/StreamSource/1",936);A(937,1,{},PY),p.td=function(t){ICt(this.a,t)};var _vn=k(Ys,"Stream/StreamSource/1/lambda$0$Type",937);A(938,446,Vp,IUe),p.sd=function(t){var i;return this.a||(i=new Re,this.b.a.gc(new LY(i)),yt(),ua(i,this.c),this.a=new pi(i,16)),U0e(this.a,t)},p.a=null;var yvn=k(Ys,"Stream/StreamSource/5",938);A(939,1,{},LY),p.td=function(t){De(this.a,t)};var xvn=k(Ys,"Stream/StreamSource/5/2methodref$add$Type",939);A(933,1,{},ve),p.td=function(t){};var Evn=k(Ys,"Stream/StreamSource/lambda$0$Type",933);A(934,1,{},kY),p.le=function(t,i){return $St(this.a,t,i)};var Svn=k(Ys,"Stream/StreamSource/lambda$3$Type",934);A(935,1,{},wOe),p.td=function(t){xSt(this.b,this.a,t)};var Mvn=k(Ys,"Stream/StreamSource/lambda$4$Type",935);A(553,1,{},_t),p.td=function(t){SF(this,t)};var Tvn=k(Ys,"Stream/ValueConsumer",553);A(944,1,{},RY),p.td=function(t){aIt(this.a,t)};var Cvn=k(Ys,"TerminatableStream/lambda$0$Type",944),aVt=0,F3e,U3e=0,Wz;A(1480,1,{},_ze);var Avn=k(VJe,"Scanline",1480),cVt=br(VJe,WJe);A(1450,1,{},_je);var Pvn=k(hd,"CGraph",1450);A(309,1,{309:1},x7e),p.b=0,p.c=0,p.d=0,p.g=0,p.i=0,p.k=Ts;var Lvn=k(hd,"CGroup",309);A(723,1,{},epe);var kvn=k(hd,"CGroup/CGroupBuilder",723);A(57,1,{57:1},u8e),p.Ib=function(){return this.j?Qn(this.j.Kb(this)):(Nd(Hz),Hz.o+"@"+(p0(this)>>>0).toString(16))},p.f=0,p.i=Ts;var Hz=k(hd,"CNode",57);A(722,1,{},tpe);var Rvn=k(hd,"CNode/CNodeBuilder",722),Znt;A(1236,1,{},mn),p.se=function(t,i){return 0},p.te=function(t,i){return 0};var Ivn=k(hd,qJe,1236);A(1505,1,{},yn),p.pe=function(t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V;for(E=Kr,l=new j(t.a.b);l.al.d.c||l.d.c==g.d.c&&l.d.b=0?"b"+t+"["+RQ(this.a)+"]":"b["+RQ(this.a)+"]"):"b_"+p0(this)};var z_n=k(X6,"FBendpoint",497);A(262,131,{3:1,262:1,93:1,131:1},g8e),p.Ib=function(){return RQ(this)};var G_n=k(X6,"FEdge",262);A(202,131,{3:1,202:1,93:1,131:1},iU);var uVt=k(X6,"FGraph",202);A(454,329,{3:1,454:1,329:1,93:1,131:1},vze),p.Ib=function(){return this.b==null||this.b.length==0?"l["+RQ(this.a)+"]":"l_"+this.b};var j_n=k(X6,"FLabel",454);A(146,329,{3:1,146:1,329:1,93:1,131:1},sUe),p.Ib=function(){return X1e(this)},p.b=0;var $_n=k(X6,"FNode",146);A(1691,1,{}),p.Ee=function(t){b_e(this,t)},p.Fe=function(){BHe(this)},p.d=0;var V_n=k(wye,"AbstractForceModel",1691);A(568,1691,{568:1},H$e),p.De=function(t,i){var a,l,f,g,m;return vXe(this.f,t,i),f=Dc(Fa(i.d),t.d),m=w.Math.sqrt(f.a*f.a+f.b*f.b),l=w.Math.max(0,m-sQ(t.e)/2-sQ(i.e)/2),a=eVe(this.e,t,i),a>0?g=-EAt(l,this.c)*a:g=_Mt(l,this.b)*h(G(t,(Mf(),cM)),21).a,ou(f,g/m),f},p.Ee=function(t){b_e(this,t),this.a=h(G(t,(Mf(),Jz)),21).a,this.c=ce(Xe(G(t,Qz))),this.b=ce(Xe(G(t,dse)))},p.Ge=function(t){return t0&&(g-=J3t(l,this.a)*a),ou(f,g*this.b/m),f},p.Ee=function(t){var i,a,l,f,g,m,v;for(b_e(this,t),this.b=ce(Xe(G(t,(Mf(),pse)))),this.c=this.b/h(G(t,Jz),21).a,l=t.e.c.length,g=0,f=0,v=new j(t.e);v.a0},p.a=0,p.b=0,p.c=0;var H_n=k(wye,"FruchtermanReingoldModel",569);A(748,1,dd,BX),p.ue=function(t){zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,K7),""),"Force Model"),"Determines the model for force calculation."),hEe),(o1(),gs)),dEe),Wt((i1(),Pn))))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,vye),""),"Iterations"),"The number of iterations on the force model."),He(300)),yc),Ao),Wt(Pn)))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,_ye),""),"Repulsive Power"),"Determines how many bend points are added to the edge; such bend points are regarded as repelling particles in the force model"),He(0)),yc),Ao),Wt(md)))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Aie),""),"FR Temperature"),"The temperature is used as a scaling factor for particle displacements."),Kd),tc),Eo),Wt(Pn)))),gc(t,Aie,K7,Eit),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Pie),""),"Eades Repulsion"),"Factor for repulsive forces in Eades' model."),5),tc),Eo),Wt(Pn)))),gc(t,Pie,K7,_it),$Ke((new NX,t))};var bit,wit,hEe,vit,_it,yit,xit,Eit,q_n=k(_P,"ForceMetaDataProvider",748);A(387,23,{3:1,34:1,23:1,387:1},Kpe);var hse,Kz,dEe=Mi(_P,"ForceModelStrategy",387,Di,RPt,hTt),Sit;A(880,1,dd,NX),p.ue=function(t){$Ke(t)};var Mit,pEe,Jz,gEe,Tit,mEe,bEe,cM,Cit,dse,wEe,Ait,Pit,Qz,pse,X_n=k(_P,"ForceOptions",880);A(881,1,{},dh),p.Be=function(){var t;return t=new npe,t},p.Ce=function(t){};var Y_n=k(_P,"ForceOptions/ForceFactory",881),y5,HP,Xx,eG;A(749,1,dd,sF),p.ue=function(t){zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Eye),""),"Fixed Position"),"Prevent that the node is moved by the layout algorithm."),(vt(),vt(),!1)),(o1(),va)),lo),Wt((i1(),pa))))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Sye),""),"Desired Edge Length"),"Either specified for parent nodes or for individual edges, where the latter takes higher precedence."),100),tc),Eo),or(Pn,X(q(Jp,1),Oe,163,0,[md]))))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Mye),""),"Layout Dimension"),"Dimensions that are permitted to be altered during layout."),vEe),gs),MEe),Wt(Pn)))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Tye),""),"Stress Epsilon"),"Termination criterion for the iterative process."),Kd),tc),Eo),Wt(Pn)))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Cye),""),"Iteration Limit"),"Maximum number of performed iterations. Takes higher precedence than 'epsilon'."),He(zi)),yc),Ao),Wt(Pn)))),cKe((new OX,t))};var Lit,kit,vEe,Rit,Iit,Dit,Z_n=k(_P,"StressMetaDataProvider",749);A(884,1,dd,OX),p.ue=function(t){cKe(t)};var tG,_Ee,yEe,xEe,EEe,SEe,K_n=k(_P,"StressOptions",884);A(885,1,{},Lm),p.Be=function(){var t;return t=new m8e,t},p.Ce=function(t){};var J_n=k(_P,"StressOptions/StressFactory",885);A(959,244,K_,m8e),p.Ae=function(t,i){var a,l,f,g;for(ni(i,dQe,1),ce(bt(nn(t,(UI(),EEe))))||Qqe(new npe,t,mc(i,1)),l=bVe(t),a=YZe(this.a,l),g=a.tc();g.hc();)f=h(g.ic(),202),gzt(this.b,f),aFt(this.b);l=aJe(a),iJe(l),Bn(i)};var Q_n=k(Rie,"StressLayoutProvider",959);A(882,1,{},iK),p.c=0,p.e=0,p.g=0;var eyn=k(Rie,"StressMajorization",882);A(348,23,{3:1,34:1,23:1,348:1},LK);var gse,mse,bse,MEe=Mi(Rie,"StressMajorization/Dimension",348,Di,_Lt,dTt),Bit;A(883,1,Or,Vv),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return zMt(this.a,t,i)};var tyn=k(Rie,"StressMajorization/lambda$0$Type",883);A(985,1,{},D7e);var nyn=k(K6,"ElkLayered",985);A(986,1,{},Rs),p.td=function(t){Fkt(this.a,t)};var iyn=k(K6,"ElkLayered/lambda$0$Type",986);A(987,1,{},mg),p.td=function(t){Ee(h(t,31),($e(),IG),(mS(),EG))};var ryn=k(K6,"ElkLayered/lambda$1$Type",987);A(1033,1,{},rFe);var Oit,Nit,Fit,syn=k(K6,"GraphConfigurator",1033);A(958,244,K_,gl),p.Ae=function(t,i){var a;a=q9t(new SNe,t),Be(nn(t,($e(),iL)))===Be((e1(),h3))?u6t(this.a,a,i):wFt(this.a,a,i),nJe(new oF,a)};var oyn=k(K6,"LayeredLayoutProvider",958);A(328,23,{3:1,34:1,23:1,328:1},FR);var Ih,Yx,Ja,Qa,Ho,TEe=Mi(K6,"LayeredPhases",328,Di,P4t,pTt),Uit;A(1407,1,{},U$e),p.i=0;var zit,ayn=k(J6,"ComponentsToCGraphTransformer",1407),Git;A(1408,1,{},kv),p.He=function(t,i){return w.Math.min(t.a!=null?ce(t.a):t.c.i,i.a!=null?ce(i.a):i.c.i)},p.Ie=function(t,i){return w.Math.min(t.a!=null?ce(t.a):t.c.i,i.a!=null?ce(i.a):i.c.i)};var cyn=k(J6,"ComponentsToCGraphTransformer/1",1408);A(80,1,{80:1}),p.i=0,p.k=!0,p.o=Ts;var wse=k(xP,"CNode",80);A(282,80,{282:1,80:1},jge,uwe),p.Ib=function(){return""};var lyn=k(J6,"ComponentsToCGraphTransformer/CRectNode",282);A(1391,1,{},Rv);var vse,_se,uyn=k(J6,"OneDimensionalComponentsCompaction",1391);A(1392,1,Ju,AT),p.Fb=function(t){return this===t},p.Kb=function(t){return jee(),vt(),h(h(t,48).a,80).d.e!=0};var fyn=k(J6,"OneDimensionalComponentsCompaction/lambda$0$Type",1392);A(1393,1,Ju,bk),p.Fb=function(t){return this===t},p.Kb=function(t){return jee(),vt(),!!(mWe(h(h(t,48).a,80).j,h(h(t,48).b,110))||h(h(t,48).a,80).d.e!=0&&mWe(h(h(t,48).a,80).j,h(h(t,48).b,110)))};var hyn=k(J6,"OneDimensionalComponentsCompaction/lambda$1$Type",1393);A(1410,1,{},rUe);var dyn=k(xP,"CGraph",1410);A(172,1,{172:1},ite),p.b=0,p.c=0,p.e=0,p.g=!0,p.i=Ts;var pyn=k(xP,"CGroup",172);A(1409,1,{},Le),p.He=function(t,i){return w.Math.max(t.a!=null?ce(t.a):t.c.i,i.a!=null?ce(i.a):i.c.i)},p.Ie=function(t,i){return w.Math.max(t.a!=null?ce(t.a):t.c.i,i.a!=null?ce(i.a):i.c.i)};var gyn=k(xP,qJe,1409);A(1411,1,{},DXe),p.d=!1;var jit,yse=k(xP,ZJe,1411);A(1412,1,Ju,St),p.Fb=function(t){return this===t},p.Kb=function(t){return kpe(),vt(),h(h(t,48).a,80).d.e!=0};var myn=k(xP,KJe,1412);A(726,1,{},Hme),p.a=!1,p.b=!1,p.c=!1,p.d=!1;var byn=k(xP,JJe,726);A(1521,1,{},R9e);var wyn=k(ez,QJe,1521),x5=br(h1,WJe);A(1522,1,{341:1},VUe),p.Ne=function(t){B9t(this,h(t,524))};var vyn=k(ez,eQe,1522);A(1523,1,Or,Kt),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return no(h(t,282).g.c+h(t,282).g.b/2,h(i,282).g.c+h(i,282).g.b/2)};var _yn=k(ez,tQe,1523);A(524,1,{524:1},Jpe),p.a=!1;var yyn=k(ez,nQe,524);A(1524,1,Or,en),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return dBt(t,i)};var xyn=k(ez,iQe,1524);A(102,1,{102:1},GE,Ome),p.Fb=function(t){var i;return t==null||fVt!=rl(t)?!1:(i=h(t,102),el(this.c,i.c)&&el(this.d,i.d))},p.Hb=function(){return Aee(X(q(sn,1),nt,1,5,[this.c,this.d]))},p.Ib=function(){return"("+this.c+Ta+this.d+(this.a?"cx":"")+this.b+")"},p.a=!0,p.c=0,p.d=0;var fVt=k(h1,"Point",102);A(373,23,{3:1,34:1,23:1,373:1},P8);var J0,Dw,fy,Bw,$it=Mi(h1,"Point/Quadrant",373,Di,QLt,gTt),Vit;A(1398,1,{},l0),p.b=null,p.c=null,p.d=null,p.e=null,p.f=null;var Wit,Hit,qit,Xit,Yit,Eyn=k(h1,"RectilinearConvexHull",1398);A(516,1,{341:1},QU),p.Ne=function(t){Ckt(this,h(t,102))},p.b=0;var CEe,Syn=k(h1,"RectilinearConvexHull/MaximalElementsEventHandler",516);A(1400,1,Or,Xi),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return Rpe(),no(ce(Xe(t)),ce(Xe(i)))};var Myn=k(h1,"RectilinearConvexHull/MaximalElementsEventHandler/lambda$0$Type",1400);A(1399,1,{341:1},yje),p.Ne=function(t){l9t(this,h(t,102))},p.a=0,p.b=null,p.c=null,p.d=null,p.e=null;var Tyn=k(h1,"RectilinearConvexHull/RectangleEventHandler",1399);A(1401,1,Or,Rr),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return EA(),h(t,102).c==h(i,102).c?no(h(i,102).d,h(t,102).d):no(h(t,102).c,h(i,102).c)};var Cyn=k(h1,"RectilinearConvexHull/lambda$0$Type",1401);A(1402,1,Or,qr),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return EA(),h(t,102).c==h(i,102).c?no(h(t,102).d,h(i,102).d):no(h(t,102).c,h(i,102).c)};var Ayn=k(h1,"RectilinearConvexHull/lambda$1$Type",1402);A(1403,1,Or,Yt),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return EA(),h(t,102).c==h(i,102).c?no(h(i,102).d,h(t,102).d):no(h(i,102).c,h(t,102).c)};var Pyn=k(h1,"RectilinearConvexHull/lambda$2$Type",1403);A(1404,1,Or,bs),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return EA(),h(t,102).c==h(i,102).c?no(h(t,102).d,h(i,102).d):no(h(i,102).c,h(t,102).c)};var Lyn=k(h1,"RectilinearConvexHull/lambda$3$Type",1404);A(1405,1,Or,Ws),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return kOt(t,i)};var kyn=k(h1,"RectilinearConvexHull/lambda$4$Type",1405);A(1406,1,{},yze);var Ryn=k(h1,"Scanline",1406);A(1694,1,{});var Iyn=k(nm,"AbstractGraphPlacer",1694);A(458,1,{458:1},f9e);var us,Dyn=k(nm,"ComponentGroup",458);A(1076,1694,{},l8),p.Oe=function(t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W;if(this.a.c=le(sn,nt,1,0,5,1),i.a.c=le(sn,nt,1,0,5,1),t.Wb()){i.e.a=0,i.e.b=0;return}for(m=h(t.cd(0),31),Oo(i,m),f=t.tc();f.hc();)l=h(f.ic(),31),p6t(this,l);for(W=new fo,g=ce(Xe(G(m,($e(),woe)))),E=new j(this.a);E.aN&&(Ue=0,qe+=B+f,B=0),ee=m.c,A6(m,Ue+ee.a,qe+ee.b),Vf(ee),a=w.Math.max(a,Ue+fe.a),B=w.Math.max(B,fe.b),Ue+=fe.a+f;if(i.e.a=a,i.e.b=qe+B,ce(bt(G(g,hoe)))){for(l=new xs,dJe(l,t,f),R=t.tc();R.hc();)C=h(R.ic(),31),tr(Vf(C.c),l.e);tr(Vf(i.e),l.a)}GGe(i,t)};var Wyn=k(nm,"SimpleRowGraphPlacer",1074);A(1075,1,Or,Pc),p.Ld=function(t,i){return VRt(h(t,31),h(i,31))},p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)};var Hyn=k(nm,"SimpleRowGraphPlacer/1",1075),Zit;A(1032,1,Qu,Uf),p.Mb=function(t){var i;return i=h(G(h(t,234).b,($e(),Po)),74),!!i&&i.b!=0},p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)};var qyn=k(tz,"CompoundGraphPostprocessor/1",1032);A(1031,1,kr,ENe),p.Pe=function(t,i){EHe(this,h(t,31),i)};var Xyn=k(tz,"CompoundGraphPreprocessor",1031);A(400,1,{400:1},KVe),p.c=!1;var Yyn=k(tz,"CompoundGraphPreprocessor/ExternalPort",400);A(234,1,{234:1},d9),p.Ib=function(){return tI(this.c)+":"+Oje(this.b)};var Zyn=k(tz,"CrossHierarchyEdge",234);A(687,1,Or,BF),p.Ld=function(t,i){return ZDt(this,h(t,234),h(i,234))},p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)};var Kyn=k(tz,"CrossHierarchyEdgeComparator",687);A(279,131,{3:1,279:1,93:1,131:1}),p.o=0;var Jyn=k(Za,"LGraphElement",279);A(14,279,{3:1,14:1,279:1,93:1,131:1},Bp),p.Ib=function(){return Oje(this)};var yu=k(Za,"LEdge",14);A(31,279,{3:1,20:1,31:1,279:1,93:1,131:1},J0e),p.sc=function(t){mo(this,t)},p.tc=function(){return new j(this.b)},p.Ib=function(){return this.b.c.length==0?"G-unlayered"+$p(this.a):this.a.c.length==0?"G-layered"+$p(this.b):"G[layerless"+$p(this.a)+", layers"+$p(this.b)+"]"};var Kit=k(Za,"LGraph",31);A(591,1,{}),p.Qe=function(){return this.e.k},p.xe=function(t){return G(this.e,t)},p.Re=function(){return this.e.n},p.Se=function(){return this.e.o},p.ye=function(t){return ow(this.e,t)},p.Te=function(t){this.e.k.a=t.a,this.e.k.b=t.b},p.Ue=function(t){this.e.n.a=t.a,this.e.n.b=t.b},p.Ve=function(t){this.e.o=t};var Qyn=k(Za,"LGraphAdapters/AbstractLShapeAdapter",591);A(520,1,{741:1},mf),p.We=function(){var t,i;if(!this.b)for(this.b=Qh(this.a.b.c.length),i=new j(this.a.b);i.a0&&$$e(t.charCodeAt(i-1),wQe);)--i;if(g "+this.a+" "+tI(this.c)},p.a=0,p.b=0,p.d=0;var k3n=k(Cn,"SplineSelfLoopRouter/LoopPadding",188);A(1294,1,Qu,b9e),p.Mb=function(t){return O5t(this,h(t,188))},p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)},p.a=0,p.c=0;var R3n=k(Cn,"SplineSelfLoopRouter/LoopPadding/EnclosingPredicate",1294);A(1293,1,Or,KO),p.Ld=function(t,i){return rSt(h(t,188),h(i,188))},p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)};var I3n=k(Cn,"SplineSelfLoopRouter/LoopPadding/MarginComparator",1293);A(415,1,Qu,Kb),p.Mb=function(t){return h(t,188).c==this.a},p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)};var D3n=k(Cn,"SplineSelfLoopRouter/LoopPadding/PortSidePredicate",415);A(414,1,{414:1},hze),p.c=0,p.d=0,p.e=0;var B3n=k(Cn,"SplineSelfLoopRouter/SelfLoopEdge",414);A(1292,1,Or,NH),p.Ld=function(t,i){return wEt(h(t,414),h(i,414))},p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)};var O3n=k(Cn,"SplineSelfLoopRouter/SelfLoopEdge/StepSizeComparator",1292);A(1451,715,{},T$e),p.qe=function(t){var i,a,l,f;switch(this.c=t,this.a.g){case 2:i=new Re,Na(go(new si(null,new pi(this.c.a.b,16)),new jH),new LOe(this,i)),w6(this,new $H),ad(i,new FH),i.c=le(sn,nt,1,0,5,1),Na(go(new si(null,new pi(this.c.a.b,16)),new JO),new zF(i)),w6(this,new Ad),ad(i,new Lk),i.c=le(sn,nt,1,0,5,1),a=QNe(M$e(wI(new si(null,new pi(this.c.a.b,16)),new gC(this))),new sE),Na(new si(null,new pi(this.c.a.a,16)),new SOe(a,i)),w6(this,new QO),ad(i,new eN),i.c=le(sn,nt,1,0,5,1);break;case 3:l=new Re,w6(this,new Pk),f=QNe(M$e(wI(new si(null,new pi(this.c.a.b,16)),new WY(this))),new UH),Na(go(new si(null,new pi(this.c.a.b,16)),new Ak),new POe(f,l)),w6(this,new zH),ad(l,new GH),l.c=le(sn,nt,1,0,5,1);break;default:throw Y(new pe)}},p.b=0;var N3n=k(Hr,"EdgeAwareScanlineConstraintCalculation",1451);A(1452,1,Qu,Pk),p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)},p.Mb=function(t){return re(h(t,57).g,153)};var F3n=k(Hr,"EdgeAwareScanlineConstraintCalculation/lambda$0$Type",1452);A(1453,1,{},WY),p.oe=function(t){return XNt(this.a,t)};var U3n=k(Hr,"EdgeAwareScanlineConstraintCalculation/lambda$1$Type",1453);A(1464,1,{},FH),p.td=function(t){h(t,340).fe()};var z3n=k(Hr,"EdgeAwareScanlineConstraintCalculation/lambda$10$Type",1464);A(1465,1,ss,JO),p.Nb=function(t){return re(h(t,57).g,8)};var G3n=k(Hr,"EdgeAwareScanlineConstraintCalculation/lambda$11$Type",1465);A(1467,1,{},zF),p.td=function(t){P6t(this.a,t)};var j3n=k(Hr,"EdgeAwareScanlineConstraintCalculation/lambda$12$Type",1467);A(1468,1,Qu,Ad),p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)},p.Mb=function(t){return re(h(t,57).g,8)};var $3n=k(Hr,"EdgeAwareScanlineConstraintCalculation/lambda$13$Type",1468);A(1469,1,{},Lk),p.td=function(t){h(t,340).fe()};var V3n=k(Hr,"EdgeAwareScanlineConstraintCalculation/lambda$14$Type",1469);A(1470,1,{},gC),p.oe=function(t){return YNt(this.a,t)};var W3n=k(Hr,"EdgeAwareScanlineConstraintCalculation/lambda$15$Type",1470);A(1471,1,{},sE),p.me=function(){return 0};var H3n=k(Hr,"EdgeAwareScanlineConstraintCalculation/lambda$16$Type",1471);A(1473,1,{},SOe),p.td=function(t){aAt(this.a,this.b,t)},p.a=0;var q3n=k(Hr,"EdgeAwareScanlineConstraintCalculation/lambda$17$Type",1473);A(1474,1,Qu,QO),p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)},p.Mb=function(t){return!0};var X3n=k(Hr,"EdgeAwareScanlineConstraintCalculation/lambda$18$Type",1474);A(1475,1,{},eN),p.td=function(t){h(t,340).fe()};var Y3n=k(Hr,"EdgeAwareScanlineConstraintCalculation/lambda$19$Type",1475);A(1454,1,{},UH),p.me=function(){return 0};var Z3n=k(Hr,"EdgeAwareScanlineConstraintCalculation/lambda$2$Type",1454);A(1456,1,H6,MOe),p.fe=function(){ZA(this.b,this.a,-1)},p.a=0;var K3n=k(Hr,"EdgeAwareScanlineConstraintCalculation/lambda$20$Type",1456);A(1461,1,H6,TOe),p.fe=function(){ZA(this.a,this.b,-1)},p.b=0;var J3n=k(Hr,"EdgeAwareScanlineConstraintCalculation/lambda$21$Type",1461);A(1466,1,H6,COe),p.fe=function(){ZA(this.b,this.a,-1)},p.a=0;var Q3n=k(Hr,"EdgeAwareScanlineConstraintCalculation/lambda$22$Type",1466);A(1472,1,H6,AOe),p.fe=function(){sYe(this.a,this.b,-1)},p.b=0;var eEn=k(Hr,"EdgeAwareScanlineConstraintCalculation/lambda$23$Type",1472);A(1455,1,ss,Ak),p.Nb=function(t){return re(h(t,57).g,8)};var tEn=k(Hr,"EdgeAwareScanlineConstraintCalculation/lambda$3$Type",1455);A(1457,1,{},POe),p.td=function(t){cAt(this.a,this.b,t)},p.a=0;var nEn=k(Hr,"EdgeAwareScanlineConstraintCalculation/lambda$4$Type",1457);A(1458,1,Qu,zH),p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)},p.Mb=function(t){return!0};var iEn=k(Hr,"EdgeAwareScanlineConstraintCalculation/lambda$5$Type",1458);A(1459,1,{},GH),p.td=function(t){h(t,340).fe()};var rEn=k(Hr,"EdgeAwareScanlineConstraintCalculation/lambda$6$Type",1459);A(1460,1,ss,jH),p.Nb=function(t){return re(h(t,57).g,153)};var sEn=k(Hr,"EdgeAwareScanlineConstraintCalculation/lambda$7$Type",1460);A(1462,1,{},LOe),p.td=function(t){Kkt(this.a,this.b,t)};var oEn=k(Hr,"EdgeAwareScanlineConstraintCalculation/lambda$8$Type",1462);A(1463,1,Qu,$H),p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)},p.Mb=function(t){return re(h(t,57).g,153)};var aEn=k(Hr,"EdgeAwareScanlineConstraintCalculation/lambda$9$Type",1463);A(1232,1,kr,kFe),p.Pe=function(t,i){zzt(this,h(t,31),i)};var srt,cEn=k(Hr,"HorizontalGraphCompactor",1232);A(1233,1,{},D2),p.se=function(t,i){var a,l,f;return Be(G(this.a.a,($e(),cm)))===Be((cd(),cb))&&(re(t.g,153)&&re(i.g,8)||re(i.g,153)&&re(t.g,8))?ce(bt(G(this.a.a,BG)))?0:10:R0e(t,i)||(a=p_(t),l=p_(i),a&&a.j==(qt(),Jr)||l&&l.j==(qt(),Jr))?0:(f=h(G(this.a.a,(Ie(),Nw)),266),lMt(f,a?a.j:(qt(),Nr),l?l.j:(qt(),Nr)))},p.te=function(t,i){var a,l,f;return R0e(t,i)?1:(a=p_(t),l=p_(i),f=h(G(this.a.a,(Ie(),Nw)),266),Gge(f,a?a.j:(qt(),Nr),l?l.j:(qt(),Nr)))};var lEn=k(Hr,"HorizontalGraphCompactor/1",1233);A(1234,1,{},E2),p.re=function(t,i){return PC(),t.a.i==0};var uEn=k(Hr,"HorizontalGraphCompactor/lambda$0$Type",1234);A(1235,1,{},Rd),p.re=function(t,i){return dPt(this.a,t,i)};var fEn=k(Hr,"HorizontalGraphCompactor/lambda$1$Type",1235);A(1422,1,{},Hje);var ort,art,hEn=k(Hr,"LGraphToCGraphTransformer",1422);A(1430,1,ss,VH),p.Nb=function(t){return t!=null};var dEn=k(Hr,"LGraphToCGraphTransformer/0methodref$nonNull$Type",1430);A(1423,1,ps,WH),p.Kb=function(t){return $u(),za(G(h(h(t,57).g,8),(Ie(),Jn)))};var pEn=k(Hr,"LGraphToCGraphTransformer/lambda$0$Type",1423);A(1424,1,ps,kk),p.Kb=function(t){return $u(),sWe(h(h(t,57).g,153))};var gEn=k(Hr,"LGraphToCGraphTransformer/lambda$1$Type",1424);A(1435,1,ss,tN),p.Nb=function(t){return $u(),re(h(t,57).g,153)};var mEn=k(Hr,"LGraphToCGraphTransformer/lambda$10$Type",1435);A(1439,1,{},Gb),p.td=function(t){var i,a;$u(),i=t.d.c-t.e.c,a=h(t.g,153),ad(a.b,new YY(i)),ad(a.c,new ZY(i)),mo(a.i,new GF(i))};var bEn=k(Hr,"LGraphToCGraphTransformer/lambda$11$Type",1439);A(1440,1,ps,RT),p.Kb=function(t){return $u(),new si(null,new rx(Tn(ur(h(t,8)))))};var wEn=k(Hr,"LGraphToCGraphTransformer/lambda$12$Type",1440);A(1441,1,ss,HH),p.Nb=function(t){return $u(),Ko(h(t,14))};var vEn=k(Hr,"LGraphToCGraphTransformer/lambda$13$Type",1441);A(1442,1,{},HY),p.td=function(t){Ukt(this.a,t)};var _En=k(Hr,"LGraphToCGraphTransformer/lambda$14$Type",1442);A(1443,1,ps,qH),p.Kb=function(t){return $u(),new si(null,new pi(h(t,26).a,16))};var yEn=k(Hr,"LGraphToCGraphTransformer/lambda$15$Type",1443);A(1444,1,ps,XH),p.Kb=function(t){return $u(),new si(null,new rx(Tn(ur(h(t,8)))))};var xEn=k(Hr,"LGraphToCGraphTransformer/lambda$16$Type",1444);A(1445,1,ps,S2),p.Kb=function(t){return $u(),h(G(h(t,14),(Ie(),JP)),15)};var EEn=k(Hr,"LGraphToCGraphTransformer/lambda$17$Type",1445);A(1446,1,ss,wg),p.Nb=function(t){return $u(),!!h(t,15)&&!h(t,15).Wb()};var SEn=k(Hr,"LGraphToCGraphTransformer/lambda$18$Type",1446);A(1447,1,{},qY),p.td=function(t){ZNt(this.a,h(t,15))};var MEn=k(Hr,"LGraphToCGraphTransformer/lambda$19$Type",1447);A(1426,1,{},XY),p.td=function(t){aLt(this.a,t)};var TEn=k(Hr,"LGraphToCGraphTransformer/lambda$2$Type",1426);A(1425,1,{},kOe),p.td=function(t){r4t(this.a,this.b,t)};var CEn=k(Hr,"LGraphToCGraphTransformer/lambda$20$Type",1425);A(1436,1,{},YY),p.td=function(t){wSt(this.a,t)},p.a=0;var AEn=k(Hr,"LGraphToCGraphTransformer/lambda$21$Type",1436);A(1437,1,{},ZY),p.td=function(t){vSt(this.a,t)},p.a=0;var PEn=k(Hr,"LGraphToCGraphTransformer/lambda$22$Type",1437);A(1438,1,{},GF),p.td=function(t){_St(this.a,t)},p.a=0;var LEn=k(Hr,"LGraphToCGraphTransformer/lambda$23$Type",1438);A(1427,1,ps,nN),p.Kb=function(t){return $u(),new si(null,new pi(h(t,26).a,16))};var kEn=k(Hr,"LGraphToCGraphTransformer/lambda$3$Type",1427);A(1428,1,ps,YH),p.Kb=function(t){return $u(),new si(null,new rx(Tn(ur(h(t,8)))))};var REn=k(Hr,"LGraphToCGraphTransformer/lambda$4$Type",1428);A(1429,1,ps,ZH),p.Kb=function(t){return $u(),h(G(h(t,14),(Ie(),JP)),15)};var IEn=k(Hr,"LGraphToCGraphTransformer/lambda$5$Type",1429);A(1431,1,{},c0),p.td=function(t){_Ft(this.a,t)};var DEn=k(Hr,"LGraphToCGraphTransformer/lambda$6$Type",1431);A(1432,1,{},ROe),p.td=function(t){MSt(this.a,this.b,t)};var BEn=k(Hr,"LGraphToCGraphTransformer/lambda$7$Type",1432);A(1433,1,ss,KH),p.Nb=function(t){return $u(),re(h(t,57).g,8)};var OEn=k(Hr,"LGraphToCGraphTransformer/lambda$8$Type",1433);A(1434,1,{},JH),p.td=function(t){var i;$u(),i=h(t.g,8),i.k.a=t.d.c+i.d.b};var NEn=k(Hr,"LGraphToCGraphTransformer/lambda$9$Type",1434);A(1421,1,{},QH),p.pe=function(t){var i,a,l,f,g;for(this.a=t,this.d=new rK,this.c=le(wSe,nt,113,this.a.a.a.c.length,0,1),this.b=0,a=new j(this.a.a.a);a.af-m?0:f-m;B<=f0(i.f-1,f+m);B++){if(V=ie/(B+1),ee=0,C=1,g=new Re,fe=Ts,R=0,v=0,W=y[0],B==0)fe=ie,v=(i.g==null&&(i.g=x$e(i,new Il)),ce(i.g));else{for(;C=V&&(De(g,He(C)),fe=w.Math.max(fe,we[C-1]-R),v+=W,ee+=we[C-1]-ee,R=we[C-1],W=y[C]),W=w.Math.max(W,y[C]),++C;v+=W}N=w.Math.min(1/fe,1/i.b/v),N>l&&(l=N,a=g)}return a},p.tf=function(){return!1};var aSn=k(Jd,"MSDCutIndexHeuristic",714);A(1279,1,kr,eq),p.Pe=function(t,i){Y7t(h(t,31),i)};var cSn=k(Jd,"SingleEdgeGraphWrapper",1279);A(189,1,{189:1},wp),p.Ib=function(){return"NEdge[id="+this.b+" w="+this.g+" d="+this.a+"]"},p.a=1,p.b=0,p.c=0,p.f=!1,p.g=0;var lrt=k(SP,"NEdge",189);A(162,1,{},nu);var lSn=k(SP,"NEdge/NEdgeBuilder",162);A(592,1,{},rK);var uSn=k(SP,"NGraph",592);A(113,1,{113:1},oGe),p.c=-1,p.d=0,p.e=0,p.i=-1,p.j=!1;var wSe=k(SP,"NNode",113);A(717,1,GJe,ipe),p.sc=function(t){mo(this,t)},p.uc=function(){return this.xc()},p.jd=function(t){Ug(this,t)},p.wc=function(){return new pi(this,16)},p.xc=function(){return new si(null,this.wc())},p.bd=function(t,i){++this.b,w0(this.a,t,i)},p.nc=function(t){return J8(this,t)},p.oc=function(t){return++this.b,Lr(this.a,t)},p.Pb=function(){++this.b,this.a.c=le(sn,nt,1,0,5,1)},p.pc=function(t){return Jo(this.a,t,0)!=-1},p.qc=function(t){return Gg(this.a,t)},p.cd=function(t){return Tt(this.a,t)},p.dd=function(t){return Jo(this.a,t,0)},p.Wb=function(){return this.a.c.length==0},p.tc=function(){return mx(new j(this.a))},p.ed=function(){throw Y(new Ai)},p.fd=function(t){throw Y(new Ai)},p.gd=function(t){return++this.b,A0(this.a,t)},p.vc=function(t){return zge(this,t)},p.hd=function(t,i){return++this.b,Wu(this.a,t,i)},p._b=function(){return this.a.c.length},p.kd=function(t,i){return new Rg(this.a,t,i)},p.yc=function(){return mJ(this.a)},p.zc=function(t){return vo(this.a,t)},p.b=0;var fSn=k(SP,"NNode/ChangeAwareArrayList",717);A(251,1,{},Fm);var hSn=k(SP,"NNode/NNodeBuilder",251);A(1482,1,{},DT),p.a=!1,p.f=zi,p.j=0;var dSn=k(SP,"NetworkSimplex",1482);A(276,23,{3:1,34:1,23:1,276:1},zR);var Nse,Fse,Use,vSe,zse,_Se=Mi(vc,"CenterEdgeLabelPlacementStrategy",276,Di,L4t,vTt),urt;A(386,23,{3:1,34:1,23:1,386:1},Qpe);var ySe,Gse,xSe=Mi(vc,"ConstraintCalculationStrategy",386,Di,IPt,_Tt),frt;A(290,23,{3:1,34:1,23:1,290:1},FC);var dG,ESe,pG,gG,mG,SSe,jse=Mi(vc,"ContentAlignment",290,Di,fkt,yTt),hrt;A(317,23,{3:1,34:1,23:1,317:1,285:1,286:1},ege),p.hf=function(){return zqe(this)},p.uf=function(){return zqe(this)};var S5,M5,MSe=Mi(vc,"CrossingMinimizationStrategy",317,Di,DPt,xTt),drt;A(319,23,{3:1,34:1,23:1,319:1},RK);var TSe,$se,bG,CSe=Mi(vc,"CuttingStrategy",319,Di,hLt,ETt),prt;A(384,23,{3:1,34:1,23:1,384:1,285:1,286:1},IK),p.hf=function(){return Hqe(this)},p.uf=function(){return Hqe(this)};var ASe,Vse,Wse,PSe=Mi(vc,"CycleBreakingStrategy",384,Di,dLt,STt),grt;A(406,23,{3:1,34:1,23:1,406:1},DK);var T5,Hse,YP,mrt=Mi(vc,"EdgeConstraint",406,Di,pLt,MTt),brt;A(241,23,{3:1,34:1,23:1,241:1},UC);var qse,Xse,Yse,Zse,wG,Kse,LSe=Mi(vc,"EdgeLabelSideSelection",241,Di,hkt,TTt),wrt;A(255,23,{3:1,34:1,23:1,255:1},zC);var Jse,kSe,RSe,vG,ISe,DSe,BSe=Mi(vc,"FixedAlignment",255,Di,dkt,CTt),vrt;A(256,23,{3:1,34:1,23:1,256:1},GC);var OSe,NSe,FSe,USe,ZP,zSe,GSe=Mi(vc,"GraphCompactionStrategy",256,Di,pkt,ATt),_rt;A(233,23,{3:1,34:1,23:1,233:1},iw);var fM,_G,hM,Eu,KP,yG,dy,py,xG,C5,Qse=Mi(vc,"GraphProperties",233,Di,CRt,PTt),yrt;A(318,23,{3:1,34:1,23:1,318:1},BK);var EG,eoe,toe,jSe=Mi(vc,"GreedySwitchType",318,Di,fLt,LTt),xrt;A(280,23,{3:1,34:1,23:1,280:1},OK);var Zx,A5,gy,Ert=Mi(vc,"InLayerConstraint",280,Di,uLt,kTt),Srt;A(383,23,{3:1,34:1,23:1,383:1},tge);var noe,$Se,VSe=Mi(vc,"InteractiveReferencePoint",383,Di,BPt,RTt),Mrt,WSe,HSe,ioe,Ow,P5,Kx,Q0,SG,qSe,XSe,MG,YSe,TG,roe,CG,Jx,soe,AG,da,ZSe,$a,ooe,L5,y1,dM,Qx,e3,k5,t3,Tl,Cl,my,gd,Jn,KSe,JSe,QSe,aoe,sm,PG,Al,eb,coe,pM,LG,om,Nw,loe,Trt,R5,JP,uoe,eMe,foe,n3;A(178,23,{3:1,34:1,23:1,178:1},GR);var I5,Fw,QP,tb,i3,tMe=Mi(vc,"LayerConstraint",178,Di,k4t,ITt),Crt;A(747,1,dd,DX),p.ue=function(t){zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Iye),""),"Content Alignment"),"Specifies how the content of compound nodes is to be aligned, e.g. top-left."),rMe),(o1(),vM)),jse),Wt((i1(),Pn))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.contentAlignment"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Dye),""),"Feedback Edges"),"Whether feedback edges should be highlighted by routing around the nodes."),(vt(),vt(),!1)),va),lo),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.feedBackEdges"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,nz),""),"Interactive Reference Point"),"Determines which point of a node is considered by interactive layout phases."),fMe),gs),VSe),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.interactiveReferencePoint"])))),gc(t,nz,Bie,Jrt),gc(t,nz,Gie,Krt),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Bye),""),"Merge Edges"),"Edges that have no ports are merged so they touch the connected nodes at the same points. When this option is disabled, one port is created for each edge directly connected to a node. When it is enabled, all such incoming edges share an input port, and all outgoing edges share an output port."),!1),va),lo),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.mergeEdges"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Oye),""),"Merge Hierarchy-Crossing Edges"),"If hierarchical layout is active, hierarchy-crossing edges use as few hierarchical ports as possible. They are broken by the algorithm, with hierarchical ports inserted as required. Usually, one such port is created for each edge at each hierarchy crossing point. With this option set to true, we try to create as few hierarchical ports as possible in the process. In particular, all edges that form a hyperedge can share a port."),!0),va),lo),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.mergeHierarchyEdges"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Nye),""),"Thoroughness"),"How much effort should be spent to produce a nice layout."),He(7)),yc),Ao),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.thoroughness"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Fye),""),"Add Unnecessary Bendpoints"),"Adds bend points even if an edge does not change direction. If true, each long edge dummy will contribute a bend point to its edges and hierarchy-crossing edges will always get a bend point where they cross hierarchy boundaries. By default, bend points are only added where an edge changes direction."),!1),va),lo),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.unnecessaryBendpoints"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Uye),""),"North or South Port"),"Specifies that this port can either be placed on the north side of a node or on the south side (if port constraints permit)"),!1),va),lo),Wt(ab)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.northOrSouthPort"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Bie),"cycleBreaking"),"Cycle Breaking Strategy"),"Strategy for cycle breaking. Cycle breaking looks for cycles in the graph and determines which edges to reverse to break the cycles. Reversed edges will end up pointing to the opposite direction of regular edges (that is, reversed edges will point left if edges usually point right)."),aMe),gs),PSe),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.cycleBreaking"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,t5),s2e),"Node Layering Strategy"),"Strategy for node layering."),pMe),gs),hTe),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.nodeLayering"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,zye),s2e),"Layer Constraint"),"Determines a constraint on the placement of the node regarding the layering."),hMe),gs),tMe),Wt(pa)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.layerConstraint"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Gye),s2e),"Wide Nodes on Multiple Layers"),"Strategy to distribute wide nodes over multiple layers."),gMe),gs),TTe),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.wideNodesOnMultipleLayers"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Oie),LQe),"Upper Bound On Width [MinWidth Layerer]"),"Defines a loose upper bound on the width of the MinWidth layerer. If set to '-1' multiple values are tested and the best result is selected."),He(4)),yc),Ao),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.minWidthUpperBoundOnWidth"])))),gc(t,Oie,t5,ist),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Nie),LQe),"Upper Layer Estimation Scaling Factor [MinWidth Layerer]"),"Multiplied with Upper Bound On Width for defining an upper bound on the width of layers which haven't been determined yet, but whose maximum width had been (roughly) estimated by the MinWidth algorithm. Compensates for too high estimations. If set to '-1' multiple values are tested and the best result is selected."),He(2)),yc),Ao),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.minWidthUpperLayerEstimationScalingFactor"])))),gc(t,Nie,t5,sst),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Fie),kQe),"Node Promotion Strategy"),"Reduces number of dummy nodes after layering phase (if possible)."),dMe),gs),vTe),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.nodePromotion"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Uie),kQe),"Max Node Promotion Iterations"),"Limits the number of iterations for node promotion."),He(0)),yc),Ao),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.nodePromotionBoundary"])))),gc(t,Uie,Fie,null),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,zie),"layering.coffmanGraham"),"Layer Bound"),"The maximum number of nodes allowed per layer."),He(zi)),yc),Ao),Wt(Pn)))),gc(t,zie,t5,est),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Gie),o2e),"Crossing Minimization Strategy"),"Strategy for crossing minimization."),oMe),gs),MSe),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.crossMin"])))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,jye),o2e),"Hierarchical Sweepiness"),"How likely it is to use cross-hierarchy (1) vs bottom-up (-1)."),.1),tc),Eo),Wt(Pn)))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,$ye),o2e),"Semi-Interactive Crossing Minimization"),"Preserves the order of nodes within a layer but still minimizes crossings between edges connecting long edge dummies. Derives the desired order from positions specified by the 'org.eclipse.elk.position' layout option. Requires a crossing minimization strategy that is able to process 'in-layer' constraints."),!1),va),lo),Wt(Pn)))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Vye),RQe),"Greedy Switch Activation Threshold"),"By default it is decided automatically if the greedy switch is activated or not. The decision is based on whether the size of the input graph (without dummy nodes) is smaller than the value of this option. A '0' enforces the activation."),He(40)),yc),Ao),Wt(Pn)))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Wye),RQe),"Greedy Switch Crossing Minimization"),"Greedy Switch strategy for crossing minimization. The greedy switch heuristic is executed after the regular layer sweep as a post-processor."),sMe),gs),jSe),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.greedySwitch"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,YS),IQe),"Node Placement Strategy"),"Strategy for node placement."),vMe),gs),pTe),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.nodePlace"])))),zt(t,new Rt(Ft(Nt(Ut(It(Ot(Dt(Bt(new Lt,jie),IQe),"Favor Straight Edges Over Balancing"),"Favor straight edges over a balanced node placement. The default behavior is determined automatically based on the used 'edgeRouting'. For an orthogonal style it is set to true, for all other styles to false."),va),lo),Wt(Pn)))),gc(t,jie,YS,bst),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,$ie),DQe),"BK Edge Straightening"),"Specifies whether the Brandes Koepf node placer tries to increase the number of straight edges at the expense of diagram size. There is a subtle difference to the 'favorStraightEdges' option, which decides whether a balanced placement of the nodes is desired, or not. In bk terms this means combining the four alignments into a single balanced one, or not. This option on the other hand tries to straighten additional edges during the creation of each of the four alignments."),mMe),gs),kTe),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.nodeplace.compactionStrategy"])))),gc(t,$ie,YS,dst),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Vie),DQe),"BK Fixed Alignment"),"Tells the BK node placer to use a certain alignment (out of its four) instead of the one producing the smallest height, or the combination of all four."),bMe),gs),BSe),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.fixedAlignment"])))),gc(t,Vie,YS,gst),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Wie),"nodePlacement.linearSegments"),"Linear Segments Deflection Dampening"),"Dampens the movement of nodes to keep the diagram from getting too large."),.3),tc),Eo),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.linearSegmentsDeflectionDampening"])))),gc(t,Wie,YS,vst),zt(t,new Rt(Ft(Nt(Ut(It(Ot(Dt(Bt(new Lt,Hie),"nodePlacement.networkSimplex"),"Node Flexibility"),"Aims at shorter and straighter edges. Two configurations are possible: (a) allow ports to move freely on the side they are assigned to (the order is always defined beforehand), (b) additionally allow to enlarge a node wherever it helps. If this option is not configured for a node, the 'nodeFlexibility.default' value is used, which is specified for the node's parent."),gs),Moe),Wt(pa)))),gc(t,Hie,YS,xst),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Hye),"nodePlacement.networkSimplex.nodeFlexibility"),"Node Flexibility Default"),"Default value of the 'nodeFlexibility' option for the children of a hierarchical node."),wMe),gs),Moe),Wt(Pn)))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,qie),a2e),"Spline Self-Loop Placement"),null),uMe),gs),xTe),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.splines.selfLoopPlacement"])))),gc(t,qie,n5,Grt),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,iz),a2e),"Sloppy Spline Routing"),"Use less spline control points at the start and end of an edge. Might lead to crossings edge/node overlap."),!0),va),lo),Wt(Pn)))),gc(t,iz,n5,Wrt),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,rz),a2e),"Sloppy Spline Layer Spacing Factor"),"Spacing factor for routing area between layers when using sloppy spline routing."),.4),tc),Eo),Wt(Pn)))),gc(t,rz,n5,$rt),gc(t,rz,iz,!0),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,qye),im),"Edge Node Between Layers Spacing"),"The spacing to be preserved between nodes and edges that are routed next to the node's layer. For the spacing between nodes and edges that cross the node's layer 'spacing.edgeNode' is used."),10),tc),Eo),Wt(Pn)))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Xye),im),"Edge Edge Between Layer Spacing"),"Spacing to be preserved between pairs of edges that are routed between the same pair of layers. Note that 'spacing.edgeEdge' is used for the spacing between pairs of edges crossing the same layer."),10),tc),Eo),Wt(Pn)))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Yye),im),"Node Node Between Layers Spacing"),"The spacing to be preserved between any pair of nodes of two adjacent layers. Note that 'spacing.nodeNode' is used for the spacing between nodes within the layer itself."),20),tc),Eo),Wt(Pn)))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Zye),c2e),"Direction Priority"),"Defines how important it is to have a certain edge point into the direction of the overall layout. This option is evaluated during the cycle breaking phase."),He(0)),yc),Ao),Wt(md)))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Kye),c2e),"Shortness Priority"),"Defines how important it is to keep an edge as short as possible. This option is evaluated during the layering phase."),He(0)),yc),Ao),Wt(md)))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Jye),c2e),"Straightness Priority"),"Defines how important it is to keep an edge straight, i.e. aligned with one of the two axes. This option is evaluated during node placement."),He(0)),yc),Ao),Wt(md)))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Xie),"compaction"),sQe),"Tries to further compact components (disconnected sub-graphs)."),!1),va),lo),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.components.compact"])))),gc(t,Xie,Z6,!0),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Qye),BQe),"Post Compaction Strategy"),OQe),iMe),gs),GSe),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.postCompaction"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,e2e),BQe),"Post Compaction Constraint Calculation"),OQe),nMe),gs),xSe),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.postCompaction.constraints"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,sz),l2e),"High Degree Node Treatment"),"Makes room around high degree nodes to place leafs and trees."),!1),va),lo),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.highDegreeNode.treatment"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Yie),l2e),"High Degree Node Threshold"),"Whether a node is considered to have a high degree."),He(16)),yc),Ao),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.highDegreeNode.threshold"])))),gc(t,Yie,sz,!0),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Zie),l2e),"High Degree Node Maximum Tree Height"),"Maximum height of a subtree connected to a high degree node to be moved to separate layers."),He(5)),yc),Ao),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.highDegreeNode.treeHeight"])))),gc(t,Zie,sz,!0),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,TP),u2e),"Graph Wrapping Strategy"),"For certain graphs and certain prescribed drawing areas it may be desirable to split the laid out graph into chunks that are placed side by side. The edges that connect different chunks are 'wrapped' around from the end of one chunk to the start of the other chunk. The points between the chunks are referred to as 'cuts'."),EMe),gs),CTe),Wt(Pn)))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,t2e),u2e),"Additional Wrapped Edges Spacing"),"To visually separate edges that are wrapped from regularly routed edges an additional spacing value can be specified in form of this layout option. The spacing is added to the regular edgeNode spacing."),10),tc),Eo),Wt(Pn)))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,n2e),u2e),"Correction factor for the wrapping"),"At times and for certain types of graphs the executed wrapping may produce results that are consistently biased in the same fashion: either wrapping to often or to rarely. This factor can be used to correct the bias. Internally, it is simplay multiplied with the 'aspect ratio' layout option."),1),tc),Eo),Wt(Pn)))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,oz),NQe),"Cutting Strategy"),"The strategy by which the layer indexes are determined at which the layering crumbles into chunks."),yMe),gs),CSe),Wt(Pn)))),zt(t,new Rt(Ft(Nt(Ut(It(Ot(Dt(Bt(new Lt,Kie),NQe),"Manually Specified Cuts"),"Allows the user to specify her own cuts for a certain graph."),bd),_u),Wt(Pn)))),gc(t,Kie,oz,Ost),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Jie),"wrapping.cutting.msd"),"MSD Freedom"),"The MSD cutting strategy starts with an initial guess on the number of chunks the graph should be split into. The freedom specifies how much the strategy may deviate from this guess. E.g. if an initial number of 3 is computed, a freedom of 1 allows 2, 3, and 4 cuts."),_Me),yc),Ao),Wt(Pn)))),gc(t,Jie,oz,Fst),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Qie),"wrapping.singleEdge.validify"),"Path-Like Validify Strategy"),"When wrapping path-like graphs, the graph must not be split between any pair of layers. The validify strategy makes sure every computed split point is allowed."),xMe),gs),MTe),Wt(Pn)))),gc(t,Qie,TP,qst),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,az),f2e),"Improve Cuts"),"For general graphs it is important that not too many edges wrap backwards. Thus a compromise between evenly-distributed cuts and the total number of cut edges is sought."),!0),va),lo),Wt(Pn)))),gc(t,az,TP,$st),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,cz),f2e),"Distance Penalty When Improving Cuts"),null),2),tc),Eo),Wt(Pn)))),gc(t,cz,TP,Gst),gc(t,cz,az,!0),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,ere),f2e),"Improve Wrapped Edges"),"The initial wrapping is performed in a very simple way. As a consequence, edges that wrap from one chunk to another may be unnecessarily long. Activating this option tries to shorten such edges."),!0),va),lo),Wt(Pn)))),gc(t,ere,TP,Wst),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,i2e),tre),"Edge Label Side Selection"),"Method to decide on edge label sides."),lMe),gs),LSe),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.edgeLabelSideSelection"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,r2e),tre),"Edge Center Label Placement Strategy"),"Determines in which layer center labels of long edges should be placed."),cMe),gs),_Se),or(Pn,X(q(Jp,1),Oe,163,0,[fm]))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.edgeLabelPlacementStrategy"])))),mJe((new cF,t))};var Art,Prt,nMe,Lrt,iMe,krt,rMe,Rrt,Irt,sMe,Drt,Brt,Ort,oMe,Nrt,aMe,Frt,cMe,Urt,lMe,zrt,uMe,Grt,jrt,$rt,Vrt,Wrt,Hrt,qrt,Xrt,Yrt,Zrt,fMe,Krt,Jrt,Qrt,est,tst,hMe,nst,ist,rst,sst,ost,ast,dMe,cst,pMe,lst,gMe,ust,fst,hst,mMe,dst,pst,bMe,gst,mst,bst,wst,vst,_st,yst,wMe,xst,Est,vMe,Sst,Mst,Tst,Cst,Ast,Pst,Lst,kst,Rst,Ist,Dst,Bst,Ost,Nst,_Me,Fst,Ust,yMe,zst,Gst,jst,$st,Vst,Wst,Hst,xMe,qst,Xst,EMe,pSn=k(vc,"LayeredMetaDataProvider",747);A(878,1,dd,cF),p.ue=function(t){mJe(t)};var Dh,kG,eL,hoe,SMe,RG,doe,MMe,IG,TMe,poe,gM,CMe,tL,tf,AMe,DG,PMe,am,nL,cm,LMe,kMe,RMe,BG,ep,D5,iL,IMe,DMe,BMe,OG,by,Uw,OMe,Po,NMe,ec,FMe,UMe,zMe,goe,GMe,B5,NG,jMe,$Me,Lf,VMe,moe,rL,WMe,nb,sL,FG,zw,mM,UG,boe,x1,HMe,qMe,XMe,YMe,ZMe,Yst,Zst,Kst,Jst,Gw,jw,Yi,E1,KMe,r3,oL,$w,Qst,O5,JMe,s3,eot,tot,woe,ih,o3,N5,S1,wy,zG,a3,QMe,aL,tp,Vw,voe,cL,F5,_oe,eTe,tTe,nTe,iTe,yoe,rTe,sTe,oTe,aTe,cTe,gSn=k(vc,"LayeredOptions",878);A(879,1,{},tq),p.Be=function(){var t;return t=new gl,t},p.Ce=function(t){};var mSn=k(vc,"LayeredOptions/LayeredFactory",879);A(291,23,{3:1,34:1,23:1,291:1,285:1,286:1},jC),p.hf=function(){return gYe(this)},p.uf=function(){return gYe(this)};var xoe,lTe,uTe,GG,Eoe,fTe,hTe=Mi(vc,"LayeringStrategy",291,Di,gkt,DTt),not;A(179,23,{3:1,34:1,23:1,179:1},L8);var vy,_y,jG,Soe,Moe=Mi(vc,"NodeFlexibility",179,Di,d4t,BTt),iot;A(292,23,{3:1,34:1,23:1,292:1,285:1,286:1},jR),p.hf=function(){return JXe(this)},p.uf=function(){return JXe(this)};var U5,Toe,Coe,z5,dTe,pTe=Mi(vc,"NodePlacementStrategy",292,Di,R4t,OTt),rot;A(240,23,{3:1,34:1,23:1,240:1},Z2);var gTe,G5,mTe,bTe,j5,wTe,$G,VG,vTe=Mi(vc,"NodePromotionStrategy",240,Di,eRt,NTt),sot;A(410,23,{3:1,34:1,23:1,410:1},NK);var Nc,cc,WG,oot=Mi(vc,"PortType",410,Di,gLt,FTt),aot;A(345,23,{3:1,34:1,23:1,345:1},FK);var _Te,yTe,Aoe,xTe=Mi(vc,"SelfLoopPlacement",345,Di,mLt,UTt),cot;A(266,1,{266:1},jqe);var bSn=k(vc,"Spacings",266);A(347,23,{3:1,34:1,23:1,347:1},UK);var Poe,ETe,STe,MTe=Mi(vc,"ValidifyStrategy",347,Di,bLt,zTt),lot;A(385,23,{3:1,34:1,23:1,385:1},zK);var $5,V5,W5,TTe=Mi(vc,"WideNodesStrategy",385,Di,vLt,GTt),uot;A(346,23,{3:1,34:1,23:1,346:1},GK);var H5,Loe,koe,CTe=Mi(vc,"WrappingStrategy",346,Di,wLt,jTt),fot;A(1296,1,Ml,zOe),p.vf=function(t){return h(t,31),hot},p.Pe=function(t,i){JGt(this,h(t,31),i)};var hot,wSn=k(W2e,"DepthFirstCycleBreaker",1296);A(1295,1,Ml,I9e),p.vf=function(t){return h(t,31),dot},p.Pe=function(t,i){O$t(this,h(t,31),i)};var dot,vSn=k(W2e,"GreedyCycleBreaker",1295);A(1297,1,Ml,aR),p.vf=function(t){return h(t,31),pot},p.Pe=function(t,i){nGt(this,h(t,31),i)};var pot,_Sn=k(W2e,"InteractiveCycleBreaker",1297);A(1300,1,Ml,GOe),p.vf=function(t){return h(t,31),got},p.Pe=function(t,i){k$t(this,h(t,31),i)};var got,ySn=k(Lw,"CoffmanGrahamLayerer",1300);A(1301,1,Or,Ep),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return yFt(this.a,h(t,8),h(i,8))};var xSn=k(Lw,"CoffmanGrahamLayerer/lambda$0$Type",1301);A(1302,1,Or,$F),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return iAt(this.a,t,i)};var ESn=k(Lw,"CoffmanGrahamLayerer/lambda$1$Type",1302);A(1303,1,Ml,M2),p.vf=function(t){return h(t,31),Ci(Ci(new rs,(_o(),Ih),(Co(),kse)),Ja,uM)},p.Pe=function(t,i){Gjt(this,h(t,31),i)};var SSn=k(Lw,"InteractiveLayerer",1303);A(511,1,{511:1},dDe),p.a=0,p.c=0;var MSn=k(Lw,"InteractiveLayerer/LayerSpan",511);A(1299,1,Ml,aF),p.vf=function(t){return n5t(h(t,31))},p.Pe=function(t,i){k9t(this,h(t,31),i)};var mot,bot,wot,TSn=k(Lw,"LongestPathLayerer",1299);A(1306,1,Ml,lF),p.vf=function(t){return h(t,31),Ci(Ci(new rs,(_o(),Ih),(Co(),qP)),Ja,uM)},p.Pe=function(t,i){f$t(this,h(t,31),i)},p.a=0,p.b=0,p.d=0;var ATe,PTe,CSn=k(Lw,"MinWidthLayerer",1306);A(1307,1,Or,ya),p.Ld=function(t,i){return WRt(this,h(t,8),h(i,8))},p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)};var ASn=k(Lw,"MinWidthLayerer/MinOutgoingEdgesComparator",1307);A(1298,1,Ml,iFe),p.vf=function(t){return tBt(this,h(t,31))},p.Pe=function(t,i){Ezt(this,h(t,31),i)};var vot,_ot,yot,PSn=k(Lw,"NetworkSimplexLayerer",1298);A(1304,1,Ml,d8e),p.vf=function(t){return h(t,31),Ci(Ci(new rs,(_o(),Ih),(Co(),qP)),Ja,uM)},p.Pe=function(t,i){gjt(this,h(t,31),i)},p.d=0,p.f=0,p.g=0,p.i=0,p.s=0,p.t=0,p.u=0;var LSn=k(Lw,"StretchWidthLayerer",1304);A(1305,1,Or,FT),p.Ld=function(t,i){return q4t(h(t,8),h(i,8))},p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)};var kSn=k(Lw,"StretchWidthLayerer/1",1305);A(422,1,H2e),p.lf=function(t,i,a,l,f,g){},p.xf=function(t,i,a){return FZe(this,t,i,a)},p.kf=function(){this.g=le(sv,zQe,22,this.d,15,1),this.f=le(sv,zQe,22,this.d,15,1)},p.mf=function(t,i){this.e[t]=le(Rn,ii,22,i[t].length,15,1)},p.nf=function(t,i,a){var l;l=a[t][i],l.o=i,this.e[t][i]=i},p.of=function(t,i,a,l){h(Tt(l[t][i].i,a),11).o=this.d++},p.b=0,p.c=0,p.d=0;var RSn=k(Hl,"AbstractBarycenterPortDistributor",422);A(1484,1,Or,JY),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return A5t(this.a,t,i)};var ISn=k(Hl,"AbstractBarycenterPortDistributor/lambda$0$Type",1484);A(1532,1,e5,sze),p.lf=function(t,i,a,l,f,g){},p.nf=function(t,i,a){},p.of=function(t,i,a,l){},p.jf=function(){return!1},p.kf=function(){this.a=this.c.a,this.e=this.d.g},p.mf=function(t,i){i[t][0].c.o=t},p.pf=function(){return!1},p.qf=function(t,i,a,l){var f,g,m,v,y,E,C;for(i!=pFe(a,t.length)&&(g=t[i-(a?1:-1)],y0e(this.d,g,a?(Bo(),cc):(Bo(),Nc))),f=t[i][0],C=!l||f.j==(qt(),Jr),E=Ym(t[i]),FVe(this,E,C,!1,a),m=0,y=new j(E);y.a"),t0?xQ(this.a,t[i-1],t[i]):!a&&i1&&(f.i==(Fe(),Zt)?this.b[t]=!0:f.i==tn&&t>0&&(this.b[t-1]=!0))},p.f=0;var KSn=k(p1,"AllCrossingsCounter",1528);A(602,1,{},dee),p.b=0,p.d=0;var JSn=k(p1,"BinaryIndexedTree",602);A(473,1,{},ZR);var QSn=k(p1,"CrossingsCounter",473);A(1557,1,Or,nZ),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return WCt(this.a,t,i)};var eMn=k(p1,"CrossingsCounter/lambda$0$Type",1557);A(1558,1,Or,iZ),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return HCt(this.a,t,i)};var tMn=k(p1,"CrossingsCounter/lambda$1$Type",1558);A(1559,1,Or,rZ),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return qCt(this.a,t,i)};var nMn=k(p1,"CrossingsCounter/lambda$2$Type",1559);A(1560,1,Or,sZ),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return XCt(this.a,t,i)};var iMn=k(p1,"CrossingsCounter/lambda$3$Type",1560);A(1555,1,{},oZ);var rMn=k(p1,"HyperedgeCrossingsCounter",1555);A(426,1,{34:1,426:1},p8e),p.vd=function(t){return v5t(this,h(t,426))},p.b=0,p.c=0,p.e=0,p.f=0;var pVt=k(p1,"HyperedgeCrossingsCounter/Hyperedge",426);A(336,1,{34:1,336:1},U9),p.vd=function(t){return w8t(this,h(t,336))},p.b=0,p.c=0;var Pot=k(p1,"HyperedgeCrossingsCounter/HyperedgeCorner",336);A(472,23,{3:1,34:1,23:1,472:1},nge);var uL,fL,Lot=Mi(p1,"HyperedgeCrossingsCounter/HyperedgeCorner/Type",472,Di,$Pt,VTt),kot;A(1556,1,{},wZ),p.e=!0,p.f=0,p.g=0;var sMn=k(p1,"NorthSouthEdgeAllCrossingsCounter",1556);A(1311,1,Ml,uF),p.vf=function(t){return h(G(h(t,31),(Ie(),$a)),19).pc((xo(),Eu))?Rot:null},p.Pe=function(t,i){yBt(this,h(t,31),i)};var Rot,oMn=k(co,"InteractiveNodePlacer",1311);A(1312,1,Ml,_g),p.vf=function(t){return h(G(h(t,31),(Ie(),$a)),19).pc((xo(),Eu))?Iot:null},p.Pe=function(t,i){wDt(this,h(t,31),i)};var Iot,XG,YG,aMn=k(co,"LinearSegmentsNodePlacer",1312);A(235,1,{34:1,235:1},rpe),p.vd=function(t){return yEt(this,h(t,235))},p.Fb=function(t){var i;return re(t,235)?(i=h(t,235),this.b==i.b):!1},p.Hb=function(){return this.b},p.Ib=function(){return"ls"+$p(this.f)},p.a=0,p.b=0,p.c=-1,p.d=-1,p.i=0;var Dot=k(co,"LinearSegmentsNodePlacer/LinearSegment",235);A(1314,1,Ml,TUe),p.vf=function(t){return h(G(h(t,31),(Ie(),$a)),19).pc((xo(),Eu))?Bot:null},p.Pe=function(t,i){M$t(this,h(t,31),i)},p.b=0,p.g=0;var Bot,cMn=k(co,"NetworkSimplexPlacer",1314);A(1333,1,Or,OT),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return Lp(h(t,21).a,h(i,21).a)};var lMn=k(co,"NetworkSimplexPlacer/0methodref$compare$Type",1333);A(1335,1,Or,_a),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return Lp(h(t,21).a,h(i,21).a)};var uMn=k(co,"NetworkSimplexPlacer/1methodref$compare$Type",1335);A(584,1,{584:1},DOe);var gVt=k(co,"NetworkSimplexPlacer/EdgeRep",584);A(416,1,{416:1},L1e),p.b=!1;var mVt=k(co,"NetworkSimplexPlacer/NodeRep",416);A(460,12,{3:1,4:1,20:1,25:1,41:1,12:1,13:1,15:1,49:1,460:1},bDe);var fMn=k(co,"NetworkSimplexPlacer/Path",460);A(1315,1,ps,nq),p.Kb=function(t){return h(t,14).d.g.j};var hMn=k(co,"NetworkSimplexPlacer/Path/lambda$0$Type",1315);A(1316,1,ss,BT),p.Nb=function(t){return h(t,232)==(qt(),Nr)};var dMn=k(co,"NetworkSimplexPlacer/Path/lambda$1$Type",1316);A(1317,1,ps,iN),p.Kb=function(t){return h(t,14).d.g};var pMn=k(co,"NetworkSimplexPlacer/Path/lambda$2$Type",1317);A(1318,1,ss,aZ),p.Nb=function(t){return e8e(DWe(h(t,8)))};var gMn=k(co,"NetworkSimplexPlacer/Path/lambda$3$Type",1318);A(1319,1,ss,NT),p.Nb=function(t){return wl(),(Fe(),hb).pc(h(t,11).i)};var mMn=k(co,"NetworkSimplexPlacer/lambda$0$Type",1319);A(1320,1,{},BOe),p.td=function(t){TSt(this.a,this.b,t)};var bMn=k(co,"NetworkSimplexPlacer/lambda$1$Type",1320);A(1329,1,{},cZ),p.td=function(t){JNt(this.a,t)};var wMn=k(co,"NetworkSimplexPlacer/lambda$10$Type",1329);A(1330,1,ps,iq),p.Kb=function(t){return wl(),new si(null,new pi(h(t,26).a,16))};var vMn=k(co,"NetworkSimplexPlacer/lambda$11$Type",1330);A(1331,1,{},lZ),p.td=function(t){cUt(this.a,t)};var _Mn=k(co,"NetworkSimplexPlacer/lambda$12$Type",1331);A(1332,1,ps,rq),p.Kb=function(t){return wl(),He(h(t,113).e)};var yMn=k(co,"NetworkSimplexPlacer/lambda$13$Type",1332);A(1334,1,ps,sq),p.Kb=function(t){return wl(),He(h(t,113).e)};var xMn=k(co,"NetworkSimplexPlacer/lambda$14$Type",1334);A(1336,1,ss,sN),p.Nb=function(t){return wl(),h(t,416).c.j==(qt(),fs)};var EMn=k(co,"NetworkSimplexPlacer/lambda$15$Type",1336);A(1337,1,ss,oN),p.Nb=function(t){return wl(),h(t,416).c.i.c.length>1};var SMn=k(co,"NetworkSimplexPlacer/lambda$16$Type",1337);A(1338,1,{},xUe),p.td=function(t){Z6t(this.c,this.b,this.d,this.a,t)},p.c=0,p.d=0;var MMn=k(co,"NetworkSimplexPlacer/lambda$17$Type",1338);A(1339,1,{},uZ),p.td=function(t){USt(this.a,t)},p.a=0;var TMn=k(co,"NetworkSimplexPlacer/lambda$18$Type",1339);A(1340,1,ps,GT),p.Kb=function(t){return wl(),new si(null,new pi(h(t,26).a,16))};var CMn=k(co,"NetworkSimplexPlacer/lambda$19$Type",1340);A(1321,1,ps,aN),p.Kb=function(t){return wl(),new si(null,new pi(h(t,26).a,16))};var AMn=k(co,"NetworkSimplexPlacer/lambda$2$Type",1321);A(1341,1,{},yR),p.td=function(t){KSt(this.a,t)};var PMn=k(co,"NetworkSimplexPlacer/lambda$20$Type",1341);A(1342,1,ss,oE),p.Nb=function(t){return e8e(t)};var LMn=k(co,"NetworkSimplexPlacer/lambda$21$Type",1342);A(1343,1,ps,Bv),p.Kb=function(t){return wl(),new si(null,new pi(h(t,26).a,16))};var kMn=k(co,"NetworkSimplexPlacer/lambda$22$Type",1343);A(1344,1,ss,fZ),p.Nb=function(t){return cSt(this.a,t)};var RMn=k(co,"NetworkSimplexPlacer/lambda$23$Type",1344);A(1345,1,{},OOe),p.td=function(t){EOt(this.a,this.b,t)};var IMn=k(co,"NetworkSimplexPlacer/lambda$24$Type",1345);A(1346,1,ss,jT),p.Nb=function(t){return wl(),!Ko(h(t,14))};var DMn=k(co,"NetworkSimplexPlacer/lambda$25$Type",1346);A(1347,1,ss,oq),p.Nb=function(t){return wl(),!Ko(h(t,14))};var BMn=k(co,"NetworkSimplexPlacer/lambda$26$Type",1347);A(1348,1,{},xR),p.le=function(t,i){return FSt(this.a,t,i)};var OMn=k(co,"NetworkSimplexPlacer/lambda$27$Type",1348);A(1322,1,ps,aq),p.Kb=function(t){return wl(),new si(null,new rx(Tn(ur(h(t,8)))))};var NMn=k(co,"NetworkSimplexPlacer/lambda$3$Type",1322);A(1323,1,ss,cq),p.Nb=function(t){return wl(),qLt(h(t,14))};var FMn=k(co,"NetworkSimplexPlacer/lambda$4$Type",1323);A(1324,1,{},hZ),p.td=function(t){G7t(this.a,h(t,14))};var UMn=k(co,"NetworkSimplexPlacer/lambda$5$Type",1324);A(1325,1,ps,$T),p.Kb=function(t){return wl(),new si(null,new pi(h(t,26).a,16))};var zMn=k(co,"NetworkSimplexPlacer/lambda$6$Type",1325);A(1326,1,ss,VT),p.Nb=function(t){return wl(),h(t,8).j==(qt(),fs)};var GMn=k(co,"NetworkSimplexPlacer/lambda$7$Type",1326);A(1327,1,ps,Rk),p.Kb=function(t){return wl(),new si(null,new rx(Tn(t1(h(t,8)))))};var jMn=k(co,"NetworkSimplexPlacer/lambda$8$Type",1327);A(1328,1,ss,lq),p.Nb=function(t){return wl(),jCt(h(t,14))};var $Mn=k(co,"NetworkSimplexPlacer/lambda$9$Type",1328);A(1310,1,Ml,zv),p.vf=function(t){return h(G(h(t,31),(Ie(),$a)),19).pc((xo(),Eu))?Oot:null},p.Pe=function(t,i){wzt(h(t,31),i)};var Oot,VMn=k(co,"SimpleNodePlacer",1310);A(164,1,{164:1},$_),p.Ib=function(){var t;return t="",this.c==(xh(),ib)?t+=XS:this.c==Xp&&(t+=qS),this.o==(Zf(),M1)?t+=ore:this.o==rh?t+="UP":t+="BALANCED",t};var WMn=k(Wp,"BKAlignedLayout",164);A(466,23,{3:1,34:1,23:1,466:1},ige);var Xp,ib,Not=Mi(Wp,"BKAlignedLayout/HDirection",466,Di,zPt,XTt),Fot;A(465,23,{3:1,34:1,23:1,465:1},rge);var M1,rh,Uot=Mi(Wp,"BKAlignedLayout/VDirection",465,Di,GPt,YTt),zot;A(1485,1,{},NOe);var HMn=k(Wp,"BKAligner",1485);A(1488,1,{},tqe);var qMn=k(Wp,"BKCompactor",1488);A(593,1,{593:1},uq),p.a=0;var XMn=k(Wp,"BKCompactor/ClassEdge",593);A(423,1,{423:1},pDe),p.a=null,p.b=0;var YMn=k(Wp,"BKCompactor/ClassNode",423);A(1313,1,Ml,jOe),p.vf=function(t){return h(G(h(t,31),(Ie(),$a)),19).pc((xo(),Eu))?Got:null},p.Pe=function(t,i){z$t(this,h(t,31),i)},p.a=!1,p.e=!1;var Got,ZMn=k(Wp,"BKNodePlacer",1313);A(437,23,{3:1,34:1,23:1,437:1},sge);var ZG,LTe,kTe=Mi(Wp,"EdgeStraighteningStrategy",437,Di,UPt,ZTt),jot;A(1486,1,{},fq),p.d=0;var KMn=k(Wp,"NeighborhoodInformation",1486);A(1487,1,Or,dZ),p.Ld=function(t,i){return Wkt(this,h(t,48),h(i,48))},p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)};var JMn=k(Wp,"NeighborhoodInformation/NeighborComparator",1487);A(724,1,{});var QMn=k(Wp,"ThresholdStrategy",724);A(1510,724,{},yDe),p.yf=function(t,i,a){return this.a.o==(Zf(),rh)?Kr:Ts},p.zf=function(){};var eTn=k(Wp,"ThresholdStrategy/NullThresholdStrategy",1510);A(522,1,{522:1},UOe),p.c=!1,p.d=!1;var tTn=k(Wp,"ThresholdStrategy/Postprocessable",522);A(1511,724,{},xDe),p.yf=function(t,i,a){var l,f,g;return f=i==a,l=this.a.a[a.o]==i,f||l?(g=t,this.a.c==(xh(),ib)?(f&&(g=Cne(this,i,!0)),!isNaN(g)&&!isFinite(g)&&l&&(g=Cne(this,a,!1))):(f&&(g=Cne(this,i,!0)),!isNaN(g)&&!isFinite(g)&&l&&(g=Cne(this,a,!1))),g):t},p.zf=function(){for(var t,i,a,l,f;this.c.b!=0;)f=h(XPt(this.c),522),l=XZe(this,f),l.a&&(t=l.a,a=ce(this.a.f[this.a.g[f.b.o].o]),!(!a&&!Ko(t)&&t.c.g.c==t.d.g.c)&&(i=tYe(this,f),i||FNe(this.d,f)));for(;this.d.a.c.length!=0;)tYe(this,h(Abe(this.d),522))};var nTn=k(Wp,"ThresholdStrategy/SimpleThresholdStrategy",1511);A(573,1,{573:1,285:1,286:1},tu),p.hf=function(){return K$e(this)},p.uf=function(){return K$e(this)};var Roe,iTn=k(Q_,"EdgeRouterFactory",573);A(1356,1,Ml,$X),p.vf=function(t){return N9t(h(t,31))},p.Pe=function(t,i){Nzt(h(t,31),i)};var $ot,Vot,Wot,Hot,qot,RTe,Xot,Yot,rTn=k(Q_,"OrthogonalEdgeRouter",1356);A(594,1,{},Nte),p.a=0,p.c=0;var sTn=k(Q_,"OrthogonalRoutingGenerator",594);A(252,1,{252:1},mU),p.Ib=function(){return this.a+"->"+this.b},p.c=0;var oTn=k(Q_,"OrthogonalRoutingGenerator/Dependency",252);A(165,1,{34:1,165:1},rVe),p.vd=function(t){return xEt(this,h(t,165))},p.Fb=function(t){var i;return re(t,165)?(i=h(t,165),this.d==i.d):!1},p.Hb=function(){return this.d},p.Ib=function(){var t,i,a,l;for(t=new su("{"),l=new j(this.g);l.aKd&&(f=new $t(y,R),Gi(a.a,f),P6(this.a,a,t,f,!1),g=new $t(C,R),Gi(a.a,g),P6(this.a,a,t,g,!1))},p.Bf=function(t){return t.g.k.a+t.k.a+t.a.a},p.Cf=function(){return Fe(),ei},p.Df=function(){return Fe(),bn};var cTn=k(Q_,"OrthogonalRoutingGenerator/NorthToSouthRoutingStrategy",1490);A(1491,1,{},Ou),p.Af=function(t,i){var a,l,f,g,m,v,y,E,C,R;for(R=i-t.i*this.a.c,v=new j(t.g);v.aKd&&(f=new $t(y,R),Gi(a.a,f),P6(this.a,a,t,f,!1),g=new $t(C,R),Gi(a.a,g),P6(this.a,a,t,g,!1))},p.Bf=function(t){return t.g.k.a+t.k.a+t.a.a},p.Cf=function(){return Fe(),bn},p.Df=function(){return Fe(),ei};var lTn=k(Q_,"OrthogonalRoutingGenerator/SouthToNorthRoutingStrategy",1491);A(1489,1,{},Xh),p.Af=function(t,i){var a,l,f,g,m,v,y,E,C,R;for(R=i+t.i*this.a.c,v=new j(t.g);v.aKd&&(f=new $t(R,y),Gi(a.a,f),P6(this.a,a,t,f,!0),g=new $t(R,C),Gi(a.a,g),P6(this.a,a,t,g,!0))},p.Bf=function(t){return t.g.k.b+t.k.b+t.a.b},p.Cf=function(){return Fe(),Zt},p.Df=function(){return Fe(),tn};var uTn=k(Q_,"OrthogonalRoutingGenerator/WestToEastRoutingStrategy",1489);A(1351,1,Ml,$Oe),p.vf=function(t){return uNt(h(t,31))},p.Pe=function(t,i){Fjt(this,h(t,31),i)};var Zot,Kot,Jot,Qot,KG,fTn=k(Q_,"PolylineEdgeRouter",1351);A(1352,1,Qu,cN),p.Mb=function(t){return YRt(h(t,8))},p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)};var hTn=k(Q_,"PolylineEdgeRouter/1",1352);A(151,1,{151:1},XVe),p.Ib=function(){var t,i,a,l;for(a=new u0,this.e&&Si(Si(a,tI(this.e)),": "),i=On(wQ(this),0);i.b!=i.d.c;)t=h(Fn(i),11),Si(Si(Lg(Si(a,(l=rGe(t),l==null?"p_"+t.o:"p_"+l)),32),tI(t.i))," / ");return E8(a,a.a.length-2-1)},p.j=0,p.k=0;var dTn=k(g1,"ConnectedSelfLoopComponent",151);A(129,23,{3:1,34:1,23:1,129:1},Ig),p.c=0;var eat,tat,nat,rb,Ww,Yp,Hw,lm,np,Zp,sb,ob,iat,rat,sat,oat,aat,cat,lat,uat,fat,hat,dat,pat,gat,yy,c3,qw,Xw,hL=Mi(g1,"LoopSide",129,Di,Tee,KTt),mat;A(424,1,{},OWe,__e,fwe),p.Ib=function(){return this.b.Ib()},p.c=0,p.d=!1,p.e=!1,p.f=!1,p.i=0,p.j=0;var pTn=k(g1,"NubSpline",424);A(190,1,{190:1},GYe,vQ);var gTn=k(g1,"NubSpline/PolarCP",190);A(599,424,{},fQ);var mTn=k(g1,"NubsSelfLoop",599);A(236,1,{},tXe,Wte,Aqe,EI,Yte),p.a=q2e,p.b=zx,p.c=q2e,p.d=zx;var bTn=k(g1,"Rectangle",236);A(1353,1,Ml,HHe),p.vf=function(t){return DFt(h(t,31))},p.Pe=function(t,i){G$t(this,h(t,31),i)},p.d=3;var bat,wat,vat,_at,yat,xat,wTn=k(g1,"SplineEdgeRouter",1353);A(250,1,{250:1},oU),p.Ib=function(){return this.a+" ->("+this.c+") "+this.b},p.c=0;var vTn=k(g1,"SplineEdgeRouter/Dependency",250);A(417,23,{3:1,34:1,23:1,417:1},cge);var um,xy,Eat=Mi(g1,"SplineEdgeRouter/SideToProcess",417,Di,jPt,eCt),Sat;A(1354,1,{},KOe),p.td=function(t){OCt(this.a,this.b,t)};var _Tn=k(g1,"SplineEdgeRouter/lambda$0$Type",1354);A(1355,1,{},JOe),p.td=function(t){NCt(this.a,this.b,t)};var yTn=k(g1,"SplineEdgeRouter/lambda$1$Type",1355);A(125,1,{34:1,125:1},hXe,y_e),p.vd=function(t){return EEt(this,h(t,125))},p.b=0,p.e=0,p.f=0,p.i=!1,p.j=0,p.k=!1,p.n=!1,p.p=0,p.r=0,p.s=0;var xTn=k(g1,"SplineSegment",125);A(589,1,{589:1},zf),p.a=0,p.b=!1,p.c=!1,p.d=!1,p.e=!1,p.f=0;var ETn=k(g1,"SplineSegment/EdgeInformation",589);A(990,1,{},hq);var STn=k(CP,bye,990);A(991,1,Or,dq),p.Ld=function(t,i){return fFt(h(t,128),h(i,128))},p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)};var MTn=k(CP,lQe,991);A(989,1,{},ABe);var TTn=k(CP,"MrTree",989);A(360,23,{3:1,34:1,23:1,360:1,285:1,286:1},k8),p.hf=function(){return TXe(this)},p.uf=function(){return TXe(this)};var JG,dL,q5,pL,ITe=Mi(CP,"TreeLayoutPhases",360,Di,s4t,HTt),Mat;A(960,244,K_,f8e),p.Ae=function(t,i){var a,l,f,g,m,v;for(g=(m=new aU,Oo(m,t),Ee(m,(fa(),bL),t),v=new li,y7t(t,m,v),l7t(t,m,v),m),f=S7t(this.a,g),l=new j(f);l.a"+Z9(this.c):"e_"+Wr(this)};var kTn=k(AP,"TEdge",170);A(128,131,{3:1,128:1,93:1,131:1},aU),p.Ib=function(){var t,i,a,l,f;for(f=null,l=On(this.b,0);l.b!=l.d.c;)a=h(Fn(l),76),f+=(a.c==null||a.c.length==0?"n_"+a.g:"n_"+a.c)+` +`;for(i=On(this.a,0);i.b!=i.d.c;)t=h(Fn(i),170),f+=(t.b&&t.c?Z9(t.b)+"->"+Z9(t.c):"e_"+Wr(t))+` +`;return f};var bVt=k(AP,"TGraph",128);A(570,452,{3:1,452:1,570:1,93:1,131:1});var RTn=k(AP,"TShape",570);A(76,570,{3:1,452:1,76:1,570:1,93:1,131:1},Pee),p.Ib=function(){return Z9(this)};var wVt=k(AP,"TNode",76);A(231,1,fd,Id),p.sc=function(t){mo(this,t)},p.tc=function(){var t;return t=On(this.a.d,0),new Jb(t)};var ITn=k(AP,"TNode/2",231);A(330,1,ys,Jb),p.gc=function(t){Ss(this,t)},p.ic=function(){return h(Fn(this.a),170).c},p.hc=function(){return v8(this.a)},p.jc=function(){z0e(this.a)};var DTn=k(AP,"TNode/2/1",330);A(1545,1,kr,h8e),p.Pe=function(t,i){D7t(this,h(t,128),i)};var BTn=k(Gx,"FanProcessor",1545);A(308,23,{3:1,34:1,23:1,308:1,286:1},$C),p.hf=function(){switch(this.g){case 0:return new gDe;case 1:return new h8e;case 2:return new T2;case 3:return new aE;case 4:return new Ik;case 5:return new lE;default:throw Y(new un(Iie+(this.f!=null?this.f:""+this.g)))}};var Ioe,Doe,Boe,Ooe,Noe,QG,Tat=Mi(Gx,Lye,308,Di,bkt,qTt),Cat;A(1548,1,kr,aE),p.Pe=function(t,i){m8t(this,h(t,128),i)},p.a=0;var OTn=k(Gx,"LevelHeightProcessor",1548);A(1549,1,fd,Dk),p.sc=function(t){mo(this,t)},p.tc=function(){return yt(),Yv(),uy};var NTn=k(Gx,"LevelHeightProcessor/1",1549);A(1546,1,kr,T2),p.Pe=function(t,i){NNt(this,h(t,128),i)},p.a=0;var FTn=k(Gx,"NeighborsProcessor",1546);A(1547,1,fd,cE),p.sc=function(t){mo(this,t)},p.tc=function(){return yt(),Yv(),uy};var UTn=k(Gx,"NeighborsProcessor/1",1547);A(1550,1,kr,Ik),p.Pe=function(t,i){g8t(this,h(t,128),i)},p.a=0;var zTn=k(Gx,"NodePositionProcessor",1550);A(1544,1,kr,gDe),p.Pe=function(t,i){eGt(this,h(t,128))};var GTn=k(Gx,"RootProcessor",1544);A(1551,1,kr,lE),p.Pe=function(t,i){r6t(h(t,128))};var jTn=k(Gx,"Untreeifyer",1551),X5,gL,Aat,Foe,ej,mL,Uoe,tj,nj,bM,bL,ij,Kp,DTe,Pat,zoe,Yw,Goe,BTe;A(750,1,dd,UX),p.ue=function(t){zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,X2e),""),"Weighting of Nodes"),"Which weighting to use when computing a node order."),NTe),(o1(),gs)),VTe),Wt((i1(),Pn))))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Y2e),""),"Search Order"),"Which search order to use when computing a spanning tree."),OTe),gs),HTe),Wt(Pn)))),gKe((new zX,t))};var Lat,OTe,kat,NTe,$Tn=k(dz,"MrTreeMetaDataProvider",750);A(886,1,dd,zX),p.ue=function(t){gKe(t)};var Rat,FTe,UTe,Iat,zTe,rj,GTe,Dat,jTe,Bat,VTn=k(dz,"MrTreeOptions",886);A(887,1,{},vq),p.Be=function(){var t;return t=new f8e,t},p.Ce=function(t){};var WTn=k(dz,"MrTreeOptions/MrtreeFactory",887);A(438,23,{3:1,34:1,23:1,438:1},lge);var joe,$Te,VTe=Mi(dz,"OrderWeighting",438,Di,NPt,tCt),Oat;A(388,23,{3:1,34:1,23:1,388:1},uge);var WTe,$oe,HTe=Mi(dz,"TreeifyingOrder",388,Di,OPt,nCt),Nat;A(1357,1,Ml,GX),p.vf=function(t){return h(t,128),Fat},p.Pe=function(t,i){DRt(this,h(t,128),i)};var Fat,HTn=k("org.eclipse.elk.alg.mrtree.p1treeify","DFSTreeifyer",1357);A(1358,1,Ml,jX),p.vf=function(t){return h(t,128),Uat},p.Pe=function(t,i){FNt(this,h(t,128),i)};var Uat,qTn=k("org.eclipse.elk.alg.mrtree.p2order","NodeOrderer",1358);A(1359,1,Ml,fF),p.vf=function(t){return h(t,128),zat},p.Pe=function(t,i){_Ut(this,h(t,128),i)},p.a=0;var zat,XTn=k("org.eclipse.elk.alg.mrtree.p3place","NodePlacer",1359);A(1360,1,Ml,VX),p.vf=function(t){return h(t,128),Gat},p.Pe=function(t,i){oBt(h(t,128),i)};var Gat,YTn=k("org.eclipse.elk.alg.mrtree.p4route","EdgeRouter",1360),wL;A(447,23,{3:1,34:1,23:1,447:1,285:1,286:1},fge),p.hf=function(){return xWe(this)},p.uf=function(){return xWe(this)};var sj,wM,qTe=Mi(Z2e,"RadialLayoutPhases",447,Di,FPt,iCt),jat;A(961,244,K_,PBe),p.Ae=function(t,i){var a,l,f,g,m,v,y;if(l=lXe(this,t),ni(i,"Radial layout",l.c.length),y=SOt(t),oc(t,(eA(),wL),y),!y)throw Y(new un("The given graph is not a tree!"));for(g=ce(Xe(nn(t,(mw(),cj)))),g==0&&(g=MXe(t)),oc(t,cj,g),a=new dK(t),ad(OHe(a),new hE),f=new ER(a),SWe(f),v=new j(lXe(this,t));v.a0&&V$e(t.charCodeAt(i-1),wQe);)--i;if(l>=i)throw Y(new un("The given string does not contain any numbers."));if(f=Px(t.substr(l,i-l),`,|;|\r| +`),f.length!=2)throw Y(new un("Exactly two numbers are expected, "+f.length+" were found."));try{this.a=_w(vw(f[0])),this.b=_w(vw(f[1]))}catch(g){throw g=hr(g),re(g,118)?(a=g,Y(new un(vQe+a))):Y(g)}},p.Ib=function(){return"("+this.a+","+this.b+")"},p.a=0,p.b=0;var Qr=k(Q6,"KVector",9);A(74,66,{3:1,4:1,20:1,25:1,41:1,13:1,66:1,15:1,74:1,428:1},Uc,p8),p.gf=function(t){var i,a,l,f,g,m;l=Px(t,`,|;|\\(|\\)|\\[|\\]|\\{|\\}| | | +`),id(this);try{for(a=0,g=0,f=0,m=0;a0&&(g%2==0?f=_w(l[a]):m=_w(l[a]),g>0&&g%2!=0&&Gi(this,new $t(f,m)),++g),++a}catch(v){throw v=hr(v),re(v,118)?(i=v,Y(new un("The given string does not match the expected format for vectors."+i))):Y(v)}},p.Ib=function(){var t,i,a;for(t=new su("("),i=On(this,0);i.b!=i.d.c;)a=h(Fn(i),9),Si(t,a.a+","+a.b),i.b!=i.d.c&&(t.a+="; ");return(t.a+=")",t).a};var pCe=k(Q6,"KVectorChain",74);A(224,23,{3:1,34:1,23:1,224:1},VC);var Qoe,lj,uj,J5,Q5,fj,gCe=Mi(Af,"Alignment",224,Di,wkt,lCt),cct;A(855,1,dd,qX),p.ue=function(t){RZe(t)};var mCe,eae,bCe,wCe,lct,tae,uct,fct,vCe,_Ce,hct,oAn=k(Af,"BoxLayouterOptions",855);A(856,1,{},hN),p.Be=function(){var t;return t=new jq,t},p.Ce=function(t){};var aAn=k(Af,"BoxLayouterOptions/BoxFactory",856);A(785,1,dd,XX),p.ue=function(t){zt(t,new Rt(Ft(Nt(Ut(It(Ot(Dt(Bt(new Lt,iet),""),"Layout Algorithm"),"Select a specific layout algorithm."),(o1(),Z5)),Se),Wt((i1(),Pn))))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,x2e),""),"Alignment"),"Alignment of the selected node relative to other nodes, the exact meaning depends on the used algorithm."),xCe),gs),gCe),Wt(pa)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.alignment"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(It(Ot(Dt(Bt(new Lt,VS),""),"Aspect Ratio"),"The desired aspect ratio of the drawing, that is the quotient of width by height."),tc),Eo),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.aspectRatio"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(It(Ot(Dt(Bt(new Lt,cxe),""),"Bend Points"),"A fixed list of bend points for the edge. This is used by the 'Fixed Layout' algorithm to specify a pre-defined routing for an edge. The vector chain must include the source point, any bend points, and the target point, so it must have at least two points."),bd),pCe),Wt(md)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.bendPoints"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,nre),""),"Debug Mode"),"Whether additional debug information shall be generated."),(vt(),vt(),!1)),va),lo),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.debugMode"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,rre),""),uye),"Overall direction of edges: horizontal (right / left) or vertical (down / up)."),SCe),gs),yL),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.direction"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,n5),""),"Edge Routing"),"What kind of edge routing style should be applied for the content of a parent node. Algorithms may also set this option to single edges in order to mark them as splines. The bend point list of edges with this option set to SPLINES must be interpreted as control points for a piecewise cubic spline."),CCe),gs),mae),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.edgeRouting"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,oxe),""),"Expand Nodes"),"If active, nodes are expanded to fill the area of their parent."),!1),va),lo),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.expandNodes"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,E2e),""),"Hierarchy Handling"),"If this option is set to SEPARATE_CHILDREN, each hierarchy level of the graph is processed independently, possibly by different layout algorithms, beginning with the lowest level. If it is set to INCLUDE_CHILDREN, the algorithm is responsible to process all hierarchy levels that are contained in the associated parent node. If the root node is set to inherit (or not set at all), the default behavior is SEPARATE_CHILDREN."),LCe),gs),uAe),or(Pn,X(q(Jp,1),Oe,163,0,[pa]))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.hierarchyHandling"])))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Fx),""),"Padding"),"The padding to be left to a parent element's border when placing child elements. This can also serve as an output option of a layout algorithm if node size calculation is setup appropriately."),FCe),bd),PEe),or(Pn,X(q(Jp,1),Oe,163,0,[pa]))))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Q7),""),"Interactive"),"Whether the algorithm should be run in interactive mode for the content of a parent node. What this means exactly depends on how the specific algorithm interprets this option. Usually in the interactive mode algorithms try to modify the current layout as little as possible."),!1),va),lo),Wt(Pn)))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,kie),""),"Port Constraints"),"Defines constraints of the position of the ports of a node."),$Ce),gs),dAe),Wt(pa)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portConstraints"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(It(Ot(Dt(Bt(new Lt,fz),""),"Position"),"The position of a node, port, or label. This is used by the 'Fixed Layout' algorithm to specify a pre-defined position."),bd),Qr),or(pa,X(q(Jp,1),Oe,163,0,[ab,fm]))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.position"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(It(Ot(Dt(Bt(new Lt,Y6),""),"Priority"),"Defines the priority of an object; its meaning depends on the specific layout algorithm and the context where it is used."),yc),Ao),or(pa,X(q(Jp,1),Oe,163,0,[md]))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.priority"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(It(Ot(Dt(Bt(new Lt,J7),""),"Randomization Seed"),"Seed used for pseudo-random number generators to control the layout algorithm. If the value is 0, the seed shall be determined pseudo-randomly (e.g. from the system time)."),yc),Ao),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.randomSeed"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(It(Ot(Dt(Bt(new Lt,Z6),""),"Separate Connected Components"),"Whether each connected component should be processed separately."),va),lo),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.separateConnComp"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,D2e),""),"Junction Points"),"This option is not used as option, but as output of the layout algorithms. It is attached to edges and determines the points where junction symbols should be drawn in order to represent hyperedges with orthogonal routing. Whether such points are computed depends on the chosen layout algorithm and edge routing style. The points are put into the vector chain with no specific order."),kCe),bd),pCe),Wt(md)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.junctionPoints"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,F2e),""),"Comment Box"),"Whether the node should be regarded as a comment box instead of a regular node. In that case its placement should be similar to how labels are handled. Any edges incident to a comment box specify to which graph elements the comment is related."),!1),va),lo),Wt(pa)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.commentBox"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,U2e),""),"Hypernode"),"Whether the node should be handled as a hypernode."),!1),va),lo),Wt(pa)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.hypernode"])))),zt(t,new Rt(Ft(Nt(Ut(It(Ot(Dt(Bt(new Lt,ret),""),"Label Manager"),"Label managers can shorten labels upon a layout algorithm's request."),bd),TVt),or(Pn,X(q(Jp,1),Oe,163,0,[fm]))))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,$2e),""),"Margins"),"Margins define additional space around the actual bounds of a graph element. For instance, ports or labels being placed on the outside of a node's border might introduce such a margin. The margin is used to guarantee non-overlap of other graph elements with those ports or labels."),RCe),bd),AEe),Wt(pa)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.margins"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,_2e),""),"No Layout"),"No layout is done for the associated element. This is used to mark parts of a diagram to avoid their inclusion in the layout graph, or to mark parts of the layout graph to prevent layout engines from processing them. If you wish to exclude the contents of a compound node from automatic layout, while the node itself is still considered on its own layer, use the 'Fixed Layout' algorithm for that node."),!1),va),lo),or(pa,X(q(Jp,1),Oe,163,0,[md,ab,fm]))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.noLayout"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,set),""),"Scale Factor"),"The scaling factor to be applied to the corresponding node in recursive layout. It causes the corresponding node's size to be adjusted, and its ports and labels to be sized and placed accordingly after the layout of that node has been determined (and before the node itself and its siblings are arranged). The scaling is not reverted afterwards, so the resulting layout graph contains the adjusted size and position data. This option is currently not supported if 'Layout Hierarchy' is set."),1),tc),Eo),Wt(pa)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.scaleFactor"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,oet),""),"Animate"),"Whether the shift from the old layout to the new computed layout shall be animated."),!0),va),lo),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.animate"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,aet),""),"Animation Time Factor"),"Factor for computation of animation time. The higher the value, the longer the animation time. If the value is 0, the resulting time is always equal to the minimum defined by 'Minimal Animation Time'."),He(100)),yc),Ao),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.animTimeFactor"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,cet),""),"Layout Ancestors"),"Whether the hierarchy levels on the path from the selected element to the root of the diagram shall be included in the layout process."),!1),va),lo),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.layoutAncestors"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,uet),""),"Maximal Animation Time"),"The maximal time for animations, in milliseconds."),He(4e3)),yc),Ao),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.maxAnimTime"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,fet),""),"Minimal Animation Time"),"The minimal time for animations, in milliseconds."),He(400)),yc),Ao),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.minAnimTime"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,het),""),"Progress Bar"),"Whether a progress bar shall be displayed during layout computations."),!1),va),lo),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.progressBar"])))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,det),""),"Validate Options"),"Whether layout options shall be validated before any layout algorithm is applied. If this option is enabled and at least one error is found, the layout process is aborted and a message is shown to the user."),!0),va),lo),Wt(Pn)))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,pet),""),"Zoom to Fit"),"Whether the zoom level shall be set to view the whole diagram after layout."),!1),va),lo),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.zoomToFit"])))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,axe),"box"),"Box Layout Mode"),"Configures the packing mode used by the {@link BoxLayoutProvider}. If SIMPLE is not required (neither priorities are used nor the interactive mode), GROUP_DEC can improve the packing and decrease the area. GROUP_MIXED and GROUP_INC may, in very specific scenarios, work better."),ECe),gs),yAe),Wt(Pn)))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Mie),im),"Components Spacing"),"Spacing to be preserved between pairs of connected components. This option is only relevant if 'separateConnectedComponents' is activated."),12),tc),Eo),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.borderSpacing"])))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,h2e),im),"Edge Spacing"),"Spacing to be preserved between any two edges. Note that while this can somewhat easily be satisfied for the segments of orthogonally drawn edges, it is harder for general polylines or splines."),10),tc),Eo),Wt(Pn)))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Lie),im),"Edge Label Spacing"),"The minimal distance to be preserved between a label and the edge it is associated with. Note that the placement of a label is influenced by the 'edgelabels.placement' option."),2),tc),Eo),Wt(Pn)))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,d2e),im),"Edge Node Spacing"),"Spacing to be preserved between nodes and edges."),10),tc),Eo),Wt(Pn)))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,p2e),im),"Label Spacing"),"Determines the amount of space to be left between two labels of the same graph element."),0),tc),Eo),Wt(Pn)),X(q(Se,1),be,2,6,[vet])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,m2e),im),"Label Node Spacing"),"Spacing to be preserved between labels and the border of node they are associated with. Note that the placement of a label is influenced by the 'nodelabels.placement' option."),5),tc),Eo),Wt(Pn)),X(q(Se,1),be,2,6,[vet])))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,g2e),im),"Label Port Spacing"),"Spacing to be preserved between labels and the ports they are associated with. Note that the placement of a label is influenced by the 'portlabels.placement' option."),1),tc),Eo),Wt(Pn)))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,HS),im),"Node Spacing"),"The minimal distance to be preserved between each two nodes."),20),tc),Eo),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.spacing"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,b2e),im),"Port Spacing"),"Spacing between pairs of ports of the same node."),10),tc),Eo),or(Pn,X(q(Jp,1),Oe,163,0,[pa]))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portSpacing"])))),zt(t,new Rt(Ft(Nt(Ut(It(Ot(Dt(Bt(new Lt,w2e),im),"Individual Spacing Override"),"In general spacing values apply to the children of the hierarchical node (possibly the root node) for which the values are actually specified. Hereby, the children include ports, edges, and labels."),bd),_Vt),or(pa,X(q(Jp,1),Oe,163,0,[md,ab,fm]))))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,V2e),im),"Additional Port Space"),"Additional space around the sets of ports on each node side. For each side of a node, this option can reserve additional space before and after the ports on each side. For example, a top spacing of 20 makes sure that the first port on the western and eastern side is 20 units away from the northern border."),KCe),bd),AEe),Wt(Pn)))),zt(t,new Rt(Ti(Ft(Nt(Ut(It(Ot(Dt(Bt(new Lt,j2e),_et),"Layout Partition"),"Partition to which the node belongs to. If 'layoutPartitions' is true, all nodes are expected to have a partition."),yc),Ao),or(Pn,X(q(Jp,1),Oe,163,0,[pa]))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.partition"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,G2e),_et),"Layout Partitioning"),"Whether to activate partitioned layout."),UCe),va),lo),Wt(Pn)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.layoutPartitions"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,get),yet),"Node Label Padding"),"Define padding for node labels that are placed inside of a node."),ICe),bd),PEe),Wt(pa)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.nodeLabelInset"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,T2e),yet),"Node Label Placement"),"Hints for where node labels are to be placed; if empty, the node label's position is not modified."),DCe),vM),Zs),or(pa,X(q(Jp,1),Oe,163,0,[fm]))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.nodeLabelPlacement"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,P2e),pz),"Port Alignment"),"Defines the default port distribution for a node. May be overridden for each side individually."),GCe),gs),CL),Wt(pa)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portAlignment"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(It(Ot(Dt(Bt(new Lt,L2e),pz),"Port Alignment (North)"),"Defines how ports on the northern side are placed, overriding the node's general port alignment."),gs),CL),Wt(pa)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portAlignment.north"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(It(Ot(Dt(Bt(new Lt,k2e),pz),"Port Alignment (South)"),"Defines how ports on the southern side are placed, overriding the node's general port alignment."),gs),CL),Wt(pa)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portAlignment.south"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(It(Ot(Dt(Bt(new Lt,R2e),pz),"Port Alignment (West)"),"Defines how ports on the western side are placed, overriding the node's general port alignment."),gs),CL),Wt(pa)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portAlignment.west"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(It(Ot(Dt(Bt(new Lt,I2e),pz),"Port Alignment (East)"),"Defines how ports on the eastern side are placed, overriding the node's general port alignment."),gs),CL),Wt(pa)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portAlignment.east"])))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,lz),lxe),"Node Size Constraints"),"Constraints for determining node sizes. Each member of the set specifies something that should be taken into account when calculating node sizes. The empty set corresponds to node sizes being fixed."),BCe),vM),AL),Wt(pa)))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,ire),lxe),"Node Size Options"),"Options modifying the behavior of the size constraints set on a node. Each member of the set specifies something that should be taken into account when calculating node sizes. The empty set corresponds to no further modifications."),NCe),vM),bAe),Wt(pa)))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,uz),lxe),"Node Size Minimum"),"The minimal size to which a node can be reduced."),OCe),bd),Qr),Wt(pa)))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,B2e),tre),"Edge Label Placement"),"Gives a hint on where to put edge labels."),MCe),gs),QCe),Wt(fm)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.edgeLabelPlacement"])))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,O2e),tre),"Inline Edge Labels"),"If true, an edge label is placed directly on its edge. May only apply to center edge labels. This kind of label placement is only advisable if the label's rendering is such that it is not crossed by its edge and thus stays legible."),!1),va),lo),Wt(fm)))),zt(t,new Rt(Ti(Ft(Nt(Ut(It(Ot(Dt(Bt(new Lt,met),"font"),"Font Name"),"Font name used for a label."),Z5),Se),Wt(fm)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.fontName"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(It(Ot(Dt(Bt(new Lt,bet),"font"),"Font Size"),"Font size used for a label."),yc),Ao),Wt(fm)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.fontSize"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(It(Ot(Dt(Bt(new Lt,z2e),pre),"Port Anchor Offset"),"The offset to the port position where connections shall be attached."),bd),Qr),Wt(ab)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portAnchor"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(It(Ot(Dt(Bt(new Lt,N2e),pre),"Port Index"),"The index of a port in the fixed order around a node. The order is assumed as clockwise, starting with the leftmost port on the top side. This option must be set if 'Port Constraints' is set to FIXED_ORDER and no specific positions are given for the ports. Additionally, the option 'Port Side' must be defined in this case."),yc),Ao),Wt(ab)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portIndex"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,y2e),pre),"Port Side"),"The side of a node on which a port is situated. This option must be set if 'Port Constraints' is set to FIXED_SIDE or FIXED_ORDER and no specific positions are given for the ports."),WCe),gs),xc),Wt(ab)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portSide"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(It(Ot(Dt(Bt(new Lt,v2e),pre),"Port Border Offset"),"The offset of ports on the node border. With a positive offset the port is moved outside of the node, while with a negative offset the port is moved towards the inside. An offset of 0 means that the port is placed directly on the node border, i.e. if the port side is north, the port's south border touches the nodes's north border; if the port side is east, the port's west border touches the nodes's east border; if the port side is south, the port's north border touches the node's south border; if the port side is west, the port's east border touches the node's west border."),tc),Eo),Wt(ab)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.offset"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,C2e),xet),"Port Label Placement"),"Decides on a placement method for port labels."),VCe),gs),pAe),Wt(pa)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portLabelPlacement"])))),zt(t,new Rt(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,A2e),xet),"Port Labels Next to Port"),"Usually, inside port labels of hierarchical nodes are placed not next to their port, but with an offset to avoid edge-label crossings. The offset is not necessary if the port has no connections that would cross the label, but is usually applied anyway to keep things uniform. Setting this option to true places labels next to their ports if they won't be crossed by edges."),!1),va),lo),Wt(pa)))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,S2e),Eet),"Activate Inside Self Loops"),"Whether this node allows to route self loops inside of it instead of around it. If set to true, this will make the node a compound node if it isn't already, and will require the layout algorithm to support compound nodes with hierarchical ports."),!1),va),lo),Wt(pa)),X(q(Se,1),be,2,6,[Met])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,M2e),Eet),"Inside Self Loop"),"Whether a self loop should be routed inside a node instead of around that node."),!1),va),lo),Wt(md)),X(q(Se,1),be,2,6,[Met])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,Tie),"edge"),"Edge Thickness"),"The thickness of an edge. This is a hint on the line width used to draw an edge, possibly requiring more space to be reserved for it."),1),tc),Eo),Wt(md)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.thickness"])))),zt(t,new Rt(Ti(Ft(Nt(Ut(dn(It(Ot(Dt(Bt(new Lt,wet),"edge"),"Edge Type"),"The type of an edge. This is usually used for UML class diagrams, where associations must be handled differently from generalizations."),PCe),gs),sAe),Wt(md)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.edgeType"])))),BC(t,new ax(AC(DE(IE(new $b,An),"Layered"),'The layer-based method was introduced by Sugiyama, Tagawa and Toda in 1981. It emphasizes the direction of edges by pointing as many edges as possible into the same direction. The nodes are arranged in layers, which are sometimes called "hierarchies", and then reordered such that the number of edge crossings is minimized. Afterwards, concrete coordinates are computed for the nodes and edge bend points.'))),BC(t,new ax(AC(DE(IE(new $b,"org.eclipse.elk.orthogonal"),"Orthogonal"),`Orthogonal methods that follow the "topology-shape-metrics" approach by Batini, Nardelli and Tamassia '86. The first phase determines the topology of the drawing by applying a planarization technique, which results in a planar representation of the graph. The orthogonal shape is computed in the second phase, which aims at minimizing the number of edge bends, and is called orthogonalization. The third phase leads to concrete coordinates for nodes and edge bend points by applying a compaction method, thus defining the metrics.`))),BC(t,new ax(AC(DE(IE(new $b,Lh),"Force"),"Layout algorithms that follow physical analogies by simulating a system of attractive and repulsive forces. The first successful method of this kind was proposed by Eades in 1984."))),BC(t,new ax(AC(DE(IE(new $b,"org.eclipse.elk.circle"),"Circle"),"Circular layout algorithms emphasize cycles or biconnected components of a graph by arranging them in circles. This is useful if a drawing is desired where such components are clearly grouped, or where cycles are shown as prominent OPTIONS of the graph."))),BC(t,new ax(AC(DE(IE(new $b,qQe),"Tree"),"Specialized layout methods for trees, i.e. acyclic graphs. The regular structure of graphs that have no undirected cycles can be emphasized using an algorithm of this type."))),BC(t,new ax(AC(DE(IE(new $b,"org.eclipse.elk.planar"),"Planar"),"Algorithms that require a planar or upward planar graph. Most of these algorithms are theoretically interesting, but not practically usable."))),BC(t,new ax(AC(DE(IE(new $b,H0),"Radial"),"Radial layout algorithms usually position the nodes of the graph on concentric circles."))),dZe((new dF,t)),RZe((new qX,t)),tZe((new pF,t))};var yCe,dct,xCe,_M,pct,gct,ECe,mct,nae,vL,SCe,bct,eD,MCe,TCe,CCe,ACe,PCe,wct,Ey,LCe,vct,hj,iae,rae,l3,kCe,dj,RCe,_ct,ICe,pj,DCe,yM,BCe,tD,OCe,gj,NCe,sae,Sy,FCe,yct,UCe,xct,zCe,GCe,oae,aae,cae,lae,jCe,Yc,nD,$Ce,Ect,iD,uae,VCe,_L,WCe,u3,mj,fae,Sct,hae,HCe,Mct,qCe,Tct,dae,XCe,bj,YCe,My,ZCe,KCe,JCe,cAn=k(Af,"CoreOptions",785);A(110,23,{3:1,34:1,23:1,110:1},VR);var ip,nf,rf,Bh,hm,yL=Mi(Af,uye,110,Di,B4t,mCt),Cct;A(226,23,{3:1,34:1,23:1,226:1},I8);var xL,f3,EL,wj,QCe=Mi(Af,"EdgeLabelPlacement",226,Di,a4t,bCt),Act;A(197,23,{3:1,34:1,23:1,197:1},D8);var xM,pae,cb,gae,mae=Mi(Af,"EdgeRouting",197,Di,c4t,wCt),Pct;A(289,23,{3:1,34:1,23:1,289:1},WC);var eAe,tAe,nAe,iAe,bae,rAe,sAe=Mi(Af,"EdgeType",289,Di,vkt,vCt),Lct;A(853,1,dd,dF),p.ue=function(t){dZe(t)};var oAe,aAe,cAe,kct,lAe,SL,lAn=k(Af,"FixedLayouterOptions",853);A(854,1,{},dN),p.Be=function(){var t;return t=new vg,t},p.Ce=function(t){};var uAn=k(Af,"FixedLayouterOptions/FixedFactory",854);A(316,23,{3:1,34:1,23:1,316:1},qK);var h3,vj,ML,uAe=Mi(Af,"HierarchyHandling",316,Di,PLt,dCt),Rct;A(86,23,{3:1,34:1,23:1,86:1},Qv);var Oh,Su,Mu,Tu,Pl,Cu,sf,of,kf,Zs=Mi(Af,"NodeLabelPlacement",86,Di,lRt,pCt),Ict;A(225,23,{3:1,34:1,23:1,225:1},WR);var fAe,TL,lb,hAe,wae,CL=Mi(Af,"PortAlignment",225,Di,I4t,gCt),Dct;A(83,23,{3:1,34:1,23:1,83:1},HC);var d3,Ba,wd,p3,rp,ub,dAe=Mi(Af,"PortConstraints",83,Di,mkt,hCt),Bct;A(275,23,{3:1,34:1,23:1,275:1},XK);var _j,fb,Ty,pAe=Mi(Af,"PortLabelPlacement",275,Di,TLt,uCt),Oct;A(69,23,{3:1,34:1,23:1,69:1},HR);var Zt,bn,rD,Cy,Nh,hb,gAe,sD,Ay,vd,vae,_d,T1,yd,g3,oD,Py,aD,ei,Oa,tn,xc=Mi(Af,"PortSide",69,Di,M4t,fCt),Nct;A(857,1,dd,pF),p.ue=function(t){tZe(t)};var Fct,Uct,mAe,zct,Gct,fAn=k(Af,"RandomLayouterOptions",857);A(858,1,{},Gq),p.Be=function(){var t;return t=new fE,t},p.Ce=function(t){};var hAn=k(Af,"RandomLayouterOptions/RandomFactory",858);A(344,23,{3:1,34:1,23:1,344:1},B8);var db,cD,lD,C1,AL=Mi(Af,"SizeConstraint",344,Di,l4t,_Ct),jct;A(239,23,{3:1,34:1,23:1,239:1},e_);var yj,xj,EM,_ae,PL,LL,Ej,m3,Sj,bAe=Mi(Af,"SizeOptions",239,Di,uRt,yCt),$ct;A(313,1,{},g9,Eme,xme),p.b=!1,p.c=0,p.d=-1,p.e=0,p.f=!1,p.j=0;var dAn=k(Cf,"BasicProgressMonitor",313);A(848,244,K_,jq),p.Ae=function(t,i){var a,l,f,g,m,v,y,E,C,R;switch(ni(i,"Box layout",2),g=ce(Xe(nn(t,(l7(),hct)))),m=h(nn(t,fct),119),a=ce(bt(nn(t,bCe))),l=ce(bt(nn(t,wCe))),f=h(nn(t,eae),288),f.g){case 0:v=(y=new h9((!t.a&&(t.a=new ze(Br,t,10,11)),t.a)),yt(),Ug(y,new mZ(l)),y),E=h(nn(t,tae),9),E.a=w.Math.max(E.a-m.b-m.c,0),E.b=w.Math.max(E.b-m.d-m.a,0),C=Xe(nn(t,mCe)),(C==null||(pn(C),C<=0))&&(C=1.3),R=kjt(v,g,m,E.a,E.b,a,(pn(C),C)),H_(t,R.a,R.b,!1,!0);break;default:jzt(t,g,m,a)}Bn(i)};var pAn=k(Cf,"BoxLayoutProvider",848);A(849,1,Or,mZ),p.Ld=function(t,i){return X8t(this,h(t,35),h(i,35))},p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.a=!1;var gAn=k(Cf,"BoxLayoutProvider/1",849);A(145,1,{145:1},xU,YFe),p.Ib=function(){return this.c?s_e(this.c):$p(this.b)};var mAn=k(Cf,"BoxLayoutProvider/Group",145);A(288,23,{3:1,34:1,23:1,288:1},O8);var wAe,vAe,_Ae,yae,yAe=Mi(Cf,"BoxLayoutProvider/PackingMode",288,Di,f4t,xCt),Vct;A(850,1,Or,Nq),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return-no(XR(h(t,145)),XR(h(i,145)))};var bAn=k(Cf,"BoxLayoutProvider/lambda$0$Type",850);A(851,1,Or,Fq),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return no(XR(h(t,145)),XR(h(i,145)))};var wAn=k(Cf,"BoxLayoutProvider/lambda$1$Type",851);A(852,1,Or,Uq),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return no(XR(h(t,145)),XR(h(i,145)))};var vAn=k(Cf,"BoxLayoutProvider/lambda$2$Type",852);A(833,1,{},XOe),p.td=function(t){AFt(this.a,this.b,t)},p.a=0,p.b=0;var _An=k(Cf,"ElkUtil/lambda$0$Type",833);A(834,1,{},YOe),p.td=function(t){Q3t(this.a,this.b,t)},p.a=0,p.b=0;var yAn=k(Cf,"ElkUtil/lambda$1$Type",834);A(835,1,{},ZOe),p.td=function(t){CSt(this.a,this.b,t)},p.a=0,p.b=0;var xAn=k(Cf,"ElkUtil/lambda$2$Type",835);A(322,1,{34:1,322:1},TE),p.vd=function(t){return DSt(this,h(t,210))},p.Fb=function(t){var i;return re(t,322)?(i=h(t,322),this.a==i.a):!1},p.Hb=function(){return wr(this.a)},p.Ib=function(){return this.a+" (exclusive)"},p.a=0;var EAn=k(Cf,"ExclusiveBounds/ExclusiveLowerBound",322);A(963,244,K_,vg),p.Ae=function(t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ae,Ue,qe,ut,ft,Ct;for(ni(i,Tet,1),g=h(nn(t,(lr(),TCe)),197),B=0,N=0,we=new Dn((!t.a&&(t.a=new ze(Br,t,10,11)),t.a));we.e!=we.i._b();){for(ie=h(Xn(we),35),Ct=h(nn(ie,(CU(),SL)),9),Ct&&(Bd(ie,Ct.a,Ct.b),h(nn(ie,aAe),185).pc((Wl(),db))&&(W=h(nn(ie,cAe),9),W.a>0&&W.b>0&&H_(ie,W.a,W.b,!0,!0))),B=w.Math.max(B,ie.i+ie.g),N=w.Math.max(N,ie.j+ie.f),C=new Dn((!ie.n&&(ie.n=new ze(Qo,ie,1,7)),ie.n));C.e!=C.i._b();)y=h(Xn(C),137),Ct=h(nn(y,SL),9),Ct&&Bd(y,Ct.a,Ct.b),B=w.Math.max(B,ie.i+y.i+y.g),N=w.Math.max(N,ie.j+y.j+y.f);for(qe=new Dn((!ie.c&&(ie.c=new ze(Au,ie,9,9)),ie.c));qe.e!=qe.i._b();)for(Ue=h(Xn(qe),121),Ct=h(nn(Ue,SL),9),Ct&&Bd(Ue,Ct.a,Ct.b),ut=ie.i+Ue.i,ft=ie.j+Ue.j,B=w.Math.max(B,ut+Ue.g),N=w.Math.max(N,ft+Ue.f),E=new Dn((!Ue.n&&(Ue.n=new ze(Qo,Ue,1,7)),Ue.n));E.e!=E.i._b();)y=h(Xn(E),137),Ct=h(nn(y,SL),9),Ct&&Bd(y,Ct.a,Ct.b),B=w.Math.max(B,ut+y.i+y.g),N=w.Math.max(N,ft+y.j+y.f);for(f=Tn(Mh(ie));Gn(f);)a=h(Mn(f),105),R=oJe(a),B=w.Math.max(B,R.a),N=w.Math.max(N,R.b);for(l=Tn(S6(ie));Gn(l);)a=h(Mn(l),105),Ra(h(ae((!a.b&&(a.b=new an(gi,a,4,7)),a.b),0),97))!=t&&(R=oJe(a),B=w.Math.max(B,R.a),N=w.Math.max(N,R.b))}if(g==(cd(),xM))for(fe=new Dn((!t.a&&(t.a=new ze(Br,t,10,11)),t.a));fe.e!=fe.i._b();)for(ie=h(Xn(fe),35),l=Tn(Mh(ie));Gn(l);)a=h(Mn(l),105),v=(m=new Uc,m),v.b==0?oc(a,l3,null):oc(a,l3,v);Ae=h(nn(t,(CU(),kct)),119),ee=B+Ae.b+Ae.c,V=N+Ae.d+Ae.a,H_(t,ee,V,!0,!0),Bn(i)};var SAn=k(Cf,"FixedLayoutProvider",963);A(786,131,Eie,Bk);var _Vt=k(Cf,"IndividualSpacings",786);A(635,1,{},T9e),p.c=0;var MAn=k(Cf,"InstancePool",635);A(48,1,{20:1,48:1},Is),p.sc=function(t){mo(this,t)},p.Fb=function(t){var i,a,l;return re(t,48)?(a=h(t,48),i=this.a==null?a.a==null:Li(this.a,a.a),l=this.b==null?a.b==null:Li(this.b,a.b),i&&l):!1},p.Hb=function(){var t,i,a,l,f,g;return a=this.a==null?0:Wr(this.a),t=a&Gr,i=a&-65536,g=this.b==null?0:Wr(this.b),l=g&Gr,f=g&-65536,t^f>>16&Gr|i^l<<16},p.tc=function(){return new bZ(this)},p.Ib=function(){return this.a==null&&this.b==null?"pair(null,null)":this.a==null?"pair(null,"+za(this.b)+")":this.b==null?"pair("+za(this.a)+",null)":"pair("+za(this.a)+","+za(this.b)+")"};var TAn=k(Cf,"Pair",48);A(859,1,ys,bZ),p.gc=function(t){Ss(this,t)},p.hc=function(){return!this.c&&(!this.b&&this.a.a!=null||this.a.b!=null)},p.ic=function(){if(!this.c&&!this.b&&this.a.a!=null)return this.b=!0,this.a.a;if(!this.c&&this.a.b!=null)return this.c=!0,this.a.b;throw Y(new K)},p.jc=function(){throw this.c&&this.a.b!=null?this.a.b=null:this.b&&this.a.a!=null&&(this.a.a=null),Y(new Ha)},p.b=!1,p.c=!1;var CAn=k(Cf,"Pair/1",859);A(404,1,{404:1},EUe),p.Fb=function(t){return el(this.a,h(t,404).a)&&el(this.c,h(t,404).c)&&el(this.d,h(t,404).d)&&el(this.b,h(t,404).b)},p.Hb=function(){return Aee(X(q(sn,1),nt,1,5,[this.a,this.c,this.d,this.b]))},p.Ib=function(){return"("+this.a+Ta+this.c+Ta+this.d+Ta+this.b+")"};var AAn=k(Cf,"Quadruple",404);A(957,244,K_,fE),p.Ae=function(t,i){var a,l,f,g,m;if(ni(i,"Random Layout",1),(!t.a&&(t.a=new ze(Br,t,10,11)),t.a).i==0){Bn(i);return}g=h(nn(t,(twe(),zct)),21),g&&g.a!=0?f=new J9(g.a):f=new Jee,a=ce(Xe(nn(t,Fct))),m=ce(Xe(nn(t,Gct))),l=h(nn(t,Uct),119),bjt(t,f,a,m,l),Bn(i)};var PAn=k(Cf,"RandomLayoutProvider",957);A(490,1,{}),p.Qe=function(){return new $t(this.f.i,this.f.j)},p.xe=function(t){return zUe(t,(lr(),Yc))?nn(this.f,Wct):nn(this.f,t)},p.Re=function(){return new $t(this.f.g,this.f.f)},p.Se=function(){return this.g},p.ye=function(t){return UQ(this.f,t)},p.Te=function(t){Xu(this.f,t.a),Yu(this.f,t.b)},p.Ue=function(t){x_(this.f,t.a),y_(this.f,t.b)},p.Ve=function(t){this.g=t},p.g=0;var Wct,LAn=k(r5,"ElkGraphAdapters/AbstractElkGraphElementAdapter",490);A(491,1,{741:1},mC),p.We=function(){var t,i;if(!this.b)for(this.b=Y9(uQ(this.a).i),i=new Dn(uQ(this.a));i.e!=i.i._b();)t=h(Xn(i),137),De(this.b,new pK(t));return this.b},p.b=null;var kAn=k(r5,"ElkGraphAdapters/ElkEdgeAdapter",491);A(562,490,{},dK),p.Xe=function(){return OHe(this)},p.a=null;var RAn=k(r5,"ElkGraphAdapters/ElkGraphAdapter",562);A(564,490,{271:1},pK);var IAn=k(r5,"ElkGraphAdapters/ElkLabelAdapter",564);A(563,490,{739:1},gJ),p.We=function(){return ADt(this)},p.$e=function(){var t;return t=h(nn(this.f,(lr(),dj)),135),!t&&(t=new z2),t},p.af=function(){return PDt(this)},p.cf=function(t){var i;i=new RJ(t),oc(this.f,(lr(),dj),i)},p.df=function(t){oc(this.f,(lr(),Sy),new Tme(t))},p.Ye=function(){return this.d},p.Ze=function(){var t,i;if(!this.a)for(this.a=new Re,i=Tn(S6(h(this.f,35)));Gn(i);)t=h(Mn(i),105),De(this.a,new mC(t));return this.a},p._e=function(){var t,i;if(!this.c)for(this.c=new Re,i=Tn(Mh(h(this.f,35)));Gn(i);)t=h(Mn(i),105),De(this.c,new mC(t));return this.c},p.bf=function(){return N1e(h(this.f,35)).i!=0||ce(bt(h(this.f,35).xe((lr(),hj))))},p.a=null,p.b=null,p.c=null,p.d=null,p.e=null;var DAn=k(r5,"ElkGraphAdapters/ElkNodeAdapter",563);A(997,490,{740:1},qF),p.We=function(){return NDt(this)},p.Ze=function(){var t,i;if(!this.a)for(this.a=Qh(h(this.f,121).Tf().i),i=new Dn(h(this.f,121).Tf());i.e!=i.i._b();)t=h(Xn(i),105),De(this.a,new mC(t));return this.a},p._e=function(){var t,i;if(!this.c)for(this.c=Qh(h(this.f,121).Uf().i),i=new Dn(h(this.f,121).Uf());i.e!=i.i._b();)t=h(Xn(i),105),De(this.c,new mC(t));return this.c},p.ef=function(){return h(h(this.f,121).xe((lr(),_L)),69)},p.ff=function(){var t,i,a,l,f,g,m,v;for(l=Eh(h(this.f,121)),a=new Dn(h(this.f,121).Uf());a.e!=a.i._b();)for(t=h(Xn(a),105),v=new Dn((!t.c&&(t.c=new an(gi,t,5,8)),t.c));v.e!=v.i._b();){if(m=h(Xn(v),97),SA(Ra(m),l))return!0;if(Ra(m)==l&&ce(bt(nn(t,(lr(),iae)))))return!0}for(i=new Dn(h(this.f,121).Tf());i.e!=i.i._b();)for(t=h(Xn(i),105),g=new Dn((!t.b&&(t.b=new an(gi,t,4,7)),t.b));g.e!=g.i._b();)if(f=h(Xn(g),97),SA(Ra(f),l))return!0;return!1},p.a=null,p.b=null,p.c=null;var BAn=k(r5,"ElkGraphAdapters/ElkPortAdapter",997);A(265,23,{3:1,34:1,23:1,265:1},N8);var xd,dm,uD,fD,Hct=Mi(uxe,"LabelSide",265,Di,h4t,ECt),qct;A(676,1,{},hE),p.td=function(t){UKe(h(t,739),!0,!1)};var OAn=k(uxe,"NodeLabelAndSizeCalculator/lambda$0$Type",676);A(571,1,{},ER),p.b=!0,p.c=!0,p.d=!0,p.e=!0;var NAn=k(uxe,MQe,571);A(171,1,{171:1}),p.j=!1,p.k=!1;var Xct=k(m1,"Cell",171);A(114,171,{114:1,171:1},w8e),p.Pf=function(){return v9(this)},p.Qf=function(){var t;return t=this.n,this.a.a+t.b+t.c};var FAn=k(m1,"AtomicCell",114);A(203,23,{3:1,34:1,23:1,203:1},YK);var oa,Va,aa,Zw=Mi(m1,"ContainerArea",203,Di,ALt,SCt),Yct;A(307,171,Aet);var UAn=k(m1,"ContainerCell",307);A(1179,307,Aet,RWe),p.Pf=function(){var t;return t=0,this.e?this.b?t=this.b.b:this.a[1][1]&&(t=this.a[1][1].Pf()):t=jbe(this,NHe(this,!0)),t>0?t+this.n.d+this.n.a:0},p.Qf=function(){var t,i,a,l,f;if(f=0,this.e)this.b?f=this.b.a:this.a[1][1]&&(f=this.a[1][1].Qf());else if(this.g)f=jbe(this,Cte(this,null,!0));else for(i=(yf(),X(q(Zw,1),Oe,203,0,[oa,Va,aa])),a=0,l=i.length;a0?f+this.n.b+this.n.c:0},p.Rf=function(){var t,i,a,l,f;if(this.g)for(t=Cte(this,null,!1),a=(yf(),X(q(Zw,1),Oe,203,0,[oa,Va,aa])),l=0,f=a.length;l0&&(l[0]+=this.d,a-=l[0]),l[2]>0&&(l[2]+=this.d,a-=l[2]),this.c.a=w.Math.max(0,a),this.c.d=i.d+t.d+(this.c.a-a)/2,l[1]=w.Math.max(l[1],a),w0e(this,Va,i.d+t.d+l[0]-(l[1]-a)/2,l)},p.b=null,p.d=0,p.e=!1,p.f=!1,p.g=!1;var xae=0,Mj=0,zAn=k(m1,"GridContainerCell",1179);A(419,23,{3:1,34:1,23:1,419:1},ZK);var pb,Fh,af,Zct=Mi(m1,"HorizontalLabelAlignment",419,Di,SLt,MCt),Kct;A(267,171,{171:1,267:1},s7e,Dje,e7e),p.Pf=function(){return zJ(this)},p.Qf=function(){return w9(this)},p.a=0,p.c=!1;var yVt=k(m1,"LabelCell",267);A(219,307,{171:1,307:1,219:1},HA),p.Pf=function(){return _6(this)},p.Qf=function(){return y6(this)},p.Rf=function(){gne(this)},p.Sf=function(){mne(this)},p.b=0,p.c=0,p.d=!1;var GAn=k(m1,"StripContainerCell",219);A(1394,1,ss,Vq),p.Nb=function(t){return!!h(t,171)&&h(t,171).k};var jAn=k(m1,"StripContainerCell/lambda$0$Type",1394);A(1395,1,{},Im),p.oe=function(t){return h(t,171).Qf()};var $An=k(m1,"StripContainerCell/lambda$1$Type",1395);A(1396,1,ss,Ok),p.Nb=function(t){return!!h(t,171)&&h(t,171).j};var VAn=k(m1,"StripContainerCell/lambda$2$Type",1396);A(1397,1,{},Fv),p.oe=function(t){return h(t,171).Pf()};var WAn=k(m1,"StripContainerCell/lambda$3$Type",1397);A(420,23,{3:1,34:1,23:1,420:1},KK);var cf,gb,Rf,Jct=Mi(m1,"VerticalLabelAlignment",420,Di,MLt,TCt),Qct;A(697,1,{},L_e),p.c=0,p.d=0,p.k=0,p.s=0,p.u=0,p.B=!1;var HAn=k(mz,"NodeContext",697);A(1177,1,Or,pN),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return TNe(h(t,69),h(i,69))};var qAn=k(mz,"NodeContext/0methodref$comparePortSides$Type",1177);A(1178,1,Or,$q),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return bOt(h(t,111),h(i,111))};var XAn=k(mz,"NodeContext/1methodref$comparePortContexts$Type",1178);A(147,23,{3:1,34:1,23:1,147:1},$l);var elt,tlt,nlt,ilt,rlt,slt,olt,alt,clt,llt,ult,flt,hlt,dlt,plt,glt,mlt,blt,wlt,vlt,_lt,Eae,ylt=Mi(mz,"NodeLabelLocation",147,Di,cte,CCt),xlt;A(111,1,{111:1},Jze);var YAn=k(mz,"PortContext",111);A(1182,1,{},_p),p.oe=function(t){return h(t,111).c?w9(h(t,111).c):0};var ZAn=k(KS,"HorizontalPortPlacementSizeCalculator/lambda$0$Type",1182);A(1184,1,{},Wq),p.td=function(t){DBe(h(t,267))};var KAn=k(KS,"LabelPlacer/lambda$0$Type",1184);A(1185,1,ss,gN),p.Nb=function(t){return!!h(t,111).c};var JAn=k(KS,"LabelPlacer/lambda$1$Type",1185);A(1186,1,{},mN),p.td=function(t){DBe(h(t,111).c)};var QAn=k(KS,"LabelPlacer/lambda$2$Type",1186),xAe;A(1181,1,{},dE),p.td=function(t){Gm(),Kde(h(t,111))};var ePn=k(KS,"NodeLabelAndSizeUtilities/lambda$0$Type",1181);A(698,1,{},hge),p.td=function(t){tEt(this.a,this.b,t)},p.b=!1;var tPn=k(KS,"NodeLabelCellCreator/lambda$0$Type",698);A(1180,1,{},vZ),p.td=function(t){je(this.a,t)};var nPn=k(KS,"PortContextCreator/lambda$0$Type",1180),Tj;A(1183,1,{},Vb),p.oe=function(t){return h(t,111).c?zJ(h(t,111).c):0};var iPn=k(KS,"VerticalPortPlacementSizeCalculator/lambda$0$Type",1183);A(1525,1,{},bN);var rPn=k(JS,"GreedyRectangleStripOverlapRemover",1525);A(1526,1,Or,Hq),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return JSt(h(t,194),h(i,194))};var sPn=k(JS,"GreedyRectangleStripOverlapRemover/0methodref$compareByYCoordinate$Type",1526);A(1497,1,{},UDe),p.a=5,p.e=0;var oPn=k(JS,"RectangleStripOverlapRemover",1497);A(1498,1,Or,XT),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return QSt(h(t,194),h(i,194))};var aPn=k(JS,"RectangleStripOverlapRemover/0methodref$compareLeftRectangleBorders$Type",1498);A(1500,1,Or,qq),p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)},p.Ld=function(t,i){return SAt(h(t,194),h(i,194))};var cPn=k(JS,"RectangleStripOverlapRemover/1methodref$compareRightRectangleBorders$Type",1500);A(374,23,{3:1,34:1,23:1,374:1},F8);var hD,Sae,Mae,dD,Elt=Mi(JS,"RectangleStripOverlapRemover/OverlapRemovalDirection",374,Di,u4t,ACt),Slt;A(194,1,{194:1},jJ);var lPn=k(JS,"RectangleStripOverlapRemover/RectangleNode",194);A(1499,1,{},XF),p.td=function(t){SDt(this.a,h(t,194))};var uPn=k(JS,"RectangleStripOverlapRemover/lambda$0$Type",1499),Kw=br(ql,"EObject"),SM=br(iy,Pet),sh=br(iy,Let),pD=br(iy,ket),gD=br(iy,"ElkShape"),gi=br(iy,Ret),js=br(iy,hxe),es=br(iy,Iet),mD=br(ql,Det),kL=br(ql,"EFactory"),Mlt,Tae=br(ql,Bet),oh=br(ql,"EPackage"),hs,Tlt,Clt,EAe,Cj,Alt,SAe,MAe,TAe,sp,Plt,Llt,Qo=br(iy,dxe),Br=br(iy,pxe),Au=br(iy,gxe);A(87,1,Oet),p.cg=function(){return this.dg(),null},p.dg=function(){return null},p.eg=function(){return this.dg(),!1},p.fg=function(){return!1},p.gg=function(t){Pi(this,t)};var fPn=k(Wx,"BasicNotifierImpl",87);A(92,87,Fet),p.Hg=function(){return ju(this)},p.hg=function(t,i){return t},p.ig=function(){throw Y(new Ai)},p.jg=function(t){var i;return i=Fo(h(Vt(this.mg(),this.og()),17)),this.yg().Cg(this,i.n,i.f,t)},p.kg=function(t,i){throw Y(new Ai)},p.lg=function(t,i,a){return Sl(this,t,i,a)},p.mg=function(){var t;return this.ig()&&(t=this.ig().pj(),t)?t:this.Rg()},p.ng=function(){return Xte(this)},p.og=function(){throw Y(new Ai)},p.pg=function(){var t,i;return i=this.Jg().qj(),!i&&this.ig().vj(i=(LC(),t=z1e(Jg(this.mg())),t==null?Dae:new eI(this,t))),i},p.qg=function(t,i){return t},p.rg=function(t){var i;return i=t.Vi(),i?t.pi():gr(this.mg(),t)},p.sg=function(){var t;return t=this.ig(),t?t.sj():null},p.tg=function(){return this.ig()?this.ig().pj():null},p.ug=function(t,i,a){return t7(this,t,i,a)},p.vg=function(t){return AI(this,t)},p.wg=function(t,i){return m0e(this,t,i)},p.xg=function(){var t;return t=this.ig(),!!t&&t.tj()},p.yg=function(){throw Y(new Ai)},p.zg=function(){return ZU(this)},p.Ag=function(t,i,a,l){return _x(this,t,i,l)},p.Bg=function(t,i,a){var l;return l=h(Vt(this.mg(),i),61),l.aj().dj(this,this.Qg(),i-this.Sg(),t,a)},p.Cg=function(t,i,a,l){return j9(this,t,i,l)},p.Dg=function(t,i,a){var l;return l=h(Vt(this.mg(),i),61),l.aj().ej(this,this.Qg(),i-this.Sg(),t,a)},p.Eg=function(){return!!this.ig()&&(this.ig().rj(),!1)},p.Fg=function(t){return fte(this,t)},p.Gg=function(t){var i;return i=this.rg(t),i>=0?this.Fg(i):Vte(this,t)},p.Ig=function(t){return wKe(this,t)},p.Jg=function(){throw Y(new Ai)},p.Kg=function(){return this.ig()?this.ig().rj():null},p.Lg=function(){return ZU(this)},p.Mg=function(t,i){b7(this,t,i)},p.Ng=function(t){this.Jg().uj(t)},p.Og=function(t){this.Jg().wj(t)},p.Pg=function(t,i){var a,l,f,g;return g=this.sg(),g&&t&&(i=Us(g.fk(),this,i),g.jk(this)),l=this.yg(),l&&(ane(this,this.yg(),this.og()).Bb&oo?(f=l.zg(),f&&(t?!g&&f.jk(this):f.ik(this))):(i=(a=this.og(),a>=0?this.jg(i):this.yg().Cg(this,-1-a,null,i)),i=this.lg(null,-1,i))),this.Og(t),i},p.Qg=function(){return B0e(this)},p.Rg=function(){return(kg(),At).S},p.Sg=function(){return jn(this.Rg())},p.Ib=function(){return Zu(this)};var hPn=k(kt,"BasicEObjectImpl",92),klt;A(107,92,{95:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1}),p.Tg=function(t){var i;return i=D0e(this),i[t]},p.Ug=function(t,i){var a;a=D0e(this),zr(a,t,i)},p.Vg=function(t){var i;i=D0e(this),zr(i,t,null)},p.cg=function(){return h(rn(this,4),116)},p.dg=function(){throw Y(new Ai)},p.eg=function(){return(this.Db&4)!=0},p.ig=function(){throw Y(new Ai)},p.Wg=function(t){VA(this,2,t)},p.kg=function(t,i){this.Db=i<<16|this.Db&255,this.Wg(t)},p.mg=function(){return rc(this)},p.og=function(){return this.Db>>16},p.pg=function(){var t,i;return LC(),i=z1e(Jg((t=h(rn(this,16),24),t||this.Rg()))),i==null?Dae:new eI(this,i)},p.fg=function(){return(this.Db&1)==0},p.sg=function(){return h(rn(this,128),1628)},p.tg=function(){return h(rn(this,16),24)},p.xg=function(){return(this.Db&32)!=0},p.yg=function(){return h(rn(this,2),42)},p.Eg=function(){return(this.Db&64)!=0},p.Jg=function(){throw Y(new Ai)},p.Kg=function(){return h(rn(this,64),261)},p.Ng=function(t){VA(this,16,t)},p.Og=function(t){VA(this,128,t)},p.Qg=function(){return Xa(this)},p.Db=0;var dPn=k(kt,"MinimalEObjectImpl",107);A(108,107,{95:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1}),p.Wg=function(t){this.Cb=t},p.yg=function(){return this.Cb};var pPn=k(kt,"MinimalEObjectImpl/Container",108);A(1676,108,{95:1,379:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1}),p.ve=function(t){return!this.o&&(this.o=new nl((Ma(),sp),pm,this,0)),l$e(this.o,t.p?t.p:(yt(),yt(),Qd)),this},p.ug=function(t,i,a){return Mwe(this,t,i,a)},p.Dg=function(t,i,a){return sve(this,t,i,a)},p.Fg=function(t){return q1e(this,t)},p.Mg=function(t,i){xbe(this,t,i)},p.Rg=function(){return Ma(),Llt},p.we=function(){return cHe(this)},p.xe=function(t){return nn(this,t)},p.ye=function(t){return UQ(this,t)},p.ze=function(t,i){return oc(this,t,i)};var gPn=k(b1,"EMapPropertyHolderImpl",1676);A(502,108,{95:1,531:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1},pE),p.ug=function(t,i,a){switch(t){case 0:return this.a;case 1:return this.b}return t7(this,t,i,a)},p.Fg=function(t){switch(t){case 0:return this.a!=0;case 1:return this.b!=0}return fte(this,t)},p.Mg=function(t,i){switch(t){case 0:see(this,ce(Xe(i)));return;case 1:oee(this,ce(Xe(i)));return}b7(this,t,i)},p.Rg=function(){return Ma(),Tlt},p.Ib=function(){var t;return this.Db&64?Zu(this):(t=new ru(Zu(this)),t.a+=" (x: ",Xv(t,this.a),t.a+=", y: ",Xv(t,this.b),t.a+=")",t.a)},p.a=0,p.b=0;var mPn=k(b1,"ElkBendPointImpl",502);A(651,1676,{95:1,379:1,253:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1}),p.ug=function(t,i,a){return Nbe(this,t,i,a)},p.Bg=function(t,i,a){return Dte(this,t,i,a)},p.Dg=function(t,i,a){return Mee(this,t,i,a)},p.Fg=function(t){return fbe(this,t)},p.Mg=function(t,i){jwe(this,t,i)},p.Rg=function(){return Ma(),Alt},p.Vf=function(){return uQ(this)},p.Ib=function(){return Xee(this)},p.k=null;var bPn=k(b1,"ElkGraphElementImpl",651);A(652,651,{95:1,379:1,253:1,429:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1}),p.ug=function(t,i,a){return Hbe(this,t,i,a)},p.Fg=function(t){return Kbe(this,t)},p.Mg=function(t,i){$we(this,t,i)},p.Rg=function(){return Ma(),Plt},p.Wf=function(){return this.f},p.Xf=function(){return this.g},p.Yf=function(){return this.i},p.Zf=function(){return this.j},p.$f=function(t,i){W8(this,t,i)},p._f=function(t,i){Bd(this,t,i)},p.ag=function(t){Xu(this,t)},p.bg=function(t){Yu(this,t)},p.Ib=function(){return Ote(this)},p.f=0,p.g=0,p.i=0,p.j=0;var wPn=k(b1,"ElkShapeImpl",652);A(653,652,{95:1,379:1,97:1,253:1,429:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1}),p.ug=function(t,i,a){return bwe(this,t,i,a)},p.Bg=function(t,i,a){return Nwe(this,t,i,a)},p.Dg=function(t,i,a){return Fwe(this,t,i,a)},p.Fg=function(t){return _be(this,t)},p.Mg=function(t,i){Ive(this,t,i)},p.Rg=function(){return Ma(),Clt},p.Tf=function(){return!this.d&&(this.d=new an(js,this,8,5)),this.d},p.Uf=function(){return!this.e&&(this.e=new an(js,this,7,4)),this.e};var vPn=k(b1,"ElkConnectableShapeImpl",653);A(183,651,{95:1,379:1,105:1,253:1,183:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1},YT),p.jg=function(t){return kwe(this,t)},p.ug=function(t,i,a){switch(t){case 3:return V9(this);case 4:return!this.b&&(this.b=new an(gi,this,4,7)),this.b;case 5:return!this.c&&(this.c=new an(gi,this,5,8)),this.c;case 6:return!this.a&&(this.a=new ze(es,this,6,6)),this.a;case 7:return vt(),!this.b&&(this.b=new an(gi,this,4,7)),!(this.b.i<=1&&(!this.c&&(this.c=new an(gi,this,5,8)),this.c.i<=1));case 8:return vt(),!!rP(this);case 9:return vt(),!!U0(this);case 10:return vt(),!this.b&&(this.b=new an(gi,this,4,7)),this.b.i!=0&&(!this.c&&(this.c=new an(gi,this,5,8)),this.c.i!=0)}return Nbe(this,t,i,a)},p.Bg=function(t,i,a){var l;switch(i){case 3:return this.Cb&&(a=(l=this.Db>>16,l>=0?kwe(this,a):this.Cb.Cg(this,-1-l,null,a))),nme(this,h(t,35),a);case 4:return!this.b&&(this.b=new an(gi,this,4,7)),Ga(this.b,t,a);case 5:return!this.c&&(this.c=new an(gi,this,5,8)),Ga(this.c,t,a);case 6:return!this.a&&(this.a=new ze(es,this,6,6)),Ga(this.a,t,a)}return Dte(this,t,i,a)},p.Dg=function(t,i,a){switch(i){case 3:return nme(this,null,a);case 4:return!this.b&&(this.b=new an(gi,this,4,7)),Us(this.b,t,a);case 5:return!this.c&&(this.c=new an(gi,this,5,8)),Us(this.c,t,a);case 6:return!this.a&&(this.a=new ze(es,this,6,6)),Us(this.a,t,a)}return Mee(this,t,i,a)},p.Fg=function(t){switch(t){case 3:return!!V9(this);case 4:return!!this.b&&this.b.i!=0;case 5:return!!this.c&&this.c.i!=0;case 6:return!!this.a&&this.a.i!=0;case 7:return!this.b&&(this.b=new an(gi,this,4,7)),!(this.b.i<=1&&(!this.c&&(this.c=new an(gi,this,5,8)),this.c.i<=1));case 8:return rP(this);case 9:return U0(this);case 10:return!this.b&&(this.b=new an(gi,this,4,7)),this.b.i!=0&&(!this.c&&(this.c=new an(gi,this,5,8)),this.c.i!=0)}return fbe(this,t)},p.Mg=function(t,i){switch(t){case 3:SYe(this,h(i,35));return;case 4:!this.b&&(this.b=new an(gi,this,4,7)),Pr(this.b),!this.b&&(this.b=new an(gi,this,4,7)),Mr(this.b,h(i,13));return;case 5:!this.c&&(this.c=new an(gi,this,5,8)),Pr(this.c),!this.c&&(this.c=new an(gi,this,5,8)),Mr(this.c,h(i,13));return;case 6:!this.a&&(this.a=new ze(es,this,6,6)),Pr(this.a),!this.a&&(this.a=new ze(es,this,6,6)),Mr(this.a,h(i,13));return}jwe(this,t,i)},p.Rg=function(){return Ma(),EAe},p.Ib=function(){return uKe(this)};var _Pn=k(b1,"ElkEdgeImpl",183);A(405,1676,{95:1,379:1,270:1,405:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1},gE),p.jg=function(t){return Awe(this,t)},p.ug=function(t,i,a){switch(t){case 1:return this.j;case 2:return this.k;case 3:return this.b;case 4:return this.c;case 5:return!this.a&&(this.a=new vs(sh,this,5)),this.a;case 6:return g7e(this);case 7:return i?mte(this):this.i;case 8:return i?gte(this):this.f;case 9:return!this.g&&(this.g=new an(es,this,9,10)),this.g;case 10:return!this.e&&(this.e=new an(es,this,10,9)),this.e;case 11:return this.d}return Mwe(this,t,i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 6:return this.Cb&&(a=(f=this.Db>>16,f>=0?Awe(this,a):this.Cb.Cg(this,-1-f,null,a))),ime(this,h(t,105),a);case 9:return!this.g&&(this.g=new an(es,this,9,10)),Ga(this.g,t,a);case 10:return!this.e&&(this.e=new an(es,this,10,9)),Ga(this.e,t,a)}return g=h(Vt((l=h(rn(this,16),24),l||(Ma(),Cj)),i),61),g.aj().dj(this,Xa(this),i-jn((Ma(),Cj)),t,a)},p.Dg=function(t,i,a){switch(i){case 5:return!this.a&&(this.a=new vs(sh,this,5)),Us(this.a,t,a);case 6:return ime(this,null,a);case 9:return!this.g&&(this.g=new an(es,this,9,10)),Us(this.g,t,a);case 10:return!this.e&&(this.e=new an(es,this,10,9)),Us(this.e,t,a)}return sve(this,t,i,a)},p.Fg=function(t){switch(t){case 1:return this.j!=0;case 2:return this.k!=0;case 3:return this.b!=0;case 4:return this.c!=0;case 5:return!!this.a&&this.a.i!=0;case 6:return!!g7e(this);case 7:return!!this.i;case 8:return!!this.f;case 9:return!!this.g&&this.g.i!=0;case 10:return!!this.e&&this.e.i!=0;case 11:return this.d!=null}return q1e(this,t)},p.Mg=function(t,i){switch(t){case 1:AA(this,ce(Xe(i)));return;case 2:PA(this,ce(Xe(i)));return;case 3:CA(this,ce(Xe(i)));return;case 4:TA(this,ce(Xe(i)));return;case 5:!this.a&&(this.a=new vs(sh,this,5)),Pr(this.a),!this.a&&(this.a=new vs(sh,this,5)),Mr(this.a,h(i,13));return;case 6:t9t(this,h(i,105));return;case 7:ebe(this,h(i,97));return;case 8:Q0e(this,h(i,97));return;case 9:!this.g&&(this.g=new an(es,this,9,10)),Pr(this.g),!this.g&&(this.g=new an(es,this,9,10)),Mr(this.g,h(i,13));return;case 10:!this.e&&(this.e=new an(es,this,10,9)),Pr(this.e),!this.e&&(this.e=new an(es,this,10,9)),Mr(this.e,h(i,13));return;case 11:u$e(this,Qn(i));return}xbe(this,t,i)},p.Rg=function(){return Ma(),Cj},p.Ib=function(){return kXe(this)},p.b=0,p.c=0,p.d=null,p.j=0,p.k=0;var yPn=k(b1,"ElkEdgeSectionImpl",405);A(142,108,{95:1,91:1,87:1,139:1,51:1,103:1,42:1,92:1,142:1,107:1,108:1}),p.ug=function(t,i,a){var l;return t==0?(!this.Ab&&(this.Ab=new ze(ki,this,0,3)),this.Ab):Gl(this,t-jn(this.Rg()),Vt((l=h(rn(this,16),24),l||this.Rg()),t),i,a)},p.Bg=function(t,i,a){var l,f;return i==0?(!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Ga(this.Ab,t,a)):(f=h(Vt((l=h(rn(this,16),24),l||this.Rg()),i),61),f.aj().dj(this,Xa(this),i-jn(this.Rg()),t,a))},p.Dg=function(t,i,a){var l,f;return i==0?(!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Us(this.Ab,t,a)):(f=h(Vt((l=h(rn(this,16),24),l||this.Rg()),i),61),f.aj().ej(this,Xa(this),i-jn(this.Rg()),t,a))},p.Fg=function(t){var i;return t==0?!!this.Ab&&this.Ab.i!=0:Ul(this,t-jn(this.Rg()),Vt((i=h(rn(this,16),24),i||this.Rg()),t))},p.Ig=function(t){return D_e(this,t)},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Mr(this.Ab,h(i,13));return}Vl(this,t-jn(this.Rg()),Vt((a=h(rn(this,16),24),a||this.Rg()),t),i)},p.Og=function(t){VA(this,128,t)},p.Rg=function(){return Et(),Ylt},p.Xg=function(){this.Bb|=1},p.Yg=function(t){return uP(this,t)},p.Bb=0;var xPn=k(kt,"EModelElementImpl",142);A(638,142,{95:1,91:1,87:1,430:1,139:1,51:1,103:1,42:1,92:1,142:1,107:1,108:1},hF),p.Zg=function(t,i){return OKe(this,t,i)},p.$g=function(t){var i,a,l,f,g;if(this.a!=jl(t)||t.Bb&256)throw Y(new un(bre+t.zb+q0));for(l=Do(t);xa(l.a).i!=0;){if(a=h(B6(l,0,(i=h(ae(xa(l.a),0),84),g=i.c,re(g,96)?h(g,24):(Et(),uf))),24),O0(a))return f=jl(a).dh().$g(a),h(f,42).Ng(t),f;l=Do(a)}return(t.D!=null?t.D:t.B)=="java.util.Map$Entry"?new w9e(t):new Fme(t)},p._g=function(t,i){return G0(this,t,i)},p.ug=function(t,i,a){var l;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),this.Ab;case 1:return this.a}return Gl(this,t-jn((Et(),wb)),Vt((l=h(rn(this,16),24),l||wb),t),i,a)},p.Bg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Ga(this.Ab,t,a);case 1:return this.a&&(a=h(this.a,42).Cg(this,4,oh,a)),Rbe(this,h(t,207),a)}return f=h(Vt((l=h(rn(this,16),24),l||(Et(),wb)),i),61),f.aj().dj(this,Xa(this),i-jn((Et(),wb)),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Us(this.Ab,t,a);case 1:return Rbe(this,null,a)}return f=h(Vt((l=h(rn(this,16),24),l||(Et(),wb)),i),61),f.aj().ej(this,Xa(this),i-jn((Et(),wb)),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return!!this.a}return Ul(this,t-jn((Et(),wb)),Vt((i=h(rn(this,16),24),i||wb),t))},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:XOt(this,h(i,207));return}Vl(this,t-jn((Et(),wb)),Vt((a=h(rn(this,16),24),a||wb),t),i)},p.Rg=function(){return Et(),wb};var RL,CAe,Rlt,EPn=k(kt,"EFactoryImpl",638);A(914,638,{95:1,1698:1,91:1,87:1,430:1,139:1,51:1,103:1,42:1,92:1,142:1,107:1,108:1},Dm),p.Zg=function(t,i){switch(t.Ni()){case 12:return h(i,166).Lf();case 13:return za(i);default:throw Y(new un(QS+t.be()+q0))}},p.$g=function(t){var i,a,l,f,g,m,v,y;switch(t.G==-1&&(t.G=(i=jl(t),i?jp(i.bh(),t):-1)),t.G){case 4:return g=new ZT,g;case 6:return m=new cpe,m;case 7:return v=new lpe,v;case 8:return l=new YT,l;case 9:return a=new pE,a;case 10:return f=new gE,f;case 11:return y=new Nk,y;default:throw Y(new un(bre+t.zb+q0))}},p._g=function(t,i){switch(t.Ni()){case 13:case 12:return null;default:throw Y(new un(QS+t.be()+q0))}};var SPn=k(b1,"ElkGraphFactoryImpl",914);A(399,142,{95:1,91:1,87:1,139:1,174:1,51:1,103:1,42:1,92:1,142:1,107:1,108:1}),p.pg=function(){var t,i;return i=(t=h(rn(this,16),24),z1e(Jg(t||this.Rg()))),i==null?(LC(),LC(),Dae):new jFe(this,i)},p.ug=function(t,i,a){var l;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),this.Ab;case 1:return this.be()}return Gl(this,t-jn(this.Rg()),Vt((l=h(rn(this,16),24),l||this.Rg()),t),i,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null}return Ul(this,t-jn(this.Rg()),Vt((i=h(rn(this,16),24),i||this.Rg()),t))},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:this.ah(Qn(i));return}Vl(this,t-jn(this.Rg()),Vt((a=h(rn(this,16),24),a||this.Rg()),t),i)},p.Rg=function(){return Et(),Zlt},p.be=function(){return this.zb},p.ah=function(t){Ef(this,t)},p.Ib=function(){return FA(this)},p.zb=null;var MPn=k(kt,"ENamedElementImpl",399);A(248,399,{95:1,91:1,87:1,139:1,174:1,51:1,207:1,103:1,42:1,92:1,142:1,248:1,107:1,108:1,613:1},UUe),p.jg=function(t){return VHe(this,t)},p.ug=function(t,i,a){var l;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),this.Ab;case 1:return this.zb;case 2:return this.yb;case 3:return this.xb;case 4:return this.sb;case 5:return!this.rb&&(this.rb=new u_(this,ah,this)),this.rb;case 6:return!this.vb&&(this.vb=new YE(oh,this,6,7)),this.vb;case 7:return i?this.Db>>16==7?h(this.Cb,207):null:m7e(this)}return Gl(this,t-jn((Et(),k1)),Vt((l=h(rn(this,16),24),l||k1),t),i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Ga(this.Ab,t,a);case 4:return this.sb&&(a=h(this.sb,42).Cg(this,1,kL,a)),Dbe(this,h(t,430),a);case 5:return!this.rb&&(this.rb=new u_(this,ah,this)),Ga(this.rb,t,a);case 6:return!this.vb&&(this.vb=new YE(oh,this,6,7)),Ga(this.vb,t,a);case 7:return this.Cb&&(a=(f=this.Db>>16,f>=0?VHe(this,a):this.Cb.Cg(this,-1-f,null,a))),Sl(this,t,7,a)}return g=h(Vt((l=h(rn(this,16),24),l||(Et(),k1)),i),61),g.aj().dj(this,Xa(this),i-jn((Et(),k1)),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Us(this.Ab,t,a);case 4:return Dbe(this,null,a);case 5:return!this.rb&&(this.rb=new u_(this,ah,this)),Us(this.rb,t,a);case 6:return!this.vb&&(this.vb=new YE(oh,this,6,7)),Us(this.vb,t,a);case 7:return Sl(this,null,7,a)}return f=h(Vt((l=h(rn(this,16),24),l||(Et(),k1)),i),61),f.aj().ej(this,Xa(this),i-jn((Et(),k1)),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.yb!=null;case 3:return this.xb!=null;case 4:return!!this.sb;case 5:return!!this.rb&&this.rb.i!=0;case 6:return!!this.vb&&this.vb.i!=0;case 7:return!!m7e(this)}return Ul(this,t-jn((Et(),k1)),Vt((i=h(rn(this,16),24),i||k1),t))},p.Ig=function(t){var i;return i=u9t(this,t),i||D_e(this,t)},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:Ef(this,Qn(i));return;case 2:gee(this,Qn(i));return;case 3:pee(this,Qn(i));return;case 4:ove(this,h(i,430));return;case 5:!this.rb&&(this.rb=new u_(this,ah,this)),Pr(this.rb),!this.rb&&(this.rb=new u_(this,ah,this)),Mr(this.rb,h(i,13));return;case 6:!this.vb&&(this.vb=new YE(oh,this,6,7)),Pr(this.vb),!this.vb&&(this.vb=new YE(oh,this,6,7)),Mr(this.vb,h(i,13));return}Vl(this,t-jn((Et(),k1)),Vt((a=h(rn(this,16),24),a||k1),t),i)},p.Rg=function(){return Et(),k1},p.Xg=function(){Tte(this)},p.bh=function(){return!this.rb&&(this.rb=new u_(this,ah,this)),this.rb},p.dh=function(){return this.sb},p.eh=function(){return this.ub},p.fh=function(){return this.xb},p.gh=function(){return this.yb},p.hh=function(t){this.ub=t},p.Ib=function(){var t;return this.Db&64?FA(this):(t=new ru(FA(this)),t.a+=" (nsURI: ",ho(t,this.yb),t.a+=", nsPrefix: ",ho(t,this.xb),t.a+=")",t.a)},p.xb=null,p.yb=null;var Ilt,TPn=k(kt,"EPackageImpl",248);A(506,248,{95:1,1702:1,506:1,91:1,87:1,139:1,174:1,51:1,207:1,103:1,42:1,92:1,142:1,248:1,107:1,108:1,613:1},HXe),p.q=!1,p.r=!1;var Dlt=!1,CPn=k(b1,"ElkGraphPackageImpl",506);A(263,652,{95:1,379:1,253:1,137:1,429:1,263:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1},ZT),p.jg=function(t){return Pwe(this,t)},p.ug=function(t,i,a){switch(t){case 7:return b7e(this);case 8:return this.a}return Hbe(this,t,i,a)},p.Bg=function(t,i,a){var l;switch(i){case 7:return this.Cb&&(a=(l=this.Db>>16,l>=0?Pwe(this,a):this.Cb.Cg(this,-1-l,null,a))),Qme(this,h(t,253),a)}return Dte(this,t,i,a)},p.Dg=function(t,i,a){return i==7?Qme(this,null,a):Mee(this,t,i,a)},p.Fg=function(t){switch(t){case 7:return!!b7e(this);case 8:return!pt("",this.a)}return Kbe(this,t)},p.Mg=function(t,i){switch(t){case 7:kYe(this,h(i,253));return;case 8:i$e(this,Qn(i));return}$we(this,t,i)},p.Rg=function(){return Ma(),SAe},p.Ib=function(){return Oqe(this)},p.a="";var APn=k(b1,"ElkLabelImpl",263);A(246,653,{95:1,379:1,97:1,253:1,35:1,429:1,246:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1},cpe),p.jg=function(t){return Dwe(this,t)},p.ug=function(t,i,a){switch(t){case 9:return!this.c&&(this.c=new ze(Au,this,9,9)),this.c;case 10:return!this.a&&(this.a=new ze(Br,this,10,11)),this.a;case 11:return to(this);case 12:return!this.b&&(this.b=new ze(js,this,12,3)),this.b;case 13:return vt(),!this.a&&(this.a=new ze(Br,this,10,11)),this.a.i>0}return bwe(this,t,i,a)},p.Bg=function(t,i,a){var l;switch(i){case 9:return!this.c&&(this.c=new ze(Au,this,9,9)),Ga(this.c,t,a);case 10:return!this.a&&(this.a=new ze(Br,this,10,11)),Ga(this.a,t,a);case 11:return this.Cb&&(a=(l=this.Db>>16,l>=0?Dwe(this,a):this.Cb.Cg(this,-1-l,null,a))),hme(this,h(t,35),a);case 12:return!this.b&&(this.b=new ze(js,this,12,3)),Ga(this.b,t,a)}return Nwe(this,t,i,a)},p.Dg=function(t,i,a){switch(i){case 9:return!this.c&&(this.c=new ze(Au,this,9,9)),Us(this.c,t,a);case 10:return!this.a&&(this.a=new ze(Br,this,10,11)),Us(this.a,t,a);case 11:return hme(this,null,a);case 12:return!this.b&&(this.b=new ze(js,this,12,3)),Us(this.b,t,a)}return Fwe(this,t,i,a)},p.Fg=function(t){switch(t){case 9:return!!this.c&&this.c.i!=0;case 10:return!!this.a&&this.a.i!=0;case 11:return!!to(this);case 12:return!!this.b&&this.b.i!=0;case 13:return!this.a&&(this.a=new ze(Br,this,10,11)),this.a.i>0}return _be(this,t)},p.Mg=function(t,i){switch(t){case 9:!this.c&&(this.c=new ze(Au,this,9,9)),Pr(this.c),!this.c&&(this.c=new ze(Au,this,9,9)),Mr(this.c,h(i,13));return;case 10:!this.a&&(this.a=new ze(Br,this,10,11)),Pr(this.a),!this.a&&(this.a=new ze(Br,this,10,11)),Mr(this.a,h(i,13));return;case 11:TYe(this,h(i,35));return;case 12:!this.b&&(this.b=new ze(js,this,12,3)),Pr(this.b),!this.b&&(this.b=new ze(js,this,12,3)),Mr(this.b,h(i,13));return}Ive(this,t,i)},p.Rg=function(){return Ma(),MAe},p.Ib=function(){return s_e(this)};var PPn=k(b1,"ElkNodeImpl",246);A(187,653,{95:1,379:1,97:1,253:1,121:1,429:1,187:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1},lpe),p.jg=function(t){return Lwe(this,t)},p.ug=function(t,i,a){return t==9?Eh(this):bwe(this,t,i,a)},p.Bg=function(t,i,a){var l;switch(i){case 9:return this.Cb&&(a=(l=this.Db>>16,l>=0?Lwe(this,a):this.Cb.Cg(this,-1-l,null,a))),rme(this,h(t,35),a)}return Nwe(this,t,i,a)},p.Dg=function(t,i,a){return i==9?rme(this,null,a):Fwe(this,t,i,a)},p.Fg=function(t){return t==9?!!Eh(this):_be(this,t)},p.Mg=function(t,i){switch(t){case 9:MYe(this,h(i,35));return}Ive(this,t,i)},p.Rg=function(){return Ma(),TAe},p.Ib=function(){return vZe(this)};var LPn=k(b1,"ElkPortImpl",187),Blt=br(Gs,"BasicEMap/Entry");A(966,108,{95:1,38:1,91:1,87:1,134:1,51:1,103:1,42:1,92:1,107:1,108:1},Nk),p.Fb=function(t){return this===t},p.kc=function(){return this.b},p.Hb=function(){return p0(this)},p.kh=function(t){n$e(this,h(t,166))},p.ug=function(t,i,a){switch(t){case 0:return this.b;case 1:return this.c}return t7(this,t,i,a)},p.Fg=function(t){switch(t){case 0:return!!this.b;case 1:return this.c!=null}return fte(this,t)},p.Mg=function(t,i){switch(t){case 0:n$e(this,h(i,166));return;case 1:t$e(this,i);return}b7(this,t,i)},p.Rg=function(){return Ma(),sp},p.ih=function(){var t;return this.a==-1&&(t=this.b,this.a=t?Wr(t):0),this.a},p.lc=function(){return this.c},p.jh=function(t){this.a=t},p.mc=function(t){var i;return i=this.c,t$e(this,t),i},p.Ib=function(){var t;return this.Db&64?Zu(this):(t=new u0,Si(Si(Si(t,this.b?this.b.Lf():qc)," -> "),YC(this.c)),t.a)},p.a=-1,p.c=null;var pm=k(b1,"ElkPropertyToValueMapEntryImpl",966);A(876,1,{},Xq);var kPn=k(Ps,"JsonAdapter",876);A(186,54,Yd,vh);var RPn=k(Ps,"JsonImportException",186);A(754,1,{},iqe);var IPn=k(Ps,"JsonImporter",754);A(792,1,{},tNe);var DPn=k(Ps,"JsonImporter/lambda$0$Type",792);A(793,1,{},nNe);var BPn=k(Ps,"JsonImporter/lambda$1$Type",793);A(816,1,{},YF);var OPn=k(Ps,"JsonImporter/lambda$10$Type",816);A(818,1,{},_Z);var NPn=k(Ps,"JsonImporter/lambda$11$Type",818);A(819,1,{},iNe),p.td=function(t){y4t(this.b,this.a,t)};var FPn=k(Ps,"JsonImporter/lambda$12$Type",819);A(820,1,{},rNe);var UPn=k(Ps,"JsonImporter/lambda$13$Type",820);A(821,1,{},sNe);var zPn=k(Ps,"JsonImporter/lambda$14$Type",821);A(822,1,{},yZ);var GPn=k(Ps,"JsonImporter/lambda$15$Type",822);A(823,1,{},xZ);var jPn=k(Ps,"JsonImporter/lambda$16$Type",823);A(824,1,{},EZ);var $Pn=k(Ps,"JsonImporter/lambda$17$Type",824);A(825,1,{},B2);var VPn=k(Ps,"JsonImporter/lambda$18$Type",825);A(756,1,{},SZ);var WPn=k(Ps,"JsonImporter/lambda$19$Type",756);A(794,1,{},MZ);var HPn=k(Ps,"JsonImporter/lambda$2$Type",794);A(829,1,{},q8e);var qPn=k(Ps,"JsonImporter/lambda$20$Type",829);A(830,1,{},TZ),p.td=function(t){x4t(this.a,t)};var XPn=k(Ps,"JsonImporter/lambda$21$Type",830);A(795,1,{},CZ);var YPn=k(Ps,"JsonImporter/lambda$22$Type",795);A(796,1,{},AZ);var ZPn=k(Ps,"JsonImporter/lambda$23$Type",796);A(798,1,{},ZF);var KPn=k(Ps,"JsonImporter/lambda$24$Type",798);A(799,1,{},KF);var JPn=k(Ps,"JsonImporter/lambda$25$Type",799);A(801,1,{},PZ);var QPn=k(Ps,"JsonImporter/lambda$26$Type",801);A(809,1,{},CUe);var eLn=k(Ps,"JsonImporter/lambda$27$Type",809);A(811,1,{},LZ);var tLn=k(Ps,"JsonImporter/lambda$28$Type",811);A(812,1,{},kZ);var nLn=k(Ps,"JsonImporter/lambda$29$Type",812);A(797,1,{},RZ);var iLn=k(Ps,"JsonImporter/lambda$3$Type",797);A(814,1,{},IZ);var rLn=k(Ps,"JsonImporter/lambda$30$Type",814);A(815,1,{},DZ);var sLn=k(Ps,"JsonImporter/lambda$31$Type",815);A(817,1,{},BZ);var oLn=k(Ps,"JsonImporter/lambda$32$Type",817);A(826,1,{},OZ),p.td=function(t){E4t(this.a,t)};var aLn=k(Ps,"JsonImporter/lambda$33$Type",826);A(827,1,{},oNe),p.td=function(t){QEt(this.a,this.b,t)};var cLn=k(Ps,"JsonImporter/lambda$34$Type",827);A(828,1,{},aNe),p.td=function(t){eSt(this.a,this.b,t)};var lLn=k(Ps,"JsonImporter/lambda$35$Type",828);A(805,1,{},cNe);var uLn=k(Ps,"JsonImporter/lambda$36$Type",805);A(806,1,{},lNe);var fLn=k(Ps,"JsonImporter/lambda$37$Type",806);A(807,1,{},hNe);var hLn=k(Ps,"JsonImporter/lambda$38$Type",807);A(808,1,{},dNe);var dLn=k(Ps,"JsonImporter/lambda$39$Type",808);A(800,1,{},NZ);var pLn=k(Ps,"JsonImporter/lambda$4$Type",800);A(802,1,{},FZ);var gLn=k(Ps,"JsonImporter/lambda$5$Type",802);A(803,1,{},uNe);var mLn=k(Ps,"JsonImporter/lambda$6$Type",803);A(804,1,{},fNe);var bLn=k(Ps,"JsonImporter/lambda$7$Type",804);A(810,1,{},AUe);var wLn=k(Ps,"JsonImporter/lambda$8$Type",810);A(813,1,{},UZ);var vLn=k(Ps,"JsonImporter/lambda$9$Type",813);A(864,1,{},zZ),p.td=function(t){sx(this.a,new ix(Qn(t)))};var _Ln=k(Ps,"JsonMetaDataConverter/lambda$0$Type",864);A(865,1,{},GZ),p.td=function(t){HAt(this.a,t)};var yLn=k(Ps,"JsonMetaDataConverter/lambda$1$Type",865);A(866,1,{},jZ),p.td=function(t){iLt(this.a,t)};var xLn=k(Ps,"JsonMetaDataConverter/lambda$2$Type",866);A(867,1,{},$Z),p.td=function(t){WAt(this.a,t)};var ELn=k(Ps,"JsonMetaDataConverter/lambda$3$Type",867);A(229,23,{3:1,34:1,23:1,229:1},J2);var Aj,Pj,Cae,Lj,kj,Rj,Aae,Pae,Ij=Mi(q6,"GraphFeature",229,Di,nRt,PCt),Olt;A(16,1,{34:1,166:1},Sr,Yr,ln,ba),p.vd=function(t){return ISt(this,h(t,166))},p.Fb=function(t){return zUe(this,t)},p.Of=function(){return Ht(this)},p.Lf=function(){return this.b},p.Hb=function(){return Hg(this.b)},p.Ib=function(){return this.b};var SLn=k(q6,"Property",16);A(727,1,Or,JF),p.Ld=function(t,i){return l6t(this,h(t,93),h(i,93))},p.Fb=function(t){return this===t},p.Md=function(){return new dr(this)};var MLn=k(q6,"PropertyHolderComparator",727),AAe=br(Gs,"EList");A(59,41,{20:1,25:1,41:1,13:1,15:1,59:1,52:1}),p.bd=function(t,i){JI(this,t,i)},p.nc=function(t){return $n(this,t)},p.oc=function(t){return Mr(this,t)},p.oh=function(){return new tx(this)},p.ph=function(){return new QR(this)},p.qh=function(t){return GI(this,t)},p.rh=function(){return!0},p.sh=function(t,i){},p.th=function(){},p.uh=function(t,i){GQ(this,t,i)},p.vh=function(t,i){},p.wh=function(t,i,a){},p.Fb=function(t){return iZe(this,t)},p.Hb=function(){return pbe(this)},p.xh=function(){return!1},p.tc=function(){return new Dn(this)},p.ed=function(){return new QC(this)},p.fd=function(t){var i;if(i=this._b(),t<0||t>i)throw Y(new o_(t,i));return new KJ(this,t)},p.vc=function(t){return JQ(this,t)},p.zh=function(t,i){return i},p.hd=function(t,i){return yx(this,t,i)},p.Ib=function(){return Xbe(this)},p.Bh=function(){return!0},p.Ch=function(t,i){return DA(this,i)};var TLn=k(Gs,"AbstractEList",59);A(55,59,Rh,n0,w_,cbe),p.lh=function(t){return kHe(this,t)},p.mh=function(t,i){e6(this,t,i)},p.nh=function(t){MI(this,t)},p.Dh=function(t){return P0e(this,t)},p.Pb=function(){_A(this)},p.pc=function(t){return QA(this,t)},p.cd=function(t){return ae(this,t)},p.Eh=function(t){eHe(this,t)},p.dd=function(t){return $He(this,t)},p.Wb=function(){return this.i==0},p.Fh=function(t){return le(sn,nt,1,t,5,1)},p.yh=function(t){return this.g[t]},p.gd=function(t){return xx(this,t)},p.Ah=function(t,i){return KQ(this,t,i)},p._b=function(){return this.i},p.yc=function(){return K1e(this)},p.zc=function(t){return ewe(this,t)},p.i=0;var PAe=k(Gs,"BasicEList",55),LAe=br(Gs,"TreeIterator");A(629,55,Tre),p.gc=function(t){Ss(this,t)},p.hc=function(){return this.g==null&&!this.c?P1e(this):this.g==null||this.i!=0&&h(this.g[this.i-1],43).hc()},p.ic=function(){return _7(this)},p.jc=function(){if(!this.e)throw Y(new ma("There is no valid object to remove."));this.e.jc()},p.c=!1;var CLn=k(Gs,"AbstractTreeIterator",629);A(621,629,Tre,_ge),p.Gh=function(t){var i;return i=h(t,51).pg().tc(),re(i,260)&&h(i,260).Zj(new wN),i};var ALn=k(Cre,"ElkGraphUtil/PropertiesSkippingTreeIterator",621);A(868,1,{},wN);var PLn=k(Cre,"ElkGraphUtil/PropertiesSkippingTreeIterator/1",868),bD,Lae,wD=k(Cre,"ElkReflect",null);A(784,1,ny,KT),p.Nf=function(t){return tU(),skt(h(t,185))};var LLn=k(Cre,"ElkReflect/lambda$0$Type",784),Jw,kLn=br(Gs,"ResourceLocator");A(953,1,{});var RLn=k(Gs,"DelegatingResourceLocator",953);A(954,953,{});var ILn=k("org.eclipse.emf.common","EMFPlugin",954),kae=br(btt,"Adapter"),xVt=br(btt,"Notification");A(1016,1,Bxe),p.Hh=function(){return this.d},p.Ih=function(t){},p.Jh=function(t){this.d=t},p.Kh=function(t){this.d==t&&(this.d=null)},p.d=null;var DLn=k(Wx,"AdapterImpl",1016);A(1688,59,wtt),p.lh=function(t){var i,a,l;if(++this.j,t.Wb())return!1;for(i=this.hi(),l=t.tc();l.hc();)a=l.ic(),this.Wh(this.Ch(i,a)),++i;return!0},p.mh=function(t,i){t8e(this,t,i)},p.nh=function(t){iUe(this,t)},p.Uh=function(){return this.Xh()},p.Pb=function(){rI(this,this.hi(),this.ii())},p.pc=function(t){return this.Zh(t)},p.qc=function(t){return this.$h(t)},p.Vh=function(t,i){this.ei().tl()},p.Wh=function(t){this.ei().tl()},p.Xh=function(){return this.ei()},p.Yh=function(){this.ei().tl()},p.Zh=function(t){return this.ei().tl()},p.$h=function(t){return this.ei().tl()},p._h=function(t){return this.ei().tl()},p.ai=function(t){return this.ei().tl()},p.bi=function(){return this.ei().tl()},p.ci=function(t){return this.ei().tl()},p.di=function(){return this.ei().tl()},p.fi=function(t){return this.ei().tl()},p.gi=function(t,i){return this.ei().tl()},p.hi=function(){return this.ei().tl()},p.ii=function(){return this.ei().tl()},p.ji=function(t){return this.ei().tl()},p.ki=function(){return this.ei().tl()},p.Fb=function(t){return this._h(t)},p.cd=function(t){return this.zh(t,this.ai(t))},p.Hb=function(){return this.bi()},p.dd=function(t){return this.ci(t)},p.Wb=function(){return this.di()},p.yh=function(t){return this.ai(t)},p.gd=function(t){return x9(this,t)},p.vc=function(t){var i;return i=this.dd(t),i>=0?(this.gd(i),!0):!1},p.Ah=function(t,i){return this.gi(t,this.Ch(t,i))},p._b=function(){return this.hi()},p.yc=function(){return this.ii()},p.zc=function(t){return this.ji(t)},p.Ib=function(){return this.ki()};var BLn=k(Gs,"DelegatingEList",1688);A(1689,1688,wtt),p.li=function(t,i){return m_e(this,t,i)},p.lh=function(t){return this.li(this.hi(),t)},p.mh=function(t,i){qXe(this,t,i)},p.nh=function(t){UXe(this,t)},p.rh=function(){return!this.qi()},p.Pb=function(){O7(this)},p.mi=function(t,i,a,l,f){return new YUe(this,t,i,a,l,f)},p.ni=function(t){Pi(this.Oh(),t)},p.oi=function(){return null},p.pi=function(){return-1},p.Oh=function(){return null},p.qi=function(){return!1},p.ri=function(t,i){return i},p.si=function(t,i){return i},p.ti=function(){return!1},p.ui=function(){return!this.di()},p.gd=function(t){var i,a,l,f;return this.ti()?(l=this.ui(),i=this.mi(4,f=x9(this,t),null,t,l),this.qi()&&f?(a=this.si(f,null),a?(a.Sh(i),a.Th()):this.ni(i)):this.ni(i),f):(f=x9(this,t),this.qi()&&f&&(a=this.si(f,null),a&&a.Th()),f)},p.Ah=function(t,i){return UZe(this,t,i)};var OLn=k(Wx,"DelegatingNotifyingListImpl",1689);A(136,1,o5),p.Sh=function(t){return Hwe(this,t)},p.Th=function(){XQ(this)},p.Lh=function(){return this.d},p.oi=function(){return null},p.vi=function(){return null},p.Mh=function(t){return-1},p.Nh=function(){return BYe(this)},p.Oh=function(){return null},p.Ph=function(){return Wve(this)},p.Qh=function(){return this.o<0?this.o<-2?-2-this.o-1:-1:this.o},p.wi=function(){return!1},p.Rh=function(t){var i,a,l,f,g,m,v,y,E,C,R;switch(this.d){case 1:case 2:switch(f=t.Lh(),f){case 1:case 2:if(g=t.Oh(),Be(g)===Be(this.Oh())&&this.Mh(null)==t.Mh(null))return this.g=t.Nh(),t.Lh()==1&&(this.d=1),!0}case 4:{switch(f=t.Lh(),f){case 4:{if(g=t.Oh(),Be(g)===Be(this.Oh())&&this.Mh(null)==t.Mh(null))return E=P_e(this),y=this.o<0?this.o<-2?-2-this.o-1:-1:this.o,m=t.Qh(),this.d=6,R=new w_(2),y<=m?($n(R,this.n),$n(R,t.Ph()),this.g=X(q(Rn,1),ii,22,15,[this.o=y,m+1])):($n(R,t.Ph()),$n(R,this.n),this.g=X(q(Rn,1),ii,22,15,[this.o=m,y])),this.n=R,E||(this.o=-2-this.o-1),!0;break}}break}case 6:{switch(f=t.Lh(),f){case 4:{if(g=t.Oh(),Be(g)===Be(this.Oh())&&this.Mh(null)==t.Mh(null)){for(E=P_e(this),m=t.Qh(),C=h(this.g,37),l=le(Rn,ii,22,C.length+1,15,1),i=0;i>>0).toString(16)),a.a+=" (eventType: ",this.d){case 1:{a.a+="SET";break}case 2:{a.a+="UNSET";break}case 3:{a.a+="ADD";break}case 5:{a.a+="ADD_MANY";break}case 4:{a.a+="REMOVE";break}case 6:{a.a+="REMOVE_MANY";break}case 7:{a.a+="MOVE";break}case 8:{a.a+="REMOVING_ADAPTER";break}case 9:{a.a+="RESOLVE";break}default:{wK(a,this.d);break}}if(MZe(this)&&(a.a+=", touch: true"),a.a+=", position: ",wK(a,this.o<0?this.o<-2?-2-this.o-1:-1:this.o),a.a+=", notifier: ",OC(a,this.Oh()),a.a+=", feature: ",OC(a,this.oi()),a.a+=", oldValue: ",OC(a,Wve(this)),a.a+=", newValue: ",this.d==6&&re(this.g,37)){for(i=h(this.g,37),a.a+="[",t=0;t10?((!this.b||this.c.j!=this.a)&&(this.b=new hI(this),this.a=this.j),IC(this.b,t)):QA(this,t)},p.Bh=function(){return!0},p.a=0;var $Ln=k(Gs,"AbstractEList/1",869);A(295,79,lie,o_);var VLn=k(Gs,"AbstractEList/BasicIndexOutOfBoundsException",295);A(36,1,ys,Dn),p.gc=function(t){Ss(this,t)},p.Bi=function(){if(this.i.j!=this.f)throw Y(new P)},p.Ci=function(){return Xn(this)},p.hc=function(){return this.e!=this.i._b()},p.ic=function(){return this.Ci()},p.jc=function(){KA(this)},p.e=0,p.f=0,p.g=-1;var WLn=k(Gs,"AbstractEList/EIterator",36);A(296,36,Th,QC,KJ),p.jc=function(){KA(this)},p.Bc=function(t){MWe(this,t)},p.Di=function(){var t;try{return t=this.d.cd(--this.e),this.Bi(),this.g=this.e,t}catch(i){throw i=hr(i),re(i,79)?(this.Bi(),Y(new K)):Y(i)}},p.Ei=function(t){xHe(this,t)},p.Cc=function(){return this.e!=0},p.Dc=function(){return this.e},p.Ec=function(){return this.Di()},p.Fc=function(){return this.e-1},p.Gc=function(t){this.Ei(t)};var HLn=k(Gs,"AbstractEList/EListIterator",296);A(324,36,ys,tx),p.Ci=function(){return ate(this)},p.jc=function(){throw Y(new Ai)};var qLn=k(Gs,"AbstractEList/NonResolvingEIterator",324);A(355,296,Th,QR,Sme),p.Bc=function(t){throw Y(new Ai)},p.Ci=function(){var t;try{return t=this.c.yh(this.e),this.Bi(),this.g=this.e++,t}catch(i){throw i=hr(i),re(i,79)?(this.Bi(),Y(new K)):Y(i)}},p.Di=function(){var t;try{return t=this.c.yh(--this.e),this.Bi(),this.g=this.e,t}catch(i){throw i=hr(i),re(i,79)?(this.Bi(),Y(new K)):Y(i)}},p.jc=function(){throw Y(new Ai)},p.Gc=function(t){throw Y(new Ai)};var XLn=k(Gs,"AbstractEList/NonResolvingEListIterator",355);A(1673,59,vtt),p.lh=function(t){var i,a,l,f,g,m,v,y,E;if(l=t._b(),l!=0){for(y=(a=h(rn(this.a,4),116),a==null?0:a.length),E=y+l,i=Tbe(this,E),v=t.tc(),g=y;ga)throw Y(new o_(t,a));return new gUe(this,t)},p.Pb=function(){var t,i;++this.j,t=h(rn(this.a,4),116),i=t==null?0:t.length,l6(this,null),GQ(this,i,t)},p.pc=function(t){var i,a,l,f;if(i=h(rn(this.a,4),116),i!=null){if(t!=null){for(l=0,f=i.length;l=a)throw Y(new o_(t,a));return i[t]},p.dd=function(t){var i,a,l;if(i=h(rn(this.a,4),116),i!=null){if(t!=null){for(a=0,l=i.length;aa)throw Y(new o_(t,a));return new pUe(this,t)},p.yh=function(t){return h(rn(this.a,4),116)[t]},p.gd=function(t){return LFt(this,t)},p.Ah=function(t,i){var a,l;return a=g5t(this),l=a[t],Tge(a,t,DA(this,i)),l6(this,a),l},p._b=function(){var t;return t=h(rn(this.a,4),116),t==null?0:t.length},p.yc=function(){var t,i,a;return t=h(rn(this.a,4),116),a=t==null?0:t.length,i=le(kae,kre,380,a,0,1),a>0&&wc(t,0,i,0,a),i},p.zc=function(t){var i,a,l;return i=h(rn(this.a,4),116),l=i==null?0:i.length,l>0&&(t.lengthl&&zr(t,l,null),t};var Nlt,YLn=k(Gs,"ArrayDelegatingEList",1673);A(927,36,ys,Zze),p.Bi=function(){if(this.b.j!=this.f||Be(h(rn(this.b.a,4),116))!==Be(this.a))throw Y(new P)},p.jc=function(){KA(this),this.a=h(rn(this.b.a,4),116)};var ZLn=k(Gs,"ArrayDelegatingEList/EIterator",927);A(640,296,Th,z9e,pUe),p.Bi=function(){if(this.b.j!=this.f||Be(h(rn(this.b.a,4),116))!==Be(this.a))throw Y(new P)},p.Ei=function(t){xHe(this,t),this.a=h(rn(this.b.a,4),116)},p.jc=function(){KA(this),this.a=h(rn(this.b.a,4),116)};var KLn=k(Gs,"ArrayDelegatingEList/EListIterator",640);A(928,324,ys,Kze),p.Bi=function(){if(this.b.j!=this.f||Be(h(rn(this.b.a,4),116))!==Be(this.a))throw Y(new P)};var JLn=k(Gs,"ArrayDelegatingEList/NonResolvingEIterator",928);A(641,355,Th,G9e,gUe),p.Bi=function(){if(this.b.j!=this.f||Be(h(rn(this.b.a,4),116))!==Be(this.a))throw Y(new P)};var QLn=k(Gs,"ArrayDelegatingEList/NonResolvingEListIterator",641);A(549,295,lie,JK);var e4n=k(Gs,"BasicEList/BasicIndexOutOfBoundsException",549);A(630,55,Rh,dge),p.bd=function(t,i){throw Y(new Ai)},p.nc=function(t){throw Y(new Ai)},p.oc=function(t){throw Y(new Ai)},p.Pb=function(){throw Y(new Ai)},p.Eh=function(t){throw Y(new Ai)},p.tc=function(){return this.oh()},p.ed=function(){return this.ph()},p.fd=function(t){return this.qh(t)},p.gd=function(t){throw Y(new Ai)},p.vc=function(t){throw Y(new Ai)},p.hd=function(t,i){throw Y(new Ai)};var t4n=k(Gs,"BasicEList/UnmodifiableEList",630);A(639,1,{3:1,20:1,13:1,15:1,52:1,533:1}),p.bd=function(t,i){NSt(this,t,h(i,38))},p.nc=function(t){return bMt(this,h(t,38))},p.sc=function(t){mo(this,t)},p.cd=function(t){return h(ae(this.c,t),134)},p.uc=function(){return this.xc()},p.gd=function(t){return h(this.c.gd(t),38)},p.hd=function(t,i){return UAt(this,t,h(i,38))},p.jd=function(t){Ug(this,t)},p.wc=function(){return new pi(this,16)},p.xc=function(){return new si(null,this.wc())},p.oc=function(t){return this.c.oc(t)},p.Pb=function(){this.c.Pb()},p.pc=function(t){return this.c.pc(t)},p.qc=function(t){return Gg(this.c,t)},p.Fi=function(){var t,i,a;if(this.d==null){for(this.d=le(PAe,Oxe,55,2*this.f+1,0,1),a=this.e,this.f=0,i=this.c.tc();i.e!=i.i._b();)t=h(i.Ci(),134),n7(this,t);this.e=a}},p.Fb=function(t){return N8e(this,t)},p.Hb=function(){return pbe(this.c)},p.dd=function(t){return this.c.dd(t)},p.Gi=function(){this.c=new VZ(this)},p.Wb=function(){return this.f==0},p.tc=function(){return this.c.tc()},p.ed=function(){return this.c.ed()},p.fd=function(t){return this.c.fd(t)},p.Hi=function(){return CI(this)},p.Ii=function(t,i,a){return new X8e(t,i,a)},p.Ji=function(){return new Zq},p.vc=function(t){return Yje(this,t)},p._b=function(){return this.f},p.kd=function(t,i){return new Rg(this.c,t,i)},p.yc=function(){return this.c.yc()},p.zc=function(t){return this.c.zc(t)},p.Ib=function(){return Xbe(this.c)},p.e=0,p.f=0;var n4n=k(Gs,"BasicEMap",639);A(922,55,Rh,VZ),p.sh=function(t,i){rt(this,h(i,134))},p.vh=function(t,i){mt(this,h(i,134))},p.wh=function(t,i,a){uMt(this,h(i,134),h(a,134))},p.uh=function(t,i){W$e(this.a)};var i4n=k(Gs,"BasicEMap/1",922);A(923,55,Rh,Zq),p.Fh=function(t){return le(EVt,_tt,551,t,0,1)};var r4n=k(Gs,"BasicEMap/2",923);A(924,ud,pu,WZ),p.Pb=function(){this.a.c.Pb()},p.pc=function(t){return nte(this.a,t)},p.tc=function(){return this.a.f==0?(tA(),vD.a):new _Be(this.a)},p.vc=function(t){var i;return i=this.a.f,a6(this.a,t),this.a.f!=i},p._b=function(){return this.a.f};var s4n=k(Gs,"BasicEMap/3",924);A(925,25,Y_,HZ),p.Pb=function(){this.a.c.Pb()},p.pc=function(t){return oZe(this.a,t)},p.tc=function(){return this.a.f==0?(tA(),vD.a):new yBe(this.a)},p._b=function(){return this.a.f};var o4n=k(Gs,"BasicEMap/4",925);A(926,ud,pu,qZ),p.Pb=function(){this.a.c.Pb()},p.pc=function(t){var i,a,l,f,g,m,v,y,E;if(this.a.f>0&&re(t,38)&&(this.a.Fi(),y=h(t,38),v=y.kc(),f=v==null?0:Wr(v),g=sme(this.a,f),i=this.a.d[g],i)){for(a=h(i.g,339),E=i.i,m=0;m"+this.c},p.a=0;var EVt=k(Gs,"BasicEMap/EntryImpl",551);A(484,1,{},P2);var h4n=k(Gs,"BasicEMap/View",484),vD;A(695,1,{}),p.Fb=function(t){return Cve((yt(),uo),t)},p.Hb=function(){return ybe((yt(),uo))},p.Ib=function(){return $p((yt(),uo))};var d4n=k(Gs,"ECollections/BasicEmptyUnmodifiableEList",695);A(1164,1,Th,Kq),p.gc=function(t){Ss(this,t)},p.Bc=function(t){throw Y(new Ai)},p.hc=function(){return!1},p.Cc=function(){return!1},p.ic=function(){throw Y(new K)},p.Dc=function(){return 0},p.Ec=function(){throw Y(new K)},p.Fc=function(){return-1},p.jc=function(){throw Y(new Ai)},p.Gc=function(t){throw Y(new Ai)};var p4n=k(Gs,"ECollections/BasicEmptyUnmodifiableEList/1",1164);A(1162,695,{20:1,13:1,15:1,52:1},MDe),p.bd=function(t,i){qDe()},p.nc=function(t){return XDe()},p.oc=function(t){return YDe()},p.Pb=function(){ZDe()},p.pc=function(t){return!1},p.qc=function(t){return!1},p.sc=function(t){mo(this,t)},p.cd=function(t){return wge((yt(),t)),null},p.dd=function(t){return-1},p.Wb=function(){return!0},p.tc=function(){return this.a},p.ed=function(){return this.a},p.fd=function(t){return this.a},p.uc=function(){return this.xc()},p.gd=function(t){return KDe()},p.vc=function(t){return JDe()},p.hd=function(t,i){return QDe()},p._b=function(){return 0},p.jd=function(t){Ug(this,t)},p.wc=function(){return new pi(this,16)},p.xc=function(){return new si(null,this.wc())},p.kd=function(t,i){return yt(),new Rg(uo,t,i)},p.yc=function(){return VJ((yt(),uo))},p.zc=function(t){return yt(),u6(uo,t)};var g4n=k(Gs,"ECollections/EmptyUnmodifiableEList",1162);A(1163,695,{20:1,13:1,15:1,52:1,533:1},SDe),p.bd=function(t,i){qDe()},p.nc=function(t){return XDe()},p.oc=function(t){return YDe()},p.Pb=function(){ZDe()},p.pc=function(t){return!1},p.qc=function(t){return!1},p.sc=function(t){mo(this,t)},p.cd=function(t){return wge((yt(),t)),null},p.dd=function(t){return-1},p.Wb=function(){return!0},p.tc=function(){return this.a},p.ed=function(){return this.a},p.fd=function(t){return this.a},p.uc=function(){return this.xc()},p.gd=function(t){return KDe()},p.vc=function(t){return JDe()},p.hd=function(t,i){return QDe()},p._b=function(){return 0},p.jd=function(t){Ug(this,t)},p.wc=function(){return new pi(this,16)},p.xc=function(){return new si(null,this.wc())},p.kd=function(t,i){return yt(),new Rg(uo,t,i)},p.yc=function(){return VJ((yt(),uo))},p.zc=function(t){return yt(),u6(uo,t)},p.Hi=function(){return yt(),yt(),Qd};var m4n=k(Gs,"ECollections/EmptyUnmodifiableEMap",1163),kAe=br(Gs,"Enumerator"),Dj;A(261,1,{261:1},sne),p.Fb=function(t){var i;return this===t?!0:re(t,261)?(i=h(t,261),this.f==i.f&&ZCt(this.i,i.i)&&GJ(this.a,this.f&256?i.f&256?i.a:null:i.f&256?null:i.a)&&GJ(this.d,i.d)&&GJ(this.g,i.g)&&GJ(this.e,i.e)&&F5t(this,i)):!1},p.Hb=function(){return this.f},p.Ib=function(){return NZe(this)},p.f=0;var Flt=0,Ult=0,zlt=0,Glt=0,RAe=0,IAe=0,DAe=0,BAe=0,OAe=0,jlt,IL=0,DL=0,$lt=0,Vlt=0,Bj,NAe,b4n=k(Gs,"URI",261);A(965,44,Nx,wDe),p.Zb=function(t,i){return h(Zo(this,Qn(t),h(i,261)),261)};var w4n=k(Gs,"URI/URICache",965);A(451,55,Rh,mE,S9),p.xh=function(){return!0};var v4n=k(Gs,"UniqueEList",451);A(526,54,Yd,hU);var _4n=k(Gs,"WrappedException",526),ki=br(ql,Ett),Qw=br(ql,Stt),Ec=br(ql,Mtt),Ly=br(ql,Ttt),ah=br(ql,Ctt),Pu=br(ql,"EClass"),Rae=br(ql,"EDataType"),Wlt;A(1096,44,Nx,vDe),p.Vb=function(t){return ws(t)?Ua(this,t):Ic(pc(this.d,t))};var y4n=k(ql,"EDataType/Internal/ConversionDelegate/Factory/Registry/Impl",1096),Oj=br(ql,"EEnum"),Qp=br(ql,Att),Lo=br(ql,Ptt),lf=br(ql,Ltt),Lu,ev=br(ql,ktt),tv=br(ql,Rtt);A(918,1,{},vN),p.Ib=function(){return"NIL"};var x4n=k(ql,"EStructuralFeature/Internal/DynamicValueHolder/1",918),Hlt;A(917,44,Nx,_De),p.Vb=function(t){return ws(t)?Ua(this,t):Ic(pc(this.d,t))};var E4n=k(ql,"EStructuralFeature/Internal/SettingDelegate/Factory/Registry/Impl",917),ul=br(ql,Itt),b3=br(ql,"EValidator/PatternMatcher"),FAe,UAe,At,A1,w3,mb,qlt,Xlt,bb,P1,wb,ky,Uh,Ylt,Zlt,uf,L1,k1,nv,MM,Uo,Klt,Jlt,Ry,Nj=br(ar,"FeatureMap/Entry");A(483,1,{75:1},U8),p.nj=function(){return this.a},p.lc=function(){return this.b};var S4n=k(kt,"BasicEObjectImpl/1",483);A(1674,1,{103:1}),p.oj=function(t){this.e=t==0?Qlt:le(sn,nt,1,t,5,1)},p.Tg=function(t){return this.e[t]},p.Ug=function(t,i){this.e[t]=i},p.Vg=function(t){this.e[t]=null},p.pj=function(){return this.c},p.qj=function(){throw Y(new Ai)},p.rj=function(){throw Y(new Ai)},p.sj=function(){return this.d},p.tj=function(){return this.e!=null},p.uj=function(t){this.c=t},p.vj=function(t){throw Y(new Ai)},p.wj=function(t){this.d=t};var Qlt,M4n=k(kt,"BasicEObjectImpl/EPropertiesHolderBaseImpl",1674);A(201,1674,{103:1},gh),p.qj=function(){return this.a},p.rj=function(){return this.b},p.vj=function(t){this.a=t};var T4n=k(kt,"BasicEObjectImpl/EPropertiesHolderImpl",201);A(463,92,Fet,Du),p.dg=function(){return this.f},p.ig=function(){return this.k},p.kg=function(t,i){this.g=t,this.i=i},p.mg=function(){return this.j&2?this.Jg().pj():this.Rg()},p.og=function(){return this.i},p.fg=function(){return(this.j&1)!=0},p.yg=function(){return this.g},p.Eg=function(){return(this.j&4)!=0},p.Jg=function(){return!this.k&&(this.k=new gh),this.k},p.Ng=function(t){this.Jg().uj(t),t?this.j|=2:this.j&=-3},p.Rg=function(){return(kg(),At).S},p.i=0,p.j=1;var C4n=k(kt,"EObjectImpl",463);A(710,463,{95:1,91:1,87:1,51:1,103:1,42:1,92:1},Fme),p.Tg=function(t){return this.e[t]},p.Ug=function(t,i){this.e[t]=i},p.Vg=function(t){this.e[t]=null},p.mg=function(){return this.d},p.rg=function(t){return gr(this.d,t)},p.tg=function(){return this.d},p.xg=function(){return this.e!=null},p.Jg=function(){return!this.k&&(this.k=new Jq),this.k},p.Ng=function(t){this.d=t},p.Qg=function(){var t;return this.e==null&&(t=jn(this.d),this.e=t==0?eut:le(sn,nt,1,t,5,1)),this},p.Sg=function(){return 0};var eut,A4n=k(kt,"DynamicEObjectImpl",710);A(1389,710,{95:1,38:1,91:1,87:1,134:1,51:1,103:1,42:1,92:1},w9e),p.Fb=function(t){return this===t},p.Hb=function(){return p0(this)},p.Ng=function(t){this.d=t,this.b=T6(t,"key"),this.c=T6(t,kP)},p.ih=function(){var t;return this.a==-1&&(t=QQ(this,this.b),this.a=t==null?0:Wr(t)),this.a},p.kc=function(){return QQ(this,this.b)},p.lc=function(){return QQ(this,this.c)},p.jh=function(t){this.a=t},p.kh=function(t){R7e(this,this.b,t)},p.mc=function(t){var i;return i=QQ(this,this.c),R7e(this,this.c,t),i},p.a=0;var P4n=k(kt,"DynamicEObjectImpl/BasicEMapEntry",1389);A(1390,1,{103:1},Jq),p.oj=function(t){throw Y(new Ai)},p.Tg=function(t){throw Y(new Ai)},p.Ug=function(t,i){throw Y(new Ai)},p.Vg=function(t){throw Y(new Ai)},p.pj=function(){throw Y(new Ai)},p.qj=function(){return this.a},p.rj=function(){return this.b},p.sj=function(){return this.c},p.tj=function(){throw Y(new Ai)},p.uj=function(t){throw Y(new Ai)},p.vj=function(t){this.a=t},p.wj=function(t){this.c=t};var L4n=k(kt,"DynamicEObjectImpl/DynamicEPropertiesHolderImpl",1390);A(469,142,{95:1,91:1,87:1,609:1,139:1,51:1,103:1,42:1,92:1,469:1,142:1,107:1,108:1},_N),p.jg=function(t){return Rwe(this,t)},p.ug=function(t,i,a){var l;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),this.Ab;case 1:return this.d;case 2:return a?(!this.b&&(this.b=new bl((Et(),Uo),Ca,this)),this.b):(!this.b&&(this.b=new bl((Et(),Uo),Ca,this)),CI(this.b));case 3:return w7e(this);case 4:return!this.a&&(this.a=new vs(Kw,this,4)),this.a;case 5:return!this.c&&(this.c=new HE(Kw,this,5)),this.c}return Gl(this,t-jn((Et(),A1)),Vt((l=h(rn(this,16),24),l||A1),t),i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Ga(this.Ab,t,a);case 3:return this.Cb&&(a=(f=this.Db>>16,f>=0?Rwe(this,a):this.Cb.Cg(this,-1-f,null,a))),e1e(this,h(t,139),a)}return g=h(Vt((l=h(rn(this,16),24),l||(Et(),A1)),i),61),g.aj().dj(this,Xa(this),i-jn((Et(),A1)),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Us(this.Ab,t,a);case 2:return!this.b&&(this.b=new bl((Et(),Uo),Ca,this)),f9(this.b,t,a);case 3:return e1e(this,null,a);case 4:return!this.a&&(this.a=new vs(Kw,this,4)),Us(this.a,t,a)}return f=h(Vt((l=h(rn(this,16),24),l||(Et(),A1)),i),61),f.aj().ej(this,Xa(this),i-jn((Et(),A1)),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.d!=null;case 2:return!!this.b&&this.b.f!=0;case 3:return!!w7e(this);case 4:return!!this.a&&this.a.i!=0;case 5:return!!this.c&&this.c.i!=0}return Ul(this,t-jn((Et(),A1)),Vt((i=h(rn(this,16),24),i||A1),t))},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:KCt(this,Qn(i));return;case 2:!this.b&&(this.b=new bl((Et(),Uo),Ca,this)),TU(this.b,i);return;case 3:p9t(this,h(i,139));return;case 4:!this.a&&(this.a=new vs(Kw,this,4)),Pr(this.a),!this.a&&(this.a=new vs(Kw,this,4)),Mr(this.a,h(i,13));return;case 5:!this.c&&(this.c=new HE(Kw,this,5)),Pr(this.c),!this.c&&(this.c=new HE(Kw,this,5)),Mr(this.c,h(i,13));return}Vl(this,t-jn((Et(),A1)),Vt((a=h(rn(this,16),24),a||A1),t),i)},p.Rg=function(){return Et(),A1},p.Ib=function(){return qVe(this)},p.d=null;var k4n=k(kt,"EAnnotationImpl",469);A(143,639,Nxe,nl),p.xj=function(t,i){return KMt(this,h(t,38),i)},p.Dh=function(t){return h(h(this.c,64).Dh(t),134)},p.oh=function(){return h(this.c,64).oh()},p.ph=function(){return h(this.c,64).ph()},p.qh=function(t){return h(this.c,64).qh(t)},p.yj=function(t,i){return f9(this,t,i)},p.hj=function(t){return h(this.c,81).hj(t)},p.Gi=function(){},p.ui=function(){return h(this.c,81).ui()},p.Ii=function(t,i,a){var l;return l=h(jl(this.b).dh().$g(this.b),134),l.jh(t),l.kh(i),l.mc(a),l},p.Ji=function(){return new _C(this)},p.Gc=function(t){TU(this,t)},p.ij=function(){h(this.c,81).ij()};var R4n=k(ar,"EcoreEMap",143);A(152,143,Nxe,bl),p.Fi=function(){var t,i,a,l,f,g;if(this.d==null){for(g=le(PAe,Oxe,55,2*this.f+1,0,1),a=this.c.tc();a.e!=a.i._b();)i=h(a.Ci(),134),l=i.ih(),f=(l&zi)%g.length,t=g[f],!t&&(t=g[f]=new _C(this)),t.nc(i);this.d=g}};var I4n=k(kt,"EAnnotationImpl/1",152);A(268,399,{95:1,91:1,87:1,139:1,174:1,51:1,103:1,431:1,42:1,92:1,142:1,268:1,107:1,108:1}),p.ug=function(t,i,a){var l,f;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),this.Ab;case 1:return this.zb;case 2:return vt(),!!(this.Bb&256);case 3:return vt(),!!(this.Bb&512);case 4:return He(this.s);case 5:return He(this.t);case 6:return vt(),!!this.lj();case 7:return vt(),f=this.s,f>=1;case 8:return i?du(this):this.r;case 9:return this.q}return Gl(this,t-jn(this.Rg()),Vt((l=h(rn(this,16),24),l||this.Rg()),t),i,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Us(this.Ab,t,a);case 9:return nQ(this,a)}return f=h(Vt((l=h(rn(this,16),24),l||this.Rg()),i),61),f.aj().ej(this,Xa(this),i-jn(this.Rg()),t,a)},p.Fg=function(t){var i,a;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return(this.Bb&256)==0;case 3:return(this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return this.lj();case 7:return a=this.s,a>=1;case 8:return!!this.r&&!this.q.e&&_0(this.q).i==0;case 9:return!!this.q&&!(this.r&&!this.q.e&&_0(this.q).i==0)}return Ul(this,t-jn(this.Rg()),Vt((i=h(rn(this,16),24),i||this.Rg()),t))},p.Mg=function(t,i){var a,l;switch(t){case 0:!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:this.ah(Qn(i));return;case 2:C_(this,ce(bt(i)));return;case 3:A_(this,ce(bt(i)));return;case 4:E_(this,h(i,21).a);return;case 5:this.Aj(h(i,21).a);return;case 8:xS(this,h(i,133));return;case 9:l=Zg(this,h(i,84),null),l&&l.Th();return}Vl(this,t-jn(this.Rg()),Vt((a=h(rn(this,16),24),a||this.Rg()),t),i)},p.Rg=function(){return Et(),Jlt},p.Xg=function(){du(this),this.Bb|=1},p.jj=function(){return du(this)},p.kj=function(){return this.t},p.lj=function(){var t;return t=this.t,t>1||t==-1},p.xh=function(){return(this.Bb&512)!=0},p.zj=function(t,i){return Bbe(this,t,i)},p.Aj=function(t){gS(this,t)},p.Ib=function(){return Eve(this)},p.s=0,p.t=1;var D4n=k(kt,"ETypedElementImpl",268);A(418,268,{95:1,91:1,87:1,139:1,174:1,51:1,158:1,61:1,103:1,431:1,42:1,92:1,142:1,418:1,268:1,107:1,108:1,615:1}),p.jg=function(t){return jHe(this,t)},p.ug=function(t,i,a){var l,f;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),this.Ab;case 1:return this.zb;case 2:return vt(),!!(this.Bb&256);case 3:return vt(),!!(this.Bb&512);case 4:return He(this.s);case 5:return He(this.t);case 6:return vt(),!!this.lj();case 7:return vt(),f=this.s,f>=1;case 8:return i?du(this):this.r;case 9:return this.q;case 10:return vt(),!!(this.Bb&ef);case 11:return vt(),!!(this.Bb&Rw);case 12:return vt(),!!(this.Bb&V0);case 13:return this.j;case 14:return OS(this);case 15:return vt(),!!(this.Bb&_c);case 16:return vt(),!!(this.Bb&Ch);case 17:return fw(this)}return Gl(this,t-jn(this.Rg()),Vt((l=h(rn(this,16),24),l||this.Rg()),t),i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Ga(this.Ab,t,a);case 17:return this.Cb&&(a=(f=this.Db>>16,f>=0?jHe(this,a):this.Cb.Cg(this,-1-f,null,a))),Sl(this,t,17,a)}return g=h(Vt((l=h(rn(this,16),24),l||this.Rg()),i),61),g.aj().dj(this,Xa(this),i-jn(this.Rg()),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Us(this.Ab,t,a);case 9:return nQ(this,a);case 17:return Sl(this,null,17,a)}return f=h(Vt((l=h(rn(this,16),24),l||this.Rg()),i),61),f.aj().ej(this,Xa(this),i-jn(this.Rg()),t,a)},p.Fg=function(t){var i,a;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return(this.Bb&256)==0;case 3:return(this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return this.lj();case 7:return a=this.s,a>=1;case 8:return!!this.r&&!this.q.e&&_0(this.q).i==0;case 9:return!!this.q&&!(this.r&&!this.q.e&&_0(this.q).i==0);case 10:return(this.Bb&ef)==0;case 11:return(this.Bb&Rw)!=0;case 12:return(this.Bb&V0)!=0;case 13:return this.j!=null;case 14:return OS(this)!=null;case 15:return(this.Bb&_c)!=0;case 16:return(this.Bb&Ch)!=0;case 17:return!!fw(this)}return Ul(this,t-jn(this.Rg()),Vt((i=h(rn(this,16),24),i||this.Rg()),t))},p.Mg=function(t,i){var a,l;switch(t){case 0:!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:SQ(this,Qn(i));return;case 2:C_(this,ce(bt(i)));return;case 3:A_(this,ce(bt(i)));return;case 4:E_(this,h(i,21).a);return;case 5:this.Aj(h(i,21).a);return;case 8:xS(this,h(i,133));return;case 9:l=Zg(this,h(i,84),null),l&&l.Th();return;case 10:OU(this,ce(bt(i)));return;case 11:BU(this,ce(bt(i)));return;case 12:FU(this,ce(bt(i)));return;case 13:mge(this,Qn(i));return;case 15:NU(this,ce(bt(i)));return;case 16:UU(this,ce(bt(i)));return}Vl(this,t-jn(this.Rg()),Vt((a=h(rn(this,16),24),a||this.Rg()),t),i)},p.Rg=function(){return Et(),Klt},p.Xg=function(){nS($o((Hc(),Ks),this)),du(this),this.Bb|=1},p.Vi=function(){return this.f},p.Oi=function(){return OS(this)},p.Wi=function(){return fw(this)},p.$i=function(){return null},p.Bj=function(){return this.k},p.pi=function(){return this.n},p._i=function(){return c7(this)},p.aj=function(){var t,i,a,l,f,g,m,v,y;return this.p||(a=fw(this),(a.i==null&&Jg(a),a.i).length,l=this.$i(),l&&jn(fw(l)),f=du(this),m=f.Qi(),t=m?m.i&1?m==ku?lo:m==Rn?Ao:m==sv?oM:m==ks?Eo:m==R1?Z0:m==By?K0:m==Sc?Hx:$P:m:null,i=OS(this),v=f.Oi(),M6t(this),this.Bb&Ch&&((g=Uwe((Hc(),Ks),a))&&g!=this||(g=pA($o(Ks,this))))?this.p=new mNe(this,g):this.lj()?this.Dj()?l?this.Bb&_c?t?this.Ej()?this.p=new Vm(47,t,this,l):this.p=new Vm(5,t,this,l):this.Ej()?this.p=new qm(46,this,l):this.p=new qm(4,this,l):t?this.Ej()?this.p=new Vm(49,t,this,l):this.p=new Vm(7,t,this,l):this.Ej()?this.p=new qm(48,this,l):this.p=new qm(6,this,l):this.Bb&_c?t?t==cy?this.p=new Rp(50,Blt,this):this.Ej()?this.p=new Rp(43,t,this):this.p=new Rp(1,t,this):this.Ej()?this.p=new Op(42,this):this.p=new Op(0,this):t?t==cy?this.p=new Rp(41,Blt,this):this.Ej()?this.p=new Rp(45,t,this):this.p=new Rp(3,t,this):this.Ej()?this.p=new Op(44,this):this.p=new Op(2,this):re(f,140)?t==Nj?this.p=new Op(40,this):this.Bb&512?this.Bb&_c?t?this.p=new Rp(9,t,this):this.p=new Op(8,this):t?this.p=new Rp(11,t,this):this.p=new Op(10,this):this.Bb&_c?t?this.p=new Rp(13,t,this):this.p=new Op(12,this):t?this.p=new Rp(15,t,this):this.p=new Op(14,this):l?(y=l.t,y>1||y==-1?this.Ej()?this.Bb&_c?t?this.p=new Vm(25,t,this,l):this.p=new qm(24,this,l):t?this.p=new Vm(27,t,this,l):this.p=new qm(26,this,l):this.Bb&_c?t?this.p=new Vm(29,t,this,l):this.p=new qm(28,this,l):t?this.p=new Vm(31,t,this,l):this.p=new qm(30,this,l):this.Ej()?this.Bb&_c?t?this.p=new Vm(33,t,this,l):this.p=new qm(32,this,l):t?this.p=new Vm(35,t,this,l):this.p=new qm(34,this,l):this.Bb&_c?t?this.p=new Vm(37,t,this,l):this.p=new qm(36,this,l):t?this.p=new Vm(39,t,this,l):this.p=new qm(38,this,l)):this.Ej()?this.Bb&_c?t?this.p=new Rp(17,t,this):this.p=new Op(16,this):t?this.p=new Rp(19,t,this):this.p=new Op(18,this):this.Bb&_c?t?this.p=new Rp(21,t,this):this.p=new Op(20,this):t?this.p=new Rp(23,t,this):this.p=new Op(22,this):this.Cj()?this.Ej()?this.p=new Y8e(h(f,24),this,l):this.p=new j1e(h(f,24),this,l):re(f,140)?t==Nj?this.p=new Op(40,this):this.Bb&_c?t?this.p=new O9e(i,v,this,(tte(),m==Rn?HAe:m==ku?GAe:m==R1?qAe:m==sv?WAe:m==ks?VAe:m==By?XAe:m==Sc?jAe:m==Yl?$Ae:Bae)):this.p=new RUe(h(f,140),i,v,this):t?this.p=new B9e(i,v,this,(tte(),m==Rn?HAe:m==ku?GAe:m==R1?qAe:m==sv?WAe:m==ks?VAe:m==By?XAe:m==Sc?jAe:m==Yl?$Ae:Bae)):this.p=new kUe(h(f,140),i,v,this):this.Dj()?l?this.Bb&_c?this.Ej()?this.p=new K8e(h(f,24),this,l):this.p=new Lme(h(f,24),this,l):this.Ej()?this.p=new Z8e(h(f,24),this,l):this.p=new OJ(h(f,24),this,l):this.Bb&_c?this.Ej()?this.p=new HFe(h(f,24),this):this.p=new Yge(h(f,24),this):this.Ej()?this.p=new WFe(h(f,24),this):this.p=new _J(h(f,24),this):this.Ej()?l?this.Bb&_c?this.p=new J8e(h(f,24),this,l):this.p=new Pme(h(f,24),this,l):this.Bb&_c?this.p=new qFe(h(f,24),this):this.p=new Xge(h(f,24),this):l?this.Bb&_c?this.p=new Q8e(h(f,24),this,l):this.p=new kme(h(f,24),this,l):this.Bb&_c?this.p=new XFe(h(f,24),this):this.p=new M9(h(f,24),this)),this.p},p.Xi=function(){return(this.Bb&ef)!=0},p.Cj=function(){return!1},p.Dj=function(){return!1},p.Yi=function(){return(this.Bb&Ch)!=0},p.bj=function(){return O0e(this)},p.Ej=function(){return!1},p.Zi=function(){return(this.Bb&_c)!=0},p.Fj=function(t){this.k=t},p.ah=function(t){SQ(this,t)},p.Ib=function(){return L7(this)},p.e=!1,p.n=0;var B4n=k(kt,"EStructuralFeatureImpl",418);A(335,418,{95:1,91:1,87:1,29:1,139:1,174:1,51:1,158:1,61:1,103:1,431:1,42:1,92:1,335:1,142:1,418:1,268:1,107:1,108:1,615:1},cK),p.ug=function(t,i,a){var l,f;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),this.Ab;case 1:return this.zb;case 2:return vt(),!!(this.Bb&256);case 3:return vt(),!!(this.Bb&512);case 4:return He(this.s);case 5:return He(this.t);case 6:return vt(),!!yve(this);case 7:return vt(),f=this.s,f>=1;case 8:return i?du(this):this.r;case 9:return this.q;case 10:return vt(),!!(this.Bb&ef);case 11:return vt(),!!(this.Bb&Rw);case 12:return vt(),!!(this.Bb&V0);case 13:return this.j;case 14:return OS(this);case 15:return vt(),!!(this.Bb&_c);case 16:return vt(),!!(this.Bb&Ch);case 17:return fw(this);case 18:return vt(),!!(this.Bb&Ka);case 19:return i?See(this):AGe(this)}return Gl(this,t-jn((Et(),w3)),Vt((l=h(rn(this,16),24),l||w3),t),i,a)},p.Fg=function(t){var i,a;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return(this.Bb&256)==0;case 3:return(this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return yve(this);case 7:return a=this.s,a>=1;case 8:return!!this.r&&!this.q.e&&_0(this.q).i==0;case 9:return!!this.q&&!(this.r&&!this.q.e&&_0(this.q).i==0);case 10:return(this.Bb&ef)==0;case 11:return(this.Bb&Rw)!=0;case 12:return(this.Bb&V0)!=0;case 13:return this.j!=null;case 14:return OS(this)!=null;case 15:return(this.Bb&_c)!=0;case 16:return(this.Bb&Ch)!=0;case 17:return!!fw(this);case 18:return(this.Bb&Ka)!=0;case 19:return!!AGe(this)}return Ul(this,t-jn((Et(),w3)),Vt((i=h(rn(this,16),24),i||w3),t))},p.Mg=function(t,i){var a,l;switch(t){case 0:!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:SQ(this,Qn(i));return;case 2:C_(this,ce(bt(i)));return;case 3:A_(this,ce(bt(i)));return;case 4:E_(this,h(i,21).a);return;case 5:mBe(this,h(i,21).a);return;case 8:xS(this,h(i,133));return;case 9:l=Zg(this,h(i,84),null),l&&l.Th();return;case 10:OU(this,ce(bt(i)));return;case 11:BU(this,ce(bt(i)));return;case 12:FU(this,ce(bt(i)));return;case 13:mge(this,Qn(i));return;case 15:NU(this,ce(bt(i)));return;case 16:UU(this,ce(bt(i)));return;case 18:$be(this,ce(bt(i)));return}Vl(this,t-jn((Et(),w3)),Vt((a=h(rn(this,16),24),a||w3),t),i)},p.Rg=function(){return Et(),w3},p.Xg=function(){See(this),nS($o((Hc(),Ks),this)),du(this),this.Bb|=1},p.lj=function(){return yve(this)},p.zj=function(t,i){return this.b=0,this.a=null,Bbe(this,t,i)},p.Aj=function(t){mBe(this,t)},p.Ib=function(){var t;return this.Db&64?L7(this):(t=new ru(L7(this)),t.a+=" (iD: ",Cp(t,(this.Bb&Ka)!=0),t.a+=")",t.a)},p.b=0;var O4n=k(kt,"EAttributeImpl",335);A(672,399,{95:1,91:1,87:1,133:1,139:1,174:1,51:1,103:1,42:1,92:1,142:1,107:1,108:1,614:1}),p.Gj=function(t){return t.mg()==this},p.jg=function(t){return Mte(this,t)},p.kg=function(t,i){this.w=null,this.Db=i<<16|this.Db&255,this.Cb=t},p.ug=function(t,i,a){var l;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),this.Ab;case 1:return this.zb;case 2:return this.D!=null?this.D:this.B;case 3:return O0(this);case 4:return this.Oi();case 5:return this.F;case 6:return i?jl(this):oS(this);case 7:return!this.A&&(this.A=new Ol(ul,this,7)),this.A}return Gl(this,t-jn(this.Rg()),Vt((l=h(rn(this,16),24),l||this.Rg()),t),i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Ga(this.Ab,t,a);case 6:return this.Cb&&(a=(f=this.Db>>16,f>=0?Mte(this,a):this.Cb.Cg(this,-1-f,null,a))),Sl(this,t,6,a)}return g=h(Vt((l=h(rn(this,16),24),l||this.Rg()),i),61),g.aj().dj(this,Xa(this),i-jn(this.Rg()),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Us(this.Ab,t,a);case 6:return Sl(this,null,6,a);case 7:return!this.A&&(this.A=new Ol(ul,this,7)),Us(this.A,t,a)}return f=h(Vt((l=h(rn(this,16),24),l||this.Rg()),i),61),f.aj().ej(this,Xa(this),i-jn(this.Rg()),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.D!=null&&this.D==this.F;case 3:return!!O0(this);case 4:return this.Oi()!=null;case 5:return this.F!=null&&this.F!=this.D&&this.F!=this.B;case 6:return!!oS(this);case 7:return!!this.A&&this.A.i!=0}return Ul(this,t-jn(this.Rg()),Vt((i=h(rn(this,16),24),i||this.Rg()),t))},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:H9(this,Qn(i));return;case 2:iJ(this,Qn(i));return;case 5:Pne(this,Qn(i));return;case 7:!this.A&&(this.A=new Ol(ul,this,7)),Pr(this.A),!this.A&&(this.A=new Ol(ul,this,7)),Mr(this.A,h(i,13));return}Vl(this,t-jn(this.Rg()),Vt((a=h(rn(this,16),24),a||this.Rg()),t),i)},p.Rg=function(){return Et(),qlt},p.Ni=function(){var t;return this.G==-1&&(this.G=(t=jl(this),t?jp(t.bh(),this):-1)),this.G},p.Oi=function(){return null},p.Pi=function(){return jl(this)},p.Hj=function(){return this.v},p.Qi=function(){return O0(this)},p.Ri=function(){return this.D!=null?this.D:this.B},p.Si=function(){return this.F},p.Li=function(t){return hne(this,t)},p.Ij=function(t){this.v=t},p.Jj=function(t){E$e(this,t)},p.Kj=function(t){this.C=t},p.ah=function(t){H9(this,t)},p.Ib=function(){return HU(this)},p.C=null,p.D=null,p.G=-1;var N4n=k(kt,"EClassifierImpl",672);A(96,672,{95:1,91:1,87:1,24:1,133:1,139:1,174:1,51:1,103:1,42:1,92:1,96:1,142:1,432:1,107:1,108:1,614:1},lR),p.Gj=function(t){return WMt(this,t.mg())},p.ug=function(t,i,a){var l;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),this.Ab;case 1:return this.zb;case 2:return this.D!=null?this.D:this.B;case 3:return O0(this);case 4:return null;case 5:return this.F;case 6:return i?jl(this):oS(this);case 7:return!this.A&&(this.A=new Ol(ul,this,7)),this.A;case 8:return vt(),!!(this.Bb&256);case 9:return vt(),!!(this.Bb&512);case 10:return Do(this);case 11:return!this.q&&(this.q=new ze(lf,this,11,10)),this.q;case 12:return V_(this);case 13:return pP(this);case 14:return pP(this),this.r;case 15:return V_(this),this.k;case 16:return hve(this);case 17:return wne(this);case 18:return Jg(this);case 19:return E7(this);case 20:return V_(this),this.o;case 21:return!this.s&&(this.s=new ze(Ec,this,21,17)),this.s;case 22:return xa(this);case 23:return rne(this)}return Gl(this,t-jn((Et(),mb)),Vt((l=h(rn(this,16),24),l||mb),t),i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Ga(this.Ab,t,a);case 6:return this.Cb&&(a=(f=this.Db>>16,f>=0?Mte(this,a):this.Cb.Cg(this,-1-f,null,a))),Sl(this,t,6,a);case 11:return!this.q&&(this.q=new ze(lf,this,11,10)),Ga(this.q,t,a);case 21:return!this.s&&(this.s=new ze(Ec,this,21,17)),Ga(this.s,t,a)}return g=h(Vt((l=h(rn(this,16),24),l||(Et(),mb)),i),61),g.aj().dj(this,Xa(this),i-jn((Et(),mb)),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Us(this.Ab,t,a);case 6:return Sl(this,null,6,a);case 7:return!this.A&&(this.A=new Ol(ul,this,7)),Us(this.A,t,a);case 11:return!this.q&&(this.q=new ze(lf,this,11,10)),Us(this.q,t,a);case 21:return!this.s&&(this.s=new ze(Ec,this,21,17)),Us(this.s,t,a);case 22:return Us(xa(this),t,a)}return f=h(Vt((l=h(rn(this,16),24),l||(Et(),mb)),i),61),f.aj().ej(this,Xa(this),i-jn((Et(),mb)),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.D!=null&&this.D==this.F;case 3:return!!O0(this);case 4:return!1;case 5:return this.F!=null&&this.F!=this.D&&this.F!=this.B;case 6:return!!oS(this);case 7:return!!this.A&&this.A.i!=0;case 8:return(this.Bb&256)!=0;case 9:return(this.Bb&512)!=0;case 10:return!!this.u&&xa(this.u.a).i!=0&&!(this.n&&bte(this.n));case 11:return!!this.q&&this.q.i!=0;case 12:return V_(this).i!=0;case 13:return pP(this).i!=0;case 14:return pP(this),this.r.i!=0;case 15:return V_(this),this.k.i!=0;case 16:return hve(this).i!=0;case 17:return wne(this).i!=0;case 18:return Jg(this).i!=0;case 19:return E7(this).i!=0;case 20:return V_(this),!!this.o;case 21:return!!this.s&&this.s.i!=0;case 22:return!!this.n&&bte(this.n);case 23:return rne(this).i!=0}return Ul(this,t-jn((Et(),mb)),Vt((i=h(rn(this,16),24),i||mb),t))},p.Ig=function(t){var i;return i=this.i==null||this.q&&this.q.i!=0?null:T6(this,t),i||D_e(this,t)},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:H9(this,Qn(i));return;case 2:iJ(this,Qn(i));return;case 5:Pne(this,Qn(i));return;case 7:!this.A&&(this.A=new Ol(ul,this,7)),Pr(this.A),!this.A&&(this.A=new Ol(ul,this,7)),Mr(this.A,h(i,13));return;case 8:eWe(this,ce(bt(i)));return;case 9:tWe(this,ce(bt(i)));return;case 10:O7(Do(this)),Mr(Do(this),h(i,13));return;case 11:!this.q&&(this.q=new ze(lf,this,11,10)),Pr(this.q),!this.q&&(this.q=new ze(lf,this,11,10)),Mr(this.q,h(i,13));return;case 21:!this.s&&(this.s=new ze(Ec,this,21,17)),Pr(this.s),!this.s&&(this.s=new ze(Ec,this,21,17)),Mr(this.s,h(i,13));return;case 22:Pr(xa(this)),Mr(xa(this),h(i,13));return}Vl(this,t-jn((Et(),mb)),Vt((a=h(rn(this,16),24),a||mb),t),i)},p.Rg=function(){return Et(),mb},p.Xg=function(){var t,i;if(V_(this),pP(this),hve(this),wne(this),Jg(this),E7(this),rne(this),_A(kCt(lu(this))),this.s)for(t=0,i=this.s.i;t=0;--t)ae(this,t);return K1e(this)},p.zc=function(t){var i;if(this.Qj())for(i=this.i-1;i>=0;--i)ae(this,i);return ewe(this,t)},p.ij=function(){Pr(this)},p.Ch=function(t,i){return Rje(this,t,i)};var z4n=k(ar,"EcoreEList",565);A(450,565,Wo,uI),p.rh=function(){return!1},p.pi=function(){return this.c},p.qi=function(){return!1},p.Rj=function(){return!0},p.xh=function(){return!0},p.zh=function(t,i){return i},p.Bh=function(){return!1},p.c=0;var G4n=k(ar,"EObjectEList",450);A(88,450,Wo,vs),p.qi=function(){return!0},p.Pj=function(){return!1},p.Dj=function(){return!0};var j4n=k(ar,"EObjectContainmentEList",88);A(493,88,Wo,Z8),p.th=function(){this.a=!0},p.ui=function(){return this.a},p.ij=function(){var t;Pr(this),ju(this.e)?(t=this.a,this.a=!1,Pi(this.e,new Hu(this.e,2,this.c,t,!1))):this.a=!1},p.a=!1;var $4n=k(ar,"EObjectContainmentEList/Unsettable",493);A(1003,493,Wo,cFe),p.yi=function(t,i){return t5t(this,h(t,84),i)},p.zi=function(t,i){return e5t(this,h(t,84),i)},p.Ai=function(t,i,a){return FBt(this,h(t,84),h(i,84),a)},p.mi=function(t,i,a,l,f){switch(t){case 3:return dA(this,3,i,a,l,this.i>1);case 5:return dA(this,5,i,a,l,this.i-h(a,15)._b()>0);default:return new Vd(this.e,t,this.c,i,a,l,!0)}},p.xi=function(){return!0},p.ui=function(){return bte(this)},p.ij=function(){Pr(this)};var V4n=k(kt,"EClassImpl/1",1003);A(1017,1016,Bxe),p.Ih=function(t){var i,a,l,f,g,m,v;if(a=t.Lh(),a!=8){if(l=I5t(t),l==0)switch(a){case 1:case 9:{v=t.Ph(),v!=null&&(i=lu(h(v,432)),!i.c&&(i.c=new Wb),JQ(i.c,t.Oh())),m=t.Nh(),m!=null&&(f=h(m,432),f.Bb&1||(i=lu(f),!i.c&&(i.c=new Wb),$n(i.c,h(t.Oh(),24))));break}case 3:{m=t.Nh(),m!=null&&(f=h(m,432),f.Bb&1||(i=lu(f),!i.c&&(i.c=new Wb),$n(i.c,h(t.Oh(),24))));break}case 5:{if(m=t.Nh(),m!=null)for(g=h(m,13).tc();g.hc();)f=h(g.ic(),432),f.Bb&1||(i=lu(f),!i.c&&(i.c=new Wb),$n(i.c,h(t.Oh(),24)));break}case 4:{v=t.Ph(),v!=null&&(f=h(v,432),f.Bb&1||(i=lu(f),!i.c&&(i.c=new Wb),JQ(i.c,t.Oh())));break}case 6:{if(v=t.Ph(),v!=null)for(g=h(v,13).tc();g.hc();)f=h(g.ic(),432),f.Bb&1||(i=lu(f),!i.c&&(i.c=new Wb),JQ(i.c,t.Oh()));break}}this.Tj(l)}},p.Tj=function(t){mZe(this,t)},p.b=63;var W4n=k(kt,"ESuperAdapter",1017);A(1018,1017,Bxe,YZ),p.Tj=function(t){sP(this,t)};var H4n=k(kt,"EClassImpl/10",1018);A(1007,630,Wo),p.lh=function(t){return kHe(this,t)},p.mh=function(t,i){e6(this,t,i)},p.nh=function(t){MI(this,t)},p.Dh=function(t){return P0e(this,t)},p.Ah=function(t,i){return KQ(this,t,i)},p.xj=function(t,i){throw Y(new Ai)},p.oh=function(){return new tx(this)},p.ph=function(){return new QR(this)},p.qh=function(t){return GI(this,t)},p.yj=function(t,i){throw Y(new Ai)},p.hj=function(t){return this},p.ui=function(){return this.i!=0},p.Gc=function(t){throw Y(new Ai)},p.ij=function(){throw Y(new Ai)};var q4n=k(ar,"EcoreEList/UnmodifiableEList",1007);A(301,1007,Wo,t_),p.Bh=function(){return!1};var X4n=k(ar,"EcoreEList/UnmodifiableEList/FastCompare",301);A(1010,301,Wo,_Ve),p.dd=function(t){var i,a,l;if(re(t,158)&&(i=h(t,158),a=i.pi(),a!=-1)){for(l=this.i;a4)if(this.Li(t)){if(this.Dj()){if(l=h(t,42),a=l.ng(),v=a==this.b&&(this.Pj()?l.hg(l.og(),h(Vt(rc(this.b),this.pi()).jj(),24).Qi())==Fo(h(Vt(rc(this.b),this.pi()),17)).n:-1-l.og()==this.pi()),this.Qj()&&!v&&!a&&l.sg()){for(f=0;f1||l==-1)):!1},p.Pj=function(){var t,i,a;return i=Vt(rc(this.b),this.pi()),re(i,62)?(t=h(i,17),a=Fo(t),!!a):!1},p.Qj=function(){var t,i;return i=Vt(rc(this.b),this.pi()),re(i,62)?(t=h(i,17),(t.Bb&oo)!=0):!1},p.dd=function(t){var i,a,l,f;if(l=this.ci(t),l>=0)return l;if(this.Rj()){for(a=0,f=this.hi();a=0;--t)B6(this,t,this.ai(t));return this.ii()},p.zc=function(t){var i;if(this.Qj())for(i=this.hi()-1;i>=0;--i)B6(this,i,this.ai(i));return this.ji(t)},p.ij=function(){O7(this)},p.Ch=function(t,i){return jGe(this,t,i)};var okn=k(ar,"DelegatingEcoreEList",674);A(1013,674,Uxe,r8e),p.Vh=function(t,i){yMt(this,t,h(i,24))},p.Wh=function(t){PSt(this,h(t,24))},p.ai=function(t){var i,a;return i=h(ae(xa(this.a),t),84),a=i.c,re(a,96)?h(a,24):(Et(),uf)},p.fi=function(t){var i,a;return i=h(Ew(xa(this.a),t),84),a=i.c,re(a,96)?h(a,24):(Et(),uf)},p.gi=function(t,i){return dDt(this,t,h(i,24))},p.rh=function(){return!1},p.mi=function(t,i,a,l,f){return null},p.Xh=function(){return new SR(this)},p.Yh=function(){Pr(xa(this.a))},p.Zh=function(t){return iWe(this,t)},p.$h=function(t){var i,a;for(a=t.tc();a.hc();)if(i=a.ic(),!iWe(this,i))return!1;return!0},p._h=function(t){var i,a,l;if(re(t,15)&&(l=h(t,15),l._b()==xa(this.a).i)){for(i=l.tc(),a=new Dn(this);i.hc();)if(Be(i.ic())!==Be(Xn(a)))return!1;return!0}return!1},p.bi=function(){var t,i,a,l,f;for(a=1,i=new Dn(xa(this.a));i.e!=i.i._b();)t=h(Xn(i),84),l=(f=t.c,re(f,96)?h(f,24):(Et(),uf)),a=31*a+(l?p0(l):0);return a},p.ci=function(t){var i,a,l,f;for(l=0,a=new Dn(xa(this.a));a.e!=a.i._b();){if(i=h(Xn(a),84),Be(t)===Be((f=i.c,re(f,96)?h(f,24):(Et(),uf))))return l;++l}return-1},p.di=function(){return xa(this.a).i==0},p.ei=function(){return null},p.hi=function(){return xa(this.a).i},p.ii=function(){var t,i,a,l,f,g;for(g=xa(this.a).i,f=le(sn,nt,1,g,5,1),a=0,i=new Dn(xa(this.a));i.e!=i.i._b();)t=h(Xn(i),84),f[a++]=(l=t.c,re(l,96)?h(l,24):(Et(),uf));return f},p.ji=function(t){var i,a,l,f,g,m,v;for(v=xa(this.a).i,t.lengthv&&zr(t,v,null),l=0,a=new Dn(xa(this.a));a.e!=a.i._b();)i=h(Xn(a),84),g=(m=i.c,re(m,96)?h(m,24):(Et(),uf)),zr(t,l++,g);return t},p.ki=function(){var t,i,a,l,f;for(f=new Mp,f.a+="[",t=xa(this.a),i=0,l=xa(this.a).i;i>16,f>=0?Mte(this,a):this.Cb.Cg(this,-1-f,null,a))),Sl(this,t,6,a);case 9:return!this.a&&(this.a=new ze(Qp,this,9,5)),Ga(this.a,t,a)}return g=h(Vt((l=h(rn(this,16),24),l||(Et(),bb)),i),61),g.aj().dj(this,Xa(this),i-jn((Et(),bb)),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Us(this.Ab,t,a);case 6:return Sl(this,null,6,a);case 7:return!this.A&&(this.A=new Ol(ul,this,7)),Us(this.A,t,a);case 9:return!this.a&&(this.a=new ze(Qp,this,9,5)),Us(this.a,t,a)}return f=h(Vt((l=h(rn(this,16),24),l||(Et(),bb)),i),61),f.aj().ej(this,Xa(this),i-jn((Et(),bb)),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.D!=null&&this.D==this.F;case 3:return!!O0(this);case 4:return!!Lbe(this);case 5:return this.F!=null&&this.F!=this.D&&this.F!=this.B;case 6:return!!oS(this);case 7:return!!this.A&&this.A.i!=0;case 8:return(this.Bb&256)==0;case 9:return!!this.a&&this.a.i!=0}return Ul(this,t-jn((Et(),bb)),Vt((i=h(rn(this,16),24),i||bb),t))},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:H9(this,Qn(i));return;case 2:iJ(this,Qn(i));return;case 5:Pne(this,Qn(i));return;case 7:!this.A&&(this.A=new Ol(ul,this,7)),Pr(this.A),!this.A&&(this.A=new Ol(ul,this,7)),Mr(this.A,h(i,13));return;case 8:Fbe(this,ce(bt(i)));return;case 9:!this.a&&(this.a=new ze(Qp,this,9,5)),Pr(this.a),!this.a&&(this.a=new ze(Qp,this,9,5)),Mr(this.a,h(i,13));return}Vl(this,t-jn((Et(),bb)),Vt((a=h(rn(this,16),24),a||bb),t),i)},p.Rg=function(){return Et(),bb},p.Xg=function(){var t,i;if(this.a)for(t=0,i=this.a.i;t>16==5?h(this.Cb,608):null}return Gl(this,t-jn((Et(),P1)),Vt((l=h(rn(this,16),24),l||P1),t),i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Ga(this.Ab,t,a);case 5:return this.Cb&&(a=(f=this.Db>>16,f>=0?WHe(this,a):this.Cb.Cg(this,-1-f,null,a))),Sl(this,t,5,a)}return g=h(Vt((l=h(rn(this,16),24),l||(Et(),P1)),i),61),g.aj().dj(this,Xa(this),i-jn((Et(),P1)),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Us(this.Ab,t,a);case 5:return Sl(this,null,5,a)}return f=h(Vt((l=h(rn(this,16),24),l||(Et(),P1)),i),61),f.aj().ej(this,Xa(this),i-jn((Et(),P1)),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.d!=0;case 3:return!!this.b;case 4:return this.c!=null;case 5:return!!(this.Db>>16==5&&h(this.Cb,608))}return Ul(this,t-jn((Et(),P1)),Vt((i=h(rn(this,16),24),i||P1),t))},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:Ef(this,Qn(i));return;case 2:$0e(this,h(i,21).a);return;case 3:IFt(this,h(i,1634));return;case 4:tbe(this,Qn(i));return}Vl(this,t-jn((Et(),P1)),Vt((a=h(rn(this,16),24),a||P1),t),i)},p.Rg=function(){return Et(),P1},p.Ib=function(){var t;return t=this.c,t??this.zb},p.b=null,p.c=null,p.d=0;var dkn=k(kt,"EEnumLiteralImpl",525),SVt=br(kt,"EFactoryImpl/InternalEDateTimeFormat");A(445,1,{1699:1},O2);var pkn=k(kt,"EFactoryImpl/1ClientInternalEDateTimeFormat",445);A(217,108,{95:1,91:1,87:1,84:1,51:1,103:1,42:1,92:1,217:1,107:1,108:1},xg),p.lg=function(t,i,a){var l;return a=Sl(this,t,i,a),this.e&&re(t,158)&&(l=x7(this,this.e),l!=this.c&&(a=zS(this,l,a))),a},p.ug=function(t,i,a){var l;switch(t){case 0:return this.f;case 1:return!this.d&&(this.d=new vs(Lo,this,1)),this.d;case 2:return i?R7(this):this.c;case 3:return this.b;case 4:return this.e;case 5:return i?vte(this):this.a}return Gl(this,t-jn((Et(),ky)),Vt((l=h(rn(this,16),24),l||ky),t),i,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return WVe(this,null,a);case 1:return!this.d&&(this.d=new vs(Lo,this,1)),Us(this.d,t,a);case 3:return VVe(this,null,a)}return f=h(Vt((l=h(rn(this,16),24),l||(Et(),ky)),i),61),f.aj().ej(this,Xa(this),i-jn((Et(),ky)),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.f;case 1:return!!this.d&&this.d.i!=0;case 2:return!!this.c;case 3:return!!this.b;case 4:return!!this.e;case 5:return!!this.a}return Ul(this,t-jn((Et(),ky)),Vt((i=h(rn(this,16),24),i||ky),t))},p.Mg=function(t,i){var a;switch(t){case 0:aOt(this,h(i,84));return;case 1:!this.d&&(this.d=new vs(Lo,this,1)),Pr(this.d),!this.d&&(this.d=new vs(Lo,this,1)),Mr(this.d,h(i,13));return;case 3:dqe(this,h(i,84));return;case 4:kqe(this,h(i,742));return;case 5:MA(this,h(i,133));return}Vl(this,t-jn((Et(),ky)),Vt((a=h(rn(this,16),24),a||ky),t),i)},p.Rg=function(){return Et(),ky},p.Ib=function(){var t;return t=new su(Zu(this)),t.a+=" (expression: ",Ene(this,t),t.a+=")",t.a};var zAe,gkn=k(kt,"EGenericTypeImpl",217);A(1667,1657,xz),p.xj=function(t,i){return DMt(this,this._b(),t),i},p.Dh=function(t){return qg(this.Uh(),t)},p.oh=function(){return this.ph()},p.Uh=function(){return new TR(this)},p.ph=function(){return this.qh(0)},p.qh=function(t){return this.Uh().fd(t)},p.yj=function(t,i){return vx(this,t,!0),i};var mkn=k(ar,"AbstractSequentialInternalEList",1667);A(444,1667,xz,eI),p.Dh=function(t){return qg(this.Uh(),t)},p.oh=function(){return this.b==null?(Ap(),Ap(),_D):this.Vj()},p.Uh=function(){return new PNe(this.a,this.b)},p.ph=function(){return this.b==null?(Ap(),Ap(),_D):this.Vj()},p.qh=function(t){var i,a;if(this.b==null){if(t<0||t>1)throw Y(new ka(RP+t+", size=0"));return Ap(),Ap(),_D}for(a=this.Vj(),i=0;i0;)if(i=this.c[--this.d],(!this.e||i.Vi()!=SM||i.pi()!=0)&&(!this.Yj()||this.b.Gg(i))){if(g=this.b.wg(i,this.Xj()),this.f=(Xo(),h(i,61).bj()),this.f||i.lj()){if(this.Xj()?(l=h(g,15),this.k=l):(l=h(g,64),this.k=this.j=l),re(this.k,49)?(this.o=this.k._b(),this.n=this.o):this.p=this.j?this.j.qh(this.k._b()):this.k.fd(this.k._b()),this.p?cXe(this,this.p):xXe(this))return f=this.p?this.p.Ec():this.j?this.j.Dh(--this.n):this.k.cd(--this.n),this.f?(t=h(f,75),t.nj(),a=t.lc(),this.i=a):this.i=f,this.g=-3,!0}else if(g!=null)return this.k=null,this.p=null,this.i=g,this.g=-2,!0}return this.k=null,this.p=null,this.g=-1,!1}else return f=this.p?this.p.Ec():this.j?this.j.Dh(--this.n):this.k.cd(--this.n),this.f?(t=h(f,75),t.nj(),a=t.lc(),this.i=a):this.i=f,this.g=-3,!0}},p.ic=function(){return MU(this)},p.Dc=function(){return this.a},p.Ec=function(){var t;if(this.g<-1||this.Cc())return--this.a,this.g=0,t=this.i,this.Cc(),t;throw Y(new K)},p.Fc=function(){return this.a-1},p.jc=function(){throw Y(new Ai)},p.Xj=function(){return!1},p.Gc=function(t){throw Y(new Ai)},p.Yj=function(){return!0},p.a=0,p.d=0,p.f=!1,p.g=0,p.n=0,p.o=0;var _D,vkn=k(ar,"EContentsEList/FeatureIteratorImpl",260);A(631,260,Ez,qge),p.Xj=function(){return!0};var _kn=k(ar,"EContentsEList/ResolvingFeatureIteratorImpl",631);A(1020,631,Ez,VFe),p.Yj=function(){return!1};var ykn=k(kt,"ENamedElementImpl/1/1",1020);A(1021,260,Ez,$Fe),p.Yj=function(){return!1};var xkn=k(kt,"ENamedElementImpl/1/2",1021);A(32,136,o5,dw,LQ,cs,VQ,Vd,Hu,V0e,N7e,W0e,F7e,d0e,U7e,X0e,z7e,p0e,G7e,H0e,j7e,pI,I1e,q0e,$7e,g0e,V7e),p.oi=function(){return C0e(this)},p.vi=function(){var t;return t=C0e(this),t?t.Oi():null},p.Mh=function(t){return this.b==-1&&this.a&&(this.b=this.c.qg(this.a.pi(),this.a.Vi())),this.c.hg(this.b,t)},p.Oh=function(){return this.c},p.wi=function(){var t;return t=C0e(this),t?t.Zi():!1},p.b=-1;var Ekn=k(kt,"ENotificationImpl",32);A(371,268,{95:1,91:1,87:1,139:1,174:1,51:1,53:1,103:1,431:1,42:1,92:1,142:1,371:1,268:1,107:1,108:1},oK),p.jg=function(t){return qHe(this,t)},p.ug=function(t,i,a){var l,f,g;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),this.Ab;case 1:return this.zb;case 2:return vt(),!!(this.Bb&256);case 3:return vt(),!!(this.Bb&512);case 4:return He(this.s);case 5:return He(this.t);case 6:return vt(),g=this.t,g>1||g==-1;case 7:return vt(),f=this.s,f>=1;case 8:return i?du(this):this.r;case 9:return this.q;case 10:return this.Db>>16==10?h(this.Cb,24):null;case 11:return!this.d&&(this.d=new Ol(ul,this,11)),this.d;case 12:return!this.c&&(this.c=new ze(ev,this,12,10)),this.c;case 13:return!this.a&&(this.a=new sI(this,this)),this.a;case 14:return $c(this)}return Gl(this,t-jn((Et(),L1)),Vt((l=h(rn(this,16),24),l||L1),t),i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Ga(this.Ab,t,a);case 10:return this.Cb&&(a=(f=this.Db>>16,f>=0?qHe(this,a):this.Cb.Cg(this,-1-f,null,a))),Sl(this,t,10,a);case 12:return!this.c&&(this.c=new ze(ev,this,12,10)),Ga(this.c,t,a)}return g=h(Vt((l=h(rn(this,16),24),l||(Et(),L1)),i),61),g.aj().dj(this,Xa(this),i-jn((Et(),L1)),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Us(this.Ab,t,a);case 9:return nQ(this,a);case 10:return Sl(this,null,10,a);case 11:return!this.d&&(this.d=new Ol(ul,this,11)),Us(this.d,t,a);case 12:return!this.c&&(this.c=new ze(ev,this,12,10)),Us(this.c,t,a);case 14:return Us($c(this),t,a)}return f=h(Vt((l=h(rn(this,16),24),l||(Et(),L1)),i),61),f.aj().ej(this,Xa(this),i-jn((Et(),L1)),t,a)},p.Fg=function(t){var i,a,l;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return(this.Bb&256)==0;case 3:return(this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return l=this.t,l>1||l==-1;case 7:return a=this.s,a>=1;case 8:return!!this.r&&!this.q.e&&_0(this.q).i==0;case 9:return!!this.q&&!(this.r&&!this.q.e&&_0(this.q).i==0);case 10:return!!(this.Db>>16==10&&h(this.Cb,24));case 11:return!!this.d&&this.d.i!=0;case 12:return!!this.c&&this.c.i!=0;case 13:return!!this.a&&$c(this.a.a).i!=0&&!(this.b&&wte(this.b));case 14:return!!this.b&&wte(this.b)}return Ul(this,t-jn((Et(),L1)),Vt((i=h(rn(this,16),24),i||L1),t))},p.Mg=function(t,i){var a,l;switch(t){case 0:!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:Ef(this,Qn(i));return;case 2:C_(this,ce(bt(i)));return;case 3:A_(this,ce(bt(i)));return;case 4:E_(this,h(i,21).a);return;case 5:gS(this,h(i,21).a);return;case 8:xS(this,h(i,133));return;case 9:l=Zg(this,h(i,84),null),l&&l.Th();return;case 11:!this.d&&(this.d=new Ol(ul,this,11)),Pr(this.d),!this.d&&(this.d=new Ol(ul,this,11)),Mr(this.d,h(i,13));return;case 12:!this.c&&(this.c=new ze(ev,this,12,10)),Pr(this.c),!this.c&&(this.c=new ze(ev,this,12,10)),Mr(this.c,h(i,13));return;case 13:!this.a&&(this.a=new sI(this,this)),O7(this.a),!this.a&&(this.a=new sI(this,this)),Mr(this.a,h(i,13));return;case 14:Pr($c(this)),Mr($c(this),h(i,13));return}Vl(this,t-jn((Et(),L1)),Vt((a=h(rn(this,16),24),a||L1),t),i)},p.Rg=function(){return Et(),L1},p.Xg=function(){var t,i;if(this.c)for(t=0,i=this.c.i;tv&&zr(t,v,null),l=0,a=new Dn($c(this.a));a.e!=a.i._b();)i=h(Xn(a),84),g=(m=i.c,m||(Et(),Uh)),zr(t,l++,g);return t},p.ki=function(){var t,i,a,l,f;for(f=new Mp,f.a+="[",t=$c(this.a),i=0,l=$c(this.a).i;i1);case 5:return dA(this,5,i,a,l,this.i-h(a,15)._b()>0);default:return new Vd(this.e,t,this.c,i,a,l,!0)}},p.xi=function(){return!0},p.ui=function(){return wte(this)},p.ij=function(){Pr(this)};var Ckn=k(kt,"EOperationImpl/2",1388);A(456,1,{1631:1,456:1},gNe);var Akn=k(kt,"EPackageImpl/1",456);A(18,88,Wo,ze),p.Lj=function(){return this.d},p.Mj=function(){return this.b},p.Pj=function(){return!0},p.b=0;var Pkn=k(ar,"EObjectContainmentWithInverseEList",18);A(364,18,Wo,YE),p.Qj=function(){return!0},p.zh=function(t,i){return Tx(this,t,h(i,51))};var Lkn=k(ar,"EObjectContainmentWithInverseEList/Resolving",364);A(303,364,Wo,u_),p.th=function(){this.a.tb=null};var kkn=k(kt,"EPackageImpl/2",303);A(1155,1,{},tX);var Rkn=k(kt,"EPackageImpl/3",1155);A(650,44,Nx,fpe),p.Qb=function(t){return ws(t)?gQ(this,t):!!pc(this.d,t)};var Ikn=k(kt,"EPackageRegistryImpl",650);A(468,268,{95:1,91:1,87:1,139:1,174:1,51:1,1703:1,103:1,431:1,42:1,92:1,142:1,468:1,268:1,107:1,108:1},aK),p.jg=function(t){return XHe(this,t)},p.ug=function(t,i,a){var l,f,g;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),this.Ab;case 1:return this.zb;case 2:return vt(),!!(this.Bb&256);case 3:return vt(),!!(this.Bb&512);case 4:return He(this.s);case 5:return He(this.t);case 6:return vt(),g=this.t,g>1||g==-1;case 7:return vt(),f=this.s,f>=1;case 8:return i?du(this):this.r;case 9:return this.q;case 10:return this.Db>>16==10?h(this.Cb,53):null}return Gl(this,t-jn((Et(),nv)),Vt((l=h(rn(this,16),24),l||nv),t),i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Ga(this.Ab,t,a);case 10:return this.Cb&&(a=(f=this.Db>>16,f>=0?XHe(this,a):this.Cb.Cg(this,-1-f,null,a))),Sl(this,t,10,a)}return g=h(Vt((l=h(rn(this,16),24),l||(Et(),nv)),i),61),g.aj().dj(this,Xa(this),i-jn((Et(),nv)),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Us(this.Ab,t,a);case 9:return nQ(this,a);case 10:return Sl(this,null,10,a)}return f=h(Vt((l=h(rn(this,16),24),l||(Et(),nv)),i),61),f.aj().ej(this,Xa(this),i-jn((Et(),nv)),t,a)},p.Fg=function(t){var i,a,l;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return(this.Bb&256)==0;case 3:return(this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return l=this.t,l>1||l==-1;case 7:return a=this.s,a>=1;case 8:return!!this.r&&!this.q.e&&_0(this.q).i==0;case 9:return!!this.q&&!(this.r&&!this.q.e&&_0(this.q).i==0);case 10:return!!(this.Db>>16==10&&h(this.Cb,53))}return Ul(this,t-jn((Et(),nv)),Vt((i=h(rn(this,16),24),i||nv),t))},p.Rg=function(){return Et(),nv};var Dkn=k(kt,"EParameterImpl",468);A(62,418,{95:1,91:1,87:1,139:1,174:1,51:1,17:1,158:1,61:1,103:1,431:1,42:1,92:1,142:1,62:1,418:1,268:1,107:1,108:1,615:1},Jge),p.ug=function(t,i,a){var l,f,g,m;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),this.Ab;case 1:return this.zb;case 2:return vt(),!!(this.Bb&256);case 3:return vt(),!!(this.Bb&512);case 4:return He(this.s);case 5:return He(this.t);case 6:return vt(),m=this.t,m>1||m==-1;case 7:return vt(),f=this.s,f>=1;case 8:return i?du(this):this.r;case 9:return this.q;case 10:return vt(),!!(this.Bb&ef);case 11:return vt(),!!(this.Bb&Rw);case 12:return vt(),!!(this.Bb&V0);case 13:return this.j;case 14:return OS(this);case 15:return vt(),!!(this.Bb&_c);case 16:return vt(),!!(this.Bb&Ch);case 17:return fw(this);case 18:return vt(),!!(this.Bb&Ka);case 19:return vt(),g=Fo(this),!!(g&&g.Bb&Ka);case 20:return vt(),!!(this.Bb&oo);case 21:return i?Fo(this):this.b;case 22:return i?vbe(this):Hze(this);case 23:return!this.a&&(this.a=new HE(Ly,this,23)),this.a}return Gl(this,t-jn((Et(),MM)),Vt((l=h(rn(this,16),24),l||MM),t),i,a)},p.Fg=function(t){var i,a,l,f;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return(this.Bb&256)==0;case 3:return(this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return f=this.t,f>1||f==-1;case 7:return a=this.s,a>=1;case 8:return!!this.r&&!this.q.e&&_0(this.q).i==0;case 9:return!!this.q&&!(this.r&&!this.q.e&&_0(this.q).i==0);case 10:return(this.Bb&ef)==0;case 11:return(this.Bb&Rw)!=0;case 12:return(this.Bb&V0)!=0;case 13:return this.j!=null;case 14:return OS(this)!=null;case 15:return(this.Bb&_c)!=0;case 16:return(this.Bb&Ch)!=0;case 17:return!!fw(this);case 18:return(this.Bb&Ka)!=0;case 19:return l=Fo(this),!!l&&(l.Bb&Ka)!=0;case 20:return(this.Bb&oo)==0;case 21:return!!this.b;case 22:return!!Hze(this);case 23:return!!this.a&&this.a.i!=0}return Ul(this,t-jn((Et(),MM)),Vt((i=h(rn(this,16),24),i||MM),t))},p.Mg=function(t,i){var a,l;switch(t){case 0:!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:SQ(this,Qn(i));return;case 2:C_(this,ce(bt(i)));return;case 3:A_(this,ce(bt(i)));return;case 4:E_(this,h(i,21).a);return;case 5:gS(this,h(i,21).a);return;case 8:xS(this,h(i,133));return;case 9:l=Zg(this,h(i,84),null),l&&l.Th();return;case 10:OU(this,ce(bt(i)));return;case 11:BU(this,ce(bt(i)));return;case 12:FU(this,ce(bt(i)));return;case 13:mge(this,Qn(i));return;case 15:NU(this,ce(bt(i)));return;case 16:UU(this,ce(bt(i)));return;case 18:sLt(this,ce(bt(i)));return;case 20:fWe(this,ce(bt(i)));return;case 21:h$e(this,h(i,17));return;case 23:!this.a&&(this.a=new HE(Ly,this,23)),Pr(this.a),!this.a&&(this.a=new HE(Ly,this,23)),Mr(this.a,h(i,13));return}Vl(this,t-jn((Et(),MM)),Vt((a=h(rn(this,16),24),a||MM),t),i)},p.Rg=function(){return Et(),MM},p.Xg=function(){vbe(this),nS($o((Hc(),Ks),this)),du(this),this.Bb|=1},p.$i=function(){return Fo(this)},p.Cj=function(){var t;return t=Fo(this),!!t&&(t.Bb&Ka)!=0},p.Dj=function(){return(this.Bb&Ka)!=0},p.Ej=function(){return(this.Bb&oo)!=0},p.zj=function(t,i){return this.c=null,Bbe(this,t,i)},p.Ib=function(){var t;return this.Db&64?L7(this):(t=new ru(L7(this)),t.a+=" (containment: ",Cp(t,(this.Bb&Ka)!=0),t.a+=", resolveProxies: ",Cp(t,(this.Bb&oo)!=0),t.a+=")",t.a)};var Bkn=k(kt,"EReferenceImpl",62);A(505,108,{95:1,38:1,91:1,87:1,134:1,51:1,103:1,42:1,92:1,505:1,107:1,108:1},EN),p.Fb=function(t){return this===t},p.kc=function(){return this.b},p.lc=function(){return this.c},p.Hb=function(){return p0(this)},p.kh=function(t){JCt(this,Qn(t))},p.mc=function(t){return GCt(this,Qn(t))},p.ug=function(t,i,a){var l;switch(t){case 0:return this.b;case 1:return this.c}return Gl(this,t-jn((Et(),Uo)),Vt((l=h(rn(this,16),24),l||Uo),t),i,a)},p.Fg=function(t){var i;switch(t){case 0:return this.b!=null;case 1:return this.c!=null}return Ul(this,t-jn((Et(),Uo)),Vt((i=h(rn(this,16),24),i||Uo),t))},p.Mg=function(t,i){var a;switch(t){case 0:QCt(this,Qn(i));return;case 1:s$e(this,Qn(i));return}Vl(this,t-jn((Et(),Uo)),Vt((a=h(rn(this,16),24),a||Uo),t),i)},p.Rg=function(){return Et(),Uo},p.ih=function(){var t;return this.a==-1&&(t=this.b,this.a=t==null?0:Hg(t)),this.a},p.jh=function(t){this.a=t},p.Ib=function(){var t;return this.Db&64?Zu(this):(t=new ru(Zu(this)),t.a+=" (key: ",ho(t,this.b),t.a+=", value: ",ho(t,this.c),t.a+=")",t.a)},p.a=-1,p.b=null,p.c=null;var Ca=k(kt,"EStringToStringMapEntryImpl",505),nut=br(ar,"FeatureMap/Entry/Internal");A(514,1,Sz),p.$j=function(t){return this._j(h(t,42))},p._j=function(t){return this.$j(t)},p.Fb=function(t){var i,a;return this===t?!0:re(t,75)?(i=h(t,75),i.nj()==this.c?(a=this.lc(),a==null?i.lc()==null:Li(a,i.lc())):!1):!1},p.nj=function(){return this.c},p.Hb=function(){var t;return t=this.lc(),Wr(this.c)^(t==null?0:Wr(t))},p.Ib=function(){var t,i;return t=this.c,i=jl(t.Wi()).fh(),t.be(),(i!=null&&i.length!=0?i+":"+t.be():t.be())+"="+this.lc()};var Okn=k(kt,"EStructuralFeatureImpl/BasicFeatureMapEntry",514);A(709,514,Sz,ome),p._j=function(t){return new ome(this.c,t)},p.lc=function(){return this.a},p.ak=function(t,i,a){return NRt(this,t,this.a,i,a)},p.bk=function(t,i,a){return FRt(this,t,this.a,i,a)};var Nkn=k(kt,"EStructuralFeatureImpl/ContainmentUpdatingFeatureMapEntry",709);A(1363,1,{},mNe),p.cj=function(t,i,a,l,f){var g;return g=h(AI(t,this.b),237),g.yk(this.a).hj(l)},p.dj=function(t,i,a,l,f){var g;return g=h(AI(t,this.b),237),g.pk(this.a,l,f)},p.ej=function(t,i,a,l,f){var g;return g=h(AI(t,this.b),237),g.qk(this.a,l,f)},p.fj=function(t,i,a){var l;return l=h(AI(t,this.b),237),l.yk(this.a).ui()},p.gj=function(t,i,a,l){var f;f=h(AI(t,this.b),237),f.yk(this.a).Gc(l)};var Fkn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateFeatureMapDelegator",1363);A(82,1,{},Rp,Vm,Op,qm),p.cj=function(t,i,a,l,f){var g;if(g=i.Tg(a),g==null&&i.Ug(a,g=z_e(this,t)),!f)switch(this.e){case 50:case 41:return h(g,533).Hi();case 40:return h(g,237).vk()}return g},p.dj=function(t,i,a,l,f){var g,m;return m=i.Tg(a),m==null&&i.Ug(a,m=z_e(this,t)),g=h(m,64).xj(l,f),g},p.ej=function(t,i,a,l,f){var g;return g=i.Tg(a),g!=null&&(f=h(g,64).yj(l,f)),f},p.fj=function(t,i,a){var l;return l=i.Tg(a),l!=null&&h(l,81).ui()},p.gj=function(t,i,a,l){var f;f=h(i.Tg(a),81),!f&&i.Ug(a,f=z_e(this,t)),f.Gc(l)},p.b=0,p.e=0;var Ukn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateMany",82);A(461,1,{}),p.dj=function(t,i,a,l,f){throw Y(new Ai)},p.ej=function(t,i,a,l,f){throw Y(new Ai)};var gm,zkn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingle",461);A(702,461,{},j1e),p.cj=function(t,i,a,l,f){return ane(t,t.yg(),t.og())==this.b?this.Ej()&&l?Xte(t):t.yg():null},p.dj=function(t,i,a,l,f){var g,m;return t.yg()&&(f=(g=t.og(),g>=0?t.jg(f):t.yg().Cg(t,-1-g,null,f))),m=gr(t.mg(),this.e),t.lg(l,m,f)},p.ej=function(t,i,a,l,f){var g;return g=gr(t.mg(),this.e),t.lg(null,g,f)},p.fj=function(t,i,a){var l;return l=gr(t.mg(),this.e),!!t.yg()&&t.og()==l},p.gj=function(t,i,a,l){var f,g,m,v,y;if(l!=null&&!hne(this.a,l))throw Y(new xC(Mz+(re(l,51)?Vwe(h(l,51).mg()):N0e(rl(l)))+Tz+this.a+"'"));if(f=t.yg(),m=gr(t.mg(),this.e),Be(l)!==Be(f)||t.og()!=m&&l!=null){if(PS(t,h(l,51)))throw Y(new un(LP+t.Ib()));y=null,f&&(y=(g=t.og(),g>=0?t.jg(null):t.yg().Cg(t,-1-g,null,null))),v=h(l,42),v&&(y=v.Ag(t,gr(v.mg(),this.b),null,y)),y=t.lg(v,m,y),y&&y.Th()}else t.eg()&&t.fg()&&Pi(t,new cs(t,1,m,l,l))},p.Ej=function(){return!1};var Gkn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleContainer",702);A(1364,702,{},Y8e),p.Ej=function(){return!0};var jkn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleContainerResolving",1364);A(512,461,{}),p.cj=function(t,i,a,l,f){var g;return g=i.Tg(a),g==null?this.b:Be(g)===Be(gm)?null:g},p.fj=function(t,i,a){var l;return l=i.Tg(a),l!=null&&(Be(l)===Be(gm)||!Li(l,this.b))},p.gj=function(t,i,a,l){var f,g;t.eg()&&t.fg()?(f=(g=i.Tg(a),g==null?this.b:Be(g)===Be(gm)?null:g),l==null?this.c!=null?(i.Ug(a,null),l=this.b):this.b!=null?i.Ug(a,gm):i.Ug(a,null):(this.ck(l),i.Ug(a,l)),Pi(t,this.d.dk(t,1,this.e,f,l))):l==null?this.c!=null?i.Ug(a,null):this.b!=null?i.Ug(a,gm):i.Ug(a,null):(this.ck(l),i.Ug(a,l))},p.ck=function(t){throw Y(new i8)};var $kn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData",512);A(ay,1,{},zk),p.dk=function(t,i,a,l,f){return new pI(t,i,a,l,f)},p.ek=function(t,i,a,l,f,g){return new I1e(t,i,a,l,f,g)};var GAe,jAe,$Ae,VAe,WAe,HAe,qAe,Bae,XAe,Vkn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator",ay);A(1379,ay,{},nX),p.dk=function(t,i,a,l,f){return new g0e(t,i,a,ce(bt(l)),ce(bt(f)))},p.ek=function(t,i,a,l,f,g){return new V7e(t,i,a,ce(bt(l)),ce(bt(f)),g)};var Wkn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/1",1379);A(1380,ay,{},Gk),p.dk=function(t,i,a,l,f){return new V0e(t,i,a,h(l,192).a,h(f,192).a)},p.ek=function(t,i,a,l,f,g){return new N7e(t,i,a,h(l,192).a,h(f,192).a,g)};var Hkn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/2",1380);A(1381,ay,{},SN),p.dk=function(t,i,a,l,f){return new W0e(t,i,a,h(l,159).a,h(f,159).a)},p.ek=function(t,i,a,l,f,g){return new F7e(t,i,a,h(l,159).a,h(f,159).a,g)};var qkn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/3",1381);A(1382,ay,{},MN),p.dk=function(t,i,a,l,f){return new d0e(t,i,a,ce(Xe(l)),ce(Xe(f)))},p.ek=function(t,i,a,l,f,g){return new U7e(t,i,a,ce(Xe(l)),ce(Xe(f)),g)};var Xkn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/4",1382);A(1383,ay,{},TN),p.dk=function(t,i,a,l,f){return new X0e(t,i,a,h(l,126).a,h(f,126).a)},p.ek=function(t,i,a,l,f,g){return new z7e(t,i,a,h(l,126).a,h(f,126).a,g)};var Ykn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/5",1383);A(1384,ay,{},JT),p.dk=function(t,i,a,l,f){return new p0e(t,i,a,h(l,21).a,h(f,21).a)},p.ek=function(t,i,a,l,f,g){return new G7e(t,i,a,h(l,21).a,h(f,21).a,g)};var Zkn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/6",1384);A(1385,ay,{},iX),p.dk=function(t,i,a,l,f){return new H0e(t,i,a,h(l,149).a,h(f,149).a)},p.ek=function(t,i,a,l,f,g){return new j7e(t,i,a,h(l,149).a,h(f,149).a,g)};var Kkn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/7",1385);A(1386,ay,{},CN),p.dk=function(t,i,a,l,f){return new q0e(t,i,a,h(l,168).a,h(f,168).a)},p.ek=function(t,i,a,l,f,g){return new $7e(t,i,a,h(l,168).a,h(f,168).a,g)};var Jkn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/8",1386);A(1366,512,{},kUe),p.ck=function(t){if(!this.a.Li(t))throw Y(new xC(Mz+rl(t)+Tz+this.a+"'"))};var Qkn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleDataDynamic",1366);A(1367,512,{},B9e),p.ck=function(t){};var eRn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleDataStatic",1367);A(703,512,{}),p.fj=function(t,i,a){var l;return l=i.Tg(a),l!=null},p.gj=function(t,i,a,l){var f,g;t.eg()&&t.fg()?(f=!0,g=i.Tg(a),g==null?(f=!1,g=this.b):Be(g)===Be(gm)&&(g=null),l==null?this.c!=null?(i.Ug(a,null),l=this.b):i.Ug(a,gm):(this.ck(l),i.Ug(a,l)),Pi(t,this.d.ek(t,1,this.e,g,l,!f))):l==null?this.c!=null?i.Ug(a,null):i.Ug(a,gm):(this.ck(l),i.Ug(a,l))};var tRn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleDataUnsettable",703);A(1368,703,{},RUe),p.ck=function(t){if(!this.a.Li(t))throw Y(new xC(Mz+rl(t)+Tz+this.a+"'"))};var nRn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleDataUnsettableDynamic",1368);A(1369,703,{},O9e),p.ck=function(t){};var iRn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleDataUnsettableStatic",1369);A(370,461,{},M9),p.cj=function(t,i,a,l,f){var g,m,v,y,E;if(E=i.Tg(a),this.Zi()&&Be(E)===Be(gm))return null;if(this.Ej()&&l&&E!=null){if(v=h(E,42),v.Eg()&&(y=jg(t,v),v!=y)){if(!hne(this.a,y))throw Y(new xC(Mz+rl(y)+Tz+this.a+"'"));i.Ug(a,E=y),this.Dj()&&(g=h(y,42),m=v.Cg(t,this.b?gr(v.mg(),this.b):-1-gr(t.mg(),this.e),null,null),!g.yg()&&(m=g.Ag(t,this.b?gr(g.mg(),this.b):-1-gr(t.mg(),this.e),null,m)),m&&m.Th()),t.eg()&&t.fg()&&Pi(t,new pI(t,9,this.e,v,y))}return E}else return E},p.dj=function(t,i,a,l,f){var g,m;return m=i.Tg(a),Be(m)===Be(gm)&&(m=null),i.Ug(a,l),this.qi()?Be(m)!==Be(l)&&m!=null&&(g=h(m,42),f=g.Cg(t,gr(g.mg(),this.b),null,f)):this.Dj()&&m!=null&&(f=h(m,42).Cg(t,-1-gr(t.mg(),this.e),null,f)),t.eg()&&t.fg()&&(!f&&(f=new Eg(4)),f.Sh(new pI(t,1,this.e,m,l))),f},p.ej=function(t,i,a,l,f){var g;return g=i.Tg(a),Be(g)===Be(gm)&&(g=null),i.Vg(a),t.eg()&&t.fg()&&(!f&&(f=new Eg(4)),this.Zi()?f.Sh(new pI(t,2,this.e,g,null)):f.Sh(new pI(t,1,this.e,g,null))),f},p.fj=function(t,i,a){var l;return l=i.Tg(a),l!=null},p.gj=function(t,i,a,l){var f,g,m,v,y;if(l!=null&&!hne(this.a,l))throw Y(new xC(Mz+(re(l,51)?Vwe(h(l,51).mg()):N0e(rl(l)))+Tz+this.a+"'"));y=i.Tg(a),v=y!=null,this.Zi()&&Be(y)===Be(gm)&&(y=null),m=null,this.qi()?Be(y)!==Be(l)&&(y!=null&&(f=h(y,42),m=f.Cg(t,gr(f.mg(),this.b),null,null)),l!=null&&(f=h(l,42),m=f.Ag(t,gr(f.mg(),this.b),null,m))):this.Dj()&&Be(y)!==Be(l)&&(y!=null&&(m=h(y,42).Cg(t,-1-gr(t.mg(),this.e),null,null)),l!=null&&(m=h(l,42).Ag(t,-1-gr(t.mg(),this.e),null,m))),l==null&&this.Zi()?i.Ug(a,gm):i.Ug(a,l),t.eg()&&t.fg()?(g=new I1e(t,1,this.e,y,l,this.Zi()&&!v),m?(m.Sh(g),m.Th()):Pi(t,g)):m&&m.Th()},p.qi=function(){return!1},p.Dj=function(){return!1},p.Ej=function(){return!1},p.Zi=function(){return!1};var rRn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObject",370);A(513,370,{},_J),p.Dj=function(){return!0};var sRn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainment",513);A(1372,513,{},WFe),p.Ej=function(){return!0};var oRn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentResolving",1372);A(705,513,{},Yge),p.Zi=function(){return!0};var aRn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentUnsettable",705);A(1374,705,{},HFe),p.Ej=function(){return!0};var cRn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentUnsettableResolving",1374);A(585,513,{},OJ),p.qi=function(){return!0};var lRn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverse",585);A(1373,585,{},Z8e),p.Ej=function(){return!0};var uRn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverseResolving",1373);A(706,585,{},Lme),p.Zi=function(){return!0};var fRn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverseUnsettable",706);A(1375,706,{},K8e),p.Ej=function(){return!0};var hRn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverseUnsettableResolving",1375);A(586,370,{},Xge),p.Ej=function(){return!0};var dRn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolving",586);A(1376,586,{},qFe),p.Zi=function(){return!0};var pRn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolvingUnsettable",1376);A(707,586,{},Pme),p.qi=function(){return!0};var gRn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolvingWithInverse",707);A(1377,707,{},J8e),p.Zi=function(){return!0};var mRn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolvingWithInverseUnsettable",1377);A(1370,370,{},XFe),p.Zi=function(){return!0};var bRn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectUnsettable",1370);A(704,370,{},kme),p.qi=function(){return!0};var wRn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectWithInverse",704);A(1371,704,{},Q8e),p.Zi=function(){return!0};var vRn=k(kt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectWithInverseUnsettable",1371);A(708,514,Sz,y1e),p._j=function(t){return new y1e(this.a,this.c,t)},p.lc=function(){return this.b},p.ak=function(t,i,a){return Q4t(this,t,this.b,a)},p.bk=function(t,i,a){return ekt(this,t,this.b,a)};var _Rn=k(kt,"EStructuralFeatureImpl/InverseUpdatingFeatureMapEntry",708);A(1378,514,Sz,Fze),p.$j=function(t){return new MJ((cr(),MD),this.b.Zg(this.a,t))},p.lc=function(){return null},p.ak=function(t,i,a){return a},p.bk=function(t,i,a){return a};var yRn=k(kt,"EStructuralFeatureImpl/SimpleContentFeatureMapEntry",1378);A(587,514,Sz,MJ),p.$j=function(t){return new MJ(this.c,t)},p.lc=function(){return this.a},p.ak=function(t,i,a){return a},p.bk=function(t,i,a){return a};var xRn=k(kt,"EStructuralFeatureImpl/SimpleFeatureMapEntry",587);A(361,451,Rh,Wb),p.Fh=function(t){return le(Pu,nt,24,t,0,1)},p.Bh=function(){return!1};var ERn=k(kt,"ESuperAdapter/1",361);A(411,399,{95:1,91:1,87:1,139:1,174:1,51:1,103:1,742:1,42:1,92:1,142:1,411:1,107:1,108:1},jk),p.ug=function(t,i,a){var l;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),this.Ab;case 1:return this.zb;case 2:return!this.a&&(this.a=new dI(this,Lo,this)),this.a}return Gl(this,t-jn((Et(),Ry)),Vt((l=h(rn(this,16),24),l||Ry),t),i,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Us(this.Ab,t,a);case 2:return!this.a&&(this.a=new dI(this,Lo,this)),Us(this.a,t,a)}return f=h(Vt((l=h(rn(this,16),24),l||(Et(),Ry)),i),61),f.aj().ej(this,Xa(this),i-jn((Et(),Ry)),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return!!this.a&&this.a.i!=0}return Ul(this,t-jn((Et(),Ry)),Vt((i=h(rn(this,16),24),i||Ry),t))},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(ki,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:Ef(this,Qn(i));return;case 2:!this.a&&(this.a=new dI(this,Lo,this)),Pr(this.a),!this.a&&(this.a=new dI(this,Lo,this)),Mr(this.a,h(i,13));return}Vl(this,t-jn((Et(),Ry)),Vt((a=h(rn(this,16),24),a||Ry),t),i)},p.Rg=function(){return Et(),Ry};var SRn=k(kt,"ETypeParameterImpl",411);A(457,88,Wo,dI),p.ri=function(t,i){return jBt(this,h(t,84),i)},p.si=function(t,i){return $Bt(this,h(t,84),i)};var MRn=k(kt,"ETypeParameterImpl/1",457);A(579,44,Nx,lK),p.Xb=function(){return new bC(this)};var TRn=k(kt,"ETypeParameterImpl/2",579);A(508,ud,pu,bC),p.nc=function(t){return n8e(this,h(t,84))},p.oc=function(t){var i,a,l;for(l=!1,a=t.tc();a.hc();)i=h(a.ic(),84),fr(this.a,i,"")==null&&(l=!0);return l},p.Pb=function(){tl(this.a)},p.pc=function(t){return b0(this.a,t)},p.tc=function(){var t;return t=new Zm(new xp(this.a).a),new wC(t)},p.vc=function(t){return qze(this,t)},p._b=function(){return BE(this.a)};var CRn=k(kt,"ETypeParameterImpl/2/1",508);A(509,1,ys,wC),p.gc=function(t){Ss(this,t)},p.ic=function(){return h(P0(this.a).kc(),84)},p.hc=function(){return this.a.b},p.jc=function(){RGe(this.a)};var ARn=k(kt,"ETypeParameterImpl/2/1/1",509);A(1169,44,Nx,LDe),p.Qb=function(t){return ws(t)?gQ(this,t):!!pc(this.d,t)},p.Vb=function(t){var i,a;return i=ws(t)?Ua(this,t):Ic(pc(this.d,t)),re(i,743)?(a=h(i,743),i=a.mj(),fr(this,h(t,207),i),i):i??(t==null?(yK(),rut):null)};var PRn=k(kt,"EValidatorRegistryImpl",1169);A(1362,638,{95:1,91:1,87:1,430:1,139:1,51:1,103:1,1635:1,42:1,92:1,142:1,107:1,108:1},AN),p.Zg=function(t,i){switch(t.Ni()){case 21:case 22:case 23:case 24:case 26:case 31:case 32:case 37:case 38:case 39:case 40:case 43:case 44:case 48:case 49:case 20:return i==null?null:za(i);case 25:return oRt(i);case 27:return xkt(i);case 28:return Ekt(i);case 29:return i==null?null:sFe(RL[0],h(i,181));case 41:return i==null?"":Um(h(i,274));case 42:return za(i);case 50:return Qn(i);default:throw Y(new un(QS+t.be()+q0))}},p.$g=function(t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee;switch(t.G==-1&&(t.G=(B=jl(t),B?jp(B.bh(),t):-1)),t.G){case 0:return a=new cK,a;case 1:return i=new _N,i;case 2:return l=new lR,l;case 4:return f=new S,f;case 5:return g=new ADe,g;case 6:return m=new CR,m;case 7:return v=new hF,v;case 10:return E=new Du,E;case 11:return C=new oK,C;case 12:return R=new UUe,R;case 13:return N=new aK,N;case 14:return W=new Jge,W;case 17:return V=new EN,V;case 18:return y=new xg,y;case 19:return ee=new jk,ee;default:throw Y(new un(bre+t.zb+q0))}},p._g=function(t,i){switch(t.Ni()){case 20:return i==null?null:new mpe(i);case 21:return i==null?null:new Tg(i);case 23:case 22:return i==null?null:K6t(i);case 26:case 24:return i==null?null:LI(El(i,-128,127)<<24>>24);case 25:return PFt(i);case 27:return tDt(i);case 28:return nDt(i);case 29:return MOt(i);case 32:case 31:return i==null?null:_w(i);case 38:case 37:return i==null?null:new yC(i);case 40:case 39:return i==null?null:He(El(i,zs,zi));case 41:return null;case 42:return i==null,null;case 44:case 43:return i==null?null:n1(F7(i));case 49:case 48:return i==null?null:yS(El(i,Cz,32767)<<16>>16);case 50:return i;default:throw Y(new un(QS+t.be()+q0))}};var LRn=k(kt,"EcoreFactoryImpl",1362);A(504,248,{95:1,91:1,87:1,139:1,174:1,51:1,207:1,103:1,1633:1,42:1,92:1,142:1,248:1,504:1,107:1,108:1,613:1},bUe),p.gb=!1,p.hb=!1;var YAe,iut=!1,kRn=k(kt,"EcorePackageImpl",504);A(1111,1,{743:1},rX),p.mj=function(){return hFe(),sut};var RRn=k(kt,"EcorePackageImpl/1",1111);A(1120,1,ci,$k),p.Li=function(t){return re(t,139)},p.Mi=function(t){return le(mD,nt,139,t,0,1)};var IRn=k(kt,"EcorePackageImpl/10",1120);A(1121,1,ci,PN),p.Li=function(t){return re(t,174)},p.Mi=function(t){return le(Tae,nt,174,t,0,1)};var DRn=k(kt,"EcorePackageImpl/11",1121);A(1122,1,ci,Vk),p.Li=function(t){return re(t,51)},p.Mi=function(t){return le(Kw,nt,51,t,0,1)};var BRn=k(kt,"EcorePackageImpl/12",1122);A(1123,1,ci,sX),p.Li=function(t){return re(t,371)},p.Mi=function(t){return le(lf,Fxe,53,t,0,1)};var ORn=k(kt,"EcorePackageImpl/13",1123);A(1124,1,ci,Wk),p.Li=function(t){return re(t,207)},p.Mi=function(t){return le(oh,nt,207,t,0,1)};var NRn=k(kt,"EcorePackageImpl/14",1124);A(1125,1,ci,ro),p.Li=function(t){return re(t,468)},p.Mi=function(t){return le(ev,nt,1703,t,0,1)};var FRn=k(kt,"EcorePackageImpl/15",1125);A(1126,1,ci,oX),p.Li=function(t){return re(t,62)},p.Mi=function(t){return le(tv,oy,17,t,0,1)};var URn=k(kt,"EcorePackageImpl/16",1126);A(1127,1,ci,aX),p.Li=function(t){return re(t,158)},p.Mi=function(t){return le(Ec,oy,158,t,0,1)};var zRn=k(kt,"EcorePackageImpl/17",1127);A(1128,1,ci,wE),p.Li=function(t){return re(t,431)},p.Mi=function(t){return le(Qw,nt,431,t,0,1)};var GRn=k(kt,"EcorePackageImpl/18",1128);A(1129,1,ci,LN),p.Li=function(t){return re(t,505)},p.Mi=function(t){return le(Ca,_tt,505,t,0,1)};var jRn=k(kt,"EcorePackageImpl/19",1129);A(1112,1,ci,cX),p.Li=function(t){return re(t,335)},p.Mi=function(t){return le(Ly,oy,29,t,0,1)};var $Rn=k(kt,"EcorePackageImpl/2",1112);A(1130,1,ci,lX),p.Li=function(t){return re(t,217)},p.Mi=function(t){return le(Lo,Ntt,84,t,0,1)};var VRn=k(kt,"EcorePackageImpl/20",1130);A(1131,1,ci,yp),p.Li=function(t){return re(t,411)},p.Mi=function(t){return le(ul,nt,742,t,0,1)};var WRn=k(kt,"EcorePackageImpl/21",1131);A(1132,1,ci,uX),p.Li=function(t){return rw(t)},p.Mi=function(t){return le(lo,be,434,t,8,1)};var HRn=k(kt,"EcorePackageImpl/22",1132);A(1133,1,ci,QT),p.Li=function(t){return re(t,173)},p.Mi=function(t){return le(Sc,be,173,t,0,2)};var qRn=k(kt,"EcorePackageImpl/23",1133);A(1134,1,ci,Hk),p.Li=function(t){return re(t,192)},p.Mi=function(t){return le(Hx,be,192,t,0,1)};var XRn=k(kt,"EcorePackageImpl/24",1134);A(1135,1,ci,kN),p.Li=function(t){return re(t,159)},p.Mi=function(t){return le($P,be,159,t,0,1)};var YRn=k(kt,"EcorePackageImpl/25",1135);A(1136,1,ci,RN),p.Li=function(t){return re(t,181)},p.Mi=function(t){return le(zz,be,181,t,0,1)};var ZRn=k(kt,"EcorePackageImpl/26",1136);A(1137,1,ci,Pd),p.Li=function(t){return!1},p.Mi=function(t){return le(dPe,nt,1787,t,0,1)};var KRn=k(kt,"EcorePackageImpl/27",1137);A(1138,1,ci,Hb),p.Li=function(t){return sw(t)},p.Mi=function(t){return le(Eo,be,315,t,7,1)};var JRn=k(kt,"EcorePackageImpl/28",1138);A(1139,1,ci,qk),p.Li=function(t){return re(t,52)},p.Mi=function(t){return le(AAe,Aw,52,t,0,1)};var QRn=k(kt,"EcorePackageImpl/29",1139);A(1113,1,ci,IN),p.Li=function(t){return re(t,469)},p.Mi=function(t){return le(ki,{3:1,4:1,5:1,1627:1},609,t,0,1)};var eIn=k(kt,"EcorePackageImpl/3",1113);A(1140,1,ci,eC),p.Li=function(t){return re(t,525)},p.Mi=function(t){return le(kAe,nt,1634,t,0,1)};var tIn=k(kt,"EcorePackageImpl/30",1140);A(1141,1,ci,DN),p.Li=function(t){return re(t,184)},p.Mi=function(t){return le(ePe,Aw,184,t,0,1)};var nIn=k(kt,"EcorePackageImpl/31",1141);A(1142,1,ci,Xk),p.Li=function(t){return re(t,75)},p.Mi=function(t){return le(Nj,Htt,75,t,0,1)};var iIn=k(kt,"EcorePackageImpl/32",1142);A(1143,1,ci,BN),p.Li=function(t){return re(t,126)},p.Mi=function(t){return le(oM,be,126,t,0,1)};var rIn=k(kt,"EcorePackageImpl/33",1143);A(1144,1,ci,Yk),p.Li=function(t){return re(t,21)},p.Mi=function(t){return le(Ao,be,21,t,0,1)};var sIn=k(kt,"EcorePackageImpl/34",1144);A(1145,1,ci,Zk),p.Li=function(t){return re(t,274)},p.Mi=function(t){return le(Kxe,nt,274,t,0,1)};var oIn=k(kt,"EcorePackageImpl/35",1145);A(1146,1,ci,qb),p.Li=function(t){return re(t,149)},p.Mi=function(t){return le(Z0,be,149,t,0,1)};var aIn=k(kt,"EcorePackageImpl/36",1146);A(1147,1,ci,fX),p.Li=function(t){return re(t,109)},p.Mi=function(t){return le(Jxe,nt,109,t,0,1)};var cIn=k(kt,"EcorePackageImpl/37",1147);A(1148,1,ci,Xb),p.Li=function(t){return re(t,534)},p.Mi=function(t){return le(ZAe,nt,534,t,0,1)};var lIn=k(kt,"EcorePackageImpl/38",1148);A(1149,1,ci,ON),p.Li=function(t){return!1},p.Mi=function(t){return le(pPe,nt,1788,t,0,1)};var uIn=k(kt,"EcorePackageImpl/39",1149);A(1114,1,ci,NN),p.Li=function(t){return re(t,96)},p.Mi=function(t){return le(Pu,nt,24,t,0,1)};var fIn=k(kt,"EcorePackageImpl/4",1114);A(1150,1,ci,Kk),p.Li=function(t){return re(t,168)},p.Mi=function(t){return le(K0,be,168,t,0,1)};var hIn=k(kt,"EcorePackageImpl/40",1150);A(1151,1,ci,hX),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var dIn=k(kt,"EcorePackageImpl/41",1151);A(1152,1,ci,dX),p.Li=function(t){return re(t,532)},p.Mi=function(t){return le(LAe,nt,532,t,0,1)};var pIn=k(kt,"EcorePackageImpl/42",1152);A(1153,1,ci,pX),p.Li=function(t){return!1},p.Mi=function(t){return le(gPe,be,1789,t,0,1)};var gIn=k(kt,"EcorePackageImpl/43",1153);A(1154,1,ci,FN),p.Li=function(t){return re(t,38)},p.Mi=function(t){return le(cy,nt,38,t,0,1)};var mIn=k(kt,"EcorePackageImpl/44",1154);A(1115,1,ci,UN),p.Li=function(t){return re(t,133)},p.Mi=function(t){return le(ah,nt,133,t,0,1)};var bIn=k(kt,"EcorePackageImpl/5",1115);A(1116,1,ci,gX),p.Li=function(t){return re(t,140)},p.Mi=function(t){return le(Rae,nt,140,t,0,1)};var wIn=k(kt,"EcorePackageImpl/6",1116);A(1117,1,ci,zN),p.Li=function(t){return re(t,425)},p.Mi=function(t){return le(Oj,nt,608,t,0,1)};var vIn=k(kt,"EcorePackageImpl/7",1117);A(1118,1,ci,GN),p.Li=function(t){return re(t,525)},p.Mi=function(t){return le(Qp,nt,617,t,0,1)};var _In=k(kt,"EcorePackageImpl/8",1118);A(1119,1,ci,qh),p.Li=function(t){return re(t,430)},p.Mi=function(t){return le(kL,nt,430,t,0,1)};var yIn=k(kt,"EcorePackageImpl/9",1119);A(915,1673,vtt,VDe),p.sh=function(t,i){CIt(this,h(i,380))},p.vh=function(t,i){Vqe(this,t,h(i,380))};var xIn=k(kt,"MinimalEObjectImpl/1ArrayDelegatingAdapterList",915);A(916,136,o5,oUe),p.Oh=function(){return this.a.a};var EIn=k(kt,"MinimalEObjectImpl/1ArrayDelegatingAdapterList/1",916);A(955,954,{},ZNe);var SIn=k("org.eclipse.emf.ecore.plugin","EcorePlugin",955),ZAe=br(qtt,"Resource");A(719,1492,Xtt),p.ik=function(t){},p.jk=function(t){},p.fk=function(){return!this.a&&(this.a=new MR(this)),this.a},p.gk=function(t){var i,a,l,f,g;if(l=t.length,l>0)if(t.charCodeAt(0)==47){for(g=new zl(4),f=1,i=1;i0&&(t=t.substr(0,a)));return sFt(this,t)},p.hk=function(){return this.c},p.Ib=function(){return Um(this.ql)+"@"+(Wr(this)>>>0).toString(16)+" uri='"+this.d+"'"},p.b=!1;var MIn=k(Rre,"ResourceImpl",719);A(1493,719,Xtt,JZ);var TIn=k(Rre,"BinaryResourceImpl",1493);A(1048,629,Tre),p.Gh=function(t){return re(t,51)?PPt(this,h(t,51)):re(t,534)?new Dn(h(t,534).fk()):Be(t)===Be(this.f)?h(t,13).tc():(tA(),vD.a)},p.hc=function(){return Sve(this)},p.a=!1;var CIn=k(ar,"EcoreUtil/ContentTreeIterator",1048);A(1494,1048,Tre,j9e),p.Gh=function(t){return Be(t)===Be(this.f)?h(t,15).tc():new lze(h(t,51))};var AIn=k(Rre,"ResourceImpl/5",1494);A(595,1687,Ott,MR),p.pc=function(t){return this.i<=4?QA(this,t):re(t,42)&&h(t,42).sg()==this.a},p.sh=function(t,i){t==this.i-1&&(this.a.b||(this.a.b=!0))},p.uh=function(t,i){t==0?this.a.b||(this.a.b=!0):GQ(this,t,i)},p.vh=function(t,i){},p.wh=function(t,i,a){},p.pi=function(){return 2},p.Oh=function(){return this.a},p.qi=function(){return!0},p.ri=function(t,i){var a;return a=h(t,42),i=a.Pg(this.a,i),i},p.si=function(t,i){var a;return a=h(t,42),a.Pg(null,i)},p.ti=function(){return!1},p.xh=function(){return!0},p.Fh=function(t){return le(Kw,nt,51,t,0,1)},p.Bh=function(){return!1};var PIn=k(Rre,"ResourceImpl/ContentsEList",595);A(873,1657,Rx,TR),p.fd=function(t){return this.a.qh(t)},p._b=function(){return this.a._b()};var LIn=k(ar,"AbstractSequentialInternalEList/1",873),KAe,JAe,Ks,QAe;A(567,1,{},l9e);var Fj,Uj,kIn=k(ar,"BasicExtendedMetaData",567);A(1023,1,{},bNe),p.kk=function(){return null},p.lk=function(){return this.a==-2&&Rde(this,TOt(this.d,this.b)),this.a},p.mk=function(){return null},p.nk=function(){return yt(),yt(),uo},p.be=function(){return this.c==nM&&gY(this,tHe(this.d,this.b)),this.c},p.ok=function(){return 0},p.a=-2,p.c=nM;var RIn=k(ar,"BasicExtendedMetaData/EClassExtendedMetaDataImpl",1023);A(ef,1,{},H7e),p.kk=function(){return this.a==(uS(),Fj)&&Ide(this,G9t(this.f,this.b)),this.a},p.lk=function(){return 0},p.mk=function(){return this.c==(uS(),Fj)&&mY(this,j9t(this.f,this.b)),this.c},p.nk=function(){return!this.d&&Dde(this,_7t(this.f,this.b)),this.d},p.be=function(){return this.e==nM&&Bde(this,tHe(this.f,this.b)),this.e},p.ok=function(){return this.g==-2&&Ode(this,tOt(this.f,this.b)),this.g},p.e=nM,p.g=-2;var IIn=k(ar,"BasicExtendedMetaData/EDataTypeExtendedMetaDataImpl",ef);A(1022,1,{},wNe),p.b=!1,p.c=!1;var DIn=k(ar,"BasicExtendedMetaData/EPackageExtendedMetaDataImpl",1022);A(1025,1,{},q7e),p.c=-2,p.e=nM,p.f=nM;var BIn=k(ar,"BasicExtendedMetaData/EStructuralFeatureExtendedMetaDataImpl",1025);A(529,565,Wo,b9),p.pi=function(){return this.c},p.Rj=function(){return!1},p.zh=function(t,i){return i},p.c=0;var OIn=k(ar,"EDataTypeEList",529),ePe=br(ar,"FeatureMap");A(90,529,{3:1,4:1,20:1,25:1,41:1,13:1,15:1,49:1,59:1,55:1,52:1,81:1,184:1,237:1,1630:1,64:1},ds),p.bd=function(t,i){$8t(this,t,h(i,75))},p.nc=function(t){return S8t(this,h(t,75))},p.nh=function(t){zAt(this,h(t,75))},p.ri=function(t,i){return JMt(this,h(t,75),i)},p.si=function(t,i){return Mme(this,h(t,75),i)},p.zh=function(t,i){return wGt(this,t,h(i,75))},p.hd=function(t,i){return v9t(this,t,h(i,75))},p.yi=function(t,i){return QMt(this,h(t,75),i)},p.zi=function(t,i){return F8e(this,h(t,75),i)},p.Ai=function(t,i,a){return fOt(this,h(t,75),h(i,75),a)},p.Ch=function(t,i){return Ite(this,t,h(i,75))},p.oc=function(t){var i,a,l,f,g,m,v,y,E;for(y=new w_(t._b()),l=t.tc();l.hc();)if(a=h(l.ic(),75),f=a.nj(),z0(this.e,f))(!f.xh()||!$Q(this,f,a.lc())&&!QA(y,a))&&$n(y,a);else{for(E=al(this.e.mg(),f),i=h(this.g,124),g=!0,m=0;m=0;)if(i=t[this.c],this.k.Bk(i.nj()))return this.j=this.f?i:i.lc(),this.i=-2,!0;return this.i=-1,this.g=-1,!1};var UIn=k(ar,"BasicFeatureMap/FeatureEIterator",377);A(601,377,Th,QK),p.Xj=function(){return!0};var zIn=k(ar,"BasicFeatureMap/ResolvingFeatureEIterator",601);A(871,444,xz,oFe),p.Uh=function(){return this};var GIn=k(ar,"EContentsEList/1",871);A(872,444,xz,PNe),p.Xj=function(){return!1};var jIn=k(ar,"EContentsEList/2",872);A(870,260,Ez,aFe),p.Zj=function(t){},p.hc=function(){return!1},p.Cc=function(){return!1};var $In=k(ar,"EContentsEList/FeatureIteratorImpl/1",870);A(734,529,Wo,Rge),p.th=function(){this.a=!0},p.ui=function(){return this.a},p.ij=function(){var t;Pr(this),ju(this.e)?(t=this.a,this.a=!1,Pi(this.e,new Hu(this.e,2,this.c,t,!1))):this.a=!1},p.a=!1;var VIn=k(ar,"EDataTypeEList/Unsettable",734);A(1566,529,Wo,mFe),p.xh=function(){return!0};var WIn=k(ar,"EDataTypeUniqueEList",1566);A(1567,734,Wo,bFe),p.xh=function(){return!0};var HIn=k(ar,"EDataTypeUniqueEList/Unsettable",1567);A(156,88,Wo,Ol),p.Qj=function(){return!0},p.zh=function(t,i){return Tx(this,t,h(i,51))};var qIn=k(ar,"EObjectContainmentEList/Resolving",156);A(1026,493,Wo,gFe),p.Qj=function(){return!0},p.zh=function(t,i){return Tx(this,t,h(i,51))};var XIn=k(ar,"EObjectContainmentEList/Unsettable/Resolving",1026);A(679,18,Wo,pme),p.th=function(){this.a=!0},p.ui=function(){return this.a},p.ij=function(){var t;Pr(this),ju(this.e)?(t=this.a,this.a=!1,Pi(this.e,new Hu(this.e,2,this.c,t,!1))):this.a=!1},p.a=!1;var YIn=k(ar,"EObjectContainmentWithInverseEList/Unsettable",679);A(1044,679,Wo,v8e),p.Qj=function(){return!0},p.zh=function(t,i){return Tx(this,t,h(i,51))};var ZIn=k(ar,"EObjectContainmentWithInverseEList/Unsettable/Resolving",1044);A(675,450,Wo,Ige),p.th=function(){this.a=!0},p.ui=function(){return this.a},p.ij=function(){var t;Pr(this),ju(this.e)?(t=this.a,this.a=!1,Pi(this.e,new Hu(this.e,2,this.c,t,!1))):this.a=!1},p.a=!1;var KIn=k(ar,"EObjectEList/Unsettable",675);A(376,450,Wo,HE),p.Qj=function(){return!0},p.zh=function(t,i){return Tx(this,t,h(i,51))};var JIn=k(ar,"EObjectResolvingEList",376);A(1554,675,Wo,wFe),p.Qj=function(){return!0},p.zh=function(t,i){return Tx(this,t,h(i,51))};var QIn=k(ar,"EObjectResolvingEList/Unsettable",1554);A(1495,1,{},Bm);var rut,e6n=k(ar,"EObjectValidator",1495);A(496,450,Wo,D9),p.Lj=function(){return this.d},p.Mj=function(){return this.b},p.qi=function(){return!0},p.Pj=function(){return!0},p.b=0;var t6n=k(ar,"EObjectWithInverseEList",496);A(1047,496,Wo,_8e),p.Oj=function(){return!0};var n6n=k(ar,"EObjectWithInverseEList/ManyInverse",1047);A(572,496,Wo,AJ),p.th=function(){this.a=!0},p.ui=function(){return this.a},p.ij=function(){var t;Pr(this),ju(this.e)?(t=this.a,this.a=!1,Pi(this.e,new Hu(this.e,2,this.c,t,!1))):this.a=!1},p.a=!1;var i6n=k(ar,"EObjectWithInverseEList/Unsettable",572);A(1046,572,Wo,y8e),p.Oj=function(){return!0};var r6n=k(ar,"EObjectWithInverseEList/Unsettable/ManyInverse",1046);A(680,496,Wo,gme),p.Qj=function(){return!0},p.zh=function(t,i){return Tx(this,t,h(i,51))};var s6n=k(ar,"EObjectWithInverseResolvingEList",680);A(33,680,Wo,an),p.Oj=function(){return!0};var o6n=k(ar,"EObjectWithInverseResolvingEList/ManyInverse",33);A(681,572,Wo,mme),p.Qj=function(){return!0},p.zh=function(t,i){return Tx(this,t,h(i,51))};var a6n=k(ar,"EObjectWithInverseResolvingEList/Unsettable",681);A(1045,681,Wo,x8e),p.Oj=function(){return!0};var c6n=k(ar,"EObjectWithInverseResolvingEList/Unsettable/ManyInverse",1045);A(1027,565,Wo),p.rh=function(){return(this.b&1792)==0},p.th=function(){this.b|=1},p.Nj=function(){return(this.b&4)!=0},p.qi=function(){return(this.b&40)!=0},p.Oj=function(){return(this.b&16)!=0},p.Pj=function(){return(this.b&8)!=0},p.Qj=function(){return(this.b&Rw)!=0},p.Dj=function(){return(this.b&32)!=0},p.Rj=function(){return(this.b&ef)!=0},p.Li=function(t){return this.d?cze(this.d,t):this.nj().jj().Li(t)},p.ui=function(){return this.b&2?(this.b&1)!=0:this.i!=0},p.xh=function(){return(this.b&128)!=0},p.ij=function(){var t;Pr(this),this.b&2&&(ju(this.e)?(t=(this.b&1)!=0,this.b&=-2,In(this,new Hu(this.e,2,gr(this.e.mg(),this.nj()),t,!1))):this.b&=-2)},p.Bh=function(){return(this.b&1536)==0},p.b=0;var l6n=k(ar,"EcoreEList/Generic",1027);A(1028,1027,Wo,GUe),p.nj=function(){return this.a};var u6n=k(ar,"EcoreEList/Dynamic",1028);A(678,55,Rh,_C),p.Fh=function(t){return zI(this.a.a,t)};var f6n=k(ar,"EcoreEMap/1",678);A(677,88,Wo,o1e),p.sh=function(t,i){n7(this.b,h(i,134))},p.uh=function(t,i){W$e(this.b)},p.vh=function(t,i){Yee(this.b,h(i,134))},p.wh=function(t,i,a){Yee(this.b,h(a,134)),Be(a)===Be(i)&&h(a,134).jh(ASt(h(i,134).kc())),n7(this.b,h(i,134))};var h6n=k(ar,"EcoreEMap/DelegateEObjectContainmentEList",677);A(1042,143,Nxe,Jje);var d6n=k(ar,"EcoreEMap/Unsettable",1042);A(1043,677,Wo,E8e),p.th=function(){this.a=!0},p.ui=function(){return this.a},p.ij=function(){var t;Pr(this),ju(this.e)?(t=this.a,this.a=!1,Pi(this.e,new Hu(this.e,2,this.c,t,!1))):this.a=!1},p.a=!1;var p6n=k(ar,"EcoreEMap/Unsettable/UnsettableDelegateEObjectContainmentEList",1043);A(682,1,ys,lze),p.gc=function(t){Ss(this,t)},p.hc=function(){return UWe(this)},p.ic=function(){var t;return UWe(this),t=this.b,this.b=null,t},p.jc=function(){this.a.jc()};var g6n=k(ar,"EcoreUtil/ProperContentIterator",682);A(1496,1495,{},YX);var sut,m6n=k(ar,"EcoreValidator",1496),out,b6n=br(ar,"FeatureMapUtil/Validator");A(1095,1,{1632:1},mX),p.Bk=function(t){return!0};var w6n=k(ar,"FeatureMapUtil/1",1095);A(692,1,{1632:1},B_e),p.Bk=function(t){var i;return this.c==t?!0:(i=bt(Ii(this.a,t)),i==null?kUt(this,t)?(Qze(this.a,t,(vt(),sM)),!0):(Qze(this.a,t,(vt(),Y0)),!1):i==(vt(),sM))},p.e=!1;var Oae,v6n=k(ar,"FeatureMapUtil/BasicValidator",692);A(693,44,Nx,Age);var _6n=k(ar,"FeatureMapUtil/BasicValidator/Cache",693);A(455,41,{20:1,25:1,41:1,13:1,15:1,52:1,81:1,64:1},qR),p.bd=function(t,i){qYe(this.c,this.b,t,i)},p.nc=function(t){return r7t(this.c,this.b,t)},p.oc=function(t){return ZC(this,t)},p.xj=function(t,i){return a_e(this.c,this.b,t,i)},p.Dh=function(t){return D7(this.c,this.b,t,!1)},p.oh=function(){return $Ne(this.c,this.b)},p.ph=function(){return ySt(this.c,this.b)},p.qh=function(t){return J4t(this.c,this.b,t)},p.yj=function(t,i){return i8e(this,t,i)},p.Pb=function(){xe(this)},p.pc=function(t){return $Q(this.c,this.b,t)},p.qc=function(t){return BRt(this.c,this.b,t)},p.cd=function(t){return D7(this.c,this.b,t,!0)},p.hj=function(t){return this},p.dd=function(t){return ckt(this.c,this.b,t)},p.Wb=function(){return z8(this)},p.ui=function(){return!o6(this.c,this.b)},p.tc=function(){return pRt(this.c,this.b)},p.ed=function(){return gRt(this.c,this.b)},p.fd=function(t){return G6t(this.c,this.b,t)},p.gd=function(t){return qqe(this.c,this.b,t)},p.vc=function(t){return XUt(this.c,this.b,t)},p.hd=function(t,i){return QZe(this.c,this.b,t,i)},p.Gc=function(t){g7(this.c,this.b),ZC(this,h(t,15))},p._b=function(){return f6t(this.c,this.b)},p.yc=function(){return S4t(this.c,this.b)},p.zc=function(t){return lkt(this.c,this.b,t)},p.Ib=function(){var t,i;for(i=new Mp,i.a+="[",t=$Ne(this.c,this.b);Oee(t);)ho(i,YC(e7(t))),Oee(t)&&(i.a+=Ta);return i.a+="]",i.a},p.ij=function(){g7(this.c,this.b)};var y6n=k(ar,"FeatureMapUtil/FeatureEList",455);A(575,32,o5,kQ),p.Mh=function(t){return UA(this,t)},p.Rh=function(t){var i,a,l,f,g,m,v;switch(this.d){case 1:case 2:{if(g=t.Oh(),Be(g)===Be(this.c)&&UA(this,null)==t.Mh(null))return this.g=t.Nh(),t.Lh()==1&&(this.d=1),!0;break}case 3:{switch(f=t.Lh(),f){case 3:{if(g=t.Oh(),Be(g)===Be(this.c)&&UA(this,null)==t.Mh(null))return this.d=5,i=new w_(2),$n(i,this.g),$n(i,t.Nh()),this.g=i,!0;break}}break}case 5:{switch(f=t.Lh(),f){case 3:{if(g=t.Oh(),Be(g)===Be(this.c)&&UA(this,null)==t.Mh(null))return a=h(this.g,13),a.nc(t.Nh()),!0;break}}break}case 4:{switch(f=t.Lh(),f){case 3:{if(g=t.Oh(),Be(g)===Be(this.c)&&UA(this,null)==t.Mh(null))return this.d=1,this.g=t.Nh(),!0;break}case 4:{if(g=t.Oh(),Be(g)===Be(this.c)&&UA(this,null)==t.Mh(null))return this.d=6,v=new w_(2),$n(v,this.n),$n(v,t.Ph()),this.n=v,m=X(q(Rn,1),ii,22,15,[this.o,t.Qh()]),this.g=m,!0;break}}break}case 6:{switch(f=t.Lh(),f){case 4:{if(g=t.Oh(),Be(g)===Be(this.c)&&UA(this,null)==t.Mh(null))return a=h(this.n,13),a.nc(t.Ph()),m=h(this.g,37),l=le(Rn,ii,22,m.length+1,15,1),wc(m,0,l,0,m.length),l[m.length]=t.Qh(),this.g=l,!0;break}}break}}return!1};var x6n=k(ar,"FeatureMapUtil/FeatureENotificationImpl",575);A(501,455,{20:1,25:1,41:1,13:1,15:1,52:1,81:1,184:1,237:1,1630:1,64:1},y9),p.pk=function(t,i,a){return a_e(this.c,t,i,a)},p.qk=function(t,i,a){return E_e(this.c,t,i,a)},p.rk=function(){return this},p.sk=function(t,i){return D6(this.c,t,i)},p.tk=function(t){return h(D7(this.c,this.b,t,!1),75).nj()},p.uk=function(t){return h(D7(this.c,this.b,t,!1),75).lc()},p.vk=function(){return this.a},p.wk=function(t){return!o6(this.c,t)},p.xk=function(t,i){Sne(this.c,t,i)},p.yk=function(t){return a$e(this.c,t)};var E6n=k(ar,"FeatureMapUtil/FeatureFeatureMap",501);A(1094,1,{81:1},yNe),p.hj=function(t){return D7(this.b,this.a,-1,t)},p.ui=function(){return!o6(this.b,this.a)},p.Gc=function(t){Sne(this.b,this.a,t)},p.ij=function(){g7(this.b,this.a)};var S6n=k(ar,"FeatureMapUtil/FeatureValue",1094),v3,Nae,Fae,_3,aut,yD=br(kz,"AnyType");A(603,54,Yd,mK);var M6n=k(kz,"InvalidDatatypeValueException",603),zj=br(kz,Ztt),xD=br(kz,Ktt),tPe=br(kz,Jtt),cut,ga,nPe,iv,lut,uut,fut,hut,dut,put,gut,mut,but,wut,vut,TM,_ut,CM,ED,yut,Iy,Gj,jj,xut,SD,MD;A(735,463,{95:1,91:1,87:1,51:1,42:1,92:1,746:1},upe),p.ug=function(t,i,a){switch(t){case 0:return a?(!this.c&&(this.c=new ds(this,0)),this.c):(!this.c&&(this.c=new ds(this,0)),this.c.b);case 1:return a?(!this.c&&(this.c=new ds(this,0)),h(jc(this.c,(cr(),iv)),184)):(!this.c&&(this.c=new ds(this,0)),h(h(jc(this.c,(cr(),iv)),184),237)).vk();case 2:return a?(!this.b&&(this.b=new ds(this,2)),this.b):(!this.b&&(this.b=new ds(this,2)),this.b.b)}return Gl(this,t-jn(this.Rg()),Vt(this.j&2?(!this.k&&(this.k=new gh),this.k).pj():this.Rg(),t),i,a)},p.Dg=function(t,i,a){var l;switch(i){case 0:return!this.c&&(this.c=new ds(this,0)),k6(this.c,t,a);case 1:return(!this.c&&(this.c=new ds(this,0)),h(h(jc(this.c,(cr(),iv)),184),64)).yj(t,a);case 2:return!this.b&&(this.b=new ds(this,2)),k6(this.b,t,a)}return l=h(Vt(this.j&2?(!this.k&&(this.k=new gh),this.k).pj():this.Rg(),i),61),l.aj().ej(this,B0e(this),i-jn(this.Rg()),t,a)},p.Fg=function(t){switch(t){case 0:return!!this.c&&this.c.i!=0;case 1:return!(!this.c&&(this.c=new ds(this,0)),h(jc(this.c,(cr(),iv)),184)).Wb();case 2:return!!this.b&&this.b.i!=0}return Ul(this,t-jn(this.Rg()),Vt(this.j&2?(!this.k&&(this.k=new gh),this.k).pj():this.Rg(),t))},p.Mg=function(t,i){switch(t){case 0:!this.c&&(this.c=new ds(this,0)),gI(this.c,i);return;case 1:(!this.c&&(this.c=new ds(this,0)),h(h(jc(this.c,(cr(),iv)),184),237)).Gc(i);return;case 2:!this.b&&(this.b=new ds(this,2)),gI(this.b,i);return}Vl(this,t-jn(this.Rg()),Vt(this.j&2?(!this.k&&(this.k=new gh),this.k).pj():this.Rg(),t),i)},p.Rg=function(){return cr(),nPe},p.Ib=function(){var t;return this.j&4?Zu(this):(t=new ru(Zu(this)),t.a+=" (mixed: ",OC(t,this.c),t.a+=", anyAttribute: ",OC(t,this.b),t.a+=")",t.a)};var T6n=k(jr,"AnyTypeImpl",735);A(604,463,{95:1,91:1,87:1,51:1,42:1,92:1,1707:1,604:1},bX),p.ug=function(t,i,a){switch(t){case 0:return this.a;case 1:return this.b}return Gl(this,t-jn((cr(),TM)),Vt(this.j&2?(!this.k&&(this.k=new gh),this.k).pj():TM,t),i,a)},p.Fg=function(t){switch(t){case 0:return this.a!=null;case 1:return this.b!=null}return Ul(this,t-jn((cr(),TM)),Vt(this.j&2?(!this.k&&(this.k=new gh),this.k).pj():TM,t))},p.Mg=function(t,i){switch(t){case 0:jde(this,Qn(i));return;case 1:Vde(this,Qn(i));return}Vl(this,t-jn((cr(),TM)),Vt(this.j&2?(!this.k&&(this.k=new gh),this.k).pj():TM,t),i)},p.Rg=function(){return cr(),TM},p.Ib=function(){var t;return this.j&4?Zu(this):(t=new ru(Zu(this)),t.a+=" (data: ",ho(t,this.a),t.a+=", target: ",ho(t,this.b),t.a+=")",t.a)},p.a=null,p.b=null;var C6n=k(jr,"ProcessingInstructionImpl",604);A(605,735,{95:1,91:1,87:1,51:1,42:1,92:1,746:1,1708:1,605:1},CDe),p.ug=function(t,i,a){switch(t){case 0:return a?(!this.c&&(this.c=new ds(this,0)),this.c):(!this.c&&(this.c=new ds(this,0)),this.c.b);case 1:return a?(!this.c&&(this.c=new ds(this,0)),h(jc(this.c,(cr(),iv)),184)):(!this.c&&(this.c=new ds(this,0)),h(h(jc(this.c,(cr(),iv)),184),237)).vk();case 2:return a?(!this.b&&(this.b=new ds(this,2)),this.b):(!this.b&&(this.b=new ds(this,2)),this.b.b);case 3:return!this.c&&(this.c=new ds(this,0)),Qn(D6(this.c,(cr(),ED),!0));case 4:return bme(this.a,(!this.c&&(this.c=new ds(this,0)),Qn(D6(this.c,(cr(),ED),!0))));case 5:return this.a}return Gl(this,t-jn((cr(),CM)),Vt(this.j&2?(!this.k&&(this.k=new gh),this.k).pj():CM,t),i,a)},p.Fg=function(t){switch(t){case 0:return!!this.c&&this.c.i!=0;case 1:return!(!this.c&&(this.c=new ds(this,0)),h(jc(this.c,(cr(),iv)),184)).Wb();case 2:return!!this.b&&this.b.i!=0;case 3:return!this.c&&(this.c=new ds(this,0)),Qn(D6(this.c,(cr(),ED),!0))!=null;case 4:return bme(this.a,(!this.c&&(this.c=new ds(this,0)),Qn(D6(this.c,(cr(),ED),!0))))!=null;case 5:return!!this.a}return Ul(this,t-jn((cr(),CM)),Vt(this.j&2?(!this.k&&(this.k=new gh),this.k).pj():CM,t))},p.Mg=function(t,i){switch(t){case 0:!this.c&&(this.c=new ds(this,0)),gI(this.c,i);return;case 1:(!this.c&&(this.c=new ds(this,0)),h(h(jc(this.c,(cr(),iv)),184),237)).Gc(i);return;case 2:!this.b&&(this.b=new ds(this,2)),gI(this.b,i);return;case 3:X7e(this,Qn(i));return;case 4:X7e(this,M8e(this.a,i));return;case 5:$de(this,h(i,140));return}Vl(this,t-jn((cr(),CM)),Vt(this.j&2?(!this.k&&(this.k=new gh),this.k).pj():CM,t),i)},p.Rg=function(){return cr(),CM};var A6n=k(jr,"SimpleAnyTypeImpl",605);A(606,463,{95:1,91:1,87:1,51:1,42:1,92:1,1709:1,606:1},TDe),p.ug=function(t,i,a){switch(t){case 0:return a?(!this.a&&(this.a=new ds(this,0)),this.a):(!this.a&&(this.a=new ds(this,0)),this.a.b);case 1:return a?(!this.b&&(this.b=new nl((Et(),Uo),Ca,this,1)),this.b):(!this.b&&(this.b=new nl((Et(),Uo),Ca,this,1)),CI(this.b));case 2:return a?(!this.c&&(this.c=new nl((Et(),Uo),Ca,this,2)),this.c):(!this.c&&(this.c=new nl((Et(),Uo),Ca,this,2)),CI(this.c));case 3:return!this.a&&(this.a=new ds(this,0)),jc(this.a,(cr(),Gj));case 4:return!this.a&&(this.a=new ds(this,0)),jc(this.a,(cr(),jj));case 5:return!this.a&&(this.a=new ds(this,0)),jc(this.a,(cr(),SD));case 6:return!this.a&&(this.a=new ds(this,0)),jc(this.a,(cr(),MD))}return Gl(this,t-jn((cr(),Iy)),Vt(this.j&2?(!this.k&&(this.k=new gh),this.k).pj():Iy,t),i,a)},p.Dg=function(t,i,a){var l;switch(i){case 0:return!this.a&&(this.a=new ds(this,0)),k6(this.a,t,a);case 1:return!this.b&&(this.b=new nl((Et(),Uo),Ca,this,1)),f9(this.b,t,a);case 2:return!this.c&&(this.c=new nl((Et(),Uo),Ca,this,2)),f9(this.c,t,a);case 5:return!this.a&&(this.a=new ds(this,0)),i8e(jc(this.a,(cr(),SD)),t,a)}return l=h(Vt(this.j&2?(!this.k&&(this.k=new gh),this.k).pj():(cr(),Iy),i),61),l.aj().ej(this,B0e(this),i-jn((cr(),Iy)),t,a)},p.Fg=function(t){switch(t){case 0:return!!this.a&&this.a.i!=0;case 1:return!!this.b&&this.b.f!=0;case 2:return!!this.c&&this.c.f!=0;case 3:return!this.a&&(this.a=new ds(this,0)),!z8(jc(this.a,(cr(),Gj)));case 4:return!this.a&&(this.a=new ds(this,0)),!z8(jc(this.a,(cr(),jj)));case 5:return!this.a&&(this.a=new ds(this,0)),!z8(jc(this.a,(cr(),SD)));case 6:return!this.a&&(this.a=new ds(this,0)),!z8(jc(this.a,(cr(),MD)))}return Ul(this,t-jn((cr(),Iy)),Vt(this.j&2?(!this.k&&(this.k=new gh),this.k).pj():Iy,t))},p.Mg=function(t,i){switch(t){case 0:!this.a&&(this.a=new ds(this,0)),gI(this.a,i);return;case 1:!this.b&&(this.b=new nl((Et(),Uo),Ca,this,1)),TU(this.b,i);return;case 2:!this.c&&(this.c=new nl((Et(),Uo),Ca,this,2)),TU(this.c,i);return;case 3:!this.a&&(this.a=new ds(this,0)),xe(jc(this.a,(cr(),Gj))),!this.a&&(this.a=new ds(this,0)),ZC(jc(this.a,Gj),h(i,13));return;case 4:!this.a&&(this.a=new ds(this,0)),xe(jc(this.a,(cr(),jj))),!this.a&&(this.a=new ds(this,0)),ZC(jc(this.a,jj),h(i,13));return;case 5:!this.a&&(this.a=new ds(this,0)),xe(jc(this.a,(cr(),SD))),!this.a&&(this.a=new ds(this,0)),ZC(jc(this.a,SD),h(i,13));return;case 6:!this.a&&(this.a=new ds(this,0)),xe(jc(this.a,(cr(),MD))),!this.a&&(this.a=new ds(this,0)),ZC(jc(this.a,MD),h(i,13));return}Vl(this,t-jn((cr(),Iy)),Vt(this.j&2?(!this.k&&(this.k=new gh),this.k).pj():Iy,t),i)},p.Rg=function(){return cr(),Iy},p.Ib=function(){var t;return this.j&4?Zu(this):(t=new ru(Zu(this)),t.a+=" (mixed: ",OC(t,this.a),t.a+=")",t.a)};var P6n=k(jr,"XMLTypeDocumentRootImpl",606);A(1626,638,{95:1,91:1,87:1,430:1,139:1,51:1,103:1,42:1,92:1,142:1,107:1,108:1,1710:1},tC),p.Zg=function(t,i){switch(t.Ni()){case 7:case 8:case 9:case 10:case 16:case 22:case 23:case 24:case 25:case 26:case 32:case 33:case 34:case 36:case 37:case 44:case 45:case 50:case 51:case 53:case 55:case 56:case 57:case 58:case 60:case 61:case 4:return i==null?null:za(i);case 19:case 28:case 29:case 35:case 38:case 39:case 41:case 46:case 52:case 54:case 5:return Qn(i);case 6:return MMt(h(i,173));case 12:case 47:case 49:case 11:return OKe(this,t,i);case 13:return i==null?null:nzt(h(i,216));case 15:case 14:return i==null?null:kAt(ce(Xe(i)));case 17:return lqe((cr(),i));case 18:return lqe(i);case 21:case 20:return i==null?null:RAt(h(i,126).a);case 27:return TMt(h(i,173));case 30:return RHe((cr(),h(i,15)));case 31:return RHe(h(i,15));case 40:return gMt((cr(),i));case 42:return uqe((cr(),i));case 43:return uqe(i);case 59:case 48:return pMt((cr(),i));default:throw Y(new un(QS+t.be()+q0))}},p.$g=function(t){var i,a,l,f,g;switch(t.G==-1&&(t.G=(a=jl(t),a?jp(a.bh(),t):-1)),t.G){case 0:return i=new upe,i;case 1:return l=new bX,l;case 2:return f=new CDe,f;case 3:return g=new TDe,g;default:throw Y(new un(bre+t.zb+q0))}},p._g=function(t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie;switch(t.Ni()){case 5:case 52:case 4:return i;case 6:return G5t(i);case 8:case 7:return i==null?null:TBt(i);case 9:return i==null?null:LI(El((l=Da(i,!0),l.length>0&&l.charCodeAt(0)==43?l.substr(1,l.length-1):l),-128,127)<<24>>24);case 10:return i==null?null:LI(El((f=Da(i,!0),f.length>0&&f.charCodeAt(0)==43?f.substr(1,f.length-1):f),-128,127)<<24>>24);case 11:return Qn(G0(this,(cr(),fut),i));case 12:return Qn(G0(this,(cr(),hut),i));case 13:return i==null?null:new mpe(Da(i,!0));case 15:case 14:return JFt(i);case 16:return Qn(G0(this,(cr(),dut),i));case 17:return HWe((cr(),i));case 18:return HWe(i);case 28:case 29:case 35:case 38:case 39:case 41:case 54:case 19:return Da(i,!0);case 21:case 20:return l8t(i);case 22:return Qn(G0(this,(cr(),put),i));case 23:return Qn(G0(this,(cr(),gut),i));case 24:return Qn(G0(this,(cr(),mut),i));case 25:return Qn(G0(this,(cr(),but),i));case 26:return Qn(G0(this,(cr(),wut),i));case 27:return M5t(i);case 30:return qWe((cr(),i));case 31:return qWe(i);case 32:return i==null?null:He(El((C=Da(i,!0),C.length>0&&C.charCodeAt(0)==43?C.substr(1,C.length-1):C),zs,zi));case 33:return i==null?null:new Tg((R=Da(i,!0),R.length>0&&R.charCodeAt(0)==43?R.substr(1,R.length-1):R));case 34:return i==null?null:He(El((B=Da(i,!0),B.length>0&&B.charCodeAt(0)==43?B.substr(1,B.length-1):B),zs,zi));case 36:return i==null?null:n1(F7((N=Da(i,!0),N.length>0&&N.charCodeAt(0)==43?N.substr(1,N.length-1):N)));case 37:return i==null?null:n1(F7((W=Da(i,!0),W.length>0&&W.charCodeAt(0)==43?W.substr(1,W.length-1):W)));case 40:return S6t((cr(),i));case 42:return XWe((cr(),i));case 43:return XWe(i);case 44:return i==null?null:new Tg((V=Da(i,!0),V.length>0&&V.charCodeAt(0)==43?V.substr(1,V.length-1):V));case 45:return i==null?null:new Tg((ee=Da(i,!0),ee.length>0&&ee.charCodeAt(0)==43?ee.substr(1,ee.length-1):ee));case 46:return Da(i,!1);case 47:return Qn(G0(this,(cr(),vut),i));case 59:case 48:return E6t((cr(),i));case 49:return Qn(G0(this,(cr(),_ut),i));case 50:return i==null?null:yS(El((ie=Da(i,!0),ie.length>0&&ie.charCodeAt(0)==43?ie.substr(1,ie.length-1):ie),Cz,32767)<<16>>16);case 51:return i==null?null:yS(El((g=Da(i,!0),g.length>0&&g.charCodeAt(0)==43?g.substr(1,g.length-1):g),Cz,32767)<<16>>16);case 53:return Qn(G0(this,(cr(),yut),i));case 55:return i==null?null:yS(El((m=Da(i,!0),m.length>0&&m.charCodeAt(0)==43?m.substr(1,m.length-1):m),Cz,32767)<<16>>16);case 56:return i==null?null:yS(El((v=Da(i,!0),v.length>0&&v.charCodeAt(0)==43?v.substr(1,v.length-1):v),Cz,32767)<<16>>16);case 57:return i==null?null:n1(F7((y=Da(i,!0),y.length>0&&y.charCodeAt(0)==43?y.substr(1,y.length-1):y)));case 58:return i==null?null:n1(F7((E=Da(i,!0),E.length>0&&E.charCodeAt(0)==43?E.substr(1,E.length-1):E)));case 60:return i==null?null:He(El((a=Da(i,!0),a.length>0&&a.charCodeAt(0)==43?a.substr(1,a.length-1):a),zs,zi));case 61:return i==null?null:He(El(Da(i,!0),zs,zi));default:throw Y(new un(QS+t.be()+q0))}};var Eut,iPe,Sut,rPe,L6n=k(jr,"XMLTypeFactoryImpl",1626);A(530,248,{95:1,91:1,87:1,139:1,174:1,51:1,207:1,103:1,42:1,92:1,142:1,248:1,107:1,108:1,613:1,1639:1,530:1},mUe),p.N=!1,p.O=!1;var Mut=!1,k6n=k(jr,"XMLTypePackageImpl",530);A(1569,1,{743:1},L2),p.mj=function(){return p_e(),Dut};var R6n=k(jr,"XMLTypePackageImpl/1",1569);A(1578,1,ci,jN),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var I6n=k(jr,"XMLTypePackageImpl/10",1578);A(1579,1,ci,$N),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var D6n=k(jr,"XMLTypePackageImpl/11",1579);A(1580,1,ci,wX),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var B6n=k(jr,"XMLTypePackageImpl/12",1580);A(1581,1,ci,VN),p.Li=function(t){return sw(t)},p.Mi=function(t){return le(Eo,be,315,t,7,1)};var O6n=k(jr,"XMLTypePackageImpl/13",1581);A(1582,1,ci,k2),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var N6n=k(jr,"XMLTypePackageImpl/14",1582);A(1583,1,ci,vE),p.Li=function(t){return re(t,15)},p.Mi=function(t){return le(_u,Aw,15,t,0,1)};var F6n=k(jr,"XMLTypePackageImpl/15",1583);A(1584,1,ci,vX),p.Li=function(t){return re(t,15)},p.Mi=function(t){return le(_u,Aw,15,t,0,1)};var U6n=k(jr,"XMLTypePackageImpl/16",1584);A(1585,1,ci,WN),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var z6n=k(jr,"XMLTypePackageImpl/17",1585);A(1586,1,ci,HN),p.Li=function(t){return re(t,126)},p.Mi=function(t){return le(oM,be,126,t,0,1)};var G6n=k(jr,"XMLTypePackageImpl/18",1586);A(1587,1,ci,nC),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var j6n=k(jr,"XMLTypePackageImpl/19",1587);A(1570,1,ci,qN),p.Li=function(t){return re(t,746)},p.Mi=function(t){return le(yD,nt,746,t,0,1)};var $6n=k(jr,"XMLTypePackageImpl/2",1570);A(1588,1,ci,iC),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var V6n=k(jr,"XMLTypePackageImpl/20",1588);A(1589,1,ci,Jk),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var W6n=k(jr,"XMLTypePackageImpl/21",1589);A(1590,1,ci,rC),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var H6n=k(jr,"XMLTypePackageImpl/22",1590);A(1591,1,ci,_X),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var q6n=k(jr,"XMLTypePackageImpl/23",1591);A(1592,1,ci,XN),p.Li=function(t){return re(t,173)},p.Mi=function(t){return le(Sc,be,173,t,0,2)};var X6n=k(jr,"XMLTypePackageImpl/24",1592);A(1593,1,ci,sC),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var Y6n=k(jr,"XMLTypePackageImpl/25",1593);A(1594,1,ci,YN),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var Z6n=k(jr,"XMLTypePackageImpl/26",1594);A(1595,1,ci,Qk),p.Li=function(t){return re(t,15)},p.Mi=function(t){return le(_u,Aw,15,t,0,1)};var K6n=k(jr,"XMLTypePackageImpl/27",1595);A(1596,1,ci,yX),p.Li=function(t){return re(t,15)},p.Mi=function(t){return le(_u,Aw,15,t,0,1)};var J6n=k(jr,"XMLTypePackageImpl/28",1596);A(1597,1,ci,ZN),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var Q6n=k(jr,"XMLTypePackageImpl/29",1597);A(1571,1,ci,i0),p.Li=function(t){return re(t,604)},p.Mi=function(t){return le(zj,nt,1707,t,0,1)};var e5n=k(jr,"XMLTypePackageImpl/3",1571);A(1598,1,ci,KN),p.Li=function(t){return re(t,21)},p.Mi=function(t){return le(Ao,be,21,t,0,1)};var t5n=k(jr,"XMLTypePackageImpl/30",1598);A(1599,1,ci,JN),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var n5n=k(jr,"XMLTypePackageImpl/31",1599);A(1600,1,ci,xX),p.Li=function(t){return re(t,149)},p.Mi=function(t){return le(Z0,be,149,t,0,1)};var i5n=k(jr,"XMLTypePackageImpl/32",1600);A(1601,1,ci,QN),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var r5n=k(jr,"XMLTypePackageImpl/33",1601);A(1602,1,ci,EX),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var s5n=k(jr,"XMLTypePackageImpl/34",1602);A(1603,1,ci,SX),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var o5n=k(jr,"XMLTypePackageImpl/35",1603);A(1604,1,ci,r0),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var a5n=k(jr,"XMLTypePackageImpl/36",1604);A(1605,1,ci,eR),p.Li=function(t){return re(t,15)},p.Mi=function(t){return le(_u,Aw,15,t,0,1)};var c5n=k(jr,"XMLTypePackageImpl/37",1605);A(1606,1,ci,tR),p.Li=function(t){return re(t,15)},p.Mi=function(t){return le(_u,Aw,15,t,0,1)};var l5n=k(jr,"XMLTypePackageImpl/38",1606);A(1607,1,ci,nR),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var u5n=k(jr,"XMLTypePackageImpl/39",1607);A(1572,1,ci,oC),p.Li=function(t){return re(t,605)},p.Mi=function(t){return le(xD,nt,1708,t,0,1)};var f5n=k(jr,"XMLTypePackageImpl/4",1572);A(1608,1,ci,R2),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var h5n=k(jr,"XMLTypePackageImpl/40",1608);A(1609,1,ci,ts),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var d5n=k(jr,"XMLTypePackageImpl/41",1609);A(1610,1,ci,aC),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var p5n=k(jr,"XMLTypePackageImpl/42",1610);A(1611,1,ci,iR),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var g5n=k(jr,"XMLTypePackageImpl/43",1611);A(1612,1,ci,Uv),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var m5n=k(jr,"XMLTypePackageImpl/44",1612);A(1613,1,ci,MX),p.Li=function(t){return re(t,168)},p.Mi=function(t){return le(K0,be,168,t,0,1)};var b5n=k(jr,"XMLTypePackageImpl/45",1613);A(1614,1,ci,rR),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var w5n=k(jr,"XMLTypePackageImpl/46",1614);A(1615,1,ci,eF),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var v5n=k(jr,"XMLTypePackageImpl/47",1615);A(1616,1,ci,Gf),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var _5n=k(jr,"XMLTypePackageImpl/48",1616);A(1617,1,ci,TX),p.Li=function(t){return re(t,168)},p.Mi=function(t){return le(K0,be,168,t,0,1)};var y5n=k(jr,"XMLTypePackageImpl/49",1617);A(1573,1,ci,CX),p.Li=function(t){return re(t,606)},p.Mi=function(t){return le(tPe,nt,1709,t,0,1)};var x5n=k(jr,"XMLTypePackageImpl/5",1573);A(1618,1,ci,tF),p.Li=function(t){return re(t,149)},p.Mi=function(t){return le(Z0,be,149,t,0,1)};var E5n=k(jr,"XMLTypePackageImpl/50",1618);A(1619,1,ci,AX),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var S5n=k(jr,"XMLTypePackageImpl/51",1619);A(1620,1,ci,nF),p.Li=function(t){return re(t,21)},p.Mi=function(t){return le(Ao,be,21,t,0,1)};var M5n=k(jr,"XMLTypePackageImpl/52",1620);A(1574,1,ci,PX),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var T5n=k(jr,"XMLTypePackageImpl/6",1574);A(1575,1,ci,LX),p.Li=function(t){return re(t,173)},p.Mi=function(t){return le(Sc,be,173,t,0,2)};var C5n=k(jr,"XMLTypePackageImpl/7",1575);A(1576,1,ci,kX),p.Li=function(t){return rw(t)},p.Mi=function(t){return le(lo,be,434,t,8,1)};var A5n=k(jr,"XMLTypePackageImpl/8",1576);A(1577,1,ci,s0),p.Li=function(t){return re(t,192)},p.Mi=function(t){return le(Hx,be,192,t,0,1)};var P5n=k(jr,"XMLTypePackageImpl/9",1577),ch,eg,OL,$j,J;A(40,54,Yd,Wn);var L5n=k(qp,"RegEx/ParseException",40);A(730,1,{},jf),p.Ck=function(t){return ta*16)throw Y(new Wn(Yn((zn(),ltt))));a=a*16+f}while(!0);if(this.a!=125)throw Y(new Wn(Yn((zn(),utt))));if(a>iM)throw Y(new Wn(Yn((zn(),ftt))));t=a}else{if(f=0,this.c!=0||(f=r1(this.a))<0)throw Y(new Wn(Yn((zn(),Hp))));if(a=f,wi(this),this.c!=0||(f=r1(this.a))<0)throw Y(new Wn(Yn((zn(),Hp))));a=a*16+f,t=a}break;case 117:if(l=0,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Yn((zn(),Hp))));if(i=l,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Yn((zn(),Hp))));if(i=i*16+l,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Yn((zn(),Hp))));if(i=i*16+l,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Yn((zn(),Hp))));i=i*16+l,t=i;break;case 118:if(wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Yn((zn(),Hp))));if(i=l,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Yn((zn(),Hp))));if(i=i*16+l,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Yn((zn(),Hp))));if(i=i*16+l,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Yn((zn(),Hp))));if(i=i*16+l,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Yn((zn(),Hp))));if(i=i*16+l,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Yn((zn(),Hp))));if(i=i*16+l,i>iM)throw Y(new Wn(Yn((zn(),"parser.descappe.4"))));t=i;break;case 65:case 90:case 122:throw Y(new Wn(Yn((zn(),htt))))}return t},p.Ek=function(t){var i;switch(t){case 100:i=(this.e&32)==32?em("Nd",!0):(vi(),Vj);break;case 68:i=(this.e&32)==32?em("Nd",!1):(vi(),uPe);break;case 119:i=(this.e&32)==32?em("IsWord",!0):(vi(),LM);break;case 87:i=(this.e&32)==32?em("IsWord",!1):(vi(),hPe);break;case 115:i=(this.e&32)==32?em("IsSpace",!0):(vi(),y3);break;case 83:i=(this.e&32)==32?em("IsSpace",!1):(vi(),fPe);break;default:throw Y(new ta(hnt+t.toString(16)))}return i},p.Fk=function(t){var i,a,l,f,g,m,v,y,E,C,R,B;for(this.b=1,wi(this),i=null,this.c==0&&this.a==94?(wi(this),t?C=(vi(),vi(),++_r,new vl(5)):(i=(vi(),vi(),++_r,new vl(4)),Ia(i,0,iM),C=(++_r,new vl(4)))):C=(vi(),vi(),++_r,new vl(4)),f=!0;(B=this.c)!=1&&!(B==0&&this.a==93&&!f);){if(f=!1,a=this.a,l=!1,B==10)switch(a){case 100:case 68:case 119:case 87:case 115:case 83:Mw(C,this.Ek(a)),l=!0;break;case 105:case 73:case 99:case 67:a=this.Vk(C,a),a<0&&(l=!0);break;case 112:case 80:if(R=bve(this,a),!R)throw Y(new Wn(Yn((zn(),Pre))));Mw(C,R),l=!0;break;default:a=this.Dk()}else if(B==20){if(m=VE(this.i,58,this.d),m<0)throw Y(new Wn(Yn((zn(),kxe))));if(v=!0,po(this.i,this.d)==94&&(++this.d,v=!1),g=Hf(this.i,this.d,m),y=FGe(g,v,(this.e&512)==512),!y)throw Y(new Wn(Yn((zn(),rtt))));if(Mw(C,y),l=!0,m+1>=this.j||po(this.i,m+1)!=93)throw Y(new Wn(Yn((zn(),kxe))));this.d=m+2}if(wi(this),!l)if(this.c!=0||this.a!=45)Ia(C,a,a);else{if(wi(this),(B=this.c)==1)throw Y(new Wn(Yn((zn(),vz))));B==0&&this.a==93?(Ia(C,a,a),Ia(C,45,45)):(E=this.a,B==10&&(E=this.Dk()),wi(this),Ia(C,a,E))}(this.e&ef)==ef&&this.c==0&&this.a==44&&wi(this)}if(this.c==1)throw Y(new Wn(Yn((zn(),vz))));return i&&(mP(i,C),C=i),U_(C),gP(C),this.b=0,wi(this),C},p.Gk=function(){var t,i,a,l;for(a=this.Fk(!1);(l=this.c)!=7;)if(t=this.a,l==0&&(t==45||t==38)||l==4){if(wi(this),this.c!=9)throw Y(new Wn(Yn((zn(),ott))));if(i=this.Fk(!1),l==4)Mw(a,i);else if(t==45)mP(a,i);else if(t==38)RKe(a,i);else throw Y(new ta("ASSERT"))}else throw Y(new Wn(Yn((zn(),att))));return wi(this),a},p.Hk=function(){var t,i;return t=this.a-48,i=(vi(),vi(),++_r,new _Q(12,null,t)),!this.g&&(this.g=new Yh),vn(this.g,new t8(t)),wi(this),i},p.Ik=function(){return wi(this),vi(),Aut},p.Jk=function(){return wi(this),vi(),Cut},p.Kk=function(){throw Y(new Wn(Yn((zn(),Xl))))},p.Lk=function(){throw Y(new Wn(Yn((zn(),Xl))))},p.Mk=function(){return wi(this),vIt()},p.Nk=function(){return wi(this),vi(),Lut},p.Ok=function(){return wi(this),vi(),Rut},p.Pk=function(){var t;if(this.d>=this.j||((t=po(this.i,this.d++))&65504)!=64)throw Y(new Wn(Yn((zn(),ttt))));return wi(this),vi(),vi(),++_r,new nd(0,t-64)},p.Qk=function(){return wi(this),z7t()},p.Rk=function(){return wi(this),vi(),Iut},p.Sk=function(){var t;return t=(vi(),vi(),++_r,new nd(0,105)),wi(this),t},p.Tk=function(){return wi(this),vi(),kut},p.Uk=function(){return wi(this),vi(),Put},p.Vk=function(t,i){return this.Dk()},p.Wk=function(){return wi(this),vi(),cPe},p.Xk=function(){var t,i,a,l,f;if(this.d+1>=this.j)throw Y(new Wn(Yn((zn(),Jet))));if(l=-1,i=null,t=po(this.i,this.d),49<=t&&t<=57){if(l=t-48,!this.g&&(this.g=new Yh),vn(this.g,new t8(l)),++this.d,po(this.i,this.d)!=41)throw Y(new Wn(Yn((zn(),w1))));++this.d}else switch(t==63&&--this.d,wi(this),i=N_e(this),i.e){case 20:case 21:case 22:case 23:break;case 8:if(this.c!=7)throw Y(new Wn(Yn((zn(),w1))));break;default:throw Y(new Wn(Yn((zn(),Qet))))}if(wi(this),f=D0(this),a=null,f.e==2){if(f.ol()!=2)throw Y(new Wn(Yn((zn(),ett))));a=f.kl(1),f=f.kl(0)}if(this.c!=7)throw Y(new Wn(Yn((zn(),w1))));return wi(this),vi(),vi(),++_r,new fje(l,i,f,a)},p.Yk=function(){return wi(this),vi(),lPe},p.Zk=function(){var t;if(wi(this),t=B9(24,D0(this)),this.c!=7)throw Y(new Wn(Yn((zn(),w1))));return wi(this),t},p.$k=function(){var t;if(wi(this),t=B9(20,D0(this)),this.c!=7)throw Y(new Wn(Yn((zn(),w1))));return wi(this),t},p._k=function(){var t;if(wi(this),t=B9(22,D0(this)),this.c!=7)throw Y(new Wn(Yn((zn(),w1))));return wi(this),t},p.al=function(){var t,i,a,l,f;for(t=0,a=0,i=-1;this.d=this.j)throw Y(new Wn(Yn((zn(),Pxe))));if(i==45){for(++this.d;this.d=this.j)throw Y(new Wn(Yn((zn(),Pxe))))}if(i==58){if(++this.d,wi(this),l=Q9e(D0(this),t,a),this.c!=7)throw Y(new Wn(Yn((zn(),w1))));wi(this)}else if(i==41)++this.d,wi(this),l=Q9e(D0(this),t,a);else throw Y(new Wn(Yn((zn(),Ket))));return l},p.bl=function(){var t;if(wi(this),t=B9(21,D0(this)),this.c!=7)throw Y(new Wn(Yn((zn(),w1))));return wi(this),t},p.cl=function(){var t;if(wi(this),t=B9(23,D0(this)),this.c!=7)throw Y(new Wn(Yn((zn(),w1))));return wi(this),t},p.dl=function(){var t,i;if(wi(this),t=this.f++,i=qJ(D0(this),t),this.c!=7)throw Y(new Wn(Yn((zn(),w1))));return wi(this),i},p.el=function(){var t;if(wi(this),t=qJ(D0(this),0),this.c!=7)throw Y(new Wn(Yn((zn(),w1))));return wi(this),t},p.fl=function(t){return wi(this),this.c==5?(wi(this),C9(t,(vi(),vi(),++_r,new hw(9,t)))):C9(t,(vi(),vi(),++_r,new hw(3,t)))},p.gl=function(t){var i;return wi(this),i=(vi(),vi(),++_r,new XC(2)),this.c==5?(wi(this),c1(i,FL),c1(i,t)):(c1(i,t),c1(i,FL)),i},p.hl=function(t){return wi(this),this.c==5?(wi(this),vi(),vi(),++_r,new hw(9,t)):(vi(),vi(),++_r,new hw(3,t))},p.a=0,p.b=0,p.c=0,p.d=0,p.e=0,p.f=1,p.g=null,p.j=0;var k5n=k(qp,"RegEx/RegexParser",730);A(1564,730,{},kDe),p.Ck=function(t){return!1},p.Dk=function(){return Kve(this)},p.Ek=function(t){return NS(t)},p.Fk=function(t){return gJe(this)},p.Gk=function(){throw Y(new Wn(Yn((zn(),Xl))))},p.Hk=function(){throw Y(new Wn(Yn((zn(),Xl))))},p.Ik=function(){throw Y(new Wn(Yn((zn(),Xl))))},p.Jk=function(){throw Y(new Wn(Yn((zn(),Xl))))},p.Kk=function(){return wi(this),NS(67)},p.Lk=function(){return wi(this),NS(73)},p.Mk=function(){throw Y(new Wn(Yn((zn(),Xl))))},p.Nk=function(){throw Y(new Wn(Yn((zn(),Xl))))},p.Ok=function(){throw Y(new Wn(Yn((zn(),Xl))))},p.Pk=function(){return wi(this),NS(99)},p.Qk=function(){throw Y(new Wn(Yn((zn(),Xl))))},p.Rk=function(){throw Y(new Wn(Yn((zn(),Xl))))},p.Sk=function(){return wi(this),NS(105)},p.Tk=function(){throw Y(new Wn(Yn((zn(),Xl))))},p.Uk=function(){throw Y(new Wn(Yn((zn(),Xl))))},p.Vk=function(t,i){return Mw(t,NS(i)),-1},p.Wk=function(){return wi(this),vi(),vi(),++_r,new nd(0,94)},p.Xk=function(){throw Y(new Wn(Yn((zn(),Xl))))},p.Yk=function(){return wi(this),vi(),vi(),++_r,new nd(0,36)},p.Zk=function(){throw Y(new Wn(Yn((zn(),Xl))))},p.$k=function(){throw Y(new Wn(Yn((zn(),Xl))))},p._k=function(){throw Y(new Wn(Yn((zn(),Xl))))},p.al=function(){throw Y(new Wn(Yn((zn(),Xl))))},p.bl=function(){throw Y(new Wn(Yn((zn(),Xl))))},p.cl=function(){throw Y(new Wn(Yn((zn(),Xl))))},p.dl=function(){var t;if(wi(this),t=qJ(D0(this),0),this.c!=7)throw Y(new Wn(Yn((zn(),w1))));return wi(this),t},p.el=function(){throw Y(new Wn(Yn((zn(),Xl))))},p.fl=function(t){return wi(this),C9(t,(vi(),vi(),++_r,new hw(3,t)))},p.gl=function(t){var i;return wi(this),i=(vi(),vi(),++_r,new XC(2)),c1(i,t),c1(i,FL),i},p.hl=function(t){return wi(this),vi(),vi(),++_r,new hw(3,t)};var Dy=null,AM=null,R5n=k(qp,"RegEx/ParserForXMLSchema",1564);A(112,1,rM,kc),p.il=function(t){throw Y(new ta("Not supported."))},p.jl=function(){return-1},p.kl=function(t){return null},p.ll=function(){return null},p.ml=function(t){},p.nl=function(t){},p.ol=function(){return 0},p.Ib=function(){return this.pl(0)},p.pl=function(t){return this.e==11?".":""},p.e=0;var sPe,PM,NL,Tut,oPe,rv=null,Vj,Uae=null,aPe,FL,zae=null,cPe,lPe,uPe,fPe,hPe,Cut,y3,Aut,Put,Lut,kut,LM,Rut,Iut,_r=0,MVt=k(qp,"RegEx/Token",112);A(130,112,{3:1,130:1,112:1},vl),p.pl=function(t){var i,a,l;if(this.e==4)if(this==aPe)a=".";else if(this==Vj)a="\\d";else if(this==LM)a="\\w";else if(this==y3)a="\\s";else{for(l=new Mp,l.a+="[",i=0;i0&&(l.a+=","),this.b[i]===this.b[i+1]?ho(l,I6(this.b[i])):(ho(l,I6(this.b[i])),l.a+="-",ho(l,I6(this.b[i+1])));l.a+="]",a=l.a}else if(this==uPe)a="\\D";else if(this==hPe)a="\\W";else if(this==fPe)a="\\S";else{for(l=new Mp,l.a+="[^",i=0;i0&&(l.a+=","),this.b[i]===this.b[i+1]?ho(l,I6(this.b[i])):(ho(l,I6(this.b[i])),l.a+="-",ho(l,I6(this.b[i+1])));l.a+="]",a=l.a}return a},p.a=!1,p.c=!1;var I5n=k(qp,"RegEx/RangeToken",130);A(528,1,{528:1},t8),p.a=0;var D5n=k(qp,"RegEx/RegexParser/ReferencePosition",528);A(527,1,{3:1,527:1},nOe),p.Fb=function(t){var i;return t==null||!re(t,527)?!1:(i=h(t,527),pt(this.b,i.b)&&this.a==i.a)},p.Hb=function(){return Hg(this.b+"/"+Hve(this.a))},p.Ib=function(){return this.c.pl(this.a)},p.a=0;var B5n=k(qp,"RegEx/RegularExpression",527);A(195,112,rM,nd),p.jl=function(){return this.a},p.pl=function(t){var i,a;switch(this.e){case 0:switch(this.a){case 124:case 42:case 43:case 63:case 40:case 41:case 46:case 91:case 123:case 92:a="\\"+CJ(this.a&Gr);break;case 12:a="\\f";break;case 10:a="\\n";break;case 13:a="\\r";break;case 9:a="\\t";break;case 27:a="\\e";break;default:this.a>=oo?(i="0"+(this.a>>>0).toString(16),a="\\v"+Hf(i,i.length-6,i.length)):a=""+CJ(this.a&Gr)}break;case 8:this==cPe||this==lPe?a=""+CJ(this.a&Gr):a="\\"+CJ(this.a&Gr);break;default:a=null}return a},p.a=0;var O5n=k(qp,"RegEx/Token/CharToken",195);A(283,112,rM,hw),p.kl=function(t){return this.a},p.ml=function(t){this.b=t},p.nl=function(t){this.c=t},p.ol=function(){return 1},p.pl=function(t){var i;if(this.e==3)if(this.c<0&&this.b<0)i=this.a.pl(t)+"*";else if(this.c==this.b)i=this.a.pl(t)+"{"+this.c+"}";else if(this.c>=0&&this.b>=0)i=this.a.pl(t)+"{"+this.c+","+this.b+"}";else if(this.c>=0&&this.b<0)i=this.a.pl(t)+"{"+this.c+",}";else throw Y(new ta("Token#toString(): CLOSURE "+this.c+Ta+this.b));else if(this.c<0&&this.b<0)i=this.a.pl(t)+"*?";else if(this.c==this.b)i=this.a.pl(t)+"{"+this.c+"}?";else if(this.c>=0&&this.b>=0)i=this.a.pl(t)+"{"+this.c+","+this.b+"}?";else if(this.c>=0&&this.b<0)i=this.a.pl(t)+"{"+this.c+",}?";else throw Y(new ta("Token#toString(): NONGREEDYCLOSURE "+this.c+Ta+this.b));return i},p.b=0,p.c=0;var N5n=k(qp,"RegEx/Token/ClosureToken",283);A(731,112,rM,h1e),p.kl=function(t){return t==0?this.a:this.b},p.ol=function(){return 2},p.pl=function(t){var i;return this.b.e==3&&this.b.kl(0)==this.a?i=this.a.pl(t)+"+":this.b.e==9&&this.b.kl(0)==this.a?i=this.a.pl(t)+"+?":i=this.a.pl(t)+(""+this.b.pl(t)),i};var F5n=k(qp,"RegEx/Token/ConcatToken",731);A(1562,112,rM,fje),p.kl=function(t){if(t==0)return this.d;if(t==1)return this.b;throw Y(new ta("Internal Error: "+t))},p.ol=function(){return this.b?2:1},p.pl=function(t){var i;return this.c>0?i="(?("+this.c+")":this.a.e==8?i="(?("+this.a+")":i="(?"+this.a,this.b?i+=this.d+"|"+this.b+")":i+=this.d+")",i},p.c=0;var U5n=k(qp,"RegEx/Token/ConditionToken",1562);A(1563,112,rM,L7e),p.kl=function(t){return this.b},p.ol=function(){return 1},p.pl=function(t){return"(?"+(this.a==0?"":Hve(this.a))+(this.c==0?"":Hve(this.c))+":"+this.b.pl(t)+")"},p.a=0,p.c=0;var z5n=k(qp,"RegEx/Token/ModifierToken",1563);A(732,112,rM,_1e),p.kl=function(t){return this.a},p.ol=function(){return 1},p.pl=function(t){var i;switch(i=null,this.e){case 6:this.b==0?i="(?:"+this.a.pl(t)+")":i="("+this.a.pl(t)+")";break;case 20:i="(?="+this.a.pl(t)+")";break;case 21:i="(?!"+this.a.pl(t)+")";break;case 22:i="(?<="+this.a.pl(t)+")";break;case 23:i="(?"+this.a.pl(t)+")"}return i},p.b=0;var G5n=k(qp,"RegEx/Token/ParenToken",732);A(474,112,{3:1,112:1,474:1},_Q),p.ll=function(){return this.b},p.pl=function(t){return this.e==12?"\\"+this.a:HNt(this.b)},p.a=0;var j5n=k(qp,"RegEx/Token/StringToken",474);A(427,112,rM,XC),p.il=function(t){c1(this,t)},p.kl=function(t){return h(y0(this.a,t),112)},p.ol=function(){return this.a?this.a.a.c.length:0},p.pl=function(t){var i,a,l,f,g;if(this.e==1){if(this.a.a.c.length==2)i=h(y0(this.a,0),112),a=h(y0(this.a,1),112),a.e==3&&a.kl(0)==i?f=i.pl(t)+"+":a.e==9&&a.kl(0)==i?f=i.pl(t)+"+?":f=i.pl(t)+(""+a.pl(t));else{for(g=new Mp,l=0;l=this.c.b:this.a<=this.c.b},p.Cc=function(){return this.b>0},p.Dc=function(){return this.b},p.Fc=function(){return this.b-1},p.jc=function(){throw Y(new Tp(_nt))},p.a=0,p.b=0;var X5n=k(Zxe,"ExclusiveRange/RangeIterator",230),Yl=QE(yz,"C"),Rn=QE(OP,"I"),ku=QE(GS,"Z"),R1=QE(NP,"J"),Sc=QE(IP,"B"),ks=QE(DP,"D"),sv=QE(BP,"F"),By=QE(FP,"S"),TVt=br("org.eclipse.elk.core.labels","ILabelManager"),dPe=br(Gs,"DiagnosticChain"),pPe=br(qtt,"ResourceSet"),gPe=k(Gs,"InvocationTargetException",null),But=(h8(),T4t),Out=Out=BBt;Qkt(Wde),xRt("permProps",[[[Dz,Bz],[Oz,"gecko1_8"]],[[Dz,Bz],[Oz,"ie10"]],[[Dz,Bz],[Oz,"ie8"]],[[Dz,Bz],[Oz,"ie9"]],[[Dz,Bz],[Oz,"safari"]]]),Out(null,"elk",null)}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],3:[function(c,u,d){"use strict";function b(M,L){if(!(M instanceof L))throw new TypeError("Cannot call a class as a function")}function w(M,L){if(!M)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return L&&(typeof L=="object"||typeof L=="function")?L:M}function _(M,L){if(typeof L!="function"&&L!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof L);M.prototype=Object.create(L&&L.prototype,{constructor:{value:M,enumerable:!1,writable:!0,configurable:!0}}),L&&(Object.setPrototypeOf?Object.setPrototypeOf(M,L):M.__proto__=L)}var x=c("./elk-api.js").default,T=function(M){_(L,M);function L(){var I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};b(this,L);var D=Object.assign({},I),F=!1;try{c.resolve("webworker-threads"),F=!0}catch{}if(I.workerUrl)if(F){var O=c("webworker-threads"),z=O.Worker;D.workerFactory=function(te){return new z(te)}}else console.warn(`Web worker requested but 'webworker-threads' package not installed. Consider installing the package or pass your own 'workerFactory' to ELK's constructor. -... Falling back to non-web worker version. `);if(!V.workerFactory){var gt=p("./elk-worker.min.js"),ft=gt.Worker;V.workerFactory=function(xt){return new ft(xt)}}return y(this,(U.__proto__||Object.getPrototypeOf(U)).call(this,V))}return U}(N);Object.defineProperty(m.exports,"__esModule",{value:!0}),m.exports=B,B.default=B},{"./elk-api.js":1,"./elk-worker.min.js":2,"webworker-threads":8}],4:[function(p,m,_){(function(S,y){var I=p("fs"),N=p("path"),B=N.join,P=N.dirname,U=I.accessSync&&function(et){try{I.accessSync(et)}catch{return!1}return!0}||I.existsSync||N.existsSync,j={arrow:S.env.NODE_BINDINGS_ARROW||" \u2192 ",compiled:S.env.NODE_BINDINGS_COMPILED_DIR||"compiled",platform:S.platform,arch:S.arch,version:S.versions.node,bindings:"bindings.node",try:[["module_root","build","bindings"],["module_root","build","Debug","bindings"],["module_root","build","Release","bindings"],["module_root","out","Debug","bindings"],["module_root","Debug","bindings"],["module_root","out","Release","bindings"],["module_root","Release","bindings"],["module_root","build","default","bindings"],["module_root","compiled","version","platform","arch","bindings"]]};function V(et){typeof et=="string"?et={bindings:et}:et||(et={}),Object.keys(j).map(function(Dt){Dt in et||(et[Dt]=j[Dt])}),et.module_root||(et.module_root=_.getRoot(_.getFileName())),N.extname(et.bindings)!=".node"&&(et.bindings+=".node");for(var Q=[],X=0,gt=et.try.length,ft,xt,Bt;X=0;et--){var Q=U[et];Q==="."?U.splice(et,1):Q===".."?(U.splice(et,1),V++):V&&(U.splice(et,1),V--)}if(j)for(;V--;V)U.unshift("..");return U}var I=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,N=function(U){return I.exec(U).slice(1)};_.resolve=function(){for(var U="",j=!1,V=arguments.length-1;V>=-1&&!j;V--){var et=V>=0?arguments[V]:S.cwd();if(typeof et!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!et)continue;U=et+"/"+U,j=et.charAt(0)==="/"}return U=y(B(U.split("/"),function(Q){return!!Q}),!j).join("/"),(j?"/":"")+U||"."},_.normalize=function(U){var j=_.isAbsolute(U),V=P(U,-1)==="/";return U=y(B(U.split("/"),function(et){return!!et}),!j).join("/"),!U&&!j&&(U="."),U&&V&&(U+="/"),(j?"/":"")+U},_.isAbsolute=function(U){return U.charAt(0)==="/"},_.join=function(){var U=Array.prototype.slice.call(arguments,0);return _.normalize(B(U,function(j,V){if(typeof j!="string")throw new TypeError("Arguments to path.join must be strings");return j}).join("/"))},_.relative=function(U,j){U=_.resolve(U).substr(1),j=_.resolve(j).substr(1);function V(Bt){for(var Dt=0;Dt=0&&Bt[Pt]==="";Pt--);return Dt>Pt?[]:Bt.slice(Dt,Pt-Dt+1)}for(var et=V(U.split("/")),Q=V(j.split("/")),X=Math.min(et.length,Q.length),gt=X,ft=0;ft1)for(var Pt=1;Pt{(function(d){d.parser=function(it,ut){return new h(it,ut)},d.SAXParser=h,d.SAXStream=B,d.createStream=I,d.MAX_BUFFER_LENGTH=64*1024;var s=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];d.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function h(it,ut){if(!(this instanceof h))return new h(it,ut);var kt=this;m(kt),kt.q=kt.c="",kt.bufferCheckPosition=d.MAX_BUFFER_LENGTH,kt.encoding=null,kt.opt=ut||{},kt.opt.lowercase=kt.opt.lowercase||kt.opt.lowercasetags,kt.looseCase=kt.opt.lowercase?"toLowerCase":"toUpperCase",kt.opt.maxEntityCount=kt.opt.maxEntityCount||512,kt.opt.maxEntityDepth=kt.opt.maxEntityDepth||4,kt.entityCount=kt.entityDepth=0,kt.tags=[],kt.closed=kt.closedRoot=kt.sawRoot=!1,kt.tag=kt.error=null,kt.strict=!!it,kt.noscript=!!(it||kt.opt.noscript),kt.state=ot.BEGIN,kt.strictEntities=kt.opt.strictEntities,kt.ENTITIES=kt.strictEntities?Object.create(d.XML_ENTITIES):Object.create(d.ENTITIES),kt.attribList=[],kt.opt.xmlns&&(kt.ns=Object.create(et)),kt.opt.unquotedAttributeValues===void 0&&(kt.opt.unquotedAttributeValues=!it),kt.trackPosition=kt.opt.position!==!1,kt.trackPosition&&(kt.position=kt.line=kt.column=0),be(kt,"onready")}Object.create||(Object.create=function(it){function ut(){}ut.prototype=it;var kt=new ut;return kt}),Object.keys||(Object.keys=function(it){var ut=[];for(var kt in it)it.hasOwnProperty(kt)&&ut.push(kt);return ut});function p(it){for(var ut=Math.max(d.MAX_BUFFER_LENGTH,10),kt=0,Ot=0,ie=s.length;Otut)switch(s[Ot]){case"textNode":hn(it);break;case"cdata":re(it,"oncdata",it.cdata),it.cdata="";break;case"script":re(it,"onscript",it.script),it.script="";break;default:ke(it,"Max buffer length exceeded: "+s[Ot])}kt=Math.max(kt,rn)}var Pn=d.MAX_BUFFER_LENGTH-kt;it.bufferCheckPosition=Pn+it.position}function m(it){for(var ut=0,kt=s.length;ut=2){if(it[0]===255&&it[1]===254)return"utf-16le";if(it[0]===254&&it[1]===255)return"utf-16be"}return it.length>=3&&it[0]===239&&it[1]===187&&it[2]===191?"utf8":it.length>=4?it[0]===60&&it[1]===0&&it[2]===63&&it[3]===0?"utf-16le":it[0]===0&&it[1]===60&&it[2]===0&&it[3]===63?"utf-16be":"utf8":ut?"utf8":null}function B(it,ut){if(!(this instanceof B))return new B(it,ut);S.apply(this),this._parser=new h(it,ut),this.writable=!0,this.readable=!0;var kt=this;this._parser.onend=function(){kt.emit("end")},this._parser.onerror=function(Ot){kt.emit("error",Ot),kt._parser.error=null},this._decoder=null,this._decoderBuffer=null,y.forEach(function(Ot){Object.defineProperty(kt,"on"+Ot,{get:function(){return kt._parser["on"+Ot]},set:function(ie){if(!ie)return kt.removeAllListeners(Ot),kt._parser["on"+Ot]=ie,ie;kt.on(Ot,ie)},enumerable:!0,configurable:!1})})}B.prototype=Object.create(S.prototype,{constructor:{value:B}}),B.prototype._decodeBuffer=function(it,ut){if(this._decoderBuffer&&(it=Buffer.concat([this._decoderBuffer,it]),this._decoderBuffer=null),!this._decoder){var kt=N(it,ut);if(!kt)return this._decoderBuffer=it,"";this._parser.encoding=kt,this._decoder=new TextDecoder(kt)}return this._decoder.decode(it,{stream:!ut})},B.prototype.write=function(it){if(typeof Buffer=="function"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(it))it=this._decodeBuffer(it,!1);else if(this._decoderBuffer){var ut=this._decodeBuffer(Buffer.alloc(0),!0);ut&&(this._parser.write(ut),this.emit("data",ut))}return this._parser.write(it.toString()),this.emit("data",it),!0},B.prototype.end=function(it){if(it&&it.length&&this.write(it),this._decoderBuffer){var ut=this._decodeBuffer(Buffer.alloc(0),!0);ut&&(this._parser.write(ut),this.emit("data",ut))}else if(this._decoder){var kt=this._decoder.decode();kt&&(this._parser.write(kt),this.emit("data",kt))}return this._parser.end(),!0},B.prototype.on=function(it,ut){var kt=this;return!kt._parser["on"+it]&&y.indexOf(it)!==-1&&(kt._parser["on"+it]=function(){var Ot=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);Ot.splice(0,0,it),kt.emit.apply(kt,Ot)}),S.prototype.on.call(kt,it,ut)};var P=/^\[CDATA\[$/i,U=/^DOCTYPE$/i,j="http://www.w3.org/XML/1998/namespace",V="http://www.w3.org/2000/xmlns/",et={xml:j,xmlns:V},Q=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,X=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,gt=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,ft=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function xt(it){return it===" "||it===` -`||it==="\r"||it===" "}function Bt(it){return it==='"'||it==="'"}function Dt(it){return it===">"||xt(it)}function Pt(it,ut){return it.test(ut)}function se(it,ut){return!Pt(it,ut)}var ot=0;d.STATE={BEGIN:ot++,BEGIN_WHITESPACE:ot++,TEXT:ot++,TEXT_ENTITY:ot++,OPEN_WAKA:ot++,SGML_DECL:ot++,SGML_DECL_QUOTED:ot++,DOCTYPE:ot++,DOCTYPE_QUOTED:ot++,DOCTYPE_DTD:ot++,DOCTYPE_DTD_QUOTED:ot++,COMMENT_STARTING:ot++,COMMENT:ot++,COMMENT_ENDING:ot++,COMMENT_ENDED:ot++,CDATA:ot++,CDATA_ENDING:ot++,CDATA_ENDING_2:ot++,PROC_INST:ot++,PROC_INST_BODY:ot++,PROC_INST_ENDING:ot++,OPEN_TAG:ot++,OPEN_TAG_SLASH:ot++,ATTRIB:ot++,ATTRIB_NAME:ot++,ATTRIB_NAME_SAW_WHITE:ot++,ATTRIB_VALUE:ot++,ATTRIB_VALUE_QUOTED:ot++,ATTRIB_VALUE_CLOSED:ot++,ATTRIB_VALUE_UNQUOTED:ot++,ATTRIB_VALUE_ENTITY_Q:ot++,ATTRIB_VALUE_ENTITY_U:ot++,CLOSE_TAG:ot++,CLOSE_TAG_SAW_WHITE:ot++,SCRIPT:ot++,SCRIPT_ENDING:ot++},d.XML_ENTITIES=Object.assign(Object.create(null),{amp:"&",gt:">",lt:"<",quot:'"',apos:"'"}),d.ENTITIES=Object.assign(Object.create(null),{amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830}),Object.keys(d.ENTITIES).forEach(function(it){var ut=d.ENTITIES[it],kt=typeof ut=="number"?String.fromCharCode(ut):ut;d.ENTITIES[it]=kt});for(var Lt in d.STATE)d.STATE[d.STATE[Lt]]=Lt;ot=d.STATE;function be(it,ut,kt){it[ut]&&it[ut](kt)}function ln(it){var ut=it&&it.match(/(?:^|\s)encoding\s*=\s*(['"])([^'"]+)\1/i);return ut?ut[2]:null}function Fn(it){return it?it.toLowerCase().replace(/[^a-z0-9]/g,""):null}function ne(it,ut){let kt=Fn(it),Ot=Fn(ut);return!kt||!Ot?!0:Ot==="utf16"?kt==="utf16le"||kt==="utf16be":kt===Ot}function xe(it,ut){if(!(!it.strict||!it.encoding||!ut||ut.name!=="xml")){var kt=ln(ut.body);kt&&!ne(it.encoding,kt)&&en(it,"XML declaration encoding "+kt+" does not match detected stream encoding "+it.encoding.toUpperCase())}}function re(it,ut,kt){it.textNode&&hn(it),be(it,ut,kt)}function hn(it){it.textNode=Se(it.opt,it.textNode),it.textNode&&be(it,"ontext",it.textNode),it.textNode=""}function Se(it,ut){return it.trim&&(ut=ut.trim()),it.normalize&&(ut=ut.replace(/\s+/g," ")),ut}function ke(it,ut){return hn(it),it.trackPosition&&(ut+=` -Line: `+it.line+` -Column: `+it.column+` -Char: `+it.c),ut=new Error(ut),it.error=ut,be(it,"onerror",ut),it}function mn(it){return it.sawRoot&&!it.closedRoot&&en(it,"Unclosed root tag"),it.state!==ot.BEGIN&&it.state!==ot.BEGIN_WHITESPACE&&it.state!==ot.TEXT&&ke(it,"Unexpected end"),hn(it),it.c="",it.closed=!0,be(it,"onend"),h.call(it,it.strict,it.opt),it}function en(it,ut){if(typeof it!="object"||!(it instanceof h))throw new Error("bad call to strictFail");it.strict&&ke(it,ut)}function Qn(it){it.strict||(it.tagName=it.tagName[it.looseCase]());var ut=it.tags[it.tags.length-1]||it,kt=it.tag={name:it.tagName,attributes:{}};it.opt.xmlns&&(kt.ns=ut.ns),it.attribList.length=0,re(it,"onopentagstart",kt)}function ge(it,ut){var kt=it.indexOf(":"),Ot=kt<0?["",it]:it.split(":"),ie=Ot[0],rn=Ot[1];return ut&&it==="xmlns"&&(ie="xmlns",rn=""),{prefix:ie,local:rn}}function Pe(it){if(it.strict||(it.attribName=it.attribName[it.looseCase]()),it.attribList.indexOf(it.attribName)!==-1||it.tag.attributes.hasOwnProperty(it.attribName)){it.attribName=it.attribValue="";return}if(it.opt.xmlns){var ut=ge(it.attribName,!0),kt=ut.prefix,Ot=ut.local;if(kt==="xmlns")if(Ot==="xml"&&it.attribValue!==j)en(it,"xml: prefix must be bound to "+j+` -Actual: `+it.attribValue);else if(Ot==="xmlns"&&it.attribValue!==V)en(it,"xmlns: prefix must be bound to "+V+` -Actual: `+it.attribValue);else{var ie=it.tag,rn=it.tags[it.tags.length-1]||it;ie.ns===rn.ns&&(ie.ns=Object.create(rn.ns)),ie.ns[Ot]=it.attribValue}it.attribList.push([it.attribName,it.attribValue])}else it.tag.attributes[it.attribName]=it.attribValue,re(it,"onattribute",{name:it.attribName,value:it.attribValue});it.attribName=it.attribValue=""}function ti(it,ut){if(it.opt.xmlns){var kt=it.tag,Ot=ge(it.tagName);kt.prefix=Ot.prefix,kt.local=Ot.local,kt.uri=kt.ns[Ot.prefix]||"",kt.prefix&&!kt.uri&&(en(it,"Unbound namespace prefix: "+JSON.stringify(it.tagName)),kt.uri=Ot.prefix);var ie=it.tags[it.tags.length-1]||it;kt.ns&&ie.ns!==kt.ns&&Object.keys(kt.ns).forEach(function(Jt){re(it,"onopennamespace",{prefix:Jt,uri:kt.ns[Jt]})});for(var rn=0,Pn=it.attribList.length;rn",it.tagName="",it.state=ot.SCRIPT;return}re(it,"onscript",it.script),it.script=""}var ut=it.tags.length,kt=it.tagName;it.strict||(kt=kt[it.looseCase]());for(var Ot=kt;ut--;){var ie=it.tags[ut];if(ie.name!==Ot)en(it,"Unexpected close tag");else break}if(ut<0){en(it,"Unmatched closing tag: "+it.tagName),it.textNode+="",it.state=ot.TEXT;return}it.tagName=kt;for(var rn=it.tags.length;rn-- >ut;){var Pn=it.tag=it.tags.pop();it.tagName=it.tag.name,re(it,"onclosetag",it.tagName);var Tt={};for(var yt in Pn.ns)Tt[yt]=Pn.ns[yt];var ue=it.tags[it.tags.length-1]||it;it.opt.xmlns&&Pn.ns!==ue.ns&&Object.keys(Pn.ns).forEach(function(fn){var An=Pn.ns[fn];re(it,"onclosenamespace",{prefix:fn,uri:An})})}ut===0&&(it.closedRoot=!0),it.tagName=it.attribValue=it.attribName="",it.attribList.length=0,it.state=ot.TEXT}function ki(it){var ut=it.entity,kt=ut.toLowerCase(),Ot,ie="";return it.ENTITIES[ut]?it.ENTITIES[ut]:it.ENTITIES[kt]?it.ENTITIES[kt]:(ut=kt,ut.charAt(0)==="#"&&(ut.charAt(1)==="x"?(ut=ut.slice(2),Ot=parseInt(ut,16),ie=Ot.toString(16)):(ut=ut.slice(1),Ot=parseInt(ut,10),ie=Ot.toString(10))),ut=ut.replace(/^0+/,""),isNaN(Ot)||ie.toLowerCase()!==ut||Ot<0||Ot>1114111||!lr(Ot)?(en(it,"Invalid character entity"),"&"+it.entity+";"):String.fromCodePoint(Ot))}function lr(it){return it===9||it===10||it===13||it>=32&&it<=55295||it>=57344&&it<=65533||it>=65536&&it<=1114111}function pr(it,ut){ut==="<"?(it.state=ot.OPEN_WAKA,it.startTagPosition=it.position):xt(ut)||(en(it,"Non-whitespace before first tag."),it.textNode=ut,it.state=ot.TEXT)}function Kt(it,ut){var kt="";return ut"?(re(ut,"onsgmldeclaration",ut.sgmlDecl),ut.sgmlDecl="",ut.state=ot.TEXT):(Bt(Ot)&&(ut.state=ot.SGML_DECL_QUOTED),ut.sgmlDecl+=Ot);continue;case ot.SGML_DECL_QUOTED:Ot===ut.q&&(ut.state=ot.SGML_DECL,ut.q=""),ut.sgmlDecl+=Ot;continue;case ot.DOCTYPE:Ot===">"?(ut.state=ot.TEXT,re(ut,"ondoctype",ut.doctype),ut.doctype=!0):(ut.doctype+=Ot,Ot==="["?ut.state=ot.DOCTYPE_DTD:Bt(Ot)&&(ut.state=ot.DOCTYPE_QUOTED,ut.q=Ot));continue;case ot.DOCTYPE_QUOTED:ut.doctype+=Ot,Ot===ut.q&&(ut.q="",ut.state=ot.DOCTYPE);continue;case ot.DOCTYPE_DTD:Ot==="]"?(ut.doctype+=Ot,ut.state=ot.DOCTYPE):Ot==="<"?(ut.state=ot.OPEN_WAKA,ut.startTagPosition=ut.position):Bt(Ot)?(ut.doctype+=Ot,ut.state=ot.DOCTYPE_DTD_QUOTED,ut.q=Ot):ut.doctype+=Ot;continue;case ot.DOCTYPE_DTD_QUOTED:ut.doctype+=Ot,Ot===ut.q&&(ut.state=ot.DOCTYPE_DTD,ut.q="");continue;case ot.COMMENT:Ot==="-"?ut.state=ot.COMMENT_ENDING:ut.comment+=Ot;continue;case ot.COMMENT_ENDING:Ot==="-"?(ut.state=ot.COMMENT_ENDED,ut.comment=Se(ut.opt,ut.comment),ut.comment&&re(ut,"oncomment",ut.comment),ut.comment=""):(ut.comment+="-"+Ot,ut.state=ot.COMMENT);continue;case ot.COMMENT_ENDED:Ot!==">"?(en(ut,"Malformed comment"),ut.comment+="--"+Ot,ut.state=ot.COMMENT):ut.doctype&&ut.doctype!==!0?ut.state=ot.DOCTYPE_DTD:ut.state=ot.TEXT;continue;case ot.CDATA:for(var rn=kt-1;Ot&&Ot!=="]";)Ot=Kt(it,kt++),Ot&&ut.trackPosition&&(ut.position++,Ot===` -`?(ut.line++,ut.column=0):ut.column++);ut.cdata+=it.substring(rn,kt-1),Ot==="]"&&(ut.state=ot.CDATA_ENDING);continue;case ot.CDATA_ENDING:Ot==="]"?ut.state=ot.CDATA_ENDING_2:(ut.cdata+="]"+Ot,ut.state=ot.CDATA);continue;case ot.CDATA_ENDING_2:Ot===">"?(ut.cdata&&re(ut,"oncdata",ut.cdata),re(ut,"onclosecdata"),ut.cdata="",ut.state=ot.TEXT):Ot==="]"?ut.cdata+="]":(ut.cdata+="]]"+Ot,ut.state=ot.CDATA);continue;case ot.PROC_INST:Ot==="?"?ut.state=ot.PROC_INST_ENDING:xt(Ot)?ut.state=ot.PROC_INST_BODY:ut.procInstName+=Ot;continue;case ot.PROC_INST_BODY:if(!ut.procInstBody&&xt(Ot))continue;Ot==="?"?ut.state=ot.PROC_INST_ENDING:ut.procInstBody+=Ot;continue;case ot.PROC_INST_ENDING:if(Ot===">"){let ue={name:ut.procInstName,body:ut.procInstBody};xe(ut,ue),re(ut,"onprocessinginstruction",ue),ut.procInstName=ut.procInstBody="",ut.state=ot.TEXT}else ut.procInstBody+="?"+Ot,ut.state=ot.PROC_INST_BODY;continue;case ot.OPEN_TAG:Pt(X,Ot)?ut.tagName+=Ot:(Qn(ut),Ot===">"?ti(ut):Ot==="/"?ut.state=ot.OPEN_TAG_SLASH:(xt(Ot)||en(ut,"Invalid character in tag name"),ut.state=ot.ATTRIB));continue;case ot.OPEN_TAG_SLASH:Ot===">"?(ti(ut,!0),Yi(ut)):(en(ut,"Forward-slash in opening tag not followed by >"),ut.state=ot.ATTRIB);continue;case ot.ATTRIB:if(xt(Ot))continue;Ot===">"?ti(ut):Ot==="/"?ut.state=ot.OPEN_TAG_SLASH:Pt(Q,Ot)?(ut.attribName=Ot,ut.attribValue="",ut.state=ot.ATTRIB_NAME):en(ut,"Invalid attribute name");continue;case ot.ATTRIB_NAME:Ot==="="?ut.state=ot.ATTRIB_VALUE:Ot===">"?(en(ut,"Attribute without value"),ut.attribValue=ut.attribName,Pe(ut),ti(ut)):xt(Ot)?ut.state=ot.ATTRIB_NAME_SAW_WHITE:Pt(X,Ot)?ut.attribName+=Ot:en(ut,"Invalid attribute name");continue;case ot.ATTRIB_NAME_SAW_WHITE:if(Ot==="=")ut.state=ot.ATTRIB_VALUE;else{if(xt(Ot))continue;en(ut,"Attribute without value"),ut.tag.attributes[ut.attribName]="",ut.attribValue="",re(ut,"onattribute",{name:ut.attribName,value:""}),ut.attribName="",Ot===">"?ti(ut):Pt(Q,Ot)?(ut.attribName=Ot,ut.state=ot.ATTRIB_NAME):(en(ut,"Invalid attribute name"),ut.state=ot.ATTRIB)}continue;case ot.ATTRIB_VALUE:if(xt(Ot))continue;Bt(Ot)?(ut.q=Ot,ut.state=ot.ATTRIB_VALUE_QUOTED):(ut.opt.unquotedAttributeValues||ke(ut,"Unquoted attribute value"),ut.state=ot.ATTRIB_VALUE_UNQUOTED,ut.attribValue=Ot);continue;case ot.ATTRIB_VALUE_QUOTED:if(Ot!==ut.q){Ot==="&"?ut.state=ot.ATTRIB_VALUE_ENTITY_Q:ut.attribValue+=Ot;continue}Pe(ut),ut.q="",ut.state=ot.ATTRIB_VALUE_CLOSED;continue;case ot.ATTRIB_VALUE_CLOSED:xt(Ot)?ut.state=ot.ATTRIB:Ot===">"?ti(ut):Ot==="/"?ut.state=ot.OPEN_TAG_SLASH:Pt(Q,Ot)?(en(ut,"No whitespace between attributes"),ut.attribName=Ot,ut.attribValue="",ut.state=ot.ATTRIB_NAME):en(ut,"Invalid attribute name");continue;case ot.ATTRIB_VALUE_UNQUOTED:if(!Dt(Ot)){Ot==="&"?ut.state=ot.ATTRIB_VALUE_ENTITY_U:ut.attribValue+=Ot;continue}Pe(ut),Ot===">"?ti(ut):ut.state=ot.ATTRIB;continue;case ot.CLOSE_TAG:if(ut.tagName)Ot===">"?Yi(ut):Pt(X,Ot)?ut.tagName+=Ot:ut.script?(ut.script+=""?Yi(ut):en(ut,"Invalid characters in closing tag");continue;case ot.TEXT_ENTITY:case ot.ATTRIB_VALUE_ENTITY_Q:case ot.ATTRIB_VALUE_ENTITY_U:var Pn,Tt;switch(ut.state){case ot.TEXT_ENTITY:Pn=ot.TEXT,Tt="textNode";break;case ot.ATTRIB_VALUE_ENTITY_Q:Pn=ot.ATTRIB_VALUE_QUOTED,Tt="attribValue";break;case ot.ATTRIB_VALUE_ENTITY_U:Pn=ot.ATTRIB_VALUE_UNQUOTED,Tt="attribValue";break}if(Ot===";"){var yt=ki(ut);ut.opt.unparsedEntities&&!Object.values(d.XML_ENTITIES).includes(yt)?((ut.entityCount+=1)>ut.opt.maxEntityCount&&ke(ut,"Parsed entity count exceeds max entity count"),(ut.entityDepth+=1)>ut.opt.maxEntityDepth&&ke(ut,"Parsed entity depth exceeds max entity depth"),ut.entity="",ut.state=Pn,ut.write(yt),ut.entityDepth-=1):(ut[Tt]+=yt,ut.entity="",ut.state=Pn)}else Pt(ut.entity.length?ft:gt,Ot)?ut.entity+=Ot:(en(ut,"Invalid character in entity name"),ut[Tt]+="&"+ut.entity+Ot,ut.entity="",ut.state=Pn);continue;default:throw new Error(ut,"Unknown state: "+ut.state)}return ut.position>=ut.bufferCheckPosition&&p(ut),ut}String.fromCodePoint||function(){var it=String.fromCharCode,ut=Math.floor,kt=function(){var Ot=16384,ie=[],rn,Pn,Tt=-1,yt=arguments.length;if(!yt)return"";for(var ue="";++Tt1114111||ut(fn)!==fn)throw RangeError("Invalid code point: "+fn);fn<=65535?ie.push(fn):(fn-=65536,rn=(fn>>10)+55296,Pn=fn%1024+56320,ie.push(rn,Pn)),(Tt+1===yt||ie.length>Ot)&&(ue+=it.apply(null,ie),ie.length=0)}return ue};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:kt,configurable:!0,writable:!0}):String.fromCodePoint=kt}()})(typeof mtt>"u"?mtt.sax={}:mtt)});var UXt=Ld((aJe,FXt)=>{"use strict";var iMe=BXt().parser;function rMe(d){var s=[],h=[],p=s,m;return m=iMe(!0),m.ontext=function(_){_.trim()!==""&&p.push(_)},m.onopentag=function(_){var S;S=[_.name,_.attributes],h.push(p),p.push(S),p=S},m.onclosetag=function(){p=h.pop()},m.write(d).close(),s[0]}FXt.exports=rMe});var HXt=Ld((uJe,jXt)=>{"use strict";function sMe(d){return d&&Object.prototype.toString.call(d)==="[object Object]"}function oMe(d){var s,h=[];return typeof d!="string"?d:(s=d.split(` -`),s.length===1?" "+d:(s.forEach(function(p){if(p.trim()===""){h.push(p);return}h.push(" "+p)}),h.join(` -`)))}function cMe(d){var s=d.split(` -`),h=[];return s.forEach(function(p){p.trim()!==""&&h.push(p)}),h.join(` -`)}function zXt(d){var s,h,p,m;return h="",m=!0,p=d.some(function(_,S,y){if(S===0)return s="<"+_,y.length===1?!0:void 0;if(S===1)if(sMe(_)){if(Object.keys(_).forEach(function(I){s+=" "+I+'="'+_[I]+'"'}),y.length===2)return!0;s+=">";return}else s+=">";switch(typeof _){case"string":case"number":case"boolean":h+=_+` -`;return}m=!1,h+=zXt(_)}),p?s+`/> -`:m?s+cMe(h)+" -`:s+` -`+oMe(h)+" -`}jXt.exports=zXt});var WXt=Ld((lJe,GXt)=>{"use strict";function aMe(d,s){var h=function(){},p=h,m=h;function _(){this._skip=!0}function S(){this._remove=!0}function y(B){this._name=B}function I(B){this._replace=B}function N(B,P){var U,j={attr:{},full:B},V={name:y,skip:_,remove:S,replace:I,_name:void 0,_skip:!1,_remove:!1,_replace:void 0},et=!0,Q,X,gt;if(B!==void 0&&B!==null&&B!==!0&&B!==!1)switch(U=Object.prototype.toString.call(B),U){case"[object String]":case"[object Number]":return;case"[object Array]":if(B.some(function(ft,xt){if(xt===0)return j.name=ft,!1;if(xt===1)return Object.prototype.toString.call(ft)==="[object Object]"&&(et=!1,j.attr=ft),!0}),p.call(V,j,P),V._name&&(B[0]=V._name),V._replace)return V._replace;if(V._remove)return null;if(!V._skip){for(Q=0,X=B.length;Q1||Q===1&&et){if(gt=N(B[Q],j),gt===null){B.splice(Q,1),X-=1;continue}gt&&(B[Q]=gt)}Q+=1}if(m.call(V,j,P),V._name&&(B[0]=V._name),V._replace)return V._replace;if(V._remove)return null}}}s&&(s.enter&&(p=s.enter),s.leave&&(m=s.leave)),N(d,void 0)}GXt.exports=aMe});var tU=Ld((hJe,XXt)=>{"use strict";var $Xt=UXt(),VXt=HXt(),qXt=WXt();XXt.exports={parse:$Xt,stringify:VXt,traverse:qXt,p:$Xt,s:VXt,t:qXt}});var DA=Ld((CI,eU)=>{(function(){var d,s="4.18.1",h=200,p="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",m="Expected a function",_="Invalid `variable` option passed into `_.template`",S="Invalid `imports` option passed into `_.template`",y="__lodash_hash_undefined__",I=500,N="__lodash_placeholder__",B=1,P=2,U=4,j=1,V=2,et=1,Q=2,X=4,gt=8,ft=16,xt=32,Bt=64,Dt=128,Pt=256,se=512,ot=30,Lt="...",be=800,ln=16,Fn=1,ne=2,xe=3,re=1/0,hn=9007199254740991,Se=17976931348623157e292,ke=NaN,mn=4294967295,en=mn-1,Qn=mn>>>1,ge=[["ary",Dt],["bind",et],["bindKey",Q],["curry",gt],["curryRight",ft],["flip",se],["partial",xt],["partialRight",Bt],["rearg",Pt]],Pe="[object Arguments]",ti="[object Array]",Yi="[object AsyncFunction]",ki="[object Boolean]",lr="[object Date]",pr="[object DOMException]",Kt="[object Error]",wn="[object Function]",it="[object GeneratorFunction]",ut="[object Map]",kt="[object Number]",Ot="[object Null]",ie="[object Object]",rn="[object Promise]",Pn="[object Proxy]",Tt="[object RegExp]",yt="[object Set]",ue="[object String]",fn="[object Symbol]",An="[object Undefined]",zn="[object WeakMap]",Li="[object WeakSet]",xi="[object ArrayBuffer]",Jt="[object DataView]",nn="[object Float32Array]",vn="[object Float64Array]",he="[object Int8Array]",Mn="[object Int16Array]",Sn="[object Int32Array]",gn="[object Uint8Array]",Ce="[object Uint8ClampedArray]",dn="[object Uint16Array]",jn="[object Uint32Array]",ar=/\b__p \+= '';/g,gr=/\b(__p \+=) '' \+/g,tr=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Ln=/&(?:amp|lt|gt|quot|#39);/g,Qt=/[&<>"']/g,Mi=RegExp(Ln.source),sn=RegExp(Qt.source),Zn=/<%-([\s\S]+?)%>/g,oi=/<%([\s\S]+?)%>/g,Jr=/<%=([\s\S]+?)%>/g,Bs=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Oc=/^\w*$/,ru=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,fc=/[\\^$.*+?()[\]{}|]/g,il=RegExp(fc.source),va=/^\s+/,Mr=/\s/,tv=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,O0=/\{\n\/\* \[wrapped with (.+)\] \*/,ev=/,? & /,B0=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,F0=/[()=,{}\[\]\/\s]/,nv=/\\(\\)?/g,wg=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,iv=/\w*$/,o3=/^[-+]0x[0-9a-f]+$/i,Rt=/^0b[01]+$/i,ve=/^\[object .+?Constructor\]$/,Je=/^0o[0-7]+$/i,tn=/^(?:0|[1-9]\d*)$/,Ze=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Hi=/($^)/,Pr=/['\n\r\u2028\u2029\\]/g,Gr="\\ud800-\\udfff",hs="\\u0300-\\u036f",Fs="\\ufe20-\\ufe2f",Ms="\\u20d0-\\u20ff",bs=hs+Fs+Ms,Tc="\\u2700-\\u27bf",rl="a-z\\xdf-\\xf6\\xf8-\\xff",Oa="\\xac\\xb1\\xd7\\xf7",wh="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Nr="\\u2000-\\u206f",mr=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",c1="A-Z\\xc0-\\xd6\\xd8-\\xde",dc="\\ufe0e\\ufe0f",vh=Oa+wh+Nr+mr,vg="['\u2019]",ws="["+Gr+"]",$c="["+vh+"]",_a="["+bs+"]",ff="\\d+",Bl="["+Tc+"]",_h="["+rl+"]",a1="[^"+Gr+vh+ff+Tc+rl+c1+"]",Nd="\\ud83c[\\udffb-\\udfff]",ya="(?:"+_a+"|"+Nd+")",_g="[^"+Gr+"]",U0="(?:\\ud83c[\\udde6-\\uddff]){2}",z0="[\\ud800-\\udbff][\\udc00-\\udfff]",yg="["+c1+"]",mb="\\u200d",Ey="(?:"+_h+"|"+a1+")",c3="(?:"+yg+"|"+a1+")",rv="(?:"+vg+"(?:d|ll|m|re|s|t|ve))?",Sy="(?:"+vg+"(?:D|LL|M|RE|S|T|VE))?",Ty=ya+"?",sv="["+dc+"]?",bS="(?:"+mb+"(?:"+[_g,U0,z0].join("|")+")"+sv+Ty+")*",a3="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",bk="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",As=sv+Ty+bS,bp="(?:"+[Bl,U0,z0].join("|")+")"+As,Vc="(?:"+[_g+_a+"?",_a,U0,z0,ws].join("|")+")",wS=RegExp(vg,"g"),u3=RegExp(_a,"g"),ov=RegExp(Nd+"(?="+Nd+")|"+Vc+As,"g"),l3=RegExp([yg+"?"+_h+"+"+rv+"(?="+[$c,yg,"$"].join("|")+")",c3+"+"+Sy+"(?="+[$c,yg+Ey,"$"].join("|")+")",yg+"?"+Ey+"+"+rv,yg+"+"+Sy,bk,a3,ff,bp].join("|"),"g"),j0=RegExp("["+mb+Gr+bs+dc+"]"),h3=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,cv=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],sl=-1,rc={};rc[nn]=rc[vn]=rc[he]=rc[Mn]=rc[Sn]=rc[gn]=rc[Ce]=rc[dn]=rc[jn]=!0,rc[Pe]=rc[ti]=rc[xi]=rc[ki]=rc[Jt]=rc[lr]=rc[Kt]=rc[wn]=rc[ut]=rc[kt]=rc[ie]=rc[Tt]=rc[yt]=rc[ue]=rc[zn]=!1;var Bc={};Bc[Pe]=Bc[ti]=Bc[xi]=Bc[Jt]=Bc[ki]=Bc[lr]=Bc[nn]=Bc[vn]=Bc[he]=Bc[Mn]=Bc[Sn]=Bc[ut]=Bc[kt]=Bc[ie]=Bc[Tt]=Bc[yt]=Bc[ue]=Bc[fn]=Bc[gn]=Bc[Ce]=Bc[dn]=Bc[jn]=!0,Bc[Kt]=Bc[wn]=Bc[zn]=!1;var vS={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},wk={"&":"&","<":"<",">":">",'"':""","'":"'"},_S={"&":"&","<":"<",">":">",""":'"',"'":"'"},f3={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},vk=parseFloat,yS=parseInt,Co=typeof global=="object"&&global&&global.Object===Object&&global,_k=typeof self=="object"&&self&&self.Object===Object&&self,Cc=Co||_k||Function("return this")(),H0=typeof CI=="object"&&CI&&!CI.nodeType&&CI,xg=H0&&typeof eU=="object"&&eU&&!eU.nodeType&&eU,xS=xg&&xg.exports===H0,av=xS&&Co.process,Xf=function(){try{var oe=xg&&xg.require&&xg.require("util").types;return oe||av&&av.binding&&av.binding("util")}catch{}}(),d3=Xf&&Xf.isArrayBuffer,MS=Xf&&Xf.isDate,ES=Xf&&Xf.isMap,Cy=Xf&&Xf.isRegExp,SS=Xf&&Xf.isSet,Od=Xf&&Xf.isTypedArray;function df(oe,_n,$e){switch($e.length){case 0:return oe.call(_n);case 1:return oe.call(_n,$e[0]);case 2:return oe.call(_n,$e[0],$e[1]);case 3:return oe.call(_n,$e[0],$e[1],$e[2])}return oe.apply(_n,$e)}function TS(oe,_n,$e,er){for(var vs=-1,Wo=oe==null?0:oe.length;++vs-1}function ky(oe,_n,$e){for(var er=-1,vs=oe==null?0:oe.length;++er-1;);return $e}function G0(oe,_n){for(var $e=oe.length;$e--&&vp(_n,oe[$e],0)>-1;);return $e}function Mk(oe,_n){for(var $e=oe.length,er=0;$e--;)oe[$e]===_n&&++er;return er}var lv=uv(vS),PS=uv(wk);function Dy(oe){return"\\"+f3[oe]}function Ek(oe,_n){return oe==null?d:oe[_n]}function gf(oe){return j0.test(oe)}function Ny(oe){return h3.test(oe)}function Sk(oe){for(var _n,$e=[];!(_n=oe.next()).done;)$e.push(_n.value);return $e}function hv(oe){var _n=-1,$e=Array(oe.size);return oe.forEach(function(er,vs){$e[++_n]=[vs,er]}),$e}function IS(oe,_n){return function($e){return oe(_n($e))}}function Fl(oe,_n){for(var $e=-1,er=oe.length,vs=0,Wo=[];++$e-1}function tz(x,C){var F=this.__data__,J=k3(F,x);return J<0?(++this.size,F.push([x,C])):F[J][1]=C,this}q0.prototype.clear=YU,q0.prototype.delete=KU,q0.prototype.get=JU,q0.prototype.has=QU,q0.prototype.set=tz;function X0(x){var C=-1,F=x==null?0:x.length;for(this.clear();++C=C?x:C)),x}function _p(x,C,F,J,mt,St){var Vt,ee=C&B,fe=C&P,Cn=C&U;if(F&&(Vt=mt?F(x,J,mt,St):F(x)),Vt!==d)return Vt;if(!$a(x))return x;var kn=Us(x);if(kn){if(Vt=Qz(x),!ee)return td(x,Vt)}else{var Wn=zh(x),Ki=Wn==wn||Wn==it;if(zd(x))return VR(x,ee);if(Wn==ie||Wn==Pe||Ki&&!mt){if(Vt=fe||Ki?{}:h8(x),!ee)return fe?Hz(x,gz(Vt,x)):jz(x,MR(Vt,x))}else{if(!Bc[Wn])return mt?x:{};Vt=tj(x,Wn,ee)}}St||(St=new d1);var Er=St.get(x);if(Er)return Er;St.set(x,Vt),Z8(x)?x.forEach(function(Zr){Vt.add(_p(Zr,C,F,Zr,x,St))}):q8(x)&&x.forEach(function(Zr,co){Vt.set(co,_p(Zr,C,F,co,x,St))});var Wr=Cn?fe?Qk:Jk:fe?ed:Hl,no=kn?d:Wr(x);return su(no||x,function(Zr,co){no&&(co=Zr,Zr=x[co]),A3(Vt,co,_p(Zr,C,F,co,x,St))}),Vt}function mz(x){var C=Hl(x);return function(F){return ER(F,x,C)}}function ER(x,C,F){var J=F.length;if(x==null)return!J;for(x=Fc(x);J--;){var mt=F[J],St=C[mt],Vt=x[mt];if(Vt===d&&!(mt in x)||!St(Vt))return!1}return!0}function SR(x,C,F){if(typeof x!="function")throw new Jf(m);return F3(function(){x.apply(d,F)},C)}function L3(x,C,F,J){var mt=-1,St=Ay,Vt=!0,ee=x.length,fe=[],Cn=C.length;if(!ee)return fe;F&&(C=ea(C,Fu(F))),J?(St=ky,Vt=!1):C.length>=h&&(St=pf,Vt=!1,C=new wv(C));t:for(;++mtmt?0:mt+F),J=J===d||J>mt?mt:Ys(J),J<0&&(J+=mt),J=F>J?0:K8(J);F0&&F(ee)?C>1?yh(ee,C-1,F,J,mt):Mg(mt,ee):J||(mt[mt.length]=ee)}return mt}var zS=JR(),I3=JR(!0);function Lg(x,C){return x&&zS(x,C,Hl)}function jS(x,C){return x&&I3(x,C,Hl)}function HS(x,C){return wp(C,function(F){return tm(x[F])})}function Z0(x,C){C=Ab(C,x);for(var F=0,J=C.length;x!=null&&FC}function vz(x,C){return x!=null&&pc.call(x,C)}function _z(x,C){return x!=null&&C in Fc(x)}function yz(x,C,F){return x>=$t(C,F)&&x=120&&kn.length>=120)?new wv(Vt&&kn):d}kn=x[0];var Wn=-1,Ki=ee[0];t:for(;++Wn-1;)ee!==x&&Wy.call(ee,fe,1),Wy.call(x,fe,1);return x}function FR(x,C){for(var F=x?C.length:0,J=F-1;F--;){var mt=C[F];if(F==J||mt!==St){var St=mt;J0(mt)?Wy.call(x,mt,1):$k(x,mt)}}return x}function Hk(x,C){return x+$y(Un()*(C-x+1))}function Lz(x,C,F,J){for(var mt=-1,St=vt(mv((C-x)/(F||1)),0),Vt=$e(St);St--;)Vt[J?St:++mt]=x,x+=F;return Vt}function Gk(x,C){var F="";if(!x||C<1||C>hn)return F;do C%2&&(F+=x),C=$y(C/2),C&&(x+=x);while(C);return F}function oo(x,C){return o5(p8(x,C,Ba),x+"")}function Pz(x){return xR(Jy(x))}function Iz(x,C){var F=Jy(x);return QS(F,vv(C,0,F.length))}function N3(x,C,F,J){if(!$a(x))return x;C=Ab(C,x);for(var mt=-1,St=C.length,Vt=St-1,ee=x;ee!=null&&++mtmt?0:mt+C),F=F>mt?mt:F,F<0&&(F+=mt),mt=C>F?0:F-C>>>0,C>>>=0;for(var St=$e(mt);++J>>1,Vt=x[St];Vt!==null&&!jd(Vt)&&(F?Vt<=C:Vt=h){var Cn=C?null:Vz(x);if(Cn)return Oy(Cn);Vt=!1,mt=pf,fe=new wv}else fe=C?[]:ee;t:for(;++J=J?x:yp(x,C,F)}var $R=DS||function(x){return Cc.clearTimeout(x)};function VR(x,C){if(C)return x.slice();var F=x.length,J=pv?pv(F):new x.constructor(F);return x.copy(J),J}function Zk(x){var C=new x.constructor(x.byteLength);return new Gy(C).set(new Gy(x)),C}function Bz(x,C){var F=C?Zk(x.buffer):x.buffer;return new x.constructor(F,x.byteOffset,x.byteLength)}function Fz(x){var C=new x.constructor(x.source,iv.exec(x));return C.lastIndex=x.lastIndex,C}function Uz(x){return Ag?Fc(Ag.call(x)):{}}function qR(x,C){var F=C?Zk(x.buffer):x.buffer;return new x.constructor(F,x.byteOffset,x.length)}function XR(x,C){if(x!==C){var F=x!==d,J=x===null,mt=x===x,St=jd(x),Vt=C!==d,ee=C===null,fe=C===C,Cn=jd(C);if(!ee&&!Cn&&!St&&x>C||St&&Vt&&fe&&!ee&&!Cn||J&&Vt&&fe||!F&&fe||!mt)return 1;if(!J&&!St&&!Cn&&x=ee)return fe;var Cn=F[J];return fe*(Cn=="desc"?-1:1)}}return x.index-C.index}function ZR(x,C,F,J){for(var mt=-1,St=x.length,Vt=F.length,ee=-1,fe=C.length,Cn=vt(St-Vt,0),kn=$e(fe+Cn),Wn=!J;++ee1?F[mt-1]:d,Vt=mt>2?F[2]:d;for(St=x.length>3&&typeof St=="function"?(mt--,St):d,Vt&&jh(F[0],F[1],Vt)&&(St=mt<3?d:St,mt=1),C=Fc(C);++J-1?mt[St?C[Vt]:Vt]:d}}function e8(x){return K0(function(C){var F=C.length,J=F,mt=bf.prototype.thru;for(x&&C.reverse();J--;){var St=C[J];if(typeof St!="function")throw new Jf(m);if(mt&&!Vt&&KS(St)=="wrapper")var Vt=new bf([],!0)}for(J=Vt?J:F;++J1&&$o.reverse(),kn&&feee))return!1;var Cn=St.get(x),kn=St.get(C);if(Cn&&kn)return Cn==C&&kn==x;var Wn=-1,Ki=!0,Er=F&V?new wv:d;for(St.set(x,C),St.set(C,x);++Wn1?"& ":"")+C[J],C=C.join(F>2?", ":" "),x.replace(tv,`{ -/* [wrapped with `+C+`] */ -`)}function nj(x){return Us(x)||Sv(x)||!!(C3&&x&&x[C3])}function J0(x,C){var F=typeof x;return C=C??hn,!!C&&(F=="number"||F!="symbol"&&tn.test(x))&&x>-1&&x%1==0&&x0){if(++C>=be)return arguments[0]}else C=0;return x.apply(d,arguments)}}function QS(x,C){var F=-1,J=x.length,mt=J-1;for(C=C===d?J:C;++F1?x[C-1]:d;return F=typeof F=="function"?(x.pop(),F):d,Q0(x,F)});function R8(x){var C=Mt(x);return C.__chain__=!0,C}function Pnt(x,C){return C(x),x}function d5(x,C){return C(x)}var Int=K0(function(x){var C=x.length,F=C?x[0]:0,J=this.__wrapped__,mt=function(St){return Dk(St,x)};return C>1||this.__actions__.length||!(J instanceof po)||!J0(F)?this.thru(mt):(J=J.slice(F,+F+(C?1:0)),J.__actions__.push({func:d5,args:[mt],thisArg:d}),new bf(J,this.__chain__).thru(function(St){return C&&!St.length&&St.push(d),St}))});function Rnt(){return R8(this)}function Dnt(){return new bf(this.value(),this.__chain__)}function jl(){this.__values__===d&&(this.__values__=Y8(this.value()));var x=this.__index__>=this.__values__.length,C=x?d:this.__values__[this.__index__++];return{done:x,value:C}}function Nnt(){return this}function Ont(x){for(var C,F=this;F instanceof Mb;){var J=_8(F);J.__index__=0,J.__values__=d,C?mt.__wrapped__=J:C=J;var mt=J;F=F.__wrapped__}return mt.__wrapped__=x,C}function Bnt(){var x=this.__wrapped__;if(x instanceof po){var C=x;return this.__actions__.length&&(C=new po(this)),C=C.reverse(),C.__actions__.push({func:d5,args:[u5],thisArg:d}),new bf(C,this.__chain__)}return this.thru(u5)}function Uj(){return GR(this.__wrapped__,this.__actions__)}var D8=VS(function(x,C,F){pc.call(x,F)?++x[F]:kg(x,F,1)});function Fnt(x,C,F){var J=Us(x)?p3:bz;return F&&jh(x,C,F)&&(C=d),J(x,cs(C,3))}function Unt(x,C){var F=Us(x)?wp:P3;return F(x,cs(C,3))}var N8=t8(x8),O8=t8(M8);function znt(x,C){return yh(p5(x,C),1)}function jnt(x,C){return yh(p5(x,C),re)}function Hnt(x,C,F){return F=F===d?1:Ys(F),yh(p5(x,C),F)}function zj(x,C){var F=Us(x)?su:Sb;return F(x,cs(C,3))}function jj(x,C){var F=Us(x)?CS:TR;return F(x,cs(C,3))}var Gnt=VS(function(x,C,F){pc.call(x,F)?x[F].push(C):kg(x,F,[C])});function Wnt(x,C,F,J){x=xh(x)?x:Jy(x),F=F&&!J?Ys(F):0;var mt=x.length;return F<0&&(F=vt(mt+F,0)),oT(x)?F<=mt&&x.indexOf(C,F)>-1:!!mt&&vp(x,C,F)>-1}var $nt=oo(function(x,C,F){var J=-1,mt=typeof C=="function",St=xh(x)?$e(x.length):[];return Sb(x,function(Vt){St[++J]=mt?df(C,Vt,F):R3(Vt,C,F)}),St}),Vnt=VS(function(x,C,F){kg(x,F,C)});function p5(x,C){var F=Us(x)?ea:RR;return F(x,cs(C,3))}function qnt(x,C,F,J){return x==null?[]:(Us(C)||(C=C==null?[]:[C]),F=J?d:F,Us(F)||(F=F==null?[]:[F]),Tb(x,C,F))}var Xnt=VS(function(x,C,F){x[F?0:1].push(C)},function(){return[[],[]]});function Znt(x,C,F){var J=Us(x)?g3:Iy,mt=arguments.length<3;return J(x,cs(C,4),F,mt,Sb)}function Ynt(x,C,F){var J=Us(x)?m3:Iy,mt=arguments.length<3;return J(x,cs(C,4),F,mt,TR)}function Knt(x,C){var F=Us(x)?wp:P3;return F(x,iT(cs(C,3)))}function Jnt(x){var C=Us(x)?xR:Pz;return C(x)}function Qnt(x,C,F){(F?jh(x,C,F):C===d)?C=1:C=Ys(C);var J=Us(x)?fz:Iz;return J(x,C)}function Hj(x){var C=Us(x)?dz:Dz;return C(x)}function Gj(x){if(x==null)return 0;if(xh(x))return oT(x)?l1(x):x.length;var C=zh(x);return C==ut||C==yt?x.size:Fk(x).length}function Wj(x,C,F){var J=Us(x)?b3:Nz;return F&&jh(x,C,F)&&(C=d),J(x,cs(C,3))}var B8=oo(function(x,C){if(x==null)return[];var F=C.length;return F>1&&jh(x,C[0],C[1])?C=[]:F>2&&jh(C[0],C[1],C[2])&&(C=[C[0]]),Tb(x,yh(C,1),[])}),Mv=kk||function(){return Cc.Date.now()};function eT(x,C){if(typeof C!="function")throw new Jf(m);return x=Ys(x),function(){if(--x<1)return C.apply(this,arguments)}}function nT(x,C,F){return C=F?d:C,C=x&&C==null?x.length:C,Y0(x,Dt,d,d,d,d,C)}function Pb(x,C){var F;if(typeof C!="function")throw new Jf(m);return x=Ys(x),function(){return--x>0&&(F=C.apply(this,arguments)),x<=1&&(C=d),F}}var Rg=oo(function(x,C,F){var J=et;if(F.length){var mt=Fl(F,Zy(Rg));J|=xt}return Y0(x,J,C,F,mt)}),F8=oo(function(x,C,F){var J=et|Q;if(F.length){var mt=Fl(F,Zy(F8));J|=xt}return Y0(C,J,x,F,mt)});function U8(x,C,F){C=F?d:C;var J=Y0(x,gt,d,d,d,d,d,C);return J.placeholder=U8.placeholder,J}function _r(x,C,F){C=F?d:C;var J=Y0(x,ft,d,d,d,d,d,C);return J.placeholder=_r.placeholder,J}function z8(x,C,F){var J,mt,St,Vt,ee,fe,Cn=0,kn=!1,Wn=!1,Ki=!0;if(typeof x!="function")throw new Jf(m);C=Mp(C)||0,$a(F)&&(kn=!!F.leading,Wn="maxWait"in F,St=Wn?vt(Mp(F.maxWait)||0,C):St,Ki="trailing"in F?!!F.trailing:Ki);function Er(_u){var nd=J,nm=mt;return J=mt=d,Cn=_u,Vt=x.apply(nm,nd),Vt}function Wr(_u){return Cn=_u,ee=F3(co,C),kn?Er(_u):Vt}function no(_u){var nd=_u-fe,nm=_u-Cn,w9=C-nd;return Wn?$t(w9,St-nm):w9}function Zr(_u){var nd=_u-fe,nm=_u-Cn;return fe===d||nd>=C||nd<0||Wn&&nm>=St}function co(){var _u=Mv();if(Zr(_u))return $o(_u);ee=F3(co,no(_u))}function $o(_u){return ee=d,Ki&&J?Er(_u):(J=mt=d,Vt)}function Hh(){ee!==d&&$R(ee),Cn=0,J=fe=mt=ee=d}function _f(){return ee===d?Vt:$o(Mv())}function $r(){var _u=Mv(),nd=Zr(_u);if(J=arguments,mt=this,fe=_u,nd){if(ee===d)return Wr(fe);if(Wn)return $R(ee),ee=F3(co,C),Er(fe)}return ee===d&&(ee=F3(co,C)),Vt}return $r.cancel=Hh,$r.flush=_f,$r}var j8=oo(function(x,C){return SR(x,1,C)}),$j=oo(function(x,C,F){return SR(x,Mp(C)||0,F)});function H8(x){return Y0(x,se)}function Yy(x,C){if(typeof x!="function"||C!=null&&typeof C!="function")throw new Jf(m);var F=function(){var J=arguments,mt=C?C.apply(this,J):J[0],St=F.cache;if(St.has(mt))return St.get(mt);var Vt=x.apply(this,J);return F.cache=St.set(mt,Vt)||St,Vt};return F.cache=new(Yy.Cache||X0),F}Yy.Cache=X0;function iT(x){if(typeof x!="function")throw new Jf(m);return function(){var C=arguments;switch(C.length){case 0:return!x.call(this);case 1:return!x.call(this,C[0]);case 2:return!x.call(this,C[0],C[1]);case 3:return!x.call(this,C[0],C[1],C[2])}return!x.apply(this,C)}}function Vj(x){return Pb(2,x)}var qj=Oz(function(x,C){C=C.length==1&&Us(C[0])?ea(C[0],Fu(cs())):ea(yh(C,1),Fu(cs()));var F=C.length;return oo(function(J){for(var mt=-1,St=$t(J.length,F);++mt=C}),Sv=AR(function(){return arguments}())?AR:function(x){return ou(x)&&pc.call(x,"callee")&&!T3.call(x,"callee")},Us=$e.isArray,W8=d3?Fu(d3):Mz;function xh(x){return x!=null&&sT(x.length)&&!tm(x)}function H(x){return ou(x)&&xh(x)}function rT(x){return x===!0||x===!1||ou(x)&&zl(x)==ki}var zd=E||fT,cH=MS?Fu(MS):kR;function Tv(x){return ou(x)&&x.nodeType===1&&!H3(x)}function $8(x){if(x==null)return!0;if(xh(x)&&(Us(x)||typeof x=="string"||typeof x.splice=="function"||zd(x)||Ky(x)||Sv(x)))return!x.length;var C=zh(x);if(C==ut||C==yt)return!x.size;if(B3(x))return!Fk(x).length;for(var F in x)if(pc.call(x,F))return!1;return!0}function aH(x,C){return D3(x,C)}function uH(x,C,F){F=typeof F=="function"?F:d;var J=F?F(x,C):d;return J===d?D3(x,C,d,F):!!J}function m5(x){if(!ou(x))return!1;var C=zl(x);return C==Kt||C==pr||typeof x.message=="string"&&typeof x.name=="string"&&!H3(x)}function lH(x){return typeof x=="number"&&D(x)}function tm(x){if(!$a(x))return!1;var C=zl(x);return C==wn||C==it||C==Yi||C==Pn}function V8(x){return typeof x=="number"&&x==Ys(x)}function sT(x){return typeof x=="number"&&x>-1&&x%1==0&&x<=hn}function $a(x){var C=typeof x;return x!=null&&(C=="object"||C=="function")}function ou(x){return x!=null&&typeof x=="object"}var q8=ES?Fu(ES):LR;function b5(x,C){return x===C||Bk(x,C,e5(C))}function hH(x,C,F){return F=typeof F=="function"?F:d,Bk(x,C,e5(C),F)}function fH(x){return X8(x)&&x!=+x}function dH(x){if(r5(x))throw new vs(p);return PR(x)}function pH(x){return x===null}function gH(x){return x==null}function X8(x){return typeof x=="number"||ou(x)&&zl(x)==kt}function H3(x){if(!ou(x)||zl(x)!=ie)return!1;var C=Tg(x);if(C===null)return!0;var F=pc.call(C,"constructor")&&C.constructor;return typeof F=="function"&&F instanceof F&&Sg.call(F)==Ak}var Ib=Cy?Fu(Cy):Ez;function mH(x){return V8(x)&&x>=-hn&&x<=hn}var Z8=SS?Fu(SS):Sz;function oT(x){return typeof x=="string"||!Us(x)&&ou(x)&&zl(x)==ue}function jd(x){return typeof x=="symbol"||ou(x)&&zl(x)==fn}var Ky=Od?Fu(Od):Tz;function bH(x){return x===d}function wH(x){return ou(x)&&zh(x)==zn}function vH(x){return ou(x)&&zl(x)==Li}var _H=YS(Uk),yH=YS(function(x,C){return x<=C});function Y8(x){if(!x)return[];if(xh(x))return oT(x)?Kf(x):td(x);if(_b&&x[_b])return Sk(x[_b]());var C=zh(x),F=C==ut?hv:C==yt?Oy:Jy;return F(x)}function em(x){if(!x)return x===0?x:0;if(x=Mp(x),x===re||x===-re){var C=x<0?-1:1;return C*Se}return x===x?x:0}function Ys(x){var C=em(x),F=C%1;return C===C?F?C-F:C:0}function K8(x){return x?vv(Ys(x),0,mn):0}function Mp(x){if(typeof x=="number")return x;if(jd(x))return ke;if($a(x)){var C=typeof x.valueOf=="function"?x.valueOf():x;x=$a(C)?C+"":C}if(typeof x!="string")return x===0?x:+x;x=Yf(x);var F=Rt.test(x);return F||Je.test(x)?yS(x.slice(2),F?2:8):o3.test(x)?ke:+x}function J8(x){return Pg(x,ed(x))}function xH(x){return x?vv(Ys(x),-hn,hn):x===0?x:0}function Ac(x){return x==null?"":Fd(x)}var MH=qy(function(x,C){if(B3(C)||xh(C)){Pg(C,Hl(C),x);return}for(var F in C)pc.call(C,F)&&A3(x,F,C[F])}),Q8=qy(function(x,C){Pg(C,ed(C),x)}),t9=qy(function(x,C,F,J){Pg(C,ed(C),x,J)}),w5=qy(function(x,C,F,J){Pg(C,Hl(C),x,J)}),EH=K0(Dk);function SH(x,C){var F=xb(x);return C==null?F:MR(F,C)}var TH=oo(function(x,C){x=Fc(x);var F=-1,J=C.length,mt=J>2?C[2]:d;for(mt&&jh(C[0],C[1],mt)&&(J=1);++F1),St}),Pg(x,Qk(x),F),J&&(F=_p(F,B|P|U,qz));for(var mt=C.length;mt--;)$k(F,C[mt]);return F});function HH(x,C){return n9(x,iT(cs(C)))}var cT=K0(function(x,C){return x==null?{}:zk(x,C)});function n9(x,C){if(x==null)return{};var F=ea(Qk(x),function(J){return[J]});return C=cs(C),BR(x,F,function(J,mt){return C(J,mt[0])})}function GH(x,C,F){C=Ab(C,x);var J=-1,mt=C.length;for(mt||(mt=1,x=d);++JC){var J=x;x=C,C=J}if(F||x%1||C%1){var mt=Un();return $t(x+mt*(C-x+vk("1e-"+((mt+"").length-1))),C)}return Hk(x,C)}var QH=Xy(function(x,C,F){return C=C.toLowerCase(),x+(F?s9(C):C)});function s9(x){return x5(Ac(x).toLowerCase())}function o9(x){return x=Ac(x),x&&x.replace(Ze,lv).replace(u3,"")}function tG(x,C,F){x=Ac(x),C=Fd(C);var J=x.length;F=F===d?J:vv(Ys(F),0,J);var mt=F;return F-=C.length,F>=0&&x.slice(F,mt)==C}function eG(x){return x=Ac(x),x&&sn.test(x)?x.replace(Qt,PS):x}function nG(x){return x=Ac(x),x&&il.test(x)?x.replace(fc,"\\$&"):x}var iG=Xy(function(x,C,F){return x+(F?"-":"")+C.toLowerCase()}),rG=Xy(function(x,C,F){return x+(F?" ":"")+C.toLowerCase()}),sG=QR("toLowerCase");function oG(x,C,F){x=Ac(x),C=Ys(C);var J=C?l1(x):0;if(!C||J>=C)return x;var mt=(C-J)/2;return ZS($y(mt),F)+x+ZS(mv(mt),F)}function cG(x,C,F){x=Ac(x),C=Ys(C);var J=C?l1(x):0;return C&&J>>0,F?(x=Ac(x),x&&(typeof C=="string"||C!=null&&!Ib(C))&&(C=Fd(C),!C&&gf(x))?kb(Kf(x),0,F):x.split(C,F)):[]}var pG=Xy(function(x,C,F){return x+(F?" ":"")+x5(C)});function c9(x,C,F){return x=Ac(x),F=F==null?0:vv(Ys(F),0,x.length),C=Fd(C),x.slice(F,F+C.length)==C}function kr(x,C,F){var J=Mt.templateSettings;F&&jh(x,C,F)&&(C=d),x=Ac(x),C=w5({},C,J,o8);var mt=w5({},C.imports,J.imports,o8),St=Hl(mt),Vt=x3(mt,St);su(St,function(Zr){if(F0.test(Zr))throw new vs(S)});var ee,fe,Cn=0,kn=C.interpolate||Hi,Wn="__p += '",Ki=mf((C.escape||Hi).source+"|"+kn.source+"|"+(kn===Jr?wg:Hi).source+"|"+(C.evaluate||Hi).source+"|$","g"),Er="//# sourceURL="+(pc.call(C,"sourceURL")?(C.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++sl+"]")+` -`;x.replace(Ki,function(Zr,co,$o,Hh,_f,$r){return $o||($o=Hh),Wn+=x.slice(Cn,$r).replace(Pr,Dy),co&&(ee=!0,Wn+=`' + -__e(`+co+`) + -'`),_f&&(fe=!0,Wn+=`'; -`+_f+`; -__p += '`),$o&&(Wn+=`' + -((__t = (`+$o+`)) == null ? '' : __t) + -'`),Cn=$r+Zr.length,Zr}),Wn+=`'; -`;var Wr=pc.call(C,"variable")&&C.variable;if(!Wr)Wn=`with (obj) { -`+Wn+` -} -`;else if(F0.test(Wr))throw new vs(_);Wn=(fe?Wn.replace(ar,""):Wn).replace(gr,"$1").replace(tr,"$1;"),Wn="function("+(Wr||"obj")+`) { -`+(Wr?"":`obj || (obj = {}); -`)+"var __t, __p = ''"+(ee?", __e = _.escape":"")+(fe?`, __j = Array.prototype.join; +... Falling back to non-web worker version. `);if(!D.workerFactory){var Z=c("./elk-worker.min.js"),H=Z.Worker;D.workerFactory=function(te){return new H(te)}}return w(this,(L.__proto__||Object.getPrototypeOf(L)).call(this,D))}return L}(x);Object.defineProperty(u.exports,"__esModule",{value:!0}),u.exports=T,T.default=T},{"./elk-api.js":1,"./elk-worker.min.js":2,"webworker-threads":8}],4:[function(c,u,d){(function(b,w){var _=c("fs"),x=c("path"),T=x.join,M=x.dirname,L=_.accessSync&&function(F){try{_.accessSync(F)}catch{return!1}return!0}||_.existsSync||x.existsSync,I={arrow:b.env.NODE_BINDINGS_ARROW||" \u2192 ",compiled:b.env.NODE_BINDINGS_COMPILED_DIR||"compiled",platform:b.platform,arch:b.arch,version:b.versions.node,bindings:"bindings.node",try:[["module_root","build","bindings"],["module_root","build","Debug","bindings"],["module_root","build","Release","bindings"],["module_root","out","Debug","bindings"],["module_root","Debug","bindings"],["module_root","out","Release","bindings"],["module_root","Release","bindings"],["module_root","build","default","bindings"],["module_root","compiled","version","platform","arch","bindings"]]};function D(F){typeof F=="string"?F={bindings:F}:F||(F={}),Object.keys(I).map(function(ne){ne in F||(F[ne]=I[ne])}),F.module_root||(F.module_root=d.getRoot(d.getFileName())),x.extname(F.bindings)!=".node"&&(F.bindings+=".node");for(var O=[],z=0,Z=F.try.length,H,te,se;z=0;F--){var O=L[F];O==="."?L.splice(F,1):O===".."?(L.splice(F,1),D++):D&&(L.splice(F,1),D--)}if(I)for(;D--;D)L.unshift("..");return L}var _=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,x=function(L){return _.exec(L).slice(1)};d.resolve=function(){for(var L="",I=!1,D=arguments.length-1;D>=-1&&!I;D--){var F=D>=0?arguments[D]:b.cwd();if(typeof F!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!F)continue;L=F+"/"+L,I=F.charAt(0)==="/"}return L=w(T(L.split("/"),function(O){return!!O}),!I).join("/"),(I?"/":"")+L||"."},d.normalize=function(L){var I=d.isAbsolute(L),D=M(L,-1)==="/";return L=w(T(L.split("/"),function(F){return!!F}),!I).join("/"),!L&&!I&&(L="."),L&&D&&(L+="/"),(I?"/":"")+L},d.isAbsolute=function(L){return L.charAt(0)==="/"},d.join=function(){var L=Array.prototype.slice.call(arguments,0);return d.normalize(T(L,function(I,D){if(typeof I!="string")throw new TypeError("Arguments to path.join must be strings");return I}).join("/"))},d.relative=function(L,I){L=d.resolve(L).substr(1),I=d.resolve(I).substr(1);function D(se){for(var ne=0;ne=0&&se[ue]==="";ue--);return ne>ue?[]:se.slice(ne,ue-ne+1)}for(var F=D(L.split("/")),O=D(I.split("/")),z=Math.min(F.length,O.length),Z=z,H=0;H1)for(var ue=1;ue{(function(s){s.parser=function(oe,de){return new r(oe,de)},s.SAXParser=r,s.SAXStream=T,s.createStream=_,s.MAX_BUFFER_LENGTH=64*1024;var n=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];s.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function r(oe,de){if(!(this instanceof r))return new r(oe,de);var it=this;u(it),it.q=it.c="",it.bufferCheckPosition=s.MAX_BUFFER_LENGTH,it.encoding=null,it.opt=de||{},it.opt.lowercase=it.opt.lowercase||it.opt.lowercasetags,it.looseCase=it.opt.lowercase?"toLowerCase":"toUpperCase",it.opt.maxEntityCount=it.opt.maxEntityCount||512,it.opt.maxEntityDepth=it.opt.maxEntityDepth||4,it.entityCount=it.entityDepth=0,it.tags=[],it.closed=it.closedRoot=it.sawRoot=!1,it.tag=it.error=null,it.strict=!!oe,it.noscript=!!(oe||it.opt.noscript),it.state=Q.BEGIN,it.strictEntities=it.opt.strictEntities,it.ENTITIES=it.strictEntities?Object.create(s.XML_ENTITIES):Object.create(s.ENTITIES),it.attribList=[],it.opt.xmlns&&(it.ns=Object.create(F)),it.opt.unquotedAttributeValues===void 0&&(it.opt.unquotedAttributeValues=!oe),it.trackPosition=it.opt.position!==!1,it.trackPosition&&(it.position=it.line=it.column=0),tt(it,"onready")}Object.create||(Object.create=function(oe){function de(){}de.prototype=oe;var it=new de;return it}),Object.keys||(Object.keys=function(oe){var de=[];for(var it in oe)oe.hasOwnProperty(it)&&de.push(it);return de});function c(oe){for(var de=Math.max(s.MAX_BUFFER_LENGTH,10),it=0,We=0,_n=n.length;We<_n;We++){var Er=oe[n[We]].length;if(Er>de)switch(n[We]){case"textNode":xt(oe);break;case"cdata":ot(oe,"oncdata",oe.cdata),oe.cdata="";break;case"script":ot(oe,"onscript",oe.script),oe.script="";break;default:Xt(oe,"Max buffer length exceeded: "+n[We])}it=Math.max(it,Er)}var qi=s.MAX_BUFFER_LENGTH-it;oe.bufferCheckPosition=qi+oe.position}function u(oe){for(var de=0,it=n.length;de=2){if(oe[0]===255&&oe[1]===254)return"utf-16le";if(oe[0]===254&&oe[1]===255)return"utf-16be"}return oe.length>=3&&oe[0]===239&&oe[1]===187&&oe[2]===191?"utf8":oe.length>=4?oe[0]===60&&oe[1]===0&&oe[2]===63&&oe[3]===0?"utf-16le":oe[0]===0&&oe[1]===60&&oe[2]===0&&oe[3]===63?"utf-16be":"utf8":de?"utf8":null}function T(oe,de){if(!(this instanceof T))return new T(oe,de);b.apply(this),this._parser=new r(oe,de),this.writable=!0,this.readable=!0;var it=this;this._parser.onend=function(){it.emit("end")},this._parser.onerror=function(We){it.emit("error",We),it._parser.error=null},this._decoder=null,this._decoderBuffer=null,w.forEach(function(We){Object.defineProperty(it,"on"+We,{get:function(){return it._parser["on"+We]},set:function(_n){if(!_n)return it.removeAllListeners(We),it._parser["on"+We]=_n,_n;it.on(We,_n)},enumerable:!0,configurable:!1})})}T.prototype=Object.create(b.prototype,{constructor:{value:T}}),T.prototype._decodeBuffer=function(oe,de){if(this._decoderBuffer&&(oe=Buffer.concat([this._decoderBuffer,oe]),this._decoderBuffer=null),!this._decoder){var it=x(oe,de);if(!it)return this._decoderBuffer=oe,"";this._parser.encoding=it,this._decoder=new TextDecoder(it)}return this._decoder.decode(oe,{stream:!de})},T.prototype.write=function(oe){if(typeof Buffer=="function"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(oe))oe=this._decodeBuffer(oe,!1);else if(this._decoderBuffer){var de=this._decodeBuffer(Buffer.alloc(0),!0);de&&(this._parser.write(de),this.emit("data",de))}return this._parser.write(oe.toString()),this.emit("data",oe),!0},T.prototype.end=function(oe){if(oe&&oe.length&&this.write(oe),this._decoderBuffer){var de=this._decodeBuffer(Buffer.alloc(0),!0);de&&(this._parser.write(de),this.emit("data",de))}else if(this._decoder){var it=this._decoder.decode();it&&(this._parser.write(it),this.emit("data",it))}return this._parser.end(),!0},T.prototype.on=function(oe,de){var it=this;return!it._parser["on"+oe]&&w.indexOf(oe)!==-1&&(it._parser["on"+oe]=function(){var We=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);We.splice(0,0,oe),it.emit.apply(it,We)}),b.prototype.on.call(it,oe,de)};var M=/^\[CDATA\[$/i,L=/^DOCTYPE$/i,I="http://www.w3.org/XML/1998/namespace",D="http://www.w3.org/2000/xmlns/",F={xml:I,xmlns:D},O=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,z=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,Z=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,H=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function te(oe){return oe===" "||oe===` +`||oe==="\r"||oe===" "}function se(oe){return oe==='"'||oe==="'"}function ne(oe){return oe===">"||te(oe)}function ue(oe,de){return oe.test(de)}function Ce(oe,de){return!ue(oe,de)}var Q=0;s.STATE={BEGIN:Q++,BEGIN_WHITESPACE:Q++,TEXT:Q++,TEXT_ENTITY:Q++,OPEN_WAKA:Q++,SGML_DECL:Q++,SGML_DECL_QUOTED:Q++,DOCTYPE:Q++,DOCTYPE_QUOTED:Q++,DOCTYPE_DTD:Q++,DOCTYPE_DTD_QUOTED:Q++,COMMENT_STARTING:Q++,COMMENT:Q++,COMMENT_ENDING:Q++,COMMENT_ENDED:Q++,CDATA:Q++,CDATA_ENDING:Q++,CDATA_ENDING_2:Q++,PROC_INST:Q++,PROC_INST_BODY:Q++,PROC_INST_ENDING:Q++,OPEN_TAG:Q++,OPEN_TAG_SLASH:Q++,ATTRIB:Q++,ATTRIB_NAME:Q++,ATTRIB_NAME_SAW_WHITE:Q++,ATTRIB_VALUE:Q++,ATTRIB_VALUE_QUOTED:Q++,ATTRIB_VALUE_CLOSED:Q++,ATTRIB_VALUE_UNQUOTED:Q++,ATTRIB_VALUE_ENTITY_Q:Q++,ATTRIB_VALUE_ENTITY_U:Q++,CLOSE_TAG:Q++,CLOSE_TAG_SAW_WHITE:Q++,SCRIPT:Q++,SCRIPT_ENDING:Q++},s.XML_ENTITIES=Object.assign(Object.create(null),{amp:"&",gt:">",lt:"<",quot:'"',apos:"'"}),s.ENTITIES=Object.assign(Object.create(null),{amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830}),Object.keys(s.ENTITIES).forEach(function(oe){var de=s.ENTITIES[oe],it=typeof de=="number"?String.fromCharCode(de):de;s.ENTITIES[oe]=it});for(var me in s.STATE)s.STATE[s.STATE[me]]=me;Q=s.STATE;function tt(oe,de,it){oe[de]&&oe[de](it)}function st(oe){var de=oe&&oe.match(/(?:^|\s)encoding\s*=\s*(['"])([^'"]+)\1/i);return de?de[2]:null}function at(oe){return oe?oe.toLowerCase().replace(/[^a-z0-9]/g,""):null}function Ne(oe,de){let it=at(oe),We=at(de);return!it||!We?!0:We==="utf16"?it==="utf16le"||it==="utf16be":it===We}function Qe(oe,de){if(!(!oe.strict||!oe.encoding||!de||de.name!=="xml")){var it=st(de.body);it&&!Ne(oe.encoding,it)&&cn(oe,"XML declaration encoding "+it+" does not match detected stream encoding "+oe.encoding.toUpperCase())}}function ot(oe,de,it){oe.textNode&&xt(oe),tt(oe,de,it)}function xt(oe){oe.textNode=fn(oe.opt,oe.textNode),oe.textNode&&tt(oe,"ontext",oe.textNode),oe.textNode=""}function fn(oe,de){return oe.trim&&(de=de.trim()),oe.normalize&&(de=de.replace(/\s+/g," ")),de}function Xt(oe,de){return xt(oe),oe.trackPosition&&(de+=` +Line: `+oe.line+` +Column: `+oe.column+` +Char: `+oe.c),de=new Error(de),oe.error=de,tt(oe,"onerror",de),oe}function wn(oe){return oe.sawRoot&&!oe.closedRoot&&cn(oe,"Unclosed root tag"),oe.state!==Q.BEGIN&&oe.state!==Q.BEGIN_WHITESPACE&&oe.state!==Q.TEXT&&Xt(oe,"Unexpected end"),xt(oe),oe.c="",oe.closed=!0,tt(oe,"onend"),r.call(oe,oe.strict,oe.opt),oe}function cn(oe,de){if(typeof oe!="object"||!(oe instanceof r))throw new Error("bad call to strictFail");oe.strict&&Xt(oe,de)}function bi(oe){oe.strict||(oe.tagName=oe.tagName[oe.looseCase]());var de=oe.tags[oe.tags.length-1]||oe,it=oe.tag={name:oe.tagName,attributes:{}};oe.opt.xmlns&&(it.ns=de.ns),oe.attribList.length=0,ot(oe,"onopentagstart",it)}function jt(oe,de){var it=oe.indexOf(":"),We=it<0?["",oe]:oe.split(":"),_n=We[0],Er=We[1];return de&&oe==="xmlns"&&(_n="xmlns",Er=""),{prefix:_n,local:Er}}function gn(oe){if(oe.strict||(oe.attribName=oe.attribName[oe.looseCase]()),oe.attribList.indexOf(oe.attribName)!==-1||oe.tag.attributes.hasOwnProperty(oe.attribName)){oe.attribName=oe.attribValue="";return}if(oe.opt.xmlns){var de=jt(oe.attribName,!0),it=de.prefix,We=de.local;if(it==="xmlns")if(We==="xml"&&oe.attribValue!==I)cn(oe,"xml: prefix must be bound to "+I+` +Actual: `+oe.attribValue);else if(We==="xmlns"&&oe.attribValue!==D)cn(oe,"xmlns: prefix must be bound to "+D+` +Actual: `+oe.attribValue);else{var _n=oe.tag,Er=oe.tags[oe.tags.length-1]||oe;_n.ns===Er.ns&&(_n.ns=Object.create(Er.ns)),_n.ns[We]=oe.attribValue}oe.attribList.push([oe.attribName,oe.attribValue])}else oe.tag.attributes[oe.attribName]=oe.attribValue,ot(oe,"onattribute",{name:oe.attribName,value:oe.attribValue});oe.attribName=oe.attribValue=""}function Un(oe,de){if(oe.opt.xmlns){var it=oe.tag,We=jt(oe.tagName);it.prefix=We.prefix,it.local=We.local,it.uri=it.ns[We.prefix]||"",it.prefix&&!it.uri&&(cn(oe,"Unbound namespace prefix: "+JSON.stringify(oe.tagName)),it.uri=We.prefix);var _n=oe.tags[oe.tags.length-1]||oe;it.ns&&_n.ns!==it.ns&&Object.keys(it.ns).forEach(function(ri){ot(oe,"onopennamespace",{prefix:ri,uri:it.ns[ri]})});for(var Er=0,qi=oe.attribList.length;Er",oe.tagName="",oe.state=Q.SCRIPT;return}ot(oe,"onscript",oe.script),oe.script=""}var de=oe.tags.length,it=oe.tagName;oe.strict||(it=it[oe.looseCase]());for(var We=it;de--;){var _n=oe.tags[de];if(_n.name!==We)cn(oe,"Unexpected close tag");else break}if(de<0){cn(oe,"Unmatched closing tag: "+oe.tagName),oe.textNode+="",oe.state=Q.TEXT;return}oe.tagName=it;for(var Er=oe.tags.length;Er-- >de;){var qi=oe.tag=oe.tags.pop();oe.tagName=oe.tag.name,ot(oe,"onclosetag",oe.tagName);var Te={};for(var ve in qi.ns)Te[ve]=qi.ns[ve];var _t=oe.tags[oe.tags.length-1]||oe;oe.opt.xmlns&&qi.ns!==_t.ns&&Object.keys(qi.ns).forEach(function(mn){var yn=qi.ns[mn];ot(oe,"onclosenamespace",{prefix:mn,uri:yn})})}de===0&&(oe.closedRoot=!0),oe.tagName=oe.attribValue=oe.attribName="",oe.attribList.length=0,oe.state=Q.TEXT}function Hi(oe){var de=oe.entity,it=de.toLowerCase(),We,_n="";return oe.ENTITIES[de]?oe.ENTITIES[de]:oe.ENTITIES[it]?oe.ENTITIES[it]:(de=it,de.charAt(0)==="#"&&(de.charAt(1)==="x"?(de=de.slice(2),We=parseInt(de,16),_n=We.toString(16)):(de=de.slice(1),We=parseInt(de,10),_n=We.toString(10))),de=de.replace(/^0+/,""),isNaN(We)||_n.toLowerCase()!==de||We<0||We>1114111||!yr(We)?(cn(oe,"Invalid character entity"),"&"+oe.entity+";"):String.fromCodePoint(We))}function yr(oe){return oe===9||oe===10||oe===13||oe>=32&&oe<=55295||oe>=57344&&oe<=65533||oe>=65536&&oe<=1114111}function Tr(oe,de){de==="<"?(oe.state=Q.OPEN_WAKA,oe.startTagPosition=oe.position):te(de)||(cn(oe,"Non-whitespace before first tag."),oe.textNode=de,oe.state=Q.TEXT)}function Ei(oe,de){var it="";return de"?(ot(de,"onsgmldeclaration",de.sgmlDecl),de.sgmlDecl="",de.state=Q.TEXT):(se(We)&&(de.state=Q.SGML_DECL_QUOTED),de.sgmlDecl+=We);continue;case Q.SGML_DECL_QUOTED:We===de.q&&(de.state=Q.SGML_DECL,de.q=""),de.sgmlDecl+=We;continue;case Q.DOCTYPE:We===">"?(de.state=Q.TEXT,ot(de,"ondoctype",de.doctype),de.doctype=!0):(de.doctype+=We,We==="["?de.state=Q.DOCTYPE_DTD:se(We)&&(de.state=Q.DOCTYPE_QUOTED,de.q=We));continue;case Q.DOCTYPE_QUOTED:de.doctype+=We,We===de.q&&(de.q="",de.state=Q.DOCTYPE);continue;case Q.DOCTYPE_DTD:We==="]"?(de.doctype+=We,de.state=Q.DOCTYPE):We==="<"?(de.state=Q.OPEN_WAKA,de.startTagPosition=de.position):se(We)?(de.doctype+=We,de.state=Q.DOCTYPE_DTD_QUOTED,de.q=We):de.doctype+=We;continue;case Q.DOCTYPE_DTD_QUOTED:de.doctype+=We,We===de.q&&(de.state=Q.DOCTYPE_DTD,de.q="");continue;case Q.COMMENT:We==="-"?de.state=Q.COMMENT_ENDING:de.comment+=We;continue;case Q.COMMENT_ENDING:We==="-"?(de.state=Q.COMMENT_ENDED,de.comment=fn(de.opt,de.comment),de.comment&&ot(de,"oncomment",de.comment),de.comment=""):(de.comment+="-"+We,de.state=Q.COMMENT);continue;case Q.COMMENT_ENDED:We!==">"?(cn(de,"Malformed comment"),de.comment+="--"+We,de.state=Q.COMMENT):de.doctype&&de.doctype!==!0?de.state=Q.DOCTYPE_DTD:de.state=Q.TEXT;continue;case Q.CDATA:for(var Er=it-1;We&&We!=="]";)We=Ei(oe,it++),We&&de.trackPosition&&(de.position++,We===` +`?(de.line++,de.column=0):de.column++);de.cdata+=oe.substring(Er,it-1),We==="]"&&(de.state=Q.CDATA_ENDING);continue;case Q.CDATA_ENDING:We==="]"?de.state=Q.CDATA_ENDING_2:(de.cdata+="]"+We,de.state=Q.CDATA);continue;case Q.CDATA_ENDING_2:We===">"?(de.cdata&&ot(de,"oncdata",de.cdata),ot(de,"onclosecdata"),de.cdata="",de.state=Q.TEXT):We==="]"?de.cdata+="]":(de.cdata+="]]"+We,de.state=Q.CDATA);continue;case Q.PROC_INST:We==="?"?de.state=Q.PROC_INST_ENDING:te(We)?de.state=Q.PROC_INST_BODY:de.procInstName+=We;continue;case Q.PROC_INST_BODY:if(!de.procInstBody&&te(We))continue;We==="?"?de.state=Q.PROC_INST_ENDING:de.procInstBody+=We;continue;case Q.PROC_INST_ENDING:if(We===">"){let _t={name:de.procInstName,body:de.procInstBody};Qe(de,_t),ot(de,"onprocessinginstruction",_t),de.procInstName=de.procInstBody="",de.state=Q.TEXT}else de.procInstBody+="?"+We,de.state=Q.PROC_INST_BODY;continue;case Q.OPEN_TAG:ue(z,We)?de.tagName+=We:(bi(de),We===">"?Un(de):We==="/"?de.state=Q.OPEN_TAG_SLASH:(te(We)||cn(de,"Invalid character in tag name"),de.state=Q.ATTRIB));continue;case Q.OPEN_TAG_SLASH:We===">"?(Un(de,!0),Zi(de)):(cn(de,"Forward-slash in opening tag not followed by >"),de.state=Q.ATTRIB);continue;case Q.ATTRIB:if(te(We))continue;We===">"?Un(de):We==="/"?de.state=Q.OPEN_TAG_SLASH:ue(O,We)?(de.attribName=We,de.attribValue="",de.state=Q.ATTRIB_NAME):cn(de,"Invalid attribute name");continue;case Q.ATTRIB_NAME:We==="="?de.state=Q.ATTRIB_VALUE:We===">"?(cn(de,"Attribute without value"),de.attribValue=de.attribName,gn(de),Un(de)):te(We)?de.state=Q.ATTRIB_NAME_SAW_WHITE:ue(z,We)?de.attribName+=We:cn(de,"Invalid attribute name");continue;case Q.ATTRIB_NAME_SAW_WHITE:if(We==="=")de.state=Q.ATTRIB_VALUE;else{if(te(We))continue;cn(de,"Attribute without value"),de.tag.attributes[de.attribName]="",de.attribValue="",ot(de,"onattribute",{name:de.attribName,value:""}),de.attribName="",We===">"?Un(de):ue(O,We)?(de.attribName=We,de.state=Q.ATTRIB_NAME):(cn(de,"Invalid attribute name"),de.state=Q.ATTRIB)}continue;case Q.ATTRIB_VALUE:if(te(We))continue;se(We)?(de.q=We,de.state=Q.ATTRIB_VALUE_QUOTED):(de.opt.unquotedAttributeValues||Xt(de,"Unquoted attribute value"),de.state=Q.ATTRIB_VALUE_UNQUOTED,de.attribValue=We);continue;case Q.ATTRIB_VALUE_QUOTED:if(We!==de.q){We==="&"?de.state=Q.ATTRIB_VALUE_ENTITY_Q:de.attribValue+=We;continue}gn(de),de.q="",de.state=Q.ATTRIB_VALUE_CLOSED;continue;case Q.ATTRIB_VALUE_CLOSED:te(We)?de.state=Q.ATTRIB:We===">"?Un(de):We==="/"?de.state=Q.OPEN_TAG_SLASH:ue(O,We)?(cn(de,"No whitespace between attributes"),de.attribName=We,de.attribValue="",de.state=Q.ATTRIB_NAME):cn(de,"Invalid attribute name");continue;case Q.ATTRIB_VALUE_UNQUOTED:if(!ne(We)){We==="&"?de.state=Q.ATTRIB_VALUE_ENTITY_U:de.attribValue+=We;continue}gn(de),We===">"?Un(de):de.state=Q.ATTRIB;continue;case Q.CLOSE_TAG:if(de.tagName)We===">"?Zi(de):ue(z,We)?de.tagName+=We:de.script?(de.script+=""?Zi(de):cn(de,"Invalid characters in closing tag");continue;case Q.TEXT_ENTITY:case Q.ATTRIB_VALUE_ENTITY_Q:case Q.ATTRIB_VALUE_ENTITY_U:var qi,Te;switch(de.state){case Q.TEXT_ENTITY:qi=Q.TEXT,Te="textNode";break;case Q.ATTRIB_VALUE_ENTITY_Q:qi=Q.ATTRIB_VALUE_QUOTED,Te="attribValue";break;case Q.ATTRIB_VALUE_ENTITY_U:qi=Q.ATTRIB_VALUE_UNQUOTED,Te="attribValue";break}if(We===";"){var ve=Hi(de);de.opt.unparsedEntities&&!Object.values(s.XML_ENTITIES).includes(ve)?((de.entityCount+=1)>de.opt.maxEntityCount&&Xt(de,"Parsed entity count exceeds max entity count"),(de.entityDepth+=1)>de.opt.maxEntityDepth&&Xt(de,"Parsed entity depth exceeds max entity depth"),de.entity="",de.state=qi,de.write(ve),de.entityDepth-=1):(de[Te]+=ve,de.entity="",de.state=qi)}else ue(de.entity.length?H:Z,We)?de.entity+=We:(cn(de,"Invalid character in entity name"),de[Te]+="&"+de.entity+We,de.entity="",de.state=qi);continue;default:throw new Error(de,"Unknown state: "+de.state)}return de.position>=de.bufferCheckPosition&&c(de),de}String.fromCodePoint||function(){var oe=String.fromCharCode,de=Math.floor,it=function(){var We=16384,_n=[],Er,qi,Te=-1,ve=arguments.length;if(!ve)return"";for(var _t="";++Te1114111||de(mn)!==mn)throw RangeError("Invalid code point: "+mn);mn<=65535?_n.push(mn):(mn-=65536,Er=(mn>>10)+55296,qi=mn%1024+56320,_n.push(Er,qi)),(Te+1===ve||_n.length>We)&&(_t+=oe.apply(null,_n),_n.length=0)}return _t};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:it,configurable:!0,writable:!0}):String.fromCodePoint=it}()})(typeof rfe>"u"?rfe.sax={}:rfe)});var a_t=Ed((Bai,o_t)=>{"use strict";var Dsn=s_t().parser;function Bsn(s){var n=[],r=[],c=n,u;return u=Dsn(!0),u.ontext=function(d){d.trim()!==""&&c.push(d)},u.onopentag=function(d){var b;b=[d.name,d.attributes],r.push(c),c.push(b),c=b},u.onclosetag=function(){c=r.pop()},u.write(s).close(),n[0]}o_t.exports=Bsn});var u_t=Ed((Oai,l_t)=>{"use strict";function Osn(s){return s&&Object.prototype.toString.call(s)==="[object Object]"}function Nsn(s){var n,r=[];return typeof s!="string"?s:(n=s.split(` +`),n.length===1?" "+s:(n.forEach(function(c){if(c.trim()===""){r.push(c);return}r.push(" "+c)}),r.join(` +`)))}function Fsn(s){var n=s.split(` +`),r=[];return n.forEach(function(c){c.trim()!==""&&r.push(c)}),r.join(` +`)}function c_t(s){var n,r,c,u;return r="",u=!0,c=s.some(function(d,b,w){if(b===0)return n="<"+d,w.length===1?!0:void 0;if(b===1)if(Osn(d)){if(Object.keys(d).forEach(function(_){n+=" "+_+'="'+d[_]+'"'}),w.length===2)return!0;n+=">";return}else n+=">";switch(typeof d){case"string":case"number":case"boolean":r+=d+` +`;return}u=!1,r+=c_t(d)}),c?n+`/> +`:u?n+Fsn(r)+" +`:n+` +`+Nsn(r)+" +`}l_t.exports=c_t});var h_t=Ed((Nai,f_t)=>{"use strict";function Usn(s,n){var r=function(){},c=r,u=r;function d(){this._skip=!0}function b(){this._remove=!0}function w(T){this._name=T}function _(T){this._replace=T}function x(T,M){var L,I={attr:{},full:T},D={name:w,skip:d,remove:b,replace:_,_name:void 0,_skip:!1,_remove:!1,_replace:void 0},F=!0,O,z,Z;if(T!==void 0&&T!==null&&T!==!0&&T!==!1)switch(L=Object.prototype.toString.call(T),L){case"[object String]":case"[object Number]":return;case"[object Array]":if(T.some(function(H,te){if(te===0)return I.name=H,!1;if(te===1)return Object.prototype.toString.call(H)==="[object Object]"&&(F=!1,I.attr=H),!0}),c.call(D,I,M),D._name&&(T[0]=D._name),D._replace)return D._replace;if(D._remove)return null;if(!D._skip){for(O=0,z=T.length;O1||O===1&&F){if(Z=x(T[O],I),Z===null){T.splice(O,1),z-=1;continue}Z&&(T[O]=Z)}O+=1}if(u.call(D,I,M),D._name&&(T[0]=D._name),D._replace)return D._replace;if(D._remove)return null}}}n&&(n.enter&&(c=n.enter),n.leave&&(u=n.leave)),x(s,void 0)}f_t.exports=Usn});var bW=Ed((Fai,m_t)=>{"use strict";var d_t=a_t(),p_t=u_t(),g_t=h_t();m_t.exports={parse:d_t,stringify:p_t,traverse:g_t,p:d_t,s:p_t,t:g_t}});var O4=Ed((NB,wW)=>{(function(){var s,n="4.18.1",r=200,c="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",u="Expected a function",d="Invalid `variable` option passed into `_.template`",b="Invalid `imports` option passed into `_.template`",w="__lodash_hash_undefined__",_=500,x="__lodash_placeholder__",T=1,M=2,L=4,I=1,D=2,F=1,O=2,z=4,Z=8,H=16,te=32,se=64,ne=128,ue=256,Ce=512,Q=30,me="...",tt=800,st=16,at=1,Ne=2,Qe=3,ot=1/0,xt=9007199254740991,fn=17976931348623157e292,Xt=NaN,wn=4294967295,cn=wn-1,bi=wn>>>1,jt=[["ary",ne],["bind",F],["bindKey",O],["curry",Z],["curryRight",H],["flip",Ce],["partial",te],["partialRight",se],["rearg",ue]],gn="[object Arguments]",Un="[object Array]",Zi="[object AsyncFunction]",Hi="[object Boolean]",yr="[object Date]",Tr="[object DOMException]",Ei="[object Error]",xr="[object Function]",oe="[object GeneratorFunction]",de="[object Map]",it="[object Number]",We="[object Null]",_n="[object Object]",Er="[object Promise]",qi="[object Proxy]",Te="[object RegExp]",ve="[object Set]",_t="[object String]",mn="[object Symbol]",yn="[object Undefined]",Sn="[object WeakMap]",yi="[object WeakSet]",hi="[object ArrayBuffer]",ri="[object DataView]",Ge="[object Float32Array]",Pe="[object Float64Array]",ke="[object Int8Array]",dt="[object Int16Array]",Ye="[object Int32Array]",ct="[object Uint8Array]",Ze="[object Uint8ClampedArray]",Ke="[object Uint16Array]",gt="[object Uint32Array]",qn=/\b__p \+= '';/g,xi=/\b(__p \+=) '' \+/g,Bi=/(__e\(.*?\)|\b__t\)) \+\n'';/g,xn=/&(?:amp|lt|gt|quot|#39);/g,Je=/[&<>"']/g,ti=RegExp(xn.source),Zn=RegExp(Je.source),rr=/<%-([\s\S]+?)%>/g,Me=/<%([\s\S]+?)%>/g,et=/<%=([\s\S]+?)%>/g,ht=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,on=/^\w*$/,Ri=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,di=/[\\^$.*+?()[\]{}|]/g,er=RegExp(di.source),ms=/^\s+/,Js=/\s/,$i=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Vs=/\{\n\/\* \[wrapped with (.+)\] \*/,dh=/,? & /,Lm=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,mg=/[()=,{}\[\]\/\s]/,kv=/\\(\\)?/g,Rv=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,AT=/\w*$/,bk=/^[-+]0x[0-9a-f]+$/i,Le=/^0b[01]+$/i,St=/^\[object .+?Constructor\]$/,Kt=/^0o[0-7]+$/i,en=/^(?:0|[1-9]\d*)$/,Yt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Xi=/($^)/,Rr=/['\n\r\u2028\u2029\\]/g,qr="\\ud800-\\udfff",bs="\\u0300-\\u036f",Ws="\\ufe20-\\ufe2f",xs="\\u20d0-\\u20ff",Cs=bs+Ws+xs,Pc="\\u2700-\\u27bf",Uf="a-z\\xdf-\\xf6\\xf8-\\xff",dl="\\xac\\xb1\\xd7\\xf7",bg="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",fc="\\u2000-\\u206f",Qs=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",b2="A-Z\\xc0-\\xd6\\xd8-\\xde",hc="\\ufe0e\\ufe0f",km=dl+bg+fc+Qs,w2="['\u2019]",Iv="["+qr+"]",v2="["+km+"]",pl="["+Cs+"]",Rm="\\d+",iE="["+Pc+"]",ph="["+Uf+"]",_2="[^"+qr+km+Rm+Pc+Uf+b2+"]",rE="\\ud83c[\\udffb-\\udfff]",PT="(?:"+pl+"|"+rE+")",kO="[^"+qr+"]",wk="(?:\\ud83c[\\udde6-\\uddff]){2}",vk="[\\ud800-\\udbff][\\udc00-\\udfff]",y2="["+b2+"]",RO="\\u200d",IO="(?:"+ph+"|"+_2+")",uH="(?:"+y2+"|"+_2+")",DO="(?:"+w2+"(?:d|ll|m|re|s|t|ve))?",BO="(?:"+w2+"(?:D|LL|M|RE|S|T|VE))?",OO=PT+"?",NO="["+hc+"]?",fH="(?:"+RO+"(?:"+[kO,wk,vk].join("|")+")"+NO+OO+")*",hH="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",dH="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",FO=NO+OO+fH,pH="(?:"+[iE,wk,vk].join("|")+")"+FO,gH="(?:"+[kO+pl+"?",pl,wk,vk,Iv].join("|")+")",mH=RegExp(w2,"g"),bH=RegExp(pl,"g"),_k=RegExp(rE+"(?="+rE+")|"+gH+FO,"g"),wH=RegExp([y2+"?"+ph+"+"+DO+"(?="+[v2,y2,"$"].join("|")+")",uH+"+"+BO+"(?="+[v2,y2+IO,"$"].join("|")+")",y2+"?"+IO+"+"+DO,y2+"+"+BO,dH,hH,Rm,pH].join("|"),"g"),vH=RegExp("["+RO+qr+Cs+hc+"]"),_H=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,yH=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],xH=-1,dc={};dc[Ge]=dc[Pe]=dc[ke]=dc[dt]=dc[Ye]=dc[ct]=dc[Ze]=dc[Ke]=dc[gt]=!0,dc[gn]=dc[Un]=dc[hi]=dc[Hi]=dc[ri]=dc[yr]=dc[Ei]=dc[xr]=dc[de]=dc[it]=dc[_n]=dc[Te]=dc[ve]=dc[_t]=dc[Sn]=!1;var nc={};nc[gn]=nc[Un]=nc[hi]=nc[ri]=nc[Hi]=nc[yr]=nc[Ge]=nc[Pe]=nc[ke]=nc[dt]=nc[Ye]=nc[de]=nc[it]=nc[_n]=nc[Te]=nc[ve]=nc[_t]=nc[mn]=nc[ct]=nc[Ze]=nc[Ke]=nc[gt]=!0,nc[Ei]=nc[xr]=nc[Sn]=!1;var EH={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},SH={"&":"&","<":"<",">":">",'"':""","'":"'"},MH={"&":"&","<":"<",">":">",""":'"',"'":"'"},TH={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},CH=parseFloat,AH=parseInt,UO=typeof global=="object"&&global&&global.Object===Object&&global,PH=typeof self=="object"&&self&&self.Object===Object&&self,Iu=UO||PH||Function("return this")(),yk=typeof NB=="object"&&NB&&!NB.nodeType&&NB,Dv=yk&&typeof wW=="object"&&wW&&!wW.nodeType&&wW,zO=Dv&&Dv.exports===yk,xk=zO&&UO.process,bp=function(){try{var lt=Dv&&Dv.require&&Dv.require("util").types;return lt||xk&&xk.binding&&xk.binding("util")}catch{}}(),GO=bp&&bp.isArrayBuffer,jO=bp&&bp.isDate,$O=bp&&bp.isMap,VO=bp&&bp.isRegExp,WO=bp&&bp.isSet,HO=bp&&bp.isTypedArray;function Td(lt,hn,Jt){switch(Jt.length){case 0:return lt.call(hn);case 1:return lt.call(hn,Jt[0]);case 2:return lt.call(hn,Jt[0],Jt[1]);case 3:return lt.call(hn,Jt[0],Jt[1],Jt[2])}return lt.apply(hn,Jt)}function LH(lt,hn,Jt,sr){for(var Es=-1,ea=lt==null?0:lt.length;++Es-1}function Ek(lt,hn,Jt){for(var sr=-1,Es=lt==null?0:lt.length;++sr-1;);return Jt}function eN(lt,hn){for(var Jt=lt.length;Jt--&&x2(hn,lt[Jt],0)>-1;);return Jt}function UH(lt,hn){for(var Jt=lt.length,sr=0;Jt--;)lt[Jt]===hn&&++sr;return sr}var zH=Ck(EH),GH=Ck(SH);function jH(lt){return"\\"+TH[lt]}function $H(lt,hn){return lt==null?s:lt[hn]}function E2(lt){return vH.test(lt)}function VH(lt){return _H.test(lt)}function WH(lt){for(var hn,Jt=[];!(hn=lt.next()).done;)Jt.push(hn.value);return Jt}function kk(lt){var hn=-1,Jt=Array(lt.size);return lt.forEach(function(sr,Es){Jt[++hn]=[Es,sr]}),Jt}function tN(lt,hn){return function(Jt){return lt(hn(Jt))}}function Gb(lt,hn){for(var Jt=-1,sr=lt.length,Es=0,ea=[];++Jt-1}function Pq(S,P){var U=this.__data__,K=hE(U,S);return K<0?(++this.size,U.push([S,P])):U[K][1]=P,this}e0.prototype.clear=Mq,e0.prototype.delete=Tq,e0.prototype.get=Cq,e0.prototype.has=Aq,e0.prototype.set=Pq;function t0(S){var P=-1,U=S==null?0:S.length;for(this.clear();++P=P?S:P)),S}function _p(S,P,U,K,pe,xe){var je,rt=P&T,mt=P&M,vn=P&L;if(U&&(je=pe?U(S,K,pe,xe):U(S)),je!==s)return je;if(!Fc(S))return S;var En=Rs(S);if(En){if(je=AX(S),!rt)return qh(S,je)}else{var In=Gf(S),Vi=In==xr||In==oe;if(kd(S))return NN(S,rt);if(In==_n||In==gn||Vi&&!pe){if(je=mt||Vi?{}:nF(S),!rt)return mt?bX(S,Vq(je,S)):mX(S,pN(je,S))}else{if(!nc[In])return pe?S:{};je=PX(S,In,rt)}}xe||(xe=new vg);var mr=xe.get(S);if(mr)return mr;xe.set(S,je),zF(S)?S.forEach(function(Vr){je.add(_p(Vr,P,U,Vr,S,xe))}):FF(S)&&S.forEach(function(Vr,so){je.set(so,_p(Vr,P,U,so,S,xe))});var Fr=vn?mt?tR:eR:mt?Xh:Ou,eo=En?s:Fr(S);return Cd(eo||S,function(Vr,so){eo&&(so=Vr,Vr=S[so]),fE(je,so,_p(Vr,P,U,so,S,xe))}),je}function Wq(S){var P=Ou(S);return function(U){return gN(U,S,P)}}function gN(S,P,U){var K=U.length;if(S==null)return!K;for(S=Wa(S);K--;){var pe=U[K],xe=P[pe],je=S[pe];if(je===s&&!(pe in S)||!xe(je))return!1}return!0}function mN(S,P,U){if(typeof S!="function")throw new wp(u);return yE(function(){S.apply(s,U)},P)}function dE(S,P,U,K){var pe=-1,xe=LT,je=!0,rt=S.length,mt=[],vn=P.length;if(!rt)return mt;U&&(P=Lc(P,Ad(U))),K?(xe=Ek,je=!1):P.length>=r&&(xe=sE,je=!1,P=new Nv(P));e:for(;++pepe?0:pe+U),K=K===s||K>pe?pe:Hs(K),K<0&&(K+=pe),K=U>K?0:jF(K);U0&&U(rt)?P>1?gf(rt,P-1,U,K,pe):zb(pe,rt):K||(pe[pe.length]=rt)}return pe}var YT=$N(),gE=$N(!0);function Dm(S,P){return S&&YT(S,P,Ou)}function ZT(S,P){return S&&gE(S,P,Ou)}function KT(S,P){return Ub(P,function(U){return a0(S[U])})}function n0(S,P){P=qb(P,S);for(var U=0,K=P.length;S!=null&&UP}function Xq(S,P){return S!=null&&_a.call(S,P)}function Yq(S,P){return S!=null&&P in Wa(S)}function Zq(S,P,U){return S>=zf(P,U)&&S=120&&En.length>=120)?new Nv(je&&En):s}En=S[0];var In=-1,Vi=rt[0];e:for(;++In-1;)rt!==S&>.call(rt,mt,1),GT.call(S,mt,1);return S}function PN(S,P){for(var U=S?P.length:0,K=U-1;U--;){var pe=P[U];if(U==K||pe!==xe){var xe=pe;s0(pe)?GT.call(S,pe,1):qk(S,pe)}}return S}function Vk(S,P){return S+VT(lN()*(P-S+1))}function sX(S,P,U,K){for(var pe=-1,xe=tu($T((P-S)/(U||1)),0),je=Jt(xe);xe--;)je[K?xe:++pe]=S,S+=U;return je}function Wk(S,P){var U="";if(!S||P<1||P>xt)return U;do P%2&&(U+=S),P=VT(P/2),P&&(S+=S);while(P);return U}function ro(S,P){return cR(sF(S,P,kc),S+"")}function oX(S){return dN(B2(S))}function aX(S,P){var U=B2(S);return cC(U,Fv(P,0,U.length))}function wE(S,P,U,K){if(!Fc(S))return S;P=qb(P,S);for(var pe=-1,xe=P.length,je=xe-1,rt=S;rt!=null&&++pepe?0:pe+P),U=U>pe?pe:U,U<0&&(U+=pe),pe=P>U?0:U-P>>>0,P>>>=0;for(var xe=Jt(pe);++K>>1,je=S[xe];je!==null&&!Rd(je)&&(U?je<=P:je=r){var vn=P?null:yX(S);if(vn)return RT(vn);je=!1,pe=sE,mt=new Nv}else mt=P?[]:rt;e:for(;++K=K?S:yp(S,P,U)}var ON=oq||function(S){return Iu.clearTimeout(S)};function NN(S,P){if(P)return S.slice();var U=S.length,K=rN?rN(U):new S.constructor(U);return S.copy(K),K}function Kk(S){var P=new S.constructor(S.byteLength);return new UT(P).set(new UT(S)),P}function hX(S,P){var U=P?Kk(S.buffer):S.buffer;return new S.constructor(U,S.byteOffset,S.byteLength)}function dX(S){var P=new S.constructor(S.source,AT.exec(S));return P.lastIndex=S.lastIndex,P}function pX(S){return uE?Wa(uE.call(S)):{}}function FN(S,P){var U=P?Kk(S.buffer):S.buffer;return new S.constructor(U,S.byteOffset,S.length)}function UN(S,P){if(S!==P){var U=S!==s,K=S===null,pe=S===S,xe=Rd(S),je=P!==s,rt=P===null,mt=P===P,vn=Rd(P);if(!rt&&!vn&&!xe&&S>P||xe&&je&&mt&&!rt&&!vn||K&&je&&mt||!U&&mt||!pe)return 1;if(!K&&!xe&&!vn&&S=rt)return mt;var vn=U[K];return mt*(vn=="desc"?-1:1)}}return S.index-P.index}function zN(S,P,U,K){for(var pe=-1,xe=S.length,je=U.length,rt=-1,mt=P.length,vn=tu(xe-je,0),En=Jt(mt+vn),In=!K;++rt1?U[pe-1]:s,je=pe>2?U[2]:s;for(xe=S.length>3&&typeof xe=="function"?(pe--,xe):s,je&&jf(U[0],U[1],je)&&(xe=pe<3?s:xe,pe=1),P=Wa(P);++K-1?pe[xe?P[je]:je]:s}}function HN(S){return r0(function(P){var U=P.length,K=U,pe=vp.prototype.thru;for(S&&P.reverse();K--;){var xe=P[K];if(typeof xe!="function")throw new wp(u);if(pe&&!je&&oC(xe)=="wrapper")var je=new vp([],!0)}for(K=je?K:U;++K1&&Go.reverse(),En&&mtrt))return!1;var vn=xe.get(S),En=xe.get(P);if(vn&&En)return vn==P&&En==S;var In=-1,Vi=!0,mr=U&D?new Nv:s;for(xe.set(S,P),xe.set(P,S);++In1?"& ":"")+P[K],P=P.join(U>2?", ":" "),S.replace($i,`{ +/* [wrapped with `+P+`] */ +`)}function kX(S){return Rs(S)||Vv(S)||!!(aN&&S&&S[aN])}function s0(S,P){var U=typeof S;return P=P??xt,!!P&&(U=="number"||U!="symbol"&&en.test(S))&&S>-1&&S%1==0&&S0){if(++P>=tt)return arguments[0]}else P=0;return S.apply(s,arguments)}}function cC(S,P){var U=-1,K=S.length,pe=K-1;for(P=P===s?K:P;++U1?S[P-1]:s;return U=typeof U=="function"?(S.pop(),U):s,o0(S,U)});function SF(S){var P=_e(S);return P.__chain__=!0,P}function xde(S,P){return P(S),S}function gR(S,P){return P(S)}var Ede=r0(function(S){var P=S.length,U=P?S[0]:0,K=this.__wrapped__,pe=function(xe){return Ok(xe,S)};return P>1||this.__actions__.length||!(K instanceof Ro)||!s0(U)?this.thru(pe):(K=K.slice(U,+U+(P?1:0)),K.__actions__.push({func:gR,args:[pe],thisArg:s}),new vp(K,this.__chain__).thru(function(xe){return P&&!xe.length&&xe.push(s),xe}))});function Sde(){return SF(this)}function Mde(){return new vp(this.value(),this.__chain__)}function Bu(){this.__values__===s&&(this.__values__=GF(this.value()));var S=this.__index__>=this.__values__.length,P=S?s:this.__values__[this.__index__++];return{done:S,value:P}}function Tde(){return this}function Cde(S){for(var P,U=this;U instanceof qT;){var K=fF(U);K.__index__=0,K.__values__=s,P?pe.__wrapped__=K:P=K;var pe=K;U=U.__wrapped__}return pe.__wrapped__=S,P}function Ade(){var S=this.__wrapped__;if(S instanceof Ro){var P=S;return this.__actions__.length&&(P=new Ro(this)),P=P.reverse(),P.__actions__.push({func:gR,args:[fR],thisArg:s}),new vp(P,this.__chain__)}return this.thru(fR)}function pY(){return DN(this.__wrapped__,this.__actions__)}var MF=tC(function(S,P,U){_a.call(S,U)?++S[U]:Im(S,U,1)});function Pde(S,P,U){var K=Rs(S)?qO:Hq;return U&&jf(S,P,U)&&(P=s),K(S,ts(P,3))}function Lde(S,P){var U=Rs(S)?Ub:pE;return U(S,ts(P,3))}var TF=WN(dF),CF=WN(pF);function kde(S,P){return gf(mR(S,P),1)}function Rde(S,P){return gf(mR(S,P),ot)}function Ide(S,P,U){return U=U===s?1:Hs(U),gf(mR(S,P),U)}function gY(S,P){var U=Rs(S)?Cd:Vb;return U(S,ts(P,3))}function mY(S,P){var U=Rs(S)?kH:bN;return U(S,ts(P,3))}var Dde=tC(function(S,P,U){_a.call(S,U)?S[U].push(P):Im(S,U,[P])});function Bde(S,P,U,K){S=mf(S)?S:B2(S),U=U&&!K?Hs(U):0;var pe=S.length;return U<0&&(U=tu(pe+U,0)),gC(S)?U<=pe&&S.indexOf(P,U)>-1:!!pe&&x2(S,P,U)>-1}var Ode=ro(function(S,P,U){var K=-1,pe=typeof P=="function",xe=mf(S)?Jt(S.length):[];return Vb(S,function(je){xe[++K]=pe?Td(P,je,U):mE(je,P,U)}),xe}),Nde=tC(function(S,P,U){Im(S,U,P)});function mR(S,P){var U=Rs(S)?Lc:SN;return U(S,ts(P,3))}function Fde(S,P,U,K){return S==null?[]:(Rs(P)||(P=P==null?[]:[P]),U=K?s:U,Rs(U)||(U=U==null?[]:[U]),Wb(S,P,U))}var Ude=tC(function(S,P,U){S[U?0:1].push(P)},function(){return[[],[]]});function zde(S,P,U){var K=Rs(S)?Sk:KO,pe=arguments.length<3;return K(S,ts(P,4),U,pe,Vb)}function Gde(S,P,U){var K=Rs(S)?RH:KO,pe=arguments.length<3;return K(S,ts(P,4),U,pe,bN)}function jde(S,P){var U=Rs(S)?Ub:pE;return U(S,hC(ts(P,3)))}function $de(S){var P=Rs(S)?dN:oX;return P(S)}function Vde(S,P,U){(U?jf(S,P,U):P===s)?P=1:P=Hs(P);var K=Rs(S)?Gq:aX;return K(S,P)}function bY(S){var P=Rs(S)?jq:lX;return P(S)}function wY(S){if(S==null)return 0;if(mf(S))return gC(S)?S2(S):S.length;var P=Gf(S);return P==de||P==ve?S.size:zk(S).length}function vY(S,P,U){var K=Rs(S)?Mk:uX;return U&&jf(S,P,U)&&(P=s),K(S,ts(P,3))}var AF=ro(function(S,P){if(S==null)return[];var U=P.length;return U>1&&jf(S,P[0],P[1])?P=[]:U>2&&jf(P[0],P[1],P[2])&&(P=[P[0]]),Wb(S,gf(P,1),[])}),jv=aq||function(){return Iu.Date.now()};function uC(S,P){if(typeof P!="function")throw new wp(u);return S=Hs(S),function(){if(--S<1)return P.apply(this,arguments)}}function fC(S,P,U){return P=U?s:P,P=S&&P==null?S.length:P,i0(S,ne,s,s,s,s,P)}function Zb(S,P){var U;if(typeof P!="function")throw new wp(u);return S=Hs(S),function(){return--S>0&&(U=P.apply(this,arguments)),S<=1&&(P=s),U}}var Nm=ro(function(S,P,U){var K=F;if(U.length){var pe=Gb(U,R2(Nm));K|=te}return i0(S,K,P,U,pe)}),PF=ro(function(S,P,U){var K=F|O;if(U.length){var pe=Gb(U,R2(PF));K|=te}return i0(P,K,S,U,pe)});function LF(S,P,U){P=U?s:P;var K=i0(S,Z,s,s,s,s,s,P);return K.placeholder=LF.placeholder,K}function dr(S,P,U){P=U?s:P;var K=i0(S,H,s,s,s,s,s,P);return K.placeholder=dr.placeholder,K}function kF(S,P,U){var K,pe,xe,je,rt,mt,vn=0,En=!1,In=!1,Vi=!0;if(typeof S!="function")throw new wp(u);P=Ep(P)||0,Fc(U)&&(En=!!U.leading,In="maxWait"in U,xe=In?tu(Ep(U.maxWait)||0,P):xe,Vi="trailing"in U?!!U.trailing:Vi);function mr(gl){var Yh=K,l0=pe;return K=pe=s,vn=gl,je=S.apply(l0,Yh),je}function Fr(gl){return vn=gl,rt=yE(so,P),En?mr(gl):je}function eo(gl){var Yh=gl-mt,l0=gl-vn,l8=P-Yh;return In?zf(l8,xe-l0):l8}function Vr(gl){var Yh=gl-mt,l0=gl-vn;return mt===s||Yh>=P||Yh<0||In&&l0>=xe}function so(){var gl=jv();if(Vr(gl))return Go(gl);rt=yE(so,eo(gl))}function Go(gl){return rt=s,Vi&&K?mr(gl):(K=pe=s,je)}function $f(){rt!==s&&ON(rt),vn=0,K=mt=pe=rt=s}function bh(){return rt===s?je:Go(jv())}function Ur(){var gl=jv(),Yh=Vr(gl);if(K=arguments,pe=this,mt=gl,Yh){if(rt===s)return Fr(mt);if(In)return ON(rt),rt=yE(so,P),mr(mt)}return rt===s&&(rt=yE(so,P)),je}return Ur.cancel=$f,Ur.flush=bh,Ur}var RF=ro(function(S,P){return mN(S,1,P)}),_Y=ro(function(S,P,U){return mN(S,Ep(P)||0,U)});function IF(S){return i0(S,Ce)}function I2(S,P){if(typeof S!="function"||P!=null&&typeof P!="function")throw new wp(u);var U=function(){var K=arguments,pe=P?P.apply(this,K):K[0],xe=U.cache;if(xe.has(pe))return xe.get(pe);var je=S.apply(this,K);return U.cache=xe.set(pe,je)||xe,je};return U.cache=new(I2.Cache||t0),U}I2.Cache=t0;function hC(S){if(typeof S!="function")throw new wp(u);return function(){var P=arguments;switch(P.length){case 0:return!S.call(this);case 1:return!S.call(this,P[0]);case 2:return!S.call(this,P[0],P[1]);case 3:return!S.call(this,P[0],P[1],P[2])}return!S.apply(this,P)}}function yY(S){return Zb(2,S)}var xY=fX(function(S,P){P=P.length==1&&Rs(P[0])?Lc(P[0],Ad(ts())):Lc(gf(P,1),Ad(ts()));var U=P.length;return ro(function(K){for(var pe=-1,xe=zf(K.length,U);++pe=P}),Vv=vN(function(){return arguments}())?vN:function(S){return Jc(S)&&_a.call(S,"callee")&&!oN.call(S,"callee")},Rs=Jt.isArray,BF=GO?Ad(GO):Jq;function mf(S){return S!=null&&pC(S.length)&&!a0(S)}function j(S){return Jc(S)&&mf(S)}function dC(S){return S===!0||S===!1||Jc(S)&&Du(S)==Hi}var kd=lq||yC,OY=jO?Ad(jO):_N;function Wv(S){return Jc(S)&&S.nodeType===1&&!ME(S)}function OF(S){if(S==null)return!0;if(mf(S)&&(Rs(S)||typeof S=="string"||typeof S.splice=="function"||kd(S)||D2(S)||Vv(S)))return!S.length;var P=Gf(S);if(P==de||P==ve)return!S.size;if(_E(S))return!zk(S).length;for(var U in S)if(_a.call(S,U))return!1;return!0}function NY(S,P){return bE(S,P)}function FY(S,P,U){U=typeof U=="function"?U:s;var K=U?U(S,P):s;return K===s?bE(S,P,s,U):!!K}function wR(S){if(!Jc(S))return!1;var P=Du(S);return P==Ei||P==Tr||typeof S.message=="string"&&typeof S.name=="string"&&!ME(S)}function UY(S){return typeof S=="number"&&cN(S)}function a0(S){if(!Fc(S))return!1;var P=Du(S);return P==xr||P==oe||P==Zi||P==qi}function NF(S){return typeof S=="number"&&S==Hs(S)}function pC(S){return typeof S=="number"&&S>-1&&S%1==0&&S<=xt}function Fc(S){var P=typeof S;return S!=null&&(P=="object"||P=="function")}function Jc(S){return S!=null&&typeof S=="object"}var FF=$O?Ad($O):yN;function vR(S,P){return S===P||Uk(S,P,iR(P))}function zY(S,P,U){return U=typeof U=="function"?U:s,Uk(S,P,iR(P),U)}function GY(S){return UF(S)&&S!=+S}function jY(S){if(oR(S))throw new Es(c);return xN(S)}function $Y(S){return S===null}function VY(S){return S==null}function UF(S){return typeof S=="number"||Jc(S)&&Du(S)==it}function ME(S){if(!Jc(S)||Du(S)!=_n)return!1;var P=zT(S);if(P===null)return!0;var U=_a.call(P,"constructor")&&P.constructor;return typeof U=="function"&&U instanceof U&&OT.call(U)==iq}var Kb=VO?Ad(VO):Qq;function WY(S){return NF(S)&&S>=-xt&&S<=xt}var zF=WO?Ad(WO):eX;function gC(S){return typeof S=="string"||!Rs(S)&&Jc(S)&&Du(S)==_t}function Rd(S){return typeof S=="symbol"||Jc(S)&&Du(S)==mn}var D2=HO?Ad(HO):tX;function HY(S){return S===s}function qY(S){return Jc(S)&&Gf(S)==Sn}function XY(S){return Jc(S)&&Du(S)==yi}var YY=sC(Gk),ZY=sC(function(S,P){return S<=P});function GF(S){if(!S)return[];if(mf(S))return gC(S)?wg(S):qh(S);if(oE&&S[oE])return WH(S[oE]());var P=Gf(S),U=P==de?kk:P==ve?RT:B2;return U(S)}function c0(S){if(!S)return S===0?S:0;if(S=Ep(S),S===ot||S===-ot){var P=S<0?-1:1;return P*fn}return S===S?S:0}function Hs(S){var P=c0(S),U=P%1;return P===P?U?P-U:P:0}function jF(S){return S?Fv(Hs(S),0,wn):0}function Ep(S){if(typeof S=="number")return S;if(Rd(S))return Xt;if(Fc(S)){var P=typeof S.valueOf=="function"?S.valueOf():S;S=Fc(P)?P+"":P}if(typeof S!="string")return S===0?S:+S;S=JO(S);var U=Le.test(S);return U||Kt.test(S)?AH(S.slice(2),U?2:8):bk.test(S)?Xt:+S}function $F(S){return Bm(S,Xh(S))}function KY(S){return S?Fv(Hs(S),-xt,xt):S===0?S:0}function ya(S){return S==null?"":Pd(S)}var JY=L2(function(S,P){if(_E(P)||mf(P)){Bm(P,Ou(P),S);return}for(var U in P)_a.call(P,U)&&fE(S,U,P[U])}),VF=L2(function(S,P){Bm(P,Xh(P),S)}),WF=L2(function(S,P,U,K){Bm(P,Xh(P),S,K)}),_R=L2(function(S,P,U,K){Bm(P,Ou(P),S,K)}),QY=r0(Ok);function eZ(S,P){var U=A2(S);return P==null?U:pN(U,P)}var tZ=ro(function(S,P){S=Wa(S);var U=-1,K=P.length,pe=K>2?P[2]:s;for(pe&&jf(P[0],P[1],pe)&&(K=1);++U1),xe}),Bm(S,tR(S),U),K&&(U=_p(U,T|M|L,xX));for(var pe=P.length;pe--;)qk(U,P[pe]);return U});function bZ(S,P){return qF(S,hC(ts(P)))}var mC=r0(function(S,P){return S==null?{}:jk(S,P)});function qF(S,P){if(S==null)return{};var U=Lc(tR(S),function(K){return[K]});return P=ts(P),AN(S,U,function(K,pe){return P(K,pe[0])})}function wZ(S,P,U){P=qb(P,S);var K=-1,pe=P.length;for(pe||(pe=1,S=s);++KP){var K=S;S=P,P=K}if(U||S%1||P%1){var pe=lN();return zf(S+pe*(P-S+CH("1e-"+((pe+"").length-1))),P)}return Vk(S,P)}var AZ=k2(function(S,P,U){return P=P.toLowerCase(),S+(U?ZF(P):P)});function ZF(S){return SR(ya(S).toLowerCase())}function KF(S){return S=ya(S),S&&S.replace(Yt,zH).replace(bH,"")}function PZ(S,P,U){S=ya(S),P=Pd(P);var K=S.length;U=U===s?K:Fv(Hs(U),0,K);var pe=U;return U-=P.length,U>=0&&S.slice(U,pe)==P}function LZ(S){return S=ya(S),S&&Zn.test(S)?S.replace(Je,GH):S}function kZ(S){return S=ya(S),S&&er.test(S)?S.replace(di,"\\$&"):S}var RZ=k2(function(S,P,U){return S+(U?"-":"")+P.toLowerCase()}),IZ=k2(function(S,P,U){return S+(U?" ":"")+P.toLowerCase()}),DZ=VN("toLowerCase");function BZ(S,P,U){S=ya(S),P=Hs(P);var K=P?S2(S):0;if(!P||K>=P)return S;var pe=(P-K)/2;return rC(VT(pe),U)+S+rC($T(pe),U)}function OZ(S,P,U){S=ya(S),P=Hs(P);var K=P?S2(S):0;return P&&K>>0,U?(S=ya(S),S&&(typeof P=="string"||P!=null&&!Kb(P))&&(P=Pd(P),!P&&E2(S))?Xb(wg(S),0,U):S.split(P,U)):[]}var $Z=k2(function(S,P,U){return S+(U?" ":"")+SR(P)});function JF(S,P,U){return S=ya(S),U=U==null?0:Fv(Hs(U),0,S.length),P=Pd(P),S.slice(U,U+P.length)==P}function Sr(S,P,U){var K=_e.templateSettings;U&&jf(S,P,U)&&(P=s),S=ya(S),P=_R({},P,K,KN);var pe=_R({},P.imports,K.imports,KN),xe=Ou(pe),je=Lk(pe,xe);Cd(xe,function(Vr){if(mg.test(Vr))throw new Es(b)});var rt,mt,vn=0,En=P.interpolate||Xi,In="__p += '",Vi=IT((P.escape||Xi).source+"|"+En.source+"|"+(En===et?Rv:Xi).source+"|"+(P.evaluate||Xi).source+"|$","g"),mr="//# sourceURL="+(_a.call(P,"sourceURL")?(P.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++xH+"]")+` +`;S.replace(Vi,function(Vr,so,Go,$f,bh,Ur){return Go||(Go=$f),In+=S.slice(vn,Ur).replace(Rr,jH),so&&(rt=!0,In+=`' + +__e(`+so+`) + +'`),bh&&(mt=!0,In+=`'; +`+bh+`; +__p += '`),Go&&(In+=`' + +((__t = (`+Go+`)) == null ? '' : __t) + +'`),vn=Ur+Vr.length,Vr}),In+=`'; +`;var Fr=_a.call(P,"variable")&&P.variable;if(!Fr)In=`with (obj) { +`+In+` +} +`;else if(mg.test(Fr))throw new Es(d);In=(mt?In.replace(qn,""):In).replace(xi,"$1").replace(Bi,"$1;"),In="function("+(Fr||"obj")+`) { +`+(Fr?"":`obj || (obj = {}); +`)+"var __t, __p = ''"+(rt?", __e = _.escape":"")+(mt?`, __j = Array.prototype.join; function print() { __p += __j.call(arguments, '') } `:`; -`)+Wn+`return __p -}`;var no=a9(function(){return Wo(St,Er+"return "+Wn).apply(d,Vt)});if(no.source=Wn,m5(no))throw no;return no}function gG(x){return Ac(x).toLowerCase()}function mG(x){return Ac(x).toUpperCase()}function bG(x,C,F){if(x=Ac(x),x&&(F||C===d))return Yf(x);if(!x||!(C=Fd(C)))return x;var J=Kf(x),mt=Kf(C),St=LS(J,mt),Vt=G0(J,mt)+1;return kb(J,St,Vt).join("")}function wG(x,C,F){if(x=Ac(x),x&&(F||C===d))return x.slice(0,By(x)+1);if(!x||!(C=Fd(C)))return x;var J=Kf(x),mt=G0(J,Kf(C))+1;return kb(J,0,mt).join("")}function vG(x,C,F){if(x=Ac(x),x&&(F||C===d))return x.replace(va,"");if(!x||!(C=Fd(C)))return x;var J=Kf(x),mt=LS(J,Kf(C));return kb(J,mt).join("")}function _G(x,C){var F=ot,J=Lt;if($a(C)){var mt="separator"in C?C.separator:mt;F="length"in C?Ys(C.length):F,J="omission"in C?Fd(C.omission):J}x=Ac(x);var St=x.length;if(gf(x)){var Vt=Kf(x);St=Vt.length}if(F>=St)return x;var ee=F-l1(J);if(ee<1)return J;var fe=Vt?kb(Vt,0,ee).join(""):x.slice(0,ee);if(mt===d)return fe+J;if(Vt&&(ee+=fe.length-ee),Ib(mt)){if(x.slice(ee).search(mt)){var Cn,kn=fe;for(mt.global||(mt=mf(mt.source,Ac(iv.exec(mt))+"g")),mt.lastIndex=0;Cn=mt.exec(kn);)var Wn=Cn.index;fe=fe.slice(0,Wn===d?ee:Wn)}}else if(x.indexOf(Fd(mt),ee)!=ee){var Ki=fe.lastIndexOf(mt);Ki>-1&&(fe=fe.slice(0,Ki))}return fe+J}function yG(x){return x=Ac(x),x&&Mi.test(x)?x.replace(Ln,Fy):x}var xG=Xy(function(x,C,F){return x+(F?" ":"")+C.toUpperCase()}),x5=QR("toUpperCase");function Qy(x,C,F){return x=Ac(x),C=F?d:C,C===d?Ny(x)?wb(x):Ly(x):x.match(C)||[]}var a9=oo(function(x,C){try{return df(x,d,C)}catch(F){return m5(F)?F:new vs(F)}}),aT=K0(function(x,C){return su(C,function(F){F=p1(F),kg(x,F,Rg(x[F],x))}),x});function uT(x){var C=x==null?0:x.length,F=cs();return x=C?ea(x,function(J){if(typeof J[1]!="function")throw new Jf(m);return[F(J[0]),J[1]]}):[],oo(function(J){for(var mt=-1;++mthn)return[];var F=mn,J=$t(x,mn);C=cs(C),x-=mn;for(var mt=Ry(J,C);++F0||C<0)?new po(F):(x<0?F=F.takeRight(-x):x&&(F=F.drop(x)),C!==d&&(C=Ys(C),F=C<0?F.dropRight(-C):F.take(C-x)),F)},po.prototype.takeRightWhile=function(x){return this.reverse().takeWhile(x).reverse()},po.prototype.toArray=function(){return this.take(mn)},Lg(po.prototype,function(x,C){var F=/^(?:filter|find|map|reject)|While$/.test(C),J=/^(?:head|last)$/.test(C),mt=Mt[J?"take"+(C=="last"?"Right":""):C],St=J||/^find/.test(C);mt&&(Mt.prototype[C]=function(){var Vt=this.__wrapped__,ee=J?[1]:arguments,fe=Vt instanceof po,Cn=ee[0],kn=fe||Us(Vt),Wn=function(co){var $o=mt.apply(Mt,Mg([co],ee));return J&&Ki?$o[0]:$o};kn&&F&&typeof Cn=="function"&&Cn.length!=1&&(fe=kn=!1);var Ki=this.__chain__,Er=!!this.__actions__.length,Wr=St&&!Ki,no=fe&&!Er;if(!St&&kn){Vt=no?Vt:new po(this);var Zr=x.apply(Vt,ee);return Zr.__actions__.push({func:d5,args:[Wn],thisArg:d}),new bf(Zr,Ki)}return Wr&&no?x.apply(this,ee):(Zr=this.thru(Wn),Wr?J?Zr.value()[0]:Zr.value():Zr)})}),su(["pop","push","shift","sort","splice","unshift"],function(x){var C=W0[x],F=/^(?:push|sort|unshift)$/.test(x)?"tap":"thru",J=/^(?:pop|shift)$/.test(x);Mt.prototype[x]=function(){var mt=arguments;if(J&&!this.__chain__){var St=this.value();return C.apply(Us(St)?St:[],mt)}return this[F](function(Vt){return C.apply(Us(Vt)?Vt:[],mt)})}}),Lg(po.prototype,function(x,C){var F=Mt[C];if(F){var J=F.name+"";pc.call(yb,J)||(yb[J]=[]),yb[J].push({name:C,func:F})}}),yb[qS(d,Q).name]=[{name:"wrapper",func:d}],po.prototype.clone=$U,po.prototype.reverse=VU,po.prototype.value=qU,Mt.prototype.at=Int,Mt.prototype.chain=Rnt,Mt.prototype.commit=Dnt,Mt.prototype.next=jl,Mt.prototype.plant=Ont,Mt.prototype.reverse=Bnt,Mt.prototype.toJSON=Mt.prototype.valueOf=Mt.prototype.value=Uj,Mt.prototype.first=Mt.prototype.head,_b&&(Mt.prototype[_b]=Nnt),Mt},Bd=zy();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Cc._=Bd,define(function(){return Bd})):xg?((xg.exports=Bd)._=Bd,H0._=Bd):Cc._=Bd}).call(CI)});var iU=Ld(nU=>{"use strict";Object.defineProperty(nU,"__esModule",{value:!0});var btt=tU(),A_t=DA(),ZXt;(function(d){d.skin=null;function s(N,B){var P=A_t.filter(N,function(U){if(U instanceof Array&&U[0]==="g")return U[1]["s:pid"].startsWith(B)});return P}d.getPortsWithPrefix=s;function h(N,B){var P=A_t.filter(N,function(U){var j=U[0];if(U instanceof Array&&j==="g"){var V=U[1];return B(V)}return!1});return P.map(function(U){return U[1]["s:pid"]})}function p(N){return h(N,function(B){return B["s:position"]?B["s:position"]==="top":!1})}d.getInputPids=p;function m(N){return h(N,function(B){return B["s:position"]?B["s:position"]==="bottom":!1})}d.getOutputPids=m;function _(N){return h(N,function(B){return B["s:dir"]?B["s:dir"]==="lateral":B["s:position"]?B["s:position"]==="left"||B["s:position"]==="right":!1})}d.getLateralPortPids=_;function S(N){var B=null;return btt.traverse(d.skin,{enter:function(P,U){P.name==="s:alias"&&P.attr.val===N&&(B=U)}}),B==null&&btt.traverse(d.skin,{enter:function(P){P.attr["s:type"]==="generic"&&(B=P)}}),B.full}d.findSkinType=S;function y(){var N=[];return btt.t(d.skin,{enter:function(B){B.name==="s:low_priority_alias"&&N.push(B.attr.value)}}),N}d.getLowPriorityAliases=y;function I(){var N;return btt.t(d.skin,{enter:function(B){B.name==="s:properties"?N=A_t.mapValues(B.attr,function(P){return isNaN(Number(P))?P==="true"?!0:P==="false"?!1:P:Number(P)}):B.name==="s:layoutEngine"&&(N.layoutEngine=B.attr)}}),N.layoutEngine||(N.layoutEngine={}),N}d.getProperties=I})(ZXt=nU.Skin||(nU.Skin={}));nU.default=ZXt});var YXt=Ld(L_t=>{"use strict";Object.defineProperty(L_t,"__esModule",{value:!0});var k_t;(function(d){var s;(function(S){S.Zero="0",S.One="1",S.X="x"})(s||(s={}));var h;(function(S){S.Input="input",S.Output="output"})(h=d.Direction||(d.Direction={}));function p(S){return S.port_directions?Object.keys(S.port_directions).filter(function(y){return S.port_directions[y]===h.Input}):[]}d.getInputPortPids=p;function m(S){return S.port_directions?Object.keys(S.port_directions).filter(function(y){return S.port_directions[y]===h.Output}):[]}d.getOutputPortPids=m;var _;(function(S){S[S.Hide=0]="Hide",S[S.NoHide=1]="NoHide"})(_||(_={}))})(k_t||(k_t={}));L_t.default=k_t});var KXt=Ld(I_t=>{"use strict";Object.defineProperty(I_t,"__esModule",{value:!0});var uMe=R_t(),P_t=DA(),lMe=function(){function d(s,h){this.key=s,this.value=h}return Object.defineProperty(d.prototype,"Key",{get:function(){return this.key},enumerable:!0,configurable:!0}),d.prototype.keyIn=function(s){return P_t.includes(s,this.key)},d.prototype.maxVal=function(){return P_t.max(P_t.map(this.value,function(s){return Number(s)}))},d.prototype.valString=function(){return","+this.value.join()+","},d.prototype.findConstants=function(s,h,p){var m=this,_="",S=[],y=this.value;return y.forEach(function(I,N){I==="0"||I==="1"?(h+=1,_+=I,y[N]=h,S.push(h)):S.length>0&&(m.assignConstant(_,S,N,s,p),_="",S=[])}),S.length>0&&this.assignConstant(_,S,y.length,s,p),h},d.prototype.getGenericElkPort=function(s,h,p){var m=this.parentNode.Key,_=this.parentNode.getTemplate()[1]["s:type"];if(s===0){var S={id:m+"."+this.key,width:1,height:1,x:Number(h[0][1]["s:x"]),y:Number(h[0][1]["s:y"])};return(_==="generic"||_==="join")&&p==="in"&&(S.labels=[{id:m+"."+this.key+".label",text:this.key,x:Number(h[0][2][1].x)-10,y:Number(h[0][2][1].y)-6,width:6*this.key.length,height:11}]),(_==="generic"||_==="split")&&p==="out"&&(S.labels=[{id:m+"."+this.key+".label",text:this.key,x:Number(h[0][2][1].x)-10,y:Number(h[0][2][1].y)-6,width:6*this.key.length,height:11}]),S}else{var y=Number(h[1][1]["s:y"])-Number(h[0][1]["s:y"]),S={id:m+"."+this.key,width:1,height:1,x:Number(h[0][1]["s:x"]),y:s*y+Number(h[0][1]["s:y"])};return _==="generic"&&(S.labels=[{id:m+"."+this.key+".label",text:this.key,x:Number(h[0][2][1].x)-10,y:Number(h[0][2][1].y)-6,width:6*this.key.length,height:11}]),S}},d.prototype.assignConstant=function(s,h,p,m,_){var S=this,y=s.split("").reverse().join("");if(m.hasOwnProperty(y)){var I=m[y],N=I.length;I.forEach(function(B,P){var U=p-N+P;S.value[U]=B})}else _.push(uMe.default.fromConstantInfo(y,h)),m[y]=h},d}();I_t.Port=lMe});var JXt=Ld((gJe,wtt)=>{var hMe=function(){"use strict";function d(B,P){return P!=null&&B instanceof P}var s;try{s=Map}catch{s=function(){}}var h;try{h=Set}catch{h=function(){}}var p;try{p=Promise}catch{p=function(){}}function m(B,P,U,j,V){typeof P=="object"&&(U=P.depth,j=P.prototype,V=P.includeNonEnumerable,P=P.circular);var et=[],Q=[],X=typeof Buffer<"u";typeof P>"u"&&(P=!0),typeof U>"u"&&(U=1/0);function gt(ft,xt){if(ft===null)return null;if(xt===0)return ft;var Bt,Dt;if(typeof ft!="object")return ft;if(d(ft,s))Bt=new s;else if(d(ft,h))Bt=new h;else if(d(ft,p))Bt=new p(function(xe,re){ft.then(function(hn){xe(gt(hn,xt-1))},function(hn){re(gt(hn,xt-1))})});else if(m.__isArray(ft))Bt=[];else if(m.__isRegExp(ft))Bt=new RegExp(ft.source,N(ft)),ft.lastIndex&&(Bt.lastIndex=ft.lastIndex);else if(m.__isDate(ft))Bt=new Date(ft.getTime());else{if(X&&Buffer.isBuffer(ft))return Buffer.allocUnsafe?Bt=Buffer.allocUnsafe(ft.length):Bt=new Buffer(ft.length),ft.copy(Bt),Bt;d(ft,Error)?Bt=Object.create(ft):typeof j>"u"?(Dt=Object.getPrototypeOf(ft),Bt=Object.create(Dt)):(Bt=Object.create(j),Dt=j)}if(P){var Pt=et.indexOf(ft);if(Pt!=-1)return Q[Pt];et.push(ft),Q.push(Bt)}d(ft,s)&&ft.forEach(function(xe,re){var hn=gt(re,xt-1),Se=gt(xe,xt-1);Bt.set(hn,Se)}),d(ft,h)&&ft.forEach(function(xe){var re=gt(xe,xt-1);Bt.add(re)});for(var se in ft){var ot;Dt&&(ot=Object.getOwnPropertyDescriptor(Dt,se)),!(ot&&ot.set==null)&&(Bt[se]=gt(ft[se],xt-1))}if(Object.getOwnPropertySymbols)for(var Lt=Object.getOwnPropertySymbols(ft),se=0;se{"use strict";Object.defineProperty(B_t,"__esModule",{value:!0});var vtt=F_t(),D_t=YXt(),n1=iU(),ZE=KXt(),N_t=DA(),rU=JXt(),_tt=tU(),fMe=function(){function d(s,h,p,m,_){var S=this;this.key=s,this.type=h,this.inputPorts=p,this.outputPorts=m,this.attributes=_||{},p.forEach(function(y){y.parentNode=S}),m.forEach(function(y){y.parentNode=S})}return d.fromPort=function(s,h){var p=s.direction===D_t.default.Direction.Input;return p?new d(h,"$_inputExt_",[],[new ZE.Port("Y",s.bits)],{}):new d(h,"$_outputExt_",[new ZE.Port("A",s.bits)],[],{})},d.fromYosysCell=function(s,h){var p=n1.default.findSkinType(s.type),m=n1.default.getInputPids(p),_=n1.default.getOutputPids(p),S=N_t.map(s.connections,function(P,U){return new ZE.Port(U,P)}),y=S.filter(function(P){return P.keyIn(m)}),I=S.filter(function(P){return P.keyIn(_)});if(y.length+I.length!==S.length){var N=D_t.default.getInputPortPids(s),B=D_t.default.getOutputPortPids(s);y=S.filter(function(P){return P.keyIn(N)}),I=S.filter(function(P){return P.keyIn(B)})}return new d(h,s.type,y,I,s.attributes)},d.fromConstantInfo=function(s,h){return new d(s,"$_constant_",[],[new ZE.Port("Y",h)],{})},d.fromJoinInfo=function(s,h){var p=s.slice(1,-1).split(","),m=p.map(function(y){return Number(y)}),_=[new ZE.Port("Y",m)],S=h.map(function(y){return new ZE.Port(y,QXt(m,y))});return new d("$join$"+s,"$_join_",S,_,{})},d.fromSplitInfo=function(s,h){var p=s.slice(1,-1).split(","),m=p.map(function(y){return Number(y)}),_=[new ZE.Port("A",m)],S=h.map(function(y){var I=QXt(m,y);return new ZE.Port(y,I)});return new d("$split$"+s,"$_split_",_,S,{})},Object.defineProperty(d.prototype,"Type",{get:function(){return this.type},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"Key",{get:function(){return this.key},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"InputPorts",{get:function(){return this.inputPorts},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"OutputPorts",{get:function(){return this.outputPorts},enumerable:!0,configurable:!0}),d.prototype.maxOutVal=function(s){var h=N_t.max(this.outputPorts.map(function(p){return p.maxVal()}));return N_t.max([h,s])},d.prototype.findConstants=function(s,h,p){return this.inputPorts.forEach(function(m){h=m.findConstants(s,h,p)}),h},d.prototype.inputPortVals=function(){return this.inputPorts.map(function(s){return s.valString()})},d.prototype.outputPortVals=function(){return this.outputPorts.map(function(s){return s.valString()})},d.prototype.collectPortsByDirection=function(s,h,p,m){var _=n1.default.findSkinType(this.type),S=n1.default.getLateralPortPids(_);this.inputPorts.forEach(function(y){var I=y.keyIn(S);I||_[1]["s:type"]==="generic"&&m?vtt.addToDefaultDict(p,y.valString(),y):vtt.addToDefaultDict(s,y.valString(),y)}),this.outputPorts.forEach(function(y){var I=y.keyIn(S);I||_[1]["s:type"]==="generic"&&m?vtt.addToDefaultDict(p,y.valString(),y):vtt.addToDefaultDict(h,y.valString(),y)})},d.prototype.getValueAttribute=function(){return this.attributes&&this.attributes.value?this.attributes.value:null},d.prototype.getTemplate=function(){return n1.default.findSkinType(this.type)},d.prototype.buildElkChild=function(){var s=this,h=this.getTemplate(),p=h[1]["s:type"],m={"org.eclipse.elk.portConstraints":"FIXED_POS"},_=null,S=null;for(var y in this.attributes)if(y.startsWith("org.eclipse.elk")){if(y==="org.eclipse.elk.x"){_=this.attributes[y];continue}if(y==="org.eclipse.elk.y"){S=this.attributes[y];continue}m[y]=this.attributes[y]}if(p==="join"||p==="split"||p==="generic"){var I=n1.default.getPortsWithPrefix(h,"in"),N=n1.default.getPortsWithPrefix(h,"out"),B=this.inputPorts.map(function(Q,X){return Q.getGenericElkPort(X,I,"in")}),P=this.outputPorts.map(function(Q,X){return Q.getGenericElkPort(X,N,"out")}),U={id:this.key,width:Number(h[1]["s:width"]),height:Number(this.getGenericHeight()),ports:B.concat(P),layoutOptions:m,labels:[]};return _&&(U.x=_),S&&(U.y=S),this.addLabels(h,U),U}var j=n1.default.getPortsWithPrefix(h,"").map(function(Q){return{id:s.key+"."+Q[1]["s:pid"],width:0,height:0,x:Number(Q[1]["s:x"]),y:Number(Q[1]["s:y"])}}),V=Number(h[1]["s:width"]),et={id:this.key,width:V,height:Number(h[1]["s:height"]),ports:j,layoutOptions:m,labels:[]};return _&&(et.x=_),S&&(et.y=S),this.addLabels(h,et),et},d.prototype.render=function(s){for(var h=this.getTemplate(),p=rU(h),m=0,_=s.labels;m<_.length;m++){var S=_[m],y=S.id.split(".")[2];dMe(p,y,S.text)}for(var I=2;I3){var y=parseInt(p.key,2);S="0x"+y.toString(16)}else S=p.key;p.attributes[_]=p.key}else if(_ in p.attributes)S=p.attributes[_];else return;h.labels.push({id:p.key+".label."+_,text:S,x:m.attr.x,y:m.attr.y-6,height:11,width:6*S.length})}}})},d.prototype.getGenericHeight=function(){var s=this.getTemplate(),h=n1.default.getPortsWithPrefix(s,"in"),p=n1.default.getPortsWithPrefix(s,"out");if(this.inputPorts.length>this.outputPorts.length){var m=Number(h[1][1]["s:y"])-Number(h[0][1]["s:y"]);return Number(s[1]["s:height"])+m*(this.inputPorts.length-2)}if(p.length>1){var m=Number(p[1][1]["s:y"])-Number(p[0][1]["s:y"]);return Number(s[1]["s:height"])+m*(this.outputPorts.length-2)}return Number(s[1]["s:height"])},d}();B_t.default=fMe;function O_t(d,s){_tt.traverse(d,{enter:function(h){h.name==="rect"&&h.attr["s:generic"]==="body"&&(h.attr.height=s)}})}function dMe(d,s,h){_tt.traverse(d,{enter:function(p){p.name==="text"&&p.attr["s:attribute"]===s&&(p.full[2]=h)}})}function pMe(d,s,h){_tt.traverse(d,{enter:function(p){var m=p.attr.class;m&&m.includes(s)&&(p.attr.class=m.replace(s,h))}})}function QXt(d,s){var h=s.indexOf(":");if(h===-1)return[d[Number(s)]];var p=s.slice(0,h),m=s.slice(h+1),_=d.slice(Number(p),Number(m)+1);return _}});var F_t=Ld(AI=>{"use strict";Object.defineProperty(AI,"__esModule",{value:!0});var gMe=iU(),ytt=R_t(),L0=DA(),mMe=function(){function d(s){var h=this;this.moduleName=null,L0.forEach(s.modules,function(S,y){S.attributes&&Number(S.attributes.top)===1&&(h.moduleName=y)}),this.moduleName==null&&(this.moduleName=Object.keys(s.modules)[0]);var p=s.modules[this.moduleName],m=L0.map(p.ports,ytt.default.fromPort),_=L0.map(p.cells,function(S,y){return ytt.default.fromYosysCell(S,y)});this.nodes=_.concat(m),this.wires=[]}return d.prototype.addConstants=function(){var s=this.nodes.reduce(function(m,_){return _.maxOutVal(m)},-1),h={},p=[];this.nodes.forEach(function(m){s=m.findConstants(h,s,p)}),this.nodes=this.nodes.concat(p)},d.prototype.addSplitsJoins=function(){var s=L0.flatMap(this.nodes,function(S){return S.inputPortVals()}),h=L0.flatMap(this.nodes,function(S){return S.outputPortVals()}),p=s.slice(),m={},_={};s.forEach(function(S){oU(h,p,S,0,S.length,m,_)}),this.nodes=this.nodes.concat(L0.map(_,function(S,y){return ytt.default.fromJoinInfo(y,S)})).concat(L0.map(m,function(S,y){return ytt.default.fromSplitInfo(y,S)}))},d.prototype.createWires=function(){var s=gMe.default.getProperties(),h={},p={},m={};this.nodes.forEach(function(y){y.collectPortsByDirection(h,p,m,s.genericsLaterals)});var _=nZt(L0.keys(h).concat(L0.keys(p)).concat(L0.keys(m))),S=_.map(function(y){var I=p[y]||[],N=h[y]||[],B=m[y]||[],P={netName:y,drivers:I,riders:N,laterals:B};return I.concat(N).concat(B).forEach(function(U){U.wire=P}),P});this.wires=S},d}();AI.FlatModule=mMe;function bMe(d){var s="";return d.forEach(function(h){var p=String(h);s===""?s=p:s+=","+p}),","+s+","}AI.arrayToBitstring=bMe;function eZt(d,s){return s.indexOf(d)>-1}function tZt(d,s){return L0.findIndex(s,function(h){return eZt(d,h)})}function sU(d,s,h){d[s]===void 0?d[s]=[h]:d[s].push(h)}AI.addToDefaultDict=sU;function xtt(d,s,h){var p=L0.max([d.indexOf(s),h]),m=d.substring(0,p).split(",").length-1,_=m+s.split(",").length-3;return m===_?String(m):String(m)+":"+String(_)}function oU(d,s,h,p,m,_,S){var y=s.indexOf(h);if(y!==-1&&s.splice(y,1),!(p>=h.length||m-p<2)){var I=h.slice(p,m);if(eZt(I,d)){I!==h&&sU(S,h,xtt(h,I,p)),oU(d,s,h,m-1,h.length,_,S);return}var N=tZt(I,d);if(N!==-1){I!==h&&sU(S,h,xtt(h,I,p)),sU(_,d[N],xtt(d[N],I,0)),d.push(I),oU(d,s,h,m-1,h.length,_,S);return}if(tZt(I,s)!==-1){I!==h&&sU(S,h,xtt(h,I,p)),oU(d,[],I,0,I.length,_,S),d.push(I);return}oU(d,s,h,p,p+I.slice(0,-1).lastIndexOf(",")+1,_,S)}}function nZt(d){var s={};return d.forEach(function(h){s[h]=!0}),L0.keys(s)}AI.removeDups=nZt});var z_t=Ld(cU=>{"use strict";Object.defineProperty(cU,"__esModule",{value:!0});var rZt=DA(),Gf;(function(d){d.wireNameLookup={},d.dummyNum=0,d.edgeIndex=0})(Gf=cU.ElkModel||(cU.ElkModel={}));function wMe(d){var s=d.nodes.map(function(p){return p.buildElkChild()});Gf.edgeIndex=0,Gf.dummyNum=0;var h=rZt.flatMap(d.wires,function(p){if(p.drivers.length>0&&p.riders.length>0&&p.laterals.length===0){var m=[];return U_t(p.drivers,p.riders,m),m}else if(p.drivers.concat(p.riders).length>0&&p.laterals.length>0){var m=[];return U_t(p.drivers,p.laterals,m),U_t(p.laterals,p.riders,m),m}else if(p.riders.length===0&&p.drivers.length>1){var _=iZt(s);Gf.dummyNum+=1;var S=p.drivers.map(function(P){var U=P.parentNode.Key,j="e"+String(Gf.edgeIndex);Gf.edgeIndex+=1;var V={id:j,source:U,sourcePort:U+"."+P.key,target:_,targetPort:_+".p"};return Gf.wireNameLookup[j]=P.wire.netName,V});return S}else if(p.riders.length>1&&p.drivers.length===0){var y=iZt(s);Gf.dummyNum+=1;var S=p.riders.map(function(U){var j=U.parentNode.Key,V="e"+String(Gf.edgeIndex);Gf.edgeIndex+=1;var et={id:V,source:y,sourcePort:y+".p",target:j,targetPort:j+"."+U.key};return Gf.wireNameLookup[V]=U.wire.netName,et});return S}else if(p.laterals.length>1){var I=p.laterals[0],N=I.parentNode.Key,B=p.laterals.slice(1).map(function(P){var U=P.parentNode.Key,j="e"+String(Gf.edgeIndex);Gf.edgeIndex+=1;var V={id:j,source:N,sourcePort:N+"."+I.key,target:U,targetPort:U+"."+P.key};return Gf.wireNameLookup[j]=P.wire.netName,V});return B}return[]});return{id:d.moduleName,children:s,edges:h}}cU.buildElkGraph=wMe;function iZt(d){var s="$d_"+String(Gf.dummyNum),h={id:s,width:0,height:0,ports:[{id:s+".p",width:0,height:0}],layoutOptions:{"org.eclipse.elk.portConstraints":"FIXED_SIDE"}};return d.push(h),s}function U_t(d,s,h){var p=rZt.flatMap(d,function(m){var _=m.parentNode.key,S=_+"."+m.key;return s.map(function(y){var I=y.parentNode.key,N=I+"."+y.key,B="e"+Gf.edgeIndex,P={id:B,sources:[S],targets:[N]};return Gf.wireNameLookup[B]=y.wire.netName,m.parentNode.type!=="$dff"&&(P.layoutOptions={"org.eclipse.elk.layered.priority.direction":10}),Gf.edgeIndex+=1,P})});h.push.apply(h,p)}});var uZt=Ld(LI=>{"use strict";var sZt=LI&&LI.__spreadArrays||function(){for(var d=0,s=0,h=arguments.length;s0?[X.bendPoints[0]]:X.endPoint:X.bendPoints&&X.bendPoints.length>0?[by.last(X.bendPoints)]:X.startPoint}).map(function(Q){return Q.x>N.x?kI.Right:Q.xN.y?kI.Down:kI.Up}));et.size<3&&_.forEach(function(Q){Q.junctionPoints&&(Q.junctionPoints=Q.junctionPoints.filter(function(X){return!by.isEqual(X,N)}))}),s+=1};s<1e4;){var p=h();if(p==="break")break}}LI.removeDummyEdges=aZt});var pZt=Ld(Ett=>{"use strict";Object.defineProperty(Ett,"__esModule",{value:!0});var xMe=OXt(),MMe=tU(),EMe=F_t(),Mtt=iU(),hZt=z_t(),lZt=uZt(),fZt=new xMe;function dZt(d,s){Mtt.default.skin=MMe.p(d);var h=Mtt.default.getProperties(),p=new EMe.FlatModule(s);return h.constants!==!1&&p.addConstants(),h.splitsAndJoins!==!1&&p.addSplitsJoins(),p.createWires(),p}function SMe(d,s,h,p){var m=dZt(d,s),_=hZt.buildElkGraph(m);if(h){p(null,JSON.stringify(_,null,2));return}var S=Mtt.default.getProperties(),y=fZt.layout(_,{layoutOptions:S.layoutEngine});y.then(function(I){p(null,JSON.stringify(I,null,2))}).catch(function(I){throw Error(I)})}Ett.dumpLayout=SMe;function TMe(d,s,h,p){var m=dZt(d,s),_=hZt.buildElkGraph(m),S=Mtt.default.getProperties(),y;return p?y=new Promise(function(I){lZt.default(p,m),I()}):y=fZt.layout(_,{layoutOptions:S.layoutEngine}).then(function(I){return lZt.default(I,m)}).catch(function(I){console.error(I)}),typeof h=="function"&&y.then(function(I){return h(null,I),I}).catch(function(I){throw Error(I)}),y}Ett.render=TMe});var sJe=IXt(DXt());var PAe=IXt(pZt());var f2t={};eMe(f2t,{AmbientLight:()=>Aet,BoxGeometry:()=>VA,Color:()=>Go,DirectionalLight:()=>Cet,DoubleSide:()=>$w,EdgesGeometry:()=>Met,GridHelper:()=>Let,Group:()=>iS,InstancedMesh:()=>xet,LineBasicMaterial:()=>rR,LineSegments:()=>MU,Matrix4:()=>Bu,Mesh:()=>pg,MeshBasicMaterial:()=>nR,MeshPhongMaterial:()=>Eet,PerspectiveCamera:()=>s1,Quaternion:()=>vy,Raycaster:()=>ket,Scene:()=>_et,Vector2:()=>Nc,Vector3:()=>Ge,WebGLRenderer:()=>xU});var s2t="160";var CMe=0,gZt=1,AMe=2;var qYt=1,kMe=2,Vx=3,cS=0,gg=1,$w=2;var rS=0,YI=1,mZt=2,bZt=3,wZt=4,LMe=5,zA=100,PMe=101,IMe=102,vZt=103,_Zt=104,RMe=200,DMe=201,NMe=202,OMe=203,_yt=204,yyt=205,BMe=206,FMe=207,UMe=208,zMe=209,jMe=210,HMe=211,GMe=212,WMe=213,$Me=214,VMe=0,qMe=1,XMe=2,tet=3,ZMe=4,YMe=5,KMe=6,JMe=7,o2t=0,QMe=1,tEe=2,sS=0,eEe=1,nEe=2,iEe=3,rEe=4,sEe=5,oEe=6;var XYt=300,QI=301,tR=302,xyt=303,Myt=304,Pet=306,Eyt=1e3,Vw=1001,Syt=1002,r1=1003,yZt=1004;var j_t=1005;var pb=1006,cEe=1007;var bU=1008;var oS=1009,aEe=1010,uEe=1011,c2t=1012,ZYt=1013,eS=1014,nS=1015,wU=1016,YYt=1017,KYt=1018,GA=1020,lEe=1021,qw=1023,hEe=1024,fEe=1025,WA=1026,eR=1027,dEe=1028,JYt=1029,pEe=1030,QYt=1031,tKt=1033,H_t=33776,G_t=33777,W_t=33778,$_t=33779,xZt=35840,MZt=35841,EZt=35842,SZt=35843,eKt=36196,TZt=37492,CZt=37496,AZt=37808,kZt=37809,LZt=37810,PZt=37811,IZt=37812,RZt=37813,DZt=37814,NZt=37815,OZt=37816,BZt=37817,FZt=37818,UZt=37819,zZt=37820,jZt=37821,V_t=36492,HZt=36494,GZt=36495,gEe=36283,WZt=36284,$Zt=36285,VZt=36286;var eet=2300,net=2301,q_t=2302,qZt=2400,XZt=2401,ZZt=2402;var nKt=3e3,$A=3001,mEe=3200,bEe=3201,iKt=0,wEe=1,gb="",Pd="srgb",Zx="srgb-linear",a2t="display-p3",Iet="display-p3-linear",iet="linear",vu="srgb",ret="rec709",set="p3";var PI=7680;var YZt=519,vEe=512,_Ee=513,yEe=514,rKt=515,xEe=516,MEe=517,EEe=518,SEe=519,KZt=35044;var JZt="300 es",Tyt=1035,Xx=2e3,oet=2001,aS=class{addEventListener(s,h){this._listeners===void 0&&(this._listeners={});let p=this._listeners;p[s]===void 0&&(p[s]=[]),p[s].indexOf(h)===-1&&p[s].push(h)}hasEventListener(s,h){if(this._listeners===void 0)return!1;let p=this._listeners;return p[s]!==void 0&&p[s].indexOf(h)!==-1}removeEventListener(s,h){if(this._listeners===void 0)return;let m=this._listeners[s];if(m!==void 0){let _=m.indexOf(h);_!==-1&&m.splice(_,1)}}dispatchEvent(s){if(this._listeners===void 0)return;let p=this._listeners[s.type];if(p!==void 0){s.target=this;let m=p.slice(0);for(let _=0,S=m.length;_>8&255]+gp[d>>16&255]+gp[d>>24&255]+"-"+gp[s&255]+gp[s>>8&255]+"-"+gp[s>>16&15|64]+gp[s>>24&255]+"-"+gp[h&63|128]+gp[h>>8&255]+"-"+gp[h>>16&255]+gp[h>>24&255]+gp[p&255]+gp[p>>8&255]+gp[p>>16&255]+gp[p>>24&255]).toLowerCase()}function dg(d,s,h){return Math.max(s,Math.min(h,d))}function TEe(d,s){return(d%s+s)%s}function X_t(d,s,h){return(1-h)*d+h*s}function QZt(d){return(d&d-1)===0&&d!==0}function Ayt(d){return Math.pow(2,Math.floor(Math.log(d)/Math.LN2))}function aU(d,s){switch(s.constructor){case Float32Array:return d;case Uint32Array:return d/4294967295;case Uint16Array:return d/65535;case Uint8Array:return d/255;case Int32Array:return Math.max(d/2147483647,-1);case Int16Array:return Math.max(d/32767,-1);case Int8Array:return Math.max(d/127,-1);default:throw new Error("Invalid component type.")}}function fg(d,s){switch(s.constructor){case Float32Array:return d;case Uint32Array:return Math.round(d*4294967295);case Uint16Array:return Math.round(d*65535);case Uint8Array:return Math.round(d*255);case Int32Array:return Math.round(d*2147483647);case Int16Array:return Math.round(d*32767);case Int8Array:return Math.round(d*127);default:throw new Error("Invalid component type.")}}var Nc=class d{constructor(s=0,h=0){d.prototype.isVector2=!0,this.x=s,this.y=h}get width(){return this.x}set width(s){this.x=s}get height(){return this.y}set height(s){this.y=s}set(s,h){return this.x=s,this.y=h,this}setScalar(s){return this.x=s,this.y=s,this}setX(s){return this.x=s,this}setY(s){return this.y=s,this}setComponent(s,h){switch(s){case 0:this.x=h;break;case 1:this.y=h;break;default:throw new Error("index is out of range: "+s)}return this}getComponent(s){switch(s){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+s)}}clone(){return new this.constructor(this.x,this.y)}copy(s){return this.x=s.x,this.y=s.y,this}add(s){return this.x+=s.x,this.y+=s.y,this}addScalar(s){return this.x+=s,this.y+=s,this}addVectors(s,h){return this.x=s.x+h.x,this.y=s.y+h.y,this}addScaledVector(s,h){return this.x+=s.x*h,this.y+=s.y*h,this}sub(s){return this.x-=s.x,this.y-=s.y,this}subScalar(s){return this.x-=s,this.y-=s,this}subVectors(s,h){return this.x=s.x-h.x,this.y=s.y-h.y,this}multiply(s){return this.x*=s.x,this.y*=s.y,this}multiplyScalar(s){return this.x*=s,this.y*=s,this}divide(s){return this.x/=s.x,this.y/=s.y,this}divideScalar(s){return this.multiplyScalar(1/s)}applyMatrix3(s){let h=this.x,p=this.y,m=s.elements;return this.x=m[0]*h+m[3]*p+m[6],this.y=m[1]*h+m[4]*p+m[7],this}min(s){return this.x=Math.min(this.x,s.x),this.y=Math.min(this.y,s.y),this}max(s){return this.x=Math.max(this.x,s.x),this.y=Math.max(this.y,s.y),this}clamp(s,h){return this.x=Math.max(s.x,Math.min(h.x,this.x)),this.y=Math.max(s.y,Math.min(h.y,this.y)),this}clampScalar(s,h){return this.x=Math.max(s,Math.min(h,this.x)),this.y=Math.max(s,Math.min(h,this.y)),this}clampLength(s,h){let p=this.length();return this.divideScalar(p||1).multiplyScalar(Math.max(s,Math.min(h,p)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(s){return this.x*s.x+this.y*s.y}cross(s){return this.x*s.y-this.y*s.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(s){let h=Math.sqrt(this.lengthSq()*s.lengthSq());if(h===0)return Math.PI/2;let p=this.dot(s)/h;return Math.acos(dg(p,-1,1))}distanceTo(s){return Math.sqrt(this.distanceToSquared(s))}distanceToSquared(s){let h=this.x-s.x,p=this.y-s.y;return h*h+p*p}manhattanDistanceTo(s){return Math.abs(this.x-s.x)+Math.abs(this.y-s.y)}setLength(s){return this.normalize().multiplyScalar(s)}lerp(s,h){return this.x+=(s.x-this.x)*h,this.y+=(s.y-this.y)*h,this}lerpVectors(s,h,p){return this.x=s.x+(h.x-s.x)*p,this.y=s.y+(h.y-s.y)*p,this}equals(s){return s.x===this.x&&s.y===this.y}fromArray(s,h=0){return this.x=s[h],this.y=s[h+1],this}toArray(s=[],h=0){return s[h]=this.x,s[h+1]=this.y,s}fromBufferAttribute(s,h){return this.x=s.getX(h),this.y=s.getY(h),this}rotateAround(s,h){let p=Math.cos(h),m=Math.sin(h),_=this.x-s.x,S=this.y-s.y;return this.x=_*p-S*m+s.x,this.y=_*m+S*p+s.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Ko=class d{constructor(s,h,p,m,_,S,y,I,N){d.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],s!==void 0&&this.set(s,h,p,m,_,S,y,I,N)}set(s,h,p,m,_,S,y,I,N){let B=this.elements;return B[0]=s,B[1]=m,B[2]=y,B[3]=h,B[4]=_,B[5]=I,B[6]=p,B[7]=S,B[8]=N,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(s){let h=this.elements,p=s.elements;return h[0]=p[0],h[1]=p[1],h[2]=p[2],h[3]=p[3],h[4]=p[4],h[5]=p[5],h[6]=p[6],h[7]=p[7],h[8]=p[8],this}extractBasis(s,h,p){return s.setFromMatrix3Column(this,0),h.setFromMatrix3Column(this,1),p.setFromMatrix3Column(this,2),this}setFromMatrix4(s){let h=s.elements;return this.set(h[0],h[4],h[8],h[1],h[5],h[9],h[2],h[6],h[10]),this}multiply(s){return this.multiplyMatrices(this,s)}premultiply(s){return this.multiplyMatrices(s,this)}multiplyMatrices(s,h){let p=s.elements,m=h.elements,_=this.elements,S=p[0],y=p[3],I=p[6],N=p[1],B=p[4],P=p[7],U=p[2],j=p[5],V=p[8],et=m[0],Q=m[3],X=m[6],gt=m[1],ft=m[4],xt=m[7],Bt=m[2],Dt=m[5],Pt=m[8];return _[0]=S*et+y*gt+I*Bt,_[3]=S*Q+y*ft+I*Dt,_[6]=S*X+y*xt+I*Pt,_[1]=N*et+B*gt+P*Bt,_[4]=N*Q+B*ft+P*Dt,_[7]=N*X+B*xt+P*Pt,_[2]=U*et+j*gt+V*Bt,_[5]=U*Q+j*ft+V*Dt,_[8]=U*X+j*xt+V*Pt,this}multiplyScalar(s){let h=this.elements;return h[0]*=s,h[3]*=s,h[6]*=s,h[1]*=s,h[4]*=s,h[7]*=s,h[2]*=s,h[5]*=s,h[8]*=s,this}determinant(){let s=this.elements,h=s[0],p=s[1],m=s[2],_=s[3],S=s[4],y=s[5],I=s[6],N=s[7],B=s[8];return h*S*B-h*y*N-p*_*B+p*y*I+m*_*N-m*S*I}invert(){let s=this.elements,h=s[0],p=s[1],m=s[2],_=s[3],S=s[4],y=s[5],I=s[6],N=s[7],B=s[8],P=B*S-y*N,U=y*I-B*_,j=N*_-S*I,V=h*P+p*U+m*j;if(V===0)return this.set(0,0,0,0,0,0,0,0,0);let et=1/V;return s[0]=P*et,s[1]=(m*N-B*p)*et,s[2]=(y*p-m*S)*et,s[3]=U*et,s[4]=(B*h-m*I)*et,s[5]=(m*_-y*h)*et,s[6]=j*et,s[7]=(p*I-N*h)*et,s[8]=(S*h-p*_)*et,this}transpose(){let s,h=this.elements;return s=h[1],h[1]=h[3],h[3]=s,s=h[2],h[2]=h[6],h[6]=s,s=h[5],h[5]=h[7],h[7]=s,this}getNormalMatrix(s){return this.setFromMatrix4(s).invert().transpose()}transposeIntoArray(s){let h=this.elements;return s[0]=h[0],s[1]=h[3],s[2]=h[6],s[3]=h[1],s[4]=h[4],s[5]=h[7],s[6]=h[2],s[7]=h[5],s[8]=h[8],this}setUvTransform(s,h,p,m,_,S,y){let I=Math.cos(_),N=Math.sin(_);return this.set(p*I,p*N,-p*(I*S+N*y)+S+s,-m*N,m*I,-m*(-N*S+I*y)+y+h,0,0,1),this}scale(s,h){return this.premultiply(Z_t.makeScale(s,h)),this}rotate(s){return this.premultiply(Z_t.makeRotation(-s)),this}translate(s,h){return this.premultiply(Z_t.makeTranslation(s,h)),this}makeTranslation(s,h){return s.isVector2?this.set(1,0,s.x,0,1,s.y,0,0,1):this.set(1,0,s,0,1,h,0,0,1),this}makeRotation(s){let h=Math.cos(s),p=Math.sin(s);return this.set(h,-p,0,p,h,0,0,0,1),this}makeScale(s,h){return this.set(s,0,0,0,h,0,0,0,1),this}equals(s){let h=this.elements,p=s.elements;for(let m=0;m<9;m++)if(h[m]!==p[m])return!1;return!0}fromArray(s,h=0){for(let p=0;p<9;p++)this.elements[p]=s[p+h];return this}toArray(s=[],h=0){let p=this.elements;return s[h]=p[0],s[h+1]=p[1],s[h+2]=p[2],s[h+3]=p[3],s[h+4]=p[4],s[h+5]=p[5],s[h+6]=p[6],s[h+7]=p[7],s[h+8]=p[8],s}clone(){return new this.constructor().fromArray(this.elements)}},Z_t=new Ko;function sKt(d){for(let s=d.length-1;s>=0;--s)if(d[s]>=65535)return!0;return!1}function cet(d){return document.createElementNS("http://www.w3.org/1999/xhtml",d)}function CEe(){let d=cet("canvas");return d.style.display="block",d}var tYt={};function gU(d){d in tYt||(tYt[d]=!0,console.warn(d))}var eYt=new Ko().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),nYt=new Ko().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Stt={[Zx]:{transfer:iet,primaries:ret,toReference:d=>d,fromReference:d=>d},[Pd]:{transfer:vu,primaries:ret,toReference:d=>d.convertSRGBToLinear(),fromReference:d=>d.convertLinearToSRGB()},[Iet]:{transfer:iet,primaries:set,toReference:d=>d.applyMatrix3(nYt),fromReference:d=>d.applyMatrix3(eYt)},[a2t]:{transfer:vu,primaries:set,toReference:d=>d.convertSRGBToLinear().applyMatrix3(nYt),fromReference:d=>d.applyMatrix3(eYt).convertLinearToSRGB()}},AEe=new Set([Zx,Iet]),Na={enabled:!0,_workingColorSpace:Zx,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(d){if(!AEe.has(d))throw new Error(`Unsupported working color space, "${d}".`);this._workingColorSpace=d},convert:function(d,s,h){if(this.enabled===!1||s===h||!s||!h)return d;let p=Stt[s].toReference,m=Stt[h].fromReference;return m(p(d))},fromWorkingColorSpace:function(d,s){return this.convert(d,this._workingColorSpace,s)},toWorkingColorSpace:function(d,s){return this.convert(d,s,this._workingColorSpace)},getPrimaries:function(d){return Stt[d].primaries},getTransfer:function(d){return d===gb?iet:Stt[d].transfer}};function KI(d){return d<.04045?d*.0773993808:Math.pow(d*.9478672986+.0521327014,2.4)}function Y_t(d){return d<.0031308?d*12.92:1.055*Math.pow(d,.41666)-.055}var II,aet=class{static getDataURL(s){if(/^data:/i.test(s.src)||typeof HTMLCanvasElement>"u")return s.src;let h;if(s instanceof HTMLCanvasElement)h=s;else{II===void 0&&(II=cet("canvas")),II.width=s.width,II.height=s.height;let p=II.getContext("2d");s instanceof ImageData?p.putImageData(s,0,0):p.drawImage(s,0,0,s.width,s.height),h=II}return h.width>2048||h.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",s),h.toDataURL("image/jpeg",.6)):h.toDataURL("image/png")}static sRGBToLinear(s){if(typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap){let h=cet("canvas");h.width=s.width,h.height=s.height;let p=h.getContext("2d");p.drawImage(s,0,0,s.width,s.height);let m=p.getImageData(0,0,s.width,s.height),_=m.data;for(let S=0;S<_.length;S++)_[S]=KI(_[S]/255)*255;return p.putImageData(m,0,0),h}else if(s.data){let h=s.data.slice(0);for(let p=0;p0&&(p.userData=this.userData),h||(s.textures[this.uuid]=p),p}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(s){if(this.mapping!==XYt)return s;if(s.applyMatrix3(this.matrix),s.x<0||s.x>1)switch(this.wrapS){case Eyt:s.x=s.x-Math.floor(s.x);break;case Vw:s.x=s.x<0?0:1;break;case Syt:Math.abs(Math.floor(s.x)%2)===1?s.x=Math.ceil(s.x)-s.x:s.x=s.x-Math.floor(s.x);break}if(s.y<0||s.y>1)switch(this.wrapT){case Eyt:s.y=s.y-Math.floor(s.y);break;case Vw:s.y=s.y<0?0:1;break;case Syt:Math.abs(Math.floor(s.y)%2)===1?s.y=Math.ceil(s.y)-s.y:s.y=s.y-Math.floor(s.y);break}return this.flipY&&(s.y=1-s.y),s}set needsUpdate(s){s===!0&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return gU("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Pd?$A:nKt}set encoding(s){gU("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=s===$A?Pd:gb}};Xw.DEFAULT_IMAGE=null;Xw.DEFAULT_MAPPING=XYt;Xw.DEFAULT_ANISOTROPY=1;var $f=class d{constructor(s=0,h=0,p=0,m=1){d.prototype.isVector4=!0,this.x=s,this.y=h,this.z=p,this.w=m}get width(){return this.z}set width(s){this.z=s}get height(){return this.w}set height(s){this.w=s}set(s,h,p,m){return this.x=s,this.y=h,this.z=p,this.w=m,this}setScalar(s){return this.x=s,this.y=s,this.z=s,this.w=s,this}setX(s){return this.x=s,this}setY(s){return this.y=s,this}setZ(s){return this.z=s,this}setW(s){return this.w=s,this}setComponent(s,h){switch(s){case 0:this.x=h;break;case 1:this.y=h;break;case 2:this.z=h;break;case 3:this.w=h;break;default:throw new Error("index is out of range: "+s)}return this}getComponent(s){switch(s){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+s)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(s){return this.x=s.x,this.y=s.y,this.z=s.z,this.w=s.w!==void 0?s.w:1,this}add(s){return this.x+=s.x,this.y+=s.y,this.z+=s.z,this.w+=s.w,this}addScalar(s){return this.x+=s,this.y+=s,this.z+=s,this.w+=s,this}addVectors(s,h){return this.x=s.x+h.x,this.y=s.y+h.y,this.z=s.z+h.z,this.w=s.w+h.w,this}addScaledVector(s,h){return this.x+=s.x*h,this.y+=s.y*h,this.z+=s.z*h,this.w+=s.w*h,this}sub(s){return this.x-=s.x,this.y-=s.y,this.z-=s.z,this.w-=s.w,this}subScalar(s){return this.x-=s,this.y-=s,this.z-=s,this.w-=s,this}subVectors(s,h){return this.x=s.x-h.x,this.y=s.y-h.y,this.z=s.z-h.z,this.w=s.w-h.w,this}multiply(s){return this.x*=s.x,this.y*=s.y,this.z*=s.z,this.w*=s.w,this}multiplyScalar(s){return this.x*=s,this.y*=s,this.z*=s,this.w*=s,this}applyMatrix4(s){let h=this.x,p=this.y,m=this.z,_=this.w,S=s.elements;return this.x=S[0]*h+S[4]*p+S[8]*m+S[12]*_,this.y=S[1]*h+S[5]*p+S[9]*m+S[13]*_,this.z=S[2]*h+S[6]*p+S[10]*m+S[14]*_,this.w=S[3]*h+S[7]*p+S[11]*m+S[15]*_,this}divideScalar(s){return this.multiplyScalar(1/s)}setAxisAngleFromQuaternion(s){this.w=2*Math.acos(s.w);let h=Math.sqrt(1-s.w*s.w);return h<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=s.x/h,this.y=s.y/h,this.z=s.z/h),this}setAxisAngleFromRotationMatrix(s){let h,p,m,_,I=s.elements,N=I[0],B=I[4],P=I[8],U=I[1],j=I[5],V=I[9],et=I[2],Q=I[6],X=I[10];if(Math.abs(B-U)<.01&&Math.abs(P-et)<.01&&Math.abs(V-Q)<.01){if(Math.abs(B+U)<.1&&Math.abs(P+et)<.1&&Math.abs(V+Q)<.1&&Math.abs(N+j+X-3)<.1)return this.set(1,0,0,0),this;h=Math.PI;let ft=(N+1)/2,xt=(j+1)/2,Bt=(X+1)/2,Dt=(B+U)/4,Pt=(P+et)/4,se=(V+Q)/4;return ft>xt&&ft>Bt?ft<.01?(p=0,m=.707106781,_=.707106781):(p=Math.sqrt(ft),m=Dt/p,_=Pt/p):xt>Bt?xt<.01?(p=.707106781,m=0,_=.707106781):(m=Math.sqrt(xt),p=Dt/m,_=se/m):Bt<.01?(p=.707106781,m=.707106781,_=0):(_=Math.sqrt(Bt),p=Pt/_,m=se/_),this.set(p,m,_,h),this}let gt=Math.sqrt((Q-V)*(Q-V)+(P-et)*(P-et)+(U-B)*(U-B));return Math.abs(gt)<.001&&(gt=1),this.x=(Q-V)/gt,this.y=(P-et)/gt,this.z=(U-B)/gt,this.w=Math.acos((N+j+X-1)/2),this}min(s){return this.x=Math.min(this.x,s.x),this.y=Math.min(this.y,s.y),this.z=Math.min(this.z,s.z),this.w=Math.min(this.w,s.w),this}max(s){return this.x=Math.max(this.x,s.x),this.y=Math.max(this.y,s.y),this.z=Math.max(this.z,s.z),this.w=Math.max(this.w,s.w),this}clamp(s,h){return this.x=Math.max(s.x,Math.min(h.x,this.x)),this.y=Math.max(s.y,Math.min(h.y,this.y)),this.z=Math.max(s.z,Math.min(h.z,this.z)),this.w=Math.max(s.w,Math.min(h.w,this.w)),this}clampScalar(s,h){return this.x=Math.max(s,Math.min(h,this.x)),this.y=Math.max(s,Math.min(h,this.y)),this.z=Math.max(s,Math.min(h,this.z)),this.w=Math.max(s,Math.min(h,this.w)),this}clampLength(s,h){let p=this.length();return this.divideScalar(p||1).multiplyScalar(Math.max(s,Math.min(h,p)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(s){return this.x*s.x+this.y*s.y+this.z*s.z+this.w*s.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(s){return this.normalize().multiplyScalar(s)}lerp(s,h){return this.x+=(s.x-this.x)*h,this.y+=(s.y-this.y)*h,this.z+=(s.z-this.z)*h,this.w+=(s.w-this.w)*h,this}lerpVectors(s,h,p){return this.x=s.x+(h.x-s.x)*p,this.y=s.y+(h.y-s.y)*p,this.z=s.z+(h.z-s.z)*p,this.w=s.w+(h.w-s.w)*p,this}equals(s){return s.x===this.x&&s.y===this.y&&s.z===this.z&&s.w===this.w}fromArray(s,h=0){return this.x=s[h],this.y=s[h+1],this.z=s[h+2],this.w=s[h+3],this}toArray(s=[],h=0){return s[h]=this.x,s[h+1]=this.y,s[h+2]=this.z,s[h+3]=this.w,s}fromBufferAttribute(s,h){return this.x=s.getX(h),this.y=s.getY(h),this.z=s.getZ(h),this.w=s.getW(h),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},kyt=class extends aS{constructor(s=1,h=1,p={}){super(),this.isRenderTarget=!0,this.width=s,this.height=h,this.depth=1,this.scissor=new $f(0,0,s,h),this.scissorTest=!1,this.viewport=new $f(0,0,s,h);let m={width:s,height:h,depth:1};p.encoding!==void 0&&(gU("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),p.colorSpace=p.encoding===$A?Pd:gb),p=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:pb,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},p),this.texture=new Xw(m,p.mapping,p.wrapS,p.wrapT,p.magFilter,p.minFilter,p.format,p.type,p.anisotropy,p.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=p.generateMipmaps,this.texture.internalFormat=p.internalFormat,this.depthBuffer=p.depthBuffer,this.stencilBuffer=p.stencilBuffer,this.depthTexture=p.depthTexture,this.samples=p.samples}setSize(s,h,p=1){(this.width!==s||this.height!==h||this.depth!==p)&&(this.width=s,this.height=h,this.depth=p,this.texture.image.width=s,this.texture.image.height=h,this.texture.image.depth=p,this.dispose()),this.viewport.set(0,0,s,h),this.scissor.set(0,0,s,h)}clone(){return new this.constructor().copy(this)}copy(s){this.width=s.width,this.height=s.height,this.depth=s.depth,this.scissor.copy(s.scissor),this.scissorTest=s.scissorTest,this.viewport.copy(s.viewport),this.texture=s.texture.clone(),this.texture.isRenderTargetTexture=!0;let h=Object.assign({},s.texture.image);return this.texture.source=new uet(h),this.depthBuffer=s.depthBuffer,this.stencilBuffer=s.stencilBuffer,s.depthTexture!==null&&(this.depthTexture=s.depthTexture.clone()),this.samples=s.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},Yx=class extends kyt{constructor(s=1,h=1,p={}){super(s,h,p),this.isWebGLRenderTarget=!0}},het=class extends Xw{constructor(s=null,h=1,p=1,m=1){super(null),this.isDataArrayTexture=!0,this.image={data:s,width:h,height:p,depth:m},this.magFilter=r1,this.minFilter=r1,this.wrapR=Vw,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Lyt=class extends Xw{constructor(s=null,h=1,p=1,m=1){super(null),this.isData3DTexture=!0,this.image={data:s,width:h,height:p,depth:m},this.magFilter=r1,this.minFilter=r1,this.wrapR=Vw,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var vy=class{constructor(s=0,h=0,p=0,m=1){this.isQuaternion=!0,this._x=s,this._y=h,this._z=p,this._w=m}static slerpFlat(s,h,p,m,_,S,y){let I=p[m+0],N=p[m+1],B=p[m+2],P=p[m+3],U=_[S+0],j=_[S+1],V=_[S+2],et=_[S+3];if(y===0){s[h+0]=I,s[h+1]=N,s[h+2]=B,s[h+3]=P;return}if(y===1){s[h+0]=U,s[h+1]=j,s[h+2]=V,s[h+3]=et;return}if(P!==et||I!==U||N!==j||B!==V){let Q=1-y,X=I*U+N*j+B*V+P*et,gt=X>=0?1:-1,ft=1-X*X;if(ft>Number.EPSILON){let Bt=Math.sqrt(ft),Dt=Math.atan2(Bt,X*gt);Q=Math.sin(Q*Dt)/Bt,y=Math.sin(y*Dt)/Bt}let xt=y*gt;if(I=I*Q+U*xt,N=N*Q+j*xt,B=B*Q+V*xt,P=P*Q+et*xt,Q===1-y){let Bt=1/Math.sqrt(I*I+N*N+B*B+P*P);I*=Bt,N*=Bt,B*=Bt,P*=Bt}}s[h]=I,s[h+1]=N,s[h+2]=B,s[h+3]=P}static multiplyQuaternionsFlat(s,h,p,m,_,S){let y=p[m],I=p[m+1],N=p[m+2],B=p[m+3],P=_[S],U=_[S+1],j=_[S+2],V=_[S+3];return s[h]=y*V+B*P+I*j-N*U,s[h+1]=I*V+B*U+N*P-y*j,s[h+2]=N*V+B*j+y*U-I*P,s[h+3]=B*V-y*P-I*U-N*j,s}get x(){return this._x}set x(s){this._x=s,this._onChangeCallback()}get y(){return this._y}set y(s){this._y=s,this._onChangeCallback()}get z(){return this._z}set z(s){this._z=s,this._onChangeCallback()}get w(){return this._w}set w(s){this._w=s,this._onChangeCallback()}set(s,h,p,m){return this._x=s,this._y=h,this._z=p,this._w=m,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(s){return this._x=s.x,this._y=s.y,this._z=s.z,this._w=s.w,this._onChangeCallback(),this}setFromEuler(s,h=!0){let p=s._x,m=s._y,_=s._z,S=s._order,y=Math.cos,I=Math.sin,N=y(p/2),B=y(m/2),P=y(_/2),U=I(p/2),j=I(m/2),V=I(_/2);switch(S){case"XYZ":this._x=U*B*P+N*j*V,this._y=N*j*P-U*B*V,this._z=N*B*V+U*j*P,this._w=N*B*P-U*j*V;break;case"YXZ":this._x=U*B*P+N*j*V,this._y=N*j*P-U*B*V,this._z=N*B*V-U*j*P,this._w=N*B*P+U*j*V;break;case"ZXY":this._x=U*B*P-N*j*V,this._y=N*j*P+U*B*V,this._z=N*B*V+U*j*P,this._w=N*B*P-U*j*V;break;case"ZYX":this._x=U*B*P-N*j*V,this._y=N*j*P+U*B*V,this._z=N*B*V-U*j*P,this._w=N*B*P+U*j*V;break;case"YZX":this._x=U*B*P+N*j*V,this._y=N*j*P+U*B*V,this._z=N*B*V-U*j*P,this._w=N*B*P-U*j*V;break;case"XZY":this._x=U*B*P-N*j*V,this._y=N*j*P-U*B*V,this._z=N*B*V+U*j*P,this._w=N*B*P+U*j*V;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+S)}return h===!0&&this._onChangeCallback(),this}setFromAxisAngle(s,h){let p=h/2,m=Math.sin(p);return this._x=s.x*m,this._y=s.y*m,this._z=s.z*m,this._w=Math.cos(p),this._onChangeCallback(),this}setFromRotationMatrix(s){let h=s.elements,p=h[0],m=h[4],_=h[8],S=h[1],y=h[5],I=h[9],N=h[2],B=h[6],P=h[10],U=p+y+P;if(U>0){let j=.5/Math.sqrt(U+1);this._w=.25/j,this._x=(B-I)*j,this._y=(_-N)*j,this._z=(S-m)*j}else if(p>y&&p>P){let j=2*Math.sqrt(1+p-y-P);this._w=(B-I)/j,this._x=.25*j,this._y=(m+S)/j,this._z=(_+N)/j}else if(y>P){let j=2*Math.sqrt(1+y-p-P);this._w=(_-N)/j,this._x=(m+S)/j,this._y=.25*j,this._z=(I+B)/j}else{let j=2*Math.sqrt(1+P-p-y);this._w=(S-m)/j,this._x=(_+N)/j,this._y=(I+B)/j,this._z=.25*j}return this._onChangeCallback(),this}setFromUnitVectors(s,h){let p=s.dot(h)+1;return pMath.abs(s.z)?(this._x=-s.y,this._y=s.x,this._z=0,this._w=p):(this._x=0,this._y=-s.z,this._z=s.y,this._w=p)):(this._x=s.y*h.z-s.z*h.y,this._y=s.z*h.x-s.x*h.z,this._z=s.x*h.y-s.y*h.x,this._w=p),this.normalize()}angleTo(s){return 2*Math.acos(Math.abs(dg(this.dot(s),-1,1)))}rotateTowards(s,h){let p=this.angleTo(s);if(p===0)return this;let m=Math.min(1,h/p);return this.slerp(s,m),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(s){return this._x*s._x+this._y*s._y+this._z*s._z+this._w*s._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let s=this.length();return s===0?(this._x=0,this._y=0,this._z=0,this._w=1):(s=1/s,this._x=this._x*s,this._y=this._y*s,this._z=this._z*s,this._w=this._w*s),this._onChangeCallback(),this}multiply(s){return this.multiplyQuaternions(this,s)}premultiply(s){return this.multiplyQuaternions(s,this)}multiplyQuaternions(s,h){let p=s._x,m=s._y,_=s._z,S=s._w,y=h._x,I=h._y,N=h._z,B=h._w;return this._x=p*B+S*y+m*N-_*I,this._y=m*B+S*I+_*y-p*N,this._z=_*B+S*N+p*I-m*y,this._w=S*B-p*y-m*I-_*N,this._onChangeCallback(),this}slerp(s,h){if(h===0)return this;if(h===1)return this.copy(s);let p=this._x,m=this._y,_=this._z,S=this._w,y=S*s._w+p*s._x+m*s._y+_*s._z;if(y<0?(this._w=-s._w,this._x=-s._x,this._y=-s._y,this._z=-s._z,y=-y):this.copy(s),y>=1)return this._w=S,this._x=p,this._y=m,this._z=_,this;let I=1-y*y;if(I<=Number.EPSILON){let j=1-h;return this._w=j*S+h*this._w,this._x=j*p+h*this._x,this._y=j*m+h*this._y,this._z=j*_+h*this._z,this.normalize(),this}let N=Math.sqrt(I),B=Math.atan2(N,y),P=Math.sin((1-h)*B)/N,U=Math.sin(h*B)/N;return this._w=S*P+this._w*U,this._x=p*P+this._x*U,this._y=m*P+this._y*U,this._z=_*P+this._z*U,this._onChangeCallback(),this}slerpQuaternions(s,h,p){return this.copy(s).slerp(h,p)}random(){let s=Math.random(),h=Math.sqrt(1-s),p=Math.sqrt(s),m=2*Math.PI*Math.random(),_=2*Math.PI*Math.random();return this.set(h*Math.cos(m),p*Math.sin(_),p*Math.cos(_),h*Math.sin(m))}equals(s){return s._x===this._x&&s._y===this._y&&s._z===this._z&&s._w===this._w}fromArray(s,h=0){return this._x=s[h],this._y=s[h+1],this._z=s[h+2],this._w=s[h+3],this._onChangeCallback(),this}toArray(s=[],h=0){return s[h]=this._x,s[h+1]=this._y,s[h+2]=this._z,s[h+3]=this._w,s}fromBufferAttribute(s,h){return this._x=s.getX(h),this._y=s.getY(h),this._z=s.getZ(h),this._w=s.getW(h),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(s){return this._onChangeCallback=s,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},Ge=class d{constructor(s=0,h=0,p=0){d.prototype.isVector3=!0,this.x=s,this.y=h,this.z=p}set(s,h,p){return p===void 0&&(p=this.z),this.x=s,this.y=h,this.z=p,this}setScalar(s){return this.x=s,this.y=s,this.z=s,this}setX(s){return this.x=s,this}setY(s){return this.y=s,this}setZ(s){return this.z=s,this}setComponent(s,h){switch(s){case 0:this.x=h;break;case 1:this.y=h;break;case 2:this.z=h;break;default:throw new Error("index is out of range: "+s)}return this}getComponent(s){switch(s){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+s)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(s){return this.x=s.x,this.y=s.y,this.z=s.z,this}add(s){return this.x+=s.x,this.y+=s.y,this.z+=s.z,this}addScalar(s){return this.x+=s,this.y+=s,this.z+=s,this}addVectors(s,h){return this.x=s.x+h.x,this.y=s.y+h.y,this.z=s.z+h.z,this}addScaledVector(s,h){return this.x+=s.x*h,this.y+=s.y*h,this.z+=s.z*h,this}sub(s){return this.x-=s.x,this.y-=s.y,this.z-=s.z,this}subScalar(s){return this.x-=s,this.y-=s,this.z-=s,this}subVectors(s,h){return this.x=s.x-h.x,this.y=s.y-h.y,this.z=s.z-h.z,this}multiply(s){return this.x*=s.x,this.y*=s.y,this.z*=s.z,this}multiplyScalar(s){return this.x*=s,this.y*=s,this.z*=s,this}multiplyVectors(s,h){return this.x=s.x*h.x,this.y=s.y*h.y,this.z=s.z*h.z,this}applyEuler(s){return this.applyQuaternion(iYt.setFromEuler(s))}applyAxisAngle(s,h){return this.applyQuaternion(iYt.setFromAxisAngle(s,h))}applyMatrix3(s){let h=this.x,p=this.y,m=this.z,_=s.elements;return this.x=_[0]*h+_[3]*p+_[6]*m,this.y=_[1]*h+_[4]*p+_[7]*m,this.z=_[2]*h+_[5]*p+_[8]*m,this}applyNormalMatrix(s){return this.applyMatrix3(s).normalize()}applyMatrix4(s){let h=this.x,p=this.y,m=this.z,_=s.elements,S=1/(_[3]*h+_[7]*p+_[11]*m+_[15]);return this.x=(_[0]*h+_[4]*p+_[8]*m+_[12])*S,this.y=(_[1]*h+_[5]*p+_[9]*m+_[13])*S,this.z=(_[2]*h+_[6]*p+_[10]*m+_[14])*S,this}applyQuaternion(s){let h=this.x,p=this.y,m=this.z,_=s.x,S=s.y,y=s.z,I=s.w,N=2*(S*m-y*p),B=2*(y*h-_*m),P=2*(_*p-S*h);return this.x=h+I*N+S*P-y*B,this.y=p+I*B+y*N-_*P,this.z=m+I*P+_*B-S*N,this}project(s){return this.applyMatrix4(s.matrixWorldInverse).applyMatrix4(s.projectionMatrix)}unproject(s){return this.applyMatrix4(s.projectionMatrixInverse).applyMatrix4(s.matrixWorld)}transformDirection(s){let h=this.x,p=this.y,m=this.z,_=s.elements;return this.x=_[0]*h+_[4]*p+_[8]*m,this.y=_[1]*h+_[5]*p+_[9]*m,this.z=_[2]*h+_[6]*p+_[10]*m,this.normalize()}divide(s){return this.x/=s.x,this.y/=s.y,this.z/=s.z,this}divideScalar(s){return this.multiplyScalar(1/s)}min(s){return this.x=Math.min(this.x,s.x),this.y=Math.min(this.y,s.y),this.z=Math.min(this.z,s.z),this}max(s){return this.x=Math.max(this.x,s.x),this.y=Math.max(this.y,s.y),this.z=Math.max(this.z,s.z),this}clamp(s,h){return this.x=Math.max(s.x,Math.min(h.x,this.x)),this.y=Math.max(s.y,Math.min(h.y,this.y)),this.z=Math.max(s.z,Math.min(h.z,this.z)),this}clampScalar(s,h){return this.x=Math.max(s,Math.min(h,this.x)),this.y=Math.max(s,Math.min(h,this.y)),this.z=Math.max(s,Math.min(h,this.z)),this}clampLength(s,h){let p=this.length();return this.divideScalar(p||1).multiplyScalar(Math.max(s,Math.min(h,p)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(s){return this.x*s.x+this.y*s.y+this.z*s.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(s){return this.normalize().multiplyScalar(s)}lerp(s,h){return this.x+=(s.x-this.x)*h,this.y+=(s.y-this.y)*h,this.z+=(s.z-this.z)*h,this}lerpVectors(s,h,p){return this.x=s.x+(h.x-s.x)*p,this.y=s.y+(h.y-s.y)*p,this.z=s.z+(h.z-s.z)*p,this}cross(s){return this.crossVectors(this,s)}crossVectors(s,h){let p=s.x,m=s.y,_=s.z,S=h.x,y=h.y,I=h.z;return this.x=m*I-_*y,this.y=_*S-p*I,this.z=p*y-m*S,this}projectOnVector(s){let h=s.lengthSq();if(h===0)return this.set(0,0,0);let p=s.dot(this)/h;return this.copy(s).multiplyScalar(p)}projectOnPlane(s){return J_t.copy(this).projectOnVector(s),this.sub(J_t)}reflect(s){return this.sub(J_t.copy(s).multiplyScalar(2*this.dot(s)))}angleTo(s){let h=Math.sqrt(this.lengthSq()*s.lengthSq());if(h===0)return Math.PI/2;let p=this.dot(s)/h;return Math.acos(dg(p,-1,1))}distanceTo(s){return Math.sqrt(this.distanceToSquared(s))}distanceToSquared(s){let h=this.x-s.x,p=this.y-s.y,m=this.z-s.z;return h*h+p*p+m*m}manhattanDistanceTo(s){return Math.abs(this.x-s.x)+Math.abs(this.y-s.y)+Math.abs(this.z-s.z)}setFromSpherical(s){return this.setFromSphericalCoords(s.radius,s.phi,s.theta)}setFromSphericalCoords(s,h,p){let m=Math.sin(h)*s;return this.x=m*Math.sin(p),this.y=Math.cos(h)*s,this.z=m*Math.cos(p),this}setFromCylindrical(s){return this.setFromCylindricalCoords(s.radius,s.theta,s.y)}setFromCylindricalCoords(s,h,p){return this.x=s*Math.sin(h),this.y=p,this.z=s*Math.cos(h),this}setFromMatrixPosition(s){let h=s.elements;return this.x=h[12],this.y=h[13],this.z=h[14],this}setFromMatrixScale(s){let h=this.setFromMatrixColumn(s,0).length(),p=this.setFromMatrixColumn(s,1).length(),m=this.setFromMatrixColumn(s,2).length();return this.x=h,this.y=p,this.z=m,this}setFromMatrixColumn(s,h){return this.fromArray(s.elements,h*4)}setFromMatrix3Column(s,h){return this.fromArray(s.elements,h*3)}setFromEuler(s){return this.x=s._x,this.y=s._y,this.z=s._z,this}setFromColor(s){return this.x=s.r,this.y=s.g,this.z=s.b,this}equals(s){return s.x===this.x&&s.y===this.y&&s.z===this.z}fromArray(s,h=0){return this.x=s[h],this.y=s[h+1],this.z=s[h+2],this}toArray(s=[],h=0){return s[h]=this.x,s[h+1]=this.y,s[h+2]=this.z,s}fromBufferAttribute(s,h){return this.x=s.getX(h),this.y=s.getY(h),this.z=s.getZ(h),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let s=(Math.random()-.5)*2,h=Math.random()*Math.PI*2,p=Math.sqrt(1-s**2);return this.x=p*Math.cos(h),this.y=p*Math.sin(h),this.z=s,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},J_t=new Ge,iYt=new vy,Kx=class{constructor(s=new Ge(1/0,1/0,1/0),h=new Ge(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=s,this.max=h}set(s,h){return this.min.copy(s),this.max.copy(h),this}setFromArray(s){this.makeEmpty();for(let h=0,p=s.length;hthis.max.x||s.ythis.max.y||s.zthis.max.z)}containsBox(s){return this.min.x<=s.min.x&&s.max.x<=this.max.x&&this.min.y<=s.min.y&&s.max.y<=this.max.y&&this.min.z<=s.min.z&&s.max.z<=this.max.z}getParameter(s,h){return h.set((s.x-this.min.x)/(this.max.x-this.min.x),(s.y-this.min.y)/(this.max.y-this.min.y),(s.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(s){return!(s.max.xthis.max.x||s.max.ythis.max.y||s.max.zthis.max.z)}intersectsSphere(s){return this.clampPoint(s.center,Hw),Hw.distanceToSquared(s.center)<=s.radius*s.radius}intersectsPlane(s){let h,p;return s.normal.x>0?(h=s.normal.x*this.min.x,p=s.normal.x*this.max.x):(h=s.normal.x*this.max.x,p=s.normal.x*this.min.x),s.normal.y>0?(h+=s.normal.y*this.min.y,p+=s.normal.y*this.max.y):(h+=s.normal.y*this.max.y,p+=s.normal.y*this.min.y),s.normal.z>0?(h+=s.normal.z*this.min.z,p+=s.normal.z*this.max.z):(h+=s.normal.z*this.max.z,p+=s.normal.z*this.min.z),h<=-s.constant&&p>=-s.constant}intersectsTriangle(s){if(this.isEmpty())return!1;this.getCenter(uU),Ctt.subVectors(this.max,uU),RI.subVectors(s.a,uU),DI.subVectors(s.b,uU),NI.subVectors(s.c,uU),YE.subVectors(DI,RI),KE.subVectors(NI,DI),NA.subVectors(RI,NI);let h=[0,-YE.z,YE.y,0,-KE.z,KE.y,0,-NA.z,NA.y,YE.z,0,-YE.x,KE.z,0,-KE.x,NA.z,0,-NA.x,-YE.y,YE.x,0,-KE.y,KE.x,0,-NA.y,NA.x,0];return!Q_t(h,RI,DI,NI,Ctt)||(h=[1,0,0,0,1,0,0,0,1],!Q_t(h,RI,DI,NI,Ctt))?!1:(Att.crossVectors(YE,KE),h=[Att.x,Att.y,Att.z],Q_t(h,RI,DI,NI,Ctt))}clampPoint(s,h){return h.copy(s).clamp(this.min,this.max)}distanceToPoint(s){return this.clampPoint(s,Hw).distanceTo(s)}getBoundingSphere(s){return this.isEmpty()?s.makeEmpty():(this.getCenter(s.center),s.radius=this.getSize(Hw).length()*.5),s}intersect(s){return this.min.max(s.min),this.max.min(s.max),this.isEmpty()&&this.makeEmpty(),this}union(s){return this.min.min(s.min),this.max.max(s.max),this}applyMatrix4(s){return this.isEmpty()?this:(jx[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(s),jx[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(s),jx[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(s),jx[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(s),jx[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(s),jx[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(s),jx[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(s),jx[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(s),this.setFromPoints(jx),this)}translate(s){return this.min.add(s),this.max.add(s),this}equals(s){return s.min.equals(this.min)&&s.max.equals(this.max)}},jx=[new Ge,new Ge,new Ge,new Ge,new Ge,new Ge,new Ge,new Ge],Hw=new Ge,Ttt=new Kx,RI=new Ge,DI=new Ge,NI=new Ge,YE=new Ge,KE=new Ge,NA=new Ge,uU=new Ge,Ctt=new Ge,Att=new Ge,OA=new Ge;function Q_t(d,s,h,p,m){for(let _=0,S=d.length-3;_<=S;_+=3){OA.fromArray(d,_);let y=m.x*Math.abs(OA.x)+m.y*Math.abs(OA.y)+m.z*Math.abs(OA.z),I=s.dot(OA),N=h.dot(OA),B=p.dot(OA);if(Math.max(-Math.max(I,N,B),Math.min(I,N,B))>y)return!1}return!0}var PEe=new Kx,lU=new Ge,tyt=new Ge,uS=class{constructor(s=new Ge,h=-1){this.isSphere=!0,this.center=s,this.radius=h}set(s,h){return this.center.copy(s),this.radius=h,this}setFromPoints(s,h){let p=this.center;h!==void 0?p.copy(h):PEe.setFromPoints(s).getCenter(p);let m=0;for(let _=0,S=s.length;_this.radius*this.radius&&(h.sub(this.center).normalize(),h.multiplyScalar(this.radius).add(this.center)),h}getBoundingBox(s){return this.isEmpty()?(s.makeEmpty(),s):(s.set(this.center,this.center),s.expandByScalar(this.radius),s)}applyMatrix4(s){return this.center.applyMatrix4(s),this.radius=this.radius*s.getMaxScaleOnAxis(),this}translate(s){return this.center.add(s),this}expandByPoint(s){if(this.isEmpty())return this.center.copy(s),this.radius=0,this;lU.subVectors(s,this.center);let h=lU.lengthSq();if(h>this.radius*this.radius){let p=Math.sqrt(h),m=(p-this.radius)*.5;this.center.addScaledVector(lU,m/p),this.radius+=m}return this}union(s){return s.isEmpty()?this:this.isEmpty()?(this.copy(s),this):(this.center.equals(s.center)===!0?this.radius=Math.max(this.radius,s.radius):(tyt.subVectors(s.center,this.center).setLength(s.radius),this.expandByPoint(lU.copy(s.center).add(tyt)),this.expandByPoint(lU.copy(s.center).sub(tyt))),this)}equals(s){return s.center.equals(this.center)&&s.radius===this.radius}clone(){return new this.constructor().copy(this)}},Hx=new Ge,eyt=new Ge,ktt=new Ge,JE=new Ge,nyt=new Ge,Ltt=new Ge,iyt=new Ge,vU=class{constructor(s=new Ge,h=new Ge(0,0,-1)){this.origin=s,this.direction=h}set(s,h){return this.origin.copy(s),this.direction.copy(h),this}copy(s){return this.origin.copy(s.origin),this.direction.copy(s.direction),this}at(s,h){return h.copy(this.origin).addScaledVector(this.direction,s)}lookAt(s){return this.direction.copy(s).sub(this.origin).normalize(),this}recast(s){return this.origin.copy(this.at(s,Hx)),this}closestPointToPoint(s,h){h.subVectors(s,this.origin);let p=h.dot(this.direction);return p<0?h.copy(this.origin):h.copy(this.origin).addScaledVector(this.direction,p)}distanceToPoint(s){return Math.sqrt(this.distanceSqToPoint(s))}distanceSqToPoint(s){let h=Hx.subVectors(s,this.origin).dot(this.direction);return h<0?this.origin.distanceToSquared(s):(Hx.copy(this.origin).addScaledVector(this.direction,h),Hx.distanceToSquared(s))}distanceSqToSegment(s,h,p,m){eyt.copy(s).add(h).multiplyScalar(.5),ktt.copy(h).sub(s).normalize(),JE.copy(this.origin).sub(eyt);let _=s.distanceTo(h)*.5,S=-this.direction.dot(ktt),y=JE.dot(this.direction),I=-JE.dot(ktt),N=JE.lengthSq(),B=Math.abs(1-S*S),P,U,j,V;if(B>0)if(P=S*I-y,U=S*y-I,V=_*B,P>=0)if(U>=-V)if(U<=V){let et=1/B;P*=et,U*=et,j=P*(P+S*U+2*y)+U*(S*P+U+2*I)+N}else U=_,P=Math.max(0,-(S*U+y)),j=-P*P+U*(U+2*I)+N;else U=-_,P=Math.max(0,-(S*U+y)),j=-P*P+U*(U+2*I)+N;else U<=-V?(P=Math.max(0,-(-S*_+y)),U=P>0?-_:Math.min(Math.max(-_,-I),_),j=-P*P+U*(U+2*I)+N):U<=V?(P=0,U=Math.min(Math.max(-_,-I),_),j=U*(U+2*I)+N):(P=Math.max(0,-(S*_+y)),U=P>0?_:Math.min(Math.max(-_,-I),_),j=-P*P+U*(U+2*I)+N);else U=S>0?-_:_,P=Math.max(0,-(S*U+y)),j=-P*P+U*(U+2*I)+N;return p&&p.copy(this.origin).addScaledVector(this.direction,P),m&&m.copy(eyt).addScaledVector(ktt,U),j}intersectSphere(s,h){Hx.subVectors(s.center,this.origin);let p=Hx.dot(this.direction),m=Hx.dot(Hx)-p*p,_=s.radius*s.radius;if(m>_)return null;let S=Math.sqrt(_-m),y=p-S,I=p+S;return I<0?null:y<0?this.at(I,h):this.at(y,h)}intersectsSphere(s){return this.distanceSqToPoint(s.center)<=s.radius*s.radius}distanceToPlane(s){let h=s.normal.dot(this.direction);if(h===0)return s.distanceToPoint(this.origin)===0?0:null;let p=-(this.origin.dot(s.normal)+s.constant)/h;return p>=0?p:null}intersectPlane(s,h){let p=this.distanceToPlane(s);return p===null?null:this.at(p,h)}intersectsPlane(s){let h=s.distanceToPoint(this.origin);return h===0||s.normal.dot(this.direction)*h<0}intersectBox(s,h){let p,m,_,S,y,I,N=1/this.direction.x,B=1/this.direction.y,P=1/this.direction.z,U=this.origin;return N>=0?(p=(s.min.x-U.x)*N,m=(s.max.x-U.x)*N):(p=(s.max.x-U.x)*N,m=(s.min.x-U.x)*N),B>=0?(_=(s.min.y-U.y)*B,S=(s.max.y-U.y)*B):(_=(s.max.y-U.y)*B,S=(s.min.y-U.y)*B),p>S||_>m||((_>p||isNaN(p))&&(p=_),(S=0?(y=(s.min.z-U.z)*P,I=(s.max.z-U.z)*P):(y=(s.max.z-U.z)*P,I=(s.min.z-U.z)*P),p>I||y>m)||((y>p||p!==p)&&(p=y),(I=0?p:m,h)}intersectsBox(s){return this.intersectBox(s,Hx)!==null}intersectTriangle(s,h,p,m,_){nyt.subVectors(h,s),Ltt.subVectors(p,s),iyt.crossVectors(nyt,Ltt);let S=this.direction.dot(iyt),y;if(S>0){if(m)return null;y=1}else if(S<0)y=-1,S=-S;else return null;JE.subVectors(this.origin,s);let I=y*this.direction.dot(Ltt.crossVectors(JE,Ltt));if(I<0)return null;let N=y*this.direction.dot(nyt.cross(JE));if(N<0||I+N>S)return null;let B=-y*JE.dot(iyt);return B<0?null:this.at(B/S,_)}applyMatrix4(s){return this.origin.applyMatrix4(s),this.direction.transformDirection(s),this}equals(s){return s.origin.equals(this.origin)&&s.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Bu=class d{constructor(s,h,p,m,_,S,y,I,N,B,P,U,j,V,et,Q){d.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],s!==void 0&&this.set(s,h,p,m,_,S,y,I,N,B,P,U,j,V,et,Q)}set(s,h,p,m,_,S,y,I,N,B,P,U,j,V,et,Q){let X=this.elements;return X[0]=s,X[4]=h,X[8]=p,X[12]=m,X[1]=_,X[5]=S,X[9]=y,X[13]=I,X[2]=N,X[6]=B,X[10]=P,X[14]=U,X[3]=j,X[7]=V,X[11]=et,X[15]=Q,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new d().fromArray(this.elements)}copy(s){let h=this.elements,p=s.elements;return h[0]=p[0],h[1]=p[1],h[2]=p[2],h[3]=p[3],h[4]=p[4],h[5]=p[5],h[6]=p[6],h[7]=p[7],h[8]=p[8],h[9]=p[9],h[10]=p[10],h[11]=p[11],h[12]=p[12],h[13]=p[13],h[14]=p[14],h[15]=p[15],this}copyPosition(s){let h=this.elements,p=s.elements;return h[12]=p[12],h[13]=p[13],h[14]=p[14],this}setFromMatrix3(s){let h=s.elements;return this.set(h[0],h[3],h[6],0,h[1],h[4],h[7],0,h[2],h[5],h[8],0,0,0,0,1),this}extractBasis(s,h,p){return s.setFromMatrixColumn(this,0),h.setFromMatrixColumn(this,1),p.setFromMatrixColumn(this,2),this}makeBasis(s,h,p){return this.set(s.x,h.x,p.x,0,s.y,h.y,p.y,0,s.z,h.z,p.z,0,0,0,0,1),this}extractRotation(s){let h=this.elements,p=s.elements,m=1/OI.setFromMatrixColumn(s,0).length(),_=1/OI.setFromMatrixColumn(s,1).length(),S=1/OI.setFromMatrixColumn(s,2).length();return h[0]=p[0]*m,h[1]=p[1]*m,h[2]=p[2]*m,h[3]=0,h[4]=p[4]*_,h[5]=p[5]*_,h[6]=p[6]*_,h[7]=0,h[8]=p[8]*S,h[9]=p[9]*S,h[10]=p[10]*S,h[11]=0,h[12]=0,h[13]=0,h[14]=0,h[15]=1,this}makeRotationFromEuler(s){let h=this.elements,p=s.x,m=s.y,_=s.z,S=Math.cos(p),y=Math.sin(p),I=Math.cos(m),N=Math.sin(m),B=Math.cos(_),P=Math.sin(_);if(s.order==="XYZ"){let U=S*B,j=S*P,V=y*B,et=y*P;h[0]=I*B,h[4]=-I*P,h[8]=N,h[1]=j+V*N,h[5]=U-et*N,h[9]=-y*I,h[2]=et-U*N,h[6]=V+j*N,h[10]=S*I}else if(s.order==="YXZ"){let U=I*B,j=I*P,V=N*B,et=N*P;h[0]=U+et*y,h[4]=V*y-j,h[8]=S*N,h[1]=S*P,h[5]=S*B,h[9]=-y,h[2]=j*y-V,h[6]=et+U*y,h[10]=S*I}else if(s.order==="ZXY"){let U=I*B,j=I*P,V=N*B,et=N*P;h[0]=U-et*y,h[4]=-S*P,h[8]=V+j*y,h[1]=j+V*y,h[5]=S*B,h[9]=et-U*y,h[2]=-S*N,h[6]=y,h[10]=S*I}else if(s.order==="ZYX"){let U=S*B,j=S*P,V=y*B,et=y*P;h[0]=I*B,h[4]=V*N-j,h[8]=U*N+et,h[1]=I*P,h[5]=et*N+U,h[9]=j*N-V,h[2]=-N,h[6]=y*I,h[10]=S*I}else if(s.order==="YZX"){let U=S*I,j=S*N,V=y*I,et=y*N;h[0]=I*B,h[4]=et-U*P,h[8]=V*P+j,h[1]=P,h[5]=S*B,h[9]=-y*B,h[2]=-N*B,h[6]=j*P+V,h[10]=U-et*P}else if(s.order==="XZY"){let U=S*I,j=S*N,V=y*I,et=y*N;h[0]=I*B,h[4]=-P,h[8]=N*B,h[1]=U*P+et,h[5]=S*B,h[9]=j*P-V,h[2]=V*P-j,h[6]=y*B,h[10]=et*P+U}return h[3]=0,h[7]=0,h[11]=0,h[12]=0,h[13]=0,h[14]=0,h[15]=1,this}makeRotationFromQuaternion(s){return this.compose(IEe,s,REe)}lookAt(s,h,p){let m=this.elements;return P0.subVectors(s,h),P0.lengthSq()===0&&(P0.z=1),P0.normalize(),QE.crossVectors(p,P0),QE.lengthSq()===0&&(Math.abs(p.z)===1?P0.x+=1e-4:P0.z+=1e-4,P0.normalize(),QE.crossVectors(p,P0)),QE.normalize(),Ptt.crossVectors(P0,QE),m[0]=QE.x,m[4]=Ptt.x,m[8]=P0.x,m[1]=QE.y,m[5]=Ptt.y,m[9]=P0.y,m[2]=QE.z,m[6]=Ptt.z,m[10]=P0.z,this}multiply(s){return this.multiplyMatrices(this,s)}premultiply(s){return this.multiplyMatrices(s,this)}multiplyMatrices(s,h){let p=s.elements,m=h.elements,_=this.elements,S=p[0],y=p[4],I=p[8],N=p[12],B=p[1],P=p[5],U=p[9],j=p[13],V=p[2],et=p[6],Q=p[10],X=p[14],gt=p[3],ft=p[7],xt=p[11],Bt=p[15],Dt=m[0],Pt=m[4],se=m[8],ot=m[12],Lt=m[1],be=m[5],ln=m[9],Fn=m[13],ne=m[2],xe=m[6],re=m[10],hn=m[14],Se=m[3],ke=m[7],mn=m[11],en=m[15];return _[0]=S*Dt+y*Lt+I*ne+N*Se,_[4]=S*Pt+y*be+I*xe+N*ke,_[8]=S*se+y*ln+I*re+N*mn,_[12]=S*ot+y*Fn+I*hn+N*en,_[1]=B*Dt+P*Lt+U*ne+j*Se,_[5]=B*Pt+P*be+U*xe+j*ke,_[9]=B*se+P*ln+U*re+j*mn,_[13]=B*ot+P*Fn+U*hn+j*en,_[2]=V*Dt+et*Lt+Q*ne+X*Se,_[6]=V*Pt+et*be+Q*xe+X*ke,_[10]=V*se+et*ln+Q*re+X*mn,_[14]=V*ot+et*Fn+Q*hn+X*en,_[3]=gt*Dt+ft*Lt+xt*ne+Bt*Se,_[7]=gt*Pt+ft*be+xt*xe+Bt*ke,_[11]=gt*se+ft*ln+xt*re+Bt*mn,_[15]=gt*ot+ft*Fn+xt*hn+Bt*en,this}multiplyScalar(s){let h=this.elements;return h[0]*=s,h[4]*=s,h[8]*=s,h[12]*=s,h[1]*=s,h[5]*=s,h[9]*=s,h[13]*=s,h[2]*=s,h[6]*=s,h[10]*=s,h[14]*=s,h[3]*=s,h[7]*=s,h[11]*=s,h[15]*=s,this}determinant(){let s=this.elements,h=s[0],p=s[4],m=s[8],_=s[12],S=s[1],y=s[5],I=s[9],N=s[13],B=s[2],P=s[6],U=s[10],j=s[14],V=s[3],et=s[7],Q=s[11],X=s[15];return V*(+_*I*P-m*N*P-_*y*U+p*N*U+m*y*j-p*I*j)+et*(+h*I*j-h*N*U+_*S*U-m*S*j+m*N*B-_*I*B)+Q*(+h*N*P-h*y*j-_*S*P+p*S*j+_*y*B-p*N*B)+X*(-m*y*B-h*I*P+h*y*U+m*S*P-p*S*U+p*I*B)}transpose(){let s=this.elements,h;return h=s[1],s[1]=s[4],s[4]=h,h=s[2],s[2]=s[8],s[8]=h,h=s[6],s[6]=s[9],s[9]=h,h=s[3],s[3]=s[12],s[12]=h,h=s[7],s[7]=s[13],s[13]=h,h=s[11],s[11]=s[14],s[14]=h,this}setPosition(s,h,p){let m=this.elements;return s.isVector3?(m[12]=s.x,m[13]=s.y,m[14]=s.z):(m[12]=s,m[13]=h,m[14]=p),this}invert(){let s=this.elements,h=s[0],p=s[1],m=s[2],_=s[3],S=s[4],y=s[5],I=s[6],N=s[7],B=s[8],P=s[9],U=s[10],j=s[11],V=s[12],et=s[13],Q=s[14],X=s[15],gt=P*Q*N-et*U*N+et*I*j-y*Q*j-P*I*X+y*U*X,ft=V*U*N-B*Q*N-V*I*j+S*Q*j+B*I*X-S*U*X,xt=B*et*N-V*P*N+V*y*j-S*et*j-B*y*X+S*P*X,Bt=V*P*I-B*et*I-V*y*U+S*et*U+B*y*Q-S*P*Q,Dt=h*gt+p*ft+m*xt+_*Bt;if(Dt===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let Pt=1/Dt;return s[0]=gt*Pt,s[1]=(et*U*_-P*Q*_-et*m*j+p*Q*j+P*m*X-p*U*X)*Pt,s[2]=(y*Q*_-et*I*_+et*m*N-p*Q*N-y*m*X+p*I*X)*Pt,s[3]=(P*I*_-y*U*_-P*m*N+p*U*N+y*m*j-p*I*j)*Pt,s[4]=ft*Pt,s[5]=(B*Q*_-V*U*_+V*m*j-h*Q*j-B*m*X+h*U*X)*Pt,s[6]=(V*I*_-S*Q*_-V*m*N+h*Q*N+S*m*X-h*I*X)*Pt,s[7]=(S*U*_-B*I*_+B*m*N-h*U*N-S*m*j+h*I*j)*Pt,s[8]=xt*Pt,s[9]=(V*P*_-B*et*_-V*p*j+h*et*j+B*p*X-h*P*X)*Pt,s[10]=(S*et*_-V*y*_+V*p*N-h*et*N-S*p*X+h*y*X)*Pt,s[11]=(B*y*_-S*P*_-B*p*N+h*P*N+S*p*j-h*y*j)*Pt,s[12]=Bt*Pt,s[13]=(B*et*m-V*P*m+V*p*U-h*et*U-B*p*Q+h*P*Q)*Pt,s[14]=(V*y*m-S*et*m-V*p*I+h*et*I+S*p*Q-h*y*Q)*Pt,s[15]=(S*P*m-B*y*m+B*p*I-h*P*I-S*p*U+h*y*U)*Pt,this}scale(s){let h=this.elements,p=s.x,m=s.y,_=s.z;return h[0]*=p,h[4]*=m,h[8]*=_,h[1]*=p,h[5]*=m,h[9]*=_,h[2]*=p,h[6]*=m,h[10]*=_,h[3]*=p,h[7]*=m,h[11]*=_,this}getMaxScaleOnAxis(){let s=this.elements,h=s[0]*s[0]+s[1]*s[1]+s[2]*s[2],p=s[4]*s[4]+s[5]*s[5]+s[6]*s[6],m=s[8]*s[8]+s[9]*s[9]+s[10]*s[10];return Math.sqrt(Math.max(h,p,m))}makeTranslation(s,h,p){return s.isVector3?this.set(1,0,0,s.x,0,1,0,s.y,0,0,1,s.z,0,0,0,1):this.set(1,0,0,s,0,1,0,h,0,0,1,p,0,0,0,1),this}makeRotationX(s){let h=Math.cos(s),p=Math.sin(s);return this.set(1,0,0,0,0,h,-p,0,0,p,h,0,0,0,0,1),this}makeRotationY(s){let h=Math.cos(s),p=Math.sin(s);return this.set(h,0,p,0,0,1,0,0,-p,0,h,0,0,0,0,1),this}makeRotationZ(s){let h=Math.cos(s),p=Math.sin(s);return this.set(h,-p,0,0,p,h,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(s,h){let p=Math.cos(h),m=Math.sin(h),_=1-p,S=s.x,y=s.y,I=s.z,N=_*S,B=_*y;return this.set(N*S+p,N*y-m*I,N*I+m*y,0,N*y+m*I,B*y+p,B*I-m*S,0,N*I-m*y,B*I+m*S,_*I*I+p,0,0,0,0,1),this}makeScale(s,h,p){return this.set(s,0,0,0,0,h,0,0,0,0,p,0,0,0,0,1),this}makeShear(s,h,p,m,_,S){return this.set(1,p,_,0,s,1,S,0,h,m,1,0,0,0,0,1),this}compose(s,h,p){let m=this.elements,_=h._x,S=h._y,y=h._z,I=h._w,N=_+_,B=S+S,P=y+y,U=_*N,j=_*B,V=_*P,et=S*B,Q=S*P,X=y*P,gt=I*N,ft=I*B,xt=I*P,Bt=p.x,Dt=p.y,Pt=p.z;return m[0]=(1-(et+X))*Bt,m[1]=(j+xt)*Bt,m[2]=(V-ft)*Bt,m[3]=0,m[4]=(j-xt)*Dt,m[5]=(1-(U+X))*Dt,m[6]=(Q+gt)*Dt,m[7]=0,m[8]=(V+ft)*Pt,m[9]=(Q-gt)*Pt,m[10]=(1-(U+et))*Pt,m[11]=0,m[12]=s.x,m[13]=s.y,m[14]=s.z,m[15]=1,this}decompose(s,h,p){let m=this.elements,_=OI.set(m[0],m[1],m[2]).length(),S=OI.set(m[4],m[5],m[6]).length(),y=OI.set(m[8],m[9],m[10]).length();this.determinant()<0&&(_=-_),s.x=m[12],s.y=m[13],s.z=m[14],Gw.copy(this);let N=1/_,B=1/S,P=1/y;return Gw.elements[0]*=N,Gw.elements[1]*=N,Gw.elements[2]*=N,Gw.elements[4]*=B,Gw.elements[5]*=B,Gw.elements[6]*=B,Gw.elements[8]*=P,Gw.elements[9]*=P,Gw.elements[10]*=P,h.setFromRotationMatrix(Gw),p.x=_,p.y=S,p.z=y,this}makePerspective(s,h,p,m,_,S,y=Xx){let I=this.elements,N=2*_/(h-s),B=2*_/(p-m),P=(h+s)/(h-s),U=(p+m)/(p-m),j,V;if(y===Xx)j=-(S+_)/(S-_),V=-2*S*_/(S-_);else if(y===oet)j=-S/(S-_),V=-S*_/(S-_);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+y);return I[0]=N,I[4]=0,I[8]=P,I[12]=0,I[1]=0,I[5]=B,I[9]=U,I[13]=0,I[2]=0,I[6]=0,I[10]=j,I[14]=V,I[3]=0,I[7]=0,I[11]=-1,I[15]=0,this}makeOrthographic(s,h,p,m,_,S,y=Xx){let I=this.elements,N=1/(h-s),B=1/(p-m),P=1/(S-_),U=(h+s)*N,j=(p+m)*B,V,et;if(y===Xx)V=(S+_)*P,et=-2*P;else if(y===oet)V=_*P,et=-1*P;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+y);return I[0]=2*N,I[4]=0,I[8]=0,I[12]=-U,I[1]=0,I[5]=2*B,I[9]=0,I[13]=-j,I[2]=0,I[6]=0,I[10]=et,I[14]=-V,I[3]=0,I[7]=0,I[11]=0,I[15]=1,this}equals(s){let h=this.elements,p=s.elements;for(let m=0;m<16;m++)if(h[m]!==p[m])return!1;return!0}fromArray(s,h=0){for(let p=0;p<16;p++)this.elements[p]=s[p+h];return this}toArray(s=[],h=0){let p=this.elements;return s[h]=p[0],s[h+1]=p[1],s[h+2]=p[2],s[h+3]=p[3],s[h+4]=p[4],s[h+5]=p[5],s[h+6]=p[6],s[h+7]=p[7],s[h+8]=p[8],s[h+9]=p[9],s[h+10]=p[10],s[h+11]=p[11],s[h+12]=p[12],s[h+13]=p[13],s[h+14]=p[14],s[h+15]=p[15],s}},OI=new Ge,Gw=new Bu,IEe=new Ge(0,0,0),REe=new Ge(1,1,1),QE=new Ge,Ptt=new Ge,P0=new Ge,rYt=new Bu,sYt=new vy,fet=class d{constructor(s=0,h=0,p=0,m=d.DEFAULT_ORDER){this.isEuler=!0,this._x=s,this._y=h,this._z=p,this._order=m}get x(){return this._x}set x(s){this._x=s,this._onChangeCallback()}get y(){return this._y}set y(s){this._y=s,this._onChangeCallback()}get z(){return this._z}set z(s){this._z=s,this._onChangeCallback()}get order(){return this._order}set order(s){this._order=s,this._onChangeCallback()}set(s,h,p,m=this._order){return this._x=s,this._y=h,this._z=p,this._order=m,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(s){return this._x=s._x,this._y=s._y,this._z=s._z,this._order=s._order,this._onChangeCallback(),this}setFromRotationMatrix(s,h=this._order,p=!0){let m=s.elements,_=m[0],S=m[4],y=m[8],I=m[1],N=m[5],B=m[9],P=m[2],U=m[6],j=m[10];switch(h){case"XYZ":this._y=Math.asin(dg(y,-1,1)),Math.abs(y)<.9999999?(this._x=Math.atan2(-B,j),this._z=Math.atan2(-S,_)):(this._x=Math.atan2(U,N),this._z=0);break;case"YXZ":this._x=Math.asin(-dg(B,-1,1)),Math.abs(B)<.9999999?(this._y=Math.atan2(y,j),this._z=Math.atan2(I,N)):(this._y=Math.atan2(-P,_),this._z=0);break;case"ZXY":this._x=Math.asin(dg(U,-1,1)),Math.abs(U)<.9999999?(this._y=Math.atan2(-P,j),this._z=Math.atan2(-S,N)):(this._y=0,this._z=Math.atan2(I,_));break;case"ZYX":this._y=Math.asin(-dg(P,-1,1)),Math.abs(P)<.9999999?(this._x=Math.atan2(U,j),this._z=Math.atan2(I,_)):(this._x=0,this._z=Math.atan2(-S,N));break;case"YZX":this._z=Math.asin(dg(I,-1,1)),Math.abs(I)<.9999999?(this._x=Math.atan2(-B,N),this._y=Math.atan2(-P,_)):(this._x=0,this._y=Math.atan2(y,j));break;case"XZY":this._z=Math.asin(-dg(S,-1,1)),Math.abs(S)<.9999999?(this._x=Math.atan2(U,N),this._y=Math.atan2(y,_)):(this._x=Math.atan2(-B,j),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+h)}return this._order=h,p===!0&&this._onChangeCallback(),this}setFromQuaternion(s,h,p){return rYt.makeRotationFromQuaternion(s),this.setFromRotationMatrix(rYt,h,p)}setFromVector3(s,h=this._order){return this.set(s.x,s.y,s.z,h)}reorder(s){return sYt.setFromEuler(this),this.setFromQuaternion(sYt,s)}equals(s){return s._x===this._x&&s._y===this._y&&s._z===this._z&&s._order===this._order}fromArray(s){return this._x=s[0],this._y=s[1],this._z=s[2],s[3]!==void 0&&(this._order=s[3]),this._onChangeCallback(),this}toArray(s=[],h=0){return s[h]=this._x,s[h+1]=this._y,s[h+2]=this._z,s[h+3]=this._order,s}_onChange(s){return this._onChangeCallback=s,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};fet.DEFAULT_ORDER="XYZ";var _U=class{constructor(){this.mask=1}set(s){this.mask=(1<>>0}enable(s){this.mask|=1<1){for(let h=0;h1){for(let p=0;p0&&(m.userData=this.userData),m.layers=this.layers.mask,m.matrix=this.matrix.toArray(),m.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(m.matrixAutoUpdate=!1),this.isInstancedMesh&&(m.type="InstancedMesh",m.count=this.count,m.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(m.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(m.type="BatchedMesh",m.perObjectFrustumCulled=this.perObjectFrustumCulled,m.sortObjects=this.sortObjects,m.drawRanges=this._drawRanges,m.reservedRanges=this._reservedRanges,m.visibility=this._visibility,m.active=this._active,m.bounds=this._bounds.map(y=>({boxInitialized:y.boxInitialized,boxMin:y.box.min.toArray(),boxMax:y.box.max.toArray(),sphereInitialized:y.sphereInitialized,sphereRadius:y.sphere.radius,sphereCenter:y.sphere.center.toArray()})),m.maxGeometryCount=this._maxGeometryCount,m.maxVertexCount=this._maxVertexCount,m.maxIndexCount=this._maxIndexCount,m.geometryInitialized=this._geometryInitialized,m.geometryCount=this._geometryCount,m.matricesTexture=this._matricesTexture.toJSON(s),this.boundingSphere!==null&&(m.boundingSphere={center:m.boundingSphere.center.toArray(),radius:m.boundingSphere.radius}),this.boundingBox!==null&&(m.boundingBox={min:m.boundingBox.min.toArray(),max:m.boundingBox.max.toArray()}));function _(y,I){return y[I.uuid]===void 0&&(y[I.uuid]=I.toJSON(s)),I.uuid}if(this.isScene)this.background&&(this.background.isColor?m.background=this.background.toJSON():this.background.isTexture&&(m.background=this.background.toJSON(s).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(m.environment=this.environment.toJSON(s).uuid);else if(this.isMesh||this.isLine||this.isPoints){m.geometry=_(s.geometries,this.geometry);let y=this.geometry.parameters;if(y!==void 0&&y.shapes!==void 0){let I=y.shapes;if(Array.isArray(I))for(let N=0,B=I.length;N0){m.children=[];for(let y=0;y0){m.animations=[];for(let y=0;y0&&(p.geometries=y),I.length>0&&(p.materials=I),N.length>0&&(p.textures=N),B.length>0&&(p.images=B),P.length>0&&(p.shapes=P),U.length>0&&(p.skeletons=U),j.length>0&&(p.animations=j),V.length>0&&(p.nodes=V)}return p.object=m,p;function S(y){let I=[];for(let N in y){let B=y[N];delete B.metadata,I.push(B)}return I}}clone(s){return new this.constructor().copy(this,s)}copy(s,h=!0){if(this.name=s.name,this.up.copy(s.up),this.position.copy(s.position),this.rotation.order=s.rotation.order,this.quaternion.copy(s.quaternion),this.scale.copy(s.scale),this.matrix.copy(s.matrix),this.matrixWorld.copy(s.matrixWorld),this.matrixAutoUpdate=s.matrixAutoUpdate,this.matrixWorldAutoUpdate=s.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=s.matrixWorldNeedsUpdate,this.layers.mask=s.layers.mask,this.visible=s.visible,this.castShadow=s.castShadow,this.receiveShadow=s.receiveShadow,this.frustumCulled=s.frustumCulled,this.renderOrder=s.renderOrder,this.animations=s.animations.slice(),this.userData=JSON.parse(JSON.stringify(s.userData)),h===!0)for(let p=0;p0?m.multiplyScalar(1/Math.sqrt(_)):m.set(0,0,0)}static getBarycoord(s,h,p,m,_){Ww.subVectors(m,h),Wx.subVectors(p,h),ryt.subVectors(s,h);let S=Ww.dot(Ww),y=Ww.dot(Wx),I=Ww.dot(ryt),N=Wx.dot(Wx),B=Wx.dot(ryt),P=S*N-y*y;if(P===0)return _.set(0,0,0),null;let U=1/P,j=(N*I-y*B)*U,V=(S*B-y*I)*U;return _.set(1-j-V,V,j)}static containsPoint(s,h,p,m){return this.getBarycoord(s,h,p,m,$x)===null?!1:$x.x>=0&&$x.y>=0&&$x.x+$x.y<=1}static getUV(s,h,p,m,_,S,y,I){return Rtt===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Rtt=!0),this.getInterpolation(s,h,p,m,_,S,y,I)}static getInterpolation(s,h,p,m,_,S,y,I){return this.getBarycoord(s,h,p,m,$x)===null?(I.x=0,I.y=0,"z"in I&&(I.z=0),"w"in I&&(I.w=0),null):(I.setScalar(0),I.addScaledVector(_,$x.x),I.addScaledVector(S,$x.y),I.addScaledVector(y,$x.z),I)}static isFrontFacing(s,h,p,m){return Ww.subVectors(p,h),Wx.subVectors(s,h),Ww.cross(Wx).dot(m)<0}set(s,h,p){return this.a.copy(s),this.b.copy(h),this.c.copy(p),this}setFromPointsAndIndices(s,h,p,m){return this.a.copy(s[h]),this.b.copy(s[p]),this.c.copy(s[m]),this}setFromAttributeAndIndices(s,h,p,m){return this.a.fromBufferAttribute(s,h),this.b.fromBufferAttribute(s,p),this.c.fromBufferAttribute(s,m),this}clone(){return new this.constructor().copy(this)}copy(s){return this.a.copy(s.a),this.b.copy(s.b),this.c.copy(s.c),this}getArea(){return Ww.subVectors(this.c,this.b),Wx.subVectors(this.a,this.b),Ww.cross(Wx).length()*.5}getMidpoint(s){return s.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(s){return d.getNormal(this.a,this.b,this.c,s)}getPlane(s){return s.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(s,h){return d.getBarycoord(s,this.a,this.b,this.c,h)}getUV(s,h,p,m,_){return Rtt===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Rtt=!0),d.getInterpolation(s,this.a,this.b,this.c,h,p,m,_)}getInterpolation(s,h,p,m,_){return d.getInterpolation(s,this.a,this.b,this.c,h,p,m,_)}containsPoint(s){return d.containsPoint(s,this.a,this.b,this.c)}isFrontFacing(s){return d.isFrontFacing(this.a,this.b,this.c,s)}intersectsBox(s){return s.intersectsTriangle(this)}closestPointToPoint(s,h){let p=this.a,m=this.b,_=this.c,S,y;FI.subVectors(m,p),UI.subVectors(_,p),syt.subVectors(s,p);let I=FI.dot(syt),N=UI.dot(syt);if(I<=0&&N<=0)return h.copy(p);oyt.subVectors(s,m);let B=FI.dot(oyt),P=UI.dot(oyt);if(B>=0&&P<=B)return h.copy(m);let U=I*P-B*N;if(U<=0&&I>=0&&B<=0)return S=I/(I-B),h.copy(p).addScaledVector(FI,S);cyt.subVectors(s,_);let j=FI.dot(cyt),V=UI.dot(cyt);if(V>=0&&j<=V)return h.copy(_);let et=j*N-I*V;if(et<=0&&N>=0&&V<=0)return y=N/(N-V),h.copy(p).addScaledVector(UI,y);let Q=B*V-j*P;if(Q<=0&&P-B>=0&&j-V>=0)return lYt.subVectors(_,m),y=(P-B)/(P-B+(j-V)),h.copy(m).addScaledVector(lYt,y);let X=1/(Q+et+U);return S=et*X,y=U*X,h.copy(p).addScaledVector(FI,S).addScaledVector(UI,y)}equals(s){return s.a.equals(this.a)&&s.b.equals(this.b)&&s.c.equals(this.c)}},oKt={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},tS={h:0,s:0,l:0},Dtt={h:0,s:0,l:0};function ayt(d,s,h){return h<0&&(h+=1),h>1&&(h-=1),h<1/6?d+(s-d)*6*h:h<1/2?s:h<2/3?d+(s-d)*6*(2/3-h):d}var Go=class{constructor(s,h,p){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(s,h,p)}set(s,h,p){if(h===void 0&&p===void 0){let m=s;m&&m.isColor?this.copy(m):typeof m=="number"?this.setHex(m):typeof m=="string"&&this.setStyle(m)}else this.setRGB(s,h,p);return this}setScalar(s){return this.r=s,this.g=s,this.b=s,this}setHex(s,h=Pd){return s=Math.floor(s),this.r=(s>>16&255)/255,this.g=(s>>8&255)/255,this.b=(s&255)/255,Na.toWorkingColorSpace(this,h),this}setRGB(s,h,p,m=Na.workingColorSpace){return this.r=s,this.g=h,this.b=p,Na.toWorkingColorSpace(this,m),this}setHSL(s,h,p,m=Na.workingColorSpace){if(s=TEe(s,1),h=dg(h,0,1),p=dg(p,0,1),h===0)this.r=this.g=this.b=p;else{let _=p<=.5?p*(1+h):p+h-p*h,S=2*p-_;this.r=ayt(S,_,s+1/3),this.g=ayt(S,_,s),this.b=ayt(S,_,s-1/3)}return Na.toWorkingColorSpace(this,m),this}setStyle(s,h=Pd){function p(_){_!==void 0&&parseFloat(_)<1&&console.warn("THREE.Color: Alpha component of "+s+" will be ignored.")}let m;if(m=/^(\w+)\(([^\)]*)\)/.exec(s)){let _,S=m[1],y=m[2];switch(S){case"rgb":case"rgba":if(_=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(y))return p(_[4]),this.setRGB(Math.min(255,parseInt(_[1],10))/255,Math.min(255,parseInt(_[2],10))/255,Math.min(255,parseInt(_[3],10))/255,h);if(_=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(y))return p(_[4]),this.setRGB(Math.min(100,parseInt(_[1],10))/100,Math.min(100,parseInt(_[2],10))/100,Math.min(100,parseInt(_[3],10))/100,h);break;case"hsl":case"hsla":if(_=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(y))return p(_[4]),this.setHSL(parseFloat(_[1])/360,parseFloat(_[2])/100,parseFloat(_[3])/100,h);break;default:console.warn("THREE.Color: Unknown color model "+s)}}else if(m=/^\#([A-Fa-f\d]+)$/.exec(s)){let _=m[1],S=_.length;if(S===3)return this.setRGB(parseInt(_.charAt(0),16)/15,parseInt(_.charAt(1),16)/15,parseInt(_.charAt(2),16)/15,h);if(S===6)return this.setHex(parseInt(_,16),h);console.warn("THREE.Color: Invalid hex color "+s)}else if(s&&s.length>0)return this.setColorName(s,h);return this}setColorName(s,h=Pd){let p=oKt[s.toLowerCase()];return p!==void 0?this.setHex(p,h):console.warn("THREE.Color: Unknown color "+s),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(s){return this.r=s.r,this.g=s.g,this.b=s.b,this}copySRGBToLinear(s){return this.r=KI(s.r),this.g=KI(s.g),this.b=KI(s.b),this}copyLinearToSRGB(s){return this.r=Y_t(s.r),this.g=Y_t(s.g),this.b=Y_t(s.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(s=Pd){return Na.fromWorkingColorSpace(mp.copy(this),s),Math.round(dg(mp.r*255,0,255))*65536+Math.round(dg(mp.g*255,0,255))*256+Math.round(dg(mp.b*255,0,255))}getHexString(s=Pd){return("000000"+this.getHex(s).toString(16)).slice(-6)}getHSL(s,h=Na.workingColorSpace){Na.fromWorkingColorSpace(mp.copy(this),h);let p=mp.r,m=mp.g,_=mp.b,S=Math.max(p,m,_),y=Math.min(p,m,_),I,N,B=(y+S)/2;if(y===S)I=0,N=0;else{let P=S-y;switch(N=B<=.5?P/(S+y):P/(2-S-y),S){case p:I=(m-_)/P+(m<_?6:0);break;case m:I=(_-p)/P+2;break;case _:I=(p-m)/P+4;break}I/=6}return s.h=I,s.s=N,s.l=B,s}getRGB(s,h=Na.workingColorSpace){return Na.fromWorkingColorSpace(mp.copy(this),h),s.r=mp.r,s.g=mp.g,s.b=mp.b,s}getStyle(s=Pd){Na.fromWorkingColorSpace(mp.copy(this),s);let h=mp.r,p=mp.g,m=mp.b;return s!==Pd?`color(${s} ${h.toFixed(3)} ${p.toFixed(3)} ${m.toFixed(3)})`:`rgb(${Math.round(h*255)},${Math.round(p*255)},${Math.round(m*255)})`}offsetHSL(s,h,p){return this.getHSL(tS),this.setHSL(tS.h+s,tS.s+h,tS.l+p)}add(s){return this.r+=s.r,this.g+=s.g,this.b+=s.b,this}addColors(s,h){return this.r=s.r+h.r,this.g=s.g+h.g,this.b=s.b+h.b,this}addScalar(s){return this.r+=s,this.g+=s,this.b+=s,this}sub(s){return this.r=Math.max(0,this.r-s.r),this.g=Math.max(0,this.g-s.g),this.b=Math.max(0,this.b-s.b),this}multiply(s){return this.r*=s.r,this.g*=s.g,this.b*=s.b,this}multiplyScalar(s){return this.r*=s,this.g*=s,this.b*=s,this}lerp(s,h){return this.r+=(s.r-this.r)*h,this.g+=(s.g-this.g)*h,this.b+=(s.b-this.b)*h,this}lerpColors(s,h,p){return this.r=s.r+(h.r-s.r)*p,this.g=s.g+(h.g-s.g)*p,this.b=s.b+(h.b-s.b)*p,this}lerpHSL(s,h){this.getHSL(tS),s.getHSL(Dtt);let p=X_t(tS.h,Dtt.h,h),m=X_t(tS.s,Dtt.s,h),_=X_t(tS.l,Dtt.l,h);return this.setHSL(p,m,_),this}setFromVector3(s){return this.r=s.x,this.g=s.y,this.b=s.z,this}applyMatrix3(s){let h=this.r,p=this.g,m=this.b,_=s.elements;return this.r=_[0]*h+_[3]*p+_[6]*m,this.g=_[1]*h+_[4]*p+_[7]*m,this.b=_[2]*h+_[5]*p+_[8]*m,this}equals(s){return s.r===this.r&&s.g===this.g&&s.b===this.b}fromArray(s,h=0){return this.r=s[h],this.g=s[h+1],this.b=s[h+2],this}toArray(s=[],h=0){return s[h]=this.r,s[h+1]=this.g,s[h+2]=this.b,s}fromBufferAttribute(s,h){return this.r=s.getX(h),this.g=s.getY(h),this.b=s.getZ(h),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},mp=new Go;Go.NAMES=oKt;var UEe=0,lS=class extends aS{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:UEe++}),this.uuid=SU(),this.name="",this.type="Material",this.blending=YI,this.side=cS,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=_yt,this.blendDst=yyt,this.blendEquation=zA,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Go(0,0,0),this.blendAlpha=0,this.depthFunc=tet,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=YZt,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=PI,this.stencilZFail=PI,this.stencilZPass=PI,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(s){this._alphaTest>0!=s>0&&this.version++,this._alphaTest=s}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(s){if(s!==void 0)for(let h in s){let p=s[h];if(p===void 0){console.warn(`THREE.Material: parameter '${h}' has value of undefined.`);continue}let m=this[h];if(m===void 0){console.warn(`THREE.Material: '${h}' is not a property of THREE.${this.type}.`);continue}m&&m.isColor?m.set(p):m&&m.isVector3&&p&&p.isVector3?m.copy(p):this[h]=p}}toJSON(s){let h=s===void 0||typeof s=="string";h&&(s={textures:{},images:{}});let p={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};p.uuid=this.uuid,p.type=this.type,this.name!==""&&(p.name=this.name),this.color&&this.color.isColor&&(p.color=this.color.getHex()),this.roughness!==void 0&&(p.roughness=this.roughness),this.metalness!==void 0&&(p.metalness=this.metalness),this.sheen!==void 0&&(p.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(p.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(p.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(p.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(p.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(p.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(p.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(p.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(p.shininess=this.shininess),this.clearcoat!==void 0&&(p.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(p.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(p.clearcoatMap=this.clearcoatMap.toJSON(s).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(p.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(s).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(p.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(s).uuid,p.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(p.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(p.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(p.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(p.iridescenceMap=this.iridescenceMap.toJSON(s).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(p.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(s).uuid),this.anisotropy!==void 0&&(p.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(p.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(p.anisotropyMap=this.anisotropyMap.toJSON(s).uuid),this.map&&this.map.isTexture&&(p.map=this.map.toJSON(s).uuid),this.matcap&&this.matcap.isTexture&&(p.matcap=this.matcap.toJSON(s).uuid),this.alphaMap&&this.alphaMap.isTexture&&(p.alphaMap=this.alphaMap.toJSON(s).uuid),this.lightMap&&this.lightMap.isTexture&&(p.lightMap=this.lightMap.toJSON(s).uuid,p.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(p.aoMap=this.aoMap.toJSON(s).uuid,p.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(p.bumpMap=this.bumpMap.toJSON(s).uuid,p.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(p.normalMap=this.normalMap.toJSON(s).uuid,p.normalMapType=this.normalMapType,p.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(p.displacementMap=this.displacementMap.toJSON(s).uuid,p.displacementScale=this.displacementScale,p.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(p.roughnessMap=this.roughnessMap.toJSON(s).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(p.metalnessMap=this.metalnessMap.toJSON(s).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(p.emissiveMap=this.emissiveMap.toJSON(s).uuid),this.specularMap&&this.specularMap.isTexture&&(p.specularMap=this.specularMap.toJSON(s).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(p.specularIntensityMap=this.specularIntensityMap.toJSON(s).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(p.specularColorMap=this.specularColorMap.toJSON(s).uuid),this.envMap&&this.envMap.isTexture&&(p.envMap=this.envMap.toJSON(s).uuid,this.combine!==void 0&&(p.combine=this.combine)),this.envMapIntensity!==void 0&&(p.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(p.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(p.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(p.gradientMap=this.gradientMap.toJSON(s).uuid),this.transmission!==void 0&&(p.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(p.transmissionMap=this.transmissionMap.toJSON(s).uuid),this.thickness!==void 0&&(p.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(p.thicknessMap=this.thicknessMap.toJSON(s).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(p.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(p.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(p.size=this.size),this.shadowSide!==null&&(p.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(p.sizeAttenuation=this.sizeAttenuation),this.blending!==YI&&(p.blending=this.blending),this.side!==cS&&(p.side=this.side),this.vertexColors===!0&&(p.vertexColors=!0),this.opacity<1&&(p.opacity=this.opacity),this.transparent===!0&&(p.transparent=!0),this.blendSrc!==_yt&&(p.blendSrc=this.blendSrc),this.blendDst!==yyt&&(p.blendDst=this.blendDst),this.blendEquation!==zA&&(p.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(p.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(p.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(p.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(p.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(p.blendAlpha=this.blendAlpha),this.depthFunc!==tet&&(p.depthFunc=this.depthFunc),this.depthTest===!1&&(p.depthTest=this.depthTest),this.depthWrite===!1&&(p.depthWrite=this.depthWrite),this.colorWrite===!1&&(p.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(p.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==YZt&&(p.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(p.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(p.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==PI&&(p.stencilFail=this.stencilFail),this.stencilZFail!==PI&&(p.stencilZFail=this.stencilZFail),this.stencilZPass!==PI&&(p.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(p.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(p.rotation=this.rotation),this.polygonOffset===!0&&(p.polygonOffset=!0),this.polygonOffsetFactor!==0&&(p.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(p.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(p.linewidth=this.linewidth),this.dashSize!==void 0&&(p.dashSize=this.dashSize),this.gapSize!==void 0&&(p.gapSize=this.gapSize),this.scale!==void 0&&(p.scale=this.scale),this.dithering===!0&&(p.dithering=!0),this.alphaTest>0&&(p.alphaTest=this.alphaTest),this.alphaHash===!0&&(p.alphaHash=!0),this.alphaToCoverage===!0&&(p.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(p.premultipliedAlpha=!0),this.forceSinglePass===!0&&(p.forceSinglePass=!0),this.wireframe===!0&&(p.wireframe=!0),this.wireframeLinewidth>1&&(p.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(p.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(p.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(p.flatShading=!0),this.visible===!1&&(p.visible=!1),this.toneMapped===!1&&(p.toneMapped=!1),this.fog===!1&&(p.fog=!1),Object.keys(this.userData).length>0&&(p.userData=this.userData);function m(_){let S=[];for(let y in _){let I=_[y];delete I.metadata,S.push(I)}return S}if(h){let _=m(s.textures),S=m(s.images);_.length>0&&(p.textures=_),S.length>0&&(p.images=S)}return p}clone(){return new this.constructor().copy(this)}copy(s){this.name=s.name,this.blending=s.blending,this.side=s.side,this.vertexColors=s.vertexColors,this.opacity=s.opacity,this.transparent=s.transparent,this.blendSrc=s.blendSrc,this.blendDst=s.blendDst,this.blendEquation=s.blendEquation,this.blendSrcAlpha=s.blendSrcAlpha,this.blendDstAlpha=s.blendDstAlpha,this.blendEquationAlpha=s.blendEquationAlpha,this.blendColor.copy(s.blendColor),this.blendAlpha=s.blendAlpha,this.depthFunc=s.depthFunc,this.depthTest=s.depthTest,this.depthWrite=s.depthWrite,this.stencilWriteMask=s.stencilWriteMask,this.stencilFunc=s.stencilFunc,this.stencilRef=s.stencilRef,this.stencilFuncMask=s.stencilFuncMask,this.stencilFail=s.stencilFail,this.stencilZFail=s.stencilZFail,this.stencilZPass=s.stencilZPass,this.stencilWrite=s.stencilWrite;let h=s.clippingPlanes,p=null;if(h!==null){let m=h.length;p=new Array(m);for(let _=0;_!==m;++_)p[_]=h[_].clone()}return this.clippingPlanes=p,this.clipIntersection=s.clipIntersection,this.clipShadows=s.clipShadows,this.shadowSide=s.shadowSide,this.colorWrite=s.colorWrite,this.precision=s.precision,this.polygonOffset=s.polygonOffset,this.polygonOffsetFactor=s.polygonOffsetFactor,this.polygonOffsetUnits=s.polygonOffsetUnits,this.dithering=s.dithering,this.alphaTest=s.alphaTest,this.alphaHash=s.alphaHash,this.alphaToCoverage=s.alphaToCoverage,this.premultipliedAlpha=s.premultipliedAlpha,this.forceSinglePass=s.forceSinglePass,this.visible=s.visible,this.toneMapped=s.toneMapped,this.userData=JSON.parse(JSON.stringify(s.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(s){s===!0&&this.version++}},nR=class extends lS{constructor(s){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Go(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=o2t,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(s)}copy(s){return super.copy(s),this.color.copy(s.color),this.map=s.map,this.lightMap=s.lightMap,this.lightMapIntensity=s.lightMapIntensity,this.aoMap=s.aoMap,this.aoMapIntensity=s.aoMapIntensity,this.specularMap=s.specularMap,this.alphaMap=s.alphaMap,this.envMap=s.envMap,this.combine=s.combine,this.reflectivity=s.reflectivity,this.refractionRatio=s.refractionRatio,this.wireframe=s.wireframe,this.wireframeLinewidth=s.wireframeLinewidth,this.wireframeLinecap=s.wireframeLinecap,this.wireframeLinejoin=s.wireframeLinejoin,this.fog=s.fog,this}};var Uh=new Ge,Ntt=new Nc,R0=class{constructor(s,h,p=!1){if(Array.isArray(s))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=s,this.itemSize=h,this.count=s!==void 0?s.length/h:0,this.normalized=p,this.usage=KZt,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=nS,this.version=0}onUploadCallback(){}set needsUpdate(s){s===!0&&this.version++}get updateRange(){return console.warn("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(s){return this.usage=s,this}addUpdateRange(s,h){this.updateRanges.push({start:s,count:h})}clearUpdateRanges(){this.updateRanges.length=0}copy(s){return this.name=s.name,this.array=new s.array.constructor(s.array),this.itemSize=s.itemSize,this.count=s.count,this.normalized=s.normalized,this.usage=s.usage,this.gpuType=s.gpuType,this}copyAt(s,h,p){s*=this.itemSize,p*=h.itemSize;for(let m=0,_=this.itemSize;m<_;m++)this.array[s+m]=h.array[p+m];return this}copyArray(s){return this.array.set(s),this}applyMatrix3(s){if(this.itemSize===2)for(let h=0,p=this.count;h0&&(s.userData=this.userData),this.parameters!==void 0){let I=this.parameters;for(let N in I)I[N]!==void 0&&(s[N]=I[N]);return s}s.data={attributes:{}};let h=this.index;h!==null&&(s.data.index={type:h.array.constructor.name,array:Array.prototype.slice.call(h.array)});let p=this.attributes;for(let I in p){let N=p[I];s.data.attributes[I]=N.toJSON(s.data)}let m={},_=!1;for(let I in this.morphAttributes){let N=this.morphAttributes[I],B=[];for(let P=0,U=N.length;P0&&(m[I]=B,_=!0)}_&&(s.data.morphAttributes=m,s.data.morphTargetsRelative=this.morphTargetsRelative);let S=this.groups;S.length>0&&(s.data.groups=JSON.parse(JSON.stringify(S)));let y=this.boundingSphere;return y!==null&&(s.data.boundingSphere={center:y.center.toArray(),radius:y.radius}),s}clone(){return new this.constructor().copy(this)}copy(s){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let h={};this.name=s.name;let p=s.index;p!==null&&this.setIndex(p.clone(h));let m=s.attributes;for(let N in m){let B=m[N];this.setAttribute(N,B.clone(h))}let _=s.morphAttributes;for(let N in _){let B=[],P=_[N];for(let U=0,j=P.length;U0){let m=h[p[0]];if(m!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let _=0,S=m.length;_(s.far-s.near)**2))&&(hYt.copy(_).invert(),BA.copy(s.ray).applyMatrix4(hYt),!(p.boundingBox!==null&&BA.intersectsBox(p.boundingBox)===!1)&&this._computeIntersections(s,h,BA)))}_computeIntersections(s,h,p){let m,_=this.geometry,S=this.material,y=_.index,I=_.attributes.position,N=_.attributes.uv,B=_.attributes.uv1,P=_.attributes.normal,U=_.groups,j=_.drawRange;if(y!==null)if(Array.isArray(S))for(let V=0,et=U.length;Vh.far?null:{distance:N,point:Htt.clone(),object:d}}function Gtt(d,s,h,p,m,_,S,y,I,N){d.getVertexPosition(y,jI),d.getVertexPosition(I,HI),d.getVertexPosition(N,GI);let B=jEe(d,s,h,p,jI,HI,GI,jtt);if(B){m&&(Ftt.fromBufferAttribute(m,y),Utt.fromBufferAttribute(m,I),ztt.fromBufferAttribute(m,N),B.uv=HA.getInterpolation(jtt,jI,HI,GI,Ftt,Utt,ztt,new Nc)),_&&(Ftt.fromBufferAttribute(_,y),Utt.fromBufferAttribute(_,I),ztt.fromBufferAttribute(_,N),B.uv1=HA.getInterpolation(jtt,jI,HI,GI,Ftt,Utt,ztt,new Nc),B.uv2=B.uv1),S&&(dYt.fromBufferAttribute(S,y),pYt.fromBufferAttribute(S,I),gYt.fromBufferAttribute(S,N),B.normal=HA.getInterpolation(jtt,jI,HI,GI,dYt,pYt,gYt,new Ge),B.normal.dot(p.direction)>0&&B.normal.multiplyScalar(-1));let P={a:y,b:I,c:N,normal:new Ge,materialIndex:0};HA.getNormal(jI,HI,GI,P.normal),B.face=P}return B}var VA=class d extends _y{constructor(s=1,h=1,p=1,m=1,_=1,S=1){super(),this.type="BoxGeometry",this.parameters={width:s,height:h,depth:p,widthSegments:m,heightSegments:_,depthSegments:S};let y=this;m=Math.floor(m),_=Math.floor(_),S=Math.floor(S);let I=[],N=[],B=[],P=[],U=0,j=0;V("z","y","x",-1,-1,p,h,s,S,_,0),V("z","y","x",1,-1,p,h,-s,S,_,1),V("x","z","y",1,1,s,p,h,m,S,2),V("x","z","y",1,-1,s,p,-h,m,S,3),V("x","y","z",1,-1,s,h,p,m,_,4),V("x","y","z",-1,-1,s,h,-p,m,_,5),this.setIndex(I),this.setAttribute("position",new mg(N,3)),this.setAttribute("normal",new mg(B,3)),this.setAttribute("uv",new mg(P,2));function V(et,Q,X,gt,ft,xt,Bt,Dt,Pt,se,ot){let Lt=xt/Pt,be=Bt/se,ln=xt/2,Fn=Bt/2,ne=Dt/2,xe=Pt+1,re=se+1,hn=0,Se=0,ke=new Ge;for(let mn=0;mn0?1:-1,B.push(ke.x,ke.y,ke.z),P.push(Qn/Pt),P.push(1-mn/se),hn+=1}}for(let mn=0;mn=xe)return S;var rt=U-S2(K);if(rt<1)return K;var mt=je?Xb(je,0,rt).join(""):S.slice(0,rt);if(pe===s)return mt+K;if(je&&(rt+=mt.length-rt),Kb(pe)){if(S.slice(rt).search(pe)){var vn,En=mt;for(pe.global||(pe=IT(pe.source,ya(AT.exec(pe))+"g")),pe.lastIndex=0;vn=pe.exec(En);)var In=vn.index;mt=mt.slice(0,In===s?rt:In)}}else if(S.indexOf(Pd(pe),rt)!=rt){var Vi=mt.lastIndexOf(pe);Vi>-1&&(mt=mt.slice(0,Vi))}return mt+K}function ZZ(S){return S=ya(S),S&&ti.test(S)?S.replace(xn,YH):S}var KZ=k2(function(S,P,U){return S+(U?" ":"")+P.toUpperCase()}),SR=VN("toUpperCase");function O2(S,P,U){return S=ya(S),P=U?s:P,P===s?VH(S)?JH(S):BH(S):S.match(P)||[]}var QF=ro(function(S,P){try{return Td(S,s,P)}catch(U){return wR(U)?U:new Es(U)}}),bC=r0(function(S,P){return Cd(P,function(U){U=_g(U),Im(S,U,Nm(S[U],S))}),S});function wC(S){var P=S==null?0:S.length,U=ts();return S=P?Lc(S,function(K){if(typeof K[1]!="function")throw new wp(u);return[U(K[0]),K[1]]}):[],ro(function(K){for(var pe=-1;++pext)return[];var U=wn,K=zf(S,wn);P=ts(P),S-=wn;for(var pe=Pk(K,P);++U0||P<0)?new Ro(U):(S<0?U=U.takeRight(-S):S&&(U=U.drop(S)),P!==s&&(P=Hs(P),U=P<0?U.dropRight(-P):U.take(P-S)),U)},Ro.prototype.takeRightWhile=function(S){return this.reverse().takeWhile(S).reverse()},Ro.prototype.toArray=function(){return this.take(wn)},Dm(Ro.prototype,function(S,P){var U=/^(?:filter|find|map|reject)|While$/.test(P),K=/^(?:head|last)$/.test(P),pe=_e[K?"take"+(P=="last"?"Right":""):P],xe=K||/^find/.test(P);pe&&(_e.prototype[P]=function(){var je=this.__wrapped__,rt=K?[1]:arguments,mt=je instanceof Ro,vn=rt[0],En=mt||Rs(je),In=function(so){var Go=pe.apply(_e,zb([so],rt));return K&&Vi?Go[0]:Go};En&&U&&typeof vn=="function"&&vn.length!=1&&(mt=En=!1);var Vi=this.__chain__,mr=!!this.__actions__.length,Fr=xe&&!Vi,eo=mt&&!mr;if(!xe&&En){je=eo?je:new Ro(this);var Vr=S.apply(je,rt);return Vr.__actions__.push({func:gR,args:[In],thisArg:s}),new vp(Vr,Vi)}return Fr&&eo?S.apply(this,rt):(Vr=this.thru(In),Fr?K?Vr.value()[0]:Vr.value():Vr)})}),Cd(["pop","push","shift","sort","splice","unshift"],function(S){var P=DT[S],U=/^(?:push|sort|unshift)$/.test(S)?"tap":"thru",K=/^(?:pop|shift)$/.test(S);_e.prototype[S]=function(){var pe=arguments;if(K&&!this.__chain__){var xe=this.value();return P.apply(Rs(xe)?xe:[],pe)}return this[U](function(je){return P.apply(Rs(je)?je:[],pe)})}}),Dm(Ro.prototype,function(S,P){var U=_e[P];if(U){var K=U.name+"";_a.call(C2,K)||(C2[K]=[]),C2[K].push({name:P,func:U})}}),C2[nC(s,O).name]=[{name:"wrapper",func:s}],Ro.prototype.clone=_q,Ro.prototype.reverse=yq,Ro.prototype.value=xq,_e.prototype.at=Ede,_e.prototype.chain=Sde,_e.prototype.commit=Mde,_e.prototype.next=Bu,_e.prototype.plant=Cde,_e.prototype.reverse=Ade,_e.prototype.toJSON=_e.prototype.valueOf=_e.prototype.value=pY,_e.prototype.first=_e.prototype.head,oE&&(_e.prototype[oE]=Tde),_e},J1=QH();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Iu._=J1,define(function(){return J1})):Dv?((Dv.exports=J1)._=J1,yk._=J1):Iu._=J1}).call(NB)});var _W=Ed(vW=>{"use strict";Object.defineProperty(vW,"__esModule",{value:!0});var sfe=bW(),LIe=O4(),b_t;(function(s){s.skin=null;function n(x,T){var M=LIe.filter(x,function(L){if(L instanceof Array&&L[0]==="g")return L[1]["s:pid"].startsWith(T)});return M}s.getPortsWithPrefix=n;function r(x,T){var M=LIe.filter(x,function(L){var I=L[0];if(L instanceof Array&&I==="g"){var D=L[1];return T(D)}return!1});return M.map(function(L){return L[1]["s:pid"]})}function c(x){return r(x,function(T){return T["s:position"]?T["s:position"]==="top":!1})}s.getInputPids=c;function u(x){return r(x,function(T){return T["s:position"]?T["s:position"]==="bottom":!1})}s.getOutputPids=u;function d(x){return r(x,function(T){return T["s:dir"]?T["s:dir"]==="lateral":T["s:position"]?T["s:position"]==="left"||T["s:position"]==="right":!1})}s.getLateralPortPids=d;function b(x){var T=null;return sfe.traverse(s.skin,{enter:function(M,L){M.name==="s:alias"&&M.attr.val===x&&(T=L)}}),T==null&&sfe.traverse(s.skin,{enter:function(M){M.attr["s:type"]==="generic"&&(T=M)}}),T.full}s.findSkinType=b;function w(){var x=[];return sfe.t(s.skin,{enter:function(T){T.name==="s:low_priority_alias"&&x.push(T.attr.value)}}),x}s.getLowPriorityAliases=w;function _(){var x;return sfe.t(s.skin,{enter:function(T){T.name==="s:properties"?x=LIe.mapValues(T.attr,function(M){return isNaN(Number(M))?M==="true"?!0:M==="false"?!1:M:Number(M)}):T.name==="s:layoutEngine"&&(x.layoutEngine=T.attr)}}),x.layoutEngine||(x.layoutEngine={}),x}s.getProperties=_})(b_t=vW.Skin||(vW.Skin={}));vW.default=b_t});var w_t=Ed(RIe=>{"use strict";Object.defineProperty(RIe,"__esModule",{value:!0});var kIe;(function(s){var n;(function(b){b.Zero="0",b.One="1",b.X="x"})(n||(n={}));var r;(function(b){b.Input="input",b.Output="output"})(r=s.Direction||(s.Direction={}));function c(b){return b.port_directions?Object.keys(b.port_directions).filter(function(w){return b.port_directions[w]===r.Input}):[]}s.getInputPortPids=c;function u(b){return b.port_directions?Object.keys(b.port_directions).filter(function(w){return b.port_directions[w]===r.Output}):[]}s.getOutputPortPids=u;var d;(function(b){b[b.Hide=0]="Hide",b[b.NoHide=1]="NoHide"})(d||(d={}))})(kIe||(kIe={}));RIe.default=kIe});var v_t=Ed(DIe=>{"use strict";Object.defineProperty(DIe,"__esModule",{value:!0});var zsn=BIe(),IIe=O4(),Gsn=function(){function s(n,r){this.key=n,this.value=r}return Object.defineProperty(s.prototype,"Key",{get:function(){return this.key},enumerable:!0,configurable:!0}),s.prototype.keyIn=function(n){return IIe.includes(n,this.key)},s.prototype.maxVal=function(){return IIe.max(IIe.map(this.value,function(n){return Number(n)}))},s.prototype.valString=function(){return","+this.value.join()+","},s.prototype.findConstants=function(n,r,c){var u=this,d="",b=[],w=this.value;return w.forEach(function(_,x){_==="0"||_==="1"?(r+=1,d+=_,w[x]=r,b.push(r)):b.length>0&&(u.assignConstant(d,b,x,n,c),d="",b=[])}),b.length>0&&this.assignConstant(d,b,w.length,n,c),r},s.prototype.getGenericElkPort=function(n,r,c){var u=this.parentNode.Key,d=this.parentNode.getTemplate()[1]["s:type"];if(n===0){var b={id:u+"."+this.key,width:1,height:1,x:Number(r[0][1]["s:x"]),y:Number(r[0][1]["s:y"])};return(d==="generic"||d==="join")&&c==="in"&&(b.labels=[{id:u+"."+this.key+".label",text:this.key,x:Number(r[0][2][1].x)-10,y:Number(r[0][2][1].y)-6,width:6*this.key.length,height:11}]),(d==="generic"||d==="split")&&c==="out"&&(b.labels=[{id:u+"."+this.key+".label",text:this.key,x:Number(r[0][2][1].x)-10,y:Number(r[0][2][1].y)-6,width:6*this.key.length,height:11}]),b}else{var w=Number(r[1][1]["s:y"])-Number(r[0][1]["s:y"]),b={id:u+"."+this.key,width:1,height:1,x:Number(r[0][1]["s:x"]),y:n*w+Number(r[0][1]["s:y"])};return d==="generic"&&(b.labels=[{id:u+"."+this.key+".label",text:this.key,x:Number(r[0][2][1].x)-10,y:Number(r[0][2][1].y)-6,width:6*this.key.length,height:11}]),b}},s.prototype.assignConstant=function(n,r,c,u,d){var b=this,w=n.split("").reverse().join("");if(u.hasOwnProperty(w)){var _=u[w],x=_.length;_.forEach(function(T,M){var L=c-x+M;b.value[L]=T})}else d.push(zsn.default.fromConstantInfo(w,r)),u[w]=r},s}();DIe.Port=Gsn});var __t=Ed((jai,ofe)=>{var jsn=function(){"use strict";function s(T,M){return M!=null&&T instanceof M}var n;try{n=Map}catch{n=function(){}}var r;try{r=Set}catch{r=function(){}}var c;try{c=Promise}catch{c=function(){}}function u(T,M,L,I,D){typeof M=="object"&&(L=M.depth,I=M.prototype,D=M.includeNonEnumerable,M=M.circular);var F=[],O=[],z=typeof Buffer<"u";typeof M>"u"&&(M=!0),typeof L>"u"&&(L=1/0);function Z(H,te){if(H===null)return null;if(te===0)return H;var se,ne;if(typeof H!="object")return H;if(s(H,n))se=new n;else if(s(H,r))se=new r;else if(s(H,c))se=new c(function(Qe,ot){H.then(function(xt){Qe(Z(xt,te-1))},function(xt){ot(Z(xt,te-1))})});else if(u.__isArray(H))se=[];else if(u.__isRegExp(H))se=new RegExp(H.source,x(H)),H.lastIndex&&(se.lastIndex=H.lastIndex);else if(u.__isDate(H))se=new Date(H.getTime());else{if(z&&Buffer.isBuffer(H))return Buffer.allocUnsafe?se=Buffer.allocUnsafe(H.length):se=new Buffer(H.length),H.copy(se),se;s(H,Error)?se=Object.create(H):typeof I>"u"?(ne=Object.getPrototypeOf(H),se=Object.create(ne)):(se=Object.create(I),ne=I)}if(M){var ue=F.indexOf(H);if(ue!=-1)return O[ue];F.push(H),O.push(se)}s(H,n)&&H.forEach(function(Qe,ot){var xt=Z(ot,te-1),fn=Z(Qe,te-1);se.set(xt,fn)}),s(H,r)&&H.forEach(function(Qe){var ot=Z(Qe,te-1);se.add(ot)});for(var Ce in H){var Q;ne&&(Q=Object.getOwnPropertyDescriptor(ne,Ce)),!(Q&&Q.set==null)&&(se[Ce]=Z(H[Ce],te-1))}if(Object.getOwnPropertySymbols)for(var me=Object.getOwnPropertySymbols(H),Ce=0;Ce{"use strict";Object.defineProperty(UIe,"__esModule",{value:!0});var afe=zIe(),OIe=w_t(),ug=_W(),rT=v_t(),NIe=O4(),yW=__t(),cfe=bW(),$sn=function(){function s(n,r,c,u,d){var b=this;this.key=n,this.type=r,this.inputPorts=c,this.outputPorts=u,this.attributes=d||{},c.forEach(function(w){w.parentNode=b}),u.forEach(function(w){w.parentNode=b})}return s.fromPort=function(n,r){var c=n.direction===OIe.default.Direction.Input;return c?new s(r,"$_inputExt_",[],[new rT.Port("Y",n.bits)],{}):new s(r,"$_outputExt_",[new rT.Port("A",n.bits)],[],{})},s.fromYosysCell=function(n,r){var c=ug.default.findSkinType(n.type),u=ug.default.getInputPids(c),d=ug.default.getOutputPids(c),b=NIe.map(n.connections,function(M,L){return new rT.Port(L,M)}),w=b.filter(function(M){return M.keyIn(u)}),_=b.filter(function(M){return M.keyIn(d)});if(w.length+_.length!==b.length){var x=OIe.default.getInputPortPids(n),T=OIe.default.getOutputPortPids(n);w=b.filter(function(M){return M.keyIn(x)}),_=b.filter(function(M){return M.keyIn(T)})}return new s(r,n.type,w,_,n.attributes)},s.fromConstantInfo=function(n,r){return new s(n,"$_constant_",[],[new rT.Port("Y",r)],{})},s.fromJoinInfo=function(n,r){var c=n.slice(1,-1).split(","),u=c.map(function(w){return Number(w)}),d=[new rT.Port("Y",u)],b=r.map(function(w){return new rT.Port(w,y_t(u,w))});return new s("$join$"+n,"$_join_",b,d,{})},s.fromSplitInfo=function(n,r){var c=n.slice(1,-1).split(","),u=c.map(function(w){return Number(w)}),d=[new rT.Port("A",u)],b=r.map(function(w){var _=y_t(u,w);return new rT.Port(w,_)});return new s("$split$"+n,"$_split_",d,b,{})},Object.defineProperty(s.prototype,"Type",{get:function(){return this.type},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"Key",{get:function(){return this.key},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"InputPorts",{get:function(){return this.inputPorts},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"OutputPorts",{get:function(){return this.outputPorts},enumerable:!0,configurable:!0}),s.prototype.maxOutVal=function(n){var r=NIe.max(this.outputPorts.map(function(c){return c.maxVal()}));return NIe.max([r,n])},s.prototype.findConstants=function(n,r,c){return this.inputPorts.forEach(function(u){r=u.findConstants(n,r,c)}),r},s.prototype.inputPortVals=function(){return this.inputPorts.map(function(n){return n.valString()})},s.prototype.outputPortVals=function(){return this.outputPorts.map(function(n){return n.valString()})},s.prototype.collectPortsByDirection=function(n,r,c,u){var d=ug.default.findSkinType(this.type),b=ug.default.getLateralPortPids(d);this.inputPorts.forEach(function(w){var _=w.keyIn(b);_||d[1]["s:type"]==="generic"&&u?afe.addToDefaultDict(c,w.valString(),w):afe.addToDefaultDict(n,w.valString(),w)}),this.outputPorts.forEach(function(w){var _=w.keyIn(b);_||d[1]["s:type"]==="generic"&&u?afe.addToDefaultDict(c,w.valString(),w):afe.addToDefaultDict(r,w.valString(),w)})},s.prototype.getValueAttribute=function(){return this.attributes&&this.attributes.value?this.attributes.value:null},s.prototype.getTemplate=function(){return ug.default.findSkinType(this.type)},s.prototype.buildElkChild=function(){var n=this,r=this.getTemplate(),c=r[1]["s:type"],u={"org.eclipse.elk.portConstraints":"FIXED_POS"},d=null,b=null;for(var w in this.attributes)if(w.startsWith("org.eclipse.elk")){if(w==="org.eclipse.elk.x"){d=this.attributes[w];continue}if(w==="org.eclipse.elk.y"){b=this.attributes[w];continue}u[w]=this.attributes[w]}if(c==="join"||c==="split"||c==="generic"){var _=ug.default.getPortsWithPrefix(r,"in"),x=ug.default.getPortsWithPrefix(r,"out"),T=this.inputPorts.map(function(O,z){return O.getGenericElkPort(z,_,"in")}),M=this.outputPorts.map(function(O,z){return O.getGenericElkPort(z,x,"out")}),L={id:this.key,width:Number(r[1]["s:width"]),height:Number(this.getGenericHeight()),ports:T.concat(M),layoutOptions:u,labels:[]};return d&&(L.x=d),b&&(L.y=b),this.addLabels(r,L),L}var I=ug.default.getPortsWithPrefix(r,"").map(function(O){return{id:n.key+"."+O[1]["s:pid"],width:0,height:0,x:Number(O[1]["s:x"]),y:Number(O[1]["s:y"])}}),D=Number(r[1]["s:width"]),F={id:this.key,width:D,height:Number(r[1]["s:height"]),ports:I,layoutOptions:u,labels:[]};return d&&(F.x=d),b&&(F.y=b),this.addLabels(r,F),F},s.prototype.render=function(n){for(var r=this.getTemplate(),c=yW(r),u=0,d=n.labels;u3){var w=parseInt(c.key,2);b="0x"+w.toString(16)}else b=c.key;c.attributes[d]=c.key}else if(d in c.attributes)b=c.attributes[d];else return;r.labels.push({id:c.key+".label."+d,text:b,x:u.attr.x,y:u.attr.y-6,height:11,width:6*b.length})}}})},s.prototype.getGenericHeight=function(){var n=this.getTemplate(),r=ug.default.getPortsWithPrefix(n,"in"),c=ug.default.getPortsWithPrefix(n,"out");if(this.inputPorts.length>this.outputPorts.length){var u=Number(r[1][1]["s:y"])-Number(r[0][1]["s:y"]);return Number(n[1]["s:height"])+u*(this.inputPorts.length-2)}if(c.length>1){var u=Number(c[1][1]["s:y"])-Number(c[0][1]["s:y"]);return Number(n[1]["s:height"])+u*(this.outputPorts.length-2)}return Number(n[1]["s:height"])},s}();UIe.default=$sn;function FIe(s,n){cfe.traverse(s,{enter:function(r){r.name==="rect"&&r.attr["s:generic"]==="body"&&(r.attr.height=n)}})}function Vsn(s,n,r){cfe.traverse(s,{enter:function(c){c.name==="text"&&c.attr["s:attribute"]===n&&(c.full[2]=r)}})}function Wsn(s,n,r){cfe.traverse(s,{enter:function(c){var u=c.attr.class;u&&u.includes(n)&&(c.attr.class=u.replace(n,r))}})}function y_t(s,n){var r=n.indexOf(":");if(r===-1)return[s[Number(n)]];var c=n.slice(0,r),u=n.slice(r+1),d=s.slice(Number(c),Number(u)+1);return d}});var zIe=Ed(FB=>{"use strict";Object.defineProperty(FB,"__esModule",{value:!0});var Hsn=_W(),lfe=BIe(),V1=O4(),qsn=function(){function s(n){var r=this;this.moduleName=null,V1.forEach(n.modules,function(b,w){b.attributes&&Number(b.attributes.top)===1&&(r.moduleName=w)}),this.moduleName==null&&(this.moduleName=Object.keys(n.modules)[0]);var c=n.modules[this.moduleName],u=V1.map(c.ports,lfe.default.fromPort),d=V1.map(c.cells,function(b,w){return lfe.default.fromYosysCell(b,w)});this.nodes=d.concat(u),this.wires=[]}return s.prototype.addConstants=function(){var n=this.nodes.reduce(function(u,d){return d.maxOutVal(u)},-1),r={},c=[];this.nodes.forEach(function(u){n=u.findConstants(r,n,c)}),this.nodes=this.nodes.concat(c)},s.prototype.addSplitsJoins=function(){var n=V1.flatMap(this.nodes,function(b){return b.inputPortVals()}),r=V1.flatMap(this.nodes,function(b){return b.outputPortVals()}),c=n.slice(),u={},d={};n.forEach(function(b){EW(r,c,b,0,b.length,u,d)}),this.nodes=this.nodes.concat(V1.map(d,function(b,w){return lfe.default.fromJoinInfo(w,b)})).concat(V1.map(u,function(b,w){return lfe.default.fromSplitInfo(w,b)}))},s.prototype.createWires=function(){var n=Hsn.default.getProperties(),r={},c={},u={};this.nodes.forEach(function(w){w.collectPortsByDirection(r,c,u,n.genericsLaterals)});var d=S_t(V1.keys(r).concat(V1.keys(c)).concat(V1.keys(u))),b=d.map(function(w){var _=c[w]||[],x=r[w]||[],T=u[w]||[],M={netName:w,drivers:_,riders:x,laterals:T};return _.concat(x).concat(T).forEach(function(L){L.wire=M}),M});this.wires=b},s}();FB.FlatModule=qsn;function Xsn(s){var n="";return s.forEach(function(r){var c=String(r);n===""?n=c:n+=","+c}),","+n+","}FB.arrayToBitstring=Xsn;function E_t(s,n){return n.indexOf(s)>-1}function x_t(s,n){return V1.findIndex(n,function(r){return E_t(s,r)})}function xW(s,n,r){s[n]===void 0?s[n]=[r]:s[n].push(r)}FB.addToDefaultDict=xW;function ufe(s,n,r){var c=V1.max([s.indexOf(n),r]),u=s.substring(0,c).split(",").length-1,d=u+n.split(",").length-3;return u===d?String(u):String(u)+":"+String(d)}function EW(s,n,r,c,u,d,b){var w=n.indexOf(r);if(w!==-1&&n.splice(w,1),!(c>=r.length||u-c<2)){var _=r.slice(c,u);if(E_t(_,s)){_!==r&&xW(b,r,ufe(r,_,c)),EW(s,n,r,u-1,r.length,d,b);return}var x=x_t(_,s);if(x!==-1){_!==r&&xW(b,r,ufe(r,_,c)),xW(d,s[x],ufe(s[x],_,0)),s.push(_),EW(s,n,r,u-1,r.length,d,b);return}if(x_t(_,n)!==-1){_!==r&&xW(b,r,ufe(r,_,c)),EW(s,[],_,0,_.length,d,b),s.push(_);return}EW(s,n,r,c,c+_.slice(0,-1).lastIndexOf(",")+1,d,b)}}function S_t(s){var n={};return s.forEach(function(r){n[r]=!0}),V1.keys(n)}FB.removeDups=S_t});var jIe=Ed(SW=>{"use strict";Object.defineProperty(SW,"__esModule",{value:!0});var T_t=O4(),Vh;(function(s){s.wireNameLookup={},s.dummyNum=0,s.edgeIndex=0})(Vh=SW.ElkModel||(SW.ElkModel={}));function Ysn(s){var n=s.nodes.map(function(c){return c.buildElkChild()});Vh.edgeIndex=0,Vh.dummyNum=0;var r=T_t.flatMap(s.wires,function(c){if(c.drivers.length>0&&c.riders.length>0&&c.laterals.length===0){var u=[];return GIe(c.drivers,c.riders,u),u}else if(c.drivers.concat(c.riders).length>0&&c.laterals.length>0){var u=[];return GIe(c.drivers,c.laterals,u),GIe(c.laterals,c.riders,u),u}else if(c.riders.length===0&&c.drivers.length>1){var d=M_t(n);Vh.dummyNum+=1;var b=c.drivers.map(function(M){var L=M.parentNode.Key,I="e"+String(Vh.edgeIndex);Vh.edgeIndex+=1;var D={id:I,source:L,sourcePort:L+"."+M.key,target:d,targetPort:d+".p"};return Vh.wireNameLookup[I]=M.wire.netName,D});return b}else if(c.riders.length>1&&c.drivers.length===0){var w=M_t(n);Vh.dummyNum+=1;var b=c.riders.map(function(L){var I=L.parentNode.Key,D="e"+String(Vh.edgeIndex);Vh.edgeIndex+=1;var F={id:D,source:w,sourcePort:w+".p",target:I,targetPort:I+"."+L.key};return Vh.wireNameLookup[D]=L.wire.netName,F});return b}else if(c.laterals.length>1){var _=c.laterals[0],x=_.parentNode.Key,T=c.laterals.slice(1).map(function(M){var L=M.parentNode.Key,I="e"+String(Vh.edgeIndex);Vh.edgeIndex+=1;var D={id:I,source:x,sourcePort:x+"."+_.key,target:L,targetPort:L+"."+M.key};return Vh.wireNameLookup[I]=M.wire.netName,D});return T}return[]});return{id:s.moduleName,children:n,edges:r}}SW.buildElkGraph=Ysn;function M_t(s){var n="$d_"+String(Vh.dummyNum),r={id:n,width:0,height:0,ports:[{id:n+".p",width:0,height:0}],layoutOptions:{"org.eclipse.elk.portConstraints":"FIXED_SIDE"}};return s.push(r),n}function GIe(s,n,r){var c=T_t.flatMap(s,function(u){var d=u.parentNode.key,b=d+"."+u.key;return n.map(function(w){var _=w.parentNode.key,x=_+"."+w.key,T="e"+Vh.edgeIndex,M={id:T,sources:[b],targets:[x]};return Vh.wireNameLookup[T]=w.wire.netName,u.parentNode.type!=="$dff"&&(M.layoutOptions={"org.eclipse.elk.layered.priority.direction":10}),Vh.edgeIndex+=1,M})});r.push.apply(r,c)}});var k_t=Ed(zB=>{"use strict";var C_t=zB&&zB.__spreadArrays||function(){for(var s=0,n=0,r=arguments.length;n0?[z.bendPoints[0]]:z.endPoint:z.bendPoints&&z.bendPoints.length>0?[u2.last(z.bendPoints)]:z.startPoint}).map(function(O){return O.x>x.x?UB.Right:O.xx.y?UB.Down:UB.Up}));F.size<3&&d.forEach(function(O){O.junctionPoints&&(O.junctionPoints=O.junctionPoints.filter(function(z){return!u2.isEqual(z,x)}))}),n+=1};n<1e4;){var c=r();if(c==="break")break}}zB.removeDummyEdges=L_t});var O_t=Ed(hfe=>{"use strict";Object.defineProperty(hfe,"__esModule",{value:!0});var Qsn=r_t(),eon=bW(),ton=zIe(),ffe=_W(),I_t=jIe(),R_t=k_t(),D_t=new Qsn;function B_t(s,n){ffe.default.skin=eon.p(s);var r=ffe.default.getProperties(),c=new ton.FlatModule(n);return r.constants!==!1&&c.addConstants(),r.splitsAndJoins!==!1&&c.addSplitsJoins(),c.createWires(),c}function non(s,n,r,c){var u=B_t(s,n),d=I_t.buildElkGraph(u);if(r){c(null,JSON.stringify(d,null,2));return}var b=ffe.default.getProperties(),w=D_t.layout(d,{layoutOptions:b.layoutEngine});w.then(function(_){c(null,JSON.stringify(_,null,2))}).catch(function(_){throw Error(_)})}hfe.dumpLayout=non;function ion(s,n,r,c){var u=B_t(s,n),d=I_t.buildElkGraph(u),b=ffe.default.getProperties(),w;return c?w=new Promise(function(_){R_t.default(c,u),_()}):w=D_t.layout(d,{layoutOptions:b.layoutEngine}).then(function(_){return R_t.default(_,u)}).catch(function(_){console.error(_)}),typeof r=="function"&&w.then(function(_){return r(null,_),_}).catch(function(_){throw Error(_)}),w}hfe.render=ion});function RM(s,n){if(!s)throw new Error(n||"loader assertion failed.")}var Ny={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},IVt=Ny.self||Ny.window||Ny.global||{},DVt=Ny.window||Ny.self||Ny.global||{},BVt=Ny.global||Ny.self||Ny.window||{},OVt=Ny.document||{};var $L=!!(typeof process!="object"||String(process)!=="[object process]"||process.browser);var zut=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),NVt=zut&&parseFloat(zut[1])||0;Hj();var APe="4.5.4",WVt=APe[0]>="0"&&APe[0]<="9"?`v${APe}`:"";function HVt(){let s=new ng({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=s,globalThis.loaders.version=WVt,globalThis.probe||={},globalThis.probe.loaders=s,s}var PPe=HVt();var qVt=s=>typeof s=="boolean",Uy=s=>typeof s=="function",zy=s=>s!==null&&typeof s=="object",Zae=s=>zy(s)&&s.constructor==={}.constructor;var LPe=s=>typeof SharedArrayBuffer<"u"&&s instanceof SharedArrayBuffer,kD=s=>zy(s)&&typeof s.byteLength=="number"&&typeof s.slice=="function";var kPe=s=>!!s&&Uy(s[Symbol.iterator]),RPe=s=>!!s&&Uy(s[Symbol.asyncIterator]);var B1=s=>typeof Response<"u"&&s instanceof Response||zy(s)&&Uy(s.arrayBuffer)&&Uy(s.text)&&Uy(s.json);var O1=s=>typeof Blob<"u"&&s instanceof Blob;var nft=s=>typeof ReadableStream<"u"&&s instanceof ReadableStream||zy(s)&&Uy(s.tee)&&Uy(s.cancel)&&Uy(s.getReader);var ift=s=>zy(s)&&Uy(s.read)&&Uy(s.pipe)&&qVt(s.readable),qj=s=>nft(s)||ift(s);function IPe(s,n){return rft(s||{},n)}function rft(s,n,r=0){if(r>3)return n;let c={...s};for(let[u,d]of Object.entries(n))d&&typeof d=="object"&&!Array.isArray(d)?c[u]=rft(c[u]||{},n[u],r+1):c[u]=n[u];return c}var sft="latest";function XVt(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.5.4"),globalThis._loadersgl_.version}var oft=XVt();function ig(s,n){if(!s)throw new Error(n||"loaders.gl assertion failed.")}var Gy={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},WDn=Gy.self||Gy.window||Gy.global||{},HDn=Gy.window||Gy.self||Gy.global||{},qDn=Gy.global||Gy.self||Gy.window||{},XDn=Gy.document||{};var _b=typeof process!="object"||String(process)!=="[object process]"||process.browser;var cft=typeof window<"u"&&typeof window.orientation<"u",aft=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),YDn=aft&&parseFloat(aft[1])||0;var Xj=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(n,r){this.name=n,this.workerThread=r,this.result=new Promise((c,u)=>{this._resolve=c,this._reject=u})}postMessage(n,r){this.workerThread.postMessage({source:"loaders.gl",type:n,payload:r})}done(n){ig(this.isRunning),this.isRunning=!1,this._resolve(n)}error(n){ig(this.isRunning),this.isRunning=!1,this._reject(n)}};var RD=class{terminate(){}};var DPe=new Map;function lft(s){ig(s.source&&!s.url||!s.source&&s.url);let n=DPe.get(s.source||s.url);return n||(s.url&&(n=YVt(s.url),DPe.set(s.url,n)),s.source&&(n=uft(s.source),DPe.set(s.source,n))),ig(n),n}function YVt(s){if(!s.startsWith("http"))return s;let n=ZVt(s);return uft(n)}function uft(s){let n=new Blob([s],{type:"application/javascript"});return URL.createObjectURL(n)}function ZVt(s){return`try { + importScripts('${s}'); +} catch (error) { + console.error(error); + throw error; +}`}function BPe(s,n=!0,r){let c=r||new Set;if(s){if(fft(s))c.add(s);else if(fft(s.buffer))c.add(s.buffer);else if(!ArrayBuffer.isView(s)){if(n&&typeof s=="object")for(let u in s)BPe(s[u],n,c)}}return r===void 0?Array.from(c):[]}function fft(s){return s?s instanceof ArrayBuffer||typeof MessagePort<"u"&&s instanceof MessagePort||typeof ImageBitmap<"u"&&s instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas:!1}var OPe=()=>{},IM=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&_b||typeof RD<"u"&&!_b}constructor(n){let{name:r,source:c,url:u}=n;ig(c||u),this.name=r,this.source=c,this.url=u,this.onMessage=OPe,this.onError=d=>console.log(d),this.worker=_b?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=OPe,this.onError=OPe,this.worker.terminate(),this.terminated=!0}get isRunning(){return!!this.onMessage}postMessage(n,r){r=r||BPe(n),this.worker.postMessage(n,r)}_getErrorFromErrorEvent(n){let r="Failed to load ";return r+=`worker ${this.name} from ${this.url}. `,n.message&&(r+=`${n.message} in `),n.lineno&&(r+=`:${n.lineno}:${n.colno}`),new Error(r)}_createBrowserWorker(){this._loadableURL=lft({source:this.source,url:this.url});let n=new Worker(this._loadableURL,{name:this.name});return n.onmessage=r=>{r.data?this.onMessage(r.data):this.onError(new Error("No data received"))},n.onerror=r=>{this.onError(this._getErrorFromErrorEvent(r)),this.terminated=!0},n.onmessageerror=r=>console.error(r),n}_createNodeWorker(){let n;if(this.url){let c=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`,u=this.url.endsWith(".ts")||this.url.endsWith(".mjs")?"module":"commonjs";n=new RD(c,{eval:!1,type:u})}else if(this.source)n=new RD(this.source,{eval:!0});else throw new Error("no worker");return n.on("message",r=>{this.onMessage(r)}),n.on("error",r=>{this.onError(r)}),n.on("exit",r=>{}),n}};var Yj=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return IM.isSupported()}constructor(n){this.source=n.source,this.url=n.url,this.setProps(n)}destroy(){this.idleQueue.forEach(n=>n.destroy()),this.isDestroyed=!0}setProps(n){this.props={...this.props,...n},n.name!==void 0&&(this.name=n.name),n.maxConcurrency!==void 0&&(this.maxConcurrency=n.maxConcurrency),n.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=n.maxMobileConcurrency),n.reuseWorkers!==void 0&&(this.reuseWorkers=n.reuseWorkers),n.onDebug!==void 0&&(this.onDebug=n.onDebug)}async startJob(n,r=(u,d,b)=>u.done(b),c=(u,d)=>u.error(d)){let u=new Promise(d=>(this.jobQueue.push({name:n,onMessage:r,onError:c,onStart:d}),this));return this._startQueuedJob(),await u}async _startQueuedJob(){if(!this.jobQueue.length)return;let n=this._getAvailableWorker();if(!n)return;let r=this.jobQueue.shift();if(r){this.onDebug({message:"Starting job",name:r.name,workerThread:n,backlog:this.jobQueue.length});let c=new Xj(r.name,n);n.onMessage=u=>r.onMessage(c,u.type,u.payload),n.onError=u=>r.onError(c,u),r.onStart(c);try{await c.result}catch(u){console.error(`Worker exception: ${u}`)}finally{this.returnWorkerToQueue(n)}}}returnWorkerToQueue(n){!_b||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(n.destroy(),this.count--):this.idleQueue.push(n),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count{}},HL=class s{props;workerPools=new Map;static _workerFarm;static isSupported(){return IM.isSupported()}static getWorkerFarm(n={}){return s._workerFarm=s._workerFarm||new s({}),s._workerFarm.setProps(n),s._workerFarm}constructor(n){this.props={...KVt},this.setProps(n),this.workerPools=new Map}destroy(){for(let n of this.workerPools.values())n.destroy();this.workerPools=new Map}setProps(n){this.props={...this.props,...n};for(let r of this.workerPools.values())r.setProps(this._getWorkerPoolProps())}getWorkerPool(n){let{name:r,source:c,url:u}=n,d=this.workerPools.get(r);return d||(d=new Yj({name:r,source:c,url:u}),d.setProps(this._getWorkerPoolProps()),this.workerPools.set(r,d)),d}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}};function NPe(s,n={}){let r=n[s.id]||{},c=_b?s.workerFile||`${s.id}-worker.js`:`${s.id}-worker-node.js`,u=r.workerUrl;if(!u&&s.id==="compression"&&(u=n.workerUrl),(n._workerType||n?.core?._workerType)==="test"&&(_b?u=`modules/${s.module}/dist/${c}`:u=`modules/${s.module}/src/workers/${s.id}-worker-node.ts`),!u){let b=s.version;b==="latest"&&(b=sft);let w=b?`@${b}`:"";u=`loaders.gl-cdn-disabled/${s.module}${w}/dist/${c}`}return ig(u),u}function FPe(s,n=oft){ig(s,"no worker provided");let r=s.version;return!(!n||!r)}function UPe(s,n){if(!HL.isSupported())return!1;let r=n?._nodeWorkers??n?.core?._nodeWorkers;if(!_b&&!r)return!1;let c=n?.worker??n?.core?.worker;return!!(s.worker&&c)}async function zPe(s,n,r,c,u){let d=s.id,b=NPe(s,r),_=HL.getWorkerFarm(r?.core).getWorkerPool({name:d,url:b});r=JSON.parse(JSON.stringify(r||{})),r._workerLoaderId=s.id,c=JSON.parse(JSON.stringify(c||{}));let x=await _.startJob("process-on-worker",JVt.bind(null,u));return x.postMessage("process",{input:n,options:r,context:c}),await(await x.result).result}async function JVt(s,n,r,c){switch(r){case"done":n.done(c);break;case"error":n.error(new Error(c.error));break;case"process":let{id:u,input:d,options:b}=c;try{let w=await s(d,b);n.postMessage("done",{id:u,result:w})}catch(w){let _=w instanceof Error?w.message:"unknown error";n.postMessage("error",{id:u,error:_})}break;default:console.warn(`parse-with-worker unknown message ${r}`)}}function GPe(s,n,r){if(r=r||s.byteLength,s.byteLengthd instanceof ArrayBuffer?new Uint8Array(d):d),r=n.reduce((d,b)=>d+b.byteLength,0),c=new Uint8Array(r),u=0;for(let d of n)c.set(d,u),u+=d.byteLength;return c.buffer}async function $Pe(s){let n=[];for await(let r of s)n.push(QVt(r));return jPe(...n)}function QVt(s){if(s instanceof ArrayBuffer)return s;if(ArrayBuffer.isView(s)){let{buffer:n,byteOffset:r,byteLength:c}=s;return dft(n,r,c)}return dft(s)}function dft(s,n=0,r=s.byteLength-n){let c=new Uint8Array(s,n,r),u=new Uint8Array(c.length);return u.set(c),u.buffer}var eWt="",gft={};function HPe(s){for(let n in gft)if(s.startsWith(n)){let r=gft[n];s=s.replace(n,r)}return!s.startsWith("http://")&&!s.startsWith("https://")&&(s=`${eWt}${s}`),s}function Jae(s){return s&&typeof s=="object"&&s.isBuffer}function ID(s){if(Jae(s))return s;if(s instanceof ArrayBuffer)return s;if(LPe(s))return Kae(s);if(ArrayBuffer.isView(s)){let n=s.buffer;return s.byteOffset===0&&s.byteLength===s.buffer.byteLength?n:n.slice(s.byteOffset,s.byteOffset+s.byteLength)}if(typeof s=="string"){let n=s;return new TextEncoder().encode(n).buffer}if(s&&typeof s=="object"&&s._toArrayBuffer)return s._toArrayBuffer();throw new Error("toArrayBuffer")}function Jj(s){if(s instanceof ArrayBuffer)return s;if(LPe(s))return Kae(s);let{buffer:n,byteOffset:r,byteLength:c}=s;return n instanceof ArrayBuffer&&r===0&&c===n.byteLength?n:Kae(n,r,c)}function Kae(s,n=0,r=s.byteLength-n){let c=new Uint8Array(s,n,r),u=new Uint8Array(c.length);return u.set(c),u.buffer}function qPe(s){return ArrayBuffer.isView(s)?s:new Uint8Array(s)}var S3={};Oy(S3,{dirname:()=>nWt,filename:()=>tWt,join:()=>iWt,resolve:()=>rWt});function mft(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let s=window.location?.pathname;return s?.slice(0,s.lastIndexOf("/")+1)||""}function tWt(s){let n=s?s.lastIndexOf("/"):-1;return n>=0?s.substr(n+1):s}function nWt(s){let n=s?s.lastIndexOf("/"):-1;return n>=0?s.substr(0,n):""}function iWt(...s){let n="/";return s=s.map((r,c)=>(c&&(r=r.replace(new RegExp(`^${n}`),"")),c!==s.length-1&&(r=r.replace(new RegExp(`${n}$`),"")),r)),s.join(n)}function rWt(...s){let n=[];for(let d=0;d=-1&&!c;d--){let b;d>=0?b=n[d]:(u===void 0&&(u=mft()),b=u),b.length!==0&&(r=`${b}/${r}`,c=b.charCodeAt(0)===Qj)}return r=sWt(r,!c),c?`/${r}`:r.length>0?r:"."}var Qj=47,XPe=46;function sWt(s,n){let r="",c=-1,u=0,d,b=!1;for(let w=0;w<=s.length;++w){if(w2){let _=r.length-1,x=_;for(;x>=0&&r.charCodeAt(x)!==Qj;--x);if(x!==_){r=x===-1?"":r.slice(0,x),c=w,u=0,b=!1;continue}}else if(r.length===2||r.length===1){r="",c=w,u=0,b=!1;continue}}n&&(r.length>0?r+="/..":r="..",b=!0)}else{let _=s.slice(c+1,w);r.length>0?r+=`/${_}`:r=_,b=!1}c=w,u=0}else d===XPe&&u!==-1?++u:u=-1}return r}var Qae=class extends Error{constructor(n,r){super(n),this.reason=r.reason,this.url=r.url,this.response=r.response}reason;url;response};var cWt=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,lWt=/^([-\w.]+\/[-\w.+]+)/;function YPe(s,n){return s.toLowerCase()===n.toLowerCase()}function bft(s){let n=lWt.exec(s);return n?n[1]:s}function ZPe(s){let n=cWt.exec(s);return n?n[1]:""}var wft=/\?.*/;function vft(s){let n=s.match(wft);return n&&n[0]}function DM(s){return s.replace(wft,"")}function _ft(s){if(s.length<50)return s;let n=s.slice(s.length-15);return`${s.substr(0,32)}...${n}`}function XL(s){return B1(s)?s.url:O1(s)?("name"in s?s.name:"")||"":typeof s=="string"?s:""}function DD(s){if(B1(s)){let n=s.headers.get("content-type")||"",r=DM(s.url);return bft(n)||ZPe(r)}return O1(s)?s.type||"":typeof s=="string"?ZPe(s):""}function yft(s){return B1(s)?s.headers["content-length"]||-1:O1(s)?s.size:typeof s=="string"?s.length:s instanceof ArrayBuffer||ArrayBuffer.isView(s)?s.byteLength:-1}async function ece(s){if(B1(s))return s;let n={},r=yft(s);r>=0&&(n["content-length"]=String(r));let c=XL(s),u=DD(s);u&&(n["content-type"]=u);let d=await fWt(s);d&&(n["x-first-bytes"]=d),typeof s=="string"&&(s=new TextEncoder().encode(s));let b=new Response(s,{headers:n});return Object.defineProperty(b,"url",{value:c}),b}async function xft(s){if(!s.ok)throw await uWt(s)}async function uWt(s){let n=_ft(s.url),r=`Failed to fetch resource (${s.status}) ${s.statusText}: ${n}`;r=r.length>100?`${r.slice(0,100)}...`:r;let c={reason:s.statusText,url:s.url,response:s};try{let u=s.headers.get("Content-Type");c.reason=!s.bodyUsed&&u?.includes("application/json")?await s.json():await s.text()}catch{}return new Qae(r,c)}async function fWt(s){if(typeof s=="string")return`data:,${s.slice(0,5)}`;if(s instanceof Blob){let r=s.slice(0,5);return await new Promise(c=>{let u=new FileReader;u.onload=d=>c(d?.target?.result),u.readAsDataURL(r)})}if(s instanceof ArrayBuffer){let r=s.slice(0,5);return`data:base64,${hWt(r)}`}return null}function hWt(s){let n="",r=new Uint8Array(s);for(let c=0;c{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},nce=class{console;constructor(){this.console=console}log(...n){return this.console.log.bind(this.console,...n)}info(...n){return this.console.info.bind(this.console,...n)}warn(...n){return this.console.warn.bind(this.console,...n)}error(...n){return this.console.error.bind(this.console,...n)}};var ice={core:{baseUrl:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new nce,useLocalLibraries:!1,CDN:"loaders.gl-cdn-disabled",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:$L,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]}},Eft={baseUri:"core.baseUrl",fetch:"core.fetch",mimeType:"core.mimeType",fallbackMimeType:"core.fallbackMimeType",ignoreRegisteredLoaders:"core.ignoreRegisteredLoaders",nothrow:"core.nothrow",log:"core.log",useLocalLibraries:"core.useLocalLibraries",CDN:"core.CDN",worker:"core.worker",maxConcurrency:"core.maxConcurrency",maxMobileConcurrency:"core.maxMobileConcurrency",reuseWorkers:"core.reuseWorkers",_nodeWorkers:"core.nodeWorkers",_workerType:"core._workerType",_worker:"core._workerType",limit:"core.limit",_limitMB:"core._limitMB",batchSize:"core.batchSize",batchDebounceMs:"core.batchDebounceMs",metadata:"core.metadata",transforms:"core.transforms",throws:"nothrow",dataType:"(no longer used)",uri:"core.baseUrl",method:"core.fetch.method",headers:"core.fetch.headers",body:"core.fetch.body",mode:"core.fetch.mode",credentials:"core.fetch.credentials",cache:"core.fetch.cache",redirect:"core.fetch.redirect",referrer:"core.fetch.referrer",referrerPolicy:"core.fetch.referrerPolicy",integrity:"core.fetch.integrity",keepalive:"core.fetch.keepalive",signal:"core.fetch.signal"};var JPe=["baseUrl","fetch","mimeType","fallbackMimeType","ignoreRegisteredLoaders","nothrow","log","useLocalLibraries","CDN","worker","maxConcurrency","maxMobileConcurrency","reuseWorkers","_nodeWorkers","_workerType","limit","_limitMB","batchSize","batchDebounceMs","metadata","transforms"];function QPe(){globalThis.loaders=globalThis.loaders||{};let{loaders:s}=globalThis;return s._state||(s._state={}),s._state}function eLe(){let s=QPe();return s.globalOptions=s.globalOptions||{...ice,core:{...ice.core}},M3(s.globalOptions)}function Tft(s,n,r,c){return r=r||[],r=Array.isArray(r)?r:[r],mWt(s,r),M3(wWt(n,s,c))}function M3(s){let n=_Wt(s);Cft(n);for(let r of JPe)n.core&&n.core[r]!==void 0&&delete n[r];return n.core&&n.core._workerType!==void 0&&delete n._worker,n}function mWt(s,n){Sft(s,null,ice,Eft,n);for(let r of n){let c=s&&s[r.id]||{},u=r.options&&r.options[r.id]||{},d=r.deprecatedOptions&&r.deprecatedOptions[r.id]||{};Sft(c,r.id,u,d,n)}}function Sft(s,n,r,c,u){let d=n||"Top level",b=n?`${n}.`:"";for(let w in s){let _=!n&&zy(s[w]),x=w==="baseUri"&&!n,T=w==="workerUrl"&&n;if(!(w in r)&&!x&&!T){if(w in c)e$.level>0&&e$.warn(`${d} loader option '${b}${w}' no longer supported, use '${c[w]}'`)();else if(!_&&e$.level>0){let M=bWt(w,u);e$.warn(`${d} loader option '${b}${w}' not recognized. ${M}`)()}}}}function bWt(s,n){let r=s.toLowerCase(),c="";for(let u of n)for(let d in u.options){if(s===d)return`Did you mean '${u.id}.${d}'?`;let b=d.toLowerCase();(r.startsWith(b)||b.startsWith(r))&&(c=c||`Did you mean '${u.id}.${d}'?`)}return c}function wWt(s,n,r){let c=s.options||{},u={...c};c.core&&(u.core={...c.core}),Cft(u),u.core?.log===null&&(u.core={...u.core,log:new tce}),Mft(u,M3(eLe()));let d=M3(n);return Mft(u,d),vWt(u,r),yWt(u),u}function Mft(s,n){for(let r in n)if(r in n){let c=n[r];Zae(c)&&Zae(s[r])?s[r]={...s[r],...n[r]}:s[r]=n[r]}}function vWt(s,n){if(!n)return;s.core?.baseUrl!==void 0||(s.core||={},s.core.baseUrl=S3.dirname(DM(n)))}function _Wt(s){let n={...s};return s.core&&(n.core={...s.core}),n}function Cft(s){s.baseUri!==void 0&&(s.core||={},s.core.baseUrl===void 0&&(s.core.baseUrl=s.baseUri));for(let r of JPe)if(s[r]!==void 0){let u=s.core=s.core||{};u[r]===void 0&&(u[r]=s[r])}let n=s._worker;n!==void 0&&(s.core||={},s.core._workerType===void 0&&(s.core._workerType=n))}function yWt(s){let n=s.core;if(n)for(let r of JPe)n[r]!==void 0&&(s[r]=n[r])}function t$(s){return s?(Array.isArray(s)&&(s=s[0]),Array.isArray(s?.extensions)):!1}function n$(s){RM(s,"null loader"),RM(t$(s),"invalid loader");let n;return Array.isArray(s)&&(n=s[1],s=s[0],s={...s,options:{...s.options,...n}}),(s?.parseTextSync||s?.parseText)&&(s.text=!0),s.text||(s.binary=!0),s}var Aft=()=>{let s=QPe();return s.loaderRegistry=s.loaderRegistry||[],s.loaderRegistry};function tLe(s){let n=Aft();s=Array.isArray(s)?s:[s];for(let r of s){let c=n$(r);n.find(u=>c===u)||n.unshift(c)}}function Pft(){return Aft()}var xWt=/\.([^.]+)$/;async function Rft(s,n=[],r,c){if(!Ift(s))return null;let u=M3(r||{});if(u.core||={},s instanceof Response&&Lft(s)){let b=await s.clone().text(),w=rce(b,n,{...u,core:{...u.core,nothrow:!0}},c);if(w)return w}let d=rce(s,n,{...u,core:{...u.core,nothrow:!0}},c);if(d)return d;if(O1(s)&&(s=await s.slice(0,10).arrayBuffer(),d=rce(s,n,u,c)),!d&&s instanceof Response&&Lft(s)){let b=await s.clone().text();d=rce(b,n,u,c)}if(!d&&!u.core.nothrow)throw new Error(Dft(s));return d}function Lft(s){let n=DD(s);return!!(n&&(n.startsWith("text/")||n==="application/json"||n.endsWith("+json")))}function rce(s,n=[],r,c){if(!Ift(s))return null;let u=M3(r||{});if(u.core||={},n&&!Array.isArray(n))return n$(n);let d=[];n&&(d=d.concat(n)),u.core.ignoreRegisteredLoaders||d.push(...Pft()),SWt(d);let b=EWt(s,d,u,c);if(!b&&!u.core.nothrow)throw new Error(Dft(s));return b}function EWt(s,n,r,c){let u=XL(s),d=DD(s),b=DM(u)||c?.url,w=null,_="";return r?.core?.mimeType&&(w=nLe(n,r?.core?.mimeType),_=`match forced by supplied MIME type ${r?.core?.mimeType}`),w=w||MWt(n,b),_=_||(w?`matched url ${b}`:""),w=w||nLe(n,d),_=_||(w?`matched MIME type ${d}`:""),w=w||CWt(n,s),_=_||(w?`matched initial data ${Bft(s)}`:""),r?.core?.fallbackMimeType&&(w=w||nLe(n,r?.core?.fallbackMimeType),_=_||(w?`matched fallback MIME type ${d}`:"")),_&&PPe.log(1,`selectLoader selected ${w?.name}: ${_}.`),w}function Ift(s){return!(s instanceof Response&&s.status===204)}function Dft(s){let n=XL(s),r=DD(s),c="No valid loader found (";c+=n?`${S3.filename(n)}, `:"no url provided, ",c+=`MIME type: ${r?`"${r}"`:"not provided"}, `;let u=s?Bft(s):"";return c+=u?` first bytes: "${u}"`:"first bytes: not available",c+=")",c}function SWt(s){for(let n of s)n$(n)}function MWt(s,n){let r=n&&xWt.exec(n),c=r&&r[1];return c?TWt(s,c):null}function TWt(s,n){n=n.toLowerCase();for(let r of s)for(let c of r.extensions)if(c.toLowerCase()===n)return r;return null}function nLe(s,n){for(let r of s)if(r.mimeTypes?.some(c=>YPe(n,c))||YPe(n,`application/x.${r.id}`))return r;return null}function CWt(s,n){if(!n)return null;for(let r of s)if(typeof n=="string"){if(AWt(n,r))return r}else if(ArrayBuffer.isView(n)){if(kft(n.buffer,n.byteOffset,r))return r}else if(n instanceof ArrayBuffer&&kft(n,0,r))return r;return null}function AWt(s,n){return n.testText?n.testText(s):(Array.isArray(n.tests)?n.tests:[n.tests]).some(c=>s.startsWith(c))}function kft(s,n,r){return(Array.isArray(r.tests)?r.tests:[r.tests]).some(u=>PWt(s,n,r,u))}function PWt(s,n,r,c){if(kD(c))return GPe(c,s,c.byteLength);switch(typeof c){case"function":return c(Jj(s));case"string":let u=iLe(s,n,c.length);return c===u;default:return!1}}function Bft(s,n=5){return typeof s=="string"?s.slice(0,n):ArrayBuffer.isView(s)?iLe(s.buffer,s.byteOffset,n):s instanceof ArrayBuffer?iLe(s,0,n):""}function iLe(s,n,r){if(s.byteLengthKPe(d,u):n?.fetch?n?.fetch:KPe}function jft(s,n,r){if(r)return r;let c={fetch:sce(n,s),...s};if(c.url){let u=DM(c.url);c.baseUrl=u,c.queryString=vft(c.url),c.filename=S3.filename(u),c.baseUrl=S3.dirname(u)}return Array.isArray(c.loaders)||(c.loaders=null),c}function $ft(s,n){if(s&&!Array.isArray(s))return s;let r;if(s&&(r=Array.isArray(s)?s:[s]),n&&n.loaders){let c=Array.isArray(n.loaders)?n.loaders:[n.loaders];r=r?[...r,...c]:c}return r&&r.length?r:void 0}async function i$(s,n,r,c){n&&!Array.isArray(n)&&!t$(n)&&(c=void 0,r=n,n=void 0),s=await s,r=r||{};let u=XL(s),b=$ft(n,c),w=await Rft(s,b,r);if(!w)return null;let _=Tft(r,w,b,u);return c=jft({url:u,_parse:i$,loaders:b},_,c||null),await DWt(w,s,_,c)}async function DWt(s,n,r,c){if(FPe(s),r=IPe(s.options,r),B1(n)){let{ok:d,redirected:b,status:w,statusText:_,type:x,url:T}=n,M=Object.fromEntries(n.headers.entries());c.response={headers:M,ok:d,redirected:b,status:w,statusText:_,type:x,url:T}}n=await Gft(n,s,r);let u=s;if(u.parseTextSync&&typeof n=="string")return u.parseTextSync(n,r,c);if(UPe(s,r))return await zPe(s,n,r,c,i$);if(u.parseText&&typeof n=="string")return await u.parseText(n,r,c);if(u.parse)return await u.parse(n,r,c);throw ig(!u.parseSync),new Error(`${s.id} loader - no parser found and worker is disabled`)}async function BD(s,n,r,c){let u,d;!Array.isArray(n)&&!t$(n)?(u=[],d=n,c=void 0):(u=n,d=r);let b=sce(d),w=s;return typeof s=="string"&&(w=await b(s)),O1(s)&&(w=await b(s)),typeof s=="string"&&(M3(d||{}).core?.baseUrl||(d={...d,core:{...d?.core,baseUrl:s}})),Array.isArray(u)?await i$(w,u,d):await i$(w,u,d)}var qft="4.5.4";var BWt=globalThis.loaders?.parseImageNode,oLe=typeof Image<"u",aLe=typeof ImageBitmap<"u",OWt=!!BWt,cLe=$L?!0:OWt;function Xft(s){switch(s){case"auto":return aLe||oLe||cLe;case"imagebitmap":return aLe;case"image":return oLe;case"data":return cLe;default:throw new Error(`@loaders.gl/images: image ${s} not supported in this environment`)}}function Yft(){if(aLe)return"imagebitmap";if(oLe)return"image";if(cLe)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function NWt(s){let n=FWt(s);if(!n)throw new Error("Not an image");return n}function Zft(s){switch(NWt(s)){case"data":return s;case"image":case"imagebitmap":let n=document.createElement("canvas"),r=n.getContext("2d");if(!r)throw new Error("getImageData");return n.width=s.width,n.height=s.height,r.drawImage(s,0,0),r.getImageData(0,0,s.width,s.height);default:throw new Error("getImageData")}}function FWt(s){return typeof ImageBitmap<"u"&&s instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&s instanceof Image?"image":s&&typeof s=="object"&&s.data&&s.width&&s.height?"data":null}var UWt=/^data:image\/svg\+xml/,zWt=/\.svg((\?|#).*)?$/;function oce(s){return s&&(UWt.test(s)||zWt.test(s))}function Kft(s,n){if(oce(n)){let c=new TextDecoder().decode(s);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(c=unescape(encodeURIComponent(c)))}catch(d){throw new Error(d.message)}return`data:image/svg+xml;base64,${btoa(c)}`}return lLe(s,n)}function lLe(s,n){if(oce(n))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(s)])}async function ace(s,n,r){let c=Kft(s,r),u=self.URL||self.webkitURL,d=typeof c!="string"&&u.createObjectURL(c);try{return await GWt(d||c,n)}finally{d&&u.revokeObjectURL(d)}}async function GWt(s,n){let r=new Image;return r.src=s,n.image&&n.image.decode&&r.decode?(await r.decode(),r):await new Promise((c,u)=>{try{r.onload=()=>c(r),r.onerror=d=>{let b=d instanceof Error?d.message:"error";u(new Error(b))}}catch(d){u(d)}})}var Jft=!0;async function Qft(s,n,r){let c;oce(r)?c=await ace(s,n,r):c=lLe(s,r);let u=n&&n.imagebitmap;return await jWt(c,u)}async function jWt(s,n=null){if(($Wt(n)||!Jft)&&(n=null),n)try{return await createImageBitmap(s,n)}catch(r){console.warn(r),Jft=!1}return await createImageBitmap(s)}function $Wt(s){if(!s)return!0;for(let n in s)if(Object.prototype.hasOwnProperty.call(s,n))return!1;return!0}function eht(s){return!qWt(s,"ftyp",4)||!(s[8]&96)?null:VWt(s)}function VWt(s){switch(WWt(s,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function WWt(s,n,r){return String.fromCharCode(...s.slice(n,r))}function HWt(s){return[...s].map(n=>n.charCodeAt(0))}function qWt(s,n,r=0){let c=HWt(n);for(let u=0;u=24&&n.getUint32(0,jy)===2303741511?{mimeType:"image/png",width:n.getUint32(16,jy),height:n.getUint32(20,jy)}:null}function ZWt(s){let n=o$(s);return n.byteLength>=10&&n.getUint32(0,jy)===1195984440?{mimeType:"image/gif",width:n.getUint16(6,s$),height:n.getUint16(8,s$)}:null}function KWt(s){let n=o$(s);return n.byteLength>=14&&n.getUint16(0,jy)===16973&&n.getUint32(2,s$)===n.byteLength?{mimeType:"image/bmp",width:n.getUint32(18,s$),height:n.getUint32(22,s$)}:null}function JWt(s){let n=o$(s);if(!(n.byteLength>=3&&n.getUint16(0,jy)===65496&&n.getUint8(2)===255))return null;let{tableMarkers:c,sofMarkers:u}=QWt(),d=2;for(;d+9!!cce(new DataView(s))],options:iHt};Hj();var rHt=new ng({id:"deck"}),Bs=rHt;var fLe={};function iht(s){fLe=s}function If(s,n,r,c){Bs.level>0&&fLe[s]&&fLe[s].call(null,n,r,c)}function sHt(s){let n=s[0],r=s[s.length-1];return n==="{"&&r==="}"||n==="["&&r==="]"}var rht={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:sHt,parseTextSync:JSON.parse};function oHt(){let s="9.4.0",n=globalThis.deck&&globalThis.deck.VERSION;if(n&&n!==s)throw new Error(`deck.gl - multiple versions detected: ${n} vs ${s}`);return n||(Bs.log(1,`deck.gl ${s}`)(),globalThis.deck={...globalThis.deck,VERSION:s,version:s,log:Bs,_registerLoggers:iht},tLe([rht,[uLe,{imagebitmap:{premultiplyAlpha:"none"}}]])),s}var sht=oHt();vm();var iJt=`struct LayerUniforms { + opacity: f32, +}; + +@group(0) @binding(auto) +var layer: LayerUniforms; +`,jgt=`layout(std140) uniform layerUniforms { + uniform float opacity; +} layer; +`,fke={name:"layer",source:iJt,vs:jgt,fs:jgt,getUniforms:s=>({opacity:Math.pow(s.opacity,.45454545454545453)}),uniformTypes:{opacity:"f32"}};var rJt=` + +@must_use +fn deckgl_premultiplied_alpha(fragColor: vec4) -> vec4 { + return vec4(fragColor.rgb * fragColor.a, fragColor.a); +}; +`,qy={name:"color",dependencies:[],source:rJt,getUniforms:s=>({})};var sJt=`const SMOOTH_EDGE_RADIUS: f32 = 0.5; + +struct VertexGeometry { + position: vec4, + worldPosition: vec3, + worldPositionAlt: vec3, + normal: vec3, + uv: vec2, + pickingColor: vec3, +}; + +var geometry_: VertexGeometry = VertexGeometry( + vec4(0.0, 0.0, 1.0, 0.0), + vec3(0.0, 0.0, 0.0), + vec3(0.0, 0.0, 0.0), + vec3(0.0, 0.0, 0.0), + vec2(0.0, 0.0), + vec3(0.0, 0.0, 0.0) +); + +struct FragmentGeometry { + uv: vec2, +}; + +var fragmentGeometry: FragmentGeometry; + +fn smoothedge(edge: f32, x: f32) -> f32 { + return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x); +} +`,$gt="#define SMOOTH_EDGE_RADIUS 0.5",oJt=`${$gt} + +struct VertexGeometry { + vec4 position; + vec3 worldPosition; + vec3 worldPositionAlt; + vec3 normal; + vec2 uv; + vec3 pickingColor; +} geometry = VertexGeometry( + vec4(0.0, 0.0, 1.0, 0.0), + vec3(0.0), + vec3(0.0), + vec3(0.0), + vec2(0.0), + vec3(0.0) +); +`,aJt=`${$gt} + +struct FragmentGeometry { + vec2 uv; +}; +FragmentGeometry geometry; + +float smoothedge(float edge, float x) { + return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x); +} +`,ile={name:"geometry",source:sJt,vs:oJt,fs:aJt};vm();Bf();var is;(function(s){s[s.Start=1]="Start",s[s.Move=2]="Move",s[s.End=4]="End",s[s.Cancel=8]="Cancel"})(is||(is={}));var Kl;(function(s){s[s.None=0]="None",s[s.Left=1]="Left",s[s.Right=2]="Right",s[s.Up=4]="Up",s[s.Down=8]="Down",s[s.Horizontal=3]="Horizontal",s[s.Vertical=12]="Vertical",s[s.All=15]="All"})(Kl||(Kl={}));var Wi;(function(s){s[s.Possible=1]="Possible",s[s.Began=2]="Began",s[s.Changed=4]="Changed",s[s.Ended=8]="Ended",s[s.Recognized=8]="Recognized",s[s.Cancelled=16]="Cancelled",s[s.Failed=32]="Failed"})(Wi||(Wi={}));var Vgt="compute",hke="auto",g4="manipulation",m4="none",U$="pan-x",z$="pan-y";function dke(s){if(s.includes(m4))return m4;let n=s.includes(U$),r=s.includes(z$);return n&&r?m4:n||r?n?U$:z$:s.includes(g4)?g4:hke}var G$=class{constructor(n,r){this.actions="",this.manager=n,this.set(r)}set(n){n===Vgt&&(n=this.compute()),this.manager.element&&(this.manager.element.style.touchAction=n,this.actions=n)}update(){this.set(this.manager.options.touchAction)}compute(){let n=[];for(let r of this.manager.recognizers)r.options.enable&&(n=n.concat(r.getTouchAction()));return dke(n.join(" "))}};function KD(s){return s.trim().split(/\s+/g)}function rle(s,n,r){if(s)for(let c of KD(n))s.addEventListener(c,r,!1)}function sle(s,n,r){if(s)for(let c of KD(n))s.removeEventListener(c,r,!1)}function pke(s){return(s.ownerDocument||s).defaultView}function gke(s,n){let r=s;for(;r;){if(r===n)return!0;r=r.parentNode}return!1}function ole(s){let n=s.length;if(n===1)return{x:Math.round(s[0].clientX),y:Math.round(s[0].clientY)};let r=0,c=0,u=0;for(;u=Math.abs(n)?s<0?Kl.Left:Kl.Right:n<0?Kl.Up:Kl.Down}function Hgt(s,n){let r=n.center,c=s.offsetDelta,u=s.prevDelta,d=s.prevInput;return(n.eventType===is.Start||d?.eventType===is.End)&&(u=s.prevDelta={x:d?.deltaX||0,y:d?.deltaY||0},c=s.offsetDelta={x:r.x,y:r.y}),{deltaX:u.x+(r.x-c.x),deltaY:u.y+(r.y-c.y)}}function ale(s,n,r){return{x:n/s||0,y:r/s||0}}function qgt(s,n){return j$(n[0],n[1])/j$(s[0],s[1])}function Xgt(s,n){return bke(n[1],n[0])-bke(s[1],s[0])}function Ygt(s,n){let r=s.lastInterval||n,c=n.timeStamp-r.timeStamp,u,d,b,w;if(n.eventType!==is.Cancel&&(c>25||r.velocity===void 0)){let _=n.deltaX-r.deltaX,x=n.deltaY-r.deltaY,T=ale(c,_,x);d=T.x,b=T.y,u=Math.abs(T.x)>Math.abs(T.y)?T.x:T.y,w=QD(_,x),s.lastInterval=n}else u=r.velocity,d=r.velocityX,b=r.velocityY,w=r.direction;n.velocity=u,n.velocityX=d,n.velocityY=b,n.direction=w}function wke(s,n){return"pointerId"in s?s.pointerId:n}function Zgt(s,n){s.movementOrigin=new Map(n.map((r,c)=>[wke(r,c),{clientX:r.clientX,clientY:r.clientY}])),s.firstMovementTime=void 0}function lJt(s,n){let r=n.pointers.map(wke);if(s.movementOrigin?.size===r.length&&r.every(u=>s.movementOrigin.has(u))||Zgt(s,n.pointers),n.distancePerPointer=n.pointers.map((u,d)=>j$(s.movementOrigin.get(r[d]),u)),n.eventType&is.Move&&n.distancePerPointer.some(u=>u>0)&&(s.firstMovementTime??(s.firstMovementTime=n.timeStamp)),n.movementDeltaTime=s.firstMovementTime===void 0?0:n.timeStamp-s.firstMovementTime,n.eventType&(is.End|is.Cancel)){let u=n.changedPointers.map(d=>wke(d,n.pointers.indexOf(d)));Zgt(s,n.pointers.filter((d,b)=>!u.includes(r[b])))}}function Kgt(s,n){let{session:r}=s,{pointers:c}=n,{length:u}=c;r.firstInput||(r.firstInput=mke(n)),u>1&&!r.firstMultiple?r.firstMultiple=mke(n):u===1&&(r.firstMultiple=!1);let{firstInput:d,firstMultiple:b}=r,w=b?b.center:d.center,_=n.center=ole(c);n.timeStamp=Date.now(),n.deltaTime=n.timeStamp-d.timeStamp,lJt(r,n),n.angle=Wgt(w,_),n.distance=JD(w,_);let{deltaX:x,deltaY:T}=Hgt(r,n);n.deltaX=x,n.deltaY=T,n.offsetDirection=QD(n.deltaX,n.deltaY);let M=ale(n.deltaTime,n.deltaX,n.deltaY);n.overallVelocityX=M.x,n.overallVelocityY=M.y,n.overallVelocity=Math.abs(M.x)>Math.abs(M.y)?M.x:M.y,n.scale=b?qgt(b.pointers,c):1,n.rotation=b?Xgt(b.pointers,c):0,n.maxPointers=r.prevInput?n.pointers.length>r.prevInput.maxPointers?n.pointers.length:r.prevInput.maxPointers:n.pointers.length;let L=s.element;return gke(n.srcEvent.target,L)&&(L=n.srcEvent.target),n.target=L,Ygt(r,n),n}function Jgt(s,n,r){let c=r.pointers.length,u=r.changedPointers.length,d=n&is.Start&&c-u===0,b=n&(is.End|is.Cancel)&&c-u===0;r.isFirst=!!d,r.isFinal=!!b,d&&(s.session={}),r.eventType=n;let w=Kgt(s,r);s.emit("hammer.input",w),s.recognize(w),s.session.prevInput=w}var $$=class{constructor(n){this.evEl="",this.evWin="",this.evTarget="",this.domHandler=r=>{this.manager.options.enable&&this.handler(r)},this.manager=n,this.element=n.element,this.target=n.options.inputTarget||n.element}callback(n,r){Jgt(this.manager,n,r)}init(){rle(this.element,this.evEl,this.domHandler),rle(this.target,this.evTarget,this.domHandler),rle(pke(this.element),this.evWin,this.domHandler)}destroy(){sle(this.element,this.evEl,this.domHandler),sle(this.target,this.evTarget,this.domHandler),sle(pke(this.element),this.evWin,this.domHandler)}};var uJt={pointerdown:is.Start,pointermove:is.Move,pointerup:is.End,pointercancel:is.Cancel,pointerout:is.Cancel},fJt="pointerdown",hJt="pointermove pointerup pointercancel",V$=class extends $${constructor(n){super(n),this.evEl=fJt,this.evWin=hJt,this.store=this.manager.session.pointerEvents=[],this.init()}handler(n){let{store:r}=this,c=!1,u=uJt[n.type],d=n.pointerType,b=d==="touch",w=r.findIndex(_=>_.pointerId===n.pointerId);u&is.Start&&(n.buttons||b)?w<0&&(r.push(n),w=r.length-1):u&(is.End|is.Cancel)&&(c=!0),!(w<0)&&(r[w]=n,this.callback(u,{pointers:r,changedPointers:[n],eventType:u,pointerType:d,srcEvent:n}),c&&r.splice(w,1))}};var dJt=["","webkit","Moz","MS","ms","o"];function Qgt(s,n){let r=n[0].toUpperCase()+n.slice(1);for(let c of dJt){let u=c?c+r:n;if(u in s)return u}}var pJt=1,emt=2,tmt={touchAction:"compute",enable:!0,inputTarget:null,cssProps:{userSelect:"none",userDrag:"none",touchCallout:"none",tapHighlightColor:"rgba(0,0,0,0)"}},W$=class{constructor(n,r){this.options={...tmt,...r,cssProps:{...tmt.cssProps,...r.cssProps},inputTarget:r.inputTarget||n},this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=n,this.input=new V$(this),this.touchAction=new G$(this,this.options.touchAction),this.toggleCssProps(!0)}set(n){return Object.assign(this.options,n),n.touchAction&&this.touchAction.update(),n.inputTarget&&(this.input.destroy(),this.input.target=n.inputTarget,this.input.init()),this}stop(n){this.session.stopped=n?emt:pJt}recognize(n){let{session:r}=this;if(r.stopped)return;this.session.prevented&&n.srcEvent.preventDefault();let c,{recognizers:u}=this,{curRecognizer:d}=r;(!d||d&&d.state&Wi.Recognized)&&(d=r.curRecognizer=null);let b=0;for(;b-1&&this.requireFail.splice(c,1)}return this}hasRequireFailures(){return!!this.requireFail.find(n=>n.options.enable)}canRecognizeWith(n){return!!this.simultaneous[n.id]}emit(n){if(!n)return;let{state:r}=this;r=Wi.Ended&&this.manager.emit(this.options.event+vke(r),n)}tryEmit(n){this.canEmit()?this.emit(n):this.state=Wi.Failed}canEmit(){let n=0;for(;n=n.distance)&&(n.distancePerPointer===void 0||s.distancePerPointer.length>0&&s.distancePerPointer.every(r=>r>=n.distancePerPointer))&&(n.movementDeltaTime===void 0||s.movementDeltaTime>=n.movementDeltaTime)&&(n.rotation===void 0||mJt(s.rotation)>=n.rotation)&&(n.scale===void 0||Math.abs(s.scale-1)>=n.scale)}var b4=class extends cv{attrTest(n){let r=this.options.pointers;return r===0||n.pointers.length===r}coherentTest(n){let r=this.options.coherent;return!r?.length||r.some(c=>bJt(n,c))}process(n){let{state:r}=this,{eventType:c}=n,u=r&(Wi.Began|Wi.Changed),d=this.attrTest(n);return u&&(c&is.Cancel||!d)?r|Wi.Cancelled:u||d?c&is.End?r|Wi.Ended:r&Wi.Began?r|Wi.Changed:Wi.Began:Wi.Failed}};var wJt=["","start","move","end","cancel"],eB=class extends cv{constructor(n={}){super({enable:!0,event:"doubleclickdrag",pointers:1,interval:500,time:350,threshold:28,dragThreshold:1,pixelsPerScale:120,...n}),this._tapStart=null,this._lastTap=null,this._drag=null,this._emittedStart=!1}getTouchAction(){return[g4]}getEventNames(){return wJt.map(n=>this.options.event+n)}process(n){let{options:r}=this;return n.pointers.length===r.pointers?n.eventType&is.Start?this._handleStart(n):n.eventType&is.Move?this._handleMove(n):n.eventType&is.Cancel?this._handleEnd(n,!0):n.eventType&is.End?this._handleEnd(n,!1):Wi.Failed:(this.reset(),Wi.Failed)}reset(){this._tapStart=null,this._lastTap=null,this._drag=null,this._emittedStart=!1}emit(n){if(n){if(this.state===Wi.Began){if(!this._drag?.active||this._emittedStart)return;this._emittedStart=!0,this.manager.emit(`${this.options.event}start`,n),this.manager.emit(this.options.event,n);return}if(this.state===Wi.Changed){if(!this._emittedStart)return;this.manager.emit(`${this.options.event}move`,n),this.manager.emit(this.options.event,n);return}if(this.state===Wi.Ended){if(!this._emittedStart)return;this.manager.emit(this.options.event,n),this.manager.emit(`${this.options.event}end`,n),this._emittedStart=!1;return}if(this.state===Wi.Cancelled){if(!this._emittedStart)return;this.manager.emit(this.options.event,n),this.manager.emit(`${this.options.event}cancel`,n),this._emittedStart=!1}}}_handleStart(n){let r=this._getPointerId(n);return this._lastTap&&this._isTapMatch(n,this._lastTap)?(this._tapStart=null,this._lastTap=null,this._drag={startCenter:n.center,pointerId:r,active:!1},this._emittedStart=!1,Wi.Began):(this._tapStart={center:n.center,timeStamp:n.timeStamp,pointerId:r},this._lastTap=null,this._drag=null,this._emittedStart=!1,Wi.Failed)}_handleMove(n){if(!this._drag||!this._isSamePointer(n,this._drag.pointerId))return Wi.Failed;let r=this._drag.startCenter.y-n.center.y;return!this._drag.active&&Math.abs(r){this.state=Wi.Recognized,this.tryEmit(this._input)},r.interval),Wi.Began):Wi.Recognized}return Wi.Failed}failTimeout(){return this._timer=setTimeout(()=>{this.state=Wi.Failed},this.options.interval),Wi.Failed}reset(){clearTimeout(this._timer)}emit(n){this.state===Wi.Recognized&&(n.tapCount=this.count,this.manager.emit(this.options.event,n))}};var tB=class extends b4{constructor(){super(...arguments),this.wheelSession=null,this.wheelSessionUnsubscribe=null,this.handleWheelSessionEvent=n=>{n.device==="trackpad"&&this.handleTrackpadEvent(n)}}set(n){let{wheelSession:r,...c}=n;return r&&r!==this.wheelSession&&(this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=null,this.wheelSession=r),super.set(c),this.updateWheelSessionSubscription(),this}getTrackpadInput(n,r={}){let{srcEvent:c}=n,u=r.deltaX??n.deltaX,d=r.deltaY??n.deltaY,b=QD(u,d),w=Math.sqrt(n.deltaX*n.deltaX+n.deltaY*n.deltaY),_=c;return{pointers:[_,_],changedPointers:[_,_],pointerType:"trackpad",srcEvent:_,eventType:n.eventType,timeStamp:n.timeStamp,deltaTime:n.deltaTime,center:n.center,deltaX:u,deltaY:d,angle:Math.atan2(d,u)*180/Math.PI,distance:Math.sqrt(u*u+d*d),distancePerPointer:[w,w],movementDeltaTime:n.deltaTime,scale:1,rotation:0,direction:b,offsetDirection:b,velocity:n.velocity,velocityX:n.velocityX,velocityY:n.velocityY,overallVelocity:n.overallVelocity,overallVelocityX:n.overallVelocityX,overallVelocityY:n.overallVelocityY,maxPointers:2,target:c.target||this.manager.element,additionalEvent:"",...r}}updateWheelSessionSubscription(){let n=!!(this.wheelSession&&this.options.enable&&this.options.trackpad&&this.options.pointers===2);n&&!this.wheelSessionUnsubscribe?this.wheelSessionUnsubscribe=this.wheelSession.on(this.handleWheelSessionEvent):!n&&this.wheelSessionUnsubscribe&&(this.wheelSessionUnsubscribe(),this.wheelSessionUnsubscribe=null)}};var vJt=["","start","move","end","cancel","up","down","left","right"],VM=class extends tB{constructor(n={}){super({enable:!0,pointers:1,event:"pan",threshold:10,direction:Kl.All,trackpad:!1,coherent:[],...n}),this.trackpadGesture=!1,this.pX=null,this.pY=null}getTouchAction(){let{options:{direction:n}}=this,r=[];return n&Kl.Horizontal&&r.push(z$),n&Kl.Vertical&&r.push(U$),r}getEventNames(){return vJt.map(n=>this.options.event+n)}directionTest(n){let{options:r}=this,c=!0,{distance:u}=n,{direction:d}=n,b=n.deltaX,w=n.deltaY;return d&r.direction||(r.direction&Kl.Horizontal?(d=b===0?Kl.None:b<0?Kl.Left:Kl.Right,c=b!==this.pX,u=Math.abs(n.deltaX)):(d=w===0?Kl.None:w<0?Kl.Up:Kl.Down,c=w!==this.pY,u=Math.abs(n.deltaY))),n.direction=d,c&&u>r.threshold&&!!(d&r.direction)}attrTest(n){let r=!!(this.state&Wi.Began),c=!(this.options.coherent?.length&&n.eventType&(is.End|is.Cancel));return super.attrTest(n)&&(r||c&&this.coherentTest(n)&&this.directionTest(n))}emit(n){this.pX=n.deltaX,this.pY=n.deltaY;let r=Kl[n.direction].toLowerCase();r&&(n.additionalEvent=this.options.event+r),super.emit(n)}handleTrackpadEvent(n){n.isFirst&&(this.trackpadGesture=!n.srcEvent.ctrlKey,!this.trackpadGesture&&this.state&(Wi.Recognized|Wi.Cancelled|Wi.Failed)&&(this.state=Wi.Possible)),this.trackpadGesture&&(this.recognize(this.getTrackpadInput(n,{deltaX:-n.deltaX,deltaY:-n.deltaY,velocity:-n.velocity,velocityX:-n.velocityX,velocityY:-n.velocityY,overallVelocity:-n.overallVelocity,overallVelocityX:-n.overallVelocityX,overallVelocityY:-n.overallVelocityY})),n.isFinal&&(this.trackpadGesture=!1))}};var _Jt=["","start","move","end","cancel","in","out"],nB=class extends tB{constructor(n={}){super({enable:!0,event:"pinch",threshold:0,pointers:2,trackpad:!1,coherent:[],...n}),this.trackpadGesture=!1}getTouchAction(){return[m4]}getEventNames(){return _Jt.map(n=>this.options.event+n)}attrTest(n){let r=!!this.options.coherent?.length,c=!!(this.state&Wi.Began),u=!(r&&n.eventType&(is.End|is.Cancel));return super.attrTest(n)&&(c||u&&(r?this.coherentTest(n):Math.abs(n.scale-1)>this.options.threshold))}emit(n){if(n.scale!==1){let r=n.scale<1?"in":"out";n.additionalEvent=this.options.event+r}super.emit(n)}handleTrackpadEvent(n){n.isFirst&&(this.trackpadGesture=n.srcEvent.ctrlKey,!this.trackpadGesture&&this.state&(Wi.Recognized|Wi.Cancelled|Wi.Failed)&&(this.state=Wi.Possible)),this.trackpadGesture&&(this.recognize(this.getTrackpadInput(n,{deltaX:0,deltaY:0,velocity:0,velocityX:0,velocityY:0,overallVelocity:0,overallVelocityX:0,overallVelocityY:0,scale:Math.exp(-n.deltaY/100)})),n.isFinal&&(this.trackpadGesture=!1))}};var Xy=class{constructor(n,r,c){this.element=n,this.callback=r,this.options=c}listen(n,r){r?this.element.addEventListener(n,this.handleEvent,{passive:!1}):this.element.removeEventListener(n,this.handleEvent)}};var imt=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"";var SJt=imt.indexOf("firefox")!==-1,MJt=40,TJt=.25,cle=class extends Xy{constructor(n,r,c){c.enable=c.enable??!1,super(n,r,c),this.handleEvent=u=>{if(!this.options.enable)return;let d=u.deltaY;globalThis.WheelEvent&&(SJt&&u.deltaMode===globalThis.WheelEvent.DOM_DELTA_PIXEL&&(d/=globalThis.devicePixelRatio),u.deltaMode===globalThis.WheelEvent.DOM_DELTA_LINE&&(d*=MJt)),u.shiftKey&&d&&(d=d*TJt),this.callback({type:"wheel",center:{x:u.clientX,y:u.clientY},delta:-d,device:this.options.wheelSession?.device??"unknown",srcEvent:u,pointerType:"mouse",target:u.target})},c.enable&&(this.wheelSessionUnsubscribe=this.options.wheelSession?.on(()=>{}),this.listen("wheel",!0))}destroy(){this.listen("wheel",!1),this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=void 0}enableEventType(n,r){n==="wheel"&&this.options.enable!==r&&(this.options.enable=r,r&&!this.wheelSessionUnsubscribe&&(this.wheelSessionUnsubscribe=this.options.wheelSession?.on(()=>{})),this.listen("wheel",r),r||(this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=void 0))}};var CJt=4.000244140625,rmt=40,AJt=0,PJt=1,LJt=40,smt=40,kJt=120,RJt={classificationDelay:32,endDelay:80},lle=class{constructor(n,r={}){this.subscriptions=new Map,this.session=null,this.classificationTimer=null,this.endTimer=null,this.pressedControlKeys=new Set,this.listeningForControlKeys=!1,this.handleEvent=c=>{if(!this.hasSubscribers)return"unknown";let u=DJt(c,this.pressedControlKeys.size>0),d=this.session;if(d&&u.timeStamp-d.lastTimeStamp>=this.options.endDelay){if(this.end(),!this.hasSubscribers)return"unknown";d=null}d?(this.scheduleEnd(),this.addSample(d,u)):(d=this.startPendingSession(u),this.scheduleEnd());let{device:b}=d;return b==="unknown"&&(b=_ke(d.samples,!1),b!=="unknown"&&this.begin(d,b)),b},this.finishClassification=()=>{if(this.classificationTimer=null,!this.session||this.session.device!=="unknown")return;let c=this.session,u=_ke(c.samples,!0);this.begin(c,u==="unknown"?"mouse":u)},this.end=()=>{if(!this.session)return;if(this.session.device==="unknown"){let u=this.session,d=_ke(u.samples,!0);this.begin(u,d==="unknown"?"mouse":d)}if(!this.session)return;let c=this.session;this.emit(is.End,c.lastEvent),this.reset()},this.handleKeyDown=c=>{c.key==="Control"&&this.pressedControlKeys.add(c.code||c.key)},this.handleKeyUp=c=>{c.key==="Control"&&(c.code?this.pressedControlKeys.delete(c.code):this.pressedControlKeys.clear())},this.handleWindowBlur=()=>{this.pressedControlKeys.clear()},this.element=n,this.options={...RJt,...r},this.element?.addEventListener("wheel",this.handleEvent,{passive:!0})}get hasSubscribers(){return this.subscriptions.size>0}get device(){return this.session?.device??"unknown"}on(n){let r={listener:n};return this.subscriptions.set(n,r),this.updateControlKeyEventListeners(),()=>{this.subscriptions.get(n)===r&&this.off(n)}}off(n){this.subscriptions.delete(n),this.updateControlKeyEventListeners(),this.hasSubscribers||this.reset()}cancel(){let n=this.session;n&&n.device!=="unknown"&&this.emit(is.Cancel,n.lastEvent),this.reset()}destroy(){this.cancel(),this.subscriptions.clear(),this.updateControlKeyEventListeners(),this.element?.removeEventListener("wheel",this.handleEvent)}startPendingSession(n){let r={samples:[n],device:"unknown",firstTimeStamp:n.timeStamp,lastTimeStamp:n.timeStamp,totalDeltaX:n.deltaX,totalDeltaY:n.deltaY,velocityX:0,velocityY:0,lastEvent:n.event};return this.session=r,this.classificationTimer=globalThis.setTimeout(this.finishClassification,this.options.classificationDelay),r}addSample(n,r){if(n.samples.push(r),n.lastTimeStamp=r.timeStamp,n.lastEvent=r.event,n.totalDeltaX+=r.deltaX,n.totalDeltaY+=r.deltaY,n.device!=="unknown"){let c=n.samples[n.samples.length-2],u=r.timeStamp-c.timeStamp;n.velocityX=u>0?r.deltaX/u:0,n.velocityY=u>0?r.deltaY/u:0,this.emit(is.Move,r.event,{velocityX:n.velocityX,velocityY:n.velocityY})}}begin(n,r){n.device=r,this.clearClassificationTimer(),this.emit(is.Start,n.samples[0].event);let c=n.lastTimeStamp-n.firstTimeStamp;n.velocityX=c>0?n.totalDeltaX/c:0,n.velocityY=c>0?n.totalDeltaY/c:0,this.emit(is.Move,n.lastEvent,{velocityX:n.velocityX,velocityY:n.velocityY})}scheduleEnd(){this.clearEndTimer(),this.endTimer=globalThis.setTimeout(this.end,this.options.endDelay)}emit(n,r,c){let u=this.session;if(!u||u.device==="unknown")return;let d=n===is.Start,b=n===is.End||n===is.Cancel,w=d?u.firstTimeStamp:u.lastTimeStamp,_=d?0:Math.max(0,w-u.firstTimeStamp),x=d?0:u.totalDeltaX,T=d?0:u.totalDeltaY,M=_>0?x/_:0,L=_>0?T/_:0,I=d?0:c?.velocityX??u.velocityX,D=d?0:c?.velocityY??u.velocityY,F={eventType:n,device:u.device,srcEvent:r,timeStamp:w,center:{x:r.clientX,y:r.clientY},deltaX:x,deltaY:T,deltaTime:_,velocity:Math.abs(I)>Math.abs(D)?I:D,velocityX:I,velocityY:D,overallVelocity:Math.abs(M)>Math.abs(L)?M:L,overallVelocityX:M,overallVelocityY:L,isFirst:d,isFinal:b};for(let{listener:O}of[...this.subscriptions.values()])O(F)}reset(){this.clearClassificationTimer(),this.clearEndTimer(),this.session=null}clearClassificationTimer(){this.classificationTimer!==null&&(globalThis.clearTimeout(this.classificationTimer),this.classificationTimer=null)}clearEndTimer(){this.endTimer!==null&&(globalThis.clearTimeout(this.endTimer),this.endTimer=null)}updateControlKeyEventListeners(){let n=this.hasSubscribers,r=IJt();!r||n===this.listeningForControlKeys||(this.listeningForControlKeys=n,n?(r.addEventListener("keydown",this.handleKeyDown,!0),r.addEventListener("keyup",this.handleKeyUp,!0),r.addEventListener("blur",this.handleWindowBlur)):(r.removeEventListener("keydown",this.handleKeyDown,!0),r.removeEventListener("keyup",this.handleKeyUp,!0),r.removeEventListener("blur",this.handleWindowBlur),this.pressedControlKeys.clear()))}};function IJt(){return typeof window<"u"?window:globalThis.document?.defaultView}function DJt(s,n){let r=s.deltaX,c=s.deltaY;return s.deltaMode===PJt&&(r*=rmt,c*=rmt),{event:s,timeStamp:s.timeStamp,deltaX:r,deltaY:c,isControlKeyDown:n}}function _ke(s,n){return s.some(({event:r,isControlKeyDown:c})=>r.ctrlKey&&!c)?"trackpad":s.some(({event:r})=>r.deltaMode!==AJt)||s.some(BJt)||s.every(({event:r})=>{let c=r.wheelDelta;return c!==void 0&&Math.abs(c)%40===0})?"mouse":s.some(({deltaX:r})=>r!==0)||s.length>1&&OJt(s)?"trackpad":n?"mouse":"unknown"}function BJt({event:s,deltaX:n,deltaY:r}){if(n!==0||r===0)return!1;let c=Math.abs(r/CJt);if(Number.isInteger(c))return!0;let u=s.wheelDelta;return typeof u=="number"&&u!==0&&u%kJt===0}function OJt(s){for(let n=0;nsmt||Math.abs(r.deltaY)>smt||n>0&&r.timeStamp-s[n-1].timeStamp>LJt)return!1}return!0}var omt=["mousedown","mousemove","mouseup","mouseover","mouseout","mouseenter","mouseleave"],ule=class extends Xy{constructor(n,r,c){super(n,r,{enable:!0,...c}),this.handleEvent=d=>{this.handleOverEvent(d),this.handleOutEvent(d),this.handleEnterEvent(d),this.handleLeaveEvent(d),this.handleMoveEvent(d)},this.pressed=!1;let{enable:u=!1}=this.options;this.enableMoveEvent=u,this.enableLeaveEvent=u,this.enableEnterEvent=u,this.enableOutEvent=u,this.enableOverEvent=u,u&&omt.forEach(d=>this.listen(d,!0))}destroy(){omt.forEach(n=>this.listen(n,!1))}enableEventType(n,r){switch(n){case"pointermove":this.enableMoveEvent!==r&&(this.enableMoveEvent=r,this.listen("mousedown",r),this.listen("mousemove",r),this.listen("mouseup",r));break;case"pointerover":this.enableOverEvent!==r&&(this.enableOverEvent=r,this.listen("mouseover",r));break;case"pointerout":this.enableOutEvent!==r&&(this.enableOutEvent=r,this.listen("mouseout",r));break;case"pointerenter":this.enableEnterEvent!==r&&(this.enableEnterEvent=r,this.listen("mouseenter",r));break;case"pointerleave":this.enableLeaveEvent!==r&&(this.enableLeaveEvent=r,this.listen("mouseleave",r));break;default:}}handleOverEvent(n){this.enableOverEvent&&n.type==="mouseover"&&this._emit("pointerover",n)}handleOutEvent(n){this.enableOutEvent&&n.type==="mouseout"&&this._emit("pointerout",n)}handleEnterEvent(n){this.enableEnterEvent&&n.type==="mouseenter"&&this._emit("pointerenter",n)}handleLeaveEvent(n){this.enableLeaveEvent&&n.type==="mouseleave"&&this._emit("pointerleave",n)}handleMoveEvent(n){if(this.enableMoveEvent)switch(n.type){case"mousedown":n.button>=0&&(this.pressed=!0);break;case"mousemove":n.buttons===0&&(this.pressed=!1),this.pressed||this._emit("pointermove",n);break;case"mouseup":this.pressed=!1;break;default:}}_emit(n,r){this.callback({type:n,center:{x:r.clientX,y:r.clientY},srcEvent:r,pointerType:"mouse",target:r.target})}};var amt=["keydown","keyup"],fle=class extends Xy{constructor(n,r,c){super(n,r,{enable:!0,tabIndex:0,...c}),this.handleEvent=d=>{let b=d.target||d.srcElement;b.tagName==="INPUT"&&b.type==="text"||b.tagName==="TEXTAREA"||(this.enableDownEvent&&d.type==="keydown"&&this.callback({type:"keydown",srcEvent:d,key:d.key,target:d.target}),this.enableUpEvent&&d.type==="keyup"&&this.callback({type:"keyup",srcEvent:d,key:d.key,target:d.target}))};let{enable:u=!1}=this.options;this.enableDownEvent=u,this.enableUpEvent=u,n.tabIndex=this.options.tabIndex,n.style.outline="none",u&&amt.forEach(d=>this.listen(d,!0))}destroy(){amt.forEach(n=>this.listen(n,!1))}enableEventType(n,r){n==="keydown"&&this.enableDownEvent!==r&&(this.enableDownEvent=r,this.listen(n,r)),n==="keyup"&&this.enableUpEvent!==r&&(this.enableUpEvent=r,this.listen(n,r))}};var hle=class extends Xy{constructor(n,r,c){c.enable=c.enable??!1,super(n,r,c),this.handleEvent=u=>{this.options.enable&&this.callback({type:"contextmenu",center:{x:u.clientX,y:u.clientY},srcEvent:u,pointerType:"mouse",target:u.target})},c.enable&&this.listen("contextmenu",!0)}destroy(){this.listen("contextmenu",!1)}enableEventType(n,r){n==="contextmenu"&&this.options.enable!==r&&(this.options.enable=r,this.listen("contextmenu",r))}};var NJt={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},FJt=0,UJt=1,zJt=2,GJt=1,jJt=2,$Jt=4;function cmt(s){let n=NJt[s.srcEvent.type];if(!n)return null;let{buttons:r,button:c}=s.srcEvent,u=!1,d=!1,b=!1;return n===2?(u=!!(r&GJt),d=!!(r&$Jt),b=!!(r&jJt)):(u=c===FJt,d=c===UJt,b=c===zJt),{leftButton:u,middleButton:d,rightButton:b}}function lmt(s,n){let r=s.center;if(!r)return null;let c=n.getBoundingClientRect(),u=c.width/n.offsetWidth||1,d=c.height/n.offsetHeight||1,b={x:(r.x-c.left-n.clientLeft)/u,y:(r.y-c.top-n.clientTop)/d};return{center:r,offsetCenter:b}}var VJt={srcElement:"root",priority:0},dle=class{constructor(n,r){this.handleEvent=c=>{if(this.isEmpty())return;let u=this._normalizeEvent(c),d=c.srcEvent.target;for(;d&&d!==u.rootElement;){if(this._emit(u,d),u.handled)return;d=d.parentNode}this._emit(u,"root")},this.eventManager=n,this.recognizerName=r,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(n,r,c,u=!1,d=!1){let{handlers:b,handlersByElement:w}=this,_={...VJt,...c},x=w.get(_.srcElement);x||(x=[],w.set(_.srcElement,x));let T={type:n,handler:r,srcElement:_.srcElement,priority:_.priority};u&&(T.once=!0),d&&(T.passive=!0),b.push(T),this._active=this._active||!T.passive;let M=x.length-1;for(;M>=0&&!(x[M].priority>=T.priority);)M--;x.splice(M+1,0,T)}remove(n,r){let{handlers:c,handlersByElement:u}=this;for(let d=c.length-1;d>=0;d--){let b=c[d];if(b.type===n&&b.handler===r){c.splice(d,1);let w=u.get(b.srcElement);w.splice(w.indexOf(b),1),w.length===0&&u.delete(b.srcElement)}}this._active=c.some(d=>!d.passive)}_emit(n,r){let c=this.handlersByElement.get(r);if(c){let u=!1,d=()=>{n.handled=!0},b=()=>{n.handled=!0,u=!0},w=[];for(let _=0;_{n.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:r}}};function WJt(s){if("recognizer"in s)return s;let n,r=Array.isArray(s)?[...s]:[s];if(typeof r[0]=="function"){let c=r.shift(),u=r.shift()||{};n=new c(u)}else n=r.shift();return{recognizer:n,recognizeWith:typeof r[0]=="string"?[r[0]]:r[0],requireFailure:typeof r[1]=="string"?[r[1]]:r[1]}}var H$=class{constructor(n=null,r={}){if(this._onBasicInput=c=>{this.manager.emit(c.srcEvent.type,c)},this._onOtherEvent=c=>{this.manager.emit(c.type,c)},this.options={recognizers:[],events:{},touchAction:"compute",tabIndex:0,cssProps:{},...r},this.events=new Map,this.element=n,this.wheelSession=new lle(n),!!n){this.manager=new W$(n,this.options);for(let c of this.options.recognizers){let{recognizer:u,recognizeWith:d,requireFailure:b}=WJt(c);this.manager.add(u),d&&u.recognizeWith(d),b&&u.requireFailure(b)}this.manager.on("hammer.input",this._onBasicInput),this.wheelInput=new cle(n,this._onOtherEvent,{enable:!1,wheelSession:this.wheelSession}),this.moveInput=new ule(n,this._onOtherEvent,{enable:!1}),this.keyInput=new fle(n,this._onOtherEvent,{enable:!1,tabIndex:r.tabIndex}),this.contextmenuInput=new hle(n,this._onOtherEvent,{enable:!1}),this.on(this.options.events)}}getElement(){return this.element}destroy(){if(!this.element){this.wheelSession.destroy();return}this.wheelInput.destroy(),this.wheelSession.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy()}on(n,r,c){this._addEventHandler(n,r,c,!1)}once(n,r,c){this._addEventHandler(n,r,c,!0)}watch(n,r,c){this._addEventHandler(n,r,c,!1,!0)}off(n,r){this._removeEventHandler(n,r)}emit(n){this.manager?.emit(n.type,n)}_toggleRecognizer(n,r){let{manager:c}=this;if(!c)return;let u=c.get(n);u&&(u.set({enable:r,wheelSession:this.wheelSession}),c.touchAction.update()),this.wheelInput?.enableEventType(n,r),this.moveInput?.enableEventType(n,r),this.keyInput?.enableEventType(n,r),this.contextmenuInput?.enableEventType(n,r)}_addEventHandler(n,r,c,u,d){if(typeof n!="string"){c=r;for(let[x,T]of Object.entries(n))this._addEventHandler(x,T,c,u,d);return}let{manager:b,events:w}=this;if(!b)return;let _=w.get(n);if(!_){let x=this._getRecognizerName(n)||n;_=new dle(this,x),w.set(n,_),b&&b.on(n,_.handleEvent)}_.add(n,r,c,u,d),_.isEmpty()||this._toggleRecognizer(_.recognizerName,!0)}_removeEventHandler(n,r){if(typeof n!="string"){for(let[d,b]of Object.entries(n))this._removeEventHandler(d,b);return}let{events:c}=this,u=c.get(n);if(u&&(u.remove(n,r),u.isEmpty())){let{recognizerName:d}=u,b=!1;for(let w of c.values())if(w.recognizerName===d&&!w.isEmpty()){b=!0;break}b||this._toggleRecognizer(d,!1)}}_getRecognizerName(n){return this.manager.recognizers.find(r=>r.getEventNames().includes(n))?.options.event}};var yke={DEFAULT:"default",LNGLAT:"lnglat",METER_OFFSETS:"meter-offsets",LNGLAT_OFFSETS:"lnglat-offsets",CARTESIAN:"cartesian"};Object.defineProperty(yke,"IDENTITY",{get:()=>(Bs.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),yke.CARTESIAN)});var jh={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},Cb={common:0,meters:1,pixels:2},iB={click:"onClick",dblclick:"onClick",panstart:"onDragStart",panmove:"onDrag",panend:"onDragEnd"},xke={multipan:[VM,{threshold:10,pointers:2,trackpad:!0}],pinch:[nB,{trackpad:!0},null,["multipan"]],pan:[VM,{threshold:1},["pinch"],["multipan"]],dblclick:[w4,{event:"dblclick",taps:2,enable:!1}],dblclickdrag:[eB,{event:"dblclickdrag",enable:!1},["dblclick"],null],click:[w4,{event:"click"},["dblclickdrag"],["dblclick","dblclickdrag"]]};function HJt(s,n){if(s===n)return!0;if(Array.isArray(s)){let r=s.length;if(!n||n.length!==r)return!1;for(let c=0;c{for(let u in c)if(!HJt(c[u],n[u])){r=s(c),n=c;break}return r}}var umt=[0,0,0,0],qJt=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],fmt=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],XJt=[0,0,0],hmt=[0,0,0],YJt={default:-1,cartesian:0,lnglat:1,"meter-offsets":2,"lnglat-offsets":3};function v4(s){let n=YJt[s];if(n===void 0)throw new Error(`Invalid coordinateSystem: ${s}`);return n}var ZJt=Yy(JJt);function Eke(s,n,r=hmt){r.length<3&&(r=[r[0],r[1],0]);let c=r,u,d=!0;switch(n==="lnglat-offsets"||n==="meter-offsets"?u=r:u=s.isGeospatial?[Math.fround(s.longitude),Math.fround(s.latitude),0]:null,s.projectionMode){case jh.WEB_MERCATOR:(n==="lnglat"||n==="cartesian")&&(u=[0,0,0],d=!1);break;case jh.WEB_MERCATOR_AUTO_OFFSET:n==="lnglat"?c=u:n==="cartesian"&&(c=[Math.fround(s.center[0]),Math.fround(s.center[1]),0],u=s.unprojectPosition(c),c[0]-=r[0],c[1]-=r[1],c[2]-=r[2]);break;case jh.IDENTITY:c=s.position.map(Math.fround),c[2]=c[2]||0;break;case jh.GLOBE:d=!1,u=null;break;default:d=!1}return{geospatialOrigin:u,shaderCoordinateOrigin:c,offsetMode:d}}function KJt(s,n,r){let{viewMatrixUncentered:c,projectionMatrix:u}=s,{viewMatrix:d,viewProjectionMatrix:b}=s,w=umt,_=umt,x=s.cameraPosition,{geospatialOrigin:T,shaderCoordinateOrigin:M,offsetMode:L}=Eke(s,n,r);return L&&(_=s.projectPosition(T||M),x=[x[0]-_[0],x[1]-_[1],x[2]-_[2]],_[3]=1,w=U1.transformMat4([],_,b),d=c||d,b=uh.multiply([],u,d),b=uh.multiply([],b,qJt)),{viewMatrix:d,viewProjectionMatrix:b,projectionCenter:w,originCommon:_,cameraPosCommon:x,shaderCoordinateOrigin:M,geospatialOrigin:T}}function dmt({viewport:s,devicePixelRatio:n=1,modelMatrix:r=null,coordinateSystem:c="default",coordinateOrigin:u=hmt,autoWrapLongitude:d=!1}){c==="default"&&(c=s.isGeospatial?"lnglat":"cartesian");let b=ZJt({viewport:s,devicePixelRatio:n,coordinateSystem:c,coordinateOrigin:u});return b.wrapLongitude=d,b.modelMatrix=r||fmt,b}function JJt({viewport:s,devicePixelRatio:n,coordinateSystem:r,coordinateOrigin:c}){let{projectionCenter:u,viewProjectionMatrix:d,originCommon:b,cameraPosCommon:w,shaderCoordinateOrigin:_,geospatialOrigin:x}=KJt(s,r,c),T=s.getDistanceScales(),M=[s.width*n,s.height*n],L=U1.transformMat4([],[0,0,-s.focalDistance,1],s.projectionMatrix)[3]||1,I={coordinateSystem:v4(r),projectionMode:s.projectionMode,coordinateOrigin:_,commonOrigin:b.slice(0,3),center:u,pseudoMeters:!!s._pseudoMeters,viewportSize:M,devicePixelRatio:n,focalDistance:L,commonUnitsPerMeter:T.unitsPerMeter,commonUnitsPerWorldUnit:T.unitsPerMeter,commonUnitsPerWorldUnit2:XJt,scale:s.scale,wrapLongitude:!1,viewProjectionMatrix:d,modelMatrix:fmt,cameraPosition:w};if(x){let D=s.getDistanceScales(x);switch(r){case"meter-offsets":I.commonUnitsPerWorldUnit=D.unitsPerMeter,I.commonUnitsPerWorldUnit2=D.unitsPerMeter2;break;case"lnglat":case"lnglat-offsets":s._pseudoMeters||(I.commonUnitsPerMeter=D.unitsPerMeter),I.commonUnitsPerWorldUnit=D.unitsPerDegree,I.commonUnitsPerWorldUnit2=D.unitsPerDegree2;break;case"cartesian":I.commonUnitsPerWorldUnit=[1,1,D.unitsPerMeter[2]],I.commonUnitsPerWorldUnit2=[0,0,D.unitsPerMeter2[2]];break;default:break}}if(s.projectionMode===jh.GLOBE&&r==="meter-offsets"){let O=c[0]*Math.PI/180,z=c[1]*Math.PI/180,Z=Math.cos(z),H=((c[2]||0)/6370972+1)*256;I.commonOrigin=[Math.sin(O)*Z*H,-Math.cos(O)*Z*H,Math.sin(z)*H]}return I}var QJt=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],eQt=QJt.map(s=>`const COORDINATE_SYSTEM_${s.toUpperCase().replaceAll("-","_")}: i32 = ${v4(s)};`).join(""),tQt=Object.keys(jh).map(s=>`const PROJECTION_MODE_${s}: i32 = ${jh[s]};`).join(""),nQt=Object.keys(Cb).map(s=>`const UNIT_${s.toUpperCase()}: i32 = ${Cb[s]};`).join(""),iQt=`${eQt} +${tQt} +${nQt} + +const TILE_SIZE: f32 = 512.0; +const PI: f32 = 3.1415926536; +const WORLD_SCALE: f32 = TILE_SIZE / (PI * 2.0); +const ZERO_64_LOW: vec3 = vec3(0.0, 0.0, 0.0); +const EARTH_RADIUS: f32 = 6370972.0; // meters +const GLOBE_RADIUS: f32 = 256.0; + +// ----------------------------------------------------------------------------- +// Uniform block (converted from GLSL uniform block) +// ----------------------------------------------------------------------------- +struct ProjectUniforms { + wrapLongitude: i32, + coordinateSystem: i32, + commonUnitsPerMeter: vec3, + projectionMode: i32, + scale: f32, + commonUnitsPerWorldUnit: vec3, + commonUnitsPerWorldUnit2: vec3, + center: vec4, + modelMatrix: mat4x4, + viewProjectionMatrix: mat4x4, + viewportSize: vec2, + devicePixelRatio: f32, + focalDistance: f32, + cameraPosition: vec3, + coordinateOrigin: vec3, + commonOrigin: vec3, + pseudoMeters: i32, +}; + +@group(0) @binding(auto) +var project: ProjectUniforms; + +// ----------------------------------------------------------------------------- +// Geometry data shared across the project helpers. +// The active layer shader is responsible for populating this private module +// state before calling the project functions below. +// ----------------------------------------------------------------------------- + +// Structure to carry additional geometry data used by deck.gl filters. +struct Geometry { + worldPosition: vec3, + worldPositionAlt: vec3, + position: vec4, + normal: vec3, + uv: vec2, + pickingColor: vec3, +}; + +var geometry: Geometry; +`,pmt=`${iQt} + +// ----------------------------------------------------------------------------- +// Functions +// ----------------------------------------------------------------------------- + +// Returns an adjustment factor for commonUnitsPerMeter +fn _project_size_at_latitude(lat: f32) -> f32 { + let y = clamp(lat, -89.9, 89.9); + return 1.0 / cos(radians(y)); +} + +// Overloaded version: scales a value in meters at a given latitude. +fn _project_size_at_latitude_m(meters: f32, lat: f32) -> f32 { + return meters * project.commonUnitsPerMeter.z * _project_size_at_latitude(lat); +} + +// Computes a non-linear scale factor based on geometry. +// (Note: This function relies on "geometry" being provided.) +fn project_size() -> f32 { + if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR && + project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT && + project.pseudoMeters == 0) { + if (geometry.position.w == 0.0) { + return _project_size_at_latitude(geometry.worldPosition.y); + } + let y: f32 = geometry.position.y / TILE_SIZE * 2.0 - 1.0; + let y2 = y * y; + let y4 = y2 * y2; + let y6 = y4 * y2; + return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6; + } + return 1.0; +} + +// Overloads to scale offsets (meters to world units) +fn project_size_float(meters: f32) -> f32 { + return meters * project.commonUnitsPerMeter.z * project_size(); +} + +fn project_size_vec2(meters: vec2) -> vec2 { + return meters * project.commonUnitsPerMeter.xy * project_size(); +} + +fn project_size_vec3(meters: vec3) -> vec3 { + return meters * project.commonUnitsPerMeter * project_size(); +} + +fn project_size_vec4(meters: vec4) -> vec4 { + return vec4(meters.xyz * project.commonUnitsPerMeter, meters.w); +} + +// Returns a rotation matrix aligning the z\u2011axis with the given up vector. +fn project_get_orientation_matrix(up: vec3) -> mat3x3 { + let uz = normalize(up); + let ux = select( + vec3(1.0, 0.0, 0.0), + normalize(vec3(uz.y, -uz.x, 0.0)), + abs(uz.z) == 1.0 + ); + let uy = cross(uz, ux); + return mat3x3(ux, uy, uz); +} + +// Since WGSL does not support "out" parameters, we return a struct. +struct RotationResult { + needsRotation: bool, + transform: mat3x3, +}; + +fn project_needs_rotation(commonPosition: vec3) -> RotationResult { + if (project.projectionMode == PROJECTION_MODE_GLOBE) { + return RotationResult(true, project_get_orientation_matrix(commonPosition)); + } else { + return RotationResult(false, mat3x3()); // identity alternative if needed + }; +} + +// Projects a normal vector from the current coordinate system to world space. +fn project_normal(vector: vec3) -> vec3 { + let normal_modelspace = project.modelMatrix * vec4(vector, 0.0); + var n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter); + let rotResult = project_needs_rotation(geometry.position.xyz); + if (rotResult.needsRotation) { + n = rotResult.transform * n; + } + return n; +} + +// Applies a scale offset based on y-offset (dy) +fn project_offset_(offset: vec4) -> vec4 { + let dy: f32 = offset.y; + let commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy; + return vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w); +} + +// Projects lng/lat coordinates to a unit tile [0,1] +fn project_mercator_(lnglat: vec2) -> vec2 { + var x = lnglat.x; + if (project.wrapLongitude != 0) { + x = ((x + 180.0) % 360.0) - 180.0; + } + let y = clamp(lnglat.y, -89.9, 89.9); + return vec2( + radians(x) + PI, + PI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5)) + ) * WORLD_SCALE; +} + +// Projects lng/lat/z coordinates for a globe projection. +fn project_globe_(lnglatz: vec3) -> vec3 { + let lambda = radians(lnglatz.x); + let phi = radians(lnglatz.y); + let cosPhi = cos(phi); + let D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS; + return vec3( + sin(lambda) * cosPhi, + -cos(lambda) * cosPhi, + sin(phi) + ) * D; +} + +// Projects positions (with an optional 64-bit low part) from the input +// coordinate system to the common space. +fn project_position_vec4_f64(position: vec4, position64Low: vec3) -> vec4 { + var position_world = project.modelMatrix * position; + + // Work around for a Mac+NVIDIA bug: + if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) { + if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { + return vec4( + project_mercator_(position_world.xy), + _project_size_at_latitude_m(position_world.z, position_world.y), + position_world.w + ); + } + if (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) { + position_world = vec4f(position_world.xyz + project.coordinateOrigin, position_world.w); + } + } + if (project.projectionMode == PROJECTION_MODE_GLOBE) { + if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { + return vec4( + project_globe_(position_world.xyz), + position_world.w + ); + } + if (project.coordinateSystem == COORDINATE_SYSTEM_METER_OFFSETS) { + let enuMatrix = project_get_orientation_matrix(project.commonOrigin); + let metersToCommon = GLOBE_RADIUS / EARTH_RADIUS; + let offsetCommon = (enuMatrix * vec3(-position_world.x, -position_world.y, position_world.z)) * metersToCommon; + return vec4(project.commonOrigin + offsetCommon, position_world.w); + } + } + if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) { + if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { + if (abs(position_world.y - project.coordinateOrigin.y) > 0.25) { + return vec4( + project_mercator_(position_world.xy) - project.commonOrigin.xy, + project_size_float(position_world.z), + position_world.w + ); + } + } + } + if (project.projectionMode == PROJECTION_MODE_IDENTITY || + (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET && + (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT || + project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) { + position_world = vec4f(position_world.xyz - project.coordinateOrigin, position_world.w); + } + + return project_offset_(position_world) + + project_offset_(project.modelMatrix * vec4(position64Low, 0.0)); +} + +// Overloaded versions for different input types. +fn project_position_vec4_f32(position: vec4) -> vec4 { + return project_position_vec4_f64(position, ZERO_64_LOW); +} + +fn project_position_vec3_f64(position: vec3, position64Low: vec3) -> vec3 { + let projected_position = project_position_vec4_f64(vec4(position, 1.0), position64Low); + return projected_position.xyz; +} + +fn project_position_vec3_f32(position: vec3) -> vec3 { + let projected_position = project_position_vec4_f64(vec4(position, 1.0), ZERO_64_LOW); + return projected_position.xyz; +} + +fn project_position_vec2_f32(position: vec2) -> vec2 { + let projected_position = project_position_vec4_f64(vec4(position, 0.0, 1.0), ZERO_64_LOW); + return projected_position.xy; +} + +// Transforms a common space position to clip space. +fn project_common_position_to_clipspace_with_projection(position: vec4, viewProjectionMatrix: mat4x4, center: vec4) -> vec4 { + var clipPosition = viewProjectionMatrix * position + center; + // deck.gl projection matrices use WebGL's [-w, w] depth range; WebGPU clips z to [0, w]. + clipPosition.z = (clipPosition.z + clipPosition.w) * 0.5; + return clipPosition; +} + +// Uses the project viewProjectionMatrix and center. +fn project_common_position_to_clipspace(position: vec4) -> vec4 { + return project_common_position_to_clipspace_with_projection(position, project.viewProjectionMatrix, project.center); +} + +// Returns a clip space offset corresponding to a given number of screen pixels. +fn project_pixel_size_to_clipspace(pixels: vec2) -> vec2 { + let offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0; + return offset * project.focalDistance; +} + +fn project_meter_size_to_pixel(meters: f32) -> f32 { + return project_size_float(meters) * project.scale; +} + +fn project_unit_size_to_pixel(size: f32, unit: i32) -> f32 { + if (unit == UNIT_METERS) { + return project_meter_size_to_pixel(size); + } else if (unit == UNIT_COMMON) { + return size * project.scale; + } + // UNIT_PIXELS: no scaling applied. + return size; +} + +fn project_pixel_size_float(pixels: f32) -> f32 { + return pixels / project.scale; +} + +fn project_pixel_size_vec2(pixels: vec2) -> vec2 { + return pixels / project.scale; +} +`;var rQt=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],sQt=rQt.map(s=>`const int COORDINATE_SYSTEM_${s.toUpperCase().replaceAll("-","_")} = ${v4(s)};`).join(""),oQt=Object.keys(jh).map(s=>`const int PROJECTION_MODE_${s} = ${jh[s]};`).join(""),aQt=Object.keys(Cb).map(s=>`const int UNIT_${s.toUpperCase()} = ${Cb[s]};`).join(""),gmt=`${sQt} +${oQt} +${aQt} +layout(std140) uniform projectUniforms { +bool wrapLongitude; +int coordinateSystem; +vec3 commonUnitsPerMeter; +int projectionMode; +float scale; +vec3 commonUnitsPerWorldUnit; +vec3 commonUnitsPerWorldUnit2; +vec4 center; +mat4 modelMatrix; +mat4 viewProjectionMatrix; +vec2 viewportSize; +float devicePixelRatio; +float focalDistance; +vec3 cameraPosition; +vec3 coordinateOrigin; +vec3 commonOrigin; +bool pseudoMeters; +} project; +const float TILE_SIZE = 512.0; +const float PI = 3.1415926536; +const float WORLD_SCALE = TILE_SIZE / (PI * 2.0); +const vec3 ZERO_64_LOW = vec3(0.0); +const float EARTH_RADIUS = 6370972.0; +const float GLOBE_RADIUS = 256.0; +float project_size_at_latitude(float lat) { +float y = clamp(lat, -89.9, 89.9); +return 1.0 / cos(radians(y)); +} +float project_size() { +if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR && +project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT && +project.pseudoMeters == false) { +if (geometry.position.w == 0.0) { +return project_size_at_latitude(geometry.worldPosition.y); +} +float y = geometry.position.y / TILE_SIZE * 2.0 - 1.0; +float y2 = y * y; +float y4 = y2 * y2; +float y6 = y4 * y2; +return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6; +} +return 1.0; +} +float project_size_at_latitude(float meters, float lat) { +return meters * project.commonUnitsPerMeter.z * project_size_at_latitude(lat); +} +float project_size(float meters) { +return meters * project.commonUnitsPerMeter.z * project_size(); +} +vec2 project_size(vec2 meters) { +return meters * project.commonUnitsPerMeter.xy * project_size(); +} +vec3 project_size(vec3 meters) { +return meters * project.commonUnitsPerMeter * project_size(); +} +vec4 project_size(vec4 meters) { +return vec4(meters.xyz * project.commonUnitsPerMeter, meters.w); +} +mat3 project_get_orientation_matrix(vec3 up) { +vec3 uz = normalize(up); +vec3 ux = abs(uz.z) == 1.0 ? vec3(1.0, 0.0, 0.0) : normalize(vec3(uz.y, -uz.x, 0)); +vec3 uy = cross(uz, ux); +return mat3(ux, uy, uz); +} +bool project_needs_rotation(vec3 commonPosition, out mat3 transform) { +if (project.projectionMode == PROJECTION_MODE_GLOBE) { +transform = project_get_orientation_matrix(commonPosition); +return true; +} +return false; +} +vec3 project_normal(vec3 vector) { +vec4 normal_modelspace = project.modelMatrix * vec4(vector, 0.0); +vec3 n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter); +mat3 rotation; +if (project_needs_rotation(geometry.position.xyz, rotation)) { +n = rotation * n; +} +return n; +} +vec4 project_offset_(vec4 offset) { +float dy = offset.y; +vec3 commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy; +return vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w); +} +vec2 project_mercator_(vec2 lnglat) { +float x = lnglat.x; +if (project.wrapLongitude) { +x = mod(x + 180., 360.0) - 180.; +} +float y = clamp(lnglat.y, -89.9, 89.9); +return vec2( +radians(x) + PI, +PI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5)) +) * WORLD_SCALE; +} +vec3 project_globe_(vec3 lnglatz) { +float lambda = radians(lnglatz.x); +float phi = radians(lnglatz.y); +float cosPhi = cos(phi); +float D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS; +return vec3( +sin(lambda) * cosPhi, +-cos(lambda) * cosPhi, +sin(phi) +) * D; +} +vec4 project_position(vec4 position, vec3 position64Low) { +vec4 position_world = project.modelMatrix * position; +if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) { +if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { +return vec4( +project_mercator_(position_world.xy), +project_size_at_latitude(position_world.z, position_world.y), +position_world.w +); +} +if (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) { +position_world.xyz += project.coordinateOrigin; +} +} +if (project.projectionMode == PROJECTION_MODE_GLOBE) { +if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { +return vec4( +project_globe_(position_world.xyz), +position_world.w +); +} +if (project.coordinateSystem == COORDINATE_SYSTEM_METER_OFFSETS) { +mat3 enuMatrix = project_get_orientation_matrix(project.commonOrigin); +float metersToCommon = GLOBE_RADIUS / EARTH_RADIUS; +vec3 offsetCommon = (enuMatrix * vec3(-position_world.xy, position_world.z)) * metersToCommon; +return vec4(project.commonOrigin + offsetCommon, position_world.w); +} +} +if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) { +if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { +if (abs(position_world.y - project.coordinateOrigin.y) > 0.25) { +return vec4( +project_mercator_(position_world.xy) - project.commonOrigin.xy, +project_size(position_world.z), +position_world.w +); +} +} +} +if (project.projectionMode == PROJECTION_MODE_IDENTITY || +(project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET && +(project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT || +project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) { +position_world.xyz -= project.coordinateOrigin; +} +return project_offset_(position_world) + project_offset_(project.modelMatrix * vec4(position64Low, 0.0)); +} +vec4 project_position(vec4 position) { +return project_position(position, ZERO_64_LOW); +} +vec3 project_position(vec3 position, vec3 position64Low) { +vec4 projected_position = project_position(vec4(position, 1.0), position64Low); +return projected_position.xyz; +} +vec3 project_position(vec3 position) { +vec4 projected_position = project_position(vec4(position, 1.0), ZERO_64_LOW); +return projected_position.xyz; +} +vec2 project_position(vec2 position) { +vec4 projected_position = project_position(vec4(position, 0.0, 1.0), ZERO_64_LOW); +return projected_position.xy; +} +vec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) { +return viewProjectionMatrix * position + center; +} +vec4 project_common_position_to_clipspace(vec4 position) { +return project_common_position_to_clipspace(position, project.viewProjectionMatrix, project.center); +} +vec2 project_pixel_size_to_clipspace(vec2 pixels) { +vec2 offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0; +return offset * project.focalDistance; +} +float project_size_to_pixel(float meters) { +return project_size(meters) * project.scale; +} +vec2 project_size_to_pixel(vec2 meters) { +return project_size(meters) * project.scale; +} +float project_size_to_pixel(float size, int unit) { +if (unit == UNIT_METERS) return project_size_to_pixel(size); +if (unit == UNIT_COMMON) return size * project.scale; +return size; +} +float project_pixel_size(float pixels) { +return pixels / project.scale; +} +vec2 project_pixel_size(vec2 pixels) { +return pixels / project.scale; +} +`;var cQt={};function lQt(s=cQt){return"viewport"in s?dmt(s):{}}var lv={name:"project",dependencies:[d4,ile],source:pmt,vs:gmt,getUniforms:lQt,uniformTypes:{wrapLongitude:"f32",coordinateSystem:"i32",commonUnitsPerMeter:"vec3",projectionMode:"i32",scale:"f32",commonUnitsPerWorldUnit:"vec3",commonUnitsPerWorldUnit2:"vec3",center:"vec4",modelMatrix:"mat4x4",viewProjectionMatrix:"mat4x4",viewportSize:"vec2",devicePixelRatio:"f32",focalDistance:"f32",cameraPosition:"vec3",coordinateOrigin:"vec3",commonOrigin:"vec3",pseudoMeters:"f32"}};var uQt=`// Define a structure to hold both the clip-space position and the common position. +struct ProjectResult { + clipPosition: vec4, + commonPosition: vec4, +}; + +// This function mimics the GLSL version with the 'out' parameter by returning both values. +fn project_position_to_clipspace_and_commonspace( + position: vec3, + position64Low: vec3, + offset: vec3 +) -> ProjectResult { + // Compute the projected position. + let projectedPosition: vec3 = project_position_vec3_f64(position, position64Low); + + // Start with the provided offset. + var finalOffset: vec3 = offset; + + // Get whether a rotation is needed and the rotation matrix. + let rotationResult = project_needs_rotation(projectedPosition); + + // If rotation is needed, update the offset. + if (rotationResult.needsRotation) { + finalOffset = rotationResult.transform * offset; + } + + // Compute the common position. + let commonPosition: vec4 = vec4(projectedPosition + finalOffset, 1.0); + + // Convert to clip-space. + let clipPosition: vec4 = project_common_position_to_clipspace(commonPosition); + + return ProjectResult(clipPosition, commonPosition); +} + +// A convenience overload that returns only the clip-space position. +fn project_position_to_clipspace( + position: vec3, + position64Low: vec3, + offset: vec3 +) -> vec4 { + return project_position_to_clipspace_and_commonspace(position, position64Low, offset).clipPosition; +} +`,fQt=`vec4 project_position_to_clipspace( + vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition +) { + vec3 projectedPosition = project_position(position, position64Low); + mat3 rotation; + if (project_needs_rotation(projectedPosition, rotation)) { + // offset is specified as ENU + // when in globe projection, rotate offset so that the ground alighs with the surface of the globe + offset = rotation * offset; + } + commonPosition = vec4(projectedPosition + offset, 1.0); + return project_common_position_to_clipspace(commonPosition); +} + +vec4 project_position_to_clipspace( + vec3 position, vec3 position64Low, vec3 offset +) { + vec4 commonPosition; + return project_position_to_clipspace(position, position64Low, offset, commonPosition); +} +`,Zy={name:"project32",dependencies:[lv],source:uQt,vs:fQt};Bf();Bf();function Ske(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function WM(s,n){let r=U1.transformMat4([],n,s);return U1.scale(r,r,1/r[3]),r}function q$(s,n,r){return sr?r:s}function hQt(s){return Math.log(s)*Math.LOG2E}var X$=Math.log2||hQt;Bf();function uv(s,n){if(!s)throw new Error(n||"@math.gl/web-mercator: assertion failed.")}var fv=Math.PI,mmt=fv/4,Ab=fv/180,Mke=180/fv,rB=512,ple=4003e4,sB=85.051129,bmt=1.5;function Tke(s){return X$(s)}function ag(s){let[n,r]=s;uv(Number.isFinite(n)),uv(Number.isFinite(r)&&r>=-90&&r<=90,"invalid latitude");let c=n*Ab,u=r*Ab,d=rB*(c+fv)/(2*fv),b=rB*(fv+Math.log(Math.tan(mmt+u*.5)))/(2*fv);return[d,b]}function z1(s){let[n,r]=s,c=n/rB*(2*fv)-fv,u=2*(Math.atan(Math.exp(r/rB*(2*fv)-fv))-mmt);return[c*Mke,u*Mke]}function Cke(s){let{latitude:n}=s;uv(Number.isFinite(n));let r=Math.cos(n*Ab);return Tke(ple*r)-9}function Y$(s){let n=Math.cos(s*Ab);return rB/ple/n}function oB(s){let{latitude:n,longitude:r,highPrecision:c=!1}=s;uv(Number.isFinite(n)&&Number.isFinite(r));let u=rB,d=Math.cos(n*Ab),b=u/360,w=b/d,_=u/ple/d,x={unitsPerMeter:[_,_,_],metersPerUnit:[1/_,1/_,1/_],unitsPerDegree:[b,w,_],degreesPerUnit:[1/b,1/w,1/_]};if(c){let T=Ab*Math.tan(n*Ab)/d,M=b*T/2,L=u/ple*T,I=L/w*_;x.unitsPerDegree2=[0,M,L],x.unitsPerMeter2=[I,0,I]}return x}function Z$(s,n){let[r,c,u]=s,[d,b,w]=n,{unitsPerMeter:_,unitsPerMeter2:x}=oB({longitude:r,latitude:c,highPrecision:!0}),T=ag(s);T[0]+=d*(_[0]+x[0]*b),T[1]+=b*(_[1]+x[1]*b);let M=z1(T),L=(u||0)+(w||0);return Number.isFinite(u)||Number.isFinite(w)?[M[0],M[1],L]:M}function gle(s){let{height:n,pitch:r,bearing:c,altitude:u,scale:d,center:b}=s,w=Ske();uh.translate(w,w,[0,0,-u]),uh.rotateX(w,w,-r*Ab),uh.rotateZ(w,w,c*Ab);let _=d/n;return uh.scale(w,w,[_,_,_]),b&&uh.translate(w,w,wm.negate([],b)),w}function Ake(s){let{width:n,height:r,altitude:c,pitch:u=0,offset:d,center:b,scale:w,nearZMultiplier:_=1,farZMultiplier:x=1}=s,{fovy:T=_4(bmt)}=s;c!==void 0&&(T=_4(c));let M=T*Ab,L=u*Ab,I=K$(T),D=I;b&&(D+=b[2]*w/Math.cos(L)/r);let F=M*(.5+(d?d[1]:0)/r),O=Math.sin(F)*D/Math.sin(q$(Math.PI/2-L-F,.01,Math.PI-.01)),z=Math.sin(L)*O+D,Z=D*10,H=Math.min(z*x,Z);return{fov:M,aspect:n/r,focalDistance:I,near:_,far:H}}function _4(s){return 2*Math.atan(.5/s)*Mke}function K$(s){return .5/Math.tan(.5*s*Ab)}function HM(s,n){let[r,c,u=0]=s;return uv(Number.isFinite(r)&&Number.isFinite(c)&&Number.isFinite(u)),WM(n,[r,c,u,1])}function Ky(s,n,r=0){let[c,u,d]=s;if(uv(Number.isFinite(c)&&Number.isFinite(u),"invalid pixel coordinate"),Number.isFinite(d))return WM(n,[c,u,d,1]);let b=WM(n,[c,u,0,1]),w=WM(n,[c,u,1,1]),_=b[2],x=w[2],T=_===x?0:((r||0)-_)/(x-_);return og.lerp([],b,w,T)}function mle(s){let{width:n,height:r,bounds:c,minExtent:u=0,maxZoom:d=24,offset:b=[0,0]}=s,[[w,_],[x,T]]=c,M=dQt(s.padding),L=ag([w,q$(T,-sB,sB)]),I=ag([x,q$(_,-sB,sB)]),D=[Math.max(Math.abs(I[0]-L[0]),u),Math.max(Math.abs(I[1]-L[1]),u)],F=[n-M.left-M.right-Math.abs(b[0])*2,r-M.top-M.bottom-Math.abs(b[1])*2];uv(F[0]>0&&F[1]>0);let O=F[0]/D[0],z=F[1]/D[1],Z=(M.right-M.left)/2/O,H=(M.top-M.bottom)/2/z,te=[(I[0]+L[0])/2+Z,(I[1]+L[1])/2+H],se=z1(te),ne=Math.min(d,X$(Math.abs(Math.min(O,z))));return uv(Number.isFinite(ne)),{longitude:se[0],latitude:se[1],zoom:ne}}function dQt(s=0){return typeof s=="number"?{top:s,bottom:s,left:s,right:s}:(uv(Number.isFinite(s.top)&&Number.isFinite(s.bottom)&&Number.isFinite(s.left)&&Number.isFinite(s.right)),s)}Bf();var wmt=Math.PI/180;function ble(s,n=0){let{width:r,height:c,unproject:u}=s,d={targetZ:n},b=u([0,c],d),w=u([r,c],d),_,x,T=s.fovy?.5*s.fovy*wmt:Math.atan(.5/s.altitude),M=(90-s.pitch)*wmt;return T>M-.01?(_=vmt(s,0,n),x=vmt(s,r,n)):(_=u([0,0],d),x=u([r,0],d)),[b,w,x,_]}function vmt(s,n,r){let{pixelUnprojectionMatrix:c}=s,u=WM(c,[n,0,1,1]),d=WM(c,[n,s.height,1,1]),w=(r*s.distanceScales.unitsPerMeter[2]-u[2])/(d[2]-u[2]),_=og.lerp([],u,d,w),x=z1(_);return x.push(r),x}var ymt=` +layout(std140) uniform shadowUniforms { + bool drawShadowMap; + bool useShadowMap; + vec4 color; + highp int lightId; + float lightCount; + mat4 viewProjectionMatrix0; + mat4 viewProjectionMatrix1; + vec4 projectCenter0; + vec4 projectCenter1; +} shadow; +`,mQt=` +const int max_lights = 2; + +out vec3 shadow_vPosition[max_lights]; + +vec4 shadow_setVertexPosition(vec4 position_commonspace) { + mat4 viewProjectionMatrices[max_lights]; + viewProjectionMatrices[0] = shadow.viewProjectionMatrix0; + viewProjectionMatrices[1] = shadow.viewProjectionMatrix1; + vec4 projectCenters[max_lights]; + projectCenters[0] = shadow.projectCenter0; + projectCenters[1] = shadow.projectCenter1; + + if (shadow.drawShadowMap) { + return project_common_position_to_clipspace(position_commonspace, viewProjectionMatrices[shadow.lightId], projectCenters[shadow.lightId]); + } + if (shadow.useShadowMap) { + for (int i = 0; i < max_lights; i++) { + if(i < int(shadow.lightCount)) { + vec4 shadowMap_position = project_common_position_to_clipspace(position_commonspace, viewProjectionMatrices[i], projectCenters[i]); + shadow_vPosition[i] = (shadowMap_position.xyz / shadowMap_position.w + 1.0) / 2.0; + } + } + } + return gl_Position; +} +`,bQt=` +${ymt} +${mQt} +`,wQt=` +const int max_lights = 2; +uniform sampler2D shadow_uShadowMap0; +uniform sampler2D shadow_uShadowMap1; + +in vec3 shadow_vPosition[max_lights]; + +const vec4 bitPackShift = vec4(1.0, 255.0, 65025.0, 16581375.0); +const vec4 bitUnpackShift = 1.0 / bitPackShift; +const vec4 bitMask = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0); + +float shadow_getShadowWeight(vec3 position, sampler2D shadowMap) { + vec4 rgbaDepth = texture(shadowMap, position.xy); + + float z = dot(rgbaDepth, bitUnpackShift); + return smoothstep(0.001, 0.01, position.z - z); +} + +vec4 shadow_filterShadowColor(vec4 color) { + if (shadow.drawShadowMap) { + vec4 rgbaDepth = fract(gl_FragCoord.z * bitPackShift); + rgbaDepth -= rgbaDepth.gbaa * bitMask; + return rgbaDepth; + } + if (shadow.useShadowMap) { + float shadowAlpha = 0.0; + shadowAlpha += shadow_getShadowWeight(shadow_vPosition[0], shadow_uShadowMap0); + if(shadow.lightCount > 1.0) { + shadowAlpha += shadow_getShadowWeight(shadow_vPosition[1], shadow_uShadowMap1); + } + shadowAlpha *= shadow.color.a / shadow.lightCount; + float blendedAlpha = shadowAlpha + color.a * (1.0 - shadowAlpha); + + return vec4( + mix(color.rgb, shadow.color.rgb, shadowAlpha / blendedAlpha), + blendedAlpha + ); + } + return color; +} +`,vQt=` +${ymt} +${wQt} +`,_Qt=Yy(MQt),yQt=Yy(TQt),xQt=[0,0,0,1],EQt=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];function SQt(s,n){let[r,c,u]=s,d=Ky([r,c,u],n);return Number.isFinite(u)?d:[d[0],d[1],0]}function MQt({viewport:s,center:n}){return new Df(s.viewProjectionMatrix).invert().transform(n)}function TQt({viewport:s,shadowMatrices:n}){let r=[],c=s.pixelUnprojectionMatrix,u=s.isGeospatial?void 0:1,d=[[0,0,u],[s.width,0,u],[0,s.height,u],[s.width,s.height,u],[0,0,-1],[s.width,0,-1],[0,s.height,-1],[s.width,s.height,-1]].map(b=>SQt(b,c));for(let b of n){let w=b.clone().translate(new cp(s.center).negate()),_=d.map(T=>w.transform(T)),x=new Df().ortho({left:Math.min(..._.map(T=>T[0])),right:Math.max(..._.map(T=>T[0])),bottom:Math.min(..._.map(T=>T[1])),top:Math.max(..._.map(T=>T[1])),near:Math.min(..._.map(T=>-T[2])),far:Math.max(..._.map(T=>-T[2]))});r.push(x.multiplyRight(b))}return r}function CQt(s){let{shadowEnabled:n=!0,project:r}=s;if(!n||!r||!s.shadowMatrices||!s.shadowMatrices.length)return{drawShadowMap:!1,useShadowMap:!1,shadow_uShadowMap0:s.dummyShadowMap,shadow_uShadowMap1:s.dummyShadowMap};let c=lv.getUniforms(r),u=_Qt({viewport:r.viewport,center:c.center}),d=[],b=yQt({shadowMatrices:s.shadowMatrices,viewport:r.viewport}).slice();for(let _=0;_0:!1,color:s.shadowColor||xQt,lightId:s.shadowLightId||0,lightCount:s.shadowMatrices.length,shadow_uShadowMap0:s.dummyShadowMap,shadow_uShadowMap1:s.dummyShadowMap};for(let _=0;_",lightId:"i32",lightCount:"f32",viewProjectionMatrix0:"mat4x4",viewProjectionMatrix1:"mat4x4",projectCenter0:"vec4",projectCenter1:"vec4"}};vm();var vle=10,J$=16777215;function Emt(s,n){s.length===vle?Bs.warn(`pickMultipleObjects can only exclude ${vle} previously picked objects for layers without picking buffers`)():s.push(n)}var AQt=` float disabledPickingIndexCount; + vec4 disabledPickingIndices0; + vec4 disabledPickingIndices1; + vec4 disabledPickingIndices2; +`;function xmt(s){return s.replace(` vec4 highlightColor; +} picking;`,` vec4 highlightColor; +${AQt}} picking;`)}function Pke(s,n){return[s[n]||0,s[n+1]||0,s[n+2]||0,s[n+3]||0]}var PQt=`vec3 picking_getPickingColorFromIndex(float objectIndex) { + if (objectIndex < 0.0 || objectIndex >= ${J$}.0) { + return vec3(0.0); + } + + for (int i = 0; i < ${vle}; i++) { + if (float(i) >= picking.disabledPickingIndexCount) { + break; + } + vec4 disabledIndices = i < 4 + ? picking.disabledPickingIndices0 + : (i < 8 ? picking.disabledPickingIndices1 : picking.disabledPickingIndices2); + float disabledIndex = disabledIndices[i - (i / 4) * 4]; + if (disabledIndex == objectIndex) { + return vec3(0.0); + } + } + + float encodedIndex = objectIndex + 1.0; + return vec3( + mod(encodedIndex, 256.0), + mod(floor(encodedIndex / 256.0), 256.0), + mod(floor(encodedIndex / 65536.0), 256.0) + ); +} + +vec3 picking_getPickingColorFromIndex(uint objectIndex) { + return picking_getPickingColorFromIndex(float(objectIndex)); +} + +vec3 picking_getPickingColorFromInstanceID() { + return picking_getPickingColorFromIndex(float(gl_InstanceID)); +} + +void picking_setPickingColorFromInstanceID() { + picking_setPickingColor(picking_getPickingColorFromInstanceID()); +} +`,LQt=`struct pickingUniforms { + isActive: f32, + isAttribute: f32, + isHighlightActive: f32, + useByteColors: f32, + highlightedObjectColor: vec3, + highlightColor: vec4, + disabledPickingIndexCount: f32, + disabledPickingIndices0: vec4, + disabledPickingIndices1: vec4, + disabledPickingIndices2: vec4, +}; + +@group(0) @binding(auto) var picking: pickingUniforms; + +fn picking_normalizeColor(color: vec3) -> vec3 { + return select(color, color / 255.0, picking.useByteColors > 0.5); +} + +fn picking_normalizeColor4(color: vec4) -> vec4 { + return select(color, color / 255.0, picking.useByteColors > 0.5); +} + +fn picking_isColorZero(color: vec3) -> bool { + return dot(color, vec3(1.0)) < 0.00001; +} + +fn picking_isColorValid(color: vec3) -> bool { + return dot(color, vec3(1.0)) > 0.00001; +} + +fn picking_getPickingColorFromIndex(objectIndex: u32) -> vec3 { + if (objectIndex >= ${J$}u) { + return vec3(0.0); + } + + for (var i = 0; i < ${vle}; i = i + 1) { + if (f32(i) >= picking.disabledPickingIndexCount) { + break; + } + let disabledIndices = select( + picking.disabledPickingIndices2, + select(picking.disabledPickingIndices1, picking.disabledPickingIndices0, i < 4), + i < 8 + ); + let disabledIndex = disabledIndices[i % 4]; + if (disabledIndex == f32(objectIndex)) { + return vec3(0.0); + } + } + + let encodedIndex = objectIndex + 1u; + return vec3( + f32(encodedIndex % 256u), + f32((encodedIndex / 256u) % 256u), + f32((encodedIndex / 65536u) % 256u) + ) / 255.0; +} +`,Jy={...$M,vs:`${xmt($M.vs)} +${PQt}`,fs:xmt($M.fs),source:LQt,uniformTypes:{...$M.uniformTypes,disabledPickingIndexCount:"f32",disabledPickingIndices0:"vec4",disabledPickingIndices1:"vec4",disabledPickingIndices2:"vec4"},defaultUniforms:{...$M.defaultUniforms,useByteColors:!0,disabledPickingIndexCount:0,disabledPickingIndices0:[0,0,0,0],disabledPickingIndices1:[0,0,0,0],disabledPickingIndices2:[0,0,0,0]},getUniforms(s,n){let r=$M.getUniforms(s,n),c=s.disabledPickingIndices||[];return r.disabledPickingIndexCount=c.length,r.disabledPickingIndices0=Pke(c,0),r.disabledPickingIndices1=Pke(c,4),r.disabledPickingIndices2=Pke(c,8),r},inject:{"vs:DECKGL_FILTER_GL_POSITION":` + // for picking depth values + picking_setPickingAttribute(position.z / position.w); + `,"vs:DECKGL_FILTER_COLOR":` + picking_setPickingColor(geometry.pickingColor); + `,"fs:DECKGL_FILTER_COLOR":{order:99,injection:` + // use highlight color if this fragment belongs to the selected object. + color = picking_filterHighlightColor(color); + + // use picking color if rendering to picking FBO. + color = picking_filterPickingColor(color); + `}}};var RQt=[ile],IQt=["vs:DECKGL_FILTER_SIZE(inout vec3 size, VertexGeometry geometry)","vs:DECKGL_FILTER_GL_POSITION(inout vec4 position, VertexGeometry geometry)","vs:DECKGL_FILTER_COLOR(inout vec4 color, VertexGeometry geometry)","fs:DECKGL_FILTER_COLOR(inout vec4 color, FragmentGeometry geometry)"],DQt=[];function Smt(s){let n=Mb.getDefaultShaderAssembler(s);for(let c of RQt)n.addDefaultModule(c);n._hookFunctions.length=0;let r=s==="glsl"?IQt:DQt;for(let c of r)n.addShaderHook(c);return n}var BQt=[255,255,255],OQt=1,NQt=0,_le=class{constructor(n={}){this.type="ambient";let{color:r=BQt}=n,{intensity:c=OQt}=n;this.id=n.id||`ambient-${NQt++}`,this.color=r,this.intensity=c}};Bf();var FQt=[255,255,255],UQt=1,zQt=[0,0,-1],GQt=0,Q$=class{constructor(n={}){this.type="directional";let{color:r=FQt}=n,{intensity:c=UQt}=n,{direction:u=zQt}=n,{_shadow:d=!1}=n;this.id=n.id||`directional-${GQt++}`,this.color=r,this.intensity=c,this.type="directional",this.direction=new cp(u).normalize().toArray(),this.shadow=d}getProjectedLight(n){return this}};Bf();var eV=class{constructor(n,r={id:"pass"}){let{id:c}=r;this.id=c,this.device=n,this.props={...r}}setProps(n){Object.assign(this.props,n)}render(n){}cleanup(){}};var jQt={depthWriteEnabled:!0,depthCompare:"less-equal",blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one-minus-src-alpha",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha"},L3=class extends eV{constructor(){super(...arguments),this._lastRenderIndex=-1}render(n){this._render(n)}_render(n){let{canvasContext:r=this.device.canvasContext}=n,c=n.target??r.getCurrentFramebuffer(),[u,d]=r.getDrawingBufferSize(),b=n.clearCanvas??!0,w=n.clearColor??(b?[0,0,0,0]:!1),_=b?1:!1,x=b?0:!1,T=n.colorMask??15,M={viewport:[0,0,u,d]};n.colorMask&&(M.colorMask=T),n.scissorRect&&(M.scissorRect=n.scissorRect);let{shaderModuleProps:L,viewports:I,views:D,onViewportActive:F,clearStack:O=!0}=n,z=n.pass||"unknown",Z=this.device.type==="webgpu";O&&(this._lastRenderIndex=-1);let H=[];if(!I.length)return this.device.beginRenderPass({framebuffer:c,parameters:M,clearColor:w,clearDepth:_,clearStencil:x}).end(),this.device.submit(),H;try{for(let te of I){F?.(te);let se=this._getDrawLayerParams(te,n),ne=D&&D[te.id],ue=te.subViewports||[te],Ce=Z?ue.map(Q=>[Q]):[ue];for(let Q of Ce){let me=this.device.beginRenderPass({framebuffer:c,parameters:M,clearColor:w,clearDepth:_,clearStencil:x});try{for(let tt of Q){let st=this._drawLayersInViewport(me,{target:c,canvasContext:r,shaderModuleProps:L,viewport:tt,view:ne,pass:z,layers:n.layers,isPicking:n.isPicking},se);H.push(st)}}finally{me.end(),Z&&this.device.submit()}w=!1,_=!1,x=!1}}return H}finally{Z||this.device.submit()}}_getDrawLayerParams(n,{layers:r,pass:c,isPicking:u=!1,layerFilter:d,cullRect:b,views:w,effects:_,canvasContext:x=this.device.canvasContext,shaderModuleProps:T},M=!1){let L=[],I=Tmt(this._lastRenderIndex+1),D={layer:r[0],viewport:n,isPicking:u,renderPass:c,cullRect:b},F={};for(let O=0;Ose/255):D===!1&&(z=!1),F!==void 0&&(Z=F),O!==void 0&&(H=O),this.device.beginRenderPass({framebuffer:d,parameters:{viewport:M,scissorRect:M},clearColor:z,clearDepth:Z,clearStencil:H}).end()}}let L={totalCount:r.length,visibleCount:0,compositeCount:0,pickableCount:0};n.setParameters({viewport:M});for(let I=0;I{let b=u.props._offset,w=u.id,_=u.parent&&u.parent.id,x;if(_&&!(_ in n)&&c(u.parent,!1),_ in r){let T=r[_]=r[_]||Tmt(n[_],n);x=T(u,d),r[w]=T}else Number.isFinite(b)?(x=b+(n[_]||0),r[w]=null):x=s;return d&&x>=s&&(s=x+1),n[w]=x,x};return c}function $Qt(s,{canvasContext:n=s.canvasContext,shaderModuleProps:r,target:c,viewport:u}){let d=r?.project?.devicePixelRatio??n.cssToDeviceRatio(),[,b]=n.getDrawingBufferSize(),w=c?c.height:b,_=u;return[_.x*d,w-(_.y+_.height)*d,_.width*d,_.height*d]}function Mmt(s,...n){for(let r of n)if(r)for(let c in r)s[c]?Object.assign(s[c],r[c]):s[c]=r[c];return s}var tV=class extends L3{constructor(n,r){super(n,r);let c=n.createTexture({format:"rgba8unorm",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),u=n.createTexture({format:"depth16unorm",width:1,height:1});this.fbo=n.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[c],depthStencilAttachment:u})}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null)}getShadowMap(){return this.fbo.colorAttachments[0].texture}render(n){let r=this.fbo,c=this.device.canvasContext.cssToDeviceRatio(),u=n.viewports[0],d=u.width*c,b=u.height*c,w=[1,1,1,1];(d!==r.width||b!==r.height)&&r.resize({width:d,height:b}),super.render({...n,clearColor:w,target:r,pass:"shadow"})}getLayerParameters(n,r,c){return{...n.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal"}}shouldDrawLayer(n){return n.props.shadowEnabled!==!1}getShaderModuleProps(n,r,c){return{shadow:{project:c.project,drawToShadowMap:!0}}}};var VQt={color:[255,255,255],intensity:1},Cmt=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],WQt=[0,0,0,200/255],aB=class{constructor(n={}){this.id="lighting-effect",this.shadowColor=WQt,this.shadow=!1,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.dummyShadowMap=null,this.setProps(n)}setup(n){this.context=n;let{device:r,deck:c}=n;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(r),c._addDefaultShaderModule(wle),this.dummyShadowMap=r.createTexture({width:1,height:1}))}setProps(n){this.ambientLight=void 0,this.directionalLights=[],this.pointLights=[];for(let r in n){let c=n[r];switch(c.type){case"ambient":this.ambientLight=c;break;case"directional":this.directionalLights.push(c);break;case"point":this.pointLights.push(c);break;default:}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(r=>r.shadow),this.context&&this.setup(this.context),this.props=n}preRender({layers:n,layerFilter:r,viewports:c,onViewportActive:u,views:d}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let b=0;bb.getShadowMap()),dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{},u={enabled:!0,lights:this._getLights(n)},d=n.props.material;return{shadow:c,lighting:u,phongMaterial:d,gouraudMaterial:d}}cleanup(n){for(let r of this.shadowPasses)r.delete();this.shadowPasses.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,n.deck._removeDefaultShaderModule(wle))}_calculateMatrices(){let n=[];for(let r of this.directionalLights){let c=new Df().lookAt({eye:new cp(r.direction).negate()});n.push(c)}return n}_createShadowPasses(n){for(let r=0;ru&&(d=u);let b=this._pool,w=n.BYTES_PER_ELEMENT*d,_=b.findIndex(x=>x.byteLength>=w);if(_>=0){let x=new n(b.splice(_,1)[0],0,d);return c&&x.fill(0),x}return new n(d)}_release(n){if(!ArrayBuffer.isView(n))return;let r=this._pool,{buffer:c}=n,{byteLength:u}=c,d=r.findIndex(b=>b.byteLength>=u);d<0?r.push(c):(d>0||r.lengththis.opts.poolSize&&r.shift()}},hv=new Lke;Bf();function lB(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function kke(s,n){let r=s%n;return r<0?n+r:r}function Pmt(s){return[s[12],s[13],s[14]]}function Lmt(s){return{left:cB(s[3]+s[0],s[7]+s[4],s[11]+s[8],s[15]+s[12]),right:cB(s[3]-s[0],s[7]-s[4],s[11]-s[8],s[15]-s[12]),bottom:cB(s[3]+s[1],s[7]+s[5],s[11]+s[9],s[15]+s[13]),top:cB(s[3]-s[1],s[7]-s[5],s[11]-s[9],s[15]-s[13]),near:cB(s[3]+s[2],s[7]+s[6],s[11]+s[10],s[15]+s[14]),far:cB(s[3]-s[2],s[7]-s[6],s[11]-s[10],s[15]-s[14])}}var Amt=new cp;function cB(s,n,r,c){Amt.set(s,n,r);let u=Amt.len();return{distance:c/u,normal:new cp(-s/u,-n/u,-r/u)}}function HQt(s){return s-Math.fround(s)}var nV;function uB(s,n){let{size:r=1,startIndex:c=0}=n,u=n.endIndex!==void 0?n.endIndex:s.length,d=(u-c)/r;nV=hv.allocate(nV,d,{type:Float32Array,size:r*2});let b=c,w=0;for(;bne.useInPicking),pass:I,canvasContext:F,isPicking:!0,shaderModuleProps:O,clearColor:z??[0,0,0,0],colorMask:15,scissorRect:H});return this._colorEncoderState=null,{decodePickingColor:Z&&Den.bind(null,Z),stats:te}}shouldDrawLayer(n){let{pickable:r,operation:c}=n.props;return r&&c.includes("draw")||c.includes("terrain")||c.includes("mask")}getShaderModuleProps(n,r,c){return{picking:{isActive:1,isAttribute:this.pickZ,disabledPickingIndices:n.internalState?.disabledPickingIndices},lighting:{enabled:!1}}}getLayerParameters(n,r,c){let u={...n.props.parameters},{pickable:d,operation:b}=n.props;return this._colorEncoderState?d&&b.includes("draw")?(Object.assign(u,Ien),u.blend=!0,this.device.type==="webgpu"?u.blendConstant=d1t(this._colorEncoderState,n,c):u.blendColor=d1t(this._colorEncoderState,n,c),b.includes("terrain")&&n.state?._hasPickingCover&&(u.blendAlphaSrcFactor="one")):b.includes("terrain")&&(u.blend=!1):u.blend=!1,u}_resetColorEncoder(n){return this._colorEncoderState=n?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}};function d1t(s,n,r){let{byLayer:c,byAlpha:u}=s,d,b=c.get(n);return b?(b.viewports.push(r),d=b.a):(d=c.size+1,d<=255?(b={a:d,layer:n,viewports:[r]},c.set(n,b),u[d]=b):(Bs.warn("Too many pickable layers, only picking the first 255")(),d=0)),[0,0,0,d/255]}function Den(s,n){let r=s.byAlpha[n[3]];return r&&{pickedLayer:r.layer,pickedViewports:r.viewports,pickedObjectIndex:r.layer.decodePickingColor(n)}}Jl();var qM={NO_STATE:"Awaiting state",MATCHED:"Matched. State transferred from previous layer",INITIALIZED:"Initialized",AWAITING_GC:"Discarded. Awaiting garbage collection",AWAITING_FINALIZATION:"No longer matched. Awaiting garbage collection",FINALIZED:"Finalized! Awaiting garbage collection"},bB=Symbol.for("component"),t2=Symbol.for("propTypes"),Cle=Symbol.for("deprecatedProps"),R3=Symbol.for("asyncPropDefaults"),n2=Symbol.for("asyncPropOriginal"),dv=Symbol.for("asyncPropResolved");function Ale(s,n=()=>!0){return Array.isArray(s)?p1t(s,n,[]):n(s)?[s]:[]}function p1t(s,n,r){let c=-1;for(;++c0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(n,r){if(n===this._data&&!r)return;this._data=n;let c=++this._loadCount,u=n;typeof n=="string"&&(u=BD(n)),u instanceof Promise?(this.isLoaded=!1,this._loader=u.then(d=>{this._loadCount===c&&(this.isLoaded=!0,this._error=void 0,this._content=d)}).catch(d=>{this._loadCount===c&&(this.isLoaded=!0,this._error=d||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=n);for(let d of this._subscribers)d.onChange(this.getData())}};var cV=class{constructor(n){this.protocol=n.protocol||"resource://",this._context={device:n.device,gl:n.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(n){return n.startsWith(this.protocol)?!0:n in this._resources}add({resourceId:n,data:r,forceUpdate:c=!1,persistent:u=!0}){let d=this._resources[n];d?d.setData(r,c):(d=new aV(n,r,this._context),this._resources[n]=d),d.persistent=u}remove(n){let r=this._resources[n];r&&(r.delete(),delete this._resources[n])}unsubscribe({consumerId:n}){let r=this._consumers[n];if(r){for(let c in r){let u=r[c],d=this._resources[u.resourceId];d&&d.unsubscribe(u)}delete this._consumers[n],this.prune()}}subscribe({resourceId:n,onChange:r,consumerId:c,requestId:u="default"}){let{_resources:d,protocol:b}=this;n.startsWith(b)&&(n=n.replace(b,""),d[n]||this.add({resourceId:n,data:null,persistent:!1}));let w=d[n];if(this._track(c,u,w,r),w)return w.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(let n in this._resources)this._resources[n].delete()}_track(n,r,c,u){let d=this._consumers,b=d[n]=d[n]||{},w=b[r],_=w&&w.resourceId&&this._resources[w.resourceId];_&&(_.unsubscribe(w),this.prune()),c&&(w?(w.onChange=u,w.resourceId=c.id):w={onChange:u,resourceId:c.id},b[r]=w,c.subscribe(w))}_prune(){this._pruneRequest=null;for(let n of Object.keys(this._resources)){let r=this._resources[n];!r.persistent&&!r.inUse()&&(r.delete(),delete this._resources[n])}}};var Ben="layerManager.setLayers",Oen="layerManager.activateViewport",lV=class{constructor(n,r){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=w=>{If(Oen,this,w),w&&(this.context.viewport=w)};let{deck:c,stats:u,viewport:d,timeline:b}=r||{};this.layers=[],this.resourceManager=new cV({device:n,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:n,gl:n?.gl,deck:c,shaderAssembler:Smt(n?.info?.shadingLanguage||"glsl"),defaultShaderModules:[fke],renderPass:void 0,stats:u||new yb({id:"deck.gl"}),viewport:d||new fB({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:b||new x4,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(let n of this.layers)this._finalizeLayer(n)}needsRedraw(n={clearRedrawFlags:!1}){let r=this._needsRedraw;n.clearRedrawFlags&&(this._needsRedraw=!1);for(let c of this.layers){let u=c.getNeedsRedraw(n);r=r||u}return r}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(n){this._needsRedraw=this._needsRedraw||n}setNeedsUpdate(n){this._needsUpdate=this._needsUpdate||n}getLayers({layerIds:n}={}){return n?this.layers.filter(r=>n.find(c=>r.id.indexOf(c)===0)):this.layers}setProps(n){"debug"in n&&(this._debug=n.debug),"userData"in n&&(this.context.userData=n.userData),"layers"in n&&(this._nextLayers=n.layers),"onError"in n&&(this.context.onError=n.onError)}setLayers(n,r){If(Ben,this,r,n),this._lastRenderedLayers=n;let c=Ale(n,Boolean);for(let u of c)u.context=this.context;this._updateLayers(this.layers,c)}updateLayers(){let n=this.needsUpdate();n&&(this.setNeedsRedraw(`updating layers: ${n}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,n)),this._nextLayers=null}addDefaultShaderModule(n){let{defaultShaderModules:r}=this.context;r.find(c=>c.name===n.name)||(r.push(n),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(n){let{defaultShaderModules:r}=this.context,c=r.findIndex(u=>u.name===n.name);c>=0&&(r.splice(c,1),this._defaultShaderModulesChanged=!0)}_handleError(n,r,c){c.raiseError(r,`${n} of ${c}`)}_updateLayers(n,r){let c={};for(let b of n)c[b.id]?Bs.warn(`Multiple old layers with same id ${b.id}`)():c[b.id]=b;if(this._defaultShaderModulesChanged){for(let b of n)b.setNeedsUpdate(),b.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}let u=[];this._updateSublayersRecursively(r,c,u),this._finalizeOldLayers(c);let d=!1;for(let b of u)if(b.hasUniformTransition()){d=`Uniform transition in ${b}`;break}this._needsUpdate=d,this.layers=u}_updateSublayersRecursively(n,r,c){for(let u of n){u.context=this.context;let d=r[u.id];d===null&&Bs.warn(`Multiple new layers with same id ${u.id}`)(),r[u.id]=null;let b=null;try{this._debug&&d!==u&&u.validateProps(),d?(this._transferLayerState(d,u),this._updateLayer(u)):this._initializeLayer(u),c.push(u),b=u.isComposite?u.getSubLayers():null}catch(w){this._handleError("matching",w,u)}b&&this._updateSublayersRecursively(b,r,c)}}_finalizeOldLayers(n){for(let r in n){let c=n[r];c&&this._finalizeLayer(c)}}_initializeLayer(n){try{n._initialize(),n.lifecycle=qM.INITIALIZED}catch(r){this._handleError("initialization",r,n)}}_transferLayerState(n,r){r._transferState(n),r.lifecycle=qM.MATCHED,r!==n&&(n.lifecycle=qM.AWAITING_GC)}_updateLayer(n){try{n._update()}catch(r){this._handleError("update",r,n)}}_finalizeLayer(n){this._needsRedraw=this._needsRedraw||`finalized ${n}`,n.lifecycle=qM.AWAITING_FINALIZATION;try{n._finalize(),n.lifecycle=qM.FINALIZED}catch(r){this._handleError("finalization",r,n)}}};function Cc(s,n,r){if(s===n)return!0;if(!r||!s||!n)return!1;if(Array.isArray(s)){if(!Array.isArray(n)||s.length!==n.length)return!1;for(let c=0;c{let c=!n.canvasId||this.getCanvasId(r.id)===n.canvasId,u=!("x"in n)||r.containsPixel(n);return c&&u}):this._viewports}getViews(){let n={};return this.views.forEach(r=>{n[r.id]=r}),n}getView(n){return this.views.find(r=>r.id===n)}getViewState(n){let r=typeof n=="string"?this.getView(n):n,c=r&&this.viewState[r.getViewStateId()]||this.viewState;return r?r.filterViewState(c):c}getViewport(n){return this._viewportMap[n]}getCanvasId(n){let r=typeof n=="string"?this.getView(n):n;return r?this._viewEventManagers[r.id]?.canvasId||this._getCanvasIdFromView(r):void 0}unproject(n,r){let c=this.getViewports(),u={x:n[0],y:n[1]};for(let d=c.length-1;d>=0;--d){let b=c[d];if(b.containsPixel(u)){let w=n.slice();return w[0]-=b.x,w[1]-=b.y,b.unproject(w,r)}}return null}setProps(n){n.views&&this._setViews(n.views),n.viewState&&this._setViewState(n.viewState),("width"in n||"height"in n)&&this._setSize(n.width,n.height),"pickPosition"in n&&(this._pickPosition=n.pickPosition),"eventManagers"in n&&this._setEventManagers(n.eventManagers||{}),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(n,r){(n!==this.width||r!==this.height)&&(this.width=n,this.height=r,this.setNeedsUpdate("Size changed"))}_setViews(n){n=Ale(n,Boolean),this._diffViews(n,this.views)&&this.setNeedsUpdate("views changed"),this.views=n}_setViewState(n){n?(!Cc(n,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=n):Bs.warn("missing `viewState` or `initialViewState`")()}_setEventManagers(n){this._eventManagers!==n&&(this._eventManagers=n,this.setNeedsUpdate("eventManagers changed"))}_getCanvasIdFromView(n){return n.props.canvasId||this._getCanvasContext?.(n.id)?.id||XM}_getCanvasDimensions(n){let r=this._getCanvasContext?.(n.id),[c,u]=r?.getCSSSize()||[this.width,this.height];return{width:c,height:u}}_getViewEventManager(n){let r=this.getCanvasId(n)||XM;return{canvasId:r,eventManager:this._eventManagers[r]||this._eventManager}}_startViewportRebuild(){let n=this.controllers,r=this._viewEventManagers;return this._viewports=[],this.controllers={},this._viewEventManagers={},{oldControllers:n,oldViewEventManagers:r}}_getReusableController(n,r,c){return n&&(r?.canvasId!==c.canvasId||r?.eventManager!==c.eventManager)?(n.finalize(),null):n}_createController(n,r){let c=r.type;return new c({timeline:this.timeline,eventManager:this._getViewEventManager(n).eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:d=>this.getView(n.id)?.makeViewport({viewState:d,...this._getCanvasDimensions(n)}),pickPosition:(d,b)=>this._pickPosition?.(d,b,n.id)})}_updateController(n,r,c,u){let d=n.controller;if(d&&c){let b={...r,...d,id:n.id,x:c.x,y:c.y,width:c.width,height:c.height};return(!u||u.constructor!==d.type)&&(u=this._createController(n,b)),u&&u.setProps(b),u}return null}_rebuildViewports(){let{views:n}=this,{oldControllers:r,oldViewEventManagers:c}=this._startViewportRebuild(),u=!1;for(let d=n.length;d--;){let b=n[d],{width:w,height:_}=this._getCanvasDimensions(b),x=this._getViewEventManager(b);this._viewEventManagers[b.id]=x;let T=this.getViewState(b),M=b.makeViewport({viewState:T,width:w,height:_}),L=this._getReusableController(r[b.id],c[b.id],x),I=!!b.controller;I&&!L&&(u=!0),(u||!I)&&L&&(L.finalize(),L=null),this.controllers[b.id]=this._updateController(b,T,M,L),M&&this._viewports.unshift(M)}for(let d in r){let b=r[d];b&&!this.controllers[d]&&b.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(n=>{n.id&&(this._viewportMap[n.id]=this._viewportMap[n.id]||n)})}_diffViews(n,r){return n.length!==r.length?!0:n.some((c,u)=>!n[u].equals(r[u]))}};var Nen=/^(?:\d+\.?\d*|\.\d+)$/;function _m(s){switch(typeof s){case"number":if(!Number.isFinite(s))throw new Error(`Could not parse position string ${s}`);return{type:"literal",value:s};case"string":try{let n=Fen(s);return new Hke(n).parseExpression()}catch(n){let r=n instanceof Error?n.message:String(n);throw new Error(`Could not parse position string ${s}: ${r}`)}default:throw new Error(`Could not parse position string ${s}`)}}function Wke(s,n){switch(s.type){case"literal":return s.value;case"percentage":return Math.round(s.value*n);case"binary":let r=Wke(s.left,n),c=Wke(s.right,n);return s.operator==="+"?r+c:r-c;default:throw new Error("Unknown layout expression type")}}function ym(s,n){return Wke(s,n)}function Fen(s){let n=[],r=0;for(;r="0"&&s<="9"}function b1t(s){return s>="a"&&s<="z"||s>="A"&&s<="Z"}function Uen(s){return!!(s&&s.type==="symbol"&&(s.value==="+"||s.value==="-"))}function w1t(s,n){let r={...s};for(let c in n)c!=="id"&&(Array.isArray(r[c])&&Array.isArray(n[c])?r[c]=zen(r[c],n[c]):r[c]=n[c]);return r}function zen(s,n){s=s.slice();for(let r=0;r{},_1t={mode:"preserve"},Gen={mode:"hard"},qke={BREAK:1,SNAP_TO_END:2,IGNORE:3},jen=s=>s,$en=qke.BREAK,fV=class{constructor(n){this._onTransitionUpdate=r=>{let{time:c,settings:{interpolator:u,startProps:d,endProps:b,duration:w,easing:_}}=r,x=_(c/w),T=u.interpolateProps(d,b,x);this.propsInTransition=this.getControllerState({...this.props,...T},_1t).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=n.getControllerState,this.propsInTransition=null,this.transition=new pv(n.timeline),this.onViewStateChange=n.onViewStateChange||v1t,this.onStateChange=n.onStateChange||v1t}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(n){let r=!1,c=this.props;if(this.props=n,!c||this._shouldIgnoreViewportChange(c,n))return!1;if(this._isTransitionEnabled(n)){let u=c;if(this.transition.inProgress){let{interruption:d,endProps:b}=this.transition.settings;u={...c,...d===qke.SNAP_TO_END?b:this.propsInTransition||c}}this._triggerTransition(u,n),r=!0}else this.transition.cancel();return r}updateTransition(){this.transition.update()}_isTransitionEnabled(n){let{transitionDuration:r,transitionInterpolator:c}=n;return(r>0||r==="auto")&&!!c}_isUpdateDueToCurrentTransition(n){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(n,this.propsInTransition):!1}_shouldIgnoreViewportChange(n,r){return this.transition.inProgress?this.transition.settings.interruption===qke.IGNORE||this._isUpdateDueToCurrentTransition(r):this._isTransitionEnabled(r)?r.transitionInterpolator.arePropsEqual(n,r):!0}_triggerTransition(n,r){let c=this.getControllerState(n,_1t),u=this.getControllerState(r,Gen).shortestPathFrom(c),d=r.transitionInterpolator,b=d.getDuration?d.getDuration(n,r):r.transitionDuration;if(b===0)return;let w=d.initializeProps(n,u);this.propsInTransition={};let _={duration:b,easing:r.transitionEasing||jen,interpolator:d,interruption:r.transitionInterruption||$en,startProps:w.start,endProps:w.end,onStart:r.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(r.onTransitionInterrupt),onEnd:this._onTransitionEnd(r.onTransitionEnd)};this.transition.start(_),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(n){return r=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),n?.(r)}}};Bf();function Pa(s,n){if(!s)throw new Error(n||"deck.gl: assertion failed.")}var hV=class{constructor(n){let{compare:r,extract:c,required:u}=n;this._propsToCompare=r,this._propsToExtract=c||r,this._requiredProps=u}arePropsEqual(n,r){for(let c of this._propsToCompare)if(!(c in n)||!(c in r)||!Wy(n[c],r[c]))return!1;return!0}initializeProps(n,r){let c={},u={};for(let d of this._propsToExtract)(d in n||d in r)&&(c[d]=n[d],u[d]=r[d]);return this._checkRequiredProps(c),this._checkRequiredProps(u),{start:c,end:u}}getDuration(n,r){return r.transitionDuration}_checkRequiredProps(n){this._requiredProps&&this._requiredProps.forEach(r=>{let c=n[r];Pa(Number.isFinite(c)||Array.isArray(c),`${r} is required for transition`)})}};Bf();var Ven=["longitude","latitude","zoom","bearing","pitch"],Wen=["longitude","latitude","zoom"],I3=class extends hV{constructor(n={}){let r=Array.isArray(n)?n:n.transitionProps,c=Array.isArray(n)?{}:n;c.transitionProps=Array.isArray(r)?{compare:r,required:r}:r||{compare:Ven,required:Wen},super(c.transitionProps),this.opts=c}initializeProps(n,r){let c=super.initializeProps(n,r),{makeViewport:u,around:d}=this.opts;if(u&&d){let b=u(n),w=u(r),_=b.unproject(d);c.start.around=d,Object.assign(c.end,{around:w.project(_),aroundPosition:_,width:r.width,height:r.height})}return c}interpolateProps(n,r,c){let u={};for(let d of this._propsToExtract)u[d]=av(n[d]||0,r[d]||0,c);if(r.aroundPosition&&this.opts.makeViewport){let d=this.opts.makeViewport({...r,...u});Object.assign(u,d.panByPosition(r.aroundPosition,av(n.around,r.around,c)))}return u}};var i2={transitionDuration:0},Hen=300,qen=300,Xke=s=>1-(1-s)*(1-s),Xen=s=>s===1?1:1-Math.pow(2,-10*s),M4={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],MULTI_PAN:["multipanstart","multipanmove","multipanend"],DOUBLE_CLICK:["dblclick"],DOUBLE_CLICK_DRAG:["dblclickdragstart","dblclickdragmove","dblclickdragend","dblclickdragcancel"],KEYBOARD:["keydown"]},T4={},C4=class{constructor(n){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this._multiPanMode=null,this._multiPanStartCenter=null,this._doubleClickDragAnchor=null,this._suppressDoubleClickUntil=0,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.doubleClickDragZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.multiTouchDrag=null,this.trackpadGesture=!1,this.zoomAround="pointer",this.keyboard=!0,this.transitionManager=new fV({...n,getControllerState:(r,c)=>new this.ControllerState({...r,constraintContext:c,makeViewport:n.makeViewport}),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=n.eventManager,this.onViewStateChange=n.onViewStateChange||(()=>{}),this.onStateChange=n.onStateChange||(()=>{}),this.makeViewport=n.makeViewport,this.pickPosition=n.pickPosition}set events(n){this.toggleEvents(this._customEvents,!1),this.toggleEvents(n,!0),this._customEvents=n,this.props&&this.setProps(this.props)}finalize(){for(let n in this._events)this._events[n]&&this.eventManager?.off(n,this.handleEvent);this.transitionManager.finalize()}handleEvent(n){this._controllerState=void 0;let r=this._eventStartBlocked;switch(n.type){case"panstart":return r?!1:this._onPanStart(n);case"panmove":return this._onPan(n);case"panend":return this._onPanEnd(n);case"pinchstart":return r||!this._isTrackpadGestureAllowed(n)?!1:this._onPinchStart(n);case"pinchmove":return this._isTrackpadGestureAllowed(n)?this._onPinch(n):!1;case"pinchend":return this._isTrackpadGestureAllowed(n)?this._onPinchEnd(n):!1;case"multipanstart":return r?!1:this._onMultiPanStart(n);case"multipanmove":return this._onMultiPan(n);case"multipanend":return this._onMultiPanEnd(n);case"dblclick":return this._onDoubleClick(n);case"dblclickdragstart":return r?!1:this._onDoubleClickDragStart(n);case"dblclickdragmove":return this._onDoubleClickDrag(n);case"dblclickdragend":case"dblclickdragcancel":return this._onDoubleClickDragEnd(n);case"wheel":return this._onWheel(n);case"keydown":return this._onKeyDown(n);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(n){let{x:r,y:c}=this.props,{offsetCenter:u}=n;return[u.x-r,u.y-c]}getZoomPosition(n){if(this.zoomAround==="pointer")return n;let r=this.makeViewport(this.controllerState.getViewportProps()),[c,u]=HM(r.center,r.pixelProjectionMatrix);return[c,u]}isPointInBounds(n,r){let{width:c,height:u}=this.props;if(r&&r.handled)return!1;let d=n[0]>=0&&n[0]<=c&&n[1]>=0&&n[1]<=u;return d&&r&&r.stopPropagation(),d}isFunctionKeyPressed(n){let{srcEvent:r}=n;return!!(r.metaKey||r.altKey||r.ctrlKey||r.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(n){let r=setTimeout(()=>{this._eventStartBlocked===r&&(this._eventStartBlocked=null)},n);this._eventStartBlocked=r}setProps(n){n.maxBoundsPadding===void 0&&(n.maxBoundsPadding=null),n.dragMode&&(this.dragMode=n.dragMode);let r=this.props;this.props=n,"transitionInterpolator"in n||(n.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(n);let{inertia:c}=n;this.inertia=Number.isFinite(c)?c:c===!0?Hen:0;let{scrollZoom:u=!0,dragPan:d=!0,dragRotate:b=!0,doubleClickZoom:w=!0,doubleClickDragZoom:_=!1,touchZoom:x=!0,touchRotate:T=!1,multiTouchDrag:M=T?"rotate":null,trackpadGesture:L=!1,zoomAround:I="pointer",keyboard:D=!0}=n,F=!!this.onViewStateChange;if(this.toggleEvents(M4.WHEEL,F&&u),this.toggleEvents(M4.PAN,F),this.toggleEvents(M4.PINCH,F&&(x||M==="rotate")),this.toggleEvents(M4.MULTI_PAN,F&&!!M),this.toggleEvents(M4.DOUBLE_CLICK,F&&w),this.toggleEvents(M4.DOUBLE_CLICK_DRAG,F&&_),this.toggleEvents(M4.KEYBOARD,F&&D),this.scrollZoom=u,this.dragPan=d,this.dragRotate=b,this.doubleClickZoom=w,this.doubleClickDragZoom=_,this.touchZoom=x,this.touchRotate=M==="rotate",this.multiTouchDrag=M,this.trackpadGesture=L,this.zoomAround=I,this.keyboard=D,(!r||r.height!==n.height||r.width!==n.width||r.maxBounds!==n.maxBounds||r.maxBoundsPadding!==n.maxBoundsPadding)&&n.maxBounds){let z=new this.ControllerState({...n,makeViewport:this.makeViewport}),Z=z.getViewportProps();Object.keys(Z).some(te=>!Cc(Z[te],n[te],1))&&this.updateViewport(z)}}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(n,r){this.eventManager&&n.forEach(c=>{this._events[c]!==r&&(this._events[c]=r,r?this.eventManager.on(c,this.handleEvent):this.eventManager.off(c,this.handleEvent))})}updateViewport(n,r=null,c={}){let u={...n.getViewportProps(),...r},d=this.controllerState!==n;if(this.state=n.getState(),this._setInteractionState(c),d){let b=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:u,interactionState:this._interactionState,oldViewState:b,viewId:this.props.id})}}_onTransition(n){this.onViewStateChange({...n,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(n){Object.assign(this._interactionState,n),this.onStateChange(this._interactionState)}_getConstraintContext(n,r){return this.props.rubberBand?{mode:r==="update"?"elastic":r==="end"?"rebound":"hard"}:{mode:"hard"}}_getReboundTransition(n,r){if(n.mode!=="rebound")return null;let c=r.getViewportProps();return Object.keys(c).some(d=>!Cc(this.props[d],c[d],1))?{...this._getTransitionProps(),transitionDuration:qen,transitionEasing:Xen}:null}_onPanStart(n){let r=this.getCenter(n);if(!this.isPointInBounds(r,n))return!1;let c=this.isFunctionKeyPressed(n)||n.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(c=!c);let u=c?"pan":"rotate",d=this._getConstraintContext(u,"start"),b=c?this.controllerState.panStart({pos:r},d):this.controllerState.rotateStart({pos:r},d);return this._panMove=c,this.updateViewport(b,i2,{isDragging:!0}),!0}_onPan(n){return this.isDragging()?this._panMove?this._onPanMove(n):this._onPanRotate(n):!1}_onPanEnd(n){return this.isDragging()?this._panMove?this._onPanMoveEnd(n):this._onPanRotateEnd(n):!1}_onPanMove(n){if(!this.dragPan)return!1;let r=this.getCenter(n),c=this.controllerState.pan({pos:r},this._getConstraintContext("pan","update"));return this.updateViewport(c,i2,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(n){let{inertia:r}=this;if(this.dragPan&&r&&n.velocity){let c=this.getCenter(n),u=[c[0]+n.velocityX*r/2,c[1]+n.velocityY*r/2],d=this.controllerState.pan({pos:u}).panEnd();this.updateViewport(d,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Xke},{isDragging:!1,isPanning:!0})}else{let c=this.controllerState,u=this._getConstraintContext("pan","end"),d=c.panEnd(u),b=this._getReboundTransition(u,d);this.updateViewport(d,b,{isDragging:!1,isPanning:!!b})}return!0}_onPanRotate(n){if(!this.dragRotate)return!1;let r=this.getCenter(n),c=this.controllerState.rotate({pos:r},this._getConstraintContext("rotate","update"));return this.updateViewport(c,i2,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(n){let{inertia:r}=this;if(this.dragRotate&&r&&n.velocity){let c=this.getCenter(n),u=[c[0]+n.velocityX*r/2,c[1]+n.velocityY*r/2],d=this.controllerState.rotate({pos:u}).rotateEnd();this.updateViewport(d,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Xke},{isDragging:!1,isRotating:!0})}else{let c=this.controllerState,u=this._getConstraintContext("rotate","end"),d=c.rotateEnd(u),b=this._getReboundTransition(u,d);this.updateViewport(d,b,{isDragging:!1,isRotating:!!b})}return!0}_onWheel(n){if(!this.scrollZoom||this.trackpadGesture&&n.device!=="mouse")return!1;let r=this.getCenter(n);if(!this.isPointInBounds(r,n))return!1;n.srcEvent.preventDefault();let{speed:c=.01,smooth:u=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:d}=n,b=2/(1+Math.exp(-Math.abs(d*c)));d<0&&b!==0&&(b=1/b);let w=this.getZoomPosition(r),_=u?{...this._getTransitionProps({around:w}),transitionDuration:250}:i2,x=this.controllerState.zoom({pos:w,scale:b});return this.updateViewport(x,_,{isZooming:!0,isPanning:!0}),u||this._setInteractionState({isZooming:!1,isPanning:!1}),!0}_onMultiPanStart(n){let{multiTouchDrag:r}=this;if(!r||!this._isMultiPanEventAllowed(n,r))return!1;let c=n.offsetCenter;if(!this.isPointInBounds(this.getCenter(n),n))return!1;let u=n.pointerType==="trackpad",d={x:c.x-(u?0:n.deltaX),y:c.y-(u?0:n.deltaY)},b={...n,offsetCenter:d},w=this.getCenter(b),_=r==="pan"?this.controllerState.panStart({pos:w},this._getConstraintContext("pan","start")):this.controllerState.rotateStart({pos:w},this._getConstraintContext("rotate","start"));return this._multiPanMode=r,this._multiPanStartCenter=d,this.updateViewport(_,i2,{isDragging:!0}),!0}_onMultiPan(n){let{mode:r,event:c}=this._getMultiPanEvent(n);return!r||!c||!this.isDragging()?!1:r==="pan"?this._onPanMove(c):this._onPanRotate(c)}_onMultiPanEnd(n){let{mode:r,event:c}=this._getMultiPanEvent(n);if(!r||!c||!this.isDragging())return this._resetMultiPan(),!1;let u=r==="pan"?this._onPanMoveEnd(c):this._onPanRotateEnd(c);return this._resetMultiPan(),u}_isTrackpadGestureAllowed(n){return n.pointerType!=="trackpad"||this.trackpadGesture}_isMultiPanEventAllowed(n,r){return n.pointerType==="trackpad"?this.trackpadGesture&&(r==="pan"?this.dragPan:this.dragRotate):n.pointerType==="touch"&&(r==="pan"?this.dragPan:this.dragRotate)}_getMultiPanEvent(n){let r=this._multiPanMode,c=this._multiPanStartCenter;return!r||!c?{mode:null,event:null}:{mode:r,event:{...n,offsetCenter:{x:c.x+n.deltaX,y:c.y+n.deltaY}}}}_resetMultiPan(){this._multiPanMode=null,this._multiPanStartCenter=null}_onPinchStart(n){this._doubleClickDragAnchor=null;let r=this.getCenter(n);if(!this.isPointInBounds(r,n))return!1;let c=this.controllerState.zoomStart({pos:this.getZoomPosition(r)},this._getConstraintContext("zoom","start")).rotateStart({pos:r},this._getConstraintContext("rotate","start"));return T4._startPinchRotation=n.rotation,T4._lastPinchEvent=n,this.updateViewport(c,i2,{isDragging:!0}),!0}_onPinch(n){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let r=this.controllerState;if(this.touchZoom){let{scale:c}=n,u=this.getCenter(n);r=r.zoom({pos:this.getZoomPosition(u),scale:c},this._getConstraintContext("zoom","update"))}if(this.touchRotate){let{rotation:c}=n;r=r.rotate({deltaAngleX:T4._startPinchRotation-c},this._getConstraintContext("rotate","update"))}return this.updateViewport(r,i2,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),T4._lastPinchEvent=n,!0}_onPinchEnd(n){if(!this.isDragging())return!1;let{inertia:r}=this,{_lastPinchEvent:c}=T4;if(this.touchZoom&&r&&c&&n.scale!==c.scale){let u=this.getCenter(n),d=this.getZoomPosition(u),b=this.controllerState.rotateEnd(),w=Math.log2(n.scale),_=(w-Math.log2(c.scale))/(n.deltaTime-c.deltaTime),x=Math.pow(2,w+_*r/2);b=b.zoom({pos:d,scale:x}).zoomEnd(),this.updateViewport(b,{...this._getTransitionProps({around:d}),transitionDuration:r,transitionEasing:Xke},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(r)}else{let u=this.controllerState,d=this._getConstraintContext("zoom","end"),b=this._getConstraintContext("rotate","end"),w=u.zoomEnd(d).rotateEnd(b),_=this._getReboundTransition(this.touchZoom?d:b,w);this.updateViewport(w,_,{isDragging:!1,isPanning:!!_&&this.touchZoom,isZooming:!!_&&this.touchZoom,isRotating:!!_&&this.touchRotate})}return T4._startPinchRotation=null,T4._lastPinchEvent=null,!0}_onDoubleClick(n){if(!this.doubleClickZoom||Date.now()90&&(n=Math.sign(n)*90),Number.isFinite(s)){let[c,u]=ag([s,n]);return[c,Zl(u,0,x1t)]}let[,r]=ag([0,n]);return[s,Zl(r,0,x1t)]}var Yke=class extends A4{constructor(n){let{width:r,height:c,latitude:u,longitude:d,zoom:b,bearing:w=0,pitch:_=0,altitude:x=1.5,position:T=[0,0,0],maxZoom:M=20,minZoom:L=0,maxPitch:I=60,minPitch:D=0,startPanLngLat:F,startZoomLngLat:O,startRotatePos:z,startRotateLngLat:Z,startBearing:H,startPitch:te,startZoom:se,normalize:ne=!0,rubberBand:ue=!1}=n,{[Lb]:Ce}=n;Pa(Number.isFinite(d)),Pa(Number.isFinite(u)),Pa(Number.isFinite(b));let Q=n.maxBounds||(ne?E1t:null),me=n.maxBoundsPadding||null;super({width:r,height:c,latitude:u,longitude:d,zoom:b,bearing:w,pitch:_,altitude:x,maxZoom:M,minZoom:L,maxPitch:I,minPitch:D,normalize:ne,position:T,maxBounds:Q,maxBoundsPadding:me,rubberBand:ue,[Lb]:Ce},{startPanLngLat:F,startZoomLngLat:O,startRotatePos:z,startRotateLngLat:Z,startBearing:H,startPitch:te,startZoom:se},n.makeViewport,n.constraintContext),this.getAltitude=n.getAltitude}panStart({pos:n},r){return this._getUpdatedState({startPanLngLat:this._unproject(n)},r)}pan({pos:n,startPos:r},c){let u=this.getState().startPanLngLat||this._unproject(r);if(!u)return this;let b=this.makeViewport(this.getViewportProps()).panByPosition(u,n);return this._getUpdatedState(b,c)}panEnd(n){return this._getUpdatedState({startPanLngLat:null},n)}rotateStart({pos:n}){let r=this.getAltitude?.(n);return this._getUpdatedState({startRotatePos:n,startRotateLngLat:r!==void 0?this._unproject3D(n,r):void 0,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:n,deltaAngleX:r=0,deltaAngleY:c=0}){let{startRotatePos:u,startRotateLngLat:d,startBearing:b,startPitch:w}=this.getState();if(!u||b===void 0||w===void 0)return this;let _;if(n?_=this._getNewRotation(n,u,w,b):_={bearing:b+r,pitch:w+c},d){let x=this.makeViewport({...this.getViewportProps(),..._}),T="panByPosition3D"in x?"panByPosition3D":"panByPosition";return this._getUpdatedState({..._,...x[T](d,u)})}return this._getUpdatedState(_)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startRotateLngLat:null,startBearing:null,startPitch:null})}zoomStart({pos:n},r){return this._getUpdatedState({startZoomLngLat:this._unproject(n),startZoom:this.getViewportProps().zoom},r)}zoom({pos:n,startPos:r,scale:c},u){let{startZoom:d,startZoomLngLat:b}=this.getState();return b||(d=this.getViewportProps().zoom,b=this._unproject(r)||this._unproject(n)),b?this._getUpdatedState({zoom:d+Math.log2(c),[Lb]:{position:b,screenPosition:n}},u):this}zoomEnd(n){return this._getUpdatedState({startZoomLngLat:null,startZoom:null},n)}zoomIn(n=2,r){return this._zoomFromCenter(n,r)}zoomOut(n=2,r){return this._zoomFromCenter(1/n,r)}moveLeft(n=100,r){return this._panFromCenter([n,0],r)}moveRight(n=100,r){return this._panFromCenter([-n,0],r)}moveUp(n=100,r){return this._panFromCenter([0,n],r)}moveDown(n=100,r){return this._panFromCenter([0,-n],r)}rotateLeft(n=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-n})}rotateRight(n=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+n})}rotateUp(n=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+n})}rotateDown(n=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-n})}shortestPathFrom(n){let r=n.getViewportProps(),c={...this.getViewportProps()},{bearing:u,longitude:d}=c;return Math.abs(u-r.bearing)>180&&(c.bearing=u<0?u+360:u-360),Math.abs(d-r.longitude)>180&&(c.longitude=d<0?d+360:d-360),c}applyConstraints(n,r){let c=n,u=c[Lb];delete c[Lb];let{maxPitch:d,minPitch:b,pitch:w,bearing:_,normalize:x,maxBounds:T,rubberBand:M}=n;x&&(_<-180||_>180)&&(n.bearing=kke(_+180,360)-180),n.pitch=Zl(w,b,d);let L=this._constrainZoom(n.zoom,n),I=M&&r?.mode==="elastic";if(n.zoom=r?.mode==="preserve"?n.zoom:I?YM(n.zoom,L,Zen):L,u){let D=this.makeViewport(n);Object.assign(n,D.panByPosition(u.position,u.screenPosition))}if(x&&(n.longitude<-180||n.longitude>180)&&(n.longitude=kke(n.longitude+180,360)-180),T){let D=wB(n.width,n.height,n.maxBoundsPadding),F=this.makeViewport({...n,bearing:0,pitch:0}),O=Ple(F,[n.longitude,n.latitude],D),z=dV(T[0]),Z=dV(T[1]),H=2**n.zoom,te=[z[0]+O.left/H,z[1]+O.bottom/H],se=[Z[0]-O.right/H,Z[1]-O.top/H],ne=dV([n.longitude,n.latitude]),ue=[Zl(ne[0],te[0],se[0]),Zl(ne[1],te[1],se[1])],Ce=ne.slice();if(D.width>=0&&(Ce[0]=r?.mode==="preserve"?ne[0]:I?YM(ne[0],ue[0],D.width/2/H):ue[0]),D.height>=0&&(Ce[1]=r?.mode==="preserve"?ne[1]:I?YM(ne[1],ue[1],D.height/2/H):ue[1]),Ce[0]!==ne[0]||Ce[1]!==ne[1]){let[Q,me]=z1(Ce);Ce[0]!==ne[0]&&(n.longitude=Q),Ce[1]!==ne[1]&&(n.latitude=me)}}return n}_constrainZoom(n,r){r||(r=this.getViewportProps());let{maxZoom:c,maxBounds:u}=r,d=u!==null&&r.width>0&&r.height>0,{minZoom:b}=r;if(d){let w=wB(r.width,r.height,r.maxBoundsPadding),_=dV(u[0]),x=dV(u[1]),T=x[0]-_[0],M=x[1]-_[1];w.width>0&&Number.isFinite(T)&&T>0&&(b=Math.max(b,Math.log2(w.width/T))),w.height>0&&Number.isFinite(M)&&M>0&&(b=Math.max(b,Math.log2(w.height/M))),b>c&&(b=c)}return Zl(n,b,c)}_zoomFromCenter(n,r){let{width:c,height:u}=this.getViewportProps();return this.zoom({pos:[c/2,u/2],scale:n},r)}_panFromCenter(n,r){let{width:c,height:u}=this.getViewportProps();return this.pan({startPos:[c/2,u/2],pos:[c/2+n[0],u/2+n[1]]},r)}_getUpdatedState(n,r){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...n,constraintContext:r})}_unproject(n){let r=this.makeViewport(this.getViewportProps());return n&&r.unproject(n)}_unproject3D(n,r){return this.makeViewport(this.getViewportProps()).unproject(n,{targetZ:r})}_getNewRotation(n,r,c,u){let d=n[0]-r[0],b=n[1]-r[1],w=n[1],_=r[1],{width:x,height:T}=this.getViewportProps(),M=d/x,L=0;b>0?Math.abs(T-_)>y1t&&(L=b/(_-T)*Yen):b<0&&_>y1t&&(L=1-w/_),L=Zl(L,-1,1);let{minPitch:I,maxPitch:D}=this.getViewportProps(),F=u+180*M,O=c;return L>0?O=c+L*(D-c):L<0&&(O=c-L*(I-c)),{pitch:O,bearing:F}}},pV=class extends C4{constructor(){super(...arguments),this.ControllerState=Yke,this.transition={transitionDuration:300,transitionInterpolator:new I3({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan",this.rotationPivot="center",this._getAltitude=n=>{if(this.rotationPivot==="2d")return 0;if(this.rotationPivot==="3d"&&this.pickPosition){let{x:r,y:c}=this.props,u=this.pickPosition(r+n[0],c+n[1]);if(u&&u.coordinate&&u.coordinate.length>=3)return u.coordinate[2]}}}setProps(n){"rotationPivot"in n&&(this.rotationPivot=n.rotationPivot||"center"),n.getAltitude=this._getAltitude,n.position=n.position||[0,0,0],n.maxBounds=n.maxBounds||(n.normalize===!1?null:E1t),super.setProps(n)}updateViewport(n,r=null,c={}){let u=n.getState();c.isDragging&&u.startRotateLngLat?c={...c,rotationPivotPosition:u.startRotateLngLat}:c.isDragging===!1&&(c={...c,rotationPivotPosition:void 0}),super.updateViewport(n,r,c)}};var Lle=class extends S4{constructor(n={}){super(n)}getViewportType(){return k3}get ControllerType(){return pV}};Lle.displayName="MapView";var S1t=Lle;var Ken=new aB;function Jen(s,n){let r=s.order??1/0,c=n.order??1/0;return r-c}var gV=class{constructor(n){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=n,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(n){let r=this._defaultEffects;if(!r.find(c=>c.id===n.id)){let c=r.findIndex(u=>Jen(u,n)>0);c<0?r.push(n):r.splice(c,0,n),n.setup(this._context),this._setEffects(this.effects)}}setProps(n){"effects"in n&&(Cc(n.effects,this.effects,1)||this._setEffects(n.effects))}needsRedraw(n={clearRedrawFlags:!1}){let r=this._needsRedraw;return n.clearRedrawFlags&&(this._needsRedraw=!1),r}getEffects(){return this._resolvedEffects}_setEffects(n){let r={};for(let u of this.effects)r[u.id]=u;let c=[];for(let u of n){let d=r[u.id],b=u;d&&d!==u?d.setProps?(d.setProps(u.props),b=d):d.cleanup(this._context):d||u.setup(this._context),c.push(b),delete r[u.id]}for(let u in r)r[u].cleanup(this._context);this.effects=c,this._resolvedEffects=c.concat(this._defaultEffects),n.some(u=>u instanceof aB)||this._resolvedEffects.push(Ken),this._needsRedraw="effects changed"}finalize(){for(let n of this._resolvedEffects)n.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}};var mV=class extends L3{shouldDrawLayer(n){let{operation:r}=n.props;return r.includes("draw")||r.includes("terrain")}render(n){return this._render(n)}};var Qen="deckRenderer.renderLayers",bV=class{constructor(n,r={}){this.device=n,this.stats=r.stats,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new mV(n),this.pickLayersPass=new E4(n),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(n){this.layerFilter!==n.layerFilter&&(this.layerFilter=n.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==n.drawPickingColors&&(this.drawPickingColors=n.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(n){let r=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,c={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...n};if(!n.viewports.length){let w=r.render(c),_="stats"in w?w.stats:w;this._updateStats(_);return}c.effects&&this._preRender(c.effects,c);let u=this.lastPostProcessEffect?this.renderBuffers[0]:c.target;this.lastPostProcessEffect&&(c.clearColor=[0,0,0,0],c.clearCanvas=!0);let d=r.render({...c,target:u}),b="stats"in d?d.stats:d;c.effects&&(this.lastPostProcessEffect&&(c.clearCanvas=n.clearCanvas===void 0?!0:n.clearCanvas),this._postRender(c.effects,c)),this.renderCount++,If(Qen,this,b,n),this._updateStats(b)}needsRedraw(n={clearRedrawFlags:!1}){let r=this._needsRedraw;return n.clearRedrawFlags&&(this._needsRedraw=!1),r}finalize(){let{renderBuffers:n}=this;for(let r of n)r.delete();n.length=0}_updateStats(n){if(!this.stats)return;let r=0;for(let{visibleCount:c}of n)r+=c;this.stats.get("Layers rendered").addCount(r)}_preRender(n,r){this.lastPostProcessEffect=null,r.preRenderStats=r.preRenderStats||{};for(let c of n)r.preRenderStats[c.id]=c.preRender(r),c.postRender&&(this.lastPostProcessEffect=c.id);this.lastPostProcessEffect&&this._resizeRenderBuffers(r.canvasContext)}_resizeRenderBuffers(n=this.device.canvasContext){let{renderBuffers:r}=this,c=n.getDrawingBufferSize(),[u,d]=c;r.length===0&&[0,1].map(b=>{let w=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"},width:u,height:d});r.push(this.device.createFramebuffer({id:`deck-renderbuffer-${b}`,colorAttachments:[w]}))});for(let b of r)b.resize(c)}_postRender(n,r){let{renderBuffers:c}=this,u=r.target??r.canvasContext?.getCurrentFramebuffer()??r.target,d={...r,inputBuffer:c[0],swapBuffer:c[1]};for(let b of n)if(b.postRender){d.target=b.id===this.lastPostProcessEffect?u:void 0;let w=b.postRender(d);d.inputBuffer=w,d.swapBuffer=w===c[0]?c[1]:c[0]}}};$r();var etn={pickedColor:null,pickedObjectIndex:-1};function Zke({pickedColors:s,decodePickingColor:n,deviceX:r,deviceY:c,deviceRadius:u,deviceRect:d}){let{x:b,y:w,width:_,height:x}=d,T=u*u,M=-1,L=0;for(let I=0;IT)L+=4*_;else for(let O=0;O<_;O++){if(s[L+3]-1>=0){let Z=O+b-r,H=Z*Z+F;H<=T&&(T=H,M=L)}L+=4}}if(M>=0){let I=s.slice(M,M+4),D=n(I);if(D){let F=Math.floor(M/4/_),O=M/4-F*_;return{...D,pickedColor:I,pickedX:b+O,pickedY:w+F}}Bs.error("Picked non-existent layer. Is picking buffer corrupt?")()}return etn}function Kke({pickedColors:s,decodePickingColor:n}){let r=new Map;if(s){for(let c=0;c=0){let d=s.slice(c,c+4),b=d.join(",");if(!r.has(b)){let w=n(d);w?r.set(b,{...w,color:d}):Bs.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(r.values())}function kle({pickInfo:s,viewports:n,pixelRatio:r,x:c,y:u,z:d}){let b=n[0];n.length>1&&(b=ttn(s?.pickedViewports||n,{x:c,y:u}));let w;if(b){let _=[c-b.x,u-b.y];d!==void 0&&(_[2]=d),w=b.unproject(_)}return{color:null,layer:null,viewport:b,index:-1,picked:!1,x:c,y:u,pixel:[c,u],coordinate:w,devicePixel:s&&"pickedX"in s?[s.pickedX,s.pickedY]:void 0,pixelRatio:r}}function Jke(s){let{pickInfo:n,lastPickedInfo:r,mode:c,layers:u}=s,{pickedColor:d,pickedLayer:b,pickedObjectIndex:w}=n,_=b?[b]:[];if(c==="hover"){let M=r.index,L=r.layerId,I=b?b.props.id:null;if(I!==L||w!==M){if(I!==L){let D=u.find(F=>F.props.id===L);D&&_.unshift(D)}r.layerId=I,r.index=w,r.info=null}}let x=kle(s),T=new Map;return T.set(null,x),_.forEach(M=>{let L={...x};M===b&&(L.color=d,L.index=w,L.picked=!0),L=Rle({layer:M,info:L,mode:c});let I=L.layer;M===b&&c==="hover"&&(r.info=L),T.set(I.id,L),c==="hover"&&I.updateAutoHighlight(L)}),T}function Rle({layer:s,info:n,mode:r}){for(;s&&n;){let c=n.layer||null;n.sourceLayer=c,n.layer=s,n=s.getPickingInfo({info:n,mode:r,sourceLayer:c}),s=s.parent}return n}function ttn(s,n){for(let r=s.length-1;r>=0;r--){let c=s[r];if(c.containsPixel(n))return c}return s[0]}var wV=class{constructor(n,r={}){this._pickable=!0,this.device=n,this.stats=r.stats,this.pickLayersPass=new E4(n),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(n){"layerFilter"in n&&(this.layerFilter=n.layerFilter),"_pickable"in n&&(this._pickable=n._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObjectAsync(n){return this._pickClosestObjectAsync(n)}pickObjectsAsync(n){return this._pickVisibleObjectsAsync(n)}pickObject(n){return this._pickClosestObject(n)}pickObjects(n){return this._pickVisibleObjects(n)}getLastPickedObject({x:n,y:r,layers:c,viewports:u},d=this.lastPickedInfo.info){let b=d&&d.layer&&d.layer.id,w=d&&d.viewport&&d.viewport.id,_=b?c.find(L=>L.id===b):null,x=w&&u.find(L=>L.id===w)||u[0],T=x&&x.unproject([n-x.x,r-x.y]);return{...d,...{x:n,y:r,viewport:x,coordinate:T,layer:_}}}_resizeBuffer(n=this.device.getDefaultCanvasContext()){if(!this.pickingFBO){let u=this.device.createTexture({format:"rgba8unorm",width:1,height:1,usage:Aa.RENDER_ATTACHMENT|Aa.COPY_SRC});if(this.pickingFBO=this.device.createFramebuffer({colorAttachments:[u],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float")){let d=this.device.createTexture({format:"rgba32float",width:1,height:1,usage:Aa.RENDER_ATTACHMENT|Aa.COPY_SRC}),b=this.device.createFramebuffer({colorAttachments:[d],depthStencilAttachment:"depth16unorm"});this.depthFBO=b}}let[r,c]=n.getDrawingBufferSize();this.pickingFBO?.resize({width:r,height:c}),this.depthFBO?.resize({width:r,height:c})}_getPickable(n){if(this._pickable===!1)return null;let r=n.filter(c=>this.pickLayersPass.shouldDrawLayer(c)&&!c.isComposite);return r.length?r:null}async _pickClosestObjectAsync({layers:n,views:r,viewports:c,x:u,y:d,radius:b=0,depth:w=1,mode:_="query",unproject3D:x,canvasContext:T=this.device.getDefaultCanvasContext(),onViewportActive:M,effects:L}){let I=T.cssToDeviceRatio(),D=this._getPickable(n);if(!D||c.length===0)return{result:[],emptyInfo:kle({viewports:c,x:u,y:d,pixelRatio:I})};this._resizeBuffer(T);let F=T.cssToDevicePixels([u,d],!0),O=[F.x+Math.floor(F.width/2),F.y+Math.floor(F.height/2)],z=Math.round(b*I),{width:Z,height:H}=this.pickingFBO,te=this._getPickingRect({deviceX:O[0],deviceY:O[1],deviceRadius:z,deviceWidth:Z,deviceHeight:H}),se={x:u-b,y:d-b,width:b*2+1,height:b*2+1},ne,ue=[],Ce=new Set;for(let Q=0;Q0){let{pickedColors:at}=await this._drawAndSampleAsync({layers:st,views:r,viewports:c,onViewportActive:M,deviceRect:{x:me.pickedX??O[0],y:me.pickedY??O[1],width:1,height:1},cullRect:se,effects:L,pass:`picking:${_}:z`,canvasContext:T},!0);at[3]&&(tt=at[0])}me.pickedLayer&&Q+10){let{pickedColors:at}=this._drawAndSample({layers:st,views:r,viewports:c,onViewportActive:M,deviceRect:{x:me.pickedX??O[0],y:me.pickedY??O[1],width:1,height:1},cullRect:se,effects:L,pass:`picking:${_}:z`,canvasContext:T},!0);at[3]&&(tt=at[0])}me.pickedLayer&&Q+1=x);tt++){let st=ue[tt],at={color:st.pickedColor,layer:null,index:st.pickedObjectIndex,picked:!0,x:u,y:d,pixelRatio:D};at=Rle({layer:st.pickedLayer,info:at,mode:_});let Ne=at.layer.id;Ce.has(Ne)||Ce.set(Ne,new Set);let Qe=Ce.get(Ne),ot=at.object??at.index;Qe.has(ot)||(Qe.add(ot),Q.push(at))}return Q}_pickVisibleObjects({layers:n,views:r,viewports:c,x:u,y:d,width:b=1,height:w=1,mode:_="query",maxObjects:x=null,canvasContext:T=this.device.getDefaultCanvasContext(),onViewportActive:M,effects:L}){let I=this._getPickable(n);if(!I||c.length===0)return[];this._resizeBuffer(T);let D=T.cssToDeviceRatio(),F=T.cssToDevicePixels([u,d],!0),O=F.x,z=F.y+F.height,Z=T.cssToDevicePixels([u+b,d+w],!0),H=Z.x+Z.width,te=Z.y,se={x:O,y:te,width:H-O,height:z-te},ne=this._drawAndSample({layers:I,views:r,viewports:c,onViewportActive:M,deviceRect:se,cullRect:{x:u,y:d,width:b,height:w},effects:L,pass:`picking:${_}`,canvasContext:T}),ue=Kke(ne),Ce=new Map,Q=[],me=Number.isFinite(x);for(let tt=0;tt=x);tt++){let st=ue[tt],at={color:st.pickedColor,layer:null,index:st.pickedObjectIndex,picked:!0,x:u,y:d,pixelRatio:D};at=Rle({layer:st.pickedLayer,info:at,mode:_});let Ne=at.layer.id;Ce.has(Ne)||Ce.set(Ne,new Set);let Qe=Ce.get(Ne),ot=at.object??at.index;Qe.has(ot)||(Qe.add(ot),Q.push(at))}return Q}async _drawAndSampleAsync({layers:n,views:r,viewports:c,onViewportActive:u,deviceRect:d,cullRect:b,effects:w,pass:_,canvasContext:x},T=!1){let M=T?this.depthFBO:this.pickingFBO,L={layers:n,layerFilter:this.layerFilter,views:r,viewports:c,onViewportActive:u,pickingFBO:M,deviceRect:d,cullRect:b,effects:w,pass:_,canvasContext:x,pickZ:T,preRenderStats:{},isPicking:!0};for(let se of w)se.useInPicking&&(L.preRenderStats[se.id]=se.preRender(L));let{decodePickingColor:I,stats:D}=this.pickLayersPass.render(L);this._updateStats(D);let{x:F,y:O,width:z,height:Z}=d,H=M.colorAttachments[0]?.texture;if(!H)throw new Error("Picking framebuffer color attachment is missing");let te=await this._readTextureDataAsync(H,{x:F,y:O,width:z,height:Z},T?Float32Array:Uint8Array);if(!T){let se=!1;for(let ne=3;ne0&&Bs.warn("Async pick readback returned only zero alpha values",{deviceRect:d,bytes:Array.from(te.subarray(0,Math.min(te.length,16)))})()}return{pickedColors:te,decodePickingColor:I}}async _readTextureDataAsync(n,r,c){let{width:u,height:d}=r,b=n.computeMemoryLayout(r),w=this.device.createBuffer({byteLength:b.byteLength,usage:as.COPY_DST|as.MAP_READ});try{n.readBuffer(r,w);let _=await w.readAsync(0,b.byteLength),x=c.BYTES_PER_ELEMENT;if(b.bytesPerRow%x!==0)throw new Error(`Texture readback row stride ${b.bytesPerRow} is not aligned to ${x}-byte elements.`);let T=new c(_.buffer,_.byteOffset,b.byteLength/x),M=u*4,L=b.bytesPerRow/x;if(Lb.props.operation.includes("terrain"))}_getPickingRect({deviceX:n,deviceY:r,deviceRadius:c,deviceWidth:u,deviceHeight:d}){let b=Math.max(0,n-c),w=Math.max(0,r-c),_=Math.min(u,n+c+1)-b,x=Math.min(d,r+c+1)-w;return _<=0||x<=0?null:{x:b,y:w,width:_,height:x}}};var ntn={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},itn="top-left",M1t="root",Ile=class{constructor({deck:n,parentElement:r}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=n,r?.classList.add("deck-widget-container"),this.parentElement=r}getWidgets(){return this.resolvedWidgets}setProps(n){if(n.widgets&&!Cc(n.widgets,this.widgets,1)){let r=n.widgets.filter(Boolean);this._setWidgets(r)}}finalize(){for(let n of this.getWidgets())this._removeWidget(n);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(let n in this.containers)this.containers[n].remove()}addDefault(n){this.defaultWidgets.find(r=>r.id===n.id)||(this._addWidget(n),this.defaultWidgets.push(n),this._setWidgets(this.widgets))}onRedraw({viewports:n,layers:r}){let c=n.reduce((u,d)=>(u[d.id]=d,u),{});for(let u of this.getWidgets()){let{viewId:d}=u;if(d){let b=c[d];b&&(u.onViewportChange&&u.onViewportChange(b),u.onRedraw?.({viewports:[b],layers:r}))}else{if(u.onViewportChange)for(let b of n)u.onViewportChange(b);u.onRedraw?.({viewports:n,layers:r})}}this.lastViewports=c,this._updateContainers()}onHover(n,r){for(let c of this.getWidgets()){let{viewId:u}=c;(!u||u===n.viewport?.id)&&c.onHover?.(n,r)}}getCanvasBounds(n){let c=this.deck?.getCanvas?.()?.getBoundingClientRect(),u=this.parentElement?.getBoundingClientRect(),d=this.deck?.getCanvasContext?.(n?.id);if(d&&u){d.updatePosition();let[b,w]=d.getPosition(),[_,x]=d.getCSSSize();return{x:b-u.left,y:w-u.top,width:_,height:x}}return{x:c&&u?c.left-u.left:0,y:c&&u?c.top-u.top:0,width:c?.width||this.deck?.width||0,height:c?.height||this.deck?.height||0}}onEvent(n,r){let c=iB[r.type];if(c)for(let u of this.getWidgets()){let{viewId:d}=u;(!d||d===n.viewport?.id)&&u[c]?.(n,r)}}_setWidgets(n){let r={};for(let c of this.resolvedWidgets)r[c.id]=c;this.resolvedWidgets.length=0;for(let c of this.defaultWidgets)r[c.id]=null,this.resolvedWidgets.push(c);for(let c of n){let u=r[c.id];u?u.viewId!==c.viewId||u.placement!==c.placement?(this._removeWidget(u),this._addWidget(c)):c!==u&&(u.setProps(c.props),c=u):this._addWidget(c),r[c.id]=null,this.resolvedWidgets.push(c)}for(let c in r){let u=r[c];u&&this._removeWidget(u)}this.widgets=n}_addWidget(n){let{viewId:r=null,placement:c=itn}=n,u=n.props._container??r;n.widgetManager=this,n.deck=this.deck,n.rootElement=n._onAdd({deck:this.deck,viewId:r}),n.rootElement&&this._getContainer(u,c).append(n.rootElement),n.updateHTML()}_removeWidget(n){n.onRemove?.(),n.rootElement&&n.rootElement.remove(),n.rootElement=void 0,n.deck=void 0,n.widgetManager=void 0}_getContainer(n,r){if(n&&typeof n!="string")return n;let c=n||M1t,u=this.containers[c];u||(u=document.createElement("div"),u.style.pointerEvents="none",u.style.position="absolute",u.style.overflow="hidden",this.parentElement?.append(u),this.containers[c]=u);let d=u.querySelector(`.${r}`);return d||(d=globalThis.document.createElement("div"),d.className=r,d.style.position="absolute",d.style.zIndex="2",Object.assign(d.style,ntn[r]),u.append(d)),d}_updateContainers(){for(let n in this.containers){let r=this.lastViewports[n]||null,c=n===M1t||r,u=this.containers[n];if(c){let d=this._getContainerBounds(r);u.style.display="block",u.style.left=`${d.x}px`,u.style.top=`${d.y}px`,u.style.width=`${d.width}px`,u.style.height=`${d.height}px`}else u.style.display="none"}}_getContainerBounds(n){if(!n)return{x:0,y:0,width:this.parentElement?.clientWidth||this.deck.width,height:this.parentElement?.clientHeight||this.deck.height};let r=this.getCanvasBounds(n);return{x:r.x+n.x,y:r.y+n.y,width:n.width,height:n.height}}};function Qke(s,n){n&&Object.entries(n).map(([r,c])=>{r.startsWith("--")?s.style.setProperty(r,c):s.style[r]=c})}function T1t(s,n){n&&Object.keys(n).map(r=>{r.startsWith("--")?s.style.removeProperty(r):s.style[r]=""})}var vB=class{constructor(n){this.viewId=null,this.props={...this.constructor.defaultProps,...n},this.id=this.props.id}setProps(n){let r=this.props,c=this.rootElement;c&&r.className!==n.className&&(r.className&&c.classList.remove(r.className),n.className&&c.classList.add(n.className)),c&&!Cc(r.style,n.style,1)&&(T1t(c,r.style),Qke(c,n.style)),Object.assign(this.props,n),this.updateHTML()}updateHTML(){this.rootElement&&this.onRenderHTML(this.rootElement)}get viewIds(){return this.viewId?[this.viewId]:this.deck?.getViews().map(n=>n.id)??[]}getViewState(n){return this.deck?.viewManager?.getViewState(n)||{}}setViewState(n,r){this.deck?._onViewStateChange({viewId:n,viewState:r,interactionState:{}})}onCreateRootElement(){let n=["deck-widget",this.className,this.props.className],r=document.createElement("div");return n.filter(c=>typeof c=="string"&&c.length>0).forEach(c=>r.classList.add(c)),Qke(r,this.props.style),r}_onAdd(n){return this.onAdd(n)??this.onCreateRootElement()}onAdd(n){}onRemove(){}onViewportChange(n){}onRedraw(n){}onHover(n,r){}onClick(n,r){}onDrag(n,r){}onDragStart(n,r){}onDragEnd(n,r){}};vB.defaultProps={id:"widget",style:{},_container:null,className:""};var rtn={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"},vV=class extends vB{constructor(n={}){super(n),this.id="default-tooltip",this.placement="fill",this.className="deck-tooltip",this.isVisible=!1,this.setProps(n)}onCreateRootElement(){let n=document.createElement("div");return n.className=this.className,Object.assign(n.style,rtn),n}onRenderHTML(n){}onViewportChange(n){this.isVisible&&n.id===this.lastViewport?.id&&!n.equals(this.lastViewport)&&this.setTooltip(null),this.lastViewport=n}onHover(n){let{deck:r}=this,c=r&&r.props.getTooltip;if(!c)return;let u=c(n),d=this.widgetManager?.getCanvasBounds(n.viewport),b=n.x+(d?.x||0),w=n.y+(d?.y||0);this.setTooltip(u,b,w)}setTooltip(n,r,c){let u=this.rootElement;if(u){if(typeof n=="string")u.innerText=n;else if(n)n.text&&(u.innerText=n.text),n.html&&(u.innerHTML=n.html),n.className&&(u.className=n.className);else{this.isVisible=!1,u.style.display="none";return}this.isVisible=!0,u.style.display="block",u.style.transform=`translate(${r}px, ${c}px)`,n&&typeof n=="object"&&"style"in n&&Object.assign(u.style,n.style)}}};vV.defaultProps={...vB.defaultProps};var _V=class{constructor(n){this.targets={},this.order=[],this.eventManagers={},this._eventRootToCanvasId=new WeakMap,this._createEventManager=n.createEventManager,this._getEventRoot=n.getEventRoot}finalize(){for(let n of Object.values(this.targets))n.eventManager.destroy(),n.presentationContext.destroy();this.targets={},this.order=[],this.eventManagers={},this._eventRootToCanvasId=new WeakMap}syncCanvasEntries(n){let r=this._normalizeCanvasList(n.canvases),c={},u=[],d=new Map;for(let{canvas:w}of r){let _=this._getEventRoot(w);d.set(_,(d.get(_)||0)+1)}for(let{id:w,canvas:_}of r){let x=this._getEventRoot(_),T=d.get(x)===1?x:_,M=this.targets[w];if(!M||M.device!==n.device||M.canvas!==_||M.eventRoot!==T){M?.eventManager.destroy(),M?.presentationContext.destroy();let L=n.device.createPresentationContext({id:w,canvas:_,useDevicePixels:n.useDevicePixels,autoResize:!0});M={id:w,device:n.device,canvas:_,eventRoot:T,presentationContext:L,eventManager:this._createEventManager(T)}}this._eventRootToCanvasId.set(T,w),this._eventRootToCanvasId.set(_,w),c[w]=M,u.push(w)}for(let[w,_]of Object.entries(this.targets))c[w]||(_.eventManager.destroy(),_.presentationContext.destroy());this.targets=c,this.order=u;let b=Object.fromEntries(Object.entries(c).map(([w,_])=>[w,_.eventManager]));this._haveSameEventManagers(b)||(this.eventManagers=b)}getCanvasIdFromEvent(n){return n?this._eventRootToCanvasId.get(n):void 0}getTarget(n){return this.targets[n||this.order[0]||XM]||null}_normalizeCanvasList(n=[]){let r=new Set;return n.map((c,u)=>{let d,b;return typeof c=="string"?(d=document.getElementById(c),Pa(d,`Canvas with id ${c} not found`),b=c):(d=c,b=d.id||`deckgl-canvas-${u}`),Pa(!r.has(b),`Duplicate canvas id ${b}`),r.add(b),{id:b,canvas:d}})}_haveSameEventManagers(n){let r=Object.keys(n),c=Object.keys(this.eventManagers);return r.length===c.length&&r.every(u=>n[u]===this.eventManagers[u])}};$r();fue();Jl();Jl();Kj();function D3(){}var gnn=({isDragging:s})=>s?"grabbing":"grab",J0t={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,pickAsync:"auto",layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{},gl:null,canvas:null,_canvases:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:D3,onWebGLInitialized:D3,onResize:D3,onViewStateChange:D3,onInteractionStateChange:D3,onBeforeRender:D3,onAfterRender:D3,onLoad:D3,onError:s=>Bs.error(s.message,s.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:gnn,getTooltip:null,debug:!1,drawPickingColors:!1},RV=class{constructor(n){this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.eventManagers={},this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this._canvasContext=null,this._deviceResizeHandler=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new yb({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,layersCount:0,drawLayersCount:0,updateLayersCount:0,updateAttributesCount:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,pickLayersCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._hoverPickSequence=0,this._pointerDownPickSequence=0,this._needsRedraw="Initial render",this._canvasManager=new _V({createEventManager:u=>this._createEventManager(u),getEventRoot:u=>this._getEventRoot(u)}),this._ownedCanvas=null,this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,canvasId:void 0,event:null,unproject3D:!1},this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this._onPointerMove=u=>{let{_pickRequest:d}=this,b=this._getCanvasIdFromEvent(u);if(u.type==="pointerleave")d.x=-1,d.y=-1,d.radius=0,d.canvasId=b;else{if(u.leftButton||u.rightButton)return;{let w=u.offsetCenter;if(!w)return;d.x=w.x,d.y=w.y,d.radius=this.props.pickingRadius,d.canvasId=b}}this.layerManager&&(this.layerManager.context.mousePosition={x:d.x,y:d.y}),d.event=u},this._onEvent=u=>{let d=iB[u.type],b=u.offsetCenter,w=this._getCanvasIdFromEvent(u);if(!d||!b||!this.layerManager)return;let _=this.layerManager.getLayers(),x=this._getInternalPickingMode();if(!x)return;if(x==="sync"){let M=u.type==="click"&&this._shouldUnproject3D(_)?this._getFirstPickedInfo(this._pickPointSync(this._getPointPickOptions(b.x,b.y,{unproject3D:!0,canvasId:w},_))):this._getLastPointerDownPickingInfo(b.x,b.y,w,_);this._dispatchPickingEvent(M,u);return}(this._lastPointerDownInfoPromise||Promise.resolve(this._getLastPointerDownPickingInfo(b.x,b.y,w,_))).then(M=>{this._dispatchPickingEvent(M,u)}).catch(M=>this.props.onError?.(M))},this._onPointerDown=u=>{let d=u.offsetCenter,b=this._getCanvasIdFromEvent(u);if(!d)return;let w=this._getInternalPickingMode();if(!w)return;let _=this.layerManager?.getLayers()||[],x=++this._pointerDownPickSequence;if(w==="sync"){let M=this._pickPointSync({x:d.x,y:d.y,canvasId:b,radius:this.props.pickingRadius}),L=this._getFirstPickedInfo(M);this._lastPointerDownInfo=L,this._lastPointerDownInfoPromise=Promise.resolve(L);return}let T=this._pickPointAsync(this._getPointPickOptions(d.x,d.y,{canvasId:b},_)).then(M=>this._getFirstPickedInfo(M)).then(M=>(x===this._pointerDownPickSequence&&(this._lastPointerDownInfo=M),M)).catch(M=>{this.props.onError?.(M);let L=this.deckPicker&&this.viewManager?this._getLastPointerDownPickingInfo(d.x,d.y,b,_):{};return x===this._pointerDownPickSequence&&(this._lastPointerDownInfo=L),L});this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=T};let r=n;this.props={...J0t,...n},n=this.props,this._validateCanvasConfiguration(n),n.viewState&&n.initialViewState&&Bs.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,n.device&&(this.device=n.device,this._setDeviceCanvasContext(n.device));let c=this.device;!c&&n.gl&&(n.gl instanceof WebGLRenderingContext&&Bs.error("WebGL1 context not supported.")(),c=kV.attach(n.gl,{_cacheShaders:!0,_cachePipelines:!0,...this.props.deviceProps})),c||(c=this._createDevice(n)),this.animationLoop=this._createAnimationLoop(c,n),this.setProps(r),n._typedArrayManagerProps&&hv.setOptions(n._typedArrayManagerProps),this.animationLoop.start()}finalize(){this._restoreDeviceResizeHandler(),this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._hoverPickSequence++,this._pointerDownPickSequence++,this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this.layerManager?.finalize(),this.layerManager=null,this.viewManager?.finalize(),this.viewManager=null,this.effectManager?.finalize(),this.effectManager=null,this.deckRenderer?.finalize(),this.deckRenderer=null,this.deckPicker?.finalize(),this.deckPicker=null,Object.keys(this._canvasManager.targets).length||this.eventManager?.destroy(),this.eventManager=null,this.eventManagers={},this.widgetManager?.finalize(),this.widgetManager=null,this._canvasManager.finalize(),this._isMultiCanvasMode()?this.canvas=null:this.canvas&&this.canvas===this._ownedCanvas&&(this.canvas.parentElement?.removeChild(this.canvas),this.canvas=null,this._ownedCanvas=null),this._canvasContext=null}setProps(n){this.stats.get("setProps Time").timeStart(),"onLayerHover"in n&&Bs.removed("onLayerHover","onHover")(),"onLayerClick"in n&&Bs.removed("onLayerClick","onClick")(),n.initialViewState&&!Cc(this.props.initialViewState,n.initialViewState,3)&&(this.viewState=n.initialViewState),Pa(!("_canvases"in n)||Array.isArray(n._canvases)===this._isMultiCanvasMode()),Object.assign(this.props,n),this._validateCanvasConfiguration(this.props),this._validateInternalPickingMode(),this.device&&this._isMultiCanvasMode()&&this._syncCanvasTargets(),this._setCanvasSize(this.props);let r=Object.create(this.props);if(Object.assign(r,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState(),eventManagers:this.eventManagers}),n.device&&n.device.id!==this.device?.id){let c=n.device.getDefaultCanvasContext();this.animationLoop?.stop(),!this._isMultiCanvasMode()&&this.canvas!==c.canvas&&(this.canvas?.remove(),this.eventManager?.destroy(),this.canvas=null),this._setDeviceCanvasContext(n.device),Bs.log(`recreating animation loop for new device! id=${n.device.id}`)(),this.animationLoop=this._createAnimationLoop(n.device,n),this.animationLoop.start()}if(this.animationLoop?.setProps(r),n.useDevicePixels!==void 0&&this._canvasContext?.setProps){this._canvasContext.setProps({useDevicePixels:n.useDevicePixels});for(let c of Object.values(this._canvasManager.targets))c.presentationContext.setProps({useDevicePixels:n.useDevicePixels})}this.layerManager&&(this.viewManager.setProps(r),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(r),this.effectManager.setProps(r),this.deckRenderer.setProps(r),this.deckPicker.setProps(r),this.widgetManager.setProps(r)),this.stats.get("setProps Time").timeEnd()}needsRedraw(n={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let r=this._needsRedraw;n.clearRedrawFlags&&(this._needsRedraw=!1);let c=this.viewManager.needsRedraw(n),u=this.layerManager.needsRedraw(n),d=this.effectManager.needsRedraw(n),b=this.deckRenderer.needsRedraw(n);return r=r||c||u||d||b,r}redraw(n){if(!this.layerManager)return;let r=this.needsRedraw({clearRedrawFlags:!0});r=n||r,r&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(r):this._drawLayers(r))}get isInitialized(){return this.viewManager!==null}getViews(){return Pa(this.viewManager),this.viewManager.views}getView(n){return Pa(this.viewManager),this.viewManager.getView(n)}getViewports(n){return Pa(this.viewManager),this.viewManager.getViewports(n)}getCanvas(){return this.canvas}getCanvasContext(n){let r=n?this.viewManager?.getView(n)?.props.canvasId:void 0;return this._getCanvasContext(r)}getEventManager(n){if(!n||!this.viewManager)return this.eventManager;let r=this.viewManager.getCanvasId(n)||XM;return this.eventManagers[r]||this.eventManager}async pickObjectAsync(n){let r=(await this._pickAsync("pickObjectAsync","pickObject Time",n)).result;return r.length?r[0]:null}async pickObjectsAsync(n){return await this._pickAsync("pickObjectsAsync","pickObjects Time",n)}pickObject(n){let r=this._pick("pickObject","pickObject Time",n).result;return r.length?r[0]:null}pickMultipleObjects(n){return n.depth=n.depth||10,this._pick("pickObject","pickMultipleObjects Time",n).result}pickObjects(n){return this._pick("pickObjects","pickObjects Time",n)}_pickPositionForController(n,r,c){return this._getInternalPickingMode()!=="sync"?null:this.pickObject({x:n,y:r,radius:0,unproject3D:!0,canvasId:c?this.viewManager?.getCanvasId(c):void 0})}_addResources(n,r=!1){for(let c in n)this.layerManager.resourceManager.add({resourceId:c,data:n[c],forceUpdate:r})}_removeResources(n){for(let r of n)this.layerManager.resourceManager.remove(r)}_addDefaultEffect(n){this.effectManager.addDefaultEffect(n)}_addDefaultShaderModule(n){this.layerManager.addDefaultShaderModule(n)}_removeDefaultShaderModule(n){this.layerManager?.removeDefaultShaderModule(n)}_resolveInternalPickingMode(){let{pickAsync:n}=this.props,r=this.device?.type||this.props.deviceProps?.type;if(n==="auto")return r==="webgpu"?"async":"sync";if(n==="sync"&&r==="webgpu")throw new Error('`pickAsync: "sync"` is not supported when Deck is using a WebGPU device.');return n}_getInternalPickingMode(){try{return this._resolveInternalPickingMode()}catch(n){return this.props.onError?.(n),null}}_validateInternalPickingMode(){this._getInternalPickingMode()}_getFirstPickedInfo({result:n,emptyInfo:r}){return n[0]||r}_shouldUnproject3D(n=this.layerManager?.getLayers()||[]){return n.some(r=>r.props.pickable==="3d")}_getPointPickOptions(n,r,c={},u=this.layerManager?.getLayers()||[]){return{x:n,y:r,canvasId:c.canvasId,radius:this.props.pickingRadius,unproject3D:this._shouldUnproject3D(u),...c}}_pickPointSync(n){return this._pick("pickObject","pickObject Time",n)}_pickPointAsync(n){return this._pickAsync("pickObjectAsync","pickObject Time",n)}_getLastPointerDownPickingInfo(n,r,c,u=this.layerManager?.getLayers()||[]){return this.deckPicker.getLastPickedObject({x:n,y:r,layers:u,viewports:this.getViewports({x:n,y:r,canvasId:c})},this._lastPointerDownInfo)}_applyHoverCallbacks({result:n,emptyInfo:r},c){if(!this.widgetManager)return;this.cursorState.isHovering=n.length>0;let u=r,d=!1;for(let b of n)u=b,d=b.layer?.onHover(b,c)||d;d||(this.props.onHover?.(u,c),this.widgetManager.onHover(u,c))}_dispatchPickingEvent(n,r){if(!this.layerManager||!this.widgetManager)return;let c=iB[r.type];if(!c)return;let{layer:u}=n,d=u&&(u[c]||u.props[c]),b=this.props[c],w=!1;d&&(w=d.call(u,n,r)),w||(b?.(n,r),this.widgetManager.onEvent(n,r))}_pickAsync(n,r,c){Pa(this.deckPicker);let{stats:u}=this,d=this._isMultiCanvasMode()?c.canvasId||this._getDefaultCanvasId():c.canvasId,b=this._getCanvasContext(d)||void 0;u.get("Pick Count").incrementCount(),u.get(r).timeStart(),this._resizeForCanvasTarget(d);let w=this.deckPicker[n]({layers:this.layerManager.getLayers(c),views:this.viewManager.getViews(),viewports:this.getViewports({...c,canvasId:d}),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...c,canvasId:d,canvasContext:b});return u.get(r).timeEnd(),w}_pick(n,r,c){Pa(this.deckPicker);let{stats:u}=this,d=this._isMultiCanvasMode()?c.canvasId||this._getDefaultCanvasId():c.canvasId,b=this._getCanvasContext(d)||void 0;u.get("Pick Count").incrementCount(),u.get(r).timeStart(),this._resizeForCanvasTarget(d);let w=this.deckPicker[n]({layers:this.layerManager.getLayers(c),views:this.viewManager.getViews(),viewports:this.getViewports({...c,canvasId:d}),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...c,canvasId:d,canvasContext:b});return u.get(r).timeEnd(),w}_createCanvas(n){let r=n.canvas;return typeof r=="string"&&(r=document.getElementById(r),Pa(r)),r?this._ownedCanvas=null:(r=document.createElement("canvas"),r.id=n.id||"deckgl-overlay",n.width&&typeof n.width=="number"&&(r.width=n.width),n.height&&typeof n.height=="number"&&(r.height=n.height),(n.parent||document.body).appendChild(r),this._ownedCanvas=r),Object.assign(r.style,n.style),r}_isMultiCanvasMode(){return Array.isArray(this.props._canvases)}_getDefaultCanvasId(){return this._canvasManager.order[0]||XM}_validateCanvasConfiguration(n){Array.isArray(n._canvases)&&(Pa(!n.canvas),Pa(!n.gl),Pa(!n.device?.canvasContext||n.device.getDefaultCanvasContext().offscreenCanvas))}_createEventManager(n){let r=new H$(n,{touchAction:this.props.touchAction,recognizers:Object.keys(xke).map(c=>{let[u,d,b,w]=xke[c],_=this.props.eventRecognizerOptions?.[c],x={...d,..._,event:c};return{recognizer:new u(x),recognizeWith:b,requireFailure:w}}),events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(let c in iB)c==="dblclick"?r.watch(c,this._onEvent):r.on(c,this._onEvent);return r}_getEventRoot(n){return n.closest(".deck-events-root")||this.props.parent?.querySelector(".deck-events-root")||n}_syncCanvasTargets(){if(!this.device||!this._isMultiCanvasMode())return;this._canvasManager.syncCanvasEntries({device:this.device,canvases:this.props._canvases||[],useDevicePixels:this.props.useDevicePixels}),this.eventManagers=this._canvasManager.eventManagers;let n=this._getDefaultCanvasId();this.eventManager=this.eventManagers[n]||null,this.canvas=this._canvasManager.targets[n]?.canvas||null}_setCanvasContext(n){this._canvasContext=n,"style"in n.canvas&&(this.canvas=n.canvas)}_setDeviceCanvasContext(n,r={}){let c=n.getDefaultCanvasContext();this._setCanvasContext(c),this._setDeviceResizeHandler(n,r)}_setDeviceResizeHandler(n,r={}){let c=!!r.syncDrawingBuffer;if(this._deviceResizeHandler?.device===n){this._deviceResizeHandler.syncDrawingBuffer=c;return}this._restoreDeviceResizeHandler();let u=d=>{this._isMultiCanvasMode()?this._updateMultiCanvasDimensions():d===this._canvasContext&&this._canvasContext&&this._onCanvasContextResize(this._canvasContext,{syncDrawingBuffer:this._deviceResizeHandler?.syncDrawingBuffer})};n.props.onResize=u,this._deviceResizeHandler={device:n,onResize:u,syncDrawingBuffer:c}}_restoreDeviceResizeHandler(){let n=this._deviceResizeHandler;n&&n.device.props?.onResize===n.onResize&&(n.device.props.onResize=D3),this._deviceResizeHandler=null}_setCanvasSize(n){if(this._isMultiCanvasMode()||!this.canvas)return;let{width:r,height:c}=n;if(r||r===0){let u=Number.isFinite(r)?`${r}px`:r;this.canvas.style.width=u}if(c||c===0){let u=Number.isFinite(c)?`${c}px`:c;this.canvas.style.position=n.style?.position||"absolute",this.canvas.style.height=u}}_getCanvasIdFromEvent(n){return this._canvasManager.getCanvasIdFromEvent(n?.rootElement)}_getCanvasContext(n){return this._canvasManager.getTarget(n)?.presentationContext||this._canvasContext}_resizeForCanvasTarget(n){let r=this._canvasManager.getTarget(n);if(!r||!this.device?.canvasContext)return;let[c,u]=r.presentationContext.getDrawingBufferSize();this.device.canvasContext.setDrawingBufferSize(c,u)}_createDeviceCanvas(n){if(this._isMultiCanvasMode()){let r=globalThis.OffscreenCanvas;if(!r)throw new Error("`_canvases` requires OffscreenCanvas support.");let c=typeof n.width=="number"&&Number.isFinite(n.width)?n.width:1,u=typeof n.height=="number"&&Number.isFinite(n.height)?n.height:1;return new r(c,u)}return this._createCanvas(n)}_updateCanvasSize(n=this._canvasContext){if(this._isMultiCanvasMode()){this._updateMultiCanvasDimensions();return}let{canvas:r}=this,[c,u]=n?n.getCSSSize():[r?.clientWidth??r?.width??0,r?.clientHeight??r?.height??0];(c!==this.width||u!==this.height)&&(this.width=c,this.height=u,this.viewManager?.setProps({width:c,height:u}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:c,height:u},n||void 0))}_onCanvasContextResize(n,r={}){if(r.syncDrawingBuffer){let{width:c,height:u}=n.canvas;n.setDrawingBufferSize(c,u)}this._needsRedraw="Canvas resized",this._updateCanvasSize(n)}_updateMultiCanvasDimensions(){let[n,r]=this._getCanvasContext()?.getCSSSize()||[0,0];(n!==this.width||r!==this.height)&&(this.width=n,this.height=r,this.props.onResize({width:n,height:r})),this._needsRedraw="Canvas resized",this.viewManager?.setNeedsUpdate("Canvas resized"),this.viewManager?.setProps({width:this.width,height:this.height})}_createAnimationLoop(n,r){let{gl:c,onError:u}=r;return new iV({device:n,autoResizeDrawingBuffer:!c&&!Array.isArray(r._canvases),autoResizeViewport:!1,onInitialize:d=>this._setDevice(d.device),onRender:this._onRenderFrame.bind(this),onError:u})}_createDevice(n){let r=this.props.deviceProps?.createCanvasContext,c=typeof r=="object"?r:void 0,u={adapters:[],_cacheShaders:!0,_cachePipelines:!0,...n.deviceProps};u.adapters.includes(kV)||u.adapters.push(kV);let d={alphaMode:this.props.deviceProps?.type==="webgpu"?"premultiplied":void 0};return UD.createDevice({_reuseDevices:!0,type:"webgl",...u,createCanvasContext:{...d,...c,canvas:this._createDeviceCanvas(n),useDevicePixels:this.props.useDevicePixels,autoResize:!0}})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let{views:n}=this.props,r=Array.isArray(n)?n:n?[n]:[new S1t({id:"default-view"})];return r.length&&this.props.controller&&(r[0]=r[0].clone({controller:this.props.controller})),r}_onContextLost(){let{onError:n}=this.props;this.animationLoop&&n&&n(new Error("WebGL context is lost"))}_pickAndCallback(){let{_pickRequest:n}=this;if(n.event){let r=n.event,c=this.layerManager?.getLayers()||[],u=this._getPointPickOptions(n.x,n.y,{canvasId:n.canvasId,radius:n.radius,mode:n.mode},c),d=this._getInternalPickingMode(),b=++this._hoverPickSequence;if(n.event=null,n.canvasId=void 0,!d)return;if(d==="sync"){this._applyHoverCallbacks(this._pickPointSync(u),r);return}this._pickPointAsync(u).then(({result:w,emptyInfo:_})=>{b===this._hoverPickSequence&&this._applyHoverCallbacks({result:w,emptyInfo:_},r)}).catch(w=>this.props.onError?.(w))}}_updateCursor(){let n=this.props.getCursor(this.cursorState);if(this._isMultiCanvasMode()){for(let c of Object.values(this._canvasManager.targets))c.canvas.style.cursor=n;return}let r=this.props.parent||this.canvas;r&&(r.style.cursor=n)}_setDevice(n){if(this.device=n,this._validateInternalPickingMode(),!this.animationLoop)return;this._setDeviceCanvasContext(n,{syncDrawingBuffer:!!(this.props.gl&&this.props.device!==n)}),this._isMultiCanvasMode()?this._syncCanvasTargets():this.canvas&&!this.canvas.isConnected&&this.props.parent&&this.props.parent.insertBefore(this.canvas,this.props.parent.firstChild),this.device.type==="webgl"&&this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),this.device.type==="webgl"&&this.props.onWebGLInitialized(this.device.gl);let r=new x4;if(r.play(),this.animationLoop.attachTimeline(r),!this._isMultiCanvasMode()){let d=this.canvas&&this._getEventRoot(this.canvas);Pa(d),this.eventManager=this._createEventManager(d),this.eventManagers={[XM]:this.eventManager}}this.viewManager=new uV({timeline:r,eventManager:this.eventManager,eventManagers:this.eventManagers,getCanvasContext:this._isMultiCanvasMode()?this.getCanvasContext.bind(this):void 0,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),pickPosition:this._pickPositionForController.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});let c=this.viewManager.getViewports()[0];this.layerManager=new lV(this.device,{deck:this,stats:this.stats,viewport:c,timeline:r}),this.effectManager=new gV({deck:this,device:this.device}),this.deckRenderer=new bV(this.device,{stats:this.stats}),this.deckPicker=new wV(this.device,{stats:this.stats});let u=this.props.parent?.querySelector(".deck-widgets-root")||(this._isMultiCanvasMode()?this.props.parent||this.canvas?.parentElement:null)||this.canvas?.parentElement;this.widgetManager=new Ile({deck:this,parentElement:u}),this.widgetManager.addDefault(new vV),this.setProps({}),this._updateCanvasSize(this._canvasContext),this.props.onLoad()}_drawLayers(n,r){let{device:c,gl:u}=this.layerManager.context;this.props.onBeforeRender({device:c,gl:u});let d={target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:"screen",effects:this.effectManager.getEffects(),...r};if(this._isMultiCanvasMode()&&d.pass==="screen"&&!d.target&&this._canvasManager.order.length)for(let b of this._canvasManager.order){let w=d.viewports.filter(T=>this.viewManager.getCanvasId(T.id)===b);if(!w.length){let T=this._canvasManager.targets[b];this._resizeForCanvasTarget(b),this.deckRenderer?.renderLayers({...d,canvasContext:T.presentationContext,target:T.presentationContext.getCurrentFramebuffer(),viewports:[],clearCanvas:!0}),T.presentationContext.present();continue}let _=this._canvasManager.targets[b];this._resizeForCanvasTarget(b);let x=_.presentationContext.getCurrentFramebuffer();this.deckRenderer?.renderLayers({...d,canvasContext:_.presentationContext,target:x,viewports:w}),_.presentationContext.present()}else this.deckRenderer?.renderLayers(d);d.pass==="screen"&&this.widgetManager.onRedraw({viewports:d.viewports,layers:d.layers}),this.props.onAfterRender({device:c,gl:u})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60===0&&(this._getMetrics(),this.stats.reset(),Bs.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCursor(),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(n){let r=this.props.onViewStateChange(n)||n.viewState;this.viewState&&(this.viewState={...this.viewState,[n.viewId]:r},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(n){this.cursorState.isDragging=n.isDragging||!1,this.props.onInteractionStateChange(n)}_getFrameStats(){let{stats:n}=this;n.get("frameRate").timeEnd(),n.get("frameRate").timeStart();let r=this.animationLoop.stats;n.get("GPU Time").addTime(r.get("GPU Time").lastTiming),n.get("CPU Time").addTime(r.get("CPU Time").lastTiming)}_getMetrics(){let{metrics:n,stats:r}=this;n.fps=r.get("frameRate").getHz(),n.setPropsTime=r.get("setProps Time").time,n.updateAttributesTime=r.get("Update Attributes").time,n.framesRedrawn=r.get("Redraw Count").count,n.pickTime=r.get("pickObject Time").time+r.get("pickMultipleObjects Time").time+r.get("pickObjects Time").time,n.pickCount=r.get("Pick Count").count,n.layersCount=this.layerManager?.layers.length??0,n.drawLayersCount=r.get("Layers rendered").lastSampleCount,n.pickLayersCount=r.get("Layers picked").lastSampleCount,n.updateLayersCount=r.get("Layer updates").count,n.updateAttributesCount=r.get("Attributes updated").count,n.gpuTime=r.get("GPU Time").time,n.cpuTime=r.get("CPU Time").time,n.gpuTimePerFrame=r.get("GPU Time").getAverageTime(),n.cpuTimePerFrame=r.get("CPU Time").getAverageTime();let c=UD.stats.get("GPU Time and Memory");n.bufferMemory=c.get("Buffer Memory").count,n.textureMemory=c.get("Texture Memory").count,n.renderbufferMemory=c.get("Renderbuffer Memory").count,n.gpuMemory=c.get("GPU Memory").count}};RV.defaultProps=J0t;RV.VERSION=sht;var CRe=RV;$r();$r();function Q0t(s){switch(s){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return JL(s)}}var ebt=Sd.getDataType.bind(Sd);function IV(s,n,r){if(n.size>4)return null;let c=r==="webgpu"&&n.type==="uint8"?"unorm8":n.type,u=n.size,d=!!(r!=="webgpu"&&u===3&&c&&["uint8","sint8","unorm8","snorm8","uint16","sint16","unorm16","snorm16"].includes(c));return{attribute:s,format:u>1?`${c}x${u}${d?"-webgl":""}`:n.type,byteOffset:n.offset||0}}function kb(s){return s.stride||s.size*s.bytesPerElement}function tbt(s,n){return s.type===n.type&&s.size===n.size&&kb(s)===kb(n)&&(s.offset||0)===(n.offset||0)}function ARe(s,n){n.offset&&Bs.removed("shaderAttribute.offset","vertexOffset, elementOffset")();let r=kb(s),c=n.vertexOffset!==void 0?n.vertexOffset:s.vertexOffset||0,u=n.elementOffset||0,d=c*r+u*s.bytesPerElement+(s.offset||0);return{...n,offset:d,stride:r}}function mnn(s,n){let r=ARe(s,n);return{high:r,low:{...r,offset:r.offset+s.size*4}}}var DV=class{constructor(n,r,c){this._buffer=null,this.device=n,this.id=r.id||"",this.size=r.size||1;let u=r.logicalType||r.type,d=u==="float64",{defaultValue:b}=r;b=Number.isFinite(b)?[b]:b||new Array(this.size).fill(0);let w;d?w="float32":!u&&r.isIndexed?w="uint32":w=u||"float32";let _=Q0t(u||w);this.doublePrecision=d,d&&r.fp64===!1&&(_=Float32Array),this.value=null,this.settings={...r,defaultType:_,defaultValue:b,logicalType:u,type:w,normalized:w.includes("norm"),size:this.size,bytesPerElement:_.BYTES_PER_ELEMENT},this.state={...c,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){let n=this.getAccessor();return n.vertexOffset?n.vertexOffset*kb(n):0}get numInstances(){return this.state.numInstances}set numInstances(n){this.state.numInstances=n}get isDoublePrecisionBuffer(){return this._shouldSplitDoublePrecisionValue(this.value)}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),hv.release(this.state.allocatedValue),this.state.allocatedValue=null}getBuffer(){return this.state.constant&&this.device.type!=="webgpu"?null:this.state.externalBuffer||this._buffer}getValue(n=this.id,r=null){let c={};if(this.state.constant){let u=this.value;if(this.device.type==="webgpu"&&this._buffer)c[n]=this._buffer;else if(r){let d=ARe(this.getAccessor(),r),b=d.offset/u.BYTES_PER_ELEMENT,w=d.size||this.size;c[n]=u.subarray(b,b+w)}else c[n]=u}else c[n]=this.getBuffer();return this.doublePrecision&&(this.isDoublePrecisionBuffer?c[`${n}64Low`]=c[n]:c[`${n}64Low`]=new Float32Array(this.size)),c}_getBufferLayout(n=this.id,r=null){let c=this.getAccessor(),u=[],d={name:this.id,byteStride:this.device.type==="webgpu"&&this.state.constant?0:kb(c)};if(this.doublePrecision){let b=mnn(c,r||{});u.push(IV(n,{...c,...b.high},this.device.type),IV(`${n}64Low`,{...c,...b.low},this.device.type))}else if(r){let b=ARe(c,r);u.push(IV(n,{...c,...b},this.device.type))}else u.push(IV(n,c,this.device.type));return d.attributes=u.filter(Boolean),d}setAccessor(n){this.state.bufferAccessor=n}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let n=null;if(this.state.constant&&this.value){let r=Array.from(this.value);n=[r,r]}else{let{value:r,numInstances:c,size:u}=this,d=c*u;if(r&&d&&r.length>=d){let b=new Array(u).fill(1/0),w=new Array(u).fill(-1/0);for(let _=0;_w[x]&&(w[x]=T)}n=[b,w]}}return this.state.bounds=n,n}setData(n){let{state:r}=this,c;ArrayBuffer.isView(n)?c={value:n}:n instanceof as?c={buffer:n}:c=n;let u={...this.settings,...c};if(ArrayBuffer.isView(c.value)){if(!c.type)if(this.doublePrecision&&c.value instanceof Float64Array)u.type="float32";else{let b=ebt(c.value);u.type=u.normalized?b.replace("int","norm"):b}u.bytesPerElement=c.value.BYTES_PER_ELEMENT,u.stride=kb(u)}if(r.bounds=null,c.constant){let d=c.value;if(d=this._normalizeValue(d,[],0),this.settings.normalized&&(d=this.normalizeConstant(d)),!(!r.constant||!this._areValuesEqual(d,this.value)))return!1;r.externalBuffer=null,r.constant=!0,this.value=ArrayBuffer.isView(d)?d:new Float32Array(d)}else if(c.buffer){let d=c.buffer;r.externalBuffer=d,r.constant=!1,this.value=c.value||null}else if(c.value){this._checkExternalBuffer(c);let d=c.value,b=d;r.externalBuffer=null,r.constant=!1,this.value=d,this._shouldSplitDoublePrecisionValue(b)&&(b=uB(b,u),d instanceof Float32Array&&(u.stride=u.size*2*Float32Array.BYTES_PER_ELEMENT));let{buffer:w}=this,_=kb(u),x=(u.vertexOffset||0)*_;if(this.settings.isIndexed){let M=this.settings.defaultType;b.constructor!==M&&(b=new M(b))}let T=b.byteLength+x+_*2;(!w||w.byteLength(r+128)/255*2-1);case"snorm16":return new Float32Array(n).map(r=>(r+32768)/65535*2-1);case"unorm8":return new Float32Array(n).map(r=>r/255);case"unorm16":return new Float32Array(n).map(r=>r/65535);default:return n}}_normalizeValue(n,r,c){let{defaultValue:u,size:d}=this.settings;if(Number.isFinite(n))return r[c]=n,r;if(!n){let b=d;for(;--b>=0;)r[c+b]=u[b];return r}switch(d){case 4:r[c+3]=Number.isFinite(n[3])?n[3]:u[3];case 3:r[c+2]=Number.isFinite(n[2])?n[2]:u[2];case 2:r[c+1]=Number.isFinite(n[1])?n[1]:u[1];case 1:r[c+0]=Number.isFinite(n[0])?n[0]:u[0];break;default:let b=d;for(;--b>=0;)r[c+b]=Number.isFinite(n[b])?n[b]:u[b]}return r}_areValuesEqual(n,r){if(!n||!r)return!1;let{size:c}=this;for(let u=0;u0&&(ibt.length=s.length,c=ibt):c=nbt,(n>0||Number.isFinite(r))&&(c=(Array.isArray(c)?c:Array.from(c)).slice(n,r),u.index=n-1),{iterable:c,objectInfo:u}}function mue(s){return s&&s[Symbol.asyncIterator]}function bue(s,n){let{size:r,stride:c,offset:u,startIndices:d,nested:b}=n,w=s.BYTES_PER_ELEMENT,_=c?c/w:r,x=u?u/w:0,T=Math.floor((s.length-x)/_);return(M,{index:L,target:I})=>{if(!d){let z=L*_+x;for(let Z=0;Z=n[1]))return s;let r=[],c=s.length,u=0;for(let d=0;dn[1]?r.push(b):n=[Math.min(b[0],n[0]),Math.max(b[1],n[1])]}return r.splice(u,0,n),r}var wnn={interpolation:{duration:0,easing:s=>s},spring:{stiffness:.05,damping:.5}};function wue(s,n){if(!s)return null;Number.isFinite(s)&&(s={type:"interpolation",duration:s});let r=s.type||"interpolation";return{...wnn[r],...n,...s,type:r}}var k4=class extends DV{constructor(n,r){super(n,r,{startIndices:null,constantValue:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:BV}),this.constant=!1,this.settings.update=r.update||(r.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(n){this.state.startIndices=n}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:n=!1}={}){let r=this.state.needsRedraw;return this.state.needsRedraw=r&&!n,r}layoutChanged(){return this.state.layoutChanged}setAccessor(n){var r;(r=this.state).layoutChanged||(r.layoutChanged=!tbt(n,this.getAccessor())),super.setAccessor(n)}getUpdateTriggers(){let{accessor:n}=this.settings;return[this.id].concat(typeof n!="function"&&n||[])}supportsTransition(){return!!this.settings.transition}getTransitionSetting(n){if(!n||!this.supportsTransition())return null;let{accessor:r}=this.settings,c=this.settings.transition,u=Array.isArray(r)?n[r.find(d=>n[d])]:n[r];return wue(u,c)}setNeedsUpdate(n=this.id,r){if(this.state.needsUpdate=this.state.needsUpdate||n,this.setNeedsRedraw(n),r){let{startRow:c=0,endRow:u=1/0}=r;this.state.updateRanges=sbt(this.state.updateRanges,[c,u])}else this.state.updateRanges=BV}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=rbt}setNeedsRedraw(n=this.id){this.state.needsRedraw=this.state.needsRedraw||n}allocate(n){let{state:r,settings:c}=this;if(c.noAlloc)return!1;if(c.update){let u=this.isConstant;return super.allocate(n,r.updateRanges!==BV),r.layoutChanged||(r.layoutChanged=u&&this.device.type==="webgpu"),!0}return!1}updateBuffer({numInstances:n,data:r,props:c,context:u}){if(!this.needsUpdate())return!1;let{state:{updateRanges:d},settings:{update:b,noAlloc:w}}=this,_=!0;if(b){for(let[x,T]of d)b.call(u,this,{data:r,startRow:x,endRow:T,props:c,numInstances:n});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLengthT?x.set(H,F):(n._normalizeValue(H,z.target,0),g1t({target:x,source:z.target,start:F,count:te}));F+=te*T}else n._normalizeValue(H,x,F),F+=T}}_validateAttributeUpdaters(){let{settings:n}=this;if(!(n.noAlloc||typeof n.update=="function"))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){let{value:n}=this,r=Math.min(4,this.size);if(n&&n.length>=r){let c=!0;switch(r){case 4:c=c&&Number.isFinite(n[3]);case 3:c=c&&Number.isFinite(n[2]);case 2:c=c&&Number.isFinite(n[1]);case 1:c=c&&Number.isFinite(n[0]);break;default:c=!1}if(!c)throw new Error(`Illegal attribute generated for ${this.id}`)}}};N3();DRe();N3();var NV=class s{gpuDataEvaluators;format;length;id;_gpuVector;_ownsGPUDataEvaluators;_destroyed=!1;static fromGPUVector(n){if(n.bufferLayout)throw new Error(`GPUVectorEvaluator.fromGPUVector() does not accept interleaved vector "${n.name}"`);if(n.data.length===0)throw new Error(`GPUVectorEvaluator.fromGPUVector() requires GPUData for "${n.name}"`);return new s({id:n.name,gpuDataEvaluators:n.data.map(r=>uc.fromGPUData(r,{id:n.name})),gpuVector:n,format:n.format})}static fromGPUDataEvaluators(n,r={}){return new s({id:r.id,gpuDataEvaluators:n,format:r.format})}constructor({id:n,gpuDataEvaluators:r,gpuVector:c,format:u}){if(r.length===0)throw new Error("GPUVectorEvaluator requires at least one GPUData evaluator");knn(r),this.id=n,this.gpuDataEvaluators=r,this.format=u??r[0].format,this.length=r.reduce((d,b)=>d+b.length,0),this._gpuVector=c,this._ownsGPUDataEvaluators=!c}get evaluated(){return!!this._gpuVector}get gpuVector(){if(!this._gpuVector)throw new Error(`${this} not evaluated`);return this._gpuVector}mapGPUData(n){return s.fromGPUDataEvaluators(this.gpuDataEvaluators.map((r,c)=>n(r,c)),{id:this.id})}async evaluate(n,r={}){if(this._destroyed)throw new Error(`GPUVectorEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let c=await Promise.all(this.gpuDataEvaluators.map(w=>w.evaluate(n,r))),u=c[0],d=c.map(bbt),b=r.format??this.format??u.format;return this._gpuVector=new c2({type:"data",name:r.name??this.id??"vector",format:b,data:d,stride:u.stride,byteStride:u.byteStride,rowByteLength:u.rowByteLength,bufferLayout:u.bufferLayout}),this._gpuVector}evaluateSync(n,r={}){if(this._destroyed)throw new Error(`GPUVectorEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let c=this.gpuDataEvaluators.map(w=>w.evaluateSync(n,r)),u=c[0],d=c.map(bbt),b=r.format??this.format??u.format;return this._gpuVector=new c2({type:"data",name:r.name??this.id??"vector",format:b,data:d,stride:u.stride,byteStride:u.byteStride,rowByteLength:u.rowByteLength,bufferLayout:u.bufferLayout}),this._gpuVector}destroy(){if(this._ownsGPUDataEvaluators)for(let n of this.gpuDataEvaluators)n.destroy();this._gpuVector=void 0,this._destroyed=!0}toString(){return this.id??this.constructor.name}};function knn(s){let n=s[0];for(let r of s.slice(1))if(r.type!==n.type||r.size!==n.size||r.normalized!==n.normalized||r.format!==n.format)throw new Error("GPUVectorEvaluator requires matching GPUData evaluator layouts")}function bbt(s){let[n,...r]=s.data;if(!n||r.length>0)throw new Error(`GPUVectorEvaluator requires one GPUData chunk for "${s.name}"`);return n}N3();$r();var FRe={};Oy(FRe,{arithmetic:()=>wbt,dot:()=>Sbt,equalAll:()=>Mbt,extent:()=>_bt,fround:()=>ybt,gather:()=>xbt,interleave:()=>Ebt,length:()=>Tbt,segmentedMap:()=>Cbt,select:()=>Abt,sequence:()=>Pbt,swizzle:()=>Lbt});Tue();function TB({elementWise:s,func:n,inputs:r,output:c,outputBuffer:u}){let d=Array.isArray(r)?r:Object.values(r);for(let D of d)if(!D.value)throw new Error(`${D} does not have CPU value`);let b=c.length,w=c.size,_=new c.ValueType(b*w);for(let D=0;Ddf(O,D));if(s)for(let O=0;Oz[O]));else n.call(null,_.subarray(D*w,D*w+w),...F)}let x=c.ValueType.BYTES_PER_ELEMENT,T=c.offset/x,M=c.stride/x,L=w,I=_;if(T!==0||M!==L){I=new c.ValueType(T+c.byteLength/x);for(let D=0;D{for(let u of Object.values(s.namedInputs))if(!u.value)throw new Error(`${u} does not have CPU value`);let c=new n.ValueType(n.length*n.size);for(let u=0;u[b,df(w,u)]));for(let b=0;bvbt(u,n,r));switch(s.op){case"add":return c[0]+c[1];case"subtract":return c[0]-c[1];case"multiply":return c[0]*c[1];case"divide":return c[0]/c[1];case"pow":return Math.pow(c[0],c[1]);case"sqrt":return Math.sqrt(c[0]);case"abs":return Math.abs(c[0]);case"sin":return Math.sin(c[0]);case"cos":return Math.cos(c[0]);case"tan":return Math.tan(c[0]);case"exp":return Math.exp(c[0]);case"log":return Math.log(c[0]);default:{let u=s.op;throw new Error(`Unsupported arithmetic op ${u}`)}}}default:{let c=s;throw new Error(`Unsupported expression node ${c.kind}`)}}}function Inn(s,n){let r=MB[s].arity;if(n!==r)throw new Error(`Arithmetic op '${s}' expects ${r} args, got ${n}`)}var _bt=({inputs:s,output:n,target:r})=>{let{sourceValues:c}=s;if(!c.value)throw new Error(`${c} does not have CPU value`);let d=new n.ValueType(n.length*n.size);if(c.length===0)return{success:!1,error:new Error(`${c} is empty`)};for(let b=0;bd[x]&&(d[x]=M)}}return r.write(d),{success:!0,value:d}};var ybt=({inputs:s,output:n,target:r})=>TB({func:(c,u)=>{let d=c.length/2,b=new Float64Array(u.buffer);for(let w=0;w{let{ids:c,sourceValues:u}=s,d=c.value,b=u.value;if(!d)throw new Error(`${c} does not have CPU value`);if(!b)throw new Error(`${u} does not have CPU value`);let w=new n.ValueType(n.length*n.size),_=new Array(n.size).fill(0);for(let x=0;x=0&&sTB({func:(c,...u)=>{let d=0;for(let b of u)c.set(b,d),d+=b.length},inputs:s,output:n,outputBuffer:r});var Sbt=({inputs:s,output:n,target:r})=>{let{x:c,y:u}=s,d=new n.ValueType(n.length);for(let b=0;b{let{x:c,y:u}=s,d=new n.ValueType(n.length);for(let b=0;b{let{x:c}=s,u=new n.ValueType(n.length);for(let d=0;d{let{segments:c,vertexCount:u}=s,d=c.value;if(!d)throw new Error(`${c} does not have CPU value`);Bnn(d,c,u);let b=new n.ValueType(n.length*n.size),w=0;for(let _=0;_0&&dr)throw new Error(`segmentedMap last segment start must be <= vertexCount, got ${c} > ${r}`)}function ORe(s,n){return s.offset/s.ValueType.BYTES_PER_ELEMENT+n*(s.stride/s.ValueType.BYTES_PER_ELEMENT)}var Abt=async({inputs:s,output:n,target:r})=>{let{condition:c,whenTrue:u,whenFalse:d}=s,b=new n.ValueType(n.length*n.size);for(let w=0;w{let c=new n.ValueType(n.length);for(let u=0;u{let{columns:c}=s;return TB({func:(u,d)=>{for(let b=0;b({...b,...w}));return this._modules[n]=d,d.then(b=>{this._modules[n]=b}).catch(b=>{Qt.error(`Failed to register ${n} backend: ${b}`)()}),d}if(c&&typeof c.then=="function"){let d=Promise.resolve(c).then(b=>({...b,...r})).then(b=>(this._modules[n]=b,b)).catch(b=>{throw Qt.error(`Failed to register ${n} backend: ${b}`)(),b});return this._modules[n]=d,d}let u={...c||{},...r};return this._modules[n]=u,Promise.resolve(u)}async get(n,r){let c=this._modules[n];if(!c)if(n==="webgl")c=this.add("webgl",Promise.resolve().then(()=>(owt(),swt)));else if(n==="webgpu")c=this.add("webgpu",Promise.resolve().then(()=>(ZRe(),Rwt)));else throw new Error(`${n} backend not registered`);let d=(await c)[r];if(typeof d!="function")throw new Error(`${n} backend does not implement ${r}`);return d}getSync(n,r){let c=this._modules[n];if(!c)throw new Error(`${n} backend not registered`);if(typeof c.then=="function")throw new Error(`${n} backend is not loaded yet`);let d=c[r];if(typeof d!="function")throw new Error(`${n} backend does not implement ${r}`);return d}clear(){this._modules={}}},RB=new KRe;var Bue=class{inputs;dependencies;constructor(n){this.inputs=n,this.dependencies=Array.from(n instanceof Array?n:Object.values(n)).filter(r=>r instanceof uc)}async execute(n,r){return await this._resolveDependencies(n),await this._executeWithHandler(await RB.get(this._getHandlerRegistry(n),this.name),r)}executeSync(n,r){this._resolveDependenciesSync(n);let c=this._executeWithHandler(RB.getSync(this._getHandlerRegistry(n),this.name),r);if(Tin(c))throw new Error(`${this.name} returned a Promise in executeSync()`);return c}shouldExecuteOnCPU(){return this.output.length<=1&&Array.from(this.dependencies).every(n=>!!n.value)}_getHandlerRegistry(n){return this.shouldExecuteOnCPU()?"cpu":n.type}async _resolveDependencies(n){for(let c of this.dependencies)await c.evaluate(n);if(this._getHandlerRegistry(n)==="cpu"||n.type==="null")for(let c of this.dependencies)await c.ensureCPUValue()}_resolveDependenciesSync(n){for(let c of this.dependencies)c.evaluateSync(n);if(this._getHandlerRegistry(n)==="cpu"||n.type==="null")for(let c of this.dependencies)c.ensureCPUValueSync()}_executeWithHandler(n,r){return n({device:r.device,inputs:this.inputs,output:this.output,target:r})}};function Tin(s){return typeof s?.then=="function"}function Iwt(...s){let n=Cin(s.map(r=>r.type));return n[0]!=="f"&&s.some(r=>r.normalized)&&(n="float32"),{isConstant:s.every(r=>r.isConstant),type:n,size:s.reduce((r,c)=>Math.max(r,c.size),0),length:s.reduce((r,c)=>Math.max(r,c.length),0)}}function Cin(s){let n=0,r=0;for(let c of s){if(c[0]==="f")return"float32";let u=c.endsWith("8")?8:c.endsWith("6")?16:32;c[0]==="u"?n=Math.max(n,u):r=Math.max(r,u)}return n&&!r?`uint${n}`:r&&n<32?`sint${Math.max(r,n*2)}`:"float32"}N3();var JRe=class extends Bue{name="interleave";output;constructor(n){super(n);let{isConstant:r,type:c,length:u}=Iwt(...n);this.output=new uc({isConstant:r,type:c,size:n.reduce((d,b)=>d+b.size,0),length:u,source:this})}toString(){return`_${this.inputs.join("_")}_`}};function QRe(...s){if(s.length===0)throw new Error("interleave() requires at least one input");return s.length===1?Mue(s[0]):new JRe(s.map(Mue)).output}Jl();N3();function tIe(s,n){let r=Pin(n);for(let c of r)c.evaluateSync(s);return Ain(r),n}function Ain(s){let n=new Set(s.flatMap(kin)),r=new Set;for(let c of s)Oue(c,r);for(let c of r)c.evaluated&&!n.has(c.buffer)&&c.destroy()}function Pin(s){let n=new Set;return eIe(s,n,new Set),Array.from(n)}function eIe(s,n,r){if(Rin(s)){n.add(s);return}if(!(!s||typeof s!="object"||r.has(s))){if(r.add(s),Array.isArray(s)){for(let c of s)eIe(c,n,r);return}if(Lin(s))for(let c of Object.values(s))eIe(c,n,r)}}function Lin(s){let n=Object.getPrototypeOf(s);return n===Object.prototype||n===null}function Oue(s,n){if(s instanceof NV){for(let c of s.gpuDataEvaluators)Oue(c,n);return}let r=s.source;if(r){if(r instanceof uc){n.has(r)||(n.add(r),Oue(r,n));return}for(let c of r.dependencies)n.has(c)||(n.add(c),Oue(c,n))}}function kin(s){return s instanceof uc?[s.buffer]:s.gpuVector.data.map(n=>n.buffer instanceof lp?n.buffer.buffer:n.buffer)}function Rin(s){return s instanceof uc||s instanceof NV}ZRe();var UV=class{constructor(n,{id:r,isTransitionAttribute:c}){this.packedBuffers={},this.device=n,this.id=r,this.isTransitionAttribute=c,this.device.type==="webgpu"&&RB.add("webgpu",{interleave:Due})}hasGroups(n){return this.device.type==="webgpu"&&Object.values(n).some(r=>!!r.settings.bufferGroup)}finalize(){for(let n of Object.values(this.packedBuffers))n.packed.destroy();this.packedBuffers={}}getBufferLayouts(n,r){let c=this._getPackedGroups(n,r,{requireValues:!1,excludeAttributes:{}});return this._getBufferLayouts(n,c,r)}getBindings(n,r,c,u){let d=this._getPackedGroups(n,c,{requireValues:!0,excludeAttributes:u}),b={},w=new Set;for(let _ of d.values()){let x=!this.packedBuffers[_.id]||_.attributes.some(T=>!!r[T.id]);b[_.id]=this._getPackedBuffer(_,x);for(let T of _.attributes)w.add(T.id)}return{bufferLayouts:this._getBufferLayouts(n,d,c).filter(_=>!u[_.name]&&!n[_.name]?.settings.isIndexed),buffers:b,groupedAttributeIds:w}}_getPackedGroups(n,r,{requireValues:c,excludeAttributes:u}){let d=new Map;for(let w of Object.values(n)){let _=w.settings.bufferGroup;if(!_)continue;let x=d.get(_)||[];x.push(w),d.set(_,x)}let b=new Map;for(let[w,_]of d){let x=this._getPackedGroup(w,_,r,c,u);x&&b.set(w,x)}return b}_getPackedGroup(n,r,c,u,d){if(r.length<2)return null;let b=r.map(I=>I.getBufferLayout(c)),w=b[0].stepMode,_=Math.max(1,r[0].numInstances),x=u&&r.every(I=>I.isConstant);for(let I=0;Ithis._getInterleaveInput(n,u)),c=QRe(...r);return tIe(this.device,c),c}_getInterleaveInput(n,r){let c=kb(r.getAccessor()),u=n.byteOffsets[r.id];if(FV(`${n.id}.${r.id} rowByteLength`,c),FV(`${n.id}.${r.id} groupByteOffset`,u),r.isConstant){let _=r.getConstantValue();if(!_)throw new Error(`Attribute group ${n.id} is missing constant value ${r.id}`);return FV(`${n.id}.${r.id} constant byteOffset`,_.byteOffset),new uc({id:r.id,type:"uint32",size:c/4,isConstant:!0,value:new Uint32Array(_.buffer,_.byteOffset,c/Uint32Array.BYTES_PER_ELEMENT)})}let d=r.getBuffer(),b=r.byteOffset,w=r.getAccessor().stride||c;if(FV(`${n.id}.${r.id} byteOffset`,b),FV(`${n.id}.${r.id} stride`,w),!d)throw new Error(`Attribute group ${n.id} cannot interleave missing buffer ${r.id}`);return new uc({id:r.id,type:"uint32",size:c/4,offset:b,stride:w,length:n.rowCount,buffer:d})}};function Dwt(s){return Math.ceil(s/4)*4}function FV(s,n){if(n%4!==0)throw new Error(`Attribute buffer groups require 32-bit alignment: ${s}=${n}`)}Jl();vm();function nIe(s){let{source:n,target:r,start:c=0,size:u,getData:d}=s,b=s.end||r.length,w=n.length,_=b-c;if(w>_){r.set(n.subarray(0,_),c);return}if(r.set(n,c),!d)return;let x=w;for(;x<_;){let T=d(x,n);for(let M=0;Mc(T+w,M)),x=Math.min(u.length,d.length);for(let T=1;Tw}){let w=r.isDoublePrecisionBuffer?2:1,_=r.size*w,x=r.byteOffset,T=r.settings.bytesPerElement<4?x/r.settings.bytesPerElement*4:x,M=r.startIndices,L=d&&M,I=r.isConstant;if(!L&&n&&c>=u)return n;let D=r.value instanceof Float64Array?Float32Array:r.value.constructor,F=I?r.value:new D(r.getBuffer().readSyncWebGL(x,u*D.BYTES_PER_ELEMENT).buffer);if(r.settings.normalized&&!I){let H=b;b=(te,se)=>r.normalizeConstant(H(te,se))}let O=I?(H,te)=>b(F,te):(H,te)=>b(F.subarray(H+x,H+x+_),te),z=n?new Float32Array(n.readSyncWebGL(T,c*4).buffer):new Float32Array(0),Z=new Float32Array(u);return Bwt({source:z,target:Z,sourceStartIndices:d,targetStartIndices:M,size:_,getData:O}),(!n||n.byteLength0||u.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}},Nin=`layout(std140) uniform springUniforms { + float damping; + float stiffness; +} spring; +`,Fin={name:"spring",vs:Nin,uniformTypes:{damping:"f32",stiffness:"f32"}},Uin=`#version 300 es +#define SHADER_NAME spring-transition-vertex-shader + +#define EPSILON 0.00001 + +in ATTRIBUTE_TYPE aPrev; +in ATTRIBUTE_TYPE aCur; +in ATTRIBUTE_TYPE aTo; +out ATTRIBUTE_TYPE vNext; +out float vIsTransitioningFlag; + +ATTRIBUTE_TYPE getNextValue(ATTRIBUTE_TYPE cur, ATTRIBUTE_TYPE prev, ATTRIBUTE_TYPE dest) { + ATTRIBUTE_TYPE velocity = cur - prev; + ATTRIBUTE_TYPE delta = dest - cur; + ATTRIBUTE_TYPE force = delta * spring.stiffness; + ATTRIBUTE_TYPE resistance = velocity * spring.damping; + return force - resistance + velocity + cur; +} + +void main(void) { + bool isTransitioning = length(aCur - aPrev) > EPSILON || length(aTo - aCur) > EPSILON; + vIsTransitioningFlag = isTransitioning ? 1.0 : 0.0; + + vNext = getNextValue(aCur, aPrev, aTo); + gl_Position = vec4(0, 0, 0, 1); + gl_PointSize = 100.0; +} +`,zin=`#version 300 es +#define SHADER_NAME spring-transition-is-transitioning-fragment-shader + +in float vIsTransitioningFlag; + +out vec4 fragColor; + +void main(void) { + if (vIsTransitioningFlag == 0.0) { + discard; + } + fragColor = vec4(1.0); +}`;function Gin(s,n){let r=Nue(n.size),c=Fue(n.size);return new up(s,{vs:Uin,fs:zin,bufferLayout:[{name:"aPrev",format:c},{name:"aCur",format:c},{name:"aTo",format:n.getBufferLayout().attributes[0].format}],varyings:["vNext"],modules:[Fin],defines:{ATTRIBUTE_TYPE:r},parameters:{depthCompare:"always",blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}})}function jin(s){return s.createTexture({data:new Uint8Array(4),format:"rgba8unorm",width:1,height:1})}function $in(s,n){return s.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[n]})}var Vin={interpolation:zV,spring:GV},jV=class{constructor(n,{id:r,timeline:c}){if(!n)throw new Error("AttributeTransitionManager is constructed without device");this.id=r,this.device=n,this.timeline=c,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(let n in this.transitions)this._removeTransition(n)}update({attributes:n,transitions:r,numInstances:c}){this.numInstances=c||1;for(let u in n){let d=n[u],b=d.getTransitionSetting(r);b&&this._updateAttribute(u,d,b)}for(let u in this.transitions){let d=n[u];(!d||!d.getTransitionSetting(r))&&this._removeTransition(u)}}hasAttribute(n){let r=this.transitions[n];return r&&r.inProgress}getAttributes(){let n={};for(let r in this.transitions){let c=this.transitions[r];c.inProgress&&(n[r]=c.attributeInTransition)}return n}run(){if(this.numInstances===0)return!1;for(let r in this.transitions)this.transitions[r].update()&&(this.needsRedraw=!0);let n=this.needsRedraw;return this.needsRedraw=!1,n}_removeTransition(n){this.transitions[n].delete(),delete this.transitions[n]}_updateAttribute(n,r,c){let u=this.transitions[n],d=!u||u.type!==c.type;if(d){u&&this._removeTransition(n);let b=Vin[c.type];b?this.transitions[n]=new b({attribute:r,timeline:this.timeline,device:this.device}):(Bs.error(`unsupported transition type '${c.type}'`)(),d=!1)}(d||r.needsRedraw())&&(this.needsRedraw=!0,this.transitions[n].start(c,this.numInstances))}};var zwt="attributeManager.invalidate",Win="attributeManager.updateStart",Hin="attributeManager.updateEnd",qin="attribute.updateStart",Xin="attribute.allocate",Yin="attribute.updateEnd",$V=class{constructor(n,{id:r="attribute-manager",stats:c,timeline:u}={}){this.mergeBoundsMemoized=Yy(kmt),this.id=r,this.device=n,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=c,this.attributeTransitionManager=new jV(n,{id:`${r}-transitions`,timeline:u}),this.attributeBufferGroups=n.type==="webgpu"?new UV(n,{id:r,isTransitionAttribute:d=>this.attributeTransitionManager.hasAttribute(d)}):null,Object.seal(this)}finalize(){this.attributeBufferGroups?.finalize();for(let n in this.attributes)this.attributes[n].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(n={clearRedrawFlags:!1}){let r=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!n.clearRedrawFlags,r&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(n){this._add(n)}addInstanced(n){this._add(n,{stepMode:"instance"})}remove(n){for(let r of n)this.attributes[r]!==void 0&&(this.attributes[r].delete(),delete this.attributes[r])}invalidate(n,r){let c=this._invalidateTrigger(n,r);If(zwt,this,n,c)}invalidateAll(n){for(let r in this.attributes)this.attributes[r].setNeedsUpdate(r,n);If(zwt,this,"all")}update({data:n,numInstances:r,startIndices:c=null,transitions:u,props:d={},buffers:b={},context:w={}}){let _=!1;If(Win,this),this.stats&&this.stats.get("Update Attributes").timeStart();for(let x in this.attributes){let T=this.attributes[x],M=T.settings.accessor;T.startIndices=c,T.numInstances=r,d[x]&&Bs.removed(`props.${x}`,`data.attributes.${x}`)(),T.setExternalBuffer(b[x])||T.setBinaryValue(typeof M=="string"?b[M]:void 0,n.startIndices)||typeof M=="string"&&!b[M]&&T.setConstantValue(w,d[M])||T.needsUpdate()&&(_=!0,this._updateAttribute({attribute:T,numInstances:r,data:n,props:d,context:w})),this.needsRedraw=this.needsRedraw||T.needsRedraw()}_&&If(Hin,this,r),this.stats&&(this.stats.get("Update Attributes").timeEnd(),_&&this.stats.get("Attributes updated").incrementCount()),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:r,transitions:u})}updateTransition(){let{attributeTransitionManager:n}=this,r=n.run();return this.needsRedraw=this.needsRedraw||r,r}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(n){let r=n.map(c=>this.attributes[c]?.getBounds());return this.mergeBoundsMemoized(r)}getChangedAttributes(n={clearChangedFlags:!1}){let{attributes:r,attributeTransitionManager:c}=this,u={...c.getAttributes()};for(let d in r){let b=r[d];b.needsRedraw(n)&&!c.hasAttribute(d)&&(u[d]=b)}return u}getBufferLayouts(n){return this.hasBufferGroups()?this.attributeBufferGroups.getBufferLayouts(this.getAttributes(),n):Object.values(this.getAttributes()).map(r=>r.getBufferLayout(n))}hasBufferGroups(){return!!this.attributeBufferGroups?.hasGroups(this.attributes)}getBufferGroupBindings(n,r,c={}){return this.attributeBufferGroups?this.attributeBufferGroups.getBindings(this.getAttributes(),n,r,c):{bufferLayouts:this.getBufferLayouts(r),buffers:{},groupedAttributeIds:new Set}}_add(n,r){for(let c in n){let u=n[c],d={...u,id:c,size:u.isIndexed&&1||u.size||1,...r};this.attributes[c]=new k4(this.device,d)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){let n={};for(let r in this.attributes)this.attributes[r].getUpdateTriggers().forEach(u=>{n[u]||(n[u]=[]),n[u].push(r)});this.updateTriggers=n}_invalidateTrigger(n,r){let{attributes:c,updateTriggers:u}=this,d=u[n];return d&&d.forEach(b=>{let w=c[b];w&&w.setNeedsUpdate(w.id,r)}),d}_updateAttribute(n){let{attribute:r,numInstances:c}=n;if(If(qin,r),r.constant){r.setConstantValue(n.context,r.value);return}r.allocate(c)&&If(Xin,r,c),r.updateBuffer(n)&&(this.needsRedraw=!0,If(Yin,r,c))}};$r();fue();Bf();var VV=class extends pv{get value(){return this._value}_onUpdate(){let{time:n,settings:{fromValue:r,toValue:c,duration:u,easing:d}}=this,b=d(n/u);this._value=av(r,c,b)}};var Gwt=1e-5;function jwt(s,n,r,c,u){let d=n-s,w=(r-n)*u,_=-d*c;return w+_+d+n}function Zin(s,n,r,c,u){if(Array.isArray(r)){let d=[];for(let b=0;b0}add(n,r,c,u){let{transitions:d}=this;if(d.has(n)){let _=d.get(n),{value:x=_.settings.fromValue}=_;r=x,this.remove(n)}if(u=wue(u),!u)return;let b=Kin[u.type];if(!b){Bs.error(`unsupported transition type '${u.type}'`)();return}let w=new b(this.timeline);w.start({...u,fromValue:r,toValue:c}),d.set(n,w)}remove(n){let{transitions:r}=this;r.has(n)&&(r.get(n).cancel(),r.delete(n))}update(){let n={};for(let[r,c]of this.transitions)c.update(),n[r]=c.value,c.inProgress||this.remove(r);return n}clear(){for(let n of this.transitions.keys())this.remove(n)}};function Wwt(s){let n=s[t2];for(let r in n){let c=n[r],{validate:u}=c;if(u&&!u(s[r],c))throw new Error(`Invalid prop ${r}: ${s[r]}`)}}function Hwt(s,n){let r=qwt({newProps:s,oldProps:n,propTypes:s[t2],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),c=Qin(s,n),u=!1;return c||(u=ern(s,n)),{dataChanged:c,propsChanged:r,updateTriggersChanged:u,extensionsChanged:trn(s,n),transitionsChanged:Jin(s,n)}}function Jin(s,n){if(!s.transitions)return!1;let r={},c=s[t2],u=!1;for(let d in s.transitions){let b=c[d],w=b&&b.type;(w==="number"||w==="color"||w==="array")&&iIe(s[d],n[d],b)&&(r[d]=!0,u=!0)}return u?r:!1}function qwt({newProps:s,oldProps:n,ignoreProps:r={},propTypes:c={},triggerName:u="props"}){if(n===s)return!1;if(typeof s!="object"||s===null)return`${u} changed shallowly`;if(typeof n!="object"||n===null)return`${u} changed shallowly`;for(let d of Object.keys(s))if(!(d in r)){if(!(d in n))return`${u}.${d} added`;let b=iIe(s[d],n[d],c[d]);if(b)return`${u}.${d} ${b}`}for(let d of Object.keys(n))if(!(d in r)){if(!(d in s))return`${u}.${d} dropped`;if(!Object.hasOwnProperty.call(s,d)){let b=iIe(s[d],n[d],c[d]);if(b)return`${u}.${d} ${b}`}}return!1}function iIe(s,n,r){let c=r&&r.equal;return c&&!c(s,n,r)||!c&&(c=s&&n&&s.equals,c&&!c.call(s,n))?"changed deeply":!c&&n!==s?"changed shallowly":null}function Qin(s,n){if(n===null)return"oldProps is null, initial diff";let r=!1,{dataComparator:c,_dataDiff:u}=s;return c?c(s.data,n.data)||(r="Data comparator detected a change"):s.data!==n.data&&(r="A new data container was supplied"),r&&u&&(r=u(s.data,n.data)||r),r}function ern(s,n){if(n===null)return{all:!0};if("all"in s.updateTriggers&&Vwt(s,n,"all"))return{all:!0};let r={},c=!1;for(let u in s.updateTriggers)u!=="all"&&Vwt(s,n,u)&&(r[u]=!0,c=!0);return c?r:!1}function trn(s,n){if(n===null)return!0;let r=n.extensions,{extensions:c}=s;if(c===r)return!1;if(!r||!c||c.length!==r.length)return!0;for(let u=0;uc.name==="project64"))){let c=r.modules.findIndex(u=>u.name==="project32");c>=0&&r.modules.splice(c,1)}if("inject"in n)if(!s.inject)r.inject=n.inject;else{let c={...s.inject};for(let u in n.inject)c[u]=(c[u]||"")+n.inject[u];r.inject=c}return r}$r();var orn={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},rIe={};function Ywt(s,n,r,c){if(r instanceof Aa)return r;r.constructor&&r.constructor.name!=="Object"&&(r={data:r});let u=null;r.compressed&&(u={minFilter:"linear",mipmapFilter:r.data.length>1?"nearest":"linear"});let{width:d,height:b}=r.data,w=n.createTexture({...r,sampler:{...orn,...u,...c},mipLevels:n.getMipLevelCount(d,b)});return n.type==="webgl"?w.generateMipmapsWebGL():n.type==="webgpu"&&n.generateMipmapsWebGPU(w),rIe[w.id]=s,w}function Zwt(s,n){!n||!(n instanceof Aa)||rIe[n.id]===s&&(n.delete(),delete rIe[n.id])}var arn={boolean:{validate(s,n){return!0},equal(s,n,r){return!!s==!!n}},number:{validate(s,n){return Number.isFinite(s)&&(!("max"in n)||s<=n.max)&&(!("min"in n)||s>=n.min)}},color:{validate(s,n){return n.optional&&!s||sIe(s)&&(s.length===3||s.length===4)},equal(s,n,r){return Cc(s,n,1)}},accessor:{validate(s,n){let r=jue(s);return r==="function"||r===jue(n.value)},equal(s,n,r){return typeof n=="function"?!0:Cc(s,n,1)}},array:{validate(s,n){return n.optional&&!s||sIe(s)},equal(s,n,r){let{compare:c}=r,u=Number.isInteger(c)?c:c?1:0;return c?Cc(s,n,u):s===n}},object:{equal(s,n,r){if(r.ignore)return!0;let{compare:c}=r,u=Number.isInteger(c)?c:c?1:0;return c?Cc(s,n,u):s===n}},function:{validate(s,n){return n.optional&&!s||typeof s=="function"},equal(s,n,r){return!r.compare&&r.ignore!==!1||s===n}},data:{transform:(s,n,r)=>{if(!s)return s;let{dataTransform:c}=r.props;return c?c(s):typeof s.shape=="string"&&s.shape.endsWith("-table")&&Array.isArray(s.data)?s.data:s}},image:{transform:(s,n,r)=>{let c=r.context;return!c||!c.device?null:Ywt(r.id,c.device,s,{...n.parameters,...r.props.textureParameters})},release:(s,n,r)=>{Zwt(r.id,s)}}};function Kwt(s){let n={},r={},c={};for(let[u,d]of Object.entries(s)){let b=d?.deprecatedFor;if(b)c[u]=Array.isArray(b)?b:[b];else{let w=crn(u,d);n[u]=w,r[u]=w.value}}return{propTypes:n,defaultProps:r,deprecatedProps:c}}function crn(s,n){switch(jue(n)){case"object":return qV(s,n);case"array":return qV(s,{type:"array",value:n,compare:!1});case"boolean":return qV(s,{type:"boolean",value:n});case"number":return qV(s,{type:"number",value:n});case"function":return qV(s,{type:"function",value:n,compare:!0});default:return{name:s,type:"unknown",value:n}}}function qV(s,n){return"type"in n?{name:s,...arn[n.type],...n}:"value"in n?{name:s,type:jue(n.value),...n}:{name:s,type:"object",value:n}}function sIe(s){return Array.isArray(s)||ArrayBuffer.isView(s)}function jue(s){return sIe(s)?"array":s===null?"null":typeof s}function Jwt(s,n){let r;for(let d=n.length-1;d>=0;d--){let b=n[d];"extensions"in b&&(r=b.extensions)}let c=oIe(s.constructor,r),u=Object.create(c);u[bB]=s,u[n2]={},u[dv]={};for(let d=0;d{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(let n in this.asyncProps){let r=this.asyncProps[n];r&&r.type&&r.type.release&&r.type.release(r.resolvedValue,r.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||brn}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(n){return n in this.asyncProps}getAsyncProp(n){let r=this.asyncProps[n];return r&&r.resolvedValue}isAsyncPropLoading(n){if(n){let r=this.asyncProps[n];return!!(r&&r.pendingLoadCount>0&&r.pendingLoadCount!==r.resolvedLoadCount)}for(let r in this.asyncProps)if(this.isAsyncPropLoading(r))return!0;return!1}reloadAsyncProp(n,r){this._watchPromise(n,Promise.resolve(r))}setAsyncProps(n){this.component=n[bB]||this.component;let r=n[dv]||{},c=n[n2]||n,u=n[R3]||{};for(let d in r){let b=r[d];this._createAsyncPropData(d,u[d]),this._updateAsyncProp(d,b),r[d]=this.getAsyncProp(d)}for(let d in c){let b=c[d];this._createAsyncPropData(d,u[d]),this._updateAsyncProp(d,b)}}_fetch(n,r){return null}_onResolve(n,r){}_onError(n,r){}_updateAsyncProp(n,r){if(this._didAsyncInputValueChange(n,r)){if(typeof r=="string"&&(r=this._fetch(n,r)),r instanceof Promise){this._watchPromise(n,r);return}if(mue(r)){this._resolveAsyncIterable(n,r);return}this._setPropValue(n,r)}}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(let n in this.asyncProps)Object.defineProperty(this.oldAsyncProps,n,{enumerable:!0,value:this.oldProps[n]})}}_didAsyncInputValueChange(n,r){let c=this.asyncProps[n];return r===c.resolvedValue||r===c.lastValue?!1:(c.lastValue=r,!0)}_setPropValue(n,r){this._freezeAsyncOldProps();let c=this.asyncProps[n];c&&(r=this._postProcessValue(c,r),c.resolvedValue=r,c.pendingLoadCount++,c.resolvedLoadCount=c.pendingLoadCount)}_setAsyncPropValue(n,r,c){let u=this.asyncProps[n];u&&c>=u.resolvedLoadCount&&r!==void 0&&(this._freezeAsyncOldProps(),u.resolvedValue=r,u.resolvedLoadCount=c,this.onAsyncPropUpdated(n,r))}_watchPromise(n,r){let c=this.asyncProps[n];if(c){c.pendingLoadCount++;let u=c.pendingLoadCount;r.then(d=>{this.component&&(d=this._postProcessValue(c,d),this._setAsyncPropValue(n,d,u),this._onResolve(n,d))}).catch(d=>{this._onError(n,d)})}}async _resolveAsyncIterable(n,r){if(n!=="data"){this._setPropValue(n,r);return}let c=this.asyncProps[n];if(!c)return;c.pendingLoadCount++;let u=c.pendingLoadCount,d=[],b=0;for await(let w of r){if(!this.component)return;let{dataTransform:_}=this.component.props;_?d=_(w,d):d=d.concat(w),Object.defineProperty(d,"__diff",{enumerable:!1,value:[{startRow:b,endRow:d.length}]}),b=d.length,this._setAsyncPropValue(n,d,u)}this._onResolve(n,d)}_postProcessValue(n,r){let c=n.type;return c&&this.component&&(c.release&&c.release(n.resolvedValue,c,this.component),c.transform)?c.transform(r,c,this.component):r}_createAsyncPropData(n,r){if(!this.asyncProps[n]){let u=this.component&&this.component.props[t2];this.asyncProps[n]={type:u&&u[n],lastValue:null,resolvedValue:r,pendingLoadCount:0,resolvedLoadCount:0}}}};var ZV=class extends YV{constructor({attributeManager:n,layer:r}){super(r),this.attributeManager=n,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1,this.disabledPickingIndices=[]}get layer(){return this.component}_fetch(n,r){let c=this.layer,u=c?.props.fetch;return u?u(r,{propName:n,layer:c}):super._fetch(n,r)}_onResolve(n,r){let c=this.layer;if(c){let u=c.props.onDataLoad;n==="data"&&u&&u(r,{propName:n,layer:c})}}_onError(n,r){let c=this.layer;c&&c.raiseError(r,`loading ${n} of ${this.layer}`)}};var wrn="layer.changeFlag",vrn="layer.initialize",_rn="layer.update",yrn="layer.finalize",xrn="layer.matched",evt=2**24-1,Ern=Object.freeze([]),Srn=Yy(({oldViewport:s,viewport:n})=>s.equals(n)),Rb=new Uint8ClampedArray(0);function tvt(s){return s.rowIndexes||s.pickingColors||s.instancePickingColors}function cIe(s){return s.rowIndexes}function lIe(s){return s.pickingColors||s.instancePickingColors}var Mrn={data:{type:"data",value:Ern,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:s=>s&&s.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(s,{propName:n,layer:r,loaders:c,loadOptions:u,signal:d})=>{let{resourceManager:b}=r.context;u=u||r.getLoadOptions(),c=c||r.props.loaders,d&&(u={...u,core:{...u?.core,fetch:{...u?.core?.fetch,signal:d}}});let w=b.contains(s);return!w&&!u&&(b.add({resourceId:s,data:BD(s,c),persistent:!1}),w=!0),w?b.subscribe({resourceId:s,onChange:_=>r.internalState?.reloadAsyncProp(n,_),consumerId:r.id,requestId:n}):BD(s,c,u)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:"default",coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:s})=>[0,-s*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}},KV=class extends $ue{constructor(){super(...arguments),this.internalState=null,this.lifecycle=qM.NO_STATE,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let n=this;for(;n.parent;)n=n.parent;return n}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(n){Pa(this.internalState);let r=this.internalState.viewport||this.context.viewport,c=Ele(n,{viewport:r,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[u,d,b]=HM(c,r.pixelProjectionMatrix);return n.length===2?[u,d]:[u,d,b]}unproject(n){return Pa(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(n)}projectPosition(n,r){Pa(this.internalState);let c=this.internalState.viewport||this.context.viewport;return Dmt(n,{viewport:c,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...r})}get isComposite(){return!1}get isDrawable(){return!0}setState(n){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,n),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return this.internalState?!this.internalState.isAsyncPropLoading():!1}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){let n=this.state;return n&&(n.models||n.model&&[n.model])||[]}setShaderModuleProps(...n){for(let r of this.getModels())r.shaderInputs.setProps(...n)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){let{coordinateSystem:n}=this.props;return n==="default"||n==="lnglat"||n==="cartesian"}onHover(n,r){return this.props.onHover&&this.props.onHover(n,r)||!1}onClick(n,r){return this.props.onClick&&this.props.onClick(n,r)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(n,r=[]){return r[0]=n+1&255,r[1]=n+1>>8&255,r[2]=n+1>>8>>8&255,r}decodePickingColor(n){Pa(n instanceof Uint8Array);let[r,c,u]=n;return r+c*256+u*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:Xwt(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds(["positions","instancePositions"])}getShaders(n){n=D4(n,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(let r of this.props.extensions)n=D4(n,r.getShaders.call(this,r));return n}shouldUpdateState(n){return n.changeFlags.propsOrDataChanged}updateState(n){let r=this.getAttributeManager(),{dataChanged:c}=n.changeFlags;if(c&&r)if(Array.isArray(c))for(let u of c)r.invalidateAll(u);else r.invalidateAll();if(r){let{props:u}=n,d=this.internalState.hasPickingBuffer,b=Number.isInteger(u.highlightedObjectIndex)||!!u.pickable||u.extensions.some(w=>w.getNeedsPickingBuffer.call(this,w));if(d!==b){this.internalState.hasPickingBuffer=b;let w=tvt(r.attributes);w&&(b&&w.constant&&(w.constant=!1,r.invalidate(w.id)),!w.value&&!b&&(w.constant=!0,w.value=cIe(r.attributes)?[J$]:[0,0,0]))}}}finalizeState(n){for(let c of this.getModels())c.destroy();let r=this.getAttributeManager();r&&r.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(n){for(let r of this.getModels())r.draw(n.renderPass)}getPickingInfo({info:n,mode:r,sourceLayer:c}){let{index:u}=n;return u>=0&&Array.isArray(this.props.data)&&(n.object=this.props.data[u]),n}raiseError(n,r){r&&(n=new Error(`${r}: ${n.message}`,{cause:n})),this.props.onError?.(n)||this.context?.onError?.(n,this)}getNeedsRedraw(n={clearRedrawFlags:!1}){return this._getNeedsRedraw(n)}needsUpdate(){return this.internalState?this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()):!1}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(n){if(!this.internalState)return;let r=this.internalState.viewport;this.internalState.viewport=n,(!r||!Srn({oldViewport:r,viewport:n}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(n="all"){let r=this.getAttributeManager();r&&(n==="all"?r.invalidateAll():r.invalidate(n))}updateAttributes(n){let r=!1;for(let c in n)n[c].layoutChanged()&&(r=!0);for(let c of this.getModels())this._setModelAttributes(c,n,r)}_updateAttributes(){let n=this.getAttributeManager();if(!n)return;let r=this.props,c=this.getNumInstances(),u=this.getStartIndices();n.update({data:r.data,numInstances:c,startIndices:u,props:r,transitions:r.transitions,buffers:r.data.attributes,context:this});let d=n.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(d)}_updateAttributeTransition(){let n=this.getAttributeManager();n&&n.updateTransition()}_updateUniformTransition(){let{uniformTransitions:n}=this.internalState;if(n.active){let r=n.update(),c=Object.create(this.props);for(let u in r)Object.defineProperty(c,u,{value:r[u]});return c}return this.props}calculateInstancePickingColors(n,{numInstances:r}){if(n.constant)return;let c=Math.floor(Rb.length/4);this.internalState.usesPickingColorCache=!0;let u=r>0&&Rb[0]===0;if(cevt&&Bs.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),Rb=hv.allocate(Rb,r,{size:4,copy:!0,maxCount:Math.max(r,evt)});let d=Math.floor(Rb.length/4),b=[0,0,0],w=u?0:c;for(let _=w;_(Bs.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),n)}),this.internalState.uniformTransitions=new HV(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(let r of this.props.extensions)r.initializeState.call(this,this.context,r);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(n){If(xrn,this,this===n);let{state:r,internalState:c}=n;this!==n&&(this.internalState=c,this.state=r,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){let n=this.needsUpdate();if(If(_rn,this,n),!n)return;this.context.stats.get("Layer updates").incrementCount();let r=this.props,c=this.context,u=this.internalState,d=c.viewport,b=this._updateUniformTransition();u.propsInTransition=b,c.viewport=u.viewport||d,this.props=b;try{let w=this._getUpdateParams(),_=this.getModels();if(c.device)this.updateState(w);else try{this.updateState(w)}catch{}for(let T of this.props.extensions)T.updateState.call(this,w,T);this.setNeedsRedraw(),this._updateAttributes();let x=this.getModels()[0]!==_[0];this._postUpdate(w,x)}finally{c.viewport=d,this.props=r,this._clearChangeFlags(),u.needsUpdate=!1,u.resetOldProps()}}_finalize(){If(yrn,this),this.finalizeState(this.context);for(let n of this.props.extensions)n.finalizeState.call(this,this.context,n)}_drawLayer({renderPass:n,shaderModuleProps:r=null,uniforms:c={},parameters:u={}}){this._updateAttributeTransition();let d=this.props,b=this.context;this.props=this.internalState.propsInTransition||d;try{r&&this.setShaderModuleProps(r);let{getPolygonOffset:w}=this.props,_=w&&w(c)||[0,0];b.device instanceof ZM&&b.device.setParametersWebGL({polygonOffset:_});let x=b.device instanceof ZM?null:Trn(u);if(Crn(this.getModels(),n,u,x),b.device instanceof ZM)b.device.withParametersWebGL(u,()=>{let T={renderPass:n,shaderModuleProps:r,uniforms:c,parameters:u,context:b};for(let M of this.props.extensions)M.draw.call(this,T,M);this.draw(T)});else{x?.renderPassParameters&&n.setParameters(x.renderPassParameters);let T={renderPass:n,shaderModuleProps:r,uniforms:c,parameters:u,context:b};for(let M of this.props.extensions)M.draw.call(this,T,M);this.draw(T)}}finally{this.props=d}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(n){if(!this.internalState)return;let{changeFlags:r}=this.internalState;for(let u in n)if(n[u]){let d=!1;switch(u){case"dataChanged":let b=n[u],w=r[u];b&&Array.isArray(w)&&(r.dataChanged=Array.isArray(b)?w.concat(b):b,d=!0);default:r[u]||(r[u]=n[u],d=!0)}d&&If(wrn,this,u,n)}let c=!!(r.dataChanged||r.updateTriggersChanged||r.propsChanged||r.extensionsChanged);r.propsOrDataChanged=c,r.somethingChanged=c||r.viewportChanged||r.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(n,r){let c=Hwt(n,r);if(c.updateTriggersChanged)for(let u in c.updateTriggersChanged)c.updateTriggersChanged[u]&&this.invalidateAttribute(u);if(c.transitionsChanged)for(let u in c.transitionsChanged)this.internalState.uniformTransitions.add(u,r[u],n[u],n.transitions?.[u]);return this.setChangeFlags(c)}validateProps(){Wwt(this.props)}updateAutoHighlight(n){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(n)}_updateAutoHighlight(n){let r={highlightedObjectColor:n.picked?n.color:null},{highlightColor:c}=this.props;n.picked&&typeof c=="function"&&(r.highlightColor=c(n)),this.setShaderModuleProps({picking:r}),this.setNeedsRedraw()}_getAttributeManager(){let n=this.context;return new $V(n.device,{id:this.props.id,stats:n.stats,timeline:n.timeline})}_postUpdate(n,r){let{props:c,oldProps:u}=n,d=this.state.model;d?.isInstanced&&d.setInstanceCount(this.getNumInstances());let{autoHighlight:b,highlightedObjectIndex:w,highlightColor:_}=c;if(r||u.autoHighlight!==b||u.highlightedObjectIndex!==w||u.highlightColor!==_){let x={};Array.isArray(_)&&(x.highlightColor=_),(r||u.autoHighlight!==b||w!==u.highlightedObjectIndex)&&(x.highlightedObjectColor=Number.isFinite(w)&&w>=0?this.encodePickingColor(w):null),this.setShaderModuleProps({picking:x})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(n){if(!this.internalState)return!1;let r=!1;r=r||this.internalState.needsRedraw&&this.id;let c=this.getAttributeManager(),u=c?c.getNeedsRedraw(n):!1;if(r=r||u,r)for(let d of this.props.extensions)d.onNeedsRedraw.call(this,d);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!n.clearRedrawFlags,r}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}};KV.defaultProps=Mrn;KV.layerName="Layer";var U3=KV;function Trn(s){let{blendConstant:n,...r}=s;return n?{pipelineParameters:r,renderPassParameters:{blendConstant:n}}:{pipelineParameters:r}}function Crn(s,n,r,c){for(let u of s)u.device.type==="webgpu"?(Arn(u,n),u.setParameters({...u.parameters,...c?.pipelineParameters})):u.setParameters(r)}function Arn(s,n){let r=n.props.framebuffer||(n.framebuffer??null);if(!r)return;let c=r.colorAttachments.map(b=>b?.texture?.format??null),u=r.depthStencilAttachment?.texture?.format,d=s;(!Prn(d.props.colorAttachmentFormats,c)||d.props.depthStencilAttachmentFormat!==u)&&(d.props.colorAttachmentFormats=c,d.props.depthStencilAttachmentFormat=u,d._setPipelineNeedsUpdate("attachment formats"))}function Prn(s,n){if(s===n)return!0;if(!s||!n||s.length!==n.length)return!1;for(let r=0;r{let ne=L.slice();ne[se]+=1;let ue=D.project(ne)[se]-O[se];return Number.isFinite(ue)?ue:2**(se===0?_:x)*(se===0?1:-1)}),Z=z.map((se,ne)=>{let ue=ne===0?F.left:F.top,Ce=ne===0?F.right:F.bottom,Q=Math.abs(se);return se>=0?[ue/Q,Ce/Q]:[Ce/Q,ue/Q]}),H=L.slice(),te=[I.width,I.height];for(let[se,[ne,ue]]of Z.entries()){if(te[se]<0)continue;let{minimum:Ce,maximum:Q,midpoint:me,settledTarget:tt}=Rrn(T,se,ne,ue,L[se]);if(r?.mode!=="preserve"&&M&&(!Number.isFinite(ne)||!Number.isFinite(ue))){H[se]=me;continue}let st=M?tt:Zl(L[se],Ce,Q);H[se]=r?.mode==="preserve"?L[se]:w?YM(L[se],st,(se===0?I.width:I.height)/2/Math.abs(z[se])):st}(H[0]!==L[0]||H[1]!==L[1])&&(n.target=H)}return n}_constrainZoom({zoomX:n,zoomY:r},c){c||(c=this.getViewportProps());let{zoomAxis:u,maxZoomX:d,maxZoomY:b,maxBounds:w}=c,{minZoomX:_,minZoomY:x}=c;if(w!==null&&c.width>0&&c.height>0){let M=wB(c.width,c.height,c.maxBoundsPadding),L=w[0],I=w[1],D=I[0]-L[0],F=I[1]-L[1];M.width>0&&Number.isFinite(D)&&D>0&&(_=Math.max(_,Math.log2(M.width/D)),_>d&&(_=d)),M.height>0&&Number.isFinite(F)&&F>0&&(x=Math.max(x,Math.log2(M.height/F)),x>b&&(x=b))}switch(u){case"X":n=Zl(n,_,d);break;case"Y":r=Zl(r,x,b);break;default:let M=Math.min(d-n,b-r,0);M===0&&(M=Math.max(_-n,x-r,0)),M!==0&&(n+=M,r+=M)}return{zoomX:n,zoomY:r}}},JV=class extends C4{constructor(){super(...arguments),this.ControllerState=fIe,this.transition={transitionDuration:300,transitionInterpolator:new I3(["target","zoomX","zoomY"])},this.dragMode="pan"}setProps(n){Object.assign(n,uIe(n)),super.setProps(n)}_onMultiPanStart(n){return this.multiTouchDrag==="pan"&&super._onMultiPanStart(n)}_onPanRotate(){return!1}};var Wue=class extends S4{constructor(n={}){super(n)}getViewportType(){return nvt}get ControllerType(){return JV}};Wue.displayName="OrthographicView";var hIe=Wue;var QV=class{static get componentName(){return Object.prototype.hasOwnProperty.call(this,"extensionName")?this.extensionName:""}constructor(n){n&&(this.opts=n)}equals(n){return this===n?!0:this.constructor===n.constructor&&Cc(this.opts,n.opts,1)}getShaders(n){return null}getSubLayerProps(n){let{defaultProps:r}=n.constructor,c={updateTriggers:{}};for(let u in r)if(u in this.props){let d=r[u],b=this.props[u];c[u]=b,d&&d.type==="accessor"&&(c.updateTriggers[u]=this.props.updateTriggers[u],typeof b=="function"&&(c[u]=this.getSubLayerAccessor(b)))}return c}initializeState(n,r){}updateState(n,r){}onNeedsRedraw(n){}getNeedsPickingBuffer(n){return!1}draw(n,r){}finalizeState(n,r){}};QV.defaultProps={};QV.extensionName="LayerExtension";var dIe=QV;$r();var tT=class{constructor(n){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;let{attributes:r={}}=n;this.typedArrayManager=hv,this.attributes={},this._attributeDefs=r,this.opts=n,this.updateGeometry(n)}updateGeometry(n){Object.assign(this.opts,n);let{data:r,buffers:c={},getGeometry:u,geometryBuffer:d,positionFormat:b,dataChanged:w,normalize:_=!0}=this.opts;if(this.data=r,this.getGeometry=u,this.positionSize=d&&d.size||(b==="XY"?2:3),this.buffers=c,this.normalize=_,d&&(Pa(r.startIndices),this.getGeometry=this.getGeometryFromBuffer(d),_||(c.vertexPositions=d)),this.geometryBuffer=c.vertexPositions,Array.isArray(w))for(let x of w)this._rebuildGeometry(x);else this._rebuildGeometry()}updatePartialGeometry({startRow:n,endRow:r}){this._rebuildGeometry({startRow:n,endRow:r})}getGeometryFromBuffer(n){let r=n.value||n;return ArrayBuffer.isView(r)?bue(r,{size:this.positionSize,offset:n.offset,stride:n.stride,startIndices:this.data.startIndices}):null}_allocate(n,r){let{attributes:c,buffers:u,_attributeDefs:d,typedArrayManager:b}=this;for(let w in d)if(w in u)b.release(c[w]),c[w]=null;else{let _=d[w];_.copy=r,c[w]=b.allocate(c[w],n,_)}}_forEachGeometry(n,r,c){let{data:u,getGeometry:d}=this,{iterable:b,objectInfo:w}=gue(u,r,c);for(let _ of b){w.index++;let x=d?d(_,w):null;n(x,w.index)}}_rebuildGeometry(n){if(!this.data)return;let{indexStarts:r,vertexStarts:c,instanceCount:u}=this,{data:d,geometryBuffer:b}=this,{startRow:w=0,endRow:_=1/0}=n||{},x={};if(n||(r=[0],c=[0]),this.normalize||!b)this._forEachGeometry((M,L)=>{let I=M&&this.normalizeGeometry(M);x[L]=I,c[L+1]=c[L]+(I?this.getGeometrySize(I):0)},w,_),u=c[c.length-1];else if(c=d.startIndices,u=c[d.length]||0,ArrayBuffer.isView(b))u=u||b.length/this.positionSize;else if(b instanceof as){let M=this.positionSize*4;u=u||b.byteLength/M}else if(b.buffer){let M=b.stride||this.positionSize*4;u=u||b.buffer.byteLength/M}else if(b.value){let M=b.value,L=b.stride/M.BYTES_PER_ELEMENT||this.positionSize;u=u||M.length/L}this._allocate(u,!!n),this.indexStarts=r,this.vertexStarts=c,this.instanceCount=u;let T={};this._forEachGeometry((M,L)=>{let I=x[L]||M;T.vertexStart=c[L],T.indexStart=r[L];let D=L 0.0 ? mod(dashOffsetAndLength.x, dashPeriod) : 0.0; +#else +vDashOffset = 0.0; +vDashPathLength = 0.0; +#endif +`,"fs:#decl":` +layout(std140) uniform pathStyleUniforms { +float dashAlignMode; +bool dashGapPickable; +highp int dashUnits; +} pathStyle; +in vec2 vDashArray; +in float vDashOffset; +in float vDashPathLength; +float dashPatternIntegral(float position, float solidLength, float unitLength) { +return floor(position / unitLength) * solidLength + +min(mod(position, unitLength), solidLength); +} +float dashPatternCoverage( +float position, +float solidLength, +float unitLength, +float filterWidth +) { +float halfFilter = 0.5 * filterWidth; +float reducedPosition = mod(position, unitLength); +return (dashPatternIntegral(reducedPosition + halfFilter, solidLength, unitLength) - +dashPatternIntegral(reducedPosition - halfFilter, solidLength, unitLength)) / filterWidth; +} +`,"fs:#main-start":` +float dashCoverage = 1.0; +bool shouldDiscardDash = false; +bool inRoundedDashGap = false; +float roundedDashResolvedCoverage = 1.0; +float roundedDashSubPixelBlend = 0.0; +float roundedDashDutyCycle = 1.0; +float solidLength = vDashArray.x; +float gapLength = vDashArray.y; +float unitLength = solidLength + gapLength; +if (unitLength > 0.0 && gapLength > 0.0) { +float offset; +if (pathStyle.dashAlignMode == 0.0) { +offset = vDashOffset; +} else { +#ifdef HIGH_PRECISION_DASH +unitLength = vDashPathLength / max(round(vDashPathLength / unitLength), 1.0); +#else +unitLength = vPathLength / max(round(vPathLength / unitLength), 1.0); +#endif +solidLength = min(solidLength, unitLength); +offset = solidLength / 2.0; +#ifdef HIGH_PRECISION_DASH +offset += vDashOffset; +#endif +} +float alongPath = vPathPosition.y + offset; +float unitOffset = mod(alongPath, unitLength); +float filterWidth = max(fwidth(alongPath), 0.0001); +if (bool(picking.isActive)) { +bool inGap = unitOffset > solidLength; +if (inGap && path.capType > 0.5) { +inGap = length(vec2( +min(unitOffset - solidLength, unitLength - unitOffset), +vPathPosition.x +)) > 1.0; +} +if (inGap && !pathStyle.dashGapPickable) { +shouldDiscardDash = true; +} +} else if (path.capType <= 0.5) { +dashCoverage = dashPatternCoverage(alongPath, solidLength, unitLength, filterWidth); +} else { +float distanceAlongGap = min(unitOffset - solidLength, unitLength - unitOffset); +float distanceToEnd = length(vec2(max(distanceAlongGap, 0.0), vPathPosition.x)); +float capEdgePixels = (1.0 - distanceToEnd) / max(fwidth(distanceToEnd), 1e-6); +if (distanceAlongGap > 0.0) { +inRoundedDashGap = true; +roundedDashResolvedCoverage = smoothedge(0.0, capEdgePixels); +dashCoverage = roundedDashResolvedCoverage; +} +float subPixelBlend = smoothstep(unitLength, 2.0 * unitLength, filterWidth); +roundedDashSubPixelBlend = subPixelBlend; +float boundedSolidLength = min(solidLength, unitLength); +float effectiveGap = max(unitLength - boundedSolidLength, 0.0); +float capSpan = 2.0 * sqrt(max(1.0 - vPathPosition.x * vPathPosition.x, 0.0)); +float roundedDutyCycle = clamp( +(boundedSolidLength + min(effectiveGap, capSpan)) / unitLength, +0.0, +1.0 +); +roundedDashDutyCycle = roundedDutyCycle; +dashCoverage = mix(dashCoverage, roundedDutyCycle, subPixelBlend); +} +dashCoverage = clamp(dashCoverage, 0.0, 1.0); +shouldDiscardDash = shouldDiscardDash || dashCoverage <= 0.0; +} +`,"fs:#main-end":` +#ifdef ANTIALIASING +if (inRoundedDashGap) { +float pathCoverage = smoothedge(0.0, edgePixels); +float resolvedCapMultiplier = +min(pathCoverage, roundedDashResolvedCoverage) / max(pathCoverage, 1e-6); +dashCoverage = mix( +resolvedCapMultiplier, +roundedDashDutyCycle, +roundedDashSubPixelBlend +); +} +#endif +if (shouldDiscardDash) { +discard; +} +fragColor.a *= dashCoverage; +`}},svt={inject:{"vs:#decl":` +in vec2 instanceDashArrays; +out vec2 vDashArray; +`,"vs:#main-end":` +vDashArray = instanceDashArrays; +`,"fs:#decl":` +layout(std140) uniform pathStyleUniforms { +bool dashGapPickable; +} pathStyle; +in vec2 vDashArray; +#define PI 3.141592653589793 +`,"fs:#main-start":` +bool inDashGap = false; +float dashUnitLength = vDashArray.x + vDashArray.y; +if (dashUnitLength > 0.0 && scatterplot.stroked > 0.5) { +float _distToCenter = length(unitPosition) * outerRadiusPixels; +float innerRadius = innerUnitRadius * outerRadiusPixels; +if (_distToCenter >= innerRadius) { +float strokeWidth = (1.0 - innerUnitRadius) * outerRadiusPixels; +float midStrokeRadius = (innerUnitRadius + 1.0) * 0.5 * outerRadiusPixels; +float angle = atan(unitPosition.y, unitPosition.x) + PI; +float circumference = 2.0 * PI * midStrokeRadius; +float posAlongStroke = (angle / (2.0 * PI)) * circumference / strokeWidth; +float unitOffset = mod(posAlongStroke, dashUnitLength); +if (unitOffset > vDashArray.x) { +if (scatterplot.filled > 0.5) { +inDashGap = true; +} else { +if (!(pathStyle.dashGapPickable && bool(picking.isActive))) { +discard; +} +} +} +} +} +`,"fs:#main-end":` +if (inDashGap) { +float alphaFactor = fragColor.a / max(vLineColor.a, 0.001); +fragColor = vec4(vFillColor.rgb, vFillColor.a * alphaFactor); +fragColor = picking_filterPickingColor(fragColor); +fragColor = picking_filterHighlightColor(fragColor); +} +`}},ovt={inject:{"vs:#decl":` +in vec2 instanceDashArrays; +out vec2 vDashArray; +`,"vs:#main-end":` +vDashArray = instanceDashArrays; +`,"fs:#decl":` +layout(std140) uniform pathStyleUniforms { +bool dashGapPickable; +} pathStyle; +in vec2 vDashArray; +#define PI 3.141592653589793 +float getPerimeterPosition(vec2 fragUV, vec2 dims, vec4 radii, float lineWidth) { +float width = dims.x; +float height = dims.y; +float maxRadius = min(width, height) * 0.5; +float rBL = min(radii.w, maxRadius); +float rTL = min(radii.z, maxRadius); +float rTR = min(radii.x, maxRadius); +float rBR = min(radii.y, maxRadius); +vec2 p = fragUV * dims; +float leftLen = height - rBL - rTL; +float topLen = width - rTL - rTR; +float rightLen = height - rTR - rBR; +float bottomLen = width - rBR - rBL; +float arcBL = PI * 0.5 * rBL; +float arcTL = PI * 0.5 * rTL; +float arcTR = PI * 0.5 * rTR; +float arcBR = PI * 0.5 * rBR; +float pos = 0.0; +float distLeft = p.x; +float distRight = width - p.x; +float distBottom = p.y; +float distTop = height - p.y; +float minDist = min(min(distLeft, distRight), min(distBottom, distTop)); +if (p.x < rBL && p.y < rBL) { +vec2 c = vec2(rBL, rBL); +vec2 d = p - c; +float angle = atan(-d.x, -d.y); +pos = angle / (PI * 0.5) * arcBL; +} else if (p.x < rTL && p.y > height - rTL) { +vec2 c = vec2(rTL, height - rTL); +vec2 d = p - c; +float angle = atan(d.y, -d.x); +pos = arcBL + leftLen + angle / (PI * 0.5) * arcTL; +} else if (p.x > width - rTR && p.y > height - rTR) { +vec2 c = vec2(width - rTR, height - rTR); +vec2 d = p - c; +float angle = atan(d.x, d.y); +pos = arcBL + leftLen + arcTL + topLen + angle / (PI * 0.5) * arcTR; +} else if (p.x > width - rBR && p.y < rBR) { +vec2 c = vec2(width - rBR, rBR); +vec2 d = p - c; +float angle = atan(-d.y, d.x); +pos = arcBL + leftLen + arcTL + topLen + arcTR + rightLen + angle / (PI * 0.5) * arcBR; +} else if (minDist == distLeft) { +pos = arcBL + clamp(p.y - rBL, 0.0, leftLen); +} else if (minDist == distTop) { +pos = arcBL + leftLen + arcTL + clamp(p.x - rTL, 0.0, topLen); +} else if (minDist == distRight) { +pos = arcBL + leftLen + arcTL + topLen + arcTR + clamp(height - rTR - p.y, 0.0, rightLen); +} else { +pos = arcBL + leftLen + arcTL + topLen + arcTR + rightLen + arcBR + clamp(width - rBR - p.x, 0.0, bottomLen); +} +return pos / lineWidth; +} +float getRectPerimeterPosition(vec2 fragUV, vec2 dims, float lineWidth) { +float width = dims.x; +float height = dims.y; +float distLeft = fragUV.x * width; +float distRight = (1.0 - fragUV.x) * width; +float distBottom = fragUV.y * height; +float distTop = (1.0 - fragUV.y) * height; +float minDist = min(min(distLeft, distRight), min(distBottom, distTop)); +float pos = 0.0; +if (minDist == distLeft) { +pos = fragUV.y * height; +} else if (minDist == distTop) { +pos = height + fragUV.x * width; +} else if (minDist == distRight) { +pos = height + width + (1.0 - fragUV.y) * height; +} else { +pos = 2.0 * height + width + (1.0 - fragUV.x) * width; +} +return pos / lineWidth; +} +`,"fs:#main-start":` +bool inDashGap = false; +float dashUnitLength = vDashArray.x + vDashArray.y; +if (dashUnitLength > 0.0 && textBackground.stroked) { +float distToEdge; +bool hasRoundedCorners = textBackground.borderRadius != vec4(0.0); +if (hasRoundedCorners) { +distToEdge = round_rect(uv, dimensions, textBackground.borderRadius); +} else { +distToEdge = rect(uv, dimensions); +} +if (distToEdge <= vLineWidth && distToEdge >= 0.0) { +float posAlongStroke; +if (hasRoundedCorners) { +posAlongStroke = getPerimeterPosition(uv, dimensions, textBackground.borderRadius, vLineWidth); +} else { +posAlongStroke = getRectPerimeterPosition(uv, dimensions, vLineWidth); +} +float unitOffset = mod(posAlongStroke, dashUnitLength); +if (unitOffset > vDashArray.x) { +if (vFillColor.a > 0.0) { +inDashGap = true; +} else { +if (!(pathStyle.dashGapPickable && bool(picking.isActive))) { +discard; +} +} +} +} +} +`,"fs:#main-end":` +if (inDashGap) { +float alphaFactor = fragColor.a / max(vLineColor.a, 0.001); +fragColor = vec4(vFillColor.rgb, vFillColor.a * alphaFactor); +fragColor = picking_filterPickingColor(fragColor); +fragColor = picking_filterHighlightColor(fragColor); +} +`}},avt={inject:{"vs:#decl":` +in float instanceOffsets; +`,"vs:DECKGL_FILTER_SIZE":` +float offsetWidth = abs(instanceOffsets * 2.0) + 1.0; +size *= offsetWidth; +`,"vs:#main-end":` +float offsetWidth = abs(instanceOffsets * 2.0) + 1.0; +float offsetDir = sign(instanceOffsets); +vPathPosition.x = (vPathPosition.x + offsetDir) * offsetWidth - offsetDir; +vPathPosition.y *= offsetWidth; +vPathLength *= offsetWidth; +#ifdef DASH_ENABLED +if (pathStyle.dashUnits != 0) { +vDashArray *= offsetWidth; +} +vPathBounds *= offsetWidth; +#ifdef HIGH_PRECISION_DASH +vDashPathLength *= offsetWidth; +float restoredDashUnitLength = vDashArray.x + vDashArray.y; +float restoredDashPeriod = pathStyle.dashAlignMode == 0.0 +? restoredDashUnitLength +: vDashPathLength / +max(round(vDashPathLength / max(restoredDashUnitLength, 0.0001)), 1.0); +vDashOffset = restoredDashPeriod > 0.0 +? mod(dashOffsetAndLength.x * offsetWidth, restoredDashPeriod) +: 0.0; +#else +vDashOffset *= offsetWidth; +#endif +#endif +`,"fs:#main-end":` +#ifndef ANTIALIASING +if (abs(vPathPosition.x) > 1.0) { +discard; +} +#endif +`}};var Irn={getDashArray:{type:"accessor",value:[0,0]},getOffset:{type:"accessor",value:0},dashJustified:!1,dashGapPickable:!1,dashUnits:"widths"},Drn={widths:0,pixels:1,meters:2,common:3},Brn=["instanceDashArrays","instanceDashOffsets","instanceOffsets"];function Orn({props:s,oldProps:n}){return!Cc(s.modelMatrix,n.modelMatrix,2)||s.coordinateSystem!==n.coordinateSystem||!Cc(s.coordinateOrigin,n.coordinateOrigin,1)}function cvt(s,n,r){let c=s.context.viewport;if(!(c instanceof k3)||c.zoom<12)return s.projectPosition(n,{autoOffset:!1});let u=U1.transformMat4([],[n[0],n[1],n[2]||0,1],r.modelMatrix),d=s.props.coordinateSystem==="default"?"lnglat":s.props.coordinateSystem;if(d==="lnglat"){if(Math.abs(u[1]-r.coordinateOrigin[1])>.25){let _=u[0];r.wrapLongitude&&(_=((_+180)%360+360)%360-180);let x=c.projectPosition([_,u[1],0]);return[x[0]-r.commonOrigin[0],x[1]-r.commonOrigin[1],u[2]*r.commonUnitsPerMeter[2]]}wm.sub(u,u,r.coordinateOrigin)}else d==="cartesian"&&wm.sub(u,u,r.coordinateOrigin);let b=u[1],w=wm.scaleAndAdd([],r.commonUnitsPerWorldUnit,r.commonUnitsPerWorldUnit2,b);return wm.multiply([],u,w)}var eW=class extends dIe{constructor({dash:n=!1,offset:r=!1,dashMode:c,highPrecisionDash:u=!1}={}){let d=c??(u?"path":"segment");super({dash:n||u||c!==void 0,offset:r,dashMode:d,highPrecisionDash:d==="path"})}getLayerType(n){if("pathTesselator"in n.state)return"path";let r=n.constructor.layerName;return r==="ScatterplotLayer"?"scatterplot":r==="TextBackgroundLayer"?"textBackground":null}synchronizeAttributes(n){let r=n.getAttributeManager(),c=this.getLayerType(n);if(!r||!c)return!1;let u=r.getAttributes(),d=new Set;this.opts.dash&&d.add("instanceDashArrays"),c==="path"&&this.opts.dash&&this.opts.dashMode==="path"&&d.add("instanceDashOffsets"),c==="path"&&this.opts.offset&&d.add("instanceOffsets");let b=!1;for(let w of Brn)u[w]&&!d.has(w)&&(r.remove([w]),b=!0);return d.has("instanceDashArrays")&&!u.instanceDashArrays&&(r.addInstanced({instanceDashArrays:{size:2,accessor:"getDashArray"}}),b=!0),d.has("instanceDashOffsets")&&!u.instanceDashOffsets&&(r.addInstanced({instanceDashOffsets:{size:2,accessor:["getPath"],update:this.calculateDashMetrics}}),b=!0),d.has("instanceOffsets")&&!u.instanceOffsets&&(r.addInstanced({instanceOffsets:{size:1,accessor:"getOffset"}}),b=!0),b}isEnabled(n){return this.getLayerType(n)!==null}getShaders(n){let r=n.getLayerType(this);if(!r)return null;if(r==="scatterplot"||r==="textBackground")return n.opts.dash?{modules:[{name:"pathStyle",inject:r==="scatterplot"?svt.inject:ovt.inject,uniformTypes:{dashGapPickable:"i32"}}]}:null;let c={},u={};n.opts.dash&&(c=D4(c,rvt),u.DASH_ENABLED=!0,n.opts.dashMode==="path"&&(u.HIGH_PRECISION_DASH=!0)),n.opts.offset&&(c=D4(c,avt),u.PATH_STYLE_OFFSET=!0);let{inject:d}=c,b={name:"pathStyle",inject:d};return n.opts.dash&&(b.uniformTypes={dashAlignMode:"f32",dashGapPickable:"i32",dashUnits:"i32"}),{modules:[b],defines:u}}initializeState(n,r){r.synchronizeAttributes(this)}updateState(n,r){if(r.isEnabled(this)){if(n.changeFlags.extensionsChanged){let c=r.synchronizeAttributes(this),u=this.getAttributeManager();if(u&&c){u.invalidateAll();for(let d of this.getModels())d.setBufferLayout(u.getBufferLayouts(d))}}if(r.opts.dash){let c=r.getLayerType(this);if(c==="path"&&r.opts.dashMode==="path"&&Orn(n)&&this.getAttributeManager()?.invalidate("instanceDashOffsets"),c==="scatterplot"||c==="textBackground"){let u={dashGapPickable:!!this.props.dashGapPickable};this.setShaderModuleProps({pathStyle:u})}else{let u={dashAlignMode:this.props.dashJustified?1:0,dashGapPickable:!!this.props.dashGapPickable,dashUnits:Drn[this.props.dashUnits??"widths"]};this.setShaderModuleProps({pathStyle:u})}}}}calculateDashMetrics(n,{startRow:r,endRow:c}){let u=this.state.pathTesselator,d=u?.vertexStarts,b=u?.instanceCount,w=u?.get("positions");if(!d||b===void 0||typeof u?.getPathSegmentIndices!="function")throw new Error("PathStyleExtension requires PathLayer tessellation data for path dashes.");let _=this.props.data?.attributes?.getPath,x=ArrayBuffer.isView(_)?_:_?.value,T=ArrayBuffer.isView(x),M=w&&(!_||u.normalize||u.opts?.isWebGPU);if(_&&!T||!M&&!T)throw new Error("PathStyleExtension cannot calculate whole-path dash metrics from GPU-only getPath data; supply data.attributes.instanceDashOffsets.");let L=n.value,I=n.size,D=Math.max(0,r),F=Math.min(c,d.length-1),O=3,z=3,Z=0;if(!M){let ne=x.BYTES_PER_ELEMENT;O=_?.size||(this.props.positionFormat==="XY"?2:3),z=_?.stride?_.stride/ne:O,Z=_?.offset?_.offset/ne:0}let H=new Array(3),te=lv.getUniforms({viewport:this.context.viewport,modelMatrix:this.props.modelMatrix,coordinateSystem:this.props.coordinateSystem,coordinateOrigin:this.props.coordinateOrigin,autoWrapLongitude:this.wrapLongitude}),se=ne=>{if(M)H[0]=w[ne*3],H[1]=w[ne*3+1],H[2]=w[ne*3+2];else{let ue=Z+ne*z;H[0]=x[ue],H[1]=x[ue+1],H[2]=O===3?x[ue+2]:0}return H};n.startIndices=d;for(let ne=D;ne1)for(let at=ue;at0&&(r[_]=r[_-1]+wm.dist(w,b)),w=b;return r[d-1]=0,r}};eW.defaultProps=Irn;eW.extensionName="PathStyleExtension";var pIe=eW;Jl();Bf();var Nrn=new Uint32Array([0,2,1,0,3,2]),Frn=new Float32Array([0,1,0,0,1,0,1,1]);function gIe(s,n){if(!n)return Urn(s);let r=Math.max(Math.abs(s[0][0]-s[3][0]),Math.abs(s[1][0]-s[2][0])),c=Math.max(Math.abs(s[1][1]-s[0][1]),Math.abs(s[2][1]-s[3][1])),u=Math.ceil(r/n)+1,d=Math.ceil(c/n)+1,b=(u-1)*(d-1)*6,w=new Uint32Array(b),_=new Float32Array(u*d*2),x=new Float64Array(u*d*3),T=0,M=0;for(let L=0;L0&&D>0&&(w[M++]=T-d,w[M++]=T-d-1,w[M++]=T-1,w[M++]=T-d,w[M++]=T-1,w[M++]=T),T++}}return{vertexCount:b,positions:x,indices:w,texCoords:_}}function Urn(s){let n=new Float64Array(12);for(let r=0;r, + coordinateConversion: f32, + desaturate: f32, + tintColor: vec3, + transparentColor: vec4, +}; + +@group(0) @binding(auto) var bitmap: BitmapUniforms; +@group(0) @binding(auto) var bitmapTexture: texture_2d; +@group(0) @binding(auto) var bitmapTextureSampler: sampler; +`,lvt=`layout(std140) uniform bitmapUniforms { + vec4 bounds; + float coordinateConversion; + float desaturate; + vec3 tintColor; + vec4 transparentColor; +} bitmap; +`,uvt={name:"bitmap",source:Grn,vs:lvt,fs:lvt,uniformTypes:{bounds:"vec4",coordinateConversion:"f32",desaturate:"f32",tintColor:"vec3",transparentColor:"vec4"}};var fvt=`struct Attributes { + @location(0) positions: vec3, + @location(1) positions64Low: vec3, + @location(2) texCoords: vec2, +}; + +struct Varyings { + @builtin(position) position: vec4, + @location(0) vTexCoord: vec2, + @location(1) vTexPos: vec2, + @location(2) pickingColor: vec3, + @location(3) pickingDepth: f32, +}; + +// from degrees to Web Mercator +fn lnglat_to_mercator(lnglat: vec2) -> vec2 { + let x = lnglat.x; + let y = clamp(lnglat.y, -89.9, 89.9); + return vec2( + radians(x) + PI, + PI + log(tan(PI * 0.25 + radians(y) * 0.5)) + ) * WORLD_SCALE; +} + +// from Web Mercator to degrees +fn mercator_to_lnglat(xy: vec2) -> vec2 { + let position = xy / WORLD_SCALE; + return degrees(vec2( + position.x - PI, + atan(exp(position.y - PI)) * 2.0 - PI * 0.5 + )); +} + +fn color_desaturate(colorValue: vec3) -> vec3 { + let luminance = (colorValue.r + colorValue.g + colorValue.b) * 0.333333333; + return mix(colorValue, vec3(luminance), bitmap.desaturate); +} + +fn color_tint(colorValue: vec3) -> vec3 { + return colorValue * bitmap.tintColor; +} + +fn apply_opacity(colorValue: vec3, alpha: f32) -> vec4 { + if (bitmap.transparentColor.a == 0.0) { + return vec4(colorValue, alpha); + } + let blendedAlpha = alpha + bitmap.transparentColor.a * (1.0 - alpha); + let highLightRatio = alpha / blendedAlpha; + let blendedRGB = mix(bitmap.transparentColor.rgb, colorValue, highLightRatio); + return vec4(blendedRGB, blendedAlpha); +} + +fn getUV(position: vec2) -> vec2 { + return vec2( + (position.x - bitmap.bounds[0]) / (bitmap.bounds[2] - bitmap.bounds[0]), + (position.y - bitmap.bounds[3]) / (bitmap.bounds[1] - bitmap.bounds[3]) + ); +} + +// Pack the top 12 bits of two normalized floats into three 8-bit values. +fn packUVsIntoRGB(uv: vec2) -> vec3 { + let uv8bit = floor(uv * 256.0); + let uvFraction = fract(uv * 256.0); + let uvFraction4bit = floor(uvFraction * 16.0); + let fractions = uvFraction4bit.x + uvFraction4bit.y * 16.0; + return vec3(uv8bit, fractions) / 255.0; +} + +@vertex +fn vertexMain(attributes: Attributes) -> Varyings { + var output: Varyings; + geometry.worldPosition = attributes.positions; + geometry.uv = attributes.texCoords; + geometry.pickingColor = picking_getPickingColorFromIndex(0u); + + let projectedPosition = project_position_to_clipspace_and_commonspace( + attributes.positions, + attributes.positions64Low, + vec3(0.0) + ); + geometry.position = projectedPosition.commonPosition; + output.position = projectedPosition.clipPosition; + output.vTexCoord = attributes.texCoords; + output.vTexPos = vec2(0.0); + output.pickingColor = geometry.pickingColor; + output.pickingDepth = output.position.z / output.position.w; + + if (bitmap.coordinateConversion < -0.5) { + output.vTexPos = geometry.position.xy + project.commonOrigin.xy; + } else if (bitmap.coordinateConversion > 0.5) { + output.vTexPos = geometry.worldPosition.xy; + } + + return output; +} + +@fragment +fn fragmentMain(input: Varyings) -> @location(0) vec4 { + var uv = input.vTexCoord; + if (bitmap.coordinateConversion < -0.5) { + uv = getUV(mercator_to_lnglat(input.vTexPos)); + } else if (bitmap.coordinateConversion > 0.5) { + uv = getUV(lnglat_to_mercator(input.vTexPos)); + } + + let bitmapColor = textureSample(bitmapTexture, bitmapTextureSampler, uv); + var fragColor = apply_opacity( + color_tint(color_desaturate(bitmapColor.rgb)), + bitmapColor.a * layer.opacity + ); + + geometry.uv = uv; + + if (picking.isActive > 0.5) { + if (picking.isAttribute > 0.5) { + return vec4(input.pickingDepth, 0.0, 0.0, 1.0); + } + return vec4(packUVsIntoRGB(uv), 1.0); + } + + if (picking.isHighlightActive > 0.5) { + let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor); + if (picking_isColorZero(abs(input.pickingColor - highlightedObjectColor))) { + let highLightAlpha = picking.highlightColor.a; + let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha); + if (blendedAlpha > 0.0) { + let highLightRatio = highLightAlpha / blendedAlpha; + fragColor = vec4( + mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio), + blendedAlpha + ); + } else { + fragColor = vec4(fragColor.rgb, 0.0); + } + } + } + + return deckgl_premultiplied_alpha(fragColor); +} +`;var hvt=`#version 300 es +#define SHADER_NAME bitmap-layer-vertex-shader + +in vec2 texCoords; +in vec3 positions; +in vec3 positions64Low; + +out vec2 vTexCoord; +out vec2 vTexPos; + +const vec3 pickingColor = vec3(1.0, 0.0, 0.0); + +void main(void) { + geometry.worldPosition = positions; + geometry.uv = texCoords; + geometry.pickingColor = pickingColor; + + gl_Position = project_position_to_clipspace(positions, positions64Low, vec3(0.0), geometry.position); + DECKGL_FILTER_GL_POSITION(gl_Position, geometry); + + vTexCoord = texCoords; + + if (bitmap.coordinateConversion < -0.5) { + vTexPos = geometry.position.xy + project.commonOrigin.xy; + } else if (bitmap.coordinateConversion > 0.5) { + vTexPos = geometry.worldPosition.xy; + } + + vec4 color = vec4(0.0); + DECKGL_FILTER_COLOR(color, geometry); +} +`;var jrn=` +vec3 packUVsIntoRGB(vec2 uv) { + // Extract the top 8 bits. We want values to be truncated down so we can add a fraction + vec2 uv8bit = floor(uv * 256.); + + // Calculate the normalized remainders of u and v parts that do not fit into 8 bits + // Scale and clamp to 0-1 range + vec2 uvFraction = fract(uv * 256.); + vec2 uvFraction4bit = floor(uvFraction * 16.); + + // Remainder can be encoded in blue channel, encode as 4 bits for pixel coordinates + float fractions = uvFraction4bit.x + uvFraction4bit.y * 16.; + + return vec3(uv8bit, fractions) / 255.; +} +`,dvt=`#version 300 es +#define SHADER_NAME bitmap-layer-fragment-shader + +#ifdef GL_ES +precision highp float; +#endif + +uniform sampler2D bitmapTexture; + +in vec2 vTexCoord; +in vec2 vTexPos; + +out vec4 fragColor; + +/* projection utils */ +const float TILE_SIZE = 512.0; +const float PI = 3.1415926536; +const float WORLD_SCALE = TILE_SIZE / PI / 2.0; + +// from degrees to Web Mercator +vec2 lnglat_to_mercator(vec2 lnglat) { + float x = lnglat.x; + float y = clamp(lnglat.y, -89.9, 89.9); + return vec2( + radians(x) + PI, + PI + log(tan(PI * 0.25 + radians(y) * 0.5)) + ) * WORLD_SCALE; +} + +// from Web Mercator to degrees +vec2 mercator_to_lnglat(vec2 xy) { + xy /= WORLD_SCALE; + return degrees(vec2( + xy.x - PI, + atan(exp(xy.y - PI)) * 2.0 - PI * 0.5 + )); +} +/* End projection utils */ + +// apply desaturation +vec3 color_desaturate(vec3 color) { + float luminance = (color.r + color.g + color.b) * 0.333333333; + return mix(color, vec3(luminance), bitmap.desaturate); +} + +// apply tint +vec3 color_tint(vec3 color) { + return color * bitmap.tintColor; +} + +// blend with background color +vec4 apply_opacity(vec3 color, float alpha) { + if (bitmap.transparentColor.a == 0.0) { + return vec4(color, alpha); + } + float blendedAlpha = alpha + bitmap.transparentColor.a * (1.0 - alpha); + float highLightRatio = alpha / blendedAlpha; + vec3 blendedRGB = mix(bitmap.transparentColor.rgb, color, highLightRatio); + return vec4(blendedRGB, blendedAlpha); +} + +vec2 getUV(vec2 pos) { + return vec2( + (pos.x - bitmap.bounds[0]) / (bitmap.bounds[2] - bitmap.bounds[0]), + (pos.y - bitmap.bounds[3]) / (bitmap.bounds[1] - bitmap.bounds[3]) + ); +} + +${jrn} + +void main(void) { + vec2 uv = vTexCoord; + if (bitmap.coordinateConversion < -0.5) { + vec2 lnglat = mercator_to_lnglat(vTexPos); + uv = getUV(lnglat); + } else if (bitmap.coordinateConversion > 0.5) { + vec2 commonPos = lnglat_to_mercator(vTexPos); + uv = getUV(commonPos); + } + vec4 bitmapColor = texture(bitmapTexture, uv); + + fragColor = apply_opacity(color_tint(color_desaturate(bitmapColor.rgb)), bitmapColor.a * layer.opacity); + + geometry.uv = uv; + DECKGL_FILTER_COLOR(fragColor, geometry); + + if (bool(picking.isActive) && !bool(picking.isAttribute)) { + // Since instance information is not used, we can use picking color for pixel index + fragColor.rgb = packUVsIntoRGB(uv); + } +} +`;var $rn={image:{type:"image",value:null,async:!0},bounds:{type:"array",value:[1,0,0,1],compare:!0},_imageCoordinateSystem:"default",desaturate:{type:"number",min:0,max:1,value:0},transparentColor:{type:"color",value:[0,0,0,0]},tintColor:{type:"color",value:[255,255,255]},textureParameters:{type:"object",ignore:!0,value:null}},tW=class extends U3{getShaders(){return super.getShaders({vs:hvt,fs:dvt,source:fvt,modules:[qy,Zy,Jy,uvt]})}initializeState(){let n=this.getAttributeManager(),r=!0;n.add({indices:{size:1,isIndexed:!0,update:c=>c.value=this.state.mesh.indices,noAlloc:r},positions:{size:3,type:"float64",fp64:this.use64bitPositions(),update:c=>c.value=this.state.mesh.positions,noAlloc:r},texCoords:{size:2,update:c=>c.value=this.state.mesh.texCoords,noAlloc:r}})}updateState({props:n,oldProps:r,changeFlags:c}){let u=this.getAttributeManager();if(c.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),u.invalidateAll()),n.bounds!==r.bounds){let d=this.state.mesh,b=this._createMesh();this.state.model.setVertexCount(b.vertexCount);for(let w in b)d&&d[w]!==b[w]&&u.invalidate(w);this.setState({mesh:b,...this._getCoordinateUniforms()})}else n._imageCoordinateSystem!==r._imageCoordinateSystem&&this.setState(this._getCoordinateUniforms())}getPickingInfo(n){let{image:r}=this.props,c=n.info;if(!c.color||!r)return c.bitmap=null,c;let{width:u,height:d}=r;c.index=0;let b=Vrn(c.color);return c.bitmap={size:{width:u,height:d},uv:b,pixel:[Math.floor(b[0]*u),Math.floor(b[1]*d)]},c}disablePickingIndex(){this.setState({disablePicking:!0})}restorePickingColors(){this.setState({disablePicking:!1})}_updateAutoHighlight(n){super._updateAutoHighlight({...n,color:this.encodePickingColor(0)})}_createMesh(){let{bounds:n}=this.props,r=n;return pvt(n)&&(r=[[n[0],n[1]],[n[0],n[3]],[n[2],n[3]],[n[2],n[1]]]),gIe(r,this.context.viewport.resolution)}_getModel(){let n=this.context.device.type==="webgpu"?this.getAttributeManager().getBufferLayouts({isInstanced:!1}).filter(r=>r.name!=="indices"):this.getAttributeManager().getBufferLayouts();return new $h(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:n,topology:"triangle-list",isInstanced:!1})}draw(n){let{shaderModuleProps:r}=n,{model:c,coordinateConversion:u,bounds:d,disablePicking:b}=this.state,{image:w,desaturate:_,transparentColor:x,tintColor:T}=this.props;if(!(r.picking.isActive&&b)&&w&&c){let M={bitmapTexture:w,bounds:d,coordinateConversion:u,desaturate:_,tintColor:T.slice(0,3).map(L=>L/255),transparentColor:x.map(L=>L/255)};c.shaderInputs.setProps({bitmap:M}),c.draw(this.context.renderPass)}}_getCoordinateUniforms(){let{_imageCoordinateSystem:n}=this.props;if(n!=="default"){let{bounds:r}=this.props;if(!pvt(r))throw new Error("_imageCoordinateSystem only supports rectangular bounds");let c=this.context.viewport.resolution?"lnglat":"cartesian";if(n=n==="lnglat"?"lnglat":"cartesian",n==="lnglat"&&c==="cartesian")return{coordinateConversion:-1,bounds:r};if(n==="cartesian"&&c==="lnglat"){let u=ag([r[0],r[1]]),d=ag([r[2],r[3]]);return{coordinateConversion:1,bounds:[u[0],u[1],d[0],d[1]]}}}return{coordinateConversion:0,bounds:[0,0,0,0]}}};tW.layerName="BitmapLayer";tW.defaultProps=$rn;var mIe=tW;function Vrn(s){let[n,r,c]=s,u=(c&240)/256,d=(c&15)/16;return[(n+d)/256,(r+u)/256]}function pvt(s){return Number.isFinite(s[0])}Jl();var gvt=`layout(std140) uniform scatterplotUniforms { + float radiusScale; + float radiusMinPixels; + float radiusMaxPixels; + float lineWidthScale; + float lineWidthMinPixels; + float lineWidthMaxPixels; + float stroked; + float filled; + bool antialiasing; + bool billboard; + highp int radiusUnits; + highp int lineWidthUnits; +} scatterplot; +`,mvt={name:"scatterplot",vs:gvt,fs:gvt,source:"",uniformTypes:{radiusScale:"f32",radiusMinPixels:"f32",radiusMaxPixels:"f32",lineWidthScale:"f32",lineWidthMinPixels:"f32",lineWidthMaxPixels:"f32",stroked:"f32",filled:"f32",antialiasing:"f32",billboard:"f32",radiusUnits:"i32",lineWidthUnits:"i32"}};var bvt=`#version 300 es +#define SHADER_NAME scatterplot-layer-vertex-shader +in vec3 positions; +in vec3 instancePositions; +in vec3 instancePositions64Low; +in float instanceRadius; +in float instanceLineWidths; +in vec4 instanceFillColors; +in vec4 instanceLineColors; +#ifdef USE_ROW_INDEXES +in float rowIndexes; +#endif +in vec2 instancePixelOffset; +out vec4 vFillColor; +out vec4 vLineColor; +out vec2 unitPosition; +out float innerUnitRadius; +out float outerRadiusPixels; +void main(void) { +geometry.worldPosition = instancePositions; +outerRadiusPixels = clamp( +project_size_to_pixel(scatterplot.radiusScale * instanceRadius, scatterplot.radiusUnits), +scatterplot.radiusMinPixels, scatterplot.radiusMaxPixels +); +float lineWidthPixels = clamp( +project_size_to_pixel(scatterplot.lineWidthScale * instanceLineWidths, scatterplot.lineWidthUnits), +scatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels +); +outerRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0; +float edgePadding = scatterplot.antialiasing ? (outerRadiusPixels + SMOOTH_EDGE_RADIUS) / outerRadiusPixels : 1.0; +unitPosition = edgePadding * positions.xy; +geometry.uv = unitPosition; +#ifdef USE_ROW_INDEXES +geometry.pickingColor = picking_getPickingColorFromIndex(rowIndexes); +#else +geometry.pickingColor = picking_getPickingColorFromInstanceID(); +#endif +innerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / outerRadiusPixels; +if (scatterplot.billboard) { +gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position); +DECKGL_FILTER_GL_POSITION(gl_Position, geometry); +vec3 offset = edgePadding * positions * outerRadiusPixels; +offset.xy += instancePixelOffset; +DECKGL_FILTER_SIZE(offset, geometry); +gl_Position.xy += project_pixel_size_to_clipspace(offset.xy); +} else { +vec3 offset = edgePadding * positions * project_pixel_size(outerRadiusPixels); +offset.xy += project_pixel_size(instancePixelOffset); +DECKGL_FILTER_SIZE(offset, geometry); +gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset, geometry.position); +DECKGL_FILTER_GL_POSITION(gl_Position, geometry); +} +vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * layer.opacity); +DECKGL_FILTER_COLOR(vFillColor, geometry); +vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity); +DECKGL_FILTER_COLOR(vLineColor, geometry); +} +`;var wvt=`#version 300 es +#define SHADER_NAME scatterplot-layer-fragment-shader +precision highp float; +in vec4 vFillColor; +in vec4 vLineColor; +in vec2 unitPosition; +in float innerUnitRadius; +in float outerRadiusPixels; +out vec4 fragColor; +void main(void) { +geometry.uv = unitPosition; +float distToCenter = length(unitPosition) * outerRadiusPixels; +float inCircle = scatterplot.antialiasing ? +smoothedge(distToCenter, outerRadiusPixels) : +step(distToCenter, outerRadiusPixels); +if (inCircle == 0.0) { +discard; +} +if (scatterplot.stroked > 0.5) { +float isLine = scatterplot.antialiasing ? +smoothedge(innerUnitRadius * outerRadiusPixels, distToCenter) : +step(innerUnitRadius * outerRadiusPixels, distToCenter); +if (scatterplot.filled > 0.5) { +fragColor = mix(vFillColor, vLineColor, isLine); +} else { +if (isLine == 0.0) { +discard; +} +fragColor = vec4(vLineColor.rgb, vLineColor.a * isLine); +} +} else if (scatterplot.filled < 0.5) { +discard; +} else { +fragColor = vFillColor; +} +fragColor.a *= inCircle; +DECKGL_FILTER_COLOR(fragColor, geometry); +} +`;var Wrn=`// Main shaders + +struct ScatterplotUniforms { + radiusScale: f32, + radiusMinPixels: f32, + radiusMaxPixels: f32, + lineWidthScale: f32, + lineWidthMinPixels: f32, + lineWidthMaxPixels: f32, + stroked: f32, + filled: i32, + antialiasing: i32, + billboard: i32, + radiusUnits: i32, + lineWidthUnits: i32, +}; + +@group(0) @binding(0) var scatterplot: ScatterplotUniforms; + +struct Attributes { + @builtin(instance_index) instanceIndex : u32, + @builtin(vertex_index) vertexIndex : u32, + @location(0) positions: vec3, + @location(1) instancePositions: vec3, + @location(2) instancePositions64Low: vec3, + @location(3) instanceRadius: f32, + @location(4) instanceLineWidths: f32, + @location(5) instanceFillColors: vec4, + @location(6) instanceLineColors: vec4, + @location(7) instancePixelOffset: vec2, + PICKING_COLOR_ATTRIBUTE +}; + +struct Varyings { + @builtin(position) position: vec4, + @location(0) vFillColor: vec4, + @location(1) vLineColor: vec4, + @location(2) unitPosition: vec2, + @location(3) innerUnitRadius: f32, + @location(4) outerRadiusPixels: f32, + @location(5) pickingColor: vec3, + @location(6) clipCoordinates: vec2, +}; + +@vertex +fn vertexMain(attributes: Attributes) -> Varyings { + var varyings: Varyings; + + // Draw an inline geometry constant array clip space triangle to verify that rendering works. + // var positions = array, 3>(vec2(0.0, 0.5), vec2(-0.5, -0.5), vec2(0.5, -0.5)); + // if (attributes.instanceIndex == 0) { + // varyings.position = vec4(positions[attributes.vertexIndex], 0.0, 1.0); + // return varyings; + // } + + geometry.worldPosition = attributes.instancePositions; + + // Multiply out radius and clamp to limits + varyings.outerRadiusPixels = clamp( + project_unit_size_to_pixel(scatterplot.radiusScale * attributes.instanceRadius, scatterplot.radiusUnits), + scatterplot.radiusMinPixels, scatterplot.radiusMaxPixels + ); + + // Multiply out line width and clamp to limits + let lineWidthPixels = clamp( + project_unit_size_to_pixel(scatterplot.lineWidthScale * attributes.instanceLineWidths, scatterplot.lineWidthUnits), + scatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels + ); + + // outer radius needs to offset by half stroke width + varyings.outerRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0; + // Expand geometry to accommodate edge smoothing + // WGSL selects the second value when the condition is true, so keep the antialiased path second. + let edgePadding = select( + 1.0, + (varyings.outerRadiusPixels + SMOOTH_EDGE_RADIUS) / varyings.outerRadiusPixels, + scatterplot.antialiasing != 0 + ); + + // position on the containing square in [-1, 1] space + varyings.unitPosition = edgePadding * attributes.positions.xy; + geometry.uv = varyings.unitPosition; + geometry.pickingColor = PICKING_COLOR_VALUE; + + varyings.innerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / varyings.outerRadiusPixels; + + if (scatterplot.billboard != 0) { + let projectedPosition = project_position_to_clipspace_and_commonspace( + attributes.instancePositions, + attributes.instancePositions64Low, + vec3(0.0) + ); + geometry.position = projectedPosition.commonPosition; + varyings.position = projectedPosition.clipPosition; + // DECKGL_FILTER_GL_POSITION(varyings.position, geometry); + var offset = edgePadding * attributes.positions * varyings.outerRadiusPixels; + offset = vec3(offset.xy + attributes.instancePixelOffset, offset.z); + // DECKGL_FILTER_SIZE(offset, geometry); + let clipPixels = project_pixel_size_to_clipspace(offset.xy); + varyings.position = vec4(varyings.position.x + clipPixels.x, varyings.position.y + clipPixels.y, varyings.position.z, varyings.position.w); + geometry.position = vec4( + geometry.position.xy + project_pixel_size_vec2(offset.xy), + geometry.position.zw + ); + } else { + var offset = edgePadding * attributes.positions * project_pixel_size_float(varyings.outerRadiusPixels); + offset = vec3(offset.xy + project_pixel_size_vec2(attributes.instancePixelOffset), offset.z); + // DECKGL_FILTER_SIZE(offset, geometry); + let projectedPosition = project_position_to_clipspace_and_commonspace( + attributes.instancePositions, + attributes.instancePositions64Low, + offset + ); + geometry.position = projectedPosition.commonPosition; + varyings.position = projectedPosition.clipPosition; + // DECKGL_FILTER_GL_POSITION(varyings.position, geometry); + } + + varyings.clipCoordinates = geometry.position.xy; + clip_filterPosition(&varyings.position, geometry.worldPosition.xy); + + // Apply opacity to instance color, or return instance picking color + varyings.vFillColor = vec4(attributes.instanceFillColors.rgb, attributes.instanceFillColors.a * layer.opacity); + // DECKGL_FILTER_COLOR(varyings.vFillColor, geometry); + varyings.vLineColor = vec4(attributes.instanceLineColors.rgb, attributes.instanceLineColors.a * layer.opacity); + // DECKGL_FILTER_COLOR(varyings.vLineColor, geometry); + varyings.pickingColor = geometry.pickingColor; + + return varyings; +} + +@fragment +fn fragmentMain(varyings: Varyings) -> @location(0) vec4 { + // var geometry: Geometry; + // geometry.uv = unitPosition; + + let distToCenter = length(varyings.unitPosition) * varyings.outerRadiusPixels; + let inCircle = select( + step(distToCenter, varyings.outerRadiusPixels), + smoothedge(distToCenter, varyings.outerRadiusPixels), + scatterplot.antialiasing != 0 + ); + + if (inCircle == 0.0) { + discard; + } + + var fragColor: vec4; + + if (scatterplot.stroked != 0) { + let isLine = select( + step(varyings.innerUnitRadius * varyings.outerRadiusPixels, distToCenter), + smoothedge(varyings.innerUnitRadius * varyings.outerRadiusPixels, distToCenter), + scatterplot.antialiasing != 0 + ); + + if (scatterplot.filled != 0) { + fragColor = mix(varyings.vFillColor, varyings.vLineColor, isLine); + } else { + if (isLine == 0.0) { + discard; + } + fragColor = vec4(varyings.vLineColor.rgb, varyings.vLineColor.a * isLine); + } + } else if (scatterplot.filled == 0) { + discard; + } else { + fragColor = varyings.vFillColor; + } + + fragColor.a *= inCircle; + + clip_filterColor(varyings.clipCoordinates); + + if (picking.isActive > 0.5) { + if (!picking_isColorValid(varyings.pickingColor)) { + discard; + } + return vec4(varyings.pickingColor, 1.0); + } + + if (picking.isHighlightActive > 0.5) { + let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor); + if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) { + let highLightAlpha = picking.highlightColor.a; + let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha); + if (blendedAlpha > 0.0) { + let highLightRatio = highLightAlpha / blendedAlpha; + fragColor = vec4( + mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio), + blendedAlpha + ); + } else { + fragColor = vec4(fragColor.rgb, 0.0); + } + } + } + + // Apply premultiplied alpha as required by transparent canvas + fragColor = deckgl_premultiplied_alpha(fragColor); + + return fragColor; + // return vec4(0, 0, 1, 1); +} +`;function vvt(s){return Wrn.replace("PICKING_COLOR_ATTRIBUTE",s?"@location(8) rowIndexes: u32,":"").replace("PICKING_COLOR_VALUE",s?"picking_getPickingColorFromIndex(attributes.rowIndexes)":"picking_getPickingColorFromIndex(attributes.instanceIndex)")}var Hrn=`struct ClipUniforms { + enabled: i32, + mode: i32, + bounds: vec4, +}; + +@group(2) @binding(auto) var clipUniforms: ClipUniforms; + +fn clip_isInBounds(coordinates: vec2) -> bool { + return coordinates.x >= clipUniforms.bounds.x && + coordinates.y >= clipUniforms.bounds.y && + coordinates.x < clipUniforms.bounds.z && + coordinates.y < clipUniforms.bounds.w; +} + +fn clip_filterPosition(position: ptr>, instanceCoordinates: vec2) { + if ( + clipUniforms.enabled != 0 && + clipUniforms.mode == 1 && + !clip_isInBounds(instanceCoordinates) + ) { + *position = vec4(2.0, 2.0, 2.0, 1.0); + } +} + +fn clip_filterColor(geometryCoordinates: vec2) { + if ( + clipUniforms.enabled != 0 && + clipUniforms.mode == 0 && + !clip_isInBounds(geometryCoordinates) + ) { + discard; + } +} +`,qrn={name:"clip",source:Hrn,props:{},uniforms:{},bindingLayout:[{name:"clip",group:2}],uniformTypes:{enabled:"i32",mode:"i32",bounds:"vec4"},defaultUniforms:{enabled:0,mode:0,bounds:[0,0,1,1]},getUniforms(s={}){let n={};return s.enabled!==void 0&&(n.enabled=s.enabled?1:0),s.mode!==void 0&&(n.mode=s.mode==="instance"?1:0),s.bounds!==void 0&&(n.bounds=s.bounds),n}},DB=qrn;var _vt=[0,0,0,255],Xrn={radiusUnits:"meters",radiusScale:{type:"number",min:0,value:1},radiusMinPixels:{type:"number",min:0,value:0},radiusMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},lineWidthUnits:"meters",lineWidthScale:{type:"number",min:0,value:1},lineWidthMinPixels:{type:"number",min:0,value:0},lineWidthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,getPosition:{type:"accessor",value:s=>s.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:_vt},getLineColor:{type:"accessor",value:_vt},getLineWidth:{type:"accessor",value:1},getPixelOffset:{type:"accessor",value:[0,0]},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}},nW=class extends U3{getShaders(){let n=!!this.props.data?.attributes?.rowIndexes;return super.getShaders({vs:bvt,fs:wvt,source:vvt(n),defines:n?{USE_ROW_INDEXES:!0}:{},modules:[Zy,qy,Jy,mvt,...this.context.device.type==="webgpu"?[DB]:[]]})}initializeState(){let n=this.props.data?.attributes?.rowIndexes?{rowIndexes:{size:1,type:"uint32",noAlloc:!0}}:{};this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceRadius:{size:1,transition:!0,accessor:"getRadius",defaultValue:1,bufferGroup:"scatterplot-instance-data"},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255],bufferGroup:"scatterplot-instance-data"},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255],bufferGroup:"scatterplot-instance-data"},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1,bufferGroup:"scatterplot-instance-data"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset",bufferGroup:"scatterplot-instance-data"},...n})}updateState(n){super.updateState(n),n.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:n}){let{radiusUnits:r,radiusScale:c,radiusMinPixels:u,radiusMaxPixels:d,stroked:b,filled:w,billboard:_,antialiasing:x,lineWidthUnits:T,lineWidthScale:M,lineWidthMinPixels:L,lineWidthMaxPixels:I}=this.props,D={stroked:b,filled:w,billboard:_,antialiasing:x,radiusUnits:Cb[r],radiusScale:c,radiusMinPixels:u,radiusMaxPixels:d,lineWidthUnits:Cb[T],lineWidthScale:M,lineWidthMinPixels:L,lineWidthMaxPixels:I},F=this.state.model;F.shaderInputs.setProps({scatterplot:D}),F.draw(this.context.renderPass)}_getModel(){let n=[-1,-1,0,1,-1,0,-1,1,0,1,1,0];return new $h(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Pb({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(n)}}}),isInstanced:!0})}};nW.defaultProps=Xrn;nW.layerName="ScatterplotLayer";var bIe=nW;var Hue={CLOCKWISE:1,COUNTER_CLOCKWISE:-1};function iW(s,n,r={}){return yvt(s,r)!==n?(Yrn(s,r),!0):!1}function yvt(s,n={}){return Math.sign(que(s,n))}var wIe={x:0,y:1,z:2};function que(s,n={}){let{start:r=0,end:c=s.length,plane:u="xy"}=n,d=n.size||2,b=0,w=wIe[u[0]],_=wIe[u[1]];for(let x=r,T=c-d;x0){let u=!0;for(let d=0;dn[2]&&(r|=2),s[1]n[3]&&(r|=8),r}function oW(s,n){let{size:r=2,broken:c=!1,gridResolution:u=10,gridOffset:d=[0,0],startIndex:b=0,endIndex:w=s.length}=n||{},_=(w-b)/r,x=[],T=[x],M=nT(s,0,r,b),L,I,D=Svt(M,u,d,[]),F=[];xm(x,M);for(let O=1;O<_;O++){for(L=nT(s,O,r,b,L),I=sW(L,D);I;){Xue(M,L,I,D,F);let z=sW(F,D);z&&(Xue(M,F,z,D,F),I=z),xm(x,F),rW(M,F),Jrn(D,u,I),c&&x.length>r&&(x=[],T.push(x),xm(x,M)),I=sW(L,D)}xm(x,L),rW(M,L)}return c?T:T[0]}var xvt=0,Krn=1;function aW(s,n=null,r){if(!s.length)return[];let{size:c=2,gridResolution:u=10,gridOffset:d=[0,0],edgeTypes:b=!1}=r||{},w=[],_=[{pos:s,types:b?new Array(s.length/c).fill(Krn):null,holes:n||[]}],x=[[],[]],T=[];for(;_.length;){let{pos:M,types:L,holes:I}=_.shift();Qrn(M,c,I[0]||M.length,x),T=Svt(x[0],u,d,T);let D=sW(x[1],T);if(D){let F=Evt(M,L,c,0,I[0]||M.length,T,D),O={pos:F[0].pos,types:F[0].types,holes:[]},z={pos:F[1].pos,types:F[1].types,holes:[]};_.push(O,z);for(let Z=0;Z=0?(xm(x,I)&&M.push(F),te+=D):M.length&&(M[M.length-1]=xvt),rW(O,I),z=D,Z=F;return[H?{pos:_,types:n&&T}:null,te?{pos:x,types:n&&M}:null]}function Svt(s,n,r,c){let u=Math.floor((s[0]-r[0])/n)*n+r[0],d=Math.floor((s[1]-r[1])/n)*n+r[1];return c[0]=u,c[1]=d,c[2]=u+n,c[3]=d+n,c}function Jrn(s,n,r){r&8?(s[1]+=n,s[3]+=n):r&4?(s[1]-=n,s[3]-=n):r&2?(s[0]+=n,s[2]+=n):r&1&&(s[0]-=n,s[2]-=n)}function Qrn(s,n,r,c){let u=1/0,d=-1/0,b=1/0,w=-1/0;for(let _=0;_d?x:d,b=Tw?T:w}return c[0][0]=u,c[0][1]=b,c[1][0]=d,c[1][1]=w,c}function Yue(s,n){for(let r=0;ru&&(u=w,d=b-1)}return d}function nsn(s,n,r,c,u=esn){let d=s[r],b=s[c-n];if(Math.abs(d-b)>180){let w=nT(s,0,n,r);w[0]+=Math.round((b-d)/360)*360,xm(s,w),w[1]=Math.sign(w[1])*u,xm(s,w),w[0]=d,xm(s,w)}}function Mvt(s,n,r,c){let u=s[0],d;for(let b=r;b180||w<-180)&&(d-=Math.round(w/360)*360),s[b]=u=d}}function Tvt(s,n){let r,c=s.length/n;for(let d=0;d=n.length&&(r+=1-n.length/u);let d=r*u;return c[0]=n[d],c[1]=n[d+1],c[2]=u===3&&n[d+2]||0,c}isClosed(n){if(!this.normalize)return!!this.opts.loop;let{positionSize:r}=this,c=n.length-r;return n[0]===n[c]&&n[1]===n[c+1]&&(r===2||n[2]===n[c+2])}};function Avt(s){return Array.isArray(s[0])}var osn=`struct PathUniforms { + widthScale: f32, + widthMinPixels: f32, + widthMaxPixels: f32, + jointType: f32, + capType: f32, + miterLimit: f32, + billboard: f32, + widthUnits: i32, +}; + +@group(0) @binding(auto) +var path: PathUniforms; +`,Pvt=`layout(std140) uniform pathUniforms { + float widthScale; + float widthMinPixels; + float widthMaxPixels; + float jointType; + float capType; + float miterLimit; + bool billboard; + highp int widthUnits; +} path; +`,Lvt={name:"path",source:osn,vs:Pvt,fs:Pvt,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",jointType:"f32",capType:"f32",miterLimit:"f32",billboard:"f32",widthUnits:"i32"}};var kvt=`const EPSILON: f32 = 0.001; +const ZERO_OFFSET: vec3 = vec3(0.0, 0.0, 0.0); + +struct JoinResult { + offset: vec3, + cornerOffset: vec2, + miterLength: f32, + pathPosition: vec2, + pathLength: f32, + jointType: f32, +}; + +struct Attributes { + @location(0) positions: vec2, + @location(1) instanceTypes: f32, + @location(2) instanceLeftPositions: vec3, + @location(3) instanceStartPositions: vec3, + @location(4) instanceEndPositions: vec3, + @location(5) instanceRightPositions: vec3, + @location(6) instanceLeftPositions64Low: vec3, + @location(7) instanceStartPositions64Low: vec3, + @location(8) instanceEndPositions64Low: vec3, + @location(9) instanceRightPositions64Low: vec3, + @location(10) instanceStrokeWidths: f32, + @location(11) instanceColors: vec4, + @location(12) rowIndexes: u32, +}; + +struct Varyings { + @builtin(position) position: vec4, + @location(0) vColor: vec4, + @location(1) vCornerOffset: vec2, + @location(2) vMiterLength: f32, + @location(3) vPathPosition: vec2, + @location(4) vPathLength: f32, + @location(5) vJointType: f32, + // Location 6 is reserved for TripsLayer's injected vTime varying. + @location(7) clipCoordinates: vec2, +#ifdef DASH_ENABLED + @location(8) vPathBounds: vec2, +#endif +}; + +fn flipIfTrue(flag: bool) -> f32 { + return select(1.0, -1.0, flag); +} + +fn clipLine(position: vec4, refPosition: vec4) -> vec4 { + if (position.w < EPSILON) { + let r = (EPSILON - refPosition.w) / (position.w - refPosition.w); + return refPosition + (position - refPosition) * r; + } + return position; +} + +#ifdef DASH_ENABLED +// Return the visible interval of the original segment before clipLine moves either endpoint. +fn getClippedPathRange(startW: f32, endW: f32) -> vec2 { + let startClipped = startW < EPSILON; + let endClipped = endW < EPSILON; + if (startClipped && endClipped) { + return vec2(0.0, 0.0); + } + if (startClipped || endClipped) { + let intersection = clamp((EPSILON - startW) / (endW - startW), 0.0, 1.0); + if (startClipped) { + return vec2(intersection, 1.0); + } + return vec2(0.0, intersection); + } + return vec2(0.0, 1.0); +} +#endif + +fn getLineJoinOffset( + prevPoint: vec3, + currPoint: vec3, + nextPoint: vec3, + width: vec2, +#ifdef DASH_ENABLED + sourcePathLength: f32, + sourcePathRange: vec2, +#endif +#ifdef ANTIALIASING + coverageScale: f32, +#endif + positions: vec2, + instanceTypes: f32 +) -> JoinResult { + let isEnd = positions.x > 0.0; + let sideOfPath = positions.y; + let isJoint = select(0.0, 1.0, sideOfPath == 0.0); + + var deltaA3 = currPoint - prevPoint; + var deltaB3 = nextPoint - currPoint; + + let rotationResult = project_needs_rotation(currPoint); + if (path.billboard == 0.0 && rotationResult.needsRotation) { + deltaA3 = rotationResult.transform * deltaA3; + deltaB3 = rotationResult.transform * deltaB3; + } + + let deltaA = deltaA3.xy / width; + let deltaB = deltaB3.xy / width; + + let lenA = length(deltaA); + let lenB = length(deltaB); + + let dirA = select(vec2(0.0, 0.0), normalize(deltaA), lenA > 0.0); + let dirB = select(vec2(0.0, 0.0), normalize(deltaB), lenB > 0.0); + + let perpA = vec2(-dirA.y, dirA.x); + let perpB = vec2(-dirB.y, dirB.x); + + var tangent = dirA + dirB; + tangent = select(perpA, normalize(tangent), length(tangent) > 0.0); + let miterVec = vec2(-tangent.y, tangent.x); + let dir = select(dirB, dirA, isEnd); + let perp = select(perpB, perpA, isEnd); +#ifdef DASH_ENABLED + let segmentLength2D = select(lenB, lenA, isEnd); + + // Extrusion happens in the XY plane, so segmentLength2D is a 2D length and pathPosition.y + // below measures 2D distance along the segment. For a path that also moves in Z the true + // arc length is longer by this ratio. Scaling pathLength and pathPosition.y by it makes + // the coordinate measure real 3D distance while leaving the joint tests unchanged, since + // they compare the two against each other and both are scaled alike. Billboard mode + // extrudes in clip space, where the perspective divide has already reduced the segment to + // its screen projection, so its complete common-space length is supplied by the caller. + // Mirrors path-layer-vertex.glsl.ts. + let currDelta3 = select(deltaB3, deltaA3, isEnd); + let currLength2D = length(currDelta3.xy); + // Do not clamp a valid denominator to EPSILON: high-zoom Web Mercator deltas are often + // smaller than that in common space, and changing their scale corrupts even flat paths. + let safeLength2D = select(1.0, currLength2D, currLength2D > 0.0); + var arcLengthRatio = 1.0; + var pathPositionOffset = 0.0; + var pathLength = segmentLength2D; + if (path.billboard != 0.0) { + // clipLine may shorten the visible screen-space segment. Preserve the corresponding interval + // of the complete common-space arclength instead of compressing the full dash period into the + // visible span. Keep pathLength complete so justification is stable as the camera clips it. + let visiblePathLength = sourcePathLength * (sourcePathRange.y - sourcePathRange.x); + arcLengthRatio = 0.0; + if (segmentLength2D > 0.0) { + arcLengthRatio = visiblePathLength / segmentLength2D; + } + pathPositionOffset = sourcePathLength * sourcePathRange.x; + pathLength = sourcePathLength; + } else if (currLength2D > 0.0) { + arcLengthRatio = length(currDelta3) / safeLength2D; + pathLength = segmentLength2D * arcLengthRatio; + } +#else + let pathLength = select(lenB, lenA, isEnd); +#endif + + let sinHalfA = abs(dot(miterVec, perp)); + let cosHalfA = abs(dot(dirA, miterVec)); + let turnDirection = flipIfTrue(dirA.x * dirB.y >= dirA.y * dirB.x); + let cornerPosition = sideOfPath * turnDirection; + + var miterSize = 1.0 / max(sinHalfA, EPSILON); + miterSize = mix( + min(miterSize, max(lenA, lenB) / max(cosHalfA, EPSILON)), + miterSize, + step(0.0, cornerPosition) + ); + + var offsetVec = + mix(miterVec * miterSize, perp, step(0.5, cornerPosition)) * + (sideOfPath + isJoint * turnDirection); + + let isStartCap = lenA == 0.0 || (!isEnd && (instanceTypes == 1.0 || instanceTypes == 3.0)); + let isEndCap = lenB == 0.0 || (isEnd && (instanceTypes == 2.0 || instanceTypes == 3.0)); + let isCap = isStartCap || isEndCap; + + var jointType = path.jointType; + if (isCap) { + offsetVec = mix( + perp * sideOfPath, + dir * path.capType * 4.0 * flipIfTrue(isStartCap), + isJoint + ); + jointType = path.capType; + } + +#ifdef ANTIALIASING + let coverageOffsetVec = offsetVec * coverageScale; + var miterLength = dot(coverageOffsetVec, miterVec * turnDirection); +#else + var miterLength = dot(offsetVec, miterVec * turnDirection); +#endif + miterLength = select(miterLength, isJoint, isCap); + +#ifdef ANTIALIASING + let offsetFromStartOfPath = coverageOffsetVec + deltaA * select(0.0, 1.0, isEnd); +#else + let offsetFromStartOfPath = offsetVec + deltaA * select(0.0, 1.0, isEnd); +#endif + let pathPosition = vec2( + dot(offsetFromStartOfPath, perp), +#ifdef DASH_ENABLED + pathPositionOffset + dot(offsetFromStartOfPath, dir) * arcLengthRatio +#else + dot(offsetFromStartOfPath, dir) +#endif + ); + let isValid = step(f32(instanceTypes), 3.5); +#ifdef ANTIALIASING + var offset = vec3(coverageOffsetVec * width * isValid, 0.0); +#else + var offset = vec3(offsetVec * width * isValid, 0.0); +#endif + + if (path.billboard == 0.0 && rotationResult.needsRotation) { + offset = rotationResult.transform * offset; + } + +#ifdef ANTIALIASING + return JoinResult( + offset, coverageOffsetVec, miterLength, pathPosition, pathLength, jointType + ); +#else + return JoinResult(offset, offsetVec, miterLength, pathPosition, pathLength, jointType); +#endif +} + +@vertex +fn vertexMain(attributes: Attributes) -> Varyings { + var varyings: Varyings; + + geometry.pickingColor = picking_getPickingColorFromIndex(attributes.rowIndexes); + + let isEnd = attributes.positions.x; + + let prevPosition = mix(attributes.instanceLeftPositions, attributes.instanceStartPositions, isEnd); + let prevPosition64Low = mix( + attributes.instanceLeftPositions64Low, + attributes.instanceStartPositions64Low, + isEnd + ); + let currPosition = mix(attributes.instanceStartPositions, attributes.instanceEndPositions, isEnd); + let currPosition64Low = mix( + attributes.instanceStartPositions64Low, + attributes.instanceEndPositions64Low, + isEnd + ); + let nextPosition = mix(attributes.instanceEndPositions, attributes.instanceRightPositions, isEnd); + let nextPosition64Low = mix( + attributes.instanceEndPositions64Low, + attributes.instanceRightPositions64Low, + isEnd + ); + + geometry.worldPosition = currPosition; + + let widthPixels = + clamp( + project_unit_size_to_pixel(attributes.instanceStrokeWidths * path.widthScale, path.widthUnits), + path.widthMinPixels, + path.widthMaxPixels + ) / 2.0; + + if (path.billboard != 0.0) { +#ifdef DASH_ENABLED + let prevProjection = project_position_to_clipspace_and_commonspace( + prevPosition, prevPosition64Low, ZERO_OFFSET + ); + let nextProjection = project_position_to_clipspace_and_commonspace( + nextPosition, nextPosition64Low, ZERO_OFFSET + ); + let prevPositionCommon = prevProjection.commonPosition.xyz; + let nextPositionCommon = nextProjection.commonPosition.xyz; + var prevPositionScreen = prevProjection.clipPosition; + var nextPositionScreen = nextProjection.clipPosition; +#else + var prevPositionScreen = project_position_to_clipspace( + prevPosition, prevPosition64Low, ZERO_OFFSET + ); + var nextPositionScreen = project_position_to_clipspace( + nextPosition, nextPosition64Low, ZERO_OFFSET + ); +#endif + let currProjection = project_position_to_clipspace_and_commonspace( + currPosition, currPosition64Low, ZERO_OFFSET + ); + geometry.position = currProjection.commonPosition; + var currPositionScreen = currProjection.clipPosition; +#ifdef DASH_ENABLED + let currPositionCommon = currProjection.commonPosition.xyz; + let sourcePathStartScreen = mix(currPositionScreen, prevPositionScreen, isEnd); + let sourcePathEndScreen = mix(nextPositionScreen, currPositionScreen, isEnd); + let billboardPathRange = getClippedPathRange( + sourcePathStartScreen.w, sourcePathEndScreen.w + ); +#endif + + prevPositionScreen = clipLine(prevPositionScreen, currPositionScreen); + nextPositionScreen = clipLine(nextPositionScreen, currPositionScreen); + currPositionScreen = clipLine(currPositionScreen, mix(nextPositionScreen, prevPositionScreen, isEnd)); + +#ifdef ANTIALIASING + let coverageScale = select( + 1.0, + (widthPixels + 0.5 / project.devicePixelRatio) / max(widthPixels, 1e-6), + widthPixels > 0.0 + ); +#endif +#ifdef DASH_ENABLED + let currentDeltaCommon = select( + nextPositionCommon - currPositionCommon, + currPositionCommon - prevPositionCommon, + isEnd > 0.0 + ); + let billboardPathLength = select( + 0.0, + length(currentDeltaCommon) * project.scale / (widthPixels * project.focalDistance), + widthPixels > 0.0 + ); +#endif + let join = getLineJoinOffset( + prevPositionScreen.xyz / prevPositionScreen.w, + currPositionScreen.xyz / currPositionScreen.w, + nextPositionScreen.xyz / nextPositionScreen.w, + project_pixel_size_to_clipspace(vec2(widthPixels, widthPixels)), +#ifdef DASH_ENABLED + billboardPathLength, + billboardPathRange, +#endif +#ifdef ANTIALIASING + coverageScale, +#endif + attributes.positions, + attributes.instanceTypes + ); +#ifdef DASH_ENABLED + // Phase and justification use the complete source segment, while cap and joint coverage + // must still recognize the endpoints moved by clipLine. + varyings.vPathBounds = billboardPathLength * billboardPathRange; +#endif + + geometry.uv = join.pathPosition; + varyings.position = vec4( + currPositionScreen.xyz + join.offset * currPositionScreen.w, + currPositionScreen.w + ); + varyings.vCornerOffset = join.cornerOffset; + varyings.vMiterLength = join.miterLength; + varyings.vPathPosition = join.pathPosition; + varyings.vPathLength = join.pathLength; + varyings.vJointType = join.jointType; + } else { + let prevPositionCommon = project_position_vec3_f64(prevPosition, prevPosition64Low); + let currPositionCommon = project_position_vec3_f64(currPosition, currPosition64Low); + let nextPositionCommon = project_position_vec3_f64(nextPosition, nextPosition64Low); + + let width = vec2( + project_pixel_size_float(widthPixels), + project_pixel_size_float(widthPixels) + ); +#ifdef ANTIALIASING + let coverageScale = select( + 1.0, + (widthPixels + 0.5 / project.devicePixelRatio) / max(widthPixels, 1e-6), + widthPixels > 0.0 + ); +#endif + let join = getLineJoinOffset( + prevPositionCommon, + currPositionCommon, + nextPositionCommon, + width, +#ifdef DASH_ENABLED + 1.0, + vec2(0.0, 1.0), +#endif +#ifdef ANTIALIASING + coverageScale, +#endif + attributes.positions, + attributes.instanceTypes + ); +#ifdef DASH_ENABLED + varyings.vPathBounds = vec2(0.0, join.pathLength); +#endif + + geometry.position = vec4(currPositionCommon + join.offset, 1.0); + geometry.uv = join.pathPosition; + varyings.position = project_common_position_to_clipspace(geometry.position); + varyings.vCornerOffset = join.cornerOffset; + varyings.vMiterLength = join.miterLength; + varyings.vPathPosition = join.pathPosition; + varyings.vPathLength = join.pathLength; + varyings.vJointType = join.jointType; + } + + varyings.clipCoordinates = geometry.position.xy; + clip_filterPosition(&varyings.position, geometry.worldPosition.xy); + + varyings.vColor = vec4( + attributes.instanceColors.rgb, + attributes.instanceColors.a * layer.opacity + ); + return varyings; +} + +@fragment +fn fragmentMain(varyings: Varyings) -> @location(0) vec4 { + geometry.uv = varyings.vPathPosition; + +#ifdef ANTIALIASING + // Coordinates of the outer silhouette, in units of half-width: rounded joints and caps are + // bounded by the corner offset, everywhere else by the edge of the stroke. Dividing by the + // screen-space derivative converts the distance to the boundary into device pixels, which stays + // correct under perspective foreshortening and under extensions that rescale the stroke. +#ifdef DASH_ENABLED + let isCorner = + varyings.vPathPosition.y < varyings.vPathBounds.x || + varyings.vPathPosition.y > varyings.vPathBounds.y; +#else + let isCorner = varyings.vPathPosition.y < 0.0 || varyings.vPathPosition.y > varyings.vPathLength; +#endif + let isRound = varyings.vJointType > 0.5; + + // Distance to the silhouette in device pixels, from the derivative of the coordinate that + // bounds it. Computed before the discards below: derivatives need uniform control flow and are + // undefined after a discard in the quad. See dev-docs/RFCs/v9.4/analytic-antialiasing-rfc.md + let bodyCoord = abs(varyings.vPathPosition.x); + let cornerCoord = length(varyings.vCornerOffset); + // Both evaluated so each derivative stays on one field across the corner/body boundary + let bodyPixels = (1.0 - bodyCoord) / max(fwidth(bodyCoord), 1e-6); + let cornerPixels = (1.0 - cornerCoord) / max(fwidth(cornerCoord), 1e-6); +#ifdef PATH_STYLE_OFFSET + // Rounded corners still intersect the stroke-width envelope. Extensions may remap + // vPathPosition.x independently of vCornerOffset, as PathStyleExtension does for offsets. + let edgePixels = select(bodyPixels, min(cornerPixels, bodyPixels), isRound && isCorner); +#else + let edgePixels = select(bodyPixels, cornerPixels, isRound && isCorner); +#endif + + // Fragments outside the coverage ramp must not write depth or picking colors. + if (edgePixels <= -SMOOTH_EDGE_RADIUS) { + discard; + } + + if (isCorner) { + if (!isRound && varyings.vMiterLength > path.miterLimit + 1.0) { + discard; + } + } + + var color = varyings.vColor; + + // Feather one device pixel across the width only, before premultiplication. edgePixels is a + // signed device-pixel distance and SMOOTH_EDGE_RADIUS is 0.5, so this ramps across one pixel. + color.a *= smoothedge(0.0, edgePixels); +#else +#ifdef DASH_ENABLED + if ( + varyings.vPathPosition.y < varyings.vPathBounds.x || + varyings.vPathPosition.y > varyings.vPathBounds.y + ) { +#else + if ( + varyings.vPathPosition.y < 0.0 || + varyings.vPathPosition.y > varyings.vPathLength + ) { +#endif + if (varyings.vJointType > 0.5 && length(varyings.vCornerOffset) > 1.0) { + discard; + } + if ( + varyings.vJointType < 0.5 && + varyings.vMiterLength > path.miterLimit + 1.0 + ) { + discard; + } + } +#endif + + // Fragment-layer injections that discard pixels must run after analytic coverage derivatives. + // See TripsLayer, which rejects fragments outside of the active time window at this anchor. + // DECKGL_FILTER_COLOR + clip_filterColor(varyings.clipCoordinates); +#ifdef ANTIALIASING + return deckgl_premultiplied_alpha(color); +#else + return deckgl_premultiplied_alpha(varyings.vColor); +#endif +} +`;var Rvt=`#version 300 es +#define SHADER_NAME path-layer-vertex-shader +in vec2 positions; +in float instanceTypes; +in vec3 instanceStartPositions; +in vec3 instanceEndPositions; +in vec3 instanceLeftPositions; +in vec3 instanceRightPositions; +in vec3 instanceLeftPositions64Low; +in vec3 instanceStartPositions64Low; +in vec3 instanceEndPositions64Low; +in vec3 instanceRightPositions64Low; +in float instanceStrokeWidths; +in vec4 instanceColors; +in float rowIndexes; +uniform float opacity; +out vec4 vColor; +out vec2 vCornerOffset; +out float vMiterLength; +out vec2 vPathPosition; +out float vPathLength; +out float vJointType; +#ifdef DASH_ENABLED +out vec2 vPathBounds; +#endif +const float EPSILON = 0.001; +const vec3 ZERO_OFFSET = vec3(0.0); +float flipIfTrue(bool flag) { +return -(float(flag) * 2. - 1.); +} +vec3 getLineJoinOffset( +vec3 prevPoint, vec3 currPoint, vec3 nextPoint, +vec2 width +#ifdef DASH_ENABLED +, float sourcePathLength, vec2 sourcePathRange +#endif +#ifdef ANTIALIASING +, float coverageScale +#endif +) { +bool isEnd = positions.x > 0.0; +float sideOfPath = positions.y; +float isJoint = float(sideOfPath == 0.0); +vec3 deltaA3 = (currPoint - prevPoint); +vec3 deltaB3 = (nextPoint - currPoint); +mat3 rotationMatrix; +bool needsRotation = !path.billboard && project_needs_rotation(currPoint, rotationMatrix); +if (needsRotation) { +deltaA3 = deltaA3 * rotationMatrix; +deltaB3 = deltaB3 * rotationMatrix; +} +vec2 deltaA = deltaA3.xy / width; +vec2 deltaB = deltaB3.xy / width; +float lenA = length(deltaA); +float lenB = length(deltaB); +vec2 dirA = lenA > 0. ? normalize(deltaA) : vec2(0.0, 0.0); +vec2 dirB = lenB > 0. ? normalize(deltaB) : vec2(0.0, 0.0); +vec2 perpA = vec2(-dirA.y, dirA.x); +vec2 perpB = vec2(-dirB.y, dirB.x); +vec2 tangent = dirA + dirB; +tangent = length(tangent) > 0. ? normalize(tangent) : perpA; +vec2 miterVec = vec2(-tangent.y, tangent.x); +vec2 dir = isEnd ? dirA : dirB; +vec2 perp = isEnd ? perpA : perpB; +float L = isEnd ? lenA : lenB; +#ifdef DASH_ENABLED +vec3 currDelta3 = isEnd ? deltaA3 : deltaB3; +float currLength2D = length(currDelta3.xy); +float arcLengthRatio = 1.0; +float pathPositionOffset = 0.0; +float pathLength = L; +if (path.billboard) { +float visiblePathLength = sourcePathLength * (sourcePathRange.y - sourcePathRange.x); +arcLengthRatio = L > 0.0 ? visiblePathLength / L : 0.0; +pathPositionOffset = sourcePathLength * sourcePathRange.x; +pathLength = sourcePathLength; +} else if (currLength2D > 0.0) { +arcLengthRatio = length(currDelta3) / currLength2D; +pathLength = L * arcLengthRatio; +} +#endif +float sinHalfA = abs(dot(miterVec, perp)); +float cosHalfA = abs(dot(dirA, miterVec)); +float turnDirection = flipIfTrue(dirA.x * dirB.y >= dirA.y * dirB.x); +float cornerPosition = sideOfPath * turnDirection; +float miterSize = 1.0 / max(sinHalfA, EPSILON); +miterSize = mix( +min(miterSize, max(lenA, lenB) / max(cosHalfA, EPSILON)), +miterSize, +step(0.0, cornerPosition) +); +vec2 offsetVec = mix(miterVec * miterSize, perp, step(0.5, cornerPosition)) +* (sideOfPath + isJoint * turnDirection); +bool isStartCap = lenA == 0.0 || (!isEnd && (instanceTypes == 1.0 || instanceTypes == 3.0)); +bool isEndCap = lenB == 0.0 || (isEnd && (instanceTypes == 2.0 || instanceTypes == 3.0)); +bool isCap = isStartCap || isEndCap; +if (isCap) { +offsetVec = mix(perp * sideOfPath, dir * path.capType * 4.0 * flipIfTrue(isStartCap), isJoint); +vJointType = path.capType; +} else { +vJointType = path.jointType; +} +#ifdef ANTIALIASING +vec2 coverageOffsetVec = offsetVec * coverageScale; +#ifdef DASH_ENABLED +vPathLength = pathLength; +#else +vPathLength = L; +#endif +vCornerOffset = coverageOffsetVec; +vMiterLength = dot(vCornerOffset, miterVec * turnDirection); +vMiterLength = isCap ? isJoint : vMiterLength; +vec2 offsetFromStartOfPath = coverageOffsetVec + deltaA * float(isEnd); +vPathPosition = vec2( +dot(offsetFromStartOfPath, perp), +#ifdef DASH_ENABLED +pathPositionOffset + dot(offsetFromStartOfPath, dir) * arcLengthRatio +#else +dot(offsetFromStartOfPath, dir) +#endif +); +geometry.uv = vPathPosition; +float isValid = step(instanceTypes, 3.5); +vec3 offset = vec3(coverageOffsetVec * width * isValid, 0.0); +#else +#ifdef DASH_ENABLED +vPathLength = pathLength; +#else +vPathLength = L; +#endif +vCornerOffset = offsetVec; +vMiterLength = dot(vCornerOffset, miterVec * turnDirection); +vMiterLength = isCap ? isJoint : vMiterLength; +vec2 offsetFromStartOfPath = vCornerOffset + deltaA * float(isEnd); +vPathPosition = vec2( +dot(offsetFromStartOfPath, perp), +#ifdef DASH_ENABLED +pathPositionOffset + dot(offsetFromStartOfPath, dir) * arcLengthRatio +#else +dot(offsetFromStartOfPath, dir) +#endif +); +geometry.uv = vPathPosition; +float isValid = step(instanceTypes, 3.5); +vec3 offset = vec3(offsetVec * width * isValid, 0.0); +#endif +if (needsRotation) { +offset = rotationMatrix * offset; +} +return offset; +} +void clipLine(inout vec4 position, vec4 refPosition) { +if (position.w < EPSILON) { +float r = (EPSILON - refPosition.w) / (position.w - refPosition.w); +position = refPosition + (position - refPosition) * r; +} +} +#ifdef DASH_ENABLED +vec2 getClippedPathRange(float startW, float endW) { +bool startClipped = startW < EPSILON; +bool endClipped = endW < EPSILON; +if (startClipped && endClipped) { +return vec2(0.0); +} +if (startClipped || endClipped) { +float intersection = clamp((EPSILON - startW) / (endW - startW), 0.0, 1.0); +return startClipped ? vec2(intersection, 1.0) : vec2(0.0, intersection); +} +return vec2(0.0, 1.0); +} +#endif +void main() { +geometry.pickingColor = picking_getPickingColorFromIndex(rowIndexes); +vColor = vec4(instanceColors.rgb, instanceColors.a * layer.opacity); +float isEnd = positions.x; +vec3 prevPosition = mix(instanceLeftPositions, instanceStartPositions, isEnd); +vec3 prevPosition64Low = mix(instanceLeftPositions64Low, instanceStartPositions64Low, isEnd); +vec3 currPosition = mix(instanceStartPositions, instanceEndPositions, isEnd); +vec3 currPosition64Low = mix(instanceStartPositions64Low, instanceEndPositions64Low, isEnd); +vec3 nextPosition = mix(instanceEndPositions, instanceRightPositions, isEnd); +vec3 nextPosition64Low = mix(instanceEndPositions64Low, instanceRightPositions64Low, isEnd); +geometry.worldPosition = currPosition; +vec2 widthPixels = vec2(clamp( +project_size_to_pixel(instanceStrokeWidths * path.widthScale, path.widthUnits), +path.widthMinPixels, path.widthMaxPixels) / 2.0); +vec3 width; +if (path.billboard) { +#ifdef DASH_ENABLED +vec4 prevPositionCommon; +vec4 nextPositionCommon; +vec4 prevPositionScreen = project_position_to_clipspace( +prevPosition, prevPosition64Low, ZERO_OFFSET, prevPositionCommon +); +#else +vec4 prevPositionScreen = project_position_to_clipspace( +prevPosition, prevPosition64Low, ZERO_OFFSET +); +#endif +vec4 currPositionScreen = project_position_to_clipspace(currPosition, currPosition64Low, ZERO_OFFSET, geometry.position); +#ifdef DASH_ENABLED +vec4 nextPositionScreen = project_position_to_clipspace( +nextPosition, nextPosition64Low, ZERO_OFFSET, nextPositionCommon +); +#else +vec4 nextPositionScreen = project_position_to_clipspace( +nextPosition, nextPosition64Low, ZERO_OFFSET +); +#endif +#ifdef DASH_ENABLED +vec4 sourcePathStartScreen = mix(currPositionScreen, prevPositionScreen, isEnd); +vec4 sourcePathEndScreen = mix(nextPositionScreen, currPositionScreen, isEnd); +vec2 billboardPathRange = getClippedPathRange( +sourcePathStartScreen.w, sourcePathEndScreen.w +); +#endif +clipLine(prevPositionScreen, currPositionScreen); +clipLine(nextPositionScreen, currPositionScreen); +clipLine(currPositionScreen, mix(nextPositionScreen, prevPositionScreen, isEnd)); +width = vec3(widthPixels, 0.0); +DECKGL_FILTER_SIZE(width, geometry); +#ifdef ANTIALIASING +vec2 coveragePadding = vec2(0.5 / project.devicePixelRatio); +float coverageScale = length(width.xy) > 0.0 +? length(width.xy + coveragePadding) / length(width.xy) +: 1.0; +#endif +#ifdef DASH_ENABLED +vec3 currentDeltaCommon = isEnd > 0.0 +? geometry.position.xyz - prevPositionCommon.xyz +: nextPositionCommon.xyz - geometry.position.xyz; +float billboardPathLength = width.x > 0.0 +? length(currentDeltaCommon) * project.scale / (width.x * project.focalDistance) +: 0.0; +#endif +vec3 offset = getLineJoinOffset( +prevPositionScreen.xyz / prevPositionScreen.w, +currPositionScreen.xyz / currPositionScreen.w, +nextPositionScreen.xyz / nextPositionScreen.w, +project_pixel_size_to_clipspace(width.xy) +#ifdef DASH_ENABLED +, +billboardPathLength, billboardPathRange +#endif +#ifdef ANTIALIASING +, +coverageScale +#endif +); +#ifdef DASH_ENABLED +vPathBounds = billboardPathLength * billboardPathRange; +#endif +DECKGL_FILTER_GL_POSITION(currPositionScreen, geometry); +gl_Position = vec4(currPositionScreen.xyz + offset * currPositionScreen.w, currPositionScreen.w); +} else { +prevPosition = project_position(prevPosition, prevPosition64Low); +currPosition = project_position(currPosition, currPosition64Low); +nextPosition = project_position(nextPosition, nextPosition64Low); +width = vec3(project_pixel_size(widthPixels), 0.0); +DECKGL_FILTER_SIZE(width, geometry); +#ifdef ANTIALIASING +vec2 coveragePadding = project_pixel_size(vec2(0.5 / project.devicePixelRatio)); +float coverageScale = length(width.xy) > 0.0 +? length(width.xy + coveragePadding) / length(width.xy) +: 1.0; +#endif +vec3 offset = getLineJoinOffset( +prevPosition, currPosition, nextPosition, width.xy +#ifdef DASH_ENABLED +, 1.0, vec2(0.0, 1.0) +#endif +#ifdef ANTIALIASING +, coverageScale +#endif +); +#ifdef DASH_ENABLED +vPathBounds = vec2(0.0, vPathLength); +#endif +geometry.position = vec4(currPosition + offset, 1.0); +gl_Position = project_common_position_to_clipspace(geometry.position); +DECKGL_FILTER_GL_POSITION(gl_Position, geometry); +} +DECKGL_FILTER_COLOR(vColor, geometry); +} +`;var Ivt=`#version 300 es +#define SHADER_NAME path-layer-fragment-shader +precision highp float; +in vec4 vColor; +in vec2 vCornerOffset; +in float vMiterLength; +in vec2 vPathPosition; +in float vPathLength; +in float vJointType; +#ifdef DASH_ENABLED +in vec2 vPathBounds; +#endif +out vec4 fragColor; +void main(void) { +geometry.uv = vPathPosition; +#ifdef ANTIALIASING +#ifdef DASH_ENABLED +bool isCorner = vPathPosition.y < vPathBounds.x || vPathPosition.y > vPathBounds.y; +#else +bool isCorner = vPathPosition.y < 0.0 || vPathPosition.y > vPathLength; +#endif +bool isRound = vJointType > 0.5; +float bodyCoord = abs(vPathPosition.x); +float cornerCoord = length(vCornerOffset); +float bodyPixels = (1.0 - bodyCoord) / max(fwidth(bodyCoord), 1e-6); +float cornerPixels = (1.0 - cornerCoord) / max(fwidth(cornerCoord), 1e-6); +#ifdef PATH_STYLE_OFFSET +float edgePixels = isRound && isCorner ? min(cornerPixels, bodyPixels) : bodyPixels; +#else +float edgePixels = isRound && isCorner ? cornerPixels : bodyPixels; +#endif +if (edgePixels <= -SMOOTH_EDGE_RADIUS) { +discard; +} +if (isCorner) { +if (!isRound && vMiterLength > path.miterLimit + 1.0) { +discard; +} +} +fragColor = vColor; +fragColor.a *= smoothedge(0.0, edgePixels); +#else +#ifdef DASH_ENABLED +if (vPathPosition.y < vPathBounds.x || vPathPosition.y > vPathBounds.y) { +#else +if (vPathPosition.y < 0.0 || vPathPosition.y > vPathLength) { +#endif +if (vJointType > 0.5 && length(vCornerOffset) > 1.0) { +discard; +} +if (vJointType < 0.5 && vMiterLength > path.miterLimit + 1.0) { +discard; +} +} +fragColor = vColor; +#endif +DECKGL_FILTER_COLOR(fragColor, geometry); +} +`;var Bvt=[0,0,0,255],asn={widthUnits:"meters",widthScale:{type:"number",min:0,value:1},widthMinPixels:{type:"number",min:0,value:0},widthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},jointRounded:!1,capRounded:!1,miterLimit:{type:"number",min:0,value:4},antialiasing:!1,billboard:!1,_pathType:null,getPath:{type:"accessor",value:s=>s.path},getColor:{type:"accessor",value:Bvt},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},yIe={enter:(s,n)=>n.length?n.subarray(n.length-s.length):s};function csn(s){if(s.isGeospatial)return null;let{unitsPerMeter:n}=s.distanceScales;return[n[0],n[1],n[2]]}function Dvt(s,n){return s===n||!!(s&&n&&s.length===n.length&&s.every((r,c)=>r===n[c]))}var uW=class extends U3{getShaders(){let{antialiasing:n}=this.props;return super.getShaders({vs:Rvt,fs:Ivt,source:kvt,defines:n?{ANTIALIASING:1}:{},modules:[Zy,qy,Jy,Lvt,...this.context.device.type==="webgpu"?[DB]:[]]})}get wrapLongitude(){return!1}getBounds(){return this.context.device.type==="webgpu"?null:this.getAttributeManager()?.getBounds(["vertexPositions"])}getPathProjectionScale(n){let r=this.props.coordinateSystem;if(!!!this.getAttributeManager()?.getAttributes().instanceDashOffsets)return null;if(n instanceof k3&&n.zoom>=12&&(r==="default"||r==="lnglat"||r==="cartesian")){let b=lv.getUniforms({viewport:n,coordinateSystem:r,coordinateOrigin:this.props.coordinateOrigin,autoWrapLongitude:this.wrapLongitude});return[n.projectionMode,b.coordinateOrigin[1],b.commonOrigin[1],...b.commonUnitsPerWorldUnit,...b.commonUnitsPerWorldUnit2,b.commonUnitsPerMeter[2]]}let d=csn(n);return d?[n.projectionMode,...d]:[n.projectionMode]}shouldUpdateState(n){let{viewport:r}=this.context;return super.shouldUpdateState(n)||this.state?.tessellationResolution!==r.resolution||!Dvt(this.state?.pathProjectionScale,this.getPathProjectionScale(r))}initializeState(){let r=this.context.device.type==="webgpu";this.getAttributeManager().addInstanced({...r?{pathPositions:{size:24,type:"float32",transition:!1,accessor:"getPath",update:this.calculateWebGPUPositions,shaderAttributes:{instanceLeftPositions:{size:3,elementOffset:0},instanceStartPositions:{size:3,elementOffset:3},instanceEndPositions:{size:3,elementOffset:6},instanceRightPositions:{size:3,elementOffset:9},instanceLeftPositions64Low:{size:3,elementOffset:12},instanceStartPositions64Low:{size:3,elementOffset:15},instanceEndPositions64Low:{size:3,elementOffset:18},instanceRightPositions64Low:{size:3,elementOffset:21}},noAlloc:!0}}:{vertexPositions:{size:3,vertexOffset:1,type:"float64",fp64:this.use64bitPositions(),transition:yIe,accessor:"getPath",update:this.calculatePositions,noAlloc:!0,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}}},instanceTypes:{size:1,type:r?"float32":"uint8",update:this.calculateSegmentTypes,noAlloc:!0},instanceStrokeWidths:{size:1,accessor:"getWidth",transition:r?!1:yIe,defaultValue:1,bufferGroup:"path-instance-data"},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",accessor:"getColor",transition:r?!1:yIe,defaultValue:Bvt,bufferGroup:"path-instance-data"},rowIndexes:{size:1,type:"uint32",accessor:(u,{index:d})=>u&&u.__source?u.__source.index:d,bufferGroup:"path-instance-data"}}),this.setState({pathTesselator:new lW({fp64:this.use64bitPositions(),isWebGPU:r}),tessellationResolution:this.context.viewport.resolution,pathProjectionScale:this.getPathProjectionScale(this.context.viewport)})}updateState(n){super.updateState(n);let{props:r,oldProps:c,changeFlags:u}=n,d=this.getAttributeManager(),{viewport:b}=this.context,w=this.state.tessellationResolution!==b.resolution,_=this.getPathProjectionScale(b),x=!Dvt(this.state.pathProjectionScale,_),M=u.updateTriggersChanged&&(u.updateTriggersChanged.all||u.updateTriggersChanged.getPath)||r._pathType!==c._pathType||r.positionFormat!==c.positionFormat||r.wrapLongitude!==c.wrapLongitude||w;if(u.dataChanged||M){let{pathTesselator:I}=this.state,D=r.data.attributes||{};I.updateGeometry({data:r.data,geometryBuffer:D.getPath,buffers:D,normalize:!r._pathType,loop:r._pathType==="loop",getGeometry:r.getPath,positionFormat:r.positionFormat,wrapLongitude:r.wrapLongitude,resolution:b.resolution,dataChanged:M?void 0:u.dataChanged}),this.setState({numInstances:I.instanceCount,startIndices:I.vertexStarts,tessellationResolution:b.resolution,pathProjectionScale:_}),!u.dataChanged||M?d.invalidateAll():x&&d.invalidate("instanceDashOffsets")}else x&&(this.setState({pathProjectionScale:_}),d.invalidate("instanceDashOffsets"));(u.extensionsChanged||r.antialiasing!==c.antialiasing)&&(this.state.model?.destroy(),this.state.model=this._getModel(),d.invalidateAll())}getPickingInfo(n){let r=super.getPickingInfo(n),{index:c}=r,u=this.props.data;return u[0]&&u[0].__source&&(r.object=u.find(d=>d.__source.index===c)),r}disablePickingIndex(n){let r=this.props.data;if(r[0]&&r[0].__source)for(let c=0;c=0&&T=1&&s[0].length>=2&&Number.isFinite(s[0][0])}function Csn(s){let n=s[0],r=s[s.length-1];return n[0]===r[0]&&n[1]===r[1]&&n[2]===r[2]}function Asn(s,n,r,c){for(let u=0;uw/n));let d=OB(s),b=c&&n===3;if(r){let w=d.length;d=d.slice();let _=[];for(let x=0;x_&&w>x||(_>x?(r||(d=d.slice()),Vvt(d,0,2,1)):(r||(d=d.slice()),Vvt(d,2,0,1)))}return(0,Wvt.default)(d,u,n)}var gW=class extends tT{constructor(n){let{fp64:r,IndexType:c=Uint32Array}=n;super({...n,attributes:{positions:{size:3,type:r?Float64Array:Float32Array},vertexValid:{type:Uint16Array,size:1},indices:{type:c,size:1}}})}get(n){let{attributes:r}=this;return n==="indices"?r.indices&&r.indices.subarray(0,this.vertexCount):r[n]}updateGeometry(n){super.updateGeometry(n);let r=this.buffers.indices;if(r)this.vertexCount=(r.value||r).length;else if(this.data&&!this.getGeometry)throw new Error("missing indices buffer")}normalizeGeometry(n){if(this.normalize){let r=Hvt(n,this.positionSize);return this.opts.resolution?aW(OB(r),pW(r),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?_Ie(OB(r),pW(r),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):r}return n}getGeometrySize(n){if(Xvt(n)){let r=0;for(let c of n)r+=this.getGeometrySize(c);return r}return OB(n).length/this.positionSize}getGeometryFromBuffer(n){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(n):null}updateGeometryAttributes(n,r){if(n&&Xvt(n))for(let c of n){let u=this.getGeometrySize(c);r.geometrySize=u,this.updateGeometryAttributes(c,r),r.vertexStart+=u,r.indexStart=this.indexStarts[r.geometryIndex+1]}else{let c=n;this._updateIndices(c,r),this._updatePositions(c,r),this._updateVertexValid(c,r)}}_updateIndices(n,{geometryIndex:r,vertexStart:c,indexStart:u}){let{attributes:d,indexStarts:b,typedArrayManager:w}=this,_=d.indices;if(!_||!n)return;let x=u,T=qvt(n,this.positionSize,this.opts.preproject,this.opts.full3d);_=w.allocate(_,u+T.length,{copy:!0});for(let M=0;M2?b[_*d+2]:0;u[w*3]=x,u[w*3+1]=T,u[w*3+2]=M}}_updateVertexValid(n,{vertexStart:r,geometrySize:c}){let{positionSize:u}=this,d=this.attributes.vertexValid,b=n&&pW(n);if(n&&n.edgeTypes?d.set(n.edgeTypes,r):d.fill(1,r,r+c),b)for(let w=0;w0&&!Number.isFinite(s[0])}var Lsn=`struct SolidPolygonUniforms { + extruded: f32, + isWireframe: f32, + elevationScale: f32, +}; + +@group(0) @binding(auto) var solidPolygon: SolidPolygonUniforms; +`,Yvt=`layout(std140) uniform solidPolygonUniforms { + bool extruded; + bool isWireframe; + float elevationScale; +} solidPolygon; +`,Zvt={name:"solidPolygon",source:Lsn,vs:Yvt,fs:Yvt,uniformTypes:{extruded:"f32",isWireframe:"f32",elevationScale:"f32"}};var tfe=`in vec4 fillColors; +in vec4 lineColors; +in float rowIndexes; +out vec4 vColor; +struct PolygonProps { +vec3 positions; +vec3 positions64Low; +vec3 normal; +float elevations; +}; +vec3 project_offset_normal(vec3 vector) { +if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT || +project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSETS) { +return normalize(vector * project.commonUnitsPerWorldUnit); +} +return project_normal(vector); +} +void calculatePosition(PolygonProps props) { +vec3 pos = props.positions; +vec3 pos64Low = props.positions64Low; +vec3 normal = props.normal; +vec4 colors = solidPolygon.isWireframe ? lineColors : fillColors; +geometry.worldPosition = props.positions; +geometry.pickingColor = picking_getPickingColorFromIndex(rowIndexes); +if (solidPolygon.extruded) { +pos.z += props.elevations * solidPolygon.elevationScale; +} +gl_Position = project_position_to_clipspace(pos, pos64Low, vec3(0.), geometry.position); +DECKGL_FILTER_GL_POSITION(gl_Position, geometry); +if (solidPolygon.extruded) { +#ifdef IS_SIDE_VERTEX +normal = project_offset_normal(normal); +#else +normal = project_normal(normal); +#endif +geometry.normal = normal; +vec3 lightColor = lighting_getLightColor(colors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal); +vColor = vec4(lightColor, colors.a * layer.opacity); +} else { +vColor = vec4(colors.rgb, colors.a * layer.opacity); +} +DECKGL_FILTER_COLOR(vColor, geometry); +} +`;var Kvt=`#version 300 es +#define SHADER_NAME solid-polygon-layer-vertex-shader +in vec3 vertexPositions; +in vec3 vertexPositions64Low; +in float elevations; +${tfe} +void main(void) { +PolygonProps props; +props.positions = vertexPositions; +props.positions64Low = vertexPositions64Low; +props.elevations = elevations; +props.normal = vec3(0.0, 0.0, 1.0); +calculatePosition(props); +} +`;var Jvt=`#version 300 es +#define SHADER_NAME solid-polygon-layer-vertex-shader-side +#define IS_SIDE_VERTEX +in vec2 positions; +in vec3 vertexPositions; +in vec3 nextVertexPositions; +in vec3 vertexPositions64Low; +in vec3 nextVertexPositions64Low; +in float elevations; +in float instanceVertexValid; +${tfe} +void main(void) { +if(instanceVertexValid < 0.5){ +gl_Position = vec4(0.); +return; +} +PolygonProps props; +vec3 pos; +vec3 pos64Low; +vec3 nextPos; +vec3 nextPos64Low; +#if RING_WINDING_ORDER_CW == 1 +pos = vertexPositions; +pos64Low = vertexPositions64Low; +nextPos = nextVertexPositions; +nextPos64Low = nextVertexPositions64Low; +#else +pos = nextVertexPositions; +pos64Low = nextVertexPositions64Low; +nextPos = vertexPositions; +nextPos64Low = vertexPositions64Low; +#endif +props.positions = mix(pos, nextPos, positions.x); +props.positions64Low = mix(pos64Low, nextPos64Low, positions.x); +props.normal = vec3( +pos.y - nextPos.y + (pos64Low.y - nextPos64Low.y), +nextPos.x - pos.x + (nextPos64Low.x - pos64Low.x), +0.0); +props.elevations = elevations * positions.y; +calculatePosition(props); +} +`;var Qvt=`#version 300 es +#define SHADER_NAME solid-polygon-layer-fragment-shader +precision highp float; +in vec4 vColor; +out vec4 fragColor; +void main(void) { +fragColor = vColor; +geometry.uv = vec2(0.); +DECKGL_FILTER_COLOR(fragColor, geometry); +} +`;function e_t(){return`fn project_offset_normal(vector: vec3) -> vec3 { + if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT || + project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSETS) { + return normalize(vector * project.commonUnitsPerWorldUnit); + } + return project_normal(vector); +} + +fn apply_polygon_color( + colors: vec4, + normal: vec3, + position: vec4 +) -> vec4 { + if (solidPolygon.extruded > 0.5) { + let lightColor = lighting_getLightColor2( + colors.rgb, + project.cameraPosition, + position.xyz, + normal + ); + return vec4(lightColor, colors.a * layer.opacity); + } + return vec4(colors.rgb, colors.a * layer.opacity); +} +`}function t_t(){return`@fragment +fn fragmentMain(inp: Varyings) -> @location(0) vec4 { + geometry.uv = vec2(0.0, 0.0); + + clip_filterColor(inp.clipCoordinates); + + if (picking.isActive > 0.5) { + if (!picking_isColorValid(inp.pickingColor)) { + discard; + } + return vec4(inp.pickingColor, 1.0); + } + + var fragColor = inp.vColor; + + if (picking.isHighlightActive > 0.5) { + let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor); + if (picking_isColorZero(abs(inp.pickingColor - highlightedObjectColor))) { + let highLightAlpha = picking.highlightColor.a; + let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha); + if (blendedAlpha > 0.0) { + let highLightRatio = highLightAlpha / blendedAlpha; + fragColor = vec4( + mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio), + blendedAlpha + ); + } else { + fragColor = vec4(fragColor.rgb, 0.0); + } + } + } + + return deckgl_premultiplied_alpha(fragColor); +} +`}function ksn(){return`${e_t()} + +struct Attributes { + @location(0) vertexPositions: vec3, + @location(1) vertexPositions64Low: vec3, + @location(2) elevations: f32, + @location(3) fillColors: vec4, + @location(4) lineColors: vec4, + @location(5) rowIndexes: u32, +}; + +struct Varyings { + @builtin(position) position: vec4, + @location(0) vColor: vec4, + @location(1) pickingColor: vec3, + @location(2) clipCoordinates: vec2, +}; + +@vertex +fn vertexMain(attributes: Attributes) -> Varyings { + var outp: Varyings; + + var pos = attributes.vertexPositions; + if (solidPolygon.extruded > 0.5) { + pos.z += attributes.elevations * solidPolygon.elevationScale; + } + + geometry.worldPosition = attributes.vertexPositions; + geometry.pickingColor = picking_getPickingColorFromIndex(attributes.rowIndexes); + + let projectedPosition = project_position_to_clipspace_and_commonspace( + pos, + attributes.vertexPositions64Low, + vec3(0.0) + ); + geometry.position = projectedPosition.commonPosition; + outp.position = projectedPosition.clipPosition; + + let normal = project_normal(vec3(0.0, 0.0, 1.0)); + geometry.normal = normal; + + let colors = select( + attributes.fillColors, + attributes.lineColors, + solidPolygon.isWireframe > 0.5 + ); + outp.vColor = apply_polygon_color(colors, normal, geometry.position); + outp.pickingColor = geometry.pickingColor; + + outp.clipCoordinates = geometry.position.xy; + clip_filterPosition(&outp.position, geometry.worldPosition.xy); + + return outp; +} + +${t_t()} +`}function Rsn(s){return`const RING_WINDING_ORDER_CW: bool = ${s?"true":"false"}; + +${e_t()} + +struct Attributes { + @location(0) positions: vec2, + @location(1) vertexPositions: vec3, + @location(2) vertexPositions64Low: vec3, + @location(3) nextVertexPositions: vec3, + @location(4) nextVertexPositions64Low: vec3, + @location(5) vertexValid: f32, + @location(6) elevations: f32, + @location(7) fillColors: vec4, + @location(8) lineColors: vec4, + @location(9) rowIndexes: u32, +}; + +struct Varyings { + @builtin(position) position: vec4, + @location(0) vColor: vec4, + @location(1) pickingColor: vec3, + @location(2) clipCoordinates: vec2, +}; + +@vertex +fn vertexMain(attributes: Attributes) -> Varyings { + var outp: Varyings; + outp.position = vec4(0.0); + outp.vColor = vec4(0.0); + outp.pickingColor = picking_getPickingColorFromIndex(attributes.rowIndexes); + outp.clipCoordinates = vec2(0.0); + + if (attributes.vertexValid < 0.5) { + return outp; + } + + let pos = select(attributes.nextVertexPositions, attributes.vertexPositions, RING_WINDING_ORDER_CW); + let pos64Low = select( + attributes.nextVertexPositions64Low, + attributes.vertexPositions64Low, + RING_WINDING_ORDER_CW + ); + let nextPos = select(attributes.vertexPositions, attributes.nextVertexPositions, RING_WINDING_ORDER_CW); + let nextPos64Low = select( + attributes.vertexPositions64Low, + attributes.nextVertexPositions64Low, + RING_WINDING_ORDER_CW + ); + + let position = mix(pos, nextPos, attributes.positions.x); + let position64Low = mix(pos64Low, nextPos64Low, attributes.positions.x); + + var worldPosition = position; + if (solidPolygon.extruded > 0.5) { + worldPosition.z += attributes.elevations * attributes.positions.y * solidPolygon.elevationScale; + } + + geometry.worldPosition = position; + geometry.pickingColor = picking_getPickingColorFromIndex(attributes.rowIndexes); + + let projectedPosition = project_position_to_clipspace_and_commonspace( + worldPosition, + position64Low, + vec3(0.0) + ); + geometry.position = projectedPosition.commonPosition; + outp.position = projectedPosition.clipPosition; + + let normal = project_offset_normal(vec3( + pos.y - nextPos.y + (pos64Low.y - nextPos64Low.y), + nextPos.x - pos.x + (nextPos64Low.x - pos64Low.x), + 0.0 + )); + geometry.normal = normal; + + let colors = select( + attributes.fillColors, + attributes.lineColors, + solidPolygon.isWireframe > 0.5 + ); + outp.vColor = apply_polygon_color(colors, normal, geometry.position); + outp.pickingColor = geometry.pickingColor; + + outp.clipCoordinates = geometry.position.xy; + clip_filterPosition(&outp.position, geometry.worldPosition.xy); + + return outp; +} + +${t_t()} +`}function n_t(s,n){return s==="top"?ksn():Rsn(n)}var ife=[0,0,0,255],Isn={filled:!0,extruded:!1,wireframe:!1,_normalize:!0,_windingOrder:"CW",_full3d:!1,elevationScale:{type:"number",min:0,value:1},getPolygon:{type:"accessor",value:s=>s.polygon},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:ife},getLineColor:{type:"accessor",value:ife},material:!0},nfe={enter:(s,n)=>n.length?n.subarray(n.length-s.length):s},mW=class extends U3{getShaders(n){let r=!this.props._normalize&&this.props._windingOrder==="CCW"?0:1;return super.getShaders({vs:n==="top"?Kvt:Jvt,fs:Qvt,source:n_t(n,!!r),defines:{RING_WINDING_ORDER_CW:r},modules:[Zy,qy,ZD,Jy,Zvt,...this.context.device.type==="webgpu"?[DB]:[]]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){let{viewport:n}=this.context,{coordinateSystem:r}=this.props,{_full3d:c}=this.props;n.isGeospatial&&r==="default"&&(r="lnglat");let u;r==="lnglat"&&(c?u=n.projectPosition.bind(n):u=n.projectFlat.bind(n)),this.setState({numInstances:0,polygonTesselator:new gW({preproject:u,fp64:this.use64bitPositions(),IndexType:Uint32Array})});let d=this.getAttributeManager(),b=!0,w=this.context.device.type==="webgpu";d.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:b},vertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:nfe,accessor:"getPolygon",update:this.calculatePositions,noAlloc:b,...w?{}:{shaderAttributes:{nextVertexPositions:{vertexOffset:1}}}},...w?{nextVertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:!1,update:this.calculateNextPositions,noAlloc:b}}:{},[w?"vertexValid":"instanceVertexValid"]:{size:1,type:w?"float32":"uint16",stepMode:"instance",update:this.calculateVertexValid,noAlloc:b},elevations:{size:1,stepMode:"dynamic",transition:nfe,accessor:"getElevation",bufferGroup:"solid-polygon-instance-data"},fillColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:nfe,accessor:"getFillColor",defaultValue:ife,bufferGroup:"solid-polygon-instance-data"},lineColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:nfe,accessor:"getLineColor",defaultValue:ife,bufferGroup:"solid-polygon-instance-data"},rowIndexes:{size:1,type:"uint32",stepMode:"dynamic",accessor:(_,{index:x})=>_&&_.__source?_.__source.index:x,bufferGroup:"solid-polygon-instance-data"}})}getPickingInfo(n){let r=super.getPickingInfo(n),{index:c}=r,u=this.props.data;return u[0]&&u[0].__source&&(r.object=u.find(d=>d.__source.index===c)),r}disablePickingIndex(n){let r=this.props.data;if(r[0]&&r[0].__source)for(let c=0;cw.destroy()),this.setState(this._getModels()),d.invalidateAll())}updateGeometry({props:n,oldProps:r,changeFlags:c}){if(c.dataChanged||c.updateTriggersChanged&&(c.updateTriggersChanged.all||c.updateTriggersChanged.getPolygon)){let{polygonTesselator:d}=this.state,b=n.data.attributes||{};d.updateGeometry({data:n.data,normalize:n._normalize,geometryBuffer:b.getPolygon,buffers:this.context.device.type==="webgpu"?{...b}:b,getGeometry:n.getPolygon,positionFormat:n.positionFormat,wrapLongitude:n.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:c.dataChanged,full3d:n._full3d}),this.setState({numInstances:d.instanceCount,startIndices:d.vertexStarts}),c.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(){let{id:n,filled:r,extruded:c}=this.props,u,d,b;if(r){let w=this.getShaders("top");w.defines={...w.defines,NON_INSTANCED_MODEL:1};let _=this.getAttributeManager().getBufferLayouts({isInstanced:!1});this.context.device.type==="webgpu"&&(_=_.filter(x=>x.name!=="indices"&&x.name!=="vertexValid"&&x.name!=="instanceVertexValid"&&x.name!=="nextVertexPositions")),u=new $h(this.context.device,{...w,id:`${n}-top`,topology:"triangle-list",bufferLayout:_,isIndexed:!0,userData:{excludeAttributes:{vertexValid:!0,instanceVertexValid:!0,nextVertexPositions:!0}}})}if(c){let w=this.getAttributeManager().getBufferLayouts({isInstanced:!0});this.context.device.type==="webgpu"&&(w=w.filter(_=>_.name!=="indices")),d=new $h(this.context.device,{...this.getShaders("side"),id:`${n}-side`,bufferLayout:w,geometry:new Pb({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,1,1,0,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}}),b=new $h(this.context.device,{...this.getShaders("side"),id:`${n}-wireframe`,bufferLayout:w,geometry:new Pb({topology:"line-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,0,1,1,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}})}return{models:[d,b,u].filter(Boolean),topModel:u,sideModel:d,wireframeModel:b}}calculateIndices(n){let{polygonTesselator:r}=this.state;n.startIndices=r.indexStarts,n.value=r.get("indices")}calculatePositions(n){let{polygonTesselator:r}=this.state;n.startIndices=r.vertexStarts;let c=this.props.data.attributes?.getPolygon;if(this.context.device.type==="webgpu"&&ArrayBuffer.isView(c?.value)){let{value:u,size:d=3,offset:b=0,stride:w}=c,_=b/u.BYTES_PER_ELEMENT,x=w?w/u.BYTES_PER_ELEMENT:d,T=new Float64Array(r.instanceCount*3);for(let M=0;M2?u[L+2]:0}n.value=T;return}n.value=r.get("positions")}calculateVertexValid(n){let r=this.props.data.attributes?.instanceVertexValid?.value,c=this.context.device.type==="webgpu"&&r?r:this.state.polygonTesselator.get("vertexValid");n.value=this.context.device.type==="webgpu"&&c?Float32Array.from(c):c}calculateNextPositions(n){let{polygonTesselator:r}=this.state,c=this.getAttributeManager().getAttributes(),u=c.vertexPositions.value,d=this.props.data.attributes?.instanceVertexValid?.value||c.vertexValid?.value||r.get("vertexValid");if(n.startIndices=r.vertexStarts,!u){n.value=u;return}let b=u.length/3,w=new u.constructor(u.length);for(let _=0;_phe,BoxGeometry:()=>X4,Color:()=>zo,DirectionalLight:()=>dhe,DoubleSide:()=>Ev,EdgesGeometry:()=>uhe,GridHelper:()=>mhe,Group:()=>hT,InstancedMesh:()=>lhe,LineBasicMaterial:()=>pO,LineSegments:()=>zW,Matrix4:()=>Rl,Mesh:()=>Mm,MeshBasicMaterial:()=>hO,MeshPhongMaterial:()=>fhe,PerspectiveCamera:()=>dg,Quaternion:()=>h2,Raycaster:()=>ghe,Scene:()=>ahe,Vector2:()=>La,Vector3:()=>Gt,WebGLRenderer:()=>UW});var a5e="160";var ron=0,N_t=1,son=2;var g2t=1,oon=2,W3=3,mT=0,Tm=1,Ev=2;var dT=0,oO=1,F_t=2,U_t=3,z_t=4,aon=5,j4=100,con=101,lon=102,G_t=103,j_t=104,uon=200,fon=201,hon=202,don=203,x6e=204,E6e=205,pon=206,gon=207,mon=208,bon=209,won=210,von=211,_on=212,yon=213,xon=214,Eon=0,Son=1,Mon=2,jfe=3,Ton=4,Con=5,Aon=6,Pon=7,c5e=0,Lon=1,kon=2,pT=0,Ron=1,Ion=2,Don=3,Bon=4,Oon=5,Non=6;var m2t=300,lO=301,uO=302,S6e=303,M6e=304,bhe=306,T6e=1e3,Sv=1001,C6e=1002,hg=1003,$_t=1004;var $Ie=1005;var Db=1006,Fon=1007;var DW=1008;var gT=1009,Uon=1010,zon=1011,l5e=1012,b2t=1013,uT=1014,fT=1015,BW=1016,w2t=1017,v2t=1018,W4=1020,Gon=1021,Mv=1023,jon=1024,$on=1025,H4=1026,fO=1027,Von=1028,_2t=1029,Won=1030,y2t=1031,x2t=1033,VIe=33776,WIe=33777,HIe=33778,qIe=33779,V_t=35840,W_t=35841,H_t=35842,q_t=35843,E2t=36196,X_t=37492,Y_t=37496,Z_t=37808,K_t=37809,J_t=37810,Q_t=37811,eyt=37812,tyt=37813,nyt=37814,iyt=37815,ryt=37816,syt=37817,oyt=37818,ayt=37819,cyt=37820,lyt=37821,XIe=36492,uyt=36494,fyt=36495,Hon=36283,hyt=36284,dyt=36285,pyt=36286;var $fe=2300,Vfe=2301,YIe=2302,gyt=2400,myt=2401,byt=2402;var S2t=3e3,q4=3001,qon=3200,Xon=3201,M2t=0,Yon=1,Bb="",Md="srgb",X3="srgb-linear",u5e="display-p3",whe="display-p3-linear",Wfe="linear",hl="srgb",Hfe="rec709",qfe="p3";var GB=7680;var wyt=519,Zon=512,Kon=513,Jon=514,T2t=515,Qon=516,ean=517,tan=518,nan=519,vyt=35044;var _yt="300 es",A6e=1035,q3=2e3,Xfe=2001,bT=class{addEventListener(n,r){this._listeners===void 0&&(this._listeners={});let c=this._listeners;c[n]===void 0&&(c[n]=[]),c[n].indexOf(r)===-1&&c[n].push(r)}hasEventListener(n,r){if(this._listeners===void 0)return!1;let c=this._listeners;return c[n]!==void 0&&c[n].indexOf(r)!==-1}removeEventListener(n,r){if(this._listeners===void 0)return;let u=this._listeners[n];if(u!==void 0){let d=u.indexOf(r);d!==-1&&u.splice(d,1)}}dispatchEvent(n){if(this._listeners===void 0)return;let c=this._listeners[n.type];if(c!==void 0){n.target=this;let u=c.slice(0);for(let d=0,b=u.length;d>8&255]+pp[s>>16&255]+pp[s>>24&255]+"-"+pp[n&255]+pp[n>>8&255]+"-"+pp[n>>16&15|64]+pp[n>>24&255]+"-"+pp[r&63|128]+pp[r>>8&255]+"-"+pp[r>>16&255]+pp[r>>24&255]+pp[c&255]+pp[c>>8&255]+pp[c>>16&255]+pp[c>>24&255]).toLowerCase()}function Sm(s,n,r){return Math.max(n,Math.min(r,s))}function ian(s,n){return(s%n+n)%n}function ZIe(s,n,r){return(1-r)*s+r*n}function yyt(s){return(s&s-1)===0&&s!==0}function L6e(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function MW(s,n){switch(n.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function Em(s,n){switch(n.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}var La=class s{constructor(n=0,r=0){s.prototype.isVector2=!0,this.x=n,this.y=r}get width(){return this.x}set width(n){this.x=n}get height(){return this.y}set height(n){this.y=n}set(n,r){return this.x=n,this.y=r,this}setScalar(n){return this.x=n,this.y=n,this}setX(n){return this.x=n,this}setY(n){return this.y=n,this}setComponent(n,r){switch(n){case 0:this.x=r;break;case 1:this.y=r;break;default:throw new Error("index is out of range: "+n)}return this}getComponent(n){switch(n){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+n)}}clone(){return new this.constructor(this.x,this.y)}copy(n){return this.x=n.x,this.y=n.y,this}add(n){return this.x+=n.x,this.y+=n.y,this}addScalar(n){return this.x+=n,this.y+=n,this}addVectors(n,r){return this.x=n.x+r.x,this.y=n.y+r.y,this}addScaledVector(n,r){return this.x+=n.x*r,this.y+=n.y*r,this}sub(n){return this.x-=n.x,this.y-=n.y,this}subScalar(n){return this.x-=n,this.y-=n,this}subVectors(n,r){return this.x=n.x-r.x,this.y=n.y-r.y,this}multiply(n){return this.x*=n.x,this.y*=n.y,this}multiplyScalar(n){return this.x*=n,this.y*=n,this}divide(n){return this.x/=n.x,this.y/=n.y,this}divideScalar(n){return this.multiplyScalar(1/n)}applyMatrix3(n){let r=this.x,c=this.y,u=n.elements;return this.x=u[0]*r+u[3]*c+u[6],this.y=u[1]*r+u[4]*c+u[7],this}min(n){return this.x=Math.min(this.x,n.x),this.y=Math.min(this.y,n.y),this}max(n){return this.x=Math.max(this.x,n.x),this.y=Math.max(this.y,n.y),this}clamp(n,r){return this.x=Math.max(n.x,Math.min(r.x,this.x)),this.y=Math.max(n.y,Math.min(r.y,this.y)),this}clampScalar(n,r){return this.x=Math.max(n,Math.min(r,this.x)),this.y=Math.max(n,Math.min(r,this.y)),this}clampLength(n,r){let c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(n,Math.min(r,c)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(n){return this.x*n.x+this.y*n.y}cross(n){return this.x*n.y-this.y*n.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(n){let r=Math.sqrt(this.lengthSq()*n.lengthSq());if(r===0)return Math.PI/2;let c=this.dot(n)/r;return Math.acos(Sm(c,-1,1))}distanceTo(n){return Math.sqrt(this.distanceToSquared(n))}distanceToSquared(n){let r=this.x-n.x,c=this.y-n.y;return r*r+c*c}manhattanDistanceTo(n){return Math.abs(this.x-n.x)+Math.abs(this.y-n.y)}setLength(n){return this.normalize().multiplyScalar(n)}lerp(n,r){return this.x+=(n.x-this.x)*r,this.y+=(n.y-this.y)*r,this}lerpVectors(n,r,c){return this.x=n.x+(r.x-n.x)*c,this.y=n.y+(r.y-n.y)*c,this}equals(n){return n.x===this.x&&n.y===this.y}fromArray(n,r=0){return this.x=n[r],this.y=n[r+1],this}toArray(n=[],r=0){return n[r]=this.x,n[r+1]=this.y,n}fromBufferAttribute(n,r){return this.x=n.getX(r),this.y=n.getY(r),this}rotateAround(n,r){let c=Math.cos(r),u=Math.sin(r),d=this.x-n.x,b=this.y-n.y;return this.x=d*c-b*u+n.x,this.y=d*u+b*c+n.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},qo=class s{constructor(n,r,c,u,d,b,w,_,x){s.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],n!==void 0&&this.set(n,r,c,u,d,b,w,_,x)}set(n,r,c,u,d,b,w,_,x){let T=this.elements;return T[0]=n,T[1]=u,T[2]=w,T[3]=r,T[4]=d,T[5]=_,T[6]=c,T[7]=b,T[8]=x,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(n){let r=this.elements,c=n.elements;return r[0]=c[0],r[1]=c[1],r[2]=c[2],r[3]=c[3],r[4]=c[4],r[5]=c[5],r[6]=c[6],r[7]=c[7],r[8]=c[8],this}extractBasis(n,r,c){return n.setFromMatrix3Column(this,0),r.setFromMatrix3Column(this,1),c.setFromMatrix3Column(this,2),this}setFromMatrix4(n){let r=n.elements;return this.set(r[0],r[4],r[8],r[1],r[5],r[9],r[2],r[6],r[10]),this}multiply(n){return this.multiplyMatrices(this,n)}premultiply(n){return this.multiplyMatrices(n,this)}multiplyMatrices(n,r){let c=n.elements,u=r.elements,d=this.elements,b=c[0],w=c[3],_=c[6],x=c[1],T=c[4],M=c[7],L=c[2],I=c[5],D=c[8],F=u[0],O=u[3],z=u[6],Z=u[1],H=u[4],te=u[7],se=u[2],ne=u[5],ue=u[8];return d[0]=b*F+w*Z+_*se,d[3]=b*O+w*H+_*ne,d[6]=b*z+w*te+_*ue,d[1]=x*F+T*Z+M*se,d[4]=x*O+T*H+M*ne,d[7]=x*z+T*te+M*ue,d[2]=L*F+I*Z+D*se,d[5]=L*O+I*H+D*ne,d[8]=L*z+I*te+D*ue,this}multiplyScalar(n){let r=this.elements;return r[0]*=n,r[3]*=n,r[6]*=n,r[1]*=n,r[4]*=n,r[7]*=n,r[2]*=n,r[5]*=n,r[8]*=n,this}determinant(){let n=this.elements,r=n[0],c=n[1],u=n[2],d=n[3],b=n[4],w=n[5],_=n[6],x=n[7],T=n[8];return r*b*T-r*w*x-c*d*T+c*w*_+u*d*x-u*b*_}invert(){let n=this.elements,r=n[0],c=n[1],u=n[2],d=n[3],b=n[4],w=n[5],_=n[6],x=n[7],T=n[8],M=T*b-w*x,L=w*_-T*d,I=x*d-b*_,D=r*M+c*L+u*I;if(D===0)return this.set(0,0,0,0,0,0,0,0,0);let F=1/D;return n[0]=M*F,n[1]=(u*x-T*c)*F,n[2]=(w*c-u*b)*F,n[3]=L*F,n[4]=(T*r-u*_)*F,n[5]=(u*d-w*r)*F,n[6]=I*F,n[7]=(c*_-x*r)*F,n[8]=(b*r-c*d)*F,this}transpose(){let n,r=this.elements;return n=r[1],r[1]=r[3],r[3]=n,n=r[2],r[2]=r[6],r[6]=n,n=r[5],r[5]=r[7],r[7]=n,this}getNormalMatrix(n){return this.setFromMatrix4(n).invert().transpose()}transposeIntoArray(n){let r=this.elements;return n[0]=r[0],n[1]=r[3],n[2]=r[6],n[3]=r[1],n[4]=r[4],n[5]=r[7],n[6]=r[2],n[7]=r[5],n[8]=r[8],this}setUvTransform(n,r,c,u,d,b,w){let _=Math.cos(d),x=Math.sin(d);return this.set(c*_,c*x,-c*(_*b+x*w)+b+n,-u*x,u*_,-u*(-x*b+_*w)+w+r,0,0,1),this}scale(n,r){return this.premultiply(KIe.makeScale(n,r)),this}rotate(n){return this.premultiply(KIe.makeRotation(-n)),this}translate(n,r){return this.premultiply(KIe.makeTranslation(n,r)),this}makeTranslation(n,r){return n.isVector2?this.set(1,0,n.x,0,1,n.y,0,0,1):this.set(1,0,n,0,1,r,0,0,1),this}makeRotation(n){let r=Math.cos(n),c=Math.sin(n);return this.set(r,-c,0,c,r,0,0,0,1),this}makeScale(n,r){return this.set(n,0,0,0,r,0,0,0,1),this}equals(n){let r=this.elements,c=n.elements;for(let u=0;u<9;u++)if(r[u]!==c[u])return!1;return!0}fromArray(n,r=0){for(let c=0;c<9;c++)this.elements[c]=n[c+r];return this}toArray(n=[],r=0){let c=this.elements;return n[r]=c[0],n[r+1]=c[1],n[r+2]=c[2],n[r+3]=c[3],n[r+4]=c[4],n[r+5]=c[5],n[r+6]=c[6],n[r+7]=c[7],n[r+8]=c[8],n}clone(){return new this.constructor().fromArray(this.elements)}},KIe=new qo;function C2t(s){for(let n=s.length-1;n>=0;--n)if(s[n]>=65535)return!0;return!1}function Yfe(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function ran(){let s=Yfe("canvas");return s.style.display="block",s}var xyt={};function RW(s){s in xyt||(xyt[s]=!0,console.warn(s))}var Eyt=new qo().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Syt=new qo().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),dfe={[X3]:{transfer:Wfe,primaries:Hfe,toReference:s=>s,fromReference:s=>s},[Md]:{transfer:hl,primaries:Hfe,toReference:s=>s.convertSRGBToLinear(),fromReference:s=>s.convertLinearToSRGB()},[whe]:{transfer:Wfe,primaries:qfe,toReference:s=>s.applyMatrix3(Syt),fromReference:s=>s.applyMatrix3(Eyt)},[u5e]:{transfer:hl,primaries:qfe,toReference:s=>s.convertSRGBToLinear().applyMatrix3(Syt),fromReference:s=>s.applyMatrix3(Eyt).convertLinearToSRGB()}},san=new Set([X3,whe]),Ac={enabled:!0,_workingColorSpace:X3,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(s){if(!san.has(s))throw new Error(`Unsupported working color space, "${s}".`);this._workingColorSpace=s},convert:function(s,n,r){if(this.enabled===!1||n===r||!n||!r)return s;let c=dfe[n].toReference,u=dfe[r].fromReference;return u(c(s))},fromWorkingColorSpace:function(s,n){return this.convert(s,this._workingColorSpace,n)},toWorkingColorSpace:function(s,n){return this.convert(s,n,this._workingColorSpace)},getPrimaries:function(s){return dfe[s].primaries},getTransfer:function(s){return s===Bb?Wfe:dfe[s].transfer}};function aO(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function JIe(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}var jB,Zfe=class{static getDataURL(n){if(/^data:/i.test(n.src)||typeof HTMLCanvasElement>"u")return n.src;let r;if(n instanceof HTMLCanvasElement)r=n;else{jB===void 0&&(jB=Yfe("canvas")),jB.width=n.width,jB.height=n.height;let c=jB.getContext("2d");n instanceof ImageData?c.putImageData(n,0,0):c.drawImage(n,0,0,n.width,n.height),r=jB}return r.width>2048||r.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",n),r.toDataURL("image/jpeg",.6)):r.toDataURL("image/png")}static sRGBToLinear(n){if(typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap){let r=Yfe("canvas");r.width=n.width,r.height=n.height;let c=r.getContext("2d");c.drawImage(n,0,0,n.width,n.height);let u=c.getImageData(0,0,n.width,n.height),d=u.data;for(let b=0;b0&&(c.userData=this.userData),r||(n.textures[this.uuid]=c),c}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(n){if(this.mapping!==m2t)return n;if(n.applyMatrix3(this.matrix),n.x<0||n.x>1)switch(this.wrapS){case T6e:n.x=n.x-Math.floor(n.x);break;case Sv:n.x=n.x<0?0:1;break;case C6e:Math.abs(Math.floor(n.x)%2)===1?n.x=Math.ceil(n.x)-n.x:n.x=n.x-Math.floor(n.x);break}if(n.y<0||n.y>1)switch(this.wrapT){case T6e:n.y=n.y-Math.floor(n.y);break;case Sv:n.y=n.y<0?0:1;break;case C6e:Math.abs(Math.floor(n.y)%2)===1?n.y=Math.ceil(n.y)-n.y:n.y=n.y-Math.floor(n.y);break}return this.flipY&&(n.y=1-n.y),n}set needsUpdate(n){n===!0&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return RW("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Md?q4:S2t}set encoding(n){RW("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=n===q4?Md:Bb}};Tv.DEFAULT_IMAGE=null;Tv.DEFAULT_MAPPING=m2t;Tv.DEFAULT_ANISOTROPY=1;var Hh=class s{constructor(n=0,r=0,c=0,u=1){s.prototype.isVector4=!0,this.x=n,this.y=r,this.z=c,this.w=u}get width(){return this.z}set width(n){this.z=n}get height(){return this.w}set height(n){this.w=n}set(n,r,c,u){return this.x=n,this.y=r,this.z=c,this.w=u,this}setScalar(n){return this.x=n,this.y=n,this.z=n,this.w=n,this}setX(n){return this.x=n,this}setY(n){return this.y=n,this}setZ(n){return this.z=n,this}setW(n){return this.w=n,this}setComponent(n,r){switch(n){case 0:this.x=r;break;case 1:this.y=r;break;case 2:this.z=r;break;case 3:this.w=r;break;default:throw new Error("index is out of range: "+n)}return this}getComponent(n){switch(n){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+n)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(n){return this.x=n.x,this.y=n.y,this.z=n.z,this.w=n.w!==void 0?n.w:1,this}add(n){return this.x+=n.x,this.y+=n.y,this.z+=n.z,this.w+=n.w,this}addScalar(n){return this.x+=n,this.y+=n,this.z+=n,this.w+=n,this}addVectors(n,r){return this.x=n.x+r.x,this.y=n.y+r.y,this.z=n.z+r.z,this.w=n.w+r.w,this}addScaledVector(n,r){return this.x+=n.x*r,this.y+=n.y*r,this.z+=n.z*r,this.w+=n.w*r,this}sub(n){return this.x-=n.x,this.y-=n.y,this.z-=n.z,this.w-=n.w,this}subScalar(n){return this.x-=n,this.y-=n,this.z-=n,this.w-=n,this}subVectors(n,r){return this.x=n.x-r.x,this.y=n.y-r.y,this.z=n.z-r.z,this.w=n.w-r.w,this}multiply(n){return this.x*=n.x,this.y*=n.y,this.z*=n.z,this.w*=n.w,this}multiplyScalar(n){return this.x*=n,this.y*=n,this.z*=n,this.w*=n,this}applyMatrix4(n){let r=this.x,c=this.y,u=this.z,d=this.w,b=n.elements;return this.x=b[0]*r+b[4]*c+b[8]*u+b[12]*d,this.y=b[1]*r+b[5]*c+b[9]*u+b[13]*d,this.z=b[2]*r+b[6]*c+b[10]*u+b[14]*d,this.w=b[3]*r+b[7]*c+b[11]*u+b[15]*d,this}divideScalar(n){return this.multiplyScalar(1/n)}setAxisAngleFromQuaternion(n){this.w=2*Math.acos(n.w);let r=Math.sqrt(1-n.w*n.w);return r<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=n.x/r,this.y=n.y/r,this.z=n.z/r),this}setAxisAngleFromRotationMatrix(n){let r,c,u,d,_=n.elements,x=_[0],T=_[4],M=_[8],L=_[1],I=_[5],D=_[9],F=_[2],O=_[6],z=_[10];if(Math.abs(T-L)<.01&&Math.abs(M-F)<.01&&Math.abs(D-O)<.01){if(Math.abs(T+L)<.1&&Math.abs(M+F)<.1&&Math.abs(D+O)<.1&&Math.abs(x+I+z-3)<.1)return this.set(1,0,0,0),this;r=Math.PI;let H=(x+1)/2,te=(I+1)/2,se=(z+1)/2,ne=(T+L)/4,ue=(M+F)/4,Ce=(D+O)/4;return H>te&&H>se?H<.01?(c=0,u=.707106781,d=.707106781):(c=Math.sqrt(H),u=ne/c,d=ue/c):te>se?te<.01?(c=.707106781,u=0,d=.707106781):(u=Math.sqrt(te),c=ne/u,d=Ce/u):se<.01?(c=.707106781,u=.707106781,d=0):(d=Math.sqrt(se),c=ue/d,u=Ce/d),this.set(c,u,d,r),this}let Z=Math.sqrt((O-D)*(O-D)+(M-F)*(M-F)+(L-T)*(L-T));return Math.abs(Z)<.001&&(Z=1),this.x=(O-D)/Z,this.y=(M-F)/Z,this.z=(L-T)/Z,this.w=Math.acos((x+I+z-1)/2),this}min(n){return this.x=Math.min(this.x,n.x),this.y=Math.min(this.y,n.y),this.z=Math.min(this.z,n.z),this.w=Math.min(this.w,n.w),this}max(n){return this.x=Math.max(this.x,n.x),this.y=Math.max(this.y,n.y),this.z=Math.max(this.z,n.z),this.w=Math.max(this.w,n.w),this}clamp(n,r){return this.x=Math.max(n.x,Math.min(r.x,this.x)),this.y=Math.max(n.y,Math.min(r.y,this.y)),this.z=Math.max(n.z,Math.min(r.z,this.z)),this.w=Math.max(n.w,Math.min(r.w,this.w)),this}clampScalar(n,r){return this.x=Math.max(n,Math.min(r,this.x)),this.y=Math.max(n,Math.min(r,this.y)),this.z=Math.max(n,Math.min(r,this.z)),this.w=Math.max(n,Math.min(r,this.w)),this}clampLength(n,r){let c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(n,Math.min(r,c)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(n){return this.x*n.x+this.y*n.y+this.z*n.z+this.w*n.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(n){return this.normalize().multiplyScalar(n)}lerp(n,r){return this.x+=(n.x-this.x)*r,this.y+=(n.y-this.y)*r,this.z+=(n.z-this.z)*r,this.w+=(n.w-this.w)*r,this}lerpVectors(n,r,c){return this.x=n.x+(r.x-n.x)*c,this.y=n.y+(r.y-n.y)*c,this.z=n.z+(r.z-n.z)*c,this.w=n.w+(r.w-n.w)*c,this}equals(n){return n.x===this.x&&n.y===this.y&&n.z===this.z&&n.w===this.w}fromArray(n,r=0){return this.x=n[r],this.y=n[r+1],this.z=n[r+2],this.w=n[r+3],this}toArray(n=[],r=0){return n[r]=this.x,n[r+1]=this.y,n[r+2]=this.z,n[r+3]=this.w,n}fromBufferAttribute(n,r){return this.x=n.getX(r),this.y=n.getY(r),this.z=n.getZ(r),this.w=n.getW(r),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},k6e=class extends bT{constructor(n=1,r=1,c={}){super(),this.isRenderTarget=!0,this.width=n,this.height=r,this.depth=1,this.scissor=new Hh(0,0,n,r),this.scissorTest=!1,this.viewport=new Hh(0,0,n,r);let u={width:n,height:r,depth:1};c.encoding!==void 0&&(RW("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),c.colorSpace=c.encoding===q4?Md:Bb),c=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Db,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},c),this.texture=new Tv(u,c.mapping,c.wrapS,c.wrapT,c.magFilter,c.minFilter,c.format,c.type,c.anisotropy,c.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=c.generateMipmaps,this.texture.internalFormat=c.internalFormat,this.depthBuffer=c.depthBuffer,this.stencilBuffer=c.stencilBuffer,this.depthTexture=c.depthTexture,this.samples=c.samples}setSize(n,r,c=1){(this.width!==n||this.height!==r||this.depth!==c)&&(this.width=n,this.height=r,this.depth=c,this.texture.image.width=n,this.texture.image.height=r,this.texture.image.depth=c,this.dispose()),this.viewport.set(0,0,n,r),this.scissor.set(0,0,n,r)}clone(){return new this.constructor().copy(this)}copy(n){this.width=n.width,this.height=n.height,this.depth=n.depth,this.scissor.copy(n.scissor),this.scissorTest=n.scissorTest,this.viewport.copy(n.viewport),this.texture=n.texture.clone(),this.texture.isRenderTargetTexture=!0;let r=Object.assign({},n.texture.image);return this.texture.source=new Kfe(r),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,n.depthTexture!==null&&(this.depthTexture=n.depthTexture.clone()),this.samples=n.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},Y3=class extends k6e{constructor(n=1,r=1,c={}){super(n,r,c),this.isWebGLRenderTarget=!0}},Jfe=class extends Tv{constructor(n=null,r=1,c=1,u=1){super(null),this.isDataArrayTexture=!0,this.image={data:n,width:r,height:c,depth:u},this.magFilter=hg,this.minFilter=hg,this.wrapR=Sv,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var R6e=class extends Tv{constructor(n=null,r=1,c=1,u=1){super(null),this.isData3DTexture=!0,this.image={data:n,width:r,height:c,depth:u},this.magFilter=hg,this.minFilter=hg,this.wrapR=Sv,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var h2=class{constructor(n=0,r=0,c=0,u=1){this.isQuaternion=!0,this._x=n,this._y=r,this._z=c,this._w=u}static slerpFlat(n,r,c,u,d,b,w){let _=c[u+0],x=c[u+1],T=c[u+2],M=c[u+3],L=d[b+0],I=d[b+1],D=d[b+2],F=d[b+3];if(w===0){n[r+0]=_,n[r+1]=x,n[r+2]=T,n[r+3]=M;return}if(w===1){n[r+0]=L,n[r+1]=I,n[r+2]=D,n[r+3]=F;return}if(M!==F||_!==L||x!==I||T!==D){let O=1-w,z=_*L+x*I+T*D+M*F,Z=z>=0?1:-1,H=1-z*z;if(H>Number.EPSILON){let se=Math.sqrt(H),ne=Math.atan2(se,z*Z);O=Math.sin(O*ne)/se,w=Math.sin(w*ne)/se}let te=w*Z;if(_=_*O+L*te,x=x*O+I*te,T=T*O+D*te,M=M*O+F*te,O===1-w){let se=1/Math.sqrt(_*_+x*x+T*T+M*M);_*=se,x*=se,T*=se,M*=se}}n[r]=_,n[r+1]=x,n[r+2]=T,n[r+3]=M}static multiplyQuaternionsFlat(n,r,c,u,d,b){let w=c[u],_=c[u+1],x=c[u+2],T=c[u+3],M=d[b],L=d[b+1],I=d[b+2],D=d[b+3];return n[r]=w*D+T*M+_*I-x*L,n[r+1]=_*D+T*L+x*M-w*I,n[r+2]=x*D+T*I+w*L-_*M,n[r+3]=T*D-w*M-_*L-x*I,n}get x(){return this._x}set x(n){this._x=n,this._onChangeCallback()}get y(){return this._y}set y(n){this._y=n,this._onChangeCallback()}get z(){return this._z}set z(n){this._z=n,this._onChangeCallback()}get w(){return this._w}set w(n){this._w=n,this._onChangeCallback()}set(n,r,c,u){return this._x=n,this._y=r,this._z=c,this._w=u,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(n){return this._x=n.x,this._y=n.y,this._z=n.z,this._w=n.w,this._onChangeCallback(),this}setFromEuler(n,r=!0){let c=n._x,u=n._y,d=n._z,b=n._order,w=Math.cos,_=Math.sin,x=w(c/2),T=w(u/2),M=w(d/2),L=_(c/2),I=_(u/2),D=_(d/2);switch(b){case"XYZ":this._x=L*T*M+x*I*D,this._y=x*I*M-L*T*D,this._z=x*T*D+L*I*M,this._w=x*T*M-L*I*D;break;case"YXZ":this._x=L*T*M+x*I*D,this._y=x*I*M-L*T*D,this._z=x*T*D-L*I*M,this._w=x*T*M+L*I*D;break;case"ZXY":this._x=L*T*M-x*I*D,this._y=x*I*M+L*T*D,this._z=x*T*D+L*I*M,this._w=x*T*M-L*I*D;break;case"ZYX":this._x=L*T*M-x*I*D,this._y=x*I*M+L*T*D,this._z=x*T*D-L*I*M,this._w=x*T*M+L*I*D;break;case"YZX":this._x=L*T*M+x*I*D,this._y=x*I*M+L*T*D,this._z=x*T*D-L*I*M,this._w=x*T*M-L*I*D;break;case"XZY":this._x=L*T*M-x*I*D,this._y=x*I*M-L*T*D,this._z=x*T*D+L*I*M,this._w=x*T*M+L*I*D;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+b)}return r===!0&&this._onChangeCallback(),this}setFromAxisAngle(n,r){let c=r/2,u=Math.sin(c);return this._x=n.x*u,this._y=n.y*u,this._z=n.z*u,this._w=Math.cos(c),this._onChangeCallback(),this}setFromRotationMatrix(n){let r=n.elements,c=r[0],u=r[4],d=r[8],b=r[1],w=r[5],_=r[9],x=r[2],T=r[6],M=r[10],L=c+w+M;if(L>0){let I=.5/Math.sqrt(L+1);this._w=.25/I,this._x=(T-_)*I,this._y=(d-x)*I,this._z=(b-u)*I}else if(c>w&&c>M){let I=2*Math.sqrt(1+c-w-M);this._w=(T-_)/I,this._x=.25*I,this._y=(u+b)/I,this._z=(d+x)/I}else if(w>M){let I=2*Math.sqrt(1+w-c-M);this._w=(d-x)/I,this._x=(u+b)/I,this._y=.25*I,this._z=(_+T)/I}else{let I=2*Math.sqrt(1+M-c-w);this._w=(b-u)/I,this._x=(d+x)/I,this._y=(_+T)/I,this._z=.25*I}return this._onChangeCallback(),this}setFromUnitVectors(n,r){let c=n.dot(r)+1;return cMath.abs(n.z)?(this._x=-n.y,this._y=n.x,this._z=0,this._w=c):(this._x=0,this._y=-n.z,this._z=n.y,this._w=c)):(this._x=n.y*r.z-n.z*r.y,this._y=n.z*r.x-n.x*r.z,this._z=n.x*r.y-n.y*r.x,this._w=c),this.normalize()}angleTo(n){return 2*Math.acos(Math.abs(Sm(this.dot(n),-1,1)))}rotateTowards(n,r){let c=this.angleTo(n);if(c===0)return this;let u=Math.min(1,r/c);return this.slerp(n,u),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(n){return this._x*n._x+this._y*n._y+this._z*n._z+this._w*n._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let n=this.length();return n===0?(this._x=0,this._y=0,this._z=0,this._w=1):(n=1/n,this._x=this._x*n,this._y=this._y*n,this._z=this._z*n,this._w=this._w*n),this._onChangeCallback(),this}multiply(n){return this.multiplyQuaternions(this,n)}premultiply(n){return this.multiplyQuaternions(n,this)}multiplyQuaternions(n,r){let c=n._x,u=n._y,d=n._z,b=n._w,w=r._x,_=r._y,x=r._z,T=r._w;return this._x=c*T+b*w+u*x-d*_,this._y=u*T+b*_+d*w-c*x,this._z=d*T+b*x+c*_-u*w,this._w=b*T-c*w-u*_-d*x,this._onChangeCallback(),this}slerp(n,r){if(r===0)return this;if(r===1)return this.copy(n);let c=this._x,u=this._y,d=this._z,b=this._w,w=b*n._w+c*n._x+u*n._y+d*n._z;if(w<0?(this._w=-n._w,this._x=-n._x,this._y=-n._y,this._z=-n._z,w=-w):this.copy(n),w>=1)return this._w=b,this._x=c,this._y=u,this._z=d,this;let _=1-w*w;if(_<=Number.EPSILON){let I=1-r;return this._w=I*b+r*this._w,this._x=I*c+r*this._x,this._y=I*u+r*this._y,this._z=I*d+r*this._z,this.normalize(),this}let x=Math.sqrt(_),T=Math.atan2(x,w),M=Math.sin((1-r)*T)/x,L=Math.sin(r*T)/x;return this._w=b*M+this._w*L,this._x=c*M+this._x*L,this._y=u*M+this._y*L,this._z=d*M+this._z*L,this._onChangeCallback(),this}slerpQuaternions(n,r,c){return this.copy(n).slerp(r,c)}random(){let n=Math.random(),r=Math.sqrt(1-n),c=Math.sqrt(n),u=2*Math.PI*Math.random(),d=2*Math.PI*Math.random();return this.set(r*Math.cos(u),c*Math.sin(d),c*Math.cos(d),r*Math.sin(u))}equals(n){return n._x===this._x&&n._y===this._y&&n._z===this._z&&n._w===this._w}fromArray(n,r=0){return this._x=n[r],this._y=n[r+1],this._z=n[r+2],this._w=n[r+3],this._onChangeCallback(),this}toArray(n=[],r=0){return n[r]=this._x,n[r+1]=this._y,n[r+2]=this._z,n[r+3]=this._w,n}fromBufferAttribute(n,r){return this._x=n.getX(r),this._y=n.getY(r),this._z=n.getZ(r),this._w=n.getW(r),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(n){return this._onChangeCallback=n,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},Gt=class s{constructor(n=0,r=0,c=0){s.prototype.isVector3=!0,this.x=n,this.y=r,this.z=c}set(n,r,c){return c===void 0&&(c=this.z),this.x=n,this.y=r,this.z=c,this}setScalar(n){return this.x=n,this.y=n,this.z=n,this}setX(n){return this.x=n,this}setY(n){return this.y=n,this}setZ(n){return this.z=n,this}setComponent(n,r){switch(n){case 0:this.x=r;break;case 1:this.y=r;break;case 2:this.z=r;break;default:throw new Error("index is out of range: "+n)}return this}getComponent(n){switch(n){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+n)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(n){return this.x=n.x,this.y=n.y,this.z=n.z,this}add(n){return this.x+=n.x,this.y+=n.y,this.z+=n.z,this}addScalar(n){return this.x+=n,this.y+=n,this.z+=n,this}addVectors(n,r){return this.x=n.x+r.x,this.y=n.y+r.y,this.z=n.z+r.z,this}addScaledVector(n,r){return this.x+=n.x*r,this.y+=n.y*r,this.z+=n.z*r,this}sub(n){return this.x-=n.x,this.y-=n.y,this.z-=n.z,this}subScalar(n){return this.x-=n,this.y-=n,this.z-=n,this}subVectors(n,r){return this.x=n.x-r.x,this.y=n.y-r.y,this.z=n.z-r.z,this}multiply(n){return this.x*=n.x,this.y*=n.y,this.z*=n.z,this}multiplyScalar(n){return this.x*=n,this.y*=n,this.z*=n,this}multiplyVectors(n,r){return this.x=n.x*r.x,this.y=n.y*r.y,this.z=n.z*r.z,this}applyEuler(n){return this.applyQuaternion(Myt.setFromEuler(n))}applyAxisAngle(n,r){return this.applyQuaternion(Myt.setFromAxisAngle(n,r))}applyMatrix3(n){let r=this.x,c=this.y,u=this.z,d=n.elements;return this.x=d[0]*r+d[3]*c+d[6]*u,this.y=d[1]*r+d[4]*c+d[7]*u,this.z=d[2]*r+d[5]*c+d[8]*u,this}applyNormalMatrix(n){return this.applyMatrix3(n).normalize()}applyMatrix4(n){let r=this.x,c=this.y,u=this.z,d=n.elements,b=1/(d[3]*r+d[7]*c+d[11]*u+d[15]);return this.x=(d[0]*r+d[4]*c+d[8]*u+d[12])*b,this.y=(d[1]*r+d[5]*c+d[9]*u+d[13])*b,this.z=(d[2]*r+d[6]*c+d[10]*u+d[14])*b,this}applyQuaternion(n){let r=this.x,c=this.y,u=this.z,d=n.x,b=n.y,w=n.z,_=n.w,x=2*(b*u-w*c),T=2*(w*r-d*u),M=2*(d*c-b*r);return this.x=r+_*x+b*M-w*T,this.y=c+_*T+w*x-d*M,this.z=u+_*M+d*T-b*x,this}project(n){return this.applyMatrix4(n.matrixWorldInverse).applyMatrix4(n.projectionMatrix)}unproject(n){return this.applyMatrix4(n.projectionMatrixInverse).applyMatrix4(n.matrixWorld)}transformDirection(n){let r=this.x,c=this.y,u=this.z,d=n.elements;return this.x=d[0]*r+d[4]*c+d[8]*u,this.y=d[1]*r+d[5]*c+d[9]*u,this.z=d[2]*r+d[6]*c+d[10]*u,this.normalize()}divide(n){return this.x/=n.x,this.y/=n.y,this.z/=n.z,this}divideScalar(n){return this.multiplyScalar(1/n)}min(n){return this.x=Math.min(this.x,n.x),this.y=Math.min(this.y,n.y),this.z=Math.min(this.z,n.z),this}max(n){return this.x=Math.max(this.x,n.x),this.y=Math.max(this.y,n.y),this.z=Math.max(this.z,n.z),this}clamp(n,r){return this.x=Math.max(n.x,Math.min(r.x,this.x)),this.y=Math.max(n.y,Math.min(r.y,this.y)),this.z=Math.max(n.z,Math.min(r.z,this.z)),this}clampScalar(n,r){return this.x=Math.max(n,Math.min(r,this.x)),this.y=Math.max(n,Math.min(r,this.y)),this.z=Math.max(n,Math.min(r,this.z)),this}clampLength(n,r){let c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(n,Math.min(r,c)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(n){return this.x*n.x+this.y*n.y+this.z*n.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(n){return this.normalize().multiplyScalar(n)}lerp(n,r){return this.x+=(n.x-this.x)*r,this.y+=(n.y-this.y)*r,this.z+=(n.z-this.z)*r,this}lerpVectors(n,r,c){return this.x=n.x+(r.x-n.x)*c,this.y=n.y+(r.y-n.y)*c,this.z=n.z+(r.z-n.z)*c,this}cross(n){return this.crossVectors(this,n)}crossVectors(n,r){let c=n.x,u=n.y,d=n.z,b=r.x,w=r.y,_=r.z;return this.x=u*_-d*w,this.y=d*b-c*_,this.z=c*w-u*b,this}projectOnVector(n){let r=n.lengthSq();if(r===0)return this.set(0,0,0);let c=n.dot(this)/r;return this.copy(n).multiplyScalar(c)}projectOnPlane(n){return e6e.copy(this).projectOnVector(n),this.sub(e6e)}reflect(n){return this.sub(e6e.copy(n).multiplyScalar(2*this.dot(n)))}angleTo(n){let r=Math.sqrt(this.lengthSq()*n.lengthSq());if(r===0)return Math.PI/2;let c=this.dot(n)/r;return Math.acos(Sm(c,-1,1))}distanceTo(n){return Math.sqrt(this.distanceToSquared(n))}distanceToSquared(n){let r=this.x-n.x,c=this.y-n.y,u=this.z-n.z;return r*r+c*c+u*u}manhattanDistanceTo(n){return Math.abs(this.x-n.x)+Math.abs(this.y-n.y)+Math.abs(this.z-n.z)}setFromSpherical(n){return this.setFromSphericalCoords(n.radius,n.phi,n.theta)}setFromSphericalCoords(n,r,c){let u=Math.sin(r)*n;return this.x=u*Math.sin(c),this.y=Math.cos(r)*n,this.z=u*Math.cos(c),this}setFromCylindrical(n){return this.setFromCylindricalCoords(n.radius,n.theta,n.y)}setFromCylindricalCoords(n,r,c){return this.x=n*Math.sin(r),this.y=c,this.z=n*Math.cos(r),this}setFromMatrixPosition(n){let r=n.elements;return this.x=r[12],this.y=r[13],this.z=r[14],this}setFromMatrixScale(n){let r=this.setFromMatrixColumn(n,0).length(),c=this.setFromMatrixColumn(n,1).length(),u=this.setFromMatrixColumn(n,2).length();return this.x=r,this.y=c,this.z=u,this}setFromMatrixColumn(n,r){return this.fromArray(n.elements,r*4)}setFromMatrix3Column(n,r){return this.fromArray(n.elements,r*3)}setFromEuler(n){return this.x=n._x,this.y=n._y,this.z=n._z,this}setFromColor(n){return this.x=n.r,this.y=n.g,this.z=n.b,this}equals(n){return n.x===this.x&&n.y===this.y&&n.z===this.z}fromArray(n,r=0){return this.x=n[r],this.y=n[r+1],this.z=n[r+2],this}toArray(n=[],r=0){return n[r]=this.x,n[r+1]=this.y,n[r+2]=this.z,n}fromBufferAttribute(n,r){return this.x=n.getX(r),this.y=n.getY(r),this.z=n.getZ(r),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let n=(Math.random()-.5)*2,r=Math.random()*Math.PI*2,c=Math.sqrt(1-n**2);return this.x=c*Math.cos(r),this.y=c*Math.sin(r),this.z=n,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},e6e=new Gt,Myt=new h2,Z3=class{constructor(n=new Gt(1/0,1/0,1/0),r=new Gt(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=n,this.max=r}set(n,r){return this.min.copy(n),this.max.copy(r),this}setFromArray(n){this.makeEmpty();for(let r=0,c=n.length;rthis.max.x||n.ythis.max.y||n.zthis.max.z)}containsBox(n){return this.min.x<=n.min.x&&n.max.x<=this.max.x&&this.min.y<=n.min.y&&n.max.y<=this.max.y&&this.min.z<=n.min.z&&n.max.z<=this.max.z}getParameter(n,r){return r.set((n.x-this.min.x)/(this.max.x-this.min.x),(n.y-this.min.y)/(this.max.y-this.min.y),(n.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(n){return!(n.max.xthis.max.x||n.max.ythis.max.y||n.max.zthis.max.z)}intersectsSphere(n){return this.clampPoint(n.center,_v),_v.distanceToSquared(n.center)<=n.radius*n.radius}intersectsPlane(n){let r,c;return n.normal.x>0?(r=n.normal.x*this.min.x,c=n.normal.x*this.max.x):(r=n.normal.x*this.max.x,c=n.normal.x*this.min.x),n.normal.y>0?(r+=n.normal.y*this.min.y,c+=n.normal.y*this.max.y):(r+=n.normal.y*this.max.y,c+=n.normal.y*this.min.y),n.normal.z>0?(r+=n.normal.z*this.min.z,c+=n.normal.z*this.max.z):(r+=n.normal.z*this.max.z,c+=n.normal.z*this.min.z),r<=-n.constant&&c>=-n.constant}intersectsTriangle(n){if(this.isEmpty())return!1;this.getCenter(TW),gfe.subVectors(this.max,TW),$B.subVectors(n.a,TW),VB.subVectors(n.b,TW),WB.subVectors(n.c,TW),sT.subVectors(VB,$B),oT.subVectors(WB,VB),N4.subVectors($B,WB);let r=[0,-sT.z,sT.y,0,-oT.z,oT.y,0,-N4.z,N4.y,sT.z,0,-sT.x,oT.z,0,-oT.x,N4.z,0,-N4.x,-sT.y,sT.x,0,-oT.y,oT.x,0,-N4.y,N4.x,0];return!t6e(r,$B,VB,WB,gfe)||(r=[1,0,0,0,1,0,0,0,1],!t6e(r,$B,VB,WB,gfe))?!1:(mfe.crossVectors(sT,oT),r=[mfe.x,mfe.y,mfe.z],t6e(r,$B,VB,WB,gfe))}clampPoint(n,r){return r.copy(n).clamp(this.min,this.max)}distanceToPoint(n){return this.clampPoint(n,_v).distanceTo(n)}getBoundingSphere(n){return this.isEmpty()?n.makeEmpty():(this.getCenter(n.center),n.radius=this.getSize(_v).length()*.5),n}intersect(n){return this.min.max(n.min),this.max.min(n.max),this.isEmpty()&&this.makeEmpty(),this}union(n){return this.min.min(n.min),this.max.max(n.max),this}applyMatrix4(n){return this.isEmpty()?this:(z3[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(n),z3[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(n),z3[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(n),z3[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(n),z3[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(n),z3[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(n),z3[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(n),z3[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(n),this.setFromPoints(z3),this)}translate(n){return this.min.add(n),this.max.add(n),this}equals(n){return n.min.equals(this.min)&&n.max.equals(this.max)}},z3=[new Gt,new Gt,new Gt,new Gt,new Gt,new Gt,new Gt,new Gt],_v=new Gt,pfe=new Z3,$B=new Gt,VB=new Gt,WB=new Gt,sT=new Gt,oT=new Gt,N4=new Gt,TW=new Gt,gfe=new Gt,mfe=new Gt,F4=new Gt;function t6e(s,n,r,c,u){for(let d=0,b=s.length-3;d<=b;d+=3){F4.fromArray(s,d);let w=u.x*Math.abs(F4.x)+u.y*Math.abs(F4.y)+u.z*Math.abs(F4.z),_=n.dot(F4),x=r.dot(F4),T=c.dot(F4);if(Math.max(-Math.max(_,x,T),Math.min(_,x,T))>w)return!1}return!0}var can=new Z3,CW=new Gt,n6e=new Gt,wT=class{constructor(n=new Gt,r=-1){this.isSphere=!0,this.center=n,this.radius=r}set(n,r){return this.center.copy(n),this.radius=r,this}setFromPoints(n,r){let c=this.center;r!==void 0?c.copy(r):can.setFromPoints(n).getCenter(c);let u=0;for(let d=0,b=n.length;dthis.radius*this.radius&&(r.sub(this.center).normalize(),r.multiplyScalar(this.radius).add(this.center)),r}getBoundingBox(n){return this.isEmpty()?(n.makeEmpty(),n):(n.set(this.center,this.center),n.expandByScalar(this.radius),n)}applyMatrix4(n){return this.center.applyMatrix4(n),this.radius=this.radius*n.getMaxScaleOnAxis(),this}translate(n){return this.center.add(n),this}expandByPoint(n){if(this.isEmpty())return this.center.copy(n),this.radius=0,this;CW.subVectors(n,this.center);let r=CW.lengthSq();if(r>this.radius*this.radius){let c=Math.sqrt(r),u=(c-this.radius)*.5;this.center.addScaledVector(CW,u/c),this.radius+=u}return this}union(n){return n.isEmpty()?this:this.isEmpty()?(this.copy(n),this):(this.center.equals(n.center)===!0?this.radius=Math.max(this.radius,n.radius):(n6e.subVectors(n.center,this.center).setLength(n.radius),this.expandByPoint(CW.copy(n.center).add(n6e)),this.expandByPoint(CW.copy(n.center).sub(n6e))),this)}equals(n){return n.center.equals(this.center)&&n.radius===this.radius}clone(){return new this.constructor().copy(this)}},G3=new Gt,i6e=new Gt,bfe=new Gt,aT=new Gt,r6e=new Gt,wfe=new Gt,s6e=new Gt,OW=class{constructor(n=new Gt,r=new Gt(0,0,-1)){this.origin=n,this.direction=r}set(n,r){return this.origin.copy(n),this.direction.copy(r),this}copy(n){return this.origin.copy(n.origin),this.direction.copy(n.direction),this}at(n,r){return r.copy(this.origin).addScaledVector(this.direction,n)}lookAt(n){return this.direction.copy(n).sub(this.origin).normalize(),this}recast(n){return this.origin.copy(this.at(n,G3)),this}closestPointToPoint(n,r){r.subVectors(n,this.origin);let c=r.dot(this.direction);return c<0?r.copy(this.origin):r.copy(this.origin).addScaledVector(this.direction,c)}distanceToPoint(n){return Math.sqrt(this.distanceSqToPoint(n))}distanceSqToPoint(n){let r=G3.subVectors(n,this.origin).dot(this.direction);return r<0?this.origin.distanceToSquared(n):(G3.copy(this.origin).addScaledVector(this.direction,r),G3.distanceToSquared(n))}distanceSqToSegment(n,r,c,u){i6e.copy(n).add(r).multiplyScalar(.5),bfe.copy(r).sub(n).normalize(),aT.copy(this.origin).sub(i6e);let d=n.distanceTo(r)*.5,b=-this.direction.dot(bfe),w=aT.dot(this.direction),_=-aT.dot(bfe),x=aT.lengthSq(),T=Math.abs(1-b*b),M,L,I,D;if(T>0)if(M=b*_-w,L=b*w-_,D=d*T,M>=0)if(L>=-D)if(L<=D){let F=1/T;M*=F,L*=F,I=M*(M+b*L+2*w)+L*(b*M+L+2*_)+x}else L=d,M=Math.max(0,-(b*L+w)),I=-M*M+L*(L+2*_)+x;else L=-d,M=Math.max(0,-(b*L+w)),I=-M*M+L*(L+2*_)+x;else L<=-D?(M=Math.max(0,-(-b*d+w)),L=M>0?-d:Math.min(Math.max(-d,-_),d),I=-M*M+L*(L+2*_)+x):L<=D?(M=0,L=Math.min(Math.max(-d,-_),d),I=L*(L+2*_)+x):(M=Math.max(0,-(b*d+w)),L=M>0?d:Math.min(Math.max(-d,-_),d),I=-M*M+L*(L+2*_)+x);else L=b>0?-d:d,M=Math.max(0,-(b*L+w)),I=-M*M+L*(L+2*_)+x;return c&&c.copy(this.origin).addScaledVector(this.direction,M),u&&u.copy(i6e).addScaledVector(bfe,L),I}intersectSphere(n,r){G3.subVectors(n.center,this.origin);let c=G3.dot(this.direction),u=G3.dot(G3)-c*c,d=n.radius*n.radius;if(u>d)return null;let b=Math.sqrt(d-u),w=c-b,_=c+b;return _<0?null:w<0?this.at(_,r):this.at(w,r)}intersectsSphere(n){return this.distanceSqToPoint(n.center)<=n.radius*n.radius}distanceToPlane(n){let r=n.normal.dot(this.direction);if(r===0)return n.distanceToPoint(this.origin)===0?0:null;let c=-(this.origin.dot(n.normal)+n.constant)/r;return c>=0?c:null}intersectPlane(n,r){let c=this.distanceToPlane(n);return c===null?null:this.at(c,r)}intersectsPlane(n){let r=n.distanceToPoint(this.origin);return r===0||n.normal.dot(this.direction)*r<0}intersectBox(n,r){let c,u,d,b,w,_,x=1/this.direction.x,T=1/this.direction.y,M=1/this.direction.z,L=this.origin;return x>=0?(c=(n.min.x-L.x)*x,u=(n.max.x-L.x)*x):(c=(n.max.x-L.x)*x,u=(n.min.x-L.x)*x),T>=0?(d=(n.min.y-L.y)*T,b=(n.max.y-L.y)*T):(d=(n.max.y-L.y)*T,b=(n.min.y-L.y)*T),c>b||d>u||((d>c||isNaN(c))&&(c=d),(b=0?(w=(n.min.z-L.z)*M,_=(n.max.z-L.z)*M):(w=(n.max.z-L.z)*M,_=(n.min.z-L.z)*M),c>_||w>u)||((w>c||c!==c)&&(c=w),(_=0?c:u,r)}intersectsBox(n){return this.intersectBox(n,G3)!==null}intersectTriangle(n,r,c,u,d){r6e.subVectors(r,n),wfe.subVectors(c,n),s6e.crossVectors(r6e,wfe);let b=this.direction.dot(s6e),w;if(b>0){if(u)return null;w=1}else if(b<0)w=-1,b=-b;else return null;aT.subVectors(this.origin,n);let _=w*this.direction.dot(wfe.crossVectors(aT,wfe));if(_<0)return null;let x=w*this.direction.dot(r6e.cross(aT));if(x<0||_+x>b)return null;let T=-w*aT.dot(s6e);return T<0?null:this.at(T/b,d)}applyMatrix4(n){return this.origin.applyMatrix4(n),this.direction.transformDirection(n),this}equals(n){return n.origin.equals(this.origin)&&n.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Rl=class s{constructor(n,r,c,u,d,b,w,_,x,T,M,L,I,D,F,O){s.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],n!==void 0&&this.set(n,r,c,u,d,b,w,_,x,T,M,L,I,D,F,O)}set(n,r,c,u,d,b,w,_,x,T,M,L,I,D,F,O){let z=this.elements;return z[0]=n,z[4]=r,z[8]=c,z[12]=u,z[1]=d,z[5]=b,z[9]=w,z[13]=_,z[2]=x,z[6]=T,z[10]=M,z[14]=L,z[3]=I,z[7]=D,z[11]=F,z[15]=O,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new s().fromArray(this.elements)}copy(n){let r=this.elements,c=n.elements;return r[0]=c[0],r[1]=c[1],r[2]=c[2],r[3]=c[3],r[4]=c[4],r[5]=c[5],r[6]=c[6],r[7]=c[7],r[8]=c[8],r[9]=c[9],r[10]=c[10],r[11]=c[11],r[12]=c[12],r[13]=c[13],r[14]=c[14],r[15]=c[15],this}copyPosition(n){let r=this.elements,c=n.elements;return r[12]=c[12],r[13]=c[13],r[14]=c[14],this}setFromMatrix3(n){let r=n.elements;return this.set(r[0],r[3],r[6],0,r[1],r[4],r[7],0,r[2],r[5],r[8],0,0,0,0,1),this}extractBasis(n,r,c){return n.setFromMatrixColumn(this,0),r.setFromMatrixColumn(this,1),c.setFromMatrixColumn(this,2),this}makeBasis(n,r,c){return this.set(n.x,r.x,c.x,0,n.y,r.y,c.y,0,n.z,r.z,c.z,0,0,0,0,1),this}extractRotation(n){let r=this.elements,c=n.elements,u=1/HB.setFromMatrixColumn(n,0).length(),d=1/HB.setFromMatrixColumn(n,1).length(),b=1/HB.setFromMatrixColumn(n,2).length();return r[0]=c[0]*u,r[1]=c[1]*u,r[2]=c[2]*u,r[3]=0,r[4]=c[4]*d,r[5]=c[5]*d,r[6]=c[6]*d,r[7]=0,r[8]=c[8]*b,r[9]=c[9]*b,r[10]=c[10]*b,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,this}makeRotationFromEuler(n){let r=this.elements,c=n.x,u=n.y,d=n.z,b=Math.cos(c),w=Math.sin(c),_=Math.cos(u),x=Math.sin(u),T=Math.cos(d),M=Math.sin(d);if(n.order==="XYZ"){let L=b*T,I=b*M,D=w*T,F=w*M;r[0]=_*T,r[4]=-_*M,r[8]=x,r[1]=I+D*x,r[5]=L-F*x,r[9]=-w*_,r[2]=F-L*x,r[6]=D+I*x,r[10]=b*_}else if(n.order==="YXZ"){let L=_*T,I=_*M,D=x*T,F=x*M;r[0]=L+F*w,r[4]=D*w-I,r[8]=b*x,r[1]=b*M,r[5]=b*T,r[9]=-w,r[2]=I*w-D,r[6]=F+L*w,r[10]=b*_}else if(n.order==="ZXY"){let L=_*T,I=_*M,D=x*T,F=x*M;r[0]=L-F*w,r[4]=-b*M,r[8]=D+I*w,r[1]=I+D*w,r[5]=b*T,r[9]=F-L*w,r[2]=-b*x,r[6]=w,r[10]=b*_}else if(n.order==="ZYX"){let L=b*T,I=b*M,D=w*T,F=w*M;r[0]=_*T,r[4]=D*x-I,r[8]=L*x+F,r[1]=_*M,r[5]=F*x+L,r[9]=I*x-D,r[2]=-x,r[6]=w*_,r[10]=b*_}else if(n.order==="YZX"){let L=b*_,I=b*x,D=w*_,F=w*x;r[0]=_*T,r[4]=F-L*M,r[8]=D*M+I,r[1]=M,r[5]=b*T,r[9]=-w*T,r[2]=-x*T,r[6]=I*M+D,r[10]=L-F*M}else if(n.order==="XZY"){let L=b*_,I=b*x,D=w*_,F=w*x;r[0]=_*T,r[4]=-M,r[8]=x*T,r[1]=L*M+F,r[5]=b*T,r[9]=I*M-D,r[2]=D*M-I,r[6]=w*T,r[10]=F*M+L}return r[3]=0,r[7]=0,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,this}makeRotationFromQuaternion(n){return this.compose(lan,n,uan)}lookAt(n,r,c){let u=this.elements;return W1.subVectors(n,r),W1.lengthSq()===0&&(W1.z=1),W1.normalize(),cT.crossVectors(c,W1),cT.lengthSq()===0&&(Math.abs(c.z)===1?W1.x+=1e-4:W1.z+=1e-4,W1.normalize(),cT.crossVectors(c,W1)),cT.normalize(),vfe.crossVectors(W1,cT),u[0]=cT.x,u[4]=vfe.x,u[8]=W1.x,u[1]=cT.y,u[5]=vfe.y,u[9]=W1.y,u[2]=cT.z,u[6]=vfe.z,u[10]=W1.z,this}multiply(n){return this.multiplyMatrices(this,n)}premultiply(n){return this.multiplyMatrices(n,this)}multiplyMatrices(n,r){let c=n.elements,u=r.elements,d=this.elements,b=c[0],w=c[4],_=c[8],x=c[12],T=c[1],M=c[5],L=c[9],I=c[13],D=c[2],F=c[6],O=c[10],z=c[14],Z=c[3],H=c[7],te=c[11],se=c[15],ne=u[0],ue=u[4],Ce=u[8],Q=u[12],me=u[1],tt=u[5],st=u[9],at=u[13],Ne=u[2],Qe=u[6],ot=u[10],xt=u[14],fn=u[3],Xt=u[7],wn=u[11],cn=u[15];return d[0]=b*ne+w*me+_*Ne+x*fn,d[4]=b*ue+w*tt+_*Qe+x*Xt,d[8]=b*Ce+w*st+_*ot+x*wn,d[12]=b*Q+w*at+_*xt+x*cn,d[1]=T*ne+M*me+L*Ne+I*fn,d[5]=T*ue+M*tt+L*Qe+I*Xt,d[9]=T*Ce+M*st+L*ot+I*wn,d[13]=T*Q+M*at+L*xt+I*cn,d[2]=D*ne+F*me+O*Ne+z*fn,d[6]=D*ue+F*tt+O*Qe+z*Xt,d[10]=D*Ce+F*st+O*ot+z*wn,d[14]=D*Q+F*at+O*xt+z*cn,d[3]=Z*ne+H*me+te*Ne+se*fn,d[7]=Z*ue+H*tt+te*Qe+se*Xt,d[11]=Z*Ce+H*st+te*ot+se*wn,d[15]=Z*Q+H*at+te*xt+se*cn,this}multiplyScalar(n){let r=this.elements;return r[0]*=n,r[4]*=n,r[8]*=n,r[12]*=n,r[1]*=n,r[5]*=n,r[9]*=n,r[13]*=n,r[2]*=n,r[6]*=n,r[10]*=n,r[14]*=n,r[3]*=n,r[7]*=n,r[11]*=n,r[15]*=n,this}determinant(){let n=this.elements,r=n[0],c=n[4],u=n[8],d=n[12],b=n[1],w=n[5],_=n[9],x=n[13],T=n[2],M=n[6],L=n[10],I=n[14],D=n[3],F=n[7],O=n[11],z=n[15];return D*(+d*_*M-u*x*M-d*w*L+c*x*L+u*w*I-c*_*I)+F*(+r*_*I-r*x*L+d*b*L-u*b*I+u*x*T-d*_*T)+O*(+r*x*M-r*w*I-d*b*M+c*b*I+d*w*T-c*x*T)+z*(-u*w*T-r*_*M+r*w*L+u*b*M-c*b*L+c*_*T)}transpose(){let n=this.elements,r;return r=n[1],n[1]=n[4],n[4]=r,r=n[2],n[2]=n[8],n[8]=r,r=n[6],n[6]=n[9],n[9]=r,r=n[3],n[3]=n[12],n[12]=r,r=n[7],n[7]=n[13],n[13]=r,r=n[11],n[11]=n[14],n[14]=r,this}setPosition(n,r,c){let u=this.elements;return n.isVector3?(u[12]=n.x,u[13]=n.y,u[14]=n.z):(u[12]=n,u[13]=r,u[14]=c),this}invert(){let n=this.elements,r=n[0],c=n[1],u=n[2],d=n[3],b=n[4],w=n[5],_=n[6],x=n[7],T=n[8],M=n[9],L=n[10],I=n[11],D=n[12],F=n[13],O=n[14],z=n[15],Z=M*O*x-F*L*x+F*_*I-w*O*I-M*_*z+w*L*z,H=D*L*x-T*O*x-D*_*I+b*O*I+T*_*z-b*L*z,te=T*F*x-D*M*x+D*w*I-b*F*I-T*w*z+b*M*z,se=D*M*_-T*F*_-D*w*L+b*F*L+T*w*O-b*M*O,ne=r*Z+c*H+u*te+d*se;if(ne===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let ue=1/ne;return n[0]=Z*ue,n[1]=(F*L*d-M*O*d-F*u*I+c*O*I+M*u*z-c*L*z)*ue,n[2]=(w*O*d-F*_*d+F*u*x-c*O*x-w*u*z+c*_*z)*ue,n[3]=(M*_*d-w*L*d-M*u*x+c*L*x+w*u*I-c*_*I)*ue,n[4]=H*ue,n[5]=(T*O*d-D*L*d+D*u*I-r*O*I-T*u*z+r*L*z)*ue,n[6]=(D*_*d-b*O*d-D*u*x+r*O*x+b*u*z-r*_*z)*ue,n[7]=(b*L*d-T*_*d+T*u*x-r*L*x-b*u*I+r*_*I)*ue,n[8]=te*ue,n[9]=(D*M*d-T*F*d-D*c*I+r*F*I+T*c*z-r*M*z)*ue,n[10]=(b*F*d-D*w*d+D*c*x-r*F*x-b*c*z+r*w*z)*ue,n[11]=(T*w*d-b*M*d-T*c*x+r*M*x+b*c*I-r*w*I)*ue,n[12]=se*ue,n[13]=(T*F*u-D*M*u+D*c*L-r*F*L-T*c*O+r*M*O)*ue,n[14]=(D*w*u-b*F*u-D*c*_+r*F*_+b*c*O-r*w*O)*ue,n[15]=(b*M*u-T*w*u+T*c*_-r*M*_-b*c*L+r*w*L)*ue,this}scale(n){let r=this.elements,c=n.x,u=n.y,d=n.z;return r[0]*=c,r[4]*=u,r[8]*=d,r[1]*=c,r[5]*=u,r[9]*=d,r[2]*=c,r[6]*=u,r[10]*=d,r[3]*=c,r[7]*=u,r[11]*=d,this}getMaxScaleOnAxis(){let n=this.elements,r=n[0]*n[0]+n[1]*n[1]+n[2]*n[2],c=n[4]*n[4]+n[5]*n[5]+n[6]*n[6],u=n[8]*n[8]+n[9]*n[9]+n[10]*n[10];return Math.sqrt(Math.max(r,c,u))}makeTranslation(n,r,c){return n.isVector3?this.set(1,0,0,n.x,0,1,0,n.y,0,0,1,n.z,0,0,0,1):this.set(1,0,0,n,0,1,0,r,0,0,1,c,0,0,0,1),this}makeRotationX(n){let r=Math.cos(n),c=Math.sin(n);return this.set(1,0,0,0,0,r,-c,0,0,c,r,0,0,0,0,1),this}makeRotationY(n){let r=Math.cos(n),c=Math.sin(n);return this.set(r,0,c,0,0,1,0,0,-c,0,r,0,0,0,0,1),this}makeRotationZ(n){let r=Math.cos(n),c=Math.sin(n);return this.set(r,-c,0,0,c,r,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(n,r){let c=Math.cos(r),u=Math.sin(r),d=1-c,b=n.x,w=n.y,_=n.z,x=d*b,T=d*w;return this.set(x*b+c,x*w-u*_,x*_+u*w,0,x*w+u*_,T*w+c,T*_-u*b,0,x*_-u*w,T*_+u*b,d*_*_+c,0,0,0,0,1),this}makeScale(n,r,c){return this.set(n,0,0,0,0,r,0,0,0,0,c,0,0,0,0,1),this}makeShear(n,r,c,u,d,b){return this.set(1,c,d,0,n,1,b,0,r,u,1,0,0,0,0,1),this}compose(n,r,c){let u=this.elements,d=r._x,b=r._y,w=r._z,_=r._w,x=d+d,T=b+b,M=w+w,L=d*x,I=d*T,D=d*M,F=b*T,O=b*M,z=w*M,Z=_*x,H=_*T,te=_*M,se=c.x,ne=c.y,ue=c.z;return u[0]=(1-(F+z))*se,u[1]=(I+te)*se,u[2]=(D-H)*se,u[3]=0,u[4]=(I-te)*ne,u[5]=(1-(L+z))*ne,u[6]=(O+Z)*ne,u[7]=0,u[8]=(D+H)*ue,u[9]=(O-Z)*ue,u[10]=(1-(L+F))*ue,u[11]=0,u[12]=n.x,u[13]=n.y,u[14]=n.z,u[15]=1,this}decompose(n,r,c){let u=this.elements,d=HB.set(u[0],u[1],u[2]).length(),b=HB.set(u[4],u[5],u[6]).length(),w=HB.set(u[8],u[9],u[10]).length();this.determinant()<0&&(d=-d),n.x=u[12],n.y=u[13],n.z=u[14],yv.copy(this);let x=1/d,T=1/b,M=1/w;return yv.elements[0]*=x,yv.elements[1]*=x,yv.elements[2]*=x,yv.elements[4]*=T,yv.elements[5]*=T,yv.elements[6]*=T,yv.elements[8]*=M,yv.elements[9]*=M,yv.elements[10]*=M,r.setFromRotationMatrix(yv),c.x=d,c.y=b,c.z=w,this}makePerspective(n,r,c,u,d,b,w=q3){let _=this.elements,x=2*d/(r-n),T=2*d/(c-u),M=(r+n)/(r-n),L=(c+u)/(c-u),I,D;if(w===q3)I=-(b+d)/(b-d),D=-2*b*d/(b-d);else if(w===Xfe)I=-b/(b-d),D=-b*d/(b-d);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+w);return _[0]=x,_[4]=0,_[8]=M,_[12]=0,_[1]=0,_[5]=T,_[9]=L,_[13]=0,_[2]=0,_[6]=0,_[10]=I,_[14]=D,_[3]=0,_[7]=0,_[11]=-1,_[15]=0,this}makeOrthographic(n,r,c,u,d,b,w=q3){let _=this.elements,x=1/(r-n),T=1/(c-u),M=1/(b-d),L=(r+n)*x,I=(c+u)*T,D,F;if(w===q3)D=(b+d)*M,F=-2*M;else if(w===Xfe)D=d*M,F=-1*M;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+w);return _[0]=2*x,_[4]=0,_[8]=0,_[12]=-L,_[1]=0,_[5]=2*T,_[9]=0,_[13]=-I,_[2]=0,_[6]=0,_[10]=F,_[14]=-D,_[3]=0,_[7]=0,_[11]=0,_[15]=1,this}equals(n){let r=this.elements,c=n.elements;for(let u=0;u<16;u++)if(r[u]!==c[u])return!1;return!0}fromArray(n,r=0){for(let c=0;c<16;c++)this.elements[c]=n[c+r];return this}toArray(n=[],r=0){let c=this.elements;return n[r]=c[0],n[r+1]=c[1],n[r+2]=c[2],n[r+3]=c[3],n[r+4]=c[4],n[r+5]=c[5],n[r+6]=c[6],n[r+7]=c[7],n[r+8]=c[8],n[r+9]=c[9],n[r+10]=c[10],n[r+11]=c[11],n[r+12]=c[12],n[r+13]=c[13],n[r+14]=c[14],n[r+15]=c[15],n}},HB=new Gt,yv=new Rl,lan=new Gt(0,0,0),uan=new Gt(1,1,1),cT=new Gt,vfe=new Gt,W1=new Gt,Tyt=new Rl,Cyt=new h2,Qfe=class s{constructor(n=0,r=0,c=0,u=s.DEFAULT_ORDER){this.isEuler=!0,this._x=n,this._y=r,this._z=c,this._order=u}get x(){return this._x}set x(n){this._x=n,this._onChangeCallback()}get y(){return this._y}set y(n){this._y=n,this._onChangeCallback()}get z(){return this._z}set z(n){this._z=n,this._onChangeCallback()}get order(){return this._order}set order(n){this._order=n,this._onChangeCallback()}set(n,r,c,u=this._order){return this._x=n,this._y=r,this._z=c,this._order=u,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(n){return this._x=n._x,this._y=n._y,this._z=n._z,this._order=n._order,this._onChangeCallback(),this}setFromRotationMatrix(n,r=this._order,c=!0){let u=n.elements,d=u[0],b=u[4],w=u[8],_=u[1],x=u[5],T=u[9],M=u[2],L=u[6],I=u[10];switch(r){case"XYZ":this._y=Math.asin(Sm(w,-1,1)),Math.abs(w)<.9999999?(this._x=Math.atan2(-T,I),this._z=Math.atan2(-b,d)):(this._x=Math.atan2(L,x),this._z=0);break;case"YXZ":this._x=Math.asin(-Sm(T,-1,1)),Math.abs(T)<.9999999?(this._y=Math.atan2(w,I),this._z=Math.atan2(_,x)):(this._y=Math.atan2(-M,d),this._z=0);break;case"ZXY":this._x=Math.asin(Sm(L,-1,1)),Math.abs(L)<.9999999?(this._y=Math.atan2(-M,I),this._z=Math.atan2(-b,x)):(this._y=0,this._z=Math.atan2(_,d));break;case"ZYX":this._y=Math.asin(-Sm(M,-1,1)),Math.abs(M)<.9999999?(this._x=Math.atan2(L,I),this._z=Math.atan2(_,d)):(this._x=0,this._z=Math.atan2(-b,x));break;case"YZX":this._z=Math.asin(Sm(_,-1,1)),Math.abs(_)<.9999999?(this._x=Math.atan2(-T,x),this._y=Math.atan2(-M,d)):(this._x=0,this._y=Math.atan2(w,I));break;case"XZY":this._z=Math.asin(-Sm(b,-1,1)),Math.abs(b)<.9999999?(this._x=Math.atan2(L,x),this._y=Math.atan2(w,d)):(this._x=Math.atan2(-T,I),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+r)}return this._order=r,c===!0&&this._onChangeCallback(),this}setFromQuaternion(n,r,c){return Tyt.makeRotationFromQuaternion(n),this.setFromRotationMatrix(Tyt,r,c)}setFromVector3(n,r=this._order){return this.set(n.x,n.y,n.z,r)}reorder(n){return Cyt.setFromEuler(this),this.setFromQuaternion(Cyt,n)}equals(n){return n._x===this._x&&n._y===this._y&&n._z===this._z&&n._order===this._order}fromArray(n){return this._x=n[0],this._y=n[1],this._z=n[2],n[3]!==void 0&&(this._order=n[3]),this._onChangeCallback(),this}toArray(n=[],r=0){return n[r]=this._x,n[r+1]=this._y,n[r+2]=this._z,n[r+3]=this._order,n}_onChange(n){return this._onChangeCallback=n,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Qfe.DEFAULT_ORDER="XYZ";var NW=class{constructor(){this.mask=1}set(n){this.mask=(1<>>0}enable(n){this.mask|=1<1){for(let r=0;r1){for(let c=0;c0&&(u.userData=this.userData),u.layers=this.layers.mask,u.matrix=this.matrix.toArray(),u.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(u.matrixAutoUpdate=!1),this.isInstancedMesh&&(u.type="InstancedMesh",u.count=this.count,u.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(u.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(u.type="BatchedMesh",u.perObjectFrustumCulled=this.perObjectFrustumCulled,u.sortObjects=this.sortObjects,u.drawRanges=this._drawRanges,u.reservedRanges=this._reservedRanges,u.visibility=this._visibility,u.active=this._active,u.bounds=this._bounds.map(w=>({boxInitialized:w.boxInitialized,boxMin:w.box.min.toArray(),boxMax:w.box.max.toArray(),sphereInitialized:w.sphereInitialized,sphereRadius:w.sphere.radius,sphereCenter:w.sphere.center.toArray()})),u.maxGeometryCount=this._maxGeometryCount,u.maxVertexCount=this._maxVertexCount,u.maxIndexCount=this._maxIndexCount,u.geometryInitialized=this._geometryInitialized,u.geometryCount=this._geometryCount,u.matricesTexture=this._matricesTexture.toJSON(n),this.boundingSphere!==null&&(u.boundingSphere={center:u.boundingSphere.center.toArray(),radius:u.boundingSphere.radius}),this.boundingBox!==null&&(u.boundingBox={min:u.boundingBox.min.toArray(),max:u.boundingBox.max.toArray()}));function d(w,_){return w[_.uuid]===void 0&&(w[_.uuid]=_.toJSON(n)),_.uuid}if(this.isScene)this.background&&(this.background.isColor?u.background=this.background.toJSON():this.background.isTexture&&(u.background=this.background.toJSON(n).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(u.environment=this.environment.toJSON(n).uuid);else if(this.isMesh||this.isLine||this.isPoints){u.geometry=d(n.geometries,this.geometry);let w=this.geometry.parameters;if(w!==void 0&&w.shapes!==void 0){let _=w.shapes;if(Array.isArray(_))for(let x=0,T=_.length;x0){u.children=[];for(let w=0;w0){u.animations=[];for(let w=0;w0&&(c.geometries=w),_.length>0&&(c.materials=_),x.length>0&&(c.textures=x),T.length>0&&(c.images=T),M.length>0&&(c.shapes=M),L.length>0&&(c.skeletons=L),I.length>0&&(c.animations=I),D.length>0&&(c.nodes=D)}return c.object=u,c;function b(w){let _=[];for(let x in w){let T=w[x];delete T.metadata,_.push(T)}return _}}clone(n){return new this.constructor().copy(this,n)}copy(n,r=!0){if(this.name=n.name,this.up.copy(n.up),this.position.copy(n.position),this.rotation.order=n.rotation.order,this.quaternion.copy(n.quaternion),this.scale.copy(n.scale),this.matrix.copy(n.matrix),this.matrixWorld.copy(n.matrixWorld),this.matrixAutoUpdate=n.matrixAutoUpdate,this.matrixWorldAutoUpdate=n.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=n.matrixWorldNeedsUpdate,this.layers.mask=n.layers.mask,this.visible=n.visible,this.castShadow=n.castShadow,this.receiveShadow=n.receiveShadow,this.frustumCulled=n.frustumCulled,this.renderOrder=n.renderOrder,this.animations=n.animations.slice(),this.userData=JSON.parse(JSON.stringify(n.userData)),r===!0)for(let c=0;c0?u.multiplyScalar(1/Math.sqrt(d)):u.set(0,0,0)}static getBarycoord(n,r,c,u,d){xv.subVectors(u,r),$3.subVectors(c,r),o6e.subVectors(n,r);let b=xv.dot(xv),w=xv.dot($3),_=xv.dot(o6e),x=$3.dot($3),T=$3.dot(o6e),M=b*x-w*w;if(M===0)return d.set(0,0,0),null;let L=1/M,I=(x*_-w*T)*L,D=(b*T-w*_)*L;return d.set(1-I-D,D,I)}static containsPoint(n,r,c,u){return this.getBarycoord(n,r,c,u,V3)===null?!1:V3.x>=0&&V3.y>=0&&V3.x+V3.y<=1}static getUV(n,r,c,u,d,b,w,_){return yfe===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),yfe=!0),this.getInterpolation(n,r,c,u,d,b,w,_)}static getInterpolation(n,r,c,u,d,b,w,_){return this.getBarycoord(n,r,c,u,V3)===null?(_.x=0,_.y=0,"z"in _&&(_.z=0),"w"in _&&(_.w=0),null):(_.setScalar(0),_.addScaledVector(d,V3.x),_.addScaledVector(b,V3.y),_.addScaledVector(w,V3.z),_)}static isFrontFacing(n,r,c,u){return xv.subVectors(c,r),$3.subVectors(n,r),xv.cross($3).dot(u)<0}set(n,r,c){return this.a.copy(n),this.b.copy(r),this.c.copy(c),this}setFromPointsAndIndices(n,r,c,u){return this.a.copy(n[r]),this.b.copy(n[c]),this.c.copy(n[u]),this}setFromAttributeAndIndices(n,r,c,u){return this.a.fromBufferAttribute(n,r),this.b.fromBufferAttribute(n,c),this.c.fromBufferAttribute(n,u),this}clone(){return new this.constructor().copy(this)}copy(n){return this.a.copy(n.a),this.b.copy(n.b),this.c.copy(n.c),this}getArea(){return xv.subVectors(this.c,this.b),$3.subVectors(this.a,this.b),xv.cross($3).length()*.5}getMidpoint(n){return n.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(n){return s.getNormal(this.a,this.b,this.c,n)}getPlane(n){return n.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(n,r){return s.getBarycoord(n,this.a,this.b,this.c,r)}getUV(n,r,c,u,d){return yfe===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),yfe=!0),s.getInterpolation(n,this.a,this.b,this.c,r,c,u,d)}getInterpolation(n,r,c,u,d){return s.getInterpolation(n,this.a,this.b,this.c,r,c,u,d)}containsPoint(n){return s.containsPoint(n,this.a,this.b,this.c)}isFrontFacing(n){return s.isFrontFacing(this.a,this.b,this.c,n)}intersectsBox(n){return n.intersectsTriangle(this)}closestPointToPoint(n,r){let c=this.a,u=this.b,d=this.c,b,w;XB.subVectors(u,c),YB.subVectors(d,c),a6e.subVectors(n,c);let _=XB.dot(a6e),x=YB.dot(a6e);if(_<=0&&x<=0)return r.copy(c);c6e.subVectors(n,u);let T=XB.dot(c6e),M=YB.dot(c6e);if(T>=0&&M<=T)return r.copy(u);let L=_*M-T*x;if(L<=0&&_>=0&&T<=0)return b=_/(_-T),r.copy(c).addScaledVector(XB,b);l6e.subVectors(n,d);let I=XB.dot(l6e),D=YB.dot(l6e);if(D>=0&&I<=D)return r.copy(d);let F=I*x-_*D;if(F<=0&&x>=0&&D<=0)return w=x/(x-D),r.copy(c).addScaledVector(YB,w);let O=T*D-I*M;if(O<=0&&M-T>=0&&I-D>=0)return Ryt.subVectors(d,u),w=(M-T)/(M-T+(I-D)),r.copy(u).addScaledVector(Ryt,w);let z=1/(O+F+L);return b=F*z,w=L*z,r.copy(c).addScaledVector(XB,b).addScaledVector(YB,w)}equals(n){return n.a.equals(this.a)&&n.b.equals(this.b)&&n.c.equals(this.c)}},A2t={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},lT={h:0,s:0,l:0},xfe={h:0,s:0,l:0};function u6e(s,n,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?s+(n-s)*6*r:r<1/2?n:r<2/3?s+(n-s)*6*(2/3-r):s}var zo=class{constructor(n,r,c){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(n,r,c)}set(n,r,c){if(r===void 0&&c===void 0){let u=n;u&&u.isColor?this.copy(u):typeof u=="number"?this.setHex(u):typeof u=="string"&&this.setStyle(u)}else this.setRGB(n,r,c);return this}setScalar(n){return this.r=n,this.g=n,this.b=n,this}setHex(n,r=Md){return n=Math.floor(n),this.r=(n>>16&255)/255,this.g=(n>>8&255)/255,this.b=(n&255)/255,Ac.toWorkingColorSpace(this,r),this}setRGB(n,r,c,u=Ac.workingColorSpace){return this.r=n,this.g=r,this.b=c,Ac.toWorkingColorSpace(this,u),this}setHSL(n,r,c,u=Ac.workingColorSpace){if(n=ian(n,1),r=Sm(r,0,1),c=Sm(c,0,1),r===0)this.r=this.g=this.b=c;else{let d=c<=.5?c*(1+r):c+r-c*r,b=2*c-d;this.r=u6e(b,d,n+1/3),this.g=u6e(b,d,n),this.b=u6e(b,d,n-1/3)}return Ac.toWorkingColorSpace(this,u),this}setStyle(n,r=Md){function c(d){d!==void 0&&parseFloat(d)<1&&console.warn("THREE.Color: Alpha component of "+n+" will be ignored.")}let u;if(u=/^(\w+)\(([^\)]*)\)/.exec(n)){let d,b=u[1],w=u[2];switch(b){case"rgb":case"rgba":if(d=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(w))return c(d[4]),this.setRGB(Math.min(255,parseInt(d[1],10))/255,Math.min(255,parseInt(d[2],10))/255,Math.min(255,parseInt(d[3],10))/255,r);if(d=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(w))return c(d[4]),this.setRGB(Math.min(100,parseInt(d[1],10))/100,Math.min(100,parseInt(d[2],10))/100,Math.min(100,parseInt(d[3],10))/100,r);break;case"hsl":case"hsla":if(d=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(w))return c(d[4]),this.setHSL(parseFloat(d[1])/360,parseFloat(d[2])/100,parseFloat(d[3])/100,r);break;default:console.warn("THREE.Color: Unknown color model "+n)}}else if(u=/^\#([A-Fa-f\d]+)$/.exec(n)){let d=u[1],b=d.length;if(b===3)return this.setRGB(parseInt(d.charAt(0),16)/15,parseInt(d.charAt(1),16)/15,parseInt(d.charAt(2),16)/15,r);if(b===6)return this.setHex(parseInt(d,16),r);console.warn("THREE.Color: Invalid hex color "+n)}else if(n&&n.length>0)return this.setColorName(n,r);return this}setColorName(n,r=Md){let c=A2t[n.toLowerCase()];return c!==void 0?this.setHex(c,r):console.warn("THREE.Color: Unknown color "+n),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(n){return this.r=n.r,this.g=n.g,this.b=n.b,this}copySRGBToLinear(n){return this.r=aO(n.r),this.g=aO(n.g),this.b=aO(n.b),this}copyLinearToSRGB(n){return this.r=JIe(n.r),this.g=JIe(n.g),this.b=JIe(n.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(n=Md){return Ac.fromWorkingColorSpace(gp.copy(this),n),Math.round(Sm(gp.r*255,0,255))*65536+Math.round(Sm(gp.g*255,0,255))*256+Math.round(Sm(gp.b*255,0,255))}getHexString(n=Md){return("000000"+this.getHex(n).toString(16)).slice(-6)}getHSL(n,r=Ac.workingColorSpace){Ac.fromWorkingColorSpace(gp.copy(this),r);let c=gp.r,u=gp.g,d=gp.b,b=Math.max(c,u,d),w=Math.min(c,u,d),_,x,T=(w+b)/2;if(w===b)_=0,x=0;else{let M=b-w;switch(x=T<=.5?M/(b+w):M/(2-b-w),b){case c:_=(u-d)/M+(u0!=n>0&&this.version++,this._alphaTest=n}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(n){if(n!==void 0)for(let r in n){let c=n[r];if(c===void 0){console.warn(`THREE.Material: parameter '${r}' has value of undefined.`);continue}let u=this[r];if(u===void 0){console.warn(`THREE.Material: '${r}' is not a property of THREE.${this.type}.`);continue}u&&u.isColor?u.set(c):u&&u.isVector3&&c&&c.isVector3?u.copy(c):this[r]=c}}toJSON(n){let r=n===void 0||typeof n=="string";r&&(n={textures:{},images:{}});let c={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};c.uuid=this.uuid,c.type=this.type,this.name!==""&&(c.name=this.name),this.color&&this.color.isColor&&(c.color=this.color.getHex()),this.roughness!==void 0&&(c.roughness=this.roughness),this.metalness!==void 0&&(c.metalness=this.metalness),this.sheen!==void 0&&(c.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(c.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(c.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(c.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(c.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(c.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(c.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(c.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(c.shininess=this.shininess),this.clearcoat!==void 0&&(c.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(c.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(c.clearcoatMap=this.clearcoatMap.toJSON(n).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(c.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(n).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(c.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(n).uuid,c.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(c.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(c.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(c.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(c.iridescenceMap=this.iridescenceMap.toJSON(n).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(c.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(n).uuid),this.anisotropy!==void 0&&(c.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(c.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(c.anisotropyMap=this.anisotropyMap.toJSON(n).uuid),this.map&&this.map.isTexture&&(c.map=this.map.toJSON(n).uuid),this.matcap&&this.matcap.isTexture&&(c.matcap=this.matcap.toJSON(n).uuid),this.alphaMap&&this.alphaMap.isTexture&&(c.alphaMap=this.alphaMap.toJSON(n).uuid),this.lightMap&&this.lightMap.isTexture&&(c.lightMap=this.lightMap.toJSON(n).uuid,c.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(c.aoMap=this.aoMap.toJSON(n).uuid,c.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(c.bumpMap=this.bumpMap.toJSON(n).uuid,c.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(c.normalMap=this.normalMap.toJSON(n).uuid,c.normalMapType=this.normalMapType,c.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(c.displacementMap=this.displacementMap.toJSON(n).uuid,c.displacementScale=this.displacementScale,c.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(c.roughnessMap=this.roughnessMap.toJSON(n).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(c.metalnessMap=this.metalnessMap.toJSON(n).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(c.emissiveMap=this.emissiveMap.toJSON(n).uuid),this.specularMap&&this.specularMap.isTexture&&(c.specularMap=this.specularMap.toJSON(n).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(c.specularIntensityMap=this.specularIntensityMap.toJSON(n).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(c.specularColorMap=this.specularColorMap.toJSON(n).uuid),this.envMap&&this.envMap.isTexture&&(c.envMap=this.envMap.toJSON(n).uuid,this.combine!==void 0&&(c.combine=this.combine)),this.envMapIntensity!==void 0&&(c.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(c.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(c.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(c.gradientMap=this.gradientMap.toJSON(n).uuid),this.transmission!==void 0&&(c.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(c.transmissionMap=this.transmissionMap.toJSON(n).uuid),this.thickness!==void 0&&(c.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(c.thicknessMap=this.thicknessMap.toJSON(n).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(c.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(c.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(c.size=this.size),this.shadowSide!==null&&(c.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(c.sizeAttenuation=this.sizeAttenuation),this.blending!==oO&&(c.blending=this.blending),this.side!==mT&&(c.side=this.side),this.vertexColors===!0&&(c.vertexColors=!0),this.opacity<1&&(c.opacity=this.opacity),this.transparent===!0&&(c.transparent=!0),this.blendSrc!==x6e&&(c.blendSrc=this.blendSrc),this.blendDst!==E6e&&(c.blendDst=this.blendDst),this.blendEquation!==j4&&(c.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(c.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(c.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(c.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(c.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(c.blendAlpha=this.blendAlpha),this.depthFunc!==jfe&&(c.depthFunc=this.depthFunc),this.depthTest===!1&&(c.depthTest=this.depthTest),this.depthWrite===!1&&(c.depthWrite=this.depthWrite),this.colorWrite===!1&&(c.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(c.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==wyt&&(c.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(c.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(c.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==GB&&(c.stencilFail=this.stencilFail),this.stencilZFail!==GB&&(c.stencilZFail=this.stencilZFail),this.stencilZPass!==GB&&(c.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(c.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(c.rotation=this.rotation),this.polygonOffset===!0&&(c.polygonOffset=!0),this.polygonOffsetFactor!==0&&(c.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(c.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(c.linewidth=this.linewidth),this.dashSize!==void 0&&(c.dashSize=this.dashSize),this.gapSize!==void 0&&(c.gapSize=this.gapSize),this.scale!==void 0&&(c.scale=this.scale),this.dithering===!0&&(c.dithering=!0),this.alphaTest>0&&(c.alphaTest=this.alphaTest),this.alphaHash===!0&&(c.alphaHash=!0),this.alphaToCoverage===!0&&(c.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(c.premultipliedAlpha=!0),this.forceSinglePass===!0&&(c.forceSinglePass=!0),this.wireframe===!0&&(c.wireframe=!0),this.wireframeLinewidth>1&&(c.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(c.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(c.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(c.flatShading=!0),this.visible===!1&&(c.visible=!1),this.toneMapped===!1&&(c.toneMapped=!1),this.fog===!1&&(c.fog=!1),Object.keys(this.userData).length>0&&(c.userData=this.userData);function u(d){let b=[];for(let w in d){let _=d[w];delete _.metadata,b.push(_)}return b}if(r){let d=u(n.textures),b=u(n.images);d.length>0&&(c.textures=d),b.length>0&&(c.images=b)}return c}clone(){return new this.constructor().copy(this)}copy(n){this.name=n.name,this.blending=n.blending,this.side=n.side,this.vertexColors=n.vertexColors,this.opacity=n.opacity,this.transparent=n.transparent,this.blendSrc=n.blendSrc,this.blendDst=n.blendDst,this.blendEquation=n.blendEquation,this.blendSrcAlpha=n.blendSrcAlpha,this.blendDstAlpha=n.blendDstAlpha,this.blendEquationAlpha=n.blendEquationAlpha,this.blendColor.copy(n.blendColor),this.blendAlpha=n.blendAlpha,this.depthFunc=n.depthFunc,this.depthTest=n.depthTest,this.depthWrite=n.depthWrite,this.stencilWriteMask=n.stencilWriteMask,this.stencilFunc=n.stencilFunc,this.stencilRef=n.stencilRef,this.stencilFuncMask=n.stencilFuncMask,this.stencilFail=n.stencilFail,this.stencilZFail=n.stencilZFail,this.stencilZPass=n.stencilZPass,this.stencilWrite=n.stencilWrite;let r=n.clippingPlanes,c=null;if(r!==null){let u=r.length;c=new Array(u);for(let d=0;d!==u;++d)c[d]=r[d].clone()}return this.clippingPlanes=c,this.clipIntersection=n.clipIntersection,this.clipShadows=n.clipShadows,this.shadowSide=n.shadowSide,this.colorWrite=n.colorWrite,this.precision=n.precision,this.polygonOffset=n.polygonOffset,this.polygonOffsetFactor=n.polygonOffsetFactor,this.polygonOffsetUnits=n.polygonOffsetUnits,this.dithering=n.dithering,this.alphaTest=n.alphaTest,this.alphaHash=n.alphaHash,this.alphaToCoverage=n.alphaToCoverage,this.premultipliedAlpha=n.premultipliedAlpha,this.forceSinglePass=n.forceSinglePass,this.visible=n.visible,this.toneMapped=n.toneMapped,this.userData=JSON.parse(JSON.stringify(n.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(n){n===!0&&this.version++}},hO=class extends vT{constructor(n){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new zo(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=c5e,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(n)}copy(n){return super.copy(n),this.color.copy(n.color),this.map=n.map,this.lightMap=n.lightMap,this.lightMapIntensity=n.lightMapIntensity,this.aoMap=n.aoMap,this.aoMapIntensity=n.aoMapIntensity,this.specularMap=n.specularMap,this.alphaMap=n.alphaMap,this.envMap=n.envMap,this.combine=n.combine,this.reflectivity=n.reflectivity,this.refractionRatio=n.refractionRatio,this.wireframe=n.wireframe,this.wireframeLinewidth=n.wireframeLinewidth,this.wireframeLinecap=n.wireframeLinecap,this.wireframeLinejoin=n.wireframeLinejoin,this.fog=n.fog,this}};var Nf=new Gt,Efe=new La,q1=class{constructor(n,r,c=!1){if(Array.isArray(n))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=n,this.itemSize=r,this.count=n!==void 0?n.length/r:0,this.normalized=c,this.usage=vyt,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=fT,this.version=0}onUploadCallback(){}set needsUpdate(n){n===!0&&this.version++}get updateRange(){return console.warn("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(n){return this.usage=n,this}addUpdateRange(n,r){this.updateRanges.push({start:n,count:r})}clearUpdateRanges(){this.updateRanges.length=0}copy(n){return this.name=n.name,this.array=new n.array.constructor(n.array),this.itemSize=n.itemSize,this.count=n.count,this.normalized=n.normalized,this.usage=n.usage,this.gpuType=n.gpuType,this}copyAt(n,r,c){n*=this.itemSize,c*=r.itemSize;for(let u=0,d=this.itemSize;u0&&(n.userData=this.userData),this.parameters!==void 0){let _=this.parameters;for(let x in _)_[x]!==void 0&&(n[x]=_[x]);return n}n.data={attributes:{}};let r=this.index;r!==null&&(n.data.index={type:r.array.constructor.name,array:Array.prototype.slice.call(r.array)});let c=this.attributes;for(let _ in c){let x=c[_];n.data.attributes[_]=x.toJSON(n.data)}let u={},d=!1;for(let _ in this.morphAttributes){let x=this.morphAttributes[_],T=[];for(let M=0,L=x.length;M0&&(u[_]=T,d=!0)}d&&(n.data.morphAttributes=u,n.data.morphTargetsRelative=this.morphTargetsRelative);let b=this.groups;b.length>0&&(n.data.groups=JSON.parse(JSON.stringify(b)));let w=this.boundingSphere;return w!==null&&(n.data.boundingSphere={center:w.center.toArray(),radius:w.radius}),n}clone(){return new this.constructor().copy(this)}copy(n){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let r={};this.name=n.name;let c=n.index;c!==null&&this.setIndex(c.clone(r));let u=n.attributes;for(let x in u){let T=u[x];this.setAttribute(x,T.clone(r))}let d=n.morphAttributes;for(let x in d){let T=[],M=d[x];for(let L=0,I=M.length;L0){let u=r[c[0]];if(u!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let d=0,b=u.length;d(n.far-n.near)**2))&&(Iyt.copy(d).invert(),U4.copy(n.ray).applyMatrix4(Iyt),!(c.boundingBox!==null&&U4.intersectsBox(c.boundingBox)===!1)&&this._computeIntersections(n,r,U4)))}_computeIntersections(n,r,c){let u,d=this.geometry,b=this.material,w=d.index,_=d.attributes.position,x=d.attributes.uv,T=d.attributes.uv1,M=d.attributes.normal,L=d.groups,I=d.drawRange;if(w!==null)if(Array.isArray(b))for(let D=0,F=L.length;Dr.far?null:{distance:x,point:Lfe.clone(),object:s}}function kfe(s,n,r,c,u,d,b,w,_,x){s.getVertexPosition(w,KB),s.getVertexPosition(_,JB),s.getVertexPosition(x,QB);let T=wan(s,n,r,c,KB,JB,QB,Pfe);if(T){u&&(Tfe.fromBufferAttribute(u,w),Cfe.fromBufferAttribute(u,_),Afe.fromBufferAttribute(u,x),T.uv=V4.getInterpolation(Pfe,KB,JB,QB,Tfe,Cfe,Afe,new La)),d&&(Tfe.fromBufferAttribute(d,w),Cfe.fromBufferAttribute(d,_),Afe.fromBufferAttribute(d,x),T.uv1=V4.getInterpolation(Pfe,KB,JB,QB,Tfe,Cfe,Afe,new La),T.uv2=T.uv1),b&&(Byt.fromBufferAttribute(b,w),Oyt.fromBufferAttribute(b,_),Nyt.fromBufferAttribute(b,x),T.normal=V4.getInterpolation(Pfe,KB,JB,QB,Byt,Oyt,Nyt,new Gt),T.normal.dot(c.direction)>0&&T.normal.multiplyScalar(-1));let M={a:w,b:_,c:x,normal:new Gt,materialIndex:0};V4.getNormal(KB,JB,QB,M.normal),T.face=M}return T}var X4=class s extends d2{constructor(n=1,r=1,c=1,u=1,d=1,b=1){super(),this.type="BoxGeometry",this.parameters={width:n,height:r,depth:c,widthSegments:u,heightSegments:d,depthSegments:b};let w=this;u=Math.floor(u),d=Math.floor(d),b=Math.floor(b);let _=[],x=[],T=[],M=[],L=0,I=0;D("z","y","x",-1,-1,c,r,n,b,d,0),D("z","y","x",1,-1,c,r,-n,b,d,1),D("x","z","y",1,1,n,c,r,u,b,2),D("x","z","y",1,-1,n,c,-r,u,b,3),D("x","y","z",1,-1,n,r,c,u,d,4),D("x","y","z",-1,-1,n,r,-c,u,d,5),this.setIndex(_),this.setAttribute("position",new Cm(x,3)),this.setAttribute("normal",new Cm(T,3)),this.setAttribute("uv",new Cm(M,2));function D(F,O,z,Z,H,te,se,ne,ue,Ce,Q){let me=te/ue,tt=se/Ce,st=te/2,at=se/2,Ne=ne/2,Qe=ue+1,ot=Ce+1,xt=0,fn=0,Xt=new Gt;for(let wn=0;wn0?1:-1,T.push(Xt.x,Xt.y,Xt.z),M.push(bi/ue),M.push(1-wn/Ce),xt+=1}}for(let wn=0;wn0&&(h.defines=this.defines),h.vertexShader=this.vertexShader,h.fragmentShader=this.fragmentShader,h.lights=this.lights,h.clipping=this.clipping;let p={};for(let m in this.extensions)this.extensions[m]===!0&&(p[m]=!0);return Object.keys(p).length>0&&(h.extensions=p),h}},get=class extends o1{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Bu,this.projectionMatrix=new Bu,this.projectionMatrixInverse=new Bu,this.coordinateSystem=Xx}copy(s,h){return super.copy(s,h),this.matrixWorldInverse.copy(s.matrixWorldInverse),this.projectionMatrix.copy(s.projectionMatrix),this.projectionMatrixInverse.copy(s.projectionMatrixInverse),this.coordinateSystem=s.coordinateSystem,this}getWorldDirection(s){return super.getWorldDirection(s).negate()}updateMatrixWorld(s){super.updateMatrixWorld(s),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(s,h){super.updateWorldMatrix(s,h),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},s1=class extends get{constructor(s=50,h=1,p=.1,m=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=s,this.zoom=1,this.near=p,this.far=m,this.focus=10,this.aspect=h,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(s,h){return super.copy(s,h),this.fov=s.fov,this.zoom=s.zoom,this.near=s.near,this.far=s.far,this.focus=s.focus,this.aspect=s.aspect,this.view=s.view===null?null:Object.assign({},s.view),this.filmGauge=s.filmGauge,this.filmOffset=s.filmOffset,this}setFocalLength(s){let h=.5*this.getFilmHeight()/s;this.fov=Cyt*2*Math.atan(h),this.updateProjectionMatrix()}getFocalLength(){let s=Math.tan(Qtt*.5*this.fov);return .5*this.getFilmHeight()/s}getEffectiveFOV(){return Cyt*2*Math.atan(Math.tan(Qtt*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(s,h,p,m,_,S){this.aspect=s/h,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=s,this.view.fullHeight=h,this.view.offsetX=p,this.view.offsetY=m,this.view.width=_,this.view.height=S,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let s=this.near,h=s*Math.tan(Qtt*.5*this.fov)/this.zoom,p=2*h,m=this.aspect*p,_=-.5*m,S=this.view;if(this.view!==null&&this.view.enabled){let I=S.fullWidth,N=S.fullHeight;_+=S.offsetX*m/I,h-=S.offsetY*p/N,m*=S.width/I,p*=S.height/N}let y=this.filmOffset;y!==0&&(_+=s*y/this.getFilmWidth()),this.projectionMatrix.makePerspective(_,_+m,h,h-p,s,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(s){let h=super.toJSON(s);return h.object.fov=this.fov,h.object.zoom=this.zoom,h.object.near=this.near,h.object.far=this.far,h.object.focus=this.focus,h.object.aspect=this.aspect,this.view!==null&&(h.object.view=Object.assign({},this.view)),h.object.filmGauge=this.filmGauge,h.object.filmOffset=this.filmOffset,h}},WI=-90,$I=1,Pyt=class extends o1{constructor(s,h,p){super(),this.type="CubeCamera",this.renderTarget=p,this.coordinateSystem=null,this.activeMipmapLevel=0;let m=new s1(WI,$I,s,h);m.layers=this.layers,this.add(m);let _=new s1(WI,$I,s,h);_.layers=this.layers,this.add(_);let S=new s1(WI,$I,s,h);S.layers=this.layers,this.add(S);let y=new s1(WI,$I,s,h);y.layers=this.layers,this.add(y);let I=new s1(WI,$I,s,h);I.layers=this.layers,this.add(I);let N=new s1(WI,$I,s,h);N.layers=this.layers,this.add(N)}updateCoordinateSystem(){let s=this.coordinateSystem,h=this.children.concat(),[p,m,_,S,y,I]=h;for(let N of h)this.remove(N);if(s===Xx)p.up.set(0,1,0),p.lookAt(1,0,0),m.up.set(0,1,0),m.lookAt(-1,0,0),_.up.set(0,0,-1),_.lookAt(0,1,0),S.up.set(0,0,1),S.lookAt(0,-1,0),y.up.set(0,1,0),y.lookAt(0,0,1),I.up.set(0,1,0),I.lookAt(0,0,-1);else if(s===oet)p.up.set(0,-1,0),p.lookAt(-1,0,0),m.up.set(0,-1,0),m.lookAt(1,0,0),_.up.set(0,0,1),_.lookAt(0,1,0),S.up.set(0,0,-1),S.lookAt(0,-1,0),y.up.set(0,-1,0),y.lookAt(0,0,1),I.up.set(0,-1,0),I.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+s);for(let N of h)this.add(N),N.updateMatrixWorld()}update(s,h){this.parent===null&&this.updateMatrixWorld();let{renderTarget:p,activeMipmapLevel:m}=this;this.coordinateSystem!==s.coordinateSystem&&(this.coordinateSystem=s.coordinateSystem,this.updateCoordinateSystem());let[_,S,y,I,N,B]=this.children,P=s.getRenderTarget(),U=s.getActiveCubeFace(),j=s.getActiveMipmapLevel(),V=s.xr.enabled;s.xr.enabled=!1;let et=p.texture.generateMipmaps;p.texture.generateMipmaps=!1,s.setRenderTarget(p,0,m),s.render(h,_),s.setRenderTarget(p,1,m),s.render(h,S),s.setRenderTarget(p,2,m),s.render(h,y),s.setRenderTarget(p,3,m),s.render(h,I),s.setRenderTarget(p,4,m),s.render(h,N),p.texture.generateMipmaps=et,s.setRenderTarget(p,5,m),s.render(h,B),s.setRenderTarget(P,U,j),s.xr.enabled=V,p.texture.needsPMREMUpdate=!0}},met=class extends Xw{constructor(s,h,p,m,_,S,y,I,N,B){s=s!==void 0?s:[],h=h!==void 0?h:QI,super(s,h,p,m,_,S,y,I,N,B),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(s){this.image=s}},Iyt=class extends Yx{constructor(s=1,h={}){super(s,s,h),this.isWebGLCubeRenderTarget=!0;let p={width:s,height:s,depth:1},m=[p,p,p,p,p,p];h.encoding!==void 0&&(gU("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),h.colorSpace=h.encoding===$A?Pd:gb),this.texture=new met(m,h.mapping,h.wrapS,h.wrapT,h.magFilter,h.minFilter,h.format,h.type,h.anisotropy,h.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=h.generateMipmaps!==void 0?h.generateMipmaps:!1,this.texture.minFilter=h.minFilter!==void 0?h.minFilter:pb}fromEquirectangularTexture(s,h){this.texture.type=h.type,this.texture.colorSpace=h.colorSpace,this.texture.generateMipmaps=h.generateMipmaps,this.texture.minFilter=h.minFilter,this.texture.magFilter=h.magFilter;let p={uniforms:{tEquirect:{value:null}},vertexShader:` +}`,K3=class extends vT{constructor(n){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=yan,this.fragmentShader=xan,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1,clipCullDistance:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,n!==void 0&&this.setValues(n)}copy(n){return super.copy(n),this.fragmentShader=n.fragmentShader,this.vertexShader=n.vertexShader,this.uniforms=dO(n.uniforms),this.uniformsGroups=van(n.uniformsGroups),this.defines=Object.assign({},n.defines),this.wireframe=n.wireframe,this.wireframeLinewidth=n.wireframeLinewidth,this.fog=n.fog,this.lights=n.lights,this.clipping=n.clipping,this.extensions=Object.assign({},n.extensions),this.glslVersion=n.glslVersion,this}toJSON(n){let r=super.toJSON(n);r.glslVersion=this.glslVersion,r.uniforms={};for(let u in this.uniforms){let b=this.uniforms[u].value;b&&b.isTexture?r.uniforms[u]={type:"t",value:b.toJSON(n).uuid}:b&&b.isColor?r.uniforms[u]={type:"c",value:b.getHex()}:b&&b.isVector2?r.uniforms[u]={type:"v2",value:b.toArray()}:b&&b.isVector3?r.uniforms[u]={type:"v3",value:b.toArray()}:b&&b.isVector4?r.uniforms[u]={type:"v4",value:b.toArray()}:b&&b.isMatrix3?r.uniforms[u]={type:"m3",value:b.toArray()}:b&&b.isMatrix4?r.uniforms[u]={type:"m4",value:b.toArray()}:r.uniforms[u]={value:b}}Object.keys(this.defines).length>0&&(r.defines=this.defines),r.vertexShader=this.vertexShader,r.fragmentShader=this.fragmentShader,r.lights=this.lights,r.clipping=this.clipping;let c={};for(let u in this.extensions)this.extensions[u]===!0&&(c[u]=!0);return Object.keys(c).length>0&&(r.extensions=c),r}},nhe=class extends pg{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Rl,this.projectionMatrix=new Rl,this.projectionMatrixInverse=new Rl,this.coordinateSystem=q3}copy(n,r){return super.copy(n,r),this.matrixWorldInverse.copy(n.matrixWorldInverse),this.projectionMatrix.copy(n.projectionMatrix),this.projectionMatrixInverse.copy(n.projectionMatrixInverse),this.coordinateSystem=n.coordinateSystem,this}getWorldDirection(n){return super.getWorldDirection(n).negate()}updateMatrixWorld(n){super.updateMatrixWorld(n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(n,r){super.updateWorldMatrix(n,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},dg=class extends nhe{constructor(n=50,r=1,c=.1,u=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=n,this.zoom=1,this.near=c,this.far=u,this.focus=10,this.aspect=r,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(n,r){return super.copy(n,r),this.fov=n.fov,this.zoom=n.zoom,this.near=n.near,this.far=n.far,this.focus=n.focus,this.aspect=n.aspect,this.view=n.view===null?null:Object.assign({},n.view),this.filmGauge=n.filmGauge,this.filmOffset=n.filmOffset,this}setFocalLength(n){let r=.5*this.getFilmHeight()/n;this.fov=P6e*2*Math.atan(r),this.updateProjectionMatrix()}getFocalLength(){let n=Math.tan(Gfe*.5*this.fov);return .5*this.getFilmHeight()/n}getEffectiveFOV(){return P6e*2*Math.atan(Math.tan(Gfe*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(n,r,c,u,d,b){this.aspect=n/r,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=n,this.view.fullHeight=r,this.view.offsetX=c,this.view.offsetY=u,this.view.width=d,this.view.height=b,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let n=this.near,r=n*Math.tan(Gfe*.5*this.fov)/this.zoom,c=2*r,u=this.aspect*c,d=-.5*u,b=this.view;if(this.view!==null&&this.view.enabled){let _=b.fullWidth,x=b.fullHeight;d+=b.offsetX*u/_,r-=b.offsetY*c/x,u*=b.width/_,c*=b.height/x}let w=this.filmOffset;w!==0&&(d+=n*w/this.getFilmWidth()),this.projectionMatrix.makePerspective(d,d+u,r,r-c,n,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(n){let r=super.toJSON(n);return r.object.fov=this.fov,r.object.zoom=this.zoom,r.object.near=this.near,r.object.far=this.far,r.object.focus=this.focus,r.object.aspect=this.aspect,this.view!==null&&(r.object.view=Object.assign({},this.view)),r.object.filmGauge=this.filmGauge,r.object.filmOffset=this.filmOffset,r}},eO=-90,tO=1,I6e=class extends pg{constructor(n,r,c){super(),this.type="CubeCamera",this.renderTarget=c,this.coordinateSystem=null,this.activeMipmapLevel=0;let u=new dg(eO,tO,n,r);u.layers=this.layers,this.add(u);let d=new dg(eO,tO,n,r);d.layers=this.layers,this.add(d);let b=new dg(eO,tO,n,r);b.layers=this.layers,this.add(b);let w=new dg(eO,tO,n,r);w.layers=this.layers,this.add(w);let _=new dg(eO,tO,n,r);_.layers=this.layers,this.add(_);let x=new dg(eO,tO,n,r);x.layers=this.layers,this.add(x)}updateCoordinateSystem(){let n=this.coordinateSystem,r=this.children.concat(),[c,u,d,b,w,_]=r;for(let x of r)this.remove(x);if(n===q3)c.up.set(0,1,0),c.lookAt(1,0,0),u.up.set(0,1,0),u.lookAt(-1,0,0),d.up.set(0,0,-1),d.lookAt(0,1,0),b.up.set(0,0,1),b.lookAt(0,-1,0),w.up.set(0,1,0),w.lookAt(0,0,1),_.up.set(0,1,0),_.lookAt(0,0,-1);else if(n===Xfe)c.up.set(0,-1,0),c.lookAt(-1,0,0),u.up.set(0,-1,0),u.lookAt(1,0,0),d.up.set(0,0,1),d.lookAt(0,1,0),b.up.set(0,0,-1),b.lookAt(0,-1,0),w.up.set(0,-1,0),w.lookAt(0,0,1),_.up.set(0,-1,0),_.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+n);for(let x of r)this.add(x),x.updateMatrixWorld()}update(n,r){this.parent===null&&this.updateMatrixWorld();let{renderTarget:c,activeMipmapLevel:u}=this;this.coordinateSystem!==n.coordinateSystem&&(this.coordinateSystem=n.coordinateSystem,this.updateCoordinateSystem());let[d,b,w,_,x,T]=this.children,M=n.getRenderTarget(),L=n.getActiveCubeFace(),I=n.getActiveMipmapLevel(),D=n.xr.enabled;n.xr.enabled=!1;let F=c.texture.generateMipmaps;c.texture.generateMipmaps=!1,n.setRenderTarget(c,0,u),n.render(r,d),n.setRenderTarget(c,1,u),n.render(r,b),n.setRenderTarget(c,2,u),n.render(r,w),n.setRenderTarget(c,3,u),n.render(r,_),n.setRenderTarget(c,4,u),n.render(r,x),c.texture.generateMipmaps=F,n.setRenderTarget(c,5,u),n.render(r,T),n.setRenderTarget(M,L,I),n.xr.enabled=D,c.texture.needsPMREMUpdate=!0}},ihe=class extends Tv{constructor(n,r,c,u,d,b,w,_,x,T){n=n!==void 0?n:[],r=r!==void 0?r:lO,super(n,r,c,u,d,b,w,_,x,T),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(n){this.image=n}},D6e=class extends Y3{constructor(n=1,r={}){super(n,n,r),this.isWebGLCubeRenderTarget=!0;let c={width:n,height:n,depth:1},u=[c,c,c,c,c,c];r.encoding!==void 0&&(RW("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===q4?Md:Bb),this.texture=new ihe(u,r.mapping,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=r.generateMipmaps!==void 0?r.generateMipmaps:!1,this.texture.minFilter=r.minFilter!==void 0?r.minFilter:Db}fromEquirectangularTexture(n,r){this.texture.type=r.type,this.texture.colorSpace=r.colorSpace,this.texture.generateMipmaps=r.generateMipmaps,this.texture.minFilter=r.minFilter,this.texture.magFilter=r.magFilter;let c={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; @@ -100,9 +6457,9 @@ function print() { __p += __j.call(arguments, '') } gl_FragColor = texture2D( tEquirect, sampleUV ); } - `},m=new VA(5,5,5),_=new Jx({name:"CubemapFromEquirect",uniforms:iR(p.uniforms),vertexShader:p.vertexShader,fragmentShader:p.fragmentShader,side:gg,blending:rS});_.uniforms.tEquirect.value=h;let S=new pg(m,_),y=h.minFilter;return h.minFilter===bU&&(h.minFilter=pb),new Pyt(1,10,this).update(s,S),h.minFilter=y,S.geometry.dispose(),S.material.dispose(),this}clear(s,h,p,m){let _=s.getRenderTarget();for(let S=0;S<6;S++)s.setRenderTarget(this,S),s.clear(h,p,m);s.setRenderTarget(_)}},hyt=new Ge,VEe=new Ge,qEe=new Ko,qx=class{constructor(s=new Ge(1,0,0),h=0){this.isPlane=!0,this.normal=s,this.constant=h}set(s,h){return this.normal.copy(s),this.constant=h,this}setComponents(s,h,p,m){return this.normal.set(s,h,p),this.constant=m,this}setFromNormalAndCoplanarPoint(s,h){return this.normal.copy(s),this.constant=-h.dot(this.normal),this}setFromCoplanarPoints(s,h,p){let m=hyt.subVectors(p,h).cross(VEe.subVectors(s,h)).normalize();return this.setFromNormalAndCoplanarPoint(m,s),this}copy(s){return this.normal.copy(s.normal),this.constant=s.constant,this}normalize(){let s=1/this.normal.length();return this.normal.multiplyScalar(s),this.constant*=s,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(s){return this.normal.dot(s)+this.constant}distanceToSphere(s){return this.distanceToPoint(s.center)-s.radius}projectPoint(s,h){return h.copy(s).addScaledVector(this.normal,-this.distanceToPoint(s))}intersectLine(s,h){let p=s.delta(hyt),m=this.normal.dot(p);if(m===0)return this.distanceToPoint(s.start)===0?h.copy(s.start):null;let _=-(s.start.dot(this.normal)+this.constant)/m;return _<0||_>1?null:h.copy(s.start).addScaledVector(p,_)}intersectsLine(s){let h=this.distanceToPoint(s.start),p=this.distanceToPoint(s.end);return h<0&&p>0||p<0&&h>0}intersectsBox(s){return s.intersectsPlane(this)}intersectsSphere(s){return s.intersectsPlane(this)}coplanarPoint(s){return s.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(s,h){let p=h||qEe.getNormalMatrix(s),m=this.coplanarPoint(hyt).applyMatrix4(s),_=this.normal.applyMatrix3(p).normalize();return this.constant=-m.dot(_),this}translate(s){return this.constant-=s.dot(this.normal),this}equals(s){return s.normal.equals(this.normal)&&s.constant===this.constant}clone(){return new this.constructor().copy(this)}},FA=new uS,Wtt=new Ge,yU=class{constructor(s=new qx,h=new qx,p=new qx,m=new qx,_=new qx,S=new qx){this.planes=[s,h,p,m,_,S]}set(s,h,p,m,_,S){let y=this.planes;return y[0].copy(s),y[1].copy(h),y[2].copy(p),y[3].copy(m),y[4].copy(_),y[5].copy(S),this}copy(s){let h=this.planes;for(let p=0;p<6;p++)h[p].copy(s.planes[p]);return this}setFromProjectionMatrix(s,h=Xx){let p=this.planes,m=s.elements,_=m[0],S=m[1],y=m[2],I=m[3],N=m[4],B=m[5],P=m[6],U=m[7],j=m[8],V=m[9],et=m[10],Q=m[11],X=m[12],gt=m[13],ft=m[14],xt=m[15];if(p[0].setComponents(I-_,U-N,Q-j,xt-X).normalize(),p[1].setComponents(I+_,U+N,Q+j,xt+X).normalize(),p[2].setComponents(I+S,U+B,Q+V,xt+gt).normalize(),p[3].setComponents(I-S,U-B,Q-V,xt-gt).normalize(),p[4].setComponents(I-y,U-P,Q-et,xt-ft).normalize(),h===Xx)p[5].setComponents(I+y,U+P,Q+et,xt+ft).normalize();else if(h===oet)p[5].setComponents(y,P,et,ft).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+h);return this}intersectsObject(s){if(s.boundingSphere!==void 0)s.boundingSphere===null&&s.computeBoundingSphere(),FA.copy(s.boundingSphere).applyMatrix4(s.matrixWorld);else{let h=s.geometry;h.boundingSphere===null&&h.computeBoundingSphere(),FA.copy(h.boundingSphere).applyMatrix4(s.matrixWorld)}return this.intersectsSphere(FA)}intersectsSprite(s){return FA.center.set(0,0,0),FA.radius=.7071067811865476,FA.applyMatrix4(s.matrixWorld),this.intersectsSphere(FA)}intersectsSphere(s){let h=this.planes,p=s.center,m=-s.radius;for(let _=0;_<6;_++)if(h[_].distanceToPoint(p)0?s.max.x:s.min.x,Wtt.y=m.normal.y>0?s.max.y:s.min.y,Wtt.z=m.normal.z>0?s.max.z:s.min.z,m.distanceToPoint(Wtt)<0)return!1}return!0}containsPoint(s){let h=this.planes;for(let p=0;p<6;p++)if(h[p].distanceToPoint(s)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function aKt(){let d=null,s=!1,h=null,p=null;function m(_,S){h(_,S),p=d.requestAnimationFrame(m)}return{start:function(){s!==!0&&h!==null&&(p=d.requestAnimationFrame(m),s=!0)},stop:function(){d.cancelAnimationFrame(p),s=!1},setAnimationLoop:function(_){h=_},setContext:function(_){d=_}}}function XEe(d,s){let h=s.isWebGL2,p=new WeakMap;function m(N,B){let P=N.array,U=N.usage,j=P.byteLength,V=d.createBuffer();d.bindBuffer(B,V),d.bufferData(B,P,U),N.onUploadCallback();let et;if(P instanceof Float32Array)et=d.FLOAT;else if(P instanceof Uint16Array)if(N.isFloat16BufferAttribute)if(h)et=d.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else et=d.UNSIGNED_SHORT;else if(P instanceof Int16Array)et=d.SHORT;else if(P instanceof Uint32Array)et=d.UNSIGNED_INT;else if(P instanceof Int32Array)et=d.INT;else if(P instanceof Int8Array)et=d.BYTE;else if(P instanceof Uint8Array)et=d.UNSIGNED_BYTE;else if(P instanceof Uint8ClampedArray)et=d.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+P);return{buffer:V,type:et,bytesPerElement:P.BYTES_PER_ELEMENT,version:N.version,size:j}}function _(N,B,P){let U=B.array,j=B._updateRange,V=B.updateRanges;if(d.bindBuffer(P,N),j.count===-1&&V.length===0&&d.bufferSubData(P,0,U),V.length!==0){for(let et=0,Q=V.length;et1?null:r.copy(n.start).addScaledVector(c,d)}intersectsLine(n){let r=this.distanceToPoint(n.start),c=this.distanceToPoint(n.end);return r<0&&c>0||c<0&&r>0}intersectsBox(n){return n.intersectsPlane(this)}intersectsSphere(n){return n.intersectsPlane(this)}coplanarPoint(n){return n.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(n,r){let c=r||San.getNormalMatrix(n),u=this.coplanarPoint(d6e).applyMatrix4(n),d=this.normal.applyMatrix3(c).normalize();return this.constant=-u.dot(d),this}translate(n){return this.constant-=n.dot(this.normal),this}equals(n){return n.normal.equals(this.normal)&&n.constant===this.constant}clone(){return new this.constructor().copy(this)}},z4=new wT,Rfe=new Gt,FW=class{constructor(n=new H3,r=new H3,c=new H3,u=new H3,d=new H3,b=new H3){this.planes=[n,r,c,u,d,b]}set(n,r,c,u,d,b){let w=this.planes;return w[0].copy(n),w[1].copy(r),w[2].copy(c),w[3].copy(u),w[4].copy(d),w[5].copy(b),this}copy(n){let r=this.planes;for(let c=0;c<6;c++)r[c].copy(n.planes[c]);return this}setFromProjectionMatrix(n,r=q3){let c=this.planes,u=n.elements,d=u[0],b=u[1],w=u[2],_=u[3],x=u[4],T=u[5],M=u[6],L=u[7],I=u[8],D=u[9],F=u[10],O=u[11],z=u[12],Z=u[13],H=u[14],te=u[15];if(c[0].setComponents(_-d,L-x,O-I,te-z).normalize(),c[1].setComponents(_+d,L+x,O+I,te+z).normalize(),c[2].setComponents(_+b,L+T,O+D,te+Z).normalize(),c[3].setComponents(_-b,L-T,O-D,te-Z).normalize(),c[4].setComponents(_-w,L-M,O-F,te-H).normalize(),r===q3)c[5].setComponents(_+w,L+M,O+F,te+H).normalize();else if(r===Xfe)c[5].setComponents(w,M,F,H).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+r);return this}intersectsObject(n){if(n.boundingSphere!==void 0)n.boundingSphere===null&&n.computeBoundingSphere(),z4.copy(n.boundingSphere).applyMatrix4(n.matrixWorld);else{let r=n.geometry;r.boundingSphere===null&&r.computeBoundingSphere(),z4.copy(r.boundingSphere).applyMatrix4(n.matrixWorld)}return this.intersectsSphere(z4)}intersectsSprite(n){return z4.center.set(0,0,0),z4.radius=.7071067811865476,z4.applyMatrix4(n.matrixWorld),this.intersectsSphere(z4)}intersectsSphere(n){let r=this.planes,c=n.center,u=-n.radius;for(let d=0;d<6;d++)if(r[d].distanceToPoint(c)0?n.max.x:n.min.x,Rfe.y=u.normal.y>0?n.max.y:n.min.y,Rfe.z=u.normal.z>0?n.max.z:n.min.z,u.distanceToPoint(Rfe)<0)return!1}return!0}containsPoint(n){let r=this.planes;for(let c=0;c<6;c++)if(r[c].distanceToPoint(n)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function L2t(){let s=null,n=!1,r=null,c=null;function u(d,b){r(d,b),c=s.requestAnimationFrame(u)}return{start:function(){n!==!0&&r!==null&&(c=s.requestAnimationFrame(u),n=!0)},stop:function(){s.cancelAnimationFrame(c),n=!1},setAnimationLoop:function(d){r=d},setContext:function(d){s=d}}}function Man(s,n){let r=n.isWebGL2,c=new WeakMap;function u(x,T){let M=x.array,L=x.usage,I=M.byteLength,D=s.createBuffer();s.bindBuffer(T,D),s.bufferData(T,M,L),x.onUploadCallback();let F;if(M instanceof Float32Array)F=s.FLOAT;else if(M instanceof Uint16Array)if(x.isFloat16BufferAttribute)if(r)F=s.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else F=s.UNSIGNED_SHORT;else if(M instanceof Int16Array)F=s.SHORT;else if(M instanceof Uint32Array)F=s.UNSIGNED_INT;else if(M instanceof Int32Array)F=s.INT;else if(M instanceof Int8Array)F=s.BYTE;else if(M instanceof Uint8Array)F=s.UNSIGNED_BYTE;else if(M instanceof Uint8ClampedArray)F=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+M);return{buffer:D,type:F,bytesPerElement:M.BYTES_PER_ELEMENT,version:x.version,size:I}}function d(x,T,M){let L=T.array,I=T._updateRange,D=T.updateRanges;if(s.bindBuffer(M,x),I.count===-1&&D.length===0&&s.bufferSubData(M,0,L),D.length!==0){for(let F=0,O=D.length;F 0 +#endif`,Gan=`#if NUM_CLIPPING_PLANES > 0 vec4 plane; #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { @@ -299,26 +6656,26 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve #pragma unroll_loop_end if ( clipped ) discard; #endif -#endif`,hSe=`#if NUM_CLIPPING_PLANES > 0 +#endif`,jan=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; -#endif`,fSe=`#if NUM_CLIPPING_PLANES > 0 +#endif`,$an=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; -#endif`,dSe=`#if NUM_CLIPPING_PLANES > 0 +#endif`,Van=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; -#endif`,pSe=`#if defined( USE_COLOR_ALPHA ) +#endif`,Wan=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; -#endif`,gSe=`#if defined( USE_COLOR_ALPHA ) +#endif`,Han=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; -#endif`,mSe=`#if defined( USE_COLOR_ALPHA ) +#endif`,qan=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) varying vec3 vColor; -#endif`,bSe=`#if defined( USE_COLOR_ALPHA ) +#endif`,Xan=`#if defined( USE_COLOR_ALPHA ) vColor = vec4( 1.0 ); #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) vColor = vec3( 1.0 ); @@ -328,7 +6685,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve #endif #ifdef USE_INSTANCING_COLOR vColor.xyz *= instanceColor.xyz; -#endif`,wSe=`#define PI 3.141592653589793 +#endif`,Yan=`#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 @@ -406,7 +6763,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); -} // validated`,vSe=`#ifdef ENVMAP_TYPE_CUBE_UV +} // validated`,Zan=`#ifdef ENVMAP_TYPE_CUBE_UV #define cubeUV_minMipLevel 4.0 #define cubeUV_minTileSize 16.0 float getFace( vec3 direction ) { @@ -499,7 +6856,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { return vec4( mix( color0, color1, mipF ), 1.0 ); } } -#endif`,_Se=`vec3 transformedNormal = objectNormal; +#endif`,Kan=`vec3 transformedNormal = objectNormal; #ifdef USE_TANGENT vec3 transformedTangent = objectTangent; #endif @@ -528,18 +6885,18 @@ transformedNormal = normalMatrix * transformedNormal; #ifdef FLIP_SIDED transformedTangent = - transformedTangent; #endif -#endif`,ySe=`#ifdef USE_DISPLACEMENTMAP +#endif`,Jan=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; -#endif`,xSe=`#ifdef USE_DISPLACEMENTMAP +#endif`,Qan=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); -#endif`,MSe=`#ifdef USE_EMISSIVEMAP +#endif`,ecn=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); totalEmissiveRadiance *= emissiveColor.rgb; -#endif`,ESe=`#ifdef USE_EMISSIVEMAP +#endif`,tcn=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; -#endif`,SSe="gl_FragColor = linearToOutputTexel( gl_FragColor );",TSe=` +#endif`,ncn="gl_FragColor = linearToOutputTexel( gl_FragColor );",icn=` const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3( vec3( 0.8224621, 0.177538, 0.0 ), vec3( 0.0331941, 0.9668058, 0.0 ), @@ -567,7 +6924,7 @@ vec4 LinearToLinear( in vec4 value ) { } vec4 LinearTosRGB( in vec4 value ) { return sRGBTransferOETF( value ); -}`,CSe=`#ifdef USE_ENVMAP +}`,rcn=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { @@ -596,7 +6953,7 @@ vec4 LinearTosRGB( in vec4 value ) { #elif defined( ENVMAP_BLENDING_ADD ) outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif -#endif`,ASe=`#ifdef USE_ENVMAP +#endif`,scn=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; #ifdef ENVMAP_TYPE_CUBE @@ -605,7 +6962,7 @@ vec4 LinearTosRGB( in vec4 value ) { uniform sampler2D envMap; #endif -#endif`,kSe=`#ifdef USE_ENVMAP +#endif`,ocn=`#ifdef USE_ENVMAP uniform float reflectivity; #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS @@ -616,7 +6973,7 @@ vec4 LinearTosRGB( in vec4 value ) { #else varying vec3 vReflect; #endif -#endif`,LSe=`#ifdef USE_ENVMAP +#endif`,acn=`#ifdef USE_ENVMAP #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif @@ -627,7 +6984,7 @@ vec4 LinearTosRGB( in vec4 value ) { varying vec3 vReflect; uniform float refractionRatio; #endif -#endif`,PSe=`#ifdef USE_ENVMAP +#endif`,ccn=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vWorldPosition = worldPosition.xyz; #else @@ -644,18 +7001,18 @@ vec4 LinearTosRGB( in vec4 value ) { vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); #endif #endif -#endif`,ISe=`#ifdef USE_FOG +#endif`,lcn=`#ifdef USE_FOG vFogDepth = - mvPosition.z; -#endif`,RSe=`#ifdef USE_FOG +#endif`,ucn=`#ifdef USE_FOG varying float vFogDepth; -#endif`,DSe=`#ifdef USE_FOG +#endif`,fcn=`#ifdef USE_FOG #ifdef FOG_EXP2 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); #else float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); #endif gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); -#endif`,NSe=`#ifdef USE_FOG +#endif`,hcn=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 @@ -664,7 +7021,7 @@ vec4 LinearTosRGB( in vec4 value ) { uniform float fogNear; uniform float fogFar; #endif -#endif`,OSe=`#ifdef USE_GRADIENTMAP +#endif`,dcn=`#ifdef USE_GRADIENTMAP uniform sampler2D gradientMap; #endif vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { @@ -676,16 +7033,16 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { vec2 fw = fwidth( coord ) * 0.5; return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); #endif -}`,BSe=`#ifdef USE_LIGHTMAP +}`,pcn=`#ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; reflectedLight.indirectDiffuse += lightMapIrradiance; -#endif`,FSe=`#ifdef USE_LIGHTMAP +#endif`,gcn=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; -#endif`,USe=`LambertMaterial material; +#endif`,mcn=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; -material.specularStrength = specularStrength;`,zSe=`varying vec3 vViewPosition; +material.specularStrength = specularStrength;`,bcn=`varying vec3 vViewPosition; struct LambertMaterial { vec3 diffuseColor; float specularStrength; @@ -699,7 +7056,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Lambert -#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,jSe=`uniform bool receiveShadow; +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,wcn=`uniform bool receiveShadow; uniform vec3 ambientLightColor; #if defined( USE_LIGHT_PROBES ) uniform vec3 lightProbe[ 9 ]; @@ -822,7 +7179,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); return irradiance; } -#endif`,HSe=`#ifdef USE_ENVMAP +#endif`,vcn=`#ifdef USE_ENVMAP vec3 getIBLIrradiance( const in vec3 normal ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); @@ -855,8 +7212,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi #endif } #endif -#endif`,GSe=`ToonMaterial material; -material.diffuseColor = diffuseColor.rgb;`,WSe=`varying vec3 vViewPosition; +#endif`,_cn=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,ycn=`varying vec3 vViewPosition; struct ToonMaterial { vec3 diffuseColor; }; @@ -868,11 +7225,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon -#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,$Se=`BlinnPhongMaterial material; +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,xcn=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; -material.specularStrength = specularStrength;`,VSe=`varying vec3 vViewPosition; +material.specularStrength = specularStrength;`,Ecn=`varying vec3 vViewPosition; struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; @@ -889,7 +7246,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_BlinnPhong -#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,qSe=`PhysicalMaterial material; +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Scn=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); @@ -972,7 +7329,7 @@ material.roughness = min( material.roughness, 1.0 ); material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; -#endif`,XSe=`struct PhysicalMaterial { +#endif`,Mcn=`struct PhysicalMaterial { vec3 diffuseColor; float roughness; vec3 specularColor; @@ -1272,7 +7629,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); -}`,ZSe=` +}`,Tcn=` vec3 geometryPosition = - vViewPosition; vec3 geometryNormal = normal; vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); @@ -1387,7 +7744,7 @@ IncidentLight directLight; #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); -#endif`,YSe=`#if defined( RE_IndirectDiffuse ) +#endif`,Ccn=`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; @@ -1406,25 +7763,25 @@ IncidentLight directLight; #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); #endif -#endif`,KSe=`#if defined( RE_IndirectDiffuse ) +#endif`,Acn=`#if defined( RE_IndirectDiffuse ) RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); -#endif`,JSe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) +#endif`,Pcn=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; -#endif`,QSe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) +#endif`,Lcn=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; -#endif`,tTe=`#ifdef USE_LOGDEPTHBUF +#endif`,kcn=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT varying float vFragDepth; varying float vIsPerspective; #else uniform float logDepthBufFC; #endif -#endif`,eTe=`#ifdef USE_LOGDEPTHBUF +#endif`,Rcn=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); @@ -1434,16 +7791,16 @@ IncidentLight directLight; gl_Position.z *= gl_Position.w; } #endif -#endif`,nTe=`#ifdef USE_MAP +#endif`,Icn=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w ); #endif diffuseColor *= sampledDiffuseColor; -#endif`,iTe=`#ifdef USE_MAP +#endif`,Dcn=`#ifdef USE_MAP uniform sampler2D map; -#endif`,rTe=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) +#endif`,Bcn=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) #if defined( USE_POINTS_UV ) vec2 uv = vUv; #else @@ -1455,7 +7812,7 @@ IncidentLight directLight; #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; -#endif`,sTe=`#if defined( USE_POINTS_UV ) +#endif`,Ocn=`#if defined( USE_POINTS_UV ) varying vec2 vUv; #else #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) @@ -1467,13 +7824,13 @@ IncidentLight directLight; #endif #ifdef USE_ALPHAMAP uniform sampler2D alphaMap; -#endif`,oTe=`float metalnessFactor = metalness; +#endif`,Ncn=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; -#endif`,cTe=`#ifdef USE_METALNESSMAP +#endif`,Fcn=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; -#endif`,aTe=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE ) +#endif`,Ucn=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE ) vColor *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { #if defined( USE_COLOR_ALPHA ) @@ -1482,7 +7839,7 @@ IncidentLight directLight; if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; #endif } -#endif`,uTe=`#ifdef USE_MORPHNORMALS +#endif`,zcn=`#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { @@ -1494,7 +7851,7 @@ IncidentLight directLight; objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; #endif -#endif`,lTe=`#ifdef USE_MORPHTARGETS +#endif`,Gcn=`#ifdef USE_MORPHTARGETS uniform float morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; @@ -1514,7 +7871,7 @@ IncidentLight directLight; uniform float morphTargetInfluences[ 4 ]; #endif #endif -#endif`,hTe=`#ifdef USE_MORPHTARGETS +#endif`,jcn=`#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { @@ -1532,7 +7889,7 @@ IncidentLight directLight; transformed += morphTarget7 * morphTargetInfluences[ 7 ]; #endif #endif -#endif`,fTe=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#endif`,$cn=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; #ifdef FLAT_SHADED vec3 fdx = dFdx( vViewPosition ); vec3 fdy = dFdy( vViewPosition ); @@ -1573,7 +7930,7 @@ IncidentLight directLight; tbn2[1] *= faceDirection; #endif #endif -vec3 nonPerturbedNormal = normal;`,dTe=`#ifdef USE_NORMALMAP_OBJECTSPACE +vec3 nonPerturbedNormal = normal;`,Vcn=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; @@ -1588,25 +7945,25 @@ vec3 nonPerturbedNormal = normal;`,dTe=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = normalize( tbn * mapN ); #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); -#endif`,pTe=`#ifndef FLAT_SHADED +#endif`,Wcn=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif -#endif`,gTe=`#ifndef FLAT_SHADED +#endif`,Hcn=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif -#endif`,mTe=`#ifndef FLAT_SHADED +#endif`,qcn=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif -#endif`,bTe=`#ifdef USE_NORMALMAP +#endif`,Xcn=`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif @@ -1628,13 +7985,13 @@ vec3 nonPerturbedNormal = normal;`,dTe=`#ifdef USE_NORMALMAP_OBJECTSPACE float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); return mat3( T * scale, B * scale, N ); } -#endif`,wTe=`#ifdef USE_CLEARCOAT +#endif`,Ycn=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; -#endif`,vTe=`#ifdef USE_CLEARCOAT_NORMALMAP +#endif`,Zcn=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); -#endif`,_Te=`#ifdef USE_CLEARCOATMAP +#endif`,Kcn=`#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP @@ -1643,18 +8000,18 @@ vec3 nonPerturbedNormal = normal;`,dTe=`#ifdef USE_NORMALMAP_OBJECTSPACE #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; -#endif`,yTe=`#ifdef USE_IRIDESCENCEMAP +#endif`,Jcn=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; -#endif`,xTe=`#ifdef OPAQUE +#endif`,Qcn=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif -gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,MTe=`vec3 packNormalToRGB( const in vec3 normal ) { +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,eln=`vec3 packNormalToRGB( const in vec3 normal ) { return normalize( normal ) * 0.5 + 0.5; } vec3 unpackRGBToNormal( const in vec3 rgb ) { @@ -1695,9 +8052,9 @@ float viewZToPerspectiveDepth( const in float viewZ, const in float near, const } float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { return ( near * far ) / ( ( far - near ) * depth - far ); -}`,ETe=`#ifdef PREMULTIPLIED_ALPHA +}`,tln=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; -#endif`,STe=`vec4 mvPosition = vec4( transformed, 1.0 ); +#endif`,nln=`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING mvPosition = batchingMatrix * mvPosition; #endif @@ -1705,22 +8062,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; -gl_Position = projectionMatrix * mvPosition;`,TTe=`#ifdef DITHERING +gl_Position = projectionMatrix * mvPosition;`,iln=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); -#endif`,CTe=`#ifdef DITHERING +#endif`,rln=`#ifdef DITHERING vec3 dithering( vec3 color ) { float grid_position = rand( gl_FragCoord.xy ); vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); return color + dither_shift_RGB; } -#endif`,ATe=`float roughnessFactor = roughness; +#endif`,sln=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; -#endif`,kTe=`#ifdef USE_ROUGHNESSMAP +#endif`,oln=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; -#endif`,LTe=`#if NUM_SPOT_LIGHT_COORDS > 0 +#endif`,aln=`#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #if NUM_SPOT_LIGHT_MAPS > 0 @@ -1897,7 +8254,7 @@ gl_Position = projectionMatrix * mvPosition;`,TTe=`#ifdef DITHERING return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); #endif } -#endif`,PTe=`#if NUM_SPOT_LIGHT_COORDS > 0 +#endif`,cln=`#if NUM_SPOT_LIGHT_COORDS > 0 uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif @@ -1935,7 +8292,7 @@ gl_Position = projectionMatrix * mvPosition;`,TTe=`#ifdef DITHERING }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif -#endif`,ITe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) +#endif`,lln=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); vec4 shadowWorldPosition; #endif @@ -1967,7 +8324,7 @@ gl_Position = projectionMatrix * mvPosition;`,TTe=`#ifdef DITHERING vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end -#endif`,RTe=`float getShadowMask() { +#endif`,uln=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 @@ -1999,12 +8356,12 @@ gl_Position = projectionMatrix * mvPosition;`,TTe=`#ifdef DITHERING #endif #endif return shadow; -}`,DTe=`#ifdef USE_SKINNING +}`,fln=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); -#endif`,NTe=`#ifdef USE_SKINNING +#endif`,hln=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; @@ -2019,7 +8376,7 @@ gl_Position = projectionMatrix * mvPosition;`,TTe=`#ifdef DITHERING vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); return mat4( v1, v2, v3, v4 ); } -#endif`,OTe=`#ifdef USE_SKINNING +#endif`,dln=`#ifdef USE_SKINNING vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); vec4 skinned = vec4( 0.0 ); skinned += boneMatX * skinVertex * skinWeight.x; @@ -2027,7 +8384,7 @@ gl_Position = projectionMatrix * mvPosition;`,TTe=`#ifdef DITHERING skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; -#endif`,BTe=`#ifdef USE_SKINNING +#endif`,pln=`#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; @@ -2038,17 +8395,17 @@ gl_Position = projectionMatrix * mvPosition;`,TTe=`#ifdef DITHERING #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif -#endif`,FTe=`float specularStrength; +#endif`,gln=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; -#endif`,UTe=`#ifdef USE_SPECULARMAP +#endif`,mln=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; -#endif`,zTe=`#if defined( TONE_MAPPING ) +#endif`,bln=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); -#endif`,jTe=`#ifndef saturate +#endif`,wln=`#ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; @@ -2129,7 +8486,7 @@ vec3 AgXToneMapping( vec3 color ) { color = LINEAR_REC2020_TO_LINEAR_SRGB * color; return color; } -vec3 CustomToneMapping( vec3 color ) { return color; }`,HTe=`#ifdef USE_TRANSMISSION +vec3 CustomToneMapping( vec3 color ) { return color; }`,vln=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; @@ -2150,7 +8507,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,HTe=`#ifdef USE_TRANSMIS material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); -#endif`,GTe=`#ifdef USE_TRANSMISSION +#endif`,_ln=`#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; @@ -2256,7 +8613,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,HTe=`#ifdef USE_TRANSMIS float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); } -#endif`,WTe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,yln=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP @@ -2326,7 +8683,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,HTe=`#ifdef USE_TRANSMIS #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; -#endif`,$Te=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,xln=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP @@ -2420,7 +8777,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,HTe=`#ifdef USE_TRANSMIS #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; -#endif`,VTe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,Eln=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) vUv = vec3( uv, 1 ).xy; #endif #ifdef USE_MAP @@ -2491,7 +8848,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,HTe=`#ifdef USE_TRANSMIS #endif #ifdef USE_THICKNESSMAP vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; -#endif`,qTe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 +#endif`,Sln=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING worldPosition = batchingMatrix * worldPosition; @@ -2500,12 +8857,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,HTe=`#ifdef USE_TRANSMIS worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; -#endif`,XTe=`varying vec2 vUv; +#endif`,Mln=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); -}`,ZTe=`uniform sampler2D t2D; +}`,Tln=`uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { @@ -2517,14 +8874,14 @@ void main() { gl_FragColor = texColor; #include #include -}`,YTe=`varying vec3 vWorldDirection; +}`,Cln=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; -}`,KTe=`#ifdef ENVMAP_TYPE_CUBE +}`,Aln=`#ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #elif defined( ENVMAP_TYPE_CUBE_UV ) uniform sampler2D envMap; @@ -2546,14 +8903,14 @@ void main() { gl_FragColor = texColor; #include #include -}`,JTe=`varying vec3 vWorldDirection; +}`,Pln=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; -}`,QTe=`uniform samplerCube tCube; +}`,Lln=`uniform samplerCube tCube; uniform float tFlip; uniform float opacity; varying vec3 vWorldDirection; @@ -2563,7 +8920,7 @@ void main() { gl_FragColor.a *= opacity; #include #include -}`,tCe=`#include +}`,kln=`#include #include #include #include @@ -2589,7 +8946,7 @@ void main() { #include #include vHighPrecisionZW = gl_Position.zw; -}`,eCe=`#if DEPTH_PACKING == 3200 +}`,Rln=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include @@ -2619,7 +8976,7 @@ void main() { #elif DEPTH_PACKING == 3201 gl_FragColor = packDepthToRGBA( fragCoordZ ); #endif -}`,nCe=`#define DISTANCE +}`,Iln=`#define DISTANCE varying vec3 vWorldPosition; #include #include @@ -2645,7 +9002,7 @@ void main() { #include #include vWorldPosition = worldPosition.xyz; -}`,iCe=`#define DISTANCE +}`,Dln=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; @@ -2669,13 +9026,13 @@ void main () { dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); -}`,rCe=`varying vec3 vWorldDirection; +}`,Bln=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include -}`,sCe=`uniform sampler2D tEquirect; +}`,Oln=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { @@ -2684,7 +9041,7 @@ void main() { gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include -}`,oCe=`uniform float scale; +}`,Nln=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include @@ -2705,7 +9062,7 @@ void main() { #include #include #include -}`,cCe=`uniform vec3 diffuse; +}`,Fln=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; @@ -2733,7 +9090,7 @@ void main() { #include #include #include -}`,aCe=`#include +}`,Uln=`#include #include #include #include @@ -2764,7 +9121,7 @@ void main() { #include #include #include -}`,uCe=`uniform vec3 diffuse; +}`,zln=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; @@ -2812,7 +9169,7 @@ void main() { #include #include #include -}`,lCe=`#define LAMBERT +}`,Gln=`#define LAMBERT varying vec3 vViewPosition; #include #include @@ -2850,7 +9207,7 @@ void main() { #include #include #include -}`,hCe=`#define LAMBERT +}`,jln=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; @@ -2907,7 +9264,7 @@ void main() { #include #include #include -}`,fCe=`#define MATCAP +}`,$ln=`#define MATCAP varying vec3 vViewPosition; #include #include @@ -2940,7 +9297,7 @@ void main() { #include #include vViewPosition = - mvPosition.xyz; -}`,dCe=`#define MATCAP +}`,Vln=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; @@ -2986,7 +9343,7 @@ void main() { #include #include #include -}`,pCe=`#define NORMAL +}`,Wln=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif @@ -3018,7 +9375,7 @@ void main() { #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) vViewPosition = - mvPosition.xyz; #endif -}`,gCe=`#define NORMAL +}`,Hln=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; @@ -3039,7 +9396,7 @@ void main() { #ifdef OPAQUE gl_FragColor.a = 1.0; #endif -}`,mCe=`#define PHONG +}`,qln=`#define PHONG varying vec3 vViewPosition; #include #include @@ -3077,7 +9434,7 @@ void main() { #include #include #include -}`,bCe=`#define PHONG +}`,Xln=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; @@ -3136,7 +9493,7 @@ void main() { #include #include #include -}`,wCe=`#define STANDARD +}`,Yln=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; @@ -3178,7 +9535,7 @@ void main() { #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif -}`,vCe=`#define STANDARD +}`,Zln=`#define STANDARD #ifdef PHYSICAL #define IOR #define USE_SPECULAR @@ -3300,7 +9657,7 @@ void main() { #include #include #include -}`,_Ce=`#define TOON +}`,Kln=`#define TOON varying vec3 vViewPosition; #include #include @@ -3336,7 +9693,7 @@ void main() { #include #include #include -}`,yCe=`#define TOON +}`,Jln=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; @@ -3389,7 +9746,7 @@ void main() { #include #include #include -}`,xCe=`uniform float size; +}`,Qln=`uniform float size; uniform float scale; #include #include @@ -3419,7 +9776,7 @@ void main() { #include #include #include -}`,MCe=`uniform vec3 diffuse; +}`,eun=`uniform vec3 diffuse; uniform float opacity; #include #include @@ -3444,7 +9801,7 @@ void main() { #include #include #include -}`,ECe=`#include +}`,tun=`#include #include #include #include @@ -3466,7 +9823,7 @@ void main() { #include #include #include -}`,SCe=`uniform vec3 color; +}`,nun=`uniform vec3 color; uniform float opacity; #include #include @@ -3482,7 +9839,7 @@ void main() { #include #include #include -}`,TCe=`uniform float rotation; +}`,iun=`uniform float rotation; uniform vec2 center; #include #include @@ -3508,7 +9865,7 @@ void main() { #include #include #include -}`,CCe=`uniform vec3 diffuse; +}`,run=`uniform vec3 diffuse; uniform float opacity; #include #include @@ -3533,7 +9890,7 @@ void main() { #include #include #include -}`,No={alphahash_fragment:ZEe,alphahash_pars_fragment:YEe,alphamap_fragment:KEe,alphamap_pars_fragment:JEe,alphatest_fragment:QEe,alphatest_pars_fragment:tSe,aomap_fragment:eSe,aomap_pars_fragment:nSe,batching_pars_vertex:iSe,batching_vertex:rSe,begin_vertex:sSe,beginnormal_vertex:oSe,bsdfs:cSe,iridescence_fragment:aSe,bumpmap_pars_fragment:uSe,clipping_planes_fragment:lSe,clipping_planes_pars_fragment:hSe,clipping_planes_pars_vertex:fSe,clipping_planes_vertex:dSe,color_fragment:pSe,color_pars_fragment:gSe,color_pars_vertex:mSe,color_vertex:bSe,common:wSe,cube_uv_reflection_fragment:vSe,defaultnormal_vertex:_Se,displacementmap_pars_vertex:ySe,displacementmap_vertex:xSe,emissivemap_fragment:MSe,emissivemap_pars_fragment:ESe,colorspace_fragment:SSe,colorspace_pars_fragment:TSe,envmap_fragment:CSe,envmap_common_pars_fragment:ASe,envmap_pars_fragment:kSe,envmap_pars_vertex:LSe,envmap_physical_pars_fragment:HSe,envmap_vertex:PSe,fog_vertex:ISe,fog_pars_vertex:RSe,fog_fragment:DSe,fog_pars_fragment:NSe,gradientmap_pars_fragment:OSe,lightmap_fragment:BSe,lightmap_pars_fragment:FSe,lights_lambert_fragment:USe,lights_lambert_pars_fragment:zSe,lights_pars_begin:jSe,lights_toon_fragment:GSe,lights_toon_pars_fragment:WSe,lights_phong_fragment:$Se,lights_phong_pars_fragment:VSe,lights_physical_fragment:qSe,lights_physical_pars_fragment:XSe,lights_fragment_begin:ZSe,lights_fragment_maps:YSe,lights_fragment_end:KSe,logdepthbuf_fragment:JSe,logdepthbuf_pars_fragment:QSe,logdepthbuf_pars_vertex:tTe,logdepthbuf_vertex:eTe,map_fragment:nTe,map_pars_fragment:iTe,map_particle_fragment:rTe,map_particle_pars_fragment:sTe,metalnessmap_fragment:oTe,metalnessmap_pars_fragment:cTe,morphcolor_vertex:aTe,morphnormal_vertex:uTe,morphtarget_pars_vertex:lTe,morphtarget_vertex:hTe,normal_fragment_begin:fTe,normal_fragment_maps:dTe,normal_pars_fragment:pTe,normal_pars_vertex:gTe,normal_vertex:mTe,normalmap_pars_fragment:bTe,clearcoat_normal_fragment_begin:wTe,clearcoat_normal_fragment_maps:vTe,clearcoat_pars_fragment:_Te,iridescence_pars_fragment:yTe,opaque_fragment:xTe,packing:MTe,premultiplied_alpha_fragment:ETe,project_vertex:STe,dithering_fragment:TTe,dithering_pars_fragment:CTe,roughnessmap_fragment:ATe,roughnessmap_pars_fragment:kTe,shadowmap_pars_fragment:LTe,shadowmap_pars_vertex:PTe,shadowmap_vertex:ITe,shadowmask_pars_fragment:RTe,skinbase_vertex:DTe,skinning_pars_vertex:NTe,skinning_vertex:OTe,skinnormal_vertex:BTe,specularmap_fragment:FTe,specularmap_pars_fragment:UTe,tonemapping_fragment:zTe,tonemapping_pars_fragment:jTe,transmission_fragment:HTe,transmission_pars_fragment:GTe,uv_pars_fragment:WTe,uv_pars_vertex:$Te,uv_vertex:VTe,worldpos_vertex:qTe,background_vert:XTe,background_frag:ZTe,backgroundCube_vert:YTe,backgroundCube_frag:KTe,cube_vert:JTe,cube_frag:QTe,depth_vert:tCe,depth_frag:eCe,distanceRGBA_vert:nCe,distanceRGBA_frag:iCe,equirect_vert:rCe,equirect_frag:sCe,linedashed_vert:oCe,linedashed_frag:cCe,meshbasic_vert:aCe,meshbasic_frag:uCe,meshlambert_vert:lCe,meshlambert_frag:hCe,meshmatcap_vert:fCe,meshmatcap_frag:dCe,meshnormal_vert:pCe,meshnormal_frag:gCe,meshphong_vert:mCe,meshphong_frag:bCe,meshphysical_vert:wCe,meshphysical_frag:vCe,meshtoon_vert:_Ce,meshtoon_frag:yCe,points_vert:xCe,points_frag:MCe,shadow_vert:ECe,shadow_frag:SCe,sprite_vert:TCe,sprite_frag:CCe},Zi={common:{diffuse:{value:new Go(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ko},alphaMap:{value:null},alphaMapTransform:{value:new Ko},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ko}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ko}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ko}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ko},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ko},normalScale:{value:new Nc(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ko},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ko}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ko}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ko}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Go(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Go(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ko},alphaTest:{value:0},uvTransform:{value:new Ko}},sprite:{diffuse:{value:new Go(16777215)},opacity:{value:1},center:{value:new Nc(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ko},alphaMap:{value:null},alphaMapTransform:{value:new Ko},alphaTest:{value:0}}},wy={basic:{uniforms:i1([Zi.common,Zi.specularmap,Zi.envmap,Zi.aomap,Zi.lightmap,Zi.fog]),vertexShader:No.meshbasic_vert,fragmentShader:No.meshbasic_frag},lambert:{uniforms:i1([Zi.common,Zi.specularmap,Zi.envmap,Zi.aomap,Zi.lightmap,Zi.emissivemap,Zi.bumpmap,Zi.normalmap,Zi.displacementmap,Zi.fog,Zi.lights,{emissive:{value:new Go(0)}}]),vertexShader:No.meshlambert_vert,fragmentShader:No.meshlambert_frag},phong:{uniforms:i1([Zi.common,Zi.specularmap,Zi.envmap,Zi.aomap,Zi.lightmap,Zi.emissivemap,Zi.bumpmap,Zi.normalmap,Zi.displacementmap,Zi.fog,Zi.lights,{emissive:{value:new Go(0)},specular:{value:new Go(1118481)},shininess:{value:30}}]),vertexShader:No.meshphong_vert,fragmentShader:No.meshphong_frag},standard:{uniforms:i1([Zi.common,Zi.envmap,Zi.aomap,Zi.lightmap,Zi.emissivemap,Zi.bumpmap,Zi.normalmap,Zi.displacementmap,Zi.roughnessmap,Zi.metalnessmap,Zi.fog,Zi.lights,{emissive:{value:new Go(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:No.meshphysical_vert,fragmentShader:No.meshphysical_frag},toon:{uniforms:i1([Zi.common,Zi.aomap,Zi.lightmap,Zi.emissivemap,Zi.bumpmap,Zi.normalmap,Zi.displacementmap,Zi.gradientmap,Zi.fog,Zi.lights,{emissive:{value:new Go(0)}}]),vertexShader:No.meshtoon_vert,fragmentShader:No.meshtoon_frag},matcap:{uniforms:i1([Zi.common,Zi.bumpmap,Zi.normalmap,Zi.displacementmap,Zi.fog,{matcap:{value:null}}]),vertexShader:No.meshmatcap_vert,fragmentShader:No.meshmatcap_frag},points:{uniforms:i1([Zi.points,Zi.fog]),vertexShader:No.points_vert,fragmentShader:No.points_frag},dashed:{uniforms:i1([Zi.common,Zi.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:No.linedashed_vert,fragmentShader:No.linedashed_frag},depth:{uniforms:i1([Zi.common,Zi.displacementmap]),vertexShader:No.depth_vert,fragmentShader:No.depth_frag},normal:{uniforms:i1([Zi.common,Zi.bumpmap,Zi.normalmap,Zi.displacementmap,{opacity:{value:1}}]),vertexShader:No.meshnormal_vert,fragmentShader:No.meshnormal_frag},sprite:{uniforms:i1([Zi.sprite,Zi.fog]),vertexShader:No.sprite_vert,fragmentShader:No.sprite_frag},background:{uniforms:{uvTransform:{value:new Ko},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:No.background_vert,fragmentShader:No.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:No.backgroundCube_vert,fragmentShader:No.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:No.cube_vert,fragmentShader:No.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:No.equirect_vert,fragmentShader:No.equirect_frag},distanceRGBA:{uniforms:i1([Zi.common,Zi.displacementmap,{referencePosition:{value:new Ge},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:No.distanceRGBA_vert,fragmentShader:No.distanceRGBA_frag},shadow:{uniforms:i1([Zi.lights,Zi.fog,{color:{value:new Go(0)},opacity:{value:1}}]),vertexShader:No.shadow_vert,fragmentShader:No.shadow_frag}};wy.physical={uniforms:i1([wy.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ko},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ko},clearcoatNormalScale:{value:new Nc(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ko},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ko},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ko},sheen:{value:0},sheenColor:{value:new Go(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ko},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ko},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ko},transmissionSamplerSize:{value:new Nc},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ko},attenuationDistance:{value:0},attenuationColor:{value:new Go(0)},specularColor:{value:new Go(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ko},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ko},anisotropyVector:{value:new Nc},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ko}}]),vertexShader:No.meshphysical_vert,fragmentShader:No.meshphysical_frag};var $tt={r:0,b:0,g:0};function ACe(d,s,h,p,m,_,S){let y=new Go(0),I=_===!0?0:1,N,B,P=null,U=0,j=null;function V(Q,X){let gt=!1,ft=X.isScene===!0?X.background:null;ft&&ft.isTexture&&(ft=(X.backgroundBlurriness>0?h:s).get(ft)),ft===null?et(y,I):ft&&ft.isColor&&(et(ft,1),gt=!0);let xt=d.xr.getEnvironmentBlendMode();xt==="additive"?p.buffers.color.setClear(0,0,0,1,S):xt==="alpha-blend"&&p.buffers.color.setClear(0,0,0,0,S),(d.autoClear||gt)&&d.clear(d.autoClearColor,d.autoClearDepth,d.autoClearStencil),ft&&(ft.isCubeTexture||ft.mapping===Pet)?(B===void 0&&(B=new pg(new VA(1,1,1),new Jx({name:"BackgroundCubeMaterial",uniforms:iR(wy.backgroundCube.uniforms),vertexShader:wy.backgroundCube.vertexShader,fragmentShader:wy.backgroundCube.fragmentShader,side:gg,depthTest:!1,depthWrite:!1,fog:!1})),B.geometry.deleteAttribute("normal"),B.geometry.deleteAttribute("uv"),B.onBeforeRender=function(Bt,Dt,Pt){this.matrixWorld.copyPosition(Pt.matrixWorld)},Object.defineProperty(B.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),m.update(B)),B.material.uniforms.envMap.value=ft,B.material.uniforms.flipEnvMap.value=ft.isCubeTexture&&ft.isRenderTargetTexture===!1?-1:1,B.material.uniforms.backgroundBlurriness.value=X.backgroundBlurriness,B.material.uniforms.backgroundIntensity.value=X.backgroundIntensity,B.material.toneMapped=Na.getTransfer(ft.colorSpace)!==vu,(P!==ft||U!==ft.version||j!==d.toneMapping)&&(B.material.needsUpdate=!0,P=ft,U=ft.version,j=d.toneMapping),B.layers.enableAll(),Q.unshift(B,B.geometry,B.material,0,0,null)):ft&&ft.isTexture&&(N===void 0&&(N=new pg(new Ryt(2,2),new Jx({name:"BackgroundMaterial",uniforms:iR(wy.background.uniforms),vertexShader:wy.background.vertexShader,fragmentShader:wy.background.fragmentShader,side:cS,depthTest:!1,depthWrite:!1,fog:!1})),N.geometry.deleteAttribute("normal"),Object.defineProperty(N.material,"map",{get:function(){return this.uniforms.t2D.value}}),m.update(N)),N.material.uniforms.t2D.value=ft,N.material.uniforms.backgroundIntensity.value=X.backgroundIntensity,N.material.toneMapped=Na.getTransfer(ft.colorSpace)!==vu,ft.matrixAutoUpdate===!0&&ft.updateMatrix(),N.material.uniforms.uvTransform.value.copy(ft.matrix),(P!==ft||U!==ft.version||j!==d.toneMapping)&&(N.material.needsUpdate=!0,P=ft,U=ft.version,j=d.toneMapping),N.layers.enableAll(),Q.unshift(N,N.geometry,N.material,0,0,null))}function et(Q,X){Q.getRGB($tt,cKt(d)),p.buffers.color.setClear($tt.r,$tt.g,$tt.b,X,S)}return{getClearColor:function(){return y},setClearColor:function(Q,X=1){y.set(Q),I=X,et(y,I)},getClearAlpha:function(){return I},setClearAlpha:function(Q){I=Q,et(y,I)},render:V}}function kCe(d,s,h,p){let m=d.getParameter(d.MAX_VERTEX_ATTRIBS),_=p.isWebGL2?null:s.get("OES_vertex_array_object"),S=p.isWebGL2||_!==null,y={},I=Q(null),N=I,B=!1;function P(ne,xe,re,hn,Se){let ke=!1;if(S){let mn=et(hn,re,xe);N!==mn&&(N=mn,j(N.object)),ke=X(ne,hn,re,Se),ke&>(ne,hn,re,Se)}else{let mn=xe.wireframe===!0;(N.geometry!==hn.id||N.program!==re.id||N.wireframe!==mn)&&(N.geometry=hn.id,N.program=re.id,N.wireframe=mn,ke=!0)}Se!==null&&h.update(Se,d.ELEMENT_ARRAY_BUFFER),(ke||B)&&(B=!1,se(ne,xe,re,hn),Se!==null&&d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,h.get(Se).buffer))}function U(){return p.isWebGL2?d.createVertexArray():_.createVertexArrayOES()}function j(ne){return p.isWebGL2?d.bindVertexArray(ne):_.bindVertexArrayOES(ne)}function V(ne){return p.isWebGL2?d.deleteVertexArray(ne):_.deleteVertexArrayOES(ne)}function et(ne,xe,re){let hn=re.wireframe===!0,Se=y[ne.id];Se===void 0&&(Se={},y[ne.id]=Se);let ke=Se[xe.id];ke===void 0&&(ke={},Se[xe.id]=ke);let mn=ke[hn];return mn===void 0&&(mn=Q(U()),ke[hn]=mn),mn}function Q(ne){let xe=[],re=[],hn=[];for(let Se=0;Se=0){let Pe=Se[Qn],ti=ke[Qn];if(ti===void 0&&(Qn==="instanceMatrix"&&ne.instanceMatrix&&(ti=ne.instanceMatrix),Qn==="instanceColor"&&ne.instanceColor&&(ti=ne.instanceColor)),Pe===void 0||Pe.attribute!==ti||ti&&Pe.data!==ti.data)return!0;mn++}return N.attributesNum!==mn||N.index!==hn}function gt(ne,xe,re,hn){let Se={},ke=xe.attributes,mn=0,en=re.getAttributes();for(let Qn in en)if(en[Qn].location>=0){let Pe=ke[Qn];Pe===void 0&&(Qn==="instanceMatrix"&&ne.instanceMatrix&&(Pe=ne.instanceMatrix),Qn==="instanceColor"&&ne.instanceColor&&(Pe=ne.instanceColor));let ti={};ti.attribute=Pe,Pe&&Pe.data&&(ti.data=Pe.data),Se[Qn]=ti,mn++}N.attributes=Se,N.attributesNum=mn,N.index=hn}function ft(){let ne=N.newAttributes;for(let xe=0,re=ne.length;xe=0){let ge=Se[en];if(ge===void 0&&(en==="instanceMatrix"&&ne.instanceMatrix&&(ge=ne.instanceMatrix),en==="instanceColor"&&ne.instanceColor&&(ge=ne.instanceColor)),ge!==void 0){let Pe=ge.normalized,ti=ge.itemSize,Yi=h.get(ge);if(Yi===void 0)continue;let ki=Yi.buffer,lr=Yi.type,pr=Yi.bytesPerElement,Kt=p.isWebGL2===!0&&(lr===d.INT||lr===d.UNSIGNED_INT||ge.gpuType===ZYt);if(ge.isInterleavedBufferAttribute){let wn=ge.data,it=wn.stride,ut=ge.offset;if(wn.isInstancedInterleavedBuffer){for(let kt=0;kt0&&d.getShaderPrecisionFormat(d.FRAGMENT_SHADER,d.HIGH_FLOAT).precision>0)return"highp";Pt="mediump"}return Pt==="mediump"&&d.getShaderPrecisionFormat(d.VERTEX_SHADER,d.MEDIUM_FLOAT).precision>0&&d.getShaderPrecisionFormat(d.FRAGMENT_SHADER,d.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let S=typeof WebGL2RenderingContext<"u"&&d.constructor.name==="WebGL2RenderingContext",y=h.precision!==void 0?h.precision:"highp",I=_(y);I!==y&&(console.warn("THREE.WebGLRenderer:",y,"not supported, using",I,"instead."),y=I);let N=S||s.has("WEBGL_draw_buffers"),B=h.logarithmicDepthBuffer===!0,P=d.getParameter(d.MAX_TEXTURE_IMAGE_UNITS),U=d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS),j=d.getParameter(d.MAX_TEXTURE_SIZE),V=d.getParameter(d.MAX_CUBE_MAP_TEXTURE_SIZE),et=d.getParameter(d.MAX_VERTEX_ATTRIBS),Q=d.getParameter(d.MAX_VERTEX_UNIFORM_VECTORS),X=d.getParameter(d.MAX_VARYING_VECTORS),gt=d.getParameter(d.MAX_FRAGMENT_UNIFORM_VECTORS),ft=U>0,xt=S||s.has("OES_texture_float"),Bt=ft&&xt,Dt=S?d.getParameter(d.MAX_SAMPLES):0;return{isWebGL2:S,drawBuffers:N,getMaxAnisotropy:m,getMaxPrecision:_,precision:y,logarithmicDepthBuffer:B,maxTextures:P,maxVertexTextures:U,maxTextureSize:j,maxCubemapSize:V,maxAttributes:et,maxVertexUniforms:Q,maxVaryings:X,maxFragmentUniforms:gt,vertexTextures:ft,floatFragmentTextures:xt,floatVertexTextures:Bt,maxSamples:Dt}}function ICe(d){let s=this,h=null,p=0,m=!1,_=!1,S=new qx,y=new Ko,I={value:null,needsUpdate:!1};this.uniform=I,this.numPlanes=0,this.numIntersection=0,this.init=function(P,U){let j=P.length!==0||U||p!==0||m;return m=U,p=P.length,j},this.beginShadows=function(){_=!0,B(null)},this.endShadows=function(){_=!1},this.setGlobalState=function(P,U){h=B(P,U,0)},this.setState=function(P,U,j){let V=P.clippingPlanes,et=P.clipIntersection,Q=P.clipShadows,X=d.get(P);if(!m||V===null||V.length===0||_&&!Q)_?B(null):N();else{let gt=_?0:p,ft=gt*4,xt=X.clippingState||null;I.value=xt,xt=B(V,U,ft,j);for(let Bt=0;Bt!==ft;++Bt)xt[Bt]=h[Bt];X.clippingState=xt,this.numIntersection=et?this.numPlanes:0,this.numPlanes+=gt}};function N(){I.value!==h&&(I.value=h,I.needsUpdate=p>0),s.numPlanes=p,s.numIntersection=0}function B(P,U,j,V){let et=P!==null?P.length:0,Q=null;if(et!==0){if(Q=I.value,V!==!0||Q===null){let X=j+et*4,gt=U.matrixWorldInverse;y.getNormalMatrix(gt),(Q===null||Q.length0){let N=new Iyt(I.height/2);return N.fromEquirectangularTexture(d,S),s.set(S,N),S.addEventListener("dispose",m),h(N.texture,S.mapping)}else return null}}return S}function m(S){let y=S.target;y.removeEventListener("dispose",m);let I=s.get(y);I!==void 0&&(s.delete(y),I.dispose())}function _(){s=new WeakMap}return{get:p,dispose:_}}var bet=class extends get{constructor(s=-1,h=1,p=1,m=-1,_=.1,S=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=s,this.right=h,this.top=p,this.bottom=m,this.near=_,this.far=S,this.updateProjectionMatrix()}copy(s,h){return super.copy(s,h),this.left=s.left,this.right=s.right,this.top=s.top,this.bottom=s.bottom,this.near=s.near,this.far=s.far,this.zoom=s.zoom,this.view=s.view===null?null:Object.assign({},s.view),this}setViewOffset(s,h,p,m,_,S){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=s,this.view.fullHeight=h,this.view.offsetX=p,this.view.offsetY=m,this.view.width=_,this.view.height=S,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let s=(this.right-this.left)/(2*this.zoom),h=(this.top-this.bottom)/(2*this.zoom),p=(this.right+this.left)/2,m=(this.top+this.bottom)/2,_=p-s,S=p+s,y=m+h,I=m-h;if(this.view!==null&&this.view.enabled){let N=(this.right-this.left)/this.view.fullWidth/this.zoom,B=(this.top-this.bottom)/this.view.fullHeight/this.zoom;_+=N*this.view.offsetX,S=_+N*this.view.width,y-=B*this.view.offsetY,I=y-B*this.view.height}this.projectionMatrix.makeOrthographic(_,S,y,I,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(s){let h=super.toJSON(s);return h.object.zoom=this.zoom,h.object.left=this.left,h.object.right=this.right,h.object.top=this.top,h.object.bottom=this.bottom,h.object.near=this.near,h.object.far=this.far,this.view!==null&&(h.object.view=Object.assign({},this.view)),h}},XI=4,mYt=[.125,.215,.35,.446,.526,.582],jA=20,fyt=new bet,bYt=new Go,dyt=null,pyt=0,gyt=0,UA=(1+Math.sqrt(5))/2,VI=1/UA,wYt=[new Ge(1,1,1),new Ge(-1,1,1),new Ge(1,1,-1),new Ge(-1,1,-1),new Ge(0,UA,VI),new Ge(0,UA,-VI),new Ge(VI,0,UA),new Ge(-VI,0,UA),new Ge(UA,VI,0),new Ge(-UA,VI,0)],wet=class{constructor(s){this._renderer=s,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(s,h=0,p=.1,m=100){dyt=this._renderer.getRenderTarget(),pyt=this._renderer.getActiveCubeFace(),gyt=this._renderer.getActiveMipmapLevel(),this._setSize(256);let _=this._allocateTargets();return _.depthBuffer=!0,this._sceneToCubeUV(s,p,m,_),h>0&&this._blur(_,0,0,h),this._applyPMREM(_),this._cleanup(_),_}fromEquirectangular(s,h=null){return this._fromTexture(s,h)}fromCubemap(s,h=null){return this._fromTexture(s,h)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=yYt(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=_Yt(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(s){this._lodMax=Math.floor(Math.log2(s)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let s=0;s2?ft:0,ft,ft),B.setRenderTarget(m),et&&B.render(V,y),B.render(s,y)}V.geometry.dispose(),V.material.dispose(),B.toneMapping=U,B.autoClear=P,s.background=Q}_textureToCubeUV(s,h){let p=this._renderer,m=s.mapping===QI||s.mapping===tR;m?(this._cubemapMaterial===null&&(this._cubemapMaterial=yYt()),this._cubemapMaterial.uniforms.flipEnvMap.value=s.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=_Yt());let _=m?this._cubemapMaterial:this._equirectMaterial,S=new pg(this._lodPlanes[0],_),y=_.uniforms;y.envMap.value=s;let I=this._cubeSize;Vtt(h,0,0,3*I,2*I),p.setRenderTarget(h),p.render(S,fyt)}_applyPMREM(s){let h=this._renderer,p=h.autoClear;h.autoClear=!1;for(let m=1;mjA&&console.warn(`sigmaRadians, ${_}, is too large and will clip, as it requested ${Q} samples when the maximum is set to ${jA}`);let X=[],gt=0;for(let Pt=0;Ptft-XI?m-ft+XI:0),Dt=4*(this._cubeSize-xt);Vtt(h,Bt,Dt,3*xt,2*xt),I.setRenderTarget(h),I.render(P,fyt)}};function DCe(d){let s=[],h=[],p=[],m=d,_=d-XI+1+mYt.length;for(let S=0;S<_;S++){let y=Math.pow(2,m);h.push(y);let I=1/y;S>d-XI?I=mYt[S-d+XI-1]:S===0&&(I=0),p.push(I);let N=1/(y-2),B=-N,P=1+N,U=[B,B,P,B,P,P,B,B,P,P,B,P],j=6,V=6,et=3,Q=2,X=1,gt=new Float32Array(et*V*j),ft=new Float32Array(Q*V*j),xt=new Float32Array(X*V*j);for(let Dt=0;Dt2?0:-1,ot=[Pt,se,0,Pt+2/3,se,0,Pt+2/3,se+1,0,Pt,se,0,Pt+2/3,se+1,0,Pt,se+1,0];gt.set(ot,et*V*Dt),ft.set(U,Q*V*Dt);let Lt=[Dt,Dt,Dt,Dt,Dt,Dt];xt.set(Lt,X*V*Dt)}let Bt=new _y;Bt.setAttribute("position",new R0(gt,et)),Bt.setAttribute("uv",new R0(ft,Q)),Bt.setAttribute("faceIndex",new R0(xt,X)),s.push(Bt),m>XI&&m--}return{lodPlanes:s,sizeLods:h,sigmas:p}}function vYt(d,s,h){let p=new Yx(d,s,h);return p.texture.mapping=Pet,p.texture.name="PMREM.cubeUv",p.scissorTest=!0,p}function Vtt(d,s,h,p,m){d.viewport.set(s,h,p,m),d.scissor.set(s,h,p,m)}function NCe(d,s,h){let p=new Float32Array(jA),m=new Ge(0,1,0);return new Jx({name:"SphericalGaussianBlur",defines:{n:jA,CUBEUV_TEXEL_WIDTH:1/s,CUBEUV_TEXEL_HEIGHT:1/h,CUBEUV_MAX_MIP:`${d}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:p},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:m}},vertexShader:u2t(),fragmentShader:` +}`,ko={alphahash_fragment:Tan,alphahash_pars_fragment:Can,alphamap_fragment:Aan,alphamap_pars_fragment:Pan,alphatest_fragment:Lan,alphatest_pars_fragment:kan,aomap_fragment:Ran,aomap_pars_fragment:Ian,batching_pars_vertex:Dan,batching_vertex:Ban,begin_vertex:Oan,beginnormal_vertex:Nan,bsdfs:Fan,iridescence_fragment:Uan,bumpmap_pars_fragment:zan,clipping_planes_fragment:Gan,clipping_planes_pars_fragment:jan,clipping_planes_pars_vertex:$an,clipping_planes_vertex:Van,color_fragment:Wan,color_pars_fragment:Han,color_pars_vertex:qan,color_vertex:Xan,common:Yan,cube_uv_reflection_fragment:Zan,defaultnormal_vertex:Kan,displacementmap_pars_vertex:Jan,displacementmap_vertex:Qan,emissivemap_fragment:ecn,emissivemap_pars_fragment:tcn,colorspace_fragment:ncn,colorspace_pars_fragment:icn,envmap_fragment:rcn,envmap_common_pars_fragment:scn,envmap_pars_fragment:ocn,envmap_pars_vertex:acn,envmap_physical_pars_fragment:vcn,envmap_vertex:ccn,fog_vertex:lcn,fog_pars_vertex:ucn,fog_fragment:fcn,fog_pars_fragment:hcn,gradientmap_pars_fragment:dcn,lightmap_fragment:pcn,lightmap_pars_fragment:gcn,lights_lambert_fragment:mcn,lights_lambert_pars_fragment:bcn,lights_pars_begin:wcn,lights_toon_fragment:_cn,lights_toon_pars_fragment:ycn,lights_phong_fragment:xcn,lights_phong_pars_fragment:Ecn,lights_physical_fragment:Scn,lights_physical_pars_fragment:Mcn,lights_fragment_begin:Tcn,lights_fragment_maps:Ccn,lights_fragment_end:Acn,logdepthbuf_fragment:Pcn,logdepthbuf_pars_fragment:Lcn,logdepthbuf_pars_vertex:kcn,logdepthbuf_vertex:Rcn,map_fragment:Icn,map_pars_fragment:Dcn,map_particle_fragment:Bcn,map_particle_pars_fragment:Ocn,metalnessmap_fragment:Ncn,metalnessmap_pars_fragment:Fcn,morphcolor_vertex:Ucn,morphnormal_vertex:zcn,morphtarget_pars_vertex:Gcn,morphtarget_vertex:jcn,normal_fragment_begin:$cn,normal_fragment_maps:Vcn,normal_pars_fragment:Wcn,normal_pars_vertex:Hcn,normal_vertex:qcn,normalmap_pars_fragment:Xcn,clearcoat_normal_fragment_begin:Ycn,clearcoat_normal_fragment_maps:Zcn,clearcoat_pars_fragment:Kcn,iridescence_pars_fragment:Jcn,opaque_fragment:Qcn,packing:eln,premultiplied_alpha_fragment:tln,project_vertex:nln,dithering_fragment:iln,dithering_pars_fragment:rln,roughnessmap_fragment:sln,roughnessmap_pars_fragment:oln,shadowmap_pars_fragment:aln,shadowmap_pars_vertex:cln,shadowmap_vertex:lln,shadowmask_pars_fragment:uln,skinbase_vertex:fln,skinning_pars_vertex:hln,skinning_vertex:dln,skinnormal_vertex:pln,specularmap_fragment:gln,specularmap_pars_fragment:mln,tonemapping_fragment:bln,tonemapping_pars_fragment:wln,transmission_fragment:vln,transmission_pars_fragment:_ln,uv_pars_fragment:yln,uv_pars_vertex:xln,uv_vertex:Eln,worldpos_vertex:Sln,background_vert:Mln,background_frag:Tln,backgroundCube_vert:Cln,backgroundCube_frag:Aln,cube_vert:Pln,cube_frag:Lln,depth_vert:kln,depth_frag:Rln,distanceRGBA_vert:Iln,distanceRGBA_frag:Dln,equirect_vert:Bln,equirect_frag:Oln,linedashed_vert:Nln,linedashed_frag:Fln,meshbasic_vert:Uln,meshbasic_frag:zln,meshlambert_vert:Gln,meshlambert_frag:jln,meshmatcap_vert:$ln,meshmatcap_frag:Vln,meshnormal_vert:Wln,meshnormal_frag:Hln,meshphong_vert:qln,meshphong_frag:Xln,meshphysical_vert:Yln,meshphysical_frag:Zln,meshtoon_vert:Kln,meshtoon_frag:Jln,points_vert:Qln,points_frag:eun,shadow_vert:tun,shadow_frag:nun,sprite_vert:iun,sprite_frag:run},ji={common:{diffuse:{value:new zo(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new qo},alphaMap:{value:null},alphaMapTransform:{value:new qo},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new qo}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new qo}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new qo}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new qo},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new qo},normalScale:{value:new La(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new qo},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new qo}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new qo}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new qo}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new zo(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new zo(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new qo},alphaTest:{value:0},uvTransform:{value:new qo}},sprite:{diffuse:{value:new zo(16777215)},opacity:{value:1},center:{value:new La(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new qo},alphaMap:{value:null},alphaMapTransform:{value:new qo},alphaTest:{value:0}}},f2={basic:{uniforms:fg([ji.common,ji.specularmap,ji.envmap,ji.aomap,ji.lightmap,ji.fog]),vertexShader:ko.meshbasic_vert,fragmentShader:ko.meshbasic_frag},lambert:{uniforms:fg([ji.common,ji.specularmap,ji.envmap,ji.aomap,ji.lightmap,ji.emissivemap,ji.bumpmap,ji.normalmap,ji.displacementmap,ji.fog,ji.lights,{emissive:{value:new zo(0)}}]),vertexShader:ko.meshlambert_vert,fragmentShader:ko.meshlambert_frag},phong:{uniforms:fg([ji.common,ji.specularmap,ji.envmap,ji.aomap,ji.lightmap,ji.emissivemap,ji.bumpmap,ji.normalmap,ji.displacementmap,ji.fog,ji.lights,{emissive:{value:new zo(0)},specular:{value:new zo(1118481)},shininess:{value:30}}]),vertexShader:ko.meshphong_vert,fragmentShader:ko.meshphong_frag},standard:{uniforms:fg([ji.common,ji.envmap,ji.aomap,ji.lightmap,ji.emissivemap,ji.bumpmap,ji.normalmap,ji.displacementmap,ji.roughnessmap,ji.metalnessmap,ji.fog,ji.lights,{emissive:{value:new zo(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ko.meshphysical_vert,fragmentShader:ko.meshphysical_frag},toon:{uniforms:fg([ji.common,ji.aomap,ji.lightmap,ji.emissivemap,ji.bumpmap,ji.normalmap,ji.displacementmap,ji.gradientmap,ji.fog,ji.lights,{emissive:{value:new zo(0)}}]),vertexShader:ko.meshtoon_vert,fragmentShader:ko.meshtoon_frag},matcap:{uniforms:fg([ji.common,ji.bumpmap,ji.normalmap,ji.displacementmap,ji.fog,{matcap:{value:null}}]),vertexShader:ko.meshmatcap_vert,fragmentShader:ko.meshmatcap_frag},points:{uniforms:fg([ji.points,ji.fog]),vertexShader:ko.points_vert,fragmentShader:ko.points_frag},dashed:{uniforms:fg([ji.common,ji.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ko.linedashed_vert,fragmentShader:ko.linedashed_frag},depth:{uniforms:fg([ji.common,ji.displacementmap]),vertexShader:ko.depth_vert,fragmentShader:ko.depth_frag},normal:{uniforms:fg([ji.common,ji.bumpmap,ji.normalmap,ji.displacementmap,{opacity:{value:1}}]),vertexShader:ko.meshnormal_vert,fragmentShader:ko.meshnormal_frag},sprite:{uniforms:fg([ji.sprite,ji.fog]),vertexShader:ko.sprite_vert,fragmentShader:ko.sprite_frag},background:{uniforms:{uvTransform:{value:new qo},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ko.background_vert,fragmentShader:ko.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:ko.backgroundCube_vert,fragmentShader:ko.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ko.cube_vert,fragmentShader:ko.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ko.equirect_vert,fragmentShader:ko.equirect_frag},distanceRGBA:{uniforms:fg([ji.common,ji.displacementmap,{referencePosition:{value:new Gt},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ko.distanceRGBA_vert,fragmentShader:ko.distanceRGBA_frag},shadow:{uniforms:fg([ji.lights,ji.fog,{color:{value:new zo(0)},opacity:{value:1}}]),vertexShader:ko.shadow_vert,fragmentShader:ko.shadow_frag}};f2.physical={uniforms:fg([f2.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new qo},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new qo},clearcoatNormalScale:{value:new La(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new qo},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new qo},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new qo},sheen:{value:0},sheenColor:{value:new zo(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new qo},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new qo},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new qo},transmissionSamplerSize:{value:new La},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new qo},attenuationDistance:{value:0},attenuationColor:{value:new zo(0)},specularColor:{value:new zo(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new qo},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new qo},anisotropyVector:{value:new La},anisotropyMap:{value:null},anisotropyMapTransform:{value:new qo}}]),vertexShader:ko.meshphysical_vert,fragmentShader:ko.meshphysical_frag};var Ife={r:0,b:0,g:0};function sun(s,n,r,c,u,d,b){let w=new zo(0),_=d===!0?0:1,x,T,M=null,L=0,I=null;function D(O,z){let Z=!1,H=z.isScene===!0?z.background:null;H&&H.isTexture&&(H=(z.backgroundBlurriness>0?r:n).get(H)),H===null?F(w,_):H&&H.isColor&&(F(H,1),Z=!0);let te=s.xr.getEnvironmentBlendMode();te==="additive"?c.buffers.color.setClear(0,0,0,1,b):te==="alpha-blend"&&c.buffers.color.setClear(0,0,0,0,b),(s.autoClear||Z)&&s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil),H&&(H.isCubeTexture||H.mapping===bhe)?(T===void 0&&(T=new Mm(new X4(1,1,1),new K3({name:"BackgroundCubeMaterial",uniforms:dO(f2.backgroundCube.uniforms),vertexShader:f2.backgroundCube.vertexShader,fragmentShader:f2.backgroundCube.fragmentShader,side:Tm,depthTest:!1,depthWrite:!1,fog:!1})),T.geometry.deleteAttribute("normal"),T.geometry.deleteAttribute("uv"),T.onBeforeRender=function(se,ne,ue){this.matrixWorld.copyPosition(ue.matrixWorld)},Object.defineProperty(T.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),u.update(T)),T.material.uniforms.envMap.value=H,T.material.uniforms.flipEnvMap.value=H.isCubeTexture&&H.isRenderTargetTexture===!1?-1:1,T.material.uniforms.backgroundBlurriness.value=z.backgroundBlurriness,T.material.uniforms.backgroundIntensity.value=z.backgroundIntensity,T.material.toneMapped=Ac.getTransfer(H.colorSpace)!==hl,(M!==H||L!==H.version||I!==s.toneMapping)&&(T.material.needsUpdate=!0,M=H,L=H.version,I=s.toneMapping),T.layers.enableAll(),O.unshift(T,T.geometry,T.material,0,0,null)):H&&H.isTexture&&(x===void 0&&(x=new Mm(new B6e(2,2),new K3({name:"BackgroundMaterial",uniforms:dO(f2.background.uniforms),vertexShader:f2.background.vertexShader,fragmentShader:f2.background.fragmentShader,side:mT,depthTest:!1,depthWrite:!1,fog:!1})),x.geometry.deleteAttribute("normal"),Object.defineProperty(x.material,"map",{get:function(){return this.uniforms.t2D.value}}),u.update(x)),x.material.uniforms.t2D.value=H,x.material.uniforms.backgroundIntensity.value=z.backgroundIntensity,x.material.toneMapped=Ac.getTransfer(H.colorSpace)!==hl,H.matrixAutoUpdate===!0&&H.updateMatrix(),x.material.uniforms.uvTransform.value.copy(H.matrix),(M!==H||L!==H.version||I!==s.toneMapping)&&(x.material.needsUpdate=!0,M=H,L=H.version,I=s.toneMapping),x.layers.enableAll(),O.unshift(x,x.geometry,x.material,0,0,null))}function F(O,z){O.getRGB(Ife,P2t(s)),c.buffers.color.setClear(Ife.r,Ife.g,Ife.b,z,b)}return{getClearColor:function(){return w},setClearColor:function(O,z=1){w.set(O),_=z,F(w,_)},getClearAlpha:function(){return _},setClearAlpha:function(O){_=O,F(w,_)},render:D}}function oun(s,n,r,c){let u=s.getParameter(s.MAX_VERTEX_ATTRIBS),d=c.isWebGL2?null:n.get("OES_vertex_array_object"),b=c.isWebGL2||d!==null,w={},_=O(null),x=_,T=!1;function M(Ne,Qe,ot,xt,fn){let Xt=!1;if(b){let wn=F(xt,ot,Qe);x!==wn&&(x=wn,I(x.object)),Xt=z(Ne,xt,ot,fn),Xt&&Z(Ne,xt,ot,fn)}else{let wn=Qe.wireframe===!0;(x.geometry!==xt.id||x.program!==ot.id||x.wireframe!==wn)&&(x.geometry=xt.id,x.program=ot.id,x.wireframe=wn,Xt=!0)}fn!==null&&r.update(fn,s.ELEMENT_ARRAY_BUFFER),(Xt||T)&&(T=!1,Ce(Ne,Qe,ot,xt),fn!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,r.get(fn).buffer))}function L(){return c.isWebGL2?s.createVertexArray():d.createVertexArrayOES()}function I(Ne){return c.isWebGL2?s.bindVertexArray(Ne):d.bindVertexArrayOES(Ne)}function D(Ne){return c.isWebGL2?s.deleteVertexArray(Ne):d.deleteVertexArrayOES(Ne)}function F(Ne,Qe,ot){let xt=ot.wireframe===!0,fn=w[Ne.id];fn===void 0&&(fn={},w[Ne.id]=fn);let Xt=fn[Qe.id];Xt===void 0&&(Xt={},fn[Qe.id]=Xt);let wn=Xt[xt];return wn===void 0&&(wn=O(L()),Xt[xt]=wn),wn}function O(Ne){let Qe=[],ot=[],xt=[];for(let fn=0;fn=0){let gn=fn[bi],Un=Xt[bi];if(Un===void 0&&(bi==="instanceMatrix"&&Ne.instanceMatrix&&(Un=Ne.instanceMatrix),bi==="instanceColor"&&Ne.instanceColor&&(Un=Ne.instanceColor)),gn===void 0||gn.attribute!==Un||Un&&gn.data!==Un.data)return!0;wn++}return x.attributesNum!==wn||x.index!==xt}function Z(Ne,Qe,ot,xt){let fn={},Xt=Qe.attributes,wn=0,cn=ot.getAttributes();for(let bi in cn)if(cn[bi].location>=0){let gn=Xt[bi];gn===void 0&&(bi==="instanceMatrix"&&Ne.instanceMatrix&&(gn=Ne.instanceMatrix),bi==="instanceColor"&&Ne.instanceColor&&(gn=Ne.instanceColor));let Un={};Un.attribute=gn,gn&&gn.data&&(Un.data=gn.data),fn[bi]=Un,wn++}x.attributes=fn,x.attributesNum=wn,x.index=xt}function H(){let Ne=x.newAttributes;for(let Qe=0,ot=Ne.length;Qe=0){let jt=fn[cn];if(jt===void 0&&(cn==="instanceMatrix"&&Ne.instanceMatrix&&(jt=Ne.instanceMatrix),cn==="instanceColor"&&Ne.instanceColor&&(jt=Ne.instanceColor)),jt!==void 0){let gn=jt.normalized,Un=jt.itemSize,Zi=r.get(jt);if(Zi===void 0)continue;let Hi=Zi.buffer,yr=Zi.type,Tr=Zi.bytesPerElement,Ei=c.isWebGL2===!0&&(yr===s.INT||yr===s.UNSIGNED_INT||jt.gpuType===b2t);if(jt.isInterleavedBufferAttribute){let xr=jt.data,oe=xr.stride,de=jt.offset;if(xr.isInstancedInterleavedBuffer){for(let it=0;it0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";ue="mediump"}return ue==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let b=typeof WebGL2RenderingContext<"u"&&s.constructor.name==="WebGL2RenderingContext",w=r.precision!==void 0?r.precision:"highp",_=d(w);_!==w&&(console.warn("THREE.WebGLRenderer:",w,"not supported, using",_,"instead."),w=_);let x=b||n.has("WEBGL_draw_buffers"),T=r.logarithmicDepthBuffer===!0,M=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),L=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),I=s.getParameter(s.MAX_TEXTURE_SIZE),D=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),F=s.getParameter(s.MAX_VERTEX_ATTRIBS),O=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),z=s.getParameter(s.MAX_VARYING_VECTORS),Z=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),H=L>0,te=b||n.has("OES_texture_float"),se=H&&te,ne=b?s.getParameter(s.MAX_SAMPLES):0;return{isWebGL2:b,drawBuffers:x,getMaxAnisotropy:u,getMaxPrecision:d,precision:w,logarithmicDepthBuffer:T,maxTextures:M,maxVertexTextures:L,maxTextureSize:I,maxCubemapSize:D,maxAttributes:F,maxVertexUniforms:O,maxVaryings:z,maxFragmentUniforms:Z,vertexTextures:H,floatFragmentTextures:te,floatVertexTextures:se,maxSamples:ne}}function lun(s){let n=this,r=null,c=0,u=!1,d=!1,b=new H3,w=new qo,_={value:null,needsUpdate:!1};this.uniform=_,this.numPlanes=0,this.numIntersection=0,this.init=function(M,L){let I=M.length!==0||L||c!==0||u;return u=L,c=M.length,I},this.beginShadows=function(){d=!0,T(null)},this.endShadows=function(){d=!1},this.setGlobalState=function(M,L){r=T(M,L,0)},this.setState=function(M,L,I){let D=M.clippingPlanes,F=M.clipIntersection,O=M.clipShadows,z=s.get(M);if(!u||D===null||D.length===0||d&&!O)d?T(null):x();else{let Z=d?0:c,H=Z*4,te=z.clippingState||null;_.value=te,te=T(D,L,H,I);for(let se=0;se!==H;++se)te[se]=r[se];z.clippingState=te,this.numIntersection=F?this.numPlanes:0,this.numPlanes+=Z}};function x(){_.value!==r&&(_.value=r,_.needsUpdate=c>0),n.numPlanes=c,n.numIntersection=0}function T(M,L,I,D){let F=M!==null?M.length:0,O=null;if(F!==0){if(O=_.value,D!==!0||O===null){let z=I+F*4,Z=L.matrixWorldInverse;w.getNormalMatrix(Z),(O===null||O.length0){let x=new D6e(_.height/2);return x.fromEquirectangularTexture(s,b),n.set(b,x),b.addEventListener("dispose",u),r(x.texture,b.mapping)}else return null}}return b}function u(b){let w=b.target;w.removeEventListener("dispose",u);let _=n.get(w);_!==void 0&&(n.delete(w),_.dispose())}function d(){n=new WeakMap}return{get:c,dispose:d}}var rhe=class extends nhe{constructor(n=-1,r=1,c=1,u=-1,d=.1,b=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=n,this.right=r,this.top=c,this.bottom=u,this.near=d,this.far=b,this.updateProjectionMatrix()}copy(n,r){return super.copy(n,r),this.left=n.left,this.right=n.right,this.top=n.top,this.bottom=n.bottom,this.near=n.near,this.far=n.far,this.zoom=n.zoom,this.view=n.view===null?null:Object.assign({},n.view),this}setViewOffset(n,r,c,u,d,b){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=n,this.view.fullHeight=r,this.view.offsetX=c,this.view.offsetY=u,this.view.width=d,this.view.height=b,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let n=(this.right-this.left)/(2*this.zoom),r=(this.top-this.bottom)/(2*this.zoom),c=(this.right+this.left)/2,u=(this.top+this.bottom)/2,d=c-n,b=c+n,w=u+r,_=u-r;if(this.view!==null&&this.view.enabled){let x=(this.right-this.left)/this.view.fullWidth/this.zoom,T=(this.top-this.bottom)/this.view.fullHeight/this.zoom;d+=x*this.view.offsetX,b=d+x*this.view.width,w-=T*this.view.offsetY,_=w-T*this.view.height}this.projectionMatrix.makeOrthographic(d,b,w,_,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(n){let r=super.toJSON(n);return r.object.zoom=this.zoom,r.object.left=this.left,r.object.right=this.right,r.object.top=this.top,r.object.bottom=this.bottom,r.object.near=this.near,r.object.far=this.far,this.view!==null&&(r.object.view=Object.assign({},this.view)),r}},rO=4,Fyt=[.125,.215,.35,.446,.526,.582],$4=20,p6e=new rhe,Uyt=new zo,g6e=null,m6e=0,b6e=0,G4=(1+Math.sqrt(5))/2,nO=1/G4,zyt=[new Gt(1,1,1),new Gt(-1,1,1),new Gt(1,1,-1),new Gt(-1,1,-1),new Gt(0,G4,nO),new Gt(0,G4,-nO),new Gt(nO,0,G4),new Gt(-nO,0,G4),new Gt(G4,nO,0),new Gt(-G4,nO,0)],she=class{constructor(n){this._renderer=n,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(n,r=0,c=.1,u=100){g6e=this._renderer.getRenderTarget(),m6e=this._renderer.getActiveCubeFace(),b6e=this._renderer.getActiveMipmapLevel(),this._setSize(256);let d=this._allocateTargets();return d.depthBuffer=!0,this._sceneToCubeUV(n,c,u,d),r>0&&this._blur(d,0,0,r),this._applyPMREM(d),this._cleanup(d),d}fromEquirectangular(n,r=null){return this._fromTexture(n,r)}fromCubemap(n,r=null){return this._fromTexture(n,r)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=$yt(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=jyt(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(n){this._lodMax=Math.floor(Math.log2(n)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let n=0;n2?H:0,H,H),T.setRenderTarget(u),F&&T.render(D,w),T.render(n,w)}D.geometry.dispose(),D.material.dispose(),T.toneMapping=L,T.autoClear=M,n.background=O}_textureToCubeUV(n,r){let c=this._renderer,u=n.mapping===lO||n.mapping===uO;u?(this._cubemapMaterial===null&&(this._cubemapMaterial=$yt()),this._cubemapMaterial.uniforms.flipEnvMap.value=n.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=jyt());let d=u?this._cubemapMaterial:this._equirectMaterial,b=new Mm(this._lodPlanes[0],d),w=d.uniforms;w.envMap.value=n;let _=this._cubeSize;Dfe(r,0,0,3*_,2*_),c.setRenderTarget(r),c.render(b,p6e)}_applyPMREM(n){let r=this._renderer,c=r.autoClear;r.autoClear=!1;for(let u=1;u$4&&console.warn(`sigmaRadians, ${d}, is too large and will clip, as it requested ${O} samples when the maximum is set to ${$4}`);let z=[],Z=0;for(let ue=0;ue<$4;++ue){let Ce=ue/F,Q=Math.exp(-Ce*Ce/2);z.push(Q),ue===0?Z+=Q:ueH-rO?u-H+rO:0),ne=4*(this._cubeSize-te);Dfe(r,se,ne,3*te,2*te),_.setRenderTarget(r),_.render(M,p6e)}};function fun(s){let n=[],r=[],c=[],u=s,d=s-rO+1+Fyt.length;for(let b=0;bs-rO?_=Fyt[b-s+rO-1]:b===0&&(_=0),c.push(_);let x=1/(w-2),T=-x,M=1+x,L=[T,T,M,T,M,M,T,T,M,M,T,M],I=6,D=6,F=3,O=2,z=1,Z=new Float32Array(F*D*I),H=new Float32Array(O*D*I),te=new Float32Array(z*D*I);for(let ne=0;ne2?0:-1,Q=[ue,Ce,0,ue+2/3,Ce,0,ue+2/3,Ce+1,0,ue,Ce,0,ue+2/3,Ce+1,0,ue,Ce+1,0];Z.set(Q,F*D*ne),H.set(L,O*D*ne);let me=[ne,ne,ne,ne,ne,ne];te.set(me,z*D*ne)}let se=new d2;se.setAttribute("position",new q1(Z,F)),se.setAttribute("uv",new q1(H,O)),se.setAttribute("faceIndex",new q1(te,z)),n.push(se),u>rO&&u--}return{lodPlanes:n,sizeLods:r,sigmas:c}}function Gyt(s,n,r){let c=new Y3(s,n,r);return c.texture.mapping=bhe,c.texture.name="PMREM.cubeUv",c.scissorTest=!0,c}function Dfe(s,n,r,c,u){s.viewport.set(n,r,c,u),s.scissor.set(n,r,c,u)}function hun(s,n,r){let c=new Float32Array($4),u=new Gt(0,1,0);return new K3({name:"SphericalGaussianBlur",defines:{n:$4,CUBEUV_TEXEL_WIDTH:1/n,CUBEUV_TEXEL_HEIGHT:1/r,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:c},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:u}},vertexShader:f5e(),fragmentShader:` precision mediump float; precision mediump int; @@ -3593,7 +9950,7 @@ void main() { } } - `,blending:rS,depthTest:!1,depthWrite:!1})}function _Yt(){return new Jx({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:u2t(),fragmentShader:` + `,blending:dT,depthTest:!1,depthWrite:!1})}function jyt(){return new K3({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:f5e(),fragmentShader:` precision mediump float; precision mediump int; @@ -3612,7 +9969,7 @@ void main() { gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } - `,blending:rS,depthTest:!1,depthWrite:!1})}function yYt(){return new Jx({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:u2t(),fragmentShader:` + `,blending:dT,depthTest:!1,depthWrite:!1})}function $yt(){return new K3({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:f5e(),fragmentShader:` precision mediump float; precision mediump int; @@ -3628,7 +9985,7 @@ void main() { gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } - `,blending:rS,depthTest:!1,depthWrite:!1})}function u2t(){return` + `,blending:dT,depthTest:!1,depthWrite:!1})}function f5e(){return` precision mediump float; precision mediump int; @@ -3683,40 +10040,40 @@ void main() { gl_Position = vec4( position, 1.0 ); } - `}function OCe(d){let s=new WeakMap,h=null;function p(y){if(y&&y.isTexture){let I=y.mapping,N=I===xyt||I===Myt,B=I===QI||I===tR;if(N||B)if(y.isRenderTargetTexture&&y.needsPMREMUpdate===!0){y.needsPMREMUpdate=!1;let P=s.get(y);return h===null&&(h=new wet(d)),P=N?h.fromEquirectangular(y,P):h.fromCubemap(y,P),s.set(y,P),P.texture}else{if(s.has(y))return s.get(y).texture;{let P=y.image;if(N&&P&&P.height>0||B&&P&&m(P)){h===null&&(h=new wet(d));let U=N?h.fromEquirectangular(y):h.fromCubemap(y);return s.set(y,U),y.addEventListener("dispose",_),U.texture}else return null}}}return y}function m(y){let I=0,N=6;for(let B=0;Bs.maxTextureSize&&(Lt=Math.ceil(ot/s.maxTextureSize),ot=s.maxTextureSize);let be=new Float32Array(ot*Lt*4*V),ln=new het(be,ot,Lt,V);ln.type=nS,ln.needsUpdate=!0;let Fn=se*4;for(let xe=0;xe0)return d;let m=s*h,_=xYt[m];if(_===void 0&&(_=new Float32Array(m),xYt[m]=_),s!==0){p.toArray(_,0);for(let S=1,y=0;S!==s;++S)y+=h,d[S].toArray(_,y)}return _}function lf(d,s){if(d.length!==s.length)return!1;for(let h=0,p=d.length;h":" "} ${y}: ${h[S]}`)}return p.join(` -`)}function N4e(d){let s=Na.getPrimaries(Na.workingColorSpace),h=Na.getPrimaries(d),p;switch(s===h?p="":s===set&&h===ret?p="LinearDisplayP3ToLinearSRGB":s===ret&&h===set&&(p="LinearSRGBToLinearDisplayP3"),d){case Zx:case Iet:return[p,"LinearTransferOETF"];case Pd:case a2t:return[p,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",d),[p,"LinearTransferOETF"]}}function kYt(d,s,h){let p=d.getShaderParameter(s,d.COMPILE_STATUS),m=d.getShaderInfoLog(s).trim();if(p&&m==="")return"";let _=/ERROR: 0:(\d+)/.exec(m);if(_){let S=parseInt(_[1]);return h.toUpperCase()+` - -`+m+` - -`+D4e(d.getShaderSource(s),S)}else return m}function O4e(d,s){let h=N4e(s);return`vec4 ${d}( vec4 value ) { return ${h[0]}( ${h[1]}( value ) ); }`}function B4e(d,s){let h;switch(s){case eEe:h="Linear";break;case nEe:h="Reinhard";break;case iEe:h="OptimizedCineon";break;case rEe:h="ACESFilmic";break;case oEe:h="AgX";break;case sEe:h="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",s),h="Linear"}return"vec3 "+d+"( vec3 color ) { return "+h+"ToneMapping( color ); }"}function F4e(d){return[d.extensionDerivatives||d.envMapCubeUVHeight||d.bumpMap||d.normalMapTangentSpace||d.clearcoatNormalMap||d.flatShading||d.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(d.extensionFragDepth||d.logarithmicDepthBuffer)&&d.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",d.extensionDrawBuffers&&d.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(d.extensionShaderTextureLOD||d.envMap||d.transmission)&&d.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(ZI).join(` -`)}function U4e(d){return[d.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":""].filter(ZI).join(` -`)}function z4e(d){let s=[];for(let h in d){let p=d[h];p!==!1&&s.push("#define "+h+" "+p)}return s.join(` -`)}function j4e(d,s){let h={},p=d.getProgramParameter(s,d.ACTIVE_ATTRIBUTES);for(let m=0;m/gm;function Byt(d){return d.replace(H4e,W4e)}var G4e=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function W4e(d,s){let h=No[s];if(h===void 0){let p=G4e.get(s);if(p!==void 0)h=No[p],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',s,p);else throw new Error("Can not resolve #include <"+s+">")}return Byt(h)}var $4e=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function IYt(d){return d.replace($4e,V4e)}function V4e(d,s,h,p){let m="";for(let _=parseInt(s);_0&&(X+=` -`),gt=[j,"#define SHADER_TYPE "+h.shaderType,"#define SHADER_NAME "+h.shaderName,et].filter(ZI).join(` -`),gt.length>0&&(gt+=` -`)):(X=[RYt(h),"#define SHADER_TYPE "+h.shaderType,"#define SHADER_NAME "+h.shaderName,et,h.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",h.batching?"#define USE_BATCHING":"",h.instancing?"#define USE_INSTANCING":"",h.instancingColor?"#define USE_INSTANCING_COLOR":"",h.useFog&&h.fog?"#define USE_FOG":"",h.useFog&&h.fogExp2?"#define FOG_EXP2":"",h.map?"#define USE_MAP":"",h.envMap?"#define USE_ENVMAP":"",h.envMap?"#define "+B:"",h.lightMap?"#define USE_LIGHTMAP":"",h.aoMap?"#define USE_AOMAP":"",h.bumpMap?"#define USE_BUMPMAP":"",h.normalMap?"#define USE_NORMALMAP":"",h.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",h.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",h.displacementMap?"#define USE_DISPLACEMENTMAP":"",h.emissiveMap?"#define USE_EMISSIVEMAP":"",h.anisotropy?"#define USE_ANISOTROPY":"",h.anisotropyMap?"#define USE_ANISOTROPYMAP":"",h.clearcoatMap?"#define USE_CLEARCOATMAP":"",h.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",h.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",h.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",h.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",h.specularMap?"#define USE_SPECULARMAP":"",h.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",h.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",h.roughnessMap?"#define USE_ROUGHNESSMAP":"",h.metalnessMap?"#define USE_METALNESSMAP":"",h.alphaMap?"#define USE_ALPHAMAP":"",h.alphaHash?"#define USE_ALPHAHASH":"",h.transmission?"#define USE_TRANSMISSION":"",h.transmissionMap?"#define USE_TRANSMISSIONMAP":"",h.thicknessMap?"#define USE_THICKNESSMAP":"",h.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",h.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",h.mapUv?"#define MAP_UV "+h.mapUv:"",h.alphaMapUv?"#define ALPHAMAP_UV "+h.alphaMapUv:"",h.lightMapUv?"#define LIGHTMAP_UV "+h.lightMapUv:"",h.aoMapUv?"#define AOMAP_UV "+h.aoMapUv:"",h.emissiveMapUv?"#define EMISSIVEMAP_UV "+h.emissiveMapUv:"",h.bumpMapUv?"#define BUMPMAP_UV "+h.bumpMapUv:"",h.normalMapUv?"#define NORMALMAP_UV "+h.normalMapUv:"",h.displacementMapUv?"#define DISPLACEMENTMAP_UV "+h.displacementMapUv:"",h.metalnessMapUv?"#define METALNESSMAP_UV "+h.metalnessMapUv:"",h.roughnessMapUv?"#define ROUGHNESSMAP_UV "+h.roughnessMapUv:"",h.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+h.anisotropyMapUv:"",h.clearcoatMapUv?"#define CLEARCOATMAP_UV "+h.clearcoatMapUv:"",h.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+h.clearcoatNormalMapUv:"",h.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+h.clearcoatRoughnessMapUv:"",h.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+h.iridescenceMapUv:"",h.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+h.iridescenceThicknessMapUv:"",h.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+h.sheenColorMapUv:"",h.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+h.sheenRoughnessMapUv:"",h.specularMapUv?"#define SPECULARMAP_UV "+h.specularMapUv:"",h.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+h.specularColorMapUv:"",h.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+h.specularIntensityMapUv:"",h.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+h.transmissionMapUv:"",h.thicknessMapUv?"#define THICKNESSMAP_UV "+h.thicknessMapUv:"",h.vertexTangents&&h.flatShading===!1?"#define USE_TANGENT":"",h.vertexColors?"#define USE_COLOR":"",h.vertexAlphas?"#define USE_COLOR_ALPHA":"",h.vertexUv1s?"#define USE_UV1":"",h.vertexUv2s?"#define USE_UV2":"",h.vertexUv3s?"#define USE_UV3":"",h.pointsUvs?"#define USE_POINTS_UV":"",h.flatShading?"#define FLAT_SHADED":"",h.skinning?"#define USE_SKINNING":"",h.morphTargets?"#define USE_MORPHTARGETS":"",h.morphNormals&&h.flatShading===!1?"#define USE_MORPHNORMALS":"",h.morphColors&&h.isWebGL2?"#define USE_MORPHCOLORS":"",h.morphTargetsCount>0&&h.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",h.morphTargetsCount>0&&h.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+h.morphTextureStride:"",h.morphTargetsCount>0&&h.isWebGL2?"#define MORPHTARGETS_COUNT "+h.morphTargetsCount:"",h.doubleSided?"#define DOUBLE_SIDED":"",h.flipSided?"#define FLIP_SIDED":"",h.shadowMapEnabled?"#define USE_SHADOWMAP":"",h.shadowMapEnabled?"#define "+I:"",h.sizeAttenuation?"#define USE_SIZEATTENUATION":"",h.numLightProbes>0?"#define USE_LIGHT_PROBES":"",h.useLegacyLights?"#define LEGACY_LIGHTS":"",h.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",h.logarithmicDepthBuffer&&h.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` -`].filter(ZI).join(` -`),gt=[j,RYt(h),"#define SHADER_TYPE "+h.shaderType,"#define SHADER_NAME "+h.shaderName,et,h.useFog&&h.fog?"#define USE_FOG":"",h.useFog&&h.fogExp2?"#define FOG_EXP2":"",h.map?"#define USE_MAP":"",h.matcap?"#define USE_MATCAP":"",h.envMap?"#define USE_ENVMAP":"",h.envMap?"#define "+N:"",h.envMap?"#define "+B:"",h.envMap?"#define "+P:"",U?"#define CUBEUV_TEXEL_WIDTH "+U.texelWidth:"",U?"#define CUBEUV_TEXEL_HEIGHT "+U.texelHeight:"",U?"#define CUBEUV_MAX_MIP "+U.maxMip+".0":"",h.lightMap?"#define USE_LIGHTMAP":"",h.aoMap?"#define USE_AOMAP":"",h.bumpMap?"#define USE_BUMPMAP":"",h.normalMap?"#define USE_NORMALMAP":"",h.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",h.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",h.emissiveMap?"#define USE_EMISSIVEMAP":"",h.anisotropy?"#define USE_ANISOTROPY":"",h.anisotropyMap?"#define USE_ANISOTROPYMAP":"",h.clearcoat?"#define USE_CLEARCOAT":"",h.clearcoatMap?"#define USE_CLEARCOATMAP":"",h.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",h.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",h.iridescence?"#define USE_IRIDESCENCE":"",h.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",h.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",h.specularMap?"#define USE_SPECULARMAP":"",h.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",h.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",h.roughnessMap?"#define USE_ROUGHNESSMAP":"",h.metalnessMap?"#define USE_METALNESSMAP":"",h.alphaMap?"#define USE_ALPHAMAP":"",h.alphaTest?"#define USE_ALPHATEST":"",h.alphaHash?"#define USE_ALPHAHASH":"",h.sheen?"#define USE_SHEEN":"",h.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",h.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",h.transmission?"#define USE_TRANSMISSION":"",h.transmissionMap?"#define USE_TRANSMISSIONMAP":"",h.thicknessMap?"#define USE_THICKNESSMAP":"",h.vertexTangents&&h.flatShading===!1?"#define USE_TANGENT":"",h.vertexColors||h.instancingColor?"#define USE_COLOR":"",h.vertexAlphas?"#define USE_COLOR_ALPHA":"",h.vertexUv1s?"#define USE_UV1":"",h.vertexUv2s?"#define USE_UV2":"",h.vertexUv3s?"#define USE_UV3":"",h.pointsUvs?"#define USE_POINTS_UV":"",h.gradientMap?"#define USE_GRADIENTMAP":"",h.flatShading?"#define FLAT_SHADED":"",h.doubleSided?"#define DOUBLE_SIDED":"",h.flipSided?"#define FLIP_SIDED":"",h.shadowMapEnabled?"#define USE_SHADOWMAP":"",h.shadowMapEnabled?"#define "+I:"",h.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",h.numLightProbes>0?"#define USE_LIGHT_PROBES":"",h.useLegacyLights?"#define LEGACY_LIGHTS":"",h.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",h.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",h.logarithmicDepthBuffer&&h.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",h.toneMapping!==sS?"#define TONE_MAPPING":"",h.toneMapping!==sS?No.tonemapping_pars_fragment:"",h.toneMapping!==sS?B4e("toneMapping",h.toneMapping):"",h.dithering?"#define DITHERING":"",h.opaque?"#define OPAQUE":"",No.colorspace_pars_fragment,O4e("linearToOutputTexel",h.outputColorSpace),h.useDepthPacking?"#define DEPTH_PACKING "+h.depthPacking:"",` -`].filter(ZI).join(` -`)),S=Byt(S),S=LYt(S,h),S=PYt(S,h),y=Byt(y),y=LYt(y,h),y=PYt(y,h),S=IYt(S),y=IYt(y),h.isWebGL2&&h.isRawShaderMaterial!==!0&&(ft=`#version 300 es -`,X=[V,"precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(` + `}function dun(s){let n=new WeakMap,r=null;function c(w){if(w&&w.isTexture){let _=w.mapping,x=_===S6e||_===M6e,T=_===lO||_===uO;if(x||T)if(w.isRenderTargetTexture&&w.needsPMREMUpdate===!0){w.needsPMREMUpdate=!1;let M=n.get(w);return r===null&&(r=new she(s)),M=x?r.fromEquirectangular(w,M):r.fromCubemap(w,M),n.set(w,M),M.texture}else{if(n.has(w))return n.get(w).texture;{let M=w.image;if(x&&M&&M.height>0||T&&M&&u(M)){r===null&&(r=new she(s));let L=x?r.fromEquirectangular(w):r.fromCubemap(w);return n.set(w,L),w.addEventListener("dispose",d),L.texture}else return null}}}return w}function u(w){let _=0,x=6;for(let T=0;Tn.maxTextureSize&&(me=Math.ceil(Q/n.maxTextureSize),Q=n.maxTextureSize);let tt=new Float32Array(Q*me*4*D),st=new Jfe(tt,Q,me,D);st.type=fT,st.needsUpdate=!0;let at=Ce*4;for(let Qe=0;Qe0)return s;let u=n*r,d=Vyt[u];if(d===void 0&&(d=new Float32Array(u),Vyt[u]=d),n!==0){c.toArray(d,0);for(let b=1,w=0;b!==n;++b)w+=r,s[b].toArray(d,w)}return d}function fh(s,n){if(s.length!==n.length)return!1;for(let r=0,c=s.length;r":" "} ${w}: ${r[b]}`)}return c.join(` +`)}function hfn(s){let n=Ac.getPrimaries(Ac.workingColorSpace),r=Ac.getPrimaries(s),c;switch(n===r?c="":n===qfe&&r===Hfe?c="LinearDisplayP3ToLinearSRGB":n===Hfe&&r===qfe&&(c="LinearSRGBToLinearDisplayP3"),s){case X3:case whe:return[c,"LinearTransferOETF"];case Md:case u5e:return[c,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",s),[c,"LinearTransferOETF"]}}function Kyt(s,n,r){let c=s.getShaderParameter(n,s.COMPILE_STATUS),u=s.getShaderInfoLog(n).trim();if(c&&u==="")return"";let d=/ERROR: 0:(\d+)/.exec(u);if(d){let b=parseInt(d[1]);return r.toUpperCase()+` + +`+u+` + +`+ffn(s.getShaderSource(n),b)}else return u}function dfn(s,n){let r=hfn(n);return`vec4 ${s}( vec4 value ) { return ${r[0]}( ${r[1]}( value ) ); }`}function pfn(s,n){let r;switch(n){case Ron:r="Linear";break;case Ion:r="Reinhard";break;case Don:r="OptimizedCineon";break;case Bon:r="ACESFilmic";break;case Non:r="AgX";break;case Oon:r="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",n),r="Linear"}return"vec3 "+s+"( vec3 color ) { return "+r+"ToneMapping( color ); }"}function gfn(s){return[s.extensionDerivatives||s.envMapCubeUVHeight||s.bumpMap||s.normalMapTangentSpace||s.clearcoatNormalMap||s.flatShading||s.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(s.extensionFragDepth||s.logarithmicDepthBuffer)&&s.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",s.extensionDrawBuffers&&s.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(s.extensionShaderTextureLOD||s.envMap||s.transmission)&&s.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(sO).join(` +`)}function mfn(s){return[s.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":""].filter(sO).join(` +`)}function bfn(s){let n=[];for(let r in s){let c=s[r];c!==!1&&n.push("#define "+r+" "+c)}return n.join(` +`)}function wfn(s,n){let r={},c=s.getProgramParameter(n,s.ACTIVE_ATTRIBUTES);for(let u=0;u/gm;function U6e(s){return s.replace(vfn,yfn)}var _fn=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function yfn(s,n){let r=ko[n];if(r===void 0){let c=_fn.get(n);if(c!==void 0)r=ko[c],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',n,c);else throw new Error("Can not resolve #include <"+n+">")}return U6e(r)}var xfn=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function e2t(s){return s.replace(xfn,Efn)}function Efn(s,n,r,c){let u="";for(let d=parseInt(n);d0&&(z+=` +`),Z=[I,"#define SHADER_TYPE "+r.shaderType,"#define SHADER_NAME "+r.shaderName,F].filter(sO).join(` +`),Z.length>0&&(Z+=` +`)):(z=[t2t(r),"#define SHADER_TYPE "+r.shaderType,"#define SHADER_NAME "+r.shaderName,F,r.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",r.batching?"#define USE_BATCHING":"",r.instancing?"#define USE_INSTANCING":"",r.instancingColor?"#define USE_INSTANCING_COLOR":"",r.useFog&&r.fog?"#define USE_FOG":"",r.useFog&&r.fogExp2?"#define FOG_EXP2":"",r.map?"#define USE_MAP":"",r.envMap?"#define USE_ENVMAP":"",r.envMap?"#define "+T:"",r.lightMap?"#define USE_LIGHTMAP":"",r.aoMap?"#define USE_AOMAP":"",r.bumpMap?"#define USE_BUMPMAP":"",r.normalMap?"#define USE_NORMALMAP":"",r.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",r.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",r.displacementMap?"#define USE_DISPLACEMENTMAP":"",r.emissiveMap?"#define USE_EMISSIVEMAP":"",r.anisotropy?"#define USE_ANISOTROPY":"",r.anisotropyMap?"#define USE_ANISOTROPYMAP":"",r.clearcoatMap?"#define USE_CLEARCOATMAP":"",r.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",r.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",r.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",r.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",r.specularMap?"#define USE_SPECULARMAP":"",r.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",r.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",r.roughnessMap?"#define USE_ROUGHNESSMAP":"",r.metalnessMap?"#define USE_METALNESSMAP":"",r.alphaMap?"#define USE_ALPHAMAP":"",r.alphaHash?"#define USE_ALPHAHASH":"",r.transmission?"#define USE_TRANSMISSION":"",r.transmissionMap?"#define USE_TRANSMISSIONMAP":"",r.thicknessMap?"#define USE_THICKNESSMAP":"",r.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",r.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",r.mapUv?"#define MAP_UV "+r.mapUv:"",r.alphaMapUv?"#define ALPHAMAP_UV "+r.alphaMapUv:"",r.lightMapUv?"#define LIGHTMAP_UV "+r.lightMapUv:"",r.aoMapUv?"#define AOMAP_UV "+r.aoMapUv:"",r.emissiveMapUv?"#define EMISSIVEMAP_UV "+r.emissiveMapUv:"",r.bumpMapUv?"#define BUMPMAP_UV "+r.bumpMapUv:"",r.normalMapUv?"#define NORMALMAP_UV "+r.normalMapUv:"",r.displacementMapUv?"#define DISPLACEMENTMAP_UV "+r.displacementMapUv:"",r.metalnessMapUv?"#define METALNESSMAP_UV "+r.metalnessMapUv:"",r.roughnessMapUv?"#define ROUGHNESSMAP_UV "+r.roughnessMapUv:"",r.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+r.anisotropyMapUv:"",r.clearcoatMapUv?"#define CLEARCOATMAP_UV "+r.clearcoatMapUv:"",r.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+r.clearcoatNormalMapUv:"",r.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+r.clearcoatRoughnessMapUv:"",r.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+r.iridescenceMapUv:"",r.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+r.iridescenceThicknessMapUv:"",r.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+r.sheenColorMapUv:"",r.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+r.sheenRoughnessMapUv:"",r.specularMapUv?"#define SPECULARMAP_UV "+r.specularMapUv:"",r.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+r.specularColorMapUv:"",r.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+r.specularIntensityMapUv:"",r.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+r.transmissionMapUv:"",r.thicknessMapUv?"#define THICKNESSMAP_UV "+r.thicknessMapUv:"",r.vertexTangents&&r.flatShading===!1?"#define USE_TANGENT":"",r.vertexColors?"#define USE_COLOR":"",r.vertexAlphas?"#define USE_COLOR_ALPHA":"",r.vertexUv1s?"#define USE_UV1":"",r.vertexUv2s?"#define USE_UV2":"",r.vertexUv3s?"#define USE_UV3":"",r.pointsUvs?"#define USE_POINTS_UV":"",r.flatShading?"#define FLAT_SHADED":"",r.skinning?"#define USE_SKINNING":"",r.morphTargets?"#define USE_MORPHTARGETS":"",r.morphNormals&&r.flatShading===!1?"#define USE_MORPHNORMALS":"",r.morphColors&&r.isWebGL2?"#define USE_MORPHCOLORS":"",r.morphTargetsCount>0&&r.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",r.morphTargetsCount>0&&r.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+r.morphTextureStride:"",r.morphTargetsCount>0&&r.isWebGL2?"#define MORPHTARGETS_COUNT "+r.morphTargetsCount:"",r.doubleSided?"#define DOUBLE_SIDED":"",r.flipSided?"#define FLIP_SIDED":"",r.shadowMapEnabled?"#define USE_SHADOWMAP":"",r.shadowMapEnabled?"#define "+_:"",r.sizeAttenuation?"#define USE_SIZEATTENUATION":"",r.numLightProbes>0?"#define USE_LIGHT_PROBES":"",r.useLegacyLights?"#define LEGACY_LIGHTS":"",r.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",r.logarithmicDepthBuffer&&r.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(sO).join(` +`),Z=[I,t2t(r),"#define SHADER_TYPE "+r.shaderType,"#define SHADER_NAME "+r.shaderName,F,r.useFog&&r.fog?"#define USE_FOG":"",r.useFog&&r.fogExp2?"#define FOG_EXP2":"",r.map?"#define USE_MAP":"",r.matcap?"#define USE_MATCAP":"",r.envMap?"#define USE_ENVMAP":"",r.envMap?"#define "+x:"",r.envMap?"#define "+T:"",r.envMap?"#define "+M:"",L?"#define CUBEUV_TEXEL_WIDTH "+L.texelWidth:"",L?"#define CUBEUV_TEXEL_HEIGHT "+L.texelHeight:"",L?"#define CUBEUV_MAX_MIP "+L.maxMip+".0":"",r.lightMap?"#define USE_LIGHTMAP":"",r.aoMap?"#define USE_AOMAP":"",r.bumpMap?"#define USE_BUMPMAP":"",r.normalMap?"#define USE_NORMALMAP":"",r.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",r.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",r.emissiveMap?"#define USE_EMISSIVEMAP":"",r.anisotropy?"#define USE_ANISOTROPY":"",r.anisotropyMap?"#define USE_ANISOTROPYMAP":"",r.clearcoat?"#define USE_CLEARCOAT":"",r.clearcoatMap?"#define USE_CLEARCOATMAP":"",r.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",r.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",r.iridescence?"#define USE_IRIDESCENCE":"",r.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",r.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",r.specularMap?"#define USE_SPECULARMAP":"",r.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",r.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",r.roughnessMap?"#define USE_ROUGHNESSMAP":"",r.metalnessMap?"#define USE_METALNESSMAP":"",r.alphaMap?"#define USE_ALPHAMAP":"",r.alphaTest?"#define USE_ALPHATEST":"",r.alphaHash?"#define USE_ALPHAHASH":"",r.sheen?"#define USE_SHEEN":"",r.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",r.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",r.transmission?"#define USE_TRANSMISSION":"",r.transmissionMap?"#define USE_TRANSMISSIONMAP":"",r.thicknessMap?"#define USE_THICKNESSMAP":"",r.vertexTangents&&r.flatShading===!1?"#define USE_TANGENT":"",r.vertexColors||r.instancingColor?"#define USE_COLOR":"",r.vertexAlphas?"#define USE_COLOR_ALPHA":"",r.vertexUv1s?"#define USE_UV1":"",r.vertexUv2s?"#define USE_UV2":"",r.vertexUv3s?"#define USE_UV3":"",r.pointsUvs?"#define USE_POINTS_UV":"",r.gradientMap?"#define USE_GRADIENTMAP":"",r.flatShading?"#define FLAT_SHADED":"",r.doubleSided?"#define DOUBLE_SIDED":"",r.flipSided?"#define FLIP_SIDED":"",r.shadowMapEnabled?"#define USE_SHADOWMAP":"",r.shadowMapEnabled?"#define "+_:"",r.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",r.numLightProbes>0?"#define USE_LIGHT_PROBES":"",r.useLegacyLights?"#define LEGACY_LIGHTS":"",r.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",r.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",r.logarithmicDepthBuffer&&r.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",r.toneMapping!==pT?"#define TONE_MAPPING":"",r.toneMapping!==pT?ko.tonemapping_pars_fragment:"",r.toneMapping!==pT?pfn("toneMapping",r.toneMapping):"",r.dithering?"#define DITHERING":"",r.opaque?"#define OPAQUE":"",ko.colorspace_pars_fragment,dfn("linearToOutputTexel",r.outputColorSpace),r.useDepthPacking?"#define DEPTH_PACKING "+r.depthPacking:"",` +`].filter(sO).join(` +`)),b=U6e(b),b=Jyt(b,r),b=Qyt(b,r),w=U6e(w),w=Jyt(w,r),w=Qyt(w,r),b=e2t(b),w=e2t(w),r.isWebGL2&&r.isRawShaderMaterial!==!0&&(H=`#version 300 es +`,z=[D,"precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` -`+X,gt=["precision mediump sampler2DArray;","#define varying in",h.glslVersion===JZt?"":"layout(location = 0) out highp vec4 pc_fragColor;",h.glslVersion===JZt?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` +`+z,Z=["precision mediump sampler2DArray;","#define varying in",r.glslVersion===_yt?"":"layout(location = 0) out highp vec4 pc_fragColor;",r.glslVersion===_yt?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` `)+` -`+gt);let xt=ft+X+S,Bt=ft+gt+y,Dt=AYt(m,m.VERTEX_SHADER,xt),Pt=AYt(m,m.FRAGMENT_SHADER,Bt);m.attachShader(Q,Dt),m.attachShader(Q,Pt),h.index0AttributeName!==void 0?m.bindAttribLocation(Q,0,h.index0AttributeName):h.morphTargets===!0&&m.bindAttribLocation(Q,0,"position"),m.linkProgram(Q);function se(ln){if(d.debug.checkShaderErrors){let Fn=m.getProgramInfoLog(Q).trim(),ne=m.getShaderInfoLog(Dt).trim(),xe=m.getShaderInfoLog(Pt).trim(),re=!0,hn=!0;if(m.getProgramParameter(Q,m.LINK_STATUS)===!1)if(re=!1,typeof d.debug.onShaderError=="function")d.debug.onShaderError(m,Q,Dt,Pt);else{let Se=kYt(m,Dt,"vertex"),ke=kYt(m,Pt,"fragment");console.error("THREE.WebGLProgram: Shader Error "+m.getError()+" - VALIDATE_STATUS "+m.getProgramParameter(Q,m.VALIDATE_STATUS)+` +`+Z);let te=H+z+b,se=H+Z+w,ne=Zyt(u,u.VERTEX_SHADER,te),ue=Zyt(u,u.FRAGMENT_SHADER,se);u.attachShader(O,ne),u.attachShader(O,ue),r.index0AttributeName!==void 0?u.bindAttribLocation(O,0,r.index0AttributeName):r.morphTargets===!0&&u.bindAttribLocation(O,0,"position"),u.linkProgram(O);function Ce(st){if(s.debug.checkShaderErrors){let at=u.getProgramInfoLog(O).trim(),Ne=u.getShaderInfoLog(ne).trim(),Qe=u.getShaderInfoLog(ue).trim(),ot=!0,xt=!0;if(u.getProgramParameter(O,u.LINK_STATUS)===!1)if(ot=!1,typeof s.debug.onShaderError=="function")s.debug.onShaderError(u,O,ne,ue);else{let fn=Kyt(u,ne,"vertex"),Xt=Kyt(u,ue,"fragment");console.error("THREE.WebGLProgram: Shader Error "+u.getError()+" - VALIDATE_STATUS "+u.getProgramParameter(O,u.VALIDATE_STATUS)+` -Program Info Log: `+Fn+` -`+Se+` -`+ke)}else Fn!==""?console.warn("THREE.WebGLProgram: Program Info Log:",Fn):(ne===""||xe==="")&&(hn=!1);hn&&(ln.diagnostics={runnable:re,programLog:Fn,vertexShader:{log:ne,prefix:X},fragmentShader:{log:xe,prefix:gt}})}m.deleteShader(Dt),m.deleteShader(Pt),ot=new JI(m,Q),Lt=j4e(m,Q)}let ot;this.getUniforms=function(){return ot===void 0&&se(this),ot};let Lt;this.getAttributes=function(){return Lt===void 0&&se(this),Lt};let be=h.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return be===!1&&(be=m.getProgramParameter(Q,I4e)),be},this.destroy=function(){p.releaseStatesOfProgram(this),m.deleteProgram(Q),this.program=void 0},this.type=h.shaderType,this.name=h.shaderName,this.id=R4e++,this.cacheKey=s,this.usedTimes=1,this.program=Q,this.vertexShader=Dt,this.fragmentShader=Pt,this}var Q4e=0,Fyt=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(s){let h=s.vertexShader,p=s.fragmentShader,m=this._getShaderStage(h),_=this._getShaderStage(p),S=this._getShaderCacheForMaterial(s);return S.has(m)===!1&&(S.add(m),m.usedTimes++),S.has(_)===!1&&(S.add(_),_.usedTimes++),this}remove(s){let h=this.materialCache.get(s);for(let p of h)p.usedTimes--,p.usedTimes===0&&this.shaderCache.delete(p.code);return this.materialCache.delete(s),this}getVertexShaderID(s){return this._getShaderStage(s.vertexShader).id}getFragmentShaderID(s){return this._getShaderStage(s.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(s){let h=this.materialCache,p=h.get(s);return p===void 0&&(p=new Set,h.set(s,p)),p}_getShaderStage(s){let h=this.shaderCache,p=h.get(s);return p===void 0&&(p=new Uyt(s),h.set(s,p)),p}},Uyt=class{constructor(s){this.id=Q4e++,this.code=s,this.usedTimes=0}};function tAe(d,s,h,p,m,_,S){let y=new _U,I=new Fyt,N=[],B=m.isWebGL2,P=m.logarithmicDepthBuffer,U=m.vertexTextures,j=m.precision,V={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function et(ot){return ot===0?"uv":`uv${ot}`}function Q(ot,Lt,be,ln,Fn){let ne=ln.fog,xe=Fn.geometry,re=ot.isMeshStandardMaterial?ln.environment:null,hn=(ot.isMeshStandardMaterial?h:s).get(ot.envMap||re),Se=hn&&hn.mapping===Pet?hn.image.height:null,ke=V[ot.type];ot.precision!==null&&(j=m.getMaxPrecision(ot.precision),j!==ot.precision&&console.warn("THREE.WebGLProgram.getParameters:",ot.precision,"not supported, using",j,"instead."));let mn=xe.morphAttributes.position||xe.morphAttributes.normal||xe.morphAttributes.color,en=mn!==void 0?mn.length:0,Qn=0;xe.morphAttributes.position!==void 0&&(Qn=1),xe.morphAttributes.normal!==void 0&&(Qn=2),xe.morphAttributes.color!==void 0&&(Qn=3);let ge,Pe,ti,Yi;if(ke){let ru=wy[ke];ge=ru.vertexShader,Pe=ru.fragmentShader}else ge=ot.vertexShader,Pe=ot.fragmentShader,I.update(ot),ti=I.getVertexShaderID(ot),Yi=I.getFragmentShaderID(ot);let ki=d.getRenderTarget(),lr=Fn.isInstancedMesh===!0,pr=Fn.isBatchedMesh===!0,Kt=!!ot.map,wn=!!ot.matcap,it=!!hn,ut=!!ot.aoMap,kt=!!ot.lightMap,Ot=!!ot.bumpMap,ie=!!ot.normalMap,rn=!!ot.displacementMap,Pn=!!ot.emissiveMap,Tt=!!ot.metalnessMap,yt=!!ot.roughnessMap,ue=ot.anisotropy>0,fn=ot.clearcoat>0,An=ot.iridescence>0,zn=ot.sheen>0,Li=ot.transmission>0,xi=ue&&!!ot.anisotropyMap,Jt=fn&&!!ot.clearcoatMap,nn=fn&&!!ot.clearcoatNormalMap,vn=fn&&!!ot.clearcoatRoughnessMap,he=An&&!!ot.iridescenceMap,Mn=An&&!!ot.iridescenceThicknessMap,Sn=zn&&!!ot.sheenColorMap,gn=zn&&!!ot.sheenRoughnessMap,Ce=!!ot.specularMap,dn=!!ot.specularColorMap,jn=!!ot.specularIntensityMap,ar=Li&&!!ot.transmissionMap,gr=Li&&!!ot.thicknessMap,tr=!!ot.gradientMap,Ln=!!ot.alphaMap,Qt=ot.alphaTest>0,Mi=!!ot.alphaHash,sn=!!ot.extensions,Zn=!!xe.attributes.uv1,oi=!!xe.attributes.uv2,Jr=!!xe.attributes.uv3,Bs=sS;return ot.toneMapped&&(ki===null||ki.isXRRenderTarget===!0)&&(Bs=d.toneMapping),{isWebGL2:B,shaderID:ke,shaderType:ot.type,shaderName:ot.name,vertexShader:ge,fragmentShader:Pe,defines:ot.defines,customVertexShaderID:ti,customFragmentShaderID:Yi,isRawShaderMaterial:ot.isRawShaderMaterial===!0,glslVersion:ot.glslVersion,precision:j,batching:pr,instancing:lr,instancingColor:lr&&Fn.instanceColor!==null,supportsVertexTextures:U,outputColorSpace:ki===null?d.outputColorSpace:ki.isXRRenderTarget===!0?ki.texture.colorSpace:Zx,map:Kt,matcap:wn,envMap:it,envMapMode:it&&hn.mapping,envMapCubeUVHeight:Se,aoMap:ut,lightMap:kt,bumpMap:Ot,normalMap:ie,displacementMap:U&&rn,emissiveMap:Pn,normalMapObjectSpace:ie&&ot.normalMapType===wEe,normalMapTangentSpace:ie&&ot.normalMapType===iKt,metalnessMap:Tt,roughnessMap:yt,anisotropy:ue,anisotropyMap:xi,clearcoat:fn,clearcoatMap:Jt,clearcoatNormalMap:nn,clearcoatRoughnessMap:vn,iridescence:An,iridescenceMap:he,iridescenceThicknessMap:Mn,sheen:zn,sheenColorMap:Sn,sheenRoughnessMap:gn,specularMap:Ce,specularColorMap:dn,specularIntensityMap:jn,transmission:Li,transmissionMap:ar,thicknessMap:gr,gradientMap:tr,opaque:ot.transparent===!1&&ot.blending===YI,alphaMap:Ln,alphaTest:Qt,alphaHash:Mi,combine:ot.combine,mapUv:Kt&&et(ot.map.channel),aoMapUv:ut&&et(ot.aoMap.channel),lightMapUv:kt&&et(ot.lightMap.channel),bumpMapUv:Ot&&et(ot.bumpMap.channel),normalMapUv:ie&&et(ot.normalMap.channel),displacementMapUv:rn&&et(ot.displacementMap.channel),emissiveMapUv:Pn&&et(ot.emissiveMap.channel),metalnessMapUv:Tt&&et(ot.metalnessMap.channel),roughnessMapUv:yt&&et(ot.roughnessMap.channel),anisotropyMapUv:xi&&et(ot.anisotropyMap.channel),clearcoatMapUv:Jt&&et(ot.clearcoatMap.channel),clearcoatNormalMapUv:nn&&et(ot.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:vn&&et(ot.clearcoatRoughnessMap.channel),iridescenceMapUv:he&&et(ot.iridescenceMap.channel),iridescenceThicknessMapUv:Mn&&et(ot.iridescenceThicknessMap.channel),sheenColorMapUv:Sn&&et(ot.sheenColorMap.channel),sheenRoughnessMapUv:gn&&et(ot.sheenRoughnessMap.channel),specularMapUv:Ce&&et(ot.specularMap.channel),specularColorMapUv:dn&&et(ot.specularColorMap.channel),specularIntensityMapUv:jn&&et(ot.specularIntensityMap.channel),transmissionMapUv:ar&&et(ot.transmissionMap.channel),thicknessMapUv:gr&&et(ot.thicknessMap.channel),alphaMapUv:Ln&&et(ot.alphaMap.channel),vertexTangents:!!xe.attributes.tangent&&(ie||ue),vertexColors:ot.vertexColors,vertexAlphas:ot.vertexColors===!0&&!!xe.attributes.color&&xe.attributes.color.itemSize===4,vertexUv1s:Zn,vertexUv2s:oi,vertexUv3s:Jr,pointsUvs:Fn.isPoints===!0&&!!xe.attributes.uv&&(Kt||Ln),fog:!!ne,useFog:ot.fog===!0,fogExp2:ne&&ne.isFogExp2,flatShading:ot.flatShading===!0,sizeAttenuation:ot.sizeAttenuation===!0,logarithmicDepthBuffer:P,skinning:Fn.isSkinnedMesh===!0,morphTargets:xe.morphAttributes.position!==void 0,morphNormals:xe.morphAttributes.normal!==void 0,morphColors:xe.morphAttributes.color!==void 0,morphTargetsCount:en,morphTextureStride:Qn,numDirLights:Lt.directional.length,numPointLights:Lt.point.length,numSpotLights:Lt.spot.length,numSpotLightMaps:Lt.spotLightMap.length,numRectAreaLights:Lt.rectArea.length,numHemiLights:Lt.hemi.length,numDirLightShadows:Lt.directionalShadowMap.length,numPointLightShadows:Lt.pointShadowMap.length,numSpotLightShadows:Lt.spotShadowMap.length,numSpotLightShadowsWithMaps:Lt.numSpotLightShadowsWithMaps,numLightProbes:Lt.numLightProbes,numClippingPlanes:S.numPlanes,numClipIntersection:S.numIntersection,dithering:ot.dithering,shadowMapEnabled:d.shadowMap.enabled&&be.length>0,shadowMapType:d.shadowMap.type,toneMapping:Bs,useLegacyLights:d._useLegacyLights,decodeVideoTexture:Kt&&ot.map.isVideoTexture===!0&&Na.getTransfer(ot.map.colorSpace)===vu,premultipliedAlpha:ot.premultipliedAlpha,doubleSided:ot.side===$w,flipSided:ot.side===gg,useDepthPacking:ot.depthPacking>=0,depthPacking:ot.depthPacking||0,index0AttributeName:ot.index0AttributeName,extensionDerivatives:sn&&ot.extensions.derivatives===!0,extensionFragDepth:sn&&ot.extensions.fragDepth===!0,extensionDrawBuffers:sn&&ot.extensions.drawBuffers===!0,extensionShaderTextureLOD:sn&&ot.extensions.shaderTextureLOD===!0,extensionClipCullDistance:sn&&ot.extensions.clipCullDistance&&p.has("WEBGL_clip_cull_distance"),rendererExtensionFragDepth:B||p.has("EXT_frag_depth"),rendererExtensionDrawBuffers:B||p.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:B||p.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:p.has("KHR_parallel_shader_compile"),customProgramCacheKey:ot.customProgramCacheKey()}}function X(ot){let Lt=[];if(ot.shaderID?Lt.push(ot.shaderID):(Lt.push(ot.customVertexShaderID),Lt.push(ot.customFragmentShaderID)),ot.defines!==void 0)for(let be in ot.defines)Lt.push(be),Lt.push(ot.defines[be]);return ot.isRawShaderMaterial===!1&&(gt(Lt,ot),ft(Lt,ot),Lt.push(d.outputColorSpace)),Lt.push(ot.customProgramCacheKey),Lt.join()}function gt(ot,Lt){ot.push(Lt.precision),ot.push(Lt.outputColorSpace),ot.push(Lt.envMapMode),ot.push(Lt.envMapCubeUVHeight),ot.push(Lt.mapUv),ot.push(Lt.alphaMapUv),ot.push(Lt.lightMapUv),ot.push(Lt.aoMapUv),ot.push(Lt.bumpMapUv),ot.push(Lt.normalMapUv),ot.push(Lt.displacementMapUv),ot.push(Lt.emissiveMapUv),ot.push(Lt.metalnessMapUv),ot.push(Lt.roughnessMapUv),ot.push(Lt.anisotropyMapUv),ot.push(Lt.clearcoatMapUv),ot.push(Lt.clearcoatNormalMapUv),ot.push(Lt.clearcoatRoughnessMapUv),ot.push(Lt.iridescenceMapUv),ot.push(Lt.iridescenceThicknessMapUv),ot.push(Lt.sheenColorMapUv),ot.push(Lt.sheenRoughnessMapUv),ot.push(Lt.specularMapUv),ot.push(Lt.specularColorMapUv),ot.push(Lt.specularIntensityMapUv),ot.push(Lt.transmissionMapUv),ot.push(Lt.thicknessMapUv),ot.push(Lt.combine),ot.push(Lt.fogExp2),ot.push(Lt.sizeAttenuation),ot.push(Lt.morphTargetsCount),ot.push(Lt.morphAttributeCount),ot.push(Lt.numDirLights),ot.push(Lt.numPointLights),ot.push(Lt.numSpotLights),ot.push(Lt.numSpotLightMaps),ot.push(Lt.numHemiLights),ot.push(Lt.numRectAreaLights),ot.push(Lt.numDirLightShadows),ot.push(Lt.numPointLightShadows),ot.push(Lt.numSpotLightShadows),ot.push(Lt.numSpotLightShadowsWithMaps),ot.push(Lt.numLightProbes),ot.push(Lt.shadowMapType),ot.push(Lt.toneMapping),ot.push(Lt.numClippingPlanes),ot.push(Lt.numClipIntersection),ot.push(Lt.depthPacking)}function ft(ot,Lt){y.disableAll(),Lt.isWebGL2&&y.enable(0),Lt.supportsVertexTextures&&y.enable(1),Lt.instancing&&y.enable(2),Lt.instancingColor&&y.enable(3),Lt.matcap&&y.enable(4),Lt.envMap&&y.enable(5),Lt.normalMapObjectSpace&&y.enable(6),Lt.normalMapTangentSpace&&y.enable(7),Lt.clearcoat&&y.enable(8),Lt.iridescence&&y.enable(9),Lt.alphaTest&&y.enable(10),Lt.vertexColors&&y.enable(11),Lt.vertexAlphas&&y.enable(12),Lt.vertexUv1s&&y.enable(13),Lt.vertexUv2s&&y.enable(14),Lt.vertexUv3s&&y.enable(15),Lt.vertexTangents&&y.enable(16),Lt.anisotropy&&y.enable(17),Lt.alphaHash&&y.enable(18),Lt.batching&&y.enable(19),ot.push(y.mask),y.disableAll(),Lt.fog&&y.enable(0),Lt.useFog&&y.enable(1),Lt.flatShading&&y.enable(2),Lt.logarithmicDepthBuffer&&y.enable(3),Lt.skinning&&y.enable(4),Lt.morphTargets&&y.enable(5),Lt.morphNormals&&y.enable(6),Lt.morphColors&&y.enable(7),Lt.premultipliedAlpha&&y.enable(8),Lt.shadowMapEnabled&&y.enable(9),Lt.useLegacyLights&&y.enable(10),Lt.doubleSided&&y.enable(11),Lt.flipSided&&y.enable(12),Lt.useDepthPacking&&y.enable(13),Lt.dithering&&y.enable(14),Lt.transmission&&y.enable(15),Lt.sheen&&y.enable(16),Lt.opaque&&y.enable(17),Lt.pointsUvs&&y.enable(18),Lt.decodeVideoTexture&&y.enable(19),ot.push(y.mask)}function xt(ot){let Lt=V[ot.type],be;if(Lt){let ln=wy[Lt];be=GEe.clone(ln.uniforms)}else be=ot.uniforms;return be}function Bt(ot,Lt){let be;for(let ln=0,Fn=N.length;ln0?p.push(X):j.transparent===!0?m.push(X):h.push(X)}function I(P,U,j,V,et,Q){let X=S(P,U,j,V,et,Q);j.transmission>0?p.unshift(X):j.transparent===!0?m.unshift(X):h.unshift(X)}function N(P,U){h.length>1&&h.sort(P||nAe),p.length>1&&p.sort(U||DYt),m.length>1&&m.sort(U||DYt)}function B(){for(let P=s,U=d.length;P=_.length?(S=new NYt,_.push(S)):S=_[m],S}function h(){d=new WeakMap}return{get:s,dispose:h}}function rAe(){let d={};return{get:function(s){if(d[s.id]!==void 0)return d[s.id];let h;switch(s.type){case"DirectionalLight":h={direction:new Ge,color:new Go};break;case"SpotLight":h={position:new Ge,direction:new Ge,color:new Go,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":h={position:new Ge,color:new Go,distance:0,decay:0};break;case"HemisphereLight":h={direction:new Ge,skyColor:new Go,groundColor:new Go};break;case"RectAreaLight":h={color:new Go,position:new Ge,halfWidth:new Ge,halfHeight:new Ge};break}return d[s.id]=h,h}}}function sAe(){let d={};return{get:function(s){if(d[s.id]!==void 0)return d[s.id];let h;switch(s.type){case"DirectionalLight":h={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Nc};break;case"SpotLight":h={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Nc};break;case"PointLight":h={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Nc,shadowCameraNear:1,shadowCameraFar:1e3};break}return d[s.id]=h,h}}}var oAe=0;function cAe(d,s){return(s.castShadow?2:0)-(d.castShadow?2:0)+(s.map?1:0)-(d.map?1:0)}function aAe(d,s){let h=new rAe,p=sAe(),m={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let B=0;B<9;B++)m.probe.push(new Ge);let _=new Ge,S=new Bu,y=new Bu;function I(B,P){let U=0,j=0,V=0;for(let ln=0;ln<9;ln++)m.probe[ln].set(0,0,0);let et=0,Q=0,X=0,gt=0,ft=0,xt=0,Bt=0,Dt=0,Pt=0,se=0,ot=0;B.sort(cAe);let Lt=P===!0?Math.PI:1;for(let ln=0,Fn=B.length;ln0&&(s.isWebGL2?d.has("OES_texture_float_linear")===!0?(m.rectAreaLTC1=Zi.LTC_FLOAT_1,m.rectAreaLTC2=Zi.LTC_FLOAT_2):(m.rectAreaLTC1=Zi.LTC_HALF_1,m.rectAreaLTC2=Zi.LTC_HALF_2):d.has("OES_texture_float_linear")===!0?(m.rectAreaLTC1=Zi.LTC_FLOAT_1,m.rectAreaLTC2=Zi.LTC_FLOAT_2):d.has("OES_texture_half_float_linear")===!0?(m.rectAreaLTC1=Zi.LTC_HALF_1,m.rectAreaLTC2=Zi.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),m.ambient[0]=U,m.ambient[1]=j,m.ambient[2]=V;let be=m.hash;(be.directionalLength!==et||be.pointLength!==Q||be.spotLength!==X||be.rectAreaLength!==gt||be.hemiLength!==ft||be.numDirectionalShadows!==xt||be.numPointShadows!==Bt||be.numSpotShadows!==Dt||be.numSpotMaps!==Pt||be.numLightProbes!==ot)&&(m.directional.length=et,m.spot.length=X,m.rectArea.length=gt,m.point.length=Q,m.hemi.length=ft,m.directionalShadow.length=xt,m.directionalShadowMap.length=xt,m.pointShadow.length=Bt,m.pointShadowMap.length=Bt,m.spotShadow.length=Dt,m.spotShadowMap.length=Dt,m.directionalShadowMatrix.length=xt,m.pointShadowMatrix.length=Bt,m.spotLightMatrix.length=Dt+Pt-se,m.spotLightMap.length=Pt,m.numSpotLightShadowsWithMaps=se,m.numLightProbes=ot,be.directionalLength=et,be.pointLength=Q,be.spotLength=X,be.rectAreaLength=gt,be.hemiLength=ft,be.numDirectionalShadows=xt,be.numPointShadows=Bt,be.numSpotShadows=Dt,be.numSpotMaps=Pt,be.numLightProbes=ot,m.version=oAe++)}function N(B,P){let U=0,j=0,V=0,et=0,Q=0,X=P.matrixWorldInverse;for(let gt=0,ft=B.length;gt=y.length?(I=new OYt(d,s),y.push(I)):I=y[S],I}function m(){h=new WeakMap}return{get:p,dispose:m}}var zyt=class extends lS{constructor(s){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=mEe,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(s)}copy(s){return super.copy(s),this.depthPacking=s.depthPacking,this.map=s.map,this.alphaMap=s.alphaMap,this.displacementMap=s.displacementMap,this.displacementScale=s.displacementScale,this.displacementBias=s.displacementBias,this.wireframe=s.wireframe,this.wireframeLinewidth=s.wireframeLinewidth,this}},jyt=class extends lS{constructor(s){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(s)}copy(s){return super.copy(s),this.map=s.map,this.alphaMap=s.alphaMap,this.displacementMap=s.displacementMap,this.displacementScale=s.displacementScale,this.displacementBias=s.displacementBias,this}},lAe=`void main() { +Program Info Log: `+at+` +`+fn+` +`+Xt)}else at!==""?console.warn("THREE.WebGLProgram: Program Info Log:",at):(Ne===""||Qe==="")&&(xt=!1);xt&&(st.diagnostics={runnable:ot,programLog:at,vertexShader:{log:Ne,prefix:z},fragmentShader:{log:Qe,prefix:Z}})}u.deleteShader(ne),u.deleteShader(ue),Q=new cO(u,O),me=wfn(u,O)}let Q;this.getUniforms=function(){return Q===void 0&&Ce(this),Q};let me;this.getAttributes=function(){return me===void 0&&Ce(this),me};let tt=r.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return tt===!1&&(tt=u.getProgramParameter(O,lfn)),tt},this.destroy=function(){c.releaseStatesOfProgram(this),u.deleteProgram(O),this.program=void 0},this.type=r.shaderType,this.name=r.shaderName,this.id=ufn++,this.cacheKey=n,this.usedTimes=1,this.program=O,this.vertexShader=ne,this.fragmentShader=ue,this}var Lfn=0,z6e=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(n){let r=n.vertexShader,c=n.fragmentShader,u=this._getShaderStage(r),d=this._getShaderStage(c),b=this._getShaderCacheForMaterial(n);return b.has(u)===!1&&(b.add(u),u.usedTimes++),b.has(d)===!1&&(b.add(d),d.usedTimes++),this}remove(n){let r=this.materialCache.get(n);for(let c of r)c.usedTimes--,c.usedTimes===0&&this.shaderCache.delete(c.code);return this.materialCache.delete(n),this}getVertexShaderID(n){return this._getShaderStage(n.vertexShader).id}getFragmentShaderID(n){return this._getShaderStage(n.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(n){let r=this.materialCache,c=r.get(n);return c===void 0&&(c=new Set,r.set(n,c)),c}_getShaderStage(n){let r=this.shaderCache,c=r.get(n);return c===void 0&&(c=new G6e(n),r.set(n,c)),c}},G6e=class{constructor(n){this.id=Lfn++,this.code=n,this.usedTimes=0}};function kfn(s,n,r,c,u,d,b){let w=new NW,_=new z6e,x=[],T=u.isWebGL2,M=u.logarithmicDepthBuffer,L=u.vertexTextures,I=u.precision,D={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function F(Q){return Q===0?"uv":`uv${Q}`}function O(Q,me,tt,st,at){let Ne=st.fog,Qe=at.geometry,ot=Q.isMeshStandardMaterial?st.environment:null,xt=(Q.isMeshStandardMaterial?r:n).get(Q.envMap||ot),fn=xt&&xt.mapping===bhe?xt.image.height:null,Xt=D[Q.type];Q.precision!==null&&(I=u.getMaxPrecision(Q.precision),I!==Q.precision&&console.warn("THREE.WebGLProgram.getParameters:",Q.precision,"not supported, using",I,"instead."));let wn=Qe.morphAttributes.position||Qe.morphAttributes.normal||Qe.morphAttributes.color,cn=wn!==void 0?wn.length:0,bi=0;Qe.morphAttributes.position!==void 0&&(bi=1),Qe.morphAttributes.normal!==void 0&&(bi=2),Qe.morphAttributes.color!==void 0&&(bi=3);let jt,gn,Un,Zi;if(Xt){let Ri=f2[Xt];jt=Ri.vertexShader,gn=Ri.fragmentShader}else jt=Q.vertexShader,gn=Q.fragmentShader,_.update(Q),Un=_.getVertexShaderID(Q),Zi=_.getFragmentShaderID(Q);let Hi=s.getRenderTarget(),yr=at.isInstancedMesh===!0,Tr=at.isBatchedMesh===!0,Ei=!!Q.map,xr=!!Q.matcap,oe=!!xt,de=!!Q.aoMap,it=!!Q.lightMap,We=!!Q.bumpMap,_n=!!Q.normalMap,Er=!!Q.displacementMap,qi=!!Q.emissiveMap,Te=!!Q.metalnessMap,ve=!!Q.roughnessMap,_t=Q.anisotropy>0,mn=Q.clearcoat>0,yn=Q.iridescence>0,Sn=Q.sheen>0,yi=Q.transmission>0,hi=_t&&!!Q.anisotropyMap,ri=mn&&!!Q.clearcoatMap,Ge=mn&&!!Q.clearcoatNormalMap,Pe=mn&&!!Q.clearcoatRoughnessMap,ke=yn&&!!Q.iridescenceMap,dt=yn&&!!Q.iridescenceThicknessMap,Ye=Sn&&!!Q.sheenColorMap,ct=Sn&&!!Q.sheenRoughnessMap,Ze=!!Q.specularMap,Ke=!!Q.specularColorMap,gt=!!Q.specularIntensityMap,qn=yi&&!!Q.transmissionMap,xi=yi&&!!Q.thicknessMap,Bi=!!Q.gradientMap,xn=!!Q.alphaMap,Je=Q.alphaTest>0,ti=!!Q.alphaHash,Zn=!!Q.extensions,rr=!!Qe.attributes.uv1,Me=!!Qe.attributes.uv2,et=!!Qe.attributes.uv3,ht=pT;return Q.toneMapped&&(Hi===null||Hi.isXRRenderTarget===!0)&&(ht=s.toneMapping),{isWebGL2:T,shaderID:Xt,shaderType:Q.type,shaderName:Q.name,vertexShader:jt,fragmentShader:gn,defines:Q.defines,customVertexShaderID:Un,customFragmentShaderID:Zi,isRawShaderMaterial:Q.isRawShaderMaterial===!0,glslVersion:Q.glslVersion,precision:I,batching:Tr,instancing:yr,instancingColor:yr&&at.instanceColor!==null,supportsVertexTextures:L,outputColorSpace:Hi===null?s.outputColorSpace:Hi.isXRRenderTarget===!0?Hi.texture.colorSpace:X3,map:Ei,matcap:xr,envMap:oe,envMapMode:oe&&xt.mapping,envMapCubeUVHeight:fn,aoMap:de,lightMap:it,bumpMap:We,normalMap:_n,displacementMap:L&&Er,emissiveMap:qi,normalMapObjectSpace:_n&&Q.normalMapType===Yon,normalMapTangentSpace:_n&&Q.normalMapType===M2t,metalnessMap:Te,roughnessMap:ve,anisotropy:_t,anisotropyMap:hi,clearcoat:mn,clearcoatMap:ri,clearcoatNormalMap:Ge,clearcoatRoughnessMap:Pe,iridescence:yn,iridescenceMap:ke,iridescenceThicknessMap:dt,sheen:Sn,sheenColorMap:Ye,sheenRoughnessMap:ct,specularMap:Ze,specularColorMap:Ke,specularIntensityMap:gt,transmission:yi,transmissionMap:qn,thicknessMap:xi,gradientMap:Bi,opaque:Q.transparent===!1&&Q.blending===oO,alphaMap:xn,alphaTest:Je,alphaHash:ti,combine:Q.combine,mapUv:Ei&&F(Q.map.channel),aoMapUv:de&&F(Q.aoMap.channel),lightMapUv:it&&F(Q.lightMap.channel),bumpMapUv:We&&F(Q.bumpMap.channel),normalMapUv:_n&&F(Q.normalMap.channel),displacementMapUv:Er&&F(Q.displacementMap.channel),emissiveMapUv:qi&&F(Q.emissiveMap.channel),metalnessMapUv:Te&&F(Q.metalnessMap.channel),roughnessMapUv:ve&&F(Q.roughnessMap.channel),anisotropyMapUv:hi&&F(Q.anisotropyMap.channel),clearcoatMapUv:ri&&F(Q.clearcoatMap.channel),clearcoatNormalMapUv:Ge&&F(Q.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Pe&&F(Q.clearcoatRoughnessMap.channel),iridescenceMapUv:ke&&F(Q.iridescenceMap.channel),iridescenceThicknessMapUv:dt&&F(Q.iridescenceThicknessMap.channel),sheenColorMapUv:Ye&&F(Q.sheenColorMap.channel),sheenRoughnessMapUv:ct&&F(Q.sheenRoughnessMap.channel),specularMapUv:Ze&&F(Q.specularMap.channel),specularColorMapUv:Ke&&F(Q.specularColorMap.channel),specularIntensityMapUv:gt&&F(Q.specularIntensityMap.channel),transmissionMapUv:qn&&F(Q.transmissionMap.channel),thicknessMapUv:xi&&F(Q.thicknessMap.channel),alphaMapUv:xn&&F(Q.alphaMap.channel),vertexTangents:!!Qe.attributes.tangent&&(_n||_t),vertexColors:Q.vertexColors,vertexAlphas:Q.vertexColors===!0&&!!Qe.attributes.color&&Qe.attributes.color.itemSize===4,vertexUv1s:rr,vertexUv2s:Me,vertexUv3s:et,pointsUvs:at.isPoints===!0&&!!Qe.attributes.uv&&(Ei||xn),fog:!!Ne,useFog:Q.fog===!0,fogExp2:Ne&&Ne.isFogExp2,flatShading:Q.flatShading===!0,sizeAttenuation:Q.sizeAttenuation===!0,logarithmicDepthBuffer:M,skinning:at.isSkinnedMesh===!0,morphTargets:Qe.morphAttributes.position!==void 0,morphNormals:Qe.morphAttributes.normal!==void 0,morphColors:Qe.morphAttributes.color!==void 0,morphTargetsCount:cn,morphTextureStride:bi,numDirLights:me.directional.length,numPointLights:me.point.length,numSpotLights:me.spot.length,numSpotLightMaps:me.spotLightMap.length,numRectAreaLights:me.rectArea.length,numHemiLights:me.hemi.length,numDirLightShadows:me.directionalShadowMap.length,numPointLightShadows:me.pointShadowMap.length,numSpotLightShadows:me.spotShadowMap.length,numSpotLightShadowsWithMaps:me.numSpotLightShadowsWithMaps,numLightProbes:me.numLightProbes,numClippingPlanes:b.numPlanes,numClipIntersection:b.numIntersection,dithering:Q.dithering,shadowMapEnabled:s.shadowMap.enabled&&tt.length>0,shadowMapType:s.shadowMap.type,toneMapping:ht,useLegacyLights:s._useLegacyLights,decodeVideoTexture:Ei&&Q.map.isVideoTexture===!0&&Ac.getTransfer(Q.map.colorSpace)===hl,premultipliedAlpha:Q.premultipliedAlpha,doubleSided:Q.side===Ev,flipSided:Q.side===Tm,useDepthPacking:Q.depthPacking>=0,depthPacking:Q.depthPacking||0,index0AttributeName:Q.index0AttributeName,extensionDerivatives:Zn&&Q.extensions.derivatives===!0,extensionFragDepth:Zn&&Q.extensions.fragDepth===!0,extensionDrawBuffers:Zn&&Q.extensions.drawBuffers===!0,extensionShaderTextureLOD:Zn&&Q.extensions.shaderTextureLOD===!0,extensionClipCullDistance:Zn&&Q.extensions.clipCullDistance&&c.has("WEBGL_clip_cull_distance"),rendererExtensionFragDepth:T||c.has("EXT_frag_depth"),rendererExtensionDrawBuffers:T||c.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:T||c.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:c.has("KHR_parallel_shader_compile"),customProgramCacheKey:Q.customProgramCacheKey()}}function z(Q){let me=[];if(Q.shaderID?me.push(Q.shaderID):(me.push(Q.customVertexShaderID),me.push(Q.customFragmentShaderID)),Q.defines!==void 0)for(let tt in Q.defines)me.push(tt),me.push(Q.defines[tt]);return Q.isRawShaderMaterial===!1&&(Z(me,Q),H(me,Q),me.push(s.outputColorSpace)),me.push(Q.customProgramCacheKey),me.join()}function Z(Q,me){Q.push(me.precision),Q.push(me.outputColorSpace),Q.push(me.envMapMode),Q.push(me.envMapCubeUVHeight),Q.push(me.mapUv),Q.push(me.alphaMapUv),Q.push(me.lightMapUv),Q.push(me.aoMapUv),Q.push(me.bumpMapUv),Q.push(me.normalMapUv),Q.push(me.displacementMapUv),Q.push(me.emissiveMapUv),Q.push(me.metalnessMapUv),Q.push(me.roughnessMapUv),Q.push(me.anisotropyMapUv),Q.push(me.clearcoatMapUv),Q.push(me.clearcoatNormalMapUv),Q.push(me.clearcoatRoughnessMapUv),Q.push(me.iridescenceMapUv),Q.push(me.iridescenceThicknessMapUv),Q.push(me.sheenColorMapUv),Q.push(me.sheenRoughnessMapUv),Q.push(me.specularMapUv),Q.push(me.specularColorMapUv),Q.push(me.specularIntensityMapUv),Q.push(me.transmissionMapUv),Q.push(me.thicknessMapUv),Q.push(me.combine),Q.push(me.fogExp2),Q.push(me.sizeAttenuation),Q.push(me.morphTargetsCount),Q.push(me.morphAttributeCount),Q.push(me.numDirLights),Q.push(me.numPointLights),Q.push(me.numSpotLights),Q.push(me.numSpotLightMaps),Q.push(me.numHemiLights),Q.push(me.numRectAreaLights),Q.push(me.numDirLightShadows),Q.push(me.numPointLightShadows),Q.push(me.numSpotLightShadows),Q.push(me.numSpotLightShadowsWithMaps),Q.push(me.numLightProbes),Q.push(me.shadowMapType),Q.push(me.toneMapping),Q.push(me.numClippingPlanes),Q.push(me.numClipIntersection),Q.push(me.depthPacking)}function H(Q,me){w.disableAll(),me.isWebGL2&&w.enable(0),me.supportsVertexTextures&&w.enable(1),me.instancing&&w.enable(2),me.instancingColor&&w.enable(3),me.matcap&&w.enable(4),me.envMap&&w.enable(5),me.normalMapObjectSpace&&w.enable(6),me.normalMapTangentSpace&&w.enable(7),me.clearcoat&&w.enable(8),me.iridescence&&w.enable(9),me.alphaTest&&w.enable(10),me.vertexColors&&w.enable(11),me.vertexAlphas&&w.enable(12),me.vertexUv1s&&w.enable(13),me.vertexUv2s&&w.enable(14),me.vertexUv3s&&w.enable(15),me.vertexTangents&&w.enable(16),me.anisotropy&&w.enable(17),me.alphaHash&&w.enable(18),me.batching&&w.enable(19),Q.push(w.mask),w.disableAll(),me.fog&&w.enable(0),me.useFog&&w.enable(1),me.flatShading&&w.enable(2),me.logarithmicDepthBuffer&&w.enable(3),me.skinning&&w.enable(4),me.morphTargets&&w.enable(5),me.morphNormals&&w.enable(6),me.morphColors&&w.enable(7),me.premultipliedAlpha&&w.enable(8),me.shadowMapEnabled&&w.enable(9),me.useLegacyLights&&w.enable(10),me.doubleSided&&w.enable(11),me.flipSided&&w.enable(12),me.useDepthPacking&&w.enable(13),me.dithering&&w.enable(14),me.transmission&&w.enable(15),me.sheen&&w.enable(16),me.opaque&&w.enable(17),me.pointsUvs&&w.enable(18),me.decodeVideoTexture&&w.enable(19),Q.push(w.mask)}function te(Q){let me=D[Q.type],tt;if(me){let st=f2[me];tt=_an.clone(st.uniforms)}else tt=Q.uniforms;return tt}function se(Q,me){let tt;for(let st=0,at=x.length;st0?c.push(z):I.transparent===!0?u.push(z):r.push(z)}function _(M,L,I,D,F,O){let z=b(M,L,I,D,F,O);I.transmission>0?c.unshift(z):I.transparent===!0?u.unshift(z):r.unshift(z)}function x(M,L){r.length>1&&r.sort(M||Ifn),c.length>1&&c.sort(L||n2t),u.length>1&&u.sort(L||n2t)}function T(){for(let M=n,L=s.length;M=d.length?(b=new i2t,d.push(b)):b=d[u],b}function r(){s=new WeakMap}return{get:n,dispose:r}}function Bfn(){let s={};return{get:function(n){if(s[n.id]!==void 0)return s[n.id];let r;switch(n.type){case"DirectionalLight":r={direction:new Gt,color:new zo};break;case"SpotLight":r={position:new Gt,direction:new Gt,color:new zo,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":r={position:new Gt,color:new zo,distance:0,decay:0};break;case"HemisphereLight":r={direction:new Gt,skyColor:new zo,groundColor:new zo};break;case"RectAreaLight":r={color:new zo,position:new Gt,halfWidth:new Gt,halfHeight:new Gt};break}return s[n.id]=r,r}}}function Ofn(){let s={};return{get:function(n){if(s[n.id]!==void 0)return s[n.id];let r;switch(n.type){case"DirectionalLight":r={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new La};break;case"SpotLight":r={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new La};break;case"PointLight":r={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new La,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[n.id]=r,r}}}var Nfn=0;function Ffn(s,n){return(n.castShadow?2:0)-(s.castShadow?2:0)+(n.map?1:0)-(s.map?1:0)}function Ufn(s,n){let r=new Bfn,c=Ofn(),u={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let T=0;T<9;T++)u.probe.push(new Gt);let d=new Gt,b=new Rl,w=new Rl;function _(T,M){let L=0,I=0,D=0;for(let st=0;st<9;st++)u.probe[st].set(0,0,0);let F=0,O=0,z=0,Z=0,H=0,te=0,se=0,ne=0,ue=0,Ce=0,Q=0;T.sort(Ffn);let me=M===!0?Math.PI:1;for(let st=0,at=T.length;st0&&(n.isWebGL2?s.has("OES_texture_float_linear")===!0?(u.rectAreaLTC1=ji.LTC_FLOAT_1,u.rectAreaLTC2=ji.LTC_FLOAT_2):(u.rectAreaLTC1=ji.LTC_HALF_1,u.rectAreaLTC2=ji.LTC_HALF_2):s.has("OES_texture_float_linear")===!0?(u.rectAreaLTC1=ji.LTC_FLOAT_1,u.rectAreaLTC2=ji.LTC_FLOAT_2):s.has("OES_texture_half_float_linear")===!0?(u.rectAreaLTC1=ji.LTC_HALF_1,u.rectAreaLTC2=ji.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),u.ambient[0]=L,u.ambient[1]=I,u.ambient[2]=D;let tt=u.hash;(tt.directionalLength!==F||tt.pointLength!==O||tt.spotLength!==z||tt.rectAreaLength!==Z||tt.hemiLength!==H||tt.numDirectionalShadows!==te||tt.numPointShadows!==se||tt.numSpotShadows!==ne||tt.numSpotMaps!==ue||tt.numLightProbes!==Q)&&(u.directional.length=F,u.spot.length=z,u.rectArea.length=Z,u.point.length=O,u.hemi.length=H,u.directionalShadow.length=te,u.directionalShadowMap.length=te,u.pointShadow.length=se,u.pointShadowMap.length=se,u.spotShadow.length=ne,u.spotShadowMap.length=ne,u.directionalShadowMatrix.length=te,u.pointShadowMatrix.length=se,u.spotLightMatrix.length=ne+ue-Ce,u.spotLightMap.length=ue,u.numSpotLightShadowsWithMaps=Ce,u.numLightProbes=Q,tt.directionalLength=F,tt.pointLength=O,tt.spotLength=z,tt.rectAreaLength=Z,tt.hemiLength=H,tt.numDirectionalShadows=te,tt.numPointShadows=se,tt.numSpotShadows=ne,tt.numSpotMaps=ue,tt.numLightProbes=Q,u.version=Nfn++)}function x(T,M){let L=0,I=0,D=0,F=0,O=0,z=M.matrixWorldInverse;for(let Z=0,H=T.length;Z=w.length?(_=new r2t(s,n),w.push(_)):_=w[b],_}function u(){r=new WeakMap}return{get:c,dispose:u}}var j6e=class extends vT{constructor(n){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=qon,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(n)}copy(n){return super.copy(n),this.depthPacking=n.depthPacking,this.map=n.map,this.alphaMap=n.alphaMap,this.displacementMap=n.displacementMap,this.displacementScale=n.displacementScale,this.displacementBias=n.displacementBias,this.wireframe=n.wireframe,this.wireframeLinewidth=n.wireframeLinewidth,this}},$6e=class extends vT{constructor(n){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(n)}copy(n){return super.copy(n),this.map=n.map,this.alphaMap=n.alphaMap,this.displacementMap=n.displacementMap,this.displacementScale=n.displacementScale,this.displacementBias=n.displacementBias,this}},Gfn=`void main() { gl_Position = vec4( position, 1.0 ); -}`,hAe=`uniform sampler2D shadow_pass; +}`,jfn=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include @@ -3742,7 +10099,7 @@ void main() { squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); -}`;function fAe(d,s,h){let p=new yU,m=new Nc,_=new Nc,S=new $f,y=new zyt({depthPacking:bEe}),I=new jyt,N={},B=h.maxTextureSize,P={[cS]:gg,[gg]:cS,[$w]:$w},U=new Jx({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Nc},radius:{value:4}},vertexShader:lAe,fragmentShader:hAe}),j=U.clone();j.defines.HORIZONTAL_PASS=1;let V=new _y;V.setAttribute("position",new R0(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let et=new pg(V,U),Q=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=qYt;let X=this.type;this.render=function(Dt,Pt,se){if(Q.enabled===!1||Q.autoUpdate===!1&&Q.needsUpdate===!1||Dt.length===0)return;let ot=d.getRenderTarget(),Lt=d.getActiveCubeFace(),be=d.getActiveMipmapLevel(),ln=d.state;ln.setBlending(rS),ln.buffers.color.setClear(1,1,1,1),ln.buffers.depth.setTest(!0),ln.setScissorTest(!1);let Fn=X!==Vx&&this.type===Vx,ne=X===Vx&&this.type!==Vx;for(let xe=0,re=Dt.length;xeB||m.y>B)&&(m.x>B&&(_.x=Math.floor(B/ke.x),m.x=_.x*ke.x,Se.mapSize.x=_.x),m.y>B&&(_.y=Math.floor(B/ke.y),m.y=_.y*ke.y,Se.mapSize.y=_.y)),Se.map===null||Fn===!0||ne===!0){let en=this.type!==Vx?{minFilter:r1,magFilter:r1}:{};Se.map!==null&&Se.map.dispose(),Se.map=new Yx(m.x,m.y,en),Se.map.texture.name=hn.name+".shadowMap",Se.camera.updateProjectionMatrix()}d.setRenderTarget(Se.map),d.clear();let mn=Se.getViewportCount();for(let en=0;en0||Pt.map&&Pt.alphaTest>0){let ln=Lt.uuid,Fn=Pt.uuid,ne=N[ln];ne===void 0&&(ne={},N[ln]=ne);let xe=ne[Fn];xe===void 0&&(xe=Lt.clone(),ne[Fn]=xe,Pt.addEventListener("dispose",Bt)),Lt=xe}if(Lt.visible=Pt.visible,Lt.wireframe=Pt.wireframe,ot===Vx?Lt.side=Pt.shadowSide!==null?Pt.shadowSide:Pt.side:Lt.side=Pt.shadowSide!==null?Pt.shadowSide:P[Pt.side],Lt.alphaMap=Pt.alphaMap,Lt.alphaTest=Pt.alphaTest,Lt.map=Pt.map,Lt.clipShadows=Pt.clipShadows,Lt.clippingPlanes=Pt.clippingPlanes,Lt.clipIntersection=Pt.clipIntersection,Lt.displacementMap=Pt.displacementMap,Lt.displacementScale=Pt.displacementScale,Lt.displacementBias=Pt.displacementBias,Lt.wireframeLinewidth=Pt.wireframeLinewidth,Lt.linewidth=Pt.linewidth,se.isPointLight===!0&&Lt.isMeshDistanceMaterial===!0){let ln=d.properties.get(Lt);ln.light=se}return Lt}function xt(Dt,Pt,se,ot,Lt){if(Dt.visible===!1)return;if(Dt.layers.test(Pt.layers)&&(Dt.isMesh||Dt.isLine||Dt.isPoints)&&(Dt.castShadow||Dt.receiveShadow&&Lt===Vx)&&(!Dt.frustumCulled||p.intersectsObject(Dt))){Dt.modelViewMatrix.multiplyMatrices(se.matrixWorldInverse,Dt.matrixWorld);let Fn=s.update(Dt),ne=Dt.material;if(Array.isArray(ne)){let xe=Fn.groups;for(let re=0,hn=xe.length;re=1):mn.indexOf("OpenGL ES")!==-1&&(ke=parseFloat(/^OpenGL ES (\d)/.exec(mn)[1]),Se=ke>=2);let en=null,Qn={},ge=d.getParameter(d.SCISSOR_BOX),Pe=d.getParameter(d.VIEWPORT),ti=new $f().fromArray(ge),Yi=new $f().fromArray(Pe);function ki(Qt,Mi,sn,Zn){let oi=new Uint8Array(4),Jr=d.createTexture();d.bindTexture(Qt,Jr),d.texParameteri(Qt,d.TEXTURE_MIN_FILTER,d.NEAREST),d.texParameteri(Qt,d.TEXTURE_MAG_FILTER,d.NEAREST);for(let Bs=0;Bs"u"?!1:/OculusBrowser/g.test(navigator.userAgent),B=new WeakMap,P,U=new WeakMap,j=!1;try{j=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function V(Tt,yt){return j?new OffscreenCanvas(Tt,yt):cet("canvas")}function et(Tt,yt,ue,fn){let An=1;if((Tt.width>fn||Tt.height>fn)&&(An=fn/Math.max(Tt.width,Tt.height)),An<1||yt===!0)if(typeof HTMLImageElement<"u"&&Tt instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&Tt instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&Tt instanceof ImageBitmap){let zn=yt?Ayt:Math.floor,Li=zn(An*Tt.width),xi=zn(An*Tt.height);P===void 0&&(P=V(Li,xi));let Jt=ue?V(Li,xi):P;return Jt.width=Li,Jt.height=xi,Jt.getContext("2d").drawImage(Tt,0,0,Li,xi),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Tt.width+"x"+Tt.height+") to ("+Li+"x"+xi+")."),Jt}else return"data"in Tt&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Tt.width+"x"+Tt.height+")."),Tt;return Tt}function Q(Tt){return QZt(Tt.width)&&QZt(Tt.height)}function X(Tt){return y?!1:Tt.wrapS!==Vw||Tt.wrapT!==Vw||Tt.minFilter!==r1&&Tt.minFilter!==pb}function gt(Tt,yt){return Tt.generateMipmaps&&yt&&Tt.minFilter!==r1&&Tt.minFilter!==pb}function ft(Tt){d.generateMipmap(Tt)}function xt(Tt,yt,ue,fn,An=!1){if(y===!1)return yt;if(Tt!==null){if(d[Tt]!==void 0)return d[Tt];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+Tt+"'")}let zn=yt;if(yt===d.RED&&(ue===d.FLOAT&&(zn=d.R32F),ue===d.HALF_FLOAT&&(zn=d.R16F),ue===d.UNSIGNED_BYTE&&(zn=d.R8)),yt===d.RED_INTEGER&&(ue===d.UNSIGNED_BYTE&&(zn=d.R8UI),ue===d.UNSIGNED_SHORT&&(zn=d.R16UI),ue===d.UNSIGNED_INT&&(zn=d.R32UI),ue===d.BYTE&&(zn=d.R8I),ue===d.SHORT&&(zn=d.R16I),ue===d.INT&&(zn=d.R32I)),yt===d.RG&&(ue===d.FLOAT&&(zn=d.RG32F),ue===d.HALF_FLOAT&&(zn=d.RG16F),ue===d.UNSIGNED_BYTE&&(zn=d.RG8)),yt===d.RGBA){let Li=An?iet:Na.getTransfer(fn);ue===d.FLOAT&&(zn=d.RGBA32F),ue===d.HALF_FLOAT&&(zn=d.RGBA16F),ue===d.UNSIGNED_BYTE&&(zn=Li===vu?d.SRGB8_ALPHA8:d.RGBA8),ue===d.UNSIGNED_SHORT_4_4_4_4&&(zn=d.RGBA4),ue===d.UNSIGNED_SHORT_5_5_5_1&&(zn=d.RGB5_A1)}return(zn===d.R16F||zn===d.R32F||zn===d.RG16F||zn===d.RG32F||zn===d.RGBA16F||zn===d.RGBA32F)&&s.get("EXT_color_buffer_float"),zn}function Bt(Tt,yt,ue){return gt(Tt,ue)===!0||Tt.isFramebufferTexture&&Tt.minFilter!==r1&&Tt.minFilter!==pb?Math.log2(Math.max(yt.width,yt.height))+1:Tt.mipmaps!==void 0&&Tt.mipmaps.length>0?Tt.mipmaps.length:Tt.isCompressedTexture&&Array.isArray(Tt.image)?yt.mipmaps.length:1}function Dt(Tt){return Tt===r1||Tt===yZt||Tt===j_t?d.NEAREST:d.LINEAR}function Pt(Tt){let yt=Tt.target;yt.removeEventListener("dispose",Pt),ot(yt),yt.isVideoTexture&&B.delete(yt)}function se(Tt){let yt=Tt.target;yt.removeEventListener("dispose",se),be(yt)}function ot(Tt){let yt=p.get(Tt);if(yt.__webglInit===void 0)return;let ue=Tt.source,fn=U.get(ue);if(fn){let An=fn[yt.__cacheKey];An.usedTimes--,An.usedTimes===0&&Lt(Tt),Object.keys(fn).length===0&&U.delete(ue)}p.remove(Tt)}function Lt(Tt){let yt=p.get(Tt);d.deleteTexture(yt.__webglTexture);let ue=Tt.source,fn=U.get(ue);delete fn[yt.__cacheKey],S.memory.textures--}function be(Tt){let yt=Tt.texture,ue=p.get(Tt),fn=p.get(yt);if(fn.__webglTexture!==void 0&&(d.deleteTexture(fn.__webglTexture),S.memory.textures--),Tt.depthTexture&&Tt.depthTexture.dispose(),Tt.isWebGLCubeRenderTarget)for(let An=0;An<6;An++){if(Array.isArray(ue.__webglFramebuffer[An]))for(let zn=0;zn=m.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+Tt+" texture units while this GPU supports only "+m.maxTextures),ln+=1,Tt}function xe(Tt){let yt=[];return yt.push(Tt.wrapS),yt.push(Tt.wrapT),yt.push(Tt.wrapR||0),yt.push(Tt.magFilter),yt.push(Tt.minFilter),yt.push(Tt.anisotropy),yt.push(Tt.internalFormat),yt.push(Tt.format),yt.push(Tt.type),yt.push(Tt.generateMipmaps),yt.push(Tt.premultiplyAlpha),yt.push(Tt.flipY),yt.push(Tt.unpackAlignment),yt.push(Tt.colorSpace),yt.join()}function re(Tt,yt){let ue=p.get(Tt);if(Tt.isVideoTexture&&rn(Tt),Tt.isRenderTargetTexture===!1&&Tt.version>0&&ue.__version!==Tt.version){let fn=Tt.image;if(fn===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(fn.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ti(ue,Tt,yt);return}}h.bindTexture(d.TEXTURE_2D,ue.__webglTexture,d.TEXTURE0+yt)}function hn(Tt,yt){let ue=p.get(Tt);if(Tt.version>0&&ue.__version!==Tt.version){ti(ue,Tt,yt);return}h.bindTexture(d.TEXTURE_2D_ARRAY,ue.__webglTexture,d.TEXTURE0+yt)}function Se(Tt,yt){let ue=p.get(Tt);if(Tt.version>0&&ue.__version!==Tt.version){ti(ue,Tt,yt);return}h.bindTexture(d.TEXTURE_3D,ue.__webglTexture,d.TEXTURE0+yt)}function ke(Tt,yt){let ue=p.get(Tt);if(Tt.version>0&&ue.__version!==Tt.version){Yi(ue,Tt,yt);return}h.bindTexture(d.TEXTURE_CUBE_MAP,ue.__webglTexture,d.TEXTURE0+yt)}let mn={[Eyt]:d.REPEAT,[Vw]:d.CLAMP_TO_EDGE,[Syt]:d.MIRRORED_REPEAT},en={[r1]:d.NEAREST,[yZt]:d.NEAREST_MIPMAP_NEAREST,[j_t]:d.NEAREST_MIPMAP_LINEAR,[pb]:d.LINEAR,[cEe]:d.LINEAR_MIPMAP_NEAREST,[bU]:d.LINEAR_MIPMAP_LINEAR},Qn={[vEe]:d.NEVER,[SEe]:d.ALWAYS,[_Ee]:d.LESS,[rKt]:d.LEQUAL,[yEe]:d.EQUAL,[EEe]:d.GEQUAL,[xEe]:d.GREATER,[MEe]:d.NOTEQUAL};function ge(Tt,yt,ue){if(ue?(d.texParameteri(Tt,d.TEXTURE_WRAP_S,mn[yt.wrapS]),d.texParameteri(Tt,d.TEXTURE_WRAP_T,mn[yt.wrapT]),(Tt===d.TEXTURE_3D||Tt===d.TEXTURE_2D_ARRAY)&&d.texParameteri(Tt,d.TEXTURE_WRAP_R,mn[yt.wrapR]),d.texParameteri(Tt,d.TEXTURE_MAG_FILTER,en[yt.magFilter]),d.texParameteri(Tt,d.TEXTURE_MIN_FILTER,en[yt.minFilter])):(d.texParameteri(Tt,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(Tt,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),(Tt===d.TEXTURE_3D||Tt===d.TEXTURE_2D_ARRAY)&&d.texParameteri(Tt,d.TEXTURE_WRAP_R,d.CLAMP_TO_EDGE),(yt.wrapS!==Vw||yt.wrapT!==Vw)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),d.texParameteri(Tt,d.TEXTURE_MAG_FILTER,Dt(yt.magFilter)),d.texParameteri(Tt,d.TEXTURE_MIN_FILTER,Dt(yt.minFilter)),yt.minFilter!==r1&&yt.minFilter!==pb&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),yt.compareFunction&&(d.texParameteri(Tt,d.TEXTURE_COMPARE_MODE,d.COMPARE_REF_TO_TEXTURE),d.texParameteri(Tt,d.TEXTURE_COMPARE_FUNC,Qn[yt.compareFunction])),s.has("EXT_texture_filter_anisotropic")===!0){let fn=s.get("EXT_texture_filter_anisotropic");if(yt.magFilter===r1||yt.minFilter!==j_t&&yt.minFilter!==bU||yt.type===nS&&s.has("OES_texture_float_linear")===!1||y===!1&&yt.type===wU&&s.has("OES_texture_half_float_linear")===!1)return;(yt.anisotropy>1||p.get(yt).__currentAnisotropy)&&(d.texParameterf(Tt,fn.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(yt.anisotropy,m.getMaxAnisotropy())),p.get(yt).__currentAnisotropy=yt.anisotropy)}}function Pe(Tt,yt){let ue=!1;Tt.__webglInit===void 0&&(Tt.__webglInit=!0,yt.addEventListener("dispose",Pt));let fn=yt.source,An=U.get(fn);An===void 0&&(An={},U.set(fn,An));let zn=xe(yt);if(zn!==Tt.__cacheKey){An[zn]===void 0&&(An[zn]={texture:d.createTexture(),usedTimes:0},S.memory.textures++,ue=!0),An[zn].usedTimes++;let Li=An[Tt.__cacheKey];Li!==void 0&&(An[Tt.__cacheKey].usedTimes--,Li.usedTimes===0&&Lt(yt)),Tt.__cacheKey=zn,Tt.__webglTexture=An[zn].texture}return ue}function ti(Tt,yt,ue){let fn=d.TEXTURE_2D;(yt.isDataArrayTexture||yt.isCompressedArrayTexture)&&(fn=d.TEXTURE_2D_ARRAY),yt.isData3DTexture&&(fn=d.TEXTURE_3D);let An=Pe(Tt,yt),zn=yt.source;h.bindTexture(fn,Tt.__webglTexture,d.TEXTURE0+ue);let Li=p.get(zn);if(zn.version!==Li.__version||An===!0){h.activeTexture(d.TEXTURE0+ue);let xi=Na.getPrimaries(Na.workingColorSpace),Jt=yt.colorSpace===gb?null:Na.getPrimaries(yt.colorSpace),nn=yt.colorSpace===gb||xi===Jt?d.NONE:d.BROWSER_DEFAULT_WEBGL;d.pixelStorei(d.UNPACK_FLIP_Y_WEBGL,yt.flipY),d.pixelStorei(d.UNPACK_PREMULTIPLY_ALPHA_WEBGL,yt.premultiplyAlpha),d.pixelStorei(d.UNPACK_ALIGNMENT,yt.unpackAlignment),d.pixelStorei(d.UNPACK_COLORSPACE_CONVERSION_WEBGL,nn);let vn=X(yt)&&Q(yt.image)===!1,he=et(yt.image,vn,!1,m.maxTextureSize);he=Pn(yt,he);let Mn=Q(he)||y,Sn=_.convert(yt.format,yt.colorSpace),gn=_.convert(yt.type),Ce=xt(yt.internalFormat,Sn,gn,yt.colorSpace,yt.isVideoTexture);ge(fn,yt,Mn);let dn,jn=yt.mipmaps,ar=y&&yt.isVideoTexture!==!0&&Ce!==eKt,gr=Li.__version===void 0||An===!0,tr=Bt(yt,he,Mn);if(yt.isDepthTexture)Ce=d.DEPTH_COMPONENT,y?yt.type===nS?Ce=d.DEPTH_COMPONENT32F:yt.type===eS?Ce=d.DEPTH_COMPONENT24:yt.type===GA?Ce=d.DEPTH24_STENCIL8:Ce=d.DEPTH_COMPONENT16:yt.type===nS&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),yt.format===WA&&Ce===d.DEPTH_COMPONENT&&yt.type!==c2t&&yt.type!==eS&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),yt.type=eS,gn=_.convert(yt.type)),yt.format===eR&&Ce===d.DEPTH_COMPONENT&&(Ce=d.DEPTH_STENCIL,yt.type!==GA&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),yt.type=GA,gn=_.convert(yt.type))),gr&&(ar?h.texStorage2D(d.TEXTURE_2D,1,Ce,he.width,he.height):h.texImage2D(d.TEXTURE_2D,0,Ce,he.width,he.height,0,Sn,gn,null));else if(yt.isDataTexture)if(jn.length>0&&Mn){ar&&gr&&h.texStorage2D(d.TEXTURE_2D,tr,Ce,jn[0].width,jn[0].height);for(let Ln=0,Qt=jn.length;Ln>=1,Qt>>=1}}else if(jn.length>0&&Mn){ar&&gr&&h.texStorage2D(d.TEXTURE_2D,tr,Ce,jn[0].width,jn[0].height);for(let Ln=0,Qt=jn.length;Ln0&&gr++,h.texStorage2D(d.TEXTURE_CUBE_MAP,gr,dn,he[0].width,he[0].height));for(let Ln=0;Ln<6;Ln++)if(vn){jn?h.texSubImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_X+Ln,0,0,0,he[Ln].width,he[Ln].height,gn,Ce,he[Ln].data):h.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_X+Ln,0,dn,he[Ln].width,he[Ln].height,0,gn,Ce,he[Ln].data);for(let Qt=0;Qt>zn),he=Math.max(1,yt.height>>zn);An===d.TEXTURE_3D||An===d.TEXTURE_2D_ARRAY?h.texImage3D(An,zn,Jt,vn,he,yt.depth,0,Li,xi,null):h.texImage2D(An,zn,Jt,vn,he,0,Li,xi,null)}h.bindFramebuffer(d.FRAMEBUFFER,Tt),ie(yt)?I.framebufferTexture2DMultisampleEXT(d.FRAMEBUFFER,fn,An,p.get(ue).__webglTexture,0,Ot(yt)):(An===d.TEXTURE_2D||An>=d.TEXTURE_CUBE_MAP_POSITIVE_X&&An<=d.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&d.framebufferTexture2D(d.FRAMEBUFFER,fn,An,p.get(ue).__webglTexture,zn),h.bindFramebuffer(d.FRAMEBUFFER,null)}function lr(Tt,yt,ue){if(d.bindRenderbuffer(d.RENDERBUFFER,Tt),yt.depthBuffer&&!yt.stencilBuffer){let fn=y===!0?d.DEPTH_COMPONENT24:d.DEPTH_COMPONENT16;if(ue||ie(yt)){let An=yt.depthTexture;An&&An.isDepthTexture&&(An.type===nS?fn=d.DEPTH_COMPONENT32F:An.type===eS&&(fn=d.DEPTH_COMPONENT24));let zn=Ot(yt);ie(yt)?I.renderbufferStorageMultisampleEXT(d.RENDERBUFFER,zn,fn,yt.width,yt.height):d.renderbufferStorageMultisample(d.RENDERBUFFER,zn,fn,yt.width,yt.height)}else d.renderbufferStorage(d.RENDERBUFFER,fn,yt.width,yt.height);d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_ATTACHMENT,d.RENDERBUFFER,Tt)}else if(yt.depthBuffer&&yt.stencilBuffer){let fn=Ot(yt);ue&&ie(yt)===!1?d.renderbufferStorageMultisample(d.RENDERBUFFER,fn,d.DEPTH24_STENCIL8,yt.width,yt.height):ie(yt)?I.renderbufferStorageMultisampleEXT(d.RENDERBUFFER,fn,d.DEPTH24_STENCIL8,yt.width,yt.height):d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_STENCIL,yt.width,yt.height),d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_STENCIL_ATTACHMENT,d.RENDERBUFFER,Tt)}else{let fn=yt.isWebGLMultipleRenderTargets===!0?yt.texture:[yt.texture];for(let An=0;An0){ue.__webglFramebuffer[xi]=[];for(let Jt=0;Jt0){ue.__webglFramebuffer=[];for(let xi=0;xi0&&ie(Tt)===!1){let xi=zn?yt:[yt];ue.__webglMultisampledFramebuffer=d.createFramebuffer(),ue.__webglColorRenderbuffer=[],h.bindFramebuffer(d.FRAMEBUFFER,ue.__webglMultisampledFramebuffer);for(let Jt=0;Jt0)for(let Jt=0;Jt0)for(let Jt=0;Jt0&&ie(Tt)===!1){let yt=Tt.isWebGLMultipleRenderTargets?Tt.texture:[Tt.texture],ue=Tt.width,fn=Tt.height,An=d.COLOR_BUFFER_BIT,zn=[],Li=Tt.stencilBuffer?d.DEPTH_STENCIL_ATTACHMENT:d.DEPTH_ATTACHMENT,xi=p.get(Tt),Jt=Tt.isWebGLMultipleRenderTargets===!0;if(Jt)for(let nn=0;nn0&&s.has("WEBGL_multisampled_render_to_texture")===!0&&yt.__useRenderToTexture!==!1}function rn(Tt){let yt=S.render.frame;B.get(Tt)!==yt&&(B.set(Tt,yt),Tt.update())}function Pn(Tt,yt){let ue=Tt.colorSpace,fn=Tt.format,An=Tt.type;return Tt.isCompressedTexture===!0||Tt.isVideoTexture===!0||Tt.format===Tyt||ue!==Zx&&ue!==gb&&(Na.getTransfer(ue)===vu?y===!1?s.has("EXT_sRGB")===!0&&fn===qw?(Tt.format=Tyt,Tt.minFilter=pb,Tt.generateMipmaps=!1):yt=aet.sRGBToLinear(yt):(fn!==qw||An!==oS)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",ue)),yt}this.allocateTextureUnit=ne,this.resetTextureUnits=Fn,this.setTexture2D=re,this.setTexture2DArray=hn,this.setTexture3D=Se,this.setTextureCube=ke,this.rebindTextures=wn,this.setupRenderTarget=it,this.updateRenderTargetMipmap=ut,this.updateMultisampleRenderTarget=kt,this.setupDepthRenderbuffer=Kt,this.setupFrameBufferTexture=ki,this.useMultisampledRTT=ie}function gAe(d,s,h){let p=h.isWebGL2;function m(_,S=gb){let y,I=Na.getTransfer(S);if(_===oS)return d.UNSIGNED_BYTE;if(_===YYt)return d.UNSIGNED_SHORT_4_4_4_4;if(_===KYt)return d.UNSIGNED_SHORT_5_5_5_1;if(_===aEe)return d.BYTE;if(_===uEe)return d.SHORT;if(_===c2t)return d.UNSIGNED_SHORT;if(_===ZYt)return d.INT;if(_===eS)return d.UNSIGNED_INT;if(_===nS)return d.FLOAT;if(_===wU)return p?d.HALF_FLOAT:(y=s.get("OES_texture_half_float"),y!==null?y.HALF_FLOAT_OES:null);if(_===lEe)return d.ALPHA;if(_===qw)return d.RGBA;if(_===hEe)return d.LUMINANCE;if(_===fEe)return d.LUMINANCE_ALPHA;if(_===WA)return d.DEPTH_COMPONENT;if(_===eR)return d.DEPTH_STENCIL;if(_===Tyt)return y=s.get("EXT_sRGB"),y!==null?y.SRGB_ALPHA_EXT:null;if(_===dEe)return d.RED;if(_===JYt)return d.RED_INTEGER;if(_===pEe)return d.RG;if(_===QYt)return d.RG_INTEGER;if(_===tKt)return d.RGBA_INTEGER;if(_===H_t||_===G_t||_===W_t||_===$_t)if(I===vu)if(y=s.get("WEBGL_compressed_texture_s3tc_srgb"),y!==null){if(_===H_t)return y.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(_===G_t)return y.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(_===W_t)return y.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(_===$_t)return y.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(y=s.get("WEBGL_compressed_texture_s3tc"),y!==null){if(_===H_t)return y.COMPRESSED_RGB_S3TC_DXT1_EXT;if(_===G_t)return y.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(_===W_t)return y.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(_===$_t)return y.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(_===xZt||_===MZt||_===EZt||_===SZt)if(y=s.get("WEBGL_compressed_texture_pvrtc"),y!==null){if(_===xZt)return y.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(_===MZt)return y.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(_===EZt)return y.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(_===SZt)return y.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(_===eKt)return y=s.get("WEBGL_compressed_texture_etc1"),y!==null?y.COMPRESSED_RGB_ETC1_WEBGL:null;if(_===TZt||_===CZt)if(y=s.get("WEBGL_compressed_texture_etc"),y!==null){if(_===TZt)return I===vu?y.COMPRESSED_SRGB8_ETC2:y.COMPRESSED_RGB8_ETC2;if(_===CZt)return I===vu?y.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:y.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(_===AZt||_===kZt||_===LZt||_===PZt||_===IZt||_===RZt||_===DZt||_===NZt||_===OZt||_===BZt||_===FZt||_===UZt||_===zZt||_===jZt)if(y=s.get("WEBGL_compressed_texture_astc"),y!==null){if(_===AZt)return I===vu?y.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:y.COMPRESSED_RGBA_ASTC_4x4_KHR;if(_===kZt)return I===vu?y.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:y.COMPRESSED_RGBA_ASTC_5x4_KHR;if(_===LZt)return I===vu?y.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:y.COMPRESSED_RGBA_ASTC_5x5_KHR;if(_===PZt)return I===vu?y.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:y.COMPRESSED_RGBA_ASTC_6x5_KHR;if(_===IZt)return I===vu?y.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:y.COMPRESSED_RGBA_ASTC_6x6_KHR;if(_===RZt)return I===vu?y.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:y.COMPRESSED_RGBA_ASTC_8x5_KHR;if(_===DZt)return I===vu?y.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:y.COMPRESSED_RGBA_ASTC_8x6_KHR;if(_===NZt)return I===vu?y.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:y.COMPRESSED_RGBA_ASTC_8x8_KHR;if(_===OZt)return I===vu?y.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:y.COMPRESSED_RGBA_ASTC_10x5_KHR;if(_===BZt)return I===vu?y.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:y.COMPRESSED_RGBA_ASTC_10x6_KHR;if(_===FZt)return I===vu?y.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:y.COMPRESSED_RGBA_ASTC_10x8_KHR;if(_===UZt)return I===vu?y.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:y.COMPRESSED_RGBA_ASTC_10x10_KHR;if(_===zZt)return I===vu?y.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:y.COMPRESSED_RGBA_ASTC_12x10_KHR;if(_===jZt)return I===vu?y.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:y.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(_===V_t||_===HZt||_===GZt)if(y=s.get("EXT_texture_compression_bptc"),y!==null){if(_===V_t)return I===vu?y.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:y.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(_===HZt)return y.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(_===GZt)return y.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(_===gEe||_===WZt||_===$Zt||_===VZt)if(y=s.get("EXT_texture_compression_rgtc"),y!==null){if(_===V_t)return y.COMPRESSED_RED_RGTC1_EXT;if(_===WZt)return y.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(_===$Zt)return y.COMPRESSED_RED_GREEN_RGTC2_EXT;if(_===VZt)return y.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return _===GA?p?d.UNSIGNED_INT_24_8:(y=s.get("WEBGL_depth_texture"),y!==null?y.UNSIGNED_INT_24_8_WEBGL:null):d[_]!==void 0?d[_]:null}return{convert:m}}var Hyt=class extends s1{constructor(s=[]){super(),this.isArrayCamera=!0,this.cameras=s}},iS=class extends o1{constructor(){super(),this.isGroup=!0,this.type="Group"}},mAe={type:"move"},mU=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new iS,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new iS,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Ge,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Ge),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new iS,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Ge,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Ge),this._grip}dispatchEvent(s){return this._targetRay!==null&&this._targetRay.dispatchEvent(s),this._grip!==null&&this._grip.dispatchEvent(s),this._hand!==null&&this._hand.dispatchEvent(s),this}connect(s){if(s&&s.hand){let h=this._hand;if(h)for(let p of s.hand.values())this._getHandJoint(h,p)}return this.dispatchEvent({type:"connected",data:s}),this}disconnect(s){return this.dispatchEvent({type:"disconnected",data:s}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(s,h,p){let m=null,_=null,S=null,y=this._targetRay,I=this._grip,N=this._hand;if(s&&h.session.visibilityState!=="visible-blurred"){if(N&&s.hand){S=!0;for(let et of s.hand.values()){let Q=h.getJointPose(et,p),X=this._getHandJoint(N,et);Q!==null&&(X.matrix.fromArray(Q.transform.matrix),X.matrix.decompose(X.position,X.rotation,X.scale),X.matrixWorldNeedsUpdate=!0,X.jointRadius=Q.radius),X.visible=Q!==null}let B=N.joints["index-finger-tip"],P=N.joints["thumb-tip"],U=B.position.distanceTo(P.position),j=.02,V=.005;N.inputState.pinching&&U>j+V?(N.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:s.handedness,target:this})):!N.inputState.pinching&&U<=j-V&&(N.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:s.handedness,target:this}))}else I!==null&&s.gripSpace&&(_=h.getPose(s.gripSpace,p),_!==null&&(I.matrix.fromArray(_.transform.matrix),I.matrix.decompose(I.position,I.rotation,I.scale),I.matrixWorldNeedsUpdate=!0,_.linearVelocity?(I.hasLinearVelocity=!0,I.linearVelocity.copy(_.linearVelocity)):I.hasLinearVelocity=!1,_.angularVelocity?(I.hasAngularVelocity=!0,I.angularVelocity.copy(_.angularVelocity)):I.hasAngularVelocity=!1));y!==null&&(m=h.getPose(s.targetRaySpace,p),m===null&&_!==null&&(m=_),m!==null&&(y.matrix.fromArray(m.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.matrixWorldNeedsUpdate=!0,m.linearVelocity?(y.hasLinearVelocity=!0,y.linearVelocity.copy(m.linearVelocity)):y.hasLinearVelocity=!1,m.angularVelocity?(y.hasAngularVelocity=!0,y.angularVelocity.copy(m.angularVelocity)):y.hasAngularVelocity=!1,this.dispatchEvent(mAe)))}return y!==null&&(y.visible=m!==null),I!==null&&(I.visible=_!==null),N!==null&&(N.visible=S!==null),this}_getHandJoint(s,h){if(s.joints[h.jointName]===void 0){let p=new iS;p.matrixAutoUpdate=!1,p.visible=!1,s.joints[h.jointName]=p,s.add(p)}return s.joints[h.jointName]}},Gyt=class extends aS{constructor(s,h){super();let p=this,m=null,_=1,S=null,y="local-floor",I=1,N=null,B=null,P=null,U=null,j=null,V=null,et=h.getContextAttributes(),Q=null,X=null,gt=[],ft=[],xt=new Nc,Bt=null,Dt=new s1;Dt.layers.enable(1),Dt.viewport=new $f;let Pt=new s1;Pt.layers.enable(2),Pt.viewport=new $f;let se=[Dt,Pt],ot=new Hyt;ot.layers.enable(1),ot.layers.enable(2);let Lt=null,be=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ge){let Pe=gt[ge];return Pe===void 0&&(Pe=new mU,gt[ge]=Pe),Pe.getTargetRaySpace()},this.getControllerGrip=function(ge){let Pe=gt[ge];return Pe===void 0&&(Pe=new mU,gt[ge]=Pe),Pe.getGripSpace()},this.getHand=function(ge){let Pe=gt[ge];return Pe===void 0&&(Pe=new mU,gt[ge]=Pe),Pe.getHandSpace()};function ln(ge){let Pe=ft.indexOf(ge.inputSource);if(Pe===-1)return;let ti=gt[Pe];ti!==void 0&&(ti.update(ge.inputSource,ge.frame,N||S),ti.dispatchEvent({type:ge.type,data:ge.inputSource}))}function Fn(){m.removeEventListener("select",ln),m.removeEventListener("selectstart",ln),m.removeEventListener("selectend",ln),m.removeEventListener("squeeze",ln),m.removeEventListener("squeezestart",ln),m.removeEventListener("squeezeend",ln),m.removeEventListener("end",Fn),m.removeEventListener("inputsourceschange",ne);for(let ge=0;ge=0&&(ft[Yi]=null,gt[Yi].disconnect(ti))}for(let Pe=0;Pe=ft.length){ft.push(ti),Yi=lr;break}else if(ft[lr]===null){ft[lr]=ti,Yi=lr;break}if(Yi===-1)break}let ki=gt[Yi];ki&&ki.connect(ti)}}let xe=new Ge,re=new Ge;function hn(ge,Pe,ti){xe.setFromMatrixPosition(Pe.matrixWorld),re.setFromMatrixPosition(ti.matrixWorld);let Yi=xe.distanceTo(re),ki=Pe.projectionMatrix.elements,lr=ti.projectionMatrix.elements,pr=ki[14]/(ki[10]-1),Kt=ki[14]/(ki[10]+1),wn=(ki[9]+1)/ki[5],it=(ki[9]-1)/ki[5],ut=(ki[8]-1)/ki[0],kt=(lr[8]+1)/lr[0],Ot=pr*ut,ie=pr*kt,rn=Yi/(-ut+kt),Pn=rn*-ut;Pe.matrixWorld.decompose(ge.position,ge.quaternion,ge.scale),ge.translateX(Pn),ge.translateZ(rn),ge.matrixWorld.compose(ge.position,ge.quaternion,ge.scale),ge.matrixWorldInverse.copy(ge.matrixWorld).invert();let Tt=pr+rn,yt=Kt+rn,ue=Ot-Pn,fn=ie+(Yi-Pn),An=wn*Kt/yt*Tt,zn=it*Kt/yt*Tt;ge.projectionMatrix.makePerspective(ue,fn,An,zn,Tt,yt),ge.projectionMatrixInverse.copy(ge.projectionMatrix).invert()}function Se(ge,Pe){Pe===null?ge.matrixWorld.copy(ge.matrix):ge.matrixWorld.multiplyMatrices(Pe.matrixWorld,ge.matrix),ge.matrixWorldInverse.copy(ge.matrixWorld).invert()}this.updateCamera=function(ge){if(m===null)return;ot.near=Pt.near=Dt.near=ge.near,ot.far=Pt.far=Dt.far=ge.far,(Lt!==ot.near||be!==ot.far)&&(m.updateRenderState({depthNear:ot.near,depthFar:ot.far}),Lt=ot.near,be=ot.far);let Pe=ge.parent,ti=ot.cameras;Se(ot,Pe);for(let Yi=0;Yi0&&(Q.alphaTest.value=X.alphaTest);let gt=s.get(X).envMap;if(gt&&(Q.envMap.value=gt,Q.flipEnvMap.value=gt.isCubeTexture&>.isRenderTargetTexture===!1?-1:1,Q.reflectivity.value=X.reflectivity,Q.ior.value=X.ior,Q.refractionRatio.value=X.refractionRatio),X.lightMap){Q.lightMap.value=X.lightMap;let ft=d._useLegacyLights===!0?Math.PI:1;Q.lightMapIntensity.value=X.lightMapIntensity*ft,h(X.lightMap,Q.lightMapTransform)}X.aoMap&&(Q.aoMap.value=X.aoMap,Q.aoMapIntensity.value=X.aoMapIntensity,h(X.aoMap,Q.aoMapTransform))}function S(Q,X){Q.diffuse.value.copy(X.color),Q.opacity.value=X.opacity,X.map&&(Q.map.value=X.map,h(X.map,Q.mapTransform))}function y(Q,X){Q.dashSize.value=X.dashSize,Q.totalSize.value=X.dashSize+X.gapSize,Q.scale.value=X.scale}function I(Q,X,gt,ft){Q.diffuse.value.copy(X.color),Q.opacity.value=X.opacity,Q.size.value=X.size*gt,Q.scale.value=ft*.5,X.map&&(Q.map.value=X.map,h(X.map,Q.uvTransform)),X.alphaMap&&(Q.alphaMap.value=X.alphaMap,h(X.alphaMap,Q.alphaMapTransform)),X.alphaTest>0&&(Q.alphaTest.value=X.alphaTest)}function N(Q,X){Q.diffuse.value.copy(X.color),Q.opacity.value=X.opacity,Q.rotation.value=X.rotation,X.map&&(Q.map.value=X.map,h(X.map,Q.mapTransform)),X.alphaMap&&(Q.alphaMap.value=X.alphaMap,h(X.alphaMap,Q.alphaMapTransform)),X.alphaTest>0&&(Q.alphaTest.value=X.alphaTest)}function B(Q,X){Q.specular.value.copy(X.specular),Q.shininess.value=Math.max(X.shininess,1e-4)}function P(Q,X){X.gradientMap&&(Q.gradientMap.value=X.gradientMap)}function U(Q,X){Q.metalness.value=X.metalness,X.metalnessMap&&(Q.metalnessMap.value=X.metalnessMap,h(X.metalnessMap,Q.metalnessMapTransform)),Q.roughness.value=X.roughness,X.roughnessMap&&(Q.roughnessMap.value=X.roughnessMap,h(X.roughnessMap,Q.roughnessMapTransform)),s.get(X).envMap&&(Q.envMapIntensity.value=X.envMapIntensity)}function j(Q,X,gt){Q.ior.value=X.ior,X.sheen>0&&(Q.sheenColor.value.copy(X.sheenColor).multiplyScalar(X.sheen),Q.sheenRoughness.value=X.sheenRoughness,X.sheenColorMap&&(Q.sheenColorMap.value=X.sheenColorMap,h(X.sheenColorMap,Q.sheenColorMapTransform)),X.sheenRoughnessMap&&(Q.sheenRoughnessMap.value=X.sheenRoughnessMap,h(X.sheenRoughnessMap,Q.sheenRoughnessMapTransform))),X.clearcoat>0&&(Q.clearcoat.value=X.clearcoat,Q.clearcoatRoughness.value=X.clearcoatRoughness,X.clearcoatMap&&(Q.clearcoatMap.value=X.clearcoatMap,h(X.clearcoatMap,Q.clearcoatMapTransform)),X.clearcoatRoughnessMap&&(Q.clearcoatRoughnessMap.value=X.clearcoatRoughnessMap,h(X.clearcoatRoughnessMap,Q.clearcoatRoughnessMapTransform)),X.clearcoatNormalMap&&(Q.clearcoatNormalMap.value=X.clearcoatNormalMap,h(X.clearcoatNormalMap,Q.clearcoatNormalMapTransform),Q.clearcoatNormalScale.value.copy(X.clearcoatNormalScale),X.side===gg&&Q.clearcoatNormalScale.value.negate())),X.iridescence>0&&(Q.iridescence.value=X.iridescence,Q.iridescenceIOR.value=X.iridescenceIOR,Q.iridescenceThicknessMinimum.value=X.iridescenceThicknessRange[0],Q.iridescenceThicknessMaximum.value=X.iridescenceThicknessRange[1],X.iridescenceMap&&(Q.iridescenceMap.value=X.iridescenceMap,h(X.iridescenceMap,Q.iridescenceMapTransform)),X.iridescenceThicknessMap&&(Q.iridescenceThicknessMap.value=X.iridescenceThicknessMap,h(X.iridescenceThicknessMap,Q.iridescenceThicknessMapTransform))),X.transmission>0&&(Q.transmission.value=X.transmission,Q.transmissionSamplerMap.value=gt.texture,Q.transmissionSamplerSize.value.set(gt.width,gt.height),X.transmissionMap&&(Q.transmissionMap.value=X.transmissionMap,h(X.transmissionMap,Q.transmissionMapTransform)),Q.thickness.value=X.thickness,X.thicknessMap&&(Q.thicknessMap.value=X.thicknessMap,h(X.thicknessMap,Q.thicknessMapTransform)),Q.attenuationDistance.value=X.attenuationDistance,Q.attenuationColor.value.copy(X.attenuationColor)),X.anisotropy>0&&(Q.anisotropyVector.value.set(X.anisotropy*Math.cos(X.anisotropyRotation),X.anisotropy*Math.sin(X.anisotropyRotation)),X.anisotropyMap&&(Q.anisotropyMap.value=X.anisotropyMap,h(X.anisotropyMap,Q.anisotropyMapTransform))),Q.specularIntensity.value=X.specularIntensity,Q.specularColor.value.copy(X.specularColor),X.specularColorMap&&(Q.specularColorMap.value=X.specularColorMap,h(X.specularColorMap,Q.specularColorMapTransform)),X.specularIntensityMap&&(Q.specularIntensityMap.value=X.specularIntensityMap,h(X.specularIntensityMap,Q.specularIntensityMapTransform))}function V(Q,X){X.matcap&&(Q.matcap.value=X.matcap)}function et(Q,X){let gt=s.get(X).light;Q.referencePosition.value.setFromMatrixPosition(gt.matrixWorld),Q.nearDistance.value=gt.shadow.camera.near,Q.farDistance.value=gt.shadow.camera.far}return{refreshFogUniforms:p,refreshMaterialUniforms:m}}function wAe(d,s,h,p){let m={},_={},S=[],y=h.isWebGL2?d.getParameter(d.MAX_UNIFORM_BUFFER_BINDINGS):0;function I(gt,ft){let xt=ft.program;p.uniformBlockBinding(gt,xt)}function N(gt,ft){let xt=m[gt.id];xt===void 0&&(V(gt),xt=B(gt),m[gt.id]=xt,gt.addEventListener("dispose",Q));let Bt=ft.program;p.updateUBOMapping(gt,Bt);let Dt=s.render.frame;_[gt.id]!==Dt&&(U(gt),_[gt.id]=Dt)}function B(gt){let ft=P();gt.__bindingPointIndex=ft;let xt=d.createBuffer(),Bt=gt.__size,Dt=gt.usage;return d.bindBuffer(d.UNIFORM_BUFFER,xt),d.bufferData(d.UNIFORM_BUFFER,Bt,Dt),d.bindBuffer(d.UNIFORM_BUFFER,null),d.bindBufferBase(d.UNIFORM_BUFFER,ft,xt),xt}function P(){for(let gt=0;gt0&&(xt+=Bt-Dt),gt.__size=xt,gt.__cache={},this}function et(gt){let ft={boundary:0,storage:0};return typeof gt=="number"||typeof gt=="boolean"?(ft.boundary=4,ft.storage=4):gt.isVector2?(ft.boundary=8,ft.storage=8):gt.isVector3||gt.isColor?(ft.boundary=16,ft.storage=12):gt.isVector4?(ft.boundary=16,ft.storage=16):gt.isMatrix3?(ft.boundary=48,ft.storage=48):gt.isMatrix4?(ft.boundary=64,ft.storage=64):gt.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",gt),ft}function Q(gt){let ft=gt.target;ft.removeEventListener("dispose",Q);let xt=S.indexOf(ft.__bindingPointIndex);S.splice(xt,1),d.deleteBuffer(m[ft.id]),delete m[ft.id],delete _[ft.id]}function X(){for(let gt in m)d.deleteBuffer(m[gt]);S=[],m={},_={}}return{bind:I,update:N,dispose:X}}var xU=class{constructor(s={}){let{canvas:h=CEe(),context:p=null,depth:m=!0,stencil:_=!0,alpha:S=!1,antialias:y=!1,premultipliedAlpha:I=!0,preserveDrawingBuffer:N=!1,powerPreference:B="default",failIfMajorPerformanceCaveat:P=!1}=s;this.isWebGLRenderer=!0;let U;p!==null?U=p.getContextAttributes().alpha:U=S;let j=new Uint32Array(4),V=new Int32Array(4),et=null,Q=null,X=[],gt=[];this.domElement=h,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Pd,this._useLegacyLights=!1,this.toneMapping=sS,this.toneMappingExposure=1;let ft=this,xt=!1,Bt=0,Dt=0,Pt=null,se=-1,ot=null,Lt=new $f,be=new $f,ln=null,Fn=new Go(0),ne=0,xe=h.width,re=h.height,hn=1,Se=null,ke=null,mn=new $f(0,0,xe,re),en=new $f(0,0,xe,re),Qn=!1,ge=new yU,Pe=!1,ti=!1,Yi=null,ki=new Bu,lr=new Nc,pr=new Ge,Kt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function wn(){return Pt===null?hn:1}let it=p;function ut(Rt,ve){for(let Je=0;Je{function Hi(){if(tn.forEach(function(Pr){Pn.get(Pr).currentProgram.isReady()&&tn.delete(Pr)}),tn.size===0){Ze(Rt);return}setTimeout(Hi,10)}kt.get("KHR_parallel_shader_compile")!==null?Hi():setTimeout(Hi,10)})};let Bs=null;function Oc(Rt){Bs&&Bs(Rt)}function ru(){il.stop()}function fc(){il.start()}let il=new aKt;il.setAnimationLoop(Oc),typeof self<"u"&&il.setContext(self),this.setAnimationLoop=function(Rt){Bs=Rt,tr.setAnimationLoop(Rt),Rt===null?il.stop():il.start()},tr.addEventListener("sessionstart",ru),tr.addEventListener("sessionend",fc),this.render=function(Rt,ve){if(ve!==void 0&&ve.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(xt===!0)return;Rt.matrixWorldAutoUpdate===!0&&Rt.updateMatrixWorld(),ve.parent===null&&ve.matrixWorldAutoUpdate===!0&&ve.updateMatrixWorld(),tr.enabled===!0&&tr.isPresenting===!0&&(tr.cameraAutoUpdate===!0&&tr.updateCamera(ve),ve=tr.getCamera()),Rt.isScene===!0&&Rt.onBeforeRender(ft,Rt,ve,Pt),Q=nn.get(Rt,gt.length),Q.init(),gt.push(Q),ki.multiplyMatrices(ve.projectionMatrix,ve.matrixWorldInverse),ge.setFromProjectionMatrix(ki),ti=this.localClippingEnabled,Pe=vn.init(this.clippingPlanes,ti),et=Jt.get(Rt,X.length),et.init(),X.push(et),va(Rt,ve,0,ft.sortObjects),et.finish(),ft.sortObjects===!0&&et.sort(Se,ke),this.info.render.frame++,Pe===!0&&vn.beginShadows();let Je=Q.state.shadowsArray;if(he.render(Je,Rt,ve),Pe===!0&&vn.endShadows(),this.info.autoReset===!0&&this.info.reset(),Mn.render(et,Rt),Q.setupLights(ft._useLegacyLights),ve.isArrayCamera){let tn=ve.cameras;for(let Ze=0,Hi=tn.length;Ze0?Q=gt[gt.length-1]:Q=null,X.pop(),X.length>0?et=X[X.length-1]:et=null};function va(Rt,ve,Je,tn){if(Rt.visible===!1)return;if(Rt.layers.test(ve.layers)){if(Rt.isGroup)Je=Rt.renderOrder;else if(Rt.isLOD)Rt.autoUpdate===!0&&Rt.update(ve);else if(Rt.isLight)Q.pushLight(Rt),Rt.castShadow&&Q.pushShadow(Rt);else if(Rt.isSprite){if(!Rt.frustumCulled||ge.intersectsSprite(Rt)){tn&&pr.setFromMatrixPosition(Rt.matrixWorld).applyMatrix4(ki);let Pr=zn.update(Rt),Gr=Rt.material;Gr.visible&&et.push(Rt,Pr,Gr,Je,pr.z,null)}}else if((Rt.isMesh||Rt.isLine||Rt.isPoints)&&(!Rt.frustumCulled||ge.intersectsObject(Rt))){let Pr=zn.update(Rt),Gr=Rt.material;if(tn&&(Rt.boundingSphere!==void 0?(Rt.boundingSphere===null&&Rt.computeBoundingSphere(),pr.copy(Rt.boundingSphere.center)):(Pr.boundingSphere===null&&Pr.computeBoundingSphere(),pr.copy(Pr.boundingSphere.center)),pr.applyMatrix4(Rt.matrixWorld).applyMatrix4(ki)),Array.isArray(Gr)){let hs=Pr.groups;for(let Fs=0,Ms=hs.length;Fs0&&tv(Ze,Hi,ve,Je),tn&&ie.viewport(Lt.copy(tn)),Ze.length>0&&O0(Ze,ve,Je),Hi.length>0&&O0(Hi,ve,Je),Pr.length>0&&O0(Pr,ve,Je),ie.buffers.depth.setTest(!0),ie.buffers.depth.setMask(!0),ie.buffers.color.setMask(!0),ie.setPolygonOffset(!1)}function tv(Rt,ve,Je,tn){if((Je.isScene===!0?Je.overrideMaterial:null)!==null)return;let Hi=Ot.isWebGL2;Yi===null&&(Yi=new Yx(1,1,{generateMipmaps:!0,type:kt.has("EXT_color_buffer_half_float")?wU:oS,minFilter:bU,samples:Hi?4:0})),ft.getDrawingBufferSize(lr),Hi?Yi.setSize(lr.x,lr.y):Yi.setSize(Ayt(lr.x),Ayt(lr.y));let Pr=ft.getRenderTarget();ft.setRenderTarget(Yi),ft.getClearColor(Fn),ne=ft.getClearAlpha(),ne<1&&ft.setClearColor(16777215,.5),ft.clear();let Gr=ft.toneMapping;ft.toneMapping=sS,O0(Rt,Je,tn),Tt.updateMultisampleRenderTarget(Yi),Tt.updateRenderTargetMipmap(Yi);let hs=!1;for(let Fs=0,Ms=ve.length;Fs0),bs=!!Je.morphAttributes.position,Tc=!!Je.morphAttributes.normal,rl=!!Je.morphAttributes.color,Oa=sS;tn.toneMapped&&(Pt===null||Pt.isXRRenderTarget===!0)&&(Oa=ft.toneMapping);let wh=Je.morphAttributes.position||Je.morphAttributes.normal||Je.morphAttributes.color,Nr=wh!==void 0?wh.length:0,mr=Pn.get(tn),c1=Q.state.lights;if(Pe===!0&&(ti===!0||Rt!==ot)){let _h=Rt===ot&&tn.id===se;vn.setState(tn,Rt,_h)}let dc=!1;tn.version===mr.__version?(mr.needsLights&&mr.lightsStateVersion!==c1.state.version||mr.outputColorSpace!==Gr||Ze.isBatchedMesh&&mr.batching===!1||!Ze.isBatchedMesh&&mr.batching===!0||Ze.isInstancedMesh&&mr.instancing===!1||!Ze.isInstancedMesh&&mr.instancing===!0||Ze.isSkinnedMesh&&mr.skinning===!1||!Ze.isSkinnedMesh&&mr.skinning===!0||Ze.isInstancedMesh&&mr.instancingColor===!0&&Ze.instanceColor===null||Ze.isInstancedMesh&&mr.instancingColor===!1&&Ze.instanceColor!==null||mr.envMap!==hs||tn.fog===!0&&mr.fog!==Hi||mr.numClippingPlanes!==void 0&&(mr.numClippingPlanes!==vn.numPlanes||mr.numIntersection!==vn.numIntersection)||mr.vertexAlphas!==Fs||mr.vertexTangents!==Ms||mr.morphTargets!==bs||mr.morphNormals!==Tc||mr.morphColors!==rl||mr.toneMapping!==Oa||Ot.isWebGL2===!0&&mr.morphTargetsCount!==Nr)&&(dc=!0):(dc=!0,mr.__version=tn.version);let vh=mr.currentProgram;dc===!0&&(vh=B0(tn,ve,Ze));let vg=!1,ws=!1,$c=!1,_a=vh.getUniforms(),ff=mr.uniforms;if(ie.useProgram(vh.program)&&(vg=!0,ws=!0,$c=!0),tn.id!==se&&(se=tn.id,ws=!0),vg||ot!==Rt){_a.setValue(it,"projectionMatrix",Rt.projectionMatrix),_a.setValue(it,"viewMatrix",Rt.matrixWorldInverse);let _h=_a.map.cameraPosition;_h!==void 0&&_h.setValue(it,pr.setFromMatrixPosition(Rt.matrixWorld)),Ot.logarithmicDepthBuffer&&_a.setValue(it,"logDepthBufFC",2/(Math.log(Rt.far+1)/Math.LN2)),(tn.isMeshPhongMaterial||tn.isMeshToonMaterial||tn.isMeshLambertMaterial||tn.isMeshBasicMaterial||tn.isMeshStandardMaterial||tn.isShaderMaterial)&&_a.setValue(it,"isOrthographic",Rt.isOrthographicCamera===!0),ot!==Rt&&(ot=Rt,ws=!0,$c=!0)}if(Ze.isSkinnedMesh){_a.setOptional(it,Ze,"bindMatrix"),_a.setOptional(it,Ze,"bindMatrixInverse");let _h=Ze.skeleton;_h&&(Ot.floatVertexTextures?(_h.boneTexture===null&&_h.computeBoneTexture(),_a.setValue(it,"boneTexture",_h.boneTexture,Tt)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}Ze.isBatchedMesh&&(_a.setOptional(it,Ze,"batchingTexture"),_a.setValue(it,"batchingTexture",Ze._matricesTexture,Tt));let Bl=Je.morphAttributes;if((Bl.position!==void 0||Bl.normal!==void 0||Bl.color!==void 0&&Ot.isWebGL2===!0)&&Sn.update(Ze,Je,vh),(ws||mr.receiveShadow!==Ze.receiveShadow)&&(mr.receiveShadow=Ze.receiveShadow,_a.setValue(it,"receiveShadow",Ze.receiveShadow)),tn.isMeshGouraudMaterial&&tn.envMap!==null&&(ff.envMap.value=hs,ff.flipEnvMap.value=hs.isCubeTexture&&hs.isRenderTargetTexture===!1?-1:1),ws&&(_a.setValue(it,"toneMappingExposure",ft.toneMappingExposure),mr.needsLights&&iv(ff,$c),Hi&&tn.fog===!0&&xi.refreshFogUniforms(ff,Hi),xi.refreshMaterialUniforms(ff,tn,hn,re,Yi),JI.upload(it,F0(mr),ff,Tt)),tn.isShaderMaterial&&tn.uniformsNeedUpdate===!0&&(JI.upload(it,F0(mr),ff,Tt),tn.uniformsNeedUpdate=!1),tn.isSpriteMaterial&&_a.setValue(it,"center",Ze.center),_a.setValue(it,"modelViewMatrix",Ze.modelViewMatrix),_a.setValue(it,"normalMatrix",Ze.normalMatrix),_a.setValue(it,"modelMatrix",Ze.matrixWorld),tn.isShaderMaterial||tn.isRawShaderMaterial){let _h=tn.uniformsGroups;for(let a1=0,Nd=_h.length;a10&&Tt.useMultisampledRTT(Rt)===!1?Ze=Pn.get(Rt).__webglMultisampledFramebuffer:Array.isArray(Ms)?Ze=Ms[Je]:Ze=Ms,Lt.copy(Rt.viewport),be.copy(Rt.scissor),ln=Rt.scissorTest}else Lt.copy(mn).multiplyScalar(hn).floor(),be.copy(en).multiplyScalar(hn).floor(),ln=Qn;if(ie.bindFramebuffer(it.FRAMEBUFFER,Ze)&&Ot.drawBuffers&&tn&&ie.drawBuffers(Rt,Ze),ie.viewport(Lt),ie.scissor(be),ie.setScissorTest(ln),Hi){let hs=Pn.get(Rt.texture);it.framebufferTexture2D(it.FRAMEBUFFER,it.COLOR_ATTACHMENT0,it.TEXTURE_CUBE_MAP_POSITIVE_X+ve,hs.__webglTexture,Je)}else if(Pr){let hs=Pn.get(Rt.texture),Fs=ve||0;it.framebufferTextureLayer(it.FRAMEBUFFER,it.COLOR_ATTACHMENT0,hs.__webglTexture,Je||0,Fs)}se=-1},this.readRenderTargetPixels=function(Rt,ve,Je,tn,Ze,Hi,Pr){if(!(Rt&&Rt.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Gr=Pn.get(Rt).__webglFramebuffer;if(Rt.isWebGLCubeRenderTarget&&Pr!==void 0&&(Gr=Gr[Pr]),Gr){ie.bindFramebuffer(it.FRAMEBUFFER,Gr);try{let hs=Rt.texture,Fs=hs.format,Ms=hs.type;if(Fs!==qw&&dn.convert(Fs)!==it.getParameter(it.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let bs=Ms===wU&&(kt.has("EXT_color_buffer_half_float")||Ot.isWebGL2&&kt.has("EXT_color_buffer_float"));if(Ms!==oS&&dn.convert(Ms)!==it.getParameter(it.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Ms===nS&&(Ot.isWebGL2||kt.has("OES_texture_float")||kt.has("WEBGL_color_buffer_float")))&&!bs){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ve>=0&&ve<=Rt.width-tn&&Je>=0&&Je<=Rt.height-Ze&&it.readPixels(ve,Je,tn,Ze,dn.convert(Fs),dn.convert(Ms),Hi)}finally{let hs=Pt!==null?Pn.get(Pt).__webglFramebuffer:null;ie.bindFramebuffer(it.FRAMEBUFFER,hs)}}},this.copyFramebufferToTexture=function(Rt,ve,Je=0){let tn=Math.pow(2,-Je),Ze=Math.floor(ve.image.width*tn),Hi=Math.floor(ve.image.height*tn);Tt.setTexture2D(ve,0),it.copyTexSubImage2D(it.TEXTURE_2D,Je,0,0,Rt.x,Rt.y,Ze,Hi),ie.unbindTexture()},this.copyTextureToTexture=function(Rt,ve,Je,tn=0){let Ze=ve.image.width,Hi=ve.image.height,Pr=dn.convert(Je.format),Gr=dn.convert(Je.type);Tt.setTexture2D(Je,0),it.pixelStorei(it.UNPACK_FLIP_Y_WEBGL,Je.flipY),it.pixelStorei(it.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Je.premultiplyAlpha),it.pixelStorei(it.UNPACK_ALIGNMENT,Je.unpackAlignment),ve.isDataTexture?it.texSubImage2D(it.TEXTURE_2D,tn,Rt.x,Rt.y,Ze,Hi,Pr,Gr,ve.image.data):ve.isCompressedTexture?it.compressedTexSubImage2D(it.TEXTURE_2D,tn,Rt.x,Rt.y,ve.mipmaps[0].width,ve.mipmaps[0].height,Pr,ve.mipmaps[0].data):it.texSubImage2D(it.TEXTURE_2D,tn,Rt.x,Rt.y,Pr,Gr,ve.image),tn===0&&Je.generateMipmaps&&it.generateMipmap(it.TEXTURE_2D),ie.unbindTexture()},this.copyTextureToTexture3D=function(Rt,ve,Je,tn,Ze=0){if(ft.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Hi=Rt.max.x-Rt.min.x+1,Pr=Rt.max.y-Rt.min.y+1,Gr=Rt.max.z-Rt.min.z+1,hs=dn.convert(tn.format),Fs=dn.convert(tn.type),Ms;if(tn.isData3DTexture)Tt.setTexture3D(tn,0),Ms=it.TEXTURE_3D;else if(tn.isDataArrayTexture||tn.isCompressedArrayTexture)Tt.setTexture2DArray(tn,0),Ms=it.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}it.pixelStorei(it.UNPACK_FLIP_Y_WEBGL,tn.flipY),it.pixelStorei(it.UNPACK_PREMULTIPLY_ALPHA_WEBGL,tn.premultiplyAlpha),it.pixelStorei(it.UNPACK_ALIGNMENT,tn.unpackAlignment);let bs=it.getParameter(it.UNPACK_ROW_LENGTH),Tc=it.getParameter(it.UNPACK_IMAGE_HEIGHT),rl=it.getParameter(it.UNPACK_SKIP_PIXELS),Oa=it.getParameter(it.UNPACK_SKIP_ROWS),wh=it.getParameter(it.UNPACK_SKIP_IMAGES),Nr=Je.isCompressedTexture?Je.mipmaps[Ze]:Je.image;it.pixelStorei(it.UNPACK_ROW_LENGTH,Nr.width),it.pixelStorei(it.UNPACK_IMAGE_HEIGHT,Nr.height),it.pixelStorei(it.UNPACK_SKIP_PIXELS,Rt.min.x),it.pixelStorei(it.UNPACK_SKIP_ROWS,Rt.min.y),it.pixelStorei(it.UNPACK_SKIP_IMAGES,Rt.min.z),Je.isDataTexture||Je.isData3DTexture?it.texSubImage3D(Ms,Ze,ve.x,ve.y,ve.z,Hi,Pr,Gr,hs,Fs,Nr.data):Je.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),it.compressedTexSubImage3D(Ms,Ze,ve.x,ve.y,ve.z,Hi,Pr,Gr,hs,Nr.data)):it.texSubImage3D(Ms,Ze,ve.x,ve.y,ve.z,Hi,Pr,Gr,hs,Fs,Nr),it.pixelStorei(it.UNPACK_ROW_LENGTH,bs),it.pixelStorei(it.UNPACK_IMAGE_HEIGHT,Tc),it.pixelStorei(it.UNPACK_SKIP_PIXELS,rl),it.pixelStorei(it.UNPACK_SKIP_ROWS,Oa),it.pixelStorei(it.UNPACK_SKIP_IMAGES,wh),Ze===0&&tn.generateMipmaps&&it.generateMipmap(Ms),ie.unbindTexture()},this.initTexture=function(Rt){Rt.isCubeTexture?Tt.setTextureCube(Rt,0):Rt.isData3DTexture?Tt.setTexture3D(Rt,0):Rt.isDataArrayTexture||Rt.isCompressedArrayTexture?Tt.setTexture2DArray(Rt,0):Tt.setTexture2D(Rt,0),ie.unbindTexture()},this.resetState=function(){Bt=0,Dt=0,Pt=null,ie.reset(),jn.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Xx}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(s){this._outputColorSpace=s;let h=this.getContext();h.drawingBufferColorSpace=s===a2t?"display-p3":"srgb",h.unpackColorSpace=Na.workingColorSpace===Iet?"display-p3":"srgb"}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Pd?$A:nKt}set outputEncoding(s){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=s===$A?Pd:Zx}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(s){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=s}},Wyt=class extends xU{};Wyt.prototype.isWebGL1Renderer=!0;var _et=class extends o1{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(s,h){return super.copy(s,h),s.background!==null&&(this.background=s.background.clone()),s.environment!==null&&(this.environment=s.environment.clone()),s.fog!==null&&(this.fog=s.fog.clone()),this.backgroundBlurriness=s.backgroundBlurriness,this.backgroundIntensity=s.backgroundIntensity,s.overrideMaterial!==null&&(this.overrideMaterial=s.overrideMaterial.clone()),this.matrixAutoUpdate=s.matrixAutoUpdate,this}toJSON(s){let h=super.toJSON(s);return this.fog!==null&&(h.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(h.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(h.object.backgroundIntensity=this.backgroundIntensity),h}};var yet=class extends R0{constructor(s,h,p,m=1){super(s,h,p),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=m}copy(s){return super.copy(s),this.meshPerAttribute=s.meshPerAttribute,this}toJSON(){let s=super.toJSON();return s.meshPerAttribute=this.meshPerAttribute,s.isInstancedBufferAttribute=!0,s}},qI=new Bu,BYt=new Bu,qtt=[],FYt=new Kx,vAe=new Bu,dU=new pg,pU=new uS,xet=class extends pg{constructor(s,h,p){super(s,h),this.isInstancedMesh=!0,this.instanceMatrix=new yet(new Float32Array(p*16),16),this.instanceColor=null,this.count=p,this.boundingBox=null,this.boundingSphere=null;for(let m=0;mI)continue;U.applyMatrix4(this.matrixWorld);let se=s.ray.origin.distanceTo(U);ses.far||h.push({distance:se,point:P.clone().applyMatrix4(this.matrixWorld),index:ft,face:null,faceIndex:null,object:this})}}else{let X=Math.max(0,S.start),gt=Math.min(Q.count,S.start+S.count);for(let ft=X,xt=gt-1;ftI)continue;U.applyMatrix4(this.matrixWorld);let Dt=s.ray.origin.distanceTo(U);Dts.far||h.push({distance:Dt,point:P.clone().applyMatrix4(this.matrixWorld),index:ft,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let h=this.geometry.morphAttributes,p=Object.keys(h);if(p.length>0){let m=h[p[0]];if(m!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let _=0,S=m.length;_=_)){let y=h[1];s=_)break e}S=p,p=0;break n}break t}for(;p>>1;sh;)--S;if(++S,_!==0||S!==m){_>=S&&(S=Math.max(S,1),_=S-1);let y=this.getValueSize();this.times=p.slice(_,S),this.values=this.values.slice(_*y,S*y)}return this}validate(){let s=!0,h=this.getValueSize();h-Math.floor(h)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),s=!1);let p=this.times,m=this.values,_=p.length;_===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),s=!1);let S=null;for(let y=0;y!==_;y++){let I=p[y];if(typeof I=="number"&&isNaN(I)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,y,I),s=!1;break}if(S!==null&&S>I){console.error("THREE.KeyframeTrack: Out of order keys.",this,y,I,S),s=!1;break}S=I}if(m!==void 0&&_Ae(m))for(let y=0,I=m.length;y!==I;++y){let N=m[y];if(isNaN(N)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,y,N),s=!1;break}}return s}optimize(){let s=this.times.slice(),h=this.values.slice(),p=this.getValueSize(),m=this.getInterpolation()===q_t,_=s.length-1,S=1;for(let y=1;y<_;++y){let I=!1,N=s[y],B=s[y+1];if(N!==B&&(y!==1||N!==s[0]))if(m)I=!0;else{let P=y*p,U=P-p,j=P+p;for(let V=0;V!==p;++V){let et=h[P+V];if(et!==h[U+V]||et!==h[j+V]){I=!0;break}}}if(I){if(y!==S){s[S]=s[y];let P=y*p,U=S*p;for(let j=0;j!==p;++j)h[U+j]=h[P+j]}++S}}if(_>0){s[S]=s[_];for(let y=_*p,I=S*p,N=0;N!==p;++N)h[I+N]=h[y+N];++S}return S!==s.length?(this.times=s.slice(0,S),this.values=h.slice(0,S*p)):(this.times=s,this.values=h),this}clone(){let s=this.times.slice(),h=this.values.slice(),p=this.constructor,m=new p(this.name,s,h);return m.createInterpolant=this.createInterpolant,m}};Zw.prototype.TimeBufferType=Float32Array;Zw.prototype.ValueBufferType=Float32Array;Zw.prototype.DefaultInterpolation=net;var qA=class extends Zw{};qA.prototype.ValueTypeName="bool";qA.prototype.ValueBufferType=Array;qA.prototype.DefaultInterpolation=eet;qA.prototype.InterpolantFactoryMethodLinear=void 0;qA.prototype.InterpolantFactoryMethodSmooth=void 0;var Zyt=class extends Zw{};Zyt.prototype.ValueTypeName="color";var Yyt=class extends Zw{};Yyt.prototype.ValueTypeName="number";var Kyt=class extends sR{constructor(s,h,p,m){super(s,h,p,m)}interpolate_(s,h,p,m){let _=this.resultBuffer,S=this.sampleValues,y=this.valueSize,I=(p-h)/(m-h),N=s*y;for(let B=N+y;N!==B;N+=4)vy.slerpFlat(_,0,S,N-y,S,N,I);return _}},EU=class extends Zw{InterpolantFactoryMethodLinear(s){return new Kyt(this.times,this.values,this.getValueSize(),s)}};EU.prototype.ValueTypeName="quaternion";EU.prototype.DefaultInterpolation=net;EU.prototype.InterpolantFactoryMethodSmooth=void 0;var XA=class extends Zw{};XA.prototype.ValueTypeName="string";XA.prototype.ValueBufferType=Array;XA.prototype.DefaultInterpolation=eet;XA.prototype.InterpolantFactoryMethodLinear=void 0;XA.prototype.InterpolantFactoryMethodSmooth=void 0;var Jyt=class extends Zw{};Jyt.prototype.ValueTypeName="vector";var Qyt=class{constructor(s,h,p){let m=this,_=!1,S=0,y=0,I,N=[];this.onStart=void 0,this.onLoad=s,this.onProgress=h,this.onError=p,this.itemStart=function(B){y++,_===!1&&m.onStart!==void 0&&m.onStart(B,S,y),_=!0},this.itemEnd=function(B){S++,m.onProgress!==void 0&&m.onProgress(B,S,y),S===y&&(_=!1,m.onLoad!==void 0&&m.onLoad())},this.itemError=function(B){m.onError!==void 0&&m.onError(B)},this.resolveURL=function(B){return I?I(B):B},this.setURLModifier=function(B){return I=B,this},this.addHandler=function(B,P){return N.push(B,P),this},this.removeHandler=function(B){let P=N.indexOf(B);return P!==-1&&N.splice(P,2),this},this.getHandler=function(B){for(let P=0,U=N.length;PT||u.y>T)&&(u.x>T&&(d.x=Math.floor(T/Xt.x),u.x=d.x*Xt.x,fn.mapSize.x=d.x),u.y>T&&(d.y=Math.floor(T/Xt.y),u.y=d.y*Xt.y,fn.mapSize.y=d.y)),fn.map===null||at===!0||Ne===!0){let cn=this.type!==W3?{minFilter:hg,magFilter:hg}:{};fn.map!==null&&fn.map.dispose(),fn.map=new Y3(u.x,u.y,cn),fn.map.texture.name=xt.name+".shadowMap",fn.camera.updateProjectionMatrix()}s.setRenderTarget(fn.map),s.clear();let wn=fn.getViewportCount();for(let cn=0;cn0||ue.map&&ue.alphaTest>0){let st=me.uuid,at=ue.uuid,Ne=x[st];Ne===void 0&&(Ne={},x[st]=Ne);let Qe=Ne[at];Qe===void 0&&(Qe=me.clone(),Ne[at]=Qe,ue.addEventListener("dispose",se)),me=Qe}if(me.visible=ue.visible,me.wireframe=ue.wireframe,Q===W3?me.side=ue.shadowSide!==null?ue.shadowSide:ue.side:me.side=ue.shadowSide!==null?ue.shadowSide:M[ue.side],me.alphaMap=ue.alphaMap,me.alphaTest=ue.alphaTest,me.map=ue.map,me.clipShadows=ue.clipShadows,me.clippingPlanes=ue.clippingPlanes,me.clipIntersection=ue.clipIntersection,me.displacementMap=ue.displacementMap,me.displacementScale=ue.displacementScale,me.displacementBias=ue.displacementBias,me.wireframeLinewidth=ue.wireframeLinewidth,me.linewidth=ue.linewidth,Ce.isPointLight===!0&&me.isMeshDistanceMaterial===!0){let st=s.properties.get(me);st.light=Ce}return me}function te(ne,ue,Ce,Q,me){if(ne.visible===!1)return;if(ne.layers.test(ue.layers)&&(ne.isMesh||ne.isLine||ne.isPoints)&&(ne.castShadow||ne.receiveShadow&&me===W3)&&(!ne.frustumCulled||c.intersectsObject(ne))){ne.modelViewMatrix.multiplyMatrices(Ce.matrixWorldInverse,ne.matrixWorld);let at=n.update(ne),Ne=ne.material;if(Array.isArray(Ne)){let Qe=at.groups;for(let ot=0,xt=Qe.length;ot=1):wn.indexOf("OpenGL ES")!==-1&&(Xt=parseFloat(/^OpenGL ES (\d)/.exec(wn)[1]),fn=Xt>=2);let cn=null,bi={},jt=s.getParameter(s.SCISSOR_BOX),gn=s.getParameter(s.VIEWPORT),Un=new Hh().fromArray(jt),Zi=new Hh().fromArray(gn);function Hi(Je,ti,Zn,rr){let Me=new Uint8Array(4),et=s.createTexture();s.bindTexture(Je,et),s.texParameteri(Je,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(Je,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let ht=0;ht"u"?!1:/OculusBrowser/g.test(navigator.userAgent),T=new WeakMap,M,L=new WeakMap,I=!1;try{I=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function D(Te,ve){return I?new OffscreenCanvas(Te,ve):Yfe("canvas")}function F(Te,ve,_t,mn){let yn=1;if((Te.width>mn||Te.height>mn)&&(yn=mn/Math.max(Te.width,Te.height)),yn<1||ve===!0)if(typeof HTMLImageElement<"u"&&Te instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&Te instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&Te instanceof ImageBitmap){let Sn=ve?L6e:Math.floor,yi=Sn(yn*Te.width),hi=Sn(yn*Te.height);M===void 0&&(M=D(yi,hi));let ri=_t?D(yi,hi):M;return ri.width=yi,ri.height=hi,ri.getContext("2d").drawImage(Te,0,0,yi,hi),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Te.width+"x"+Te.height+") to ("+yi+"x"+hi+")."),ri}else return"data"in Te&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Te.width+"x"+Te.height+")."),Te;return Te}function O(Te){return yyt(Te.width)&&yyt(Te.height)}function z(Te){return w?!1:Te.wrapS!==Sv||Te.wrapT!==Sv||Te.minFilter!==hg&&Te.minFilter!==Db}function Z(Te,ve){return Te.generateMipmaps&&ve&&Te.minFilter!==hg&&Te.minFilter!==Db}function H(Te){s.generateMipmap(Te)}function te(Te,ve,_t,mn,yn=!1){if(w===!1)return ve;if(Te!==null){if(s[Te]!==void 0)return s[Te];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+Te+"'")}let Sn=ve;if(ve===s.RED&&(_t===s.FLOAT&&(Sn=s.R32F),_t===s.HALF_FLOAT&&(Sn=s.R16F),_t===s.UNSIGNED_BYTE&&(Sn=s.R8)),ve===s.RED_INTEGER&&(_t===s.UNSIGNED_BYTE&&(Sn=s.R8UI),_t===s.UNSIGNED_SHORT&&(Sn=s.R16UI),_t===s.UNSIGNED_INT&&(Sn=s.R32UI),_t===s.BYTE&&(Sn=s.R8I),_t===s.SHORT&&(Sn=s.R16I),_t===s.INT&&(Sn=s.R32I)),ve===s.RG&&(_t===s.FLOAT&&(Sn=s.RG32F),_t===s.HALF_FLOAT&&(Sn=s.RG16F),_t===s.UNSIGNED_BYTE&&(Sn=s.RG8)),ve===s.RGBA){let yi=yn?Wfe:Ac.getTransfer(mn);_t===s.FLOAT&&(Sn=s.RGBA32F),_t===s.HALF_FLOAT&&(Sn=s.RGBA16F),_t===s.UNSIGNED_BYTE&&(Sn=yi===hl?s.SRGB8_ALPHA8:s.RGBA8),_t===s.UNSIGNED_SHORT_4_4_4_4&&(Sn=s.RGBA4),_t===s.UNSIGNED_SHORT_5_5_5_1&&(Sn=s.RGB5_A1)}return(Sn===s.R16F||Sn===s.R32F||Sn===s.RG16F||Sn===s.RG32F||Sn===s.RGBA16F||Sn===s.RGBA32F)&&n.get("EXT_color_buffer_float"),Sn}function se(Te,ve,_t){return Z(Te,_t)===!0||Te.isFramebufferTexture&&Te.minFilter!==hg&&Te.minFilter!==Db?Math.log2(Math.max(ve.width,ve.height))+1:Te.mipmaps!==void 0&&Te.mipmaps.length>0?Te.mipmaps.length:Te.isCompressedTexture&&Array.isArray(Te.image)?ve.mipmaps.length:1}function ne(Te){return Te===hg||Te===$_t||Te===$Ie?s.NEAREST:s.LINEAR}function ue(Te){let ve=Te.target;ve.removeEventListener("dispose",ue),Q(ve),ve.isVideoTexture&&T.delete(ve)}function Ce(Te){let ve=Te.target;ve.removeEventListener("dispose",Ce),tt(ve)}function Q(Te){let ve=c.get(Te);if(ve.__webglInit===void 0)return;let _t=Te.source,mn=L.get(_t);if(mn){let yn=mn[ve.__cacheKey];yn.usedTimes--,yn.usedTimes===0&&me(Te),Object.keys(mn).length===0&&L.delete(_t)}c.remove(Te)}function me(Te){let ve=c.get(Te);s.deleteTexture(ve.__webglTexture);let _t=Te.source,mn=L.get(_t);delete mn[ve.__cacheKey],b.memory.textures--}function tt(Te){let ve=Te.texture,_t=c.get(Te),mn=c.get(ve);if(mn.__webglTexture!==void 0&&(s.deleteTexture(mn.__webglTexture),b.memory.textures--),Te.depthTexture&&Te.depthTexture.dispose(),Te.isWebGLCubeRenderTarget)for(let yn=0;yn<6;yn++){if(Array.isArray(_t.__webglFramebuffer[yn]))for(let Sn=0;Sn<_t.__webglFramebuffer[yn].length;Sn++)s.deleteFramebuffer(_t.__webglFramebuffer[yn][Sn]);else s.deleteFramebuffer(_t.__webglFramebuffer[yn]);_t.__webglDepthbuffer&&s.deleteRenderbuffer(_t.__webglDepthbuffer[yn])}else{if(Array.isArray(_t.__webglFramebuffer))for(let yn=0;yn<_t.__webglFramebuffer.length;yn++)s.deleteFramebuffer(_t.__webglFramebuffer[yn]);else s.deleteFramebuffer(_t.__webglFramebuffer);if(_t.__webglDepthbuffer&&s.deleteRenderbuffer(_t.__webglDepthbuffer),_t.__webglMultisampledFramebuffer&&s.deleteFramebuffer(_t.__webglMultisampledFramebuffer),_t.__webglColorRenderbuffer)for(let yn=0;yn<_t.__webglColorRenderbuffer.length;yn++)_t.__webglColorRenderbuffer[yn]&&s.deleteRenderbuffer(_t.__webglColorRenderbuffer[yn]);_t.__webglDepthRenderbuffer&&s.deleteRenderbuffer(_t.__webglDepthRenderbuffer)}if(Te.isWebGLMultipleRenderTargets)for(let yn=0,Sn=ve.length;yn=u.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+Te+" texture units while this GPU supports only "+u.maxTextures),st+=1,Te}function Qe(Te){let ve=[];return ve.push(Te.wrapS),ve.push(Te.wrapT),ve.push(Te.wrapR||0),ve.push(Te.magFilter),ve.push(Te.minFilter),ve.push(Te.anisotropy),ve.push(Te.internalFormat),ve.push(Te.format),ve.push(Te.type),ve.push(Te.generateMipmaps),ve.push(Te.premultiplyAlpha),ve.push(Te.flipY),ve.push(Te.unpackAlignment),ve.push(Te.colorSpace),ve.join()}function ot(Te,ve){let _t=c.get(Te);if(Te.isVideoTexture&&Er(Te),Te.isRenderTargetTexture===!1&&Te.version>0&&_t.__version!==Te.version){let mn=Te.image;if(mn===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(mn.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Un(_t,Te,ve);return}}r.bindTexture(s.TEXTURE_2D,_t.__webglTexture,s.TEXTURE0+ve)}function xt(Te,ve){let _t=c.get(Te);if(Te.version>0&&_t.__version!==Te.version){Un(_t,Te,ve);return}r.bindTexture(s.TEXTURE_2D_ARRAY,_t.__webglTexture,s.TEXTURE0+ve)}function fn(Te,ve){let _t=c.get(Te);if(Te.version>0&&_t.__version!==Te.version){Un(_t,Te,ve);return}r.bindTexture(s.TEXTURE_3D,_t.__webglTexture,s.TEXTURE0+ve)}function Xt(Te,ve){let _t=c.get(Te);if(Te.version>0&&_t.__version!==Te.version){Zi(_t,Te,ve);return}r.bindTexture(s.TEXTURE_CUBE_MAP,_t.__webglTexture,s.TEXTURE0+ve)}let wn={[T6e]:s.REPEAT,[Sv]:s.CLAMP_TO_EDGE,[C6e]:s.MIRRORED_REPEAT},cn={[hg]:s.NEAREST,[$_t]:s.NEAREST_MIPMAP_NEAREST,[$Ie]:s.NEAREST_MIPMAP_LINEAR,[Db]:s.LINEAR,[Fon]:s.LINEAR_MIPMAP_NEAREST,[DW]:s.LINEAR_MIPMAP_LINEAR},bi={[Zon]:s.NEVER,[nan]:s.ALWAYS,[Kon]:s.LESS,[T2t]:s.LEQUAL,[Jon]:s.EQUAL,[tan]:s.GEQUAL,[Qon]:s.GREATER,[ean]:s.NOTEQUAL};function jt(Te,ve,_t){if(_t?(s.texParameteri(Te,s.TEXTURE_WRAP_S,wn[ve.wrapS]),s.texParameteri(Te,s.TEXTURE_WRAP_T,wn[ve.wrapT]),(Te===s.TEXTURE_3D||Te===s.TEXTURE_2D_ARRAY)&&s.texParameteri(Te,s.TEXTURE_WRAP_R,wn[ve.wrapR]),s.texParameteri(Te,s.TEXTURE_MAG_FILTER,cn[ve.magFilter]),s.texParameteri(Te,s.TEXTURE_MIN_FILTER,cn[ve.minFilter])):(s.texParameteri(Te,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(Te,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),(Te===s.TEXTURE_3D||Te===s.TEXTURE_2D_ARRAY)&&s.texParameteri(Te,s.TEXTURE_WRAP_R,s.CLAMP_TO_EDGE),(ve.wrapS!==Sv||ve.wrapT!==Sv)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),s.texParameteri(Te,s.TEXTURE_MAG_FILTER,ne(ve.magFilter)),s.texParameteri(Te,s.TEXTURE_MIN_FILTER,ne(ve.minFilter)),ve.minFilter!==hg&&ve.minFilter!==Db&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),ve.compareFunction&&(s.texParameteri(Te,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(Te,s.TEXTURE_COMPARE_FUNC,bi[ve.compareFunction])),n.has("EXT_texture_filter_anisotropic")===!0){let mn=n.get("EXT_texture_filter_anisotropic");if(ve.magFilter===hg||ve.minFilter!==$Ie&&ve.minFilter!==DW||ve.type===fT&&n.has("OES_texture_float_linear")===!1||w===!1&&ve.type===BW&&n.has("OES_texture_half_float_linear")===!1)return;(ve.anisotropy>1||c.get(ve).__currentAnisotropy)&&(s.texParameterf(Te,mn.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(ve.anisotropy,u.getMaxAnisotropy())),c.get(ve).__currentAnisotropy=ve.anisotropy)}}function gn(Te,ve){let _t=!1;Te.__webglInit===void 0&&(Te.__webglInit=!0,ve.addEventListener("dispose",ue));let mn=ve.source,yn=L.get(mn);yn===void 0&&(yn={},L.set(mn,yn));let Sn=Qe(ve);if(Sn!==Te.__cacheKey){yn[Sn]===void 0&&(yn[Sn]={texture:s.createTexture(),usedTimes:0},b.memory.textures++,_t=!0),yn[Sn].usedTimes++;let yi=yn[Te.__cacheKey];yi!==void 0&&(yn[Te.__cacheKey].usedTimes--,yi.usedTimes===0&&me(ve)),Te.__cacheKey=Sn,Te.__webglTexture=yn[Sn].texture}return _t}function Un(Te,ve,_t){let mn=s.TEXTURE_2D;(ve.isDataArrayTexture||ve.isCompressedArrayTexture)&&(mn=s.TEXTURE_2D_ARRAY),ve.isData3DTexture&&(mn=s.TEXTURE_3D);let yn=gn(Te,ve),Sn=ve.source;r.bindTexture(mn,Te.__webglTexture,s.TEXTURE0+_t);let yi=c.get(Sn);if(Sn.version!==yi.__version||yn===!0){r.activeTexture(s.TEXTURE0+_t);let hi=Ac.getPrimaries(Ac.workingColorSpace),ri=ve.colorSpace===Bb?null:Ac.getPrimaries(ve.colorSpace),Ge=ve.colorSpace===Bb||hi===ri?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,ve.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ve.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,ve.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ge);let Pe=z(ve)&&O(ve.image)===!1,ke=F(ve.image,Pe,!1,u.maxTextureSize);ke=qi(ve,ke);let dt=O(ke)||w,Ye=d.convert(ve.format,ve.colorSpace),ct=d.convert(ve.type),Ze=te(ve.internalFormat,Ye,ct,ve.colorSpace,ve.isVideoTexture);jt(mn,ve,dt);let Ke,gt=ve.mipmaps,qn=w&&ve.isVideoTexture!==!0&&Ze!==E2t,xi=yi.__version===void 0||yn===!0,Bi=se(ve,ke,dt);if(ve.isDepthTexture)Ze=s.DEPTH_COMPONENT,w?ve.type===fT?Ze=s.DEPTH_COMPONENT32F:ve.type===uT?Ze=s.DEPTH_COMPONENT24:ve.type===W4?Ze=s.DEPTH24_STENCIL8:Ze=s.DEPTH_COMPONENT16:ve.type===fT&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),ve.format===H4&&Ze===s.DEPTH_COMPONENT&&ve.type!==l5e&&ve.type!==uT&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),ve.type=uT,ct=d.convert(ve.type)),ve.format===fO&&Ze===s.DEPTH_COMPONENT&&(Ze=s.DEPTH_STENCIL,ve.type!==W4&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),ve.type=W4,ct=d.convert(ve.type))),xi&&(qn?r.texStorage2D(s.TEXTURE_2D,1,Ze,ke.width,ke.height):r.texImage2D(s.TEXTURE_2D,0,Ze,ke.width,ke.height,0,Ye,ct,null));else if(ve.isDataTexture)if(gt.length>0&&dt){qn&&xi&&r.texStorage2D(s.TEXTURE_2D,Bi,Ze,gt[0].width,gt[0].height);for(let xn=0,Je=gt.length;xn>=1,Je>>=1}}else if(gt.length>0&&dt){qn&&xi&&r.texStorage2D(s.TEXTURE_2D,Bi,Ze,gt[0].width,gt[0].height);for(let xn=0,Je=gt.length;xn0&&xi++,r.texStorage2D(s.TEXTURE_CUBE_MAP,xi,Ke,ke[0].width,ke[0].height));for(let xn=0;xn<6;xn++)if(Pe){gt?r.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+xn,0,0,0,ke[xn].width,ke[xn].height,ct,Ze,ke[xn].data):r.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+xn,0,Ke,ke[xn].width,ke[xn].height,0,ct,Ze,ke[xn].data);for(let Je=0;Je>Sn),ke=Math.max(1,ve.height>>Sn);yn===s.TEXTURE_3D||yn===s.TEXTURE_2D_ARRAY?r.texImage3D(yn,Sn,ri,Pe,ke,ve.depth,0,yi,hi,null):r.texImage2D(yn,Sn,ri,Pe,ke,0,yi,hi,null)}r.bindFramebuffer(s.FRAMEBUFFER,Te),_n(ve)?_.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,mn,yn,c.get(_t).__webglTexture,0,We(ve)):(yn===s.TEXTURE_2D||yn>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&yn<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,mn,yn,c.get(_t).__webglTexture,Sn),r.bindFramebuffer(s.FRAMEBUFFER,null)}function yr(Te,ve,_t){if(s.bindRenderbuffer(s.RENDERBUFFER,Te),ve.depthBuffer&&!ve.stencilBuffer){let mn=w===!0?s.DEPTH_COMPONENT24:s.DEPTH_COMPONENT16;if(_t||_n(ve)){let yn=ve.depthTexture;yn&&yn.isDepthTexture&&(yn.type===fT?mn=s.DEPTH_COMPONENT32F:yn.type===uT&&(mn=s.DEPTH_COMPONENT24));let Sn=We(ve);_n(ve)?_.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Sn,mn,ve.width,ve.height):s.renderbufferStorageMultisample(s.RENDERBUFFER,Sn,mn,ve.width,ve.height)}else s.renderbufferStorage(s.RENDERBUFFER,mn,ve.width,ve.height);s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,Te)}else if(ve.depthBuffer&&ve.stencilBuffer){let mn=We(ve);_t&&_n(ve)===!1?s.renderbufferStorageMultisample(s.RENDERBUFFER,mn,s.DEPTH24_STENCIL8,ve.width,ve.height):_n(ve)?_.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,mn,s.DEPTH24_STENCIL8,ve.width,ve.height):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,ve.width,ve.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,Te)}else{let mn=ve.isWebGLMultipleRenderTargets===!0?ve.texture:[ve.texture];for(let yn=0;yn0){_t.__webglFramebuffer[hi]=[];for(let ri=0;ri0){_t.__webglFramebuffer=[];for(let hi=0;hi0&&_n(Te)===!1){let hi=Sn?ve:[ve];_t.__webglMultisampledFramebuffer=s.createFramebuffer(),_t.__webglColorRenderbuffer=[],r.bindFramebuffer(s.FRAMEBUFFER,_t.__webglMultisampledFramebuffer);for(let ri=0;ri0)for(let ri=0;ri0)for(let ri=0;ri0&&_n(Te)===!1){let ve=Te.isWebGLMultipleRenderTargets?Te.texture:[Te.texture],_t=Te.width,mn=Te.height,yn=s.COLOR_BUFFER_BIT,Sn=[],yi=Te.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,hi=c.get(Te),ri=Te.isWebGLMultipleRenderTargets===!0;if(ri)for(let Ge=0;Ge0&&n.has("WEBGL_multisampled_render_to_texture")===!0&&ve.__useRenderToTexture!==!1}function Er(Te){let ve=b.render.frame;T.get(Te)!==ve&&(T.set(Te,ve),Te.update())}function qi(Te,ve){let _t=Te.colorSpace,mn=Te.format,yn=Te.type;return Te.isCompressedTexture===!0||Te.isVideoTexture===!0||Te.format===A6e||_t!==X3&&_t!==Bb&&(Ac.getTransfer(_t)===hl?w===!1?n.has("EXT_sRGB")===!0&&mn===Mv?(Te.format=A6e,Te.minFilter=Db,Te.generateMipmaps=!1):ve=Zfe.sRGBToLinear(ve):(mn!==Mv||yn!==gT)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",_t)),ve}this.allocateTextureUnit=Ne,this.resetTextureUnits=at,this.setTexture2D=ot,this.setTexture2DArray=xt,this.setTexture3D=fn,this.setTextureCube=Xt,this.rebindTextures=xr,this.setupRenderTarget=oe,this.updateRenderTargetMipmap=de,this.updateMultisampleRenderTarget=it,this.setupDepthRenderbuffer=Ei,this.setupFrameBufferTexture=Hi,this.useMultisampledRTT=_n}function Hfn(s,n,r){let c=r.isWebGL2;function u(d,b=Bb){let w,_=Ac.getTransfer(b);if(d===gT)return s.UNSIGNED_BYTE;if(d===w2t)return s.UNSIGNED_SHORT_4_4_4_4;if(d===v2t)return s.UNSIGNED_SHORT_5_5_5_1;if(d===Uon)return s.BYTE;if(d===zon)return s.SHORT;if(d===l5e)return s.UNSIGNED_SHORT;if(d===b2t)return s.INT;if(d===uT)return s.UNSIGNED_INT;if(d===fT)return s.FLOAT;if(d===BW)return c?s.HALF_FLOAT:(w=n.get("OES_texture_half_float"),w!==null?w.HALF_FLOAT_OES:null);if(d===Gon)return s.ALPHA;if(d===Mv)return s.RGBA;if(d===jon)return s.LUMINANCE;if(d===$on)return s.LUMINANCE_ALPHA;if(d===H4)return s.DEPTH_COMPONENT;if(d===fO)return s.DEPTH_STENCIL;if(d===A6e)return w=n.get("EXT_sRGB"),w!==null?w.SRGB_ALPHA_EXT:null;if(d===Von)return s.RED;if(d===_2t)return s.RED_INTEGER;if(d===Won)return s.RG;if(d===y2t)return s.RG_INTEGER;if(d===x2t)return s.RGBA_INTEGER;if(d===VIe||d===WIe||d===HIe||d===qIe)if(_===hl)if(w=n.get("WEBGL_compressed_texture_s3tc_srgb"),w!==null){if(d===VIe)return w.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(d===WIe)return w.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(d===HIe)return w.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(d===qIe)return w.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(w=n.get("WEBGL_compressed_texture_s3tc"),w!==null){if(d===VIe)return w.COMPRESSED_RGB_S3TC_DXT1_EXT;if(d===WIe)return w.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(d===HIe)return w.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(d===qIe)return w.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(d===V_t||d===W_t||d===H_t||d===q_t)if(w=n.get("WEBGL_compressed_texture_pvrtc"),w!==null){if(d===V_t)return w.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(d===W_t)return w.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(d===H_t)return w.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(d===q_t)return w.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(d===E2t)return w=n.get("WEBGL_compressed_texture_etc1"),w!==null?w.COMPRESSED_RGB_ETC1_WEBGL:null;if(d===X_t||d===Y_t)if(w=n.get("WEBGL_compressed_texture_etc"),w!==null){if(d===X_t)return _===hl?w.COMPRESSED_SRGB8_ETC2:w.COMPRESSED_RGB8_ETC2;if(d===Y_t)return _===hl?w.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:w.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(d===Z_t||d===K_t||d===J_t||d===Q_t||d===eyt||d===tyt||d===nyt||d===iyt||d===ryt||d===syt||d===oyt||d===ayt||d===cyt||d===lyt)if(w=n.get("WEBGL_compressed_texture_astc"),w!==null){if(d===Z_t)return _===hl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:w.COMPRESSED_RGBA_ASTC_4x4_KHR;if(d===K_t)return _===hl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:w.COMPRESSED_RGBA_ASTC_5x4_KHR;if(d===J_t)return _===hl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:w.COMPRESSED_RGBA_ASTC_5x5_KHR;if(d===Q_t)return _===hl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:w.COMPRESSED_RGBA_ASTC_6x5_KHR;if(d===eyt)return _===hl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:w.COMPRESSED_RGBA_ASTC_6x6_KHR;if(d===tyt)return _===hl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:w.COMPRESSED_RGBA_ASTC_8x5_KHR;if(d===nyt)return _===hl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:w.COMPRESSED_RGBA_ASTC_8x6_KHR;if(d===iyt)return _===hl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:w.COMPRESSED_RGBA_ASTC_8x8_KHR;if(d===ryt)return _===hl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:w.COMPRESSED_RGBA_ASTC_10x5_KHR;if(d===syt)return _===hl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:w.COMPRESSED_RGBA_ASTC_10x6_KHR;if(d===oyt)return _===hl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:w.COMPRESSED_RGBA_ASTC_10x8_KHR;if(d===ayt)return _===hl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:w.COMPRESSED_RGBA_ASTC_10x10_KHR;if(d===cyt)return _===hl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:w.COMPRESSED_RGBA_ASTC_12x10_KHR;if(d===lyt)return _===hl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:w.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(d===XIe||d===uyt||d===fyt)if(w=n.get("EXT_texture_compression_bptc"),w!==null){if(d===XIe)return _===hl?w.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:w.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(d===uyt)return w.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(d===fyt)return w.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(d===Hon||d===hyt||d===dyt||d===pyt)if(w=n.get("EXT_texture_compression_rgtc"),w!==null){if(d===XIe)return w.COMPRESSED_RED_RGTC1_EXT;if(d===hyt)return w.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(d===dyt)return w.COMPRESSED_RED_GREEN_RGTC2_EXT;if(d===pyt)return w.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return d===W4?c?s.UNSIGNED_INT_24_8:(w=n.get("WEBGL_depth_texture"),w!==null?w.UNSIGNED_INT_24_8_WEBGL:null):s[d]!==void 0?s[d]:null}return{convert:u}}var V6e=class extends dg{constructor(n=[]){super(),this.isArrayCamera=!0,this.cameras=n}},hT=class extends pg{constructor(){super(),this.isGroup=!0,this.type="Group"}},qfn={type:"move"},IW=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new hT,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new hT,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Gt,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Gt),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new hT,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Gt,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Gt),this._grip}dispatchEvent(n){return this._targetRay!==null&&this._targetRay.dispatchEvent(n),this._grip!==null&&this._grip.dispatchEvent(n),this._hand!==null&&this._hand.dispatchEvent(n),this}connect(n){if(n&&n.hand){let r=this._hand;if(r)for(let c of n.hand.values())this._getHandJoint(r,c)}return this.dispatchEvent({type:"connected",data:n}),this}disconnect(n){return this.dispatchEvent({type:"disconnected",data:n}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(n,r,c){let u=null,d=null,b=null,w=this._targetRay,_=this._grip,x=this._hand;if(n&&r.session.visibilityState!=="visible-blurred"){if(x&&n.hand){b=!0;for(let F of n.hand.values()){let O=r.getJointPose(F,c),z=this._getHandJoint(x,F);O!==null&&(z.matrix.fromArray(O.transform.matrix),z.matrix.decompose(z.position,z.rotation,z.scale),z.matrixWorldNeedsUpdate=!0,z.jointRadius=O.radius),z.visible=O!==null}let T=x.joints["index-finger-tip"],M=x.joints["thumb-tip"],L=T.position.distanceTo(M.position),I=.02,D=.005;x.inputState.pinching&&L>I+D?(x.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:n.handedness,target:this})):!x.inputState.pinching&&L<=I-D&&(x.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:n.handedness,target:this}))}else _!==null&&n.gripSpace&&(d=r.getPose(n.gripSpace,c),d!==null&&(_.matrix.fromArray(d.transform.matrix),_.matrix.decompose(_.position,_.rotation,_.scale),_.matrixWorldNeedsUpdate=!0,d.linearVelocity?(_.hasLinearVelocity=!0,_.linearVelocity.copy(d.linearVelocity)):_.hasLinearVelocity=!1,d.angularVelocity?(_.hasAngularVelocity=!0,_.angularVelocity.copy(d.angularVelocity)):_.hasAngularVelocity=!1));w!==null&&(u=r.getPose(n.targetRaySpace,c),u===null&&d!==null&&(u=d),u!==null&&(w.matrix.fromArray(u.transform.matrix),w.matrix.decompose(w.position,w.rotation,w.scale),w.matrixWorldNeedsUpdate=!0,u.linearVelocity?(w.hasLinearVelocity=!0,w.linearVelocity.copy(u.linearVelocity)):w.hasLinearVelocity=!1,u.angularVelocity?(w.hasAngularVelocity=!0,w.angularVelocity.copy(u.angularVelocity)):w.hasAngularVelocity=!1,this.dispatchEvent(qfn)))}return w!==null&&(w.visible=u!==null),_!==null&&(_.visible=d!==null),x!==null&&(x.visible=b!==null),this}_getHandJoint(n,r){if(n.joints[r.jointName]===void 0){let c=new hT;c.matrixAutoUpdate=!1,c.visible=!1,n.joints[r.jointName]=c,n.add(c)}return n.joints[r.jointName]}},W6e=class extends bT{constructor(n,r){super();let c=this,u=null,d=1,b=null,w="local-floor",_=1,x=null,T=null,M=null,L=null,I=null,D=null,F=r.getContextAttributes(),O=null,z=null,Z=[],H=[],te=new La,se=null,ne=new dg;ne.layers.enable(1),ne.viewport=new Hh;let ue=new dg;ue.layers.enable(2),ue.viewport=new Hh;let Ce=[ne,ue],Q=new V6e;Q.layers.enable(1),Q.layers.enable(2);let me=null,tt=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(jt){let gn=Z[jt];return gn===void 0&&(gn=new IW,Z[jt]=gn),gn.getTargetRaySpace()},this.getControllerGrip=function(jt){let gn=Z[jt];return gn===void 0&&(gn=new IW,Z[jt]=gn),gn.getGripSpace()},this.getHand=function(jt){let gn=Z[jt];return gn===void 0&&(gn=new IW,Z[jt]=gn),gn.getHandSpace()};function st(jt){let gn=H.indexOf(jt.inputSource);if(gn===-1)return;let Un=Z[gn];Un!==void 0&&(Un.update(jt.inputSource,jt.frame,x||b),Un.dispatchEvent({type:jt.type,data:jt.inputSource}))}function at(){u.removeEventListener("select",st),u.removeEventListener("selectstart",st),u.removeEventListener("selectend",st),u.removeEventListener("squeeze",st),u.removeEventListener("squeezestart",st),u.removeEventListener("squeezeend",st),u.removeEventListener("end",at),u.removeEventListener("inputsourceschange",Ne);for(let jt=0;jt=0&&(H[Zi]=null,Z[Zi].disconnect(Un))}for(let gn=0;gn=H.length){H.push(Un),Zi=yr;break}else if(H[yr]===null){H[yr]=Un,Zi=yr;break}if(Zi===-1)break}let Hi=Z[Zi];Hi&&Hi.connect(Un)}}let Qe=new Gt,ot=new Gt;function xt(jt,gn,Un){Qe.setFromMatrixPosition(gn.matrixWorld),ot.setFromMatrixPosition(Un.matrixWorld);let Zi=Qe.distanceTo(ot),Hi=gn.projectionMatrix.elements,yr=Un.projectionMatrix.elements,Tr=Hi[14]/(Hi[10]-1),Ei=Hi[14]/(Hi[10]+1),xr=(Hi[9]+1)/Hi[5],oe=(Hi[9]-1)/Hi[5],de=(Hi[8]-1)/Hi[0],it=(yr[8]+1)/yr[0],We=Tr*de,_n=Tr*it,Er=Zi/(-de+it),qi=Er*-de;gn.matrixWorld.decompose(jt.position,jt.quaternion,jt.scale),jt.translateX(qi),jt.translateZ(Er),jt.matrixWorld.compose(jt.position,jt.quaternion,jt.scale),jt.matrixWorldInverse.copy(jt.matrixWorld).invert();let Te=Tr+Er,ve=Ei+Er,_t=We-qi,mn=_n+(Zi-qi),yn=xr*Ei/ve*Te,Sn=oe*Ei/ve*Te;jt.projectionMatrix.makePerspective(_t,mn,yn,Sn,Te,ve),jt.projectionMatrixInverse.copy(jt.projectionMatrix).invert()}function fn(jt,gn){gn===null?jt.matrixWorld.copy(jt.matrix):jt.matrixWorld.multiplyMatrices(gn.matrixWorld,jt.matrix),jt.matrixWorldInverse.copy(jt.matrixWorld).invert()}this.updateCamera=function(jt){if(u===null)return;Q.near=ue.near=ne.near=jt.near,Q.far=ue.far=ne.far=jt.far,(me!==Q.near||tt!==Q.far)&&(u.updateRenderState({depthNear:Q.near,depthFar:Q.far}),me=Q.near,tt=Q.far);let gn=jt.parent,Un=Q.cameras;fn(Q,gn);for(let Zi=0;Zi0&&(O.alphaTest.value=z.alphaTest);let Z=n.get(z).envMap;if(Z&&(O.envMap.value=Z,O.flipEnvMap.value=Z.isCubeTexture&&Z.isRenderTargetTexture===!1?-1:1,O.reflectivity.value=z.reflectivity,O.ior.value=z.ior,O.refractionRatio.value=z.refractionRatio),z.lightMap){O.lightMap.value=z.lightMap;let H=s._useLegacyLights===!0?Math.PI:1;O.lightMapIntensity.value=z.lightMapIntensity*H,r(z.lightMap,O.lightMapTransform)}z.aoMap&&(O.aoMap.value=z.aoMap,O.aoMapIntensity.value=z.aoMapIntensity,r(z.aoMap,O.aoMapTransform))}function b(O,z){O.diffuse.value.copy(z.color),O.opacity.value=z.opacity,z.map&&(O.map.value=z.map,r(z.map,O.mapTransform))}function w(O,z){O.dashSize.value=z.dashSize,O.totalSize.value=z.dashSize+z.gapSize,O.scale.value=z.scale}function _(O,z,Z,H){O.diffuse.value.copy(z.color),O.opacity.value=z.opacity,O.size.value=z.size*Z,O.scale.value=H*.5,z.map&&(O.map.value=z.map,r(z.map,O.uvTransform)),z.alphaMap&&(O.alphaMap.value=z.alphaMap,r(z.alphaMap,O.alphaMapTransform)),z.alphaTest>0&&(O.alphaTest.value=z.alphaTest)}function x(O,z){O.diffuse.value.copy(z.color),O.opacity.value=z.opacity,O.rotation.value=z.rotation,z.map&&(O.map.value=z.map,r(z.map,O.mapTransform)),z.alphaMap&&(O.alphaMap.value=z.alphaMap,r(z.alphaMap,O.alphaMapTransform)),z.alphaTest>0&&(O.alphaTest.value=z.alphaTest)}function T(O,z){O.specular.value.copy(z.specular),O.shininess.value=Math.max(z.shininess,1e-4)}function M(O,z){z.gradientMap&&(O.gradientMap.value=z.gradientMap)}function L(O,z){O.metalness.value=z.metalness,z.metalnessMap&&(O.metalnessMap.value=z.metalnessMap,r(z.metalnessMap,O.metalnessMapTransform)),O.roughness.value=z.roughness,z.roughnessMap&&(O.roughnessMap.value=z.roughnessMap,r(z.roughnessMap,O.roughnessMapTransform)),n.get(z).envMap&&(O.envMapIntensity.value=z.envMapIntensity)}function I(O,z,Z){O.ior.value=z.ior,z.sheen>0&&(O.sheenColor.value.copy(z.sheenColor).multiplyScalar(z.sheen),O.sheenRoughness.value=z.sheenRoughness,z.sheenColorMap&&(O.sheenColorMap.value=z.sheenColorMap,r(z.sheenColorMap,O.sheenColorMapTransform)),z.sheenRoughnessMap&&(O.sheenRoughnessMap.value=z.sheenRoughnessMap,r(z.sheenRoughnessMap,O.sheenRoughnessMapTransform))),z.clearcoat>0&&(O.clearcoat.value=z.clearcoat,O.clearcoatRoughness.value=z.clearcoatRoughness,z.clearcoatMap&&(O.clearcoatMap.value=z.clearcoatMap,r(z.clearcoatMap,O.clearcoatMapTransform)),z.clearcoatRoughnessMap&&(O.clearcoatRoughnessMap.value=z.clearcoatRoughnessMap,r(z.clearcoatRoughnessMap,O.clearcoatRoughnessMapTransform)),z.clearcoatNormalMap&&(O.clearcoatNormalMap.value=z.clearcoatNormalMap,r(z.clearcoatNormalMap,O.clearcoatNormalMapTransform),O.clearcoatNormalScale.value.copy(z.clearcoatNormalScale),z.side===Tm&&O.clearcoatNormalScale.value.negate())),z.iridescence>0&&(O.iridescence.value=z.iridescence,O.iridescenceIOR.value=z.iridescenceIOR,O.iridescenceThicknessMinimum.value=z.iridescenceThicknessRange[0],O.iridescenceThicknessMaximum.value=z.iridescenceThicknessRange[1],z.iridescenceMap&&(O.iridescenceMap.value=z.iridescenceMap,r(z.iridescenceMap,O.iridescenceMapTransform)),z.iridescenceThicknessMap&&(O.iridescenceThicknessMap.value=z.iridescenceThicknessMap,r(z.iridescenceThicknessMap,O.iridescenceThicknessMapTransform))),z.transmission>0&&(O.transmission.value=z.transmission,O.transmissionSamplerMap.value=Z.texture,O.transmissionSamplerSize.value.set(Z.width,Z.height),z.transmissionMap&&(O.transmissionMap.value=z.transmissionMap,r(z.transmissionMap,O.transmissionMapTransform)),O.thickness.value=z.thickness,z.thicknessMap&&(O.thicknessMap.value=z.thicknessMap,r(z.thicknessMap,O.thicknessMapTransform)),O.attenuationDistance.value=z.attenuationDistance,O.attenuationColor.value.copy(z.attenuationColor)),z.anisotropy>0&&(O.anisotropyVector.value.set(z.anisotropy*Math.cos(z.anisotropyRotation),z.anisotropy*Math.sin(z.anisotropyRotation)),z.anisotropyMap&&(O.anisotropyMap.value=z.anisotropyMap,r(z.anisotropyMap,O.anisotropyMapTransform))),O.specularIntensity.value=z.specularIntensity,O.specularColor.value.copy(z.specularColor),z.specularColorMap&&(O.specularColorMap.value=z.specularColorMap,r(z.specularColorMap,O.specularColorMapTransform)),z.specularIntensityMap&&(O.specularIntensityMap.value=z.specularIntensityMap,r(z.specularIntensityMap,O.specularIntensityMapTransform))}function D(O,z){z.matcap&&(O.matcap.value=z.matcap)}function F(O,z){let Z=n.get(z).light;O.referencePosition.value.setFromMatrixPosition(Z.matrixWorld),O.nearDistance.value=Z.shadow.camera.near,O.farDistance.value=Z.shadow.camera.far}return{refreshFogUniforms:c,refreshMaterialUniforms:u}}function Yfn(s,n,r,c){let u={},d={},b=[],w=r.isWebGL2?s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS):0;function _(Z,H){let te=H.program;c.uniformBlockBinding(Z,te)}function x(Z,H){let te=u[Z.id];te===void 0&&(D(Z),te=T(Z),u[Z.id]=te,Z.addEventListener("dispose",O));let se=H.program;c.updateUBOMapping(Z,se);let ne=n.render.frame;d[Z.id]!==ne&&(L(Z),d[Z.id]=ne)}function T(Z){let H=M();Z.__bindingPointIndex=H;let te=s.createBuffer(),se=Z.__size,ne=Z.usage;return s.bindBuffer(s.UNIFORM_BUFFER,te),s.bufferData(s.UNIFORM_BUFFER,se,ne),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,H,te),te}function M(){for(let Z=0;Z0&&(te+=se-ne),Z.__size=te,Z.__cache={},this}function F(Z){let H={boundary:0,storage:0};return typeof Z=="number"||typeof Z=="boolean"?(H.boundary=4,H.storage=4):Z.isVector2?(H.boundary=8,H.storage=8):Z.isVector3||Z.isColor?(H.boundary=16,H.storage=12):Z.isVector4?(H.boundary=16,H.storage=16):Z.isMatrix3?(H.boundary=48,H.storage=48):Z.isMatrix4?(H.boundary=64,H.storage=64):Z.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",Z),H}function O(Z){let H=Z.target;H.removeEventListener("dispose",O);let te=b.indexOf(H.__bindingPointIndex);b.splice(te,1),s.deleteBuffer(u[H.id]),delete u[H.id],delete d[H.id]}function z(){for(let Z in u)s.deleteBuffer(u[Z]);b=[],u={},d={}}return{bind:_,update:x,dispose:z}}var UW=class{constructor(n={}){let{canvas:r=ran(),context:c=null,depth:u=!0,stencil:d=!0,alpha:b=!1,antialias:w=!1,premultipliedAlpha:_=!0,preserveDrawingBuffer:x=!1,powerPreference:T="default",failIfMajorPerformanceCaveat:M=!1}=n;this.isWebGLRenderer=!0;let L;c!==null?L=c.getContextAttributes().alpha:L=b;let I=new Uint32Array(4),D=new Int32Array(4),F=null,O=null,z=[],Z=[];this.domElement=r,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Md,this._useLegacyLights=!1,this.toneMapping=pT,this.toneMappingExposure=1;let H=this,te=!1,se=0,ne=0,ue=null,Ce=-1,Q=null,me=new Hh,tt=new Hh,st=null,at=new zo(0),Ne=0,Qe=r.width,ot=r.height,xt=1,fn=null,Xt=null,wn=new Hh(0,0,Qe,ot),cn=new Hh(0,0,Qe,ot),bi=!1,jt=new FW,gn=!1,Un=!1,Zi=null,Hi=new Rl,yr=new La,Tr=new Gt,Ei={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function xr(){return ue===null?xt:1}let oe=c;function de(Le,St){for(let Kt=0;Kt{function Xi(){if(en.forEach(function(Rr){qi.get(Rr).currentProgram.isReady()&&en.delete(Rr)}),en.size===0){Yt(Le);return}setTimeout(Xi,10)}it.get("KHR_parallel_shader_compile")!==null?Xi():setTimeout(Xi,10)})};let ht=null;function on(Le){ht&&ht(Le)}function Ri(){er.stop()}function di(){er.start()}let er=new L2t;er.setAnimationLoop(on),typeof self<"u"&&er.setContext(self),this.setAnimationLoop=function(Le){ht=Le,Bi.setAnimationLoop(Le),Le===null?er.stop():er.start()},Bi.addEventListener("sessionstart",Ri),Bi.addEventListener("sessionend",di),this.render=function(Le,St){if(St!==void 0&&St.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(te===!0)return;Le.matrixWorldAutoUpdate===!0&&Le.updateMatrixWorld(),St.parent===null&&St.matrixWorldAutoUpdate===!0&&St.updateMatrixWorld(),Bi.enabled===!0&&Bi.isPresenting===!0&&(Bi.cameraAutoUpdate===!0&&Bi.updateCamera(St),St=Bi.getCamera()),Le.isScene===!0&&Le.onBeforeRender(H,Le,St,ue),O=Ge.get(Le,Z.length),O.init(),Z.push(O),Hi.multiplyMatrices(St.projectionMatrix,St.matrixWorldInverse),jt.setFromProjectionMatrix(Hi),Un=this.localClippingEnabled,gn=Pe.init(this.clippingPlanes,Un),F=ri.get(Le,z.length),F.init(),z.push(F),ms(Le,St,0,H.sortObjects),F.finish(),H.sortObjects===!0&&F.sort(fn,Xt),this.info.render.frame++,gn===!0&&Pe.beginShadows();let Kt=O.state.shadowsArray;if(ke.render(Kt,Le,St),gn===!0&&Pe.endShadows(),this.info.autoReset===!0&&this.info.reset(),dt.render(F,Le),O.setupLights(H._useLegacyLights),St.isArrayCamera){let en=St.cameras;for(let Yt=0,Xi=en.length;Yt0?O=Z[Z.length-1]:O=null,z.pop(),z.length>0?F=z[z.length-1]:F=null};function ms(Le,St,Kt,en){if(Le.visible===!1)return;if(Le.layers.test(St.layers)){if(Le.isGroup)Kt=Le.renderOrder;else if(Le.isLOD)Le.autoUpdate===!0&&Le.update(St);else if(Le.isLight)O.pushLight(Le),Le.castShadow&&O.pushShadow(Le);else if(Le.isSprite){if(!Le.frustumCulled||jt.intersectsSprite(Le)){en&&Tr.setFromMatrixPosition(Le.matrixWorld).applyMatrix4(Hi);let Rr=Sn.update(Le),qr=Le.material;qr.visible&&F.push(Le,Rr,qr,Kt,Tr.z,null)}}else if((Le.isMesh||Le.isLine||Le.isPoints)&&(!Le.frustumCulled||jt.intersectsObject(Le))){let Rr=Sn.update(Le),qr=Le.material;if(en&&(Le.boundingSphere!==void 0?(Le.boundingSphere===null&&Le.computeBoundingSphere(),Tr.copy(Le.boundingSphere.center)):(Rr.boundingSphere===null&&Rr.computeBoundingSphere(),Tr.copy(Rr.boundingSphere.center)),Tr.applyMatrix4(Le.matrixWorld).applyMatrix4(Hi)),Array.isArray(qr)){let bs=Rr.groups;for(let Ws=0,xs=bs.length;Ws0&&$i(Yt,Xi,St,Kt),en&&_n.viewport(me.copy(en)),Yt.length>0&&Vs(Yt,St,Kt),Xi.length>0&&Vs(Xi,St,Kt),Rr.length>0&&Vs(Rr,St,Kt),_n.buffers.depth.setTest(!0),_n.buffers.depth.setMask(!0),_n.buffers.color.setMask(!0),_n.setPolygonOffset(!1)}function $i(Le,St,Kt,en){if((Kt.isScene===!0?Kt.overrideMaterial:null)!==null)return;let Xi=We.isWebGL2;Zi===null&&(Zi=new Y3(1,1,{generateMipmaps:!0,type:it.has("EXT_color_buffer_half_float")?BW:gT,minFilter:DW,samples:Xi?4:0})),H.getDrawingBufferSize(yr),Xi?Zi.setSize(yr.x,yr.y):Zi.setSize(L6e(yr.x),L6e(yr.y));let Rr=H.getRenderTarget();H.setRenderTarget(Zi),H.getClearColor(at),Ne=H.getClearAlpha(),Ne<1&&H.setClearColor(16777215,.5),H.clear();let qr=H.toneMapping;H.toneMapping=pT,Vs(Le,Kt,en),Te.updateMultisampleRenderTarget(Zi),Te.updateRenderTargetMipmap(Zi);let bs=!1;for(let Ws=0,xs=St.length;Ws0),Cs=!!Kt.morphAttributes.position,Pc=!!Kt.morphAttributes.normal,Uf=!!Kt.morphAttributes.color,dl=pT;en.toneMapped&&(ue===null||ue.isXRRenderTarget===!0)&&(dl=H.toneMapping);let bg=Kt.morphAttributes.position||Kt.morphAttributes.normal||Kt.morphAttributes.color,fc=bg!==void 0?bg.length:0,Qs=qi.get(en),b2=O.state.lights;if(gn===!0&&(Un===!0||Le!==Q)){let ph=Le===Q&&en.id===Ce;Pe.setState(en,Le,ph)}let hc=!1;en.version===Qs.__version?(Qs.needsLights&&Qs.lightsStateVersion!==b2.state.version||Qs.outputColorSpace!==qr||Yt.isBatchedMesh&&Qs.batching===!1||!Yt.isBatchedMesh&&Qs.batching===!0||Yt.isInstancedMesh&&Qs.instancing===!1||!Yt.isInstancedMesh&&Qs.instancing===!0||Yt.isSkinnedMesh&&Qs.skinning===!1||!Yt.isSkinnedMesh&&Qs.skinning===!0||Yt.isInstancedMesh&&Qs.instancingColor===!0&&Yt.instanceColor===null||Yt.isInstancedMesh&&Qs.instancingColor===!1&&Yt.instanceColor!==null||Qs.envMap!==bs||en.fog===!0&&Qs.fog!==Xi||Qs.numClippingPlanes!==void 0&&(Qs.numClippingPlanes!==Pe.numPlanes||Qs.numIntersection!==Pe.numIntersection)||Qs.vertexAlphas!==Ws||Qs.vertexTangents!==xs||Qs.morphTargets!==Cs||Qs.morphNormals!==Pc||Qs.morphColors!==Uf||Qs.toneMapping!==dl||We.isWebGL2===!0&&Qs.morphTargetsCount!==fc)&&(hc=!0):(hc=!0,Qs.__version=en.version);let km=Qs.currentProgram;hc===!0&&(km=Lm(en,St,Yt));let w2=!1,Iv=!1,v2=!1,pl=km.getUniforms(),Rm=Qs.uniforms;if(_n.useProgram(km.program)&&(w2=!0,Iv=!0,v2=!0),en.id!==Ce&&(Ce=en.id,Iv=!0),w2||Q!==Le){pl.setValue(oe,"projectionMatrix",Le.projectionMatrix),pl.setValue(oe,"viewMatrix",Le.matrixWorldInverse);let ph=pl.map.cameraPosition;ph!==void 0&&ph.setValue(oe,Tr.setFromMatrixPosition(Le.matrixWorld)),We.logarithmicDepthBuffer&&pl.setValue(oe,"logDepthBufFC",2/(Math.log(Le.far+1)/Math.LN2)),(en.isMeshPhongMaterial||en.isMeshToonMaterial||en.isMeshLambertMaterial||en.isMeshBasicMaterial||en.isMeshStandardMaterial||en.isShaderMaterial)&&pl.setValue(oe,"isOrthographic",Le.isOrthographicCamera===!0),Q!==Le&&(Q=Le,Iv=!0,v2=!0)}if(Yt.isSkinnedMesh){pl.setOptional(oe,Yt,"bindMatrix"),pl.setOptional(oe,Yt,"bindMatrixInverse");let ph=Yt.skeleton;ph&&(We.floatVertexTextures?(ph.boneTexture===null&&ph.computeBoneTexture(),pl.setValue(oe,"boneTexture",ph.boneTexture,Te)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}Yt.isBatchedMesh&&(pl.setOptional(oe,Yt,"batchingTexture"),pl.setValue(oe,"batchingTexture",Yt._matricesTexture,Te));let iE=Kt.morphAttributes;if((iE.position!==void 0||iE.normal!==void 0||iE.color!==void 0&&We.isWebGL2===!0)&&Ye.update(Yt,Kt,km),(Iv||Qs.receiveShadow!==Yt.receiveShadow)&&(Qs.receiveShadow=Yt.receiveShadow,pl.setValue(oe,"receiveShadow",Yt.receiveShadow)),en.isMeshGouraudMaterial&&en.envMap!==null&&(Rm.envMap.value=bs,Rm.flipEnvMap.value=bs.isCubeTexture&&bs.isRenderTargetTexture===!1?-1:1),Iv&&(pl.setValue(oe,"toneMappingExposure",H.toneMappingExposure),Qs.needsLights&&AT(Rm,v2),Xi&&en.fog===!0&&hi.refreshFogUniforms(Rm,Xi),hi.refreshMaterialUniforms(Rm,en,xt,ot,Zi),cO.upload(oe,mg(Qs),Rm,Te)),en.isShaderMaterial&&en.uniformsNeedUpdate===!0&&(cO.upload(oe,mg(Qs),Rm,Te),en.uniformsNeedUpdate=!1),en.isSpriteMaterial&&pl.setValue(oe,"center",Yt.center),pl.setValue(oe,"modelViewMatrix",Yt.modelViewMatrix),pl.setValue(oe,"normalMatrix",Yt.normalMatrix),pl.setValue(oe,"modelMatrix",Yt.matrixWorld),en.isShaderMaterial||en.isRawShaderMaterial){let ph=en.uniformsGroups;for(let _2=0,rE=ph.length;_20&&Te.useMultisampledRTT(Le)===!1?Yt=qi.get(Le).__webglMultisampledFramebuffer:Array.isArray(xs)?Yt=xs[Kt]:Yt=xs,me.copy(Le.viewport),tt.copy(Le.scissor),st=Le.scissorTest}else me.copy(wn).multiplyScalar(xt).floor(),tt.copy(cn).multiplyScalar(xt).floor(),st=bi;if(_n.bindFramebuffer(oe.FRAMEBUFFER,Yt)&&We.drawBuffers&&en&&_n.drawBuffers(Le,Yt),_n.viewport(me),_n.scissor(tt),_n.setScissorTest(st),Xi){let bs=qi.get(Le.texture);oe.framebufferTexture2D(oe.FRAMEBUFFER,oe.COLOR_ATTACHMENT0,oe.TEXTURE_CUBE_MAP_POSITIVE_X+St,bs.__webglTexture,Kt)}else if(Rr){let bs=qi.get(Le.texture),Ws=St||0;oe.framebufferTextureLayer(oe.FRAMEBUFFER,oe.COLOR_ATTACHMENT0,bs.__webglTexture,Kt||0,Ws)}Ce=-1},this.readRenderTargetPixels=function(Le,St,Kt,en,Yt,Xi,Rr){if(!(Le&&Le.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let qr=qi.get(Le).__webglFramebuffer;if(Le.isWebGLCubeRenderTarget&&Rr!==void 0&&(qr=qr[Rr]),qr){_n.bindFramebuffer(oe.FRAMEBUFFER,qr);try{let bs=Le.texture,Ws=bs.format,xs=bs.type;if(Ws!==Mv&&Ke.convert(Ws)!==oe.getParameter(oe.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Cs=xs===BW&&(it.has("EXT_color_buffer_half_float")||We.isWebGL2&&it.has("EXT_color_buffer_float"));if(xs!==gT&&Ke.convert(xs)!==oe.getParameter(oe.IMPLEMENTATION_COLOR_READ_TYPE)&&!(xs===fT&&(We.isWebGL2||it.has("OES_texture_float")||it.has("WEBGL_color_buffer_float")))&&!Cs){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}St>=0&&St<=Le.width-en&&Kt>=0&&Kt<=Le.height-Yt&&oe.readPixels(St,Kt,en,Yt,Ke.convert(Ws),Ke.convert(xs),Xi)}finally{let bs=ue!==null?qi.get(ue).__webglFramebuffer:null;_n.bindFramebuffer(oe.FRAMEBUFFER,bs)}}},this.copyFramebufferToTexture=function(Le,St,Kt=0){let en=Math.pow(2,-Kt),Yt=Math.floor(St.image.width*en),Xi=Math.floor(St.image.height*en);Te.setTexture2D(St,0),oe.copyTexSubImage2D(oe.TEXTURE_2D,Kt,0,0,Le.x,Le.y,Yt,Xi),_n.unbindTexture()},this.copyTextureToTexture=function(Le,St,Kt,en=0){let Yt=St.image.width,Xi=St.image.height,Rr=Ke.convert(Kt.format),qr=Ke.convert(Kt.type);Te.setTexture2D(Kt,0),oe.pixelStorei(oe.UNPACK_FLIP_Y_WEBGL,Kt.flipY),oe.pixelStorei(oe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Kt.premultiplyAlpha),oe.pixelStorei(oe.UNPACK_ALIGNMENT,Kt.unpackAlignment),St.isDataTexture?oe.texSubImage2D(oe.TEXTURE_2D,en,Le.x,Le.y,Yt,Xi,Rr,qr,St.image.data):St.isCompressedTexture?oe.compressedTexSubImage2D(oe.TEXTURE_2D,en,Le.x,Le.y,St.mipmaps[0].width,St.mipmaps[0].height,Rr,St.mipmaps[0].data):oe.texSubImage2D(oe.TEXTURE_2D,en,Le.x,Le.y,Rr,qr,St.image),en===0&&Kt.generateMipmaps&&oe.generateMipmap(oe.TEXTURE_2D),_n.unbindTexture()},this.copyTextureToTexture3D=function(Le,St,Kt,en,Yt=0){if(H.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Xi=Le.max.x-Le.min.x+1,Rr=Le.max.y-Le.min.y+1,qr=Le.max.z-Le.min.z+1,bs=Ke.convert(en.format),Ws=Ke.convert(en.type),xs;if(en.isData3DTexture)Te.setTexture3D(en,0),xs=oe.TEXTURE_3D;else if(en.isDataArrayTexture||en.isCompressedArrayTexture)Te.setTexture2DArray(en,0),xs=oe.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}oe.pixelStorei(oe.UNPACK_FLIP_Y_WEBGL,en.flipY),oe.pixelStorei(oe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,en.premultiplyAlpha),oe.pixelStorei(oe.UNPACK_ALIGNMENT,en.unpackAlignment);let Cs=oe.getParameter(oe.UNPACK_ROW_LENGTH),Pc=oe.getParameter(oe.UNPACK_IMAGE_HEIGHT),Uf=oe.getParameter(oe.UNPACK_SKIP_PIXELS),dl=oe.getParameter(oe.UNPACK_SKIP_ROWS),bg=oe.getParameter(oe.UNPACK_SKIP_IMAGES),fc=Kt.isCompressedTexture?Kt.mipmaps[Yt]:Kt.image;oe.pixelStorei(oe.UNPACK_ROW_LENGTH,fc.width),oe.pixelStorei(oe.UNPACK_IMAGE_HEIGHT,fc.height),oe.pixelStorei(oe.UNPACK_SKIP_PIXELS,Le.min.x),oe.pixelStorei(oe.UNPACK_SKIP_ROWS,Le.min.y),oe.pixelStorei(oe.UNPACK_SKIP_IMAGES,Le.min.z),Kt.isDataTexture||Kt.isData3DTexture?oe.texSubImage3D(xs,Yt,St.x,St.y,St.z,Xi,Rr,qr,bs,Ws,fc.data):Kt.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),oe.compressedTexSubImage3D(xs,Yt,St.x,St.y,St.z,Xi,Rr,qr,bs,fc.data)):oe.texSubImage3D(xs,Yt,St.x,St.y,St.z,Xi,Rr,qr,bs,Ws,fc),oe.pixelStorei(oe.UNPACK_ROW_LENGTH,Cs),oe.pixelStorei(oe.UNPACK_IMAGE_HEIGHT,Pc),oe.pixelStorei(oe.UNPACK_SKIP_PIXELS,Uf),oe.pixelStorei(oe.UNPACK_SKIP_ROWS,dl),oe.pixelStorei(oe.UNPACK_SKIP_IMAGES,bg),Yt===0&&en.generateMipmaps&&oe.generateMipmap(xs),_n.unbindTexture()},this.initTexture=function(Le){Le.isCubeTexture?Te.setTextureCube(Le,0):Le.isData3DTexture?Te.setTexture3D(Le,0):Le.isDataArrayTexture||Le.isCompressedArrayTexture?Te.setTexture2DArray(Le,0):Te.setTexture2D(Le,0),_n.unbindTexture()},this.resetState=function(){se=0,ne=0,ue=null,_n.reset(),gt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return q3}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(n){this._outputColorSpace=n;let r=this.getContext();r.drawingBufferColorSpace=n===u5e?"display-p3":"srgb",r.unpackColorSpace=Ac.workingColorSpace===whe?"display-p3":"srgb"}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Md?q4:S2t}set outputEncoding(n){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=n===q4?Md:X3}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(n){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=n}},H6e=class extends UW{};H6e.prototype.isWebGL1Renderer=!0;var ahe=class extends pg{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(n,r){return super.copy(n,r),n.background!==null&&(this.background=n.background.clone()),n.environment!==null&&(this.environment=n.environment.clone()),n.fog!==null&&(this.fog=n.fog.clone()),this.backgroundBlurriness=n.backgroundBlurriness,this.backgroundIntensity=n.backgroundIntensity,n.overrideMaterial!==null&&(this.overrideMaterial=n.overrideMaterial.clone()),this.matrixAutoUpdate=n.matrixAutoUpdate,this}toJSON(n){let r=super.toJSON(n);return this.fog!==null&&(r.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(r.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(r.object.backgroundIntensity=this.backgroundIntensity),r}};var che=class extends q1{constructor(n,r,c,u=1){super(n,r,c),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=u}copy(n){return super.copy(n),this.meshPerAttribute=n.meshPerAttribute,this}toJSON(){let n=super.toJSON();return n.meshPerAttribute=this.meshPerAttribute,n.isInstancedBufferAttribute=!0,n}},iO=new Rl,s2t=new Rl,Bfe=[],o2t=new Z3,Zfn=new Rl,LW=new Mm,kW=new wT,lhe=class extends Mm{constructor(n,r,c){super(n,r),this.isInstancedMesh=!0,this.instanceMatrix=new che(new Float32Array(c*16),16),this.instanceColor=null,this.count=c,this.boundingBox=null,this.boundingSphere=null;for(let u=0;u_)continue;L.applyMatrix4(this.matrixWorld);let Ce=n.ray.origin.distanceTo(L);Cen.far||r.push({distance:Ce,point:M.clone().applyMatrix4(this.matrixWorld),index:H,face:null,faceIndex:null,object:this})}}else{let z=Math.max(0,b.start),Z=Math.min(O.count,b.start+b.count);for(let H=z,te=Z-1;H_)continue;L.applyMatrix4(this.matrixWorld);let ne=n.ray.origin.distanceTo(L);nen.far||r.push({distance:ne,point:M.clone().applyMatrix4(this.matrixWorld),index:H,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let r=this.geometry.morphAttributes,c=Object.keys(r);if(c.length>0){let u=r[c[0]];if(u!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let d=0,b=u.length;d=d)){let w=r[1];n=d)break t}b=c,c=0;break n}break e}for(;c>>1;nr;)--b;if(++b,d!==0||b!==u){d>=b&&(b=Math.max(b,1),d=b-1);let w=this.getValueSize();this.times=c.slice(d,b),this.values=this.values.slice(d*w,b*w)}return this}validate(){let n=!0,r=this.getValueSize();r-Math.floor(r)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),n=!1);let c=this.times,u=this.values,d=c.length;d===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),n=!1);let b=null;for(let w=0;w!==d;w++){let _=c[w];if(typeof _=="number"&&isNaN(_)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,w,_),n=!1;break}if(b!==null&&b>_){console.error("THREE.KeyframeTrack: Out of order keys.",this,w,_,b),n=!1;break}b=_}if(u!==void 0&&Kfn(u))for(let w=0,_=u.length;w!==_;++w){let x=u[w];if(isNaN(x)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,w,x),n=!1;break}}return n}optimize(){let n=this.times.slice(),r=this.values.slice(),c=this.getValueSize(),u=this.getInterpolation()===YIe,d=n.length-1,b=1;for(let w=1;w0){n[b]=n[d];for(let w=d*c,_=b*c,x=0;x!==c;++x)r[_+x]=r[w+x];++b}return b!==n.length?(this.times=n.slice(0,b),this.values=r.slice(0,b*c)):(this.times=n,this.values=r),this}clone(){let n=this.times.slice(),r=this.values.slice(),c=this.constructor,u=new c(this.name,n,r);return u.createInterpolant=this.createInterpolant,u}};Cv.prototype.TimeBufferType=Float32Array;Cv.prototype.ValueBufferType=Float32Array;Cv.prototype.DefaultInterpolation=Vfe;var Y4=class extends Cv{};Y4.prototype.ValueTypeName="bool";Y4.prototype.ValueBufferType=Array;Y4.prototype.DefaultInterpolation=$fe;Y4.prototype.InterpolantFactoryMethodLinear=void 0;Y4.prototype.InterpolantFactoryMethodSmooth=void 0;var K6e=class extends Cv{};K6e.prototype.ValueTypeName="color";var J6e=class extends Cv{};J6e.prototype.ValueTypeName="number";var Q6e=class extends gO{constructor(n,r,c,u){super(n,r,c,u)}interpolate_(n,r,c,u){let d=this.resultBuffer,b=this.sampleValues,w=this.valueSize,_=(c-r)/(u-r),x=n*w;for(let T=x+w;x!==T;x+=4)h2.slerpFlat(d,0,b,x-w,b,x,_);return d}},GW=class extends Cv{InterpolantFactoryMethodLinear(n){return new Q6e(this.times,this.values,this.getValueSize(),n)}};GW.prototype.ValueTypeName="quaternion";GW.prototype.DefaultInterpolation=Vfe;GW.prototype.InterpolantFactoryMethodSmooth=void 0;var Z4=class extends Cv{};Z4.prototype.ValueTypeName="string";Z4.prototype.ValueBufferType=Array;Z4.prototype.DefaultInterpolation=$fe;Z4.prototype.InterpolantFactoryMethodLinear=void 0;Z4.prototype.InterpolantFactoryMethodSmooth=void 0;var e5e=class extends Cv{};e5e.prototype.ValueTypeName="vector";var t5e=class{constructor(n,r,c){let u=this,d=!1,b=0,w=0,_,x=[];this.onStart=void 0,this.onLoad=n,this.onProgress=r,this.onError=c,this.itemStart=function(T){w++,d===!1&&u.onStart!==void 0&&u.onStart(T,b,w),d=!0},this.itemEnd=function(T){b++,u.onProgress!==void 0&&u.onProgress(T,b,w),b===w&&(d=!1,u.onLoad!==void 0&&u.onLoad())},this.itemError=function(T){u.onError!==void 0&&u.onError(T)},this.resolveURL=function(T){return _?_(T):T},this.setURLModifier=function(T){return _=T,this},this.addHandler=function(T,M){return x.push(T,M),this},this.removeHandler=function(T){let M=x.indexOf(T);return M!==-1&&x.splice(M,2),this},this.getHandler=function(T){for(let M=0,L=x.length;Mandnandornorxorxnornotbufdffinputconstantoutputhi:lohi:lohi:lohi:logenericout0out1in0in1aoi21aoi22aoi211aoi221aoi222aoi33oai21oai22oai211oai221oai222oai33and3nand3or3nor3and4nand4or4nor4`;window.netlistsvg=PAe;window.openroadSkin=pKt;window.THREE=f2t;var Det=globalThis,Oet=Det.ShadowRoot&&(Det.ShadyCSS===void 0||Det.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,mKt=Symbol(),gKt=new WeakMap,Net=class{constructor(s,h,p){if(this._$cssResult$=!0,p!==mKt)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=s,this.t=h}get styleSheet(){let s=this.o,h=this.t;if(Oet&&s===void 0){let p=h!==void 0&&h.length===1;p&&(s=gKt.get(h)),s===void 0&&((this.o=s=new CSSStyleSheet).replaceSync(this.cssText),p&&gKt.set(h,s))}return s}toString(){return this.cssText}},bKt=d=>new Net(typeof d=="string"?d:d+"",void 0,mKt);var wKt=(d,s)=>{if(Oet)d.adoptedStyleSheets=s.map(h=>h instanceof CSSStyleSheet?h:h.styleSheet);else for(let h of s){let p=document.createElement("style"),m=Det.litNonce;m!==void 0&&p.setAttribute("nonce",m),p.textContent=h.cssText,d.appendChild(p)}},d2t=Oet?d=>d:d=>d instanceof CSSStyleSheet?(s=>{let h="";for(let p of s.cssRules)h+=p.cssText;return bKt(h)})(d):d;var{is:IAe,defineProperty:RAe,getOwnPropertyDescriptor:DAe,getOwnPropertyNames:NAe,getOwnPropertySymbols:OAe,getPrototypeOf:BAe}=Object,Bet=globalThis,vKt=Bet.trustedTypes,FAe=vKt?vKt.emptyScript:"",UAe=Bet.reactiveElementPolyfillSupport,TU=(d,s)=>d,p2t={toAttribute(d,s){switch(s){case Boolean:d=d?FAe:null;break;case Object:case Array:d=d==null?d:JSON.stringify(d)}return d},fromAttribute(d,s){let h=d;switch(s){case Boolean:h=d!==null;break;case Number:h=d===null?null:Number(d);break;case Object:case Array:try{h=JSON.parse(d)}catch{h=null}}return h}},yKt=(d,s)=>!IAe(d,s),_Kt={attribute:!0,type:String,converter:p2t,reflect:!1,useDefault:!1,hasChanged:yKt};Symbol.metadata??=Symbol("metadata"),Bet.litPropertyMetadata??=new WeakMap;var Qx=class extends HTMLElement{static addInitializer(s){this._$Ei(),(this.l??=[]).push(s)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(s,h=_Kt){if(h.state&&(h.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(s)&&((h=Object.create(h)).wrapped=!0),this.elementProperties.set(s,h),!h.noAccessor){let p=Symbol(),m=this.getPropertyDescriptor(s,p,h);m!==void 0&&RAe(this.prototype,s,m)}}static getPropertyDescriptor(s,h,p){let{get:m,set:_}=DAe(this.prototype,s)??{get(){return this[h]},set(S){this[h]=S}};return{get:m,set(S){let y=m?.call(this);_?.call(this,S),this.requestUpdate(s,y,p)},configurable:!0,enumerable:!0}}static getPropertyOptions(s){return this.elementProperties.get(s)??_Kt}static _$Ei(){if(this.hasOwnProperty(TU("elementProperties")))return;let s=BAe(this);s.finalize(),s.l!==void 0&&(this.l=[...s.l]),this.elementProperties=new Map(s.elementProperties)}static finalize(){if(this.hasOwnProperty(TU("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(TU("properties"))){let h=this.properties,p=[...NAe(h),...OAe(h)];for(let m of p)this.createProperty(m,h[m])}let s=this[Symbol.metadata];if(s!==null){let h=litPropertyMetadata.get(s);if(h!==void 0)for(let[p,m]of h)this.elementProperties.set(p,m)}this._$Eh=new Map;for(let[h,p]of this.elementProperties){let m=this._$Eu(h,p);m!==void 0&&this._$Eh.set(m,h)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(s){let h=[];if(Array.isArray(s)){let p=new Set(s.flat(1/0).reverse());for(let m of p)h.unshift(d2t(m))}else s!==void 0&&h.push(d2t(s));return h}static _$Eu(s,h){let p=h.attribute;return p===!1?void 0:typeof p=="string"?p:typeof s=="string"?s.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(s=>this.enableUpdating=s),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(s=>s(this))}addController(s){(this._$EO??=new Set).add(s),this.renderRoot!==void 0&&this.isConnected&&s.hostConnected?.()}removeController(s){this._$EO?.delete(s)}_$E_(){let s=new Map,h=this.constructor.elementProperties;for(let p of h.keys())this.hasOwnProperty(p)&&(s.set(p,this[p]),delete this[p]);s.size>0&&(this._$Ep=s)}createRenderRoot(){let s=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return wKt(s,this.constructor.elementStyles),s}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(s=>s.hostConnected?.())}enableUpdating(s){}disconnectedCallback(){this._$EO?.forEach(s=>s.hostDisconnected?.())}attributeChangedCallback(s,h,p){this._$AK(s,p)}_$ET(s,h){let p=this.constructor.elementProperties.get(s),m=this.constructor._$Eu(s,p);if(m!==void 0&&p.reflect===!0){let _=(p.converter?.toAttribute!==void 0?p.converter:p2t).toAttribute(h,p.type);this._$Em=s,_==null?this.removeAttribute(m):this.setAttribute(m,_),this._$Em=null}}_$AK(s,h){let p=this.constructor,m=p._$Eh.get(s);if(m!==void 0&&this._$Em!==m){let _=p.getPropertyOptions(m),S=typeof _.converter=="function"?{fromAttribute:_.converter}:_.converter?.fromAttribute!==void 0?_.converter:p2t;this._$Em=m;let y=S.fromAttribute(h,_.type);this[m]=y??this._$Ej?.get(m)??y,this._$Em=null}}requestUpdate(s,h,p,m=!1,_){if(s!==void 0){let S=this.constructor;if(m===!1&&(_=this[s]),p??=S.getPropertyOptions(s),!((p.hasChanged??yKt)(_,h)||p.useDefault&&p.reflect&&_===this._$Ej?.get(s)&&!this.hasAttribute(S._$Eu(s,p))))return;this.C(s,h,p)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(s,h,{useDefault:p,reflect:m,wrapped:_},S){p&&!(this._$Ej??=new Map).has(s)&&(this._$Ej.set(s,S??h??this[s]),_!==!0||S!==void 0)||(this._$AL.has(s)||(this.hasUpdated||p||(h=void 0),this._$AL.set(s,h)),m===!0&&this._$Em!==s&&(this._$Eq??=new Set).add(s))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(h){Promise.reject(h)}let s=this.scheduleUpdate();return s!=null&&await s,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[m,_]of this._$Ep)this[m]=_;this._$Ep=void 0}let p=this.constructor.elementProperties;if(p.size>0)for(let[m,_]of p){let{wrapped:S}=_,y=this[m];S!==!0||this._$AL.has(m)||y===void 0||this.C(m,void 0,_,y)}}let s=!1,h=this._$AL;try{s=this.shouldUpdate(h),s?(this.willUpdate(h),this._$EO?.forEach(p=>p.hostUpdate?.()),this.update(h)):this._$EM()}catch(p){throw s=!1,this._$EM(),p}s&&this._$AE(h)}willUpdate(s){}_$AE(s){this._$EO?.forEach(h=>h.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(s)),this.updated(s)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(s){return!0}update(s){this._$Eq&&=this._$Eq.forEach(h=>this._$ET(h,this[h])),this._$EM()}updated(s){}firstUpdated(s){}};Qx.elementStyles=[],Qx.shadowRootOptions={mode:"open"},Qx[TU("elementProperties")]=new Map,Qx[TU("finalized")]=new Map,UAe?.({ReactiveElement:Qx}),(Bet.reactiveElementVersions??=[]).push("2.1.2");var m2t=globalThis,xKt=d=>d,Fet=m2t.trustedTypes,MKt=Fet?Fet.createPolicy("lit-html",{createHTML:d=>d}):void 0,b2t="$lit$",t3=`lit$${Math.random().toFixed(9).slice(2)}$`,w2t="?"+t3,zAe=`<${w2t}>`,KA=document,AU=()=>KA.createComment(""),kU=d=>d===null||typeof d!="object"&&typeof d!="function",v2t=Array.isArray,kKt=d=>v2t(d)||typeof d?.[Symbol.iterator]=="function",g2t=`[ -\f\r]`,CU=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,EKt=/-->/g,SKt=/>/g,ZA=RegExp(`>|${g2t}(?:([^\\s"'>=/]+)(${g2t}*=${g2t}*(?:[^ -\f\r"'\`<>=]|("|')|))|$)`,"g"),TKt=/'/g,CKt=/"/g,LKt=/^(?:script|style|textarea|title)$/i,_2t=d=>(s,...h)=>({_$litType$:d,strings:s,values:h}),ek=_2t(1),PJe=_2t(2),IJe=_2t(3),JA=Symbol.for("lit-noChange"),nl=Symbol.for("lit-nothing"),AKt=new WeakMap,YA=KA.createTreeWalker(KA,129);function PKt(d,s){if(!v2t(d)||!d.hasOwnProperty("raw"))throw Error("invalid template strings array");return MKt!==void 0?MKt.createHTML(s):s}var IKt=(d,s)=>{let h=d.length-1,p=[],m,_=s===2?"":s===3?"":"",S=CU;for(let y=0;y"?(S=m??CU,P=-1):B[1]===void 0?P=-2:(P=S.lastIndex-B[2].length,N=B[1],S=B[3]===void 0?ZA:B[3]==='"'?CKt:TKt):S===CKt||S===TKt?S=ZA:S===EKt||S===SKt?S=CU:(S=ZA,m=void 0);let j=S===ZA&&d[y+1].startsWith("/>")?" ":"";_+=S===CU?I+zAe:P>=0?(p.push(N),I.slice(0,P)+b2t+I.slice(P)+t3+j):I+t3+(P===-2?y:j)}return[PKt(d,_+(d[h]||"")+(s===2?"":s===3?"":"")),p]},LU=class d{constructor({strings:s,_$litType$:h},p){let m;this.parts=[];let _=0,S=0,y=s.length-1,I=this.parts,[N,B]=IKt(s,h);if(this.el=d.createElement(N,p),YA.currentNode=this.el.content,h===2||h===3){let P=this.el.content.firstChild;P.replaceWith(...P.childNodes)}for(;(m=YA.nextNode())!==null&&I.length0){m.textContent=Fet?Fet.emptyScript:"";for(let j=0;j2||p[0]!==""||p[1]!==""?(this._$AH=Array(p.length-1).fill(new String),this.strings=p):this._$AH=nl}_$AI(s,h=this,p,m){let _=this.strings,S=!1;if(_===void 0)s=QA(this,s,h,0),S=!kU(s)||s!==this._$AH&&s!==JA,S&&(this._$AH=s);else{let y=s,I,N;for(s=_[0],I=0;I<_.length-1;I++)N=QA(this,y[p+I],h,I),N===JA&&(N=this._$AH[I]),S||=!kU(N)||N!==this._$AH[I],N===nl?s=nl:s!==nl&&(s+=(N??"")+_[I+1]),this._$AH[I]=N}S&&!m&&this.j(s)}j(s){s===nl?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,s??"")}},zet=class extends tk{constructor(){super(...arguments),this.type=3}j(s){this.element[this.name]=s===nl?void 0:s}},jet=class extends tk{constructor(){super(...arguments),this.type=4}j(s){this.element.toggleAttribute(this.name,!!s&&s!==nl)}},Het=class extends tk{constructor(s,h,p,m,_){super(s,h,p,m,_),this.type=5}_$AI(s,h=this){if((s=QA(this,s,h,0)??nl)===JA)return;let p=this._$AH,m=s===nl&&p!==nl||s.capture!==p.capture||s.once!==p.once||s.passive!==p.passive,_=s!==nl&&(p===nl||m);m&&this.element.removeEventListener(this.name,this,p),_&&this.element.addEventListener(this.name,this,s),this._$AH=s}handleEvent(s){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,s):this._$AH.handleEvent(s)}},Get=class{constructor(s,h,p){this.element=s,this.type=6,this._$AN=void 0,this._$AM=h,this.options=p}get _$AU(){return this._$AM._$AU}_$AI(s){QA(this,s)}},RKt={M:b2t,P:t3,A:w2t,C:1,L:IKt,R:Uet,D:kKt,V:QA,I:cR,H:tk,N:jet,U:Het,B:zet,F:Get},jAe=m2t.litHtmlPolyfillSupport;jAe?.(LU,cR),(m2t.litHtmlVersions??=[]).push("3.3.3");var DKt=(d,s,h)=>{let p=h?.renderBefore??s,m=p._$litPart$;if(m===void 0){let _=h?.renderBefore??null;p._$litPart$=m=new cR(s.insertBefore(AU(),_),_,void 0,h??{})}return m._$AI(d),m};var y2t=globalThis,yy=class extends Qx{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let s=super.createRenderRoot();return this.renderOptions.renderBefore??=s.firstChild,s}update(s){let h=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(s),this._$Do=DKt(h,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return JA}};yy._$litElement$=!0,yy.finalized=!0,y2t.litElementHydrateSupport?.({LitElement:yy});var HAe=y2t.litElementPolyfillSupport;HAe?.({LitElement:yy});(y2t.litElementVersions??=[]).push("4.2.2");var{I:VJe}=RKt;var NKt=d=>d.strings===void 0;var OKt={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},x2t=d=>(...s)=>({_$litDirective$:d,values:s}),Wet=class{constructor(s){}get _$AU(){return this._$AM._$AU}_$AT(s,h,p){this._$Ct=s,this._$AM=h,this._$Ci=p}_$AS(s,h){return this.update(s,h)}update(s,h){return this.render(...h)}};var PU=(d,s)=>{let h=d._$AN;if(h===void 0)return!1;for(let p of h)p._$AO?.(s,!1),PU(p,s);return!0},$et=d=>{let s,h;do{if((s=d._$AM)===void 0)break;h=s._$AN,h.delete(d),d=s}while(h?.size===0)},BKt=d=>{for(let s;s=d._$AM;d=s){let h=s._$AN;if(h===void 0)s._$AN=h=new Set;else if(h.has(d))break;h.add(d),$Ae(s)}};function GAe(d){this._$AN!==void 0?($et(this),this._$AM=d,BKt(this)):this._$AM=d}function WAe(d,s=!1,h=0){let p=this._$AH,m=this._$AN;if(m!==void 0&&m.size!==0)if(s)if(Array.isArray(p))for(let _=h;_{d.type==OKt.CHILD&&(d._$AP??=WAe,d._$AQ??=GAe)},Vet=class extends Wet{constructor(){super(...arguments),this._$AN=void 0}_$AT(s,h,p){super._$AT(s,h,p),BKt(this),this.isConnected=s._$AU}_$AO(s,h=!0){s!==this.isConnected&&(this.isConnected=s,s?this.reconnected?.():this.disconnected?.()),h&&(PU(this,s),$et(this))}setValue(s){if(NKt(this._$Ct))this._$Ct._$AI(s,this);else{let h=[...this._$Ct._$AH];h[this._$Ci]=s,this._$Ct._$AI(h,this,0)}}disconnected(){}reconnected(){}};var e3=()=>new E2t,E2t=class{},M2t=new WeakMap,n3=x2t(class extends Vet{render(d){return nl}update(d,[s]){let h=s!==this.G;return h&&this.rt(void 0),(h||this.lt!==this.ct)&&(this.G=s,this.ht=d.options?.host,this.rt(this.ct=d.element)),nl}rt(d){if(this.G!==void 0)if(this.isConnected||(d=void 0),typeof this.G=="function"){let s=this.ht??globalThis,h=M2t.get(s);h===void 0&&(h=new WeakMap,M2t.set(s,h)),h.get(this.G)!==void 0&&this.G.call(this.ht,void 0),h.set(this.G,d),d!==void 0&&this.G.call(this.ht,d)}else this.G.value=d}get lt(){return typeof this.G=="function"?M2t.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});function IU(d,s,h){return d?s(d):h?.(d)}var S2t=d=>d??nl;var T2t=class extends yy{static properties={name:{type:String,reflect:!0},maximizable:{type:Boolean,reflect:!0},collapsible:{type:Boolean,reflect:!0},maximized:{type:Boolean,reflect:!0},collapsed:{type:Boolean,reflect:!0}};constructor(){super(),this.tabsRef=e3(),this.contentRef=e3(),this.headerRef=e3(),this.controlsRef=e3(),this.maximizeBtnRef=e3(),this.collapseBtnRef=e3(),this._onMaximizeClick=this._onMaximizeClick.bind(this),this._onCollapseClick=this._onCollapseClick.bind(this),this._onResetLayoutClick=this._onResetLayoutClick.bind(this)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.classList.add("ide-pane",`ide-pane-${this.paneName}`),this.performUpdate()}get paneName(){return this.name||this.getAttribute("name")||this.id.replace(/^pane-/,"")||"pane"}get tabsEl(){return this.hasUpdated||this.performUpdate(),this.tabsRef.value}get contentEl(){return this.hasUpdated||this.performUpdate(),this.contentRef.value}get headerEl(){return this.hasUpdated||this.performUpdate(),this.headerRef.value}get controlsEl(){return this.hasUpdated||this.performUpdate(),this.controlsRef.value}get maximizeBtn(){return this.hasUpdated||this.performUpdate(),this.maximizeBtnRef.value}get collapseBtn(){return this.hasUpdated||this.performUpdate(),this.collapseBtnRef.value}get _collapseIcon(){let s=this.paneName;return s==="bottom"?this.collapsed?"\u25B2":"\u25BC":s==="left"?this.collapsed?"\u25B6":"\u25C0":s==="right"?this.collapsed?"\u25C0":"\u25B6":"\u25BC"}get _collapseTitle(){let s=this.paneName,h=s.charAt(0).toUpperCase()+s.slice(1);return s==="bottom"?this.collapsed?"Expand Console":"Collapse Console":s==="left"?this.collapsed?"Expand Left Panel":"Collapse Left Panel":s==="right"?this.collapsed?"Expand Right Panel":"Collapse Right Panel":`Collapse ${h}`}_emit(s,h={}){this.dispatchEvent(new CustomEvent(s,{bubbles:!0,composed:!0,detail:h}))}_onMaximizeClick(s){s.stopPropagation(),this._emit("ide-pane-maximize",{pane:this.paneName})}_onCollapseClick(s){s.stopPropagation(),this._emit("ide-pane-collapse",{pane:this.paneName})}_onResetLayoutClick(s){s.stopPropagation(),this._emit("ide-layout-reset")}setMaximized(s){this.maximized=!!s,this.classList.toggle("maximized",this.maximized),this.maximizeBtn&&(this.maximizeBtn.textContent=this.maximized?"\u29C9":"\u2922",this.maximizeBtn.title=this.maximized?"Restore":"Maximize")}setCollapsed(s){this.collapsed=!!s,this.classList.toggle("collapsed",this.collapsed),this.collapseBtn&&(this.collapseBtn.textContent=this._collapseIcon,this.collapseBtn.title=this._collapseTitle)}build(){this.hasUpdated||this.performUpdate()}updated(s){super.updated(s),s.has("maximized")&&this.classList.toggle("maximized",!!this.maximized),s.has("collapsed")&&this.classList.toggle("collapsed",!!this.collapsed)}render(){let s=this.paneName,h=this.id||`pane-${s}`,p=this.maximizable||this.hasAttribute("maximizable"),m=this.collapsible||this.hasAttribute("collapsible");return ek` -
-
-
- ${IU(p,()=>ek` + the output wire straight to it. -->aoi21aoi22aoi211aoi221aoi222aoi33oai21oai22oai211oai221oai222oai33and3nand3or3nor3and4nand4or4nor4`;window.netlistsvg=chn;window.openroadSkin=O2t;window.THREE=p5e;var _he=globalThis,xhe=_he.ShadowRoot&&(_he.ShadyCSS===void 0||_he.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,F2t=Symbol(),N2t=new WeakMap,yhe=class{constructor(n,r,c){if(this._$cssResult$=!0,c!==F2t)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=n,this.t=r}get styleSheet(){let n=this.o,r=this.t;if(xhe&&n===void 0){let c=r!==void 0&&r.length===1;c&&(n=N2t.get(r)),n===void 0&&((this.o=n=new CSSStyleSheet).replaceSync(this.cssText),c&&N2t.set(r,n))}return n}toString(){return this.cssText}},U2t=s=>new yhe(typeof s=="string"?s:s+"",void 0,F2t);var z2t=(s,n)=>{if(xhe)s.adoptedStyleSheets=n.map(r=>r instanceof CSSStyleSheet?r:r.styleSheet);else for(let r of n){let c=document.createElement("style"),u=_he.litNonce;u!==void 0&&c.setAttribute("nonce",u),c.textContent=r.cssText,s.appendChild(c)}},g5e=xhe?s=>s:s=>s instanceof CSSStyleSheet?(n=>{let r="";for(let c of n.cssRules)r+=c.cssText;return U2t(r)})(s):s;var{is:lhn,defineProperty:uhn,getOwnPropertyDescriptor:fhn,getOwnPropertyNames:hhn,getOwnPropertySymbols:dhn,getPrototypeOf:phn}=Object,Ehe=globalThis,G2t=Ehe.trustedTypes,ghn=G2t?G2t.emptyScript:"",mhn=Ehe.reactiveElementPolyfillSupport,$W=(s,n)=>s,m5e={toAttribute(s,n){switch(n){case Boolean:s=s?ghn:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,n){let r=s;switch(n){case Boolean:r=s!==null;break;case Number:r=s===null?null:Number(s);break;case Object:case Array:try{r=JSON.parse(s)}catch{r=null}}return r}},$2t=(s,n)=>!lhn(s,n),j2t={attribute:!0,type:String,converter:m5e,reflect:!1,useDefault:!1,hasChanged:$2t};Symbol.metadata??=Symbol("metadata"),Ehe.litPropertyMetadata??=new WeakMap;var J3=class extends HTMLElement{static addInitializer(n){this._$Ei(),(this.l??=[]).push(n)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(n,r=j2t){if(r.state&&(r.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(n)&&((r=Object.create(r)).wrapped=!0),this.elementProperties.set(n,r),!r.noAccessor){let c=Symbol(),u=this.getPropertyDescriptor(n,c,r);u!==void 0&&uhn(this.prototype,n,u)}}static getPropertyDescriptor(n,r,c){let{get:u,set:d}=fhn(this.prototype,n)??{get(){return this[r]},set(b){this[r]=b}};return{get:u,set(b){let w=u?.call(this);d?.call(this,b),this.requestUpdate(n,w,c)},configurable:!0,enumerable:!0}}static getPropertyOptions(n){return this.elementProperties.get(n)??j2t}static _$Ei(){if(this.hasOwnProperty($W("elementProperties")))return;let n=phn(this);n.finalize(),n.l!==void 0&&(this.l=[...n.l]),this.elementProperties=new Map(n.elementProperties)}static finalize(){if(this.hasOwnProperty($W("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty($W("properties"))){let r=this.properties,c=[...hhn(r),...dhn(r)];for(let u of c)this.createProperty(u,r[u])}let n=this[Symbol.metadata];if(n!==null){let r=litPropertyMetadata.get(n);if(r!==void 0)for(let[c,u]of r)this.elementProperties.set(c,u)}this._$Eh=new Map;for(let[r,c]of this.elementProperties){let u=this._$Eu(r,c);u!==void 0&&this._$Eh.set(u,r)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(n){let r=[];if(Array.isArray(n)){let c=new Set(n.flat(1/0).reverse());for(let u of c)r.unshift(g5e(u))}else n!==void 0&&r.push(g5e(n));return r}static _$Eu(n,r){let c=r.attribute;return c===!1?void 0:typeof c=="string"?c:typeof n=="string"?n.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(n=>this.enableUpdating=n),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(n=>n(this))}addController(n){(this._$EO??=new Set).add(n),this.renderRoot!==void 0&&this.isConnected&&n.hostConnected?.()}removeController(n){this._$EO?.delete(n)}_$E_(){let n=new Map,r=this.constructor.elementProperties;for(let c of r.keys())this.hasOwnProperty(c)&&(n.set(c,this[c]),delete this[c]);n.size>0&&(this._$Ep=n)}createRenderRoot(){let n=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return z2t(n,this.constructor.elementStyles),n}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(n=>n.hostConnected?.())}enableUpdating(n){}disconnectedCallback(){this._$EO?.forEach(n=>n.hostDisconnected?.())}attributeChangedCallback(n,r,c){this._$AK(n,c)}_$ET(n,r){let c=this.constructor.elementProperties.get(n),u=this.constructor._$Eu(n,c);if(u!==void 0&&c.reflect===!0){let d=(c.converter?.toAttribute!==void 0?c.converter:m5e).toAttribute(r,c.type);this._$Em=n,d==null?this.removeAttribute(u):this.setAttribute(u,d),this._$Em=null}}_$AK(n,r){let c=this.constructor,u=c._$Eh.get(n);if(u!==void 0&&this._$Em!==u){let d=c.getPropertyOptions(u),b=typeof d.converter=="function"?{fromAttribute:d.converter}:d.converter?.fromAttribute!==void 0?d.converter:m5e;this._$Em=u;let w=b.fromAttribute(r,d.type);this[u]=w??this._$Ej?.get(u)??w,this._$Em=null}}requestUpdate(n,r,c,u=!1,d){if(n!==void 0){let b=this.constructor;if(u===!1&&(d=this[n]),c??=b.getPropertyOptions(n),!((c.hasChanged??$2t)(d,r)||c.useDefault&&c.reflect&&d===this._$Ej?.get(n)&&!this.hasAttribute(b._$Eu(n,c))))return;this.C(n,r,c)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(n,r,{useDefault:c,reflect:u,wrapped:d},b){c&&!(this._$Ej??=new Map).has(n)&&(this._$Ej.set(n,b??r??this[n]),d!==!0||b!==void 0)||(this._$AL.has(n)||(this.hasUpdated||c||(r=void 0),this._$AL.set(n,r)),u===!0&&this._$Em!==n&&(this._$Eq??=new Set).add(n))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(r){Promise.reject(r)}let n=this.scheduleUpdate();return n!=null&&await n,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[u,d]of this._$Ep)this[u]=d;this._$Ep=void 0}let c=this.constructor.elementProperties;if(c.size>0)for(let[u,d]of c){let{wrapped:b}=d,w=this[u];b!==!0||this._$AL.has(u)||w===void 0||this.C(u,void 0,d,w)}}let n=!1,r=this._$AL;try{n=this.shouldUpdate(r),n?(this.willUpdate(r),this._$EO?.forEach(c=>c.hostUpdate?.()),this.update(r)):this._$EM()}catch(c){throw n=!1,this._$EM(),c}n&&this._$AE(r)}willUpdate(n){}_$AE(n){this._$EO?.forEach(r=>r.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(n)),this.updated(n)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(n){return!0}update(n){this._$Eq&&=this._$Eq.forEach(r=>this._$ET(r,this[r])),this._$EM()}updated(n){}firstUpdated(n){}};J3.elementStyles=[],J3.shadowRootOptions={mode:"open"},J3[$W("elementProperties")]=new Map,J3[$W("finalized")]=new Map,mhn?.({ReactiveElement:J3}),(Ehe.reactiveElementVersions??=[]).push("2.1.2");var w5e=globalThis,V2t=s=>s,She=w5e.trustedTypes,W2t=She?She.createPolicy("lit-html",{createHTML:s=>s}):void 0,v5e="$lit$",Q3=`lit$${Math.random().toFixed(9).slice(2)}$`,_5e="?"+Q3,bhn=`<${_5e}>`,Q4=document,WW=()=>Q4.createComment(""),HW=s=>s===null||typeof s!="object"&&typeof s!="function",y5e=Array.isArray,K2t=s=>y5e(s)||typeof s?.[Symbol.iterator]=="function",b5e=`[ +\f\r]`,VW=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,H2t=/-->/g,q2t=/>/g,K4=RegExp(`>|${b5e}(?:([^\\s"'>=/]+)(${b5e}*=${b5e}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`,"g"),X2t=/'/g,Y2t=/"/g,J2t=/^(?:script|style|textarea|title)$/i,x5e=s=>(n,...r)=>({_$litType$:s,strings:n,values:r}),ik=x5e(1),rci=x5e(2),sci=x5e(3),ek=Symbol.for("lit-noChange"),eu=Symbol.for("lit-nothing"),Z2t=new WeakMap,J4=Q4.createTreeWalker(Q4,129);function Q2t(s,n){if(!y5e(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return W2t!==void 0?W2t.createHTML(n):n}var ext=(s,n)=>{let r=s.length-1,c=[],u,d=n===2?"":n===3?"":"",b=VW;for(let w=0;w"?(b=u??VW,M=-1):T[1]===void 0?M=-2:(M=b.lastIndex-T[2].length,x=T[1],b=T[3]===void 0?K4:T[3]==='"'?Y2t:X2t):b===Y2t||b===X2t?b=K4:b===H2t||b===q2t?b=VW:(b=K4,u=void 0);let I=b===K4&&s[w+1].startsWith("/>")?" ":"";d+=b===VW?_+bhn:M>=0?(c.push(x),_.slice(0,M)+v5e+_.slice(M)+Q3+I):_+Q3+(M===-2?w:I)}return[Q2t(s,d+(s[r]||"")+(n===2?"":n===3?"":"")),c]},qW=class s{constructor({strings:n,_$litType$:r},c){let u;this.parts=[];let d=0,b=0,w=n.length-1,_=this.parts,[x,T]=ext(n,r);if(this.el=s.createElement(x,c),J4.currentNode=this.el.content,r===2||r===3){let M=this.el.content.firstChild;M.replaceWith(...M.childNodes)}for(;(u=J4.nextNode())!==null&&_.length0){u.textContent=She?She.emptyScript:"";for(let I=0;I2||c[0]!==""||c[1]!==""?(this._$AH=Array(c.length-1).fill(new String),this.strings=c):this._$AH=eu}_$AI(n,r=this,c,u){let d=this.strings,b=!1;if(d===void 0)n=tk(this,n,r,0),b=!HW(n)||n!==this._$AH&&n!==ek,b&&(this._$AH=n);else{let w=n,_,x;for(n=d[0],_=0;_{let c=r?.renderBefore??n,u=c._$litPart$;if(u===void 0){let d=r?.renderBefore??null;c._$litPart$=u=new bO(n.insertBefore(WW(),d),d,void 0,r??{})}return u._$AI(s),u};var E5e=globalThis,p2=class extends J3{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let n=super.createRenderRoot();return this.renderOptions.renderBefore??=n.firstChild,n}update(n){let r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(n),this._$Do=nxt(r,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return ek}};p2._$litElement$=!0,p2.finalized=!0,E5e.litElementHydrateSupport?.({LitElement:p2});var vhn=E5e.litElementPolyfillSupport;vhn?.({LitElement:p2});(E5e.litElementVersions??=[]).push("4.2.2");var{I:vci}=txt;var ixt=s=>s.strings===void 0;var rxt={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},S5e=s=>(...n)=>({_$litDirective$:s,values:n}),Lhe=class{constructor(n){}get _$AU(){return this._$AM._$AU}_$AT(n,r,c){this._$Ct=n,this._$AM=r,this._$Ci=c}_$AS(n,r){return this.update(n,r)}update(n,r){return this.render(...r)}};var XW=(s,n)=>{let r=s._$AN;if(r===void 0)return!1;for(let c of r)c._$AO?.(n,!1),XW(c,n);return!0},khe=s=>{let n,r;do{if((n=s._$AM)===void 0)break;r=n._$AN,r.delete(s),s=n}while(r?.size===0)},sxt=s=>{for(let n;n=s._$AM;s=n){let r=n._$AN;if(r===void 0)n._$AN=r=new Set;else if(r.has(s))break;r.add(s),xhn(n)}};function _hn(s){this._$AN!==void 0?(khe(this),this._$AM=s,sxt(this)):this._$AM=s}function yhn(s,n=!1,r=0){let c=this._$AH,u=this._$AN;if(u!==void 0&&u.size!==0)if(n)if(Array.isArray(c))for(let d=r;d{s.type==rxt.CHILD&&(s._$AP??=yhn,s._$AQ??=_hn)},Rhe=class extends Lhe{constructor(){super(...arguments),this._$AN=void 0}_$AT(n,r,c){super._$AT(n,r,c),sxt(this),this.isConnected=n._$AU}_$AO(n,r=!0){n!==this.isConnected&&(this.isConnected=n,n?this.reconnected?.():this.disconnected?.()),r&&(XW(this,n),khe(this))}setValue(n){if(ixt(this._$Ct))this._$Ct._$AI(n,this);else{let r=[...this._$Ct._$AH];r[this._$Ci]=n,this._$Ct._$AI(r,this,0)}}disconnected(){}reconnected(){}};var eE=()=>new T5e,T5e=class{},M5e=new WeakMap,tE=S5e(class extends Rhe{render(s){return eu}update(s,[n]){let r=n!==this.G;return r&&this.rt(void 0),(r||this.lt!==this.ct)&&(this.G=n,this.ht=s.options?.host,this.rt(this.ct=s.element)),eu}rt(s){if(this.G!==void 0)if(this.isConnected||(s=void 0),typeof this.G=="function"){let n=this.ht??globalThis,r=M5e.get(n);r===void 0&&(r=new WeakMap,M5e.set(n,r)),r.get(this.G)!==void 0&&this.G.call(this.ht,void 0),r.set(this.G,s),s!==void 0&&this.G.call(this.ht,s)}else this.G.value=s}get lt(){return typeof this.G=="function"?M5e.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});function YW(s,n,r){return s?n(s):r?.(s)}var C5e=s=>s??eu;var A5e=class extends p2{static properties={name:{type:String,reflect:!0},maximizable:{type:Boolean,reflect:!0},collapsible:{type:Boolean,reflect:!0},maximized:{type:Boolean,reflect:!0},collapsed:{type:Boolean,reflect:!0}};constructor(){super(),this.tabsRef=eE(),this.contentRef=eE(),this.headerRef=eE(),this.controlsRef=eE(),this.maximizeBtnRef=eE(),this.collapseBtnRef=eE(),this._onMaximizeClick=this._onMaximizeClick.bind(this),this._onCollapseClick=this._onCollapseClick.bind(this),this._onResetLayoutClick=this._onResetLayoutClick.bind(this)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.classList.add("ide-pane",`ide-pane-${this.paneName}`),this.performUpdate()}get paneName(){return this.name||this.getAttribute("name")||this.id.replace(/^pane-/,"")||"pane"}get tabsEl(){return this.hasUpdated||this.performUpdate(),this.tabsRef.value}get contentEl(){return this.hasUpdated||this.performUpdate(),this.contentRef.value}get headerEl(){return this.hasUpdated||this.performUpdate(),this.headerRef.value}get controlsEl(){return this.hasUpdated||this.performUpdate(),this.controlsRef.value}get maximizeBtn(){return this.hasUpdated||this.performUpdate(),this.maximizeBtnRef.value}get collapseBtn(){return this.hasUpdated||this.performUpdate(),this.collapseBtnRef.value}get _collapseIcon(){let n=this.paneName;return n==="bottom"?this.collapsed?"\u25B2":"\u25BC":n==="left"?this.collapsed?"\u25B6":"\u25C0":n==="right"?this.collapsed?"\u25C0":"\u25B6":"\u25BC"}get _collapseTitle(){let n=this.paneName,r=n.charAt(0).toUpperCase()+n.slice(1);return n==="bottom"?this.collapsed?"Expand Console":"Collapse Console":n==="left"?this.collapsed?"Expand Left Panel":"Collapse Left Panel":n==="right"?this.collapsed?"Expand Right Panel":"Collapse Right Panel":`Collapse ${r}`}_emit(n,r={}){this.dispatchEvent(new CustomEvent(n,{bubbles:!0,composed:!0,detail:r}))}_onMaximizeClick(n){n.stopPropagation(),this._emit("ide-pane-maximize",{pane:this.paneName})}_onCollapseClick(n){n.stopPropagation(),this._emit("ide-pane-collapse",{pane:this.paneName})}_onResetLayoutClick(n){n.stopPropagation(),this._emit("ide-layout-reset")}setMaximized(n){this.maximized=!!n,this.classList.toggle("maximized",this.maximized),this.maximizeBtn&&(this.maximizeBtn.textContent=this.maximized?"\u29C9":"\u2922",this.maximizeBtn.title=this.maximized?"Restore":"Maximize")}setCollapsed(n){this.collapsed=!!n,this.classList.toggle("collapsed",this.collapsed),this.collapseBtn&&(this.collapseBtn.textContent=this._collapseIcon,this.collapseBtn.title=this._collapseTitle)}build(){this.hasUpdated||this.performUpdate()}updated(n){super.updated(n),n.has("maximized")&&this.classList.toggle("maximized",!!this.maximized),n.has("collapsed")&&this.classList.toggle("collapsed",!!this.collapsed)}render(){let n=this.paneName,r=this.id||`pane-${n}`,c=this.maximizable||this.hasAttribute("maximizable"),u=this.collapsible||this.hasAttribute("collapsible");return ik` +
+
+
+ ${YW(c,()=>ik` `)} - ${IU(m,()=>ek` + ${YW(u,()=>ik` `)}
-
- ${IU(s==="main",()=>ek` +
+ ${YW(n==="main",()=>ik` `)}
- `}},C2t=class{constructor(s,h={}){(this.host=s).addController(this),this.options=h,this._abort=null,this.isDragging=!1,this.startPos=0}hostDisconnected(){this.stop()}start(s,h=!0){s.preventDefault();try{this.host.setPointerCapture(s.pointerId)}catch{}this.isDragging=!0,this.host.classList.add("dragging"),document.body&&document.body.classList.add("is-resizing",h?"is-resizing-v":"is-resizing-h"),this.startPos=h?s.clientX:s.clientY,this.options.onStart?.({startPos:this.startPos,event:s}),this._abort=new AbortController;let{signal:p}=this._abort;window.addEventListener("pointermove",_=>{let S=h?_.clientX:_.clientY,y=S-this.startPos;this.options.onDrag?.({delta:y,currentPos:S,startPos:this.startPos,event:_})},{signal:p});let m=_=>{try{this.host.releasePointerCapture(s.pointerId)}catch{}this.stop(h),this.options.onEnd?.({event:_})};window.addEventListener("pointerup",m,{signal:p}),window.addEventListener("pointercancel",m,{signal:p})}stop(s=!0){this.isDragging&&(this.isDragging=!1,this.host.classList.remove("dragging"),document.body&&document.body.classList.remove("is-resizing","is-resizing-v","is-resizing-h"),this._abort?.abort(),this._abort=null)}},Xet=class extends yy{static properties={for:{type:String},orientation:{type:String,reflect:!0}};constructor(){super(),this.orientation="vertical",this._connectedAbort=null,this.drag=new C2t(this,{onStart:({startPos:s})=>this._emit("start",{startPos:s}),onDrag:({delta:s,currentPos:h,startPos:p})=>this._emit("drag",{delta:s,currentPos:h,startPos:p}),onEnd:()=>this._emit("end")})}connectedCallback(){super.connectedCallback(),this._connectedAbort=new AbortController;let{signal:s}=this._connectedAbort;this.setAttribute("role","separator"),this.classList.add("ide-splitter"),this.performUpdate(),this.addEventListener("pointerdown",h=>this.drag.start(h,this.isVertical),{signal:s}),this.addEventListener("dblclick",()=>this._emit("reset"),{signal:s})}disconnectedCallback(){super.disconnectedCallback(),this._connectedAbort?.abort()}build(){}updated(s){super.updated(s);let h=this.isVertical;this.setAttribute("aria-orientation",h?"vertical":"horizontal"),this.classList.toggle("ide-splitter-v",h),this.classList.toggle("ide-splitter-h",!h)}get targetPane(){return this.for||this.getAttribute("for")||""}get isVertical(){return(this.orientation||this.getAttribute("orientation")||"vertical")==="vertical"}_emit(s,h={}){this.dispatchEvent(new CustomEvent(`ide-splitter-${s}`,{bubbles:!0,composed:!0,detail:{for:this.targetPane,orientation:this.isVertical?"vertical":"horizontal",...h}}))}},A2t=class extends yy{static properties={title:{type:String,reflect:!0},closable:{type:Boolean,reflect:!0},for:{type:String},active:{type:Boolean,reflect:!0}};constructor(){super(),this._connectedAbort=null,this.titleRef=e3(),this.closeBtnRef=e3(),this._onClick=this._onClick.bind(this),this._onCloseClick=this._onCloseClick.bind(this)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this._connectedAbort=new AbortController;let{signal:s}=this._connectedAbort;this.classList.add("ide-tab","lm_tab"),this.setAttribute("role","tab"),this.hasAttribute("aria-selected")||this.setAttribute("aria-selected","false"),this.addEventListener("click",this._onClick,{signal:s}),this.performUpdate()}disconnectedCallback(){super.disconnectedCallback(),this._connectedAbort?.abort()}_emit(s,h={}){this.dispatchEvent(new CustomEvent(s,{bubbles:!0,composed:!0,detail:h}))}_onClick(s){s&&s.target&&s.target.closest(".ide-tab-close")||this._emit("tab-select",{componentType:this.targetComponent})}_onCloseClick(s){s.stopPropagation(),this._emit("tab-close",{componentType:this.targetComponent})}get targetComponent(){return this.for||this.getAttribute("for")||this.getAttribute("data-component")||this.id.replace(/^tab-/,"")||""}get titleText(){return this.title||""}set titleText(s){this.title=s}get titleEl(){return this.hasUpdated||this.performUpdate(),this.titleRef.value}get closeBtn(){return this.hasUpdated||this.performUpdate(),this.closeBtnRef.value}setActive(s){this.active=!!s,this.performUpdate()}updated(s){super.updated(s),s.has("active")&&(this.classList.toggle("active",this.active),this.classList.toggle("lm_active",this.active),this.setAttribute("aria-selected",this.active?"true":"false"))}render(){let s=this.title||"",h=!!this.closable;return ek` - ${s} - ${IU(h,()=>ek` + `}},P5e=class{constructor(n,r={}){(this.host=n).addController(this),this.options=r,this._abort=null,this.isDragging=!1,this.startPos=0}hostDisconnected(){this.stop()}start(n,r=!0){n.preventDefault();try{this.host.setPointerCapture(n.pointerId)}catch{}this.isDragging=!0,this.host.classList.add("dragging"),document.body&&document.body.classList.add("is-resizing",r?"is-resizing-v":"is-resizing-h"),this.startPos=r?n.clientX:n.clientY,this.options.onStart?.({startPos:this.startPos,event:n}),this._abort=new AbortController;let{signal:c}=this._abort;window.addEventListener("pointermove",d=>{let b=r?d.clientX:d.clientY,w=b-this.startPos;this.options.onDrag?.({delta:w,currentPos:b,startPos:this.startPos,event:d})},{signal:c});let u=d=>{try{this.host.releasePointerCapture(n.pointerId)}catch{}this.stop(r),this.options.onEnd?.({event:d})};window.addEventListener("pointerup",u,{signal:c}),window.addEventListener("pointercancel",u,{signal:c})}stop(n=!0){this.isDragging&&(this.isDragging=!1,this.host.classList.remove("dragging"),document.body&&document.body.classList.remove("is-resizing","is-resizing-v","is-resizing-h"),this._abort?.abort(),this._abort=null)}},Dhe=class extends p2{static properties={for:{type:String},orientation:{type:String,reflect:!0}};constructor(){super(),this.orientation="vertical",this._connectedAbort=null,this.drag=new P5e(this,{onStart:({startPos:n})=>this._emit("start",{startPos:n}),onDrag:({delta:n,currentPos:r,startPos:c})=>this._emit("drag",{delta:n,currentPos:r,startPos:c}),onEnd:()=>this._emit("end")})}connectedCallback(){super.connectedCallback(),this._connectedAbort=new AbortController;let{signal:n}=this._connectedAbort;this.setAttribute("role","separator"),this.classList.add("ide-splitter"),this.performUpdate(),this.addEventListener("pointerdown",r=>this.drag.start(r,this.isVertical),{signal:n}),this.addEventListener("dblclick",()=>this._emit("reset"),{signal:n})}disconnectedCallback(){super.disconnectedCallback(),this._connectedAbort?.abort()}build(){}updated(n){super.updated(n);let r=this.isVertical;this.setAttribute("aria-orientation",r?"vertical":"horizontal"),this.classList.toggle("ide-splitter-v",r),this.classList.toggle("ide-splitter-h",!r)}get targetPane(){return this.for||this.getAttribute("for")||""}get isVertical(){return(this.orientation||this.getAttribute("orientation")||"vertical")==="vertical"}_emit(n,r={}){this.dispatchEvent(new CustomEvent(`ide-splitter-${n}`,{bubbles:!0,composed:!0,detail:{for:this.targetPane,orientation:this.isVertical?"vertical":"horizontal",...r}}))}},L5e=class extends p2{static properties={title:{type:String,reflect:!0},closable:{type:Boolean,reflect:!0},for:{type:String},active:{type:Boolean,reflect:!0}};constructor(){super(),this._connectedAbort=null,this.titleRef=eE(),this.closeBtnRef=eE(),this._onClick=this._onClick.bind(this),this._onCloseClick=this._onCloseClick.bind(this)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this._connectedAbort=new AbortController;let{signal:n}=this._connectedAbort;this.classList.add("ide-tab","lm_tab"),this.setAttribute("role","tab"),this.hasAttribute("aria-selected")||this.setAttribute("aria-selected","false"),this.addEventListener("click",this._onClick,{signal:n}),this.performUpdate()}disconnectedCallback(){super.disconnectedCallback(),this._connectedAbort?.abort()}_emit(n,r={}){this.dispatchEvent(new CustomEvent(n,{bubbles:!0,composed:!0,detail:r}))}_onClick(n){n&&n.target&&n.target.closest(".ide-tab-close")||this._emit("tab-select",{componentType:this.targetComponent})}_onCloseClick(n){n.stopPropagation(),this._emit("tab-close",{componentType:this.targetComponent})}get targetComponent(){return this.for||this.getAttribute("for")||this.getAttribute("data-component")||this.id.replace(/^tab-/,"")||""}get titleText(){return this.title||""}set titleText(n){this.title=n}get titleEl(){return this.hasUpdated||this.performUpdate(),this.titleRef.value}get closeBtn(){return this.hasUpdated||this.performUpdate(),this.closeBtnRef.value}setActive(n){this.active=!!n,this.performUpdate()}updated(n){super.updated(n),n.has("active")&&(this.classList.toggle("active",this.active),this.classList.toggle("lm_active",this.active),this.setAttribute("aria-selected",this.active?"true":"false"))}render(){let n=this.title||"",r=!!this.closable;return ik` + ${n} + ${YW(r,()=>ik` ✕ `)} - `}};customElements.get("ide-pane")||customElements.define("ide-pane",T2t);customElements.get("ide-splitter")||customElements.define("ide-splitter",Xet);customElements.get("ide-tab")||customElements.define("ide-tab",A2t);var FKt={DisplayControls:{pane:"left",title:"Display Controls",closable:!1},LayoutViewer:{pane:"main",title:"Layout",closable:!1},SchematicWidget:{pane:"main",title:"Schematic",closable:!0},"3DViewer":{pane:"main",title:"3D Viewer",closable:!0},TclConsole:{pane:"bottom",title:"Tcl Console",closable:!1},Inspector:{pane:"right",title:"Inspector",closable:!0},Browser:{pane:"right",title:"Hierarchy",closable:!0},TimingWidget:{pane:"right",title:"Timing",closable:!0},DRCWidget:{pane:"right",title:"DRC",closable:!0},SelectHighlight:{pane:"right",title:"Select Highlight",closable:!0},ClockWidget:{pane:"right",title:"Clock Tree",closable:!0},ChartsWidget:{pane:"right",title:"Charts",closable:!0},HelpWidget:{pane:"right",title:"Help",closable:!0}},qet={left:{cssVar:"--pane-left-width",defaultSize:"240px",minSize:140,maxFraction:.45,dimension:"width",isVertical:!0,invertDelta:!1},right:{cssVar:"--pane-right-width",defaultSize:"340px",minSize:160,maxFraction:.5,dimension:"width",isVertical:!0,invertDelta:!0},bottom:{cssVar:"--pane-bottom-height",defaultSize:"220px",minSize:70,maxFraction:.75,dimension:"height",isVertical:!1,invertDelta:!0}},Zet=class{constructor(s){this.containerEl=s,this.factories=new Map,this.components=new Map,this.activeTabs={left:null,main:null,bottom:null,right:null},this.closedComponents=new Set,this.eventListeners=new Map,this._resizeScheduled=!1,this._ensureDOM(),this._initSplitters(),this._initControls(),this._initResizeObserver()}on(s,h){this.eventListeners.has(s)||this.eventListeners.set(s,new Set),this.eventListeners.get(s).add(h)}off(s,h){this.eventListeners.get(s)?.delete(h)}emit(s,...h){let p=this.eventListeners.get(s);if(p)for(let m of p)try{m(...h)}catch(_){console.error(_)}}_ensureDOM(){this.containerEl.classList.add("ide-layout"),this.containerEl.querySelector("#pane-left")||this._buildInitialLayoutTree(),this._resolvePaneReferences()}_buildInitialLayoutTree(){this.containerEl.appendChild(this._createGutterButton("left","\u25B6 Display Controls","Restore Display Controls")),this.containerEl.appendChild(this._createGutterButton("right","\u25C0 Tools & Inspector","Restore Right Panel")),this.containerEl.appendChild(this._createPane("pane-left","left")),this.containerEl.appendChild(this._createSplitter("splitter-left","left","vertical","Drag to resize panel"));let s=document.createElement("main");s.id="pane-center",s.className="ide-center",s.appendChild(this._createPane("pane-main","main",{maximizable:!0})),s.appendChild(this._createSplitter("splitter-bottom","bottom","horizontal","Drag to resize console")),s.appendChild(this._createGutterButton("bottom","\u25B2 Tcl Console","Restore Tcl Console")),s.appendChild(this._createPane("pane-bottom","bottom",{maximizable:!0,collapsible:!0})),this.containerEl.appendChild(s),this.containerEl.appendChild(this._createSplitter("splitter-right","right","vertical","Drag to resize panel")),this.containerEl.appendChild(this._createPane("pane-right","right",{maximizable:!0,collapsible:!0}))}_createGutterButton(s,h,p){let m=document.createElement("button");m.id=`gutter-expand-${s}`,m.className=`ide-gutter-expand ide-gutter-${s}`,m.title=p;let _=document.createElement("span");return _.textContent=h,m.appendChild(_),m}_createPane(s,h,p={}){let m=document.createElement("ide-pane");return m.id=s,m.setAttribute("name",h),p.maximizable&&m.setAttribute("maximizable",""),p.collapsible&&m.setAttribute("collapsible",""),m}_createSplitter(s,h,p,m){let _=document.createElement("ide-splitter");return _.id=s,_.setAttribute("for",h),_.setAttribute("orientation",p),_.title=m,_}_resolvePaneReferences(){let s=["left","main","bottom","right"];this.panes={};for(let h of s){let p=this.containerEl.querySelector(`#pane-${h}`);p?.build&&p.build(),this.panes[h]={el:p,paneComponent:p,tabsEl:p?.tabsEl||this.containerEl.querySelector(`#pane-${h}-tabs`),contentEl:p?.contentEl||this.containerEl.querySelector(`#pane-${h}-content`)}}this.centerEl=this.containerEl.querySelector("#pane-center")}_initSplitters(){let s=null;this.containerEl.addEventListener("ide-splitter-start",h=>{let p=h.detail?.for,m=qet[p];if(!m)return;let S=(p==="bottom"?this.centerEl||this.containerEl:this.containerEl).getBoundingClientRect(),y=this.panes[p]?.el?.getBoundingClientRect()||{},I=m.dimension==="width"?S.width:S.height,N=m.dimension==="width"?y.width||240:y.height||220;s={paneName:p,cfg:m,startSize:N,maxLimit:Math.round(I*m.maxFraction)||500}}),this.containerEl.addEventListener("ide-splitter-drag",h=>{if(!s||s.paneName!==h.detail?.for)return;let{cfg:p,startSize:m,maxLimit:_}=s,S=p.invertDelta?-h.detail.delta:h.detail.delta,y=Math.round(m+S),I=Math.max(p.minSize,Math.min(_,y));this.containerEl.style.setProperty(p.cssVar,`${I}px`),this.notifyResize()}),this.containerEl.addEventListener("ide-splitter-end",()=>{s=null,this.saveLayout(),this.notifyResize()}),this.containerEl.addEventListener("ide-splitter-reset",h=>{let p=h.detail?.for;this._resetSplitterPane(p)}),this._setupFallbackSplitters()}_resetSplitterPane(s){let h=qet[s];h&&(this.containerEl.style.setProperty(h.cssVar,h.defaultSize),this.isPaneCollapsed(s)?this.restorePane(s):(this.saveLayout(),this.notifyResize()))}_setupFallbackSplitters(){for(let[s,h]of Object.entries(qet)){let p=this.containerEl.querySelector(`#splitter-${s}`);if(!p||p instanceof Xet)continue;let m=!h.invertDelta,_=h.isVertical;p.addEventListener("pointerdown",S=>{S.preventDefault();try{p.setPointerCapture(S.pointerId)}catch{}p.classList.add("dragging"),document.body&&document.body.classList.add("is-resizing",_?"is-resizing-v":"is-resizing-h");let y=_?S.clientX:S.clientY,N=(s==="bottom"?this.centerEl||this.containerEl:this.containerEl).getBoundingClientRect(),B=this.panes[s]?.el?.getBoundingClientRect()||{},P=h.dimension==="width"?B.width||240:B.height||220,U=h.dimension==="width"?N.width:N.height,j=Math.round(U*h.maxFraction)||500,V=new AbortController,{signal:et}=V,Q=gt=>{let ft=_?gt.clientX:gt.clientY,xt=m?ft-y:y-ft,Bt=Math.round(P+xt),Dt=Math.max(h.minSize,Math.min(j,Bt));this.containerEl.style.setProperty(h.cssVar,`${Dt}px`),this.notifyResize()},X=gt=>{try{p.releasePointerCapture(gt.pointerId)}catch{}p.classList.remove("dragging"),document.body&&document.body.classList.remove("is-resizing","is-resizing-v","is-resizing-h"),V.abort(),this.saveLayout(),this.notifyResize()};window.addEventListener("pointermove",Q,{signal:et}),window.addEventListener("pointerup",X,{signal:et}),window.addEventListener("pointercancel",X,{signal:et})}),p.addEventListener("dblclick",()=>{this._resetSplitterPane(s)})}}_initControls(){this.containerEl.addEventListener("ide-pane-maximize",h=>{this.toggleMaximize(h.detail?.pane)}),this.containerEl.addEventListener("ide-pane-collapse",h=>{this.toggleCollapse(h.detail?.pane)}),this.containerEl.addEventListener("ide-layout-reset",()=>{this.resetLayout()});for(let h of["left","right","bottom"]){let p=this.containerEl.querySelector(`#gutter-expand-${h}`);p&&p.addEventListener("click",()=>this.restorePane(h))}let s=[{sel:"#btn-collapse-left",handler:()=>this.toggleCollapse("left")},{sel:"#btn-collapse-right",handler:()=>this.toggleCollapse("right")},{sel:"#btn-collapse-bottom",handler:()=>this.toggleCollapse("bottom")},{sel:"#btn-maximize-main",handler:()=>this.toggleMaximize("main")},{sel:"#btn-maximize-bottom",handler:()=>this.toggleMaximize("bottom")},{sel:"#btn-maximize-right",handler:()=>this.toggleMaximize("right")},{sel:"#btn-empty-reset-layout",handler:()=>this.resetLayout()}];for(let{sel:h,handler:p}of s){let m=this.containerEl.querySelector(h);m&&!m.closest("ide-pane")&&m.addEventListener("click",p)}}isPaneMaximized(s){return s?this.containerEl.classList.contains(`maximized-${s}`):this.containerEl.classList.contains("maximized-main")||this.containerEl.classList.contains("maximized-bottom")||this.containerEl.classList.contains("maximized-right")}setMaximizedPane(s,h=!0){let p=["main","bottom","right"];if(s&&!p.includes(s))return!1;let m=h?s:null;for(let _ of p){let S=_===m;this.containerEl.classList.toggle(`maximized-${_}`,S),this.panes[_]?.paneComponent?.setMaximized(S);let y=this.containerEl.querySelector(`#btn-maximize-${_}`);y&&(y.textContent=S?"\u29C9":"\u2922",y.title=S?"Restore":"Maximize")}return this.notifyResize(),!!m}maximizePane(s){return this.setMaximizedPane(s,!0)}restoreMaximized(){return this.setMaximizedPane(null,!1)}toggleMaximize(s){return this.setMaximizedPane(s,!this.isPaneMaximized(s))}isPaneCollapsed(s){let h=s==="bottom"?this.centerEl:this.containerEl;return h?h.classList.contains(`hide-${s}`):!1}_setPaneCollapsed(s,h){let p=s==="bottom"?this.centerEl:this.containerEl;if(!p)return;p.classList.toggle(`hide-${s}`,h),this.panes[s]?.paneComponent?.setCollapsed?.(h);let m=this.containerEl.querySelector(`#btn-collapse-${s}`);if(m){let S={bottom:{collapsed:"\u25B2",expanded:"\u25BC"},left:{collapsed:"\u25B6",expanded:"\u25C0"},right:{collapsed:"\u25C0",expanded:"\u25B6"}}[s]||{collapsed:"\u25B6",expanded:"\u25C0"};m.textContent=h?S.collapsed:S.expanded,m.title=h?`Expand ${s.charAt(0).toUpperCase()+s.slice(1)}`:`Collapse ${s.charAt(0).toUpperCase()+s.slice(1)}`}this.saveLayout(),this.notifyResize()}toggleCollapse(s){this._setPaneCollapsed(s,!this.isPaneCollapsed(s))}collapsePane(s){this._setPaneCollapsed(s,!0)}restorePane(s){this._setPaneCollapsed(s,!1)}_updateEmptyState(){let s=this.containerEl.querySelector("#ide-empty-state");if(!s)return;let h=!!this.activeTabs.main;s.style.display=h?"none":"flex"}resetLayout(){try{localStorage.removeItem("or_ide_layout")}catch{}for(let[s,h]of Object.entries(qet))this.containerEl.style.setProperty(h.cssVar,h.defaultSize);for(let s of["left","right","bottom"])this.restorePane(s);this.restoreMaximized(),this.closedComponents.clear();for(let s of this.components.values())s.tabEl.style.display="",s.contentDiv.style.display="";this.components.has("DisplayControls")&&this.activateTab("DisplayControls"),this.components.has("LayoutViewer")&&this.activateTab("LayoutViewer"),this.components.has("TclConsole")&&this.activateTab("TclConsole"),this.components.has("Inspector")&&this.activateTab("Inspector"),this._updateEmptyState(),this.saveLayout(),this.notifyResize(),this.emit("stateChanged"),typeof app<"u"&&app.map&&setTimeout(()=>app.map.invalidateSize({animate:!1}),0)}_initResizeObserver(){typeof ResizeObserver<"u"&&new ResizeObserver(()=>{this.notifyResize()}).observe(this.containerEl)}registerComponentFactoryFunction(s,h){this.factories.set(s,h)}loadLayout(s){for(let[p,m]of Object.entries(FKt)){let _=this.factories.get(p);_&&this._mountComponent(p,m.pane,m.title,m.closable,_)}let h=null;try{let p=localStorage.getItem("or_ide_layout");p&&(h=JSON.parse(p))}catch{}if(h){if(h.leftWidth&&this.containerEl.style.setProperty("--pane-left-width",`${h.leftWidth}px`),h.rightWidth&&this.containerEl.style.setProperty("--pane-right-width",`${h.rightWidth}px`),h.bottomHeight&&this.containerEl.style.setProperty("--pane-bottom-height",`${h.bottomHeight}px`),h.closed)for(let p of h.closed)this.closeComponent(p,!1);this.activateTab(h.activeTabs?.left||"DisplayControls"),this.activateTab(h.activeTabs?.main||"LayoutViewer"),this.activateTab(h.activeTabs?.bottom||"TclConsole"),this.activateTab(h.activeTabs?.right||"Inspector"),h.hideLeft&&this.collapsePane("left"),h.hideRight&&this.collapsePane("right"),h.hideBottom&&this.collapsePane("bottom")}else this.activateTab("DisplayControls"),this.activateTab("LayoutViewer"),this.activateTab("TclConsole"),this.activateTab("Inspector");this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}_mountComponent(s,h,p,m,_){if(this.components.has(s))return;let S=this.panes[h];if(!S)return;let y=document.createElement("div");y.className="ide-component-container",y.id=`cmp-${s}`,S.contentEl.appendChild(y);let I=document.createElement("ide-tab");I.id=`tab-${s}`,I.setAttribute("for",s),I.setAttribute("data-component",s),I.setAttribute("title",p),m&&I.setAttribute("closable",""),I.addEventListener("tab-select",()=>{this.activateTab(s)}),I.addEventListener("tab-close",()=>{this.closeComponent(s)}),S.tabsEl.appendChild(I);let N=new Map,B={element:y,get width(){return y.clientWidth},get height(){return y.clientHeight},title:p,on:(U,j)=>{N.has(U)||N.set(U,new Set),N.get(U).add(j)},off:(U,j)=>{N.get(U)?.delete(j)},fire:(U,...j)=>{let V=N.get(U);if(V)for(let et of V)try{et(...j)}catch(Q){console.error(Q)}},focus:()=>this.focusComponent(s),close:()=>this.closeComponent(s)},P={componentType:s,paneName:h,title:p,closable:m,tabEl:I,contentDiv:y,container:B};this.components.set(s,P);try{_(B)}catch(U){console.error(`Failed to initialize component ${s}:`,U)}}isComponentActive(s){return s?!!s.contentDiv?.classList.contains("active"):!1}_setComponentActive(s,h){if(!s)return;let p=!!h;s.tabEl?.setActive(p),s.contentDiv?.classList.toggle("active",p)}activateTab(s){let h=this.components.get(s);if(!h||!this.panes[h.paneName])return;["left","right","bottom"].includes(h.paneName)&&this.isPaneCollapsed(h.paneName)&&this.restorePane(h.paneName);let m=this.activeTabs[h.paneName];if(m&&m!==s){let _=this.components.get(m);_&&(this._setComponentActive(_,!1),_.container.fire("hide"))}this.activeTabs[h.paneName]=s,h.tabEl.style.display="",h.contentDiv.style.display="",this._setComponentActive(h,!0),this.closedComponents.delete(s),h.container.fire("show"),h.container.fire("open"),h.container.fire("resize"),typeof app<"u"&&(s==="LayoutViewer"&&app.map&&setTimeout(()=>app.map.invalidateSize({animate:!1}),0),s==="3DViewer"&&app.threeDViewerWidget&&setTimeout(()=>app.threeDViewerWidget.onOpen(),0));try{h.tabEl.scrollIntoView({behavior:"smooth",inline:"nearest",block:"nearest"})}catch{}this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}closeComponent(s,h=!0){let p=this.components.get(s);if(!(!p||!p.closable)){if(p.tabEl.style.display="none",p.contentDiv.style.display="none",this._setComponentActive(p,!1),p.container.fire("hide"),this.closedComponents.add(s),h&&this.activeTabs[p.paneName]===s){let m=null;for(let _ of this.components.values())if(_.paneName===p.paneName&&!this.closedComponents.has(_.componentType)){m=_;break}m?this.activateTab(m.componentType):(this.activeTabs[p.paneName]=null,["left","right","bottom"].includes(p.paneName)&&this.collapsePane(p.paneName))}this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}}focusComponent(s){if(!this.components.get(s)){let p=this.factories.get(s);if(p){let m=FKt[s]||{pane:"right",title:s,closable:!0};this._mountComponent(s,m.pane,m.title,m.closable,p)}else return}this.activateTab(s)}saveLayout(){let s={leftWidth:parseInt(this.containerEl.style.getPropertyValue("--pane-left-width")||"240",10),rightWidth:parseInt(this.containerEl.style.getPropertyValue("--pane-right-width")||"340",10),bottomHeight:parseInt(this.containerEl.style.getPropertyValue("--pane-bottom-height")||"220",10),hideLeft:this.isPaneCollapsed("left"),hideRight:this.isPaneCollapsed("right"),hideBottom:this.isPaneCollapsed("bottom"),activeTabs:{...this.activeTabs},closed:Array.from(this.closedComponents)};try{localStorage.setItem("or_ide_layout",JSON.stringify(s))}catch{}return s}notifyResize(){if(this._resizeScheduled)return;this._resizeScheduled=!0,(typeof requestAnimationFrame=="function"?requestAnimationFrame:h=>{h()})(()=>{this._resizeScheduled=!1;for(let h of this.components.values())this.isComponentActive(h)&&h.container.fire("resize");typeof app<"u"&&app&&app.map&&app.map.invalidateSize({animate:!1}),window.dispatchEvent(new Event("resize"))})}updateSize(){this.notifyResize()}setSize(s,h){this.notifyResize()}addComponent(s,h,p){this.focusComponent(s)}get rootItem(){return{contentItems:Array.from(this.components.keys()).map(s=>({isComponent:!0,componentType:s,focus:()=>this.focusComponent(s)}))}}};function Id(d,s,h,p,m=0,_=0){return[(s-_-p)*h,(d-m)*h]}function Vf(d,s,h,p,m,_,S=0,y=0){return[[(s-y-_)*m,(d-S)*m],[(p-y-_)*m,(h-S)*m]]}function Yw(d,s,h,p,m=0,_=0){return{dbuX:Math.round(m+s/h),dbuY:Math.round(_+p+d/h)}}var RU=class d{constructor(s,h){this.url=s,this.socket=null,this.nextId=1,this.pending=new Map,this._queue=new Map,this._inFlight=0,this._inFlightIds=new Set,this._unknownPayloadTypes=new Set,this._maxInFlight=48,this._lastRecvAt=0,this._bufStuckSince=0,this._lastBuffered=0,this.reconnectDelay=1e3,this.readyPromise=null,this.readyResolve=null,this.onStatusChange=h||(()=>{}),this.onPush=null,this._cache=null,this._isConnected=!1,this._shutdown=!1,this._livenessTimer=void 0,this._startLivenessMonitor(),this.connect()}get isConnected(){return this._isConnected||this.socket&&this.socket.readyState===WebSocket.OPEN}get pendingCount(){return this.pending.size+(this._queue?this._queue.size:0)}static fromCache(s,h){let p=Object.create(d.prototype);return p.url=null,p.socket=null,p.nextId=1,p.pending=new Map,p._queue=new Map,p._inFlight=0,p._inFlightIds=new Set,p._unknownPayloadTypes=new Set,p._maxInFlight=48,p._lastRecvAt=0,p.reconnectDelay=0,p.onStatusChange=h||(()=>{}),p.onPush=null,p._cache=s,p._isConnected=!0,p.readyPromise=Promise.resolve(),p.readyResolve=null,p}get isStaticMode(){return!!this._cache}connect(){this.readyPromise=new Promise(s=>{this.readyResolve=s}),this.socket=new WebSocket(this.url),this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{console.log("WebSocket connected");let s=this._everConnected===!0;this._everConnected=!0,this._isConnected=!0,this.reconnectDelay=1e3,this._lastRecvAt=typeof performance<"u"?performance.now():0,this.readyResolve(),this.onStatusChange(),this._pump(),s&&this.onReconnected&&this.onReconnected()},this.socket.onmessage=s=>{this.handleMessage(s.data)},this.socket.onclose=()=>this._handleClose(),this.socket.onerror=s=>{console.error("WebSocket error:",s)}}_handleClose(){this._isConnected=!1,this._inFlight=0,this._inFlightIds.clear(),this._bufStuckSince=0,this.onStatusChange();for(let[s,h]of this.pending)h.reject(new Error("WebSocket closed"));this.pending.clear();for(let[s,h]of this._queue)h.reject(new Error("WebSocket closed"));if(this._queue.clear(),this._shutdown){console.log("WebSocket closed (server stopped)"),this._stopLivenessMonitor();return}console.log("WebSocket closed, reconnecting..."),setTimeout(()=>this.connect(),this.reconnectDelay),this.reconnectDelay=Math.min(this.reconnectDelay*2,3e4)}_forceReconnect(){let s=this.socket;if(this.socket=null,s){s.onopen=null,s.onmessage=null,s.onclose=null,s.onerror=null;try{s.close()}catch{}}this._handleClose()}handleMessage(s){let h=new DataView(s),p=h.getUint32(0),m=h.getUint8(4);if(this._lastRecvAt=typeof performance<"u"?performance.now():0,p===0&&m===0){let y=s.slice(8),I;try{I=JSON.parse(new TextDecoder().decode(y))}catch(N){console.error("Failed to parse server push JSON:",N);return}if(I&&I.type==="config"){Number.isFinite(I.max_in_flight)&&(this._maxInFlight=Math.max(1,Math.min(4096,Math.floor(I.max_in_flight))),this._pump());return}this.onPush&&this.onPush(I);return}this._inFlightIds.delete(p)&&this._inFlight>0&&this._inFlight--;let _=this.pending.get(p);if(!_){this._pump();return}this.pending.delete(p),this._pump(),this.onStatusChange();let S=s.slice(8);if(m===2)_.reject(new Error(new TextDecoder().decode(S)));else if(m===0)try{_.resolve(JSON.parse(new TextDecoder().decode(S)))}catch(y){_.reject(new Error("JSON parse error: "+y.message))}else m===1?_.resolve(new Blob([S],{type:"image/png"})):m===3?_.resolve(null):(this._unknownPayloadTypes.has(m)||(this._unknownPayloadTypes.add(m),console.warn(`Unrecognized websocket payload type ${m}. The server is likely newer than this page \u2014 reload to pick up the current client.`)),_.reject(new Error(`Unsupported websocket payload type ${m}`)))}request(s){if(this._cache)return this._cacheRequest(s);let h=this.nextId++;if(s.id=h,!this.socket||this.socket.readyState!==WebSocket.OPEN)return Promise.reject(new Error("WebSocket not connected"));let p,m,_=new Promise((S,y)=>{p=S,m=y});return _.requestId=h,this._queue.set(h,{msg:s,resolve:p,reject:m}),this._pump(),_}_pump(){if(!(!this.socket||this.socket.readyState!==WebSocket.OPEN)){for(;this._inFlight0&&this.socket.bufferedAmount<524288;){let[s,h]=this._queue.entries().next().value;this._queue.delete(s),this.pending.set(s,{resolve:h.resolve,reject:h.reject}),this.socket.send(JSON.stringify(h.msg)),this._inFlightIds.add(s),this._inFlight++}this.onStatusChange()}}cancel(s){let h=this._queue.get(s);if(h){this._queue.delete(s),h.reject(new Error("Request cancelled")),this.onStatusChange();return}let p=this.pending.get(s),m=this.pending.delete(s);p&&p.reject(new Error("Request cancelled")),m&&!this._cache&&this.socket&&this.socket.readyState===WebSocket.OPEN&&this.socket.send(JSON.stringify({type:"cancel",cancel_id:s,id:this.nextId++})),this.onStatusChange()}_startLivenessMonitor(){typeof setInterval>"u"||(this._livenessTimer=setInterval(()=>this._checkLiveness(),3e3),this._livenessTimer&&typeof this._livenessTimer.unref=="function"&&this._livenessTimer.unref())}_stopLivenessMonitor(){this._livenessTimer!==void 0&&typeof clearInterval<"u"&&(clearInterval(this._livenessTimer),this._livenessTimer=void 0)}_checkLiveness(){if(this._cache)return;let s=this.socket;if(!s||s.readyState!==WebSocket.OPEN){this._bufStuckSince=0,this._lastBuffered=0;return}let h=s.bufferedAmount,p=typeof performance<"u"?performance.now():0,m=!1,_="";h<=262144||h12e3&&(m=!0,_=`send buffer stuck at ${h}B for ${Math.round(p-this._bufStuckSince)}ms`),this._lastBuffered=h,!m&&this._inFlight>=this._maxInFlight&&this._queue.size>0&&this._lastRecvAt>0&&p-this._lastRecvAt>3e4&&(m=!0,_=`saturated (${this._inFlight} in flight, ${this._queue.size} queued) but silent for ${Math.round(p-this._lastRecvAt)}ms`),m&&(console.warn(`WebSocket connection wedged \u2014 ${_}; reconnecting to recover`),this._bufStuckSince=0,this._forceReconnect())}_cacheRequest(s){let h=s.type;if(h==="tile"){let _=s.layer+"/"+s.z+"/"+s.x+"/"+s.y,S=this._cache.tiles&&this._cache.tiles[_];return S?Promise.resolve("data:image/png;base64,"+S):Promise.reject(new Error("Tile not cached: "+_))}if(h==="timing_highlight"){let _=s.path_index;if(_>=0&&this._cache.overlays){let S=s.is_setup?"setup":"hold",y=this._cache.overlays[S]?.[_];this._cache.setPathOverlay&&this._cache.setPathOverlay(y?"data:image/png;base64,"+y:null)}else this._cache.setPathOverlay&&this._cache.setPathOverlay(null);return Promise.resolve({})}if(h==="set_module_colors")return Promise.resolve({ok:1,count:0});let p=h;h==="timing_report"?p="timing_report:"+(s.is_setup?"setup":"hold"):h==="slack_histogram"&&(p="slack_histogram:"+(s.is_setup?"setup":"hold"));let m=this._cache.json&&this._cache.json[p];if(m!==void 0){if(h==="timing_report"&&s.slack_min!=null&&s.slack_max!=null&&m.paths){let _=[];return m.paths.forEach((S,y)=>{S.slack>=s.slack_min&&S.slack"u"||typeof window.matchMedia!="function"||typeof d!="function")return()=>{};let s=!1,h=null,p=null,m=()=>{if(s)return;let _=window.devicePixelRatio||1;h=window.matchMedia(`(resolution: ${_}dppx)`),p=()=>{s||(m(),d(window.devicePixelRatio||1))},h.addEventListener("change",p,{once:!0})};return m(),()=>{s=!0,h&&p&&h.removeEventListener("change",p),h=null,p=null}}function lR(d,s){let h=d&&d._map?d._map.getZoom():s;return Math.floor(h)}var XAe=["tracks_pref","tracks_non_pref","debug","debug_renderers"],ZAe=1/16;function P2t(d,s){if(d==null)return!1;if(!Array.isArray(d)||d.length!==4||!s)return!0;let h=Math.pow(2,s.z),p=ZAe/h,m=s.x/h-p,_=s.y/h-p,S=(s.x+1)/h+p,y=(s.y+1)/h+p,[I,N,B,P]=d;return I<=S&&B>=m&&N<=y&&P>=_}function YAe(d,s,h){let p=d&&Array.isArray(d.by_size)?d.by_size:[];if(p.length===0||!s||!(h>0))return!0;let m=d.min_css_px/(h*Math.pow(2,s.z)),_=p[0];for(let S of p)S[0]<=m&&(_=S);return P2t(_[1],s)}var Jet=class{constructor(){this._layers=null,this._gated=new Map,this._sized=new Map,this._generation=0}invalidate(){return this._generation++,this._layers=null,this._gated=new Map,this._sized=new Map,this._generation}apply(s,h){if(s!==this._generation)return!1;if(!h||h.supported!==!0||!h.layers||typeof h.layers!="object")return this._layers=null,!1;let p=new Map;if(h.gated&&typeof h.gated=="object")for(let[m,_]of Object.entries(h.gated))_&&typeof _=="object"&&p.set(m,new Map(Object.entries(_)));return this._layers=new Map(Object.entries(h.layers)),this._gated=p,this._sized=new Map(h.sized&&typeof h.sized=="object"?Object.entries(h.sized):[]),!0}refetch(s){let h=this.invalidate();return Promise.resolve().then(()=>s({type:"layer_extents"})).then(p=>this.apply(h,p)).catch(()=>!1)}mayHaveContent(s,h,p,m=256){if(!this._layers||p&&XAe.some(_=>p[_]))return!0;if(this._sized.has(s))return YAe(this._sized.get(s),h,m);if(!this._layers.has(s)||P2t(this._layers.get(s),h))return!0;for(let[_,S]of this._gated)if(!(p&&p[_]===!1)&&S.has(s)&&P2t(S.get(s),h))return!0;return!1}};function DU(d,s,h){let p=d&&d.app&&d.app.layerExtents;return p?p.mayHaveContent(s,h,d.visibility,Kw()):!0}function ik(){return aR()}function HKt(d,s,h){return Ket(d,s,h,ik(),Kw())}function hR(d,s){if(d.src&&d.src.startsWith("blob:")&&URL.revokeObjectURL(d.src),s==null){d.src=r3;return}d.src=typeof s=="string"?s:URL.createObjectURL(s)}function GKt(d,s,h,p,m){let _={visibility:d,selectability:h,visibleLayers:s,selectableLayers:p,app:m};return L.GridLayer.extend({_clampZoom:function(S){return L.GridLayer.prototype._clampZoom.call(this,lR(this,S))},initialize:function(S,y,I){this._websocketManager=S,this._layerName=y,L.GridLayer.prototype.initialize.call(this,nk(I))},createTile:function(S,y){let I=document.createElement("img");return I.alt="",I.setAttribute("role","presentation"),I._tileDone=!1,I.onload=()=>{I.src&&I.src.startsWith("blob:")&&URL.revokeObjectURL(I.src),I._tileDone||(I._tileDone=!0,y(null,I))},I.onerror=()=>{I._tileDone||(I._tileDone=!0,y(new Error("tile image load error"),I))},I._websocketRequestId=this._websocketManager.nextId,DU(_,this._layerName,S)?(this._websocketManager.request(HKt(S,this._layerName,_)).then(N=>{hR(I,N)}).catch(N=>{}),I):(I._websocketRequestId=void 0,hR(I,null),I)},refreshTiles:function(){if(this._map)for(let S in this._tiles){let y=this._tiles[S];if(!y||!y.el)continue;let I=y.el,N=y.coords;if(I._websocketRequestId!==void 0&&this._websocketManager.cancel(I._websocketRequestId),!DU(_,this._layerName,N)){I._websocketRequestId=void 0,hR(I,null);continue}I._websocketRequestId=this._websocketManager.nextId,this._websocketManager.request(HKt(N,this._layerName,_)).then(B=>{hR(I,B)}).catch(B=>{})}},_removeTile:function(S){let y=this._tiles[S];y&&y.el&&(y.el._websocketRequestId!==void 0&&this._websocketManager.cancel(y.el._websocketRequestId),y.el.src&&y.el.src.startsWith("blob:")&&URL.revokeObjectURL(y.el.src)),L.GridLayer.prototype._removeTile.call(this,S)}})}function WKt(d,s){function h(p,m){let _={type:"overlay_tile",z:p.z,x:p.x,y:p.y,...uR(ik(),m),debug_renderers:!!d.debug_renderers,debug_live:!!d.debug_live,flywires_only:!!d.flywires_only,poly_decomp:!!(s&&s.polyDecomp),focused_nets_guides:!!d.focused_nets_guides,highlight_selected:d.highlight_selected!==!1,draw_labels:d.labels!==!1};return s&&s.visibleLayerNames&&(_.visible_layers=[...s.visibleLayerNames]),_}return L.GridLayer.extend({initialize:function(p,m){this._websocketManager=p,L.GridLayer.prototype.initialize.call(this,nk(m))},createTile:function(p,m){let _=document.createElement("img");_.alt="",_.setAttribute("role","presentation"),_._tileDone=!1,_.onload=()=>{_.src&&_.src.startsWith("blob:")&&URL.revokeObjectURL(_.src),_._tileDone||(_._tileDone=!0,m(null,_))},_.onerror=()=>{_._tileDone||(_._tileDone=!0,m(new Error("overlay tile load error"),_))};let S=this._websocketManager.nextId;return _._websocketRequestId=S,this._websocketManager.request(h(p,this.getTileSize().x)).then(y=>{_._websocketRequestId===S&&hR(_,y)}).catch(y=>{}),_},refreshTiles:function(){if(this._map)for(let p in this._tiles){let m=this._tiles[p];if(!m||!m.el)continue;let _=m.el,S=m.coords;_._websocketRequestId!==void 0&&this._websocketManager.cancel(_._websocketRequestId);let y=this._websocketManager.nextId;_._websocketRequestId=y,this._websocketManager.request(h(S,this.getTileSize().x)).then(I=>{_._websocketRequestId===y&&hR(_,I)}).catch(()=>{})}},_removeTile:function(p){let m=this._tiles[p];m&&m.el&&(m.el._websocketRequestId!==void 0&&(this._websocketManager.cancel(m.el._websocketRequestId),m.el._websocketRequestId=void 0),m.el.src&&m.el.src.startsWith("blob:")&&URL.revokeObjectURL(m.el.src)),L.GridLayer.prototype._removeTile.call(this,p)}})}function $Kt({zIndex:d=0,tileSize:s}={}){let h={opacity:1,zIndex:d};return s!==void 0&&(h.tileSize=s),h}var KAe=4,I2t=350*1024*1024;function VKt(d,s=1){let h=Math.round(d*Math.max(0,s));return h*h*KAe}function qKt(d,s,h=256){return!(d>0)||!(s>0)||!(h>0)?1:(Math.ceil(d/h)+1)*(Math.ceil(s/h)+1)}function XKt(d,s){let h=s||(typeof window<"u"?window:null),p=d&&d.clientWidth>0?d.clientWidth:h&&h.innerWidth>0?h.innerWidth:1024,m=d&&d.clientHeight>0?d.clientHeight:h&&h.innerHeight>0?h.innerHeight:768;return{width:p,height:m}}function R2t(d,s){if(!d)return!1;let h=!!s;return!!d.visible===h?!1:(d.visible=h,!0)}var Qet=4;function ZKt(d,s,h,p=Qet){let m=s*h;return m>0?Math.max(m,d-p*m):d}function YKt({budgetBytes:d=I2t,tilesPerPane:s,bytesPerTile:h,paneCount:p}={}){if(!(s>0)||!(h>0)||!(p>0))return 1;let m=s*h;return Math.max(1,Math.min(p,Math.floor(d/m)))}function D2t(d,s){if(!Array.isArray(d)||d.length===0)return[];let h=Math.max(1,Math.min(Math.floor(s)||1,d.length)),p=Math.floor(d.length/h),m=d.length%h,_=[],S=0;for(let y=0;y0&&(I++,m--),_.push(d.slice(S,S+I)),S+=I}return _}function KKt(d,s,h){if(!d||!(h>0))return 0;d.clearRect(0,0,h,h);let p=0;for(let m of s||[]){let _=m?m.image:null;if(!_)continue;let S=m.opacity===void 0?1:m.opacity;S>0&&(d.globalAlpha=Math.min(1,S),d.drawImage(_,0,0,h,h),p++)}return d.globalAlpha=1,p}function N2t(d){for(let s of d||[])s&&typeof s.close=="function"&&s.close()}async function JKt({items:d,request:s,decode:h,draw:p,release:m=N2t,isStale:_=()=>!1,onFirstDraw:S}={}){let y=Array.isArray(d)?d:[],I={requested:y.length,arrived:0,decoded:0,drawn:0,paints:0,stale:!1};if(y.length===0)return typeof p=="function"&&p([]),I;let N=new Array(y.length).fill(null),B=!1;function P(){if(_()){I.stale=!0;return}I.drawn=p(y.map((U,j)=>({image:N[j],opacity:U.opacity})))||0,I.paints++,B||(B=!0,S&&S())}try{await Promise.all(y.map(async(U,j)=>{let V=null;try{V=await s(U)}catch{return}if(V==null)return;I.arrived++;let et=null;try{et=await h(V)}catch{return}et&&(N[j]=et,I.decoded++,P())})),B||P()}finally{m(N)}return I}function JAe(d){return d==null?Promise.resolve(null):typeof d=="string"?new Promise(s=>{let h=document.createElement("img");h.onload=()=>s(h),h.onerror=()=>s(null),h.src=d}):typeof createImageBitmap=="function"?createImageBitmap(d).catch(()=>null):new Promise(s=>{let h=URL.createObjectURL(d),p=new Image;p.onload=()=>{URL.revokeObjectURL(h),s(p)},p.onerror=()=>{URL.revokeObjectURL(h),s(null)},p.src=h})}function QKt(d,s={}){let h=s.decode||JAe,p=s.dpr||aR;return L.GridLayer.extend({_clampZoom:function(m){return L.GridLayer.prototype._clampZoom.call(this,lR(this,m))},initialize:function(m,_,S){this._websocketManager=m,this._items=_||[],this._generation=0,L.GridLayer.prototype.initialize.call(this,nk(S))},setItems:function(m){this._items=m||[],this.refreshTiles()},visibleItems:function(){return this._items.filter(m=>m&&m.visible!==!1)},createTile:function(m,_){let S=document.createElement("canvas");S.setAttribute("role","presentation");let y=p();return S._orDone=_,this._renderTile(S,m,y),S},_sizeCanvas:function(m,_,{empty:S=!1}={}){let y=this.getTileSize(),I=S?0:Yet(y.x,_),N=S?0:Yet(y.y,_);(m.width!==I||m.height!==N)&&(m.width=I,m.height=N),m.style.width=y.x+"px",m.style.height=y.y+"px"},_finishTile:function(m,_){m._orTileDone||!m._orDone||(m._orTileDone=!0,m._orDone(_||null,m))},_renderTile:function(m,_,S){let y=this._generation,I=this.visibleItems().filter(P=>DU(d,P.layer,_));this._sizeCanvas(m,S,{empty:I.length===0});let N=m.getContext("2d");m._orRequestIds=[];let B=()=>this._generation!==y||m._orRemoved===!0;JKt({items:I,request:P=>{let U=this._websocketManager.nextId;return m._orRequestIds.push(U),this._websocketManager.request(Ket(_,P.layer,d,S,this.getTileSize().x))},decode:h,draw:P=>KKt(N,P,m.width),release:N2t,isStale:B,onFirstDraw:()=>this._finishTile(m)}).then(()=>{B()||this._finishTile(m)}).catch(P=>{B()||this._finishTile(m,P)})},refreshTiles:function(){if(this._map){this._generation++;for(let m in this._tiles){let _=this._tiles[m];if(!_||!_.el)continue;this._cancelTile(_.el);let S=p();this._renderTile(_.el,_.coords,S)}}},_cancelTile:function(m){let _=m._orRequestIds;if(!(!_||!_.length)){for(let S of _)this._websocketManager.cancel(S);m._orRequestIds=[]}},_removeTile:function(m){let _=this._tiles[m];_&&_.el&&(_.el._orRemoved=!0,this._cancelTile(_.el),_.el.width=0,_.el.height=0),L.GridLayer.prototype._removeTile.call(this,m)}})}function tJt(d,s,h,p,m=0){let _=[];return h.forEach((S,y)=>{let I=new d(s,S,$Kt({zIndex:m+y}));p&&I.addTo(p),_.push(I)}),_}var QAe=".leaflet-tile-container",iJt=".leaflet-tile";function eJt(d,s){if(!Number.isFinite(d)||!(s>0))return 0;let h=d*s;return(h-Math.round(h))/s}function tke(d,s,h=rJt){let p=d&&d.parentElement;if(!p)return null;let m=typeof d.querySelector=="function"?d.querySelector(iJt):null;if(!m)return null;let _=h(m),S=nJt((p._orSnapDx||0)-eJt(_.left,s),s),y=nJt((p._orSnapDy||0)-eJt(_.top,s),s);return p._orSnapDx=S,p._orSnapDy=y,p.style.transform=S||y?`translate3d(${S}px, ${y}px, 0)`:"",{dx:S,dy:y}}function eke(d,s,h=rJt){if(!d||typeof d.getPane!="function"||!(s>0)||Number.isInteger(s))return 0;let p=d.getPane("tilePane");if(!p||typeof p.querySelectorAll!="function")return 0;let m=0,_=[...p.querySelectorAll(QAe)].filter(nke).map(S=>{let y=S.querySelector(iJt);return{container:S,rect:y?h(y):null}});for(let{container:S,rect:y}of _)y&&tke(S,s,()=>y)&&m++;return m}function rJt(d){return d.getBoundingClientRect()}function nJt(d,s){return d-Math.round(d*s)/s}function nke(d){let s=d.style&&d.style.transform||"",h=/scale\(([^)]*)\)/.exec(s);return!h||Number(h[1])===1}var ike="move zoomend viewreset resize load";function sJt(d,s=aR){if(!d||typeof d.on!="function")return!1;let h=()=>eke(d,s());return d.on(ike,h),h(),!0}function Sc(d){return!!d?.websocketManager?.isStaticMode}function uJt(d,s){let h={};for(let[p,m]of Object.entries(d||{}))h[p]=!!m;for(let[p,m]of Object.entries(s||{}))h["s_"+p]=!!m;return h}function fR(d,s){s&&typeof s.sel_has_inst=="boolean"&&(d.selHasInst=s.sel_has_inst,d.selHasNet=!!s.sel_has_net)}var O2t=null;function Jw(d,s=4e3){let h=document.getElementById("or-toast");return h||(h=document.createElement("div"),h.id="or-toast",document.body.appendChild(h)),h.textContent=d,h.classList.add("visible"),O2t&&clearTimeout(O2t),O2t=setTimeout(()=>h.classList.remove("visible"),s),h}function lJt({title:d,message:s,confirmLabel:h="OK",danger:p=!1}){return new Promise(m=>{let _=document.createElement("div");_.className="or-modal-overlay";let S=document.createElement("div");S.className="or-modal";let y=document.createElement("div");y.className="or-modal-title",y.textContent=d;let I=document.createElement("div");I.className="or-modal-message",I.textContent=s;let N=document.createElement("div");N.className="or-modal-buttons";let B=document.createElement("button");B.className="or-btn",B.textContent="Cancel";let P=document.createElement("button");P.className="or-btn"+(p?" or-btn-danger":""),P.textContent=h;let U=V=>{document.removeEventListener("keydown",j,!0),_.remove(),m(V)},j=V=>{V.key==="Escape"&&(V.stopPropagation(),U(!1))};B.addEventListener("click",()=>U(!1)),P.addEventListener("click",()=>U(!0)),_.addEventListener("click",V=>{V.target===_&&U(!1)}),document.addEventListener("keydown",j,!0),N.appendChild(B),N.appendChild(P),S.appendChild(y),S.appendChild(I),S.appendChild(N),_.appendChild(S),document.body.appendChild(_),B.focus()})}var rke=.05;function ske([[d,s],[h,p]],m){let _=(p-s)*m,S=(h-d)*m;return[[d-S,s-_],[h+S,p+_]]}function B2t(d,s=256,h=null){if(!oJt(d))return null;let p=d[0][0],m=d[0][1],_=Math.max(d[1][1]-m,d[1][0]-p),S=s/_,y=oJt(h)?h:d,[[I,N],[B,P]]=ske(y,rke);return{scale:S,maxDXDY:_,originX:m,originY:p,fitBounds:Vf(N,I,P,B,S,_,m,p)}}function oJt(d){return!!d&&d[1][0]>d[0][0]&&d[1][1]>d[0][1]}function hJt(d,s){return!!d&&!!s&&d[0][0]===s[0][0]&&d[0][1]===s[0][1]&&d[1][0]===s[1][0]&&d[1][1]===s[1][1]}function bg(d){d.selectionToken=(d.selectionToken||0)+1;for(let s of d.selectionResetters||[])s();return d.selectionToken}function D0(d,s){return d.selectionToken===s}function fJt(d,s){d.selectionResetters||(d.selectionResetters=[]),d.selectionResetters.push(s)}function dJt(d=typeof L<"u"?L.CRS.Simple:void 0,s={}){return{crs:d,zoom:1,zoomSnap:1,zoomDelta:1,fadeAnimation:!1,attributionControl:!1,scrollWheelZoom:s.wheelZoom!==!1,keyboardPanDelta:dR(s.arrowStep)}}var F2t=80,NU=10,OU=1e3;function dR(d){let s=d===""||d===null?NaN:Math.round(Number(d));return Number.isFinite(s)?Math.min(OU,Math.max(NU,s)):F2t}function pJt(d,s){d?.keyboard?._setPanDelta?.(s)}function rk(d="vis-group-header"){let s=document.createElement("div");s.className=d;let h=document.createElement("span");h.className="vis-arrow",s.appendChild(h);let p=document.createElement("span");return p.className="vis-name",s.appendChild(p),{header:s,arrow:h,name:p}}function sk(d,s,h,p){let m=_=>{h.classList.toggle("collapsed",_),s.textContent=_?"\u25B6":"\u25BC"};m(!!p),d.addEventListener("click",_=>{let S=_.target&&_.target.parentNode===d&&_.target.classList&&_.target.classList.contains("vis-name");_.target!==d&&_.target!==s&&!S||m(!h.classList.contains("collapsed"))})}var cJt=30;function gJt(d,s=8){if(!Number.isFinite(d)||d<=0)return cJt;let h=Math.ceil(Math.log2(s/d));return Math.max(1,Math.min(cJt,h))}function mJt({designBounds:d,fitRect:s,viewW:h,viewH:p}){let m=B2t(d,i3,s),_=j=>Number.isFinite(j)&&j>0;if(!m||!_(h)||!_(p))return i3;let S=m.fitBounds[1][1]-m.fitBounds[0][1],y=m.fitBounds[1][0]-m.fitBounds[0][0],I=Math.min(h/S,p/y),N=Math.log2(I);if(!Number.isFinite(N)||N<0)return i3;let B=Math.floor(N),P=i3*2**(N-B),U=Math.floor(P/L2t)*L2t;return U>i3&&Math.log2(i3*I/U)>=B?U:i3}function bJt(d,{showDbu:s,dbuPerMicron:h},p=!1){if(s)return String(Math.round(d));let m=h>0?h:1e3,_=Math.ceil(Math.log10(m)),S=(d/m).toFixed(_);return p?S+" \xB5m":S}function wJt(d,{showDbu:s,dbuPerMicron:h}){let p=parseFloat(d);if(!Number.isFinite(p))return null;if(s)return Math.round(p);let m=h>0?h:1e3;return Math.round(p*m)}function vJt(d,{showDbu:s,dbuPerMicron:h}){if(s)return String(Math.round(d));let p=h>0?h:1e3,m=d/p;return m>=1e3?(m/1e3).toFixed(3)+" mm":m>=1?m.toFixed(3)+" um":(m*1e3).toFixed(1)+" nm"}function _Jt({showDbu:d}){return d?"DBU":"\xB5m"}function pR(d){return typeof d=="string"&&/^#[0-9a-fA-F]{6}$/.test(d)}function yJt(d){if(typeof d!="string")return null;let s=d.trim();if(pR(s))return s.toLowerCase();let h=s.match(/^#([0-9a-fA-F]{3})$/);if(h)return"#"+h[1].split("").map(m=>m+m).join("").toLowerCase();let p=s.match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/);if(p){let m=p.slice(1).map(Number);return m.some(_=>_>255)?null:"#"+m.map(_=>_.toString(16).padStart(2,"0")).join("")}return null}function BU(d){let s=null;return()=>{s===null&&(s=requestAnimationFrame(()=>{s=null,d()}))}}function aJt(d){let s=Math.pow(10,Math.floor(Math.log10(d))),h=d/s,p;return h<1.5?p=1:h<3.5?p=2:h<7.5?p=5:p=10,{value:p*s,digit:p}}function xJt({targetPx:d,pxPerDbu:s,dbuPerMicron:h,showDbu:p}){if(!Number.isFinite(s)||s<=0||!Number.isFinite(d)||d<=0)return null;let m,_,S;if(p){let I=aJt(Math.max(1,d/s));S=I.digit,m=Math.round(I.value*s),_=String(Math.round(I.value))}else{let I=Number.isFinite(h)&&h>0?h:1e3,N=s*I,B=aJt(d/N);S=B.digit;let P=B.value;m=Math.round(P*N);let U,j;P>=1e3?(U=1/1e3,j="mm"):P>=1?(U=1,j="\xB5m"):P>=.001?(U=1e3,j="nm"):(U=1e6,j="pm"),_=Math.round(P*U)+" "+j}return{barPx:m,label:_,segments:S===1?5:S}}function FU(d,s,h){return s?typeof d.runTclScript=="function"?d.runTclScript(s,h):(h&&typeof d.echoTcl=="function"&&d.echoTcl(s),d.websocketManager.request({type:"tcl_eval",cmd:s}).catch(()=>{})):Promise.resolve()}function ok(d,s){let h=d.querySelectorAll("thead th");(!s||!s[0])&&(d.style.tableLayout="auto",h.forEach(p=>p.style.width=""),s=Array.from(h,p=>p.offsetWidth+"px")),h.forEach((p,m)=>p.style.width=s[m]||""),d.style.tableLayout="fixed",h.forEach((p,m)=>{if(m===h.length-1)return;let _=document.createElement("div");_.className="col-resize-grip",p.style.position="relative",p.appendChild(_);let S,y,I=B=>{p.style.width=Math.max(30,y+B.clientX-S)+"px"},N=()=>{document.removeEventListener("mousemove",I),document.removeEventListener("mouseup",N);let B=P=>P.stopPropagation();document.addEventListener("click",B,{capture:!0,once:!0}),setTimeout(()=>{document.removeEventListener("click",B,{capture:!0})},0)};_.addEventListener("mousedown",B=>{B.preventDefault(),S=B.clientX,y=p.offsetWidth,document.addEventListener("mousemove",I),document.addEventListener("mouseup",N)})})}var oke={Layout:'',Schematic:'',"3D Viewer":'',"Display Controls":'',Inspector:'',Hierarchy:'',Timing:'',DRC:'',"Select Highlight":'',"Clock Tree":'',Charts:'',"Tcl Console":'',Help:''};function cke(d){let s=oke[d];if(!s)return null;let h=document.createElement("span");return h.className="or-tab-icon",h.innerHTML='",h}function MJt(d=document){let s=0;for(let h of d.querySelectorAll(".lm_tab:not([data-or-icon])")){let p=h.querySelector(".lm_title");if(!p)continue;let m=p.textContent.trim();if(!m)continue;h.setAttribute("data-or-icon","");let _=cke(m);_&&(h.insertBefore(_,p),s++)}return s}function EJt(d,s){d.scrollWheelZoom.disable(),d.getContainer().addEventListener("wheel",h=>{if(h.preventDefault(),s()===h.ctrlKey){let[m,_]=ake(h,d.getContainer());d.panBy([m,_],{animate:!1});return}let p=h.deltaY<0?1:-1;d.setZoomAround(d.mouseEventToLatLng(h),d.getZoom()+p)},{passive:!1})}function ake(d,s){let p=1;return d.deltaMode===1?p=16:d.deltaMode===2&&(p=s.clientHeight||16),[d.deltaX*p,d.deltaY*p]}function gR(d,s,h,p){let m=document.createElement("div");m.className="modal-overlay",m.innerHTML=` - `,document.body.appendChild(u);let d=()=>u.remove();u.addEventListener("click",_=>{_.target===u&&d()}),u.addEventListener("keydown",_=>{_.key==="Escape"&&d()}),u.querySelector(".cancel").addEventListener("click",d),u.querySelector(".modal-close").addEventListener("click",d);let b=u.querySelector(".modal-error"),w=(_,x)=>{b.textContent=_,b.style.display=_?"block":"none",b.classList.toggle("info",!!x)};return{overlay:u,close:d,okBtn:u.querySelector(".ok"),showError:w}}var Nhn=1e4,Fhn=150,Uhn=3;function zhn(s){return 1-(1-s)*(1-s)}var $he=class{constructor({isEnabled:n=()=>!0,isSmooth:r=()=>!1,reducedMotion:c=nH,now:u=()=>performance.now(),setTimer:d=(T,M)=>setTimeout(T,M),clearTimer:b=T=>clearTimeout(T),timeoutMs:w=Nhn,fadeMs:_=Fhn,onChange:x=()=>{}}={}){Object.assign(this,{isEnabled:n,isSmooth:r,reducedMotion:c,now:u,setTimer:d,clearTimer:b,timeoutMs:w,fadeMs:_,onChange:x}),this.shownZ=null,this.pendingZ=null,this.under=[],this.fade=null,this._timer=null}wantedZ(){return this.pendingZ!==null?this.pendingZ:this.shownZ}setZoom(n,{hasContent:r=!0}={}){n!==this.wantedZ()&&(this.endFade(),this._clearTimer(),this.shownZ===null?(this.shownZ=n,this.pendingZ=null,this.under=[]):r?n===this.shownZ?this.pendingZ=null:this.isEnabled()?(this.pendingZ=n,this.under=[],this._timer=this.setTimer(()=>this.reveal(),this.timeoutMs)):(this.under=[...this.under.filter(c=>c!==n),this.shownZ].slice(-Uhn),this.shownZ=n,this.pendingZ=null):(this.shownZ=n,this.pendingZ=null,this.under=this.under.filter(c=>c!==n)),this.onChange())}check({settled:n,animating:r=!1}){return this.pendingZ!==null?r||!n&&this.isEnabled()?!1:(this.reveal(),!0):this.under.length>0&&n&&!r?(this.under=[],this.onChange(),!0):!1}reveal(){if(this.pendingZ===null)return;this._clearTimer();let n=this.shownZ;this.shownZ=this.pendingZ,this.pendingZ=null;let r=this.isSmooth()&&!this.reducedMotion()?this.fadeMs:0;this.fade=r>0&&n!==null?{fromZ:n,toZ:this.shownZ,start:this.now(),ms:r}:null,this.onChange()}endFade(){this.fade&&(this.fade=null,this.onChange())}plan(n=this.now()){if(this.fade){let r=(n-this.fade.start)/this.fade.ms;if(r<1)return{draw:[{z:this.fade.fromZ,opacity:1},{z:this.fade.toZ,opacity:zhn(Math.max(0,r))}],fading:!0};this.fade=null}return this.shownZ===null?{draw:[],fading:!1}:this.pendingZ!==null?{draw:[{z:this.shownZ,opacity:1}],fading:!1}:this.under.length>0?{draw:[...this.under,this.shownZ].map(r=>({z:r,opacity:1})),fading:!1}:{draw:[{z:this.shownZ,opacity:1}],fading:!1}}isIdle(n=this.now()){return this.pendingZ===null&&this.under.length===0&&!this.plan(n).fading}dispose(){this._clearTimer()}_clearTimer(){this._timer!==null&&(this.clearTimer(this._timer),this._timer=null)}};var mp=Object.freeze({base:10,overlay:20,heatmap:30,top:40,pathImage:50,selection:60,highlight:70,ruler:80}),ck={depthCompare:"always",depthWriteEnabled:!1},Hxt=250,qxt=4,W5e=300,Ghn=1,jhn=2,$hn=300,Vhn=300,Whn=400,Hhn=1e3,Xxt=100,qhn=.05,Yxt=1200,Zxt=30;function Z1(s,n=1){if(Array.isArray(s)){let u=s.length>3?s[3]:255;return[s[0],s[1],s[2],Math.round(u*n)]}let r=String(s||"#000").replace("#","");r.length===3&&(r=r.split("").map(u=>u+u).join(""));let c=parseInt(r.slice(0,6),16)||0;return[c>>16&255,c>>8&255,c&255,Math.round(255*n)]}function Xhn(s){return 1-Math.pow(1-s,3)}function Yhn(s){return s<.5?4*s*s*s:1-Math.pow(2-2*s,3)/2}function Zhn(){let s=new Map;return{on(n,r){for(let c of n.split(/\s+/))s.has(c)||s.set(c,new Set),s.get(c).add(r)},off(n,r){for(let c of n.split(/\s+/))s.get(c)?.delete(r)},emit(n,r){for(let c of[...s.get(n)||[]])c(r)}}}function Kxt(s,n={}){let r=n.deckApi!==void 0?n.deckApi:globalThis.deck,c=n.copyCanvas||z5e,u={smooth:()=>!1,doubleBuffer:()=>!0,defer:()=>!1,...n.prefs||{}},d=n.tileSize||(()=>240),b=n.dpr||(()=>typeof devicePixelRatio=="number"?devicePixelRatio:1),w=n.raf||(Me=>requestAnimationFrame(Me)),_=n.now||(()=>performance.now()),x=Zhn(),T={target:[0,0],zoom:0,width:1,height:1},M={minZoom:-1/0,maxZoom:Zxt},L=null,I=!1,D=[],F=[],O=null,z=null,Z=!1,H=!1,te=0,se=new Set,ne=!1;s.classList.add("or-view");let ue=document.createElement("div");ue.className="or-view-canvas",s.appendChild(ue);let Ce=document.createElement("div");Ce.className="or-view-markers",s.appendChild(Ce);let Q=new Map,me=new Map,tt=new Map,st=new Map,at=new WeakMap,Ne=[],Qe=_T(qn,w),ot=new $he({isEnabled:()=>u.doubleBuffer(),isSmooth:()=>u.smooth(),now:_,onChange:()=>Qe()}),xt=null;function fn(){return{dragPan:!0,dragRotate:!1,scrollZoom:!1,doubleClickZoom:!1,touchZoom:!n.isStatic,touchRotate:!1,keyboard:!1,inertia:!1}}function Xt(){return{target:[T.target[0],T.target[1],0],zoom:T.zoom,minZoom:M.minZoom,maxZoom:M.maxZoom}}function wn(){return new r.Deck({parent:ue,views:new r.OrthographicView({id:"main",flipY:!1,controller:fn()}),viewState:Xt(),layers:[],useDevicePixels:!0,deviceProps:{webgl:{preserveDrawingBuffer:!!n.preserveDrawingBuffer}},getCursor:({isDragging:Me})=>se.size?"crosshair":Me?"grabbing":"default",onViewStateChange:({viewState:Me})=>{if(L=null,Un(Me.target,Me.zoom),I){let et=_();F.push({t:et,target:[...T.target],zoom:T.zoom}),F=F.filter(ht=>et-ht.t<=Xxt)}return Xt()},onInteractionStateChange:Me=>{let et=!!(Me.isDragging||Me.isPanning||Me.isZooming||Me.inTransition);if(et!==I){if(I=et,et){F=[],Hi();return}queueMicrotask(()=>{!I&&!L&&!Tr()&&yr()})}},onLoad:()=>{cn(),Qe()},onAfterRender:()=>{let Me=D;D=[],Me.forEach(et=>et())}})}function cn(){let Me=xt.getCanvas&&xt.getCanvas();Me?.addEventListener("webglcontextlost",et=>{if(et.preventDefault(),ne)return;x.emit("contextlost");let ht=xt;xt=null,at=new WeakMap,Ne=[];try{ht.finalize?.()}catch{}Me.remove();try{xt=wn(),x.emit("contextrestored")}catch(on){x.emit("contextfailed",on)}Qe()})}r&&typeof r.Deck=="function"&&(xt=wn());function bi(){let Me=b(),et=Math.max(1,Math.floor(s.clientWidth*Me)/Me),ht=Math.max(1,Math.floor(s.clientHeight*Me)/Me),on=et!==T.width||ht!==T.height;return T.width=et,T.height=ht,ue.style.width=et+"px",ue.style.height=ht+"px",on}bi();let jt=null;typeof ResizeObserver=="function"&&(jt=new ResizeObserver(()=>gn()),jt.observe(s));function gn(){bi()?(Zi(),x.emit("resize",Zn())):Qe()}function Un(Me,et,{tiles:ht=!0}={}){let on=rk(et,M),Ri=on!==T.zoom;T.target=[Me[0],Me[1]],T.zoom=on,Zi(Ri,ht)}function Zi(Me=!1,et=!0){xt&&xt.setProps({viewState:Xt()}),Me&&x.emit("zoom"),x.emit("move"),et&&_n(),Qe()}function Hi(){H||(H=!0,x.emit("movestart"))}function yr(){if(L||I)return;let Me=Math.round(T.zoom);if(Math.abs(Me-T.zoom)>1e-9){xr({target:Nhe(T,[T.width/2,T.height/2],Me),zoom:Me},{anchor:null});return}T.target=lxt(T,b());let et=H;H=!1,Zi(),et&&(x.emit("moveend"),x.emit("zoomend"))}function Tr(){let Me=F;if(F=[],!u.smooth()||Me.length<2)return!1;let et=Me[0],ht=Me[Me.length-1],on=ht.t-et.t;if(on<=0||_()-ht.t>Xxt||et.zoom!==ht.zoom)return!1;let Ri=(ht.target[0]-et.target[0])/on,di=(ht.target[1]-et.target[1])/on;return Math.hypot(Ri,di)*Math.pow(2,T.zoom)qxt?0:Hxt}function xr(Me,{anchor:et=null,ms:ht=void 0,settle:on=!0,curve:Ri=!1}={}){Me={target:Me.target,zoom:rk(Me.zoom,M)};let di=Ri&&ht===void 0?oe(Me):null;if(ht===void 0&&(ht=di?di.ms:Ei(Me)),Hi(),Me.zoom!==T.zoom&&x.emit("zoomstart"),ht<=0){L=null;let er=on&&!I;Un(Me.target,Me.zoom,{tiles:!er}),on&&yr();return}z=null,L={from:{...T,target:[...T.target]},to:Me,anchor:et,start:di?null:_(),created:_(),ms:ht,flight:di},_n(),it()}function oe(Me){if(!u.smooth()||!(Math.hypot(Me.target[0]-T.target[0],Me.target[1]-T.target[1])*Math.pow(2,Math.min(T.zoom,Me.zoom))>jhn*Math.max(T.width,T.height))&&Math.abs(Me.zoom-T.zoom)<=qxt)return null;let on=uxt(T,{...T,...Me}),Ri=1/0,di=null;for(let Js=0;Js<=16;Js++){let $i=on.at(Js/16);Ri=Math.min(Ri,$i.zoom);let Vs=_O({...T,...$i});di=di?[Math.min(di[0],Vs[0]),Math.min(di[1],Vs[1]),Math.max(di[2],Vs[2]),Math.max(di[3],Vs[3])]:Vs}let er=Math.max(0,k5e(Ri)),ms=KW(di,er,d());return{path:on,ms:Math.min(Hhn,Math.max(Whn,Vhn*on.S)),apex:ms?{z:er,range:ms}:null}}function de(Me){return!Me||[...Q.values()].every(et=>!et.visible||et.grid.settledIn(Me.z,Me.range))}function it(){if(!L||ne)return;if(L.start===null){if(!de(L.flight.apex)&&_()-L.created<$hn){w(it);return}L.start=_()}let Me=Math.min(1,(_()-L.start)/L.ms),et=Xhn(Me),ht=L.from.zoom+(L.to.zoom-L.from.zoom)*et,on;if(L.flight?{target:on,zoom:ht}=L.flight.path.at(Yhn(Me)):L.anchor?on=Nhe(L.from,L.anchor,ht):on=[L.from.target[0]+(L.to.target[0]-L.from.target[0])*et,L.from.target[1]+(L.to.target[1]-L.from.target[1])*et],Me>=1){let Ri=L.to;z=L.flight?L.flight.apex:null,L=null,Un(Ri.target,Ri.zoom),yr();return}Un(on,ht),w(it)}function We(){return L?{...T,target:L.to.target,zoom:L.to.zoom}:T}function _n(){if(Q.size===0)return;let Me=u.doubleBuffer(),et=rk(k5e(T.zoom,{targetZoom:L?L.to.zoom:null,hidingNewLevels:Me}),{minZoom:0,maxZoom:Zxt}),ht=We(),on=KW(_O(ht),et,d()),Ri=Fhe(on),di=ot.shownZ,er=u.defer()&&I;er||ot.setZoom(et,{hasContent:[...Q.values()].some(Vs=>Vs.visible&&di!==null&&Vs.grid.hasContentAt(di))});let ms=[];et>0&&!L&&!I&&!H&&ot.pendingZ===null&&(O=et-1,ms.push({z:O,range:KW(R5e(_O(ht),Ghn),O,d())}));let Js=Er();Js&&ms.push({...Js,background:!1});let $i=L?KW(_O(T),et,d()):null;for(let Vs of Q.values())Vs.visible&&!er&&Vs.grid.update({z:et,range:on,ring:Ri,extra:ms,hold:$i});_t()}function Er(){return L&&L.flight&&L.flight.apex||z}function qi(Me){let et=[];for(let ht of[Er()?.z,ot.pendingZ])ht!=null&&!et.includes(ht)&&!Me.some(on=>on.z===ht)&&et.push(ht);return et}function Te(){Z||(Z=!0,queueMicrotask(()=>{Z=!1,ne||_n()}))}function ve(){for(let Me of Q.values())if(Me.visible&&!Me.grid.isSettled())return!1;return!0}function _t(Me){let et=ot.check({settled:ve(),animating:!!L});et&&ot.pendingZ===null&&Te();let ht=!1;z&&!L&&ot.isIdle()&&ve()&&(z=null,ht=!0),(et||ht||!Me||mn(Me.z))&&Qe()}function mn(Me){let et=ot.plan(_()).draw;return et.some(ht=>ht.z===Me)||qi(et).includes(Me)}function yn(Me,{order:et,source:ht,visible:on=!0}){let Ri={load:(er,ms)=>ht.load(er,ms),release:er=>{let ms=er&&at.get(er);ms&&(at.delete(er),Ne.push(ms)),ht.release?.(er)}},di={id:Me,order:et,visible:on,grid:new Uhe({source:Ri,onChange:er=>_t(er)})};return Q.set(Me,di),_n(),{id:Me,setVisible(er){di.visible!==!!er&&(di.visible=!!er,di.visible||di.grid.clear(),_n())},isVisible:()=>di.visible,refresh(){di.visible&&(di.grid.refresh(),Qe())},remove(){di.grid.clear(),Q.delete(Me),Qe()}}}function Sn(Me){if(!xt||!xt.device)return Me.image;let et=at.get(Me);if(!et){try{et=xt.device.createTexture({data:Me.image,width:Me.width,height:Me.height,mipLevels:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}})}catch{return Me.image}at.set(Me,et)}return et}function yi(Me){if(Me>=te)return 1;let et=(Yxt-(te-Me))%400/400;return 1-.7*(.5-.5*Math.cos(2*Math.PI*et))}let hi=new WeakMap,ri=null;function Ge(Me){let et=d();et!==ri&&(hi=new WeakMap,ri=et);let ht=hi.get(Me);return ht||(ht=cxt(Me.z,Me.x,Me.y,et),hi.set(Me,ht)),ht}function Pe(Me,et,ht,on,Ri,di){for(let er of et.grid.drawableTilesAt(ht)){let ms=Ge(er);I5e(ms,on)&&Me.push({order:et.order,props:{id:`${et.id}:${Ri}${er.key}`,image:Sn(er.drawable),bounds:ms,opacity:di,parameters:ck}})}}function ke(Me,et){let ht=[],on=ot.plan(Me);if(!on.fading&&ot.pendingZ===null&&on.draw.length>0){let Js=[...on.draw.map($i=>$i.z),O,Er()?.z].filter($i=>$i!=null);for(let $i of Q.values())$i.grid.prune(Js)}let Ri=yi(Me),di=[...Q.values()].sort((Js,$i)=>Js.order-$i.order),er=di.find(Js=>Js.visible),ms=qi(on.draw);for(let Js of di)if(Js.visible){Js===er&&ms.length>0&&ht.push(...dt(Js,ms,on.draw,et,Ri));for(let $i of on.draw)Pe(ht,Js,$i.z,et,"",$i.opacity*Ri)}return{layers:ht,animate:on.fading||MeVs.z===Js.z)||Js.loading&&!Js.drawable)continue;let $i=Ge(Js);if(I5e($i,on)){let[Vs,dh,Lm,mg]=$i;ms.push([[Vs-er,dh-er],[Lm+er,dh-er],[Lm+er,mg+er],[Vs-er,mg+er]])}}return ms.length&&di.push({order:Me.order,kind:"SolidPolygonLayer",props:{id:`${Me.id}:mask`,data:ms,getPolygon:Js=>Js,getFillColor:Ye(),parameters:ck}}),di}function Ye(){let Me=(getComputedStyle(s).backgroundColor||"").match(/[\d.]+/g);return!Me||Me.length<3||Me.length>3&&Number(Me[3])===0?[0,0,0,255]:[Number(Me[0]),Number(Me[1]),Number(Me[2]),255]}function ct(Me,et,ht){let on=[],Ri=[],di=[],er=[];for(let $i of et){if($i.kind==="circle"){er.push($i);continue}let Vs=$i.kind==="rect"?[[$i.rect[0],$i.rect[1]],[$i.rect[2],$i.rect[1]],[$i.rect[2],$i.rect[3]],[$i.rect[0],$i.rect[3]]]:$i.points;if($i.fill&&Ri.push({polygon:Vs,color:$i.fill}),$i.stroke){let dh=$i.kind==="rect"||$i.closed;di.push({path:dh?[...Vs,Vs[0]]:Vs,color:$i.stroke,width:$i.width||1,dash:$i.dash||null})}}Ri.length&&on.push({order:ht,kind:"SolidPolygonLayer",props:{id:`${Me}:fill`,data:Ri,getPolygon:$i=>$i.polygon,getFillColor:$i=>$i.color,parameters:ck}});let ms=di.filter($i=>!$i.dash),Js=di.filter($i=>$i.dash);if(ms.length&&on.push({order:ht,kind:"PathLayer",props:{id:`${Me}:stroke`,data:ms,widthUnits:"pixels",getPath:$i=>$i.path,getColor:$i=>$i.color,getWidth:$i=>$i.width,parameters:ck}}),Js.length){let $i={id:`${Me}:dash`,data:Js,widthUnits:"pixels",getPath:Vs=>Vs.path,getColor:Vs=>Vs.color,getWidth:Vs=>Vs.width,getDashArray:Vs=>Vs.dash.map(dh=>dh/Vs.width),dashJustified:!0,parameters:ck};r?.PathStyleExtension&&($i.extensions=[new r.PathStyleExtension({dash:!0})]),on.push({order:ht,kind:"PathLayer",props:$i})}return er.length&&on.push({order:ht,kind:"ScatterplotLayer",props:{id:`${Me}:circle`,data:er,radiusUnits:"pixels",lineWidthUnits:"pixels",getPosition:$i=>$i.center,getRadius:$i=>$i.radius,stroked:!0,filled:!0,getLineColor:$i=>$i.stroke||[0,0,0,0],getFillColor:$i=>$i.fill||[0,0,0,0],getLineWidth:$i=>$i.width||1,parameters:ck}}),on}function Ze(){let Me=[];for(let et of me.values())Me.push(...et);return Me.push(...tt.values()),Me}function Ke(Me){return Me.map(et=>new r[et.kind||"BitmapLayer"](et.props))}let gt=0;function qn(){if(ne)return;let Me=_(),et=ke(Me,R5e(_O(T),.5)),ht=[...et.layers,...Ze()].sort((on,Ri)=>on.order-Ri.order);gt=ht.length,xt&&xt.setProps({layers:Ke(ht)});for(let on of Ne.splice(0))on.destroy?.();ti(),et.animate&&Qe(),x.emit("render")}function xi(Me=32,et=20){let ht=Q.get("base");if(!ht)return null;let on=d(),Ri=ot.plan(_()).draw,di=[...Ri,...qi(Ri).map(Js=>({z:Js}))],er=0,ms=0;for(let Js=0;Js=on||dh>=on)continue;er++,di.some(({z:mg})=>{let kv=on/2**mg,Rv=ht.grid.tiles.get(yO(mg,Math.floor(Vs/kv),Math.floor((on-dh)/kv)));return Rv&&(Rv.drawable||!Rv.loading)})&&ms++}return er?ms/er:null}function Bi(Me){return st.has(Me)||st.set(Me,{visible:!0,items:new Map}),st.get(Me)}function xn(Me,et){let[ht,on]=Ohe(Me.world,T);Me.el.style.display=et?"":"none",Me.el.style.transform=`translate(${ht}px, ${on}px)`+(Me.center?" translate(-50%, -50%)":"")}function Je(Me){for(let et of Me.items.values())xn(et,Me.visible)}function ti(){for(let Me of st.values())Je(Me)}function Zn(){return{width:T.width,height:T.height}}let rr={DRAW_ORDER:mp,getContainer:()=>s,getSize:Zn,getZoom:()=>T.zoom,getTargetZoom:()=>L?L.to.zoom:T.zoom,getCenter:()=>[...T.target],getViewState:()=>({...T,target:[...T.target]}),isAnimating:()=>!!L,isMoving:()=>H,project:Me=>Ohe(Me,T),unproject:Me=>vO(Me,T),on:x.on,off:x.off,setLimits({minZoom:Me,maxZoom:et}={}){Me!==void 0&&(M.minZoom=Me),et!==void 0&&(M.maxZoom=et);let ht=rk(T.zoom,M);ht!==T.zoom?Un(T.target,ht):xt&&xt.setProps({viewState:Xt()}),x.emit("limits")},getLimits:()=>({...M}),setView(Me,et=T.zoom,{animate:ht}={}){let on={target:[Me[0],Me[1]],zoom:et};xr(on,ht===!1?{ms:0}:{curve:!0})},fitWorldRect(Me,{padding:et=[0,0],animate:ht}={}){let on=axt(Me,T,{padding:et,...M});xr(on,ht===!1?{ms:0}:{curve:!0})},zoomAround(Me,et,{animate:ht,settle:on=!0}={}){let Ri=rk(rr.getTargetZoom()+et,M),di=We(),er=Me||[T.width/2,T.height/2],ms=Nhe(di,er,Ri);xr({target:ms,zoom:Ri},ht===!1?{ms:0,settle:on}:{anchor:Me?er:null})},zoomIn:()=>rr.zoomAround(null,1),zoomOut:()=>rr.zoomAround(null,-1),panByPx(Me,et,{animate:ht}={}){let on=We(),Ri=Math.pow(2,on.zoom),di=[on.target[0]+Me/Ri,on.target[1]-et/Ri],er=ht===!1||!u.smooth()?0:Hxt;xr({target:di,zoom:on.zoom},{ms:er})},invalidateSize:gn,applyPrefs(){_n()},addTileSlot:yn,setOverlay(Me,et,{order:ht=mp.selection}={}){!et||et.length===0?me.delete(Me):me.set(Me,ct(Me,et,ht)),Qe()},hasOverlay:Me=>me.has(Me),setImageOverlay(Me,et,{order:ht=mp.pathImage}={}){et?tt.set(Me,{order:ht,kind:"BitmapLayer",props:{id:`image:${Me}`,image:et.image,bounds:et.rect,parameters:ck}}):tt.delete(Me),Qe()},addMarker(Me,et,ht,on,{center:Ri=!1}={}){let di=Bi(Me),er=di.items.get(et);er&&er.el.remove(),on.classList.add("or-view-marker"),Ce.appendChild(on);let ms={el:on,world:[ht[0],ht[1]],center:Ri};return di.items.set(et,ms),xn(ms,di.visible),on},moveMarker(Me,et,ht){let on=Bi(Me),Ri=on.items.get(et);Ri&&(Ri.world=[ht[0],ht[1]],xn(Ri,on.visible))},clearMarkers(Me){let et=Bi(Me);for(let ht of et.items.values())ht.el.remove();et.items.clear()},setMarkerGroupVisible(Me,et){let ht=Bi(Me);ht.visible=!!et,Je(ht)},setCursorMode(Me,et=!0){et?se.add(Me):se.delete(Me),s.classList.toggle(`${Me}-mode-cursor`,!!et);let ht=xt&&xt.getCanvas&&xt.getCanvas();ht&&(ht.style.cursor=se.size?"crosshair":"default")},flashTiles(){te=_()+Yxt,Qe()},whenTilesSettled({timeoutMs:Me=6e3}={}){let et=_()+Me;return new Promise(ht=>{let on=()=>{if(ve()&&ot.isIdle()&&!L&&!H||_()>=et){ht();return}setTimeout(on,32)};on()})},captureCanvas({timeoutMs:Me=500}={}){return xt?.getCanvas()?(qn(),new Promise(et=>{let ht=null,on=()=>{clearTimeout(ht),D=D.filter(di=>di!==on);let Ri=xt?.getCanvas();et(Ri?{image:c(Ri),rect:Ri.getBoundingClientRect()}:null)};D.push(on),ht=setTimeout(()=>{xt?.redraw("capture"),on()},Me)})):Promise.resolve(null)},redraw:()=>Qe(),debugSnapshot(){let Me=ot.plan();return{zoom:T.zoom,target:[...T.target],width:T.width,height:T.height,animating:!!L,moving:H,interacting:I,shownZ:ot.shownZ,pendingZ:ot.pendingZ,fading:Me.fading,drawLevels:Me.draw,layers:gt,coverage:xi(),overlays:[...me.keys()],markers:Object.fromEntries([...st].map(([et,ht])=>[et,ht.items.size])),slots:[...Q.values()].map(et=>({id:et.id,visible:et.visible,settled:et.grid.isSettled(),...et.grid.stats()}))}},destroy(){ne=!0,jt?.disconnect(),ot.dispose();for(let Me of Q.values())Me.grid.clear();xt?.finalize?.()}};return rr}var Khn=4.000244140625;function Jhn(s){return s.deltaMode!==0?!0:s.deltaX!==0||s.deltaY===0?!1:Number.isInteger(s.deltaY)&&Math.abs(s.deltaY)>=50||s.deltaY%Khn===0}function Qhn(s){let n=Math.abs(s);return n<.2?0:Math.sign(s)*Math.max(1,Math.round(n))}function edn(s,n){let c=1;return s.deltaMode===1?c=16:s.deltaMode===2&&(c=n.clientHeight||16),[s.deltaX*c,s.deltaY*c]}function tdn(s,n,r){let c=r?3*n:n;switch(s){case"ArrowLeft":return[-c,0];case"ArrowRight":return[c,0];case"ArrowUp":return[0,-c];case"ArrowDown":return[0,c];default:return null}}function Qxt(s,n={}){let r=s.getContainer(),c=n.isStatic||(()=>!1),u=n.wheelZoom||(()=>!0),d=n.arrowStep||(()=>80),b=n.gestureIdleMs??200,w=n.contextEnabled||(()=>!0),_=[],x=(ne,ue,Ce,Q)=>{ne.addEventListener(ue,Ce,Q),_.push(()=>ne.removeEventListener(ue,Ce,Q))},T=ne=>{let ue=r.getBoundingClientRect();return[ne.clientX-ue.left,ne.clientY-ue.top]},M=ne=>s.unproject(T(ne)),L=ne=>ne.target===r||!!ne.target?.closest?.(".or-view-canvas");r.tabIndex<0&&(r.tabIndex=0);let I=null;function D(ne,ue){I||(I={z0:s.getZoom()}),I.pt=ne,clearTimeout(I.timer),I.timer=setTimeout(F,b),s.zoomAround(ne,ue,{animate:!1,settle:!1})}function F(){if(!I)return;let ne=I;I=null,clearTimeout(ne.timer);let ue=s.getZoom();s.zoomAround(ne.pt,ne.z0+Qhn(ue-ne.z0)-ue)}_.push(()=>{clearTimeout(I?.timer),I=null}),x(r,"wheel",ne=>{if(ne.preventDefault(),c())return;let ue=Jhn(ne);if(!ue&&ne.ctrlKey){D(T(ne),-ne.deltaY/(100*Math.LN2));return}if(u()===ne.ctrlKey){let[Ce,Q]=edn(ne,r);s.panByPx(Ce,Q,{animate:!1});return}if(!ue){D(T(ne),-ne.deltaY/100);return}F(),s.zoomAround(T(ne),ne.deltaY<0?1:-1)},{passive:!1}),x(r,"keydown",ne=>{if(ne.altKey||ne.ctrlKey||ne.metaKey)return;let ue=tdn(ne.key,d(),ne.shiftKey);if(ue){ne.preventDefault(),s.panByPx(ue[0],ue[1]);return}if(c())return;let Ce={"+":1,"=":1,"-":-1,_:-1};ne.key in Ce&&(ne.preventDefault(),s.zoomAround(null,Ce[ne.key]*(ne.shiftKey?3:1)))});let O=null,z=null;x(r,"pointerdown",ne=>{ne.button!==0||!L(ne)||(r.focus({preventScroll:!0}),O={x:ne.clientX,y:ne.clientY,moved:!1,box:ne.shiftKey&&!c()},O.box&&ne.stopPropagation())},{capture:!0}),x(window,"pointermove",ne=>{if(!O)return;let ue=ne.clientX-O.x,Ce=ne.clientY-O.y;(Math.abs(ue)>3||Math.abs(Ce)>3)&&(O.moved=!0),O.box&&O.moved&&(z=Jxt(z,O,ne))}),x(window,"pointerup",ne=>{if(!O||ne.button!==0)return;let ue=O;if(O=null,z&&(z.remove(),z=null),ue.box&&ue.moved){se(ue,ne);return}!ue.moved&&n.onClick&&te(ne)&&n.onClick(M(ne),ne)}),x(r,"dblclick",ne=>{c()||!L(ne)||s.zoomAround(T(ne),ne.shiftKey?-1:1)});let Z=null,H=null;x(r,"contextmenu",ne=>ne.preventDefault()),x(r,"pointerdown",ne=>{ne.button!==2||c()||!L(ne)||(ne.stopPropagation(),Z={x:ne.clientX,y:ne.clientY})},{capture:!0}),x(window,"pointermove",ne=>{if(!Z)return;let ue=ne.clientX-Z.x,Ce=ne.clientY-Z.y;(H||Math.abs(ue)>=4&&Math.abs(Ce)>=4)&&(H=Jxt(H,Z,ne))}),x(window,"pointerup",ne=>{if(!Z||ne.button!==2)return;let ue=Z;if(Z=null,H){H.remove(),H=null,se(ue,ne);return}te(ne)&&w()&&n.onContextClick&&n.onContextClick(M(ne),ne)}),x(r,"pointermove",ne=>{n.onMove&&n.onMove(M(ne),ne)}),x(r,"pointerleave",ne=>{n.onLeave&&n.onLeave(ne)});function te(ne){let ue=r.getBoundingClientRect();return ne.clientX>=ue.left&&ne.clientX<=ue.right&&ne.clientY>=ue.top&&ne.clientY<=ue.bottom}function se(ne,ue){let Ce=r.getBoundingClientRect(),Q=s.unproject([ne.x-Ce.left,ne.y-Ce.top]),me=s.unproject([ue.clientX-Ce.left,ue.clientY-Ce.top]);s.fitWorldRect([Math.min(Q[0],me[0]),Math.min(Q[1],me[1]),Math.max(Q[0],me[0]),Math.max(Q[1],me[1])])}return{dispose(){for(let ne of _.splice(0))ne()}}}function Jxt(s,n,r){return s||(s=document.createElement("div"),s.className="rubber-band",document.body.appendChild(s)),s.style.left=Math.min(n.x,r.clientX)+"px",s.style.top=Math.min(n.y,r.clientY)+"px",s.style.width=Math.abs(r.clientX-n.x)+"px",s.style.height=Math.abs(r.clientY-n.y)+"px",s}var uk=class s{constructor(n,r,c){this._app=n,this._redrawAllLayers=r,this._refreshOverlay=c||r,this._currentTab="setup",this._setupPaths=[],this._holdPaths=[],this._selectedPathIndex=-1,this._detailTab="data",this._selectedDetailIndex=-1,this._sortCol="slack",this._sortAscending=!0,this._build()}_build(){let n=document.createElement("div");n.className="timing-widget";let r=document.createElement("div");r.className="timing-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",la(this._app)&&(this._updateBtn.style.display="none"),this._pathCountLabel=document.createElement("span"),this._pathCountLabel.className="timing-path-count",r.appendChild(this._updateBtn),r.appendChild(this._pathCountLabel),n.appendChild(r),n.appendChild(this._buildConePanel());let c=document.createElement("div");c.className="timing-tab-bar",this._setupTab=this._makeTab("Setup",!0),this._holdTab=this._makeTab("Hold",!1),c.appendChild(this._setupTab),c.appendChild(this._holdTab),n.appendChild(c),this._pathTableContainer=document.createElement("div"),this._pathTableContainer.className="timing-path-table-container",this._pathTable=document.createElement("table"),this._pathTable.className="timing-table",this._pathTableContainer.appendChild(this._pathTable),n.appendChild(this._pathTableContainer);let u=document.createElement("div");u.className="timing-tab-bar",this._dataTab=this._makeTab("Data Path",!0),this._captureTab=this._makeTab("Capture Path",!1),u.appendChild(this._dataTab),u.appendChild(this._captureTab),n.appendChild(u),this._detailTableContainer=document.createElement("div"),this._detailTableContainer.className="timing-detail-table-container",this._detailTable=document.createElement("table"),this._detailTable.className="timing-table",this._detailTableContainer.appendChild(this._detailTable),n.appendChild(this._detailTableContainer),this._headerTooltip=document.createElement("div"),this._headerTooltip.className="or-tooltip or-tooltip-fixed",n.appendChild(this._headerTooltip),this.element=n,this._bindEvents(),la(this._app)&&setTimeout(()=>this.update(),0)}_makeTab(n,r){let c=document.createElement("button");return c.className="timing-tab"+(r?" active":""),c.textContent=n,c}_bindEvents(){this._setupTab.addEventListener("click",()=>{this._currentTab="setup",this._setupTab.classList.add("active"),this._holdTab.classList.remove("active"),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}),this._holdTab.addEventListener("click",()=>{this._currentTab="hold",this._holdTab.classList.add("active"),this._setupTab.classList.remove("active"),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}),this._dataTab.addEventListener("click",()=>{this._detailTab="data",this._dataTab.classList.add("active"),this._captureTab.classList.remove("active"),this._renderDetailTable()}),this._captureTab.addEventListener("click",()=>{this._detailTab="capture",this._captureTab.classList.add("active"),this._dataTab.classList.remove("active"),this._renderDetailTable()}),this._updateBtn.addEventListener("click",()=>this.update()),this._pathTableContainer.setAttribute("tabindex","0"),this._pathTableContainer.style.outline="none",this._pathTableContainer.addEventListener("keydown",n=>{if(n.key==="ArrowDown"){n.preventDefault();let r=this._pathTable.querySelectorAll("tbody tr");this._selectedPathIndex0&&this._selectPathRow(this._selectedPathIndex-1))}),this._detailTableContainer.setAttribute("tabindex","0"),this._detailTableContainer.style.outline="none",this._detailTableContainer.addEventListener("keydown",n=>{if(n.key==="ArrowDown"){n.preventDefault();let r=this._detailTable.querySelectorAll("tbody tr");this._selectedDetailIndex0&&this._selectDetailRow(this._selectedDetailIndex-1))})}_buildConePanel(){let n=document.createElement("div");n.className="timing-cone-panel";let r=document.createElement("span");r.className="timing-cone-title",r.textContent="Timing cone:",n.appendChild(r);let c=(T,M,L=!1)=>{let I=document.createElement("input");I.type="checkbox",I.id=T,I.checked=L;let D=document.createElement("label");return D.htmlFor=T,D.textContent=M,{input:I,lbl:D}},u=c("cone-fanin","Fanin",!0),d=c("cone-fanout","Fanout",!0);this._coneFanin=u.input,this._coneFanout=d.input,n.append(u.input,u.lbl,d.input,d.lbl);let b=T=>{let M=document.createElement("label");M.className="timing-cone-depth-label",M.textContent=T;let L=document.createElement("input");return L.type="number",L.min="0",L.value="0",L.className="timing-cone-depth",L.title="0 = unlimited",M.appendChild(L),{lbl:M,input:L}},w=b("in\u2264"),_=b("out\u2264");this._coneFaninDepth=w.input,this._coneFanoutDepth=_.input,n.append(w.lbl,_.lbl),this._coneColorMode=document.createElement("select"),this._coneColorMode.className="timing-cone-colormode";for(let[T,M]of[["slack","by slack"],["depth","by depth"]]){let L=document.createElement("option");L.value=T,L.textContent=M,this._coneColorMode.appendChild(L)}n.appendChild(this._coneColorMode);let x=c("cone-sync-schematic","Sync schematic");return this._coneSyncSchematic=x.input,n.append(x.input,x.lbl),this._coneApplyBtn=document.createElement("button"),this._coneApplyBtn.className="or-btn",this._coneApplyBtn.textContent="Cone",this._coneApplyBtn.title="Show the timing cone for the selected instance",this._coneClearBtn=document.createElement("button"),this._coneClearBtn.className="or-btn",this._coneClearBtn.textContent="Clear",n.append(this._coneApplyBtn,this._coneClearBtn),this._coneStatus=document.createElement("span"),this._coneStatus.className="timing-cone-status",n.appendChild(this._coneStatus),this._coneApplyBtn.addEventListener("click",()=>this._applyCone()),this._coneClearBtn.addEventListener("click",()=>this._clearCone()),n}_coneTarget(){return this._app.selectedInstanceName||""}async _applyCone(){let n=this._coneFanin.checked,r=this._coneFanout.checked;if(!n&&!r){this._coneStatus.textContent="select fanin and/or fanout";return}let c=this._coneTarget();if(!c){this._coneStatus.textContent="select an instance first";return}let u={type:"timing_cone",fanin:n,fanout:r,fanin_depth:Math.max(0,parseInt(this._coneFaninDepth.value,10)||0),fanout_depth:Math.max(0,parseInt(this._coneFanoutDepth.value,10)||0),color_mode:this._coneColorMode.value,inst_name:c};this._coneApplyBtn.disabled=!0,this._coneStatus.textContent="computing\u2026";try{let d=await this._app.websocketManager.request(u);this._refreshOverlay(),this._renderConeStatus(d),this._coneSyncSchematic.checked&&c&&document.dispatchEvent(new CustomEvent("openroad-cone-sync",{detail:{inst_name:c,fanin:u.fanin,fanout:u.fanout,fanin_depth:u.fanin_depth,fanout_depth:u.fanout_depth}}))}catch(d){this._coneStatus.textContent="cone error: "+(d.message||d)}this._coneApplyBtn.disabled=!1}_renderConeStatus(n){if(!n){this._coneStatus.textContent="";return}let r=n.node_count||0;if(r===0){this._coneStatus.textContent="empty cone";return}let c=r+" pins";if(n.color_mode==="depth")c+=`, depth \xB1${n.max_depth}`;else if(n.constrained){let u=n.time_unit||"";c+=`, slack ${lk(n.min_slack)}\u2026${lk(n.max_slack)}${u}`}else c+=", unconstrained";this._coneStatus.textContent=c}_clearCone(){this._app.websocketManager.request({type:"timing_cone",clear:!0}).then(()=>this._refreshOverlay()),this._coneStatus.textContent=""}showPaths(n,r){this._currentTab=n,n==="setup"?(this._setupPaths=[...r],this._setupTab.classList.add("active"),this._holdTab.classList.remove("active")):(this._holdPaths=[...r],this._holdTab.classList.add("active"),this._setupTab.classList.remove("active")),this._applySort(),this._selectedPathIndex=-1,this._pathCountLabel.textContent=r.length+" paths",this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...";try{let[n,r]=await Promise.all([this._app.websocketManager.request({type:"timing_report",is_setup:!0,max_paths:100}),this._app.websocketManager.request({type:"timing_report",is_setup:!1,max_paths:100})]);this._setupPaths=[...n.paths||[]],this._holdPaths=[...r.paths||[]],this._applySort(),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}catch(n){console.error("Timing fetch failed:",n)}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}_applySort(){for(let n of[this._setupPaths,this._holdPaths]){n.forEach((u,d)=>{u._originalIndex===void 0&&(u._originalIndex=d)});let r=this._sortAscending?1:-1,c=this._sortCol;n.sort((u,d)=>{let b=u[c],w=d[c],_=typeof b=="number"&&typeof w=="number"?b-w:String(b).localeCompare(String(w));return r*_})}}_showHeaderTooltip(n,r){if(n.buttons!==0){this._hideHeaderTooltip();return}let c=this._headerTooltip;c.textContent=r,c.style.display="block";let u=Math.min(n.clientX+12,window.innerWidth-c.offsetWidth-8);c.style.left=Math.max(0,u)+"px",c.style.top=n.clientY+14+"px"}_hideHeaderTooltip(){this._headerTooltip.style.display="none"}_sortBy(n){this._sortCol===n?this._sortAscending=!this._sortAscending:(this._sortCol=n,this._sortAscending=!0),this._applySort(),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}_clearTimingHighlight(){this._app.websocketManager.request({type:"timing_highlight",path_index:-1}).then(()=>this._refreshOverlay())}_selectPathRow(n){let r=this._pathTable.querySelectorAll("tbody tr");if(n<0||n>=r.length)return;this._selectedPathIndex=n;for(let d of r)d.classList.remove("selected");r[n].classList.add("selected"),r[n].scrollIntoView({block:"nearest"}),this._pathTableContainer.focus(),this._renderDetailTable();let u=(this._currentTab==="setup"?this._setupPaths:this._holdPaths)[n]?._originalIndex??n;this._app.websocketManager.request({type:"timing_highlight",path_index:u,is_setup:this._currentTab==="setup"}).then(()=>this._refreshOverlay()).catch(d=>console.error("timing_highlight error:",d))}_renderPathTable(){this._hideHeaderTooltip();let n=this._currentTab==="setup"?this._setupPaths:this._holdPaths;this._pathCountLabel.textContent=n.length+" paths";let r=this._pathTable.querySelectorAll("thead th"),c=Array.from(r,_=>_.style.width);this._pathTable.innerHTML="";let u=document.createElement("thead"),d=document.createElement("tr");for(let _ of s.PATH_COLS){let x=document.createElement("th");x.classList.add("sortable"),_.num&&x.classList.add("num"),x.textContent=_.label+(_.key===this._sortCol?this._sortAscending?" \u25B2":" \u25BC":""),_.tooltip&&(x.addEventListener("mousemove",T=>this._showHeaderTooltip(T,_.tooltip)),x.addEventListener("mouseleave",()=>this._hideHeaderTooltip())),x.addEventListener("click",()=>this._sortBy(_.key)),d.appendChild(x)}u.appendChild(d),this._pathTable.appendChild(u);let b=document.createElement("tbody"),w=n.reduce((_,x)=>Math.max(_,Math.abs(Number(x.slack)||0)),0);if(n.forEach((_,x)=>{let T=document.createElement("tr");x===this._selectedPathIndex&&T.classList.add("selected");for(let M of s.PATH_COLS){let L=document.createElement("td"),I=_[M.key];if(L.textContent=M.time?lk(I):I,M.num&&L.classList.add("num"),M.key==="slack"){let D=Number(_.slack);D<0&&L.classList.add("slack-negative"),Number.isFinite(D)&&w>0&&(L.classList.add("slack-cell",D<0?"slack-under":"slack-over"),L.style.setProperty("--slack-frac",String(Math.abs(D)/w)))}T.appendChild(L)}T.style.cursor="pointer",T.addEventListener("click",()=>this._selectPathRow(x)),b.appendChild(T)}),n.length===0){let _=document.createElement("tr"),x=document.createElement("td");x.colSpan=s.PATH_COLS.length,x.style.textAlign="center",x.style.color="var(--fg-secondary)",x.textContent=la(this._app)?"No timing data available":'Click "Update" to load timing paths',_.appendChild(x),b.appendChild(_)}this._pathTable.appendChild(b),ak(this._pathTable,c)}_selectDetailRow(n){let r=this._detailTable.querySelectorAll("tbody tr");if(n<0||n>=r.length)return;this._selectedDetailIndex=n;for(let w of r)w.classList.remove("timing-selected-row");r[n].classList.add("timing-selected-row"),r[n].scrollIntoView({block:"nearest"}),this._detailTableContainer.focus();let u=(this._currentTab==="setup"?this._setupPaths:this._holdPaths)[this._selectedPathIndex],d=this._detailTab==="data"?u.data_nodes:u.capture_nodes,b=u._originalIndex??this._selectedPathIndex;this._app.websocketManager.request({type:"timing_highlight",path_index:b,is_setup:this._currentTab==="setup",pin_name:d[n].pin}).then(()=>this._refreshOverlay())}_renderDetailTable(){let n=this._detailTable.querySelectorAll("thead th"),r=Array.from(n,x=>x.style.width);this._detailTable.innerHTML="",this._selectedDetailIndex=-1;let c=this._currentTab==="setup"?this._setupPaths:this._holdPaths;if(this._selectedPathIndex<0||this._selectedPathIndex>=c.length)return;let u=c[this._selectedPathIndex],d=this._detailTab==="data"?u.data_nodes:u.capture_nodes,b=document.createElement("thead"),w=document.createElement("tr");for(let x of s.DETAIL_COLS){let T=document.createElement("th");s.DETAIL_NUM_COLS.has(x)&&T.classList.add("num"),T.textContent=x,w.appendChild(T)}b.appendChild(w),this._detailTable.appendChild(b);let _=document.createElement("tbody");if(d.forEach((x,T)=>{let M=document.createElement("tr");x.clk&&M.classList.add("timing-clock-row"),[x.pin,x.fanout,x.rise?"\u2191":"\u2193",lk(x.time),lk(x.delay),lk(x.slew),lk(x.load)].forEach((I,D)=>{let F=document.createElement("td");s.DETAIL_NUM_COLS.has(s.DETAIL_COLS[D])&&F.classList.add("num"),F.textContent=I,M.appendChild(F)}),M.style.cursor="pointer",M.addEventListener("click",()=>this._selectDetailRow(T)),_.appendChild(M)}),this._detailTable.appendChild(_),ak(this._detailTable,r),!r[0]){let x=this._detailTable.querySelector("thead th");x&&(x.style.width="30ch")}}};function lk(s){return s==null?"":typeof s=="number"?s.toFixed(4):String(s)}uk.PATH_COLS=[{label:"Clock",key:"end_clk"},{label:"Required",key:"required",time:!0,num:!0},{label:"Arrival",key:"arrival",time:!0,num:!0},{label:"Slack",key:"slack",time:!0,num:!0},{label:"Skew",key:"skew",time:!0,num:!0,tooltip:`The difference in arrival times between source and destination clock pins of a macro/register, adjusted for CRPR and subtracting a clock period. -Setup and hold times account for internal clock delays.`},{label:"Logic Delay",key:"path_delay",time:!0,num:!0,tooltip:"Path delay from instances (excluding buffers and consecutive inverter pairs)"},{label:"Logic Depth",key:"logic_depth",num:!0,tooltip:"Path instances (excluding buffers and consecutive inverter pairs)"},{label:"Fanout",key:"fanout",num:!0},{label:"Start",key:"start_pin"},{label:"End",key:"end_pin"}];ak.DETAIL_COLS=["Pin","Fanout","R/F","Time","Delay","Slew","Load"];ak.DETAIL_NUM_COLS=new Set(["Fanout","Time","Delay","Slew","Load"]);function qf(d){let s=document.cookie.match("(?:^|; )"+d+"=([^;]*)");return s?s[1]:null}function Rd(d,s){document.cookie=d+"="+s+"; path=/; max-age=31536000; SameSite=Lax"}function tnt(d){document.cookie=d+"=; path=/; max-age=0; SameSite=Lax"}function ent(d){Rd("or_theme",d);try{window.localStorage.setItem("or_theme",d)}catch{}}function SJt(){tnt("or_theme");try{window.localStorage.removeItem("or_theme")}catch{}}function U2t(d){let s=document.getElementById("gl-theme-dark"),h=document.getElementById("gl-theme-light");!s||!h||(s.disabled=d!=="dark",h.disabled=d!=="light")}function TJt(d,s){pR(d)&&(document.documentElement.style.setProperty("--bg-map",d),Rd("or_bg_color",d),AJt(s),s.syncDisplayState())}function CJt(d){document.documentElement.style.removeProperty("--bg-map"),tnt("or_bg_color"),AJt(d),d.syncDisplayState()}function z2t(){return yJt(getComputedStyle(document.documentElement).getPropertyValue("--bg-map"))??"#000000"}function AJt(d){d.threeDViewerWidget?.render?.()}if(typeof document<"u"){let d=qf("or_theme")||typeof localStorage<"u"&&localStorage.getItem("or_theme")||(matchMedia("(prefers-color-scheme: light)").matches?"light":"dark");document.documentElement.dataset.theme=d,U2t(d);let s=qf("or_bg_color");pR(s)&&document.documentElement.style.setProperty("--bg-map",s)}function uk(){let d=getComputedStyle(document.documentElement),s=h=>d.getPropertyValue(h).trim();return{canvasBg:s("--canvas-bg"),canvasText:s("--canvas-text"),canvasAxis:s("--canvas-axis"),canvasLabel:s("--canvas-label"),canvasGrid:s("--canvas-grid"),canvasTitle:s("--canvas-title"),fgPrimary:s("--fg-primary"),fgMuted:s("--fg-muted"),bgPanel:s("--bg-panel"),bgMap:s("--bg-map"),fontMono:s("--font-mono"),fontSans:s("--font-sans")}}function lk(d,s){let h=document.createElement("a");h.href=d,h.download=s,document.body.appendChild(h),h.click(),h.remove()}function kJt(d,s){let h=URL.createObjectURL(d);lk(h,s),setTimeout(()=>URL.revokeObjectURL(h),1e3)}function j2t(d){let s=d.cloneNode(!0);if(s.getAttribute("xmlns")||s.setAttribute("xmlns","http://www.w3.org/2000/svg"),s.getAttribute("xmlns:xlink")||s.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),!s.getAttribute("width")||!s.getAttribute("height")){let h=d.viewBox&&d.viewBox.baseVal;h&&h.width&&h.height&&(s.setAttribute("width",h.width),s.setAttribute("height",h.height))}return` -`+new XMLSerializer().serializeToString(s)}function uke(d){let s=d.viewBox&&d.viewBox.baseVal;if(s&&s.width&&s.height)return{width:s.width,height:s.height};let h=parseFloat(d.getAttribute("width")),p=parseFloat(d.getAttribute("height"));if(h&&p)return{width:h,height:p};let m=d.getBoundingClientRect();return{width:m.width||800,height:m.height||600}}function H2t(d,s=2){let{width:h,height:p}=uke(d),m=j2t(d),_=new Blob([m],{type:"image/svg+xml;charset=utf-8"}),S=URL.createObjectURL(_);return new Promise((y,I)=>{let N=new Image;N.onload=()=>{let B=document.createElement("canvas");B.width=Math.max(1,Math.round(h*s)),B.height=Math.max(1,Math.round(p*s));let P=B.getContext("2d");P.fillStyle="#ffffff",P.fillRect(0,0,B.width,B.height),P.drawImage(N,0,0,B.width,B.height),URL.revokeObjectURL(S),y(B.toDataURL("image/png"))},N.onerror=B=>{URL.revokeObjectURL(S),I(B)},N.src=S})}async function nnt(d){try{if(!navigator.clipboard||!window.ClipboardItem)return!1;let s=await(await fetch(d)).blob();return await navigator.clipboard.write([new ClipboardItem({"image/png":s})]),!0}catch{return!1}}function lke(d){return(String(d||"").replace(/[^A-Za-z0-9._-]/g,"_").replace(/^_+|_+$/g,"")||"clock_tree")+".png"}var G2t=24,W2t=10,rnt=40,hke=40,$2t=70,fke=20,int={root:"#ff4444",buffer:"#4488ff",inverter:"#00b0b0",clock_gate:"#cc44cc",register:"#ff4444",macro:"#00b0b0",unknown:"#888888"};function dke(d){let s=parseInt(d.slice(1,3),16),h=parseInt(d.slice(3,5),16),p=parseInt(d.slice(5,7),16),m=S=>Math.round((S+255)/2),_=S=>S.toString(16).padStart(2,"0");return"#"+_(m(s))+_(m(h))+_(m(p))}function pke(d){let s=d.nodes;if(!s||s.length===0)return{layout:[],layoutWidth:0,layoutHeight:0,timeMin:0,timeMax:0,timeUnit:"",sceneHeight:0,layoutById:new Map};let h=new Map;for(let gt of s)h.set(gt.id,[]);for(let gt of s)gt.parent_id>=0&&h.has(gt.parent_id)&&h.get(gt.parent_id).push(gt.id);let p=new Map;for(let gt of s)p.set(gt.id,gt);let m=new Map,_=gt=>{let ft=h.get(gt)||[];if(ft.length===0)return m.set(gt,1),1;let xt=0;for(let Bt of ft)xt+=_(Bt);return m.set(gt,xt),xt},S=s.filter(gt=>gt.parent_id===-1),y=0;for(let gt of S)y+=_(gt.id);let I=d.min_arrival,N=d.max_arrival,B=N-I||1,P=Math.max(200,y*G2t*.6),U=[],j=(gt,ft)=>{let xt=p.get(gt),Bt=m.get(gt),Dt=$2t+(ft+Bt/2)*G2t,Pt=rnt+(xt.arrival-I)/B*P;U.push({id:xt.id,x:Dt,y:Pt,type:xt.type,name:xt.name,pin_name:xt.pin_name,arrival:xt.arrival,delay:xt.delay,fanout:xt.fanout,level:xt.level,parent_id:xt.parent_id});let se=ft,ot=h.get(gt)||[];for(let Lt of ot)j(Lt,se),se+=m.get(Lt)},V=0;for(let gt of S)j(gt.id,V),V+=m.get(gt.id);let et=$2t+y*G2t+fke,Q=rnt+P+hke,X=new Map;for(let gt of U)X.set(gt.id,gt);return{layout:U,layoutWidth:et,layoutHeight:Q,timeMin:I,timeMax:N,timeUnit:d.time_unit||"",sceneHeight:P,layoutById:X}}var snt=class{constructor(s,h,p,m){this._app=h,this._redrawAllLayers=p,this._refreshOverlay=m||p,this._clockData=[],this._selectedClockIdx=0,this._selectedNodeId=-1,this._tx=0,this._ty=0,this._scale=1,this._layout=[],this._dragging=!1,this._dragStartX=0,this._dragStartY=0,this._dragStartTx=0,this._dragStartTy=0,this._build(s)}_build(s){let h=document.createElement("div");h.className="clock-tree-widget";let p=document.createElement("div");p.className="clock-tree-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",Sc(this._app)&&(this._updateBtn.style.display="none"),this._fitBtn=document.createElement("button"),this._fitBtn.className="or-btn",this._fitBtn.textContent="Fit",this._pngBtn=document.createElement("button"),this._pngBtn.className="or-btn",this._pngBtn.textContent="PNG",this._pngBtn.title="Export the clock tree as a PNG image",this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",p.appendChild(this._updateBtn),p.appendChild(this._fitBtn),p.appendChild(this._pngBtn),p.appendChild(this._statusLabel),h.appendChild(p),this._tabBar=document.createElement("div"),this._tabBar.className="timing-tab-bar",h.appendChild(this._tabBar),this._canvas=document.createElement("canvas"),this._canvas.className="clock-tree-canvas",h.appendChild(this._canvas),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._tooltip.style.display="none",h.appendChild(this._tooltip),s.element.appendChild(h),this._el=h,this._ctx=this._canvas.getContext("2d"),this._bindEvents(),Sc(this._app)&&setTimeout(()=>this.update(),0)}_fit(){this._sizeCanvas(),this._fitToView(),this._render()}_pngFileName(){let s=this._clockData[this._selectedClockIdx];return lke(s&&s.name)}_exportPng(){try{lk(this._canvas.toDataURL("image/png"),this._pngFileName())}catch(s){console.error("PNG export failed:",s)}}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update()),this._fitBtn.addEventListener("click",()=>this._fit()),this._pngBtn.addEventListener("click",()=>this._exportPng()),this._canvas.addEventListener("keydown",s=>{s.key==="f"&&this._fit()}),this._canvas.tabIndex=0,this._canvas.addEventListener("wheel",s=>{s.preventDefault();let h=this._canvas.getBoundingClientRect(),p=s.clientX-h.left,m=s.clientY-h.top,_=s.deltaY<0?1.15:1/1.15;this._tx=p-(p-this._tx)*_,this._ty=m-(m-this._ty)*_,this._scale*=_,this._render()}),this._canvas.addEventListener("mousedown",s=>{this._dragging=!0,this._dragStartX=s.clientX,this._dragStartY=s.clientY,this._dragStartTx=this._tx,this._dragStartTy=this._ty,this._canvas.style.cursor="grabbing"}),window.addEventListener("mousemove",s=>{this._dragging?(this._tx=this._dragStartTx+(s.clientX-this._dragStartX),this._ty=this._dragStartTy+(s.clientY-this._dragStartY),this._render()):this._handleHover(s)}),window.addEventListener("mouseup",()=>{this._dragging&&(this._dragging=!1,this._canvas.style.cursor="grab")}),this._canvas.addEventListener("click",s=>this._handleClick(s)),this._resizeObserver=new ResizeObserver(()=>{this._sizeCanvas(),this._render()}),this._resizeObserver.observe(this._canvas)}_sizeCanvas(){let s=this._canvas.getBoundingClientRect(),h=window.devicePixelRatio||1;this._canvas.width=s.width*h,this._canvas.height=s.height*h,this._ctx.setTransform(h,0,0,h,0,0)}async update(){this._statusLabel.textContent="Loading...";try{let s=await this._app.websocketManager.request({type:"clock_tree"});this._clockData=s.clocks||[],this._buildTabs(),this._selectClock(0),this._statusLabel.textContent=this._clockData.length+" clock"+(this._clockData.length!==1?"s":"")}catch(s){console.error("Clock tree error:",s),this._statusLabel.textContent="Error: "+s.message}}_buildTabs(){this._tabBar.innerHTML="",this._clockData.forEach((s,h)=>{let p=document.createElement("button");p.className="timing-tab"+(h===this._selectedClockIdx?" active":""),p.textContent=s.name,p.addEventListener("click",()=>this._selectClock(h)),this._tabBar.appendChild(p)})}_selectClock(s){if(s<0||s>=this._clockData.length)return;this._selectedClockIdx=s,this._selectedNodeId=-1,this._tabBar.querySelectorAll(".timing-tab").forEach((p,m)=>{p.classList.toggle("active",m===s)}),this._computeLayout(this._clockData[s]),requestAnimationFrame(()=>{this._sizeCanvas(),this._fitToView(),this._render()})}_computeLayout(s){let h=pke(s);this._layout=h.layout,this._layoutWidth=h.layoutWidth,this._layoutHeight=h.layoutHeight,this._timeMin=h.timeMin,this._timeMax=h.timeMax,this._timeUnit=h.timeUnit,this._sceneHeight=h.sceneHeight,this._layoutById=h.layoutById}_fitToView(){if(!this._layout.length)return;let s=this._canvas.getBoundingClientRect(),h=s.width,p=s.height,m=h/this._layoutWidth,_=p/this._layoutHeight;this._scale=Math.min(m,_)*.9,this._tx=(h-this._layoutWidth*this._scale)/2,this._ty=(p-this._layoutHeight*this._scale)/2}render(){this._render()}_render(){let s=this._ctx,h=this._canvas.getBoundingClientRect(),p=h.width,m=h.height,_=uk();if(s.clearRect(0,0,p,m),s.fillStyle=_.canvasBg,s.fillRect(0,0,p,m),!this._layout.length){s.fillStyle=_.canvasText,s.font="14px "+_.fontSans,s.textAlign="center";let S=Sc(this._app)?"No clock tree data available":'Click "Update" to load clock tree data';s.fillText(S,p/2,m/2);return}s.save(),s.translate(this._tx,this._ty),s.scale(this._scale,this._scale),this._drawConnections(s);for(let S of this._layout)this._drawNode(s,S,S.id===this._selectedNodeId);s.restore(),this._drawTimeScale(s,p,m,_)}_drawConnections(s){let h=1.5/this._scale,p=W2t,m=this._timeMax-this._timeMin||1;for(let _ of this._layout){if(_.parent_id<0)continue;let S=this._layoutById.get(_.parent_id);if(!S)continue;let y=S.x,I=_.x,N=(S.delay||0)/m*this._sceneHeight,B=S.y+N,P=_.y,U=S.type==="root"?S.y:S.y+p;if(B>U){let V=int[S.type]||int.unknown;s.strokeStyle=V,s.lineWidth=h,s.beginPath(),s.moveTo(y,U),s.lineTo(y,B);let et=p/20;s.moveTo(y-et,B),s.lineTo(y+et,B),s.stroke()}s.strokeStyle="#006400",s.lineWidth=h;let j=(B+P)/2;s.beginPath(),s.moveTo(y,B),s.bezierCurveTo(y,j,I,j,I,P),s.stroke()}}_drawNode(s,h,p){let m=h.x,_=h.y,S=W2t,y=int[h.type]||int.unknown;switch(s.fillStyle=dke(y),s.strokeStyle=y,s.lineWidth=1/this._scale,h.type){case"root":{s.beginPath(),s.moveTo(m-S/2,_-S),s.lineTo(m+S/2,_-S),s.lineTo(m,_),s.closePath(),s.fill(),s.stroke();break}case"buffer":{s.beginPath(),s.moveTo(m-S/2,_),s.lineTo(m+S/2,_),s.lineTo(m,_+S),s.closePath(),s.fill(),s.stroke();break}case"inverter":{let I=S*.1,N=_+S-I;s.beginPath(),s.moveTo(m-S/2,_),s.lineTo(m+S/2,_),s.lineTo(m,N),s.closePath(),s.fill(),s.stroke(),s.beginPath(),s.arc(m,N+I/2,I/2,0,Math.PI*2),s.fill(),s.stroke();break}case"clock_gate":{s.beginPath(),s.arc(m,_+S/2,S/2,0,Math.PI*2),s.fill(),s.stroke();break}case"register":case"macro":{s.beginPath(),s.rect(m-S/2,_,S,S),s.fill(),s.stroke(),s.beginPath(),s.moveTo(m-S/8,_),s.lineTo(m+S/8,_),s.lineTo(m,_+S/4),s.closePath(),s.stroke();break}default:{s.beginPath(),s.arc(m,_+S/2,S/2,0,Math.PI*2),s.fill(),s.stroke();break}}if(p){s.strokeStyle="#ffff00",s.lineWidth=2/this._scale;let I=h.type==="root"?_-S/2:_+S/2;s.beginPath(),s.arc(m,I,S/2+3,0,Math.PI*2),s.stroke()}}_drawTimeScale(s,h,p,m){if(!this._sceneHeight)return;let _=et=>et*this._scale+this._ty,S=_(rnt),y=_(rnt+this._sceneHeight);if(y<0||S>p)return;s.save(),s.fillStyle=m.canvasLabel,s.strokeStyle=m.canvasAxis,s.font="11px "+m.fontMono,s.textAlign="right",s.textBaseline="middle";let I=this._timeMax-this._timeMin;if(I<=0){s.restore();return}let N=y-S,B=Math.max(2,Math.floor(N/40)),P=I/B,U=Math.pow(10,Math.floor(Math.log10(P))),j=U;P/U>5?j=10*U:P/U>2?j=5*U:P/U>1&&(j=2*U);let V=Math.ceil(this._timeMin/j)*j;s.beginPath();for(let et=V;et<=this._timeMax;et+=j){let Q=(et-this._timeMin)/I,X=S+Q*(y-S);s.moveTo(0,X),s.lineTo(h,X);let gt=et.toFixed(j<.01?3:j<.1?2:1)+" "+this._timeUnit;s.fillText(gt,$2t-4,X)}s.stroke(),s.restore()}_screenToLayout(s,h){return{x:(s-this._tx)/this._scale,y:(h-this._ty)/this._scale}}_hitTest(s,h){let p=this._screenToLayout(s,h),m=W2t;for(let _ of this._layout){let S=_.type==="root"?_.y-m:_.y,y=_.type==="root"?_.y:_.y+m;if(p.x>=_.x-m/2&&p.x<=_.x+m/2&&p.y>=S&&p.y<=y)return _}return null}_handleClick(s){let h=this._canvas.getBoundingClientRect(),p=s.clientX-h.left,m=s.clientY-h.top,_=this._hitTest(p,m);_?(this._selectedNodeId=_.id,this._render(),this._app.websocketManager.request({type:"clock_tree_highlight",inst_name:_.name}).then(()=>this._refreshOverlay())):this._selectedNodeId>=0&&(this._selectedNodeId=-1,this._render(),this._app.websocketManager.request({type:"clock_tree_highlight",inst_name:""}).then(()=>this._refreshOverlay()))}_handleHover(s){let h=this._canvas.getBoundingClientRect(),p=s.clientX-h.left,m=s.clientY-h.top;if(p<0||m<0||p>h.width||m>h.height){this._tooltip.style.display="none";return}let _=this._hitTest(p,m);if(_){let S=[_.name,"Type: "+_.type,"Arrival: "+_.arrival.toFixed(3)+" "+(this._timeUnit||"")];_.delay&&S.push("Delay: "+_.delay.toFixed(3)+" "+(this._timeUnit||"")),_.fanout&&S.push("Fanout: "+_.fanout),this._tooltip.textContent=S.join(` -`),this._tooltip.style.display="block",this._tooltip.style.left=s.clientX+12+"px",this._tooltip.style.top=s.clientY+12+"px"}else this._tooltip.style.display="none"}};var PJt=60,IJt=20,RJt=30,DJt=50,LJt=2,gke="#f08080",mke="#8b0000",bke="#90ee90",wke="#006400",hS=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7"],vke="rgba(240,128,128,0.12)",_ke="rgba(144,238,144,0.12)",yke="#ff9999",xke="#b0ffb0",Mke=[{value:"setup",label:"Setup Slack"},{value:"hold",label:"Hold Slack"},{value:"fanout",label:"Net Fanout"},{value:"netlength",label:"Net Length (HPWL)"}];function Eke(d,s,h,p){if(!d||!s||ps.bottom)return null;for(let m of d)if(h>=m.x&&h<=m.x+m.width)return m;return null}function Ske(d,s,h){return h?Math.log10(d+1)/Math.log10(s+1):d/s}function Tke(d,s,h,p={}){let m=!!p.logY,_=d?.bins;if(!_||_.length===0)return{bars:[],yMax:0,yTicks:[],chartArea:null,logY:m};let S=PJt,y=s-IJt,I=RJt,N=h-DJt,B=y-S,P=N-I;if(B<=0||P<=0)return{bars:[],yMax:0,yTicks:[],chartArea:null,logY:m};let U={left:S,right:y,top:I,bottom:N},j=0;for(let gt of _)gt.count>j&&(j=gt.count);j===0&&(j=1);let{yMax:V,yTicks:et}=m?Ake(j):Cke(j),Q=(B-LJt*(_.length-1))/_.length,X=[];for(let gt=0;gt<_.length;gt++){let ft=_[gt],xt=Ske(ft.count,V,m)*P;X.push({x:S+gt*(Q+LJt),y:N-xt,width:Q,height:xt,count:ft.count,lower:ft.lower,upper:ft.upper,negative:ft.negative})}return{bars:X,yMax:V,yTicks:et,chartArea:U,logY:m}}function Cke(d){if(d<=10){let N=[];for(let B=0;B<=d;B++)N.push(B);return{yMax:d,yTicks:N}}let h=d/8,p=Math.pow(10,Math.floor(Math.log10(h))),m=h/p,_;m<1.5?_=1:m<3?_=2:m<7?_=5:_=10;let S=_*p,y=Math.ceil(d/S)*S,I=[];for(let N=0;N<=y+S/2;N+=S)I.push(N);return{yMax:y,yTicks:I}}function Ake(d){let s=Math.max(1,Math.pow(10,Math.ceil(Math.log10(Math.max(1,d+1))))),h=[0];for(let p=1;p<=s+.5;p*=10)h.push(p);return{yMax:s,yTicks:h}}function kke(d,s){if(!s)return"";if(d==="generic"){let y=["x",...s.y_labels||[]].join(","),I=(s.points||[]).map(N=>[N.x,...N.ys||[]].join(","));return[y,...I].join(` -`)}let h=s.bins||[],p=Array.isArray(s.series)?s.series:[],m=["lower","upper","count",...p.map(S=>S.name||"group")].join(","),_=h.map((S,y)=>{let I=[S.lower,S.upper,S.count];for(let N of p)I.push(N.counts&&N.counts[y]||0);return I.join(",")});return[m,..._].join(` -`)}var ont=class{constructor(s,h){this._app=s,this._redrawAllLayers=h,this._currentTab="setup",this._histogramData=null,this._bars=[],this._yMax=0,this._yTicks=[],this._chartArea=null,this._hoveredBar=null,this._debugCharts=[],this._activeDebugChart=-1,this._build()}_build(){let s=document.createElement("div");s.className="charts-widget";let h=document.createElement("div");h.className="charts-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",Sc(this._app)&&(this._updateBtn.style.display="none"),this._chartSelect=document.createElement("select"),this._chartSelect.className="charts-select",this._csvBtn=document.createElement("button"),this._csvBtn.className="or-btn",this._csvBtn.textContent="CSV",this._csvBtn.title="Export the current chart data as CSV",this._pngBtn=document.createElement("button"),this._pngBtn.className="or-btn",this._pngBtn.textContent="PNG",this._pngBtn.title="Export the current chart as a PNG image",this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",h.appendChild(this._updateBtn),h.appendChild(this._chartSelect),h.appendChild(this._csvBtn),h.appendChild(this._pngBtn),h.appendChild(this._statusLabel),s.appendChild(h);let p=document.createElement("div");p.className="charts-toolbar";let m=document.createElement("span");m.textContent="Path Groups:",m.style.color="var(--fg-muted)",m.style.fontSize="var(--fs-12)",this._pathGroupSelect=document.createElement("select"),this._pathGroupSelect.className="charts-select",this._pathGroupSelect.multiple=!0,this._pathGroupSelect.size=1,this._pathGroupSelect.title="Select 0 = all, or \u22651 to stack by group";let _=document.createElement("span");_.textContent="Clock:",_.style.color="var(--fg-muted)",_.style.fontSize="var(--fs-12)",this._clockSelect=document.createElement("select"),this._clockSelect.className="charts-select",this._clockSelect.innerHTML='',p.appendChild(m),p.appendChild(this._pathGroupSelect),p.appendChild(_),p.appendChild(this._clockSelect),s.appendChild(p),this._canvas=document.createElement("canvas"),this._canvas.className="charts-canvas",s.appendChild(this._canvas),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._tooltip.style.display="none",s.appendChild(this._tooltip),this._filterRow=p,this.element=s,this._ctx=this._canvas.getContext("2d"),this._rebuildSelect(),this._bindEvents(),Sc(this._app)&&setTimeout(()=>this.update(),0)}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update()),this._chartSelect.addEventListener("change",()=>this._onSelectChange()),this._csvBtn.addEventListener("click",()=>this._exportCsv()),this._pngBtn.addEventListener("click",()=>this._exportPng()),this._pathGroupSelect.addEventListener("change",()=>this._fetchHistogram()),this._clockSelect.addEventListener("change",()=>this._fetchHistogram()),this._canvas.addEventListener("mousemove",h=>this._handleHover(h)),this._canvas.addEventListener("mouseleave",()=>{this._hoveredBar=null,this._tooltip.style.display="none",this._syncView()}),this._canvas.addEventListener("click",h=>this._handleClick(h)),this._canvas.addEventListener("dblclick",h=>this._handleDblClick(h)),new ResizeObserver(()=>this._syncView()).observe(this._canvas)}_sizeCanvas(){let s=this._canvas.getBoundingClientRect(),h=window.devicePixelRatio||1;this._canvas.width=s.width*h,this._canvas.height=s.height*h,this._ctx.setTransform(h,0,0,h,0,0)}_rebuildSelect(){let s=this._chartSelect;s.innerHTML="";for(let h of Mke){let p=document.createElement("option");p.value=h.value,p.textContent=h.label,s.appendChild(p)}this._debugCharts.forEach((h,p)=>{let m=document.createElement("option");m.value="gen:"+p,m.textContent=h.name||"Chart "+p,s.appendChild(m)}),s.value=this._activeDebugChart>=0?"gen:"+this._activeDebugChart:this._currentTab}_onSelectChange(){let s=this._chartSelect.value;s.startsWith("gen:")?(this._activeDebugChart=parseInt(s.slice(4),10)||0,this._hoveredBar=null,this._tooltip.style.display="none",this._syncView()):this._selectTab(s)}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...",this._statusLabel.textContent="";try{this._activeDebugChart<0?((this._currentTab==="setup"||this._currentTab==="hold")&&await this._fetchFilters(),await Promise.all([this._fetchHistogram(),this._fetchGenericCharts()])):await this._fetchGenericCharts()}catch(s){this._statusLabel.textContent="Error: "+s.message}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}async _fetchFilters(){let s=await this._app.websocketManager.request({type:"chart_filters"});this._populatePathGroups(s.path_groups||[]),this._populateClocks(s.clocks||[])}_populatePathGroups(s){let h=new Set(Array.from(this._pathGroupSelect.selectedOptions,p=>p.value));this._pathGroupSelect.innerHTML="";for(let p of s){let m=document.createElement("option");m.value=p,m.textContent=p,m.selected=h.has(p),this._pathGroupSelect.appendChild(m)}}_populateClocks(s){let h=this._clockSelect.value;this._clockSelect.innerHTML='';for(let p of s){let m=document.createElement("option");m.value=p,m.textContent=p,this._clockSelect.appendChild(m)}s.includes(h)&&(this._clockSelect.value=h)}async _fetchGenericCharts(){try{let s=await this._app.websocketManager.request({type:"debug_charts"});this.setDebugCharts(s.charts||[])}catch{}}async _fetchHistogram(){try{let s=this._currentTab,h;if(s==="fanout")h={type:"fanout_histogram"};else if(s==="netlength")h={type:"net_length_histogram",use_dbu:!!this._app.showDbu};else{h={type:"slack_histogram",is_setup:s==="setup"};let m=Array.from(this._pathGroupSelect.selectedOptions,_=>_.value).filter(Boolean);m.length>0&&(h.path_groups=m),this._clockSelect.value&&(h.clock_name=this._clockSelect.value)}let p=await this._app.websocketManager.request(h);if(this._currentTab!==s)return;if(this._histogramData=p,this._syncView(),s==="fanout"||s==="netlength"){let m=p.total_nets||0;this._statusLabel.textContent=`${m} nets`}else{let m=p.total_endpoints||0,_=p.unconstrained_count||0,S=m-_;this._statusLabel.textContent=`${S} endpoints`+(_>0?`, ${_} unconstrained`:"")}}catch(s){this._statusLabel.textContent="Error: "+s.message}}_selectTab(s){this._currentTab===s&&this._activeDebugChart<0||(this._currentTab=s,this._activeDebugChart=-1,this._chartSelect&&(this._chartSelect.value=s),this._filterRow.style.display=s==="setup"||s==="hold"?"":"none",this._hoveredBar=null,this._tooltip.style.display="none",this.update())}_computeLayout(){if(!this._histogramData)return;let s=this._canvas.getBoundingClientRect(),h=Tke(this._histogramData,s.width,s.height,{logY:this._currentTab==="fanout"});this._bars=h.bars,this._yMax=h.yMax,this._yTicks=h.yTicks,this._chartArea=h.chartArea,this._logY=!!h.logY}render(){this._syncView()}_stackedSeries(){let s=this._histogramData?.series;return Array.isArray(s)&&s.length>1?s:null}_render(){let s=this._canvas.getBoundingClientRect(),h=s.width,p=s.height,m=this._ctx,_=uk();if(m.clearRect(0,0,h,p),m.fillStyle=_.canvasBg,m.fillRect(0,0,h,p),!this._bars||this._bars.length===0){m.fillStyle=_.canvasText,m.font="14px "+_.fontSans,m.textAlign="center",m.textBaseline="middle";let S=Sc(this._app)?"No histogram data available":'Click "Update" to load histogram';m.fillText(S,h/2,p/2);return}this._drawAxes(m,_),this._drawBars(m),this._drawTitle(m,h,_),this._stackedSeries()&&this._drawSeriesLegend(m,_)}_drawAxes(s,h){let p=this._chartArea;if(!p)return;s.strokeStyle=h.canvasAxis,s.lineWidth=1,s.beginPath(),s.moveTo(p.left,p.top),s.lineTo(p.left,p.bottom),s.stroke(),s.beginPath(),s.moveTo(p.left,p.bottom),s.lineTo(p.right,p.bottom),s.stroke(),s.fillStyle=h.canvasLabel,s.font="11px "+h.fontMono,s.textAlign="right",s.textBaseline="middle";let m=p.bottom-p.top;for(let U of this._yTicks){let j=this._logY?Math.log10(U+1)/Math.log10(this._yMax+1):U/this._yMax,V=p.bottom-j*m;s.fillText(this._formatCount(U),p.left-6,V),U>0&&(s.strokeStyle=h.canvasGrid,s.beginPath(),s.moveTo(p.left,V),s.lineTo(p.right,V),s.stroke(),s.strokeStyle=h.canvasAxis)}let _=this._currentTab,S=_==="fanout"||_==="netlength";s.save(),s.translate(14,(p.top+p.bottom)/2),s.rotate(-Math.PI/2),s.textAlign="center",s.textBaseline="middle",s.fillStyle=h.canvasTitle,s.font="11px "+h.fontMono,s.fillText(this._logY?"Nets (log)":S?"Nets":"Endpoints",0,0),s.restore(),s.textAlign="center",s.textBaseline="top",s.fillStyle=h.canvasLabel,s.font="10px "+h.fontMono;let y=this._histogramData.bins,I=this._histogramData.time_unit||this._histogramData.length_unit||"",N=y.length>0?y[0].upper-y[0].lower:1,B=_==="fanout"?0:Math.max(0,-Math.floor(Math.log10(N)));for(let U=0;U<=this._bars.length;U++){let j=U=0){this._hoveredBar=null,this._tooltip.style.display="none";return}let h=this._hitTestBar(s);if(h!==this._hoveredBar&&(this._hoveredBar=h,this._render()),h){let p=this._currentTab,m=h.upper-h.lower;if(p==="fanout"){let U=h.upper-1,j=h.lower===U?`${h.lower}`:`[${h.lower}, ${U}]`;this._tooltip.textContent=`Nets: ${h.count} -Fanout: ${j}`}else if(p==="netlength"){let U=this._histogramData?.length_unit||"",j=Math.max(0,-Math.floor(Math.log10(m)));this._tooltip.textContent=`Nets: ${h.count} -Length: [${h.lower.toFixed(j)}, ${h.upper.toFixed(j)}) ${U}`}else{let U=this._histogramData?.time_unit||"",j=Math.max(0,-Math.floor(Math.log10(m)));this._tooltip.textContent=`Endpoints: ${h.count} -Slack: [${h.lower.toFixed(j)}, ${h.upper.toFixed(j)}) ${U}`}this._tooltip.style.display="block";let _=this.element.getBoundingClientRect(),S=this._tooltip.getBoundingClientRect(),y=4,I=s.clientX-_.left,N=s.clientY-_.top,B=I+12;B+S.width>_.width-y&&(B=I-12-S.width),B=Math.max(y,B);let P=N-10;P=Math.min(_.height-S.height-y,Math.max(y,P)),this._tooltip.style.left=B+"px",this._tooltip.style.top=P+"px"}else this._tooltip.style.display="none"}async _handleClick(s){if(this._activeDebugChart>=0||this._currentTab==="fanout"||this._currentTab==="netlength")return;let h=this._hitTestBar(s);if(!(!h||h.count===0))try{let p=await this._app.websocketManager.request({type:"timing_report",is_setup:this._currentTab==="setup",max_paths:50,slack_min:h.lower,slack_max:h.upper});this._app.timingWidget&&(this._app.timingWidget.showPaths(this._currentTab,p.paths||[]),this._app.focusComponent&&this._app.focusComponent("TimingWidget"))}catch(p){console.error("Charts bar click error:",p)}}async _handleDblClick(s){if(this._activeDebugChart>=0)return;let h;if(this._currentTab==="fanout")h="select_fanout_bin";else if(this._currentTab==="netlength")h="select_net_length_bin";else return;let p=this._hitTestBar(s);if(!p||p.count===0)return;let m=bg(this._app);try{let _=await this._app.websocketManager.request({type:h,lower:p.lower,upper:p.upper,use_dbu:this._app.showDbu});if(!D0(this._app,m))return;_&&_.truncated&&console.warn(`Bin has ${_.count} nets; selection capped at ${_.selection_limit} for performance.`),this._app.updateInspector&&this._app.updateInspector(_),this._app.focusComponent&&this._app.focusComponent("Inspector"),this._redrawAllLayers&&this._redrawAllLayers()}catch(_){console.error("Net bin select failed:",_)}}_activeChartData(){return this._activeDebugChart>=0?{kind:"generic",data:this._debugCharts[this._activeDebugChart]}:{kind:"histogram",data:this._histogramData}}_chartBaseName(){return this._activeDebugChart>=0?this._debugCharts[this._activeDebugChart].name||"chart":this._currentTab}_triggerDownload(s,h,{revoke:p=!1}={}){let m=document.createElement("a");m.href=h,m.download=s,document.body.appendChild(m),m.click(),m.remove(),p&&URL.revokeObjectURL(h)}_download(s,h,p){try{let m=URL.createObjectURL(new Blob([p],{type:h}));this._triggerDownload(s,m,{revoke:!0})}catch(m){console.error("Download failed:",m)}}_exportCsv(){let{kind:s,data:h}=this._activeChartData();if(!h)return;let p=kke(s,h);this._download(this._chartBaseName()+".csv","text/csv",p)}_exportPng(){try{let s=this._canvas.toDataURL("image/png");this._triggerDownload(this._chartBaseName()+".png",s)}catch(s){console.error("PNG export failed:",s)}}setDebugCharts(s){this._debugCharts=s,s.length===0?this._activeDebugChart=-1:this._activeDebugChart>=s.length&&(this._activeDebugChart=0),this._rebuildSelect(),this._syncView()}_syncView(){let s=this._activeDebugChart>=0;s&&(this._hoveredBar=null,this._tooltip.style.display="none");let h=!s&&(this._currentTab==="setup"||this._currentTab==="hold");this._filterRow&&(this._filterRow.style.display=h?"":"none"),this._sizeCanvas(),s?this._renderLineChart(this._debugCharts[this._activeDebugChart]):(this._computeLayout(),this._render())}_renderLineChart(s){let h=this._canvas.getBoundingClientRect(),p=h.width,m=h.height,_=this._ctx,S=uk();_.clearRect(0,0,p,m),_.fillStyle=S.canvasBg,_.fillRect(0,0,p,m);let y=s.points;if(!y||y.length===0){_.fillStyle=S.canvasText,_.font="14px "+S.fontSans,_.textAlign="center",_.textBaseline="middle",_.fillText("No data points yet",p/2,m/2);return}let I=s.y_labels?s.y_labels.length:1,N=PJt,B=p-IJt,P=RJt,U=m-DJt,j=B-N,V=U-P;if(j<=0||V<=0)return;let et=y[0].x,Q=y[0].x,X=1/0,gt=-1/0;for(let Pt of y){Pt.xQ&&(Q=Pt.x);for(let se of Pt.ys)segt&&(gt=se)}et===Q&&(Q=et+1),(!isFinite(X)||!isFinite(gt))&&(X=0,gt=1);let ft=(gt-X)*.05||1;X-=ft,gt+=ft;let xt=Pt=>N+(Pt-et)/(Q-et)*j,Bt=Pt=>U-(Pt-X)/(gt-X)*V;_.strokeStyle=S.canvasAxis,_.lineWidth=1,_.beginPath(),_.moveTo(N,P),_.lineTo(N,U),_.lineTo(B,U),_.stroke(),_.fillStyle=S.canvasLabel,_.font="10px "+S.fontMono,_.textAlign="right",_.textBaseline="middle";let Dt=5;for(let Pt=0;Pt<=Dt;Pt++){let se=X+(gt-X)*Pt/Dt,ot=Bt(se);_.fillText(this._formatNum(se),N-4,ot),Pt>0&&Pt1&&s.y_labels){_.font="10px "+S.fontMono,_.textAlign="left",_.textBaseline="top";let Pt=N+8,se=P+4;for(let ot=0;ot=1e6?(s/1e6).toFixed(1)+"M":h>=1e3?(s/1e3).toFixed(1)+"k":h>=1?s.toFixed(1):s.toPrecision(3)}_formatCount(s){return s===0?"0":s>=1e6?s/1e6+"M":s>=1e3?s/1e3+"k":String(s)}};var Qw=class{constructor(s){this.onChange=s,this.roots=[],this._nodeMap=new Map}addFromSpec(s,h=null){let p=this._makeNode(s.id,h,s);if(p.checked=s.checked!==!1,s.children){for(let m of s.children)p.children.push(this.addFromSpec(m,p));p.hasCheckbox&&this._computeParent(p)}return h||this.roots.push(p),p}buildFromNodes(s){this._nodeMap.clear(),this.roots=[];for(let h of s)this._makeNode(h.id,null,h);for(let h of s){let p=this._nodeMap.get(h.id);if(h.parentId!=null&&this._nodeMap.has(h.parentId)){let m=this._nodeMap.get(h.parentId);p.parent=m,m.children.push(p)}else this.roots.push(p)}for(let h=s.length-1;h>=0;h--){let p=this._nodeMap.get(s[h].id);p.hasCheckbox&&p.children.length>0&&this._computeParent(p)}return this.roots}get(s){return this._nodeMap.get(s)}isVisible(s){let h=this.get(s);return h?h.checked:!1}check(s,h){let p=this._nodeMap.get(s);if(p){p.checked=h,p.indeterminate=!1;for(let m of p.children)this._setSubtree(m,h);for(let m=p.parent;m;m=m.parent)m.hasCheckbox&&this._computeParent(m);this.onChange()}}cascadeQuiet(s,h){let p=this._nodeMap.get(s);if(p){p.checked=h,p.indeterminate=!1;for(let m of p.children)this._setSubtree(m,h);for(let m=p.parent;m;m=m.parent)m.hasCheckbox&&this._computeParent(m)}}checkSet(s){for(let[h,p]of Object.entries(s)){let m=this._nodeMap.get(h);m&&(m.checked=p,m.indeterminate=!1)}this._recomputeAllParents(),this.onChange()}mirrorStates(s){this._applyMirror(s),this.onChange()}mirrorStatesQuiet(s){this._applyMirror(s)}_applyMirror(s){for(let[h,p]of Object.entries(s)){let m=this._nodeMap.get(h);m&&(m.checked=!!p.checked,m.indeterminate=!!p.indeterminate)}}forEach(s){let h=p=>{s(p);for(let m of p.children)h(m)};for(let p of this.roots)h(p)}_makeNode(s,h,p){let m={id:s,parent:h,children:[],hasCheckbox:p.hasCheckbox!==!1,checked:p.checked!==!1,indeterminate:!1,data:p.data!=null?p.data:p};return this._nodeMap.set(s,m),m}_checkboxDescendants(s){let h=[];for(let p of s.children)p.hasCheckbox?h.push(p):h.push(...this._checkboxDescendants(p));return h}_computeParent(s){let h=this._checkboxDescendants(s);if(h.length===0)return;let p=h.every(_=>_.checked&&!_.indeterminate),m=h.every(_=>!_.checked&&!_.indeterminate);s.checked=p,s.indeterminate=!p&&!m}_setSubtree(s,h){s.hasCheckbox&&(s.checked=h,s.indeterminate=!1);for(let p of s.children)this._setSubtree(p,h)}_recomputeAllParents(){let s=h=>{for(let p of h.children)s(p);h.hasCheckbox&&h.children.length>0&&this._computeParent(h)};for(let h of this.roots)s(h)}};var NJt=["Instance","Module","Instances","Macros","Modules","Area","Local Inst","Local Macros","Local Modules"],fS={MODULE:0,LEAF_GROUP:1,TYPE_GROUP:2,INSTANCE:3,NAME_GROUP:4};function hk(d){return d===fS.MODULE||d===fS.NAME_GROUP}var cnt=class{constructor(s,h,p){this._app=h,this._redrawAllLayers=p,this._nodes=[],this._nameGrouped=!1,this._nameGroupsCapped=!1,this._rows=[],this._childrenMap=new Map,this._collapsed=new Set,this._moduleState=new Map,this._checkModel=null,this._build(s),h.hierarchyBrowser=this,Sc(h)&&this.update()}_build(s){let h=document.createElement("div");h.className="hierarchy-widget";let p=document.createElement("div");p.className="timing-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",Sc(this._app)&&(this._updateBtn.style.display="none"),this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",p.appendChild(this._updateBtn),p.appendChild(this._statusLabel),h.appendChild(p),this._tableContainer=document.createElement("div"),this._tableContainer.className="hierarchy-table-container",this._table=document.createElement("table"),this._table.className="timing-table",this._tableContainer.appendChild(this._table),h.appendChild(this._tableContainer),s.element.appendChild(h),this._bindEvents()}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update())}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...",this._statusLabel.textContent="";try{let s=await this._app.websocketManager.request({type:"module_hierarchy"});this._nodes=s.nodes||[],this._nameGrouped=!!s.name_grouped,this._nameGroupsCapped=!!s.name_groups_capped,this._buildTree(),this._readServerColors(),this._computeEffectiveColors(),this._render(),this._statusLabel.textContent=this._statusText(),await this._sendModuleColors()}catch(s){this._statusLabel.textContent="Error: "+s.message}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}_statusText(){let s=this._nodes.filter(m=>hk(m.node_kind||0)).length;if(!this._nameGrouped)return s+" modules";let p=Math.max(0,s-1)+" groups from instance names \u2014 this design has no module hierarchy";return this._nameGroupsCapped&&(p+=" (truncated: too many groups)"),p}_buildTree(){this._childrenMap.clear(),this._collapsed.clear();for(let h of this._nodes)this._childrenMap.set(h.id,[]);for(let h of this._nodes)h.parent_id>=0&&this._childrenMap.has(h.parent_id)&&this._childrenMap.get(h.parent_id).push(h.id);this._nodeMap=new Map;for(let h of this._nodes)this._nodeMap.set(h.id,h);for(let h of this._nodes){let p=this._childrenMap.get(h.id);if(!p||p.length===0)continue;let m=h.node_kind||0;m===fS.LEAF_GROUP||m===fS.TYPE_GROUP?this._collapsed.add(h.id):hk(m)&&h.parent_id>=0&&this._collapsed.add(h.id)}this._rows=[];let s=this._nodes.filter(h=>h.parent_id<0);for(let h of s)this._dfs(h.id,0);this._checkModel=new Qw(()=>{this._checkModel.forEach(h=>{if(!h.hasCheckbox)return;let p=this._moduleState.get(h.data.odb_id);p&&(p.visible=h.checked)}),this._sendModuleColors()}),this._checkModel.buildFromNodes(this._nodes.map(h=>({id:h.id,parentId:h.parent_id,hasCheckbox:hk(h.node_kind||0)&&h.odb_id!=null,checked:!0,data:h})))}_readServerColors(){this._moduleState.clear();for(let s of this._rows){let h=this._nodeMap.get(s.id);if(!h||!hk(h.node_kind||0)||h.odb_id==null)continue;let p=h.color||[128,128,128];this._moduleState.set(h.odb_id,{color:p,effectiveColor:p,visible:!0,nodeId:h.id})}}_computeEffectiveColors(){for(let s of this._rows){let h=this._nodeMap.get(s.id);if(!h||!hk(h.node_kind||0))continue;let p=this._moduleState.get(h.odb_id);if(!p)continue;let m=h.parent_id,_=null;for(;m>=0;){let S=this._nodeMap.get(m);if(!S)break;if(hk(S.node_kind||0)){let y=this._moduleState.get(S.odb_id);y&&this._collapsed.has(S.id)&&(_=y.effectiveColor)}m=S.parent_id}p.effectiveColor=_||p.color}}async _sendModuleColors(){let s=[];for(let[p,m]of this._moduleState){if(!m.visible)continue;let[_,S,y]=m.effectiveColor;s.push(`${p}:${_},${S},${y},100`)}let h=s.join(";");try{let p=await this._app.websocketManager.request({type:"set_module_colors",colors:h});console.log("set_module_colors:",p.count,"modules,",s.length,"sent")}catch(p){console.error("set_module_colors failed:",p)}this._redrawAllLayers()}_dfs(s,h){this._rows.push({id:s,depth:h});let p=this._childrenMap.get(s)||[];for(let m of p)this._dfs(m,h+1)}_render(){this._table.innerHTML="";let s=document.createElement("thead"),h=document.createElement("tr");for(let m of NJt){let _=document.createElement("th");_.textContent=m,h.appendChild(_)}s.appendChild(h),this._table.appendChild(s);let p=document.createElement("tbody");for(let m of this._rows){let _=this._nodeMap.get(m.id);if(!_||this._isHidden(_))continue;let S=document.createElement("tr"),y=_.node_kind||0,N=(this._childrenMap.get(m.id)||[]).length>0,B=this._collapsed.has(m.id);y===fS.LEAF_GROUP||y===fS.TYPE_GROUP?(S.style.fontStyle="italic",S.style.color="var(--fg-disabled)"):y===fS.INSTANCE?S.style.color="var(--fg-secondary)":y===fS.NAME_GROUP&&(S.classList.add("hierarchy-name-group"),S.title="Recovered from instance names \u2014 this design has no module hierarchy");let P=document.createElement("td");if(P.style.paddingLeft=8+m.depth*16+"px",P.style.whiteSpace="nowrap",hk(y)&&_.odb_id!=null){let V=this._moduleState.get(_.odb_id),et=this._checkModel?this._checkModel.get(_.id):null;if(V&&et){let Q=document.createElement("input");Q.type="checkbox",Q.checked=et.checked,Q.indeterminate=et.indeterminate,Q.className="hierarchy-module-cb",et.cb=Q,Q.addEventListener("change",Bt=>{Bt.stopPropagation(),this._checkModel.check(_.id,Q.checked),this._render()}),P.appendChild(Q);let X=document.createElement("span");X.className="hierarchy-color-swatch";let[gt,ft,xt]=V.effectiveColor;X.style.backgroundColor=`rgb(${gt},${ft},${xt})`,P.appendChild(X)}}if(N){let V=document.createElement("span");V.className="hierarchy-arrow",V.textContent=B?"\u25B6":"\u25BC",V.addEventListener("click",et=>{et.stopPropagation(),this._toggleNode(m.id)}),P.appendChild(V)}else{let V=document.createElement("span");V.className="hierarchy-arrow",V.style.visibility="hidden",V.textContent="\u25B6",P.appendChild(V)}let U=document.createElement("span");U.textContent=_.inst_name,P.appendChild(U),S.appendChild(P);let j=[_.module_name,mR(_.insts),mR(_.macros),mR(_.modules),this._fmtArea(_.area),mR(_.local_insts),mR(_.local_macros),mR(_.local_modules)];for(let V of j){let et=document.createElement("td");et.textContent=V,et.style.textAlign="right",S.appendChild(et)}S.children[1].style.textAlign="left",p.appendChild(S)}if(this._rows.length===0){let m=document.createElement("tr"),_=document.createElement("td");_.colSpan=NJt.length,_.style.textAlign="center",_.style.color="var(--fg-secondary)",_.textContent=Sc(this._app)?"No hierarchy data available":'Click "Update" to load hierarchy',m.appendChild(_),p.appendChild(m)}this._table.appendChild(p),ok(this._table)}_isHidden(s){let h=s.parent_id;for(;h>=0;){if(this._collapsed.has(h))return!0;let p=this._nodeMap.get(h);if(!p)break;h=p.parent_id}return!1}_toggleNode(s){this._collapsed.has(s)?this._collapsed.delete(s):this._collapsed.add(s),this._computeEffectiveColors(),this._render(),this._sendModuleColors()}_fmtArea(s){if(s==null)return"";if(this._app.showDbu){let h=this._app.getDbuPerMicron();return String(Math.round(s*h*h))}return s>=1e6?(s/1e6).toFixed(3)+" mm\xB2":s.toFixed(3)+" \u03BCm\xB2"}};function mR(d){return d!=null?String(d):""}var Lke='',Pke='',Ike='',Rke='',Dke='',Nke='',Oke='',Bke='',Fke='',Uke='',zke='',jke='';function OJt(d,s,h){h=h||s;let p=null,m=null,_=null,S=!1,y=10;function I(Kt,wn){return S?Promise.resolve():(S=!0,d.websocketManager.request({type:"set_property",name:Kt,use_dbu:d.showDbu,...wn}).then(it=>{!it.ok&&it.error&&Jw(it.error),ki(it),it.ok&&it.bbox&&ln(it.bbox)}).catch(it=>{console.error("set_property failed:",it),Jw("Edit failed: "+it),p&&ki(p)}).finally(()=>{S=!1}))}function N(Kt,wn){let it=document.createElement("select");it.className="inspector-editor-select";let ut=Kt.editor.type==="bool"?["True","False"]:Kt.editor.options||[];for(let kt of ut){let Ot=document.createElement("option");Ot.value=kt,Ot.textContent=kt,kt===Kt.value&&(Ot.selected=!0),it.appendChild(Ot)}if(!ut.includes(Kt.value)){let kt=document.createElement("option");kt.value=Kt.value||"",kt.textContent=Kt.value||"",kt.selected=!0,kt.disabled=!0,it.insertBefore(kt,it.firstChild)}return it.addEventListener("change",()=>{if(wn.onPropertyChange){wn.onPropertyChange(Kt.name,it.value);return}if(Kt.editor.type==="bool")wn.onPropertyEdit(Kt,{value:it.value==="True"});else{let kt=(Kt.editor.options||[]).indexOf(it.value);wn.onPropertyEdit(Kt,{option_index:kt,option_name:it.value})}}),it}async function B(Kt,wn){if(!S&&!(Kt==="Delete"&&!await lJt({title:"Delete "+(wn.type||"object"),message:"Delete "+(wn.type||"object")+' "'+(wn.name||"")+'"? This cannot be undone.',confirmLabel:"Delete",danger:!0}))){S=!0;try{let it=await d.websocketManager.request({type:"trigger_action",name:Kt,use_dbu:d.showDbu});!it.ok&&it.error&&Jw(it.error),ki(it.properties?it:null),it.deleted&&d.highlightRect&&d.map&&(d.map.removeLayer(d.highlightRect),d.highlightRect=null),gt(),h()}catch(it){console.error("trigger_action failed:",it),Jw("Action failed: "+it)}finally{S=!1}}}function P(Kt){d.websocketManager.request({...Kt,use_dbu:d.showDbu}).then(wn=>{!wn.ok&&wn.error&&Jw(wn.error),ki(wn),h()}).catch(wn=>{console.error(Kt.type+" failed:",wn)})}function U(){let Kt=document.getElementById("highlight-picker");Kt&&Kt.remove()}function j(Kt,wn){U();let it=d.techData?.highlight_colors||[];if(!it.length)return;let ut=document.createElement("div");ut.id="highlight-picker";let kt=document.createElement("div");if(kt.className="highlight-swatch-grid",it.forEach((rn,Pn)=>{let Tt=document.createElement("button");Tt.className="highlight-swatch",Tt.title="Group "+(Pn+1),Tt.style.backgroundColor=`rgb(${rn[0]}, ${rn[1]}, ${rn[2]})`,Pn===wn.highlight_group&&Tt.classList.add("active"),Tt.addEventListener("click",()=>{U(),P({type:"highlight",group:Pn})}),kt.appendChild(Tt)}),ut.appendChild(kt),wn.highlight_group>=0){let rn=document.createElement("button");rn.className="highlight-remove",rn.textContent="Remove highlight",rn.addEventListener("click",()=>{U(),P({type:"unhighlight"})}),ut.appendChild(rn)}document.body.appendChild(ut);let Ot=Kt.getBoundingClientRect();ut.style.left=Ot.left+"px",ut.style.top=Ot.bottom+4+"px";let ie=rn=>{rn.type==="keydown"&&rn.key!=="Escape"||rn.type==="mousedown"&&ut.contains(rn.target)||(U(),document.removeEventListener("mousedown",ie,!0),document.removeEventListener("keydown",ie,!0))};setTimeout(()=>{document.addEventListener("mousedown",ie,!0),document.addEventListener("keydown",ie,!0)},0)}function V(){if(!d.inspectorEl)return;d.inspectorEl.innerHTML="";let Kt=document.createElement("div");Kt.className="stub-panel",Kt.innerHTML='
Loading\u2026
Fetching properties from server.
',d.inspectorEl.appendChild(Kt)}async function et(Kt){let wn=d.focusNets.has(Kt)?"remove":"add";wn==="add"?d.focusNets.add(Kt):d.focusNets.delete(Kt);try{await d.websocketManager.request({type:"set_focus_nets",action:wn,net_name:Kt})}catch(it){console.error("set_focus_nets failed:",it)}s(),p&&ki(p)}async function Q(){d.focusNets.clear();try{await d.websocketManager.request({type:"set_focus_nets",action:"clear",net_name:""})}catch(Kt){console.error("set_focus_nets clear failed:",Kt)}s(),p&&ki(p)}async function X(Kt){let wn=d.routeGuideNets.has(Kt)?"remove":"add";wn==="add"?d.routeGuideNets.add(Kt):d.routeGuideNets.delete(Kt);try{await d.websocketManager.request({type:"set_route_guides",action:wn,net_name:Kt})}catch(it){console.error("set_route_guides failed:",it)}h(),p&&ki(p)}function gt(){d.hoverHighlightLayer&&(d.map.removeLayer(d.hoverHighlightLayer),d.hoverHighlightLayer=null)}function ft(){gt(),d.websocketManager.request({type:"hover",select_id:-1}).then(()=>{}).catch(()=>{})}function xt(Kt,wn,it,ut){let kt=L.latLngBounds(Vf(Kt,wn,it,ut,d.designScale,d.designMaxDXDY,d.designOriginX,d.designOriginY));if(!d.map)return kt;let Ot=kt.getSouthWest(),ie=kt.getNorthEast(),rn=d.map.latLngToContainerPoint(Ot),Pn=d.map.latLngToContainerPoint(ie),Tt=Math.min(rn.x,Pn.x),yt=Math.max(rn.x,Pn.x),ue=Math.min(rn.y,Pn.y),fn=Math.max(rn.y,Pn.y),An=Tt,zn=yt,Li=ue,xi=fn;if(yt-TtL.rectangle(xt(wn,it,ut,kt),{color:"#ffe85c",weight:3,fill:!0,fillColor:"#fff27a",fillOpacity:.14,opacity:1,interactive:!1,className:"hover-highlight",pane:d.hoverHighlightPane}))).addTo(d.map))}function Dt(Kt,wn){Kt.classList.add("inspector-link"),Kt.addEventListener("click",it=>{it.stopPropagation(),se(wn)}),Kt.addEventListener("mouseenter",()=>{_!==null&&(d.websocketManager.cancel(_),_=null);let it=d.websocketManager.request({type:"hover",select_id:wn});_=it.requestId,it.then(ut=>{_=null,Bt(ut.rects||[]),h()}).catch(()=>{_=null})}),Kt.addEventListener("mouseleave",()=>{ft(),h()})}function Pt(Kt){let wn=Kt>0?"select_next":"select_prev";m!==null&&(d.websocketManager.cancel(m),m=null),V();let it=bg(d),ut=d.websocketManager.request({type:wn,use_dbu:d.showDbu});m=ut.requestId,ut.then(kt=>{if(m=null,!!D0(d,it)){if(kt.error){console.error("Selection cycle error:",kt.error),ki(p);return}if(ki(kt),kt.type==="Inst"&&kt.name&&(d.selectedInstanceName=kt.name,d.schematicWidget&&d.schematicWidget.refresh()),d.map&&d.map.closePopup(),gt(),d.highlightRect&&d.map&&(d.map.removeLayer(d.highlightRect),d.highlightRect=null),kt.bbox&&d.map&&d.designScale){let[Ot,ie,rn,Pn]=kt.bbox;kt.type!=="Inst"&&Lt(Ot,ie,rn,Pn,kt.type),kt.selection_count>1?re(kt.bbox):ln(kt.bbox,kt.type)}s()}}).catch(kt=>{m=null,console.error("Selection cycle failed:",kt),ki(p)})}function se(Kt){m!==null&&(d.websocketManager.cancel(m),m=null),V();let wn=bg(d),it=d.websocketManager.request({type:"inspect",select_id:Kt,use_dbu:d.showDbu});m=it.requestId,it.then(ut=>{if(m=null,!!D0(d,wn)){if(ut.error){console.error("Inspect error:",ut.error);return}if(ki(ut),d.map.closePopup(),gt(),d.highlightRect&&(d.map.removeLayer(d.highlightRect),d.highlightRect=null),ut.bbox&&d.map&&d.designScale){let[kt,Ot,ie,rn]=ut.bbox;ut.type!=="Inst"&&Lt(kt,Ot,ie,rn,ut.type),ln(ut.bbox,ut.type)}h()}}).catch(ut=>{m=null,console.error("Inspect failed:",ut)})}function ot(){m!==null&&(d.websocketManager.cancel(m),m=null),V();let Kt=bg(d),wn=d.websocketManager.request({type:"inspect_back",use_dbu:d.showDbu});m=wn.requestId,wn.then(it=>{if(m=null,!!D0(d,Kt)){if(it.error){console.error("Inspect back error:",it.error);return}if(ki(it),d.map.closePopup(),gt(),d.highlightRect&&(d.map.removeLayer(d.highlightRect),d.highlightRect=null),it.bbox&&d.map&&d.designScale){if(it.type!=="Inst"){let[ut,kt,Ot,ie]=it.bbox;Lt(ut,kt,Ot,ie,it.type)}ln(it.bbox,it.type)}h()}}).catch(it=>{m=null,console.error("Inspect back failed:",it)})}function Lt(Kt,wn,it,ut,kt){if(d.highlightRect&&(d.map.removeLayer(d.highlightRect),d.highlightRect=null),kt==="Net")return;let Ot=Vf(Kt,wn,it,ut,d.designScale,d.designMaxDXDY,d.designOriginX,d.designOriginY);d.highlightRect=L.rectangle(Ot,{color:"#ff0",weight:2,fill:!1,dashArray:"6,4"}),d.visibility&&d.visibility.highlight_selected===!1||d.highlightRect.addTo(d.map)}let be=null;function ln(Kt,wn){if(!Kt||!d.map||!d.designScale||(ne!==null&&xe(),be&&(d.map.removeLayer(be),be=null),d.visibility&&d.visibility.highlight_selected===!1)||wn==="Net")return;let[it,ut,kt,Ot]=Kt,ie=Vf(it,ut,kt,Ot,d.designScale,d.designMaxDXDY,d.designOriginX,d.designOriginY);be=L.rectangle(ie,{color:"#ff0",weight:3,fill:!0,fillColor:"#ff0",fillOpacity:.25,opacity:1,interactive:!1,className:"selection-pulse",pane:d.hoverHighlightPane}).addTo(d.map);let rn=be;setTimeout(()=>{rn&&d.map&&d.map.hasLayer(rn)&&d.map.removeLayer(rn),be===rn&&(be=null)},1100)}let Fn=null,ne=null;function xe(){ne!==null&&(clearInterval(ne),ne=null),Fn&&(d.map&&d.map.hasLayer(Fn)&&d.map.removeLayer(Fn),Fn=null)}function re(Kt,{repeats:wn=6,intervalMs:it=300}={}){if(!Kt||!d.map||!d.designScale)return;if(xe(),typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches){ln(Kt);return}let[ut,kt,Ot,ie]=Kt,rn=Vf(ut,kt,Ot,ie,d.designScale,d.designMaxDXDY,d.designOriginX,d.designOriginY);Fn=L.rectangle(rn,{color:"#ff0",weight:1,fill:!0,fillColor:"#ff0",fillOpacity:.39,opacity:1,interactive:!1,pane:d.hoverHighlightPane}).addTo(d.map);let Pn=0,Tt=wn>0?wn*3:1/0;ne=setInterval(()=>{if(Pn+=1,Pn>=Tt){xe();return}let yt=Pn%3+1;Fn.setStyle({weight:yt,fillOpacity:yt===1?.39:0})},it)}d.clearSelectionPulse=function(){be&&(d.map.removeLayer(be),be=null)};function hn(Kt,wn,it){let ut=document.createElement("div");ut.className="inspector-group";let kt=document.createElement("div");kt.className="inspector-group-header";let Ot=document.createElement("span");Ot.className="vis-arrow";let ie=document.createElement("span");if(ie.className="inspector-prop-name",ie.textContent=Kt,ie.title=Kt,kt.appendChild(Ot),kt.appendChild(ie),wn!==null){let Pn=document.createElement("span");Pn.className="inspector-count",Pn.textContent=`(${wn})`,kt.appendChild(Pn)}ut.appendChild(kt);let rn=document.createElement("div");return rn.className="inspector-group-children"+(it?" collapsed":""),Ot.textContent=it?"\u25B6":"\u25BC",ut.appendChild(rn),kt.addEventListener("click",()=>{rn.classList.toggle("collapsed"),Ot.textContent=rn.classList.contains("collapsed")?"\u25B6":"\u25BC"}),{group:ut,header:kt,arrow:Ot,body:rn}}function Se(Kt){let wn=Kt.column_headers||[],it=Kt.row_headers||[],ut=Kt.data||[],kt=wn.some(Pn=>Pn!==""),Ot=it.some(Pn=>Pn!==""),ie=document.createElement("table");if(ie.className="inspector-table",kt){let Pn=document.createElement("thead"),Tt=document.createElement("tr");Ot&&Tt.appendChild(document.createElement("th"));for(let yt of wn){let ue=document.createElement("th");ue.textContent=yt,Tt.appendChild(ue)}Pn.appendChild(Tt),ie.appendChild(Pn)}let rn=document.createElement("tbody");return ut.forEach((Pn,Tt)=>{let yt=document.createElement("tr");if(Ot){let ue=document.createElement("th");ue.textContent=it[Tt]||"",yt.appendChild(ue)}for(let ue of Pn){let fn=document.createElement("td");fn.textContent=ue,yt.appendChild(fn)}rn.appendChild(yt)}),ie.appendChild(rn),ie}function ke(Kt,wn){if(Kt.table){let ie=(Kt.table.data||[]).length,{group:rn,body:Pn}=hn(Kt.name,ie,ie>=10),Tt=document.createElement("div");return Tt.className="inspector-table-scroll",Tt.appendChild(Se(Kt.table)),Pn.appendChild(Tt),rn}if(Kt.children){let ie=Kt.children.length<10,{group:rn,body:Pn}=hn(Kt.name,Kt.children.length,!ie);for(let Tt of Kt.children)Pn.appendChild(ke(Tt,wn));return rn}let it=document.createElement("div");it.className="inspector-prop";let ut=document.createElement("span");ut.className="inspector-prop-name",ut.textContent=Kt.name||"",ut.title=Kt.name||"";let kt=document.createElement("span");kt.className="inspector-prop-value",kt.textContent=Kt.value||"",it.appendChild(ut),it.appendChild(kt);let Ot=Kt.editable&&wn&&(wn.onPropertyEdit||wn.onPropertyChange)&&Kt.editor&&(Kt.editor.type==="list"||Kt.editor.type==="bool");if(Ot&&Kt.value_select_id===void 0)it.replaceChild(N(Kt,wn),kt);else if(Ot){let ie=document.createElement("button");ie.className="inspector-edit-btn",ie.title="Edit "+Kt.name,ie.textContent="\u270E",ie.addEventListener("click",rn=>{rn.stopPropagation();let Pn=N(Kt,wn);it.replaceChild(Pn,kt),ie.remove(),Pn.focus()}),it.appendChild(ie)}else Kt.editable&&wn&&(wn.onPropertyChange||wn.onPropertyEdit)&&(kt.contentEditable=!0,kt.classList.add("inspector-editable"),kt.addEventListener("blur",()=>{let ie=kt.textContent;if(ie!==Kt.value){if(wn.onPropertyChange){wn.onPropertyChange(Kt.name,ie);return}if(Kt.editor&&Kt.editor.type==="number"){let rn=Number(ie);if(ie.trim()===""||Number.isNaN(rn)){Jw("Not a number: "+ie),kt.textContent=Kt.value;return}wn.onPropertyEdit(Kt,{value:rn});return}wn.onPropertyEdit(Kt,{value:ie})}}),kt.addEventListener("keydown",ie=>{ie.key==="Enter"&&(ie.preventDefault(),kt.blur()),ie.key==="Escape"&&(kt.textContent=Kt.value,kt.blur())}));return Kt.name_select_id!==void 0&&Kt.value_select_id===void 0?(Dt(it,Kt.name_select_id),ut.classList.add("inspector-link")):Kt.name_select_id!==void 0&&Dt(ut,Kt.name_select_id),Kt.value_select_id!==void 0&&Dt(kt,Kt.value_select_id),it}let mn=140,en=60,Qn=500,ge=mn;function Pe(){d.inspectorEl&&d.inspectorEl.style.setProperty("--inspector-name-w",ge+"px")}function ti(){let Kt=document.createElement("div");return Kt.className="inspector-col-resizer",Kt.title="Drag to resize the name column",Kt.addEventListener("mousedown",wn=>{wn.preventDefault();let it=wn.clientX,ut=ge;Kt.classList.add("dragging");let kt=ie=>{ge=Math.max(en,Math.min(Qn,ut+ie.clientX-it)),Pe()},Ot=()=>{Kt.classList.remove("dragging"),document.removeEventListener("mousemove",kt),document.removeEventListener("mouseup",Ot)};document.addEventListener("mousemove",kt),document.addEventListener("mouseup",Ot)}),Kt}function Yi(Kt){if(!Kt||!d.map||!d.designScale)return;let[wn,it,ut,kt]=Kt;d.map.fitBounds(Vf(wn,it,ut,kt,d.designScale,d.designMaxDXDY,d.designOriginX,d.designOriginY),{padding:[20,20]})}function ki(Kt){if(!d.inspectorEl)return;if(p=Kt,d.inspectorEl.innerHTML="",!Kt||!Kt.properties||Kt.properties.length===0){xe();let kt=document.createElement("div");kt.className="stub-panel",kt.innerHTML='
Inspector
Select an object in the layout to inspect its properties.
',d.inspectorEl.appendChild(kt);return}if(!Kt.onPropertyChange&&!Kt.onPropertyEdit&&!Sc(d)&&(Kt.onPropertyEdit=(kt,Ot)=>I(kt.name,Ot)),Kt){let kt=document.createElement("div");kt.className="inspector-toolbar";let Ot=document.createElement("button");if(Ot.className="or-btn or-btn-icon",Ot.title="Back",Ot.innerHTML=Rke,Ot.disabled=!Kt.can_navigate_back,Ot.addEventListener("click",()=>ot()),kt.appendChild(Ot),Kt.bbox){let ie=document.createElement("button");ie.className="or-btn or-btn-icon",ie.title="Zoom to",ie.innerHTML=Ike,ie.addEventListener("click",()=>Yi(Kt.bbox)),kt.appendChild(ie)}if(Kt.type==="Net"&&Kt.name){let ie=d.focusNets.has(Kt.name),rn=document.createElement("button");rn.className="or-btn or-btn-icon",rn.title=ie?"De-focus net":"Focus net",rn.innerHTML=ie?Nke:Dke,rn.addEventListener("click",()=>et(Kt.name)),kt.appendChild(rn)}if(Kt.type==="Net"&&Kt.name&&Kt.has_guides){let ie=d.routeGuideNets.has(Kt.name),rn=document.createElement("button");rn.className="or-btn or-btn-icon",rn.title=ie?"Hide route guides":"Show route guides",rn.innerHTML=ie?Bke:Oke,rn.addEventListener("click",()=>X(Kt.name)),kt.appendChild(rn)}if(Kt.type==="Net"&&Kt.name&&d.showInsertBufferDialog){let ie=document.createElement("button");ie.className="or-btn or-btn-icon",ie.title="Insert buffer",ie.innerHTML=jke,ie.addEventListener("click",()=>d.showInsertBufferDialog(Kt.name)),kt.appendChild(ie)}if(d.focusNets.size>0){let ie=document.createElement("button");ie.className="or-btn or-btn-icon",ie.title="Clear focus nets",ie.innerHTML=Fke,ie.addEventListener("click",()=>Q()),kt.appendChild(ie)}if(typeof Kt.highlight_group=="number"&&!Sc(d)&&(d.techData?.highlight_colors||[]).length){let ie=document.createElement("button");ie.className="or-btn or-btn-icon inspector-highlight-btn";let rn=Kt.highlight_group;if(ie.title=rn>=0?"Highlight group "+(rn+1):"Add to highlight group",ie.innerHTML=Pke,rn>=0){let Pn=d.techData.highlight_colors[rn];ie.style.backgroundColor=`rgba(${Pn[0]}, ${Pn[1]}, ${Pn[2]}, 0.45)`,ie.style.borderColor=`rgb(${Pn[0]}, ${Pn[1]}, ${Pn[2]})`}ie.addEventListener("click",()=>j(ie,Kt)),kt.appendChild(ie)}if(Array.isArray(Kt.actions)&&!Sc(d))for(let ie of Kt.actions){let rn=document.createElement("button");rn.className="or-btn inspector-action-btn",rn.title=ie,ie==="Delete"?(rn.classList.add("or-btn-icon","or-btn-danger-hover"),rn.innerHTML=Lke):(rn.classList.add("or-btn-sm"),rn.textContent=ie),rn.addEventListener("click",()=>B(ie,Kt)),kt.appendChild(rn)}d.inspectorEl.appendChild(kt)}let wn=Kt.selection_count||0,it=typeof Kt.selection_index=="number"?Kt.selection_index:-1;if(wn>1&&it>=0){let kt=document.createElement("div");kt.className="inspector-selection-nav";let Ot=document.createElement("button");Ot.className="or-btn or-btn-icon",Ot.title="Previous (Shift+click to multi-select)",Ot.innerHTML=Uke,Ot.addEventListener("click",()=>Pt(-1));let ie=document.createElement("span");ie.className="inspector-selection-label",ie.textContent=it+1+" / "+wn;let rn=document.createElement("button");rn.className="or-btn or-btn-icon",rn.title="Next",rn.innerHTML=zke,rn.addEventListener("click",()=>Pt(1)),kt.appendChild(Ot),kt.appendChild(ie),kt.appendChild(rn),d.inspectorEl.appendChild(kt)}let ut=document.createElement("div");ut.className="inspector-rows";for(let kt of Kt.properties)ut.appendChild(ke(kt,Kt));ut.appendChild(ti()),d.inspectorEl.appendChild(ut),Pe()}function lr(Kt){let wn=document.createElement("div");wn.className="inspector",d.inspectorEl=wn,Kt.element.appendChild(wn),ki(null)}function pr(){if(p){if(p.type==="Ruler"){d.rulerManager&&d.rulerManager._selectedRulerId!==null&&d.rulerManager._selectRuler(d.rulerManager._selectedRulerId);return}d.websocketManager&&se(-1)}}return{createInspector:lr,updateInspector:ki,highlightBBox:Lt,pulseHighlight:ln,animateSelection:re,stopSelectionAnimation:xe,navigateInspector:se,refreshInspector:pr}}var ant=class{constructor(s,h,p){this._app=h,this._refreshOverlay=p||(()=>{}),this._data={selection:[],groups:[],truncated:!1},this._tab="selected",this._filter="",this._sortKey=null,this._sortAsc=!0,this._pendingRefresh=null,this._inFlight=!1,this._staleWhileInFlight=!1,this._visible=!0,this._el=document.createElement("div"),this._el.className="selection-browser",s.element.appendChild(this._el),s.on?.("show",()=>{this._visible=!0,this.refresh()}),s.on?.("hide",()=>{this._visible=!1}),s.on?.("destroy",()=>{this._visible=!1,this._staleWhileInFlight=!1,this._pendingRefresh!==null&&(clearTimeout(this._pendingRefresh),this._pendingRefresh=null)}),this._render(),this.refresh()}scheduleRefresh(){!this._visible||this._pendingRefresh!==null||(this._pendingRefresh=setTimeout(()=>{this._pendingRefresh=null,this.refresh()},150))}refresh(){if(!this._visible||Sc(this._app))return;if(this._inFlight){this._staleWhileInFlight=!0;return}this._inFlight=!0;let s=()=>{this._inFlight=!1,this._staleWhileInFlight&&(this._staleWhileInFlight=!1,this.refresh())};this._app.websocketManager.request({type:"list_selection"}).then(h=>{h.ok&&(this._data=h,this._render()),s()}).catch(s)}_entries(){let s;this._tab==="selected"?s=(this._data.selection||[]).map((p,m)=>({row:p,index:m,group:-1})):s=(this._data.groups||[]).flatMap((p,m)=>p.map((_,S)=>({row:_,index:S,group:m})));let h=this._filter.trim().toLowerCase();if(h&&(s=s.filter(({row:p})=>(p.name||"").toLowerCase().includes(h)||(p.type||"").toLowerCase().includes(h))),this._sortKey){let p=this._sortKey,m=this._sortAsc?1:-1;s=s.slice().sort((_,S)=>m*String(_.row[p]||"").localeCompare(String(S.row[p]||"")))}return s}_fmtCoord(s){if(this._app.showDbu)return String(s);let h=this._app.getDbuPerMicron?this._app.getDbuPerMicron():1e3;return(s/h).toFixed(3)}_fmtBounds(s){if(!s)return"";let[h,p,m,_]=s;return`(${this._fmtCoord(h)}, ${this._fmtCoord(p)}), (${this._fmtCoord(m)}, ${this._fmtCoord(_)})`}_inspectRow(s,h){let p=s.group<0?{type:"inspect_selection",index:s.index,use_dbu:this._app.showDbu}:{type:"inspect_group",group:s.group,index:s.index,use_dbu:this._app.showDbu};this._app.websocketManager.request(p).then(m=>{if(!m.ok){this.refresh();return}this._app.updateInspector&&this._app.updateInspector(m),h&&this._app.focusComponent&&this._app.focusComponent("Inspector"),this._refreshOverlay()}).catch(()=>{})}_deselectRow(s){this._app.websocketManager.request({type:"deselect",index:s.index}).then(()=>{this.refresh(),this._refreshOverlay()}).catch(()=>{})}_clearHighlights(){this._app.websocketManager.request({type:"clear_highlights",group:-1}).then(()=>{this.refresh(),this._refreshOverlay(),this._app.refreshInspector&&this._app.refreshInspector()}).catch(()=>{})}_zoomToBBox(s){if(!s||!this._app.designScale||!this._app.map)return;let[h,p,m,_]=s,S=this._app.getDbuPerMicron?this._app.getDbuPerMicron():1e3,y=Math.min(10*S,2*Math.max(m-h,_-p));this._app.map.fitBounds(Vf(h-y,p-y,m+y,_+y,this._app.designScale,this._app.designMaxDXDY,this._app.designOriginX,this._app.designOriginY))}_render(){this._app.stopSelectionAnimation&&this._app.stopSelectionAnimation(),this._el.innerHTML="";let s=(this._data.selection||[]).length,h=(this._data.groups||[]).reduce((S,y)=>S+y.length,0),p=document.createElement("div");p.className="sb-tabs";for(let[S,y,I]of[["selected","Selected",s],["highlighted","Highlighted",h]]){let N=document.createElement("button");N.className="sb-tab"+(this._tab===S?" active":""),N.textContent=`${y} (${I})`,N.addEventListener("click",()=>{this._tab=S,this._render()}),p.appendChild(N)}let m=document.createElement("button");if(m.className="or-btn or-btn-sm sb-tool",m.title="Refresh",m.textContent="\u27F3",m.addEventListener("click",()=>this.refresh()),p.appendChild(m),this._tab==="highlighted"&&h>0){let S=document.createElement("button");S.className="or-btn or-btn-sm sb-tool",S.title="Clear all highlights",S.textContent="Clear",S.addEventListener("click",()=>this._clearHighlights()),p.appendChild(S)}this._el.appendChild(p);let _=document.createElement("input");if(_.type="text",_.className="sb-filter",_.placeholder="Filter by name or type\u2026",_.value=this._filter,_.addEventListener("input",()=>{this._filter=_.value,this._renderTable()}),this._el.appendChild(_),this._data.truncated){let S=document.createElement("div");S.className="sb-truncated",S.textContent="List truncated \u2014 showing the first 1000 entries per set.",this._el.appendChild(S)}this._tableWrap=document.createElement("div"),this._tableWrap.className="sb-table-wrap",this._el.appendChild(this._tableWrap),this._renderTable()}_renderTable(){this._tableWrap.innerHTML="";let s=this._entries();if(!s.length){let I=document.createElement("div");I.className="sb-empty",I.textContent=this._tab==="selected"?"Nothing selected.":"Nothing highlighted.",this._tableWrap.appendChild(I);return}let h=document.createElement("table");h.className="sb-table";let p=document.createElement("thead"),m=document.createElement("tr"),_=[["name","Object"],["type","Type"],[null,"Bounds"]];this._tab==="highlighted"&&_.push([null,"Group"]),_.push([null,""]);for(let[I,N]of _){let B=document.createElement("th");B.textContent=N,I&&(B.classList.add("sb-sortable"),this._sortKey===I&&(B.textContent+=this._sortAsc?" \u25B2":" \u25BC"),B.addEventListener("click",()=>{this._sortKey===I?this._sortAsc=!this._sortAsc:(this._sortKey=I,this._sortAsc=!0),this._renderTable()})),m.appendChild(B)}p.appendChild(m),h.appendChild(p);let S=document.createElement("tbody"),y=this._app.techData?.highlight_colors||[];for(let I of s){let N=document.createElement("tr");N.className="sb-row";let B=document.createElement("td");B.textContent=I.row.name||"";let P=document.createElement("td");P.textContent=I.row.type||"";let U=document.createElement("td");if(U.textContent=this._fmtBounds(I.row.bbox),N.appendChild(B),N.appendChild(P),N.appendChild(U),this._tab==="highlighted"){let V=document.createElement("td"),et=document.createElement("span");et.className="sb-chip";let Q=y[I.group];Q&&(et.style.backgroundColor=`rgb(${Q[0]}, ${Q[1]}, ${Q[2]})`),V.appendChild(et),V.appendChild(document.createTextNode(` Group ${I.group+1}`)),N.appendChild(V)}let j=document.createElement("td");if(j.className="sb-actions",I.row.bbox){let V=document.createElement("button");V.className="sb-row-btn",V.title="Zoom to",V.textContent="\u2316",V.addEventListener("click",et=>{et.stopPropagation(),this._zoomToBBox(I.row.bbox)}),j.appendChild(V)}if(this._tab==="selected"){let V=document.createElement("button");V.className="sb-row-btn",V.title="De-select",V.textContent="\u2715",V.addEventListener("click",et=>{et.stopPropagation(),this._deselectRow(I)}),j.appendChild(V)}N.appendChild(j),N.addEventListener("click",()=>this._inspectRow(I,!1)),N.addEventListener("dblclick",()=>this._inspectRow(I,!0)),I.row.bbox&&(N.addEventListener("mouseenter",()=>{this._app.animateSelection&&this._app.animateSelection(I.row.bbox,{repeats:0})}),N.addEventListener("mouseleave",()=>{this._app.stopSelectionAnimation&&this._app.stopSelectionAnimation()})),S.appendChild(N)}h.appendChild(S),this._tableWrap.appendChild(h),ok(h)}};var FJt="options-dialog",BJt=[{label:"System default",value:""},{label:"Sans-serif",value:"sans-serif"},{label:"Serif",value:"serif"},{label:"Monospace",value:"monospace"},{label:"Helvetica / Arial",value:"Helvetica, Arial, sans-serif"},{label:"Georgia",value:"Georgia, 'Times New Roman', serif"},{label:"Courier",value:"'Courier New', Courier, monospace"}],Hke=100,unt=70,lnt=200;function UU(d){let s=d===""||d===null?NaN:Math.round(Number(d));return Number.isFinite(s)?Math.min(lnt,Math.max(unt,s)):Hke}function UJt(d){let{overlay:s,close:h,okBtn:p,showError:m}=gR("Arrow keys scroll step",` +Setup and hold times account for internal clock delays.`},{label:"Logic Delay",key:"path_delay",time:!0,num:!0,tooltip:"Path delay from instances (excluding buffers and consecutive inverter pairs)"},{label:"Logic Depth",key:"logic_depth",num:!0,tooltip:"Path instances (excluding buffers and consecutive inverter pairs)"},{label:"Fanout",key:"fanout",num:!0},{label:"Start",key:"start_pin"},{label:"End",key:"end_pin"}];uk.DETAIL_COLS=["Pin","Fanout","R/F","Time","Delay","Slew","Load"];uk.DETAIL_NUM_COLS=new Set(["Fanout","Time","Delay","Slew","Load"]);function pf(s){let n=document.cookie.match("(?:^|; )"+s+"=([^;]*)");return n?n[1]:null}function Ff(s,n){document.cookie=s+"="+n+"; path=/; max-age=31536000; SameSite=Lax"}function Vhe(s){document.cookie=s+"=; path=/; max-age=0; SameSite=Lax"}function Whe(s){Ff("or_theme",s);try{window.localStorage.setItem("or_theme",s)}catch{}}function e3t(){Vhe("or_theme");try{window.localStorage.removeItem("or_theme")}catch{}}function H5e(s){let n=document.getElementById("gl-theme-dark"),r=document.getElementById("gl-theme-light");!n||!r||(n.disabled=s!=="dark",r.disabled=s!=="light")}function t3t(s,n){SO(s)&&(document.documentElement.style.setProperty("--bg-map",s),Ff("or_bg_color",s),i3t(n),n.syncDisplayState())}function n3t(s){document.documentElement.style.removeProperty("--bg-map"),Vhe("or_bg_color"),i3t(s),s.syncDisplayState()}function q5e(){return $xt(getComputedStyle(document.documentElement).getPropertyValue("--bg-map"))??"#000000"}function i3t(s){s.threeDViewerWidget?.render?.()}if(typeof document<"u"){let s=pf("or_theme")||typeof localStorage<"u"&&localStorage.getItem("or_theme")||(matchMedia("(prefers-color-scheme: light)").matches?"light":"dark");document.documentElement.dataset.theme=s,H5e(s);let n=pf("or_bg_color");SO(n)&&document.documentElement.style.setProperty("--bg-map",n)}function fk(){let s=getComputedStyle(document.documentElement),n=r=>s.getPropertyValue(r).trim();return{canvasBg:n("--canvas-bg"),canvasText:n("--canvas-text"),canvasAxis:n("--canvas-axis"),canvasLabel:n("--canvas-label"),canvasGrid:n("--canvas-grid"),canvasTitle:n("--canvas-title"),fgPrimary:n("--fg-primary"),fgMuted:n("--fg-muted"),bgPanel:n("--bg-panel"),bgMap:n("--bg-map"),fontMono:n("--font-mono"),fontSans:n("--font-sans")}}function hk(s,n){let r=document.createElement("a");r.href=s,r.download=n,document.body.appendChild(r),r.click(),r.remove()}function r3t(s,n){let r=URL.createObjectURL(s);hk(r,n),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function X5e(s){let n=s.cloneNode(!0);if(n.getAttribute("xmlns")||n.setAttribute("xmlns","http://www.w3.org/2000/svg"),n.getAttribute("xmlns:xlink")||n.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),!n.getAttribute("width")||!n.getAttribute("height")){let r=s.viewBox&&s.viewBox.baseVal;r&&r.width&&r.height&&(n.setAttribute("width",r.width),n.setAttribute("height",r.height))}return` +`+new XMLSerializer().serializeToString(n)}function ndn(s){let n=s.viewBox&&s.viewBox.baseVal;if(n&&n.width&&n.height)return{width:n.width,height:n.height};let r=parseFloat(s.getAttribute("width")),c=parseFloat(s.getAttribute("height"));if(r&&c)return{width:r,height:c};let u=s.getBoundingClientRect();return{width:u.width||800,height:u.height||600}}function Y5e(s,n=2){let{width:r,height:c}=ndn(s),u=X5e(s),d=new Blob([u],{type:"image/svg+xml;charset=utf-8"}),b=URL.createObjectURL(d);return new Promise((w,_)=>{let x=new Image;x.onload=()=>{let T=document.createElement("canvas");T.width=Math.max(1,Math.round(r*n)),T.height=Math.max(1,Math.round(c*n));let M=T.getContext("2d");M.fillStyle="#ffffff",M.fillRect(0,0,T.width,T.height),M.drawImage(x,0,0,T.width,T.height),URL.revokeObjectURL(b),w(T.toDataURL("image/png"))},x.onerror=T=>{URL.revokeObjectURL(b),_(T)},x.src=b})}async function Hhe(s){try{if(!navigator.clipboard||!window.ClipboardItem)return!1;let n=await(await fetch(s)).blob();return await navigator.clipboard.write([new ClipboardItem({"image/png":n})]),!0}catch{return!1}}function idn(s){return(String(s||"").replace(/[^A-Za-z0-9._-]/g,"_").replace(/^_+|_+$/g,"")||"clock_tree")+".png"}var Z5e=24,K5e=10,Xhe=40,rdn=40,J5e=70,sdn=20,qhe={root:"#ff4444",buffer:"#4488ff",inverter:"#00b0b0",clock_gate:"#cc44cc",register:"#ff4444",macro:"#00b0b0",unknown:"#888888"};function odn(s){let n=parseInt(s.slice(1,3),16),r=parseInt(s.slice(3,5),16),c=parseInt(s.slice(5,7),16),u=b=>Math.round((b+255)/2),d=b=>b.toString(16).padStart(2,"0");return"#"+d(u(n))+d(u(r))+d(u(c))}function adn(s){let n=s.nodes;if(!n||n.length===0)return{layout:[],layoutWidth:0,layoutHeight:0,timeMin:0,timeMax:0,timeUnit:"",sceneHeight:0,layoutById:new Map};let r=new Map;for(let Z of n)r.set(Z.id,[]);for(let Z of n)Z.parent_id>=0&&r.has(Z.parent_id)&&r.get(Z.parent_id).push(Z.id);let c=new Map;for(let Z of n)c.set(Z.id,Z);let u=new Map,d=Z=>{let H=r.get(Z)||[];if(H.length===0)return u.set(Z,1),1;let te=0;for(let se of H)te+=d(se);return u.set(Z,te),te},b=n.filter(Z=>Z.parent_id===-1),w=0;for(let Z of b)w+=d(Z.id);let _=s.min_arrival,x=s.max_arrival,T=x-_||1,M=Math.max(200,w*Z5e*.6),L=[],I=(Z,H)=>{let te=c.get(Z),se=u.get(Z),ne=J5e+(H+se/2)*Z5e,ue=Xhe+(te.arrival-_)/T*M;L.push({id:te.id,x:ne,y:ue,type:te.type,name:te.name,pin_name:te.pin_name,arrival:te.arrival,delay:te.delay,fanout:te.fanout,level:te.level,parent_id:te.parent_id});let Ce=H,Q=r.get(Z)||[];for(let me of Q)I(me,Ce),Ce+=u.get(me)},D=0;for(let Z of b)I(Z.id,D),D+=u.get(Z.id);let F=J5e+w*Z5e+sdn,O=Xhe+M+rdn,z=new Map;for(let Z of L)z.set(Z.id,Z);return{layout:L,layoutWidth:F,layoutHeight:O,timeMin:_,timeMax:x,timeUnit:s.time_unit||"",sceneHeight:M,layoutById:z}}var Yhe=class{constructor(n,r,c,u){this._app=r,this._redrawAllLayers=c,this._refreshOverlay=u||c,this._clockData=[],this._selectedClockIdx=0,this._selectedNodeId=-1,this._tx=0,this._ty=0,this._scale=1,this._layout=[],this._dragging=!1,this._dragStartX=0,this._dragStartY=0,this._dragStartTx=0,this._dragStartTy=0,this._build(n)}_build(n){let r=document.createElement("div");r.className="clock-tree-widget";let c=document.createElement("div");c.className="clock-tree-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",la(this._app)&&(this._updateBtn.style.display="none"),this._fitBtn=document.createElement("button"),this._fitBtn.className="or-btn",this._fitBtn.textContent="Fit",this._pngBtn=document.createElement("button"),this._pngBtn.className="or-btn",this._pngBtn.textContent="PNG",this._pngBtn.title="Export the clock tree as a PNG image",this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",c.appendChild(this._updateBtn),c.appendChild(this._fitBtn),c.appendChild(this._pngBtn),c.appendChild(this._statusLabel),r.appendChild(c),this._tabBar=document.createElement("div"),this._tabBar.className="timing-tab-bar",r.appendChild(this._tabBar),this._canvas=document.createElement("canvas"),this._canvas.className="clock-tree-canvas",r.appendChild(this._canvas),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._tooltip.style.display="none",r.appendChild(this._tooltip),n.element.appendChild(r),this._el=r,this._ctx=this._canvas.getContext("2d"),this._bindEvents(),la(this._app)&&setTimeout(()=>this.update(),0)}_fit(){this._sizeCanvas(),this._fitToView(),this._render()}_pngFileName(){let n=this._clockData[this._selectedClockIdx];return idn(n&&n.name)}_exportPng(){try{hk(this._canvas.toDataURL("image/png"),this._pngFileName())}catch(n){console.error("PNG export failed:",n)}}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update()),this._fitBtn.addEventListener("click",()=>this._fit()),this._pngBtn.addEventListener("click",()=>this._exportPng()),this._canvas.addEventListener("keydown",n=>{n.key==="f"&&this._fit()}),this._canvas.tabIndex=0,this._canvas.addEventListener("wheel",n=>{n.preventDefault();let r=this._canvas.getBoundingClientRect(),c=n.clientX-r.left,u=n.clientY-r.top,d=n.deltaY<0?1.15:1/1.15;this._tx=c-(c-this._tx)*d,this._ty=u-(u-this._ty)*d,this._scale*=d,this._render()}),this._canvas.addEventListener("mousedown",n=>{this._dragging=!0,this._dragStartX=n.clientX,this._dragStartY=n.clientY,this._dragStartTx=this._tx,this._dragStartTy=this._ty,this._canvas.style.cursor="grabbing"}),window.addEventListener("mousemove",n=>{this._dragging?(this._tx=this._dragStartTx+(n.clientX-this._dragStartX),this._ty=this._dragStartTy+(n.clientY-this._dragStartY),this._render()):this._handleHover(n)}),window.addEventListener("mouseup",()=>{this._dragging&&(this._dragging=!1,this._canvas.style.cursor="grab")}),this._canvas.addEventListener("click",n=>this._handleClick(n)),this._resizeObserver=new ResizeObserver(()=>{this._sizeCanvas(),this._render()}),this._resizeObserver.observe(this._canvas)}_sizeCanvas(){let n=this._canvas.getBoundingClientRect(),r=window.devicePixelRatio||1;this._canvas.width=n.width*r,this._canvas.height=n.height*r,this._ctx.setTransform(r,0,0,r,0,0)}async update(){this._statusLabel.textContent="Loading...";try{let n=await this._app.websocketManager.request({type:"clock_tree"});this._clockData=n.clocks||[],this._buildTabs(),this._selectClock(0),this._statusLabel.textContent=this._clockData.length+" clock"+(this._clockData.length!==1?"s":"")}catch(n){console.error("Clock tree error:",n),this._statusLabel.textContent="Error: "+n.message}}_buildTabs(){this._tabBar.innerHTML="",this._clockData.forEach((n,r)=>{let c=document.createElement("button");c.className="timing-tab"+(r===this._selectedClockIdx?" active":""),c.textContent=n.name,c.addEventListener("click",()=>this._selectClock(r)),this._tabBar.appendChild(c)})}_selectClock(n){if(n<0||n>=this._clockData.length)return;this._selectedClockIdx=n,this._selectedNodeId=-1,this._tabBar.querySelectorAll(".timing-tab").forEach((c,u)=>{c.classList.toggle("active",u===n)}),this._computeLayout(this._clockData[n]),requestAnimationFrame(()=>{this._sizeCanvas(),this._fitToView(),this._render()})}_computeLayout(n){let r=adn(n);this._layout=r.layout,this._layoutWidth=r.layoutWidth,this._layoutHeight=r.layoutHeight,this._timeMin=r.timeMin,this._timeMax=r.timeMax,this._timeUnit=r.timeUnit,this._sceneHeight=r.sceneHeight,this._layoutById=r.layoutById}_fitToView(){if(!this._layout.length)return;let n=this._canvas.getBoundingClientRect(),r=n.width,c=n.height,u=r/this._layoutWidth,d=c/this._layoutHeight;this._scale=Math.min(u,d)*.9,this._tx=(r-this._layoutWidth*this._scale)/2,this._ty=(c-this._layoutHeight*this._scale)/2}render(){this._render()}_render(){let n=this._ctx,r=this._canvas.getBoundingClientRect(),c=r.width,u=r.height,d=fk();if(n.clearRect(0,0,c,u),n.fillStyle=d.canvasBg,n.fillRect(0,0,c,u),!this._layout.length){n.fillStyle=d.canvasText,n.font="14px "+d.fontSans,n.textAlign="center";let b=la(this._app)?"No clock tree data available":'Click "Update" to load clock tree data';n.fillText(b,c/2,u/2);return}n.save(),n.translate(this._tx,this._ty),n.scale(this._scale,this._scale),this._drawConnections(n);for(let b of this._layout)this._drawNode(n,b,b.id===this._selectedNodeId);n.restore(),this._drawTimeScale(n,c,u,d)}_drawConnections(n){let r=1.5/this._scale,c=K5e,u=this._timeMax-this._timeMin||1;for(let d of this._layout){if(d.parent_id<0)continue;let b=this._layoutById.get(d.parent_id);if(!b)continue;let w=b.x,_=d.x,x=(b.delay||0)/u*this._sceneHeight,T=b.y+x,M=d.y,L=b.type==="root"?b.y:b.y+c;if(T>L){let D=qhe[b.type]||qhe.unknown;n.strokeStyle=D,n.lineWidth=r,n.beginPath(),n.moveTo(w,L),n.lineTo(w,T);let F=c/20;n.moveTo(w-F,T),n.lineTo(w+F,T),n.stroke()}n.strokeStyle="#006400",n.lineWidth=r;let I=(T+M)/2;n.beginPath(),n.moveTo(w,T),n.bezierCurveTo(w,I,_,I,_,M),n.stroke()}}_drawNode(n,r,c){let u=r.x,d=r.y,b=K5e,w=qhe[r.type]||qhe.unknown;switch(n.fillStyle=odn(w),n.strokeStyle=w,n.lineWidth=1/this._scale,r.type){case"root":{n.beginPath(),n.moveTo(u-b/2,d-b),n.lineTo(u+b/2,d-b),n.lineTo(u,d),n.closePath(),n.fill(),n.stroke();break}case"buffer":{n.beginPath(),n.moveTo(u-b/2,d),n.lineTo(u+b/2,d),n.lineTo(u,d+b),n.closePath(),n.fill(),n.stroke();break}case"inverter":{let _=b*.1,x=d+b-_;n.beginPath(),n.moveTo(u-b/2,d),n.lineTo(u+b/2,d),n.lineTo(u,x),n.closePath(),n.fill(),n.stroke(),n.beginPath(),n.arc(u,x+_/2,_/2,0,Math.PI*2),n.fill(),n.stroke();break}case"clock_gate":{n.beginPath(),n.arc(u,d+b/2,b/2,0,Math.PI*2),n.fill(),n.stroke();break}case"register":case"macro":{n.beginPath(),n.rect(u-b/2,d,b,b),n.fill(),n.stroke(),n.beginPath(),n.moveTo(u-b/8,d),n.lineTo(u+b/8,d),n.lineTo(u,d+b/4),n.closePath(),n.stroke();break}default:{n.beginPath(),n.arc(u,d+b/2,b/2,0,Math.PI*2),n.fill(),n.stroke();break}}if(c){n.strokeStyle="#ffff00",n.lineWidth=2/this._scale;let _=r.type==="root"?d-b/2:d+b/2;n.beginPath(),n.arc(u,_,b/2+3,0,Math.PI*2),n.stroke()}}_drawTimeScale(n,r,c,u){if(!this._sceneHeight)return;let d=F=>F*this._scale+this._ty,b=d(Xhe),w=d(Xhe+this._sceneHeight);if(w<0||b>c)return;n.save(),n.fillStyle=u.canvasLabel,n.strokeStyle=u.canvasAxis,n.font="11px "+u.fontMono,n.textAlign="right",n.textBaseline="middle";let _=this._timeMax-this._timeMin;if(_<=0){n.restore();return}let x=w-b,T=Math.max(2,Math.floor(x/40)),M=_/T,L=Math.pow(10,Math.floor(Math.log10(M))),I=L;M/L>5?I=10*L:M/L>2?I=5*L:M/L>1&&(I=2*L);let D=Math.ceil(this._timeMin/I)*I;n.beginPath();for(let F=D;F<=this._timeMax;F+=I){let O=(F-this._timeMin)/_,z=b+O*(w-b);n.moveTo(0,z),n.lineTo(r,z);let Z=F.toFixed(I<.01?3:I<.1?2:1)+" "+this._timeUnit;n.fillText(Z,J5e-4,z)}n.stroke(),n.restore()}_screenToLayout(n,r){return{x:(n-this._tx)/this._scale,y:(r-this._ty)/this._scale}}_hitTest(n,r){let c=this._screenToLayout(n,r),u=K5e;for(let d of this._layout){let b=d.type==="root"?d.y-u:d.y,w=d.type==="root"?d.y:d.y+u;if(c.x>=d.x-u/2&&c.x<=d.x+u/2&&c.y>=b&&c.y<=w)return d}return null}_handleClick(n){let r=this._canvas.getBoundingClientRect(),c=n.clientX-r.left,u=n.clientY-r.top,d=this._hitTest(c,u);d?(this._selectedNodeId=d.id,this._render(),this._app.websocketManager.request({type:"clock_tree_highlight",inst_name:d.name}).then(()=>this._refreshOverlay())):this._selectedNodeId>=0&&(this._selectedNodeId=-1,this._render(),this._app.websocketManager.request({type:"clock_tree_highlight",inst_name:""}).then(()=>this._refreshOverlay()))}_handleHover(n){let r=this._canvas.getBoundingClientRect(),c=n.clientX-r.left,u=n.clientY-r.top;if(c<0||u<0||c>r.width||u>r.height){this._tooltip.style.display="none";return}let d=this._hitTest(c,u);if(d){let b=[d.name,"Type: "+d.type,"Arrival: "+d.arrival.toFixed(3)+" "+(this._timeUnit||"")];d.delay&&b.push("Delay: "+d.delay.toFixed(3)+" "+(this._timeUnit||"")),d.fanout&&b.push("Fanout: "+d.fanout),this._tooltip.textContent=b.join(` +`),this._tooltip.style.display="block",this._tooltip.style.left=n.clientX+12+"px",this._tooltip.style.top=n.clientY+12+"px"}else this._tooltip.style.display="none"}};var o3t=60,a3t=20,c3t=30,l3t=50,s3t=2,cdn="#f08080",ldn="#8b0000",udn="#90ee90",fdn="#006400",yT=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7"],hdn="rgba(240,128,128,0.12)",ddn="rgba(144,238,144,0.12)",pdn="#ff9999",gdn="#b0ffb0",mdn=[{value:"setup",label:"Setup Slack"},{value:"hold",label:"Hold Slack"},{value:"fanout",label:"Net Fanout"},{value:"netlength",label:"Net Length (HPWL)"}];function bdn(s,n,r,c){if(!s||!n||cn.bottom)return null;for(let u of s)if(r>=u.x&&r<=u.x+u.width)return u;return null}function wdn(s,n,r){return r?Math.log10(s+1)/Math.log10(n+1):s/n}function vdn(s,n,r,c={}){let u=!!c.logY,d=s?.bins;if(!d||d.length===0)return{bars:[],yMax:0,yTicks:[],chartArea:null,logY:u};let b=o3t,w=n-a3t,_=c3t,x=r-l3t,T=w-b,M=x-_;if(T<=0||M<=0)return{bars:[],yMax:0,yTicks:[],chartArea:null,logY:u};let L={left:b,right:w,top:_,bottom:x},I=0;for(let Z of d)Z.count>I&&(I=Z.count);I===0&&(I=1);let{yMax:D,yTicks:F}=u?ydn(I):_dn(I),O=(T-s3t*(d.length-1))/d.length,z=[];for(let Z=0;Z[x.x,...x.ys||[]].join(","));return[w,..._].join(` +`)}let r=n.bins||[],c=Array.isArray(n.series)?n.series:[],u=["lower","upper","count",...c.map(b=>b.name||"group")].join(","),d=r.map((b,w)=>{let _=[b.lower,b.upper,b.count];for(let x of c)_.push(x.counts&&x.counts[w]||0);return _.join(",")});return[u,...d].join(` +`)}var Zhe=class{constructor(n,r){this._app=n,this._redrawAllLayers=r,this._currentTab="setup",this._histogramData=null,this._bars=[],this._yMax=0,this._yTicks=[],this._chartArea=null,this._hoveredBar=null,this._debugCharts=[],this._activeDebugChart=-1,this._build()}_build(){let n=document.createElement("div");n.className="charts-widget";let r=document.createElement("div");r.className="charts-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",la(this._app)&&(this._updateBtn.style.display="none"),this._chartSelect=document.createElement("select"),this._chartSelect.className="charts-select",this._csvBtn=document.createElement("button"),this._csvBtn.className="or-btn",this._csvBtn.textContent="CSV",this._csvBtn.title="Export the current chart data as CSV",this._pngBtn=document.createElement("button"),this._pngBtn.className="or-btn",this._pngBtn.textContent="PNG",this._pngBtn.title="Export the current chart as a PNG image",this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",r.appendChild(this._updateBtn),r.appendChild(this._chartSelect),r.appendChild(this._csvBtn),r.appendChild(this._pngBtn),r.appendChild(this._statusLabel),n.appendChild(r);let c=document.createElement("div");c.className="charts-toolbar";let u=document.createElement("span");u.textContent="Path Groups:",u.style.color="var(--fg-muted)",u.style.fontSize="var(--fs-12)",this._pathGroupSelect=document.createElement("select"),this._pathGroupSelect.className="charts-select",this._pathGroupSelect.multiple=!0,this._pathGroupSelect.size=1,this._pathGroupSelect.title="Select 0 = all, or \u22651 to stack by group";let d=document.createElement("span");d.textContent="Clock:",d.style.color="var(--fg-muted)",d.style.fontSize="var(--fs-12)",this._clockSelect=document.createElement("select"),this._clockSelect.className="charts-select",this._clockSelect.innerHTML='',c.appendChild(u),c.appendChild(this._pathGroupSelect),c.appendChild(d),c.appendChild(this._clockSelect),n.appendChild(c),this._canvas=document.createElement("canvas"),this._canvas.className="charts-canvas",n.appendChild(this._canvas),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._tooltip.style.display="none",n.appendChild(this._tooltip),this._filterRow=c,this.element=n,this._ctx=this._canvas.getContext("2d"),this._rebuildSelect(),this._bindEvents(),la(this._app)&&setTimeout(()=>this.update(),0)}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update()),this._chartSelect.addEventListener("change",()=>this._onSelectChange()),this._csvBtn.addEventListener("click",()=>this._exportCsv()),this._pngBtn.addEventListener("click",()=>this._exportPng()),this._pathGroupSelect.addEventListener("change",()=>this._fetchHistogram()),this._clockSelect.addEventListener("change",()=>this._fetchHistogram()),this._canvas.addEventListener("mousemove",r=>this._handleHover(r)),this._canvas.addEventListener("mouseleave",()=>{this._hoveredBar=null,this._tooltip.style.display="none",this._syncView()}),this._canvas.addEventListener("click",r=>this._handleClick(r)),this._canvas.addEventListener("dblclick",r=>this._handleDblClick(r)),new ResizeObserver(()=>this._syncView()).observe(this._canvas)}_sizeCanvas(){let n=this._canvas.getBoundingClientRect(),r=window.devicePixelRatio||1;this._canvas.width=n.width*r,this._canvas.height=n.height*r,this._ctx.setTransform(r,0,0,r,0,0)}_rebuildSelect(){let n=this._chartSelect;n.innerHTML="";for(let r of mdn){let c=document.createElement("option");c.value=r.value,c.textContent=r.label,n.appendChild(c)}this._debugCharts.forEach((r,c)=>{let u=document.createElement("option");u.value="gen:"+c,u.textContent=r.name||"Chart "+c,n.appendChild(u)}),n.value=this._activeDebugChart>=0?"gen:"+this._activeDebugChart:this._currentTab}_onSelectChange(){let n=this._chartSelect.value;n.startsWith("gen:")?(this._activeDebugChart=parseInt(n.slice(4),10)||0,this._hoveredBar=null,this._tooltip.style.display="none",this._syncView()):this._selectTab(n)}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...",this._statusLabel.textContent="";try{this._activeDebugChart<0?((this._currentTab==="setup"||this._currentTab==="hold")&&await this._fetchFilters(),await Promise.all([this._fetchHistogram(),this._fetchGenericCharts()])):await this._fetchGenericCharts()}catch(n){this._statusLabel.textContent="Error: "+n.message}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}async _fetchFilters(){let n=await this._app.websocketManager.request({type:"chart_filters"});this._populatePathGroups(n.path_groups||[]),this._populateClocks(n.clocks||[])}_populatePathGroups(n){let r=new Set(Array.from(this._pathGroupSelect.selectedOptions,c=>c.value));this._pathGroupSelect.innerHTML="";for(let c of n){let u=document.createElement("option");u.value=c,u.textContent=c,u.selected=r.has(c),this._pathGroupSelect.appendChild(u)}}_populateClocks(n){let r=this._clockSelect.value;this._clockSelect.innerHTML='';for(let c of n){let u=document.createElement("option");u.value=c,u.textContent=c,this._clockSelect.appendChild(u)}n.includes(r)&&(this._clockSelect.value=r)}async _fetchGenericCharts(){try{let n=await this._app.websocketManager.request({type:"debug_charts"});this.setDebugCharts(n.charts||[])}catch{}}async _fetchHistogram(){try{let n=this._currentTab,r;if(n==="fanout")r={type:"fanout_histogram"};else if(n==="netlength")r={type:"net_length_histogram",use_dbu:!!this._app.showDbu};else{r={type:"slack_histogram",is_setup:n==="setup"};let u=Array.from(this._pathGroupSelect.selectedOptions,d=>d.value).filter(Boolean);u.length>0&&(r.path_groups=u),this._clockSelect.value&&(r.clock_name=this._clockSelect.value)}let c=await this._app.websocketManager.request(r);if(this._currentTab!==n)return;if(this._histogramData=c,this._syncView(),n==="fanout"||n==="netlength"){let u=c.total_nets||0;this._statusLabel.textContent=`${u} nets`}else{let u=c.total_endpoints||0,d=c.unconstrained_count||0,b=u-d;this._statusLabel.textContent=`${b} endpoints`+(d>0?`, ${d} unconstrained`:"")}}catch(n){this._statusLabel.textContent="Error: "+n.message}}_selectTab(n){this._currentTab===n&&this._activeDebugChart<0||(this._currentTab=n,this._activeDebugChart=-1,this._chartSelect&&(this._chartSelect.value=n),this._filterRow.style.display=n==="setup"||n==="hold"?"":"none",this._hoveredBar=null,this._tooltip.style.display="none",this.update())}_computeLayout(){if(!this._histogramData)return;let n=this._canvas.getBoundingClientRect(),r=vdn(this._histogramData,n.width,n.height,{logY:this._currentTab==="fanout"});this._bars=r.bars,this._yMax=r.yMax,this._yTicks=r.yTicks,this._chartArea=r.chartArea,this._logY=!!r.logY}render(){this._syncView()}_stackedSeries(){let n=this._histogramData?.series;return Array.isArray(n)&&n.length>1?n:null}_render(){let n=this._canvas.getBoundingClientRect(),r=n.width,c=n.height,u=this._ctx,d=fk();if(u.clearRect(0,0,r,c),u.fillStyle=d.canvasBg,u.fillRect(0,0,r,c),!this._bars||this._bars.length===0){u.fillStyle=d.canvasText,u.font="14px "+d.fontSans,u.textAlign="center",u.textBaseline="middle";let b=la(this._app)?"No histogram data available":'Click "Update" to load histogram';u.fillText(b,r/2,c/2);return}this._drawAxes(u,d),this._drawBars(u),this._drawTitle(u,r,d),this._stackedSeries()&&this._drawSeriesLegend(u,d)}_drawAxes(n,r){let c=this._chartArea;if(!c)return;n.strokeStyle=r.canvasAxis,n.lineWidth=1,n.beginPath(),n.moveTo(c.left,c.top),n.lineTo(c.left,c.bottom),n.stroke(),n.beginPath(),n.moveTo(c.left,c.bottom),n.lineTo(c.right,c.bottom),n.stroke(),n.fillStyle=r.canvasLabel,n.font="11px "+r.fontMono,n.textAlign="right",n.textBaseline="middle";let u=c.bottom-c.top;for(let L of this._yTicks){let I=this._logY?Math.log10(L+1)/Math.log10(this._yMax+1):L/this._yMax,D=c.bottom-I*u;n.fillText(this._formatCount(L),c.left-6,D),L>0&&(n.strokeStyle=r.canvasGrid,n.beginPath(),n.moveTo(c.left,D),n.lineTo(c.right,D),n.stroke(),n.strokeStyle=r.canvasAxis)}let d=this._currentTab,b=d==="fanout"||d==="netlength";n.save(),n.translate(14,(c.top+c.bottom)/2),n.rotate(-Math.PI/2),n.textAlign="center",n.textBaseline="middle",n.fillStyle=r.canvasTitle,n.font="11px "+r.fontMono,n.fillText(this._logY?"Nets (log)":b?"Nets":"Endpoints",0,0),n.restore(),n.textAlign="center",n.textBaseline="top",n.fillStyle=r.canvasLabel,n.font="10px "+r.fontMono;let w=this._histogramData.bins,_=this._histogramData.time_unit||this._histogramData.length_unit||"",x=w.length>0?w[0].upper-w[0].lower:1,T=d==="fanout"?0:Math.max(0,-Math.floor(Math.log10(x)));for(let L=0;L<=this._bars.length;L++){let I=L=0){this._hoveredBar=null,this._tooltip.style.display="none";return}let r=this._hitTestBar(n);if(r!==this._hoveredBar&&(this._hoveredBar=r,this._render()),r){let c=this._currentTab,u=r.upper-r.lower;if(c==="fanout"){let L=r.upper-1,I=r.lower===L?`${r.lower}`:`[${r.lower}, ${L}]`;this._tooltip.textContent=`Nets: ${r.count} +Fanout: ${I}`}else if(c==="netlength"){let L=this._histogramData?.length_unit||"",I=Math.max(0,-Math.floor(Math.log10(u)));this._tooltip.textContent=`Nets: ${r.count} +Length: [${r.lower.toFixed(I)}, ${r.upper.toFixed(I)}) ${L}`}else{let L=this._histogramData?.time_unit||"",I=Math.max(0,-Math.floor(Math.log10(u)));this._tooltip.textContent=`Endpoints: ${r.count} +Slack: [${r.lower.toFixed(I)}, ${r.upper.toFixed(I)}) ${L}`}this._tooltip.style.display="block";let d=this.element.getBoundingClientRect(),b=this._tooltip.getBoundingClientRect(),w=4,_=n.clientX-d.left,x=n.clientY-d.top,T=_+12;T+b.width>d.width-w&&(T=_-12-b.width),T=Math.max(w,T);let M=x-10;M=Math.min(d.height-b.height-w,Math.max(w,M)),this._tooltip.style.left=T+"px",this._tooltip.style.top=M+"px"}else this._tooltip.style.display="none"}async _handleClick(n){if(this._activeDebugChart>=0||this._currentTab==="fanout"||this._currentTab==="netlength")return;let r=this._hitTestBar(n);if(!(!r||r.count===0))try{let c=await this._app.websocketManager.request({type:"timing_report",is_setup:this._currentTab==="setup",max_paths:50,slack_min:r.lower,slack_max:r.upper});this._app.timingWidget&&(this._app.timingWidget.showPaths(this._currentTab,c.paths||[]),this._app.focusComponent&&this._app.focusComponent("TimingWidget"))}catch(c){console.error("Charts bar click error:",c)}}async _handleDblClick(n){if(this._activeDebugChart>=0)return;let r;if(this._currentTab==="fanout")r="select_fanout_bin";else if(this._currentTab==="netlength")r="select_net_length_bin";else return;let c=this._hitTestBar(n);if(!c||c.count===0)return;let u=Pm(this._app);try{let d=await this._app.websocketManager.request({type:r,lower:c.lower,upper:c.upper,use_dbu:this._app.showDbu});if(!Y1(this._app,u))return;d&&d.truncated&&console.warn(`Bin has ${d.count} nets; selection capped at ${d.selection_limit} for performance.`),this._app.updateInspector&&this._app.updateInspector(d),this._app.focusComponent&&this._app.focusComponent("Inspector"),this._redrawAllLayers&&this._redrawAllLayers()}catch(d){console.error("Net bin select failed:",d)}}_activeChartData(){return this._activeDebugChart>=0?{kind:"generic",data:this._debugCharts[this._activeDebugChart]}:{kind:"histogram",data:this._histogramData}}_chartBaseName(){return this._activeDebugChart>=0?this._debugCharts[this._activeDebugChart].name||"chart":this._currentTab}_triggerDownload(n,r,{revoke:c=!1}={}){let u=document.createElement("a");u.href=r,u.download=n,document.body.appendChild(u),u.click(),u.remove(),c&&URL.revokeObjectURL(r)}_download(n,r,c){try{let u=URL.createObjectURL(new Blob([c],{type:r}));this._triggerDownload(n,u,{revoke:!0})}catch(u){console.error("Download failed:",u)}}_exportCsv(){let{kind:n,data:r}=this._activeChartData();if(!r)return;let c=xdn(n,r);this._download(this._chartBaseName()+".csv","text/csv",c)}_exportPng(){try{let n=this._canvas.toDataURL("image/png");this._triggerDownload(this._chartBaseName()+".png",n)}catch(n){console.error("PNG export failed:",n)}}setDebugCharts(n){this._debugCharts=n,n.length===0?this._activeDebugChart=-1:this._activeDebugChart>=n.length&&(this._activeDebugChart=0),this._rebuildSelect(),this._syncView()}_syncView(){let n=this._activeDebugChart>=0;n&&(this._hoveredBar=null,this._tooltip.style.display="none");let r=!n&&(this._currentTab==="setup"||this._currentTab==="hold");this._filterRow&&(this._filterRow.style.display=r?"":"none"),this._sizeCanvas(),n?this._renderLineChart(this._debugCharts[this._activeDebugChart]):(this._computeLayout(),this._render())}_renderLineChart(n){let r=this._canvas.getBoundingClientRect(),c=r.width,u=r.height,d=this._ctx,b=fk();d.clearRect(0,0,c,u),d.fillStyle=b.canvasBg,d.fillRect(0,0,c,u);let w=n.points;if(!w||w.length===0){d.fillStyle=b.canvasText,d.font="14px "+b.fontSans,d.textAlign="center",d.textBaseline="middle",d.fillText("No data points yet",c/2,u/2);return}let _=n.y_labels?n.y_labels.length:1,x=o3t,T=c-a3t,M=c3t,L=u-l3t,I=T-x,D=L-M;if(I<=0||D<=0)return;let F=w[0].x,O=w[0].x,z=1/0,Z=-1/0;for(let ue of w){ue.xO&&(O=ue.x);for(let Ce of ue.ys)CeZ&&(Z=Ce)}F===O&&(O=F+1),(!isFinite(z)||!isFinite(Z))&&(z=0,Z=1);let H=(Z-z)*.05||1;z-=H,Z+=H;let te=ue=>x+(ue-F)/(O-F)*I,se=ue=>L-(ue-z)/(Z-z)*D;d.strokeStyle=b.canvasAxis,d.lineWidth=1,d.beginPath(),d.moveTo(x,M),d.lineTo(x,L),d.lineTo(T,L),d.stroke(),d.fillStyle=b.canvasLabel,d.font="10px "+b.fontMono,d.textAlign="right",d.textBaseline="middle";let ne=5;for(let ue=0;ue<=ne;ue++){let Ce=z+(Z-z)*ue/ne,Q=se(Ce);d.fillText(this._formatNum(Ce),x-4,Q),ue>0&&ue1&&n.y_labels){d.font="10px "+b.fontMono,d.textAlign="left",d.textBaseline="top";let ue=x+8,Ce=M+4;for(let Q=0;Q<_;Q++){let me=yT[Q%yT.length];d.fillStyle=me,d.fillRect(ue,Ce+Q*14,12,10),d.fillStyle=b.canvasLabel,d.fillText(n.y_labels[Q],ue+16,Ce+Q*14)}}}_formatNum(n){let r=Math.abs(n);return r===0?"0":r>=1e6?(n/1e6).toFixed(1)+"M":r>=1e3?(n/1e3).toFixed(1)+"k":r>=1?n.toFixed(1):n.toPrecision(3)}_formatCount(n){return n===0?"0":n>=1e6?n/1e6+"M":n>=1e3?n/1e3+"k":String(n)}};var Lv=class{constructor(n){this.onChange=n,this.roots=[],this._nodeMap=new Map}addFromSpec(n,r=null){let c=this._makeNode(n.id,r,n);if(c.checked=n.checked!==!1,n.children){for(let u of n.children)c.children.push(this.addFromSpec(u,c));c.hasCheckbox&&this._computeParent(c)}return r||this.roots.push(c),c}buildFromNodes(n){this._nodeMap.clear(),this.roots=[];for(let r of n)this._makeNode(r.id,null,r);for(let r of n){let c=this._nodeMap.get(r.id);if(r.parentId!=null&&this._nodeMap.has(r.parentId)){let u=this._nodeMap.get(r.parentId);c.parent=u,u.children.push(c)}else this.roots.push(c)}for(let r=n.length-1;r>=0;r--){let c=this._nodeMap.get(n[r].id);c.hasCheckbox&&c.children.length>0&&this._computeParent(c)}return this.roots}get(n){return this._nodeMap.get(n)}isVisible(n){let r=this.get(n);return r?r.checked:!1}check(n,r){let c=this._nodeMap.get(n);if(c){c.checked=r,c.indeterminate=!1;for(let u of c.children)this._setSubtree(u,r);for(let u=c.parent;u;u=u.parent)u.hasCheckbox&&this._computeParent(u);this.onChange()}}cascadeQuiet(n,r){let c=this._nodeMap.get(n);if(c){c.checked=r,c.indeterminate=!1;for(let u of c.children)this._setSubtree(u,r);for(let u=c.parent;u;u=u.parent)u.hasCheckbox&&this._computeParent(u)}}checkSet(n){for(let[r,c]of Object.entries(n)){let u=this._nodeMap.get(r);u&&(u.checked=c,u.indeterminate=!1)}this._recomputeAllParents(),this.onChange()}mirrorStates(n){this._applyMirror(n),this.onChange()}mirrorStatesQuiet(n){this._applyMirror(n)}_applyMirror(n){for(let[r,c]of Object.entries(n)){let u=this._nodeMap.get(r);u&&(u.checked=!!c.checked,u.indeterminate=!!c.indeterminate)}}forEach(n){let r=c=>{n(c);for(let u of c.children)r(u)};for(let c of this.roots)r(c)}_makeNode(n,r,c){let u={id:n,parent:r,children:[],hasCheckbox:c.hasCheckbox!==!1,checked:c.checked!==!1,indeterminate:!1,data:c.data!=null?c.data:c};return this._nodeMap.set(n,u),u}_checkboxDescendants(n){let r=[];for(let c of n.children)c.hasCheckbox?r.push(c):r.push(...this._checkboxDescendants(c));return r}_computeParent(n){let r=this._checkboxDescendants(n);if(r.length===0)return;let c=r.every(d=>d.checked&&!d.indeterminate),u=r.every(d=>!d.checked&&!d.indeterminate);n.checked=c,n.indeterminate=!c&&!u}_setSubtree(n,r){n.hasCheckbox&&(n.checked=r,n.indeterminate=!1);for(let c of n.children)this._setSubtree(c,r)}_recomputeAllParents(){let n=r=>{for(let c of r.children)n(c);r.hasCheckbox&&r.children.length>0&&this._computeParent(r)};for(let r of this.roots)n(r)}};var u3t=["Instance","Module","Instances","Macros","Modules","Area","Local Inst","Local Macros","Local Modules"],xT={MODULE:0,LEAF_GROUP:1,TYPE_GROUP:2,INSTANCE:3,NAME_GROUP:4};function dk(s){return s===xT.MODULE||s===xT.NAME_GROUP}var Khe=class{constructor(n,r,c){this._app=r,this._redrawAllLayers=c,this._nodes=[],this._nameGrouped=!1,this._nameGroupsCapped=!1,this._rows=[],this._childrenMap=new Map,this._collapsed=new Set,this._moduleState=new Map,this._checkModel=null,this._build(n),r.hierarchyBrowser=this,la(r)&&this.update()}_build(n){let r=document.createElement("div");r.className="hierarchy-widget";let c=document.createElement("div");c.className="timing-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",la(this._app)&&(this._updateBtn.style.display="none"),this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",c.appendChild(this._updateBtn),c.appendChild(this._statusLabel),r.appendChild(c),this._tableContainer=document.createElement("div"),this._tableContainer.className="hierarchy-table-container",this._table=document.createElement("table"),this._table.className="timing-table",this._tableContainer.appendChild(this._table),r.appendChild(this._tableContainer),n.element.appendChild(r),this._bindEvents()}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update())}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...",this._statusLabel.textContent="";try{let n=await this._app.websocketManager.request({type:"module_hierarchy"});this._nodes=n.nodes||[],this._nameGrouped=!!n.name_grouped,this._nameGroupsCapped=!!n.name_groups_capped,this._buildTree(),this._readServerColors(),this._computeEffectiveColors(),this._render(),this._statusLabel.textContent=this._statusText(),await this._sendModuleColors()}catch(n){this._statusLabel.textContent="Error: "+n.message}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}_statusText(){let n=this._nodes.filter(u=>dk(u.node_kind||0)).length;if(!this._nameGrouped)return n+" modules";let c=Math.max(0,n-1)+" groups from instance names \u2014 this design has no module hierarchy";return this._nameGroupsCapped&&(c+=" (truncated: too many groups)"),c}_buildTree(){this._childrenMap.clear(),this._collapsed.clear();for(let r of this._nodes)this._childrenMap.set(r.id,[]);for(let r of this._nodes)r.parent_id>=0&&this._childrenMap.has(r.parent_id)&&this._childrenMap.get(r.parent_id).push(r.id);this._nodeMap=new Map;for(let r of this._nodes)this._nodeMap.set(r.id,r);for(let r of this._nodes){let c=this._childrenMap.get(r.id);if(!c||c.length===0)continue;let u=r.node_kind||0;u===xT.LEAF_GROUP||u===xT.TYPE_GROUP?this._collapsed.add(r.id):dk(u)&&r.parent_id>=0&&this._collapsed.add(r.id)}this._rows=[];let n=this._nodes.filter(r=>r.parent_id<0);for(let r of n)this._dfs(r.id,0);this._checkModel=new Lv(()=>{this._checkModel.forEach(r=>{if(!r.hasCheckbox)return;let c=this._moduleState.get(r.data.odb_id);c&&(c.visible=r.checked)}),this._sendModuleColors()}),this._checkModel.buildFromNodes(this._nodes.map(r=>({id:r.id,parentId:r.parent_id,hasCheckbox:dk(r.node_kind||0)&&r.odb_id!=null,checked:!0,data:r})))}_readServerColors(){this._moduleState.clear();for(let n of this._rows){let r=this._nodeMap.get(n.id);if(!r||!dk(r.node_kind||0)||r.odb_id==null)continue;let c=r.color||[128,128,128];this._moduleState.set(r.odb_id,{color:c,effectiveColor:c,visible:!0,nodeId:r.id})}}_computeEffectiveColors(){for(let n of this._rows){let r=this._nodeMap.get(n.id);if(!r||!dk(r.node_kind||0))continue;let c=this._moduleState.get(r.odb_id);if(!c)continue;let u=r.parent_id,d=null;for(;u>=0;){let b=this._nodeMap.get(u);if(!b)break;if(dk(b.node_kind||0)){let w=this._moduleState.get(b.odb_id);w&&this._collapsed.has(b.id)&&(d=w.effectiveColor)}u=b.parent_id}c.effectiveColor=d||c.color}}async _sendModuleColors(){let n=[];for(let[c,u]of this._moduleState){if(!u.visible)continue;let[d,b,w]=u.effectiveColor;n.push(`${c}:${d},${b},${w},100`)}let r=n.join(";");try{let c=await this._app.websocketManager.request({type:"set_module_colors",colors:r});console.log("set_module_colors:",c.count,"modules,",n.length,"sent")}catch(c){console.error("set_module_colors failed:",c)}this._redrawAllLayers()}_dfs(n,r){this._rows.push({id:n,depth:r});let c=this._childrenMap.get(n)||[];for(let u of c)this._dfs(u,r+1)}_render(){this._table.innerHTML="";let n=document.createElement("thead"),r=document.createElement("tr");for(let u of u3t){let d=document.createElement("th");d.textContent=u,r.appendChild(d)}n.appendChild(r),this._table.appendChild(n);let c=document.createElement("tbody");for(let u of this._rows){let d=this._nodeMap.get(u.id);if(!d||this._isHidden(d))continue;let b=document.createElement("tr"),w=d.node_kind||0,x=(this._childrenMap.get(u.id)||[]).length>0,T=this._collapsed.has(u.id);w===xT.LEAF_GROUP||w===xT.TYPE_GROUP?(b.style.fontStyle="italic",b.style.color="var(--fg-disabled)"):w===xT.INSTANCE?b.style.color="var(--fg-secondary)":w===xT.NAME_GROUP&&(b.classList.add("hierarchy-name-group"),b.title="Recovered from instance names \u2014 this design has no module hierarchy");let M=document.createElement("td");if(M.style.paddingLeft=8+u.depth*16+"px",M.style.whiteSpace="nowrap",dk(w)&&d.odb_id!=null){let D=this._moduleState.get(d.odb_id),F=this._checkModel?this._checkModel.get(d.id):null;if(D&&F){let O=document.createElement("input");O.type="checkbox",O.checked=F.checked,O.indeterminate=F.indeterminate,O.className="hierarchy-module-cb",F.cb=O,O.addEventListener("change",se=>{se.stopPropagation(),this._checkModel.check(d.id,O.checked),this._render()}),M.appendChild(O);let z=document.createElement("span");z.className="hierarchy-color-swatch";let[Z,H,te]=D.effectiveColor;z.style.backgroundColor=`rgb(${Z},${H},${te})`,M.appendChild(z)}}if(x){let D=document.createElement("span");D.className="hierarchy-arrow",D.textContent=T?"\u25B6":"\u25BC",D.addEventListener("click",F=>{F.stopPropagation(),this._toggleNode(u.id)}),M.appendChild(D)}else{let D=document.createElement("span");D.className="hierarchy-arrow",D.style.visibility="hidden",D.textContent="\u25B6",M.appendChild(D)}let L=document.createElement("span");L.textContent=d.inst_name,M.appendChild(L),b.appendChild(M);let I=[d.module_name,TO(d.insts),TO(d.macros),TO(d.modules),this._fmtArea(d.area),TO(d.local_insts),TO(d.local_macros),TO(d.local_modules)];for(let D of I){let F=document.createElement("td");F.textContent=D,F.style.textAlign="right",b.appendChild(F)}b.children[1].style.textAlign="left",c.appendChild(b)}if(this._rows.length===0){let u=document.createElement("tr"),d=document.createElement("td");d.colSpan=u3t.length,d.style.textAlign="center",d.style.color="var(--fg-secondary)",d.textContent=la(this._app)?"No hierarchy data available":'Click "Update" to load hierarchy',u.appendChild(d),c.appendChild(u)}this._table.appendChild(c),ak(this._table)}_isHidden(n){let r=n.parent_id;for(;r>=0;){if(this._collapsed.has(r))return!0;let c=this._nodeMap.get(r);if(!c)break;r=c.parent_id}return!1}_toggleNode(n){this._collapsed.has(n)?this._collapsed.delete(n):this._collapsed.add(n),this._computeEffectiveColors(),this._render(),this._sendModuleColors()}_fmtArea(n){if(n==null)return"";if(this._app.showDbu){let r=this._app.getDbuPerMicron();return String(Math.round(n*r*r))}return n>=1e6?(n/1e6).toFixed(3)+" mm\xB2":n.toFixed(3)+" \u03BCm\xB2"}};function TO(s){return s!=null?String(s):""}var Edn='',Sdn='',Mdn='',Tdn='',Cdn='',Adn='',Pdn='',Ldn='',kdn='',Rdn='',Idn='',Ddn='';function f3t(s,n,r){r=r||n;let c=null,u=null,d=null,b=!1,w=10;function _(Ge,Pe){return b?Promise.resolve():(b=!0,s.websocketManager.request({type:"set_property",name:Ge,use_dbu:s.showDbu,...Pe}).then(ke=>{!ke.ok&&ke.error&&Nb(ke.error),yi(ke),ke.ok&&ke.bbox&&Ei(ke.bbox)}).catch(ke=>{console.error("set_property failed:",ke),Nb("Edit failed: "+ke),c&&yi(c)}).finally(()=>{b=!1}))}function x(Ge,Pe){let ke=document.createElement("select");ke.className="inspector-editor-select";let dt=Ge.editor.type==="bool"?["True","False"]:Ge.editor.options||[];for(let Ye of dt){let ct=document.createElement("option");ct.value=Ye,ct.textContent=Ye,Ye===Ge.value&&(ct.selected=!0),ke.appendChild(ct)}if(!dt.includes(Ge.value)){let Ye=document.createElement("option");Ye.value=Ge.value||"",Ye.textContent=Ge.value||"",Ye.selected=!0,Ye.disabled=!0,ke.insertBefore(Ye,ke.firstChild)}return ke.addEventListener("change",()=>{if(Pe.onPropertyChange){Pe.onPropertyChange(Ge.name,ke.value);return}if(Ge.editor.type==="bool")Pe.onPropertyEdit(Ge,{value:ke.value==="True"});else{let Ye=(Ge.editor.options||[]).indexOf(ke.value);Pe.onPropertyEdit(Ge,{option_index:Ye,option_name:ke.value})}}),ke}async function T(Ge,Pe){if(!b&&!(Ge==="Delete"&&!await Dxt({title:"Delete "+(Pe.type||"object"),message:"Delete "+(Pe.type||"object")+' "'+(Pe.name||"")+'"? This cannot be undone.',confirmLabel:"Delete",danger:!0}))){b=!0;try{let ke=await s.websocketManager.request({type:"trigger_action",name:Ge,use_dbu:s.showDbu});!ke.ok&&ke.error&&Nb(ke.error),yi(ke.properties?ke:null),ke.deleted&&Un(),ot(),r()}catch(ke){console.error("trigger_action failed:",ke),Nb("Action failed: "+ke)}finally{b=!1}}}function M(Ge){s.websocketManager.request({...Ge,use_dbu:s.showDbu}).then(Pe=>{!Pe.ok&&Pe.error&&Nb(Pe.error),yi(Pe),r()}).catch(Pe=>{console.error(Ge.type+" failed:",Pe)})}function L(){let Ge=document.getElementById("highlight-picker");Ge&&Ge.remove()}function I(Ge,Pe){L();let ke=s.techData?.highlight_colors||[];if(!ke.length)return;let dt=document.createElement("div");dt.id="highlight-picker";let Ye=document.createElement("div");if(Ye.className="highlight-swatch-grid",ke.forEach((Ke,gt)=>{let qn=document.createElement("button");qn.className="highlight-swatch",qn.title="Group "+(gt+1),qn.style.backgroundColor=`rgb(${Ke[0]}, ${Ke[1]}, ${Ke[2]})`,gt===Pe.highlight_group&&qn.classList.add("active"),qn.addEventListener("click",()=>{L(),M({type:"highlight",group:gt})}),Ye.appendChild(qn)}),dt.appendChild(Ye),Pe.highlight_group>=0){let Ke=document.createElement("button");Ke.className="highlight-remove",Ke.textContent="Remove highlight",Ke.addEventListener("click",()=>{L(),M({type:"unhighlight"})}),dt.appendChild(Ke)}document.body.appendChild(dt);let ct=Ge.getBoundingClientRect();dt.style.left=ct.left+"px",dt.style.top=ct.bottom+4+"px";let Ze=Ke=>{Ke.type==="keydown"&&Ke.key!=="Escape"||Ke.type==="mousedown"&&dt.contains(Ke.target)||(L(),document.removeEventListener("mousedown",Ze,!0),document.removeEventListener("keydown",Ze,!0))};setTimeout(()=>{document.addEventListener("mousedown",Ze,!0),document.addEventListener("keydown",Ze,!0)},0)}function D(){if(!s.inspectorEl)return;s.inspectorEl.innerHTML="";let Ge=document.createElement("div");Ge.className="stub-panel",Ge.innerHTML='
Loading\u2026
Fetching properties from server.
',s.inspectorEl.appendChild(Ge)}async function F(Ge){let Pe=s.focusNets.has(Ge)?"remove":"add";Pe==="add"?s.focusNets.add(Ge):s.focusNets.delete(Ge);try{await s.websocketManager.request({type:"set_focus_nets",action:Pe,net_name:Ge})}catch(ke){console.error("set_focus_nets failed:",ke)}n(),c&&yi(c)}async function O(){s.focusNets.clear();try{await s.websocketManager.request({type:"set_focus_nets",action:"clear",net_name:""})}catch(Ge){console.error("set_focus_nets clear failed:",Ge)}n(),c&&yi(c)}async function z(Ge){let Pe=s.routeGuideNets.has(Ge)?"remove":"add";Pe==="add"?s.routeGuideNets.add(Ge):s.routeGuideNets.delete(Ge);try{await s.websocketManager.request({type:"set_route_guides",action:Pe,net_name:Ge})}catch(ke){console.error("set_route_guides failed:",ke)}r(),c&&yi(c)}function Z(Ge,Pe,ke,dt){return X1(Ge,Pe,ke,dt,s.designScale,s.designOriginX,s.designOriginY)}function H(Ge,Pe,ke){return Ge+(Pe-Ge)*ke}function te(Ge,Pe,ke){return Ge.map((dt,Ye)=>Math.round(H(dt,Pe[Ye],ke)))}function se(Ge,Pe){let ke=0;for(;keGe[ke+1].at;)ke++;let dt=Ge[ke],Ye=Ge[ke+1],ct=Math.max(0,Math.min(1,(Pe-dt.at)/(Ye.at-dt.at))),Ze={};for(let Ke of Object.keys(dt))Ke!=="at"&&(Ze[Ke]=Array.isArray(dt[Ke])?te(dt[Ke],Ye[Ke],ct):H(dt[Ke],Ye[Ke],ct));return Ze}function ne(Ge,Pe,ke,dt){if(nH()||typeof requestAnimationFrame!="function")return dt(),()=>{};let Ye=performance.now(),ct=!1,Ze=()=>{if(ct)return;let Ke=performance.now()-Ye;if(Ke>=Ge*Pe){dt();return}ke(Ke%Ge/Ge),requestAnimationFrame(Ze)};return Ze(),()=>{ct=!0}}function ue(Ge,Pe,ke=mp.highlight){s.view&&s.view.setOverlay(Ge,Pe,{order:ke})}let Ce=null,Q=()=>{},me=[255,242,122],tt=[{at:0,stroke:[255,246,176],width:7,alpha:1,fill:.28},{at:.55,stroke:[255,255,255],width:5,alpha:1,fill:.06},{at:1,stroke:[255,232,92],width:3,alpha:.95,fill:.14}],st={stroke:[255,232,92],width:3,alpha:1,fill:.14};function at(Ge,Pe,ke,dt){let[Ye,ct,Ze,Ke]=Z(Ge,Pe,ke,dt),gt=w/2**s.view.getZoom(),qn=Math.max(0,(gt-(Ze-Ye))/2),xi=Math.max(0,(gt-(Ke-ct))/2);return[Ye-qn,ct-xi,Ze+qn,Ke+xi]}function Ne(Ge){Ce&&ue("hover",Ce.map(([Pe,ke,dt,Ye])=>({kind:"rect",rect:at(Pe,ke,dt,Ye),stroke:Z1(Ge.stroke,Ge.alpha),width:Ge.width,fill:Z1(me,Ge.fill)})))}function Qe(){Ne(st)}function ot(){Q(),Ce=null,ue("hover",null),s.view?.off("zoom",Qe)}function xt(){ot(),s.websocketManager.request({type:"hover",select_id:-1}).then(()=>{}).catch(()=>{})}function fn(Ge){ot(),!(!s.view||!s.designScale||!Ge||Ge.length===0)&&(Ce=Ge,s.view.on("zoom",Qe),Q=ne(900,3,Pe=>Ne(se(tt,1-Math.pow(1-Pe,2))),()=>Ne(st)))}function Xt(Ge,Pe){Ge.classList.add("inspector-link"),Ge.addEventListener("click",ke=>{ke.stopPropagation(),cn(Pe)}),Ge.addEventListener("mouseenter",()=>{d!==null&&(s.websocketManager.cancel(d),d=null);let ke=s.websocketManager.request({type:"hover",select_id:Pe});d=ke.requestId,ke.then(dt=>{d=null,fn(dt.rects||[]),r()}).catch(()=>{d=null})}),Ge.addEventListener("mouseleave",()=>{xt(),r()})}function wn(Ge){let Pe=Ge>0?"select_next":"select_prev";u!==null&&(s.websocketManager.cancel(u),u=null),D();let ke=Pm(s),dt=s.websocketManager.request({type:Pe,use_dbu:s.showDbu});u=dt.requestId,dt.then(Ye=>{if(u=null,!!Y1(s,ke)){if(Ye.error){console.error("Selection cycle error:",Ye.error),yi(c);return}if(yi(Ye),Ye.type==="Inst"&&Ye.name&&(s.selectedInstanceName=Ye.name,s.schematicWidget&&s.schematicWidget.refresh()),ot(),Un(),Ye.bbox&&s.view&&s.designScale){let[ct,Ze,Ke,gt]=Ye.bbox;Ye.type!=="Inst"&&Zi(ct,Ze,Ke,gt,Ye.type),Ye.selection_count>1?it(Ye.bbox):Ei(Ye.bbox,Ye.type)}n()}}).catch(Ye=>{u=null,console.error("Selection cycle failed:",Ye),yi(c)})}function cn(Ge){u!==null&&(s.websocketManager.cancel(u),u=null),D();let Pe=Pm(s),ke=s.websocketManager.request({type:"inspect",select_id:Ge,use_dbu:s.showDbu});u=ke.requestId,ke.then(dt=>{if(u=null,!!Y1(s,Pe)){if(dt.error){console.error("Inspect error:",dt.error);return}if(yi(dt),ot(),Un(),dt.bbox&&s.view&&s.designScale){let[Ye,ct,Ze,Ke]=dt.bbox;dt.type!=="Inst"&&Zi(Ye,ct,Ze,Ke,dt.type),Ei(dt.bbox,dt.type)}r()}}).catch(dt=>{u=null,console.error("Inspect failed:",dt)})}function bi(){u!==null&&(s.websocketManager.cancel(u),u=null),D();let Ge=Pm(s),Pe=s.websocketManager.request({type:"inspect_back",use_dbu:s.showDbu});u=Pe.requestId,Pe.then(ke=>{if(u=null,!!Y1(s,Ge)){if(ke.error){console.error("Inspect back error:",ke.error);return}if(yi(ke),ot(),Un(),ke.bbox&&s.view&&s.designScale){if(ke.type!=="Inst"){let[dt,Ye,ct,Ze]=ke.bbox;Zi(dt,Ye,ct,Ze,ke.type)}Ei(ke.bbox,ke.type)}r()}}).catch(ke=>{u=null,console.error("Inspect back failed:",ke)})}let jt=null;function gn(){let Ge=jt&&s.designScale&&!(s.visibility&&s.visibility.highlight_selected===!1);ue("selection",Ge?[{kind:"rect",rect:Z(...jt),stroke:Z1("#ff0"),width:2,dash:[6,4]}]:null,mp.selection)}function Un(){jt=null,gn()}function Zi(Ge,Pe,ke,dt,Ye){jt=Ye==="Net"?null:[Ge,Pe,ke,dt],gn()}let Hi=null,yr=[{at:0,alpha:0,fill:0},{at:.5,alpha:1,fill:.28},{at:1,alpha:0,fill:0}];function Tr(){Hi&&(Hi(),Hi=null),ue("pulse",null)}function Ei(Ge,Pe){if(!Ge||!s.view||!s.designScale||(xr!==null&&de(),Tr(),s.visibility&&s.visibility.highlight_selected===!1)||Pe==="Net")return;let ke=Z(...Ge);Hi=ne(350,3,dt=>{let Ye=se(yr,.5-.5*Math.cos(Math.PI*dt));ue("pulse",[{kind:"rect",rect:ke,stroke:Z1("#ff0",Ye.alpha),width:3,fill:Z1("#ff0",Ye.fill)}])},()=>{Hi=null,ue("pulse",null)})}let xr=null;function oe(Ge,Pe){ue("anim",[{kind:"rect",rect:Ge,stroke:Z1("#ff0"),width:Pe,fill:Z1("#ff0",Pe===1?.39:0)}])}function de(){xr!==null&&(clearInterval(xr),xr=null),ue("anim",null)}function it(Ge,{repeats:Pe=6,intervalMs:ke=300}={}){if(!Ge||!s.view||!s.designScale)return;if(de(),nH()){Ei(Ge);return}let dt=Z(...Ge);oe(dt,1);let Ye=0,ct=Pe>0?Pe*3:1/0;xr=setInterval(()=>{if(Ye+=1,Ye>=ct){de();return}oe(dt,Ye%3+1)},ke)}s.clearSelectionPulse=Tr,s.renderSelectionOutline=gn,s.clearSelectionOutline=Un;function We(Ge,Pe,ke){let dt=document.createElement("div");dt.className="inspector-group";let Ye=document.createElement("div");Ye.className="inspector-group-header";let ct=document.createElement("span");ct.className="vis-arrow";let Ze=document.createElement("span");if(Ze.className="inspector-prop-name",Ze.textContent=Ge,Ze.title=Ge,Ye.appendChild(ct),Ye.appendChild(Ze),Pe!==null){let gt=document.createElement("span");gt.className="inspector-count",gt.textContent=`(${Pe})`,Ye.appendChild(gt)}dt.appendChild(Ye);let Ke=document.createElement("div");return Ke.className="inspector-group-children"+(ke?" collapsed":""),ct.textContent=ke?"\u25B6":"\u25BC",dt.appendChild(Ke),Ye.addEventListener("click",()=>{Ke.classList.toggle("collapsed"),ct.textContent=Ke.classList.contains("collapsed")?"\u25B6":"\u25BC"}),{group:dt,header:Ye,arrow:ct,body:Ke}}function _n(Ge){let Pe=Ge.column_headers||[],ke=Ge.row_headers||[],dt=Ge.data||[],Ye=Pe.some(gt=>gt!==""),ct=ke.some(gt=>gt!==""),Ze=document.createElement("table");if(Ze.className="inspector-table",Ye){let gt=document.createElement("thead"),qn=document.createElement("tr");ct&&qn.appendChild(document.createElement("th"));for(let xi of Pe){let Bi=document.createElement("th");Bi.textContent=xi,qn.appendChild(Bi)}gt.appendChild(qn),Ze.appendChild(gt)}let Ke=document.createElement("tbody");return dt.forEach((gt,qn)=>{let xi=document.createElement("tr");if(ct){let Bi=document.createElement("th");Bi.textContent=ke[qn]||"",xi.appendChild(Bi)}for(let Bi of gt){let xn=document.createElement("td");xn.textContent=Bi,xi.appendChild(xn)}Ke.appendChild(xi)}),Ze.appendChild(Ke),Ze}function Er(Ge,Pe){if(Ge.table){let Ze=(Ge.table.data||[]).length,{group:Ke,body:gt}=We(Ge.name,Ze,Ze>=10),qn=document.createElement("div");return qn.className="inspector-table-scroll",qn.appendChild(_n(Ge.table)),gt.appendChild(qn),Ke}if(Ge.children){let Ze=Ge.children.length<10,{group:Ke,body:gt}=We(Ge.name,Ge.children.length,!Ze);for(let qn of Ge.children)gt.appendChild(Er(qn,Pe));return Ke}let ke=document.createElement("div");ke.className="inspector-prop";let dt=document.createElement("span");dt.className="inspector-prop-name",dt.textContent=Ge.name||"",dt.title=Ge.name||"";let Ye=document.createElement("span");Ye.className="inspector-prop-value",Ye.textContent=Ge.value||"",ke.appendChild(dt),ke.appendChild(Ye);let ct=Ge.editable&&Pe&&(Pe.onPropertyEdit||Pe.onPropertyChange)&&Ge.editor&&(Ge.editor.type==="list"||Ge.editor.type==="bool");if(ct&&Ge.value_select_id===void 0)ke.replaceChild(x(Ge,Pe),Ye);else if(ct){let Ze=document.createElement("button");Ze.className="inspector-edit-btn",Ze.title="Edit "+Ge.name,Ze.textContent="\u270E",Ze.addEventListener("click",Ke=>{Ke.stopPropagation();let gt=x(Ge,Pe);ke.replaceChild(gt,Ye),Ze.remove(),gt.focus()}),ke.appendChild(Ze)}else Ge.editable&&Pe&&(Pe.onPropertyChange||Pe.onPropertyEdit)&&(Ye.contentEditable=!0,Ye.classList.add("inspector-editable"),Ye.addEventListener("blur",()=>{let Ze=Ye.textContent;if(Ze!==Ge.value){if(Pe.onPropertyChange){Pe.onPropertyChange(Ge.name,Ze);return}if(Ge.editor&&Ge.editor.type==="number"){let Ke=Number(Ze);if(Ze.trim()===""||Number.isNaN(Ke)){Nb("Not a number: "+Ze),Ye.textContent=Ge.value;return}Pe.onPropertyEdit(Ge,{value:Ke});return}Pe.onPropertyEdit(Ge,{value:Ze})}}),Ye.addEventListener("keydown",Ze=>{Ze.key==="Enter"&&(Ze.preventDefault(),Ye.blur()),Ze.key==="Escape"&&(Ye.textContent=Ge.value,Ye.blur())}));return Ge.name_select_id!==void 0&&Ge.value_select_id===void 0?(Xt(ke,Ge.name_select_id),dt.classList.add("inspector-link")):Ge.name_select_id!==void 0&&Xt(dt,Ge.name_select_id),Ge.value_select_id!==void 0&&Xt(Ye,Ge.value_select_id),ke}let qi=140,Te=60,ve=500,_t=qi;function mn(){s.inspectorEl&&s.inspectorEl.style.setProperty("--inspector-name-w",_t+"px")}function yn(){let Ge=document.createElement("div");return Ge.className="inspector-col-resizer",Ge.title="Drag to resize the name column",Ge.addEventListener("mousedown",Pe=>{Pe.preventDefault();let ke=Pe.clientX,dt=_t;Ge.classList.add("dragging");let Ye=Ze=>{_t=Math.max(Te,Math.min(ve,dt+Ze.clientX-ke)),mn()},ct=()=>{Ge.classList.remove("dragging"),document.removeEventListener("mousemove",Ye),document.removeEventListener("mouseup",ct)};document.addEventListener("mousemove",Ye),document.addEventListener("mouseup",ct)}),Ge}function Sn(Ge){!Ge||!s.view||!s.designScale||s.view.fitWorldRect(Z(...Ge),{padding:[20,20]})}function yi(Ge){if(!s.inspectorEl)return;if(c=Ge,s.inspectorEl.innerHTML="",!Ge||!Ge.properties||Ge.properties.length===0){de();let Ye=document.createElement("div");Ye.className="stub-panel",Ye.innerHTML='
Inspector
Select an object in the layout to inspect its properties.
',s.inspectorEl.appendChild(Ye);return}if(!Ge.onPropertyChange&&!Ge.onPropertyEdit&&!la(s)&&(Ge.onPropertyEdit=(Ye,ct)=>_(Ye.name,ct)),Ge){let Ye=document.createElement("div");Ye.className="inspector-toolbar";let ct=document.createElement("button");if(ct.className="or-btn or-btn-icon",ct.title="Back",ct.innerHTML=Tdn,ct.disabled=!Ge.can_navigate_back,ct.addEventListener("click",()=>bi()),Ye.appendChild(ct),Ge.bbox){let Ze=document.createElement("button");Ze.className="or-btn or-btn-icon",Ze.title="Zoom to",Ze.innerHTML=Mdn,Ze.addEventListener("click",()=>Sn(Ge.bbox)),Ye.appendChild(Ze)}if(Ge.type==="Net"&&Ge.name){let Ze=s.focusNets.has(Ge.name),Ke=document.createElement("button");Ke.className="or-btn or-btn-icon",Ke.title=Ze?"De-focus net":"Focus net",Ke.innerHTML=Ze?Adn:Cdn,Ke.addEventListener("click",()=>F(Ge.name)),Ye.appendChild(Ke)}if(Ge.type==="Net"&&Ge.name&&Ge.has_guides){let Ze=s.routeGuideNets.has(Ge.name),Ke=document.createElement("button");Ke.className="or-btn or-btn-icon",Ke.title=Ze?"Hide route guides":"Show route guides",Ke.innerHTML=Ze?Ldn:Pdn,Ke.addEventListener("click",()=>z(Ge.name)),Ye.appendChild(Ke)}if(Ge.type==="Net"&&Ge.name&&s.showInsertBufferDialog){let Ze=document.createElement("button");Ze.className="or-btn or-btn-icon",Ze.title="Insert buffer",Ze.innerHTML=Ddn,Ze.addEventListener("click",()=>s.showInsertBufferDialog(Ge.name)),Ye.appendChild(Ze)}if(s.focusNets.size>0){let Ze=document.createElement("button");Ze.className="or-btn or-btn-icon",Ze.title="Clear focus nets",Ze.innerHTML=kdn,Ze.addEventListener("click",()=>O()),Ye.appendChild(Ze)}if(typeof Ge.highlight_group=="number"&&!la(s)&&(s.techData?.highlight_colors||[]).length){let Ze=document.createElement("button");Ze.className="or-btn or-btn-icon inspector-highlight-btn";let Ke=Ge.highlight_group;if(Ze.title=Ke>=0?"Highlight group "+(Ke+1):"Add to highlight group",Ze.innerHTML=Sdn,Ke>=0){let gt=s.techData.highlight_colors[Ke];Ze.style.backgroundColor=`rgba(${gt[0]}, ${gt[1]}, ${gt[2]}, 0.45)`,Ze.style.borderColor=`rgb(${gt[0]}, ${gt[1]}, ${gt[2]})`}Ze.addEventListener("click",()=>I(Ze,Ge)),Ye.appendChild(Ze)}if(Array.isArray(Ge.actions)&&!la(s))for(let Ze of Ge.actions){let Ke=document.createElement("button");Ke.className="or-btn inspector-action-btn",Ke.title=Ze,Ze==="Delete"?(Ke.classList.add("or-btn-icon","or-btn-danger-hover"),Ke.innerHTML=Edn):(Ke.classList.add("or-btn-sm"),Ke.textContent=Ze),Ke.addEventListener("click",()=>T(Ze,Ge)),Ye.appendChild(Ke)}s.inspectorEl.appendChild(Ye)}let Pe=Ge.selection_count||0,ke=typeof Ge.selection_index=="number"?Ge.selection_index:-1;if(Pe>1&&ke>=0){let Ye=document.createElement("div");Ye.className="inspector-selection-nav";let ct=document.createElement("button");ct.className="or-btn or-btn-icon",ct.title="Previous (Shift+click to multi-select)",ct.innerHTML=Rdn,ct.addEventListener("click",()=>wn(-1));let Ze=document.createElement("span");Ze.className="inspector-selection-label",Ze.textContent=ke+1+" / "+Pe;let Ke=document.createElement("button");Ke.className="or-btn or-btn-icon",Ke.title="Next",Ke.innerHTML=Idn,Ke.addEventListener("click",()=>wn(1)),Ye.appendChild(ct),Ye.appendChild(Ze),Ye.appendChild(Ke),s.inspectorEl.appendChild(Ye)}let dt=document.createElement("div");dt.className="inspector-rows";for(let Ye of Ge.properties)dt.appendChild(Er(Ye,Ge));dt.appendChild(yn()),s.inspectorEl.appendChild(dt),mn()}function hi(Ge){let Pe=document.createElement("div");Pe.className="inspector",s.inspectorEl=Pe,Ge.element.appendChild(Pe),yi(null)}function ri(){if(c){if(c.type==="Ruler"){s.rulerManager&&s.rulerManager._selectedRulerId!==null&&s.rulerManager._selectRuler(s.rulerManager._selectedRulerId);return}s.websocketManager&&cn(-1)}}return{createInspector:hi,updateInspector:yi,highlightBBox:Zi,pulseHighlight:Ei,animateSelection:it,stopSelectionAnimation:de,navigateInspector:cn,refreshInspector:ri}}var Jhe=class{constructor(n,r,c){this._app=r,this._refreshOverlay=c||(()=>{}),this._data={selection:[],groups:[],truncated:!1},this._tab="selected",this._filter="",this._sortKey=null,this._sortAsc=!0,this._pendingRefresh=null,this._inFlight=!1,this._staleWhileInFlight=!1,this._visible=!0,this._el=document.createElement("div"),this._el.className="selection-browser",n.element.appendChild(this._el),n.on?.("show",()=>{this._visible=!0,this.refresh()}),n.on?.("hide",()=>{this._visible=!1}),n.on?.("destroy",()=>{this._visible=!1,this._staleWhileInFlight=!1,this._pendingRefresh!==null&&(clearTimeout(this._pendingRefresh),this._pendingRefresh=null)}),this._render(),this.refresh()}scheduleRefresh(){!this._visible||this._pendingRefresh!==null||(this._pendingRefresh=setTimeout(()=>{this._pendingRefresh=null,this.refresh()},150))}refresh(){if(!this._visible||la(this._app))return;if(this._inFlight){this._staleWhileInFlight=!0;return}this._inFlight=!0;let n=()=>{this._inFlight=!1,this._staleWhileInFlight&&(this._staleWhileInFlight=!1,this.refresh())};this._app.websocketManager.request({type:"list_selection"}).then(r=>{r.ok&&(this._data=r,this._render()),n()}).catch(n)}_entries(){let n;this._tab==="selected"?n=(this._data.selection||[]).map((c,u)=>({row:c,index:u,group:-1})):n=(this._data.groups||[]).flatMap((c,u)=>c.map((d,b)=>({row:d,index:b,group:u})));let r=this._filter.trim().toLowerCase();if(r&&(n=n.filter(({row:c})=>(c.name||"").toLowerCase().includes(r)||(c.type||"").toLowerCase().includes(r))),this._sortKey){let c=this._sortKey,u=this._sortAsc?1:-1;n=n.slice().sort((d,b)=>u*String(d.row[c]||"").localeCompare(String(b.row[c]||"")))}return n}_fmtCoord(n){if(this._app.showDbu)return String(n);let r=this._app.getDbuPerMicron?this._app.getDbuPerMicron():1e3;return(n/r).toFixed(3)}_fmtBounds(n){if(!n)return"";let[r,c,u,d]=n;return`(${this._fmtCoord(r)}, ${this._fmtCoord(c)}), (${this._fmtCoord(u)}, ${this._fmtCoord(d)})`}_inspectRow(n,r){let c=n.group<0?{type:"inspect_selection",index:n.index,use_dbu:this._app.showDbu}:{type:"inspect_group",group:n.group,index:n.index,use_dbu:this._app.showDbu};this._app.websocketManager.request(c).then(u=>{if(!u.ok){this.refresh();return}this._app.updateInspector&&this._app.updateInspector(u),r&&this._app.focusComponent&&this._app.focusComponent("Inspector"),this._refreshOverlay()}).catch(()=>{})}_deselectRow(n){this._app.websocketManager.request({type:"deselect",index:n.index}).then(()=>{this.refresh(),this._refreshOverlay()}).catch(()=>{})}_clearHighlights(){this._app.websocketManager.request({type:"clear_highlights",group:-1}).then(()=>{this.refresh(),this._refreshOverlay(),this._app.refreshInspector&&this._app.refreshInspector()}).catch(()=>{})}_zoomToBBox(n){if(!n||!this._app.designScale||!this._app.view)return;let[r,c,u,d]=n,b=this._app.getDbuPerMicron?this._app.getDbuPerMicron():1e3,w=Math.min(10*b,2*Math.max(u-r,d-c));this._app.view.fitWorldRect(X1(r-w,c-w,u+w,d+w,this._app.designScale,this._app.designOriginX,this._app.designOriginY))}_render(){this._app.stopSelectionAnimation&&this._app.stopSelectionAnimation(),this._el.innerHTML="";let n=(this._data.selection||[]).length,r=(this._data.groups||[]).reduce((b,w)=>b+w.length,0),c=document.createElement("div");c.className="sb-tabs";for(let[b,w,_]of[["selected","Selected",n],["highlighted","Highlighted",r]]){let x=document.createElement("button");x.className="sb-tab"+(this._tab===b?" active":""),x.textContent=`${w} (${_})`,x.addEventListener("click",()=>{this._tab=b,this._render()}),c.appendChild(x)}let u=document.createElement("button");if(u.className="or-btn or-btn-sm sb-tool",u.title="Refresh",u.textContent="\u27F3",u.addEventListener("click",()=>this.refresh()),c.appendChild(u),this._tab==="highlighted"&&r>0){let b=document.createElement("button");b.className="or-btn or-btn-sm sb-tool",b.title="Clear all highlights",b.textContent="Clear",b.addEventListener("click",()=>this._clearHighlights()),c.appendChild(b)}this._el.appendChild(c);let d=document.createElement("input");if(d.type="text",d.className="sb-filter",d.placeholder="Filter by name or type\u2026",d.value=this._filter,d.addEventListener("input",()=>{this._filter=d.value,this._renderTable()}),this._el.appendChild(d),this._data.truncated){let b=document.createElement("div");b.className="sb-truncated",b.textContent="List truncated \u2014 showing the first 1000 entries per set.",this._el.appendChild(b)}this._tableWrap=document.createElement("div"),this._tableWrap.className="sb-table-wrap",this._el.appendChild(this._tableWrap),this._renderTable()}_renderTable(){this._tableWrap.innerHTML="";let n=this._entries();if(!n.length){let _=document.createElement("div");_.className="sb-empty",_.textContent=this._tab==="selected"?"Nothing selected.":"Nothing highlighted.",this._tableWrap.appendChild(_);return}let r=document.createElement("table");r.className="sb-table";let c=document.createElement("thead"),u=document.createElement("tr"),d=[["name","Object"],["type","Type"],[null,"Bounds"]];this._tab==="highlighted"&&d.push([null,"Group"]),d.push([null,""]);for(let[_,x]of d){let T=document.createElement("th");T.textContent=x,_&&(T.classList.add("sb-sortable"),this._sortKey===_&&(T.textContent+=this._sortAsc?" \u25B2":" \u25BC"),T.addEventListener("click",()=>{this._sortKey===_?this._sortAsc=!this._sortAsc:(this._sortKey=_,this._sortAsc=!0),this._renderTable()})),u.appendChild(T)}c.appendChild(u),r.appendChild(c);let b=document.createElement("tbody"),w=this._app.techData?.highlight_colors||[];for(let _ of n){let x=document.createElement("tr");x.className="sb-row";let T=document.createElement("td");T.textContent=_.row.name||"";let M=document.createElement("td");M.textContent=_.row.type||"";let L=document.createElement("td");if(L.textContent=this._fmtBounds(_.row.bbox),x.appendChild(T),x.appendChild(M),x.appendChild(L),this._tab==="highlighted"){let D=document.createElement("td"),F=document.createElement("span");F.className="sb-chip";let O=w[_.group];O&&(F.style.backgroundColor=`rgb(${O[0]}, ${O[1]}, ${O[2]})`),D.appendChild(F),D.appendChild(document.createTextNode(` Group ${_.group+1}`)),x.appendChild(D)}let I=document.createElement("td");if(I.className="sb-actions",_.row.bbox){let D=document.createElement("button");D.className="sb-row-btn",D.title="Zoom to",D.textContent="\u2316",D.addEventListener("click",F=>{F.stopPropagation(),this._zoomToBBox(_.row.bbox)}),I.appendChild(D)}if(this._tab==="selected"){let D=document.createElement("button");D.className="sb-row-btn",D.title="De-select",D.textContent="\u2715",D.addEventListener("click",F=>{F.stopPropagation(),this._deselectRow(_)}),I.appendChild(D)}x.appendChild(I),x.addEventListener("click",()=>this._inspectRow(_,!1)),x.addEventListener("dblclick",()=>this._inspectRow(_,!0)),_.row.bbox&&(x.addEventListener("mouseenter",()=>{this._app.animateSelection&&this._app.animateSelection(_.row.bbox,{repeats:0})}),x.addEventListener("mouseleave",()=>{this._app.stopSelectionAnimation&&this._app.stopSelectionAnimation()})),b.appendChild(x)}r.appendChild(b),this._tableWrap.appendChild(r),ak(r)}};var d3t="options-dialog",h3t=[{label:"System default",value:""},{label:"Sans-serif",value:"sans-serif"},{label:"Serif",value:"serif"},{label:"Monospace",value:"monospace"},{label:"Helvetica / Arial",value:"Helvetica, Arial, sans-serif"},{label:"Georgia",value:"Georgia, 'Times New Roman', serif"},{label:"Courier",value:"'Courier New', Courier, monospace"}],Bdn=100,Qhe=70,ede=200;function rH(s){let n=s===""||s===null?NaN:Math.round(Number(s));return Number.isFinite(n)?Math.min(ede,Math.max(Qhe,n)):Bdn}function p3t(s){let{overlay:n,close:r,okBtn:c,showError:u}=MO("Arrow keys scroll step",`
+ min="${QW}" max="${eH}" step="1" + value="${tH(s.arrowStep)}">
How far one arrow-key press pans the layout. - Default ${F2t}.
`,"Apply",FJt),_=s.querySelector(".opt-step");_.focus(),_.select();function S(){let y=_.value.trim(),I=Number(y);if(y===""||!Number.isFinite(I)){m("Step must be a number.");return}if(IOU){m(`Step must be between ${NU} and ${OU} px.`);return}d.setArrowStep(I),h()}return p.addEventListener("click",S),_.addEventListener("keydown",y=>{y.key==="Enter"&&(y.preventDefault(),S())}),{close:h}}function zJt(d){let s=d.fontFamily||"",h=BJt.some(V=>V.value===s),p=BJt.map(V=>``).join("")+(h?"":``),{overlay:m,close:_,okBtn:S,showError:y}=gR("Application font",` + Default ${V5e}.
`,"Apply",d3t),d=n.querySelector(".opt-step");d.focus(),d.select();function b(){let w=d.value.trim(),_=Number(w);if(w===""||!Number.isFinite(_)){u("Step must be a number.");return}if(_eH){u(`Step must be between ${QW} and ${eH} px.`);return}s.setArrowStep(_),r()}return c.addEventListener("click",b),d.addEventListener("keydown",w=>{w.key==="Enter"&&(w.preventDefault(),b())}),{close:r}}function g3t(s){let n=s.fontFamily||"",r=h3t.some(D=>D.value===n),c=h3t.map(D=>``).join("")+(r?"":``),{overlay:u,close:d,okBtn:b,showError:w}=MO("Application font",`
- +
+ value="${r?"":Q5e(n)}">
+ min="${Qhe}" max="${ede}" step="5" + value="${rH(s.fontScale)}">
The quick brown fox jumps over the lazy dog 0123456789
Applies to the panels, menus and console. Text drawn into the layout is rendered on the server and is not - affected.
`,"Apply",FJt),I=m.querySelector(".opt-family"),N=m.querySelector(".opt-custom"),B=m.querySelector(".opt-scale"),P=m.querySelector(".opt-preview");function U(){P.style.fontFamily=N.value.trim()||I.value,P.style.fontSize=`calc(13px * ${UU(B.value)/100})`}for(let V of[I,N,B])V.addEventListener("input",U);U();function j(){let V=B.value.trim(),et=Number(V);if(V===""||!Number.isFinite(et)){y("Size must be a number.");return}if(etlnt){y(`Size must be between ${unt} and ${lnt} %.`);return}d.setAppFont({family:N.value.trim()||I.value,scale:et}),_()}S.addEventListener("click",j);for(let V of[N,B])V.addEventListener("keydown",et=>{et.key==="Enter"&&(et.preventDefault(),j())});return{close:_}}function V2t(d){return String(d).replace(/&/g,"&").replace(/"/g,""").replace(//g,">")}var Gke='',Wke='';function bR(d){let s=document.createElement("span");return s.className="vis-name",d!=null&&(s.textContent=d),s}function dS(){let d=document.createElement("span");return d.className="vis-sel-cb vis-sel-spacer",d}function jJt(){let d=document.createElement("div");d.className="display-controls-header",d.appendChild(bR(""));for(let[s,h]of[[Gke,"Visible"],[Wke,"Selectable"]]){let p=document.createElement("span");p.className="vis-header-icon",p.title=h,p.innerHTML=s,d.appendChild(p)}return d}var hnt=class{constructor(s,h,p){this.visibility=s,this.selectability=h,this.onChange=p;let m=()=>{this._syncAll(),this.onChange()};this.model=new Qw(m),this.selModel=new Qw(m)}add(s){return this.model.addFromSpec(this._enrichSpec(s,"")),this.selModel.addFromSpec(this._enrichSelSpec(s,"",!1)),this}render(s){for(let h of this.model.roots)s.appendChild(this._dom(h));this._syncAll()}_nodeId(s,h){let p=s.key||s.label;return h?h+"/"+p:p}_enrichSpec(s,h){let p=this._nodeId(s,h),m={id:p,data:s};return s.children?m.children=s.children.map(_=>this._enrichSpec(_,p)):s.key&&(m.checked=!!this.visibility[s.key]),s.disabled!=null&&(m.disabled=s.disabled),m}_enrichSelSpec(s,h,p){let m=s.addSelectable===!0?!0:s.addSelectable===!1?!1:p,_=this._nodeId(s,h),S={id:_,data:s,hasCheckbox:!1};if(s.children){S.children=s.children.map(I=>this._enrichSelSpec(I,_,m));let y=I=>I.some(N=>N.hasCheckbox||N.children&&y(N.children));S.hasCheckbox=y(S.children),S.hasCheckbox&&(S.checked=!0)}else if(s.key){let y=s.selectable===!0||s.selectable!==!1&&p;S.hasCheckbox=y,y&&(S.checked=this.selectability[s.key]!==!1)}return S}_syncAll(){this.model.forEach(s=>{s.cb&&(s.cb.checked=s.checked,s.cb.indeterminate=s.indeterminate);let h=s.data;h.key&&(this.visibility[h.key]=s.checked),h.visKey&&(this.visibility[h.visKey]=s.checked||s.indeterminate)}),this.selModel.forEach(s=>{if(!s.hasCheckbox)return;let h=s.data;if(h.key&&(this.selectability[h.key]=s.checked),!s.selCb)return;s.selCb.checked=s.checked,s.selCb.indeterminate=s.indeterminate;let p=this.model.get(s.id),m=p&&!p.checked&&!p.indeterminate;s.selCb.disabled=m,s.selLabel&&s.selLabel.classList.toggle("vis-sel-disabled",m)}),this.model.forEach(s=>{let h=s.data;if(h.disabledBy&&s.el){let p=!this.visibility[h.disabledBy];s.el.classList.toggle("disabled",p)}})}_buildSelCheckbox(s){let h=this.selModel.get(s.id);if(!h||!h.hasCheckbox)return null;let p=document.createElement("input");return p.type="checkbox",p.className="vis-sel-cb",p.title="Selectable",p.addEventListener("change",()=>{this.selModel.check(h.id,p.checked)}),h.selCb=p,p}_dom(s){let h=s.data,p=document.createElement("input");p.type="checkbox",p.className="vis-cb",p.title="Visible",s.cb=p,p.addEventListener("change",()=>this.model.check(s.id,p.checked));let m=this._buildSelCheckbox(s),_=P=>{if(P.appendChild(p),m){P.appendChild(m);let U=this.selModel.get(s.id);U&&(U.selLabel=P)}else P.appendChild(dS())};if(!s.children.length){let P=document.createElement("div");P.className="vis-leaf";let U=document.createElement("span");return U.className="vis-arrow",U.style.visibility="hidden",U.textContent="\u25B6",P.appendChild(U),P.appendChild(bR(h.label)),_(P),s.el=P,P}let S=document.createElement("div");S.className="vis-group";let{header:y,arrow:I,name:N}=rk();N.textContent=h.label,_(y),S.appendChild(y);let B=document.createElement("div");B.className="vis-group-children",h.disabled&&B.classList.add("disabled");for(let P of s.children)B.appendChild(this._dom(P));return S.appendChild(B),sk(y,I,B,!0),S}};function zU(d,s,h,p){let m=new Set,_=Math.max(0,d-s),S=Math.min(p-1,d+h);for(let y=_;y<=S;y++)m.add(y);return m}function $ke(d){let s={};for(let[h,p]of Object.entries(d||{}))p!==1&&(s[h]=p);return s}function fnt(d,s){return(d||[]).some(h=>h.every(p=>!!s[p]))}function Vke(d,s){return d.map(h=>{let p=!s.has(h.path);return{id:h.path,parentId:h.parent!=null?h.parent:null,hasCheckbox:h.parent!=null,checked:p,data:{path:h.path,name:h.name,master:h.master,depth:h.depth}}})}var HJt=[[70,130,210],[200,50,50],[50,180,80],[200,160,40],[160,60,200],[40,190,190],[220,120,50],[180,70,150]];function GJt(d,s,h,p,m,_,S){if(!d.displayControlsEl)return;d.displayControlsEl.innerHTML="",d.allLayers=[],d.displayControlsEl.appendChild(jJt());let y=d.mergeTiles?d.MergedTileLayer:null,I=new Set;function N(){for(let Jt of I)Jt.refreshTiles();I.clear()}function B(Jt,nn){if(!y){let he=new p(d.websocketManager,Jt,{opacity:1,zIndex:nn});return he._orShow=()=>he.addTo(d.map),he._orHide=()=>d.map.removeLayer(he),he}let vn={layer:Jt,opacity:1,visible:!1};return{_orItem:vn,_orPane:null,refreshTiles(){this._orPane&&(I.add(this._orPane),N())},_orShow(){R2t(vn,!0)&&this._orPane&&I.add(this._orPane)},_orHide(){R2t(vn,!1)&&this._orPane&&I.add(this._orPane)}}}function P(Jt,nn,vn,he){let Mn=new p(d.websocketManager,Jt,{zIndex:vn});return he&&Mn.addTo(d.map),nn&&(d[nn]=Mn),d.allLayers.push(Mn),Mn}P("_instances",null,0,!0),P("_pins","pinsLayer",1,s.pins),P("_modules","modulesLayer",2,s.module_view),d.overlayLayers=(m&&m.overlays||[]).map(Jt=>({def:Jt,layer:P(Jt.name,null,Jt.z_index,fnt(Jt.shown_by,s))}));let U=[],j=[],V=null,et=new Set,Q=new Set;try{let Jt=window.sessionStorage.getItem("or_hidden_layers");Jt&&(et=new Set(JSON.parse(Jt)))}catch{}try{let Jt=window.sessionStorage.getItem("or_nonselectable_layers");Jt&&(Q=new Set(JSON.parse(Jt)))}catch{}try{let Jt=window.sessionStorage.getItem("or_layer_patterns");Jt&&Object.assign(d.layerPatterns,JSON.parse(Jt))}catch{}function X(){try{window.sessionStorage.setItem("or_layer_patterns",JSON.stringify($ke(d.layerPatterns)))}catch{}}function gt(Jt,nn,vn){vn===1?delete d.layerPatterns[Jt]:d.layerPatterns[Jt]=vn,X(),nn&&typeof nn.refreshTiles=="function"&&nn.refreshTiles()}let ft=[{label:"Solid",value:1},{label:"Diagonal",value:2},{label:"Cross",value:3},{label:"Dots",value:4},{label:"None (no fill)",value:0}],xt=0,Bt=3;function Dt(Jt,nn="layers",vn=void 0){let he=[],Mn=Jt.type==="category"?vn:Jt.path,Sn=Jt.flipped===!0,gn=Jt.instances||[],Ce=gn.filter(Qt=>Qt.type!=="category"),dn=gn.filter(Qt=>Qt.type==="category"),jn=Jt.layers||[],ar=xt;xt+=jn.length;function gr(Qt,Mi){let sn=Qt.map((Zn,oi)=>oi);Mi&&sn.reverse(),sn.forEach(Zn=>{let oi=Qt[Zn],Jr=nn+"/"+(oi.name||Zn);he.push(Dt(oi,Jr,Mn))})}function tr(){(Sn?jn.map((Mi,sn)=>sn).reverse():jn.map((Mi,sn)=>sn)).forEach(Mi=>{let sn=jn[Mi],Zn=sn.name||sn,oi=ar+Mi,Jr=Bt++,Bs=B(Zn,Jr),Oc=`${nn}/${Zn}`;Bs._nodeId=Oc;let ru=!et.has(Oc);ru&&(Bs._orShow(),d.visibleLayers.add(Oc),d.visibleLayerNames.add(Zn)),y||d.allLayers.push(Bs),U.push(Bs),j.push(Oc),he.push({id:Oc,data:{name:Zn,layer:Bs,color:sn.color,colorIndex:oi,nodeId:Oc,ownerChipletPath:Mn},checked:ru})})}gr(Ce,!1),Sn&&tr(),gr(dn,Sn),Sn||tr();let Ln={name:Jt.name,isInstance:!0};return Jt.type==="category"&&(Jt.name==="Implant"||Jt.name==="Other")&&(Ln.startCollapsed=!0),Jt.type!=="category"&&(Ln.chipletPath=Jt.path),{id:nn,data:Ln,children:he}}let Pt;if(m.layer_hierarchy?Pt=Dt(m.layer_hierarchy,"layers_parent"):Pt={id:"layers_parent",children:m.layers.map((Jt,nn)=>{let vn=B(Jt,nn+3),he=`layers_parent/${Jt}`;vn._nodeId=he;let Mn=!et.has(he);return Mn&&(vn._orShow(),d.visibleLayers.add(he),d.visibleLayerNames.add(Jt)),y||d.allLayers.push(vn),U.push(vn),j.push(he),{id:he,data:{name:Jt,layer:vn,colorIndex:nn,nodeId:he},checked:Mn}})},y&&U.length>0){let vn=function(){let{width:dn,height:jn}=XKt(d.map.getContainer()),ar=Kw(),gr=qKt(dn,jn,ar),tr=VKt(ar,d.tileDpr?d.tileDpr():1);return{count:d.mergeGroupCount||YKt({budgetBytes:ZKt(nn,gr,tr),tilesPerPane:gr,bytesPerTile:tr,paneCount:Jt.length}),tilesPerPane:gr,perTile:tr}},he=function(dn,jn,ar){let gr=(dn+Qet)*jn*ar;return{layers:Jt.length,groups:dn,tilesPerPane:jn,unmergedPanes:Qet,budgetMB:Math.round(nn/(1024*1024)),estimatedMB:Math.round(gr/(1024*1024))}},Mn=function(dn,jn){let ar=0;jn.forEach((gr,tr)=>{for(let Ln=0;Lndn._orItem),nn=d.tileBudgetBytes||I2t,Sn=vn(),gn=D2t(Jt,Sn.count),Ce=tJt(y,d.websocketManager,gn,d.map,3);Mn(Ce,gn),d.allLayers.push(...Ce),d.mergedPanes=Ce,d.mergeStats=he(Ce.length,Sn.tilesPerPane,Sn.perTile),console.log("[tiles] merged %d layers into %d panes (~%d MB of %d MB budget, %d tiles/pane)",d.mergeStats.layers,d.mergeStats.groups,d.mergeStats.estimatedMB,d.mergeStats.budgetMB,Sn.tilesPerPane),d.map.on("resize",()=>{let dn=vn();if(dn.count>=d.mergedPanes.length)return;let jn=D2t(Jt,dn.count),ar=d.mergedPanes.slice(0,jn.length);for(let gr of d.mergedPanes.slice(jn.length)){d.map.removeLayer(gr);let tr=d.allLayers.indexOf(gr);tr>=0&&d.allLayers.splice(tr,1)}d.mergedPanes=ar,Mn(ar,jn),ar.forEach((gr,tr)=>gr.setItems(jn[tr])),d.mergeStats=he(ar.length,dn.tilesPerPane,dn.perTile),console.log("[tiles] window grew \u2014 regrouped %d layers into %d panes (~%d MB of %d MB budget, %d tiles/pane)",d.mergeStats.layers,d.mergeStats.groups,d.mergeStats.estimatedMB,d.mergeStats.budgetMB,dn.tilesPerPane)})}function se(Jt){if(!Jt.children||Jt.children.length===0){let nn=Jt.data&&Jt.data.name,vn=nn?!Q.has(nn):!0;return vn&&nn&&d.selectableLayers.add(nn),{id:Jt.id,data:{name:nn},checked:vn}}return{id:Jt.id,data:{name:Jt.data&&Jt.data.name},children:Jt.children.map(se)}}let ot=se(Pt),Lt=new Qw(()=>{d.visibleLayerNames.clear();let Jt=[],nn={},vn=!1,he=!1,Mn=V&&d.visibleChiplets instanceof Set;Lt.forEach(gn=>{if(gn.cb&&(gn.cb.checked=gn.checked,gn.cb.indeterminate=gn.indeterminate),gn.data&&gn.data.layer){let Ce=gn.data.nodeId||gn.data.name;Jt.push(Ce),gn.checked?(gn.data.layer._orShow(),d.visibleLayers.add(Ce),d.visibleLayerNames.add(gn.data.name)):(gn.data.layer._orHide(),d.visibleLayers.delete(Ce))}if(Mn&&gn.data&&gn.data.chipletPath){let Ce=gn.data.chipletPath,dn=V.get(Ce);if(dn){let jn=gn.checked||gn.indeterminate,ar={checked:gn.checked,indeterminate:gn.indeterminate};(dn.checked!==gn.checked||dn.indeterminate!==gn.indeterminate)&&(nn[Ce]=ar,vn=!0),d.visibleChiplets.has(Ce)!==jn&&(he=!0)}}}),N(),ln(),d.pinsLayer&&d.map.hasLayer(d.pinsLayer)&&d.pinsLayer.refreshTiles();for(let{def:gn,layer:Ce}of d.overlayLayers||[])fnt(gn.layers_by,s)&&d.map.hasLayer(Ce)&&Ce.refreshTiles();let Sn=Jt.filter(gn=>!d.visibleLayers.has(gn));try{window.sessionStorage.setItem("or_hidden_layers",JSON.stringify(Sn))}catch{}d.syncDisplayState(),he?V.mirrorStates(nn):vn&&(V.mirrorStatesQuiet(nn),V.forEach(gn=>{gn.cb&&(gn.cb.checked=gn.checked,gn.cb.indeterminate=gn.indeterminate)}))});d.layerModel=Lt,Lt.addFromSpec(Pt);let be=new Qw(()=>{d.selectableLayers.clear(),be.forEach(nn=>{nn.checked&&nn.data&&nn.data.name&&d.selectableLayers.add(nn.data.name)}),ln();let Jt=m.layers.filter(nn=>!d.selectableLayers.has(nn));try{window.sessionStorage.setItem("or_nonselectable_layers",JSON.stringify(Jt))}catch{}d.syncDisplayState()});be.addFromSpec(ot);function ln(){be.forEach(Jt=>{if(!Jt.selCb)return;Jt.selCb.checked=Jt.checked,Jt.selCb.indeterminate=Jt.indeterminate;let nn=Lt.get(Jt.id),vn=nn&&!nn.checked&&!nn.indeterminate;Jt.selCb.disabled=vn})}let Fn=document.createElement("div");Fn.className="context-menu",Fn.style.display="none",document.body.appendChild(Fn);function ne(Jt){let nn={};j.forEach((vn,he)=>{vn&&(nn[vn]=Jt.has(he))}),Lt.checkSet(nn)}function xe(){Fn.style.display="none"}function re(Jt,nn){let vn=document.createElement("div");vn.className="context-menu-item",vn.textContent=Jt,vn.addEventListener("click",()=>{nn(),xe()}),Fn.appendChild(vn)}let hn=U.length,Se=[{label:"Show only this layer",fn:Jt=>zU(Jt,0,0,hn)},{label:"Show layer range \u2195",fn:Jt=>zU(Jt,1,1,hn)},{label:"Show layer range \u2195\u2195",fn:Jt=>zU(Jt,2,2,hn)},{label:"Show layer range \u2193",fn:Jt=>zU(Jt,1,0,hn)},{label:"Show layer range \u2191",fn:Jt=>zU(Jt,0,1,hn)}];document.addEventListener("click",Jt=>{Fn.contains(Jt.target)||xe()}),document.addEventListener("keydown",Jt=>{Jt.key==="Escape"&&xe()});let ke=!Sc(d),mn=null;function en(){mn&&(mn.classList.remove("vis-row-selected"),mn=null)}ke&&fJt(d,en);function Qn(Jt,nn,vn){let he=bg(d);mn=Jt,Jt.classList.add("vis-row-selected");let Mn={type:"select_layer",layer:nn,use_dbu:d.showDbu};vn&&(Mn.chiplet=vn),d.websocketManager.request(Mn).then(Sn=>{D0(d,he)&&(d.updateInspector&&d.updateInspector(Sn),d.focusComponent&&d.focusComponent("Inspector"),d.refreshOverlay&&d.refreshOverlay())}).catch(Sn=>{console.error("select_layer failed:",Sn),D0(d,he)&&en()})}function ge(Jt,nn=!1){let vn=be.get(Jt.id);if(!Jt.children||Jt.children.length===0){let he=document.createElement("div");he.className=ke?"vis-leaf vis-leaf-selectable":"vis-leaf";let Mn=document.createElement("span");Mn.className="vis-arrow",Mn.style.visibility="hidden",Mn.textContent="\u25B6",he.appendChild(Mn);let Sn=Jt.data.colorIndex,gn=Jt.data.name,Ce=bR(),dn=document.createElement("span");dn.className="layer-color";let jn=Jt.data.color||m.layer_colors&&m.layer_colors[Sn]||HJt[Sn%HJt.length];dn.style.backgroundColor=`rgb(${jn[0]},${jn[1]},${jn[2]})`,Ce.appendChild(dn),Ce.appendChild(document.createTextNode(gn)),he.appendChild(Ce),ke&&Ce.addEventListener("click",()=>{Qn(he,gn,Jt.data.ownerChipletPath)});let ar=document.createElement("input");if(ar.type="checkbox",ar.className="vis-cb",ar.title="Visible",ar.checked=Jt.checked,Jt.cb=ar,ar.addEventListener("change",()=>{Lt.check(Jt.id,ar.checked)}),he.appendChild(ar),vn){let gr=document.createElement("input");gr.type="checkbox",gr.className="vis-sel-cb",gr.title="Selectable",gr.checked=vn.checked,vn.selCb=gr,gr.addEventListener("change",()=>{be.check(Jt.id,gr.checked)}),he.appendChild(gr)}else he.appendChild(dS());return he.addEventListener("contextmenu",gr=>{gr.preventDefault(),gr.stopPropagation(),Fn.innerHTML="";for(let Qt of Se)re(Qt.label,()=>ne(Qt.fn(Sn)));let tr=document.createElement("div");tr.className="context-menu-separator",tr.style.borderTop="1px solid #555",tr.style.margin="4px 0",Fn.appendChild(tr);let Ln=d.layerPatterns[gn]??1;for(let Qt of ft){let Mi=Ln===Qt.value?"\u25CF ":" ";re(Mi+"Fill: "+Qt.label,()=>gt(gn,Jt.data.layer,Qt.value))}Fn.style.left=gr.clientX+"px",Fn.style.top=gr.clientY+"px",Fn.style.display="block"}),he}else{let he=document.createElement("div");he.className="vis-group";let{header:Mn,arrow:Sn,name:gn}=rk();gn.textContent=nn?"Layers":Jt.data.name||"Group";let Ce=document.createElement("input");if(Ce.type="checkbox",Ce.className="vis-cb",Ce.title="Visible",Ce.checked=Jt.checked,Ce.indeterminate=Jt.indeterminate,Jt.cb=Ce,Ce.addEventListener("change",()=>{Lt.check(Jt.id,Ce.checked)}),Mn.appendChild(Ce),vn){let jn=document.createElement("input");jn.type="checkbox",jn.className="vis-sel-cb",jn.title="Selectable",jn.checked=vn.checked,jn.indeterminate=vn.indeterminate,vn.selCb=jn,jn.addEventListener("change",()=>{be.check(Jt.id,jn.checked)}),Mn.appendChild(jn)}else Mn.appendChild(dS());he.appendChild(Mn);let dn=document.createElement("div");dn.className="vis-group-children";for(let jn of Jt.children)dn.appendChild(ge(jn,!1));return he.appendChild(dn),sk(Mn,Sn,dn,!!(Jt.data&&Jt.data.startCollapsed)),he}}let Pe=Lt.roots[0]||Lt.get("layers_parent"),ti=ge(Pe,!0);d.displayControlsEl.appendChild(ti),ln();let Yi=m&&Array.isArray(m.chiplets)?m.chiplets:[];if(Yi.length>1){let dn=function(sn,Zn){let oi=Ce.get(sn);oi&&(Lt.cascadeQuiet(oi.id,Zn),Lt.onChange())},Mi=function(sn){let Zn=sn.data;if(sn!==Ln){let oi=document.createElement("div");oi.className="vis-leaf",oi.style.paddingLeft=8*(Zn.depth-1)+"px",oi.title=Zn.path+(Zn.master?` (${Zn.master})`:""),oi.appendChild(bR(Zn.name));let Jr=document.createElement("input");Jr.type="checkbox",Jr.className="vis-cb",Jr.checked=sn.checked,Jr.indeterminate=sn.indeterminate,sn.cb=Jr,Jr.addEventListener("change",()=>{V.check(sn.id,Jr.checked),dn(Zn.path,Jr.checked)}),oi.appendChild(Jr),oi.appendChild(dS()),Qt.appendChild(oi)}sn.children&&sn.children.forEach(Mi)},Jt=m&&m.block_name||"",nn=Jt!=="",vn={};if(nn)try{let sn=qf("or_hidden_chiplets");if(sn){let Zn=JSON.parse(decodeURIComponent(sn));Zn&&typeof Zn=="object"&&!Array.isArray(Zn)&&(vn=Zn)}}catch{}let he=new Set(Array.isArray(vn[Jt])?vn[Jt]:[]),Mn=Vke(Yi,he),Sn=Mn.findIndex(sn=>sn.parentId===null),gn=Sn>=0?Mn[Sn].id:null;if(Sn>=0&&(Mn[Sn].hasCheckbox=!0),d.visibleChiplets=new Set(Yi.filter(sn=>!he.has(sn.path)).map(sn=>sn.path)),V=new Qw(()=>{let sn=new Set;if(V.forEach(Zn=>{Zn.cb&&(Zn.cb.checked=Zn.checked,Zn.cb.indeterminate=Zn.indeterminate),Zn.data&&Zn.data.path&&(Zn.checked||Zn.indeterminate)&&sn.add(Zn.data.path)}),d.visibleChiplets=sn,nn){let Zn=Yi.filter(Jr=>!sn.has(Jr.path)).map(Jr=>Jr.path),oi={};try{let Jr=qf("or_hidden_chiplets");if(Jr){let Bs=JSON.parse(decodeURIComponent(Jr));Bs&&typeof Bs=="object"&&!Array.isArray(Bs)&&(oi=Bs)}}catch{}Zn.length===0?delete oi[Jt]:oi[Jt]=Zn,Rd("or_hidden_chiplets",encodeURIComponent(JSON.stringify(oi)))}_()}),V.buildFromNodes(Mn),typeof console<"u"&&console.warn){let sn=new Set;Lt.forEach(oi=>{oi.data&&oi.data.chipletPath&&sn.add(oi.data.chipletPath)});let Zn=new Set;V.forEach(oi=>{oi.data&&oi.data.path&&Zn.add(oi.data.path)});for(let oi of Zn)sn.has(oi)||console.warn(`[display-controls] chiplet "${oi}" missing from layer_hierarchy \u2014 Layers/Chiplets sync may drift`);for(let oi of sn)Zn.has(oi)||console.warn(`[display-controls] layer hierarchy node "${oi}" has no matching chiplet \u2014 Layers/Chiplets sync may drift`)}let Ce=new Map;Lt.forEach(sn=>{sn.data&&sn.data.chipletPath&&Ce.set(sn.data.chipletPath,sn)});{let sn={};if(Lt.forEach(Zn=>{if(!Zn.data||!Zn.data.chipletPath)return;let oi=Zn.data.chipletPath;he.has(oi)||V.get(oi)&&(sn[oi]={checked:Zn.checked,indeterminate:Zn.indeterminate})}),Object.keys(sn).length>0){V.mirrorStatesQuiet(sn);let Zn=new Set;V.forEach(oi=>{oi.data&&oi.data.path&&(oi.checked||oi.indeterminate)&&Zn.add(oi.data.path)}),d.visibleChiplets=Zn}}let jn=document.createElement("div");jn.className="vis-group";let{header:ar,arrow:gr,name:tr}=rk();tr.textContent="Chiplets";let Ln=gn!=null?V.get(gn):null;if(Ln){let sn=document.createElement("input");sn.type="checkbox",sn.className="vis-cb",sn.checked=Ln.checked,sn.indeterminate=Ln.indeterminate,Ln.cb=sn,sn.addEventListener("change",Zn=>{Zn.stopPropagation(),V.check(gn,sn.checked),Ln.data&&Ln.data.path&&dn(Ln.data.path,sn.checked)}),ar.appendChild(sn)}ar.appendChild(dS()),jn.appendChild(ar);let Qt=document.createElement("div");Qt.className="vis-group-children",V.roots.forEach(Mi),jn.appendChild(Qt),sk(ar,gr,Qt,!1),d.displayControlsEl.appendChild(jn)}else d.visibleChiplets=null;let ki=!!s.debug_renderers,lr=new hnt(s,h,()=>{_(),!!s.debug_renderers!==ki&&(ki=!!s.debug_renderers,d.refreshRendererControls&&d.refreshRendererControls())});lr.add({label:"Nets",addSelectable:!0,children:[{key:"net_signal",label:"Signal"},{key:"net_power",label:"Power"},{key:"net_ground",label:"Ground"},{key:"net_clock",label:"Clock"},{key:"net_reset",label:"Reset"},{key:"net_tieoff",label:"Tie off"},{key:"net_scan",label:"Scan"},{key:"net_analog",label:"Analog"}]}),lr.add({label:"Instances",addSelectable:!0,children:[{label:"Std Cells",visKey:"stdcells",disabled:!d.hasLiberty,children:[{label:"Bufs/Invs",children:[{key:"std_bufinv_timing",label:"Timing opt."},{key:"std_bufinv",label:"Netlist"}]},{key:"std_combinational",label:"Combinational"},{key:"std_sequential",label:"Sequential"},{label:"Clock tree",children:[{key:"std_clock_bufinv",label:"Buffer/Inverter"},{key:"std_clock_gate",label:"Clock gate"}]},{key:"std_level_shift",label:"Level shifter"}]},{key:"macros",label:"Macros"},{label:"Pads",children:[{key:"pad_input",label:"Input"},{key:"pad_output",label:"Output"},{key:"pad_inout",label:"Inout"},{key:"pad_power",label:"Power"},{key:"pad_spacer",label:"Spacer"},{key:"pad_areaio",label:"Area IO"},{key:"pad_other",label:"Other"}]},{label:"Physical",children:[{key:"phys_fill",label:"Fill"},{key:"phys_endcap",label:"Endcap"},{key:"phys_welltap",label:"Welltap"},{key:"phys_tie",label:"Tie Hi/Lo"},{key:"phys_antenna",label:"Antenna"},{key:"phys_cover",label:"Cover"},{key:"phys_bump",label:"Bump"},{key:"phys_other",label:"Other"}]}]}),lr.add({label:"Blockages",addSelectable:!0,children:[{key:"placement_blockages",label:"Placement"},{key:"routing_obstructions",label:"Routing"}]}),m.sites&&m.sites.length>0&&lr.add({label:"Rows",visKey:"rows",addSelectable:!0,children:m.sites.map(Jt=>({key:"site_"+Jt,label:Jt}))}),lr.add({label:"Tracks",children:[{key:"tracks_pref",label:"Pref"},{key:"tracks_non_pref",label:"Non Pref"}]}),lr.add({label:"Shapes",children:[{label:"Routing",visKey:"routing",children:[{key:"routing_segments",label:"Segments"},{key:"routing_vias",label:"Vias"}]},{label:"Special Routing",visKey:"special_nets",children:[{key:"srouting_segments",label:"Segments"},{key:"srouting_vias",label:"Vias"}]},{key:"pins",label:"Pins",selectable:!0},{key:"pin_names",label:"Pin Names",disabledBy:"pins"},{key:"fills",label:"Fills"}]}),lr.add({label:"Misc",children:[{label:"Instances",children:[{key:"inst_names",label:"Names"},{key:"inst_pins",label:"Pins",selectable:!0},{key:"inst_pin_names",label:"Pin Names",disabledBy:"inst_pins"},{key:"blockages",label:"Blockages"}]},{key:"detailed",label:"Detailed view"},{key:"rulers",label:"Rulers"},{key:"labels",label:"Labels"},{key:"scale_bar",label:"Scale bar"},{key:"access_points",label:"Access Points"},{key:"regions",label:"Regions"},{key:"mfg_grid",label:"Manufacturing grid"},{key:"gcell_grid",label:"GCell grid"},{key:"flywires_only",label:"Flywires only"},{key:"focused_nets_guides",label:"Focused nets guides"},{key:"highlight_selected",label:"Highlight selected"}]}),lr.add({key:"module_view",label:"Module view"}),lr.add({label:"Debug Graphics",children:[{key:"debug_renderers",label:"Renderers"},{key:"debug_live",label:"Live (don't require pause)",disabledBy:"debug_renderers"},{key:"debug",label:"Tiles"}]}),lr.render(d.displayControlsEl);let pr=document.createElement("div");pr.className="renderer-controls",d.displayControlsEl.appendChild(pr);function Kt(Jt){return Promise.all(Jt.map(({path:nn,value:vn})=>d.websocketManager.request({type:"set_renderer_control",path:nn,value:vn}))).catch(()=>{})}function wn(Jt){pr.innerHTML="";let nn=new Map;for(let vn of Jt||[]){let he=vn.group||"";nn.has(he)||nn.set(he,[]),nn.get(he).push(vn)}for(let[vn,he]of nn){let Mn=pr;if(vn){let Sn=document.createElement("div");Sn.className="vis-group";let{header:gn,arrow:Ce,name:dn}=rk();dn.textContent=vn;let jn=document.createElement("input");jn.type="checkbox",jn.className="vis-cb",jn.title="Visible";let ar=he.filter(tr=>tr.visible).length;jn.checked=ar===he.length,jn.indeterminate=ar>0&&ar{let tr=jn.checked;Kt(he.filter(Ln=>!!Ln.visible!==tr).map(Ln=>({path:Ln.path,value:tr})))}),gn.appendChild(jn),gn.appendChild(dS()),Sn.appendChild(gn);let gr=document.createElement("div");gr.className="vis-group-children",Sn.appendChild(gr),sk(gn,Ce,gr,!1),pr.appendChild(Sn),Mn=gr}for(let Sn of he){let gn=document.createElement("div");gn.className="vis-leaf";let Ce=document.createElement("span");Ce.className="vis-arrow",Ce.style.visibility="hidden",Ce.textContent="\u25B6",gn.appendChild(Ce),gn.appendChild(bR(Sn.name));let dn=document.createElement("input");dn.type="checkbox",dn.className="vis-cb",dn.title="Visible",dn.checked=!!Sn.visible,dn.addEventListener("change",()=>Kt([{path:Sn.path,value:dn.checked}])),gn.appendChild(dn),gn.appendChild(dS()),Mn.appendChild(gn)}}}d.refreshRendererControls=function(){return!d.websocketManager||Sc(d)||!s.debug_renderers?(pr.innerHTML="",Promise.resolve()):d.websocketManager.request({type:"renderer_controls"}).then(Jt=>wn(Jt.controls)).catch(()=>{})},d.refreshRendererControls();let it=document.createElement("div");it.className="bg-color-row";let ut=document.createElement("span");ut.textContent="Background";let kt=document.createElement("input");kt.type="color",kt.className="bg-color-input",kt.title="Layout background color";let Ot=qf("or_bg_color");kt.value=pR(Ot)?Ot:z2t(),kt.addEventListener("input",()=>{document.documentElement.style.setProperty("--bg-map",kt.value)}),kt.addEventListener("change",()=>{TJt(kt.value,d)});let ie=document.createElement("button");ie.className="bg-color-reset",ie.textContent="Reset",ie.title="Reset background to the theme default",ie.addEventListener("click",()=>{CJt(d),kt.value=z2t()}),it.appendChild(ut),it.appendChild(kt),it.appendChild(ie),d.heatMapLayer||(d.heatMapLayer=new S(d.websocketManager,d,{zIndex:U.length+10,opacity:1}));let rn=document.createElement("div");rn.className="vis-group heatmap-controls",d.displayControlsEl.appendChild(rn);let{header:Pn,arrow:Tt,name:yt}=rk("vis-group-header heatmap-header");yt.textContent="Heat Maps",rn.appendChild(Pn);let ue=document.createElement("div");ue.className="vis-group-children heatmap-group-children",rn.appendChild(ue),sk(Pn,Tt,ue,!0),d.displayControlsEl.appendChild(it);function fn(Jt,nn,vn,he){let Mn=document.createElement("label");Mn.className="heatmap-setting";let Sn=document.createElement("input");Sn.type="checkbox",Sn.checked=vn,Sn.addEventListener("change",()=>he(Sn.checked)),Mn.appendChild(Sn),Mn.appendChild(document.createTextNode(nn)),Jt.appendChild(Mn)}function An(Jt,nn,vn,he,Mn){let Sn=document.createElement("label");Sn.className="heatmap-setting";let gn=document.createElement("span");gn.textContent=nn;let Ce=document.createElement("input");Ce.type="number",Ce.value=String(vn),Ce.step=String(he||1),Ce.addEventListener("change",()=>Mn(parseFloat(Ce.value))),Sn.appendChild(gn),Sn.appendChild(Ce),Jt.appendChild(Sn)}function zn(Jt,nn,vn,he,Mn){let Sn=document.createElement("label");Sn.className="heatmap-setting";let gn=document.createElement("span");gn.textContent=nn;let Ce=document.createElement("select");for(let dn of he){let jn=document.createElement("option");jn.value=dn,jn.textContent=dn,dn===vn&&(jn.selected=!0),Ce.appendChild(jn)}Ce.addEventListener("change",()=>Mn(Ce.value)),Sn.appendChild(gn),Sn.appendChild(Ce),Jt.appendChild(Sn)}function Li(Jt){d.websocketManager.request(Jt).then(nn=>{d.updateHeatMaps&&d.updateHeatMaps(nn)}).catch(nn=>console.error("Heat map update failed",nn))}function xi(Jt){if(!d.heatMapLegendEl)return;let nn=d.heatMapLegendEl;if(nn.innerHTML="",!Jt||!Jt.show_legend||!Jt.legend||Jt.legend.length===0){nn.classList.add("hidden");return}let vn=document.createElement("div");vn.className="heatmap-map-legend-title",vn.textContent=Jt.title,nn.appendChild(vn);let he=document.createElement("div");he.className="heatmap-map-legend-units",he.textContent=Jt.units||"",nn.appendChild(he);let Mn=document.createElement("div");Mn.className="heatmap-map-legend-list";for(let Sn of Jt.legend){let gn=document.createElement("div");gn.className="heatmap-legend-row";let Ce=document.createElement("span");Ce.className="heatmap-legend-swatch",Ce.style.backgroundColor=`rgba(${Sn.color[0]}, ${Sn.color[1]}, ${Sn.color[2]}, ${Sn.color[3]/255})`;let dn=document.createElement("span");dn.textContent=Sn.value,gn.appendChild(Ce),gn.appendChild(dn),Mn.appendChild(gn)}nn.appendChild(Mn),nn.classList.remove("hidden")}d.renderHeatMapControls=Jt=>{ue.innerHTML="";let nn=document.createElement("div");nn.className="heatmap-list",ue.appendChild(nn);let vn=document.createElement("label");vn.className="heatmap-setting";let he=document.createElement("input");he.type="radio",he.name="active-heatmap",he.checked=!Jt.active,he.addEventListener("change",()=>{Li({type:"set_active_heatmap",name:""})}),vn.appendChild(he),vn.appendChild(document.createTextNode("Off")),nn.appendChild(vn);for(let Ce of Jt.heatmaps||[]){let dn=document.createElement("label");dn.className="heatmap-setting";let jn=document.createElement("input");jn.type="radio",jn.name="active-heatmap",jn.checked=Ce.name===Jt.active,jn.addEventListener("change",()=>{Li({type:"set_active_heatmap",name:Ce.name})}),dn.appendChild(jn),dn.appendChild(document.createTextNode(Ce.title)),nn.appendChild(dn)}let Mn=(Jt.heatmaps||[]).find(Ce=>Ce.name===Jt.active);if(xi(Mn),!Mn)return;let Sn=document.createElement("div");Sn.className="heatmap-settings",ue.appendChild(Sn),An(Sn,"Display min",Mn.display_min,Mn.display_range_increment,Ce=>{Li({type:"set_heatmap",name:Mn.name,option:"DisplayMin",value:Ce})}),An(Sn,"Display max",Mn.display_max,Mn.display_range_increment,Ce=>{Li({type:"set_heatmap",name:Mn.name,option:"DisplayMax",value:Ce})}),fn(Sn,"Show below min",Mn.draw_below_min,Ce=>{Li({type:"set_heatmap",name:Mn.name,option:"ShowMin",value:Ce})}),fn(Sn,"Show above max",Mn.draw_above_max,Ce=>{Li({type:"set_heatmap",name:Mn.name,option:"ShowMax",value:Ce})}),fn(Sn,"Log scale",Mn.log_scale,Ce=>{Li({type:"set_heatmap",name:Mn.name,option:"LogScale",value:Ce})}),fn(Sn,"Reverse log",Mn.reverse_log,Ce=>{Li({type:"set_heatmap",name:Mn.name,option:"ReverseLog",value:Ce})}),Mn.can_adjust_grid&&(An(Sn,"Grid X",Mn.grid_x,.1,Ce=>{Li({type:"set_heatmap",name:Mn.name,option:"GridX",value:Ce})}),An(Sn,"Grid Y",Mn.grid_y,.1,Ce=>{Li({type:"set_heatmap",name:Mn.name,option:"GridY",value:Ce})})),An(Sn,"Alpha",Mn.alpha,1,Ce=>{Li({type:"set_heatmap",name:Mn.name,option:"Alpha",value:Ce})}),fn(Sn,"Legend",Mn.show_legend,Ce=>{Li({type:"set_heatmap",name:Mn.name,option:"ShowLegend",value:Ce})}),Mn.supports_numbers&&fn(Sn,"Show numbers",Mn.show_numbers,Ce=>{Li({type:"set_heatmap",name:Mn.name,option:"ShowNumbers",value:Ce})});for(let Ce of Mn.options||[])Ce.type==="bool"?fn(Sn,Ce.label,Ce.value,dn=>{Li({type:"set_heatmap",name:Mn.name,option:Ce.name,value:dn})}):Ce.type==="choice"&&zn(Sn,Ce.label,Ce.value,Ce.choices||[],dn=>{Li({type:"set_heatmap",name:Mn.name,option:Ce.name,value:dn})});Mn.selection_filter_label&&fn(Sn,Mn.selection_filter_label,Mn.use_selected_only,Ce=>{Li({type:"set_heatmap",name:Mn.name,option:"use_selected_only",value:Ce})});let gn=document.createElement("button");gn.className="or-btn or-btn-sm heatmap-rebuild",gn.textContent="Rebuild data",gn.addEventListener("click",()=>{Li({type:"set_heatmap",name:Mn.name,option:"rebuild",value:1})}),Sn.appendChild(gn)}}var WJt="search-nav-dialog",qke=[{label:"Instance",value:"inst"},{label:"Net",value:"net"},{label:"Port",value:"port"}];function dnt(d){if(!d.designScale)return;let s=qke.map(B=>``).join(""),{overlay:h,close:p,okBtn:m,showError:_}=gR("Find Object",` + affected.
`,"Apply",d3t),_=u.querySelector(".opt-family"),x=u.querySelector(".opt-custom"),T=u.querySelector(".opt-scale"),M=u.querySelector(".opt-preview");function L(){M.style.fontFamily=x.value.trim()||_.value,M.style.fontSize=`calc(13px * ${rH(T.value)/100})`}for(let D of[_,x,T])D.addEventListener("input",L);L();function I(){let D=T.value.trim(),F=Number(D);if(D===""||!Number.isFinite(F)){w("Size must be a number.");return}if(Fede){w(`Size must be between ${Qhe} and ${ede} %.`);return}s.setAppFont({family:x.value.trim()||_.value,scale:F}),d()}b.addEventListener("click",I);for(let D of[x,T])D.addEventListener("keydown",F=>{F.key==="Enter"&&(F.preventDefault(),I())});return{close:d}}function Q5e(s){return String(s).replace(/&/g,"&").replace(/"/g,""").replace(//g,">")}var Odn='',Ndn='';function CO(s){let n=document.createElement("span");return n.className="vis-name",s!=null&&(n.textContent=s),n}function ET(){let s=document.createElement("span");return s.className="vis-sel-cb vis-sel-spacer",s}function m3t(){let s=document.createElement("div");s.className="display-controls-header",s.appendChild(CO(""));for(let[n,r]of[[Odn,"Visible"],[Ndn,"Selectable"]]){let c=document.createElement("span");c.className="vis-header-icon",c.title=r,c.innerHTML=n,s.appendChild(c)}return s}var tde=class{constructor(n,r,c){this.visibility=n,this.selectability=r,this.onChange=c;let u=()=>{this._syncAll(),this.onChange()};this.model=new Lv(u),this.selModel=new Lv(u)}add(n){return this.model.addFromSpec(this._enrichSpec(n,"")),this.selModel.addFromSpec(this._enrichSelSpec(n,"",!1)),this}render(n){for(let r of this.model.roots)n.appendChild(this._dom(r));this._syncAll()}_nodeId(n,r){let c=n.key||n.label;return r?r+"/"+c:c}_enrichSpec(n,r){let c=this._nodeId(n,r),u={id:c,data:n};return n.children?u.children=n.children.map(d=>this._enrichSpec(d,c)):n.key&&(u.checked=!!this.visibility[n.key]),n.disabled!=null&&(u.disabled=n.disabled),u}_enrichSelSpec(n,r,c){let u=n.addSelectable===!0?!0:n.addSelectable===!1?!1:c,d=this._nodeId(n,r),b={id:d,data:n,hasCheckbox:!1};if(n.children){b.children=n.children.map(_=>this._enrichSelSpec(_,d,u));let w=_=>_.some(x=>x.hasCheckbox||x.children&&w(x.children));b.hasCheckbox=w(b.children),b.hasCheckbox&&(b.checked=!0)}else if(n.key){let w=n.selectable===!0||n.selectable!==!1&&c;b.hasCheckbox=w,w&&(b.checked=this.selectability[n.key]!==!1)}return b}_syncAll(){this.model.forEach(n=>{n.cb&&(n.cb.checked=n.checked,n.cb.indeterminate=n.indeterminate);let r=n.data;r.key&&(this.visibility[r.key]=n.checked),r.visKey&&(this.visibility[r.visKey]=n.checked||n.indeterminate)}),this.selModel.forEach(n=>{if(!n.hasCheckbox)return;let r=n.data;if(r.key&&(this.selectability[r.key]=n.checked),!n.selCb)return;n.selCb.checked=n.checked,n.selCb.indeterminate=n.indeterminate;let c=this.model.get(n.id),u=c&&!c.checked&&!c.indeterminate;n.selCb.disabled=u,n.selLabel&&n.selLabel.classList.toggle("vis-sel-disabled",u)}),this.model.forEach(n=>{let r=n.data;if(r.disabledBy&&n.el){let c=!this.visibility[r.disabledBy];n.el.classList.toggle("disabled",c)}})}_buildSelCheckbox(n){let r=this.selModel.get(n.id);if(!r||!r.hasCheckbox)return null;let c=document.createElement("input");return c.type="checkbox",c.className="vis-sel-cb",c.title="Selectable",c.addEventListener("change",()=>{this.selModel.check(r.id,c.checked)}),r.selCb=c,c}_dom(n){let r=n.data,c=document.createElement("input");c.type="checkbox",c.className="vis-cb",c.title="Visible",n.cb=c,c.addEventListener("change",()=>this.model.check(n.id,c.checked));let u=this._buildSelCheckbox(n),d=M=>{if(M.appendChild(c),u){M.appendChild(u);let L=this.selModel.get(n.id);L&&(L.selLabel=M)}else M.appendChild(ET())};if(!n.children.length){let M=document.createElement("div");M.className="vis-leaf";let L=document.createElement("span");return L.className="vis-arrow",L.style.visibility="hidden",L.textContent="\u25B6",M.appendChild(L),M.appendChild(CO(r.label)),d(M),n.el=M,M}let b=document.createElement("div");b.className="vis-group";let{header:w,arrow:_,name:x}=sk();x.textContent=r.label,d(w),b.appendChild(w);let T=document.createElement("div");T.className="vis-group-children",r.disabled&&T.classList.add("disabled");for(let M of n.children)T.appendChild(this._dom(M));return b.appendChild(T),ok(w,_,T,!0),b}};function sH(s,n,r,c){let u=new Set,d=Math.max(0,s-n),b=Math.min(c-1,s+r);for(let w=d;w<=b;w++)u.add(w);return u}function Fdn(s){let n={};for(let[r,c]of Object.entries(s||{}))c!==1&&(n[r]=c);return n}function nde(s,n){return(s||[]).some(r=>r.every(c=>!!n[c]))}function Udn(s,n){return s.map(r=>{let c=!n.has(r.path);return{id:r.path,parentId:r.parent!=null?r.parent:null,hasCheckbox:r.parent!=null,checked:c,data:{path:r.path,name:r.name,master:r.master,depth:r.depth}}})}var zdn=3,b3t=[[70,130,210],[200,50,50],[50,180,80],[200,160,40],[160,60,200],[40,190,190],[220,120,50],[180,70,150]];function Gdn(s){return!s.forceComposite||la(s)?0:s.groupLayers||Txt}function w3t(s,n,r,c,u,d){if(!s.displayControlsEl)return;s.displayControlsEl.innerHTML="",s.displayControlsEl.appendChild(m3t());for(let Pe of s.allLayers||[])Pe.remove();s.allLayers=[],s.baseSlot=null,s.topSlot=null;let b=new Set;function w(){for(let Pe of b)Pe.refresh();b.clear()}function _(){s.baseSlot&&b.add(s.baseSlot)}function x(Pe){return{layer:Pe,opacity:1,visible:!1}}function T(Pe,ke){wxt(Pe,ke)&&_()}function M(Pe,ke,dt){let Ye={layer:Pe,opacity:1,visible:!!dt};return ke&&(s[ke]=Ye),Ye}let L=[M("_instances",null,!0),M("_pins","pinsLayer",n.pins),M("_modules","modulesLayer",n.module_view)],I=[];s.overlayLayers=(c&&c.overlays||[]).map(Pe=>({def:Pe,layer:M(Pe.name,null,nde(Pe.shown_by,n)),under:Pe.z_indexdt.def.z_index-Ye.def.z_index))(ke?L:I).push(Pe);let D=[],F=[],O=null,z=new Set,Z=new Set;try{let Pe=window.sessionStorage.getItem("or_hidden_layers");Pe&&(z=new Set(JSON.parse(Pe)))}catch{}try{let Pe=window.sessionStorage.getItem("or_nonselectable_layers");Pe&&(Z=new Set(JSON.parse(Pe)))}catch{}try{let Pe=window.sessionStorage.getItem("or_layer_patterns");Pe&&Object.assign(s.layerPatterns,JSON.parse(Pe))}catch{}function H(){try{window.sessionStorage.setItem("or_layer_patterns",JSON.stringify(Fdn(s.layerPatterns)))}catch{}}function te(Pe,ke){ke===1?delete s.layerPatterns[Pe]:s.layerPatterns[Pe]=ke,H(),_(),w()}let se=[{label:"Solid",value:1},{label:"Diagonal",value:2},{label:"Cross",value:3},{label:"Dots",value:4},{label:"None (no fill)",value:0}],ne=0;function ue(Pe,ke="layers",dt=void 0){let Ye=[],ct=Pe.type==="category"?dt:Pe.path,Ze=Pe.flipped===!0,Ke=Pe.instances||[],gt=Ke.filter(Zn=>Zn.type!=="category"),qn=Ke.filter(Zn=>Zn.type==="category"),xi=Pe.layers||[],Bi=ne;ne+=xi.length;function xn(Zn,rr){let Me=Zn.map((et,ht)=>ht);rr&&Me.reverse(),Me.forEach(et=>{let ht=Zn[et],on=ke+"/"+(ht.name||et);Ye.push(ue(ht,on,ct))})}function Je(){(Ze?xi.map((rr,Me)=>Me).reverse():xi.map((rr,Me)=>Me)).forEach(rr=>{let Me=xi[rr],et=Me.name||Me,ht=Bi+rr,on=x(et),Ri=`${ke}/${et}`,di=!z.has(Ri);di&&(T(on,!0),s.visibleLayers.add(Ri),s.visibleLayerNames.add(et)),D.push(on),F.push(Ri),Ye.push({id:Ri,data:{name:et,layer:on,color:Me.color,colorIndex:ht,nodeId:Ri,ownerChipletPath:ct},checked:di})})}xn(gt,!1),Ze&&Je(),xn(qn,Ze),Ze||Je();let ti={name:Pe.name,isInstance:!0};return Pe.type==="category"&&(Pe.name==="Implant"||Pe.name==="Other")&&(ti.startCollapsed=!0),Pe.type!=="category"&&(ti.chipletPath=Pe.path),{id:ke,data:ti,children:Ye}}let Ce;c.layer_hierarchy?Ce=ue(c.layer_hierarchy,"layers_parent"):Ce={id:"layers_parent",children:c.layers.map((Pe,ke)=>{let dt=x(Pe),Ye=`layers_parent/${Pe}`,ct=!z.has(Ye);return ct&&(T(dt,!0),s.visibleLayers.add(Ye),s.visibleLayerNames.add(Pe)),D.push(dt),F.push(Ye),{id:Ye,data:{name:Pe,layer:dt,colorIndex:ke,nodeId:Ye},checked:ct}})};function Q(Pe,ke,dt){let Ye=s.view.addTileSlot(Pe,{order:ke,source:Cxt({wm:s.websocketManager,ctx:s.tileCtx,getItems:()=>dt,dpr:xO,tileSize:Ob,isDoubleBuffer:()=>s.doubleBuffer,groupLayers:()=>Gdn(s)})});return Ye.items=dt,Ye}s.baseSlot=Q("base",mp.base,[...L,...D]),s.topSlot=Q("top",mp.top,I),s.allLayers=[s.baseSlot,s.topSlot];function me(Pe){if(!Pe.children||Pe.children.length===0){let ke=Pe.data&&Pe.data.name,dt=ke?!Z.has(ke):!0;return dt&&ke&&s.selectableLayers.add(ke),{id:Pe.id,data:{name:ke},checked:dt}}return{id:Pe.id,data:{name:Pe.data&&Pe.data.name},children:Pe.children.map(me)}}let tt=me(Ce),st=new Lv(()=>{s.visibleLayerNames.clear();let Pe=[],ke={},dt=!1,Ye=!1,ct=O&&s.visibleChiplets instanceof Set;if(st.forEach(Ke=>{if(Ke.cb&&(Ke.cb.checked=Ke.checked,Ke.cb.indeterminate=Ke.indeterminate),Ke.data&&Ke.data.layer){let gt=Ke.data.nodeId||Ke.data.name;Pe.push(gt),T(Ke.data.layer,Ke.checked),Ke.checked?(s.visibleLayers.add(gt),s.visibleLayerNames.add(Ke.data.name)):s.visibleLayers.delete(gt)}if(ct&&Ke.data&&Ke.data.chipletPath){let gt=Ke.data.chipletPath,qn=O.get(gt);if(qn){let xi=Ke.checked||Ke.indeterminate,Bi={checked:Ke.checked,indeterminate:Ke.indeterminate};(qn.checked!==Ke.checked||qn.indeterminate!==Ke.indeterminate)&&(ke[gt]=Bi,dt=!0),s.visibleChiplets.has(gt)!==xi&&(Ye=!0)}}}),s.baseSlot&&b.has(s.baseSlot))for(let{def:Ke,under:gt}of s.overlayLayers)nde(Ke.layers_by,n)&&b.add(gt?s.baseSlot:s.topSlot);w(),Ne();let Ze=Pe.filter(Ke=>!s.visibleLayers.has(Ke));try{window.sessionStorage.setItem("or_hidden_layers",JSON.stringify(Ze))}catch{}s.syncDisplayState(),Ye?O.mirrorStates(ke):dt&&(O.mirrorStatesQuiet(ke),O.forEach(Ke=>{Ke.cb&&(Ke.cb.checked=Ke.checked,Ke.cb.indeterminate=Ke.indeterminate)}))});s.layerModel=st,st.addFromSpec(Ce);let at=new Lv(()=>{s.selectableLayers.clear(),at.forEach(ke=>{ke.checked&&ke.data&&ke.data.name&&s.selectableLayers.add(ke.data.name)}),Ne();let Pe=c.layers.filter(ke=>!s.selectableLayers.has(ke));try{window.sessionStorage.setItem("or_nonselectable_layers",JSON.stringify(Pe))}catch{}s.syncDisplayState()});at.addFromSpec(tt);function Ne(){at.forEach(Pe=>{if(!Pe.selCb)return;Pe.selCb.checked=Pe.checked,Pe.selCb.indeterminate=Pe.indeterminate;let ke=st.get(Pe.id),dt=ke&&!ke.checked&&!ke.indeterminate;Pe.selCb.disabled=dt})}let Qe=document.createElement("div");Qe.className="context-menu",Qe.style.display="none",document.body.appendChild(Qe);function ot(Pe){let ke={};F.forEach((dt,Ye)=>{dt&&(ke[dt]=Pe.has(Ye))}),st.checkSet(ke)}function xt(){Qe.style.display="none"}function fn(Pe,ke){let dt=document.createElement("div");dt.className="context-menu-item",dt.textContent=Pe,dt.addEventListener("click",()=>{ke(),xt()}),Qe.appendChild(dt)}let Xt=D.length,wn=[{label:"Show only this layer",fn:Pe=>sH(Pe,0,0,Xt)},{label:"Show layer range \u2195",fn:Pe=>sH(Pe,1,1,Xt)},{label:"Show layer range \u2195\u2195",fn:Pe=>sH(Pe,2,2,Xt)},{label:"Show layer range \u2193",fn:Pe=>sH(Pe,1,0,Xt)},{label:"Show layer range \u2191",fn:Pe=>sH(Pe,0,1,Xt)}];document.addEventListener("click",Pe=>{Qe.contains(Pe.target)||xt()}),document.addEventListener("keydown",Pe=>{Pe.key==="Escape"&&xt()});let cn=!la(s),bi=null;function jt(){bi&&(bi.classList.remove("vis-row-selected"),bi=null)}cn&&Oxt(s,jt);function gn(Pe,ke,dt){let Ye=Pm(s);bi=Pe,Pe.classList.add("vis-row-selected");let ct={type:"select_layer",layer:ke,use_dbu:s.showDbu};dt&&(ct.chiplet=dt),s.websocketManager.request(ct).then(Ze=>{Y1(s,Ye)&&(s.updateInspector&&s.updateInspector(Ze),s.focusComponent&&s.focusComponent("Inspector"),s.refreshOverlay&&s.refreshOverlay())}).catch(Ze=>{console.error("select_layer failed:",Ze),Y1(s,Ye)&&jt()})}function Un(Pe,ke=!1){let dt=at.get(Pe.id);if(!Pe.children||Pe.children.length===0){let Ye=document.createElement("div");Ye.className=cn?"vis-leaf vis-leaf-selectable":"vis-leaf";let ct=document.createElement("span");ct.className="vis-arrow",ct.style.visibility="hidden",ct.textContent="\u25B6",Ye.appendChild(ct);let Ze=Pe.data.colorIndex,Ke=Pe.data.name,gt=CO(),qn=document.createElement("span");qn.className="layer-color";let xi=Pe.data.color||c.layer_colors&&c.layer_colors[Ze]||b3t[Ze%b3t.length];qn.style.backgroundColor=`rgb(${xi[0]},${xi[1]},${xi[2]})`,gt.appendChild(qn),gt.appendChild(document.createTextNode(Ke)),Ye.appendChild(gt),cn&>.addEventListener("click",()=>{gn(Ye,Ke,Pe.data.ownerChipletPath)});let Bi=document.createElement("input");if(Bi.type="checkbox",Bi.className="vis-cb",Bi.title="Visible",Bi.checked=Pe.checked,Pe.cb=Bi,Bi.addEventListener("change",()=>{st.check(Pe.id,Bi.checked)}),Ye.appendChild(Bi),dt){let xn=document.createElement("input");xn.type="checkbox",xn.className="vis-sel-cb",xn.title="Selectable",xn.checked=dt.checked,dt.selCb=xn,xn.addEventListener("change",()=>{at.check(Pe.id,xn.checked)}),Ye.appendChild(xn)}else Ye.appendChild(ET());return Ye.addEventListener("contextmenu",xn=>{xn.preventDefault(),xn.stopPropagation(),Qe.innerHTML="";for(let Zn of wn)fn(Zn.label,()=>ot(Zn.fn(Ze)));let Je=document.createElement("div");Je.className="context-menu-separator",Je.style.borderTop="1px solid #555",Je.style.margin="4px 0",Qe.appendChild(Je);let ti=s.layerPatterns[Ke]??1;for(let Zn of se){let rr=ti===Zn.value?"\u25CF ":" ";fn(rr+"Fill: "+Zn.label,()=>te(Ke,Zn.value))}Qe.style.left=xn.clientX+"px",Qe.style.top=xn.clientY+"px",Qe.style.display="block"}),Ye}else{let Ye=document.createElement("div");Ye.className="vis-group";let{header:ct,arrow:Ze,name:Ke}=sk();Ke.textContent=ke?"Layers":Pe.data.name||"Group";let gt=document.createElement("input");if(gt.type="checkbox",gt.className="vis-cb",gt.title="Visible",gt.checked=Pe.checked,gt.indeterminate=Pe.indeterminate,Pe.cb=gt,gt.addEventListener("change",()=>{st.check(Pe.id,gt.checked)}),ct.appendChild(gt),dt){let xi=document.createElement("input");xi.type="checkbox",xi.className="vis-sel-cb",xi.title="Selectable",xi.checked=dt.checked,xi.indeterminate=dt.indeterminate,dt.selCb=xi,xi.addEventListener("change",()=>{at.check(Pe.id,xi.checked)}),ct.appendChild(xi)}else ct.appendChild(ET());Ye.appendChild(ct);let qn=document.createElement("div");qn.className="vis-group-children";for(let xi of Pe.children)qn.appendChild(Un(xi,!1));return Ye.appendChild(qn),ok(ct,Ze,qn,!!(Pe.data&&Pe.data.startCollapsed)),Ye}}let Zi=st.roots[0]||st.get("layers_parent"),Hi=Un(Zi,!0);s.displayControlsEl.appendChild(Hi),Ne();let yr=c&&Array.isArray(c.chiplets)?c.chiplets:[];if(yr.length>1){let qn=function(Me,et){let ht=gt.get(Me);ht&&(st.cascadeQuiet(ht.id,et),st.onChange())},rr=function(Me){let et=Me.data;if(Me!==ti){let ht=document.createElement("div");ht.className="vis-leaf",ht.style.paddingLeft=8*(et.depth-1)+"px",ht.title=et.path+(et.master?` (${et.master})`:""),ht.appendChild(CO(et.name));let on=document.createElement("input");on.type="checkbox",on.className="vis-cb",on.checked=Me.checked,on.indeterminate=Me.indeterminate,Me.cb=on,on.addEventListener("change",()=>{O.check(Me.id,on.checked),qn(et.path,on.checked)}),ht.appendChild(on),ht.appendChild(ET()),Zn.appendChild(ht)}Me.children&&Me.children.forEach(rr)},Pe=c&&c.block_name||"",ke=Pe!=="",dt={};if(ke)try{let Me=pf("or_hidden_chiplets");if(Me){let et=JSON.parse(decodeURIComponent(Me));et&&typeof et=="object"&&!Array.isArray(et)&&(dt=et)}}catch{}let Ye=new Set(Array.isArray(dt[Pe])?dt[Pe]:[]),ct=Udn(yr,Ye),Ze=ct.findIndex(Me=>Me.parentId===null),Ke=Ze>=0?ct[Ze].id:null;if(Ze>=0&&(ct[Ze].hasCheckbox=!0),s.visibleChiplets=new Set(yr.filter(Me=>!Ye.has(Me.path)).map(Me=>Me.path)),O=new Lv(()=>{let Me=new Set;if(O.forEach(et=>{et.cb&&(et.cb.checked=et.checked,et.cb.indeterminate=et.indeterminate),et.data&&et.data.path&&(et.checked||et.indeterminate)&&Me.add(et.data.path)}),s.visibleChiplets=Me,ke){let et=yr.filter(on=>!Me.has(on.path)).map(on=>on.path),ht={};try{let on=pf("or_hidden_chiplets");if(on){let Ri=JSON.parse(decodeURIComponent(on));Ri&&typeof Ri=="object"&&!Array.isArray(Ri)&&(ht=Ri)}}catch{}et.length===0?delete ht[Pe]:ht[Pe]=et,Ff("or_hidden_chiplets",encodeURIComponent(JSON.stringify(ht)))}u()}),O.buildFromNodes(ct),typeof console<"u"&&console.warn){let Me=new Set;st.forEach(ht=>{ht.data&&ht.data.chipletPath&&Me.add(ht.data.chipletPath)});let et=new Set;O.forEach(ht=>{ht.data&&ht.data.path&&et.add(ht.data.path)});for(let ht of et)Me.has(ht)||console.warn(`[display-controls] chiplet "${ht}" missing from layer_hierarchy \u2014 Layers/Chiplets sync may drift`);for(let ht of Me)et.has(ht)||console.warn(`[display-controls] layer hierarchy node "${ht}" has no matching chiplet \u2014 Layers/Chiplets sync may drift`)}let gt=new Map;st.forEach(Me=>{Me.data&&Me.data.chipletPath&>.set(Me.data.chipletPath,Me)});{let Me={};if(st.forEach(et=>{if(!et.data||!et.data.chipletPath)return;let ht=et.data.chipletPath;Ye.has(ht)||O.get(ht)&&(Me[ht]={checked:et.checked,indeterminate:et.indeterminate})}),Object.keys(Me).length>0){O.mirrorStatesQuiet(Me);let et=new Set;O.forEach(ht=>{ht.data&&ht.data.path&&(ht.checked||ht.indeterminate)&&et.add(ht.data.path)}),s.visibleChiplets=et}}let xi=document.createElement("div");xi.className="vis-group";let{header:Bi,arrow:xn,name:Je}=sk();Je.textContent="Chiplets";let ti=Ke!=null?O.get(Ke):null;if(ti){let Me=document.createElement("input");Me.type="checkbox",Me.className="vis-cb",Me.checked=ti.checked,Me.indeterminate=ti.indeterminate,ti.cb=Me,Me.addEventListener("change",et=>{et.stopPropagation(),O.check(Ke,Me.checked),ti.data&&ti.data.path&&qn(ti.data.path,Me.checked)}),Bi.appendChild(Me)}Bi.appendChild(ET()),xi.appendChild(Bi);let Zn=document.createElement("div");Zn.className="vis-group-children",O.roots.forEach(rr),xi.appendChild(Zn),ok(Bi,xn,Zn,!1),s.displayControlsEl.appendChild(xi)}else s.visibleChiplets=null;let Tr=!!n.debug_renderers,Ei=new tde(n,r,()=>{u(),!!n.debug_renderers!==Tr&&(Tr=!!n.debug_renderers,s.refreshRendererControls&&s.refreshRendererControls())});Ei.add({label:"Nets",addSelectable:!0,children:[{key:"net_signal",label:"Signal"},{key:"net_power",label:"Power"},{key:"net_ground",label:"Ground"},{key:"net_clock",label:"Clock"},{key:"net_reset",label:"Reset"},{key:"net_tieoff",label:"Tie off"},{key:"net_scan",label:"Scan"},{key:"net_analog",label:"Analog"}]}),Ei.add({label:"Instances",addSelectable:!0,children:[{label:"Std Cells",visKey:"stdcells",disabled:!s.hasLiberty,children:[{label:"Bufs/Invs",children:[{key:"std_bufinv_timing",label:"Timing opt."},{key:"std_bufinv",label:"Netlist"}]},{key:"std_combinational",label:"Combinational"},{key:"std_sequential",label:"Sequential"},{label:"Clock tree",children:[{key:"std_clock_bufinv",label:"Buffer/Inverter"},{key:"std_clock_gate",label:"Clock gate"}]},{key:"std_level_shift",label:"Level shifter"}]},{key:"macros",label:"Macros"},{label:"Pads",children:[{key:"pad_input",label:"Input"},{key:"pad_output",label:"Output"},{key:"pad_inout",label:"Inout"},{key:"pad_power",label:"Power"},{key:"pad_spacer",label:"Spacer"},{key:"pad_areaio",label:"Area IO"},{key:"pad_other",label:"Other"}]},{label:"Physical",children:[{key:"phys_fill",label:"Fill"},{key:"phys_endcap",label:"Endcap"},{key:"phys_welltap",label:"Welltap"},{key:"phys_tie",label:"Tie Hi/Lo"},{key:"phys_antenna",label:"Antenna"},{key:"phys_cover",label:"Cover"},{key:"phys_bump",label:"Bump"},{key:"phys_other",label:"Other"}]}]}),Ei.add({label:"Blockages",addSelectable:!0,children:[{key:"placement_blockages",label:"Placement"},{key:"routing_obstructions",label:"Routing"}]}),c.sites&&c.sites.length>0&&Ei.add({label:"Rows",visKey:"rows",addSelectable:!0,children:c.sites.map(Pe=>({key:"site_"+Pe,label:Pe}))}),Ei.add({label:"Tracks",children:[{key:"tracks_pref",label:"Pref"},{key:"tracks_non_pref",label:"Non Pref"}]}),Ei.add({label:"Shapes",children:[{label:"Routing",visKey:"routing",children:[{key:"routing_segments",label:"Segments"},{key:"routing_vias",label:"Vias"}]},{label:"Special Routing",visKey:"special_nets",children:[{key:"srouting_segments",label:"Segments"},{key:"srouting_vias",label:"Vias"}]},{key:"pins",label:"Pins",selectable:!0},{key:"pin_names",label:"Pin Names",disabledBy:"pins"},{key:"fills",label:"Fills"}]}),Ei.add({label:"Misc",children:[{label:"Instances",children:[{key:"inst_names",label:"Names"},{key:"inst_pins",label:"Pins",selectable:!0},{key:"inst_pin_names",label:"Pin Names",disabledBy:"inst_pins"},{key:"blockages",label:"Blockages"}]},{key:"detailed",label:"Detailed view"},{key:"rulers",label:"Rulers"},{key:"labels",label:"Labels"},{key:"scale_bar",label:"Scale bar"},{key:"access_points",label:"Access Points"},{key:"regions",label:"Regions"},{key:"mfg_grid",label:"Manufacturing grid"},{key:"gcell_grid",label:"GCell grid"},{key:"flywires_only",label:"Flywires only"},{key:"focused_nets_guides",label:"Focused nets guides"},{key:"highlight_selected",label:"Highlight selected"}]}),Ei.add({key:"module_view",label:"Module view"}),Ei.add({label:"Debug Graphics",children:[{key:"debug_renderers",label:"Renderers"},{key:"debug_live",label:"Live (don't require pause)",disabledBy:"debug_renderers"},{key:"debug",label:"Tiles"}]}),Ei.render(s.displayControlsEl);let xr=document.createElement("div");xr.className="renderer-controls",s.displayControlsEl.appendChild(xr);function oe(Pe){return Promise.all(Pe.map(({path:ke,value:dt})=>s.websocketManager.request({type:"set_renderer_control",path:ke,value:dt}))).catch(()=>{})}function de(Pe){xr.innerHTML="";let ke=new Map;for(let dt of Pe||[]){let Ye=dt.group||"";ke.has(Ye)||ke.set(Ye,[]),ke.get(Ye).push(dt)}for(let[dt,Ye]of ke){let ct=xr;if(dt){let Ze=document.createElement("div");Ze.className="vis-group";let{header:Ke,arrow:gt,name:qn}=sk();qn.textContent=dt;let xi=document.createElement("input");xi.type="checkbox",xi.className="vis-cb",xi.title="Visible";let Bi=Ye.filter(Je=>Je.visible).length;xi.checked=Bi===Ye.length,xi.indeterminate=Bi>0&&Bi{let Je=xi.checked;oe(Ye.filter(ti=>!!ti.visible!==Je).map(ti=>({path:ti.path,value:Je})))}),Ke.appendChild(xi),Ke.appendChild(ET()),Ze.appendChild(Ke);let xn=document.createElement("div");xn.className="vis-group-children",Ze.appendChild(xn),ok(Ke,gt,xn,!1),xr.appendChild(Ze),ct=xn}for(let Ze of Ye){let Ke=document.createElement("div");Ke.className="vis-leaf";let gt=document.createElement("span");gt.className="vis-arrow",gt.style.visibility="hidden",gt.textContent="\u25B6",Ke.appendChild(gt),Ke.appendChild(CO(Ze.name));let qn=document.createElement("input");qn.type="checkbox",qn.className="vis-cb",qn.title="Visible",qn.checked=!!Ze.visible,qn.addEventListener("change",()=>oe([{path:Ze.path,value:qn.checked}])),Ke.appendChild(qn),Ke.appendChild(ET()),ct.appendChild(Ke)}}}s.refreshRendererControls=function(){return!s.websocketManager||la(s)||!n.debug_renderers?(xr.innerHTML="",Promise.resolve()):s.websocketManager.request({type:"renderer_controls"}).then(Pe=>de(Pe.controls)).catch(()=>{})},s.refreshRendererControls();let it=document.createElement("div");it.className="bg-color-row";let We=document.createElement("span");We.textContent="Background";let _n=document.createElement("input");_n.type="color",_n.className="bg-color-input",_n.title="Layout background color";let Er=pf("or_bg_color");_n.value=SO(Er)?Er:q5e(),_n.addEventListener("input",()=>{document.documentElement.style.setProperty("--bg-map",_n.value)}),_n.addEventListener("change",()=>{t3t(_n.value,s)});let qi=document.createElement("button");qi.className="bg-color-reset",qi.textContent="Reset",qi.title="Reset background to the theme default",qi.addEventListener("click",()=>{n3t(s),_n.value=q5e()}),it.appendChild(We),it.appendChild(_n),it.appendChild(qi),!s.heatMapLayer&&d&&(s.heatMapLayer=d());let Te=document.createElement("div");Te.className="vis-group heatmap-controls",s.displayControlsEl.appendChild(Te);let{header:ve,arrow:_t,name:mn}=sk("vis-group-header heatmap-header");mn.textContent="Heat Maps",Te.appendChild(ve);let yn=document.createElement("div");yn.className="vis-group-children heatmap-group-children",Te.appendChild(yn),ok(ve,_t,yn,!0),s.displayControlsEl.appendChild(it);function Sn(Pe,ke,dt,Ye){let ct=document.createElement("label");ct.className="heatmap-setting";let Ze=document.createElement("input");Ze.type="checkbox",Ze.checked=dt,Ze.addEventListener("change",()=>Ye(Ze.checked)),ct.appendChild(Ze),ct.appendChild(document.createTextNode(ke)),Pe.appendChild(ct)}function yi(Pe,ke,dt,Ye,ct){let Ze=document.createElement("label");Ze.className="heatmap-setting";let Ke=document.createElement("span");Ke.textContent=ke;let gt=document.createElement("input");gt.type="number",gt.value=String(dt),gt.step=String(Ye||1),gt.addEventListener("change",()=>ct(parseFloat(gt.value))),Ze.appendChild(Ke),Ze.appendChild(gt),Pe.appendChild(Ze)}function hi(Pe,ke,dt,Ye,ct){let Ze=document.createElement("label");Ze.className="heatmap-setting";let Ke=document.createElement("span");Ke.textContent=ke;let gt=document.createElement("select");for(let qn of Ye){let xi=document.createElement("option");xi.value=qn,xi.textContent=qn,qn===dt&&(xi.selected=!0),gt.appendChild(xi)}gt.addEventListener("change",()=>ct(gt.value)),Ze.appendChild(Ke),Ze.appendChild(gt),Pe.appendChild(Ze)}function ri(Pe){s.websocketManager.request(Pe).then(ke=>{s.updateHeatMaps&&s.updateHeatMaps(ke)}).catch(ke=>console.error("Heat map update failed",ke))}function Ge(Pe){if(!s.heatMapLegendEl)return;let ke=s.heatMapLegendEl;if(ke.innerHTML="",!Pe||!Pe.show_legend||!Pe.legend||Pe.legend.length===0){ke.classList.add("hidden");return}let dt=document.createElement("div");dt.className="heatmap-map-legend-title",dt.textContent=Pe.title,ke.appendChild(dt);let Ye=document.createElement("div");Ye.className="heatmap-map-legend-units",Ye.textContent=Pe.units||"",ke.appendChild(Ye);let ct=document.createElement("div");ct.className="heatmap-map-legend-list";for(let Ze of Pe.legend){let Ke=document.createElement("div");Ke.className="heatmap-legend-row";let gt=document.createElement("span");gt.className="heatmap-legend-swatch",gt.style.backgroundColor=`rgba(${Ze.color[0]}, ${Ze.color[1]}, ${Ze.color[2]}, ${Ze.color[3]/255})`;let qn=document.createElement("span");qn.textContent=Ze.value,Ke.appendChild(gt),Ke.appendChild(qn),ct.appendChild(Ke)}ke.appendChild(ct),ke.classList.remove("hidden")}s.renderHeatMapControls=Pe=>{yn.innerHTML="";let ke=document.createElement("div");ke.className="heatmap-list",yn.appendChild(ke);let dt=document.createElement("label");dt.className="heatmap-setting";let Ye=document.createElement("input");Ye.type="radio",Ye.name="active-heatmap",Ye.checked=!Pe.active,Ye.addEventListener("change",()=>{ri({type:"set_active_heatmap",name:""})}),dt.appendChild(Ye),dt.appendChild(document.createTextNode("Off")),ke.appendChild(dt);for(let gt of Pe.heatmaps||[]){let qn=document.createElement("label");qn.className="heatmap-setting";let xi=document.createElement("input");xi.type="radio",xi.name="active-heatmap",xi.checked=gt.name===Pe.active,xi.addEventListener("change",()=>{ri({type:"set_active_heatmap",name:gt.name})}),qn.appendChild(xi),qn.appendChild(document.createTextNode(gt.title)),ke.appendChild(qn)}let ct=(Pe.heatmaps||[]).find(gt=>gt.name===Pe.active);if(Ge(ct),!ct)return;let Ze=document.createElement("div");Ze.className="heatmap-settings",yn.appendChild(Ze),yi(Ze,"Display min",ct.display_min,ct.display_range_increment,gt=>{ri({type:"set_heatmap",name:ct.name,option:"DisplayMin",value:gt})}),yi(Ze,"Display max",ct.display_max,ct.display_range_increment,gt=>{ri({type:"set_heatmap",name:ct.name,option:"DisplayMax",value:gt})}),Sn(Ze,"Show below min",ct.draw_below_min,gt=>{ri({type:"set_heatmap",name:ct.name,option:"ShowMin",value:gt})}),Sn(Ze,"Show above max",ct.draw_above_max,gt=>{ri({type:"set_heatmap",name:ct.name,option:"ShowMax",value:gt})}),Sn(Ze,"Log scale",ct.log_scale,gt=>{ri({type:"set_heatmap",name:ct.name,option:"LogScale",value:gt})}),Sn(Ze,"Reverse log",ct.reverse_log,gt=>{ri({type:"set_heatmap",name:ct.name,option:"ReverseLog",value:gt})}),ct.can_adjust_grid&&(yi(Ze,"Grid X",ct.grid_x,.1,gt=>{ri({type:"set_heatmap",name:ct.name,option:"GridX",value:gt})}),yi(Ze,"Grid Y",ct.grid_y,.1,gt=>{ri({type:"set_heatmap",name:ct.name,option:"GridY",value:gt})})),yi(Ze,"Alpha",ct.alpha,1,gt=>{ri({type:"set_heatmap",name:ct.name,option:"Alpha",value:gt})}),Sn(Ze,"Legend",ct.show_legend,gt=>{ri({type:"set_heatmap",name:ct.name,option:"ShowLegend",value:gt})}),ct.supports_numbers&&Sn(Ze,"Show numbers",ct.show_numbers,gt=>{ri({type:"set_heatmap",name:ct.name,option:"ShowNumbers",value:gt})});for(let gt of ct.options||[])gt.type==="bool"?Sn(Ze,gt.label,gt.value,qn=>{ri({type:"set_heatmap",name:ct.name,option:gt.name,value:qn})}):gt.type==="choice"&&hi(Ze,gt.label,gt.value,gt.choices||[],qn=>{ri({type:"set_heatmap",name:ct.name,option:gt.name,value:qn})});ct.selection_filter_label&&Sn(Ze,ct.selection_filter_label,ct.use_selected_only,gt=>{ri({type:"set_heatmap",name:ct.name,option:"use_selected_only",value:gt})});let Ke=document.createElement("button");Ke.className="or-btn or-btn-sm heatmap-rebuild",Ke.textContent="Rebuild data",Ke.addEventListener("click",()=>{ri({type:"set_heatmap",name:ct.name,option:"rebuild",value:1})}),Ze.appendChild(Ke)}}var v3t="search-nav-dialog",jdn=[{label:"Instance",value:"inst"},{label:"Net",value:"net"},{label:"Port",value:"port"}];function ide(s){if(!s.designScale)return;let n=jdn.map(T=>``).join(""),{overlay:r,close:c,okBtn:u,showError:d}=MO("Find Object",`
- +
`,"Find",WJt),S=h.querySelector(".sn-pattern"),y=h.querySelector(".sn-type"),I=h.querySelector(".sn-case");S.focus();function N(){let B=S.value.trim();if(!B){_("Enter a name or glob pattern.");return}d.websocketManager&&(_("Searching\u2026",!0),d.websocketManager.request({type:"find",obj_type:y.value,pattern:B,match_case:I.checked}).then(P=>{fR(d,P);let U=P&&P.count?P.count:0;if(!U){_("No objects found.");return}Array.isArray(P.bbox)&&(d.lastSelectionBounds=Vf(P.bbox[0],P.bbox[1],P.bbox[2],P.bbox[3],d.designScale,d.designMaxDXDY,d.designOriginX,d.designOriginY),d.map.fitBounds(d.lastSelectionBounds)),typeof d.updateInspector=="function"&&d.updateInspector(P),typeof d.redrawAllLayers=="function"&&d.redrawAllLayers();let j=P.selection_count||U;_(P.truncated?`${U} found (showing first ${j}).`:`${U} found.`,!0)}).catch(P=>_("Find failed: "+P)))}return m.addEventListener("click",N),S.addEventListener("keydown",B=>{B.key==="Enter"&&(B.preventDefault(),N())}),{close:p}}function pnt(d){if(!d.designScale||!d.map)return;let s=V=>d.formatDbu(V),h=V=>d.parseDbu(V),p=d.unitLabel(),m=d.map.getCenter(),_=Yw(m.lat,m.lng,d.designScale,d.designMaxDXDY,d.designOriginX,d.designOriginY),{overlay:S,close:y,okBtn:I,showError:N}=gR("Go to Position",` -
-
-
-
-
-
`,"Go to",WJt),B=S.querySelector(".sn-x"),P=S.querySelector(".sn-y"),U=S.querySelector(".sn-size");B.focus(),B.select();function j(){let V=h(B.value),et=h(P.value);if(V===null||et===null){N(`X and Y must be numbers (${p}).`);return}let Q=Id(V,et,d.designScale,d.designMaxDXDY,d.designOriginX,d.designOriginY),X=U.value.trim(),gt=X?h(X):null;if(gt!==null&>>0){let ft=gt/2;d.map.fitBounds(Vf(V-ft,et-ft,V+ft,et+ft,d.designScale,d.designMaxDXDY,d.designOriginX,d.designOriginY))}else d.map.setView(Q,d.map.getZoom());y()}I.addEventListener("click",j);for(let V of[B,P,U])V.addEventListener("keydown",et=>{et.key==="Enter"&&(et.preventDefault(),j())});return{close:y}}var $Jt={ctrl:"ctrl",control:"ctrl",shift:"shift",alt:"alt",meta:"meta",cmd:"meta",command:"meta",super:"meta"};function Xke(d){if(typeof d!="string")return null;let s=d.split("+").map(_=>_.trim().toLowerCase()).filter(Boolean);if(s.length===0)return null;let h=s.pop();if($Jt[h]!==void 0)return null;let p=new Set;for(let _ of s){let S=$Jt[_];if(S===void 0)return null;p.add(S)}return[...["ctrl","alt","shift","meta"].filter(_=>p.has(_)),h].join("+")}function Zke(d){let s=[];return d.ctrlKey&&s.push("ctrl"),d.altKey&&s.push("alt"),d.shiftKey&&s.push("shift"),d.metaKey&&s.push("meta"),[...s,String(d.key).toLowerCase()].join("+")}function qJt(d){let s=[{label:"File",items:[{label:"Open DB...",action:()=>VJt(d,"Open DB","read_db"),enabledWhen:()=>!d.designScale},{label:"Save DB...",action:()=>VJt(d,"Save DB","write_db"),enabledWhen:()=>!!d.designScale}]},{label:"View",items:[{label:"Fit",shortcut:"F",action:()=>{d.fitBounds&&d.map.fitBounds(d.fitBounds)}},{label:"Zoom In",shortcut:"Z",action:()=>d.map.zoomIn()},{label:"Zoom Out",shortcut:"Shift+Z",action:()=>d.map.zoomOut()},{type:"separator"},{label:"Toggle Theme",shortcut:"T",action:()=>d.toggleTheme()},{type:"separator"},{label:"Find...",shortcut:"Ctrl+F",action:()=>dnt(d),enabledWhen:()=>!!d.designScale},{label:"Go to Position...",shortcut:"Shift+G",action:()=>pnt(d),enabledWhen:()=>!!d.designScale}]},{label:"Tools",items:[{label:"Ruler",shortcut:"K",action:()=>{d.rulerManager&&d.rulerManager.toggleRulerMode()}},{label:"Clear Rulers",shortcut:"Shift+K",action:()=>{d.rulerManager&&d.rulerManager.clearAllRulers()}},{type:"separator"},{label:"Add Label",shortcut:"L",action:()=>{d.labelManager&&d.labelManager.toggleLabelMode()}},{label:"Clear Labels",action:()=>{d.labelManager&&d.labelManager.clearAllLabels()}},{type:"separator"},{label:"Clear Highlights",action:()=>{d.websocketManager.request({type:"clear_highlights",group:-1}).then(()=>{d.refreshOverlay&&d.refreshOverlay(),d.refreshInspector&&d.refreshInspector()}).catch(()=>{})}},{type:"separator"},{label:"Global Connect...",action:()=>{d.showGlobalConnectDialog&&d.showGlobalConnectDialog()},enabledWhen:()=>!!d.designScale}]},{label:"Options",items:[{label:"Show DBU",action:()=>d.toggleShowDbu(),checked:()=>d.showDbu},{label:"Make euclidian rulers",action:()=>d.toggleRulerStyle(),checked:()=>d.rulerStyle!=="manhattan"},{type:"separator"},{label:"Mouse wheel mapped to zoom by default",action:()=>d.toggleWheelZoom(),checked:()=>d.wheelZoom},{label:"Arrow keys scroll step...",action:()=>d.showArrowStepDialog()},{label:"Application font...",action:()=>d.showAppFontDialog()},{type:"separator"},{label:"Show polygon decomposition",action:()=>d.togglePolyDecomp(),checked:()=>d.polyDecomp,enabledWhen:()=>!!d.designScale}]},{label:"Windows",items:[{label:"Layout Viewer",action:()=>d.focusComponent("LayoutViewer")},{label:"3D Viewer",action:()=>d.focusComponent("3DViewer")},{label:"Display Controls",action:()=>d.focusComponent("DisplayControls")},{label:"Inspector",action:()=>d.focusComponent("Inspector")},{label:"Selection Browser",action:()=>d.focusComponent("SelectHighlight")},{label:"Tcl Console",action:()=>d.focusComponent("TclConsole")},{label:"Hierarchy Browser",action:()=>d.focusComponent("Browser")},{label:"Timing",action:()=>d.focusComponent("TimingWidget")},{label:"DRC Viewer",action:()=>d.focusComponent("DRCWidget")},{label:"Clock Tree",action:()=>d.focusComponent("ClockWidget")},{label:"Charts",action:()=>d.focusComponent("ChartsWidget")},{label:"Help",action:()=>d.focusComponent("HelpWidget")},{type:"separator"},{label:"Reset to Default Layout",action:()=>d.resetLayout()}]},{label:"Help",items:[{label:"Keyboard Shortcuts",action:()=>d.focusComponent("HelpWidget")}]}],h=document.getElementById("menu-bar"),p=null,m=new Map;function _(){p&&(p.classList.remove("open"),p=null)}function S(){let N=s.map(j=>({label:j.label,items:j.items.slice()})),B=new Map(N.map(j=>[j.label,j]));function P(j){let V=B.get(j);return V||(V={label:j,items:[]},B.set(j,V),N.push(V)),V}function U(j,V){let et=j.items.find(Q=>Q.submenu&&Q.label===V);return et||(et={label:V,submenu:{label:V,items:[]}},j.items.push(et)),et.submenu}for(let j of d.customMenu||[]){let V=String(j.path||"Custom Scripts").split("/").map(gt=>gt.trim()).filter(Boolean);V.length===0&&V.push("Custom Scripts");let et=P(V[0]);for(let gt=1;gtFU(d,j.script,j.echo);et.items.push({label:j.text,shortcut:j.shortcut,action:Q});let X=Xke(j.shortcut);X&&m.set(X,Q)}return N}function y(N,B){for(let P of B){if(P.type==="separator"){let V=document.createElement("div");V.className="menu-separator",N.appendChild(V);continue}let U=document.createElement("div");if(U.className="menu-item",P.submenu){U.classList.add("submenu-item");let V=document.createElement("span");V.textContent=P.label,U.appendChild(V);let et=document.createElement("span");et.className="submenu-arrow",et.textContent="\u25B8",U.appendChild(et);let Q=document.createElement("div");Q.className="menu-dropdown submenu",y(Q,P.submenu.items),U.appendChild(Q),N.appendChild(U);continue}if(P.disabled&&U.classList.add("disabled"),P.enabledWhen&&(U._enabledWhen=P.enabledWhen),P.checked){let V=document.createElement("span");V.className="menu-check",V.textContent=P.checked()?"\u2713":"",U.appendChild(V),U._checkedFn=P.checked}let j=document.createElement("span");if(j.textContent=P.label,U.appendChild(j),P.shortcut){let V=document.createElement("span");V.className="shortcut",V.textContent=P.shortcut,U.appendChild(V)}P.action&&U.addEventListener("click",V=>{U.classList.contains("disabled")||(V.stopPropagation(),_(),P.action())}),N.appendChild(U)}}function I(){for(let B of h.querySelectorAll(":scope > .menu-label"))B.remove();let N=h.firstChild;p=null,m.clear();for(let B of S()){let j=function(){for(let V of U.querySelectorAll(".menu-item"))if(V._enabledWhen&&V.classList.toggle("disabled",!V._enabledWhen()),V._checkedFn){let et=V.querySelector(".menu-check");et&&(et.textContent=V._checkedFn()?"\u2713":"")}},P=document.createElement("div");P.className="menu-label",P.textContent=B.label;let U=document.createElement("div");U.className="menu-dropdown",y(U,B.items),P.appendChild(U),P.addEventListener("click",V=>{V.stopPropagation(),p===P?_():(_(),j(),P.classList.add("open"),p=P)}),P.addEventListener("mouseenter",()=>{p&&p!==P&&(_(),j(),P.classList.add("open"),p=P)}),h.insertBefore(P,N)}}I(),d.rebuildMenuBar=I,document.addEventListener("click",_),Yke(m)}function Yke(d){document.addEventListener("keydown",s=>{if(d.size===0)return;let h=s.target.tagName;if(h==="INPUT"||h==="TEXTAREA"||s.target.isContentEditable)return;let p=d.get(Zke(s));p&&(s.preventDefault(),s.stopImmediatePropagation(),p())},!0)}function VJt(d,s,h){let p=h==="write_db",m=document.createElement("div");m.className="modal-overlay",m.innerHTML=` + `,"Find",v3t),b=r.querySelector(".sn-pattern"),w=r.querySelector(".sn-type"),_=r.querySelector(".sn-case");b.focus();function x(){let T=b.value.trim();if(!T){d("Enter a name or glob pattern.");return}s.websocketManager&&(d("Searching\u2026",!0),s.websocketManager.request({type:"find",obj_type:w.value,pattern:T,match_case:_.checked}).then(M=>{EO(s,M);let L=M&&M.count?M.count:0;if(!L){d("No objects found.");return}Array.isArray(M.bbox)&&(s.lastSelectionBounds=M.bbox.slice(0,4),s.view.fitWorldRect(X1(...s.lastSelectionBounds,s.designScale,s.designOriginX,s.designOriginY))),typeof s.updateInspector=="function"&&s.updateInspector(M),typeof s.redrawAllLayers=="function"&&s.redrawAllLayers();let I=M.selection_count||L;d(M.truncated?`${L} found (showing first ${I}).`:`${L} found.`,!0)}).catch(M=>d("Find failed: "+M)))}return u.addEventListener("click",x),b.addEventListener("keydown",T=>{T.key==="Enter"&&(T.preventDefault(),x())}),{close:c}}function rde(s){if(!s.designScale||!s.view)return;let n=D=>s.formatDbu(D),r=D=>s.parseDbu(D),c=s.unitLabel(),u=s.view.getCenter(),d=Pv(u[0],u[1],s.designScale,s.designOriginX,s.designOriginY),{overlay:b,close:w,okBtn:_,showError:x}=MO("Go to Position",` +
+
+
+
+
+
`,"Go to",v3t),T=b.querySelector(".sn-x"),M=b.querySelector(".sn-y"),L=b.querySelector(".sn-size");T.focus(),T.select();function I(){let D=r(T.value),F=r(M.value);if(D===null||F===null){x(`X and Y must be numbers (${c}).`);return}let O=L.value.trim(),z=O?r(O):null;if(z!==null&&z>0){let Z=z/2;s.view.fitWorldRect(X1(D-Z,F-Z,D+Z,F+Z,s.designScale,s.designOriginX,s.designOriginY))}else s.view.setView(Av(D,F,s.designScale,s.designOriginX,s.designOriginY),s.view.getZoom());w()}_.addEventListener("click",I);for(let D of[T,M,L])D.addEventListener("keydown",F=>{F.key==="Enter"&&(F.preventDefault(),I())});return{close:w}}var _3t={ctrl:"ctrl",control:"ctrl",shift:"shift",alt:"alt",meta:"meta",cmd:"meta",command:"meta",super:"meta"};function $dn(s){if(typeof s!="string")return null;let n=s.split("+").map(d=>d.trim().toLowerCase()).filter(Boolean);if(n.length===0)return null;let r=n.pop();if(_3t[r]!==void 0)return null;let c=new Set;for(let d of n){let b=_3t[d];if(b===void 0)return null;c.add(b)}return[...["ctrl","alt","shift","meta"].filter(d=>c.has(d)),r].join("+")}function Vdn(s){let n=[];return s.ctrlKey&&n.push("ctrl"),s.altKey&&n.push("alt"),s.shiftKey&&n.push("shift"),s.metaKey&&n.push("meta"),[...n,String(s.key).toLowerCase()].join("+")}function x3t(s){let n=[{label:"File",items:[{label:"Open DB...",action:()=>y3t(s,"Open DB","read_db"),enabledWhen:()=>!s.designScale},{label:"Save DB...",action:()=>y3t(s,"Save DB","write_db"),enabledWhen:()=>!!s.designScale}]},{label:"View",items:[{label:"Fit",shortcut:"F",action:()=>{s.fitRect&&s.view.fitWorldRect(s.fitRect)}},{label:"Zoom In",shortcut:"Z",action:()=>s.view.zoomIn()},{label:"Zoom Out",shortcut:"Shift+Z",action:()=>s.view.zoomOut()},{type:"separator"},{label:"Toggle Theme",shortcut:"T",action:()=>s.toggleTheme()},{type:"separator"},{label:"Find...",shortcut:"Ctrl+F",action:()=>ide(s),enabledWhen:()=>!!s.designScale},{label:"Go to Position...",shortcut:"Shift+G",action:()=>rde(s),enabledWhen:()=>!!s.designScale}]},{label:"Tools",items:[{label:"Ruler",shortcut:"K",action:()=>{s.rulerManager&&s.rulerManager.toggleRulerMode()}},{label:"Clear Rulers",shortcut:"Shift+K",action:()=>{s.rulerManager&&s.rulerManager.clearAllRulers()}},{type:"separator"},{label:"Add Label",shortcut:"L",action:()=>{s.labelManager&&s.labelManager.toggleLabelMode()}},{label:"Clear Labels",action:()=>{s.labelManager&&s.labelManager.clearAllLabels()}},{type:"separator"},{label:"Clear Highlights",action:()=>{s.websocketManager.request({type:"clear_highlights",group:-1}).then(()=>{s.refreshOverlay&&s.refreshOverlay(),s.refreshInspector&&s.refreshInspector()}).catch(()=>{})}},{type:"separator"},{label:"Global Connect...",action:()=>{s.showGlobalConnectDialog&&s.showGlobalConnectDialog()},enabledWhen:()=>!!s.designScale}]},{label:"Options",items:[{label:"Show DBU",action:()=>s.toggleShowDbu(),checked:()=>s.showDbu},{label:"Make euclidian rulers",action:()=>s.toggleRulerStyle(),checked:()=>s.rulerStyle!=="manhattan"},{type:"separator"},{label:"Mouse wheel mapped to zoom by default",action:()=>s.toggleWheelZoom(),checked:()=>s.wheelZoom},{label:"Arrow keys scroll step...",action:()=>s.showArrowStepDialog()},{label:"Application font...",action:()=>s.showAppFontDialog()},{type:"separator"},{label:"Smooth zoom and pan",action:()=>s.toggleControlSmoothing(),checked:()=>s.controlSmoothing},{label:"Double buffering",action:()=>s.toggleDoubleBuffer(),checked:()=>s.doubleBuffer},{label:"Defer tile updates while panning",action:()=>s.toggleDeferTileUpdates(),checked:()=>s.deferTileUpdates},{type:"separator"},{label:"Show polygon decomposition",action:()=>s.togglePolyDecomp(),checked:()=>s.polyDecomp,enabledWhen:()=>!!s.designScale}]},{label:"Windows",items:[{label:"Layout Viewer",action:()=>s.focusComponent("LayoutViewer")},{label:"3D Viewer",action:()=>s.focusComponent("3DViewer")},{label:"Display Controls",action:()=>s.focusComponent("DisplayControls")},{label:"Inspector",action:()=>s.focusComponent("Inspector")},{label:"Selection Browser",action:()=>s.focusComponent("SelectHighlight")},{label:"Tcl Console",action:()=>s.focusComponent("TclConsole")},{label:"Hierarchy Browser",action:()=>s.focusComponent("Browser")},{label:"Timing",action:()=>s.focusComponent("TimingWidget")},{label:"DRC Viewer",action:()=>s.focusComponent("DRCWidget")},{label:"Clock Tree",action:()=>s.focusComponent("ClockWidget")},{label:"Charts",action:()=>s.focusComponent("ChartsWidget")},{label:"Help",action:()=>s.focusComponent("HelpWidget")},{type:"separator"},{label:"Reset to Default Layout",action:()=>s.resetLayout()}]},{label:"Help",items:[{label:"Keyboard Shortcuts",action:()=>s.focusComponent("HelpWidget")}]}],r=document.getElementById("menu-bar"),c=null,u=new Map;function d(){c&&(c.classList.remove("open"),c=null)}function b(){let x=n.map(I=>({label:I.label,items:I.items.slice()})),T=new Map(x.map(I=>[I.label,I]));function M(I){let D=T.get(I);return D||(D={label:I,items:[]},T.set(I,D),x.push(D)),D}function L(I,D){let F=I.items.find(O=>O.submenu&&O.label===D);return F||(F={label:D,submenu:{label:D,items:[]}},I.items.push(F)),F.submenu}for(let I of s.customMenu||[]){let D=String(I.path||"Custom Scripts").split("/").map(Z=>Z.trim()).filter(Boolean);D.length===0&&D.push("Custom Scripts");let F=M(D[0]);for(let Z=1;ZiH(s,I.script,I.echo);F.items.push({label:I.text,shortcut:I.shortcut,action:O});let z=$dn(I.shortcut);z&&u.set(z,O)}return x}function w(x,T){for(let M of T){if(M.type==="separator"){let D=document.createElement("div");D.className="menu-separator",x.appendChild(D);continue}let L=document.createElement("div");if(L.className="menu-item",M.submenu){L.classList.add("submenu-item");let D=document.createElement("span");D.textContent=M.label,L.appendChild(D);let F=document.createElement("span");F.className="submenu-arrow",F.textContent="\u25B8",L.appendChild(F);let O=document.createElement("div");O.className="menu-dropdown submenu",w(O,M.submenu.items),L.appendChild(O),x.appendChild(L);continue}if(M.disabled&&L.classList.add("disabled"),M.enabledWhen&&(L._enabledWhen=M.enabledWhen),M.checked){let D=document.createElement("span");D.className="menu-check",D.textContent=M.checked()?"\u2713":"",L.appendChild(D),L._checkedFn=M.checked}let I=document.createElement("span");if(I.textContent=M.label,L.appendChild(I),M.shortcut){let D=document.createElement("span");D.className="shortcut",D.textContent=M.shortcut,L.appendChild(D)}M.action&&L.addEventListener("click",D=>{L.classList.contains("disabled")||(D.stopPropagation(),d(),M.action())}),x.appendChild(L)}}function _(){for(let T of r.querySelectorAll(":scope > .menu-label"))T.remove();let x=r.firstChild;c=null,u.clear();for(let T of b()){let I=function(){for(let D of L.querySelectorAll(".menu-item"))if(D._enabledWhen&&D.classList.toggle("disabled",!D._enabledWhen()),D._checkedFn){let F=D.querySelector(".menu-check");F&&(F.textContent=D._checkedFn()?"\u2713":"")}},M=document.createElement("div");M.className="menu-label",M.textContent=T.label;let L=document.createElement("div");L.className="menu-dropdown",w(L,T.items),M.appendChild(L),M.addEventListener("click",D=>{D.stopPropagation(),c===M?d():(d(),I(),M.classList.add("open"),c=M)}),M.addEventListener("mouseenter",()=>{c&&c!==M&&(d(),I(),M.classList.add("open"),c=M)}),r.insertBefore(M,x)}}_(),s.rebuildMenuBar=_,document.addEventListener("click",d),Wdn(u)}function Wdn(s){document.addEventListener("keydown",n=>{if(s.size===0)return;let r=n.target.tagName;if(r==="INPUT"||r==="TEXTAREA"||n.target.isContentEditable)return;let c=s.get(Vdn(n));c&&(n.preventDefault(),n.stopImmediatePropagation(),c())},!0)}function y3t(s,n,r){let c=r==="write_db",u=document.createElement("div");u.className="modal-overlay",u.innerHTML=` -
`,document.body.appendChild(m);let _=m.querySelector(".fb-breadcrumb"),S=m.querySelector(".fb-file-list"),y=m.querySelector(".fb-path-input"),I=m.querySelector(".modal-error"),N=m.querySelector(".ok"),B=m.querySelector(".cancel"),P="",U=null;function j(){m.remove()}function V(){let ft=y.value.trim();N.disabled=!ft}function et(ft){_.innerHTML="";let xt=ft.split("/").filter(Boolean),Bt=document.createElement("span");Bt.className="fb-crumb",Bt.textContent="/",Bt.addEventListener("click",()=>X("/")),_.appendChild(Bt);let Dt="";for(let Pt of xt){Dt+="/"+Pt;let se=document.createElement("span");se.className="fb-crumb-sep",se.textContent=" / ",_.appendChild(se);let ot=document.createElement("span");ot.className="fb-crumb",ot.textContent=Pt;let Lt=Dt;ot.addEventListener("click",()=>X(Lt)),_.appendChild(ot)}}function Q(ft){if(S.innerHTML="",U=null,!ft||ft.length===0){let xt=document.createElement("div");xt.className="fb-empty",xt.textContent="(empty directory)",S.appendChild(xt);return}for(let xt of ft){let Bt=document.createElement("div");Bt.className="fb-entry",xt.is_dir&&Bt.classList.add("fb-dir");let Dt=document.createElement("span");Dt.className="fb-icon",Dt.textContent=xt.is_dir?"\u{1F4C1}":"\u{1F4C4}",Bt.appendChild(Dt);let Pt=document.createElement("span");if(Pt.className="fb-name",Pt.textContent=xt.name,Bt.appendChild(Pt),!xt.is_dir&&xt.size!==void 0){let se=document.createElement("span");se.className="fb-size",se.textContent=Kke(xt.size),Bt.appendChild(se)}xt.is_dir?Bt.addEventListener("click",()=>{X(P+"/"+xt.name)}):(Bt.addEventListener("click",()=>{let se=S.querySelector(".fb-selected");se&&se.classList.remove("fb-selected"),Bt.classList.add("fb-selected"),U=xt,y.value=P+"/"+xt.name,V()}),Bt.addEventListener("dblclick",()=>{y.value=P+"/"+xt.name,V(),gt()})),S.appendChild(Bt)}}async function X(ft){I.style.display="none",S.innerHTML='
Loading...
';try{let xt=await d.websocketManager.request({type:"list_dir",path:ft||""});if(P=xt.path,et(xt.path),Q(xt.entries),p){let Dt=y.value.trim().split("/").pop();Dt&&!Dt.includes("/")?y.value=P+"/"+Dt:y.value=P+"/"}else y.value="",U=null;V()}catch(xt){S.innerHTML="",I.textContent=xt.message||String(xt),I.style.display=""}}async function gt(){let ft=y.value.trim();if(ft){N.disabled=!0,N.textContent="Working...",I.style.display="none";try{let xt=await d.websocketManager.request({type:"tcl_eval",cmd:`${h} ${ft}`});if(xt.is_error){I.textContent=xt.output||xt.result||"Command failed",I.style.display="",N.disabled=!1,N.textContent=p?"Save":"Open";return}if(j(),h==="read_db"){window.location.reload();return}}catch(xt){I.textContent=xt.message||"Request failed",I.style.display="",N.disabled=!1,N.textContent=p?"Save":"Open"}}}y.addEventListener("input",V),y.addEventListener("keydown",ft=>{if(ft.key==="Enter"){let xt=y.value.trim();xt.endsWith("/")?X(xt.replace(/\/+$/,"")||"/"):gt()}ft.key==="Escape"&&j()}),N.addEventListener("click",gt),B.addEventListener("click",j),m.addEventListener("click",ft=>{ft.target===m&&j()}),X("")}function Kke(d){return d<1024?d+" B":d<1024*1024?(d/1024).toFixed(1)+" KB":d<1024*1024*1024?(d/(1024*1024)).toFixed(1)+" MB":(d/(1024*1024*1024)).toFixed(1)+" GB"}function XJt(d){let s=document.getElementById("toolbar");if(!s)return;d._toolbarToggleState||(d._toolbarToggleState={});function h(){s.innerHTML="";let p=d.customToolbar||[],m=new Set(p.map(_=>_.key));for(let _ of Object.keys(d._toolbarToggleState))m.has(_)||delete d._toolbarToggleState[_];for(let _ of p){let S=document.createElement("button");if(S.className="or-btn or-btn-sm toolbar-button",S.dataset.key=_.key,_.tooltip&&(S.title=_.tooltip),_.icon){let y=document.createElement("span");if(y.className="toolbar-icon",/^(data:|https?:|\.?\/)/.test(_.icon)){let I=document.createElement("img");I.src=_.icon,I.alt="",y.appendChild(I)}else y.textContent=_.icon;S.appendChild(y)}if(_.text){let y=document.createElement("span");y.className="toolbar-label",y.textContent=_.text,S.appendChild(y)}_.toggle&&d._toolbarToggleState[_.key]&&S.classList.add("active"),S.addEventListener("click",()=>{if(_.toggle){let y=!d._toolbarToggleState[_.key];d._toolbarToggleState[_.key]=y,S.classList.toggle("active",y),FU(d,y?_.script:_.script_off,_.echo)}else FU(d,_.script,_.echo)}),s.appendChild(S)}}return h(),d.rebuildToolbar=h,{rebuild:h}}function YJt(d,s=""){let h=document.createElement("div");h.className="modal-overlay",h.innerHTML=` - `,document.body.appendChild(u);let d=u.querySelector(".fb-breadcrumb"),b=u.querySelector(".fb-file-list"),w=u.querySelector(".fb-path-input"),_=u.querySelector(".modal-error"),x=u.querySelector(".ok"),T=u.querySelector(".cancel"),M="",L=null;function I(){u.remove()}function D(){let H=w.value.trim();x.disabled=!H}function F(H){d.innerHTML="";let te=H.split("/").filter(Boolean),se=document.createElement("span");se.className="fb-crumb",se.textContent="/",se.addEventListener("click",()=>z("/")),d.appendChild(se);let ne="";for(let ue of te){ne+="/"+ue;let Ce=document.createElement("span");Ce.className="fb-crumb-sep",Ce.textContent=" / ",d.appendChild(Ce);let Q=document.createElement("span");Q.className="fb-crumb",Q.textContent=ue;let me=ne;Q.addEventListener("click",()=>z(me)),d.appendChild(Q)}}function O(H){if(b.innerHTML="",L=null,!H||H.length===0){let te=document.createElement("div");te.className="fb-empty",te.textContent="(empty directory)",b.appendChild(te);return}for(let te of H){let se=document.createElement("div");se.className="fb-entry",te.is_dir&&se.classList.add("fb-dir");let ne=document.createElement("span");ne.className="fb-icon",ne.textContent=te.is_dir?"\u{1F4C1}":"\u{1F4C4}",se.appendChild(ne);let ue=document.createElement("span");if(ue.className="fb-name",ue.textContent=te.name,se.appendChild(ue),!te.is_dir&&te.size!==void 0){let Ce=document.createElement("span");Ce.className="fb-size",Ce.textContent=Hdn(te.size),se.appendChild(Ce)}te.is_dir?se.addEventListener("click",()=>{z(M+"/"+te.name)}):(se.addEventListener("click",()=>{let Ce=b.querySelector(".fb-selected");Ce&&Ce.classList.remove("fb-selected"),se.classList.add("fb-selected"),L=te,w.value=M+"/"+te.name,D()}),se.addEventListener("dblclick",()=>{w.value=M+"/"+te.name,D(),Z()})),b.appendChild(se)}}async function z(H){_.style.display="none",b.innerHTML='
Loading...
';try{let te=await s.websocketManager.request({type:"list_dir",path:H||""});if(M=te.path,F(te.path),O(te.entries),c){let ne=w.value.trim().split("/").pop();ne&&!ne.includes("/")?w.value=M+"/"+ne:w.value=M+"/"}else w.value="",L=null;D()}catch(te){b.innerHTML="",_.textContent=te.message||String(te),_.style.display=""}}async function Z(){let H=w.value.trim();if(H){x.disabled=!0,x.textContent="Working...",_.style.display="none";try{let te=await s.websocketManager.request({type:"tcl_eval",cmd:`${r} ${H}`});if(te.is_error){_.textContent=te.output||te.result||"Command failed",_.style.display="",x.disabled=!1,x.textContent=c?"Save":"Open";return}if(I(),r==="read_db"){window.location.reload();return}}catch(te){_.textContent=te.message||"Request failed",_.style.display="",x.disabled=!1,x.textContent=c?"Save":"Open"}}}w.addEventListener("input",D),w.addEventListener("keydown",H=>{if(H.key==="Enter"){let te=w.value.trim();te.endsWith("/")?z(te.replace(/\/+$/,"")||"/"):Z()}H.key==="Escape"&&I()}),x.addEventListener("click",Z),T.addEventListener("click",I),u.addEventListener("click",H=>{H.target===u&&I()}),z("")}function Hdn(s){return s<1024?s+" B":s<1024*1024?(s/1024).toFixed(1)+" KB":s<1024*1024*1024?(s/(1024*1024)).toFixed(1)+" MB":(s/(1024*1024*1024)).toFixed(1)+" GB"}function E3t(s){let n=document.getElementById("toolbar");if(!n)return;s._toolbarToggleState||(s._toolbarToggleState={});function r(){n.innerHTML="";let c=s.customToolbar||[],u=new Set(c.map(d=>d.key));for(let d of Object.keys(s._toolbarToggleState))u.has(d)||delete s._toolbarToggleState[d];for(let d of c){let b=document.createElement("button");if(b.className="or-btn or-btn-sm toolbar-button",b.dataset.key=d.key,d.tooltip&&(b.title=d.tooltip),d.icon){let w=document.createElement("span");if(w.className="toolbar-icon",/^(data:|https?:|\.?\/)/.test(d.icon)){let _=document.createElement("img");_.src=d.icon,_.alt="",w.appendChild(_)}else w.textContent=d.icon;b.appendChild(w)}if(d.text){let w=document.createElement("span");w.className="toolbar-label",w.textContent=d.text,b.appendChild(w)}d.toggle&&s._toolbarToggleState[d.key]&&b.classList.add("active"),b.addEventListener("click",()=>{if(d.toggle){let w=!s._toolbarToggleState[d.key];s._toolbarToggleState[d.key]=w,b.classList.toggle("active",w),iH(s,w?d.script:d.script_off,d.echo)}else iH(s,d.script,d.echo)}),n.appendChild(b)}}return r(),s.rebuildToolbar=r,{rebuild:r}}function M3t(s,n=""){let r=document.createElement("div");r.className="modal-overlay",r.innerHTML=` + `,document.body.appendChild(h);function p(_){_.key==="Escape"&&m()}let m=()=>{h.remove(),document.removeEventListener("keydown",p)};return h.addEventListener("click",_=>{_.target===h&&m()}),document.addEventListener("keydown",p),{overlay:h,body:h.querySelector(".modal-body"),errorDiv:h.querySelector(".modal-error"),buttons:h.querySelector(".modal-buttons"),close:m}}function xy(d,s){d.textContent=s,d.style.display=s?"":"none"}function wR(d,s,{primary:h=!1}={}){let p=document.createElement("button");return p.textContent=s,p.className="or-btn"+(h?" or-btn-primary":""),d.appendChild(p),p}function gnt(d){return"{"+String(d)+"}"}function KJt(d){let s=YJt("Global Connect","gc-dialog"),h=document.createElement("div");h.className="gc-table",s.body.appendChild(h);let p=document.createElement("div");p.className="gc-form";let m=document.createElement("input");m.placeholder="Instance pattern (regex)",m.value=".*";let _=document.createElement("input");_.placeholder="Pin pattern (regex)";let S=document.createElement("select"),y=document.createElement("select"),I=document.createElement("span");I.innerHTML='',p.append(pS("Instance",m),pS("Pin",_),pS("Net",S),pS("Region",y),I);let N=wR(p,"Add rule");s.body.appendChild(p);function B(){let V=_.value.trim()!==""&&S.value!=="";for(let et of[m,_])try{new RegExp(et.value),et.classList.remove("gc-invalid")}catch{et.classList.add("gc-invalid"),V=!1}N.disabled=!V}m.addEventListener("input",B),_.addEventListener("input",B),S.addEventListener("change",B);function P(){d.websocketManager.request({type:"global_connect_info"}).then(V=>{h.innerHTML='
InstancePinNetRegion
',(V.rules||[]).forEach(et=>{let Q=document.createElement("div");Q.className="gc-row",Q.innerHTML=`${jU(et.inst)}${jU(et.pin)}${jU(et.net)}${jU(et.region||"All")}`;let X=document.createElement("button");X.className="or-btn or-btn-sm or-btn-icon",X.textContent="\u2715",X.title="Delete rule",X.addEventListener("click",()=>{d.websocketManager.request({type:"global_connect_delete",inst:et.inst,pin:et.pin,net:et.net,region:et.region||""}).then(P).catch(gt=>xy(s.errorDiv,String(gt)))}),Q.appendChild(X),h.appendChild(Q)}),q2t(S,V.nets||[]),q2t(y,["All",...V.regions||[]]),B()}).catch(V=>xy(s.errorDiv,String(V)))}N.addEventListener("click",()=>{let V=p.querySelector('input[name="gc-pg"]:checked').value,et=`add_global_connection -net ${gnt(S.value)} -inst_pattern ${gnt(m.value||".*")} -pin_pattern ${gnt(_.value)} -${V}`;y.value&&y.value!=="All"&&(et+=` -region ${gnt(y.value)}`),ZJt(d,et,s.errorDiv,"Rule added.",P)}),wR(s.buttons,"Apply (force)").addEventListener("click",()=>{d.websocketManager.request({type:"global_connect_apply",force:!0}).then(V=>{if(!V.had_rules){xy(s.errorDiv,"No global-connect rules defined \u2014 add a rule first.");return}xy(s.errorDiv,`Connected ${V.connected} pin(s).`),d.scheduleRedrawAllLayers&&d.scheduleRedrawAllLayers(),P()}).catch(V=>xy(s.errorDiv,V.message||String(V)))}),wR(s.buttons,"Clear all").addEventListener("click",()=>ZJt(d,"clear_global_connect",s.errorDiv,"Rules cleared.",P)),wR(s.buttons,"Close").addEventListener("click",s.close),P()}function ZJt(d,s,h,p,m){d.websocketManager.request({type:"tcl_eval",cmd:s}).then(_=>{if(_.is_error){xy(h,_.output||_.result||"Command failed");return}xy(h,p||""),d.scheduleRedrawAllLayers&&d.scheduleRedrawAllLayers(),m&&m()}).catch(_=>xy(h,_.message||String(_)))}function JJt(d,s){let h=YJt(`Insert Buffer \u2014 ${jU(s)}`,"buf-dialog"),p=wR(h.buttons,"Insert",{primary:!0});p.disabled=!0,wR(h.buttons,"Cancel").addEventListener("click",h.close),d.websocketManager.request({type:"buffer_info",net:s}).then(_=>{if(!_.can_buffer){h.body.textContent=_.error||"This net has multiple drivers and cannot be buffered.";return}Jke(d,h,s,_,p)}).catch(_=>{h.body.textContent=String(_)})}function Jke(d,s,h,p,m){let _=document.createElement("div");_.className="buf-pins";let S=p.drivers||[],y=p.loads||[],I=new Set;function N(){_.innerHTML="";let V=(et,Q)=>{let X=document.createElement("label");X.className="buf-pin";let gt=document.createElement("input");gt.type="checkbox",gt.checked=I.has(et.id),gt.addEventListener("change",()=>{if(gt.checked){if(Q)I.clear();else for(let ft of S)I.delete(ft.id);I.add(et.id)}else I.delete(et.id);N(),j()}),X.append(gt,document.createTextNode(" "+et.label)),_.appendChild(X)};S.forEach(et=>V(et,!0)),y.forEach(et=>V(et,!1))}S.length&&I.add(S[0].id),N();let B=document.createElement("select");q2t(B,p.masters||[]);let P=document.createElement("input");P.placeholder="Optional: new buffer name";let U=document.createElement("input");U.placeholder="Optional: new net name",s.body.append(pS("Pins to buffer",_),pS("Buffer master",B),pS("Buffer name",P),pS("Net name",U));function j(){m.disabled=I.size===0||!B.value}B.addEventListener("change",j),j(),m.addEventListener("click",()=>{let V=new Set(S.map(X=>X.id)),et=[...I],Q=et.some(X=>V.has(X))?"driver":"loads";d.websocketManager.request({type:"insert_buffer",net:h,mode:Q,pins:et,master:B.value,buf_name:P.value.trim(),net_name:U.value.trim()}).then(X=>{if(X.is_error||X.ok===!1){xy(s.errorDiv,X.error||X.result||"Insertion failed");return}s.close(),X.inst&&(d.selectedInstanceName=X.inst),d.scheduleRedrawAllLayers&&d.scheduleRedrawAllLayers()}).catch(X=>xy(s.errorDiv,X.message||String(X)))})}function pS(d,s){let h=document.createElement("label");h.className="edit-field";let p=document.createElement("span");return p.textContent=d,h.append(p,s),h}function q2t(d,s){let h=d.value;d.innerHTML="";for(let p of s){let m=document.createElement("option");m.value=p,m.textContent=p,d.appendChild(m)}s.includes(h)&&(d.value=h)}function jU(d){return String(d??"").replace(/&/g,"&").replace(//g,">")}var QJt="#00ffff",Qke="#ffff00",X2t="#ffffff",fk=0,Z2t=1,HU=2,mnt=class{constructor(s,h,p,m){this._app=s,this._visibility=h,this._updateInspector=p,this._focusComponent=m,this._state=fk,this._rulers=[],this._nextId=0,this._pt0=null,this._selectedRulerId=null,this._ctrlHeld=!1,this._shiftHeld=!1,this._rulerPane=null,this._rulerLayerGroup=null,this._previewGroup=null,this._snapGroup=null,this._snapTimer=null,this._lastSnapResult=null,this._onMouseMove=this._handleMouseMove.bind(this),this._onMapClick=this._handleMapClick.bind(this),this._initLayers()}_initLayers(){let s=this._app.map;s&&(this._rulerPane=s.createPane("ruler-pane"),this._rulerPane.style.zIndex="700",this._rulerPane.style.pointerEvents="auto",this._rulerLayerGroup=L.layerGroup([],{pane:"ruler-pane"}).addTo(s),this._previewGroup=L.layerGroup([],{pane:"ruler-pane"}).addTo(s),this._snapGroup=L.layerGroup([],{pane:"ruler-pane"}).addTo(s))}isActive(){return this._state!==fk}updateVisibility(){this._rulerPane&&(this._rulerPane.style.display=this._visibility.rulers?"":"none")}toggleRulerMode(){this._state===fk?this._enterFirstPoint():this.cancelRulerBuild()}cancelRulerBuild(){this._state=fk,this._pt0=null,this._lastSnapResult=null,this._clearPreview(),this._clearSnap(),this._setCursor(!1),this._removeMapListeners()}clearAllRulers(){this._rulers=[],this._selectedRulerId=null,this._rulerLayerGroup.clearLayers(),this._clearPreview(),this._clearSnap(),this._state!==fk&&this.cancelRulerBuild()}_enterFirstPoint(){this._state=Z2t,this._pt0=null,this._lastSnapResult=null,this._setCursor(!0),this._addMapListeners()}_enterMeasuring(s){this._state=HU,this._pt0=s}_addMapListeners(){let s=this._app.map;s&&(s.getContainer().addEventListener("mousemove",this._onMouseMove),s.on("click",this._onMapClick))}_removeMapListeners(){let s=this._app.map;s&&(s.getContainer().removeEventListener("mousemove",this._onMouseMove),s.off("click",this._onMapClick))}_handleMouseMove(s){if(this._state===fk)return;this._ctrlHeld=s.ctrlKey||s.metaKey,this._shiftHeld=s.shiftKey;let h=this._app.map,p=h.getContainer().getBoundingClientRect(),m=h.containerPointToLatLng([s.clientX-p.left,s.clientY-p.top]),_=Yw(m.lat,m.lng,this._app.designScale,this._app.designMaxDXDY,this._app.designOriginX,this._app.designOriginY);this._snapTimer&&clearTimeout(this._snapTimer),this._snapTimer=setTimeout(()=>{this._requestSnap(_.dbuX,_.dbuY)},50)}_handleMapClick(s){if(this._state===fk)return;L.DomEvent.stopPropagation(s);let h=s.originalEvent;h&&(this._ctrlHeld=h.ctrlKey||h.metaKey,this._shiftHeld=h.shiftKey);let p=Yw(s.latlng.lat,s.latlng.lng,this._app.designScale,this._app.designMaxDXDY,this._app.designOriginX,this._app.designOriginY),m=this._getSnappedPoint(p.dbuX,p.dbuY);this._state===Z2t?this._enterMeasuring(m):this._state===HU&&(this._createRuler(this._pt0,m),this._state=Z2t,this._pt0=null,this._clearPreview(),this._clearSnap(),this._lastSnapResult=null)}async _requestSnap(s,h){let p=this._app;if(!p.websocketManager||!p.designScale)return;if(this._ctrlHeld){this._lastSnapResult=null,this._clearSnap(),this._updatePreview(s,h);return}let _=p.techData?.dbu_per_micron||1e3,S=p.map.getZoom(),y=Math.pow(2,Math.max(0,S)),I=1/(p.designScale*y),N=Math.max(Math.round(10*I),10),B=!0,P=!0;if(this._shiftHeld)B=!0,P=!0;else if(this._state===HU&&this._pt0){let j=Math.abs(s-this._pt0.x),V=Math.abs(h-this._pt0.y);j>V?(B=!1,P=!0):V>j&&(B=!0,P=!1)}let U={};for(let[j,V]of Object.entries(this._visibility))U[j]=!!V;try{let j=await p.websocketManager.request({type:"snap",dbu_x:s,dbu_y:h,radius:_,point_threshold:N,horizontal:!!B,vertical:!!P,visible_layers:[...p.visibleLayerNames],...U});this._lastSnapResult=j,this._updateSnapIndicator(j),this._updatePreview(s,h)}catch{this._lastSnapResult=null,this._clearSnap()}}_getSnappedPoint(s,h){if(this._ctrlHeld)return{x:s,y:h};let p=this._lastSnapResult,m;if(p?.found&&p.is_point)m={x:p.edge[0][0],y:p.edge[0][1]};else if(p?.found){let _=p.edge;_[0][1]===_[1][1]?m={x:s,y:_[0][1]}:m={x:_[0][0],y:h}}else m={x:s,y:h};if(!this._shiftHeld&&this._state===HU&&this._pt0){let _=Math.abs(m.x-this._pt0.x),S=Math.abs(m.y-this._pt0.y);_{L.DomEvent.stopPropagation(se),this._selectRuler(s.id)}),B.addLayer(V);let et=this._app.map.getZoom(),Q=Math.pow(2,Math.max(0,et)),gt=8*(1/(h*Q)),ft=(se,ot,Lt)=>{let be=Math.sqrt(ot*ot+Lt*Lt);if(be===0)return;let ln=-Lt/be,Fn=ot/be,ne=Id(se.x+ln*gt,se.y+Fn*gt,h,p,m,_),xe=Id(se.x-ln*gt,se.y-Fn*gt,h,p,m,_);B.addLayer(L.polyline([ne,xe],{color:N,weight:2,pane:"ruler-pane",interactive:!1}))};if(P)ft(s.pt0,P.x-s.pt0.x,P.y-s.pt0.y),ft(s.pt1,s.pt1.x-P.x,s.pt1.y-P.y);else{let se=s.pt1.x-s.pt0.x,ot=s.pt1.y-s.pt0.y;ft(s.pt0,se,ot),ft(s.pt1,se,ot)}let xt=this._computeDistance(s.pt0,s.pt1,s.euclidian),Bt=U?U[0]:(S[0]+y[0])/2,Dt=U?U[1]:(S[1]+y[1])/2,Pt=L.marker([Bt,Dt],{icon:L.divIcon({className:"ruler-label",html:this._formatDistance(xt),iconSize:null}),pane:"ruler-pane",interactive:!1});B.addLayer(Pt),s._layerGroup=B,this._rulerLayerGroup.addLayer(B)}_rerenderAll(){this._rulerLayerGroup.clearLayers();for(let s of this._rulers)this._renderRuler(s)}_selectRuler(s){this._selectedRulerId=s,this._rerenderAll();let h=this._rulers.find(N=>N.id===s);if(!h)return;bg(this._app);let p=Math.abs(h.pt1.x-h.pt0.x),m=Math.abs(h.pt1.y-h.pt0.y),_=h.euclidian?Math.sqrt(p*p+m*m):p+m,S=N=>this._app.formatDbu(N,!0),y=N=>this._app.parseDbu(N),I={type:"Ruler",name:h.name,bbox:[Math.min(h.pt0.x,h.pt1.x),Math.min(h.pt0.y,h.pt1.y),Math.max(h.pt0.x,h.pt1.x),Math.max(h.pt0.y,h.pt1.y)],properties:[{name:"Name",value:h.name,editable:!0},{name:"Label",value:h.label||"",editable:!0},{name:"Point 0 - x",value:S(h.pt0.x),editable:!0},{name:"Point 0 - y",value:S(h.pt0.y),editable:!0},{name:"Point 1 - x",value:S(h.pt1.x),editable:!0},{name:"Point 1 - y",value:S(h.pt1.y),editable:!0},{name:"Delta x",value:S(p)},{name:"Delta y",value:S(m)},{name:"Length",value:S(_)},{name:"Euclidian",value:h.euclidian?"True":"False",editable:!0,editor:{type:"bool"}}],onPropertyChange:(N,B)=>{switch(N){case"Name":h.name=B;break;case"Label":h.label=B;break;case"Point 0 - x":{let P=y(B);P!==null&&(h.pt0.x=P);break}case"Point 0 - y":{let P=y(B);P!==null&&(h.pt0.y=P);break}case"Point 1 - x":{let P=y(B);P!==null&&(h.pt1.x=P);break}case"Point 1 - y":{let P=y(B);P!==null&&(h.pt1.y=P);break}case"Euclidian":h.euclidian=B.trim().toLowerCase()==="true";break}this._rerenderAll(),this._selectRuler(h.id)}};this._updateInspector(I),this._focusComponent("Inspector"),requestAnimationFrame(()=>{let N=this._app.inspectorEl?.querySelector(".inspector-toolbar");if(!N)return;let B=document.createElement("button");B.className="or-btn or-btn-icon",B.title="Delete ruler",B.innerHTML='',B.addEventListener("click",()=>{this.deleteRuler(s)}),N.appendChild(B)})}deleteRuler(s){let h=this._rulers.findIndex(m=>m.id===s);if(h===-1)return;let p=this._rulers[h];p._layerGroup&&this._rulerLayerGroup.removeLayer(p._layerGroup),this._rulers.splice(h,1),this._selectedRulerId===s&&(this._selectedRulerId=null,this._updateInspector(null))}_getManhattanJoinPt(s,h){return{x:h.x,y:s.y}}_computeDistance(s,h,p=!0){let m=Math.abs(h.x-s.x),_=Math.abs(h.y-s.y);return p?Math.sqrt(m*m+_*_):m+_}_formatDistance(s){return this._app.formatDistance(s)}_setCursor(s){let h=this._app.map?.getContainer();h&&(s?h.classList.add("ruler-mode-cursor"):h.classList.remove("ruler-mode-cursor"))}_clearPreview(){this._previewGroup?.clearLayers()}_clearSnap(){this._snapGroup?.clearLayers()}};var bnt=class{constructor(s,h,p,m){this._app=s,this._visibility=h,this._updateInspector=p,this._focusComponent=m,this._labels=[],this._anchors=[],this._mode=!1,this._selectedName=null,this._pane=null,this._handleGroup=null,this._initLayers()}_initLayers(){let s=this._app.map;s&&(this._pane=s.createPane("label-pane"),this._pane.style.zIndex="690",this._pane.style.pointerEvents="auto",this._handleGroup=L.layerGroup([],{pane:"label-pane"}).addTo(s))}isActive(){return this._mode}updateVisibility(){this._pane&&(this._pane.style.display=this._visibility.labels?"":"none")}toggleLabelMode(){this._mode=!this._mode,this._setCursor(this._mode)}cancelLabelMode(){this._mode=!1,this._setCursor(!1)}_setCursor(s){let h=this._app.map?.getContainer();h&&h.classList.toggle("label-mode-cursor",s)}_wm(){return this._app.websocketManager}_applyLabels(s){this._labels=s||[],this._renderHandles()}_refresh(s){this._applyLabels(s&&s.labels),this._app.refreshOverlay()}applyRemoteLabels(s){this._applyLabels(s),this._selectedName&&!this._labels.some(h=>h.name===this._selectedName)&&(this._selectedName=null,this._updateInspector(null),this._renderHandles()),this._app.refreshOverlay()}_updateLabel(s,h){return this._wm().request({type:"update_label",name:s,...h})}async reload(){let s=this._wm();if(s)try{let h=await s.request({type:"list_labels"});this._anchors=h.anchors||[],this._applyLabels(h.labels)}catch{this._applyLabels([])}}async handleMapClick(s,h){let p=window.prompt("Label text:");if(this._mode=!1,this._setCursor(!1),!!p)try{let m=await this._wm().request({type:"add_label",x:Math.round(s),y:Math.round(h),text:p});this._refresh(m)}catch(m){console.error("add_label failed:",m)}}_renderHandles(){if(!this._handleGroup)return;this._handleGroup.clearLayers();let s=this._app.designScale;if(!s)return;let h=this._app.designMaxDXDY,p=this._app.designOriginX,m=this._app.designOriginY;for(let _ of this._labels){let S=Id(_.x,_.y,s,h,p,m),y=_.name===this._selectedName,I=L.marker(S,{pane:"label-pane",draggable:!0,keyboard:!1,icon:L.divIcon({className:"label-handle"+(y?" label-handle-selected":""),html:"",iconSize:[10,10]}),title:_.text});I.on("click",N=>{L.DomEvent.stopPropagation(N),this._select(_.name)}),I.on("dragend",N=>{let B=N.target.getLatLng(),{dbuX:P,dbuY:U}=Yw(B.lat,B.lng,s,h,p,m);this._commitMove(_,Math.round(P),Math.round(U))}),this._handleGroup.addLayer(I)}}async _commitMove(s,h,p){try{let m=await this._updateLabel(s.name,{x:h,y:p,text:s.text,size:s.size||0,anchor:s.anchor||"center",color:s.color});this._refresh(m)}catch(m){console.error("move label failed:",m)}}_select(s){this._selectedName=s,this._renderHandles();let h=this._labels.find(_=>_.name===s);if(!h)return;let p=_=>this._app.formatDbu(_,!0),m={type:"Label",name:h.name,bbox:[h.x,h.y,h.x,h.y],properties:[{name:"Name",value:h.name},{name:"Text",value:h.text,editable:!0},{name:"x",value:p(h.x)},{name:"y",value:p(h.y)},{name:"Font size",value:String(h.size||0),editable:!0},{name:"Anchor",value:h.anchor||"center",editable:!0,editor:{type:"list",options:this._anchors}}],onPropertyChange:(_,S)=>{let y={text:h.text,size:h.size||0,anchor:h.anchor||"center"};_==="Text"?y.text=S:_==="Font size"?y.size=parseInt(S,10)||0:_==="Anchor"&&(y.anchor=S.trim()),this._edit(h,y)}};this._updateInspector(m),this._focusComponent("Inspector"),requestAnimationFrame(()=>{let _=this._app.inspectorEl?.querySelector(".inspector-toolbar");if(!_||_.querySelector(".delete-label-btn"))return;let S=document.createElement("button");S.className="or-btn or-btn-icon delete-label-btn",S.title="Delete label",S.innerHTML='',S.addEventListener("click",()=>this.deleteLabel(s)),_.appendChild(S)})}async _edit(s,h){try{let p=await this._updateLabel(s.name,{x:s.x,y:s.y,text:h.text,size:h.size,anchor:h.anchor,color:s.color});this._refresh(p),this._select(s.name)}catch(p){console.error("edit label failed:",p)}}async deleteLabel(s){try{let h=await this._wm().request({type:"delete_label",name:s});this._selectedName===s&&(this._selectedName=null,this._updateInspector(null)),this._refresh(h)}catch(h){console.error("delete_label failed:",h)}}async clearAllLabels(){try{let s=await this._wm().request({type:"clear_labels"});this._selectedName=null,this._refresh(s)}catch(s){console.error("clear_labels failed:",s)}}};var tQt="Select an instance in the layout to view its schematic.",wnt=class{constructor(s,h){this.container=s,this.appState=h,this.element=document.createElement("div"),this.element.className="schematic-widget",this.element.style.cssText="width:100%; height:100%; display:flex; flex-direction:column; background:var(--bg-panel); color:var(--fg-primary); overflow:hidden;",this.controls=document.createElement("div"),this.controls.style.cssText="padding:4px 8px; background:var(--bg-header); border-bottom:1px solid var(--border);flex-shrink:0; display:flex; align-items:center; gap:8px; flex-wrap:wrap;",this.controls.innerHTML='',this.element.appendChild(this.controls),this.svgContainer=document.createElement("div"),this.svgContainer.style.cssText="flex:1; overflow:hidden; position:relative; cursor:grab; background:var(--bg-main);",this.element.appendChild(this.svgContainer),this.container.element.appendChild(this.element),this.controls.querySelector("#schematic-refresh").addEventListener("click",()=>this.refresh()),this.controls.querySelector("#schematic-fit").addEventListener("click",()=>this.fitView()),this.controls.querySelector("#schematic-zoom-in").addEventListener("click",()=>this._zoomStep(1.5)),this.controls.querySelector("#schematic-zoom-out").addEventListener("click",()=>this._zoomStep(1/1.5)),this.controls.querySelector("#schematic-select").addEventListener("click",()=>this._toggleSelectMode()),this.controls.querySelector("#schematic-zoom-to").addEventListener("click",()=>this._zoomToSelected()),this.controls.querySelector("#schematic-save-svg").addEventListener("click",()=>this._exportSvg()),this.controls.querySelector("#schematic-save-png").addEventListener("click",()=>this._exportPng()),this.controls.querySelector("#schematic-copy").addEventListener("click",()=>this._copyImage()),this.appState.schematicWidget=this,this.netlistsvg=null,this.skin=null,this._svgEl=null,this._scale=1,this._panX=0,this._panY=0,this._selectMode=!1,this._selectedCell=null,this._svgIdToInstName=new Map,this._setupPanZoom(),this.initNetlistSVG()}_setupPanZoom(){let s=this.svgContainer,h=!1,p,m,_,S;s.addEventListener("wheel",y=>{if(!this._svgEl)return;y.preventDefault();let I=y.deltaY<0?1.2:1/1.2,N=s.getBoundingClientRect(),B=y.clientX-N.left,P=y.clientY-N.top;this._panX=B+(this._panX-B)*I,this._panY=P+(this._panY-P)*I,this._scale*=I,this._applyTransform()},{passive:!1}),s.addEventListener("mousedown",y=>{if(!(!this._svgEl||y.button!==0)){if(this._selectMode){this._handleSelectClick(y);return}h=!0,p=y.clientX,m=y.clientY,_=this._panX,S=this._panY,s.style.cursor="grabbing",y.preventDefault()}}),window.addEventListener("mousemove",y=>{h&&(this._panX=_+(y.clientX-p),this._panY=S+(y.clientY-m),this._applyTransform())}),window.addEventListener("mouseup",()=>{h&&(h=!1,s.style.cursor=this._selectMode?"default":"grab")})}_zoomStep(s){if(!this._svgEl)return;let h=this.svgContainer.getBoundingClientRect(),p=h.width/2,m=h.height/2;this._panX=p+(this._panX-p)*s,this._panY=m+(this._panY-m)*s,this._scale*=s,this._applyTransform()}_toggleSelectMode(){this._selectMode=!this._selectMode;let s=this.controls.querySelector("#schematic-select");this._selectMode?(s.style.background="var(--accent)",s.style.color="var(--fg-white)",this.svgContainer.style.cursor="default"):(s.style.background="",s.style.color="",this.svgContainer.style.cursor="grab",this._clearCellHighlight())}_handleSelectClick(s){if(!this._svgEl)return;let h=s.target,p=null;for(;h&&h!==this._svgEl;){if(h.tagName==="g"&&h.id&&this._svgIdToInstName.has(h.id)){p=h;break}h=h.parentElement}if(this._clearCellHighlight(),!p)return;let m=this._svgIdToInstName.get(p.id);try{let _=p.getBBox(),S=3,y=document.createElementNS("http://www.w3.org/2000/svg","rect");y.setAttribute("x",_.x-S),y.setAttribute("y",_.y-S),y.setAttribute("width",_.width+S*2),y.setAttribute("height",_.height+S*2),y.setAttribute("fill","none"),y.setAttribute("stroke","#e05a00"),y.setAttribute("stroke-width","1.5"),y.setAttribute("rx","3"),y.id="_schematic_highlight",p.appendChild(y),this._selectedCell=p}catch{}this.controls.querySelector("#schematic-zoom-to").disabled=!1,this.setStatus(`Selected: ${m}`),this._fetchInspect(m)}_fetchInspect(s){let h=this.appState.websocketManager;if(!h)return;console.log("[Schematic] inspect:",s);let p=bg(this.appState);h.request({type:"schematic_inspect",inst_name:s,use_dbu:this.appState.showDbu}).then(m=>{D0(this.appState,p)&&(this.appState.updateInspector&&this.appState.updateInspector(m),this.appState.focusComponent&&this.appState.focusComponent("Inspector"),this.appState.refreshOverlay&&this.appState.refreshOverlay())}).catch(m=>{console.error("schematic_inspect failed:",m),this.setStatus(`Inspect error: ${m}`)})}_clearCellHighlight(){if(this._svgEl){let s=this._svgEl.querySelector("#_schematic_highlight");s&&s.remove()}this._selectedCell=null,this.controls.querySelector("#schematic-zoom-to").disabled=!0}_zoomToSelected(){if(!this._selectedCell||!this._svgEl)return;let s=this.svgContainer.getBoundingClientRect(),h=this._selectedCell.getBoundingClientRect(),p=(h.left-s.left-this._panX)/this._scale,m=(h.top-s.top-this._panY)/this._scale,_=h.width/this._scale,S=h.height/this._scale,y=Math.min(s.width/_,s.height/S)*.9;this._scale=y,this._panX=s.width/2-(p+_/2)*y,this._panY=s.height/2-(m+S/2)*y,this._applyTransform()}_applyTransform(){this._svgEl&&(this._svgEl.style.transform=`translate(${this._panX}px, ${this._panY}px) scale(${this._scale})`,this._svgEl.style.transformOrigin="0 0")}fitView(){if(!this._svgEl)return;let s=this.svgContainer.getBoundingClientRect();if(s.width===0||s.height===0)return;let h=this._svgEl.viewBox&&this._svgEl.viewBox.baseVal,p=h&&h.width||this._svgEl.clientWidth||1,m=h&&h.height||this._svgEl.clientHeight||1;this._scale=Math.min(s.width/p,s.height/m)*.95,this._panX=(s.width-p*this._scale)/2,this._panY=(s.height-m*this._scale)/2,this._applyTransform()}initNetlistSVG(){this.netlistsvg=globalThis.netlistsvg,this.skin=globalThis.openroadSkin,this._netlistsvgReady=!!(this.netlistsvg&&this.skin),this._netlistsvgReady&&console.log("NetlistSVG ready."),this.setStatus(this._unreadyStatus()??tQt)}_unreadyStatus(){return this._netlistsvgReady?null:Sc(this.appState)?"The schematic is not available in saved reports.":"Init error: netlistsvg or its skin is missing from the page."}syncCone(s={}){let h=this.controls.querySelector("#schematic-fanin-depth"),p=this.controls.querySelector("#schematic-fanout-depth"),m=(_,S,y)=>{if(!_)return;let I=parseInt(_.max,10)||10;S===!1?_.value=0:y!==void 0&&(_.value=y>0?Math.min(y,I):I)};m(h,s.fanin,s.fanin_depth),m(p,s.fanout,s.fanout_depth),this.refresh(),this.appState.focusComponent&&this.appState.focusComponent("SchematicWidget")}refresh(){if(!this._netlistsvgReady){this.setStatus(this._unreadyStatus());return}let s=this.appState.selectedInstanceName;if(!s){this.setStatus(tQt);return}let h=this.appState.websocketManager;if(!h){this.setStatus("Waiting for server connection\u2026");return}this.setStatus(`Loading schematic for ${s}\u2026`);let p=parseInt(this.controls.querySelector("#schematic-fanin-depth").value,10),m=parseInt(this.controls.querySelector("#schematic-fanout-depth").value,10),_=isNaN(p)?1:p,S=isNaN(m)?1:m;h.readyPromise.then(()=>{h.request({type:"schematic_cone",inst_name:s,fanin_depth:_,fanout_depth:S}).then(y=>{let I=y.modules&&y.modules.top&&y.modules.top.cells;if(!I||Object.keys(I).length===0){this.setStatus("No cells found for selected instance.");return}this.renderNetlist(y)}).catch(y=>{this.setStatus(`Error: ${y}`)})})}setStatus(s){this.controls.querySelector("#schematic-status").textContent=s}_exportSvg(){if(!this._svgEl){this.setStatus("No schematic to export.");return}let s=j2t(this._svgEl);kJt(new Blob([s],{type:"image/svg+xml;charset=utf-8"}),"schematic.svg")}async _exportPng(){if(!this._svgEl){this.setStatus("No schematic to export.");return}try{let s=await H2t(this._svgEl,2);lk(s,"schematic.png")}catch{this.setStatus("PNG export failed.")}}async _copyImage(){if(!this._svgEl){this.setStatus("No schematic to export.");return}try{let s=await H2t(this._svgEl,2),h=await nnt(s);this.setStatus(h?"Schematic copied to clipboard.":"Clipboard not available.")}catch{this.setStatus("Copy failed.")}}async renderNetlist(s){try{this.setStatus("Rendering\u2026"),typeof window<"u"&&(window.__lastSchematic=s);let h=r5e(s),p,m=this.netlistsvg.render(this.skin,h);if(m&&typeof m.then=="function"?p=await m:p=await new Promise((y,I)=>{this.netlistsvg.render(this.skin,h,(N,B)=>{N?I(N):y(B)})}),typeof p!="string"||!p.includes("requestAnimationFrame(()=>this.fitView()));let S=Object.keys(s.modules.top.cells).length;this.setStatus(`${S} cell${S!==1?"s":""}`)}catch(h){console.error("NetlistSVG render failed:",h),this.setStatus(`Render error: ${h.message||h}`)}}_applyPinLabels(s){if(!this._svgEl)return;let h="http://www.w3.org/2000/svg",p="https://github.com/nturley/netlistsvg",m=s.modules&&s.modules.top&&s.modules.top.cells||{},_=(S,y)=>S.getAttribute("s:"+y)??S.getAttributeNS(p,y);for(let[S,y]of Object.entries(m)){let I=y.port_labels;if(!I)continue;let N=this._svgEl.querySelector("#"+CSS.escape("cell_"+S))||this._svgEl.querySelector("#"+CSS.escape(S));if(!N)continue;let B=y.port_directions||{};for(let P of Array.from(N.children)){if(P.tagName!=="g")continue;let U=_(P,"pid");if(!U||!(U in I))continue;let j=parseFloat(_(P,"x")),V=parseFloat(_(P,"y"));if(!isFinite(j)||!isFinite(V))continue;let et=document.createElementNS(h,"text");B[U]==="input"?(et.setAttribute("class","inputPortLabel"),et.setAttribute("x",j-3)):et.setAttribute("x",j+4),et.setAttribute("y",V-4),et.setAttribute("style","font-size:5px"),et.setAttribute("pointer-events","none"),et.textContent=I[U],N.appendChild(et)}}}_scopeSkinStyles(){if(!this._svgEl)return;let s=".schematic-widget",h=p=>{for(let m of p)m.selectorText?m.selectorText=t5e(m.selectorText,s):m.cssRules&&h(m.cssRules)};for(let p of this._svgEl.querySelectorAll("style")){let m=p.sheet;if(m)try{h(m.cssRules)}catch{continue}}}};function t5e(d,s){return d.split(",").map(h=>{let p=h.trim();if(!p)return"";let m=p.charAt(s.length);return p.startsWith(s)&&(m===""||!/[\w-]/.test(m))?p:`${s} ${p}`}).filter(Boolean).join(", ")}var eQt={and:"$_AND_",nand:"$_NAND_",or:"$_OR_",nor:"$_NOR_",xor:"$_XOR_",xnor:"$_XNOR_",not:"$_NOT_",buf:"$_BUF_"},e5e=new Set(["aoi21","aoi22","aoi211","aoi221","aoi222","aoi33","oai21","oai22","oai211","oai221","oai222","oai33"]),n5e=new Set(["and3","and4","or3","or4","nand3","nand4","nor3","nor4"]),nQt=["A","B","C","D","E","F"];function i5e(d){let s=d&&d.gate_kind;if(!s)return d;let h=d.port_directions||{},p=null,m=[];for(let[P,U]of Object.entries(h))U==="output"&&p===null?p=P:U==="input"&&m.push(P);let _,S={};if(s==="aoi"||s==="oai"){let P=Array.isArray(d.gate_terms)?d.gate_terms:[];if(!P.length)return d;let U=P.map(et=>et.length);if(_=s+U.slice().sort((et,Q)=>Q-et).join(""),!e5e.has(_))return d;let j=P.map(et=>et.slice()).sort((et,Q)=>et.length-Q.length),V=0;for(let et of j)for(let Q of et)S[Q]=nQt[V]||"I"+V,V++}else{let P=m.length;if(s==="not"||s==="buf")_=eQt[s];else if(P<=2)_=eQt[s];else if(_=s+P,!n5e.has(_))return d;if(!_)return d;m.forEach((U,j)=>{S[U]=nQt[j]||"I"+j})}p!==null&&(S[p]="Y");let y=d.connections||{},I={},N={};for(let[P,U]of Object.entries(y))S[P]&&(I[S[P]]=U);for(let[P,U]of Object.entries(h))S[P]&&(N[S[P]]=U);let B={};for(let[P,U]of Object.entries(S))B[U]=P;return{...d,type:_,connections:I,port_directions:N,port_labels:B}}function r5e(d){let s=d&&d.modules&&d.modules.top;if(!s||!s.cells)return d;let h={};for(let[p,m]of Object.entries(s.cells))h[p]=i5e(m);return{...d,modules:{...d.modules,top:{...s,cells:h}}}}var vnt=class{constructor(s,h,p){this._app=s,this._redrawAllLayers=h,this._refreshOverlay=p||h,this._categories=[],this._activeCategory="",this._markerTree=null,this._expandedNodes=new Set,this._build(),this._app.websocketManager.readyPromise.then(()=>this.refresh())}_build(){let s=document.createElement("div");s.className="drc-widget";let h=document.createElement("div");h.className="drc-toolbar",this._categorySelect=document.createElement("select"),this._categorySelect.className="drc-category-select",h.appendChild(this._categorySelect),this._loadBtn=document.createElement("button"),this._loadBtn.className="or-btn or-btn-sm",this._loadBtn.textContent="Load...",h.appendChild(this._loadBtn),s.appendChild(h),this._infoBar=document.createElement("div"),this._infoBar.className="drc-info-bar",s.appendChild(this._infoBar),this._treeContainer=document.createElement("div"),this._treeContainer.className="drc-tree-container",s.appendChild(this._treeContainer),this.element=s,this._bindEvents()}_bindEvents(){this._categorySelect.addEventListener("change",()=>{this._activeCategory=this._categorySelect.value,this._loadMarkers()}),this._loadBtn.addEventListener("click",()=>{this._showLoadDialog()})}_loadCategories(){return this._app.websocketManager.request({type:"drc_categories"}).then(s=>{this._categories=s.categories||[],this._renderCategorySelect()}).catch(s=>{console.error("Failed to load DRC categories:",s)})}refresh(){this._loadCategories().then(()=>{!this._activeCategory&&this._categories.length>0&&(this._activeCategory=this._categories[0].name,this._categorySelect.value=this._activeCategory),this._activeCategory&&this._loadMarkers()})}_renderCategorySelect(){let s=this._categorySelect,h=s.value;s.innerHTML="";let p=document.createElement("option");p.value="",p.textContent="(none)",s.appendChild(p);for(let m of this._categories){let _=document.createElement("option");_.value=m.name,_.textContent=`${m.name} (${m.count})`,s.appendChild(_)}this._activeCategory&&this._categories.some(m=>m.name===this._activeCategory)?s.value=this._activeCategory:h&&this._categories.some(m=>m.name===h)?(s.value=h,this._activeCategory=h):this._activeCategory=""}_loadMarkers(){if(!this._activeCategory){this._markerTree=null,this._treeContainer.innerHTML="",this._infoBar.textContent="",this._refreshOverlay();return}this._treeContainer.innerHTML='
Loading...
',this._app.websocketManager.request({type:"drc_markers",category:this._activeCategory}).then(s=>{this._markerTree=s,this._renderTree(),this._refreshOverlay()}).catch(s=>{this._treeContainer.innerHTML="";let h=document.createElement("div");h.className="drc-error",h.textContent=`Error: ${s}`,this._treeContainer.appendChild(h),console.error("Failed to load DRC markers:",s)})}_renderTree(){if(this._treeContainer.innerHTML="",!this._markerTree)return;if(this._markerTree.error){let S=document.createElement("div");S.className="drc-error",S.textContent=this._markerTree.error,this._treeContainer.appendChild(S);return}let s=this._markerTree.total_count||0;this._infoBar.textContent=`${s} total violation${s!==1?"s":""}`;let h=this._markerTree.name||this._activeCategory,p=this._markerTree.subcategories||[],m=this._markerTree.markers||[];if(p.length===0&&m.length===0){this._treeContainer.innerHTML='
No violations
';return}let _=document.createElement("div");_.className="drc-tree",m.length>0&&_.appendChild(this._buildCategoryNode({name:h||"Markers",count:m.length,markers:m},[]));for(let S of p)_.appendChild(this._buildCategoryNode(S,[h]));this._treeContainer.appendChild(_)}_buildCategoryNode(s,h=[]){let p=[...h,s.name],m=document.createElement("div");m.className="drc-tree-node";let _=document.createElement("div");_.className="drc-tree-header";let S=document.createElement("span");S.className="drc-toggle";let y=s.subcategories&&s.subcategories.length>0||s.markers&&s.markers.length>0,I=JSON.stringify(p),N=this._expandedNodes.has(I);S.textContent=y?N?"\u25BC":"\u25B6":" ",_.appendChild(S);let B=document.createElement("input");B.type="checkbox",B.checked=this._allMarkersVisible(s),B.className="drc-visibility-check",B.addEventListener("change",V=>{V.stopPropagation(),this._toggleCategoryVisibility(s,B.checked,p)}),_.appendChild(B);let P=document.createElement("span");P.className="drc-category-label",P.textContent=s.name,_.appendChild(P);let U=document.createElement("span");U.className="drc-count",U.textContent=`${s.count} markers`,_.appendChild(U),m.appendChild(_);let j=document.createElement("div");if(j.className="drc-tree-children",j.style.display=N?"":"none",s.subcategories)for(let V of s.subcategories)j.appendChild(this._buildCategoryNode(V,p));if(s.markers)for(let V of s.markers)j.appendChild(this._buildMarkerNode(V));return m.appendChild(j),y&&(_.addEventListener("click",V=>{if(V.target===B)return;let et=j.style.display!=="none";j.style.display=et?"none":"",S.textContent=et?"\u25B6":"\u25BC",et?this._expandedNodes.delete(I):this._expandedNodes.add(I)}),_.style.cursor="pointer"),m}_buildMarkerNode(s){let h=document.createElement("div");h.className="drc-marker-row",h.dataset.markerId=s.id,s.visited||h.classList.add("drc-unvisited");let p=document.createElement("input");p.type="checkbox",p.checked=s.visible,p.className="drc-visibility-check",p.addEventListener("change",S=>{S.stopPropagation(),s.visible=p.checked,this._updateMarker(s.id,"visible",p.checked)}),h.appendChild(p);let m=document.createElement("span");m.className="drc-marker-index",m.textContent=s.index,h.appendChild(m);let _=document.createElement("span");if(_.className="drc-marker-name",_.textContent=s.name,s.layer&&(_.title=`Layer: ${s.layer}`),h.appendChild(_),s.layer){let S=document.createElement("span");S.className="drc-layer-badge",S.textContent=s.layer,h.appendChild(S)}return h.addEventListener("click",S=>{S.target!==p&&this._highlightMarker(s)}),h.addEventListener("dblclick",S=>{S.target!==p&&this._highlightMarker(s,!0)}),h}highlightMarkerById(s,h=!1){let p=this._findMarkerById(s);p&&this._highlightMarker(p,h)}_findMarkerById(s){let h=p=>{if(!p)return null;if(p.markers){for(let m of p.markers)if(m.id===s)return m}if(p.subcategories)for(let m of p.subcategories){let _=h(m);if(_)return _}return null};return h(this._markerTree)}_highlightMarker(s,h=!1){this._app.websocketManager.request({type:"drc_highlight",marker_id:s.id,open_inspector:h}).then(p=>{if(p.ok&&p.bbox){s.visited=!0;let m=this._treeContainer.querySelector(`.drc-marker-row[data-marker-id="${s.id}"]`);m&&m.classList.remove("drc-unvisited"),this._zoomToBBox(p.bbox),this._refreshOverlay(),h&&(p.select_id!=null&&this._app.navigateInspector&&this._app.navigateInspector(p.select_id),this._app.focusComponent&&this._app.focusComponent("Inspector"))}}).catch(p=>{console.error("Failed to highlight DRC marker:",p)})}_zoomToBBox(s){if(!this._app.designScale||!this._app.map)return;let[h,p,m,_]=s,S=m-h,y=_-p,N=10*this._app.getDbuPerMicron(),B=2*Math.max(S,y),P=Math.min(N,B);this._app.map.fitBounds(Vf(h-P,p-P,m+P,_+P,this._app.designScale,this._app.designMaxDXDY,this._app.designOriginX,this._app.designOriginY))}_updateMarker(s,h,p){this._app.websocketManager.request({type:"drc_update_marker",marker_id:s,field:h,value:!!p}).then(()=>{this._refreshOverlay(),h==="visible"&&(this._update3DHighlights(),p&&this._flashHighlight())}).catch(m=>{console.error("Failed to update DRC marker:",m)})}_flashHighlight(){let s=this._app.map?.getContainer();s&&(s.classList.remove("drc-flashing"),s.offsetWidth,s.classList.add("drc-flashing"),s.addEventListener("animationend",()=>{s.classList.remove("drc-flashing")},{once:!0}))}_update3DHighlights(){let s=this._app.threeDViewerWidget;if(!s)return;let h=[];this._collectVisibleMarkers(this._markerTree,h),h.length>0?s.highlightDRC(h):s.clearHighlightDRC()}_collectVisibleMarkers(s,h){if(s){if(s.markers)for(let p of s.markers)p.visible&&h.push(p);if(s.subcategories)for(let p of s.subcategories)this._collectVisibleMarkers(p,h)}}_setMarkersVisible(s,h){if(s){if(s.markers)for(let p of s.markers)p.visible=h;if(s.subcategories)for(let p of s.subcategories)this._setMarkersVisible(p,h)}}_snapshotMarkerVisibility(s,h=new Map){if(!s)return h;if(s.markers)for(let p of s.markers)h.set(p.id,p.visible);if(s.subcategories)for(let p of s.subcategories)this._snapshotMarkerVisibility(p,h);return h}_restoreMarkerVisibility(s,h){if(s){if(s.markers)for(let p of s.markers)h.has(p.id)&&(p.visible=h.get(p.id));if(s.subcategories)for(let p of s.subcategories)this._restoreMarkerVisibility(p,h)}}_allMarkersVisible(s){if(s.markers){for(let h of s.markers)if(!h.visible)return!1}if(s.subcategories){for(let h of s.subcategories)if(!this._allMarkersVisible(h))return!1}return!0}_toggleCategoryVisibility(s,h,p){let m=this._snapshotMarkerVisibility(s);this._setMarkersVisible(s,h),this._renderTree(),this._app.websocketManager.request({type:"drc_update_category_visibility",category:s.name,path:p||[s.name],visible:!!h}).then(()=>{this._refreshOverlay(),this._update3DHighlights(),h&&this._flashHighlight()}).catch(_=>{console.error("Failed to update category visibility:",_),this._restoreMarkerVisibility(s,m),this._renderTree()})}_showLoadDialog(){new Y2t(this._app,h=>{this._activeCategory=h,this._loadCategories().then(()=>{this._categorySelect.value=this._activeCategory,this._loadMarkers()})}).open()}selectCategory(s){this._activeCategory=s,this._categorySelect.value=s,this._loadMarkers()}},Y2t=class{constructor(s,h){this._app=s,this._onLoaded=h,this._currentPath="",this._disposers=[],this._closed=!1}open(){this._overlay=document.createElement("div"),this._overlay.className="modal-overlay",this._overlay.innerHTML=` +
`,document.body.appendChild(r);function c(d){d.key==="Escape"&&u()}let u=()=>{r.remove(),document.removeEventListener("keydown",c)};return r.addEventListener("click",d=>{d.target===r&&u()}),document.addEventListener("keydown",c),{overlay:r,body:r.querySelector(".modal-body"),errorDiv:r.querySelector(".modal-error"),buttons:r.querySelector(".modal-buttons"),close:u}}function g2(s,n){s.textContent=n,s.style.display=n?"":"none"}function AO(s,n,{primary:r=!1}={}){let c=document.createElement("button");return c.textContent=n,c.className="or-btn"+(r?" or-btn-primary":""),s.appendChild(c),c}function sde(s){return"{"+String(s)+"}"}function T3t(s){let n=M3t("Global Connect","gc-dialog"),r=document.createElement("div");r.className="gc-table",n.body.appendChild(r);let c=document.createElement("div");c.className="gc-form";let u=document.createElement("input");u.placeholder="Instance pattern (regex)",u.value=".*";let d=document.createElement("input");d.placeholder="Pin pattern (regex)";let b=document.createElement("select"),w=document.createElement("select"),_=document.createElement("span");_.innerHTML='',c.append(ST("Instance",u),ST("Pin",d),ST("Net",b),ST("Region",w),_);let x=AO(c,"Add rule");n.body.appendChild(c);function T(){let D=d.value.trim()!==""&&b.value!=="";for(let F of[u,d])try{new RegExp(F.value),F.classList.remove("gc-invalid")}catch{F.classList.add("gc-invalid"),D=!1}x.disabled=!D}u.addEventListener("input",T),d.addEventListener("input",T),b.addEventListener("change",T);function M(){s.websocketManager.request({type:"global_connect_info"}).then(D=>{r.innerHTML='
InstancePinNetRegion
',(D.rules||[]).forEach(F=>{let O=document.createElement("div");O.className="gc-row",O.innerHTML=`${oH(F.inst)}${oH(F.pin)}${oH(F.net)}${oH(F.region||"All")}`;let z=document.createElement("button");z.className="or-btn or-btn-sm or-btn-icon",z.textContent="\u2715",z.title="Delete rule",z.addEventListener("click",()=>{s.websocketManager.request({type:"global_connect_delete",inst:F.inst,pin:F.pin,net:F.net,region:F.region||""}).then(M).catch(Z=>g2(n.errorDiv,String(Z)))}),O.appendChild(z),r.appendChild(O)}),eDe(b,D.nets||[]),eDe(w,["All",...D.regions||[]]),T()}).catch(D=>g2(n.errorDiv,String(D)))}x.addEventListener("click",()=>{let D=c.querySelector('input[name="gc-pg"]:checked').value,F=`add_global_connection -net ${sde(b.value)} -inst_pattern ${sde(u.value||".*")} -pin_pattern ${sde(d.value)} -${D}`;w.value&&w.value!=="All"&&(F+=` -region ${sde(w.value)}`),S3t(s,F,n.errorDiv,"Rule added.",M)}),AO(n.buttons,"Apply (force)").addEventListener("click",()=>{s.websocketManager.request({type:"global_connect_apply",force:!0}).then(D=>{if(!D.had_rules){g2(n.errorDiv,"No global-connect rules defined \u2014 add a rule first.");return}g2(n.errorDiv,`Connected ${D.connected} pin(s).`),s.scheduleRedrawAllLayers&&s.scheduleRedrawAllLayers(),M()}).catch(D=>g2(n.errorDiv,D.message||String(D)))}),AO(n.buttons,"Clear all").addEventListener("click",()=>S3t(s,"clear_global_connect",n.errorDiv,"Rules cleared.",M)),AO(n.buttons,"Close").addEventListener("click",n.close),M()}function S3t(s,n,r,c,u){s.websocketManager.request({type:"tcl_eval",cmd:n}).then(d=>{if(d.is_error){g2(r,d.output||d.result||"Command failed");return}g2(r,c||""),s.scheduleRedrawAllLayers&&s.scheduleRedrawAllLayers(),u&&u()}).catch(d=>g2(r,d.message||String(d)))}function C3t(s,n){let r=M3t(`Insert Buffer \u2014 ${oH(n)}`,"buf-dialog"),c=AO(r.buttons,"Insert",{primary:!0});c.disabled=!0,AO(r.buttons,"Cancel").addEventListener("click",r.close),s.websocketManager.request({type:"buffer_info",net:n}).then(d=>{if(!d.can_buffer){r.body.textContent=d.error||"This net has multiple drivers and cannot be buffered.";return}qdn(s,r,n,d,c)}).catch(d=>{r.body.textContent=String(d)})}function qdn(s,n,r,c,u){let d=document.createElement("div");d.className="buf-pins";let b=c.drivers||[],w=c.loads||[],_=new Set;function x(){d.innerHTML="";let D=(F,O)=>{let z=document.createElement("label");z.className="buf-pin";let Z=document.createElement("input");Z.type="checkbox",Z.checked=_.has(F.id),Z.addEventListener("change",()=>{if(Z.checked){if(O)_.clear();else for(let H of b)_.delete(H.id);_.add(F.id)}else _.delete(F.id);x(),I()}),z.append(Z,document.createTextNode(" "+F.label)),d.appendChild(z)};b.forEach(F=>D(F,!0)),w.forEach(F=>D(F,!1))}b.length&&_.add(b[0].id),x();let T=document.createElement("select");eDe(T,c.masters||[]);let M=document.createElement("input");M.placeholder="Optional: new buffer name";let L=document.createElement("input");L.placeholder="Optional: new net name",n.body.append(ST("Pins to buffer",d),ST("Buffer master",T),ST("Buffer name",M),ST("Net name",L));function I(){u.disabled=_.size===0||!T.value}T.addEventListener("change",I),I(),u.addEventListener("click",()=>{let D=new Set(b.map(z=>z.id)),F=[..._],O=F.some(z=>D.has(z))?"driver":"loads";s.websocketManager.request({type:"insert_buffer",net:r,mode:O,pins:F,master:T.value,buf_name:M.value.trim(),net_name:L.value.trim()}).then(z=>{if(z.is_error||z.ok===!1){g2(n.errorDiv,z.error||z.result||"Insertion failed");return}n.close(),z.inst&&(s.selectedInstanceName=z.inst),s.scheduleRedrawAllLayers&&s.scheduleRedrawAllLayers()}).catch(z=>g2(n.errorDiv,z.message||String(z)))})}function ST(s,n){let r=document.createElement("label");r.className="edit-field";let c=document.createElement("span");return c.textContent=s,r.append(c,n),r}function eDe(s,n){let r=s.value;s.innerHTML="";for(let c of n){let u=document.createElement("option");u.value=c,u.textContent=c,s.appendChild(u)}n.includes(r)&&(s.value=r)}function oH(s){return String(s??"").replace(/&/g,"&").replace(//g,">")}var A3t="#00ffff",Xdn="#ffff00",P3t="#ffffff",Ydn=4,pk=0,tDe=1,aH=2,ode=class{constructor(n,r,c,u){this._app=n,this._visibility=r,this._updateInspector=c,this._focusComponent=u,this._state=pk,this._rulers=[],this._nextId=0,this._pt0=null,this._selectedRulerId=null,this._ctrlHeld=!1,this._shiftHeld=!1,this._snapTimer=null,this._lastSnapResult=null,this._snapShapes=null,this._preview=null,n.view?.on("zoom",()=>this._renderRulerShapes())}isActive(){return this._state!==pk}updateVisibility(){this._renderAll(),this._drawTransient()}_shown(){return this._visibility.rulers!==!1}toggleRulerMode(){this._state===pk?this._enterFirstPoint():this.cancelRulerBuild()}cancelRulerBuild(){this._state=pk,this._pt0=null,this._lastSnapResult=null,this._clearTransient(),this._setCursor(!1)}clearAllRulers(){this._rulers=[],this._selectedRulerId=null,this._renderAll(),this._clearTransient(),this._state!==pk&&this.cancelRulerBuild()}_enterFirstPoint(){this._state=tDe,this._pt0=null,this._lastSnapResult=null,this._setCursor(!0)}_enterMeasuring(n){this._state=aH,this._pt0=n}_toDbu(n){return Pv(n[0],n[1],this._app.designScale,this._app.designOriginX,this._app.designOriginY)}_toWorld(n,r){return Av(n,r,this._app.designScale,this._app.designOriginX,this._app.designOriginY)}handleMouseMove(n,r){if(this._state===pk)return;this._ctrlHeld=r.ctrlKey||r.metaKey,this._shiftHeld=r.shiftKey;let c=this._toDbu(n);this._snapTimer&&clearTimeout(this._snapTimer),this._snapTimer=setTimeout(()=>{this._requestSnap(c.dbuX,c.dbuY)},50)}handleMapClick(n,r){if(this._state===pk)return;this._ctrlHeld=r.ctrlKey||r.metaKey,this._shiftHeld=r.shiftKey;let c=this._toDbu(n),u=this._getSnappedPoint(c.dbuX,c.dbuY);this._state===tDe?this._enterMeasuring(u):this._state===aH&&(this._createRuler(this._pt0,u),this._state=tDe,this._pt0=null,this._clearTransient(),this._lastSnapResult=null)}async _requestSnap(n,r){let c=this._app;if(!c.websocketManager||!c.designScale)return;if(this._ctrlHeld){this._lastSnapResult=null,this._snapShapes=null,this._updatePreview(n,r);return}let d=c.techData?.dbu_per_micron||1e3,b=c.view.getZoom(),w=Math.pow(2,Math.max(0,b)),_=1/(c.designScale*w),x=Math.max(Math.round(10*_),10),T=!0,M=!0;if(this._shiftHeld)T=!0,M=!0;else if(this._state===aH&&this._pt0){let I=Math.abs(n-this._pt0.x),D=Math.abs(r-this._pt0.y);I>D?(T=!1,M=!0):D>I&&(T=!0,M=!1)}let L={};for(let[I,D]of Object.entries(this._visibility))L[I]=!!D;try{let I=await c.websocketManager.request({type:"snap",dbu_x:n,dbu_y:r,radius:d,point_threshold:x,horizontal:!!T,vertical:!!M,visible_layers:[...c.visibleLayerNames],...L});this._lastSnapResult=I,this._updateSnapIndicator(I),this._updatePreview(n,r)}catch{this._lastSnapResult=null,this._clearSnap()}}_getSnappedPoint(n,r){if(this._ctrlHeld)return{x:n,y:r};let c=this._lastSnapResult,u;if(c?.found&&c.is_point)u={x:c.edge[0][0],y:c.edge[0][1]};else if(c?.found){let d=c.edge;d[0][1]===d[1][1]?u={x:n,y:d[0][1]}:u={x:d[0][0],y:r}}else u={x:n,y:r};if(!this._shiftHeld&&this._state===aH&&this._pt0){let d=Math.abs(u.x-this._pt0.x),b=Math.abs(u.y-this._pt0.y);dthis._toWorld(u.x,u.y))}}_rulerShapes(n){let r=n.id===this._selectedRulerId,c=Z1(r?Xdn:A3t),{joinPt:u,points:d}=this._rulerPath(n),b=[{kind:"path",points:d,stroke:c,width:2}],w=this._app.view.getZoom(),_=Math.pow(2,Math.max(0,w)),T=8*(1/(this._app.designScale*_)),M=(L,I,D)=>{let F=Math.sqrt(I*I+D*D);if(F===0)return;let O=-D/F,z=I/F;b.push({kind:"path",stroke:c,width:2,points:[this._toWorld(L.x+O*T,L.y+z*T),this._toWorld(L.x-O*T,L.y-z*T)]})};if(u)M(n.pt0,u.x-n.pt0.x,u.y-n.pt0.y),M(n.pt1,n.pt1.x-u.x,n.pt1.y-u.y);else{let L=n.pt1.x-n.pt0.x,I=n.pt1.y-n.pt0.y;M(n.pt0,L,I),M(n.pt1,L,I)}return b}_renderAll(){this._renderRulerShapes(),this._renderRulerLabels()}_renderRulerShapes(){let n=this._app.view;!n||!this._app.designScale||n.setOverlay("rulers",this._shown()?this._rulers.flatMap(r=>this._rulerShapes(r)):null,{order:mp.ruler})}_renderRulerLabels(){let n=this._app.view;if(!(!n||!this._app.designScale)&&(n.clearMarkers("ruler-labels"),!!this._shown()))for(let r of this._rulers){let{joinPt:c,points:u}=this._rulerPath(r),d=c?u[1]:[(u[0][0]+u[1][0])/2,(u[0][1]+u[1][1])/2],b=this._computeDistance(r.pt0,r.pt1,r.euclidian);n.addMarker("ruler-labels",r.id,d,this._labelElement(this._formatDistance(b)))}}handleRulerClick(n){let r=this._app.view;if(!r||!this._shown()||this._rulers.length===0)return!1;let c=r.project(n);for(let u of this._rulers){let d=this._rulerPath(u).points.map(b=>r.project(b));for(let b=0;b+1x.id===n);if(!r)return;Pm(this._app);let c=Math.abs(r.pt1.x-r.pt0.x),u=Math.abs(r.pt1.y-r.pt0.y),d=r.euclidian?Math.sqrt(c*c+u*u):c+u,b=x=>this._app.formatDbu(x,!0),w=x=>this._app.parseDbu(x),_={type:"Ruler",name:r.name,bbox:[Math.min(r.pt0.x,r.pt1.x),Math.min(r.pt0.y,r.pt1.y),Math.max(r.pt0.x,r.pt1.x),Math.max(r.pt0.y,r.pt1.y)],properties:[{name:"Name",value:r.name,editable:!0},{name:"Label",value:r.label||"",editable:!0},{name:"Point 0 - x",value:b(r.pt0.x),editable:!0},{name:"Point 0 - y",value:b(r.pt0.y),editable:!0},{name:"Point 1 - x",value:b(r.pt1.x),editable:!0},{name:"Point 1 - y",value:b(r.pt1.y),editable:!0},{name:"Delta x",value:b(c)},{name:"Delta y",value:b(u)},{name:"Length",value:b(d)},{name:"Euclidian",value:r.euclidian?"True":"False",editable:!0,editor:{type:"bool"}}],onPropertyChange:(x,T)=>{switch(x){case"Name":r.name=T;break;case"Label":r.label=T;break;case"Point 0 - x":{let M=w(T);M!==null&&(r.pt0.x=M);break}case"Point 0 - y":{let M=w(T);M!==null&&(r.pt0.y=M);break}case"Point 1 - x":{let M=w(T);M!==null&&(r.pt1.x=M);break}case"Point 1 - y":{let M=w(T);M!==null&&(r.pt1.y=M);break}case"Euclidian":r.euclidian=T.trim().toLowerCase()==="true";break}this._renderAll(),this._selectRuler(r.id)}};this._updateInspector(_),this._focusComponent("Inspector"),requestAnimationFrame(()=>{let x=this._app.inspectorEl?.querySelector(".inspector-toolbar");if(!x)return;let T=document.createElement("button");T.className="or-btn or-btn-icon",T.title="Delete ruler",T.innerHTML='',T.addEventListener("click",()=>{this.deleteRuler(n)}),x.appendChild(T)})}deleteRuler(n){let r=this._rulers.findIndex(c=>c.id===n);r!==-1&&(this._rulers.splice(r,1),this._renderAll(),this._selectedRulerId===n&&(this._selectedRulerId=null,this._updateInspector(null)))}_getManhattanJoinPt(n,r){return{x:r.x,y:n.y}}_computeDistance(n,r,c=!0){let u=Math.abs(r.x-n.x),d=Math.abs(r.y-n.y);return c?Math.sqrt(u*u+d*d):u+d}_formatDistance(n){return this._app.formatDistance(n)}_setCursor(n){this._app.view?.setCursorMode("ruler",n)}_clearTransient(){this._preview=null,this._snapShapes=null,this._drawTransient()}_clearSnap(){this._snapShapes=null,this._drawTransient()}};function Zdn(s,n,r){let c=r[0]-n[0],u=r[1]-n[1],d=c*c+u*u,b=d>0?((s[0]-n[0])*c+(s[1]-n[1])*u)/d:0;return b=Math.max(0,Math.min(1,b)),Math.hypot(s[0]-(n[0]+b*c),s[1]-(n[1]+b*u))}var ade="label-handles",L3t=3,cde=class{constructor(n,r,c,u){this._app=n,this._visibility=r,this._updateInspector=c,this._focusComponent=u,this._labels=[],this._anchors=[],this._mode=!1,this._selectedName=null}isActive(){return this._mode}updateVisibility(){this._app.view?.setMarkerGroupVisible(ade,!!this._visibility.labels)}toggleLabelMode(){this._mode=!this._mode,this._setCursor(this._mode)}cancelLabelMode(){this._mode=!1,this._setCursor(!1)}_setCursor(n){this._app.view?.setCursorMode("label",n)}_wm(){return this._app.websocketManager}_applyLabels(n){this._labels=n||[],this._renderHandles()}_refresh(n){this._applyLabels(n&&n.labels),this._app.refreshOverlay()}applyRemoteLabels(n){this._applyLabels(n),this._selectedName&&!this._labels.some(r=>r.name===this._selectedName)&&(this._selectedName=null,this._updateInspector(null),this._renderHandles()),this._app.refreshOverlay()}_updateLabel(n,r){return this._wm().request({type:"update_label",name:n,...r})}async reload(){let n=this._wm();if(n)try{let r=await n.request({type:"list_labels"});this._anchors=r.anchors||[],this._applyLabels(r.labels)}catch{this._applyLabels([])}}async handleMapClick(n,r){let c=window.prompt("Label text:");if(this._mode=!1,this._setCursor(!1),!!c)try{let u=await this._wm().request({type:"add_label",x:Math.round(n),y:Math.round(r),text:c});this._refresh(u)}catch(u){console.error("add_label failed:",u)}}_renderHandles(){let n=this._app.view;if(!n)return;n.clearMarkers(ade);let r=this._app;if(r.designScale)for(let c of this._labels){let u=document.createElement("div");u.className="label-handle"+(c.name===this._selectedName?" label-handle-selected":""),u.title=c.text,this._installDrag(u,c),n.addMarker(ade,c.name,Av(c.x,c.y,r.designScale,r.designOriginX,r.designOriginY),u,{center:!0})}}_installDrag(n,r){let c=this._app.view,u=w=>{let _=c.getContainer().getBoundingClientRect();return c.unproject([w.clientX-_.left,w.clientY-_.top])},d=null;n.addEventListener("pointerdown",w=>{w.button===0&&(w.stopPropagation(),w.preventDefault(),n.setPointerCapture?.(w.pointerId),d={x:w.clientX,y:w.clientY,moved:!1})}),n.addEventListener("pointermove",w=>{d&&((Math.abs(w.clientX-d.x)>L3t||Math.abs(w.clientY-d.y)>L3t)&&(d.moved=!0),d.moved&&c.moveMarker(ade,r.name,u(w)))});let b=(w,_)=>{if(!d)return;let x=d;if(d=null,n.releasePointerCapture?.(w.pointerId),!_)this._renderHandles();else if(!x.moved)this._select(r.name);else{let T=this._app,[M,L]=u(w),{dbuX:I,dbuY:D}=Pv(M,L,T.designScale,T.designOriginX,T.designOriginY);this._commitMove(r,Math.round(I),Math.round(D))}};n.addEventListener("pointerup",w=>b(w,!0)),n.addEventListener("pointercancel",w=>b(w,!1)),n.addEventListener("click",w=>w.stopPropagation())}async _commitMove(n,r,c){try{let u=await this._updateLabel(n.name,{x:r,y:c,text:n.text,size:n.size||0,anchor:n.anchor||"center",color:n.color});this._refresh(u)}catch(u){console.error("move label failed:",u)}}_select(n){this._selectedName=n,this._renderHandles();let r=this._labels.find(d=>d.name===n);if(!r)return;let c=d=>this._app.formatDbu(d,!0),u={type:"Label",name:r.name,bbox:[r.x,r.y,r.x,r.y],properties:[{name:"Name",value:r.name},{name:"Text",value:r.text,editable:!0},{name:"x",value:c(r.x)},{name:"y",value:c(r.y)},{name:"Font size",value:String(r.size||0),editable:!0},{name:"Anchor",value:r.anchor||"center",editable:!0,editor:{type:"list",options:this._anchors}}],onPropertyChange:(d,b)=>{let w={text:r.text,size:r.size||0,anchor:r.anchor||"center"};d==="Text"?w.text=b:d==="Font size"?w.size=parseInt(b,10)||0:d==="Anchor"&&(w.anchor=b.trim()),this._edit(r,w)}};this._updateInspector(u),this._focusComponent("Inspector"),requestAnimationFrame(()=>{let d=this._app.inspectorEl?.querySelector(".inspector-toolbar");if(!d||d.querySelector(".delete-label-btn"))return;let b=document.createElement("button");b.className="or-btn or-btn-icon delete-label-btn",b.title="Delete label",b.innerHTML='',b.addEventListener("click",()=>this.deleteLabel(n)),d.appendChild(b)})}async _edit(n,r){try{let c=await this._updateLabel(n.name,{x:n.x,y:n.y,text:r.text,size:r.size,anchor:r.anchor,color:n.color});this._refresh(c),this._select(n.name)}catch(c){console.error("edit label failed:",c)}}async deleteLabel(n){try{let r=await this._wm().request({type:"delete_label",name:n});this._selectedName===n&&(this._selectedName=null,this._updateInspector(null)),this._refresh(r)}catch(r){console.error("delete_label failed:",r)}}async clearAllLabels(){try{let n=await this._wm().request({type:"clear_labels"});this._selectedName=null,this._refresh(n)}catch(n){console.error("clear_labels failed:",n)}}};var k3t="Select an instance in the layout to view its schematic.",lde=class{constructor(n,r){this.container=n,this.appState=r,this.element=document.createElement("div"),this.element.className="schematic-widget",this.element.style.cssText="width:100%; height:100%; display:flex; flex-direction:column; background:var(--bg-panel); color:var(--fg-primary); overflow:hidden;",this.controls=document.createElement("div"),this.controls.style.cssText="padding:4px 8px; background:var(--bg-header); border-bottom:1px solid var(--border);flex-shrink:0; display:flex; align-items:center; gap:8px; flex-wrap:wrap;",this.controls.innerHTML='',this.element.appendChild(this.controls),this.svgContainer=document.createElement("div"),this.svgContainer.style.cssText="flex:1; overflow:hidden; position:relative; cursor:grab; background:var(--bg-main);",this.element.appendChild(this.svgContainer),this.container.element.appendChild(this.element),this.controls.querySelector("#schematic-refresh").addEventListener("click",()=>this.refresh()),this.controls.querySelector("#schematic-fit").addEventListener("click",()=>this.fitView()),this.controls.querySelector("#schematic-zoom-in").addEventListener("click",()=>this._zoomStep(1.5)),this.controls.querySelector("#schematic-zoom-out").addEventListener("click",()=>this._zoomStep(1/1.5)),this.controls.querySelector("#schematic-select").addEventListener("click",()=>this._toggleSelectMode()),this.controls.querySelector("#schematic-zoom-to").addEventListener("click",()=>this._zoomToSelected()),this.controls.querySelector("#schematic-save-svg").addEventListener("click",()=>this._exportSvg()),this.controls.querySelector("#schematic-save-png").addEventListener("click",()=>this._exportPng()),this.controls.querySelector("#schematic-copy").addEventListener("click",()=>this._copyImage()),this.appState.schematicWidget=this,this.netlistsvg=null,this.skin=null,this._svgEl=null,this._scale=1,this._panX=0,this._panY=0,this._selectMode=!1,this._selectedCell=null,this._svgIdToInstName=new Map,this._setupPanZoom(),this.initNetlistSVG()}_setupPanZoom(){let n=this.svgContainer,r=!1,c,u,d,b;n.addEventListener("wheel",w=>{if(!this._svgEl)return;w.preventDefault();let _=w.deltaY<0?1.2:1/1.2,x=n.getBoundingClientRect(),T=w.clientX-x.left,M=w.clientY-x.top;this._panX=T+(this._panX-T)*_,this._panY=M+(this._panY-M)*_,this._scale*=_,this._applyTransform()},{passive:!1}),n.addEventListener("mousedown",w=>{if(!(!this._svgEl||w.button!==0)){if(this._selectMode){this._handleSelectClick(w);return}r=!0,c=w.clientX,u=w.clientY,d=this._panX,b=this._panY,n.style.cursor="grabbing",w.preventDefault()}}),window.addEventListener("mousemove",w=>{r&&(this._panX=d+(w.clientX-c),this._panY=b+(w.clientY-u),this._applyTransform())}),window.addEventListener("mouseup",()=>{r&&(r=!1,n.style.cursor=this._selectMode?"default":"grab")})}_zoomStep(n){if(!this._svgEl)return;let r=this.svgContainer.getBoundingClientRect(),c=r.width/2,u=r.height/2;this._panX=c+(this._panX-c)*n,this._panY=u+(this._panY-u)*n,this._scale*=n,this._applyTransform()}_toggleSelectMode(){this._selectMode=!this._selectMode;let n=this.controls.querySelector("#schematic-select");this._selectMode?(n.style.background="var(--accent)",n.style.color="var(--fg-white)",this.svgContainer.style.cursor="default"):(n.style.background="",n.style.color="",this.svgContainer.style.cursor="grab",this._clearCellHighlight())}_handleSelectClick(n){if(!this._svgEl)return;let r=n.target,c=null;for(;r&&r!==this._svgEl;){if(r.tagName==="g"&&r.id&&this._svgIdToInstName.has(r.id)){c=r;break}r=r.parentElement}if(this._clearCellHighlight(),!c)return;let u=this._svgIdToInstName.get(c.id);try{let d=c.getBBox(),b=3,w=document.createElementNS("http://www.w3.org/2000/svg","rect");w.setAttribute("x",d.x-b),w.setAttribute("y",d.y-b),w.setAttribute("width",d.width+b*2),w.setAttribute("height",d.height+b*2),w.setAttribute("fill","none"),w.setAttribute("stroke","#e05a00"),w.setAttribute("stroke-width","1.5"),w.setAttribute("rx","3"),w.id="_schematic_highlight",c.appendChild(w),this._selectedCell=c}catch{}this.controls.querySelector("#schematic-zoom-to").disabled=!1,this.setStatus(`Selected: ${u}`),this._fetchInspect(u)}_fetchInspect(n){let r=this.appState.websocketManager;if(!r)return;console.log("[Schematic] inspect:",n);let c=Pm(this.appState);r.request({type:"schematic_inspect",inst_name:n,use_dbu:this.appState.showDbu}).then(u=>{Y1(this.appState,c)&&(this.appState.updateInspector&&this.appState.updateInspector(u),this.appState.focusComponent&&this.appState.focusComponent("Inspector"),this.appState.refreshOverlay&&this.appState.refreshOverlay())}).catch(u=>{console.error("schematic_inspect failed:",u),this.setStatus(`Inspect error: ${u}`)})}_clearCellHighlight(){if(this._svgEl){let n=this._svgEl.querySelector("#_schematic_highlight");n&&n.remove()}this._selectedCell=null,this.controls.querySelector("#schematic-zoom-to").disabled=!0}_zoomToSelected(){if(!this._selectedCell||!this._svgEl)return;let n=this.svgContainer.getBoundingClientRect(),r=this._selectedCell.getBoundingClientRect(),c=(r.left-n.left-this._panX)/this._scale,u=(r.top-n.top-this._panY)/this._scale,d=r.width/this._scale,b=r.height/this._scale,w=Math.min(n.width/d,n.height/b)*.9;this._scale=w,this._panX=n.width/2-(c+d/2)*w,this._panY=n.height/2-(u+b/2)*w,this._applyTransform()}_applyTransform(){this._svgEl&&(this._svgEl.style.transform=`translate(${this._panX}px, ${this._panY}px) scale(${this._scale})`,this._svgEl.style.transformOrigin="0 0")}fitView(){if(!this._svgEl)return;let n=this.svgContainer.getBoundingClientRect();if(n.width===0||n.height===0)return;let r=this._svgEl.viewBox&&this._svgEl.viewBox.baseVal,c=r&&r.width||this._svgEl.clientWidth||1,u=r&&r.height||this._svgEl.clientHeight||1;this._scale=Math.min(n.width/c,n.height/u)*.95,this._panX=(n.width-c*this._scale)/2,this._panY=(n.height-u*this._scale)/2,this._applyTransform()}initNetlistSVG(){this.netlistsvg=globalThis.netlistsvg,this.skin=globalThis.openroadSkin,this._netlistsvgReady=!!(this.netlistsvg&&this.skin),this._netlistsvgReady&&console.log("NetlistSVG ready."),this.setStatus(this._unreadyStatus()??k3t)}_unreadyStatus(){return this._netlistsvgReady?null:la(this.appState)?"The schematic is not available in saved reports.":"Init error: netlistsvg or its skin is missing from the page."}syncCone(n={}){let r=this.controls.querySelector("#schematic-fanin-depth"),c=this.controls.querySelector("#schematic-fanout-depth"),u=(d,b,w)=>{if(!d)return;let _=parseInt(d.max,10)||10;b===!1?d.value=0:w!==void 0&&(d.value=w>0?Math.min(w,_):_)};u(r,n.fanin,n.fanin_depth),u(c,n.fanout,n.fanout_depth),this.refresh(),this.appState.focusComponent&&this.appState.focusComponent("SchematicWidget")}refresh(){if(!this._netlistsvgReady){this.setStatus(this._unreadyStatus());return}let n=this.appState.selectedInstanceName;if(!n){this.setStatus(k3t);return}let r=this.appState.websocketManager;if(!r){this.setStatus("Waiting for server connection\u2026");return}this.setStatus(`Loading schematic for ${n}\u2026`);let c=parseInt(this.controls.querySelector("#schematic-fanin-depth").value,10),u=parseInt(this.controls.querySelector("#schematic-fanout-depth").value,10),d=isNaN(c)?1:c,b=isNaN(u)?1:u;r.readyPromise.then(()=>{r.request({type:"schematic_cone",inst_name:n,fanin_depth:d,fanout_depth:b}).then(w=>{let _=w.modules&&w.modules.top&&w.modules.top.cells;if(!_||Object.keys(_).length===0){this.setStatus("No cells found for selected instance.");return}this.renderNetlist(w)}).catch(w=>{this.setStatus(`Error: ${w}`)})})}setStatus(n){this.controls.querySelector("#schematic-status").textContent=n}_exportSvg(){if(!this._svgEl){this.setStatus("No schematic to export.");return}let n=X5e(this._svgEl);r3t(new Blob([n],{type:"image/svg+xml;charset=utf-8"}),"schematic.svg")}async _exportPng(){if(!this._svgEl){this.setStatus("No schematic to export.");return}try{let n=await Y5e(this._svgEl,2);hk(n,"schematic.png")}catch{this.setStatus("PNG export failed.")}}async _copyImage(){if(!this._svgEl){this.setStatus("No schematic to export.");return}try{let n=await Y5e(this._svgEl,2),r=await Hhe(n);this.setStatus(r?"Schematic copied to clipboard.":"Clipboard not available.")}catch{this.setStatus("Copy failed.")}}async renderNetlist(n){try{this.setStatus("Rendering\u2026"),typeof window<"u"&&(window.__lastSchematic=n);let r=tpn(n),c,u=this.netlistsvg.render(this.skin,r);if(u&&typeof u.then=="function"?c=await u:c=await new Promise((w,_)=>{this.netlistsvg.render(this.skin,r,(x,T)=>{x?_(x):w(T)})}),typeof c!="string"||!c.includes("requestAnimationFrame(()=>this.fitView()));let b=Object.keys(n.modules.top.cells).length;this.setStatus(`${b} cell${b!==1?"s":""}`)}catch(r){console.error("NetlistSVG render failed:",r),this.setStatus(`Render error: ${r.message||r}`)}}_applyPinLabels(n){if(!this._svgEl)return;let r="http://www.w3.org/2000/svg",c="https://github.com/nturley/netlistsvg",u=n.modules&&n.modules.top&&n.modules.top.cells||{},d=(b,w)=>b.getAttribute("s:"+w)??b.getAttributeNS(c,w);for(let[b,w]of Object.entries(u)){let _=w.port_labels;if(!_)continue;let x=this._svgEl.querySelector("#"+CSS.escape("cell_"+b))||this._svgEl.querySelector("#"+CSS.escape(b));if(!x)continue;let T=w.port_directions||{};for(let M of Array.from(x.children)){if(M.tagName!=="g")continue;let L=d(M,"pid");if(!L||!(L in _))continue;let I=parseFloat(d(M,"x")),D=parseFloat(d(M,"y"));if(!isFinite(I)||!isFinite(D))continue;let F=document.createElementNS(r,"text");T[L]==="input"?(F.setAttribute("class","inputPortLabel"),F.setAttribute("x",I-3)):F.setAttribute("x",I+4),F.setAttribute("y",D-4),F.setAttribute("style","font-size:5px"),F.setAttribute("pointer-events","none"),F.textContent=_[L],x.appendChild(F)}}}_scopeSkinStyles(){if(!this._svgEl)return;let n=".schematic-widget",r=c=>{for(let u of c)u.selectorText?u.selectorText=Kdn(u.selectorText,n):u.cssRules&&r(u.cssRules)};for(let c of this._svgEl.querySelectorAll("style")){let u=c.sheet;if(u)try{r(u.cssRules)}catch{continue}}}};function Kdn(s,n){return s.split(",").map(r=>{let c=r.trim();if(!c)return"";let u=c.charAt(n.length);return c.startsWith(n)&&(u===""||!/[\w-]/.test(u))?c:`${n} ${c}`}).filter(Boolean).join(", ")}var R3t={and:"$_AND_",nand:"$_NAND_",or:"$_OR_",nor:"$_NOR_",xor:"$_XOR_",xnor:"$_XNOR_",not:"$_NOT_",buf:"$_BUF_"},Jdn=new Set(["aoi21","aoi22","aoi211","aoi221","aoi222","aoi33","oai21","oai22","oai211","oai221","oai222","oai33"]),Qdn=new Set(["and3","and4","or3","or4","nand3","nand4","nor3","nor4"]),I3t=["A","B","C","D","E","F"];function epn(s){let n=s&&s.gate_kind;if(!n)return s;let r=s.port_directions||{},c=null,u=[];for(let[M,L]of Object.entries(r))L==="output"&&c===null?c=M:L==="input"&&u.push(M);let d,b={};if(n==="aoi"||n==="oai"){let M=Array.isArray(s.gate_terms)?s.gate_terms:[];if(!M.length)return s;let L=M.map(F=>F.length);if(d=n+L.slice().sort((F,O)=>O-F).join(""),!Jdn.has(d))return s;let I=M.map(F=>F.slice()).sort((F,O)=>F.length-O.length),D=0;for(let F of I)for(let O of F)b[O]=I3t[D]||"I"+D,D++}else{let M=u.length;if(n==="not"||n==="buf")d=R3t[n];else if(M<=2)d=R3t[n];else if(d=n+M,!Qdn.has(d))return s;if(!d)return s;u.forEach((L,I)=>{b[L]=I3t[I]||"I"+I})}c!==null&&(b[c]="Y");let w=s.connections||{},_={},x={};for(let[M,L]of Object.entries(w))b[M]&&(_[b[M]]=L);for(let[M,L]of Object.entries(r))b[M]&&(x[b[M]]=L);let T={};for(let[M,L]of Object.entries(b))T[L]=M;return{...s,type:d,connections:_,port_directions:x,port_labels:T}}function tpn(s){let n=s&&s.modules&&s.modules.top;if(!n||!n.cells)return s;let r={};for(let[c,u]of Object.entries(n.cells))r[c]=epn(u);return{...s,modules:{...s.modules,top:{...n,cells:r}}}}var ude=class{constructor(n,r,c){this._app=n,this._redrawAllLayers=r,this._refreshOverlay=c||r,this._categories=[],this._activeCategory="",this._markerTree=null,this._expandedNodes=new Set,this._build(),this._app.websocketManager.readyPromise.then(()=>this.refresh())}_build(){let n=document.createElement("div");n.className="drc-widget";let r=document.createElement("div");r.className="drc-toolbar",this._categorySelect=document.createElement("select"),this._categorySelect.className="drc-category-select",r.appendChild(this._categorySelect),this._loadBtn=document.createElement("button"),this._loadBtn.className="or-btn or-btn-sm",this._loadBtn.textContent="Load...",r.appendChild(this._loadBtn),n.appendChild(r),this._infoBar=document.createElement("div"),this._infoBar.className="drc-info-bar",n.appendChild(this._infoBar),this._treeContainer=document.createElement("div"),this._treeContainer.className="drc-tree-container",n.appendChild(this._treeContainer),this.element=n,this._bindEvents()}_bindEvents(){this._categorySelect.addEventListener("change",()=>{this._activeCategory=this._categorySelect.value,this._loadMarkers()}),this._loadBtn.addEventListener("click",()=>{this._showLoadDialog()})}_loadCategories(){return this._app.websocketManager.request({type:"drc_categories"}).then(n=>{this._categories=n.categories||[],this._renderCategorySelect()}).catch(n=>{console.error("Failed to load DRC categories:",n)})}refresh(){this._loadCategories().then(()=>{!this._activeCategory&&this._categories.length>0&&(this._activeCategory=this._categories[0].name,this._categorySelect.value=this._activeCategory),this._activeCategory&&this._loadMarkers()})}_renderCategorySelect(){let n=this._categorySelect,r=n.value;n.innerHTML="";let c=document.createElement("option");c.value="",c.textContent="(none)",n.appendChild(c);for(let u of this._categories){let d=document.createElement("option");d.value=u.name,d.textContent=`${u.name} (${u.count})`,n.appendChild(d)}this._activeCategory&&this._categories.some(u=>u.name===this._activeCategory)?n.value=this._activeCategory:r&&this._categories.some(u=>u.name===r)?(n.value=r,this._activeCategory=r):this._activeCategory=""}_loadMarkers(){if(!this._activeCategory){this._markerTree=null,this._treeContainer.innerHTML="",this._infoBar.textContent="",this._refreshOverlay();return}this._treeContainer.innerHTML='
Loading...
',this._app.websocketManager.request({type:"drc_markers",category:this._activeCategory}).then(n=>{this._markerTree=n,this._renderTree(),this._refreshOverlay()}).catch(n=>{this._treeContainer.innerHTML="";let r=document.createElement("div");r.className="drc-error",r.textContent=`Error: ${n}`,this._treeContainer.appendChild(r),console.error("Failed to load DRC markers:",n)})}_renderTree(){if(this._treeContainer.innerHTML="",!this._markerTree)return;if(this._markerTree.error){let b=document.createElement("div");b.className="drc-error",b.textContent=this._markerTree.error,this._treeContainer.appendChild(b);return}let n=this._markerTree.total_count||0;this._infoBar.textContent=`${n} total violation${n!==1?"s":""}`;let r=this._markerTree.name||this._activeCategory,c=this._markerTree.subcategories||[],u=this._markerTree.markers||[];if(c.length===0&&u.length===0){this._treeContainer.innerHTML='
No violations
';return}let d=document.createElement("div");d.className="drc-tree",u.length>0&&d.appendChild(this._buildCategoryNode({name:r||"Markers",count:u.length,markers:u},[]));for(let b of c)d.appendChild(this._buildCategoryNode(b,[r]));this._treeContainer.appendChild(d)}_buildCategoryNode(n,r=[]){let c=[...r,n.name],u=document.createElement("div");u.className="drc-tree-node";let d=document.createElement("div");d.className="drc-tree-header";let b=document.createElement("span");b.className="drc-toggle";let w=n.subcategories&&n.subcategories.length>0||n.markers&&n.markers.length>0,_=JSON.stringify(c),x=this._expandedNodes.has(_);b.textContent=w?x?"\u25BC":"\u25B6":" ",d.appendChild(b);let T=document.createElement("input");T.type="checkbox",T.checked=this._allMarkersVisible(n),T.className="drc-visibility-check",T.addEventListener("change",D=>{D.stopPropagation(),this._toggleCategoryVisibility(n,T.checked,c)}),d.appendChild(T);let M=document.createElement("span");M.className="drc-category-label",M.textContent=n.name,d.appendChild(M);let L=document.createElement("span");L.className="drc-count",L.textContent=`${n.count} markers`,d.appendChild(L),u.appendChild(d);let I=document.createElement("div");if(I.className="drc-tree-children",I.style.display=x?"":"none",n.subcategories)for(let D of n.subcategories)I.appendChild(this._buildCategoryNode(D,c));if(n.markers)for(let D of n.markers)I.appendChild(this._buildMarkerNode(D));return u.appendChild(I),w&&(d.addEventListener("click",D=>{if(D.target===T)return;let F=I.style.display!=="none";I.style.display=F?"none":"",b.textContent=F?"\u25B6":"\u25BC",F?this._expandedNodes.delete(_):this._expandedNodes.add(_)}),d.style.cursor="pointer"),u}_buildMarkerNode(n){let r=document.createElement("div");r.className="drc-marker-row",r.dataset.markerId=n.id,n.visited||r.classList.add("drc-unvisited");let c=document.createElement("input");c.type="checkbox",c.checked=n.visible,c.className="drc-visibility-check",c.addEventListener("change",b=>{b.stopPropagation(),n.visible=c.checked,this._updateMarker(n.id,"visible",c.checked)}),r.appendChild(c);let u=document.createElement("span");u.className="drc-marker-index",u.textContent=n.index,r.appendChild(u);let d=document.createElement("span");if(d.className="drc-marker-name",d.textContent=n.name,n.layer&&(d.title=`Layer: ${n.layer}`),r.appendChild(d),n.layer){let b=document.createElement("span");b.className="drc-layer-badge",b.textContent=n.layer,r.appendChild(b)}return r.addEventListener("click",b=>{b.target!==c&&this._highlightMarker(n)}),r.addEventListener("dblclick",b=>{b.target!==c&&this._highlightMarker(n,!0)}),r}highlightMarkerById(n,r=!1){let c=this._findMarkerById(n);c&&this._highlightMarker(c,r)}_findMarkerById(n){let r=c=>{if(!c)return null;if(c.markers){for(let u of c.markers)if(u.id===n)return u}if(c.subcategories)for(let u of c.subcategories){let d=r(u);if(d)return d}return null};return r(this._markerTree)}_highlightMarker(n,r=!1){this._app.websocketManager.request({type:"drc_highlight",marker_id:n.id,open_inspector:r}).then(c=>{if(c.ok&&c.bbox){n.visited=!0;let u=this._treeContainer.querySelector(`.drc-marker-row[data-marker-id="${n.id}"]`);u&&u.classList.remove("drc-unvisited"),this._zoomToBBox(c.bbox),this._refreshOverlay(),r&&(c.select_id!=null&&this._app.navigateInspector&&this._app.navigateInspector(c.select_id),this._app.focusComponent&&this._app.focusComponent("Inspector"))}}).catch(c=>{console.error("Failed to highlight DRC marker:",c)})}_zoomToBBox(n){if(!this._app.designScale||!this._app.view)return;let[r,c,u,d]=n,b=u-r,w=d-c,x=10*this._app.getDbuPerMicron(),T=2*Math.max(b,w),M=Math.min(x,T);this._app.view.fitWorldRect(X1(r-M,c-M,u+M,d+M,this._app.designScale,this._app.designOriginX,this._app.designOriginY))}_updateMarker(n,r,c){this._app.websocketManager.request({type:"drc_update_marker",marker_id:n,field:r,value:!!c}).then(()=>{this._refreshOverlay(),r==="visible"&&(this._update3DHighlights(),c&&this._flashHighlight())}).catch(u=>{console.error("Failed to update DRC marker:",u)})}_flashHighlight(){this._app.view?.flashTiles()}_update3DHighlights(){let n=this._app.threeDViewerWidget;if(!n)return;let r=[];this._collectVisibleMarkers(this._markerTree,r),r.length>0?n.highlightDRC(r):n.clearHighlightDRC()}_collectVisibleMarkers(n,r){if(n){if(n.markers)for(let c of n.markers)c.visible&&r.push(c);if(n.subcategories)for(let c of n.subcategories)this._collectVisibleMarkers(c,r)}}_setMarkersVisible(n,r){if(n){if(n.markers)for(let c of n.markers)c.visible=r;if(n.subcategories)for(let c of n.subcategories)this._setMarkersVisible(c,r)}}_snapshotMarkerVisibility(n,r=new Map){if(!n)return r;if(n.markers)for(let c of n.markers)r.set(c.id,c.visible);if(n.subcategories)for(let c of n.subcategories)this._snapshotMarkerVisibility(c,r);return r}_restoreMarkerVisibility(n,r){if(n){if(n.markers)for(let c of n.markers)r.has(c.id)&&(c.visible=r.get(c.id));if(n.subcategories)for(let c of n.subcategories)this._restoreMarkerVisibility(c,r)}}_allMarkersVisible(n){if(n.markers){for(let r of n.markers)if(!r.visible)return!1}if(n.subcategories){for(let r of n.subcategories)if(!this._allMarkersVisible(r))return!1}return!0}_toggleCategoryVisibility(n,r,c){let u=this._snapshotMarkerVisibility(n);this._setMarkersVisible(n,r),this._renderTree(),this._app.websocketManager.request({type:"drc_update_category_visibility",category:n.name,path:c||[n.name],visible:!!r}).then(()=>{this._refreshOverlay(),this._update3DHighlights(),r&&this._flashHighlight()}).catch(d=>{console.error("Failed to update category visibility:",d),this._restoreMarkerVisibility(n,u),this._renderTree()})}_showLoadDialog(){new nDe(this._app,r=>{this._activeCategory=r,this._loadCategories().then(()=>{this._categorySelect.value=this._activeCategory,this._loadMarkers()})}).open()}selectCategory(n){this._activeCategory=n,this._categorySelect.value=n,this._loadMarkers()}},nDe=class{constructor(n,r){this._app=n,this._onLoaded=r,this._currentPath="",this._disposers=[],this._closed=!1}open(){this._overlay=document.createElement("div"),this._overlay.className="modal-overlay",this._overlay.innerHTML=` - `,document.body.appendChild(this._overlay),this._breadcrumb=this._overlay.querySelector(".fb-breadcrumb"),this._fileList=this._overlay.querySelector(".fb-file-list"),this._pathInput=this._overlay.querySelector(".fb-path-input"),this._errorDiv=this._overlay.querySelector(".modal-error"),this._okBtn=this._overlay.querySelector(".ok"),this._cancelBtn=this._overlay.querySelector(".cancel"),this._listen(this._pathInput,"input",()=>this._updateOkState()),this._listen(this._pathInput,"keydown",s=>{if(s.key==="Enter"){let h=this._pathInput.value.trim();h.endsWith("/")?this._navigate(h.replace(/\/+$/,"")||"/"):this._submit()}else s.key==="Escape"&&this.close()}),this._listen(this._okBtn,"click",()=>this._submit()),this._listen(this._cancelBtn,"click",()=>this.close()),this._listen(this._overlay,"click",s=>{s.target===this._overlay&&this.close()}),this._navigate("")}close(){if(!this._closed){this._closed=!0;for(let s of this._disposers)s();this._disposers.length=0,this._overlay&&(this._overlay.remove(),this._overlay=null)}}_listen(s,h,p){s.addEventListener(h,p),this._disposers.push(()=>s.removeEventListener(h,p))}_updateOkState(){this._okBtn.disabled=!this._pathInput.value.trim()}_renderBreadcrumb(s){this._breadcrumb.innerHTML="";let h=s.split("/").filter(Boolean),p=document.createElement("span");p.className="fb-crumb",p.textContent="/",this._listen(p,"click",()=>this._navigate("/")),this._breadcrumb.appendChild(p);let m="";for(let _ of h){m+="/"+_;let S=document.createElement("span");S.className="fb-crumb-sep",S.textContent=" / ",this._breadcrumb.appendChild(S);let y=document.createElement("span");y.className="fb-crumb",y.textContent=_;let I=m;this._listen(y,"click",()=>this._navigate(I)),this._breadcrumb.appendChild(y)}}_renderEntries(s){if(this._fileList.innerHTML="",!s||s.length===0){let h=document.createElement("div");h.className="fb-empty",h.textContent="(empty directory)",this._fileList.appendChild(h);return}for(let h of s){let p=document.createElement("div");p.className="fb-entry",h.is_dir&&p.classList.add("fb-dir");let m=document.createElement("span");m.className="fb-icon",m.textContent=h.is_dir?"\u{1F4C1}":"\u{1F4C4}",p.appendChild(m);let _=document.createElement("span");_.className="fb-name",_.textContent=h.name,p.appendChild(_),h.is_dir?this._listen(p,"click",()=>this._navigate(this._currentPath+"/"+h.name)):(this._listen(p,"click",()=>{let S=this._fileList.querySelector(".fb-selected");S&&S.classList.remove("fb-selected"),p.classList.add("fb-selected"),this._pathInput.value=this._currentPath+"/"+h.name,this._updateOkState()}),this._listen(p,"dblclick",()=>{this._pathInput.value=this._currentPath+"/"+h.name,this._updateOkState(),this._submit()})),this._fileList.appendChild(p)}}async _navigate(s){this._errorDiv.style.display="none",this._fileList.innerHTML='
Loading...
';try{let h=await this._app.websocketManager.request({type:"list_dir",path:s||""});if(this._closed)return;this._currentPath=h.path,this._renderBreadcrumb(h.path),this._renderEntries(h.entries),this._pathInput.value="",this._updateOkState()}catch(h){if(this._closed)return;this._fileList.innerHTML="",this._errorDiv.textContent=h.message||String(h),this._errorDiv.style.display=""}}async _submit(){let s=this._pathInput.value.trim();if(s){this._okBtn.disabled=!0,this._okBtn.textContent="Loading...",this._errorDiv.style.display="none";try{let h=await this._app.websocketManager.request({type:"drc_load_report",path:s});if(this._closed)return;if(h.ok){let p=h.category;this.close(),this._onLoaded(p)}else this._errorDiv.textContent=h.error||"Failed to load report",this._errorDiv.style.display="",this._okBtn.disabled=!1,this._okBtn.textContent="Load"}catch(h){if(this._closed)return;this._errorDiv.textContent=h.message||"Request failed",this._errorDiv.style.display="",this._okBtn.disabled=!1,this._okBtn.textContent="Load"}}}};var s5e=` -\r[]{}`;var _nt=class{constructor(s,h){this._input=s,this._ws=h,this._popup=null,this._items=[],this._selectedIndex=-1,this._replaceStart=0,this._replaceEnd=0,this._debounceTimer=null,this._commandCache=null,this._history=[],this._historyIndex=-1,this._historyStash="",this._createPopup(),this._onInputBound=this._onInput.bind(this),this._onBlurBound=this._onBlur.bind(this),this._input.addEventListener("input",this._onInputBound),this._input.addEventListener("blur",this._onBlurBound)}_createPopup(){this._popup=document.createElement("div"),this._popup.className="tcl-complete-popup",this._popup.style.display="none",this._input.parentElement.appendChild(this._popup)}handleKeyDown(s){let h=this._popup.style.display!=="none";return s.key==="Tab"?(s.preventDefault(),h?this._tabAccept():this._tabComplete(this._input.value,this._input.selectionStart),!0):s.key==="Escape"?h?(this._hidePopup(),!0):!1:s.key==="ArrowDown"?h?(s.preventDefault(),this._selectItem(this._selectedIndex+1),!0):this._historyIndex>=0?(s.preventDefault(),this._historyIndex--,this._historyIndex<0?this._input.value=this._historyStash:this._input.value=this._history[this._historyIndex],!0):!1:s.key==="ArrowUp"?h?(s.preventDefault(),this._selectItem(this._selectedIndex-1),!0):this._historyIndex{let s=this._input.value,h=this._input.selectionStart,p=this._extractPrefix(s,h);p.length>=2||p.length>=1&&(p[0]==="$"||p[0]==="-")?this._requestCompletions(s,h):this._hidePopup()},100)}_onBlur(){setTimeout(()=>this._hidePopup(),150)}_extractPrefix(s,h){let p=h-1;for(;p>=0&&s5e.indexOf(s[p])===-1;)p--;return s.substring(p+1,h)}_fetchCompletions(s,h,p){let m=this._extractPrefix(s,h),_=m.length>0&&m[0]==="$",S=m.length>0&&m[0]==="-",y=!_&&!S,I=h-m.length,N=s.substring(0,I),B=/^[\s\[]*$/.test(N);if(y&&B&&this._commandCache){let P=m.toLowerCase(),U=this._commandCache.filter(j=>j.toLowerCase().startsWith(P));p(U,I,h);return}this._ws.request({type:"tcl_complete",line:s,cursor_pos:h}).then(P=>{P.mode==="commands"&&!this._commandCache&&m===""&&(this._commandCache=P.completions),P.mode==="commands"&&!this._commandCache&&this._ws.request({type:"tcl_complete",line:"",cursor_pos:0}).then(U=>{U.mode==="commands"&&(this._commandCache=U.completions)}).catch(()=>{}),p(P.completions,P.replace_start,P.replace_end)}).catch(()=>p([],0,0))}_requestCompletions(s,h){this._fetchCompletions(s,h,(p,m,_)=>{this._showPopup(p,m,_)})}_tabAccept(){if(this._items.length===0){this._hidePopup();return}if(this._items.length===1){this._selectedIndex=0,this._acceptCompletion();return}this._advanceToCommonPrefix()}_tabComplete(s,h){this._fetchCompletions(s,h,(p,m,_)=>{if(!p||p.length===0){this._hidePopup();return}if(p.length===1){this._items=p,this._replaceStart=m,this._replaceEnd=_,this._selectedIndex=0,this._acceptCompletion();return}this._items=p,this._replaceStart=m,this._replaceEnd=_,this._advanceToCommonPrefix(),this._showPopup(p,this._replaceStart,this._replaceEnd)})}_advanceToCommonPrefix(){if(this._items.length<2)return!1;let s=this._items[0];for(let S=1;S0;S++){let y=this._items[S],I=0;for(;I{let I=document.createElement("div");I.className="tcl-complete-item",I.textContent=S,I.addEventListener("mousedown",N=>{N.preventDefault(),this._selectedIndex=y,this._acceptCompletion()}),this._popup.appendChild(I)}),s.length>15){let S=document.createElement("div");S.className="tcl-complete-more",S.textContent=`... ${s.length-15} more`,this._popup.appendChild(S)}this._selectedIndex=0,this._highlightSelected(),this._popup.style.display="block"}_hidePopup(){this._popup.style.display="none",this._items=[],this._selectedIndex=-1}_selectItem(s){if(this._items.length===0)return;let h=Math.min(this._items.length,15)-1;this._selectedIndex=Math.max(0,Math.min(s,h)),this._highlightSelected()}_highlightSelected(){let s=this._popup.querySelectorAll(".tcl-complete-item");s.forEach((h,p)=>{h.classList.toggle("selected",p===this._selectedIndex)}),s[this._selectedIndex]&&s[this._selectedIndex].scrollIntoView&&s[this._selectedIndex].scrollIntoView({block:"nearest"})}_acceptCompletion(){if(this._selectedIndex<0||this._selectedIndex>=this._items.length){this._hidePopup();return}let s=this._items[this._selectedIndex],h=this._input.value.substring(0,this._replaceStart),p=this._input.value.substring(this._replaceEnd),_=!s.endsWith("/")&&!s.endsWith("::")&&(p.length===0||p[0]!==" ")?" ":"";this._input.value=h+s+_+p;let S=this._replaceStart+s.length+_.length;this._input.setSelectionRange(S,S),this._input.focus(),this._hidePopup()}};var iQt=[{key:"or_visibility",store:"cookie"},{key:"or_selectability",store:"cookie"},{key:"or_hidden_layers",store:"session"},{key:"or_nonselectable_layers",store:"session"},{key:"or_layer_patterns",store:"session"},{key:"or_hidden_chiplets",store:"cookie"},{key:"or_bg_color",store:"cookie"},{key:"or_show_dbu",store:"cookie"},{key:"or_theme",store:"theme"},{key:"or_use_true_z",store:"cookie"},{key:"or_ruler_style",store:"cookie"},{key:"or_wheel_zoom",store:"cookie"},{key:"or_arrow_step",store:"cookie"},{key:"or_font_family",store:"cookie"},{key:"or_font_scale",store:"cookie"}];function o5e(d,s){try{return window[d].getItem(s)}catch{return null}}function c5e(d,s,h){try{h===null?window[d].removeItem(s):window[d].setItem(s,h)}catch{}}function a5e({key:d,store:s}){return s==="session"?o5e("sessionStorage",d):qf(d)}function u5e({key:d,store:s},h){s==="session"?c5e("sessionStorage",d,h):s==="theme"?h===null?SJt():ent(h):h===null?tnt(d):Rd(d,h)}function rQt(){let d={};for(let s of iQt){let h=a5e(s);h&&(d[s.key]=h)}return{version:1,entries:d}}function l5e(d){return typeof d=="string"&&d!==""&&!/[;\r\n]/.test(d)}function sQt(d){for(let s of iQt){let h=d[s.key];u5e(s,l5e(h)?h:null)}}function oQt(d,s=typeof document<"u"?document:null){let h="OpenROAD",p=d?`${h} - ${d}`:h;return s&&(s.title=p),p}var Zs=globalThis.THREE,cQt=2,h5e=.002,f5e=.9,d5e=1.1,p5e=.1,g5e=20,m5e=3,dk=2,aQt=2,b5e=10,w5e=1e4,v5e=.15,_5e=300,y5e=6,ynt=Math.PI/180,uQt=[5025616,2201331,16750592,10233776,48340,16007990,2533018,7951688,15277667,4149685];function x5e(d){let s=new Array(d.length).fill(0),h=new Map;d.forEach((p,m)=>{let _=p.z;h.has(_)||h.set(_,[]),h.get(_).push({idx:m,chiplet:p})});for(let p of h.values()){if(p.length<=1)continue;let m=[];for(let{idx:_,chiplet:S}of p){let y=S.x,I=S.y,N=S.x+S.width,B=S.y+S.height,P=!1;for(let U=0;UyV.x1&&IV.y1)){m[U].push({x1:y,y1:I,x2:N,y2:B}),s[_]=U,P=!0;break}P||(m.push([{x1:y,y1:I,x2:N,y2:B}]),s[_]=m.length-1)}}return s}var xnt=class{constructor(s,h){if(this._app=h,this._container=s,this._element=document.createElement("div"),this._element.className="three-d-viewer-widget",s.element.appendChild(this._element),!Zs){Sc(h)?this._showInfo("The 3D view is not available in saved reports."):this._showError("three.js is missing from the page."),this._destroyed=!0;return}this._canvasContainer=document.createElement("div"),this._canvasContainer.className="three-d-canvas-container",this._element.appendChild(this._canvasContainer),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._canvasContainer.appendChild(this._tooltip),this._optionsOverlay=this._createOptionsOverlay(),this._canvasContainer.appendChild(this._optionsOverlay),this._raycaster=new Zs.Raycaster,this._scene=new Zs.Scene,this._applyTheme(),this._themeObserver=new MutationObserver(()=>{this._applyTheme(),this.render()}),this._themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),this._camera=new Zs.PerspectiveCamera(45,1,10,1e5),this._camera.position.set(0,0,1e3);try{this._renderer=new Zs.WebGLRenderer({antialias:!0,preserveDrawingBuffer:!0})}catch(S){console.error("3D viewer: failed to create WebGL context:",S),this._showWebGLUnavailable(S),this._themeObserver&&(this._themeObserver.disconnect(),this._themeObserver=null),this._destroyed=!0;return}this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(s.width,s.height),this._canvasContainer.appendChild(this._renderer.domElement),this._rotation=new Zs.Quaternion,this._distance=1e3,this._panX=0,this._panY=0,this._boundingRadius=1,this._sceneCenter=new Zs.Vector3,this._mouseDown=!1,this._mouseButton=-1,this._lastMousePos={x:0,y:0},this._setupMouseHandlers();let p=new Zs.AmbientLight(16777215,.5);this._scene.add(p);let m=new Zs.DirectionalLight(16777215,.8);m.position.set(1,1,1).normalize(),this._scene.add(m);let _=new Zs.DirectionalLight(16777215,.3);_.position.set(-1,-.5,.5).normalize(),this._scene.add(_),s.on("resize",this.onResize.bind(this)),s.on("open",this.onOpen.bind(this)),s.on("destroy",this.onDestroy.bind(this)),this._designGroup=new Zs.Group,this._scene.add(this._designGroup),this._chipletMeshes=[],this._loading=!1,this._destroyed=!1,this._edgeMaterial=null}_setupMouseHandlers(){let s=this._renderer.domElement;s.addEventListener("mousedown",h=>{this._mouseDown=!0,this._mouseButton=h.button,this._lastMousePos.x=h.clientX,this._lastMousePos.y=h.clientY,s.focus(),h.preventDefault()}),s.addEventListener("contextmenu",h=>h.preventDefault()),this._onMouseMove=h=>{if(!this._mouseDown)return;let p=h.clientX-this._lastMousePos.x,m=h.clientY-this._lastMousePos.y;this._lastMousePos.x=h.clientX,this._lastMousePos.y=h.clientY,!(p===0&&m===0)&&(this._mouseButton===0?this._handleRotate(p,m):this._mouseButton===2&&this._handlePan(p,m),this._updateCamera())},this._onMouseUp=h=>{this._mouseDown&&h.button===this._mouseButton&&(this._mouseDown=!1,this._mouseButton=-1)},window.addEventListener("mousemove",this._onMouseMove),window.addEventListener("mouseup",this._onMouseUp),s.addEventListener("wheel",h=>{h.preventDefault(),h.deltaY<0?this._distance*=f5e:this._distance*=d5e;let p=Math.max(this._boundingRadius*p5e,1),m=Math.max(this._boundingRadius*g5e,p);this._distance=Math.max(p,Math.min(m,this._distance)),this._updateCamera()},{passive:!1}),s.tabIndex=0,s.style.outline="none",s.addEventListener("keydown",h=>{h.key.toLowerCase()==="f"&&this.resetCamera()}),s.addEventListener("dblclick",h=>{h.preventDefault();let p=this._pickDrcMarkerId(h);if(p!=null&&this._app.drcWidget){this._app.drcWidget.highlightMarkerById(p,!0);return}this.resetCamera()}),s.addEventListener("mousemove",h=>{if(this._mouseDown){this._hideTooltip();return}this._updateTooltip(h)}),s.addEventListener("mouseleave",()=>{this._hideTooltip()})}_createOptionsOverlay(){let s=document.createElement("div");s.className="three-d-options";let h=document.createElement("label");h.title="Render chiplets at their true Z (disable stacking offset for overlapping chiplets at same Z).";let p=document.createElement("input");p.type="checkbox",p.checked=!!this._app.useTrueZ,p.addEventListener("change",()=>{this._app.useTrueZ=p.checked,Rd("or_use_true_z",p.checked?"1":"0"),this._app.syncDisplayState(),this.refreshSceneForOptions()}),h.appendChild(p),h.appendChild(document.createTextNode("True Z (no stacking)")),s.appendChild(h);let m=document.createElement("div");m.style.cssText="margin-top:4px; display:flex; gap:4px;";let _=document.createElement("button");_.className="or-btn or-btn-sm",_.textContent="Save PNG",_.title="Save the 3D view as a PNG image (2x resolution)",_.addEventListener("click",()=>this._exportPng(2));let S=document.createElement("button");return S.className="or-btn or-btn-sm",S.textContent="Copy",S.title="Copy the 3D view image to the clipboard",S.addEventListener("click",()=>this._copyImage(2)),m.appendChild(_),m.appendChild(S),s.appendChild(m),s}_capturePng(s=2){if(!this._renderer)return null;let h=this._renderer,p=h.domElement.clientWidth||h.domElement.width,m=h.domElement.clientHeight||h.domElement.height,_=h.getPixelRatio();try{return h.setPixelRatio(_*s),h.setSize(p,m,!1),this.render(),h.domElement.toDataURL("image/png")}finally{h.setPixelRatio(_),h.setSize(p,m,!1),this.render()}}_exportPng(s=2){let h=this._capturePng(s);h&&lk(h,"3d-view.png")}async _copyImage(s=2){let h=this._capturePng(s);h&&await nnt(h)}_setRaycasterFromEvent(s){let p=this._renderer.domElement.getBoundingClientRect(),m=new Zs.Vector2((s.clientX-p.left)/p.width*2-1,-((s.clientY-p.top)/p.height*2-1));this._raycaster.setFromCamera(m,this._camera)}_updateTooltip(s){if(!this._chipletMeshes.length){this._hideTooltip();return}this._setRaycasterFromEvent(s);let h=this._chipletMeshes.map(y=>y.mesh),p=this._raycaster.intersectObjects(h,!1);if(p.length===0){this._hideTooltip();return}let m=p[0].object,_=this._chipletMeshes.find(y=>y.mesh===m);if(!_){this._hideTooltip();return}this._tooltip.textContent=_.data.name,this._tooltip.style.display="block";let S=this._canvasContainer.getBoundingClientRect();this._tooltip.style.left=s.clientX-S.left+12+"px",this._tooltip.style.top=s.clientY-S.top+12+"px"}_hideTooltip(){this._tooltip&&(this._tooltip.style.display="none")}_pickDrcMarkerId(s){if(!this._drcHitboxMesh||!this._drcHitboxMarkerIds)return null;this._setRaycasterFromEvent(s);let h=this._raycaster.intersectObject(this._drcHitboxMesh,!1);if(h.length===0)return null;let p=h[0].instanceId;return p==null?null:this._drcHitboxMarkerIds[p]??null}_handleRotate(s,h){let p=Math.sqrt(s*s+h*h);if(p<.001)return;let m=new Zs.Vector3(h/p,s/p,0),_=p/cQt,y=new Zs.Quaternion().setFromAxisAngle(m,_*ynt).clone().multiply(this._rotation);if(new Zs.Vector3(0,0,1).applyQuaternion(y).z>=0)this._rotation.copy(y);else{let N=new Zs.Vector3(0,1,0),B=s/cQt*ynt,U=new Zs.Quaternion().setFromAxisAngle(N,B).clone().multiply(this._rotation);new Zs.Vector3(0,0,1).applyQuaternion(U).z>=0&&this._rotation.copy(U)}}_handlePan(s,h){let p=this._distance*h5e;this._panX+=s*p,this._panY-=h*p}_updateCamera(){let s=Math.max(this._boundingRadius,1e3),h=Math.max(this._distance-s*aQt,b5e),p=this._distance+s*aQt;p0;){let s=this._designGroup.children[0];this._designGroup.remove(s),s.geometry&&s.geometry.dispose(),s.material&&!s.material._shared&&s.material.dispose()}this._edgeMaterial&&(this._edgeMaterial.dispose(),this._edgeMaterial=null),this._onMouseMove&&(window.removeEventListener("mousemove",this._onMouseMove),this._onMouseMove=null),this._onMouseUp&&(window.removeEventListener("mouseup",this._onMouseUp),this._onMouseUp=null),this._renderer&&(this._renderer.dispose(),this._renderer=null),this._app.threeDViewerWidget===this&&(this._app.threeDViewerWidget=null)}}_setInitialCameraState(){this._distance=this._boundingRadius*m5e;let s=new Zs.Quaternion().setFromAxisAngle(new Zs.Vector3(1,0,0),-45*ynt),h=new Zs.Quaternion().setFromAxisAngle(new Zs.Vector3(0,0,1),45*ynt);this._rotation=s.multiply(h),this._panX=0,this._panY=0}resetCamera(){this._sceneBounds&&(this._setInitialCameraState(),this._updateCamera())}onResize(){if(this._destroyed)return;let s=this._canvasContainer.getBoundingClientRect(),h=s.width,p=s.height;h===0||p===0||(this._camera.aspect=h/p,this._camera.updateProjectionMatrix(),this._renderer.setSize(h,p),this.render())}render(){this._destroyed||this._renderer&&this._scene&&this._camera&&this._renderer.render(this._scene,this._camera)}_applyTheme(){let h=uk().bgMap||"#000000";this._scene.background=new Zs.Color(h)}async loadData(){if(!(this._loading||this._destroyed)){this._loading=!0;for(let s of[".three-d-error",".three-d-info"]){let h=this._element.querySelector(s);h&&h.remove()}try{await this._app.websocketManager.readyPromise;let s=await this._app.websocketManager.request({type:"get_3d_data"});if(this._destroyed)return;if(s&&s.error){this._showError(s.error);return}if(s&&s.info){this._showInfo(s.info);return}this.buildScene(s)}catch(s){if(this._destroyed)return;console.error("Failed to load 3D data:",s),this._showError(s.message||String(s))}finally{this._loading=!1}}}_showOverlay(s,h,p){let m=document.createElement("div");m.className=s,m.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-family:monospace;text-align:center;",m.style.color=p,m.textContent=h,this._element.appendChild(m)}_showError(s){this._showOverlay("three-d-error","Failed to load 3D data: "+s,"var(--error)")}_showInfo(s){this._showOverlay("three-d-info",s,"var(--fg-muted, #888)")}_showWebGLUnavailable(s){let h=document.createElement("div");h.className="three-d-error",h.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-family:monospace;text-align:center;max-width:80%;color:var(--error);";let p=s&&s.message?s.message:String(s||"");h.innerHTML='
3D viewer unavailable: WebGL context could not be created.
In Chrome, open chrome://flags/#ignore-gpu-blocklist and set Override software rendering list to Enabled, then relaunch the browser.
Otherwise enable hardware acceleration or try a different browser. See chrome://gpu for details.
'+(p?'
'+p+"
":""),this._element.appendChild(h)}buildScene(s){if(this._destroyed||(this._lastSceneData=s,this._clearScene(),!s||!s.chiplets||s.chiplets.length===0))return;let h=this._app.getDbuPerMicron(),p=this._buildChiplets(s.chiplets,h);p.minX!==1/0&&(this._buildGrid(p),this._setSceneBoundsAndCenter(p),this._setInitialCameraState(),this._updateCamera())}_clearScene(){for(this._chipletMeshes=[];this._designGroup.children.length>0;){let s=this._designGroup.children[0];this._designGroup.remove(s),s.geometry&&s.geometry.dispose(),s.material&&!s.material._shared&&s.material.dispose()}this._hideTooltip()}_buildChiplets(s,h){let p={minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0};this._edgeMaterial||(this._edgeMaterial=new Zs.LineBasicMaterial({color:0,linewidth:1}),this._edgeMaterial._shared=!0);let m=this._app.useTrueZ?new Array(s.length).fill(0):x5e(s);return s.forEach((_,S)=>{let y=_.width/h,I=_.height/h,N=_.thickness/h*dk,B=uQt[S%uQt.length],P=new Zs.MeshPhongMaterial({color:B,transparent:!1,opacity:1,side:Zs.DoubleSide,shininess:40}),U=new Zs.BoxGeometry(y,I,N),j=new Zs.Mesh(U,P),V=_.x/h+y/2,et=_.y/h+I/2,Q=N*v5e,X=_.z/h*dk+N/2+m[S]*(N+Q);j.position.set(V,et,X),this._designGroup.add(j),this._chipletMeshes.push({mesh:j,data:_,color:B});let gt=new Zs.EdgesGeometry(U),ft=new Zs.LineSegments(gt,this._edgeMaterial);ft.position.set(V,et,X),this._designGroup.add(ft),p.minX=Math.min(p.minX,_.x/h),p.minY=Math.min(p.minY,_.y/h),p.minZ=Math.min(p.minZ,X-N/2),p.maxX=Math.max(p.maxX,_.x/h+y),p.maxY=Math.max(p.maxY,_.y/h+I),p.maxZ=Math.max(p.maxZ,X+N/2)}),p}_buildGrid(s){let h=s.maxX-s.minX,p=s.maxY-s.minY,m=Math.max(h,p)*1.4,_=10,S=new Zs.GridHelper(m,_,8947848,4473924);S.rotation.x=Math.PI/2,S.position.set((s.minX+s.maxX)/2,(s.minY+s.maxY)/2,s.minZ-1),this._designGroup.add(S)}_setSceneBoundsAndCenter(s){this._sceneBounds=s;let h=s.maxX-s.minX,p=s.maxY-s.minY,m=s.maxZ-s.minZ;this._boundingRadius=Math.sqrt(h*h+p*p+m*m)/2,this._sceneCenter.set((s.minX+s.maxX)/2,(s.minY+s.maxY)/2,(s.minZ+s.maxZ)/2)}_stackOffsetForPoint(s,h,p,m){for(let{mesh:_,data:S}of this._chipletMeshes){if(s!==S.z||hS.x+S.width||pS.y+S.height)continue;let y=S.thickness/m*dk,I=S.z/m*dk+y/2;return _.position.z-I}return 0}clearHighlightDRC(){this._drcBlinkInterval&&(clearInterval(this._drcBlinkInterval),this._drcBlinkInterval=null),this._drcMeshGroup&&(this._scene.remove(this._drcMeshGroup),this._drcMeshGroup.children.forEach(s=>{s.geometry&&s.geometry.dispose()}),this._drcMaterial&&(this._drcMaterial.dispose(),this._drcMaterial=null),this._drcHitboxMaterial&&(this._drcHitboxMaterial.dispose(),this._drcHitboxMaterial=null),this._drcHitboxMesh=null,this._drcHitboxMarkerIds=null,this._drcMeshGroup=null,this.render())}highlightDRC(s){if(this._destroyed||(this.clearHighlightDRC(),!s||s.length===0))return;let h=this._app.getDbuPerMicron(),p=0,m=1e4/h*dk;this._sceneBounds&&this._sceneBounds.minZ!==1/0&&(p=this._sceneBounds.minZ,m=this._sceneBounds.maxZ),p-=1,m+=1;let _=Math.max(m-p,1);this._drcMeshGroup=new Zs.Group,this._drcMaterial=new Zs.LineBasicMaterial({color:16776960,transparent:!0,opacity:1,depthTest:!1,depthWrite:!1}),this._drcHitboxMaterial=new Zs.MeshBasicMaterial({transparent:!0,opacity:0,depthWrite:!1});let S=[];for(let N of s){let B=N.rects&&N.rects.length>0?N.rects:[N.bbox];for(let P of B){let[U,j,V,et,Q,X]=P,gt=Math.max((V-U)/h,.001),ft=Math.max((et-j)/h,.001),xt=p,Bt=_,Dt=0;if(P.length>=6&&Q!==void 0&&X!==void 0){xt=Q/h*dk;let Lt=X/h*dk;Bt=Math.max(Lt-xt,.001),Dt=this._stackOffsetForPoint(Q,(U+V)/2,(j+et)/2,h)}let Pt=U/h+gt/2,se=j/h+ft/2,ot=xt+Bt/2+Dt;S.push({cx:Pt,cy:se,cz:ot,width:gt,height:ft,depth:Bt,markerId:N.id})}}if(S.length>0){let N=new Zs.BoxGeometry(1,1,1);this._drcHitboxMesh=new Zs.InstancedMesh(N,this._drcHitboxMaterial,S.length),this._drcHitboxMarkerIds=new Array(S.length);let B=new Zs.Matrix4,P=new Zs.Vector3,U=new Zs.Vector3,j=new Zs.Quaternion;S.forEach((V,et)=>{U.set(V.cx,V.cy,V.cz),P.set(V.width,V.height,V.depth),B.compose(U,j,P),this._drcHitboxMesh.setMatrixAt(et,B),this._drcHitboxMarkerIds[et]=V.markerId;let Q=new Zs.BoxGeometry(V.width,V.height,V.depth),X=new Zs.EdgesGeometry(Q);Q.dispose();let gt=new Zs.LineSegments(X,this._drcMaterial);gt.position.set(V.cx,V.cy,V.cz),gt.renderOrder=999,this._drcMeshGroup.add(gt)}),this._drcHitboxMesh.instanceMatrix.needsUpdate=!0,this._drcMeshGroup.add(this._drcHitboxMesh)}this._drcMeshGroup.renderOrder=999,this._scene.add(this._drcMeshGroup),this.render();let y=!0,I=0;this._drcBlinkInterval=setInterval(()=>{if(!(!this._drcMeshGroup||!this._drcMaterial)){if(I+=1,I>=y5e){this._drcMaterial.opacity=1,this.render(),clearInterval(this._drcBlinkInterval),this._drcBlinkInterval=null;return}y=!y,this._drcMaterial.opacity=y?1:.2,this.render()}},_5e)}refreshSceneForOptions(){this._destroyed||this._lastSceneData&&(this.clearHighlightDRC(),this.buildScene(this._lastSceneData))}};var M5e=[{name:"green",hex:"#00ff00"},{name:"yellow",hex:"#ffff00"},{name:"cyan",hex:"#00ffff"},{name:"magenta",hex:"#ff00ff"},{name:"red",hex:"#ff0000"},{name:"dark_green",hex:"#008000"},{name:"dark_magenta",hex:"#800080"},{name:"blue",hex:"#0000ff"},{name:"orange",hex:"#ffa500"},{name:"purple",hex:"#800080"},{name:"lime",hex:"#bfff00"},{name:"teal",hex:"#008080"},{name:"pink",hex:"#ffc0cb"},{name:"brown",hex:"#8b4513"},{name:"indigo",hex:"#4b0082"},{name:"turquoise",hex:"#40e0d0"}],E5e=[{label:"Connected Insts",suffix:"connected_insts",needsNet:!0},{label:"Output Nets",suffix:"connected_nets",args:{output:!0,input:!1}},{label:"Input Nets",suffix:"connected_nets",args:{output:!1,input:!0}},{label:"All Nets",suffix:"connected_nets",args:{output:!0,input:!0}},{label:"All buffer trees",suffix:"connected_buffer_trees"},{label:"All buffer trees (incl. inverters)",suffix:"connected_buffer_trees",args:{include_inverters:!0}}],Mnt=class{constructor(s){this._app=s,this._el=document.createElement("div"),this._el.className="context-menu",this._el.style.display="none",this._el.style.zIndex="10000",document.body.appendChild(this._el),this._bindEvents()}_bindEvents(){document.addEventListener("mousedown",s=>{this._el.contains(s.target)||this.hide()}),this._app.map&&this._app.map.on("movestart",()=>this.hide())}show(s){this._el.innerHTML="";let h=!!this._app.selHasInst,p=!!this._app.selHasNet,m=!(h||p),_=j=>E5e.map(V=>({label:V.label,disabled:V.needsNet?!p:!h,...j(V.suffix,V.args||{})})),S=[{label:"Select",disabled:m,subMenu:_((j,V)=>({action:()=>this._sendContextAction("select_"+j,V)}))},{label:"Highlight",disabled:m,subMenu:_((j,V)=>({subMenu:this._buildColorSubmenu("highlight_"+j,V)}))},{label:"Save",subMenu:[{label:"Visible layout",action:()=>this._app.captureLayout?.({entire:!1})},{label:"Entire layout",action:()=>this._app.captureLayout?.({entire:!0})}]},{label:"Clear",subMenu:[{label:"Selections",action:()=>this._sendContextAction("clear_selections")},{label:"Highlights",action:()=>this._sendContextAction("clear_highlights")},{label:"Rulers",action:()=>{this._app.rulerManager?.clearAllRulers()}},{label:"Focus nets",action:()=>this._sendContextAction("clear_focus_nets")},{label:"Route Guides",action:()=>this._sendContextAction("clear_route_guides")},{label:"All",action:()=>{this._sendContextAction("clear_all"),this._app.rulerManager?.clearAllRulers()}}]}];this._buildMenu(S,this._el),this._el.style.display="block";let y=4,I=this._el.getBoundingClientRect(),N=window.innerWidth-I.width-y,B=window.innerHeight-I.height-y,P=Math.max(y,Math.min(s.originalEvent.clientX,N)),U=Math.max(y,Math.min(s.originalEvent.clientY,B));this._el.style.left=P+"px",this._el.style.top=U+"px"}hide(){this._el.style.display="none"}_buildColorSubmenu(s,h={}){return M5e.map(({name:p,hex:m},_)=>({label:p,swatch:m,action:()=>this._sendContextAction(s,{...h,group:_})}))}_buildMenu(s,h){s.forEach(p=>{let m=document.createElement("div");if(m.className="cm-item",p.swatch){let _=document.createElement("span");_.className="cm-swatch",_.style.background=p.swatch,m.appendChild(_)}if(m.appendChild(document.createTextNode(p.label)),p.disabled){m.classList.add("disabled"),p.subMenu&&m.classList.add("has-submenu"),h.appendChild(m);return}if(p.subMenu){m.classList.add("has-submenu");let _=document.createElement("div");_.className="cm-submenu",this._buildMenu(p.subMenu,_),m.appendChild(_),m.addEventListener("mouseenter",()=>{_.classList.remove("flip-left"),_.getBoundingClientRect().right>window.innerWidth&&_.classList.add("flip-left")})}else p.action&&m.addEventListener("click",_=>{_.stopPropagation(),this.hide();try{p.action()}catch(S){console.error("Context menu item action threw:",p.label,S)}});h.appendChild(m)})}_sendContextAction(s,h={}){this._app.websocketManager&&this._app.websocketManager.request({type:"context_action",action:s,...h}).then(p=>{fR(this._app,p),p&&p.connected_count===0&&Jw('Nothing connected \u2014 select an instance (or a net for "Connected Insts") first.'),this._syncAfterAction(s)}).catch(p=>{console.error("Context action failed:",s,p)})}_syncAfterAction(s){let h=this._app;(s==="clear_focus_nets"||s==="clear_route_guides"||s==="clear_all")&&typeof h.redrawAllLayers=="function"&&h.redrawAllLayers(),s==="clear_selections"||s==="clear_all"?(h.updateInspector?.(null),h.stopSelectionAnimation?.(),h.highlightRect&&h.map&&(h.map.removeLayer(h.highlightRect),h.highlightRect=null),h.lastSelectionBounds=null):h.refreshInspector?.(),h.refreshOverlay?.()}};function lQt(d,s){if(!d)return;let h=URL.createObjectURL(d),p=document.createElement("a");p.href=h,p.download=s,p.style.display="none",document.body.appendChild(p),p.click(),document.body.removeChild(p),setTimeout(()=>URL.revokeObjectURL(h),0)}function fQt(d){return d.options&&d.options.opacity!=null?d.options.opacity:1}function dQt(d,s,h){if(!s||s.tagName==="IMG"&&(!s.complete||!s.naturalWidth))return;let p=s.getBoundingClientRect();if(!(p.width<=0||p.height<=0))try{d.drawImage(s,p.left-h.left,p.top-h.top,p.width,p.height)}catch{}}function S5e(d,s,h){let p=[];d.map.eachLayer(m=>{m instanceof L.GridLayer&&m._tiles&&p.push(m)}),p.sort((m,_)=>(m.options&&m.options.zIndex||0)-(_.options&&_.options.zIndex||0));for(let m of p){let _=fQt(m);if(!(_<=0)){s.globalAlpha=_;for(let S of Object.keys(m._tiles)){let y=m._tiles[S];!y||!y.current||dQt(s,y.el,h)}}}s.globalAlpha=1}function T5e(d,s,h){let p=d.map.getContainer().querySelectorAll(".leaflet-pane svg"),m=[];return p.forEach(_=>{let S=_.getBoundingClientRect();if(S.width<=0||S.height<=0)return;let y=_.cloneNode(!0);y.setAttribute("width",S.width),y.setAttribute("height",S.height);let I=new XMLSerializer().serializeToString(y),N="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(I);m.push(new Promise(B=>{let P=new Image;P.onload=()=>{try{s.drawImage(P,S.left-h.left,S.top-h.top,S.width,S.height)}catch{}B()},P.onerror=()=>B(),P.src=N}))}),Promise.all(m)}function C5e(d,s,h){d.map.getContainer().querySelectorAll(".leaflet-pane .ruler-label").forEach(m=>{let _=m.getBoundingClientRect();if(_.width<=0||_.height<=0)return;let S=m.textContent;if(!S)return;let y=getComputedStyle(m),I=_.left-h.left,N=_.top-h.top;s.save(),s.fillStyle=y.backgroundColor||"rgba(0, 0, 0, 0.75)";let B=Math.min(parseFloat(y.borderTopLeftRadius)||0,_.height/2);B>0&&typeof s.roundRect=="function"?(s.beginPath(),s.roundRect(I,N,_.width,_.height,B),s.fill()):s.fillRect(I,N,_.width,_.height),s.fillStyle=y.color||"#eee",s.font=y.font||`${y.fontSize||"12px"} ${y.fontFamily||"monospace"}`,s.textAlign="left",s.textBaseline="middle",s.fillText(S,I+(parseFloat(y.paddingLeft)||0),N+_.height/2),s.restore()})}function A5e(d){let s=0;return d.map.eachLayer(h=>{if(!(!(h instanceof L.GridLayer)||!h._tiles)){h._loading&&s++;for(let p of Object.keys(h._tiles)){let m=h._tiles[p],_=m&&m.el;m&&m.current&&_&&_.tagName==="IMG"&&(!_.complete||!_.naturalWidth)&&s++}}}),s}function k5e(d,s=6e3,h=32){return new Promise(p=>{let m=Date.now()+s,_=0,S=()=>{if(A5e(d)===0){if(++_>=2){p();return}}else _=0;if(Date.now()>=m){p();return}setTimeout(S,h)};setTimeout(S,h)})}function L5e(d,s,h){d.map.eachLayer(p=>{if(!(p instanceof L.ImageOverlay))return;let m=fQt(p);m<=0||(s.globalAlpha=m,dQt(s,p._image,h),s.globalAlpha=1)})}async function hQt(d){let s=d.map.getContainer(),h=s.getBoundingClientRect(),p=Math.max(1,Math.round(h.width)),m=Math.max(1,Math.round(h.height)),_=document.createElement("canvas");_.width=p,_.height=m;let S=_.getContext("2d"),y=getComputedStyle(s).backgroundColor;return S.fillStyle=y&&y!=="transparent"&&y!=="rgba(0, 0, 0, 0)"?y:"#000",S.fillRect(0,0,p,m),S5e(d,S,h),L5e(d,S,h),await T5e(d,S,h),C5e(d,S,h),new Promise(I=>_.toBlob(I,"image/png"))}async function pQt(d,{entire:s=!1}={}){if(!d.map)return;if(!s||!d.fitBounds){lQt(await hQt(d),"layout_visible.png");return}let h=d.map.getCenter(),p=d.map.getZoom();try{d.map.fitBounds(d.fitBounds,{animate:!1}),await k5e(d),lQt(await hQt(d),"layout_entire.png")}finally{d.map.setView(h,p,{animate:!1})}}var pk=document.getElementById("websocket-status"),GU=null,P5e=2e3,I5e=20;function K2t(){let d=ht.websocketManager&&ht.websocketManager.isConnected,s=ht.websocketManager?ht.websocketManager.pendingCount:0;if(d)GU&&(clearTimeout(GU),GU=null),s>I5e?(pk.innerHTML=`
pending: ${s}
`,pk.style.display="block"):pk.style.display="none";else{if(ht.websocketManager?._shutdown)return;GU||(GU=setTimeout(()=>{ht.websocketManager?.isConnected||(pk.innerHTML='
\u26A0 OpenROAD disconnected \u2014 retrying\u2026
',pk.style.display="block")},P5e))}R5e(s)}function R5e(d){let s=ht.tileProgressEl;s&&(s.classList.toggle("active",d>0),s.title=d>0?`${d} tile requests pending`:"")}function D5e(d){if(!d)return"";try{return decodeURIComponent(d)}catch{return""}}var ht={map:null,fitBounds:null,lastSelectionBounds:null,selHasInst:!1,selHasNet:!1,displayControlsEl:null,allLayers:[],designScale:null,designMaxDXDY:null,designOriginX:0,designOriginY:0,websocketManager:null,goldenLayout:null,hasLiberty:!1,techData:null,inspectorEl:null,tclOutputEl:null,highlightRect:null,hoverHighlightLayer:null,hoverHighlightPane:"hover-highlight-pane",modulesLayer:null,pinsLayer:null,overlayLayers:[],hierarchyBrowser:null,focusNets:new Set,routeGuideNets:new Set,visibleLayers:new Set,visibleLayerNames:new Set,visibleChiplets:null,layerPatterns:{},useTrueZ:qf("or_use_true_z")==="1",showDbu:qf("or_show_dbu")==="1",rulerStyle:qf("or_ruler_style")==="manhattan"?"manhattan":"euclidian",wheelZoom:qf("or_wheel_zoom")!=="0",arrowStep:dR(qf("or_arrow_step")),fontFamily:D5e(qf("or_font_family")),fontScale:UU(qf("or_font_scale")),polyDecomp:!1,labelManager:null,selectableLayers:new Set,heatMapData:null,activeHeatMap:"",heatMapLayer:null,heatMapLegendEl:null,renderHeatMapControls:null,rulerManager:null,selectionToken:0,selectionResetters:[],getDbuPerMicron(){return this.techData?.dbu_per_micron||1e3},unitOpts(){return{showDbu:this.showDbu,dbuPerMicron:this.getDbuPerMicron()}},formatDbu(d,s=!1){return bJt(d,this.unitOpts(),s)},parseDbu(d){return wJt(d,this.unitOpts())},formatDistance(d){return vJt(d,this.unitOpts())},unitLabel(){return _Jt(this.unitOpts())}},Dd={stdcells:!0,macros:!0,pad_input:!0,pad_output:!0,pad_inout:!0,pad_power:!0,pad_spacer:!0,pad_areaio:!0,pad_other:!0,phys_fill:!1,phys_endcap:!0,phys_welltap:!0,phys_tie:!0,phys_antenna:!0,phys_cover:!0,phys_bump:!0,phys_other:!0,std_bufinv:!0,std_bufinv_timing:!0,std_clock_bufinv:!0,std_clock_gate:!0,std_level_shift:!0,std_sequential:!0,std_combinational:!0,net_signal:!0,net_power:!0,net_ground:!0,net_clock:!0,net_reset:!0,net_tieoff:!0,net_scan:!0,net_analog:!0,inst_names:!0,inst_pins:!0,inst_pin_names:!1,routing:!0,routing_segments:!0,routing_vias:!0,special_nets:!0,srouting_segments:!0,srouting_vias:!0,pins:!0,pin_names:!0,access_points:!1,regions:!0,mfg_grid:!1,gcell_grid:!1,flywires_only:!1,blockages:!0,placement_blockages:!0,routing_obstructions:!0,fills:!1,rows:!1,tracks_pref:!1,tracks_non_pref:!1,module_view:!1,detailed:!1,rulers:!0,labels:!0,scale_bar:!0,focused_nets_guides:!1,highlight_selected:!0,debug:!1};try{let d=qf("or_visibility");if(d){let s=JSON.parse(decodeURIComponent(d));for(let[h,p]of Object.entries(s))Dd[h]=!!p}}catch{}var gk={stdcells:!0,macros:!0,pad_input:!0,pad_output:!0,pad_inout:!0,pad_power:!0,pad_spacer:!0,pad_areaio:!0,pad_other:!0,phys_fill:!0,phys_endcap:!0,phys_welltap:!0,phys_tie:!0,phys_antenna:!0,phys_cover:!0,phys_bump:!0,phys_other:!0,std_bufinv:!0,std_bufinv_timing:!0,std_clock_bufinv:!0,std_clock_gate:!0,std_level_shift:!0,std_sequential:!0,std_combinational:!0,net_signal:!0,net_power:!0,net_ground:!0,net_clock:!0,net_reset:!0,net_tieoff:!0,net_scan:!0,net_analog:!0,pins:!0,inst_pins:!0,placement_blockages:!0,routing_obstructions:!0};ht.visibility=Dd;ht.selectability=gk;try{let d=qf("or_selectability");if(d){let s=JSON.parse(decodeURIComponent(d));for(let[h,p]of Object.entries(s))gk[h]=!!p}}catch{}var N5e=GKt(Dd,ht.visibleLayerNames,gk,ht.selectableLayers,ht);(function(){let s=null;try{s=new URLSearchParams(window.location.search)}catch{s=null}let h=_=>s?s.get(_):null;ht.mergeTiles=h("mergetiles")!=="0";let p=Number(h("tilebudget"));Number.isFinite(p)&&p>0&&(ht.tileBudgetBytes=Math.round(p*1024*1024));let m=Number(h("mergegroups"));Number.isFinite(m)&&m>0&&(ht.mergeGroupCount=Math.floor(m)),ht.tileDpr=ik,ht.MergedTileLayer=QKt({visibility:Dd,selectability:gk,visibleLayers:ht.visibleLayerNames,selectableLayers:ht.selectableLayers,app:ht},{dpr:ik})})();var O5e=L.GridLayer.extend({initialize:function(d,s,h){this._websocketManager=d,this._appState=s,L.GridLayer.prototype.initialize.call(this,nk(h))},_clampZoom:function(d){return L.GridLayer.prototype._clampZoom.call(this,lR(this,d))},createTile:function(d,s){let h=document.createElement("img");h.alt="",h.setAttribute("role","presentation"),h._tileDone=!1,h.onload=()=>{h.src&&h.src.startsWith("blob:")&&URL.revokeObjectURL(h.src),h._tileDone||(h._tileDone=!0,s(null,h))},h.onerror=()=>{h._tileDone||(h._tileDone=!0,s(new Error("heat map tile load error"),h))};let p=this._appState.activeHeatMap;return p?(this._websocketManager.request({type:"heatmap_tile",name:p,z:d.z,x:d.x,y:d.y,...uR(ik(),this.getTileSize().x)}).then(m=>{h.src=m?URL.createObjectURL(m):r3}).catch(()=>{h.src=r3}),h):(h.src=r3,h)},refreshTiles:function(){if(this._map)for(let d in this._tiles){let s=this._tiles[d];if(!s||!s.el)continue;let h=s.el,p=s.coords,m=this._appState.activeHeatMap;if(!m){h.src&&h.src.startsWith("blob:")&&URL.revokeObjectURL(h.src),h.src=r3;continue}this._websocketManager.request({type:"heatmap_tile",name:m,z:p.z,x:p.x,y:p.y,...uR(ik(),this.getTileSize().x)}).then(_=>{h.src&&h.src.startsWith("blob:")&&URL.revokeObjectURL(h.src),h.src=_?URL.createObjectURL(_):r3}).catch(()=>{h.src=r3})}}});function Q2t(d){ht.heatMapData=d,ht.activeHeatMap=d.active||"",ht.heatMapLayer&&(ht.activeHeatMap?ht.map.hasLayer(ht.heatMapLayer)||ht.heatMapLayer.addTo(ht.map):ht.map.hasLayer(ht.heatMapLayer)&&ht.map.removeLayer(ht.heatMapLayer),ht.heatMapLayer.refreshTiles()),ht.renderHeatMapControls&&ht.renderHeatMapControls(d)}ht.updateHeatMaps=Q2t;function txt(){ht.overlayLayer&&ht.overlayLayer.refreshTiles()}var mk=BU(()=>{txt(),ht.selectionBrowser&&ht.selectionBrowser.scheduleRefresh()});ht.refreshOverlay=mk;function N0(){Rd("or_visibility",encodeURIComponent(JSON.stringify(Dd))),Rd("or_selectability",encodeURIComponent(JSON.stringify(gk))),s3();let d=[[ht.modulesLayer,Dd.module_view],[ht.pinsLayer,Dd.pins],...ht.overlayLayers.map(({def:s,layer:h})=>[h,fnt(s.shown_by,Dd)])];for(let[s,h]of d)s&&(h&&!ht.map.hasLayer(s)?s.addTo(ht.map):!h&&ht.map.hasLayer(s)&&ht.map.removeLayer(s));for(let s of ht.allLayers)s.refreshTiles();if(ht.heatMapLayer&&ht.heatMapLayer.refreshTiles(),ht.highlightRect){let s=Dd.highlight_selected!==!1;!s&&ht.map.hasLayer(ht.highlightRect)?ht.map.removeLayer(ht.highlightRect):s&&!ht.map.hasLayer(ht.highlightRect)&&ht.highlightRect.addTo(ht.map)}!Dd.highlight_selected&&ht.clearSelectionPulse&&ht.clearSelectionPulse(),txt(),ht.rulerManager&&ht.rulerManager.updateVisibility(),ht.labelManager&&ht.labelManager.updateVisibility(),ht.updateScaleBar&&ht.updateScaleBar()}var vR=BU(N0),s3=BU(()=>{!ht.websocketManager||Sc(ht)||ht.websocketManager.request({type:"set_display_state",state:rQt()}).catch(()=>{})});ht.syncDisplayState=s3;function B5e(d){if(!d||typeof d!="object")return;let s=d.entries;if(!(!s||typeof s!="object")){sQt(s);try{if(ht.map&&typeof sessionStorage<"u"){let h=ht.map.getCenter();sessionStorage.setItem("or_restore_view",JSON.stringify({lat:h.lat,lng:h.lng,zoom:ht.map.getZoom()}))}}catch{}window.location.reload()}}ht.redrawAllLayers=N0;ht.captureLayout=(d={})=>pQt(ht,d);function F5e(d){let s=document.createElement("div");s.className="layout-viewer",s.style.width="100%",s.style.height="100%",s.style.backgroundColor="var(--bg-map)",d.element.appendChild(s);let h=document.createElement("div");h.className="or-hud or-hud-bottom-right heatmap-map-legend hidden",s.appendChild(h),ht.heatMapLegendEl=h;let p=document.createElement("div");p.className="or-progress",s.appendChild(p),ht.tileProgressEl=p,d.on("destroy",()=>{ht.tileProgressEl=null,ht.heatMapLegendEl=null}),ht.map=L.map(s,dJt(void 0,{wheelZoom:ht.wheelZoom,arrowStep:ht.arrowStep})),Sc(ht)||EJt(ht.map,()=>ht.wheelZoom),sJt(ht.map),jKt(()=>N0());let m=ht.map.createPane(ht.hoverHighlightPane);m.style.zIndex="650",m.style.pointerEvents="none";let _=L.Control.extend({onAdd:function(){let X=L.DomUtil.create("div","leaflet-bar leaflet-control leaflet-control-fit"),gt=L.DomUtil.create("a","",X);return gt.href="#",gt.title="Fit",gt.setAttribute("role","button"),gt.setAttribute("aria-label","Fit"),gt.textContent="\u2922",L.DomEvent.on(gt,"click",L.DomEvent.stop).on(gt,"click",()=>{ht.fitBounds&&ht.map.fitBounds(ht.fitBounds)}),X}});new _({position:"topleft"}).addTo(ht.map),new ResizeObserver(()=>{ht.map.invalidateSize({animate:!1})}).observe(s);let S=document.createElement("div");S.className="or-hud or-hud-bottom-left hidden";let y=document.createElement("div");y.id="scale-bar";let I=document.createElement("span");I.className="or-hud-divider";let N=document.createElement("div");N.id="coord-bar",S.appendChild(y),S.appendChild(I),S.appendChild(N),s.appendChild(S);function B(){let X=y.style.display!=="none"&&y.childElementCount>0,gt=N.textContent!=="";I.style.display=X&>?"":"none",S.classList.toggle("hidden",!X&&!gt)}B(),ht.map.on("mousemove",X=>{if(ht.lastMouseLatLng=X.latlng,!ht.designScale)return;let{dbuX:gt,dbuY:ft}=Yw(X.latlng.lat,X.latlng.lng,ht.designScale,ht.designMaxDXDY,ht.designOriginX,ht.designOriginY);N.textContent=`X: ${ht.formatDbu(gt)} Y: ${ht.formatDbu(ft)}`,B()}),ht.map.on("mouseout",X=>{let gt=X.originalEvent&&X.originalEvent.relatedTarget;gt&&s.contains(gt)||(ht.lastMouseLatLng=null,N.textContent="",B())});let P=22,U=8,j=22;function V(X,gt,ft){let Bt=2+U,Dt=j,Pt=j+X,se=P-2,ot=X>=40,Lt=[];if(Lt.push(``),ot&&ft>1)for(let be=1;be`)}ot&&Lt.push(`0`),Lt.push(`${gt}`),y.innerHTML=`${Lt.join("")}`}function et(){if(!ht.designScale||!Dd.scale_bar){y.style.display="none",B();return}let X=ht.designScale*Math.pow(2,ht.map.getZoom()),gt=ht.map.getContainer().clientWidth||400,ft=xJt({targetPx:gt*.15,pxPerDbu:X,dbuPerMicron:ht.techData?.dbu_per_micron,showDbu:ht.showDbu});if(!ft){y.style.display="none",B();return}y.style.display="",V(ft.barPx,ft.label,ft.segments),B()}let Q=BU(et);ht.map.on("zoom zoomend resize",Q),ht.updateScaleBar=et,ht.rulerManager=new mnt(ht,Dd,WU,Ent),ht.labelManager=new bnt(ht,Dd,WU,Ent)}function U5e(d){let s=document.createElement("div");s.className="display-controls",s.innerHTML='
Loading layers...
',d.element.appendChild(s),ht.displayControlsEl=s}var J2t="or_restore_console",z5e=1<<20;function j5e(){try{if(ht.tclOutputEl){let d=[...ht.tclOutputEl.children].map(m=>[m.textContent,m.className]),s=d.length,h=0;for(;s>0&&h+d[s-1][0].length<=z5e;)h+=d[--s][0].length;let p=d.slice(s);s>0&&p.unshift([`[earlier output not kept across reload] -`,""]),sessionStorage.setItem(J2t,JSON.stringify(p))}}catch{}window.location.reload()}function H5e(){try{let d=sessionStorage.getItem(J2t);if(!d)return;sessionStorage.removeItem(J2t);for(let[s,h]of JSON.parse(d))gS(s,h)}catch{}}function gS(d,s){if(!ht.tclOutputEl)return;let h=document.createElement("span");s&&(h.className=s),h.textContent=d,ht.tclOutputEl.appendChild(h),ht.tclOutputEl.scrollTop=ht.tclOutputEl.scrollHeight}function G5e(){if(ht._shutdownHandled)return;ht._shutdownHandled=!0,ht.websocketManager&&(ht.websocketManager._shutdown=!0,ht.websocketManager.onPush=()=>{});let d=document.createElement("div");d.style.cssText="position:fixed;inset:0;z-index:99999;background:#1e1e1e;color:#ddd;display:flex;flex-direction:column;align-items:center;justify-content:center;font-family:system-ui,sans-serif;font-size:16px;padding:24px;text-align:center;",d.innerHTML='
OpenROAD exited
You can close this tab.
',document.body.appendChild(d),setTimeout(()=>{try{window.close()}catch{}},1500)}function W5e(d){let s=document.createElement("div");if(s.className="tcl-console",s.innerHTML='
%
',d.element.appendChild(s),ht.tclOutputEl=s.querySelector(".tcl-output"),H5e(),Sc(ht)){s.querySelector(".tcl-input-row").style.display="none";let m=document.createElement("span");m.className="tcl-static-notice",m.setAttribute("role","status"),m.setAttribute("aria-live","polite"),m.textContent="Tcl console is not available in saved reports.",ht.tclOutputEl.appendChild(m);return}let h=s.querySelector(".tcl-input"),p=new _nt(h,ht.websocketManager);h.addEventListener("keydown",m=>{if(!p.handleKeyDown(m)&&m.key==="Enter"){let _=h.value.trim();if(!_)return;gS(`>>> ${_} -`,"tcl-cmd"),p.addToHistory(_),h.value="",ht.websocketManager.request({type:"tcl_eval",cmd:_}).then(S=>{S.result&&gS(S.result+` -`,S.is_error?"tcl-error":""),S.action==="shutdown"&&G5e(),!S.is_error&&ht.drcWidget&&ht.drcWidget.refresh()}).catch(S=>gS(`Error: ${S} -`,"tcl-error"))}})}ht.visibility=Dd;var mS=OJt(ht,N0,mk),$5e=mS.createInspector,WU=mS.updateInspector,V5e=mS.highlightBBox,q5e=mS.pulseHighlight;ht.updateInspector=WU;ht.navigateInspector=mS.navigateInspector;ht.refreshInspector=mS.refreshInspector;ht.animateSelection=mS.animateSelection;ht.stopSelectionAnimation=mS.stopSelectionAnimation;function X5e(d){new cnt(d,ht,N0)}function Z5e(d){ht.timingWidget=new ak(ht,N0,mk),d.element.appendChild(ht.timingWidget.element)}function Y5e(d){ht.drcWidget=new vnt(ht,N0,mk),d.element.appendChild(ht.drcWidget.element)}function K5e(d){ht.clockTreeWidget=new snt(d,ht,N0,mk)}function J5e(d){ht.chartsWidget=new ont(ht,N0),d.element.appendChild(ht.chartsWidget.element)}function Q5e(d){let s=document.createElement("div");s.className="help-panel",s.innerHTML="

Keyboard Shortcuts

fFit design to viewport
scrollZoom in/out
dragPan the view
right-dragRubber-band zoom
Shift+clickAdd object to selection
Ctrl/Cmd+clickSelect object and its connected nets
kToggle ruler mode
Shift+KClear all rulers
EscapeCancel ruler (when building)
",d.element.appendChild(s)}function tLe(d){ht.selectionBrowser=new ant(d,ht,mk)}function eLe(d){new wnt(d,ht)}function nLe(d){ht.threeDViewerWidget=new xnt(d,ht)}var iLe=28,rLe={dimensions:{headerHeight:iLe},root:{type:"row",content:[{type:"component",componentType:"DisplayControls",title:"Display Controls",width:15},{type:"column",width:55,content:[{type:"stack",height:70,content:[{type:"component",componentType:"LayoutViewer",title:"Layout",isClosable:!1},{type:"component",componentType:"SchematicWidget",title:"Schematic"},{type:"component",componentType:"3DViewer",title:"3D Viewer"}]},{type:"component",componentType:"TclConsole",title:"Tcl Console",height:30}]},{type:"stack",width:30,content:[{type:"component",componentType:"Inspector",title:"Inspector"},{type:"component",componentType:"Browser",title:"Hierarchy"},{type:"component",componentType:"TimingWidget",title:"Timing"},{type:"component",componentType:"DRCWidget",title:"DRC"},{type:"component",componentType:"SelectHighlight",title:"Select Highlight"},{type:"component",componentType:"ClockWidget",title:"Clock Tree"},{type:"component",componentType:"ChartsWidget",title:"Charts"},{type:"component",componentType:"HelpWidget",title:"Help"}]}]}};ht.goldenLayout=new Zet(document.getElementById("gl-container"));ht.goldenLayout.registerComponentFactoryFunction("LayoutViewer",F5e);ht.goldenLayout.registerComponentFactoryFunction("DisplayControls",U5e);ht.goldenLayout.registerComponentFactoryFunction("TclConsole",W5e);ht.goldenLayout.registerComponentFactoryFunction("Inspector",$5e);ht.goldenLayout.registerComponentFactoryFunction("Browser",X5e);ht.goldenLayout.registerComponentFactoryFunction("TimingWidget",Z5e);ht.goldenLayout.registerComponentFactoryFunction("DRCWidget",Y5e);ht.goldenLayout.registerComponentFactoryFunction("ClockWidget",K5e);ht.goldenLayout.registerComponentFactoryFunction("ChartsWidget",J5e);ht.goldenLayout.registerComponentFactoryFunction("SchematicWidget",eLe);ht.goldenLayout.registerComponentFactoryFunction("3DViewer",nLe);ht.goldenLayout.registerComponentFactoryFunction("HelpWidget",Q5e);ht.goldenLayout.registerComponentFactoryFunction("SelectHighlight",tLe);var My=window.__STATIC_CACHE__||null;if(My)UKt(),ht.websocketManager=RU.fromCache(My,K2t);else{let d=`ws://${window.location.host||"localhost:8080"}/ws`;ht.websocketManager=new RU(d,K2t),ht.layerExtents=new Jet,ht.websocketManager.onReconnected=()=>{Snt(),ixt(null,null,{reloadOnChange:!0}).catch(()=>{})}}K2t();ht.goldenLayout.loadLayout(rLe);gQt();function gQt(){MJt(document.getElementById("gl-container"))>0&&ht.goldenLayout.updateSize()}ht.goldenLayout.on("stateChanged",()=>{gQt()});function ext(){ht.goldenLayout.updateSize()}ht.syncLayoutSize=ext;window.addEventListener("resize",ext);function Ent(d){ht.goldenLayout.focusComponent(d)}ht.focusComponent=Ent;ht.resetLayout=function(){ht.goldenLayout&&typeof ht.goldenLayout.resetLayout=="function"&&ht.goldenLayout.resetLayout()};ht.toggleTheme=function(){let d=document.documentElement.dataset.theme==="dark"?"light":"dark";document.documentElement.dataset.theme=d,U2t(d),ent(d),ht.chartsWidget&&ht.chartsWidget.render(),ht.clockTreeWidget&&ht.clockTreeWidget.render(),s3()};ht.toggleShowDbu=function(){ht.showDbu=!ht.showDbu,Rd("or_show_dbu",ht.showDbu?"1":"0"),ht.rulerManager&&ht.rulerManager._rerenderAll(),ht.hierarchyBrowser&&ht.hierarchyBrowser._render(),ht.updateScaleBar&&ht.updateScaleBar(),ht.refreshInspector&&ht.refreshInspector(),s3()};ht.toggleRulerStyle=function(){ht.rulerStyle=ht.rulerStyle==="manhattan"?"euclidian":"manhattan",Rd("or_ruler_style",ht.rulerStyle),s3()};ht.toggleWheelZoom=function(){ht.wheelZoom=!ht.wheelZoom,Rd("or_wheel_zoom",ht.wheelZoom?"1":"0"),s3()};ht.setArrowStep=function(d){ht.arrowStep=dR(d),Rd("or_arrow_step",String(ht.arrowStep)),pJt(ht.map,ht.arrowStep),s3()};ht.setAppFont=function({family:d,scale:s}){ht.fontFamily=d??ht.fontFamily,ht.fontScale=UU(s??ht.fontScale),Rd("or_font_family",encodeURIComponent(ht.fontFamily)),Rd("or_font_scale",String(ht.fontScale)),ht.applyAppFont(),s3()};ht.applyAppFont=function(){let d=document.documentElement;ht.fontFamily?d.style.setProperty("--or-font-family",ht.fontFamily):d.style.removeProperty("--or-font-family"),d.style.setProperty("--or-font-scale",String(ht.fontScale/100)),ht.chartsWidget&&ht.chartsWidget.render(),ht.clockTreeWidget&&ht.clockTreeWidget.render()};ht.showArrowStepDialog=()=>UJt(ht);ht.showAppFontDialog=()=>zJt(ht);ht.togglePolyDecomp=function(){ht.websocketManager&&ht.websocketManager.request({type:"poly_decomp",value:!ht.polyDecomp}).then(d=>nxt(d.value)).catch(()=>{})};function nxt(d){ht.polyDecomp=!!d,ht.rebuildMenuBar&&ht.rebuildMenuBar(),ht.refreshOverlay&&ht.refreshOverlay()}ht.applyAppFont();ht.echoTcl=d=>gS(`>>> ${d} -`,"tcl-cmd");ht.runTclScript=(d,s)=>d?(s&&ht.echoTcl(d),ht.websocketManager.request({type:"tcl_eval",cmd:d}).then(h=>(h&&h.result&&gS(h.result+` -`,h.is_error?"tcl-error":""),h)).catch(h=>{gS(`Error: ${h} -`,"tcl-error")})):Promise.resolve();function mQt(d){d&&(ht.customMenu=d.menu||[],ht.customToolbar=d.toolbar||[],ht.rebuildMenuBar&&ht.rebuildMenuBar(),ht.rebuildToolbar&&ht.rebuildToolbar(),ext())}ht.customMenu=[];ht.customToolbar=[];ht.scheduleRedrawAllLayers=vR;ht.showGlobalConnectDialog=()=>KJt(ht);ht.showInsertBufferDialog=d=>JJt(ht,d);qJt(ht);XJt(ht);ht.contextMenu=new Mnt(ht);function sLe(){let d=document.getElementById("debug-continue-btn");return d||(d=document.createElement("button"),d.id="debug-continue-btn",d.className="debug-continue-btn",d.textContent="Continue",d.title="Advance the debugger (gpl, cts, ...)",d.addEventListener("click",()=>{ht.websocketManager.request({type:"debug_continue"}).catch(()=>{})}),(document.getElementById("menu-bar")||document.body).appendChild(d),d)}function bQt(d,s){let h=B2t(d,Kw(),s);return h?(ht.currentBounds=d,ht.designScale=h.scale,ht.designMaxDXDY=h.maxDXDY,ht.designOriginX=h.originX,ht.designOriginY=h.originY,ht.fitBounds=h.fitBounds,ht.map.setMaxZoom(gJt(h.scale)),!0):!1}async function ixt(d,s,{reloadOnChange:h=!1}={}){if(Sc(ht)||!ht.map)return!1;let p=d,m=s;if(!p)try{let y=await ht.websocketManager.request({type:"bounds"});p=y.bounds,m=y.fit_bounds}catch{return!1}if(!p||hJt(ht.currentBounds,p))return!1;if(h)return window.location.reload(),!0;let S=!!ht.designScale?Yw(ht.map.getCenter().lat,ht.map.getCenter().lng,ht.designScale,ht.designMaxDXDY,ht.designOriginX,ht.designOriginY):null;if(!bQt(p,m))return!1;if(S){let y=Id(S.dbuX,S.dbuY,ht.designScale,ht.designMaxDXDY,ht.designOriginX,ht.designOriginY);ht.map.setView(y,ht.map.getZoom(),{animate:!1})}return ht.highlightRect&&(ht.map.removeLayer(ht.highlightRect),ht.highlightRect=null),N0(),!0}function oLe(){let d=document.getElementById("loading-overlay");d.style.display="flex";let s=()=>{d.style.display!=="none"&&ht.websocketManager.request({type:"bounds"}).then(h=>{h.shapes_ready&&(d.style.display="none")}).catch(()=>{}).finally(()=>{d.style.display!=="none"&&setTimeout(s,1e3)})};setTimeout(s,1e3)}function Snt(){ht.layerExtents&&ht.layerExtents.refetch(d=>ht.websocketManager.request(d))}function cLe(d){document.getElementById("loading-overlay").style.display="none",Snt(),ixt(d.bounds,d.fit_bounds).then(s=>{s||N0()}).catch(()=>N0()),ht.refreshInspector&&ht.refreshInspector()}function aLe(){let d=document.getElementById("script-running-badge");return d||(d=document.createElement("span"),d.id="script-running-badge",d.className="script-running-badge",d.textContent="Script running",d.title="The view updates when the script pauses or finishes",(document.getElementById("menu-bar")||document.body).appendChild(d),d)}function uLe(d){if(ht.scriptRunning=d,aLe().style.display=d?"block":"none",!d){if(!ht.booted||!ht.designScale){j5e();return}ht.refreshPending&&(ht.refreshPending=!1,Snt(),ht.refreshInspector&&ht.refreshInspector()),ixt().then(s=>{s||vR()}).catch(()=>vR())}}ht.websocketManager.onPush=d=>{if(d.type==="refresh"){if(ht.scriptRunning){ht.refreshPending=!0;return}cLe(d)}else if(d.type==="script_running")uLe(!!d.running);else if(d.type==="renderer_controls_changed")ht.refreshRendererControls&&ht.refreshRendererControls(),vR();else if(d.type==="selection_invalidated")ht.updateInspector&&ht.updateInspector(null),ht.stopSelectionAnimation&&ht.stopSelectionAnimation(),ht.highlightRect&&ht.map&&(ht.map.removeLayer(ht.highlightRect),ht.highlightRect=null),mk();else if(d.type==="heatmaps_changed")ht.websocketManager.request({type:"heatmaps"}).then(Q2t).catch(s=>console.error("Heat map refresh failed",s));else if(d.type==="labels_changed")ht.labelManager&&ht.labelManager.applyRemoteLabels(d.labels);else if(d.type==="drcUpdated")ht._drcUpdateTimeout&&clearTimeout(ht._drcUpdateTimeout),ht._drcUpdateTimeout=setTimeout(()=>{ht.drcWidget&&ht.drcWidget.refresh()},500);else if(d.type==="debug_paused")ht.refreshRendererControls&&ht.refreshRendererControls(),sLe().style.display="block",vR(),ht.chartsWidget&&ht.websocketManager.request({type:"debug_charts"}).then(s=>ht.chartsWidget.setDebugCharts(s.charts||[])).catch(()=>{});else if(d.type==="debug_resumed"){let s=document.getElementById("debug-continue-btn");s&&(s.style.display="none")}else if(d.type==="debug_refresh"){if(ht.scriptRunning)return;ht.highlightRect&&(ht.map.removeLayer(ht.highlightRect),ht.highlightRect=null),vR()}else if(d.type==="log"){let s=d.text;s.endsWith(` -`)&&(s=s.slice(0,-1)),s&&gS(s+` -`,"")}else d.type==="restore_display_state"?B5e(d.state):d.type==="custom_ui"?mQt(d):d.type==="poly_decomp"?nxt(d.value):d.type==="shutdown"&&(ht.websocketManager._shutdown=!0,pk.innerHTML='
Server stopped
',pk.style.display="block")};ht.websocketManager.readyPromise.then(async()=>{try{let S=function(y,I={}){let{addToSelection:N=!1,focusInspector:B=!0,context:P=!1,showConnectivity:U=!1}=I;if(!ht.designScale)return Promise.resolve(null);let{dbuX:j,dbuY:V}=Yw(y.lat,y.lng,ht.designScale,ht.designMaxDXDY,ht.designOriginX,ht.designOriginY);if(ht.labelManager&&ht.labelManager.isActive()){ht.labelManager.handleMapClick(j,V);return}let et=uJt(Dd,gk),Q={type:"select",dbu_x:j,dbu_y:V,zoom:Math.round(ht.map.getZoom()),visible_layers:[...ht.visibleLayerNames],selectable_layers:[...ht.selectableLayers],use_dbu:ht.showDbu,...et};N&&(Q.add_to_selection=!0),P&&(Q.context=!0),U&&(Q.show_connectivity=!0),ht.visibleChiplets instanceof Set&&(Q.visible_chiplets=[...ht.visibleChiplets]);let X=bg(ht);return ht.websocketManager.request(Q).then(gt=>{if(D0(ht,X)){if(console.log("Select response:",gt,"at dbu",j,V),ht.map.closePopup(),fR(ht,gt),gt.selected&>.selected.length>0){let ft=gt.selected[0];ft.type==="Inst"&&(ht.selectedInstanceName=ft.name,ht.schematicWidget&&ht.schematicWidget.refresh()),WU(gt),B&&Ent("Inspector"),gt.bbox&&(V5e(gt.bbox[0],gt.bbox[1],gt.bbox[2],gt.bbox[3],gt.type),q5e(gt.bbox,gt.type),ht.lastSelectionBounds=Vf(gt.bbox[0],gt.bbox[1],gt.bbox[2],gt.bbox[3],ht.designScale,ht.designMaxDXDY,ht.designOriginX,ht.designOriginY)),Q.show_connectivity&>.connected_added>0&&Jw(`Selected ${gt.connected_added} connected net`+(gt.connected_added>1?"s":""))}else!N&&!P&&(WU(null),ht.highlightRect&&(ht.map.removeLayer(ht.highlightRect),ht.highlightRect=null),ht.lastSelectionBounds=null);return txt(),gt}}).catch(gt=>(console.error("Select failed:",gt),null))},[d,s,h]=await Promise.all([ht.websocketManager.request({type:"tech"}),ht.websocketManager.request({type:"bounds"}),ht.websocketManager.request({type:"heatmaps"})]);Snt(),ht.hasLiberty=d.has_liberty,ht.techData=d,oQt(d.block_name),ht.websocketManager.request({type:"custom_ui"}).then(mQt).catch(()=>{}),ht.websocketManager.request({type:"poly_decomp"}).then(y=>nxt(y.value)).catch(()=>{});let p=s.bounds,m=s.fit_bounds;if(!My){let y=ht.map.getSize();zKt(mJt({designBounds:p,fitRect:m,viewW:y.x,viewH:y.y}))}let _=bQt(p,m);if(_){if(ht.labelManager&&ht.labelManager.reload(),ht.map.fitBounds(ht.fitBounds),My){let y=My.zoom;ht.map.setMinZoom(y),ht.map.setMaxZoom(y),ht.map.fitBounds(ht.fitBounds),ht.map.scrollWheelZoom.disable(),ht.map.touchZoom.disable(),ht.map.boxZoom.disable(),ht.map.doubleClickZoom.disable(),ht.pathOverlay=L.imageOverlay("",Vf(p[0][1],p[0][0],p[1][1],p[1][0],ht.designScale,ht.designMaxDXDY,ht.designOriginX,ht.designOriginY),{opacity:1,interactive:!1,zIndex:1e3}),My.setPathOverlay=I=>{I?(ht.pathOverlay.setUrl(I),ht.pathOverlay.addTo(ht.map)):ht.map.removeLayer(ht.pathOverlay)}}try{let y=sessionStorage.getItem("or_restore_view");if(y){sessionStorage.removeItem("or_restore_view");let I=JSON.parse(y);I&&isFinite(I.lat)&&isFinite(I.lng)&&isFinite(I.zoom)&&ht.map.setView([I.lat,I.lng],I.zoom)}}catch{}}if(My&&(document.getElementById("loading-overlay").style.display="none"),ht.selectAtLatLng=S,My||ht.map.on("click",y=>{if(ht.rulerManager&&ht.rulerManager.isActive())return;let I=y.originalEvent;S(y.latlng,{addToSelection:!!(I&&I.shiftKey),showConnectivity:!!(I&&(I.ctrlKey||I.metaKey))})}),!My){let y=ht.map.getContainer(),I=null,N=null;y.addEventListener("contextmenu",B=>{B.preventDefault()}),y.addEventListener("mousedown",B=>{B.button===2&&(I={x:B.clientX,y:B.clientY},ht.map.dragging.disable())}),window.addEventListener("mousemove",B=>{if(!I)return;let P=B.clientX-I.x,U=B.clientY-I.y;if(!N&&Math.abs(P)>=4&&Math.abs(U)>=4&&(N=document.createElement("div"),N.className="rubber-band",document.body.appendChild(N)),N){let j=Math.min(I.x,B.clientX),V=Math.min(I.y,B.clientY);N.style.left=j+"px",N.style.top=V+"px",N.style.width=Math.abs(P)+"px",N.style.height=Math.abs(U)+"px"}}),window.addEventListener("mouseup",B=>{if(!I)return;let P=!!N;N&&(N.remove(),N=null);let U=I;I=null,ht.map.dragging.enable();let j=y.getBoundingClientRect();if(P){let Q=ht.map.containerPointToLatLng([U.x-j.left,U.y-j.top]),X=ht.map.containerPointToLatLng([B.clientX-j.left,B.clientY-j.top]);ht.map.fitBounds([[Math.min(Q.lat,X.lat),Math.min(Q.lng,X.lng)],[Math.max(Q.lat,X.lat),Math.max(Q.lng,X.lng)]]);return}if(!(B.clientX>=j.left&&B.clientX<=j.right&&B.clientY>=j.top&&B.clientY<=j.bottom)||ht.rulerManager&&ht.rulerManager.isActive())return;let et=ht.map.containerPointToLatLng([B.clientX-j.left,B.clientY-j.top]);ht.selectAtLatLng(et,{context:!0,focusInspector:!1}).then(()=>ht.contextMenu.show({originalEvent:B}))})}if(GJt(ht,Dd,gk,N5e,d,N0,O5e),!ht.overlayLayer&&!My){let y=WKt(Dd,ht);ht.overlayLayer=new y(ht.websocketManager,{zIndex:ht.allLayers.length+5,opacity:1}),ht.overlayLayer.addTo(ht.map)}Q2t(h),_&&!s.shapes_ready&&oLe(),s3(),ht.booted=!0}catch(d){ht.scriptRunning||console.error("Failed to load initial data from server:",d)}});document.addEventListener("openroad-cone-sync",d=>{ht.schematicWidget?.syncCone(d.detail||{})});document.addEventListener("keydown",d=>{let s=d.target.tagName;if(s==="INPUT"||s==="TEXTAREA"||d.target.isContentEditable)return;let h=d.key.toLowerCase();h==="escape"&&ht.rulerManager&&ht.rulerManager.isActive()?ht.rulerManager.cancelRulerBuild():h==="escape"&&ht.labelManager&&ht.labelManager.isActive()?ht.labelManager.cancelLabelMode():h==="k"&&!d.shiftKey&&!d.ctrlKey&&!d.metaKey?ht.rulerManager&&ht.rulerManager.toggleRulerMode():h==="k"&&d.shiftKey&&!d.ctrlKey&&!d.metaKey?ht.rulerManager&&ht.rulerManager.clearAllRulers():h==="l"&&!d.shiftKey&&!d.ctrlKey&&!d.metaKey?ht.labelManager&&ht.labelManager.toggleLabelMode():h==="f"&&!d.ctrlKey&&!d.metaKey&&ht.fitBounds?ht.map.fitBounds(ht.fitBounds):h==="z"&&!d.shiftKey&&!d.ctrlKey&&ht.map?ht.lastMouseLatLng?ht.map.setZoomAround(ht.lastMouseLatLng,ht.map.getZoom()+1):ht.map.zoomIn():h==="z"&&d.shiftKey&&!d.ctrlKey&&ht.map?ht.lastMouseLatLng?ht.map.setZoomAround(ht.lastMouseLatLng,ht.map.getZoom()-1):ht.map.zoomOut():h==="f"&&(d.ctrlKey||d.metaKey)?(d.preventDefault(),ht.designScale&&dnt(ht)):h==="g"&&d.shiftKey&&!d.ctrlKey&&!d.metaKey?(d.preventDefault(),ht.designScale&&pnt(ht)):h==="t"&&!d.shiftKey&&!d.ctrlKey&&!d.metaKey&&ht.toggleTheme()},!0);})(); + `,document.body.appendChild(this._overlay),this._breadcrumb=this._overlay.querySelector(".fb-breadcrumb"),this._fileList=this._overlay.querySelector(".fb-file-list"),this._pathInput=this._overlay.querySelector(".fb-path-input"),this._errorDiv=this._overlay.querySelector(".modal-error"),this._okBtn=this._overlay.querySelector(".ok"),this._cancelBtn=this._overlay.querySelector(".cancel"),this._listen(this._pathInput,"input",()=>this._updateOkState()),this._listen(this._pathInput,"keydown",n=>{if(n.key==="Enter"){let r=this._pathInput.value.trim();r.endsWith("/")?this._navigate(r.replace(/\/+$/,"")||"/"):this._submit()}else n.key==="Escape"&&this.close()}),this._listen(this._okBtn,"click",()=>this._submit()),this._listen(this._cancelBtn,"click",()=>this.close()),this._listen(this._overlay,"click",n=>{n.target===this._overlay&&this.close()}),this._navigate("")}close(){if(!this._closed){this._closed=!0;for(let n of this._disposers)n();this._disposers.length=0,this._overlay&&(this._overlay.remove(),this._overlay=null)}}_listen(n,r,c){n.addEventListener(r,c),this._disposers.push(()=>n.removeEventListener(r,c))}_updateOkState(){this._okBtn.disabled=!this._pathInput.value.trim()}_renderBreadcrumb(n){this._breadcrumb.innerHTML="";let r=n.split("/").filter(Boolean),c=document.createElement("span");c.className="fb-crumb",c.textContent="/",this._listen(c,"click",()=>this._navigate("/")),this._breadcrumb.appendChild(c);let u="";for(let d of r){u+="/"+d;let b=document.createElement("span");b.className="fb-crumb-sep",b.textContent=" / ",this._breadcrumb.appendChild(b);let w=document.createElement("span");w.className="fb-crumb",w.textContent=d;let _=u;this._listen(w,"click",()=>this._navigate(_)),this._breadcrumb.appendChild(w)}}_renderEntries(n){if(this._fileList.innerHTML="",!n||n.length===0){let r=document.createElement("div");r.className="fb-empty",r.textContent="(empty directory)",this._fileList.appendChild(r);return}for(let r of n){let c=document.createElement("div");c.className="fb-entry",r.is_dir&&c.classList.add("fb-dir");let u=document.createElement("span");u.className="fb-icon",u.textContent=r.is_dir?"\u{1F4C1}":"\u{1F4C4}",c.appendChild(u);let d=document.createElement("span");d.className="fb-name",d.textContent=r.name,c.appendChild(d),r.is_dir?this._listen(c,"click",()=>this._navigate(this._currentPath+"/"+r.name)):(this._listen(c,"click",()=>{let b=this._fileList.querySelector(".fb-selected");b&&b.classList.remove("fb-selected"),c.classList.add("fb-selected"),this._pathInput.value=this._currentPath+"/"+r.name,this._updateOkState()}),this._listen(c,"dblclick",()=>{this._pathInput.value=this._currentPath+"/"+r.name,this._updateOkState(),this._submit()})),this._fileList.appendChild(c)}}async _navigate(n){this._errorDiv.style.display="none",this._fileList.innerHTML='
Loading...
';try{let r=await this._app.websocketManager.request({type:"list_dir",path:n||""});if(this._closed)return;this._currentPath=r.path,this._renderBreadcrumb(r.path),this._renderEntries(r.entries),this._pathInput.value="",this._updateOkState()}catch(r){if(this._closed)return;this._fileList.innerHTML="",this._errorDiv.textContent=r.message||String(r),this._errorDiv.style.display=""}}async _submit(){let n=this._pathInput.value.trim();if(n){this._okBtn.disabled=!0,this._okBtn.textContent="Loading...",this._errorDiv.style.display="none";try{let r=await this._app.websocketManager.request({type:"drc_load_report",path:n});if(this._closed)return;if(r.ok){let c=r.category;this.close(),this._onLoaded(c)}else this._errorDiv.textContent=r.error||"Failed to load report",this._errorDiv.style.display="",this._okBtn.disabled=!1,this._okBtn.textContent="Load"}catch(r){if(this._closed)return;this._errorDiv.textContent=r.message||"Request failed",this._errorDiv.style.display="",this._okBtn.disabled=!1,this._okBtn.textContent="Load"}}}};var npn=` +\r[]{}`;var fde=class{constructor(n,r){this._input=n,this._ws=r,this._popup=null,this._items=[],this._selectedIndex=-1,this._replaceStart=0,this._replaceEnd=0,this._debounceTimer=null,this._commandCache=null,this._history=[],this._historyIndex=-1,this._historyStash="",this._createPopup(),this._onInputBound=this._onInput.bind(this),this._onBlurBound=this._onBlur.bind(this),this._input.addEventListener("input",this._onInputBound),this._input.addEventListener("blur",this._onBlurBound)}_createPopup(){this._popup=document.createElement("div"),this._popup.className="tcl-complete-popup",this._popup.style.display="none",this._input.parentElement.appendChild(this._popup)}handleKeyDown(n){let r=this._popup.style.display!=="none";return n.key==="Tab"?(n.preventDefault(),r?this._tabAccept():this._tabComplete(this._input.value,this._input.selectionStart),!0):n.key==="Escape"?r?(this._hidePopup(),!0):!1:n.key==="ArrowDown"?r?(n.preventDefault(),this._selectItem(this._selectedIndex+1),!0):this._historyIndex>=0?(n.preventDefault(),this._historyIndex--,this._historyIndex<0?this._input.value=this._historyStash:this._input.value=this._history[this._historyIndex],!0):!1:n.key==="ArrowUp"?r?(n.preventDefault(),this._selectItem(this._selectedIndex-1),!0):this._historyIndex{let n=this._input.value,r=this._input.selectionStart,c=this._extractPrefix(n,r);c.length>=2||c.length>=1&&(c[0]==="$"||c[0]==="-")?this._requestCompletions(n,r):this._hidePopup()},100)}_onBlur(){setTimeout(()=>this._hidePopup(),150)}_extractPrefix(n,r){let c=r-1;for(;c>=0&&npn.indexOf(n[c])===-1;)c--;return n.substring(c+1,r)}_fetchCompletions(n,r,c){let u=this._extractPrefix(n,r),d=u.length>0&&u[0]==="$",b=u.length>0&&u[0]==="-",w=!d&&!b,_=r-u.length,x=n.substring(0,_),T=/^[\s\[]*$/.test(x);if(w&&T&&this._commandCache){let M=u.toLowerCase(),L=this._commandCache.filter(I=>I.toLowerCase().startsWith(M));c(L,_,r);return}this._ws.request({type:"tcl_complete",line:n,cursor_pos:r}).then(M=>{M.mode==="commands"&&!this._commandCache&&u===""&&(this._commandCache=M.completions),M.mode==="commands"&&!this._commandCache&&this._ws.request({type:"tcl_complete",line:"",cursor_pos:0}).then(L=>{L.mode==="commands"&&(this._commandCache=L.completions)}).catch(()=>{}),c(M.completions,M.replace_start,M.replace_end)}).catch(()=>c([],0,0))}_requestCompletions(n,r){this._fetchCompletions(n,r,(c,u,d)=>{this._showPopup(c,u,d)})}_tabAccept(){if(this._items.length===0){this._hidePopup();return}if(this._items.length===1){this._selectedIndex=0,this._acceptCompletion();return}this._advanceToCommonPrefix()}_tabComplete(n,r){this._fetchCompletions(n,r,(c,u,d)=>{if(!c||c.length===0){this._hidePopup();return}if(c.length===1){this._items=c,this._replaceStart=u,this._replaceEnd=d,this._selectedIndex=0,this._acceptCompletion();return}this._items=c,this._replaceStart=u,this._replaceEnd=d,this._advanceToCommonPrefix(),this._showPopup(c,this._replaceStart,this._replaceEnd)})}_advanceToCommonPrefix(){if(this._items.length<2)return!1;let n=this._items[0];for(let b=1;b0;b++){let w=this._items[b],_=0;for(;_{let _=document.createElement("div");_.className="tcl-complete-item",_.textContent=b,_.addEventListener("mousedown",x=>{x.preventDefault(),this._selectedIndex=w,this._acceptCompletion()}),this._popup.appendChild(_)}),n.length>15){let b=document.createElement("div");b.className="tcl-complete-more",b.textContent=`... ${n.length-15} more`,this._popup.appendChild(b)}this._selectedIndex=0,this._highlightSelected(),this._popup.style.display="block"}_hidePopup(){this._popup.style.display="none",this._items=[],this._selectedIndex=-1}_selectItem(n){if(this._items.length===0)return;let r=Math.min(this._items.length,15)-1;this._selectedIndex=Math.max(0,Math.min(n,r)),this._highlightSelected()}_highlightSelected(){let n=this._popup.querySelectorAll(".tcl-complete-item");n.forEach((r,c)=>{r.classList.toggle("selected",c===this._selectedIndex)}),n[this._selectedIndex]&&n[this._selectedIndex].scrollIntoView&&n[this._selectedIndex].scrollIntoView({block:"nearest"})}_acceptCompletion(){if(this._selectedIndex<0||this._selectedIndex>=this._items.length){this._hidePopup();return}let n=this._items[this._selectedIndex],r=this._input.value.substring(0,this._replaceStart),c=this._input.value.substring(this._replaceEnd),d=!n.endsWith("/")&&!n.endsWith("::")&&(c.length===0||c[0]!==" ")?" ":"";this._input.value=r+n+d+c;let b=this._replaceStart+n.length+d.length;this._input.setSelectionRange(b,b),this._input.focus(),this._hidePopup()}};var D3t=[{key:"or_visibility",store:"cookie"},{key:"or_selectability",store:"cookie"},{key:"or_hidden_layers",store:"session"},{key:"or_nonselectable_layers",store:"session"},{key:"or_layer_patterns",store:"session"},{key:"or_hidden_chiplets",store:"cookie"},{key:"or_bg_color",store:"cookie"},{key:"or_show_dbu",store:"cookie"},{key:"or_theme",store:"theme"},{key:"or_use_true_z",store:"cookie"},{key:"or_ruler_style",store:"cookie"},{key:"or_wheel_zoom",store:"cookie"},{key:"or_arrow_step",store:"cookie"},{key:"or_font_family",store:"cookie"},{key:"or_font_scale",store:"cookie"},{key:"or_control_smoothing",store:"cookie"},{key:"or_double_buffer",store:"cookie"},{key:"or_defer_tile_updates",store:"cookie"}];function ipn(s,n){try{return window[s].getItem(n)}catch{return null}}function rpn(s,n,r){try{r===null?window[s].removeItem(n):window[s].setItem(n,r)}catch{}}function spn({key:s,store:n}){return n==="session"?ipn("sessionStorage",s):pf(s)}function opn({key:s,store:n},r){n==="session"?rpn("sessionStorage",s,r):n==="theme"?r===null?e3t():Whe(r):r===null?Vhe(s):Ff(s,r)}function B3t(){let s={};for(let n of D3t){let r=spn(n);r&&(s[n.key]=r)}return{version:1,entries:s}}function apn(s){return typeof s=="string"&&s!==""&&!/[;\r\n]/.test(s)}function O3t(s){for(let n of D3t){let r=s[n.key];opn(n,apn(r)?r:null)}}function N3t(s,n=typeof document<"u"?document:null){let r="OpenROAD",c=s?`${r} - ${s}`:r;return n&&(n.title=c),c}var $s=globalThis.THREE,F3t=2,cpn=.002,lpn=.9,upn=1.1,fpn=.1,hpn=20,dpn=3,gk=2,U3t=2,ppn=10,gpn=1e4,mpn=.15,bpn=300,wpn=6,hde=Math.PI/180,z3t=[5025616,2201331,16750592,10233776,48340,16007990,2533018,7951688,15277667,4149685];function vpn(s){let n=new Array(s.length).fill(0),r=new Map;s.forEach((c,u)=>{let d=c.z;r.has(d)||r.set(d,[]),r.get(d).push({idx:u,chiplet:c})});for(let c of r.values()){if(c.length<=1)continue;let u=[];for(let{idx:d,chiplet:b}of c){let w=b.x,_=b.y,x=b.x+b.width,T=b.y+b.height,M=!1;for(let L=0;LwD.x1&&_D.y1)){u[L].push({x1:w,y1:_,x2:x,y2:T}),n[d]=L,M=!0;break}M||(u.push([{x1:w,y1:_,x2:x,y2:T}]),n[d]=u.length-1)}}return n}var dde=class{constructor(n,r){if(this._app=r,this._container=n,this._element=document.createElement("div"),this._element.className="three-d-viewer-widget",n.element.appendChild(this._element),!$s){la(r)?this._showInfo("The 3D view is not available in saved reports."):this._showError("three.js is missing from the page."),this._destroyed=!0;return}this._canvasContainer=document.createElement("div"),this._canvasContainer.className="three-d-canvas-container",this._element.appendChild(this._canvasContainer),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._canvasContainer.appendChild(this._tooltip),this._optionsOverlay=this._createOptionsOverlay(),this._canvasContainer.appendChild(this._optionsOverlay),this._raycaster=new $s.Raycaster,this._scene=new $s.Scene,this._applyTheme(),this._themeObserver=new MutationObserver(()=>{this._applyTheme(),this.render()}),this._themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),this._camera=new $s.PerspectiveCamera(45,1,10,1e5),this._camera.position.set(0,0,1e3);try{this._renderer=new $s.WebGLRenderer({antialias:!0,preserveDrawingBuffer:!0})}catch(b){console.error("3D viewer: failed to create WebGL context:",b),this._showWebGLUnavailable(b),this._themeObserver&&(this._themeObserver.disconnect(),this._themeObserver=null),this._destroyed=!0;return}this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(n.width,n.height),this._canvasContainer.appendChild(this._renderer.domElement),this._rotation=new $s.Quaternion,this._distance=1e3,this._panX=0,this._panY=0,this._boundingRadius=1,this._sceneCenter=new $s.Vector3,this._mouseDown=!1,this._mouseButton=-1,this._lastMousePos={x:0,y:0},this._setupMouseHandlers();let c=new $s.AmbientLight(16777215,.5);this._scene.add(c);let u=new $s.DirectionalLight(16777215,.8);u.position.set(1,1,1).normalize(),this._scene.add(u);let d=new $s.DirectionalLight(16777215,.3);d.position.set(-1,-.5,.5).normalize(),this._scene.add(d),n.on("resize",this.onResize.bind(this)),n.on("open",this.onOpen.bind(this)),n.on("destroy",this.onDestroy.bind(this)),this._designGroup=new $s.Group,this._scene.add(this._designGroup),this._chipletMeshes=[],this._loading=!1,this._destroyed=!1,this._edgeMaterial=null}_setupMouseHandlers(){let n=this._renderer.domElement;n.addEventListener("mousedown",r=>{this._mouseDown=!0,this._mouseButton=r.button,this._lastMousePos.x=r.clientX,this._lastMousePos.y=r.clientY,n.focus(),r.preventDefault()}),n.addEventListener("contextmenu",r=>r.preventDefault()),this._onMouseMove=r=>{if(!this._mouseDown)return;let c=r.clientX-this._lastMousePos.x,u=r.clientY-this._lastMousePos.y;this._lastMousePos.x=r.clientX,this._lastMousePos.y=r.clientY,!(c===0&&u===0)&&(this._mouseButton===0?this._handleRotate(c,u):this._mouseButton===2&&this._handlePan(c,u),this._updateCamera())},this._onMouseUp=r=>{this._mouseDown&&r.button===this._mouseButton&&(this._mouseDown=!1,this._mouseButton=-1)},window.addEventListener("mousemove",this._onMouseMove),window.addEventListener("mouseup",this._onMouseUp),n.addEventListener("wheel",r=>{r.preventDefault(),r.deltaY<0?this._distance*=lpn:this._distance*=upn;let c=Math.max(this._boundingRadius*fpn,1),u=Math.max(this._boundingRadius*hpn,c);this._distance=Math.max(c,Math.min(u,this._distance)),this._updateCamera()},{passive:!1}),n.tabIndex=0,n.style.outline="none",n.addEventListener("keydown",r=>{r.key.toLowerCase()==="f"&&this.resetCamera()}),n.addEventListener("dblclick",r=>{r.preventDefault();let c=this._pickDrcMarkerId(r);if(c!=null&&this._app.drcWidget){this._app.drcWidget.highlightMarkerById(c,!0);return}this.resetCamera()}),n.addEventListener("mousemove",r=>{if(this._mouseDown){this._hideTooltip();return}this._updateTooltip(r)}),n.addEventListener("mouseleave",()=>{this._hideTooltip()})}_createOptionsOverlay(){let n=document.createElement("div");n.className="three-d-options";let r=document.createElement("label");r.title="Render chiplets at their true Z (disable stacking offset for overlapping chiplets at same Z).";let c=document.createElement("input");c.type="checkbox",c.checked=!!this._app.useTrueZ,c.addEventListener("change",()=>{this._app.useTrueZ=c.checked,Ff("or_use_true_z",c.checked?"1":"0"),this._app.syncDisplayState(),this.refreshSceneForOptions()}),r.appendChild(c),r.appendChild(document.createTextNode("True Z (no stacking)")),n.appendChild(r);let u=document.createElement("div");u.style.cssText="margin-top:4px; display:flex; gap:4px;";let d=document.createElement("button");d.className="or-btn or-btn-sm",d.textContent="Save PNG",d.title="Save the 3D view as a PNG image (2x resolution)",d.addEventListener("click",()=>this._exportPng(2));let b=document.createElement("button");return b.className="or-btn or-btn-sm",b.textContent="Copy",b.title="Copy the 3D view image to the clipboard",b.addEventListener("click",()=>this._copyImage(2)),u.appendChild(d),u.appendChild(b),n.appendChild(u),n}_capturePng(n=2){if(!this._renderer)return null;let r=this._renderer,c=r.domElement.clientWidth||r.domElement.width,u=r.domElement.clientHeight||r.domElement.height,d=r.getPixelRatio();try{return r.setPixelRatio(d*n),r.setSize(c,u,!1),this.render(),r.domElement.toDataURL("image/png")}finally{r.setPixelRatio(d),r.setSize(c,u,!1),this.render()}}_exportPng(n=2){let r=this._capturePng(n);r&&hk(r,"3d-view.png")}async _copyImage(n=2){let r=this._capturePng(n);r&&await Hhe(r)}_setRaycasterFromEvent(n){let c=this._renderer.domElement.getBoundingClientRect(),u=new $s.Vector2((n.clientX-c.left)/c.width*2-1,-((n.clientY-c.top)/c.height*2-1));this._raycaster.setFromCamera(u,this._camera)}_updateTooltip(n){if(!this._chipletMeshes.length){this._hideTooltip();return}this._setRaycasterFromEvent(n);let r=this._chipletMeshes.map(w=>w.mesh),c=this._raycaster.intersectObjects(r,!1);if(c.length===0){this._hideTooltip();return}let u=c[0].object,d=this._chipletMeshes.find(w=>w.mesh===u);if(!d){this._hideTooltip();return}this._tooltip.textContent=d.data.name,this._tooltip.style.display="block";let b=this._canvasContainer.getBoundingClientRect();this._tooltip.style.left=n.clientX-b.left+12+"px",this._tooltip.style.top=n.clientY-b.top+12+"px"}_hideTooltip(){this._tooltip&&(this._tooltip.style.display="none")}_pickDrcMarkerId(n){if(!this._drcHitboxMesh||!this._drcHitboxMarkerIds)return null;this._setRaycasterFromEvent(n);let r=this._raycaster.intersectObject(this._drcHitboxMesh,!1);if(r.length===0)return null;let c=r[0].instanceId;return c==null?null:this._drcHitboxMarkerIds[c]??null}_handleRotate(n,r){let c=Math.sqrt(n*n+r*r);if(c<.001)return;let u=new $s.Vector3(r/c,n/c,0),d=c/F3t,w=new $s.Quaternion().setFromAxisAngle(u,d*hde).clone().multiply(this._rotation);if(new $s.Vector3(0,0,1).applyQuaternion(w).z>=0)this._rotation.copy(w);else{let x=new $s.Vector3(0,1,0),T=n/F3t*hde,L=new $s.Quaternion().setFromAxisAngle(x,T).clone().multiply(this._rotation);new $s.Vector3(0,0,1).applyQuaternion(L).z>=0&&this._rotation.copy(L)}}_handlePan(n,r){let c=this._distance*cpn;this._panX+=n*c,this._panY-=r*c}_updateCamera(){let n=Math.max(this._boundingRadius,1e3),r=Math.max(this._distance-n*U3t,ppn),c=this._distance+n*U3t;c0;){let n=this._designGroup.children[0];this._designGroup.remove(n),n.geometry&&n.geometry.dispose(),n.material&&!n.material._shared&&n.material.dispose()}this._edgeMaterial&&(this._edgeMaterial.dispose(),this._edgeMaterial=null),this._onMouseMove&&(window.removeEventListener("mousemove",this._onMouseMove),this._onMouseMove=null),this._onMouseUp&&(window.removeEventListener("mouseup",this._onMouseUp),this._onMouseUp=null),this._renderer&&(this._renderer.dispose(),this._renderer=null),this._app.threeDViewerWidget===this&&(this._app.threeDViewerWidget=null)}}_setInitialCameraState(){this._distance=this._boundingRadius*dpn;let n=new $s.Quaternion().setFromAxisAngle(new $s.Vector3(1,0,0),-45*hde),r=new $s.Quaternion().setFromAxisAngle(new $s.Vector3(0,0,1),45*hde);this._rotation=n.multiply(r),this._panX=0,this._panY=0}resetCamera(){this._sceneBounds&&(this._setInitialCameraState(),this._updateCamera())}onResize(){if(this._destroyed)return;let n=this._canvasContainer.getBoundingClientRect(),r=n.width,c=n.height;r===0||c===0||(this._camera.aspect=r/c,this._camera.updateProjectionMatrix(),this._renderer.setSize(r,c),this.render())}render(){this._destroyed||this._renderer&&this._scene&&this._camera&&this._renderer.render(this._scene,this._camera)}_applyTheme(){let r=fk().bgMap||"#000000";this._scene.background=new $s.Color(r)}async loadData(){if(!(this._loading||this._destroyed)){this._loading=!0;for(let n of[".three-d-error",".three-d-info"]){let r=this._element.querySelector(n);r&&r.remove()}try{await this._app.websocketManager.readyPromise;let n=await this._app.websocketManager.request({type:"get_3d_data"});if(this._destroyed)return;if(n&&n.error){this._showError(n.error);return}if(n&&n.info){this._showInfo(n.info);return}this.buildScene(n)}catch(n){if(this._destroyed)return;console.error("Failed to load 3D data:",n),this._showError(n.message||String(n))}finally{this._loading=!1}}}_showOverlay(n,r,c){let u=document.createElement("div");u.className=n,u.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-family:monospace;text-align:center;",u.style.color=c,u.textContent=r,this._element.appendChild(u)}_showError(n){this._showOverlay("three-d-error","Failed to load 3D data: "+n,"var(--error)")}_showInfo(n){this._showOverlay("three-d-info",n,"var(--fg-muted, #888)")}_showWebGLUnavailable(n){let r=document.createElement("div");r.className="three-d-error",r.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-family:monospace;text-align:center;max-width:80%;color:var(--error);";let c=n&&n.message?n.message:String(n||"");r.innerHTML='
3D viewer unavailable: WebGL context could not be created.
In Chrome, open chrome://flags/#ignore-gpu-blocklist and set Override software rendering list to Enabled, then relaunch the browser.
Otherwise enable hardware acceleration or try a different browser. See chrome://gpu for details.
'+(c?'
'+c+"
":""),this._element.appendChild(r)}buildScene(n){if(this._destroyed||(this._lastSceneData=n,this._clearScene(),!n||!n.chiplets||n.chiplets.length===0))return;let r=this._app.getDbuPerMicron(),c=this._buildChiplets(n.chiplets,r);c.minX!==1/0&&(this._buildGrid(c),this._setSceneBoundsAndCenter(c),this._setInitialCameraState(),this._updateCamera())}_clearScene(){for(this._chipletMeshes=[];this._designGroup.children.length>0;){let n=this._designGroup.children[0];this._designGroup.remove(n),n.geometry&&n.geometry.dispose(),n.material&&!n.material._shared&&n.material.dispose()}this._hideTooltip()}_buildChiplets(n,r){let c={minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0};this._edgeMaterial||(this._edgeMaterial=new $s.LineBasicMaterial({color:0,linewidth:1}),this._edgeMaterial._shared=!0);let u=this._app.useTrueZ?new Array(n.length).fill(0):vpn(n);return n.forEach((d,b)=>{let w=d.width/r,_=d.height/r,x=d.thickness/r*gk,T=z3t[b%z3t.length],M=new $s.MeshPhongMaterial({color:T,transparent:!1,opacity:1,side:$s.DoubleSide,shininess:40}),L=new $s.BoxGeometry(w,_,x),I=new $s.Mesh(L,M),D=d.x/r+w/2,F=d.y/r+_/2,O=x*mpn,z=d.z/r*gk+x/2+u[b]*(x+O);I.position.set(D,F,z),this._designGroup.add(I),this._chipletMeshes.push({mesh:I,data:d,color:T});let Z=new $s.EdgesGeometry(L),H=new $s.LineSegments(Z,this._edgeMaterial);H.position.set(D,F,z),this._designGroup.add(H),c.minX=Math.min(c.minX,d.x/r),c.minY=Math.min(c.minY,d.y/r),c.minZ=Math.min(c.minZ,z-x/2),c.maxX=Math.max(c.maxX,d.x/r+w),c.maxY=Math.max(c.maxY,d.y/r+_),c.maxZ=Math.max(c.maxZ,z+x/2)}),c}_buildGrid(n){let r=n.maxX-n.minX,c=n.maxY-n.minY,u=Math.max(r,c)*1.4,d=10,b=new $s.GridHelper(u,d,8947848,4473924);b.rotation.x=Math.PI/2,b.position.set((n.minX+n.maxX)/2,(n.minY+n.maxY)/2,n.minZ-1),this._designGroup.add(b)}_setSceneBoundsAndCenter(n){this._sceneBounds=n;let r=n.maxX-n.minX,c=n.maxY-n.minY,u=n.maxZ-n.minZ;this._boundingRadius=Math.sqrt(r*r+c*c+u*u)/2,this._sceneCenter.set((n.minX+n.maxX)/2,(n.minY+n.maxY)/2,(n.minZ+n.maxZ)/2)}_stackOffsetForPoint(n,r,c,u){for(let{mesh:d,data:b}of this._chipletMeshes){if(n!==b.z||rb.x+b.width||cb.y+b.height)continue;let w=b.thickness/u*gk,_=b.z/u*gk+w/2;return d.position.z-_}return 0}clearHighlightDRC(){this._drcBlinkInterval&&(clearInterval(this._drcBlinkInterval),this._drcBlinkInterval=null),this._drcMeshGroup&&(this._scene.remove(this._drcMeshGroup),this._drcMeshGroup.children.forEach(n=>{n.geometry&&n.geometry.dispose()}),this._drcMaterial&&(this._drcMaterial.dispose(),this._drcMaterial=null),this._drcHitboxMaterial&&(this._drcHitboxMaterial.dispose(),this._drcHitboxMaterial=null),this._drcHitboxMesh=null,this._drcHitboxMarkerIds=null,this._drcMeshGroup=null,this.render())}highlightDRC(n){if(this._destroyed||(this.clearHighlightDRC(),!n||n.length===0))return;let r=this._app.getDbuPerMicron(),c=0,u=1e4/r*gk;this._sceneBounds&&this._sceneBounds.minZ!==1/0&&(c=this._sceneBounds.minZ,u=this._sceneBounds.maxZ),c-=1,u+=1;let d=Math.max(u-c,1);this._drcMeshGroup=new $s.Group,this._drcMaterial=new $s.LineBasicMaterial({color:16776960,transparent:!0,opacity:1,depthTest:!1,depthWrite:!1}),this._drcHitboxMaterial=new $s.MeshBasicMaterial({transparent:!0,opacity:0,depthWrite:!1});let b=[];for(let x of n){let T=x.rects&&x.rects.length>0?x.rects:[x.bbox];for(let M of T){let[L,I,D,F,O,z]=M,Z=Math.max((D-L)/r,.001),H=Math.max((F-I)/r,.001),te=c,se=d,ne=0;if(M.length>=6&&O!==void 0&&z!==void 0){te=O/r*gk;let me=z/r*gk;se=Math.max(me-te,.001),ne=this._stackOffsetForPoint(O,(L+D)/2,(I+F)/2,r)}let ue=L/r+Z/2,Ce=I/r+H/2,Q=te+se/2+ne;b.push({cx:ue,cy:Ce,cz:Q,width:Z,height:H,depth:se,markerId:x.id})}}if(b.length>0){let x=new $s.BoxGeometry(1,1,1);this._drcHitboxMesh=new $s.InstancedMesh(x,this._drcHitboxMaterial,b.length),this._drcHitboxMarkerIds=new Array(b.length);let T=new $s.Matrix4,M=new $s.Vector3,L=new $s.Vector3,I=new $s.Quaternion;b.forEach((D,F)=>{L.set(D.cx,D.cy,D.cz),M.set(D.width,D.height,D.depth),T.compose(L,I,M),this._drcHitboxMesh.setMatrixAt(F,T),this._drcHitboxMarkerIds[F]=D.markerId;let O=new $s.BoxGeometry(D.width,D.height,D.depth),z=new $s.EdgesGeometry(O);O.dispose();let Z=new $s.LineSegments(z,this._drcMaterial);Z.position.set(D.cx,D.cy,D.cz),Z.renderOrder=999,this._drcMeshGroup.add(Z)}),this._drcHitboxMesh.instanceMatrix.needsUpdate=!0,this._drcMeshGroup.add(this._drcHitboxMesh)}this._drcMeshGroup.renderOrder=999,this._scene.add(this._drcMeshGroup),this.render();let w=!0,_=0;this._drcBlinkInterval=setInterval(()=>{if(!(!this._drcMeshGroup||!this._drcMaterial)){if(_+=1,_>=wpn){this._drcMaterial.opacity=1,this.render(),clearInterval(this._drcBlinkInterval),this._drcBlinkInterval=null;return}w=!w,this._drcMaterial.opacity=w?1:.2,this.render()}},bpn)}refreshSceneForOptions(){this._destroyed||this._lastSceneData&&(this.clearHighlightDRC(),this.buildScene(this._lastSceneData))}};var _pn=[{name:"green",hex:"#00ff00"},{name:"yellow",hex:"#ffff00"},{name:"cyan",hex:"#00ffff"},{name:"magenta",hex:"#ff00ff"},{name:"red",hex:"#ff0000"},{name:"dark_green",hex:"#008000"},{name:"dark_magenta",hex:"#800080"},{name:"blue",hex:"#0000ff"},{name:"orange",hex:"#ffa500"},{name:"purple",hex:"#800080"},{name:"lime",hex:"#bfff00"},{name:"teal",hex:"#008080"},{name:"pink",hex:"#ffc0cb"},{name:"brown",hex:"#8b4513"},{name:"indigo",hex:"#4b0082"},{name:"turquoise",hex:"#40e0d0"}],ypn=[{label:"Connected Insts",suffix:"connected_insts",needsNet:!0},{label:"Output Nets",suffix:"connected_nets",args:{output:!0,input:!1}},{label:"Input Nets",suffix:"connected_nets",args:{output:!1,input:!0}},{label:"All Nets",suffix:"connected_nets",args:{output:!0,input:!0}},{label:"All buffer trees",suffix:"connected_buffer_trees"},{label:"All buffer trees (incl. inverters)",suffix:"connected_buffer_trees",args:{include_inverters:!0}}],pde=class{constructor(n){this._app=n,this._el=document.createElement("div"),this._el.className="context-menu",this._el.style.display="none",this._el.style.zIndex="10000",document.body.appendChild(this._el),this._bindEvents()}_bindEvents(){document.addEventListener("mousedown",n=>{this._el.contains(n.target)||this.hide()}),this._app.view&&this._app.view.on("movestart",()=>this.hide())}show(n){this._el.innerHTML="";let r=!!this._app.selHasInst,c=!!this._app.selHasNet,u=!(r||c),d=I=>ypn.map(D=>({label:D.label,disabled:D.needsNet?!c:!r,...I(D.suffix,D.args||{})})),b=[{label:"Select",disabled:u,subMenu:d((I,D)=>({action:()=>this._sendContextAction("select_"+I,D)}))},{label:"Highlight",disabled:u,subMenu:d((I,D)=>({subMenu:this._buildColorSubmenu("highlight_"+I,D)}))},{label:"Save",subMenu:[{label:"Visible layout",action:()=>this._app.captureLayout?.({entire:!1})},{label:"Entire layout",action:()=>this._app.captureLayout?.({entire:!0})}]},{label:"Clear",subMenu:[{label:"Selections",action:()=>this._sendContextAction("clear_selections")},{label:"Highlights",action:()=>this._sendContextAction("clear_highlights")},{label:"Rulers",action:()=>{this._app.rulerManager?.clearAllRulers()}},{label:"Focus nets",action:()=>this._sendContextAction("clear_focus_nets")},{label:"Route Guides",action:()=>this._sendContextAction("clear_route_guides")},{label:"All",action:()=>{this._sendContextAction("clear_all"),this._app.rulerManager?.clearAllRulers()}}]}];this._buildMenu(b,this._el),this._el.style.display="block";let w=4,_=this._el.getBoundingClientRect(),x=window.innerWidth-_.width-w,T=window.innerHeight-_.height-w,M=Math.max(w,Math.min(n.clientX,x)),L=Math.max(w,Math.min(n.clientY,T));this._el.style.left=M+"px",this._el.style.top=L+"px"}hide(){this._el.style.display="none"}_buildColorSubmenu(n,r={}){return _pn.map(({name:c,hex:u},d)=>({label:c,swatch:u,action:()=>this._sendContextAction(n,{...r,group:d})}))}_buildMenu(n,r){n.forEach(c=>{let u=document.createElement("div");if(u.className="cm-item",c.swatch){let d=document.createElement("span");d.className="cm-swatch",d.style.background=c.swatch,u.appendChild(d)}if(u.appendChild(document.createTextNode(c.label)),c.disabled){u.classList.add("disabled"),c.subMenu&&u.classList.add("has-submenu"),r.appendChild(u);return}if(c.subMenu){u.classList.add("has-submenu");let d=document.createElement("div");d.className="cm-submenu",this._buildMenu(c.subMenu,d),u.appendChild(d),u.addEventListener("mouseenter",()=>{d.classList.remove("flip-left"),d.getBoundingClientRect().right>window.innerWidth&&d.classList.add("flip-left")})}else c.action&&u.addEventListener("click",d=>{d.stopPropagation(),this.hide();try{c.action()}catch(b){console.error("Context menu item action threw:",c.label,b)}});r.appendChild(u)})}_sendContextAction(n,r={}){this._app.websocketManager&&this._app.websocketManager.request({type:"context_action",action:n,...r}).then(c=>{EO(this._app,c),c&&c.connected_count===0&&Nb('Nothing connected \u2014 select an instance (or a net for "Connected Insts") first.'),this._syncAfterAction(n)}).catch(c=>{console.error("Context action failed:",n,c)})}_syncAfterAction(n){let r=this._app;(n==="clear_focus_nets"||n==="clear_route_guides"||n==="clear_all")&&typeof r.redrawAllLayers=="function"&&r.redrawAllLayers(),n==="clear_selections"||n==="clear_all"?(r.updateInspector?.(null),r.stopSelectionAnimation?.(),r.clearSelectionOutline?.(),r.lastSelectionBounds=null):r.refreshInspector?.(),r.refreshOverlay?.()}};function G3t(s,n){if(!s)return;let r=URL.createObjectURL(s),c=document.createElement("a");c.href=r,c.download=n,c.style.display="none",document.body.appendChild(c),c.click(),document.body.removeChild(c),setTimeout(()=>URL.revokeObjectURL(r),0)}function xpn(s,n,r){s.view.getContainer().querySelectorAll(".or-view-markers .ruler-label").forEach(u=>{let d=u.getBoundingClientRect();if(d.width<=0||d.height<=0)return;let b=u.textContent;if(!b)return;let w=getComputedStyle(u),_=d.left-r.left,x=d.top-r.top;n.save(),n.fillStyle=w.backgroundColor||"rgba(0, 0, 0, 0.75)";let T=Math.min(parseFloat(w.borderTopLeftRadius)||0,d.height/2);T>0&&typeof n.roundRect=="function"?(n.beginPath(),n.roundRect(_,x,d.width,d.height,T),n.fill()):n.fillRect(_,x,d.width,d.height),n.fillStyle=w.color||"#eee",n.font=w.font||`${w.fontSize||"12px"} ${w.fontFamily||"monospace"}`,n.textAlign="left",n.textBaseline="middle",n.fillText(b,_+(parseFloat(w.paddingLeft)||0),x+d.height/2),n.restore()})}async function j3t(s){let n=s.view.getContainer(),r=n.getBoundingClientRect(),c=Math.max(1,Math.round(r.width)),u=Math.max(1,Math.round(r.height)),d=document.createElement("canvas");d.width=c,d.height=u;let b=d.getContext("2d"),w=getComputedStyle(n).backgroundColor;b.fillStyle=w&&w!=="transparent"&&w!=="rgba(0, 0, 0, 0)"?w:"#000",b.fillRect(0,0,c,u);let _=await s.view.captureCanvas();if(_){let x=_.rect;try{b.drawImage(_.image,x.left-r.left,x.top-r.top,x.width,x.height)}catch{}}return xpn(s,b,r),new Promise(x=>d.toBlob(x,"image/png"))}async function $3t(s,{entire:n=!1}={}){if(!s.view)return;if(!n||!s.fitRect){G3t(await j3t(s),"layout_visible.png");return}let r=s.view.getCenter(),c=s.view.getZoom();try{s.view.fitWorldRect(s.fitRect,{animate:!1}),await s.view.whenTilesSettled(),G3t(await j3t(s),"layout_entire.png")}finally{s.view.setView(r,c,{animate:!1})}}var MT=document.getElementById("websocket-status"),cH=null,Epn=2e3,Spn=20;function W3t(){let s=he.websocketManager&&he.websocketManager.isConnected,n=he.websocketManager?he.websocketManager.pendingCount:0;if(s)if(cH&&(clearTimeout(cH),cH=null),n>Spn){let r=`pending: ${n}`,c=MT.firstElementChild;(!c?.classList.contains("pending-indicator")||c.textContent!==r)&&(MT.innerHTML=`
${r}
`),MT.style.display="block"}else MT.style.display="none";else{if(he.websocketManager?._shutdown)return;cH||(cH=setTimeout(()=>{he.websocketManager?.isConnected||(MT.innerHTML='
\u26A0 OpenROAD disconnected \u2014 retrying\u2026
',MT.style.display="block")},Epn))}Mpn(n)}function Mpn(s){let n=he.tileProgressEl;if(!n)return;n.classList.toggle("active",s>0);let r=s>0?`${s} tile requests pending`:"";n.title!==r&&(n.title=r)}var V3t=_T(W3t);function Tpn(s){if(!s)return"";try{return decodeURIComponent(s)}catch{return""}}var he={view:null,fitRect:null,lastSelectionBounds:null,selHasInst:!1,selHasNet:!1,displayControlsEl:null,allLayers:[],designScale:null,designOriginX:0,designOriginY:0,websocketManager:null,goldenLayout:null,hasLiberty:!1,techData:null,inspectorEl:null,tclOutputEl:null,modulesLayer:null,pinsLayer:null,overlayLayers:[],hierarchyBrowser:null,focusNets:new Set,routeGuideNets:new Set,visibleLayers:new Set,visibleLayerNames:new Set,visibleChiplets:null,layerPatterns:{},useTrueZ:pf("or_use_true_z")==="1",showDbu:pf("or_show_dbu")==="1",rulerStyle:pf("or_ruler_style")==="manhattan"?"manhattan":"euclidian",wheelZoom:pf("or_wheel_zoom")!=="0",arrowStep:tH(pf("or_arrow_step")),controlSmoothing:pf("or_control_smoothing")!=="0",doubleBuffer:pf("or_double_buffer")!=="0",deferTileUpdates:pf("or_defer_tile_updates")==="1",fontFamily:Tpn(pf("or_font_family")),fontScale:rH(pf("or_font_scale")),polyDecomp:!1,labelManager:null,selectableLayers:new Set,heatMapData:null,activeHeatMap:"",heatMapLayer:null,heatMapLegendEl:null,renderHeatMapControls:null,rulerManager:null,selectionToken:0,selectionResetters:[],getDbuPerMicron(){return this.techData?.dbu_per_micron||1e3},unitOpts(){return{showDbu:this.showDbu,dbuPerMicron:this.getDbuPerMicron()}},formatDbu(s,n=!1){return Uxt(s,this.unitOpts(),n)},parseDbu(s){return zxt(s,this.unitOpts())},formatDistance(s){return Gxt(s,this.unitOpts())},unitLabel(){return jxt(this.unitOpts())}},gg={stdcells:!0,macros:!0,pad_input:!0,pad_output:!0,pad_inout:!0,pad_power:!0,pad_spacer:!0,pad_areaio:!0,pad_other:!0,phys_fill:!1,phys_endcap:!0,phys_welltap:!0,phys_tie:!0,phys_antenna:!0,phys_cover:!0,phys_bump:!0,phys_other:!0,std_bufinv:!0,std_bufinv_timing:!0,std_clock_bufinv:!0,std_clock_gate:!0,std_level_shift:!0,std_sequential:!0,std_combinational:!0,net_signal:!0,net_power:!0,net_ground:!0,net_clock:!0,net_reset:!0,net_tieoff:!0,net_scan:!0,net_analog:!0,inst_names:!0,inst_pins:!0,inst_pin_names:!1,routing:!0,routing_segments:!0,routing_vias:!0,special_nets:!0,srouting_segments:!0,srouting_vias:!0,pins:!0,pin_names:!0,access_points:!1,regions:!0,mfg_grid:!1,gcell_grid:!1,flywires_only:!1,blockages:!0,placement_blockages:!0,routing_obstructions:!0,fills:!1,rows:!1,tracks_pref:!1,tracks_non_pref:!1,module_view:!1,detailed:!1,rulers:!0,labels:!0,scale_bar:!0,focused_nets_guides:!1,highlight_selected:!0,debug:!1};try{let s=pf("or_visibility");if(s){let n=JSON.parse(decodeURIComponent(s));for(let[r,c]of Object.entries(n))gg[r]=!!c}}catch{}var LO={stdcells:!0,macros:!0,pad_input:!0,pad_output:!0,pad_inout:!0,pad_power:!0,pad_spacer:!0,pad_areaio:!0,pad_other:!0,phys_fill:!0,phys_endcap:!0,phys_welltap:!0,phys_tie:!0,phys_antenna:!0,phys_cover:!0,phys_bump:!0,phys_other:!0,std_bufinv:!0,std_bufinv_timing:!0,std_clock_bufinv:!0,std_clock_gate:!0,std_level_shift:!0,std_sequential:!0,std_combinational:!0,net_signal:!0,net_power:!0,net_ground:!0,net_clock:!0,net_reset:!0,net_tieoff:!0,net_scan:!0,net_analog:!0,pins:!0,inst_pins:!0,placement_blockages:!0,routing_obstructions:!0};he.visibility=gg;he.selectability=LO;try{let s=pf("or_selectability");if(s){let n=JSON.parse(decodeURIComponent(s));for(let[r,c]of Object.entries(n))LO[r]=!!c}}catch{}(function(){let n=null;try{n=new URLSearchParams(window.location.search)}catch{return}he.forceComposite=n.get("composite")==="1",he.preserveBuffer=n.get("preservebuffer")==="1";let r=Number(n.get("grouplayers"));Number.isFinite(r)&&r>0&&(he.groupLayers=Math.floor(r))})();he.tileCtx={visibility:gg,selectability:LO,visibleLayers:he.visibleLayerNames,selectableLayers:he.selectableLayers,app:he};function Cpn(){return he.view.addTileSlot("heatmap",{order:mp.heatmap,visible:!!he.activeHeatMap,source:G5e({wm:he.websocketManager,dpr:xO,tileSize:Ob,buildRequest:(s,n,r)=>Pxt(s,n,r,he)})})}function rDe(s){if(he.heatMapData=s,he.activeHeatMap=s.active||"",he.heatMapLayer){let n=he.heatMapLayer.isVisible();he.heatMapLayer.setVisible(!!he.activeHeatMap),n&&he.heatMapLayer.refresh()}he.renderHeatMapControls&&he.renderHeatMapControls(s)}he.updateHeatMaps=rDe;function sDe(){he.overlayLayer&&he.overlayLayer.refresh()}var mk=_T(()=>{sDe(),he.selectionBrowser&&he.selectionBrowser.scheduleRefresh()});he.refreshOverlay=mk;function K1(){Ff("or_visibility",encodeURIComponent(JSON.stringify(gg))),Ff("or_selectability",encodeURIComponent(JSON.stringify(LO))),Fb();let s=[[he.modulesLayer,gg.module_view],[he.pinsLayer,gg.pins],...he.overlayLayers.map(({def:n,layer:r})=>[r,nde(n.shown_by,gg)])];for(let[n,r]of s)n&&(n.visible=!!r);for(let n of he.allLayers)n.refresh();he.heatMapLayer&&he.heatMapLayer.refresh(),he.renderSelectionOutline&&he.renderSelectionOutline(),!gg.highlight_selected&&he.clearSelectionPulse&&he.clearSelectionPulse(),sDe(),he.rulerManager&&he.rulerManager.updateVisibility(),he.labelManager&&he.labelManager.updateVisibility(),he.updateScaleBar&&he.updateScaleBar()}var PO=_T(K1),Fb=_T(()=>{!he.websocketManager||la(he)||he.websocketManager.request({type:"set_display_state",state:B3t()}).catch(()=>{})});he.syncDisplayState=Fb;function Apn(s){if(!s||typeof s!="object")return;let n=s.entries;if(!(!n||typeof n!="object")){O3t(n);try{if(he.view&&he.designScale&&typeof sessionStorage<"u"){let[r,c]=he.view.getCenter(),{dbuX:u,dbuY:d}=Pv(r,c,he.designScale,he.designOriginX,he.designOriginY);sessionStorage.setItem("or_restore_view",JSON.stringify({dbuX:u,dbuY:d,zoom:he.view.getZoom()}))}}catch{}window.location.reload()}}he.redrawAllLayers=K1;he.captureLayout=(s={})=>$3t(he,s);function Ppn(s){let n=document.createElement("div");n.className="layout-viewer",n.style.width="100%",n.style.height="100%",n.style.backgroundColor="var(--bg-map)",s.element.appendChild(n);let r=document.createElement("div");r.className="or-hud or-hud-bottom-right heatmap-map-legend hidden",n.appendChild(r),he.heatMapLegendEl=r;let c=document.createElement("div");c.className="or-progress",n.appendChild(c),he.tileProgressEl=c,s.on("destroy",()=>{he.tileProgressEl=null,he.heatMapLegendEl=null}),he.view=Kxt(n,{preserveDrawingBuffer:he.preserveBuffer,prefs:{smooth:()=>he.controlSmoothing,doubleBuffer:()=>he.doubleBuffer,defer:()=>he.deferTileUpdates},tileSize:Ob,dpr:xO,isStatic:la(he)}),he.view.on("contextlost",()=>{console.warn("Layout view: WebGL context lost; rebuilding the view.")}),he.view.on("contextfailed",()=>{Nb("The layout view lost its graphics context and could not get it back; reload the page.",15e3)}),window.__orView=he.view,bxt(()=>{he.view.invalidateSize(),K1()});let u=document.createElement("div");u.className="or-zoom-control";let d=[];for(let[Z,H,te]of[["+","Zoom in",()=>he.view.zoomIn()],["\u2212","Zoom out",()=>he.view.zoomOut()],["\u2922","Fit",()=>{he.fitRect&&he.view.fitWorldRect(he.fitRect)}]]){let se=document.createElement("button");se.type="button",se.title=H,se.setAttribute("aria-label",H),se.textContent=Z,se.addEventListener("click",ne=>{ne.stopPropagation(),te()}),u.appendChild(se),d.push(se)}n.appendChild(u);let b=()=>{let{minZoom:Z,maxZoom:H}=he.view.getLimits(),te=he.view.getTargetZoom();d[0].disabled=te>=H,d[1].disabled=te<=Z};he.view.on("zoom zoomend limits",b),b();let w=document.createElement("div");w.className="or-hud or-hud-bottom-left hidden";let _=document.createElement("div");_.id="scale-bar";let x=document.createElement("span");x.className="or-hud-divider";let T=document.createElement("div");T.id="coord-bar",w.appendChild(_),w.appendChild(x),w.appendChild(T),n.appendChild(w);function M(){let Z=_.style.display!=="none"&&_.childElementCount>0,H=T.textContent!=="";x.style.display=Z&&H?"":"none",w.classList.toggle("hidden",!Z&&!H)}M(),Qxt(he.view,{isStatic:()=>la(he),wheelZoom:()=>he.wheelZoom,arrowStep:()=>he.arrowStep,contextEnabled:()=>!(he.rulerManager&&he.rulerManager.isActive()),onClick:(Z,H)=>{he.rulerManager&&he.rulerManager.isActive()?he.rulerManager.handleMapClick(Z,H):he.rulerManager?.handleRulerClick(Z)||he.onMapClick&&he.onMapClick(Z,H)},onContextClick:(Z,H)=>{he.onMapContextClick&&he.onMapContextClick(Z,H)},onMove:(Z,H)=>{if(he.lastMouseWorld=Z,he.rulerManager&&he.rulerManager.isActive()&&he.rulerManager.handleMouseMove(Z,H),!he.designScale)return;let{dbuX:te,dbuY:se}=Pv(Z[0],Z[1],he.designScale,he.designOriginX,he.designOriginY);T.textContent=`X: ${he.formatDbu(te)} Y: ${he.formatDbu(se)}`,M()},onLeave:()=>{he.lastMouseWorld=null,T.textContent="",M()}});let L=22,I=8,D=22;function F(Z,H,te){let ne=2+I,ue=D,Ce=D+Z,Q=L-2,me=Z>=40,tt=[];if(tt.push(``),me&&te>1)for(let st=1;st`)}me&&tt.push(`0`),tt.push(`${H}`),_.innerHTML=`${tt.join("")}`}function O(){if(!he.designScale||!gg.scale_bar){_.style.display="none",M();return}let Z=he.designScale*Math.pow(2,he.view.getZoom()),H=he.view.getSize().width||400,te=Vxt({targetPx:H*.15,pxPerDbu:Z,dbuPerMicron:he.techData?.dbu_per_micron,showDbu:he.showDbu});if(!te){_.style.display="none",M();return}_.style.display="",F(te.barPx,te.label,te.segments),M()}let z=_T(O);he.view.on("zoom zoomend resize",z),he.updateScaleBar=O,he.rulerManager=new ode(he,gg,lH,gde),he.labelManager=new cde(he,gg,lH,gde)}function Lpn(s){let n=document.createElement("div");n.className="display-controls",n.innerHTML='
Loading layers...
',s.element.appendChild(n),he.displayControlsEl=n}var iDe="or_restore_console",kpn=1<<20;function Rpn(){try{if(he.tclOutputEl){let s=[...he.tclOutputEl.children].map(u=>[u.textContent,u.className]),n=s.length,r=0;for(;n>0&&r+s[n-1][0].length<=kpn;)r+=s[--n][0].length;let c=s.slice(n);n>0&&c.unshift([`[earlier output not kept across reload] +`,""]),sessionStorage.setItem(iDe,JSON.stringify(c))}}catch{}window.location.reload()}function Ipn(){try{let s=sessionStorage.getItem(iDe);if(!s)return;sessionStorage.removeItem(iDe);for(let[n,r]of JSON.parse(s))TT(n,r)}catch{}}function TT(s,n){if(!he.tclOutputEl)return;let r=document.createElement("span");n&&(r.className=n),r.textContent=s,he.tclOutputEl.appendChild(r),he.tclOutputEl.scrollTop=he.tclOutputEl.scrollHeight}function Dpn(){if(he._shutdownHandled)return;he._shutdownHandled=!0,he.websocketManager&&(he.websocketManager._shutdown=!0,he.websocketManager.onPush=()=>{});let s=document.createElement("div");s.style.cssText="position:fixed;inset:0;z-index:99999;background:#1e1e1e;color:#ddd;display:flex;flex-direction:column;align-items:center;justify-content:center;font-family:system-ui,sans-serif;font-size:16px;padding:24px;text-align:center;",s.innerHTML='
OpenROAD exited
You can close this tab.
',document.body.appendChild(s),setTimeout(()=>{try{window.close()}catch{}},1500)}function Bpn(s){let n=document.createElement("div");if(n.className="tcl-console",n.innerHTML='
%
',s.element.appendChild(n),he.tclOutputEl=n.querySelector(".tcl-output"),Ipn(),la(he)){n.querySelector(".tcl-input-row").style.display="none";let u=document.createElement("span");u.className="tcl-static-notice",u.setAttribute("role","status"),u.setAttribute("aria-live","polite"),u.textContent="Tcl console is not available in saved reports.",he.tclOutputEl.appendChild(u);return}let r=n.querySelector(".tcl-input"),c=new fde(r,he.websocketManager);r.addEventListener("keydown",u=>{if(!c.handleKeyDown(u)&&u.key==="Enter"){let d=r.value.trim();if(!d)return;TT(`>>> ${d} +`,"tcl-cmd"),c.addToHistory(d),r.value="",he.websocketManager.request({type:"tcl_eval",cmd:d}).then(b=>{b.result&&TT(b.result+` +`,b.is_error?"tcl-error":""),b.action==="shutdown"&&Dpn(),!b.is_error&&he.drcWidget&&he.drcWidget.refresh()}).catch(b=>TT(`Error: ${b} +`,"tcl-error"))}})}he.visibility=gg;var CT=f3t(he,K1,mk),Opn=CT.createInspector,lH=CT.updateInspector,Npn=CT.highlightBBox,Fpn=CT.pulseHighlight;he.updateInspector=lH;he.navigateInspector=CT.navigateInspector;he.refreshInspector=CT.refreshInspector;he.animateSelection=CT.animateSelection;he.stopSelectionAnimation=CT.stopSelectionAnimation;function Upn(s){new Khe(s,he,K1)}function zpn(s){he.timingWidget=new uk(he,K1,mk),s.element.appendChild(he.timingWidget.element)}function Gpn(s){he.drcWidget=new ude(he,K1,mk),s.element.appendChild(he.drcWidget.element)}function jpn(s){he.clockTreeWidget=new Yhe(s,he,K1,mk)}function $pn(s){he.chartsWidget=new Zhe(he,K1),s.element.appendChild(he.chartsWidget.element)}function Vpn(s){let n=document.createElement("div");n.className="help-panel",n.innerHTML="

Keyboard Shortcuts

fFit design to viewport
scrollZoom in/out
dragPan the view
right-dragRubber-band zoom
Shift+clickAdd object to selection
Ctrl/Cmd+clickSelect object and its connected nets
kToggle ruler mode
Shift+KClear all rulers
EscapeCancel ruler (when building)
",s.element.appendChild(n)}function Wpn(s){he.selectionBrowser=new Jhe(s,he,mk)}function Hpn(s){new lde(s,he)}function qpn(s){he.threeDViewerWidget=new dde(s,he)}var Xpn=28,Ypn={dimensions:{headerHeight:Xpn},root:{type:"row",content:[{type:"component",componentType:"DisplayControls",title:"Display Controls",width:15},{type:"column",width:55,content:[{type:"stack",height:70,content:[{type:"component",componentType:"LayoutViewer",title:"Layout",isClosable:!1},{type:"component",componentType:"SchematicWidget",title:"Schematic"},{type:"component",componentType:"3DViewer",title:"3D Viewer"}]},{type:"component",componentType:"TclConsole",title:"Tcl Console",height:30}]},{type:"stack",width:30,content:[{type:"component",componentType:"Inspector",title:"Inspector"},{type:"component",componentType:"Browser",title:"Hierarchy"},{type:"component",componentType:"TimingWidget",title:"Timing"},{type:"component",componentType:"DRCWidget",title:"DRC"},{type:"component",componentType:"SelectHighlight",title:"Select Highlight"},{type:"component",componentType:"ClockWidget",title:"Clock Tree"},{type:"component",componentType:"ChartsWidget",title:"Charts"},{type:"component",componentType:"HelpWidget",title:"Help"}]}]}};he.goldenLayout=new Bhe(document.getElementById("gl-container"));he.goldenLayout.registerComponentFactoryFunction("LayoutViewer",Ppn);he.goldenLayout.registerComponentFactoryFunction("DisplayControls",Lpn);he.goldenLayout.registerComponentFactoryFunction("TclConsole",Bpn);he.goldenLayout.registerComponentFactoryFunction("Inspector",Opn);he.goldenLayout.registerComponentFactoryFunction("Browser",Upn);he.goldenLayout.registerComponentFactoryFunction("TimingWidget",zpn);he.goldenLayout.registerComponentFactoryFunction("DRCWidget",Gpn);he.goldenLayout.registerComponentFactoryFunction("ClockWidget",jpn);he.goldenLayout.registerComponentFactoryFunction("ChartsWidget",$pn);he.goldenLayout.registerComponentFactoryFunction("SchematicWidget",Hpn);he.goldenLayout.registerComponentFactoryFunction("3DViewer",qpn);he.goldenLayout.registerComponentFactoryFunction("HelpWidget",Vpn);he.goldenLayout.registerComponentFactoryFunction("SelectHighlight",Wpn);var m2=window.__STATIC_CACHE__||null;if(m2)fxt(),he.websocketManager=ZW.fromCache(m2,V3t);else{let s=`ws://${window.location.host||"localhost:8080"}/ws`;he.websocketManager=new ZW(s,V3t),he.layerExtents=new Ghe,he.websocketManager.onReconnected=()=>{mde(),cDe(null,null,{reloadOnChange:!0}).catch(()=>{})}}W3t();he.goldenLayout.loadLayout(Ypn);H3t();function H3t(){Wxt(document.getElementById("gl-container"))>0&&he.goldenLayout.updateSize()}he.goldenLayout.on("stateChanged",()=>{H3t()});function oDe(){he.goldenLayout.updateSize()}he.syncLayoutSize=oDe;window.addEventListener("resize",oDe);function gde(s){he.goldenLayout.focusComponent(s)}he.focusComponent=gde;he.resetLayout=function(){he.goldenLayout&&typeof he.goldenLayout.resetLayout=="function"&&he.goldenLayout.resetLayout()};he.toggleTheme=function(){let s=document.documentElement.dataset.theme==="dark"?"light":"dark";document.documentElement.dataset.theme=s,H5e(s),Whe(s),he.chartsWidget&&he.chartsWidget.render(),he.clockTreeWidget&&he.clockTreeWidget.render(),Fb()};he.toggleShowDbu=function(){he.showDbu=!he.showDbu,Ff("or_show_dbu",he.showDbu?"1":"0"),he.rulerManager&&he.rulerManager._renderAll(),he.hierarchyBrowser&&he.hierarchyBrowser._render(),he.updateScaleBar&&he.updateScaleBar(),he.refreshInspector&&he.refreshInspector(),Fb()};he.toggleRulerStyle=function(){he.rulerStyle=he.rulerStyle==="manhattan"?"euclidian":"manhattan",Ff("or_ruler_style",he.rulerStyle),Fb()};he.toggleWheelZoom=function(){he.wheelZoom=!he.wheelZoom,Ff("or_wheel_zoom",he.wheelZoom?"1":"0"),Fb()};he.toggleControlSmoothing=function(){he.controlSmoothing=!he.controlSmoothing,Ff("or_control_smoothing",he.controlSmoothing?"1":"0"),Fb()};he.toggleDoubleBuffer=function(){he.doubleBuffer=!he.doubleBuffer,Ff("or_double_buffer",he.doubleBuffer?"1":"0"),he.view?.applyPrefs(),Fb()};he.toggleDeferTileUpdates=function(){he.deferTileUpdates=!he.deferTileUpdates,Ff("or_defer_tile_updates",he.deferTileUpdates?"1":"0"),he.view?.applyPrefs(),Fb()};he.setArrowStep=function(s){he.arrowStep=tH(s),Ff("or_arrow_step",String(he.arrowStep)),Fb()};he.setAppFont=function({family:s,scale:n}){he.fontFamily=s??he.fontFamily,he.fontScale=rH(n??he.fontScale),Ff("or_font_family",encodeURIComponent(he.fontFamily)),Ff("or_font_scale",String(he.fontScale)),he.applyAppFont(),Fb()};he.applyAppFont=function(){let s=document.documentElement;he.fontFamily?s.style.setProperty("--or-font-family",he.fontFamily):s.style.removeProperty("--or-font-family"),s.style.setProperty("--or-font-scale",String(he.fontScale/100)),he.chartsWidget&&he.chartsWidget.render(),he.clockTreeWidget&&he.clockTreeWidget.render()};he.showArrowStepDialog=()=>p3t(he);he.showAppFontDialog=()=>g3t(he);he.togglePolyDecomp=function(){he.websocketManager&&he.websocketManager.request({type:"poly_decomp",value:!he.polyDecomp}).then(s=>aDe(s.value)).catch(()=>{})};function aDe(s){he.polyDecomp=!!s,he.rebuildMenuBar&&he.rebuildMenuBar(),he.refreshOverlay&&he.refreshOverlay()}he.applyAppFont();he.echoTcl=s=>TT(`>>> ${s} +`,"tcl-cmd");he.runTclScript=(s,n)=>s?(n&&he.echoTcl(s),he.websocketManager.request({type:"tcl_eval",cmd:s}).then(r=>(r&&r.result&&TT(r.result+` +`,r.is_error?"tcl-error":""),r)).catch(r=>{TT(`Error: ${r} +`,"tcl-error")})):Promise.resolve();function q3t(s){s&&(he.customMenu=s.menu||[],he.customToolbar=s.toolbar||[],he.rebuildMenuBar&&he.rebuildMenuBar(),he.rebuildToolbar&&he.rebuildToolbar(),oDe())}he.customMenu=[];he.customToolbar=[];he.scheduleRedrawAllLayers=PO;he.showGlobalConnectDialog=()=>T3t(he);he.showInsertBufferDialog=s=>C3t(he,s);x3t(he);E3t(he);he.contextMenu=new pde(he);function Zpn(){let s=document.getElementById("debug-continue-btn");return s||(s=document.createElement("button"),s.id="debug-continue-btn",s.className="debug-continue-btn",s.textContent="Continue",s.title="Advance the debugger (gpl, cts, ...)",s.addEventListener("click",()=>{he.websocketManager.request({type:"debug_continue"}).catch(()=>{})}),(document.getElementById("menu-bar")||document.body).appendChild(s),s)}function X3t(s,n){let r=$5e(s,Ob(),n);return r?(he.currentBounds=s,he.designScale=r.scale,he.designOriginX=r.originX,he.designOriginY=r.originY,he.fitRect=r.fitRect,he.view.setLimits({minZoom:0,maxZoom:Nxt(r.scale)}),!0):!1}async function cDe(s,n,{reloadOnChange:r=!1}={}){if(la(he)||!he.view)return!1;let c=s,u=n;if(!c)try{let x=await he.websocketManager.request({type:"bounds"});c=x.bounds,u=x.fit_bounds}catch{return!1}if(!c||Bxt(he.currentBounds,c))return!1;if(r)return window.location.reload(),!0;let d=!!he.designScale,[b,w]=he.view.getCenter(),_=d?Pv(b,w,he.designScale,he.designOriginX,he.designOriginY):null;return X3t(c,u)?(_&&he.view.setView(Av(_.dbuX,_.dbuY,he.designScale,he.designOriginX,he.designOriginY),he.view.getZoom(),{animate:!1}),he.clearSelectionOutline&&he.clearSelectionOutline(),K1(),!0):!1}function Kpn(){let s=document.getElementById("loading-overlay");s.style.display="flex";let n=()=>{s.style.display!=="none"&&he.websocketManager.request({type:"bounds"}).then(r=>{r.shapes_ready&&(s.style.display="none")}).catch(()=>{}).finally(()=>{s.style.display!=="none"&&setTimeout(n,1e3)})};setTimeout(n,1e3)}function mde(){he.layerExtents&&he.layerExtents.refetch(s=>he.websocketManager.request(s))}function Jpn(s){document.getElementById("loading-overlay").style.display="none",mde(),cDe(s.bounds,s.fit_bounds).then(n=>{n||K1()}).catch(()=>K1()),he.refreshInspector&&he.refreshInspector()}function Qpn(){let s=document.getElementById("script-running-badge");return s||(s=document.createElement("span"),s.id="script-running-badge",s.className="script-running-badge",s.textContent="Script running",s.title="The view updates when the script pauses or finishes",(document.getElementById("menu-bar")||document.body).appendChild(s),s)}function egn(s){if(he.scriptRunning=s,Qpn().style.display=s?"block":"none",!s){if(!he.booted||!he.designScale){Rpn();return}he.refreshPending&&(he.refreshPending=!1,mde(),he.refreshInspector&&he.refreshInspector()),cDe().then(n=>{n||PO()}).catch(()=>PO())}}he.websocketManager.onPush=s=>{if(s.type==="refresh"){if(he.scriptRunning){he.refreshPending=!0;return}Jpn(s)}else if(s.type==="script_running")egn(!!s.running);else if(s.type==="renderer_controls_changed")he.refreshRendererControls&&he.refreshRendererControls(),PO();else if(s.type==="selection_invalidated")he.updateInspector&&he.updateInspector(null),he.stopSelectionAnimation&&he.stopSelectionAnimation(),he.clearSelectionOutline&&he.clearSelectionOutline(),mk();else if(s.type==="heatmaps_changed")he.websocketManager.request({type:"heatmaps"}).then(rDe).catch(n=>console.error("Heat map refresh failed",n));else if(s.type==="labels_changed")he.labelManager&&he.labelManager.applyRemoteLabels(s.labels);else if(s.type==="drcUpdated")he._drcUpdateTimeout&&clearTimeout(he._drcUpdateTimeout),he._drcUpdateTimeout=setTimeout(()=>{he.drcWidget&&he.drcWidget.refresh()},500);else if(s.type==="debug_paused")he.refreshRendererControls&&he.refreshRendererControls(),Zpn().style.display="block",PO(),he.chartsWidget&&he.websocketManager.request({type:"debug_charts"}).then(n=>he.chartsWidget.setDebugCharts(n.charts||[])).catch(()=>{});else if(s.type==="debug_resumed"){let n=document.getElementById("debug-continue-btn");n&&(n.style.display="none")}else if(s.type==="debug_refresh"){if(he.scriptRunning)return;he.clearSelectionOutline&&he.clearSelectionOutline(),PO()}else if(s.type==="log"){let n=s.text;n.endsWith(` +`)&&(n=n.slice(0,-1)),n&&TT(n+` +`,"")}else s.type==="restore_display_state"?Apn(s.state):s.type==="custom_ui"?q3t(s):s.type==="poly_decomp"?aDe(s.value):s.type==="shutdown"&&(he.websocketManager._shutdown=!0,MT.innerHTML='
Server stopped
',MT.style.display="block")};he.websocketManager.readyPromise.then(async()=>{try{let b=function(w,_={}){let{addToSelection:x=!1,focusInspector:T=!0,context:M=!1,showConnectivity:L=!1}=_;if(!he.designScale)return Promise.resolve(null);let{dbuX:I,dbuY:D}=Pv(w[0],w[1],he.designScale,he.designOriginX,he.designOriginY);if(he.labelManager&&he.labelManager.isActive())return he.labelManager.handleMapClick(I,D),Promise.resolve(null);let F=Ixt(gg,LO),O={type:"select",dbu_x:I,dbu_y:D,zoom:Math.round(he.view.getZoom()),visible_layers:[...he.visibleLayerNames],selectable_layers:[...he.selectableLayers],use_dbu:he.showDbu,...F};x&&(O.add_to_selection=!0),M&&(O.context=!0),L&&(O.show_connectivity=!0),he.visibleChiplets instanceof Set&&(O.visible_chiplets=[...he.visibleChiplets]);let z=Pm(he);return he.websocketManager.request(O).then(Z=>{if(Y1(he,z)){if(console.log("Select response:",Z,"at dbu",I,D),EO(he,Z),Z.selected&&Z.selected.length>0){let H=Z.selected[0];H.type==="Inst"&&(he.selectedInstanceName=H.name,he.schematicWidget&&he.schematicWidget.refresh()),lH(Z),T&&gde("Inspector"),Z.bbox&&(Npn(Z.bbox[0],Z.bbox[1],Z.bbox[2],Z.bbox[3],Z.type),Fpn(Z.bbox,Z.type),he.lastSelectionBounds=Z.bbox.slice(0,4)),O.show_connectivity&&Z.connected_added>0&&Nb(`Selected ${Z.connected_added} connected net`+(Z.connected_added>1?"s":""))}else!x&&!M&&(lH(null),he.clearSelectionOutline&&he.clearSelectionOutline(),he.lastSelectionBounds=null);return sDe(),Z}}).catch(Z=>(console.error("Select failed:",Z),null))},[s,n,r]=await Promise.all([he.websocketManager.request({type:"tech"}),he.websocketManager.request({type:"bounds"}),he.websocketManager.request({type:"heatmaps"})]);mde(),he.hasLiberty=s.has_liberty,he.techData=s,N3t(s.block_name),he.websocketManager.request({type:"custom_ui"}).then(q3t).catch(()=>{}),he.websocketManager.request({type:"poly_decomp"}).then(w=>aDe(w.value)).catch(()=>{});let c=n.bounds,u=n.fit_bounds;if(!m2){let w=he.view.getSize();hxt(Fxt({designBounds:c,fitRect:u,viewW:w.width,viewH:w.height}))}let d=X3t(c,u);if(d){if(he.labelManager&&he.labelManager.reload(),m2){let w=m2.zoom;he.view.setLimits({minZoom:w,maxZoom:w})}if(he.view.fitWorldRect(he.fitRect,{animate:!1}),m2){let w=X1(c[0][1],c[0][0],c[1][1],c[1][0],he.designScale,he.designOriginX,he.designOriginY);m2.setPathOverlay=_=>{he.view.setImageOverlay("timing-path",_?{image:_,rect:w}:null)}}try{let w=sessionStorage.getItem("or_restore_view");if(w){sessionStorage.removeItem("or_restore_view");let _=JSON.parse(w);_&&isFinite(_.dbuX)&&isFinite(_.dbuY)&&isFinite(_.zoom)&&he.view.setView(Av(_.dbuX,_.dbuY,he.designScale,he.designOriginX,he.designOriginY),_.zoom,{animate:!1})}}catch{}}m2&&(document.getElementById("loading-overlay").style.display="none"),he.selectAtWorld=b,m2||(he.onMapClick=(w,_)=>b(w,{addToSelection:!!_.shiftKey,showConnectivity:!!(_.ctrlKey||_.metaKey)}),he.onMapContextClick=(w,_)=>{b(w,{context:!0,focusInspector:!1}).then(()=>he.contextMenu.show(_))}),w3t(he,gg,LO,s,K1,Cpn),!he.overlayLayer&&!m2&&(he.overlayLayer=he.view.addTileSlot("overlay",{order:mp.overlay,source:G5e({wm:he.websocketManager,dpr:xO,tileSize:Ob,buildRequest:(w,_,x)=>Axt(w,_,x,gg,he)})})),rDe(r),d&&!n.shapes_ready&&Kpn(),Fb(),he.booted=!0}catch(s){he.scriptRunning||console.error("Failed to load initial data from server:",s)}});document.addEventListener("openroad-cone-sync",s=>{he.schematicWidget?.syncCone(s.detail||{})});document.addEventListener("keydown",s=>{let n=s.target.tagName;if(n==="INPUT"||n==="TEXTAREA"||s.target.isContentEditable)return;let r=s.key.toLowerCase();if(r==="escape"&&he.rulerManager&&he.rulerManager.isActive())he.rulerManager.cancelRulerBuild();else if(r==="escape"&&he.labelManager&&he.labelManager.isActive())he.labelManager.cancelLabelMode();else if(r==="k"&&!s.shiftKey&&!s.ctrlKey&&!s.metaKey)he.rulerManager&&he.rulerManager.toggleRulerMode();else if(r==="k"&&s.shiftKey&&!s.ctrlKey&&!s.metaKey)he.rulerManager&&he.rulerManager.clearAllRulers();else if(r==="l"&&!s.shiftKey&&!s.ctrlKey&&!s.metaKey)he.labelManager&&he.labelManager.toggleLabelMode();else if(r==="f"&&!s.ctrlKey&&!s.metaKey&&he.fitRect)he.view.fitWorldRect(he.fitRect);else if(r==="z"&&!s.ctrlKey&&he.view){let c=s.shiftKey?-1:1;he.view.zoomAround(he.lastMouseWorld?he.view.project(he.lastMouseWorld):null,c)}else r==="f"&&(s.ctrlKey||s.metaKey)?(s.preventDefault(),he.designScale&&ide(he)):r==="g"&&s.shiftKey&&!s.ctrlKey&&!s.metaKey?(s.preventDefault(),he.designScale&&rde(he)):r==="t"&&!s.shiftKey&&!s.ctrlKey&&!s.metaKey&&he.toggleTheme()},!0);})(); /*! Bundled license information: -leaflet/dist/leaflet-src.js: - (* @preserve - * Leaflet 1.9.4, a JS library for interactive maps. https://leafletjs.com - * (c) 2010-2023 Vladimir Agafonkin, (c) 2010-2011 CloudMade - *) - sax/lib/sax.js: (*! http://mths.be/fromcodepoint v0.1.0 by @mathias *) diff --git a/src/web/dist/index.html b/src/web/dist/index.html index 6bead9b081d..33aa88f2304 100644 --- a/src/web/dist/index.html +++ b/src/web/dist/index.html @@ -11,7 +11,7 @@ - @@ -19,7 +19,7 @@ - diff --git a/src/web/dist/report.min.js b/src/web/dist/report.min.js index 3de7d016e39..f6343535b46 100644 --- a/src/web/dist/report.min.js +++ b/src/web/dist/report.min.js @@ -1,31 +1,6388 @@ -(()=>{var ch=Object.create;var jr=Object.defineProperty;var hh=Object.getOwnPropertyDescriptor;var dh=Object.getOwnPropertyNames;var uh=Object.getPrototypeOf,ph=Object.prototype.hasOwnProperty;var fh=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var mh=(s,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of dh(e))!ph.call(s,r)&&r!==i&&jr(s,r,{get:()=>e[r],enumerable:!(o=hh(e,r))||o.enumerable});return s};var _h=(s,e,i)=>(i=s!=null?ch(uh(s)):{},mh(e||!s||!s.__esModule?jr(i,"default",{value:s,enumerable:!0}):i,s));var Jr=fh((Wn,Kr)=>{(function(s,e){typeof Wn=="object"&&typeof Kr<"u"?e(Wn):typeof define=="function"&&define.amd?define(["exports"],e):(s=typeof globalThis<"u"?globalThis:s||self,e(s.leaflet={}))})(Wn,function(s){"use strict";var e="1.9.4";function i(t){var n,a,c,d;for(a=1,c=arguments.length;a"u"||!L||!L.Mixin)){t=A(t)?t:[t];for(var n=0;n0?Math.floor(t):Math.ceil(t)};rt.prototype={clone:function(){return new rt(this.x,this.y)},add:function(t){return this.clone()._add(at(t))},_add:function(t){return this.x+=t.x,this.y+=t.y,this},subtract:function(t){return this.clone()._subtract(at(t))},_subtract:function(t){return this.x-=t.x,this.y-=t.y,this},divideBy:function(t){return this.clone()._divideBy(t)},_divideBy:function(t){return this.x/=t,this.y/=t,this},multiplyBy:function(t){return this.clone()._multiplyBy(t)},_multiplyBy:function(t){return this.x*=t,this.y*=t,this},scaleBy:function(t){return new rt(this.x*t.x,this.y*t.y)},unscaleBy:function(t){return new rt(this.x/t.x,this.y/t.y)},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.clone()._ceil()},_ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},trunc:function(){return this.clone()._trunc()},_trunc:function(){return this.x=me(this.x),this.y=me(this.y),this},distanceTo:function(t){t=at(t);var n=t.x-this.x,a=t.y-this.y;return Math.sqrt(n*n+a*a)},equals:function(t){return t=at(t),t.x===this.x&&t.y===this.y},contains:function(t){return t=at(t),Math.abs(t.x)<=Math.abs(this.x)&&Math.abs(t.y)<=Math.abs(this.y)},toString:function(){return"Point("+y(this.x)+", "+y(this.y)+")"}};function at(t,n,a){return t instanceof rt?t:A(t)?new rt(t[0],t[1]):t==null?t:typeof t=="object"&&"x"in t&&"y"in t?new rt(t.x,t.y):new rt(t,n,a)}function Lt(t,n){if(t)for(var a=n?[t,n]:t,c=0,d=a.length;c=this.min.x&&a.x<=this.max.x&&n.y>=this.min.y&&a.y<=this.max.y},intersects:function(t){t=zt(t);var n=this.min,a=this.max,c=t.min,d=t.max,m=d.x>=n.x&&c.x<=a.x,x=d.y>=n.y&&c.y<=a.y;return m&&x},overlaps:function(t){t=zt(t);var n=this.min,a=this.max,c=t.min,d=t.max,m=d.x>n.x&&c.xn.y&&c.y=n.lat&&d.lat<=a.lat&&c.lng>=n.lng&&d.lng<=a.lng},intersects:function(t){t=Pt(t);var n=this._southWest,a=this._northEast,c=t.getSouthWest(),d=t.getNorthEast(),m=d.lat>=n.lat&&c.lat<=a.lat,x=d.lng>=n.lng&&c.lng<=a.lng;return m&&x},overlaps:function(t){t=Pt(t);var n=this._southWest,a=this._northEast,c=t.getSouthWest(),d=t.getNorthEast(),m=d.lat>n.lat&&c.latn.lng&&c.lng1,lt=function(){var t=!1;try{var n=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassiveEventSupport",_,n),window.removeEventListener("testPassiveEventSupport",_,n)}catch{}return t}(),Nt=function(){return!!document.createElement("canvas").getContext}(),se=!!(document.createElementNS&&Y("svg").createSVGRect),Ze=!!se&&function(){var t=document.createElement("div");return t.innerHTML="",(t.firstChild&&t.firstChild.namespaceURI)==="http://www.w3.org/2000/svg"}(),kn=!se&&function(){try{var t=document.createElement("div");t.innerHTML='';var n=t.firstChild;return n.style.behavior="url(#default#VML)",n&&typeof n.adj=="object"}catch{return!1}}(),ic=navigator.platform.indexOf("Mac")===0,nc=navigator.platform.indexOf("Linux")===0;function Ce(t){return navigator.userAgent.toLowerCase().indexOf(t)>=0}var et={ie:I,ielt9:O,edge:ct,webkit:kt,android:Xt,android23:Ot,androidStock:xe,opera:Fe,chrome:Bt,gecko:Ke,safari:E,phantom:$,opera12:F,win:U,ie3d:z,webkit3d:W,gecko3d:Z,any3d:D,mobile:X,mobileWebkit:j,mobileWebkit3d:vt,msPointer:mt,pointer:St,touch:$t,touchNative:Tt,mobileOpera:le,mobileGecko:K,retina:st,passiveEvents:lt,canvas:Nt,svg:se,vml:kn,inlineSvg:Ze,mac:ic,linux:nc},er=et.msPointer?"MSPointerDown":"pointerdown",ir=et.msPointer?"MSPointerMove":"pointermove",nr=et.msPointer?"MSPointerUp":"pointerup",sr=et.msPointer?"MSPointerCancel":"pointercancel",zs={touchstart:er,touchmove:ir,touchend:nr,touchcancel:sr},or={touchstart:cc,touchmove:Sn,touchend:Sn,touchcancel:Sn},ki={},rr=!1;function sc(t,n,a){return n==="touchstart"&&lc(),or[n]?(a=or[n].bind(this,a),t.addEventListener(zs[n],a,!1),a):(console.warn("wrong event specified:",n),_)}function oc(t,n,a){if(!zs[n]){console.warn("wrong event specified:",n);return}t.removeEventListener(zs[n],a,!1)}function rc(t){ki[t.pointerId]=t}function ac(t){ki[t.pointerId]&&(ki[t.pointerId]=t)}function ar(t){delete ki[t.pointerId]}function lc(){rr||(document.addEventListener(er,rc,!0),document.addEventListener(ir,ac,!0),document.addEventListener(nr,ar,!0),document.addEventListener(sr,ar,!0),rr=!0)}function Sn(t,n){if(n.pointerType!==(n.MSPOINTER_TYPE_MOUSE||"mouse")){n.touches=[];for(var a in ki)n.touches.push(ki[a]);n.changedTouches=[n],t(n)}}function cc(t,n){n.MSPOINTER_TYPE_TOUCH&&n.pointerType===n.MSPOINTER_TYPE_TOUCH&&Kt(n),Sn(t,n)}function hc(t){var n={},a,c;for(c in t)a=t[c],n[c]=a&&a.bind?a.bind(t):a;return t=n,n.type="dblclick",n.detail=2,n.isTrusted=!1,n._simulated=!0,n}var dc=200;function uc(t,n){t.addEventListener("dblclick",n);var a=0,c;function d(m){if(m.detail!==1){c=m.detail;return}if(!(m.pointerType==="mouse"||m.sourceCapabilities&&!m.sourceCapabilities.firesTouchEvents)){var x=ur(m);if(!(x.some(function(T){return T instanceof HTMLLabelElement&&T.attributes.for})&&!x.some(function(T){return T instanceof HTMLInputElement||T instanceof HTMLSelectElement}))){var S=Date.now();S-a<=dc?(c++,c===2&&n(hc(m))):c=1,a=S}}}return t.addEventListener("click",d),{dblclick:n,simDblclick:d}}function pc(t,n){t.removeEventListener("dblclick",n.dblclick),t.removeEventListener("click",n.simDblclick)}var Os=Tn(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),Vi=Tn(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),lr=Vi==="webkitTransition"||Vi==="OTransition"?Vi+"End":"transitionend";function cr(t){return typeof t=="string"?document.getElementById(t):t}function Yi(t,n){var a=t.style[n]||t.currentStyle&&t.currentStyle[n];if((!a||a==="auto")&&document.defaultView){var c=document.defaultView.getComputedStyle(t,null);a=c?c[n]:null}return a==="auto"?null:a}function xt(t,n,a){var c=document.createElement(t);return c.className=n||"",a&&a.appendChild(c),c}function Dt(t){var n=t.parentNode;n&&n.removeChild(t)}function En(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function Si(t){var n=t.parentNode;n&&n.lastChild!==t&&n.appendChild(t)}function Ei(t){var n=t.parentNode;n&&n.firstChild!==t&&n.insertBefore(t,n.firstChild)}function $s(t,n){if(t.classList!==void 0)return t.classList.contains(n);var a=Mn(t);return a.length>0&&new RegExp("(^|\\s)"+n+"(\\s|$)").test(a)}function pt(t,n){if(t.classList!==void 0)for(var a=v(n),c=0,d=a.length;c0?2*window.devicePixelRatio:1;function fr(t){return et.edge?t.wheelDeltaY/2:t.deltaY&&t.deltaMode===0?-t.deltaY/_c:t.deltaY&&t.deltaMode===1?-t.deltaY*20:t.deltaY&&t.deltaMode===2?-t.deltaY*60:t.deltaX||t.deltaZ?0:t.wheelDelta?(t.wheelDeltaY||t.wheelDelta)/2:t.detail&&Math.abs(t.detail)<32765?-t.detail*20:t.detail?t.detail/-32765*60:0}function Ks(t,n){var a=n.relatedTarget;if(!a)return!0;try{for(;a&&a!==t;)a=a.parentNode}catch{return!1}return a!==t}var gc={__proto__:null,on:ut,off:Mt,stopPropagation:ti,disableScrollPropagation:js,disableClickPropagation:Ji,preventDefault:Kt,stop:ei,getPropagationPath:ur,getMousePosition:pr,getWheelDelta:fr,isExternalTarget:Ks,addListener:ut,removeListener:Mt},mr=Yt.extend({run:function(t,n,a,c){this.stop(),this._el=t,this._inProgress=!0,this._duration=a||.25,this._easeOutPower=1/Math.max(c||.5,.2),this._startPos=Qe(t),this._offset=n.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=nt(this._animate,this),this._step()},_step:function(t){var n=+new Date-this._startTime,a=this._duration*1e3;nthis.options.maxZoom)?this.setZoom(t):this},panInsideBounds:function(t,n){this._enforcingBounds=!0;var a=this.getCenter(),c=this._limitCenter(a,this._zoom,Pt(t));return a.equals(c)||this.panTo(c,n),this._enforcingBounds=!1,this},panInside:function(t,n){n=n||{};var a=at(n.paddingTopLeft||n.padding||[0,0]),c=at(n.paddingBottomRight||n.padding||[0,0]),d=this.project(this.getCenter()),m=this.project(t),x=this.getPixelBounds(),S=zt([x.min.add(a),x.max.subtract(c)]),T=S.getSize();if(!S.contains(m)){this._enforcingBounds=!0;var B=m.subtract(S.getCenter()),V=S.extend(m).getSize().subtract(T);d.x+=B.x<0?-V.x:V.x,d.y+=B.y<0?-V.y:V.y,this.panTo(this.unproject(d),n),this._enforcingBounds=!1}return this},invalidateSize:function(t){if(!this._loaded)return this;t=i({animate:!1,pan:!0},t===!0?{animate:!0}:t);var n=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var a=this.getSize(),c=n.divideBy(2).round(),d=a.divideBy(2).round(),m=c.subtract(d);return!m.x&&!m.y?this:(t.animate&&t.pan?this.panBy(m):(t.pan&&this._rawPanBy(m),this.fire("move"),t.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(r(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:n,newSize:a}))},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(t){if(t=this._locateOptions=i({timeout:1e4,watch:!1},t),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var n=r(this._handleGeolocationResponse,this),a=r(this._handleGeolocationError,this);return t.watch?this._locationWatchId=navigator.geolocation.watchPosition(n,a,t):navigator.geolocation.getCurrentPosition(n,a,t),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(t){if(this._container._leaflet_id){var n=t.code,a=t.message||(n===1?"permission denied":n===2?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:n,message:"Geolocation error: "+a+"."})}},_handleGeolocationResponse:function(t){if(this._container._leaflet_id){var n=t.coords.latitude,a=t.coords.longitude,c=new yt(n,a),d=c.toBounds(t.coords.accuracy*2),m=this._locateOptions;if(m.setView){var x=this.getBoundsZoom(d);this.setView(c,m.maxZoom?Math.min(x,m.maxZoom):x)}var S={latlng:c,bounds:d,timestamp:t.timestamp};for(var T in t.coords)typeof t.coords[T]=="number"&&(S[T]=t.coords[T]);this.fire("locationfound",S)}},addHandler:function(t,n){if(!n)return this;var a=this[t]=new n(this);return this._handlers.push(a),this.options[t]&&a.enable(),this},remove:function(){if(this._initEvents(!0),this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch{this._container._leaflet_id=void 0,this._containerId=void 0}this._locationWatchId!==void 0&&this.stopLocate(),this._stop(),Dt(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(tt(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload");var t;for(t in this._layers)this._layers[t].remove();for(t in this._panes)Dt(this._panes[t]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(t,n){var a="leaflet-pane"+(t?" leaflet-"+t.replace("Pane","")+"-pane":""),c=xt("div",a,n||this._mapPane);return t&&(this._panes[t]=c),c},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var t=this.getPixelBounds(),n=this.unproject(t.getBottomLeft()),a=this.unproject(t.getTopRight());return new Wt(n,a)},getMinZoom:function(){return this.options.minZoom===void 0?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return this.options.maxZoom===void 0?this._layersMaxZoom===void 0?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(t,n,a){t=Pt(t),a=at(a||[0,0]);var c=this.getZoom()||0,d=this.getMinZoom(),m=this.getMaxZoom(),x=t.getNorthWest(),S=t.getSouthEast(),T=this.getSize().subtract(a),B=zt(this.project(S,c),this.project(x,c)).getSize(),V=et.any3d?this.options.zoomSnap:1,ot=T.x/B.x,_t=T.y/B.y,ne=n?Math.max(ot,_t):Math.min(ot,_t);return c=this.getScaleZoom(ne,c),V&&(c=Math.round(c/(V/100))*(V/100),c=n?Math.ceil(c/V)*V:Math.floor(c/V)*V),Math.max(d,Math.min(m,c))},getSize:function(){return(!this._size||this._sizeChanged)&&(this._size=new rt(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(t,n){var a=this._getTopLeftPoint(t,n);return new Lt(a,a.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(t){return this.options.crs.getProjectedBounds(t===void 0?this.getZoom():t)},getPane:function(t){return typeof t=="string"?this._panes[t]:t},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(t,n){var a=this.options.crs;return n=n===void 0?this._zoom:n,a.scale(t)/a.scale(n)},getScaleZoom:function(t,n){var a=this.options.crs;n=n===void 0?this._zoom:n;var c=a.zoom(t*a.scale(n));return isNaN(c)?1/0:c},project:function(t,n){return n=n===void 0?this._zoom:n,this.options.crs.latLngToPoint(ft(t),n)},unproject:function(t,n){return n=n===void 0?this._zoom:n,this.options.crs.pointToLatLng(at(t),n)},layerPointToLatLng:function(t){var n=at(t).add(this.getPixelOrigin());return this.unproject(n)},latLngToLayerPoint:function(t){var n=this.project(ft(t))._round();return n._subtract(this.getPixelOrigin())},wrapLatLng:function(t){return this.options.crs.wrapLatLng(ft(t))},wrapLatLngBounds:function(t){return this.options.crs.wrapLatLngBounds(Pt(t))},distance:function(t,n){return this.options.crs.distance(ft(t),ft(n))},containerPointToLayerPoint:function(t){return at(t).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(t){return at(t).add(this._getMapPanePos())},containerPointToLatLng:function(t){var n=this.containerPointToLayerPoint(at(t));return this.layerPointToLatLng(n)},latLngToContainerPoint:function(t){return this.layerPointToContainerPoint(this.latLngToLayerPoint(ft(t)))},mouseEventToContainerPoint:function(t){return pr(t,this._container)},mouseEventToLayerPoint:function(t){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(t))},mouseEventToLatLng:function(t){return this.layerPointToLatLng(this.mouseEventToLayerPoint(t))},_initContainer:function(t){var n=this._container=cr(t);if(n){if(n._leaflet_id)throw new Error("Map container is already initialized.")}else throw new Error("Map container not found.");ut(n,"scroll",this._onScroll,this),this._containerId=h(n)},_initLayout:function(){var t=this._container;this._fadeAnimated=this.options.fadeAnimation&&et.any3d,pt(t,"leaflet-container"+(et.touch?" leaflet-touch":"")+(et.retina?" leaflet-retina":"")+(et.ielt9?" leaflet-oldie":"")+(et.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var n=Yi(t,"position");n!=="absolute"&&n!=="relative"&&n!=="fixed"&&n!=="sticky"&&(t.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var t=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),Zt(this._mapPane,new rt(0,0)),this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(pt(t.markerPane,"leaflet-zoom-hide"),pt(t.shadowPane,"leaflet-zoom-hide"))},_resetView:function(t,n,a){Zt(this._mapPane,new rt(0,0));var c=!this._loaded;this._loaded=!0,n=this._limitZoom(n),this.fire("viewprereset");var d=this._zoom!==n;this._moveStart(d,a)._move(t,n)._moveEnd(d),this.fire("viewreset"),c&&this.fire("load")},_moveStart:function(t,n){return t&&this.fire("zoomstart"),n||this.fire("movestart"),this},_move:function(t,n,a,c){n===void 0&&(n=this._zoom);var d=this._zoom!==n;return this._zoom=n,this._lastCenter=t,this._pixelOrigin=this._getNewPixelOrigin(t),c?a&&a.pinch&&this.fire("zoom",a):((d||a&&a.pinch)&&this.fire("zoom",a),this.fire("move",a)),this},_moveEnd:function(t){return t&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return tt(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(t){Zt(this._mapPane,this._getMapPanePos().subtract(t))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(t){this._targets={},this._targets[h(this._container)]=this;var n=t?Mt:ut;n(this._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&n(window,"resize",this._onResize,this),et.any3d&&this.options.transform3DLimit&&(t?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){tt(this._resizeRequest),this._resizeRequest=nt(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var t=this._getMapPanePos();Math.max(Math.abs(t.x),Math.abs(t.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(t,n){for(var a=[],c,d=n==="mouseout"||n==="mouseover",m=t.target||t.srcElement,x=!1;m;){if(c=this._targets[h(m)],c&&(n==="click"||n==="preclick")&&this._draggableMoved(c)){x=!0;break}if(c&&c.listens(n,!0)&&(d&&!Ks(m,t)||(a.push(c),d))||m===this._container)break;m=m.parentNode}return!a.length&&!x&&!d&&this.listens(n,!0)&&(a=[this]),a},_isClickDisabled:function(t){for(;t&&t!==this._container;){if(t._leaflet_disable_click)return!0;t=t.parentNode}},_handleDOMEvent:function(t){var n=t.target||t.srcElement;if(!(!this._loaded||n._leaflet_disable_events||t.type==="click"&&this._isClickDisabled(n))){var a=t.type;a==="mousedown"&&Us(n),this._fireDOMEvent(t,a)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(t,n,a){if(t.type==="click"){var c=i({},t);c.type="preclick",this._fireDOMEvent(c,c.type,a)}var d=this._findEventTargets(t,n);if(a){for(var m=[],x=0;x0?Math.round(t-n)/2:Math.max(0,Math.ceil(t))-Math.max(0,Math.floor(n))},_limitZoom:function(t){var n=this.getMinZoom(),a=this.getMaxZoom(),c=et.any3d?this.options.zoomSnap:1;return c&&(t=Math.round(t/c)*c),Math.max(n,Math.min(a,t))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){Ht(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(t,n){var a=this._getCenterOffset(t)._trunc();return(n&&n.animate)!==!0&&!this.getSize().contains(a)?!1:(this.panBy(a,n),!0)},_createAnimProxy:function(){var t=this._proxy=xt("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(t),this.on("zoomanim",function(n){var a=Os,c=this._proxy.style[a];Je(this._proxy,this.project(n.center,n.zoom),this.getZoomScale(n.zoom,1)),c===this._proxy.style[a]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",this._animMoveEnd,this),this._on("unload",this._destroyAnimProxy,this)},_destroyAnimProxy:function(){Dt(this._proxy),this.off("load moveend",this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var t=this.getCenter(),n=this.getZoom();Je(this._proxy,this.project(t,n),this.getZoomScale(n,1))},_catchTransitionEnd:function(t){this._animatingZoom&&t.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(t,n,a){if(this._animatingZoom)return!0;if(a=a||{},!this._zoomAnimated||a.animate===!1||this._nothingToAnimate()||Math.abs(n-this._zoom)>this.options.zoomAnimationThreshold)return!1;var c=this.getZoomScale(n),d=this._getCenterOffset(t)._divideBy(1-1/c);return a.animate!==!0&&!this.getSize().contains(d)?!1:(nt(function(){this._moveStart(!0,a.noMoveStart||!1)._animateZoom(t,n,!0)},this),!0)},_animateZoom:function(t,n,a,c){this._mapPane&&(a&&(this._animatingZoom=!0,this._animateToCenter=t,this._animateToZoom=n,pt(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:t,zoom:n,noUpdate:c}),this._tempFireZoomEvent||(this._tempFireZoomEvent=this._zoom!==this._animateToZoom),this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(r(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&Ht(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire("zoom"),delete this._tempFireZoomEvent,this.fire("move"),this._moveEnd(!0))}});function yc(t,n){return new bt(t,n)}var _e=Et.extend({options:{position:"topright"},initialize:function(t){w(this,t)},getPosition:function(){return this.options.position},setPosition:function(t){var n=this._map;return n&&n.removeControl(this),this.options.position=t,n&&n.addControl(this),this},getContainer:function(){return this._container},addTo:function(t){this.remove(),this._map=t;var n=this._container=this.onAdd(t),a=this.getPosition(),c=t._controlCorners[a];return pt(n,"leaflet-control"),a.indexOf("bottom")!==-1?c.insertBefore(n,c.firstChild):c.appendChild(n),this._map.on("unload",this.remove,this),this},remove:function(){return this._map?(Dt(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null,this):this},_refocusOnMap:function(t){this._map&&t&&t.screenX>0&&t.screenY>0&&this._map.getContainer().focus()}}),Qi=function(t){return new _e(t)};bt.include({addControl:function(t){return t.addTo(this),this},removeControl:function(t){return t.remove(),this},_initControlPos:function(){var t=this._controlCorners={},n="leaflet-",a=this._controlContainer=xt("div",n+"control-container",this._container);function c(d,m){var x=n+d+" "+n+m;t[d+m]=xt("div",x,a)}c("top","left"),c("top","right"),c("bottom","left"),c("bottom","right")},_clearControlPos:function(){for(var t in this._controlCorners)Dt(this._controlCorners[t]);Dt(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var _r=_e.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(t,n,a,c){return a1,this._baseLayersList.style.display=t?"":"none"),this._separator.style.display=n&&t?"":"none",this},_onLayerChange:function(t){this._handlingClick||this._update();var n=this._getLayer(h(t.target)),a=n.overlay?t.type==="add"?"overlayadd":"overlayremove":t.type==="add"?"baselayerchange":null;a&&this._map.fire(a,n)},_createRadioElement:function(t,n){var a='",c=document.createElement("div");return c.innerHTML=a,c.firstChild},_addItem:function(t){var n=document.createElement("label"),a=this._map.hasLayer(t.layer),c;t.overlay?(c=document.createElement("input"),c.type="checkbox",c.className="leaflet-control-layers-selector",c.defaultChecked=a):c=this._createRadioElement("leaflet-base-layers_"+h(this),a),this._layerControlInputs.push(c),c.layerId=h(t.layer),ut(c,"click",this._onInputClick,this);var d=document.createElement("span");d.innerHTML=" "+t.name;var m=document.createElement("span");n.appendChild(m),m.appendChild(c),m.appendChild(d);var x=t.overlay?this._overlaysList:this._baseLayersList;return x.appendChild(n),this._checkDisabledLayers(),n},_onInputClick:function(){if(!this._preventClick){var t=this._layerControlInputs,n,a,c=[],d=[];this._handlingClick=!0;for(var m=t.length-1;m>=0;m--)n=t[m],a=this._getLayer(n.layerId).layer,n.checked?c.push(a):n.checked||d.push(a);for(m=0;m=0;d--)n=t[d],a=this._getLayer(n.layerId).layer,n.disabled=a.options.minZoom!==void 0&&ca.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expandSafely:function(){var t=this._section;this._preventClick=!0,ut(t,"click",Kt),this.expand();var n=this;setTimeout(function(){Mt(t,"click",Kt),n._preventClick=!1})}}),vc=function(t,n,a){return new _r(t,n,a)},Js=_e.extend({options:{position:"topleft",zoomInText:'',zoomInTitle:"Zoom in",zoomOutText:'',zoomOutTitle:"Zoom out"},onAdd:function(t){var n="leaflet-control-zoom",a=xt("div",n+" leaflet-bar"),c=this.options;return this._zoomInButton=this._createButton(c.zoomInText,c.zoomInTitle,n+"-in",a,this._zoomIn),this._zoomOutButton=this._createButton(c.zoomOutText,c.zoomOutTitle,n+"-out",a,this._zoomOut),this._updateDisabled(),t.on("zoomend zoomlevelschange",this._updateDisabled,this),a},onRemove:function(t){t.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(t){!this._disabled&&this._map._zoomthis._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(t.shiftKey?3:1))},_createButton:function(t,n,a,c,d){var m=xt("a",a,c);return m.innerHTML=t,m.href="#",m.title=n,m.setAttribute("role","button"),m.setAttribute("aria-label",n),Ji(m),ut(m,"click",ei),ut(m,"click",d,this),ut(m,"click",this._refocusOnMap,this),m},_updateDisabled:function(){var t=this._map,n="leaflet-disabled";Ht(this._zoomInButton,n),Ht(this._zoomOutButton,n),this._zoomInButton.setAttribute("aria-disabled","false"),this._zoomOutButton.setAttribute("aria-disabled","false"),(this._disabled||t._zoom===t.getMinZoom())&&(pt(this._zoomOutButton,n),this._zoomOutButton.setAttribute("aria-disabled","true")),(this._disabled||t._zoom===t.getMaxZoom())&&(pt(this._zoomInButton,n),this._zoomInButton.setAttribute("aria-disabled","true"))}});bt.mergeOptions({zoomControl:!0}),bt.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new Js,this.addControl(this.zoomControl))});var bc=function(t){return new Js(t)},gr=_e.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(t){var n="leaflet-control-scale",a=xt("div",n),c=this.options;return this._addScales(c,n+"-line",a),t.on(c.updateWhenIdle?"moveend":"move",this._update,this),t.whenReady(this._update,this),a},onRemove:function(t){t.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(t,n,a){t.metric&&(this._mScale=xt("div",n,a)),t.imperial&&(this._iScale=xt("div",n,a))},_update:function(){var t=this._map,n=t.getSize().y/2,a=t.distance(t.containerPointToLatLng([0,n]),t.containerPointToLatLng([this.options.maxWidth,n]));this._updateScales(a)},_updateScales:function(t){this.options.metric&&t&&this._updateMetric(t),this.options.imperial&&t&&this._updateImperial(t)},_updateMetric:function(t){var n=this._getRoundNum(t),a=n<1e3?n+" m":n/1e3+" km";this._updateScale(this._mScale,a,n/t)},_updateImperial:function(t){var n=t*3.2808399,a,c,d;n>5280?(a=n/5280,c=this._getRoundNum(a),this._updateScale(this._iScale,c+" mi",c/a)):(d=this._getRoundNum(n),this._updateScale(this._iScale,d+" ft",d/n))},_updateScale:function(t,n,a){t.style.width=Math.round(this.options.maxWidth*a)+"px",t.innerHTML=n},_getRoundNum:function(t){var n=Math.pow(10,(Math.floor(t)+"").length-1),a=t/n;return a=a>=10?10:a>=5?5:a>=3?3:a>=2?2:1,n*a}}),wc=function(t){return new gr(t)},xc='',Qs=_e.extend({options:{position:"bottomright",prefix:''+(et.inlineSvg?xc+" ":"")+"Leaflet"},initialize:function(t){w(this,t),this._attributions={}},onAdd:function(t){t.attributionControl=this,this._container=xt("div","leaflet-control-attribution"),Ji(this._container);for(var n in t._layers)t._layers[n].getAttribution&&this.addAttribution(t._layers[n].getAttribution());return this._update(),t.on("layeradd",this._addAttribution,this),this._container},onRemove:function(t){t.off("layeradd",this._addAttribution,this)},_addAttribution:function(t){t.layer.getAttribution&&(this.addAttribution(t.layer.getAttribution()),t.layer.once("remove",function(){this.removeAttribution(t.layer.getAttribution())},this))},setPrefix:function(t){return this.options.prefix=t,this._update(),this},addAttribution:function(t){return t?(this._attributions[t]||(this._attributions[t]=0),this._attributions[t]++,this._update(),this):this},removeAttribution:function(t){return t?(this._attributions[t]&&(this._attributions[t]--,this._update()),this):this},_update:function(){if(this._map){var t=[];for(var n in this._attributions)this._attributions[n]&&t.push(n);var a=[];this.options.prefix&&a.push(this.options.prefix),t.length&&a.push(t.join(", ")),this._container.innerHTML=a.join(' ')}}});bt.mergeOptions({attributionControl:!0}),bt.addInitHook(function(){this.options.attributionControl&&new Qs().addTo(this)});var Cc=function(t){return new Qs(t)};_e.Layers=_r,_e.Zoom=Js,_e.Scale=gr,_e.Attribution=Qs,Qi.layers=vc,Qi.zoom=bc,Qi.scale=wc,Qi.attribution=Cc;var ke=Et.extend({initialize:function(t){this._map=t},enable:function(){return this._enabled?this:(this._enabled=!0,this.addHooks(),this)},disable:function(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this},enabled:function(){return!!this._enabled}});ke.addTo=function(t,n){return t.addHandler(n,this),this};var Lc={Events:It},yr=et.touch?"touchstart mousedown":"mousedown",qe=Yt.extend({options:{clickTolerance:3},initialize:function(t,n,a,c){w(this,c),this._element=t,this._dragStartTarget=n||t,this._preventOutline=a},enable:function(){this._enabled||(ut(this._dragStartTarget,yr,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(qe._dragging===this&&this.finishDrag(!0),Mt(this._dragStartTarget,yr,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(t){if(this._enabled&&(this._moved=!1,!$s(this._element,"leaflet-zoom-anim"))){if(t.touches&&t.touches.length!==1){qe._dragging===this&&this.finishDrag();return}if(!(qe._dragging||t.shiftKey||t.which!==1&&t.button!==1&&!t.touches)&&(qe._dragging=this,this._preventOutline&&Us(this._element),Zs(),Xi(),!this._moving)){this.fire("down");var n=t.touches?t.touches[0]:t,a=hr(this._element);this._startPoint=new rt(n.clientX,n.clientY),this._startPos=Qe(this._element),this._parentScale=Gs(a);var c=t.type==="mousedown";ut(document,c?"mousemove":"touchmove",this._onMove,this),ut(document,c?"mouseup":"touchend touchcancel",this._onUp,this)}}},_onMove:function(t){if(this._enabled){if(t.touches&&t.touches.length>1){this._moved=!0;return}var n=t.touches&&t.touches.length===1?t.touches[0]:t,a=new rt(n.clientX,n.clientY)._subtract(this._startPoint);!a.x&&!a.y||Math.abs(a.x)+Math.abs(a.y)m&&(x=S,m=T);m>a&&(n[x]=1,eo(t,n,a,c,x),eo(t,n,a,x,d))}function Mc(t,n){for(var a=[t[0]],c=1,d=0,m=t.length;cn&&(a.push(t[c]),d=c);return dn.max.x&&(a|=2),t.yn.max.y&&(a|=8),a}function Tc(t,n){var a=n.x-t.x,c=n.y-t.y;return a*a+c*c}function tn(t,n,a,c){var d=n.x,m=n.y,x=a.x-d,S=a.y-m,T=x*x+S*S,B;return T>0&&(B=((t.x-d)*x+(t.y-m)*S)/T,B>1?(d=a.x,m=a.y):B>0&&(d+=x*B,m+=S*B)),x=t.x-d,S=t.y-m,c?x*x+S*S:new rt(d,m)}function pe(t){return!A(t[0])||typeof t[0][0]!="object"&&typeof t[0][0]<"u"}function kr(t){return console.warn("Deprecated use of _flat, please use L.LineUtil.isFlat instead."),pe(t)}function Sr(t,n){var a,c,d,m,x,S,T,B;if(!t||t.length===0)throw new Error("latlngs not passed");pe(t)||(console.warn("latlngs are not flat! Only the first ring will be used"),t=t[0]);var V=ft([0,0]),ot=Pt(t),_t=ot.getNorthWest().distanceTo(ot.getSouthWest())*ot.getNorthEast().distanceTo(ot.getNorthWest());_t<1700&&(V=to(t));var ne=t.length,Ut=[];for(a=0;ac){T=(m-c)/d,B=[S.x-T*(S.x-x.x),S.y-T*(S.y-x.y)];break}var oe=n.unproject(at(B));return ft([oe.lat+V.lat,oe.lng+V.lng])}var Pc={__proto__:null,simplify:wr,pointToSegmentDistance:xr,closestPointOnSegment:Sc,clipSegment:Lr,_getEdgeIntersection:In,_getBitCode:ii,_sqClosestPointOnSegment:tn,isFlat:pe,_flat:kr,polylineCenter:Sr},io={project:function(t){return new rt(t.lng,t.lat)},unproject:function(t){return new yt(t.y,t.x)},bounds:new Lt([-180,-90],[180,90])},no={R:6378137,R_MINOR:6356752314245179e-9,bounds:new Lt([-2003750834279e-5,-1549657073972e-5],[2003750834279e-5,1876465623138e-5]),project:function(t){var n=Math.PI/180,a=this.R,c=t.lat*n,d=this.R_MINOR/a,m=Math.sqrt(1-d*d),x=m*Math.sin(c),S=Math.tan(Math.PI/4-c/2)/Math.pow((1-x)/(1+x),m/2);return c=-a*Math.log(Math.max(S,1e-10)),new rt(t.lng*n*a,c)},unproject:function(t){for(var n=180/Math.PI,a=this.R,c=this.R_MINOR/a,d=Math.sqrt(1-c*c),m=Math.exp(-t.y/a),x=Math.PI/2-2*Math.atan(m),S=0,T=.1,B;S<15&&Math.abs(T)>1e-7;S++)B=d*Math.sin(x),B=Math.pow((1-B)/(1+B),d/2),T=Math.PI/2-2*Math.atan(m*B)-x,x+=T;return new yt(x*n,t.x*n/a)}},Ac={__proto__:null,LonLat:io,Mercator:no,SphericalMercator:ee},Ic=i({},ie,{code:"EPSG:3395",projection:no,transformation:function(){var t=.5/(Math.PI*no.R);return k(t,.5,-t,.5)}()}),Er=i({},ie,{code:"EPSG:4326",projection:io,transformation:k(1/180,1,-1/180,.5)}),Bc=i({},ae,{projection:io,transformation:k(1,0,-1,0),scale:function(t){return Math.pow(2,t)},zoom:function(t){return Math.log(t)/Math.LN2},distance:function(t,n){var a=n.lng-t.lng,c=n.lat-t.lat;return Math.sqrt(a*a+c*c)},infinite:!0});ae.Earth=ie,ae.EPSG3395=Ic,ae.EPSG3857=H,ae.EPSG900913=N,ae.EPSG4326=Er,ae.Simple=Bc;var ge=Yt.extend({options:{pane:"overlayPane",attribution:null,bubblingMouseEvents:!0},addTo:function(t){return t.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(t){return t&&t.removeLayer(this),this},getPane:function(t){return this._map.getPane(t?this.options[t]||t:this.options.pane)},addInteractiveTarget:function(t){return this._map._targets[h(t)]=this,this},removeInteractiveTarget:function(t){return delete this._map._targets[h(t)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(t){var n=t.target;if(n.hasLayer(this)){if(this._map=n,this._zoomAnimated=n._zoomAnimated,this.getEvents){var a=this.getEvents();n.on(a,this),this.once("remove",function(){n.off(a,this)},this)}this.onAdd(n),this.fire("add"),n.fire("layeradd",{layer:this})}}});bt.include({addLayer:function(t){if(!t._layerAdd)throw new Error("The provided object is not a Layer.");var n=h(t);return this._layers[n]?this:(this._layers[n]=t,t._mapToAdd=this,t.beforeAdd&&t.beforeAdd(this),this.whenReady(t._layerAdd,t),this)},removeLayer:function(t){var n=h(t);return this._layers[n]?(this._loaded&&t.onRemove(this),delete this._layers[n],this._loaded&&(this.fire("layerremove",{layer:t}),t.fire("remove")),t._map=t._mapToAdd=null,this):this},hasLayer:function(t){return h(t)in this._layers},eachLayer:function(t,n){for(var a in this._layers)t.call(n,this._layers[a]);return this},_addLayers:function(t){t=t?A(t)?t:[t]:[];for(var n=0,a=t.length;nthis._layersMaxZoom&&this.setZoom(this._layersMaxZoom),this.options.minZoom===void 0&&this._layersMinZoom&&this.getZoom()=2&&n[0]instanceof yt&&n[0].equals(n[a-1])&&n.pop(),n},_setLatLngs:function(t){Ae.prototype._setLatLngs.call(this,t),pe(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return pe(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var t=this._renderer._bounds,n=this.options.weight,a=new rt(n,n);if(t=new Lt(t.min.subtract(a),t.max.add(a)),this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(t))){if(this.options.noClip){this._parts=this._rings;return}for(var c=0,d=this._rings.length,m;ct.y!=d.y>t.y&&t.x<(d.x-c.x)*(t.y-c.y)/(d.y-c.y)+c.x&&(n=!n);return n||Ae.prototype._containsPoint.call(this,t,!0)}});function Fc(t,n){return new Pi(t,n)}var Ie=Pe.extend({initialize:function(t,n){w(this,n),this._layers={},t&&this.addData(t)},addData:function(t){var n=A(t)?t:t.features,a,c,d;if(n){for(a=0,c=n.length;a0&&d.push(d[0].slice()),d}function Ai(t,n){return t.feature?i({},t.feature,{geometry:n}):On(n)}function On(t){return t.type==="Feature"||t.type==="FeatureCollection"?t:{type:"Feature",properties:{},geometry:t}}var ao={toGeoJSON:function(t){return Ai(this,{type:"Point",coordinates:ro(this.getLatLng(),t)})}};Bn.include(ao),so.include(ao),Nn.include(ao),Ae.include({toGeoJSON:function(t){var n=!pe(this._latlngs),a=zn(this._latlngs,n?1:0,!1,t);return Ai(this,{type:(n?"Multi":"")+"LineString",coordinates:a})}}),Pi.include({toGeoJSON:function(t){var n=!pe(this._latlngs),a=n&&!pe(this._latlngs[0]),c=zn(this._latlngs,a?2:n?1:0,!0,t);return n||(c=[c]),Ai(this,{type:(a?"Multi":"")+"Polygon",coordinates:c})}}),Mi.include({toMultiPoint:function(t){var n=[];return this.eachLayer(function(a){n.push(a.toGeoJSON(t).geometry.coordinates)}),Ai(this,{type:"MultiPoint",coordinates:n})},toGeoJSON:function(t){var n=this.feature&&this.feature.geometry&&this.feature.geometry.type;if(n==="MultiPoint")return this.toMultiPoint(t);var a=n==="GeometryCollection",c=[];return this.eachLayer(function(d){if(d.toGeoJSON){var m=d.toGeoJSON(t);if(a)c.push(m.geometry);else{var x=On(m);x.type==="FeatureCollection"?c.push.apply(c,x.features):c.push(x)}}}),a?Ai(this,{geometries:c,type:"GeometryCollection"}):{type:"FeatureCollection",features:c}}});function Pr(t,n){return new Ie(t,n)}var Zc=Pr,$n=ge.extend({options:{opacity:1,alt:"",interactive:!1,crossOrigin:!1,errorOverlayUrl:"",zIndex:1,className:""},initialize:function(t,n,a){this._url=t,this._bounds=Pt(n),w(this,a)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(pt(this._image,"leaflet-interactive"),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){Dt(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(t){return this.options.opacity=t,this._image&&this._updateOpacity(),this},setStyle:function(t){return t.opacity&&this.setOpacity(t.opacity),this},bringToFront:function(){return this._map&&Si(this._image),this},bringToBack:function(){return this._map&&Ei(this._image),this},setUrl:function(t){return this._url=t,this._image&&(this._image.src=t),this},setBounds:function(t){return this._bounds=Pt(t),this._map&&this._reset(),this},getEvents:function(){var t={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(t.zoomanim=this._animateZoom),t},setZIndex:function(t){return this.options.zIndex=t,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var t=this._url.tagName==="IMG",n=this._image=t?this._url:xt("img");if(pt(n,"leaflet-image-layer"),this._zoomAnimated&&pt(n,"leaflet-zoom-animated"),this.options.className&&pt(n,this.options.className),n.onselectstart=_,n.onmousemove=_,n.onload=r(this.fire,this,"load"),n.onerror=r(this._overlayOnError,this,"error"),(this.options.crossOrigin||this.options.crossOrigin==="")&&(n.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),t){this._url=n.src;return}n.src=this._url,n.alt=this.options.alt},_animateZoom:function(t){var n=this._map.getZoomScale(t.zoom),a=this._map._latLngBoundsToNewLayerBounds(this._bounds,t.zoom,t.center).min;Je(this._image,a,n)},_reset:function(){var t=this._image,n=new Lt(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),a=n.getSize();Zt(t,n.min),t.style.width=a.x+"px",t.style.height=a.y+"px"},_updateOpacity:function(){ue(this._image,this.options.opacity)},_updateZIndex:function(){this._image&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._image.style.zIndex=this.options.zIndex)},_overlayOnError:function(){this.fire("error");var t=this.options.errorOverlayUrl;t&&this._url!==t&&(this._url=t,this._image.src=t)},getCenter:function(){return this._bounds.getCenter()}}),qc=function(t,n,a){return new $n(t,n,a)},Ar=$n.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0},_initImage:function(){var t=this._url.tagName==="VIDEO",n=this._image=t?this._url:xt("video");if(pt(n,"leaflet-image-layer"),this._zoomAnimated&&pt(n,"leaflet-zoom-animated"),this.options.className&&pt(n,this.options.className),n.onselectstart=_,n.onmousemove=_,n.onloadeddata=r(this.fire,this,"load"),t){for(var a=n.getElementsByTagName("source"),c=[],d=0;d0?c:[n.src];return}A(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(n.style,"objectFit")&&(n.style.objectFit="fill"),n.autoplay=!!this.options.autoplay,n.loop=!!this.options.loop,n.muted=!!this.options.muted,n.playsInline=!!this.options.playsInline;for(var m=0;md?(n.height=d+"px",pt(t,m)):Ht(t,m),this._containerWidth=this._container.offsetWidth},_animateZoom:function(t){var n=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center),a=this._getAnchor();Zt(this._container,n.add(a))},_adjustPan:function(){if(this.options.autoPan){if(this._map._panAnim&&this._map._panAnim.stop(),this._autopanning){this._autopanning=!1;return}var t=this._map,n=parseInt(Yi(this._container,"marginBottom"),10)||0,a=this._container.offsetHeight+n,c=this._containerWidth,d=new rt(this._containerLeft,-a-this._containerBottom);d._add(Qe(this._container));var m=t.layerPointToContainerPoint(d),x=at(this.options.autoPanPadding),S=at(this.options.autoPanPaddingTopLeft||x),T=at(this.options.autoPanPaddingBottomRight||x),B=t.getSize(),V=0,ot=0;m.x+c+T.x>B.x&&(V=m.x+c-B.x+T.x),m.x-V-S.x<0&&(V=m.x-S.x),m.y+a+T.y>B.y&&(ot=m.y+a-B.y+T.y),m.y-ot-S.y<0&&(ot=m.y-S.y),(V||ot)&&(this.options.keepInView&&(this._autopanning=!0),t.fire("autopanstart").panBy([V,ot]))}},_getAnchor:function(){return at(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}),Gc=function(t,n){return new Hn(t,n)};bt.mergeOptions({closePopupOnClick:!0}),bt.include({openPopup:function(t,n,a){return this._initOverlay(Hn,t,n,a).openOn(this),this},closePopup:function(t){return t=arguments.length?t:this._popup,t&&t.close(),this}}),ge.include({bindPopup:function(t,n){return this._popup=this._initOverlay(Hn,this._popup,t,n),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(t){return this._popup&&(this instanceof Pe||(this._popup._source=this),this._popup._prepareOpen(t||this._latlng)&&this._popup.openOn(this._map)),this},closePopup:function(){return this._popup&&this._popup.close(),this},togglePopup:function(){return this._popup&&this._popup.toggle(this),this},isPopupOpen:function(){return this._popup?this._popup.isOpen():!1},setPopupContent:function(t){return this._popup&&this._popup.setContent(t),this},getPopup:function(){return this._popup},_openPopup:function(t){if(!(!this._popup||!this._map)){ei(t);var n=t.layer||t.target;if(this._popup._source===n&&!(n instanceof We)){this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(t.latlng);return}this._popup._source=n,this.openPopup(t.latlng)}},_movePopup:function(t){this._popup.setLatLng(t.latlng)},_onKeyPress:function(t){t.originalEvent.keyCode===13&&this._openPopup(t)}});var Fn=Se.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:.9},onAdd:function(t){Se.prototype.onAdd.call(this,t),this.setOpacity(this.options.opacity),t.fire("tooltipopen",{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0))},onRemove:function(t){Se.prototype.onRemove.call(this,t),t.fire("tooltipclose",{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0))},getEvents:function(){var t=Se.prototype.getEvents.call(this);return this.options.permanent||(t.preclick=this.close),t},_initLayout:function(){var t="leaflet-tooltip",n=t+" "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=xt("div",n),this._container.setAttribute("role","tooltip"),this._container.setAttribute("id","leaflet-tooltip-"+h(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(t){var n,a,c=this._map,d=this._container,m=c.latLngToContainerPoint(c.getCenter()),x=c.layerPointToContainerPoint(t),S=this.options.direction,T=d.offsetWidth,B=d.offsetHeight,V=at(this.options.offset),ot=this._getAnchor();S==="top"?(n=T/2,a=B):S==="bottom"?(n=T/2,a=0):S==="center"?(n=T/2,a=B/2):S==="right"?(n=0,a=B/2):S==="left"?(n=T,a=B/2):x.xthis.options.maxZoom||ac?this._retainParent(d,m,x,c):!1)},_retainChildren:function(t,n,a,c){for(var d=2*t;d<2*t+2;d++)for(var m=2*n;m<2*n+2;m++){var x=new rt(d,m);x.z=a+1;var S=this._tileCoordsToKey(x),T=this._tiles[S];if(T&&T.active){T.retain=!0;continue}else T&&T.loaded&&(T.retain=!0);a+1this.options.maxZoom||this.options.minZoom!==void 0&&d1){this._setView(t,a);return}for(var ot=d.min.y;ot<=d.max.y;ot++)for(var _t=d.min.x;_t<=d.max.x;_t++){var ne=new rt(_t,ot);if(ne.z=this._tileZoom,!!this._isValidTile(ne)){var Ut=this._tiles[this._tileCoordsToKey(ne)];Ut?Ut.current=!0:x.push(ne)}}if(x.sort(function(oe,Bi){return oe.distanceTo(m)-Bi.distanceTo(m)}),x.length!==0){this._loading||(this._loading=!0,this.fire("loading"));var fe=document.createDocumentFragment();for(_t=0;_ta.max.x)||!n.wrapLat&&(t.ya.max.y))return!1}if(!this.options.bounds)return!0;var c=this._tileCoordsToBounds(t);return Pt(this.options.bounds).overlaps(c)},_keyToBounds:function(t){return this._tileCoordsToBounds(this._keyToTileCoords(t))},_tileCoordsToNwSe:function(t){var n=this._map,a=this.getTileSize(),c=t.scaleBy(a),d=c.add(a),m=n.unproject(c,t.z),x=n.unproject(d,t.z);return[m,x]},_tileCoordsToBounds:function(t){var n=this._tileCoordsToNwSe(t),a=new Wt(n[0],n[1]);return this.options.noWrap||(a=this._map.wrapLatLngBounds(a)),a},_tileCoordsToKey:function(t){return t.x+":"+t.y+":"+t.z},_keyToTileCoords:function(t){var n=t.split(":"),a=new rt(+n[0],+n[1]);return a.z=+n[2],a},_removeTile:function(t){var n=this._tiles[t];n&&(Dt(n.el),delete this._tiles[t],this.fire("tileunload",{tile:n.el,coords:this._keyToTileCoords(t)}))},_initTile:function(t){pt(t,"leaflet-tile");var n=this.getTileSize();t.style.width=n.x+"px",t.style.height=n.y+"px",t.onselectstart=_,t.onmousemove=_,et.ielt9&&this.options.opacity<1&&ue(t,this.options.opacity)},_addTile:function(t,n){var a=this._getTilePos(t),c=this._tileCoordsToKey(t),d=this.createTile(this._wrapCoords(t),r(this._tileReady,this,t));this._initTile(d),this.createTile.length<2&&nt(r(this._tileReady,this,t,null,d)),Zt(d,a),this._tiles[c]={el:d,coords:t,current:!0},n.appendChild(d),this.fire("tileloadstart",{tile:d,coords:t})},_tileReady:function(t,n,a){n&&this.fire("tileerror",{error:n,tile:a,coords:t});var c=this._tileCoordsToKey(t);a=this._tiles[c],a&&(a.loaded=+new Date,this._map._fadeAnimated?(ue(a.el,0),tt(this._fadeFrame),this._fadeFrame=nt(this._updateOpacity,this)):(a.active=!0,this._pruneTiles()),n||(pt(a.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:a.el,coords:t})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),et.ielt9||!this._map._fadeAnimated?nt(this._pruneTiles,this):setTimeout(r(this._pruneTiles,this),250)))},_getTilePos:function(t){return t.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(t){var n=new rt(this._wrapX?f(t.x,this._wrapX):t.x,this._wrapY?f(t.y,this._wrapY):t.y);return n.z=t.z,n},_pxBoundsToTileRange:function(t){var n=this.getTileSize();return new Lt(t.min.unscaleBy(n).floor(),t.max.unscaleBy(n).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var t in this._tiles)if(!this._tiles[t].loaded)return!1;return!0}});function Xc(t){return new nn(t)}var Ii=nn.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(t,n){this._url=t,n=w(this,n),n.detectRetina&&et.retina&&n.maxZoom>0?(n.tileSize=Math.floor(n.tileSize/2),n.zoomReverse?(n.zoomOffset--,n.minZoom=Math.min(n.maxZoom,n.minZoom+1)):(n.zoomOffset++,n.maxZoom=Math.max(n.minZoom,n.maxZoom-1)),n.minZoom=Math.max(0,n.minZoom)):n.zoomReverse?n.minZoom=Math.min(n.maxZoom,n.minZoom):n.maxZoom=Math.max(n.minZoom,n.maxZoom),typeof n.subdomains=="string"&&(n.subdomains=n.subdomains.split("")),this.on("tileunload",this._onTileRemove)},setUrl:function(t,n){return this._url===t&&n===void 0&&(n=!0),this._url=t,n||this.redraw(),this},createTile:function(t,n){var a=document.createElement("img");return ut(a,"load",r(this._tileOnLoad,this,n,a)),ut(a,"error",r(this._tileOnError,this,n,a)),(this.options.crossOrigin||this.options.crossOrigin==="")&&(a.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),typeof this.options.referrerPolicy=="string"&&(a.referrerPolicy=this.options.referrerPolicy),a.alt="",a.src=this.getTileUrl(t),a},getTileUrl:function(t){var n={r:et.retina?"@2x":"",s:this._getSubdomain(t),x:t.x,y:t.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var a=this._globalTileRange.max.y-t.y;this.options.tms&&(n.y=a),n["-y"]=a}return R(this._url,i(n,this.options))},_tileOnLoad:function(t,n){et.ielt9?setTimeout(r(t,this,null,n),0):t(null,n)},_tileOnError:function(t,n,a){var c=this.options.errorTileUrl;c&&n.getAttribute("src")!==c&&(n.src=c),t(a,n)},_onTileRemove:function(t){t.tile.onload=null},_getZoomForUrl:function(){var t=this._tileZoom,n=this.options.maxZoom,a=this.options.zoomReverse,c=this.options.zoomOffset;return a&&(t=n-t),t+c},_getSubdomain:function(t){var n=Math.abs(t.x+t.y)%this.options.subdomains.length;return this.options.subdomains[n]},_abortLoading:function(){var t,n;for(t in this._tiles)if(this._tiles[t].coords.z!==this._tileZoom&&(n=this._tiles[t].el,n.onload=_,n.onerror=_,!n.complete)){n.src=q;var a=this._tiles[t].coords;Dt(n),delete this._tiles[t],this.fire("tileabort",{tile:n,coords:a})}},_removeTile:function(t){var n=this._tiles[t];if(n)return n.el.setAttribute("src",q),nn.prototype._removeTile.call(this,t)},_tileReady:function(t,n,a){if(!(!this._map||a&&a.getAttribute("src")===q))return nn.prototype._tileReady.call(this,t,n,a)}});function Nr(t,n){return new Ii(t,n)}var Dr=Ii.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(t,n){this._url=t;var a=i({},this.defaultWmsParams);for(var c in n)c in this.options||(a[c]=n[c]);n=w(this,n);var d=n.detectRetina&&et.retina?2:1,m=this.getTileSize();a.width=m.x*d,a.height=m.y*d,this.wmsParams=a},onAdd:function(t){this._crs=this.options.crs||t.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var n=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[n]=this._crs.code,Ii.prototype.onAdd.call(this,t)},getTileUrl:function(t){var n=this._tileCoordsToNwSe(t),a=this._crs,c=zt(a.project(n[0]),a.project(n[1])),d=c.min,m=c.max,x=(this._wmsVersion>=1.3&&this._crs===Er?[d.y,d.x,m.y,m.x]:[d.x,d.y,m.x,m.y]).join(","),S=Ii.prototype.getTileUrl.call(this,t);return S+b(this.wmsParams,S,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+x},setParams:function(t,n){return i(this.wmsParams,t),n||this.redraw(),this}});function jc(t,n){return new Dr(t,n)}Ii.WMS=Dr,Nr.wms=jc;var Be=ge.extend({options:{padding:.1},initialize:function(t){w(this,t),h(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),pt(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){this.off("update",this._updatePaths,this),this._destroyContainer()},getEvents:function(){var t={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(t.zoomanim=this._onAnimZoom),t},_onAnimZoom:function(t){this._updateTransform(t.center,t.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(t,n){var a=this._map.getZoomScale(n,this._zoom),c=this._map.getSize().multiplyBy(.5+this.options.padding),d=this._map.project(this._center,n),m=c.multiplyBy(-a).add(d).subtract(this._map._getNewPixelOrigin(t,n));et.any3d?Je(this._container,m,a):Zt(this._container,m)},_reset:function(){this._update(),this._updateTransform(this._center,this._zoom);for(var t in this._layers)this._layers[t]._reset()},_onZoomEnd:function(){for(var t in this._layers)this._layers[t]._project()},_updatePaths:function(){for(var t in this._layers)this._layers[t]._update()},_update:function(){var t=this.options.padding,n=this._map.getSize(),a=this._map.containerPointToLayerPoint(n.multiplyBy(-t)).round();this._bounds=new Lt(a,a.add(n.multiplyBy(1+t*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),Rr=Be.extend({options:{tolerance:0},getEvents:function(){var t=Be.prototype.getEvents.call(this);return t.viewprereset=this._onViewPreReset,t},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){Be.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var t=this._container=document.createElement("canvas");ut(t,"mousemove",this._onMouseMove,this),ut(t,"click dblclick mousedown mouseup contextmenu",this._onClick,this),ut(t,"mouseout",this._handleMouseOut,this),t._leaflet_disable_events=!0,this._ctx=t.getContext("2d")},_destroyContainer:function(){tt(this._redrawRequest),delete this._ctx,Dt(this._container),Mt(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){var t;this._redrawBounds=null;for(var n in this._layers)t=this._layers[n],t._update();this._redraw()}},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){Be.prototype._update.call(this);var t=this._bounds,n=this._container,a=t.getSize(),c=et.retina?2:1;Zt(n,t.min),n.width=c*a.x,n.height=c*a.y,n.style.width=a.x+"px",n.style.height=a.y+"px",et.retina&&this._ctx.scale(2,2),this._ctx.translate(-t.min.x,-t.min.y),this.fire("update")}},_reset:function(){Be.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(t){this._updateDashArray(t),this._layers[h(t)]=t;var n=t._order={layer:t,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=n),this._drawLast=n,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(t){this._requestRedraw(t)},_removePath:function(t){var n=t._order,a=n.next,c=n.prev;a?a.prev=c:this._drawLast=c,c?c.next=a:this._drawFirst=a,delete t._order,delete this._layers[h(t)],this._requestRedraw(t)},_updatePath:function(t){this._extendRedrawBounds(t),t._project(),t._update(),this._requestRedraw(t)},_updateStyle:function(t){this._updateDashArray(t),this._requestRedraw(t)},_updateDashArray:function(t){if(typeof t.options.dashArray=="string"){var n=t.options.dashArray.split(/[, ]+/),a=[],c,d;for(d=0;d')}}catch{}return function(t){return document.createElement("<"+t+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}(),Kc={_initContainer:function(){this._container=xt("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(Be.prototype._update.call(this),this.fire("update"))},_initPath:function(t){var n=t._container=sn("shape");pt(n,"leaflet-vml-shape "+(this.options.className||"")),n.coordsize="1 1",t._path=sn("path"),n.appendChild(t._path),this._updateStyle(t),this._layers[h(t)]=t},_addPath:function(t){var n=t._container;this._container.appendChild(n),t.options.interactive&&t.addInteractiveTarget(n)},_removePath:function(t){var n=t._container;Dt(n),t.removeInteractiveTarget(n),delete this._layers[h(t)]},_updateStyle:function(t){var n=t._stroke,a=t._fill,c=t.options,d=t._container;d.stroked=!!c.stroke,d.filled=!!c.fill,c.stroke?(n||(n=t._stroke=sn("stroke")),d.appendChild(n),n.weight=c.weight+"px",n.color=c.color,n.opacity=c.opacity,c.dashArray?n.dashStyle=A(c.dashArray)?c.dashArray.join(" "):c.dashArray.replace(/( *, *)/g," "):n.dashStyle="",n.endcap=c.lineCap.replace("butt","flat"),n.joinstyle=c.lineJoin):n&&(d.removeChild(n),t._stroke=null),c.fill?(a||(a=t._fill=sn("fill")),d.appendChild(a),a.color=c.fillColor||c.color,a.opacity=c.fillOpacity):a&&(d.removeChild(a),t._fill=null)},_updateCircle:function(t){var n=t._point.round(),a=Math.round(t._radius),c=Math.round(t._radiusY||a);this._setPath(t,t._empty()?"M0 0":"AL "+n.x+","+n.y+" "+a+","+c+" 0,"+65535*360)},_setPath:function(t,n){t._path.v=n},_bringToFront:function(t){Si(t._container)},_bringToBack:function(t){Ei(t._container)}},Zn=et.vml?sn:Y,on=Be.extend({_initContainer:function(){this._container=Zn("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=Zn("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){Dt(this._container),Mt(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){Be.prototype._update.call(this);var t=this._bounds,n=t.getSize(),a=this._container;(!this._svgSize||!this._svgSize.equals(n))&&(this._svgSize=n,a.setAttribute("width",n.x),a.setAttribute("height",n.y)),Zt(a,t.min),a.setAttribute("viewBox",[t.min.x,t.min.y,n.x,n.y].join(" ")),this.fire("update")}},_initPath:function(t){var n=t._path=Zn("path");t.options.className&&pt(n,t.options.className),t.options.interactive&&pt(n,"leaflet-interactive"),this._updateStyle(t),this._layers[h(t)]=t},_addPath:function(t){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(t._path),t.addInteractiveTarget(t._path)},_removePath:function(t){Dt(t._path),t.removeInteractiveTarget(t._path),delete this._layers[h(t)]},_updatePath:function(t){t._project(),t._update()},_updateStyle:function(t){var n=t._path,a=t.options;n&&(a.stroke?(n.setAttribute("stroke",a.color),n.setAttribute("stroke-opacity",a.opacity),n.setAttribute("stroke-width",a.weight),n.setAttribute("stroke-linecap",a.lineCap),n.setAttribute("stroke-linejoin",a.lineJoin),a.dashArray?n.setAttribute("stroke-dasharray",a.dashArray):n.removeAttribute("stroke-dasharray"),a.dashOffset?n.setAttribute("stroke-dashoffset",a.dashOffset):n.removeAttribute("stroke-dashoffset")):n.setAttribute("stroke","none"),a.fill?(n.setAttribute("fill",a.fillColor||a.color),n.setAttribute("fill-opacity",a.fillOpacity),n.setAttribute("fill-rule",a.fillRule||"evenodd")):n.setAttribute("fill","none"))},_updatePoly:function(t,n){this._setPath(t,P(t._parts,n))},_updateCircle:function(t){var n=t._point,a=Math.max(Math.round(t._radius),1),c=Math.max(Math.round(t._radiusY),1)||a,d="a"+a+","+c+" 0 1,0 ",m=t._empty()?"M0 0":"M"+(n.x-a)+","+n.y+d+a*2+",0 "+d+-a*2+",0 ";this._setPath(t,m)},_setPath:function(t,n){t._path.setAttribute("d",n)},_bringToFront:function(t){Si(t._path)},_bringToBack:function(t){Ei(t._path)}});et.vml&&on.include(Kc);function Or(t){return et.svg||et.vml?new on(t):null}bt.include({getRenderer:function(t){var n=t.options.renderer||this._getPaneRenderer(t.options.pane)||this.options.renderer||this._renderer;return n||(n=this._renderer=this._createRenderer()),this.hasLayer(n)||this.addLayer(n),n},_getPaneRenderer:function(t){if(t==="overlayPane"||t===void 0)return!1;var n=this._paneRenderers[t];return n===void 0&&(n=this._createRenderer({pane:t}),this._paneRenderers[t]=n),n},_createRenderer:function(t){return this.options.preferCanvas&&zr(t)||Or(t)}});var $r=Pi.extend({initialize:function(t,n){Pi.prototype.initialize.call(this,this._boundsToLatLngs(t),n)},setBounds:function(t){return this.setLatLngs(this._boundsToLatLngs(t))},_boundsToLatLngs:function(t){return t=Pt(t),[t.getSouthWest(),t.getNorthWest(),t.getNorthEast(),t.getSouthEast()]}});function Jc(t,n){return new $r(t,n)}on.create=Zn,on.pointsToPath=P,Ie.geometryToLayer=Dn,Ie.coordsToLatLng=oo,Ie.coordsToLatLngs=Rn,Ie.latLngToCoords=ro,Ie.latLngsToCoords=zn,Ie.getFeature=Ai,Ie.asFeature=On,bt.mergeOptions({boxZoom:!0});var Hr=ke.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane,this._resetStateTimeout=0,t.on("unload",this._destroy,this)},addHooks:function(){ut(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){Mt(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){Dt(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){this._resetStateTimeout!==0&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(t){if(!t.shiftKey||t.which!==1&&t.button!==1)return!1;this._clearDeferredResetState(),this._resetState(),Xi(),Zs(),this._startPoint=this._map.mouseEventToContainerPoint(t),ut(document,{contextmenu:ei,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(t){this._moved||(this._moved=!0,this._box=xt("div","leaflet-zoom-box",this._container),pt(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(t);var n=new Lt(this._point,this._startPoint),a=n.getSize();Zt(this._box,n.min),this._box.style.width=a.x+"px",this._box.style.height=a.y+"px"},_finish:function(){this._moved&&(Dt(this._box),Ht(this._container,"leaflet-crosshair")),ji(),qs(),Mt(document,{contextmenu:ei,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(t){if(!(t.which!==1&&t.button!==1)&&(this._finish(),!!this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(r(this._resetState,this),0);var n=new Wt(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(n).fire("boxzoomend",{boxZoomBounds:n})}},_onKeyDown:function(t){t.keyCode===27&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});bt.addInitHook("addHandler","boxZoom",Hr),bt.mergeOptions({doubleClickZoom:!0});var Fr=ke.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(t){var n=this._map,a=n.getZoom(),c=n.options.zoomDelta,d=t.originalEvent.shiftKey?a-c:a+c;n.options.doubleClickZoom==="center"?n.setZoom(d):n.setZoomAround(t.containerPoint,d)}});bt.addInitHook("addHandler","doubleClickZoom",Fr),bt.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var Zr=ke.extend({addHooks:function(){if(!this._draggable){var t=this._map;this._draggable=new qe(t._mapPane,t._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),t.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),t.on("zoomend",this._onZoomEnd,this),t.whenReady(this._onZoomEnd,this))}pt(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){Ht(this._map._container,"leaflet-grab"),Ht(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var t=this._map;if(t._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var n=Pt(this._map.options.maxBounds);this._offsetLimit=zt(this._map.latLngToContainerPoint(n.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(n.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;t.fire("movestart").fire("dragstart"),t.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(t){if(this._map.options.inertia){var n=this._lastTime=+new Date,a=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(a),this._times.push(n),this._prunePositions(n)}this._map.fire("move",t).fire("drag",t)},_prunePositions:function(t){for(;this._positions.length>1&&t-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var t=this._map.getSize().divideBy(2),n=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=n.subtract(t).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(t,n){return t-(t-n)*this._viscosity},_onPreDragLimit:function(){if(!(!this._viscosity||!this._offsetLimit)){var t=this._draggable._newPos.subtract(this._draggable._startPos),n=this._offsetLimit;t.xn.max.x&&(t.x=this._viscousLimit(t.x,n.max.x)),t.y>n.max.y&&(t.y=this._viscousLimit(t.y,n.max.y)),this._draggable._newPos=this._draggable._startPos.add(t)}},_onPreDragWrap:function(){var t=this._worldWidth,n=Math.round(t/2),a=this._initialWorldOffset,c=this._draggable._newPos.x,d=(c-n+a)%t+n-a,m=(c+n+a)%t-n-a,x=Math.abs(d+a)0?m:-m))-n;this._delta=0,this._startTime=null,x&&(t.options.scrollWheelZoom==="center"?t.setZoom(n+x):t.setZoomAround(this._lastMousePos,n+x))}});bt.addInitHook("addHandler","scrollWheelZoom",Wr);var Qc=600;bt.mergeOptions({tapHold:et.touchNative&&et.safari&&et.mobile,tapTolerance:15});var Ur=ke.extend({addHooks:function(){ut(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){Mt(this._map._container,"touchstart",this._onDown,this)},_onDown:function(t){if(clearTimeout(this._holdTimeout),t.touches.length===1){var n=t.touches[0];this._startPos=this._newPos=new rt(n.clientX,n.clientY),this._holdTimeout=setTimeout(r(function(){this._cancel(),this._isTapValid()&&(ut(document,"touchend",Kt),ut(document,"touchend touchcancel",this._cancelClickPrevent),this._simulateEvent("contextmenu",n))},this),Qc),ut(document,"touchend touchcancel contextmenu",this._cancel,this),ut(document,"touchmove",this._onMove,this)}},_cancelClickPrevent:function t(){Mt(document,"touchend",Kt),Mt(document,"touchend touchcancel",t)},_cancel:function(){clearTimeout(this._holdTimeout),Mt(document,"touchend touchcancel contextmenu",this._cancel,this),Mt(document,"touchmove",this._onMove,this)},_onMove:function(t){var n=t.touches[0];this._newPos=new rt(n.clientX,n.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_simulateEvent:function(t,n){var a=new MouseEvent(t,{bubbles:!0,cancelable:!0,view:window,screenX:n.screenX,screenY:n.screenY,clientX:n.clientX,clientY:n.clientY});a._simulated=!0,n.target.dispatchEvent(a)}});bt.addInitHook("addHandler","tapHold",Ur),bt.mergeOptions({touchZoom:et.touch,bounceAtZoomLimits:!0});var Gr=ke.extend({addHooks:function(){pt(this._map._container,"leaflet-touch-zoom"),ut(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){Ht(this._map._container,"leaflet-touch-zoom"),Mt(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(t){var n=this._map;if(!(!t.touches||t.touches.length!==2||n._animatingZoom||this._zooming)){var a=n.mouseEventToContainerPoint(t.touches[0]),c=n.mouseEventToContainerPoint(t.touches[1]);this._centerPoint=n.getSize()._divideBy(2),this._startLatLng=n.containerPointToLatLng(this._centerPoint),n.options.touchZoom!=="center"&&(this._pinchStartLatLng=n.containerPointToLatLng(a.add(c)._divideBy(2))),this._startDist=a.distanceTo(c),this._startZoom=n.getZoom(),this._moved=!1,this._zooming=!0,n._stop(),ut(document,"touchmove",this._onTouchMove,this),ut(document,"touchend touchcancel",this._onTouchEnd,this),Kt(t)}},_onTouchMove:function(t){if(!(!t.touches||t.touches.length!==2||!this._zooming)){var n=this._map,a=n.mouseEventToContainerPoint(t.touches[0]),c=n.mouseEventToContainerPoint(t.touches[1]),d=a.distanceTo(c)/this._startDist;if(this._zoom=n.getScaleZoom(d,this._startZoom),!n.options.bounceAtZoomLimits&&(this._zoomn.getMaxZoom()&&d>1)&&(this._zoom=n._limitZoom(this._zoom)),n.options.touchZoom==="center"){if(this._center=this._startLatLng,d===1)return}else{var m=a._add(c)._divideBy(2)._subtract(this._centerPoint);if(d===1&&m.x===0&&m.y===0)return;this._center=n.unproject(n.project(this._pinchStartLatLng,this._zoom).subtract(m),this._zoom)}this._moved||(n._moveStart(!0,!1),this._moved=!0),tt(this._animRequest);var x=r(n._move,n,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=nt(x,this,!0),Kt(t)}},_onTouchEnd:function(){if(!this._moved||!this._zooming){this._zooming=!1;return}this._zooming=!1,tt(this._animRequest),Mt(document,"touchmove",this._onTouchMove,this),Mt(document,"touchend touchcancel",this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom))}});bt.addInitHook("addHandler","touchZoom",Gr),bt.BoxZoom=Hr,bt.DoubleClickZoom=Fr,bt.Drag=Zr,bt.Keyboard=qr,bt.ScrollWheelZoom=Wr,bt.TapHold=Ur,bt.TouchZoom=Gr,s.Bounds=Lt,s.Browser=et,s.CRS=ae,s.Canvas=Rr,s.Circle=so,s.CircleMarker=Nn,s.Class=Et,s.Control=_e,s.DivIcon=Br,s.DivOverlay=Se,s.DomEvent=gc,s.DomUtil=mc,s.Draggable=qe,s.Evented=Yt,s.FeatureGroup=Pe,s.GeoJSON=Ie,s.GridLayer=nn,s.Handler=ke,s.Icon=Ti,s.ImageOverlay=$n,s.LatLng=yt,s.LatLngBounds=Wt,s.Layer=ge,s.LayerGroup=Mi,s.LineUtil=Pc,s.Map=bt,s.Marker=Bn,s.Mixin=Lc,s.Path=We,s.Point=rt,s.PolyUtil=kc,s.Polygon=Pi,s.Polyline=Ae,s.Popup=Hn,s.PosAnimation=mr,s.Projection=Ac,s.Rectangle=$r,s.Renderer=Be,s.SVG=on,s.SVGOverlay=Ir,s.TileLayer=Ii,s.Tooltip=Fn,s.Transformation=de,s.Util=Ct,s.VideoOverlay=Ar,s.bind=r,s.bounds=zt,s.canvas=zr,s.circle=$c,s.circleMarker=Oc,s.control=Qi,s.divIcon=Yc,s.extend=i,s.featureGroup=Dc,s.geoJSON=Pr,s.geoJson=Zc,s.gridLayer=Xc,s.icon=Rc,s.imageOverlay=qc,s.latLng=ft,s.latLngBounds=Pt,s.layerGroup=Nc,s.map=yc,s.marker=zc,s.point=at,s.polygon=Fc,s.polyline=Hc,s.popup=Gc,s.rectangle=Jc,s.setOptions=w,s.stamp=h,s.svg=Or,s.svgOverlay=Uc,s.tileLayer=Nr,s.tooltip=Vc,s.transformation=k,s.version=e,s.videoOverlay=Wc;var th=window.L;s.noConflict=function(){return window.L=th,this},window.L=s})});var ju=_h(Jr());var Un=globalThis,Vn=Un.ShadowRoot&&(Un.ShadyCSS===void 0||Un.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ta=Symbol(),Qr=new WeakMap,Gn=class{constructor(e,i,o){if(this._$cssResult$=!0,o!==ta)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=i}get styleSheet(){let e=this.o,i=this.t;if(Vn&&e===void 0){let o=i!==void 0&&i.length===1;o&&(e=Qr.get(i)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),o&&Qr.set(i,e))}return e}toString(){return this.cssText}},ea=s=>new Gn(typeof s=="string"?s:s+"",void 0,ta);var ia=(s,e)=>{if(Vn)s.adoptedStyleSheets=e.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet);else for(let i of e){let o=document.createElement("style"),r=Un.litNonce;r!==void 0&&o.setAttribute("nonce",r),o.textContent=i.cssText,s.appendChild(o)}},co=Vn?s=>s:s=>s instanceof CSSStyleSheet?(e=>{let i="";for(let o of e.cssRules)i+=o.cssText;return ea(i)})(s):s;var{is:gh,defineProperty:yh,getOwnPropertyDescriptor:vh,getOwnPropertyNames:bh,getOwnPropertySymbols:wh,getPrototypeOf:xh}=Object,Yn=globalThis,na=Yn.trustedTypes,Ch=na?na.emptyScript:"",Lh=Yn.reactiveElementPolyfillSupport,rn=(s,e)=>s,ho={toAttribute(s,e){switch(e){case Boolean:s=s?Ch:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,e){let i=s;switch(e){case Boolean:i=s!==null;break;case Number:i=s===null?null:Number(s);break;case Object:case Array:try{i=JSON.parse(s)}catch{i=null}}return i}},oa=(s,e)=>!gh(s,e),sa={attribute:!0,type:String,converter:ho,reflect:!1,useDefault:!1,hasChanged:oa};Symbol.metadata??=Symbol("metadata"),Yn.litPropertyMetadata??=new WeakMap;var Ne=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,i=sa){if(i.state&&(i.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((i=Object.create(i)).wrapped=!0),this.elementProperties.set(e,i),!i.noAccessor){let o=Symbol(),r=this.getPropertyDescriptor(e,o,i);r!==void 0&&yh(this.prototype,e,r)}}static getPropertyDescriptor(e,i,o){let{get:r,set:l}=vh(this.prototype,e)??{get(){return this[i]},set(h){this[i]=h}};return{get:r,set(h){let u=r?.call(this);l?.call(this,h),this.requestUpdate(e,u,o)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??sa}static _$Ei(){if(this.hasOwnProperty(rn("elementProperties")))return;let e=xh(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(rn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(rn("properties"))){let i=this.properties,o=[...bh(i),...wh(i)];for(let r of o)this.createProperty(r,i[r])}let e=this[Symbol.metadata];if(e!==null){let i=litPropertyMetadata.get(e);if(i!==void 0)for(let[o,r]of i)this.elementProperties.set(o,r)}this._$Eh=new Map;for(let[i,o]of this.elementProperties){let r=this._$Eu(i,o);r!==void 0&&this._$Eh.set(r,i)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let i=[];if(Array.isArray(e)){let o=new Set(e.flat(1/0).reverse());for(let r of o)i.unshift(co(r))}else e!==void 0&&i.push(co(e));return i}static _$Eu(e,i){let o=i.attribute;return o===!1?void 0:typeof o=="string"?o:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,i=this.constructor.elementProperties;for(let o of i.keys())this.hasOwnProperty(o)&&(e.set(o,this[o]),delete this[o]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return ia(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,i,o){this._$AK(e,o)}_$ET(e,i){let o=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,o);if(r!==void 0&&o.reflect===!0){let l=(o.converter?.toAttribute!==void 0?o.converter:ho).toAttribute(i,o.type);this._$Em=e,l==null?this.removeAttribute(r):this.setAttribute(r,l),this._$Em=null}}_$AK(e,i){let o=this.constructor,r=o._$Eh.get(e);if(r!==void 0&&this._$Em!==r){let l=o.getPropertyOptions(r),h=typeof l.converter=="function"?{fromAttribute:l.converter}:l.converter?.fromAttribute!==void 0?l.converter:ho;this._$Em=r;let u=h.fromAttribute(i,l.type);this[r]=u??this._$Ej?.get(r)??u,this._$Em=null}}requestUpdate(e,i,o,r=!1,l){if(e!==void 0){let h=this.constructor;if(r===!1&&(l=this[e]),o??=h.getPropertyOptions(e),!((o.hasChanged??oa)(l,i)||o.useDefault&&o.reflect&&l===this._$Ej?.get(e)&&!this.hasAttribute(h._$Eu(e,o))))return;this.C(e,i,o)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,i,{useDefault:o,reflect:r,wrapped:l},h){o&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,h??i??this[e]),l!==!0||h!==void 0)||(this._$AL.has(e)||(this.hasUpdated||o||(i=void 0),this._$AL.set(e,i)),r===!0&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(i){Promise.reject(i)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[r,l]of this._$Ep)this[r]=l;this._$Ep=void 0}let o=this.constructor.elementProperties;if(o.size>0)for(let[r,l]of o){let{wrapped:h}=l,u=this[r];h!==!0||this._$AL.has(r)||u===void 0||this.C(r,void 0,l,u)}}let e=!1,i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),this._$EO?.forEach(o=>o.hostUpdate?.()),this.update(i)):this._$EM()}catch(o){throw e=!1,this._$EM(),o}e&&this._$AE(i)}willUpdate(e){}_$AE(e){this._$EO?.forEach(i=>i.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(i=>this._$ET(i,this[i])),this._$EM()}updated(e){}firstUpdated(e){}};Ne.elementStyles=[],Ne.shadowRootOptions={mode:"open"},Ne[rn("elementProperties")]=new Map,Ne[rn("finalized")]=new Map,Lh?.({ReactiveElement:Ne}),(Yn.reactiveElementVersions??=[]).push("2.1.2");var po=globalThis,ra=s=>s,Xn=po.trustedTypes,aa=Xn?Xn.createPolicy("lit-html",{createHTML:s=>s}):void 0,fo="$lit$",De=`lit$${Math.random().toFixed(9).slice(2)}$`,mo="?"+De,kh=`<${mo}>`,oi=document,ln=()=>oi.createComment(""),cn=s=>s===null||typeof s!="object"&&typeof s!="function",_o=Array.isArray,pa=s=>_o(s)||typeof s?.[Symbol.iterator]=="function",uo=`[ -\f\r]`,an=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,la=/-->/g,ca=/>/g,ni=RegExp(`>|${uo}(?:([^\\s"'>=/]+)(${uo}*=${uo}*(?:[^ -\f\r"'\`<>=]|("|')|))|$)`,"g"),ha=/'/g,da=/"/g,fa=/^(?:script|style|textarea|title)$/i,go=s=>(e,...i)=>({_$litType$:s,strings:e,values:i}),ci=go(1),ip=go(2),np=go(3),ri=Symbol.for("lit-noChange"),Rt=Symbol.for("lit-nothing"),ua=new WeakMap,si=oi.createTreeWalker(oi,129);function ma(s,e){if(!_o(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return aa!==void 0?aa.createHTML(e):e}var _a=(s,e)=>{let i=s.length-1,o=[],r,l=e===2?"":e===3?"":"",h=an;for(let u=0;u"?(h=r??an,g=-1):y[1]===void 0?g=-2:(g=h.lastIndex-y[2].length,_=y[1],h=y[3]===void 0?ni:y[3]==='"'?da:ha):h===da||h===ha?h=ni:h===la||h===ca?h=an:(h=ni,r=void 0);let w=h===ni&&s[u+1].startsWith("/>")?" ":"";l+=h===an?f+kh:g>=0?(o.push(_),f.slice(0,g)+fo+f.slice(g)+De+w):f+De+(g===-2?u:w)}return[ma(s,l+(s[i]||"")+(e===2?"":e===3?"":"")),o]},hn=class s{constructor({strings:e,_$litType$:i},o){let r;this.parts=[];let l=0,h=0,u=e.length-1,f=this.parts,[_,y]=_a(e,i);if(this.el=s.createElement(_,o),si.currentNode=this.el.content,i===2||i===3){let g=this.el.content.firstChild;g.replaceWith(...g.childNodes)}for(;(r=si.nextNode())!==null&&f.length0){r.textContent=Xn?Xn.emptyScript:"";for(let w=0;w2||o[0]!==""||o[1]!==""?(this._$AH=Array(o.length-1).fill(new String),this.strings=o):this._$AH=Rt}_$AI(e,i=this,o,r){let l=this.strings,h=!1;if(l===void 0)e=ai(this,e,i,0),h=!cn(e)||e!==this._$AH&&e!==ri,h&&(this._$AH=e);else{let u=e,f,_;for(e=l[0],f=0;f{let o=i?.renderBefore??e,r=o._$litPart$;if(r===void 0){let l=i?.renderBefore??null;o._$litPart$=r=new Ni(e.insertBefore(ln(),l),l,void 0,i??{})}return r._$AI(s),r};var yo=globalThis,Ee=class extends Ne{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=ya(i,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return ri}};Ee._$litElement$=!0,Ee.finalized=!0,yo.litElementHydrateSupport?.({LitElement:Ee});var Eh=yo.litElementPolyfillSupport;Eh?.({LitElement:Ee});(yo.litElementVersions??=[]).push("4.2.2");var{I:gp}=ga;var va=s=>s.strings===void 0;var ba={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},vo=s=>(...e)=>({_$litDirective$:s,values:e}),es=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,i,o){this._$Ct=e,this._$AM=i,this._$Ci=o}_$AS(e,i){return this.update(e,i)}update(e,i){return this.render(...i)}};var dn=(s,e)=>{let i=s._$AN;if(i===void 0)return!1;for(let o of i)o._$AO?.(e,!1),dn(o,e);return!0},is=s=>{let e,i;do{if((e=s._$AM)===void 0)break;i=e._$AN,i.delete(s),s=e}while(i?.size===0)},wa=s=>{for(let e;e=s._$AM;s=e){let i=e._$AN;if(i===void 0)e._$AN=i=new Set;else if(i.has(s))break;i.add(s),Ph(e)}};function Mh(s){this._$AN!==void 0?(is(this),this._$AM=s,wa(this)):this._$AM=s}function Th(s,e=!1,i=0){let o=this._$AH,r=this._$AN;if(r!==void 0&&r.size!==0)if(e)if(Array.isArray(o))for(let l=i;l{s.type==ba.CHILD&&(s._$AP??=Th,s._$AQ??=Mh)},ns=class extends es{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,i,o){super._$AT(e,i,o),wa(this),this.isConnected=e._$AU}_$AO(e,i=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),i&&(dn(this,e),is(this))}setValue(e){if(va(this._$Ct))this._$Ct._$AI(e,this);else{let i=[...this._$Ct._$AH];i[this._$Ci]=e,this._$Ct._$AI(i,this,0)}}disconnected(){}reconnected(){}};var Re=()=>new wo,wo=class{},bo=new WeakMap,ze=vo(class extends ns{render(s){return Rt}update(s,[e]){let i=e!==this.G;return i&&this.rt(void 0),(i||this.lt!==this.ct)&&(this.G=e,this.ht=s.options?.host,this.rt(this.ct=s.element)),Rt}rt(s){if(this.G!==void 0)if(this.isConnected||(s=void 0),typeof this.G=="function"){let e=this.ht??globalThis,i=bo.get(e);i===void 0&&(i=new WeakMap,bo.set(e,i)),i.get(this.G)!==void 0&&this.G.call(this.ht,void 0),i.set(this.G,s),s!==void 0&&this.G.call(this.ht,s)}else this.G.value=s}get lt(){return typeof this.G=="function"?bo.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});function un(s,e,i){return s?e(s):i?.(s)}var xo=s=>s??Rt;var Co=class extends Ee{static properties={name:{type:String,reflect:!0},maximizable:{type:Boolean,reflect:!0},collapsible:{type:Boolean,reflect:!0},maximized:{type:Boolean,reflect:!0},collapsed:{type:Boolean,reflect:!0}};constructor(){super(),this.tabsRef=Re(),this.contentRef=Re(),this.headerRef=Re(),this.controlsRef=Re(),this.maximizeBtnRef=Re(),this.collapseBtnRef=Re(),this._onMaximizeClick=this._onMaximizeClick.bind(this),this._onCollapseClick=this._onCollapseClick.bind(this),this._onResetLayoutClick=this._onResetLayoutClick.bind(this)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.classList.add("ide-pane",`ide-pane-${this.paneName}`),this.performUpdate()}get paneName(){return this.name||this.getAttribute("name")||this.id.replace(/^pane-/,"")||"pane"}get tabsEl(){return this.hasUpdated||this.performUpdate(),this.tabsRef.value}get contentEl(){return this.hasUpdated||this.performUpdate(),this.contentRef.value}get headerEl(){return this.hasUpdated||this.performUpdate(),this.headerRef.value}get controlsEl(){return this.hasUpdated||this.performUpdate(),this.controlsRef.value}get maximizeBtn(){return this.hasUpdated||this.performUpdate(),this.maximizeBtnRef.value}get collapseBtn(){return this.hasUpdated||this.performUpdate(),this.collapseBtnRef.value}get _collapseIcon(){let e=this.paneName;return e==="bottom"?this.collapsed?"\u25B2":"\u25BC":e==="left"?this.collapsed?"\u25B6":"\u25C0":e==="right"?this.collapsed?"\u25C0":"\u25B6":"\u25BC"}get _collapseTitle(){let e=this.paneName,i=e.charAt(0).toUpperCase()+e.slice(1);return e==="bottom"?this.collapsed?"Expand Console":"Collapse Console":e==="left"?this.collapsed?"Expand Left Panel":"Collapse Left Panel":e==="right"?this.collapsed?"Expand Right Panel":"Collapse Right Panel":`Collapse ${i}`}_emit(e,i={}){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:i}))}_onMaximizeClick(e){e.stopPropagation(),this._emit("ide-pane-maximize",{pane:this.paneName})}_onCollapseClick(e){e.stopPropagation(),this._emit("ide-pane-collapse",{pane:this.paneName})}_onResetLayoutClick(e){e.stopPropagation(),this._emit("ide-layout-reset")}setMaximized(e){this.maximized=!!e,this.classList.toggle("maximized",this.maximized),this.maximizeBtn&&(this.maximizeBtn.textContent=this.maximized?"\u29C9":"\u2922",this.maximizeBtn.title=this.maximized?"Restore":"Maximize")}setCollapsed(e){this.collapsed=!!e,this.classList.toggle("collapsed",this.collapsed),this.collapseBtn&&(this.collapseBtn.textContent=this._collapseIcon,this.collapseBtn.title=this._collapseTitle)}build(){this.hasUpdated||this.performUpdate()}updated(e){super.updated(e),e.has("maximized")&&this.classList.toggle("maximized",!!this.maximized),e.has("collapsed")&&this.classList.toggle("collapsed",!!this.collapsed)}render(){let e=this.paneName,i=this.id||`pane-${e}`,o=this.maximizable||this.hasAttribute("maximizable"),r=this.collapsible||this.hasAttribute("collapsible");return ci` -
-
-
- ${un(o,()=>ci` +(()=>{var HM=Object.create;var up=Object.defineProperty;var YM=Object.getOwnPropertyDescriptor;var qM=Object.getOwnPropertyNames;var ZM=Object.getPrototypeOf,XM=Object.prototype.hasOwnProperty;var C=(n,e)=>()=>(n&&(e=n(n=0)),e);var KM=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),ui=(n,e)=>{for(var t in e)up(n,t,{get:e[t],enumerable:!0})},QM=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of qM(e))!XM.call(n,r)&&r!==t&&up(n,r,{get:()=>e[r],enumerable:!(i=YM(e,r))||i.enumerable});return n};var JM=(n,e,t)=>(t=n!=null?HM(ZM(n)):{},QM(e||!n||!n.__esModule?up(t,"default",{value:n,enumerable:!0}):t,n));var ia,sA,Xl,oA,yv,fp=C(()=>{ia=globalThis,sA=globalThis.document||{},Xl=globalThis.process||{},oA=globalThis.console,yv=globalThis.navigator||{}});function Kl(n){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&process.versions?.electron)return!0;let e=typeof navigator<"u"&&navigator.userAgent,t=n||e;return!!(t&&t.indexOf("Electron")>=0)}var dp=C(()=>{});function Pt(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Kl()}var hp=C(()=>{dp()});function pp(n){return!n&&!Pt()?"Node":Kl(n)?"Electron":(n||yv.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var bv=C(()=>{hp();dp();fp()});var mp,vr=C(()=>{fp();hp();bv();mp="4.1.2"});function Is(n,e){if(!n)throw new Error(e||"Assertion failed")}var gp=C(()=>{});function _p(n){if(!n)return 0;let e;switch(typeof n){case"number":e=n;break;case"object":e=n.logLevel||n.priority||0;break;default:return 0}return Is(Number.isFinite(e)&&e>=0),e}function vv(n){let{logLevel:e,message:t}=n;n.logLevel=_p(e);let i=n.args?Array.from(n.args):[];for(;i.length&&i.shift()!==t;);switch(typeof e){case"string":case"function":t!==void 0&&i.unshift(t),n.message=e;break;case"object":Object.assign(n,e);break;default:}typeof n.message=="function"&&(n.message=n.message());let r=typeof n.message;return Is(r==="string"||r==="object"),Object.assign(n,{args:i},n.opts)}var xv=C(()=>{gp()});var xr,Ql,wv=C(()=>{xv();xr=()=>{},Ql=class{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...t){return this._log("warn",0,e,t,{once:!0})}error(e,...t){return this._log("error",0,e,t)}log(e,t,...i){return this._log("log",e,t,i)}info(e,t,...i){return this._log("info",e,t,i)}once(e,t,...i){return this._log("once",e,t,i,{once:!0})}_log(e,t,i,r,s={}){let o=vv({logLevel:t,message:i,args:this._buildArgs(t,i,r),opts:s});return this._createLogFunction(e,o,s)}_buildArgs(e,t,i){return[e,t,...i]}_createLogFunction(e,t,i){if(!this._shouldLog(t.logLevel))return xr;let r=this._getOnceTag(i.tag??t.tag??t.message);if((i.once||t.once)&&r!==void 0){if(this._onceCache.has(r))return xr;this._onceCache.add(r)}return this._emit(e,t)}_shouldLog(e){return this.getLevel()>=_p(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}}});function cA(n){try{let e=window[n],t="__storage_test__";return e.setItem(t,t),e.removeItem(t),e}catch{return null}}var Jl,Ev=C(()=>{Jl=class{constructor(e,t,i="sessionStorage"){this.storage=cA(i),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}}_loadConfiguration(){let e={};if(this.storage){let t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}});function Sv(n){let e;return n<10?e=`${n.toFixed(2)}ms`:n<100?e=`${n.toFixed(1)}ms`:n<1e3?e=`${n.toFixed(0)}ms`:e=`${(n/1e3).toFixed(2)}s`,e}function Pv(n,e=8){let t=Math.max(e-n.length,0);return`${" ".repeat(t)}${n}`}var Cv=C(()=>{});function Tv(n){return typeof n!="string"?n:(n=n.toUpperCase(),eu[n]||eu.WHITE)}function Lv(n,e,t){return!Pt&&typeof n=="string"&&(e&&(n=`\x1B[${Tv(e)}m${n}\x1B[39m`),t&&(n=`\x1B[${Tv(t)+lA}m${n}\x1B[49m`)),n}var eu,lA,Mv=C(()=>{vr();(function(n){n[n.BLACK=30]="BLACK",n[n.RED=31]="RED",n[n.GREEN=32]="GREEN",n[n.YELLOW=33]="YELLOW",n[n.BLUE=34]="BLUE",n[n.MAGENTA=35]="MAGENTA",n[n.CYAN=36]="CYAN",n[n.WHITE=37]="WHITE",n[n.BRIGHT_BLACK=90]="BRIGHT_BLACK",n[n.BRIGHT_RED=91]="BRIGHT_RED",n[n.BRIGHT_GREEN=92]="BRIGHT_GREEN",n[n.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",n[n.BRIGHT_BLUE=94]="BRIGHT_BLUE",n[n.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",n[n.BRIGHT_CYAN=96]="BRIGHT_CYAN",n[n.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(eu||(eu={}));lA=10});function Av(n,e=["constructor"]){let t=Object.getPrototypeOf(n),i=Object.getOwnPropertyNames(t),r=n;for(let s of i){let o=r[s];typeof o=="function"&&(e.find(a=>s===a)||(r[s]=o.bind(n)))}}var kv=C(()=>{});var tu,An,yp=C(()=>{vr();tu=class{getHighResolutionTimer(){let e;if(Pt()&&ia.performance)e=ia?.performance?.now?.();else if("hrtime"in Xl){let t=Xl?.hrtime?.();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}getMemoryUsageMB(){let t=ia?.performance?.memory?.usedJSHeapSize;return t==null?null:Math.trunc(t/1024/1024)}},An=new tu;globalThis.Probe=tu;globalThis.probe=An});function uA(n,e,t){if(typeof e=="string"){let i=t.time?Pv(Sv(t.total)):"";e=t.time?`${n}: ${i} ${e}`:`${n}: ${e}`,e=Lv(e,t.color,t.background)}return e}function fA(n){for(let e in n)for(let t in n[e])return t||"untitled";return"empty"}var Bs,bp,ct,vp=C(()=>{vr();wv();Ev();Cv();Mv();kv();gp();yp();Bs={debug:Pt()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},bp={enabled:!0,level:0},ct=class extends Ql{constructor({id:e}={id:""}){super({level:0}),this.VERSION=mp,this._startTs=An.getHighResolutionTimer(),this._deltaTs=An.getHighResolutionTimer(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Jl(`__probe-${this.id}__`,{[this.id]:bp}),this.timeStamp(`${this.id} started`),Av(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((An.getHighResolutionTimer()-this._startTs).toPrecision(10))}getDelta(){return Number((An.getHighResolutionTimer()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,t){this._updateConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw new Error(t||"Assertion failed")}warn(e,...t){return this._log("warn",0,e,t,{method:Bs.warn,once:!0})}error(e,...t){return this._log("error",0,e,t,{method:Bs.error})}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t,...i){let r=An.getMemoryUsageMB();if(r!==null){let s=`${r}MB `;typeof t=="function"?t=()=>`${s}${t()}`:typeof t=="string"&&(t=`${s}${t}`)}return this._log("log",e,t,i,{method:Bs.log,time:!0,once:!0})}log(e,t,...i){return this._log("log",e,t,i,{method:Bs.debug})}info(e,t,...i){return this._log("info",e,t,i,{method:console.info})}once(e,t,...i){return this._log("once",e,t,i,{method:Bs.debug||Bs.info,once:!0})}table(e,t,i){return t?this._log("table",e,t,i&&[i]||[],{method:console.table||xr,tag:fA(t)}):xr}time(e,t){return this._log("time",e,t,[],{method:console.time?console.time:console.info})}timeEnd(e,t){return this._log("time",e,t,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,t){return this._log("time",e,t,[],{method:console.timeStamp||xr})}group(e,t,i={collapsed:!1}){let r=(i.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,t,[],{method:r})}groupCollapsed(e,t,i={}){return this.group(e,t,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||xr})}withGroup(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,t){let i=t.method;Is(i),t.total=this.getTotal(),t.delta=this.getDelta(),this._deltaTs=An.getHighResolutionTimer();let r=uA(this.id,t.message,t);return i.bind(console,r,...t.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(bp),this._storage.config[this.id]}_updateConfiguration(e){let t=this._storage.config[this.id]||{...bp};this._storage.setConfiguration({[this.id]:{...t,...e}})}};ct.VERSION=mp});var Rv=C(()=>{yp();globalThis.probe||(globalThis.probe=An)});var Rj,ra=C(()=>{vp();vp();Rv();Rj=new ct({id:"@probe.gl/log"})});function ca(){let n;if(typeof window<"u"&&window.performance)n=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();n=e[0]*1e3+e[1]/1e6}else n=Date.now();return n}var Np=C(()=>{});var Er,Fp=C(()=>{Np();Er=class{constructor(e,t){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=ca(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(ca()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}});var Vt,jv=C(()=>{Fp();Vt=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let t of Object.values(this.stats))e(t)}getTable(){let e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(t=>this._getOrCreate(t))}_getOrCreate(e){let{name:t,type:i}=e,r=this.stats[t];return r||(e instanceof Er?r=e:r=new Er(t,i),this.stats[t]=r),r}}});var la=C(()=>{jv();Fp();Np()});function xx(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function wx(n){return Array.isArray(n)?n.length===0||typeof n[0]=="number":!1}function ga(n){return xx(n)||wx(n)}var Ex=C(()=>{});var Qp=C(()=>{Ex()});function $s(n){let e=n.split(""),t=0,i=0,r=!1,s=!1,o=!1;for(;t0){if(a==="/"&&c==="*"){e[t]=" ",e[t+1]=" ",i++,t+=2;continue}if(a==="*"&&c==="/"){e[t]=" ",e[t+1]=" ",i--,t+=2;continue}a!==` +`&&a!=="\r"&&(e[t]=" "),t++;continue}if(a==='"'){s=!0,t++;continue}if(a==="/"&&c==="/"){e[t]=" ",e[t+1]=" ",r=!0,t+=2;continue}if(a==="/"&&c==="*"){e[t]=" ",e[t+1]=" ",i=1,t+=2;continue}t++}return e.join("")}function Pr(n,e){let t=$s(n),i=[];for(let r of e){r.lastIndex=0;let s;for(s=r.exec(t);s;){let o=r===e[0],a=s.index,c=s[0].length;i.push({match:n.slice(a,a+c),index:a,length:c,bindingToken:s[o?1:2],groupToken:s[o?2:1],accessDeclaration:s[3]?.trim(),name:s[4]}),s=r.exec(t)}}return i.sort((r,s)=>r.index-s.index)}function sm(n,e,t){let i=Pr(n,e);if(!i.length)return n;let r="",s=0;for(let o of i)r+=n.slice(s,o.index),r+=t(o),s=o.index+o.length;return r+=n.slice(s),r}function om(n){return/@binding\(\s*auto\s*\)/.test($s(n))}function Fx(n,e){return Pr(n,e===Us||e===mu?Lk:e).find(i=>i.bindingToken==="auto")}var Lt,Wt,Us,mu,Nx,Lk,gu=C(()=>{Lt="(?:var<\\s*(uniform|storage(?:\\s*,\\s*[A-Za-z_][A-Za-z0-9_]*)?)\\s*>|var)\\s+([A-Za-z_][A-Za-z0-9_]*)",Wt="\\s*",Us=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${Wt}@group\\(\\s*(\\d+)\\s*\\)${Wt}${Lt}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${Wt}@binding\\(\\s*(auto|\\d+)\\s*\\)${Wt}${Lt}`,"g")],mu=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${Wt}@group\\(\\s*(\\d+)\\s*\\)${Wt}${Lt}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${Wt}@binding\\(\\s*(auto|\\d+)\\s*\\)${Wt}${Lt}`,"g")],Nx=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)${Wt}@group\\(\\s*(\\d+)\\s*\\)${Wt}${Lt}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${Wt}@binding\\(\\s*(\\d+)\\s*\\)${Wt}${Lt}`,"g")],Lk=[new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${Lt}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)\\s*${Lt}`,"g"),new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${Lt}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${Lt}`,"g")]});function yu(n,e={}){let t=zx(n),i=Mk(t);if(!i)return null;let r=Ak(t,i);if(!r)return null;let s=Rk(t,i,r);if(!s)return null;if(e.scanVertexAttributes===!1)return{attributes:[],bindings:s};let o=kk(t,i);if(!o)return null;let a=Nk(t,i,r,o,e.vertexEntryPoint);return a?{attributes:a,bindings:s}:null}function zx(n){let e=$s(n),t=/[A-Za-z_][A-Za-z0-9_]*|(?:0[xX][0-9A-Fa-f]+|\d+)|[@(){}<>\[\]:,;=]/g,i=[],r=t.exec(e);for(;r;)i.push({value:r[0],index:r.index}),r=t.exec(e);return i}function Mk(n){let e=[],t=0;for(let i of n){if(i.value==="}"&&t===0)return null;e.push(t),i.value==="{"?t++:i.value==="}"&&t--}return t===0?e:null}function Ak(n,e){let t=new Map;for(let i=0;i");if(y<0)return null;let b=bu(n.slice(f+1,y),",");if(!b)return null;d=b.map(_u),f=y+1}let h=n[f]?.value;if(!ba(h)||n[f+1]?.value!==":")return null;let p=Gx(n,e,f+2,";");if(p<0||p===f+2)return null;let m=lm(_u(n.slice(f+2,p)),t);if(!m)return null;let g=Ik({name:h,group:l,location:u,addressSpace:d,resourceType:m}),v=`${l}:${u}`;if(!g||r.has(v)||s.has(h))return null;i.push(g),r.add(v),s.add(h),o=p}return Dk(i),i.sort((o,a)=>o.group-a.group||o.location-a.location||o.name.localeCompare(a.name))}function Ik(n){let{name:e,group:t,location:i,addressSpace:r,resourceType:s}=n,o={name:e,group:t,location:i};if(r[0]==="uniform"&&r.length===1)return{...o,type:"uniform"};if(r[0]==="storage"&&r.length<=2){let a=r[1]||"read";return a==="read"?{...o,type:"read-only-storage"}:a==="read_write"?{...o,type:"storage"}:null}return r.length>0?null:s==="sampler"||s==="sampler_comparison"?{...o,type:"sampler",...s==="sampler_comparison"?{samplerType:"comparison"}:{}}:s==="texture_external"?{...o,type:"external-texture"}:Bk(o,s)||Ok(o,s)}function Bk(n,e){let t=/^texture_storage_(1d|2d|2d_array|3d)<([A-Za-z0-9_]+),(read|write|read_write)>$/.exec(e);if(!t)return null;let i={read:"read-only",write:"write-only",read_write:"read-write"}[t[3]];return{...n,type:"storage",format:t[2],access:i,viewDimension:cm(t[1])}}function Ok(n,e){let t=/^texture_(multisampled_)?(1d|2d|2d_array|cube|cube_array|3d)<(f32|i32|u32)>$/.exec(e);if(t){if(t[1]&&t[2]!=="2d")return null;let r={f32:"float",i32:"sint",u32:"uint"}[t[3]];return{...n,type:"texture",viewDimension:cm(t[2]),sampleType:r,multisampled:!!t[1]}}let i=/^texture_depth_(multisampled_)?(2d|2d_array|cube|cube_array)$/.exec(e);return!i||i[1]&&i[2]!=="2d"?null:{...n,type:"texture",viewDimension:cm(i[2]),sampleType:"depth",multisampled:!!i[1]}}function Dk(n){for(let e of n){if(e.type!=="sampler"||e.samplerType||!e.name.endsWith("Sampler"))continue;let t=e.name.slice(0,-7);n.find(r=>r.type==="texture"&&r.name===t&&r.group===e.group)?.sampleType==="depth"&&(e.samplerType="non-filtering")}}function Nk(n,e,t,i,r){let s=Fk(n,e);if(!s)return null;let o=s.filter(h=>h.vertex),a=r?o.find(h=>h.name===r):o.length===1?o[0]:void 0;if(!a)return o.length===0&&!r?[]:null;let c=bu(a.parameters,",");if(!c)return null;let l=[],u=new Set,f=new Set,d=new Set;for(let h of c)if(h.length>0&&!Ux({declaration:h,aliases:t,structures:i,attributes:l,attributeLocations:u,attributeNames:f,visitedStructures:d}))return null;return l.sort((h,p)=>h.location-p.location||h.name.localeCompare(p.name))}function Fk(n,e){let t=[],i=new Set;for(let r=0;r0&&!Ux({...n,declaration:m}))return!1;return a.delete(d),!0}function lm(n,e,t=new Set){let i=zx(n),r="";for(let s of i){let o=e.get(s.value);if(!o){r+=zk(s.value);continue}if(t.has(s.value))return null;let a=new Set(t);a.add(s.value);let c=lm(o,e,a);if(!c)return null;r+=c}return r}function zk(n){let e=/^(vec[234]|mat[234]x[234])([fiuh])$/.exec(n);if(!e)return n;let t={f:"f32",i:"i32",u:"u32",h:"f16"}[e[2]];return`${e[1]}<${t}>`}function Uk(n){return/^(?:i32|u32|f32|f16|vec[234]<(?:i32|u32|f32|f16)>)$/.test(n)?n:null}function am(n,e){let t;for(let i=0;it.value==="@"&&n[i+1]?.value===e)}function cm(n){return n.replace("_","-")}function um(n,e,t,i){let r=0;for(let s=e;s":"<","]":"[","}":"{"};for(let a=0;ar[l]===0)){t.push(n.slice(i,a)),i=a+1;continue}if(c in r)r[c]++;else if(c in o){let l=o[c];if(r[l]--,r[l]<0)return null}}return s.every(a=>r[a]===0)?(t.push(n.slice(i)),t):null}function $k(n,e){let t=bu(n,e);return t&&t.length===2?t[0].length:-1}function Gx(n,e,t,i){for(let r=t;r=0;i--)if(n[i].value===";"&&e[i]===0||n[i].value==="}"&&e[i]===1)return i+1;return 0}function Gk(n){for(let e=n.length-1;e>=0;e--)if(ba(n[e].value))return n[e].value;return null}function _u(n){return n.map(e=>e.value).join("")}function ba(n){return!!(n&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(n))}var fm=C(()=>{gu()});function hi(n,e){if(!n){let t=new Error(e||"shadertools: assertion failed.");throw Error.captureStackTrace?.(t,hi),t}}var vu=C(()=>{});function jx(n){let e={};for(let[t,i]of Object.entries(n))e[t]=Vk(i);return e}function Vk(n){let e=Wx(n);if(e!=="object")return{value:n,...dm[e],type:e};if(typeof n=="object")return n?n.type!==void 0?{...n,...dm[n.type],type:n.type}:n.value===void 0?{type:"object",value:n}:(e=Wx(n.value),{...n,...dm[e],type:e}):{type:"object",value:null};throw new Error("props")}function Wx(n){return Array.isArray(n)||ArrayBuffer.isView(n)?"array":typeof n}var dm,Hx=C(()=>{dm={number:{type:"number",validate(n,e){return Number.isFinite(n)&&typeof e=="object"&&(e.max===void 0||n<=e.max)&&(e.min===void 0||n>=e.min)}},array:{type:"array",validate(n,e){return Array.isArray(n)||ArrayBuffer.isView(n)}}}});var Yx,qx,Zx=C(()=>{Yx=`#ifdef MODULE_LOGDEPTH + logdepth_adjustPosition(gl_Position); +#endif +`,qx=`#ifdef MODULE_MATERIAL + fragColor = material_filterColor(fragColor); +#endif + +#ifdef MODULE_LIGHTING + fragColor = lighting_filterColor(fragColor); +#endif + +#ifdef MODULE_FOG + fragColor = fog_filterColor(fragColor); +#endif + +#ifdef MODULE_PICKING + fragColor = picking_filterHighlightColor(fragColor); + fragColor = picking_filterPickingColor(fragColor); +#endif + +#ifdef MODULE_LOGDEPTH + logdepth_setFragDepth(); +#endif +`});function Qx(n){let e={vertex:{},fragment:{}};for(let t in n){let i=n[t],r=jk(t);typeof i=="string"&&(i={order:0,injection:i}),e[r][t]=i}return e}function jk(n){let e=n.slice(0,2);switch(e){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(e)}}function xa(n,e,t,i=!1,r="glsl",s={}){let o=e==="vertex";for(let a in t){let c=t[a];c.sort((u,f)=>u.order-f.order),hm.length=c.length;for(let u=0,f=c.length;uu+l));break;case"vs:#main-end":(r==="wgsl"||o)&&(n=r==="wgsl"?xu(n,"vertex",l,"end",s.vertex):n.replace(Kx,u=>l+u));break;case"fs:#decl":(r==="wgsl"||!o)&&(n=n.replace(va,l));break;case"fs:#main-start":(r==="wgsl"||!o)&&(n=r==="wgsl"?xu(n,"fragment",l,"start",s.fragment):n.replace(Xx,u=>u+l));break;case"fs:#main-end":(r==="wgsl"||!o)&&(n=r==="wgsl"?xu(n,"fragment",l,"end",s.fragment):n.replace(Kx,u=>l+u));break;default:n=n.replace(a,u=>u+l)}}return n=n.replace(va,""),i&&(n=n.replace(/\}\s*$/,a=>a+Wk[e])),n}function xu(n,e,t,i,r){let s=Hk(n,e,r);if(!s)return n;if(i==="start"){let o=s.openBraceIndex+1;return`${n.slice(0,o)} +${t}${n.slice(o)}`}return`${n.slice(0,s.closeBraceIndex)}${t}${n.slice(s.closeBraceIndex)}`}function Hk(n,e,t){let i=e==="vertex"?"@vertex":"@fragment",r=n.indexOf(i);if(r<0)return null;let s=t?n.search(new RegExp(`\\bfn\\s+${Yk(t)}\\s*\\(`)):n.indexOf("fn",r);if(s<0)return null;let o=n.indexOf("{",s);if(o<0)return null;let a=0;for(let c=o;c{Zx();Wk={vertex:Yx,fragment:qx},Xx=/void\s+main\s*\([^)]*\)\s*\{\n?/,Kx=/}\n?[^{}]*$/,hm=[],va="__LUMA_INJECT_DECLARATIONS__"});function Gs(n){n.map(e=>qk(e))}function qk(n){if(n.instance)return;Gs(n.dependencies||[]);let{propTypes:e={},deprecations:t=[],inject:i={}}=n,r={normalizedInjections:Qx(i),parsedDeprecations:Zk(t)};e&&(r.propValidators=jx(e)),n.instance=r;let s={};e&&(s=Object.entries(e).reduce((o,[a,c])=>{let l=c?.value;return l&&(o[a]=l),o},{})),n.defaultUniforms={...n.defaultUniforms,...s}}function mm(n,e,t){n.deprecations?.forEach(i=>{i.regex?.test(e)&&(i.deprecated?t.deprecated(i.old,i.new)():t.removed(i.old,i.new)())})}function Zk(n){return n.forEach(e=>{switch(e.type){case"function":e.regex=new RegExp(`\\b${e.old}\\(`);break;default:e.regex=new RegExp(`${e.type} ${e.old};`)}}),n}var wu=C(()=>{Hx();pm()});function Cr(n){Gs(n);let e={},t={};Jx({modules:n,level:0,moduleMap:e,moduleDepth:t});let i=Object.keys(t).sort((r,s)=>t[s]-t[r]).map(r=>e[r]);return Gs(i),i}function Jx(n){let{modules:e,level:t,moduleMap:i,moduleDepth:r}=n;if(t>=5)throw new Error("Possible loop in shader dependency graph");for(let s of e)i[s.name]=s,(r[s.name]===void 0||r[s.name]{wu()});var z,ut=C(()=>{ra();z=new ct({id:"luma.gl"})});function Xk(n,e){return n!=null?!!n:e!==void 0?e!=="production":!1}function Kk(){return Xk(z.get("debug"),Qk())}function Qk(){let n=globalThis.process;if(n?.env)return n.env.NODE_ENV}var Eu,_m=C(()=>{ut();Eu={id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,featureLevel:void 0,optionalFeatures:[],xrCompatible:!1,createCanvasContext:void 0,webgl:{},onError:(n,e)=>{},onResize:(n,e)=>{let[t,i]=n.getDevicePixelSize();z.log(1,`${n} resized => ${t}x${i}px`)()},onPositionChange:(n,e)=>{let[t,i]=n.getPosition();z.log(1,`${n} repositioned => ${t},${i}`)()},onVisibilityChange:n=>z.log(1,`${n} Visibility changed ${n.isVisible}`)(),onDevicePixelRatioChange:(n,e)=>z.log(1,`${n} DPR changed ${e.oldRatio} => ${n.devicePixelRatio}`)(),debug:Kk(),debugGPUTime:!1,debugShaders:z.get("debug-shaders")||void 0,debugFramebuffers:!!z.get("debug-framebuffers"),debugFactories:!!z.get("debug-factories"),debugWebGL:!!z.get("debug-webgl"),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0}});function tR(n,e){let t=n.stats,i=!1;for(let c of e)t[c]||(n.get(c),i=!0);let r=Object.keys(t).length,s=e0.get(n);if(!i&&s?.orderedStatNames===e&&s.statCount===r)return;let o={},a=t0.get(e);a||(a=new Set(e),t0.set(e,a));for(let c of e)t[c]&&(o[c]=t[c]);for(let[c,l]of Object.entries(t))a.has(c)||(o[c]=l);for(let c of Object.keys(t))delete t[c];Object.assign(t,o),e0.set(n,{orderedStatNames:e,statCount:r})}var Jk,eR,e0,t0,ym,Su,bm=C(()=>{la();Jk="GPU Time and Memory",eR=["Adapter","GPU","GPU Type","GPU Backend","Frame Rate","CPU Time","GPU Time","GPU Memory","Buffer Memory","Texture Memory","External Buffer Memory","External Texture Memory","Swap Chain Texture"],e0=new WeakMap,t0=new WeakMap,ym=class{stats=new Map;getStats(e){return this.get(e)}get(e){this.stats.has(e)||this.stats.set(e,new Vt({id:e}));let t=this.stats.get(e);return e===Jk&&tR(t,eR),t}},Su=new ym});var nR,n0,vm,Vs,i0=C(()=>{_m();bm();ut();nR="set luma.log.level=1 (or higher) to trace rendering",n0="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",vm=class n{static defaultProps={...Eu,type:"best-available",adapters:void 0,waitForPageLoad:!0};stats=Su;log=z;VERSION="9.4.2";spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw z.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),z.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");z.error("This version of luma.gl has already been initialized")()}z.log(1,`${this.VERSION} - ${nR}`)(),globalThis.luma=this}async createDevice(e={}){let t={...n.defaultProps,...e},i=this.selectAdapter(t.type,t.adapters);if(!i)throw new Error(n0);return t.waitForPageLoad&&await i.pageLoaded,await i.create(t)}async attachDevice(e,t){let i=this._getTypeFromHandle(e,t.adapters),r=i&&this.selectAdapter(i,t.adapters);if(!r)throw new Error(n0);return await r?.attach?.(e,t)}registerAdapters(e){for(let t of e)this.preregisteredAdapters.set(t.type,t)}getSupportedAdapters(e=[]){let t=this._getAdapterMap(e);return Array.from(t).map(([,i])=>i).filter(i=>i.isSupported?.()).map(i=>i.type)}getBestAvailableAdapterType(e=[]){let t=["webgpu","webgl","null"],i=this._getAdapterMap(e);for(let r of t)if(i.get(r)?.isSupported?.())return r;return null}selectAdapter(e,t=[]){let i=e;e==="best-available"&&(i=this.getBestAvailableAdapterType(t));let r=this._getAdapterMap(t);return i&&r.get(i)||null}enforceWebGL2(e=!0,t=[]){let r=this._getAdapterMap(t).get("webgl");r||z.warn("enforceWebGL2: webgl adapter not found")(),r?.enforceWebGL2?.(e)}setDefaultDeviceProps(e){Object.assign(n.defaultProps,e)}_getAdapterMap(e=[]){let t=new Map(this.preregisteredAdapters);for(let i of e)t.set(i.type,i);return t}_getTypeFromHandle(e,t=[]){return e instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&e instanceof GPUDevice||e?.queue?"webgpu":e===null?"null":(e instanceof WebGLRenderingContext?z.warn("WebGL1 is not supported",e)():z.warn("Unknown handle type",e)(),null)}},Vs=new vm});function sR(){return Pu||(rR()||typeof window>"u"?Pu=Promise.resolve():Pu=new Promise(n=>window.addEventListener("load",()=>n()))),Pu}var wa,iR,rR,Pu,r0=C(()=>{vr();wa=class{get pageLoaded(){return sR()}},iR=Pt()&&typeof document<"u",rR=()=>iR&&document.readyState==="complete",Pu=null});function On(n="id"){xm[n]=xm[n]||1;let e=xm[n]++;return`${n}-${e}`}var xm,Ws=C(()=>{xm={}});function fR(n,e){let t={...e};for(let i in n)n[i]!==void 0&&(t[i]=n[i]);return t}function u0(n,e){let t=n.stats,i=!1;for(let c of e)t[c]||(n.get(c),i=!0);let r=Object.keys(t).length,s=c0.get(n);if(!i&&s?.orderedStatNames===e&&s.statCount===r)return;let o={},a=l0.get(e);a||(a=new Set(e),l0.set(e,a));for(let c of e)t[c]&&(o[c]=t[c]);for(let[c,l]of Object.entries(t))a.has(c)||(o[c]=l);for(let c of Object.keys(t))delete t[c];Object.assign(t,o),c0.set(n,{orderedStatNames:e,statCount:r})}function f0(n){return n.type==="webgl"?uR:lR}function Ea(n){let e=n.userData[oR];return e?.enabled?e:null}function zi(){return globalThis.performance?.now?.()??Date.now()}function dR(n,e){let t=Ea(n);if(!(!t||!t.activeDefaultFramebufferAcquireDepth))switch(t.transientCanvasResourceCreates=(t.transientCanvasResourceCreates||0)+1,e){case"Texture":t.transientCanvasTextureCreates=(t.transientCanvasTextureCreates||0)+1;break;case"TextureView":t.transientCanvasTextureViewCreates=(t.transientCanvasTextureViewCreates||0)+1;break;case"Sampler":t.transientCanvasSamplerCreates=(t.transientCanvasSamplerCreates||0)+1;break;case"Framebuffer":t.transientCanvasFramebufferCreates=(t.transientCanvasFramebufferCreates||0)+1;break;default:break}}function hR(n){let e=Object.getPrototypeOf(n);for(;e;){let t=Object.getPrototypeOf(e);if(!t||t===te.prototype)return pR(e)||n[Symbol.toStringTag]||n.constructor.name;e=t}return n[Symbol.toStringTag]||n.constructor.name}function pR(n){let e=Object.getOwnPropertyDescriptor(n,Symbol.toStringTag);return typeof e?.get=="function"?e.get.call(n):typeof e?.value=="string"?e.value:null}var oR,s0,o0,a0,aR,cR,lR,uR,c0,l0,te,He=C(()=>{Ws();oR="cpu-hotspot-profiler",s0="GPU Resource Counts",o0="Resource Counts",a0="GPU Time and Memory",aR=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","RenderBundleEncoders","RenderBundles","ComputePasss","CommandEncoders","CommandBuffers"],cR=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","SharedRenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","RenderBundleEncoders","RenderBundles","ComputePasss","CommandEncoders","CommandBuffers"],lR=aR.flatMap(n=>[`${n} Created`,`${n} Active`]),uR=cR.flatMap(n=>[`${n} Created`,`${n} Active`]),c0=new WeakMap,l0=new WeakMap,te=class{static defaultProps={id:"undefined",handle:void 0,_isHandleBorrowed:!1,userData:void 0};toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}toJSON(){return this.toString()}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;allocatedBytesName=null;_attachedResources=new Set;get ownsHandle(){return(this.props.handle===void 0||this.props.handle===null)&&!this.isHandleBorrowed}get isHandleBorrowed(){return!!this.props._isHandleBorrowed}constructor(e,t,i){if(!e)throw new Error("no device");this._device=e,this.props=fR(t,i);let r=this.props.id!=="undefined"?this.props.id:On(this[Symbol.toStringTag]);this.props.id=r,this.id=r,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyed||this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of this._attachedResources)e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyed||(this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0)}removeStats(){let e=Ea(this._device),t=e?zi():0,i=[this._device.statsManager.getStats(s0),this._device.statsManager.getStats(o0)],r=f0(this._device);for(let o of i)u0(o,r);let s=this.getStatsName();for(let o of i)o.get("Resources Active").decrementCount(),o.get(`${s}s Active`).decrementCount();e&&(e.statsBookkeepingCalls=(e.statsBookkeepingCalls||0)+1,e.statsBookkeepingTimeMs=(e.statsBookkeepingTimeMs||0)+(zi()-t))}trackAllocatedMemory(e,t=this.getStatsName()){let i=Ea(this._device),r=i?zi():0,s=this._device.statsManager.getStats(a0);this.allocatedBytes>0&&this.allocatedBytesName&&(s.get("GPU Memory").subtractCount(this.allocatedBytes),s.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes)),s.get("GPU Memory").addCount(e),s.get(`${t} Memory`).addCount(e),i&&(i.statsBookkeepingCalls=(i.statsBookkeepingCalls||0)+1,i.statsBookkeepingTimeMs=(i.statsBookkeepingTimeMs||0)+(zi()-r)),this.allocatedBytes=e,this.allocatedBytesName=t}trackReferencedMemory(e,t=this.getStatsName()){this.trackAllocatedMemory(e,`External ${t}`)}trackDeallocatedMemory(e=this.getStatsName()){if(this.allocatedBytes===0){this.allocatedBytesName=null;return}let t=Ea(this._device),i=t?zi():0,r=this._device.statsManager.getStats(a0);r.get("GPU Memory").subtractCount(this.allocatedBytes),r.get(`${this.allocatedBytesName||e} Memory`).subtractCount(this.allocatedBytes),t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+(zi()-i)),this.allocatedBytes=0,this.allocatedBytesName=null}trackDeallocatedReferencedMemory(e=this.getStatsName()){this.trackDeallocatedMemory(`Referenced ${e}`)}addStats(){let e=this.getStatsName(),t=Ea(this._device),i=t?zi():0,r=[this._device.statsManager.getStats(s0),this._device.statsManager.getStats(o0)],s=f0(this._device);for(let o of r)u0(o,s);for(let o of r)o.get("Resources Created").incrementCount(),o.get("Resources Active").incrementCount(),o.get(`${e}s Created`).incrementCount(),o.get(`${e}s Active`).incrementCount();t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+(zi()-i)),dR(this._device,e)}getStatsName(){return hR(this)}}});var re,Cu=C(()=>{He();re=class n extends te{static INDEX=16;static VERTEX=32;static UNIFORM=64;static STORAGE=128;static INDIRECT=256;static QUERY_RESOLVE=512;static MAP_READ=1;static MAP_WRITE=2;static COPY_SRC=4;static COPY_DST=8;get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,t){let i={...t};(t.usage||0)&n.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?i.indexType="uint32":t.data instanceof Uint16Array?i.indexType="uint16":t.data instanceof Uint8Array&&(i.indexType="uint8")),delete i.data,super(e,i,n.defaultProps),this.usage=i.usage||0,this.indexType=i.indexType,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}static DEBUG_DATA_MAX_LENGTH=32;debugData=new ArrayBuffer(0);_setDebugData(e,t,i){if(!this.device.props.debug)return;let r=null,s;ArrayBuffer.isView(e)?(r=e,s=e.buffer):s=e;let o=Math.min(e?e.byteLength:i,n.DEBUG_DATA_MAX_LENGTH);if(s===null)this.debugData=new ArrayBuffer(o);else{let a=Math.min(r?.byteOffset||0,s.byteLength),c=Math.max(0,s.byteLength-a),l=Math.min(o,c);this.debugData=new Uint8Array(s,a,l).slice().buffer}}static defaultProps={...te.defaultProps,handle:void 0,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0}}});function d0(){return wm??Uint16Array}function h0(n){return!!(wm&&n===wm)}var wm,p0=C(()=>{wm=globalThis.Float16Array});function m0(n){let e=n.includes("norm"),t=!e&&!n.startsWith("float"),i=n.startsWith("s"),r=Em[n],[s,o,a]=r||["uint8 ","i32",1];return{signedType:s,primitiveType:o,byteLength:a,normalized:e,integer:t,signed:i}}function g0(n){let e=n;switch(e){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return e}}function jt(n,e){switch(e){case 1:return n;case 2:return n+n%2;default:return n+(4-n%4)%4}}function Tu(n){let e=ArrayBuffer.isView(n)?n.constructor:n;if(h0(e))return"float16";if(e===Uint8ClampedArray)return"uint8";let t=Object.values(Em).find(i=>e===i[4]);if(!t)throw new Error(e.name);return t[0]}function _0(n){return Tu(n)}function Tr(n){if(n==="float16")return d0();let e=Em[n];if(!e)throw new Error(n);let[,,,,t]=e;return t}function Lr(n){return Tr(n)}var Em,Lu=C(()=>{p0();Em={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]}});var Sm,Ke,Mu=C(()=>{Lu();Sm=class{getDataTypeInfo(e){return m0(e)}getNormalizedDataType(e){return g0(e)}alignTo(e,t){return jt(e,t)}getDataType(e){return _0(e)}getTypedArrayConstructor(e){return Lr(e)}},Ke=new Sm});function mR(n,e){try{return Ke.getDataTypeInfo(e)}catch{throw new Error(`Unsupported vertex format: ${n}`)}}function gR(n,e){if(!e)return 1;let t=Number(e);if(t===2||t===3||t===4)return t;throw new Error(`Unsupported vertex format: ${n}`)}function _R(n,e,t){if(t!==3)throw new Error(`Unsupported vertex format: ${n}`);switch(e){case"uint8":case"sint8":case"unorm8":case"snorm8":case"uint16":case"sint16":case"unorm16":case"snorm16":return`${e}x3-webgl`;default:throw new Error(`Unsupported vertex format: ${n}`)}}var Pm,Ee,Sa=C(()=>{Mu();Pm=class{getVertexFormatInfo(e){if(e==="unorm10-10-10-2")return{type:"unorm8",components:4,byteLength:4,integer:!1,signed:!1,normalized:!0};let t=e==="unorm8x4-bgra"?"unorm8x4":e,i;t.endsWith("-webgl")&&(t=t.slice(0,-6),i=!0);let r=t.split("x");if(r.length>2)throw new Error(`Unsupported vertex format: ${e}`);let[s,o]=r,a=s,c=gR(e,o),l=mR(e,a),u;try{u=i?_R(e,a,c):this.makeVertexFormat(l.signedType,c,l.normalized)}catch{throw new Error(`Unsupported vertex format: ${e}`)}if(u!==(i?e:t))throw new Error(`Unsupported vertex format: ${e}`);let f={type:a,components:c,byteLength:l.byteLength*c,integer:l.integer,signed:l.signed,normalized:l.normalized};return i&&(f.webglOnly=!0),f}makeVertexFormat(e,t,i){let r=i?Ke.getNormalizedDataType(e):e;switch(r){case"unorm8":return t===1?"unorm8":t===3?"unorm8x3-webgl":`${r}x${t}`;case"snorm8":return t===1?"snorm8":t===3?"snorm8x3-webgl":`${r}x${t}`;case"uint8":case"sint8":if(t===3)throw new Error(`size: ${t}`);return t===1?r:`${r}x${t}`;case"uint16":return t===1?"uint16":t===3?"uint16x3-webgl":`${r}x${t}`;case"sint16":return t===1?"sint16":t===3?"sint16x3-webgl":`${r}x${t}`;case"unorm16":return t===1?"unorm16":t===3?"unorm16x3-webgl":`${r}x${t}`;case"snorm16":return t===1?"snorm16":t===3?"snorm16x3-webgl":`${r}x${t}`;case"float16":if(t===3)throw new Error(`size: ${t}`);return t===1?r:`${r}x${t}`;default:return t===1?r:`${r}x${t}`}}getVertexFormatFromAttribute(e,t,i){if(!t||t>4)throw new Error(`size ${t}`);let r=t,s=Ke.getDataType(e);return this.makeVertexFormat(s,r,i)}getCompatibleVertexFormat(e){let t;switch(e.primitiveType){case"f32":t="float32";break;case"i32":t="sint32";break;case"u32":t="uint32";break;case"f16":return e.components<=2?"float16x2":"float16x4"}return e.components===1?t:`${t}x${e.components}`}},Ee=new Pm});function Iu(n){let e=v0[n];if(!e)throw new Error(`Unsupported texture format ${n}`);return e}function b0(){return v0}var Je,be,Dn,yR,Au,Cm,ku,Tm,bR,Lm,Ui,Mm,Am,Ru,y0,vR,xR,v0,km=C(()=>{Je="texture-compression-bc",be="texture-compression-astc",Dn="texture-compression-etc2",yR="texture-compression-etc1-webgl",Au="texture-compression-pvrtc-webgl",Cm="texture-compression-atc-webgl",ku="float32-renderable-webgl",Tm="float16-renderable-webgl",bR="rgb9e5ufloat-renderable-webgl",Lm="snorm8-renderable-webgl",Ui="norm16-webgl",Mm="norm16-renderable-webgl",Am="snorm16-renderable-webgl",Ru="float32-filterable",y0="float16-filterable-webgl";vR={r8unorm:{webgpu:527},rg8unorm:{webgpu:527},"rgb8unorm-webgl":{},rgba8unorm:{webgpu:31},"rgba8unorm-srgb":{webgpu:15},r8snorm:{render:Lm,webgpu:837},rg8snorm:{render:Lm,webgpu:837},"rgb8snorm-webgl":{},rgba8snorm:{render:Lm,webgpu:341},r8uint:{webgpu:515},rg8uint:{webgpu:515},rgba8uint:{webgpu:19},r8sint:{webgpu:515},rg8sint:{webgpu:515},rgba8sint:{webgpu:19},bgra8unorm:{webgpu:15},"bgra8unorm-srgb":{webgpu:15360},r16unorm:{f:Ui,render:Mm,webgpu:992},rg16unorm:{f:Ui,render:Mm,webgpu:992},"rgb16unorm-webgl":{f:Ui,render:!1},rgba16unorm:{f:Ui,render:Mm,webgpu:992},r16snorm:{f:Ui,render:Am,webgpu:992},rg16snorm:{f:Ui,render:Am,webgpu:992},"rgb16snorm-webgl":{f:Ui,render:!1},rgba16snorm:{f:Ui,render:Am,webgpu:992},r16uint:{webgpu:515},rg16uint:{webgpu:515},rgba16uint:{webgpu:19},r16sint:{webgpu:515},rg16sint:{webgpu:515},rgba16sint:{webgpu:19},r16float:{render:Tm,filter:"float16-filterable-webgl",webgpu:527},rg16float:{render:Tm,filter:y0,webgpu:527},rgba16float:{render:Tm,filter:y0,webgpu:31},r32uint:{webgpu:19},rg32uint:{webgpu:16387},rgba32uint:{webgpu:19},r32sint:{webgpu:19},rg32sint:{webgpu:16387},rgba32sint:{webgpu:19},r32float:{render:ku,filter:Ru,webgpu:19},rg32float:{render:!1,filter:Ru,webgpu:16387},"rgb32float-webgl":{render:ku,filter:Ru},rgba32float:{render:ku,filter:Ru,webgpu:19},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:bR,webgpu:5},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:ku,webgpu:517},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:527},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:515},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8",webgpu:3},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16",webgpu:3},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32",webgpu:3},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32",webgpu:3},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0,webgpu:3},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0,f:"depth32float-stencil8",webgpu:3}},xR={"bc1-rgb-unorm-webgl":{f:Je},"bc1-rgb-unorm-srgb-webgl":{f:Je},"bc1-rgba-unorm":{f:Je},"bc1-rgba-unorm-srgb":{f:Je},"bc2-rgba-unorm":{f:Je},"bc2-rgba-unorm-srgb":{f:Je},"bc3-rgba-unorm":{f:Je},"bc3-rgba-unorm-srgb":{f:Je},"bc4-r-unorm":{f:Je},"bc4-r-snorm":{f:Je},"bc5-rg-unorm":{f:Je},"bc5-rg-snorm":{f:Je},"bc6h-rgb-ufloat":{f:Je},"bc6h-rgb-float":{f:Je},"bc7-rgba-unorm":{f:Je},"bc7-rgba-unorm-srgb":{f:Je},"etc2-rgb8unorm":{f:Dn},"etc2-rgb8unorm-srgb":{f:Dn},"etc2-rgb8a1unorm":{f:Dn},"etc2-rgb8a1unorm-srgb":{f:Dn},"etc2-rgba8unorm":{f:Dn},"etc2-rgba8unorm-srgb":{f:Dn},"eac-r11unorm":{f:Dn},"eac-r11snorm":{f:Dn},"eac-rg11unorm":{f:Dn},"eac-rg11snorm":{f:Dn},"astc-4x4-unorm":{f:be},"astc-4x4-unorm-srgb":{f:be},"astc-5x4-unorm":{f:be},"astc-5x4-unorm-srgb":{f:be},"astc-5x5-unorm":{f:be},"astc-5x5-unorm-srgb":{f:be},"astc-6x5-unorm":{f:be},"astc-6x5-unorm-srgb":{f:be},"astc-6x6-unorm":{f:be},"astc-6x6-unorm-srgb":{f:be},"astc-8x5-unorm":{f:be},"astc-8x5-unorm-srgb":{f:be},"astc-8x6-unorm":{f:be},"astc-8x6-unorm-srgb":{f:be},"astc-8x8-unorm":{f:be},"astc-8x8-unorm-srgb":{f:be},"astc-10x5-unorm":{f:be},"astc-10x5-unorm-srgb":{f:be},"astc-10x6-unorm":{f:be},"astc-10x6-unorm-srgb":{f:be},"astc-10x8-unorm":{f:be},"astc-10x8-unorm-srgb":{f:be},"astc-10x10-unorm":{f:be},"astc-10x10-unorm-srgb":{f:be},"astc-12x10-unorm":{f:be},"astc-12x10-unorm-srgb":{f:be},"astc-12x12-unorm":{f:be},"astc-12x12-unorm-srgb":{f:be},"pvrtc-rgb4unorm-webgl":{f:Au},"pvrtc-rgba4unorm-webgl":{f:Au},"pvrtc-rgb2unorm-webgl":{f:Au},"pvrtc-rgba2unorm-webgl":{f:Au},"etc1-rbg-unorm-webgl":{f:yR},"atc-rgb-unorm-webgl":{f:Cm},"atc-rgba-unorm-webgl":{f:Cm},"atc-rgbai-unorm-webgl":{f:Cm}},v0={...vR,...xR}});function TR({format:n,width:e,height:t,depth:i,byteAlignment:r}){let s=ft.getInfo(n),{bytesPerPixel:o,bytesPerBlock:a=o,blockWidth:c=1,blockHeight:l=1,compressed:u=!1}=s,f=u?Math.ceil(e/c):e,d=u?Math.ceil(t/l):t,h=f*a,p=Math.ceil(h/r)*r,m=d,g=p*m*i;return{bytesPerPixel:o,bytesPerRow:p,rowsPerImage:m,depthOrArrayLayers:i,bytesPerImage:p*m,byteLength:g}}function LR(n){let e=Iu(n),t={format:n,create:e.f??!0,render:e.render??!0,filter:e.filter??!0,blend:e.blend??!0,store:e.store??!0},i=x0(n),r=n.startsWith("depth")||n.startsWith("stencil"),s=i?.signed,o=i?.integer,a=i?.webgl,c=!!i?.compressed;return t.render&&=!r&&!c,t.filter&&=!r&&!s&&!o&&!a,t}function x0(n){let e=MR(n);if(ft.isCompressed(n)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0,e.bytesPerBlock=kR(n);let i=AR(n);i&&(e.blockWidth=i.blockWidth,e.blockHeight=i.blockHeight)}let t=e.packed?null:wR.exec(n);if(t){let[,i,r,s,o,a]=t,c=`${s}${r}`,l=Ke.getDataTypeInfo(c),u=l.byteLength*8,f=i?.length??1,d=[u,f>=2?u:0,f>=3?u:0,f>=4?u:0];e={format:n,attachment:e.attachment,dataType:l.signedType,components:f,channels:i,integer:l.integer,signed:l.signed,normalized:l.normalized,bitsPerChannel:d,bytesPerPixel:l.byteLength*f,packed:e.packed,srgb:e.srgb},a==="-webgl"&&(e.webgl=!0),o==="-srgb"&&(e.srgb=!0)}return n.endsWith("-webgl")&&(e.webgl=!0),n.endsWith("-srgb")&&(e.srgb=!0),e}function MR(n){let e={...Iu(n)},t=e.bytesPerPixel||1,i=e.bitsPerChannel||[8,8,8,8];return delete e.bitsPerChannel,delete e.bytesPerPixel,delete e.f,delete e.render,delete e.filter,delete e.blend,delete e.store,delete e.webgpu,{...e,format:n,attachment:e.attachment||"color",channels:e.channels||"r",components:e.components||e.channels?.length||1,bytesPerPixel:t,bitsPerChannel:i,dataType:e.dataType||"uint8",srgb:e.srgb??!1,packed:e.packed??!1,webgl:e.webgl??!1,integer:e.integer??!1,signed:e.signed??!1,normalized:e.normalized??!1,compressed:e.compressed??!1}}function AR(n){let t=/.*-(\d+)x(\d+)-.*/.exec(n);if(t){let[,i,r]=t;return{blockWidth:Number(i),blockHeight:Number(r)}}return n.startsWith("bc")||n.startsWith("etc1")||n.startsWith("etc2")||n.startsWith("eac")||n.startsWith("atc")?{blockWidth:4,blockHeight:4}:n.startsWith("pvrtc-rgb4")||n.startsWith("pvrtc-rgba4")?{blockWidth:4,blockHeight:4}:n.startsWith("pvrtc-rgb2")||n.startsWith("pvrtc-rgba2")?{blockWidth:8,blockHeight:4}:null}function kR(n){return n.startsWith("bc1")||n.startsWith("bc4")||n.startsWith("etc1")||n.startsWith("etc2-rgb8")||n.startsWith("etc2-rgb8a1")||n.startsWith("eac-r11")||n==="atc-rgb-unorm-webgl"?8:n.startsWith("bc2")||n.startsWith("bc3")||n.startsWith("bc5")||n.startsWith("bc6h")||n.startsWith("bc7")||n.startsWith("etc2-rgba8")||n.startsWith("eac-rg11")||n.startsWith("astc")||n==="atc-rgba-unorm-webgl"||n==="atc-rgbai-unorm-webgl"?16:n.startsWith("pvrtc")?8:16}var wR,ER,SR,PR,CR,Rm,ft,Bu=C(()=>{Mu();km();wR=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,ER=["rgb","rgba","bgra"],SR=["depth","stencil"],PR=5,CR=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],Rm=class{isColor(e){return ER.some(t=>e.startsWith(t))}isDepthStencil(e){return SR.some(t=>e.startsWith(t))}isCompressed(e){return CR.some(t=>e.startsWith(t))}getInfo(e){return x0(e)}getCapabilities(e){return LR(e)}getWebGPUCapabilities(e){let t=Iu(e);return t.webgpu!==void 0?t.webgpu:this.isCompressed(e)&&!e.endsWith("-webgl")?PR:0}computeMemoryLayout(e){return TR(e)}},ft=new Rm});function w0(n){return typeof ImageData<"u"&&n instanceof ImageData||typeof ImageBitmap<"u"&&n instanceof ImageBitmap||typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement||typeof VideoFrame<"u"&&n instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas}function E0(n){if(typeof ImageData<"u"&&n instanceof ImageData||typeof ImageBitmap<"u"&&n instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas)return{width:n.width,height:n.height};if(typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement)return{width:n.naturalWidth,height:n.naturalHeight};if(typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement)return{width:n.videoWidth,height:n.videoHeight};if(typeof VideoFrame<"u"&&n instanceof VideoFrame)return{width:n.displayWidth,height:n.displayHeight};throw new Error("Unknown image type")}var S0=C(()=>{});function RR(n,e){let t=Im(n),i=e.map(Im).filter(r=>r!==void 0);return[t,...i].filter(r=>r!==void 0)}function Im(n){if(n!==void 0){if(n===null||typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n;if(n instanceof Error)return n.message;if(Array.isArray(n))return n.map(Im);if(typeof n=="object"){if(IR(n)){let e=String(n);if(e!=="[object Object]")return e}return BR(n)?OR(n):n.constructor?.name||"Object"}return String(n)}}function IR(n){return"toString"in n&&typeof n.toString=="function"&&n.toString!==Object.prototype.toString}function BR(n){return"message"in n&&"type"in n}function OR(n){let e=typeof n.type=="string"?n.type:"message",t=typeof n.message=="string"?n.message:"",i=typeof n.lineNum=="number"?n.lineNum:null,r=typeof n.linePos=="number"?n.linePos:null,s=i!==null&&r!==null?` @ ${i}:${r}`:i!==null?` @ ${i}`:"";return`${e}${s}: ${t}`.trim()}function Bm(){if(typeof HTMLCanvasElement>"u")return!1;let n=HTMLCanvasElement.prototype;return"layoutSubtree"in n&&typeof n.requestPaint=="function"}var Pa,Ca,pi,P0=C(()=>{bm();ut();Ws();Cu();Sa();Bu();S0();km();_m();Pa=class{};Ca=class{features;disabledFeatures;constructor(e=[],t){this.features=new Set(e),this.disabledFeatures=t||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures?.[e]&&this.features.has(e)}};pi=class n{static defaultProps={...Eu};get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}toJSON(){return this.toString()}id;props;userData={};statsManager=Su;_factories={};timestamp=0;_reused=!1;_moduleData={};wgslLanguageFeatures=new Set;_textureCaps={};_debugGPUTimeQuery=null;constructor(e){this.props={...n.defaultProps,...e},this.id=this.props.id||On(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(e){return Ee.getVertexFormatInfo(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return ft.getInfo(e)}getTextureFormatCapabilities(e){let t=this._textureCaps[e];if(!t){let i=this._getDeviceTextureFormatCapabilities(e);t=this._getDeviceSpecificTextureFormatCapabilities(i),this._textureCaps[e]=t}return t}getMipLevelCount(e,t,i=1){let r=Math.max(e,t,i);return 1+Math.floor(Math.log2(r))}isExternalImage(e){return w0(e)}getExternalImageSize(e){return E0(e)}isTextureFormatSupported(e){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return ft.isCompressed(e)}getSupportedCompressedTextureFormats(){let e=[];for(let t of Object.keys(b0()))this.isTextureFormatCompressed(t)&&this.isTextureFormatSupported(t)&&e.push(t);return e}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){this.commandEncoder?.popDebugGroup()}insertDebugMarker(e){this.commandEncoder?.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,t,...i){if(!this.props.onError(e,t)){let s=RR(t,i);return z.error(this.type==="webgl"?"%cWebGL":"%cWebGPU","color: white; background: red; padding: 2px 6px; border-radius: 3px;",e.message,...s)}return()=>{}}debug(){if(this.props.debug)debugger;else{let e=`'Type luma.log.set({debug: true}) in console to enable debug breakpoints', +or create a device with the 'debug: true' prop.`;z.once(0,e)()}}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}createFence(){throw new Error("createFence() not implemented")}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}writeBufferViaCommandEncoder(e,t,i,r=0){throw new Error("writeBufferViaCommandEncoder() not implemented")}generateMipmapsWebGPU(e){throw new Error("not implemented")}_createSharedRenderPipelineWebGL(e){throw new Error("_createSharedRenderPipelineWebGL() not implemented")}_createBindGroupLayoutWebGPU(e,t){throw new Error("_createBindGroupLayoutWebGPU() not implemented")}_createBindGroupWebGPU(e,t,i,r,s){throw new Error("_createBindGroupWebGPU() not implemented")}_supportsDebugGPUTime(){return this.features.has("timestamp-query")&&!!(this.props.debug||this.props.debugGPUTime)}_enableDebugGPUTime(e=256){if(!this._supportsDebugGPUTime())return null;if(this._debugGPUTimeQuery)return this._debugGPUTimeQuery;try{this._debugGPUTimeQuery=this.createQuerySet({type:"timestamp",count:e}),this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id,timeProfilingQuerySet:this._debugGPUTimeQuery})}catch{this._debugGPUTimeQuery=null}return this._debugGPUTimeQuery}_disableDebugGPUTime(){this._debugGPUTimeQuery&&(this.commandEncoder.getTimeProfilingQuerySet()===this._debugGPUTimeQuery&&(this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id})),this._debugGPUTimeQuery.destroy(),this._debugGPUTimeQuery=null)}_isDebugGPUTimeEnabled(){return this._debugGPUTimeQuery!==null}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}getModuleData(e){return this._moduleData[e]||={},this._moduleData[e]}static _getCanvasContextProps(e){return e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){let t=ft.getCapabilities(e),i=s=>(typeof s=="string"?this.features.has(s):s)??!0,r=i(t.create);return{format:e,create:r,render:r&&i(t.render),filter:r&&i(t.filter),blend:r&&i(t.blend),store:r&&i(t.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let t={...e};if((e.usage||0)&re.INDEX&&(e.indexType||(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array?t.indexType="uint16":e.data instanceof Uint8Array&&(t.data=new Uint16Array(e.data),t.indexType="uint16")),!t.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return t}}});var Ou,C0=C(()=>{Ou=class{props;_resizeObserver;_intersectionObserver;_observeDevicePixelRatioTimeout=null;_observeDevicePixelRatioMediaQuery=null;_handleDevicePixelRatioChange=()=>this._refreshDevicePixelRatio();_trackPositionInterval=null;_started=!1;get started(){return this._started}constructor(e){this.props=e}start(){if(this._started||!this.props.canvas)return;this._started=!0,this._intersectionObserver||=new IntersectionObserver(t=>this.props.onIntersection(t)),this._resizeObserver||=new ResizeObserver(t=>this.props.onResize(t)),this._intersectionObserver.observe(this.props.canvas);let e=this.props.resizeObserverBox;try{this._resizeObserver.observe(this.props.canvas,{box:e})}catch{this._resizeObserver.observe(this.props.canvas,{box:"content-box"})}this._observeDevicePixelRatioTimeout=setTimeout(()=>this._refreshDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}stop(){this._started&&(this._started=!1,this._observeDevicePixelRatioTimeout&&(clearTimeout(this._observeDevicePixelRatioTimeout),this._observeDevicePixelRatioTimeout=null),this._observeDevicePixelRatioMediaQuery&&(this._observeDevicePixelRatioMediaQuery.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=null),this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null),this._resizeObserver?.disconnect(),this._intersectionObserver?.disconnect())}_refreshDevicePixelRatio(){this._started&&(this.props.onDevicePixelRatioChange(),this._observeDevicePixelRatioMediaQuery?.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._observeDevicePixelRatioMediaQuery.addEventListener("change",this._handleDevicePixelRatioChange,{once:!0}))}_trackPosition(e=100){this._trackPositionInterval||(this._trackPositionInterval=setInterval(()=>{this._started?this.props.onPositionChange():this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null)},e))}}});function T0(){let n,e;return{promise:new Promise((i,r)=>{n=i,e=r}),resolve:n,reject:e}}var L0=C(()=>{});function $i(n,e){if(!n){let t=new Error(e??"luma.gl assertion failed.");throw Error.captureStackTrace?.(t,$i),t}}function Gi(n,e){return $i(n,e),n}var Om=C(()=>{});function DR(n){if(typeof n=="string"){let e=document.getElementById(n);if(!e)throw new Error(`${n} is not an HTML element`);return e}return n||document.body}function NR(n){let e=document.getElementById(n);if(!Vi.isHTMLCanvas(e))throw new Error("Object is not a canvas element");return e}function FR(n){let{width:e,height:t}=n,i=document.createElement("canvas");i.id=On("lumagl-auto-created-canvas"),i.width=e||1,i.height=t||1,i.style.width=Number.isFinite(e)?`${e}px`:"100%",i.style.height=Number.isFinite(t)?`${t}px`:"100%",n?.visible||(i.style.visibility="hidden");let r=DR(n?.container||null);return r.insertBefore(i,r.firstChild),i}function zR(n,e,t,i,r){let s=n,o=M0(s[0],e,t),a=A0(s[1],e,i,r),c=M0(s[0]+1,e,t),l=c===t-1?c:c-1;c=A0(s[1]+1,e,i,r);let u;return r?(c=c===0?c:c+1,u=a,a=c):u=c===i-1?c:c-1,{x:o,y:a,width:Math.max(l-o+1,1),height:Math.max(u-a+1,1)}}function M0(n,e,t){return Math.min(Math.round(n*e),t-1)}function A0(n,e,t,i){return i?Math.max(0,t-1-Math.round(n*e)):Math.min(Math.round(n*e),t-1)}var Vi,Dm=C(()=>{vr();C0();Ws();L0();Om();Vi=class n{static isHTMLCanvas(e){return typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}static defaultProps={id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,pixelSizeSource:"exact",autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",colorFormat:void 0,toneMapping:"standard",trackPosition:!1};id;props;canvas;htmlCanvas;offscreenCanvas;type;initialized;isInitialized=!1;isVisible=!0;cssWidth;cssHeight;devicePixelRatio;devicePixelWidth;devicePixelHeight;drawingBufferWidth;drawingBufferHeight;_initializedResolvers=T0();_canvasObserver;_position=[0,0];destroyed=!1;_needsDrawingBufferResize=!0;_configuredDrawingBufferSize=[0,0];toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(e){this.props={...n.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,Pt()?e.canvas?typeof e.canvas=="string"?this.canvas=NR(e.canvas):this.canvas=e.canvas:this.canvas=FR(e):this.canvas={width:e.width||1,height:e.height||1},n.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):n.isOffscreenCanvas(this.canvas)?(this.id=e.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=e.id||"node-canvas-context",this.type="node"),this.cssWidth=this.htmlCanvas?.clientWidth||this.canvas.width,this.cssHeight=this.htmlCanvas?.clientHeight||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this._configuredDrawingBufferSize=[this.canvas.width,this.canvas.height],this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],this._canvasObserver=new Ou({canvas:this.htmlCanvas,trackPosition:this.props.trackPosition,resizeObserverBox:this.props.pixelSizeSource==="css-dpr"?"content-box":"device-pixel-content-box",onResize:t=>this._handleResize(t),onIntersection:t=>this._handleIntersection(t),onDevicePixelRatioChange:()=>this._observeDevicePixelRatio(),onPositionChange:()=>this.updatePosition()})}destroy(){this.destroyed||(this.destroyed=!0,this._stopObservers(),this.device=null)}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCurrentFramebuffer(e){return this._resizeDrawingBufferIfNeeded(),this._getCurrentFramebuffer(e)}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){let e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,t){e=Math.floor(e),t=Math.floor(t),!(this.drawingBufferWidth===e&&this.drawingBufferHeight===t)&&(this.drawingBufferWidth=e,this.drawingBufferHeight=t,this._needsDrawingBufferResize=!0)}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(e,t=!0){let i=this.cssToDeviceRatio(),[r,s]=this.getDrawingBufferSize();return zR(e,i,r,s,t)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){let[e,t]=this.getDrawingBufferSize();return e>0&&t>0?e/t:1}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),[t]=this.getCSSSize();return t?e/t:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}_startObservers(){this.destroyed||this._canvasObserver.start()}_stopObservers(){this._canvasObserver.stop()}_handleIntersection(e){if(this.destroyed)return;let t=e.find(r=>r.target===this.canvas);if(!t)return;let i=t.isIntersecting;this.isVisible!==i&&(this.isVisible=i,this.device.props.onVisibilityChange(this))}_handleResize(e){if(this.destroyed)return;let t=e.find(s=>s.target===this.canvas);if(!t)return;let i=Gi(t.contentBoxSize?.[0]);this.cssWidth=i.inlineSize,this.cssHeight=i.blockSize;let r=this.getDevicePixelSize();this._setDevicePixelSize(this._getDevicePixelSizeFromResizeEntry(t)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:r})}_updateDrawingBufferSize(){if(this.props.autoResize)if(typeof this.props.useDevicePixels=="number"){let e=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*e,this.cssHeight*e)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_getDevicePixelSizeFromResizeEntry(e){let t=Gi(e.contentBoxSize?.[0]);return this.props.pixelSizeSource==="css-dpr"?this._getDevicePixelSizeFromCSSSize(t.inlineSize,t.blockSize):{devicePixelWidth:e.devicePixelContentBoxSize?.[0]?.inlineSize||t.inlineSize*devicePixelRatio,devicePixelHeight:e.devicePixelContentBoxSize?.[0]?.blockSize||t.blockSize*devicePixelRatio}}_getDevicePixelSizeFromCSSSize(e,t){let i=this.getDevicePixelRatio();return{devicePixelWidth:Math.floor(e*i),devicePixelHeight:Math.floor(t*i)}}_setDevicePixelSize({devicePixelWidth:e,devicePixelHeight:t}){let[i,r]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(e,i)),this.devicePixelHeight=Math.max(1,Math.min(t,r))}_resizeDrawingBufferIfNeeded(){if(this._needsDrawingBufferResize){this._needsDrawingBufferResize=!1,(this.drawingBufferWidth!==this.canvas.width||this.drawingBufferHeight!==this.canvas.height)&&(this.canvas.width=this.drawingBufferWidth,this.canvas.height=this.drawingBufferHeight);let[t,i]=this._configuredDrawingBufferSize;(this.drawingBufferWidth!==t||this.drawingBufferHeight!==i)&&(this._configureDevice(),this._configuredDrawingBufferSize=[this.drawingBufferWidth,this.drawingBufferHeight])}}_observeDevicePixelRatio(){if(this.destroyed||!this._canvasObserver.started)return;let e=this.devicePixelRatio;if(this.devicePixelRatio=window.devicePixelRatio,this.props.pixelSizeSource==="css-dpr"){let t=this.getDevicePixelSize();this._setDevicePixelSize(this._getDevicePixelSizeFromCSSSize(this.cssWidth,this.cssHeight)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:t})}this.updatePosition(),this.device.props.onDevicePixelRatioChange?.(this,{oldRatio:e})}updatePosition(){if(this.destroyed)return;let e=this.htmlCanvas?.getBoundingClientRect();if(e){let t=[e.left,e.top];if(this._position??=t,t[0]!==this._position[0]||t[1]!==this._position[1]){let r=this._position;this._position=t,this.device.props.onPositionChange?.(this,{oldPosition:r})}}}}});var Ta,k0=C(()=>{Dm();Ta=class extends Vi{static defaultProps=Vi.defaultProps}});var La,R0=C(()=>{Dm();La=class extends Vi{}});var Mr,Nm=C(()=>{He();Mr=class n extends te{static defaultProps={...te.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1};get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){t=n.normalizeProps(e,t),super(e,t,n.defaultProps)}static normalizeProps(e,t){return t}}});var UR,pe,Fm=C(()=>{He();Nm();ut();Bu();UR={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},pe=class n extends te{static SAMPLE=4;static STORAGE=8;static RENDER=16;static COPY_SRC=1;static COPY_DST=2;static TEXTURE=4;static RENDER_ATTACHMENT=16;dimension;baseDimension;format;width;height;depth;mipLevels;samples;byteAlignment;ready=Promise.resolve(this);isReady=!0;updateTimestamp;get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(e,t,i){if(t=n.normalizeProps(e,t),super(e,t,n.defaultProps),this.dimension=this.props.dimension,this.baseDimension=UR[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.samples=this.props.samples||1,this.dimension==="cube"&&(this.depth=6),this.props.width===void 0||this.props.height===void 0)if(e.isExternalImage(t.data)){let r=e.getExternalImageSize(t.data);this.width=r?.width||1,this.height=r?.height||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&z.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=i?.byteAlignment||1,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createTexture({...this.props,...e})}setSampler(e){this.sampler=e instanceof Mr?e:this.device.createSampler(e)}copyImageData(e){let{data:t,depth:i,...r}=e;this.writeData(t,{...r,depthOrArrayLayers:r.depthOrArrayLayers??i})}computeMemoryLayout(e={}){let t=this._normalizeTextureReadOptions(e),{width:i=this.width,height:r=this.height,depthOrArrayLayers:s=this.depth}=t,{format:o,byteAlignment:a}=this;return ft.computeMemoryLayout({format:o,width:i,height:r,depth:s,byteAlignment:a})}readBuffer(e,t){throw new Error("readBuffer not implemented")}readDataAsync(e){throw new Error("readBuffer not implemented")}writeBuffer(e,t){throw new Error("readBuffer not implemented")}writeData(e,t){throw new Error("readBuffer not implemented")}readDataSyncWebGL(e){throw new Error("readDataSyncWebGL not available")}generateMipmapsWebGL(){throw new Error("generateMipmapsWebGL not available")}static normalizeProps(e,t){let i={...t},{width:r,height:s}=i;return typeof r=="number"&&(i.width=Math.max(1,Math.ceil(r))),typeof s=="number"&&(i.height=Math.max(1,Math.ceil(s))),i}_initializeData(e){this.device.isExternalImage(e)?this.copyExternalImage({image:e,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):e&&this.copyImageData({data:e,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(e){let{data:t,depth:i,...r}=e,s=this._normalizeTextureWriteOptions({...r,depthOrArrayLayers:r.depthOrArrayLayers??i});return{data:t,depth:s.depthOrArrayLayers,...s}}_normalizeCopyExternalImageOptions(e){let t=n._omitUndefined(e),i=t.mipLevel??0,r=this._getMipLevelSize(i),s=this.device.getExternalImageSize(e.image),o={...n.defaultCopyExternalImageOptions,...r,...s,...t};return o.width=Math.min(o.width,r.width-o.x),o.height=Math.min(o.height,r.height-o.y),o.depth=Math.min(o.depth,r.depthOrArrayLayers-o.z),o}_normalizeCopyElementImageOptions(e){let t=n._omitUndefined(e),i=t.mipLevel??0,r=this._getMipLevelSize(i),s={...n.defaultCopyElementImageOptions,...r,...t};return s.width=Math.min(s.width,r.width-s.x),s.height=Math.min(s.height,r.height-s.y),s.depth=Math.min(s.depth,r.depthOrArrayLayers-s.z),s}_normalizeTextureReadOptions(e){let t=n._omitUndefined(e),i=t.mipLevel??0,r=this._getMipLevelSize(i),s={...n.defaultTextureReadOptions,...r,...t};return s.width=Math.min(s.width,r.width-s.x),s.height=Math.min(s.height,r.height-s.y),s.depthOrArrayLayers=Math.min(s.depthOrArrayLayers,r.depthOrArrayLayers-s.z),s}_getSupportedColorReadOptions(e){let t=this._normalizeTextureReadOptions(e),i=ft.getInfo(this.format);switch(this._validateColorReadAspect(t),this._validateColorReadFormat(i),this.dimension){case"2d":case"cube":case"cube-array":case"2d-array":case"3d":return t;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}}_validateColorReadAspect(e){if(e.aspect!=="all")throw new Error(`${this} color readback only supports aspect 'all'`)}_validateColorReadFormat(e){if(e.compressed)throw new Error(`${this} color readback does not support compressed formats (${this.format})`);switch(e.attachment){case"color":return;case"depth":throw new Error(`${this} color readback does not support depth formats (${this.format})`);case"stencil":throw new Error(`${this} color readback does not support stencil formats (${this.format})`);case"depth-stencil":throw new Error(`${this} color readback does not support depth-stencil formats (${this.format})`);default:throw new Error(`${this} color readback does not support format ${this.format}`)}}_normalizeTextureWriteOptions(e){let t=n._omitUndefined(e),i=t.mipLevel??0,r=this._getMipLevelSize(i),s={...n.defaultTextureWriteOptions,...r,...t};s.width=Math.min(s.width,r.width-s.x),s.height=Math.min(s.height,r.height-s.y),s.depthOrArrayLayers=Math.min(s.depthOrArrayLayers,r.depthOrArrayLayers-s.z);let o=ft.computeMemoryLayout({format:this.format,width:s.width,height:s.height,depth:s.depthOrArrayLayers,byteAlignment:this.byteAlignment}),a=o.bytesPerPixel*s.width;if(s.bytesPerRow=t.bytesPerRow??o.bytesPerRow,s.rowsPerImage=t.rowsPerImage??s.height,s.bytesPerRow>e),i=this.baseDimension==="1d"?1:Math.max(1,this.height>>e),r=this.dimension==="3d"?Math.max(1,this.depth>>e):this.depth;return{width:t,height:i,depthOrArrayLayers:r}}getAllocatedByteLength(){let e=0;for(let t=0;tt!==void 0))}static defaultProps={...te.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:n.SAMPLE|n.RENDER|n.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0};static defaultCopyDataOptions={data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,width:void 0,height:void 0,depthOrArrayLayers:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all"};static defaultCopyExternalImageOptions={image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultCopyElementImageOptions={element:void 0,width:void 0,height:void 0,sourceX:0,sourceY:0,sourceWidth:void 0,sourceHeight:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultTextureReadOptions={x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"};static defaultTextureWriteOptions={byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"}}});var Ar,I0=C(()=>{He();Ar=class n extends te{get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,n.defaultProps)}static defaultProps={...te.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0}}});var Ma,B0=C(()=>{He();Ma=class n extends te{width;height;updateTimestamp;get[Symbol.toStringTag](){return"ExternalTexture"}constructor(e,t){super(e,t,n.defaultProps);let i=this.props.source?e.getExternalImageSize(this.props.source):null;this.width=this.props.width||i?.width||0,this.height=this.props.height||i?.height||0,this.updateTimestamp=e.incrementTimestamp()}static defaultProps={...te.defaultProps,source:void 0,width:0,height:0,colorSpace:"srgb",sampler:{}}}});function O0(n,e,t){let i="",r=e.split(/\r?\n/),s=n.slice().sort((o,a)=>o.lineNum-a.lineNum);switch(t?.showSourceCode||"no"){case"all":let o=0;for(let a=1;a<=r.length;a++){let c=r[a-1],l=s[o];for(c&&l&&(i+=D0(c,a,t));s.length>o&&l.lineNum===a;){let u=s[o++];u&&(i+=zm(u,r,u.lineNum,{...t,inlineSource:!1}))}}for(;s.length>o;){let a=s[o++];a&&(i+=zm(a,[],0,{...t,inlineSource:!1}))}return i;case"issues":case"no":for(let a of n)i+=zm(a,r,a.lineNum,{inlineSource:t?.showSourceCode!=="no"});return i}}function zm(n,e,t,i){if(i?.inlineSource){let s=$R(e,t),o=n.linePos>0?`${" ".repeat(n.linePos+5)}^^^ +`:"";return` +${s}${o}${n.type.toUpperCase()}: ${n.message} + +`}let r=n.type==="error"?"red":"orange";return i?.html?`
${n.type.toUpperCase()}: ${n.message}
`:`${n.type.toUpperCase()}: ${n.message}`}function $R(n,e,t){let i="";for(let r=e-2;r<=e;r++){let s=n[r-1];s!==void 0&&(i+=D0(s,e,t))}return i}function D0(n,e,t){let i=t?.html?VR(n):n;return`${GR(String(e),4)}: ${i}${t?.html?"
":` +`}`}function GR(n,e){let t="";for(let i=n.length;i",">").replaceAll('"',""").replaceAll("'","'")}var N0=C(()=>{});function WR(n){return jR(n.source)||n.id||On(`unnamed ${n.stage}-shader`)}function jR(n,e="unnamed"){return/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(n)?.[1]??e}var kr,Um=C(()=>{He();ut();Ws();N0();kr=class n extends te{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,t){t={...t,debugShaders:t.debugShaders||e.props.debugShaders||"errors"},super(e,{id:WR(t),...t},n.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(){let e=this.props.debugShaders;switch(e){case"never":return;case"errors":if(this.compilationStatus==="success")return;break;case"warnings":case"always":break}try{let t=await this.getCompilationInfo();if(e==="warnings"&&t?.length===0)return;this._displayShaderLog(t,this.id)}catch(t){z.warn(`Shader ${this.id}: failed to fetch compilation info during debug logging`,t)()}}_displayShaderLog(e,t){if(typeof document>"u"||!document?.createElement)return;let i=t,r=`${this.stage} shader "${i}"`,s=O0(e,this.source,{showSourceCode:"all",html:!0}),o=this.getTranslatedSource(),a=document.createElement("div");a.innerHTML=`

Compilation error in ${r}

+
+
+ +
+
${s}
`,o&&(a.innerHTML+=`

Translated Source



${o}
`),a.style.top="0",a.style.left="0",a.style.background="white",a.style.position="fixed",a.style.zIndex="9999",a.style.maxWidth="100vw",a.style.maxHeight="100vh",a.style.overflowY="auto",document.body.appendChild(a),a.querySelector(".luma-compiler-log-error")?.scrollIntoView(),a.querySelector("button#close").onclick=()=>{a.remove()},a.querySelector("button#copy").onclick=()=>{navigator.clipboard.writeText(this.source)}}static defaultProps={...te.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0}}});var Rr,F0=C(()=>{He();Fm();ut();Rr=class n extends te{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(e,t={}){super(e,t,n.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(e){let t=this.colorAttachments.map(r=>r.texture.clone(e)),i=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,...e,colorAttachments:t,depthStencilAttachment:i})}resize(e){let t=!e;if(e){let[i,r]=Array.isArray(e)?e:[e.width,e.height];t=t||r!==this.height||i!==this.width,this.width=i,this.height=r}t&&(z.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map((t,i)=>{if(typeof t=="string"){let r=this.createColorTexture(t,i);return this.attachResource(r),r.view}return t instanceof pe?t.view:t});let e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){let t=this.createDepthStencilTexture(e);this.attachResource(t),this.depthStencilAttachment=t.view}else e instanceof pe?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,t){return this.device.createTexture({id:`${this.id}-color-attachment-${t}`,usage:pe.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(e){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:pe.RENDER_ATTACHMENT|pe.SAMPLE,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){if(this.colorAttachments.forEach((i,r)=>{let s=i.texture.clone({width:e,height:t});this.destroyAttachedResource(i),this.colorAttachments[r]=s.view,this.attachResource(s.view)}),this.depthStencilAttachment){let i=this.depthStencilAttachment.texture.clone({width:e,height:t});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=i.view,this.attachResource(i)}this.updateAttachments()}static defaultProps={...te.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null}}});var Ht,$m=C(()=>{He();Ht=class n extends te{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";sharedRenderPipeline=null;get isPending(){return this.linkStatus==="pending"||this.vs.compilationStatus==="pending"||this.fs?.compilationStatus==="pending"}get isErrored(){return this.linkStatus==="error"||this.vs.compilationStatus==="error"||this.fs?.compilationStatus==="error"}constructor(e,t){super(e,t,n.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[],this.sharedRenderPipeline=this.props._sharedRenderPipeline||null}static defaultProps={...te.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},varyings:void 0,bufferMode:void 0,disableWarnings:!1,_sharedRenderPipeline:void 0,_uniformBlockLayouts:[],bindings:void 0,bindGroups:void 0}}});var Aa,z0=C(()=>{He();Aa=class extends te{get[Symbol.toStringTag](){return"SharedRenderPipeline"}constructor(e,t){super(e,t,{...te.defaultProps,handle:void 0,vs:void 0,fs:void 0,varyings:void 0,bufferMode:void 0})}}});var Wi,Gm=C(()=>{He();Wi=class n extends te{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(e,t){super(e,t,n.defaultProps),this.shaderLayout=t.shaderLayout}static defaultProps={...te.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0}}});var Ir,U0=C(()=>{Gm();$m();ut();Ws();Ir=class n{static defaultProps={...Ht.defaultProps};static getDefaultPipelineFactory(e){let t=e.getModuleData("@luma.gl/core");return t.defaultPipelineFactory||=new n(e),t.defaultPipelineFactory}device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};_sharedRenderPipelineCache={};get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}constructor(e){this.device=e}createRenderPipeline(e){if(!this.device.props._cachePipelines)return this.device.createRenderPipeline(e);let t={...Ht.defaultProps,...e},i=this._renderPipelineCache,r=this._hashRenderPipeline(t),s=i[r]?.resource;if(s)i[r].useCount++,this.device.props.debugFactories&&z.log(3,`${this}: ${i[r].resource} reused, count=${i[r].useCount}, (id=${e.id})`)();else{let o=this.device.type==="webgl"&&this.device.props._sharePipelines?this.createSharedRenderPipeline(t):void 0;s=this.device.createRenderPipeline({...t,id:t.id?`${t.id}-cached`:On("unnamed-cached"),_sharedRenderPipeline:o}),s.hash=r,i[r]={resource:s,useCount:1},this.device.props.debugFactories&&z.log(3,`${this}: ${s} created, count=${i[r].useCount}`)()}return s}createComputePipeline(e){if(!this.device.props._cachePipelines)return this.device.createComputePipeline(e);let t={...Wi.defaultProps,...e},i=this._computePipelineCache,r=this._hashComputePipeline(t),s=i[r]?.resource;return s?(i[r].useCount++,this.device.props.debugFactories&&z.log(3,`${this}: ${i[r].resource} reused, count=${i[r].useCount}, (id=${e.id})`)()):(s=this.device.createComputePipeline({...t,id:t.id?`${t.id}-cached`:void 0}),s.hash=r,i[r]={resource:s,useCount:1},this.device.props.debugFactories&&z.log(3,`${this}: ${s} created, count=${i[r].useCount}`)()),s}release(e){if(!this.device.props._cachePipelines){e.destroy();return}let t=this._getCache(e),i=e.hash;t[i].useCount--,t[i].useCount===0?(this._destroyPipeline(e),this.device.props.debugFactories&&z.log(3,`${this}: ${e} released and destroyed`)()):t[i].useCount<0?(z.error(`${this}: ${e} released, useCount < 0, resetting`)(),t[i].useCount=0):this.device.props.debugFactories&&z.log(3,`${this}: ${e} released, count=${t[i].useCount}`)()}createSharedRenderPipeline(e){let t=this._hashSharedRenderPipeline(e),i=this._sharedRenderPipelineCache[t];return i||(i={resource:this.device._createSharedRenderPipelineWebGL(e),useCount:0},this._sharedRenderPipelineCache[t]=i),i.useCount++,i.resource}releaseSharedRenderPipeline(e){if(!e.sharedRenderPipeline)return;let t=this._hashSharedRenderPipeline(e.sharedRenderPipeline.props),i=this._sharedRenderPipelineCache[t];i&&(i.useCount--,i.useCount===0&&(i.resource.destroy(),delete this._sharedRenderPipelineCache[t]))}_destroyPipeline(e){let t=this._getCache(e);return this.device.props._destroyPipelines?(delete t[e.hash],e.destroy(),e instanceof Ht&&this.releaseSharedRenderPipeline(e),!0):!1}_getCache(e){let t;if(e instanceof Wi&&(t=this._computePipelineCache),e instanceof Ht&&(t=this._renderPipelineCache),!t)throw new Error(`${this}`);if(!t[e.hash])throw new Error(`${this}: ${e} matched incorrect entry`);return t}_hashComputePipeline(e){let{type:t}=this.device,i=this._getHash(e.shader.source),r=this._getHash(JSON.stringify(e.shaderLayout));return`${t}/C/${i}SL${r}`}_hashRenderPipeline(e){let t=e.vs?this._getHash(e.vs.source):0,i=e.fs?this._getHash(e.fs.source):0,r=this._getWebGLVaryingHash(e),s=this._getHash(JSON.stringify(e.shaderLayout)),o=this._getHash(JSON.stringify(e._uniformBlockLayouts)),a=this._getHash(JSON.stringify(e.bufferLayout)),{type:c}=this.device;switch(c){case"webgl":let l=this._getHash(JSON.stringify(e.parameters));return`${c}/R/${t}/${i}V${r}T${e.topology}P${l}SL${s}UBL${o}BL${a}`;case"webgpu":default:let u=this._getHash(JSON.stringify({vertexEntryPoint:e.vertexEntryPoint,fragmentEntryPoint:e.fragmentEntryPoint})),f=this._getHash(JSON.stringify(e.parameters)),d=this._getWebGPUAttachmentHash(e);return`${c}/R/${t}/${i}V${r}T${e.topology}EP${u}P${f}SL${s}BL${a}A${d}`}}_hashSharedRenderPipeline(e){let t=e.vs?this._getHash(e.vs.source):0,i=e.fs?this._getHash(e.fs.source):0,r=this._getWebGLVaryingHash(e);return`webgl/S/${t}/${i}V${r}`}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}_getWebGLVaryingHash(e){let{varyings:t=[],bufferMode:i=null}=e;return this._getHash(JSON.stringify({varyings:t,bufferMode:i}))}_getWebGPUAttachmentHash(e){let t=e.colorAttachmentFormats??[this.device.preferredColorFormat],i=e.depthStencilAttachmentFormat??(e.parameters?.depthWriteEnabled?this.device.preferredDepthFormat:null);return this._getHash(JSON.stringify({colorAttachmentFormats:t,depthStencilAttachmentFormat:i}))}}});var Br,$0=C(()=>{Um();ut();Br=class n{static defaultProps={...kr.defaultProps};static getDefaultShaderFactory(e){let t=e.getModuleData("@luma.gl/core");return t.defaultShaderFactory||=new n(e),t.defaultShaderFactory}device;_cache={};get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}constructor(e){this.device=e}createShader(e){if(!this.device.props._cacheShaders)return this.device.createShader(e);let t=this._hashShader(e),i=this._cache[t];if(i)i.useCount++,this.device.props.debugFactories&&z.log(3,`${this}: Reusing shader ${i.resource.id} count=${i.useCount}`)();else{let r=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[t]=i={resource:r,useCount:1},this.device.props.debugFactories&&z.log(3,`${this}: Created new shader ${r.id}`)()}return i.resource}release(e){if(!this.device.props._cacheShaders){e.destroy();return}let t=this._hashShader(e),i=this._cache[t];if(i)if(i.useCount--,i.useCount===0)this.device.props._destroyShaders&&(delete this._cache[t],i.resource.destroy(),this.device.props.debugFactories&&z.log(3,`${this}: Releasing shader ${e.id}, destroyed`)());else{if(i.useCount<0)throw new Error(`ShaderFactory: Shader ${e.id} released too many times`);this.device.props.debugFactories&&z.log(3,`${this}: Releasing shader ${e.id} count=${i.useCount}`)()}}_hashShader(e){return`${e.stage}:${e.source}`}}});function Du(n,e,t){let i=n.bindings.find(r=>r.name===e||`${r.name.toLocaleLowerCase()}uniforms`===e.toLocaleLowerCase());return!i&&!t?.ignoreWarnings&&z.warn(`Binding ${e} not set: Not found in shader layout.`)(),i||null}function Or(n,e){if(!e)return{};if(HR(e))return Object.fromEntries(Object.entries(e).map(([r,s])=>[Number(r),{...s}]));let t={};for(let[i,r]of Object.entries(e)){let o=Du(n,i)?.group??0;t[o]||={},t[o][i]=r}return t}function js(n){let e={};for(let t of Object.values(n))Object.assign(e,t);return e}function HR(n){let e=Object.keys(n);return e.length>0&&e.every(t=>/^\d+$/.test(t))}var G0=C(()=>{ut()});var ka,V0=C(()=>{He();ka=class n extends te{static defaultClearColor=[0,0,0,1];static defaultClearDepth=1;static defaultClearStencil=0;get[Symbol.toStringTag](){return"RenderPass"}constructor(e,t,i=n.defaultProps){t=n.normalizeProps(e,t),super(e,t,i)}static normalizeProps(e,t){return t}static defaultProps={...te.defaultProps,framebuffer:null,resolveTargets:void 0,parameters:void 0,clearColor:n.defaultClearColor,clearColors:void 0,clearDepth:n.defaultClearDepth,clearStencil:n.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0}}});var Ra,W0=C(()=>{He();Ra=class n extends te{get[Symbol.toStringTag](){return"CommandEncoder"}_timeProfilingQuerySet=null;_timeProfilingSlotCount=0;_gpuTimeMs;constructor(e,t){super(e,t,n.defaultProps),this._timeProfilingQuerySet=t.timeProfilingQuerySet??null,this._timeProfilingSlotCount=0,this._gpuTimeMs=void 0}async resolveTimeProfilingQuerySet(){if(this._gpuTimeMs=void 0,!this._timeProfilingQuerySet)return;let e=Math.floor(this._timeProfilingSlotCount/2);if(e<=0)return;let t=e*2,i=await this._timeProfilingQuerySet.readResults({firstQuery:0,queryCount:t}),r=0n;for(let s=0;s=this._timeProfilingQuerySet.props.count?t:(this._timeProfilingSlotCount+=2,{...t,timestampQuerySet:this._timeProfilingQuerySet,beginTimestampIndex:i,endTimestampIndex:i+1})}_supportsTimestampQueries(){return this.device.features.has("timestamp-query")}static defaultProps={...te.defaultProps,measureExecutionTime:void 0,timeProfilingQuerySet:void 0}}});var Ia,j0=C(()=>{He();Ia=class n extends te{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,t){super(e,t,n.defaultProps)}static defaultProps={...te.defaultProps}}});var Ba,H0=C(()=>{He();Ba=class n extends te{static defaultProps={...te.defaultProps,shaderLayout:void 0,bufferLayout:[]};get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;indexBuffer=null;attributes;constructor(e,t){super(e,t,n.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null)}getBufferSlot(e){return null}getDrawValidationError(){return null}setConstantWebGL(e,t){this.device.reportError(new Error("constant attributes not supported"),this)()}}});var Oa,Y0=C(()=>{He();Oa=class n extends te{static defaultProps={...te.defaultProps,layout:void 0,buffers:{}};get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,n.defaultProps)}}});var Da,q0=C(()=>{He();Da=class n extends te{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){super(e,t,n.defaultProps)}static defaultProps={...te.defaultProps,type:void 0,count:void 0}}});var Na,Z0=C(()=>{He();Na=class n extends te{static defaultProps={...te.defaultProps};get[Symbol.toStringTag](){return"Fence"}constructor(e,t={}){super(e,t,n.defaultProps)}}});function Hs(n){let e=Nu(n),t=XR[e];if(!t)throw new Error(`Unsupported variable shader type: ${n}`);return t}function X0(n){let e=K0(n),t=ZR[e];if(!t)throw new Error(`Unsupported attribute shader type: ${n}`);let[i,r]=t,s=i==="i32"||i==="u32",o=i!=="u32",a=qR[i]*r;return{primitiveType:i,components:r,byteLength:a,integer:s,signed:o}}function YR(n,e){return e===1?n:`vec${e}<${n}>`}function K0(n){return KR[n]||n}function Nu(n){return QR[n]||n}var Vm,Mt,qR,ZR,XR,KR,QR,Fa=C(()=>{Vm=class{getVariableShaderTypeInfo(e){return Hs(e)}getAttributeShaderTypeInfo(e){return X0(e)}makeShaderAttributeType(e,t){return YR(e,t)}resolveAttributeShaderTypeAlias(e){return K0(e)}resolveVariableShaderTypeAlias(e){return Nu(e)}};Mt=new Vm,qR={f32:4,f16:2,i32:4,u32:4},ZR={f32:["f32",1],"vec2":["f32",2],"vec3":["f32",3],"vec4":["f32",4],f16:["f16",1],"vec2":["f16",2],"vec3":["f16",3],"vec4":["f16",4],i32:["i32",1],"vec2":["i32",2],"vec3":["i32",3],"vec4":["i32",4],u32:["u32",1],"vec2":["u32",2],"vec3":["u32",3],"vec4":["u32",4]},XR={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2":{type:"f32",components:2},"vec3":{type:"f32",components:3},"vec4":{type:"f32",components:4},"vec2":{type:"f16",components:2},"vec3":{type:"f16",components:3},"vec4":{type:"f16",components:4},"vec2":{type:"i32",components:2},"vec3":{type:"i32",components:3},"vec4":{type:"i32",components:4},"vec2":{type:"u32",components:2},"vec3":{type:"u32",components:3},"vec4":{type:"u32",components:4},"mat2x2":{type:"f32",components:4},"mat2x3":{type:"f32",components:6},"mat2x4":{type:"f32",components:8},"mat3x2":{type:"f32",components:6},"mat3x3":{type:"f32",components:9},"mat3x4":{type:"f32",components:12},"mat4x2":{type:"f32",components:8},"mat4x3":{type:"f32",components:12},"mat4x4":{type:"f32",components:16},"mat2x2":{type:"f16",components:4},"mat2x3":{type:"f16",components:6},"mat2x4":{type:"f16",components:8},"mat3x2":{type:"f16",components:6},"mat3x3":{type:"f16",components:9},"mat3x4":{type:"f16",components:12},"mat4x2":{type:"f16",components:8},"mat4x3":{type:"f16",components:12},"mat4x4":{type:"f16",components:16},"mat2x2":{type:"i32",components:4},"mat2x3":{type:"i32",components:6},"mat2x4":{type:"i32",components:8},"mat3x2":{type:"i32",components:6},"mat3x3":{type:"i32",components:9},"mat3x4":{type:"i32",components:12},"mat4x2":{type:"i32",components:8},"mat4x3":{type:"i32",components:12},"mat4x4":{type:"i32",components:16},"mat2x2":{type:"u32",components:4},"mat2x3":{type:"u32",components:6},"mat2x4":{type:"u32",components:8},"mat3x2":{type:"u32",components:6},"mat3x3":{type:"u32",components:9},"mat3x4":{type:"u32",components:12},"mat4x2":{type:"u32",components:8},"mat4x3":{type:"u32",components:12},"mat4x4":{type:"u32",components:16}},KR={vec2i:"vec2",vec3i:"vec3",vec4i:"vec4",vec2u:"vec2",vec3u:"vec3",vec4u:"vec4",vec2f:"vec2",vec3f:"vec3",vec4f:"vec4",vec2h:"vec2",vec3h:"vec3",vec4h:"vec4"},QR={vec2i:"vec2",vec3i:"vec3",vec4i:"vec4",vec2u:"vec2",vec3u:"vec3",vec4u:"vec4",vec2f:"vec2",vec3f:"vec3",vec4f:"vec4",vec2h:"vec2",vec3h:"vec3",vec4h:"vec4",mat2x2f:"mat2x2",mat2x3f:"mat2x3",mat2x4f:"mat2x4",mat3x2f:"mat3x2",mat3x3f:"mat3x3",mat3x4f:"mat3x4",mat4x2f:"mat4x2",mat4x3f:"mat4x3",mat4x4f:"mat4x4",mat2x2i:"mat2x2",mat2x3i:"mat2x3",mat2x4i:"mat2x4",mat3x2i:"mat3x2",mat3x3i:"mat3x3",mat3x4i:"mat3x4",mat4x2i:"mat4x2",mat4x3i:"mat4x3",mat4x4i:"mat4x4",mat2x2u:"mat2x2",mat2x3u:"mat2x3",mat2x4u:"mat2x4",mat3x2u:"mat3x2",mat3x3u:"mat3x3",mat3x4u:"mat3x4",mat4x2u:"mat4x2",mat4x3u:"mat4x3",mat4x4u:"mat4x4",mat2x2h:"mat2x2",mat2x3h:"mat2x3",mat2x4h:"mat2x4",mat3x2h:"mat3x2",mat3x3h:"mat3x3",mat3x4h:"mat3x4",mat4x2h:"mat4x2",mat4x3h:"mat4x3",mat4x4h:"mat4x4"}});function Dr(n,e={}){let t={...n},i=e.layout??"std140",r={},s=0;for(let[o,a]of Object.entries(t))s=Wm(r,o,a,s,i);return s=jt(s,ji(t,i)),{layout:i,byteLength:s*4,uniformTypes:t,fields:r}}function za(n,e){let t=Nu(n),i=Hs(t),r=/^mat(\d)x(\d)<.+>$/.exec(t);if(r){let o=Number(r[1]),a=Number(r[2]),c=Q0(a,t,i.type,e),l=eI(c.size,c.alignment,e);return{alignment:c.alignment,size:o*l,components:o*a,columns:o,rows:a,columnStride:l,shaderType:t,type:i.type}}let s=/^vec(\d)<.+>$/.exec(t);return s?Q0(Number(s[1]),t,i.type,e):{alignment:1,size:1,components:1,columns:1,rows:1,columnStride:1,shaderType:t,type:i.type}}function jm(n){return!!n&&typeof n=="object"&&!Array.isArray(n)}function Wm(n,e,t,i,r){if(typeof t=="string"){let s=za(t,r),o=jt(i,s.alignment);return n[e]={offset:o,...s},o+s.size}if(Array.isArray(t)){if(Array.isArray(t[0]))throw new Error(`Nested arrays are not supported for ${e}`);let s=t[0],o=t[1],a=ew(s,r),c=jt(i,ji(t,r));for(let l=0;l{Lu();Fa()});function Hm(n){return(!zu||zu.byteLength{});function nI(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Ys(n){return Array.isArray(n)?n.length===0||typeof n[0]=="number":nI(n)}var Zm=C(()=>{});function iI(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&!ArrayBuffer.isView(n)}function rI(n,e,t){return Array.prototype.slice.call(n,e,t)}var Uu,nw=C(()=>{qm();Zm();ut();Fu();Uu=class{layout;constructor(e){this.layout=e}has(e){return!!this.layout.fields[e]}get(e){let t=this.layout.fields[e];return t?{offset:t.offset,size:t.size}:void 0}getFlatUniformValues(e){let t={};for(let[i,r]of Object.entries(e)){let s=this.layout.uniformTypes[i];s?this._flattenCompositeValue(t,i,s,r):this.layout.fields[i]&&(t[i]=r)}return t}getData(e){let t=Hm(this.layout.byteLength);new Uint8Array(t,0,this.layout.byteLength).fill(0);let i={i32:new Int32Array(t),u32:new Uint32Array(t),f32:new Float32Array(t),f16:new Uint16Array(t)},r=this.getFlatUniformValues(e);for(let[s,o]of Object.entries(r))this._writeLeafValue(i,s,o);return new Uint8Array(t,0,this.layout.byteLength)}_flattenCompositeValue(e,t,i,r){if(r!==void 0){if(typeof i=="string"||this.layout.fields[t]){e[t]=r;return}if(Array.isArray(i)){let s=i[0],o=i[1];if(Array.isArray(s))throw new Error(`Nested arrays are not supported for ${t}`);if(typeof s=="string"&&Ys(r)){this._flattenPackedArray(e,t,s,o,r);return}if(!Array.isArray(r)){z.warn(`Unsupported uniform array value for ${t}:`,r)();return}for(let a=0;a=o.length)break;c===1?e[`${t}[${l}]`]=Number(o[u]):e[`${t}[${l}]`]=rI(s,u,u+c)}}_writeLeafValue(e,t,i){let r=this.layout.fields[t];if(!r){z.warn(`Uniform ${t} not found in layout`)();return}let{type:s,components:o,columns:a,rows:c,offset:l,columnStride:u}=r,f=e[s];if(o===1){f[l]=Number(i);return}let d=i;if(a===1){for(let p=0;ps)return!1;for(let o=0;o{Zm();sI=128});var $u,ow=C(()=>{sw();$u=class{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(e){if(this.name=e?.name||"unnamed",e?.name&&e?.shaderLayout){let t=e?.shaderLayout.bindings?.find(r=>r.type==="uniform"&&r.name===e?.name);if(!t)throw new Error(e?.name);let i=t;for(let r of i.uniforms||[])this.bindingLayout[r.name]=r}}setUniforms(e){for(let[t,i]of Object.entries(e))this._setUniform(t,i)&&!this.needsRedraw&&this.setNeedsRedraw(`${this.name}.${t}=${i}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){return iw(this.uniforms[e],t)?!1:(this.uniforms[e]=rw(t),this.modifiedUniforms[e]=!0,this.modified=!0,!0)}}});function aI(n){return n.type==="webgpu"?"wgsl-uniform":"std140"}var oI,Nr,aw=C(()=>{Cu();ut();Fu();ow();nw();oI=1024,Nr=class{device;uniformBlocks=new Map;shaderBlockLayouts=new Map;shaderBlockWriters=new Map;uniformBuffers=new Map;constructor(e,t){this.device=e;for(let[i,r]of Object.entries(t)){let s=i,o=Dr(r.uniformTypes??{},{layout:r.layout??aI(e)}),a=new Uu(o);this.shaderBlockLayouts.set(s,o),this.shaderBlockWriters.set(s,a);let c=new $u({name:i});c.setUniforms(a.getFlatUniformValues(r.defaultUniforms||{})),this.uniformBlocks.set(s,c)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e,t){for(let[i,r]of Object.entries(e)){let s=i,a=this.shaderBlockWriters.get(s)?.getFlatUniformValues(r||{});this.uniformBlocks.get(s)?.setUniforms(a||{})}this.updateUniformBuffers(t)}getUniformBufferByteLength(e){let t=this.shaderBlockLayouts.get(e)?.byteLength||0;return Math.max(t,oI)}getUniformBufferData(e){let t=this.uniformBlocks.get(e)?.getAllUniforms()||{};return this.shaderBlockWriters.get(e)?.getData(t)||new Uint8Array(0)}createUniformBuffer(e,t){t&&this.setUniforms(t);let i=this.getUniformBufferByteLength(e),r=this.device.createBuffer({usage:re.UNIFORM|re.COPY_DST,byteLength:i}),s=this.getUniformBufferData(e);return r.write(s),r}getManagedUniformBuffer(e){if(!this.uniformBuffers.get(e)){let t=this.getUniformBufferByteLength(e),i=this.device.createBuffer({usage:re.UNIFORM|re.COPY_DST,byteLength:t});this.uniformBuffers.set(e,i)}return this.uniformBuffers.get(e)}updateUniformBuffers(e){let t=!1;for(let i of this.uniformBlocks.keys()){let r=this.updateUniformBuffer(i,e);t||=r}return t&&z.log(3,`UniformStore.updateUniformBuffers(): ${t}`)(),t}updateUniformBuffer(e,t){let i=this.uniformBlocks.get(e),r=this.uniformBuffers.get(e),s=!1;if(r&&i?.needsRedraw){s||=i.needsRedraw;let o=this.getUniformBufferData(e);if(r=this.uniformBuffers.get(e),r&&(t?this.device.writeBufferViaCommandEncoder(t,r,o):r.write(o)),z.level>=4){let a=this.uniformBlocks.get(e)?.getAllUniforms();z.log(4,`Writing to uniform buffer ${String(e)}`,o,a)()}}return s}}});function qs(n){return n.attributes?n.attributes.map(e=>e.attribute):[n.name]}function Xm(n){return Object.fromEntries(n.attributes.map(e=>[e.name,e.location]))}function Gu(n){let e=1/0;for(let t of n)t!==void 0&&(e=Math.min(e,t));return e}function Km(n,e,t){cI(e);let i=new Map;for(let r of e){let s=lI(r);if(r.attributes)for(let o of r.attributes)i.has(o.attribute)||i.set(o.attribute,{bufferName:r.name,stepMode:r.stepMode,vertexFormat:o.format,byteOffset:o.byteOffset,byteStride:s});else r.format&&!i.has(r.name)&&i.set(r.name,{bufferName:r.name,stepMode:r.stepMode,vertexFormat:r.format,byteOffset:0,byteStride:s})}return n.attributes.map(r=>{let s=i.get(r.name);!s&&t?.warnOnMissingBufferLayout&&z.warn(`layout for attribute "${r.name}" not present in buffer layout`)();let o=Mt.getAttributeShaderTypeInfo(r.type),a=s?.vertexFormat||Ee.getCompatibleVertexFormat(o);return{attributeName:r.name,bufferName:s?.bufferName||r.name,location:r.location,vertexFormat:a,byteOffset:s?.byteOffset??0,byteStride:s?.byteStride??Ee.getVertexFormatInfo(a).byteLength,stepMode:s?.stepMode||r.stepMode||(r.name.startsWith("instance")?"instance":"vertex")}}).sort((r,s)=>r.location-s.location)}function cI(n){for(let e of n)(e.attributes&&e.format||!e.attributes&&!e.format)&&z.warn(`BufferLayout ${e.name} must have either 'attributes' or 'format' field`)()}function lI(n){if(typeof n.byteStride=="number")return n.byteStride;if(n.attributes){let e=0;for(let t of n.attributes)e+=Ee.getVertexFormatInfo(t.format).byteLength;return e}return Ee.getVertexFormatInfo(n.format).byteLength}var Qm=C(()=>{ut();Fa();Sa()});function Ua(n,e){let t={},i=Km(n,e,{warnOnMissingBufferLayout:!0});for(let r of i){let s=uI(n,r);t[r.attributeName]=s}return t}function uI(n,e){let t=fI(n,e.attributeName),i=Mt.getAttributeShaderTypeInfo(t.type),r=e.vertexFormat,s=Ee.getVertexFormatInfo(r);return{attributeName:e.attributeName,bufferName:e.bufferName,location:t.location,shaderType:t.type,primitiveType:i.primitiveType,shaderComponents:i.components,vertexFormat:r,bufferDataType:s.type,bufferComponents:s.components,normalized:s.normalized,integer:i.integer,stepMode:e.stepMode,byteOffset:e.byteOffset,byteStride:e.byteStride}}function fI(n,e){let t=n.attributes.find(i=>i.name===e);return t||z.warn(`shader layout attribute "${e}" not present in shader`)(),t||null}var cw=C(()=>{ut();Fa();Sa();Qm()});var ee=C(()=>{i0();r0();P0();k0();R0();Cu();Fm();I0();B0();Um();Nm();F0();$m();z0();U0();$0();V0();Gm();W0();j0();H0();Y0();q0();Z0();Fu();aw();Mu();Lu();Fa();Sa();Bu();ut();G0();Om();qm();cw();Qm()});function $a(n=[],e){let t=[],i={},r={},s={},o={};for(let a of n)lw({modules:t,defines:i,injections:r,vertexInputs:s,varyings:o},a),lw({modules:t,defines:i,injections:r,vertexInputs:s,varyings:o},a[e]);for(let a of Object.keys(o))if(s[a])throw new Error(`ShaderPlugin name "${a}" cannot be both a vertex input and a varying`);return{modules:t,defines:i,injections:r,vertexInputs:s,varyings:o}}function Ga(n=[],e=[]){let t=[...n],i=new Set(t.map(r=>r.name));for(let r of e)i.has(r.name)||(t.push(r),i.add(r.name));return t}function lw(n,e){if(e){e.modules?.length&&n.modules.push(...e.modules),e.defines&&Object.assign(n.defines,e.defines);for(let[t,i]of Object.entries(e.vertexInputs||{})){uw(t,"vertex input");let r=n.vertexInputs[t];if(r&&r!==i)throw new Error(`ShaderPlugin vertex input "${t}" has conflicting types "${r}" and "${i}"`);n.vertexInputs[t]=i}for(let[t,i]of Object.entries(e.varyings||{})){uw(t,"varying");let r=hI(t,i),s=n.varyings[t];if(s&&(s.type!==r.type||s.interpolation!==r.interpolation))throw new Error(`ShaderPlugin varying "${t}" has conflicting declarations "${s.type}/${s.interpolation}" and "${r.type}/${r.interpolation}"`);n.varyings[t]=r}for(let t of e.injections||[])pI(t.target),n.injections[t.target]||(n.injections[t.target]=[]),n.injections[t.target].push({injection:t.injection,order:t.order??0})}}function uw(n,e){if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(n)||n.startsWith("_luma_"))throw new Error(`ShaderPlugin ${e} "${n}" must be a valid non-reserved identifier`)}function hI(n,e){let{primitiveType:t}=Mt.getAttributeShaderTypeInfo(e.type),i=t==="i32"||t==="u32",r=e.interpolation||(i?"flat":"smooth");if(i&&r==="smooth")throw new Error(`ShaderPlugin integer varying "${n}" must use flat interpolation`);return{type:e.type,interpolation:r}}function pI(n){if(!dI.test(n))throw new Error(`ShaderPlugin injection target "${n}" must be a named shader anchor or hook`)}var dI,fw=C(()=>{ee();dI=/^(vs|fs):(?:#(?:decl|main-start|main-end)|[A-Za-z_][\w-]*)$/});function Va(n){return`${n.name}Uniforms`}function hw(n,e){let t=e==="wgsl"?n.source:e==="vertex"?n.vs:n.fs;if(!t)return null;let i=Va(n);return _I(t,e==="wgsl"?"wgsl":"glsl",i)}function pw(n,e){let t=Object.keys(n.uniformTypes||{});if(!t.length)return null;let i=hw(n,e);return i?{moduleName:n.name,uniformBlockName:Va(n),stage:e,expectedUniformNames:t,actualUniformNames:i,matches:vI(t,i)}:null}function Jm(n,e,t={}){let i=pw(n,e);if(!i||i.matches)return i;let r=xI(i);return t.log?.error?.(r,i)(),t.throwOnError!==!1&&hi(!1,r),i}function Wa(n){let e=[],t=wI(n);for(let i of t.matchAll(gI)){let r=i[1]?.trim()||null;e.push({blockName:i[2],body:i[3],instanceName:i[4]||null,layoutQualifier:r,hasLayoutQualifier:!!r,isStd140:!!(r&&/\blayout\s*\([^)]*\bstd140\b[^)]*\)/.exec(r))})}return e}function eg(n,e,t,i){let r=Wa(n).filter(o=>!o.isStd140),s=new Set;for(let o of r){if(s.has(o.blockName))continue;s.add(o.blockName);let a=i?.label?`${i.label} `:"",c=o.hasLayoutQualifier?`declares ${EI(o.layoutQualifier)} instead of layout(std140)`:"does not declare layout(std140)",l=`${a}${e} shader uniform block ${o.blockName} ${c}. luma.gl host-side shader block packing assumes explicit layout(std140) for GLSL uniform blocks. Add \`layout(std140)\` to the block declaration.`;t?.warn?.(l,o)()}return r}function _I(n,e,t){let i=e==="wgsl"?yI(n,t):bI(n,t);if(!i)return null;let r=[];for(let s of i.split(` +`)){let o=s.replace(/\/\/.*$/,"").trim();if(!o||o.startsWith("#"))continue;let a=e==="wgsl"?o.match(/^([A-Za-z0-9_]+)\s*:/):o.match(mI);a&&r.push(a[1])}return r}function yI(n,e){let t=new RegExp(`\\bstruct\\s+${e}\\b`,"m").exec(n);if(!t)return null;let i=n.indexOf("{",t.index);if(i<0)return null;let r=0;for(let s=i;si.blockName===e)?.body||null}function vI(n,e){if(n.length!==e.length)return!1;for(let t=0;t!t.includes(a)),r=t.filter(a=>!e.includes(a)),s=[`Expected ${e.length} fields, found ${t.length}.`],o=SI(e,t);return o&&s.push(o),i.length&&s.push(`Missing from shader block (${i.length}): ${dw(i)}.`),r.length&&s.push(`Unexpected in shader block (${r.length}): ${dw(r)}.`),e.length<=12&&t.length<=12&&(i.length||r.length)&&(s.push(`Expected: ${e.join(", ")}.`),s.push(`Actual: ${t.join(", ")}.`)),`${n.moduleName}: ${n.stage} shader uniform block ${n.uniformBlockName} does not match module.uniformTypes. ${s.join(" ")}`}function wI(n){return n.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"")}function EI(n){return n.replace(/\s+/g," ").trim()}function SI(n,e){let t=Math.min(n.length,e.length);for(let i=0;ie.length?`Shader block ends after field ${e.length}; expected next field ${n[e.length]}.`:e.length>n.length?`Shader block has extra field ${e.length}: ${e[n.length]}.`:null}function dw(n,e=8){if(n.length<=e)return n.join(", ");let t=n.length-e;return`${n.slice(0,e).join(", ")}, ... (${t} more)`}var mI,gI,tg=C(()=>{vu();mI=/^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/,gI=/((?:layout\s*\([^)]*\)\s*)*)uniform\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([\s\S]*?)\}\s*([A-Za-z_][A-Za-z0-9_]*)?\s*;/g});function mw(n){switch(n?.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU +// Apple optimizes away the calculation necessary for emulated fp64 +#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 +#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 +// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow +#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 +`;case"nvidia":return`#define NVIDIA_GPU +// Nvidia optimizes away the calculation necessary for emulated fp64 +#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 +`;case"intel":return`#define INTEL_GPU +// Intel optimizes away the calculation necessary for emulated fp64 +#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 +// Intel's built-in 'tan' function doesn't have acceptable precision +#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 +// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow +#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 +`;case"amd":return`#define AMD_GPU +`;default:return`#define DEFAULT_GPU +// Prevent driver from optimizing away the calculation necessary for emulated fp64 +#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 +// Headless Chrome's software shader 'tan' function doesn't have acceptable precision +#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 +// If the GPU doesn't have full 32 bits precision, will causes overflow +#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 +`}}var gw=C(()=>{});function yw(n,e){if(Number(n.match(/^#version[ \t]+(\d+)/m)?.[1]||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(e){case"vertex":return n=_w(n,PI),n;case"fragment":return n=_w(n,CI),n;default:throw new Error(e)}}function _w(n,e){for(let[t,i]of e)n=n.replace(t,i);return n}function ng(n){return new RegExp(`\\b${n}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}var bw,PI,CI,vw=C(()=>{bw=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es +`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],PI=[...bw,[ng("attribute"),"in $1"],[ng("varying"),"out $1"]],CI=[...bw,[ng("varying"),"in $1"]]});function Vu(n,e,t="glsl"){let i="";for(let r in n){let s=n[r];if(i+=`${t==="wgsl"?"fn":"void"} ${s.signature} { +`,s.header&&(i+=` ${s.header}`),e[r]){let a=e[r];a.sort((c,l)=>c.order-l.order);for(let c of a)i+=` ${c.injection} +`}s.footer&&(i+=` ${s.footer}`),i+=`} +`}return i}function ig(n){let e={vertex:{},fragment:{}};for(let t of n){let i,r;typeof t!="string"?(i=t,r=i.hook):(i={},r=t),r=r.trim();let s=r.indexOf(":"),o=r.slice(0,s),a=r.slice(s+1),c=r.replace(/\(.+/,""),l=Object.assign(i,{signature:a});switch(o){case"vs":e.vertex[c]=l;break;case"fs":e.fragment[c]=l;break;default:throw new Error(o)}}return e}var xw=C(()=>{});function ww(n,e){return{name:TI(n,e),language:"glsl",version:LI(n)}}function TI(n,e="unnamed"){let i=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(n);return i?i[1]:e}function LI(n){let e=100,t=n.match(/[^\s]+/g);if(t&&t.length>=2&&t[0]==="#version"){let i=parseInt(t[1],10);Number.isFinite(i)&&(e=i)}if(e!==100&&e!==300)throw new Error(`Invalid GLSL version ${e}`);return e}var Ew=C(()=>{});function Wu(n,e=[]){let t=$s(n),i=new Map;for(let s of e)i.set(Pw(s.name,s.group,s.location),s.moduleName);let r=[];for(let s of Sw){s.lastIndex=0;let o;for(o=s.exec(t);o;){let a=s===Sw[0],c=Number(o[a?1:2]),l=Number(o[a?2:1]),u=o[3]?.trim(),f=o[4],d=o[5].trim(),h=i.get(Pw(f,l,c));r.push(MI({name:f,group:l,binding:c,owner:h?"module":"application",moduleName:h,accessDeclaration:u,resourceType:d})),o=s.exec(t)}}return r.sort((s,o)=>s.group!==o.group?s.group-o.group:s.binding!==o.binding?s.binding-o.binding:s.name.localeCompare(o.name))}function MI(n){let e={name:n.name,group:n.group,binding:n.binding,owner:n.owner,kind:"unknown",moduleName:n.moduleName,resourceType:n.resourceType};if(n.accessDeclaration){let t=n.accessDeclaration.split(",").map(i=>i.trim());if(t[0]==="uniform")return{...e,kind:"uniform",access:"uniform"};if(t[0]==="storage"){let i=t[1]||"read_write";return{...e,kind:i==="read"?"read-only-storage":"storage",access:i}}}return n.resourceType==="sampler"||n.resourceType==="sampler_comparison"?{...e,kind:"sampler",samplerKind:n.resourceType==="sampler_comparison"?"comparison":"filtering"}:n.resourceType.startsWith("texture_storage_")?{...e,kind:"storage-texture",access:kI(n.resourceType),viewDimension:Cw(n.resourceType)}:n.resourceType.startsWith("texture_")?{...e,kind:"texture",viewDimension:Cw(n.resourceType),sampleType:AI(n.resourceType),multisampled:n.resourceType.startsWith("texture_multisampled_")}:e}function Pw(n,e,t){return`${e}:${t}:${n}`}function Cw(n){if(n.includes("cube_array"))return"cube-array";if(n.includes("2d_array"))return"2d-array";if(n.includes("cube"))return"cube";if(n.includes("3d"))return"3d";if(n.includes("2d"))return"2d";if(n.includes("1d"))return"1d"}function AI(n){if(n.startsWith("texture_depth_"))return"depth";if(n.includes(""))return"sint";if(n.includes(""))return"uint";if(n.includes(""))return"float"}function kI(n){return/,\s*([A-Za-z_][A-Za-z0-9_]*)\s*>$/.exec(n)?.[1]}var Sw,rg=C(()=>{gu();Sw=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${Lt}\\s*:\\s*([^;]+);`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(\\d+)\\s*\\)\\s*${Lt}\\s*:\\s*([^;]+);`,"g")]});function zr(n,e){let t=n.split(` +`),i=[],r=[],s=!0;for(let o of t){let a=o.match(RI),c=o.match(NI)||o.match(II),l=o.match(BI),u=o.match(OI),f=o.match(FI)||o.match(DI);if(a){let d=zI(a[1],e?.defines||{}),h=s&&d;r.push({parentActive:s,branchTaken:d,active:h}),s=h}else if(c||l){let d=(c||l)?.[1],h=!!e?.defines?.[d],p=c?h:!h,m=s&&p;r.push({parentActive:s,branchTaken:p,active:m}),s=m}else if(u){let d=r[r.length-1];if(!d)throw new Error("Encountered #else without matching #if, #ifdef or #ifndef");d.active=d.parentActive&&!d.branchTaken,d.branchTaken=!0,s=d.active}else f?(r.pop(),s=r.length?r[r.length-1].active:!0):s&&i.push(o)}if(r.length>0)throw new Error("Unterminated conditional block in shader source");return i.join(` +`)}function zI(n,e){let t=n.trim();if(/^[+-]?\d+(?:\.\d+)?$/.test(t))return Number(t)!==0;if(t==="true")return!0;if(t==="false")return!1;let i=t.match(new RegExp(`^!\\s*${Fr}$`));if(i)return!e[i[1]];let r=t.match(new RegExp(`^${Fr}$`));if(r)return!!e[r[1]];let s=t.match(new RegExp(`^defined\\s*\\(\\s*${Fr}\\s*\\)$`));if(s)return e[s[1]]!==void 0;let o=t.match(new RegExp(`^!\\s*defined\\s*\\(\\s*${Fr}\\s*\\)$`));if(o)return e[o[1]]===void 0;throw new Error(`Unsupported #if expression "${n}"`)}var Fr,RI,II,BI,OI,DI,NI,FI,sg=C(()=>{Fr="([a-zA-Z_][a-zA-Z0-9_]*)",RI=/^\s*\#\s*if\s+(.+?)\s*(?:\/\/.*)?$/,II=new RegExp(`^\\s*\\#\\s*ifdef\\s*${Fr}\\s*$`),BI=new RegExp(`^\\s*\\#\\s*ifndef\\s*${Fr}\\s*(?:\\/\\/.*)?$`),OI=/^\s*\#\s*else\s*(?:\/\/.*)?$/,DI=/^\s*\#\s*endif\s*$/,NI=new RegExp(`^\\s*\\#\\s*ifdef\\s*${Fr}\\s*(?:\\/\\/.*)?$`),FI=/^\s*\#\s*endif\s*(?:\/\/.*)?$/});function Mw(n,e){let t=[];for(let[i,r]of Object.entries(e))UI(n,i),t.push(`in ${ju(r)} ${i};`);return t.join(` +`)}function Aw(n,e,t){let i=Object.entries(t);if(i.length===0)return{source:n,declarations:"",initialization:""};let r=$I(n,e),s=n.slice(r.openParenthesis+1,r.closeParenthesis),o=GI(n,s),a=new Set(o.locations),c=[],l=[],u=[];for(let[m,g]of i){if(o.names.has(m)||jI(n,m))throw new Error(`ShaderPlugin vertex input "${m}" conflicts with an existing WGSL shader input or variable`);let v=HI(a);a.add(v);let y=`_luma_${m}`;c.push(`@location(${v}) ${y}: ${g}`),l.push(`var ${m}: ${g};`),u.push(`${m} = ${y};`)}let f=s.trim()?`, + `:` + `,d=s.trim()?"":` +`,h=`${s}${f}${c.join(`, + `)}${d}`;return{source:n.slice(0,r.openParenthesis+1)+h+n.slice(r.closeParenthesis),declarations:l.join(` +`),initialization:u.join(` +`)}}function ju(n){let{primitiveType:e,components:t}=Mt.getAttributeShaderTypeInfo(n),i=e==="i32"?"int":e==="u32"?"uint":"float";return t===1?i:`${i==="int"?"i":i==="uint"?"u":""}vec${t}`}function UI(n,e){let t=Hu(e);if(new RegExp(`\\b(?:in|attribute)\\s+(?:(?:lowp|mediump|highp)\\s+)?[A-Za-z_][A-Za-z0-9_]*\\s+${t}\\s*(?:\\[|;)`).test(n))throw new Error(`ShaderPlugin vertex input "${e}" conflicts with an existing GLSL input`)}function $I(n,e){let i=new RegExp(`\\bfn\\s+${Hu(e)}\\s*\\(`,"g").exec(n);if(!i)throw new Error(`ShaderPlugin vertex inputs require WGSL vertex entry point "${e}"`);let r=n.indexOf("(",i.index),s=kw(n,r,"(",")");if(s<0)throw new Error(`Unable to parse WGSL vertex entry point "${e}" parameters`);return{openParenthesis:r,closeParenthesis:s}}function GI(n,e){let t=Tw(e),i=new Set(Lw(e)),r=VI(e);for(let s of r){let o=WI(n,s);if(o!==null){t.push(...Tw(o));for(let a of Lw(o))i.add(a)}}return{locations:t,names:i}}function Tw(n){let e=[],t=/@location\s*\(\s*(\d+)\s*\)/g,i=t.exec(n);for(;i;)e.push(Number(i[1])),i=t.exec(n);return e}function Lw(n){let e=[],t=/(?:^|,)\s*(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:/gm,i=t.exec(n);for(;i;)e.push(i[1]),i=t.exec(n);return e}function VI(n){let e=[],t=/:\s*([A-Za-z_][\w]*)\b/g,i=t.exec(n);for(;i;)e.push(i[1]),i=t.exec(n);return e}function WI(n,e){let i=new RegExp(`\\bstruct\\s+${Hu(e)}\\s*\\{`,"g").exec(n);if(!i)return null;let r=n.indexOf("{",i.index),s=kw(n,r,"{","}");return s<0?null:n.slice(r+1,s)}function jI(n,e){let t=Hu(e),i=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${t}\\b`,"g"),r=i.exec(n);for(;r;){if(YI(n,r.index)===0)return!0;r=i.exec(n)}return!1}function HI(n){let e=0;for(;n.has(e);)e++;return e}function kw(n,e,t,i){let r=0,s=0,o=!1;for(let a=e;a0){c==="/"&&l==="*"?(s++,a++):c==="*"&&l==="/"&&(s--,a++);continue}if(c==="/"&&l==="/"){o=!0,a++;continue}if(c==="/"&&l==="*"){s=1,a++;continue}if(c===t&&r++,c===i&&--r===0)return a}return-1}function YI(n,e){let t=0,i=0,r=!1;for(let s=0;s0){o==="/"&&a==="*"?(i++,s++):o==="*"&&a==="/"&&(i--,s++);continue}o==="/"&&a==="/"?(r=!0,s++):o==="/"&&a==="*"?(i=1,s++):o==="{"?t++:o==="}"&&t--}return t}function Hu(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var og=C(()=>{ee()});function Iw(n,e,t){let i=[],r=[];for(let[s,o]of Object.entries(t)){oB(n,s);let a=o.interpolation==="flat"?"flat ":"",c=e==="vertex"?"out":"in";i.push(`${a}${c} ${ju(o.type)} ${s};`),e==="vertex"&&r.push(`${s} = ${rB(o.type)};`)}return{declarations:i.join(` +`),initialization:r.join(` +`)}}function Bw(n,e,t,i){let r=Object.entries(i);if(r.length===0)return{source:n,declarations:"",vertexInitialization:"",fragmentInitialization:""};let s=n,o=Yu(s,e,"vertex"),a=qI(s,o),c=Yu(s,t,"fragment"),l=ZI(s,c),u=ag(s,a),f=ag(s,l.type),d=new Set([...qu(o.parameters),...qu(u.body),...qu(c.parameters),...qu(f.body)]),h=new Set([...Rw(u.body),...Rw(f.body)]),p=[],m=[],g=[],v=[];for(let[E,x]of r){if(d.has(E)||nB(s,E))throw new Error(`ShaderPlugin varying "${E}" conflicts with existing WGSL stage I/O or a module variable`);let T=iB(h);h.add(T);let I=x.interpolation==="flat"?" @interpolate(flat)":"";p.push(` @location(${T})${I} ${E}: ${x.type},`),m.push(`var ${E}: ${x.type};`),g.push(`${E} = ${sB(x.type)};`),v.push(`${E} = ${l.name}.${E};`)}XI(s,a,o.openBrace,o.closeBrace),s=KI(s,a,o,r.map(([E])=>E)),o=Yu(s,e,"vertex"),s=QI(s,o,r.map(([E])=>E));let b=(a===l.type?[a]:[a,l.type]).map(E=>ag(s,E).closeBrace).sort((E,x)=>x-E);for(let E of b)s=s.slice(0,E)+`${p.join(` +`)} +`+s.slice(E);if(c=Yu(s,t,"fragment"),!new RegExp(`\\b${Ur(l.name)}\\s*:`).test(c.parameters))throw new Error(`Unable to preserve WGSL fragment input "${l.name}"`);return{source:s,declarations:m.join(` +`),vertexInitialization:g.join(` +`),fragmentInitialization:v.join(` +`)}}function Yu(n,e,t){let r=new RegExp(`\\bfn\\s+${Ur(e)}\\s*\\(`,"g").exec(n);if(!r)throw new Error(`ShaderPlugin varyings require WGSL ${t} entry point "${e}"`);let s=n.indexOf("(",r.index),o=Zu(n,s,"(",")"),a=n.indexOf("{",o),c=Zu(n,a,"{","}");if(o<0||a<0||c<0)throw new Error(`Unable to parse WGSL ${t} entry point "${e}"`);return{openParenthesis:s,closeParenthesis:o,openBrace:a,closeBrace:c,parameters:n.slice(s+1,o)}}function qI(n,e){let t=n.slice(e.closeParenthesis+1,e.openBrace),i=/->\s*([A-Za-z_][\w]*)\s*$/.exec(t.trim());if(!i||cg(n,i[1])===null)throw new Error("ShaderPlugin varyings require the WGSL vertex entry point to return a named struct");return i[1]}function ZI(n,e){let t=[];for(let i of tB(e.parameters,",")){let r=/(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:\s*([A-Za-z_][\w]*)\s*$/.exec(i.trim());r&&cg(n,r[2])&&t.push({name:r[1],type:r[2]})}if(t.length!==1)throw new Error(`ShaderPlugin varyings require exactly one named WGSL fragment input struct; found ${t.length}`);return t[0]}function ag(n,e){let t=cg(n,e);if(!t)throw new Error(`Unable to find WGSL stage I/O struct "${e}"`);return t}function cg(n,e){let i=new RegExp(`\\bstruct\\s+${Ur(e)}\\s*\\{`,"g").exec(n);if(!i)return null;let r=n.indexOf("{",i.index),s=Zu(n,r,"{","}");return s<0?null:{openBrace:r,closeBrace:s,body:n.slice(r+1,s)}}function XI(n,e,t,i){let r=new RegExp(`\\b${Ur(e)}\\s*\\(`,"g"),s=r.exec(n);for(;s;){if(s.indexi)throw new Error(`ShaderPlugin varying output struct "${e}" is constructed outside the selected vertex entry point`);s=r.exec(n)}}function KI(n,e,t,i){let r=new RegExp(`\\b${Ur(e)}\\s*\\(`,"g"),s=[],o=r.exec(n);for(;o;){if(o.index>t.openBrace&&o.indext.closeBrace)throw new Error(`Unable to parse WGSL output constructor "${e}"`);s.push({openParenthesis:a,closeParenthesis:c})}o=r.exec(n)}for(let a of s.sort((c,l)=>l.closeParenthesis-c.closeParenthesis)){let l=n.slice(a.openParenthesis+1,a.closeParenthesis).trim()?", ":"";n=n.slice(0,a.closeParenthesis)+l+i.join(", ")+n.slice(a.closeParenthesis)}return n}function QI(n,e,t){let i=JI(n,e.openBrace+1,e.closeBrace);for(let r=i.length-1;r>=0;r--){let s=i[r],o=n.slice(s.expressionStart,s.semicolon).trim();if(!o)throw new Error("ShaderPlugin varying vertex entry point cannot use an empty return");let a=`_luma_vertexOutput${r}`,c=t.map(u=>`${a}.${u} = ${u};`).join(` +`),l=`{ +var ${a} = ${o}; +${c} +return ${a}; +}`;n=n.slice(0,s.start)+l+n.slice(s.semicolon+1)}return n}function JI(n,e,t){let i=[],r=e;for(;rt?t:r+1}if(n[i]==="/"&&n[i+1]==="*"){let r=1;for(i+=2;i0;)n[i]==="/"&&n[i+1]==="*"?(r++,i+=2):n[i]==="*"&&n[i+1]==="/"?(r--,i+=2):i++}return i}function tB(n,e){let t=[],i=0,r=0,s=0;for(let o=0;o"&&s--,a===e&&r===0&&s===0&&(t.push(n.slice(i,o)),i=o+1)}return t.push(n.slice(i)),t}function Rw(n){let e=[],t=/@location\s*\(\s*(\d+)\s*\)/g,i=t.exec(n);for(;i;)e.push(Number(i[1])),i=t.exec(n);return e}function qu(n){let e=[],t=/(?:^|,)\s*(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:/gm,i=t.exec(n);for(;i;)e.push(i[1]),i=t.exec(n);return e}function nB(n,e){let t=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${Ur(e)}\\b`,"g"),i=t.exec(n);for(;i;){if(aB(n,i.index)===0)return!0;i=t.exec(n)}return!1}function iB(n){let e=0;for(;n.has(e);)e++;return e}function rB(n){let{primitiveType:e,components:t}=Mt.getAttributeShaderTypeInfo(n),i=e==="u32"?"0u":e==="i32"?"0":"0.0";return t===1?i:`${ju(n)}(${i})`}function sB(n){let{primitiveType:e,components:t}=Mt.getAttributeShaderTypeInfo(n),i=`${e}(0)`;return t===1?i:`${n}(${i})`}function oB(n,e){if(new RegExp(`\\b(?:flat\\s+|smooth\\s+)?(?:in|out|varying)\\s+(?:(?:lowp|mediump|highp)\\s+)?[A-Za-z_][A-Za-z0-9_]*\\s+${Ur(e)}\\s*(?:\\[|;)`).test(n))throw new Error(`ShaderPlugin varying "${e}" conflicts with existing GLSL stage I/O`)}function Zu(n,e,t,i){let r=0,s=0,o=!1;for(let a=e;a0){c==="/"&&l==="*"?(s++,a++):c==="*"&&l==="/"&&(s--,a++);continue}if(c==="/"&&l==="/"){o=!0,a++;continue}if(c==="/"&&l==="*"){s=1,a++;continue}if(c===t&&r++,c===i&&--r===0)return a}return-1}function aB(n,e){let t=0;for(let i=0;i{ee();og()});function Fw(n){let e=Cr(n.modules||[]),{source:t,bindingAssignments:i}=lB(n.platformInfo,{...n,source:n.source,stage:"vertex",modules:e});return{source:t,getUniforms:Uw(e),bindingAssignments:i,bindingTable:Wu(t,i),shaderLayout:yu(t,{vertexEntryPoint:n.vertexEntryPoint,scanVertexAttributes:n.scanVertexAttributes})}}function zw(n){let{vs:e,fs:t}=n,i=Cr(n.modules||[]);return{vs:Dw(n.platformInfo,{...n,source:e,stage:"vertex",modules:i}),fs:Dw(n.platformInfo,{...n,source:t,stage:"fragment",modules:i}),getUniforms:Uw(i)}}function lB(n,e){let{source:t,stage:i,modules:r,defines:s={},hookFunctions:o=[],inject:a={},pluginInjections:c={},pluginVertexInputs:l={},pluginVaryings:u={},vertexEntryPoint:f="vertexMain",fragmentEntryPoint:d="fragmentMain",log:h}=e;hi(typeof t=="string","shader source must be a string");let p=zr(t,{defines:s}),m=Aw(p,f,l),g=Bw(m.source,f,d,u),v=g.source,y="",b=ig(o),w={},E={},x={};$w(c,w,E,x);for(let W in a){let V=typeof a[W]=="string"?{injection:a[W],order:0}:a[W],X=/^(v|f)s:(#)?([\w-]+)$/.exec(W);if(X){let Y=X[2],ie=X[3];Y?ie==="decl"?E[W]=[V]:x[W]=[V]:w[W]=[V]}else x[W]=[V]}uB(m.declarations,m.initialization,E,x),fB(g,E,x);let T=r,I=_B(v),N=gB(I.source),D=xB(T,e._bindingRegistry,N,s),H=[];for(let W of T){h&&mm(W,v,h);let V=zr(Gw(W,"wgsl",h),{defines:s}),X=yB(V,W,{usedBindingsByGroup:N,bindingRegistry:e._bindingRegistry,reservedBindingKeysByGroup:D});H.push(...X.bindingAssignments);let Y=X.source;y+=Y;let ie=dB(W);for(let oe in ie){let zt=/^(v|f)s:#([\w-]+)$/.exec(oe);if(zt){let sn=zt[2]==="decl"?E:x;sn[oe]=sn[oe]||[],sn[oe].push(ie[oe])}else w[oe]=w[oe]||[],w[oe].push(ie[oe])}}return y+=ug,y=xa(y,i,hB(E),!1,"wgsl",{vertex:f,fragment:d}),y+=pB(b,w),y+=TB(H),y+=I.source,y=xa(y,i,x,!1,"wgsl",{vertex:f,fragment:d}),CB(y),{source:y,bindingAssignments:H}}function Dw(n,e){let{source:t,stage:i,language:r="glsl",modules:s,defines:o={},hookFunctions:a=[],inject:c={},pluginInjections:l={},pluginVertexInputs:u={},pluginVaryings:f={},prologue:d=!0,log:h}=e;hi(typeof t=="string","shader source must be a string");let p=r==="glsl"?ww(t).version:-1,m=n.shaderLanguageVersion,g=p===100?"#version 100":"#version 300 es",y=t.split(` +`).slice(1).join(` +`),b={};s.forEach(D=>{Object.assign(b,D.defines)}),Object.assign(b,o);let w="";switch(r){case"wgsl":break;case"glsl":w=d?`${g} + +// ----- PROLOGUE ------------------------- +${`#define SHADER_TYPE_${i.toUpperCase()}`} + +${mw(n)} +${i==="fragment"?cB:""} + +// ----- APPLICATION DEFINES ------------------------- + +${mB(b)} + +`:`${g} +`;break}let E=ig(a),x={},T={},I={};$w(l,x,T,I);for(let D in c){let H=typeof c[D]=="string"?{injection:c[D],order:0}:c[D],W=/^(v|f)s:(#)?([\w-]+)$/.exec(D);if(W){let V=W[2],X=W[3];V?X==="decl"?T[D]=[H]:I[D]=[H]:x[D]=[H]}else I[D]=[H]}if(i==="vertex"){let D=Mw(y,u);D&&(T["vs:#decl"]=T["vs:#decl"]||[],T["vs:#decl"].push({injection:D,order:Number.MIN_SAFE_INTEGER}))}let N=Iw(y,i,f);if(N.declarations){let D=i==="vertex"?"vs:#decl":"fs:#decl";T[D]=T[D]||[],T[D].push({injection:N.declarations,order:Number.MIN_SAFE_INTEGER})}N.initialization&&(I["vs:#main-start"]=I["vs:#main-start"]||[],I["vs:#main-start"].push({injection:N.initialization,order:Number.MIN_SAFE_INTEGER}));for(let D of s){h&&mm(D,y,h);let H=Gw(D,i,h);w+=H;let W=D.instance?.normalizedInjections[i]||{};for(let V in W){let X=/^(v|f)s:#([\w-]+)$/.exec(V);if(X){let ie=X[2]==="decl"?T:I;ie[V]=ie[V]||[],ie[V].push(W[V])}else x[V]=x[V]||[],x[V].push(W[V])}}return w+="// ----- MAIN SHADER SOURCE -------------------------",w+=ug,w=xa(w,i,T),w+=Vu(E[i],x),w+=y,w=xa(w,i,I),r==="glsl"&&p!==m&&(w=yw(w,i)),r==="glsl"&&eg(w,i,h),w.trim()}function Uw(n){return function(t){let i={};for(let r of n){let s=r.getUniforms?.(t,i);Object.assign(i,s)}return i}}function $w(n,e,t,i){for(let r in n){let s=/^(v|f)s:(#)?([\w-]+)$/.exec(r);if(s){let o=s[2],a=s[3],c=o?a==="decl"?t:i:e;c[r]=c[r]||[],c[r].push(...n[r])}else i[r]=i[r]||[],i[r].push(...n[r])}}function uB(n,e,t,i){n&&(t["vs:#decl"]=t["vs:#decl"]||[],t["vs:#decl"].push({injection:n,order:Number.MIN_SAFE_INTEGER})),e&&(i["vs:#main-start"]=i["vs:#main-start"]||[],i["vs:#main-start"].push({injection:e,order:Number.MIN_SAFE_INTEGER}))}function fB(n,e,t){n.declarations&&(e["vs:#decl"]=e["vs:#decl"]||[],e["vs:#decl"].push({injection:n.declarations,order:Number.MIN_SAFE_INTEGER})),n.vertexInitialization&&(t["vs:#main-start"]=t["vs:#main-start"]||[],t["vs:#main-start"].push({injection:n.vertexInitialization,order:Number.MIN_SAFE_INTEGER})),n.fragmentInitialization&&(t["fs:#main-start"]=t["fs:#main-start"]||[],t["fs:#main-start"].push({injection:n.fragmentInitialization,order:Number.MIN_SAFE_INTEGER}))}function dB(n){return{...n.instance?.normalizedInjections.vertex||{},...n.instance?.normalizedInjections.fragment||{}}}function hB(n){let e=[...n["vs:#decl"]||[],...n["fs:#decl"]||[]];return e.length?{"vs:#decl":e}:{}}function pB(n,e){return Vu(n.vertex,e,"wgsl")+Vu(n.fragment,e,"wgsl")}function mB(n={}){let e="";for(let t in n){let i=n[t];(i||Number.isFinite(i))&&(e+=`#define ${t.toUpperCase()} ${n[t]} +`)}return e}function Gw(n,e,t){let i;switch(e){case"vertex":i=n.vs||"";break;case"fragment":i=n.fs||"";break;case"wgsl":i=n.source||"";break;default:hi(!1)}if(!n.name)throw new Error("Shader module must have a name");Jm(n,e,{log:t});let r=n.name.toUpperCase().replace(/[^0-9a-z]/gi,"_"),s=`// ----- MODULE ${n.name} --------------- + +`;return e!=="wgsl"&&(s+=`#define MODULE_${r} +`),s+=`${i} +`,s}function gB(n){let e=new Map;for(let t of Pr(n,Nx)){let i=Number(t.bindingToken),r=Number(t.groupToken);fg(r,i,t.name),Zs(e,r,i,`application binding "${t.name}"`)}return e}function _B(n){let e=Pr(n,mu),t=new Map;for(let s of e){if(s.bindingToken==="auto")continue;let o=Number(s.bindingToken),a=Number(s.groupToken);fg(a,o,s.name),Zs(t,a,o,`application binding "${s.name}"`)}let i={sawSupportedBindingDeclaration:e.length>0},r=sm(n,mu,s=>vB(s,t,i));if(om(n)&&!i.sawSupportedBindingDeclaration)throw new Error('Unsupported @binding(auto) declaration form in application WGSL. Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.');return{source:r}}function yB(n,e,t){let i=[],s={sawSupportedBindingDeclaration:Pr(n,Us).length>0,nextHintedBindingLocation:typeof e.firstBindingSlot=="number"?e.firstBindingSlot:null},o=sm(n,Us,a=>bB(a,{module:e,context:t,bindingAssignments:i,relocationState:s}));if(om(n)&&!s.sawSupportedBindingDeclaration)throw new Error(`Unsupported @binding(auto) declaration form in module "${e.name}". Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.`);return{source:o,bindingAssignments:i}}function bB(n,e){let{module:t,context:i,bindingAssignments:r,relocationState:s}=e,{match:o,bindingToken:a,groupToken:c,name:l}=n,u=Number(c);if(a==="auto"){let d=Vw(u,t.name,l),h=i.bindingRegistry?.get(d),p=h!==void 0?h:SB(u,i.usedBindingsByGroup,t.name,s.nextHintedBindingLocation??void 0,i.bindingRegistry);return Nw(t.name,u,p,l),h!==void 0&&wB(i.reservedBindingKeysByGroup,u,p,d)?(r.push({moduleName:t.name,name:l,group:u,location:p}),o.replace(/@binding\(\s*auto\s*\)/,`@binding(${p})`)):(Zs(i.usedBindingsByGroup,u,p,`module "${t.name}" binding "${l}"`),i.bindingRegistry?.set(d,p),r.push({moduleName:t.name,name:l,group:u,location:p}),s.nextHintedBindingLocation!==null&&h===void 0&&(s.nextHintedBindingLocation=p+1),o.replace(/@binding\(\s*auto\s*\)/,`@binding(${p})`))}let f=Number(a);return Nw(t.name,u,f,l),Zs(i.usedBindingsByGroup,u,f,`module "${t.name}" binding "${l}"`),r.push({moduleName:t.name,name:l,group:u,location:f}),o}function vB(n,e,t){let{match:i,bindingToken:r,groupToken:s,name:o}=n,a=Number(s);if(r==="auto"){let c=PB(a,e);return fg(a,c,o),Zs(e,a,c,`application binding "${o}"`),i.replace(/@binding\(\s*auto\s*\)/,`@binding(${c})`)}return t.sawSupportedBindingDeclaration=!0,i}function xB(n,e,t,i){let r=new Map;if(!e)return r;for(let s of n)for(let o of EB(s,i)){let a=Vw(o.group,s.name,o.name),c=e.get(a);if(c!==void 0){let l=r.get(o.group)||new Map,u=l.get(c);if(u&&u!==a)throw new Error(`Duplicate WGSL binding reservation for modules "${u}" and "${a}": group ${o.group}, binding ${c}.`);Zs(t,o.group,c,`registered module binding "${a}"`),l.set(c,a),r.set(o.group,l)}}return r}function wB(n,e,t,i){let r=n.get(e);if(!r)return!1;let s=r.get(t);if(!s)return!1;if(s!==i)throw new Error(`Registered module binding "${i}" collided with "${s}": group ${e}, binding ${t}.`);return!0}function EB(n,e){let t=[],i=zr(n.source||"",{defines:e});for(let r of Pr(i,Us))t.push({name:r.name,group:Number(r.groupToken)});return t}function fg(n,e,t){if(n===0&&e>=ja)throw new Error(`Application binding "${t}" in group 0 uses reserved binding ${e}. Application-owned explicit group-0 bindings must stay below ${ja}.`)}function Nw(n,e,t,i){if(e===0&&t0?Math.max(...s)+1:0);for(;s.has(l)||o.has(l);)l++;for(let[u,f]of r||[])f===l&&u.startsWith(a)&&r?.delete(u);return l}function PB(n,e){let t=e.get(n)||new Set,i=0;for(;t.has(i);)i++;return i}function CB(n){let e=Fx(n,Us);if(!e)return;let t=LB(n,e.index);throw t?new Error(`Unresolved @binding(auto) for module "${t}" binding "${e.name}" remained in assembled WGSL source.`):MB(n,e.index)?new Error(`Unresolved @binding(auto) for application binding "${e.name}" remained in assembled WGSL source.`):new Error(`Unresolved @binding(auto) remained in assembled WGSL source near "${AB(e.match)}".`)}function TB(n){if(n.length===0)return"";let e=`// ----- MODULE WGSL BINDING ASSIGNMENTS --------------- +`;for(let t of n)e+=`// ${t.moduleName}.${t.name} -> @group(${t.group}) @binding(${t.location}) +`;return e+=` +`,e}function Vw(n,e,t){return`${n}:${e}:${t}`}function LB(n,e){let t=/^\/\/ ----- MODULE ([^\n]+) ---------------$/gm,i,r;for(r=t.exec(n);r&&r.index<=e;)i=r[1],r=t.exec(n);return i}function MB(n,e){let t=n.indexOf(ug);return t>=0?e>t:!0}function AB(n){return n.replace(/\s+/g," ").trim()}var ug,ja,cB,Ww=C(()=>{gm();gw();pm();vw();wu();tg();xw();vu();Ew();rg();fm();sg();og();Ow();gu();ug=` + +${va} +`,ja=100,cB=`precision highp float; +`});var Yt,Xs,Hi,jw=C(()=>{wu();Ww();rg();sg();fm();vu();Yt=class n{static defaultShaderAssemblers={};_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(e){return hi(e==="glsl"||e==="wgsl"),e==="wgsl"?(n.defaultShaderAssemblers.wgsl=n.defaultShaderAssemblers.wgsl||new Hi,n.defaultShaderAssemblers.wgsl):(n.defaultShaderAssemblers.glsl=n.defaultShaderAssemblers.glsl||new Xs,n.defaultShaderAssemblers.glsl)}addDefaultModule(e){this._defaultModules.find(t=>t.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){let t=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(i=>i.name!==t)}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e)}_getModuleList(e=[]){let t=new Array(this._defaultModules.length+e.length),i={},r=0;for(let s=0,o=this._defaultModules.length;s(Object.assign(i,r.defines),i),{}),...e.defines}}static getPlatformPreprocessorDefines(e){let t=e.limits||{};return{LUMA_SUPPORTS_VERTEX_STORAGE_BUFFERS:e.type==="webgpu"&&(t.maxStorageBuffersInVertexStage||0)>0,LUMA_FP32_TAN_PRECISION_WORKAROUND:e.type==="webgpu"&&e.gpu.toLowerCase()!=="nvidia"&&e.gpu.toLowerCase()!=="amd",LUMA_FP64_INTEGER_ARITHMETIC:e.type==="webgpu"&&e.gpu.toLowerCase()==="apple"}}}});function dg(n){let{input:e,inputChannels:t,output:i}=n||{};if(!e)return RB;if(!t)throw new Error("inputChannels");let r=IB(t),s=Hw(e,t);return`#version 300 es +in ${r} ${e}; +out vec4 ${i}; +void main() { + ${i} = ${s}; +}`}function IB(n){switch(n){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${n}`)}}function Hw(n,e){switch(e){case 1:return`vec4(${n}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${n}, 0.0, 1.0)`;case 3:return`vec4(${n}, 1.0)`;case 4:return n;default:throw new Error(`invalid channels: ${e}`)}}var kB,RB,Yw=C(()=>{kB=`out vec4 transform_output; +void main() { + transform_output = vec4(0); +}`,RB=`#version 300 es +${kB}`});function hg(n,{precision:e=Ye.precision}={}){return n=OB(n),`${parseFloat(n.toPrecision(e))}`}function mi(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Se(n,e,t){return NB(n,i=>Math.max(e,Math.min(t,i)))}function cn(n,e,t){return mi(n)?n.map((i,r)=>cn(i,e[r],t)):t*e+(1-t)*n}function Nn(n,e,t){let i=Ye.EPSILON;t&&(Ye.EPSILON=t);try{if(n===e)return!0;if(mi(n)&&mi(e)){if(n.length!==e.length)return!1;for(let r=0;r{HX=1/Math.PI*180,YX=1/180*Math.PI,BB={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...BB}};Ye=globalThis.mathgl.config});var Qs,pg=C(()=>{Ks();Qs=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,t=0){for(let i=0;i0?", ":"")+hg(this[i],e);return`${e.printTypes?this.constructor.name:""}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t{Ks()});function mg(n,e){if(!n)throw new Error(`math.gl assertion ${e}`)}var qw=C(()=>{});var Ku,Zw=C(()=>{pg();Ha();qw();Ku=class extends Qs{get x(){return this[0]}set x(e){this[0]=et(e)}get y(){return this[1]}set y(e){this[1]=et(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let t=0;t=0&&e=0&&e=0?Math.round(n):n%.5===0?Math.floor(n):Math.round(n)}var ve,Fn,rK,$r=C(()=>{ve=typeof Float32Array<"u"?Float32Array:Array,Fn=Math.random;rK=Math.PI/180});var dt={};ui(dt,{add:()=>VB,angle:()=>cO,ceil:()=>WB,clone:()=>zB,copy:()=>$B,create:()=>Xw,cross:()=>tO,dist:()=>_O,distance:()=>eE,div:()=>gO,divide:()=>Jw,dot:()=>eO,equals:()=>dO,exactEquals:()=>fO,floor:()=>jB,forEach:()=>vO,fromValues:()=>UB,inverse:()=>QB,len:()=>hO,length:()=>nE,lerp:()=>nO,max:()=>YB,min:()=>HB,mul:()=>mO,multiply:()=>Qw,negate:()=>KB,normalize:()=>JB,random:()=>iO,rotate:()=>aO,round:()=>qB,scale:()=>ZB,scaleAndAdd:()=>XB,set:()=>GB,sqrDist:()=>yO,sqrLen:()=>bO,squaredDistance:()=>tE,squaredLength:()=>iE,str:()=>uO,sub:()=>pO,subtract:()=>Kw,transformMat2:()=>rO,transformMat2d:()=>sO,transformMat3:()=>oO,transformMat4:()=>gg,zero:()=>lO});function Xw(){let n=new ve(2);return ve!=Float32Array&&(n[0]=0,n[1]=0),n}function zB(n){let e=new ve(2);return e[0]=n[0],e[1]=n[1],e}function UB(n,e){let t=new ve(2);return t[0]=n,t[1]=e,t}function $B(n,e){return n[0]=e[0],n[1]=e[1],n}function GB(n,e,t){return n[0]=e,n[1]=t,n}function VB(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n}function Kw(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n}function Qw(n,e,t){return n[0]=e[0]*t[0],n[1]=e[1]*t[1],n}function Jw(n,e,t){return n[0]=e[0]/t[0],n[1]=e[1]/t[1],n}function WB(n,e){return n[0]=Math.ceil(e[0]),n[1]=Math.ceil(e[1]),n}function jB(n,e){return n[0]=Math.floor(e[0]),n[1]=Math.floor(e[1]),n}function HB(n,e,t){return n[0]=Math.min(e[0],t[0]),n[1]=Math.min(e[1],t[1]),n}function YB(n,e,t){return n[0]=Math.max(e[0],t[0]),n[1]=Math.max(e[1],t[1]),n}function qB(n,e){return n[0]=qt(e[0]),n[1]=qt(e[1]),n}function ZB(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n}function XB(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n}function eE(n,e){let t=e[0]-n[0],i=e[1]-n[1];return Math.sqrt(t*t+i*i)}function tE(n,e){let t=e[0]-n[0],i=e[1]-n[1];return t*t+i*i}function nE(n){let e=n[0],t=n[1];return Math.sqrt(e*e+t*t)}function iE(n){let e=n[0],t=n[1];return e*e+t*t}function KB(n,e){return n[0]=-e[0],n[1]=-e[1],n}function QB(n,e){return n[0]=1/e[0],n[1]=1/e[1],n}function JB(n,e){let t=e[0],i=e[1],r=t*t+i*i;return r>0&&(r=1/Math.sqrt(r)),n[0]=e[0]*r,n[1]=e[1]*r,n}function eO(n,e){return n[0]*e[0]+n[1]*e[1]}function tO(n,e,t){let i=e[0]*t[1]-e[1]*t[0];return n[0]=n[1]=0,n[2]=i,n}function nO(n,e,t,i){let r=e[0],s=e[1];return n[0]=r+i*(t[0]-r),n[1]=s+i*(t[1]-s),n}function iO(n,e){e=e===void 0?1:e;let t=Fn()*2*Math.PI;return n[0]=Math.cos(t)*e,n[1]=Math.sin(t)*e,n}function rO(n,e,t){let i=e[0],r=e[1];return n[0]=t[0]*i+t[2]*r,n[1]=t[1]*i+t[3]*r,n}function sO(n,e,t){let i=e[0],r=e[1];return n[0]=t[0]*i+t[2]*r+t[4],n[1]=t[1]*i+t[3]*r+t[5],n}function oO(n,e,t){let i=e[0],r=e[1];return n[0]=t[0]*i+t[3]*r+t[6],n[1]=t[1]*i+t[4]*r+t[7],n}function gg(n,e,t){let i=e[0],r=e[1];return n[0]=t[0]*i+t[4]*r+t[12],n[1]=t[1]*i+t[5]*r+t[13],n}function aO(n,e,t,i){let r=e[0]-t[0],s=e[1]-t[1],o=Math.sin(i),a=Math.cos(i);return n[0]=r*a-s*o+t[0],n[1]=r*o+s*a+t[1],n}function cO(n,e){let t=n[0],i=n[1],r=e[0],s=e[1],o=Math.sqrt((t*t+i*i)*(r*r+s*s)),a=o&&(t*r+i*s)/o;return Math.acos(Math.min(Math.max(a,-1),1))}function lO(n){return n[0]=0,n[1]=0,n}function uO(n){return`vec2(${n[0]}, ${n[1]})`}function fO(n,e){return n[0]===e[0]&&n[1]===e[1]}function dO(n,e){let t=n[0],i=n[1],r=e[0],s=e[1];return Math.abs(t-r)<=1e-6*Math.max(1,Math.abs(t),Math.abs(r))&&Math.abs(i-s)<=1e-6*Math.max(1,Math.abs(i),Math.abs(s))}var hO,pO,mO,gO,_O,yO,bO,vO,_g=C(()=>{$r();hO=nE,pO=Kw,mO=Qw,gO=Jw,_O=eE,yO=tE,bO=iE,vO=function(){let n=Xw();return function(e,t,i,r,s,o){let a,c;for(t||(t=2),i||(i=0),r?c=Math.min(r*t+i,e.length):c=e.length,a=i;a{});var yt={};ui(yt,{add:()=>SO,angle:()=>Pg,bezier:()=>NO,ceil:()=>PO,clone:()=>xO,copy:()=>wO,create:()=>Ju,cross:()=>Gr,dist:()=>HO,distance:()=>uE,div:()=>jO,divide:()=>lE,dot:()=>Ya,equals:()=>GO,exactEquals:()=>$O,floor:()=>CO,forEach:()=>ZO,fromValues:()=>ef,hermite:()=>DO,inverse:()=>IO,len:()=>Cg,length:()=>oE,lerp:()=>BO,max:()=>LO,min:()=>TO,mul:()=>WO,multiply:()=>cE,negate:()=>RO,normalize:()=>bg,random:()=>FO,rotateX:()=>wg,rotateY:()=>Eg,rotateZ:()=>Sg,round:()=>MO,scale:()=>AO,scaleAndAdd:()=>kO,set:()=>EO,slerp:()=>OO,sqrDist:()=>YO,sqrLen:()=>qO,squaredDistance:()=>fE,squaredLength:()=>dE,str:()=>UO,sub:()=>VO,subtract:()=>aE,transformMat3:()=>vg,transformMat4:()=>qa,transformQuat:()=>xg,zero:()=>zO});function Ju(){let n=new ve(3);return ve!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n}function xO(n){let e=new ve(3);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e}function oE(n){let e=n[0],t=n[1],i=n[2];return Math.sqrt(e*e+t*t+i*i)}function ef(n,e,t){let i=new ve(3);return i[0]=n,i[1]=e,i[2]=t,i}function wO(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n}function EO(n,e,t,i){return n[0]=e,n[1]=t,n[2]=i,n}function SO(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n}function aE(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n}function cE(n,e,t){return n[0]=e[0]*t[0],n[1]=e[1]*t[1],n[2]=e[2]*t[2],n}function lE(n,e,t){return n[0]=e[0]/t[0],n[1]=e[1]/t[1],n[2]=e[2]/t[2],n}function PO(n,e){return n[0]=Math.ceil(e[0]),n[1]=Math.ceil(e[1]),n[2]=Math.ceil(e[2]),n}function CO(n,e){return n[0]=Math.floor(e[0]),n[1]=Math.floor(e[1]),n[2]=Math.floor(e[2]),n}function TO(n,e,t){return n[0]=Math.min(e[0],t[0]),n[1]=Math.min(e[1],t[1]),n[2]=Math.min(e[2],t[2]),n}function LO(n,e,t){return n[0]=Math.max(e[0],t[0]),n[1]=Math.max(e[1],t[1]),n[2]=Math.max(e[2],t[2]),n}function MO(n,e){return n[0]=qt(e[0]),n[1]=qt(e[1]),n[2]=qt(e[2]),n}function AO(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n}function kO(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n[2]=e[2]+t[2]*i,n}function uE(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2];return Math.sqrt(t*t+i*i+r*r)}function fE(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2];return t*t+i*i+r*r}function dE(n){let e=n[0],t=n[1],i=n[2];return e*e+t*t+i*i}function RO(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n}function IO(n,e){return n[0]=1/e[0],n[1]=1/e[1],n[2]=1/e[2],n}function bg(n,e){let t=e[0],i=e[1],r=e[2],s=t*t+i*i+r*r;return s>0&&(s=1/Math.sqrt(s)),n[0]=e[0]*s,n[1]=e[1]*s,n[2]=e[2]*s,n}function Ya(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]}function Gr(n,e,t){let i=e[0],r=e[1],s=e[2],o=t[0],a=t[1],c=t[2];return n[0]=r*c-s*a,n[1]=s*o-i*c,n[2]=i*a-r*o,n}function BO(n,e,t,i){let r=e[0],s=e[1],o=e[2];return n[0]=r+i*(t[0]-r),n[1]=s+i*(t[1]-s),n[2]=o+i*(t[2]-o),n}function OO(n,e,t,i){let r=Math.acos(Math.min(Math.max(Ya(e,t),-1),1)),s=Math.sin(r),o=Math.sin((1-i)*r)/s,a=Math.sin(i*r)/s;return n[0]=o*e[0]+a*t[0],n[1]=o*e[1]+a*t[1],n[2]=o*e[2]+a*t[2],n}function DO(n,e,t,i,r,s){let o=s*s,a=o*(2*s-3)+1,c=o*(s-2)+s,l=o*(s-1),u=o*(3-2*s);return n[0]=e[0]*a+t[0]*c+i[0]*l+r[0]*u,n[1]=e[1]*a+t[1]*c+i[1]*l+r[1]*u,n[2]=e[2]*a+t[2]*c+i[2]*l+r[2]*u,n}function NO(n,e,t,i,r,s){let o=1-s,a=o*o,c=s*s,l=a*o,u=3*s*a,f=3*c*o,d=c*s;return n[0]=e[0]*l+t[0]*u+i[0]*f+r[0]*d,n[1]=e[1]*l+t[1]*u+i[1]*f+r[1]*d,n[2]=e[2]*l+t[2]*u+i[2]*f+r[2]*d,n}function FO(n,e){e=e===void 0?1:e;let t=Fn()*2*Math.PI,i=Fn()*2-1,r=Math.sqrt(1-i*i)*e;return n[0]=Math.cos(t)*r,n[1]=Math.sin(t)*r,n[2]=i*e,n}function qa(n,e,t){let i=e[0],r=e[1],s=e[2],o=t[3]*i+t[7]*r+t[11]*s+t[15];return o=o||1,n[0]=(t[0]*i+t[4]*r+t[8]*s+t[12])/o,n[1]=(t[1]*i+t[5]*r+t[9]*s+t[13])/o,n[2]=(t[2]*i+t[6]*r+t[10]*s+t[14])/o,n}function vg(n,e,t){let i=e[0],r=e[1],s=e[2];return n[0]=i*t[0]+r*t[3]+s*t[6],n[1]=i*t[1]+r*t[4]+s*t[7],n[2]=i*t[2]+r*t[5]+s*t[8],n}function xg(n,e,t){let i=t[0],r=t[1],s=t[2],o=t[3],a=e[0],c=e[1],l=e[2],u=r*l-s*c,f=s*a-i*l,d=i*c-r*a,h=r*d-s*f,p=s*u-i*d,m=i*f-r*u,g=o*2;return u*=g,f*=g,d*=g,h*=2,p*=2,m*=2,n[0]=a+u+h,n[1]=c+f+p,n[2]=l+d+m,n}function wg(n,e,t,i){let r=[],s=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],s[0]=r[0],s[1]=r[1]*Math.cos(i)-r[2]*Math.sin(i),s[2]=r[1]*Math.sin(i)+r[2]*Math.cos(i),n[0]=s[0]+t[0],n[1]=s[1]+t[1],n[2]=s[2]+t[2],n}function Eg(n,e,t,i){let r=[],s=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],s[0]=r[2]*Math.sin(i)+r[0]*Math.cos(i),s[1]=r[1],s[2]=r[2]*Math.cos(i)-r[0]*Math.sin(i),n[0]=s[0]+t[0],n[1]=s[1]+t[1],n[2]=s[2]+t[2],n}function Sg(n,e,t,i){let r=[],s=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],s[0]=r[0]*Math.cos(i)-r[1]*Math.sin(i),s[1]=r[0]*Math.sin(i)+r[1]*Math.cos(i),s[2]=r[2],n[0]=s[0]+t[0],n[1]=s[1]+t[1],n[2]=s[2]+t[2],n}function Pg(n,e){let t=n[0],i=n[1],r=n[2],s=e[0],o=e[1],a=e[2],c=Math.sqrt((t*t+i*i+r*r)*(s*s+o*o+a*a)),l=c&&Ya(n,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function zO(n){return n[0]=0,n[1]=0,n[2]=0,n}function UO(n){return`vec3(${n[0]}, ${n[1]}, ${n[2]})`}function $O(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]}function GO(n,e){let t=n[0],i=n[1],r=n[2],s=e[0],o=e[1],a=e[2];return Math.abs(t-s)<=1e-6*Math.max(1,Math.abs(t),Math.abs(s))&&Math.abs(i-o)<=1e-6*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(r-a)<=1e-6*Math.max(1,Math.abs(r),Math.abs(a))}var VO,WO,jO,HO,YO,Cg,qO,ZO,Za=C(()=>{$r();VO=aE,WO=cE,jO=lE,HO=uE,YO=fE,Cg=oE,qO=dE,ZO=function(){let n=Ju();return function(e,t,i,r,s,o){let a,c;for(t||(t=3),i||(i=0),r?c=Math.min(r*t+i,e.length):c=e.length,a=i;a{Zw();Ks();Ha();Za();yg();Tg=[0,0,0],tt=class n extends Ku{static get ZERO(){return tf||(tf=new n(0,0,0),Object.freeze(tf)),tf}constructor(e=0,t=0,i=0){super(-0,-0,-0),arguments.length===1&&mi(e)?this.copy(e):(Ye.debug&&(et(e),et(t),et(i)),this[0]=e,this[1]=t,this[2]=i)}set(e,t,i){return this[0]=e,this[1]=t,this[2]=i,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return Ye.debug&&(et(e.x),et(e.y),et(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=et(e)}angle(e){return Pg(this,e)}cross(e){return Gr(this,this,e),this.check()}rotateX({radians:e,origin:t=Tg}){return wg(this,this,t,e),this.check()}rotateY({radians:e,origin:t=Tg}){return Eg(this,this,t,e),this.check()}rotateZ({radians:e,origin:t=Tg}){return Sg(this,this,t,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return qa(this,this,e),this.check()}transformAsVector(e){return Qu(this,this,e),this.check()}transformByMatrix3(e){return vg(this,this,e),this.check()}transformByMatrix2(e){return sE(this,this,e),this.check()}transformByQuaternion(e){return xg(this,this,e),this.check()}}});var nf,pE=C(()=>{pg();Ha();Ks();nf=class extends Qs{toString(){let e="[";if(Ye.printRowMajor){e+="row-major:";for(let t=0;t{$r()});var We={};ui(We,{add:()=>vD,adjoint:()=>tD,clone:()=>KO,copy:()=>QO,create:()=>XO,decompose:()=>fD,determinant:()=>kg,equals:()=>SD,exactEquals:()=>ED,frob:()=>bD,fromQuat:()=>Fg,fromQuat2:()=>cD,fromRotation:()=>rD,fromRotationTranslation:()=>yE,fromRotationTranslationScale:()=>dD,fromRotationTranslationScaleOrigin:()=>hD,fromScaling:()=>iD,fromTranslation:()=>nD,fromValues:()=>JO,fromXRotation:()=>sD,fromYRotation:()=>oD,fromZRotation:()=>aD,frustum:()=>zg,getRotation:()=>uD,getScaling:()=>bE,getTranslation:()=>lD,identity:()=>_E,invert:()=>Ag,lookAt:()=>Gg,mul:()=>PD,multiply:()=>Xa,multiplyScalar:()=>xD,multiplyScalarAndAdd:()=>wD,ortho:()=>$g,orthoNO:()=>xE,orthoZO:()=>gD,perspective:()=>Ug,perspectiveFromFieldOfView:()=>mD,perspectiveNO:()=>vE,perspectiveZO:()=>pD,rotate:()=>Bg,rotateX:()=>Og,rotateY:()=>Dg,rotateZ:()=>Ng,scale:()=>Ig,set:()=>eD,str:()=>yD,sub:()=>CD,subtract:()=>wE,targetTo:()=>_D,translate:()=>Rg,transpose:()=>Mg});function XO(){let n=new ve(16);return ve!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0),n[0]=1,n[5]=1,n[10]=1,n[15]=1,n}function KO(n){let e=new ve(16);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],e}function QO(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function JO(n,e,t,i,r,s,o,a,c,l,u,f,d,h,p,m){let g=new ve(16);return g[0]=n,g[1]=e,g[2]=t,g[3]=i,g[4]=r,g[5]=s,g[6]=o,g[7]=a,g[8]=c,g[9]=l,g[10]=u,g[11]=f,g[12]=d,g[13]=h,g[14]=p,g[15]=m,g}function eD(n,e,t,i,r,s,o,a,c,l,u,f,d,h,p,m,g){return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n[4]=s,n[5]=o,n[6]=a,n[7]=c,n[8]=l,n[9]=u,n[10]=f,n[11]=d,n[12]=h,n[13]=p,n[14]=m,n[15]=g,n}function _E(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Mg(n,e){if(n===e){let t=e[1],i=e[2],r=e[3],s=e[6],o=e[7],a=e[11];n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=t,n[6]=e[9],n[7]=e[13],n[8]=i,n[9]=s,n[11]=e[14],n[12]=r,n[13]=o,n[14]=a}else n[0]=e[0],n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=e[1],n[5]=e[5],n[6]=e[9],n[7]=e[13],n[8]=e[2],n[9]=e[6],n[10]=e[10],n[11]=e[14],n[12]=e[3],n[13]=e[7],n[14]=e[11],n[15]=e[15];return n}function Ag(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],d=e[10],h=e[11],p=e[12],m=e[13],g=e[14],v=e[15],y=t*a-i*o,b=t*c-r*o,w=t*l-s*o,E=i*c-r*a,x=i*l-s*a,T=r*l-s*c,I=u*m-f*p,N=u*g-d*p,D=u*v-h*p,H=f*g-d*m,W=f*v-h*m,V=d*v-h*g,X=y*V-b*W+w*H+E*D-x*N+T*I;return X?(X=1/X,n[0]=(a*V-c*W+l*H)*X,n[1]=(r*W-i*V-s*H)*X,n[2]=(m*T-g*x+v*E)*X,n[3]=(d*x-f*T-h*E)*X,n[4]=(c*D-o*V-l*N)*X,n[5]=(t*V-r*D+s*N)*X,n[6]=(g*w-p*T-v*b)*X,n[7]=(u*T-d*w+h*b)*X,n[8]=(o*W-a*D+l*I)*X,n[9]=(i*D-t*W-s*I)*X,n[10]=(p*x-m*w+v*y)*X,n[11]=(f*w-u*x-h*y)*X,n[12]=(a*N-o*H-c*I)*X,n[13]=(t*H-i*N+r*I)*X,n[14]=(m*b-p*E-g*y)*X,n[15]=(u*E-f*b+d*y)*X,n):null}function tD(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],d=e[10],h=e[11],p=e[12],m=e[13],g=e[14],v=e[15],y=t*a-i*o,b=t*c-r*o,w=t*l-s*o,E=i*c-r*a,x=i*l-s*a,T=r*l-s*c,I=u*m-f*p,N=u*g-d*p,D=u*v-h*p,H=f*g-d*m,W=f*v-h*m,V=d*v-h*g;return n[0]=a*V-c*W+l*H,n[1]=r*W-i*V-s*H,n[2]=m*T-g*x+v*E,n[3]=d*x-f*T-h*E,n[4]=c*D-o*V-l*N,n[5]=t*V-r*D+s*N,n[6]=g*w-p*T-v*b,n[7]=u*T-d*w+h*b,n[8]=o*W-a*D+l*I,n[9]=i*D-t*W-s*I,n[10]=p*x-m*w+v*y,n[11]=f*w-u*x-h*y,n[12]=a*N-o*H-c*I,n[13]=t*H-i*N+r*I,n[14]=m*b-p*E-g*y,n[15]=u*E-f*b+d*y,n}function kg(n){let e=n[0],t=n[1],i=n[2],r=n[3],s=n[4],o=n[5],a=n[6],c=n[7],l=n[8],u=n[9],f=n[10],d=n[11],h=n[12],p=n[13],m=n[14],g=n[15],v=e*o-t*s,y=e*a-i*s,b=t*a-i*o,w=l*p-u*h,E=l*m-f*h,x=u*m-f*p,T=e*x-t*E+i*w,I=s*x-o*E+a*w,N=l*b-u*y+f*v,D=h*b-p*y+m*v;return c*T-r*I+g*N-d*D}function Xa(n,e,t){let i=e[0],r=e[1],s=e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=e[8],d=e[9],h=e[10],p=e[11],m=e[12],g=e[13],v=e[14],y=e[15],b=t[0],w=t[1],E=t[2],x=t[3];return n[0]=b*i+w*a+E*f+x*m,n[1]=b*r+w*c+E*d+x*g,n[2]=b*s+w*l+E*h+x*v,n[3]=b*o+w*u+E*p+x*y,b=t[4],w=t[5],E=t[6],x=t[7],n[4]=b*i+w*a+E*f+x*m,n[5]=b*r+w*c+E*d+x*g,n[6]=b*s+w*l+E*h+x*v,n[7]=b*o+w*u+E*p+x*y,b=t[8],w=t[9],E=t[10],x=t[11],n[8]=b*i+w*a+E*f+x*m,n[9]=b*r+w*c+E*d+x*g,n[10]=b*s+w*l+E*h+x*v,n[11]=b*o+w*u+E*p+x*y,b=t[12],w=t[13],E=t[14],x=t[15],n[12]=b*i+w*a+E*f+x*m,n[13]=b*r+w*c+E*d+x*g,n[14]=b*s+w*l+E*h+x*v,n[15]=b*o+w*u+E*p+x*y,n}function Rg(n,e,t){let i=t[0],r=t[1],s=t[2],o,a,c,l,u,f,d,h,p,m,g,v;return e===n?(n[12]=e[0]*i+e[4]*r+e[8]*s+e[12],n[13]=e[1]*i+e[5]*r+e[9]*s+e[13],n[14]=e[2]*i+e[6]*r+e[10]*s+e[14],n[15]=e[3]*i+e[7]*r+e[11]*s+e[15]):(o=e[0],a=e[1],c=e[2],l=e[3],u=e[4],f=e[5],d=e[6],h=e[7],p=e[8],m=e[9],g=e[10],v=e[11],n[0]=o,n[1]=a,n[2]=c,n[3]=l,n[4]=u,n[5]=f,n[6]=d,n[7]=h,n[8]=p,n[9]=m,n[10]=g,n[11]=v,n[12]=o*i+u*r+p*s+e[12],n[13]=a*i+f*r+m*s+e[13],n[14]=c*i+d*r+g*s+e[14],n[15]=l*i+h*r+v*s+e[15]),n}function Ig(n,e,t){let i=t[0],r=t[1],s=t[2];return n[0]=e[0]*i,n[1]=e[1]*i,n[2]=e[2]*i,n[3]=e[3]*i,n[4]=e[4]*r,n[5]=e[5]*r,n[6]=e[6]*r,n[7]=e[7]*r,n[8]=e[8]*s,n[9]=e[9]*s,n[10]=e[10]*s,n[11]=e[11]*s,n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function Bg(n,e,t,i){let r=i[0],s=i[1],o=i[2],a=Math.sqrt(r*r+s*s+o*o),c,l,u,f,d,h,p,m,g,v,y,b,w,E,x,T,I,N,D,H,W,V,X,Y;return a<1e-6?null:(a=1/a,r*=a,s*=a,o*=a,l=Math.sin(t),c=Math.cos(t),u=1-c,f=e[0],d=e[1],h=e[2],p=e[3],m=e[4],g=e[5],v=e[6],y=e[7],b=e[8],w=e[9],E=e[10],x=e[11],T=r*r*u+c,I=s*r*u+o*l,N=o*r*u-s*l,D=r*s*u-o*l,H=s*s*u+c,W=o*s*u+r*l,V=r*o*u+s*l,X=s*o*u-r*l,Y=o*o*u+c,n[0]=f*T+m*I+b*N,n[1]=d*T+g*I+w*N,n[2]=h*T+v*I+E*N,n[3]=p*T+y*I+x*N,n[4]=f*D+m*H+b*W,n[5]=d*D+g*H+w*W,n[6]=h*D+v*H+E*W,n[7]=p*D+y*H+x*W,n[8]=f*V+m*X+b*Y,n[9]=d*V+g*X+w*Y,n[10]=h*V+v*X+E*Y,n[11]=p*V+y*X+x*Y,e!==n&&(n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n)}function Og(n,e,t){let i=Math.sin(t),r=Math.cos(t),s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],f=e[10],d=e[11];return e!==n&&(n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[4]=s*r+l*i,n[5]=o*r+u*i,n[6]=a*r+f*i,n[7]=c*r+d*i,n[8]=l*r-s*i,n[9]=u*r-o*i,n[10]=f*r-a*i,n[11]=d*r-c*i,n}function Dg(n,e,t){let i=Math.sin(t),r=Math.cos(t),s=e[0],o=e[1],a=e[2],c=e[3],l=e[8],u=e[9],f=e[10],d=e[11];return e!==n&&(n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=s*r-l*i,n[1]=o*r-u*i,n[2]=a*r-f*i,n[3]=c*r-d*i,n[8]=s*i+l*r,n[9]=o*i+u*r,n[10]=a*i+f*r,n[11]=c*i+d*r,n}function Ng(n,e,t){let i=Math.sin(t),r=Math.cos(t),s=e[0],o=e[1],a=e[2],c=e[3],l=e[4],u=e[5],f=e[6],d=e[7];return e!==n&&(n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=s*r+l*i,n[1]=o*r+u*i,n[2]=a*r+f*i,n[3]=c*r+d*i,n[4]=l*r-s*i,n[5]=u*r-o*i,n[6]=f*r-a*i,n[7]=d*r-c*i,n}function nD(n,e){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=e[0],n[13]=e[1],n[14]=e[2],n[15]=1,n}function iD(n,e){return n[0]=e[0],n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=e[1],n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=e[2],n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function rD(n,e,t){let i=t[0],r=t[1],s=t[2],o=Math.sqrt(i*i+r*r+s*s),a,c,l;return o<1e-6?null:(o=1/o,i*=o,r*=o,s*=o,c=Math.sin(e),a=Math.cos(e),l=1-a,n[0]=i*i*l+a,n[1]=r*i*l+s*c,n[2]=s*i*l-r*c,n[3]=0,n[4]=i*r*l-s*c,n[5]=r*r*l+a,n[6]=s*r*l+i*c,n[7]=0,n[8]=i*s*l+r*c,n[9]=r*s*l-i*c,n[10]=s*s*l+a,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n)}function sD(n,e){let t=Math.sin(e),i=Math.cos(e);return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i,n[6]=t,n[7]=0,n[8]=0,n[9]=-t,n[10]=i,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function oD(n,e){let t=Math.sin(e),i=Math.cos(e);return n[0]=i,n[1]=0,n[2]=-t,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=t,n[9]=0,n[10]=i,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function aD(n,e){let t=Math.sin(e),i=Math.cos(e);return n[0]=i,n[1]=t,n[2]=0,n[3]=0,n[4]=-t,n[5]=i,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function yE(n,e,t){let i=e[0],r=e[1],s=e[2],o=e[3],a=i+i,c=r+r,l=s+s,u=i*a,f=i*c,d=i*l,h=r*c,p=r*l,m=s*l,g=o*a,v=o*c,y=o*l;return n[0]=1-(h+m),n[1]=f+y,n[2]=d-v,n[3]=0,n[4]=f-y,n[5]=1-(u+m),n[6]=p+g,n[7]=0,n[8]=d+v,n[9]=p-g,n[10]=1-(u+h),n[11]=0,n[12]=t[0],n[13]=t[1],n[14]=t[2],n[15]=1,n}function cD(n,e){let t=new ve(3),i=-e[0],r=-e[1],s=-e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=i*i+r*r+s*s+o*o;return f>0?(t[0]=(a*o+u*i+c*s-l*r)*2/f,t[1]=(c*o+u*r+l*i-a*s)*2/f,t[2]=(l*o+u*s+a*r-c*i)*2/f):(t[0]=(a*o+u*i+c*s-l*r)*2,t[1]=(c*o+u*r+l*i-a*s)*2,t[2]=(l*o+u*s+a*r-c*i)*2),yE(n,e,t),n}function lD(n,e){return n[0]=e[12],n[1]=e[13],n[2]=e[14],n}function bE(n,e){let t=e[0],i=e[1],r=e[2],s=e[4],o=e[5],a=e[6],c=e[8],l=e[9],u=e[10];return n[0]=Math.sqrt(t*t+i*i+r*r),n[1]=Math.sqrt(s*s+o*o+a*a),n[2]=Math.sqrt(c*c+l*l+u*u),n}function uD(n,e){let t=new ve(3);bE(t,e);let i=1/t[0],r=1/t[1],s=1/t[2],o=e[0]*i,a=e[1]*r,c=e[2]*s,l=e[4]*i,u=e[5]*r,f=e[6]*s,d=e[8]*i,h=e[9]*r,p=e[10]*s,m=o+u+p,g=0;return m>0?(g=Math.sqrt(m+1)*2,n[3]=.25*g,n[0]=(f-h)/g,n[1]=(d-c)/g,n[2]=(a-l)/g):o>u&&o>p?(g=Math.sqrt(1+o-u-p)*2,n[3]=(f-h)/g,n[0]=.25*g,n[1]=(a+l)/g,n[2]=(d+c)/g):u>p?(g=Math.sqrt(1+u-o-p)*2,n[3]=(d-c)/g,n[0]=(a+l)/g,n[1]=.25*g,n[2]=(f+h)/g):(g=Math.sqrt(1+p-o-u)*2,n[3]=(a-l)/g,n[0]=(d+c)/g,n[1]=(f+h)/g,n[2]=.25*g),n}function fD(n,e,t,i){e[0]=i[12],e[1]=i[13],e[2]=i[14];let r=i[0],s=i[1],o=i[2],a=i[4],c=i[5],l=i[6],u=i[8],f=i[9],d=i[10];t[0]=Math.sqrt(r*r+s*s+o*o),t[1]=Math.sqrt(a*a+c*c+l*l),t[2]=Math.sqrt(u*u+f*f+d*d);let h=1/t[0],p=1/t[1],m=1/t[2],g=r*h,v=s*p,y=o*m,b=a*h,w=c*p,E=l*m,x=u*h,T=f*p,I=d*m,N=g+w+I,D=0;return N>0?(D=Math.sqrt(N+1)*2,n[3]=.25*D,n[0]=(E-T)/D,n[1]=(x-y)/D,n[2]=(v-b)/D):g>w&&g>I?(D=Math.sqrt(1+g-w-I)*2,n[3]=(E-T)/D,n[0]=.25*D,n[1]=(v+b)/D,n[2]=(x+y)/D):w>I?(D=Math.sqrt(1+w-g-I)*2,n[3]=(x-y)/D,n[0]=(v+b)/D,n[1]=.25*D,n[2]=(E+T)/D):(D=Math.sqrt(1+I-g-w)*2,n[3]=(v-b)/D,n[0]=(x+y)/D,n[1]=(E+T)/D,n[2]=.25*D),n}function dD(n,e,t,i){let r=e[0],s=e[1],o=e[2],a=e[3],c=r+r,l=s+s,u=o+o,f=r*c,d=r*l,h=r*u,p=s*l,m=s*u,g=o*u,v=a*c,y=a*l,b=a*u,w=i[0],E=i[1],x=i[2];return n[0]=(1-(p+g))*w,n[1]=(d+b)*w,n[2]=(h-y)*w,n[3]=0,n[4]=(d-b)*E,n[5]=(1-(f+g))*E,n[6]=(m+v)*E,n[7]=0,n[8]=(h+y)*x,n[9]=(m-v)*x,n[10]=(1-(f+p))*x,n[11]=0,n[12]=t[0],n[13]=t[1],n[14]=t[2],n[15]=1,n}function hD(n,e,t,i,r){let s=e[0],o=e[1],a=e[2],c=e[3],l=s+s,u=o+o,f=a+a,d=s*l,h=s*u,p=s*f,m=o*u,g=o*f,v=a*f,y=c*l,b=c*u,w=c*f,E=i[0],x=i[1],T=i[2],I=r[0],N=r[1],D=r[2],H=(1-(m+v))*E,W=(h+w)*E,V=(p-b)*E,X=(h-w)*x,Y=(1-(d+v))*x,ie=(g+y)*x,oe=(p+b)*T,zt=(g-y)*T,je=(1-(d+m))*T;return n[0]=H,n[1]=W,n[2]=V,n[3]=0,n[4]=X,n[5]=Y,n[6]=ie,n[7]=0,n[8]=oe,n[9]=zt,n[10]=je,n[11]=0,n[12]=t[0]+I-(H*I+X*N+oe*D),n[13]=t[1]+N-(W*I+Y*N+zt*D),n[14]=t[2]+D-(V*I+ie*N+je*D),n[15]=1,n}function Fg(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],o=t+t,a=i+i,c=r+r,l=t*o,u=i*o,f=i*a,d=r*o,h=r*a,p=r*c,m=s*o,g=s*a,v=s*c;return n[0]=1-f-p,n[1]=u+v,n[2]=d-g,n[3]=0,n[4]=u-v,n[5]=1-l-p,n[6]=h+m,n[7]=0,n[8]=d+g,n[9]=h-m,n[10]=1-l-f,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function zg(n,e,t,i,r,s,o){let a=1/(t-e),c=1/(r-i),l=1/(s-o);return n[0]=s*2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=s*2*c,n[6]=0,n[7]=0,n[8]=(t+e)*a,n[9]=(r+i)*c,n[10]=(o+s)*l,n[11]=-1,n[12]=0,n[13]=0,n[14]=o*s*2*l,n[15]=0,n}function vE(n,e,t,i,r){let s=1/Math.tan(e/2);if(n[0]=s/t,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=s,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,r!=null&&r!==1/0){let o=1/(i-r);n[10]=(r+i)*o,n[14]=2*r*i*o}else n[10]=-1,n[14]=-2*i;return n}function pD(n,e,t,i,r){let s=1/Math.tan(e/2);if(n[0]=s/t,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=s,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,r!=null&&r!==1/0){let o=1/(i-r);n[10]=r*o,n[14]=r*i*o}else n[10]=-1,n[14]=-i;return n}function mD(n,e,t,i){let r=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),o=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),c=2/(o+a),l=2/(r+s);return n[0]=c,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=l,n[6]=0,n[7]=0,n[8]=-((o-a)*c*.5),n[9]=(r-s)*l*.5,n[10]=i/(t-i),n[11]=-1,n[12]=0,n[13]=0,n[14]=i*t/(t-i),n[15]=0,n}function xE(n,e,t,i,r,s,o){let a=1/(e-t),c=1/(i-r),l=1/(s-o);return n[0]=-2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*c,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*l,n[11]=0,n[12]=(e+t)*a,n[13]=(r+i)*c,n[14]=(o+s)*l,n[15]=1,n}function gD(n,e,t,i,r,s,o){let a=1/(e-t),c=1/(i-r),l=1/(s-o);return n[0]=-2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*c,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=l,n[11]=0,n[12]=(e+t)*a,n[13]=(r+i)*c,n[14]=s*l,n[15]=1,n}function Gg(n,e,t,i){let r,s,o,a,c,l,u,f,d,h,p=e[0],m=e[1],g=e[2],v=i[0],y=i[1],b=i[2],w=t[0],E=t[1],x=t[2];return Math.abs(p-w)<1e-6&&Math.abs(m-E)<1e-6&&Math.abs(g-x)<1e-6?_E(n):(f=p-w,d=m-E,h=g-x,r=1/Math.sqrt(f*f+d*d+h*h),f*=r,d*=r,h*=r,s=y*h-b*d,o=b*f-v*h,a=v*d-y*f,r=Math.sqrt(s*s+o*o+a*a),r?(r=1/r,s*=r,o*=r,a*=r):(s=0,o=0,a=0),c=d*a-h*o,l=h*s-f*a,u=f*o-d*s,r=Math.sqrt(c*c+l*l+u*u),r?(r=1/r,c*=r,l*=r,u*=r):(c=0,l=0,u=0),n[0]=s,n[1]=c,n[2]=f,n[3]=0,n[4]=o,n[5]=l,n[6]=d,n[7]=0,n[8]=a,n[9]=u,n[10]=h,n[11]=0,n[12]=-(s*p+o*m+a*g),n[13]=-(c*p+l*m+u*g),n[14]=-(f*p+d*m+h*g),n[15]=1,n)}function _D(n,e,t,i){let r=e[0],s=e[1],o=e[2],a=i[0],c=i[1],l=i[2],u=r-t[0],f=s-t[1],d=o-t[2],h=u*u+f*f+d*d;h>0&&(h=1/Math.sqrt(h),u*=h,f*=h,d*=h);let p=c*d-l*f,m=l*u-a*d,g=a*f-c*u;return h=p*p+m*m+g*g,h>0&&(h=1/Math.sqrt(h),p*=h,m*=h,g*=h),n[0]=p,n[1]=m,n[2]=g,n[3]=0,n[4]=f*g-d*m,n[5]=d*p-u*g,n[6]=u*m-f*p,n[7]=0,n[8]=u,n[9]=f,n[10]=d,n[11]=0,n[12]=r,n[13]=s,n[14]=o,n[15]=1,n}function yD(n){return`mat4(${n[0]}, ${n[1]}, ${n[2]}, ${n[3]}, ${n[4]}, ${n[5]}, ${n[6]}, ${n[7]}, ${n[8]}, ${n[9]}, ${n[10]}, ${n[11]}, ${n[12]}, ${n[13]}, ${n[14]}, ${n[15]})`}function bD(n){return Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]+n[3]*n[3]+n[4]*n[4]+n[5]*n[5]+n[6]*n[6]+n[7]*n[7]+n[8]*n[8]+n[9]*n[9]+n[10]*n[10]+n[11]*n[11]+n[12]*n[12]+n[13]*n[13]+n[14]*n[14]+n[15]*n[15])}function vD(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n[3]=e[3]+t[3],n[4]=e[4]+t[4],n[5]=e[5]+t[5],n[6]=e[6]+t[6],n[7]=e[7]+t[7],n[8]=e[8]+t[8],n[9]=e[9]+t[9],n[10]=e[10]+t[10],n[11]=e[11]+t[11],n[12]=e[12]+t[12],n[13]=e[13]+t[13],n[14]=e[14]+t[14],n[15]=e[15]+t[15],n}function wE(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n[3]=e[3]-t[3],n[4]=e[4]-t[4],n[5]=e[5]-t[5],n[6]=e[6]-t[6],n[7]=e[7]-t[7],n[8]=e[8]-t[8],n[9]=e[9]-t[9],n[10]=e[10]-t[10],n[11]=e[11]-t[11],n[12]=e[12]-t[12],n[13]=e[13]-t[13],n[14]=e[14]-t[14],n[15]=e[15]-t[15],n}function xD(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n[3]=e[3]*t,n[4]=e[4]*t,n[5]=e[5]*t,n[6]=e[6]*t,n[7]=e[7]*t,n[8]=e[8]*t,n[9]=e[9]*t,n[10]=e[10]*t,n[11]=e[11]*t,n[12]=e[12]*t,n[13]=e[13]*t,n[14]=e[14]*t,n[15]=e[15]*t,n}function wD(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n[2]=e[2]+t[2]*i,n[3]=e[3]+t[3]*i,n[4]=e[4]+t[4]*i,n[5]=e[5]+t[5]*i,n[6]=e[6]+t[6]*i,n[7]=e[7]+t[7]*i,n[8]=e[8]+t[8]*i,n[9]=e[9]+t[9]*i,n[10]=e[10]+t[10]*i,n[11]=e[11]+t[11]*i,n[12]=e[12]+t[12]*i,n[13]=e[13]+t[13]*i,n[14]=e[14]+t[14]*i,n[15]=e[15]+t[15]*i,n}function ED(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]&&n[3]===e[3]&&n[4]===e[4]&&n[5]===e[5]&&n[6]===e[6]&&n[7]===e[7]&&n[8]===e[8]&&n[9]===e[9]&&n[10]===e[10]&&n[11]===e[11]&&n[12]===e[12]&&n[13]===e[13]&&n[14]===e[14]&&n[15]===e[15]}function SD(n,e){let t=n[0],i=n[1],r=n[2],s=n[3],o=n[4],a=n[5],c=n[6],l=n[7],u=n[8],f=n[9],d=n[10],h=n[11],p=n[12],m=n[13],g=n[14],v=n[15],y=e[0],b=e[1],w=e[2],E=e[3],x=e[4],T=e[5],I=e[6],N=e[7],D=e[8],H=e[9],W=e[10],V=e[11],X=e[12],Y=e[13],ie=e[14],oe=e[15];return Math.abs(t-y)<=1e-6*Math.max(1,Math.abs(t),Math.abs(y))&&Math.abs(i-b)<=1e-6*Math.max(1,Math.abs(i),Math.abs(b))&&Math.abs(r-w)<=1e-6*Math.max(1,Math.abs(r),Math.abs(w))&&Math.abs(s-E)<=1e-6*Math.max(1,Math.abs(s),Math.abs(E))&&Math.abs(o-x)<=1e-6*Math.max(1,Math.abs(o),Math.abs(x))&&Math.abs(a-T)<=1e-6*Math.max(1,Math.abs(a),Math.abs(T))&&Math.abs(c-I)<=1e-6*Math.max(1,Math.abs(c),Math.abs(I))&&Math.abs(l-N)<=1e-6*Math.max(1,Math.abs(l),Math.abs(N))&&Math.abs(u-D)<=1e-6*Math.max(1,Math.abs(u),Math.abs(D))&&Math.abs(f-H)<=1e-6*Math.max(1,Math.abs(f),Math.abs(H))&&Math.abs(d-W)<=1e-6*Math.max(1,Math.abs(d),Math.abs(W))&&Math.abs(h-V)<=1e-6*Math.max(1,Math.abs(h),Math.abs(V))&&Math.abs(p-X)<=1e-6*Math.max(1,Math.abs(p),Math.abs(X))&&Math.abs(m-Y)<=1e-6*Math.max(1,Math.abs(m),Math.abs(Y))&&Math.abs(g-ie)<=1e-6*Math.max(1,Math.abs(g),Math.abs(ie))&&Math.abs(v-oe)<=1e-6*Math.max(1,Math.abs(v),Math.abs(oe))}var Ug,$g,PD,CD,Vg=C(()=>{$r();Ug=vE;$g=xE;PD=Xa,CD=wE});var At={};ui(At,{add:()=>LE,ceil:()=>TD,clone:()=>SE,copy:()=>CE,create:()=>EE,cross:()=>OD,dist:()=>WD,distance:()=>IE,div:()=>VD,divide:()=>kE,dot:()=>OE,equals:()=>UD,exactEquals:()=>NE,floor:()=>LD,forEach:()=>qD,fromValues:()=>PE,inverse:()=>BD,len:()=>HD,length:()=>Wg,lerp:()=>DE,max:()=>AD,min:()=>MD,mul:()=>GD,multiply:()=>AE,negate:()=>ID,normalize:()=>Hg,random:()=>DD,round:()=>kD,scale:()=>RE,scaleAndAdd:()=>RD,set:()=>TE,sqrDist:()=>jD,sqrLen:()=>YD,squaredDistance:()=>BE,squaredLength:()=>jg,str:()=>zD,sub:()=>$D,subtract:()=>ME,transformMat4:()=>Yg,transformQuat:()=>ND,zero:()=>FD});function EE(){let n=new ve(4);return ve!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0,n[3]=0),n}function SE(n){let e=new ve(4);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e}function PE(n,e,t,i){let r=new ve(4);return r[0]=n,r[1]=e,r[2]=t,r[3]=i,r}function CE(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n}function TE(n,e,t,i,r){return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n}function LE(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n[3]=e[3]+t[3],n}function ME(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n[3]=e[3]-t[3],n}function AE(n,e,t){return n[0]=e[0]*t[0],n[1]=e[1]*t[1],n[2]=e[2]*t[2],n[3]=e[3]*t[3],n}function kE(n,e,t){return n[0]=e[0]/t[0],n[1]=e[1]/t[1],n[2]=e[2]/t[2],n[3]=e[3]/t[3],n}function TD(n,e){return n[0]=Math.ceil(e[0]),n[1]=Math.ceil(e[1]),n[2]=Math.ceil(e[2]),n[3]=Math.ceil(e[3]),n}function LD(n,e){return n[0]=Math.floor(e[0]),n[1]=Math.floor(e[1]),n[2]=Math.floor(e[2]),n[3]=Math.floor(e[3]),n}function MD(n,e,t){return n[0]=Math.min(e[0],t[0]),n[1]=Math.min(e[1],t[1]),n[2]=Math.min(e[2],t[2]),n[3]=Math.min(e[3],t[3]),n}function AD(n,e,t){return n[0]=Math.max(e[0],t[0]),n[1]=Math.max(e[1],t[1]),n[2]=Math.max(e[2],t[2]),n[3]=Math.max(e[3],t[3]),n}function kD(n,e){return n[0]=qt(e[0]),n[1]=qt(e[1]),n[2]=qt(e[2]),n[3]=qt(e[3]),n}function RE(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n[3]=e[3]*t,n}function RD(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n[2]=e[2]+t[2]*i,n[3]=e[3]+t[3]*i,n}function IE(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2],s=e[3]-n[3];return Math.sqrt(t*t+i*i+r*r+s*s)}function BE(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2],s=e[3]-n[3];return t*t+i*i+r*r+s*s}function Wg(n){let e=n[0],t=n[1],i=n[2],r=n[3];return Math.sqrt(e*e+t*t+i*i+r*r)}function jg(n){let e=n[0],t=n[1],i=n[2],r=n[3];return e*e+t*t+i*i+r*r}function ID(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n[3]=-e[3],n}function BD(n,e){return n[0]=1/e[0],n[1]=1/e[1],n[2]=1/e[2],n[3]=1/e[3],n}function Hg(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],o=t*t+i*i+r*r+s*s;return o>0&&(o=1/Math.sqrt(o)),n[0]=t*o,n[1]=i*o,n[2]=r*o,n[3]=s*o,n}function OE(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]+n[3]*e[3]}function OD(n,e,t,i){let r=t[0]*i[1]-t[1]*i[0],s=t[0]*i[2]-t[2]*i[0],o=t[0]*i[3]-t[3]*i[0],a=t[1]*i[2]-t[2]*i[1],c=t[1]*i[3]-t[3]*i[1],l=t[2]*i[3]-t[3]*i[2],u=e[0],f=e[1],d=e[2],h=e[3];return n[0]=f*l-d*c+h*a,n[1]=-(u*l)+d*o-h*s,n[2]=u*c-f*o+h*r,n[3]=-(u*a)+f*s-d*r,n}function DE(n,e,t,i){let r=e[0],s=e[1],o=e[2],a=e[3];return n[0]=r+i*(t[0]-r),n[1]=s+i*(t[1]-s),n[2]=o+i*(t[2]-o),n[3]=a+i*(t[3]-a),n}function DD(n,e){e=e===void 0?1:e;let t,i,r,s,o,a;do t=Fn()*2-1,i=Fn()*2-1,o=t*t+i*i;while(o>=1);do r=Fn()*2-1,s=Fn()*2-1,a=r*r+s*s;while(a>=1);let c=Math.sqrt((1-o)/a);return n[0]=e*t,n[1]=e*i,n[2]=e*r*c,n[3]=e*s*c,n}function Yg(n,e,t){let i=e[0],r=e[1],s=e[2],o=e[3];return n[0]=t[0]*i+t[4]*r+t[8]*s+t[12]*o,n[1]=t[1]*i+t[5]*r+t[9]*s+t[13]*o,n[2]=t[2]*i+t[6]*r+t[10]*s+t[14]*o,n[3]=t[3]*i+t[7]*r+t[11]*s+t[15]*o,n}function ND(n,e,t){let i=e[0],r=e[1],s=e[2],o=t[0],a=t[1],c=t[2],l=t[3],u=l*i+a*s-c*r,f=l*r+c*i-o*s,d=l*s+o*r-a*i,h=-o*i-a*r-c*s;return n[0]=u*l+h*-o+f*-c-d*-a,n[1]=f*l+h*-a+d*-o-u*-c,n[2]=d*l+h*-c+u*-a-f*-o,n[3]=e[3],n}function FD(n){return n[0]=0,n[1]=0,n[2]=0,n[3]=0,n}function zD(n){return`vec4(${n[0]}, ${n[1]}, ${n[2]}, ${n[3]})`}function NE(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]&&n[3]===e[3]}function UD(n,e){let t=n[0],i=n[1],r=n[2],s=n[3],o=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(t-o)<=1e-6*Math.max(1,Math.abs(t),Math.abs(o))&&Math.abs(i-a)<=1e-6*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(r-c)<=1e-6*Math.max(1,Math.abs(r),Math.abs(c))&&Math.abs(s-l)<=1e-6*Math.max(1,Math.abs(s),Math.abs(l))}var $D,GD,VD,WD,jD,HD,YD,qD,rf=C(()=>{$r();$D=ME,GD=AE,VD=kE,WD=IE,jD=BE,HD=Wg,YD=jg,qD=function(){let n=EE();return function(e,t,i,r,s,o){let a,c;for(t||(t=4),i||(i=0),r?c=Math.min(r*t+i,e.length):c=e.length,a=i;aMath.PI*2)throw Error("expected radians")}function e4(n,e,t,i,r,s){let o=2*s/(t-e),a=2*s/(r-i),c=(t+e)/(t-e),l=(r+i)/(r-i),u=-1,f=-1,d=-2*s;return n[0]=o,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=a,n[6]=0,n[7]=0,n[8]=c,n[9]=l,n[10]=u,n[11]=f,n[12]=0,n[13]=0,n[14]=d,n[15]=0,n}var Xg,ZD,XD,qg,Zg,KD,Ne,sf,of,zE=C(()=>{pE();Ha();yg();Vg();_g();Za();rf();(function(n){n[n.COL0ROW0=0]="COL0ROW0",n[n.COL0ROW1=1]="COL0ROW1",n[n.COL0ROW2=2]="COL0ROW2",n[n.COL0ROW3=3]="COL0ROW3",n[n.COL1ROW0=4]="COL1ROW0",n[n.COL1ROW1=5]="COL1ROW1",n[n.COL1ROW2=6]="COL1ROW2",n[n.COL1ROW3=7]="COL1ROW3",n[n.COL2ROW0=8]="COL2ROW0",n[n.COL2ROW1=9]="COL2ROW1",n[n.COL2ROW2=10]="COL2ROW2",n[n.COL2ROW3=11]="COL2ROW3",n[n.COL3ROW0=12]="COL3ROW0",n[n.COL3ROW1=13]="COL3ROW1",n[n.COL3ROW2=14]="COL3ROW2",n[n.COL3ROW3=15]="COL3ROW3"})(Xg||(Xg={}));ZD=45*Math.PI/180,XD=1,qg=.1,Zg=500,KD=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),Ne=class extends nf{static get IDENTITY(){return JD()}static get ZERO(){return QD()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Xg}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,i,r,s,o,a,c,l,u,f,d,h,p,m,g){return this[0]=e,this[1]=t,this[2]=i,this[3]=r,this[4]=s,this[5]=o,this[6]=a,this[7]=c,this[8]=l,this[9]=u,this[10]=f,this[11]=d,this[12]=h,this[13]=p,this[14]=m,this[15]=g,this.check()}setRowMajor(e,t,i,r,s,o,a,c,l,u,f,d,h,p,m,g){return this[0]=e,this[1]=s,this[2]=l,this[3]=h,this[4]=t,this[5]=o,this[6]=u,this[7]=p,this[8]=i,this[9]=a,this[10]=f,this[11]=m,this[12]=r,this[13]=c,this[14]=d,this[15]=g,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(KD)}fromObject(e){return this.check()}fromQuaternion(e){return Fg(this,e),this.check()}frustum(e){let{left:t,right:i,bottom:r,top:s,near:o=qg,far:a=Zg}=e;return a===1/0?e4(this,t,i,r,s,o):zg(this,t,i,r,s,o,a),this.check()}lookAt(e){let{eye:t,center:i=[0,0,0],up:r=[0,1,0]}=e;return Gg(this,t,i,r),this.check()}ortho(e){let{left:t,right:i,bottom:r,top:s,near:o=qg,far:a=Zg}=e;return $g(this,t,i,r,s,o,a),this.check()}orthographic(e){let{fovy:t=ZD,aspect:i=XD,focalDistance:r=1,near:s=qg,far:o=Zg}=e;FE(t);let a=t/2,c=r*Math.tan(a),l=c*i;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:s,far:o})}perspective(e){let{fovy:t=45*Math.PI/180,aspect:i=1,near:r=.1,far:s=500}=e;return FE(t),Ug(this,t,i,r,s),this.check()}determinant(){return kg(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let i=this.getScale(t),r=1/i[0],s=1/i[1],o=1/i[2];return e[0]=this[0]*r,e[1]=this[1]*s,e[2]=this[2]*o,e[3]=0,e[4]=this[4]*r,e[5]=this[5]*s,e[6]=this[6]*o,e[7]=0,e[8]=this[8]*r,e[9]=this[9]*s,e[10]=this[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let i=this.getScale(t),r=1/i[0],s=1/i[1],o=1/i[2];return e[0]=this[0]*r,e[1]=this[1]*s,e[2]=this[2]*o,e[3]=this[4]*r,e[4]=this[5]*s,e[5]=this[6]*o,e[6]=this[8]*r,e[7]=this[9]*s,e[8]=this[10]*o,e}transpose(){return Mg(this,this),this.check()}invert(){return Ag(this,this),this.check()}multiplyLeft(e){return Xa(this,e,this),this.check()}multiplyRight(e){return Xa(this,this,e),this.check()}rotateX(e){return Og(this,this,e),this.check()}rotateY(e){return Dg(this,this,e),this.check()}rotateZ(e){return Ng(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return Bg(this,this,e,t),this.check()}scale(e){return Ig(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return Rg(this,this,e),this.check()}transform(e,t){return e.length===4?(t=Yg(t||[-0,-0,-0,-0],e,this),Xu(t,4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){let{length:i}=e,r;switch(i){case 2:r=gg(t||[-0,-0],e,this);break;case 3:r=qa(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Xu(r,e.length),r}transformAsVector(e,t){let i;switch(e.length){case 2:i=rE(t||[-0,-0],e,this);break;case 3:i=Qu(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Xu(i,e.length),i}transformPoint(e,t){return this.transformAsPoint(e,t)}transformVector(e,t){return this.transformAsPoint(e,t)}transformDirection(e,t){return this.transformAsVector(e,t)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,i){return this.identity().translate([e,t,i])}}});function UE(){let n=new ve(4);return ve!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n[3]=1,n}function t4(n,e,t){t=t*.5;let i=Math.sin(t);return n[0]=i*e[0],n[1]=i*e[1],n[2]=i*e[2],n[3]=Math.cos(t),n}function Kg(n,e,t,i){let r=e[0],s=e[1],o=e[2],a=e[3],c=t[0],l=t[1],u=t[2],f=t[3],d,h,p,m,g;return d=r*c+s*l+o*u+a*f,d<0&&(d=-d,c=-c,l=-l,u=-u,f=-f),1-d>1e-6?(h=Math.acos(d),g=Math.sin(h),p=Math.sin((1-i)*h)/g,m=Math.sin(i*h)/g):(p=1-i,m=i),n[0]=p*r+m*c,n[1]=p*s+m*l,n[2]=p*o+m*u,n[3]=p*a+m*f,n}function n4(n,e){let t=e[0]+e[4]+e[8],i;if(t>0)i=Math.sqrt(t+1),n[3]=.5*i,i=.5/i,n[0]=(e[5]-e[7])*i,n[1]=(e[6]-e[2])*i,n[2]=(e[1]-e[3])*i;else{let r=0;e[4]>e[0]&&(r=1),e[8]>e[r*3+r]&&(r=2);let s=(r+1)%3,o=(r+2)%3;i=Math.sqrt(e[r*3+r]-e[s*3+s]-e[o*3+o]+1),n[r]=.5*i,i=.5/i,n[3]=(e[s*3+o]-e[o*3+s])*i,n[s]=(e[s*3+r]+e[r*3+s])*i,n[o]=(e[o*3+r]+e[r*3+o])*i}return n}var $E,SK,PK,CK,GE=C(()=>{$r();Lg();Za();rf();$E=Hg,SK=function(){let n=Ju(),e=ef(1,0,0),t=ef(0,1,0);return function(i,r,s){let o=Ya(r,s);return o<-.999999?(Gr(n,e,r),Cg(n)<1e-6&&Gr(n,t,r),bg(n,n),t4(i,n,Math.PI),i):o>.999999?(i[0]=0,i[1]=0,i[2]=0,i[3]=1,i):(Gr(n,r,s),i[0]=n[0],i[1]=n[1],i[2]=n[2],i[3]=1+o,$E(i,i))}}(),PK=function(){let n=UE(),e=UE();return function(t,i,r,s,o,a){return Kg(n,i,o,a),Kg(e,r,s,a),Kg(t,n,e,2*a*(1-a)),t}}(),CK=function(){let n=mE();return function(e,t,i,r){return n[0]=i[0],n[3]=i[1],n[6]=i[2],n[1]=r[0],n[4]=r[1],n[7]=r[2],n[2]=-t[0],n[5]=-t[1],n[8]=-t[2],$E(e,n4(e,n))}}()});var TK,LK,MK,AK,VE=C(()=>{TK=Math.PI/2,LK=Math.PI/4,MK=Math.PI/6,AK=Math.PI*2});var Fe=C(()=>{hE();zE();VE();Ks();Lg();Vg();GE();_g();Za();rf()});function Qg(n,e=[],t=0){let i=Math.fround(n),r=n-i;return e[t]=i,e[t+1]=r,e}function WE(n){return n-Math.fround(n)}function jE(n){let e=new Float32Array(32);for(let t=0;t<4;++t)for(let i=0;i<4;++i){let r=t*4+i;Qg(n[i*4+t],e,r*2)}return e}var HE=C(()=>{});function af(n,e=!0){return n??e}function Jg(n=[0,0,0],e=!0){return e?n.map(t=>t/255):[...n]}function YE(n,e=!0){let t=Jg(n.slice(0,3),e),i=Number.isFinite(n[3]),r=i?n[3]:1;return[t[0],t[1],t[2],e&&i?r/255:r]}var e_=C(()=>{});var s4,o4,Vr,qE=C(()=>{s4=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND + +// All these functions are for substituting tan() function from Intel GPU only +const float TWO_PI = 6.2831854820251465; +const float PI_2 = 1.5707963705062866; +const float PI_16 = 0.1963495463132858; + +const float SIN_TABLE_0 = 0.19509032368659973; +const float SIN_TABLE_1 = 0.3826834261417389; +const float SIN_TABLE_2 = 0.5555702447891235; +const float SIN_TABLE_3 = 0.7071067690849304; + +const float COS_TABLE_0 = 0.9807852506637573; +const float COS_TABLE_1 = 0.9238795042037964; +const float COS_TABLE_2 = 0.8314695954322815; +const float COS_TABLE_3 = 0.7071067690849304; + +const float INVERSE_FACTORIAL_3 = 1.666666716337204e-01; // 1/3! +const float INVERSE_FACTORIAL_5 = 8.333333767950535e-03; // 1/5! +const float INVERSE_FACTORIAL_7 = 1.9841270113829523e-04; // 1/7! +const float INVERSE_FACTORIAL_9 = 2.75573188446287533e-06; // 1/9! + +float sin_taylor_fp32(float a) { + float r, s, t, x; + + if (a == 0.0) { + return 0.0; + } + + x = -a * a; + s = a; + r = a; + + r = r * x; + t = r * INVERSE_FACTORIAL_3; + s = s + t; + + r = r * x; + t = r * INVERSE_FACTORIAL_5; + s = s + t; + + r = r * x; + t = r * INVERSE_FACTORIAL_7; + s = s + t; + + r = r * x; + t = r * INVERSE_FACTORIAL_9; + s = s + t; + + return s; +} + +void sincos_taylor_fp32(float a, out float sin_t, out float cos_t) { + if (a == 0.0) { + sin_t = 0.0; + cos_t = 1.0; + } + sin_t = sin_taylor_fp32(a); + cos_t = sqrt(1.0 - sin_t * sin_t); +} + +float tan_taylor_fp32(float a) { + float sin_a; + float cos_a; + + if (a == 0.0) { + return 0.0; + } + + // 2pi range reduction + float z = floor(a / TWO_PI); + float r = a - TWO_PI * z; + + float t; + float q = floor(r / PI_2 + 0.5); + int j = int(q); + + if (j < -2 || j > 2) { + return 1.0 / 0.0; + } + + t = r - PI_2 * q; + + q = floor(t / PI_16 + 0.5); + int k = int(q); + int abs_k = int(abs(float(k))); + + if (abs_k > 4) { + return 1.0 / 0.0; + } else { + t = t - PI_16 * q; + } + + float u = 0.0; + float v = 0.0; + + float sin_t, cos_t; + float s, c; + sincos_taylor_fp32(t, sin_t, cos_t); + + if (k == 0) { + s = sin_t; + c = cos_t; + } else { + if (abs(float(abs_k) - 1.0) < 0.5) { + u = COS_TABLE_0; + v = SIN_TABLE_0; + } else if (abs(float(abs_k) - 2.0) < 0.5) { + u = COS_TABLE_1; + v = SIN_TABLE_1; + } else if (abs(float(abs_k) - 3.0) < 0.5) { + u = COS_TABLE_2; + v = SIN_TABLE_2; + } else if (abs(float(abs_k) - 4.0) < 0.5) { + u = COS_TABLE_3; + v = SIN_TABLE_3; + } + if (k > 0) { + s = u * sin_t + v * cos_t; + c = u * cos_t - v * sin_t; + } else { + s = u * sin_t - v * cos_t; + c = u * cos_t + v * sin_t; + } + } + + if (j == 0) { + sin_a = s; + cos_a = c; + } else if (j == 1) { + sin_a = c; + cos_a = -s; + } else if (j == -1) { + sin_a = -c; + cos_a = s; + } else { + sin_a = -s; + cos_a = -c; + } + return sin_a / cos_a; +} +#endif + +float tan_fp32(float a) { +#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND + return tan_taylor_fp32(a); +#else + return tan(a); +#endif +} +`,o4=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND +const FP32_TWO_PI: f32 = 6.2831854820251465; +const FP32_PI_2: f32 = 1.5707963705062866; +const FP32_PI_16: f32 = 0.1963495463132858; + +const FP32_SIN_TABLE_0: f32 = 0.19509032368659973; +const FP32_SIN_TABLE_1: f32 = 0.3826834261417389; +const FP32_SIN_TABLE_2: f32 = 0.5555702447891235; +const FP32_SIN_TABLE_3: f32 = 0.7071067690849304; + +const FP32_COS_TABLE_0: f32 = 0.9807852506637573; +const FP32_COS_TABLE_1: f32 = 0.9238795042037964; +const FP32_COS_TABLE_2: f32 = 0.8314695954322815; +const FP32_COS_TABLE_3: f32 = 0.7071067690849304; + +const FP32_INVERSE_FACTORIAL_3: f32 = 1.666666716337204e-01; +const FP32_INVERSE_FACTORIAL_5: f32 = 8.333333767950535e-03; +const FP32_INVERSE_FACTORIAL_7: f32 = 1.9841270113829523e-04; +const FP32_INVERSE_FACTORIAL_9: f32 = 2.75573188446287533e-06; +const FP32_OVERFLOW: f32 = 3.402823466e+38; + +fn sin_taylor_fp32(a: f32) -> f32 { + if (a == 0.0) { + return 0.0; + } + + let x = -a * a; + var sum = a; + var term = a; + + term = term * x; + sum = sum + term * FP32_INVERSE_FACTORIAL_3; + term = term * x; + sum = sum + term * FP32_INVERSE_FACTORIAL_5; + term = term * x; + sum = sum + term * FP32_INVERSE_FACTORIAL_7; + term = term * x; + sum = sum + term * FP32_INVERSE_FACTORIAL_9; + + return sum; +} + +fn tan_taylor_fp32(a: f32) -> f32 { + if (a == 0.0) { + return 0.0; + } + + let z = floor(a / FP32_TWO_PI); + let reduced = a - FP32_TWO_PI * z; + + var quadrantValue = floor(reduced / FP32_PI_2 + 0.5); + let quadrant = i32(quadrantValue); + if (quadrant < -2 || quadrant > 2) { + return FP32_OVERFLOW; + } + + var angle = reduced - FP32_PI_2 * quadrantValue; + quadrantValue = floor(angle / FP32_PI_16 + 0.5); + let tableIndex = i32(quadrantValue); + let absoluteTableIndex = abs(tableIndex); + if (absoluteTableIndex > 4) { + return FP32_OVERFLOW; + } + + angle = angle - FP32_PI_16 * quadrantValue; + let sinAngle = sin_taylor_fp32(angle); + let cosAngle = sqrt(1.0 - sinAngle * sinAngle); + + var tableCos = 0.0; + var tableSin = 0.0; + if (absoluteTableIndex == 1) { + tableCos = FP32_COS_TABLE_0; + tableSin = FP32_SIN_TABLE_0; + } else if (absoluteTableIndex == 2) { + tableCos = FP32_COS_TABLE_1; + tableSin = FP32_SIN_TABLE_1; + } else if (absoluteTableIndex == 3) { + tableCos = FP32_COS_TABLE_2; + tableSin = FP32_SIN_TABLE_2; + } else if (absoluteTableIndex == 4) { + tableCos = FP32_COS_TABLE_3; + tableSin = FP32_SIN_TABLE_3; + } + + var sinReduced = sinAngle; + var cosReduced = cosAngle; + if (tableIndex > 0) { + sinReduced = tableCos * sinAngle + tableSin * cosAngle; + cosReduced = tableCos * cosAngle - tableSin * sinAngle; + } else if (tableIndex < 0) { + sinReduced = tableCos * sinAngle - tableSin * cosAngle; + cosReduced = tableCos * cosAngle + tableSin * sinAngle; + } + + var sinValue = 0.0; + var cosValue = 0.0; + if (quadrant == 0) { + sinValue = sinReduced; + cosValue = cosReduced; + } else if (quadrant == 1) { + sinValue = cosReduced; + cosValue = -sinReduced; + } else if (quadrant == -1) { + sinValue = -cosReduced; + cosValue = sinReduced; + } else { + sinValue = -sinReduced; + cosValue = -cosReduced; + } + + return sinValue / cosValue; +} + +fn tan_fp32(a: f32) -> f32 { + return tan_taylor_fp32(a); +} +#else +fn tan_fp32(a: f32) -> f32 { + return tan(a); +} +#endif +`,Vr={name:"fp32",source:o4,vs:s4}});var t_,ZE=C(()=>{t_=` +layout(std140) uniform fp64arithmeticUniforms { + uniform float ONE; + uniform float SPLIT; +} fp64; + +/* +About LUMA_FP64_CODE_ELIMINATION_WORKAROUND + +The purpose of this workaround is to prevent shader compilers from +optimizing away necessary arithmetic operations by swapping their sequences +or transform the equation to some 'equivalent' form. + +These helpers implement Dekker/Veltkamp-style error tracking. If the compiler +folds constants or reassociates the arithmetic, the high/low split can stop +tracking the rounding error correctly. That failure mode tends to look fine in +simple coordinate setup, but then breaks down inside iterative arithmetic such +as fp64 Mandelbrot loops. + +The method is to multiply an artifical variable, ONE, which will be known to +the compiler to be 1 only at runtime. The whole expression is then represented +as a polynomial with respective to ONE. In the coefficients of all terms, only one a +and one b should appear + +err = (a + b) * ONE^6 - a * ONE^5 - (a + b) * ONE^4 + a * ONE^3 - b - (a + b) * ONE^2 + a * ONE +*/ + +float prevent_fp64_optimization(float value) { +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) + return value + fp64.ONE * 0.0; +#else + return value; +#endif +} + +// Divide float number to high and low floats to extend fraction bits +vec2 split(float a) { + // Keep SPLIT as a runtime uniform so the compiler cannot fold the Dekker + // split into a constant expression and reassociate the recovery steps. + float split = prevent_fp64_optimization(fp64.SPLIT); + float t = prevent_fp64_optimization(a * split); + float temp = t - a; + float a_hi = t - temp; + float a_lo = a - a_hi; + return vec2(a_hi, a_lo); +} + +// Divide float number again when high float uses too many fraction bits +vec2 split2(vec2 a) { + vec2 b = split(a.x); + b.y += a.y; + return b; +} + +// Special sum operation when a > b +vec2 quickTwoSum(float a, float b) { +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) + float sum = (a + b) * fp64.ONE; + float err = b - (sum - a) * fp64.ONE; +#else + float sum = a + b; + float err = b - (sum - a); +#endif + return vec2(sum, err); +} + +// General sum operation +vec2 twoSum(float a, float b) { + float s = (a + b); +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) + float v = (s * fp64.ONE - a) * fp64.ONE; + float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE + (b - v); +#else + float v = s - a; + float err = (a - (s - v)) + (b - v); +#endif + return vec2(s, err); +} + +vec2 twoSub(float a, float b) { + float s = (a - b); +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) + float v = (s * fp64.ONE - a) * fp64.ONE; + float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE - (b + v); +#else + float v = s - a; + float err = (a - (s - v)) - (b + v); +#endif + return vec2(s, err); +} + +vec2 twoSqr(float a) { + float prod = a * a; + vec2 a_fp64 = split(a); +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) + float err = ((a_fp64.x * a_fp64.x - prod) * fp64.ONE + 2.0 * a_fp64.x * + a_fp64.y * fp64.ONE * fp64.ONE) + a_fp64.y * a_fp64.y * fp64.ONE * fp64.ONE * fp64.ONE; +#else + float err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y; +#endif + return vec2(prod, err); +} + +vec2 twoProd(float a, float b) { + float prod = a * b; + vec2 a_fp64 = split(a); + vec2 b_fp64 = split(b); + // twoProd is especially sensitive because mul_fp64 and div_fp64 both depend + // on the split terms and cross terms staying in the original evaluation + // order. If the compiler folds or reassociates them, the low part tends to + // collapse to zero or NaN on some drivers. + float highProduct = prevent_fp64_optimization(a_fp64.x * b_fp64.x); + float crossProduct1 = prevent_fp64_optimization(a_fp64.x * b_fp64.y); + float crossProduct2 = prevent_fp64_optimization(a_fp64.y * b_fp64.x); + float lowProduct = prevent_fp64_optimization(a_fp64.y * b_fp64.y); +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) + float err1 = (highProduct - prod) * fp64.ONE; + float err2 = crossProduct1 * fp64.ONE * fp64.ONE; + float err3 = crossProduct2 * fp64.ONE * fp64.ONE * fp64.ONE; + float err4 = lowProduct * fp64.ONE * fp64.ONE * fp64.ONE * fp64.ONE; +#else + float err1 = highProduct - prod; + float err2 = crossProduct1; + float err3 = crossProduct2; + float err4 = lowProduct; +#endif + float err = ((err1 + err2) + err3) + err4; + return vec2(prod, err); +} + +vec2 sum_fp64(vec2 a, vec2 b) { + vec2 s, t; + s = twoSum(a.x, b.x); + t = twoSum(a.y, b.y); + s.y += t.x; + s = quickTwoSum(s.x, s.y); + s.y += t.y; + s = quickTwoSum(s.x, s.y); + return s; +} + +vec2 sub_fp64(vec2 a, vec2 b) { + vec2 s, t; + s = twoSub(a.x, b.x); + t = twoSub(a.y, b.y); + s.y += t.x; + s = quickTwoSum(s.x, s.y); + s.y += t.y; + s = quickTwoSum(s.x, s.y); + return s; +} + +vec2 mul_fp64(vec2 a, vec2 b) { + vec2 prod = twoProd(a.x, b.x); + // y component is for the error + prod.y += a.x * b.y; +#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) + prod = split2(prod); +#endif + prod = quickTwoSum(prod.x, prod.y); + prod.y += a.y * b.x; +#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) + prod = split2(prod); +#endif + prod = quickTwoSum(prod.x, prod.y); + return prod; +} + +vec2 div_fp64(vec2 a, vec2 b) { + float xn = 1.0 / b.x; +#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) + vec2 yn = mul_fp64(a, vec2(xn, 0)); +#else + vec2 yn = a * xn; +#endif + float diff = (sub_fp64(a, mul_fp64(b, yn))).x; + vec2 prod = twoProd(xn, diff); + return sum_fp64(yn, prod); +} + +vec2 sqrt_fp64(vec2 a) { + if (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0); + if (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0); + + float x = 1.0 / sqrt(a.x); + float yn = a.x * x; +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) + vec2 yn_sqr = twoSqr(yn) * fp64.ONE; +#else + vec2 yn_sqr = twoSqr(yn); +#endif + float diff = sub_fp64(a, yn_sqr).x; + vec2 prod = twoProd(x * 0.5, diff); +#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) + return sum_fp64(split(yn), prod); +#else + return sum_fp64(vec2(yn, 0.0), prod); +#endif +} +`});var XE,KE=C(()=>{XE=`struct Fp64F32Bits { + sign: u32, + baseExponent: i32, + significand: u32, + isZero: bool, + isInf: bool, + isNan: bool, +}; + +// Decode an f32 as (-1)^sign * significand * 2^baseExponent. +fn fp64_decode_f32_bits(bits: u32) -> Fp64F32Bits { + let sign = bits >> 31u; + let exponentBits = (bits >> 23u) & 0xffu; + let fraction = bits & 0x7fffffu; + + if (exponentBits == 0xffu) { + return Fp64F32Bits(sign, 0, 0u, false, fraction == 0u, fraction != 0u); + } + if (exponentBits == 0u) { + return Fp64F32Bits(sign, -149, fraction, fraction == 0u, false, false); + } + return Fp64F32Bits(sign, i32(exponentBits) - 150, 0x800000u | fraction, false, false, false); +} + +fn fp64_f32_magnitude_compare(aBits: u32, bBits: u32) -> i32 { + let aMagnitude = aBits & 0x7fffffffu; + let bMagnitude = bBits & 0x7fffffffu; + if (aMagnitude == bMagnitude) { + return 0; + } + return select(-1, 1, aMagnitude > bMagnitude); +} + +fn fp64_make_residual_f32_bits( + exactSign: u32, + exactMagnitude: vec2u, + exactBaseExponent: i32, + highBits: u32 +) -> u32 { + if (fp64_u64_is_zero(exactMagnitude)) { + return 0u; + } + + let high = fp64_decode_f32_bits(highBits); + if (high.isInf || high.isNan) { + return exactSign << 31u; + } + if (high.isZero) { + return fp64_make_f32_bits_from_u64(exactSign, exactMagnitude, exactBaseExponent); + } + + let commonBaseExponent = min(exactBaseExponent, high.baseExponent); + let exactShift = exactBaseExponent - commonBaseExponent; + let highShift = high.baseExponent - commonBaseExponent; + + // A normal two-sum/two-product residual never needs a shift this large. + // This guard gives deterministic underflow behavior outside that contract. + if (exactShift >= 64 || highShift >= 64) { + return exactSign << 31u; + } + + let exactAligned = fp64_u64_shift_left(exactMagnitude, u32(exactShift)); + let highAligned = fp64_u64_shift_left(vec2u(0u, high.significand), u32(highShift)); + let comparison = fp64_u64_compare(exactAligned, highAligned); + if (comparison == 0) { + return 0u; + } + + var residualSign = exactSign; + var residualMagnitude: vec2u; + if (comparison > 0) { + residualMagnitude = fp64_u64_sub(exactAligned, highAligned); + } else { + residualSign = exactSign ^ 1u; + residualMagnitude = fp64_u64_sub(highAligned, exactAligned); + } + return fp64_make_f32_bits_from_u64( + residualSign, + residualMagnitude, + commonBaseExponent + ); +} + +fn fp64_split_accumulator_bits( + sign: u32, + magnitude: vec2u, + baseExponent: i32 +) -> vec2u { + let highBits = fp64_make_f32_bits_from_u64(sign, magnitude, baseExponent); + let lowBits = fp64_make_residual_f32_bits(sign, magnitude, baseExponent, highBits); + return vec2u(highBits, lowBits); +} + +fn fp64_two_sum_integer_bits(aBits: u32, bBits: u32) -> vec2u { + let a = fp64_decode_f32_bits(aBits); + let b = fp64_decode_f32_bits(bBits); + + if (a.isNan || b.isNan) { + return vec2u(0x7fc00000u, 0u); + } + if (a.isInf || b.isInf) { + if (a.isInf && b.isInf && a.sign != b.sign) { + return vec2u(0x7fc00000u, 0u); + } + return select(vec2u(bBits, 0u), vec2u(aBits, 0u), a.isInf); + } + if (a.isZero && b.isZero) { + return vec2u((a.sign & b.sign) << 31u, 0u); + } + if (a.isZero) { + return vec2u(bBits, 0u); + } + if (b.isZero) { + return vec2u(aBits, 0u); + } + + let exponentDifference = select( + b.baseExponent - a.baseExponent, + a.baseExponent - b.baseExponent, + a.baseExponent >= b.baseExponent + ); + + // Beyond half an ulp, rounding cannot change the larger operand. Returning + // the smaller operand intact also avoids an unbounded integer alignment. + // At a power-of-two boundary the spacing below the larger operand is half + // the spacing above it, so an opposite-sign gap-25 operand can still change + // the rounded high limb. Gap 26 is the first universally safe early-out. + if (exponentDifference > 25) { + if (fp64_f32_magnitude_compare(aBits, bBits) >= 0) { + return vec2u(aBits, bBits); + } + return vec2u(bBits, aBits); + } + + let commonBaseExponent = min(a.baseExponent, b.baseExponent); + let aMagnitude = fp64_u64_shift_left( + vec2u(0u, a.significand), + u32(a.baseExponent - commonBaseExponent) + ); + let bMagnitude = fp64_u64_shift_left( + vec2u(0u, b.significand), + u32(b.baseExponent - commonBaseExponent) + ); + + var resultSign = a.sign; + var resultMagnitude: vec2u; + if (a.sign == b.sign) { + resultMagnitude = fp64_u64_add(aMagnitude, bMagnitude); + } else { + let comparison = fp64_u64_compare(aMagnitude, bMagnitude); + if (comparison == 0) { + return vec2u(0u, 0u); + } + if (comparison > 0) { + resultMagnitude = fp64_u64_sub(aMagnitude, bMagnitude); + } else { + resultSign = b.sign; + resultMagnitude = fp64_u64_sub(bMagnitude, aMagnitude); + } + } + + return fp64_split_accumulator_bits(resultSign, resultMagnitude, commonBaseExponent); +} + +fn fp64_two_sum_integer(a: f32, b: f32) -> vec2f { + let resultBits = fp64_two_sum_integer_bits(bitcast(a), bitcast(b)); + return vec2f(bitcast(resultBits.x), bitcast(resultBits.y)); +} + +fn fp64_multiply_significands(a: u32, b: u32) -> vec2u { + let aLow = a & 0xffffu; + let aHigh = a >> 16u; + let bLow = b & 0xffffu; + let bHigh = b >> 16u; + let lowProduct = aLow * bLow; + let crossProduct = aLow * bHigh + aHigh * bLow; + let highProduct = aHigh * bHigh; + + var result = vec2u(0u, lowProduct); + result = fp64_u64_add( + result, + fp64_u64_shift_left(vec2u(0u, crossProduct), 16u) + ); + result = fp64_u64_add(result, vec2u(highProduct, 0u)); + return result; +} + +fn fp64_two_prod_integer_bits(aBits: u32, bBits: u32) -> vec2u { + let a = fp64_decode_f32_bits(aBits); + let b = fp64_decode_f32_bits(bBits); + let resultSign = a.sign ^ b.sign; + + if (a.isNan || b.isNan || ((a.isZero || b.isZero) && (a.isInf || b.isInf))) { + return vec2u(0x7fc00000u, 0u); + } + if (a.isInf || b.isInf) { + return vec2u((resultSign << 31u) | 0x7f800000u, resultSign << 31u); + } + if (a.isZero || b.isZero) { + return vec2u(resultSign << 31u, resultSign << 31u); + } + + let magnitude = fp64_multiply_significands(a.significand, b.significand); + return fp64_split_accumulator_bits( + resultSign, + magnitude, + a.baseExponent + b.baseExponent + ); +} + +fn fp64_two_prod_integer(a: f32, b: f32) -> vec2f { + let resultBits = fp64_two_prod_integer_bits(bitcast(a), bitcast(b)); + return vec2f(bitcast(resultBits.x), bitcast(resultBits.y)); +} + +fn fp64_round_add_integer(a: f32, b: f32) -> f32 { + return fp64_two_sum_integer(a, b).x; +} + +fn fp64_round_mul_integer(a: f32, b: f32) -> f32 { + return fp64_two_prod_integer(a, b).x; +} + +#ifndef LUMA_FP64_PREDICATE_ONLY +fn fp64_f32_finite_exponent(value: Fp64F32Bits) -> i32 { + let mostSignificantBit = 31u - countLeadingZeros(value.significand); + return value.baseExponent + i32(mostSignificantBit); +} + +fn fp64_scale_f32_integer(value: f32, exponent: i32) -> f32 { + let decoded = fp64_decode_f32_bits(bitcast(value)); + if (decoded.isZero || decoded.isInf || decoded.isNan) { + return value; + } + let resultBits = fp64_make_f32_bits_from_u64( + decoded.sign, + vec2u(0u, decoded.significand), + decoded.baseExponent + exponent + ); + return bitcast(resultBits); +} + +// Divide normalized significands so the hardware operation cannot overflow, +// underflow, or flush a subnormal result. Reapply the exponent with integer +// packing, which also produces subnormal correction limbs without relying on +// floating-point arithmetic to preserve them. +fn fp64_divide_f32_integer(aValue: f32, bValue: f32) -> f32 { + let a = fp64_decode_f32_bits(bitcast(aValue)); + let b = fp64_decode_f32_bits(bitcast(bValue)); + if (a.isZero || b.isZero || a.isInf || b.isInf || a.isNan || b.isNan) { + return aValue / bValue; + } + + let aMostSignificantBit = 31u - countLeadingZeros(a.significand); + let bMostSignificantBit = 31u - countLeadingZeros(b.significand); + let normalizedABits = fp64_make_f32_bits_from_u64( + a.sign, + vec2u(0u, a.significand), + -i32(aMostSignificantBit) + ); + let normalizedBBits = fp64_make_f32_bits_from_u64( + b.sign, + vec2u(0u, b.significand), + -i32(bMostSignificantBit) + ); + let normalizedQuotient = bitcast(normalizedABits) / bitcast(normalizedBBits); + let quotient = fp64_decode_f32_bits(bitcast(normalizedQuotient)); + let exponentShift = + a.baseExponent + i32(aMostSignificantBit) - + b.baseExponent - i32(bMostSignificantBit); + let quotientBits = fp64_make_f32_bits_from_u64( + quotient.sign, + vec2u(0u, quotient.significand), + quotient.baseExponent + exponentShift + ); + return bitcast(quotientBits); +} +#endif + +#ifndef LUMA_FP64_PREDICATE_ONLY +fn split(a: f32) -> vec2f { + let aBits = bitcast(a); + let decoded = fp64_decode_f32_bits(aBits); + if (decoded.isZero || decoded.isInf || decoded.isNan) { + return vec2f(a, 0.0); + } + + var roundedHigh = decoded.significand >> 12u; + let remainder = decoded.significand & 0xfffu; + if (remainder > 0x800u || (remainder == 0x800u && (roundedHigh & 1u) == 1u)) { + roundedHigh = roundedHigh + 1u; + } + var highMagnitude = vec2u(0u, roundedHigh << 12u); + var highBits = fp64_make_f32_bits_from_u64( + decoded.sign, + highMagnitude, + decoded.baseExponent + ); + // Rounding the high limb of a maximum-exponent value can overflow even + // though the original value is finite. Truncate only in that boundary case + // so split remains an exact finite decomposition. + if (fp64_decode_f32_bits(highBits).isInf) { + roundedHigh = decoded.significand >> 12u; + highMagnitude = vec2u(0u, roundedHigh << 12u); + highBits = fp64_make_f32_bits_from_u64( + decoded.sign, + highMagnitude, + decoded.baseExponent + ); + } + let lowBits = fp64_make_residual_f32_bits( + decoded.sign, + vec2u(0u, decoded.significand), + decoded.baseExponent, + highBits + ); + return vec2f(bitcast(highBits), bitcast(lowBits)); +} + +fn split2(a: vec2f) -> vec2f { + var result = split(a.x); + result.y = fp64_round_add_integer(result.y, a.y); + return result; +} +#endif + +#ifndef LUMA_FP64_PREDICATE_ONLY +fn quickTwoSum(a: f32, b: f32) -> vec2f { + return fp64_two_sum_integer(a, b); +} +#endif + +fn twoSum(a: f32, b: f32) -> vec2f { + return fp64_two_sum_integer(a, b); +} + +fn twoSub(a: f32, b: f32) -> vec2f { + let bBits = bitcast(b) ^ 0x80000000u; + let resultBits = fp64_two_sum_integer_bits(bitcast(a), bBits); + return vec2f(bitcast(resultBits.x), bitcast(resultBits.y)); +} + +#ifndef LUMA_FP64_PREDICATE_ONLY +fn twoSqr(a: f32) -> vec2f { + return fp64_two_prod_integer(a, a); +} + +fn twoProd(a: f32, b: f32) -> vec2f { + return fp64_two_prod_integer(a, b); +} +#endif + +fn sum_fp64(a: vec2f, b: vec2f) -> vec2f { + var sum = fp64_two_sum_integer(a.x, b.x); + let lowSum = fp64_two_sum_integer(a.y, b.y); + sum.y = fp64_round_add_integer(sum.y, lowSum.x); + sum = fp64_two_sum_integer(sum.x, sum.y); + sum.y = fp64_round_add_integer(sum.y, lowSum.y); + return fp64_two_sum_integer(sum.x, sum.y); +} + +fn sub_fp64(a: vec2f, b: vec2f) -> vec2f { + let negatedB = vec2f( + bitcast(bitcast(b.x) ^ 0x80000000u), + bitcast(bitcast(b.y) ^ 0x80000000u) + ); + return sum_fp64(a, negatedB); +} + +fn mul_fp64(a: vec2f, b: vec2f) -> vec2f { + var product = fp64_two_prod_integer(a.x, b.x); + let crossProduct1 = fp64_round_mul_integer(a.x, b.y); + product.y = fp64_round_add_integer(product.y, crossProduct1); + product = fp64_two_sum_integer(product.x, product.y); + let crossProduct2 = fp64_round_mul_integer(a.y, b.x); + product.y = fp64_round_add_integer(product.y, crossProduct2); + return fp64_two_sum_integer(product.x, product.y); +} + +#ifndef LUMA_FP64_PREDICATE_ONLY +fn fp64_scale_fp64_integer(value: vec2f, exponent: i32) -> vec2f { + let high = fp64_scale_f32_integer(value.x, exponent); + let low = fp64_scale_f32_integer(value.y, exponent); + return sum_fp64(vec2f(high, 0.0), vec2f(low, 0.0)); +} + +fn fp64_div_fp64_normalized(a: vec2f, b: vec2f) -> vec2f { + let quotientHigh = fp64_divide_f32_integer(a.x, b.x); + var quotient = vec2f(quotientHigh, 0.0); + + let remainder = sub_fp64(a, mul_fp64(b, quotient)); + let quotientLow = fp64_divide_f32_integer(remainder.x, b.x); + quotient = sum_fp64(quotient, vec2f(quotientLow, 0.0)); + + let secondRemainder = sub_fp64(a, mul_fp64(b, quotient)); + let correction = fp64_divide_f32_integer(secondRemainder.x, b.x); + return sum_fp64(quotient, vec2f(correction, 0.0)); +} + +fn div_fp64(a: vec2f, b: vec2f) -> vec2f { + let decodedA = fp64_decode_f32_bits(bitcast(a.x)); + let decodedB = fp64_decode_f32_bits(bitcast(b.x)); + if ( + decodedA.isZero || decodedB.isZero || + decodedA.isInf || decodedB.isInf || + decodedA.isNan || decodedB.isNan + ) { + return fp64_div_fp64_normalized(a, b); + } + + let exponentA = fp64_f32_finite_exponent(decodedA); + let exponentB = fp64_f32_finite_exponent(decodedB); + // Correct the quotient near unity so b * q and the remainder stay clear of + // both f32 underflow and overflow. The exponent difference is applied once. + let normalizedA = fp64_scale_fp64_integer(a, -exponentA); + let normalizedB = fp64_scale_fp64_integer(b, -exponentB); + let normalizedQuotient = fp64_div_fp64_normalized(normalizedA, normalizedB); + return fp64_scale_fp64_integer(normalizedQuotient, exponentA - exponentB); +} + +fn fp64_sqrt_fp64_normalized(a: vec2f) -> vec2f { + let estimate = sqrt(a.x); + let difference = sub_fp64(a, fp64_two_prod_integer(estimate, estimate)).x; + let denominator = fp64_round_add_integer(estimate, estimate); + let correction = fp64_divide_f32_integer(difference, denominator); + return sum_fp64(vec2f(estimate, 0.0), vec2f(correction, 0.0)); +} + +fn sqrt_fp64(a: vec2f) -> vec2f { + let decoded = fp64_decode_f32_bits(bitcast(a.x)); + let decodedLow = fp64_decode_f32_bits(bitcast(a.y)); + if (decoded.isZero && decodedLow.isZero) { + return vec2f(0.0, 0.0); + } + if (decoded.sign == 1u) { + let nanValue = fp64_nan(a.x); + return vec2f(nanValue, nanValue); + } + + if (decoded.isInf || decoded.isNan) { + return fp64_sqrt_fp64_normalized(a); + } + let exponent = fp64_f32_finite_exponent(decoded); + // An even scale lets the final square-root rescale use an integer exponent. + let evenExponent = exponent - (exponent & 1); + let normalizedA = fp64_scale_fp64_integer(a, -evenExponent); + let normalizedRoot = fp64_sqrt_fp64_normalized(normalizedA); + return fp64_scale_fp64_integer(normalizedRoot, evenExponent / 2); +} +#endif +`});var QE,JE=C(()=>{KE();QE=`struct Fp64ArithmeticUniforms { + ONE: f32, + SPLIT: f32, +}; + +@group(0) @binding(auto) var fp64arithmetic : Fp64ArithmeticUniforms; + +#ifndef LUMA_FP64_F32_INPUT_ONLY +struct Fp64Bits { + sign: u32, + exponent: i32, + significand: vec2u, + isZero: bool, + isInf: bool, + isNan: bool, +}; +#endif + +#ifndef LUMA_FP64_PREDICATE_ONLY +fn fp64_nan(seed: f32) -> f32 { + let nanBits = 0x7fc00000u | select(0u, 1u, seed < 0.0); + return bitcast(nanBits); +} +#endif + +fn fp64_u64_is_zero(value: vec2u) -> bool { + return value.x == 0u && value.y == 0u; +} + +fn fp64_u64_compare(a: vec2u, b: vec2u) -> i32 { + if (a.x != b.x) { + return select(-1, 1, a.x > b.x); + } + if (a.y != b.y) { + return select(-1, 1, a.y > b.y); + } + return 0; +} + +fn fp64_u64_add(a: vec2u, b: vec2u) -> vec2u { + let low = a.y + b.y; + let carry = select(0u, 1u, low < a.y); + return vec2u(a.x + b.x + carry, low); +} + +fn fp64_u64_sub(a: vec2u, b: vec2u) -> vec2u { + let borrow = select(0u, 1u, a.y < b.y); + return vec2u(a.x - b.x - borrow, a.y - b.y); +} + +fn fp64_u64_shift_left(value: vec2u, shift: u32) -> vec2u { + if (shift == 0u) { + return value; + } + if (shift < 32u) { + return vec2u((value.x << shift) | (value.y >> (32u - shift)), value.y << shift); + } + if (shift == 32u) { + return vec2u(value.y, 0u); + } + if (shift < 64u) { + return vec2u(value.y << (shift - 32u), 0u); + } + return vec2u(0u); +} + +fn fp64_u64_shift_right(value: vec2u, shift: u32) -> vec2u { + if (shift == 0u) { + return value; + } + if (shift < 32u) { + return vec2u(value.x >> shift, (value.y >> shift) | (value.x << (32u - shift))); + } + if (shift == 32u) { + return vec2u(0u, value.x); + } + if (shift < 64u) { + return vec2u(0u, value.x >> (shift - 32u)); + } + return vec2u(0u); +} + +fn fp64_u64_get_bit(value: vec2u, bitIndex: u32) -> bool { + if (bitIndex >= 64u) { + return false; + } + if (bitIndex >= 32u) { + return ((value.x >> (bitIndex - 32u)) & 1u) != 0u; + } + return ((value.y >> bitIndex) & 1u) != 0u; +} + +fn fp64_u64_has_bits_below(value: vec2u, bitCount: u32) -> bool { + if (bitCount == 0u) { + return false; + } + if (bitCount >= 64u) { + return !fp64_u64_is_zero(value); + } + if (bitCount > 32u) { + let highBitCount = bitCount - 32u; + let highMask = (1u << highBitCount) - 1u; + return value.y != 0u || (value.x & highMask) != 0u; + } + if (bitCount == 32u) { + return value.y != 0u; + } + let lowMask = (1u << bitCount) - 1u; + return (value.y & lowMask) != 0u; +} + +#ifndef LUMA_FP64_F32_INPUT_ONLY +fn fp64_u64_shift_right_sticky(value: vec2u, shift: u32) -> vec2u { + var shifted = fp64_u64_shift_right(value, shift); + if (fp64_u64_has_bits_below(value, shift)) { + shifted.y = shifted.y | 1u; + } + return shifted; +} +#endif + +fn fp64_u64_count_leading_zeros(value: vec2u) -> u32 { + if (value.x != 0u) { + return countLeadingZeros(value.x); + } + return 32u + countLeadingZeros(value.y); +} + +fn fp64_round_shift_right_to_u32(value: vec2u, shift: u32) -> u32 { + if (shift == 0u) { + return value.y; + } + + let truncated = fp64_u64_shift_right(value, shift); + var rounded = truncated.y; + let guard = fp64_u64_get_bit(value, shift - 1u); + let hasTrailingBits = fp64_u64_has_bits_below(value, shift - 1u); + if (guard && (hasTrailingBits || (rounded & 1u) == 1u)) { + rounded = rounded + 1u; + } + return rounded; +} + +#ifndef LUMA_FP64_F32_INPUT_ONLY +fn fp64_round_shift_right(value: vec2u, shift: u32) -> vec2u { + if (shift == 0u) { + return value; + } + + var rounded = fp64_u64_shift_right(value, shift); + let guard = fp64_u64_get_bit(value, shift - 1u); + let hasTrailingBits = fp64_u64_has_bits_below(value, shift - 1u); + if (guard && (hasTrailingBits || (rounded.y & 1u) == 1u)) { + rounded = fp64_u64_add(rounded, vec2u(0u, 1u)); + } + return rounded; +} +#endif + +fn fp64_make_f32_bits_from_u64(sign: u32, significand: vec2u, baseExponent: i32) -> u32 { + if (fp64_u64_is_zero(significand)) { + return sign << 31u; + } + + let leadingZeros = fp64_u64_count_leading_zeros(significand); + let mostSignificantBit = 63u - leadingZeros; + var exponent = baseExponent + i32(mostSignificantBit); + + if (exponent > 127) { + return (sign << 31u) | 0x7f800000u; + } + + if (exponent >= -126) { + let shift = i32(mostSignificantBit) - 23; + var significand24: u32; + if (shift > 0) { + significand24 = fp64_round_shift_right_to_u32(significand, u32(shift)); + } else { + significand24 = fp64_u64_shift_left(significand, u32(-shift)).y; + } + + if (significand24 >= 0x1000000u) { + significand24 = significand24 >> 1u; + exponent = exponent + 1; + if (exponent > 127) { + return (sign << 31u) | 0x7f800000u; + } + } + + return (sign << 31u) | (u32(exponent + 127) << 23u) | (significand24 & 0x7fffffu); + } + + let scaleExponent = baseExponent + 149; + var mantissa: u32; + if (scaleExponent >= 0) { + mantissa = fp64_u64_shift_left(significand, u32(scaleExponent)).y; + } else { + mantissa = fp64_round_shift_right_to_u32(significand, u32(-scaleExponent)); + } + + if (mantissa >= 0x800000u) { + return (sign << 31u) | 0x00800000u; + } + return (sign << 31u) | mantissa; +} + +#ifndef LUMA_FP64_F32_INPUT_ONLY +fn fp64_decode_bits(bits: vec2u) -> Fp64Bits { + let sign = bits.x >> 31u; + let exponentBits = (bits.x >> 20u) & 0x7ffu; + let fractionHigh = bits.x & 0xfffffu; + let fractionLow = bits.y; + let fraction = vec2u(fractionHigh, fractionLow); + + if (exponentBits == 0x7ffu) { + let isInf = fp64_u64_is_zero(fraction); + return Fp64Bits(sign, 0, vec2u(0u), false, isInf, !isInf); + } + + if (exponentBits == 0u) { + let isZero = fp64_u64_is_zero(fraction); + return Fp64Bits(sign, -1022, fraction, isZero, false, false); + } + + return Fp64Bits(sign, i32(exponentBits) - 1023, vec2u((1u << 20u) | fractionHigh, fractionLow), false, false, false); +} + +fn fp64_finite_magnitude_compare(a: Fp64Bits, b: Fp64Bits) -> i32 { + if (a.exponent != b.exponent) { + return select(-1, 1, a.exponent > b.exponent); + } + return fp64_u64_compare(a.significand, b.significand); +} +#endif + +#ifndef LUMA_FP64_F32_INPUT_ONLY +struct Fp64RawF32Bits { + sign: u32, + baseExponent: i32, + significand: u32, + isZero: bool, + isInf: bool, + isNan: bool, +}; + +// Decode an f32 as (-1)^sign * significand * 2^baseExponent. This shared +// integer representation lets normalization remain independent of the +// selected double-single arithmetic implementation. +fn fp64_decode_raw_f32_bits(bits: u32) -> Fp64RawF32Bits { + let sign = bits >> 31u; + let exponentBits = (bits >> 23u) & 0xffu; + let fraction = bits & 0x7fffffu; + + if (exponentBits == 0xffu) { + return Fp64RawF32Bits(sign, 0, 0u, false, fraction == 0u, fraction != 0u); + } + if (exponentBits == 0u) { + return Fp64RawF32Bits(sign, -149, fraction, fraction == 0u, false, false); + } + return Fp64RawF32Bits( + sign, + i32(exponentBits) - 150, + 0x800000u | fraction, + false, + false, + false + ); +} + +fn fp64_raw_f32_magnitude_compare(aBits: u32, bBits: u32) -> i32 { + let aMagnitude = aBits & 0x7fffffffu; + let bMagnitude = bBits & 0x7fffffffu; + if (aMagnitude == bMagnitude) { + return 0; + } + return select(-1, 1, aMagnitude > bMagnitude); +} + +fn fp64_make_raw_residual_f32_bits( + exactSign: u32, + exactMagnitude: vec2u, + exactBaseExponent: i32, + highBits: u32 +) -> u32 { + if (fp64_u64_is_zero(exactMagnitude)) { + return 0u; + } + + let high = fp64_decode_raw_f32_bits(highBits); + if (high.isInf || high.isNan) { + return 0u; + } + if (high.isZero) { + return fp64_make_f32_bits_from_u64(exactSign, exactMagnitude, exactBaseExponent); + } + + let commonBaseExponent = min(exactBaseExponent, high.baseExponent); + let exactShift = exactBaseExponent - commonBaseExponent; + let highShift = high.baseExponent - commonBaseExponent; + if (exactShift >= 64 || highShift >= 64) { + return 0u; + } + + let exactAligned = fp64_u64_shift_left(exactMagnitude, u32(exactShift)); + let highAligned = fp64_u64_shift_left(vec2u(0u, high.significand), u32(highShift)); + let comparison = fp64_u64_compare(exactAligned, highAligned); + if (comparison == 0) { + return 0u; + } + + var residualSign = exactSign; + var residualMagnitude: vec2u; + if (comparison > 0) { + residualMagnitude = fp64_u64_sub(exactAligned, highAligned); + } else { + residualSign = exactSign ^ 1u; + residualMagnitude = fp64_u64_sub(highAligned, exactAligned); + } + return fp64_make_f32_bits_from_u64( + residualSign, + residualMagnitude, + commonBaseExponent + ); +} + +fn fp64_split_raw_accumulator_bits( + sign: u32, + magnitude: vec2u, + baseExponent: i32 +) -> vec2u { + if (fp64_u64_is_zero(magnitude)) { + return vec2u(0u); + } + let highBits = fp64_make_f32_bits_from_u64(sign, magnitude, baseExponent); + let rawLowBits = fp64_make_raw_residual_f32_bits(sign, magnitude, baseExponent, highBits); + let lowBits = select(rawLowBits, 0u, (rawLowBits & 0x7fffffffu) == 0u); + if ((highBits & 0x7fffffffu) == 0u && (lowBits & 0x7fffffffu) == 0u) { + return vec2u(0u); + } + return vec2u(highBits, lowBits); +} +#endif + +#ifndef LUMA_FP64_F32_INPUT_ONLY +// Round an arithmetic accumulator to binary64 before splitting it. The +// aligned add/subtract paths retain three guard bits plus a sticky bit, which +// is sufficient for round-to-nearest-even at the binary64 boundary. +fn fp64_split_binary64_accumulator_bits( + sign: u32, + magnitude: vec2u, + baseExponent: i32 +) -> vec2u { + if (fp64_u64_is_zero(magnitude)) { + return vec2u(0u); + } + + let mostSignificantBit = 63u - fp64_u64_count_leading_zeros(magnitude); + let exponent = baseExponent + i32(mostSignificantBit); + if (exponent > 1023) { + return vec2u((sign << 31u) | 0x7f800000u, 0u); + } + + var roundedMagnitude = magnitude; + var roundedBaseExponent = baseExponent; + if (exponent >= -1022) { + if (mostSignificantBit > 52u) { + let shift = mostSignificantBit - 52u; + roundedMagnitude = fp64_round_shift_right(magnitude, shift); + roundedBaseExponent = baseExponent + i32(shift); + } + } else { + let shift = -1074 - baseExponent; + if (shift > 0) { + roundedMagnitude = fp64_round_shift_right(magnitude, u32(shift)); + roundedBaseExponent = -1074; + } + } + + if (fp64_u64_is_zero(roundedMagnitude)) { + return vec2u(0u); + } + return fp64_split_raw_accumulator_bits(sign, roundedMagnitude, roundedBaseExponent); +} +#endif + +#ifndef LUMA_FP64_PREDICATE_ONLY +fn fp64_add_raw_f32_bits(aBits: u32, bBits: u32) -> vec2u { + let a = fp64_decode_raw_f32_bits(aBits); + let b = fp64_decode_raw_f32_bits(bBits); + + if (a.isNan || b.isNan) { + return vec2u(0x7fc00000u, 0u); + } + if (a.isInf || b.isInf) { + if (a.isInf && b.isInf && a.sign != b.sign) { + return vec2u(0x7fc00000u, 0u); + } + return select(vec2u(bBits, 0u), vec2u(aBits, 0u), a.isInf); + } + if (a.isZero && b.isZero) { + return vec2u(0u); + } + if (a.isZero) { + return vec2u(bBits, 0u); + } + if (b.isZero) { + return vec2u(aBits, 0u); + } + + let exponentDifference = abs(a.baseExponent - b.baseExponent); + if (exponentDifference > 25) { + if (fp64_raw_f32_magnitude_compare(aBits, bBits) >= 0) { + return vec2u(aBits, bBits); + } + return vec2u(bBits, aBits); + } + + let commonBaseExponent = min(a.baseExponent, b.baseExponent); + let aMagnitude = fp64_u64_shift_left( + vec2u(0u, a.significand), + u32(a.baseExponent - commonBaseExponent) + ); + let bMagnitude = fp64_u64_shift_left( + vec2u(0u, b.significand), + u32(b.baseExponent - commonBaseExponent) + ); + + var resultSign = a.sign; + var resultMagnitude: vec2u; + if (a.sign == b.sign) { + resultMagnitude = fp64_u64_add(aMagnitude, bMagnitude); + } else { + let comparison = fp64_u64_compare(aMagnitude, bMagnitude); + if (comparison == 0) { + return vec2u(0u); + } + if (comparison > 0) { + resultMagnitude = fp64_u64_sub(aMagnitude, bMagnitude); + } else { + resultSign = b.sign; + resultMagnitude = fp64_u64_sub(bMagnitude, aMagnitude); + } + } + + return fp64_split_raw_accumulator_bits( + resultSign, + resultMagnitude, + commonBaseExponent + ); +} +#endif + +#ifndef LUMA_FP64_F32_INPUT_ONLY +fn fp64_add_aligned_magnitudes_to_fp64_bits( + sign: u32, + larger: Fp64Bits, + smaller: Fp64Bits +) -> vec2u { + let largeSignificand = fp64_u64_shift_left(larger.significand, 3u); + let smallSignificand = fp64_u64_shift_right_sticky( + fp64_u64_shift_left(smaller.significand, 3u), + u32(larger.exponent - smaller.exponent) + ); + let resultSignificand = fp64_u64_add(largeSignificand, smallSignificand); + return fp64_split_binary64_accumulator_bits( + sign, + resultSignificand, + larger.exponent - 55 + ); +} + +fn fp64_sub_aligned_magnitudes_to_fp64_bits( + sign: u32, + larger: Fp64Bits, + smaller: Fp64Bits +) -> vec2u { + let largeSignificand = fp64_u64_shift_left(larger.significand, 3u); + let smallSignificand = fp64_u64_shift_right_sticky( + fp64_u64_shift_left(smaller.significand, 3u), + u32(larger.exponent - smaller.exponent) + ); + let resultSignificand = fp64_u64_sub(largeSignificand, smallSignificand); + return fp64_split_binary64_accumulator_bits( + sign, + resultSignificand, + larger.exponent - 55 + ); +} + +fn fp64_add_aligned_magnitudes_to_f32_bits(sign: u32, larger: Fp64Bits, smaller: Fp64Bits) -> u32 { + let largeSignificand = fp64_u64_shift_left(larger.significand, 3u); + let smallSignificand = fp64_u64_shift_right_sticky( + fp64_u64_shift_left(smaller.significand, 3u), + u32(larger.exponent - smaller.exponent) + ); + let resultSignificand = fp64_u64_add(largeSignificand, smallSignificand); + return fp64_make_f32_bits_from_u64(sign, resultSignificand, larger.exponent - 55); +} + +fn fp64_sub_aligned_magnitudes_to_f32_bits(sign: u32, larger: Fp64Bits, smaller: Fp64Bits) -> u32 { + let largeSignificand = fp64_u64_shift_left(larger.significand, 3u); + let smallSignificand = fp64_u64_shift_right_sticky( + fp64_u64_shift_left(smaller.significand, 3u), + u32(larger.exponent - smaller.exponent) + ); + let resultSignificand = fp64_u64_sub(largeSignificand, smallSignificand); + return fp64_make_f32_bits_from_u64(sign, resultSignificand, larger.exponent - 55); +} + +// Subtract two raw binary64 values and round the exact result once to f32. +// The input words are canonical high/low words: .x contains sign/exponent/high +// fraction bits, and .y contains the low 32 fraction bits. +fn sub_fp64u32_to_f32_bits(aBits: vec2u, bBits: vec2u) -> u32 { + let a = fp64_decode_bits(aBits); + let b = fp64_decode_bits(bBits); + let bSubtractionSign = b.sign ^ 1u; + + if (a.isNan || b.isNan) { + return 0x7fc00000u; + } + if (a.isInf && b.isInf) { + if (a.sign == bSubtractionSign) { + return (a.sign << 31u) | 0x7f800000u; + } + return 0x7fc00000u; + } + if (a.isInf) { + return (a.sign << 31u) | 0x7f800000u; + } + if (b.isInf) { + return (bSubtractionSign << 31u) | 0x7f800000u; + } + if (a.isZero && b.isZero) { + return select(0u, 0x80000000u, a.sign == 1u && b.sign == 0u); + } + + let magnitudeComparison = fp64_finite_magnitude_compare(a, b); + if (a.sign == bSubtractionSign) { + if (magnitudeComparison >= 0) { + return fp64_add_aligned_magnitudes_to_f32_bits(a.sign, a, b); + } + return fp64_add_aligned_magnitudes_to_f32_bits(a.sign, b, a); + } + + if (magnitudeComparison == 0) { + return 0u; + } + if (magnitudeComparison > 0) { + return fp64_sub_aligned_magnitudes_to_f32_bits(a.sign, a, b); + } + return fp64_sub_aligned_magnitudes_to_f32_bits(bSubtractionSign, b, a); +} + +fn sub_fp64u32_to_f32(aBits: vec2u, bBits: vec2u) -> f32 { + return bitcast(sub_fp64u32_to_f32_bits(aBits, bBits)); +} + +// Subtract two raw binary64 values, round once to binary64, then split the +// result into normalized f32 limbs. Finite results must fit within the f32 +// exponent range; larger magnitudes map to infinity and smaller magnitudes +// map to zero. The input words use canonical high/low word order. +fn sub_fp64u32_to_fp64_bits(aBits: vec2u, bBits: vec2u) -> vec2u { + let a = fp64_decode_bits(aBits); + let b = fp64_decode_bits(bBits); + let bSubtractionSign = b.sign ^ 1u; + + if (a.isNan || b.isNan) { + return vec2u(0x7fc00000u, 0u); + } + if (a.isInf && b.isInf) { + if (a.sign == bSubtractionSign) { + return vec2u((a.sign << 31u) | 0x7f800000u, 0u); + } + return vec2u(0x7fc00000u, 0u); + } + if (a.isInf) { + return vec2u((a.sign << 31u) | 0x7f800000u, 0u); + } + if (b.isInf) { + return vec2u((bSubtractionSign << 31u) | 0x7f800000u, 0u); + } + if (a.isZero && b.isZero) { + return vec2u(0u); + } + + let magnitudeComparison = fp64_finite_magnitude_compare(a, b); + if (a.sign == bSubtractionSign) { + if (magnitudeComparison >= 0) { + return fp64_add_aligned_magnitudes_to_fp64_bits(a.sign, a, b); + } + return fp64_add_aligned_magnitudes_to_fp64_bits(a.sign, b, a); + } + + if (magnitudeComparison == 0) { + return vec2u(0u); + } + if (magnitudeComparison > 0) { + return fp64_sub_aligned_magnitudes_to_fp64_bits(a.sign, a, b); + } + return fp64_sub_aligned_magnitudes_to_fp64_bits(bSubtractionSign, b, a); +} + +fn sub_fp64u32_to_fp64(aBits: vec2u, bBits: vec2u) -> vec2f { + let resultBits = sub_fp64u32_to_fp64_bits(aBits, bBits); + return vec2f(bitcast(resultBits.x), bitcast(resultBits.y)); +} +#endif + +#ifndef LUMA_FP64_PREDICATE_ONLY +fn fp64_runtime_zero() -> f32 { + return fp64arithmetic.ONE * 0.0; +} + +fn prevent_fp64_optimization(value: f32) -> f32 { +#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND + return value + fp64_runtime_zero(); +#else + return value; +#endif +} +#endif + +#ifdef LUMA_FP64_INTEGER_ARITHMETIC +${XE} +#else +fn split(a: f32) -> vec2f { + let splitValue = prevent_fp64_optimization(fp64arithmetic.SPLIT + fp64_runtime_zero()); + let t = prevent_fp64_optimization(a * splitValue); + let temp = prevent_fp64_optimization(t - a); + let aHi = prevent_fp64_optimization(t - temp); + let aLo = prevent_fp64_optimization(a - aHi); + return vec2f(aHi, aLo); +} + +fn split2(a: vec2f) -> vec2f { + var b = split(a.x); + b.y = b.y + a.y; + return b; +} + +fn quickTwoSum(a: f32, b: f32) -> vec2f { +#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND + let sum = prevent_fp64_optimization((a + b) * fp64arithmetic.ONE); + let err = prevent_fp64_optimization(b - (sum - a) * fp64arithmetic.ONE); +#else + let sum = prevent_fp64_optimization(a + b); + let err = prevent_fp64_optimization(b - (sum - a)); +#endif + return vec2f(sum, err); +} + +fn twoSum(a: f32, b: f32) -> vec2f { + let s = prevent_fp64_optimization(a + b); +#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND + let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE); + let err = + prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) * + fp64arithmetic.ONE * + fp64arithmetic.ONE * + fp64arithmetic.ONE) + + prevent_fp64_optimization(b - v); +#else + let v = prevent_fp64_optimization(s - a); + let err = prevent_fp64_optimization(a - (s - v)) + prevent_fp64_optimization(b - v); +#endif + return vec2f(s, err); +} + +fn twoSub(a: f32, b: f32) -> vec2f { + let s = prevent_fp64_optimization(a - b); +#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND + let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE); + let err = + prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) * + fp64arithmetic.ONE * + fp64arithmetic.ONE * + fp64arithmetic.ONE) - + prevent_fp64_optimization(b + v); +#else + let v = prevent_fp64_optimization(s - a); + let err = prevent_fp64_optimization(a - (s - v)) - prevent_fp64_optimization(b + v); +#endif + return vec2f(s, err); +} + +fn twoSqr(a: f32) -> vec2f { + let prod = prevent_fp64_optimization(a * a); + let aFp64 = split(a); + let highProduct = prevent_fp64_optimization(aFp64.x * aFp64.x); + let crossProduct = prevent_fp64_optimization(2.0 * aFp64.x * aFp64.y); + let lowProduct = prevent_fp64_optimization(aFp64.y * aFp64.y); +#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND + let err = + (prevent_fp64_optimization(highProduct - prod) * fp64arithmetic.ONE + + crossProduct * fp64arithmetic.ONE * fp64arithmetic.ONE) + + lowProduct * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE; +#else + let err = ((prevent_fp64_optimization(highProduct - prod) + crossProduct) + lowProduct); +#endif + return vec2f(prod, err); +} + +fn twoProd(a: f32, b: f32) -> vec2f { + let prod = prevent_fp64_optimization(a * b); + let aFp64 = split(a); + let bFp64 = split(b); + let highProduct = prevent_fp64_optimization(aFp64.x * bFp64.x); + let crossProduct1 = prevent_fp64_optimization(aFp64.x * bFp64.y); + let crossProduct2 = prevent_fp64_optimization(aFp64.y * bFp64.x); + let lowProduct = prevent_fp64_optimization(aFp64.y * bFp64.y); +#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND + let err1 = (highProduct - prod) * fp64arithmetic.ONE; + let err2 = crossProduct1 * fp64arithmetic.ONE * fp64arithmetic.ONE; + let err3 = crossProduct2 * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE; + let err4 = + lowProduct * + fp64arithmetic.ONE * + fp64arithmetic.ONE * + fp64arithmetic.ONE * + fp64arithmetic.ONE; +#else + let err1 = highProduct - prod; + let err2 = crossProduct1; + let err3 = crossProduct2; + let err4 = lowProduct; +#endif + let err12InputA = prevent_fp64_optimization(err1); + let err12InputB = prevent_fp64_optimization(err2); + let err12 = prevent_fp64_optimization(err12InputA + err12InputB); + let err123InputA = prevent_fp64_optimization(err12); + let err123InputB = prevent_fp64_optimization(err3); + let err123 = prevent_fp64_optimization(err123InputA + err123InputB); + let err1234InputA = prevent_fp64_optimization(err123); + let err1234InputB = prevent_fp64_optimization(err4); + let err = prevent_fp64_optimization(err1234InputA + err1234InputB); + return vec2f(prod, err); +} + +fn sum_fp64(a: vec2f, b: vec2f) -> vec2f { + var s = twoSum(a.x, b.x); + let t = twoSum(a.y, b.y); + s.y = prevent_fp64_optimization(s.y + t.x); + s = quickTwoSum(s.x, s.y); + s.y = prevent_fp64_optimization(s.y + t.y); + s = quickTwoSum(s.x, s.y); + return s; +} + +fn sub_fp64(a: vec2f, b: vec2f) -> vec2f { + var s = twoSub(a.x, b.x); + let t = twoSub(a.y, b.y); + s.y = prevent_fp64_optimization(s.y + t.x); + s = quickTwoSum(s.x, s.y); + s.y = prevent_fp64_optimization(s.y + t.y); + s = quickTwoSum(s.x, s.y); + return s; +} + +fn mul_fp64(a: vec2f, b: vec2f) -> vec2f { + var prod = twoProd(a.x, b.x); + let crossProduct1 = prevent_fp64_optimization(a.x * b.y); + prod.y = prevent_fp64_optimization(prod.y + crossProduct1); +#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND + prod = split2(prod); +#endif + prod = quickTwoSum(prod.x, prod.y); + let crossProduct2 = prevent_fp64_optimization(a.y * b.x); + prod.y = prevent_fp64_optimization(prod.y + crossProduct2); +#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND + prod = split2(prod); +#endif + prod = quickTwoSum(prod.x, prod.y); + return prod; +} + +#ifndef LUMA_FP64_PREDICATE_ONLY +fn div_fp64(a: vec2f, b: vec2f) -> vec2f { + let xn = prevent_fp64_optimization(1.0 / b.x); + let yn = mul_fp64(a, vec2f(xn, fp64_runtime_zero())); + let diff = prevent_fp64_optimization(sub_fp64(a, mul_fp64(b, yn)).x); + let prod = twoProd(xn, diff); + return sum_fp64(yn, prod); +} + +fn sqrt_fp64(a: vec2f) -> vec2f { + if (a.x == 0.0 && a.y == 0.0) { + return vec2f(0.0, 0.0); + } + if (a.x < 0.0) { + let nanValue = fp64_nan(a.x); + return vec2f(nanValue, nanValue); + } + + let x = prevent_fp64_optimization(1.0 / sqrt(a.x)); + let yn = prevent_fp64_optimization(a.x * x); +#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND + let ynSqr = twoSqr(yn) * fp64arithmetic.ONE; +#else + let ynSqr = twoSqr(yn); +#endif + let diff = prevent_fp64_optimization(sub_fp64(a, ynSqr).x); + let prod = twoProd(prevent_fp64_optimization(x * 0.5), diff); +#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND + return sum_fp64(split(yn), prod); +#else + return sum_fp64(vec2f(yn, 0.0), prod); +#endif +} +#endif +#endif + +#ifndef LUMA_FP64_PREDICATE_ONLY +fn fp64_f32_bits_is_nan(bits: u32) -> bool { + return (bits & 0x7fffffffu) > 0x7f800000u; +} + +fn fp64_f32_bits_is_inf(bits: u32) -> bool { + return (bits & 0x7fffffffu) == 0x7f800000u; +} + +fn fp64_compare_f32_bits(aBits: u32, bBits: u32) -> i32 { + let aMagnitude = aBits & 0x7fffffffu; + let bMagnitude = bBits & 0x7fffffffu; + if (aMagnitude == 0u && bMagnitude == 0u) { + return 0; + } + let aSign = aBits >> 31u; + let bSign = bBits >> 31u; + if (aSign != bSign) { + return select(1, -1, aSign == 1u); + } + if (aMagnitude == bMagnitude) { + return 0; + } + let magnitudeComparison = select(-1, 1, aMagnitude > bMagnitude); + return select(magnitudeComparison, -magnitudeComparison, aSign == 1u); +} + +// Normalize an arbitrary pair of finite f32 limbs with integer accumulation. +// This is independent of LUMA_FP64_INTEGER_ARITHMETIC and canonicalizes every +// representation of zero to vec2f(+0.0, +0.0). +fn normalize_fp64(value: vec2f) -> vec2f { + let resultBits = fp64_add_raw_f32_bits(bitcast(value.x), bitcast(value.y)); + return vec2f(bitcast(resultBits.x), bitcast(resultBits.y)); +} + +fn is_nan_fp64(value: vec2f) -> bool { + let normalized = normalize_fp64(value); + return fp64_f32_bits_is_nan(bitcast(normalized.x)) || + fp64_f32_bits_is_nan(bitcast(normalized.y)); +} + +fn is_finite_fp64(value: vec2f) -> bool { + let normalized = normalize_fp64(value); + let highBits = bitcast(normalized.x); + let lowBits = bitcast(normalized.y); + return !fp64_f32_bits_is_nan(highBits) && !fp64_f32_bits_is_nan(lowBits) && + !fp64_f32_bits_is_inf(highBits) && !fp64_f32_bits_is_inf(lowBits); +} + +// Returns -1, 0, or 1. NaN is unordered and returns 0; call is_nan_fp64 or +// is_finite_fp64 first when 0 must mean a finite zero. +fn sign_fp64(value: vec2f) -> i32 { + let normalized = normalize_fp64(value); + let highBits = bitcast(normalized.x); + let lowBits = bitcast(normalized.y); + if (fp64_f32_bits_is_nan(highBits) || fp64_f32_bits_is_nan(lowBits)) { + return 0; + } + if ((highBits & 0x7fffffffu) != 0u) { + return select(1, -1, (highBits >> 31u) == 1u); + } + if ((lowBits & 0x7fffffffu) != 0u) { + return select(1, -1, (lowBits >> 31u) == 1u); + } + return 0; +} + +// Compares double-single values and returns -1, 0, or 1. NaN is unordered +// and returns 0; callers that require equality semantics must first check +// is_nan_fp64 or is_finite_fp64. +fn compare_fp64(a: vec2f, b: vec2f) -> i32 { + let normalizedA = normalize_fp64(a); + let normalizedB = normalize_fp64(b); + let aHighBits = bitcast(normalizedA.x); + let aLowBits = bitcast(normalizedA.y); + let bHighBits = bitcast(normalizedB.x); + let bLowBits = bitcast(normalizedB.y); + if (fp64_f32_bits_is_nan(aHighBits) || fp64_f32_bits_is_nan(aLowBits) || + fp64_f32_bits_is_nan(bHighBits) || fp64_f32_bits_is_nan(bLowBits)) { + return 0; + } + let highComparison = fp64_compare_f32_bits(aHighBits, bHighBits); + if (highComparison != 0) { + return highComparison; + } + return fp64_compare_f32_bits(aLowBits, bLowBits); +} +#endif +`});var a4,n_,eS=C(()=>{HE();ZE();JE();a4={ONE:1,SPLIT:4097},n_={name:"fp64arithmetic",source:QE,fs:t_,vs:t_,defaultUniforms:a4,uniformTypes:{ONE:"f32",SPLIT:"f32"},fp64ify:Qg,fp64LowPart:WE,fp64ifyMatrix4:jE}});function nS(n){return`layout(std140) uniform ${n}Uniforms { + float useByteColors; +} ${n}; + +vec3 ${n}_normalize(vec3 inputColor) { + return ${n}.useByteColors > 0.5 ? inputColor / 255.0 : inputColor; +} + +vec4 ${n}_normalize(vec4 inputColor) { + return ${n}.useByteColors > 0.5 ? inputColor / 255.0 : inputColor; +} + +vec4 ${n}_premultiplyAlpha(vec4 inputColor) { + return vec4(inputColor.rgb * inputColor.a, inputColor.a); +} + +vec4 ${n}_unpremultiplyAlpha(vec4 inputColor) { + return inputColor.a > 0.0 ? vec4(inputColor.rgb / inputColor.a, inputColor.a) : vec4(0.0); +} + +vec4 ${n}_premultiply_alpha(vec4 inputColor) { + return ${n}_premultiplyAlpha(inputColor); +} + +vec4 ${n}_unpremultiply_alpha(vec4 inputColor) { + return ${n}_unpremultiplyAlpha(inputColor); +} +`}function iS(n){return`struct ${n}Uniforms { + useByteColors: f32 +}; + +@group(0) @binding(auto) var ${n} : ${n}Uniforms; + +fn ${n}_normalize(inputColor: vec3) -> vec3 { + return select(inputColor, inputColor / 255.0, ${n}.useByteColors > 0.5); +} + +fn ${n}_normalize4(inputColor: vec4) -> vec4 { + return select(inputColor, inputColor / 255.0, ${n}.useByteColors > 0.5); +} + +fn ${n}_premultiplyAlpha(inputColor: vec4) -> vec4 { + return vec4(inputColor.rgb * inputColor.a, inputColor.a); +} + +fn ${n}_unpremultiplyAlpha(inputColor: vec4) -> vec4 { + return select( + vec4(0.0), + vec4(inputColor.rgb / inputColor.a, inputColor.a), + inputColor.a > 0.0 + ); +} + +fn ${n}_premultiply_alpha(inputColor: vec4) -> vec4 { + return ${n}_premultiplyAlpha(inputColor); +} + +fn ${n}_unpremultiply_alpha(inputColor: vec4) -> vec4 { + return ${n}_unpremultiplyAlpha(inputColor); +} +`}var gi,c4,l4,oQ,aQ,u4,f4,cQ,lQ,tS,uQ,d4,fQ,rS,sS=C(()=>{gi={RGBA8UNORM:0,RGBA16FLOAT:1,RGBA32FLOAT:2},c4={rgba8unorm:4,rgba16float:8,rgba32float:16},l4={...c4},oQ={rgba8unorm:gi.RGBA8UNORM,rgba16float:gi.RGBA16FLOAT,rgba32float:gi.RGBA32FLOAT},aQ={[gi.RGBA8UNORM]:"rgba8unorm",[gi.RGBA16FLOAT]:"rgba16float",[gi.RGBA32FLOAT]:"rgba32float"},u4={useByteColors:"f32"},f4={useByteColors:!0},cQ={format:gi.RGBA8UNORM,wordStride:l4.rgba8unorm/Uint32Array.BYTES_PER_ELEMENT,wordOffset:0,_padding:0},lQ=nS("colors"),tS=nS("floatColors"),uQ=iS("colors"),d4=iS("floatColors"),fQ=`struct storageColorsUniforms { + format: u32, + wordStride: u32, + wordOffset: u32, + _padding: u32 +}; + +@group(0) @binding(auto) var storageColors : storageColorsUniforms; +@group(0) @binding(auto) var storageColorsBuffer : array; + +const STORAGE_COLOR_FORMAT_RGBA8UNORM : u32 = ${gi.RGBA8UNORM}u; +const STORAGE_COLOR_FORMAT_RGBA16FLOAT : u32 = ${gi.RGBA16FLOAT}u; + +fn storageColors_getWordIndex(rowIndex: u32) -> u32 { + return storageColors.wordOffset + rowIndex * storageColors.wordStride; +} + +fn storageColors_readRgba8UnormColor(wordIndex: u32) -> vec4 { + return unpack4x8unorm(storageColorsBuffer[wordIndex]); +} + +fn storageColors_readRgba16FloatColor(wordIndex: u32) -> vec4 { + let redGreen = unpack2x16float(storageColorsBuffer[wordIndex]); + let blueAlpha = unpack2x16float(storageColorsBuffer[wordIndex + 1u]); + return vec4(redGreen.x, redGreen.y, blueAlpha.x, blueAlpha.y); +} + +fn storageColors_readRgba32FloatColor(wordIndex: u32) -> vec4 { + return vec4( + bitcast(storageColorsBuffer[wordIndex]), + bitcast(storageColorsBuffer[wordIndex + 1u]), + bitcast(storageColorsBuffer[wordIndex + 2u]), + bitcast(storageColorsBuffer[wordIndex + 3u]) + ); +} + +fn storageColors_readColor(rowIndex: u32) -> vec4 { + let wordIndex = storageColors_getWordIndex(rowIndex); + if (storageColors.format == STORAGE_COLOR_FORMAT_RGBA8UNORM) { + return storageColors_readRgba8UnormColor(wordIndex); + } + if (storageColors.format == STORAGE_COLOR_FORMAT_RGBA16FLOAT) { + return storageColors_readRgba16FloatColor(wordIndex); + } + return storageColors_readRgba32FloatColor(wordIndex); +} +`;rS={name:"floatColors",props:{},uniforms:{},vs:tS,fs:tS,source:d4,uniformTypes:u4,defaultUniforms:f4}});function g4(n={},e){let t={},i=af(n.useByteColors,!0);if(n.highlightedObjectColor!==void 0)if(n.highlightedObjectColor===null)t.isHighlightActive=!1;else{t.isHighlightActive=!0;let r=n.highlightedObjectColor.slice(0,3);t.highlightedObjectColor=r}return n.highlightColor&&(t.highlightColor=YE(n.highlightColor,i)),n.isActive!==void 0&&(t.isActive=!!n.isActive,t.isAttribute=!!n.isAttribute),n.useByteColors!==void 0&&(t.useByteColors=!!n.useByteColors),t}var h4,p4,m4,Yi,oS=C(()=>{e_();h4=[0,1,1,1],p4=`layout(std140) uniform pickingUniforms { + float isActive; + float isAttribute; + float isHighlightActive; + float useByteColors; + vec3 highlightedObjectColor; + vec4 highlightColor; +} picking; + +out vec4 picking_vRGBcolor_Avalid; + +// Normalize unsigned byte color to 0-1 range +vec3 picking_normalizeColor(vec3 color) { + return picking.useByteColors > 0.5 ? color / 255.0 : color; +} + +// Normalize unsigned byte color to 0-1 range +vec4 picking_normalizeColor(vec4 color) { + return picking.useByteColors > 0.5 ? color / 255.0 : color; +} + +bool picking_isColorZero(vec3 color) { + return dot(color, vec3(1.0)) < 0.00001; +} + +bool picking_isColorValid(vec3 color) { + return dot(color, vec3(1.0)) > 0.00001; +} + +// Check if this vertex is highlighted +bool isVertexHighlighted(vec3 vertexColor) { + vec3 highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor); + return + bool(picking.isHighlightActive) && picking_isColorZero(abs(vertexColor - highlightedObjectColor)); +} + +// Set the current picking color +void picking_setPickingColor(vec3 pickingColor) { + pickingColor = picking_normalizeColor(pickingColor); + + if (bool(picking.isActive)) { + // Use alpha as the validity flag. If pickingColor is [0, 0, 0] fragment is non-pickable + picking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor)); + + if (!bool(picking.isAttribute)) { + // Stores the picking color so that the fragment shader can render it during picking + picking_vRGBcolor_Avalid.rgb = pickingColor; + } + } else { + // Do the comparison with selected item color in vertex shader as it should mean fewer compares + picking_vRGBcolor_Avalid.a = float(isVertexHighlighted(pickingColor)); + } +} + +void picking_setPickingAttribute(float value) { + if (bool(picking.isAttribute)) { + picking_vRGBcolor_Avalid.r = value; + } +} + +void picking_setPickingAttribute(vec2 value) { + if (bool(picking.isAttribute)) { + picking_vRGBcolor_Avalid.rg = value; + } +} + +void picking_setPickingAttribute(vec3 value) { + if (bool(picking.isAttribute)) { + picking_vRGBcolor_Avalid.rgb = value; + } +} +`,m4=`layout(std140) uniform pickingUniforms { + float isActive; + float isAttribute; + float isHighlightActive; + float useByteColors; + vec3 highlightedObjectColor; + vec4 highlightColor; +} picking; + +in vec4 picking_vRGBcolor_Avalid; + +/* + * Returns highlight color if this item is selected. + */ +vec4 picking_filterHighlightColor(vec4 color) { + // If we are still picking, we don't highlight + if (picking.isActive > 0.5) { + return color; + } + + bool selected = bool(picking_vRGBcolor_Avalid.a); + + if (selected) { + // Blend in highlight color based on its alpha value + float highLightAlpha = picking.highlightColor.a; + float blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha); + float highLightRatio = highLightAlpha / blendedAlpha; + + vec3 blendedRGB = mix(color.rgb, picking.highlightColor.rgb, highLightRatio); + return vec4(blendedRGB, blendedAlpha); + } else { + return color; + } +} + +/* + * Returns picking color if picking enabled else unmodified argument. + */ +vec4 picking_filterPickingColor(vec4 color) { + if (bool(picking.isActive)) { + if (picking_vRGBcolor_Avalid.a == 0.0) { + discard; + } + return picking_vRGBcolor_Avalid; + } + return color; +} + +/* + * Returns picking color if picking is enabled if not + * highlight color if this item is selected, otherwise unmodified argument. + */ +vec4 picking_filterColor(vec4 color) { + vec4 highlightColor = picking_filterHighlightColor(color); + return picking_filterPickingColor(highlightColor); +} +`,Yi={props:{},uniforms:{},name:"picking",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useByteColors:"f32",highlightedObjectColor:"vec3",highlightColor:"vec4"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useByteColors:!0,highlightedObjectColor:[0,0,0],highlightColor:h4},vs:p4,fs:m4,getUniforms:g4}});var i_,aS=C(()=>{i_=`precision highp int; + +// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) +struct AmbientLight { + vec3 color; +}; + +struct PointLight { + vec3 color; + vec3 position; + vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential +}; + +struct SpotLight { + vec3 color; + vec3 position; + vec3 direction; + vec3 attenuation; + vec2 coneCos; +}; + +struct DirectionalLight { + vec3 color; + vec3 direction; +}; + +struct UniformLight { + vec3 color; + vec3 position; + vec3 direction; + vec3 attenuation; + vec2 coneCos; +}; + +layout(std140) uniform lightingUniforms { + int enabled; + int directionalLightCount; + int pointLightCount; + int spotLightCount; + vec3 ambientColor; + UniformLight lights[5]; +} lighting; + +PointLight lighting_getPointLight(int index) { + UniformLight light = lighting.lights[index]; + return PointLight(light.color, light.position, light.attenuation); +} + +SpotLight lighting_getSpotLight(int index) { + UniformLight light = lighting.lights[lighting.pointLightCount + index]; + return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos); +} + +DirectionalLight lighting_getDirectionalLight(int index) { + UniformLight light = + lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index]; + return DirectionalLight(light.color, light.direction); +} + +float getPointLightAttenuation(PointLight pointLight, float distance) { + return pointLight.attenuation.x + + pointLight.attenuation.y * distance + + pointLight.attenuation.z * distance * distance; +} + +float getSpotLightAttenuation(SpotLight spotLight, vec3 positionWorldspace) { + vec3 light_direction = normalize(positionWorldspace - spotLight.position); + float coneFactor = smoothstep( + spotLight.coneCos.y, + spotLight.coneCos.x, + dot(normalize(spotLight.direction), light_direction) + ); + float distanceAttenuation = getPointLightAttenuation( + PointLight(spotLight.color, spotLight.position, spotLight.attenuation), + distance(spotLight.position, positionWorldspace) + ); + return distanceAttenuation / max(coneFactor, 0.0001); +} + +// #endif +`});var cS,lS=C(()=>{cS=`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) +const MAX_LIGHTS: i32 = 5; + +struct AmbientLight { + color: vec3, +}; + +struct PointLight { + color: vec3, + position: vec3, + attenuation: vec3, // 2nd order x:Constant-y:Linear-z:Exponential +}; + +struct SpotLight { + color: vec3, + position: vec3, + direction: vec3, + attenuation: vec3, + coneCos: vec2, +}; + +struct DirectionalLight { + color: vec3, + direction: vec3, +}; + +struct UniformLight { + color: vec3, + position: vec3, + direction: vec3, + attenuation: vec3, + coneCos: vec2, +}; + +struct lightingUniforms { + enabled: i32, + directionalLightCount: i32, + pointLightCount: i32, + spotLightCount: i32, + ambientColor: vec3, + lights: array, +}; + +@group(2) @binding(auto) var lighting : lightingUniforms; + +fn lighting_getPointLight(index: i32) -> PointLight { + let light = lighting.lights[index]; + return PointLight(light.color, light.position, light.attenuation); +} + +fn lighting_getSpotLight(index: i32) -> SpotLight { + let light = lighting.lights[lighting.pointLightCount + index]; + return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos); +} + +fn lighting_getDirectionalLight(index: i32) -> DirectionalLight { + let light = lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index]; + return DirectionalLight(light.color, light.direction); +} + +fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 { + return pointLight.attenuation.x + + pointLight.attenuation.y * distance + + pointLight.attenuation.z * distance * distance; +} + +fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3) -> f32 { + let lightDirection = normalize(positionWorldspace - spotLight.position); + let coneFactor = smoothstep( + spotLight.coneCos.y, + spotLight.coneCos.x, + dot(normalize(spotLight.direction), lightDirection) + ); + let distanceAttenuation = getPointLightAttenuation( + PointLight(spotLight.color, spotLight.position, spotLight.attenuation), + distance(spotLight.position, positionWorldspace) + ); + return distanceAttenuation / max(coneFactor, 0.0001); +} +`});function y4(n,e={}){if(n=n&&{...n},!n)return lf();n.lights&&(n={...n,...v4(n.lights),lights:void 0});let{useByteColors:t,ambientLight:i,pointLights:r,spotLights:s,directionalLights:o}=n||{};if(!(i||r&&r.length>0||s&&s.length>0||o&&o.length>0))return{...lf(),enabled:0};let c={...lf(),...b4({useByteColors:t,ambientLight:i,pointLights:r,spotLights:s,directionalLights:o})};return n.enabled!==void 0&&(c.enabled=n.enabled?1:0),c}function b4({useByteColors:n,ambientLight:e,pointLights:t=[],spotLights:i=[],directionalLights:r=[]}){let s=fS(),o=0,a=0,c=0,l=0;for(let u of t){if(o>=Wr)break;s[o]={...s[o],color:cf(u,n),position:u.position,attenuation:u.attenuation||[1,0,0]},o++,a++}for(let u of i){if(o>=Wr)break;s[o]={...s[o],color:cf(u,n),position:u.position,direction:u.direction,attenuation:u.attenuation||[1,0,0],coneCos:w4(u)},o++,c++}for(let u of r){if(o>=Wr)break;s[o]={...s[o],color:cf(u,n),direction:u.direction},o++,l++}return t.length+i.length+r.length>Wr&&z.warn(`MAX_LIGHTS exceeded, truncating to ${Wr}`)(),{ambientColor:cf(e,n),directionalLightCount:l,pointLightCount:a,spotLightCount:c,lights:s}}function v4(n){let e={pointLights:[],spotLights:[],directionalLights:[]};for(let t of n||[])switch(t.type){case"ambient":e.ambientLight=t;break;case"directional":e.directionalLights?.push(t);break;case"point":e.pointLights?.push(t);break;case"spot":e.spotLights?.push(t);break;default:}return e}function cf(n={},e){let{color:t=[0,0,0],intensity:i=1}=n;return Jg(t,af(e,!0)).map(s=>s*i)}function lf(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:fS()}}function fS(){return Array.from({length:Wr},()=>x4())}function x4(){return{color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}}function w4(n){let e=n.innerConeAngle??0,t=n.outerConeAngle??Math.PI/4;return[Math.cos(e),Math.cos(t)]}var Wr,_4,uS,dS=C(()=>{ee();aS();lS();e_();Wr=5,_4={color:"vec3",position:"vec3",direction:"vec3",attenuation:"vec3",coneCos:"vec2"},uS={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",directionalLightCount:"i32",pointLightCount:"i32",spotLightCount:"i32",ambientColor:"vec3",lights:[_4,Wr]},defaultUniforms:lf(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:cS,vs:i_,fs:i_,getUniforms:y4}});var hS,pS,mS=C(()=>{hS=`layout(std140) uniform phongMaterialUniforms { + uniform bool unlit; + uniform float ambient; + uniform float diffuse; + uniform float shininess; + uniform vec3 specularColor; +} material; +`,pS=`layout(std140) uniform phongMaterialUniforms { + uniform bool unlit; + uniform float ambient; + uniform float diffuse; + uniform float shininess; + uniform vec3 specularColor; +} material; + +vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) { + vec3 halfway_direction = normalize(light_direction + view_direction); + float lambertian = dot(light_direction, normal_worldspace); + float specular = 0.0; + if (lambertian > 0.0) { + float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0); + specular = pow(specular_angle, material.shininess); + } + lambertian = max(lambertian, 0.0); + return (lambertian * material.diffuse * surfaceColor + specular * floatColors_normalize(material.specularColor)) * color; +} + +vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) { + vec3 lightColor = surfaceColor; + + if (material.unlit) { + return surfaceColor; + } + + if (lighting.enabled == 0) { + return lightColor; + } + + vec3 view_direction = normalize(cameraPosition - position_worldspace); + lightColor = material.ambient * surfaceColor * lighting.ambientColor; + + for (int i = 0; i < lighting.pointLightCount; i++) { + PointLight pointLight = lighting_getPointLight(i); + vec3 light_position_worldspace = pointLight.position; + vec3 light_direction = normalize(light_position_worldspace - position_worldspace); + float light_attenuation = getPointLightAttenuation(pointLight, distance(light_position_worldspace, position_worldspace)); + lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation); + } + + for (int i = 0; i < lighting.spotLightCount; i++) { + SpotLight spotLight = lighting_getSpotLight(i); + vec3 light_position_worldspace = spotLight.position; + vec3 light_direction = normalize(light_position_worldspace - position_worldspace); + float light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace); + lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, spotLight.color / light_attenuation); + } + + for (int i = 0; i < lighting.directionalLightCount; i++) { + DirectionalLight directionalLight = lighting_getDirectionalLight(i); + lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); + } + + return lightColor; +} +`});var gS,_S=C(()=>{gS=`struct phongMaterialUniforms { + unlit: u32, + ambient: f32, + diffuse: f32, + shininess: f32, + specularColor: vec3, +}; + +@group(3) @binding(auto) var phongMaterial : phongMaterialUniforms; + +fn lighting_getLightColor(surfaceColor: vec3, light_direction: vec3, view_direction: vec3, normal_worldspace: vec3, color: vec3) -> vec3 { + let halfway_direction: vec3 = normalize(light_direction + view_direction); + var lambertian: f32 = dot(light_direction, normal_worldspace); + var specular: f32 = 0.0; + if (lambertian > 0.0) { + let specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0); + specular = pow(specular_angle, phongMaterial.shininess); + } + lambertian = max(lambertian, 0.0); + return ( + lambertian * phongMaterial.diffuse * surfaceColor + + specular * floatColors_normalize(phongMaterial.specularColor) + ) * color; +} + +fn lighting_getLightColor2(surfaceColor: vec3, cameraPosition: vec3, position_worldspace: vec3, normal_worldspace: vec3) -> vec3 { + var lightColor: vec3 = surfaceColor; + + if (phongMaterial.unlit != 0u) { + return surfaceColor; + } + + if (lighting.enabled == 0) { + return lightColor; + } + + let view_direction: vec3 = normalize(cameraPosition - position_worldspace); + lightColor = phongMaterial.ambient * surfaceColor * lighting.ambientColor; + + for (var i: i32 = 0; i < lighting.pointLightCount; i++) { + let pointLight: PointLight = lighting_getPointLight(i); + let light_position_worldspace: vec3 = pointLight.position; + let light_direction: vec3 = normalize(light_position_worldspace - position_worldspace); + let light_attenuation = getPointLightAttenuation( + pointLight, + distance(light_position_worldspace, position_worldspace) + ); + lightColor += lighting_getLightColor( + surfaceColor, + light_direction, + view_direction, + normal_worldspace, + pointLight.color / light_attenuation + ); + } + + for (var i: i32 = 0; i < lighting.spotLightCount; i++) { + let spotLight: SpotLight = lighting_getSpotLight(i); + let light_position_worldspace: vec3 = spotLight.position; + let light_direction: vec3 = normalize(light_position_worldspace - position_worldspace); + let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace); + lightColor += lighting_getLightColor( + surfaceColor, + light_direction, + view_direction, + normal_worldspace, + spotLight.color / light_attenuation + ); + } + + for (var i: i32 = 0; i < lighting.directionalLightCount; i++) { + let directionalLight: DirectionalLight = lighting_getDirectionalLight(i); + lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); + } + + return lightColor; +} + +fn lighting_getSpecularLightColor(cameraPosition: vec3, position_worldspace: vec3, normal_worldspace: vec3) -> vec3{ + var lightColor = vec3(0, 0, 0); + let surfaceColor = vec3(0, 0, 0); + + if (lighting.enabled != 0) { + let view_direction = normalize(cameraPosition - position_worldspace); + + for (var i: i32 = 0; i < lighting.pointLightCount; i++) { + let pointLight: PointLight = lighting_getPointLight(i); + let light_position_worldspace: vec3 = pointLight.position; + let light_direction: vec3 = normalize(light_position_worldspace - position_worldspace); + let light_attenuation = getPointLightAttenuation( + pointLight, + distance(light_position_worldspace, position_worldspace) + ); + lightColor += lighting_getLightColor( + surfaceColor, + light_direction, + view_direction, + normal_worldspace, + pointLight.color / light_attenuation + ); + } + + for (var i: i32 = 0; i < lighting.spotLightCount; i++) { + let spotLight: SpotLight = lighting_getSpotLight(i); + let light_position_worldspace: vec3 = spotLight.position; + let light_direction: vec3 = normalize(light_position_worldspace - position_worldspace); + let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace); + lightColor += lighting_getLightColor( + surfaceColor, + light_direction, + view_direction, + normal_worldspace, + spotLight.color / light_attenuation + ); + } + + for (var i: i32 = 0; i < lighting.directionalLightCount; i++) { + let directionalLight: DirectionalLight = lighting_getDirectionalLight(i); + lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); + } + } + return lightColor; +} +`});var E4,eo,yS=C(()=>{sS();dS();mS();_S();E4=[38.25,38.25,38.25],eo={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:pS.replace("phongMaterial","gouraudMaterial"),fs:hS.replace("phongMaterial","gouraudMaterial"),source:gS.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[uS,rS],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:E4},getUniforms(n){return{...eo.defaultUniforms,...n}}}});var bt=C(()=>{gm();fw();tg();jw();Yw();qE();eS();oS();yS()});function jn(n="id"){C_[n]=C_[n]||1;let e=C_[n]++;return`${n}-${e}`}var C_,_o=C(()=>{C_={}});function Kr(n){switch(n){case"POSITION":return"positions";case"NORMAL":return"normals";case"TEXCOORD_0":return"texCoords";case"TEXCOORD_1":return"texCoords1";case"COLOR_0":return"colors";default:return n}}function bF(n){let e=[];for(let[t,i]of Object.entries(n)){if(!i)continue;let{value:r,size:s,normalized:o}=i;if(s===void 0)throw new Error(`Attribute ${t} is missing a size`);e.push({name:Kr(t),format:Ee.getVertexFormatFromAttribute(r,s,o)})}return e}var Kt,kf=C(()=>{ee();_o();Kt=class{id;topology;vertexCount;indices;attributes;bufferLayout;userData={};constructor(e){let{attributes:t={},indices:i=null,vertexCount:r=null}=e;this.id=e.id||jn("geometry"),this.topology=e.topology,i&&(this.indices=ArrayBuffer.isView(i)?{value:i,size:1}:i),this.attributes={};for(let[s,o]of Object.entries(t)){let a=ArrayBuffer.isView(o)?{value:o}:o;if(!ArrayBuffer.isView(a.value))throw new Error(`${this._print(s)}: must be typed array or object with value as typed array`);if((s==="POSITION"||s==="positions")&&!a.size&&(a.size=3),s==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=a}else{let c=Kr(s),l=Object.keys(this.attributes).find(u=>Kr(u)===c);l&&delete this.attributes[l],this.attributes[s]=a}}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=r||this._calculateVertexCount(this.attributes,this.indices),this.bufferLayout=e.bufferLayout||bF(this.attributes)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,t){return this}_calculateVertexCount(e,t){if(t)return t.value.length;let i=1/0;for(let r of Object.values(e)){if(!r)continue;let{value:s,size:o,constant:a}=r;!a&&s&&o!==void 0&&o>=1&&(i=Math.min(i,s.length/o))}return i}}});function h1(n,e={}){let t=e.bufferName||"geometry";if(vF(n,t))return n;let i=e.minAttributeAlignment||4,r=xF(n,e.attributes),s=[],o=0,a=1/0;for(let[u,f]of r){if(!f)continue;if(f.constant)throw new Error(`Attribute ${u} is constant`);let{value:d,size:h,normalized:p}=f;if(!ArrayBuffer.isView(d))throw new Error(`Attribute ${u} is missing typed array data`);if(h===void 0)throw new Error(`Attribute ${u} is missing a size`);let m=Ee.getVertexFormatFromAttribute(d,h,p),g=Ee.getVertexFormatInfo(m);o=d1(o,i),s.push({sourceName:u,attributeName:Kr(u),value:d,size:h,format:m,byteOffset:o,byteLength:g.byteLength}),o+=g.byteLength;let v=d.length/h;if(!Number.isInteger(v))throw new Error(`Attribute ${u} length is not divisible by size`);a=Math.min(a,v)}if(s.length===0||!Number.isFinite(a))throw new Error(`Geometry ${n.id} has no interleavable attributes`);let c=d1(o,i),l=new ArrayBuffer(a*c);for(let u of s)wF(l,a,c,u);return new Kt({id:n.id,topology:n.topology||"triangle-list",vertexCount:n.vertexCount,indices:n.indices,attributes:{[t]:{value:new Uint8Array(l),size:c,byteStride:c}},bufferLayout:[{name:t,stepMode:"vertex",byteStride:c,attributes:s.map(u=>({attribute:u.attributeName,format:u.format,byteOffset:u.byteOffset}))}]})}function vF(n,e){if(n.bufferLayout.length!==1)return!1;let t=n.bufferLayout[0];return t.name===e&&!!t.attributes?.length&&!!n.attributes[e]}function xF(n,e){return e?e.map(t=>[t,n.attributes[t]]):Object.entries(n.attributes)}function wF(n,e,t,i){let r=i.value.constructor,s=r.BYTES_PER_ELEMENT;if(i.byteOffset%s!==0||t%s!==0)throw new Error(`Attribute ${i.sourceName} is not aligned to its component type`);let o=new r(n),a=i.value,c=i.byteOffset/s,l=t/s;for(let u=0;u{ee();kf()});var EF,SF,Qr,m1=C(()=>{EF=1,SF=1,Qr=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){let{delay:t=0,duration:i=Number.POSITIVE_INFINITY,rate:r=1,repeat:s=1}=e,o=EF++,a={time:0,delay:t,duration:i,rate:r,repeat:s};return this._setChannelTime(a,this.time),this.channels.set(o,a),o}removeChannel(e){this.channels.delete(e);for(let[t,i]of this.animations)i.channel===e&&this.detachAnimation(t)}isFinished(e){let t=this.channels.get(e);return t===void 0?!1:this.time>=t.delay+t.duration*t.repeat}getTime(e){if(e===void 0)return this.time;let t=this.channels.get(e);return t===void 0?-1:t.time}setTime(e){this.time=Math.max(0,e);let t=this.channels.values();for(let r of t)this._setChannelTime(r,this.time);let i=this.animations.values();for(let r of i){let{animation:s,channel:o}=r;s.setTime(this.getTime(o))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,t){let i=SF++;return this.animations.set(i,{animation:e,channel:t}),e.setTime(this.getTime(t)),i}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,t){let i=t-e.delay,r=e.duration*e.repeat;i>=r?e.time=e.duration*e.rate:(e.time=Math.max(0,i)%e.duration,e.time*=e.rate)}}});function g1(n){let e=typeof window<"u"?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame:null;return e?e.call(window,n):setTimeout(()=>n(typeof performance<"u"?performance.now():Date.now()),1e3/60)}function _1(n){let e=typeof window<"u"?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame:null;if(e){e.call(window,n);return}clearTimeout(n)}var y1=C(()=>{});var PF,CF,b1,mc,v1=C(()=>{ee();y1();la();PF=0,CF="Animation Loop",b1={requestAnimationFrame:n=>g1(n),cancelAnimationFrame:n=>_1(n)},mc=class n{static defaultAnimationLoopProps={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>{console.error(e)},stats:void 0,autoResizeViewport:!1,animationFrameProvider:b1};device=null;canvas=null;props;animationProps=null;timeline=null;stats;sharedStats;cpuTime;gpuTime;frameRate;display;_needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;_lastFrameTime=0;constructor(e){if(this.props={...n.defaultAnimationLoopProps,...e},e=this.props,!e.device)throw new Error("No device provided");this.stats=e.stats||new Vt({id:`animation-loop-${PF++}`}),this.sharedStats=Vs.stats.get(CF),this.frameRate=this.stats.get("Frame Rate"),this.frameRate.setSampleSize(1),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.setProps({autoResizeViewport:e.autoResizeViewport,animationFrameProvider:e.animationFrameProvider}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null),this.device?._disableDebugGPUTime()}delete(){this.destroy()}reportError(e){this._error=e,this.props.onError(e),this.props.onError===n.defaultAnimationLoopProps.onError&&typeof window<"u"&&typeof ErrorEvent<"u"&&window.dispatchEvent(new ErrorEvent("error",{error:e,message:e.message}))}setNeedsRedraw(e){return this._needsRedraw=this._needsRedraw||e,this}needsRedraw(){let e=this._needsRedraw;return this._needsRedraw=!1,e}setProps(e){if("autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),"animationFrameProvider"in e){let t=e.animationFrameProvider||b1;if(t!==this.props.animationFrameProvider){let i=this._animationFrameId!==null;i&&this._cancelAnimationFrame(),this.props.animationFrameProvider=t,i&&this._requestAnimationFrame()}}return this}async start(){if(this._running)return this;this._running=!0;try{let e;if(!this._initialized){if(this._initialized=!0,await this._initDevice(),this._initialize(),!this._running)return null;await this.props.onInitialize(this._getAnimationProps())}return this._running?(e!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){let t=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(t),t}}stop(){if(this._running){let e=this.animationProps;this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1,this._lastFrameTime=0,e&&this.props.onFinalize(e)}return this}redraw(e,t=null){return this.device?.isLost||this._error?this:(this._beginFrameTimers(e),this._setupFrame(),this.animationProps&&(this.animationProps.animationFrame=t),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeViewport(),this.device?._enableDebugGPUTime()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=this.props.animationFrameProvider.requestAnimationFrame(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(this.props.animationFrameProvider.cancelAnimationFrame(this._animationFrameId),this._animationFrameId=null)}_animationFrame(e,t){if(this._running)try{this.redraw(e,t??null),this._requestAnimationFrame()}catch(i){let r=i instanceof Error?i:new Error(String(i));this.reportError(r),this.stop()}}_renderFrame(e){if(this.display){this.display._renderFrame(e);return}let t=this.props.onRender(this._getAnimationProps());this.device&&t!==!1&&this.device.submit()}_clearNeedsRedraw(){this._needsRedraw=!1}_setupFrame(){this._resizeViewport()}_initializeAnimationProps(){let e=this.device?.getDefaultCanvasContext();if(!this.device||!e)throw new Error("loop");let t=e?.canvas,i=e.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:e,canvas:t,useDevicePixels:i,timeline:this.timeline,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,animationFrame:null,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:e,height:t,aspect:i}=this._getSizeAndAspect();(e!==this.animationProps.width||t!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),i!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=t,this.animationProps.aspect=i,this.animationProps.needsRedraw=this._needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.getDefaultCanvasContext().canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";let t=document.createElement("div");t.style.position="absolute",t.style.left="10px",t.style.bottom="10px",t.style.width="300px",t.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(t);let i=this.props.onAddHTML(t);i&&(t.innerHTML=i)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[e,t]=this.device.getDefaultCanvasContext().getDrawingBufferSize(),i=e>0&&t>0?e/t:1;return{width:e,height:t,aspect:i}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(e){let t=e??(typeof performance<"u"?performance.now():Date.now());if(this._lastFrameTime){let i=t-this._lastFrameTime;i>0&&this.frameRate.addTime(i)}this._lastFrameTime=t,this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeStart()}_endFrameTimers(){this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeEnd(),this._updateSharedStats()}_consumeEncodedGpuTime(){if(!this.device)return;let e=this.device.commandEncoder._gpuTimeMs;e!==void 0&&(this.gpuTime.addTime(e),this.device.commandEncoder._gpuTimeMs=void 0)}_updateSharedStats(){if(this.stats!==this.sharedStats){for(let e of Object.keys(this.sharedStats.stats))this.stats.stats[e]||delete this.sharedStats.stats[e];this.stats.forEach(e=>{let t=this.sharedStats.get(e.name,e.type);t.sampleSize=e.sampleSize,t.time=e.time,t.count=e.count,t.samples=e.samples,t.lastTiming=e.lastTiming,t.lastSampleTime=e.lastSampleTime,t.lastSampleCount=e.lastSampleCount,t._count=e._count,t._time=e._time,t._samples=e._samples,t._startTime=e._startTime,t._timerPending=e._timerPending})}}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}}});function x1(n,e){if(e instanceof Rf)return e;let t=h1(e),i=TF(n,t),{attributes:r,bufferLayout:s}=LF(n,t);return new Rf({topology:t.topology||"triangle-list",bufferLayout:s,vertexCount:t.vertexCount,indices:i,attributes:r})}function TF(n,e){if(!e.indices)return;let t=e.indices.value;return n.createBuffer({usage:re.INDEX,data:t})}function LF(n,e){let t={};for(let[i,r]of Object.entries(e.attributes)){let s=e.bufferLayout.find(o=>o.name===i)?.name||Kr(i);r&&(t[s]=n.createBuffer({data:r.value,id:`${i}-buffer`}))}return{attributes:t,bufferLayout:e.bufferLayout,vertexCount:e.vertexCount}}var Rf,w1=C(()=>{ee();kf();p1();_o();Rf=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){if(this.id=e.id||jn("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&!(this.indices.usage&re.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){this.indices?.destroy();for(let e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(e){return e.byteLength/12}}});function E1(n,e){let t={},i="Values";if(n.attributes.length===0&&!n.varyings?.length)return{"No attributes or varyings":{[i]:"N/A"}};for(let r of n.attributes)if(r){let s=`${r.location} ${r.name}: ${r.type}`;t[`in ${s}`]={[i]:r.stepMode||"vertex"}}for(let r of n.varyings||[]){let s=`${r.location} ${r.name}`;t[`out ${s}`]={[i]:JSON.stringify(r)}}return t}var S1=C(()=>{});function T1(n,e,t){if(n.device.type!=="webgl")return;let i=kF(n.device);if(!i.flushing){if(IF(n)){MF(n,t,i);return}e&&RF(e)&&e.handle!==null&&(i.queuedFramebuffers.includes(e)||i.queuedFramebuffers.push(e))}}function MF(n,e,t){if(t.queuedFramebuffers.length===0)return;let i=n.device,{gl:r}=i,s=r.getParameter(36010),o=r.getParameter(36006),[a,c]=n.device.getDefaultCanvasContext().getDrawingBufferSize(),l=C1(e.top,8),u=C1(e.left,8);t.flushing=!0;try{for(let f of t.queuedFramebuffers){let[d,h,p,m,g]=AF({framebuffer:f,targetWidth:a,targetHeight:c,topPx:l,leftPx:u,minimap:e.minimap});r.bindFramebuffer(36008,f.handle),r.bindFramebuffer(36009,null),r.blitFramebuffer(0,0,f.width,f.height,d,h,p,m,16384,9728),l+=g+8}}finally{r.bindFramebuffer(36008,s),r.bindFramebuffer(36009,o),t.flushing=!1}}function AF(n){let{framebuffer:e,targetWidth:t,targetHeight:i,topPx:r,leftPx:s,minimap:o}=n,a=o?Math.max(Math.floor(t/4),1):t,c=o?Math.max(Math.floor(i/4),1):i,l=Math.min(a/e.width,c/e.height),u=Math.max(Math.floor(e.width*l),1),f=Math.max(Math.floor(e.height*l),1),d=s,h=Math.max(i-r-f,0),p=d+u,m=h+f;return[d,h,p,m,f]}function kF(n){return n.userData[P1]||={flushing:!1,queuedFramebuffers:[]},n.userData[P1]}function RF(n){return"colorAttachments"in n}function IF(n){let e=n.props.framebuffer;return!e||e.handle===null}function C1(n,e){if(!n)return e;let t=Number.parseInt(n,10);return Number.isFinite(t)?t:e}var P1,L1=C(()=>{P1="__debugFramebufferState"});function yo(n,e,t){if(n===e)return!0;if(!t||!n||!e)return!1;if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let i=0;i{});var bo,A1=C(()=>{ee();bo=class{bufferLayouts;constructor(e){this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(t=>t.name===e)||null}getAttributeNamesForBuffer(e){return qs(e)}mergeBufferLayouts(e,t){let i=[...e];for(let r of t){let s=i.findIndex(o=>o.name===r.name);s<0?i.push(r):i[s]=r}return i}}});function k1(n,e){let t=Xm(n),i=e.slice();return i.sort((r,s)=>{let o=Gu(qs(r).map(c=>t[c])),a=Gu(qs(s).map(c=>t[c]));return o-a}),i}var R1=C(()=>{ee()});function vo(n,e){if(!n||!e.some(i=>i.bindingLayout?.length))return n;let t={...n,bindings:n.bindings.map(i=>({...i}))};"attributes"in(n||{})&&(t.attributes=n?.attributes||[]);for(let i of e)for(let r of i.bindingLayout||[])for(let s of BF(r.name)){let o=t.bindings.find(a=>a.name===s);o?.group===0&&(o.group=r.group),o&&r.visibility!==void 0&&(o.visibility=r.visibility)}return t}function I1(n,e,t=[]){return n?e?{...n,attributes:n.attributes.length?NF(n.attributes,e.attributes.filter(i=>t.includes(i.name))):e.attributes,bindings:DF(n.bindings,e.bindings)}:n:e}function gc(n){return!!(n.uniformTypes&&!OF(n.uniformTypes))}function B1(n){let e=[];for(let t of n){let i=Va(t),r=new Set([t.vs,t.fs].flatMap(o=>o?Wa(o).filter(a=>a.isStd140).map(a=>a.blockName):[])),s=r.has(i)?i:r.size===1?r.values().next().value:void 0;gc(t)&&s&&e.push({name:s,uniformTypes:t.uniformTypes})}return e}function If(n,e){let t=[],i=new Set;for(let r of[...n||[],...e||[]])i.has(r.name)||(i.add(r.name),t.push(r));return t}function BF(n){let e=new Set([n,`${n}Uniforms`]);return n.endsWith("Uniforms")||e.add(`${n}Sampler`),[...e]}function OF(n){for(let e in n)return!1;return!0}function DF(n,e){let t=n.map(s=>({...s})),i=new Set(n.map(s=>s.name)),r=new Set(n.map(s=>`${s.group}:${s.location}`));for(let s of e){let o=`${s.group}:${s.location}`;!i.has(s.name)&&!r.has(o)&&t.push({...s})}return t}function NF(n,e){let t=n.map(s=>({...s})),i=new Map(n.map(s=>[s.name,s])),r=new Map(n.map(s=>[s.location,s]));for(let s of e){let o=i.get(s.name);if(o){if(o.type!==s.type||o.location!==s.location)throw new Error(`Shader attribute "${s.name}" conflicts with its inferred type or location`);continue}let a=r.get(s.location);if(a)throw new Error(`Shader attributes "${a.name}" and "${s.name}" both use location ${s.location}`);t.push({...s})}return t}var T_=C(()=>{bt()});function FF(n){return ga(n)||typeof n=="number"||typeof n=="boolean"}function O1(n,e={}){let t={bindings:{},uniforms:{}};return Object.keys(n).forEach(i=>{let r=n[i];Object.prototype.hasOwnProperty.call(e,i)||FF(r)?t.uniforms[i]=r:t.bindings[i]=r}),t}var D1=C(()=>{Qp()});function N1(n={},e={},t={}){let i={...n};for(let[r,s]of Object.entries(e))s!==void 0&&(i[r]=L_(n[r],s,t[r]));return i}function L_(n,e,t){if(!t||typeof t=="string")return _c(e);if(Array.isArray(t)){if(M_(e)||!Array.isArray(e))return _c(e);let o=Array.isArray(n)&&!M_(n)?[...n]:[],a=o.slice();for(let c=0;ct===void 0?void 0:_c(t)):A_(n)?Object.fromEntries(Object.entries(n).map(([e,t])=>[e,t===void 0?void 0:_c(t)])):n}function M_(n){return ArrayBuffer.isView(n)||Array.isArray(n)&&(n.length===0||typeof n[0]=="number")}function A_(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&!ArrayBuffer.isView(n)}function zF(n){return!!n?.dependencies}var xo,k_=C(()=>{ee();bt();D1();xo=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;directBindings={};constructor(e,t){Object.assign(this.options,t);let i=Cr(Object.values(e).filter(zF));for(let r of i)e[r.name]=r;z.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(let[r,s]of Object.entries(e))s&&(this._addModule(s),s.name&&r!==s.name&&!this.options.disableWarnings&&z.warn(`Module name: ${r} vs ${s.name}`)())}destroy(){}setProps(e){e.bindings&&Object.assign(this.directBindings,e.bindings);for(let t of Object.keys(e)){if(t==="bindings")continue;let i=t,r=e[i]||{},s=this.modules[i];if(!s)this.options.disableWarnings||z.warn(`Module ${t} not found`)();else{let o=this.moduleUniforms[i],a=this.moduleBindings[i],c=s.getUniforms?.(r,o)||r,{uniforms:l,bindings:u}=O1(c,s.uniformTypes);this.moduleUniforms[i]=N1(o,l,s.uniformTypes),this.moduleBindings[i]={...a,...u}}}}getModules(){return Object.values(this.modules)}addModules(e){let t=Cr(e);for(let i of t){let r=i.name;this.modules[r]||(this.modules[r]=i,this._addModule(i))}}getUniformValues(){return this.moduleUniforms}getBindingValues(){let e={};for(let t of Object.values(this.moduleBindings))Object.assign(e,t);return Object.assign(e,this.directBindings),e}getModuleBindingValues(e){let t=this.moduleBindings[e];return t?{...t}:{}}getDebugTable(){let e={};for(let[t,i]of Object.entries(this.moduleUniforms))for(let[r,s]of Object.entries(i))e[`${t}.${r}`]={type:this.modules[t].uniformTypes?.[r],value:String(s)};return e}_addModule(e){let t=e.name;this.moduleUniforms[t]=N1({},e.defaultUniforms||{},e.uniformTypes),this.moduleBindings[t]={}}}});function R_(n){return n!==null&&typeof n=="object"&&"buffer"in n}function $F(n){return n instanceof nt?n.buffer:n}function F1(n){return{buffer:$F(n.buffer),offset:n.offset,size:n.size}}var UF,nt,I_=C(()=>{ee();_o();UF=re.DEBUG_DATA_MAX_LENGTH,nt=class{device;id;ready;usage;props;isReady=!0;destroyed=!1;generation=0;updateTimestamp;debugData=new ArrayBuffer(0);_debugDataEnabled;_maxDebugDataByteLength;_ownsBuffer;_buffer;get buffer(){return this._buffer}get byteLength(){return this._buffer.byteLength}get[Symbol.toStringTag](){return"DynamicBuffer"}toString(){return`DynamicBuffer:"${this.id}":${this.byteLength}B`}toJSON(){return this.toString()}constructor(e,t){let{debugData:i=!1,buffer:r,ownsBuffer:s=!0,...o}=t;if(r&&r.device!==e)throw new Error("DynamicBuffer adopted buffers must belong to the supplied device");if(r&&(o.byteLength!==void 0||o.data!==void 0))throw new Error("DynamicBuffer cannot combine an adopted buffer with byteLength or data");let a=t.id||r?.id||jn("dynamic-buffer"),c={...o,id:a,usage:o.usage??r?.usage,indexType:o.indexType??r?.indexType};(c.usage||0)&re.INDEX&&!c.indexType&&(o.data instanceof Uint32Array?c.indexType="uint32":o.data instanceof Uint16Array?c.indexType="uint16":o.data instanceof Uint8Array&&(c.indexType="uint8")),delete c.data,delete c.byteOffset,this.device=e,this.id=a,this.props=c,this.usage=c.usage||0,this._debugDataEnabled=!!i,this._maxDebugDataByteLength=typeof i=="object"&&i.maxByteLength!==void 0?i.maxByteLength:UF,this._ownsBuffer=s,this._buffer=r??this.device.createBuffer({...o,id:a}),this.ready=Promise.resolve(this._buffer),this.updateTimestamp=this._buffer.updateTimestamp,this._resetDebugData(this._buffer.byteLength),o.data&&this._writeDebugData(o.data,o.byteOffset||0)}write(e,t=0){this._buffer.write(e,t),this._touch(),this._writeDebugData(e,t)}async mapAndWriteAsync(e,t=0,i=this.byteLength-t){let r=null;await this._buffer.mapAndWriteAsync(async(s,o)=>{await e(s,o),r=new Uint8Array(s.slice(0,i))},t,i),this._touch(),r&&this._writeDebugData(r,t)}async readAsync(e=0,t=this.byteLength-e){let i=await this._buffer.readAsync(e,t);return this._writeDebugData(i,e)&&this._touch(),i}async mapAndReadAsync(e,t=0,i=this.byteLength-t){let r=null,s=await this._buffer.mapAndReadAsync(async(o,a)=>(r=new Uint8Array(o.slice(0)),await e(o,a)),t,i);return r&&this._writeDebugData(r,t)&&this._touch(),s}resize(e){let{byteLength:t,preserveData:i=!1}=e;if(t===this.byteLength)return!1;let r=Math.min(e.copyByteLength??Math.min(this.byteLength,t),this.byteLength,t),s=this._buffer,o=this.debugData.slice(0),{data:a,byteOffset:c,...l}=this.props,u=this.device.createBuffer({...l,byteLength:t});return i&&r>0&&this._copyBufferContents(s,u,r),this._buffer=u,this._resetDebugData(t),i&&o.byteLength>0&&this._writeDebugData(o,0),this._ownsBuffer&&s.destroy(),this._ownsBuffer=!0,this.generation++,this._touch(),!0}ensureSize(e,t){return e<=this.byteLength?!1:this.resize({byteLength:e,preserveData:t?.preserveData})}getBinding(e){return e?.offset===void 0&&e?.size===void 0?this._buffer:{buffer:this._buffer,offset:e?.offset,size:e?.size}}destroy(){this.destroyed||(this._ownsBuffer&&this._buffer.destroy(),this.destroyed=!0,this.debugData=new ArrayBuffer(0))}_copyBufferContents(e,t,i){let r=this.device.type==="webgpu"?Math.ceil(i/4)*4:i,s=this.device.createCommandEncoder();s.copyBufferToBuffer({sourceBuffer:e,destinationBuffer:t,size:r}),this.device.submit(s.finish())}_touch(){this.updateTimestamp=this.device.incrementTimestamp()}_resetDebugData(e){if(!this._debugDataEnabled){this.debugData=new ArrayBuffer(0);return}this.debugData=new ArrayBuffer(Math.min(e,this._maxDebugDataByteLength))}_writeDebugData(e,t){if(!this._debugDataEnabled||this.debugData.byteLength===0||t>=this.debugData.byteLength)return!1;let i=ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),r=new Uint8Array(this.debugData),s=Math.min(i.byteLength,r.byteLength-t);return r.set(i.subarray(0,s),t),s>0}}});function yc(n){return n!==null&&typeof n=="object"&&"resolveTextureBinding"in n&&typeof n.resolveTextureBinding=="function"}function GF(n){return n?.type==="texture"||n?.type==="external-texture"}function z1(n,e,t){let i=Du(n,e,{ignoreWarnings:!0});return GF(i)?i:n.bindings.length===0&&t?.fallbackGroup!==void 0?{type:"texture",name:e,group:t.fallbackGroup,location:0}:null}var U1=C(()=>{ee()});function O_(n,e){return n.shaderLanguage!==void 0&&n.shaderLanguage!==e?!1:e==="glsl"?"assembleGLSLShaderPair"in n&&typeof n.assembleGLSLShaderPair=="function":"assembleWGSLShader"in n&&typeof n.assembleWGSLShader=="function"}function jF(n,e){return!n||Object.keys(e).length===0?n:{...n,attributes:n.attributes.map(t=>{let i=t.name.startsWith("_luma_")?t.name.slice(6):null;return i&&e[i]?{...t,name:i}:t})}}function HF(n,e,t){if(yc(e)){let i=z1(t,n,{fallbackGroup:0});return i?e.resolveTextureBinding(i):null}return e instanceof nt?e.buffer:R_(e)?F1(e):e}function YF(n){return n&&!$1(n)?n:null}function qF(n){return n&&$1(n)?n:void 0}function $1(n){return WF.includes(n)}function ZF(n){return{type:n.type,shaderLanguage:n.info.shadingLanguage,shaderLanguageVersion:n.info.shadingLanguageVersion,gpu:n.info.gpu,limits:n.limits,features:n.features}}var Hn,VF,B_,WF,Ze,D_=C(()=>{ee();bt();w1();S1();L1();M1();A1();R1();T_();_o();k_();I_();U1();Hn=2,VF=1e4,B_="render pipeline initialization failed",WF=["stencil8","depth16unorm","depth24plus","depth24plus-stencil8","depth32float","depth32float-stencil8"],Ze=class n{static defaultProps={...Ht.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],plugins:[],geometry:null,indexBuffer:null,indexCount:void 0,firstVertex:0,firstIndex:0,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,material:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:Yt.getDefaultShaderAssembler("glsl"),debugShaders:void 0,disableWarnings:void 0};device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexCount;firstVertex;firstIndex;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;material=null;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_dynamicIndexBufferSource=null;_dynamicAttributeBufferSources={};_colorAttachmentFormats;_depthStencilAttachmentFormat;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_drawBlockedReason=!1;_destroyed=!1;_vertexCountSet=!1;_lastDrawTimestamp=-1;_bindingTable=[];get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(e,t){let i=n.defaultProps.shaderAssembler,r=t.vertexCount!==void 0;this.props={...n.defaultProps,...t,shaderAssembler:t.shaderAssembler??(O_(i,e.info.shadingLanguage)?i:Yt.getDefaultShaderAssembler(e.info.shadingLanguage))},this._vertexCountSet=r,t=this.props,this.id=t.id||jn("model"),this.device=e,Object.assign(this.userData,t.userData),this.material=t.material||null;let s=ZF(e),o=$a(this.props.plugins,s.shaderLanguage),a=Ga(this.props.modules,o.modules),c=Object.fromEntries(a.map(h=>[h.name,h])),l=t.shaderInputs||new xo(c,{disableWarnings:this.props.disableWarnings});t.shaderInputs&&o.modules.length>0&&l.addModules(o.modules),this.setShaderInputs(l);let u=If(this.props.modules,l.getModules()),f={...o.defines,...this.props.defines};if(this.device.type==="webgl"&&(this.props._uniformBlockLayouts=B1(u)),this.props.shaderLayout=vo(this.props.shaderLayout,u)||null,this.device.type==="webgpu"&&this.props.source){let h=this.props.shaderAssembler;$i(O_(h,"wgsl"));let{source:p,getUniforms:m,bindingTable:g,shaderLayout:v}=h.assembleWGSLShader({platformInfo:s,...this.props,modules:u,defines:f,pluginInjections:o.injections,pluginVertexInputs:o.vertexInputs,pluginVaryings:o.varyings});this.source=p,this._getModuleUniforms=m,this._bindingTable=g;let y=v??e.getShaderLayout?.(this.source),b=jF(y,o.vertexInputs),w=I1(this.props.shaderLayout,b,Object.keys(o.vertexInputs));this.props.shaderLayout=vo(w||null,u)||null}else{let h=this.props.shaderAssembler;$i(O_(h,"glsl"));let{vs:p,fs:m,getUniforms:g}=h.assembleGLSLShaderPair({platformInfo:s,...this.props,modules:u,defines:f,pluginInjections:o.injections,pluginVertexInputs:o.vertexInputs,pluginVaryings:o.varyings});this.vs=p,this.fs=m,this._getModuleUniforms=g,this._bindingTable=[]}this.vertexCount=this.props.vertexCount,this.indexCount=this.props.indexCount,this.firstVertex=this.props.firstVertex,this.firstIndex=this.props.firstIndex,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,this._colorAttachmentFormats=this.props.colorAttachmentFormats,this._depthStencilAttachmentFormat=this.props.depthStencilAttachmentFormat,t.geometry&&this.setGeometry(t.geometry),this.pipelineFactory=t.pipelineFactory||Ir.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||Br.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in t&&(this.isInstanced=t.isInstanced),t.instanceCount&&this.setInstanceCount(t.instanceCount),t.vertexCount&&this.setVertexCount(t.vertexCount),t.indexBuffer&&this.setIndexBuffer(t.indexBuffer),t.attributes&&this.setAttributes(t.attributes),t.constantAttributes&&this.setConstantAttributes(t.constantAttributes),t.bindings&&this.setBindings(t.bindings),t.transformFeedback&&(this.transformFeedback=t.transformFeedback)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}getBindingDebugTable(){return this._bindingTable}predraw(e){this._syncDynamicBuffers(),this.updateShaderInputs(e),this.material?.updateShaderInputs(e),this.pipeline=this._updatePipeline()}draw(e){if(this._drawBlockedReason&&!this._pipelineNeedsUpdate)return z.info(Hn,`>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)(),!1;let t=this._areBindingsLoading();if(t)return z.info(Hn,`>>> DRAWING ABORTED ${this.id}: ${t} not loaded`)(),!1;this._syncAttachmentFormats(e);try{e.pushDebugGroup(`${this}.predraw(${e})`),this.device.type==="webgpu"?(this.updateShaderInputs(),this.material?.updateShaderInputs(),this._syncDynamicBuffers(),this.pipeline=this._updatePipeline()):this.predraw(this.device.commandEncoder)}finally{e.popDebugGroup()}let i,r=this.pipeline.isErrored;try{if(e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline(),r=this.pipeline.isErrored,r)z.info(Hn,`>>> DRAWING ABORTED ${this.id}: ${B_}`)(),i=!1;else{let s=this.vertexArray.getDrawValidationError();if(s)z.info(Hn,`>>> DRAWING ABORTED ${this.id}: ${s}`)(),this._drawBlockedReason=s,i=!1;else{let o=this._getCurrentShaderLayout(),a=this._getBindings(o),c=this._getBindGroups(o,a),{indexBuffer:l}=this.vertexArray,u=l?this.indexCount??(this._vertexCountSet?this.vertexCount:l.byteLength/(l.indexType==="uint32"?4:2)):void 0;e.setPipeline(this.pipeline),e.setBindings(c,{_bindGroupCacheKeys:this._getBindGroupCacheKeys()}),e.setVertexArray(this.vertexArray),i=this.isInstanced===!0&&this.instanceCount===0?!0:e.draw({isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.isInstanced?this.instanceCount:void 0,indexCount:u,firstVertex:this.firstVertex,firstIndex:this.firstIndex,transformFeedback:this.transformFeedback||void 0,uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}}}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),i?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):r?(this._needsRedraw=B_,this._drawBlockedReason=B_):this._drawBlockedReason?this._needsRedraw=this._drawBlockedReason:this._needsRedraw="waiting for resource initialization",i}setGeometry(e){this._gpuGeometry?.destroy();let t=e&&x1(this.device,e);if(t){this.setTopology(t.topology||"triangle-list");let i=new bo(this.bufferLayout);this.bufferLayout=i.mergeBufferLayouts(t.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(t)}this._gpuGeometry=t}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){let t=new bo(this.bufferLayout),i=this._gpuGeometry?t.mergeBufferLayouts(e,this._gpuGeometry.bufferLayout):e;yo(i,this.bufferLayout,-1)||(this.bufferLayout=i,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry))}setParameters(e){yo(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,this.isInstanced===void 0&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this._vertexCountSet=!0,this.setNeedsRedraw("vertexCount")}setIndexCount(e){this.indexCount=e,this.setNeedsRedraw("indexCount")}setDrawOffsets({firstVertex:e,firstIndex:t}){this.firstVertex=e,this.firstIndex=t,this.setNeedsRedraw("drawOffsets")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new Nr(this.device,this.shaderInputs.modules);for(let[t,i]of Object.entries(this.shaderInputs.modules))if(gc(i)&&!this.material?.ownsModule(t)){let r=this._uniformStore.getManagedUniformBuffer(t);this.bindings[`${t}Uniforms`]=r}this.setNeedsRedraw("shaderInputs")}setMaterial(e){this.material=e,this.setNeedsRedraw("material")}updateShaderInputs(e){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),e),this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues())),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){let t=e instanceof nt?e.buffer:e;this.indexBuffer=t,this._dynamicIndexBufferSource=e instanceof nt?{source:e,generation:e.generation}:null,this.vertexArray.setIndexBuffer(t),this.setNeedsRedraw("indexBuffer")}setAttributes(e,t){this._drawBlockedReason=!1;let i=t?.disableWarnings??this.props.disableWarnings;e.indices&&z.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=k1(this.pipeline.shaderLayout,this.bufferLayout);let r=new bo(this.bufferLayout);for(let[s,o]of Object.entries(e)){let a=o instanceof nt?o.buffer:o,c=r.getBufferLayout(s);if(!c){i||z.warn(`Model(${this.id}): Missing layout for buffer "${s}".`)();continue}let l=r.getAttributeNamesForBuffer(c),u=!1;for(let f of l){let d=this._attributeInfos[f];if(d){let h=this.device.type==="webgpu"?this.vertexArray.getBufferSlot(d.bufferName):d.location;if(h===null){i||z.warn(`Model(${this.id}): Missing vertex array slot for buffer "${d.bufferName}".`)();continue}this.vertexArray.setBuffer(h,a),o instanceof nt?this._dynamicAttributeBufferSources[h]={source:o,generation:o.generation}:delete this._dynamicAttributeBufferSources[h],u=!0}}!u&&!i&&z.warn(`Model(${this.id}): Ignoring buffer "${a.id}" for unknown attribute "${s}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,t){for(let[i,r]of Object.entries(e)){let s=this._attributeInfos[i];s?this.vertexArray.setConstantWebGL(s.location,r):(t?.disableWarnings??this.props.disableWarnings)||z.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(let e of Object.values(this.bindings))if(yc(e)&&!e.isReady)return e.id;for(let e of Object.values(this.material?.bindings||{}))if(yc(e)&&!e.isReady)return e.id;return!1}_getBindings(e=this._getCurrentShaderLayout()){let t={};for(let[i,r]of Object.entries(this.bindings)){let s=HF(i,r,e);s&&(t[i]=s)}return t}_getBindGroups(e=this._getCurrentShaderLayout(),t=this._getBindings(e)){let i=e.bindings.length?Or(e,t):{0:t};if(!this.material)return i;for(let[r,s]of Object.entries(this.material.getBindingsByGroup(e))){let o=Number(r);i[o]={...i[o]||{},...s}}return i}_getBindGroupCacheKeys(){let e=this.material?.getBindGroupCacheKey(3);return e?{3:e}:{}}_getBindingsUpdateTimestamp(){let e=0;this._dynamicIndexBufferSource&&(e=Math.max(e,this._dynamicIndexBufferSource.source.updateTimestamp));for(let t of Object.values(this._dynamicAttributeBufferSources))e=Math.max(e,t.source.updateTimestamp);for(let t of Object.values(this.bindings))t instanceof Ar?e=Math.max(e,t.texture.updateTimestamp):t instanceof re||t instanceof pe||t instanceof Ma||t instanceof nt?e=Math.max(e,t.updateTimestamp):yc(t)?e=t.isReady?Math.max(e,t.updateTimestamp):1/0:R_(t)&&(e=Math.max(e,(t.buffer instanceof nt,t.buffer.updateTimestamp)));return Math.max(e,this.material?.getBindingsUpdateTimestamp()||0)}_setGeometryAttributes(e){let t={...e.attributes};for(let[i]of Object.entries(t))!this.pipeline.shaderLayout.attributes.find(r=>r.name===i)&&i!=="positions"&&delete t[i];this.vertexCount=e.vertexCount,this._vertexCountSet=!0,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(t,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this._drawBlockedReason=!1,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,t=null;this.pipeline&&(z.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,t=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let i=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders}),r=null;this.source?r=i:this.fs&&(r=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bindings:void 0,bufferLayout:this.bufferLayout,colorAttachmentFormats:this._colorAttachmentFormats,depthStencilAttachmentFormat:this._depthStencilAttachmentFormat,topology:this.topology,parameters:this.parameters,bindGroups:void 0,vs:i,fs:r}),this._attributeInfos=Ua(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&t!==e&&this.shaderFactory.release(t)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=z.level>3?0:VF;z.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:z.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=E1(this.pipeline.shaderLayout,this.id);z.table(Hn,e)();let t=this.shaderInputs.getDebugTable();z.table(Hn,t)();let i=this._getAttributeDebugTable();z.table(Hn,this._attributeInfos)(),z.table(Hn,i)(),z.groupEnd(Hn)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){let t=this.device.props.debugFramebuffers;if(this._drawCount++,!t)return;let i=e.props.framebuffer;T1(e,i,{id:i?.id||`${this.id}-framebuffer`,minimap:!0})}_getAttributeDebugTable(){let e={};for(let[t,i]of Object.entries(this._attributeInfos)){let r=this.vertexArray.attributes[i.location];e[i.location]={name:t,type:i.shaderType,values:r?this._getBufferOrConstantValues(r,i.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:t}=this.vertexArray,i=t.indexType==="uint32"?new Uint32Array(t.debugData):new Uint16Array(t.debugData);e.indices={name:"indices",type:t.indexType,values:i.toString()}}return e}_getBufferOrConstantValues(e,t){let i=Ke.getTypedArrayConstructor(t);return(e instanceof re?new i(e.debugData):e).toString()}_getNonMaterialBindings(e){if(!this.material)return e;let t={};for(let[i,r]of Object.entries(e))this.material.ownsBinding(i)||(t[i]=r);return t}_getCurrentShaderLayout(){return this.pipeline?.shaderLayout||this.props.shaderLayout||{bindings:[]}}_syncDynamicBuffers(){if(this._dynamicIndexBufferSource&&this._dynamicIndexBufferSource.generation!==this._dynamicIndexBufferSource.source.generation){let e=this._dynamicIndexBufferSource.source.buffer;this.indexBuffer=e,this.vertexArray.setIndexBuffer(e),this._dynamicIndexBufferSource.generation=this._dynamicIndexBufferSource.source.generation,this.setNeedsRedraw("dynamic index buffer")}for(let[e,t]of Object.entries(this._dynamicAttributeBufferSources))t.generation!==t.source.generation&&(this.vertexArray.setBuffer(Number(e),t.source.buffer),t.generation=t.source.generation,this.setNeedsRedraw("dynamic attribute buffer"))}_syncAttachmentFormats(e){if(this.device.type!=="webgpu")return;let t=e.framebuffer||e.props.framebuffer,i=e.props,r=i.colorAttachmentFormats??t?.colorAttachments?.map(o=>YF(o?.texture?.format)),s=i.depthStencilAttachmentFormat===!1?void 0:i.depthStencilAttachmentFormat??qF(t?.depthStencilAttachment?.texture?.format);(!yo(this._colorAttachmentFormats,r,1)||this._depthStencilAttachmentFormat!==s)&&(this._colorAttachmentFormats=r,this._depthStencilAttachmentFormat=s,this._setPipelineNeedsUpdate("attachment formats"))}}});var XF,KF,it,G1=C(()=>{ee();bt();D_();XF=35980,KF=35981,it=class n{device;model;transformFeedback;static defaultProps={...Ze.defaultProps,feedbackBufferMode:"separate",outputs:void 0,feedbackBuffers:void 0};static isSupported(e){return e?.info?.type==="webgl"}constructor(e,t=n.defaultProps){if(!n.isSupported(e))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=e,this.model=new Ze(this.device,{id:t.id||"buffer-transform-model",fs:t.fs||dg(),topology:t.topology||"point-list",varyings:t.outputs||t.varyings,...t,bufferMode:t.bufferMode||(t.feedbackBufferMode==="interleaved"?XF:KF)}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:t.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){e?.inputBuffers&&this.model.setAttributes(e.inputBuffers),e?.outputBuffers&&this.transformFeedback.setBuffers(e.outputBuffers);let t=this.device.beginRenderPass({discard:!0,...e});this.model.draw(t),t.end()}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){let t=this.getBuffer(e);if(!t)throw new Error("BufferTransform#getBuffer");if(t instanceof re)return t.readAsync();let{buffer:i,byteOffset:r=0,byteLength:s=i.byteLength}=t;return i.readAsync(r,s)}}});function JF(n){return{type:n.type,shaderLanguage:n.info.shadingLanguage,shaderLanguageVersion:n.info.shadingLanguageVersion,gpu:n.info.gpu,limits:n.limits,features:n.features}}var N_,QF,Rt,V1=C(()=>{ee();bt();Qp();k_();T_();_o();N_=2,QF=1e4,Rt=class n{static defaultProps={...Wi.defaultProps,id:"unnamed",handle:void 0,userData:{},source:"",modules:[],defines:{},plugins:[],bindings:void 0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,shaderAssembler:Yt.getDefaultShaderAssembler("wgsl"),debugShaders:void 0};device;id;pipelineFactory;shaderFactory;userData={};bindings={};pipeline;source;shader;shaderInputs;_uniformStore;_pipelineNeedsUpdate="newly created";_getModuleUniforms;props;_destroyed=!1;constructor(e,t){if(e.type!=="webgpu")throw new Error("Computation is only supported in WebGPU");this.props={...n.defaultProps,...t},t=this.props,this.id=t.id||jn("model"),this.device=e,Object.assign(this.userData,t.userData);let i=JF(e),r=$a(this.props.plugins,i.shaderLanguage);if(Object.keys(r.vertexInputs).length>0||Object.keys(r.varyings).length>0)throw new Error("Computation does not support ShaderPlugin vertex inputs or varyings");let s=Ga(this.props.modules,r.modules),o=Object.fromEntries(s.map(p=>[p.name,p]));this.shaderInputs=t.shaderInputs||new xo(o),t.shaderInputs&&r.modules.length>0&&this.shaderInputs.addModules(r.modules),this.setShaderInputs(this.shaderInputs);let a=If(this.props.modules,this.shaderInputs?.getModules()),c={...r.defines,...this.props.defines};this.props.shaderLayout=vo(this.props.shaderLayout,a)||null,this.pipelineFactory=t.pipelineFactory||Ir.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||Br.getDefaultShaderFactory(this.device);let l=this.props.shaderAssembler;$i(l instanceof Hi);let{source:u,getUniforms:f,shaderLayout:d}=l.assembleWGSLShader({platformInfo:i,...this.props,modules:a,defines:c,scanVertexAttributes:!1,pluginInjections:r.injections});this.source=u,this._getModuleUniforms=f;let h=d??e.getShaderLayout?.(this.source,{scanVertexAttributes:!1});this.props.shaderLayout=vo(this.props.shaderLayout||h||null,a)||null,this.pipeline=this._updatePipeline(),t.bindings&&this.setBindings(t.bindings)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.shader),this._uniformStore.destroy(),this._destroyed=!0)}predraw(e){this.updateShaderInputs(e)}dispatch(e,t,i,r){try{this._logDrawCallStart(),this._setPipeline(e),e.dispatch(t,i,r)}finally{this._logDrawCallEnd()}}dispatchIndirect(e,t,i=0){try{this._logDrawCallStart(),this._setPipeline(e),e.dispatchIndirect(t,i)}finally{this._logDrawCallEnd()}}_setPipeline(e){this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings),e.setPipeline(this.pipeline),e.setBindings({})}setVertexCount(e){}setInstanceCount(e){}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new Nr(this.device,this.shaderInputs.modules);for(let[t,i]of Object.entries(this.shaderInputs.modules))if(gc(i)){let r=this._uniformStore.getManagedUniformBuffer(t);this.bindings[`${t}Uniforms`]=r}}setShaderModuleProps(e){let t=this._getModuleUniforms(e),i=Object.keys(t).filter(s=>{let o=t[s];return!ga(o)&&typeof o!="number"&&typeof o!="boolean"}),r={};for(let s of i)r[s]=t[s],delete t[s]}updateShaderInputs(e){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),e)}setBindings(e){Object.assign(this.bindings,e)}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate=this._pipelineNeedsUpdate||e}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null;this.pipeline&&(z.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.shader),this._pipelineNeedsUpdate=!1,this.shader=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"compute",source:this.source,debugShaders:this.props.debugShaders}),this.pipeline=this.pipelineFactory.createComputePipeline({...this.props,shader:this.shader}),e&&this.shaderFactory.release(e)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=z.level>3?0:QF;z.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:z.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=this.shaderInputs.getDebugTable();z.table(N_,e)(),z.groupEnd(N_)(),this._logOpen=!1}}_drawCount=0;_getBufferOrConstantValues(e,t){let i=Ke.getTypedArrayConstructor(t);return(e instanceof re?new i(e.debugData):e).toString()}}});var Ce=C(()=>{m1();v1();D_();G1();kf();I_();V1()});function r2(n=!0){let e=HTMLCanvasElement.prototype;if(!n&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(t,i){if(t==="webgl"||t==="experimental-webgl"){let r=this.originalGetContext("webgl2",i);return r instanceof HTMLElement&&A6(r),r}return this.originalGetContext(t,i)}}function A6(n){n.getExtension("EXT_color_buffer_float");let e={...C6,WEBGL_disjoint_timer_query:n.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:T6(n),OES_vertex_array_object:L6(n),ANGLE_instanced_arrays:M6(n)},t=n.getExtension.bind(n);n.getExtension=function(r){let s=t(r);return s||(r in e?e[r]:null)};let i=n.getSupportedExtensions;n.getSupportedExtensions=function(){return(i.apply(n)||[])?.concat(Object.keys(e))}}var C6,T6,L6,M6,s2=C(()=>{C6={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},T6=n=>({drawBuffersWEBGL(e){return n.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),L6=n=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return n.createVertexArray()},deleteVertexArrayOES(e){return n.deleteVertexArray(e)},isVertexArrayOES(e){return n.isVertexArray(e)},bindVertexArrayOES(e){return n.bindVertexArray(e)}}),M6=n=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return n.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return n.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return n.vertexAttribDivisor(...e)}})});async function a2(){if(!$f){q_();return}await $f.load()}function c2(n,e){return $f?$f.makeDebugContext(n,e):(q_(),n)}async function l2(n){if(!Y_){q_();return}await Y_.load(n)}function u2(n){return Y_?.initialize(n)||null}function q_(){o2||(o2=!0,z.warn("Import @luma.gl/webgl/debug before enabling WebGL debugging.")())}var $f,Y_,o2,Z_=C(()=>{ee();$f=null,Y_=null,o2=!1});function X_(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Re(n,e,t){return e[n]!==void 0?e[n]:t[n]}var Bc,ze,f2,It,d2,Ic,h2,p2,K_,Xn,Q_,m2,J_=C(()=>{Bc={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},ze=(n,e,t)=>e?n.enable(t):n.disable(t),f2=(n,e,t)=>n.hint(t,e),It=(n,e,t)=>n.pixelStorei(t,e),d2=(n,e,t)=>{let i=t===36006?36009:36008;return n.bindFramebuffer(i,e)},Ic=(n,e,t)=>{let r={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[t];n.bindBuffer(r,e)};h2={3042:ze,32773:(n,e)=>n.blendColor(...e),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(n,e)=>n.clearColor(...e),3107:(n,e)=>n.colorMask(...e),2884:ze,2885:(n,e)=>n.cullFace(e),2929:ze,2931:(n,e)=>n.clearDepth(e),2932:(n,e)=>n.depthFunc(e),2928:(n,e)=>n.depthRange(...e),2930:(n,e)=>n.depthMask(e),3024:ze,35723:f2,35725:(n,e)=>n.useProgram(e),36007:(n,e)=>n.bindRenderbuffer(36161,e),36389:(n,e)=>n.bindTransformFeedback?.(36386,e),34229:(n,e)=>n.bindVertexArray(e),36006:d2,36010:d2,34964:Ic,36662:Ic,36663:Ic,35053:Ic,35055:Ic,2886:(n,e)=>n.frontFace(e),33170:f2,2849:(n,e)=>n.lineWidth(e),32823:ze,32824:"polygonOffset",10752:"polygonOffset",35977:ze,32926:ze,32928:ze,32938:"sampleCoverage",32939:"sampleCoverage",3089:ze,3088:(n,e)=>n.scissor(...e),2960:ze,2961:(n,e)=>n.clearStencil(e),2968:(n,e)=>n.stencilMaskSeparate(1028,e),36005:(n,e)=>n.stencilMaskSeparate(1029,e),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(n,e)=>n.viewport(...e),34383:ze,10754:ze,12288:ze,12289:ze,12290:ze,12291:ze,12292:ze,12293:ze,12294:ze,12295:ze,3333:It,3317:It,37440:It,37441:It,37443:It,3330:It,3332:It,3331:It,3314:It,32878:It,3316:It,3315:It,32877:It,framebuffer:(n,e)=>{let t=e&&"handle"in e?e.handle:e;return n.bindFramebuffer(36160,t)},blend:(n,e)=>e?n.enable(3042):n.disable(3042),blendColor:(n,e)=>n.blendColor(...e),blendEquation:(n,e)=>{let t=typeof e=="number"?[e,e]:e;n.blendEquationSeparate(...t)},blendFunc:(n,e)=>{let t=e?.length===2?[...e,...e]:e;n.blendFuncSeparate(...t)},clearColor:(n,e)=>n.clearColor(...e),clearDepth:(n,e)=>n.clearDepth(e),clearStencil:(n,e)=>n.clearStencil(e),colorMask:(n,e)=>n.colorMask(...e),cull:(n,e)=>e?n.enable(2884):n.disable(2884),cullFace:(n,e)=>n.cullFace(e),depthTest:(n,e)=>e?n.enable(2929):n.disable(2929),depthFunc:(n,e)=>n.depthFunc(e),depthMask:(n,e)=>n.depthMask(e),depthRange:(n,e)=>n.depthRange(...e),dither:(n,e)=>e?n.enable(3024):n.disable(3024),derivativeHint:(n,e)=>{n.hint(35723,e)},frontFace:(n,e)=>n.frontFace(e),mipmapHint:(n,e)=>n.hint(33170,e),lineWidth:(n,e)=>n.lineWidth(e),polygonOffsetFill:(n,e)=>e?n.enable(32823):n.disable(32823),polygonOffset:(n,e)=>n.polygonOffset(...e),sampleCoverage:(n,e)=>n.sampleCoverage(e[0],e[1]||!1),scissorTest:(n,e)=>e?n.enable(3089):n.disable(3089),scissor:(n,e)=>n.scissor(...e),stencilTest:(n,e)=>e?n.enable(2960):n.disable(2960),stencilMask:(n,e)=>{e=X_(e)?e:[e,e];let[t,i]=e;n.stencilMaskSeparate(1028,t),n.stencilMaskSeparate(1029,i)},stencilFunc:(n,e)=>{e=X_(e)&&e.length===3?[...e,...e]:e;let[t,i,r,s,o,a]=e;n.stencilFuncSeparate(1028,t,i,r),n.stencilFuncSeparate(1029,s,o,a)},stencilOp:(n,e)=>{e=X_(e)&&e.length===3?[...e,...e]:e;let[t,i,r,s,o,a]=e;n.stencilOpSeparate(1028,t,i,r),n.stencilOpSeparate(1029,s,o,a)},viewport:(n,e)=>n.viewport(...e)};p2={blendEquation:(n,e,t)=>n.blendEquationSeparate(Re(32777,e,t),Re(34877,e,t)),blendFunc:(n,e,t)=>n.blendFuncSeparate(Re(32969,e,t),Re(32968,e,t),Re(32971,e,t),Re(32970,e,t)),polygonOffset:(n,e,t)=>n.polygonOffset(Re(32824,e,t),Re(10752,e,t)),sampleCoverage:(n,e,t)=>n.sampleCoverage(Re(32938,e,t),Re(32939,e,t)),stencilFuncFront:(n,e,t)=>n.stencilFuncSeparate(1028,Re(2962,e,t),Re(2967,e,t),Re(2963,e,t)),stencilFuncBack:(n,e,t)=>n.stencilFuncSeparate(1029,Re(34816,e,t),Re(36003,e,t),Re(36004,e,t)),stencilOpFront:(n,e,t)=>n.stencilOpSeparate(1028,Re(2964,e,t),Re(2965,e,t),Re(2966,e,t)),stencilOpBack:(n,e,t)=>n.stencilOpSeparate(1029,Re(34817,e,t),Re(34818,e,t),Re(34819,e,t))},K_={enable:(n,e)=>n({[e]:!0}),disable:(n,e)=>n({[e]:!1}),pixelStorei:(n,e,t)=>n({[e]:t}),hint:(n,e,t)=>n({[e]:t}),useProgram:(n,e)=>n({35725:e}),bindRenderbuffer:(n,e,t)=>n({36007:t}),bindTransformFeedback:(n,e,t)=>n({36389:t}),bindVertexArray:(n,e)=>n({34229:e}),bindFramebuffer:(n,e,t)=>{switch(e){case 36160:return n({36006:t,36010:t});case 36009:return n({36006:t});case 36008:return n({36010:t});default:return null}},bindBuffer:(n,e,t)=>{let i={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[e];return i?n({[i]:t}):{valueChanged:!0}},blendColor:(n,e,t,i,r)=>n({32773:new Float32Array([e,t,i,r])}),blendEquation:(n,e)=>n({32777:e,34877:e}),blendEquationSeparate:(n,e,t)=>n({32777:e,34877:t}),blendFunc:(n,e,t)=>n({32969:e,32968:t,32971:e,32970:t}),blendFuncSeparate:(n,e,t,i,r)=>n({32969:e,32968:t,32971:i,32970:r}),clearColor:(n,e,t,i,r)=>n({3106:new Float32Array([e,t,i,r])}),clearDepth:(n,e)=>n({2931:e}),clearStencil:(n,e)=>n({2961:e}),colorMask:(n,e,t,i,r)=>n({3107:[e,t,i,r]}),cullFace:(n,e)=>n({2885:e}),depthFunc:(n,e)=>n({2932:e}),depthRange:(n,e,t)=>n({2928:new Float32Array([e,t])}),depthMask:(n,e)=>n({2930:e}),frontFace:(n,e)=>n({2886:e}),lineWidth:(n,e)=>n({2849:e}),polygonOffset:(n,e,t)=>n({32824:e,10752:t}),sampleCoverage:(n,e,t)=>n({32938:e,32939:t}),scissor:(n,e,t,i,r)=>n({3088:new Int32Array([e,t,i,r])}),stencilMask:(n,e)=>n({2968:e,36005:e}),stencilMaskSeparate:(n,e,t)=>n({[e===1028?2968:36005]:t}),stencilFunc:(n,e,t,i)=>n({2962:e,2967:t,2963:i,34816:e,36003:t,36004:i}),stencilFuncSeparate:(n,e,t,i,r)=>n({[e===1028?2962:34816]:t,[e===1028?2967:36003]:i,[e===1028?2963:36004]:r}),stencilOp:(n,e,t,i)=>n({2964:e,2965:t,2966:i,34817:e,34818:t,34819:i}),stencilOpSeparate:(n,e,t,i,r)=>n({[e===1028?2964:34817]:t,[e===1028?2965:34818]:i,[e===1028?2966:34819]:r}),viewport:(n,e,t,i,r)=>n({2978:[e,t,i,r]})},Xn=(n,e)=>n.isEnabled(e),Q_={3042:Xn,2884:Xn,2929:Xn,3024:Xn,32823:Xn,32926:Xn,32928:Xn,3089:Xn,2960:Xn,35977:Xn},m2=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068])});function gn(n,e){if(k6(e))return;let t={};for(let r in e){let s=Number(r),o=h2[r];o&&(typeof o=="string"?t[o]=!0:o(n,e[r],s))}let i=n.lumaState?.cache;if(i)for(let r in t){let s=p2[r];s(n,e,i)}}function Gf(n,e=Bc){if(typeof e=="number"){let r=e,s=Q_[r];return s?s(n,r):n.getParameter(r)}let t=Array.isArray(e)?e:Object.keys(e),i={};for(let r of t){let s=Q_[r];i[r]=s?s(n,Number(r)):n.getParameter(Number(r))}return i}function g2(n){gn(n,Bc)}function k6(n){for(let e in n)return!1;return!0}var Po=C(()=>{J_()});function y2(n,e){if(n===e)return!0;if(_2(n)&&_2(e)&&n.length===e.length){for(let t=0;t{});function v2(n,e){let t=n[e].bind(n);n[e]=function(r){if(r===void 0||m2.has(r))return t(r);let s=_n.get(n);return r in s.cache||(s.cache[r]=t(r)),s.enable?s.cache[r]:t(r)},Object.defineProperty(n[e],"name",{value:`${e}-from-cache`,configurable:!1})}function R6(n,e,t){if(!n[e])return;let i=n[e].bind(n);n[e]=function(...s){let o=_n.get(n),{valueChanged:a,oldValue:c}=t(o._updateCache,...s);return a&&i(...s),c},Object.defineProperty(n[e],"name",{value:`${e}-to-cache`,configurable:!1})}function I6(n){let e=n.useProgram.bind(n);n.useProgram=function(i){let r=_n.get(n);r.program!==i&&(e(i),r.program=i)}}var _n,ey=C(()=>{Po();b2();J_();_n=class{static get(e){return e.lumaState}gl;program=null;stateStack=[];enable=!0;cache=null;log;initialized=!1;constructor(e,t){this.gl=e,this.log=t?.log||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){let e=this.stateStack[this.stateStack.length-1];gn(this.gl,e),this.stateStack.pop()}trackState(e,t){if(this.cache=t?.copyState?Gf(e):Object.assign({},Bc),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.lumaState=this,I6(e);for(let i in K_){let r=K_[i];R6(e,i,r)}v2(e,"getParameter"),v2(e,"isEnabled")}_updateCache(e){let t=!1,i,r=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let s in e){let o=e[s],a=this.cache[s];y2(o,a)||(t=!0,i=a,r&&!(s in r)&&(r[s]=a),this.cache[s]=o)}return{valueChanged:t,oldValue:i}}}});function Oc(n){let e=n.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return e._polyfilled??=!1,e.extensions||={},n.luma=e,e}var ty=C(()=>{});function x2(n,e,t){let i="",r=c=>{let l=c.statusMessage;l&&(i||=l)};n.addEventListener("webglcontextcreationerror",r,!1);let s=t.failIfMajorPerformanceCaveat!==!0,o={preserveDrawingBuffer:!0,...t,failIfMajorPerformanceCaveat:!0},a=null;try{a||=n.getContext("webgl2",o),!a&&o.failIfMajorPerformanceCaveat&&(i||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.");let c=!1;if(!a&&s&&(o.failIfMajorPerformanceCaveat=!1,a=n.getContext("webgl2",o),c=!0),a||(a=n.getContext("webgl",{}),a&&(a=null,i||="Your browser only supports WebGL1")),!a)throw i||="Your browser does not support WebGL",new Error(`Failed to create WebGL context: ${i}`);let l=Oc(a);l.softwareRenderer=c;let{onContextLost:u,onContextRestored:f}=e;return n.addEventListener("webglcontextlost",d=>u(d),!1),n.addEventListener("webglcontextrestored",d=>f(d),!1),a}finally{n.removeEventListener("webglcontextcreationerror",r,!1)}}var w2=C(()=>{ty()});function yn(n,e,t){return t[e]===void 0&&(t[e]=n.getExtension(e)||null),t[e]}var Dc=C(()=>{});function E2(n,e){let t=n.getParameter(7936),i=n.getParameter(7937);yn(n,"WEBGL_debug_renderer_info",e);let r=e.WEBGL_debug_renderer_info,s=n.getParameter(r?r.UNMASKED_VENDOR_WEBGL:7936),o=n.getParameter(r?r.UNMASKED_RENDERER_WEBGL:7937),a=s||t,c=o||i,l=n.getParameter(7938),u=S2(a,c),f=B6(a,c),d=O6(a,c);return{type:"webgl",gpu:u,gpuType:d,gpuBackend:f,vendor:a,renderer:c,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function S2(n,e){return/NVIDIA/i.exec(n)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(n)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(n)||/Apple/i.exec(e)?"apple":/AMD/i.exec(n)||/AMD/i.exec(e)||/ATI/i.exec(n)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(n)||/SwiftShader/i.exec(e)?"software":"unknown"}function B6(n,e){return/Metal/i.exec(n)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(n)||/ANGLE/i.exec(e)?"opengl":"unknown"}function O6(n,e){if(/SwiftShader/i.exec(n)||/SwiftShader/i.exec(e))return"cpu";switch(S2(n,e)){case"apple":return D6(n,e)?"integrated":"unknown";case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function D6(n,e){return/Apple (M\d|A\d|GPU)/i.test(`${n} ${e}`)}var P2=C(()=>{Dc()});function Vf(n){switch(n){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(n))}var ny=C(()=>{});function L2(n){return n in jf}function ay(n,e,t){return M2(n,e,t,new Set)}function M2(n,e,t,i){let r=jf[e];if(!r||i.has(e))return!1;i.add(e);let s=(r.features||[]).every(o=>M2(n,o,t,i));return i.delete(e),s?(r.extensions||[]).every(o=>!!yn(n,o,t)):!1}function A2(n,e,t){let i=e.create,r=Hf[e.format];r?.gl===void 0&&(i=!1),r?.x&&(i=i&&!!yn(n,r.x,t)),e.format==="stencil8"&&(i=!1);let s=r?.r===!1?!1:r?.r===void 0||ay(n,r.r,t),o=i&&e.render&&s&&W6(n,e.format,t);return{format:e.format,create:i&&e.create,render:o,filter:i&&e.filter,blend:i&&e.blend,store:i&&e.store}}function W6(n,e,t){let i=Hf[e],r=i?.gl;if(r===void 0||i?.x&&!yn(n,i.x,t))return!1;let s=n.getParameter(32873),o=n.getParameter(36006),a=n.createTexture(),c=n.createFramebuffer();if(!a||!c)return!1;let l=0,u=Number(n.getError());for(;u!==l;)u=n.getError();let f=!1;try{if(n.bindTexture(3553,a),n.texStorage2D(3553,1,r,1,1),Number(n.getError())!==l)return!1;n.bindFramebuffer(36160,c),n.framebufferTexture2D(36160,36064,3553,a,0),f=Number(n.checkFramebufferStatus(36160))===36053&&Number(n.getError())===l}finally{n.bindFramebuffer(36160,o),n.deleteFramebuffer(c),n.bindTexture(3553,s),n.deleteTexture(a)}return f}function Yf(n){let e=Hf[n],t=H6(n),i=ft.getInfo(n);return i.compressed&&(e.dataFormat=t),{internalFormat:t,format:e?.dataFormat||j6(i.channels,i.integer,i.normalized,t),type:i.dataType?Vf(i.dataType):e?.types?.[0]||5121,compressed:i.compressed||!1}}function k2(n){switch(ft.getInfo(n).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${n}`)}}function j6(n,e,t,i){if(i===6408||i===6407)return i;switch(n){case"r":return e&&!t?36244:6403;case"rg":return e&&!t?33320:33319;case"rgb":return e&&!t?36248:6407;case"rgba":return e&&!t?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function H6(n){let t=Hf[n]?.gl;if(t===void 0)throw new Error(`Unsupported texture format ${n}`);return t}var Nc,Fc,Co,To,N6,F6,z6,U6,$6,G6,C2,T2,iy,ry,sy,oy,Wf,V6,jf,Hf,Lo=C(()=>{ee();Dc();ny();Nc="WEBGL_compressed_texture_s3tc",Fc="WEBGL_compressed_texture_s3tc_srgb",Co="EXT_texture_compression_rgtc",To="EXT_texture_compression_bptc",N6="WEBGL_compressed_texture_etc",F6="WEBGL_compressed_texture_astc",z6="WEBGL_compressed_texture_etc1",U6="WEBGL_compressed_texture_pvrtc",$6="WEBGL_compressed_texture_atc",G6="EXT_texture_norm16",C2="EXT_render_snorm",T2="EXT_color_buffer_float",iy="snorm8-renderable-webgl",ry="norm16-renderable-webgl",sy="snorm16-renderable-webgl",oy="float16-renderable-webgl",Wf="float32-renderable-webgl",V6="rgb9e5ufloat-renderable-webgl",jf={"float32-renderable-webgl":{extensions:[T2]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[C2]},"norm16-webgl":{extensions:[G6]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[C2]},"float32-filterable":{extensions:["OES_texture_float_linear"]},"float16-filterable-webgl":{extensions:["OES_texture_half_float_linear"]},"texture-filterable-anisotropic-webgl":{extensions:["EXT_texture_filter_anisotropic"]},"texture-blend-float-webgl":{extensions:["EXT_float_blend"]},"texture-compression-bc":{extensions:[Nc,Fc,Co,To]},"texture-compression-bc5-webgl":{extensions:[Co]},"texture-compression-bc7-webgl":{extensions:[To]},"texture-compression-etc2":{extensions:[N6]},"texture-compression-astc":{extensions:[F6]},"texture-compression-etc1-webgl":{extensions:[z6]},"texture-compression-pvrtc-webgl":{extensions:[U6]},"texture-compression-atc-webgl":{extensions:[$6]}};Hf={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:iy},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:iy},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0,r:oy},r16unorm:{gl:33322,rb:!0,r:ry},r16snorm:{gl:36760,r:sy},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759,r:iy},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:oy},rg16unorm:{gl:33324,r:ry},rg16snorm:{gl:36761,r:sy},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:Wf},rgb9e5ufloat:{gl:35901,r:V6},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852,r:!1},"rgb16snorm-webgl":{gl:36762,r:!1},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0,r:Wf},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:oy},rgba16unorm:{gl:32859,rb:!0,r:ry},rgba16snorm:{gl:36763,r:sy},"rgb32float-webgl":{gl:34837,x:T2,r:Wf,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:Wf},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:Nc},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:Fc},"bc1-rgba-unorm":{gl:33777,x:Nc},"bc1-rgba-unorm-srgb":{gl:35916,x:Fc},"bc2-rgba-unorm":{gl:33778,x:Nc},"bc2-rgba-unorm-srgb":{gl:35918,x:Fc},"bc3-rgba-unorm":{gl:33779,x:Nc},"bc3-rgba-unorm-srgb":{gl:35919,x:Fc},"bc4-r-unorm":{gl:36283,x:Co},"bc4-r-snorm":{gl:36284,x:Co},"bc5-rg-unorm":{gl:36285,x:Co},"bc5-rg-snorm":{gl:36286,x:Co},"bc6h-rgb-ufloat":{gl:36495,x:To},"bc6h-rgb-float":{gl:36494,x:To},"bc7-rgba-unorm":{gl:36492,x:To},"bc7-rgba-unorm-srgb":{gl:36493,x:To},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37816},"astc-10x5-unorm-srgb":{gl:37848},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rgb2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}}});var R2,qf,I2=C(()=>{ee();Dc();Lo();R2={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","html-in-canvas":n=>Bm()&&typeof n.texElementImage2D=="function","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},qf=class extends Ca{gl;extensions;testedFeatures=new Set;constructor(e,t,i){super([],i),this.gl=e,this.extensions=t,yn(e,"EXT_color_buffer_float",t)}*[Symbol.iterator](){let e=this.getFeatures();for(let t of e)this.has(t)&&(yield t);return[]}has(e){return this.disabledFeatures?.[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),L2(e)&&ay(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){let e=this.getFeatures().filter(t=>t!=="polygon-mode-webgl");for(let t of e)this.has(t)}getFeatures(){return[...Object.keys(R2),...Object.keys(jf)]}getWebGLFeature(e){let t=R2[e];return typeof t=="string"?!!yn(this.gl,t,this.extensions):typeof t=="function"?t(this.gl):!!t}}});var Zf,B2=C(()=>{ee();Zf=class extends Pa{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxBindGroupsPlusVertexBuffers(){return 0}get maxBindingsPerBindGroup(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageBuffersInVertexStage(){return 0}get maxStorageBuffersInFragmentStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxStorageTexturesInVertexStage(){return 0}get maxStorageTexturesInFragmentStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get maxBufferSize(){return Number.MAX_SAFE_INTEGER}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxColorAttachments(){return this.getParameter(36063)}get maxColorAttachmentBytesPerSample(){return 0}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]||0}}});function Y6(n){return n<34069?n+34069:n}function q6(n){switch(n){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${n}`}}var Kn,Xf=C(()=>{ee();Lo();Kn=class extends Rr{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(e,t){super(e,t);let i=t.handle,r=i===null;this.device=e,this.gl=e.gl,this.handle=i||r?i:this.gl.createFramebuffer(),r||(e._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),t.handle||(this.autoCreateAttachmentTextures(),this.updateAttachments()))}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&!this.props.handle&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){let e=this.gl.bindFramebuffer(36160,this.handle);for(let t=0;t{ee();Xf();Kf=class extends Ta{device;handle=null;_framebuffer=null;get[Symbol.toStringTag](){return"WebGLCanvasContext"}constructor(e,t){super(t),this.device=e,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._configureDevice()}_configureDevice(){(this.drawingBufferWidth!==this._framebuffer?.width||this.drawingBufferHeight!==this._framebuffer?.height)&&this._framebuffer?.resize([this.drawingBufferWidth,this.drawingBufferHeight])}_getCurrentFramebuffer(){return this._framebuffer||=new Kn(this.device,{id:"canvas-context-framebuffer",handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}}});var Qf,D2=C(()=>{ee();Qf=class extends La{device;handle=null;context2d;get[Symbol.toStringTag](){return"WebGLPresentationContext"}constructor(e,t={}){super(t),this.device=e;let i=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw new Error(`${i}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);let s=this.canvas.getContext("2d");if(!s)throw new Error(`${i}: Failed to create 2d presentation context`);this.context2d=s,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();let e=this.device.getDefaultCanvasContext(),[t,i]=e.getDrawingBufferSize();if(!(this.drawingBufferWidth===0||this.drawingBufferHeight===0||t===0||i===0||e.canvas.width===0||e.canvas.height===0)){if(t!==this.drawingBufferWidth||i!==this.drawingBufferHeight||e.canvas.width!==this.drawingBufferWidth||e.canvas.height!==this.drawingBufferHeight)throw new Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${t}x${i} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(e.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(e){let t=this.device.getDefaultCanvasContext();return t.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),t.getCurrentFramebuffer(e)}}});function N2(n="id"){cy[n]=cy[n]||1;let e=cy[n]++;return`${n}-${e}`}var cy,F2=C(()=>{cy={}});function Z6(n){return n&re.INDEX?34963:n&re.VERTEX?34962:n&re.UNIFORM?35345:34962}function X6(n){return n&re.INDEX||n&re.VERTEX?35044:n&re.UNIFORM?35048:35044}var bn,Jf=C(()=>{ee();bn=class extends re{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength=0;bytesUsed=0;constructor(e,t={}){super(e,t),this.device=e,this.gl=this.device.gl;let i=typeof t=="object"?t.handle:void 0;this.handle=i||this.gl.createBuffer(),e._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=Z6(this.props.usage),this.glUsage=X6(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,t.data?this._initWithData(t.data,t.byteOffset,t.byteLength):this._initWithByteLength(t.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Buffer"):(this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle)),this.destroyed=!0,this.handle=null)}_initWithData(e,t=0,i=e.byteLength+t){let r=this.glTarget;this.gl.bindBuffer(r,this.handle),this.gl.bufferData(r,i,this.glUsage),this.gl.bufferSubData(r,t,e),this.gl.bindBuffer(r,null),this.bytesUsed=i,this.byteLength=i,this._setDebugData(e,t,i),this.props.handle?this.trackReferencedMemory(i,"Buffer"):this.trackAllocatedMemory(i)}_initWithByteLength(e){let t=e;e===0&&(t=new Float32Array(0));let i=this.glTarget;return this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,t,this.glUsage),this.gl.bindBuffer(i,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.props.handle?this.trackReferencedMemory(e,"Buffer"):this.trackAllocatedMemory(e),this}write(e,t=0){let i=ArrayBuffer.isView(e)?e:new Uint8Array(e),r=0,s=void 0,o=36663;this.gl.bindBuffer(o,this.handle),r!==0||s!==void 0?this.gl.bufferSubData(o,t,i,r,s):this.gl.bufferSubData(o,t,i),this.gl.bindBuffer(o,null),this._setDebugData(e,t,e.byteLength)}async mapAndWriteAsync(e,t=0,i=this.byteLength-t){let r=new ArrayBuffer(i);await e(r,"copied"),this.write(r,t)}async readAsync(e=0,t){return this.readSyncWebGL(e,t)}async mapAndReadAsync(e,t=0,i){let r=await this.readAsync(t,i);return await e(r.buffer,"copied")}readSyncWebGL(e=0,t){t=t??this.byteLength-e;let i=new Uint8Array(t),r=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,i,r,t),this.gl.bindBuffer(36662,null),this._setDebugData(i,e,t),i}}});function z2(n){let e=n.split(/\r?\n/),t=[];for(let i of e){if(i.length<=1)continue;let r=i.trim(),s=i.split(":"),o=s[0]?.trim();if(s.length===2){let[h,p]=s;if(!h||!p){t.push({message:r,type:ed(o||"info"),lineNum:0,linePos:0});continue}t.push({message:p.trim(),type:ed(h),lineNum:0,linePos:0});continue}let[a,c,l,...u]=s;if(!a||!c||!l){t.push({message:s.slice(1).join(":").trim()||r,type:ed(o||"info"),lineNum:0,linePos:0});continue}let f=parseInt(l,10);Number.isNaN(f)&&(f=0);let d=parseInt(c,10);Number.isNaN(d)&&(d=0),t.push({message:u.join(":").trim(),type:ed(a),lineNum:f,linePos:d})}return t}function ed(n){let e=["warning","error","info"],t=n.toLowerCase();return e.includes(t)?t:"info"}var U2=C(()=>{});function K6(n){return n.split(/\r?\n/).find(e=>e.trim())?.trim()}var td,$2=C(()=>{ee();U2();td=class extends kr{device;handle;_compilationInfoLog="";constructor(e,t){super(e,t),this.device=e;let i=this.props.handle;switch(this.props.stage){case"vertex":this.handle=i||this.device.gl.createShader(35633);break;case"fragment":this.handle=i||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}e._setWebGLDebugMetadata(this.handle,this,{spector:this.props});let r=this._compile(this.source);r&&typeof r.catch=="function"&&r.catch(()=>{this.compilationStatus="error"})}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this._getCompilationInfoLog();return e?z2(e):[]}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)||null}_compile(e){e=e.startsWith("#version ")?e:`#version 300 es +${e}`;let{gl:t}=this.device;if(t.shaderSource(this.handle,e),t.compileShader(this.handle),!this.device.props.debug){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus==="error")throw new Error(this._getCompilationErrorMessage(e));return}return z.once(1,"Shader compilation is asynchronous")(),this._waitForCompilationComplete().then(()=>{z.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()})}async _waitForCompilationComplete(){let e=async r=>await new Promise(s=>setTimeout(s,r));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error",this.compilationStatus==="error"&&this._getCompilationInfoLog()}_getCompilationErrorMessage(e){let t=`${this.props.stage} shader ${this.props.id}`,i=K6(this._getCompilationInfoLog()),r=this.getCompilationInfoSync(),s=r.find(u=>u.type==="error"&&u.message.trim())||r.find(u=>u.message.trim())||r.find(u=>u.type==="error")||r[0];if(!s)return i?`GLSL compilation errors in ${t}: ${i}`:`GLSL compilation errors in ${t}: WebGL did not provide a shader compiler log`;let o=s.lineNum?e.split(/\r?\n/)[s.lineNum-1]?.trim():void 0,a=s.lineNum?` line ${s.lineNum}`:"",c=o?` +Source: ${o}`:"",l=s.message.trim()||i||"WebGL did not provide a shader compiler log";return`GLSL compilation errors in ${t}:${a}: ${l}${c}`}_getCompilationInfoLog(){let e=this.device.gl.getShaderInfoLog(this.handle)?.trim();return e&&(this._compilationInfoLog=e),this._compilationInfoLog}}});function V2(n,e,t,i){if(tz(e))return i(n);let r=n;r.pushState();try{return Q6(n,e),gn(r.gl,t),i(n)}finally{r.popState()}}function Q6(n,e){let t=n,{gl:i}=t;if(e.cullMode)switch(e.cullMode){case"none":i.disable(2884);break;case"front":i.enable(2884),i.cullFace(1028);break;case"back":i.enable(2884),i.cullFace(1029);break}if(e.frontFace&&i.frontFace(ss("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&n.features.has("depth-clip-control")&&i.enable(34383),e.depthBias!==void 0&&(i.enable(32823),i.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&n.features.has("provoking-vertex-webgl")){let s=t.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,o=ss("provokingVertex",e.provokingVertex,{first:36429,last:36430});s?.provokingVertexWEBGL(o)}if((e.polygonMode||e.polygonOffsetLine)&&n.features.has("polygon-mode-webgl")){if(e.polygonMode){let s=t.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,o=ss("polygonMode",e.polygonMode,{fill:6914,line:6913});s?.polygonModeWEBGL(1028,o),s?.polygonModeWEBGL(1029,o)}e.polygonOffsetLine&&i.enable(10754)}if(n.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&i.enable(12288),e.clipDistance1&&i.enable(12289),e.clipDistance2&&i.enable(12290),e.clipDistance3&&i.enable(12291),e.clipDistance4&&i.enable(12292),e.clipDistance5&&i.enable(12293),e.clipDistance6&&i.enable(12294),e.clipDistance7&&i.enable(12295)),e.depthWriteEnabled!==void 0&&i.depthMask(ez("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?i.enable(2929):i.disable(2929),i.depthFunc(id("depthCompare",e.depthCompare))),e.clearDepth!==void 0&&i.clearDepth(e.clearDepth),e.stencilWriteMask){let r=e.stencilWriteMask;i.stencilMaskSeparate(1028,r),i.stencilMaskSeparate(1029,r)}if(e.stencilReadMask&&z.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){let r=e.stencilReadMask||4294967295,s=id("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?i.enable(2960):i.disable(2960),i.stencilFuncSeparate(1028,s,0,r),i.stencilFuncSeparate(1029,s,0,r)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){let r=ly("stencilPassOperation",e.stencilPassOperation),s=ly("stencilFailOperation",e.stencilFailOperation),o=ly("stencilDepthFailOperation",e.stencilDepthFailOperation);i.stencilOpSeparate(1028,s,o,r),i.stencilOpSeparate(1029,s,o,r)}switch(e.blend){case!0:i.enable(3042);break;case!1:i.disable(3042);break;default:}if(e.blendColorOperation||e.blendAlphaOperation){let r=G2("blendColorOperation",e.blendColorOperation||"add"),s=G2("blendAlphaOperation",e.blendAlphaOperation||"add");i.blendEquationSeparate(r,s);let o=nd("blendColorSrcFactor",e.blendColorSrcFactor||"one"),a=nd("blendColorDstFactor",e.blendColorDstFactor||"zero"),c=nd("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),l=nd("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");i.blendFuncSeparate(o,a,c,l)}}function id(n,e){return ss(n,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function ly(n,e){return ss(n,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function G2(n,e){return ss(n,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function nd(n,e,t="color"){return ss(n,e,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:t==="color"?32769:32771,"one-minus-constant":t==="color"?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function J6(n,e){return`Illegal parameter ${e} for ${n}`}function ss(n,e,t){if(!(e in t))throw new Error(J6(n,e));return t[e]}function ez(n,e){return e}function tz(n){let e=!0;for(let t in n){e=!1;break}return e}var uy=C(()=>{ee();Po()});function rd(n){let e={};return n.addressModeU&&(e[10242]=fy(n.addressModeU)),n.addressModeV&&(e[10243]=fy(n.addressModeV)),n.addressModeW&&(e[32882]=fy(n.addressModeW)),n.magFilter&&(e[10240]=dy(n.magFilter)),(n.minFilter||n.mipmapFilter)&&(e[10241]=nz(n.minFilter||"linear",n.mipmapFilter)),n.lodMinClamp!==void 0&&(e[33082]=n.lodMinClamp),n.lodMaxClamp!==void 0&&(e[33083]=n.lodMaxClamp),n.type==="comparison-sampler"&&(e[34892]=34894),n.compare&&(e[34893]=id("compare",n.compare)),n.maxAnisotropy&&(e[34046]=n.maxAnisotropy),e}function fy(n){switch(n){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function dy(n){switch(n){case"nearest":return 9728;case"linear":return 9729}}function nz(n,e="none"){if(!e)return dy(n);switch(e){case"none":return dy(n);case"nearest":switch(n){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(n){case"nearest":return 9986;case"linear":return 9987}}}var hy=C(()=>{uy()});var sd,W2=C(()=>{ee();hy();sd=class extends Mr{device;handle;parameters;constructor(e,t){super(e,t),this.device=e,this.parameters=rd(t),this.handle=t.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(let[t,i]of Object.entries(e)){let r=Number(t);switch(r){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,r,i);break;default:this.device.gl.samplerParameteri(this.handle,r,i);break}}}}});function vn(n,e,t){if(iz(e))return t(n);let{nocatch:i=!0}=e,r=_n.get(n);r.push(),gn(n,e);let s;if(i)s=t(n),r.pop();else try{s=t(n)}finally{r.pop()}return s}function iz(n){for(let e in n)return!1;return!0}var od=C(()=>{Po();ey()});var Qn,py=C(()=>{ee();Qn=class extends Ar{device;gl;handle;texture;constructor(e,t){super(e,{...pe.defaultProps,...t}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=t.texture}}});function ad(n){return rz[n]}var rz,my=C(()=>{rz={5124:"sint32",5125:"uint32",5122:"sint16",5123:"uint16",5120:"sint8",5121:"uint8",5126:"float32",5131:"float16",33635:"uint16",32819:"uint16",32820:"uint16",33640:"uint32",35899:"uint32",35902:"uint32",34042:"uint32",36269:"uint32"}});function sz(n,e=0){return e?new n.constructor(n.buffer,n.byteOffset+e,(n.byteLength-e)/n.BYTES_PER_ELEMENT):n}function oz(n,e){if(e%n.BYTES_PER_ELEMENT!==0)throw new Error(`Texture byteOffset ${e} must align to typed array element size ${n.BYTES_PER_ELEMENT}`);return e/n.BYTES_PER_ELEMENT}function az(n){switch(n){case"1d":break;case"2d":return 3553;case"3d":return 32879;case"cube":return 34067;case"2d-array":return 35866;case"cube-array":break}throw new Error(n)}function zc(n,e,t){return e==="cube"?34069+t:n}var Jn,cd=C(()=>{ee();Lo();hy();od();py();my();Jn=class extends pe{device;gl;handle;sampler=void 0;view;glTarget;glFormat;glType;glInternalFormat;compressed;_textureUnit=0;_framebuffer=null;_framebufferAttachmentKey=null;constructor(e,t){super(e,t,{byteAlignment:1}),this.device=e,this.gl=this.device.gl;let i=Yf(this.props.format);if(this.glTarget=az(this.props.dimension),this.glInternalFormat=i.internalFormat,this.glFormat=i.format,this.glType=i.type,this.compressed=i.compressed,this.isHandleBorrowed&&this.props.handle===void 0)throw new Error("Borrowed WebGL textures require a texture handle");if(this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),!this.isHandleBorrowed){this.gl.bindTexture(this.glTarget,this.handle);let{dimension:r,width:s,height:o,depth:a,mipLevels:c,glTarget:l,glInternalFormat:u}=this;if(!this.compressed)switch(r){case"2d":case"cube":this.gl.texStorage2D(l,c,u,s,o);break;case"2d-array":case"3d":this.gl.texStorage3D(l,c,u,s,o,a);break;default:throw new Error(r)}this.gl.bindTexture(this.glTarget,null),this._initializeData(t.data)}this.ownsHandle?this.trackAllocatedMemory(this.getAllocatedByteLength(),"Texture"):this.trackReferencedMemory(this.getAllocatedByteLength(),"Texture"),this.isHandleBorrowed||this.setSampler(this.props.sampler),this.view=new Qn(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this._framebuffer?.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.ownsHandle?(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory("Texture")):this.trackDeallocatedReferencedMemory("Texture"),this.destroyed=!0)}createView(e){return new Qn(this.device,{...e,texture:this})}clone(e){if(this.isHandleBorrowed&&e&&(e.width!==this.width||e.height!==this.height))throw new Error(`Cannot resize borrowed read-only ${this}`);return super.clone(e)}setSampler(e={}){this._assertWritable("set sampler parameters on"),super.setSampler(e);let t=rd(this.sampler.props);this._setSamplerParameters(t)}copyExternalImage(e){this._assertWritable("copy external image data into");let t=this._normalizeCopyExternalImageOptions(e);if(t.sourceX||t.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");let{glFormat:i,glType:r}=this,{image:s,depth:o,mipLevel:a,x:c,y:l,z:u,width:f,height:d}=t,h=zc(this.glTarget,this.dimension,u),p=t.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),vn(this.gl,p,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(h,a,c,l,f,d,i,r,s);break;case"2d-array":case"3d":this.gl.texSubImage3D(h,a,c,l,u,f,d,o,i,r,s);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:t.width,height:t.height}}copyElementImage(e){this._assertWritable("copy element image data into");let t=this._normalizeCopyElementImageOptions(e),{glFormat:i}=this,{element:r,depth:s,mipLevel:o,sourceX:a,sourceY:c,sourceWidth:l,sourceHeight:u,x:f,y:d,z:h,width:p,height:m}=t,g=zc(this.glTarget,this.dimension,h),v=t.flipY?{37440:!0}:{},y=this.gl;if(s!==1||this.dimension!=="2d"&&this.dimension!=="cube")throw new Error(`${this} copyElementImage only supports 2d and cube textures on WebGL`);if(o!==0||f!==0||d!==0)throw new Error(`${this} copyElementImage only supports full base-level uploads on WebGL`);if(typeof y.texElementImage2D!="function")throw new Error(`${this} copyElementImage is not supported by this WebGL implementation`);return this.gl.bindTexture(this.glTarget,this.handle),vn(this.gl,v,()=>{y.texElementImage2D?.(g,i,r,{sx:a,sy:c,swidth:l??p,sheight:u??m,width:p,height:m})}),this.gl.bindTexture(this.glTarget,null),{width:t.width,height:t.height}}copyImageData(e){super.copyImageData(e)}readBuffer(e={},t){if(!t)throw new Error(`${this} readBuffer requires a destination buffer`);let i=this._getSupportedColorReadOptions(e),r=e.byteOffset??0,s=this.computeMemoryLayout(i);if(t.byteLength{this.gl.readPixels(i.x,i.y,i.width,i.height,this.glFormat,this.glType,r+a)})}finally{this.gl.bindBuffer(35051,null)}return t}async readDataAsync(e={}){throw new Error(`${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`)}writeBuffer(e,t={}){this._assertWritable("write buffer data into");let i=this._normalizeTextureWriteOptions(t),{width:r,height:s,depthOrArrayLayers:o,mipLevel:a,byteOffset:c,x:l,y:u,z:f}=i,{glFormat:d,glType:h,compressed:p}=this,m=zc(this.glTarget,this.dimension,f);if(p)throw new Error("writeBuffer for compressed textures is not implemented in WebGL");let{bytesPerPixel:g}=this.device.getTextureFormatInfo(this.format),v=g?i.bytesPerRow/g:void 0,y={3317:this.byteAlignment,...v!==void 0?{3314:v}:{},32878:i.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,e.handle),vn(this.gl,y,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(m,a,l,u,r,s,d,h,c);break;case"2d-array":case"3d":this.gl.texSubImage3D(m,a,l,u,f,r,s,o,d,h,c);break;default:}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(e,t={}){this._assertWritable("write data into");let i=this._normalizeTextureWriteOptions(t),r=ArrayBuffer.isView(e)?e:new Uint8Array(e),{width:s,height:o,depthOrArrayLayers:a,mipLevel:c,x:l,y:u,z:f,byteOffset:d}=i,{glFormat:h,glType:p,compressed:m}=this,g=zc(this.glTarget,this.dimension,f),v;if(!m){let{bytesPerPixel:T}=this.device.getTextureFormatInfo(this.format);T&&(v=i.bytesPerRow/T)}let y=this.compressed?{}:{3317:this.byteAlignment,...v!==void 0?{3314:v}:{},32878:i.rowsPerImage},b=oz(r,d),w=m?sz(r,d):r,E=this._getMipLevelSize(c),x=l===0&&u===0&&f===0&&s===E.width&&o===E.height&&a===E.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),vn(this.gl,y,()=>{switch(this.dimension){case"2d":case"cube":m?x?this.gl.compressedTexImage2D(g,c,h,s,o,0,w):this.gl.compressedTexSubImage2D(g,c,l,u,s,o,h,w):this.gl.texSubImage2D(g,c,l,u,s,o,h,p,r,b);break;case"2d-array":case"3d":m?x?this.gl.compressedTexImage3D(g,c,h,s,o,a,0,w):this.gl.compressedTexSubImage3D(g,c,l,u,f,s,o,a,h,w):this.gl.texSubImage3D(g,c,l,u,f,s,o,a,h,p,r,b);break;default:}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(e,t){return 1}_getFramebuffer(){return this._framebuffer||=this.device.createFramebuffer({id:`framebuffer-for-${this.id}`,width:this.width,height:this.height,colorAttachments:[this]}),this._framebuffer}readDataSyncWebGL(e={}){let t=this._getSupportedColorReadOptions(e),i=this.computeMemoryLayout(t),r=ad(this.glType),s=Lr(r),o=new s(i.byteLength/s.BYTES_PER_ELEMENT);return this._readColorTextureLayers(t,i,a=>{let c=new s(o.buffer,o.byteOffset+a,i.bytesPerImage/s.BYTES_PER_ELEMENT);this.gl.readPixels(t.x,t.y,t.width,t.height,this.glFormat,this.glType,c)}),o.buffer}_readColorTextureLayers(e,t,i){let r=this._getFramebuffer(),s=t.bytesPerRow/t.bytesPerPixel,o={3333:this.byteAlignment,...s!==e.width?{3330:s}:{}},a=this.gl.getParameter(3074),c=this.gl.bindFramebuffer(36160,r.handle);try{this.gl.readBuffer(36064),vn(this.gl,o,()=>{for(let l=0;l=2&&z.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(e))(),this.gl.bindTexture(this.glTarget,this.handle);for(let[t,i]of Object.entries(e)){let r=Number(t),s=i;switch(r){case 33082:case 33083:this.gl.texParameterf(this.glTarget,r,s);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,r,s);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,r,s);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,r,s);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,r,s);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(e){let{gl:t}=this;return e!==void 0&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,this.handle),e}_unbind(e){let{gl:t}=this;return e!==void 0&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,null),e}_assertWritable(e){if(this.isHandleBorrowed)throw new Error(`Cannot ${e} borrowed read-only ${this}`)}}});function j2(n,e,t,i){let r=n,s=i;s===!0&&(s=1),s===!1&&(s=0);let o=typeof s=="number"?[s]:s;switch(t){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof i!="number")throw new Error("samplers must be set to integers");return n.uniform1i(e,i);case 5126:return n.uniform1fv(e,o);case 35664:return n.uniform2fv(e,o);case 35665:return n.uniform3fv(e,o);case 35666:return n.uniform4fv(e,o);case 5124:return n.uniform1iv(e,o);case 35667:return n.uniform2iv(e,o);case 35668:return n.uniform3iv(e,o);case 35669:return n.uniform4iv(e,o);case 35670:return n.uniform1iv(e,o);case 35671:return n.uniform2iv(e,o);case 35672:return n.uniform3iv(e,o);case 35673:return n.uniform4iv(e,o);case 5125:return r.uniform1uiv(e,o,1);case 36294:return r.uniform2uiv(e,o,2);case 36295:return r.uniform3uiv(e,o,3);case 36296:return r.uniform4uiv(e,o,4);case 35674:return n.uniformMatrix2fv(e,!1,o);case 35675:return n.uniformMatrix3fv(e,!1,o);case 35676:return n.uniformMatrix4fv(e,!1,o);case 35685:return r.uniformMatrix2x3fv(e,!1,o);case 35686:return r.uniformMatrix2x4fv(e,!1,o);case 35687:return r.uniformMatrix3x2fv(e,!1,o);case 35688:return r.uniformMatrix3x4fv(e,!1,o);case 35689:return r.uniformMatrix4x2fv(e,!1,o);case 35690:return r.uniformMatrix4x3fv(e,!1,o)}throw new Error("Illegal uniform")}var H2=C(()=>{});function Y2(n){return lz[n]}function ld(n){return cz[n]}function ud(n){return!!Z2[n]}function q2(n){return Z2[n]}var cz,Z2,lz,fd=C(()=>{cz={5126:"f32",35664:"vec2",35665:"vec3",35666:"vec4",5124:"i32",35667:"vec2",35668:"vec3",35669:"vec4",5125:"u32",36294:"vec2",36295:"vec3",36296:"vec4",35670:"f32",35671:"vec2",35672:"vec3",35673:"vec4",35674:"mat2x2",35685:"mat2x3",35686:"mat2x4",35687:"mat3x2",35675:"mat3x3",35688:"mat3x4",35689:"mat4x2",35690:"mat4x3",35676:"mat4x4"},Z2={35678:{viewDimension:"2d",sampleType:"float"},35680:{viewDimension:"cube",sampleType:"float"},35679:{viewDimension:"3d",sampleType:"float"},35682:{viewDimension:"3d",sampleType:"depth"},36289:{viewDimension:"2d-array",sampleType:"float"},36292:{viewDimension:"2d-array",sampleType:"depth"},36293:{viewDimension:"cube",sampleType:"float"},36298:{viewDimension:"2d",sampleType:"sint"},36299:{viewDimension:"3d",sampleType:"sint"},36300:{viewDimension:"cube",sampleType:"sint"},36303:{viewDimension:"2d-array",sampleType:"uint"},36306:{viewDimension:"2d",sampleType:"uint"},36307:{viewDimension:"3d",sampleType:"uint"},36308:{viewDimension:"cube",sampleType:"uint"},36311:{viewDimension:"2d-array",sampleType:"uint"}},lz={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126}});function K2(n,e,t={}){let i={attributes:[],bindings:[]};i.attributes=uz(n,e);let r=hz(n,e,t);for(let c of r){let l=c.uniforms.map(u=>({name:u.name,format:u.format,byteOffset:u.byteOffset,byteStride:u.byteStride,arrayLength:u.arrayLength}));i.bindings.push({type:"uniform",name:c.name,group:0,location:c.location,visibility:(c.vertex?1:0)|(c.fragment?2:0),minBindingSize:c.byteLength,uniforms:l})}let s=dz(n,e),o=0;for(let c of s)if(ud(c.type)){let{viewDimension:l,sampleType:u}=q2(c.type);i.bindings.push({type:"texture",name:c.name,group:0,location:o,viewDimension:l,sampleType:u}),c.textureUnit=o,o+=1}s.length&&(i.uniforms=s);let a=fz(n,e);return a?.length&&(i.varyings=a),i}function uz(n,e){let t=[],i=n.getProgramParameter(e,35721);for(let r=0;r=0){let l=ld(a),u=/instance/i.test(o)?"instance":"vertex";t.push({name:o,location:c,stepMode:u,type:l})}}return t.sort((r,s)=>r.location-s.location),t}function fz(n,e){let t=[],i=n.getProgramParameter(e,35971);for(let r=0;rr.location-s.location),t}function dz(n,e){let t=[],i=n.getProgramParameter(e,35718);for(let r=0;r1)for(let h=0;ho.location-a.location),i}function pz(n,e){for(let t of n.uniforms){let i=e.uniforms.find(r=>t.name===r.name||t.name.endsWith(`.${r.name}`));if(!i)throw new Error(`Failed to validate WebGL uniform block "${e.name}": reflected unexpected member "${t.name}"`);if(t.format!==i.format||t.arrayLength!==i.arrayLength||t.byteOffset!==i.byteOffset||t.byteStride!==i.byteStride)throw new Error(`Failed to validate WebGL uniform block "${e.name}": reflected layout for "${t.name}" does not match supplied std140 metadata`)}}function mz(n,e,t){let i=new Map;for(let s of t.uniformBlockLayouts||[])i.set(s.name,_z(s));for(let s of t.shaderLayout?.bindings||[])bz(s)&&i.set(s.name,s);let r=new Map;for(let s of i.values()){let o=gz(n,e,s.name);if(!o)continue;let{blockIndex:a,blockName:c}=o;if(r.has(a))throw new Error(`Multiple supplied uniform block layouts resolve to active WebGL block "${c}"`);r.set(a,{name:c,location:a,byteLength:s.minBindingSize,vertex:!!(s.visibility&&s.visibility&1),fragment:!!(s.visibility&&s.visibility&2),uniformCount:s.uniforms.length,uniforms:s.uniforms.map(l=>({...l}))})}return r}function gz(n,e,t){let i=t.endsWith("Uniforms")?[t,t.slice(0,-8)]:[t,`${t}Uniforms`];for(let r of i){let s=n.getUniformBlockIndex(e,r);if(s!==4294967295){if(!Number.isInteger(s)||s<0)throw new Error(`Failed to resolve WebGL uniform block "${r}": getUniformBlockIndex returned ${String(s)}`);return{blockIndex:s,blockName:r}}}return null}function X2(n,e,t,i){let r=i||n.getActiveUniformBlockName(e,t);if(!r)throw new Error(`Failed to reflect WebGL uniform block at index ${t}: missing block name`);let s=(b,w)=>{let E=n.getActiveUniformBlockParameter(e,t,b);if(E==null)throw new Error(`Failed to reflect WebGL uniform block "${r}": ${w} returned null`);return E},o=os(s(35391,"UNIFORM_BLOCK_BINDING"),r,"UNIFORM_BLOCK_BINDING",0),a=os(s(35392,"UNIFORM_BLOCK_DATA_SIZE"),r,"UNIFORM_BLOCK_DATA_SIZE",0),c=os(s(35394,"UNIFORM_BLOCK_ACTIVE_UNIFORMS"),r,"UNIFORM_BLOCK_ACTIVE_UNIFORMS",0),l=Q2(s(35395,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES"),r,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",c),u=Uc(n,e,l,35383,"UNIFORM_TYPE",r,c),f=Uc(n,e,l,35384,"UNIFORM_SIZE",r,c),d=Uc(n,e,l,35386,"UNIFORM_BLOCK_INDEX",r,c),h=Uc(n,e,l,35387,"UNIFORM_OFFSET",r,c),p=Uc(n,e,l,35388,"UNIFORM_ARRAY_STRIDE",r,c),m=[];for(let b=0;bb.name.split(".")[0]).filter(b=>!!b)),y=g.name.replace(/Uniforms$/,"");if(v.size===1&&!v.has(g.name)&&!v.has(y)){let[b]=v;z.warn(`Uniform block "${g.name}" uses GLSL instance "${b}". luma.gl binds uniform buffers by block name ("${g.name}") and alias ("${y}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}return g}function Uc(n,e,t,i,r,s,o){let a=n.getActiveUniforms(e,t,i);if(a===null)throw new Error(`Failed to reflect WebGL uniform block "${s}": ${r} returned null`);return Q2(a,s,r,o)}function Q2(n,e,t,i){if(!Array.isArray(n)&&!ArrayBuffer.isView(n))throw new Error(`Failed to reflect WebGL uniform block "${e}": ${t} returned a non-array value`);let r=Array.from(n);if(r.length!==i||r.some(s=>!Number.isInteger(s)))throw new Error(`Failed to reflect WebGL uniform block "${e}": ${t} returned ${r.length} invalid values, expected ${i}`);return r}function os(n,e,t,i){if(!Number.isInteger(n)||n{if(typeof o=="string"){let a=e[s];if(!a)throw new Error(`Missing std140 layout field ${s}`);t.push({name:s,format:a.shaderType,arrayLength:1,byteOffset:a.offset*4,byteStride:0});return}if(Array.isArray(o)){r(s,o[0],o[1]);return}for(let[a,c]of Object.entries(o))i(`${s}.${a}`,c)},r=(s,o,a)=>{if(typeof o=="string"){let c=e[`${s}[0]`],l=a>1?e[`${s}[1]`]:void 0;if(!c)throw new Error(`Missing std140 array layout field ${s}[0]`);t.push({name:`${s}[0]`,format:c.shaderType,arrayLength:a,byteOffset:c.offset*4,byteStride:l?(l.offset-c.offset)*4:0});return}if(Array.isArray(o))throw new Error(`Nested uniform arrays are not supported for ${s}`);for(let[c,l]of Object.entries(o)){if(typeof l!="string")throw new Error(`Composite uniform array members are not supported for ${s}`);let u=`${s}[0].${c}`,f=`${s}[1].${c}`,d=e[u],h=a>1?e[f]:void 0;if(!d)throw new Error(`Missing std140 array layout field ${u}`);t.push({name:u,format:d.shaderType,arrayLength:a,byteOffset:d.offset*4,byteStride:h?(h.offset-d.offset)*4:0})}};for(let[s,o]of Object.entries(n))i(s,o);return t}function bz(n){return n.type==="uniform"&&Number.isInteger(n.minBindingSize)&&n.minBindingSize>=0&&Array.isArray(n.uniforms)&&n.uniforms.every(e=>typeof e.name=="string"&&typeof e.format=="string"&&Number.isInteger(e.arrayLength)&&e.arrayLength>0&&Number.isInteger(e.byteOffset)&&e.byteOffset>=0&&Number.isInteger(e.byteStride)&&e.byteStride>=0)}function vz(n){if(n[n.length-1]!=="]")return{name:n,length:1,isArray:!1};let t=/([^[]*)(\[[0-9]+\])?/.exec(n);return{name:Gi(t?.[1],`Failed to parse GLSL uniform name ${n}`),length:t?.[2]?1:0,isArray:!!t?.[2]}}var J2=C(()=>{ee();fd()});function xz(n,e){let t={...n,attributes:n.attributes.map(i=>({...i})),bindings:n.bindings.map(i=>({...i}))};for(let i of e?.attributes||[]){let r=t.attributes.find(s=>s.name===i.name);r?(r.type=i.type||r.type,r.stepMode=i.stepMode||r.stepMode):z.warn(`shader layout attribute ${i.name} not present in shader`)}for(let i of e?.bindings||[]){let r=tP(t,i.name);if(!r){z.warn(`shader layout binding ${i.name} not present in shader`);continue}Object.assign(r,i)}return t}function tP(n,e){return n.bindings.find(t=>t.name===e||t.name===`${e}Uniforms`||`${t.name}Uniforms`===e)}function eP(n,e){return n[e]||n[`${e}Uniforms`]||n[e.replace(/Uniforms$/,"")]}var dd,nP=C(()=>{ee();H2();Jf();Xf();cd();py();J2();dd=class extends Ht{device;handle;vs;fs;introspectedLayout;bindings={};uniforms={};varyings=null;_uniformCount=0;_uniformSetters={};get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}constructor(e,t){super(e,t),this.device=e;let i=this.sharedRenderPipeline||this.device._createSharedRenderPipelineWebGL(t);this.sharedRenderPipeline=i,this.handle=i.handle,this.vs=i.vs,this.fs=i.fs,this.linkStatus=i.linkStatus,this.introspectedLayout=K2(this.device.gl,this.handle,{uniformBlockLayouts:t._uniformBlockLayouts,shaderLayout:t.shaderLayout}),this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.shaderLayout=t.shaderLayout?xz(this.introspectedLayout,t.shaderLayout):this.introspectedLayout}destroy(){this.destroyed||(this.sharedRenderPipeline&&!this.props._sharedRenderPipeline&&this.sharedRenderPipeline.destroy(),this.destroyResource())}setBindings(e,t){let i=js(Or(this.shaderLayout,e));for(let[r,s]of Object.entries(i)){let o=tP(this.shaderLayout,r);if(o){switch(s||z.warn(`Unsetting binding "${r}" in render pipeline "${this.id}"`)(),o.type){case"uniform":if(!(s instanceof bn)&&!(s.buffer instanceof bn))throw new Error("buffer value");break;case"texture":if(!(s instanceof Qn||s instanceof Jn||s instanceof Kn))throw new Error(`${this} Bad texture binding for ${r}`);break;case"sampler":z.warn(`Ignoring sampler ${r}`)();break;default:throw new Error(o.type)}this.bindings[r]=s}else{let a=this.shaderLayout.bindings.map(c=>`"${c.name}"`).join(", ");t?.disableWarnings||z.warn(`No binding "${r}" in render pipeline "${this.id}", expected one of ${a}`,s)()}}}draw(e){let t=e.renderPass,i=e.bindGroups?js(e.bindGroups):e.bindings||this.bindings;return t.setPipeline(this),t.setBindings(i),t.setVertexArray(e.vertexArray),t.draw({parameters:e.parameters,topology:e.topology,isInstanced:e.isInstanced,vertexCount:e.vertexCount,indexCount:e.indexCount,instanceCount:e.instanceCount,firstVertex:e.firstVertex,firstIndex:e.firstIndex,firstInstance:e.firstInstance,baseVertex:e.baseVertex,transformFeedback:e.transformFeedback,uniforms:e.uniforms})}_areTexturesRenderable(e){let t=!0;for(let i of this.shaderLayout.bindings)eP(e,i.name)||(z.warn(`Binding ${i.name} not found in ${this.id}`)(),t=!1);return t}_applyBindings(e,t){if(this._syncLinkStatus(),this.linkStatus!=="success")return;let{gl:i}=this.device;i.useProgram(this.handle);let r=0,s=0;for(let o of this.shaderLayout.bindings){let a=eP(e,o.name);if(!a)throw new Error(`No value for binding ${o.name} in ${this.id}`);switch(o.type){case"uniform":let{name:c}=o,l=i.getUniformBlockIndex(this.handle,c);if(l===4294967295)throw new Error(`Invalid uniform block name ${c}`);if(i.uniformBlockBinding(this.handle,l,s),a instanceof bn)i.bindBufferBase(35345,s,a.handle);else{let f=a;i.bindBufferRange(35345,s,f.buffer.handle,f.offset||0,f.size||f.buffer.byteLength-(f.offset||0))}s+=1;break;case"texture":if(!(a instanceof Qn||a instanceof Jn||a instanceof Kn))throw new Error("texture");let u;if(a instanceof Qn)u=a.texture;else if(a instanceof Jn)u=a;else if(a instanceof Kn&&a.colorAttachments[0]instanceof Qn)z.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),u=a.colorAttachments[0].texture;else throw new Error("No texture");i.activeTexture(33984+r),i.bindTexture(u.glTarget,u.handle),r+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${o.type}' not supported in WebGL`)}}}_applyUniforms(e){for(let t of this.shaderLayout.uniforms||[]){let{name:i,location:r,type:s,textureUnit:o}=t,a=e[i]??o;a!==void 0&&j2(this.device.gl,r,s,a)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}}});var iP,hd,rP=C(()=>{ee();fd();iP=4,hd=class extends Aa{device;handle;vs;fs;linkStatus="pending";constructor(e,t){super(e,t),this.device=e,this.handle=t.handle||this.device.gl.createProgram(),this.vs=t.vs,this.fs=t.fs,t.varyings&&t.varyings.length>0&&this.device.gl.transformFeedbackVaryings(this.handle,t.varyings,t.bufferMode||35981),this._linkShaders()}destroy(){this.destroyed||(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.handle.destroyed=!0,this.destroyResource())}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),z.time(iP,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),z.timeEnd(iP,`linkProgram for ${this.id}`)(),!this.device.features.has("compilation-status-async-webgl")){let i=this._getLinkStatus();this._reportLinkStatus(i);return}z.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),z.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let t=this._getLinkStatus();this._reportLinkStatus(t)}async _reportLinkStatus(e){switch(e){case"success":return;default:let t=e==="link-error"?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${t} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader();break;case"success":break}switch(this.fs?.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`${this} ${t} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader();break;case"success":break}let i=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${t} during ${e}: ${i}`),this)(),this.device.debug()}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(this._initializeSamplerUniforms(),e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}_initializeSamplerUniforms(){let{gl:e}=this.device;e.useProgram(this.handle);let t=0,i=e.getProgramParameter(this.handle,35718);for(let r=0;r1){let o=Int32Array.from({length:t.size},(a,c)=>r+c);return s.uniform1iv(e,o),r+t.size}return s.uniform1i(e,r),r+1}async _waitForLinkComplete(){let e=async r=>await new Promise(s=>setTimeout(s,r));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getProgramParameter(this.handle,37297))return;await e(10)}}}});function wz(n,e){let t=e.sourceBuffer,i=e.destinationBuffer;n.gl.bindBuffer(36662,t.handle),n.gl.bindBuffer(36663,i.handle),n.gl.copyBufferSubData(36662,36663,e.sourceOffset??0,e.destinationOffset??0,e.size),n.gl.bindBuffer(36662,null),n.gl.bindBuffer(36663,null)}function Ez(n,e){let{sourceBuffer:t,byteOffset:i=0,destinationTexture:r,mipLevel:s=0,origin:o=[0,0,0],aspect:a="all",bytesPerRow:c,rowsPerImage:l,size:u}=e;if(a!=="all")throw new Error("copyBufferToTexture aspect is not supported in WebGL");r.writeBuffer(t,{byteOffset:i,bytesPerRow:c,rowsPerImage:l,mipLevel:s,x:o[0]??0,y:o[1]??0,z:o[2]??0,width:u[0],height:u[1],depthOrArrayLayers:u[2]})}function Sz(n,e){let{sourceTexture:t,mipLevel:i=0,aspect:r="all",width:s=e.sourceTexture.width,height:o=e.sourceTexture.height,depthOrArrayLayers:a,origin:c=[0,0,0],destinationBuffer:l,byteOffset:u=0,bytesPerRow:f,rowsPerImage:d}=e;if(t instanceof pe){t.readBuffer({x:c[0]??0,y:c[1]??0,z:c[2]??0,width:s,height:o,depthOrArrayLayers:a,mipLevel:i,aspect:r,byteOffset:u},l);return}if(r!=="all")throw new Error("aspect not supported in WebGL");if(i!==0||a!==void 0||f||d)throw new Error("not implemented");let{framebuffer:h,destroyFramebuffer:p}=sP(t),m;try{let g=l,v=s||h.width,y=o||h.height,b=Gi(h.colorAttachments[0]),w=Yf(b.texture.props.format),E=w.format,x=w.type;n.gl.bindBuffer(35051,g.handle),m=n.gl.bindFramebuffer(36160,h.handle),n.gl.readPixels(c[0],c[1],v,y,E,x,u)}finally{n.gl.bindBuffer(35051,null),m!==void 0&&n.gl.bindFramebuffer(36160,m),p&&h.destroy()}}function Pz(n,e){let{sourceTexture:t,destinationMipLevel:i=0,origin:r=[0,0],destinationOrigin:s=[0,0,0],destinationTexture:o}=e,{width:a=e.destinationTexture.width,height:c=e.destinationTexture.height}=e,{framebuffer:l,destroyFramebuffer:u}=sP(t),[f=0,d=0]=r,[h,p,m]=s,g=n.gl.bindFramebuffer(36160,l.handle),v,y;if(o instanceof Jn)v=o,a=Number.isFinite(a)?a:v.width,c=Number.isFinite(c)?c:v.height,v._bind(0),y=v.glTarget;else throw new Error("invalid destination");switch(y){case 3553:case 34067:n.gl.copyTexSubImage2D(y,i,h,p,f,d,a,c);break;case 35866:case 32879:n.gl.copyTexSubImage3D(y,i,h,p,m,f,d,a,c);break;default:}v&&v._unbind(),n.gl.bindFramebuffer(36160,g),u&&l.destroy()}function sP(n){if(n instanceof pe){let{width:e,height:t,id:i}=n;return{framebuffer:n.device.createFramebuffer({id:`framebuffer-for-${i}`,width:e,height:t,colorAttachments:[n]}),destroyFramebuffer:!0}}return{framebuffer:n,destroyFramebuffer:!1}}var pd,oP=C(()=>{ee();Lo();cd();pd=class extends Ia{device;handle=null;commands=[];constructor(e,t={}){super(e,t),this.device=e}_executeCommands(e=this.commands){for(let t of e)switch(t.name){case"copy-buffer-to-buffer":wz(this.device,t.options);break;case"copy-buffer-to-texture":Ez(this.device,t.options);break;case"copy-texture-to-buffer":Sz(this.device,t.options);break;case"copy-texture-to-texture":Pz(this.device,t.options);break;default:throw new Error(t.name)}}}});function aP(n){switch(n){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"triangle-list":return 4;case"triangle-strip":return 5;default:throw new Error(n)}}function cP(n){switch(n){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;default:throw new Error(n)}}var gy=C(()=>{});var Cz,md,lP=C(()=>{ee();od();Po();gy();uy();Cz=[1,2,4,8],md=class extends ka{device;handle=null;glParameters={};pipeline=null;bindings={};bindingsPipeline=null;vertexArray=null;constructor(e,t){super(e,t),this.device=e;let i=this.props.framebuffer,r=!i||i.handle===null;r&&e.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();let s;if(!t?.parameters?.viewport)if(!r&&i){let{width:o,height:a}=i;s=[0,0,o,a]}else{let[o,a]=e.getDefaultCanvasContext().getDrawingBufferSize();s=[0,0,o,a]}if(this.device.pushState(),this.setParameters({viewport:s,...this.props.parameters}),!r&&i?.colorAttachments.length){let o=i.colorAttachments.map((a,c)=>36064+c);this.device.gl.drawBuffers(o)}else r&&this.device.gl.drawBuffers([1029]);this.clear(),this.props.timestampQuerySet&&this.props.beginTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.beginTimestampIndex)}end(){this.destroyed||(this.props.timestampQuerySet&&this.props.endTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.endTimestampIndex),this.device.popState(),this.destroy())}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}executeBundles(e){throw new Error("Render bundles are only supported in WebGPU")}setParameters(e={}){let t={...this.glParameters};t.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(t.depthMask=!this.props.depthReadOnly),t.stencilMask=this.props.stencilReadOnly?0:1,t[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(t.viewport=e.viewport.slice(0,4),t.depthRange=[e.viewport[4],e.viewport[5]]):t.viewport=e.viewport),e.scissorRect&&(t.scissorTest=!0,t.scissor=e.scissorRect),e.blendConstant&&(t.blendColor=e.blendConstant),e.stencilReference!==void 0&&(t[2967]=e.stencilReference,t[36003]=e.stencilReference),"colorMask"in e&&(t.colorMask=Cz.map(i=>!!(i&e.colorMask))),this.glParameters=t,gn(this.device.gl,t)}setPipeline(e){this.pipeline=e}setBindings(e,t){if(!this.pipeline)throw new Error("RenderPass.setPipeline() must be called before setBindings()");this.bindings=js(Or(this.pipeline.shaderLayout,e)),this.bindingsPipeline=this.pipeline}setVertexArray(e){this.vertexArray=e}draw(e){let t=this.pipeline,i=this.vertexArray;if(!t)throw new Error("RenderPass.setPipeline() must be called before draw()");if(!i)throw new Error("RenderPass.setVertexArray() must be called before draw()");if(t.shaderLayout.bindings.length>0&&this.bindingsPipeline!==t)throw new Error("RenderPass.setBindings() must be called after setPipeline() before draw()");t._syncLinkStatus();let{parameters:r=t.props.parameters,topology:s=t.props.topology,vertexCount:o,indexCount:a,instanceCount:c,isInstanced:l=!1,firstVertex:u=0,transformFeedback:f,uniforms:d=t.uniforms}=e,h=aP(s),p=!!i.indexBuffer,m=i.indexBuffer?.glIndexType,g=a??o??0;if(t.linkStatus!=="success")return z.info(2,`RenderPipeline:${t.id}.draw() aborted - waiting for shader linking`)(),!1;if(!t._areTexturesRenderable(this.bindings))return z.info(2,`RenderPipeline:${t.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(t.handle),i.bindBeforeRender(this);let v=f;return v&&v.begin(t.props.topology),t._applyBindings(this.bindings,{disableWarnings:t.props.disableWarnings}),t._applyUniforms(d),V2(this.device,r,this.glParameters,()=>{p&&l?this.device.gl.drawElementsInstanced(h,g,m,u,c||0):p?this.device.gl.drawElements(h,g,m,u):l?this.device.gl.drawArraysInstanced(h,u,o||0,c||0):this.device.gl.drawArrays(h,u,o||0),v&&v.end()}),i.unbindAfterRender(this),!0}drawIndirect(e,t=0){throw new Error("Indirect drawing is only supported in WebGPU")}drawIndexedIndirect(e,t=0){throw new Error("Indirect drawing is only supported in WebGPU")}beginOcclusionQuery(e){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let e={...this.glParameters},t=0;this.props.clearColors&&this.props.clearColors.forEach((i,r)=>{i&&this.clearColorBuffer(r,i)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(t|=16384,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(t|=256,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(t|=1024,e.clearStencil=this.props.clearStencil),t!==0&&vn(this.device.gl,e,()=>{this.device.gl.clear(t)})}clearColorBuffer(e=0,t=[0,0,0,0]){vn(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,e,t);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,e,t);break;case Float32Array:this.device.gl.clearBufferfv(6144,e,t);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}});var $c,uP=C(()=>{ee();oP();lP();$c=class extends Ra{device;handle=null;commandBuffer;constructor(e,t){super(e,t),this.device=e,this.commandBuffer=new pd(e,{id:this.id,userData:this.userData})}destroy(){this.destroyResource()}finish(){return this.destroy(),this.commandBuffer}beginRenderPass(e={}){return new md(this.device,this._applyTimeProfilingToPassProps(e))}beginComputePass(e={}){throw new Error("ComputePass not supported in WebGL")}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,t,i){throw new Error("resolveQuerySet is not supported in WebGL")}writeTimestamp(e,t){e.writeTimestamp(t)}}});function fP(n){let{target:e,source:t,start:i=0,count:r=1}=n,s=t.length,o=r*s,a=0;for(let c=i;a{});function Tz(n){return Array.isArray(n)?new Float32Array(n):n}function Lz(n,e){if(!n||!e||n.length!==e.length||n.constructor!==e.constructor)return!1;for(let t=0;t{ee();vr();ny();dP();gd=class n extends Ba{get[Symbol.toStringTag](){return"VertexArray"}device;handle;attributeInfosByLocation;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return pp()==="Chrome"}constructor(e,t){super(e,t),this.device=e,this.handle=this.device.gl.createVertexArray(),this.attributeInfosByLocation=new Array(this.maxVertexAttributes).fill(null);for(let i of Object.values(Ua(t.shaderLayout,t.bufferLayout)))this.attributeInfosByLocation[i.location]=i}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){let t=e;if(t&&t.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,t?t.handle:null),this.indexBuffer=t,this.device.gl.bindVertexArray(null)}setBuffer(e,t){let i=t;if(i.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:r,type:s,stride:o,offset:a,normalized:c,integer:l,divisor:u}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,i.handle),l?this.device.gl.vertexAttribIPointer(e,r,s,o,a):this.device.gl.vertexAttribPointer(e,r,s,c,o,a),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,u||0),this.attributes[e]=i,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,t){this._enable(e,!1),this.attributes[e]=t}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e{ee();yd();gy();_d=class extends Oa{device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(e,t){super(e,t),this.device=e,this.gl=e.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,t.buffers&&this.setBuffers(t.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(e="point-list"){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(cP(e))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(e){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let[t,i]of Object.entries(e))this.setBuffer(t,i)})}setBuffer(e,t){let i=this._getVaryingIndex(e),{buffer:r,byteLength:s,byteOffset:o}=this._getBufferRange(t);if(i<0){this.unusedBuffers[e]=r,z.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[i]={buffer:r,byteLength:s,byteOffset:o},this.bindOnUse||this._bindBuffer(i,r,o,s)}getBuffer(e){if(pP(e))return this.buffers[e]||null;let t=this._getVaryingIndex(e);return this.buffers[t]??null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(36386,e),this;let t;return this._bound?t=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,t=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),t}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof bn)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:t,byteOffset:i=0,byteLength:r=e.buffer.byteLength}=e;return{buffer:t,byteOffset:i,byteLength:r}}_getVaryingIndex(e){if(pP(e))return Number(e);for(let t of this.layout.varyings||[])if(e===t.name)return t.location;return-1}_bindBuffers(){for(let[e,t]of Object.entries(this.buffers)){let{buffer:i,byteLength:r,byteOffset:s}=this._getBufferRange(t);this._bindBuffer(Number(e),i,s,r)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,t,i=0,r){let s=t&&t.handle;!s||r===void 0?this.gl.bindBufferBase(35982,e,s):this.gl.bindBufferRange(35982,e,s,i,r)}}});var bd,gP=C(()=>{ee();bd=class extends Da{device;handle;_timestampPairs=[];_pendingReads=new Set;_occlusionQuery=null;_occlusionActive=!1;get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){if(super(e,t),this.device=e,t.type==="timestamp"){if(t.count<2)throw new Error("Timestamp QuerySet requires at least two query slots");this._timestampPairs=new Array(Math.ceil(t.count/2)).fill(null).map(()=>({activeQuery:null,completedQueries:[]})),this.handle=null}else{if(t.count>1)throw new Error("WebGL occlusion QuerySet can only have one value");let i=this.device.gl.createQuery();if(!i)throw new Error("WebGL query not supported");this.handle=i}Object.seal(this)}destroy(){if(!this.destroyed){this.handle&&this.device.gl.deleteQuery(this.handle);for(let e of this._timestampPairs){e.activeQuery&&(this._cancelPendingQuery(e.activeQuery),this.device.gl.deleteQuery(e.activeQuery.handle));for(let t of e.completedQueries)this._cancelPendingQuery(t),this.device.gl.deleteQuery(t.handle)}this._occlusionQuery&&(this._cancelPendingQuery(this._occlusionQuery),this.device.gl.deleteQuery(this._occlusionQuery.handle));for(let e of Array.from(this._pendingReads))this._cancelPendingQuery(e);this.destroyResource()}}isResultAvailable(e){return this.props.type==="timestamp"?e===void 0?this._timestampPairs.some((t,i)=>this._isTimestampPairAvailable(i)):this._isTimestampPairAvailable(this._getTimestampPairIndex(e)):this._occlusionQuery?this._pollQueryAvailability(this._occlusionQuery):!1}async readResults(e){let t=e?.firstQuery||0,i=e?.queryCount||this.props.count-t;if(this._validateRange(t,i),this.props.type==="timestamp"){let r=new Array(i).fill(0n),s=Math.floor(t/2),o=Math.floor((t+i-1)/2);for(let a=s;a<=o;a++){let c=await this._consumeTimestampPairResult(a),l=a*2,u=l+1;l>=t&&l=t&&u=this.props.count||t<=e)throw new Error("Timestamp duration range is out of bounds");if(e%2!==0||t!==e+1)throw new Error("WebGL timestamp durations require adjacent even/odd query indices");let i=await this._consumeTimestampPairResult(this._getTimestampPairIndex(e));return Number(i)/1e6}beginOcclusionQuery(){if(this.props.type!=="occlusion")throw new Error("Occlusion queries require an occlusion QuerySet");if(!this.handle)throw new Error("WebGL occlusion query is not available");if(this._occlusionActive)throw new Error("Occlusion query is already active");this.device.gl.beginQuery(35887,this.handle),this._occlusionQuery={handle:this.handle,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null},this._occlusionActive=!0}endOcclusionQuery(){if(!this._occlusionActive)throw new Error("Occlusion query is not active");this.device.gl.endQuery(35887),this._occlusionActive=!1}writeTimestamp(e){if(this.props.type!=="timestamp")throw new Error("Timestamp writes require a timestamp QuerySet");let t=this._getTimestampPairIndex(e),i=this._timestampPairs[t];if(e%2===0){if(i.activeQuery)throw new Error("Timestamp query pair is already active");let r=this.device.gl.createQuery();if(!r)throw new Error("WebGL query not supported");let s={handle:r,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null};this.device.gl.beginQuery(35007,r),i.activeQuery=s;return}if(!i.activeQuery)throw new Error("Timestamp query pair was ended before it was started");this.device.gl.endQuery(35007),i.completedQueries.push(i.activeQuery),i.activeQuery=null}_validateRange(e,t){if(e<0||t<0||e+t>this.props.count)throw new Error("Query read range is out of bounds")}_getTimestampPairIndex(e){if(e<0||e>=this.props.count)throw new Error("Query index is out of bounds");return Math.floor(e/2)}_isTimestampPairAvailable(e){let t=this._timestampPairs[e];return!t||t.completedQueries.length===0?!1:this._pollQueryAvailability(t.completedQueries[0])}_pollQueryAvailability(e){if(e.cancelled||this.destroyed)return e.result=0n,!0;if(e.result!==null||e.disjoint)return!0;if(!this.device.gl.getQueryParameter(e.handle,34919))return!1;let i=!!this.device.gl.getParameter(36795);return e.disjoint=i,e.result=i?0n:BigInt(this.device.gl.getQueryParameter(e.handle,34918)),!0}async _consumeTimestampPairResult(e){let t=this._timestampPairs[e];if(!t||t.completedQueries.length===0)throw new Error("Timestamp query pair has no completed result");let i=t.completedQueries.shift();try{return await this._consumeQueryResult(i)}finally{this.device.gl.deleteQuery(i.handle)}}_consumeQueryResult(e){return e.promise||(this._pendingReads.add(e),e.promise=new Promise((t,i)=>{e.resolve=t,e.reject=i;let r=()=>{if(e.pollRequestId=null,e.cancelled||this.destroyed){this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,t(0n);return}if(!this._pollQueryAvailability(e)){e.pollRequestId=this._requestAnimationFrame(r);return}this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,e.disjoint?i(new Error("GPU timestamp query was invalidated by a disjoint event")):t(e.result||0n)};r()})),e.promise}_cancelPendingQuery(e){if(this._pendingReads.delete(e),e.cancelled=!0,e.pollRequestId!==null&&(this._cancelAnimationFrame(e.pollRequestId),e.pollRequestId=null),e.resolve){let t=e.resolve;e.promise=null,e.resolve=null,e.reject=null,t(0n)}}_requestAnimationFrame(e){return requestAnimationFrame(e)}_cancelAnimationFrame(e){cancelAnimationFrame(e)}}});var vd,_P=C(()=>{ee();vd=class extends Na{device;gl;handle;signaled;_signaled=!1;constructor(e,t={}){super(e,{}),this.device=e,this.gl=e.gl;let i=this.props.handle||this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE,0);if(!i)throw new Error("Failed to create WebGL fence");this.handle=i,this.signaled=new Promise(r=>{let s=()=>{let o=this.gl.clientWaitSync(this.handle,0,0);o===this.gl.ALREADY_SIGNALED||o===this.gl.CONDITION_SATISFIED?(this._signaled=!0,r()):setTimeout(s,1)};s()})}isSignaled(){if(this._signaled)return!0;let e=this.gl.getSyncParameter(this.handle,this.gl.SYNC_STATUS);return this._signaled=e===this.gl.SIGNALED,this._signaled}destroy(){this.destroyed||this.gl.deleteSync(this.handle)}}});function _y(n){switch(n){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function yP(n){switch(n){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}var bP=C(()=>{});function vP(n,e){let{sourceX:t=0,sourceY:i=0,sourceAttachment:r=0}=e||{},{target:s=null,sourceWidth:o,sourceHeight:a,sourceDepth:c,sourceFormat:l,sourceType:u}=e||{},{framebuffer:f,deleteFramebuffer:d}=wP(n),{gl:h,handle:p}=f;o||=f.width,a||=f.height;let m=f.colorAttachments[r]?.texture;if(!m)throw new Error(`Invalid framebuffer attachment ${r}`);c=m?.depth||1,l||=m?.glFormat||6408,u||=m?.glType||5121,s=Az(s,u,l,o,a,c);let g=Ke.getDataType(s);u=u||Y2(g);let v=h.bindFramebuffer(36160,p);return h.readBuffer(36064+r),h.readPixels(t,i,o,a,l,u,s),h.readBuffer(36064),h.bindFramebuffer(36160,v||null),d&&f.destroy(),s}function xP(n,e){let{target:t,sourceX:i=0,sourceY:r=0,sourceFormat:s=6408,targetByteOffset:o=0}=e||{},{sourceWidth:a,sourceHeight:c,sourceType:l}=e||{},{framebuffer:u,deleteFramebuffer:f}=wP(n);a=a||u.width,c=c||u.height;let d=u;l=l||5121;let h=t;if(!h){let m=_y(s),g=yP(l),v=o+a*c*m*g;h=d.device.createBuffer({byteLength:v})}let p=n.device.createCommandEncoder();return p.copyTextureToBuffer({sourceTexture:n,width:a,height:c,origin:[i,r],destinationBuffer:h,byteOffset:o}),p.destroy(),f&&u.destroy(),h}function wP(n){return n instanceof Rr?{framebuffer:n,deleteFramebuffer:!1}:{framebuffer:Mz(n),deleteFramebuffer:!0}}function Mz(n,e){let{device:t,width:i,height:r,id:s}=n;return t.createFramebuffer({...e,id:`framebuffer-for-${s}`,width:i,height:r,colorAttachments:[n]})}function Az(n,e,t,i,r,s){if(n)return n;e||=5121;let o=ad(e),a=Ke.getTypedArrayConstructor(o),c=_y(t);return new a(i*r*c)}var EP=C(()=>{ee();fd();bP();my()});function SP(n){let e=new Map;for(let t in n){let i=n[t];if(t<"a"){let r=e.get(i);e.set(i,r?`${r}, GL.${t}`:`GL.${t}`)}}return e}var PP=C(()=>{});var yy={};ui(yy,{WebGLDevice:()=>er});function kz(n,e,t){switch(t.length){case 1:n.gl.vertexAttrib1fv(e,t);break;case 2:n.gl.vertexAttrib2fv(e,t);break;case 3:n.gl.vertexAttrib3fv(e,t);break;case 4:n.gl.vertexAttrib4fv(e,t);break;default:}}function Rz(n,e,t){n.gl.vertexAttribI4iv(e,t)}function Iz(n,e,t){n.gl.vertexAttribI4uiv(e,t)}function Bz(n,e){if(!n||!e||n.length!==e.length||n.constructor!==e.constructor)return!1;for(let t=0;t{ee();ey();w2();ty();P2();I2();B2();O2();D2();Z_();Lo();F2();Jf();$2();W2();cd();Xf();nP();rP();uP();hP();mP();gP();_P();EP();Po();od();Dc();PP();er=class n extends pi{static getDeviceFromContext(e){return e?e.luma?.device??null:null}type="webgl";handle;features;limits;info;canvasContext;preferredColorFormat="rgba8unorm";preferredDepthFormat="depth24plus";commandEncoder;lost;_resolveContextLost;_isLost=!1;gl;_glKeyByValue=null;_constants;extensions;_polyfilled=!1;spectorJS;get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(e){switch(e){case"unorm8x4-bgra":return!1;default:return!0}}constructor(e){super({...e,id:e.id||N2("webgl-device")});let t=pi._getCanvasContextProps(e);if(!t)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let i=t.canvas?.gl??null,r=n.getDeviceFromContext(i);if(r)throw new Error(`WebGL context already attached to device ${r.id}`);this.canvasContext=new Kf(this,t),this.lost=new Promise(u=>{this._resolveContextLost=u});let s={...e.webgl};t.alphaMode==="premultiplied"&&(s.premultipliedAlpha=!0),e.powerPreference!==void 0&&(s.powerPreference=e.powerPreference),e.failIfMajorPerformanceCaveat!==void 0&&(s.failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat);let a=this.props._handle||x2(this.canvasContext.canvas,{onContextLost:u=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."}),onContextRestored:u=>{console.log("WebGL context restored")}},s);if(!a)throw new Error("WebGL context creation failed");if(r=n.getDeviceFromContext(a),r){if(e._reuseDevices)return z.log(1,`Not creating a new Device, instead returning a reference to Device ${r.id} already attached to WebGL context`,r)(),this.canvasContext.destroy(),r._reused=!0,r;throw new Error(`WebGL context already attached to device ${r.id}`)}this.handle=a,this.gl=a,this.spectorJS=u2({...this.props,gl:this.handle});let c=Oc(this.handle);c.device=this,c.extensions||(c.extensions={}),this.extensions=c.extensions,this.info=E2(this.gl,this.extensions),this.limits=new Zf(this.gl),this.features=new qf(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new _n(this.gl,{log:(...u)=>z.log(1,...u)()}).trackState(this.gl,{copyState:!1}),(e.debug||e.debugWebGL)&&(this.gl=c2(this.gl,{debugWebGL:!0,traceWebGL:e.debugWebGL}),z.warn("WebGL debug mode activated. Performance reduced.")()),e.debugWebGL&&(z.level=Math.max(z.level,1)),this.commandEncoder=new $c(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}destroy(){if(!this.props._reuseDevices&&!this._reused){this._isLost=!0,this.commandEncoder?.destroy();let e=Oc(this.handle);e.device=null}}get isLost(){return this._isLost||this.gl.isContextLost()}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createPresentationContext(e){return new Qf(this,e||{})}createBuffer(e){let t=this._normalizeBufferProps(e);return new bn(this,t)}createTexture(e){return new Jn(this,e)}createExternalTexture(e){throw new Error("ExternalTexture is not available on WebGL")}createSampler(e){return new sd(this,e)}createShader(e){return new td(this,e)}createFramebuffer(e){return new Kn(this,e)}createVertexArray(e){return new gd(this,e)}createTransformFeedback(e){return new _d(this,e)}createQuerySet(e){return new bd(this,e)}createFence(){return new vd(this)}createRenderPipeline(e){return new dd(this,e)}_createSharedRenderPipelineWebGL(e){return new hd(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}createRenderBundleEncoder(e){throw new Error("Render bundles are only supported in WebGPU")}createCommandEncoder(e={}){return new $c(this,e)}submit(e){let t=null;e||({submittedCommandEncoder:t,commandBuffer:e}=this._finalizeDefaultCommandEncoderForSubmit());try{e._executeCommands(),t&&t.resolveTimeProfilingQuerySet().then(()=>{this.commandEncoder._gpuTimeMs=t._gpuTimeMs}).catch(()=>{})}finally{e.destroy()}}writeBufferViaCommandEncoder(e,t,i,r=0){t.write(i,r)}_finalizeDefaultCommandEncoderForSubmit(){let e=this.commandEncoder,t=e.finish();return this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:e.props.id,timeProfilingQuerySet:e.getTimeProfilingQuerySet()}),{submittedCommandEncoder:e,commandBuffer:t}}readPixelsToArrayWebGL(e,t){return vP(e,t)}readPixelsToBufferWebGL(e,t){return xP(e,t)}setParametersWebGL(e){gn(this.gl,e)}getParametersWebGL(e){return Gf(this.gl,e)}withParametersWebGL(e,t){return vn(this.gl,e,t)}resetWebGL(){z.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),g2(this.gl)}_getDeviceSpecificTextureFormatCapabilities(e){return A2(this.gl,e,this.extensions)}loseDevice(){let e=!1,i=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return i&&(e=!0,i.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){_n.get(this.gl).push()}popState(){_n.get(this.gl).pop()}getGLKey(e,t){let i=this._getGLKeyByValue().get(Number(e));return i||(t?.emptyIfUnknown?"":String(e))}getGLKeys(e){let t={emptyIfUnknown:!0};return Object.entries(e).reduce((i,[r,s])=>(i[`${r}:${this.getGLKey(r,t)}`]=`${s}:${this.getGLKey(s,t)}`,i),{})}_getGLKeyByValue(){return this._glKeyByValue??=SP(this.gl),this._glKeyByValue}setConstantAttributeWebGL(e,t){let i=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(i).fill(null);let r=this._constants[e];switch(r&&Bz(r,t)&&z.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=t,t.constructor){case Float32Array:kz(this,e,t);break;case Int32Array:Rz(this,e,t);break;case Uint32Array:Iz(this,e,t);break;default:throw new Error("constant")}}getExtension(e){return yn(this.gl,e,this.extensions),this.extensions}_setWebGLDebugMetadata(e,t,i){e.luma=t;let r={props:i.spector,id:i.spector.id};e.__SPECTOR_Metadata=r}}});function Oz(n){return typeof WebGL2RenderingContext<"u"&&n instanceof WebGL2RenderingContext?!0:!!(n&&typeof n.createVertexArray=="function")}function CP(n){return{...n,debug:n.debug??pi.defaultProps.debug,debugWebGL:n.debugWebGL??pi.defaultProps.debugWebGL,debugSpectorJS:n.debugSpectorJS??!!z.get("debug-spectorjs")}}async function TP(n){let e=[];(n.debugWebGL||n.debug)&&e.push(a2()),n.debugSpectorJS&&e.push(l2(n));let t=await Promise.allSettled(e);for(let i of t)i.status==="rejected"&&z.error(`Failed to initialize debug libraries ${i.reason}`)()}var Gc,by,Vc,LP=C(()=>{ee();s2();Z_();Gc=1,by=class extends wa{type="webgl";enforceWebGL2(e){r2(e)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext&&z.warn("WebGL1 is not supported",e)(),!1)}async attach(e,t={}){let{WebGLDevice:i}=await Promise.resolve().then(()=>(xd(),yy));if(e instanceof i)return e;let r=i.getDeviceFromContext(e);if(r)return r;if(!Oz(e))throw new Error("Invalid WebGL2RenderingContext");t=CP(t),await TP(t);let s=t.createCanvasContext===!0?{}:t.createCanvasContext;return new i({...t,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...s}})}async create(e={}){let{WebGLDevice:t}=await Promise.resolve().then(()=>(xd(),yy));e=CP(e),await TP(e);try{let i=new t(e);z.groupCollapsed(Gc,`WebGLDevice ${i.id} created`)();let r=`${i._reused?"Reusing":"Created"} device with WebGL2 ${i.props.debug?"debug ":""}context: ${i.info.vendor}, ${i.info.renderer} for canvas: ${i.canvasContext.id}`;return z.probe(Gc,r)(),z.table(Gc,i.info)(),i}finally{z.groupEnd(Gc)(),z.info(Gc,"%cWebGL call tracing: luma.log.set('debug-webgl') ","color: white; background: blue; padding: 2px 6px; border-radius: 3px;")()}}};Vc=new by});var yd=C(()=>{LP();xd();Jf()});function Cd(n){return NP.test(n)}function Td(n){return FP.test(n)}function zP(n){let e=NP.exec(n),t=FP.exec(n),i=e?.[1]??t?.[1]??n;try{Ee.getVertexFormatInfo(i)}catch{throw new Error(`Unsupported GPUVector format ${n}`)}return i}function wi(n){let e=zP(n),t=Cd(n),i=Td(n),r=Ee.getVertexFormatInfo(e),s=r.type,o=r.normalized,a=Uz(s,o);return{format:n,elementFormat:e,vertexList:t,valueList:i,type:s,signedDataType:$z(e,s),primitiveType:a,components:r.components,byteLength:r.byteLength,integer:r.integer,signed:r.signed,normalized:o,...r.webglOnly?{webglOnly:!0}:{}}}function Uz(n,e){if(e)return"f32";switch(n){case"float32":return"f32";case"float16":return"f16";case"uint8":case"uint16":case"uint32":return"u32";case"sint8":case"sint16":case"sint32":return"i32";default:throw new Error(`Unsupported GPUVector component type ${n}`)}}function $z(n,e){if(n==="unorm10-10-10-2")return"uint32";switch(e){case"unorm8":return"uint8";case"snorm8":return"sint8";case"unorm16":return"uint16";case"snorm16":return"sint16";default:return e}}var NP,FP,Ld=C(()=>{ee();NP=/^vertex-list<([^<>]+)>$/,FP=/^value-list<([^<>]+)>$/});function wy(n,e){if(!Number.isSafeInteger(n)||n<0)throw new Error(`${e} must be a non-negative safe integer`)}var Ei,Ey=C(()=>{ee();Ei=class{buffer;format;length;byteOffset;byteStride;constructor(e){let t=Ee.getVertexFormatInfo(e.format).byteLength,i=e.byteOffset??0,r=e.byteStride??t;if(wy(e.length,"GPUDataView length"),wy(i,"GPUDataView byteOffset"),wy(r,"GPUDataView byteStride"),re.buffer.byteLength)throw new Error("GPUDataView exceeds its backing buffer byte length");this.buffer=e.buffer,this.format=e.format,this.length=e.length,this.byteOffset=i,this.byteStride=r}get elementByteLength(){return Ee.getVertexFormatInfo(this.format).byteLength}get byteLength(){return this.length===0?0:(this.length-1)*this.byteStride+this.elementByteLength}}});function Ad(n){return!!(n&&typeof n=="object"&&n.type==="struct")}function $P(n,e){let t=Object.entries(n);if(t.length===0)throw new Error("GPUData struct format must declare at least one field");return e==="packed"?Gz(t):Vz(t)}function Gz(n){let e=[],t=0,i=0;for(let[r,s]of n){let o=Ee.getVertexFormatInfo(s);if(o.webglOnly)throw new Error(`Packed GPUData struct field "${r}" uses WebGL-only format ${s}`);t=UP(t,Math.min(4,o.byteLength)),e.push([r,Object.freeze({format:s,byteOffset:t,byteLength:o.byteLength})]),t+=o.byteLength,i+=o.components}return Object.freeze({type:"struct",layout:"packed",fields:Object.freeze(Object.fromEntries(e)),components:i,byteStride:UP(t,4),rowByteLength:t})}function Vz(n){let e=Object.fromEntries(n.map(([o,a])=>[o,Wz(a)])),t=Dr(e,{layout:"wgsl-storage"}),i=[],r=0,s=0;for(let[o,a]of n){let c=Ee.getVertexFormatInfo(a),l=t.fields[o].offset*4;i.push([o,Object.freeze({format:a,byteOffset:l,byteLength:c.byteLength})]),r=Math.max(r,l+c.byteLength),s+=c.components}return Object.freeze({type:"struct",layout:"wgsl-storage",fields:Object.freeze(Object.fromEntries(i)),components:s,byteStride:t.byteLength,rowByteLength:r})}function Wz(n){let e=Ee.getVertexFormatInfo(n);switch(e.type){case"float32":return Md("f32",e.components);case"sint32":return Md("i32",e.components);case"uint32":return Md("u32",e.components);default:{let t=Math.ceil(e.byteLength/4);return Md("u32",t)}}}function Md(n,e){return e===1?n:`vec${e}<${n}>`}function UP(n,e){return Math.ceil(n/e)*e}var GP=C(()=>{ee()});var Sy,Py,Mo,Cy=C(()=>{Ey();GP();Ld();Sy=class{buffer;ownsDataBuffer;constructor(e,t){this.buffer=e,this.ownsDataBuffer=t}get ownsBuffer(){return this.ownsDataBuffer}transferBufferOwnership(e){if(e.buffer!==this.buffer)throw new Error("GPUData ownership can only be transferred to the same buffer");e.ownsDataBuffer=this.ownsDataBuffer,this.ownsDataBuffer=!1}destroy(){this.ownsDataBuffer&&(this.buffer.destroy(),this.ownsDataBuffer=!1)}},Py=class extends Sy{dataType;format;length;valueLength;stride;byteOffset;byteStride;rowByteLength;readbackMetadata;valueOffsets;nullBitmap;valueByteLength;constructor(e){let{buffer:t,format:i,length:r,valueLength:s,stride:o,byteOffset:a=0,byteStride:c,rowByteLength:l,ownsBuffer:u=!1,readbackMetadata:f,valueOffsets:d,nullBitmap:h,valueByteLength:p,dataType:m}=e;super(t,u);let g;i?typeof i=="string"?g=i:g=$P(i,e.layout??"wgsl-storage"):g=void 0;let v=Ad(g)?g:void 0,y=typeof g=="string"?wi(g):void 0;if(this.dataType=m,this.format=g,this.length=r,this.valueLength=s??r,this.stride=o??y?.components??v?.components??c??l??1,this.byteOffset=a,this.rowByteLength=l??v?.rowByteLength??y?.byteLength??c??this.stride,this.byteStride=c??v?.byteStride??this.rowByteLength,v){if(this.rowByteLengthi.format!==e))throw new Error("GPUVector data chunks must share the declared format")}var ei,WP=C(()=>{Cy();Ld();ei=class{name;dataType;format;length;valueLength;stride;byteOffset;byteStride;rowByteLength;bufferLayout;data=[];device;bufferProps;isAppendable=!1;ownsDataChunks=!0;ownedVectors=[];appendableByteLength=0;constructor(e){switch(e.type){case"buffer":{let{name:t,buffer:i,format:r,length:s,valueLength:o=s,byteOffset:a=0,ownsBuffer:c=!1}=e,{stride:l,byteStride:u,rowByteLength:f}=VP(e);this.name=t,this.dataType=e.dataType,this.format=r,this.length=s,this.valueLength=o,this.stride=l,this.byteOffset=a,this.byteStride=u,this.rowByteLength=f,this.data.push(new Mo({buffer:i,format:r,length:s,valueLength:o,stride:l,byteOffset:a,byteStride:u,rowByteLength:f,ownsBuffer:c,dataType:e.dataType}));return}case"interleaved":{let{name:t,buffer:i,format:r,length:s,valueLength:o=s,byteOffset:a=0,byteStride:c,attributes:l,ownsBuffer:u=!1}=e;this.name=t,this.dataType=e.dataType,this.format=r,this.length=s,this.valueLength=o,this.stride=c,this.byteOffset=a,this.byteStride=c,this.rowByteLength=c,this.bufferLayout={name:t,byteStride:c,attributes:l},this.data.push(new Mo({buffer:i,format:r,length:s,valueLength:o,stride:c,byteOffset:a,byteStride:c,rowByteLength:c,ownsBuffer:u,dataType:e.dataType}));return}case"data":{let t=e.format??jz(e.data),i=t?wi(t):void 0,{name:r,data:s,stride:o=s[0]?.stride??i?.components??1,valueLength:a=s.reduce((d,h)=>d+h.valueLength,0),byteStride:c=s[0]?.byteStride??i?.byteLength,rowByteLength:l=s[0]?.rowByteLength??i?.byteLength,bufferLayout:u,ownsData:f=!1}=e;if(c===void 0||l===void 0)throw new Error("GPUVector requires format or explicit byte layout metadata");t&&Hz(s,t),this.name=r,this.dataType=e.dataType,this.format=t,this.length=s.reduce((d,h)=>d+h.length,0),this.valueLength=a,this.stride=o,this.byteOffset=s.length===1?s[0].byteOffset:0,this.byteStride=c,this.rowByteLength=l,this.bufferLayout=u,this.ownsDataChunks=f,this.data.push(...s);return}case"appendable":{let{name:t,device:i,format:r,valueLength:s=0,bufferProps:o}=e,{stride:a,byteStride:c,rowByteLength:l}=VP(e);this.name=t,this.dataType=e.dataType,this.format=r,this.length=0,this.valueLength=s,this.stride=a,this.byteOffset=0,this.byteStride=c,this.rowByteLength=l,this.device=i,this.bufferProps=o,this.isAppendable=!0;return}}}get ownsBuffer(){return this.ownsDataChunks&&this.data.some(e=>e.ownsBuffer)||this.ownedVectors.some(e=>e.ownsBuffer)}get capacityRows(){return this.isAppendable?this.length:void 0}get appendedByteLength(){return this.appendableByteLength}addData(e){if(this.format&&e.format!==this.format)throw new Error("GPUVector.addData() requires matching formats");if(e.byteStride!==this.byteStride)throw new Error("GPUVector.addData() requires matching byteStride");if(e.rowByteLength!==this.rowByteLength)throw new Error("GPUVector.addData() requires matching rowByteLength");return this.data.push(e),this.length+=e.length,this.valueLength+=e.valueLength,this}appendDataChunk(e,t=this.appendableByteLength+e.buffer.byteLength){if(!this.isAppendable)throw new Error("GPUVector.appendDataChunk() requires appendable vector storage");if(this.format&&e.format!==this.format)throw new Error("GPUVector.appendDataChunk() requires matching formats");if(e.byteStride!==this.byteStride||e.rowByteLength!==this.rowByteLength)throw new Error("GPUVector.appendDataChunk() requires matching byte layout metadata");return this.data.push(e),this.length+=e.length,this.valueLength+=e.valueLength,this.appendableByteLength=t,this}resetLastBatch(){if(!this.isAppendable)throw new Error("GPUVector.resetLastBatch() requires appendable vector storage");for(let e of this.data.splice(0))e.destroy();return this.length=0,this.valueLength=0,this.appendableByteLength=0,this}retainOwnedVectors(e){return this.ownedVectors.push(...e),this}transferBufferOwnership(e){let t=this.data[0],i=e.data[0];if(!t||!i||t.buffer!==i.buffer)throw new Error("GPUVector ownership can only be transferred to the same buffer");t.transferBufferOwnership(i)}destroy(){if(this.ownsDataChunks)for(let e of this.data)e.destroy();for(let e of this.ownedVectors.splice(0))e.destroy()}}});var Ty=C(()=>{Cy();Ey();WP();Ld()});var Ly,pt,qc=C(()=>{ee();Ly=class{poolSize=20;bufferPools;constructor(){this.bufferPools=new Map}createOrReuse(e,t){if(t>e.limits.maxBufferSize)throw new Error(`Buffer pool cannot allocate ${t} bytes: device.limits.maxBufferSize is ${e.limits.maxBufferSize}`);let i=this.bufferPools.get(e),r=i?i.findIndex(o=>o.byteLength>=t):-1;if(r<0)return e.createBuffer({usage:re.VERTEX|re.STORAGE|re.COPY_DST|re.COPY_SRC,byteLength:t});let[s]=i.splice(r,1);return s}recycle(e){let t=e.device;this.bufferPools.has(t)||this.bufferPools.set(t,[]);let i=this.bufferPools.get(t),r=i.findIndex(s=>s.byteLength>e.byteLength);r<0?i.push(e):i.splice(r,0,e),this.purge()}purge(){for(let[e,t]of this.bufferPools){let i=e.isLost?0:this.poolSize;for(;t.length>i;)t.shift().destroy();t.length===0&&this.bufferPools.delete(e)}}},pt=new Ly});function Yz(n,e,t,i){let{ValueType:r,size:s,offset:o,stride:a}=n,c=a/r.BYTES_PER_ELEMENT,l=o/r.BYTES_PER_ELEMENT,u=i-t;if(c===s){let d=l+t*c;return e.subarray(d,d+u*s)}let f=new r(u*s);for(let d=0;d0)throw new Error(`GPUDataEvaluator requires exactly one GPUData chunk for "${n.name}"`);return e}function Xz(n){let e=[];return HP(n,e,{byteOffset:0}),e}function HP(n,e,t){let i=n.source;if(i&&!(i instanceof ye)&&i.name==="interleave"){for(let r of Object.values(i.inputs))r instanceof ye&&HP(r,e,t);return}e.push({attribute:n.id??n.toString(),format:YP(n.type,n.size,n.normalized),byteOffset:t.byteOffset}),t.byteOffset+=n.ValueType.BYTES_PER_ELEMENT*n.size}function YP(n,e,t=!1){if(e<1||e>4)throw new Error(`Cannot synthesize a GPUVector vertex format with ${e} components`);let i=n;if(t)switch(n){case"uint8":i="unorm8";break;case"sint8":i="snorm8";break;case"uint16":i="unorm16";break;case"sint16":i="snorm16";break;case"float32":i="float32";break;default:throw new Error(`Unsupported normalized vertex format for ${n}`)}return(i==="uint8"||i==="sint8"||i==="uint16"||i==="sint16"||i==="unorm8"||i==="snorm8"||i==="unorm16"||i==="snorm16")&&e===3?`${i}x3-webgl`:`${i}${e===1?"":`x${e}`}`}function Kz(n,e,t=!1){return e>=1&&e<=4?YP(n,e,t):void 0}var ye,Si=C(()=>{ee();Ce();Ty();qc();ye=class n{static get bufferPoolSize(){return pt.poolSize}static set bufferPoolSize(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("GPUDataEvaluator.bufferPoolSize must be a non-negative safe integer");pt.poolSize=e,pt.purge()}type;size;get offset(){return this._offset}get stride(){return this._stride}normalized;isConstant;length;get byteLength(){return this._byteLength}ValueType;source=null;format;_id;_destroyed=!1;_value;_offset;_stride;_byteLength;_gpuVector;_bufferOwnership="owned";_targetBuffer;static fromArray(e,{type:t,size:i=1,offset:r=0,stride:s=0,normalized:o=!1}){let a=t,c;if(Array.isArray(e)){a=a||"float32";let u=Tr(a);c=new u(e)}else e instanceof Float64Array?(a="uint32",i*=2,r*=2,s*=2,c=new Uint32Array(e.buffer,e.byteOffset,e.byteLength/4)):(a=a||Tu(e),c=e);let l=`<${a} * ${i}>`;return new n({id:l,type:a,size:i,offset:r,stride:s,normalized:o,value:c})}static fromConstant(e,t="float32"){let i=Tr(t),r;return Array.isArray(e)?r=`[${e.join(",")}]`:(r=String(e),e=[e]),new n({id:r,isConstant:!0,type:t,size:e.length,value:new i(e)})}static fromGPUData(e,t={}){qz(e);let i=new Ei({buffer:e.buffer,format:e.format,length:e.length,byteOffset:e.byteOffset,byteStride:e.byteStride});return new n({...jP(i),id:t.id,gpuData:e})}static fromGPUDataView(e,t={}){return new n({...jP(e),id:t.id,buffer:e.buffer})}constructor(e){let{id:t,value:i,buffer:r,gpuData:s,format:o,source:a=null,isConstant:c=!1}=e;if(!a&&!i&&!r&&!s)throw new Error("GPUDataEvaluator must have a value source");let{type:l,size:u,offset:f,stride:d,normalized:h,length:p}=e;if(a instanceof n?(l=l??a.type,u=u??a.size,f=f??a.offset,d=d??a.stride,h=h??a.normalized,p=p??a.length):(u=u??1,f=f??0,h=h??!1,p=c?1:p),!l)throw new Error("GPUDataEvaluator: type not defined");if(this._id=t,this.type=l,this.size=u,this.ValueType=Tr(this.type),this._offset=f,this._stride=d||this.ValueType.BYTES_PER_ELEMENT*u,this.normalized=h,this.source=a,this.format=o,p===void 0)if(c)p=1;else{if(!i)throw new Error("GPUDataEvaluator: length not defined");p=Math.ceil(i.byteLength/this.stride)}this.isConstant=c,this.length=p;let m=this.ValueType.BYTES_PER_ELEMENT*this.size;this._byteLength=p===0?0:(p-1)*this.stride+m,this._value=i,this._bufferOwnership=a instanceof n||r||s?"borrowed":"owned",s?this._gpuVector=new ei({type:"data",name:this._id??"data",format:s.format,data:[s],stride:s.stride,byteStride:s.byteStride,rowByteLength:s.rowByteLength}):r&&(this._gpuVector=this.createGPUVectorView({buffer:r,name:this._id,format:this.format}))}get value(){return this._value||(this.source instanceof n?this.source.value:void 0)}get evaluated(){return!!this._gpuVector}get id(){return this._id}get gpuVector(){if(!this._gpuVector)throw new Error(`${this} not evaluated`);return this._gpuVector}get buffer(){return kd(this.gpuVector)}setTargetBuffer({buffer:e,byteOffset:t=0,byteStride:i=this.stride}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)throw new Error(`GPUDataEvaluator ${this} already evaluated`);if(!this.source||this.source instanceof n)throw new Error("GPUDataEvaluator target buffers require a deferred operation source");this._targetBuffer={buffer:e,byteOffset:t,byteStride:i}}async evaluate(e,t={}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let i;if(this.source instanceof n){let r=await this.source.evaluate(e);return this._gpuVector=this.createGPUVectorView({...t,buffer:kd(r)}),this._gpuVector}if(i=this._getEvaluationBuffer(e),this._value)i.write(this._value);else{let r=await this.source.execute(e,i);if(!r.success)throw r.error||new Error(`${this.source} evaluation failed`);r.value&&(this._value=r.value)}return this._gpuVector=this.createGPUVectorView({...t,buffer:i}),this._gpuVector}evaluateSync(e,t={}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let i;if(this.source instanceof n){let r=this.source.evaluateSync(e);return this._gpuVector=this.createGPUVectorView({...t,buffer:kd(r)}),this._gpuVector}if(i=this._getEvaluationBuffer(e),this._value)i.write(this._value);else{let r=this.source.executeSync(e,i);if(!r.success)throw r.error||new Error(`${this.source} evaluation failed`);r.value&&(this._value=r.value)}return this._gpuVector=this.createGPUVectorView({...t,buffer:i}),this._gpuVector}createGPUVectorView(e){let t=e.name??this._id??"vector",i=e.format??this.format??Kz(this.type,this.size,this.normalized);if(e.interleaved){let r=typeof e.interleaved=="object"&&e.interleaved.attributes?e.interleaved.attributes:Xz(this);return new ei({type:"interleaved",name:t,buffer:e.buffer,format:e.format??this.format,length:this.length,byteOffset:this.offset,byteStride:this.stride,attributes:r,ownsBuffer:!1})}return new ei({type:"buffer",name:t,buffer:e.buffer,format:i,length:this.length,stride:this.size,byteOffset:this.offset,byteStride:this.stride,rowByteLength:this.ValueType.BYTES_PER_ELEMENT*this.size,ownsBuffer:!1})}_getEvaluationBuffer(e){let t=this._targetBuffer;if(!t)return pt.createOrReuse(e,this.byteLength);if(t.buffer.device!==e)throw new Error("GPUDataEvaluator target buffer belongs to a different device");let i=this.ValueType.BYTES_PER_ELEMENT*this.size,r=this.length===0?0:(this.length-1)*t.byteStride+i;if(t.byteOffset+r>t.buffer.byteLength)throw new Error("GPUDataEvaluator target buffer is too small for the output layout");return this._offset=t.byteOffset,this._stride=t.byteStride,this._byteLength=r,this._bufferOwnership="borrowed",this._targetBuffer=void 0,t.buffer}async readValue(e=0,t){let{ValueType:i}=this,{size:r,offset:s,stride:o,length:a}=this,c=i.BYTES_PER_ELEMENT*r;if(t=t??a,e=Math.max(0,Math.min(a,e)),t=Math.max(e,Math.min(a,t)),this._value)return Yz(this,this._value,e,t);let l=t-e;if(l===0)return new i(0);let u=s+e*o,f=o===c?l*c:(l-1)*o+c,d=await this.buffer.readAsync(u,f),h=new i(d.buffer,d.byteOffset,d.byteLength/i.BYTES_PER_ELEMENT);if(o===c)return h;let p=new Uint8Array(c*l);for(let m=0;m{Ao={add:{arity:2,symbol:"arithmetic_add"},subtract:{arity:2,symbol:"arithmetic_subtract"},multiply:{arity:2,symbol:"arithmetic_multiply"},divide:{arity:2,symbol:"arithmetic_divide"},pow:{arity:2,symbol:"pow"},sqrt:{arity:1,symbol:"sqrt"},abs:{arity:1,symbol:"abs"},sin:{arity:1,symbol:"sin"},cos:{arity:1,symbol:"cos"},tan:{arity:1,symbol:"arithmetic_tan"},exp:{arity:1,symbol:"exp"},log:{arity:1,symbol:"log"}}});function cC(n,{operations:e,inputs:t}){switch(n.kind){case"input":if(!(n.name in t))throw new Error(`Unknown expression input '${n.name}'`);return;case"literal":if(Array.isArray(n.value)){for(let i of n.value)if(!Number.isFinite(i))throw new Error(`Expression literal array must contain only finite values, got ${i}`)}else if(!Number.isFinite(n.value))throw new Error(`Expression literal must be finite, got ${n.value}`);return;case"call":{let i=e[n.op];if(!i)throw new Error(`Unknown expression op '${n.op}'`);if(n.args.length!==i.arity)throw new Error(`Expression op '${n.op}' expects ${i.arity} args, got ${n.args.length}`);for(let r of n.args)cC(r,{operations:e,inputs:t});return}default:{let i=n;throw new Error(`Unsupported expression node ${i.kind}`)}}}function Bd(n,e){return cC(n,e),lC(n,e)}function lC(n,e){switch(n.kind){case"input":{let t=e.inputs[n.name];return e.laneIndexlC(r,e));return e.formatCall(t.symbol,i)}default:{let t=n;throw new Error(`Unsupported expression node ${t.kind}`)}}}var Ry=C(()=>{});function rt(n,e,t=!1){if(t)return e===1?"float":`vec${e}`;switch(n){case"uint8":case"uint16":case"uint32":return e===1?"uint":`uvec${e}`;case"sint8":case"sint16":case"sint32":return e===1?"int":`ivec${e}`;default:return e===1?"float":`vec${e}`}}function Od(n,e,t=!1){let i;if(t)switch(n){case"uint8":i="unorm8";break;case"sint8":i="snorm8";break;case"uint16":i="unorm16";break;case"sint16":i="snorm16";break;case"float32":i="float32";break;default:throw new Error(`Unsupported normalized vertex format for ${n}`)}else i=n;return e===1?i:e===3&&!i.startsWith("float32")&&!i.endsWith("32")?`${i}x3-webgl`:`${i}x${e}`}function tr(n){switch(n[0]){case"u":return"0u";case"s":return"0";default:return"0."}}function uC(n,e){switch(n){case"uint8":case"uint16":case"uint32":return`${Math.trunc(e)}u`;case"sint8":case"sint16":case"sint32":return`${Math.trunc(e)}`;default:return Number.isInteger(e)?`${e}.0`:`${e}`}}function fC(n){switch(n){case"uint8":return"r8uint";case"sint8":return"r8sint";case"uint16":return"r16uint";case"sint16":return"r16sint";case"uint32":return"r32uint";case"sint32":return"r32sint";case"float32":return"r32float";default:throw new Error(`Unsupported WebGL gather texture format for ${n}`)}}function dC(n){switch(n){case"uint32":return"usampler2D";case"sint32":return"isampler2D";case"float32":return"sampler2D";default:throw new Error(`Unsupported WebGL gather sampler type for ${n}`)}}var Ro=C(()=>{});function st({module:n,elementWise:e=!1,expression:t,inputs:i,output:r,operationType:s=r.type,outputBuffer:o}){let a=o.device,c=cs("result",r.type,r.size,r.normalized),l=[n,c],u=[],f={},d=rt(r.type,1,r.normalized),h=rt(s,1,r.normalized),p="",m=null,g={TYPE:h,RESULT_LEN:r.size.toString()},v=oU(i);for(let[E,x]of v)l.push(Iy(E,x.type,x.size,x.normalized,s)),u.push(By(E,x)),x instanceof ye?f[E]=x.buffer:(m=m||pt.createOrReuse(a,o.byteLength),f[E]=m),p+=`TYPE ${E}[${x.size}]; get_${E}(${E}); +`,g[`${E.toUpperCase()}_LEN`]=x.size.toString();let y="";if(t)for(let E=0;EEE).join(", ")}, result);`;let b=`#version 300 es + +void main() { +${p} +${d} result[${r.size}]; +${y} +set_result(result); +} + `,w=new it(a,{vs:b,shaderAssembler:sU,defines:g,modules:l,bufferLayout:u,vertexCount:1,instanceCount:r.length,attributes:f,feedbackBufferMode:"interleaved",outputs:c.varyings});a.statsManager.getStats(iU).get(rU).incrementCount(),w.run({inputBuffers:f,outputBuffers:{[c.varyings[0]]:r.offset===0?o:{buffer:o,byteOffset:r.offset,byteLength:r.byteLength}}}),m&&pt.recycle(m)}function oU(n){return Array.isArray(n)?n.map((e,t)=>[`x${t}`,e]):Object.entries(n)}function Iy(n,e,t,i=!1,r=e){let s="",o="";for(let c=0;c1&&(d=`${d}[${f}]`),(i||e!==r)&&(d=`TYPE(${d})`),o+=`v[${c+f}]=${d}; +`}}let a=` +${s} +void get_${n}(out TYPE v[${t}]) { + ${o} +} +`;return{name:n,vs:a}}function By(n,e){let t={name:n,stepMode:e.isConstant?"vertex":"instance",byteStride:e.stride,attributes:[]};for(let i=0;ic+h);a+=`${n}_${c} = ${u}(${f.map(d=>`v[${d}]`).join(",")}); +`}return{name:n,varyings:r,vs:` +${o} +void set_${n}(in ${s} v[${t}]) { + ${a} +} +`}}var iU,rU,sU,Bt=C(()=>{Ce();bt();Si();qc();Ro();iU="GPGPU Operation Counts",rU="Transform Runs",sU=new Xs});var aU,Dd,Oy=C(()=>{bt();Ry();Id();Bt();Ro();aU=`TYPE arithmetic_add(TYPE x, TYPE y) { + return x + y; +} + +TYPE arithmetic_subtract(TYPE x, TYPE y) { + return x - y; +} + +TYPE arithmetic_multiply(TYPE x, TYPE y) { + return x * y; +} + +TYPE arithmetic_divide(TYPE x, TYPE y) { + return x / y; +} + +float arithmetic_tan(float x) { + return tan_fp32(x); +} +`,Dd=({inputs:n,output:e,target:t})=>{let i=e.type,r=rt(i,1,e.normalized),s=tr(r),o=n.namedInputs;return st({module:{name:"arithmetic",dependencies:[Vr],vs:aU},inputs:o,output:e,operationType:i,outputBuffer:t,expression:a=>Bd(n.expression,{operations:Ao,inputs:o,laneIndex:a,formatInput:c=>`${c}[${a}]`,formatOutOfBoundsInput:c=>o[c].size===1?`${c}[0]`:s,formatLiteral:c=>{let l=Array.isArray(c)?c[a]??0:c;return`${r}(${uC(i,l)})`},formatCall:(c,l)=>`${c}(${l.join(", ")})`})}),{success:!0}}});var cU,lU,pC,hC,mC=C(()=>{ee();Ce();Si();qc();Oy();Bt();cU="GPGPU Operation Counts",lU="Transform Runs",pC=({inputs:n,output:e,target:t})=>{let{sourceValues:i}=n,r=t.device;if(i.length===0){let f=new e.ValueType(e.length*e.size);return t.write(f),{success:!0,value:f}}if(i.isConstant){let f=i.value,d=new e.ValueType(e.length*e.size);for(let h=0;hi+Math.ceil(r.size/4),0);if(t>n)throw new Error(`interleave() requires ${t} vertex attributes, exceeding device limit ${n}`)}function fU(n,e){if(e.size>n)throw new Error(`interleave() output size ${e.size} exceeds device inter-stage component limit ${n}`)}var gC,_C=C(()=>{Bt();gC=({inputs:n,output:e,target:t})=>{let i=n.map((c,l)=>[`x${l}`,c]);uU(t.device.limits.maxVertexAttributes,i),fU(t.device.limits.maxInterStageShaderVariables,e);let r=i.map(([c,l])=>`in TYPE ${c}[${l.size}]`).join(", "),s=0,o=i.map(([c,l])=>{let u=Array.from({length:l.size},(f,d)=>` result[${s+d}] = ${c}[${d}];`).join(` +`);return s+=l.size,u}).join(` +`),a=`void interleave(${r}, out TYPE result[RESULT_LEN]) { +${o} +} +`;return st({module:{name:"interleave",vs:a},inputs:n,output:e,outputBuffer:t}),{success:!0}}});function dU(){let n=new Uint16Array([255]);return new Uint8Array(n.buffer)[0]>0}var hU,yC,bC=C(()=>{Bt();hU=`#define LE ${dU()?1:0} +const uint F32_NAN = 0xffffffffu; +const uint F32_INF = 0x7f800000u; + +// Find first set bit using binary search +// https://en.wikipedia.org/wiki/Find_first_set#CLZ +int countLeadingZeros(uint a) { + if (a == 0u) return 32; + int n = 0; + if ((a & 0xffff0000u) == 0u) { n += 16; a = a << 16; } + if ((a & 0xff000000u) == 0u) { n += 8; a = a << 8; } + if ((a & 0xf0000000u) == 0u) { n += 4; a = a << 4; } + if ((a & 0xc0000000u) == 0u) { n += 2; a = a << 2; } + if ((a & 0x80000000u) == 0u) return n + 1; + return n; +} + +uint roundShiftRight(uint value, int shift) { + if (shift <= 0) { + return value << (-shift); + } + + if (shift >= 32) { + if (shift == 32 && value > 0x80000000u) { + return 1u; + } + return 0u; + } + + uint truncated = value >> shift; + uint halfShift = 1u << (shift - 1); + uint remainder = value & ((1u << shift) - 1u); + if (remainder > halfShift || (remainder == halfShift && (truncated & 1u) == 1u)) { + return truncated + 1u; + } + return truncated; +} + +uint makeFloat_(uint sign, int exponent, uint mantissa) { + return (sign << 31) | (uint(exponent + 127) << 23) | (mantissa & 0x7fffffu); +} + +/** + * Assemble a float32 in bit representation according to IEEE 754 + * https://en.wikipedia.org/wiki/Single-precision_floating-point_format + */ +uint makeFloat(uint sign, int exponent, uint significand) { + if (significand == 0u) { + return sign << 31; + } + + // Remove any extra leading zeros for better precision + int lead_zeros = countLeadingZeros(significand); + // Significand is encoded as 1.fraction + int normalizedExponent = exponent + 31 - lead_zeros; + + if (normalizedExponent > 127) { + return (sign << 31) | F32_INF; + } + + uint mantissa; + if (normalizedExponent >= -126) { + mantissa = roundShiftRight(significand, 8 - lead_zeros); + if (mantissa >= 0x1000000u) { + mantissa >>= 1; + normalizedExponent++; + if (normalizedExponent > 127) { + return (sign << 31) | F32_INF; + } + } + return makeFloat_(sign, normalizedExponent, mantissa); + } + + int subnormalShift = -149 - exponent; + mantissa = roundShiftRight(significand, subnormalShift); + if (mantissa >= 0x800000u) { + return (sign << 31) | (1u << 23); + } + return (sign << 31) | mantissa; +} + +/** + * Parse 8-byte memory as a float64 number according to IEEE 754 + * https://en.wikipedia.org/wiki/Double-precision_floating-point_format + * Returns 8-byte memory as 2 float32 numbers, consisting of + * high part: fround(d) + * low part: d - fround(d) + */ +uvec2 parseAsDouble(uvec2 d) { + #if LE + d = d.yx; // to big endian + #endif + + uint sign = (d[0] >> 31) & 1u; // first bit + uint exponentBits = (d[0] >> 20) & 0x7ffu; + int exponent = int(exponentBits) - 1023; // next 11 bits + uint fractionHigh = d[0] & 0xfffffu; + uint fractionLow = d[1]; + + if (exponentBits == 0x7ffu) { + if (fractionHigh == 0u && fractionLow == 0u) { + return uvec2((sign << 31) | F32_INF, F32_NAN); + } + return uvec2(F32_NAN); + } + + if (exponentBits == 0u) { + // All float64 subnormals are too small to survive a float32 split. + return uvec2(sign << 31); + } + + if (exponent > 127) { + return uvec2((sign << 31) | F32_INF, ((1u - sign) << 31) | F32_INF); + } + + uint hi_part; + uint low_part; + + // float64 significand has 52 bits + // float32 significand has 23 bits + // The significand of the high part is the significand of the double, trimmed + uint f_hi = 0x800000u | (fractionHigh << 3) | (fractionLow >> 29); + uint f_low = fractionLow & 0x1fffffffu; + + if (exponent < -126) { + // For tiny normals, the top 24 significand bits still contribute to the float32 + // high part, but they land in the float32 subnormal range. + hi_part = makeFloat(sign, exponent - 23, f_hi); + + // The residual keeps the remaining 29 significand bits at the original double scale. + low_part = makeFloat(sign, exponent - 52, f_low); + return uvec2(hi_part, low_part); + } + + bool roundUp = f_low > 0x10000000u || (f_low == 0x10000000u && (f_hi & 1u) == 1u); + + uint f_rounded = f_hi + (roundUp ? 1u : 0u); + int exponent_hi = exponent; + if (f_rounded == 0x1000000u) { + f_rounded = 0x800000u; + exponent_hi++; + } + + if (exponent_hi > 127) { + // Overflows float32 limit + hi_part = (sign << 31) | F32_INF; + low_part = ((1u - sign) << 31) | F32_INF; + return uvec2(hi_part, low_part); + } + + hi_part = makeFloat_(sign, exponent_hi, f_rounded); + + int remainder = int(f_low); + uint sign_low = sign; + if (roundUp) { + remainder -= 0x20000000; + } + if (remainder < 0) { + sign_low = 1u - sign; + remainder = -remainder; + } + low_part = makeFloat(sign_low, exponent - 52, uint(remainder)); + + return uvec2(hi_part, low_part); +} + +void fround(in uint x[X_LEN], out float result[X_LEN]) { + int n = X_LEN / 2; + for (int i = 0; i < n; i++) { + uvec2 f = parseAsDouble(uvec2(x[i * 2], x[i * 2 + 1])); + result[i] = uintBitsToFloat(f.x); + result[i + n] = uintBitsToFloat(f.y); + } +} +`,yC=({inputs:n,output:e,target:t})=>(st({module:{name:"fround",vs:hU},inputs:n,output:e,operationType:"uint32",outputBuffer:t}),{success:!0})});function Nd(n,e,t){let i=dC(t),r=rt(e,1),s=Array.from({length:n.size},(o,a)=>` v[${a}] = ${r}(texelFetch(source_values_texture, ivec2(${a}, rowIndex), 0).r);`).join(` +`);return{name:"source_values_texture",vs:` +uniform highp ${i} source_values_texture; +void read_source_values(int rowIndex, out TYPE v[${n.size}]) { +${s} +} +`}}function Fd(n,e,t){let i=t.createTexture({width:Math.max(n.size,1),height:n.length,format:fC(e),usage:pe.SAMPLE|pe.COPY_DST});if(n.length===0)return i;let r=t.createCommandEncoder();return r.copyBufferToTexture({sourceBuffer:n.buffer,destinationTexture:i,byteOffset:n.offset,bytesPerRow:n.stride,rowsPerImage:n.length,size:[n.size,n.length,1]}),t.submit(r.finish()),i}var Dy=C(()=>{ee();Ro()});function pU(n,e){let t=rt(n.type,1),i="aids_0";return n.type!==_U(e)&&(i=`${e}(${i})`),{name:"ids",vs:` +in ${t} aids_0; +void get_ids(out INDEX_TYPE v[1]) { + v[0] = ${i}; +} +`}}function mU(n){return{name:"ids",stepMode:n.isConstant?"vertex":"instance",byteStride:n.stride,attributes:[{attribute:"aids_0",format:Od(n.type,1,n.normalized),byteOffset:n.offset}]}}function gU(n){return{name:"gather",vs:` +void zero_result(out TYPE result[RESULT_LEN]) { + for (int i = 0; i < RESULT_LEN; i++) { + result[i] = ${tr(n)}; + } +} + +void gather(in INDEX_TYPE ids[1], out TYPE result[RESULT_LEN]) { + int sourceIndex = int(ids[0]); + if (sourceIndex < 0 || sourceIndex >= SOURCE_VALUES_ROWS) { + zero_result(result); + return; + } + read_source_values(sourceIndex, result); +} +`}}function _U(n){switch(n){case"uint":return"uint32";case"int":return"sint32";default:return"float32"}}var vC,xC=C(()=>{Ce();Ro();Bt();Dy();vC=async({inputs:n,output:e,target:t})=>{let{ids:i,sourceValues:r}=n,s=t.device,o=cs("result",e.type,e.size),a=rt(i.type,1),c=rt(e.type,1),l=e.type,u=Fd(r,l,s),f=`#version 300 es + +void main() { + INDEX_TYPE ids[1]; + get_ids(ids); + TYPE result[${e.size}]; + gather(ids, result); + set_result(result); +} + `,d=new it(s,{vs:f,defines:{INDEX_TYPE:a,TYPE:c,RESULT_LEN:e.size.toString(),SOURCE_VALUES_ROWS:r.length.toString()},modules:[pU(i,a),Nd(r,e.type,l),gU(e.type),o],bindings:{source_values_texture:u},bufferLayout:[mU(i)],vertexCount:1,instanceCount:e.length,feedbackBufferMode:"interleaved",outputs:o.varyings});try{return d.run({inputBuffers:{ids:i.buffer},outputBuffers:{[o.varyings[0]]:t}}),{success:!0}}finally{d.destroy(),u.destroy()}}});var yU,wC,EC=C(()=>{Bt();yU=`void row_dot(in TYPE x[X_LEN], in TYPE y[Y_LEN], out float result[1]) { + float sum = 0.0; + for (int i = 0; i < X_LEN; i++) { + sum += float(x[i]) * float(y[i]); + } + result[0] = sum; +} +`,wC=({inputs:n,output:e,target:t})=>(st({module:{name:"row_dot",vs:yU},inputs:n,output:e,operationType:"float32",outputBuffer:t}),{success:!0})});var bU,SC,PC=C(()=>{Bt();bU=`void equalAll(in TYPE x[X_LEN], in TYPE y[Y_LEN], out uint result[1]) { + uint allEqual = uint(1); + for (int i = 0; i < X_LEN; i++) { + if (x[i] != y[i]) { + allEqual = uint(0); + break; + } + } + result[0] = allEqual; +} +`,SC=({inputs:n,output:e,target:t})=>(st({module:{name:"equalAll",vs:bU},inputs:n,output:e,operationType:e.type==="uint32"?n.x.type:e.type,outputBuffer:t}),{success:!0})});var vU,CC,TC=C(()=>{Bt();vU=`void row_length(in TYPE x[X_LEN], out float result[1]) { + float sum = 0.0; + for (int i = 0; i < X_LEN; i++) { + sum += float(x[i]) * float(x[i]); + } + result[0] = sqrt(sum); +} +`,CC=({inputs:n,output:e,target:t})=>(st({module:{name:"row_length",vs:vU},inputs:n,output:e,operationType:"float32",outputBuffer:t}),{success:!0})});function xU(){return{name:"segmentedMap",vs:` +uint read_segment_start(int segmentIndex) { + TYPE value[1]; + read_source_values(segmentIndex, value); + return uint(value[0]); +} + +void segmentedMap(out TYPE result[RESULT_LEN]) { + uint vertexIndex = uint(gl_InstanceID); + int low = 0; + int high = SEGMENTS_LENGTH; + + while (low < high) { + int mid = low + (high - low) / 2; + uint midStart = read_segment_start(mid); + if (midStart <= vertexIndex) { + low = mid + 1; + } else { + high = mid; + } + } + + uint segmentIndex = uint(max(low - 1, 0)); + uint segmentStart = read_segment_start(int(segmentIndex)); + result[0] = segmentIndex; + result[1] = vertexIndex - segmentStart; +} +`}}var LC,MC=C(()=>{Ce();Dy();Bt();LC=async({inputs:n,output:e,target:t})=>{let{segments:i}=n,r=t.device,s=cs("result",e.type,e.size),o=i.type,a=Fd(i,o,r),c=new it(r,{vs:`#version 300 es + +void main() { + TYPE result[RESULT_LEN]; + segmentedMap(result); + set_result(result); +} +`,defines:{TYPE:"uint",RESULT_LEN:e.size.toString(),SEGMENTS_LENGTH:i.length.toString()},modules:[Nd(i,e.type,o),xU(),s],bindings:{source_values_texture:a},vertexCount:1,instanceCount:e.length,feedbackBufferMode:"interleaved",outputs:s.varyings});try{return c.run({outputBuffers:{[s.varyings[0]]:t}}),{success:!0}}finally{c.destroy(),a.destroy()}}});function Ny(n,e,t,i){return t{Bt();Ro();AC=async({inputs:n,output:e,target:t})=>{let i=rt(e.type,1,e.normalized),r=tr(i);return st({module:{name:"select",vs:""},inputs:n,output:e,operationType:e.type,outputBuffer:t,expression:s=>{let o=Ny("condition",n.condition,s,r),a=Ny("whenTrue",n.whenTrue,s,r),c=Ny("whenFalse",n.whenFalse,s,r);return`(${o} != ${r} ? ${a} : ${c})`}}),{success:!0}}});var RC,IC=C(()=>{Ce();Bt();RC=({inputs:n,output:e,target:t})=>{let i=cs("result",e.type,e.size),r=new it(t.device,{vs:`#version 300 es + +void main() { + int result[1]; + result[0] = START + gl_InstanceID * STEP; + set_result(result); +} +`,defines:{START:n.start.toString(),STEP:n.step.toString()},modules:[i],vertexCount:1,instanceCount:e.length,feedbackBufferMode:"interleaved",outputs:i.varyings});try{return r.run({outputBuffers:{[i.varyings[0]]:t}}),{success:!0}}finally{r.destroy()}}});var BC,OC=C(()=>{Bt();BC=({inputs:n,output:e,target:t})=>{let{columns:i}=n;return st({module:{name:"swizzle",vs:"// swizzle expression handled inline"},expression:r=>`x[${i[r]}]`,inputs:{x:n.x},output:e,outputBuffer:t}),{success:!0}}});var DC={};ui(DC,{arithmetic:()=>Dd,dot:()=>wC,equalAll:()=>SC,extent:()=>pC,fround:()=>yC,gather:()=>vC,interleave:()=>gC,length:()=>CC,segmentedMap:()=>LC,select:()=>AC,sequence:()=>RC,swizzle:()=>BC});var NC=C(()=>{Oy();mC();_C();bC();xC();EC();PC();TC();MC();kC();IC();OC()});function ti(n,e){let t=wU(e),i=Math.max(1,Math.ceil(n)),r=Math.min(i,t),s=Math.min(Math.ceil(i/r),t),o=Math.ceil(i/r/s);if(o>t)throw new Error(`WebGPU dispatch requires ${i} workgroups, exceeding the 3D dispatch limit of ${t} per dimension`);return{x:r,y:s,z:o}}function Fy(n,e="workgroupId"){return`((${e}.z * ${n.y}u + ${e}.y) * ${n.x}u + ${e}.x)`}function nr(n,e,t="workgroupId",i="localId"){return`(${Fy(n,t)} * ${e}u + ${i}.x)`}function wU(n){return Number.isFinite(n)&&n>0?Math.floor(n):65535}var Io=C(()=>{});function ir(n,e){switch(n){case"u32":return`${e}u`;case"f32":return Number.isInteger(e)?`${e}.0`:`${e}`;default:return`${e}`}}function FC(n,e){switch(n){case"uint32":return ir("u32",Math.trunc(e));case"sint32":return`${Math.trunc(e)}`;case"float32":return ir("f32",e);default:throw new Error(`WebGPU operations only support 32-bit output types, got ${n}`)}}function rr(n){switch(n){case"uint32":return"0u";case"sint32":return"0";case"float32":return"0.0";default:throw new Error(`WebGPU operations only support 32-bit output types, got ${n}`)}}function we(n){switch(n){case"uint32":return"u32";case"sint32":return"i32";case"float32":return"f32";default:throw new Error(`WebGPU operations only support 32-bit storage types, got ${n}`)}}var ls=C(()=>{});function ot({module:n,elementWise:e=!1,expression:t,inputs:i,output:r,operationType:s=r.type,outputBuffer:o}){if(!n.source)throw new Error(`WebGPU computation ${n.name} requires WGSL source`);let a=kU(i),c=a.map(([y,b])=>({name:y,input:b})),l=c.filter(({input:y})=>!y.isConstant).map((y,b)=>({...y,index:b})),u=we(s),f=we(r.type),d={TYPE:u,RESULT_LEN:r.size.toString()},h=ti(Math.ceil(r.length/zy),o.device.limits.maxComputeWorkgroupsPerDimension);for(let[y,b]of a)d[`${y.toUpperCase()}_LEN`]=b.size.toString();let p=` +${IU(n.source,d)} +${l.map(({name:y,input:b,index:w})=>CU(y,b,w)).join(` +`)} +${c.map(({name:y,input:b})=>TU(y,b,s)).join(` +`)} +${LU(r,l.length)} +${MU(r)} + +@compute @workgroup_size(${zy}) fn main( + @builtin(workgroup_id) workgroupId: vec3, + @builtin(local_invocation_id) localId: vec3 +) { + let rowIndex = ${nr(h,zy)}; + if (rowIndex >= ${r.length}u) { + return; + } + +${c.map(({name:y})=>` let ${y} = read_${y}(rowIndex);`).join(` +`)} + var result: array<${f}, ${r.size}>; +${AU(n.name,a,r,e,t)} + write_result(rowIndex, result); +} +`,m=new Rt(o.device,{source:p,modules:n.dependencies,shaderAssembler:PU,shaderLayout:{bindings:[...l.map(({name:y},b)=>({name:y,type:"storage",group:0,location:b})),{name:"result",type:"storage",group:0,location:l.length}]}}),g=Object.fromEntries(l.map(({name:y,input:b})=>[y,b.buffer]));g.result=o,m.setBindings(g);let v=o.device.beginComputePass({});o.device.statsManager.getStats(EU).get(SU).incrementCount(),m.dispatch(v,h.x,h.y,h.z),v.end(),o.device.submit(),m.destroy()}function CU(n,e,t){if(e.isConstant)return"";let i=we(e.type);return`@group(0) @binding(${t}) var ${n}: array<${i}>;`}function TU(n,e,t){let i=we(t),r=e.type===t?"":i,s=e.stride/e.ValueType.BYTES_PER_ELEMENT,o=e.offset/e.ValueType.BYTES_PER_ELEMENT;return e.isConstant?`fn read_${n}(_rowIndex: u32) -> array<${i}, ${e.size}> { + return array<${i}, ${e.size}>(${RU(e,r)}); +}`:`fn read_${n}(rowIndex: u32) -> array<${i}, ${e.size}> { + var value: array<${i}, ${e.size}>; + let rowOffset = ${o}u + rowIndex * ${s}u; +${Array.from({length:e.size},(a,c)=>r?` value[${c}] = ${r}(${n}[rowOffset + ${c}u]);`:` value[${c}] = ${n}[rowOffset + ${c}u];`).join(` +`)} + return value; +}`}function LU(n,e){let t=we(n.type);return`@group(0) @binding(${e}) var result: array<${t}>;`}function MU(n){let e=n.stride/n.ValueType.BYTES_PER_ELEMENT,t=n.offset/n.ValueType.BYTES_PER_ELEMENT;return`fn write_result(rowIndex: u32, value: array<${we(n.type)}, ${n.size}>) { + let rowOffset = ${t}u + rowIndex * ${e}u; +${Array.from({length:n.size},(r,s)=>` result[rowOffset + ${s}u] = value[${s}];`).join(` +`)} +}`}function AU(n,e,t,i,r){let s="";if(r)for(let o=0;oco).join(", ")});`;return s.trimEnd()}function kU(n){return Array.isArray(n)?n.map((e,t)=>[`x${t}`,e]):Object.entries(n)}function RU(n,e){let t=n.value;if(!t)throw new Error(`Constant input ${n} is missing CPU values`);return Array.from({length:n.size},(i,r)=>ir(e,t[r]??0)).join(", ")}function IU(n,e){for(let t in e)n=n.replaceAll(`{${t}}`,e[t]);return n}var zy,EU,SU,PU,Pi=C(()=>{Ce();bt();Io();ls();zy=64,EU="GPGPU Operation Counts",SU="Computation Runs",PU=new Hi});var BU,zC,UC=C(()=>{bt();Ry();Id();Pi();ls();BU=`fn arithmetic_add(x: {TYPE}, y: {TYPE}) -> {TYPE} { + return x + y; +} + +fn arithmetic_subtract(x: {TYPE}, y: {TYPE}) -> {TYPE} { + return x - y; +} + +fn arithmetic_multiply(x: {TYPE}, y: {TYPE}) -> {TYPE} { + return x * y; +} + +fn arithmetic_divide(x: {TYPE}, y: {TYPE}) -> {TYPE} { + return x / y; +} + +fn arithmetic_tan(x: f32) -> f32 { + return tan_fp32(x); +} +`,zC=({inputs:n,output:e,target:t})=>{let i=e.type,r=we(i),s=rr(i),o=n.namedInputs;return ot({module:{name:"arithmetic",source:BU,dependencies:[Vr]},inputs:o,output:e,operationType:i,outputBuffer:t,expression:a=>Bd(n.expression,{operations:Ao,inputs:o,laneIndex:a,formatInput:c=>`${c}[${a}]`,formatOutOfBoundsInput:c=>o[c].size===1?`${c}[0]`:s,formatLiteral:c=>{let l=Array.isArray(c)?c[a]??0:c;return`${r}(${FC(i,l)})`},formatCall:(c,l)=>`${c}(${l.join(", ")})`})}),{success:!0}}});var OU,$C,GC=C(()=>{Pi();OU=`fn row_dot(x: array<{TYPE}, {X_LEN}>, y: array<{TYPE}, {Y_LEN}>) -> array { + var sum = 0.0; + for (var i = 0u; i < {X_LEN}u; i = i + 1u) { + sum += f32(x[i]) * f32(y[i]); + } + return array(sum); +} +`,$C=({inputs:n,output:e,target:t})=>(ot({module:{name:"row_dot",source:OU},inputs:n,output:e,operationType:"float32",outputBuffer:t}),{success:!0})});var DU,VC,WC=C(()=>{Pi();DU=`fn equalAll(x: array<{TYPE}, {X_LEN}>, y: array<{TYPE}, {Y_LEN}>) -> array { + var allEqual = 1u; + for (var i = 0u; i < {X_LEN}u; i = i + 1u) { + if (x[i] != y[i]) { + allEqual = 0u; + break; + } + } + return array(allEqual); +} +`,VC=({inputs:n,output:e,target:t})=>(ot({module:{name:"equalAll",source:DU},inputs:n,output:e,operationType:n.x.type,outputBuffer:t}),{success:!0})});function Bo(n,e,t){let i=we(e.type);return`@group(0) @binding(${t}) var ${n}: array<${i}>;`}function Uy(n,e,t,i=n){let r=we(t);if(e.isConstant){let l=e.value;if(!l)throw new Error(`Constant input ${e} is missing CPU values`);return`fn read_${i}(_sourceIndex: u32) -> array<${r}, ${e.size}> { + return array<${r}, ${e.size}>(${Array.from({length:e.size},(u,f)=>ir(r,l[f]??0)).join(", ")}); +}`}let s=e.stride/e.ValueType.BYTES_PER_ELEMENT,o=e.offset/e.ValueType.BYTES_PER_ELEMENT,c=we(e.type)===r?"":`${r}`;return`fn read_${i}(sourceIndex: u32) -> array<${r}, ${e.size}> { + var value: array<${r}, ${e.size}>; + let rowOffset = ${o}u + sourceIndex * ${s}u; +${Array.from({length:e.size},(l,u)=>c?` value[${u}] = ${c}(${n}[rowOffset + ${u}u]);`:` value[${u}] = ${n}[rowOffset + ${u}u];`).join(` +`)} + return value; +}`}function zd(n,e){return Uy("sourceValues",n,e,"source_values")}function Oo(n,e){let t=we(n.type);return`@group(0) @binding(${e}) var result: array<${t}>;`}function Do(n){let e=n.stride/n.ValueType.BYTES_PER_ELEMENT,t=n.offset/n.ValueType.BYTES_PER_ELEMENT;return`fn write_result(rowIndex: u32, value: array<${we(n.type)}, ${n.size}>) { + let rowOffset = ${t}u + rowIndex * ${e}u; +${Array.from({length:n.size},(r,s)=>` result[rowOffset + ${s}u] = value[${s}];`).join(` +`)} +}`}function jC(n,e){let t=rr(n);return`fn zero_result() -> array<${we(n)}, ${e}> { + var result: array<${we(n)}, ${e}>; +${Array.from({length:e},(i,r)=>` result[${r}] = ${t};`).join(` +`)} + return result; +}`}var mt,Ud=C(()=>{ls();mt=64});function NU({input:n,inputMode:e,inputGroupCount:t,channelCount:i,outputType:r,outputBuffer:s,outputLength:o,outputStride:a,outputOffset:c}){let l=we(r),u=ti(o,s.device.limits.maxComputeWorkgroupsPerDimension),f=new ye({buffer:s,type:r,size:2,length:o,stride:a,offset:c}),d=` +${n.isConstant?"":Bo("sourceValues",n,0)} +${zd(n,r)} +${Oo(f,n.isConstant?0:1)} +${Do(f)} +${FU(e,r,i,t)} + +var sharedMin: array<${l}, ${mt}>; +var sharedMax: array<${l}, ${mt}>; + +@compute @workgroup_size(${mt}) fn main( + @builtin(workgroup_id) workgroupId: vec3, + @builtin(local_invocation_id) localId: vec3 +) { + let outputRowIndex = ${Fy(u)}; + if (outputRowIndex >= ${o}u) { + return; + } + + let channelIndex = outputRowIndex % ${i}u; + let outputGroupIndex = outputRowIndex / ${i}u; + let inputGroupIndex = outputGroupIndex * ${mt}u + localId.x; + + let result = extent_pass(channelIndex, inputGroupIndex); + sharedMin[localId.x] = result[0]; + sharedMax[localId.x] = result[1]; + workgroupBarrier(); + + var stride = ${Math.floor(mt/2)}u; + loop { + if (stride == 0u) { + break; + } + if (localId.x < stride) { + let compareIndex = localId.x + stride; + if (sharedMin[compareIndex] < sharedMin[localId.x]) { + sharedMin[localId.x] = sharedMin[compareIndex]; + } + if (sharedMax[compareIndex] > sharedMax[localId.x]) { + sharedMax[localId.x] = sharedMax[compareIndex]; + } + } + workgroupBarrier(); + stride = stride / 2u; + } + + if (localId.x == 0u) { + write_result(outputRowIndex, array<${l}, 2>(sharedMin[0], sharedMax[0])); + } +} +`,h=new Rt(s.device,{source:d,shaderLayout:{bindings:[...n.isConstant?[]:[{name:"sourceValues",type:"storage",group:0,location:0}],{name:"result",type:"storage",group:0,location:n.isConstant?0:1}]}}),p={result:s};n.isConstant||(p.sourceValues=n.buffer),h.setBindings(p);let m=s.device.beginComputePass({});h.dispatch(m,u.x,u.y,u.z),m.end(),s.device.submit(),h.destroy()}function FU(n,e,t,i){let r=we(e),[s,o]=zU(e);return n==="raw"?`fn extent_pass(channelIndex: u32, inputGroupIndex: u32) -> array<${r}, 2> { + var result: array<${r}, 2>; + result[0] = ${s}; + result[1] = ${o}; + + if (inputGroupIndex < ${i}u) { + let value = read_source_values(inputGroupIndex); + result[0] = value[channelIndex]; + result[1] = value[channelIndex]; + } + + return result; +}`:`fn extent_pass(channelIndex: u32, inputGroupIndex: u32) -> array<${r}, 2> { + var result: array<${r}, 2>; + result[0] = ${s}; + result[1] = ${o}; + + if (inputGroupIndex < ${i}u) { + let rowIndex = inputGroupIndex * ${t}u + channelIndex; + let value = read_source_values(rowIndex); + result[0] = value[0]; + result[1] = value[1]; + } + + return result; +}`}function zU(n){switch(n){case"uint32":return["0xffffffffu","0u"];case"sint32":return["2147483647","-2147483648"];case"float32":return["3.402823e38","-3.402823e38"];default:throw new Error(`Unsupported WebGPU extent type for ${n}`)}}var HC,YC=C(()=>{Ce();Si();qc();Io();ls();Ud();HC=({inputs:n,output:e,target:t})=>{let{sourceValues:i}=n;if(i.length===0){let c=new e.ValueType(e.length*e.size);return t.write(c),{success:!0,value:c}}if(i.isConstant){let c=i.value;if(!c)throw new Error(`Constant input ${i} is missing CPU values`);let l=new e.ValueType(e.length*e.size);for(let u=0;u1&&r.push(u),NU({input:s,inputMode:o,inputGroupCount:a,channelCount:e.length,outputType:e.type,outputBuffer:u,outputLength:l,outputStride:e.stride,outputOffset:e.offset}),c===1)break;s=new ye({buffer:u,type:e.type,size:2,length:l}),o="partial",a=c}return{success:!0}}finally{for(let c of r)pt.recycle(c)}}});function UU(){let n=new Uint16Array([255]);return new Uint8Array(n.buffer)[0]>0}var $U,qC,ZC=C(()=>{Pi();$U=`const LE: bool = ${UU()?"true":"false"}; +const F32_NAN: u32 = 0xffffffffu; +const F32_INF: u32 = 0x7f800000u; + +fn roundShiftRight(value: u32, shift: i32) -> u32 { + if (shift <= 0) { + return value << u32(-shift); + } + + if (shift >= 32) { + if (shift == 32 && value > 0x80000000u) { + return 1u; + } + return 0u; + } + + let shiftU32 = u32(shift); + let truncated = value >> shiftU32; + let halfShift = 1u << u32(shift - 1); + let remainder = value & ((1u << shiftU32) - 1u); + if (remainder > halfShift || (remainder == halfShift && (truncated & 1u) == 1u)) { + return truncated + 1u; + } + return truncated; +} + +fn makeFloatImmediate(sign: u32, exponent: i32, mantissa: u32) -> u32 { + return (sign << 31u) | (u32(exponent + 127) << 23u) | (mantissa & 0x7fffffu); +} + +fn makeFloat(sign: u32, exponent: i32, significand: u32) -> u32 { + if (significand == 0u) { + return sign << 31u; + } + + let leadingZeros = i32(countLeadingZeros(significand)); + var normalizedExponent = exponent + 31 - leadingZeros; + + if (normalizedExponent > 127) { + return (sign << 31u) | F32_INF; + } + + var mantissa: u32; + if (normalizedExponent >= -126) { + mantissa = roundShiftRight(significand, 8 - leadingZeros); + if (mantissa >= 0x1000000u) { + mantissa = mantissa >> 1u; + normalizedExponent += 1; + if (normalizedExponent > 127) { + return (sign << 31u) | F32_INF; + } + } + return makeFloatImmediate(sign, normalizedExponent, mantissa); + } + + let subnormalShift = -149 - exponent; + mantissa = roundShiftRight(significand, subnormalShift); + if (mantissa >= 0x800000u) { + return (sign << 31u) | (1u << 23u); + } + return (sign << 31u) | mantissa; +} + +fn parseAsDouble(words: vec2) -> vec2 { + var d = words; + if (LE) { + d = d.yx; + } + + let sign = (d.x >> 31u) & 1u; + let exponentBits = (d.x >> 20u) & 0x7ffu; + let exponent = i32(exponentBits) - 1023; + let fractionHigh = d.x & 0xfffffu; + let fractionLow = d.y; + + if (exponentBits == 0x7ffu) { + if (fractionHigh == 0u && fractionLow == 0u) { + return vec2((sign << 31u) | F32_INF, F32_NAN); + } + return vec2(F32_NAN); + } + + if (exponentBits == 0u) { + return vec2(sign << 31u); + } + + if (exponent > 127) { + return vec2((sign << 31u) | F32_INF, ((1u - sign) << 31u) | F32_INF); + } + + let highSignificand = 0x800000u | (fractionHigh << 3u) | (fractionLow >> 29u); + let lowSignificand = fractionLow & 0x1fffffffu; + + if (exponent < -126) { + let highPart = makeFloat(sign, exponent - 23, highSignificand); + let lowPart = makeFloat(sign, exponent - 52, lowSignificand); + return vec2(highPart, lowPart); + } + + let roundUp = lowSignificand > 0x10000000u || + (lowSignificand == 0x10000000u && (highSignificand & 1u) == 1u); + + var roundedSignificand = highSignificand + select(0u, 1u, roundUp); + var highExponent = exponent; + if (roundedSignificand == 0x1000000u) { + roundedSignificand = 0x800000u; + highExponent += 1; + } + + if (highExponent > 127) { + return vec2((sign << 31u) | F32_INF, ((1u - sign) << 31u) | F32_INF); + } + + let highPart = makeFloatImmediate(sign, highExponent, roundedSignificand); + + var remainder = i32(lowSignificand); + var lowSign = sign; + if (roundUp) { + remainder -= 0x20000000; + } + if (remainder < 0) { + lowSign = 1u - sign; + remainder = -remainder; + } + + let lowPart = makeFloat(lowSign, exponent - 52, u32(remainder)); + return vec2(highPart, lowPart); +} + +fn fround(x: array) -> array { + var result: array; + let n = {X_LEN}u / 2u; + for (var i = 0u; i < n; i = i + 1u) { + let parts = parseAsDouble(vec2(x[i * 2u], x[i * 2u + 1u])); + result[i] = bitcast(parts.x); + result[i + n] = bitcast(parts.y); + } + return result; +} +`,qC=({inputs:n,output:e,target:t})=>(ot({module:{name:"fround",source:$U},inputs:n,output:e,operationType:"uint32",outputBuffer:t}),{success:!0})});function GU(n,e){if(n.isConstant){let r=n.value;if(!r)throw new Error(`Constant input ${n} is missing CPU values`);return`fn read_ids(_rowIndex: u32) -> ${e} { + return ${ir(e,r[0]??0)}; +}`}let t=n.stride/n.ValueType.BYTES_PER_ELEMENT,i=n.offset/n.ValueType.BYTES_PER_ELEMENT;return`fn read_ids(rowIndex: u32) -> ${e} { + let rowOffset = ${i}u + rowIndex * ${t}u; + return ids[rowOffset]; +}`}function VU(n,e,t,i){let r=we(n),s=we(e);return`fn gather(idsValue: ${r}) -> array<${s}, ${t}> { + let sourceIndex = ${r==="u32"?"i32(idsValue)":r==="i32"?"idsValue":"i32(idsValue)"}; + if (sourceIndex < 0 || sourceIndex >= ${i}) { + return zero_result(); + } + return read_source_values(u32(sourceIndex)); +}`}var XC,KC=C(()=>{Ce();Io();ls();Ud();XC=async({inputs:n,output:e,target:t})=>{let{ids:i,sourceValues:r}=n,s=we(i.type),o=[];i.isConstant||o.push({name:"ids",input:i,index:o.length}),r.isConstant||o.push({name:"sourceValues",input:r,index:o.length});let a=ti(Math.ceil(e.length/mt),t.device.limits.maxComputeWorkgroupsPerDimension),c=` +${o.map(({name:d,input:h,index:p})=>Bo(d,h,p)).join(` +`)} +${GU(i,s)} +${zd(r,e.type)} +${Oo(e,o.length)} +${Do(e)} +${jC(e.type,e.size)} +${VU(i.type,e.type,e.size,r.length)} + +@compute @workgroup_size(${mt}) fn main( + @builtin(workgroup_id) workgroupId: vec3, + @builtin(local_invocation_id) localId: vec3 +) { + let rowIndex = ${nr(a,mt)}; + if (rowIndex >= ${e.length}u) { + return; + } + + let idsValue = read_ids(rowIndex); + let result = gather(idsValue); + write_result(rowIndex, result); +} +`,l=new Rt(t.device,{source:c,shaderLayout:{bindings:[...o.map(({name:d,index:h})=>({name:d,type:"storage",group:0,location:h})),{name:"result",type:"storage",group:0,location:o.length}]}}),u={};i.isConstant||(u.ids=i.buffer),r.isConstant||(u.sourceValues=r.buffer),u.result=t,l.setBindings(u);let f=t.device.beginComputePass({});return l.dispatch(f,a.x,a.y,a.z),f.end(),t.device.submit(),l.destroy(),{success:!0}}});function WU(n){return`fn segmented_map(vertexIndex: u32) -> array { + var low = 0i; + var high = ${n}i; + while (low < high) { + let mid = low + (high - low) / 2i; + let midStart = read_segments(u32(mid))[0]; + if (midStart <= vertexIndex) { + low = mid + 1i; + } else { + high = mid; + } + } + + let segmentIndex = u32(max(low - 1i, 0i)); + let segmentStart = read_segments(segmentIndex)[0]; + return array(segmentIndex, vertexIndex - segmentStart); +}`}var QC,JC=C(()=>{Ce();Io();Ud();QC=async({inputs:n,output:e,target:t})=>{let{segments:i}=n,r=i.isConstant?[]:[{name:"segments",input:i,index:0}],s=ti(Math.ceil(e.length/mt),t.device.limits.maxComputeWorkgroupsPerDimension),o=` +${r.map(({name:u,input:f,index:d})=>Bo(u,f,d)).join(` +`)} +${Uy("segments",i,"uint32")} +${Oo(e,r.length)} +${Do(e)} +${WU(i.length)} + +@compute @workgroup_size(${mt}) fn main( + @builtin(workgroup_id) workgroupId: vec3, + @builtin(local_invocation_id) localId: vec3 +) { + let rowIndex = ${nr(s,mt)}; + if (rowIndex >= ${e.length}u) { + return; + } + + let result = segmented_map(rowIndex); + write_result(rowIndex, result); +} +`,a=new Rt(t.device,{source:o,shaderLayout:{bindings:[...r.map(({name:u,index:f})=>({name:u,type:"storage",group:0,location:f})),{name:"result",type:"storage",group:0,location:r.length}]}}),c=Object.fromEntries(r.map(({name:u,input:f})=>[u,f.buffer]));c.result=t,a.setBindings(c);let l=t.device.beginComputePass({});return a.dispatch(l,s.x,s.y,s.z),l.end(),t.device.submit(),a.destroy(),{success:!0}}});function jU(n,e){let i=e.filter(([,r])=>!r.isConstant).length+1;if(i>n.maxStorageBuffersPerShaderStage)throw new Error(`interleave() requires ${i} storage buffers, exceeding device limit ${n.maxStorageBuffersPerShaderStage}`);if(i>n.maxBindingsPerBindGroup)throw new Error(`interleave() requires ${i} bindings, exceeding bind group limit ${n.maxBindingsPerBindGroup}`)}var $d,eT=C(()=>{Pi();$d=({inputs:n,output:e,target:t})=>{let i=n.map((c,l)=>[`x${l}`,c]);jU(t.device.limits,i);let r=i.map(([c,l])=>`${c}: array<{TYPE}, ${l.size}>`).join(", "),s=0,o=i.map(([c,l])=>{let u=Array.from({length:l.size},(f,d)=>` out[${s+d}] = ${c}[${d}];`).join(` +`);return s+=l.size,u}).join(` +`),a=`fn interleave(${r}) -> array<{TYPE}, {RESULT_LEN}> { + var out: array<{TYPE}, {RESULT_LEN}>; +${o} + return out; +} +`;return ot({module:{name:"interleave",source:a},inputs:n,output:e,outputBuffer:t}),{success:!0}}});var HU,tT,nT=C(()=>{Pi();HU=`fn row_length(x: array<{TYPE}, {X_LEN}>) -> array { + var sum = 0.0; + for (var i = 0u; i < {X_LEN}u; i = i + 1u) { + sum += f32(x[i]) * f32(x[i]); + } + return array(sqrt(sum)); +} +`,tT=({inputs:n,output:e,target:t})=>(ot({module:{name:"row_length",source:HU},inputs:n,output:e,operationType:"float32",outputBuffer:t}),{success:!0})});function $y(n,e,t,i){return t{Pi();ls();iT=async({inputs:n,output:e,target:t})=>{let i=rr(e.type);return ot({module:{name:"select",source:`// inline expression select +`},inputs:n,output:e,operationType:e.type,outputBuffer:t,expression:r=>{let s=$y("condition",n.condition,r,i),o=$y("whenTrue",n.whenTrue,r,i);return`select(${$y("whenFalse",n.whenFalse,r,i)}, ${o}, ${s} != ${i})`}}),{success:!0}}});var Gy,sT,oT=C(()=>{Ce();Io();Gy=64,sT=({inputs:n,output:e,target:t})=>{let i=ti(Math.ceil(e.length/Gy),t.device.limits.maxComputeWorkgroupsPerDimension),r=`@group(0) @binding(0) var result: array; + +@compute @workgroup_size(${Gy}) fn main( + @builtin(workgroup_id) workgroupId: vec3, + @builtin(local_invocation_id) localId: vec3 +) { + let rowIndex = ${nr(i,Gy)}; + if (rowIndex >= ${e.length}u) { + return; + } + + let rowOffset = ${e.offset/e.ValueType.BYTES_PER_ELEMENT}u + rowIndex * ${e.stride/e.ValueType.BYTES_PER_ELEMENT}u; + result[rowOffset] = ${n.start} + i32(rowIndex) * ${n.step}; +} +`,s=new Rt(t.device,{source:r,shaderLayout:{bindings:[{name:"result",type:"storage",group:0,location:0}]}});s.setBindings({result:t});let o=t.device.beginComputePass({});return s.dispatch(o,i.x,i.y,i.z),o.end(),t.device.submit(),s.destroy(),{success:!0}}});var aT,cT=C(()=>{Pi();aT=({inputs:n,output:e,target:t})=>{let{columns:i}=n;return ot({module:{name:"swizzle",source:"// swizzle expression handled inline"},expression:r=>`x[${i[r]}]`,inputs:{x:n.x},output:e,outputBuffer:t}),{success:!0}}});var lT={};ui(lT,{arithmetic:()=>zC,dot:()=>$C,equalAll:()=>VC,extent:()=>HC,fround:()=>qC,gather:()=>XC,interleave:()=>$d,length:()=>tT,segmentedMap:()=>QC,select:()=>iT,sequence:()=>sT,swizzle:()=>aT});var Vy=C(()=>{UC();GC();WC();YC();ZC();KC();JC();eT();nT();rT();oT();cT()});var _L=KM((eye,bb)=>{"use strict";bb.exports=sh;bb.exports.default=sh;function sh(n,e,t){t=t||2;var i=e&&e.length,r=i?e[0]*t:n.length,s=pL(n,0,r,t,!0),o=[];if(!s||s.next===s.prev)return o;var a,c,l,u,f,d,h;if(i&&(s=BG(n,e,s,t)),n.length>80*t){a=l=n[0],c=u=n[1];for(var p=t;pl&&(l=f),d>u&&(u=d);h=Math.max(l-a,u-c),h=h!==0?32767/h:0}return El(s,o,t,a,c,h,0),o}function pL(n,e,t,i,r){var s,o;if(r===yb(n,e,t,i)>0)for(s=e;s=e;s-=i)o=hL(s,n[s],n[s+1],o);return o&&oh(o,o.next)&&(Pl(o),o=o.next),o}function fs(n,e){if(!n)return n;e||(e=n);var t=n,i;do if(i=!1,!t.steiner&&(oh(t,t.next)||Te(t.prev,t,t.next)===0)){if(Pl(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function El(n,e,t,i,r,s,o){if(n){!o&&s&&zG(n,i,r,s);for(var a=n,c,l;n.prev!==n.next;){if(c=n.prev,l=n.next,s?kG(n,i,r,s):AG(n)){e.push(c.i/t|0),e.push(n.i/t|0),e.push(l.i/t|0),Pl(n),n=l.next,a=l.next;continue}if(n=l,n===a){o?o===1?(n=RG(fs(n),e,t),El(n,e,t,i,r,s,2)):o===2&&IG(n,e,t,i,r,s):El(fs(n),e,t,i,r,s,1);break}}}}function AG(n){var e=n.prev,t=n,i=n.next;if(Te(e,t,i)>=0)return!1;for(var r=e.x,s=t.x,o=i.x,a=e.y,c=t.y,l=i.y,u=rs?r>o?r:o:s>o?s:o,h=a>c?a>l?a:l:c>l?c:l,p=i.next;p!==e;){if(p.x>=u&&p.x<=d&&p.y>=f&&p.y<=h&&Uo(r,a,s,c,o,l,p.x,p.y)&&Te(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function kG(n,e,t,i){var r=n.prev,s=n,o=n.next;if(Te(r,s,o)>=0)return!1;for(var a=r.x,c=s.x,l=o.x,u=r.y,f=s.y,d=o.y,h=ac?a>l?a:l:c>l?c:l,g=u>f?u>d?u:d:f>d?f:d,v=gb(h,p,e,t,i),y=gb(m,g,e,t,i),b=n.prevZ,w=n.nextZ;b&&b.z>=v&&w&&w.z<=y;){if(b.x>=h&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==o&&Uo(a,u,c,f,l,d,b.x,b.y)&&Te(b.prev,b,b.next)>=0||(b=b.prevZ,w.x>=h&&w.x<=m&&w.y>=p&&w.y<=g&&w!==r&&w!==o&&Uo(a,u,c,f,l,d,w.x,w.y)&&Te(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;b&&b.z>=v;){if(b.x>=h&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==o&&Uo(a,u,c,f,l,d,b.x,b.y)&&Te(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;w&&w.z<=y;){if(w.x>=h&&w.x<=m&&w.y>=p&&w.y<=g&&w!==r&&w!==o&&Uo(a,u,c,f,l,d,w.x,w.y)&&Te(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function RG(n,e,t){var i=n;do{var r=i.prev,s=i.next.next;!oh(r,s)&&mL(r,i,i.next,s)&&Sl(r,s)&&Sl(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),Pl(i),Pl(i.next),i=n=s),i=i.next}while(i!==n);return fs(i)}function IG(n,e,t,i,r,s){var o=n;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&GG(o,a)){var c=gL(o,a);o=fs(o,o.next),c=fs(c,c.next),El(o,e,t,i,r,s,0),El(c,e,t,i,r,s,0);return}a=a.next}o=o.next}while(o!==n)}function BG(n,e,t,i){var r=[],s,o,a,c,l;for(s=0,o=e.length;s=t.next.y&&t.next.y!==t.y){var a=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(a<=i&&a>s&&(s=a,o=t.x=t.x&&t.x>=l&&i!==t.x&&Uo(ro.x||t.x===o.x&&FG(o,t)))&&(o=t,f=d)),t=t.next;while(t!==c);return o}function FG(n,e){return Te(n.prev,n,e.prev)<0&&Te(e.next,n,n.next)<0}function zG(n,e,t,i){var r=n;do r.z===0&&(r.z=gb(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,UG(r)}function UG(n){var e,t,i,r,s,o,a,c,l=1;do{for(t=n,n=null,s=null,o=0;t;){for(o++,i=t,a=0,e=0;e0||c>0&&i;)a!==0&&(c===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,a--):(r=i,i=i.nextZ,c--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,l*=2}while(o>1);return n}function gb(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function $G(n){var e=n,t=n;do(e.x=(n-o)*(s-a)&&(n-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(i-a)}function GG(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!VG(n,e)&&(Sl(n,e)&&Sl(e,n)&&WG(n,e)&&(Te(n.prev,n,e.prev)||Te(n,e.prev,e))||oh(n,e)&&Te(n.prev,n,n.next)>0&&Te(e.prev,e,e.next)>0)}function Te(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function oh(n,e){return n.x===e.x&&n.y===e.y}function mL(n,e,t,i){var r=rh(Te(n,e,t)),s=rh(Te(n,e,i)),o=rh(Te(t,i,n)),a=rh(Te(t,i,e));return!!(r!==s&&o!==a||r===0&&ih(n,t,e)||s===0&&ih(n,i,e)||o===0&&ih(t,n,i)||a===0&&ih(t,e,i))}function ih(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function rh(n){return n>0?1:n<0?-1:0}function VG(n,e){var t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&mL(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Sl(n,e){return Te(n.prev,n,n.next)<0?Te(n,e,n.next)>=0&&Te(n,n.prev,e)>=0:Te(n,e,n.prev)<0||Te(n,n.next,e)<0}function WG(n,e){var t=n,i=!1,r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function gL(n,e){var t=new _b(n.i,n.x,n.y),i=new _b(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function hL(n,e,t,i){var r=new _b(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Pl(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function _b(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}sh.deviation=function(n,e,t,i){var r=e&&e.length,s=r?e[0]*t:n.length,o=Math.abs(yb(n,0,s,t));if(r)for(var a=0,c=e.length;a0&&(i+=n[r-1].length,t.holes.push(i))}return t}});function Di(n,e){if(!n)throw new Error(e||"loader assertion failed.")}var Mn={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},eA=Mn.self||Mn.window||Mn.global||{},tA=Mn.window||Mn.self||Mn.global||{},nA=Mn.global||Mn.self||Mn.window||{},iA=Mn.document||{};var br=!!(typeof process!="object"||String(process)!=="[object process]"||process.browser);var _v=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),rA=_v&&parseFloat(_v[1])||0;ra();var xp="4.5.4",dA=xp[0]>="0"&&xp[0]<="9"?`v${xp}`:"";function hA(){let n=new ct({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=n,globalThis.loaders.version=dA,globalThis.probe||={},globalThis.probe.loaders=n,n}var wp=hA();var pA=n=>typeof n=="boolean",kn=n=>typeof n=="function",Rn=n=>n!==null&&typeof n=="object",nu=n=>Rn(n)&&n.constructor==={}.constructor;var Ep=n=>typeof SharedArrayBuffer<"u"&&n instanceof SharedArrayBuffer,Os=n=>Rn(n)&&typeof n.byteLength=="number"&&typeof n.slice=="function";var Sp=n=>!!n&&kn(n[Symbol.iterator]),Pp=n=>!!n&&kn(n[Symbol.asyncIterator]);var Ct=n=>typeof Response<"u"&&n instanceof Response||Rn(n)&&kn(n.arrayBuffer)&&kn(n.text)&&kn(n.json);var Tt=n=>typeof Blob<"u"&&n instanceof Blob;var Iv=n=>typeof ReadableStream<"u"&&n instanceof ReadableStream||Rn(n)&&kn(n.tee)&&kn(n.cancel)&&kn(n.getReader);var Bv=n=>Rn(n)&&kn(n.read)&&kn(n.pipe)&&pA(n.readable),sa=n=>Iv(n)||Bv(n);function Cp(n,e){return Ov(n||{},e)}function Ov(n,e,t=0){if(t>3)return e;let i={...n};for(let[r,s]of Object.entries(e))s&&typeof s=="object"&&!Array.isArray(s)?i[r]=Ov(i[r]||{},e[r],t+1):i[r]=e[r];return i}var Dv="latest";function mA(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.5.4"),globalThis._loadersgl_.version}var Nv=mA();function lt(n,e){if(!n)throw new Error(e||"loaders.gl assertion failed.")}var In={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},Vj=In.self||In.window||In.global||{},Wj=In.window||In.self||In.global||{},jj=In.global||In.self||In.window||{},Hj=In.document||{};var Gt=typeof process!="object"||String(process)!=="[object process]"||process.browser;var zv=typeof window<"u"&&typeof window.orientation<"u",Fv=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),Yj=Fv&&parseFloat(Fv[1])||0;var oa=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,t){this.name=e,this.workerThread=t,this.result=new Promise((i,r)=>{this._resolve=i,this._reject=r})}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){lt(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){lt(this.isRunning),this.isRunning=!1,this._reject(e)}};var Ds=class{terminate(){}};var Tp=new Map;function Uv(n){lt(n.source&&!n.url||!n.source&&n.url);let e=Tp.get(n.source||n.url);return e||(n.url&&(e=gA(n.url),Tp.set(n.url,e)),n.source&&(e=$v(n.source),Tp.set(n.source,e))),lt(e),e}function gA(n){if(!n.startsWith("http"))return n;let e=_A(n);return $v(e)}function $v(n){let e=new Blob([n],{type:"application/javascript"});return URL.createObjectURL(e)}function _A(n){return`try { + importScripts('${n}'); +} catch (error) { + console.error(error); + throw error; +}`}function Lp(n,e=!0,t){let i=t||new Set;if(n){if(Gv(n))i.add(n);else if(Gv(n.buffer))i.add(n.buffer);else if(!ArrayBuffer.isView(n)){if(e&&typeof n=="object")for(let r in n)Lp(n[r],e,i)}}return t===void 0?Array.from(i):[]}function Gv(n){return n?n instanceof ArrayBuffer||typeof MessagePort<"u"&&n instanceof MessagePort||typeof ImageBitmap<"u"&&n instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas:!1}var Mp=()=>{},Ni=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&Gt||typeof Ds<"u"&&!Gt}constructor(e){let{name:t,source:i,url:r}=e;lt(i||r),this.name=t,this.source=i,this.url=r,this.onMessage=Mp,this.onError=s=>console.log(s),this.worker=Gt?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=Mp,this.onError=Mp,this.worker.terminate(),this.terminated=!0}get isRunning(){return!!this.onMessage}postMessage(e,t){t=t||Lp(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+=`worker ${this.name} from ${this.url}. `,e.message&&(t+=`${e.message} in `),e.lineno&&(t+=`:${e.lineno}:${e.colno}`),new Error(t)}_createBrowserWorker(){this._loadableURL=Uv({source:this.source,url:this.url});let e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=t=>{t.data?this.onMessage(t.data):this.onError(new Error("No data received"))},e.onerror=t=>{this.onError(this._getErrorFromErrorEvent(t)),this.terminated=!0},e.onmessageerror=t=>console.error(t),e}_createNodeWorker(){let e;if(this.url){let i=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`,r=this.url.endsWith(".ts")||this.url.endsWith(".mjs")?"module":"commonjs";e=new Ds(i,{eval:!1,type:r})}else if(this.source)e=new Ds(this.source,{eval:!0});else throw new Error("no worker");return e.on("message",t=>{this.onMessage(t)}),e.on("error",t=>{this.onError(t)}),e.on("exit",t=>{}),e}};var aa=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return Ni.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},e.name!==void 0&&(this.name=e.name),e.maxConcurrency!==void 0&&(this.maxConcurrency=e.maxConcurrency),e.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=e.maxMobileConcurrency),e.reuseWorkers!==void 0&&(this.reuseWorkers=e.reuseWorkers),e.onDebug!==void 0&&(this.onDebug=e.onDebug)}async startJob(e,t=(r,s,o)=>r.done(o),i=(r,s)=>r.error(s)){let r=new Promise(s=>(this.jobQueue.push({name:e,onMessage:t,onError:i,onStart:s}),this));return this._startQueuedJob(),await r}async _startQueuedJob(){if(!this.jobQueue.length)return;let e=this._getAvailableWorker();if(!e)return;let t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});let i=new oa(t.name,e);e.onMessage=r=>t.onMessage(i,r.type,r.payload),e.onError=r=>t.onError(i,r),t.onStart(i);try{await i.result}catch(r){console.error(`Worker exception: ${r}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!Gt||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count{}},wr=class n{props;workerPools=new Map;static _workerFarm;static isSupported(){return Ni.isSupported()}static getWorkerFarm(e={}){return n._workerFarm=n._workerFarm||new n({}),n._workerFarm.setProps(e),n._workerFarm}constructor(e){this.props={...yA},this.setProps(e),this.workerPools=new Map}destroy(){for(let e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(let t of this.workerPools.values())t.setProps(this._getWorkerPoolProps())}getWorkerPool(e){let{name:t,source:i,url:r}=e,s=this.workerPools.get(t);return s||(s=new aa({name:t,source:i,url:r}),s.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,s)),s}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}};function Ap(n,e={}){let t=e[n.id]||{},i=Gt?n.workerFile||`${n.id}-worker.js`:`${n.id}-worker-node.js`,r=t.workerUrl;if(!r&&n.id==="compression"&&(r=e.workerUrl),(e._workerType||e?.core?._workerType)==="test"&&(Gt?r=`modules/${n.module}/dist/${i}`:r=`modules/${n.module}/src/workers/${n.id}-worker-node.ts`),!r){let o=n.version;o==="latest"&&(o=Dv);let a=o?`@${o}`:"";r=`loaders.gl-cdn-disabled/${n.module}${a}/dist/${i}`}return lt(r),r}function kp(n,e=Nv){lt(n,"no worker provided");let t=n.version;return!(!e||!t)}function Rp(n,e){if(!wr.isSupported())return!1;let t=e?._nodeWorkers??e?.core?._nodeWorkers;if(!Gt&&!t)return!1;let i=e?.worker??e?.core?.worker;return!!(n.worker&&i)}async function Ip(n,e,t,i,r){let s=n.id,o=Ap(n,t),c=wr.getWorkerFarm(t?.core).getWorkerPool({name:s,url:o});t=JSON.parse(JSON.stringify(t||{})),t._workerLoaderId=n.id,i=JSON.parse(JSON.stringify(i||{}));let l=await c.startJob("process-on-worker",bA.bind(null,r));return l.postMessage("process",{input:e,options:t,context:i}),await(await l.result).result}async function bA(n,e,t,i){switch(t){case"done":e.done(i);break;case"error":e.error(new Error(i.error));break;case"process":let{id:r,input:s,options:o}=i;try{let a=await n(s,o);e.postMessage("done",{id:r,result:a})}catch(a){let c=a instanceof Error?a.message:"unknown error";e.postMessage("error",{id:r,error:c})}break;default:console.warn(`parse-with-worker unknown message ${t}`)}}function Bp(n,e,t){if(t=t||n.byteLength,n.byteLengths instanceof ArrayBuffer?new Uint8Array(s):s),t=e.reduce((s,o)=>s+o.byteLength,0),i=new Uint8Array(t),r=0;for(let s of e)i.set(s,r),r+=s.byteLength;return i.buffer}async function Dp(n){let e=[];for await(let t of n)e.push(vA(t));return Op(...e)}function vA(n){if(n instanceof ArrayBuffer)return n;if(ArrayBuffer.isView(n)){let{buffer:e,byteOffset:t,byteLength:i}=n;return Wv(e,t,i)}return Wv(n)}function Wv(n,e=0,t=n.byteLength-e){let i=new Uint8Array(n,e,t),r=new Uint8Array(i.length);return r.set(i),r.buffer}var xA="",Hv={};function zp(n){for(let e in Hv)if(n.startsWith(e)){let t=Hv[e];n=n.replace(e,t)}return!n.startsWith("http://")&&!n.startsWith("https://")&&(n=`${xA}${n}`),n}function ru(n){return n&&typeof n=="object"&&n.isBuffer}function Ns(n){if(ru(n))return n;if(n instanceof ArrayBuffer)return n;if(Ep(n))return iu(n);if(ArrayBuffer.isView(n)){let e=n.buffer;return n.byteOffset===0&&n.byteLength===n.buffer.byteLength?e:e.slice(n.byteOffset,n.byteOffset+n.byteLength)}if(typeof n=="string"){let e=n;return new TextEncoder().encode(e).buffer}if(n&&typeof n=="object"&&n._toArrayBuffer)return n._toArrayBuffer();throw new Error("toArrayBuffer")}function ua(n){if(n instanceof ArrayBuffer)return n;if(Ep(n))return iu(n);let{buffer:e,byteOffset:t,byteLength:i}=n;return e instanceof ArrayBuffer&&t===0&&i===e.byteLength?e:iu(e,t,i)}function iu(n,e=0,t=n.byteLength-e){let i=new Uint8Array(n,e,t),r=new Uint8Array(i.length);return r.set(i),r.buffer}function Up(n){return ArrayBuffer.isView(n)?n:new Uint8Array(n)}var fi={};ui(fi,{dirname:()=>EA,filename:()=>wA,join:()=>SA,resolve:()=>PA});function Yv(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let n=window.location?.pathname;return n?.slice(0,n.lastIndexOf("/")+1)||""}function wA(n){let e=n?n.lastIndexOf("/"):-1;return e>=0?n.substr(e+1):n}function EA(n){let e=n?n.lastIndexOf("/"):-1;return e>=0?n.substr(0,e):""}function SA(...n){let e="/";return n=n.map((t,i)=>(i&&(t=t.replace(new RegExp(`^${e}`),"")),i!==n.length-1&&(t=t.replace(new RegExp(`${e}$`),"")),t)),n.join(e)}function PA(...n){let e=[];for(let s=0;s=-1&&!i;s--){let o;s>=0?o=e[s]:(r===void 0&&(r=Yv()),o=r),o.length!==0&&(t=`${o}/${t}`,i=o.charCodeAt(0)===fa)}return t=CA(t,!i),i?`/${t}`:t.length>0?t:"."}var fa=47,$p=46;function CA(n,e){let t="",i=-1,r=0,s,o=!1;for(let a=0;a<=n.length;++a){if(a2){let c=t.length-1,l=c;for(;l>=0&&t.charCodeAt(l)!==fa;--l);if(l!==c){t=l===-1?"":t.slice(0,l),i=a,r=0,o=!1;continue}}else if(t.length===2||t.length===1){t="",i=a,r=0,o=!1;continue}}e&&(t.length>0?t+="/..":t="..",o=!0)}else{let c=n.slice(i+1,a);t.length>0?t+=`/${c}`:t=c,o=!1}i=a,r=0}else s===$p&&r!==-1?++r:r=-1}return t}var su=class extends Error{constructor(e,t){super(e),this.reason=t.reason,this.url=t.url,this.response=t.response}reason;url;response};var MA=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,AA=/^([-\w.]+\/[-\w.+]+)/;function Gp(n,e){return n.toLowerCase()===e.toLowerCase()}function qv(n){let e=AA.exec(n);return e?e[1]:n}function Vp(n){let e=MA.exec(n);return e?e[1]:""}var Zv=/\?.*/;function Xv(n){let e=n.match(Zv);return e&&e[0]}function Fi(n){return n.replace(Zv,"")}function Kv(n){if(n.length<50)return n;let e=n.slice(n.length-15);return`${n.substr(0,32)}...${e}`}function Sr(n){return Ct(n)?n.url:Tt(n)?("name"in n?n.name:"")||"":typeof n=="string"?n:""}function Fs(n){if(Ct(n)){let e=n.headers.get("content-type")||"",t=Fi(n.url);return qv(e)||Vp(t)}return Tt(n)?n.type||"":typeof n=="string"?Vp(n):""}function Qv(n){return Ct(n)?n.headers["content-length"]||-1:Tt(n)?n.size:typeof n=="string"?n.length:n instanceof ArrayBuffer||ArrayBuffer.isView(n)?n.byteLength:-1}async function ou(n){if(Ct(n))return n;let e={},t=Qv(n);t>=0&&(e["content-length"]=String(t));let i=Sr(n),r=Fs(n);r&&(e["content-type"]=r);let s=await RA(n);s&&(e["x-first-bytes"]=s),typeof n=="string"&&(n=new TextEncoder().encode(n));let o=new Response(n,{headers:e});return Object.defineProperty(o,"url",{value:i}),o}async function Jv(n){if(!n.ok)throw await kA(n)}async function kA(n){let e=Kv(n.url),t=`Failed to fetch resource (${n.status}) ${n.statusText}: ${e}`;t=t.length>100?`${t.slice(0,100)}...`:t;let i={reason:n.statusText,url:n.url,response:n};try{let r=n.headers.get("Content-Type");i.reason=!n.bodyUsed&&r?.includes("application/json")?await n.json():await n.text()}catch{}return new su(t,i)}async function RA(n){if(typeof n=="string")return`data:,${n.slice(0,5)}`;if(n instanceof Blob){let t=n.slice(0,5);return await new Promise(i=>{let r=new FileReader;r.onload=s=>i(s?.target?.result),r.readAsDataURL(t)})}if(n instanceof ArrayBuffer){let t=n.slice(0,5);return`data:base64,${IA(t)}`}return null}function IA(n){let e="",t=new Uint8Array(n);for(let i=0;i{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},cu=class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}};var lu={core:{baseUrl:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new cu,useLocalLibraries:!1,CDN:"loaders.gl-cdn-disabled",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:br,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]}},ex={baseUri:"core.baseUrl",fetch:"core.fetch",mimeType:"core.mimeType",fallbackMimeType:"core.fallbackMimeType",ignoreRegisteredLoaders:"core.ignoreRegisteredLoaders",nothrow:"core.nothrow",log:"core.log",useLocalLibraries:"core.useLocalLibraries",CDN:"core.CDN",worker:"core.worker",maxConcurrency:"core.maxConcurrency",maxMobileConcurrency:"core.maxMobileConcurrency",reuseWorkers:"core.reuseWorkers",_nodeWorkers:"core.nodeWorkers",_workerType:"core._workerType",_worker:"core._workerType",limit:"core.limit",_limitMB:"core._limitMB",batchSize:"core.batchSize",batchDebounceMs:"core.batchDebounceMs",metadata:"core.metadata",transforms:"core.transforms",throws:"nothrow",dataType:"(no longer used)",uri:"core.baseUrl",method:"core.fetch.method",headers:"core.fetch.headers",body:"core.fetch.body",mode:"core.fetch.mode",credentials:"core.fetch.credentials",cache:"core.fetch.cache",redirect:"core.fetch.redirect",referrer:"core.fetch.referrer",referrerPolicy:"core.fetch.referrerPolicy",integrity:"core.fetch.integrity",keepalive:"core.fetch.keepalive",signal:"core.fetch.signal"};var jp=["baseUrl","fetch","mimeType","fallbackMimeType","ignoreRegisteredLoaders","nothrow","log","useLocalLibraries","CDN","worker","maxConcurrency","maxMobileConcurrency","reuseWorkers","_nodeWorkers","_workerType","limit","_limitMB","batchSize","batchDebounceMs","metadata","transforms"];function Hp(){globalThis.loaders=globalThis.loaders||{};let{loaders:n}=globalThis;return n._state||(n._state={}),n._state}function Yp(){let n=Hp();return n.globalOptions=n.globalOptions||{...lu,core:{...lu.core}},di(n.globalOptions)}function ix(n,e,t,i){return t=t||[],t=Array.isArray(t)?t:[t],NA(n,t),di(zA(e,n,i))}function di(n){let e=$A(n);rx(e);for(let t of jp)e.core&&e.core[t]!==void 0&&delete e[t];return e.core&&e.core._workerType!==void 0&&delete e._worker,e}function NA(n,e){tx(n,null,lu,ex,e);for(let t of e){let i=n&&n[t.id]||{},r=t.options&&t.options[t.id]||{},s=t.deprecatedOptions&&t.deprecatedOptions[t.id]||{};tx(i,t.id,r,s,e)}}function tx(n,e,t,i,r){let s=e||"Top level",o=e?`${e}.`:"";for(let a in n){let c=!e&&Rn(n[a]),l=a==="baseUri"&&!e,u=a==="workerUrl"&&e;if(!(a in t)&&!l&&!u){if(a in i)da.level>0&&da.warn(`${s} loader option '${o}${a}' no longer supported, use '${i[a]}'`)();else if(!c&&da.level>0){let f=FA(a,r);da.warn(`${s} loader option '${o}${a}' not recognized. ${f}`)()}}}}function FA(n,e){let t=n.toLowerCase(),i="";for(let r of e)for(let s in r.options){if(n===s)return`Did you mean '${r.id}.${s}'?`;let o=s.toLowerCase();(t.startsWith(o)||o.startsWith(t))&&(i=i||`Did you mean '${r.id}.${s}'?`)}return i}function zA(n,e,t){let i=n.options||{},r={...i};i.core&&(r.core={...i.core}),rx(r),r.core?.log===null&&(r.core={...r.core,log:new au}),nx(r,di(Yp()));let s=di(e);return nx(r,s),UA(r,t),GA(r),r}function nx(n,e){for(let t in e)if(t in e){let i=e[t];nu(i)&&nu(n[t])?n[t]={...n[t],...e[t]}:n[t]=e[t]}}function UA(n,e){if(!e)return;n.core?.baseUrl!==void 0||(n.core||={},n.core.baseUrl=fi.dirname(Fi(e)))}function $A(n){let e={...n};return n.core&&(e.core={...n.core}),e}function rx(n){n.baseUri!==void 0&&(n.core||={},n.core.baseUrl===void 0&&(n.core.baseUrl=n.baseUri));for(let t of jp)if(n[t]!==void 0){let r=n.core=n.core||{};r[t]===void 0&&(r[t]=n[t])}let e=n._worker;e!==void 0&&(n.core||={},n.core._workerType===void 0&&(n.core._workerType=e))}function GA(n){let e=n.core;if(e)for(let t of jp)e[t]!==void 0&&(n[t]=e[t])}function ha(n){return n?(Array.isArray(n)&&(n=n[0]),Array.isArray(n?.extensions)):!1}function pa(n){Di(n,"null loader"),Di(ha(n),"invalid loader");let e;return Array.isArray(n)&&(e=n[1],n=n[0],n={...n,options:{...n.options,...e}}),(n?.parseTextSync||n?.parseText)&&(n.text=!0),n.text||(n.binary=!0),n}var sx=()=>{let n=Hp();return n.loaderRegistry=n.loaderRegistry||[],n.loaderRegistry};function qp(n){let e=sx();n=Array.isArray(n)?n:[n];for(let t of n){let i=pa(t);e.find(r=>i===r)||e.unshift(i)}}function ox(){return sx()}var VA=/\.([^.]+)$/;async function lx(n,e=[],t,i){if(!ux(n))return null;let r=di(t||{});if(r.core||={},n instanceof Response&&ax(n)){let o=await n.clone().text(),a=uu(o,e,{...r,core:{...r.core,nothrow:!0}},i);if(a)return a}let s=uu(n,e,{...r,core:{...r.core,nothrow:!0}},i);if(s)return s;if(Tt(n)&&(n=await n.slice(0,10).arrayBuffer(),s=uu(n,e,r,i)),!s&&n instanceof Response&&ax(n)){let o=await n.clone().text();s=uu(o,e,r,i)}if(!s&&!r.core.nothrow)throw new Error(fx(n));return s}function ax(n){let e=Fs(n);return!!(e&&(e.startsWith("text/")||e==="application/json"||e.endsWith("+json")))}function uu(n,e=[],t,i){if(!ux(n))return null;let r=di(t||{});if(r.core||={},e&&!Array.isArray(e))return pa(e);let s=[];e&&(s=s.concat(e)),r.core.ignoreRegisteredLoaders||s.push(...ox()),jA(s);let o=WA(n,s,r,i);if(!o&&!r.core.nothrow)throw new Error(fx(n));return o}function WA(n,e,t,i){let r=Sr(n),s=Fs(n),o=Fi(r)||i?.url,a=null,c="";return t?.core?.mimeType&&(a=Zp(e,t?.core?.mimeType),c=`match forced by supplied MIME type ${t?.core?.mimeType}`),a=a||HA(e,o),c=c||(a?`matched url ${o}`:""),a=a||Zp(e,s),c=c||(a?`matched MIME type ${s}`:""),a=a||qA(e,n),c=c||(a?`matched initial data ${dx(n)}`:""),t?.core?.fallbackMimeType&&(a=a||Zp(e,t?.core?.fallbackMimeType),c=c||(a?`matched fallback MIME type ${s}`:"")),c&&wp.log(1,`selectLoader selected ${a?.name}: ${c}.`),a}function ux(n){return!(n instanceof Response&&n.status===204)}function fx(n){let e=Sr(n),t=Fs(n),i="No valid loader found (";i+=e?`${fi.filename(e)}, `:"no url provided, ",i+=`MIME type: ${t?`"${t}"`:"not provided"}, `;let r=n?dx(n):"";return i+=r?` first bytes: "${r}"`:"first bytes: not available",i+=")",i}function jA(n){for(let e of n)pa(e)}function HA(n,e){let t=e&&VA.exec(e),i=t&&t[1];return i?YA(n,i):null}function YA(n,e){e=e.toLowerCase();for(let t of n)for(let i of t.extensions)if(i.toLowerCase()===e)return t;return null}function Zp(n,e){for(let t of n)if(t.mimeTypes?.some(i=>Gp(e,i))||Gp(e,`application/x.${t.id}`))return t;return null}function qA(n,e){if(!e)return null;for(let t of n)if(typeof e=="string"){if(ZA(e,t))return t}else if(ArrayBuffer.isView(e)){if(cx(e.buffer,e.byteOffset,t))return t}else if(e instanceof ArrayBuffer&&cx(e,0,t))return t;return null}function ZA(n,e){return e.testText?e.testText(n):(Array.isArray(e.tests)?e.tests:[e.tests]).some(i=>n.startsWith(i))}function cx(n,e,t){return(Array.isArray(t.tests)?t.tests:[t.tests]).some(r=>XA(n,e,t,r))}function XA(n,e,t,i){if(Os(i))return Bp(i,n,i.byteLength);switch(typeof i){case"function":return i(ua(n));case"string":let r=Xp(n,e,i.length);return i===r;default:return!1}}function dx(n,e=5){return typeof n=="string"?n.slice(0,e):ArrayBuffer.isView(n)?Xp(n.buffer,n.byteOffset,e):n instanceof ArrayBuffer?Xp(n,0,e):""}function Xp(n,e,t){if(n.byteLengthWp(s,r):e?.fetch?e?.fetch:Wp}function bx(n,e,t){if(t)return t;let i={fetch:fu(e,n),...n};if(i.url){let r=Fi(i.url);i.baseUrl=r,i.queryString=Xv(i.url),i.filename=fi.filename(r),i.baseUrl=fi.dirname(r)}return Array.isArray(i.loaders)||(i.loaders=null),i}function vx(n,e){if(n&&!Array.isArray(n))return n;let t;if(n&&(t=Array.isArray(n)?n:[n]),e&&e.loaders){let i=Array.isArray(e.loaders)?e.loaders:[e.loaders];t=t?[...t,...i]:i}return t&&t.length?t:void 0}async function ma(n,e,t,i){e&&!Array.isArray(e)&&!ha(e)&&(i=void 0,t=e,e=void 0),n=await n,t=t||{};let r=Sr(n),o=vx(e,i),a=await lx(n,o,t);if(!a)return null;let c=ix(t,a,o,r);return i=bx({url:r,_parse:ma,loaders:o},c,i||null),await tk(a,n,c,i)}async function tk(n,e,t,i){if(kp(n),t=Cp(n.options,t),Ct(e)){let{ok:s,redirected:o,status:a,statusText:c,type:l,url:u}=e,f=Object.fromEntries(e.headers.entries());i.response={headers:f,ok:s,redirected:o,status:a,statusText:c,type:l,url:u}}e=await yx(e,n,t);let r=n;if(r.parseTextSync&&typeof e=="string")return r.parseTextSync(e,t,i);if(Rp(n,t))return await Ip(n,e,t,i,ma);if(r.parseText&&typeof e=="string")return await r.parseText(e,t,i);if(r.parse)return await r.parse(e,t,i);throw lt(!r.parseSync),new Error(`${n.id} loader - no parser found and worker is disabled`)}async function zs(n,e,t,i){let r,s;!Array.isArray(e)&&!ha(e)?(r=[],s=e,i=void 0):(r=e,s=t);let o=fu(s),a=n;return typeof n=="string"&&(a=await o(n)),Tt(n)&&(a=await o(n)),typeof n=="string"&&(di(s||{}).core?.baseUrl||(s={...s,core:{...s?.core,baseUrl:n}})),Array.isArray(r)?await ma(a,r,s):await ma(a,r,s)}var Sx="4.5.4";var nk=globalThis.loaders?.parseImageNode,Jp=typeof Image<"u",em=typeof ImageBitmap<"u",ik=!!nk,tm=br?!0:ik;function Px(n){switch(n){case"auto":return em||Jp||tm;case"imagebitmap":return em;case"image":return Jp;case"data":return tm;default:throw new Error(`@loaders.gl/images: image ${n} not supported in this environment`)}}function Cx(){if(em)return"imagebitmap";if(Jp)return"image";if(tm)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function rk(n){let e=sk(n);if(!e)throw new Error("Not an image");return e}function Tx(n){switch(rk(n)){case"data":return n;case"image":case"imagebitmap":let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)throw new Error("getImageData");return e.width=n.width,e.height=n.height,t.drawImage(n,0,0),t.getImageData(0,0,n.width,n.height);default:throw new Error("getImageData")}}function sk(n){return typeof ImageBitmap<"u"&&n instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&n instanceof Image?"image":n&&typeof n=="object"&&n.data&&n.width&&n.height?"data":null}var ok=/^data:image\/svg\+xml/,ak=/\.svg((\?|#).*)?$/;function du(n){return n&&(ok.test(n)||ak.test(n))}function Lx(n,e){if(du(e)){let i=new TextDecoder().decode(n);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(i=unescape(encodeURIComponent(i)))}catch(s){throw new Error(s.message)}return`data:image/svg+xml;base64,${btoa(i)}`}return nm(n,e)}function nm(n,e){if(du(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(n)])}async function hu(n,e,t){let i=Lx(n,t),r=self.URL||self.webkitURL,s=typeof i!="string"&&r.createObjectURL(i);try{return await ck(s||i,e)}finally{s&&r.revokeObjectURL(s)}}async function ck(n,e){let t=new Image;return t.src=n,e.image&&e.image.decode&&t.decode?(await t.decode(),t):await new Promise((i,r)=>{try{t.onload=()=>i(t),t.onerror=s=>{let o=s instanceof Error?s.message:"error";r(new Error(o))}}catch(s){r(s)}})}var Mx=!0;async function Ax(n,e,t){let i;du(t)?i=await hu(n,e,t):i=nm(n,t);let r=e&&e.imagebitmap;return await lk(i,r)}async function lk(n,e=null){if((uk(e)||!Mx)&&(e=null),e)try{return await createImageBitmap(n,e)}catch(t){console.warn(t),Mx=!1}return await createImageBitmap(n)}function uk(n){if(!n)return!0;for(let e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}function kx(n){return!pk(n,"ftyp",4)||!(n[8]&96)?null:fk(n)}function fk(n){switch(dk(n,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function dk(n,e,t){return String.fromCharCode(...n.slice(e,t))}function hk(n){return[...n].map(e=>e.charCodeAt(0))}function pk(n,e,t=0){let i=hk(e);for(let r=0;r=24&&e.getUint32(0,Bn)===2303741511?{mimeType:"image/png",width:e.getUint32(16,Bn),height:e.getUint32(20,Bn)}:null}function _k(n){let e=ya(n);return e.byteLength>=10&&e.getUint32(0,Bn)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,_a),height:e.getUint16(8,_a)}:null}function yk(n){let e=ya(n);return e.byteLength>=14&&e.getUint16(0,Bn)===16973&&e.getUint32(2,_a)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,_a),height:e.getUint32(22,_a)}:null}function bk(n){let e=ya(n);if(!(e.byteLength>=3&&e.getUint16(0,Bn)===65496&&e.getUint8(2)===255))return null;let{tableMarkers:i,sofMarkers:r}=vk(),s=2;for(;s+9!!pu(new DataView(n))],options:Sk};ra();var Pk=new ct({id:"deck"}),ae=Pk;var rm={};function Bx(n){rm=n}function De(n,e,t,i){ae.level>0&&rm[n]&&rm[n].call(null,e,t,i)}function Ck(n){let e=n[0],t=n[n.length-1];return e==="{"&&t==="}"||e==="["&&t==="]"}var Ox={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:Ck,parseTextSync:JSON.parse};function Tk(){let n="9.4.0",e=globalThis.deck&&globalThis.deck.VERSION;if(e&&e!==n)throw new Error(`deck.gl - multiple versions detected: ${e} vs ${n}`);return e||(ae.log(1,`deck.gl ${n}`)(),globalThis.deck={...globalThis.deck,VERSION:n,version:n,log:ae,_registerLoggers:Bx},qp([Ox,[im,{imagebitmap:{premultiplyAlpha:"none"}}]])),n}var Dx=Tk();bt();var S4=`struct LayerUniforms { + opacity: f32, +}; + +@group(0) @binding(auto) +var layer: LayerUniforms; +`,bS=`layout(std140) uniform layerUniforms { + uniform float opacity; +} layer; +`,r_={name:"layer",source:S4,vs:bS,fs:bS,getUniforms:n=>({opacity:Math.pow(n.opacity,.45454545454545453)}),uniformTypes:{opacity:"f32"}};var P4=` + +@must_use +fn deckgl_premultiplied_alpha(fragColor: vec4) -> vec4 { + return vec4(fragColor.rgb * fragColor.a, fragColor.a); +}; +`,zn={name:"color",dependencies:[],source:P4,getUniforms:n=>({})};var C4=`const SMOOTH_EDGE_RADIUS: f32 = 0.5; + +struct VertexGeometry { + position: vec4, + worldPosition: vec3, + worldPositionAlt: vec3, + normal: vec3, + uv: vec2, + pickingColor: vec3, +}; + +var geometry_: VertexGeometry = VertexGeometry( + vec4(0.0, 0.0, 1.0, 0.0), + vec3(0.0, 0.0, 0.0), + vec3(0.0, 0.0, 0.0), + vec3(0.0, 0.0, 0.0), + vec2(0.0, 0.0), + vec3(0.0, 0.0, 0.0) +); + +struct FragmentGeometry { + uv: vec2, +}; + +var fragmentGeometry: FragmentGeometry; + +fn smoothedge(edge: f32, x: f32) -> f32 { + return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x); +} +`,vS="#define SMOOTH_EDGE_RADIUS 0.5",T4=`${vS} + +struct VertexGeometry { + vec4 position; + vec3 worldPosition; + vec3 worldPositionAlt; + vec3 normal; + vec2 uv; + vec3 pickingColor; +} geometry = VertexGeometry( + vec4(0.0, 0.0, 1.0, 0.0), + vec3(0.0), + vec3(0.0), + vec3(0.0), + vec2(0.0), + vec3(0.0) +); +`,L4=`${vS} + +struct FragmentGeometry { + vec2 uv; +}; +FragmentGeometry geometry; + +float smoothedge(float edge, float x) { + return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x); +} +`,uf={name:"geometry",source:C4,vs:T4,fs:L4};bt();Fe();var ne;(function(n){n[n.Start=1]="Start",n[n.Move=2]="Move",n[n.End=4]="End",n[n.Cancel=8]="Cancel"})(ne||(ne={}));var Pe;(function(n){n[n.None=0]="None",n[n.Left=1]="Left",n[n.Right=2]="Right",n[n.Up=4]="Up",n[n.Down=8]="Down",n[n.Horizontal=3]="Horizontal",n[n.Vertical=12]="Vertical",n[n.All=15]="All"})(Pe||(Pe={}));var j;(function(n){n[n.Possible=1]="Possible",n[n.Began=2]="Began",n[n.Changed=4]="Changed",n[n.Ended=8]="Ended",n[n.Recognized=8]="Recognized",n[n.Cancelled=16]="Cancelled",n[n.Failed=32]="Failed"})(j||(j={}));var xS="compute",s_="auto",jr="manipulation",Hr="none",Ka="pan-x",Qa="pan-y";function o_(n){if(n.includes(Hr))return Hr;let e=n.includes(Ka),t=n.includes(Qa);return e&&t?Hr:e||t?e?Ka:Qa:n.includes(jr)?jr:s_}var Ja=class{constructor(e,t){this.actions="",this.manager=e,this.set(t)}set(e){e===xS&&(e=this.compute()),this.manager.element&&(this.manager.element.style.touchAction=e,this.actions=e)}update(){this.set(this.manager.options.touchAction)}compute(){let e=[];for(let t of this.manager.recognizers)t.options.enable&&(e=e.concat(t.getTouchAction()));return o_(e.join(" "))}};function to(n){return n.trim().split(/\s+/g)}function ff(n,e,t){if(n)for(let i of to(e))n.addEventListener(i,t,!1)}function df(n,e,t){if(n)for(let i of to(e))n.removeEventListener(i,t,!1)}function a_(n){return(n.ownerDocument||n).defaultView}function c_(n,e){let t=n;for(;t;){if(t===e)return!0;t=t.parentNode}return!1}function hf(n){let e=n.length;if(e===1)return{x:Math.round(n[0].clientX),y:Math.round(n[0].clientY)};let t=0,i=0,r=0;for(;r=Math.abs(e)?n<0?Pe.Left:Pe.Right:e<0?Pe.Up:Pe.Down}function ES(n,e){let t=e.center,i=n.offsetDelta,r=n.prevDelta,s=n.prevInput;return(e.eventType===ne.Start||s?.eventType===ne.End)&&(r=n.prevDelta={x:s?.deltaX||0,y:s?.deltaY||0},i=n.offsetDelta={x:t.x,y:t.y}),{deltaX:r.x+(t.x-i.x),deltaY:r.y+(t.y-i.y)}}function pf(n,e,t){return{x:e/n||0,y:t/n||0}}function SS(n,e){return ec(e[0],e[1])/ec(n[0],n[1])}function PS(n,e){return u_(e[1],e[0])-u_(n[1],n[0])}function CS(n,e){let t=n.lastInterval||e,i=e.timeStamp-t.timeStamp,r,s,o,a;if(e.eventType!==ne.Cancel&&(i>25||t.velocity===void 0)){let c=e.deltaX-t.deltaX,l=e.deltaY-t.deltaY,u=pf(i,c,l);s=u.x,o=u.y,r=Math.abs(u.x)>Math.abs(u.y)?u.x:u.y,a=io(c,l),n.lastInterval=e}else r=t.velocity,s=t.velocityX,o=t.velocityY,a=t.direction;e.velocity=r,e.velocityX=s,e.velocityY=o,e.direction=a}function f_(n,e){return"pointerId"in n?n.pointerId:e}function TS(n,e){n.movementOrigin=new Map(e.map((t,i)=>[f_(t,i),{clientX:t.clientX,clientY:t.clientY}])),n.firstMovementTime=void 0}function A4(n,e){let t=e.pointers.map(f_);if(n.movementOrigin?.size===t.length&&t.every(r=>n.movementOrigin.has(r))||TS(n,e.pointers),e.distancePerPointer=e.pointers.map((r,s)=>ec(n.movementOrigin.get(t[s]),r)),e.eventType&ne.Move&&e.distancePerPointer.some(r=>r>0)&&(n.firstMovementTime??(n.firstMovementTime=e.timeStamp)),e.movementDeltaTime=n.firstMovementTime===void 0?0:e.timeStamp-n.firstMovementTime,e.eventType&(ne.End|ne.Cancel)){let r=e.changedPointers.map(s=>f_(s,e.pointers.indexOf(s)));TS(n,e.pointers.filter((s,o)=>!r.includes(t[o])))}}function LS(n,e){let{session:t}=n,{pointers:i}=e,{length:r}=i;t.firstInput||(t.firstInput=l_(e)),r>1&&!t.firstMultiple?t.firstMultiple=l_(e):r===1&&(t.firstMultiple=!1);let{firstInput:s,firstMultiple:o}=t,a=o?o.center:s.center,c=e.center=hf(i);e.timeStamp=Date.now(),e.deltaTime=e.timeStamp-s.timeStamp,A4(t,e),e.angle=wS(a,c),e.distance=no(a,c);let{deltaX:l,deltaY:u}=ES(t,e);e.deltaX=l,e.deltaY=u,e.offsetDirection=io(e.deltaX,e.deltaY);let f=pf(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=f.x,e.overallVelocityY=f.y,e.overallVelocity=Math.abs(f.x)>Math.abs(f.y)?f.x:f.y,e.scale=o?SS(o.pointers,i):1,e.rotation=o?PS(o.pointers,i):0,e.maxPointers=t.prevInput?e.pointers.length>t.prevInput.maxPointers?e.pointers.length:t.prevInput.maxPointers:e.pointers.length;let d=n.element;return c_(e.srcEvent.target,d)&&(d=e.srcEvent.target),e.target=d,CS(t,e),e}function MS(n,e,t){let i=t.pointers.length,r=t.changedPointers.length,s=e&ne.Start&&i-r===0,o=e&(ne.End|ne.Cancel)&&i-r===0;t.isFirst=!!s,t.isFinal=!!o,s&&(n.session={}),t.eventType=e;let a=LS(n,t);n.emit("hammer.input",a),n.recognize(a),n.session.prevInput=a}var tc=class{constructor(e){this.evEl="",this.evWin="",this.evTarget="",this.domHandler=t=>{this.manager.options.enable&&this.handler(t)},this.manager=e,this.element=e.element,this.target=e.options.inputTarget||e.element}callback(e,t){MS(this.manager,e,t)}init(){ff(this.element,this.evEl,this.domHandler),ff(this.target,this.evTarget,this.domHandler),ff(a_(this.element),this.evWin,this.domHandler)}destroy(){df(this.element,this.evEl,this.domHandler),df(this.target,this.evTarget,this.domHandler),df(a_(this.element),this.evWin,this.domHandler)}};var k4={pointerdown:ne.Start,pointermove:ne.Move,pointerup:ne.End,pointercancel:ne.Cancel,pointerout:ne.Cancel},R4="pointerdown",I4="pointermove pointerup pointercancel",nc=class extends tc{constructor(e){super(e),this.evEl=R4,this.evWin=I4,this.store=this.manager.session.pointerEvents=[],this.init()}handler(e){let{store:t}=this,i=!1,r=k4[e.type],s=e.pointerType,o=s==="touch",a=t.findIndex(c=>c.pointerId===e.pointerId);r&ne.Start&&(e.buttons||o)?a<0&&(t.push(e),a=t.length-1):r&(ne.End|ne.Cancel)&&(i=!0),!(a<0)&&(t[a]=e,this.callback(r,{pointers:t,changedPointers:[e],eventType:r,pointerType:s,srcEvent:e}),i&&t.splice(a,1))}};var B4=["","webkit","Moz","MS","ms","o"];function AS(n,e){let t=e[0].toUpperCase()+e.slice(1);for(let i of B4){let r=i?i+t:e;if(r in n)return r}}var O4=1,kS=2,RS={touchAction:"compute",enable:!0,inputTarget:null,cssProps:{userSelect:"none",userDrag:"none",touchCallout:"none",tapHighlightColor:"rgba(0,0,0,0)"}},ic=class{constructor(e,t){this.options={...RS,...t,cssProps:{...RS.cssProps,...t.cssProps},inputTarget:t.inputTarget||e},this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=new nc(this),this.touchAction=new Ja(this,this.options.touchAction),this.toggleCssProps(!0)}set(e){return Object.assign(this.options,e),e.touchAction&&this.touchAction.update(),e.inputTarget&&(this.input.destroy(),this.input.target=e.inputTarget,this.input.init()),this}stop(e){this.session.stopped=e?kS:O4}recognize(e){let{session:t}=this;if(t.stopped)return;this.session.prevented&&e.srcEvent.preventDefault();let i,{recognizers:r}=this,{curRecognizer:s}=t;(!s||s&&s.state&j.Recognized)&&(s=t.curRecognizer=null);let o=0;for(;o-1&&this.requireFail.splice(i,1)}return this}hasRequireFailures(){return!!this.requireFail.find(e=>e.options.enable)}canRecognizeWith(e){return!!this.simultaneous[e.id]}emit(e){if(!e)return;let{state:t}=this;t=j.Ended&&this.manager.emit(this.options.event+d_(t),e)}tryEmit(e){this.canEmit()?this.emit(e):this.state=j.Failed}canEmit(){let e=0;for(;e=e.distance)&&(e.distancePerPointer===void 0||n.distancePerPointer.length>0&&n.distancePerPointer.every(t=>t>=e.distancePerPointer))&&(e.movementDeltaTime===void 0||n.movementDeltaTime>=e.movementDeltaTime)&&(e.rotation===void 0||N4(n.rotation)>=e.rotation)&&(e.scale===void 0||Math.abs(n.scale-1)>=e.scale)}var Yr=class extends ln{attrTest(e){let t=this.options.pointers;return t===0||e.pointers.length===t}coherentTest(e){let t=this.options.coherent;return!t?.length||t.some(i=>F4(e,i))}process(e){let{state:t}=this,{eventType:i}=e,r=t&(j.Began|j.Changed),s=this.attrTest(e);return r&&(i&ne.Cancel||!s)?t|j.Cancelled:r||s?i&ne.End?t|j.Ended:t&j.Began?t|j.Changed:j.Began:j.Failed}};var z4=["","start","move","end","cancel"],ro=class extends ln{constructor(e={}){super({enable:!0,event:"doubleclickdrag",pointers:1,interval:500,time:350,threshold:28,dragThreshold:1,pixelsPerScale:120,...e}),this._tapStart=null,this._lastTap=null,this._drag=null,this._emittedStart=!1}getTouchAction(){return[jr]}getEventNames(){return z4.map(e=>this.options.event+e)}process(e){let{options:t}=this;return e.pointers.length===t.pointers?e.eventType&ne.Start?this._handleStart(e):e.eventType&ne.Move?this._handleMove(e):e.eventType&ne.Cancel?this._handleEnd(e,!0):e.eventType&ne.End?this._handleEnd(e,!1):j.Failed:(this.reset(),j.Failed)}reset(){this._tapStart=null,this._lastTap=null,this._drag=null,this._emittedStart=!1}emit(e){if(e){if(this.state===j.Began){if(!this._drag?.active||this._emittedStart)return;this._emittedStart=!0,this.manager.emit(`${this.options.event}start`,e),this.manager.emit(this.options.event,e);return}if(this.state===j.Changed){if(!this._emittedStart)return;this.manager.emit(`${this.options.event}move`,e),this.manager.emit(this.options.event,e);return}if(this.state===j.Ended){if(!this._emittedStart)return;this.manager.emit(this.options.event,e),this.manager.emit(`${this.options.event}end`,e),this._emittedStart=!1;return}if(this.state===j.Cancelled){if(!this._emittedStart)return;this.manager.emit(this.options.event,e),this.manager.emit(`${this.options.event}cancel`,e),this._emittedStart=!1}}}_handleStart(e){let t=this._getPointerId(e);return this._lastTap&&this._isTapMatch(e,this._lastTap)?(this._tapStart=null,this._lastTap=null,this._drag={startCenter:e.center,pointerId:t,active:!1},this._emittedStart=!1,j.Began):(this._tapStart={center:e.center,timeStamp:e.timeStamp,pointerId:t},this._lastTap=null,this._drag=null,this._emittedStart=!1,j.Failed)}_handleMove(e){if(!this._drag||!this._isSamePointer(e,this._drag.pointerId))return j.Failed;let t=this._drag.startCenter.y-e.center.y;return!this._drag.active&&Math.abs(t){this.state=j.Recognized,this.tryEmit(this._input)},t.interval),j.Began):j.Recognized}return j.Failed}failTimeout(){return this._timer=setTimeout(()=>{this.state=j.Failed},this.options.interval),j.Failed}reset(){clearTimeout(this._timer)}emit(e){this.state===j.Recognized&&(e.tapCount=this.count,this.manager.emit(this.options.event,e))}};var so=class extends Yr{constructor(){super(...arguments),this.wheelSession=null,this.wheelSessionUnsubscribe=null,this.handleWheelSessionEvent=e=>{e.device==="trackpad"&&this.handleTrackpadEvent(e)}}set(e){let{wheelSession:t,...i}=e;return t&&t!==this.wheelSession&&(this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=null,this.wheelSession=t),super.set(i),this.updateWheelSessionSubscription(),this}getTrackpadInput(e,t={}){let{srcEvent:i}=e,r=t.deltaX??e.deltaX,s=t.deltaY??e.deltaY,o=io(r,s),a=Math.sqrt(e.deltaX*e.deltaX+e.deltaY*e.deltaY),c=i;return{pointers:[c,c],changedPointers:[c,c],pointerType:"trackpad",srcEvent:c,eventType:e.eventType,timeStamp:e.timeStamp,deltaTime:e.deltaTime,center:e.center,deltaX:r,deltaY:s,angle:Math.atan2(s,r)*180/Math.PI,distance:Math.sqrt(r*r+s*s),distancePerPointer:[a,a],movementDeltaTime:e.deltaTime,scale:1,rotation:0,direction:o,offsetDirection:o,velocity:e.velocity,velocityX:e.velocityX,velocityY:e.velocityY,overallVelocity:e.overallVelocity,overallVelocityX:e.overallVelocityX,overallVelocityY:e.overallVelocityY,maxPointers:2,target:i.target||this.manager.element,additionalEvent:"",...t}}updateWheelSessionSubscription(){let e=!!(this.wheelSession&&this.options.enable&&this.options.trackpad&&this.options.pointers===2);e&&!this.wheelSessionUnsubscribe?this.wheelSessionUnsubscribe=this.wheelSession.on(this.handleWheelSessionEvent):!e&&this.wheelSessionUnsubscribe&&(this.wheelSessionUnsubscribe(),this.wheelSessionUnsubscribe=null)}};var U4=["","start","move","end","cancel","up","down","left","right"],qi=class extends so{constructor(e={}){super({enable:!0,pointers:1,event:"pan",threshold:10,direction:Pe.All,trackpad:!1,coherent:[],...e}),this.trackpadGesture=!1,this.pX=null,this.pY=null}getTouchAction(){let{options:{direction:e}}=this,t=[];return e&Pe.Horizontal&&t.push(Qa),e&Pe.Vertical&&t.push(Ka),t}getEventNames(){return U4.map(e=>this.options.event+e)}directionTest(e){let{options:t}=this,i=!0,{distance:r}=e,{direction:s}=e,o=e.deltaX,a=e.deltaY;return s&t.direction||(t.direction&Pe.Horizontal?(s=o===0?Pe.None:o<0?Pe.Left:Pe.Right,i=o!==this.pX,r=Math.abs(e.deltaX)):(s=a===0?Pe.None:a<0?Pe.Up:Pe.Down,i=a!==this.pY,r=Math.abs(e.deltaY))),e.direction=s,i&&r>t.threshold&&!!(s&t.direction)}attrTest(e){let t=!!(this.state&j.Began),i=!(this.options.coherent?.length&&e.eventType&(ne.End|ne.Cancel));return super.attrTest(e)&&(t||i&&this.coherentTest(e)&&this.directionTest(e))}emit(e){this.pX=e.deltaX,this.pY=e.deltaY;let t=Pe[e.direction].toLowerCase();t&&(e.additionalEvent=this.options.event+t),super.emit(e)}handleTrackpadEvent(e){e.isFirst&&(this.trackpadGesture=!e.srcEvent.ctrlKey,!this.trackpadGesture&&this.state&(j.Recognized|j.Cancelled|j.Failed)&&(this.state=j.Possible)),this.trackpadGesture&&(this.recognize(this.getTrackpadInput(e,{deltaX:-e.deltaX,deltaY:-e.deltaY,velocity:-e.velocity,velocityX:-e.velocityX,velocityY:-e.velocityY,overallVelocity:-e.overallVelocity,overallVelocityX:-e.overallVelocityX,overallVelocityY:-e.overallVelocityY})),e.isFinal&&(this.trackpadGesture=!1))}};var $4=["","start","move","end","cancel","in","out"],oo=class extends so{constructor(e={}){super({enable:!0,event:"pinch",threshold:0,pointers:2,trackpad:!1,coherent:[],...e}),this.trackpadGesture=!1}getTouchAction(){return[Hr]}getEventNames(){return $4.map(e=>this.options.event+e)}attrTest(e){let t=!!this.options.coherent?.length,i=!!(this.state&j.Began),r=!(t&&e.eventType&(ne.End|ne.Cancel));return super.attrTest(e)&&(i||r&&(t?this.coherentTest(e):Math.abs(e.scale-1)>this.options.threshold))}emit(e){if(e.scale!==1){let t=e.scale<1?"in":"out";e.additionalEvent=this.options.event+t}super.emit(e)}handleTrackpadEvent(e){e.isFirst&&(this.trackpadGesture=e.srcEvent.ctrlKey,!this.trackpadGesture&&this.state&(j.Recognized|j.Cancelled|j.Failed)&&(this.state=j.Possible)),this.trackpadGesture&&(this.recognize(this.getTrackpadInput(e,{deltaX:0,deltaY:0,velocity:0,velocityX:0,velocityY:0,overallVelocity:0,overallVelocityX:0,overallVelocityY:0,scale:Math.exp(-e.deltaY/100)})),e.isFinal&&(this.trackpadGesture=!1))}};var Un=class{constructor(e,t,i){this.element=e,this.callback=t,this.options=i}listen(e,t){t?this.element.addEventListener(e,this.handleEvent,{passive:!1}):this.element.removeEventListener(e,this.handleEvent)}};var BS=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"";var j4=BS.indexOf("firefox")!==-1,H4=40,Y4=.25,mf=class extends Un{constructor(e,t,i){i.enable=i.enable??!1,super(e,t,i),this.handleEvent=r=>{if(!this.options.enable)return;let s=r.deltaY;globalThis.WheelEvent&&(j4&&r.deltaMode===globalThis.WheelEvent.DOM_DELTA_PIXEL&&(s/=globalThis.devicePixelRatio),r.deltaMode===globalThis.WheelEvent.DOM_DELTA_LINE&&(s*=H4)),r.shiftKey&&s&&(s=s*Y4),this.callback({type:"wheel",center:{x:r.clientX,y:r.clientY},delta:-s,device:this.options.wheelSession?.device??"unknown",srcEvent:r,pointerType:"mouse",target:r.target})},i.enable&&(this.wheelSessionUnsubscribe=this.options.wheelSession?.on(()=>{}),this.listen("wheel",!0))}destroy(){this.listen("wheel",!1),this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=void 0}enableEventType(e,t){e==="wheel"&&this.options.enable!==t&&(this.options.enable=t,t&&!this.wheelSessionUnsubscribe&&(this.wheelSessionUnsubscribe=this.options.wheelSession?.on(()=>{})),this.listen("wheel",t),t||(this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=void 0))}};var q4=4.000244140625,OS=40,Z4=0,X4=1,K4=40,DS=40,Q4=120,J4={classificationDelay:32,endDelay:80},gf=class{constructor(e,t={}){this.subscriptions=new Map,this.session=null,this.classificationTimer=null,this.endTimer=null,this.pressedControlKeys=new Set,this.listeningForControlKeys=!1,this.handleEvent=i=>{if(!this.hasSubscribers)return"unknown";let r=tN(i,this.pressedControlKeys.size>0),s=this.session;if(s&&r.timeStamp-s.lastTimeStamp>=this.options.endDelay){if(this.end(),!this.hasSubscribers)return"unknown";s=null}s?(this.scheduleEnd(),this.addSample(s,r)):(s=this.startPendingSession(r),this.scheduleEnd());let{device:o}=s;return o==="unknown"&&(o=h_(s.samples,!1),o!=="unknown"&&this.begin(s,o)),o},this.finishClassification=()=>{if(this.classificationTimer=null,!this.session||this.session.device!=="unknown")return;let i=this.session,r=h_(i.samples,!0);this.begin(i,r==="unknown"?"mouse":r)},this.end=()=>{if(!this.session)return;if(this.session.device==="unknown"){let r=this.session,s=h_(r.samples,!0);this.begin(r,s==="unknown"?"mouse":s)}if(!this.session)return;let i=this.session;this.emit(ne.End,i.lastEvent),this.reset()},this.handleKeyDown=i=>{i.key==="Control"&&this.pressedControlKeys.add(i.code||i.key)},this.handleKeyUp=i=>{i.key==="Control"&&(i.code?this.pressedControlKeys.delete(i.code):this.pressedControlKeys.clear())},this.handleWindowBlur=()=>{this.pressedControlKeys.clear()},this.element=e,this.options={...J4,...t},this.element?.addEventListener("wheel",this.handleEvent,{passive:!0})}get hasSubscribers(){return this.subscriptions.size>0}get device(){return this.session?.device??"unknown"}on(e){let t={listener:e};return this.subscriptions.set(e,t),this.updateControlKeyEventListeners(),()=>{this.subscriptions.get(e)===t&&this.off(e)}}off(e){this.subscriptions.delete(e),this.updateControlKeyEventListeners(),this.hasSubscribers||this.reset()}cancel(){let e=this.session;e&&e.device!=="unknown"&&this.emit(ne.Cancel,e.lastEvent),this.reset()}destroy(){this.cancel(),this.subscriptions.clear(),this.updateControlKeyEventListeners(),this.element?.removeEventListener("wheel",this.handleEvent)}startPendingSession(e){let t={samples:[e],device:"unknown",firstTimeStamp:e.timeStamp,lastTimeStamp:e.timeStamp,totalDeltaX:e.deltaX,totalDeltaY:e.deltaY,velocityX:0,velocityY:0,lastEvent:e.event};return this.session=t,this.classificationTimer=globalThis.setTimeout(this.finishClassification,this.options.classificationDelay),t}addSample(e,t){if(e.samples.push(t),e.lastTimeStamp=t.timeStamp,e.lastEvent=t.event,e.totalDeltaX+=t.deltaX,e.totalDeltaY+=t.deltaY,e.device!=="unknown"){let i=e.samples[e.samples.length-2],r=t.timeStamp-i.timeStamp;e.velocityX=r>0?t.deltaX/r:0,e.velocityY=r>0?t.deltaY/r:0,this.emit(ne.Move,t.event,{velocityX:e.velocityX,velocityY:e.velocityY})}}begin(e,t){e.device=t,this.clearClassificationTimer(),this.emit(ne.Start,e.samples[0].event);let i=e.lastTimeStamp-e.firstTimeStamp;e.velocityX=i>0?e.totalDeltaX/i:0,e.velocityY=i>0?e.totalDeltaY/i:0,this.emit(ne.Move,e.lastEvent,{velocityX:e.velocityX,velocityY:e.velocityY})}scheduleEnd(){this.clearEndTimer(),this.endTimer=globalThis.setTimeout(this.end,this.options.endDelay)}emit(e,t,i){let r=this.session;if(!r||r.device==="unknown")return;let s=e===ne.Start,o=e===ne.End||e===ne.Cancel,a=s?r.firstTimeStamp:r.lastTimeStamp,c=s?0:Math.max(0,a-r.firstTimeStamp),l=s?0:r.totalDeltaX,u=s?0:r.totalDeltaY,f=c>0?l/c:0,d=c>0?u/c:0,h=s?0:i?.velocityX??r.velocityX,p=s?0:i?.velocityY??r.velocityY,m={eventType:e,device:r.device,srcEvent:t,timeStamp:a,center:{x:t.clientX,y:t.clientY},deltaX:l,deltaY:u,deltaTime:c,velocity:Math.abs(h)>Math.abs(p)?h:p,velocityX:h,velocityY:p,overallVelocity:Math.abs(f)>Math.abs(d)?f:d,overallVelocityX:f,overallVelocityY:d,isFirst:s,isFinal:o};for(let{listener:g}of[...this.subscriptions.values()])g(m)}reset(){this.clearClassificationTimer(),this.clearEndTimer(),this.session=null}clearClassificationTimer(){this.classificationTimer!==null&&(globalThis.clearTimeout(this.classificationTimer),this.classificationTimer=null)}clearEndTimer(){this.endTimer!==null&&(globalThis.clearTimeout(this.endTimer),this.endTimer=null)}updateControlKeyEventListeners(){let e=this.hasSubscribers,t=eN();!t||e===this.listeningForControlKeys||(this.listeningForControlKeys=e,e?(t.addEventListener("keydown",this.handleKeyDown,!0),t.addEventListener("keyup",this.handleKeyUp,!0),t.addEventListener("blur",this.handleWindowBlur)):(t.removeEventListener("keydown",this.handleKeyDown,!0),t.removeEventListener("keyup",this.handleKeyUp,!0),t.removeEventListener("blur",this.handleWindowBlur),this.pressedControlKeys.clear()))}};function eN(){return typeof window<"u"?window:globalThis.document?.defaultView}function tN(n,e){let t=n.deltaX,i=n.deltaY;return n.deltaMode===X4&&(t*=OS,i*=OS),{event:n,timeStamp:n.timeStamp,deltaX:t,deltaY:i,isControlKeyDown:e}}function h_(n,e){return n.some(({event:t,isControlKeyDown:i})=>t.ctrlKey&&!i)?"trackpad":n.some(({event:t})=>t.deltaMode!==Z4)||n.some(nN)||n.every(({event:t})=>{let i=t.wheelDelta;return i!==void 0&&Math.abs(i)%40===0})?"mouse":n.some(({deltaX:t})=>t!==0)||n.length>1&&iN(n)?"trackpad":e?"mouse":"unknown"}function nN({event:n,deltaX:e,deltaY:t}){if(e!==0||t===0)return!1;let i=Math.abs(t/q4);if(Number.isInteger(i))return!0;let r=n.wheelDelta;return typeof r=="number"&&r!==0&&r%Q4===0}function iN(n){for(let e=0;eDS||Math.abs(t.deltaY)>DS||e>0&&t.timeStamp-n[e-1].timeStamp>K4)return!1}return!0}var NS=["mousedown","mousemove","mouseup","mouseover","mouseout","mouseenter","mouseleave"],_f=class extends Un{constructor(e,t,i){super(e,t,{enable:!0,...i}),this.handleEvent=s=>{this.handleOverEvent(s),this.handleOutEvent(s),this.handleEnterEvent(s),this.handleLeaveEvent(s),this.handleMoveEvent(s)},this.pressed=!1;let{enable:r=!1}=this.options;this.enableMoveEvent=r,this.enableLeaveEvent=r,this.enableEnterEvent=r,this.enableOutEvent=r,this.enableOverEvent=r,r&&NS.forEach(s=>this.listen(s,!0))}destroy(){NS.forEach(e=>this.listen(e,!1))}enableEventType(e,t){switch(e){case"pointermove":this.enableMoveEvent!==t&&(this.enableMoveEvent=t,this.listen("mousedown",t),this.listen("mousemove",t),this.listen("mouseup",t));break;case"pointerover":this.enableOverEvent!==t&&(this.enableOverEvent=t,this.listen("mouseover",t));break;case"pointerout":this.enableOutEvent!==t&&(this.enableOutEvent=t,this.listen("mouseout",t));break;case"pointerenter":this.enableEnterEvent!==t&&(this.enableEnterEvent=t,this.listen("mouseenter",t));break;case"pointerleave":this.enableLeaveEvent!==t&&(this.enableLeaveEvent=t,this.listen("mouseleave",t));break;default:}}handleOverEvent(e){this.enableOverEvent&&e.type==="mouseover"&&this._emit("pointerover",e)}handleOutEvent(e){this.enableOutEvent&&e.type==="mouseout"&&this._emit("pointerout",e)}handleEnterEvent(e){this.enableEnterEvent&&e.type==="mouseenter"&&this._emit("pointerenter",e)}handleLeaveEvent(e){this.enableLeaveEvent&&e.type==="mouseleave"&&this._emit("pointerleave",e)}handleMoveEvent(e){if(this.enableMoveEvent)switch(e.type){case"mousedown":e.button>=0&&(this.pressed=!0);break;case"mousemove":e.buttons===0&&(this.pressed=!1),this.pressed||this._emit("pointermove",e);break;case"mouseup":this.pressed=!1;break;default:}}_emit(e,t){this.callback({type:e,center:{x:t.clientX,y:t.clientY},srcEvent:t,pointerType:"mouse",target:t.target})}};var FS=["keydown","keyup"],yf=class extends Un{constructor(e,t,i){super(e,t,{enable:!0,tabIndex:0,...i}),this.handleEvent=s=>{let o=s.target||s.srcElement;o.tagName==="INPUT"&&o.type==="text"||o.tagName==="TEXTAREA"||(this.enableDownEvent&&s.type==="keydown"&&this.callback({type:"keydown",srcEvent:s,key:s.key,target:s.target}),this.enableUpEvent&&s.type==="keyup"&&this.callback({type:"keyup",srcEvent:s,key:s.key,target:s.target}))};let{enable:r=!1}=this.options;this.enableDownEvent=r,this.enableUpEvent=r,e.tabIndex=this.options.tabIndex,e.style.outline="none",r&&FS.forEach(s=>this.listen(s,!0))}destroy(){FS.forEach(e=>this.listen(e,!1))}enableEventType(e,t){e==="keydown"&&this.enableDownEvent!==t&&(this.enableDownEvent=t,this.listen(e,t)),e==="keyup"&&this.enableUpEvent!==t&&(this.enableUpEvent=t,this.listen(e,t))}};var bf=class extends Un{constructor(e,t,i){i.enable=i.enable??!1,super(e,t,i),this.handleEvent=r=>{this.options.enable&&this.callback({type:"contextmenu",center:{x:r.clientX,y:r.clientY},srcEvent:r,pointerType:"mouse",target:r.target})},i.enable&&this.listen("contextmenu",!0)}destroy(){this.listen("contextmenu",!1)}enableEventType(e,t){e==="contextmenu"&&this.options.enable!==t&&(this.options.enable=t,this.listen("contextmenu",t))}};var rN={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},sN=0,oN=1,aN=2,cN=1,lN=2,uN=4;function zS(n){let e=rN[n.srcEvent.type];if(!e)return null;let{buttons:t,button:i}=n.srcEvent,r=!1,s=!1,o=!1;return e===2?(r=!!(t&cN),s=!!(t&uN),o=!!(t&lN)):(r=i===sN,s=i===oN,o=i===aN),{leftButton:r,middleButton:s,rightButton:o}}function US(n,e){let t=n.center;if(!t)return null;let i=e.getBoundingClientRect(),r=i.width/e.offsetWidth||1,s=i.height/e.offsetHeight||1,o={x:(t.x-i.left-e.clientLeft)/r,y:(t.y-i.top-e.clientTop)/s};return{center:t,offsetCenter:o}}var fN={srcElement:"root",priority:0},vf=class{constructor(e,t){this.handleEvent=i=>{if(this.isEmpty())return;let r=this._normalizeEvent(i),s=i.srcEvent.target;for(;s&&s!==r.rootElement;){if(this._emit(r,s),r.handled)return;s=s.parentNode}this._emit(r,"root")},this.eventManager=e,this.recognizerName=t,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(e,t,i,r=!1,s=!1){let{handlers:o,handlersByElement:a}=this,c={...fN,...i},l=a.get(c.srcElement);l||(l=[],a.set(c.srcElement,l));let u={type:e,handler:t,srcElement:c.srcElement,priority:c.priority};r&&(u.once=!0),s&&(u.passive=!0),o.push(u),this._active=this._active||!u.passive;let f=l.length-1;for(;f>=0&&!(l[f].priority>=u.priority);)f--;l.splice(f+1,0,u)}remove(e,t){let{handlers:i,handlersByElement:r}=this;for(let s=i.length-1;s>=0;s--){let o=i[s];if(o.type===e&&o.handler===t){i.splice(s,1);let a=r.get(o.srcElement);a.splice(a.indexOf(o),1),a.length===0&&r.delete(o.srcElement)}}this._active=i.some(s=>!s.passive)}_emit(e,t){let i=this.handlersByElement.get(t);if(i){let r=!1,s=()=>{e.handled=!0},o=()=>{e.handled=!0,r=!0},a=[];for(let c=0;c{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:t}}};function dN(n){if("recognizer"in n)return n;let e,t=Array.isArray(n)?[...n]:[n];if(typeof t[0]=="function"){let i=t.shift(),r=t.shift()||{};e=new i(r)}else e=t.shift();return{recognizer:e,recognizeWith:typeof t[0]=="string"?[t[0]]:t[0],requireFailure:typeof t[1]=="string"?[t[1]]:t[1]}}var rc=class{constructor(e=null,t={}){if(this._onBasicInput=i=>{this.manager.emit(i.srcEvent.type,i)},this._onOtherEvent=i=>{this.manager.emit(i.type,i)},this.options={recognizers:[],events:{},touchAction:"compute",tabIndex:0,cssProps:{},...t},this.events=new Map,this.element=e,this.wheelSession=new gf(e),!!e){this.manager=new ic(e,this.options);for(let i of this.options.recognizers){let{recognizer:r,recognizeWith:s,requireFailure:o}=dN(i);this.manager.add(r),s&&r.recognizeWith(s),o&&r.requireFailure(o)}this.manager.on("hammer.input",this._onBasicInput),this.wheelInput=new mf(e,this._onOtherEvent,{enable:!1,wheelSession:this.wheelSession}),this.moveInput=new _f(e,this._onOtherEvent,{enable:!1}),this.keyInput=new yf(e,this._onOtherEvent,{enable:!1,tabIndex:t.tabIndex}),this.contextmenuInput=new bf(e,this._onOtherEvent,{enable:!1}),this.on(this.options.events)}}getElement(){return this.element}destroy(){if(!this.element){this.wheelSession.destroy();return}this.wheelInput.destroy(),this.wheelSession.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy()}on(e,t,i){this._addEventHandler(e,t,i,!1)}once(e,t,i){this._addEventHandler(e,t,i,!0)}watch(e,t,i){this._addEventHandler(e,t,i,!1,!0)}off(e,t){this._removeEventHandler(e,t)}emit(e){this.manager?.emit(e.type,e)}_toggleRecognizer(e,t){let{manager:i}=this;if(!i)return;let r=i.get(e);r&&(r.set({enable:t,wheelSession:this.wheelSession}),i.touchAction.update()),this.wheelInput?.enableEventType(e,t),this.moveInput?.enableEventType(e,t),this.keyInput?.enableEventType(e,t),this.contextmenuInput?.enableEventType(e,t)}_addEventHandler(e,t,i,r,s){if(typeof e!="string"){i=t;for(let[l,u]of Object.entries(e))this._addEventHandler(l,u,i,r,s);return}let{manager:o,events:a}=this;if(!o)return;let c=a.get(e);if(!c){let l=this._getRecognizerName(e)||e;c=new vf(this,l),a.set(e,c),o&&o.on(e,c.handleEvent)}c.add(e,t,i,r,s),c.isEmpty()||this._toggleRecognizer(c.recognizerName,!0)}_removeEventHandler(e,t){if(typeof e!="string"){for(let[s,o]of Object.entries(e))this._removeEventHandler(s,o);return}let{events:i}=this,r=i.get(e);if(r&&(r.remove(e,t),r.isEmpty())){let{recognizerName:s}=r,o=!1;for(let a of i.values())if(a.recognizerName===s&&!a.isEmpty()){o=!0;break}o||this._toggleRecognizer(s,!1)}}_getRecognizerName(e){return this.manager.recognizers.find(t=>t.getEventNames().includes(e))?.options.event}};var p_={DEFAULT:"default",LNGLAT:"lnglat",METER_OFFSETS:"meter-offsets",LNGLAT_OFFSETS:"lnglat-offsets",CARTESIAN:"cartesian"};Object.defineProperty(p_,"IDENTITY",{get:()=>(ae.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),p_.CARTESIAN)});var qe={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},Zt={common:0,meters:1,pixels:2},ao={click:"onClick",dblclick:"onClick",panstart:"onDragStart",panmove:"onDrag",panend:"onDragEnd"},m_={multipan:[qi,{threshold:10,pointers:2,trackpad:!0}],pinch:[oo,{trackpad:!0},null,["multipan"]],pan:[qi,{threshold:1},["pinch"],["multipan"]],dblclick:[qr,{event:"dblclick",taps:2,enable:!1}],dblclickdrag:[ro,{event:"dblclickdrag",enable:!1},["dblclick"],null],click:[qr,{event:"click"},["dblclickdrag"],["dblclick","dblclickdrag"]]};function hN(n,e){if(n===e)return!0;if(Array.isArray(n)){let t=n.length;if(!e||e.length!==t)return!1;for(let i=0;i{for(let r in i)if(!hN(i[r],e[r])){t=n(i),e=i;break}return t}}var $S=[0,0,0,0],pN=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],GS=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],mN=[0,0,0],VS=[0,0,0],gN={default:-1,cartesian:0,lnglat:1,"meter-offsets":2,"lnglat-offsets":3};function Zr(n){let e=gN[n];if(e===void 0)throw new Error(`Invalid coordinateSystem: ${n}`);return e}var _N=$n(bN);function g_(n,e,t=VS){t.length<3&&(t=[t[0],t[1],0]);let i=t,r,s=!0;switch(e==="lnglat-offsets"||e==="meter-offsets"?r=t:r=n.isGeospatial?[Math.fround(n.longitude),Math.fround(n.latitude),0]:null,n.projectionMode){case qe.WEB_MERCATOR:(e==="lnglat"||e==="cartesian")&&(r=[0,0,0],s=!1);break;case qe.WEB_MERCATOR_AUTO_OFFSET:e==="lnglat"?i=r:e==="cartesian"&&(i=[Math.fround(n.center[0]),Math.fround(n.center[1]),0],r=n.unprojectPosition(i),i[0]-=t[0],i[1]-=t[1],i[2]-=t[2]);break;case qe.IDENTITY:i=n.position.map(Math.fround),i[2]=i[2]||0;break;case qe.GLOBE:s=!1,r=null;break;default:s=!1}return{geospatialOrigin:r,shaderCoordinateOrigin:i,offsetMode:s}}function yN(n,e,t){let{viewMatrixUncentered:i,projectionMatrix:r}=n,{viewMatrix:s,viewProjectionMatrix:o}=n,a=$S,c=$S,l=n.cameraPosition,{geospatialOrigin:u,shaderCoordinateOrigin:f,offsetMode:d}=g_(n,e,t);return d&&(c=n.projectPosition(u||f),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,a=At.transformMat4([],c,o),s=i||s,o=We.multiply([],r,s),o=We.multiply([],o,pN)),{viewMatrix:s,viewProjectionMatrix:o,projectionCenter:a,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:f,geospatialOrigin:u}}function WS({viewport:n,devicePixelRatio:e=1,modelMatrix:t=null,coordinateSystem:i="default",coordinateOrigin:r=VS,autoWrapLongitude:s=!1}){i==="default"&&(i=n.isGeospatial?"lnglat":"cartesian");let o=_N({viewport:n,devicePixelRatio:e,coordinateSystem:i,coordinateOrigin:r});return o.wrapLongitude=s,o.modelMatrix=t||GS,o}function bN({viewport:n,devicePixelRatio:e,coordinateSystem:t,coordinateOrigin:i}){let{projectionCenter:r,viewProjectionMatrix:s,originCommon:o,cameraPosCommon:a,shaderCoordinateOrigin:c,geospatialOrigin:l}=yN(n,t,i),u=n.getDistanceScales(),f=[n.width*e,n.height*e],d=At.transformMat4([],[0,0,-n.focalDistance,1],n.projectionMatrix)[3]||1,h={coordinateSystem:Zr(t),projectionMode:n.projectionMode,coordinateOrigin:c,commonOrigin:o.slice(0,3),center:r,pseudoMeters:!!n._pseudoMeters,viewportSize:f,devicePixelRatio:e,focalDistance:d,commonUnitsPerMeter:u.unitsPerMeter,commonUnitsPerWorldUnit:u.unitsPerMeter,commonUnitsPerWorldUnit2:mN,scale:n.scale,wrapLongitude:!1,viewProjectionMatrix:s,modelMatrix:GS,cameraPosition:a};if(l){let p=n.getDistanceScales(l);switch(t){case"meter-offsets":h.commonUnitsPerWorldUnit=p.unitsPerMeter,h.commonUnitsPerWorldUnit2=p.unitsPerMeter2;break;case"lnglat":case"lnglat-offsets":n._pseudoMeters||(h.commonUnitsPerMeter=p.unitsPerMeter),h.commonUnitsPerWorldUnit=p.unitsPerDegree,h.commonUnitsPerWorldUnit2=p.unitsPerDegree2;break;case"cartesian":h.commonUnitsPerWorldUnit=[1,1,p.unitsPerMeter[2]],h.commonUnitsPerWorldUnit2=[0,0,p.unitsPerMeter2[2]];break;default:break}}if(n.projectionMode===qe.GLOBE&&t==="meter-offsets"){let g=i[0]*Math.PI/180,v=i[1]*Math.PI/180,y=Math.cos(v),b=((i[2]||0)/6370972+1)*256;h.commonOrigin=[Math.sin(g)*y*b,-Math.cos(g)*y*b,Math.sin(v)*b]}return h}var vN=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],xN=vN.map(n=>`const COORDINATE_SYSTEM_${n.toUpperCase().replaceAll("-","_")}: i32 = ${Zr(n)};`).join(""),wN=Object.keys(qe).map(n=>`const PROJECTION_MODE_${n}: i32 = ${qe[n]};`).join(""),EN=Object.keys(Zt).map(n=>`const UNIT_${n.toUpperCase()}: i32 = ${Zt[n]};`).join(""),SN=`${xN} +${wN} +${EN} + +const TILE_SIZE: f32 = 512.0; +const PI: f32 = 3.1415926536; +const WORLD_SCALE: f32 = TILE_SIZE / (PI * 2.0); +const ZERO_64_LOW: vec3 = vec3(0.0, 0.0, 0.0); +const EARTH_RADIUS: f32 = 6370972.0; // meters +const GLOBE_RADIUS: f32 = 256.0; + +// ----------------------------------------------------------------------------- +// Uniform block (converted from GLSL uniform block) +// ----------------------------------------------------------------------------- +struct ProjectUniforms { + wrapLongitude: i32, + coordinateSystem: i32, + commonUnitsPerMeter: vec3, + projectionMode: i32, + scale: f32, + commonUnitsPerWorldUnit: vec3, + commonUnitsPerWorldUnit2: vec3, + center: vec4, + modelMatrix: mat4x4, + viewProjectionMatrix: mat4x4, + viewportSize: vec2, + devicePixelRatio: f32, + focalDistance: f32, + cameraPosition: vec3, + coordinateOrigin: vec3, + commonOrigin: vec3, + pseudoMeters: i32, +}; + +@group(0) @binding(auto) +var project: ProjectUniforms; + +// ----------------------------------------------------------------------------- +// Geometry data shared across the project helpers. +// The active layer shader is responsible for populating this private module +// state before calling the project functions below. +// ----------------------------------------------------------------------------- + +// Structure to carry additional geometry data used by deck.gl filters. +struct Geometry { + worldPosition: vec3, + worldPositionAlt: vec3, + position: vec4, + normal: vec3, + uv: vec2, + pickingColor: vec3, +}; + +var geometry: Geometry; +`,jS=`${SN} + +// ----------------------------------------------------------------------------- +// Functions +// ----------------------------------------------------------------------------- + +// Returns an adjustment factor for commonUnitsPerMeter +fn _project_size_at_latitude(lat: f32) -> f32 { + let y = clamp(lat, -89.9, 89.9); + return 1.0 / cos(radians(y)); +} + +// Overloaded version: scales a value in meters at a given latitude. +fn _project_size_at_latitude_m(meters: f32, lat: f32) -> f32 { + return meters * project.commonUnitsPerMeter.z * _project_size_at_latitude(lat); +} + +// Computes a non-linear scale factor based on geometry. +// (Note: This function relies on "geometry" being provided.) +fn project_size() -> f32 { + if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR && + project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT && + project.pseudoMeters == 0) { + if (geometry.position.w == 0.0) { + return _project_size_at_latitude(geometry.worldPosition.y); + } + let y: f32 = geometry.position.y / TILE_SIZE * 2.0 - 1.0; + let y2 = y * y; + let y4 = y2 * y2; + let y6 = y4 * y2; + return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6; + } + return 1.0; +} + +// Overloads to scale offsets (meters to world units) +fn project_size_float(meters: f32) -> f32 { + return meters * project.commonUnitsPerMeter.z * project_size(); +} + +fn project_size_vec2(meters: vec2) -> vec2 { + return meters * project.commonUnitsPerMeter.xy * project_size(); +} + +fn project_size_vec3(meters: vec3) -> vec3 { + return meters * project.commonUnitsPerMeter * project_size(); +} + +fn project_size_vec4(meters: vec4) -> vec4 { + return vec4(meters.xyz * project.commonUnitsPerMeter, meters.w); +} + +// Returns a rotation matrix aligning the z\u2011axis with the given up vector. +fn project_get_orientation_matrix(up: vec3) -> mat3x3 { + let uz = normalize(up); + let ux = select( + vec3(1.0, 0.0, 0.0), + normalize(vec3(uz.y, -uz.x, 0.0)), + abs(uz.z) == 1.0 + ); + let uy = cross(uz, ux); + return mat3x3(ux, uy, uz); +} + +// Since WGSL does not support "out" parameters, we return a struct. +struct RotationResult { + needsRotation: bool, + transform: mat3x3, +}; + +fn project_needs_rotation(commonPosition: vec3) -> RotationResult { + if (project.projectionMode == PROJECTION_MODE_GLOBE) { + return RotationResult(true, project_get_orientation_matrix(commonPosition)); + } else { + return RotationResult(false, mat3x3()); // identity alternative if needed + }; +} + +// Projects a normal vector from the current coordinate system to world space. +fn project_normal(vector: vec3) -> vec3 { + let normal_modelspace = project.modelMatrix * vec4(vector, 0.0); + var n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter); + let rotResult = project_needs_rotation(geometry.position.xyz); + if (rotResult.needsRotation) { + n = rotResult.transform * n; + } + return n; +} + +// Applies a scale offset based on y-offset (dy) +fn project_offset_(offset: vec4) -> vec4 { + let dy: f32 = offset.y; + let commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy; + return vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w); +} + +// Projects lng/lat coordinates to a unit tile [0,1] +fn project_mercator_(lnglat: vec2) -> vec2 { + var x = lnglat.x; + if (project.wrapLongitude != 0) { + x = ((x + 180.0) % 360.0) - 180.0; + } + let y = clamp(lnglat.y, -89.9, 89.9); + return vec2( + radians(x) + PI, + PI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5)) + ) * WORLD_SCALE; +} + +// Projects lng/lat/z coordinates for a globe projection. +fn project_globe_(lnglatz: vec3) -> vec3 { + let lambda = radians(lnglatz.x); + let phi = radians(lnglatz.y); + let cosPhi = cos(phi); + let D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS; + return vec3( + sin(lambda) * cosPhi, + -cos(lambda) * cosPhi, + sin(phi) + ) * D; +} + +// Projects positions (with an optional 64-bit low part) from the input +// coordinate system to the common space. +fn project_position_vec4_f64(position: vec4, position64Low: vec3) -> vec4 { + var position_world = project.modelMatrix * position; + + // Work around for a Mac+NVIDIA bug: + if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) { + if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { + return vec4( + project_mercator_(position_world.xy), + _project_size_at_latitude_m(position_world.z, position_world.y), + position_world.w + ); + } + if (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) { + position_world = vec4f(position_world.xyz + project.coordinateOrigin, position_world.w); + } + } + if (project.projectionMode == PROJECTION_MODE_GLOBE) { + if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { + return vec4( + project_globe_(position_world.xyz), + position_world.w + ); + } + if (project.coordinateSystem == COORDINATE_SYSTEM_METER_OFFSETS) { + let enuMatrix = project_get_orientation_matrix(project.commonOrigin); + let metersToCommon = GLOBE_RADIUS / EARTH_RADIUS; + let offsetCommon = (enuMatrix * vec3(-position_world.x, -position_world.y, position_world.z)) * metersToCommon; + return vec4(project.commonOrigin + offsetCommon, position_world.w); + } + } + if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) { + if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { + if (abs(position_world.y - project.coordinateOrigin.y) > 0.25) { + return vec4( + project_mercator_(position_world.xy) - project.commonOrigin.xy, + project_size_float(position_world.z), + position_world.w + ); + } + } + } + if (project.projectionMode == PROJECTION_MODE_IDENTITY || + (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET && + (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT || + project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) { + position_world = vec4f(position_world.xyz - project.coordinateOrigin, position_world.w); + } + + return project_offset_(position_world) + + project_offset_(project.modelMatrix * vec4(position64Low, 0.0)); +} + +// Overloaded versions for different input types. +fn project_position_vec4_f32(position: vec4) -> vec4 { + return project_position_vec4_f64(position, ZERO_64_LOW); +} + +fn project_position_vec3_f64(position: vec3, position64Low: vec3) -> vec3 { + let projected_position = project_position_vec4_f64(vec4(position, 1.0), position64Low); + return projected_position.xyz; +} + +fn project_position_vec3_f32(position: vec3) -> vec3 { + let projected_position = project_position_vec4_f64(vec4(position, 1.0), ZERO_64_LOW); + return projected_position.xyz; +} + +fn project_position_vec2_f32(position: vec2) -> vec2 { + let projected_position = project_position_vec4_f64(vec4(position, 0.0, 1.0), ZERO_64_LOW); + return projected_position.xy; +} + +// Transforms a common space position to clip space. +fn project_common_position_to_clipspace_with_projection(position: vec4, viewProjectionMatrix: mat4x4, center: vec4) -> vec4 { + var clipPosition = viewProjectionMatrix * position + center; + // deck.gl projection matrices use WebGL's [-w, w] depth range; WebGPU clips z to [0, w]. + clipPosition.z = (clipPosition.z + clipPosition.w) * 0.5; + return clipPosition; +} + +// Uses the project viewProjectionMatrix and center. +fn project_common_position_to_clipspace(position: vec4) -> vec4 { + return project_common_position_to_clipspace_with_projection(position, project.viewProjectionMatrix, project.center); +} + +// Returns a clip space offset corresponding to a given number of screen pixels. +fn project_pixel_size_to_clipspace(pixels: vec2) -> vec2 { + let offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0; + return offset * project.focalDistance; +} + +fn project_meter_size_to_pixel(meters: f32) -> f32 { + return project_size_float(meters) * project.scale; +} + +fn project_unit_size_to_pixel(size: f32, unit: i32) -> f32 { + if (unit == UNIT_METERS) { + return project_meter_size_to_pixel(size); + } else if (unit == UNIT_COMMON) { + return size * project.scale; + } + // UNIT_PIXELS: no scaling applied. + return size; +} + +fn project_pixel_size_float(pixels: f32) -> f32 { + return pixels / project.scale; +} + +fn project_pixel_size_vec2(pixels: vec2) -> vec2 { + return pixels / project.scale; +} +`;var PN=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],CN=PN.map(n=>`const int COORDINATE_SYSTEM_${n.toUpperCase().replaceAll("-","_")} = ${Zr(n)};`).join(""),TN=Object.keys(qe).map(n=>`const int PROJECTION_MODE_${n} = ${qe[n]};`).join(""),LN=Object.keys(Zt).map(n=>`const int UNIT_${n.toUpperCase()} = ${Zt[n]};`).join(""),HS=`${CN} +${TN} +${LN} +layout(std140) uniform projectUniforms { +bool wrapLongitude; +int coordinateSystem; +vec3 commonUnitsPerMeter; +int projectionMode; +float scale; +vec3 commonUnitsPerWorldUnit; +vec3 commonUnitsPerWorldUnit2; +vec4 center; +mat4 modelMatrix; +mat4 viewProjectionMatrix; +vec2 viewportSize; +float devicePixelRatio; +float focalDistance; +vec3 cameraPosition; +vec3 coordinateOrigin; +vec3 commonOrigin; +bool pseudoMeters; +} project; +const float TILE_SIZE = 512.0; +const float PI = 3.1415926536; +const float WORLD_SCALE = TILE_SIZE / (PI * 2.0); +const vec3 ZERO_64_LOW = vec3(0.0); +const float EARTH_RADIUS = 6370972.0; +const float GLOBE_RADIUS = 256.0; +float project_size_at_latitude(float lat) { +float y = clamp(lat, -89.9, 89.9); +return 1.0 / cos(radians(y)); +} +float project_size() { +if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR && +project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT && +project.pseudoMeters == false) { +if (geometry.position.w == 0.0) { +return project_size_at_latitude(geometry.worldPosition.y); +} +float y = geometry.position.y / TILE_SIZE * 2.0 - 1.0; +float y2 = y * y; +float y4 = y2 * y2; +float y6 = y4 * y2; +return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6; +} +return 1.0; +} +float project_size_at_latitude(float meters, float lat) { +return meters * project.commonUnitsPerMeter.z * project_size_at_latitude(lat); +} +float project_size(float meters) { +return meters * project.commonUnitsPerMeter.z * project_size(); +} +vec2 project_size(vec2 meters) { +return meters * project.commonUnitsPerMeter.xy * project_size(); +} +vec3 project_size(vec3 meters) { +return meters * project.commonUnitsPerMeter * project_size(); +} +vec4 project_size(vec4 meters) { +return vec4(meters.xyz * project.commonUnitsPerMeter, meters.w); +} +mat3 project_get_orientation_matrix(vec3 up) { +vec3 uz = normalize(up); +vec3 ux = abs(uz.z) == 1.0 ? vec3(1.0, 0.0, 0.0) : normalize(vec3(uz.y, -uz.x, 0)); +vec3 uy = cross(uz, ux); +return mat3(ux, uy, uz); +} +bool project_needs_rotation(vec3 commonPosition, out mat3 transform) { +if (project.projectionMode == PROJECTION_MODE_GLOBE) { +transform = project_get_orientation_matrix(commonPosition); +return true; +} +return false; +} +vec3 project_normal(vec3 vector) { +vec4 normal_modelspace = project.modelMatrix * vec4(vector, 0.0); +vec3 n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter); +mat3 rotation; +if (project_needs_rotation(geometry.position.xyz, rotation)) { +n = rotation * n; +} +return n; +} +vec4 project_offset_(vec4 offset) { +float dy = offset.y; +vec3 commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy; +return vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w); +} +vec2 project_mercator_(vec2 lnglat) { +float x = lnglat.x; +if (project.wrapLongitude) { +x = mod(x + 180., 360.0) - 180.; +} +float y = clamp(lnglat.y, -89.9, 89.9); +return vec2( +radians(x) + PI, +PI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5)) +) * WORLD_SCALE; +} +vec3 project_globe_(vec3 lnglatz) { +float lambda = radians(lnglatz.x); +float phi = radians(lnglatz.y); +float cosPhi = cos(phi); +float D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS; +return vec3( +sin(lambda) * cosPhi, +-cos(lambda) * cosPhi, +sin(phi) +) * D; +} +vec4 project_position(vec4 position, vec3 position64Low) { +vec4 position_world = project.modelMatrix * position; +if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) { +if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { +return vec4( +project_mercator_(position_world.xy), +project_size_at_latitude(position_world.z, position_world.y), +position_world.w +); +} +if (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) { +position_world.xyz += project.coordinateOrigin; +} +} +if (project.projectionMode == PROJECTION_MODE_GLOBE) { +if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { +return vec4( +project_globe_(position_world.xyz), +position_world.w +); +} +if (project.coordinateSystem == COORDINATE_SYSTEM_METER_OFFSETS) { +mat3 enuMatrix = project_get_orientation_matrix(project.commonOrigin); +float metersToCommon = GLOBE_RADIUS / EARTH_RADIUS; +vec3 offsetCommon = (enuMatrix * vec3(-position_world.xy, position_world.z)) * metersToCommon; +return vec4(project.commonOrigin + offsetCommon, position_world.w); +} +} +if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) { +if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { +if (abs(position_world.y - project.coordinateOrigin.y) > 0.25) { +return vec4( +project_mercator_(position_world.xy) - project.commonOrigin.xy, +project_size(position_world.z), +position_world.w +); +} +} +} +if (project.projectionMode == PROJECTION_MODE_IDENTITY || +(project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET && +(project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT || +project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) { +position_world.xyz -= project.coordinateOrigin; +} +return project_offset_(position_world) + project_offset_(project.modelMatrix * vec4(position64Low, 0.0)); +} +vec4 project_position(vec4 position) { +return project_position(position, ZERO_64_LOW); +} +vec3 project_position(vec3 position, vec3 position64Low) { +vec4 projected_position = project_position(vec4(position, 1.0), position64Low); +return projected_position.xyz; +} +vec3 project_position(vec3 position) { +vec4 projected_position = project_position(vec4(position, 1.0), ZERO_64_LOW); +return projected_position.xyz; +} +vec2 project_position(vec2 position) { +vec4 projected_position = project_position(vec4(position, 0.0, 1.0), ZERO_64_LOW); +return projected_position.xy; +} +vec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) { +return viewProjectionMatrix * position + center; +} +vec4 project_common_position_to_clipspace(vec4 position) { +return project_common_position_to_clipspace(position, project.viewProjectionMatrix, project.center); +} +vec2 project_pixel_size_to_clipspace(vec2 pixels) { +vec2 offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0; +return offset * project.focalDistance; +} +float project_size_to_pixel(float meters) { +return project_size(meters) * project.scale; +} +vec2 project_size_to_pixel(vec2 meters) { +return project_size(meters) * project.scale; +} +float project_size_to_pixel(float size, int unit) { +if (unit == UNIT_METERS) return project_size_to_pixel(size); +if (unit == UNIT_COMMON) return size * project.scale; +return size; +} +float project_pixel_size(float pixels) { +return pixels / project.scale; +} +vec2 project_pixel_size(vec2 pixels) { +return pixels / project.scale; +} +`;var MN={};function AN(n=MN){return"viewport"in n?WS(n):{}}var un={name:"project",dependencies:[Vr,uf],source:jS,vs:HS,getUniforms:AN,uniformTypes:{wrapLongitude:"f32",coordinateSystem:"i32",commonUnitsPerMeter:"vec3",projectionMode:"i32",scale:"f32",commonUnitsPerWorldUnit:"vec3",commonUnitsPerWorldUnit2:"vec3",center:"vec4",modelMatrix:"mat4x4",viewProjectionMatrix:"mat4x4",viewportSize:"vec2",devicePixelRatio:"f32",focalDistance:"f32",cameraPosition:"vec3",coordinateOrigin:"vec3",commonOrigin:"vec3",pseudoMeters:"f32"}};var kN=`// Define a structure to hold both the clip-space position and the common position. +struct ProjectResult { + clipPosition: vec4, + commonPosition: vec4, +}; + +// This function mimics the GLSL version with the 'out' parameter by returning both values. +fn project_position_to_clipspace_and_commonspace( + position: vec3, + position64Low: vec3, + offset: vec3 +) -> ProjectResult { + // Compute the projected position. + let projectedPosition: vec3 = project_position_vec3_f64(position, position64Low); + + // Start with the provided offset. + var finalOffset: vec3 = offset; + + // Get whether a rotation is needed and the rotation matrix. + let rotationResult = project_needs_rotation(projectedPosition); + + // If rotation is needed, update the offset. + if (rotationResult.needsRotation) { + finalOffset = rotationResult.transform * offset; + } + + // Compute the common position. + let commonPosition: vec4 = vec4(projectedPosition + finalOffset, 1.0); + + // Convert to clip-space. + let clipPosition: vec4 = project_common_position_to_clipspace(commonPosition); + + return ProjectResult(clipPosition, commonPosition); +} + +// A convenience overload that returns only the clip-space position. +fn project_position_to_clipspace( + position: vec3, + position64Low: vec3, + offset: vec3 +) -> vec4 { + return project_position_to_clipspace_and_commonspace(position, position64Low, offset).clipPosition; +} +`,RN=`vec4 project_position_to_clipspace( + vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition +) { + vec3 projectedPosition = project_position(position, position64Low); + mat3 rotation; + if (project_needs_rotation(projectedPosition, rotation)) { + // offset is specified as ENU + // when in globe projection, rotate offset so that the ground alighs with the surface of the globe + offset = rotation * offset; + } + commonPosition = vec4(projectedPosition + offset, 1.0); + return project_common_position_to_clipspace(commonPosition); +} + +vec4 project_position_to_clipspace( + vec3 position, vec3 position64Low, vec3 offset +) { + vec4 commonPosition; + return project_position_to_clipspace(position, position64Low, offset, commonPosition); +} +`,Gn={name:"project32",dependencies:[un],source:kN,vs:RN};Fe();Fe();function __(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Zi(n,e){let t=At.transformMat4([],e,n);return At.scale(t,t,1/t[3]),t}function sc(n,e,t){return nt?t:n}function IN(n){return Math.log(n)*Math.LOG2E}var oc=Math.log2||IN;Fe();function fn(n,e){if(!n)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}var dn=Math.PI,YS=dn/4,Xt=dn/180,y_=180/dn,co=512,xf=4003e4,lo=85.051129,qS=1.5;function b_(n){return oc(n)}function ht(n){let[e,t]=n;fn(Number.isFinite(e)),fn(Number.isFinite(t)&&t>=-90&&t<=90,"invalid latitude");let i=e*Xt,r=t*Xt,s=co*(i+dn)/(2*dn),o=co*(dn+Math.log(Math.tan(YS+r*.5)))/(2*dn);return[s,o]}function kt(n){let[e,t]=n,i=e/co*(2*dn)-dn,r=2*(Math.atan(Math.exp(t/co*(2*dn)-dn))-YS);return[i*y_,r*y_]}function v_(n){let{latitude:e}=n;fn(Number.isFinite(e));let t=Math.cos(e*Xt);return b_(xf*t)-9}function ac(n){let e=Math.cos(n*Xt);return co/xf/e}function uo(n){let{latitude:e,longitude:t,highPrecision:i=!1}=n;fn(Number.isFinite(e)&&Number.isFinite(t));let r=co,s=Math.cos(e*Xt),o=r/360,a=o/s,c=r/xf/s,l={unitsPerMeter:[c,c,c],metersPerUnit:[1/c,1/c,1/c],unitsPerDegree:[o,a,c],degreesPerUnit:[1/o,1/a,1/c]};if(i){let u=Xt*Math.tan(e*Xt)/s,f=o*u/2,d=r/xf*u,h=d/a*c;l.unitsPerDegree2=[0,f,d],l.unitsPerMeter2=[h,0,h]}return l}function cc(n,e){let[t,i,r]=n,[s,o,a]=e,{unitsPerMeter:c,unitsPerMeter2:l}=uo({longitude:t,latitude:i,highPrecision:!0}),u=ht(n);u[0]+=s*(c[0]+l[0]*o),u[1]+=o*(c[1]+l[1]*o);let f=kt(u),d=(r||0)+(a||0);return Number.isFinite(r)||Number.isFinite(a)?[f[0],f[1],d]:f}function wf(n){let{height:e,pitch:t,bearing:i,altitude:r,scale:s,center:o}=n,a=__();We.translate(a,a,[0,0,-r]),We.rotateX(a,a,-t*Xt),We.rotateZ(a,a,i*Xt);let c=s/e;return We.scale(a,a,[c,c,c]),o&&We.translate(a,a,yt.negate([],o)),a}function x_(n){let{width:e,height:t,altitude:i,pitch:r=0,offset:s,center:o,scale:a,nearZMultiplier:c=1,farZMultiplier:l=1}=n,{fovy:u=Xr(qS)}=n;i!==void 0&&(u=Xr(i));let f=u*Xt,d=r*Xt,h=lc(u),p=h;o&&(p+=o[2]*a/Math.cos(d)/t);let m=f*(.5+(s?s[1]:0)/t),g=Math.sin(m)*p/Math.sin(sc(Math.PI/2-d-m,.01,Math.PI-.01)),v=Math.sin(d)*g+p,y=p*10,b=Math.min(v*l,y);return{fov:f,aspect:e/t,focalDistance:h,near:c,far:b}}function Xr(n){return 2*Math.atan(.5/n)*y_}function lc(n){return .5/Math.tan(.5*n*Xt)}function Xi(n,e){let[t,i,r=0]=n;return fn(Number.isFinite(t)&&Number.isFinite(i)&&Number.isFinite(r)),Zi(e,[t,i,r,1])}function Vn(n,e,t=0){let[i,r,s]=n;if(fn(Number.isFinite(i)&&Number.isFinite(r),"invalid pixel coordinate"),Number.isFinite(s))return Zi(e,[i,r,s,1]);let o=Zi(e,[i,r,0,1]),a=Zi(e,[i,r,1,1]),c=o[2],l=a[2],u=c===l?0:((t||0)-c)/(l-c);return dt.lerp([],o,a,u)}function Ef(n){let{width:e,height:t,bounds:i,minExtent:r=0,maxZoom:s=24,offset:o=[0,0]}=n,[[a,c],[l,u]]=i,f=BN(n.padding),d=ht([a,sc(u,-lo,lo)]),h=ht([l,sc(c,-lo,lo)]),p=[Math.max(Math.abs(h[0]-d[0]),r),Math.max(Math.abs(h[1]-d[1]),r)],m=[e-f.left-f.right-Math.abs(o[0])*2,t-f.top-f.bottom-Math.abs(o[1])*2];fn(m[0]>0&&m[1]>0);let g=m[0]/p[0],v=m[1]/p[1],y=(f.right-f.left)/2/g,b=(f.top-f.bottom)/2/v,w=[(h[0]+d[0])/2+y,(h[1]+d[1])/2+b],E=kt(w),x=Math.min(s,oc(Math.abs(Math.min(g,v))));return fn(Number.isFinite(x)),{longitude:E[0],latitude:E[1],zoom:x}}function BN(n=0){return typeof n=="number"?{top:n,bottom:n,left:n,right:n}:(fn(Number.isFinite(n.top)&&Number.isFinite(n.bottom)&&Number.isFinite(n.left)&&Number.isFinite(n.right)),n)}Fe();var ZS=Math.PI/180;function Sf(n,e=0){let{width:t,height:i,unproject:r}=n,s={targetZ:e},o=r([0,i],s),a=r([t,i],s),c,l,u=n.fovy?.5*n.fovy*ZS:Math.atan(.5/n.altitude),f=(90-n.pitch)*ZS;return u>f-.01?(c=XS(n,0,e),l=XS(n,t,e)):(c=r([0,0],s),l=r([t,0],s)),[o,a,l,c]}function XS(n,e,t){let{pixelUnprojectionMatrix:i}=n,r=Zi(i,[e,0,1,1]),s=Zi(i,[e,n.height,1,1]),a=(t*n.distanceScales.unitsPerMeter[2]-r[2])/(s[2]-r[2]),c=dt.lerp([],r,s,a),l=kt(c);return l.push(t),l}var QS=` +layout(std140) uniform shadowUniforms { + bool drawShadowMap; + bool useShadowMap; + vec4 color; + highp int lightId; + float lightCount; + mat4 viewProjectionMatrix0; + mat4 viewProjectionMatrix1; + vec4 projectCenter0; + vec4 projectCenter1; +} shadow; +`,NN=` +const int max_lights = 2; + +out vec3 shadow_vPosition[max_lights]; + +vec4 shadow_setVertexPosition(vec4 position_commonspace) { + mat4 viewProjectionMatrices[max_lights]; + viewProjectionMatrices[0] = shadow.viewProjectionMatrix0; + viewProjectionMatrices[1] = shadow.viewProjectionMatrix1; + vec4 projectCenters[max_lights]; + projectCenters[0] = shadow.projectCenter0; + projectCenters[1] = shadow.projectCenter1; + + if (shadow.drawShadowMap) { + return project_common_position_to_clipspace(position_commonspace, viewProjectionMatrices[shadow.lightId], projectCenters[shadow.lightId]); + } + if (shadow.useShadowMap) { + for (int i = 0; i < max_lights; i++) { + if(i < int(shadow.lightCount)) { + vec4 shadowMap_position = project_common_position_to_clipspace(position_commonspace, viewProjectionMatrices[i], projectCenters[i]); + shadow_vPosition[i] = (shadowMap_position.xyz / shadowMap_position.w + 1.0) / 2.0; + } + } + } + return gl_Position; +} +`,FN=` +${QS} +${NN} +`,zN=` +const int max_lights = 2; +uniform sampler2D shadow_uShadowMap0; +uniform sampler2D shadow_uShadowMap1; + +in vec3 shadow_vPosition[max_lights]; + +const vec4 bitPackShift = vec4(1.0, 255.0, 65025.0, 16581375.0); +const vec4 bitUnpackShift = 1.0 / bitPackShift; +const vec4 bitMask = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0); + +float shadow_getShadowWeight(vec3 position, sampler2D shadowMap) { + vec4 rgbaDepth = texture(shadowMap, position.xy); + + float z = dot(rgbaDepth, bitUnpackShift); + return smoothstep(0.001, 0.01, position.z - z); +} + +vec4 shadow_filterShadowColor(vec4 color) { + if (shadow.drawShadowMap) { + vec4 rgbaDepth = fract(gl_FragCoord.z * bitPackShift); + rgbaDepth -= rgbaDepth.gbaa * bitMask; + return rgbaDepth; + } + if (shadow.useShadowMap) { + float shadowAlpha = 0.0; + shadowAlpha += shadow_getShadowWeight(shadow_vPosition[0], shadow_uShadowMap0); + if(shadow.lightCount > 1.0) { + shadowAlpha += shadow_getShadowWeight(shadow_vPosition[1], shadow_uShadowMap1); + } + shadowAlpha *= shadow.color.a / shadow.lightCount; + float blendedAlpha = shadowAlpha + color.a * (1.0 - shadowAlpha); + + return vec4( + mix(color.rgb, shadow.color.rgb, shadowAlpha / blendedAlpha), + blendedAlpha + ); + } + return color; +} +`,UN=` +${QS} +${zN} +`,$N=$n(HN),GN=$n(YN),VN=[0,0,0,1],WN=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];function jN(n,e){let[t,i,r]=n,s=Vn([t,i,r],e);return Number.isFinite(r)?s:[s[0],s[1],0]}function HN({viewport:n,center:e}){return new Ne(n.viewProjectionMatrix).invert().transform(e)}function YN({viewport:n,shadowMatrices:e}){let t=[],i=n.pixelUnprojectionMatrix,r=n.isGeospatial?void 0:1,s=[[0,0,r],[n.width,0,r],[0,n.height,r],[n.width,n.height,r],[0,0,-1],[n.width,0,-1],[0,n.height,-1],[n.width,n.height,-1]].map(o=>jN(o,i));for(let o of e){let a=o.clone().translate(new tt(n.center).negate()),c=s.map(u=>a.transform(u)),l=new Ne().ortho({left:Math.min(...c.map(u=>u[0])),right:Math.max(...c.map(u=>u[0])),bottom:Math.min(...c.map(u=>u[1])),top:Math.max(...c.map(u=>u[1])),near:Math.min(...c.map(u=>-u[2])),far:Math.max(...c.map(u=>-u[2]))});t.push(l.multiplyRight(o))}return t}function qN(n){let{shadowEnabled:e=!0,project:t}=n;if(!e||!t||!n.shadowMatrices||!n.shadowMatrices.length)return{drawShadowMap:!1,useShadowMap:!1,shadow_uShadowMap0:n.dummyShadowMap,shadow_uShadowMap1:n.dummyShadowMap};let i=un.getUniforms(t),r=$N({viewport:t.viewport,center:i.center}),s=[],o=GN({shadowMatrices:n.shadowMatrices,viewport:t.viewport}).slice();for(let c=0;c0:!1,color:n.shadowColor||VN,lightId:n.shadowLightId||0,lightCount:n.shadowMatrices.length,shadow_uShadowMap0:n.dummyShadowMap,shadow_uShadowMap1:n.dummyShadowMap};for(let c=0;c",lightId:"i32",lightCount:"f32",viewProjectionMatrix0:"mat4x4",viewProjectionMatrix1:"mat4x4",projectCenter0:"vec4",projectCenter1:"vec4"}};bt();var Cf=10,uc=16777215;function e1(n,e){n.length===Cf?ae.warn(`pickMultipleObjects can only exclude ${Cf} previously picked objects for layers without picking buffers`)():n.push(e)}var ZN=` float disabledPickingIndexCount; + vec4 disabledPickingIndices0; + vec4 disabledPickingIndices1; + vec4 disabledPickingIndices2; +`;function JS(n){return n.replace(` vec4 highlightColor; +} picking;`,` vec4 highlightColor; +${ZN}} picking;`)}function w_(n,e){return[n[e]||0,n[e+1]||0,n[e+2]||0,n[e+3]||0]}var XN=`vec3 picking_getPickingColorFromIndex(float objectIndex) { + if (objectIndex < 0.0 || objectIndex >= ${uc}.0) { + return vec3(0.0); + } + + for (int i = 0; i < ${Cf}; i++) { + if (float(i) >= picking.disabledPickingIndexCount) { + break; + } + vec4 disabledIndices = i < 4 + ? picking.disabledPickingIndices0 + : (i < 8 ? picking.disabledPickingIndices1 : picking.disabledPickingIndices2); + float disabledIndex = disabledIndices[i - (i / 4) * 4]; + if (disabledIndex == objectIndex) { + return vec3(0.0); + } + } + + float encodedIndex = objectIndex + 1.0; + return vec3( + mod(encodedIndex, 256.0), + mod(floor(encodedIndex / 256.0), 256.0), + mod(floor(encodedIndex / 65536.0), 256.0) + ); +} + +vec3 picking_getPickingColorFromIndex(uint objectIndex) { + return picking_getPickingColorFromIndex(float(objectIndex)); +} + +vec3 picking_getPickingColorFromInstanceID() { + return picking_getPickingColorFromIndex(float(gl_InstanceID)); +} + +void picking_setPickingColorFromInstanceID() { + picking_setPickingColor(picking_getPickingColorFromInstanceID()); +} +`,KN=`struct pickingUniforms { + isActive: f32, + isAttribute: f32, + isHighlightActive: f32, + useByteColors: f32, + highlightedObjectColor: vec3, + highlightColor: vec4, + disabledPickingIndexCount: f32, + disabledPickingIndices0: vec4, + disabledPickingIndices1: vec4, + disabledPickingIndices2: vec4, +}; + +@group(0) @binding(auto) var picking: pickingUniforms; + +fn picking_normalizeColor(color: vec3) -> vec3 { + return select(color, color / 255.0, picking.useByteColors > 0.5); +} + +fn picking_normalizeColor4(color: vec4) -> vec4 { + return select(color, color / 255.0, picking.useByteColors > 0.5); +} + +fn picking_isColorZero(color: vec3) -> bool { + return dot(color, vec3(1.0)) < 0.00001; +} + +fn picking_isColorValid(color: vec3) -> bool { + return dot(color, vec3(1.0)) > 0.00001; +} + +fn picking_getPickingColorFromIndex(objectIndex: u32) -> vec3 { + if (objectIndex >= ${uc}u) { + return vec3(0.0); + } + + for (var i = 0; i < ${Cf}; i = i + 1) { + if (f32(i) >= picking.disabledPickingIndexCount) { + break; + } + let disabledIndices = select( + picking.disabledPickingIndices2, + select(picking.disabledPickingIndices1, picking.disabledPickingIndices0, i < 4), + i < 8 + ); + let disabledIndex = disabledIndices[i % 4]; + if (disabledIndex == f32(objectIndex)) { + return vec3(0.0); + } + } + + let encodedIndex = objectIndex + 1u; + return vec3( + f32(encodedIndex % 256u), + f32((encodedIndex / 256u) % 256u), + f32((encodedIndex / 65536u) % 256u) + ) / 255.0; +} +`,Wn={...Yi,vs:`${JS(Yi.vs)} +${XN}`,fs:JS(Yi.fs),source:KN,uniformTypes:{...Yi.uniformTypes,disabledPickingIndexCount:"f32",disabledPickingIndices0:"vec4",disabledPickingIndices1:"vec4",disabledPickingIndices2:"vec4"},defaultUniforms:{...Yi.defaultUniforms,useByteColors:!0,disabledPickingIndexCount:0,disabledPickingIndices0:[0,0,0,0],disabledPickingIndices1:[0,0,0,0],disabledPickingIndices2:[0,0,0,0]},getUniforms(n,e){let t=Yi.getUniforms(n,e),i=n.disabledPickingIndices||[];return t.disabledPickingIndexCount=i.length,t.disabledPickingIndices0=w_(i,0),t.disabledPickingIndices1=w_(i,4),t.disabledPickingIndices2=w_(i,8),t},inject:{"vs:DECKGL_FILTER_GL_POSITION":` + // for picking depth values + picking_setPickingAttribute(position.z / position.w); + `,"vs:DECKGL_FILTER_COLOR":` + picking_setPickingColor(geometry.pickingColor); + `,"fs:DECKGL_FILTER_COLOR":{order:99,injection:` + // use highlight color if this fragment belongs to the selected object. + color = picking_filterHighlightColor(color); + + // use picking color if rendering to picking FBO. + color = picking_filterPickingColor(color); + `}}};var JN=[uf],eF=["vs:DECKGL_FILTER_SIZE(inout vec3 size, VertexGeometry geometry)","vs:DECKGL_FILTER_GL_POSITION(inout vec4 position, VertexGeometry geometry)","vs:DECKGL_FILTER_COLOR(inout vec4 color, VertexGeometry geometry)","fs:DECKGL_FILTER_COLOR(inout vec4 color, FragmentGeometry geometry)"],tF=[];function t1(n){let e=Yt.getDefaultShaderAssembler(n);for(let i of JN)e.addDefaultModule(i);e._hookFunctions.length=0;let t=n==="glsl"?eF:tF;for(let i of t)e.addShaderHook(i);return e}var nF=[255,255,255],iF=1,rF=0,Tf=class{constructor(e={}){this.type="ambient";let{color:t=nF}=e,{intensity:i=iF}=e;this.id=e.id||`ambient-${rF++}`,this.color=t,this.intensity=i}};Fe();var sF=[255,255,255],oF=1,aF=[0,0,-1],cF=0,fc=class{constructor(e={}){this.type="directional";let{color:t=sF}=e,{intensity:i=oF}=e,{direction:r=aF}=e,{_shadow:s=!1}=e;this.id=e.id||`directional-${cF++}`,this.color=t,this.intensity=i,this.type="directional",this.direction=new tt(r).normalize().toArray(),this.shadow=s}getProjectedLight(e){return this}};Fe();var dc=class{constructor(e,t={id:"pass"}){let{id:i}=t;this.id=i,this.device=e,this.props={...t}}setProps(e){Object.assign(this.props,e)}render(e){}cleanup(){}};var lF={depthWriteEnabled:!0,depthCompare:"less-equal",blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one-minus-src-alpha",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha"},_i=class extends dc{constructor(){super(...arguments),this._lastRenderIndex=-1}render(e){this._render(e)}_render(e){let{canvasContext:t=this.device.canvasContext}=e,i=e.target??t.getCurrentFramebuffer(),[r,s]=t.getDrawingBufferSize(),o=e.clearCanvas??!0,a=e.clearColor??(o?[0,0,0,0]:!1),c=o?1:!1,l=o?0:!1,u=e.colorMask??15,f={viewport:[0,0,r,s]};e.colorMask&&(f.colorMask=u),e.scissorRect&&(f.scissorRect=e.scissorRect);let{shaderModuleProps:d,viewports:h,views:p,onViewportActive:m,clearStack:g=!0}=e,v=e.pass||"unknown",y=this.device.type==="webgpu";g&&(this._lastRenderIndex=-1);let b=[];if(!h.length)return this.device.beginRenderPass({framebuffer:i,parameters:f,clearColor:a,clearDepth:c,clearStencil:l}).end(),this.device.submit(),b;try{for(let w of h){m?.(w);let E=this._getDrawLayerParams(w,e),x=p&&p[w.id],T=w.subViewports||[w],I=y?T.map(N=>[N]):[T];for(let N of I){let D=this.device.beginRenderPass({framebuffer:i,parameters:f,clearColor:a,clearDepth:c,clearStencil:l});try{for(let H of N){let W=this._drawLayersInViewport(D,{target:i,canvasContext:t,shaderModuleProps:d,viewport:H,view:x,pass:v,layers:e.layers,isPicking:e.isPicking},E);b.push(W)}}finally{D.end(),y&&this.device.submit()}a=!1,c=!1,l=!1}}return b}finally{y||this.device.submit()}}_getDrawLayerParams(e,{layers:t,pass:i,isPicking:r=!1,layerFilter:s,cullRect:o,views:a,effects:c,canvasContext:l=this.device.canvasContext,shaderModuleProps:u},f=!1){let d=[],h=i1(this._lastRenderIndex+1),p={layer:t[0],viewport:e,isPicking:r,renderPass:i,cullRect:o},m={};for(let g=0;gE/255):p===!1&&(v=!1),m!==void 0&&(y=m),g!==void 0&&(b=g),this.device.beginRenderPass({framebuffer:s,parameters:{viewport:f,scissorRect:f},clearColor:v,clearDepth:y,clearStencil:b}).end()}}let d={totalCount:t.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:f});for(let h=0;h{let o=r.props._offset,a=r.id,c=r.parent&&r.parent.id,l;if(c&&!(c in e)&&i(r.parent,!1),c in t){let u=t[c]=t[c]||i1(e[c],e);l=u(r,s),t[a]=u}else Number.isFinite(o)?(l=o+(e[c]||0),t[a]=null):l=n;return s&&l>=n&&(n=l+1),e[a]=l,l};return i}function uF(n,{canvasContext:e=n.canvasContext,shaderModuleProps:t,target:i,viewport:r}){let s=t?.project?.devicePixelRatio??e.cssToDeviceRatio(),[,o]=e.getDrawingBufferSize(),a=i?i.height:o,c=r;return[c.x*s,a-(c.y+c.height)*s,c.width*s,c.height*s]}function n1(n,...e){for(let t of e)if(t)for(let i in t)n[i]?Object.assign(n[i],t[i]):n[i]=t[i];return n}var hc=class extends _i{constructor(e,t){super(e,t);let i=e.createTexture({format:"rgba8unorm",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),r=e.createTexture({format:"depth16unorm",width:1,height:1});this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[i],depthStencilAttachment:r})}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null)}getShadowMap(){return this.fbo.colorAttachments[0].texture}render(e){let t=this.fbo,i=this.device.canvasContext.cssToDeviceRatio(),r=e.viewports[0],s=r.width*i,o=r.height*i,a=[1,1,1,1];(s!==t.width||o!==t.height)&&t.resize({width:s,height:o}),super.render({...e,clearColor:a,target:t,pass:"shadow"})}getLayerParameters(e,t,i){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal"}}shouldDrawLayer(e){return e.props.shadowEnabled!==!1}getShaderModuleProps(e,t,i){return{shadow:{project:i.project,drawToShadowMap:!0}}}};var fF={color:[255,255,255],intensity:1},r1=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],dF=[0,0,0,200/255],fo=class{constructor(e={}){this.id="lighting-effect",this.shadowColor=dF,this.shadow=!1,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;let{device:t,deck:i}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(t),i._addDefaultShaderModule(Pf),this.dummyShadowMap=t.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=void 0,this.directionalLights=[],this.pointLights=[];for(let t in e){let i=e[t];switch(i.type){case"ambient":this.ambientLight=i;break;case"directional":this.directionalLights.push(i);break;case"point":this.pointLights.push(i);break;default:}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(t=>t.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:t,viewports:i,onViewportActive:r,views:s}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let o=0;oo.getShadowMap()),dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{},r={enabled:!0,lights:this._getLights(e)},s=e.props.material;return{shadow:i,lighting:r,phongMaterial:s,gouraudMaterial:s}}cleanup(e){for(let t of this.shadowPasses)t.delete();this.shadowPasses.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(Pf))}_calculateMatrices(){let e=[];for(let t of this.directionalLights){let i=new Ne().lookAt({eye:new tt(t.direction).negate()});e.push(i)}return e}_createShadowPasses(e){for(let t=0;tr&&(s=r);let o=this._pool,a=e.BYTES_PER_ELEMENT*s,c=o.findIndex(l=>l.byteLength>=a);if(c>=0){let l=new e(o.splice(c,1)[0],0,s);return i&&l.fill(0),l}return new e(s)}_release(e){if(!ArrayBuffer.isView(e))return;let t=this._pool,{buffer:i}=e,{byteLength:r}=i,s=t.findIndex(o=>o.byteLength>=r);s<0?t.push(i):(s>0||t.lengththis.opts.poolSize&&t.shift()}},hn=new E_;Fe();function po(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function S_(n,e){let t=n%e;return t<0?e+t:t}function o1(n){return[n[12],n[13],n[14]]}function a1(n){return{left:ho(n[3]+n[0],n[7]+n[4],n[11]+n[8],n[15]+n[12]),right:ho(n[3]-n[0],n[7]-n[4],n[11]-n[8],n[15]-n[12]),bottom:ho(n[3]+n[1],n[7]+n[5],n[11]+n[9],n[15]+n[13]),top:ho(n[3]-n[1],n[7]-n[5],n[11]-n[9],n[15]-n[13]),near:ho(n[3]+n[2],n[7]+n[6],n[11]+n[10],n[15]+n[14]),far:ho(n[3]-n[2],n[7]-n[6],n[11]-n[10],n[15]-n[14])}}var s1=new tt;function ho(n,e,t,i){s1.set(n,e,t);let r=s1.len();return{distance:i/r,normal:new tt(-n/r,-e/r,-t/r)}}function hF(n){return n-Math.fround(n)}var pc;function mo(n,e){let{size:t=1,startIndex:i=0}=e,r=e.endIndex!==void 0?e.endIndex:n.length,s=(r-i)/t;pc=hn.allocate(pc,s,{type:Float32Array,size:t*2});let o=i,a=0;for(;ox.useInPicking),pass:h,canvasContext:m,isPicking:!0,shaderModuleProps:g,clearColor:v??[0,0,0,0],colorMask:15,scissorRect:b});return this._colorEncoderState=null,{decodePickingColor:y&&t6.bind(null,y),stats:w}}shouldDrawLayer(e){let{pickable:t,operation:i}=e.props;return t&&i.includes("draw")||i.includes("terrain")||i.includes("mask")}getShaderModuleProps(e,t,i){return{picking:{isActive:1,isAttribute:this.pickZ,disabledPickingIndices:e.internalState?.disabledPickingIndices},lighting:{enabled:!1}}}getLayerParameters(e,t,i){let r={...e.props.parameters},{pickable:s,operation:o}=e.props;return this._colorEncoderState?s&&o.includes("draw")?(Object.assign(r,e6),r.blend=!0,this.device.type==="webgpu"?r.blendConstant=W1(this._colorEncoderState,e,i):r.blendColor=W1(this._colorEncoderState,e,i),o.includes("terrain")&&e.state?._hasPickingCover&&(r.blendAlphaSrcFactor="one")):o.includes("terrain")&&(r.blend=!1):r.blend=!1,r}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}};function W1(n,e,t){let{byLayer:i,byAlpha:r}=n,s,o=i.get(e);return o?(o.viewports.push(t),s=o.a):(s=i.size+1,s<=255?(o={a:s,layer:e,viewports:[t]},i.set(e,o),r[s]=o):(ae.warn("Too many pickable layers, only picking the first 255")(),s=0)),[0,0,0,s/255]}function t6(n,e){let t=n.byAlpha[e[3]];return t&&{pickedLayer:t.layer,pickedViewports:t.viewports,pickedObjectIndex:t.layer.decodePickingColor(e)}}Ce();var Ki={NO_STATE:"Awaiting state",MATCHED:"Matched. State transferred from previous layer",INITIALIZED:"Initialized",AWAITING_GC:"Discarded. Awaiting garbage collection",AWAITING_FINALIZATION:"No longer matched. Awaiting garbage collection",FINALIZED:"Finalized! Awaiting garbage collection"},wo=Symbol.for("component"),Yn=Symbol.for("propTypes"),Bf=Symbol.for("deprecatedProps"),bi=Symbol.for("asyncPropDefaults"),qn=Symbol.for("asyncPropOriginal"),pn=Symbol.for("asyncPropResolved");function Of(n,e=()=>!0){return Array.isArray(n)?j1(n,e,[]):e(n)?[n]:[]}function j1(n,e,t){let i=-1;for(;++i0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,t){if(e===this._data&&!t)return;this._data=e;let i=++this._loadCount,r=e;typeof e=="string"&&(r=zs(e)),r instanceof Promise?(this.isLoaded=!1,this._loader=r.then(s=>{this._loadCount===i&&(this.isLoaded=!0,this._error=void 0,this._content=s)}).catch(s=>{this._loadCount===i&&(this.isLoaded=!0,this._error=s||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(let s of this._subscribers)s.onChange(this.getData())}};var vc=class{constructor(e){this.protocol=e.protocol||"resource://",this._context={device:e.device,gl:e.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return e.startsWith(this.protocol)?!0:e in this._resources}add({resourceId:e,data:t,forceUpdate:i=!1,persistent:r=!0}){let s=this._resources[e];s?s.setData(t,i):(s=new bc(e,t,this._context),this._resources[e]=s),s.persistent=r}remove(e){let t=this._resources[e];t&&(t.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){let t=this._consumers[e];if(t){for(let i in t){let r=t[i],s=this._resources[r.resourceId];s&&s.unsubscribe(r)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:t,consumerId:i,requestId:r="default"}){let{_resources:s,protocol:o}=this;e.startsWith(o)&&(e=e.replace(o,""),s[e]||this.add({resourceId:e,data:null,persistent:!1}));let a=s[e];if(this._track(i,r,a,t),a)return a.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(let e in this._resources)this._resources[e].delete()}_track(e,t,i,r){let s=this._consumers,o=s[e]=s[e]||{},a=o[t],c=a&&a.resourceId&&this._resources[a.resourceId];c&&(c.unsubscribe(a),this.prune()),i&&(a?(a.onChange=r,a.resourceId=i.id):a={onChange:r,resourceId:i.id},o[t]=a,i.subscribe(a))}_prune(){this._pruneRequest=null;for(let e of Object.keys(this._resources)){let t=this._resources[e];!t.persistent&&!t.inUse()&&(t.delete(),delete this._resources[e])}}};var n6="layerManager.setLayers",i6="layerManager.activateViewport",xc=class{constructor(e,t){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=a=>{De(i6,this,a),a&&(this.context.viewport=a)};let{deck:i,stats:r,viewport:s,timeline:o}=t||{};this.layers=[],this.resourceManager=new vc({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e?.gl,deck:i,shaderAssembler:t1(e?.info?.shadingLanguage||"glsl"),defaultShaderModules:[r_],renderPass:void 0,stats:r||new Vt({id:"deck.gl"}),viewport:s||new go({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:o||new Qr,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(let e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(let i of this.layers){let r=i.getNeedsRedraw(e);t=t||r}return t}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(t=>e.find(i=>t.id.indexOf(i)===0)):this.layers}setProps(e){"debug"in e&&(this._debug=e.debug),"userData"in e&&(this.context.userData=e.userData),"layers"in e&&(this._nextLayers=e.layers),"onError"in e&&(this.context.onError=e.onError)}setLayers(e,t){De(n6,this,t,e),this._lastRenderedLayers=e;let i=Of(e,Boolean);for(let r of i)r.context=this.context;this._updateLayers(this.layers,i)}updateLayers(){let e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){let{defaultShaderModules:t}=this.context;t.find(i=>i.name===e.name)||(t.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){let{defaultShaderModules:t}=this.context,i=t.findIndex(r=>r.name===e.name);i>=0&&(t.splice(i,1),this._defaultShaderModulesChanged=!0)}_handleError(e,t,i){i.raiseError(t,`${e} of ${i}`)}_updateLayers(e,t){let i={};for(let o of e)i[o.id]?ae.warn(`Multiple old layers with same id ${o.id}`)():i[o.id]=o;if(this._defaultShaderModulesChanged){for(let o of e)o.setNeedsUpdate(),o.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}let r=[];this._updateSublayersRecursively(t,i,r),this._finalizeOldLayers(i);let s=!1;for(let o of r)if(o.hasUniformTransition()){s=`Uniform transition in ${o}`;break}this._needsUpdate=s,this.layers=r}_updateSublayersRecursively(e,t,i){for(let r of e){r.context=this.context;let s=t[r.id];s===null&&ae.warn(`Multiple new layers with same id ${r.id}`)(),t[r.id]=null;let o=null;try{this._debug&&s!==r&&r.validateProps(),s?(this._transferLayerState(s,r),this._updateLayer(r)):this._initializeLayer(r),i.push(r),o=r.isComposite?r.getSubLayers():null}catch(a){this._handleError("matching",a,r)}o&&this._updateSublayersRecursively(o,t,i)}}_finalizeOldLayers(e){for(let t in e){let i=e[t];i&&this._finalizeLayer(i)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=Ki.INITIALIZED}catch(t){this._handleError("initialization",t,e)}}_transferLayerState(e,t){t._transferState(e),t.lifecycle=Ki.MATCHED,t!==e&&(e.lifecycle=Ki.AWAITING_GC)}_updateLayer(e){try{e._update()}catch(t){this._handleError("update",t,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=Ki.AWAITING_FINALIZATION;try{e._finalize(),e.lifecycle=Ki.FINALIZED}catch(t){this._handleError("finalization",t,e)}}};function xe(n,e,t){if(n===e)return!0;if(!t||!n||!e)return!1;if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let i=0;i{let i=!e.canvasId||this.getCanvasId(t.id)===e.canvasId,r=!("x"in e)||t.containsPixel(e);return i&&r}):this._viewports}getViews(){let e={};return this.views.forEach(t=>{e[t.id]=t}),e}getView(e){return this.views.find(t=>t.id===e)}getViewState(e){let t=typeof e=="string"?this.getView(e):e,i=t&&this.viewState[t.getViewStateId()]||this.viewState;return t?t.filterViewState(i):i}getViewport(e){return this._viewportMap[e]}getCanvasId(e){let t=typeof e=="string"?this.getView(e):e;return t?this._viewEventManagers[t.id]?.canvasId||this._getCanvasIdFromView(t):void 0}unproject(e,t){let i=this.getViewports(),r={x:e[0],y:e[1]};for(let s=i.length-1;s>=0;--s){let o=i[s];if(o.containsPixel(r)){let a=e.slice();return a[0]-=o.x,a[1]-=o.y,o.unproject(a,t)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),("width"in e||"height"in e)&&this._setSize(e.width,e.height),"pickPosition"in e&&(this._pickPosition=e.pickPosition),"eventManagers"in e&&this._setEventManagers(e.eventManagers||{}),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,t){(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.setNeedsUpdate("Size changed"))}_setViews(e){e=Of(e,Boolean),this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){e?(!xe(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e):ae.warn("missing `viewState` or `initialViewState`")()}_setEventManagers(e){this._eventManagers!==e&&(this._eventManagers=e,this.setNeedsUpdate("eventManagers changed"))}_getCanvasIdFromView(e){return e.props.canvasId||this._getCanvasContext?.(e.id)?.id||Qi}_getCanvasDimensions(e){let t=this._getCanvasContext?.(e.id),[i,r]=t?.getCSSSize()||[this.width,this.height];return{width:i,height:r}}_getViewEventManager(e){let t=this.getCanvasId(e)||Qi;return{canvasId:t,eventManager:this._eventManagers[t]||this._eventManager}}_startViewportRebuild(){let e=this.controllers,t=this._viewEventManagers;return this._viewports=[],this.controllers={},this._viewEventManagers={},{oldControllers:e,oldViewEventManagers:t}}_getReusableController(e,t,i){return e&&(t?.canvasId!==i.canvasId||t?.eventManager!==i.eventManager)?(e.finalize(),null):e}_createController(e,t){let i=t.type;return new i({timeline:this.timeline,eventManager:this._getViewEventManager(e).eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:s=>this.getView(e.id)?.makeViewport({viewState:s,...this._getCanvasDimensions(e)}),pickPosition:(s,o)=>this._pickPosition?.(s,o,e.id)})}_updateController(e,t,i,r){let s=e.controller;if(s&&i){let o={...t,...s,id:e.id,x:i.x,y:i.y,width:i.width,height:i.height};return(!r||r.constructor!==s.type)&&(r=this._createController(e,o)),r&&r.setProps(o),r}return null}_rebuildViewports(){let{views:e}=this,{oldControllers:t,oldViewEventManagers:i}=this._startViewportRebuild(),r=!1;for(let s=e.length;s--;){let o=e[s],{width:a,height:c}=this._getCanvasDimensions(o),l=this._getViewEventManager(o);this._viewEventManagers[o.id]=l;let u=this.getViewState(o),f=o.makeViewport({viewState:u,width:a,height:c}),d=this._getReusableController(t[o.id],i[o.id],l),h=!!o.controller;h&&!d&&(r=!0),(r||!h)&&d&&(d.finalize(),d=null),this.controllers[o.id]=this._updateController(o,u,f,d),f&&this._viewports.unshift(f)}for(let s in t){let o=t[s];o&&!this.controllers[s]&&o.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,t){return e.length!==t.length?!0:e.some((i,r)=>!e[r].equals(t[r]))}};var r6=/^(?:\d+\.?\d*|\.\d+)$/;function vt(n){switch(typeof n){case"number":if(!Number.isFinite(n))throw new Error(`Could not parse position string ${n}`);return{type:"literal",value:n};case"string":try{let e=s6(n);return new z_(e).parseExpression()}catch(e){let t=e instanceof Error?e.message:String(e);throw new Error(`Could not parse position string ${n}: ${t}`)}default:throw new Error(`Could not parse position string ${n}`)}}function F_(n,e){switch(n.type){case"literal":return n.value;case"percentage":return Math.round(n.value*e);case"binary":let t=F_(n.left,e),i=F_(n.right,e);return n.operator==="+"?t+i:t-i;default:throw new Error("Unknown layout expression type")}}function xt(n,e){return F_(n,e)}function s6(n){let e=[],t=0;for(;t="0"&&n<="9"}function q1(n){return n>="a"&&n<="z"||n>="A"&&n<="Z"}function o6(n){return!!(n&&n.type==="symbol"&&(n.value==="+"||n.value==="-"))}function Z1(n,e){let t={...n};for(let i in e)i!=="id"&&(Array.isArray(t[i])&&Array.isArray(e[i])?t[i]=a6(t[i],e[i]):t[i]=e[i]);return t}function a6(n,e){n=n.slice();for(let t=0;t{},K1={mode:"preserve"},c6={mode:"hard"},U_={BREAK:1,SNAP_TO_END:2,IGNORE:3},l6=n=>n,u6=U_.BREAK,Ec=class{constructor(e){this._onTransitionUpdate=t=>{let{time:i,settings:{interpolator:r,startProps:s,endProps:o,duration:a,easing:c}}=t,l=c(i/a),u=r.interpolateProps(s,o,l);this.propsInTransition=this.getControllerState({...this.props,...u},K1).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new mn(e.timeline),this.onViewStateChange=e.onViewStateChange||X1,this.onStateChange=e.onStateChange||X1}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let t=!1,i=this.props;if(this.props=e,!i||this._shouldIgnoreViewportChange(i,e))return!1;if(this._isTransitionEnabled(e)){let r=i;if(this.transition.inProgress){let{interruption:s,endProps:o}=this.transition.settings;r={...i,...s===U_.SNAP_TO_END?o:this.propsInTransition||i}}this._triggerTransition(r,e),t=!0}else this.transition.cancel();return t}updateTransition(){this.transition.update()}_isTransitionEnabled(e){let{transitionDuration:t,transitionInterpolator:i}=e;return(t>0||t==="auto")&&!!i}_isUpdateDueToCurrentTransition(e){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition):!1}_shouldIgnoreViewportChange(e,t){return this.transition.inProgress?this.transition.settings.interruption===U_.IGNORE||this._isUpdateDueToCurrentTransition(t):this._isTransitionEnabled(t)?t.transitionInterpolator.arePropsEqual(e,t):!0}_triggerTransition(e,t){let i=this.getControllerState(e,K1),r=this.getControllerState(t,c6).shortestPathFrom(i),s=t.transitionInterpolator,o=s.getDuration?s.getDuration(e,t):t.transitionDuration;if(o===0)return;let a=s.initializeProps(e,r);this.propsInTransition={};let c={duration:o,easing:t.transitionEasing||l6,interpolator:s,interruption:t.transitionInterruption||u6,startProps:a.start,endProps:a.end,onStart:t.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(t.onTransitionInterrupt),onEnd:this._onTransitionEnd(t.onTransitionEnd)};this.transition.start(c),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return t=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e?.(t)}}};Fe();function me(n,e){if(!n)throw new Error(e||"deck.gl: assertion failed.")}var Sc=class{constructor(e){let{compare:t,extract:i,required:r}=e;this._propsToCompare=t,this._propsToExtract=i||t,this._requiredProps=r}arePropsEqual(e,t){for(let i of this._propsToCompare)if(!(i in e)||!(i in t)||!Nn(e[i],t[i]))return!1;return!0}initializeProps(e,t){let i={},r={};for(let s of this._propsToExtract)(s in e||s in t)&&(i[s]=e[s],r[s]=t[s]);return this._checkRequiredProps(i),this._checkRequiredProps(r),{start:i,end:r}}getDuration(e,t){return t.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(t=>{let i=e[t];me(Number.isFinite(i)||Array.isArray(i),`${t} is required for transition`)})}};Fe();var f6=["longitude","latitude","zoom","bearing","pitch"],d6=["longitude","latitude","zoom"],vi=class extends Sc{constructor(e={}){let t=Array.isArray(e)?e:e.transitionProps,i=Array.isArray(e)?{}:e;i.transitionProps=Array.isArray(t)?{compare:t,required:t}:t||{compare:f6,required:d6},super(i.transitionProps),this.opts=i}initializeProps(e,t){let i=super.initializeProps(e,t),{makeViewport:r,around:s}=this.opts;if(r&&s){let o=r(e),a=r(t),c=o.unproject(s);i.start.around=s,Object.assign(i.end,{around:a.project(c),aroundPosition:c,width:t.width,height:t.height})}return i}interpolateProps(e,t,i){let r={};for(let s of this._propsToExtract)r[s]=cn(e[s]||0,t[s]||0,i);if(t.aroundPosition&&this.opts.makeViewport){let s=this.opts.makeViewport({...t,...r});Object.assign(r,s.panByPosition(t.aroundPosition,cn(e.around,t.around,i)))}return r}};var Zn={transitionDuration:0},h6=300,p6=300,$_=n=>1-(1-n)*(1-n),m6=n=>n===1?1:1-Math.pow(2,-10*n),ts={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],MULTI_PAN:["multipanstart","multipanmove","multipanend"],DOUBLE_CLICK:["dblclick"],DOUBLE_CLICK_DRAG:["dblclickdragstart","dblclickdragmove","dblclickdragend","dblclickdragcancel"],KEYBOARD:["keydown"]},ns={},is=class{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this._multiPanMode=null,this._multiPanStartCenter=null,this._doubleClickDragAnchor=null,this._suppressDoubleClickUntil=0,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.doubleClickDragZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.multiTouchDrag=null,this.trackpadGesture=!1,this.zoomAround="pointer",this.keyboard=!0,this.transitionManager=new Ec({...e,getControllerState:(t,i)=>new this.ControllerState({...t,constraintContext:i,makeViewport:e.makeViewport}),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport,this.pickPosition=e.pickPosition}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){for(let e in this._events)this._events[e]&&this.eventManager?.off(e,this.handleEvent);this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;let t=this._eventStartBlocked;switch(e.type){case"panstart":return t?!1:this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return t||!this._isTrackpadGestureAllowed(e)?!1:this._onPinchStart(e);case"pinchmove":return this._isTrackpadGestureAllowed(e)?this._onPinch(e):!1;case"pinchend":return this._isTrackpadGestureAllowed(e)?this._onPinchEnd(e):!1;case"multipanstart":return t?!1:this._onMultiPanStart(e);case"multipanmove":return this._onMultiPan(e);case"multipanend":return this._onMultiPanEnd(e);case"dblclick":return this._onDoubleClick(e);case"dblclickdragstart":return t?!1:this._onDoubleClickDragStart(e);case"dblclickdragmove":return this._onDoubleClickDrag(e);case"dblclickdragend":case"dblclickdragcancel":return this._onDoubleClickDragEnd(e);case"wheel":return this._onWheel(e);case"keydown":return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){let{x:t,y:i}=this.props,{offsetCenter:r}=e;return[r.x-t,r.y-i]}getZoomPosition(e){if(this.zoomAround==="pointer")return e;let t=this.makeViewport(this.controllerState.getViewportProps()),[i,r]=Xi(t.center,t.pixelProjectionMatrix);return[i,r]}isPointInBounds(e,t){let{width:i,height:r}=this.props;if(t&&t.handled)return!1;let s=e[0]>=0&&e[0]<=i&&e[1]>=0&&e[1]<=r;return s&&t&&t.stopPropagation(),s}isFunctionKeyPressed(e){let{srcEvent:t}=e;return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){let t=setTimeout(()=>{this._eventStartBlocked===t&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=t}setProps(e){e.maxBoundsPadding===void 0&&(e.maxBoundsPadding=null),e.dragMode&&(this.dragMode=e.dragMode);let t=this.props;this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);let{inertia:i}=e;this.inertia=Number.isFinite(i)?i:i===!0?h6:0;let{scrollZoom:r=!0,dragPan:s=!0,dragRotate:o=!0,doubleClickZoom:a=!0,doubleClickDragZoom:c=!1,touchZoom:l=!0,touchRotate:u=!1,multiTouchDrag:f=u?"rotate":null,trackpadGesture:d=!1,zoomAround:h="pointer",keyboard:p=!0}=e,m=!!this.onViewStateChange;if(this.toggleEvents(ts.WHEEL,m&&r),this.toggleEvents(ts.PAN,m),this.toggleEvents(ts.PINCH,m&&(l||f==="rotate")),this.toggleEvents(ts.MULTI_PAN,m&&!!f),this.toggleEvents(ts.DOUBLE_CLICK,m&&a),this.toggleEvents(ts.DOUBLE_CLICK_DRAG,m&&c),this.toggleEvents(ts.KEYBOARD,m&&p),this.scrollZoom=r,this.dragPan=s,this.dragRotate=o,this.doubleClickZoom=a,this.doubleClickDragZoom=c,this.touchZoom=l,this.touchRotate=f==="rotate",this.multiTouchDrag=f,this.trackpadGesture=d,this.zoomAround=h,this.keyboard=p,(!t||t.height!==e.height||t.width!==e.width||t.maxBounds!==e.maxBounds||t.maxBoundsPadding!==e.maxBoundsPadding)&&e.maxBounds){let v=new this.ControllerState({...e,makeViewport:this.makeViewport}),y=v.getViewportProps();Object.keys(y).some(w=>!xe(y[w],e[w],1))&&this.updateViewport(v)}}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,t){this.eventManager&&e.forEach(i=>{this._events[i]!==t&&(this._events[i]=t,t?this.eventManager.on(i,this.handleEvent):this.eventManager.off(i,this.handleEvent))})}updateViewport(e,t=null,i={}){let r={...e.getViewportProps(),...t},s=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(i),s){let o=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:r,interactionState:this._interactionState,oldViewState:o,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_getConstraintContext(e,t){return this.props.rubberBand?{mode:t==="update"?"elastic":t==="end"?"rebound":"hard"}:{mode:"hard"}}_getReboundTransition(e,t){if(e.mode!=="rebound")return null;let i=t.getViewportProps();return Object.keys(i).some(s=>!xe(this.props[s],i[s],1))?{...this._getTransitionProps(),transitionDuration:p6,transitionEasing:m6}:null}_onPanStart(e){let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let i=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(i=!i);let r=i?"pan":"rotate",s=this._getConstraintContext(r,"start"),o=i?this.controllerState.panStart({pos:t},s):this.controllerState.rotateStart({pos:t},s);return this._panMove=i,this.updateViewport(o,Zn,{isDragging:!0}),!0}_onPan(e){return this.isDragging()?this._panMove?this._onPanMove(e):this._onPanRotate(e):!1}_onPanEnd(e){return this.isDragging()?this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e):!1}_onPanMove(e){if(!this.dragPan)return!1;let t=this.getCenter(e),i=this.controllerState.pan({pos:t},this._getConstraintContext("pan","update"));return this.updateViewport(i,Zn,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){let{inertia:t}=this;if(this.dragPan&&t&&e.velocity){let i=this.getCenter(e),r=[i[0]+e.velocityX*t/2,i[1]+e.velocityY*t/2],s=this.controllerState.pan({pos:r}).panEnd();this.updateViewport(s,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:$_},{isDragging:!1,isPanning:!0})}else{let i=this.controllerState,r=this._getConstraintContext("pan","end"),s=i.panEnd(r),o=this._getReboundTransition(r,s);this.updateViewport(s,o,{isDragging:!1,isPanning:!!o})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;let t=this.getCenter(e),i=this.controllerState.rotate({pos:t},this._getConstraintContext("rotate","update"));return this.updateViewport(i,Zn,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){let{inertia:t}=this;if(this.dragRotate&&t&&e.velocity){let i=this.getCenter(e),r=[i[0]+e.velocityX*t/2,i[1]+e.velocityY*t/2],s=this.controllerState.rotate({pos:r}).rotateEnd();this.updateViewport(s,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:$_},{isDragging:!1,isRotating:!0})}else{let i=this.controllerState,r=this._getConstraintContext("rotate","end"),s=i.rotateEnd(r),o=this._getReboundTransition(r,s);this.updateViewport(s,o,{isDragging:!1,isRotating:!!o})}return!0}_onWheel(e){if(!this.scrollZoom||this.trackpadGesture&&e.device!=="mouse")return!1;let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;e.srcEvent.preventDefault();let{speed:i=.01,smooth:r=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:s}=e,o=2/(1+Math.exp(-Math.abs(s*i)));s<0&&o!==0&&(o=1/o);let a=this.getZoomPosition(t),c=r?{...this._getTransitionProps({around:a}),transitionDuration:250}:Zn,l=this.controllerState.zoom({pos:a,scale:o});return this.updateViewport(l,c,{isZooming:!0,isPanning:!0}),r||this._setInteractionState({isZooming:!1,isPanning:!1}),!0}_onMultiPanStart(e){let{multiTouchDrag:t}=this;if(!t||!this._isMultiPanEventAllowed(e,t))return!1;let i=e.offsetCenter;if(!this.isPointInBounds(this.getCenter(e),e))return!1;let r=e.pointerType==="trackpad",s={x:i.x-(r?0:e.deltaX),y:i.y-(r?0:e.deltaY)},o={...e,offsetCenter:s},a=this.getCenter(o),c=t==="pan"?this.controllerState.panStart({pos:a},this._getConstraintContext("pan","start")):this.controllerState.rotateStart({pos:a},this._getConstraintContext("rotate","start"));return this._multiPanMode=t,this._multiPanStartCenter=s,this.updateViewport(c,Zn,{isDragging:!0}),!0}_onMultiPan(e){let{mode:t,event:i}=this._getMultiPanEvent(e);return!t||!i||!this.isDragging()?!1:t==="pan"?this._onPanMove(i):this._onPanRotate(i)}_onMultiPanEnd(e){let{mode:t,event:i}=this._getMultiPanEvent(e);if(!t||!i||!this.isDragging())return this._resetMultiPan(),!1;let r=t==="pan"?this._onPanMoveEnd(i):this._onPanRotateEnd(i);return this._resetMultiPan(),r}_isTrackpadGestureAllowed(e){return e.pointerType!=="trackpad"||this.trackpadGesture}_isMultiPanEventAllowed(e,t){return e.pointerType==="trackpad"?this.trackpadGesture&&(t==="pan"?this.dragPan:this.dragRotate):e.pointerType==="touch"&&(t==="pan"?this.dragPan:this.dragRotate)}_getMultiPanEvent(e){let t=this._multiPanMode,i=this._multiPanStartCenter;return!t||!i?{mode:null,event:null}:{mode:t,event:{...e,offsetCenter:{x:i.x+e.deltaX,y:i.y+e.deltaY}}}}_resetMultiPan(){this._multiPanMode=null,this._multiPanStartCenter=null}_onPinchStart(e){this._doubleClickDragAnchor=null;let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let i=this.controllerState.zoomStart({pos:this.getZoomPosition(t)},this._getConstraintContext("zoom","start")).rotateStart({pos:t},this._getConstraintContext("rotate","start"));return ns._startPinchRotation=e.rotation,ns._lastPinchEvent=e,this.updateViewport(i,Zn,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let t=this.controllerState;if(this.touchZoom){let{scale:i}=e,r=this.getCenter(e);t=t.zoom({pos:this.getZoomPosition(r),scale:i},this._getConstraintContext("zoom","update"))}if(this.touchRotate){let{rotation:i}=e;t=t.rotate({deltaAngleX:ns._startPinchRotation-i},this._getConstraintContext("rotate","update"))}return this.updateViewport(t,Zn,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),ns._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;let{inertia:t}=this,{_lastPinchEvent:i}=ns;if(this.touchZoom&&t&&i&&e.scale!==i.scale){let r=this.getCenter(e),s=this.getZoomPosition(r),o=this.controllerState.rotateEnd(),a=Math.log2(e.scale),c=(a-Math.log2(i.scale))/(e.deltaTime-i.deltaTime),l=Math.pow(2,a+c*t/2);o=o.zoom({pos:s,scale:l}).zoomEnd(),this.updateViewport(o,{...this._getTransitionProps({around:s}),transitionDuration:t,transitionEasing:$_},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(t)}else{let r=this.controllerState,s=this._getConstraintContext("zoom","end"),o=this._getConstraintContext("rotate","end"),a=r.zoomEnd(s).rotateEnd(o),c=this._getReboundTransition(this.touchZoom?s:o,a);this.updateViewport(a,c,{isDragging:!1,isPanning:!!c&&this.touchZoom,isZooming:!!c&&this.touchZoom,isRotating:!!c&&this.touchRotate})}return ns._startPinchRotation=null,ns._lastPinchEvent=null,!0}_onDoubleClick(e){if(!this.doubleClickZoom||Date.now()90&&(e=Math.sign(e)*90),Number.isFinite(n)){let[i,r]=ht([n,e]);return[i,Se(r,0,J1)]}let[,t]=ht([0,e]);return[n,Se(t,0,J1)]}var G_=class extends rs{constructor(e){let{width:t,height:i,latitude:r,longitude:s,zoom:o,bearing:a=0,pitch:c=0,altitude:l=1.5,position:u=[0,0,0],maxZoom:f=20,minZoom:d=0,maxPitch:h=60,minPitch:p=0,startPanLngLat:m,startZoomLngLat:g,startRotatePos:v,startRotateLngLat:y,startBearing:b,startPitch:w,startZoom:E,normalize:x=!0,rubberBand:T=!1}=e,{[Qt]:I}=e;me(Number.isFinite(s)),me(Number.isFinite(r)),me(Number.isFinite(o));let N=e.maxBounds||(x?e2:null),D=e.maxBoundsPadding||null;super({width:t,height:i,latitude:r,longitude:s,zoom:o,bearing:a,pitch:c,altitude:l,maxZoom:f,minZoom:d,maxPitch:h,minPitch:p,normalize:x,position:u,maxBounds:N,maxBoundsPadding:D,rubberBand:T,[Qt]:I},{startPanLngLat:m,startZoomLngLat:g,startRotatePos:v,startRotateLngLat:y,startBearing:b,startPitch:w,startZoom:E},e.makeViewport,e.constraintContext),this.getAltitude=e.getAltitude}panStart({pos:e},t){return this._getUpdatedState({startPanLngLat:this._unproject(e)},t)}pan({pos:e,startPos:t},i){let r=this.getState().startPanLngLat||this._unproject(t);if(!r)return this;let o=this.makeViewport(this.getViewportProps()).panByPosition(r,e);return this._getUpdatedState(o,i)}panEnd(e){return this._getUpdatedState({startPanLngLat:null},e)}rotateStart({pos:e}){let t=this.getAltitude?.(e);return this._getUpdatedState({startRotatePos:e,startRotateLngLat:t!==void 0?this._unproject3D(e,t):void 0,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:t=0,deltaAngleY:i=0}){let{startRotatePos:r,startRotateLngLat:s,startBearing:o,startPitch:a}=this.getState();if(!r||o===void 0||a===void 0)return this;let c;if(e?c=this._getNewRotation(e,r,a,o):c={bearing:o+t,pitch:a+i},s){let l=this.makeViewport({...this.getViewportProps(),...c}),u="panByPosition3D"in l?"panByPosition3D":"panByPosition";return this._getUpdatedState({...c,...l[u](s,r)})}return this._getUpdatedState(c)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startRotateLngLat:null,startBearing:null,startPitch:null})}zoomStart({pos:e},t){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom},t)}zoom({pos:e,startPos:t,scale:i},r){let{startZoom:s,startZoomLngLat:o}=this.getState();return o||(s=this.getViewportProps().zoom,o=this._unproject(t)||this._unproject(e)),o?this._getUpdatedState({zoom:s+Math.log2(i),[Qt]:{position:o,screenPosition:e}},r):this}zoomEnd(e){return this._getUpdatedState({startZoomLngLat:null,startZoom:null},e)}zoomIn(e=2,t){return this._zoomFromCenter(e,t)}zoomOut(e=2,t){return this._zoomFromCenter(1/e,t)}moveLeft(e=100,t){return this._panFromCenter([e,0],t)}moveRight(e=100,t){return this._panFromCenter([-e,0],t)}moveUp(e=100,t){return this._panFromCenter([0,e],t)}moveDown(e=100,t){return this._panFromCenter([0,-e],t)}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){let t=e.getViewportProps(),i={...this.getViewportProps()},{bearing:r,longitude:s}=i;return Math.abs(r-t.bearing)>180&&(i.bearing=r<0?r+360:r-360),Math.abs(s-t.longitude)>180&&(i.longitude=s<0?s+360:s-360),i}applyConstraints(e,t){let i=e,r=i[Qt];delete i[Qt];let{maxPitch:s,minPitch:o,pitch:a,bearing:c,normalize:l,maxBounds:u,rubberBand:f}=e;l&&(c<-180||c>180)&&(e.bearing=S_(c+180,360)-180),e.pitch=Se(a,o,s);let d=this._constrainZoom(e.zoom,e),h=f&&t?.mode==="elastic";if(e.zoom=t?.mode==="preserve"?e.zoom:h?Ji(e.zoom,d,_6):d,r){let p=this.makeViewport(e);Object.assign(e,p.panByPosition(r.position,r.screenPosition))}if(l&&(e.longitude<-180||e.longitude>180)&&(e.longitude=S_(e.longitude+180,360)-180),u){let p=Eo(e.width,e.height,e.maxBoundsPadding),m=this.makeViewport({...e,bearing:0,pitch:0}),g=Df(m,[e.longitude,e.latitude],p),v=Pc(u[0]),y=Pc(u[1]),b=2**e.zoom,w=[v[0]+g.left/b,v[1]+g.bottom/b],E=[y[0]-g.right/b,y[1]-g.top/b],x=Pc([e.longitude,e.latitude]),T=[Se(x[0],w[0],E[0]),Se(x[1],w[1],E[1])],I=x.slice();if(p.width>=0&&(I[0]=t?.mode==="preserve"?x[0]:h?Ji(x[0],T[0],p.width/2/b):T[0]),p.height>=0&&(I[1]=t?.mode==="preserve"?x[1]:h?Ji(x[1],T[1],p.height/2/b):T[1]),I[0]!==x[0]||I[1]!==x[1]){let[N,D]=kt(I);I[0]!==x[0]&&(e.longitude=N),I[1]!==x[1]&&(e.latitude=D)}}return e}_constrainZoom(e,t){t||(t=this.getViewportProps());let{maxZoom:i,maxBounds:r}=t,s=r!==null&&t.width>0&&t.height>0,{minZoom:o}=t;if(s){let a=Eo(t.width,t.height,t.maxBoundsPadding),c=Pc(r[0]),l=Pc(r[1]),u=l[0]-c[0],f=l[1]-c[1];a.width>0&&Number.isFinite(u)&&u>0&&(o=Math.max(o,Math.log2(a.width/u))),a.height>0&&Number.isFinite(f)&&f>0&&(o=Math.max(o,Math.log2(a.height/f))),o>i&&(o=i)}return Se(e,o,i)}_zoomFromCenter(e,t){let{width:i,height:r}=this.getViewportProps();return this.zoom({pos:[i/2,r/2],scale:e},t)}_panFromCenter(e,t){let{width:i,height:r}=this.getViewportProps();return this.pan({startPos:[i/2,r/2],pos:[i/2+e[0],r/2+e[1]]},t)}_getUpdatedState(e,t){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e,constraintContext:t})}_unproject(e){let t=this.makeViewport(this.getViewportProps());return e&&t.unproject(e)}_unproject3D(e,t){return this.makeViewport(this.getViewportProps()).unproject(e,{targetZ:t})}_getNewRotation(e,t,i,r){let s=e[0]-t[0],o=e[1]-t[1],a=e[1],c=t[1],{width:l,height:u}=this.getViewportProps(),f=s/l,d=0;o>0?Math.abs(u-c)>Q1&&(d=o/(c-u)*g6):o<0&&c>Q1&&(d=1-a/c),d=Se(d,-1,1);let{minPitch:h,maxPitch:p}=this.getViewportProps(),m=r+180*f,g=i;return d>0?g=i+d*(p-i):d<0&&(g=i-d*(h-i)),{pitch:g,bearing:m}}},Cc=class extends is{constructor(){super(...arguments),this.ControllerState=G_,this.transition={transitionDuration:300,transitionInterpolator:new vi({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan",this.rotationPivot="center",this._getAltitude=e=>{if(this.rotationPivot==="2d")return 0;if(this.rotationPivot==="3d"&&this.pickPosition){let{x:t,y:i}=this.props,r=this.pickPosition(t+e[0],i+e[1]);if(r&&r.coordinate&&r.coordinate.length>=3)return r.coordinate[2]}}}setProps(e){"rotationPivot"in e&&(this.rotationPivot=e.rotationPivot||"center"),e.getAltitude=this._getAltitude,e.position=e.position||[0,0,0],e.maxBounds=e.maxBounds||(e.normalize===!1?null:e2),super.setProps(e)}updateViewport(e,t=null,i={}){let r=e.getState();i.isDragging&&r.startRotateLngLat?i={...i,rotationPivotPosition:r.startRotateLngLat}:i.isDragging===!1&&(i={...i,rotationPivotPosition:void 0}),super.updateViewport(e,t,i)}};var Nf=class extends es{constructor(e={}){super(e)}getViewportType(){return yi}get ControllerType(){return Cc}};Nf.displayName="MapView";var t2=Nf;var y6=new fo;function b6(n,e){let t=n.order??1/0,i=e.order??1/0;return t-i}var Tc=class{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){let t=this._defaultEffects;if(!t.find(i=>i.id===e.id)){let i=t.findIndex(r=>b6(r,e)>0);i<0?t.push(e):t.splice(i,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&(xe(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}getEffects(){return this._resolvedEffects}_setEffects(e){let t={};for(let r of this.effects)t[r.id]=r;let i=[];for(let r of e){let s=t[r.id],o=r;s&&s!==r?s.setProps?(s.setProps(r.props),o=s):s.cleanup(this._context):s||r.setup(this._context),i.push(o),delete t[r.id]}for(let r in t)t[r].cleanup(this._context);this.effects=i,this._resolvedEffects=i.concat(this._defaultEffects),e.some(r=>r instanceof fo)||this._resolvedEffects.push(y6),this._needsRedraw="effects changed"}finalize(){for(let e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}};var Lc=class extends _i{shouldDrawLayer(e){let{operation:t}=e.props;return t.includes("draw")||t.includes("terrain")}render(e){return this._render(e)}};var v6="deckRenderer.renderLayers",Mc=class{constructor(e,t={}){this.device=e,this.stats=t.stats,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new Lc(e),this.pickLayersPass=new Jr(e),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(e){let t=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,i={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};if(!e.viewports.length){let a=t.render(i),c="stats"in a?a.stats:a;this._updateStats(c);return}i.effects&&this._preRender(i.effects,i);let r=this.lastPostProcessEffect?this.renderBuffers[0]:i.target;this.lastPostProcessEffect&&(i.clearColor=[0,0,0,0],i.clearCanvas=!0);let s=t.render({...i,target:r}),o="stats"in s?s.stats:s;i.effects&&(this.lastPostProcessEffect&&(i.clearCanvas=e.clearCanvas===void 0?!0:e.clearCanvas),this._postRender(i.effects,i)),this.renderCount++,De(v6,this,o,e),this._updateStats(o)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}finalize(){let{renderBuffers:e}=this;for(let t of e)t.delete();e.length=0}_updateStats(e){if(!this.stats)return;let t=0;for(let{visibleCount:i}of e)t+=i;this.stats.get("Layers rendered").addCount(t)}_preRender(e,t){this.lastPostProcessEffect=null,t.preRenderStats=t.preRenderStats||{};for(let i of e)t.preRenderStats[i.id]=i.preRender(t),i.postRender&&(this.lastPostProcessEffect=i.id);this.lastPostProcessEffect&&this._resizeRenderBuffers(t.canvasContext)}_resizeRenderBuffers(e=this.device.canvasContext){let{renderBuffers:t}=this,i=e.getDrawingBufferSize(),[r,s]=i;t.length===0&&[0,1].map(o=>{let a=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"},width:r,height:s});t.push(this.device.createFramebuffer({id:`deck-renderbuffer-${o}`,colorAttachments:[a]}))});for(let o of t)o.resize(i)}_postRender(e,t){let{renderBuffers:i}=this,r=t.target??t.canvasContext?.getCurrentFramebuffer()??t.target,s={...t,inputBuffer:i[0],swapBuffer:i[1]};for(let o of e)if(o.postRender){s.target=o.id===this.lastPostProcessEffect?r:void 0;let a=o.postRender(s);s.inputBuffer=a,s.swapBuffer=a===i[0]?i[1]:i[0]}}};ee();var x6={pickedColor:null,pickedObjectIndex:-1};function V_({pickedColors:n,decodePickingColor:e,deviceX:t,deviceY:i,deviceRadius:r,deviceRect:s}){let{x:o,y:a,width:c,height:l}=s,u=r*r,f=-1,d=0;for(let h=0;hu)d+=4*c;else for(let g=0;g=0){let y=g+o-t,b=y*y+m;b<=u&&(u=b,f=d)}d+=4}}if(f>=0){let h=n.slice(f,f+4),p=e(h);if(p){let m=Math.floor(f/4/c),g=f/4-m*c;return{...p,pickedColor:h,pickedX:o+g,pickedY:a+m}}ae.error("Picked non-existent layer. Is picking buffer corrupt?")()}return x6}function W_({pickedColors:n,decodePickingColor:e}){let t=new Map;if(n){for(let i=0;i=0){let s=n.slice(i,i+4),o=s.join(",");if(!t.has(o)){let a=e(s);a?t.set(o,{...a,color:s}):ae.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(t.values())}function Ff({pickInfo:n,viewports:e,pixelRatio:t,x:i,y:r,z:s}){let o=e[0];e.length>1&&(o=w6(n?.pickedViewports||e,{x:i,y:r}));let a;if(o){let c=[i-o.x,r-o.y];s!==void 0&&(c[2]=s),a=o.unproject(c)}return{color:null,layer:null,viewport:o,index:-1,picked:!1,x:i,y:r,pixel:[i,r],coordinate:a,devicePixel:n&&"pickedX"in n?[n.pickedX,n.pickedY]:void 0,pixelRatio:t}}function j_(n){let{pickInfo:e,lastPickedInfo:t,mode:i,layers:r}=n,{pickedColor:s,pickedLayer:o,pickedObjectIndex:a}=e,c=o?[o]:[];if(i==="hover"){let f=t.index,d=t.layerId,h=o?o.props.id:null;if(h!==d||a!==f){if(h!==d){let p=r.find(m=>m.props.id===d);p&&c.unshift(p)}t.layerId=h,t.index=a,t.info=null}}let l=Ff(n),u=new Map;return u.set(null,l),c.forEach(f=>{let d={...l};f===o&&(d.color=s,d.index=a,d.picked=!0),d=zf({layer:f,info:d,mode:i});let h=d.layer;f===o&&i==="hover"&&(t.info=d),u.set(h.id,d),i==="hover"&&h.updateAutoHighlight(d)}),u}function zf({layer:n,info:e,mode:t}){for(;n&&e;){let i=e.layer||null;e.sourceLayer=i,e.layer=n,e=n.getPickingInfo({info:e,mode:t,sourceLayer:i}),n=n.parent}return e}function w6(n,e){for(let t=n.length-1;t>=0;t--){let i=n[t];if(i.containsPixel(e))return i}return n[0]}var Ac=class{constructor(e,t={}){this._pickable=!0,this.device=e,this.stats=t.stats,this.pickLayersPass=new Jr(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){"layerFilter"in e&&(this.layerFilter=e.layerFilter),"_pickable"in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObjectAsync(e){return this._pickClosestObjectAsync(e)}pickObjectsAsync(e){return this._pickVisibleObjectsAsync(e)}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:t,layers:i,viewports:r},s=this.lastPickedInfo.info){let o=s&&s.layer&&s.layer.id,a=s&&s.viewport&&s.viewport.id,c=o?i.find(d=>d.id===o):null,l=a&&r.find(d=>d.id===a)||r[0],u=l&&l.unproject([e-l.x,t-l.y]);return{...s,...{x:e,y:t,viewport:l,coordinate:u,layer:c}}}_resizeBuffer(e=this.device.getDefaultCanvasContext()){if(!this.pickingFBO){let r=this.device.createTexture({format:"rgba8unorm",width:1,height:1,usage:pe.RENDER_ATTACHMENT|pe.COPY_SRC});if(this.pickingFBO=this.device.createFramebuffer({colorAttachments:[r],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float")){let s=this.device.createTexture({format:"rgba32float",width:1,height:1,usage:pe.RENDER_ATTACHMENT|pe.COPY_SRC}),o=this.device.createFramebuffer({colorAttachments:[s],depthStencilAttachment:"depth16unorm"});this.depthFBO=o}}let[t,i]=e.getDrawingBufferSize();this.pickingFBO?.resize({width:t,height:i}),this.depthFBO?.resize({width:t,height:i})}_getPickable(e){if(this._pickable===!1)return null;let t=e.filter(i=>this.pickLayersPass.shouldDrawLayer(i)&&!i.isComposite);return t.length?t:null}async _pickClosestObjectAsync({layers:e,views:t,viewports:i,x:r,y:s,radius:o=0,depth:a=1,mode:c="query",unproject3D:l,canvasContext:u=this.device.getDefaultCanvasContext(),onViewportActive:f,effects:d}){let h=u.cssToDeviceRatio(),p=this._getPickable(e);if(!p||i.length===0)return{result:[],emptyInfo:Ff({viewports:i,x:r,y:s,pixelRatio:h})};this._resizeBuffer(u);let m=u.cssToDevicePixels([r,s],!0),g=[m.x+Math.floor(m.width/2),m.y+Math.floor(m.height/2)],v=Math.round(o*h),{width:y,height:b}=this.pickingFBO,w=this._getPickingRect({deviceX:g[0],deviceY:g[1],deviceRadius:v,deviceWidth:y,deviceHeight:b}),E={x:r-o,y:s-o,width:o*2+1,height:o*2+1},x,T=[],I=new Set;for(let N=0;N0){let{pickedColors:V}=await this._drawAndSampleAsync({layers:W,views:t,viewports:i,onViewportActive:f,deviceRect:{x:D.pickedX??g[0],y:D.pickedY??g[1],width:1,height:1},cullRect:E,effects:d,pass:`picking:${c}:z`,canvasContext:u},!0);V[3]&&(H=V[0])}D.pickedLayer&&N+10){let{pickedColors:V}=this._drawAndSample({layers:W,views:t,viewports:i,onViewportActive:f,deviceRect:{x:D.pickedX??g[0],y:D.pickedY??g[1],width:1,height:1},cullRect:E,effects:d,pass:`picking:${c}:z`,canvasContext:u},!0);V[3]&&(H=V[0])}D.pickedLayer&&N+1=l);H++){let W=T[H],V={color:W.pickedColor,layer:null,index:W.pickedObjectIndex,picked:!0,x:r,y:s,pixelRatio:p};V=zf({layer:W.pickedLayer,info:V,mode:c});let X=V.layer.id;I.has(X)||I.set(X,new Set);let Y=I.get(X),ie=V.object??V.index;Y.has(ie)||(Y.add(ie),N.push(V))}return N}_pickVisibleObjects({layers:e,views:t,viewports:i,x:r,y:s,width:o=1,height:a=1,mode:c="query",maxObjects:l=null,canvasContext:u=this.device.getDefaultCanvasContext(),onViewportActive:f,effects:d}){let h=this._getPickable(e);if(!h||i.length===0)return[];this._resizeBuffer(u);let p=u.cssToDeviceRatio(),m=u.cssToDevicePixels([r,s],!0),g=m.x,v=m.y+m.height,y=u.cssToDevicePixels([r+o,s+a],!0),b=y.x+y.width,w=y.y,E={x:g,y:w,width:b-g,height:v-w},x=this._drawAndSample({layers:h,views:t,viewports:i,onViewportActive:f,deviceRect:E,cullRect:{x:r,y:s,width:o,height:a},effects:d,pass:`picking:${c}`,canvasContext:u}),T=W_(x),I=new Map,N=[],D=Number.isFinite(l);for(let H=0;H=l);H++){let W=T[H],V={color:W.pickedColor,layer:null,index:W.pickedObjectIndex,picked:!0,x:r,y:s,pixelRatio:p};V=zf({layer:W.pickedLayer,info:V,mode:c});let X=V.layer.id;I.has(X)||I.set(X,new Set);let Y=I.get(X),ie=V.object??V.index;Y.has(ie)||(Y.add(ie),N.push(V))}return N}async _drawAndSampleAsync({layers:e,views:t,viewports:i,onViewportActive:r,deviceRect:s,cullRect:o,effects:a,pass:c,canvasContext:l},u=!1){let f=u?this.depthFBO:this.pickingFBO,d={layers:e,layerFilter:this.layerFilter,views:t,viewports:i,onViewportActive:r,pickingFBO:f,deviceRect:s,cullRect:o,effects:a,pass:c,canvasContext:l,pickZ:u,preRenderStats:{},isPicking:!0};for(let E of a)E.useInPicking&&(d.preRenderStats[E.id]=E.preRender(d));let{decodePickingColor:h,stats:p}=this.pickLayersPass.render(d);this._updateStats(p);let{x:m,y:g,width:v,height:y}=s,b=f.colorAttachments[0]?.texture;if(!b)throw new Error("Picking framebuffer color attachment is missing");let w=await this._readTextureDataAsync(b,{x:m,y:g,width:v,height:y},u?Float32Array:Uint8Array);if(!u){let E=!1;for(let x=3;x0&&ae.warn("Async pick readback returned only zero alpha values",{deviceRect:s,bytes:Array.from(w.subarray(0,Math.min(w.length,16)))})()}return{pickedColors:w,decodePickingColor:h}}async _readTextureDataAsync(e,t,i){let{width:r,height:s}=t,o=e.computeMemoryLayout(t),a=this.device.createBuffer({byteLength:o.byteLength,usage:re.COPY_DST|re.MAP_READ});try{e.readBuffer(t,a);let c=await a.readAsync(0,o.byteLength),l=i.BYTES_PER_ELEMENT;if(o.bytesPerRow%l!==0)throw new Error(`Texture readback row stride ${o.bytesPerRow} is not aligned to ${l}-byte elements.`);let u=new i(c.buffer,c.byteOffset,o.byteLength/l),f=r*4,d=o.bytesPerRow/l;if(do.props.operation.includes("terrain"))}_getPickingRect({deviceX:e,deviceY:t,deviceRadius:i,deviceWidth:r,deviceHeight:s}){let o=Math.max(0,e-i),a=Math.max(0,t-i),c=Math.min(r,e+i+1)-o,l=Math.min(s,t+i+1)-a;return c<=0||l<=0?null:{x:o,y:a,width:c,height:l}}};var E6={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},S6="top-left",n2="root",Uf=class{constructor({deck:e,parentElement:t}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,t?.classList.add("deck-widget-container"),this.parentElement=t}getWidgets(){return this.resolvedWidgets}setProps(e){if(e.widgets&&!xe(e.widgets,this.widgets,1)){let t=e.widgets.filter(Boolean);this._setWidgets(t)}}finalize(){for(let e of this.getWidgets())this._removeWidget(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(let e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(t=>t.id===e.id)||(this._addWidget(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}onRedraw({viewports:e,layers:t}){let i=e.reduce((r,s)=>(r[s.id]=s,r),{});for(let r of this.getWidgets()){let{viewId:s}=r;if(s){let o=i[s];o&&(r.onViewportChange&&r.onViewportChange(o),r.onRedraw?.({viewports:[o],layers:t}))}else{if(r.onViewportChange)for(let o of e)r.onViewportChange(o);r.onRedraw?.({viewports:e,layers:t})}}this.lastViewports=i,this._updateContainers()}onHover(e,t){for(let i of this.getWidgets()){let{viewId:r}=i;(!r||r===e.viewport?.id)&&i.onHover?.(e,t)}}getCanvasBounds(e){let i=this.deck?.getCanvas?.()?.getBoundingClientRect(),r=this.parentElement?.getBoundingClientRect(),s=this.deck?.getCanvasContext?.(e?.id);if(s&&r){s.updatePosition();let[o,a]=s.getPosition(),[c,l]=s.getCSSSize();return{x:o-r.left,y:a-r.top,width:c,height:l}}return{x:i&&r?i.left-r.left:0,y:i&&r?i.top-r.top:0,width:i?.width||this.deck?.width||0,height:i?.height||this.deck?.height||0}}onEvent(e,t){let i=ao[t.type];if(i)for(let r of this.getWidgets()){let{viewId:s}=r;(!s||s===e.viewport?.id)&&r[i]?.(e,t)}}_setWidgets(e){let t={};for(let i of this.resolvedWidgets)t[i.id]=i;this.resolvedWidgets.length=0;for(let i of this.defaultWidgets)t[i.id]=null,this.resolvedWidgets.push(i);for(let i of e){let r=t[i.id];r?r.viewId!==i.viewId||r.placement!==i.placement?(this._removeWidget(r),this._addWidget(i)):i!==r&&(r.setProps(i.props),i=r):this._addWidget(i),t[i.id]=null,this.resolvedWidgets.push(i)}for(let i in t){let r=t[i];r&&this._removeWidget(r)}this.widgets=e}_addWidget(e){let{viewId:t=null,placement:i=S6}=e,r=e.props._container??t;e.widgetManager=this,e.deck=this.deck,e.rootElement=e._onAdd({deck:this.deck,viewId:t}),e.rootElement&&this._getContainer(r,i).append(e.rootElement),e.updateHTML()}_removeWidget(e){e.onRemove?.(),e.rootElement&&e.rootElement.remove(),e.rootElement=void 0,e.deck=void 0,e.widgetManager=void 0}_getContainer(e,t){if(e&&typeof e!="string")return e;let i=e||n2,r=this.containers[i];r||(r=document.createElement("div"),r.style.pointerEvents="none",r.style.position="absolute",r.style.overflow="hidden",this.parentElement?.append(r),this.containers[i]=r);let s=r.querySelector(`.${t}`);return s||(s=globalThis.document.createElement("div"),s.className=t,s.style.position="absolute",s.style.zIndex="2",Object.assign(s.style,E6[t]),r.append(s)),s}_updateContainers(){for(let e in this.containers){let t=this.lastViewports[e]||null,i=e===n2||t,r=this.containers[e];if(i){let s=this._getContainerBounds(t);r.style.display="block",r.style.left=`${s.x}px`,r.style.top=`${s.y}px`,r.style.width=`${s.width}px`,r.style.height=`${s.height}px`}else r.style.display="none"}}_getContainerBounds(e){if(!e)return{x:0,y:0,width:this.parentElement?.clientWidth||this.deck.width,height:this.parentElement?.clientHeight||this.deck.height};let t=this.getCanvasBounds(e);return{x:t.x+e.x,y:t.y+e.y,width:e.width,height:e.height}}};function H_(n,e){e&&Object.entries(e).map(([t,i])=>{t.startsWith("--")?n.style.setProperty(t,i):n.style[t]=i})}function i2(n,e){e&&Object.keys(e).map(t=>{t.startsWith("--")?n.style.removeProperty(t):n.style[t]=""})}var So=class{constructor(e){this.viewId=null,this.props={...this.constructor.defaultProps,...e},this.id=this.props.id}setProps(e){let t=this.props,i=this.rootElement;i&&t.className!==e.className&&(t.className&&i.classList.remove(t.className),e.className&&i.classList.add(e.className)),i&&!xe(t.style,e.style,1)&&(i2(i,t.style),H_(i,e.style)),Object.assign(this.props,e),this.updateHTML()}updateHTML(){this.rootElement&&this.onRenderHTML(this.rootElement)}get viewIds(){return this.viewId?[this.viewId]:this.deck?.getViews().map(e=>e.id)??[]}getViewState(e){return this.deck?.viewManager?.getViewState(e)||{}}setViewState(e,t){this.deck?._onViewStateChange({viewId:e,viewState:t,interactionState:{}})}onCreateRootElement(){let e=["deck-widget",this.className,this.props.className],t=document.createElement("div");return e.filter(i=>typeof i=="string"&&i.length>0).forEach(i=>t.classList.add(i)),H_(t,this.props.style),t}_onAdd(e){return this.onAdd(e)??this.onCreateRootElement()}onAdd(e){}onRemove(){}onViewportChange(e){}onRedraw(e){}onHover(e,t){}onClick(e,t){}onDrag(e,t){}onDragStart(e,t){}onDragEnd(e,t){}};So.defaultProps={id:"widget",style:{},_container:null,className:""};var P6={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"},kc=class extends So{constructor(e={}){super(e),this.id="default-tooltip",this.placement="fill",this.className="deck-tooltip",this.isVisible=!1,this.setProps(e)}onCreateRootElement(){let e=document.createElement("div");return e.className=this.className,Object.assign(e.style,P6),e}onRenderHTML(e){}onViewportChange(e){this.isVisible&&e.id===this.lastViewport?.id&&!e.equals(this.lastViewport)&&this.setTooltip(null),this.lastViewport=e}onHover(e){let{deck:t}=this,i=t&&t.props.getTooltip;if(!i)return;let r=i(e),s=this.widgetManager?.getCanvasBounds(e.viewport),o=e.x+(s?.x||0),a=e.y+(s?.y||0);this.setTooltip(r,o,a)}setTooltip(e,t,i){let r=this.rootElement;if(r){if(typeof e=="string")r.innerText=e;else if(e)e.text&&(r.innerText=e.text),e.html&&(r.innerHTML=e.html),e.className&&(r.className=e.className);else{this.isVisible=!1,r.style.display="none";return}this.isVisible=!0,r.style.display="block",r.style.transform=`translate(${t}px, ${i}px)`,e&&typeof e=="object"&&"style"in e&&Object.assign(r.style,e.style)}}};kc.defaultProps={...So.defaultProps};var Rc=class{constructor(e){this.targets={},this.order=[],this.eventManagers={},this._eventRootToCanvasId=new WeakMap,this._createEventManager=e.createEventManager,this._getEventRoot=e.getEventRoot}finalize(){for(let e of Object.values(this.targets))e.eventManager.destroy(),e.presentationContext.destroy();this.targets={},this.order=[],this.eventManagers={},this._eventRootToCanvasId=new WeakMap}syncCanvasEntries(e){let t=this._normalizeCanvasList(e.canvases),i={},r=[],s=new Map;for(let{canvas:a}of t){let c=this._getEventRoot(a);s.set(c,(s.get(c)||0)+1)}for(let{id:a,canvas:c}of t){let l=this._getEventRoot(c),u=s.get(l)===1?l:c,f=this.targets[a];if(!f||f.device!==e.device||f.canvas!==c||f.eventRoot!==u){f?.eventManager.destroy(),f?.presentationContext.destroy();let d=e.device.createPresentationContext({id:a,canvas:c,useDevicePixels:e.useDevicePixels,autoResize:!0});f={id:a,device:e.device,canvas:c,eventRoot:u,presentationContext:d,eventManager:this._createEventManager(u)}}this._eventRootToCanvasId.set(u,a),this._eventRootToCanvasId.set(c,a),i[a]=f,r.push(a)}for(let[a,c]of Object.entries(this.targets))i[a]||(c.eventManager.destroy(),c.presentationContext.destroy());this.targets=i,this.order=r;let o=Object.fromEntries(Object.entries(i).map(([a,c])=>[a,c.eventManager]));this._haveSameEventManagers(o)||(this.eventManagers=o)}getCanvasIdFromEvent(e){return e?this._eventRootToCanvasId.get(e):void 0}getTarget(e){return this.targets[e||this.order[0]||Qi]||null}_normalizeCanvasList(e=[]){let t=new Set;return e.map((i,r)=>{let s,o;return typeof i=="string"?(s=document.getElementById(i),me(s,`Canvas with id ${i} not found`),o=i):(s=i,o=s.id||`deckgl-canvas-${r}`),me(!t.has(o),`Duplicate canvas id ${o}`),t.add(o),{id:o,canvas:s}})}_haveSameEventManagers(e){let t=Object.keys(e),i=Object.keys(this.eventManagers);return t.length===i.length&&t.every(r=>e[r]===this.eventManagers[r])}};ee();yd();Ce();Ce();la();function xi(){}var Dz=({isDragging:n})=>n?"grabbing":"grab",MP={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,pickAsync:"auto",layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{},gl:null,canvas:null,_canvases:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:xi,onWebGLInitialized:xi,onResize:xi,onViewStateChange:xi,onInteractionStateChange:xi,onBeforeRender:xi,onAfterRender:xi,onLoad:xi,onError:n=>ae.error(n.message,n.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:Dz,getTooltip:null,debug:!1,drawPickingColors:!1},Wc=class{constructor(e){this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.eventManagers={},this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this._canvasContext=null,this._deviceResizeHandler=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new Vt({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,layersCount:0,drawLayersCount:0,updateLayersCount:0,updateAttributesCount:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,pickLayersCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._hoverPickSequence=0,this._pointerDownPickSequence=0,this._needsRedraw="Initial render",this._canvasManager=new Rc({createEventManager:r=>this._createEventManager(r),getEventRoot:r=>this._getEventRoot(r)}),this._ownedCanvas=null,this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,canvasId:void 0,event:null,unproject3D:!1},this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this._onPointerMove=r=>{let{_pickRequest:s}=this,o=this._getCanvasIdFromEvent(r);if(r.type==="pointerleave")s.x=-1,s.y=-1,s.radius=0,s.canvasId=o;else{if(r.leftButton||r.rightButton)return;{let a=r.offsetCenter;if(!a)return;s.x=a.x,s.y=a.y,s.radius=this.props.pickingRadius,s.canvasId=o}}this.layerManager&&(this.layerManager.context.mousePosition={x:s.x,y:s.y}),s.event=r},this._onEvent=r=>{let s=ao[r.type],o=r.offsetCenter,a=this._getCanvasIdFromEvent(r);if(!s||!o||!this.layerManager)return;let c=this.layerManager.getLayers(),l=this._getInternalPickingMode();if(!l)return;if(l==="sync"){let f=r.type==="click"&&this._shouldUnproject3D(c)?this._getFirstPickedInfo(this._pickPointSync(this._getPointPickOptions(o.x,o.y,{unproject3D:!0,canvasId:a},c))):this._getLastPointerDownPickingInfo(o.x,o.y,a,c);this._dispatchPickingEvent(f,r);return}(this._lastPointerDownInfoPromise||Promise.resolve(this._getLastPointerDownPickingInfo(o.x,o.y,a,c))).then(f=>{this._dispatchPickingEvent(f,r)}).catch(f=>this.props.onError?.(f))},this._onPointerDown=r=>{let s=r.offsetCenter,o=this._getCanvasIdFromEvent(r);if(!s)return;let a=this._getInternalPickingMode();if(!a)return;let c=this.layerManager?.getLayers()||[],l=++this._pointerDownPickSequence;if(a==="sync"){let f=this._pickPointSync({x:s.x,y:s.y,canvasId:o,radius:this.props.pickingRadius}),d=this._getFirstPickedInfo(f);this._lastPointerDownInfo=d,this._lastPointerDownInfoPromise=Promise.resolve(d);return}let u=this._pickPointAsync(this._getPointPickOptions(s.x,s.y,{canvasId:o},c)).then(f=>this._getFirstPickedInfo(f)).then(f=>(l===this._pointerDownPickSequence&&(this._lastPointerDownInfo=f),f)).catch(f=>{this.props.onError?.(f);let d=this.deckPicker&&this.viewManager?this._getLastPointerDownPickingInfo(s.x,s.y,o,c):{};return l===this._pointerDownPickSequence&&(this._lastPointerDownInfo=d),d});this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=u};let t=e;this.props={...MP,...e},e=this.props,this._validateCanvasConfiguration(e),e.viewState&&e.initialViewState&&ae.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,e.device&&(this.device=e.device,this._setDeviceCanvasContext(e.device));let i=this.device;!i&&e.gl&&(e.gl instanceof WebGLRenderingContext&&ae.error("WebGL1 context not supported.")(),i=Vc.attach(e.gl,{_cacheShaders:!0,_cachePipelines:!0,...this.props.deviceProps})),i||(i=this._createDevice(e)),this.animationLoop=this._createAnimationLoop(i,e),this.setProps(t),e._typedArrayManagerProps&&hn.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){this._restoreDeviceResizeHandler(),this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._hoverPickSequence++,this._pointerDownPickSequence++,this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this.layerManager?.finalize(),this.layerManager=null,this.viewManager?.finalize(),this.viewManager=null,this.effectManager?.finalize(),this.effectManager=null,this.deckRenderer?.finalize(),this.deckRenderer=null,this.deckPicker?.finalize(),this.deckPicker=null,Object.keys(this._canvasManager.targets).length||this.eventManager?.destroy(),this.eventManager=null,this.eventManagers={},this.widgetManager?.finalize(),this.widgetManager=null,this._canvasManager.finalize(),this._isMultiCanvasMode()?this.canvas=null:this.canvas&&this.canvas===this._ownedCanvas&&(this.canvas.parentElement?.removeChild(this.canvas),this.canvas=null,this._ownedCanvas=null),this._canvasContext=null}setProps(e){this.stats.get("setProps Time").timeStart(),"onLayerHover"in e&&ae.removed("onLayerHover","onHover")(),"onLayerClick"in e&&ae.removed("onLayerClick","onClick")(),e.initialViewState&&!xe(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),me(!("_canvases"in e)||Array.isArray(e._canvases)===this._isMultiCanvasMode()),Object.assign(this.props,e),this._validateCanvasConfiguration(this.props),this._validateInternalPickingMode(),this.device&&this._isMultiCanvasMode()&&this._syncCanvasTargets(),this._setCanvasSize(this.props);let t=Object.create(this.props);if(Object.assign(t,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState(),eventManagers:this.eventManagers}),e.device&&e.device.id!==this.device?.id){let i=e.device.getDefaultCanvasContext();this.animationLoop?.stop(),!this._isMultiCanvasMode()&&this.canvas!==i.canvas&&(this.canvas?.remove(),this.eventManager?.destroy(),this.canvas=null),this._setDeviceCanvasContext(e.device),ae.log(`recreating animation loop for new device! id=${e.device.id}`)(),this.animationLoop=this._createAnimationLoop(e.device,e),this.animationLoop.start()}if(this.animationLoop?.setProps(t),e.useDevicePixels!==void 0&&this._canvasContext?.setProps){this._canvasContext.setProps({useDevicePixels:e.useDevicePixels});for(let i of Object.values(this._canvasManager.targets))i.presentationContext.setProps({useDevicePixels:e.useDevicePixels})}this.layerManager&&(this.viewManager.setProps(t),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(t),this.effectManager.setProps(t),this.deckRenderer.setProps(t),this.deckPicker.setProps(t),this.widgetManager.setProps(t)),this.stats.get("setProps Time").timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);let i=this.viewManager.needsRedraw(e),r=this.layerManager.needsRedraw(e),s=this.effectManager.needsRedraw(e),o=this.deckRenderer.needsRedraw(e);return t=t||i||r||s||o,t}redraw(e){if(!this.layerManager)return;let t=this.needsRedraw({clearRedrawFlags:!0});t=e||t,t&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(t):this._drawLayers(t))}get isInitialized(){return this.viewManager!==null}getViews(){return me(this.viewManager),this.viewManager.views}getView(e){return me(this.viewManager),this.viewManager.getView(e)}getViewports(e){return me(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}getCanvasContext(e){let t=e?this.viewManager?.getView(e)?.props.canvasId:void 0;return this._getCanvasContext(t)}getEventManager(e){if(!e||!this.viewManager)return this.eventManager;let t=this.viewManager.getCanvasId(e)||Qi;return this.eventManagers[t]||this.eventManager}async pickObjectAsync(e){let t=(await this._pickAsync("pickObjectAsync","pickObject Time",e)).result;return t.length?t[0]:null}async pickObjectsAsync(e){return await this._pickAsync("pickObjectsAsync","pickObjects Time",e)}pickObject(e){let t=this._pick("pickObject","pickObject Time",e).result;return t.length?t[0]:null}pickMultipleObjects(e){return e.depth=e.depth||10,this._pick("pickObject","pickMultipleObjects Time",e).result}pickObjects(e){return this._pick("pickObjects","pickObjects Time",e)}_pickPositionForController(e,t,i){return this._getInternalPickingMode()!=="sync"?null:this.pickObject({x:e,y:t,radius:0,unproject3D:!0,canvasId:i?this.viewManager?.getCanvasId(i):void 0})}_addResources(e,t=!1){for(let i in e)this.layerManager.resourceManager.add({resourceId:i,data:e[i],forceUpdate:t})}_removeResources(e){for(let t of e)this.layerManager.resourceManager.remove(t)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_addDefaultShaderModule(e){this.layerManager.addDefaultShaderModule(e)}_removeDefaultShaderModule(e){this.layerManager?.removeDefaultShaderModule(e)}_resolveInternalPickingMode(){let{pickAsync:e}=this.props,t=this.device?.type||this.props.deviceProps?.type;if(e==="auto")return t==="webgpu"?"async":"sync";if(e==="sync"&&t==="webgpu")throw new Error('`pickAsync: "sync"` is not supported when Deck is using a WebGPU device.');return e}_getInternalPickingMode(){try{return this._resolveInternalPickingMode()}catch(e){return this.props.onError?.(e),null}}_validateInternalPickingMode(){this._getInternalPickingMode()}_getFirstPickedInfo({result:e,emptyInfo:t}){return e[0]||t}_shouldUnproject3D(e=this.layerManager?.getLayers()||[]){return e.some(t=>t.props.pickable==="3d")}_getPointPickOptions(e,t,i={},r=this.layerManager?.getLayers()||[]){return{x:e,y:t,canvasId:i.canvasId,radius:this.props.pickingRadius,unproject3D:this._shouldUnproject3D(r),...i}}_pickPointSync(e){return this._pick("pickObject","pickObject Time",e)}_pickPointAsync(e){return this._pickAsync("pickObjectAsync","pickObject Time",e)}_getLastPointerDownPickingInfo(e,t,i,r=this.layerManager?.getLayers()||[]){return this.deckPicker.getLastPickedObject({x:e,y:t,layers:r,viewports:this.getViewports({x:e,y:t,canvasId:i})},this._lastPointerDownInfo)}_applyHoverCallbacks({result:e,emptyInfo:t},i){if(!this.widgetManager)return;this.cursorState.isHovering=e.length>0;let r=t,s=!1;for(let o of e)r=o,s=o.layer?.onHover(o,i)||s;s||(this.props.onHover?.(r,i),this.widgetManager.onHover(r,i))}_dispatchPickingEvent(e,t){if(!this.layerManager||!this.widgetManager)return;let i=ao[t.type];if(!i)return;let{layer:r}=e,s=r&&(r[i]||r.props[i]),o=this.props[i],a=!1;s&&(a=s.call(r,e,t)),a||(o?.(e,t),this.widgetManager.onEvent(e,t))}_pickAsync(e,t,i){me(this.deckPicker);let{stats:r}=this,s=this._isMultiCanvasMode()?i.canvasId||this._getDefaultCanvasId():i.canvasId,o=this._getCanvasContext(s)||void 0;r.get("Pick Count").incrementCount(),r.get(t).timeStart(),this._resizeForCanvasTarget(s);let a=this.deckPicker[e]({layers:this.layerManager.getLayers(i),views:this.viewManager.getViews(),viewports:this.getViewports({...i,canvasId:s}),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...i,canvasId:s,canvasContext:o});return r.get(t).timeEnd(),a}_pick(e,t,i){me(this.deckPicker);let{stats:r}=this,s=this._isMultiCanvasMode()?i.canvasId||this._getDefaultCanvasId():i.canvasId,o=this._getCanvasContext(s)||void 0;r.get("Pick Count").incrementCount(),r.get(t).timeStart(),this._resizeForCanvasTarget(s);let a=this.deckPicker[e]({layers:this.layerManager.getLayers(i),views:this.viewManager.getViews(),viewports:this.getViewports({...i,canvasId:s}),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...i,canvasId:s,canvasContext:o});return r.get(t).timeEnd(),a}_createCanvas(e){let t=e.canvas;return typeof t=="string"&&(t=document.getElementById(t),me(t)),t?this._ownedCanvas=null:(t=document.createElement("canvas"),t.id=e.id||"deckgl-overlay",e.width&&typeof e.width=="number"&&(t.width=e.width),e.height&&typeof e.height=="number"&&(t.height=e.height),(e.parent||document.body).appendChild(t),this._ownedCanvas=t),Object.assign(t.style,e.style),t}_isMultiCanvasMode(){return Array.isArray(this.props._canvases)}_getDefaultCanvasId(){return this._canvasManager.order[0]||Qi}_validateCanvasConfiguration(e){Array.isArray(e._canvases)&&(me(!e.canvas),me(!e.gl),me(!e.device?.canvasContext||e.device.getDefaultCanvasContext().offscreenCanvas))}_createEventManager(e){let t=new rc(e,{touchAction:this.props.touchAction,recognizers:Object.keys(m_).map(i=>{let[r,s,o,a]=m_[i],c=this.props.eventRecognizerOptions?.[i],l={...s,...c,event:i};return{recognizer:new r(l),recognizeWith:o,requireFailure:a}}),events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(let i in ao)i==="dblclick"?t.watch(i,this._onEvent):t.on(i,this._onEvent);return t}_getEventRoot(e){return e.closest(".deck-events-root")||this.props.parent?.querySelector(".deck-events-root")||e}_syncCanvasTargets(){if(!this.device||!this._isMultiCanvasMode())return;this._canvasManager.syncCanvasEntries({device:this.device,canvases:this.props._canvases||[],useDevicePixels:this.props.useDevicePixels}),this.eventManagers=this._canvasManager.eventManagers;let e=this._getDefaultCanvasId();this.eventManager=this.eventManagers[e]||null,this.canvas=this._canvasManager.targets[e]?.canvas||null}_setCanvasContext(e){this._canvasContext=e,"style"in e.canvas&&(this.canvas=e.canvas)}_setDeviceCanvasContext(e,t={}){let i=e.getDefaultCanvasContext();this._setCanvasContext(i),this._setDeviceResizeHandler(e,t)}_setDeviceResizeHandler(e,t={}){let i=!!t.syncDrawingBuffer;if(this._deviceResizeHandler?.device===e){this._deviceResizeHandler.syncDrawingBuffer=i;return}this._restoreDeviceResizeHandler();let r=s=>{this._isMultiCanvasMode()?this._updateMultiCanvasDimensions():s===this._canvasContext&&this._canvasContext&&this._onCanvasContextResize(this._canvasContext,{syncDrawingBuffer:this._deviceResizeHandler?.syncDrawingBuffer})};e.props.onResize=r,this._deviceResizeHandler={device:e,onResize:r,syncDrawingBuffer:i}}_restoreDeviceResizeHandler(){let e=this._deviceResizeHandler;e&&e.device.props?.onResize===e.onResize&&(e.device.props.onResize=xi),this._deviceResizeHandler=null}_setCanvasSize(e){if(this._isMultiCanvasMode()||!this.canvas)return;let{width:t,height:i}=e;if(t||t===0){let r=Number.isFinite(t)?`${t}px`:t;this.canvas.style.width=r}if(i||i===0){let r=Number.isFinite(i)?`${i}px`:i;this.canvas.style.position=e.style?.position||"absolute",this.canvas.style.height=r}}_getCanvasIdFromEvent(e){return this._canvasManager.getCanvasIdFromEvent(e?.rootElement)}_getCanvasContext(e){return this._canvasManager.getTarget(e)?.presentationContext||this._canvasContext}_resizeForCanvasTarget(e){let t=this._canvasManager.getTarget(e);if(!t||!this.device?.canvasContext)return;let[i,r]=t.presentationContext.getDrawingBufferSize();this.device.canvasContext.setDrawingBufferSize(i,r)}_createDeviceCanvas(e){if(this._isMultiCanvasMode()){let t=globalThis.OffscreenCanvas;if(!t)throw new Error("`_canvases` requires OffscreenCanvas support.");let i=typeof e.width=="number"&&Number.isFinite(e.width)?e.width:1,r=typeof e.height=="number"&&Number.isFinite(e.height)?e.height:1;return new t(i,r)}return this._createCanvas(e)}_updateCanvasSize(e=this._canvasContext){if(this._isMultiCanvasMode()){this._updateMultiCanvasDimensions();return}let{canvas:t}=this,[i,r]=e?e.getCSSSize():[t?.clientWidth??t?.width??0,t?.clientHeight??t?.height??0];(i!==this.width||r!==this.height)&&(this.width=i,this.height=r,this.viewManager?.setProps({width:i,height:r}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:i,height:r},e||void 0))}_onCanvasContextResize(e,t={}){if(t.syncDrawingBuffer){let{width:i,height:r}=e.canvas;e.setDrawingBufferSize(i,r)}this._needsRedraw="Canvas resized",this._updateCanvasSize(e)}_updateMultiCanvasDimensions(){let[e,t]=this._getCanvasContext()?.getCSSSize()||[0,0];(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.props.onResize({width:e,height:t})),this._needsRedraw="Canvas resized",this.viewManager?.setNeedsUpdate("Canvas resized"),this.viewManager?.setProps({width:this.width,height:this.height})}_createAnimationLoop(e,t){let{gl:i,onError:r}=t;return new mc({device:e,autoResizeDrawingBuffer:!i&&!Array.isArray(t._canvases),autoResizeViewport:!1,onInitialize:s=>this._setDevice(s.device),onRender:this._onRenderFrame.bind(this),onError:r})}_createDevice(e){let t=this.props.deviceProps?.createCanvasContext,i=typeof t=="object"?t:void 0,r={adapters:[],_cacheShaders:!0,_cachePipelines:!0,...e.deviceProps};r.adapters.includes(Vc)||r.adapters.push(Vc);let s={alphaMode:this.props.deviceProps?.type==="webgpu"?"premultiplied":void 0};return Vs.createDevice({_reuseDevices:!0,type:"webgl",...r,createCanvasContext:{...s,...i,canvas:this._createDeviceCanvas(e),useDevicePixels:this.props.useDevicePixels,autoResize:!0}})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let{views:e}=this.props,t=Array.isArray(e)?e:e?[e]:[new t2({id:"default-view"})];return t.length&&this.props.controller&&(t[0]=t[0].clone({controller:this.props.controller})),t}_onContextLost(){let{onError:e}=this.props;this.animationLoop&&e&&e(new Error("WebGL context is lost"))}_pickAndCallback(){let{_pickRequest:e}=this;if(e.event){let t=e.event,i=this.layerManager?.getLayers()||[],r=this._getPointPickOptions(e.x,e.y,{canvasId:e.canvasId,radius:e.radius,mode:e.mode},i),s=this._getInternalPickingMode(),o=++this._hoverPickSequence;if(e.event=null,e.canvasId=void 0,!s)return;if(s==="sync"){this._applyHoverCallbacks(this._pickPointSync(r),t);return}this._pickPointAsync(r).then(({result:a,emptyInfo:c})=>{o===this._hoverPickSequence&&this._applyHoverCallbacks({result:a,emptyInfo:c},t)}).catch(a=>this.props.onError?.(a))}}_updateCursor(){let e=this.props.getCursor(this.cursorState);if(this._isMultiCanvasMode()){for(let i of Object.values(this._canvasManager.targets))i.canvas.style.cursor=e;return}let t=this.props.parent||this.canvas;t&&(t.style.cursor=e)}_setDevice(e){if(this.device=e,this._validateInternalPickingMode(),!this.animationLoop)return;this._setDeviceCanvasContext(e,{syncDrawingBuffer:!!(this.props.gl&&this.props.device!==e)}),this._isMultiCanvasMode()?this._syncCanvasTargets():this.canvas&&!this.canvas.isConnected&&this.props.parent&&this.props.parent.insertBefore(this.canvas,this.props.parent.firstChild),this.device.type==="webgl"&&this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),this.device.type==="webgl"&&this.props.onWebGLInitialized(this.device.gl);let t=new Qr;if(t.play(),this.animationLoop.attachTimeline(t),!this._isMultiCanvasMode()){let s=this.canvas&&this._getEventRoot(this.canvas);me(s),this.eventManager=this._createEventManager(s),this.eventManagers={[Qi]:this.eventManager}}this.viewManager=new wc({timeline:t,eventManager:this.eventManager,eventManagers:this.eventManagers,getCanvasContext:this._isMultiCanvasMode()?this.getCanvasContext.bind(this):void 0,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),pickPosition:this._pickPositionForController.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});let i=this.viewManager.getViewports()[0];this.layerManager=new xc(this.device,{deck:this,stats:this.stats,viewport:i,timeline:t}),this.effectManager=new Tc({deck:this,device:this.device}),this.deckRenderer=new Mc(this.device,{stats:this.stats}),this.deckPicker=new Ac(this.device,{stats:this.stats});let r=this.props.parent?.querySelector(".deck-widgets-root")||(this._isMultiCanvasMode()?this.props.parent||this.canvas?.parentElement:null)||this.canvas?.parentElement;this.widgetManager=new Uf({deck:this,parentElement:r}),this.widgetManager.addDefault(new kc),this.setProps({}),this._updateCanvasSize(this._canvasContext),this.props.onLoad()}_drawLayers(e,t){let{device:i,gl:r}=this.layerManager.context;this.props.onBeforeRender({device:i,gl:r});let s={target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:"screen",effects:this.effectManager.getEffects(),...t};if(this._isMultiCanvasMode()&&s.pass==="screen"&&!s.target&&this._canvasManager.order.length)for(let o of this._canvasManager.order){let a=s.viewports.filter(u=>this.viewManager.getCanvasId(u.id)===o);if(!a.length){let u=this._canvasManager.targets[o];this._resizeForCanvasTarget(o),this.deckRenderer?.renderLayers({...s,canvasContext:u.presentationContext,target:u.presentationContext.getCurrentFramebuffer(),viewports:[],clearCanvas:!0}),u.presentationContext.present();continue}let c=this._canvasManager.targets[o];this._resizeForCanvasTarget(o);let l=c.presentationContext.getCurrentFramebuffer();this.deckRenderer?.renderLayers({...s,canvasContext:c.presentationContext,target:l,viewports:a}),c.presentationContext.present()}else this.deckRenderer?.renderLayers(s);s.pass==="screen"&&this.widgetManager.onRedraw({viewports:s.viewports,layers:s.layers}),this.props.onAfterRender({device:i,gl:r})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60===0&&(this._getMetrics(),this.stats.reset(),ae.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCursor(),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){let t=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:t},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(e){this.cursorState.isDragging=e.isDragging||!1,this.props.onInteractionStateChange(e)}_getFrameStats(){let{stats:e}=this;e.get("frameRate").timeEnd(),e.get("frameRate").timeStart();let t=this.animationLoop.stats;e.get("GPU Time").addTime(t.get("GPU Time").lastTiming),e.get("CPU Time").addTime(t.get("CPU Time").lastTiming)}_getMetrics(){let{metrics:e,stats:t}=this;e.fps=t.get("frameRate").getHz(),e.setPropsTime=t.get("setProps Time").time,e.updateAttributesTime=t.get("Update Attributes").time,e.framesRedrawn=t.get("Redraw Count").count,e.pickTime=t.get("pickObject Time").time+t.get("pickMultipleObjects Time").time+t.get("pickObjects Time").time,e.pickCount=t.get("Pick Count").count,e.layersCount=this.layerManager?.layers.length??0,e.drawLayersCount=t.get("Layers rendered").lastSampleCount,e.pickLayersCount=t.get("Layers picked").lastSampleCount,e.updateLayersCount=t.get("Layer updates").count,e.updateAttributesCount=t.get("Attributes updated").count,e.gpuTime=t.get("GPU Time").time,e.cpuTime=t.get("CPU Time").time,e.gpuTimePerFrame=t.get("GPU Time").getAverageTime(),e.cpuTimePerFrame=t.get("CPU Time").getAverageTime();let i=Vs.stats.get("GPU Time and Memory");e.bufferMemory=i.get("Buffer Memory").count,e.textureMemory=i.get("Texture Memory").count,e.renderbufferMemory=i.get("Renderbuffer Memory").count,e.gpuMemory=i.get("GPU Memory").count}};Wc.defaultProps=MP;Wc.VERSION=Dx;var vy=Wc;ee();ee();function AP(n){switch(n){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return Lr(n)}}var kP=Ke.getDataType.bind(Ke);function jc(n,e,t){if(e.size>4)return null;let i=t==="webgpu"&&e.type==="uint8"?"unorm8":e.type,r=e.size,s=!!(t!=="webgpu"&&r===3&&i&&["uint8","sint8","unorm8","snorm8","uint16","sint16","unorm16","snorm16"].includes(i));return{attribute:n,format:r>1?`${i}x${r}${s?"-webgl":""}`:e.type,byteOffset:e.offset||0}}function Jt(n){return n.stride||n.size*n.bytesPerElement}function RP(n,e){return n.type===e.type&&n.size===e.size&&Jt(n)===Jt(e)&&(n.offset||0)===(e.offset||0)}function xy(n,e){e.offset&&ae.removed("shaderAttribute.offset","vertexOffset, elementOffset")();let t=Jt(n),i=e.vertexOffset!==void 0?e.vertexOffset:n.vertexOffset||0,r=e.elementOffset||0,s=i*t+r*n.bytesPerElement+(n.offset||0);return{...e,offset:s,stride:t}}function Nz(n,e){let t=xy(n,e);return{high:t,low:{...t,offset:t.offset+n.size*4}}}var Hc=class{constructor(e,t,i){this._buffer=null,this.device=e,this.id=t.id||"",this.size=t.size||1;let r=t.logicalType||t.type,s=r==="float64",{defaultValue:o}=t;o=Number.isFinite(o)?[o]:o||new Array(this.size).fill(0);let a;s?a="float32":!r&&t.isIndexed?a="uint32":a=r||"float32";let c=AP(r||a);this.doublePrecision=s,s&&t.fp64===!1&&(c=Float32Array),this.value=null,this.settings={...t,defaultType:c,defaultValue:o,logicalType:r,type:a,normalized:a.includes("norm"),size:this.size,bytesPerElement:c.BYTES_PER_ELEMENT},this.state={...i,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){let e=this.getAccessor();return e.vertexOffset?e.vertexOffset*Jt(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}get isDoublePrecisionBuffer(){return this._shouldSplitDoublePrecisionValue(this.value)}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),hn.release(this.state.allocatedValue),this.state.allocatedValue=null}getBuffer(){return this.state.constant&&this.device.type!=="webgpu"?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,t=null){let i={};if(this.state.constant){let r=this.value;if(this.device.type==="webgpu"&&this._buffer)i[e]=this._buffer;else if(t){let s=xy(this.getAccessor(),t),o=s.offset/r.BYTES_PER_ELEMENT,a=s.size||this.size;i[e]=r.subarray(o,o+a)}else i[e]=r}else i[e]=this.getBuffer();return this.doublePrecision&&(this.isDoublePrecisionBuffer?i[`${e}64Low`]=i[e]:i[`${e}64Low`]=new Float32Array(this.size)),i}_getBufferLayout(e=this.id,t=null){let i=this.getAccessor(),r=[],s={name:this.id,byteStride:this.device.type==="webgpu"&&this.state.constant?0:Jt(i)};if(this.doublePrecision){let o=Nz(i,t||{});r.push(jc(e,{...i,...o.high},this.device.type),jc(`${e}64Low`,{...i,...o.low},this.device.type))}else if(t){let o=xy(i,t);r.push(jc(e,{...i,...o},this.device.type))}else r.push(jc(e,i,this.device.type));return s.attributes=r.filter(Boolean),s}setAccessor(e){this.state.bufferAccessor=e}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let e=null;if(this.state.constant&&this.value){let t=Array.from(this.value);e=[t,t]}else{let{value:t,numInstances:i,size:r}=this,s=i*r;if(t&&s&&t.length>=s){let o=new Array(r).fill(1/0),a=new Array(r).fill(-1/0);for(let c=0;ca[l]&&(a[l]=u)}e=[o,a]}}return this.state.bounds=e,e}setData(e){let{state:t}=this,i;ArrayBuffer.isView(e)?i={value:e}:e instanceof re?i={buffer:e}:i=e;let r={...this.settings,...i};if(ArrayBuffer.isView(i.value)){if(!i.type)if(this.doublePrecision&&i.value instanceof Float64Array)r.type="float32";else{let o=kP(i.value);r.type=r.normalized?o.replace("int","norm"):o}r.bytesPerElement=i.value.BYTES_PER_ELEMENT,r.stride=Jt(r)}if(t.bounds=null,i.constant){let s=i.value;if(s=this._normalizeValue(s,[],0),this.settings.normalized&&(s=this.normalizeConstant(s)),!(!t.constant||!this._areValuesEqual(s,this.value)))return!1;t.externalBuffer=null,t.constant=!0,this.value=ArrayBuffer.isView(s)?s:new Float32Array(s)}else if(i.buffer){let s=i.buffer;t.externalBuffer=s,t.constant=!1,this.value=i.value||null}else if(i.value){this._checkExternalBuffer(i);let s=i.value,o=s;t.externalBuffer=null,t.constant=!1,this.value=s,this._shouldSplitDoublePrecisionValue(o)&&(o=mo(o,r),s instanceof Float32Array&&(r.stride=r.size*2*Float32Array.BYTES_PER_ELEMENT));let{buffer:a}=this,c=Jt(r),l=(r.vertexOffset||0)*c;if(this.settings.isIndexed){let f=this.settings.defaultType;o.constructor!==f&&(o=new f(o))}let u=o.byteLength+l+c*2;(!a||a.byteLength(t+128)/255*2-1);case"snorm16":return new Float32Array(e).map(t=>(t+32768)/65535*2-1);case"unorm8":return new Float32Array(e).map(t=>t/255);case"unorm16":return new Float32Array(e).map(t=>t/65535);default:return e}}_normalizeValue(e,t,i){let{defaultValue:r,size:s}=this.settings;if(Number.isFinite(e))return t[i]=e,t;if(!e){let o=s;for(;--o>=0;)t[i+o]=r[o];return t}switch(s){case 4:t[i+3]=Number.isFinite(e[3])?e[3]:r[3];case 3:t[i+2]=Number.isFinite(e[2])?e[2]:r[2];case 2:t[i+1]=Number.isFinite(e[1])?e[1]:r[1];case 1:t[i+0]=Number.isFinite(e[0])?e[0]:r[0];break;default:let o=s;for(;--o>=0;)t[i+o]=Number.isFinite(e[o])?e[o]:r[o]}return t}_areValuesEqual(e,t){if(!e||!t)return!1;let{size:i}=this;for(let r=0;r0&&(BP.length=n.length,i=BP):i=IP,(e>0||Number.isFinite(t))&&(i=(Array.isArray(i)?i:Array.from(i)).slice(e,t),r.index=e-1),{iterable:i,objectInfo:r}}function Ed(n){return n&&n[Symbol.asyncIterator]}function Sd(n,e){let{size:t,stride:i,offset:r,startIndices:s,nested:o}=e,a=n.BYTES_PER_ELEMENT,c=i?i/a:t,l=r?r/a:0,u=Math.floor((n.length-l)/c);return(f,{index:d,target:h})=>{if(!s){let v=d*c+l;for(let y=0;y=e[1]))return n;let t=[],i=n.length,r=0;for(let s=0;se[1]?t.push(o):e=[Math.min(o[0],e[0]),Math.max(o[1],e[1])]}return t.splice(r,0,e),t}var zz={interpolation:{duration:0,easing:n=>n},spring:{stiffness:.05,damping:.5}};function Pd(n,e){if(!n)return null;Number.isFinite(n)&&(n={type:"interpolation",duration:n});let t=n.type||"interpolation";return{...zz[t],...e,...n,type:t}}var as=class extends Hc{constructor(e,t){super(e,t,{startIndices:null,constantValue:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:Yc}),this.constant=!1,this.settings.update=t.update||(t.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(e){this.state.startIndices=e}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:e=!1}={}){let t=this.state.needsRedraw;return this.state.needsRedraw=t&&!e,t}layoutChanged(){return this.state.layoutChanged}setAccessor(e){var t;(t=this.state).layoutChanged||(t.layoutChanged=!RP(e,this.getAccessor())),super.setAccessor(e)}getUpdateTriggers(){let{accessor:e}=this.settings;return[this.id].concat(typeof e!="function"&&e||[])}supportsTransition(){return!!this.settings.transition}getTransitionSetting(e){if(!e||!this.supportsTransition())return null;let{accessor:t}=this.settings,i=this.settings.transition,r=Array.isArray(t)?e[t.find(s=>e[s])]:e[t];return Pd(r,i)}setNeedsUpdate(e=this.id,t){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),t){let{startRow:i=0,endRow:r=1/0}=t;this.state.updateRanges=DP(this.state.updateRanges,[i,r])}else this.state.updateRanges=Yc}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=OP}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){let{state:t,settings:i}=this;if(i.noAlloc)return!1;if(i.update){let r=this.isConstant;return super.allocate(e,t.updateRanges!==Yc),t.layoutChanged||(t.layoutChanged=r&&this.device.type==="webgpu"),!0}return!1}updateBuffer({numInstances:e,data:t,props:i,context:r}){if(!this.needsUpdate())return!1;let{state:{updateRanges:s},settings:{update:o,noAlloc:a}}=this,c=!0;if(o){for(let[l,u]of s)o.call(r,this,{data:t,startRow:l,endRow:u,props:i,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLengthu?l.set(b,m):(e._normalizeValue(b,v.target,0),H1({target:l,source:v.target,start:m,count:w}));m+=w*u}else e._normalizeValue(b,l,m),m+=u}}_validateAttributeUpdaters(){let{settings:e}=this;if(!(e.noAlloc||typeof e.update=="function"))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){let{value:e}=this,t=Math.min(4,this.size);if(e&&e.length>=t){let i=!0;switch(t){case 4:i=i&&Number.isFinite(e[3]);case 3:i=i&&Number.isFinite(e[2]);case 2:i=i&&Number.isFinite(e[1]);case 1:i=i&&Number.isFinite(e[0]);break;default:i=!1}if(!i)throw new Error(`Illegal attribute generated for ${this.id}`)}}};Si();Ty();Si();var Zc=class n{gpuDataEvaluators;format;length;id;_gpuVector;_ownsGPUDataEvaluators;_destroyed=!1;static fromGPUVector(e){if(e.bufferLayout)throw new Error(`GPUVectorEvaluator.fromGPUVector() does not accept interleaved vector "${e.name}"`);if(e.data.length===0)throw new Error(`GPUVectorEvaluator.fromGPUVector() requires GPUData for "${e.name}"`);return new n({id:e.name,gpuDataEvaluators:e.data.map(t=>ye.fromGPUData(t,{id:e.name})),gpuVector:e,format:e.format})}static fromGPUDataEvaluators(e,t={}){return new n({id:t.id,gpuDataEvaluators:e,format:t.format})}constructor({id:e,gpuDataEvaluators:t,gpuVector:i,format:r}){if(t.length===0)throw new Error("GPUVectorEvaluator requires at least one GPUData evaluator");Qz(t),this.id=e,this.gpuDataEvaluators=t,this.format=r??t[0].format,this.length=t.reduce((s,o)=>s+o.length,0),this._gpuVector=i,this._ownsGPUDataEvaluators=!i}get evaluated(){return!!this._gpuVector}get gpuVector(){if(!this._gpuVector)throw new Error(`${this} not evaluated`);return this._gpuVector}mapGPUData(e){return n.fromGPUDataEvaluators(this.gpuDataEvaluators.map((t,i)=>e(t,i)),{id:this.id})}async evaluate(e,t={}){if(this._destroyed)throw new Error(`GPUVectorEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let i=await Promise.all(this.gpuDataEvaluators.map(a=>a.evaluate(e,t))),r=i[0],s=i.map(qP),o=t.format??this.format??r.format;return this._gpuVector=new ei({type:"data",name:t.name??this.id??"vector",format:o,data:s,stride:r.stride,byteStride:r.byteStride,rowByteLength:r.rowByteLength,bufferLayout:r.bufferLayout}),this._gpuVector}evaluateSync(e,t={}){if(this._destroyed)throw new Error(`GPUVectorEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let i=this.gpuDataEvaluators.map(a=>a.evaluateSync(e,t)),r=i[0],s=i.map(qP),o=t.format??this.format??r.format;return this._gpuVector=new ei({type:"data",name:t.name??this.id??"vector",format:o,data:s,stride:r.stride,byteStride:r.byteStride,rowByteLength:r.rowByteLength,bufferLayout:r.bufferLayout}),this._gpuVector}destroy(){if(this._ownsGPUDataEvaluators)for(let e of this.gpuDataEvaluators)e.destroy();this._gpuVector=void 0,this._destroyed=!0}toString(){return this.id??this.constructor.name}};function Qz(n){let e=n[0];for(let t of n.slice(1))if(t.type!==e.type||t.size!==e.size||t.normalized!==e.normalized||t.format!==e.format)throw new Error("GPUVectorEvaluator requires matching GPUData evaluator layouts")}function qP(n){let[e,...t]=n.data;if(!e||t.length>0)throw new Error(`GPUVectorEvaluator requires one GPUData chunk for "${n.name}"`);return e}Si();ee();var ky={};ui(ky,{arithmetic:()=>ZP,dot:()=>tC,equalAll:()=>nC,extent:()=>KP,fround:()=>QP,gather:()=>JP,interleave:()=>eC,length:()=>iC,segmentedMap:()=>rC,select:()=>sC,sequence:()=>oC,swizzle:()=>aC});Id();function ko({elementWise:n,func:e,inputs:t,output:i,outputBuffer:r}){let s=Array.isArray(t)?t:Object.values(t);for(let p of s)if(!p.value)throw new Error(`${p} does not have CPU value`);let o=i.length,a=i.size,c=new i.ValueType(o*a);for(let p=0;pIe(g,p));if(n)for(let g=0;gv[g]));else e.call(null,c.subarray(p*a,p*a+a),...m)}let l=i.ValueType.BYTES_PER_ELEMENT,u=i.offset/l,f=i.stride/l,d=a,h=c;if(u!==0||f!==d){h=new i.ValueType(u+i.byteLength/l);for(let p=0;p{for(let r of Object.values(n.namedInputs))if(!r.value)throw new Error(`${r} does not have CPU value`);let i=new e.ValueType(e.length*e.size);for(let r=0;r[o,Ie(a,r)]));for(let o=0;oXP(r,e,t));switch(n.op){case"add":return i[0]+i[1];case"subtract":return i[0]-i[1];case"multiply":return i[0]*i[1];case"divide":return i[0]/i[1];case"pow":return Math.pow(i[0],i[1]);case"sqrt":return Math.sqrt(i[0]);case"abs":return Math.abs(i[0]);case"sin":return Math.sin(i[0]);case"cos":return Math.cos(i[0]);case"tan":return Math.tan(i[0]);case"exp":return Math.exp(i[0]);case"log":return Math.log(i[0]);default:{let r=n.op;throw new Error(`Unsupported arithmetic op ${r}`)}}}default:{let i=n;throw new Error(`Unsupported expression node ${i.kind}`)}}}function eU(n,e){let t=Ao[n].arity;if(e!==t)throw new Error(`Arithmetic op '${n}' expects ${t} args, got ${e}`)}var KP=({inputs:n,output:e,target:t})=>{let{sourceValues:i}=n;if(!i.value)throw new Error(`${i} does not have CPU value`);let s=new e.ValueType(e.length*e.size);if(i.length===0)return{success:!1,error:new Error(`${i} is empty`)};for(let o=0;os[l]&&(s[l]=f)}}return t.write(s),{success:!0,value:s}};var QP=({inputs:n,output:e,target:t})=>ko({func:(i,r)=>{let s=i.length/2,o=new Float64Array(r.buffer);for(let a=0;a{let{ids:i,sourceValues:r}=n,s=i.value,o=r.value;if(!s)throw new Error(`${i} does not have CPU value`);if(!o)throw new Error(`${r} does not have CPU value`);let a=new e.ValueType(e.length*e.size),c=new Array(e.size).fill(0);for(let l=0;l=0&&nko({func:(i,...r)=>{let s=0;for(let o of r)i.set(o,s),s+=o.length},inputs:n,output:e,outputBuffer:t});var tC=({inputs:n,output:e,target:t})=>{let{x:i,y:r}=n,s=new e.ValueType(e.length);for(let o=0;o{let{x:i,y:r}=n,s=new e.ValueType(e.length);for(let o=0;o{let{x:i}=n,r=new e.ValueType(e.length);for(let s=0;s{let{segments:i,vertexCount:r}=n,s=i.value;if(!s)throw new Error(`${i} does not have CPU value`);nU(s,i,r);let o=new e.ValueType(e.length*e.size),a=0;for(let c=0;c0&&st)throw new Error(`segmentedMap last segment start must be <= vertexCount, got ${i} > ${t}`)}function My(n,e){return n.offset/n.ValueType.BYTES_PER_ELEMENT+e*(n.stride/n.ValueType.BYTES_PER_ELEMENT)}var sC=async({inputs:n,output:e,target:t})=>{let{condition:i,whenTrue:r,whenFalse:s}=n,o=new e.ValueType(e.length*e.size);for(let a=0;a{let i=new e.ValueType(e.length);for(let r=0;r{let{columns:i}=n;return ko({func:(r,s)=>{for(let o=0;o({...o,...a}));return this._modules[e]=s,s.then(o=>{this._modules[e]=o}).catch(o=>{z.error(`Failed to register ${e} backend: ${o}`)()}),s}if(i&&typeof i.then=="function"){let s=Promise.resolve(i).then(o=>({...o,...t})).then(o=>(this._modules[e]=o,o)).catch(o=>{throw z.error(`Failed to register ${e} backend: ${o}`)(),o});return this._modules[e]=s,s}let r={...i||{},...t};return this._modules[e]=r,Promise.resolve(r)}async get(e,t){let i=this._modules[e];if(!i)if(e==="webgl")i=this.add("webgl",Promise.resolve().then(()=>(NC(),DC)));else if(e==="webgpu")i=this.add("webgpu",Promise.resolve().then(()=>(Vy(),lT)));else throw new Error(`${e} backend not registered`);let s=(await i)[t];if(typeof s!="function")throw new Error(`${e} backend does not implement ${t}`);return s}getSync(e,t){let i=this._modules[e];if(!i)throw new Error(`${e} backend not registered`);if(typeof i.then=="function")throw new Error(`${e} backend is not loaded yet`);let s=i[t];if(typeof s!="function")throw new Error(`${e} backend does not implement ${t}`);return s}clear(){this._modules={}}},No=new Wy;var Gd=class{inputs;dependencies;constructor(e){this.inputs=e,this.dependencies=Array.from(e instanceof Array?e:Object.values(e)).filter(t=>t instanceof ye)}async execute(e,t){return await this._resolveDependencies(e),await this._executeWithHandler(await No.get(this._getHandlerRegistry(e),this.name),t)}executeSync(e,t){this._resolveDependenciesSync(e);let i=this._executeWithHandler(No.getSync(this._getHandlerRegistry(e),this.name),t);if(YU(i))throw new Error(`${this.name} returned a Promise in executeSync()`);return i}shouldExecuteOnCPU(){return this.output.length<=1&&Array.from(this.dependencies).every(e=>!!e.value)}_getHandlerRegistry(e){return this.shouldExecuteOnCPU()?"cpu":e.type}async _resolveDependencies(e){for(let i of this.dependencies)await i.evaluate(e);if(this._getHandlerRegistry(e)==="cpu"||e.type==="null")for(let i of this.dependencies)await i.ensureCPUValue()}_resolveDependenciesSync(e){for(let i of this.dependencies)i.evaluateSync(e);if(this._getHandlerRegistry(e)==="cpu"||e.type==="null")for(let i of this.dependencies)i.ensureCPUValueSync()}_executeWithHandler(e,t){return e({device:t.device,inputs:this.inputs,output:this.output,target:t})}};function YU(n){return typeof n?.then=="function"}function uT(...n){let e=qU(n.map(t=>t.type));return e[0]!=="f"&&n.some(t=>t.normalized)&&(e="float32"),{isConstant:n.every(t=>t.isConstant),type:e,size:n.reduce((t,i)=>Math.max(t,i.size),0),length:n.reduce((t,i)=>Math.max(t,i.length),0)}}function qU(n){let e=0,t=0;for(let i of n){if(i[0]==="f")return"float32";let r=i.endsWith("8")?8:i.endsWith("6")?16:32;i[0]==="u"?e=Math.max(e,r):t=Math.max(t,r)}return e&&!t?`uint${e}`:t&&e<32?`sint${Math.max(t,e*2)}`:"float32"}Si();var jy=class extends Gd{name="interleave";output;constructor(e){super(e);let{isConstant:t,type:i,length:r}=uT(...e);this.output=new ye({isConstant:t,type:i,size:e.reduce((s,o)=>s+o.size,0),length:r,source:this})}toString(){return`_${this.inputs.join("_")}_`}};function Hy(...n){if(n.length===0)throw new Error("interleave() requires at least one input");return n.length===1?Rd(n[0]):new jy(n.map(Rd)).output}Ce();Si();function qy(n,e){let t=XU(e);for(let i of t)i.evaluateSync(n);return ZU(t),e}function ZU(n){let e=new Set(n.flatMap(QU)),t=new Set;for(let i of n)Vd(i,t);for(let i of t)i.evaluated&&!e.has(i.buffer)&&i.destroy()}function XU(n){let e=new Set;return Yy(n,e,new Set),Array.from(e)}function Yy(n,e,t){if(JU(n)){e.add(n);return}if(!(!n||typeof n!="object"||t.has(n))){if(t.add(n),Array.isArray(n)){for(let i of n)Yy(i,e,t);return}if(KU(n))for(let i of Object.values(n))Yy(i,e,t)}}function KU(n){let e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function Vd(n,e){if(n instanceof Zc){for(let i of n.gpuDataEvaluators)Vd(i,e);return}let t=n.source;if(t){if(t instanceof ye){e.has(t)||(e.add(t),Vd(t,e));return}for(let i of t.dependencies)e.has(i)||(e.add(i),Vd(i,e))}}function QU(n){return n instanceof ye?[n.buffer]:n.gpuVector.data.map(e=>e.buffer instanceof nt?e.buffer.buffer:e.buffer)}function JU(n){return n instanceof ye||n instanceof Zc}Vy();var Kc=class{constructor(e,{id:t,isTransitionAttribute:i}){this.packedBuffers={},this.device=e,this.id=t,this.isTransitionAttribute=i,this.device.type==="webgpu"&&No.add("webgpu",{interleave:$d})}hasGroups(e){return this.device.type==="webgpu"&&Object.values(e).some(t=>!!t.settings.bufferGroup)}finalize(){for(let e of Object.values(this.packedBuffers))e.packed.destroy();this.packedBuffers={}}getBufferLayouts(e,t){let i=this._getPackedGroups(e,t,{requireValues:!1,excludeAttributes:{}});return this._getBufferLayouts(e,i,t)}getBindings(e,t,i,r){let s=this._getPackedGroups(e,i,{requireValues:!0,excludeAttributes:r}),o={},a=new Set;for(let c of s.values()){let l=!this.packedBuffers[c.id]||c.attributes.some(u=>!!t[u.id]);o[c.id]=this._getPackedBuffer(c,l);for(let u of c.attributes)a.add(u.id)}return{bufferLayouts:this._getBufferLayouts(e,s,i).filter(c=>!r[c.name]&&!e[c.name]?.settings.isIndexed),buffers:o,groupedAttributeIds:a}}_getPackedGroups(e,t,{requireValues:i,excludeAttributes:r}){let s=new Map;for(let a of Object.values(e)){let c=a.settings.bufferGroup;if(!c)continue;let l=s.get(c)||[];l.push(a),s.set(c,l)}let o=new Map;for(let[a,c]of s){let l=this._getPackedGroup(a,c,t,i,r);l&&o.set(a,l)}return o}_getPackedGroup(e,t,i,r,s){if(t.length<2)return null;let o=t.map(h=>h.getBufferLayout(i)),a=o[0].stepMode,c=Math.max(1,t[0].numInstances),l=r&&t.every(h=>h.isConstant);for(let h=0;hthis._getInterleaveInput(e,r)),i=Hy(...t);return qy(this.device,i),i}_getInterleaveInput(e,t){let i=Jt(t.getAccessor()),r=e.byteOffsets[t.id];if(Xc(`${e.id}.${t.id} rowByteLength`,i),Xc(`${e.id}.${t.id} groupByteOffset`,r),t.isConstant){let c=t.getConstantValue();if(!c)throw new Error(`Attribute group ${e.id} is missing constant value ${t.id}`);return Xc(`${e.id}.${t.id} constant byteOffset`,c.byteOffset),new ye({id:t.id,type:"uint32",size:i/4,isConstant:!0,value:new Uint32Array(c.buffer,c.byteOffset,i/Uint32Array.BYTES_PER_ELEMENT)})}let s=t.getBuffer(),o=t.byteOffset,a=t.getAccessor().stride||i;if(Xc(`${e.id}.${t.id} byteOffset`,o),Xc(`${e.id}.${t.id} stride`,a),!s)throw new Error(`Attribute group ${e.id} cannot interleave missing buffer ${t.id}`);return new ye({id:t.id,type:"uint32",size:i/4,offset:o,stride:a,length:e.rowCount,buffer:s})}};function fT(n){return Math.ceil(n/4)*4}function Xc(n,e){if(e%4!==0)throw new Error(`Attribute buffer groups require 32-bit alignment: ${n}=${e}`)}Ce();bt();function Zy(n){let{source:e,target:t,start:i=0,size:r,getData:s}=n,o=n.end||t.length,a=e.length,c=o-i;if(a>c){t.set(e.subarray(0,c),i);return}if(t.set(e,i),!s)return;let l=a;for(;li(u+a,f)),l=Math.min(r.length,s.length);for(let u=1;ua}){let a=t.isDoublePrecisionBuffer?2:1,c=t.size*a,l=t.byteOffset,u=t.settings.bytesPerElement<4?l/t.settings.bytesPerElement*4:l,f=t.startIndices,d=s&&f,h=t.isConstant;if(!d&&e&&i>=r)return e;let p=t.value instanceof Float64Array?Float32Array:t.value.constructor,m=h?t.value:new p(t.getBuffer().readSyncWebGL(l,r*p.BYTES_PER_ELEMENT).buffer);if(t.settings.normalized&&!h){let b=o;o=(w,E)=>t.normalizeConstant(b(w,E))}let g=h?(b,w)=>o(m,w):(b,w)=>o(m.subarray(b+l,b+l+c),w),v=e?new Float32Array(e.readSyncWebGL(u,i*4).buffer):new Float32Array(0),y=new Float32Array(r);return dT({source:v,target:y,sourceStartIndices:s,targetStartIndices:f,size:c,getData:g}),(!e||e.byteLength0||r.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}},r$=`layout(std140) uniform springUniforms { + float damping; + float stiffness; +} spring; +`,s$={name:"spring",vs:r$,uniformTypes:{damping:"f32",stiffness:"f32"}},o$=`#version 300 es +#define SHADER_NAME spring-transition-vertex-shader + +#define EPSILON 0.00001 + +in ATTRIBUTE_TYPE aPrev; +in ATTRIBUTE_TYPE aCur; +in ATTRIBUTE_TYPE aTo; +out ATTRIBUTE_TYPE vNext; +out float vIsTransitioningFlag; + +ATTRIBUTE_TYPE getNextValue(ATTRIBUTE_TYPE cur, ATTRIBUTE_TYPE prev, ATTRIBUTE_TYPE dest) { + ATTRIBUTE_TYPE velocity = cur - prev; + ATTRIBUTE_TYPE delta = dest - cur; + ATTRIBUTE_TYPE force = delta * spring.stiffness; + ATTRIBUTE_TYPE resistance = velocity * spring.damping; + return force - resistance + velocity + cur; +} + +void main(void) { + bool isTransitioning = length(aCur - aPrev) > EPSILON || length(aTo - aCur) > EPSILON; + vIsTransitioningFlag = isTransitioning ? 1.0 : 0.0; + + vNext = getNextValue(aCur, aPrev, aTo); + gl_Position = vec4(0, 0, 0, 1); + gl_PointSize = 100.0; +} +`,a$=`#version 300 es +#define SHADER_NAME spring-transition-is-transitioning-fragment-shader + +in float vIsTransitioningFlag; + +out vec4 fragColor; + +void main(void) { + if (vIsTransitioningFlag == 0.0) { + discard; + } + fragColor = vec4(1.0); +}`;function c$(n,e){let t=Wd(e.size),i=jd(e.size);return new it(n,{vs:o$,fs:a$,bufferLayout:[{name:"aPrev",format:i},{name:"aCur",format:i},{name:"aTo",format:e.getBufferLayout().attributes[0].format}],varyings:["vNext"],modules:[s$],defines:{ATTRIBUTE_TYPE:t},parameters:{depthCompare:"always",blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}})}function l$(n){return n.createTexture({data:new Uint8Array(4),format:"rgba8unorm",width:1,height:1})}function u$(n,e){return n.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[e]})}var f$={interpolation:Qc,spring:Jc},el=class{constructor(e,{id:t,timeline:i}){if(!e)throw new Error("AttributeTransitionManager is constructed without device");this.id=t,this.device=e,this.timeline=i,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(let e in this.transitions)this._removeTransition(e)}update({attributes:e,transitions:t,numInstances:i}){this.numInstances=i||1;for(let r in e){let s=e[r],o=s.getTransitionSetting(t);o&&this._updateAttribute(r,s,o)}for(let r in this.transitions){let s=e[r];(!s||!s.getTransitionSetting(t))&&this._removeTransition(r)}}hasAttribute(e){let t=this.transitions[e];return t&&t.inProgress}getAttributes(){let e={};for(let t in this.transitions){let i=this.transitions[t];i.inProgress&&(e[t]=i.attributeInTransition)}return e}run(){if(this.numInstances===0)return!1;for(let t in this.transitions)this.transitions[t].update()&&(this.needsRedraw=!0);let e=this.needsRedraw;return this.needsRedraw=!1,e}_removeTransition(e){this.transitions[e].delete(),delete this.transitions[e]}_updateAttribute(e,t,i){let r=this.transitions[e],s=!r||r.type!==i.type;if(s){r&&this._removeTransition(e);let o=f$[i.type];o?this.transitions[e]=new o({attribute:t,timeline:this.timeline,device:this.device}):(ae.error(`unsupported transition type '${i.type}'`)(),s=!1)}(s||t.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(i,this.numInstances))}};var _T="attributeManager.invalidate",d$="attributeManager.updateStart",h$="attributeManager.updateEnd",p$="attribute.updateStart",m$="attribute.allocate",g$="attribute.updateEnd",tl=class{constructor(e,{id:t="attribute-manager",stats:i,timeline:r}={}){this.mergeBoundsMemoized=$n(c1),this.id=t,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=i,this.attributeTransitionManager=new el(e,{id:`${t}-transitions`,timeline:r}),this.attributeBufferGroups=e.type==="webgpu"?new Kc(e,{id:t,isTransitionAttribute:s=>this.attributeTransitionManager.hasAttribute(s)}):null,Object.seal(this)}finalize(){this.attributeBufferGroups?.finalize();for(let e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){let t=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,t&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:"instance"})}remove(e){for(let t of e)this.attributes[t]!==void 0&&(this.attributes[t].delete(),delete this.attributes[t])}invalidate(e,t){let i=this._invalidateTrigger(e,t);De(_T,this,e,i)}invalidateAll(e){for(let t in this.attributes)this.attributes[t].setNeedsUpdate(t,e);De(_T,this,"all")}update({data:e,numInstances:t,startIndices:i=null,transitions:r,props:s={},buffers:o={},context:a={}}){let c=!1;De(d$,this),this.stats&&this.stats.get("Update Attributes").timeStart();for(let l in this.attributes){let u=this.attributes[l],f=u.settings.accessor;u.startIndices=i,u.numInstances=t,s[l]&&ae.removed(`props.${l}`,`data.attributes.${l}`)(),u.setExternalBuffer(o[l])||u.setBinaryValue(typeof f=="string"?o[f]:void 0,e.startIndices)||typeof f=="string"&&!o[f]&&u.setConstantValue(a,s[f])||u.needsUpdate()&&(c=!0,this._updateAttribute({attribute:u,numInstances:t,data:e,props:s,context:a})),this.needsRedraw=this.needsRedraw||u.needsRedraw()}c&&De(h$,this,t),this.stats&&(this.stats.get("Update Attributes").timeEnd(),c&&this.stats.get("Attributes updated").incrementCount()),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:t,transitions:r})}updateTransition(){let{attributeTransitionManager:e}=this,t=e.run();return this.needsRedraw=this.needsRedraw||t,t}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){let t=e.map(i=>this.attributes[i]?.getBounds());return this.mergeBoundsMemoized(t)}getChangedAttributes(e={clearChangedFlags:!1}){let{attributes:t,attributeTransitionManager:i}=this,r={...i.getAttributes()};for(let s in t){let o=t[s];o.needsRedraw(e)&&!i.hasAttribute(s)&&(r[s]=o)}return r}getBufferLayouts(e){return this.hasBufferGroups()?this.attributeBufferGroups.getBufferLayouts(this.getAttributes(),e):Object.values(this.getAttributes()).map(t=>t.getBufferLayout(e))}hasBufferGroups(){return!!this.attributeBufferGroups?.hasGroups(this.attributes)}getBufferGroupBindings(e,t,i={}){return this.attributeBufferGroups?this.attributeBufferGroups.getBindings(this.getAttributes(),e,t,i):{bufferLayouts:this.getBufferLayouts(t),buffers:{},groupedAttributeIds:new Set}}_add(e,t){for(let i in e){let r=e[i],s={...r,id:i,size:r.isIndexed&&1||r.size||1,...t};this.attributes[i]=new as(this.device,s)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){let e={};for(let t in this.attributes)this.attributes[t].getUpdateTriggers().forEach(r=>{e[r]||(e[r]=[]),e[r].push(t)});this.updateTriggers=e}_invalidateTrigger(e,t){let{attributes:i,updateTriggers:r}=this,s=r[e];return s&&s.forEach(o=>{let a=i[o];a&&a.setNeedsUpdate(a.id,t)}),s}_updateAttribute(e){let{attribute:t,numInstances:i}=e;if(De(p$,t),t.constant){t.setConstantValue(e.context,t.value);return}t.allocate(i)&&De(m$,t,i),t.updateBuffer(e)&&(this.needsRedraw=!0,De(g$,t,i))}};ee();yd();Fe();var nl=class extends mn{get value(){return this._value}_onUpdate(){let{time:e,settings:{fromValue:t,toValue:i,duration:r,easing:s}}=this,o=s(e/r);this._value=cn(t,i,o)}};var yT=1e-5;function bT(n,e,t,i,r){let s=e-n,a=(t-e)*r,c=-s*i;return a+c+s+e}function _$(n,e,t,i,r){if(Array.isArray(t)){let s=[];for(let o=0;o0}add(e,t,i,r){let{transitions:s}=this;if(s.has(e)){let c=s.get(e),{value:l=c.settings.fromValue}=c;t=l,this.remove(e)}if(r=Pd(r),!r)return;let o=y$[r.type];if(!o){ae.error(`unsupported transition type '${r.type}'`)();return}let a=new o(this.timeline);a.start({...r,fromValue:t,toValue:i}),s.set(e,a)}remove(e){let{transitions:t}=this;t.has(e)&&(t.get(e).cancel(),t.delete(e))}update(){let e={};for(let[t,i]of this.transitions)i.update(),e[t]=i.value,i.inProgress||this.remove(t);return e}clear(){for(let e of this.transitions.keys())this.remove(e)}};function wT(n){let e=n[Yn];for(let t in e){let i=e[t],{validate:r}=i;if(r&&!r(n[t],i))throw new Error(`Invalid prop ${t}: ${n[t]}`)}}function ET(n,e){let t=ST({newProps:n,oldProps:e,propTypes:n[Yn],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),i=v$(n,e),r=!1;return i||(r=x$(n,e)),{dataChanged:i,propsChanged:t,updateTriggersChanged:r,extensionsChanged:w$(n,e),transitionsChanged:b$(n,e)}}function b$(n,e){if(!n.transitions)return!1;let t={},i=n[Yn],r=!1;for(let s in n.transitions){let o=i[s],a=o&&o.type;(a==="number"||a==="color"||a==="array")&&Xy(n[s],e[s],o)&&(t[s]=!0,r=!0)}return r?t:!1}function ST({newProps:n,oldProps:e,ignoreProps:t={},propTypes:i={},triggerName:r="props"}){if(e===n)return!1;if(typeof n!="object"||n===null)return`${r} changed shallowly`;if(typeof e!="object"||e===null)return`${r} changed shallowly`;for(let s of Object.keys(n))if(!(s in t)){if(!(s in e))return`${r}.${s} added`;let o=Xy(n[s],e[s],i[s]);if(o)return`${r}.${s} ${o}`}for(let s of Object.keys(e))if(!(s in t)){if(!(s in n))return`${r}.${s} dropped`;if(!Object.hasOwnProperty.call(n,s)){let o=Xy(n[s],e[s],i[s]);if(o)return`${r}.${s} ${o}`}}return!1}function Xy(n,e,t){let i=t&&t.equal;return i&&!i(n,e,t)||!i&&(i=n&&e&&n.equals,i&&!i.call(n,e))?"changed deeply":!i&&e!==n?"changed shallowly":null}function v$(n,e){if(e===null)return"oldProps is null, initial diff";let t=!1,{dataComparator:i,_dataDiff:r}=n;return i?i(n.data,e.data)||(t="Data comparator detected a change"):n.data!==e.data&&(t="A new data container was supplied"),t&&r&&(t=r(n.data,e.data)||t),t}function x$(n,e){if(e===null)return{all:!0};if("all"in n.updateTriggers&&xT(n,e,"all"))return{all:!0};let t={},i=!1;for(let r in n.updateTriggers)r!=="all"&&xT(n,e,r)&&(t[r]=!0,i=!0);return i?t:!1}function w$(n,e){if(e===null)return!0;let t=e.extensions,{extensions:i}=n;if(i===t)return!1;if(!t||!i||i.length!==t.length)return!0;for(let r=0;ri.name==="project64"))){let i=t.modules.findIndex(r=>r.name==="project32");i>=0&&t.modules.splice(i,1)}if("inject"in e)if(!n.inject)t.inject=e.inject;else{let i={...n.inject};for(let r in e.inject)i[r]=(i[r]||"")+e.inject[r];t.inject=i}return t}ee();var T$={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},Ky={};function CT(n,e,t,i){if(t instanceof pe)return t;t.constructor&&t.constructor.name!=="Object"&&(t={data:t});let r=null;t.compressed&&(r={minFilter:"linear",mipmapFilter:t.data.length>1?"nearest":"linear"});let{width:s,height:o}=t.data,a=e.createTexture({...t,sampler:{...T$,...r,...i},mipLevels:e.getMipLevelCount(s,o)});return e.type==="webgl"?a.generateMipmapsWebGL():e.type==="webgpu"&&e.generateMipmapsWebGPU(a),Ky[a.id]=n,a}function TT(n,e){!e||!(e instanceof pe)||Ky[e.id]===n&&(e.delete(),delete Ky[e.id])}var L$={boolean:{validate(n,e){return!0},equal(n,e,t){return!!n==!!e}},number:{validate(n,e){return Number.isFinite(n)&&(!("max"in e)||n<=e.max)&&(!("min"in e)||n>=e.min)}},color:{validate(n,e){return e.optional&&!n||Qy(n)&&(n.length===3||n.length===4)},equal(n,e,t){return xe(n,e,1)}},accessor:{validate(n,e){let t=Zd(n);return t==="function"||t===Zd(e.value)},equal(n,e,t){return typeof e=="function"?!0:xe(n,e,1)}},array:{validate(n,e){return e.optional&&!n||Qy(n)},equal(n,e,t){let{compare:i}=t,r=Number.isInteger(i)?i:i?1:0;return i?xe(n,e,r):n===e}},object:{equal(n,e,t){if(t.ignore)return!0;let{compare:i}=t,r=Number.isInteger(i)?i:i?1:0;return i?xe(n,e,r):n===e}},function:{validate(n,e){return e.optional&&!n||typeof n=="function"},equal(n,e,t){return!t.compare&&t.ignore!==!1||n===e}},data:{transform:(n,e,t)=>{if(!n)return n;let{dataTransform:i}=t.props;return i?i(n):typeof n.shape=="string"&&n.shape.endsWith("-table")&&Array.isArray(n.data)?n.data:n}},image:{transform:(n,e,t)=>{let i=t.context;return!i||!i.device?null:CT(t.id,i.device,n,{...e.parameters,...t.props.textureParameters})},release:(n,e,t)=>{TT(t.id,n)}}};function LT(n){let e={},t={},i={};for(let[r,s]of Object.entries(n)){let o=s?.deprecatedFor;if(o)i[r]=Array.isArray(o)?o:[o];else{let a=M$(r,s);e[r]=a,t[r]=a.value}}return{propTypes:e,defaultProps:t,deprecatedProps:i}}function M$(n,e){switch(Zd(e)){case"object":return sl(n,e);case"array":return sl(n,{type:"array",value:e,compare:!1});case"boolean":return sl(n,{type:"boolean",value:e});case"number":return sl(n,{type:"number",value:e});case"function":return sl(n,{type:"function",value:e,compare:!0});default:return{name:n,type:"unknown",value:e}}}function sl(n,e){return"type"in e?{name:n,...L$[e.type],...e}:"value"in e?{name:n,type:Zd(e.value),...e}:{name:n,type:"object",value:e}}function Qy(n){return Array.isArray(n)||ArrayBuffer.isView(n)}function Zd(n){return Qy(n)?"array":n===null?"null":typeof n}function MT(n,e){let t;for(let s=e.length-1;s>=0;s--){let o=e[s];"extensions"in o&&(t=o.extensions)}let i=Jy(n.constructor,t),r=Object.create(i);r[wo]=n,r[qn]={},r[pn]={};for(let s=0;s{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(let e in this.asyncProps){let t=this.asyncProps[e];t&&t.type&&t.type.release&&t.type.release(t.resolvedValue,t.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||F$}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){let t=this.asyncProps[e];return t&&t.resolvedValue}isAsyncPropLoading(e){if(e){let t=this.asyncProps[e];return!!(t&&t.pendingLoadCount>0&&t.pendingLoadCount!==t.resolvedLoadCount)}for(let t in this.asyncProps)if(this.isAsyncPropLoading(t))return!0;return!1}reloadAsyncProp(e,t){this._watchPromise(e,Promise.resolve(t))}setAsyncProps(e){this.component=e[wo]||this.component;let t=e[pn]||{},i=e[qn]||e,r=e[bi]||{};for(let s in t){let o=t[s];this._createAsyncPropData(s,r[s]),this._updateAsyncProp(s,o),t[s]=this.getAsyncProp(s)}for(let s in i){let o=i[s];this._createAsyncPropData(s,r[s]),this._updateAsyncProp(s,o)}}_fetch(e,t){return null}_onResolve(e,t){}_onError(e,t){}_updateAsyncProp(e,t){if(this._didAsyncInputValueChange(e,t)){if(typeof t=="string"&&(t=this._fetch(e,t)),t instanceof Promise){this._watchPromise(e,t);return}if(Ed(t)){this._resolveAsyncIterable(e,t);return}this._setPropValue(e,t)}}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(let e in this.asyncProps)Object.defineProperty(this.oldAsyncProps,e,{enumerable:!0,value:this.oldProps[e]})}}_didAsyncInputValueChange(e,t){let i=this.asyncProps[e];return t===i.resolvedValue||t===i.lastValue?!1:(i.lastValue=t,!0)}_setPropValue(e,t){this._freezeAsyncOldProps();let i=this.asyncProps[e];i&&(t=this._postProcessValue(i,t),i.resolvedValue=t,i.pendingLoadCount++,i.resolvedLoadCount=i.pendingLoadCount)}_setAsyncPropValue(e,t,i){let r=this.asyncProps[e];r&&i>=r.resolvedLoadCount&&t!==void 0&&(this._freezeAsyncOldProps(),r.resolvedValue=t,r.resolvedLoadCount=i,this.onAsyncPropUpdated(e,t))}_watchPromise(e,t){let i=this.asyncProps[e];if(i){i.pendingLoadCount++;let r=i.pendingLoadCount;t.then(s=>{this.component&&(s=this._postProcessValue(i,s),this._setAsyncPropValue(e,s,r),this._onResolve(e,s))}).catch(s=>{this._onError(e,s)})}}async _resolveAsyncIterable(e,t){if(e!=="data"){this._setPropValue(e,t);return}let i=this.asyncProps[e];if(!i)return;i.pendingLoadCount++;let r=i.pendingLoadCount,s=[],o=0;for await(let a of t){if(!this.component)return;let{dataTransform:c}=this.component.props;c?s=c(a,s):s=s.concat(a),Object.defineProperty(s,"__diff",{enumerable:!1,value:[{startRow:o,endRow:s.length}]}),o=s.length,this._setAsyncPropValue(e,s,r)}this._onResolve(e,s)}_postProcessValue(e,t){let i=e.type;return i&&this.component&&(i.release&&i.release(e.resolvedValue,i,this.component),i.transform)?i.transform(t,i,this.component):t}_createAsyncPropData(e,t){if(!this.asyncProps[e]){let r=this.component&&this.component.props[Yn];this.asyncProps[e]={type:r&&r[e],lastValue:null,resolvedValue:t,pendingLoadCount:0,resolvedLoadCount:0}}}};var cl=class extends al{constructor({attributeManager:e,layer:t}){super(t),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1,this.disabledPickingIndices=[]}get layer(){return this.component}_fetch(e,t){let i=this.layer,r=i?.props.fetch;return r?r(t,{propName:e,layer:i}):super._fetch(e,t)}_onResolve(e,t){let i=this.layer;if(i){let r=i.props.onDataLoad;e==="data"&&r&&r(t,{propName:e,layer:i})}}_onError(e,t){let i=this.layer;i&&i.raiseError(t,`loading ${e} of ${this.layer}`)}};var z$="layer.changeFlag",U$="layer.initialize",$$="layer.update",G$="layer.finalize",V$="layer.matched",kT=2**24-1,W$=Object.freeze([]),j$=$n(({oldViewport:n,viewport:e})=>n.equals(e)),en=new Uint8ClampedArray(0);function RT(n){return n.rowIndexes||n.pickingColors||n.instancePickingColors}function tb(n){return n.rowIndexes}function nb(n){return n.pickingColors||n.instancePickingColors}var H$={data:{type:"data",value:W$,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:n=>n&&n.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(n,{propName:e,layer:t,loaders:i,loadOptions:r,signal:s})=>{let{resourceManager:o}=t.context;r=r||t.getLoadOptions(),i=i||t.props.loaders,s&&(r={...r,core:{...r?.core,fetch:{...r?.core?.fetch,signal:s}}});let a=o.contains(n);return!a&&!r&&(o.add({resourceId:n,data:zs(n,i),persistent:!1}),a=!0),a?o.subscribe({resourceId:n,onChange:c=>t.internalState?.reloadAsyncProp(e,c),consumerId:t.id,requestId:e}):zs(n,i,r)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:"default",coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:n})=>[0,-n*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}},ll=class extends Xd{constructor(){super(...arguments),this.internalState=null,this.lifecycle=Ki.NO_STATE,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let e=this;for(;e.parent;)e=e.parent;return e}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(e){me(this.internalState);let t=this.internalState.viewport||this.context.viewport,i=Af(e,{viewport:t,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[r,s,o]=Xi(i,t.pixelProjectionMatrix);return e.length===2?[r,s]:[r,s,o]}unproject(e){return me(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,t){me(this.internalState);let i=this.internalState.viewport||this.context.viewport;return f1(e,{viewport:i,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...t})}get isComposite(){return!1}get isDrawable(){return!0}setState(e){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,e),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return this.internalState?!this.internalState.isAsyncPropLoading():!1}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){let e=this.state;return e&&(e.models||e.model&&[e.model])||[]}setShaderModuleProps(...e){for(let t of this.getModels())t.shaderInputs.setProps(...e)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){let{coordinateSystem:e}=this.props;return e==="default"||e==="lnglat"||e==="cartesian"}onHover(e,t){return this.props.onHover&&this.props.onHover(e,t)||!1}onClick(e,t){return this.props.onClick&&this.props.onClick(e,t)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,t=[]){return t[0]=e+1&255,t[1]=e+1>>8&255,t[2]=e+1>>8>>8&255,t}decodePickingColor(e){me(e instanceof Uint8Array);let[t,i,r]=e;return t+i*256+r*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:PT(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds(["positions","instancePositions"])}getShaders(e){e=us(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(let t of this.props.extensions)e=us(e,t.getShaders.call(this,t));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){let t=this.getAttributeManager(),{dataChanged:i}=e.changeFlags;if(i&&t)if(Array.isArray(i))for(let r of i)t.invalidateAll(r);else t.invalidateAll();if(t){let{props:r}=e,s=this.internalState.hasPickingBuffer,o=Number.isInteger(r.highlightedObjectIndex)||!!r.pickable||r.extensions.some(a=>a.getNeedsPickingBuffer.call(this,a));if(s!==o){this.internalState.hasPickingBuffer=o;let a=RT(t.attributes);a&&(o&&a.constant&&(a.constant=!1,t.invalidate(a.id)),!a.value&&!o&&(a.constant=!0,a.value=tb(t.attributes)?[uc]:[0,0,0]))}}}finalizeState(e){for(let i of this.getModels())i.destroy();let t=this.getAttributeManager();t&&t.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(let t of this.getModels())t.draw(e.renderPass)}getPickingInfo({info:e,mode:t,sourceLayer:i}){let{index:r}=e;return r>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[r]),e}raiseError(e,t){t&&(e=new Error(`${t}: ${e.message}`,{cause:e})),this.props.onError?.(e)||this.context?.onError?.(e,this)}getNeedsRedraw(e={clearRedrawFlags:!1}){return this._getNeedsRedraw(e)}needsUpdate(){return this.internalState?this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()):!1}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(e){if(!this.internalState)return;let t=this.internalState.viewport;this.internalState.viewport=e,(!t||!j$({oldViewport:t,viewport:e}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e="all"){let t=this.getAttributeManager();t&&(e==="all"?t.invalidateAll():t.invalidate(e))}updateAttributes(e){let t=!1;for(let i in e)e[i].layoutChanged()&&(t=!0);for(let i of this.getModels())this._setModelAttributes(i,e,t)}_updateAttributes(){let e=this.getAttributeManager();if(!e)return;let t=this.props,i=this.getNumInstances(),r=this.getStartIndices();e.update({data:t.data,numInstances:i,startIndices:r,props:t,transitions:t.transitions,buffers:t.data.attributes,context:this});let s=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(s)}_updateAttributeTransition(){let e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){let{uniformTransitions:e}=this.internalState;if(e.active){let t=e.update(),i=Object.create(this.props);for(let r in t)Object.defineProperty(i,r,{value:t[r]});return i}return this.props}calculateInstancePickingColors(e,{numInstances:t}){if(e.constant)return;let i=Math.floor(en.length/4);this.internalState.usesPickingColorCache=!0;let r=t>0&&en[0]===0;if(ikT&&ae.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),en=hn.allocate(en,t,{size:4,copy:!0,maxCount:Math.max(t,kT)});let s=Math.floor(en.length/4),o=[0,0,0],a=r?0:i;for(let c=a;c(ae.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new rl(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(let t of this.props.extensions)t.initializeState.call(this,this.context,t);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){De(V$,this,this===e);let{state:t,internalState:i}=e;this!==e&&(this.internalState=i,this.state=t,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){let e=this.needsUpdate();if(De($$,this,e),!e)return;this.context.stats.get("Layer updates").incrementCount();let t=this.props,i=this.context,r=this.internalState,s=i.viewport,o=this._updateUniformTransition();r.propsInTransition=o,i.viewport=r.viewport||s,this.props=o;try{let a=this._getUpdateParams(),c=this.getModels();if(i.device)this.updateState(a);else try{this.updateState(a)}catch{}for(let u of this.props.extensions)u.updateState.call(this,a,u);this.setNeedsRedraw(),this._updateAttributes();let l=this.getModels()[0]!==c[0];this._postUpdate(a,l)}finally{i.viewport=s,this.props=t,this._clearChangeFlags(),r.needsUpdate=!1,r.resetOldProps()}}_finalize(){De(G$,this),this.finalizeState(this.context);for(let e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,shaderModuleProps:t=null,uniforms:i={},parameters:r={}}){this._updateAttributeTransition();let s=this.props,o=this.context;this.props=this.internalState.propsInTransition||s;try{t&&this.setShaderModuleProps(t);let{getPolygonOffset:a}=this.props,c=a&&a(i)||[0,0];o.device instanceof er&&o.device.setParametersWebGL({polygonOffset:c});let l=o.device instanceof er?null:Y$(r);if(q$(this.getModels(),e,r,l),o.device instanceof er)o.device.withParametersWebGL(r,()=>{let u={renderPass:e,shaderModuleProps:t,uniforms:i,parameters:r,context:o};for(let f of this.props.extensions)f.draw.call(this,u,f);this.draw(u)});else{l?.renderPassParameters&&e.setParameters(l.renderPassParameters);let u={renderPass:e,shaderModuleProps:t,uniforms:i,parameters:r,context:o};for(let f of this.props.extensions)f.draw.call(this,u,f);this.draw(u)}}finally{this.props=s}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;let{changeFlags:t}=this.internalState;for(let r in e)if(e[r]){let s=!1;switch(r){case"dataChanged":let o=e[r],a=t[r];o&&Array.isArray(a)&&(t.dataChanged=Array.isArray(o)?a.concat(o):o,s=!0);default:t[r]||(t[r]=e[r],s=!0)}s&&De(z$,this,r,e)}let i=!!(t.dataChanged||t.updateTriggersChanged||t.propsChanged||t.extensionsChanged);t.propsOrDataChanged=i,t.somethingChanged=i||t.viewportChanged||t.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,t){let i=ET(e,t);if(i.updateTriggersChanged)for(let r in i.updateTriggersChanged)i.updateTriggersChanged[r]&&this.invalidateAttribute(r);if(i.transitionsChanged)for(let r in i.transitionsChanged)this.internalState.uniformTransitions.add(r,t[r],e[r],e.transitions?.[r]);return this.setChangeFlags(i)}validateProps(){wT(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){let t={highlightedObjectColor:e.picked?e.color:null},{highlightColor:i}=this.props;e.picked&&typeof i=="function"&&(t.highlightColor=i(e)),this.setShaderModuleProps({picking:t}),this.setNeedsRedraw()}_getAttributeManager(){let e=this.context;return new tl(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,t){let{props:i,oldProps:r}=e,s=this.state.model;s?.isInstanced&&s.setInstanceCount(this.getNumInstances());let{autoHighlight:o,highlightedObjectIndex:a,highlightColor:c}=i;if(t||r.autoHighlight!==o||r.highlightedObjectIndex!==a||r.highlightColor!==c){let l={};Array.isArray(c)&&(l.highlightColor=c),(t||r.autoHighlight!==o||a!==r.highlightedObjectIndex)&&(l.highlightedObjectColor=Number.isFinite(a)&&a>=0?this.encodePickingColor(a):null),this.setShaderModuleProps({picking:l})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(e){if(!this.internalState)return!1;let t=!1;t=t||this.internalState.needsRedraw&&this.id;let i=this.getAttributeManager(),r=i?i.getNeedsRedraw(e):!1;if(t=t||r,t)for(let s of this.props.extensions)s.onNeedsRedraw.call(this,s);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,t}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}};ll.defaultProps=H$;ll.layerName="Layer";var Ci=ll;function Y$(n){let{blendConstant:e,...t}=n;return e?{pipelineParameters:t,renderPassParameters:{blendConstant:e}}:{pipelineParameters:t}}function q$(n,e,t,i){for(let r of n)r.device.type==="webgpu"?(Z$(r,e),r.setParameters({...r.parameters,...i?.pipelineParameters})):r.setParameters(t)}function Z$(n,e){let t=e.props.framebuffer||(e.framebuffer??null);if(!t)return;let i=t.colorAttachments.map(o=>o?.texture?.format??null),r=t.depthStencilAttachment?.texture?.format,s=n;(!X$(s.props.colorAttachmentFormats,i)||s.props.depthStencilAttachmentFormat!==r)&&(s.props.colorAttachmentFormats=i,s.props.depthStencilAttachmentFormat=r,s._setPipelineNeedsUpdate("attachment formats"))}function X$(n,e){if(n===e)return!0;if(!n||!e||n.length!==e.length)return!1;for(let t=0;t{let x=d.slice();x[E]+=1;let T=p.project(x)[E]-g[E];return Number.isFinite(T)?T:2**(E===0?c:l)*(E===0?1:-1)}),y=v.map((E,x)=>{let T=x===0?m.left:m.top,I=x===0?m.right:m.bottom,N=Math.abs(E);return E>=0?[T/N,I/N]:[I/N,T/N]}),b=d.slice(),w=[h.width,h.height];for(let[E,[x,T]]of y.entries()){if(w[E]<0)continue;let{minimum:I,maximum:N,midpoint:D,settledTarget:H}=J$(u,E,x,T,d[E]);if(t?.mode!=="preserve"&&f&&(!Number.isFinite(x)||!Number.isFinite(T))){b[E]=D;continue}let W=f?H:Se(d[E],I,N);b[E]=t?.mode==="preserve"?d[E]:a?Ji(d[E],W,(E===0?h.width:h.height)/2/Math.abs(v[E])):W}(b[0]!==d[0]||b[1]!==d[1])&&(e.target=b)}return e}_constrainZoom({zoomX:e,zoomY:t},i){i||(i=this.getViewportProps());let{zoomAxis:r,maxZoomX:s,maxZoomY:o,maxBounds:a}=i,{minZoomX:c,minZoomY:l}=i;if(a!==null&&i.width>0&&i.height>0){let f=Eo(i.width,i.height,i.maxBoundsPadding),d=a[0],h=a[1],p=h[0]-d[0],m=h[1]-d[1];f.width>0&&Number.isFinite(p)&&p>0&&(c=Math.max(c,Math.log2(f.width/p)),c>s&&(c=s)),f.height>0&&Number.isFinite(m)&&m>0&&(l=Math.max(l,Math.log2(f.height/m)),l>o&&(l=o))}switch(r){case"X":e=Se(e,c,s);break;case"Y":t=Se(t,l,o);break;default:let f=Math.min(s-e,o-t,0);f===0&&(f=Math.max(c-e,l-t,0)),f!==0&&(e+=f,t+=f)}return{zoomX:e,zoomY:t}}},ul=class extends is{constructor(){super(...arguments),this.ControllerState=rb,this.transition={transitionDuration:300,transitionInterpolator:new vi(["target","zoomX","zoomY"])},this.dragMode="pan"}setProps(e){Object.assign(e,ib(e)),super.setProps(e)}_onMultiPanStart(e){return this.multiTouchDrag==="pan"&&super._onMultiPanStart(e)}_onPanRotate(){return!1}};var Qd=class extends es{constructor(e={}){super(e)}getViewportType(){return IT}get ControllerType(){return ul}};Qd.displayName="OrthographicView";var sb=Qd;var fl=class{static get componentName(){return Object.prototype.hasOwnProperty.call(this,"extensionName")?this.extensionName:""}constructor(e){e&&(this.opts=e)}equals(e){return this===e?!0:this.constructor===e.constructor&&xe(this.opts,e.opts,1)}getShaders(e){return null}getSubLayerProps(e){let{defaultProps:t}=e.constructor,i={updateTriggers:{}};for(let r in t)if(r in this.props){let s=t[r],o=this.props[r];i[r]=o,s&&s.type==="accessor"&&(i.updateTriggers[r]=this.props.updateTriggers[r],typeof o=="function"&&(i[r]=this.getSubLayerAccessor(o)))}return i}initializeState(e,t){}updateState(e,t){}onNeedsRedraw(e){}getNeedsPickingBuffer(e){return!1}draw(e,t){}finalizeState(e,t){}};fl.defaultProps={};fl.extensionName="LayerExtension";var ob=fl;ee();var sr=class{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;let{attributes:t={}}=e;this.typedArrayManager=hn,this.attributes={},this._attributeDefs=t,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);let{data:t,buffers:i={},getGeometry:r,geometryBuffer:s,positionFormat:o,dataChanged:a,normalize:c=!0}=this.opts;if(this.data=t,this.getGeometry=r,this.positionSize=s&&s.size||(o==="XY"?2:3),this.buffers=i,this.normalize=c,s&&(me(t.startIndices),this.getGeometry=this.getGeometryFromBuffer(s),c||(i.vertexPositions=s)),this.geometryBuffer=i.vertexPositions,Array.isArray(a))for(let l of a)this._rebuildGeometry(l);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:t}){this._rebuildGeometry({startRow:e,endRow:t})}getGeometryFromBuffer(e){let t=e.value||e;return ArrayBuffer.isView(t)?Sd(t,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,t){let{attributes:i,buffers:r,_attributeDefs:s,typedArrayManager:o}=this;for(let a in s)if(a in r)o.release(i[a]),i[a]=null;else{let c=s[a];c.copy=t,i[a]=o.allocate(i[a],e,c)}}_forEachGeometry(e,t,i){let{data:r,getGeometry:s}=this,{iterable:o,objectInfo:a}=wd(r,t,i);for(let c of o){a.index++;let l=s?s(c,a):null;e(l,a.index)}}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:t,vertexStarts:i,instanceCount:r}=this,{data:s,geometryBuffer:o}=this,{startRow:a=0,endRow:c=1/0}=e||{},l={};if(e||(t=[0],i=[0]),this.normalize||!o)this._forEachGeometry((f,d)=>{let h=f&&this.normalizeGeometry(f);l[d]=h,i[d+1]=i[d]+(h?this.getGeometrySize(h):0)},a,c),r=i[i.length-1];else if(i=s.startIndices,r=i[s.length]||0,ArrayBuffer.isView(o))r=r||o.length/this.positionSize;else if(o instanceof re){let f=this.positionSize*4;r=r||o.byteLength/f}else if(o.buffer){let f=o.stride||this.positionSize*4;r=r||o.buffer.byteLength/f}else if(o.value){let f=o.value,d=o.stride/f.BYTES_PER_ELEMENT||this.positionSize;r=r||f.length/d}this._allocate(r,!!e),this.indexStarts=t,this.vertexStarts=i,this.instanceCount=r;let u={};this._forEachGeometry((f,d)=>{let h=l[d]||f;u.vertexStart=i[d],u.indexStart=t[d];let p=d 0.0 ? mod(dashOffsetAndLength.x, dashPeriod) : 0.0; +#else +vDashOffset = 0.0; +vDashPathLength = 0.0; +#endif +`,"fs:#decl":` +layout(std140) uniform pathStyleUniforms { +float dashAlignMode; +bool dashGapPickable; +highp int dashUnits; +} pathStyle; +in vec2 vDashArray; +in float vDashOffset; +in float vDashPathLength; +float dashPatternIntegral(float position, float solidLength, float unitLength) { +return floor(position / unitLength) * solidLength + +min(mod(position, unitLength), solidLength); +} +float dashPatternCoverage( +float position, +float solidLength, +float unitLength, +float filterWidth +) { +float halfFilter = 0.5 * filterWidth; +float reducedPosition = mod(position, unitLength); +return (dashPatternIntegral(reducedPosition + halfFilter, solidLength, unitLength) - +dashPatternIntegral(reducedPosition - halfFilter, solidLength, unitLength)) / filterWidth; +} +`,"fs:#main-start":` +float dashCoverage = 1.0; +bool shouldDiscardDash = false; +bool inRoundedDashGap = false; +float roundedDashResolvedCoverage = 1.0; +float roundedDashSubPixelBlend = 0.0; +float roundedDashDutyCycle = 1.0; +float solidLength = vDashArray.x; +float gapLength = vDashArray.y; +float unitLength = solidLength + gapLength; +if (unitLength > 0.0 && gapLength > 0.0) { +float offset; +if (pathStyle.dashAlignMode == 0.0) { +offset = vDashOffset; +} else { +#ifdef HIGH_PRECISION_DASH +unitLength = vDashPathLength / max(round(vDashPathLength / unitLength), 1.0); +#else +unitLength = vPathLength / max(round(vPathLength / unitLength), 1.0); +#endif +solidLength = min(solidLength, unitLength); +offset = solidLength / 2.0; +#ifdef HIGH_PRECISION_DASH +offset += vDashOffset; +#endif +} +float alongPath = vPathPosition.y + offset; +float unitOffset = mod(alongPath, unitLength); +float filterWidth = max(fwidth(alongPath), 0.0001); +if (bool(picking.isActive)) { +bool inGap = unitOffset > solidLength; +if (inGap && path.capType > 0.5) { +inGap = length(vec2( +min(unitOffset - solidLength, unitLength - unitOffset), +vPathPosition.x +)) > 1.0; +} +if (inGap && !pathStyle.dashGapPickable) { +shouldDiscardDash = true; +} +} else if (path.capType <= 0.5) { +dashCoverage = dashPatternCoverage(alongPath, solidLength, unitLength, filterWidth); +} else { +float distanceAlongGap = min(unitOffset - solidLength, unitLength - unitOffset); +float distanceToEnd = length(vec2(max(distanceAlongGap, 0.0), vPathPosition.x)); +float capEdgePixels = (1.0 - distanceToEnd) / max(fwidth(distanceToEnd), 1e-6); +if (distanceAlongGap > 0.0) { +inRoundedDashGap = true; +roundedDashResolvedCoverage = smoothedge(0.0, capEdgePixels); +dashCoverage = roundedDashResolvedCoverage; +} +float subPixelBlend = smoothstep(unitLength, 2.0 * unitLength, filterWidth); +roundedDashSubPixelBlend = subPixelBlend; +float boundedSolidLength = min(solidLength, unitLength); +float effectiveGap = max(unitLength - boundedSolidLength, 0.0); +float capSpan = 2.0 * sqrt(max(1.0 - vPathPosition.x * vPathPosition.x, 0.0)); +float roundedDutyCycle = clamp( +(boundedSolidLength + min(effectiveGap, capSpan)) / unitLength, +0.0, +1.0 +); +roundedDashDutyCycle = roundedDutyCycle; +dashCoverage = mix(dashCoverage, roundedDutyCycle, subPixelBlend); +} +dashCoverage = clamp(dashCoverage, 0.0, 1.0); +shouldDiscardDash = shouldDiscardDash || dashCoverage <= 0.0; +} +`,"fs:#main-end":` +#ifdef ANTIALIASING +if (inRoundedDashGap) { +float pathCoverage = smoothedge(0.0, edgePixels); +float resolvedCapMultiplier = +min(pathCoverage, roundedDashResolvedCoverage) / max(pathCoverage, 1e-6); +dashCoverage = mix( +resolvedCapMultiplier, +roundedDashDutyCycle, +roundedDashSubPixelBlend +); +} +#endif +if (shouldDiscardDash) { +discard; +} +fragColor.a *= dashCoverage; +`}},DT={inject:{"vs:#decl":` +in vec2 instanceDashArrays; +out vec2 vDashArray; +`,"vs:#main-end":` +vDashArray = instanceDashArrays; +`,"fs:#decl":` +layout(std140) uniform pathStyleUniforms { +bool dashGapPickable; +} pathStyle; +in vec2 vDashArray; +#define PI 3.141592653589793 +`,"fs:#main-start":` +bool inDashGap = false; +float dashUnitLength = vDashArray.x + vDashArray.y; +if (dashUnitLength > 0.0 && scatterplot.stroked > 0.5) { +float _distToCenter = length(unitPosition) * outerRadiusPixels; +float innerRadius = innerUnitRadius * outerRadiusPixels; +if (_distToCenter >= innerRadius) { +float strokeWidth = (1.0 - innerUnitRadius) * outerRadiusPixels; +float midStrokeRadius = (innerUnitRadius + 1.0) * 0.5 * outerRadiusPixels; +float angle = atan(unitPosition.y, unitPosition.x) + PI; +float circumference = 2.0 * PI * midStrokeRadius; +float posAlongStroke = (angle / (2.0 * PI)) * circumference / strokeWidth; +float unitOffset = mod(posAlongStroke, dashUnitLength); +if (unitOffset > vDashArray.x) { +if (scatterplot.filled > 0.5) { +inDashGap = true; +} else { +if (!(pathStyle.dashGapPickable && bool(picking.isActive))) { +discard; +} +} +} +} +} +`,"fs:#main-end":` +if (inDashGap) { +float alphaFactor = fragColor.a / max(vLineColor.a, 0.001); +fragColor = vec4(vFillColor.rgb, vFillColor.a * alphaFactor); +fragColor = picking_filterPickingColor(fragColor); +fragColor = picking_filterHighlightColor(fragColor); +} +`}},NT={inject:{"vs:#decl":` +in vec2 instanceDashArrays; +out vec2 vDashArray; +`,"vs:#main-end":` +vDashArray = instanceDashArrays; +`,"fs:#decl":` +layout(std140) uniform pathStyleUniforms { +bool dashGapPickable; +} pathStyle; +in vec2 vDashArray; +#define PI 3.141592653589793 +float getPerimeterPosition(vec2 fragUV, vec2 dims, vec4 radii, float lineWidth) { +float width = dims.x; +float height = dims.y; +float maxRadius = min(width, height) * 0.5; +float rBL = min(radii.w, maxRadius); +float rTL = min(radii.z, maxRadius); +float rTR = min(radii.x, maxRadius); +float rBR = min(radii.y, maxRadius); +vec2 p = fragUV * dims; +float leftLen = height - rBL - rTL; +float topLen = width - rTL - rTR; +float rightLen = height - rTR - rBR; +float bottomLen = width - rBR - rBL; +float arcBL = PI * 0.5 * rBL; +float arcTL = PI * 0.5 * rTL; +float arcTR = PI * 0.5 * rTR; +float arcBR = PI * 0.5 * rBR; +float pos = 0.0; +float distLeft = p.x; +float distRight = width - p.x; +float distBottom = p.y; +float distTop = height - p.y; +float minDist = min(min(distLeft, distRight), min(distBottom, distTop)); +if (p.x < rBL && p.y < rBL) { +vec2 c = vec2(rBL, rBL); +vec2 d = p - c; +float angle = atan(-d.x, -d.y); +pos = angle / (PI * 0.5) * arcBL; +} else if (p.x < rTL && p.y > height - rTL) { +vec2 c = vec2(rTL, height - rTL); +vec2 d = p - c; +float angle = atan(d.y, -d.x); +pos = arcBL + leftLen + angle / (PI * 0.5) * arcTL; +} else if (p.x > width - rTR && p.y > height - rTR) { +vec2 c = vec2(width - rTR, height - rTR); +vec2 d = p - c; +float angle = atan(d.x, d.y); +pos = arcBL + leftLen + arcTL + topLen + angle / (PI * 0.5) * arcTR; +} else if (p.x > width - rBR && p.y < rBR) { +vec2 c = vec2(width - rBR, rBR); +vec2 d = p - c; +float angle = atan(-d.y, d.x); +pos = arcBL + leftLen + arcTL + topLen + arcTR + rightLen + angle / (PI * 0.5) * arcBR; +} else if (minDist == distLeft) { +pos = arcBL + clamp(p.y - rBL, 0.0, leftLen); +} else if (minDist == distTop) { +pos = arcBL + leftLen + arcTL + clamp(p.x - rTL, 0.0, topLen); +} else if (minDist == distRight) { +pos = arcBL + leftLen + arcTL + topLen + arcTR + clamp(height - rTR - p.y, 0.0, rightLen); +} else { +pos = arcBL + leftLen + arcTL + topLen + arcTR + rightLen + arcBR + clamp(width - rBR - p.x, 0.0, bottomLen); +} +return pos / lineWidth; +} +float getRectPerimeterPosition(vec2 fragUV, vec2 dims, float lineWidth) { +float width = dims.x; +float height = dims.y; +float distLeft = fragUV.x * width; +float distRight = (1.0 - fragUV.x) * width; +float distBottom = fragUV.y * height; +float distTop = (1.0 - fragUV.y) * height; +float minDist = min(min(distLeft, distRight), min(distBottom, distTop)); +float pos = 0.0; +if (minDist == distLeft) { +pos = fragUV.y * height; +} else if (minDist == distTop) { +pos = height + fragUV.x * width; +} else if (minDist == distRight) { +pos = height + width + (1.0 - fragUV.y) * height; +} else { +pos = 2.0 * height + width + (1.0 - fragUV.x) * width; +} +return pos / lineWidth; +} +`,"fs:#main-start":` +bool inDashGap = false; +float dashUnitLength = vDashArray.x + vDashArray.y; +if (dashUnitLength > 0.0 && textBackground.stroked) { +float distToEdge; +bool hasRoundedCorners = textBackground.borderRadius != vec4(0.0); +if (hasRoundedCorners) { +distToEdge = round_rect(uv, dimensions, textBackground.borderRadius); +} else { +distToEdge = rect(uv, dimensions); +} +if (distToEdge <= vLineWidth && distToEdge >= 0.0) { +float posAlongStroke; +if (hasRoundedCorners) { +posAlongStroke = getPerimeterPosition(uv, dimensions, textBackground.borderRadius, vLineWidth); +} else { +posAlongStroke = getRectPerimeterPosition(uv, dimensions, vLineWidth); +} +float unitOffset = mod(posAlongStroke, dashUnitLength); +if (unitOffset > vDashArray.x) { +if (vFillColor.a > 0.0) { +inDashGap = true; +} else { +if (!(pathStyle.dashGapPickable && bool(picking.isActive))) { +discard; +} +} +} +} +} +`,"fs:#main-end":` +if (inDashGap) { +float alphaFactor = fragColor.a / max(vLineColor.a, 0.001); +fragColor = vec4(vFillColor.rgb, vFillColor.a * alphaFactor); +fragColor = picking_filterPickingColor(fragColor); +fragColor = picking_filterHighlightColor(fragColor); +} +`}},FT={inject:{"vs:#decl":` +in float instanceOffsets; +`,"vs:DECKGL_FILTER_SIZE":` +float offsetWidth = abs(instanceOffsets * 2.0) + 1.0; +size *= offsetWidth; +`,"vs:#main-end":` +float offsetWidth = abs(instanceOffsets * 2.0) + 1.0; +float offsetDir = sign(instanceOffsets); +vPathPosition.x = (vPathPosition.x + offsetDir) * offsetWidth - offsetDir; +vPathPosition.y *= offsetWidth; +vPathLength *= offsetWidth; +#ifdef DASH_ENABLED +if (pathStyle.dashUnits != 0) { +vDashArray *= offsetWidth; +} +vPathBounds *= offsetWidth; +#ifdef HIGH_PRECISION_DASH +vDashPathLength *= offsetWidth; +float restoredDashUnitLength = vDashArray.x + vDashArray.y; +float restoredDashPeriod = pathStyle.dashAlignMode == 0.0 +? restoredDashUnitLength +: vDashPathLength / +max(round(vDashPathLength / max(restoredDashUnitLength, 0.0001)), 1.0); +vDashOffset = restoredDashPeriod > 0.0 +? mod(dashOffsetAndLength.x * offsetWidth, restoredDashPeriod) +: 0.0; +#else +vDashOffset *= offsetWidth; +#endif +#endif +`,"fs:#main-end":` +#ifndef ANTIALIASING +if (abs(vPathPosition.x) > 1.0) { +discard; +} +#endif +`}};var eG={getDashArray:{type:"accessor",value:[0,0]},getOffset:{type:"accessor",value:0},dashJustified:!1,dashGapPickable:!1,dashUnits:"widths"},tG={widths:0,pixels:1,meters:2,common:3},nG=["instanceDashArrays","instanceDashOffsets","instanceOffsets"];function iG({props:n,oldProps:e}){return!xe(n.modelMatrix,e.modelMatrix,2)||n.coordinateSystem!==e.coordinateSystem||!xe(n.coordinateOrigin,e.coordinateOrigin,1)}function zT(n,e,t){let i=n.context.viewport;if(!(i instanceof yi)||i.zoom<12)return n.projectPosition(e,{autoOffset:!1});let r=At.transformMat4([],[e[0],e[1],e[2]||0,1],t.modelMatrix),s=n.props.coordinateSystem==="default"?"lnglat":n.props.coordinateSystem;if(s==="lnglat"){if(Math.abs(r[1]-t.coordinateOrigin[1])>.25){let c=r[0];t.wrapLongitude&&(c=((c+180)%360+360)%360-180);let l=i.projectPosition([c,r[1],0]);return[l[0]-t.commonOrigin[0],l[1]-t.commonOrigin[1],r[2]*t.commonUnitsPerMeter[2]]}yt.sub(r,r,t.coordinateOrigin)}else s==="cartesian"&&yt.sub(r,r,t.coordinateOrigin);let o=r[1],a=yt.scaleAndAdd([],t.commonUnitsPerWorldUnit,t.commonUnitsPerWorldUnit2,o);return yt.multiply([],r,a)}var dl=class extends ob{constructor({dash:e=!1,offset:t=!1,dashMode:i,highPrecisionDash:r=!1}={}){let s=i??(r?"path":"segment");super({dash:e||r||i!==void 0,offset:t,dashMode:s,highPrecisionDash:s==="path"})}getLayerType(e){if("pathTesselator"in e.state)return"path";let t=e.constructor.layerName;return t==="ScatterplotLayer"?"scatterplot":t==="TextBackgroundLayer"?"textBackground":null}synchronizeAttributes(e){let t=e.getAttributeManager(),i=this.getLayerType(e);if(!t||!i)return!1;let r=t.getAttributes(),s=new Set;this.opts.dash&&s.add("instanceDashArrays"),i==="path"&&this.opts.dash&&this.opts.dashMode==="path"&&s.add("instanceDashOffsets"),i==="path"&&this.opts.offset&&s.add("instanceOffsets");let o=!1;for(let a of nG)r[a]&&!s.has(a)&&(t.remove([a]),o=!0);return s.has("instanceDashArrays")&&!r.instanceDashArrays&&(t.addInstanced({instanceDashArrays:{size:2,accessor:"getDashArray"}}),o=!0),s.has("instanceDashOffsets")&&!r.instanceDashOffsets&&(t.addInstanced({instanceDashOffsets:{size:2,accessor:["getPath"],update:this.calculateDashMetrics}}),o=!0),s.has("instanceOffsets")&&!r.instanceOffsets&&(t.addInstanced({instanceOffsets:{size:1,accessor:"getOffset"}}),o=!0),o}isEnabled(e){return this.getLayerType(e)!==null}getShaders(e){let t=e.getLayerType(this);if(!t)return null;if(t==="scatterplot"||t==="textBackground")return e.opts.dash?{modules:[{name:"pathStyle",inject:t==="scatterplot"?DT.inject:NT.inject,uniformTypes:{dashGapPickable:"i32"}}]}:null;let i={},r={};e.opts.dash&&(i=us(i,OT),r.DASH_ENABLED=!0,e.opts.dashMode==="path"&&(r.HIGH_PRECISION_DASH=!0)),e.opts.offset&&(i=us(i,FT),r.PATH_STYLE_OFFSET=!0);let{inject:s}=i,o={name:"pathStyle",inject:s};return e.opts.dash&&(o.uniformTypes={dashAlignMode:"f32",dashGapPickable:"i32",dashUnits:"i32"}),{modules:[o],defines:r}}initializeState(e,t){t.synchronizeAttributes(this)}updateState(e,t){if(t.isEnabled(this)){if(e.changeFlags.extensionsChanged){let i=t.synchronizeAttributes(this),r=this.getAttributeManager();if(r&&i){r.invalidateAll();for(let s of this.getModels())s.setBufferLayout(r.getBufferLayouts(s))}}if(t.opts.dash){let i=t.getLayerType(this);if(i==="path"&&t.opts.dashMode==="path"&&iG(e)&&this.getAttributeManager()?.invalidate("instanceDashOffsets"),i==="scatterplot"||i==="textBackground"){let r={dashGapPickable:!!this.props.dashGapPickable};this.setShaderModuleProps({pathStyle:r})}else{let r={dashAlignMode:this.props.dashJustified?1:0,dashGapPickable:!!this.props.dashGapPickable,dashUnits:tG[this.props.dashUnits??"widths"]};this.setShaderModuleProps({pathStyle:r})}}}}calculateDashMetrics(e,{startRow:t,endRow:i}){let r=this.state.pathTesselator,s=r?.vertexStarts,o=r?.instanceCount,a=r?.get("positions");if(!s||o===void 0||typeof r?.getPathSegmentIndices!="function")throw new Error("PathStyleExtension requires PathLayer tessellation data for path dashes.");let c=this.props.data?.attributes?.getPath,l=ArrayBuffer.isView(c)?c:c?.value,u=ArrayBuffer.isView(l),f=a&&(!c||r.normalize||r.opts?.isWebGPU);if(c&&!u||!f&&!u)throw new Error("PathStyleExtension cannot calculate whole-path dash metrics from GPU-only getPath data; supply data.attributes.instanceDashOffsets.");let d=e.value,h=e.size,p=Math.max(0,t),m=Math.min(i,s.length-1),g=3,v=3,y=0;if(!f){let x=l.BYTES_PER_ELEMENT;g=c?.size||(this.props.positionFormat==="XY"?2:3),v=c?.stride?c.stride/x:g,y=c?.offset?c.offset/x:0}let b=new Array(3),w=un.getUniforms({viewport:this.context.viewport,modelMatrix:this.props.modelMatrix,coordinateSystem:this.props.coordinateSystem,coordinateOrigin:this.props.coordinateOrigin,autoWrapLongitude:this.wrapLongitude}),E=x=>{if(f)b[0]=a[x*3],b[1]=a[x*3+1],b[2]=a[x*3+2];else{let T=y+x*v;b[0]=l[T],b[1]=l[T+1],b[2]=g===3?l[T+2]:0}return b};e.startIndices=s;for(let x=p;x1)for(let V=T;V0&&(t[c]=t[c-1]+yt.dist(a,o)),a=o;return t[s-1]=0,t}};dl.defaultProps=eG;dl.extensionName="PathStyleExtension";var ab=dl;Ce();Fe();var rG=new Uint32Array([0,2,1,0,3,2]),sG=new Float32Array([0,1,0,0,1,0,1,1]);function cb(n,e){if(!e)return oG(n);let t=Math.max(Math.abs(n[0][0]-n[3][0]),Math.abs(n[1][0]-n[2][0])),i=Math.max(Math.abs(n[1][1]-n[0][1]),Math.abs(n[2][1]-n[3][1])),r=Math.ceil(t/e)+1,s=Math.ceil(i/e)+1,o=(r-1)*(s-1)*6,a=new Uint32Array(o),c=new Float32Array(r*s*2),l=new Float64Array(r*s*3),u=0,f=0;for(let d=0;d0&&p>0&&(a[f++]=u-s,a[f++]=u-s-1,a[f++]=u-1,a[f++]=u-s,a[f++]=u-1,a[f++]=u),u++}}return{vertexCount:o,positions:l,indices:a,texCoords:c}}function oG(n){let e=new Float64Array(12);for(let t=0;t, + coordinateConversion: f32, + desaturate: f32, + tintColor: vec3, + transparentColor: vec4, +}; + +@group(0) @binding(auto) var bitmap: BitmapUniforms; +@group(0) @binding(auto) var bitmapTexture: texture_2d; +@group(0) @binding(auto) var bitmapTextureSampler: sampler; +`,UT=`layout(std140) uniform bitmapUniforms { + vec4 bounds; + float coordinateConversion; + float desaturate; + vec3 tintColor; + vec4 transparentColor; +} bitmap; +`,$T={name:"bitmap",source:cG,vs:UT,fs:UT,uniformTypes:{bounds:"vec4",coordinateConversion:"f32",desaturate:"f32",tintColor:"vec3",transparentColor:"vec4"}};var GT=`struct Attributes { + @location(0) positions: vec3, + @location(1) positions64Low: vec3, + @location(2) texCoords: vec2, +}; + +struct Varyings { + @builtin(position) position: vec4, + @location(0) vTexCoord: vec2, + @location(1) vTexPos: vec2, + @location(2) pickingColor: vec3, + @location(3) pickingDepth: f32, +}; + +// from degrees to Web Mercator +fn lnglat_to_mercator(lnglat: vec2) -> vec2 { + let x = lnglat.x; + let y = clamp(lnglat.y, -89.9, 89.9); + return vec2( + radians(x) + PI, + PI + log(tan(PI * 0.25 + radians(y) * 0.5)) + ) * WORLD_SCALE; +} + +// from Web Mercator to degrees +fn mercator_to_lnglat(xy: vec2) -> vec2 { + let position = xy / WORLD_SCALE; + return degrees(vec2( + position.x - PI, + atan(exp(position.y - PI)) * 2.0 - PI * 0.5 + )); +} + +fn color_desaturate(colorValue: vec3) -> vec3 { + let luminance = (colorValue.r + colorValue.g + colorValue.b) * 0.333333333; + return mix(colorValue, vec3(luminance), bitmap.desaturate); +} + +fn color_tint(colorValue: vec3) -> vec3 { + return colorValue * bitmap.tintColor; +} + +fn apply_opacity(colorValue: vec3, alpha: f32) -> vec4 { + if (bitmap.transparentColor.a == 0.0) { + return vec4(colorValue, alpha); + } + let blendedAlpha = alpha + bitmap.transparentColor.a * (1.0 - alpha); + let highLightRatio = alpha / blendedAlpha; + let blendedRGB = mix(bitmap.transparentColor.rgb, colorValue, highLightRatio); + return vec4(blendedRGB, blendedAlpha); +} + +fn getUV(position: vec2) -> vec2 { + return vec2( + (position.x - bitmap.bounds[0]) / (bitmap.bounds[2] - bitmap.bounds[0]), + (position.y - bitmap.bounds[3]) / (bitmap.bounds[1] - bitmap.bounds[3]) + ); +} + +// Pack the top 12 bits of two normalized floats into three 8-bit values. +fn packUVsIntoRGB(uv: vec2) -> vec3 { + let uv8bit = floor(uv * 256.0); + let uvFraction = fract(uv * 256.0); + let uvFraction4bit = floor(uvFraction * 16.0); + let fractions = uvFraction4bit.x + uvFraction4bit.y * 16.0; + return vec3(uv8bit, fractions) / 255.0; +} + +@vertex +fn vertexMain(attributes: Attributes) -> Varyings { + var output: Varyings; + geometry.worldPosition = attributes.positions; + geometry.uv = attributes.texCoords; + geometry.pickingColor = picking_getPickingColorFromIndex(0u); + + let projectedPosition = project_position_to_clipspace_and_commonspace( + attributes.positions, + attributes.positions64Low, + vec3(0.0) + ); + geometry.position = projectedPosition.commonPosition; + output.position = projectedPosition.clipPosition; + output.vTexCoord = attributes.texCoords; + output.vTexPos = vec2(0.0); + output.pickingColor = geometry.pickingColor; + output.pickingDepth = output.position.z / output.position.w; + + if (bitmap.coordinateConversion < -0.5) { + output.vTexPos = geometry.position.xy + project.commonOrigin.xy; + } else if (bitmap.coordinateConversion > 0.5) { + output.vTexPos = geometry.worldPosition.xy; + } + + return output; +} + +@fragment +fn fragmentMain(input: Varyings) -> @location(0) vec4 { + var uv = input.vTexCoord; + if (bitmap.coordinateConversion < -0.5) { + uv = getUV(mercator_to_lnglat(input.vTexPos)); + } else if (bitmap.coordinateConversion > 0.5) { + uv = getUV(lnglat_to_mercator(input.vTexPos)); + } + + let bitmapColor = textureSample(bitmapTexture, bitmapTextureSampler, uv); + var fragColor = apply_opacity( + color_tint(color_desaturate(bitmapColor.rgb)), + bitmapColor.a * layer.opacity + ); + + geometry.uv = uv; + + if (picking.isActive > 0.5) { + if (picking.isAttribute > 0.5) { + return vec4(input.pickingDepth, 0.0, 0.0, 1.0); + } + return vec4(packUVsIntoRGB(uv), 1.0); + } + + if (picking.isHighlightActive > 0.5) { + let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor); + if (picking_isColorZero(abs(input.pickingColor - highlightedObjectColor))) { + let highLightAlpha = picking.highlightColor.a; + let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha); + if (blendedAlpha > 0.0) { + let highLightRatio = highLightAlpha / blendedAlpha; + fragColor = vec4( + mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio), + blendedAlpha + ); + } else { + fragColor = vec4(fragColor.rgb, 0.0); + } + } + } + + return deckgl_premultiplied_alpha(fragColor); +} +`;var VT=`#version 300 es +#define SHADER_NAME bitmap-layer-vertex-shader + +in vec2 texCoords; +in vec3 positions; +in vec3 positions64Low; + +out vec2 vTexCoord; +out vec2 vTexPos; + +const vec3 pickingColor = vec3(1.0, 0.0, 0.0); + +void main(void) { + geometry.worldPosition = positions; + geometry.uv = texCoords; + geometry.pickingColor = pickingColor; + + gl_Position = project_position_to_clipspace(positions, positions64Low, vec3(0.0), geometry.position); + DECKGL_FILTER_GL_POSITION(gl_Position, geometry); + + vTexCoord = texCoords; + + if (bitmap.coordinateConversion < -0.5) { + vTexPos = geometry.position.xy + project.commonOrigin.xy; + } else if (bitmap.coordinateConversion > 0.5) { + vTexPos = geometry.worldPosition.xy; + } + + vec4 color = vec4(0.0); + DECKGL_FILTER_COLOR(color, geometry); +} +`;var lG=` +vec3 packUVsIntoRGB(vec2 uv) { + // Extract the top 8 bits. We want values to be truncated down so we can add a fraction + vec2 uv8bit = floor(uv * 256.); + + // Calculate the normalized remainders of u and v parts that do not fit into 8 bits + // Scale and clamp to 0-1 range + vec2 uvFraction = fract(uv * 256.); + vec2 uvFraction4bit = floor(uvFraction * 16.); + + // Remainder can be encoded in blue channel, encode as 4 bits for pixel coordinates + float fractions = uvFraction4bit.x + uvFraction4bit.y * 16.; + + return vec3(uv8bit, fractions) / 255.; +} +`,WT=`#version 300 es +#define SHADER_NAME bitmap-layer-fragment-shader + +#ifdef GL_ES +precision highp float; +#endif + +uniform sampler2D bitmapTexture; + +in vec2 vTexCoord; +in vec2 vTexPos; + +out vec4 fragColor; + +/* projection utils */ +const float TILE_SIZE = 512.0; +const float PI = 3.1415926536; +const float WORLD_SCALE = TILE_SIZE / PI / 2.0; + +// from degrees to Web Mercator +vec2 lnglat_to_mercator(vec2 lnglat) { + float x = lnglat.x; + float y = clamp(lnglat.y, -89.9, 89.9); + return vec2( + radians(x) + PI, + PI + log(tan(PI * 0.25 + radians(y) * 0.5)) + ) * WORLD_SCALE; +} + +// from Web Mercator to degrees +vec2 mercator_to_lnglat(vec2 xy) { + xy /= WORLD_SCALE; + return degrees(vec2( + xy.x - PI, + atan(exp(xy.y - PI)) * 2.0 - PI * 0.5 + )); +} +/* End projection utils */ + +// apply desaturation +vec3 color_desaturate(vec3 color) { + float luminance = (color.r + color.g + color.b) * 0.333333333; + return mix(color, vec3(luminance), bitmap.desaturate); +} + +// apply tint +vec3 color_tint(vec3 color) { + return color * bitmap.tintColor; +} + +// blend with background color +vec4 apply_opacity(vec3 color, float alpha) { + if (bitmap.transparentColor.a == 0.0) { + return vec4(color, alpha); + } + float blendedAlpha = alpha + bitmap.transparentColor.a * (1.0 - alpha); + float highLightRatio = alpha / blendedAlpha; + vec3 blendedRGB = mix(bitmap.transparentColor.rgb, color, highLightRatio); + return vec4(blendedRGB, blendedAlpha); +} + +vec2 getUV(vec2 pos) { + return vec2( + (pos.x - bitmap.bounds[0]) / (bitmap.bounds[2] - bitmap.bounds[0]), + (pos.y - bitmap.bounds[3]) / (bitmap.bounds[1] - bitmap.bounds[3]) + ); +} + +${lG} + +void main(void) { + vec2 uv = vTexCoord; + if (bitmap.coordinateConversion < -0.5) { + vec2 lnglat = mercator_to_lnglat(vTexPos); + uv = getUV(lnglat); + } else if (bitmap.coordinateConversion > 0.5) { + vec2 commonPos = lnglat_to_mercator(vTexPos); + uv = getUV(commonPos); + } + vec4 bitmapColor = texture(bitmapTexture, uv); + + fragColor = apply_opacity(color_tint(color_desaturate(bitmapColor.rgb)), bitmapColor.a * layer.opacity); + + geometry.uv = uv; + DECKGL_FILTER_COLOR(fragColor, geometry); + + if (bool(picking.isActive) && !bool(picking.isAttribute)) { + // Since instance information is not used, we can use picking color for pixel index + fragColor.rgb = packUVsIntoRGB(uv); + } +} +`;var uG={image:{type:"image",value:null,async:!0},bounds:{type:"array",value:[1,0,0,1],compare:!0},_imageCoordinateSystem:"default",desaturate:{type:"number",min:0,max:1,value:0},transparentColor:{type:"color",value:[0,0,0,0]},tintColor:{type:"color",value:[255,255,255]},textureParameters:{type:"object",ignore:!0,value:null}},hl=class extends Ci{getShaders(){return super.getShaders({vs:VT,fs:WT,source:GT,modules:[zn,Gn,Wn,$T]})}initializeState(){let e=this.getAttributeManager(),t=!0;e.add({indices:{size:1,isIndexed:!0,update:i=>i.value=this.state.mesh.indices,noAlloc:t},positions:{size:3,type:"float64",fp64:this.use64bitPositions(),update:i=>i.value=this.state.mesh.positions,noAlloc:t},texCoords:{size:2,update:i=>i.value=this.state.mesh.texCoords,noAlloc:t}})}updateState({props:e,oldProps:t,changeFlags:i}){let r=this.getAttributeManager();if(i.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),r.invalidateAll()),e.bounds!==t.bounds){let s=this.state.mesh,o=this._createMesh();this.state.model.setVertexCount(o.vertexCount);for(let a in o)s&&s[a]!==o[a]&&r.invalidate(a);this.setState({mesh:o,...this._getCoordinateUniforms()})}else e._imageCoordinateSystem!==t._imageCoordinateSystem&&this.setState(this._getCoordinateUniforms())}getPickingInfo(e){let{image:t}=this.props,i=e.info;if(!i.color||!t)return i.bitmap=null,i;let{width:r,height:s}=t;i.index=0;let o=fG(i.color);return i.bitmap={size:{width:r,height:s},uv:o,pixel:[Math.floor(o[0]*r),Math.floor(o[1]*s)]},i}disablePickingIndex(){this.setState({disablePicking:!0})}restorePickingColors(){this.setState({disablePicking:!1})}_updateAutoHighlight(e){super._updateAutoHighlight({...e,color:this.encodePickingColor(0)})}_createMesh(){let{bounds:e}=this.props,t=e;return jT(e)&&(t=[[e[0],e[1]],[e[0],e[3]],[e[2],e[3]],[e[2],e[1]]]),cb(t,this.context.viewport.resolution)}_getModel(){let e=this.context.device.type==="webgpu"?this.getAttributeManager().getBufferLayouts({isInstanced:!1}).filter(t=>t.name!=="indices"):this.getAttributeManager().getBufferLayouts();return new Ze(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:e,topology:"triangle-list",isInstanced:!1})}draw(e){let{shaderModuleProps:t}=e,{model:i,coordinateConversion:r,bounds:s,disablePicking:o}=this.state,{image:a,desaturate:c,transparentColor:l,tintColor:u}=this.props;if(!(t.picking.isActive&&o)&&a&&i){let f={bitmapTexture:a,bounds:s,coordinateConversion:r,desaturate:c,tintColor:u.slice(0,3).map(d=>d/255),transparentColor:l.map(d=>d/255)};i.shaderInputs.setProps({bitmap:f}),i.draw(this.context.renderPass)}}_getCoordinateUniforms(){let{_imageCoordinateSystem:e}=this.props;if(e!=="default"){let{bounds:t}=this.props;if(!jT(t))throw new Error("_imageCoordinateSystem only supports rectangular bounds");let i=this.context.viewport.resolution?"lnglat":"cartesian";if(e=e==="lnglat"?"lnglat":"cartesian",e==="lnglat"&&i==="cartesian")return{coordinateConversion:-1,bounds:t};if(e==="cartesian"&&i==="lnglat"){let r=ht([t[0],t[1]]),s=ht([t[2],t[3]]);return{coordinateConversion:1,bounds:[r[0],r[1],s[0],s[1]]}}}return{coordinateConversion:0,bounds:[0,0,0,0]}}};hl.layerName="BitmapLayer";hl.defaultProps=uG;var lb=hl;function fG(n){let[e,t,i]=n,r=(i&240)/256,s=(i&15)/16;return[(e+s)/256,(t+r)/256]}function jT(n){return Number.isFinite(n[0])}Ce();var HT=`layout(std140) uniform scatterplotUniforms { + float radiusScale; + float radiusMinPixels; + float radiusMaxPixels; + float lineWidthScale; + float lineWidthMinPixels; + float lineWidthMaxPixels; + float stroked; + float filled; + bool antialiasing; + bool billboard; + highp int radiusUnits; + highp int lineWidthUnits; +} scatterplot; +`,YT={name:"scatterplot",vs:HT,fs:HT,source:"",uniformTypes:{radiusScale:"f32",radiusMinPixels:"f32",radiusMaxPixels:"f32",lineWidthScale:"f32",lineWidthMinPixels:"f32",lineWidthMaxPixels:"f32",stroked:"f32",filled:"f32",antialiasing:"f32",billboard:"f32",radiusUnits:"i32",lineWidthUnits:"i32"}};var qT=`#version 300 es +#define SHADER_NAME scatterplot-layer-vertex-shader +in vec3 positions; +in vec3 instancePositions; +in vec3 instancePositions64Low; +in float instanceRadius; +in float instanceLineWidths; +in vec4 instanceFillColors; +in vec4 instanceLineColors; +#ifdef USE_ROW_INDEXES +in float rowIndexes; +#endif +in vec2 instancePixelOffset; +out vec4 vFillColor; +out vec4 vLineColor; +out vec2 unitPosition; +out float innerUnitRadius; +out float outerRadiusPixels; +void main(void) { +geometry.worldPosition = instancePositions; +outerRadiusPixels = clamp( +project_size_to_pixel(scatterplot.radiusScale * instanceRadius, scatterplot.radiusUnits), +scatterplot.radiusMinPixels, scatterplot.radiusMaxPixels +); +float lineWidthPixels = clamp( +project_size_to_pixel(scatterplot.lineWidthScale * instanceLineWidths, scatterplot.lineWidthUnits), +scatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels +); +outerRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0; +float edgePadding = scatterplot.antialiasing ? (outerRadiusPixels + SMOOTH_EDGE_RADIUS) / outerRadiusPixels : 1.0; +unitPosition = edgePadding * positions.xy; +geometry.uv = unitPosition; +#ifdef USE_ROW_INDEXES +geometry.pickingColor = picking_getPickingColorFromIndex(rowIndexes); +#else +geometry.pickingColor = picking_getPickingColorFromInstanceID(); +#endif +innerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / outerRadiusPixels; +if (scatterplot.billboard) { +gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position); +DECKGL_FILTER_GL_POSITION(gl_Position, geometry); +vec3 offset = edgePadding * positions * outerRadiusPixels; +offset.xy += instancePixelOffset; +DECKGL_FILTER_SIZE(offset, geometry); +gl_Position.xy += project_pixel_size_to_clipspace(offset.xy); +} else { +vec3 offset = edgePadding * positions * project_pixel_size(outerRadiusPixels); +offset.xy += project_pixel_size(instancePixelOffset); +DECKGL_FILTER_SIZE(offset, geometry); +gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset, geometry.position); +DECKGL_FILTER_GL_POSITION(gl_Position, geometry); +} +vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * layer.opacity); +DECKGL_FILTER_COLOR(vFillColor, geometry); +vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity); +DECKGL_FILTER_COLOR(vLineColor, geometry); +} +`;var ZT=`#version 300 es +#define SHADER_NAME scatterplot-layer-fragment-shader +precision highp float; +in vec4 vFillColor; +in vec4 vLineColor; +in vec2 unitPosition; +in float innerUnitRadius; +in float outerRadiusPixels; +out vec4 fragColor; +void main(void) { +geometry.uv = unitPosition; +float distToCenter = length(unitPosition) * outerRadiusPixels; +float inCircle = scatterplot.antialiasing ? +smoothedge(distToCenter, outerRadiusPixels) : +step(distToCenter, outerRadiusPixels); +if (inCircle == 0.0) { +discard; +} +if (scatterplot.stroked > 0.5) { +float isLine = scatterplot.antialiasing ? +smoothedge(innerUnitRadius * outerRadiusPixels, distToCenter) : +step(innerUnitRadius * outerRadiusPixels, distToCenter); +if (scatterplot.filled > 0.5) { +fragColor = mix(vFillColor, vLineColor, isLine); +} else { +if (isLine == 0.0) { +discard; +} +fragColor = vec4(vLineColor.rgb, vLineColor.a * isLine); +} +} else if (scatterplot.filled < 0.5) { +discard; +} else { +fragColor = vFillColor; +} +fragColor.a *= inCircle; +DECKGL_FILTER_COLOR(fragColor, geometry); +} +`;var dG=`// Main shaders + +struct ScatterplotUniforms { + radiusScale: f32, + radiusMinPixels: f32, + radiusMaxPixels: f32, + lineWidthScale: f32, + lineWidthMinPixels: f32, + lineWidthMaxPixels: f32, + stroked: f32, + filled: i32, + antialiasing: i32, + billboard: i32, + radiusUnits: i32, + lineWidthUnits: i32, +}; + +@group(0) @binding(0) var scatterplot: ScatterplotUniforms; + +struct Attributes { + @builtin(instance_index) instanceIndex : u32, + @builtin(vertex_index) vertexIndex : u32, + @location(0) positions: vec3, + @location(1) instancePositions: vec3, + @location(2) instancePositions64Low: vec3, + @location(3) instanceRadius: f32, + @location(4) instanceLineWidths: f32, + @location(5) instanceFillColors: vec4, + @location(6) instanceLineColors: vec4, + @location(7) instancePixelOffset: vec2, + PICKING_COLOR_ATTRIBUTE +}; + +struct Varyings { + @builtin(position) position: vec4, + @location(0) vFillColor: vec4, + @location(1) vLineColor: vec4, + @location(2) unitPosition: vec2, + @location(3) innerUnitRadius: f32, + @location(4) outerRadiusPixels: f32, + @location(5) pickingColor: vec3, + @location(6) clipCoordinates: vec2, +}; + +@vertex +fn vertexMain(attributes: Attributes) -> Varyings { + var varyings: Varyings; + + // Draw an inline geometry constant array clip space triangle to verify that rendering works. + // var positions = array, 3>(vec2(0.0, 0.5), vec2(-0.5, -0.5), vec2(0.5, -0.5)); + // if (attributes.instanceIndex == 0) { + // varyings.position = vec4(positions[attributes.vertexIndex], 0.0, 1.0); + // return varyings; + // } + + geometry.worldPosition = attributes.instancePositions; + + // Multiply out radius and clamp to limits + varyings.outerRadiusPixels = clamp( + project_unit_size_to_pixel(scatterplot.radiusScale * attributes.instanceRadius, scatterplot.radiusUnits), + scatterplot.radiusMinPixels, scatterplot.radiusMaxPixels + ); + + // Multiply out line width and clamp to limits + let lineWidthPixels = clamp( + project_unit_size_to_pixel(scatterplot.lineWidthScale * attributes.instanceLineWidths, scatterplot.lineWidthUnits), + scatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels + ); + + // outer radius needs to offset by half stroke width + varyings.outerRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0; + // Expand geometry to accommodate edge smoothing + // WGSL selects the second value when the condition is true, so keep the antialiased path second. + let edgePadding = select( + 1.0, + (varyings.outerRadiusPixels + SMOOTH_EDGE_RADIUS) / varyings.outerRadiusPixels, + scatterplot.antialiasing != 0 + ); + + // position on the containing square in [-1, 1] space + varyings.unitPosition = edgePadding * attributes.positions.xy; + geometry.uv = varyings.unitPosition; + geometry.pickingColor = PICKING_COLOR_VALUE; + + varyings.innerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / varyings.outerRadiusPixels; + + if (scatterplot.billboard != 0) { + let projectedPosition = project_position_to_clipspace_and_commonspace( + attributes.instancePositions, + attributes.instancePositions64Low, + vec3(0.0) + ); + geometry.position = projectedPosition.commonPosition; + varyings.position = projectedPosition.clipPosition; + // DECKGL_FILTER_GL_POSITION(varyings.position, geometry); + var offset = edgePadding * attributes.positions * varyings.outerRadiusPixels; + offset = vec3(offset.xy + attributes.instancePixelOffset, offset.z); + // DECKGL_FILTER_SIZE(offset, geometry); + let clipPixels = project_pixel_size_to_clipspace(offset.xy); + varyings.position = vec4(varyings.position.x + clipPixels.x, varyings.position.y + clipPixels.y, varyings.position.z, varyings.position.w); + geometry.position = vec4( + geometry.position.xy + project_pixel_size_vec2(offset.xy), + geometry.position.zw + ); + } else { + var offset = edgePadding * attributes.positions * project_pixel_size_float(varyings.outerRadiusPixels); + offset = vec3(offset.xy + project_pixel_size_vec2(attributes.instancePixelOffset), offset.z); + // DECKGL_FILTER_SIZE(offset, geometry); + let projectedPosition = project_position_to_clipspace_and_commonspace( + attributes.instancePositions, + attributes.instancePositions64Low, + offset + ); + geometry.position = projectedPosition.commonPosition; + varyings.position = projectedPosition.clipPosition; + // DECKGL_FILTER_GL_POSITION(varyings.position, geometry); + } + + varyings.clipCoordinates = geometry.position.xy; + clip_filterPosition(&varyings.position, geometry.worldPosition.xy); + + // Apply opacity to instance color, or return instance picking color + varyings.vFillColor = vec4(attributes.instanceFillColors.rgb, attributes.instanceFillColors.a * layer.opacity); + // DECKGL_FILTER_COLOR(varyings.vFillColor, geometry); + varyings.vLineColor = vec4(attributes.instanceLineColors.rgb, attributes.instanceLineColors.a * layer.opacity); + // DECKGL_FILTER_COLOR(varyings.vLineColor, geometry); + varyings.pickingColor = geometry.pickingColor; + + return varyings; +} + +@fragment +fn fragmentMain(varyings: Varyings) -> @location(0) vec4 { + // var geometry: Geometry; + // geometry.uv = unitPosition; + + let distToCenter = length(varyings.unitPosition) * varyings.outerRadiusPixels; + let inCircle = select( + step(distToCenter, varyings.outerRadiusPixels), + smoothedge(distToCenter, varyings.outerRadiusPixels), + scatterplot.antialiasing != 0 + ); + + if (inCircle == 0.0) { + discard; + } + + var fragColor: vec4; + + if (scatterplot.stroked != 0) { + let isLine = select( + step(varyings.innerUnitRadius * varyings.outerRadiusPixels, distToCenter), + smoothedge(varyings.innerUnitRadius * varyings.outerRadiusPixels, distToCenter), + scatterplot.antialiasing != 0 + ); + + if (scatterplot.filled != 0) { + fragColor = mix(varyings.vFillColor, varyings.vLineColor, isLine); + } else { + if (isLine == 0.0) { + discard; + } + fragColor = vec4(varyings.vLineColor.rgb, varyings.vLineColor.a * isLine); + } + } else if (scatterplot.filled == 0) { + discard; + } else { + fragColor = varyings.vFillColor; + } + + fragColor.a *= inCircle; + + clip_filterColor(varyings.clipCoordinates); + + if (picking.isActive > 0.5) { + if (!picking_isColorValid(varyings.pickingColor)) { + discard; + } + return vec4(varyings.pickingColor, 1.0); + } + + if (picking.isHighlightActive > 0.5) { + let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor); + if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) { + let highLightAlpha = picking.highlightColor.a; + let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha); + if (blendedAlpha > 0.0) { + let highLightRatio = highLightAlpha / blendedAlpha; + fragColor = vec4( + mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio), + blendedAlpha + ); + } else { + fragColor = vec4(fragColor.rgb, 0.0); + } + } + } + + // Apply premultiplied alpha as required by transparent canvas + fragColor = deckgl_premultiplied_alpha(fragColor); + + return fragColor; + // return vec4(0, 0, 1, 1); +} +`;function XT(n){return dG.replace("PICKING_COLOR_ATTRIBUTE",n?"@location(8) rowIndexes: u32,":"").replace("PICKING_COLOR_VALUE",n?"picking_getPickingColorFromIndex(attributes.rowIndexes)":"picking_getPickingColorFromIndex(attributes.instanceIndex)")}var hG=`struct ClipUniforms { + enabled: i32, + mode: i32, + bounds: vec4, +}; + +@group(2) @binding(auto) var clipUniforms: ClipUniforms; + +fn clip_isInBounds(coordinates: vec2) -> bool { + return coordinates.x >= clipUniforms.bounds.x && + coordinates.y >= clipUniforms.bounds.y && + coordinates.x < clipUniforms.bounds.z && + coordinates.y < clipUniforms.bounds.w; +} + +fn clip_filterPosition(position: ptr>, instanceCoordinates: vec2) { + if ( + clipUniforms.enabled != 0 && + clipUniforms.mode == 1 && + !clip_isInBounds(instanceCoordinates) + ) { + *position = vec4(2.0, 2.0, 2.0, 1.0); + } +} + +fn clip_filterColor(geometryCoordinates: vec2) { + if ( + clipUniforms.enabled != 0 && + clipUniforms.mode == 0 && + !clip_isInBounds(geometryCoordinates) + ) { + discard; + } +} +`,pG={name:"clip",source:hG,props:{},uniforms:{},bindingLayout:[{name:"clip",group:2}],uniformTypes:{enabled:"i32",mode:"i32",bounds:"vec4"},defaultUniforms:{enabled:0,mode:0,bounds:[0,0,1,1]},getUniforms(n={}){let e={};return n.enabled!==void 0&&(e.enabled=n.enabled?1:0),n.mode!==void 0&&(e.mode=n.mode==="instance"?1:0),n.bounds!==void 0&&(e.bounds=n.bounds),e}},zo=pG;var KT=[0,0,0,255],mG={radiusUnits:"meters",radiusScale:{type:"number",min:0,value:1},radiusMinPixels:{type:"number",min:0,value:0},radiusMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},lineWidthUnits:"meters",lineWidthScale:{type:"number",min:0,value:1},lineWidthMinPixels:{type:"number",min:0,value:0},lineWidthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,getPosition:{type:"accessor",value:n=>n.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:KT},getLineColor:{type:"accessor",value:KT},getLineWidth:{type:"accessor",value:1},getPixelOffset:{type:"accessor",value:[0,0]},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}},pl=class extends Ci{getShaders(){let e=!!this.props.data?.attributes?.rowIndexes;return super.getShaders({vs:qT,fs:ZT,source:XT(e),defines:e?{USE_ROW_INDEXES:!0}:{},modules:[Gn,zn,Wn,YT,...this.context.device.type==="webgpu"?[zo]:[]]})}initializeState(){let e=this.props.data?.attributes?.rowIndexes?{rowIndexes:{size:1,type:"uint32",noAlloc:!0}}:{};this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceRadius:{size:1,transition:!0,accessor:"getRadius",defaultValue:1,bufferGroup:"scatterplot-instance-data"},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255],bufferGroup:"scatterplot-instance-data"},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255],bufferGroup:"scatterplot-instance-data"},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1,bufferGroup:"scatterplot-instance-data"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset",bufferGroup:"scatterplot-instance-data"},...e})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{radiusUnits:t,radiusScale:i,radiusMinPixels:r,radiusMaxPixels:s,stroked:o,filled:a,billboard:c,antialiasing:l,lineWidthUnits:u,lineWidthScale:f,lineWidthMinPixels:d,lineWidthMaxPixels:h}=this.props,p={stroked:o,filled:a,billboard:c,antialiasing:l,radiusUnits:Zt[t],radiusScale:i,radiusMinPixels:r,radiusMaxPixels:s,lineWidthUnits:Zt[u],lineWidthScale:f,lineWidthMinPixels:d,lineWidthMaxPixels:h},m=this.state.model;m.shaderInputs.setProps({scatterplot:p}),m.draw(this.context.renderPass)}_getModel(){let e=[-1,-1,0,1,-1,0,-1,1,0,1,1,0];return new Ze(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Kt({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(e)}}}),isInstanced:!0})}};pl.defaultProps=mG;pl.layerName="ScatterplotLayer";var ub=pl;var Jd={CLOCKWISE:1,COUNTER_CLOCKWISE:-1};function ml(n,e,t={}){return QT(n,t)!==e?(gG(n,t),!0):!1}function QT(n,e={}){return Math.sign(eh(n,e))}var fb={x:0,y:1,z:2};function eh(n,e={}){let{start:t=0,end:i=n.length,plane:r="xy"}=e,s=e.size||2,o=0,a=fb[r[0]],c=fb[r[1]];for(let l=t,u=i-s;l0){let r=!0;for(let s=0;se[2]&&(t|=2),n[1]e[3]&&(t|=8),t}function yl(n,e){let{size:t=2,broken:i=!1,gridResolution:r=10,gridOffset:s=[0,0],startIndex:o=0,endIndex:a=n.length}=e||{},c=(a-o)/t,l=[],u=[l],f=or(n,0,t,o),d,h,p=tL(f,r,s,[]),m=[];wt(l,f);for(let g=1;gt&&(l=[],u.push(l),wt(l,f)),h=_l(d,p)}wt(l,d),gl(f,d)}return i?u:u[0]}var JT=0,yG=1;function bl(n,e=null,t){if(!n.length)return[];let{size:i=2,gridResolution:r=10,gridOffset:s=[0,0],edgeTypes:o=!1}=t||{},a=[],c=[{pos:n,types:o?new Array(n.length/i).fill(yG):null,holes:e||[]}],l=[[],[]],u=[];for(;c.length;){let{pos:f,types:d,holes:h}=c.shift();vG(f,i,h[0]||f.length,l),u=tL(l[0],r,s,u);let p=_l(l[1],u);if(p){let m=eL(f,d,i,0,h[0]||f.length,u,p),g={pos:m[0].pos,types:m[0].types,holes:[]},v={pos:m[1].pos,types:m[1].types,holes:[]};c.push(g,v);for(let y=0;y=0?(wt(l,h)&&f.push(m),w+=p):f.length&&(f[f.length-1]=JT),gl(g,h),v=p,y=m;return[b?{pos:c,types:e&&u}:null,w?{pos:l,types:e&&f}:null]}function tL(n,e,t,i){let r=Math.floor((n[0]-t[0])/e)*e+t[0],s=Math.floor((n[1]-t[1])/e)*e+t[1];return i[0]=r,i[1]=s,i[2]=r+e,i[3]=s+e,i}function bG(n,e,t){t&8?(n[1]+=e,n[3]+=e):t&4?(n[1]-=e,n[3]-=e):t&2?(n[0]+=e,n[2]+=e):t&1&&(n[0]-=e,n[2]-=e)}function vG(n,e,t,i){let r=1/0,s=-1/0,o=1/0,a=-1/0;for(let c=0;cs?l:s,o=ua?u:a}return i[0][0]=r,i[0][1]=o,i[1][0]=s,i[1][1]=a,i}function nh(n,e){for(let t=0;tr&&(r=a,s=o-1)}return s}function EG(n,e,t,i,r=xG){let s=n[t],o=n[i-e];if(Math.abs(s-o)>180){let a=or(n,0,e,t);a[0]+=Math.round((o-s)/360)*360,wt(n,a),a[1]=Math.sign(a[1])*r,wt(n,a),a[0]=s,wt(n,a)}}function nL(n,e,t,i){let r=n[0],s;for(let o=t;o180||a<-180)&&(s-=Math.round(a/360)*360),n[o]=r=s}}function iL(n,e){let t,i=n.length/e;for(let s=0;s=e.length&&(t+=1-e.length/r);let s=t*r;return i[0]=e[s],i[1]=e[s+1],i[2]=r===3&&e[s+2]||0,i}isClosed(e){if(!this.normalize)return!!this.opts.loop;let{positionSize:t}=this,i=e.length-t;return e[0]===e[i]&&e[1]===e[i+1]&&(t===2||e[2]===e[i+2])}};function sL(n){return Array.isArray(n[0])}var TG=`struct PathUniforms { + widthScale: f32, + widthMinPixels: f32, + widthMaxPixels: f32, + jointType: f32, + capType: f32, + miterLimit: f32, + billboard: f32, + widthUnits: i32, +}; + +@group(0) @binding(auto) +var path: PathUniforms; +`,oL=`layout(std140) uniform pathUniforms { + float widthScale; + float widthMinPixels; + float widthMaxPixels; + float jointType; + float capType; + float miterLimit; + bool billboard; + highp int widthUnits; +} path; +`,aL={name:"path",source:TG,vs:oL,fs:oL,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",jointType:"f32",capType:"f32",miterLimit:"f32",billboard:"f32",widthUnits:"i32"}};var cL=`const EPSILON: f32 = 0.001; +const ZERO_OFFSET: vec3 = vec3(0.0, 0.0, 0.0); + +struct JoinResult { + offset: vec3, + cornerOffset: vec2, + miterLength: f32, + pathPosition: vec2, + pathLength: f32, + jointType: f32, +}; + +struct Attributes { + @location(0) positions: vec2, + @location(1) instanceTypes: f32, + @location(2) instanceLeftPositions: vec3, + @location(3) instanceStartPositions: vec3, + @location(4) instanceEndPositions: vec3, + @location(5) instanceRightPositions: vec3, + @location(6) instanceLeftPositions64Low: vec3, + @location(7) instanceStartPositions64Low: vec3, + @location(8) instanceEndPositions64Low: vec3, + @location(9) instanceRightPositions64Low: vec3, + @location(10) instanceStrokeWidths: f32, + @location(11) instanceColors: vec4, + @location(12) rowIndexes: u32, +}; + +struct Varyings { + @builtin(position) position: vec4, + @location(0) vColor: vec4, + @location(1) vCornerOffset: vec2, + @location(2) vMiterLength: f32, + @location(3) vPathPosition: vec2, + @location(4) vPathLength: f32, + @location(5) vJointType: f32, + // Location 6 is reserved for TripsLayer's injected vTime varying. + @location(7) clipCoordinates: vec2, +#ifdef DASH_ENABLED + @location(8) vPathBounds: vec2, +#endif +}; + +fn flipIfTrue(flag: bool) -> f32 { + return select(1.0, -1.0, flag); +} + +fn clipLine(position: vec4, refPosition: vec4) -> vec4 { + if (position.w < EPSILON) { + let r = (EPSILON - refPosition.w) / (position.w - refPosition.w); + return refPosition + (position - refPosition) * r; + } + return position; +} + +#ifdef DASH_ENABLED +// Return the visible interval of the original segment before clipLine moves either endpoint. +fn getClippedPathRange(startW: f32, endW: f32) -> vec2 { + let startClipped = startW < EPSILON; + let endClipped = endW < EPSILON; + if (startClipped && endClipped) { + return vec2(0.0, 0.0); + } + if (startClipped || endClipped) { + let intersection = clamp((EPSILON - startW) / (endW - startW), 0.0, 1.0); + if (startClipped) { + return vec2(intersection, 1.0); + } + return vec2(0.0, intersection); + } + return vec2(0.0, 1.0); +} +#endif + +fn getLineJoinOffset( + prevPoint: vec3, + currPoint: vec3, + nextPoint: vec3, + width: vec2, +#ifdef DASH_ENABLED + sourcePathLength: f32, + sourcePathRange: vec2, +#endif +#ifdef ANTIALIASING + coverageScale: f32, +#endif + positions: vec2, + instanceTypes: f32 +) -> JoinResult { + let isEnd = positions.x > 0.0; + let sideOfPath = positions.y; + let isJoint = select(0.0, 1.0, sideOfPath == 0.0); + + var deltaA3 = currPoint - prevPoint; + var deltaB3 = nextPoint - currPoint; + + let rotationResult = project_needs_rotation(currPoint); + if (path.billboard == 0.0 && rotationResult.needsRotation) { + deltaA3 = rotationResult.transform * deltaA3; + deltaB3 = rotationResult.transform * deltaB3; + } + + let deltaA = deltaA3.xy / width; + let deltaB = deltaB3.xy / width; + + let lenA = length(deltaA); + let lenB = length(deltaB); + + let dirA = select(vec2(0.0, 0.0), normalize(deltaA), lenA > 0.0); + let dirB = select(vec2(0.0, 0.0), normalize(deltaB), lenB > 0.0); + + let perpA = vec2(-dirA.y, dirA.x); + let perpB = vec2(-dirB.y, dirB.x); + + var tangent = dirA + dirB; + tangent = select(perpA, normalize(tangent), length(tangent) > 0.0); + let miterVec = vec2(-tangent.y, tangent.x); + let dir = select(dirB, dirA, isEnd); + let perp = select(perpB, perpA, isEnd); +#ifdef DASH_ENABLED + let segmentLength2D = select(lenB, lenA, isEnd); + + // Extrusion happens in the XY plane, so segmentLength2D is a 2D length and pathPosition.y + // below measures 2D distance along the segment. For a path that also moves in Z the true + // arc length is longer by this ratio. Scaling pathLength and pathPosition.y by it makes + // the coordinate measure real 3D distance while leaving the joint tests unchanged, since + // they compare the two against each other and both are scaled alike. Billboard mode + // extrudes in clip space, where the perspective divide has already reduced the segment to + // its screen projection, so its complete common-space length is supplied by the caller. + // Mirrors path-layer-vertex.glsl.ts. + let currDelta3 = select(deltaB3, deltaA3, isEnd); + let currLength2D = length(currDelta3.xy); + // Do not clamp a valid denominator to EPSILON: high-zoom Web Mercator deltas are often + // smaller than that in common space, and changing their scale corrupts even flat paths. + let safeLength2D = select(1.0, currLength2D, currLength2D > 0.0); + var arcLengthRatio = 1.0; + var pathPositionOffset = 0.0; + var pathLength = segmentLength2D; + if (path.billboard != 0.0) { + // clipLine may shorten the visible screen-space segment. Preserve the corresponding interval + // of the complete common-space arclength instead of compressing the full dash period into the + // visible span. Keep pathLength complete so justification is stable as the camera clips it. + let visiblePathLength = sourcePathLength * (sourcePathRange.y - sourcePathRange.x); + arcLengthRatio = 0.0; + if (segmentLength2D > 0.0) { + arcLengthRatio = visiblePathLength / segmentLength2D; + } + pathPositionOffset = sourcePathLength * sourcePathRange.x; + pathLength = sourcePathLength; + } else if (currLength2D > 0.0) { + arcLengthRatio = length(currDelta3) / safeLength2D; + pathLength = segmentLength2D * arcLengthRatio; + } +#else + let pathLength = select(lenB, lenA, isEnd); +#endif + + let sinHalfA = abs(dot(miterVec, perp)); + let cosHalfA = abs(dot(dirA, miterVec)); + let turnDirection = flipIfTrue(dirA.x * dirB.y >= dirA.y * dirB.x); + let cornerPosition = sideOfPath * turnDirection; + + var miterSize = 1.0 / max(sinHalfA, EPSILON); + miterSize = mix( + min(miterSize, max(lenA, lenB) / max(cosHalfA, EPSILON)), + miterSize, + step(0.0, cornerPosition) + ); + + var offsetVec = + mix(miterVec * miterSize, perp, step(0.5, cornerPosition)) * + (sideOfPath + isJoint * turnDirection); + + let isStartCap = lenA == 0.0 || (!isEnd && (instanceTypes == 1.0 || instanceTypes == 3.0)); + let isEndCap = lenB == 0.0 || (isEnd && (instanceTypes == 2.0 || instanceTypes == 3.0)); + let isCap = isStartCap || isEndCap; + + var jointType = path.jointType; + if (isCap) { + offsetVec = mix( + perp * sideOfPath, + dir * path.capType * 4.0 * flipIfTrue(isStartCap), + isJoint + ); + jointType = path.capType; + } + +#ifdef ANTIALIASING + let coverageOffsetVec = offsetVec * coverageScale; + var miterLength = dot(coverageOffsetVec, miterVec * turnDirection); +#else + var miterLength = dot(offsetVec, miterVec * turnDirection); +#endif + miterLength = select(miterLength, isJoint, isCap); + +#ifdef ANTIALIASING + let offsetFromStartOfPath = coverageOffsetVec + deltaA * select(0.0, 1.0, isEnd); +#else + let offsetFromStartOfPath = offsetVec + deltaA * select(0.0, 1.0, isEnd); +#endif + let pathPosition = vec2( + dot(offsetFromStartOfPath, perp), +#ifdef DASH_ENABLED + pathPositionOffset + dot(offsetFromStartOfPath, dir) * arcLengthRatio +#else + dot(offsetFromStartOfPath, dir) +#endif + ); + let isValid = step(f32(instanceTypes), 3.5); +#ifdef ANTIALIASING + var offset = vec3(coverageOffsetVec * width * isValid, 0.0); +#else + var offset = vec3(offsetVec * width * isValid, 0.0); +#endif + + if (path.billboard == 0.0 && rotationResult.needsRotation) { + offset = rotationResult.transform * offset; + } + +#ifdef ANTIALIASING + return JoinResult( + offset, coverageOffsetVec, miterLength, pathPosition, pathLength, jointType + ); +#else + return JoinResult(offset, offsetVec, miterLength, pathPosition, pathLength, jointType); +#endif +} + +@vertex +fn vertexMain(attributes: Attributes) -> Varyings { + var varyings: Varyings; + + geometry.pickingColor = picking_getPickingColorFromIndex(attributes.rowIndexes); + + let isEnd = attributes.positions.x; + + let prevPosition = mix(attributes.instanceLeftPositions, attributes.instanceStartPositions, isEnd); + let prevPosition64Low = mix( + attributes.instanceLeftPositions64Low, + attributes.instanceStartPositions64Low, + isEnd + ); + let currPosition = mix(attributes.instanceStartPositions, attributes.instanceEndPositions, isEnd); + let currPosition64Low = mix( + attributes.instanceStartPositions64Low, + attributes.instanceEndPositions64Low, + isEnd + ); + let nextPosition = mix(attributes.instanceEndPositions, attributes.instanceRightPositions, isEnd); + let nextPosition64Low = mix( + attributes.instanceEndPositions64Low, + attributes.instanceRightPositions64Low, + isEnd + ); + + geometry.worldPosition = currPosition; + + let widthPixels = + clamp( + project_unit_size_to_pixel(attributes.instanceStrokeWidths * path.widthScale, path.widthUnits), + path.widthMinPixels, + path.widthMaxPixels + ) / 2.0; + + if (path.billboard != 0.0) { +#ifdef DASH_ENABLED + let prevProjection = project_position_to_clipspace_and_commonspace( + prevPosition, prevPosition64Low, ZERO_OFFSET + ); + let nextProjection = project_position_to_clipspace_and_commonspace( + nextPosition, nextPosition64Low, ZERO_OFFSET + ); + let prevPositionCommon = prevProjection.commonPosition.xyz; + let nextPositionCommon = nextProjection.commonPosition.xyz; + var prevPositionScreen = prevProjection.clipPosition; + var nextPositionScreen = nextProjection.clipPosition; +#else + var prevPositionScreen = project_position_to_clipspace( + prevPosition, prevPosition64Low, ZERO_OFFSET + ); + var nextPositionScreen = project_position_to_clipspace( + nextPosition, nextPosition64Low, ZERO_OFFSET + ); +#endif + let currProjection = project_position_to_clipspace_and_commonspace( + currPosition, currPosition64Low, ZERO_OFFSET + ); + geometry.position = currProjection.commonPosition; + var currPositionScreen = currProjection.clipPosition; +#ifdef DASH_ENABLED + let currPositionCommon = currProjection.commonPosition.xyz; + let sourcePathStartScreen = mix(currPositionScreen, prevPositionScreen, isEnd); + let sourcePathEndScreen = mix(nextPositionScreen, currPositionScreen, isEnd); + let billboardPathRange = getClippedPathRange( + sourcePathStartScreen.w, sourcePathEndScreen.w + ); +#endif + + prevPositionScreen = clipLine(prevPositionScreen, currPositionScreen); + nextPositionScreen = clipLine(nextPositionScreen, currPositionScreen); + currPositionScreen = clipLine(currPositionScreen, mix(nextPositionScreen, prevPositionScreen, isEnd)); + +#ifdef ANTIALIASING + let coverageScale = select( + 1.0, + (widthPixels + 0.5 / project.devicePixelRatio) / max(widthPixels, 1e-6), + widthPixels > 0.0 + ); +#endif +#ifdef DASH_ENABLED + let currentDeltaCommon = select( + nextPositionCommon - currPositionCommon, + currPositionCommon - prevPositionCommon, + isEnd > 0.0 + ); + let billboardPathLength = select( + 0.0, + length(currentDeltaCommon) * project.scale / (widthPixels * project.focalDistance), + widthPixels > 0.0 + ); +#endif + let join = getLineJoinOffset( + prevPositionScreen.xyz / prevPositionScreen.w, + currPositionScreen.xyz / currPositionScreen.w, + nextPositionScreen.xyz / nextPositionScreen.w, + project_pixel_size_to_clipspace(vec2(widthPixels, widthPixels)), +#ifdef DASH_ENABLED + billboardPathLength, + billboardPathRange, +#endif +#ifdef ANTIALIASING + coverageScale, +#endif + attributes.positions, + attributes.instanceTypes + ); +#ifdef DASH_ENABLED + // Phase and justification use the complete source segment, while cap and joint coverage + // must still recognize the endpoints moved by clipLine. + varyings.vPathBounds = billboardPathLength * billboardPathRange; +#endif + + geometry.uv = join.pathPosition; + varyings.position = vec4( + currPositionScreen.xyz + join.offset * currPositionScreen.w, + currPositionScreen.w + ); + varyings.vCornerOffset = join.cornerOffset; + varyings.vMiterLength = join.miterLength; + varyings.vPathPosition = join.pathPosition; + varyings.vPathLength = join.pathLength; + varyings.vJointType = join.jointType; + } else { + let prevPositionCommon = project_position_vec3_f64(prevPosition, prevPosition64Low); + let currPositionCommon = project_position_vec3_f64(currPosition, currPosition64Low); + let nextPositionCommon = project_position_vec3_f64(nextPosition, nextPosition64Low); + + let width = vec2( + project_pixel_size_float(widthPixels), + project_pixel_size_float(widthPixels) + ); +#ifdef ANTIALIASING + let coverageScale = select( + 1.0, + (widthPixels + 0.5 / project.devicePixelRatio) / max(widthPixels, 1e-6), + widthPixels > 0.0 + ); +#endif + let join = getLineJoinOffset( + prevPositionCommon, + currPositionCommon, + nextPositionCommon, + width, +#ifdef DASH_ENABLED + 1.0, + vec2(0.0, 1.0), +#endif +#ifdef ANTIALIASING + coverageScale, +#endif + attributes.positions, + attributes.instanceTypes + ); +#ifdef DASH_ENABLED + varyings.vPathBounds = vec2(0.0, join.pathLength); +#endif + + geometry.position = vec4(currPositionCommon + join.offset, 1.0); + geometry.uv = join.pathPosition; + varyings.position = project_common_position_to_clipspace(geometry.position); + varyings.vCornerOffset = join.cornerOffset; + varyings.vMiterLength = join.miterLength; + varyings.vPathPosition = join.pathPosition; + varyings.vPathLength = join.pathLength; + varyings.vJointType = join.jointType; + } + + varyings.clipCoordinates = geometry.position.xy; + clip_filterPosition(&varyings.position, geometry.worldPosition.xy); + + varyings.vColor = vec4( + attributes.instanceColors.rgb, + attributes.instanceColors.a * layer.opacity + ); + return varyings; +} + +@fragment +fn fragmentMain(varyings: Varyings) -> @location(0) vec4 { + geometry.uv = varyings.vPathPosition; + +#ifdef ANTIALIASING + // Coordinates of the outer silhouette, in units of half-width: rounded joints and caps are + // bounded by the corner offset, everywhere else by the edge of the stroke. Dividing by the + // screen-space derivative converts the distance to the boundary into device pixels, which stays + // correct under perspective foreshortening and under extensions that rescale the stroke. +#ifdef DASH_ENABLED + let isCorner = + varyings.vPathPosition.y < varyings.vPathBounds.x || + varyings.vPathPosition.y > varyings.vPathBounds.y; +#else + let isCorner = varyings.vPathPosition.y < 0.0 || varyings.vPathPosition.y > varyings.vPathLength; +#endif + let isRound = varyings.vJointType > 0.5; + + // Distance to the silhouette in device pixels, from the derivative of the coordinate that + // bounds it. Computed before the discards below: derivatives need uniform control flow and are + // undefined after a discard in the quad. See dev-docs/RFCs/v9.4/analytic-antialiasing-rfc.md + let bodyCoord = abs(varyings.vPathPosition.x); + let cornerCoord = length(varyings.vCornerOffset); + // Both evaluated so each derivative stays on one field across the corner/body boundary + let bodyPixels = (1.0 - bodyCoord) / max(fwidth(bodyCoord), 1e-6); + let cornerPixels = (1.0 - cornerCoord) / max(fwidth(cornerCoord), 1e-6); +#ifdef PATH_STYLE_OFFSET + // Rounded corners still intersect the stroke-width envelope. Extensions may remap + // vPathPosition.x independently of vCornerOffset, as PathStyleExtension does for offsets. + let edgePixels = select(bodyPixels, min(cornerPixels, bodyPixels), isRound && isCorner); +#else + let edgePixels = select(bodyPixels, cornerPixels, isRound && isCorner); +#endif + + // Fragments outside the coverage ramp must not write depth or picking colors. + if (edgePixels <= -SMOOTH_EDGE_RADIUS) { + discard; + } + + if (isCorner) { + if (!isRound && varyings.vMiterLength > path.miterLimit + 1.0) { + discard; + } + } + + var color = varyings.vColor; + + // Feather one device pixel across the width only, before premultiplication. edgePixels is a + // signed device-pixel distance and SMOOTH_EDGE_RADIUS is 0.5, so this ramps across one pixel. + color.a *= smoothedge(0.0, edgePixels); +#else +#ifdef DASH_ENABLED + if ( + varyings.vPathPosition.y < varyings.vPathBounds.x || + varyings.vPathPosition.y > varyings.vPathBounds.y + ) { +#else + if ( + varyings.vPathPosition.y < 0.0 || + varyings.vPathPosition.y > varyings.vPathLength + ) { +#endif + if (varyings.vJointType > 0.5 && length(varyings.vCornerOffset) > 1.0) { + discard; + } + if ( + varyings.vJointType < 0.5 && + varyings.vMiterLength > path.miterLimit + 1.0 + ) { + discard; + } + } +#endif + + // Fragment-layer injections that discard pixels must run after analytic coverage derivatives. + // See TripsLayer, which rejects fragments outside of the active time window at this anchor. + // DECKGL_FILTER_COLOR + clip_filterColor(varyings.clipCoordinates); +#ifdef ANTIALIASING + return deckgl_premultiplied_alpha(color); +#else + return deckgl_premultiplied_alpha(varyings.vColor); +#endif +} +`;var lL=`#version 300 es +#define SHADER_NAME path-layer-vertex-shader +in vec2 positions; +in float instanceTypes; +in vec3 instanceStartPositions; +in vec3 instanceEndPositions; +in vec3 instanceLeftPositions; +in vec3 instanceRightPositions; +in vec3 instanceLeftPositions64Low; +in vec3 instanceStartPositions64Low; +in vec3 instanceEndPositions64Low; +in vec3 instanceRightPositions64Low; +in float instanceStrokeWidths; +in vec4 instanceColors; +in float rowIndexes; +uniform float opacity; +out vec4 vColor; +out vec2 vCornerOffset; +out float vMiterLength; +out vec2 vPathPosition; +out float vPathLength; +out float vJointType; +#ifdef DASH_ENABLED +out vec2 vPathBounds; +#endif +const float EPSILON = 0.001; +const vec3 ZERO_OFFSET = vec3(0.0); +float flipIfTrue(bool flag) { +return -(float(flag) * 2. - 1.); +} +vec3 getLineJoinOffset( +vec3 prevPoint, vec3 currPoint, vec3 nextPoint, +vec2 width +#ifdef DASH_ENABLED +, float sourcePathLength, vec2 sourcePathRange +#endif +#ifdef ANTIALIASING +, float coverageScale +#endif +) { +bool isEnd = positions.x > 0.0; +float sideOfPath = positions.y; +float isJoint = float(sideOfPath == 0.0); +vec3 deltaA3 = (currPoint - prevPoint); +vec3 deltaB3 = (nextPoint - currPoint); +mat3 rotationMatrix; +bool needsRotation = !path.billboard && project_needs_rotation(currPoint, rotationMatrix); +if (needsRotation) { +deltaA3 = deltaA3 * rotationMatrix; +deltaB3 = deltaB3 * rotationMatrix; +} +vec2 deltaA = deltaA3.xy / width; +vec2 deltaB = deltaB3.xy / width; +float lenA = length(deltaA); +float lenB = length(deltaB); +vec2 dirA = lenA > 0. ? normalize(deltaA) : vec2(0.0, 0.0); +vec2 dirB = lenB > 0. ? normalize(deltaB) : vec2(0.0, 0.0); +vec2 perpA = vec2(-dirA.y, dirA.x); +vec2 perpB = vec2(-dirB.y, dirB.x); +vec2 tangent = dirA + dirB; +tangent = length(tangent) > 0. ? normalize(tangent) : perpA; +vec2 miterVec = vec2(-tangent.y, tangent.x); +vec2 dir = isEnd ? dirA : dirB; +vec2 perp = isEnd ? perpA : perpB; +float L = isEnd ? lenA : lenB; +#ifdef DASH_ENABLED +vec3 currDelta3 = isEnd ? deltaA3 : deltaB3; +float currLength2D = length(currDelta3.xy); +float arcLengthRatio = 1.0; +float pathPositionOffset = 0.0; +float pathLength = L; +if (path.billboard) { +float visiblePathLength = sourcePathLength * (sourcePathRange.y - sourcePathRange.x); +arcLengthRatio = L > 0.0 ? visiblePathLength / L : 0.0; +pathPositionOffset = sourcePathLength * sourcePathRange.x; +pathLength = sourcePathLength; +} else if (currLength2D > 0.0) { +arcLengthRatio = length(currDelta3) / currLength2D; +pathLength = L * arcLengthRatio; +} +#endif +float sinHalfA = abs(dot(miterVec, perp)); +float cosHalfA = abs(dot(dirA, miterVec)); +float turnDirection = flipIfTrue(dirA.x * dirB.y >= dirA.y * dirB.x); +float cornerPosition = sideOfPath * turnDirection; +float miterSize = 1.0 / max(sinHalfA, EPSILON); +miterSize = mix( +min(miterSize, max(lenA, lenB) / max(cosHalfA, EPSILON)), +miterSize, +step(0.0, cornerPosition) +); +vec2 offsetVec = mix(miterVec * miterSize, perp, step(0.5, cornerPosition)) +* (sideOfPath + isJoint * turnDirection); +bool isStartCap = lenA == 0.0 || (!isEnd && (instanceTypes == 1.0 || instanceTypes == 3.0)); +bool isEndCap = lenB == 0.0 || (isEnd && (instanceTypes == 2.0 || instanceTypes == 3.0)); +bool isCap = isStartCap || isEndCap; +if (isCap) { +offsetVec = mix(perp * sideOfPath, dir * path.capType * 4.0 * flipIfTrue(isStartCap), isJoint); +vJointType = path.capType; +} else { +vJointType = path.jointType; +} +#ifdef ANTIALIASING +vec2 coverageOffsetVec = offsetVec * coverageScale; +#ifdef DASH_ENABLED +vPathLength = pathLength; +#else +vPathLength = L; +#endif +vCornerOffset = coverageOffsetVec; +vMiterLength = dot(vCornerOffset, miterVec * turnDirection); +vMiterLength = isCap ? isJoint : vMiterLength; +vec2 offsetFromStartOfPath = coverageOffsetVec + deltaA * float(isEnd); +vPathPosition = vec2( +dot(offsetFromStartOfPath, perp), +#ifdef DASH_ENABLED +pathPositionOffset + dot(offsetFromStartOfPath, dir) * arcLengthRatio +#else +dot(offsetFromStartOfPath, dir) +#endif +); +geometry.uv = vPathPosition; +float isValid = step(instanceTypes, 3.5); +vec3 offset = vec3(coverageOffsetVec * width * isValid, 0.0); +#else +#ifdef DASH_ENABLED +vPathLength = pathLength; +#else +vPathLength = L; +#endif +vCornerOffset = offsetVec; +vMiterLength = dot(vCornerOffset, miterVec * turnDirection); +vMiterLength = isCap ? isJoint : vMiterLength; +vec2 offsetFromStartOfPath = vCornerOffset + deltaA * float(isEnd); +vPathPosition = vec2( +dot(offsetFromStartOfPath, perp), +#ifdef DASH_ENABLED +pathPositionOffset + dot(offsetFromStartOfPath, dir) * arcLengthRatio +#else +dot(offsetFromStartOfPath, dir) +#endif +); +geometry.uv = vPathPosition; +float isValid = step(instanceTypes, 3.5); +vec3 offset = vec3(offsetVec * width * isValid, 0.0); +#endif +if (needsRotation) { +offset = rotationMatrix * offset; +} +return offset; +} +void clipLine(inout vec4 position, vec4 refPosition) { +if (position.w < EPSILON) { +float r = (EPSILON - refPosition.w) / (position.w - refPosition.w); +position = refPosition + (position - refPosition) * r; +} +} +#ifdef DASH_ENABLED +vec2 getClippedPathRange(float startW, float endW) { +bool startClipped = startW < EPSILON; +bool endClipped = endW < EPSILON; +if (startClipped && endClipped) { +return vec2(0.0); +} +if (startClipped || endClipped) { +float intersection = clamp((EPSILON - startW) / (endW - startW), 0.0, 1.0); +return startClipped ? vec2(intersection, 1.0) : vec2(0.0, intersection); +} +return vec2(0.0, 1.0); +} +#endif +void main() { +geometry.pickingColor = picking_getPickingColorFromIndex(rowIndexes); +vColor = vec4(instanceColors.rgb, instanceColors.a * layer.opacity); +float isEnd = positions.x; +vec3 prevPosition = mix(instanceLeftPositions, instanceStartPositions, isEnd); +vec3 prevPosition64Low = mix(instanceLeftPositions64Low, instanceStartPositions64Low, isEnd); +vec3 currPosition = mix(instanceStartPositions, instanceEndPositions, isEnd); +vec3 currPosition64Low = mix(instanceStartPositions64Low, instanceEndPositions64Low, isEnd); +vec3 nextPosition = mix(instanceEndPositions, instanceRightPositions, isEnd); +vec3 nextPosition64Low = mix(instanceEndPositions64Low, instanceRightPositions64Low, isEnd); +geometry.worldPosition = currPosition; +vec2 widthPixels = vec2(clamp( +project_size_to_pixel(instanceStrokeWidths * path.widthScale, path.widthUnits), +path.widthMinPixels, path.widthMaxPixels) / 2.0); +vec3 width; +if (path.billboard) { +#ifdef DASH_ENABLED +vec4 prevPositionCommon; +vec4 nextPositionCommon; +vec4 prevPositionScreen = project_position_to_clipspace( +prevPosition, prevPosition64Low, ZERO_OFFSET, prevPositionCommon +); +#else +vec4 prevPositionScreen = project_position_to_clipspace( +prevPosition, prevPosition64Low, ZERO_OFFSET +); +#endif +vec4 currPositionScreen = project_position_to_clipspace(currPosition, currPosition64Low, ZERO_OFFSET, geometry.position); +#ifdef DASH_ENABLED +vec4 nextPositionScreen = project_position_to_clipspace( +nextPosition, nextPosition64Low, ZERO_OFFSET, nextPositionCommon +); +#else +vec4 nextPositionScreen = project_position_to_clipspace( +nextPosition, nextPosition64Low, ZERO_OFFSET +); +#endif +#ifdef DASH_ENABLED +vec4 sourcePathStartScreen = mix(currPositionScreen, prevPositionScreen, isEnd); +vec4 sourcePathEndScreen = mix(nextPositionScreen, currPositionScreen, isEnd); +vec2 billboardPathRange = getClippedPathRange( +sourcePathStartScreen.w, sourcePathEndScreen.w +); +#endif +clipLine(prevPositionScreen, currPositionScreen); +clipLine(nextPositionScreen, currPositionScreen); +clipLine(currPositionScreen, mix(nextPositionScreen, prevPositionScreen, isEnd)); +width = vec3(widthPixels, 0.0); +DECKGL_FILTER_SIZE(width, geometry); +#ifdef ANTIALIASING +vec2 coveragePadding = vec2(0.5 / project.devicePixelRatio); +float coverageScale = length(width.xy) > 0.0 +? length(width.xy + coveragePadding) / length(width.xy) +: 1.0; +#endif +#ifdef DASH_ENABLED +vec3 currentDeltaCommon = isEnd > 0.0 +? geometry.position.xyz - prevPositionCommon.xyz +: nextPositionCommon.xyz - geometry.position.xyz; +float billboardPathLength = width.x > 0.0 +? length(currentDeltaCommon) * project.scale / (width.x * project.focalDistance) +: 0.0; +#endif +vec3 offset = getLineJoinOffset( +prevPositionScreen.xyz / prevPositionScreen.w, +currPositionScreen.xyz / currPositionScreen.w, +nextPositionScreen.xyz / nextPositionScreen.w, +project_pixel_size_to_clipspace(width.xy) +#ifdef DASH_ENABLED +, +billboardPathLength, billboardPathRange +#endif +#ifdef ANTIALIASING +, +coverageScale +#endif +); +#ifdef DASH_ENABLED +vPathBounds = billboardPathLength * billboardPathRange; +#endif +DECKGL_FILTER_GL_POSITION(currPositionScreen, geometry); +gl_Position = vec4(currPositionScreen.xyz + offset * currPositionScreen.w, currPositionScreen.w); +} else { +prevPosition = project_position(prevPosition, prevPosition64Low); +currPosition = project_position(currPosition, currPosition64Low); +nextPosition = project_position(nextPosition, nextPosition64Low); +width = vec3(project_pixel_size(widthPixels), 0.0); +DECKGL_FILTER_SIZE(width, geometry); +#ifdef ANTIALIASING +vec2 coveragePadding = project_pixel_size(vec2(0.5 / project.devicePixelRatio)); +float coverageScale = length(width.xy) > 0.0 +? length(width.xy + coveragePadding) / length(width.xy) +: 1.0; +#endif +vec3 offset = getLineJoinOffset( +prevPosition, currPosition, nextPosition, width.xy +#ifdef DASH_ENABLED +, 1.0, vec2(0.0, 1.0) +#endif +#ifdef ANTIALIASING +, coverageScale +#endif +); +#ifdef DASH_ENABLED +vPathBounds = vec2(0.0, vPathLength); +#endif +geometry.position = vec4(currPosition + offset, 1.0); +gl_Position = project_common_position_to_clipspace(geometry.position); +DECKGL_FILTER_GL_POSITION(gl_Position, geometry); +} +DECKGL_FILTER_COLOR(vColor, geometry); +} +`;var uL=`#version 300 es +#define SHADER_NAME path-layer-fragment-shader +precision highp float; +in vec4 vColor; +in vec2 vCornerOffset; +in float vMiterLength; +in vec2 vPathPosition; +in float vPathLength; +in float vJointType; +#ifdef DASH_ENABLED +in vec2 vPathBounds; +#endif +out vec4 fragColor; +void main(void) { +geometry.uv = vPathPosition; +#ifdef ANTIALIASING +#ifdef DASH_ENABLED +bool isCorner = vPathPosition.y < vPathBounds.x || vPathPosition.y > vPathBounds.y; +#else +bool isCorner = vPathPosition.y < 0.0 || vPathPosition.y > vPathLength; +#endif +bool isRound = vJointType > 0.5; +float bodyCoord = abs(vPathPosition.x); +float cornerCoord = length(vCornerOffset); +float bodyPixels = (1.0 - bodyCoord) / max(fwidth(bodyCoord), 1e-6); +float cornerPixels = (1.0 - cornerCoord) / max(fwidth(cornerCoord), 1e-6); +#ifdef PATH_STYLE_OFFSET +float edgePixels = isRound && isCorner ? min(cornerPixels, bodyPixels) : bodyPixels; +#else +float edgePixels = isRound && isCorner ? cornerPixels : bodyPixels; +#endif +if (edgePixels <= -SMOOTH_EDGE_RADIUS) { +discard; +} +if (isCorner) { +if (!isRound && vMiterLength > path.miterLimit + 1.0) { +discard; +} +} +fragColor = vColor; +fragColor.a *= smoothedge(0.0, edgePixels); +#else +#ifdef DASH_ENABLED +if (vPathPosition.y < vPathBounds.x || vPathPosition.y > vPathBounds.y) { +#else +if (vPathPosition.y < 0.0 || vPathPosition.y > vPathLength) { +#endif +if (vJointType > 0.5 && length(vCornerOffset) > 1.0) { +discard; +} +if (vJointType < 0.5 && vMiterLength > path.miterLimit + 1.0) { +discard; +} +} +fragColor = vColor; +#endif +DECKGL_FILTER_COLOR(fragColor, geometry); +} +`;var dL=[0,0,0,255],LG={widthUnits:"meters",widthScale:{type:"number",min:0,value:1},widthMinPixels:{type:"number",min:0,value:0},widthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},jointRounded:!1,capRounded:!1,miterLimit:{type:"number",min:0,value:4},antialiasing:!1,billboard:!1,_pathType:null,getPath:{type:"accessor",value:n=>n.path},getColor:{type:"accessor",value:dL},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},pb={enter:(n,e)=>e.length?e.subarray(e.length-n.length):n};function MG(n){if(n.isGeospatial)return null;let{unitsPerMeter:e}=n.distanceScales;return[e[0],e[1],e[2]]}function fL(n,e){return n===e||!!(n&&e&&n.length===e.length&&n.every((t,i)=>t===e[i]))}var wl=class extends Ci{getShaders(){let{antialiasing:e}=this.props;return super.getShaders({vs:lL,fs:uL,source:cL,defines:e?{ANTIALIASING:1}:{},modules:[Gn,zn,Wn,aL,...this.context.device.type==="webgpu"?[zo]:[]]})}get wrapLongitude(){return!1}getBounds(){return this.context.device.type==="webgpu"?null:this.getAttributeManager()?.getBounds(["vertexPositions"])}getPathProjectionScale(e){let t=this.props.coordinateSystem;if(!!!this.getAttributeManager()?.getAttributes().instanceDashOffsets)return null;if(e instanceof yi&&e.zoom>=12&&(t==="default"||t==="lnglat"||t==="cartesian")){let o=un.getUniforms({viewport:e,coordinateSystem:t,coordinateOrigin:this.props.coordinateOrigin,autoWrapLongitude:this.wrapLongitude});return[e.projectionMode,o.coordinateOrigin[1],o.commonOrigin[1],...o.commonUnitsPerWorldUnit,...o.commonUnitsPerWorldUnit2,o.commonUnitsPerMeter[2]]}let s=MG(e);return s?[e.projectionMode,...s]:[e.projectionMode]}shouldUpdateState(e){let{viewport:t}=this.context;return super.shouldUpdateState(e)||this.state?.tessellationResolution!==t.resolution||!fL(this.state?.pathProjectionScale,this.getPathProjectionScale(t))}initializeState(){let t=this.context.device.type==="webgpu";this.getAttributeManager().addInstanced({...t?{pathPositions:{size:24,type:"float32",transition:!1,accessor:"getPath",update:this.calculateWebGPUPositions,shaderAttributes:{instanceLeftPositions:{size:3,elementOffset:0},instanceStartPositions:{size:3,elementOffset:3},instanceEndPositions:{size:3,elementOffset:6},instanceRightPositions:{size:3,elementOffset:9},instanceLeftPositions64Low:{size:3,elementOffset:12},instanceStartPositions64Low:{size:3,elementOffset:15},instanceEndPositions64Low:{size:3,elementOffset:18},instanceRightPositions64Low:{size:3,elementOffset:21}},noAlloc:!0}}:{vertexPositions:{size:3,vertexOffset:1,type:"float64",fp64:this.use64bitPositions(),transition:pb,accessor:"getPath",update:this.calculatePositions,noAlloc:!0,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}}},instanceTypes:{size:1,type:t?"float32":"uint8",update:this.calculateSegmentTypes,noAlloc:!0},instanceStrokeWidths:{size:1,accessor:"getWidth",transition:t?!1:pb,defaultValue:1,bufferGroup:"path-instance-data"},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",accessor:"getColor",transition:t?!1:pb,defaultValue:dL,bufferGroup:"path-instance-data"},rowIndexes:{size:1,type:"uint32",accessor:(r,{index:s})=>r&&r.__source?r.__source.index:s,bufferGroup:"path-instance-data"}}),this.setState({pathTesselator:new xl({fp64:this.use64bitPositions(),isWebGPU:t}),tessellationResolution:this.context.viewport.resolution,pathProjectionScale:this.getPathProjectionScale(this.context.viewport)})}updateState(e){super.updateState(e);let{props:t,oldProps:i,changeFlags:r}=e,s=this.getAttributeManager(),{viewport:o}=this.context,a=this.state.tessellationResolution!==o.resolution,c=this.getPathProjectionScale(o),l=!fL(this.state.pathProjectionScale,c),f=r.updateTriggersChanged&&(r.updateTriggersChanged.all||r.updateTriggersChanged.getPath)||t._pathType!==i._pathType||t.positionFormat!==i.positionFormat||t.wrapLongitude!==i.wrapLongitude||a;if(r.dataChanged||f){let{pathTesselator:h}=this.state,p=t.data.attributes||{};h.updateGeometry({data:t.data,geometryBuffer:p.getPath,buffers:p,normalize:!t._pathType,loop:t._pathType==="loop",getGeometry:t.getPath,positionFormat:t.positionFormat,wrapLongitude:t.wrapLongitude,resolution:o.resolution,dataChanged:f?void 0:r.dataChanged}),this.setState({numInstances:h.instanceCount,startIndices:h.vertexStarts,tessellationResolution:o.resolution,pathProjectionScale:c}),!r.dataChanged||f?s.invalidateAll():l&&s.invalidate("instanceDashOffsets")}else l&&(this.setState({pathProjectionScale:c}),s.invalidate("instanceDashOffsets"));(r.extensionsChanged||t.antialiasing!==i.antialiasing)&&(this.state.model?.destroy(),this.state.model=this._getModel(),s.invalidateAll())}getPickingInfo(e){let t=super.getPickingInfo(e),{index:i}=t,r=this.props.data;return r[0]&&r[0].__source&&(t.object=r.find(s=>s.__source.index===i)),t}disablePickingIndex(e){let t=this.props.data;if(t[0]&&t[0].__source)for(let i=0;i=0&&u=1&&n[0].length>=2&&Number.isFinite(n[0][0])}function qG(n){let e=n[0],t=n[n.length-1];return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function ZG(n,e,t,i){for(let r=0;ra/e));let s=$o(n),o=i&&e===3;if(t){let a=s.length;s=s.slice();let c=[];for(let l=0;lc&&a>l||(c>l?(t||(s=s.slice()),xL(s,0,2,1)):(t||(s=s.slice()),xL(s,2,0,1)))}return(0,wL.default)(s,r,e)}var Tl=class extends sr{constructor(e){let{fp64:t,IndexType:i=Uint32Array}=e;super({...e,attributes:{positions:{size:3,type:t?Float64Array:Float32Array},vertexValid:{type:Uint16Array,size:1},indices:{type:i,size:1}}})}get(e){let{attributes:t}=this;return e==="indices"?t.indices&&t.indices.subarray(0,this.vertexCount):t[e]}updateGeometry(e){super.updateGeometry(e);let t=this.buffers.indices;if(t)this.vertexCount=(t.value||t).length;else if(this.data&&!this.getGeometry)throw new Error("missing indices buffer")}normalizeGeometry(e){if(this.normalize){let t=EL(e,this.positionSize);return this.opts.resolution?bl($o(t),Cl(t),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?hb($o(t),Cl(t),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):t}return e}getGeometrySize(e){if(PL(e)){let t=0;for(let i of e)t+=this.getGeometrySize(i);return t}return $o(e).length/this.positionSize}getGeometryFromBuffer(e){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(e):null}updateGeometryAttributes(e,t){if(e&&PL(e))for(let i of e){let r=this.getGeometrySize(i);t.geometrySize=r,this.updateGeometryAttributes(i,t),t.vertexStart+=r,t.indexStart=this.indexStarts[t.geometryIndex+1]}else{let i=e;this._updateIndices(i,t),this._updatePositions(i,t),this._updateVertexValid(i,t)}}_updateIndices(e,{geometryIndex:t,vertexStart:i,indexStart:r}){let{attributes:s,indexStarts:o,typedArrayManager:a}=this,c=s.indices;if(!c||!e)return;let l=r,u=SL(e,this.positionSize,this.opts.preproject,this.opts.full3d);c=a.allocate(c,r+u.length,{copy:!0});for(let f=0;f2?o[c*s+2]:0;r[a*3]=l,r[a*3+1]=u,r[a*3+2]=f}}_updateVertexValid(e,{vertexStart:t,geometrySize:i}){let{positionSize:r}=this,s=this.attributes.vertexValid,o=e&&Cl(e);if(e&&e.edgeTypes?s.set(e.edgeTypes,t):s.fill(1,t,t+i),o)for(let a=0;a0&&!Number.isFinite(n[0])}var KG=`struct SolidPolygonUniforms { + extruded: f32, + isWireframe: f32, + elevationScale: f32, +}; + +@group(0) @binding(auto) var solidPolygon: SolidPolygonUniforms; +`,CL=`layout(std140) uniform solidPolygonUniforms { + bool extruded; + bool isWireframe; + float elevationScale; +} solidPolygon; +`,TL={name:"solidPolygon",source:KG,vs:CL,fs:CL,uniformTypes:{extruded:"f32",isWireframe:"f32",elevationScale:"f32"}};var ch=`in vec4 fillColors; +in vec4 lineColors; +in float rowIndexes; +out vec4 vColor; +struct PolygonProps { +vec3 positions; +vec3 positions64Low; +vec3 normal; +float elevations; +}; +vec3 project_offset_normal(vec3 vector) { +if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT || +project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSETS) { +return normalize(vector * project.commonUnitsPerWorldUnit); +} +return project_normal(vector); +} +void calculatePosition(PolygonProps props) { +vec3 pos = props.positions; +vec3 pos64Low = props.positions64Low; +vec3 normal = props.normal; +vec4 colors = solidPolygon.isWireframe ? lineColors : fillColors; +geometry.worldPosition = props.positions; +geometry.pickingColor = picking_getPickingColorFromIndex(rowIndexes); +if (solidPolygon.extruded) { +pos.z += props.elevations * solidPolygon.elevationScale; +} +gl_Position = project_position_to_clipspace(pos, pos64Low, vec3(0.), geometry.position); +DECKGL_FILTER_GL_POSITION(gl_Position, geometry); +if (solidPolygon.extruded) { +#ifdef IS_SIDE_VERTEX +normal = project_offset_normal(normal); +#else +normal = project_normal(normal); +#endif +geometry.normal = normal; +vec3 lightColor = lighting_getLightColor(colors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal); +vColor = vec4(lightColor, colors.a * layer.opacity); +} else { +vColor = vec4(colors.rgb, colors.a * layer.opacity); +} +DECKGL_FILTER_COLOR(vColor, geometry); +} +`;var LL=`#version 300 es +#define SHADER_NAME solid-polygon-layer-vertex-shader +in vec3 vertexPositions; +in vec3 vertexPositions64Low; +in float elevations; +${ch} +void main(void) { +PolygonProps props; +props.positions = vertexPositions; +props.positions64Low = vertexPositions64Low; +props.elevations = elevations; +props.normal = vec3(0.0, 0.0, 1.0); +calculatePosition(props); +} +`;var ML=`#version 300 es +#define SHADER_NAME solid-polygon-layer-vertex-shader-side +#define IS_SIDE_VERTEX +in vec2 positions; +in vec3 vertexPositions; +in vec3 nextVertexPositions; +in vec3 vertexPositions64Low; +in vec3 nextVertexPositions64Low; +in float elevations; +in float instanceVertexValid; +${ch} +void main(void) { +if(instanceVertexValid < 0.5){ +gl_Position = vec4(0.); +return; +} +PolygonProps props; +vec3 pos; +vec3 pos64Low; +vec3 nextPos; +vec3 nextPos64Low; +#if RING_WINDING_ORDER_CW == 1 +pos = vertexPositions; +pos64Low = vertexPositions64Low; +nextPos = nextVertexPositions; +nextPos64Low = nextVertexPositions64Low; +#else +pos = nextVertexPositions; +pos64Low = nextVertexPositions64Low; +nextPos = vertexPositions; +nextPos64Low = vertexPositions64Low; +#endif +props.positions = mix(pos, nextPos, positions.x); +props.positions64Low = mix(pos64Low, nextPos64Low, positions.x); +props.normal = vec3( +pos.y - nextPos.y + (pos64Low.y - nextPos64Low.y), +nextPos.x - pos.x + (nextPos64Low.x - pos64Low.x), +0.0); +props.elevations = elevations * positions.y; +calculatePosition(props); +} +`;var AL=`#version 300 es +#define SHADER_NAME solid-polygon-layer-fragment-shader +precision highp float; +in vec4 vColor; +out vec4 fragColor; +void main(void) { +fragColor = vColor; +geometry.uv = vec2(0.); +DECKGL_FILTER_COLOR(fragColor, geometry); +} +`;function kL(){return`fn project_offset_normal(vector: vec3) -> vec3 { + if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT || + project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSETS) { + return normalize(vector * project.commonUnitsPerWorldUnit); + } + return project_normal(vector); +} + +fn apply_polygon_color( + colors: vec4, + normal: vec3, + position: vec4 +) -> vec4 { + if (solidPolygon.extruded > 0.5) { + let lightColor = lighting_getLightColor2( + colors.rgb, + project.cameraPosition, + position.xyz, + normal + ); + return vec4(lightColor, colors.a * layer.opacity); + } + return vec4(colors.rgb, colors.a * layer.opacity); +} +`}function RL(){return`@fragment +fn fragmentMain(inp: Varyings) -> @location(0) vec4 { + geometry.uv = vec2(0.0, 0.0); + + clip_filterColor(inp.clipCoordinates); + + if (picking.isActive > 0.5) { + if (!picking_isColorValid(inp.pickingColor)) { + discard; + } + return vec4(inp.pickingColor, 1.0); + } + + var fragColor = inp.vColor; + + if (picking.isHighlightActive > 0.5) { + let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor); + if (picking_isColorZero(abs(inp.pickingColor - highlightedObjectColor))) { + let highLightAlpha = picking.highlightColor.a; + let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha); + if (blendedAlpha > 0.0) { + let highLightRatio = highLightAlpha / blendedAlpha; + fragColor = vec4( + mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio), + blendedAlpha + ); + } else { + fragColor = vec4(fragColor.rgb, 0.0); + } + } + } + + return deckgl_premultiplied_alpha(fragColor); +} +`}function QG(){return`${kL()} + +struct Attributes { + @location(0) vertexPositions: vec3, + @location(1) vertexPositions64Low: vec3, + @location(2) elevations: f32, + @location(3) fillColors: vec4, + @location(4) lineColors: vec4, + @location(5) rowIndexes: u32, +}; + +struct Varyings { + @builtin(position) position: vec4, + @location(0) vColor: vec4, + @location(1) pickingColor: vec3, + @location(2) clipCoordinates: vec2, +}; + +@vertex +fn vertexMain(attributes: Attributes) -> Varyings { + var outp: Varyings; + + var pos = attributes.vertexPositions; + if (solidPolygon.extruded > 0.5) { + pos.z += attributes.elevations * solidPolygon.elevationScale; + } + + geometry.worldPosition = attributes.vertexPositions; + geometry.pickingColor = picking_getPickingColorFromIndex(attributes.rowIndexes); + + let projectedPosition = project_position_to_clipspace_and_commonspace( + pos, + attributes.vertexPositions64Low, + vec3(0.0) + ); + geometry.position = projectedPosition.commonPosition; + outp.position = projectedPosition.clipPosition; + + let normal = project_normal(vec3(0.0, 0.0, 1.0)); + geometry.normal = normal; + + let colors = select( + attributes.fillColors, + attributes.lineColors, + solidPolygon.isWireframe > 0.5 + ); + outp.vColor = apply_polygon_color(colors, normal, geometry.position); + outp.pickingColor = geometry.pickingColor; + + outp.clipCoordinates = geometry.position.xy; + clip_filterPosition(&outp.position, geometry.worldPosition.xy); + + return outp; +} + +${RL()} +`}function JG(n){return`const RING_WINDING_ORDER_CW: bool = ${n?"true":"false"}; + +${kL()} + +struct Attributes { + @location(0) positions: vec2, + @location(1) vertexPositions: vec3, + @location(2) vertexPositions64Low: vec3, + @location(3) nextVertexPositions: vec3, + @location(4) nextVertexPositions64Low: vec3, + @location(5) vertexValid: f32, + @location(6) elevations: f32, + @location(7) fillColors: vec4, + @location(8) lineColors: vec4, + @location(9) rowIndexes: u32, +}; + +struct Varyings { + @builtin(position) position: vec4, + @location(0) vColor: vec4, + @location(1) pickingColor: vec3, + @location(2) clipCoordinates: vec2, +}; + +@vertex +fn vertexMain(attributes: Attributes) -> Varyings { + var outp: Varyings; + outp.position = vec4(0.0); + outp.vColor = vec4(0.0); + outp.pickingColor = picking_getPickingColorFromIndex(attributes.rowIndexes); + outp.clipCoordinates = vec2(0.0); + + if (attributes.vertexValid < 0.5) { + return outp; + } + + let pos = select(attributes.nextVertexPositions, attributes.vertexPositions, RING_WINDING_ORDER_CW); + let pos64Low = select( + attributes.nextVertexPositions64Low, + attributes.vertexPositions64Low, + RING_WINDING_ORDER_CW + ); + let nextPos = select(attributes.vertexPositions, attributes.nextVertexPositions, RING_WINDING_ORDER_CW); + let nextPos64Low = select( + attributes.vertexPositions64Low, + attributes.nextVertexPositions64Low, + RING_WINDING_ORDER_CW + ); + + let position = mix(pos, nextPos, attributes.positions.x); + let position64Low = mix(pos64Low, nextPos64Low, attributes.positions.x); + + var worldPosition = position; + if (solidPolygon.extruded > 0.5) { + worldPosition.z += attributes.elevations * attributes.positions.y * solidPolygon.elevationScale; + } + + geometry.worldPosition = position; + geometry.pickingColor = picking_getPickingColorFromIndex(attributes.rowIndexes); + + let projectedPosition = project_position_to_clipspace_and_commonspace( + worldPosition, + position64Low, + vec3(0.0) + ); + geometry.position = projectedPosition.commonPosition; + outp.position = projectedPosition.clipPosition; + + let normal = project_offset_normal(vec3( + pos.y - nextPos.y + (pos64Low.y - nextPos64Low.y), + nextPos.x - pos.x + (nextPos64Low.x - pos64Low.x), + 0.0 + )); + geometry.normal = normal; + + let colors = select( + attributes.fillColors, + attributes.lineColors, + solidPolygon.isWireframe > 0.5 + ); + outp.vColor = apply_polygon_color(colors, normal, geometry.position); + outp.pickingColor = geometry.pickingColor; + + outp.clipCoordinates = geometry.position.xy; + clip_filterPosition(&outp.position, geometry.worldPosition.xy); + + return outp; +} + +${RL()} +`}function IL(n,e){return n==="top"?QG():JG(e)}var uh=[0,0,0,255],eV={filled:!0,extruded:!1,wireframe:!1,_normalize:!0,_windingOrder:"CW",_full3d:!1,elevationScale:{type:"number",min:0,value:1},getPolygon:{type:"accessor",value:n=>n.polygon},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:uh},getLineColor:{type:"accessor",value:uh},material:!0},lh={enter:(n,e)=>e.length?e.subarray(e.length-n.length):n},Ll=class extends Ci{getShaders(e){let t=!this.props._normalize&&this.props._windingOrder==="CCW"?0:1;return super.getShaders({vs:e==="top"?LL:ML,fs:AL,source:IL(e,!!t),defines:{RING_WINDING_ORDER_CW:t},modules:[Gn,zn,eo,Wn,TL,...this.context.device.type==="webgpu"?[zo]:[]]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){let{viewport:e}=this.context,{coordinateSystem:t}=this.props,{_full3d:i}=this.props;e.isGeospatial&&t==="default"&&(t="lnglat");let r;t==="lnglat"&&(i?r=e.projectPosition.bind(e):r=e.projectFlat.bind(e)),this.setState({numInstances:0,polygonTesselator:new Tl({preproject:r,fp64:this.use64bitPositions(),IndexType:Uint32Array})});let s=this.getAttributeManager(),o=!0,a=this.context.device.type==="webgpu";s.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:o},vertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:lh,accessor:"getPolygon",update:this.calculatePositions,noAlloc:o,...a?{}:{shaderAttributes:{nextVertexPositions:{vertexOffset:1}}}},...a?{nextVertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:!1,update:this.calculateNextPositions,noAlloc:o}}:{},[a?"vertexValid":"instanceVertexValid"]:{size:1,type:a?"float32":"uint16",stepMode:"instance",update:this.calculateVertexValid,noAlloc:o},elevations:{size:1,stepMode:"dynamic",transition:lh,accessor:"getElevation",bufferGroup:"solid-polygon-instance-data"},fillColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:lh,accessor:"getFillColor",defaultValue:uh,bufferGroup:"solid-polygon-instance-data"},lineColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:lh,accessor:"getLineColor",defaultValue:uh,bufferGroup:"solid-polygon-instance-data"},rowIndexes:{size:1,type:"uint32",stepMode:"dynamic",accessor:(c,{index:l})=>c&&c.__source?c.__source.index:l,bufferGroup:"solid-polygon-instance-data"}})}getPickingInfo(e){let t=super.getPickingInfo(e),{index:i}=t,r=this.props.data;return r[0]&&r[0].__source&&(t.object=r.find(s=>s.__source.index===i)),t}disablePickingIndex(e){let t=this.props.data;if(t[0]&&t[0].__source)for(let i=0;ia.destroy()),this.setState(this._getModels()),s.invalidateAll())}updateGeometry({props:e,oldProps:t,changeFlags:i}){if(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getPolygon)){let{polygonTesselator:s}=this.state,o=e.data.attributes||{};s.updateGeometry({data:e.data,normalize:e._normalize,geometryBuffer:o.getPolygon,buffers:this.context.device.type==="webgpu"?{...o}:o,getGeometry:e.getPolygon,positionFormat:e.positionFormat,wrapLongitude:e.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:i.dataChanged,full3d:e._full3d}),this.setState({numInstances:s.instanceCount,startIndices:s.vertexStarts}),i.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(){let{id:e,filled:t,extruded:i}=this.props,r,s,o;if(t){let a=this.getShaders("top");a.defines={...a.defines,NON_INSTANCED_MODEL:1};let c=this.getAttributeManager().getBufferLayouts({isInstanced:!1});this.context.device.type==="webgpu"&&(c=c.filter(l=>l.name!=="indices"&&l.name!=="vertexValid"&&l.name!=="instanceVertexValid"&&l.name!=="nextVertexPositions")),r=new Ze(this.context.device,{...a,id:`${e}-top`,topology:"triangle-list",bufferLayout:c,isIndexed:!0,userData:{excludeAttributes:{vertexValid:!0,instanceVertexValid:!0,nextVertexPositions:!0}}})}if(i){let a=this.getAttributeManager().getBufferLayouts({isInstanced:!0});this.context.device.type==="webgpu"&&(a=a.filter(c=>c.name!=="indices")),s=new Ze(this.context.device,{...this.getShaders("side"),id:`${e}-side`,bufferLayout:a,geometry:new Kt({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,1,1,0,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}}),o=new Ze(this.context.device,{...this.getShaders("side"),id:`${e}-wireframe`,bufferLayout:a,geometry:new Kt({topology:"line-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,0,1,1,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}})}return{models:[s,o,r].filter(Boolean),topModel:r,sideModel:s,wireframeModel:o}}calculateIndices(e){let{polygonTesselator:t}=this.state;e.startIndices=t.indexStarts,e.value=t.get("indices")}calculatePositions(e){let{polygonTesselator:t}=this.state;e.startIndices=t.vertexStarts;let i=this.props.data.attributes?.getPolygon;if(this.context.device.type==="webgpu"&&ArrayBuffer.isView(i?.value)){let{value:r,size:s=3,offset:o=0,stride:a}=i,c=o/r.BYTES_PER_ELEMENT,l=a?a/r.BYTES_PER_ELEMENT:s,u=new Float64Array(t.instanceCount*3);for(let f=0;f2?r[d+2]:0}e.value=u;return}e.value=t.get("positions")}calculateVertexValid(e){let t=this.props.data.attributes?.instanceVertexValid?.value,i=this.context.device.type==="webgpu"&&t?t:this.state.polygonTesselator.get("vertexValid");e.value=this.context.device.type==="webgpu"&&i?Float32Array.from(i):i}calculateNextPositions(e){let{polygonTesselator:t}=this.state,i=this.getAttributeManager().getAttributes(),r=i.vertexPositions.value,s=this.props.data.attributes?.instanceVertexValid?.value||i.vertexValid?.value||t.get("vertexValid");if(e.startIndices=t.vertexStarts,!r){e.value=r;return}let o=r.length/3,a=new r.constructor(r.length);for(let c=0;cnew dh(typeof n=="string"?n:n+"",void 0,OL);var NL=(n,e)=>{if(hh)n.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(let t of e){let i=document.createElement("style"),r=fh.litNonce;r!==void 0&&i.setAttribute("nonce",r),i.textContent=t.cssText,n.appendChild(i)}},wb=hh?n=>n:n=>n instanceof CSSStyleSheet?(e=>{let t="";for(let i of e.cssRules)t+=i.cssText;return DL(t)})(n):n;var{is:tV,defineProperty:nV,getOwnPropertyDescriptor:iV,getOwnPropertyNames:rV,getOwnPropertySymbols:sV,getPrototypeOf:oV}=Object,ph=globalThis,FL=ph.trustedTypes,aV=FL?FL.emptyScript:"",cV=ph.reactiveElementPolyfillSupport,Ml=(n,e)=>n,Eb={toAttribute(n,e){switch(e){case Boolean:n=n?aV:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,e){let t=n;switch(e){case Boolean:t=n!==null;break;case Number:t=n===null?null:Number(n);break;case Object:case Array:try{t=JSON.parse(n)}catch{t=null}}return t}},UL=(n,e)=>!tV(n,e),zL={attribute:!0,type:String,converter:Eb,reflect:!1,useDefault:!1,hasChanged:UL};Symbol.metadata??=Symbol("metadata"),ph.litPropertyMetadata??=new WeakMap;var Ti=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=zL){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let i=Symbol(),r=this.getPropertyDescriptor(e,i,t);r!==void 0&&nV(this.prototype,e,r)}}static getPropertyDescriptor(e,t,i){let{get:r,set:s}=iV(this.prototype,e)??{get(){return this[t]},set(o){this[t]=o}};return{get:r,set(o){let a=r?.call(this);s?.call(this,o),this.requestUpdate(e,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??zL}static _$Ei(){if(this.hasOwnProperty(Ml("elementProperties")))return;let e=oV(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Ml("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Ml("properties"))){let t=this.properties,i=[...rV(t),...sV(t)];for(let r of i)this.createProperty(r,t[r])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[i,r]of t)this.elementProperties.set(i,r)}this._$Eh=new Map;for(let[t,i]of this.elementProperties){let r=this._$Eu(t,i);r!==void 0&&this._$Eh.set(r,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let i=new Set(e.flat(1/0).reverse());for(let r of i)t.unshift(wb(r))}else e!==void 0&&t.push(wb(e));return t}static _$Eu(e,t){let i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return NL(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$ET(e,t){let i=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,i);if(r!==void 0&&i.reflect===!0){let s=(i.converter?.toAttribute!==void 0?i.converter:Eb).toAttribute(t,i.type);this._$Em=e,s==null?this.removeAttribute(r):this.setAttribute(r,s),this._$Em=null}}_$AK(e,t){let i=this.constructor,r=i._$Eh.get(e);if(r!==void 0&&this._$Em!==r){let s=i.getPropertyOptions(r),o=typeof s.converter=="function"?{fromAttribute:s.converter}:s.converter?.fromAttribute!==void 0?s.converter:Eb;this._$Em=r;let a=o.fromAttribute(t,s.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(e,t,i,r=!1,s){if(e!==void 0){let o=this.constructor;if(r===!1&&(s=this[e]),i??=o.getPropertyOptions(e),!((i.hasChanged??UL)(s,t)||i.useDefault&&i.reflect&&s===this._$Ej?.get(e)&&!this.hasAttribute(o._$Eu(e,i))))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:i,reflect:r,wrapped:s},o){i&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,o??t??this[e]),s!==!0||o!==void 0)||(this._$AL.has(e)||(this.hasUpdated||i||(t=void 0),this._$AL.set(e,t)),r===!0&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[r,s]of this._$Ep)this[r]=s;this._$Ep=void 0}let i=this.constructor.elementProperties;if(i.size>0)for(let[r,s]of i){let{wrapped:o}=s,a=this[r];o!==!0||this._$AL.has(r)||a===void 0||this.C(r,void 0,s,a)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(i=>i.hostUpdate?.()),this.update(t)):this._$EM()}catch(i){throw e=!1,this._$EM(),i}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(e){}firstUpdated(e){}};Ti.elementStyles=[],Ti.shadowRootOptions={mode:"open"},Ti[Ml("elementProperties")]=new Map,Ti[Ml("finalized")]=new Map,cV?.({ReactiveElement:Ti}),(ph.reactiveElementVersions??=[]).push("2.1.2");var Pb=globalThis,$L=n=>n,mh=Pb.trustedTypes,GL=mh?mh.createPolicy("lit-html",{createHTML:n=>n}):void 0,Cb="$lit$",Li=`lit$${Math.random().toFixed(9).slice(2)}$`,Tb="?"+Li,lV=`<${Tb}>`,ps=document,kl=()=>ps.createComment(""),Rl=n=>n===null||typeof n!="object"&&typeof n!="function",Lb=Array.isArray,qL=n=>Lb(n)||typeof n?.[Symbol.iterator]=="function",Sb=`[ +\f\r]`,Al=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,VL=/-->/g,WL=/>/g,ds=RegExp(`>|${Sb}(?:([^\\s"'>=/]+)(${Sb}*=${Sb}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`,"g"),jL=/'/g,HL=/"/g,ZL=/^(?:script|style|textarea|title)$/i,Mb=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),ys=Mb(1),Dye=Mb(2),Nye=Mb(3),ms=Symbol.for("lit-noChange"),Le=Symbol.for("lit-nothing"),YL=new WeakMap,hs=ps.createTreeWalker(ps,129);function XL(n,e){if(!Lb(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return GL!==void 0?GL.createHTML(e):e}var KL=(n,e)=>{let t=n.length-1,i=[],r,s=e===2?"":e===3?"":"",o=Al;for(let a=0;a"?(o=r??Al,f=-1):u[1]===void 0?f=-2:(f=o.lastIndex-u[2].length,l=u[1],o=u[3]===void 0?ds:u[3]==='"'?HL:jL):o===HL||o===jL?o=ds:o===VL||o===WL?o=Al:(o=ds,r=void 0);let h=o===ds&&n[a+1].startsWith("/>")?" ":"";s+=o===Al?c+lV:f>=0?(i.push(l),c.slice(0,f)+Cb+c.slice(f)+Li+h):c+Li+(f===-2?a:h)}return[XL(n,s+(n[t]||"")+(e===2?"":e===3?"":"")),i]},Il=class n{constructor({strings:e,_$litType$:t},i){let r;this.parts=[];let s=0,o=0,a=e.length-1,c=this.parts,[l,u]=KL(e,t);if(this.el=n.createElement(l,i),hs.currentNode=this.el.content,t===2||t===3){let f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(r=hs.nextNode())!==null&&c.length0){r.textContent=mh?mh.emptyScript:"";for(let h=0;h2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Le}_$AI(e,t=this,i,r){let s=this.strings,o=!1;if(s===void 0)e=gs(this,e,t,0),o=!Rl(e)||e!==this._$AH&&e!==ms,o&&(this._$AH=e);else{let a=e,c,l;for(e=s[0],c=0;c{let i=t?.renderBefore??e,r=i._$litPart$;if(r===void 0){let s=t?.renderBefore??null;i._$litPart$=r=new Go(e.insertBefore(kl(),s),s,void 0,t??{})}return r._$AI(n),r};var Ab=globalThis,ni=class extends Ti{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=JL(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return ms}};ni._$litElement$=!0,ni.finalized=!0,Ab.litElementHydrateSupport?.({LitElement:ni});var fV=Ab.litElementPolyfillSupport;fV?.({LitElement:ni});(Ab.litElementVersions??=[]).push("4.2.2");var{I:Kye}=QL;var e3=n=>n.strings===void 0;var t3={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},kb=n=>(...e)=>({_$litDirective$:n,values:e}),xh=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}};var Bl=(n,e)=>{let t=n._$AN;if(t===void 0)return!1;for(let i of t)i._$AO?.(e,!1),Bl(i,e);return!0},wh=n=>{let e,t;do{if((e=n._$AM)===void 0)break;t=e._$AN,t.delete(n),n=e}while(t?.size===0)},n3=n=>{for(let e;e=n._$AM;n=e){let t=e._$AN;if(t===void 0)e._$AN=t=new Set;else if(t.has(n))break;t.add(n),pV(e)}};function dV(n){this._$AN!==void 0?(wh(this),this._$AM=n,n3(this)):this._$AM=n}function hV(n,e=!1,t=0){let i=this._$AH,r=this._$AN;if(r!==void 0&&r.size!==0)if(e)if(Array.isArray(i))for(let s=t;s{n.type==t3.CHILD&&(n._$AP??=hV,n._$AQ??=dV)},Eh=class extends xh{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,i){super._$AT(e,t,i),n3(this),this.isConnected=e._$AU}_$AO(e,t=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),t&&(Bl(this,e),wh(this))}setValue(e){if(e3(this._$Ct))this._$Ct._$AI(e,this);else{let t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}};var Mi=()=>new Ib,Ib=class{},Rb=new WeakMap,Ai=kb(class extends Eh{render(n){return Le}update(n,[e]){let t=e!==this.G;return t&&this.rt(void 0),(t||this.lt!==this.ct)&&(this.G=e,this.ht=n.options?.host,this.rt(this.ct=n.element)),Le}rt(n){if(this.G!==void 0)if(this.isConnected||(n=void 0),typeof this.G=="function"){let e=this.ht??globalThis,t=Rb.get(e);t===void 0&&(t=new WeakMap,Rb.set(e,t)),t.get(this.G)!==void 0&&this.G.call(this.ht,void 0),t.set(this.G,n),n!==void 0&&this.G.call(this.ht,n)}else this.G.value=n}get lt(){return typeof this.G=="function"?Rb.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});function Ol(n,e,t){return n?e(n):t?.(n)}var Bb=n=>n??Le;var Ob=class extends ni{static properties={name:{type:String,reflect:!0},maximizable:{type:Boolean,reflect:!0},collapsible:{type:Boolean,reflect:!0},maximized:{type:Boolean,reflect:!0},collapsed:{type:Boolean,reflect:!0}};constructor(){super(),this.tabsRef=Mi(),this.contentRef=Mi(),this.headerRef=Mi(),this.controlsRef=Mi(),this.maximizeBtnRef=Mi(),this.collapseBtnRef=Mi(),this._onMaximizeClick=this._onMaximizeClick.bind(this),this._onCollapseClick=this._onCollapseClick.bind(this),this._onResetLayoutClick=this._onResetLayoutClick.bind(this)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.classList.add("ide-pane",`ide-pane-${this.paneName}`),this.performUpdate()}get paneName(){return this.name||this.getAttribute("name")||this.id.replace(/^pane-/,"")||"pane"}get tabsEl(){return this.hasUpdated||this.performUpdate(),this.tabsRef.value}get contentEl(){return this.hasUpdated||this.performUpdate(),this.contentRef.value}get headerEl(){return this.hasUpdated||this.performUpdate(),this.headerRef.value}get controlsEl(){return this.hasUpdated||this.performUpdate(),this.controlsRef.value}get maximizeBtn(){return this.hasUpdated||this.performUpdate(),this.maximizeBtnRef.value}get collapseBtn(){return this.hasUpdated||this.performUpdate(),this.collapseBtnRef.value}get _collapseIcon(){let e=this.paneName;return e==="bottom"?this.collapsed?"\u25B2":"\u25BC":e==="left"?this.collapsed?"\u25B6":"\u25C0":e==="right"?this.collapsed?"\u25C0":"\u25B6":"\u25BC"}get _collapseTitle(){let e=this.paneName,t=e.charAt(0).toUpperCase()+e.slice(1);return e==="bottom"?this.collapsed?"Expand Console":"Collapse Console":e==="left"?this.collapsed?"Expand Left Panel":"Collapse Left Panel":e==="right"?this.collapsed?"Expand Right Panel":"Collapse Right Panel":`Collapse ${t}`}_emit(e,t={}){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}_onMaximizeClick(e){e.stopPropagation(),this._emit("ide-pane-maximize",{pane:this.paneName})}_onCollapseClick(e){e.stopPropagation(),this._emit("ide-pane-collapse",{pane:this.paneName})}_onResetLayoutClick(e){e.stopPropagation(),this._emit("ide-layout-reset")}setMaximized(e){this.maximized=!!e,this.classList.toggle("maximized",this.maximized),this.maximizeBtn&&(this.maximizeBtn.textContent=this.maximized?"\u29C9":"\u2922",this.maximizeBtn.title=this.maximized?"Restore":"Maximize")}setCollapsed(e){this.collapsed=!!e,this.classList.toggle("collapsed",this.collapsed),this.collapseBtn&&(this.collapseBtn.textContent=this._collapseIcon,this.collapseBtn.title=this._collapseTitle)}build(){this.hasUpdated||this.performUpdate()}updated(e){super.updated(e),e.has("maximized")&&this.classList.toggle("maximized",!!this.maximized),e.has("collapsed")&&this.classList.toggle("collapsed",!!this.collapsed)}render(){let e=this.paneName,t=this.id||`pane-${e}`,i=this.maximizable||this.hasAttribute("maximizable"),r=this.collapsible||this.hasAttribute("collapsible");return ys` +
+
+
+ ${Ol(i,()=>ys` `)} - ${un(r,()=>ci` + ${Ol(r,()=>ys` `)}
-
- ${un(e==="main",()=>ci` +
+ ${Ol(e==="main",()=>ys` `)}
- `}},Lo=class{constructor(e,i={}){(this.host=e).addController(this),this.options=i,this._abort=null,this.isDragging=!1,this.startPos=0}hostDisconnected(){this.stop()}start(e,i=!0){e.preventDefault();try{this.host.setPointerCapture(e.pointerId)}catch{}this.isDragging=!0,this.host.classList.add("dragging"),document.body&&document.body.classList.add("is-resizing",i?"is-resizing-v":"is-resizing-h"),this.startPos=i?e.clientX:e.clientY,this.options.onStart?.({startPos:this.startPos,event:e}),this._abort=new AbortController;let{signal:o}=this._abort;window.addEventListener("pointermove",l=>{let h=i?l.clientX:l.clientY,u=h-this.startPos;this.options.onDrag?.({delta:u,currentPos:h,startPos:this.startPos,event:l})},{signal:o});let r=l=>{try{this.host.releasePointerCapture(e.pointerId)}catch{}this.stop(i),this.options.onEnd?.({event:l})};window.addEventListener("pointerup",r,{signal:o}),window.addEventListener("pointercancel",r,{signal:o})}stop(e=!0){this.isDragging&&(this.isDragging=!1,this.host.classList.remove("dragging"),document.body&&document.body.classList.remove("is-resizing","is-resizing-v","is-resizing-h"),this._abort?.abort(),this._abort=null)}},os=class extends Ee{static properties={for:{type:String},orientation:{type:String,reflect:!0}};constructor(){super(),this.orientation="vertical",this._connectedAbort=null,this.drag=new Lo(this,{onStart:({startPos:e})=>this._emit("start",{startPos:e}),onDrag:({delta:e,currentPos:i,startPos:o})=>this._emit("drag",{delta:e,currentPos:i,startPos:o}),onEnd:()=>this._emit("end")})}connectedCallback(){super.connectedCallback(),this._connectedAbort=new AbortController;let{signal:e}=this._connectedAbort;this.setAttribute("role","separator"),this.classList.add("ide-splitter"),this.performUpdate(),this.addEventListener("pointerdown",i=>this.drag.start(i,this.isVertical),{signal:e}),this.addEventListener("dblclick",()=>this._emit("reset"),{signal:e})}disconnectedCallback(){super.disconnectedCallback(),this._connectedAbort?.abort()}build(){}updated(e){super.updated(e);let i=this.isVertical;this.setAttribute("aria-orientation",i?"vertical":"horizontal"),this.classList.toggle("ide-splitter-v",i),this.classList.toggle("ide-splitter-h",!i)}get targetPane(){return this.for||this.getAttribute("for")||""}get isVertical(){return(this.orientation||this.getAttribute("orientation")||"vertical")==="vertical"}_emit(e,i={}){this.dispatchEvent(new CustomEvent(`ide-splitter-${e}`,{bubbles:!0,composed:!0,detail:{for:this.targetPane,orientation:this.isVertical?"vertical":"horizontal",...i}}))}},ko=class extends Ee{static properties={title:{type:String,reflect:!0},closable:{type:Boolean,reflect:!0},for:{type:String},active:{type:Boolean,reflect:!0}};constructor(){super(),this._connectedAbort=null,this.titleRef=Re(),this.closeBtnRef=Re(),this._onClick=this._onClick.bind(this),this._onCloseClick=this._onCloseClick.bind(this)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this._connectedAbort=new AbortController;let{signal:e}=this._connectedAbort;this.classList.add("ide-tab","lm_tab"),this.setAttribute("role","tab"),this.hasAttribute("aria-selected")||this.setAttribute("aria-selected","false"),this.addEventListener("click",this._onClick,{signal:e}),this.performUpdate()}disconnectedCallback(){super.disconnectedCallback(),this._connectedAbort?.abort()}_emit(e,i={}){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:i}))}_onClick(e){e&&e.target&&e.target.closest(".ide-tab-close")||this._emit("tab-select",{componentType:this.targetComponent})}_onCloseClick(e){e.stopPropagation(),this._emit("tab-close",{componentType:this.targetComponent})}get targetComponent(){return this.for||this.getAttribute("for")||this.getAttribute("data-component")||this.id.replace(/^tab-/,"")||""}get titleText(){return this.title||""}set titleText(e){this.title=e}get titleEl(){return this.hasUpdated||this.performUpdate(),this.titleRef.value}get closeBtn(){return this.hasUpdated||this.performUpdate(),this.closeBtnRef.value}setActive(e){this.active=!!e,this.performUpdate()}updated(e){super.updated(e),e.has("active")&&(this.classList.toggle("active",this.active),this.classList.toggle("lm_active",this.active),this.setAttribute("aria-selected",this.active?"true":"false"))}render(){let e=this.title||"",i=!!this.closable;return ci` - ${e} - ${un(i,()=>ci` + `}},Db=class{constructor(e,t={}){(this.host=e).addController(this),this.options=t,this._abort=null,this.isDragging=!1,this.startPos=0}hostDisconnected(){this.stop()}start(e,t=!0){e.preventDefault();try{this.host.setPointerCapture(e.pointerId)}catch{}this.isDragging=!0,this.host.classList.add("dragging"),document.body&&document.body.classList.add("is-resizing",t?"is-resizing-v":"is-resizing-h"),this.startPos=t?e.clientX:e.clientY,this.options.onStart?.({startPos:this.startPos,event:e}),this._abort=new AbortController;let{signal:i}=this._abort;window.addEventListener("pointermove",s=>{let o=t?s.clientX:s.clientY,a=o-this.startPos;this.options.onDrag?.({delta:a,currentPos:o,startPos:this.startPos,event:s})},{signal:i});let r=s=>{try{this.host.releasePointerCapture(e.pointerId)}catch{}this.stop(t),this.options.onEnd?.({event:s})};window.addEventListener("pointerup",r,{signal:i}),window.addEventListener("pointercancel",r,{signal:i})}stop(e=!0){this.isDragging&&(this.isDragging=!1,this.host.classList.remove("dragging"),document.body&&document.body.classList.remove("is-resizing","is-resizing-v","is-resizing-h"),this._abort?.abort(),this._abort=null)}},Ph=class extends ni{static properties={for:{type:String},orientation:{type:String,reflect:!0}};constructor(){super(),this.orientation="vertical",this._connectedAbort=null,this.drag=new Db(this,{onStart:({startPos:e})=>this._emit("start",{startPos:e}),onDrag:({delta:e,currentPos:t,startPos:i})=>this._emit("drag",{delta:e,currentPos:t,startPos:i}),onEnd:()=>this._emit("end")})}connectedCallback(){super.connectedCallback(),this._connectedAbort=new AbortController;let{signal:e}=this._connectedAbort;this.setAttribute("role","separator"),this.classList.add("ide-splitter"),this.performUpdate(),this.addEventListener("pointerdown",t=>this.drag.start(t,this.isVertical),{signal:e}),this.addEventListener("dblclick",()=>this._emit("reset"),{signal:e})}disconnectedCallback(){super.disconnectedCallback(),this._connectedAbort?.abort()}build(){}updated(e){super.updated(e);let t=this.isVertical;this.setAttribute("aria-orientation",t?"vertical":"horizontal"),this.classList.toggle("ide-splitter-v",t),this.classList.toggle("ide-splitter-h",!t)}get targetPane(){return this.for||this.getAttribute("for")||""}get isVertical(){return(this.orientation||this.getAttribute("orientation")||"vertical")==="vertical"}_emit(e,t={}){this.dispatchEvent(new CustomEvent(`ide-splitter-${e}`,{bubbles:!0,composed:!0,detail:{for:this.targetPane,orientation:this.isVertical?"vertical":"horizontal",...t}}))}},Nb=class extends ni{static properties={title:{type:String,reflect:!0},closable:{type:Boolean,reflect:!0},for:{type:String},active:{type:Boolean,reflect:!0}};constructor(){super(),this._connectedAbort=null,this.titleRef=Mi(),this.closeBtnRef=Mi(),this._onClick=this._onClick.bind(this),this._onCloseClick=this._onCloseClick.bind(this)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this._connectedAbort=new AbortController;let{signal:e}=this._connectedAbort;this.classList.add("ide-tab","lm_tab"),this.setAttribute("role","tab"),this.hasAttribute("aria-selected")||this.setAttribute("aria-selected","false"),this.addEventListener("click",this._onClick,{signal:e}),this.performUpdate()}disconnectedCallback(){super.disconnectedCallback(),this._connectedAbort?.abort()}_emit(e,t={}){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}_onClick(e){e&&e.target&&e.target.closest(".ide-tab-close")||this._emit("tab-select",{componentType:this.targetComponent})}_onCloseClick(e){e.stopPropagation(),this._emit("tab-close",{componentType:this.targetComponent})}get targetComponent(){return this.for||this.getAttribute("for")||this.getAttribute("data-component")||this.id.replace(/^tab-/,"")||""}get titleText(){return this.title||""}set titleText(e){this.title=e}get titleEl(){return this.hasUpdated||this.performUpdate(),this.titleRef.value}get closeBtn(){return this.hasUpdated||this.performUpdate(),this.closeBtnRef.value}setActive(e){this.active=!!e,this.performUpdate()}updated(e){super.updated(e),e.has("active")&&(this.classList.toggle("active",this.active),this.classList.toggle("lm_active",this.active),this.setAttribute("aria-selected",this.active?"true":"false"))}render(){let e=this.title||"",t=!!this.closable;return ys` + ${e} + ${Ol(t,()=>ys` ✕ `)} - `}};customElements.get("ide-pane")||customElements.define("ide-pane",Co);customElements.get("ide-splitter")||customElements.define("ide-splitter",os);customElements.get("ide-tab")||customElements.define("ide-tab",ko);var xa={DisplayControls:{pane:"left",title:"Display Controls",closable:!1},LayoutViewer:{pane:"main",title:"Layout",closable:!1},SchematicWidget:{pane:"main",title:"Schematic",closable:!0},"3DViewer":{pane:"main",title:"3D Viewer",closable:!0},TclConsole:{pane:"bottom",title:"Tcl Console",closable:!1},Inspector:{pane:"right",title:"Inspector",closable:!0},Browser:{pane:"right",title:"Hierarchy",closable:!0},TimingWidget:{pane:"right",title:"Timing",closable:!0},DRCWidget:{pane:"right",title:"DRC",closable:!0},SelectHighlight:{pane:"right",title:"Select Highlight",closable:!0},ClockWidget:{pane:"right",title:"Clock Tree",closable:!0},ChartsWidget:{pane:"right",title:"Charts",closable:!0},HelpWidget:{pane:"right",title:"Help",closable:!0}},ss={left:{cssVar:"--pane-left-width",defaultSize:"240px",minSize:140,maxFraction:.45,dimension:"width",isVertical:!0,invertDelta:!1},right:{cssVar:"--pane-right-width",defaultSize:"340px",minSize:160,maxFraction:.5,dimension:"width",isVertical:!0,invertDelta:!0},bottom:{cssVar:"--pane-bottom-height",defaultSize:"220px",minSize:70,maxFraction:.75,dimension:"height",isVertical:!1,invertDelta:!0}},rs=class{constructor(e){this.containerEl=e,this.factories=new Map,this.components=new Map,this.activeTabs={left:null,main:null,bottom:null,right:null},this.closedComponents=new Set,this.eventListeners=new Map,this._resizeScheduled=!1,this._ensureDOM(),this._initSplitters(),this._initControls(),this._initResizeObserver()}on(e,i){this.eventListeners.has(e)||this.eventListeners.set(e,new Set),this.eventListeners.get(e).add(i)}off(e,i){this.eventListeners.get(e)?.delete(i)}emit(e,...i){let o=this.eventListeners.get(e);if(o)for(let r of o)try{r(...i)}catch(l){console.error(l)}}_ensureDOM(){this.containerEl.classList.add("ide-layout"),this.containerEl.querySelector("#pane-left")||this._buildInitialLayoutTree(),this._resolvePaneReferences()}_buildInitialLayoutTree(){this.containerEl.appendChild(this._createGutterButton("left","\u25B6 Display Controls","Restore Display Controls")),this.containerEl.appendChild(this._createGutterButton("right","\u25C0 Tools & Inspector","Restore Right Panel")),this.containerEl.appendChild(this._createPane("pane-left","left")),this.containerEl.appendChild(this._createSplitter("splitter-left","left","vertical","Drag to resize panel"));let e=document.createElement("main");e.id="pane-center",e.className="ide-center",e.appendChild(this._createPane("pane-main","main",{maximizable:!0})),e.appendChild(this._createSplitter("splitter-bottom","bottom","horizontal","Drag to resize console")),e.appendChild(this._createGutterButton("bottom","\u25B2 Tcl Console","Restore Tcl Console")),e.appendChild(this._createPane("pane-bottom","bottom",{maximizable:!0,collapsible:!0})),this.containerEl.appendChild(e),this.containerEl.appendChild(this._createSplitter("splitter-right","right","vertical","Drag to resize panel")),this.containerEl.appendChild(this._createPane("pane-right","right",{maximizable:!0,collapsible:!0}))}_createGutterButton(e,i,o){let r=document.createElement("button");r.id=`gutter-expand-${e}`,r.className=`ide-gutter-expand ide-gutter-${e}`,r.title=o;let l=document.createElement("span");return l.textContent=i,r.appendChild(l),r}_createPane(e,i,o={}){let r=document.createElement("ide-pane");return r.id=e,r.setAttribute("name",i),o.maximizable&&r.setAttribute("maximizable",""),o.collapsible&&r.setAttribute("collapsible",""),r}_createSplitter(e,i,o,r){let l=document.createElement("ide-splitter");return l.id=e,l.setAttribute("for",i),l.setAttribute("orientation",o),l.title=r,l}_resolvePaneReferences(){let e=["left","main","bottom","right"];this.panes={};for(let i of e){let o=this.containerEl.querySelector(`#pane-${i}`);o?.build&&o.build(),this.panes[i]={el:o,paneComponent:o,tabsEl:o?.tabsEl||this.containerEl.querySelector(`#pane-${i}-tabs`),contentEl:o?.contentEl||this.containerEl.querySelector(`#pane-${i}-content`)}}this.centerEl=this.containerEl.querySelector("#pane-center")}_initSplitters(){let e=null;this.containerEl.addEventListener("ide-splitter-start",i=>{let o=i.detail?.for,r=ss[o];if(!r)return;let h=(o==="bottom"?this.centerEl||this.containerEl:this.containerEl).getBoundingClientRect(),u=this.panes[o]?.el?.getBoundingClientRect()||{},f=r.dimension==="width"?h.width:h.height,_=r.dimension==="width"?u.width||240:u.height||220;e={paneName:o,cfg:r,startSize:_,maxLimit:Math.round(f*r.maxFraction)||500}}),this.containerEl.addEventListener("ide-splitter-drag",i=>{if(!e||e.paneName!==i.detail?.for)return;let{cfg:o,startSize:r,maxLimit:l}=e,h=o.invertDelta?-i.detail.delta:i.detail.delta,u=Math.round(r+h),f=Math.max(o.minSize,Math.min(l,u));this.containerEl.style.setProperty(o.cssVar,`${f}px`),this.notifyResize()}),this.containerEl.addEventListener("ide-splitter-end",()=>{e=null,this.saveLayout(),this.notifyResize()}),this.containerEl.addEventListener("ide-splitter-reset",i=>{let o=i.detail?.for;this._resetSplitterPane(o)}),this._setupFallbackSplitters()}_resetSplitterPane(e){let i=ss[e];i&&(this.containerEl.style.setProperty(i.cssVar,i.defaultSize),this.isPaneCollapsed(e)?this.restorePane(e):(this.saveLayout(),this.notifyResize()))}_setupFallbackSplitters(){for(let[e,i]of Object.entries(ss)){let o=this.containerEl.querySelector(`#splitter-${e}`);if(!o||o instanceof os)continue;let r=!i.invertDelta,l=i.isVertical;o.addEventListener("pointerdown",h=>{h.preventDefault();try{o.setPointerCapture(h.pointerId)}catch{}o.classList.add("dragging"),document.body&&document.body.classList.add("is-resizing",l?"is-resizing-v":"is-resizing-h");let u=l?h.clientX:h.clientY,_=(e==="bottom"?this.centerEl||this.containerEl:this.containerEl).getBoundingClientRect(),y=this.panes[e]?.el?.getBoundingClientRect()||{},g=i.dimension==="width"?y.width||240:y.height||220,v=i.dimension==="width"?_.width:_.height,w=Math.round(v*i.maxFraction)||500,b=new AbortController,{signal:C}=b,R=M=>{let q=l?M.clientX:M.clientY,G=r?q-u:u-q,dt=Math.round(g+G),gt=Math.max(i.minSize,Math.min(w,dt));this.containerEl.style.setProperty(i.cssVar,`${gt}px`),this.notifyResize()},A=M=>{try{o.releasePointerCapture(M.pointerId)}catch{}o.classList.remove("dragging"),document.body&&document.body.classList.remove("is-resizing","is-resizing-v","is-resizing-h"),b.abort(),this.saveLayout(),this.notifyResize()};window.addEventListener("pointermove",R,{signal:C}),window.addEventListener("pointerup",A,{signal:C}),window.addEventListener("pointercancel",A,{signal:C})}),o.addEventListener("dblclick",()=>{this._resetSplitterPane(e)})}}_initControls(){this.containerEl.addEventListener("ide-pane-maximize",i=>{this.toggleMaximize(i.detail?.pane)}),this.containerEl.addEventListener("ide-pane-collapse",i=>{this.toggleCollapse(i.detail?.pane)}),this.containerEl.addEventListener("ide-layout-reset",()=>{this.resetLayout()});for(let i of["left","right","bottom"]){let o=this.containerEl.querySelector(`#gutter-expand-${i}`);o&&o.addEventListener("click",()=>this.restorePane(i))}let e=[{sel:"#btn-collapse-left",handler:()=>this.toggleCollapse("left")},{sel:"#btn-collapse-right",handler:()=>this.toggleCollapse("right")},{sel:"#btn-collapse-bottom",handler:()=>this.toggleCollapse("bottom")},{sel:"#btn-maximize-main",handler:()=>this.toggleMaximize("main")},{sel:"#btn-maximize-bottom",handler:()=>this.toggleMaximize("bottom")},{sel:"#btn-maximize-right",handler:()=>this.toggleMaximize("right")},{sel:"#btn-empty-reset-layout",handler:()=>this.resetLayout()}];for(let{sel:i,handler:o}of e){let r=this.containerEl.querySelector(i);r&&!r.closest("ide-pane")&&r.addEventListener("click",o)}}isPaneMaximized(e){return e?this.containerEl.classList.contains(`maximized-${e}`):this.containerEl.classList.contains("maximized-main")||this.containerEl.classList.contains("maximized-bottom")||this.containerEl.classList.contains("maximized-right")}setMaximizedPane(e,i=!0){let o=["main","bottom","right"];if(e&&!o.includes(e))return!1;let r=i?e:null;for(let l of o){let h=l===r;this.containerEl.classList.toggle(`maximized-${l}`,h),this.panes[l]?.paneComponent?.setMaximized(h);let u=this.containerEl.querySelector(`#btn-maximize-${l}`);u&&(u.textContent=h?"\u29C9":"\u2922",u.title=h?"Restore":"Maximize")}return this.notifyResize(),!!r}maximizePane(e){return this.setMaximizedPane(e,!0)}restoreMaximized(){return this.setMaximizedPane(null,!1)}toggleMaximize(e){return this.setMaximizedPane(e,!this.isPaneMaximized(e))}isPaneCollapsed(e){let i=e==="bottom"?this.centerEl:this.containerEl;return i?i.classList.contains(`hide-${e}`):!1}_setPaneCollapsed(e,i){let o=e==="bottom"?this.centerEl:this.containerEl;if(!o)return;o.classList.toggle(`hide-${e}`,i),this.panes[e]?.paneComponent?.setCollapsed?.(i);let r=this.containerEl.querySelector(`#btn-collapse-${e}`);if(r){let h={bottom:{collapsed:"\u25B2",expanded:"\u25BC"},left:{collapsed:"\u25B6",expanded:"\u25C0"},right:{collapsed:"\u25C0",expanded:"\u25B6"}}[e]||{collapsed:"\u25B6",expanded:"\u25C0"};r.textContent=i?h.collapsed:h.expanded,r.title=i?`Expand ${e.charAt(0).toUpperCase()+e.slice(1)}`:`Collapse ${e.charAt(0).toUpperCase()+e.slice(1)}`}this.saveLayout(),this.notifyResize()}toggleCollapse(e){this._setPaneCollapsed(e,!this.isPaneCollapsed(e))}collapsePane(e){this._setPaneCollapsed(e,!0)}restorePane(e){this._setPaneCollapsed(e,!1)}_updateEmptyState(){let e=this.containerEl.querySelector("#ide-empty-state");if(!e)return;let i=!!this.activeTabs.main;e.style.display=i?"none":"flex"}resetLayout(){try{localStorage.removeItem("or_ide_layout")}catch{}for(let[e,i]of Object.entries(ss))this.containerEl.style.setProperty(i.cssVar,i.defaultSize);for(let e of["left","right","bottom"])this.restorePane(e);this.restoreMaximized(),this.closedComponents.clear();for(let e of this.components.values())e.tabEl.style.display="",e.contentDiv.style.display="";this.components.has("DisplayControls")&&this.activateTab("DisplayControls"),this.components.has("LayoutViewer")&&this.activateTab("LayoutViewer"),this.components.has("TclConsole")&&this.activateTab("TclConsole"),this.components.has("Inspector")&&this.activateTab("Inspector"),this._updateEmptyState(),this.saveLayout(),this.notifyResize(),this.emit("stateChanged"),typeof app<"u"&&app.map&&setTimeout(()=>app.map.invalidateSize({animate:!1}),0)}_initResizeObserver(){typeof ResizeObserver<"u"&&new ResizeObserver(()=>{this.notifyResize()}).observe(this.containerEl)}registerComponentFactoryFunction(e,i){this.factories.set(e,i)}loadLayout(e){for(let[o,r]of Object.entries(xa)){let l=this.factories.get(o);l&&this._mountComponent(o,r.pane,r.title,r.closable,l)}let i=null;try{let o=localStorage.getItem("or_ide_layout");o&&(i=JSON.parse(o))}catch{}if(i){if(i.leftWidth&&this.containerEl.style.setProperty("--pane-left-width",`${i.leftWidth}px`),i.rightWidth&&this.containerEl.style.setProperty("--pane-right-width",`${i.rightWidth}px`),i.bottomHeight&&this.containerEl.style.setProperty("--pane-bottom-height",`${i.bottomHeight}px`),i.closed)for(let o of i.closed)this.closeComponent(o,!1);this.activateTab(i.activeTabs?.left||"DisplayControls"),this.activateTab(i.activeTabs?.main||"LayoutViewer"),this.activateTab(i.activeTabs?.bottom||"TclConsole"),this.activateTab(i.activeTabs?.right||"Inspector"),i.hideLeft&&this.collapsePane("left"),i.hideRight&&this.collapsePane("right"),i.hideBottom&&this.collapsePane("bottom")}else this.activateTab("DisplayControls"),this.activateTab("LayoutViewer"),this.activateTab("TclConsole"),this.activateTab("Inspector");this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}_mountComponent(e,i,o,r,l){if(this.components.has(e))return;let h=this.panes[i];if(!h)return;let u=document.createElement("div");u.className="ide-component-container",u.id=`cmp-${e}`,h.contentEl.appendChild(u);let f=document.createElement("ide-tab");f.id=`tab-${e}`,f.setAttribute("for",e),f.setAttribute("data-component",e),f.setAttribute("title",o),r&&f.setAttribute("closable",""),f.addEventListener("tab-select",()=>{this.activateTab(e)}),f.addEventListener("tab-close",()=>{this.closeComponent(e)}),h.tabsEl.appendChild(f);let _=new Map,y={element:u,get width(){return u.clientWidth},get height(){return u.clientHeight},title:o,on:(v,w)=>{_.has(v)||_.set(v,new Set),_.get(v).add(w)},off:(v,w)=>{_.get(v)?.delete(w)},fire:(v,...w)=>{let b=_.get(v);if(b)for(let C of b)try{C(...w)}catch(R){console.error(R)}},focus:()=>this.focusComponent(e),close:()=>this.closeComponent(e)},g={componentType:e,paneName:i,title:o,closable:r,tabEl:f,contentDiv:u,container:y};this.components.set(e,g);try{l(y)}catch(v){console.error(`Failed to initialize component ${e}:`,v)}}isComponentActive(e){return e?!!e.contentDiv?.classList.contains("active"):!1}_setComponentActive(e,i){if(!e)return;let o=!!i;e.tabEl?.setActive(o),e.contentDiv?.classList.toggle("active",o)}activateTab(e){let i=this.components.get(e);if(!i||!this.panes[i.paneName])return;["left","right","bottom"].includes(i.paneName)&&this.isPaneCollapsed(i.paneName)&&this.restorePane(i.paneName);let r=this.activeTabs[i.paneName];if(r&&r!==e){let l=this.components.get(r);l&&(this._setComponentActive(l,!1),l.container.fire("hide"))}this.activeTabs[i.paneName]=e,i.tabEl.style.display="",i.contentDiv.style.display="",this._setComponentActive(i,!0),this.closedComponents.delete(e),i.container.fire("show"),i.container.fire("open"),i.container.fire("resize"),typeof app<"u"&&(e==="LayoutViewer"&&app.map&&setTimeout(()=>app.map.invalidateSize({animate:!1}),0),e==="3DViewer"&&app.threeDViewerWidget&&setTimeout(()=>app.threeDViewerWidget.onOpen(),0));try{i.tabEl.scrollIntoView({behavior:"smooth",inline:"nearest",block:"nearest"})}catch{}this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}closeComponent(e,i=!0){let o=this.components.get(e);if(!(!o||!o.closable)){if(o.tabEl.style.display="none",o.contentDiv.style.display="none",this._setComponentActive(o,!1),o.container.fire("hide"),this.closedComponents.add(e),i&&this.activeTabs[o.paneName]===e){let r=null;for(let l of this.components.values())if(l.paneName===o.paneName&&!this.closedComponents.has(l.componentType)){r=l;break}r?this.activateTab(r.componentType):(this.activeTabs[o.paneName]=null,["left","right","bottom"].includes(o.paneName)&&this.collapsePane(o.paneName))}this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}}focusComponent(e){if(!this.components.get(e)){let o=this.factories.get(e);if(o){let r=xa[e]||{pane:"right",title:e,closable:!0};this._mountComponent(e,r.pane,r.title,r.closable,o)}else return}this.activateTab(e)}saveLayout(){let e={leftWidth:parseInt(this.containerEl.style.getPropertyValue("--pane-left-width")||"240",10),rightWidth:parseInt(this.containerEl.style.getPropertyValue("--pane-right-width")||"340",10),bottomHeight:parseInt(this.containerEl.style.getPropertyValue("--pane-bottom-height")||"220",10),hideLeft:this.isPaneCollapsed("left"),hideRight:this.isPaneCollapsed("right"),hideBottom:this.isPaneCollapsed("bottom"),activeTabs:{...this.activeTabs},closed:Array.from(this.closedComponents)};try{localStorage.setItem("or_ide_layout",JSON.stringify(e))}catch{}return e}notifyResize(){if(this._resizeScheduled)return;this._resizeScheduled=!0,(typeof requestAnimationFrame=="function"?requestAnimationFrame:i=>{i()})(()=>{this._resizeScheduled=!1;for(let i of this.components.values())this.isComponentActive(i)&&i.container.fire("resize");typeof app<"u"&&app&&app.map&&app.map.invalidateSize({animate:!1}),window.dispatchEvent(new Event("resize"))})}updateSize(){this.notifyResize()}setSize(e,i){this.notifyResize()}addComponent(e,i,o){this.focusComponent(e)}get rootItem(){return{contentItems:Array.from(this.components.keys()).map(e=>({isComponent:!0,componentType:e,focus:()=>this.focusComponent(e)}))}}};function Jt(s,e,i,o,r=0,l=0){return[(e-l-o)*i,(s-r)*i]}function Gt(s,e,i,o,r,l,h=0,u=0){return[[(e-u-l)*r,(s-h)*r],[(o-u-l)*r,(i-h)*r]]}function ye(s,e,i,o,r=0,l=0){return{dbuX:Math.round(r+e/i),dbuY:Math.round(l+o+s/i)}}var pn=class s{constructor(e,i){this.url=e,this.socket=null,this.nextId=1,this.pending=new Map,this._queue=new Map,this._inFlight=0,this._inFlightIds=new Set,this._unknownPayloadTypes=new Set,this._maxInFlight=48,this._lastRecvAt=0,this._bufStuckSince=0,this._lastBuffered=0,this.reconnectDelay=1e3,this.readyPromise=null,this.readyResolve=null,this.onStatusChange=i||(()=>{}),this.onPush=null,this._cache=null,this._isConnected=!1,this._shutdown=!1,this._livenessTimer=void 0,this._startLivenessMonitor(),this.connect()}get isConnected(){return this._isConnected||this.socket&&this.socket.readyState===WebSocket.OPEN}get pendingCount(){return this.pending.size+(this._queue?this._queue.size:0)}static fromCache(e,i){let o=Object.create(s.prototype);return o.url=null,o.socket=null,o.nextId=1,o.pending=new Map,o._queue=new Map,o._inFlight=0,o._inFlightIds=new Set,o._unknownPayloadTypes=new Set,o._maxInFlight=48,o._lastRecvAt=0,o.reconnectDelay=0,o.onStatusChange=i||(()=>{}),o.onPush=null,o._cache=e,o._isConnected=!0,o.readyPromise=Promise.resolve(),o.readyResolve=null,o}get isStaticMode(){return!!this._cache}connect(){this.readyPromise=new Promise(e=>{this.readyResolve=e}),this.socket=new WebSocket(this.url),this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{console.log("WebSocket connected");let e=this._everConnected===!0;this._everConnected=!0,this._isConnected=!0,this.reconnectDelay=1e3,this._lastRecvAt=typeof performance<"u"?performance.now():0,this.readyResolve(),this.onStatusChange(),this._pump(),e&&this.onReconnected&&this.onReconnected()},this.socket.onmessage=e=>{this.handleMessage(e.data)},this.socket.onclose=()=>this._handleClose(),this.socket.onerror=e=>{console.error("WebSocket error:",e)}}_handleClose(){this._isConnected=!1,this._inFlight=0,this._inFlightIds.clear(),this._bufStuckSince=0,this.onStatusChange();for(let[e,i]of this.pending)i.reject(new Error("WebSocket closed"));this.pending.clear();for(let[e,i]of this._queue)i.reject(new Error("WebSocket closed"));if(this._queue.clear(),this._shutdown){console.log("WebSocket closed (server stopped)"),this._stopLivenessMonitor();return}console.log("WebSocket closed, reconnecting..."),setTimeout(()=>this.connect(),this.reconnectDelay),this.reconnectDelay=Math.min(this.reconnectDelay*2,3e4)}_forceReconnect(){let e=this.socket;if(this.socket=null,e){e.onopen=null,e.onmessage=null,e.onclose=null,e.onerror=null;try{e.close()}catch{}}this._handleClose()}handleMessage(e){let i=new DataView(e),o=i.getUint32(0),r=i.getUint8(4);if(this._lastRecvAt=typeof performance<"u"?performance.now():0,o===0&&r===0){let u=e.slice(8),f;try{f=JSON.parse(new TextDecoder().decode(u))}catch(_){console.error("Failed to parse server push JSON:",_);return}if(f&&f.type==="config"){Number.isFinite(f.max_in_flight)&&(this._maxInFlight=Math.max(1,Math.min(4096,Math.floor(f.max_in_flight))),this._pump());return}this.onPush&&this.onPush(f);return}this._inFlightIds.delete(o)&&this._inFlight>0&&this._inFlight--;let l=this.pending.get(o);if(!l){this._pump();return}this.pending.delete(o),this._pump(),this.onStatusChange();let h=e.slice(8);if(r===2)l.reject(new Error(new TextDecoder().decode(h)));else if(r===0)try{l.resolve(JSON.parse(new TextDecoder().decode(h)))}catch(u){l.reject(new Error("JSON parse error: "+u.message))}else r===1?l.resolve(new Blob([h],{type:"image/png"})):r===3?l.resolve(null):(this._unknownPayloadTypes.has(r)||(this._unknownPayloadTypes.add(r),console.warn(`Unrecognized websocket payload type ${r}. The server is likely newer than this page \u2014 reload to pick up the current client.`)),l.reject(new Error(`Unsupported websocket payload type ${r}`)))}request(e){if(this._cache)return this._cacheRequest(e);let i=this.nextId++;if(e.id=i,!this.socket||this.socket.readyState!==WebSocket.OPEN)return Promise.reject(new Error("WebSocket not connected"));let o,r,l=new Promise((h,u)=>{o=h,r=u});return l.requestId=i,this._queue.set(i,{msg:e,resolve:o,reject:r}),this._pump(),l}_pump(){if(!(!this.socket||this.socket.readyState!==WebSocket.OPEN)){for(;this._inFlight0&&this.socket.bufferedAmount<524288;){let[e,i]=this._queue.entries().next().value;this._queue.delete(e),this.pending.set(e,{resolve:i.resolve,reject:i.reject}),this.socket.send(JSON.stringify(i.msg)),this._inFlightIds.add(e),this._inFlight++}this.onStatusChange()}}cancel(e){let i=this._queue.get(e);if(i){this._queue.delete(e),i.reject(new Error("Request cancelled")),this.onStatusChange();return}let o=this.pending.get(e),r=this.pending.delete(e);o&&o.reject(new Error("Request cancelled")),r&&!this._cache&&this.socket&&this.socket.readyState===WebSocket.OPEN&&this.socket.send(JSON.stringify({type:"cancel",cancel_id:e,id:this.nextId++})),this.onStatusChange()}_startLivenessMonitor(){typeof setInterval>"u"||(this._livenessTimer=setInterval(()=>this._checkLiveness(),3e3),this._livenessTimer&&typeof this._livenessTimer.unref=="function"&&this._livenessTimer.unref())}_stopLivenessMonitor(){this._livenessTimer!==void 0&&typeof clearInterval<"u"&&(clearInterval(this._livenessTimer),this._livenessTimer=void 0)}_checkLiveness(){if(this._cache)return;let e=this.socket;if(!e||e.readyState!==WebSocket.OPEN){this._bufStuckSince=0,this._lastBuffered=0;return}let i=e.bufferedAmount,o=typeof performance<"u"?performance.now():0,r=!1,l="";i<=262144||i12e3&&(r=!0,l=`send buffer stuck at ${i}B for ${Math.round(o-this._bufStuckSince)}ms`),this._lastBuffered=i,!r&&this._inFlight>=this._maxInFlight&&this._queue.size>0&&this._lastRecvAt>0&&o-this._lastRecvAt>3e4&&(r=!0,l=`saturated (${this._inFlight} in flight, ${this._queue.size} queued) but silent for ${Math.round(o-this._lastRecvAt)}ms`),r&&(console.warn(`WebSocket connection wedged \u2014 ${l}; reconnecting to recover`),this._bufStuckSince=0,this._forceReconnect())}_cacheRequest(e){let i=e.type;if(i==="tile"){let l=e.layer+"/"+e.z+"/"+e.x+"/"+e.y,h=this._cache.tiles&&this._cache.tiles[l];return h?Promise.resolve("data:image/png;base64,"+h):Promise.reject(new Error("Tile not cached: "+l))}if(i==="timing_highlight"){let l=e.path_index;if(l>=0&&this._cache.overlays){let h=e.is_setup?"setup":"hold",u=this._cache.overlays[h]?.[l];this._cache.setPathOverlay&&this._cache.setPathOverlay(u?"data:image/png;base64,"+u:null)}else this._cache.setPathOverlay&&this._cache.setPathOverlay(null);return Promise.resolve({})}if(i==="set_module_colors")return Promise.resolve({ok:1,count:0});let o=i;i==="timing_report"?o="timing_report:"+(e.is_setup?"setup":"hold"):i==="slack_histogram"&&(o="slack_histogram:"+(e.is_setup?"setup":"hold"));let r=this._cache.json&&this._cache.json[o];if(r!==void 0){if(i==="timing_report"&&e.slack_min!=null&&e.slack_max!=null&&r.paths){let l=[];return r.paths.forEach((h,u)=>{h.slack>=e.slack_min&&h.slack"u"||typeof window.matchMedia!="function"||typeof s!="function")return()=>{};let e=!1,i=null,o=null,r=()=>{if(e)return;let l=window.devicePixelRatio||1;i=window.matchMedia(`(resolution: ${l}dppx)`),o=()=>{e||(r(),s(window.devicePixelRatio||1))},i.addEventListener("change",o,{once:!0})};return r(),()=>{e=!0,i&&o&&i.removeEventListener("change",o),i=null,o=null}}function zi(s,e){let i=s&&s._map?s._map.getZoom():e;return Math.floor(i)}var Bh=["tracks_pref","tracks_non_pref","debug","debug_renderers"],Nh=1/16;function Mo(s,e){if(s==null)return!1;if(!Array.isArray(s)||s.length!==4||!e)return!0;let i=Math.pow(2,e.z),o=Nh/i,r=e.x/i-o,l=e.y/i-o,h=(e.x+1)/i+o,u=(e.y+1)/i+o,[f,_,y,g]=s;return f<=h&&y>=r&&_<=u&&g>=l}function Dh(s,e,i){let o=s&&Array.isArray(s.by_size)?s.by_size:[];if(o.length===0||!e||!(i>0))return!0;let r=s.min_css_px/(i*Math.pow(2,e.z)),l=o[0];for(let h of o)h[0]<=r&&(l=h);return Mo(l[1],e)}var cs=class{constructor(){this._layers=null,this._gated=new Map,this._sized=new Map,this._generation=0}invalidate(){return this._generation++,this._layers=null,this._gated=new Map,this._sized=new Map,this._generation}apply(e,i){if(e!==this._generation)return!1;if(!i||i.supported!==!0||!i.layers||typeof i.layers!="object")return this._layers=null,!1;let o=new Map;if(i.gated&&typeof i.gated=="object")for(let[r,l]of Object.entries(i.gated))l&&typeof l=="object"&&o.set(r,new Map(Object.entries(l)));return this._layers=new Map(Object.entries(i.layers)),this._gated=o,this._sized=new Map(i.sized&&typeof i.sized=="object"?Object.entries(i.sized):[]),!0}refetch(e){let i=this.invalidate();return Promise.resolve().then(()=>e({type:"layer_extents"})).then(o=>this.apply(i,o)).catch(()=>!1)}mayHaveContent(e,i,o,r=256){if(!this._layers||o&&Bh.some(l=>o[l]))return!0;if(this._sized.has(e))return Dh(this._sized.get(e),i,r);if(!this._layers.has(e)||Mo(this._layers.get(e),i))return!0;for(let[l,h]of this._gated)if(!(o&&o[l]===!1)&&h.has(e)&&Mo(h.get(e),i))return!0;return!1}};function fn(s,e,i){let o=s&&s.app&&s.app.layerExtents;return o?o.mayHaveContent(e,i,s.visibility,ve()):!0}function di(){return Di()}function Sa(s,e,i){return ls(s,e,i,di(),ve())}function Oi(s,e){if(s.src&&s.src.startsWith("blob:")&&URL.revokeObjectURL(s.src),e==null){s.src=$e;return}s.src=typeof e=="string"?e:URL.createObjectURL(e)}function Ea(s,e,i,o,r){let l={visibility:s,selectability:i,visibleLayers:e,selectableLayers:o,app:r};return L.GridLayer.extend({_clampZoom:function(h){return L.GridLayer.prototype._clampZoom.call(this,zi(this,h))},initialize:function(h,u,f){this._websocketManager=h,this._layerName=u,L.GridLayer.prototype.initialize.call(this,hi(f))},createTile:function(h,u){let f=document.createElement("img");return f.alt="",f.setAttribute("role","presentation"),f._tileDone=!1,f.onload=()=>{f.src&&f.src.startsWith("blob:")&&URL.revokeObjectURL(f.src),f._tileDone||(f._tileDone=!0,u(null,f))},f.onerror=()=>{f._tileDone||(f._tileDone=!0,u(new Error("tile image load error"),f))},f._websocketRequestId=this._websocketManager.nextId,fn(l,this._layerName,h)?(this._websocketManager.request(Sa(h,this._layerName,l)).then(_=>{Oi(f,_)}).catch(_=>{}),f):(f._websocketRequestId=void 0,Oi(f,null),f)},refreshTiles:function(){if(this._map)for(let h in this._tiles){let u=this._tiles[h];if(!u||!u.el)continue;let f=u.el,_=u.coords;if(f._websocketRequestId!==void 0&&this._websocketManager.cancel(f._websocketRequestId),!fn(l,this._layerName,_)){f._websocketRequestId=void 0,Oi(f,null);continue}f._websocketRequestId=this._websocketManager.nextId,this._websocketManager.request(Sa(_,this._layerName,l)).then(y=>{Oi(f,y)}).catch(y=>{})}},_removeTile:function(h){let u=this._tiles[h];u&&u.el&&(u.el._websocketRequestId!==void 0&&this._websocketManager.cancel(u.el._websocketRequestId),u.el.src&&u.el.src.startsWith("blob:")&&URL.revokeObjectURL(u.el.src)),L.GridLayer.prototype._removeTile.call(this,h)}})}function Ma(s,e){function i(o,r){let l={type:"overlay_tile",z:o.z,x:o.x,y:o.y,...Ri(di(),r),debug_renderers:!!s.debug_renderers,debug_live:!!s.debug_live,flywires_only:!!s.flywires_only,poly_decomp:!!(e&&e.polyDecomp),focused_nets_guides:!!s.focused_nets_guides,highlight_selected:s.highlight_selected!==!1,draw_labels:s.labels!==!1};return e&&e.visibleLayerNames&&(l.visible_layers=[...e.visibleLayerNames]),l}return L.GridLayer.extend({initialize:function(o,r){this._websocketManager=o,L.GridLayer.prototype.initialize.call(this,hi(r))},createTile:function(o,r){let l=document.createElement("img");l.alt="",l.setAttribute("role","presentation"),l._tileDone=!1,l.onload=()=>{l.src&&l.src.startsWith("blob:")&&URL.revokeObjectURL(l.src),l._tileDone||(l._tileDone=!0,r(null,l))},l.onerror=()=>{l._tileDone||(l._tileDone=!0,r(new Error("overlay tile load error"),l))};let h=this._websocketManager.nextId;return l._websocketRequestId=h,this._websocketManager.request(i(o,this.getTileSize().x)).then(u=>{l._websocketRequestId===h&&Oi(l,u)}).catch(u=>{}),l},refreshTiles:function(){if(this._map)for(let o in this._tiles){let r=this._tiles[o];if(!r||!r.el)continue;let l=r.el,h=r.coords;l._websocketRequestId!==void 0&&this._websocketManager.cancel(l._websocketRequestId);let u=this._websocketManager.nextId;l._websocketRequestId=u,this._websocketManager.request(i(h,this.getTileSize().x)).then(f=>{l._websocketRequestId===u&&Oi(l,f)}).catch(()=>{})}},_removeTile:function(o){let r=this._tiles[o];r&&r.el&&(r.el._websocketRequestId!==void 0&&(this._websocketManager.cancel(r.el._websocketRequestId),r.el._websocketRequestId=void 0),r.el.src&&r.el.src.startsWith("blob:")&&URL.revokeObjectURL(r.el.src)),L.GridLayer.prototype._removeTile.call(this,o)}})}function Ta({zIndex:s=0,tileSize:e}={}){let i={opacity:1,zIndex:s};return e!==void 0&&(i.tileSize=e),i}var Rh=4,To=350*1024*1024;function Pa(s,e=1){let i=Math.round(s*Math.max(0,e));return i*i*Rh}function Aa(s,e,i=256){return!(s>0)||!(e>0)||!(i>0)?1:(Math.ceil(s/i)+1)*(Math.ceil(e/i)+1)}function Ia(s,e){let i=e||(typeof window<"u"?window:null),o=s&&s.clientWidth>0?s.clientWidth:i&&i.innerWidth>0?i.innerWidth:1024,r=s&&s.clientHeight>0?s.clientHeight:i&&i.innerHeight>0?i.innerHeight:768;return{width:o,height:r}}function Po(s,e){if(!s)return!1;let i=!!e;return!!s.visible===i?!1:(s.visible=i,!0)}var hs=4;function Ba(s,e,i,o=hs){let r=e*i;return r>0?Math.max(r,s-o*r):s}function Na({budgetBytes:s=To,tilesPerPane:e,bytesPerTile:i,paneCount:o}={}){if(!(e>0)||!(i>0)||!(o>0))return 1;let r=e*i;return Math.max(1,Math.min(o,Math.floor(s/r)))}function Ao(s,e){if(!Array.isArray(s)||s.length===0)return[];let i=Math.max(1,Math.min(Math.floor(e)||1,s.length)),o=Math.floor(s.length/i),r=s.length%i,l=[],h=0;for(let u=0;u0&&(f++,r--),l.push(s.slice(h,h+f)),h+=f}return l}function Da(s,e,i){if(!s||!(i>0))return 0;s.clearRect(0,0,i,i);let o=0;for(let r of e||[]){let l=r?r.image:null;if(!l)continue;let h=r.opacity===void 0?1:r.opacity;h>0&&(s.globalAlpha=Math.min(1,h),s.drawImage(l,0,0,i,i),o++)}return s.globalAlpha=1,o}function Io(s){for(let e of s||[])e&&typeof e.close=="function"&&e.close()}async function Ra({items:s,request:e,decode:i,draw:o,release:r=Io,isStale:l=()=>!1,onFirstDraw:h}={}){let u=Array.isArray(s)?s:[],f={requested:u.length,arrived:0,decoded:0,drawn:0,paints:0,stale:!1};if(u.length===0)return typeof o=="function"&&o([]),f;let _=new Array(u.length).fill(null),y=!1;function g(){if(l()){f.stale=!0;return}f.drawn=o(u.map((v,w)=>({image:_[w],opacity:v.opacity})))||0,f.paints++,y||(y=!0,h&&h())}try{await Promise.all(u.map(async(v,w)=>{let b=null;try{b=await e(v)}catch{return}if(b==null)return;f.arrived++;let C=null;try{C=await i(b)}catch{return}C&&(_[w]=C,f.decoded++,g())})),y||g()}finally{r(_)}return f}function zh(s){return s==null?Promise.resolve(null):typeof s=="string"?new Promise(e=>{let i=document.createElement("img");i.onload=()=>e(i),i.onerror=()=>e(null),i.src=s}):typeof createImageBitmap=="function"?createImageBitmap(s).catch(()=>null):new Promise(e=>{let i=URL.createObjectURL(s),o=new Image;o.onload=()=>{URL.revokeObjectURL(i),e(o)},o.onerror=()=>{URL.revokeObjectURL(i),e(null)},o.src=i})}function za(s,e={}){let i=e.decode||zh,o=e.dpr||Di;return L.GridLayer.extend({_clampZoom:function(r){return L.GridLayer.prototype._clampZoom.call(this,zi(this,r))},initialize:function(r,l,h){this._websocketManager=r,this._items=l||[],this._generation=0,L.GridLayer.prototype.initialize.call(this,hi(h))},setItems:function(r){this._items=r||[],this.refreshTiles()},visibleItems:function(){return this._items.filter(r=>r&&r.visible!==!1)},createTile:function(r,l){let h=document.createElement("canvas");h.setAttribute("role","presentation");let u=o();return h._orDone=l,this._renderTile(h,r,u),h},_sizeCanvas:function(r,l,{empty:h=!1}={}){let u=this.getTileSize(),f=h?0:as(u.x,l),_=h?0:as(u.y,l);(r.width!==f||r.height!==_)&&(r.width=f,r.height=_),r.style.width=u.x+"px",r.style.height=u.y+"px"},_finishTile:function(r,l){r._orTileDone||!r._orDone||(r._orTileDone=!0,r._orDone(l||null,r))},_renderTile:function(r,l,h){let u=this._generation,f=this.visibleItems().filter(g=>fn(s,g.layer,l));this._sizeCanvas(r,h,{empty:f.length===0});let _=r.getContext("2d");r._orRequestIds=[];let y=()=>this._generation!==u||r._orRemoved===!0;Ra({items:f,request:g=>{let v=this._websocketManager.nextId;return r._orRequestIds.push(v),this._websocketManager.request(ls(l,g.layer,s,h,this.getTileSize().x))},decode:i,draw:g=>Da(_,g,r.width),release:Io,isStale:y,onFirstDraw:()=>this._finishTile(r)}).then(()=>{y()||this._finishTile(r)}).catch(g=>{y()||this._finishTile(r,g)})},refreshTiles:function(){if(this._map){this._generation++;for(let r in this._tiles){let l=this._tiles[r];if(!l||!l.el)continue;this._cancelTile(l.el);let h=o();this._renderTile(l.el,l.coords,h)}}},_cancelTile:function(r){let l=r._orRequestIds;if(!(!l||!l.length)){for(let h of l)this._websocketManager.cancel(h);r._orRequestIds=[]}},_removeTile:function(r){let l=this._tiles[r];l&&l.el&&(l.el._orRemoved=!0,this._cancelTile(l.el),l.el.width=0,l.el.height=0),L.GridLayer.prototype._removeTile.call(this,r)}})}function Oa(s,e,i,o,r=0){let l=[];return i.forEach((h,u)=>{let f=new s(e,h,Ta({zIndex:r+u}));o&&f.addTo(o),l.push(f)}),l}var Oh=".leaflet-tile-container",Fa=".leaflet-tile";function $a(s,e){if(!Number.isFinite(s)||!(e>0))return 0;let i=s*e;return(i-Math.round(i))/e}function $h(s,e,i=Za){let o=s&&s.parentElement;if(!o)return null;let r=typeof s.querySelector=="function"?s.querySelector(Fa):null;if(!r)return null;let l=i(r),h=Ha((o._orSnapDx||0)-$a(l.left,e),e),u=Ha((o._orSnapDy||0)-$a(l.top,e),e);return o._orSnapDx=h,o._orSnapDy=u,o.style.transform=h||u?`translate3d(${h}px, ${u}px, 0)`:"",{dx:h,dy:u}}function Hh(s,e,i=Za){if(!s||typeof s.getPane!="function"||!(e>0)||Number.isInteger(e))return 0;let o=s.getPane("tilePane");if(!o||typeof o.querySelectorAll!="function")return 0;let r=0,l=[...o.querySelectorAll(Oh)].filter(Fh).map(h=>{let u=h.querySelector(Fa);return{container:h,rect:u?i(u):null}});for(let{container:h,rect:u}of l)u&&$h(h,e,()=>u)&&r++;return r}function Za(s){return s.getBoundingClientRect()}function Ha(s,e){return s-Math.round(s*e)/e}function Fh(s){let e=s.style&&s.style.transform||"",i=/scale\(([^)]*)\)/.exec(e);return!i||Number(i[1])===1}var Zh="move zoomend viewreset resize load";function qa(s,e=Di){if(!s||typeof s.on!="function")return!1;let i=()=>Hh(s,e());return s.on(Zh,i),i(),!0}function wt(s){return!!s?.websocketManager?.isStaticMode}function Va(s,e){let i={};for(let[o,r]of Object.entries(s||{}))i[o]=!!r;for(let[o,r]of Object.entries(e||{}))i["s_"+o]=!!r;return i}function $i(s,e){e&&typeof e.sel_has_inst=="boolean"&&(s.selHasInst=e.sel_has_inst,s.selHasNet=!!e.sel_has_net)}var Bo=null;function be(s,e=4e3){let i=document.getElementById("or-toast");return i||(i=document.createElement("div"),i.id="or-toast",document.body.appendChild(i)),i.textContent=s,i.classList.add("visible"),Bo&&clearTimeout(Bo),Bo=setTimeout(()=>i.classList.remove("visible"),e),i}function Ya({title:s,message:e,confirmLabel:i="OK",danger:o=!1}){return new Promise(r=>{let l=document.createElement("div");l.className="or-modal-overlay";let h=document.createElement("div");h.className="or-modal";let u=document.createElement("div");u.className="or-modal-title",u.textContent=s;let f=document.createElement("div");f.className="or-modal-message",f.textContent=e;let _=document.createElement("div");_.className="or-modal-buttons";let y=document.createElement("button");y.className="or-btn",y.textContent="Cancel";let g=document.createElement("button");g.className="or-btn"+(o?" or-btn-danger":""),g.textContent=i;let v=b=>{document.removeEventListener("keydown",w,!0),l.remove(),r(b)},w=b=>{b.key==="Escape"&&(b.stopPropagation(),v(!1))};y.addEventListener("click",()=>v(!1)),g.addEventListener("click",()=>v(!0)),l.addEventListener("click",b=>{b.target===l&&v(!1)}),document.addEventListener("keydown",w,!0),_.appendChild(y),_.appendChild(g),h.appendChild(u),h.appendChild(f),h.appendChild(_),l.appendChild(h),document.body.appendChild(l),y.focus()})}var qh=.05;function Wh([[s,e],[i,o]],r){let l=(o-e)*r,h=(i-s)*r;return[[s-h,e-l],[i+h,o+l]]}function No(s,e=256,i=null){if(!Wa(s))return null;let o=s[0][0],r=s[0][1],l=Math.max(s[1][1]-r,s[1][0]-o),h=e/l,u=Wa(i)?i:s,[[f,_],[y,g]]=Wh(u,qh);return{scale:h,maxDXDY:l,originX:r,originY:o,fitBounds:Gt(_,f,g,y,h,l,r,o)}}function Wa(s){return!!s&&s[1][0]>s[0][0]&&s[1][1]>s[0][1]}function Xa(s,e){return!!s&&!!e&&s[0][0]===e[0][0]&&s[0][1]===e[0][1]&&s[1][0]===e[1][0]&&s[1][1]===e[1][1]}function re(s){s.selectionToken=(s.selectionToken||0)+1;for(let e of s.selectionResetters||[])e();return s.selectionToken}function ce(s,e){return s.selectionToken===e}function ja(s,e){s.selectionResetters||(s.selectionResetters=[]),s.selectionResetters.push(e)}function Ka(s=typeof L<"u"?L.CRS.Simple:void 0,e={}){return{crs:s,zoom:1,zoomSnap:1,zoomDelta:1,fadeAnimation:!1,attributionControl:!1,scrollWheelZoom:e.wheelZoom!==!1,keyboardPanDelta:Hi(e.arrowStep)}}var Do=80,mn=10,_n=1e3;function Hi(s){let e=s===""||s===null?NaN:Math.round(Number(s));return Number.isFinite(e)?Math.min(_n,Math.max(mn,e)):Do}function Ja(s,e){s?.keyboard?._setPanDelta?.(e)}function ui(s="vis-group-header"){let e=document.createElement("div");e.className=s;let i=document.createElement("span");i.className="vis-arrow",e.appendChild(i);let o=document.createElement("span");return o.className="vis-name",e.appendChild(o),{header:e,arrow:i,name:o}}function pi(s,e,i,o){let r=l=>{i.classList.toggle("collapsed",l),e.textContent=l?"\u25B6":"\u25BC"};r(!!o),s.addEventListener("click",l=>{let h=l.target&&l.target.parentNode===s&&l.target.classList&&l.target.classList.contains("vis-name");l.target!==s&&l.target!==e&&!h||r(!i.classList.contains("collapsed"))})}var Ua=30;function Qa(s,e=8){if(!Number.isFinite(s)||s<=0)return Ua;let i=Math.ceil(Math.log2(e/s));return Math.max(1,Math.min(Ua,i))}function tl({designBounds:s,fitRect:e,viewW:i,viewH:o}){let r=No(s,Oe,e),l=w=>Number.isFinite(w)&&w>0;if(!r||!l(i)||!l(o))return Oe;let h=r.fitBounds[1][1]-r.fitBounds[0][1],u=r.fitBounds[1][0]-r.fitBounds[0][0],f=Math.min(i/h,o/u),_=Math.log2(f);if(!Number.isFinite(_)||_<0)return Oe;let y=Math.floor(_),g=Oe*2**(_-y),v=Math.floor(g/Eo)*Eo;return v>Oe&&Math.log2(Oe*f/v)>=y?v:Oe}function el(s,{showDbu:e,dbuPerMicron:i},o=!1){if(e)return String(Math.round(s));let r=i>0?i:1e3,l=Math.ceil(Math.log10(r)),h=(s/r).toFixed(l);return o?h+" \xB5m":h}function il(s,{showDbu:e,dbuPerMicron:i}){let o=parseFloat(s);if(!Number.isFinite(o))return null;if(e)return Math.round(o);let r=i>0?i:1e3;return Math.round(o*r)}function nl(s,{showDbu:e,dbuPerMicron:i}){if(e)return String(Math.round(s));let o=i>0?i:1e3,r=s/o;return r>=1e3?(r/1e3).toFixed(3)+" mm":r>=1?r.toFixed(3)+" um":(r*1e3).toFixed(1)+" nm"}function sl({showDbu:s}){return s?"DBU":"\xB5m"}function Fi(s){return typeof s=="string"&&/^#[0-9a-fA-F]{6}$/.test(s)}function ol(s){if(typeof s!="string")return null;let e=s.trim();if(Fi(e))return e.toLowerCase();let i=e.match(/^#([0-9a-fA-F]{3})$/);if(i)return"#"+i[1].split("").map(r=>r+r).join("").toLowerCase();let o=e.match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/);if(o){let r=o.slice(1).map(Number);return r.some(l=>l>255)?null:"#"+r.map(l=>l.toString(16).padStart(2,"0")).join("")}return null}function gn(s){let e=null;return()=>{e===null&&(e=requestAnimationFrame(()=>{e=null,s()}))}}function Ga(s){let e=Math.pow(10,Math.floor(Math.log10(s))),i=s/e,o;return i<1.5?o=1:i<3.5?o=2:i<7.5?o=5:o=10,{value:o*e,digit:o}}function rl({targetPx:s,pxPerDbu:e,dbuPerMicron:i,showDbu:o}){if(!Number.isFinite(e)||e<=0||!Number.isFinite(s)||s<=0)return null;let r,l,h;if(o){let f=Ga(Math.max(1,s/e));h=f.digit,r=Math.round(f.value*e),l=String(Math.round(f.value))}else{let f=Number.isFinite(i)&&i>0?i:1e3,_=e*f,y=Ga(s/_);h=y.digit;let g=y.value;r=Math.round(g*_);let v,w;g>=1e3?(v=1/1e3,w="mm"):g>=1?(v=1,w="\xB5m"):g>=.001?(v=1e3,w="nm"):(v=1e6,w="pm"),l=Math.round(g*v)+" "+w}return{barPx:r,label:l,segments:h===1?5:h}}function yn(s,e,i){return e?typeof s.runTclScript=="function"?s.runTclScript(e,i):(i&&typeof s.echoTcl=="function"&&s.echoTcl(e),s.websocketManager.request({type:"tcl_eval",cmd:e}).catch(()=>{})):Promise.resolve()}function fi(s,e){let i=s.querySelectorAll("thead th");(!e||!e[0])&&(s.style.tableLayout="auto",i.forEach(o=>o.style.width=""),e=Array.from(i,o=>o.offsetWidth+"px")),i.forEach((o,r)=>o.style.width=e[r]||""),s.style.tableLayout="fixed",i.forEach((o,r)=>{if(r===i.length-1)return;let l=document.createElement("div");l.className="col-resize-grip",o.style.position="relative",o.appendChild(l);let h,u,f=y=>{o.style.width=Math.max(30,u+y.clientX-h)+"px"},_=()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",_);let y=g=>g.stopPropagation();document.addEventListener("click",y,{capture:!0,once:!0}),setTimeout(()=>{document.removeEventListener("click",y,{capture:!0})},0)};l.addEventListener("mousedown",y=>{y.preventDefault(),h=y.clientX,u=o.offsetWidth,document.addEventListener("mousemove",f),document.addEventListener("mouseup",_)})})}var Uh={Layout:'',Schematic:'',"3D Viewer":'',"Display Controls":'',Inspector:'',Hierarchy:'',Timing:'',DRC:'',"Select Highlight":'',"Clock Tree":'',Charts:'',"Tcl Console":'',Help:''};function Gh(s){let e=Uh[s];if(!e)return null;let i=document.createElement("span");return i.className="or-tab-icon",i.innerHTML='",i}function al(s=document){let e=0;for(let i of s.querySelectorAll(".lm_tab:not([data-or-icon])")){let o=i.querySelector(".lm_title");if(!o)continue;let r=o.textContent.trim();if(!r)continue;i.setAttribute("data-or-icon","");let l=Gh(r);l&&(i.insertBefore(l,o),e++)}return e}function ll(s,e){s.scrollWheelZoom.disable(),s.getContainer().addEventListener("wheel",i=>{if(i.preventDefault(),e()===i.ctrlKey){let[r,l]=Vh(i,s.getContainer());s.panBy([r,l],{animate:!1});return}let o=i.deltaY<0?1:-1;s.setZoomAround(s.mouseEventToLatLng(i),s.getZoom()+o)},{passive:!1})}function Vh(s,e){let o=1;return s.deltaMode===1?o=16:s.deltaMode===2&&(o=e.clientHeight||16),[s.deltaX*o,s.deltaY*o]}function Zi(s,e,i,o){let r=document.createElement("div");r.className="modal-overlay",r.innerHTML=` - `,document.body.appendChild(r);let s=()=>r.remove();r.addEventListener("click",c=>{c.target===r&&s()}),r.addEventListener("keydown",c=>{c.key==="Escape"&&s()}),r.querySelector(".cancel").addEventListener("click",s),r.querySelector(".modal-close").addEventListener("click",s);let o=r.querySelector(".modal-error"),a=(c,l)=>{o.textContent=c,o.style.display=c?"block":"none",o.classList.toggle("info",!!l)};return{overlay:r,close:s,okBtn:r.querySelector(".ok"),showError:a}}var MV=1e4,AV=150,kV=3;function RV(n){return 1-(1-n)*(1-n)}var Bh=class{constructor({isEnabled:e=()=>!0,isSmooth:t=()=>!1,reducedMotion:i=Gl,now:r=()=>performance.now(),setTimer:s=(u,f)=>setTimeout(u,f),clearTimer:o=u=>clearTimeout(u),timeoutMs:a=MV,fadeMs:c=AV,onChange:l=()=>{}}={}){Object.assign(this,{isEnabled:e,isSmooth:t,reducedMotion:i,now:r,setTimer:s,clearTimer:o,timeoutMs:a,fadeMs:c,onChange:l}),this.shownZ=null,this.pendingZ=null,this.under=[],this.fade=null,this._timer=null}wantedZ(){return this.pendingZ!==null?this.pendingZ:this.shownZ}setZoom(e,{hasContent:t=!0}={}){e!==this.wantedZ()&&(this.endFade(),this._clearTimer(),this.shownZ===null?(this.shownZ=e,this.pendingZ=null,this.under=[]):t?e===this.shownZ?this.pendingZ=null:this.isEnabled()?(this.pendingZ=e,this.under=[],this._timer=this.setTimer(()=>this.reveal(),this.timeoutMs)):(this.under=[...this.under.filter(i=>i!==e),this.shownZ].slice(-kV),this.shownZ=e,this.pendingZ=null):(this.shownZ=e,this.pendingZ=null,this.under=this.under.filter(i=>i!==e)),this.onChange())}check({settled:e,animating:t=!1}){return this.pendingZ!==null?t||!e&&this.isEnabled()?!1:(this.reveal(),!0):this.under.length>0&&e&&!t?(this.under=[],this.onChange(),!0):!1}reveal(){if(this.pendingZ===null)return;this._clearTimer();let e=this.shownZ;this.shownZ=this.pendingZ,this.pendingZ=null;let t=this.isSmooth()&&!this.reducedMotion()?this.fadeMs:0;this.fade=t>0&&e!==null?{fromZ:e,toZ:this.shownZ,start:this.now(),ms:t}:null,this.onChange()}endFade(){this.fade&&(this.fade=null,this.onChange())}plan(e=this.now()){if(this.fade){let t=(e-this.fade.start)/this.fade.ms;if(t<1)return{draw:[{z:this.fade.fromZ,opacity:1},{z:this.fade.toZ,opacity:RV(Math.max(0,t))}],fading:!0};this.fade=null}return this.shownZ===null?{draw:[],fading:!1}:this.pendingZ!==null?{draw:[{z:this.shownZ,opacity:1}],fading:!1}:this.under.length>0?{draw:[...this.under,this.shownZ].map(t=>({z:t,opacity:1})),fading:!1}:{draw:[{z:this.shownZ,opacity:1}],fading:!1}}isIdle(e=this.now()){return this.pendingZ===null&&this.under.length===0&&!this.plan(e).fading}dispose(){this._clearTimer()}_clearTimer(){this._timer!==null&&(this.clearTimer(this._timer),this._timer=null)}};var at=Object.freeze({base:10,overlay:20,heatmap:30,top:40,pathImage:50,selection:60,highlight:70,ruler:80}),Es={depthCompare:"always",depthWriteEnabled:!1},V3=250,W3=4,Qb=300,IV=1,BV=2,OV=300,DV=300,NV=400,FV=1e3,j3=100,zV=.05,H3=1200,Y3=30;function Nt(n,e=1){if(Array.isArray(n)){let r=n.length>3?n[3]:255;return[n[0],n[1],n[2],Math.round(r*e)]}let t=String(n||"#000").replace("#","");t.length===3&&(t=t.split("").map(r=>r+r).join(""));let i=parseInt(t.slice(0,6),16)||0;return[i>>16&255,i>>8&255,i&255,Math.round(255*e)]}function UV(n){return 1-Math.pow(1-n,3)}function $V(n){return n<.5?4*n*n*n:1-Math.pow(2-2*n,3)/2}function GV(){let n=new Map;return{on(e,t){for(let i of e.split(/\s+/))n.has(i)||n.set(i,new Set),n.get(i).add(t)},off(e,t){for(let i of e.split(/\s+/))n.get(i)?.delete(t)},emit(e,t){for(let i of[...n.get(e)||[]])i(t)}}}function q3(n,e={}){let t=e.deckApi!==void 0?e.deckApi:globalThis.deck,i=e.copyCanvas||Yb,r={smooth:()=>!1,doubleBuffer:()=>!0,defer:()=>!1,...e.prefs||{}},s=e.tileSize||(()=>240),o=e.dpr||(()=>typeof devicePixelRatio=="number"?devicePixelRatio:1),a=e.raf||(P=>requestAnimationFrame(P)),c=e.now||(()=>performance.now()),l=GV(),u={target:[0,0],zoom:0,width:1,height:1},f={minZoom:-1/0,maxZoom:Y3},d=null,h=!1,p=[],m=[],g=null,v=null,y=!1,b=!1,w=0,E=new Set,x=!1;n.classList.add("or-view");let T=document.createElement("div");T.className="or-view-canvas",n.appendChild(T);let I=document.createElement("div");I.className="or-view-markers",n.appendChild(I);let N=new Map,D=new Map,H=new Map,W=new Map,V=new WeakMap,X=[],Y=cr(Z,a),ie=new Bh({isEnabled:()=>r.doubleBuffer(),isSmooth:()=>r.smooth(),now:c,onChange:()=>Y()}),oe=null;function zt(){return{dragPan:!0,dragRotate:!1,scrollZoom:!1,doubleClickZoom:!1,touchZoom:!e.isStatic,touchRotate:!1,keyboard:!1,inertia:!1}}function je(){return{target:[u.target[0],u.target[1],0],zoom:u.zoom,minZoom:f.minZoom,maxZoom:f.maxZoom}}function sn(){return new t.Deck({parent:T,views:new t.OrthographicView({id:"main",flipY:!1,controller:zt()}),viewState:je(),layers:[],useDevicePixels:!0,deviceProps:{webgl:{preserveDrawingBuffer:!!e.preserveDrawingBuffer}},getCursor:({isDragging:P})=>E.size?"crosshair":P?"grabbing":"default",onViewStateChange:({viewState:P})=>{if(d=null,_t(P.target,P.zoom),h){let A=c();m.push({t:A,target:[...u.target],zoom:u.zoom}),m=m.filter(O=>A-O.t<=j3)}return je()},onInteractionStateChange:P=>{let A=!!(P.isDragging||P.isPanning||P.isZooming||P.inTransition);if(A!==h){if(h=A,A){m=[],Pn();return}queueMicrotask(()=>{!h&&!d&&!gr()&&Cn()})}},onLoad:()=>{si(),Y()},onAfterRender:()=>{let P=p;p=[],P.forEach(A=>A())}})}function si(){let P=oe.getCanvas&&oe.getCanvas();P?.addEventListener("webglcontextlost",A=>{if(A.preventDefault(),x)return;l.emit("contextlost");let O=oe;oe=null,V=new WeakMap,X=[];try{O.finalize?.()}catch{}P.remove();try{oe=sn(),l.emit("contextrestored")}catch(G){l.emit("contextfailed",G)}Y()})}t&&typeof t.Deck=="function"&&(oe=sn());function oi(){let P=o(),A=Math.max(1,Math.floor(n.clientWidth*P)/P),O=Math.max(1,Math.floor(n.clientHeight*P)/P),G=A!==u.width||O!==u.height;return u.width=A,u.height=O,T.style.width=A+"px",T.style.height=O+"px",G}oi();let on=null;typeof ResizeObserver=="function"&&(on=new ResizeObserver(()=>Ri()),on.observe(n));function Ri(){oi()?(Sn(),l.emit("resize",ke())):Y()}function _t(P,A,{tiles:O=!0}={}){let G=bs(A,f),K=G!==u.zoom;u.target=[P[0],P[1]],u.zoom=G,Sn(K,O)}function Sn(P=!1,A=!0){oe&&oe.setProps({viewState:je()}),P&&l.emit("zoom"),l.emit("move"),A&&Ve(),Y()}function Pn(){b||(b=!0,l.emit("movestart"))}function Cn(){if(d||h)return;let P=Math.round(u.zoom);if(Math.abs(P-u.zoom)>1e-9){Ge({target:Lh(u,[u.width/2,u.height/2],P),zoom:P},{anchor:null});return}u.target=o3(u,o());let A=b;b=!1,Sn(),A&&(l.emit("moveend"),l.emit("zoomend"))}function gr(){let P=m;if(m=[],!r.smooth()||P.length<2)return!1;let A=P[0],O=P[P.length-1],G=O.t-A.t;if(G<=0||c()-O.t>j3||A.zoom!==O.zoom)return!1;let K=(O.target[0]-A.target[0])/G,J=(O.target[1]-A.target[1])/G;return Math.hypot(K,J)*Math.pow(2,u.zoom)W3?0:V3}function Ge(P,{anchor:A=null,ms:O=void 0,settle:G=!0,curve:K=!1}={}){P={target:P.target,zoom:bs(P.zoom,f)};let J=K&&O===void 0?_r(P):null;if(O===void 0&&(O=J?J.ms:$e(P)),Pn(),P.zoom!==u.zoom&&l.emit("zoomstart"),O<=0){d=null;let se=G&&!h;_t(P.target,P.zoom,{tiles:!se}),G&&Cn();return}v=null,d={from:{...u,target:[...u.target]},to:P,anchor:A,start:J?null:c(),created:c(),ms:O,flight:J},Ve(),Ut()}function _r(P){if(!r.smooth()||!(Math.hypot(P.target[0]-u.target[0],P.target[1]-u.target[1])*Math.pow(2,Math.min(u.zoom,P.zoom))>BV*Math.max(u.width,u.height))&&Math.abs(P.zoom-u.zoom)<=W3)return null;let G=a3(u,{...u,...P}),K=1/0,J=null;for(let fe=0;fe<=16;fe++){let q=G.at(fe/16);K=Math.min(K,q.zoom);let he=jo({...u,...q});J=J?[Math.min(J[0],he[0]),Math.min(J[1],he[1]),Math.max(J[2],he[2]),Math.max(J[3],he[3])]:he}let se=Math.max(0,Fb(K)),ge=Nl(J,se,s());return{path:G,ms:Math.min(FV,Math.max(NV,DV*G.S)),apex:ge?{z:se,range:ge}:null}}function ai(P){return!P||[...N.values()].every(A=>!A.visible||A.grid.settledIn(P.z,P.range))}function Ut(){if(!d||x)return;if(d.start===null){if(!ai(d.flight.apex)&&c()-d.created=1){let K=d.to;v=d.flight?d.flight.apex:null,d=null,_t(K.target,K.zoom),Cn();return}_t(G,O),a(Ut)}function ci(){return d?{...u,target:d.to.target,zoom:d.to.zoom}:u}function Ve(){if(N.size===0)return;let P=r.doubleBuffer(),A=bs(Fb(u.zoom,{targetZoom:d?d.to.zoom:null,hidingNewLevels:P}),{minZoom:0,maxZoom:Y3}),O=ci(),G=Nl(jo(O),A,s()),K=Mh(G),J=ie.shownZ,se=r.defer()&&h;se||ie.setZoom(A,{hasContent:[...N.values()].some(he=>he.visible&&J!==null&&he.grid.hasContentAt(J))});let ge=[];A>0&&!d&&!h&&!b&&ie.pendingZ===null&&(g=A-1,ge.push({z:g,range:Nl(zb(jo(O),IV),g,s())}));let fe=li();fe&&ge.push({...fe,background:!1});let q=d?Nl(jo(u),A,s()):null;for(let he of N.values())he.visible&&!se&&he.grid.update({z:A,range:G,ring:K,extra:ge,hold:q});Oi()}function li(){return d&&d.flight&&d.flight.apex||v}function an(P){let A=[];for(let O of[li()?.z,ie.pendingZ])O!=null&&!A.includes(O)&&!P.some(G=>G.z===O)&&A.push(O);return A}function Ii(){y||(y=!0,queueMicrotask(()=>{y=!1,x||Ve()}))}function Bi(){for(let P of N.values())if(P.visible&&!P.grid.isSettled())return!1;return!0}function Oi(P){let A=ie.check({settled:Bi(),animating:!!d});A&&ie.pendingZ===null&&Ii();let O=!1;v&&!d&&ie.isIdle()&&Bi()&&(v=null,O=!0),(A||O||!P||Rs(P.z))&&Y()}function Rs(P){let A=ie.plan(c()).draw;return A.some(O=>O.z===P)||an(A).includes(P)}function Tn(P,{order:A,source:O,visible:G=!0}){let K={load:(se,ge)=>O.load(se,ge),release:se=>{let ge=se&&V.get(se);ge&&(V.delete(se),X.push(ge)),O.release?.(se)}},J={id:P,order:A,visible:G,grid:new Ah({source:K,onChange:se=>Oi(se)})};return N.set(P,J),Ve(),{id:P,setVisible(se){J.visible!==!!se&&(J.visible=!!se,J.visible||J.grid.clear(),Ve())},isVisible:()=>J.visible,refresh(){J.visible&&(J.grid.refresh(),Y())},remove(){J.grid.clear(),N.delete(P),Y()}}}function $t(P){if(!oe||!oe.device)return P.image;let A=V.get(P);if(!A){try{A=oe.device.createTexture({data:P.image,width:P.width,height:P.height,mipLevels:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}})}catch{return P.image}V.set(P,A)}return A}function Me(P){if(P>=w)return 1;let A=(H3-(w-P))%400/400;return 1-.7*(.5-.5*Math.cos(2*Math.PI*A))}let yr=new WeakMap,Ae=null;function M(P){let A=s();A!==Ae&&(yr=new WeakMap,Ae=A);let O=yr.get(P);return O||(O=s3(P.z,P.x,P.y,A),yr.set(P,O)),O}function S(P,A,O,G,K,J){for(let se of A.grid.drawableTilesAt(O)){let ge=M(se);Ub(ge,G)&&P.push({order:A.order,props:{id:`${A.id}:${K}${se.key}`,image:$t(se.drawable),bounds:ge,opacity:J,parameters:Es}})}}function L(P,A){let O=[],G=ie.plan(P);if(!G.fading&&ie.pendingZ===null&&G.draw.length>0){let fe=[...G.draw.map(q=>q.z),g,li()?.z].filter(q=>q!=null);for(let q of N.values())q.grid.prune(fe)}let K=Me(P),J=[...N.values()].sort((fe,q)=>fe.order-q.order),se=J.find(fe=>fe.visible),ge=an(G.draw);for(let fe of J)if(fe.visible){fe===se&&ge.length>0&&O.push(...F(fe,ge,G.draw,A,K));for(let q of G.draw)S(O,fe,q.z,A,"",q.opacity*K)}return{layers:O,animate:G.fading||Phe.z===fe.z)||fe.loading&&!fe.drawable)continue;let q=M(fe);if(Ub(q,G)){let[he,Ln,cp,na]=q;ge.push([[he-se,Ln-se],[cp+se,Ln-se],[cp+se,na+se],[he-se,na+se]])}}return ge.length&&J.push({order:P.order,kind:"SolidPolygonLayer",props:{id:`${P.id}:mask`,data:ge,getPolygon:fe=>fe,getFillColor:k(),parameters:Es}}),J}function k(){let P=(getComputedStyle(n).backgroundColor||"").match(/[\d.]+/g);return!P||P.length<3||P.length>3&&Number(P[3])===0?[0,0,0,255]:[Number(P[0]),Number(P[1]),Number(P[2]),255]}function U(P,A,O){let G=[],K=[],J=[],se=[];for(let q of A){if(q.kind==="circle"){se.push(q);continue}let he=q.kind==="rect"?[[q.rect[0],q.rect[1]],[q.rect[2],q.rect[1]],[q.rect[2],q.rect[3]],[q.rect[0],q.rect[3]]]:q.points;if(q.fill&&K.push({polygon:he,color:q.fill}),q.stroke){let Ln=q.kind==="rect"||q.closed;J.push({path:Ln?[...he,he[0]]:he,color:q.stroke,width:q.width||1,dash:q.dash||null})}}K.length&&G.push({order:O,kind:"SolidPolygonLayer",props:{id:`${P}:fill`,data:K,getPolygon:q=>q.polygon,getFillColor:q=>q.color,parameters:Es}});let ge=J.filter(q=>!q.dash),fe=J.filter(q=>q.dash);if(ge.length&&G.push({order:O,kind:"PathLayer",props:{id:`${P}:stroke`,data:ge,widthUnits:"pixels",getPath:q=>q.path,getColor:q=>q.color,getWidth:q=>q.width,parameters:Es}}),fe.length){let q={id:`${P}:dash`,data:fe,widthUnits:"pixels",getPath:he=>he.path,getColor:he=>he.color,getWidth:he=>he.width,getDashArray:he=>he.dash.map(Ln=>Ln/he.width),dashJustified:!0,parameters:Es};t?.PathStyleExtension&&(q.extensions=[new t.PathStyleExtension({dash:!0})]),G.push({order:O,kind:"PathLayer",props:q})}return se.length&&G.push({order:O,kind:"ScatterplotLayer",props:{id:`${P}:circle`,data:se,radiusUnits:"pixels",lineWidthUnits:"pixels",getPosition:q=>q.center,getRadius:q=>q.radius,stroked:!0,filled:!0,getLineColor:q=>q.stroke||[0,0,0,0],getFillColor:q=>q.fill||[0,0,0,0],getLineWidth:q=>q.width||1,parameters:Es}}),G}function R(){let P=[];for(let A of D.values())P.push(...A);return P.push(...H.values()),P}function B(P){return P.map(A=>new t[A.kind||"BitmapLayer"](A.props))}let $=0;function Z(){if(x)return;let P=c(),A=L(P,zb(jo(u),.5)),O=[...A.layers,...R()].sort((G,K)=>G.order-K.order);$=O.length,oe&&oe.setProps({layers:B(O)});for(let G of X.splice(0))G.destroy?.();Oe(),A.animate&&Y(),l.emit("render")}function Q(P=32,A=20){let O=N.get("base");if(!O)return null;let G=s(),K=ie.plan(c()).draw,J=[...K,...an(K).map(fe=>({z:fe}))],se=0,ge=0;for(let fe=0;fe=G||Ln>=G)continue;se++,J.some(({z:na})=>{let gv=G/2**na,lp=O.grid.tiles.get(Ho(na,Math.floor(he/gv),Math.floor((G-Ln)/gv)));return lp&&(lp.drawable||!lp.loading)})&&ge++}return se?ge/se:null}function de(P){return W.has(P)||W.set(P,{visible:!0,items:new Map}),W.get(P)}function _e(P,A){let[O,G]=Th(P.world,u);P.el.style.display=A?"":"none",P.el.style.transform=`translate(${O}px, ${G}px)`+(P.center?" translate(-50%, -50%)":"")}function Xe(P){for(let A of P.items.values())_e(A,P.visible)}function Oe(){for(let P of W.values())Xe(P)}function ke(){return{width:u.width,height:u.height}}let Qe={DRAW_ORDER:at,getContainer:()=>n,getSize:ke,getZoom:()=>u.zoom,getTargetZoom:()=>d?d.to.zoom:u.zoom,getCenter:()=>[...u.target],getViewState:()=>({...u,target:[...u.target]}),isAnimating:()=>!!d,isMoving:()=>b,project:P=>Th(P,u),unproject:P=>Wo(P,u),on:l.on,off:l.off,setLimits({minZoom:P,maxZoom:A}={}){P!==void 0&&(f.minZoom=P),A!==void 0&&(f.maxZoom=A);let O=bs(u.zoom,f);O!==u.zoom?_t(u.target,O):oe&&oe.setProps({viewState:je()}),l.emit("limits")},getLimits:()=>({...f}),setView(P,A=u.zoom,{animate:O}={}){let G={target:[P[0],P[1]],zoom:A};Ge(G,O===!1?{ms:0}:{curve:!0})},fitWorldRect(P,{padding:A=[0,0],animate:O}={}){let G=r3(P,u,{padding:A,...f});Ge(G,O===!1?{ms:0}:{curve:!0})},zoomAround(P,A,{animate:O,settle:G=!0}={}){let K=bs(Qe.getTargetZoom()+A,f),J=ci(),se=P||[u.width/2,u.height/2],ge=Lh(J,se,K);Ge({target:ge,zoom:K},O===!1?{ms:0,settle:G}:{anchor:P?se:null})},zoomIn:()=>Qe.zoomAround(null,1),zoomOut:()=>Qe.zoomAround(null,-1),panByPx(P,A,{animate:O}={}){let G=ci(),K=Math.pow(2,G.zoom),J=[G.target[0]+P/K,G.target[1]-A/K],se=O===!1||!r.smooth()?0:V3;Ge({target:J,zoom:G.zoom},{ms:se})},invalidateSize:Ri,applyPrefs(){Ve()},addTileSlot:Tn,setOverlay(P,A,{order:O=at.selection}={}){!A||A.length===0?D.delete(P):D.set(P,U(P,A,O)),Y()},hasOverlay:P=>D.has(P),setImageOverlay(P,A,{order:O=at.pathImage}={}){A?H.set(P,{order:O,kind:"BitmapLayer",props:{id:`image:${P}`,image:A.image,bounds:A.rect,parameters:Es}}):H.delete(P),Y()},addMarker(P,A,O,G,{center:K=!1}={}){let J=de(P),se=J.items.get(A);se&&se.el.remove(),G.classList.add("or-view-marker"),I.appendChild(G);let ge={el:G,world:[O[0],O[1]],center:K};return J.items.set(A,ge),_e(ge,J.visible),G},moveMarker(P,A,O){let G=de(P),K=G.items.get(A);K&&(K.world=[O[0],O[1]],_e(K,G.visible))},clearMarkers(P){let A=de(P);for(let O of A.items.values())O.el.remove();A.items.clear()},setMarkerGroupVisible(P,A){let O=de(P);O.visible=!!A,Xe(O)},setCursorMode(P,A=!0){A?E.add(P):E.delete(P),n.classList.toggle(`${P}-mode-cursor`,!!A);let O=oe&&oe.getCanvas&&oe.getCanvas();O&&(O.style.cursor=E.size?"crosshair":"default")},flashTiles(){w=c()+H3,Y()},whenTilesSettled({timeoutMs:P=6e3}={}){let A=c()+P;return new Promise(O=>{let G=()=>{if(Bi()&&ie.isIdle()&&!d&&!b||c()>=A){O();return}setTimeout(G,32)};G()})},captureCanvas({timeoutMs:P=500}={}){return oe?.getCanvas()?(Z(),new Promise(A=>{let O=null,G=()=>{clearTimeout(O),p=p.filter(J=>J!==G);let K=oe?.getCanvas();A(K?{image:i(K),rect:K.getBoundingClientRect()}:null)};p.push(G),O=setTimeout(()=>{oe?.redraw("capture"),G()},P)})):Promise.resolve(null)},redraw:()=>Y(),debugSnapshot(){let P=ie.plan();return{zoom:u.zoom,target:[...u.target],width:u.width,height:u.height,animating:!!d,moving:b,interacting:h,shownZ:ie.shownZ,pendingZ:ie.pendingZ,fading:P.fading,drawLevels:P.draw,layers:$,coverage:Q(),overlays:[...D.keys()],markers:Object.fromEntries([...W].map(([A,O])=>[A,O.items.size])),slots:[...N.values()].map(A=>({id:A.id,visible:A.visible,settled:A.grid.isSettled(),...A.grid.stats()}))}},destroy(){x=!0,on?.disconnect(),ie.dispose();for(let P of N.values())P.grid.clear();oe?.finalize?.()}};return Qe}var VV=4.000244140625;function WV(n){return n.deltaMode!==0?!0:n.deltaX!==0||n.deltaY===0?!1:Number.isInteger(n.deltaY)&&Math.abs(n.deltaY)>=50||n.deltaY%VV===0}function jV(n){let e=Math.abs(n);return e<.2?0:Math.sign(n)*Math.max(1,Math.round(e))}function HV(n,e){let i=1;return n.deltaMode===1?i=16:n.deltaMode===2&&(i=e.clientHeight||16),[n.deltaX*i,n.deltaY*i]}function YV(n,e,t){let i=t?3*e:e;switch(n){case"ArrowLeft":return[-i,0];case"ArrowRight":return[i,0];case"ArrowUp":return[0,-i];case"ArrowDown":return[0,i];default:return null}}function X3(n,e={}){let t=n.getContainer(),i=e.isStatic||(()=>!1),r=e.wheelZoom||(()=>!0),s=e.arrowStep||(()=>80),o=e.gestureIdleMs??200,a=e.contextEnabled||(()=>!0),c=[],l=(x,T,I,N)=>{x.addEventListener(T,I,N),c.push(()=>x.removeEventListener(T,I,N))},u=x=>{let T=t.getBoundingClientRect();return[x.clientX-T.left,x.clientY-T.top]},f=x=>n.unproject(u(x)),d=x=>x.target===t||!!x.target?.closest?.(".or-view-canvas");t.tabIndex<0&&(t.tabIndex=0);let h=null;function p(x,T){h||(h={z0:n.getZoom()}),h.pt=x,clearTimeout(h.timer),h.timer=setTimeout(m,o),n.zoomAround(x,T,{animate:!1,settle:!1})}function m(){if(!h)return;let x=h;h=null,clearTimeout(x.timer);let T=n.getZoom();n.zoomAround(x.pt,x.z0+jV(T-x.z0)-T)}c.push(()=>{clearTimeout(h?.timer),h=null}),l(t,"wheel",x=>{if(x.preventDefault(),i())return;let T=WV(x);if(!T&&x.ctrlKey){p(u(x),-x.deltaY/(100*Math.LN2));return}if(r()===x.ctrlKey){let[I,N]=HV(x,t);n.panByPx(I,N,{animate:!1});return}if(!T){p(u(x),-x.deltaY/100);return}m(),n.zoomAround(u(x),x.deltaY<0?1:-1)},{passive:!1}),l(t,"keydown",x=>{if(x.altKey||x.ctrlKey||x.metaKey)return;let T=YV(x.key,s(),x.shiftKey);if(T){x.preventDefault(),n.panByPx(T[0],T[1]);return}if(i())return;let I={"+":1,"=":1,"-":-1,_:-1};x.key in I&&(x.preventDefault(),n.zoomAround(null,I[x.key]*(x.shiftKey?3:1)))});let g=null,v=null;l(t,"pointerdown",x=>{x.button!==0||!d(x)||(t.focus({preventScroll:!0}),g={x:x.clientX,y:x.clientY,moved:!1,box:x.shiftKey&&!i()},g.box&&x.stopPropagation())},{capture:!0}),l(window,"pointermove",x=>{if(!g)return;let T=x.clientX-g.x,I=x.clientY-g.y;(Math.abs(T)>3||Math.abs(I)>3)&&(g.moved=!0),g.box&&g.moved&&(v=Z3(v,g,x))}),l(window,"pointerup",x=>{if(!g||x.button!==0)return;let T=g;if(g=null,v&&(v.remove(),v=null),T.box&&T.moved){E(T,x);return}!T.moved&&e.onClick&&w(x)&&e.onClick(f(x),x)}),l(t,"dblclick",x=>{i()||!d(x)||n.zoomAround(u(x),x.shiftKey?-1:1)});let y=null,b=null;l(t,"contextmenu",x=>x.preventDefault()),l(t,"pointerdown",x=>{x.button!==2||i()||!d(x)||(x.stopPropagation(),y={x:x.clientX,y:x.clientY})},{capture:!0}),l(window,"pointermove",x=>{if(!y)return;let T=x.clientX-y.x,I=x.clientY-y.y;(b||Math.abs(T)>=4&&Math.abs(I)>=4)&&(b=Z3(b,y,x))}),l(window,"pointerup",x=>{if(!y||x.button!==2)return;let T=y;if(y=null,b){b.remove(),b=null,E(T,x);return}w(x)&&a()&&e.onContextClick&&e.onContextClick(f(x),x)}),l(t,"pointermove",x=>{e.onMove&&e.onMove(f(x),x)}),l(t,"pointerleave",x=>{e.onLeave&&e.onLeave(x)});function w(x){let T=t.getBoundingClientRect();return x.clientX>=T.left&&x.clientX<=T.right&&x.clientY>=T.top&&x.clientY<=T.bottom}function E(x,T){let I=t.getBoundingClientRect(),N=n.unproject([x.x-I.left,x.y-I.top]),D=n.unproject([T.clientX-I.left,T.clientY-I.top]);n.fitWorldRect([Math.min(N[0],D[0]),Math.min(N[1],D[1]),Math.max(N[0],D[0]),Math.max(N[1],D[1])])}return{dispose(){for(let x of c.splice(0))x()}}}function Z3(n,e,t){return n||(n=document.createElement("div"),n.className="rubber-band",document.body.appendChild(n)),n.style.left=Math.min(e.x,t.clientX)+"px",n.style.top=Math.min(e.y,t.clientY)+"px",n.style.width=Math.abs(t.clientX-e.x)+"px",n.style.height=Math.abs(t.clientY-e.y)+"px",n}var Ps=class n{constructor(e,t,i){this._app=e,this._redrawAllLayers=t,this._refreshOverlay=i||t,this._currentTab="setup",this._setupPaths=[],this._holdPaths=[],this._selectedPathIndex=-1,this._detailTab="data",this._selectedDetailIndex=-1,this._sortCol="slack",this._sortAscending=!0,this._build()}_build(){let e=document.createElement("div");e.className="timing-widget";let t=document.createElement("div");t.className="timing-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",ue(this._app)&&(this._updateBtn.style.display="none"),this._pathCountLabel=document.createElement("span"),this._pathCountLabel.className="timing-path-count",t.appendChild(this._updateBtn),t.appendChild(this._pathCountLabel),e.appendChild(t),e.appendChild(this._buildConePanel());let i=document.createElement("div");i.className="timing-tab-bar",this._setupTab=this._makeTab("Setup",!0),this._holdTab=this._makeTab("Hold",!1),i.appendChild(this._setupTab),i.appendChild(this._holdTab),e.appendChild(i),this._pathTableContainer=document.createElement("div"),this._pathTableContainer.className="timing-path-table-container",this._pathTable=document.createElement("table"),this._pathTable.className="timing-table",this._pathTableContainer.appendChild(this._pathTable),e.appendChild(this._pathTableContainer);let r=document.createElement("div");r.className="timing-tab-bar",this._dataTab=this._makeTab("Data Path",!0),this._captureTab=this._makeTab("Capture Path",!1),r.appendChild(this._dataTab),r.appendChild(this._captureTab),e.appendChild(r),this._detailTableContainer=document.createElement("div"),this._detailTableContainer.className="timing-detail-table-container",this._detailTable=document.createElement("table"),this._detailTable.className="timing-table",this._detailTableContainer.appendChild(this._detailTable),e.appendChild(this._detailTableContainer),this._headerTooltip=document.createElement("div"),this._headerTooltip.className="or-tooltip or-tooltip-fixed",e.appendChild(this._headerTooltip),this.element=e,this._bindEvents(),ue(this._app)&&setTimeout(()=>this.update(),0)}_makeTab(e,t){let i=document.createElement("button");return i.className="timing-tab"+(t?" active":""),i.textContent=e,i}_bindEvents(){this._setupTab.addEventListener("click",()=>{this._currentTab="setup",this._setupTab.classList.add("active"),this._holdTab.classList.remove("active"),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}),this._holdTab.addEventListener("click",()=>{this._currentTab="hold",this._holdTab.classList.add("active"),this._setupTab.classList.remove("active"),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}),this._dataTab.addEventListener("click",()=>{this._detailTab="data",this._dataTab.classList.add("active"),this._captureTab.classList.remove("active"),this._renderDetailTable()}),this._captureTab.addEventListener("click",()=>{this._detailTab="capture",this._captureTab.classList.add("active"),this._dataTab.classList.remove("active"),this._renderDetailTable()}),this._updateBtn.addEventListener("click",()=>this.update()),this._pathTableContainer.setAttribute("tabindex","0"),this._pathTableContainer.style.outline="none",this._pathTableContainer.addEventListener("keydown",e=>{if(e.key==="ArrowDown"){e.preventDefault();let t=this._pathTable.querySelectorAll("tbody tr");this._selectedPathIndex0&&this._selectPathRow(this._selectedPathIndex-1))}),this._detailTableContainer.setAttribute("tabindex","0"),this._detailTableContainer.style.outline="none",this._detailTableContainer.addEventListener("keydown",e=>{if(e.key==="ArrowDown"){e.preventDefault();let t=this._detailTable.querySelectorAll("tbody tr");this._selectedDetailIndex0&&this._selectDetailRow(this._selectedDetailIndex-1))})}_buildConePanel(){let e=document.createElement("div");e.className="timing-cone-panel";let t=document.createElement("span");t.className="timing-cone-title",t.textContent="Timing cone:",e.appendChild(t);let i=(u,f,d=!1)=>{let h=document.createElement("input");h.type="checkbox",h.id=u,h.checked=d;let p=document.createElement("label");return p.htmlFor=u,p.textContent=f,{input:h,lbl:p}},r=i("cone-fanin","Fanin",!0),s=i("cone-fanout","Fanout",!0);this._coneFanin=r.input,this._coneFanout=s.input,e.append(r.input,r.lbl,s.input,s.lbl);let o=u=>{let f=document.createElement("label");f.className="timing-cone-depth-label",f.textContent=u;let d=document.createElement("input");return d.type="number",d.min="0",d.value="0",d.className="timing-cone-depth",d.title="0 = unlimited",f.appendChild(d),{lbl:f,input:d}},a=o("in\u2264"),c=o("out\u2264");this._coneFaninDepth=a.input,this._coneFanoutDepth=c.input,e.append(a.lbl,c.lbl),this._coneColorMode=document.createElement("select"),this._coneColorMode.className="timing-cone-colormode";for(let[u,f]of[["slack","by slack"],["depth","by depth"]]){let d=document.createElement("option");d.value=u,d.textContent=f,this._coneColorMode.appendChild(d)}e.appendChild(this._coneColorMode);let l=i("cone-sync-schematic","Sync schematic");return this._coneSyncSchematic=l.input,e.append(l.input,l.lbl),this._coneApplyBtn=document.createElement("button"),this._coneApplyBtn.className="or-btn",this._coneApplyBtn.textContent="Cone",this._coneApplyBtn.title="Show the timing cone for the selected instance",this._coneClearBtn=document.createElement("button"),this._coneClearBtn.className="or-btn",this._coneClearBtn.textContent="Clear",e.append(this._coneApplyBtn,this._coneClearBtn),this._coneStatus=document.createElement("span"),this._coneStatus.className="timing-cone-status",e.appendChild(this._coneStatus),this._coneApplyBtn.addEventListener("click",()=>this._applyCone()),this._coneClearBtn.addEventListener("click",()=>this._clearCone()),e}_coneTarget(){return this._app.selectedInstanceName||""}async _applyCone(){let e=this._coneFanin.checked,t=this._coneFanout.checked;if(!e&&!t){this._coneStatus.textContent="select fanin and/or fanout";return}let i=this._coneTarget();if(!i){this._coneStatus.textContent="select an instance first";return}let r={type:"timing_cone",fanin:e,fanout:t,fanin_depth:Math.max(0,parseInt(this._coneFaninDepth.value,10)||0),fanout_depth:Math.max(0,parseInt(this._coneFanoutDepth.value,10)||0),color_mode:this._coneColorMode.value,inst_name:i};this._coneApplyBtn.disabled=!0,this._coneStatus.textContent="computing\u2026";try{let s=await this._app.websocketManager.request(r);this._refreshOverlay(),this._renderConeStatus(s),this._coneSyncSchematic.checked&&i&&document.dispatchEvent(new CustomEvent("openroad-cone-sync",{detail:{inst_name:i,fanin:r.fanin,fanout:r.fanout,fanin_depth:r.fanin_depth,fanout_depth:r.fanout_depth}}))}catch(s){this._coneStatus.textContent="cone error: "+(s.message||s)}this._coneApplyBtn.disabled=!1}_renderConeStatus(e){if(!e){this._coneStatus.textContent="";return}let t=e.node_count||0;if(t===0){this._coneStatus.textContent="empty cone";return}let i=t+" pins";if(e.color_mode==="depth")i+=`, depth \xB1${e.max_depth}`;else if(e.constrained){let r=e.time_unit||"";i+=`, slack ${Ss(e.min_slack)}\u2026${Ss(e.max_slack)}${r}`}else i+=", unconstrained";this._coneStatus.textContent=i}_clearCone(){this._app.websocketManager.request({type:"timing_cone",clear:!0}).then(()=>this._refreshOverlay()),this._coneStatus.textContent=""}showPaths(e,t){this._currentTab=e,e==="setup"?(this._setupPaths=[...t],this._setupTab.classList.add("active"),this._holdTab.classList.remove("active")):(this._holdPaths=[...t],this._holdTab.classList.add("active"),this._setupTab.classList.remove("active")),this._applySort(),this._selectedPathIndex=-1,this._pathCountLabel.textContent=t.length+" paths",this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...";try{let[e,t]=await Promise.all([this._app.websocketManager.request({type:"timing_report",is_setup:!0,max_paths:100}),this._app.websocketManager.request({type:"timing_report",is_setup:!1,max_paths:100})]);this._setupPaths=[...e.paths||[]],this._holdPaths=[...t.paths||[]],this._applySort(),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}catch(e){console.error("Timing fetch failed:",e)}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}_applySort(){for(let e of[this._setupPaths,this._holdPaths]){e.forEach((r,s)=>{r._originalIndex===void 0&&(r._originalIndex=s)});let t=this._sortAscending?1:-1,i=this._sortCol;e.sort((r,s)=>{let o=r[i],a=s[i],c=typeof o=="number"&&typeof a=="number"?o-a:String(o).localeCompare(String(a));return t*c})}}_showHeaderTooltip(e,t){if(e.buttons!==0){this._hideHeaderTooltip();return}let i=this._headerTooltip;i.textContent=t,i.style.display="block";let r=Math.min(e.clientX+12,window.innerWidth-i.offsetWidth-8);i.style.left=Math.max(0,r)+"px",i.style.top=e.clientY+14+"px"}_hideHeaderTooltip(){this._headerTooltip.style.display="none"}_sortBy(e){this._sortCol===e?this._sortAscending=!this._sortAscending:(this._sortCol=e,this._sortAscending=!0),this._applySort(),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}_clearTimingHighlight(){this._app.websocketManager.request({type:"timing_highlight",path_index:-1}).then(()=>this._refreshOverlay())}_selectPathRow(e){let t=this._pathTable.querySelectorAll("tbody tr");if(e<0||e>=t.length)return;this._selectedPathIndex=e;for(let s of t)s.classList.remove("selected");t[e].classList.add("selected"),t[e].scrollIntoView({block:"nearest"}),this._pathTableContainer.focus(),this._renderDetailTable();let r=(this._currentTab==="setup"?this._setupPaths:this._holdPaths)[e]?._originalIndex??e;this._app.websocketManager.request({type:"timing_highlight",path_index:r,is_setup:this._currentTab==="setup"}).then(()=>this._refreshOverlay()).catch(s=>console.error("timing_highlight error:",s))}_renderPathTable(){this._hideHeaderTooltip();let e=this._currentTab==="setup"?this._setupPaths:this._holdPaths;this._pathCountLabel.textContent=e.length+" paths";let t=this._pathTable.querySelectorAll("thead th"),i=Array.from(t,c=>c.style.width);this._pathTable.innerHTML="";let r=document.createElement("thead"),s=document.createElement("tr");for(let c of n.PATH_COLS){let l=document.createElement("th");l.classList.add("sortable"),c.num&&l.classList.add("num"),l.textContent=c.label+(c.key===this._sortCol?this._sortAscending?" \u25B2":" \u25BC":""),c.tooltip&&(l.addEventListener("mousemove",u=>this._showHeaderTooltip(u,c.tooltip)),l.addEventListener("mouseleave",()=>this._hideHeaderTooltip())),l.addEventListener("click",()=>this._sortBy(c.key)),s.appendChild(l)}r.appendChild(s),this._pathTable.appendChild(r);let o=document.createElement("tbody"),a=e.reduce((c,l)=>Math.max(c,Math.abs(Number(l.slack)||0)),0);if(e.forEach((c,l)=>{let u=document.createElement("tr");l===this._selectedPathIndex&&u.classList.add("selected");for(let f of n.PATH_COLS){let d=document.createElement("td"),h=c[f.key];if(d.textContent=f.time?Ss(h):h,f.num&&d.classList.add("num"),f.key==="slack"){let p=Number(c.slack);p<0&&d.classList.add("slack-negative"),Number.isFinite(p)&&a>0&&(d.classList.add("slack-cell",p<0?"slack-under":"slack-over"),d.style.setProperty("--slack-frac",String(Math.abs(p)/a)))}u.appendChild(d)}u.style.cursor="pointer",u.addEventListener("click",()=>this._selectPathRow(l)),o.appendChild(u)}),e.length===0){let c=document.createElement("tr"),l=document.createElement("td");l.colSpan=n.PATH_COLS.length,l.style.textAlign="center",l.style.color="var(--fg-secondary)",l.textContent=ue(this._app)?"No timing data available":'Click "Update" to load timing paths',c.appendChild(l),o.appendChild(c)}this._pathTable.appendChild(o),ws(this._pathTable,i)}_selectDetailRow(e){let t=this._detailTable.querySelectorAll("tbody tr");if(e<0||e>=t.length)return;this._selectedDetailIndex=e;for(let a of t)a.classList.remove("timing-selected-row");t[e].classList.add("timing-selected-row"),t[e].scrollIntoView({block:"nearest"}),this._detailTableContainer.focus();let r=(this._currentTab==="setup"?this._setupPaths:this._holdPaths)[this._selectedPathIndex],s=this._detailTab==="data"?r.data_nodes:r.capture_nodes,o=r._originalIndex??this._selectedPathIndex;this._app.websocketManager.request({type:"timing_highlight",path_index:o,is_setup:this._currentTab==="setup",pin_name:s[e].pin}).then(()=>this._refreshOverlay())}_renderDetailTable(){let e=this._detailTable.querySelectorAll("thead th"),t=Array.from(e,l=>l.style.width);this._detailTable.innerHTML="",this._selectedDetailIndex=-1;let i=this._currentTab==="setup"?this._setupPaths:this._holdPaths;if(this._selectedPathIndex<0||this._selectedPathIndex>=i.length)return;let r=i[this._selectedPathIndex],s=this._detailTab==="data"?r.data_nodes:r.capture_nodes,o=document.createElement("thead"),a=document.createElement("tr");for(let l of n.DETAIL_COLS){let u=document.createElement("th");n.DETAIL_NUM_COLS.has(l)&&u.classList.add("num"),u.textContent=l,a.appendChild(u)}o.appendChild(a),this._detailTable.appendChild(o);let c=document.createElement("tbody");if(s.forEach((l,u)=>{let f=document.createElement("tr");l.clk&&f.classList.add("timing-clock-row"),[l.pin,l.fanout,l.rise?"\u2191":"\u2193",Ss(l.time),Ss(l.delay),Ss(l.slew),Ss(l.load)].forEach((h,p)=>{let m=document.createElement("td");n.DETAIL_NUM_COLS.has(n.DETAIL_COLS[p])&&m.classList.add("num"),m.textContent=h,f.appendChild(m)}),f.style.cursor="pointer",f.addEventListener("click",()=>this._selectDetailRow(u)),c.appendChild(f)}),this._detailTable.appendChild(c),ws(this._detailTable,t),!t[0]){let l=this._detailTable.querySelector("thead th");l&&(l.style.width="30ch")}}};function Ss(n){return n==null?"":typeof n=="number"?n.toFixed(4):String(n)}Ps.PATH_COLS=[{label:"Clock",key:"end_clk"},{label:"Required",key:"required",time:!0,num:!0},{label:"Arrival",key:"arrival",time:!0,num:!0},{label:"Slack",key:"slack",time:!0,num:!0},{label:"Skew",key:"skew",time:!0,num:!0,tooltip:`The difference in arrival times between source and destination clock pins of a macro/register, adjusted for CRPR and subtracting a clock period. -Setup and hold times account for internal clock delays.`},{label:"Logic Delay",key:"path_delay",time:!0,num:!0,tooltip:"Path delay from instances (excluding buffers and consecutive inverter pairs)"},{label:"Logic Depth",key:"logic_depth",num:!0,tooltip:"Path instances (excluding buffers and consecutive inverter pairs)"},{label:"Fanout",key:"fanout",num:!0},{label:"Start",key:"start_pin"},{label:"End",key:"end_pin"}];_i.DETAIL_COLS=["Pin","Fanout","R/F","Time","Delay","Slew","Load"];_i.DETAIL_NUM_COLS=new Set(["Fanout","Time","Delay","Slew","Load"]);function Vt(s){let e=document.cookie.match("(?:^|; )"+s+"=([^;]*)");return e?e[1]:null}function Qt(s,e){document.cookie=s+"="+e+"; path=/; max-age=31536000; SameSite=Lax"}function ds(s){document.cookie=s+"=; path=/; max-age=0; SameSite=Lax"}function us(s){Qt("or_theme",s);try{window.localStorage.setItem("or_theme",s)}catch{}}function cl(){ds("or_theme");try{window.localStorage.removeItem("or_theme")}catch{}}function Ro(s){let e=document.getElementById("gl-theme-dark"),i=document.getElementById("gl-theme-light");!e||!i||(e.disabled=s!=="dark",i.disabled=s!=="light")}function hl(s,e){Fi(s)&&(document.documentElement.style.setProperty("--bg-map",s),Qt("or_bg_color",s),ul(e),e.syncDisplayState())}function dl(s){document.documentElement.style.removeProperty("--bg-map"),ds("or_bg_color"),ul(s),s.syncDisplayState()}function zo(){return ol(getComputedStyle(document.documentElement).getPropertyValue("--bg-map"))??"#000000"}function ul(s){s.threeDViewerWidget?.render?.()}if(typeof document<"u"){let s=Vt("or_theme")||typeof localStorage<"u"&&localStorage.getItem("or_theme")||(matchMedia("(prefers-color-scheme: light)").matches?"light":"dark");document.documentElement.dataset.theme=s,Ro(s);let e=Vt("or_bg_color");Fi(e)&&document.documentElement.style.setProperty("--bg-map",e)}function gi(){let s=getComputedStyle(document.documentElement),e=i=>s.getPropertyValue(i).trim();return{canvasBg:e("--canvas-bg"),canvasText:e("--canvas-text"),canvasAxis:e("--canvas-axis"),canvasLabel:e("--canvas-label"),canvasGrid:e("--canvas-grid"),canvasTitle:e("--canvas-title"),fgPrimary:e("--fg-primary"),fgMuted:e("--fg-muted"),bgPanel:e("--bg-panel"),bgMap:e("--bg-map"),fontMono:e("--font-mono"),fontSans:e("--font-sans")}}function yi(s,e){let i=document.createElement("a");i.href=s,i.download=e,document.body.appendChild(i),i.click(),i.remove()}function pl(s,e){let i=URL.createObjectURL(s);yi(i,e),setTimeout(()=>URL.revokeObjectURL(i),1e3)}function Oo(s){let e=s.cloneNode(!0);if(e.getAttribute("xmlns")||e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.getAttribute("xmlns:xlink")||e.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),!e.getAttribute("width")||!e.getAttribute("height")){let i=s.viewBox&&s.viewBox.baseVal;i&&i.width&&i.height&&(e.setAttribute("width",i.width),e.setAttribute("height",i.height))}return` -`+new XMLSerializer().serializeToString(e)}function Yh(s){let e=s.viewBox&&s.viewBox.baseVal;if(e&&e.width&&e.height)return{width:e.width,height:e.height};let i=parseFloat(s.getAttribute("width")),o=parseFloat(s.getAttribute("height"));if(i&&o)return{width:i,height:o};let r=s.getBoundingClientRect();return{width:r.width||800,height:r.height||600}}function $o(s,e=2){let{width:i,height:o}=Yh(s),r=Oo(s),l=new Blob([r],{type:"image/svg+xml;charset=utf-8"}),h=URL.createObjectURL(l);return new Promise((u,f)=>{let _=new Image;_.onload=()=>{let y=document.createElement("canvas");y.width=Math.max(1,Math.round(i*e)),y.height=Math.max(1,Math.round(o*e));let g=y.getContext("2d");g.fillStyle="#ffffff",g.fillRect(0,0,y.width,y.height),g.drawImage(_,0,0,y.width,y.height),URL.revokeObjectURL(h),u(y.toDataURL("image/png"))},_.onerror=y=>{URL.revokeObjectURL(h),f(y)},_.src=h})}async function ps(s){try{if(!navigator.clipboard||!window.ClipboardItem)return!1;let e=await(await fetch(s)).blob();return await navigator.clipboard.write([new ClipboardItem({"image/png":e})]),!0}catch{return!1}}function Xh(s){return(String(s||"").replace(/[^A-Za-z0-9._-]/g,"_").replace(/^_+|_+$/g,"")||"clock_tree")+".png"}var Ho=24,Fo=10,ms=40,jh=40,Zo=70,Kh=20,fs={root:"#ff4444",buffer:"#4488ff",inverter:"#00b0b0",clock_gate:"#cc44cc",register:"#ff4444",macro:"#00b0b0",unknown:"#888888"};function Jh(s){let e=parseInt(s.slice(1,3),16),i=parseInt(s.slice(3,5),16),o=parseInt(s.slice(5,7),16),r=h=>Math.round((h+255)/2),l=h=>h.toString(16).padStart(2,"0");return"#"+l(r(e))+l(r(i))+l(r(o))}function Qh(s){let e=s.nodes;if(!e||e.length===0)return{layout:[],layoutWidth:0,layoutHeight:0,timeMin:0,timeMax:0,timeUnit:"",sceneHeight:0,layoutById:new Map};let i=new Map;for(let M of e)i.set(M.id,[]);for(let M of e)M.parent_id>=0&&i.has(M.parent_id)&&i.get(M.parent_id).push(M.id);let o=new Map;for(let M of e)o.set(M.id,M);let r=new Map,l=M=>{let q=i.get(M)||[];if(q.length===0)return r.set(M,1),1;let G=0;for(let dt of q)G+=l(dt);return r.set(M,G),G},h=e.filter(M=>M.parent_id===-1),u=0;for(let M of h)u+=l(M.id);let f=s.min_arrival,_=s.max_arrival,y=_-f||1,g=Math.max(200,u*Ho*.6),v=[],w=(M,q)=>{let G=o.get(M),dt=r.get(M),gt=Zo+(q+dt/2)*Ho,it=ms+(G.arrival-f)/y*g;v.push({id:G.id,x:gt,y:it,type:G.type,name:G.name,pin_name:G.pin_name,arrival:G.arrival,delay:G.delay,fanout:G.fanout,level:G.level,parent_id:G.parent_id});let Q=q,nt=i.get(M)||[];for(let tt of nt)w(tt,Q),Q+=r.get(tt)},b=0;for(let M of h)w(M.id,b),b+=r.get(M.id);let C=Zo+u*Ho+Kh,R=ms+g+jh,A=new Map;for(let M of v)A.set(M.id,M);return{layout:v,layoutWidth:C,layoutHeight:R,timeMin:f,timeMax:_,timeUnit:s.time_unit||"",sceneHeight:g,layoutById:A}}var _s=class{constructor(e,i,o,r){this._app=i,this._redrawAllLayers=o,this._refreshOverlay=r||o,this._clockData=[],this._selectedClockIdx=0,this._selectedNodeId=-1,this._tx=0,this._ty=0,this._scale=1,this._layout=[],this._dragging=!1,this._dragStartX=0,this._dragStartY=0,this._dragStartTx=0,this._dragStartTy=0,this._build(e)}_build(e){let i=document.createElement("div");i.className="clock-tree-widget";let o=document.createElement("div");o.className="clock-tree-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",wt(this._app)&&(this._updateBtn.style.display="none"),this._fitBtn=document.createElement("button"),this._fitBtn.className="or-btn",this._fitBtn.textContent="Fit",this._pngBtn=document.createElement("button"),this._pngBtn.className="or-btn",this._pngBtn.textContent="PNG",this._pngBtn.title="Export the clock tree as a PNG image",this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",o.appendChild(this._updateBtn),o.appendChild(this._fitBtn),o.appendChild(this._pngBtn),o.appendChild(this._statusLabel),i.appendChild(o),this._tabBar=document.createElement("div"),this._tabBar.className="timing-tab-bar",i.appendChild(this._tabBar),this._canvas=document.createElement("canvas"),this._canvas.className="clock-tree-canvas",i.appendChild(this._canvas),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._tooltip.style.display="none",i.appendChild(this._tooltip),e.element.appendChild(i),this._el=i,this._ctx=this._canvas.getContext("2d"),this._bindEvents(),wt(this._app)&&setTimeout(()=>this.update(),0)}_fit(){this._sizeCanvas(),this._fitToView(),this._render()}_pngFileName(){let e=this._clockData[this._selectedClockIdx];return Xh(e&&e.name)}_exportPng(){try{yi(this._canvas.toDataURL("image/png"),this._pngFileName())}catch(e){console.error("PNG export failed:",e)}}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update()),this._fitBtn.addEventListener("click",()=>this._fit()),this._pngBtn.addEventListener("click",()=>this._exportPng()),this._canvas.addEventListener("keydown",e=>{e.key==="f"&&this._fit()}),this._canvas.tabIndex=0,this._canvas.addEventListener("wheel",e=>{e.preventDefault();let i=this._canvas.getBoundingClientRect(),o=e.clientX-i.left,r=e.clientY-i.top,l=e.deltaY<0?1.15:1/1.15;this._tx=o-(o-this._tx)*l,this._ty=r-(r-this._ty)*l,this._scale*=l,this._render()}),this._canvas.addEventListener("mousedown",e=>{this._dragging=!0,this._dragStartX=e.clientX,this._dragStartY=e.clientY,this._dragStartTx=this._tx,this._dragStartTy=this._ty,this._canvas.style.cursor="grabbing"}),window.addEventListener("mousemove",e=>{this._dragging?(this._tx=this._dragStartTx+(e.clientX-this._dragStartX),this._ty=this._dragStartTy+(e.clientY-this._dragStartY),this._render()):this._handleHover(e)}),window.addEventListener("mouseup",()=>{this._dragging&&(this._dragging=!1,this._canvas.style.cursor="grab")}),this._canvas.addEventListener("click",e=>this._handleClick(e)),this._resizeObserver=new ResizeObserver(()=>{this._sizeCanvas(),this._render()}),this._resizeObserver.observe(this._canvas)}_sizeCanvas(){let e=this._canvas.getBoundingClientRect(),i=window.devicePixelRatio||1;this._canvas.width=e.width*i,this._canvas.height=e.height*i,this._ctx.setTransform(i,0,0,i,0,0)}async update(){this._statusLabel.textContent="Loading...";try{let e=await this._app.websocketManager.request({type:"clock_tree"});this._clockData=e.clocks||[],this._buildTabs(),this._selectClock(0),this._statusLabel.textContent=this._clockData.length+" clock"+(this._clockData.length!==1?"s":"")}catch(e){console.error("Clock tree error:",e),this._statusLabel.textContent="Error: "+e.message}}_buildTabs(){this._tabBar.innerHTML="",this._clockData.forEach((e,i)=>{let o=document.createElement("button");o.className="timing-tab"+(i===this._selectedClockIdx?" active":""),o.textContent=e.name,o.addEventListener("click",()=>this._selectClock(i)),this._tabBar.appendChild(o)})}_selectClock(e){if(e<0||e>=this._clockData.length)return;this._selectedClockIdx=e,this._selectedNodeId=-1,this._tabBar.querySelectorAll(".timing-tab").forEach((o,r)=>{o.classList.toggle("active",r===e)}),this._computeLayout(this._clockData[e]),requestAnimationFrame(()=>{this._sizeCanvas(),this._fitToView(),this._render()})}_computeLayout(e){let i=Qh(e);this._layout=i.layout,this._layoutWidth=i.layoutWidth,this._layoutHeight=i.layoutHeight,this._timeMin=i.timeMin,this._timeMax=i.timeMax,this._timeUnit=i.timeUnit,this._sceneHeight=i.sceneHeight,this._layoutById=i.layoutById}_fitToView(){if(!this._layout.length)return;let e=this._canvas.getBoundingClientRect(),i=e.width,o=e.height,r=i/this._layoutWidth,l=o/this._layoutHeight;this._scale=Math.min(r,l)*.9,this._tx=(i-this._layoutWidth*this._scale)/2,this._ty=(o-this._layoutHeight*this._scale)/2}render(){this._render()}_render(){let e=this._ctx,i=this._canvas.getBoundingClientRect(),o=i.width,r=i.height,l=gi();if(e.clearRect(0,0,o,r),e.fillStyle=l.canvasBg,e.fillRect(0,0,o,r),!this._layout.length){e.fillStyle=l.canvasText,e.font="14px "+l.fontSans,e.textAlign="center";let h=wt(this._app)?"No clock tree data available":'Click "Update" to load clock tree data';e.fillText(h,o/2,r/2);return}e.save(),e.translate(this._tx,this._ty),e.scale(this._scale,this._scale),this._drawConnections(e);for(let h of this._layout)this._drawNode(e,h,h.id===this._selectedNodeId);e.restore(),this._drawTimeScale(e,o,r,l)}_drawConnections(e){let i=1.5/this._scale,o=Fo,r=this._timeMax-this._timeMin||1;for(let l of this._layout){if(l.parent_id<0)continue;let h=this._layoutById.get(l.parent_id);if(!h)continue;let u=h.x,f=l.x,_=(h.delay||0)/r*this._sceneHeight,y=h.y+_,g=l.y,v=h.type==="root"?h.y:h.y+o;if(y>v){let b=fs[h.type]||fs.unknown;e.strokeStyle=b,e.lineWidth=i,e.beginPath(),e.moveTo(u,v),e.lineTo(u,y);let C=o/20;e.moveTo(u-C,y),e.lineTo(u+C,y),e.stroke()}e.strokeStyle="#006400",e.lineWidth=i;let w=(y+g)/2;e.beginPath(),e.moveTo(u,y),e.bezierCurveTo(u,w,f,w,f,g),e.stroke()}}_drawNode(e,i,o){let r=i.x,l=i.y,h=Fo,u=fs[i.type]||fs.unknown;switch(e.fillStyle=Jh(u),e.strokeStyle=u,e.lineWidth=1/this._scale,i.type){case"root":{e.beginPath(),e.moveTo(r-h/2,l-h),e.lineTo(r+h/2,l-h),e.lineTo(r,l),e.closePath(),e.fill(),e.stroke();break}case"buffer":{e.beginPath(),e.moveTo(r-h/2,l),e.lineTo(r+h/2,l),e.lineTo(r,l+h),e.closePath(),e.fill(),e.stroke();break}case"inverter":{let f=h*.1,_=l+h-f;e.beginPath(),e.moveTo(r-h/2,l),e.lineTo(r+h/2,l),e.lineTo(r,_),e.closePath(),e.fill(),e.stroke(),e.beginPath(),e.arc(r,_+f/2,f/2,0,Math.PI*2),e.fill(),e.stroke();break}case"clock_gate":{e.beginPath(),e.arc(r,l+h/2,h/2,0,Math.PI*2),e.fill(),e.stroke();break}case"register":case"macro":{e.beginPath(),e.rect(r-h/2,l,h,h),e.fill(),e.stroke(),e.beginPath(),e.moveTo(r-h/8,l),e.lineTo(r+h/8,l),e.lineTo(r,l+h/4),e.closePath(),e.stroke();break}default:{e.beginPath(),e.arc(r,l+h/2,h/2,0,Math.PI*2),e.fill(),e.stroke();break}}if(o){e.strokeStyle="#ffff00",e.lineWidth=2/this._scale;let f=i.type==="root"?l-h/2:l+h/2;e.beginPath(),e.arc(r,f,h/2+3,0,Math.PI*2),e.stroke()}}_drawTimeScale(e,i,o,r){if(!this._sceneHeight)return;let l=C=>C*this._scale+this._ty,h=l(ms),u=l(ms+this._sceneHeight);if(u<0||h>o)return;e.save(),e.fillStyle=r.canvasLabel,e.strokeStyle=r.canvasAxis,e.font="11px "+r.fontMono,e.textAlign="right",e.textBaseline="middle";let f=this._timeMax-this._timeMin;if(f<=0){e.restore();return}let _=u-h,y=Math.max(2,Math.floor(_/40)),g=f/y,v=Math.pow(10,Math.floor(Math.log10(g))),w=v;g/v>5?w=10*v:g/v>2?w=5*v:g/v>1&&(w=2*v);let b=Math.ceil(this._timeMin/w)*w;e.beginPath();for(let C=b;C<=this._timeMax;C+=w){let R=(C-this._timeMin)/f,A=h+R*(u-h);e.moveTo(0,A),e.lineTo(i,A);let M=C.toFixed(w<.01?3:w<.1?2:1)+" "+this._timeUnit;e.fillText(M,Zo-4,A)}e.stroke(),e.restore()}_screenToLayout(e,i){return{x:(e-this._tx)/this._scale,y:(i-this._ty)/this._scale}}_hitTest(e,i){let o=this._screenToLayout(e,i),r=Fo;for(let l of this._layout){let h=l.type==="root"?l.y-r:l.y,u=l.type==="root"?l.y:l.y+r;if(o.x>=l.x-r/2&&o.x<=l.x+r/2&&o.y>=h&&o.y<=u)return l}return null}_handleClick(e){let i=this._canvas.getBoundingClientRect(),o=e.clientX-i.left,r=e.clientY-i.top,l=this._hitTest(o,r);l?(this._selectedNodeId=l.id,this._render(),this._app.websocketManager.request({type:"clock_tree_highlight",inst_name:l.name}).then(()=>this._refreshOverlay())):this._selectedNodeId>=0&&(this._selectedNodeId=-1,this._render(),this._app.websocketManager.request({type:"clock_tree_highlight",inst_name:""}).then(()=>this._refreshOverlay()))}_handleHover(e){let i=this._canvas.getBoundingClientRect(),o=e.clientX-i.left,r=e.clientY-i.top;if(o<0||r<0||o>i.width||r>i.height){this._tooltip.style.display="none";return}let l=this._hitTest(o,r);if(l){let h=[l.name,"Type: "+l.type,"Arrival: "+l.arrival.toFixed(3)+" "+(this._timeUnit||"")];l.delay&&h.push("Delay: "+l.delay.toFixed(3)+" "+(this._timeUnit||"")),l.fanout&&h.push("Fanout: "+l.fanout),this._tooltip.textContent=h.join(` -`),this._tooltip.style.display="block",this._tooltip.style.left=e.clientX+12+"px",this._tooltip.style.top=e.clientY+12+"px"}else this._tooltip.style.display="none"}};var ml=60,_l=20,gl=30,yl=50,fl=2,td="#f08080",ed="#8b0000",id="#90ee90",nd="#006400",Ue=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7"],sd="rgba(240,128,128,0.12)",od="rgba(144,238,144,0.12)",rd="#ff9999",ad="#b0ffb0",ld=[{value:"setup",label:"Setup Slack"},{value:"hold",label:"Hold Slack"},{value:"fanout",label:"Net Fanout"},{value:"netlength",label:"Net Length (HPWL)"}];function cd(s,e,i,o){if(!s||!e||oe.bottom)return null;for(let r of s)if(i>=r.x&&i<=r.x+r.width)return r;return null}function hd(s,e,i){return i?Math.log10(s+1)/Math.log10(e+1):s/e}function dd(s,e,i,o={}){let r=!!o.logY,l=s?.bins;if(!l||l.length===0)return{bars:[],yMax:0,yTicks:[],chartArea:null,logY:r};let h=ml,u=e-_l,f=gl,_=i-yl,y=u-h,g=_-f;if(y<=0||g<=0)return{bars:[],yMax:0,yTicks:[],chartArea:null,logY:r};let v={left:h,right:u,top:f,bottom:_},w=0;for(let M of l)M.count>w&&(w=M.count);w===0&&(w=1);let{yMax:b,yTicks:C}=r?pd(w):ud(w),R=(y-fl*(l.length-1))/l.length,A=[];for(let M=0;M[_.x,..._.ys||[]].join(","));return[u,...f].join(` -`)}let i=e.bins||[],o=Array.isArray(e.series)?e.series:[],r=["lower","upper","count",...o.map(h=>h.name||"group")].join(","),l=i.map((h,u)=>{let f=[h.lower,h.upper,h.count];for(let _ of o)f.push(_.counts&&_.counts[u]||0);return f.join(",")});return[r,...l].join(` -`)}var gs=class{constructor(e,i){this._app=e,this._redrawAllLayers=i,this._currentTab="setup",this._histogramData=null,this._bars=[],this._yMax=0,this._yTicks=[],this._chartArea=null,this._hoveredBar=null,this._debugCharts=[],this._activeDebugChart=-1,this._build()}_build(){let e=document.createElement("div");e.className="charts-widget";let i=document.createElement("div");i.className="charts-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",wt(this._app)&&(this._updateBtn.style.display="none"),this._chartSelect=document.createElement("select"),this._chartSelect.className="charts-select",this._csvBtn=document.createElement("button"),this._csvBtn.className="or-btn",this._csvBtn.textContent="CSV",this._csvBtn.title="Export the current chart data as CSV",this._pngBtn=document.createElement("button"),this._pngBtn.className="or-btn",this._pngBtn.textContent="PNG",this._pngBtn.title="Export the current chart as a PNG image",this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",i.appendChild(this._updateBtn),i.appendChild(this._chartSelect),i.appendChild(this._csvBtn),i.appendChild(this._pngBtn),i.appendChild(this._statusLabel),e.appendChild(i);let o=document.createElement("div");o.className="charts-toolbar";let r=document.createElement("span");r.textContent="Path Groups:",r.style.color="var(--fg-muted)",r.style.fontSize="var(--fs-12)",this._pathGroupSelect=document.createElement("select"),this._pathGroupSelect.className="charts-select",this._pathGroupSelect.multiple=!0,this._pathGroupSelect.size=1,this._pathGroupSelect.title="Select 0 = all, or \u22651 to stack by group";let l=document.createElement("span");l.textContent="Clock:",l.style.color="var(--fg-muted)",l.style.fontSize="var(--fs-12)",this._clockSelect=document.createElement("select"),this._clockSelect.className="charts-select",this._clockSelect.innerHTML='',o.appendChild(r),o.appendChild(this._pathGroupSelect),o.appendChild(l),o.appendChild(this._clockSelect),e.appendChild(o),this._canvas=document.createElement("canvas"),this._canvas.className="charts-canvas",e.appendChild(this._canvas),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._tooltip.style.display="none",e.appendChild(this._tooltip),this._filterRow=o,this.element=e,this._ctx=this._canvas.getContext("2d"),this._rebuildSelect(),this._bindEvents(),wt(this._app)&&setTimeout(()=>this.update(),0)}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update()),this._chartSelect.addEventListener("change",()=>this._onSelectChange()),this._csvBtn.addEventListener("click",()=>this._exportCsv()),this._pngBtn.addEventListener("click",()=>this._exportPng()),this._pathGroupSelect.addEventListener("change",()=>this._fetchHistogram()),this._clockSelect.addEventListener("change",()=>this._fetchHistogram()),this._canvas.addEventListener("mousemove",i=>this._handleHover(i)),this._canvas.addEventListener("mouseleave",()=>{this._hoveredBar=null,this._tooltip.style.display="none",this._syncView()}),this._canvas.addEventListener("click",i=>this._handleClick(i)),this._canvas.addEventListener("dblclick",i=>this._handleDblClick(i)),new ResizeObserver(()=>this._syncView()).observe(this._canvas)}_sizeCanvas(){let e=this._canvas.getBoundingClientRect(),i=window.devicePixelRatio||1;this._canvas.width=e.width*i,this._canvas.height=e.height*i,this._ctx.setTransform(i,0,0,i,0,0)}_rebuildSelect(){let e=this._chartSelect;e.innerHTML="";for(let i of ld){let o=document.createElement("option");o.value=i.value,o.textContent=i.label,e.appendChild(o)}this._debugCharts.forEach((i,o)=>{let r=document.createElement("option");r.value="gen:"+o,r.textContent=i.name||"Chart "+o,e.appendChild(r)}),e.value=this._activeDebugChart>=0?"gen:"+this._activeDebugChart:this._currentTab}_onSelectChange(){let e=this._chartSelect.value;e.startsWith("gen:")?(this._activeDebugChart=parseInt(e.slice(4),10)||0,this._hoveredBar=null,this._tooltip.style.display="none",this._syncView()):this._selectTab(e)}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...",this._statusLabel.textContent="";try{this._activeDebugChart<0?((this._currentTab==="setup"||this._currentTab==="hold")&&await this._fetchFilters(),await Promise.all([this._fetchHistogram(),this._fetchGenericCharts()])):await this._fetchGenericCharts()}catch(e){this._statusLabel.textContent="Error: "+e.message}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}async _fetchFilters(){let e=await this._app.websocketManager.request({type:"chart_filters"});this._populatePathGroups(e.path_groups||[]),this._populateClocks(e.clocks||[])}_populatePathGroups(e){let i=new Set(Array.from(this._pathGroupSelect.selectedOptions,o=>o.value));this._pathGroupSelect.innerHTML="";for(let o of e){let r=document.createElement("option");r.value=o,r.textContent=o,r.selected=i.has(o),this._pathGroupSelect.appendChild(r)}}_populateClocks(e){let i=this._clockSelect.value;this._clockSelect.innerHTML='';for(let o of e){let r=document.createElement("option");r.value=o,r.textContent=o,this._clockSelect.appendChild(r)}e.includes(i)&&(this._clockSelect.value=i)}async _fetchGenericCharts(){try{let e=await this._app.websocketManager.request({type:"debug_charts"});this.setDebugCharts(e.charts||[])}catch{}}async _fetchHistogram(){try{let e=this._currentTab,i;if(e==="fanout")i={type:"fanout_histogram"};else if(e==="netlength")i={type:"net_length_histogram",use_dbu:!!this._app.showDbu};else{i={type:"slack_histogram",is_setup:e==="setup"};let r=Array.from(this._pathGroupSelect.selectedOptions,l=>l.value).filter(Boolean);r.length>0&&(i.path_groups=r),this._clockSelect.value&&(i.clock_name=this._clockSelect.value)}let o=await this._app.websocketManager.request(i);if(this._currentTab!==e)return;if(this._histogramData=o,this._syncView(),e==="fanout"||e==="netlength"){let r=o.total_nets||0;this._statusLabel.textContent=`${r} nets`}else{let r=o.total_endpoints||0,l=o.unconstrained_count||0,h=r-l;this._statusLabel.textContent=`${h} endpoints`+(l>0?`, ${l} unconstrained`:"")}}catch(e){this._statusLabel.textContent="Error: "+e.message}}_selectTab(e){this._currentTab===e&&this._activeDebugChart<0||(this._currentTab=e,this._activeDebugChart=-1,this._chartSelect&&(this._chartSelect.value=e),this._filterRow.style.display=e==="setup"||e==="hold"?"":"none",this._hoveredBar=null,this._tooltip.style.display="none",this.update())}_computeLayout(){if(!this._histogramData)return;let e=this._canvas.getBoundingClientRect(),i=dd(this._histogramData,e.width,e.height,{logY:this._currentTab==="fanout"});this._bars=i.bars,this._yMax=i.yMax,this._yTicks=i.yTicks,this._chartArea=i.chartArea,this._logY=!!i.logY}render(){this._syncView()}_stackedSeries(){let e=this._histogramData?.series;return Array.isArray(e)&&e.length>1?e:null}_render(){let e=this._canvas.getBoundingClientRect(),i=e.width,o=e.height,r=this._ctx,l=gi();if(r.clearRect(0,0,i,o),r.fillStyle=l.canvasBg,r.fillRect(0,0,i,o),!this._bars||this._bars.length===0){r.fillStyle=l.canvasText,r.font="14px "+l.fontSans,r.textAlign="center",r.textBaseline="middle";let h=wt(this._app)?"No histogram data available":'Click "Update" to load histogram';r.fillText(h,i/2,o/2);return}this._drawAxes(r,l),this._drawBars(r),this._drawTitle(r,i,l),this._stackedSeries()&&this._drawSeriesLegend(r,l)}_drawAxes(e,i){let o=this._chartArea;if(!o)return;e.strokeStyle=i.canvasAxis,e.lineWidth=1,e.beginPath(),e.moveTo(o.left,o.top),e.lineTo(o.left,o.bottom),e.stroke(),e.beginPath(),e.moveTo(o.left,o.bottom),e.lineTo(o.right,o.bottom),e.stroke(),e.fillStyle=i.canvasLabel,e.font="11px "+i.fontMono,e.textAlign="right",e.textBaseline="middle";let r=o.bottom-o.top;for(let v of this._yTicks){let w=this._logY?Math.log10(v+1)/Math.log10(this._yMax+1):v/this._yMax,b=o.bottom-w*r;e.fillText(this._formatCount(v),o.left-6,b),v>0&&(e.strokeStyle=i.canvasGrid,e.beginPath(),e.moveTo(o.left,b),e.lineTo(o.right,b),e.stroke(),e.strokeStyle=i.canvasAxis)}let l=this._currentTab,h=l==="fanout"||l==="netlength";e.save(),e.translate(14,(o.top+o.bottom)/2),e.rotate(-Math.PI/2),e.textAlign="center",e.textBaseline="middle",e.fillStyle=i.canvasTitle,e.font="11px "+i.fontMono,e.fillText(this._logY?"Nets (log)":h?"Nets":"Endpoints",0,0),e.restore(),e.textAlign="center",e.textBaseline="top",e.fillStyle=i.canvasLabel,e.font="10px "+i.fontMono;let u=this._histogramData.bins,f=this._histogramData.time_unit||this._histogramData.length_unit||"",_=u.length>0?u[0].upper-u[0].lower:1,y=l==="fanout"?0:Math.max(0,-Math.floor(Math.log10(_)));for(let v=0;v<=this._bars.length;v++){let w=v=0){this._hoveredBar=null,this._tooltip.style.display="none";return}let i=this._hitTestBar(e);if(i!==this._hoveredBar&&(this._hoveredBar=i,this._render()),i){let o=this._currentTab,r=i.upper-i.lower;if(o==="fanout"){let v=i.upper-1,w=i.lower===v?`${i.lower}`:`[${i.lower}, ${v}]`;this._tooltip.textContent=`Nets: ${i.count} -Fanout: ${w}`}else if(o==="netlength"){let v=this._histogramData?.length_unit||"",w=Math.max(0,-Math.floor(Math.log10(r)));this._tooltip.textContent=`Nets: ${i.count} -Length: [${i.lower.toFixed(w)}, ${i.upper.toFixed(w)}) ${v}`}else{let v=this._histogramData?.time_unit||"",w=Math.max(0,-Math.floor(Math.log10(r)));this._tooltip.textContent=`Endpoints: ${i.count} -Slack: [${i.lower.toFixed(w)}, ${i.upper.toFixed(w)}) ${v}`}this._tooltip.style.display="block";let l=this.element.getBoundingClientRect(),h=this._tooltip.getBoundingClientRect(),u=4,f=e.clientX-l.left,_=e.clientY-l.top,y=f+12;y+h.width>l.width-u&&(y=f-12-h.width),y=Math.max(u,y);let g=_-10;g=Math.min(l.height-h.height-u,Math.max(u,g)),this._tooltip.style.left=y+"px",this._tooltip.style.top=g+"px"}else this._tooltip.style.display="none"}async _handleClick(e){if(this._activeDebugChart>=0||this._currentTab==="fanout"||this._currentTab==="netlength")return;let i=this._hitTestBar(e);if(!(!i||i.count===0))try{let o=await this._app.websocketManager.request({type:"timing_report",is_setup:this._currentTab==="setup",max_paths:50,slack_min:i.lower,slack_max:i.upper});this._app.timingWidget&&(this._app.timingWidget.showPaths(this._currentTab,o.paths||[]),this._app.focusComponent&&this._app.focusComponent("TimingWidget"))}catch(o){console.error("Charts bar click error:",o)}}async _handleDblClick(e){if(this._activeDebugChart>=0)return;let i;if(this._currentTab==="fanout")i="select_fanout_bin";else if(this._currentTab==="netlength")i="select_net_length_bin";else return;let o=this._hitTestBar(e);if(!o||o.count===0)return;let r=re(this._app);try{let l=await this._app.websocketManager.request({type:i,lower:o.lower,upper:o.upper,use_dbu:this._app.showDbu});if(!ce(this._app,r))return;l&&l.truncated&&console.warn(`Bin has ${l.count} nets; selection capped at ${l.selection_limit} for performance.`),this._app.updateInspector&&this._app.updateInspector(l),this._app.focusComponent&&this._app.focusComponent("Inspector"),this._redrawAllLayers&&this._redrawAllLayers()}catch(l){console.error("Net bin select failed:",l)}}_activeChartData(){return this._activeDebugChart>=0?{kind:"generic",data:this._debugCharts[this._activeDebugChart]}:{kind:"histogram",data:this._histogramData}}_chartBaseName(){return this._activeDebugChart>=0?this._debugCharts[this._activeDebugChart].name||"chart":this._currentTab}_triggerDownload(e,i,{revoke:o=!1}={}){let r=document.createElement("a");r.href=i,r.download=e,document.body.appendChild(r),r.click(),r.remove(),o&&URL.revokeObjectURL(i)}_download(e,i,o){try{let r=URL.createObjectURL(new Blob([o],{type:i}));this._triggerDownload(e,r,{revoke:!0})}catch(r){console.error("Download failed:",r)}}_exportCsv(){let{kind:e,data:i}=this._activeChartData();if(!i)return;let o=fd(e,i);this._download(this._chartBaseName()+".csv","text/csv",o)}_exportPng(){try{let e=this._canvas.toDataURL("image/png");this._triggerDownload(this._chartBaseName()+".png",e)}catch(e){console.error("PNG export failed:",e)}}setDebugCharts(e){this._debugCharts=e,e.length===0?this._activeDebugChart=-1:this._activeDebugChart>=e.length&&(this._activeDebugChart=0),this._rebuildSelect(),this._syncView()}_syncView(){let e=this._activeDebugChart>=0;e&&(this._hoveredBar=null,this._tooltip.style.display="none");let i=!e&&(this._currentTab==="setup"||this._currentTab==="hold");this._filterRow&&(this._filterRow.style.display=i?"":"none"),this._sizeCanvas(),e?this._renderLineChart(this._debugCharts[this._activeDebugChart]):(this._computeLayout(),this._render())}_renderLineChart(e){let i=this._canvas.getBoundingClientRect(),o=i.width,r=i.height,l=this._ctx,h=gi();l.clearRect(0,0,o,r),l.fillStyle=h.canvasBg,l.fillRect(0,0,o,r);let u=e.points;if(!u||u.length===0){l.fillStyle=h.canvasText,l.font="14px "+h.fontSans,l.textAlign="center",l.textBaseline="middle",l.fillText("No data points yet",o/2,r/2);return}let f=e.y_labels?e.y_labels.length:1,_=ml,y=o-_l,g=gl,v=r-yl,w=y-_,b=v-g;if(w<=0||b<=0)return;let C=u[0].x,R=u[0].x,A=1/0,M=-1/0;for(let it of u){it.xR&&(R=it.x);for(let Q of it.ys)QM&&(M=Q)}C===R&&(R=C+1),(!isFinite(A)||!isFinite(M))&&(A=0,M=1);let q=(M-A)*.05||1;A-=q,M+=q;let G=it=>_+(it-C)/(R-C)*w,dt=it=>v-(it-A)/(M-A)*b;l.strokeStyle=h.canvasAxis,l.lineWidth=1,l.beginPath(),l.moveTo(_,g),l.lineTo(_,v),l.lineTo(y,v),l.stroke(),l.fillStyle=h.canvasLabel,l.font="10px "+h.fontMono,l.textAlign="right",l.textBaseline="middle";let gt=5;for(let it=0;it<=gt;it++){let Q=A+(M-A)*it/gt,nt=dt(Q);l.fillText(this._formatNum(Q),_-4,nt),it>0&&it1&&e.y_labels){l.font="10px "+h.fontMono,l.textAlign="left",l.textBaseline="top";let it=_+8,Q=g+4;for(let nt=0;nt=1e6?(e/1e6).toFixed(1)+"M":i>=1e3?(e/1e3).toFixed(1)+"k":i>=1?e.toFixed(1):e.toPrecision(3)}_formatCount(e){return e===0?"0":e>=1e6?e/1e6+"M":e>=1e3?e/1e3+"k":String(e)}};var we=class{constructor(e){this.onChange=e,this.roots=[],this._nodeMap=new Map}addFromSpec(e,i=null){let o=this._makeNode(e.id,i,e);if(o.checked=e.checked!==!1,e.children){for(let r of e.children)o.children.push(this.addFromSpec(r,o));o.hasCheckbox&&this._computeParent(o)}return i||this.roots.push(o),o}buildFromNodes(e){this._nodeMap.clear(),this.roots=[];for(let i of e)this._makeNode(i.id,null,i);for(let i of e){let o=this._nodeMap.get(i.id);if(i.parentId!=null&&this._nodeMap.has(i.parentId)){let r=this._nodeMap.get(i.parentId);o.parent=r,r.children.push(o)}else this.roots.push(o)}for(let i=e.length-1;i>=0;i--){let o=this._nodeMap.get(e[i].id);o.hasCheckbox&&o.children.length>0&&this._computeParent(o)}return this.roots}get(e){return this._nodeMap.get(e)}isVisible(e){let i=this.get(e);return i?i.checked:!1}check(e,i){let o=this._nodeMap.get(e);if(o){o.checked=i,o.indeterminate=!1;for(let r of o.children)this._setSubtree(r,i);for(let r=o.parent;r;r=r.parent)r.hasCheckbox&&this._computeParent(r);this.onChange()}}cascadeQuiet(e,i){let o=this._nodeMap.get(e);if(o){o.checked=i,o.indeterminate=!1;for(let r of o.children)this._setSubtree(r,i);for(let r=o.parent;r;r=r.parent)r.hasCheckbox&&this._computeParent(r)}}checkSet(e){for(let[i,o]of Object.entries(e)){let r=this._nodeMap.get(i);r&&(r.checked=o,r.indeterminate=!1)}this._recomputeAllParents(),this.onChange()}mirrorStates(e){this._applyMirror(e),this.onChange()}mirrorStatesQuiet(e){this._applyMirror(e)}_applyMirror(e){for(let[i,o]of Object.entries(e)){let r=this._nodeMap.get(i);r&&(r.checked=!!o.checked,r.indeterminate=!!o.indeterminate)}}forEach(e){let i=o=>{e(o);for(let r of o.children)i(r)};for(let o of this.roots)i(o)}_makeNode(e,i,o){let r={id:e,parent:i,children:[],hasCheckbox:o.hasCheckbox!==!1,checked:o.checked!==!1,indeterminate:!1,data:o.data!=null?o.data:o};return this._nodeMap.set(e,r),r}_checkboxDescendants(e){let i=[];for(let o of e.children)o.hasCheckbox?i.push(o):i.push(...this._checkboxDescendants(o));return i}_computeParent(e){let i=this._checkboxDescendants(e);if(i.length===0)return;let o=i.every(l=>l.checked&&!l.indeterminate),r=i.every(l=>!l.checked&&!l.indeterminate);e.checked=o,e.indeterminate=!o&&!r}_setSubtree(e,i){e.hasCheckbox&&(e.checked=i,e.indeterminate=!1);for(let o of e.children)this._setSubtree(o,i)}_recomputeAllParents(){let e=i=>{for(let o of i.children)e(o);i.hasCheckbox&&i.children.length>0&&this._computeParent(i)};for(let i of this.roots)e(i)}};var vl=["Instance","Module","Instances","Macros","Modules","Area","Local Inst","Local Macros","Local Modules"],Ge={MODULE:0,LEAF_GROUP:1,TYPE_GROUP:2,INSTANCE:3,NAME_GROUP:4};function vi(s){return s===Ge.MODULE||s===Ge.NAME_GROUP}var ys=class{constructor(e,i,o){this._app=i,this._redrawAllLayers=o,this._nodes=[],this._nameGrouped=!1,this._nameGroupsCapped=!1,this._rows=[],this._childrenMap=new Map,this._collapsed=new Set,this._moduleState=new Map,this._checkModel=null,this._build(e),i.hierarchyBrowser=this,wt(i)&&this.update()}_build(e){let i=document.createElement("div");i.className="hierarchy-widget";let o=document.createElement("div");o.className="timing-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",wt(this._app)&&(this._updateBtn.style.display="none"),this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",o.appendChild(this._updateBtn),o.appendChild(this._statusLabel),i.appendChild(o),this._tableContainer=document.createElement("div"),this._tableContainer.className="hierarchy-table-container",this._table=document.createElement("table"),this._table.className="timing-table",this._tableContainer.appendChild(this._table),i.appendChild(this._tableContainer),e.element.appendChild(i),this._bindEvents()}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update())}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...",this._statusLabel.textContent="";try{let e=await this._app.websocketManager.request({type:"module_hierarchy"});this._nodes=e.nodes||[],this._nameGrouped=!!e.name_grouped,this._nameGroupsCapped=!!e.name_groups_capped,this._buildTree(),this._readServerColors(),this._computeEffectiveColors(),this._render(),this._statusLabel.textContent=this._statusText(),await this._sendModuleColors()}catch(e){this._statusLabel.textContent="Error: "+e.message}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}_statusText(){let e=this._nodes.filter(r=>vi(r.node_kind||0)).length;if(!this._nameGrouped)return e+" modules";let o=Math.max(0,e-1)+" groups from instance names \u2014 this design has no module hierarchy";return this._nameGroupsCapped&&(o+=" (truncated: too many groups)"),o}_buildTree(){this._childrenMap.clear(),this._collapsed.clear();for(let i of this._nodes)this._childrenMap.set(i.id,[]);for(let i of this._nodes)i.parent_id>=0&&this._childrenMap.has(i.parent_id)&&this._childrenMap.get(i.parent_id).push(i.id);this._nodeMap=new Map;for(let i of this._nodes)this._nodeMap.set(i.id,i);for(let i of this._nodes){let o=this._childrenMap.get(i.id);if(!o||o.length===0)continue;let r=i.node_kind||0;r===Ge.LEAF_GROUP||r===Ge.TYPE_GROUP?this._collapsed.add(i.id):vi(r)&&i.parent_id>=0&&this._collapsed.add(i.id)}this._rows=[];let e=this._nodes.filter(i=>i.parent_id<0);for(let i of e)this._dfs(i.id,0);this._checkModel=new we(()=>{this._checkModel.forEach(i=>{if(!i.hasCheckbox)return;let o=this._moduleState.get(i.data.odb_id);o&&(o.visible=i.checked)}),this._sendModuleColors()}),this._checkModel.buildFromNodes(this._nodes.map(i=>({id:i.id,parentId:i.parent_id,hasCheckbox:vi(i.node_kind||0)&&i.odb_id!=null,checked:!0,data:i})))}_readServerColors(){this._moduleState.clear();for(let e of this._rows){let i=this._nodeMap.get(e.id);if(!i||!vi(i.node_kind||0)||i.odb_id==null)continue;let o=i.color||[128,128,128];this._moduleState.set(i.odb_id,{color:o,effectiveColor:o,visible:!0,nodeId:i.id})}}_computeEffectiveColors(){for(let e of this._rows){let i=this._nodeMap.get(e.id);if(!i||!vi(i.node_kind||0))continue;let o=this._moduleState.get(i.odb_id);if(!o)continue;let r=i.parent_id,l=null;for(;r>=0;){let h=this._nodeMap.get(r);if(!h)break;if(vi(h.node_kind||0)){let u=this._moduleState.get(h.odb_id);u&&this._collapsed.has(h.id)&&(l=u.effectiveColor)}r=h.parent_id}o.effectiveColor=l||o.color}}async _sendModuleColors(){let e=[];for(let[o,r]of this._moduleState){if(!r.visible)continue;let[l,h,u]=r.effectiveColor;e.push(`${o}:${l},${h},${u},100`)}let i=e.join(";");try{let o=await this._app.websocketManager.request({type:"set_module_colors",colors:i});console.log("set_module_colors:",o.count,"modules,",e.length,"sent")}catch(o){console.error("set_module_colors failed:",o)}this._redrawAllLayers()}_dfs(e,i){this._rows.push({id:e,depth:i});let o=this._childrenMap.get(e)||[];for(let r of o)this._dfs(r,i+1)}_render(){this._table.innerHTML="";let e=document.createElement("thead"),i=document.createElement("tr");for(let r of vl){let l=document.createElement("th");l.textContent=r,i.appendChild(l)}e.appendChild(i),this._table.appendChild(e);let o=document.createElement("tbody");for(let r of this._rows){let l=this._nodeMap.get(r.id);if(!l||this._isHidden(l))continue;let h=document.createElement("tr"),u=l.node_kind||0,_=(this._childrenMap.get(r.id)||[]).length>0,y=this._collapsed.has(r.id);u===Ge.LEAF_GROUP||u===Ge.TYPE_GROUP?(h.style.fontStyle="italic",h.style.color="var(--fg-disabled)"):u===Ge.INSTANCE?h.style.color="var(--fg-secondary)":u===Ge.NAME_GROUP&&(h.classList.add("hierarchy-name-group"),h.title="Recovered from instance names \u2014 this design has no module hierarchy");let g=document.createElement("td");if(g.style.paddingLeft=8+r.depth*16+"px",g.style.whiteSpace="nowrap",vi(u)&&l.odb_id!=null){let b=this._moduleState.get(l.odb_id),C=this._checkModel?this._checkModel.get(l.id):null;if(b&&C){let R=document.createElement("input");R.type="checkbox",R.checked=C.checked,R.indeterminate=C.indeterminate,R.className="hierarchy-module-cb",C.cb=R,R.addEventListener("change",dt=>{dt.stopPropagation(),this._checkModel.check(l.id,R.checked),this._render()}),g.appendChild(R);let A=document.createElement("span");A.className="hierarchy-color-swatch";let[M,q,G]=b.effectiveColor;A.style.backgroundColor=`rgb(${M},${q},${G})`,g.appendChild(A)}}if(_){let b=document.createElement("span");b.className="hierarchy-arrow",b.textContent=y?"\u25B6":"\u25BC",b.addEventListener("click",C=>{C.stopPropagation(),this._toggleNode(r.id)}),g.appendChild(b)}else{let b=document.createElement("span");b.className="hierarchy-arrow",b.style.visibility="hidden",b.textContent="\u25B6",g.appendChild(b)}let v=document.createElement("span");v.textContent=l.inst_name,g.appendChild(v),h.appendChild(g);let w=[l.module_name,qi(l.insts),qi(l.macros),qi(l.modules),this._fmtArea(l.area),qi(l.local_insts),qi(l.local_macros),qi(l.local_modules)];for(let b of w){let C=document.createElement("td");C.textContent=b,C.style.textAlign="right",h.appendChild(C)}h.children[1].style.textAlign="left",o.appendChild(h)}if(this._rows.length===0){let r=document.createElement("tr"),l=document.createElement("td");l.colSpan=vl.length,l.style.textAlign="center",l.style.color="var(--fg-secondary)",l.textContent=wt(this._app)?"No hierarchy data available":'Click "Update" to load hierarchy',r.appendChild(l),o.appendChild(r)}this._table.appendChild(o),fi(this._table)}_isHidden(e){let i=e.parent_id;for(;i>=0;){if(this._collapsed.has(i))return!0;let o=this._nodeMap.get(i);if(!o)break;i=o.parent_id}return!1}_toggleNode(e){this._collapsed.has(e)?this._collapsed.delete(e):this._collapsed.add(e),this._computeEffectiveColors(),this._render(),this._sendModuleColors()}_fmtArea(e){if(e==null)return"";if(this._app.showDbu){let i=this._app.getDbuPerMicron();return String(Math.round(e*i*i))}return e>=1e6?(e/1e6).toFixed(3)+" mm\xB2":e.toFixed(3)+" \u03BCm\xB2"}};function qi(s){return s!=null?String(s):""}var md='',_d='',gd='',yd='',vd='',bd='',wd='',xd='',Cd='',Ld='',kd='',Sd='';function bl(s,e,i){i=i||e;let o=null,r=null,l=null,h=!1,u=10;function f(k,H){return h?Promise.resolve():(h=!0,s.websocketManager.request({type:"set_property",name:k,use_dbu:s.showDbu,...H}).then(N=>{!N.ok&&N.error&&be(N.error),Ft(N),N.ok&&N.bbox&&Et(N.bbox)}).catch(N=>{console.error("set_property failed:",N),be("Edit failed: "+N),o&&Ft(o)}).finally(()=>{h=!1}))}function _(k,H){let N=document.createElement("select");N.className="inspector-editor-select";let Y=k.editor.type==="bool"?["True","False"]:k.editor.options||[];for(let P of Y){let J=document.createElement("option");J.value=P,J.textContent=P,P===k.value&&(J.selected=!0),N.appendChild(J)}if(!Y.includes(k.value)){let P=document.createElement("option");P.value=k.value||"",P.textContent=k.value||"",P.selected=!0,P.disabled=!0,N.insertBefore(P,N.firstChild)}return N.addEventListener("change",()=>{if(H.onPropertyChange){H.onPropertyChange(k.name,N.value);return}if(k.editor.type==="bool")H.onPropertyEdit(k,{value:N.value==="True"});else{let P=(k.editor.options||[]).indexOf(N.value);H.onPropertyEdit(k,{option_index:P,option_name:N.value})}}),N}async function y(k,H){if(!h&&!(k==="Delete"&&!await Ya({title:"Delete "+(H.type||"object"),message:"Delete "+(H.type||"object")+' "'+(H.name||"")+'"? This cannot be undone.',confirmLabel:"Delete",danger:!0}))){h=!0;try{let N=await s.websocketManager.request({type:"trigger_action",name:k,use_dbu:s.showDbu});!N.ok&&N.error&&be(N.error),Ft(N.properties?N:null),N.deleted&&s.highlightRect&&s.map&&(s.map.removeLayer(s.highlightRect),s.highlightRect=null),M(),i()}catch(N){console.error("trigger_action failed:",N),be("Action failed: "+N)}finally{h=!1}}}function g(k){s.websocketManager.request({...k,use_dbu:s.showDbu}).then(H=>{!H.ok&&H.error&&be(H.error),Ft(H),i()}).catch(H=>{console.error(k.type+" failed:",H)})}function v(){let k=document.getElementById("highlight-picker");k&&k.remove()}function w(k,H){v();let N=s.techData?.highlight_colors||[];if(!N.length)return;let Y=document.createElement("div");Y.id="highlight-picker";let P=document.createElement("div");if(P.className="highlight-swatch-grid",N.forEach((O,ct)=>{let kt=document.createElement("button");kt.className="highlight-swatch",kt.title="Group "+(ct+1),kt.style.backgroundColor=`rgb(${O[0]}, ${O[1]}, ${O[2]})`,ct===H.highlight_group&&kt.classList.add("active"),kt.addEventListener("click",()=>{v(),g({type:"highlight",group:ct})}),P.appendChild(kt)}),Y.appendChild(P),H.highlight_group>=0){let O=document.createElement("button");O.className="highlight-remove",O.textContent="Remove highlight",O.addEventListener("click",()=>{v(),g({type:"unhighlight"})}),Y.appendChild(O)}document.body.appendChild(Y);let J=k.getBoundingClientRect();Y.style.left=J.left+"px",Y.style.top=J.bottom+4+"px";let I=O=>{O.type==="keydown"&&O.key!=="Escape"||O.type==="mousedown"&&Y.contains(O.target)||(v(),document.removeEventListener("mousedown",I,!0),document.removeEventListener("keydown",I,!0))};setTimeout(()=>{document.addEventListener("mousedown",I,!0),document.addEventListener("keydown",I,!0)},0)}function b(){if(!s.inspectorEl)return;s.inspectorEl.innerHTML="";let k=document.createElement("div");k.className="stub-panel",k.innerHTML='
Loading\u2026
Fetching properties from server.
',s.inspectorEl.appendChild(k)}async function C(k){let H=s.focusNets.has(k)?"remove":"add";H==="add"?s.focusNets.add(k):s.focusNets.delete(k);try{await s.websocketManager.request({type:"set_focus_nets",action:H,net_name:k})}catch(N){console.error("set_focus_nets failed:",N)}e(),o&&Ft(o)}async function R(){s.focusNets.clear();try{await s.websocketManager.request({type:"set_focus_nets",action:"clear",net_name:""})}catch(k){console.error("set_focus_nets clear failed:",k)}e(),o&&Ft(o)}async function A(k){let H=s.routeGuideNets.has(k)?"remove":"add";H==="add"?s.routeGuideNets.add(k):s.routeGuideNets.delete(k);try{await s.websocketManager.request({type:"set_route_guides",action:H,net_name:k})}catch(N){console.error("set_route_guides failed:",N)}i(),o&&Ft(o)}function M(){s.hoverHighlightLayer&&(s.map.removeLayer(s.hoverHighlightLayer),s.hoverHighlightLayer=null)}function q(){M(),s.websocketManager.request({type:"hover",select_id:-1}).then(()=>{}).catch(()=>{})}function G(k,H,N,Y){let P=L.latLngBounds(Gt(k,H,N,Y,s.designScale,s.designMaxDXDY,s.designOriginX,s.designOriginY));if(!s.map)return P;let J=P.getSouthWest(),I=P.getNorthEast(),O=s.map.latLngToContainerPoint(J),ct=s.map.latLngToContainerPoint(I),kt=Math.min(O.x,ct.x),Xt=Math.max(O.x,ct.x),Ot=Math.min(O.y,ct.y),jt=Math.max(O.y,ct.y),xe=kt,Fe=Xt,Bt=Ot,Ke=jt;if(Xt-ktL.rectangle(G(H,N,Y,P),{color:"#ffe85c",weight:3,fill:!0,fillColor:"#fff27a",fillOpacity:.14,opacity:1,interactive:!1,className:"hover-highlight",pane:s.hoverHighlightPane}))).addTo(s.map))}function gt(k,H){k.classList.add("inspector-link"),k.addEventListener("click",N=>{N.stopPropagation(),Q(H)}),k.addEventListener("mouseenter",()=>{l!==null&&(s.websocketManager.cancel(l),l=null);let N=s.websocketManager.request({type:"hover",select_id:H});l=N.requestId,N.then(Y=>{l=null,dt(Y.rects||[]),i()}).catch(()=>{l=null})}),k.addEventListener("mouseleave",()=>{q(),i()})}function it(k){let H=k>0?"select_next":"select_prev";r!==null&&(s.websocketManager.cancel(r),r=null),b();let N=re(s),Y=s.websocketManager.request({type:H,use_dbu:s.showDbu});r=Y.requestId,Y.then(P=>{if(r=null,!!ce(s,N)){if(P.error){console.error("Selection cycle error:",P.error),Ft(o);return}if(Ft(P),P.type==="Inst"&&P.name&&(s.selectedInstanceName=P.name,s.schematicWidget&&s.schematicWidget.refresh()),s.map&&s.map.closePopup(),M(),s.highlightRect&&s.map&&(s.map.removeLayer(s.highlightRect),s.highlightRect=null),P.bbox&&s.map&&s.designScale){let[J,I,O,ct]=P.bbox;P.type!=="Inst"&&tt(J,I,O,ct,P.type),P.selection_count>1?rt(P.bbox):Et(P.bbox,P.type)}e()}}).catch(P=>{r=null,console.error("Selection cycle failed:",P),Ft(o)})}function Q(k){r!==null&&(s.websocketManager.cancel(r),r=null),b();let H=re(s),N=s.websocketManager.request({type:"inspect",select_id:k,use_dbu:s.showDbu});r=N.requestId,N.then(Y=>{if(r=null,!!ce(s,H)){if(Y.error){console.error("Inspect error:",Y.error);return}if(Ft(Y),s.map.closePopup(),M(),s.highlightRect&&(s.map.removeLayer(s.highlightRect),s.highlightRect=null),Y.bbox&&s.map&&s.designScale){let[P,J,I,O]=Y.bbox;Y.type!=="Inst"&&tt(P,J,I,O,Y.type),Et(Y.bbox,Y.type)}i()}}).catch(Y=>{r=null,console.error("Inspect failed:",Y)})}function nt(){r!==null&&(s.websocketManager.cancel(r),r=null),b();let k=re(s),H=s.websocketManager.request({type:"inspect_back",use_dbu:s.showDbu});r=H.requestId,H.then(N=>{if(r=null,!!ce(s,k)){if(N.error){console.error("Inspect back error:",N.error);return}if(Ft(N),s.map.closePopup(),M(),s.highlightRect&&(s.map.removeLayer(s.highlightRect),s.highlightRect=null),N.bbox&&s.map&&s.designScale){if(N.type!=="Inst"){let[Y,P,J,I]=N.bbox;tt(Y,P,J,I,N.type)}Et(N.bbox,N.type)}i()}}).catch(N=>{r=null,console.error("Inspect back failed:",N)})}function tt(k,H,N,Y,P){if(s.highlightRect&&(s.map.removeLayer(s.highlightRect),s.highlightRect=null),P==="Net")return;let J=Gt(k,H,N,Y,s.designScale,s.designMaxDXDY,s.designOriginX,s.designOriginY);s.highlightRect=L.rectangle(J,{color:"#ff0",weight:2,fill:!1,dashArray:"6,4"}),s.visibility&&s.visibility.highlight_selected===!1||s.highlightRect.addTo(s.map)}let Ct=null;function Et(k,H){if(!k||!s.map||!s.designScale||(It!==null&&Yt(),Ct&&(s.map.removeLayer(Ct),Ct=null),s.visibility&&s.visibility.highlight_selected===!1)||H==="Net")return;let[N,Y,P,J]=k,I=Gt(N,Y,P,J,s.designScale,s.designMaxDXDY,s.designOriginX,s.designOriginY);Ct=L.rectangle(I,{color:"#ff0",weight:3,fill:!0,fillColor:"#ff0",fillOpacity:.25,opacity:1,interactive:!1,className:"selection-pulse",pane:s.hoverHighlightPane}).addTo(s.map);let O=Ct;setTimeout(()=>{O&&s.map&&s.map.hasLayer(O)&&s.map.removeLayer(O),Ct===O&&(Ct=null)},1100)}let At=null,It=null;function Yt(){It!==null&&(clearInterval(It),It=null),At&&(s.map&&s.map.hasLayer(At)&&s.map.removeLayer(At),At=null)}function rt(k,{repeats:H=6,intervalMs:N=300}={}){if(!k||!s.map||!s.designScale)return;if(Yt(),typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches){Et(k);return}let[Y,P,J,I]=k,O=Gt(Y,P,J,I,s.designScale,s.designMaxDXDY,s.designOriginX,s.designOriginY);At=L.rectangle(O,{color:"#ff0",weight:1,fill:!0,fillColor:"#ff0",fillOpacity:.39,opacity:1,interactive:!1,pane:s.hoverHighlightPane}).addTo(s.map);let ct=0,kt=H>0?H*3:1/0;It=setInterval(()=>{if(ct+=1,ct>=kt){Yt();return}let Xt=ct%3+1;At.setStyle({weight:Xt,fillOpacity:Xt===1?.39:0})},N)}s.clearSelectionPulse=function(){Ct&&(s.map.removeLayer(Ct),Ct=null)};function me(k,H,N){let Y=document.createElement("div");Y.className="inspector-group";let P=document.createElement("div");P.className="inspector-group-header";let J=document.createElement("span");J.className="vis-arrow";let I=document.createElement("span");if(I.className="inspector-prop-name",I.textContent=k,I.title=k,P.appendChild(J),P.appendChild(I),H!==null){let ct=document.createElement("span");ct.className="inspector-count",ct.textContent=`(${H})`,P.appendChild(ct)}Y.appendChild(P);let O=document.createElement("div");return O.className="inspector-group-children"+(N?" collapsed":""),J.textContent=N?"\u25B6":"\u25BC",Y.appendChild(O),P.addEventListener("click",()=>{O.classList.toggle("collapsed"),J.textContent=O.classList.contains("collapsed")?"\u25B6":"\u25BC"}),{group:Y,header:P,arrow:J,body:O}}function at(k){let H=k.column_headers||[],N=k.row_headers||[],Y=k.data||[],P=H.some(ct=>ct!==""),J=N.some(ct=>ct!==""),I=document.createElement("table");if(I.className="inspector-table",P){let ct=document.createElement("thead"),kt=document.createElement("tr");J&&kt.appendChild(document.createElement("th"));for(let Xt of H){let Ot=document.createElement("th");Ot.textContent=Xt,kt.appendChild(Ot)}ct.appendChild(kt),I.appendChild(ct)}let O=document.createElement("tbody");return Y.forEach((ct,kt)=>{let Xt=document.createElement("tr");if(J){let Ot=document.createElement("th");Ot.textContent=N[kt]||"",Xt.appendChild(Ot)}for(let Ot of ct){let jt=document.createElement("td");jt.textContent=Ot,Xt.appendChild(jt)}O.appendChild(Xt)}),I.appendChild(O),I}function Lt(k,H){if(k.table){let I=(k.table.data||[]).length,{group:O,body:ct}=me(k.name,I,I>=10),kt=document.createElement("div");return kt.className="inspector-table-scroll",kt.appendChild(at(k.table)),ct.appendChild(kt),O}if(k.children){let I=k.children.length<10,{group:O,body:ct}=me(k.name,k.children.length,!I);for(let kt of k.children)ct.appendChild(Lt(kt,H));return O}let N=document.createElement("div");N.className="inspector-prop";let Y=document.createElement("span");Y.className="inspector-prop-name",Y.textContent=k.name||"",Y.title=k.name||"";let P=document.createElement("span");P.className="inspector-prop-value",P.textContent=k.value||"",N.appendChild(Y),N.appendChild(P);let J=k.editable&&H&&(H.onPropertyEdit||H.onPropertyChange)&&k.editor&&(k.editor.type==="list"||k.editor.type==="bool");if(J&&k.value_select_id===void 0)N.replaceChild(_(k,H),P);else if(J){let I=document.createElement("button");I.className="inspector-edit-btn",I.title="Edit "+k.name,I.textContent="\u270E",I.addEventListener("click",O=>{O.stopPropagation();let ct=_(k,H);N.replaceChild(ct,P),I.remove(),ct.focus()}),N.appendChild(I)}else k.editable&&H&&(H.onPropertyChange||H.onPropertyEdit)&&(P.contentEditable=!0,P.classList.add("inspector-editable"),P.addEventListener("blur",()=>{let I=P.textContent;if(I!==k.value){if(H.onPropertyChange){H.onPropertyChange(k.name,I);return}if(k.editor&&k.editor.type==="number"){let O=Number(I);if(I.trim()===""||Number.isNaN(O)){be("Not a number: "+I),P.textContent=k.value;return}H.onPropertyEdit(k,{value:O});return}H.onPropertyEdit(k,{value:I})}}),P.addEventListener("keydown",I=>{I.key==="Enter"&&(I.preventDefault(),P.blur()),I.key==="Escape"&&(P.textContent=k.value,P.blur())}));return k.name_select_id!==void 0&&k.value_select_id===void 0?(gt(N,k.name_select_id),Y.classList.add("inspector-link")):k.name_select_id!==void 0&>(Y,k.name_select_id),k.value_select_id!==void 0&>(P,k.value_select_id),N}let zt=140,Wt=60,Pt=500,yt=zt;function ft(){s.inspectorEl&&s.inspectorEl.style.setProperty("--inspector-name-w",yt+"px")}function ae(){let k=document.createElement("div");return k.className="inspector-col-resizer",k.title="Drag to resize the name column",k.addEventListener("mousedown",H=>{H.preventDefault();let N=H.clientX,Y=yt;k.classList.add("dragging");let P=I=>{yt=Math.max(Wt,Math.min(Pt,Y+I.clientX-N)),ft()},J=()=>{k.classList.remove("dragging"),document.removeEventListener("mousemove",P),document.removeEventListener("mouseup",J)};document.addEventListener("mousemove",P),document.addEventListener("mouseup",J)}),k}function ie(k){if(!k||!s.map||!s.designScale)return;let[H,N,Y,P]=k;s.map.fitBounds(Gt(H,N,Y,P,s.designScale,s.designMaxDXDY,s.designOriginX,s.designOriginY),{padding:[20,20]})}function Ft(k){if(!s.inspectorEl)return;if(o=k,s.inspectorEl.innerHTML="",!k||!k.properties||k.properties.length===0){Yt();let P=document.createElement("div");P.className="stub-panel",P.innerHTML='
Inspector
Select an object in the layout to inspect its properties.
',s.inspectorEl.appendChild(P);return}if(!k.onPropertyChange&&!k.onPropertyEdit&&!wt(s)&&(k.onPropertyEdit=(P,J)=>f(P.name,J)),k){let P=document.createElement("div");P.className="inspector-toolbar";let J=document.createElement("button");if(J.className="or-btn or-btn-icon",J.title="Back",J.innerHTML=yd,J.disabled=!k.can_navigate_back,J.addEventListener("click",()=>nt()),P.appendChild(J),k.bbox){let I=document.createElement("button");I.className="or-btn or-btn-icon",I.title="Zoom to",I.innerHTML=gd,I.addEventListener("click",()=>ie(k.bbox)),P.appendChild(I)}if(k.type==="Net"&&k.name){let I=s.focusNets.has(k.name),O=document.createElement("button");O.className="or-btn or-btn-icon",O.title=I?"De-focus net":"Focus net",O.innerHTML=I?bd:vd,O.addEventListener("click",()=>C(k.name)),P.appendChild(O)}if(k.type==="Net"&&k.name&&k.has_guides){let I=s.routeGuideNets.has(k.name),O=document.createElement("button");O.className="or-btn or-btn-icon",O.title=I?"Hide route guides":"Show route guides",O.innerHTML=I?xd:wd,O.addEventListener("click",()=>A(k.name)),P.appendChild(O)}if(k.type==="Net"&&k.name&&s.showInsertBufferDialog){let I=document.createElement("button");I.className="or-btn or-btn-icon",I.title="Insert buffer",I.innerHTML=Sd,I.addEventListener("click",()=>s.showInsertBufferDialog(k.name)),P.appendChild(I)}if(s.focusNets.size>0){let I=document.createElement("button");I.className="or-btn or-btn-icon",I.title="Clear focus nets",I.innerHTML=Cd,I.addEventListener("click",()=>R()),P.appendChild(I)}if(typeof k.highlight_group=="number"&&!wt(s)&&(s.techData?.highlight_colors||[]).length){let I=document.createElement("button");I.className="or-btn or-btn-icon inspector-highlight-btn";let O=k.highlight_group;if(I.title=O>=0?"Highlight group "+(O+1):"Add to highlight group",I.innerHTML=_d,O>=0){let ct=s.techData.highlight_colors[O];I.style.backgroundColor=`rgba(${ct[0]}, ${ct[1]}, ${ct[2]}, 0.45)`,I.style.borderColor=`rgb(${ct[0]}, ${ct[1]}, ${ct[2]})`}I.addEventListener("click",()=>w(I,k)),P.appendChild(I)}if(Array.isArray(k.actions)&&!wt(s))for(let I of k.actions){let O=document.createElement("button");O.className="or-btn inspector-action-btn",O.title=I,I==="Delete"?(O.classList.add("or-btn-icon","or-btn-danger-hover"),O.innerHTML=md):(O.classList.add("or-btn-sm"),O.textContent=I),O.addEventListener("click",()=>y(I,k)),P.appendChild(O)}s.inspectorEl.appendChild(P)}let H=k.selection_count||0,N=typeof k.selection_index=="number"?k.selection_index:-1;if(H>1&&N>=0){let P=document.createElement("div");P.className="inspector-selection-nav";let J=document.createElement("button");J.className="or-btn or-btn-icon",J.title="Previous (Shift+click to multi-select)",J.innerHTML=Ld,J.addEventListener("click",()=>it(-1));let I=document.createElement("span");I.className="inspector-selection-label",I.textContent=N+1+" / "+H;let O=document.createElement("button");O.className="or-btn or-btn-icon",O.title="Next",O.innerHTML=kd,O.addEventListener("click",()=>it(1)),P.appendChild(J),P.appendChild(I),P.appendChild(O),s.inspectorEl.appendChild(P)}let Y=document.createElement("div");Y.className="inspector-rows";for(let P of k.properties)Y.appendChild(Lt(P,k));Y.appendChild(ae()),s.inspectorEl.appendChild(Y),ft()}function ee(k){let H=document.createElement("div");H.className="inspector",s.inspectorEl=H,k.element.appendChild(H),Ft(null)}function de(){if(o){if(o.type==="Ruler"){s.rulerManager&&s.rulerManager._selectedRulerId!==null&&s.rulerManager._selectRuler(s.rulerManager._selectedRulerId);return}s.websocketManager&&Q(-1)}}return{createInspector:ee,updateInspector:Ft,highlightBBox:tt,pulseHighlight:Et,animateSelection:rt,stopSelectionAnimation:Yt,navigateInspector:Q,refreshInspector:de}}var vs=class{constructor(e,i,o){this._app=i,this._refreshOverlay=o||(()=>{}),this._data={selection:[],groups:[],truncated:!1},this._tab="selected",this._filter="",this._sortKey=null,this._sortAsc=!0,this._pendingRefresh=null,this._inFlight=!1,this._staleWhileInFlight=!1,this._visible=!0,this._el=document.createElement("div"),this._el.className="selection-browser",e.element.appendChild(this._el),e.on?.("show",()=>{this._visible=!0,this.refresh()}),e.on?.("hide",()=>{this._visible=!1}),e.on?.("destroy",()=>{this._visible=!1,this._staleWhileInFlight=!1,this._pendingRefresh!==null&&(clearTimeout(this._pendingRefresh),this._pendingRefresh=null)}),this._render(),this.refresh()}scheduleRefresh(){!this._visible||this._pendingRefresh!==null||(this._pendingRefresh=setTimeout(()=>{this._pendingRefresh=null,this.refresh()},150))}refresh(){if(!this._visible||wt(this._app))return;if(this._inFlight){this._staleWhileInFlight=!0;return}this._inFlight=!0;let e=()=>{this._inFlight=!1,this._staleWhileInFlight&&(this._staleWhileInFlight=!1,this.refresh())};this._app.websocketManager.request({type:"list_selection"}).then(i=>{i.ok&&(this._data=i,this._render()),e()}).catch(e)}_entries(){let e;this._tab==="selected"?e=(this._data.selection||[]).map((o,r)=>({row:o,index:r,group:-1})):e=(this._data.groups||[]).flatMap((o,r)=>o.map((l,h)=>({row:l,index:h,group:r})));let i=this._filter.trim().toLowerCase();if(i&&(e=e.filter(({row:o})=>(o.name||"").toLowerCase().includes(i)||(o.type||"").toLowerCase().includes(i))),this._sortKey){let o=this._sortKey,r=this._sortAsc?1:-1;e=e.slice().sort((l,h)=>r*String(l.row[o]||"").localeCompare(String(h.row[o]||"")))}return e}_fmtCoord(e){if(this._app.showDbu)return String(e);let i=this._app.getDbuPerMicron?this._app.getDbuPerMicron():1e3;return(e/i).toFixed(3)}_fmtBounds(e){if(!e)return"";let[i,o,r,l]=e;return`(${this._fmtCoord(i)}, ${this._fmtCoord(o)}), (${this._fmtCoord(r)}, ${this._fmtCoord(l)})`}_inspectRow(e,i){let o=e.group<0?{type:"inspect_selection",index:e.index,use_dbu:this._app.showDbu}:{type:"inspect_group",group:e.group,index:e.index,use_dbu:this._app.showDbu};this._app.websocketManager.request(o).then(r=>{if(!r.ok){this.refresh();return}this._app.updateInspector&&this._app.updateInspector(r),i&&this._app.focusComponent&&this._app.focusComponent("Inspector"),this._refreshOverlay()}).catch(()=>{})}_deselectRow(e){this._app.websocketManager.request({type:"deselect",index:e.index}).then(()=>{this.refresh(),this._refreshOverlay()}).catch(()=>{})}_clearHighlights(){this._app.websocketManager.request({type:"clear_highlights",group:-1}).then(()=>{this.refresh(),this._refreshOverlay(),this._app.refreshInspector&&this._app.refreshInspector()}).catch(()=>{})}_zoomToBBox(e){if(!e||!this._app.designScale||!this._app.map)return;let[i,o,r,l]=e,h=this._app.getDbuPerMicron?this._app.getDbuPerMicron():1e3,u=Math.min(10*h,2*Math.max(r-i,l-o));this._app.map.fitBounds(Gt(i-u,o-u,r+u,l+u,this._app.designScale,this._app.designMaxDXDY,this._app.designOriginX,this._app.designOriginY))}_render(){this._app.stopSelectionAnimation&&this._app.stopSelectionAnimation(),this._el.innerHTML="";let e=(this._data.selection||[]).length,i=(this._data.groups||[]).reduce((h,u)=>h+u.length,0),o=document.createElement("div");o.className="sb-tabs";for(let[h,u,f]of[["selected","Selected",e],["highlighted","Highlighted",i]]){let _=document.createElement("button");_.className="sb-tab"+(this._tab===h?" active":""),_.textContent=`${u} (${f})`,_.addEventListener("click",()=>{this._tab=h,this._render()}),o.appendChild(_)}let r=document.createElement("button");if(r.className="or-btn or-btn-sm sb-tool",r.title="Refresh",r.textContent="\u27F3",r.addEventListener("click",()=>this.refresh()),o.appendChild(r),this._tab==="highlighted"&&i>0){let h=document.createElement("button");h.className="or-btn or-btn-sm sb-tool",h.title="Clear all highlights",h.textContent="Clear",h.addEventListener("click",()=>this._clearHighlights()),o.appendChild(h)}this._el.appendChild(o);let l=document.createElement("input");if(l.type="text",l.className="sb-filter",l.placeholder="Filter by name or type\u2026",l.value=this._filter,l.addEventListener("input",()=>{this._filter=l.value,this._renderTable()}),this._el.appendChild(l),this._data.truncated){let h=document.createElement("div");h.className="sb-truncated",h.textContent="List truncated \u2014 showing the first 1000 entries per set.",this._el.appendChild(h)}this._tableWrap=document.createElement("div"),this._tableWrap.className="sb-table-wrap",this._el.appendChild(this._tableWrap),this._renderTable()}_renderTable(){this._tableWrap.innerHTML="";let e=this._entries();if(!e.length){let f=document.createElement("div");f.className="sb-empty",f.textContent=this._tab==="selected"?"Nothing selected.":"Nothing highlighted.",this._tableWrap.appendChild(f);return}let i=document.createElement("table");i.className="sb-table";let o=document.createElement("thead"),r=document.createElement("tr"),l=[["name","Object"],["type","Type"],[null,"Bounds"]];this._tab==="highlighted"&&l.push([null,"Group"]),l.push([null,""]);for(let[f,_]of l){let y=document.createElement("th");y.textContent=_,f&&(y.classList.add("sb-sortable"),this._sortKey===f&&(y.textContent+=this._sortAsc?" \u25B2":" \u25BC"),y.addEventListener("click",()=>{this._sortKey===f?this._sortAsc=!this._sortAsc:(this._sortKey=f,this._sortAsc=!0),this._renderTable()})),r.appendChild(y)}o.appendChild(r),i.appendChild(o);let h=document.createElement("tbody"),u=this._app.techData?.highlight_colors||[];for(let f of e){let _=document.createElement("tr");_.className="sb-row";let y=document.createElement("td");y.textContent=f.row.name||"";let g=document.createElement("td");g.textContent=f.row.type||"";let v=document.createElement("td");if(v.textContent=this._fmtBounds(f.row.bbox),_.appendChild(y),_.appendChild(g),_.appendChild(v),this._tab==="highlighted"){let b=document.createElement("td"),C=document.createElement("span");C.className="sb-chip";let R=u[f.group];R&&(C.style.backgroundColor=`rgb(${R[0]}, ${R[1]}, ${R[2]})`),b.appendChild(C),b.appendChild(document.createTextNode(` Group ${f.group+1}`)),_.appendChild(b)}let w=document.createElement("td");if(w.className="sb-actions",f.row.bbox){let b=document.createElement("button");b.className="sb-row-btn",b.title="Zoom to",b.textContent="\u2316",b.addEventListener("click",C=>{C.stopPropagation(),this._zoomToBBox(f.row.bbox)}),w.appendChild(b)}if(this._tab==="selected"){let b=document.createElement("button");b.className="sb-row-btn",b.title="De-select",b.textContent="\u2715",b.addEventListener("click",C=>{C.stopPropagation(),this._deselectRow(f)}),w.appendChild(b)}_.appendChild(w),_.addEventListener("click",()=>this._inspectRow(f,!1)),_.addEventListener("dblclick",()=>this._inspectRow(f,!0)),f.row.bbox&&(_.addEventListener("mouseenter",()=>{this._app.animateSelection&&this._app.animateSelection(f.row.bbox,{repeats:0})}),_.addEventListener("mouseleave",()=>{this._app.stopSelectionAnimation&&this._app.stopSelectionAnimation()})),h.appendChild(_)}i.appendChild(h),this._tableWrap.appendChild(i),fi(i)}};var xl="options-dialog",wl=[{label:"System default",value:""},{label:"Sans-serif",value:"sans-serif"},{label:"Serif",value:"serif"},{label:"Monospace",value:"monospace"},{label:"Helvetica / Arial",value:"Helvetica, Arial, sans-serif"},{label:"Georgia",value:"Georgia, 'Times New Roman', serif"},{label:"Courier",value:"'Courier New', Courier, monospace"}],Ed=100,bs=70,ws=200;function vn(s){let e=s===""||s===null?NaN:Math.round(Number(s));return Number.isFinite(e)?Math.min(ws,Math.max(bs,e)):Ed}function Cl(s){let{overlay:e,close:i,okBtn:o,showError:r}=Zi("Arrow keys scroll step",` +Setup and hold times account for internal clock delays.`},{label:"Logic Delay",key:"path_delay",time:!0,num:!0,tooltip:"Path delay from instances (excluding buffers and consecutive inverter pairs)"},{label:"Logic Depth",key:"logic_depth",num:!0,tooltip:"Path instances (excluding buffers and consecutive inverter pairs)"},{label:"Fanout",key:"fanout",num:!0},{label:"Start",key:"start_pin"},{label:"End",key:"end_pin"}];Ps.DETAIL_COLS=["Pin","Fanout","R/F","Time","Delay","Slew","Load"];Ps.DETAIL_NUM_COLS=new Set(["Fanout","Time","Delay","Slew","Load"]);function Be(n){let e=document.cookie.match("(?:^|; )"+n+"=([^;]*)");return e?e[1]:null}function Ue(n,e){document.cookie=n+"="+e+"; path=/; max-age=31536000; SameSite=Lax"}function Oh(n){document.cookie=n+"=; path=/; max-age=0; SameSite=Lax"}function Dh(n){Ue("or_theme",n);try{window.localStorage.setItem("or_theme",n)}catch{}}function K3(){Oh("or_theme");try{window.localStorage.removeItem("or_theme")}catch{}}function Jb(n){let e=document.getElementById("gl-theme-dark"),t=document.getElementById("gl-theme-light");!e||!t||(e.disabled=n!=="dark",t.disabled=n!=="light")}function Q3(n,e){Zo(n)&&(document.documentElement.style.setProperty("--bg-map",n),Ue("or_bg_color",n),eM(e),e.syncDisplayState())}function J3(n){document.documentElement.style.removeProperty("--bg-map"),Oh("or_bg_color"),eM(n),n.syncDisplayState()}function ev(){return U3(getComputedStyle(document.documentElement).getPropertyValue("--bg-map"))??"#000000"}function eM(n){n.threeDViewerWidget?.render?.()}if(typeof document<"u"){let n=Be("or_theme")||typeof localStorage<"u"&&localStorage.getItem("or_theme")||(matchMedia("(prefers-color-scheme: light)").matches?"light":"dark");document.documentElement.dataset.theme=n,Jb(n);let e=Be("or_bg_color");Zo(e)&&document.documentElement.style.setProperty("--bg-map",e)}function Cs(){let n=getComputedStyle(document.documentElement),e=t=>n.getPropertyValue(t).trim();return{canvasBg:e("--canvas-bg"),canvasText:e("--canvas-text"),canvasAxis:e("--canvas-axis"),canvasLabel:e("--canvas-label"),canvasGrid:e("--canvas-grid"),canvasTitle:e("--canvas-title"),fgPrimary:e("--fg-primary"),fgMuted:e("--fg-muted"),bgPanel:e("--bg-panel"),bgMap:e("--bg-map"),fontMono:e("--font-mono"),fontSans:e("--font-sans")}}function Ts(n,e){let t=document.createElement("a");t.href=n,t.download=e,document.body.appendChild(t),t.click(),t.remove()}function tM(n,e){let t=URL.createObjectURL(n);Ts(t,e),setTimeout(()=>URL.revokeObjectURL(t),1e3)}function tv(n){let e=n.cloneNode(!0);if(e.getAttribute("xmlns")||e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.getAttribute("xmlns:xlink")||e.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),!e.getAttribute("width")||!e.getAttribute("height")){let t=n.viewBox&&n.viewBox.baseVal;t&&t.width&&t.height&&(e.setAttribute("width",t.width),e.setAttribute("height",t.height))}return` +`+new XMLSerializer().serializeToString(e)}function qV(n){let e=n.viewBox&&n.viewBox.baseVal;if(e&&e.width&&e.height)return{width:e.width,height:e.height};let t=parseFloat(n.getAttribute("width")),i=parseFloat(n.getAttribute("height"));if(t&&i)return{width:t,height:i};let r=n.getBoundingClientRect();return{width:r.width||800,height:r.height||600}}function nv(n,e=2){let{width:t,height:i}=qV(n),r=tv(n),s=new Blob([r],{type:"image/svg+xml;charset=utf-8"}),o=URL.createObjectURL(s);return new Promise((a,c)=>{let l=new Image;l.onload=()=>{let u=document.createElement("canvas");u.width=Math.max(1,Math.round(t*e)),u.height=Math.max(1,Math.round(i*e));let f=u.getContext("2d");f.fillStyle="#ffffff",f.fillRect(0,0,u.width,u.height),f.drawImage(l,0,0,u.width,u.height),URL.revokeObjectURL(o),a(u.toDataURL("image/png"))},l.onerror=u=>{URL.revokeObjectURL(o),c(u)},l.src=o})}async function Nh(n){try{if(!navigator.clipboard||!window.ClipboardItem)return!1;let e=await(await fetch(n)).blob();return await navigator.clipboard.write([new ClipboardItem({"image/png":e})]),!0}catch{return!1}}function ZV(n){return(String(n||"").replace(/[^A-Za-z0-9._-]/g,"_").replace(/^_+|_+$/g,"")||"clock_tree")+".png"}var iv=24,rv=10,zh=40,XV=40,sv=70,KV=20,Fh={root:"#ff4444",buffer:"#4488ff",inverter:"#00b0b0",clock_gate:"#cc44cc",register:"#ff4444",macro:"#00b0b0",unknown:"#888888"};function QV(n){let e=parseInt(n.slice(1,3),16),t=parseInt(n.slice(3,5),16),i=parseInt(n.slice(5,7),16),r=o=>Math.round((o+255)/2),s=o=>o.toString(16).padStart(2,"0");return"#"+s(r(e))+s(r(t))+s(r(i))}function JV(n){let e=n.nodes;if(!e||e.length===0)return{layout:[],layoutWidth:0,layoutHeight:0,timeMin:0,timeMax:0,timeUnit:"",sceneHeight:0,layoutById:new Map};let t=new Map;for(let y of e)t.set(y.id,[]);for(let y of e)y.parent_id>=0&&t.has(y.parent_id)&&t.get(y.parent_id).push(y.id);let i=new Map;for(let y of e)i.set(y.id,y);let r=new Map,s=y=>{let b=t.get(y)||[];if(b.length===0)return r.set(y,1),1;let w=0;for(let E of b)w+=s(E);return r.set(y,w),w},o=e.filter(y=>y.parent_id===-1),a=0;for(let y of o)a+=s(y.id);let c=n.min_arrival,l=n.max_arrival,u=l-c||1,f=Math.max(200,a*iv*.6),d=[],h=(y,b)=>{let w=i.get(y),E=r.get(y),x=sv+(b+E/2)*iv,T=zh+(w.arrival-c)/u*f;d.push({id:w.id,x,y:T,type:w.type,name:w.name,pin_name:w.pin_name,arrival:w.arrival,delay:w.delay,fanout:w.fanout,level:w.level,parent_id:w.parent_id});let I=b,N=t.get(y)||[];for(let D of N)h(D,I),I+=r.get(D)},p=0;for(let y of o)h(y.id,p),p+=r.get(y.id);let m=sv+a*iv+KV,g=zh+f+XV,v=new Map;for(let y of d)v.set(y.id,y);return{layout:d,layoutWidth:m,layoutHeight:g,timeMin:c,timeMax:l,timeUnit:n.time_unit||"",sceneHeight:f,layoutById:v}}var Uh=class{constructor(e,t,i,r){this._app=t,this._redrawAllLayers=i,this._refreshOverlay=r||i,this._clockData=[],this._selectedClockIdx=0,this._selectedNodeId=-1,this._tx=0,this._ty=0,this._scale=1,this._layout=[],this._dragging=!1,this._dragStartX=0,this._dragStartY=0,this._dragStartTx=0,this._dragStartTy=0,this._build(e)}_build(e){let t=document.createElement("div");t.className="clock-tree-widget";let i=document.createElement("div");i.className="clock-tree-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",ue(this._app)&&(this._updateBtn.style.display="none"),this._fitBtn=document.createElement("button"),this._fitBtn.className="or-btn",this._fitBtn.textContent="Fit",this._pngBtn=document.createElement("button"),this._pngBtn.className="or-btn",this._pngBtn.textContent="PNG",this._pngBtn.title="Export the clock tree as a PNG image",this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",i.appendChild(this._updateBtn),i.appendChild(this._fitBtn),i.appendChild(this._pngBtn),i.appendChild(this._statusLabel),t.appendChild(i),this._tabBar=document.createElement("div"),this._tabBar.className="timing-tab-bar",t.appendChild(this._tabBar),this._canvas=document.createElement("canvas"),this._canvas.className="clock-tree-canvas",t.appendChild(this._canvas),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._tooltip.style.display="none",t.appendChild(this._tooltip),e.element.appendChild(t),this._el=t,this._ctx=this._canvas.getContext("2d"),this._bindEvents(),ue(this._app)&&setTimeout(()=>this.update(),0)}_fit(){this._sizeCanvas(),this._fitToView(),this._render()}_pngFileName(){let e=this._clockData[this._selectedClockIdx];return ZV(e&&e.name)}_exportPng(){try{Ts(this._canvas.toDataURL("image/png"),this._pngFileName())}catch(e){console.error("PNG export failed:",e)}}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update()),this._fitBtn.addEventListener("click",()=>this._fit()),this._pngBtn.addEventListener("click",()=>this._exportPng()),this._canvas.addEventListener("keydown",e=>{e.key==="f"&&this._fit()}),this._canvas.tabIndex=0,this._canvas.addEventListener("wheel",e=>{e.preventDefault();let t=this._canvas.getBoundingClientRect(),i=e.clientX-t.left,r=e.clientY-t.top,s=e.deltaY<0?1.15:1/1.15;this._tx=i-(i-this._tx)*s,this._ty=r-(r-this._ty)*s,this._scale*=s,this._render()}),this._canvas.addEventListener("mousedown",e=>{this._dragging=!0,this._dragStartX=e.clientX,this._dragStartY=e.clientY,this._dragStartTx=this._tx,this._dragStartTy=this._ty,this._canvas.style.cursor="grabbing"}),window.addEventListener("mousemove",e=>{this._dragging?(this._tx=this._dragStartTx+(e.clientX-this._dragStartX),this._ty=this._dragStartTy+(e.clientY-this._dragStartY),this._render()):this._handleHover(e)}),window.addEventListener("mouseup",()=>{this._dragging&&(this._dragging=!1,this._canvas.style.cursor="grab")}),this._canvas.addEventListener("click",e=>this._handleClick(e)),this._resizeObserver=new ResizeObserver(()=>{this._sizeCanvas(),this._render()}),this._resizeObserver.observe(this._canvas)}_sizeCanvas(){let e=this._canvas.getBoundingClientRect(),t=window.devicePixelRatio||1;this._canvas.width=e.width*t,this._canvas.height=e.height*t,this._ctx.setTransform(t,0,0,t,0,0)}async update(){this._statusLabel.textContent="Loading...";try{let e=await this._app.websocketManager.request({type:"clock_tree"});this._clockData=e.clocks||[],this._buildTabs(),this._selectClock(0),this._statusLabel.textContent=this._clockData.length+" clock"+(this._clockData.length!==1?"s":"")}catch(e){console.error("Clock tree error:",e),this._statusLabel.textContent="Error: "+e.message}}_buildTabs(){this._tabBar.innerHTML="",this._clockData.forEach((e,t)=>{let i=document.createElement("button");i.className="timing-tab"+(t===this._selectedClockIdx?" active":""),i.textContent=e.name,i.addEventListener("click",()=>this._selectClock(t)),this._tabBar.appendChild(i)})}_selectClock(e){if(e<0||e>=this._clockData.length)return;this._selectedClockIdx=e,this._selectedNodeId=-1,this._tabBar.querySelectorAll(".timing-tab").forEach((i,r)=>{i.classList.toggle("active",r===e)}),this._computeLayout(this._clockData[e]),requestAnimationFrame(()=>{this._sizeCanvas(),this._fitToView(),this._render()})}_computeLayout(e){let t=JV(e);this._layout=t.layout,this._layoutWidth=t.layoutWidth,this._layoutHeight=t.layoutHeight,this._timeMin=t.timeMin,this._timeMax=t.timeMax,this._timeUnit=t.timeUnit,this._sceneHeight=t.sceneHeight,this._layoutById=t.layoutById}_fitToView(){if(!this._layout.length)return;let e=this._canvas.getBoundingClientRect(),t=e.width,i=e.height,r=t/this._layoutWidth,s=i/this._layoutHeight;this._scale=Math.min(r,s)*.9,this._tx=(t-this._layoutWidth*this._scale)/2,this._ty=(i-this._layoutHeight*this._scale)/2}render(){this._render()}_render(){let e=this._ctx,t=this._canvas.getBoundingClientRect(),i=t.width,r=t.height,s=Cs();if(e.clearRect(0,0,i,r),e.fillStyle=s.canvasBg,e.fillRect(0,0,i,r),!this._layout.length){e.fillStyle=s.canvasText,e.font="14px "+s.fontSans,e.textAlign="center";let o=ue(this._app)?"No clock tree data available":'Click "Update" to load clock tree data';e.fillText(o,i/2,r/2);return}e.save(),e.translate(this._tx,this._ty),e.scale(this._scale,this._scale),this._drawConnections(e);for(let o of this._layout)this._drawNode(e,o,o.id===this._selectedNodeId);e.restore(),this._drawTimeScale(e,i,r,s)}_drawConnections(e){let t=1.5/this._scale,i=rv,r=this._timeMax-this._timeMin||1;for(let s of this._layout){if(s.parent_id<0)continue;let o=this._layoutById.get(s.parent_id);if(!o)continue;let a=o.x,c=s.x,l=(o.delay||0)/r*this._sceneHeight,u=o.y+l,f=s.y,d=o.type==="root"?o.y:o.y+i;if(u>d){let p=Fh[o.type]||Fh.unknown;e.strokeStyle=p,e.lineWidth=t,e.beginPath(),e.moveTo(a,d),e.lineTo(a,u);let m=i/20;e.moveTo(a-m,u),e.lineTo(a+m,u),e.stroke()}e.strokeStyle="#006400",e.lineWidth=t;let h=(u+f)/2;e.beginPath(),e.moveTo(a,u),e.bezierCurveTo(a,h,c,h,c,f),e.stroke()}}_drawNode(e,t,i){let r=t.x,s=t.y,o=rv,a=Fh[t.type]||Fh.unknown;switch(e.fillStyle=QV(a),e.strokeStyle=a,e.lineWidth=1/this._scale,t.type){case"root":{e.beginPath(),e.moveTo(r-o/2,s-o),e.lineTo(r+o/2,s-o),e.lineTo(r,s),e.closePath(),e.fill(),e.stroke();break}case"buffer":{e.beginPath(),e.moveTo(r-o/2,s),e.lineTo(r+o/2,s),e.lineTo(r,s+o),e.closePath(),e.fill(),e.stroke();break}case"inverter":{let c=o*.1,l=s+o-c;e.beginPath(),e.moveTo(r-o/2,s),e.lineTo(r+o/2,s),e.lineTo(r,l),e.closePath(),e.fill(),e.stroke(),e.beginPath(),e.arc(r,l+c/2,c/2,0,Math.PI*2),e.fill(),e.stroke();break}case"clock_gate":{e.beginPath(),e.arc(r,s+o/2,o/2,0,Math.PI*2),e.fill(),e.stroke();break}case"register":case"macro":{e.beginPath(),e.rect(r-o/2,s,o,o),e.fill(),e.stroke(),e.beginPath(),e.moveTo(r-o/8,s),e.lineTo(r+o/8,s),e.lineTo(r,s+o/4),e.closePath(),e.stroke();break}default:{e.beginPath(),e.arc(r,s+o/2,o/2,0,Math.PI*2),e.fill(),e.stroke();break}}if(i){e.strokeStyle="#ffff00",e.lineWidth=2/this._scale;let c=t.type==="root"?s-o/2:s+o/2;e.beginPath(),e.arc(r,c,o/2+3,0,Math.PI*2),e.stroke()}}_drawTimeScale(e,t,i,r){if(!this._sceneHeight)return;let s=m=>m*this._scale+this._ty,o=s(zh),a=s(zh+this._sceneHeight);if(a<0||o>i)return;e.save(),e.fillStyle=r.canvasLabel,e.strokeStyle=r.canvasAxis,e.font="11px "+r.fontMono,e.textAlign="right",e.textBaseline="middle";let c=this._timeMax-this._timeMin;if(c<=0){e.restore();return}let l=a-o,u=Math.max(2,Math.floor(l/40)),f=c/u,d=Math.pow(10,Math.floor(Math.log10(f))),h=d;f/d>5?h=10*d:f/d>2?h=5*d:f/d>1&&(h=2*d);let p=Math.ceil(this._timeMin/h)*h;e.beginPath();for(let m=p;m<=this._timeMax;m+=h){let g=(m-this._timeMin)/c,v=o+g*(a-o);e.moveTo(0,v),e.lineTo(t,v);let y=m.toFixed(h<.01?3:h<.1?2:1)+" "+this._timeUnit;e.fillText(y,sv-4,v)}e.stroke(),e.restore()}_screenToLayout(e,t){return{x:(e-this._tx)/this._scale,y:(t-this._ty)/this._scale}}_hitTest(e,t){let i=this._screenToLayout(e,t),r=rv;for(let s of this._layout){let o=s.type==="root"?s.y-r:s.y,a=s.type==="root"?s.y:s.y+r;if(i.x>=s.x-r/2&&i.x<=s.x+r/2&&i.y>=o&&i.y<=a)return s}return null}_handleClick(e){let t=this._canvas.getBoundingClientRect(),i=e.clientX-t.left,r=e.clientY-t.top,s=this._hitTest(i,r);s?(this._selectedNodeId=s.id,this._render(),this._app.websocketManager.request({type:"clock_tree_highlight",inst_name:s.name}).then(()=>this._refreshOverlay())):this._selectedNodeId>=0&&(this._selectedNodeId=-1,this._render(),this._app.websocketManager.request({type:"clock_tree_highlight",inst_name:""}).then(()=>this._refreshOverlay()))}_handleHover(e){let t=this._canvas.getBoundingClientRect(),i=e.clientX-t.left,r=e.clientY-t.top;if(i<0||r<0||i>t.width||r>t.height){this._tooltip.style.display="none";return}let s=this._hitTest(i,r);if(s){let o=[s.name,"Type: "+s.type,"Arrival: "+s.arrival.toFixed(3)+" "+(this._timeUnit||"")];s.delay&&o.push("Delay: "+s.delay.toFixed(3)+" "+(this._timeUnit||"")),s.fanout&&o.push("Fanout: "+s.fanout),this._tooltip.textContent=o.join(` +`),this._tooltip.style.display="block",this._tooltip.style.left=e.clientX+12+"px",this._tooltip.style.top=e.clientY+12+"px"}else this._tooltip.style.display="none"}};var iM=60,rM=20,sM=30,oM=50,nM=2,eW="#f08080",tW="#8b0000",nW="#90ee90",iW="#006400",lr=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7"],rW="rgba(240,128,128,0.12)",sW="rgba(144,238,144,0.12)",oW="#ff9999",aW="#b0ffb0",cW=[{value:"setup",label:"Setup Slack"},{value:"hold",label:"Hold Slack"},{value:"fanout",label:"Net Fanout"},{value:"netlength",label:"Net Length (HPWL)"}];function lW(n,e,t,i){if(!n||!e||ie.bottom)return null;for(let r of n)if(t>=r.x&&t<=r.x+r.width)return r;return null}function uW(n,e,t){return t?Math.log10(n+1)/Math.log10(e+1):n/e}function fW(n,e,t,i={}){let r=!!i.logY,s=n?.bins;if(!s||s.length===0)return{bars:[],yMax:0,yTicks:[],chartArea:null,logY:r};let o=iM,a=e-rM,c=sM,l=t-oM,u=a-o,f=l-c;if(u<=0||f<=0)return{bars:[],yMax:0,yTicks:[],chartArea:null,logY:r};let d={left:o,right:a,top:c,bottom:l},h=0;for(let y of s)y.count>h&&(h=y.count);h===0&&(h=1);let{yMax:p,yTicks:m}=r?hW(h):dW(h),g=(u-nM*(s.length-1))/s.length,v=[];for(let y=0;y[l.x,...l.ys||[]].join(","));return[a,...c].join(` +`)}let t=e.bins||[],i=Array.isArray(e.series)?e.series:[],r=["lower","upper","count",...i.map(o=>o.name||"group")].join(","),s=t.map((o,a)=>{let c=[o.lower,o.upper,o.count];for(let l of i)c.push(l.counts&&l.counts[a]||0);return c.join(",")});return[r,...s].join(` +`)}var $h=class{constructor(e,t){this._app=e,this._redrawAllLayers=t,this._currentTab="setup",this._histogramData=null,this._bars=[],this._yMax=0,this._yTicks=[],this._chartArea=null,this._hoveredBar=null,this._debugCharts=[],this._activeDebugChart=-1,this._build()}_build(){let e=document.createElement("div");e.className="charts-widget";let t=document.createElement("div");t.className="charts-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",ue(this._app)&&(this._updateBtn.style.display="none"),this._chartSelect=document.createElement("select"),this._chartSelect.className="charts-select",this._csvBtn=document.createElement("button"),this._csvBtn.className="or-btn",this._csvBtn.textContent="CSV",this._csvBtn.title="Export the current chart data as CSV",this._pngBtn=document.createElement("button"),this._pngBtn.className="or-btn",this._pngBtn.textContent="PNG",this._pngBtn.title="Export the current chart as a PNG image",this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",t.appendChild(this._updateBtn),t.appendChild(this._chartSelect),t.appendChild(this._csvBtn),t.appendChild(this._pngBtn),t.appendChild(this._statusLabel),e.appendChild(t);let i=document.createElement("div");i.className="charts-toolbar";let r=document.createElement("span");r.textContent="Path Groups:",r.style.color="var(--fg-muted)",r.style.fontSize="var(--fs-12)",this._pathGroupSelect=document.createElement("select"),this._pathGroupSelect.className="charts-select",this._pathGroupSelect.multiple=!0,this._pathGroupSelect.size=1,this._pathGroupSelect.title="Select 0 = all, or \u22651 to stack by group";let s=document.createElement("span");s.textContent="Clock:",s.style.color="var(--fg-muted)",s.style.fontSize="var(--fs-12)",this._clockSelect=document.createElement("select"),this._clockSelect.className="charts-select",this._clockSelect.innerHTML='',i.appendChild(r),i.appendChild(this._pathGroupSelect),i.appendChild(s),i.appendChild(this._clockSelect),e.appendChild(i),this._canvas=document.createElement("canvas"),this._canvas.className="charts-canvas",e.appendChild(this._canvas),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._tooltip.style.display="none",e.appendChild(this._tooltip),this._filterRow=i,this.element=e,this._ctx=this._canvas.getContext("2d"),this._rebuildSelect(),this._bindEvents(),ue(this._app)&&setTimeout(()=>this.update(),0)}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update()),this._chartSelect.addEventListener("change",()=>this._onSelectChange()),this._csvBtn.addEventListener("click",()=>this._exportCsv()),this._pngBtn.addEventListener("click",()=>this._exportPng()),this._pathGroupSelect.addEventListener("change",()=>this._fetchHistogram()),this._clockSelect.addEventListener("change",()=>this._fetchHistogram()),this._canvas.addEventListener("mousemove",t=>this._handleHover(t)),this._canvas.addEventListener("mouseleave",()=>{this._hoveredBar=null,this._tooltip.style.display="none",this._syncView()}),this._canvas.addEventListener("click",t=>this._handleClick(t)),this._canvas.addEventListener("dblclick",t=>this._handleDblClick(t)),new ResizeObserver(()=>this._syncView()).observe(this._canvas)}_sizeCanvas(){let e=this._canvas.getBoundingClientRect(),t=window.devicePixelRatio||1;this._canvas.width=e.width*t,this._canvas.height=e.height*t,this._ctx.setTransform(t,0,0,t,0,0)}_rebuildSelect(){let e=this._chartSelect;e.innerHTML="";for(let t of cW){let i=document.createElement("option");i.value=t.value,i.textContent=t.label,e.appendChild(i)}this._debugCharts.forEach((t,i)=>{let r=document.createElement("option");r.value="gen:"+i,r.textContent=t.name||"Chart "+i,e.appendChild(r)}),e.value=this._activeDebugChart>=0?"gen:"+this._activeDebugChart:this._currentTab}_onSelectChange(){let e=this._chartSelect.value;e.startsWith("gen:")?(this._activeDebugChart=parseInt(e.slice(4),10)||0,this._hoveredBar=null,this._tooltip.style.display="none",this._syncView()):this._selectTab(e)}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...",this._statusLabel.textContent="";try{this._activeDebugChart<0?((this._currentTab==="setup"||this._currentTab==="hold")&&await this._fetchFilters(),await Promise.all([this._fetchHistogram(),this._fetchGenericCharts()])):await this._fetchGenericCharts()}catch(e){this._statusLabel.textContent="Error: "+e.message}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}async _fetchFilters(){let e=await this._app.websocketManager.request({type:"chart_filters"});this._populatePathGroups(e.path_groups||[]),this._populateClocks(e.clocks||[])}_populatePathGroups(e){let t=new Set(Array.from(this._pathGroupSelect.selectedOptions,i=>i.value));this._pathGroupSelect.innerHTML="";for(let i of e){let r=document.createElement("option");r.value=i,r.textContent=i,r.selected=t.has(i),this._pathGroupSelect.appendChild(r)}}_populateClocks(e){let t=this._clockSelect.value;this._clockSelect.innerHTML='';for(let i of e){let r=document.createElement("option");r.value=i,r.textContent=i,this._clockSelect.appendChild(r)}e.includes(t)&&(this._clockSelect.value=t)}async _fetchGenericCharts(){try{let e=await this._app.websocketManager.request({type:"debug_charts"});this.setDebugCharts(e.charts||[])}catch{}}async _fetchHistogram(){try{let e=this._currentTab,t;if(e==="fanout")t={type:"fanout_histogram"};else if(e==="netlength")t={type:"net_length_histogram",use_dbu:!!this._app.showDbu};else{t={type:"slack_histogram",is_setup:e==="setup"};let r=Array.from(this._pathGroupSelect.selectedOptions,s=>s.value).filter(Boolean);r.length>0&&(t.path_groups=r),this._clockSelect.value&&(t.clock_name=this._clockSelect.value)}let i=await this._app.websocketManager.request(t);if(this._currentTab!==e)return;if(this._histogramData=i,this._syncView(),e==="fanout"||e==="netlength"){let r=i.total_nets||0;this._statusLabel.textContent=`${r} nets`}else{let r=i.total_endpoints||0,s=i.unconstrained_count||0,o=r-s;this._statusLabel.textContent=`${o} endpoints`+(s>0?`, ${s} unconstrained`:"")}}catch(e){this._statusLabel.textContent="Error: "+e.message}}_selectTab(e){this._currentTab===e&&this._activeDebugChart<0||(this._currentTab=e,this._activeDebugChart=-1,this._chartSelect&&(this._chartSelect.value=e),this._filterRow.style.display=e==="setup"||e==="hold"?"":"none",this._hoveredBar=null,this._tooltip.style.display="none",this.update())}_computeLayout(){if(!this._histogramData)return;let e=this._canvas.getBoundingClientRect(),t=fW(this._histogramData,e.width,e.height,{logY:this._currentTab==="fanout"});this._bars=t.bars,this._yMax=t.yMax,this._yTicks=t.yTicks,this._chartArea=t.chartArea,this._logY=!!t.logY}render(){this._syncView()}_stackedSeries(){let e=this._histogramData?.series;return Array.isArray(e)&&e.length>1?e:null}_render(){let e=this._canvas.getBoundingClientRect(),t=e.width,i=e.height,r=this._ctx,s=Cs();if(r.clearRect(0,0,t,i),r.fillStyle=s.canvasBg,r.fillRect(0,0,t,i),!this._bars||this._bars.length===0){r.fillStyle=s.canvasText,r.font="14px "+s.fontSans,r.textAlign="center",r.textBaseline="middle";let o=ue(this._app)?"No histogram data available":'Click "Update" to load histogram';r.fillText(o,t/2,i/2);return}this._drawAxes(r,s),this._drawBars(r),this._drawTitle(r,t,s),this._stackedSeries()&&this._drawSeriesLegend(r,s)}_drawAxes(e,t){let i=this._chartArea;if(!i)return;e.strokeStyle=t.canvasAxis,e.lineWidth=1,e.beginPath(),e.moveTo(i.left,i.top),e.lineTo(i.left,i.bottom),e.stroke(),e.beginPath(),e.moveTo(i.left,i.bottom),e.lineTo(i.right,i.bottom),e.stroke(),e.fillStyle=t.canvasLabel,e.font="11px "+t.fontMono,e.textAlign="right",e.textBaseline="middle";let r=i.bottom-i.top;for(let d of this._yTicks){let h=this._logY?Math.log10(d+1)/Math.log10(this._yMax+1):d/this._yMax,p=i.bottom-h*r;e.fillText(this._formatCount(d),i.left-6,p),d>0&&(e.strokeStyle=t.canvasGrid,e.beginPath(),e.moveTo(i.left,p),e.lineTo(i.right,p),e.stroke(),e.strokeStyle=t.canvasAxis)}let s=this._currentTab,o=s==="fanout"||s==="netlength";e.save(),e.translate(14,(i.top+i.bottom)/2),e.rotate(-Math.PI/2),e.textAlign="center",e.textBaseline="middle",e.fillStyle=t.canvasTitle,e.font="11px "+t.fontMono,e.fillText(this._logY?"Nets (log)":o?"Nets":"Endpoints",0,0),e.restore(),e.textAlign="center",e.textBaseline="top",e.fillStyle=t.canvasLabel,e.font="10px "+t.fontMono;let a=this._histogramData.bins,c=this._histogramData.time_unit||this._histogramData.length_unit||"",l=a.length>0?a[0].upper-a[0].lower:1,u=s==="fanout"?0:Math.max(0,-Math.floor(Math.log10(l)));for(let d=0;d<=this._bars.length;d++){let h=d=0){this._hoveredBar=null,this._tooltip.style.display="none";return}let t=this._hitTestBar(e);if(t!==this._hoveredBar&&(this._hoveredBar=t,this._render()),t){let i=this._currentTab,r=t.upper-t.lower;if(i==="fanout"){let d=t.upper-1,h=t.lower===d?`${t.lower}`:`[${t.lower}, ${d}]`;this._tooltip.textContent=`Nets: ${t.count} +Fanout: ${h}`}else if(i==="netlength"){let d=this._histogramData?.length_unit||"",h=Math.max(0,-Math.floor(Math.log10(r)));this._tooltip.textContent=`Nets: ${t.count} +Length: [${t.lower.toFixed(h)}, ${t.upper.toFixed(h)}) ${d}`}else{let d=this._histogramData?.time_unit||"",h=Math.max(0,-Math.floor(Math.log10(r)));this._tooltip.textContent=`Endpoints: ${t.count} +Slack: [${t.lower.toFixed(h)}, ${t.upper.toFixed(h)}) ${d}`}this._tooltip.style.display="block";let s=this.element.getBoundingClientRect(),o=this._tooltip.getBoundingClientRect(),a=4,c=e.clientX-s.left,l=e.clientY-s.top,u=c+12;u+o.width>s.width-a&&(u=c-12-o.width),u=Math.max(a,u);let f=l-10;f=Math.min(s.height-o.height-a,Math.max(a,f)),this._tooltip.style.left=u+"px",this._tooltip.style.top=f+"px"}else this._tooltip.style.display="none"}async _handleClick(e){if(this._activeDebugChart>=0||this._currentTab==="fanout"||this._currentTab==="netlength")return;let t=this._hitTestBar(e);if(!(!t||t.count===0))try{let i=await this._app.websocketManager.request({type:"timing_report",is_setup:this._currentTab==="setup",max_paths:50,slack_min:t.lower,slack_max:t.upper});this._app.timingWidget&&(this._app.timingWidget.showPaths(this._currentTab,i.paths||[]),this._app.focusComponent&&this._app.focusComponent("TimingWidget"))}catch(i){console.error("Charts bar click error:",i)}}async _handleDblClick(e){if(this._activeDebugChart>=0)return;let t;if(this._currentTab==="fanout")t="select_fanout_bin";else if(this._currentTab==="netlength")t="select_net_length_bin";else return;let i=this._hitTestBar(e);if(!i||i.count===0)return;let r=St(this._app);try{let s=await this._app.websocketManager.request({type:t,lower:i.lower,upper:i.upper,use_dbu:this._app.showDbu});if(!Dt(this._app,r))return;s&&s.truncated&&console.warn(`Bin has ${s.count} nets; selection capped at ${s.selection_limit} for performance.`),this._app.updateInspector&&this._app.updateInspector(s),this._app.focusComponent&&this._app.focusComponent("Inspector"),this._redrawAllLayers&&this._redrawAllLayers()}catch(s){console.error("Net bin select failed:",s)}}_activeChartData(){return this._activeDebugChart>=0?{kind:"generic",data:this._debugCharts[this._activeDebugChart]}:{kind:"histogram",data:this._histogramData}}_chartBaseName(){return this._activeDebugChart>=0?this._debugCharts[this._activeDebugChart].name||"chart":this._currentTab}_triggerDownload(e,t,{revoke:i=!1}={}){let r=document.createElement("a");r.href=t,r.download=e,document.body.appendChild(r),r.click(),r.remove(),i&&URL.revokeObjectURL(t)}_download(e,t,i){try{let r=URL.createObjectURL(new Blob([i],{type:t}));this._triggerDownload(e,r,{revoke:!0})}catch(r){console.error("Download failed:",r)}}_exportCsv(){let{kind:e,data:t}=this._activeChartData();if(!t)return;let i=pW(e,t);this._download(this._chartBaseName()+".csv","text/csv",i)}_exportPng(){try{let e=this._canvas.toDataURL("image/png");this._triggerDownload(this._chartBaseName()+".png",e)}catch(e){console.error("PNG export failed:",e)}}setDebugCharts(e){this._debugCharts=e,e.length===0?this._activeDebugChart=-1:this._activeDebugChart>=e.length&&(this._activeDebugChart=0),this._rebuildSelect(),this._syncView()}_syncView(){let e=this._activeDebugChart>=0;e&&(this._hoveredBar=null,this._tooltip.style.display="none");let t=!e&&(this._currentTab==="setup"||this._currentTab==="hold");this._filterRow&&(this._filterRow.style.display=t?"":"none"),this._sizeCanvas(),e?this._renderLineChart(this._debugCharts[this._activeDebugChart]):(this._computeLayout(),this._render())}_renderLineChart(e){let t=this._canvas.getBoundingClientRect(),i=t.width,r=t.height,s=this._ctx,o=Cs();s.clearRect(0,0,i,r),s.fillStyle=o.canvasBg,s.fillRect(0,0,i,r);let a=e.points;if(!a||a.length===0){s.fillStyle=o.canvasText,s.font="14px "+o.fontSans,s.textAlign="center",s.textBaseline="middle",s.fillText("No data points yet",i/2,r/2);return}let c=e.y_labels?e.y_labels.length:1,l=iM,u=i-rM,f=sM,d=r-oM,h=u-l,p=d-f;if(h<=0||p<=0)return;let m=a[0].x,g=a[0].x,v=1/0,y=-1/0;for(let T of a){T.xg&&(g=T.x);for(let I of T.ys)Iy&&(y=I)}m===g&&(g=m+1),(!isFinite(v)||!isFinite(y))&&(v=0,y=1);let b=(y-v)*.05||1;v-=b,y+=b;let w=T=>l+(T-m)/(g-m)*h,E=T=>d-(T-v)/(y-v)*p;s.strokeStyle=o.canvasAxis,s.lineWidth=1,s.beginPath(),s.moveTo(l,f),s.lineTo(l,d),s.lineTo(u,d),s.stroke(),s.fillStyle=o.canvasLabel,s.font="10px "+o.fontMono,s.textAlign="right",s.textBaseline="middle";let x=5;for(let T=0;T<=x;T++){let I=v+(y-v)*T/x,N=E(I);s.fillText(this._formatNum(I),l-4,N),T>0&&T1&&e.y_labels){s.font="10px "+o.fontMono,s.textAlign="left",s.textBaseline="top";let T=l+8,I=f+4;for(let N=0;N=1e6?(e/1e6).toFixed(1)+"M":t>=1e3?(e/1e3).toFixed(1)+"k":t>=1?e.toFixed(1):e.toPrecision(3)}_formatCount(e){return e===0?"0":e>=1e6?e/1e6+"M":e>=1e3?e/1e3+"k":String(e)}};var En=class{constructor(e){this.onChange=e,this.roots=[],this._nodeMap=new Map}addFromSpec(e,t=null){let i=this._makeNode(e.id,t,e);if(i.checked=e.checked!==!1,e.children){for(let r of e.children)i.children.push(this.addFromSpec(r,i));i.hasCheckbox&&this._computeParent(i)}return t||this.roots.push(i),i}buildFromNodes(e){this._nodeMap.clear(),this.roots=[];for(let t of e)this._makeNode(t.id,null,t);for(let t of e){let i=this._nodeMap.get(t.id);if(t.parentId!=null&&this._nodeMap.has(t.parentId)){let r=this._nodeMap.get(t.parentId);i.parent=r,r.children.push(i)}else this.roots.push(i)}for(let t=e.length-1;t>=0;t--){let i=this._nodeMap.get(e[t].id);i.hasCheckbox&&i.children.length>0&&this._computeParent(i)}return this.roots}get(e){return this._nodeMap.get(e)}isVisible(e){let t=this.get(e);return t?t.checked:!1}check(e,t){let i=this._nodeMap.get(e);if(i){i.checked=t,i.indeterminate=!1;for(let r of i.children)this._setSubtree(r,t);for(let r=i.parent;r;r=r.parent)r.hasCheckbox&&this._computeParent(r);this.onChange()}}cascadeQuiet(e,t){let i=this._nodeMap.get(e);if(i){i.checked=t,i.indeterminate=!1;for(let r of i.children)this._setSubtree(r,t);for(let r=i.parent;r;r=r.parent)r.hasCheckbox&&this._computeParent(r)}}checkSet(e){for(let[t,i]of Object.entries(e)){let r=this._nodeMap.get(t);r&&(r.checked=i,r.indeterminate=!1)}this._recomputeAllParents(),this.onChange()}mirrorStates(e){this._applyMirror(e),this.onChange()}mirrorStatesQuiet(e){this._applyMirror(e)}_applyMirror(e){for(let[t,i]of Object.entries(e)){let r=this._nodeMap.get(t);r&&(r.checked=!!i.checked,r.indeterminate=!!i.indeterminate)}}forEach(e){let t=i=>{e(i);for(let r of i.children)t(r)};for(let i of this.roots)t(i)}_makeNode(e,t,i){let r={id:e,parent:t,children:[],hasCheckbox:i.hasCheckbox!==!1,checked:i.checked!==!1,indeterminate:!1,data:i.data!=null?i.data:i};return this._nodeMap.set(e,r),r}_checkboxDescendants(e){let t=[];for(let i of e.children)i.hasCheckbox?t.push(i):t.push(...this._checkboxDescendants(i));return t}_computeParent(e){let t=this._checkboxDescendants(e);if(t.length===0)return;let i=t.every(s=>s.checked&&!s.indeterminate),r=t.every(s=>!s.checked&&!s.indeterminate);e.checked=i,e.indeterminate=!i&&!r}_setSubtree(e,t){e.hasCheckbox&&(e.checked=t,e.indeterminate=!1);for(let i of e.children)this._setSubtree(i,t)}_recomputeAllParents(){let e=t=>{for(let i of t.children)e(i);t.hasCheckbox&&t.children.length>0&&this._computeParent(t)};for(let t of this.roots)e(t)}};var aM=["Instance","Module","Instances","Macros","Modules","Area","Local Inst","Local Macros","Local Modules"],ur={MODULE:0,LEAF_GROUP:1,TYPE_GROUP:2,INSTANCE:3,NAME_GROUP:4};function Ls(n){return n===ur.MODULE||n===ur.NAME_GROUP}var Gh=class{constructor(e,t,i){this._app=t,this._redrawAllLayers=i,this._nodes=[],this._nameGrouped=!1,this._nameGroupsCapped=!1,this._rows=[],this._childrenMap=new Map,this._collapsed=new Set,this._moduleState=new Map,this._checkModel=null,this._build(e),t.hierarchyBrowser=this,ue(t)&&this.update()}_build(e){let t=document.createElement("div");t.className="hierarchy-widget";let i=document.createElement("div");i.className="timing-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",ue(this._app)&&(this._updateBtn.style.display="none"),this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",i.appendChild(this._updateBtn),i.appendChild(this._statusLabel),t.appendChild(i),this._tableContainer=document.createElement("div"),this._tableContainer.className="hierarchy-table-container",this._table=document.createElement("table"),this._table.className="timing-table",this._tableContainer.appendChild(this._table),t.appendChild(this._tableContainer),e.element.appendChild(t),this._bindEvents()}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update())}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...",this._statusLabel.textContent="";try{let e=await this._app.websocketManager.request({type:"module_hierarchy"});this._nodes=e.nodes||[],this._nameGrouped=!!e.name_grouped,this._nameGroupsCapped=!!e.name_groups_capped,this._buildTree(),this._readServerColors(),this._computeEffectiveColors(),this._render(),this._statusLabel.textContent=this._statusText(),await this._sendModuleColors()}catch(e){this._statusLabel.textContent="Error: "+e.message}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}_statusText(){let e=this._nodes.filter(r=>Ls(r.node_kind||0)).length;if(!this._nameGrouped)return e+" modules";let i=Math.max(0,e-1)+" groups from instance names \u2014 this design has no module hierarchy";return this._nameGroupsCapped&&(i+=" (truncated: too many groups)"),i}_buildTree(){this._childrenMap.clear(),this._collapsed.clear();for(let t of this._nodes)this._childrenMap.set(t.id,[]);for(let t of this._nodes)t.parent_id>=0&&this._childrenMap.has(t.parent_id)&&this._childrenMap.get(t.parent_id).push(t.id);this._nodeMap=new Map;for(let t of this._nodes)this._nodeMap.set(t.id,t);for(let t of this._nodes){let i=this._childrenMap.get(t.id);if(!i||i.length===0)continue;let r=t.node_kind||0;r===ur.LEAF_GROUP||r===ur.TYPE_GROUP?this._collapsed.add(t.id):Ls(r)&&t.parent_id>=0&&this._collapsed.add(t.id)}this._rows=[];let e=this._nodes.filter(t=>t.parent_id<0);for(let t of e)this._dfs(t.id,0);this._checkModel=new En(()=>{this._checkModel.forEach(t=>{if(!t.hasCheckbox)return;let i=this._moduleState.get(t.data.odb_id);i&&(i.visible=t.checked)}),this._sendModuleColors()}),this._checkModel.buildFromNodes(this._nodes.map(t=>({id:t.id,parentId:t.parent_id,hasCheckbox:Ls(t.node_kind||0)&&t.odb_id!=null,checked:!0,data:t})))}_readServerColors(){this._moduleState.clear();for(let e of this._rows){let t=this._nodeMap.get(e.id);if(!t||!Ls(t.node_kind||0)||t.odb_id==null)continue;let i=t.color||[128,128,128];this._moduleState.set(t.odb_id,{color:i,effectiveColor:i,visible:!0,nodeId:t.id})}}_computeEffectiveColors(){for(let e of this._rows){let t=this._nodeMap.get(e.id);if(!t||!Ls(t.node_kind||0))continue;let i=this._moduleState.get(t.odb_id);if(!i)continue;let r=t.parent_id,s=null;for(;r>=0;){let o=this._nodeMap.get(r);if(!o)break;if(Ls(o.node_kind||0)){let a=this._moduleState.get(o.odb_id);a&&this._collapsed.has(o.id)&&(s=a.effectiveColor)}r=o.parent_id}i.effectiveColor=s||i.color}}async _sendModuleColors(){let e=[];for(let[i,r]of this._moduleState){if(!r.visible)continue;let[s,o,a]=r.effectiveColor;e.push(`${i}:${s},${o},${a},100`)}let t=e.join(";");try{let i=await this._app.websocketManager.request({type:"set_module_colors",colors:t});console.log("set_module_colors:",i.count,"modules,",e.length,"sent")}catch(i){console.error("set_module_colors failed:",i)}this._redrawAllLayers()}_dfs(e,t){this._rows.push({id:e,depth:t});let i=this._childrenMap.get(e)||[];for(let r of i)this._dfs(r,t+1)}_render(){this._table.innerHTML="";let e=document.createElement("thead"),t=document.createElement("tr");for(let r of aM){let s=document.createElement("th");s.textContent=r,t.appendChild(s)}e.appendChild(t),this._table.appendChild(e);let i=document.createElement("tbody");for(let r of this._rows){let s=this._nodeMap.get(r.id);if(!s||this._isHidden(s))continue;let o=document.createElement("tr"),a=s.node_kind||0,l=(this._childrenMap.get(r.id)||[]).length>0,u=this._collapsed.has(r.id);a===ur.LEAF_GROUP||a===ur.TYPE_GROUP?(o.style.fontStyle="italic",o.style.color="var(--fg-disabled)"):a===ur.INSTANCE?o.style.color="var(--fg-secondary)":a===ur.NAME_GROUP&&(o.classList.add("hierarchy-name-group"),o.title="Recovered from instance names \u2014 this design has no module hierarchy");let f=document.createElement("td");if(f.style.paddingLeft=8+r.depth*16+"px",f.style.whiteSpace="nowrap",Ls(a)&&s.odb_id!=null){let p=this._moduleState.get(s.odb_id),m=this._checkModel?this._checkModel.get(s.id):null;if(p&&m){let g=document.createElement("input");g.type="checkbox",g.checked=m.checked,g.indeterminate=m.indeterminate,g.className="hierarchy-module-cb",m.cb=g,g.addEventListener("change",E=>{E.stopPropagation(),this._checkModel.check(s.id,g.checked),this._render()}),f.appendChild(g);let v=document.createElement("span");v.className="hierarchy-color-swatch";let[y,b,w]=p.effectiveColor;v.style.backgroundColor=`rgb(${y},${b},${w})`,f.appendChild(v)}}if(l){let p=document.createElement("span");p.className="hierarchy-arrow",p.textContent=u?"\u25B6":"\u25BC",p.addEventListener("click",m=>{m.stopPropagation(),this._toggleNode(r.id)}),f.appendChild(p)}else{let p=document.createElement("span");p.className="hierarchy-arrow",p.style.visibility="hidden",p.textContent="\u25B6",f.appendChild(p)}let d=document.createElement("span");d.textContent=s.inst_name,f.appendChild(d),o.appendChild(f);let h=[s.module_name,Ko(s.insts),Ko(s.macros),Ko(s.modules),this._fmtArea(s.area),Ko(s.local_insts),Ko(s.local_macros),Ko(s.local_modules)];for(let p of h){let m=document.createElement("td");m.textContent=p,m.style.textAlign="right",o.appendChild(m)}o.children[1].style.textAlign="left",i.appendChild(o)}if(this._rows.length===0){let r=document.createElement("tr"),s=document.createElement("td");s.colSpan=aM.length,s.style.textAlign="center",s.style.color="var(--fg-secondary)",s.textContent=ue(this._app)?"No hierarchy data available":'Click "Update" to load hierarchy',r.appendChild(s),i.appendChild(r)}this._table.appendChild(i),ws(this._table)}_isHidden(e){let t=e.parent_id;for(;t>=0;){if(this._collapsed.has(t))return!0;let i=this._nodeMap.get(t);if(!i)break;t=i.parent_id}return!1}_toggleNode(e){this._collapsed.has(e)?this._collapsed.delete(e):this._collapsed.add(e),this._computeEffectiveColors(),this._render(),this._sendModuleColors()}_fmtArea(e){if(e==null)return"";if(this._app.showDbu){let t=this._app.getDbuPerMicron();return String(Math.round(e*t*t))}return e>=1e6?(e/1e6).toFixed(3)+" mm\xB2":e.toFixed(3)+" \u03BCm\xB2"}};function Ko(n){return n!=null?String(n):""}var mW='',gW='',_W='',yW='',bW='',vW='',xW='',wW='',EW='',SW='',PW='',CW='';function cM(n,e,t){t=t||e;let i=null,r=null,s=null,o=!1,a=10;function c(M,S){return o?Promise.resolve():(o=!0,n.websocketManager.request({type:"set_property",name:M,use_dbu:n.showDbu,...S}).then(L=>{!L.ok&&L.error&&nn(L.error),Me(L),L.ok&&L.bbox&&$e(L.bbox)}).catch(L=>{console.error("set_property failed:",L),nn("Edit failed: "+L),i&&Me(i)}).finally(()=>{o=!1}))}function l(M,S){let L=document.createElement("select");L.className="inspector-editor-select";let F=M.editor.type==="bool"?["True","False"]:M.editor.options||[];for(let k of F){let U=document.createElement("option");U.value=k,U.textContent=k,k===M.value&&(U.selected=!0),L.appendChild(U)}if(!F.includes(M.value)){let k=document.createElement("option");k.value=M.value||"",k.textContent=M.value||"",k.selected=!0,k.disabled=!0,L.insertBefore(k,L.firstChild)}return L.addEventListener("change",()=>{if(S.onPropertyChange){S.onPropertyChange(M.name,L.value);return}if(M.editor.type==="bool")S.onPropertyEdit(M,{value:L.value==="True"});else{let k=(M.editor.options||[]).indexOf(L.value);S.onPropertyEdit(M,{option_index:k,option_name:L.value})}}),L}async function u(M,S){if(!o&&!(M==="Delete"&&!await k3({title:"Delete "+(S.type||"object"),message:"Delete "+(S.type||"object")+' "'+(S.name||"")+'"? This cannot be undone.',confirmLabel:"Delete",danger:!0}))){o=!0;try{let L=await n.websocketManager.request({type:"trigger_action",name:M,use_dbu:n.showDbu});!L.ok&&L.error&&nn(L.error),Me(L.properties?L:null),L.deleted&&_t(),ie(),t()}catch(L){console.error("trigger_action failed:",L),nn("Action failed: "+L)}finally{o=!1}}}function f(M){n.websocketManager.request({...M,use_dbu:n.showDbu}).then(S=>{!S.ok&&S.error&&nn(S.error),Me(S),t()}).catch(S=>{console.error(M.type+" failed:",S)})}function d(){let M=document.getElementById("highlight-picker");M&&M.remove()}function h(M,S){d();let L=n.techData?.highlight_colors||[];if(!L.length)return;let F=document.createElement("div");F.id="highlight-picker";let k=document.createElement("div");if(k.className="highlight-swatch-grid",L.forEach((B,$)=>{let Z=document.createElement("button");Z.className="highlight-swatch",Z.title="Group "+($+1),Z.style.backgroundColor=`rgb(${B[0]}, ${B[1]}, ${B[2]})`,$===S.highlight_group&&Z.classList.add("active"),Z.addEventListener("click",()=>{d(),f({type:"highlight",group:$})}),k.appendChild(Z)}),F.appendChild(k),S.highlight_group>=0){let B=document.createElement("button");B.className="highlight-remove",B.textContent="Remove highlight",B.addEventListener("click",()=>{d(),f({type:"unhighlight"})}),F.appendChild(B)}document.body.appendChild(F);let U=M.getBoundingClientRect();F.style.left=U.left+"px",F.style.top=U.bottom+4+"px";let R=B=>{B.type==="keydown"&&B.key!=="Escape"||B.type==="mousedown"&&F.contains(B.target)||(d(),document.removeEventListener("mousedown",R,!0),document.removeEventListener("keydown",R,!0))};setTimeout(()=>{document.addEventListener("mousedown",R,!0),document.addEventListener("keydown",R,!0)},0)}function p(){if(!n.inspectorEl)return;n.inspectorEl.innerHTML="";let M=document.createElement("div");M.className="stub-panel",M.innerHTML='
Loading\u2026
Fetching properties from server.
',n.inspectorEl.appendChild(M)}async function m(M){let S=n.focusNets.has(M)?"remove":"add";S==="add"?n.focusNets.add(M):n.focusNets.delete(M);try{await n.websocketManager.request({type:"set_focus_nets",action:S,net_name:M})}catch(L){console.error("set_focus_nets failed:",L)}e(),i&&Me(i)}async function g(){n.focusNets.clear();try{await n.websocketManager.request({type:"set_focus_nets",action:"clear",net_name:""})}catch(M){console.error("set_focus_nets clear failed:",M)}e(),i&&Me(i)}async function v(M){let S=n.routeGuideNets.has(M)?"remove":"add";S==="add"?n.routeGuideNets.add(M):n.routeGuideNets.delete(M);try{await n.websocketManager.request({type:"set_route_guides",action:S,net_name:M})}catch(L){console.error("set_route_guides failed:",L)}t(),i&&Me(i)}function y(M,S,L,F){return Ot(M,S,L,F,n.designScale,n.designOriginX,n.designOriginY)}function b(M,S,L){return M+(S-M)*L}function w(M,S,L){return M.map((F,k)=>Math.round(b(F,S[k],L)))}function E(M,S){let L=0;for(;LM[L+1].at;)L++;let F=M[L],k=M[L+1],U=Math.max(0,Math.min(1,(S-F.at)/(k.at-F.at))),R={};for(let B of Object.keys(F))B!=="at"&&(R[B]=Array.isArray(F[B])?w(F[B],k[B],U):b(F[B],k[B],U));return R}function x(M,S,L,F){if(Gl()||typeof requestAnimationFrame!="function")return F(),()=>{};let k=performance.now(),U=!1,R=()=>{if(U)return;let B=performance.now()-k;if(B>=M*S){F();return}L(B%M/M),requestAnimationFrame(R)};return R(),()=>{U=!0}}function T(M,S,L=at.highlight){n.view&&n.view.setOverlay(M,S,{order:L})}let I=null,N=()=>{},D=[255,242,122],H=[{at:0,stroke:[255,246,176],width:7,alpha:1,fill:.28},{at:.55,stroke:[255,255,255],width:5,alpha:1,fill:.06},{at:1,stroke:[255,232,92],width:3,alpha:.95,fill:.14}],W={stroke:[255,232,92],width:3,alpha:1,fill:.14};function V(M,S,L,F){let[k,U,R,B]=y(M,S,L,F),$=a/2**n.view.getZoom(),Z=Math.max(0,($-(R-k))/2),Q=Math.max(0,($-(B-U))/2);return[k-Z,U-Q,R+Z,B+Q]}function X(M){I&&T("hover",I.map(([S,L,F,k])=>({kind:"rect",rect:V(S,L,F,k),stroke:Nt(M.stroke,M.alpha),width:M.width,fill:Nt(D,M.fill)})))}function Y(){X(W)}function ie(){N(),I=null,T("hover",null),n.view?.off("zoom",Y)}function oe(){ie(),n.websocketManager.request({type:"hover",select_id:-1}).then(()=>{}).catch(()=>{})}function zt(M){ie(),!(!n.view||!n.designScale||!M||M.length===0)&&(I=M,n.view.on("zoom",Y),N=x(900,3,S=>X(E(H,1-Math.pow(1-S,2))),()=>X(W)))}function je(M,S){M.classList.add("inspector-link"),M.addEventListener("click",L=>{L.stopPropagation(),si(S)}),M.addEventListener("mouseenter",()=>{s!==null&&(n.websocketManager.cancel(s),s=null);let L=n.websocketManager.request({type:"hover",select_id:S});s=L.requestId,L.then(F=>{s=null,zt(F.rects||[]),t()}).catch(()=>{s=null})}),M.addEventListener("mouseleave",()=>{oe(),t()})}function sn(M){let S=M>0?"select_next":"select_prev";r!==null&&(n.websocketManager.cancel(r),r=null),p();let L=St(n),F=n.websocketManager.request({type:S,use_dbu:n.showDbu});r=F.requestId,F.then(k=>{if(r=null,!!Dt(n,L)){if(k.error){console.error("Selection cycle error:",k.error),Me(i);return}if(Me(k),k.type==="Inst"&&k.name&&(n.selectedInstanceName=k.name,n.schematicWidget&&n.schematicWidget.refresh()),ie(),_t(),k.bbox&&n.view&&n.designScale){let[U,R,B,$]=k.bbox;k.type!=="Inst"&&Sn(U,R,B,$,k.type),k.selection_count>1?Ut(k.bbox):$e(k.bbox,k.type)}e()}}).catch(k=>{r=null,console.error("Selection cycle failed:",k),Me(i)})}function si(M){r!==null&&(n.websocketManager.cancel(r),r=null),p();let S=St(n),L=n.websocketManager.request({type:"inspect",select_id:M,use_dbu:n.showDbu});r=L.requestId,L.then(F=>{if(r=null,!!Dt(n,S)){if(F.error){console.error("Inspect error:",F.error);return}if(Me(F),ie(),_t(),F.bbox&&n.view&&n.designScale){let[k,U,R,B]=F.bbox;F.type!=="Inst"&&Sn(k,U,R,B,F.type),$e(F.bbox,F.type)}t()}}).catch(F=>{r=null,console.error("Inspect failed:",F)})}function oi(){r!==null&&(n.websocketManager.cancel(r),r=null),p();let M=St(n),S=n.websocketManager.request({type:"inspect_back",use_dbu:n.showDbu});r=S.requestId,S.then(L=>{if(r=null,!!Dt(n,M)){if(L.error){console.error("Inspect back error:",L.error);return}if(Me(L),ie(),_t(),L.bbox&&n.view&&n.designScale){if(L.type!=="Inst"){let[F,k,U,R]=L.bbox;Sn(F,k,U,R,L.type)}$e(L.bbox,L.type)}t()}}).catch(L=>{r=null,console.error("Inspect back failed:",L)})}let on=null;function Ri(){let M=on&&n.designScale&&!(n.visibility&&n.visibility.highlight_selected===!1);T("selection",M?[{kind:"rect",rect:y(...on),stroke:Nt("#ff0"),width:2,dash:[6,4]}]:null,at.selection)}function _t(){on=null,Ri()}function Sn(M,S,L,F,k){on=k==="Net"?null:[M,S,L,F],Ri()}let Pn=null,Cn=[{at:0,alpha:0,fill:0},{at:.5,alpha:1,fill:.28},{at:1,alpha:0,fill:0}];function gr(){Pn&&(Pn(),Pn=null),T("pulse",null)}function $e(M,S){if(!M||!n.view||!n.designScale||(Ge!==null&&ai(),gr(),n.visibility&&n.visibility.highlight_selected===!1)||S==="Net")return;let L=y(...M);Pn=x(350,3,F=>{let k=E(Cn,.5-.5*Math.cos(Math.PI*F));T("pulse",[{kind:"rect",rect:L,stroke:Nt("#ff0",k.alpha),width:3,fill:Nt("#ff0",k.fill)}])},()=>{Pn=null,T("pulse",null)})}let Ge=null;function _r(M,S){T("anim",[{kind:"rect",rect:M,stroke:Nt("#ff0"),width:S,fill:Nt("#ff0",S===1?.39:0)}])}function ai(){Ge!==null&&(clearInterval(Ge),Ge=null),T("anim",null)}function Ut(M,{repeats:S=6,intervalMs:L=300}={}){if(!M||!n.view||!n.designScale)return;if(ai(),Gl()){$e(M);return}let F=y(...M);_r(F,1);let k=0,U=S>0?S*3:1/0;Ge=setInterval(()=>{if(k+=1,k>=U){ai();return}_r(F,k%3+1)},L)}n.clearSelectionPulse=gr,n.renderSelectionOutline=Ri,n.clearSelectionOutline=_t;function ci(M,S,L){let F=document.createElement("div");F.className="inspector-group";let k=document.createElement("div");k.className="inspector-group-header";let U=document.createElement("span");U.className="vis-arrow";let R=document.createElement("span");if(R.className="inspector-prop-name",R.textContent=M,R.title=M,k.appendChild(U),k.appendChild(R),S!==null){let $=document.createElement("span");$.className="inspector-count",$.textContent=`(${S})`,k.appendChild($)}F.appendChild(k);let B=document.createElement("div");return B.className="inspector-group-children"+(L?" collapsed":""),U.textContent=L?"\u25B6":"\u25BC",F.appendChild(B),k.addEventListener("click",()=>{B.classList.toggle("collapsed"),U.textContent=B.classList.contains("collapsed")?"\u25B6":"\u25BC"}),{group:F,header:k,arrow:U,body:B}}function Ve(M){let S=M.column_headers||[],L=M.row_headers||[],F=M.data||[],k=S.some($=>$!==""),U=L.some($=>$!==""),R=document.createElement("table");if(R.className="inspector-table",k){let $=document.createElement("thead"),Z=document.createElement("tr");U&&Z.appendChild(document.createElement("th"));for(let Q of S){let de=document.createElement("th");de.textContent=Q,Z.appendChild(de)}$.appendChild(Z),R.appendChild($)}let B=document.createElement("tbody");return F.forEach(($,Z)=>{let Q=document.createElement("tr");if(U){let de=document.createElement("th");de.textContent=L[Z]||"",Q.appendChild(de)}for(let de of $){let _e=document.createElement("td");_e.textContent=de,Q.appendChild(_e)}B.appendChild(Q)}),R.appendChild(B),R}function li(M,S){if(M.table){let R=(M.table.data||[]).length,{group:B,body:$}=ci(M.name,R,R>=10),Z=document.createElement("div");return Z.className="inspector-table-scroll",Z.appendChild(Ve(M.table)),$.appendChild(Z),B}if(M.children){let R=M.children.length<10,{group:B,body:$}=ci(M.name,M.children.length,!R);for(let Z of M.children)$.appendChild(li(Z,S));return B}let L=document.createElement("div");L.className="inspector-prop";let F=document.createElement("span");F.className="inspector-prop-name",F.textContent=M.name||"",F.title=M.name||"";let k=document.createElement("span");k.className="inspector-prop-value",k.textContent=M.value||"",L.appendChild(F),L.appendChild(k);let U=M.editable&&S&&(S.onPropertyEdit||S.onPropertyChange)&&M.editor&&(M.editor.type==="list"||M.editor.type==="bool");if(U&&M.value_select_id===void 0)L.replaceChild(l(M,S),k);else if(U){let R=document.createElement("button");R.className="inspector-edit-btn",R.title="Edit "+M.name,R.textContent="\u270E",R.addEventListener("click",B=>{B.stopPropagation();let $=l(M,S);L.replaceChild($,k),R.remove(),$.focus()}),L.appendChild(R)}else M.editable&&S&&(S.onPropertyChange||S.onPropertyEdit)&&(k.contentEditable=!0,k.classList.add("inspector-editable"),k.addEventListener("blur",()=>{let R=k.textContent;if(R!==M.value){if(S.onPropertyChange){S.onPropertyChange(M.name,R);return}if(M.editor&&M.editor.type==="number"){let B=Number(R);if(R.trim()===""||Number.isNaN(B)){nn("Not a number: "+R),k.textContent=M.value;return}S.onPropertyEdit(M,{value:B});return}S.onPropertyEdit(M,{value:R})}}),k.addEventListener("keydown",R=>{R.key==="Enter"&&(R.preventDefault(),k.blur()),R.key==="Escape"&&(k.textContent=M.value,k.blur())}));return M.name_select_id!==void 0&&M.value_select_id===void 0?(je(L,M.name_select_id),F.classList.add("inspector-link")):M.name_select_id!==void 0&&je(F,M.name_select_id),M.value_select_id!==void 0&&je(k,M.value_select_id),L}let an=140,Ii=60,Bi=500,Oi=an;function Rs(){n.inspectorEl&&n.inspectorEl.style.setProperty("--inspector-name-w",Oi+"px")}function Tn(){let M=document.createElement("div");return M.className="inspector-col-resizer",M.title="Drag to resize the name column",M.addEventListener("mousedown",S=>{S.preventDefault();let L=S.clientX,F=Oi;M.classList.add("dragging");let k=R=>{Oi=Math.max(Ii,Math.min(Bi,F+R.clientX-L)),Rs()},U=()=>{M.classList.remove("dragging"),document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",U)};document.addEventListener("mousemove",k),document.addEventListener("mouseup",U)}),M}function $t(M){!M||!n.view||!n.designScale||n.view.fitWorldRect(y(...M),{padding:[20,20]})}function Me(M){if(!n.inspectorEl)return;if(i=M,n.inspectorEl.innerHTML="",!M||!M.properties||M.properties.length===0){ai();let k=document.createElement("div");k.className="stub-panel",k.innerHTML='
Inspector
Select an object in the layout to inspect its properties.
',n.inspectorEl.appendChild(k);return}if(!M.onPropertyChange&&!M.onPropertyEdit&&!ue(n)&&(M.onPropertyEdit=(k,U)=>c(k.name,U)),M){let k=document.createElement("div");k.className="inspector-toolbar";let U=document.createElement("button");if(U.className="or-btn or-btn-icon",U.title="Back",U.innerHTML=yW,U.disabled=!M.can_navigate_back,U.addEventListener("click",()=>oi()),k.appendChild(U),M.bbox){let R=document.createElement("button");R.className="or-btn or-btn-icon",R.title="Zoom to",R.innerHTML=_W,R.addEventListener("click",()=>$t(M.bbox)),k.appendChild(R)}if(M.type==="Net"&&M.name){let R=n.focusNets.has(M.name),B=document.createElement("button");B.className="or-btn or-btn-icon",B.title=R?"De-focus net":"Focus net",B.innerHTML=R?vW:bW,B.addEventListener("click",()=>m(M.name)),k.appendChild(B)}if(M.type==="Net"&&M.name&&M.has_guides){let R=n.routeGuideNets.has(M.name),B=document.createElement("button");B.className="or-btn or-btn-icon",B.title=R?"Hide route guides":"Show route guides",B.innerHTML=R?wW:xW,B.addEventListener("click",()=>v(M.name)),k.appendChild(B)}if(M.type==="Net"&&M.name&&n.showInsertBufferDialog){let R=document.createElement("button");R.className="or-btn or-btn-icon",R.title="Insert buffer",R.innerHTML=CW,R.addEventListener("click",()=>n.showInsertBufferDialog(M.name)),k.appendChild(R)}if(n.focusNets.size>0){let R=document.createElement("button");R.className="or-btn or-btn-icon",R.title="Clear focus nets",R.innerHTML=EW,R.addEventListener("click",()=>g()),k.appendChild(R)}if(typeof M.highlight_group=="number"&&!ue(n)&&(n.techData?.highlight_colors||[]).length){let R=document.createElement("button");R.className="or-btn or-btn-icon inspector-highlight-btn";let B=M.highlight_group;if(R.title=B>=0?"Highlight group "+(B+1):"Add to highlight group",R.innerHTML=gW,B>=0){let $=n.techData.highlight_colors[B];R.style.backgroundColor=`rgba(${$[0]}, ${$[1]}, ${$[2]}, 0.45)`,R.style.borderColor=`rgb(${$[0]}, ${$[1]}, ${$[2]})`}R.addEventListener("click",()=>h(R,M)),k.appendChild(R)}if(Array.isArray(M.actions)&&!ue(n))for(let R of M.actions){let B=document.createElement("button");B.className="or-btn inspector-action-btn",B.title=R,R==="Delete"?(B.classList.add("or-btn-icon","or-btn-danger-hover"),B.innerHTML=mW):(B.classList.add("or-btn-sm"),B.textContent=R),B.addEventListener("click",()=>u(R,M)),k.appendChild(B)}n.inspectorEl.appendChild(k)}let S=M.selection_count||0,L=typeof M.selection_index=="number"?M.selection_index:-1;if(S>1&&L>=0){let k=document.createElement("div");k.className="inspector-selection-nav";let U=document.createElement("button");U.className="or-btn or-btn-icon",U.title="Previous (Shift+click to multi-select)",U.innerHTML=SW,U.addEventListener("click",()=>sn(-1));let R=document.createElement("span");R.className="inspector-selection-label",R.textContent=L+1+" / "+S;let B=document.createElement("button");B.className="or-btn or-btn-icon",B.title="Next",B.innerHTML=PW,B.addEventListener("click",()=>sn(1)),k.appendChild(U),k.appendChild(R),k.appendChild(B),n.inspectorEl.appendChild(k)}let F=document.createElement("div");F.className="inspector-rows";for(let k of M.properties)F.appendChild(li(k,M));F.appendChild(Tn()),n.inspectorEl.appendChild(F),Rs()}function yr(M){let S=document.createElement("div");S.className="inspector",n.inspectorEl=S,M.element.appendChild(S),Me(null)}function Ae(){if(i){if(i.type==="Ruler"){n.rulerManager&&n.rulerManager._selectedRulerId!==null&&n.rulerManager._selectRuler(n.rulerManager._selectedRulerId);return}n.websocketManager&&si(-1)}}return{createInspector:yr,updateInspector:Me,highlightBBox:Sn,pulseHighlight:$e,animateSelection:Ut,stopSelectionAnimation:ai,navigateInspector:si,refreshInspector:Ae}}var Vh=class{constructor(e,t,i){this._app=t,this._refreshOverlay=i||(()=>{}),this._data={selection:[],groups:[],truncated:!1},this._tab="selected",this._filter="",this._sortKey=null,this._sortAsc=!0,this._pendingRefresh=null,this._inFlight=!1,this._staleWhileInFlight=!1,this._visible=!0,this._el=document.createElement("div"),this._el.className="selection-browser",e.element.appendChild(this._el),e.on?.("show",()=>{this._visible=!0,this.refresh()}),e.on?.("hide",()=>{this._visible=!1}),e.on?.("destroy",()=>{this._visible=!1,this._staleWhileInFlight=!1,this._pendingRefresh!==null&&(clearTimeout(this._pendingRefresh),this._pendingRefresh=null)}),this._render(),this.refresh()}scheduleRefresh(){!this._visible||this._pendingRefresh!==null||(this._pendingRefresh=setTimeout(()=>{this._pendingRefresh=null,this.refresh()},150))}refresh(){if(!this._visible||ue(this._app))return;if(this._inFlight){this._staleWhileInFlight=!0;return}this._inFlight=!0;let e=()=>{this._inFlight=!1,this._staleWhileInFlight&&(this._staleWhileInFlight=!1,this.refresh())};this._app.websocketManager.request({type:"list_selection"}).then(t=>{t.ok&&(this._data=t,this._render()),e()}).catch(e)}_entries(){let e;this._tab==="selected"?e=(this._data.selection||[]).map((i,r)=>({row:i,index:r,group:-1})):e=(this._data.groups||[]).flatMap((i,r)=>i.map((s,o)=>({row:s,index:o,group:r})));let t=this._filter.trim().toLowerCase();if(t&&(e=e.filter(({row:i})=>(i.name||"").toLowerCase().includes(t)||(i.type||"").toLowerCase().includes(t))),this._sortKey){let i=this._sortKey,r=this._sortAsc?1:-1;e=e.slice().sort((s,o)=>r*String(s.row[i]||"").localeCompare(String(o.row[i]||"")))}return e}_fmtCoord(e){if(this._app.showDbu)return String(e);let t=this._app.getDbuPerMicron?this._app.getDbuPerMicron():1e3;return(e/t).toFixed(3)}_fmtBounds(e){if(!e)return"";let[t,i,r,s]=e;return`(${this._fmtCoord(t)}, ${this._fmtCoord(i)}), (${this._fmtCoord(r)}, ${this._fmtCoord(s)})`}_inspectRow(e,t){let i=e.group<0?{type:"inspect_selection",index:e.index,use_dbu:this._app.showDbu}:{type:"inspect_group",group:e.group,index:e.index,use_dbu:this._app.showDbu};this._app.websocketManager.request(i).then(r=>{if(!r.ok){this.refresh();return}this._app.updateInspector&&this._app.updateInspector(r),t&&this._app.focusComponent&&this._app.focusComponent("Inspector"),this._refreshOverlay()}).catch(()=>{})}_deselectRow(e){this._app.websocketManager.request({type:"deselect",index:e.index}).then(()=>{this.refresh(),this._refreshOverlay()}).catch(()=>{})}_clearHighlights(){this._app.websocketManager.request({type:"clear_highlights",group:-1}).then(()=>{this.refresh(),this._refreshOverlay(),this._app.refreshInspector&&this._app.refreshInspector()}).catch(()=>{})}_zoomToBBox(e){if(!e||!this._app.designScale||!this._app.view)return;let[t,i,r,s]=e,o=this._app.getDbuPerMicron?this._app.getDbuPerMicron():1e3,a=Math.min(10*o,2*Math.max(r-t,s-i));this._app.view.fitWorldRect(Ot(t-a,i-a,r+a,s+a,this._app.designScale,this._app.designOriginX,this._app.designOriginY))}_render(){this._app.stopSelectionAnimation&&this._app.stopSelectionAnimation(),this._el.innerHTML="";let e=(this._data.selection||[]).length,t=(this._data.groups||[]).reduce((o,a)=>o+a.length,0),i=document.createElement("div");i.className="sb-tabs";for(let[o,a,c]of[["selected","Selected",e],["highlighted","Highlighted",t]]){let l=document.createElement("button");l.className="sb-tab"+(this._tab===o?" active":""),l.textContent=`${a} (${c})`,l.addEventListener("click",()=>{this._tab=o,this._render()}),i.appendChild(l)}let r=document.createElement("button");if(r.className="or-btn or-btn-sm sb-tool",r.title="Refresh",r.textContent="\u27F3",r.addEventListener("click",()=>this.refresh()),i.appendChild(r),this._tab==="highlighted"&&t>0){let o=document.createElement("button");o.className="or-btn or-btn-sm sb-tool",o.title="Clear all highlights",o.textContent="Clear",o.addEventListener("click",()=>this._clearHighlights()),i.appendChild(o)}this._el.appendChild(i);let s=document.createElement("input");if(s.type="text",s.className="sb-filter",s.placeholder="Filter by name or type\u2026",s.value=this._filter,s.addEventListener("input",()=>{this._filter=s.value,this._renderTable()}),this._el.appendChild(s),this._data.truncated){let o=document.createElement("div");o.className="sb-truncated",o.textContent="List truncated \u2014 showing the first 1000 entries per set.",this._el.appendChild(o)}this._tableWrap=document.createElement("div"),this._tableWrap.className="sb-table-wrap",this._el.appendChild(this._tableWrap),this._renderTable()}_renderTable(){this._tableWrap.innerHTML="";let e=this._entries();if(!e.length){let c=document.createElement("div");c.className="sb-empty",c.textContent=this._tab==="selected"?"Nothing selected.":"Nothing highlighted.",this._tableWrap.appendChild(c);return}let t=document.createElement("table");t.className="sb-table";let i=document.createElement("thead"),r=document.createElement("tr"),s=[["name","Object"],["type","Type"],[null,"Bounds"]];this._tab==="highlighted"&&s.push([null,"Group"]),s.push([null,""]);for(let[c,l]of s){let u=document.createElement("th");u.textContent=l,c&&(u.classList.add("sb-sortable"),this._sortKey===c&&(u.textContent+=this._sortAsc?" \u25B2":" \u25BC"),u.addEventListener("click",()=>{this._sortKey===c?this._sortAsc=!this._sortAsc:(this._sortKey=c,this._sortAsc=!0),this._renderTable()})),r.appendChild(u)}i.appendChild(r),t.appendChild(i);let o=document.createElement("tbody"),a=this._app.techData?.highlight_colors||[];for(let c of e){let l=document.createElement("tr");l.className="sb-row";let u=document.createElement("td");u.textContent=c.row.name||"";let f=document.createElement("td");f.textContent=c.row.type||"";let d=document.createElement("td");if(d.textContent=this._fmtBounds(c.row.bbox),l.appendChild(u),l.appendChild(f),l.appendChild(d),this._tab==="highlighted"){let p=document.createElement("td"),m=document.createElement("span");m.className="sb-chip";let g=a[c.group];g&&(m.style.backgroundColor=`rgb(${g[0]}, ${g[1]}, ${g[2]})`),p.appendChild(m),p.appendChild(document.createTextNode(` Group ${c.group+1}`)),l.appendChild(p)}let h=document.createElement("td");if(h.className="sb-actions",c.row.bbox){let p=document.createElement("button");p.className="sb-row-btn",p.title="Zoom to",p.textContent="\u2316",p.addEventListener("click",m=>{m.stopPropagation(),this._zoomToBBox(c.row.bbox)}),h.appendChild(p)}if(this._tab==="selected"){let p=document.createElement("button");p.className="sb-row-btn",p.title="De-select",p.textContent="\u2715",p.addEventListener("click",m=>{m.stopPropagation(),this._deselectRow(c)}),h.appendChild(p)}l.appendChild(h),l.addEventListener("click",()=>this._inspectRow(c,!1)),l.addEventListener("dblclick",()=>this._inspectRow(c,!0)),c.row.bbox&&(l.addEventListener("mouseenter",()=>{this._app.animateSelection&&this._app.animateSelection(c.row.bbox,{repeats:0})}),l.addEventListener("mouseleave",()=>{this._app.stopSelectionAnimation&&this._app.stopSelectionAnimation()})),o.appendChild(l)}t.appendChild(o),this._tableWrap.appendChild(t),ws(t)}};var uM="options-dialog",lM=[{label:"System default",value:""},{label:"Sans-serif",value:"sans-serif"},{label:"Serif",value:"serif"},{label:"Monospace",value:"monospace"},{label:"Helvetica / Arial",value:"Helvetica, Arial, sans-serif"},{label:"Georgia",value:"Georgia, 'Times New Roman', serif"},{label:"Courier",value:"'Courier New', Courier, monospace"}],TW=100,Wh=70,jh=200;function Wl(n){let e=n===""||n===null?NaN:Math.round(Number(n));return Number.isFinite(e)?Math.min(jh,Math.max(Wh,e)):TW}function fM(n){let{overlay:e,close:t,okBtn:i,showError:r}=Xo("Arrow keys scroll step",`
+ min="${zl}" max="${Ul}" step="1" + value="${$l(n.arrowStep)}">
How far one arrow-key press pans the layout. - Default ${Do}.
`,"Apply",xl),l=e.querySelector(".opt-step");l.focus(),l.select();function h(){let u=l.value.trim(),f=Number(u);if(u===""||!Number.isFinite(f)){r("Step must be a number.");return}if(f_n){r(`Step must be between ${mn} and ${_n} px.`);return}s.setArrowStep(f),i()}return o.addEventListener("click",h),l.addEventListener("keydown",u=>{u.key==="Enter"&&(u.preventDefault(),h())}),{close:i}}function Ll(s){let e=s.fontFamily||"",i=wl.some(b=>b.value===e),o=wl.map(b=>``).join("")+(i?"":``),{overlay:r,close:l,okBtn:h,showError:u}=Zi("Application font",` + Default ${Kb}.
`,"Apply",uM),s=e.querySelector(".opt-step");s.focus(),s.select();function o(){let a=s.value.trim(),c=Number(a);if(a===""||!Number.isFinite(c)){r("Step must be a number.");return}if(cUl){r(`Step must be between ${zl} and ${Ul} px.`);return}n.setArrowStep(c),t()}return i.addEventListener("click",o),s.addEventListener("keydown",a=>{a.key==="Enter"&&(a.preventDefault(),o())}),{close:t}}function dM(n){let e=n.fontFamily||"",t=lM.some(p=>p.value===e),i=lM.map(p=>``).join("")+(t?"":``),{overlay:r,close:s,okBtn:o,showError:a}=Xo("Application font",`
- +
+ value="${t?"":ov(e)}">
+ min="${Wh}" max="${jh}" step="5" + value="${Wl(n.fontScale)}">
The quick brown fox jumps over the lazy dog 0123456789
Applies to the panels, menus and console. Text drawn into the layout is rendered on the server and is not - affected.
`,"Apply",xl),f=r.querySelector(".opt-family"),_=r.querySelector(".opt-custom"),y=r.querySelector(".opt-scale"),g=r.querySelector(".opt-preview");function v(){g.style.fontFamily=_.value.trim()||f.value,g.style.fontSize=`calc(13px * ${vn(y.value)/100})`}for(let b of[f,_,y])b.addEventListener("input",v);v();function w(){let b=y.value.trim(),C=Number(b);if(b===""||!Number.isFinite(C)){u("Size must be a number.");return}if(Cws){u(`Size must be between ${bs} and ${ws} %.`);return}s.setAppFont({family:_.value.trim()||f.value,scale:C}),l()}h.addEventListener("click",w);for(let b of[_,y])b.addEventListener("keydown",C=>{C.key==="Enter"&&(C.preventDefault(),w())});return{close:l}}function qo(s){return String(s).replace(/&/g,"&").replace(/"/g,""").replace(//g,">")}var Md='',Td='';function Wi(s){let e=document.createElement("span");return e.className="vis-name",s!=null&&(e.textContent=s),e}function Ve(){let s=document.createElement("span");return s.className="vis-sel-cb vis-sel-spacer",s}function kl(){let s=document.createElement("div");s.className="display-controls-header",s.appendChild(Wi(""));for(let[e,i]of[[Md,"Visible"],[Td,"Selectable"]]){let o=document.createElement("span");o.className="vis-header-icon",o.title=i,o.innerHTML=e,s.appendChild(o)}return s}var xs=class{constructor(e,i,o){this.visibility=e,this.selectability=i,this.onChange=o;let r=()=>{this._syncAll(),this.onChange()};this.model=new we(r),this.selModel=new we(r)}add(e){return this.model.addFromSpec(this._enrichSpec(e,"")),this.selModel.addFromSpec(this._enrichSelSpec(e,"",!1)),this}render(e){for(let i of this.model.roots)e.appendChild(this._dom(i));this._syncAll()}_nodeId(e,i){let o=e.key||e.label;return i?i+"/"+o:o}_enrichSpec(e,i){let o=this._nodeId(e,i),r={id:o,data:e};return e.children?r.children=e.children.map(l=>this._enrichSpec(l,o)):e.key&&(r.checked=!!this.visibility[e.key]),e.disabled!=null&&(r.disabled=e.disabled),r}_enrichSelSpec(e,i,o){let r=e.addSelectable===!0?!0:e.addSelectable===!1?!1:o,l=this._nodeId(e,i),h={id:l,data:e,hasCheckbox:!1};if(e.children){h.children=e.children.map(f=>this._enrichSelSpec(f,l,r));let u=f=>f.some(_=>_.hasCheckbox||_.children&&u(_.children));h.hasCheckbox=u(h.children),h.hasCheckbox&&(h.checked=!0)}else if(e.key){let u=e.selectable===!0||e.selectable!==!1&&o;h.hasCheckbox=u,u&&(h.checked=this.selectability[e.key]!==!1)}return h}_syncAll(){this.model.forEach(e=>{e.cb&&(e.cb.checked=e.checked,e.cb.indeterminate=e.indeterminate);let i=e.data;i.key&&(this.visibility[i.key]=e.checked),i.visKey&&(this.visibility[i.visKey]=e.checked||e.indeterminate)}),this.selModel.forEach(e=>{if(!e.hasCheckbox)return;let i=e.data;if(i.key&&(this.selectability[i.key]=e.checked),!e.selCb)return;e.selCb.checked=e.checked,e.selCb.indeterminate=e.indeterminate;let o=this.model.get(e.id),r=o&&!o.checked&&!o.indeterminate;e.selCb.disabled=r,e.selLabel&&e.selLabel.classList.toggle("vis-sel-disabled",r)}),this.model.forEach(e=>{let i=e.data;if(i.disabledBy&&e.el){let o=!this.visibility[i.disabledBy];e.el.classList.toggle("disabled",o)}})}_buildSelCheckbox(e){let i=this.selModel.get(e.id);if(!i||!i.hasCheckbox)return null;let o=document.createElement("input");return o.type="checkbox",o.className="vis-sel-cb",o.title="Selectable",o.addEventListener("change",()=>{this.selModel.check(i.id,o.checked)}),i.selCb=o,o}_dom(e){let i=e.data,o=document.createElement("input");o.type="checkbox",o.className="vis-cb",o.title="Visible",e.cb=o,o.addEventListener("change",()=>this.model.check(e.id,o.checked));let r=this._buildSelCheckbox(e),l=g=>{if(g.appendChild(o),r){g.appendChild(r);let v=this.selModel.get(e.id);v&&(v.selLabel=g)}else g.appendChild(Ve())};if(!e.children.length){let g=document.createElement("div");g.className="vis-leaf";let v=document.createElement("span");return v.className="vis-arrow",v.style.visibility="hidden",v.textContent="\u25B6",g.appendChild(v),g.appendChild(Wi(i.label)),l(g),e.el=g,g}let h=document.createElement("div");h.className="vis-group";let{header:u,arrow:f,name:_}=ui();_.textContent=i.label,l(u),h.appendChild(u);let y=document.createElement("div");y.className="vis-group-children",i.disabled&&y.classList.add("disabled");for(let g of e.children)y.appendChild(this._dom(g));return h.appendChild(y),pi(u,f,y,!0),h}};function bn(s,e,i,o){let r=new Set,l=Math.max(0,s-e),h=Math.min(o-1,s+i);for(let u=l;u<=h;u++)r.add(u);return r}function Pd(s){let e={};for(let[i,o]of Object.entries(s||{}))o!==1&&(e[i]=o);return e}function Cs(s,e){return(s||[]).some(i=>i.every(o=>!!e[o]))}function Ad(s,e){return s.map(i=>{let o=!e.has(i.path);return{id:i.path,parentId:i.parent!=null?i.parent:null,hasCheckbox:i.parent!=null,checked:o,data:{path:i.path,name:i.name,master:i.master,depth:i.depth}}})}var Sl=[[70,130,210],[200,50,50],[50,180,80],[200,160,40],[160,60,200],[40,190,190],[220,120,50],[180,70,150]];function El(s,e,i,o,r,l,h){if(!s.displayControlsEl)return;s.displayControlsEl.innerHTML="",s.allLayers=[],s.displayControlsEl.appendChild(kl());let u=s.mergeTiles?s.MergedTileLayer:null,f=new Set;function _(){for(let E of f)E.refreshTiles();f.clear()}function y(E,$){if(!u){let U=new o(s.websocketManager,E,{opacity:1,zIndex:$});return U._orShow=()=>U.addTo(s.map),U._orHide=()=>s.map.removeLayer(U),U}let F={layer:E,opacity:1,visible:!1};return{_orItem:F,_orPane:null,refreshTiles(){this._orPane&&(f.add(this._orPane),_())},_orShow(){Po(F,!0)&&this._orPane&&f.add(this._orPane)},_orHide(){Po(F,!1)&&this._orPane&&f.add(this._orPane)}}}function g(E,$,F,U){let z=new o(s.websocketManager,E,{zIndex:F});return U&&z.addTo(s.map),$&&(s[$]=z),s.allLayers.push(z),z}g("_instances",null,0,!0),g("_pins","pinsLayer",1,e.pins),g("_modules","modulesLayer",2,e.module_view),s.overlayLayers=(r&&r.overlays||[]).map(E=>({def:E,layer:g(E.name,null,E.z_index,Cs(E.shown_by,e))}));let v=[],w=[],b=null,C=new Set,R=new Set;try{let E=window.sessionStorage.getItem("or_hidden_layers");E&&(C=new Set(JSON.parse(E)))}catch{}try{let E=window.sessionStorage.getItem("or_nonselectable_layers");E&&(R=new Set(JSON.parse(E)))}catch{}try{let E=window.sessionStorage.getItem("or_layer_patterns");E&&Object.assign(s.layerPatterns,JSON.parse(E))}catch{}function A(){try{window.sessionStorage.setItem("or_layer_patterns",JSON.stringify(Pd(s.layerPatterns)))}catch{}}function M(E,$,F){F===1?delete s.layerPatterns[E]:s.layerPatterns[E]=F,A(),$&&typeof $.refreshTiles=="function"&&$.refreshTiles()}let q=[{label:"Solid",value:1},{label:"Diagonal",value:2},{label:"Cross",value:3},{label:"Dots",value:4},{label:"None (no fill)",value:0}],G=0,dt=3;function gt(E,$="layers",F=void 0){let U=[],z=E.type==="category"?F:E.path,W=E.flipped===!0,Z=E.instances||[],D=Z.filter($t=>$t.type!=="category"),X=Z.filter($t=>$t.type==="category"),j=E.layers||[],vt=G;G+=j.length;function mt($t,le){let K=$t.map((st,lt)=>lt);le&&K.reverse(),K.forEach(st=>{let lt=$t[st],Nt=$+"/"+(lt.name||st);U.push(gt(lt,Nt,z))})}function St(){(W?j.map((le,K)=>K).reverse():j.map((le,K)=>K)).forEach(le=>{let K=j[le],st=K.name||K,lt=vt+le,Nt=dt++,se=y(st,Nt),Ze=`${$}/${st}`;se._nodeId=Ze;let kn=!C.has(Ze);kn&&(se._orShow(),s.visibleLayers.add(Ze),s.visibleLayerNames.add(st)),u||s.allLayers.push(se),v.push(se),w.push(Ze),U.push({id:Ze,data:{name:st,layer:se,color:K.color,colorIndex:lt,nodeId:Ze,ownerChipletPath:z},checked:kn})})}mt(D,!1),W&&St(),mt(X,W),W||St();let Tt={name:E.name,isInstance:!0};return E.type==="category"&&(E.name==="Implant"||E.name==="Other")&&(Tt.startCollapsed=!0),E.type!=="category"&&(Tt.chipletPath=E.path),{id:$,data:Tt,children:U}}let it;if(r.layer_hierarchy?it=gt(r.layer_hierarchy,"layers_parent"):it={id:"layers_parent",children:r.layers.map((E,$)=>{let F=y(E,$+3),U=`layers_parent/${E}`;F._nodeId=U;let z=!C.has(U);return z&&(F._orShow(),s.visibleLayers.add(U),s.visibleLayerNames.add(E)),u||s.allLayers.push(F),v.push(F),w.push(U),{id:U,data:{name:E,layer:F,colorIndex:$,nodeId:U},checked:z}})},u&&v.length>0){let F=function(){let{width:X,height:j}=Ia(s.map.getContainer()),vt=ve(),mt=Aa(X,j,vt),St=Pa(vt,s.tileDpr?s.tileDpr():1);return{count:s.mergeGroupCount||Na({budgetBytes:Ba($,mt,St),tilesPerPane:mt,bytesPerTile:St,paneCount:E.length}),tilesPerPane:mt,perTile:St}},U=function(X,j,vt){let mt=(X+hs)*j*vt;return{layers:E.length,groups:X,tilesPerPane:j,unmergedPanes:hs,budgetMB:Math.round($/(1024*1024)),estimatedMB:Math.round(mt/(1024*1024))}},z=function(X,j){let vt=0;j.forEach((mt,St)=>{for(let Tt=0;TtX._orItem),$=s.tileBudgetBytes||To,W=F(),Z=Ao(E,W.count),D=Oa(u,s.websocketManager,Z,s.map,3);z(D,Z),s.allLayers.push(...D),s.mergedPanes=D,s.mergeStats=U(D.length,W.tilesPerPane,W.perTile),console.log("[tiles] merged %d layers into %d panes (~%d MB of %d MB budget, %d tiles/pane)",s.mergeStats.layers,s.mergeStats.groups,s.mergeStats.estimatedMB,s.mergeStats.budgetMB,W.tilesPerPane),s.map.on("resize",()=>{let X=F();if(X.count>=s.mergedPanes.length)return;let j=Ao(E,X.count),vt=s.mergedPanes.slice(0,j.length);for(let mt of s.mergedPanes.slice(j.length)){s.map.removeLayer(mt);let St=s.allLayers.indexOf(mt);St>=0&&s.allLayers.splice(St,1)}s.mergedPanes=vt,z(vt,j),vt.forEach((mt,St)=>mt.setItems(j[St])),s.mergeStats=U(vt.length,X.tilesPerPane,X.perTile),console.log("[tiles] window grew \u2014 regrouped %d layers into %d panes (~%d MB of %d MB budget, %d tiles/pane)",s.mergeStats.layers,s.mergeStats.groups,s.mergeStats.estimatedMB,s.mergeStats.budgetMB,X.tilesPerPane)})}function Q(E){if(!E.children||E.children.length===0){let $=E.data&&E.data.name,F=$?!R.has($):!0;return F&&$&&s.selectableLayers.add($),{id:E.id,data:{name:$},checked:F}}return{id:E.id,data:{name:E.data&&E.data.name},children:E.children.map(Q)}}let nt=Q(it),tt=new we(()=>{s.visibleLayerNames.clear();let E=[],$={},F=!1,U=!1,z=b&&s.visibleChiplets instanceof Set;tt.forEach(Z=>{if(Z.cb&&(Z.cb.checked=Z.checked,Z.cb.indeterminate=Z.indeterminate),Z.data&&Z.data.layer){let D=Z.data.nodeId||Z.data.name;E.push(D),Z.checked?(Z.data.layer._orShow(),s.visibleLayers.add(D),s.visibleLayerNames.add(Z.data.name)):(Z.data.layer._orHide(),s.visibleLayers.delete(D))}if(z&&Z.data&&Z.data.chipletPath){let D=Z.data.chipletPath,X=b.get(D);if(X){let j=Z.checked||Z.indeterminate,vt={checked:Z.checked,indeterminate:Z.indeterminate};(X.checked!==Z.checked||X.indeterminate!==Z.indeterminate)&&($[D]=vt,F=!0),s.visibleChiplets.has(D)!==j&&(U=!0)}}}),_(),Et(),s.pinsLayer&&s.map.hasLayer(s.pinsLayer)&&s.pinsLayer.refreshTiles();for(let{def:Z,layer:D}of s.overlayLayers||[])Cs(Z.layers_by,e)&&s.map.hasLayer(D)&&D.refreshTiles();let W=E.filter(Z=>!s.visibleLayers.has(Z));try{window.sessionStorage.setItem("or_hidden_layers",JSON.stringify(W))}catch{}s.syncDisplayState(),U?b.mirrorStates($):F&&(b.mirrorStatesQuiet($),b.forEach(Z=>{Z.cb&&(Z.cb.checked=Z.checked,Z.cb.indeterminate=Z.indeterminate)}))});s.layerModel=tt,tt.addFromSpec(it);let Ct=new we(()=>{s.selectableLayers.clear(),Ct.forEach($=>{$.checked&&$.data&&$.data.name&&s.selectableLayers.add($.data.name)}),Et();let E=r.layers.filter($=>!s.selectableLayers.has($));try{window.sessionStorage.setItem("or_nonselectable_layers",JSON.stringify(E))}catch{}s.syncDisplayState()});Ct.addFromSpec(nt);function Et(){Ct.forEach(E=>{if(!E.selCb)return;E.selCb.checked=E.checked,E.selCb.indeterminate=E.indeterminate;let $=tt.get(E.id),F=$&&!$.checked&&!$.indeterminate;E.selCb.disabled=F})}let At=document.createElement("div");At.className="context-menu",At.style.display="none",document.body.appendChild(At);function It(E){let $={};w.forEach((F,U)=>{F&&($[F]=E.has(U))}),tt.checkSet($)}function Yt(){At.style.display="none"}function rt(E,$){let F=document.createElement("div");F.className="context-menu-item",F.textContent=E,F.addEventListener("click",()=>{$(),Yt()}),At.appendChild(F)}let me=v.length,at=[{label:"Show only this layer",fn:E=>bn(E,0,0,me)},{label:"Show layer range \u2195",fn:E=>bn(E,1,1,me)},{label:"Show layer range \u2195\u2195",fn:E=>bn(E,2,2,me)},{label:"Show layer range \u2193",fn:E=>bn(E,1,0,me)},{label:"Show layer range \u2191",fn:E=>bn(E,0,1,me)}];document.addEventListener("click",E=>{At.contains(E.target)||Yt()}),document.addEventListener("keydown",E=>{E.key==="Escape"&&Yt()});let Lt=!wt(s),zt=null;function Wt(){zt&&(zt.classList.remove("vis-row-selected"),zt=null)}Lt&&ja(s,Wt);function Pt(E,$,F){let U=re(s);zt=E,E.classList.add("vis-row-selected");let z={type:"select_layer",layer:$,use_dbu:s.showDbu};F&&(z.chiplet=F),s.websocketManager.request(z).then(W=>{ce(s,U)&&(s.updateInspector&&s.updateInspector(W),s.focusComponent&&s.focusComponent("Inspector"),s.refreshOverlay&&s.refreshOverlay())}).catch(W=>{console.error("select_layer failed:",W),ce(s,U)&&Wt()})}function yt(E,$=!1){let F=Ct.get(E.id);if(!E.children||E.children.length===0){let U=document.createElement("div");U.className=Lt?"vis-leaf vis-leaf-selectable":"vis-leaf";let z=document.createElement("span");z.className="vis-arrow",z.style.visibility="hidden",z.textContent="\u25B6",U.appendChild(z);let W=E.data.colorIndex,Z=E.data.name,D=Wi(),X=document.createElement("span");X.className="layer-color";let j=E.data.color||r.layer_colors&&r.layer_colors[W]||Sl[W%Sl.length];X.style.backgroundColor=`rgb(${j[0]},${j[1]},${j[2]})`,D.appendChild(X),D.appendChild(document.createTextNode(Z)),U.appendChild(D),Lt&&D.addEventListener("click",()=>{Pt(U,Z,E.data.ownerChipletPath)});let vt=document.createElement("input");if(vt.type="checkbox",vt.className="vis-cb",vt.title="Visible",vt.checked=E.checked,E.cb=vt,vt.addEventListener("change",()=>{tt.check(E.id,vt.checked)}),U.appendChild(vt),F){let mt=document.createElement("input");mt.type="checkbox",mt.className="vis-sel-cb",mt.title="Selectable",mt.checked=F.checked,F.selCb=mt,mt.addEventListener("change",()=>{Ct.check(E.id,mt.checked)}),U.appendChild(mt)}else U.appendChild(Ve());return U.addEventListener("contextmenu",mt=>{mt.preventDefault(),mt.stopPropagation(),At.innerHTML="";for(let $t of at)rt($t.label,()=>It($t.fn(W)));let St=document.createElement("div");St.className="context-menu-separator",St.style.borderTop="1px solid #555",St.style.margin="4px 0",At.appendChild(St);let Tt=s.layerPatterns[Z]??1;for(let $t of q){let le=Tt===$t.value?"\u25CF ":" ";rt(le+"Fill: "+$t.label,()=>M(Z,E.data.layer,$t.value))}At.style.left=mt.clientX+"px",At.style.top=mt.clientY+"px",At.style.display="block"}),U}else{let U=document.createElement("div");U.className="vis-group";let{header:z,arrow:W,name:Z}=ui();Z.textContent=$?"Layers":E.data.name||"Group";let D=document.createElement("input");if(D.type="checkbox",D.className="vis-cb",D.title="Visible",D.checked=E.checked,D.indeterminate=E.indeterminate,E.cb=D,D.addEventListener("change",()=>{tt.check(E.id,D.checked)}),z.appendChild(D),F){let j=document.createElement("input");j.type="checkbox",j.className="vis-sel-cb",j.title="Selectable",j.checked=F.checked,j.indeterminate=F.indeterminate,F.selCb=j,j.addEventListener("change",()=>{Ct.check(E.id,j.checked)}),z.appendChild(j)}else z.appendChild(Ve());U.appendChild(z);let X=document.createElement("div");X.className="vis-group-children";for(let j of E.children)X.appendChild(yt(j,!1));return U.appendChild(X),pi(z,W,X,!!(E.data&&E.data.startCollapsed)),U}}let ft=tt.roots[0]||tt.get("layers_parent"),ae=yt(ft,!0);s.displayControlsEl.appendChild(ae),Et();let ie=r&&Array.isArray(r.chiplets)?r.chiplets:[];if(ie.length>1){let X=function(K,st){let lt=D.get(K);lt&&(tt.cascadeQuiet(lt.id,st),tt.onChange())},le=function(K){let st=K.data;if(K!==Tt){let lt=document.createElement("div");lt.className="vis-leaf",lt.style.paddingLeft=8*(st.depth-1)+"px",lt.title=st.path+(st.master?` (${st.master})`:""),lt.appendChild(Wi(st.name));let Nt=document.createElement("input");Nt.type="checkbox",Nt.className="vis-cb",Nt.checked=K.checked,Nt.indeterminate=K.indeterminate,K.cb=Nt,Nt.addEventListener("change",()=>{b.check(K.id,Nt.checked),X(st.path,Nt.checked)}),lt.appendChild(Nt),lt.appendChild(Ve()),$t.appendChild(lt)}K.children&&K.children.forEach(le)},E=r&&r.block_name||"",$=E!=="",F={};if($)try{let K=Vt("or_hidden_chiplets");if(K){let st=JSON.parse(decodeURIComponent(K));st&&typeof st=="object"&&!Array.isArray(st)&&(F=st)}}catch{}let U=new Set(Array.isArray(F[E])?F[E]:[]),z=Ad(ie,U),W=z.findIndex(K=>K.parentId===null),Z=W>=0?z[W].id:null;if(W>=0&&(z[W].hasCheckbox=!0),s.visibleChiplets=new Set(ie.filter(K=>!U.has(K.path)).map(K=>K.path)),b=new we(()=>{let K=new Set;if(b.forEach(st=>{st.cb&&(st.cb.checked=st.checked,st.cb.indeterminate=st.indeterminate),st.data&&st.data.path&&(st.checked||st.indeterminate)&&K.add(st.data.path)}),s.visibleChiplets=K,$){let st=ie.filter(Nt=>!K.has(Nt.path)).map(Nt=>Nt.path),lt={};try{let Nt=Vt("or_hidden_chiplets");if(Nt){let se=JSON.parse(decodeURIComponent(Nt));se&&typeof se=="object"&&!Array.isArray(se)&&(lt=se)}}catch{}st.length===0?delete lt[E]:lt[E]=st,Qt("or_hidden_chiplets",encodeURIComponent(JSON.stringify(lt)))}l()}),b.buildFromNodes(z),typeof console<"u"&&console.warn){let K=new Set;tt.forEach(lt=>{lt.data&<.data.chipletPath&&K.add(lt.data.chipletPath)});let st=new Set;b.forEach(lt=>{lt.data&<.data.path&&st.add(lt.data.path)});for(let lt of st)K.has(lt)||console.warn(`[display-controls] chiplet "${lt}" missing from layer_hierarchy \u2014 Layers/Chiplets sync may drift`);for(let lt of K)st.has(lt)||console.warn(`[display-controls] layer hierarchy node "${lt}" has no matching chiplet \u2014 Layers/Chiplets sync may drift`)}let D=new Map;tt.forEach(K=>{K.data&&K.data.chipletPath&&D.set(K.data.chipletPath,K)});{let K={};if(tt.forEach(st=>{if(!st.data||!st.data.chipletPath)return;let lt=st.data.chipletPath;U.has(lt)||b.get(lt)&&(K[lt]={checked:st.checked,indeterminate:st.indeterminate})}),Object.keys(K).length>0){b.mirrorStatesQuiet(K);let st=new Set;b.forEach(lt=>{lt.data&<.data.path&&(lt.checked||lt.indeterminate)&&st.add(lt.data.path)}),s.visibleChiplets=st}}let j=document.createElement("div");j.className="vis-group";let{header:vt,arrow:mt,name:St}=ui();St.textContent="Chiplets";let Tt=Z!=null?b.get(Z):null;if(Tt){let K=document.createElement("input");K.type="checkbox",K.className="vis-cb",K.checked=Tt.checked,K.indeterminate=Tt.indeterminate,Tt.cb=K,K.addEventListener("change",st=>{st.stopPropagation(),b.check(Z,K.checked),Tt.data&&Tt.data.path&&X(Tt.data.path,K.checked)}),vt.appendChild(K)}vt.appendChild(Ve()),j.appendChild(vt);let $t=document.createElement("div");$t.className="vis-group-children",b.roots.forEach(le),j.appendChild($t),pi(vt,mt,$t,!1),s.displayControlsEl.appendChild(j)}else s.visibleChiplets=null;let Ft=!!e.debug_renderers,ee=new xs(e,i,()=>{l(),!!e.debug_renderers!==Ft&&(Ft=!!e.debug_renderers,s.refreshRendererControls&&s.refreshRendererControls())});ee.add({label:"Nets",addSelectable:!0,children:[{key:"net_signal",label:"Signal"},{key:"net_power",label:"Power"},{key:"net_ground",label:"Ground"},{key:"net_clock",label:"Clock"},{key:"net_reset",label:"Reset"},{key:"net_tieoff",label:"Tie off"},{key:"net_scan",label:"Scan"},{key:"net_analog",label:"Analog"}]}),ee.add({label:"Instances",addSelectable:!0,children:[{label:"Std Cells",visKey:"stdcells",disabled:!s.hasLiberty,children:[{label:"Bufs/Invs",children:[{key:"std_bufinv_timing",label:"Timing opt."},{key:"std_bufinv",label:"Netlist"}]},{key:"std_combinational",label:"Combinational"},{key:"std_sequential",label:"Sequential"},{label:"Clock tree",children:[{key:"std_clock_bufinv",label:"Buffer/Inverter"},{key:"std_clock_gate",label:"Clock gate"}]},{key:"std_level_shift",label:"Level shifter"}]},{key:"macros",label:"Macros"},{label:"Pads",children:[{key:"pad_input",label:"Input"},{key:"pad_output",label:"Output"},{key:"pad_inout",label:"Inout"},{key:"pad_power",label:"Power"},{key:"pad_spacer",label:"Spacer"},{key:"pad_areaio",label:"Area IO"},{key:"pad_other",label:"Other"}]},{label:"Physical",children:[{key:"phys_fill",label:"Fill"},{key:"phys_endcap",label:"Endcap"},{key:"phys_welltap",label:"Welltap"},{key:"phys_tie",label:"Tie Hi/Lo"},{key:"phys_antenna",label:"Antenna"},{key:"phys_cover",label:"Cover"},{key:"phys_bump",label:"Bump"},{key:"phys_other",label:"Other"}]}]}),ee.add({label:"Blockages",addSelectable:!0,children:[{key:"placement_blockages",label:"Placement"},{key:"routing_obstructions",label:"Routing"}]}),r.sites&&r.sites.length>0&&ee.add({label:"Rows",visKey:"rows",addSelectable:!0,children:r.sites.map(E=>({key:"site_"+E,label:E}))}),ee.add({label:"Tracks",children:[{key:"tracks_pref",label:"Pref"},{key:"tracks_non_pref",label:"Non Pref"}]}),ee.add({label:"Shapes",children:[{label:"Routing",visKey:"routing",children:[{key:"routing_segments",label:"Segments"},{key:"routing_vias",label:"Vias"}]},{label:"Special Routing",visKey:"special_nets",children:[{key:"srouting_segments",label:"Segments"},{key:"srouting_vias",label:"Vias"}]},{key:"pins",label:"Pins",selectable:!0},{key:"pin_names",label:"Pin Names",disabledBy:"pins"},{key:"fills",label:"Fills"}]}),ee.add({label:"Misc",children:[{label:"Instances",children:[{key:"inst_names",label:"Names"},{key:"inst_pins",label:"Pins",selectable:!0},{key:"inst_pin_names",label:"Pin Names",disabledBy:"inst_pins"},{key:"blockages",label:"Blockages"}]},{key:"detailed",label:"Detailed view"},{key:"rulers",label:"Rulers"},{key:"labels",label:"Labels"},{key:"scale_bar",label:"Scale bar"},{key:"access_points",label:"Access Points"},{key:"regions",label:"Regions"},{key:"mfg_grid",label:"Manufacturing grid"},{key:"gcell_grid",label:"GCell grid"},{key:"flywires_only",label:"Flywires only"},{key:"focused_nets_guides",label:"Focused nets guides"},{key:"highlight_selected",label:"Highlight selected"}]}),ee.add({key:"module_view",label:"Module view"}),ee.add({label:"Debug Graphics",children:[{key:"debug_renderers",label:"Renderers"},{key:"debug_live",label:"Live (don't require pause)",disabledBy:"debug_renderers"},{key:"debug",label:"Tiles"}]}),ee.render(s.displayControlsEl);let de=document.createElement("div");de.className="renderer-controls",s.displayControlsEl.appendChild(de);function k(E){return Promise.all(E.map(({path:$,value:F})=>s.websocketManager.request({type:"set_renderer_control",path:$,value:F}))).catch(()=>{})}function H(E){de.innerHTML="";let $=new Map;for(let F of E||[]){let U=F.group||"";$.has(U)||$.set(U,[]),$.get(U).push(F)}for(let[F,U]of $){let z=de;if(F){let W=document.createElement("div");W.className="vis-group";let{header:Z,arrow:D,name:X}=ui();X.textContent=F;let j=document.createElement("input");j.type="checkbox",j.className="vis-cb",j.title="Visible";let vt=U.filter(St=>St.visible).length;j.checked=vt===U.length,j.indeterminate=vt>0&&vt{let St=j.checked;k(U.filter(Tt=>!!Tt.visible!==St).map(Tt=>({path:Tt.path,value:St})))}),Z.appendChild(j),Z.appendChild(Ve()),W.appendChild(Z);let mt=document.createElement("div");mt.className="vis-group-children",W.appendChild(mt),pi(Z,D,mt,!1),de.appendChild(W),z=mt}for(let W of U){let Z=document.createElement("div");Z.className="vis-leaf";let D=document.createElement("span");D.className="vis-arrow",D.style.visibility="hidden",D.textContent="\u25B6",Z.appendChild(D),Z.appendChild(Wi(W.name));let X=document.createElement("input");X.type="checkbox",X.className="vis-cb",X.title="Visible",X.checked=!!W.visible,X.addEventListener("change",()=>k([{path:W.path,value:X.checked}])),Z.appendChild(X),Z.appendChild(Ve()),z.appendChild(Z)}}}s.refreshRendererControls=function(){return!s.websocketManager||wt(s)||!e.debug_renderers?(de.innerHTML="",Promise.resolve()):s.websocketManager.request({type:"renderer_controls"}).then(E=>H(E.controls)).catch(()=>{})},s.refreshRendererControls();let N=document.createElement("div");N.className="bg-color-row";let Y=document.createElement("span");Y.textContent="Background";let P=document.createElement("input");P.type="color",P.className="bg-color-input",P.title="Layout background color";let J=Vt("or_bg_color");P.value=Fi(J)?J:zo(),P.addEventListener("input",()=>{document.documentElement.style.setProperty("--bg-map",P.value)}),P.addEventListener("change",()=>{hl(P.value,s)});let I=document.createElement("button");I.className="bg-color-reset",I.textContent="Reset",I.title="Reset background to the theme default",I.addEventListener("click",()=>{dl(s),P.value=zo()}),N.appendChild(Y),N.appendChild(P),N.appendChild(I),s.heatMapLayer||(s.heatMapLayer=new h(s.websocketManager,s,{zIndex:v.length+10,opacity:1}));let O=document.createElement("div");O.className="vis-group heatmap-controls",s.displayControlsEl.appendChild(O);let{header:ct,arrow:kt,name:Xt}=ui("vis-group-header heatmap-header");Xt.textContent="Heat Maps",O.appendChild(ct);let Ot=document.createElement("div");Ot.className="vis-group-children heatmap-group-children",O.appendChild(Ot),pi(ct,kt,Ot,!0),s.displayControlsEl.appendChild(N);function jt(E,$,F,U){let z=document.createElement("label");z.className="heatmap-setting";let W=document.createElement("input");W.type="checkbox",W.checked=F,W.addEventListener("change",()=>U(W.checked)),z.appendChild(W),z.appendChild(document.createTextNode($)),E.appendChild(z)}function xe(E,$,F,U,z){let W=document.createElement("label");W.className="heatmap-setting";let Z=document.createElement("span");Z.textContent=$;let D=document.createElement("input");D.type="number",D.value=String(F),D.step=String(U||1),D.addEventListener("change",()=>z(parseFloat(D.value))),W.appendChild(Z),W.appendChild(D),E.appendChild(W)}function Fe(E,$,F,U,z){let W=document.createElement("label");W.className="heatmap-setting";let Z=document.createElement("span");Z.textContent=$;let D=document.createElement("select");for(let X of U){let j=document.createElement("option");j.value=X,j.textContent=X,X===F&&(j.selected=!0),D.appendChild(j)}D.addEventListener("change",()=>z(D.value)),W.appendChild(Z),W.appendChild(D),E.appendChild(W)}function Bt(E){s.websocketManager.request(E).then($=>{s.updateHeatMaps&&s.updateHeatMaps($)}).catch($=>console.error("Heat map update failed",$))}function Ke(E){if(!s.heatMapLegendEl)return;let $=s.heatMapLegendEl;if($.innerHTML="",!E||!E.show_legend||!E.legend||E.legend.length===0){$.classList.add("hidden");return}let F=document.createElement("div");F.className="heatmap-map-legend-title",F.textContent=E.title,$.appendChild(F);let U=document.createElement("div");U.className="heatmap-map-legend-units",U.textContent=E.units||"",$.appendChild(U);let z=document.createElement("div");z.className="heatmap-map-legend-list";for(let W of E.legend){let Z=document.createElement("div");Z.className="heatmap-legend-row";let D=document.createElement("span");D.className="heatmap-legend-swatch",D.style.backgroundColor=`rgba(${W.color[0]}, ${W.color[1]}, ${W.color[2]}, ${W.color[3]/255})`;let X=document.createElement("span");X.textContent=W.value,Z.appendChild(D),Z.appendChild(X),z.appendChild(Z)}$.appendChild(z),$.classList.remove("hidden")}s.renderHeatMapControls=E=>{Ot.innerHTML="";let $=document.createElement("div");$.className="heatmap-list",Ot.appendChild($);let F=document.createElement("label");F.className="heatmap-setting";let U=document.createElement("input");U.type="radio",U.name="active-heatmap",U.checked=!E.active,U.addEventListener("change",()=>{Bt({type:"set_active_heatmap",name:""})}),F.appendChild(U),F.appendChild(document.createTextNode("Off")),$.appendChild(F);for(let D of E.heatmaps||[]){let X=document.createElement("label");X.className="heatmap-setting";let j=document.createElement("input");j.type="radio",j.name="active-heatmap",j.checked=D.name===E.active,j.addEventListener("change",()=>{Bt({type:"set_active_heatmap",name:D.name})}),X.appendChild(j),X.appendChild(document.createTextNode(D.title)),$.appendChild(X)}let z=(E.heatmaps||[]).find(D=>D.name===E.active);if(Ke(z),!z)return;let W=document.createElement("div");W.className="heatmap-settings",Ot.appendChild(W),xe(W,"Display min",z.display_min,z.display_range_increment,D=>{Bt({type:"set_heatmap",name:z.name,option:"DisplayMin",value:D})}),xe(W,"Display max",z.display_max,z.display_range_increment,D=>{Bt({type:"set_heatmap",name:z.name,option:"DisplayMax",value:D})}),jt(W,"Show below min",z.draw_below_min,D=>{Bt({type:"set_heatmap",name:z.name,option:"ShowMin",value:D})}),jt(W,"Show above max",z.draw_above_max,D=>{Bt({type:"set_heatmap",name:z.name,option:"ShowMax",value:D})}),jt(W,"Log scale",z.log_scale,D=>{Bt({type:"set_heatmap",name:z.name,option:"LogScale",value:D})}),jt(W,"Reverse log",z.reverse_log,D=>{Bt({type:"set_heatmap",name:z.name,option:"ReverseLog",value:D})}),z.can_adjust_grid&&(xe(W,"Grid X",z.grid_x,.1,D=>{Bt({type:"set_heatmap",name:z.name,option:"GridX",value:D})}),xe(W,"Grid Y",z.grid_y,.1,D=>{Bt({type:"set_heatmap",name:z.name,option:"GridY",value:D})})),xe(W,"Alpha",z.alpha,1,D=>{Bt({type:"set_heatmap",name:z.name,option:"Alpha",value:D})}),jt(W,"Legend",z.show_legend,D=>{Bt({type:"set_heatmap",name:z.name,option:"ShowLegend",value:D})}),z.supports_numbers&&jt(W,"Show numbers",z.show_numbers,D=>{Bt({type:"set_heatmap",name:z.name,option:"ShowNumbers",value:D})});for(let D of z.options||[])D.type==="bool"?jt(W,D.label,D.value,X=>{Bt({type:"set_heatmap",name:z.name,option:D.name,value:X})}):D.type==="choice"&&Fe(W,D.label,D.value,D.choices||[],X=>{Bt({type:"set_heatmap",name:z.name,option:D.name,value:X})});z.selection_filter_label&&jt(W,z.selection_filter_label,z.use_selected_only,D=>{Bt({type:"set_heatmap",name:z.name,option:"use_selected_only",value:D})});let Z=document.createElement("button");Z.className="or-btn or-btn-sm heatmap-rebuild",Z.textContent="Rebuild data",Z.addEventListener("click",()=>{Bt({type:"set_heatmap",name:z.name,option:"rebuild",value:1})}),W.appendChild(Z)}}var Ml="search-nav-dialog",Id=[{label:"Instance",value:"inst"},{label:"Net",value:"net"},{label:"Port",value:"port"}];function Ls(s){if(!s.designScale)return;let e=Id.map(y=>``).join(""),{overlay:i,close:o,okBtn:r,showError:l}=Zi("Find Object",` + affected.
`,"Apply",uM),c=r.querySelector(".opt-family"),l=r.querySelector(".opt-custom"),u=r.querySelector(".opt-scale"),f=r.querySelector(".opt-preview");function d(){f.style.fontFamily=l.value.trim()||c.value,f.style.fontSize=`calc(13px * ${Wl(u.value)/100})`}for(let p of[c,l,u])p.addEventListener("input",d);d();function h(){let p=u.value.trim(),m=Number(p);if(p===""||!Number.isFinite(m)){a("Size must be a number.");return}if(mjh){a(`Size must be between ${Wh} and ${jh} %.`);return}n.setAppFont({family:l.value.trim()||c.value,scale:m}),s()}o.addEventListener("click",h);for(let p of[l,u])p.addEventListener("keydown",m=>{m.key==="Enter"&&(m.preventDefault(),h())});return{close:s}}function ov(n){return String(n).replace(/&/g,"&").replace(/"/g,""").replace(//g,">")}var LW='',MW='';function Qo(n){let e=document.createElement("span");return e.className="vis-name",n!=null&&(e.textContent=n),e}function fr(){let n=document.createElement("span");return n.className="vis-sel-cb vis-sel-spacer",n}function hM(){let n=document.createElement("div");n.className="display-controls-header",n.appendChild(Qo(""));for(let[e,t]of[[LW,"Visible"],[MW,"Selectable"]]){let i=document.createElement("span");i.className="vis-header-icon",i.title=t,i.innerHTML=e,n.appendChild(i)}return n}var Hh=class{constructor(e,t,i){this.visibility=e,this.selectability=t,this.onChange=i;let r=()=>{this._syncAll(),this.onChange()};this.model=new En(r),this.selModel=new En(r)}add(e){return this.model.addFromSpec(this._enrichSpec(e,"")),this.selModel.addFromSpec(this._enrichSelSpec(e,"",!1)),this}render(e){for(let t of this.model.roots)e.appendChild(this._dom(t));this._syncAll()}_nodeId(e,t){let i=e.key||e.label;return t?t+"/"+i:i}_enrichSpec(e,t){let i=this._nodeId(e,t),r={id:i,data:e};return e.children?r.children=e.children.map(s=>this._enrichSpec(s,i)):e.key&&(r.checked=!!this.visibility[e.key]),e.disabled!=null&&(r.disabled=e.disabled),r}_enrichSelSpec(e,t,i){let r=e.addSelectable===!0?!0:e.addSelectable===!1?!1:i,s=this._nodeId(e,t),o={id:s,data:e,hasCheckbox:!1};if(e.children){o.children=e.children.map(c=>this._enrichSelSpec(c,s,r));let a=c=>c.some(l=>l.hasCheckbox||l.children&&a(l.children));o.hasCheckbox=a(o.children),o.hasCheckbox&&(o.checked=!0)}else if(e.key){let a=e.selectable===!0||e.selectable!==!1&&i;o.hasCheckbox=a,a&&(o.checked=this.selectability[e.key]!==!1)}return o}_syncAll(){this.model.forEach(e=>{e.cb&&(e.cb.checked=e.checked,e.cb.indeterminate=e.indeterminate);let t=e.data;t.key&&(this.visibility[t.key]=e.checked),t.visKey&&(this.visibility[t.visKey]=e.checked||e.indeterminate)}),this.selModel.forEach(e=>{if(!e.hasCheckbox)return;let t=e.data;if(t.key&&(this.selectability[t.key]=e.checked),!e.selCb)return;e.selCb.checked=e.checked,e.selCb.indeterminate=e.indeterminate;let i=this.model.get(e.id),r=i&&!i.checked&&!i.indeterminate;e.selCb.disabled=r,e.selLabel&&e.selLabel.classList.toggle("vis-sel-disabled",r)}),this.model.forEach(e=>{let t=e.data;if(t.disabledBy&&e.el){let i=!this.visibility[t.disabledBy];e.el.classList.toggle("disabled",i)}})}_buildSelCheckbox(e){let t=this.selModel.get(e.id);if(!t||!t.hasCheckbox)return null;let i=document.createElement("input");return i.type="checkbox",i.className="vis-sel-cb",i.title="Selectable",i.addEventListener("change",()=>{this.selModel.check(t.id,i.checked)}),t.selCb=i,i}_dom(e){let t=e.data,i=document.createElement("input");i.type="checkbox",i.className="vis-cb",i.title="Visible",e.cb=i,i.addEventListener("change",()=>this.model.check(e.id,i.checked));let r=this._buildSelCheckbox(e),s=f=>{if(f.appendChild(i),r){f.appendChild(r);let d=this.selModel.get(e.id);d&&(d.selLabel=f)}else f.appendChild(fr())};if(!e.children.length){let f=document.createElement("div");f.className="vis-leaf";let d=document.createElement("span");return d.className="vis-arrow",d.style.visibility="hidden",d.textContent="\u25B6",f.appendChild(d),f.appendChild(Qo(t.label)),s(f),e.el=f,f}let o=document.createElement("div");o.className="vis-group";let{header:a,arrow:c,name:l}=vs();l.textContent=t.label,s(a),o.appendChild(a);let u=document.createElement("div");u.className="vis-group-children",t.disabled&&u.classList.add("disabled");for(let f of e.children)u.appendChild(this._dom(f));return o.appendChild(u),xs(a,c,u,!0),o}};function jl(n,e,t,i){let r=new Set,s=Math.max(0,n-e),o=Math.min(i-1,n+t);for(let a=s;a<=o;a++)r.add(a);return r}function AW(n){let e={};for(let[t,i]of Object.entries(n||{}))i!==1&&(e[t]=i);return e}function Yh(n,e){return(n||[]).some(t=>t.every(i=>!!e[i]))}function kW(n,e){return n.map(t=>{let i=!e.has(t.path);return{id:t.path,parentId:t.parent!=null?t.parent:null,hasCheckbox:t.parent!=null,checked:i,data:{path:t.path,name:t.name,master:t.master,depth:t.depth}}})}var RW=3,pM=[[70,130,210],[200,50,50],[50,180,80],[200,160,40],[160,60,200],[40,190,190],[220,120,50],[180,70,150]];function IW(n){return!n.forceComposite||ue(n)?0:n.groupLayers||E3}function mM(n,e,t,i,r,s){if(!n.displayControlsEl)return;n.displayControlsEl.innerHTML="",n.displayControlsEl.appendChild(hM());for(let S of n.allLayers||[])S.remove();n.allLayers=[],n.baseSlot=null,n.topSlot=null;let o=new Set;function a(){for(let S of o)S.refresh();o.clear()}function c(){n.baseSlot&&o.add(n.baseSlot)}function l(S){return{layer:S,opacity:1,visible:!1}}function u(S,L){m3(S,L)&&c()}function f(S,L,F){let k={layer:S,opacity:1,visible:!!F};return L&&(n[L]=k),k}let d=[f("_instances",null,!0),f("_pins","pinsLayer",e.pins),f("_modules","modulesLayer",e.module_view)],h=[];n.overlayLayers=(i&&i.overlays||[]).map(S=>({def:S,layer:f(S.name,null,Yh(S.shown_by,e)),under:S.z_indexF.def.z_index-k.def.z_index))(L?d:h).push(S);let p=[],m=[],g=null,v=new Set,y=new Set;try{let S=window.sessionStorage.getItem("or_hidden_layers");S&&(v=new Set(JSON.parse(S)))}catch{}try{let S=window.sessionStorage.getItem("or_nonselectable_layers");S&&(y=new Set(JSON.parse(S)))}catch{}try{let S=window.sessionStorage.getItem("or_layer_patterns");S&&Object.assign(n.layerPatterns,JSON.parse(S))}catch{}function b(){try{window.sessionStorage.setItem("or_layer_patterns",JSON.stringify(AW(n.layerPatterns)))}catch{}}function w(S,L){L===1?delete n.layerPatterns[S]:n.layerPatterns[S]=L,b(),c(),a()}let E=[{label:"Solid",value:1},{label:"Diagonal",value:2},{label:"Cross",value:3},{label:"Dots",value:4},{label:"None (no fill)",value:0}],x=0;function T(S,L="layers",F=void 0){let k=[],U=S.type==="category"?F:S.path,R=S.flipped===!0,B=S.instances||[],$=B.filter(ke=>ke.type!=="category"),Z=B.filter(ke=>ke.type==="category"),Q=S.layers||[],de=x;x+=Q.length;function _e(ke,Qe){let P=ke.map((A,O)=>O);Qe&&P.reverse(),P.forEach(A=>{let O=ke[A],G=L+"/"+(O.name||A);k.push(T(O,G,U))})}function Xe(){(R?Q.map((Qe,P)=>P).reverse():Q.map((Qe,P)=>P)).forEach(Qe=>{let P=Q[Qe],A=P.name||P,O=de+Qe,G=l(A),K=`${L}/${A}`,J=!v.has(K);J&&(u(G,!0),n.visibleLayers.add(K),n.visibleLayerNames.add(A)),p.push(G),m.push(K),k.push({id:K,data:{name:A,layer:G,color:P.color,colorIndex:O,nodeId:K,ownerChipletPath:U},checked:J})})}_e($,!1),R&&Xe(),_e(Z,R),R||Xe();let Oe={name:S.name,isInstance:!0};return S.type==="category"&&(S.name==="Implant"||S.name==="Other")&&(Oe.startCollapsed=!0),S.type!=="category"&&(Oe.chipletPath=S.path),{id:L,data:Oe,children:k}}let I;i.layer_hierarchy?I=T(i.layer_hierarchy,"layers_parent"):I={id:"layers_parent",children:i.layers.map((S,L)=>{let F=l(S),k=`layers_parent/${S}`,U=!v.has(k);return U&&(u(F,!0),n.visibleLayers.add(k),n.visibleLayerNames.add(S)),p.push(F),m.push(k),{id:k,data:{name:S,layer:F,colorIndex:L,nodeId:k},checked:U}})};function N(S,L,F){let k=n.view.addTileSlot(S,{order:L,source:S3({wm:n.websocketManager,ctx:n.tileCtx,getItems:()=>F,dpr:Yo,tileSize:tn,isDoubleBuffer:()=>n.doubleBuffer,groupLayers:()=>IW(n)})});return k.items=F,k}n.baseSlot=N("base",at.base,[...d,...p]),n.topSlot=N("top",at.top,h),n.allLayers=[n.baseSlot,n.topSlot];function D(S){if(!S.children||S.children.length===0){let L=S.data&&S.data.name,F=L?!y.has(L):!0;return F&&L&&n.selectableLayers.add(L),{id:S.id,data:{name:L},checked:F}}return{id:S.id,data:{name:S.data&&S.data.name},children:S.children.map(D)}}let H=D(I),W=new En(()=>{n.visibleLayerNames.clear();let S=[],L={},F=!1,k=!1,U=g&&n.visibleChiplets instanceof Set;if(W.forEach(B=>{if(B.cb&&(B.cb.checked=B.checked,B.cb.indeterminate=B.indeterminate),B.data&&B.data.layer){let $=B.data.nodeId||B.data.name;S.push($),u(B.data.layer,B.checked),B.checked?(n.visibleLayers.add($),n.visibleLayerNames.add(B.data.name)):n.visibleLayers.delete($)}if(U&&B.data&&B.data.chipletPath){let $=B.data.chipletPath,Z=g.get($);if(Z){let Q=B.checked||B.indeterminate,de={checked:B.checked,indeterminate:B.indeterminate};(Z.checked!==B.checked||Z.indeterminate!==B.indeterminate)&&(L[$]=de,F=!0),n.visibleChiplets.has($)!==Q&&(k=!0)}}}),n.baseSlot&&o.has(n.baseSlot))for(let{def:B,under:$}of n.overlayLayers)Yh(B.layers_by,e)&&o.add($?n.baseSlot:n.topSlot);a(),X();let R=S.filter(B=>!n.visibleLayers.has(B));try{window.sessionStorage.setItem("or_hidden_layers",JSON.stringify(R))}catch{}n.syncDisplayState(),k?g.mirrorStates(L):F&&(g.mirrorStatesQuiet(L),g.forEach(B=>{B.cb&&(B.cb.checked=B.checked,B.cb.indeterminate=B.indeterminate)}))});n.layerModel=W,W.addFromSpec(I);let V=new En(()=>{n.selectableLayers.clear(),V.forEach(L=>{L.checked&&L.data&&L.data.name&&n.selectableLayers.add(L.data.name)}),X();let S=i.layers.filter(L=>!n.selectableLayers.has(L));try{window.sessionStorage.setItem("or_nonselectable_layers",JSON.stringify(S))}catch{}n.syncDisplayState()});V.addFromSpec(H);function X(){V.forEach(S=>{if(!S.selCb)return;S.selCb.checked=S.checked,S.selCb.indeterminate=S.indeterminate;let L=W.get(S.id),F=L&&!L.checked&&!L.indeterminate;S.selCb.disabled=F})}let Y=document.createElement("div");Y.className="context-menu",Y.style.display="none",document.body.appendChild(Y);function ie(S){let L={};m.forEach((F,k)=>{F&&(L[F]=S.has(k))}),W.checkSet(L)}function oe(){Y.style.display="none"}function zt(S,L){let F=document.createElement("div");F.className="context-menu-item",F.textContent=S,F.addEventListener("click",()=>{L(),oe()}),Y.appendChild(F)}let je=p.length,sn=[{label:"Show only this layer",fn:S=>jl(S,0,0,je)},{label:"Show layer range \u2195",fn:S=>jl(S,1,1,je)},{label:"Show layer range \u2195\u2195",fn:S=>jl(S,2,2,je)},{label:"Show layer range \u2193",fn:S=>jl(S,1,0,je)},{label:"Show layer range \u2191",fn:S=>jl(S,0,1,je)}];document.addEventListener("click",S=>{Y.contains(S.target)||oe()}),document.addEventListener("keydown",S=>{S.key==="Escape"&&oe()});let si=!ue(n),oi=null;function on(){oi&&(oi.classList.remove("vis-row-selected"),oi=null)}si&&I3(n,on);function Ri(S,L,F){let k=St(n);oi=S,S.classList.add("vis-row-selected");let U={type:"select_layer",layer:L,use_dbu:n.showDbu};F&&(U.chiplet=F),n.websocketManager.request(U).then(R=>{Dt(n,k)&&(n.updateInspector&&n.updateInspector(R),n.focusComponent&&n.focusComponent("Inspector"),n.refreshOverlay&&n.refreshOverlay())}).catch(R=>{console.error("select_layer failed:",R),Dt(n,k)&&on()})}function _t(S,L=!1){let F=V.get(S.id);if(!S.children||S.children.length===0){let k=document.createElement("div");k.className=si?"vis-leaf vis-leaf-selectable":"vis-leaf";let U=document.createElement("span");U.className="vis-arrow",U.style.visibility="hidden",U.textContent="\u25B6",k.appendChild(U);let R=S.data.colorIndex,B=S.data.name,$=Qo(),Z=document.createElement("span");Z.className="layer-color";let Q=S.data.color||i.layer_colors&&i.layer_colors[R]||pM[R%pM.length];Z.style.backgroundColor=`rgb(${Q[0]},${Q[1]},${Q[2]})`,$.appendChild(Z),$.appendChild(document.createTextNode(B)),k.appendChild($),si&&$.addEventListener("click",()=>{Ri(k,B,S.data.ownerChipletPath)});let de=document.createElement("input");if(de.type="checkbox",de.className="vis-cb",de.title="Visible",de.checked=S.checked,S.cb=de,de.addEventListener("change",()=>{W.check(S.id,de.checked)}),k.appendChild(de),F){let _e=document.createElement("input");_e.type="checkbox",_e.className="vis-sel-cb",_e.title="Selectable",_e.checked=F.checked,F.selCb=_e,_e.addEventListener("change",()=>{V.check(S.id,_e.checked)}),k.appendChild(_e)}else k.appendChild(fr());return k.addEventListener("contextmenu",_e=>{_e.preventDefault(),_e.stopPropagation(),Y.innerHTML="";for(let ke of sn)zt(ke.label,()=>ie(ke.fn(R)));let Xe=document.createElement("div");Xe.className="context-menu-separator",Xe.style.borderTop="1px solid #555",Xe.style.margin="4px 0",Y.appendChild(Xe);let Oe=n.layerPatterns[B]??1;for(let ke of E){let Qe=Oe===ke.value?"\u25CF ":" ";zt(Qe+"Fill: "+ke.label,()=>w(B,ke.value))}Y.style.left=_e.clientX+"px",Y.style.top=_e.clientY+"px",Y.style.display="block"}),k}else{let k=document.createElement("div");k.className="vis-group";let{header:U,arrow:R,name:B}=vs();B.textContent=L?"Layers":S.data.name||"Group";let $=document.createElement("input");if($.type="checkbox",$.className="vis-cb",$.title="Visible",$.checked=S.checked,$.indeterminate=S.indeterminate,S.cb=$,$.addEventListener("change",()=>{W.check(S.id,$.checked)}),U.appendChild($),F){let Q=document.createElement("input");Q.type="checkbox",Q.className="vis-sel-cb",Q.title="Selectable",Q.checked=F.checked,Q.indeterminate=F.indeterminate,F.selCb=Q,Q.addEventListener("change",()=>{V.check(S.id,Q.checked)}),U.appendChild(Q)}else U.appendChild(fr());k.appendChild(U);let Z=document.createElement("div");Z.className="vis-group-children";for(let Q of S.children)Z.appendChild(_t(Q,!1));return k.appendChild(Z),xs(U,R,Z,!!(S.data&&S.data.startCollapsed)),k}}let Sn=W.roots[0]||W.get("layers_parent"),Pn=_t(Sn,!0);n.displayControlsEl.appendChild(Pn),X();let Cn=i&&Array.isArray(i.chiplets)?i.chiplets:[];if(Cn.length>1){let Z=function(P,A){let O=$.get(P);O&&(W.cascadeQuiet(O.id,A),W.onChange())},Qe=function(P){let A=P.data;if(P!==Oe){let O=document.createElement("div");O.className="vis-leaf",O.style.paddingLeft=8*(A.depth-1)+"px",O.title=A.path+(A.master?` (${A.master})`:""),O.appendChild(Qo(A.name));let G=document.createElement("input");G.type="checkbox",G.className="vis-cb",G.checked=P.checked,G.indeterminate=P.indeterminate,P.cb=G,G.addEventListener("change",()=>{g.check(P.id,G.checked),Z(A.path,G.checked)}),O.appendChild(G),O.appendChild(fr()),ke.appendChild(O)}P.children&&P.children.forEach(Qe)},S=i&&i.block_name||"",L=S!=="",F={};if(L)try{let P=Be("or_hidden_chiplets");if(P){let A=JSON.parse(decodeURIComponent(P));A&&typeof A=="object"&&!Array.isArray(A)&&(F=A)}}catch{}let k=new Set(Array.isArray(F[S])?F[S]:[]),U=kW(Cn,k),R=U.findIndex(P=>P.parentId===null),B=R>=0?U[R].id:null;if(R>=0&&(U[R].hasCheckbox=!0),n.visibleChiplets=new Set(Cn.filter(P=>!k.has(P.path)).map(P=>P.path)),g=new En(()=>{let P=new Set;if(g.forEach(A=>{A.cb&&(A.cb.checked=A.checked,A.cb.indeterminate=A.indeterminate),A.data&&A.data.path&&(A.checked||A.indeterminate)&&P.add(A.data.path)}),n.visibleChiplets=P,L){let A=Cn.filter(G=>!P.has(G.path)).map(G=>G.path),O={};try{let G=Be("or_hidden_chiplets");if(G){let K=JSON.parse(decodeURIComponent(G));K&&typeof K=="object"&&!Array.isArray(K)&&(O=K)}}catch{}A.length===0?delete O[S]:O[S]=A,Ue("or_hidden_chiplets",encodeURIComponent(JSON.stringify(O)))}r()}),g.buildFromNodes(U),typeof console<"u"&&console.warn){let P=new Set;W.forEach(O=>{O.data&&O.data.chipletPath&&P.add(O.data.chipletPath)});let A=new Set;g.forEach(O=>{O.data&&O.data.path&&A.add(O.data.path)});for(let O of A)P.has(O)||console.warn(`[display-controls] chiplet "${O}" missing from layer_hierarchy \u2014 Layers/Chiplets sync may drift`);for(let O of P)A.has(O)||console.warn(`[display-controls] layer hierarchy node "${O}" has no matching chiplet \u2014 Layers/Chiplets sync may drift`)}let $=new Map;W.forEach(P=>{P.data&&P.data.chipletPath&&$.set(P.data.chipletPath,P)});{let P={};if(W.forEach(A=>{if(!A.data||!A.data.chipletPath)return;let O=A.data.chipletPath;k.has(O)||g.get(O)&&(P[O]={checked:A.checked,indeterminate:A.indeterminate})}),Object.keys(P).length>0){g.mirrorStatesQuiet(P);let A=new Set;g.forEach(O=>{O.data&&O.data.path&&(O.checked||O.indeterminate)&&A.add(O.data.path)}),n.visibleChiplets=A}}let Q=document.createElement("div");Q.className="vis-group";let{header:de,arrow:_e,name:Xe}=vs();Xe.textContent="Chiplets";let Oe=B!=null?g.get(B):null;if(Oe){let P=document.createElement("input");P.type="checkbox",P.className="vis-cb",P.checked=Oe.checked,P.indeterminate=Oe.indeterminate,Oe.cb=P,P.addEventListener("change",A=>{A.stopPropagation(),g.check(B,P.checked),Oe.data&&Oe.data.path&&Z(Oe.data.path,P.checked)}),de.appendChild(P)}de.appendChild(fr()),Q.appendChild(de);let ke=document.createElement("div");ke.className="vis-group-children",g.roots.forEach(Qe),Q.appendChild(ke),xs(de,_e,ke,!1),n.displayControlsEl.appendChild(Q)}else n.visibleChiplets=null;let gr=!!e.debug_renderers,$e=new Hh(e,t,()=>{r(),!!e.debug_renderers!==gr&&(gr=!!e.debug_renderers,n.refreshRendererControls&&n.refreshRendererControls())});$e.add({label:"Nets",addSelectable:!0,children:[{key:"net_signal",label:"Signal"},{key:"net_power",label:"Power"},{key:"net_ground",label:"Ground"},{key:"net_clock",label:"Clock"},{key:"net_reset",label:"Reset"},{key:"net_tieoff",label:"Tie off"},{key:"net_scan",label:"Scan"},{key:"net_analog",label:"Analog"}]}),$e.add({label:"Instances",addSelectable:!0,children:[{label:"Std Cells",visKey:"stdcells",disabled:!n.hasLiberty,children:[{label:"Bufs/Invs",children:[{key:"std_bufinv_timing",label:"Timing opt."},{key:"std_bufinv",label:"Netlist"}]},{key:"std_combinational",label:"Combinational"},{key:"std_sequential",label:"Sequential"},{label:"Clock tree",children:[{key:"std_clock_bufinv",label:"Buffer/Inverter"},{key:"std_clock_gate",label:"Clock gate"}]},{key:"std_level_shift",label:"Level shifter"}]},{key:"macros",label:"Macros"},{label:"Pads",children:[{key:"pad_input",label:"Input"},{key:"pad_output",label:"Output"},{key:"pad_inout",label:"Inout"},{key:"pad_power",label:"Power"},{key:"pad_spacer",label:"Spacer"},{key:"pad_areaio",label:"Area IO"},{key:"pad_other",label:"Other"}]},{label:"Physical",children:[{key:"phys_fill",label:"Fill"},{key:"phys_endcap",label:"Endcap"},{key:"phys_welltap",label:"Welltap"},{key:"phys_tie",label:"Tie Hi/Lo"},{key:"phys_antenna",label:"Antenna"},{key:"phys_cover",label:"Cover"},{key:"phys_bump",label:"Bump"},{key:"phys_other",label:"Other"}]}]}),$e.add({label:"Blockages",addSelectable:!0,children:[{key:"placement_blockages",label:"Placement"},{key:"routing_obstructions",label:"Routing"}]}),i.sites&&i.sites.length>0&&$e.add({label:"Rows",visKey:"rows",addSelectable:!0,children:i.sites.map(S=>({key:"site_"+S,label:S}))}),$e.add({label:"Tracks",children:[{key:"tracks_pref",label:"Pref"},{key:"tracks_non_pref",label:"Non Pref"}]}),$e.add({label:"Shapes",children:[{label:"Routing",visKey:"routing",children:[{key:"routing_segments",label:"Segments"},{key:"routing_vias",label:"Vias"}]},{label:"Special Routing",visKey:"special_nets",children:[{key:"srouting_segments",label:"Segments"},{key:"srouting_vias",label:"Vias"}]},{key:"pins",label:"Pins",selectable:!0},{key:"pin_names",label:"Pin Names",disabledBy:"pins"},{key:"fills",label:"Fills"}]}),$e.add({label:"Misc",children:[{label:"Instances",children:[{key:"inst_names",label:"Names"},{key:"inst_pins",label:"Pins",selectable:!0},{key:"inst_pin_names",label:"Pin Names",disabledBy:"inst_pins"},{key:"blockages",label:"Blockages"}]},{key:"detailed",label:"Detailed view"},{key:"rulers",label:"Rulers"},{key:"labels",label:"Labels"},{key:"scale_bar",label:"Scale bar"},{key:"access_points",label:"Access Points"},{key:"regions",label:"Regions"},{key:"mfg_grid",label:"Manufacturing grid"},{key:"gcell_grid",label:"GCell grid"},{key:"flywires_only",label:"Flywires only"},{key:"focused_nets_guides",label:"Focused nets guides"},{key:"highlight_selected",label:"Highlight selected"}]}),$e.add({key:"module_view",label:"Module view"}),$e.add({label:"Debug Graphics",children:[{key:"debug_renderers",label:"Renderers"},{key:"debug_live",label:"Live (don't require pause)",disabledBy:"debug_renderers"},{key:"debug",label:"Tiles"}]}),$e.render(n.displayControlsEl);let Ge=document.createElement("div");Ge.className="renderer-controls",n.displayControlsEl.appendChild(Ge);function _r(S){return Promise.all(S.map(({path:L,value:F})=>n.websocketManager.request({type:"set_renderer_control",path:L,value:F}))).catch(()=>{})}function ai(S){Ge.innerHTML="";let L=new Map;for(let F of S||[]){let k=F.group||"";L.has(k)||L.set(k,[]),L.get(k).push(F)}for(let[F,k]of L){let U=Ge;if(F){let R=document.createElement("div");R.className="vis-group";let{header:B,arrow:$,name:Z}=vs();Z.textContent=F;let Q=document.createElement("input");Q.type="checkbox",Q.className="vis-cb",Q.title="Visible";let de=k.filter(Xe=>Xe.visible).length;Q.checked=de===k.length,Q.indeterminate=de>0&&de{let Xe=Q.checked;_r(k.filter(Oe=>!!Oe.visible!==Xe).map(Oe=>({path:Oe.path,value:Xe})))}),B.appendChild(Q),B.appendChild(fr()),R.appendChild(B);let _e=document.createElement("div");_e.className="vis-group-children",R.appendChild(_e),xs(B,$,_e,!1),Ge.appendChild(R),U=_e}for(let R of k){let B=document.createElement("div");B.className="vis-leaf";let $=document.createElement("span");$.className="vis-arrow",$.style.visibility="hidden",$.textContent="\u25B6",B.appendChild($),B.appendChild(Qo(R.name));let Z=document.createElement("input");Z.type="checkbox",Z.className="vis-cb",Z.title="Visible",Z.checked=!!R.visible,Z.addEventListener("change",()=>_r([{path:R.path,value:Z.checked}])),B.appendChild(Z),B.appendChild(fr()),U.appendChild(B)}}}n.refreshRendererControls=function(){return!n.websocketManager||ue(n)||!e.debug_renderers?(Ge.innerHTML="",Promise.resolve()):n.websocketManager.request({type:"renderer_controls"}).then(S=>ai(S.controls)).catch(()=>{})},n.refreshRendererControls();let Ut=document.createElement("div");Ut.className="bg-color-row";let ci=document.createElement("span");ci.textContent="Background";let Ve=document.createElement("input");Ve.type="color",Ve.className="bg-color-input",Ve.title="Layout background color";let li=Be("or_bg_color");Ve.value=Zo(li)?li:ev(),Ve.addEventListener("input",()=>{document.documentElement.style.setProperty("--bg-map",Ve.value)}),Ve.addEventListener("change",()=>{Q3(Ve.value,n)});let an=document.createElement("button");an.className="bg-color-reset",an.textContent="Reset",an.title="Reset background to the theme default",an.addEventListener("click",()=>{J3(n),Ve.value=ev()}),Ut.appendChild(ci),Ut.appendChild(Ve),Ut.appendChild(an),!n.heatMapLayer&&s&&(n.heatMapLayer=s());let Ii=document.createElement("div");Ii.className="vis-group heatmap-controls",n.displayControlsEl.appendChild(Ii);let{header:Bi,arrow:Oi,name:Rs}=vs("vis-group-header heatmap-header");Rs.textContent="Heat Maps",Ii.appendChild(Bi);let Tn=document.createElement("div");Tn.className="vis-group-children heatmap-group-children",Ii.appendChild(Tn),xs(Bi,Oi,Tn,!0),n.displayControlsEl.appendChild(Ut);function $t(S,L,F,k){let U=document.createElement("label");U.className="heatmap-setting";let R=document.createElement("input");R.type="checkbox",R.checked=F,R.addEventListener("change",()=>k(R.checked)),U.appendChild(R),U.appendChild(document.createTextNode(L)),S.appendChild(U)}function Me(S,L,F,k,U){let R=document.createElement("label");R.className="heatmap-setting";let B=document.createElement("span");B.textContent=L;let $=document.createElement("input");$.type="number",$.value=String(F),$.step=String(k||1),$.addEventListener("change",()=>U(parseFloat($.value))),R.appendChild(B),R.appendChild($),S.appendChild(R)}function yr(S,L,F,k,U){let R=document.createElement("label");R.className="heatmap-setting";let B=document.createElement("span");B.textContent=L;let $=document.createElement("select");for(let Z of k){let Q=document.createElement("option");Q.value=Z,Q.textContent=Z,Z===F&&(Q.selected=!0),$.appendChild(Q)}$.addEventListener("change",()=>U($.value)),R.appendChild(B),R.appendChild($),S.appendChild(R)}function Ae(S){n.websocketManager.request(S).then(L=>{n.updateHeatMaps&&n.updateHeatMaps(L)}).catch(L=>console.error("Heat map update failed",L))}function M(S){if(!n.heatMapLegendEl)return;let L=n.heatMapLegendEl;if(L.innerHTML="",!S||!S.show_legend||!S.legend||S.legend.length===0){L.classList.add("hidden");return}let F=document.createElement("div");F.className="heatmap-map-legend-title",F.textContent=S.title,L.appendChild(F);let k=document.createElement("div");k.className="heatmap-map-legend-units",k.textContent=S.units||"",L.appendChild(k);let U=document.createElement("div");U.className="heatmap-map-legend-list";for(let R of S.legend){let B=document.createElement("div");B.className="heatmap-legend-row";let $=document.createElement("span");$.className="heatmap-legend-swatch",$.style.backgroundColor=`rgba(${R.color[0]}, ${R.color[1]}, ${R.color[2]}, ${R.color[3]/255})`;let Z=document.createElement("span");Z.textContent=R.value,B.appendChild($),B.appendChild(Z),U.appendChild(B)}L.appendChild(U),L.classList.remove("hidden")}n.renderHeatMapControls=S=>{Tn.innerHTML="";let L=document.createElement("div");L.className="heatmap-list",Tn.appendChild(L);let F=document.createElement("label");F.className="heatmap-setting";let k=document.createElement("input");k.type="radio",k.name="active-heatmap",k.checked=!S.active,k.addEventListener("change",()=>{Ae({type:"set_active_heatmap",name:""})}),F.appendChild(k),F.appendChild(document.createTextNode("Off")),L.appendChild(F);for(let $ of S.heatmaps||[]){let Z=document.createElement("label");Z.className="heatmap-setting";let Q=document.createElement("input");Q.type="radio",Q.name="active-heatmap",Q.checked=$.name===S.active,Q.addEventListener("change",()=>{Ae({type:"set_active_heatmap",name:$.name})}),Z.appendChild(Q),Z.appendChild(document.createTextNode($.title)),L.appendChild(Z)}let U=(S.heatmaps||[]).find($=>$.name===S.active);if(M(U),!U)return;let R=document.createElement("div");R.className="heatmap-settings",Tn.appendChild(R),Me(R,"Display min",U.display_min,U.display_range_increment,$=>{Ae({type:"set_heatmap",name:U.name,option:"DisplayMin",value:$})}),Me(R,"Display max",U.display_max,U.display_range_increment,$=>{Ae({type:"set_heatmap",name:U.name,option:"DisplayMax",value:$})}),$t(R,"Show below min",U.draw_below_min,$=>{Ae({type:"set_heatmap",name:U.name,option:"ShowMin",value:$})}),$t(R,"Show above max",U.draw_above_max,$=>{Ae({type:"set_heatmap",name:U.name,option:"ShowMax",value:$})}),$t(R,"Log scale",U.log_scale,$=>{Ae({type:"set_heatmap",name:U.name,option:"LogScale",value:$})}),$t(R,"Reverse log",U.reverse_log,$=>{Ae({type:"set_heatmap",name:U.name,option:"ReverseLog",value:$})}),U.can_adjust_grid&&(Me(R,"Grid X",U.grid_x,.1,$=>{Ae({type:"set_heatmap",name:U.name,option:"GridX",value:$})}),Me(R,"Grid Y",U.grid_y,.1,$=>{Ae({type:"set_heatmap",name:U.name,option:"GridY",value:$})})),Me(R,"Alpha",U.alpha,1,$=>{Ae({type:"set_heatmap",name:U.name,option:"Alpha",value:$})}),$t(R,"Legend",U.show_legend,$=>{Ae({type:"set_heatmap",name:U.name,option:"ShowLegend",value:$})}),U.supports_numbers&&$t(R,"Show numbers",U.show_numbers,$=>{Ae({type:"set_heatmap",name:U.name,option:"ShowNumbers",value:$})});for(let $ of U.options||[])$.type==="bool"?$t(R,$.label,$.value,Z=>{Ae({type:"set_heatmap",name:U.name,option:$.name,value:Z})}):$.type==="choice"&&yr(R,$.label,$.value,$.choices||[],Z=>{Ae({type:"set_heatmap",name:U.name,option:$.name,value:Z})});U.selection_filter_label&&$t(R,U.selection_filter_label,U.use_selected_only,$=>{Ae({type:"set_heatmap",name:U.name,option:"use_selected_only",value:$})});let B=document.createElement("button");B.className="or-btn or-btn-sm heatmap-rebuild",B.textContent="Rebuild data",B.addEventListener("click",()=>{Ae({type:"set_heatmap",name:U.name,option:"rebuild",value:1})}),R.appendChild(B)}}var gM="search-nav-dialog",BW=[{label:"Instance",value:"inst"},{label:"Net",value:"net"},{label:"Port",value:"port"}];function qh(n){if(!n.designScale)return;let e=BW.map(u=>``).join(""),{overlay:t,close:i,okBtn:r,showError:s}=Xo("Find Object",`
`,"Find",Ml),h=i.querySelector(".sn-pattern"),u=i.querySelector(".sn-type"),f=i.querySelector(".sn-case");h.focus();function _(){let y=h.value.trim();if(!y){l("Enter a name or glob pattern.");return}s.websocketManager&&(l("Searching\u2026",!0),s.websocketManager.request({type:"find",obj_type:u.value,pattern:y,match_case:f.checked}).then(g=>{$i(s,g);let v=g&&g.count?g.count:0;if(!v){l("No objects found.");return}Array.isArray(g.bbox)&&(s.lastSelectionBounds=Gt(g.bbox[0],g.bbox[1],g.bbox[2],g.bbox[3],s.designScale,s.designMaxDXDY,s.designOriginX,s.designOriginY),s.map.fitBounds(s.lastSelectionBounds)),typeof s.updateInspector=="function"&&s.updateInspector(g),typeof s.redrawAllLayers=="function"&&s.redrawAllLayers();let w=g.selection_count||v;l(g.truncated?`${v} found (showing first ${w}).`:`${v} found.`,!0)}).catch(g=>l("Find failed: "+g)))}return r.addEventListener("click",_),h.addEventListener("keydown",y=>{y.key==="Enter"&&(y.preventDefault(),_())}),{close:o}}function ks(s){if(!s.designScale||!s.map)return;let e=b=>s.formatDbu(b),i=b=>s.parseDbu(b),o=s.unitLabel(),r=s.map.getCenter(),l=ye(r.lat,r.lng,s.designScale,s.designMaxDXDY,s.designOriginX,s.designOriginY),{overlay:h,close:u,okBtn:f,showError:_}=Zi("Go to Position",` -
-
-
-
-
-
`,"Go to",Ml),y=h.querySelector(".sn-x"),g=h.querySelector(".sn-y"),v=h.querySelector(".sn-size");y.focus(),y.select();function w(){let b=i(y.value),C=i(g.value);if(b===null||C===null){_(`X and Y must be numbers (${o}).`);return}let R=Jt(b,C,s.designScale,s.designMaxDXDY,s.designOriginX,s.designOriginY),A=v.value.trim(),M=A?i(A):null;if(M!==null&&M>0){let q=M/2;s.map.fitBounds(Gt(b-q,C-q,b+q,C+q,s.designScale,s.designMaxDXDY,s.designOriginX,s.designOriginY))}else s.map.setView(R,s.map.getZoom());u()}f.addEventListener("click",w);for(let b of[y,g,v])b.addEventListener("keydown",C=>{C.key==="Enter"&&(C.preventDefault(),w())});return{close:u}}var Tl={ctrl:"ctrl",control:"ctrl",shift:"shift",alt:"alt",meta:"meta",cmd:"meta",command:"meta",super:"meta"};function Bd(s){if(typeof s!="string")return null;let e=s.split("+").map(l=>l.trim().toLowerCase()).filter(Boolean);if(e.length===0)return null;let i=e.pop();if(Tl[i]!==void 0)return null;let o=new Set;for(let l of e){let h=Tl[l];if(h===void 0)return null;o.add(h)}return[...["ctrl","alt","shift","meta"].filter(l=>o.has(l)),i].join("+")}function Nd(s){let e=[];return s.ctrlKey&&e.push("ctrl"),s.altKey&&e.push("alt"),s.shiftKey&&e.push("shift"),s.metaKey&&e.push("meta"),[...e,String(s.key).toLowerCase()].join("+")}function Al(s){let e=[{label:"File",items:[{label:"Open DB...",action:()=>Pl(s,"Open DB","read_db"),enabledWhen:()=>!s.designScale},{label:"Save DB...",action:()=>Pl(s,"Save DB","write_db"),enabledWhen:()=>!!s.designScale}]},{label:"View",items:[{label:"Fit",shortcut:"F",action:()=>{s.fitBounds&&s.map.fitBounds(s.fitBounds)}},{label:"Zoom In",shortcut:"Z",action:()=>s.map.zoomIn()},{label:"Zoom Out",shortcut:"Shift+Z",action:()=>s.map.zoomOut()},{type:"separator"},{label:"Toggle Theme",shortcut:"T",action:()=>s.toggleTheme()},{type:"separator"},{label:"Find...",shortcut:"Ctrl+F",action:()=>Ls(s),enabledWhen:()=>!!s.designScale},{label:"Go to Position...",shortcut:"Shift+G",action:()=>ks(s),enabledWhen:()=>!!s.designScale}]},{label:"Tools",items:[{label:"Ruler",shortcut:"K",action:()=>{s.rulerManager&&s.rulerManager.toggleRulerMode()}},{label:"Clear Rulers",shortcut:"Shift+K",action:()=>{s.rulerManager&&s.rulerManager.clearAllRulers()}},{type:"separator"},{label:"Add Label",shortcut:"L",action:()=>{s.labelManager&&s.labelManager.toggleLabelMode()}},{label:"Clear Labels",action:()=>{s.labelManager&&s.labelManager.clearAllLabels()}},{type:"separator"},{label:"Clear Highlights",action:()=>{s.websocketManager.request({type:"clear_highlights",group:-1}).then(()=>{s.refreshOverlay&&s.refreshOverlay(),s.refreshInspector&&s.refreshInspector()}).catch(()=>{})}},{type:"separator"},{label:"Global Connect...",action:()=>{s.showGlobalConnectDialog&&s.showGlobalConnectDialog()},enabledWhen:()=>!!s.designScale}]},{label:"Options",items:[{label:"Show DBU",action:()=>s.toggleShowDbu(),checked:()=>s.showDbu},{label:"Make euclidian rulers",action:()=>s.toggleRulerStyle(),checked:()=>s.rulerStyle!=="manhattan"},{type:"separator"},{label:"Mouse wheel mapped to zoom by default",action:()=>s.toggleWheelZoom(),checked:()=>s.wheelZoom},{label:"Arrow keys scroll step...",action:()=>s.showArrowStepDialog()},{label:"Application font...",action:()=>s.showAppFontDialog()},{type:"separator"},{label:"Show polygon decomposition",action:()=>s.togglePolyDecomp(),checked:()=>s.polyDecomp,enabledWhen:()=>!!s.designScale}]},{label:"Windows",items:[{label:"Layout Viewer",action:()=>s.focusComponent("LayoutViewer")},{label:"3D Viewer",action:()=>s.focusComponent("3DViewer")},{label:"Display Controls",action:()=>s.focusComponent("DisplayControls")},{label:"Inspector",action:()=>s.focusComponent("Inspector")},{label:"Selection Browser",action:()=>s.focusComponent("SelectHighlight")},{label:"Tcl Console",action:()=>s.focusComponent("TclConsole")},{label:"Hierarchy Browser",action:()=>s.focusComponent("Browser")},{label:"Timing",action:()=>s.focusComponent("TimingWidget")},{label:"DRC Viewer",action:()=>s.focusComponent("DRCWidget")},{label:"Clock Tree",action:()=>s.focusComponent("ClockWidget")},{label:"Charts",action:()=>s.focusComponent("ChartsWidget")},{label:"Help",action:()=>s.focusComponent("HelpWidget")},{type:"separator"},{label:"Reset to Default Layout",action:()=>s.resetLayout()}]},{label:"Help",items:[{label:"Keyboard Shortcuts",action:()=>s.focusComponent("HelpWidget")}]}],i=document.getElementById("menu-bar"),o=null,r=new Map;function l(){o&&(o.classList.remove("open"),o=null)}function h(){let _=e.map(w=>({label:w.label,items:w.items.slice()})),y=new Map(_.map(w=>[w.label,w]));function g(w){let b=y.get(w);return b||(b={label:w,items:[]},y.set(w,b),_.push(b)),b}function v(w,b){let C=w.items.find(R=>R.submenu&&R.label===b);return C||(C={label:b,submenu:{label:b,items:[]}},w.items.push(C)),C.submenu}for(let w of s.customMenu||[]){let b=String(w.path||"Custom Scripts").split("/").map(M=>M.trim()).filter(Boolean);b.length===0&&b.push("Custom Scripts");let C=g(b[0]);for(let M=1;Myn(s,w.script,w.echo);C.items.push({label:w.text,shortcut:w.shortcut,action:R});let A=Bd(w.shortcut);A&&r.set(A,R)}return _}function u(_,y){for(let g of y){if(g.type==="separator"){let b=document.createElement("div");b.className="menu-separator",_.appendChild(b);continue}let v=document.createElement("div");if(v.className="menu-item",g.submenu){v.classList.add("submenu-item");let b=document.createElement("span");b.textContent=g.label,v.appendChild(b);let C=document.createElement("span");C.className="submenu-arrow",C.textContent="\u25B8",v.appendChild(C);let R=document.createElement("div");R.className="menu-dropdown submenu",u(R,g.submenu.items),v.appendChild(R),_.appendChild(v);continue}if(g.disabled&&v.classList.add("disabled"),g.enabledWhen&&(v._enabledWhen=g.enabledWhen),g.checked){let b=document.createElement("span");b.className="menu-check",b.textContent=g.checked()?"\u2713":"",v.appendChild(b),v._checkedFn=g.checked}let w=document.createElement("span");if(w.textContent=g.label,v.appendChild(w),g.shortcut){let b=document.createElement("span");b.className="shortcut",b.textContent=g.shortcut,v.appendChild(b)}g.action&&v.addEventListener("click",b=>{v.classList.contains("disabled")||(b.stopPropagation(),l(),g.action())}),_.appendChild(v)}}function f(){for(let y of i.querySelectorAll(":scope > .menu-label"))y.remove();let _=i.firstChild;o=null,r.clear();for(let y of h()){let w=function(){for(let b of v.querySelectorAll(".menu-item"))if(b._enabledWhen&&b.classList.toggle("disabled",!b._enabledWhen()),b._checkedFn){let C=b.querySelector(".menu-check");C&&(C.textContent=b._checkedFn()?"\u2713":"")}},g=document.createElement("div");g.className="menu-label",g.textContent=y.label;let v=document.createElement("div");v.className="menu-dropdown",u(v,y.items),g.appendChild(v),g.addEventListener("click",b=>{b.stopPropagation(),o===g?l():(l(),w(),g.classList.add("open"),o=g)}),g.addEventListener("mouseenter",()=>{o&&o!==g&&(l(),w(),g.classList.add("open"),o=g)}),i.insertBefore(g,_)}}f(),s.rebuildMenuBar=f,document.addEventListener("click",l),Dd(r)}function Dd(s){document.addEventListener("keydown",e=>{if(s.size===0)return;let i=e.target.tagName;if(i==="INPUT"||i==="TEXTAREA"||e.target.isContentEditable)return;let o=s.get(Nd(e));o&&(e.preventDefault(),e.stopImmediatePropagation(),o())},!0)}function Pl(s,e,i){let o=i==="write_db",r=document.createElement("div");r.className="modal-overlay",r.innerHTML=` + `,"Find",gM),o=t.querySelector(".sn-pattern"),a=t.querySelector(".sn-type"),c=t.querySelector(".sn-case");o.focus();function l(){let u=o.value.trim();if(!u){s("Enter a name or glob pattern.");return}n.websocketManager&&(s("Searching\u2026",!0),n.websocketManager.request({type:"find",obj_type:a.value,pattern:u,match_case:c.checked}).then(f=>{qo(n,f);let d=f&&f.count?f.count:0;if(!d){s("No objects found.");return}Array.isArray(f.bbox)&&(n.lastSelectionBounds=f.bbox.slice(0,4),n.view.fitWorldRect(Ot(...n.lastSelectionBounds,n.designScale,n.designOriginX,n.designOriginY))),typeof n.updateInspector=="function"&&n.updateInspector(f),typeof n.redrawAllLayers=="function"&&n.redrawAllLayers();let h=f.selection_count||d;s(f.truncated?`${d} found (showing first ${h}).`:`${d} found.`,!0)}).catch(f=>s("Find failed: "+f)))}return r.addEventListener("click",l),o.addEventListener("keydown",u=>{u.key==="Enter"&&(u.preventDefault(),l())}),{close:i}}function Zh(n){if(!n.designScale||!n.view)return;let e=p=>n.formatDbu(p),t=p=>n.parseDbu(p),i=n.unitLabel(),r=n.view.getCenter(),s=wn(r[0],r[1],n.designScale,n.designOriginX,n.designOriginY),{overlay:o,close:a,okBtn:c,showError:l}=Xo("Go to Position",` +
+
+
+
+
+
`,"Go to",gM),u=o.querySelector(".sn-x"),f=o.querySelector(".sn-y"),d=o.querySelector(".sn-size");u.focus(),u.select();function h(){let p=t(u.value),m=t(f.value);if(p===null||m===null){l(`X and Y must be numbers (${i}).`);return}let g=d.value.trim(),v=g?t(g):null;if(v!==null&&v>0){let y=v/2;n.view.fitWorldRect(Ot(p-y,m-y,p+y,m+y,n.designScale,n.designOriginX,n.designOriginY))}else n.view.setView(xn(p,m,n.designScale,n.designOriginX,n.designOriginY),n.view.getZoom());a()}c.addEventListener("click",h);for(let p of[u,f,d])p.addEventListener("keydown",m=>{m.key==="Enter"&&(m.preventDefault(),h())});return{close:a}}var _M={ctrl:"ctrl",control:"ctrl",shift:"shift",alt:"alt",meta:"meta",cmd:"meta",command:"meta",super:"meta"};function OW(n){if(typeof n!="string")return null;let e=n.split("+").map(s=>s.trim().toLowerCase()).filter(Boolean);if(e.length===0)return null;let t=e.pop();if(_M[t]!==void 0)return null;let i=new Set;for(let s of e){let o=_M[s];if(o===void 0)return null;i.add(o)}return[...["ctrl","alt","shift","meta"].filter(s=>i.has(s)),t].join("+")}function DW(n){let e=[];return n.ctrlKey&&e.push("ctrl"),n.altKey&&e.push("alt"),n.shiftKey&&e.push("shift"),n.metaKey&&e.push("meta"),[...e,String(n.key).toLowerCase()].join("+")}function bM(n){let e=[{label:"File",items:[{label:"Open DB...",action:()=>yM(n,"Open DB","read_db"),enabledWhen:()=>!n.designScale},{label:"Save DB...",action:()=>yM(n,"Save DB","write_db"),enabledWhen:()=>!!n.designScale}]},{label:"View",items:[{label:"Fit",shortcut:"F",action:()=>{n.fitRect&&n.view.fitWorldRect(n.fitRect)}},{label:"Zoom In",shortcut:"Z",action:()=>n.view.zoomIn()},{label:"Zoom Out",shortcut:"Shift+Z",action:()=>n.view.zoomOut()},{type:"separator"},{label:"Toggle Theme",shortcut:"T",action:()=>n.toggleTheme()},{type:"separator"},{label:"Find...",shortcut:"Ctrl+F",action:()=>qh(n),enabledWhen:()=>!!n.designScale},{label:"Go to Position...",shortcut:"Shift+G",action:()=>Zh(n),enabledWhen:()=>!!n.designScale}]},{label:"Tools",items:[{label:"Ruler",shortcut:"K",action:()=>{n.rulerManager&&n.rulerManager.toggleRulerMode()}},{label:"Clear Rulers",shortcut:"Shift+K",action:()=>{n.rulerManager&&n.rulerManager.clearAllRulers()}},{type:"separator"},{label:"Add Label",shortcut:"L",action:()=>{n.labelManager&&n.labelManager.toggleLabelMode()}},{label:"Clear Labels",action:()=>{n.labelManager&&n.labelManager.clearAllLabels()}},{type:"separator"},{label:"Clear Highlights",action:()=>{n.websocketManager.request({type:"clear_highlights",group:-1}).then(()=>{n.refreshOverlay&&n.refreshOverlay(),n.refreshInspector&&n.refreshInspector()}).catch(()=>{})}},{type:"separator"},{label:"Global Connect...",action:()=>{n.showGlobalConnectDialog&&n.showGlobalConnectDialog()},enabledWhen:()=>!!n.designScale}]},{label:"Options",items:[{label:"Show DBU",action:()=>n.toggleShowDbu(),checked:()=>n.showDbu},{label:"Make euclidian rulers",action:()=>n.toggleRulerStyle(),checked:()=>n.rulerStyle!=="manhattan"},{type:"separator"},{label:"Mouse wheel mapped to zoom by default",action:()=>n.toggleWheelZoom(),checked:()=>n.wheelZoom},{label:"Arrow keys scroll step...",action:()=>n.showArrowStepDialog()},{label:"Application font...",action:()=>n.showAppFontDialog()},{type:"separator"},{label:"Smooth zoom and pan",action:()=>n.toggleControlSmoothing(),checked:()=>n.controlSmoothing},{label:"Double buffering",action:()=>n.toggleDoubleBuffer(),checked:()=>n.doubleBuffer},{label:"Defer tile updates while panning",action:()=>n.toggleDeferTileUpdates(),checked:()=>n.deferTileUpdates},{type:"separator"},{label:"Show polygon decomposition",action:()=>n.togglePolyDecomp(),checked:()=>n.polyDecomp,enabledWhen:()=>!!n.designScale}]},{label:"Windows",items:[{label:"Layout Viewer",action:()=>n.focusComponent("LayoutViewer")},{label:"3D Viewer",action:()=>n.focusComponent("3DViewer")},{label:"Display Controls",action:()=>n.focusComponent("DisplayControls")},{label:"Inspector",action:()=>n.focusComponent("Inspector")},{label:"Selection Browser",action:()=>n.focusComponent("SelectHighlight")},{label:"Tcl Console",action:()=>n.focusComponent("TclConsole")},{label:"Hierarchy Browser",action:()=>n.focusComponent("Browser")},{label:"Timing",action:()=>n.focusComponent("TimingWidget")},{label:"DRC Viewer",action:()=>n.focusComponent("DRCWidget")},{label:"Clock Tree",action:()=>n.focusComponent("ClockWidget")},{label:"Charts",action:()=>n.focusComponent("ChartsWidget")},{label:"Help",action:()=>n.focusComponent("HelpWidget")},{type:"separator"},{label:"Reset to Default Layout",action:()=>n.resetLayout()}]},{label:"Help",items:[{label:"Keyboard Shortcuts",action:()=>n.focusComponent("HelpWidget")}]}],t=document.getElementById("menu-bar"),i=null,r=new Map;function s(){i&&(i.classList.remove("open"),i=null)}function o(){let l=e.map(h=>({label:h.label,items:h.items.slice()})),u=new Map(l.map(h=>[h.label,h]));function f(h){let p=u.get(h);return p||(p={label:h,items:[]},u.set(h,p),l.push(p)),p}function d(h,p){let m=h.items.find(g=>g.submenu&&g.label===p);return m||(m={label:p,submenu:{label:p,items:[]}},h.items.push(m)),m.submenu}for(let h of n.customMenu||[]){let p=String(h.path||"Custom Scripts").split("/").map(y=>y.trim()).filter(Boolean);p.length===0&&p.push("Custom Scripts");let m=f(p[0]);for(let y=1;yVl(n,h.script,h.echo);m.items.push({label:h.text,shortcut:h.shortcut,action:g});let v=OW(h.shortcut);v&&r.set(v,g)}return l}function a(l,u){for(let f of u){if(f.type==="separator"){let p=document.createElement("div");p.className="menu-separator",l.appendChild(p);continue}let d=document.createElement("div");if(d.className="menu-item",f.submenu){d.classList.add("submenu-item");let p=document.createElement("span");p.textContent=f.label,d.appendChild(p);let m=document.createElement("span");m.className="submenu-arrow",m.textContent="\u25B8",d.appendChild(m);let g=document.createElement("div");g.className="menu-dropdown submenu",a(g,f.submenu.items),d.appendChild(g),l.appendChild(d);continue}if(f.disabled&&d.classList.add("disabled"),f.enabledWhen&&(d._enabledWhen=f.enabledWhen),f.checked){let p=document.createElement("span");p.className="menu-check",p.textContent=f.checked()?"\u2713":"",d.appendChild(p),d._checkedFn=f.checked}let h=document.createElement("span");if(h.textContent=f.label,d.appendChild(h),f.shortcut){let p=document.createElement("span");p.className="shortcut",p.textContent=f.shortcut,d.appendChild(p)}f.action&&d.addEventListener("click",p=>{d.classList.contains("disabled")||(p.stopPropagation(),s(),f.action())}),l.appendChild(d)}}function c(){for(let u of t.querySelectorAll(":scope > .menu-label"))u.remove();let l=t.firstChild;i=null,r.clear();for(let u of o()){let h=function(){for(let p of d.querySelectorAll(".menu-item"))if(p._enabledWhen&&p.classList.toggle("disabled",!p._enabledWhen()),p._checkedFn){let m=p.querySelector(".menu-check");m&&(m.textContent=p._checkedFn()?"\u2713":"")}},f=document.createElement("div");f.className="menu-label",f.textContent=u.label;let d=document.createElement("div");d.className="menu-dropdown",a(d,u.items),f.appendChild(d),f.addEventListener("click",p=>{p.stopPropagation(),i===f?s():(s(),h(),f.classList.add("open"),i=f)}),f.addEventListener("mouseenter",()=>{i&&i!==f&&(s(),h(),f.classList.add("open"),i=f)}),t.insertBefore(f,l)}}c(),n.rebuildMenuBar=c,document.addEventListener("click",s),NW(r)}function NW(n){document.addEventListener("keydown",e=>{if(n.size===0)return;let t=e.target.tagName;if(t==="INPUT"||t==="TEXTAREA"||e.target.isContentEditable)return;let i=n.get(DW(e));i&&(e.preventDefault(),e.stopImmediatePropagation(),i())},!0)}function yM(n,e,t){let i=t==="write_db",r=document.createElement("div");r.className="modal-overlay",r.innerHTML=` `,document.body.appendChild(r);let l=r.querySelector(".fb-breadcrumb"),h=r.querySelector(".fb-file-list"),u=r.querySelector(".fb-path-input"),f=r.querySelector(".modal-error"),_=r.querySelector(".ok"),y=r.querySelector(".cancel"),g="",v=null;function w(){r.remove()}function b(){let q=u.value.trim();_.disabled=!q}function C(q){l.innerHTML="";let G=q.split("/").filter(Boolean),dt=document.createElement("span");dt.className="fb-crumb",dt.textContent="/",dt.addEventListener("click",()=>A("/")),l.appendChild(dt);let gt="";for(let it of G){gt+="/"+it;let Q=document.createElement("span");Q.className="fb-crumb-sep",Q.textContent=" / ",l.appendChild(Q);let nt=document.createElement("span");nt.className="fb-crumb",nt.textContent=it;let tt=gt;nt.addEventListener("click",()=>A(tt)),l.appendChild(nt)}}function R(q){if(h.innerHTML="",v=null,!q||q.length===0){let G=document.createElement("div");G.className="fb-empty",G.textContent="(empty directory)",h.appendChild(G);return}for(let G of q){let dt=document.createElement("div");dt.className="fb-entry",G.is_dir&&dt.classList.add("fb-dir");let gt=document.createElement("span");gt.className="fb-icon",gt.textContent=G.is_dir?"\u{1F4C1}":"\u{1F4C4}",dt.appendChild(gt);let it=document.createElement("span");if(it.className="fb-name",it.textContent=G.name,dt.appendChild(it),!G.is_dir&&G.size!==void 0){let Q=document.createElement("span");Q.className="fb-size",Q.textContent=Rd(G.size),dt.appendChild(Q)}G.is_dir?dt.addEventListener("click",()=>{A(g+"/"+G.name)}):(dt.addEventListener("click",()=>{let Q=h.querySelector(".fb-selected");Q&&Q.classList.remove("fb-selected"),dt.classList.add("fb-selected"),v=G,u.value=g+"/"+G.name,b()}),dt.addEventListener("dblclick",()=>{u.value=g+"/"+G.name,b(),M()})),h.appendChild(dt)}}async function A(q){f.style.display="none",h.innerHTML='
Loading...
';try{let G=await s.websocketManager.request({type:"list_dir",path:q||""});if(g=G.path,C(G.path),R(G.entries),o){let gt=u.value.trim().split("/").pop();gt&&!gt.includes("/")?u.value=g+"/"+gt:u.value=g+"/"}else u.value="",v=null;b()}catch(G){h.innerHTML="",f.textContent=G.message||String(G),f.style.display=""}}async function M(){let q=u.value.trim();if(q){_.disabled=!0,_.textContent="Working...",f.style.display="none";try{let G=await s.websocketManager.request({type:"tcl_eval",cmd:`${i} ${q}`});if(G.is_error){f.textContent=G.output||G.result||"Command failed",f.style.display="",_.disabled=!1,_.textContent=o?"Save":"Open";return}if(w(),i==="read_db"){window.location.reload();return}}catch(G){f.textContent=G.message||"Request failed",f.style.display="",_.disabled=!1,_.textContent=o?"Save":"Open"}}}u.addEventListener("input",b),u.addEventListener("keydown",q=>{if(q.key==="Enter"){let G=u.value.trim();G.endsWith("/")?A(G.replace(/\/+$/,"")||"/"):M()}q.key==="Escape"&&w()}),_.addEventListener("click",M),y.addEventListener("click",w),r.addEventListener("click",q=>{q.target===r&&w()}),A("")}function Rd(s){return s<1024?s+" B":s<1024*1024?(s/1024).toFixed(1)+" KB":s<1024*1024*1024?(s/(1024*1024)).toFixed(1)+" MB":(s/(1024*1024*1024)).toFixed(1)+" GB"}function Il(s){let e=document.getElementById("toolbar");if(!e)return;s._toolbarToggleState||(s._toolbarToggleState={});function i(){e.innerHTML="";let o=s.customToolbar||[],r=new Set(o.map(l=>l.key));for(let l of Object.keys(s._toolbarToggleState))r.has(l)||delete s._toolbarToggleState[l];for(let l of o){let h=document.createElement("button");if(h.className="or-btn or-btn-sm toolbar-button",h.dataset.key=l.key,l.tooltip&&(h.title=l.tooltip),l.icon){let u=document.createElement("span");if(u.className="toolbar-icon",/^(data:|https?:|\.?\/)/.test(l.icon)){let f=document.createElement("img");f.src=l.icon,f.alt="",u.appendChild(f)}else u.textContent=l.icon;h.appendChild(u)}if(l.text){let u=document.createElement("span");u.className="toolbar-label",u.textContent=l.text,h.appendChild(u)}l.toggle&&s._toolbarToggleState[l.key]&&h.classList.add("active"),h.addEventListener("click",()=>{if(l.toggle){let u=!s._toolbarToggleState[l.key];s._toolbarToggleState[l.key]=u,h.classList.toggle("active",u),yn(s,u?l.script:l.script_off,l.echo)}else yn(s,l.script,l.echo)}),e.appendChild(h)}}return i(),s.rebuildToolbar=i,{rebuild:i}}function Nl(s,e=""){let i=document.createElement("div");i.className="modal-overlay",i.innerHTML=` +
`,document.body.appendChild(r);let s=r.querySelector(".fb-breadcrumb"),o=r.querySelector(".fb-file-list"),a=r.querySelector(".fb-path-input"),c=r.querySelector(".modal-error"),l=r.querySelector(".ok"),u=r.querySelector(".cancel"),f="",d=null;function h(){r.remove()}function p(){let b=a.value.trim();l.disabled=!b}function m(b){s.innerHTML="";let w=b.split("/").filter(Boolean),E=document.createElement("span");E.className="fb-crumb",E.textContent="/",E.addEventListener("click",()=>v("/")),s.appendChild(E);let x="";for(let T of w){x+="/"+T;let I=document.createElement("span");I.className="fb-crumb-sep",I.textContent=" / ",s.appendChild(I);let N=document.createElement("span");N.className="fb-crumb",N.textContent=T;let D=x;N.addEventListener("click",()=>v(D)),s.appendChild(N)}}function g(b){if(o.innerHTML="",d=null,!b||b.length===0){let w=document.createElement("div");w.className="fb-empty",w.textContent="(empty directory)",o.appendChild(w);return}for(let w of b){let E=document.createElement("div");E.className="fb-entry",w.is_dir&&E.classList.add("fb-dir");let x=document.createElement("span");x.className="fb-icon",x.textContent=w.is_dir?"\u{1F4C1}":"\u{1F4C4}",E.appendChild(x);let T=document.createElement("span");if(T.className="fb-name",T.textContent=w.name,E.appendChild(T),!w.is_dir&&w.size!==void 0){let I=document.createElement("span");I.className="fb-size",I.textContent=FW(w.size),E.appendChild(I)}w.is_dir?E.addEventListener("click",()=>{v(f+"/"+w.name)}):(E.addEventListener("click",()=>{let I=o.querySelector(".fb-selected");I&&I.classList.remove("fb-selected"),E.classList.add("fb-selected"),d=w,a.value=f+"/"+w.name,p()}),E.addEventListener("dblclick",()=>{a.value=f+"/"+w.name,p(),y()})),o.appendChild(E)}}async function v(b){c.style.display="none",o.innerHTML='
Loading...
';try{let w=await n.websocketManager.request({type:"list_dir",path:b||""});if(f=w.path,m(w.path),g(w.entries),i){let x=a.value.trim().split("/").pop();x&&!x.includes("/")?a.value=f+"/"+x:a.value=f+"/"}else a.value="",d=null;p()}catch(w){o.innerHTML="",c.textContent=w.message||String(w),c.style.display=""}}async function y(){let b=a.value.trim();if(b){l.disabled=!0,l.textContent="Working...",c.style.display="none";try{let w=await n.websocketManager.request({type:"tcl_eval",cmd:`${t} ${b}`});if(w.is_error){c.textContent=w.output||w.result||"Command failed",c.style.display="",l.disabled=!1,l.textContent=i?"Save":"Open";return}if(h(),t==="read_db"){window.location.reload();return}}catch(w){c.textContent=w.message||"Request failed",c.style.display="",l.disabled=!1,l.textContent=i?"Save":"Open"}}}a.addEventListener("input",p),a.addEventListener("keydown",b=>{if(b.key==="Enter"){let w=a.value.trim();w.endsWith("/")?v(w.replace(/\/+$/,"")||"/"):y()}b.key==="Escape"&&h()}),l.addEventListener("click",y),u.addEventListener("click",h),r.addEventListener("click",b=>{b.target===r&&h()}),v("")}function FW(n){return n<1024?n+" B":n<1024*1024?(n/1024).toFixed(1)+" KB":n<1024*1024*1024?(n/(1024*1024)).toFixed(1)+" MB":(n/(1024*1024*1024)).toFixed(1)+" GB"}function vM(n){let e=document.getElementById("toolbar");if(!e)return;n._toolbarToggleState||(n._toolbarToggleState={});function t(){e.innerHTML="";let i=n.customToolbar||[],r=new Set(i.map(s=>s.key));for(let s of Object.keys(n._toolbarToggleState))r.has(s)||delete n._toolbarToggleState[s];for(let s of i){let o=document.createElement("button");if(o.className="or-btn or-btn-sm toolbar-button",o.dataset.key=s.key,s.tooltip&&(o.title=s.tooltip),s.icon){let a=document.createElement("span");if(a.className="toolbar-icon",/^(data:|https?:|\.?\/)/.test(s.icon)){let c=document.createElement("img");c.src=s.icon,c.alt="",a.appendChild(c)}else a.textContent=s.icon;o.appendChild(a)}if(s.text){let a=document.createElement("span");a.className="toolbar-label",a.textContent=s.text,o.appendChild(a)}s.toggle&&n._toolbarToggleState[s.key]&&o.classList.add("active"),o.addEventListener("click",()=>{if(s.toggle){let a=!n._toolbarToggleState[s.key];n._toolbarToggleState[s.key]=a,o.classList.toggle("active",a),Vl(n,a?s.script:s.script_off,s.echo)}else Vl(n,s.script,s.echo)}),e.appendChild(o)}}return t(),n.rebuildToolbar=t,{rebuild:t}}function wM(n,e=""){let t=document.createElement("div");t.className="modal-overlay",t.innerHTML=` `,document.body.appendChild(i);function o(l){l.key==="Escape"&&r()}let r=()=>{i.remove(),document.removeEventListener("keydown",o)};return i.addEventListener("click",l=>{l.target===i&&r()}),document.addEventListener("keydown",o),{overlay:i,body:i.querySelector(".modal-body"),errorDiv:i.querySelector(".modal-error"),buttons:i.querySelector(".modal-buttons"),close:r}}function Me(s,e){s.textContent=e,s.style.display=e?"":"none"}function Ui(s,e,{primary:i=!1}={}){let o=document.createElement("button");return o.textContent=e,o.className="or-btn"+(i?" or-btn-primary":""),s.appendChild(o),o}function Ss(s){return"{"+String(s)+"}"}function Dl(s){let e=Nl("Global Connect","gc-dialog"),i=document.createElement("div");i.className="gc-table",e.body.appendChild(i);let o=document.createElement("div");o.className="gc-form";let r=document.createElement("input");r.placeholder="Instance pattern (regex)",r.value=".*";let l=document.createElement("input");l.placeholder="Pin pattern (regex)";let h=document.createElement("select"),u=document.createElement("select"),f=document.createElement("span");f.innerHTML='',o.append(Ye("Instance",r),Ye("Pin",l),Ye("Net",h),Ye("Region",u),f);let _=Ui(o,"Add rule");e.body.appendChild(o);function y(){let b=l.value.trim()!==""&&h.value!=="";for(let C of[r,l])try{new RegExp(C.value),C.classList.remove("gc-invalid")}catch{C.classList.add("gc-invalid"),b=!1}_.disabled=!b}r.addEventListener("input",y),l.addEventListener("input",y),h.addEventListener("change",y);function g(){s.websocketManager.request({type:"global_connect_info"}).then(b=>{i.innerHTML='
InstancePinNetRegion
',(b.rules||[]).forEach(C=>{let R=document.createElement("div");R.className="gc-row",R.innerHTML=`${wn(C.inst)}${wn(C.pin)}${wn(C.net)}${wn(C.region||"All")}`;let A=document.createElement("button");A.className="or-btn or-btn-sm or-btn-icon",A.textContent="\u2715",A.title="Delete rule",A.addEventListener("click",()=>{s.websocketManager.request({type:"global_connect_delete",inst:C.inst,pin:C.pin,net:C.net,region:C.region||""}).then(g).catch(M=>Me(e.errorDiv,String(M)))}),R.appendChild(A),i.appendChild(R)}),Wo(h,b.nets||[]),Wo(u,["All",...b.regions||[]]),y()}).catch(b=>Me(e.errorDiv,String(b)))}_.addEventListener("click",()=>{let b=o.querySelector('input[name="gc-pg"]:checked').value,C=`add_global_connection -net ${Ss(h.value)} -inst_pattern ${Ss(r.value||".*")} -pin_pattern ${Ss(l.value)} -${b}`;u.value&&u.value!=="All"&&(C+=` -region ${Ss(u.value)}`),Bl(s,C,e.errorDiv,"Rule added.",g)}),Ui(e.buttons,"Apply (force)").addEventListener("click",()=>{s.websocketManager.request({type:"global_connect_apply",force:!0}).then(b=>{if(!b.had_rules){Me(e.errorDiv,"No global-connect rules defined \u2014 add a rule first.");return}Me(e.errorDiv,`Connected ${b.connected} pin(s).`),s.scheduleRedrawAllLayers&&s.scheduleRedrawAllLayers(),g()}).catch(b=>Me(e.errorDiv,b.message||String(b)))}),Ui(e.buttons,"Clear all").addEventListener("click",()=>Bl(s,"clear_global_connect",e.errorDiv,"Rules cleared.",g)),Ui(e.buttons,"Close").addEventListener("click",e.close),g()}function Bl(s,e,i,o,r){s.websocketManager.request({type:"tcl_eval",cmd:e}).then(l=>{if(l.is_error){Me(i,l.output||l.result||"Command failed");return}Me(i,o||""),s.scheduleRedrawAllLayers&&s.scheduleRedrawAllLayers(),r&&r()}).catch(l=>Me(i,l.message||String(l)))}function Rl(s,e){let i=Nl(`Insert Buffer \u2014 ${wn(e)}`,"buf-dialog"),o=Ui(i.buttons,"Insert",{primary:!0});o.disabled=!0,Ui(i.buttons,"Cancel").addEventListener("click",i.close),s.websocketManager.request({type:"buffer_info",net:e}).then(l=>{if(!l.can_buffer){i.body.textContent=l.error||"This net has multiple drivers and cannot be buffered.";return}zd(s,i,e,l,o)}).catch(l=>{i.body.textContent=String(l)})}function zd(s,e,i,o,r){let l=document.createElement("div");l.className="buf-pins";let h=o.drivers||[],u=o.loads||[],f=new Set;function _(){l.innerHTML="";let b=(C,R)=>{let A=document.createElement("label");A.className="buf-pin";let M=document.createElement("input");M.type="checkbox",M.checked=f.has(C.id),M.addEventListener("change",()=>{if(M.checked){if(R)f.clear();else for(let q of h)f.delete(q.id);f.add(C.id)}else f.delete(C.id);_(),w()}),A.append(M,document.createTextNode(" "+C.label)),l.appendChild(A)};h.forEach(C=>b(C,!0)),u.forEach(C=>b(C,!1))}h.length&&f.add(h[0].id),_();let y=document.createElement("select");Wo(y,o.masters||[]);let g=document.createElement("input");g.placeholder="Optional: new buffer name";let v=document.createElement("input");v.placeholder="Optional: new net name",e.body.append(Ye("Pins to buffer",l),Ye("Buffer master",y),Ye("Buffer name",g),Ye("Net name",v));function w(){r.disabled=f.size===0||!y.value}y.addEventListener("change",w),w(),r.addEventListener("click",()=>{let b=new Set(h.map(A=>A.id)),C=[...f],R=C.some(A=>b.has(A))?"driver":"loads";s.websocketManager.request({type:"insert_buffer",net:i,mode:R,pins:C,master:y.value,buf_name:g.value.trim(),net_name:v.value.trim()}).then(A=>{if(A.is_error||A.ok===!1){Me(e.errorDiv,A.error||A.result||"Insertion failed");return}e.close(),A.inst&&(s.selectedInstanceName=A.inst),s.scheduleRedrawAllLayers&&s.scheduleRedrawAllLayers()}).catch(A=>Me(e.errorDiv,A.message||String(A)))})}function Ye(s,e){let i=document.createElement("label");i.className="edit-field";let o=document.createElement("span");return o.textContent=s,i.append(o,e),i}function Wo(s,e){let i=s.value;s.innerHTML="";for(let o of e){let r=document.createElement("option");r.value=o,r.textContent=o,s.appendChild(r)}e.includes(i)&&(s.value=i)}function wn(s){return String(s??"").replace(/&/g,"&").replace(//g,">")}var zl="#00ffff",Od="#ffff00",Uo="#ffffff",bi=0,Go=1,xn=2,Es=class{constructor(e,i,o,r){this._app=e,this._visibility=i,this._updateInspector=o,this._focusComponent=r,this._state=bi,this._rulers=[],this._nextId=0,this._pt0=null,this._selectedRulerId=null,this._ctrlHeld=!1,this._shiftHeld=!1,this._rulerPane=null,this._rulerLayerGroup=null,this._previewGroup=null,this._snapGroup=null,this._snapTimer=null,this._lastSnapResult=null,this._onMouseMove=this._handleMouseMove.bind(this),this._onMapClick=this._handleMapClick.bind(this),this._initLayers()}_initLayers(){let e=this._app.map;e&&(this._rulerPane=e.createPane("ruler-pane"),this._rulerPane.style.zIndex="700",this._rulerPane.style.pointerEvents="auto",this._rulerLayerGroup=L.layerGroup([],{pane:"ruler-pane"}).addTo(e),this._previewGroup=L.layerGroup([],{pane:"ruler-pane"}).addTo(e),this._snapGroup=L.layerGroup([],{pane:"ruler-pane"}).addTo(e))}isActive(){return this._state!==bi}updateVisibility(){this._rulerPane&&(this._rulerPane.style.display=this._visibility.rulers?"":"none")}toggleRulerMode(){this._state===bi?this._enterFirstPoint():this.cancelRulerBuild()}cancelRulerBuild(){this._state=bi,this._pt0=null,this._lastSnapResult=null,this._clearPreview(),this._clearSnap(),this._setCursor(!1),this._removeMapListeners()}clearAllRulers(){this._rulers=[],this._selectedRulerId=null,this._rulerLayerGroup.clearLayers(),this._clearPreview(),this._clearSnap(),this._state!==bi&&this.cancelRulerBuild()}_enterFirstPoint(){this._state=Go,this._pt0=null,this._lastSnapResult=null,this._setCursor(!0),this._addMapListeners()}_enterMeasuring(e){this._state=xn,this._pt0=e}_addMapListeners(){let e=this._app.map;e&&(e.getContainer().addEventListener("mousemove",this._onMouseMove),e.on("click",this._onMapClick))}_removeMapListeners(){let e=this._app.map;e&&(e.getContainer().removeEventListener("mousemove",this._onMouseMove),e.off("click",this._onMapClick))}_handleMouseMove(e){if(this._state===bi)return;this._ctrlHeld=e.ctrlKey||e.metaKey,this._shiftHeld=e.shiftKey;let i=this._app.map,o=i.getContainer().getBoundingClientRect(),r=i.containerPointToLatLng([e.clientX-o.left,e.clientY-o.top]),l=ye(r.lat,r.lng,this._app.designScale,this._app.designMaxDXDY,this._app.designOriginX,this._app.designOriginY);this._snapTimer&&clearTimeout(this._snapTimer),this._snapTimer=setTimeout(()=>{this._requestSnap(l.dbuX,l.dbuY)},50)}_handleMapClick(e){if(this._state===bi)return;L.DomEvent.stopPropagation(e);let i=e.originalEvent;i&&(this._ctrlHeld=i.ctrlKey||i.metaKey,this._shiftHeld=i.shiftKey);let o=ye(e.latlng.lat,e.latlng.lng,this._app.designScale,this._app.designMaxDXDY,this._app.designOriginX,this._app.designOriginY),r=this._getSnappedPoint(o.dbuX,o.dbuY);this._state===Go?this._enterMeasuring(r):this._state===xn&&(this._createRuler(this._pt0,r),this._state=Go,this._pt0=null,this._clearPreview(),this._clearSnap(),this._lastSnapResult=null)}async _requestSnap(e,i){let o=this._app;if(!o.websocketManager||!o.designScale)return;if(this._ctrlHeld){this._lastSnapResult=null,this._clearSnap(),this._updatePreview(e,i);return}let l=o.techData?.dbu_per_micron||1e3,h=o.map.getZoom(),u=Math.pow(2,Math.max(0,h)),f=1/(o.designScale*u),_=Math.max(Math.round(10*f),10),y=!0,g=!0;if(this._shiftHeld)y=!0,g=!0;else if(this._state===xn&&this._pt0){let w=Math.abs(e-this._pt0.x),b=Math.abs(i-this._pt0.y);w>b?(y=!1,g=!0):b>w&&(y=!0,g=!1)}let v={};for(let[w,b]of Object.entries(this._visibility))v[w]=!!b;try{let w=await o.websocketManager.request({type:"snap",dbu_x:e,dbu_y:i,radius:l,point_threshold:_,horizontal:!!y,vertical:!!g,visible_layers:[...o.visibleLayerNames],...v});this._lastSnapResult=w,this._updateSnapIndicator(w),this._updatePreview(e,i)}catch{this._lastSnapResult=null,this._clearSnap()}}_getSnappedPoint(e,i){if(this._ctrlHeld)return{x:e,y:i};let o=this._lastSnapResult,r;if(o?.found&&o.is_point)r={x:o.edge[0][0],y:o.edge[0][1]};else if(o?.found){let l=o.edge;l[0][1]===l[1][1]?r={x:e,y:l[0][1]}:r={x:l[0][0],y:i}}else r={x:e,y:i};if(!this._shiftHeld&&this._state===xn&&this._pt0){let l=Math.abs(r.x-this._pt0.x),h=Math.abs(r.y-this._pt0.y);l{L.DomEvent.stopPropagation(Q),this._selectRuler(e.id)}),y.addLayer(b);let C=this._app.map.getZoom(),R=Math.pow(2,Math.max(0,C)),M=8*(1/(i*R)),q=(Q,nt,tt)=>{let Ct=Math.sqrt(nt*nt+tt*tt);if(Ct===0)return;let Et=-tt/Ct,At=nt/Ct,It=Jt(Q.x+Et*M,Q.y+At*M,i,o,r,l),Yt=Jt(Q.x-Et*M,Q.y-At*M,i,o,r,l);y.addLayer(L.polyline([It,Yt],{color:_,weight:2,pane:"ruler-pane",interactive:!1}))};if(g)q(e.pt0,g.x-e.pt0.x,g.y-e.pt0.y),q(e.pt1,e.pt1.x-g.x,e.pt1.y-g.y);else{let Q=e.pt1.x-e.pt0.x,nt=e.pt1.y-e.pt0.y;q(e.pt0,Q,nt),q(e.pt1,Q,nt)}let G=this._computeDistance(e.pt0,e.pt1,e.euclidian),dt=v?v[0]:(h[0]+u[0])/2,gt=v?v[1]:(h[1]+u[1])/2,it=L.marker([dt,gt],{icon:L.divIcon({className:"ruler-label",html:this._formatDistance(G),iconSize:null}),pane:"ruler-pane",interactive:!1});y.addLayer(it),e._layerGroup=y,this._rulerLayerGroup.addLayer(y)}_rerenderAll(){this._rulerLayerGroup.clearLayers();for(let e of this._rulers)this._renderRuler(e)}_selectRuler(e){this._selectedRulerId=e,this._rerenderAll();let i=this._rulers.find(_=>_.id===e);if(!i)return;re(this._app);let o=Math.abs(i.pt1.x-i.pt0.x),r=Math.abs(i.pt1.y-i.pt0.y),l=i.euclidian?Math.sqrt(o*o+r*r):o+r,h=_=>this._app.formatDbu(_,!0),u=_=>this._app.parseDbu(_),f={type:"Ruler",name:i.name,bbox:[Math.min(i.pt0.x,i.pt1.x),Math.min(i.pt0.y,i.pt1.y),Math.max(i.pt0.x,i.pt1.x),Math.max(i.pt0.y,i.pt1.y)],properties:[{name:"Name",value:i.name,editable:!0},{name:"Label",value:i.label||"",editable:!0},{name:"Point 0 - x",value:h(i.pt0.x),editable:!0},{name:"Point 0 - y",value:h(i.pt0.y),editable:!0},{name:"Point 1 - x",value:h(i.pt1.x),editable:!0},{name:"Point 1 - y",value:h(i.pt1.y),editable:!0},{name:"Delta x",value:h(o)},{name:"Delta y",value:h(r)},{name:"Length",value:h(l)},{name:"Euclidian",value:i.euclidian?"True":"False",editable:!0,editor:{type:"bool"}}],onPropertyChange:(_,y)=>{switch(_){case"Name":i.name=y;break;case"Label":i.label=y;break;case"Point 0 - x":{let g=u(y);g!==null&&(i.pt0.x=g);break}case"Point 0 - y":{let g=u(y);g!==null&&(i.pt0.y=g);break}case"Point 1 - x":{let g=u(y);g!==null&&(i.pt1.x=g);break}case"Point 1 - y":{let g=u(y);g!==null&&(i.pt1.y=g);break}case"Euclidian":i.euclidian=y.trim().toLowerCase()==="true";break}this._rerenderAll(),this._selectRuler(i.id)}};this._updateInspector(f),this._focusComponent("Inspector"),requestAnimationFrame(()=>{let _=this._app.inspectorEl?.querySelector(".inspector-toolbar");if(!_)return;let y=document.createElement("button");y.className="or-btn or-btn-icon",y.title="Delete ruler",y.innerHTML='',y.addEventListener("click",()=>{this.deleteRuler(e)}),_.appendChild(y)})}deleteRuler(e){let i=this._rulers.findIndex(r=>r.id===e);if(i===-1)return;let o=this._rulers[i];o._layerGroup&&this._rulerLayerGroup.removeLayer(o._layerGroup),this._rulers.splice(i,1),this._selectedRulerId===e&&(this._selectedRulerId=null,this._updateInspector(null))}_getManhattanJoinPt(e,i){return{x:i.x,y:e.y}}_computeDistance(e,i,o=!0){let r=Math.abs(i.x-e.x),l=Math.abs(i.y-e.y);return o?Math.sqrt(r*r+l*l):r+l}_formatDistance(e){return this._app.formatDistance(e)}_setCursor(e){let i=this._app.map?.getContainer();i&&(e?i.classList.add("ruler-mode-cursor"):i.classList.remove("ruler-mode-cursor"))}_clearPreview(){this._previewGroup?.clearLayers()}_clearSnap(){this._snapGroup?.clearLayers()}};var Ms=class{constructor(e,i,o,r){this._app=e,this._visibility=i,this._updateInspector=o,this._focusComponent=r,this._labels=[],this._anchors=[],this._mode=!1,this._selectedName=null,this._pane=null,this._handleGroup=null,this._initLayers()}_initLayers(){let e=this._app.map;e&&(this._pane=e.createPane("label-pane"),this._pane.style.zIndex="690",this._pane.style.pointerEvents="auto",this._handleGroup=L.layerGroup([],{pane:"label-pane"}).addTo(e))}isActive(){return this._mode}updateVisibility(){this._pane&&(this._pane.style.display=this._visibility.labels?"":"none")}toggleLabelMode(){this._mode=!this._mode,this._setCursor(this._mode)}cancelLabelMode(){this._mode=!1,this._setCursor(!1)}_setCursor(e){let i=this._app.map?.getContainer();i&&i.classList.toggle("label-mode-cursor",e)}_wm(){return this._app.websocketManager}_applyLabels(e){this._labels=e||[],this._renderHandles()}_refresh(e){this._applyLabels(e&&e.labels),this._app.refreshOverlay()}applyRemoteLabels(e){this._applyLabels(e),this._selectedName&&!this._labels.some(i=>i.name===this._selectedName)&&(this._selectedName=null,this._updateInspector(null),this._renderHandles()),this._app.refreshOverlay()}_updateLabel(e,i){return this._wm().request({type:"update_label",name:e,...i})}async reload(){let e=this._wm();if(e)try{let i=await e.request({type:"list_labels"});this._anchors=i.anchors||[],this._applyLabels(i.labels)}catch{this._applyLabels([])}}async handleMapClick(e,i){let o=window.prompt("Label text:");if(this._mode=!1,this._setCursor(!1),!!o)try{let r=await this._wm().request({type:"add_label",x:Math.round(e),y:Math.round(i),text:o});this._refresh(r)}catch(r){console.error("add_label failed:",r)}}_renderHandles(){if(!this._handleGroup)return;this._handleGroup.clearLayers();let e=this._app.designScale;if(!e)return;let i=this._app.designMaxDXDY,o=this._app.designOriginX,r=this._app.designOriginY;for(let l of this._labels){let h=Jt(l.x,l.y,e,i,o,r),u=l.name===this._selectedName,f=L.marker(h,{pane:"label-pane",draggable:!0,keyboard:!1,icon:L.divIcon({className:"label-handle"+(u?" label-handle-selected":""),html:"",iconSize:[10,10]}),title:l.text});f.on("click",_=>{L.DomEvent.stopPropagation(_),this._select(l.name)}),f.on("dragend",_=>{let y=_.target.getLatLng(),{dbuX:g,dbuY:v}=ye(y.lat,y.lng,e,i,o,r);this._commitMove(l,Math.round(g),Math.round(v))}),this._handleGroup.addLayer(f)}}async _commitMove(e,i,o){try{let r=await this._updateLabel(e.name,{x:i,y:o,text:e.text,size:e.size||0,anchor:e.anchor||"center",color:e.color});this._refresh(r)}catch(r){console.error("move label failed:",r)}}_select(e){this._selectedName=e,this._renderHandles();let i=this._labels.find(l=>l.name===e);if(!i)return;let o=l=>this._app.formatDbu(l,!0),r={type:"Label",name:i.name,bbox:[i.x,i.y,i.x,i.y],properties:[{name:"Name",value:i.name},{name:"Text",value:i.text,editable:!0},{name:"x",value:o(i.x)},{name:"y",value:o(i.y)},{name:"Font size",value:String(i.size||0),editable:!0},{name:"Anchor",value:i.anchor||"center",editable:!0,editor:{type:"list",options:this._anchors}}],onPropertyChange:(l,h)=>{let u={text:i.text,size:i.size||0,anchor:i.anchor||"center"};l==="Text"?u.text=h:l==="Font size"?u.size=parseInt(h,10)||0:l==="Anchor"&&(u.anchor=h.trim()),this._edit(i,u)}};this._updateInspector(r),this._focusComponent("Inspector"),requestAnimationFrame(()=>{let l=this._app.inspectorEl?.querySelector(".inspector-toolbar");if(!l||l.querySelector(".delete-label-btn"))return;let h=document.createElement("button");h.className="or-btn or-btn-icon delete-label-btn",h.title="Delete label",h.innerHTML='',h.addEventListener("click",()=>this.deleteLabel(e)),l.appendChild(h)})}async _edit(e,i){try{let o=await this._updateLabel(e.name,{x:e.x,y:e.y,text:i.text,size:i.size,anchor:i.anchor,color:e.color});this._refresh(o),this._select(e.name)}catch(o){console.error("edit label failed:",o)}}async deleteLabel(e){try{let i=await this._wm().request({type:"delete_label",name:e});this._selectedName===e&&(this._selectedName=null,this._updateInspector(null)),this._refresh(i)}catch(i){console.error("delete_label failed:",i)}}async clearAllLabels(){try{let e=await this._wm().request({type:"clear_labels"});this._selectedName=null,this._refresh(e)}catch(e){console.error("clear_labels failed:",e)}}};var Ol="Select an instance in the layout to view its schematic.",Ts=class{constructor(e,i){this.container=e,this.appState=i,this.element=document.createElement("div"),this.element.className="schematic-widget",this.element.style.cssText="width:100%; height:100%; display:flex; flex-direction:column; background:var(--bg-panel); color:var(--fg-primary); overflow:hidden;",this.controls=document.createElement("div"),this.controls.style.cssText="padding:4px 8px; background:var(--bg-header); border-bottom:1px solid var(--border);flex-shrink:0; display:flex; align-items:center; gap:8px; flex-wrap:wrap;",this.controls.innerHTML='',this.element.appendChild(this.controls),this.svgContainer=document.createElement("div"),this.svgContainer.style.cssText="flex:1; overflow:hidden; position:relative; cursor:grab; background:var(--bg-main);",this.element.appendChild(this.svgContainer),this.container.element.appendChild(this.element),this.controls.querySelector("#schematic-refresh").addEventListener("click",()=>this.refresh()),this.controls.querySelector("#schematic-fit").addEventListener("click",()=>this.fitView()),this.controls.querySelector("#schematic-zoom-in").addEventListener("click",()=>this._zoomStep(1.5)),this.controls.querySelector("#schematic-zoom-out").addEventListener("click",()=>this._zoomStep(1/1.5)),this.controls.querySelector("#schematic-select").addEventListener("click",()=>this._toggleSelectMode()),this.controls.querySelector("#schematic-zoom-to").addEventListener("click",()=>this._zoomToSelected()),this.controls.querySelector("#schematic-save-svg").addEventListener("click",()=>this._exportSvg()),this.controls.querySelector("#schematic-save-png").addEventListener("click",()=>this._exportPng()),this.controls.querySelector("#schematic-copy").addEventListener("click",()=>this._copyImage()),this.appState.schematicWidget=this,this.netlistsvg=null,this.skin=null,this._svgEl=null,this._scale=1,this._panX=0,this._panY=0,this._selectMode=!1,this._selectedCell=null,this._svgIdToInstName=new Map,this._setupPanZoom(),this.initNetlistSVG()}_setupPanZoom(){let e=this.svgContainer,i=!1,o,r,l,h;e.addEventListener("wheel",u=>{if(!this._svgEl)return;u.preventDefault();let f=u.deltaY<0?1.2:1/1.2,_=e.getBoundingClientRect(),y=u.clientX-_.left,g=u.clientY-_.top;this._panX=y+(this._panX-y)*f,this._panY=g+(this._panY-g)*f,this._scale*=f,this._applyTransform()},{passive:!1}),e.addEventListener("mousedown",u=>{if(!(!this._svgEl||u.button!==0)){if(this._selectMode){this._handleSelectClick(u);return}i=!0,o=u.clientX,r=u.clientY,l=this._panX,h=this._panY,e.style.cursor="grabbing",u.preventDefault()}}),window.addEventListener("mousemove",u=>{i&&(this._panX=l+(u.clientX-o),this._panY=h+(u.clientY-r),this._applyTransform())}),window.addEventListener("mouseup",()=>{i&&(i=!1,e.style.cursor=this._selectMode?"default":"grab")})}_zoomStep(e){if(!this._svgEl)return;let i=this.svgContainer.getBoundingClientRect(),o=i.width/2,r=i.height/2;this._panX=o+(this._panX-o)*e,this._panY=r+(this._panY-r)*e,this._scale*=e,this._applyTransform()}_toggleSelectMode(){this._selectMode=!this._selectMode;let e=this.controls.querySelector("#schematic-select");this._selectMode?(e.style.background="var(--accent)",e.style.color="var(--fg-white)",this.svgContainer.style.cursor="default"):(e.style.background="",e.style.color="",this.svgContainer.style.cursor="grab",this._clearCellHighlight())}_handleSelectClick(e){if(!this._svgEl)return;let i=e.target,o=null;for(;i&&i!==this._svgEl;){if(i.tagName==="g"&&i.id&&this._svgIdToInstName.has(i.id)){o=i;break}i=i.parentElement}if(this._clearCellHighlight(),!o)return;let r=this._svgIdToInstName.get(o.id);try{let l=o.getBBox(),h=3,u=document.createElementNS("http://www.w3.org/2000/svg","rect");u.setAttribute("x",l.x-h),u.setAttribute("y",l.y-h),u.setAttribute("width",l.width+h*2),u.setAttribute("height",l.height+h*2),u.setAttribute("fill","none"),u.setAttribute("stroke","#e05a00"),u.setAttribute("stroke-width","1.5"),u.setAttribute("rx","3"),u.id="_schematic_highlight",o.appendChild(u),this._selectedCell=o}catch{}this.controls.querySelector("#schematic-zoom-to").disabled=!1,this.setStatus(`Selected: ${r}`),this._fetchInspect(r)}_fetchInspect(e){let i=this.appState.websocketManager;if(!i)return;console.log("[Schematic] inspect:",e);let o=re(this.appState);i.request({type:"schematic_inspect",inst_name:e,use_dbu:this.appState.showDbu}).then(r=>{ce(this.appState,o)&&(this.appState.updateInspector&&this.appState.updateInspector(r),this.appState.focusComponent&&this.appState.focusComponent("Inspector"),this.appState.refreshOverlay&&this.appState.refreshOverlay())}).catch(r=>{console.error("schematic_inspect failed:",r),this.setStatus(`Inspect error: ${r}`)})}_clearCellHighlight(){if(this._svgEl){let e=this._svgEl.querySelector("#_schematic_highlight");e&&e.remove()}this._selectedCell=null,this.controls.querySelector("#schematic-zoom-to").disabled=!0}_zoomToSelected(){if(!this._selectedCell||!this._svgEl)return;let e=this.svgContainer.getBoundingClientRect(),i=this._selectedCell.getBoundingClientRect(),o=(i.left-e.left-this._panX)/this._scale,r=(i.top-e.top-this._panY)/this._scale,l=i.width/this._scale,h=i.height/this._scale,u=Math.min(e.width/l,e.height/h)*.9;this._scale=u,this._panX=e.width/2-(o+l/2)*u,this._panY=e.height/2-(r+h/2)*u,this._applyTransform()}_applyTransform(){this._svgEl&&(this._svgEl.style.transform=`translate(${this._panX}px, ${this._panY}px) scale(${this._scale})`,this._svgEl.style.transformOrigin="0 0")}fitView(){if(!this._svgEl)return;let e=this.svgContainer.getBoundingClientRect();if(e.width===0||e.height===0)return;let i=this._svgEl.viewBox&&this._svgEl.viewBox.baseVal,o=i&&i.width||this._svgEl.clientWidth||1,r=i&&i.height||this._svgEl.clientHeight||1;this._scale=Math.min(e.width/o,e.height/r)*.95,this._panX=(e.width-o*this._scale)/2,this._panY=(e.height-r*this._scale)/2,this._applyTransform()}initNetlistSVG(){this.netlistsvg=globalThis.netlistsvg,this.skin=globalThis.openroadSkin,this._netlistsvgReady=!!(this.netlistsvg&&this.skin),this._netlistsvgReady&&console.log("NetlistSVG ready."),this.setStatus(this._unreadyStatus()??Ol)}_unreadyStatus(){return this._netlistsvgReady?null:wt(this.appState)?"The schematic is not available in saved reports.":"Init error: netlistsvg or its skin is missing from the page."}syncCone(e={}){let i=this.controls.querySelector("#schematic-fanin-depth"),o=this.controls.querySelector("#schematic-fanout-depth"),r=(l,h,u)=>{if(!l)return;let f=parseInt(l.max,10)||10;h===!1?l.value=0:u!==void 0&&(l.value=u>0?Math.min(u,f):f)};r(i,e.fanin,e.fanin_depth),r(o,e.fanout,e.fanout_depth),this.refresh(),this.appState.focusComponent&&this.appState.focusComponent("SchematicWidget")}refresh(){if(!this._netlistsvgReady){this.setStatus(this._unreadyStatus());return}let e=this.appState.selectedInstanceName;if(!e){this.setStatus(Ol);return}let i=this.appState.websocketManager;if(!i){this.setStatus("Waiting for server connection\u2026");return}this.setStatus(`Loading schematic for ${e}\u2026`);let o=parseInt(this.controls.querySelector("#schematic-fanin-depth").value,10),r=parseInt(this.controls.querySelector("#schematic-fanout-depth").value,10),l=isNaN(o)?1:o,h=isNaN(r)?1:r;i.readyPromise.then(()=>{i.request({type:"schematic_cone",inst_name:e,fanin_depth:l,fanout_depth:h}).then(u=>{let f=u.modules&&u.modules.top&&u.modules.top.cells;if(!f||Object.keys(f).length===0){this.setStatus("No cells found for selected instance.");return}this.renderNetlist(u)}).catch(u=>{this.setStatus(`Error: ${u}`)})})}setStatus(e){this.controls.querySelector("#schematic-status").textContent=e}_exportSvg(){if(!this._svgEl){this.setStatus("No schematic to export.");return}let e=Oo(this._svgEl);pl(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),"schematic.svg")}async _exportPng(){if(!this._svgEl){this.setStatus("No schematic to export.");return}try{let e=await $o(this._svgEl,2);yi(e,"schematic.png")}catch{this.setStatus("PNG export failed.")}}async _copyImage(){if(!this._svgEl){this.setStatus("No schematic to export.");return}try{let e=await $o(this._svgEl,2),i=await ps(e);this.setStatus(i?"Schematic copied to clipboard.":"Clipboard not available.")}catch{this.setStatus("Copy failed.")}}async renderNetlist(e){try{this.setStatus("Rendering\u2026"),typeof window<"u"&&(window.__lastSchematic=e);let i=qd(e),o,r=this.netlistsvg.render(this.skin,i);if(r&&typeof r.then=="function"?o=await r:o=await new Promise((u,f)=>{this.netlistsvg.render(this.skin,i,(_,y)=>{_?f(_):u(y)})}),typeof o!="string"||!o.includes("requestAnimationFrame(()=>this.fitView()));let h=Object.keys(e.modules.top.cells).length;this.setStatus(`${h} cell${h!==1?"s":""}`)}catch(i){console.error("NetlistSVG render failed:",i),this.setStatus(`Render error: ${i.message||i}`)}}_applyPinLabels(e){if(!this._svgEl)return;let i="http://www.w3.org/2000/svg",o="https://github.com/nturley/netlistsvg",r=e.modules&&e.modules.top&&e.modules.top.cells||{},l=(h,u)=>h.getAttribute("s:"+u)??h.getAttributeNS(o,u);for(let[h,u]of Object.entries(r)){let f=u.port_labels;if(!f)continue;let _=this._svgEl.querySelector("#"+CSS.escape("cell_"+h))||this._svgEl.querySelector("#"+CSS.escape(h));if(!_)continue;let y=u.port_directions||{};for(let g of Array.from(_.children)){if(g.tagName!=="g")continue;let v=l(g,"pid");if(!v||!(v in f))continue;let w=parseFloat(l(g,"x")),b=parseFloat(l(g,"y"));if(!isFinite(w)||!isFinite(b))continue;let C=document.createElementNS(i,"text");y[v]==="input"?(C.setAttribute("class","inputPortLabel"),C.setAttribute("x",w-3)):C.setAttribute("x",w+4),C.setAttribute("y",b-4),C.setAttribute("style","font-size:5px"),C.setAttribute("pointer-events","none"),C.textContent=f[v],_.appendChild(C)}}}_scopeSkinStyles(){if(!this._svgEl)return;let e=".schematic-widget",i=o=>{for(let r of o)r.selectorText?r.selectorText=$d(r.selectorText,e):r.cssRules&&i(r.cssRules)};for(let o of this._svgEl.querySelectorAll("style")){let r=o.sheet;if(r)try{i(r.cssRules)}catch{continue}}}};function $d(s,e){return s.split(",").map(i=>{let o=i.trim();if(!o)return"";let r=o.charAt(e.length);return o.startsWith(e)&&(r===""||!/[\w-]/.test(r))?o:`${e} ${o}`}).filter(Boolean).join(", ")}var $l={and:"$_AND_",nand:"$_NAND_",or:"$_OR_",nor:"$_NOR_",xor:"$_XOR_",xnor:"$_XNOR_",not:"$_NOT_",buf:"$_BUF_"},Hd=new Set(["aoi21","aoi22","aoi211","aoi221","aoi222","aoi33","oai21","oai22","oai211","oai221","oai222","oai33"]),Fd=new Set(["and3","and4","or3","or4","nand3","nand4","nor3","nor4"]),Hl=["A","B","C","D","E","F"];function Zd(s){let e=s&&s.gate_kind;if(!e)return s;let i=s.port_directions||{},o=null,r=[];for(let[g,v]of Object.entries(i))v==="output"&&o===null?o=g:v==="input"&&r.push(g);let l,h={};if(e==="aoi"||e==="oai"){let g=Array.isArray(s.gate_terms)?s.gate_terms:[];if(!g.length)return s;let v=g.map(C=>C.length);if(l=e+v.slice().sort((C,R)=>R-C).join(""),!Hd.has(l))return s;let w=g.map(C=>C.slice()).sort((C,R)=>C.length-R.length),b=0;for(let C of w)for(let R of C)h[R]=Hl[b]||"I"+b,b++}else{let g=r.length;if(e==="not"||e==="buf")l=$l[e];else if(g<=2)l=$l[e];else if(l=e+g,!Fd.has(l))return s;if(!l)return s;r.forEach((v,w)=>{h[v]=Hl[w]||"I"+w})}o!==null&&(h[o]="Y");let u=s.connections||{},f={},_={};for(let[g,v]of Object.entries(u))h[g]&&(f[h[g]]=v);for(let[g,v]of Object.entries(i))h[g]&&(_[h[g]]=v);let y={};for(let[g,v]of Object.entries(h))y[v]=g;return{...s,type:l,connections:f,port_directions:_,port_labels:y}}function qd(s){let e=s&&s.modules&&s.modules.top;if(!e||!e.cells)return s;let i={};for(let[o,r]of Object.entries(e.cells))i[o]=Zd(r);return{...s,modules:{...s.modules,top:{...e,cells:i}}}}var Ps=class{constructor(e,i,o){this._app=e,this._redrawAllLayers=i,this._refreshOverlay=o||i,this._categories=[],this._activeCategory="",this._markerTree=null,this._expandedNodes=new Set,this._build(),this._app.websocketManager.readyPromise.then(()=>this.refresh())}_build(){let e=document.createElement("div");e.className="drc-widget";let i=document.createElement("div");i.className="drc-toolbar",this._categorySelect=document.createElement("select"),this._categorySelect.className="drc-category-select",i.appendChild(this._categorySelect),this._loadBtn=document.createElement("button"),this._loadBtn.className="or-btn or-btn-sm",this._loadBtn.textContent="Load...",i.appendChild(this._loadBtn),e.appendChild(i),this._infoBar=document.createElement("div"),this._infoBar.className="drc-info-bar",e.appendChild(this._infoBar),this._treeContainer=document.createElement("div"),this._treeContainer.className="drc-tree-container",e.appendChild(this._treeContainer),this.element=e,this._bindEvents()}_bindEvents(){this._categorySelect.addEventListener("change",()=>{this._activeCategory=this._categorySelect.value,this._loadMarkers()}),this._loadBtn.addEventListener("click",()=>{this._showLoadDialog()})}_loadCategories(){return this._app.websocketManager.request({type:"drc_categories"}).then(e=>{this._categories=e.categories||[],this._renderCategorySelect()}).catch(e=>{console.error("Failed to load DRC categories:",e)})}refresh(){this._loadCategories().then(()=>{!this._activeCategory&&this._categories.length>0&&(this._activeCategory=this._categories[0].name,this._categorySelect.value=this._activeCategory),this._activeCategory&&this._loadMarkers()})}_renderCategorySelect(){let e=this._categorySelect,i=e.value;e.innerHTML="";let o=document.createElement("option");o.value="",o.textContent="(none)",e.appendChild(o);for(let r of this._categories){let l=document.createElement("option");l.value=r.name,l.textContent=`${r.name} (${r.count})`,e.appendChild(l)}this._activeCategory&&this._categories.some(r=>r.name===this._activeCategory)?e.value=this._activeCategory:i&&this._categories.some(r=>r.name===i)?(e.value=i,this._activeCategory=i):this._activeCategory=""}_loadMarkers(){if(!this._activeCategory){this._markerTree=null,this._treeContainer.innerHTML="",this._infoBar.textContent="",this._refreshOverlay();return}this._treeContainer.innerHTML='
Loading...
',this._app.websocketManager.request({type:"drc_markers",category:this._activeCategory}).then(e=>{this._markerTree=e,this._renderTree(),this._refreshOverlay()}).catch(e=>{this._treeContainer.innerHTML="";let i=document.createElement("div");i.className="drc-error",i.textContent=`Error: ${e}`,this._treeContainer.appendChild(i),console.error("Failed to load DRC markers:",e)})}_renderTree(){if(this._treeContainer.innerHTML="",!this._markerTree)return;if(this._markerTree.error){let h=document.createElement("div");h.className="drc-error",h.textContent=this._markerTree.error,this._treeContainer.appendChild(h);return}let e=this._markerTree.total_count||0;this._infoBar.textContent=`${e} total violation${e!==1?"s":""}`;let i=this._markerTree.name||this._activeCategory,o=this._markerTree.subcategories||[],r=this._markerTree.markers||[];if(o.length===0&&r.length===0){this._treeContainer.innerHTML='
No violations
';return}let l=document.createElement("div");l.className="drc-tree",r.length>0&&l.appendChild(this._buildCategoryNode({name:i||"Markers",count:r.length,markers:r},[]));for(let h of o)l.appendChild(this._buildCategoryNode(h,[i]));this._treeContainer.appendChild(l)}_buildCategoryNode(e,i=[]){let o=[...i,e.name],r=document.createElement("div");r.className="drc-tree-node";let l=document.createElement("div");l.className="drc-tree-header";let h=document.createElement("span");h.className="drc-toggle";let u=e.subcategories&&e.subcategories.length>0||e.markers&&e.markers.length>0,f=JSON.stringify(o),_=this._expandedNodes.has(f);h.textContent=u?_?"\u25BC":"\u25B6":" ",l.appendChild(h);let y=document.createElement("input");y.type="checkbox",y.checked=this._allMarkersVisible(e),y.className="drc-visibility-check",y.addEventListener("change",b=>{b.stopPropagation(),this._toggleCategoryVisibility(e,y.checked,o)}),l.appendChild(y);let g=document.createElement("span");g.className="drc-category-label",g.textContent=e.name,l.appendChild(g);let v=document.createElement("span");v.className="drc-count",v.textContent=`${e.count} markers`,l.appendChild(v),r.appendChild(l);let w=document.createElement("div");if(w.className="drc-tree-children",w.style.display=_?"":"none",e.subcategories)for(let b of e.subcategories)w.appendChild(this._buildCategoryNode(b,o));if(e.markers)for(let b of e.markers)w.appendChild(this._buildMarkerNode(b));return r.appendChild(w),u&&(l.addEventListener("click",b=>{if(b.target===y)return;let C=w.style.display!=="none";w.style.display=C?"none":"",h.textContent=C?"\u25B6":"\u25BC",C?this._expandedNodes.delete(f):this._expandedNodes.add(f)}),l.style.cursor="pointer"),r}_buildMarkerNode(e){let i=document.createElement("div");i.className="drc-marker-row",i.dataset.markerId=e.id,e.visited||i.classList.add("drc-unvisited");let o=document.createElement("input");o.type="checkbox",o.checked=e.visible,o.className="drc-visibility-check",o.addEventListener("change",h=>{h.stopPropagation(),e.visible=o.checked,this._updateMarker(e.id,"visible",o.checked)}),i.appendChild(o);let r=document.createElement("span");r.className="drc-marker-index",r.textContent=e.index,i.appendChild(r);let l=document.createElement("span");if(l.className="drc-marker-name",l.textContent=e.name,e.layer&&(l.title=`Layer: ${e.layer}`),i.appendChild(l),e.layer){let h=document.createElement("span");h.className="drc-layer-badge",h.textContent=e.layer,i.appendChild(h)}return i.addEventListener("click",h=>{h.target!==o&&this._highlightMarker(e)}),i.addEventListener("dblclick",h=>{h.target!==o&&this._highlightMarker(e,!0)}),i}highlightMarkerById(e,i=!1){let o=this._findMarkerById(e);o&&this._highlightMarker(o,i)}_findMarkerById(e){let i=o=>{if(!o)return null;if(o.markers){for(let r of o.markers)if(r.id===e)return r}if(o.subcategories)for(let r of o.subcategories){let l=i(r);if(l)return l}return null};return i(this._markerTree)}_highlightMarker(e,i=!1){this._app.websocketManager.request({type:"drc_highlight",marker_id:e.id,open_inspector:i}).then(o=>{if(o.ok&&o.bbox){e.visited=!0;let r=this._treeContainer.querySelector(`.drc-marker-row[data-marker-id="${e.id}"]`);r&&r.classList.remove("drc-unvisited"),this._zoomToBBox(o.bbox),this._refreshOverlay(),i&&(o.select_id!=null&&this._app.navigateInspector&&this._app.navigateInspector(o.select_id),this._app.focusComponent&&this._app.focusComponent("Inspector"))}}).catch(o=>{console.error("Failed to highlight DRC marker:",o)})}_zoomToBBox(e){if(!this._app.designScale||!this._app.map)return;let[i,o,r,l]=e,h=r-i,u=l-o,_=10*this._app.getDbuPerMicron(),y=2*Math.max(h,u),g=Math.min(_,y);this._app.map.fitBounds(Gt(i-g,o-g,r+g,l+g,this._app.designScale,this._app.designMaxDXDY,this._app.designOriginX,this._app.designOriginY))}_updateMarker(e,i,o){this._app.websocketManager.request({type:"drc_update_marker",marker_id:e,field:i,value:!!o}).then(()=>{this._refreshOverlay(),i==="visible"&&(this._update3DHighlights(),o&&this._flashHighlight())}).catch(r=>{console.error("Failed to update DRC marker:",r)})}_flashHighlight(){let e=this._app.map?.getContainer();e&&(e.classList.remove("drc-flashing"),e.offsetWidth,e.classList.add("drc-flashing"),e.addEventListener("animationend",()=>{e.classList.remove("drc-flashing")},{once:!0}))}_update3DHighlights(){let e=this._app.threeDViewerWidget;if(!e)return;let i=[];this._collectVisibleMarkers(this._markerTree,i),i.length>0?e.highlightDRC(i):e.clearHighlightDRC()}_collectVisibleMarkers(e,i){if(e){if(e.markers)for(let o of e.markers)o.visible&&i.push(o);if(e.subcategories)for(let o of e.subcategories)this._collectVisibleMarkers(o,i)}}_setMarkersVisible(e,i){if(e){if(e.markers)for(let o of e.markers)o.visible=i;if(e.subcategories)for(let o of e.subcategories)this._setMarkersVisible(o,i)}}_snapshotMarkerVisibility(e,i=new Map){if(!e)return i;if(e.markers)for(let o of e.markers)i.set(o.id,o.visible);if(e.subcategories)for(let o of e.subcategories)this._snapshotMarkerVisibility(o,i);return i}_restoreMarkerVisibility(e,i){if(e){if(e.markers)for(let o of e.markers)i.has(o.id)&&(o.visible=i.get(o.id));if(e.subcategories)for(let o of e.subcategories)this._restoreMarkerVisibility(o,i)}}_allMarkersVisible(e){if(e.markers){for(let i of e.markers)if(!i.visible)return!1}if(e.subcategories){for(let i of e.subcategories)if(!this._allMarkersVisible(i))return!1}return!0}_toggleCategoryVisibility(e,i,o){let r=this._snapshotMarkerVisibility(e);this._setMarkersVisible(e,i),this._renderTree(),this._app.websocketManager.request({type:"drc_update_category_visibility",category:e.name,path:o||[e.name],visible:!!i}).then(()=>{this._refreshOverlay(),this._update3DHighlights(),i&&this._flashHighlight()}).catch(l=>{console.error("Failed to update category visibility:",l),this._restoreMarkerVisibility(e,r),this._renderTree()})}_showLoadDialog(){new Vo(this._app,i=>{this._activeCategory=i,this._loadCategories().then(()=>{this._categorySelect.value=this._activeCategory,this._loadMarkers()})}).open()}selectCategory(e){this._activeCategory=e,this._categorySelect.value=e,this._loadMarkers()}},Vo=class{constructor(e,i){this._app=e,this._onLoaded=i,this._currentPath="",this._disposers=[],this._closed=!1}open(){this._overlay=document.createElement("div"),this._overlay.className="modal-overlay",this._overlay.innerHTML=` +
`,document.body.appendChild(t);function i(s){s.key==="Escape"&&r()}let r=()=>{t.remove(),document.removeEventListener("keydown",i)};return t.addEventListener("click",s=>{s.target===t&&r()}),document.addEventListener("keydown",i),{overlay:t,body:t.querySelector(".modal-body"),errorDiv:t.querySelector(".modal-error"),buttons:t.querySelector(".modal-buttons"),close:r}}function ii(n,e){n.textContent=e,n.style.display=e?"":"none"}function Jo(n,e,{primary:t=!1}={}){let i=document.createElement("button");return i.textContent=e,i.className="or-btn"+(t?" or-btn-primary":""),n.appendChild(i),i}function Xh(n){return"{"+String(n)+"}"}function EM(n){let e=wM("Global Connect","gc-dialog"),t=document.createElement("div");t.className="gc-table",e.body.appendChild(t);let i=document.createElement("div");i.className="gc-form";let r=document.createElement("input");r.placeholder="Instance pattern (regex)",r.value=".*";let s=document.createElement("input");s.placeholder="Pin pattern (regex)";let o=document.createElement("select"),a=document.createElement("select"),c=document.createElement("span");c.innerHTML='',i.append(dr("Instance",r),dr("Pin",s),dr("Net",o),dr("Region",a),c);let l=Jo(i,"Add rule");e.body.appendChild(i);function u(){let p=s.value.trim()!==""&&o.value!=="";for(let m of[r,s])try{new RegExp(m.value),m.classList.remove("gc-invalid")}catch{m.classList.add("gc-invalid"),p=!1}l.disabled=!p}r.addEventListener("input",u),s.addEventListener("input",u),o.addEventListener("change",u);function f(){n.websocketManager.request({type:"global_connect_info"}).then(p=>{t.innerHTML='
InstancePinNetRegion
',(p.rules||[]).forEach(m=>{let g=document.createElement("div");g.className="gc-row",g.innerHTML=`${Hl(m.inst)}${Hl(m.pin)}${Hl(m.net)}${Hl(m.region||"All")}`;let v=document.createElement("button");v.className="or-btn or-btn-sm or-btn-icon",v.textContent="\u2715",v.title="Delete rule",v.addEventListener("click",()=>{n.websocketManager.request({type:"global_connect_delete",inst:m.inst,pin:m.pin,net:m.net,region:m.region||""}).then(f).catch(y=>ii(e.errorDiv,String(y)))}),g.appendChild(v),t.appendChild(g)}),av(o,p.nets||[]),av(a,["All",...p.regions||[]]),u()}).catch(p=>ii(e.errorDiv,String(p)))}l.addEventListener("click",()=>{let p=i.querySelector('input[name="gc-pg"]:checked').value,m=`add_global_connection -net ${Xh(o.value)} -inst_pattern ${Xh(r.value||".*")} -pin_pattern ${Xh(s.value)} -${p}`;a.value&&a.value!=="All"&&(m+=` -region ${Xh(a.value)}`),xM(n,m,e.errorDiv,"Rule added.",f)}),Jo(e.buttons,"Apply (force)").addEventListener("click",()=>{n.websocketManager.request({type:"global_connect_apply",force:!0}).then(p=>{if(!p.had_rules){ii(e.errorDiv,"No global-connect rules defined \u2014 add a rule first.");return}ii(e.errorDiv,`Connected ${p.connected} pin(s).`),n.scheduleRedrawAllLayers&&n.scheduleRedrawAllLayers(),f()}).catch(p=>ii(e.errorDiv,p.message||String(p)))}),Jo(e.buttons,"Clear all").addEventListener("click",()=>xM(n,"clear_global_connect",e.errorDiv,"Rules cleared.",f)),Jo(e.buttons,"Close").addEventListener("click",e.close),f()}function xM(n,e,t,i,r){n.websocketManager.request({type:"tcl_eval",cmd:e}).then(s=>{if(s.is_error){ii(t,s.output||s.result||"Command failed");return}ii(t,i||""),n.scheduleRedrawAllLayers&&n.scheduleRedrawAllLayers(),r&&r()}).catch(s=>ii(t,s.message||String(s)))}function SM(n,e){let t=wM(`Insert Buffer \u2014 ${Hl(e)}`,"buf-dialog"),i=Jo(t.buttons,"Insert",{primary:!0});i.disabled=!0,Jo(t.buttons,"Cancel").addEventListener("click",t.close),n.websocketManager.request({type:"buffer_info",net:e}).then(s=>{if(!s.can_buffer){t.body.textContent=s.error||"This net has multiple drivers and cannot be buffered.";return}zW(n,t,e,s,i)}).catch(s=>{t.body.textContent=String(s)})}function zW(n,e,t,i,r){let s=document.createElement("div");s.className="buf-pins";let o=i.drivers||[],a=i.loads||[],c=new Set;function l(){s.innerHTML="";let p=(m,g)=>{let v=document.createElement("label");v.className="buf-pin";let y=document.createElement("input");y.type="checkbox",y.checked=c.has(m.id),y.addEventListener("change",()=>{if(y.checked){if(g)c.clear();else for(let b of o)c.delete(b.id);c.add(m.id)}else c.delete(m.id);l(),h()}),v.append(y,document.createTextNode(" "+m.label)),s.appendChild(v)};o.forEach(m=>p(m,!0)),a.forEach(m=>p(m,!1))}o.length&&c.add(o[0].id),l();let u=document.createElement("select");av(u,i.masters||[]);let f=document.createElement("input");f.placeholder="Optional: new buffer name";let d=document.createElement("input");d.placeholder="Optional: new net name",e.body.append(dr("Pins to buffer",s),dr("Buffer master",u),dr("Buffer name",f),dr("Net name",d));function h(){r.disabled=c.size===0||!u.value}u.addEventListener("change",h),h(),r.addEventListener("click",()=>{let p=new Set(o.map(v=>v.id)),m=[...c],g=m.some(v=>p.has(v))?"driver":"loads";n.websocketManager.request({type:"insert_buffer",net:t,mode:g,pins:m,master:u.value,buf_name:f.value.trim(),net_name:d.value.trim()}).then(v=>{if(v.is_error||v.ok===!1){ii(e.errorDiv,v.error||v.result||"Insertion failed");return}e.close(),v.inst&&(n.selectedInstanceName=v.inst),n.scheduleRedrawAllLayers&&n.scheduleRedrawAllLayers()}).catch(v=>ii(e.errorDiv,v.message||String(v)))})}function dr(n,e){let t=document.createElement("label");t.className="edit-field";let i=document.createElement("span");return i.textContent=n,t.append(i,e),t}function av(n,e){let t=n.value;n.innerHTML="";for(let i of e){let r=document.createElement("option");r.value=i,r.textContent=i,n.appendChild(r)}e.includes(t)&&(n.value=t)}function Hl(n){return String(n??"").replace(/&/g,"&").replace(//g,">")}var PM="#00ffff",UW="#ffff00",CM="#ffffff",$W=4,Ms=0,cv=1,Yl=2,Kh=class{constructor(e,t,i,r){this._app=e,this._visibility=t,this._updateInspector=i,this._focusComponent=r,this._state=Ms,this._rulers=[],this._nextId=0,this._pt0=null,this._selectedRulerId=null,this._ctrlHeld=!1,this._shiftHeld=!1,this._snapTimer=null,this._lastSnapResult=null,this._snapShapes=null,this._preview=null,e.view?.on("zoom",()=>this._renderRulerShapes())}isActive(){return this._state!==Ms}updateVisibility(){this._renderAll(),this._drawTransient()}_shown(){return this._visibility.rulers!==!1}toggleRulerMode(){this._state===Ms?this._enterFirstPoint():this.cancelRulerBuild()}cancelRulerBuild(){this._state=Ms,this._pt0=null,this._lastSnapResult=null,this._clearTransient(),this._setCursor(!1)}clearAllRulers(){this._rulers=[],this._selectedRulerId=null,this._renderAll(),this._clearTransient(),this._state!==Ms&&this.cancelRulerBuild()}_enterFirstPoint(){this._state=cv,this._pt0=null,this._lastSnapResult=null,this._setCursor(!0)}_enterMeasuring(e){this._state=Yl,this._pt0=e}_toDbu(e){return wn(e[0],e[1],this._app.designScale,this._app.designOriginX,this._app.designOriginY)}_toWorld(e,t){return xn(e,t,this._app.designScale,this._app.designOriginX,this._app.designOriginY)}handleMouseMove(e,t){if(this._state===Ms)return;this._ctrlHeld=t.ctrlKey||t.metaKey,this._shiftHeld=t.shiftKey;let i=this._toDbu(e);this._snapTimer&&clearTimeout(this._snapTimer),this._snapTimer=setTimeout(()=>{this._requestSnap(i.dbuX,i.dbuY)},50)}handleMapClick(e,t){if(this._state===Ms)return;this._ctrlHeld=t.ctrlKey||t.metaKey,this._shiftHeld=t.shiftKey;let i=this._toDbu(e),r=this._getSnappedPoint(i.dbuX,i.dbuY);this._state===cv?this._enterMeasuring(r):this._state===Yl&&(this._createRuler(this._pt0,r),this._state=cv,this._pt0=null,this._clearTransient(),this._lastSnapResult=null)}async _requestSnap(e,t){let i=this._app;if(!i.websocketManager||!i.designScale)return;if(this._ctrlHeld){this._lastSnapResult=null,this._snapShapes=null,this._updatePreview(e,t);return}let s=i.techData?.dbu_per_micron||1e3,o=i.view.getZoom(),a=Math.pow(2,Math.max(0,o)),c=1/(i.designScale*a),l=Math.max(Math.round(10*c),10),u=!0,f=!0;if(this._shiftHeld)u=!0,f=!0;else if(this._state===Yl&&this._pt0){let h=Math.abs(e-this._pt0.x),p=Math.abs(t-this._pt0.y);h>p?(u=!1,f=!0):p>h&&(u=!0,f=!1)}let d={};for(let[h,p]of Object.entries(this._visibility))d[h]=!!p;try{let h=await i.websocketManager.request({type:"snap",dbu_x:e,dbu_y:t,radius:s,point_threshold:l,horizontal:!!u,vertical:!!f,visible_layers:[...i.visibleLayerNames],...d});this._lastSnapResult=h,this._updateSnapIndicator(h),this._updatePreview(e,t)}catch{this._lastSnapResult=null,this._clearSnap()}}_getSnappedPoint(e,t){if(this._ctrlHeld)return{x:e,y:t};let i=this._lastSnapResult,r;if(i?.found&&i.is_point)r={x:i.edge[0][0],y:i.edge[0][1]};else if(i?.found){let s=i.edge;s[0][1]===s[1][1]?r={x:e,y:s[0][1]}:r={x:s[0][0],y:t}}else r={x:e,y:t};if(!this._shiftHeld&&this._state===Yl&&this._pt0){let s=Math.abs(r.x-this._pt0.x),o=Math.abs(r.y-this._pt0.y);sthis._toWorld(r.x,r.y))}}_rulerShapes(e){let t=e.id===this._selectedRulerId,i=Nt(t?UW:PM),{joinPt:r,points:s}=this._rulerPath(e),o=[{kind:"path",points:s,stroke:i,width:2}],a=this._app.view.getZoom(),c=Math.pow(2,Math.max(0,a)),u=8*(1/(this._app.designScale*c)),f=(d,h,p)=>{let m=Math.sqrt(h*h+p*p);if(m===0)return;let g=-p/m,v=h/m;o.push({kind:"path",stroke:i,width:2,points:[this._toWorld(d.x+g*u,d.y+v*u),this._toWorld(d.x-g*u,d.y-v*u)]})};if(r)f(e.pt0,r.x-e.pt0.x,r.y-e.pt0.y),f(e.pt1,e.pt1.x-r.x,e.pt1.y-r.y);else{let d=e.pt1.x-e.pt0.x,h=e.pt1.y-e.pt0.y;f(e.pt0,d,h),f(e.pt1,d,h)}return o}_renderAll(){this._renderRulerShapes(),this._renderRulerLabels()}_renderRulerShapes(){let e=this._app.view;!e||!this._app.designScale||e.setOverlay("rulers",this._shown()?this._rulers.flatMap(t=>this._rulerShapes(t)):null,{order:at.ruler})}_renderRulerLabels(){let e=this._app.view;if(!(!e||!this._app.designScale)&&(e.clearMarkers("ruler-labels"),!!this._shown()))for(let t of this._rulers){let{joinPt:i,points:r}=this._rulerPath(t),s=i?r[1]:[(r[0][0]+r[1][0])/2,(r[0][1]+r[1][1])/2],o=this._computeDistance(t.pt0,t.pt1,t.euclidian);e.addMarker("ruler-labels",t.id,s,this._labelElement(this._formatDistance(o)))}}handleRulerClick(e){let t=this._app.view;if(!t||!this._shown()||this._rulers.length===0)return!1;let i=t.project(e);for(let r of this._rulers){let s=this._rulerPath(r).points.map(o=>t.project(o));for(let o=0;o+1l.id===e);if(!t)return;St(this._app);let i=Math.abs(t.pt1.x-t.pt0.x),r=Math.abs(t.pt1.y-t.pt0.y),s=t.euclidian?Math.sqrt(i*i+r*r):i+r,o=l=>this._app.formatDbu(l,!0),a=l=>this._app.parseDbu(l),c={type:"Ruler",name:t.name,bbox:[Math.min(t.pt0.x,t.pt1.x),Math.min(t.pt0.y,t.pt1.y),Math.max(t.pt0.x,t.pt1.x),Math.max(t.pt0.y,t.pt1.y)],properties:[{name:"Name",value:t.name,editable:!0},{name:"Label",value:t.label||"",editable:!0},{name:"Point 0 - x",value:o(t.pt0.x),editable:!0},{name:"Point 0 - y",value:o(t.pt0.y),editable:!0},{name:"Point 1 - x",value:o(t.pt1.x),editable:!0},{name:"Point 1 - y",value:o(t.pt1.y),editable:!0},{name:"Delta x",value:o(i)},{name:"Delta y",value:o(r)},{name:"Length",value:o(s)},{name:"Euclidian",value:t.euclidian?"True":"False",editable:!0,editor:{type:"bool"}}],onPropertyChange:(l,u)=>{switch(l){case"Name":t.name=u;break;case"Label":t.label=u;break;case"Point 0 - x":{let f=a(u);f!==null&&(t.pt0.x=f);break}case"Point 0 - y":{let f=a(u);f!==null&&(t.pt0.y=f);break}case"Point 1 - x":{let f=a(u);f!==null&&(t.pt1.x=f);break}case"Point 1 - y":{let f=a(u);f!==null&&(t.pt1.y=f);break}case"Euclidian":t.euclidian=u.trim().toLowerCase()==="true";break}this._renderAll(),this._selectRuler(t.id)}};this._updateInspector(c),this._focusComponent("Inspector"),requestAnimationFrame(()=>{let l=this._app.inspectorEl?.querySelector(".inspector-toolbar");if(!l)return;let u=document.createElement("button");u.className="or-btn or-btn-icon",u.title="Delete ruler",u.innerHTML='',u.addEventListener("click",()=>{this.deleteRuler(e)}),l.appendChild(u)})}deleteRuler(e){let t=this._rulers.findIndex(i=>i.id===e);t!==-1&&(this._rulers.splice(t,1),this._renderAll(),this._selectedRulerId===e&&(this._selectedRulerId=null,this._updateInspector(null)))}_getManhattanJoinPt(e,t){return{x:t.x,y:e.y}}_computeDistance(e,t,i=!0){let r=Math.abs(t.x-e.x),s=Math.abs(t.y-e.y);return i?Math.sqrt(r*r+s*s):r+s}_formatDistance(e){return this._app.formatDistance(e)}_setCursor(e){this._app.view?.setCursorMode("ruler",e)}_clearTransient(){this._preview=null,this._snapShapes=null,this._drawTransient()}_clearSnap(){this._snapShapes=null,this._drawTransient()}};function GW(n,e,t){let i=t[0]-e[0],r=t[1]-e[1],s=i*i+r*r,o=s>0?((n[0]-e[0])*i+(n[1]-e[1])*r)/s:0;return o=Math.max(0,Math.min(1,o)),Math.hypot(n[0]-(e[0]+o*i),n[1]-(e[1]+o*r))}var Qh="label-handles",TM=3,Jh=class{constructor(e,t,i,r){this._app=e,this._visibility=t,this._updateInspector=i,this._focusComponent=r,this._labels=[],this._anchors=[],this._mode=!1,this._selectedName=null}isActive(){return this._mode}updateVisibility(){this._app.view?.setMarkerGroupVisible(Qh,!!this._visibility.labels)}toggleLabelMode(){this._mode=!this._mode,this._setCursor(this._mode)}cancelLabelMode(){this._mode=!1,this._setCursor(!1)}_setCursor(e){this._app.view?.setCursorMode("label",e)}_wm(){return this._app.websocketManager}_applyLabels(e){this._labels=e||[],this._renderHandles()}_refresh(e){this._applyLabels(e&&e.labels),this._app.refreshOverlay()}applyRemoteLabels(e){this._applyLabels(e),this._selectedName&&!this._labels.some(t=>t.name===this._selectedName)&&(this._selectedName=null,this._updateInspector(null),this._renderHandles()),this._app.refreshOverlay()}_updateLabel(e,t){return this._wm().request({type:"update_label",name:e,...t})}async reload(){let e=this._wm();if(e)try{let t=await e.request({type:"list_labels"});this._anchors=t.anchors||[],this._applyLabels(t.labels)}catch{this._applyLabels([])}}async handleMapClick(e,t){let i=window.prompt("Label text:");if(this._mode=!1,this._setCursor(!1),!!i)try{let r=await this._wm().request({type:"add_label",x:Math.round(e),y:Math.round(t),text:i});this._refresh(r)}catch(r){console.error("add_label failed:",r)}}_renderHandles(){let e=this._app.view;if(!e)return;e.clearMarkers(Qh);let t=this._app;if(t.designScale)for(let i of this._labels){let r=document.createElement("div");r.className="label-handle"+(i.name===this._selectedName?" label-handle-selected":""),r.title=i.text,this._installDrag(r,i),e.addMarker(Qh,i.name,xn(i.x,i.y,t.designScale,t.designOriginX,t.designOriginY),r,{center:!0})}}_installDrag(e,t){let i=this._app.view,r=a=>{let c=i.getContainer().getBoundingClientRect();return i.unproject([a.clientX-c.left,a.clientY-c.top])},s=null;e.addEventListener("pointerdown",a=>{a.button===0&&(a.stopPropagation(),a.preventDefault(),e.setPointerCapture?.(a.pointerId),s={x:a.clientX,y:a.clientY,moved:!1})}),e.addEventListener("pointermove",a=>{s&&((Math.abs(a.clientX-s.x)>TM||Math.abs(a.clientY-s.y)>TM)&&(s.moved=!0),s.moved&&i.moveMarker(Qh,t.name,r(a)))});let o=(a,c)=>{if(!s)return;let l=s;if(s=null,e.releasePointerCapture?.(a.pointerId),!c)this._renderHandles();else if(!l.moved)this._select(t.name);else{let u=this._app,[f,d]=r(a),{dbuX:h,dbuY:p}=wn(f,d,u.designScale,u.designOriginX,u.designOriginY);this._commitMove(t,Math.round(h),Math.round(p))}};e.addEventListener("pointerup",a=>o(a,!0)),e.addEventListener("pointercancel",a=>o(a,!1)),e.addEventListener("click",a=>a.stopPropagation())}async _commitMove(e,t,i){try{let r=await this._updateLabel(e.name,{x:t,y:i,text:e.text,size:e.size||0,anchor:e.anchor||"center",color:e.color});this._refresh(r)}catch(r){console.error("move label failed:",r)}}_select(e){this._selectedName=e,this._renderHandles();let t=this._labels.find(s=>s.name===e);if(!t)return;let i=s=>this._app.formatDbu(s,!0),r={type:"Label",name:t.name,bbox:[t.x,t.y,t.x,t.y],properties:[{name:"Name",value:t.name},{name:"Text",value:t.text,editable:!0},{name:"x",value:i(t.x)},{name:"y",value:i(t.y)},{name:"Font size",value:String(t.size||0),editable:!0},{name:"Anchor",value:t.anchor||"center",editable:!0,editor:{type:"list",options:this._anchors}}],onPropertyChange:(s,o)=>{let a={text:t.text,size:t.size||0,anchor:t.anchor||"center"};s==="Text"?a.text=o:s==="Font size"?a.size=parseInt(o,10)||0:s==="Anchor"&&(a.anchor=o.trim()),this._edit(t,a)}};this._updateInspector(r),this._focusComponent("Inspector"),requestAnimationFrame(()=>{let s=this._app.inspectorEl?.querySelector(".inspector-toolbar");if(!s||s.querySelector(".delete-label-btn"))return;let o=document.createElement("button");o.className="or-btn or-btn-icon delete-label-btn",o.title="Delete label",o.innerHTML='',o.addEventListener("click",()=>this.deleteLabel(e)),s.appendChild(o)})}async _edit(e,t){try{let i=await this._updateLabel(e.name,{x:e.x,y:e.y,text:t.text,size:t.size,anchor:t.anchor,color:e.color});this._refresh(i),this._select(e.name)}catch(i){console.error("edit label failed:",i)}}async deleteLabel(e){try{let t=await this._wm().request({type:"delete_label",name:e});this._selectedName===e&&(this._selectedName=null,this._updateInspector(null)),this._refresh(t)}catch(t){console.error("delete_label failed:",t)}}async clearAllLabels(){try{let e=await this._wm().request({type:"clear_labels"});this._selectedName=null,this._refresh(e)}catch(e){console.error("clear_labels failed:",e)}}};var LM="Select an instance in the layout to view its schematic.",ep=class{constructor(e,t){this.container=e,this.appState=t,this.element=document.createElement("div"),this.element.className="schematic-widget",this.element.style.cssText="width:100%; height:100%; display:flex; flex-direction:column; background:var(--bg-panel); color:var(--fg-primary); overflow:hidden;",this.controls=document.createElement("div"),this.controls.style.cssText="padding:4px 8px; background:var(--bg-header); border-bottom:1px solid var(--border);flex-shrink:0; display:flex; align-items:center; gap:8px; flex-wrap:wrap;",this.controls.innerHTML='',this.element.appendChild(this.controls),this.svgContainer=document.createElement("div"),this.svgContainer.style.cssText="flex:1; overflow:hidden; position:relative; cursor:grab; background:var(--bg-main);",this.element.appendChild(this.svgContainer),this.container.element.appendChild(this.element),this.controls.querySelector("#schematic-refresh").addEventListener("click",()=>this.refresh()),this.controls.querySelector("#schematic-fit").addEventListener("click",()=>this.fitView()),this.controls.querySelector("#schematic-zoom-in").addEventListener("click",()=>this._zoomStep(1.5)),this.controls.querySelector("#schematic-zoom-out").addEventListener("click",()=>this._zoomStep(1/1.5)),this.controls.querySelector("#schematic-select").addEventListener("click",()=>this._toggleSelectMode()),this.controls.querySelector("#schematic-zoom-to").addEventListener("click",()=>this._zoomToSelected()),this.controls.querySelector("#schematic-save-svg").addEventListener("click",()=>this._exportSvg()),this.controls.querySelector("#schematic-save-png").addEventListener("click",()=>this._exportPng()),this.controls.querySelector("#schematic-copy").addEventListener("click",()=>this._copyImage()),this.appState.schematicWidget=this,this.netlistsvg=null,this.skin=null,this._svgEl=null,this._scale=1,this._panX=0,this._panY=0,this._selectMode=!1,this._selectedCell=null,this._svgIdToInstName=new Map,this._setupPanZoom(),this.initNetlistSVG()}_setupPanZoom(){let e=this.svgContainer,t=!1,i,r,s,o;e.addEventListener("wheel",a=>{if(!this._svgEl)return;a.preventDefault();let c=a.deltaY<0?1.2:1/1.2,l=e.getBoundingClientRect(),u=a.clientX-l.left,f=a.clientY-l.top;this._panX=u+(this._panX-u)*c,this._panY=f+(this._panY-f)*c,this._scale*=c,this._applyTransform()},{passive:!1}),e.addEventListener("mousedown",a=>{if(!(!this._svgEl||a.button!==0)){if(this._selectMode){this._handleSelectClick(a);return}t=!0,i=a.clientX,r=a.clientY,s=this._panX,o=this._panY,e.style.cursor="grabbing",a.preventDefault()}}),window.addEventListener("mousemove",a=>{t&&(this._panX=s+(a.clientX-i),this._panY=o+(a.clientY-r),this._applyTransform())}),window.addEventListener("mouseup",()=>{t&&(t=!1,e.style.cursor=this._selectMode?"default":"grab")})}_zoomStep(e){if(!this._svgEl)return;let t=this.svgContainer.getBoundingClientRect(),i=t.width/2,r=t.height/2;this._panX=i+(this._panX-i)*e,this._panY=r+(this._panY-r)*e,this._scale*=e,this._applyTransform()}_toggleSelectMode(){this._selectMode=!this._selectMode;let e=this.controls.querySelector("#schematic-select");this._selectMode?(e.style.background="var(--accent)",e.style.color="var(--fg-white)",this.svgContainer.style.cursor="default"):(e.style.background="",e.style.color="",this.svgContainer.style.cursor="grab",this._clearCellHighlight())}_handleSelectClick(e){if(!this._svgEl)return;let t=e.target,i=null;for(;t&&t!==this._svgEl;){if(t.tagName==="g"&&t.id&&this._svgIdToInstName.has(t.id)){i=t;break}t=t.parentElement}if(this._clearCellHighlight(),!i)return;let r=this._svgIdToInstName.get(i.id);try{let s=i.getBBox(),o=3,a=document.createElementNS("http://www.w3.org/2000/svg","rect");a.setAttribute("x",s.x-o),a.setAttribute("y",s.y-o),a.setAttribute("width",s.width+o*2),a.setAttribute("height",s.height+o*2),a.setAttribute("fill","none"),a.setAttribute("stroke","#e05a00"),a.setAttribute("stroke-width","1.5"),a.setAttribute("rx","3"),a.id="_schematic_highlight",i.appendChild(a),this._selectedCell=i}catch{}this.controls.querySelector("#schematic-zoom-to").disabled=!1,this.setStatus(`Selected: ${r}`),this._fetchInspect(r)}_fetchInspect(e){let t=this.appState.websocketManager;if(!t)return;console.log("[Schematic] inspect:",e);let i=St(this.appState);t.request({type:"schematic_inspect",inst_name:e,use_dbu:this.appState.showDbu}).then(r=>{Dt(this.appState,i)&&(this.appState.updateInspector&&this.appState.updateInspector(r),this.appState.focusComponent&&this.appState.focusComponent("Inspector"),this.appState.refreshOverlay&&this.appState.refreshOverlay())}).catch(r=>{console.error("schematic_inspect failed:",r),this.setStatus(`Inspect error: ${r}`)})}_clearCellHighlight(){if(this._svgEl){let e=this._svgEl.querySelector("#_schematic_highlight");e&&e.remove()}this._selectedCell=null,this.controls.querySelector("#schematic-zoom-to").disabled=!0}_zoomToSelected(){if(!this._selectedCell||!this._svgEl)return;let e=this.svgContainer.getBoundingClientRect(),t=this._selectedCell.getBoundingClientRect(),i=(t.left-e.left-this._panX)/this._scale,r=(t.top-e.top-this._panY)/this._scale,s=t.width/this._scale,o=t.height/this._scale,a=Math.min(e.width/s,e.height/o)*.9;this._scale=a,this._panX=e.width/2-(i+s/2)*a,this._panY=e.height/2-(r+o/2)*a,this._applyTransform()}_applyTransform(){this._svgEl&&(this._svgEl.style.transform=`translate(${this._panX}px, ${this._panY}px) scale(${this._scale})`,this._svgEl.style.transformOrigin="0 0")}fitView(){if(!this._svgEl)return;let e=this.svgContainer.getBoundingClientRect();if(e.width===0||e.height===0)return;let t=this._svgEl.viewBox&&this._svgEl.viewBox.baseVal,i=t&&t.width||this._svgEl.clientWidth||1,r=t&&t.height||this._svgEl.clientHeight||1;this._scale=Math.min(e.width/i,e.height/r)*.95,this._panX=(e.width-i*this._scale)/2,this._panY=(e.height-r*this._scale)/2,this._applyTransform()}initNetlistSVG(){this.netlistsvg=globalThis.netlistsvg,this.skin=globalThis.openroadSkin,this._netlistsvgReady=!!(this.netlistsvg&&this.skin),this._netlistsvgReady&&console.log("NetlistSVG ready."),this.setStatus(this._unreadyStatus()??LM)}_unreadyStatus(){return this._netlistsvgReady?null:ue(this.appState)?"The schematic is not available in saved reports.":"Init error: netlistsvg or its skin is missing from the page."}syncCone(e={}){let t=this.controls.querySelector("#schematic-fanin-depth"),i=this.controls.querySelector("#schematic-fanout-depth"),r=(s,o,a)=>{if(!s)return;let c=parseInt(s.max,10)||10;o===!1?s.value=0:a!==void 0&&(s.value=a>0?Math.min(a,c):c)};r(t,e.fanin,e.fanin_depth),r(i,e.fanout,e.fanout_depth),this.refresh(),this.appState.focusComponent&&this.appState.focusComponent("SchematicWidget")}refresh(){if(!this._netlistsvgReady){this.setStatus(this._unreadyStatus());return}let e=this.appState.selectedInstanceName;if(!e){this.setStatus(LM);return}let t=this.appState.websocketManager;if(!t){this.setStatus("Waiting for server connection\u2026");return}this.setStatus(`Loading schematic for ${e}\u2026`);let i=parseInt(this.controls.querySelector("#schematic-fanin-depth").value,10),r=parseInt(this.controls.querySelector("#schematic-fanout-depth").value,10),s=isNaN(i)?1:i,o=isNaN(r)?1:r;t.readyPromise.then(()=>{t.request({type:"schematic_cone",inst_name:e,fanin_depth:s,fanout_depth:o}).then(a=>{let c=a.modules&&a.modules.top&&a.modules.top.cells;if(!c||Object.keys(c).length===0){this.setStatus("No cells found for selected instance.");return}this.renderNetlist(a)}).catch(a=>{this.setStatus(`Error: ${a}`)})})}setStatus(e){this.controls.querySelector("#schematic-status").textContent=e}_exportSvg(){if(!this._svgEl){this.setStatus("No schematic to export.");return}let e=tv(this._svgEl);tM(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),"schematic.svg")}async _exportPng(){if(!this._svgEl){this.setStatus("No schematic to export.");return}try{let e=await nv(this._svgEl,2);Ts(e,"schematic.png")}catch{this.setStatus("PNG export failed.")}}async _copyImage(){if(!this._svgEl){this.setStatus("No schematic to export.");return}try{let e=await nv(this._svgEl,2),t=await Nh(e);this.setStatus(t?"Schematic copied to clipboard.":"Clipboard not available.")}catch{this.setStatus("Copy failed.")}}async renderNetlist(e){try{this.setStatus("Rendering\u2026"),typeof window<"u"&&(window.__lastSchematic=e);let t=YW(e),i,r=this.netlistsvg.render(this.skin,t);if(r&&typeof r.then=="function"?i=await r:i=await new Promise((a,c)=>{this.netlistsvg.render(this.skin,t,(l,u)=>{l?c(l):a(u)})}),typeof i!="string"||!i.includes("requestAnimationFrame(()=>this.fitView()));let o=Object.keys(e.modules.top.cells).length;this.setStatus(`${o} cell${o!==1?"s":""}`)}catch(t){console.error("NetlistSVG render failed:",t),this.setStatus(`Render error: ${t.message||t}`)}}_applyPinLabels(e){if(!this._svgEl)return;let t="http://www.w3.org/2000/svg",i="https://github.com/nturley/netlistsvg",r=e.modules&&e.modules.top&&e.modules.top.cells||{},s=(o,a)=>o.getAttribute("s:"+a)??o.getAttributeNS(i,a);for(let[o,a]of Object.entries(r)){let c=a.port_labels;if(!c)continue;let l=this._svgEl.querySelector("#"+CSS.escape("cell_"+o))||this._svgEl.querySelector("#"+CSS.escape(o));if(!l)continue;let u=a.port_directions||{};for(let f of Array.from(l.children)){if(f.tagName!=="g")continue;let d=s(f,"pid");if(!d||!(d in c))continue;let h=parseFloat(s(f,"x")),p=parseFloat(s(f,"y"));if(!isFinite(h)||!isFinite(p))continue;let m=document.createElementNS(t,"text");u[d]==="input"?(m.setAttribute("class","inputPortLabel"),m.setAttribute("x",h-3)):m.setAttribute("x",h+4),m.setAttribute("y",p-4),m.setAttribute("style","font-size:5px"),m.setAttribute("pointer-events","none"),m.textContent=c[d],l.appendChild(m)}}}_scopeSkinStyles(){if(!this._svgEl)return;let e=".schematic-widget",t=i=>{for(let r of i)r.selectorText?r.selectorText=VW(r.selectorText,e):r.cssRules&&t(r.cssRules)};for(let i of this._svgEl.querySelectorAll("style")){let r=i.sheet;if(r)try{t(r.cssRules)}catch{continue}}}};function VW(n,e){return n.split(",").map(t=>{let i=t.trim();if(!i)return"";let r=i.charAt(e.length);return i.startsWith(e)&&(r===""||!/[\w-]/.test(r))?i:`${e} ${i}`}).filter(Boolean).join(", ")}var MM={and:"$_AND_",nand:"$_NAND_",or:"$_OR_",nor:"$_NOR_",xor:"$_XOR_",xnor:"$_XNOR_",not:"$_NOT_",buf:"$_BUF_"},WW=new Set(["aoi21","aoi22","aoi211","aoi221","aoi222","aoi33","oai21","oai22","oai211","oai221","oai222","oai33"]),jW=new Set(["and3","and4","or3","or4","nand3","nand4","nor3","nor4"]),AM=["A","B","C","D","E","F"];function HW(n){let e=n&&n.gate_kind;if(!e)return n;let t=n.port_directions||{},i=null,r=[];for(let[f,d]of Object.entries(t))d==="output"&&i===null?i=f:d==="input"&&r.push(f);let s,o={};if(e==="aoi"||e==="oai"){let f=Array.isArray(n.gate_terms)?n.gate_terms:[];if(!f.length)return n;let d=f.map(m=>m.length);if(s=e+d.slice().sort((m,g)=>g-m).join(""),!WW.has(s))return n;let h=f.map(m=>m.slice()).sort((m,g)=>m.length-g.length),p=0;for(let m of h)for(let g of m)o[g]=AM[p]||"I"+p,p++}else{let f=r.length;if(e==="not"||e==="buf")s=MM[e];else if(f<=2)s=MM[e];else if(s=e+f,!jW.has(s))return n;if(!s)return n;r.forEach((d,h)=>{o[d]=AM[h]||"I"+h})}i!==null&&(o[i]="Y");let a=n.connections||{},c={},l={};for(let[f,d]of Object.entries(a))o[f]&&(c[o[f]]=d);for(let[f,d]of Object.entries(t))o[f]&&(l[o[f]]=d);let u={};for(let[f,d]of Object.entries(o))u[d]=f;return{...n,type:s,connections:c,port_directions:l,port_labels:u}}function YW(n){let e=n&&n.modules&&n.modules.top;if(!e||!e.cells)return n;let t={};for(let[i,r]of Object.entries(e.cells))t[i]=HW(r);return{...n,modules:{...n.modules,top:{...e,cells:t}}}}var tp=class{constructor(e,t,i){this._app=e,this._redrawAllLayers=t,this._refreshOverlay=i||t,this._categories=[],this._activeCategory="",this._markerTree=null,this._expandedNodes=new Set,this._build(),this._app.websocketManager.readyPromise.then(()=>this.refresh())}_build(){let e=document.createElement("div");e.className="drc-widget";let t=document.createElement("div");t.className="drc-toolbar",this._categorySelect=document.createElement("select"),this._categorySelect.className="drc-category-select",t.appendChild(this._categorySelect),this._loadBtn=document.createElement("button"),this._loadBtn.className="or-btn or-btn-sm",this._loadBtn.textContent="Load...",t.appendChild(this._loadBtn),e.appendChild(t),this._infoBar=document.createElement("div"),this._infoBar.className="drc-info-bar",e.appendChild(this._infoBar),this._treeContainer=document.createElement("div"),this._treeContainer.className="drc-tree-container",e.appendChild(this._treeContainer),this.element=e,this._bindEvents()}_bindEvents(){this._categorySelect.addEventListener("change",()=>{this._activeCategory=this._categorySelect.value,this._loadMarkers()}),this._loadBtn.addEventListener("click",()=>{this._showLoadDialog()})}_loadCategories(){return this._app.websocketManager.request({type:"drc_categories"}).then(e=>{this._categories=e.categories||[],this._renderCategorySelect()}).catch(e=>{console.error("Failed to load DRC categories:",e)})}refresh(){this._loadCategories().then(()=>{!this._activeCategory&&this._categories.length>0&&(this._activeCategory=this._categories[0].name,this._categorySelect.value=this._activeCategory),this._activeCategory&&this._loadMarkers()})}_renderCategorySelect(){let e=this._categorySelect,t=e.value;e.innerHTML="";let i=document.createElement("option");i.value="",i.textContent="(none)",e.appendChild(i);for(let r of this._categories){let s=document.createElement("option");s.value=r.name,s.textContent=`${r.name} (${r.count})`,e.appendChild(s)}this._activeCategory&&this._categories.some(r=>r.name===this._activeCategory)?e.value=this._activeCategory:t&&this._categories.some(r=>r.name===t)?(e.value=t,this._activeCategory=t):this._activeCategory=""}_loadMarkers(){if(!this._activeCategory){this._markerTree=null,this._treeContainer.innerHTML="",this._infoBar.textContent="",this._refreshOverlay();return}this._treeContainer.innerHTML='
Loading...
',this._app.websocketManager.request({type:"drc_markers",category:this._activeCategory}).then(e=>{this._markerTree=e,this._renderTree(),this._refreshOverlay()}).catch(e=>{this._treeContainer.innerHTML="";let t=document.createElement("div");t.className="drc-error",t.textContent=`Error: ${e}`,this._treeContainer.appendChild(t),console.error("Failed to load DRC markers:",e)})}_renderTree(){if(this._treeContainer.innerHTML="",!this._markerTree)return;if(this._markerTree.error){let o=document.createElement("div");o.className="drc-error",o.textContent=this._markerTree.error,this._treeContainer.appendChild(o);return}let e=this._markerTree.total_count||0;this._infoBar.textContent=`${e} total violation${e!==1?"s":""}`;let t=this._markerTree.name||this._activeCategory,i=this._markerTree.subcategories||[],r=this._markerTree.markers||[];if(i.length===0&&r.length===0){this._treeContainer.innerHTML='
No violations
';return}let s=document.createElement("div");s.className="drc-tree",r.length>0&&s.appendChild(this._buildCategoryNode({name:t||"Markers",count:r.length,markers:r},[]));for(let o of i)s.appendChild(this._buildCategoryNode(o,[t]));this._treeContainer.appendChild(s)}_buildCategoryNode(e,t=[]){let i=[...t,e.name],r=document.createElement("div");r.className="drc-tree-node";let s=document.createElement("div");s.className="drc-tree-header";let o=document.createElement("span");o.className="drc-toggle";let a=e.subcategories&&e.subcategories.length>0||e.markers&&e.markers.length>0,c=JSON.stringify(i),l=this._expandedNodes.has(c);o.textContent=a?l?"\u25BC":"\u25B6":" ",s.appendChild(o);let u=document.createElement("input");u.type="checkbox",u.checked=this._allMarkersVisible(e),u.className="drc-visibility-check",u.addEventListener("change",p=>{p.stopPropagation(),this._toggleCategoryVisibility(e,u.checked,i)}),s.appendChild(u);let f=document.createElement("span");f.className="drc-category-label",f.textContent=e.name,s.appendChild(f);let d=document.createElement("span");d.className="drc-count",d.textContent=`${e.count} markers`,s.appendChild(d),r.appendChild(s);let h=document.createElement("div");if(h.className="drc-tree-children",h.style.display=l?"":"none",e.subcategories)for(let p of e.subcategories)h.appendChild(this._buildCategoryNode(p,i));if(e.markers)for(let p of e.markers)h.appendChild(this._buildMarkerNode(p));return r.appendChild(h),a&&(s.addEventListener("click",p=>{if(p.target===u)return;let m=h.style.display!=="none";h.style.display=m?"none":"",o.textContent=m?"\u25B6":"\u25BC",m?this._expandedNodes.delete(c):this._expandedNodes.add(c)}),s.style.cursor="pointer"),r}_buildMarkerNode(e){let t=document.createElement("div");t.className="drc-marker-row",t.dataset.markerId=e.id,e.visited||t.classList.add("drc-unvisited");let i=document.createElement("input");i.type="checkbox",i.checked=e.visible,i.className="drc-visibility-check",i.addEventListener("change",o=>{o.stopPropagation(),e.visible=i.checked,this._updateMarker(e.id,"visible",i.checked)}),t.appendChild(i);let r=document.createElement("span");r.className="drc-marker-index",r.textContent=e.index,t.appendChild(r);let s=document.createElement("span");if(s.className="drc-marker-name",s.textContent=e.name,e.layer&&(s.title=`Layer: ${e.layer}`),t.appendChild(s),e.layer){let o=document.createElement("span");o.className="drc-layer-badge",o.textContent=e.layer,t.appendChild(o)}return t.addEventListener("click",o=>{o.target!==i&&this._highlightMarker(e)}),t.addEventListener("dblclick",o=>{o.target!==i&&this._highlightMarker(e,!0)}),t}highlightMarkerById(e,t=!1){let i=this._findMarkerById(e);i&&this._highlightMarker(i,t)}_findMarkerById(e){let t=i=>{if(!i)return null;if(i.markers){for(let r of i.markers)if(r.id===e)return r}if(i.subcategories)for(let r of i.subcategories){let s=t(r);if(s)return s}return null};return t(this._markerTree)}_highlightMarker(e,t=!1){this._app.websocketManager.request({type:"drc_highlight",marker_id:e.id,open_inspector:t}).then(i=>{if(i.ok&&i.bbox){e.visited=!0;let r=this._treeContainer.querySelector(`.drc-marker-row[data-marker-id="${e.id}"]`);r&&r.classList.remove("drc-unvisited"),this._zoomToBBox(i.bbox),this._refreshOverlay(),t&&(i.select_id!=null&&this._app.navigateInspector&&this._app.navigateInspector(i.select_id),this._app.focusComponent&&this._app.focusComponent("Inspector"))}}).catch(i=>{console.error("Failed to highlight DRC marker:",i)})}_zoomToBBox(e){if(!this._app.designScale||!this._app.view)return;let[t,i,r,s]=e,o=r-t,a=s-i,l=10*this._app.getDbuPerMicron(),u=2*Math.max(o,a),f=Math.min(l,u);this._app.view.fitWorldRect(Ot(t-f,i-f,r+f,s+f,this._app.designScale,this._app.designOriginX,this._app.designOriginY))}_updateMarker(e,t,i){this._app.websocketManager.request({type:"drc_update_marker",marker_id:e,field:t,value:!!i}).then(()=>{this._refreshOverlay(),t==="visible"&&(this._update3DHighlights(),i&&this._flashHighlight())}).catch(r=>{console.error("Failed to update DRC marker:",r)})}_flashHighlight(){this._app.view?.flashTiles()}_update3DHighlights(){let e=this._app.threeDViewerWidget;if(!e)return;let t=[];this._collectVisibleMarkers(this._markerTree,t),t.length>0?e.highlightDRC(t):e.clearHighlightDRC()}_collectVisibleMarkers(e,t){if(e){if(e.markers)for(let i of e.markers)i.visible&&t.push(i);if(e.subcategories)for(let i of e.subcategories)this._collectVisibleMarkers(i,t)}}_setMarkersVisible(e,t){if(e){if(e.markers)for(let i of e.markers)i.visible=t;if(e.subcategories)for(let i of e.subcategories)this._setMarkersVisible(i,t)}}_snapshotMarkerVisibility(e,t=new Map){if(!e)return t;if(e.markers)for(let i of e.markers)t.set(i.id,i.visible);if(e.subcategories)for(let i of e.subcategories)this._snapshotMarkerVisibility(i,t);return t}_restoreMarkerVisibility(e,t){if(e){if(e.markers)for(let i of e.markers)t.has(i.id)&&(i.visible=t.get(i.id));if(e.subcategories)for(let i of e.subcategories)this._restoreMarkerVisibility(i,t)}}_allMarkersVisible(e){if(e.markers){for(let t of e.markers)if(!t.visible)return!1}if(e.subcategories){for(let t of e.subcategories)if(!this._allMarkersVisible(t))return!1}return!0}_toggleCategoryVisibility(e,t,i){let r=this._snapshotMarkerVisibility(e);this._setMarkersVisible(e,t),this._renderTree(),this._app.websocketManager.request({type:"drc_update_category_visibility",category:e.name,path:i||[e.name],visible:!!t}).then(()=>{this._refreshOverlay(),this._update3DHighlights(),t&&this._flashHighlight()}).catch(s=>{console.error("Failed to update category visibility:",s),this._restoreMarkerVisibility(e,r),this._renderTree()})}_showLoadDialog(){new lv(this._app,t=>{this._activeCategory=t,this._loadCategories().then(()=>{this._categorySelect.value=this._activeCategory,this._loadMarkers()})}).open()}selectCategory(e){this._activeCategory=e,this._categorySelect.value=e,this._loadMarkers()}},lv=class{constructor(e,t){this._app=e,this._onLoaded=t,this._currentPath="",this._disposers=[],this._closed=!1}open(){this._overlay=document.createElement("div"),this._overlay.className="modal-overlay",this._overlay.innerHTML=` - `,document.body.appendChild(this._overlay),this._breadcrumb=this._overlay.querySelector(".fb-breadcrumb"),this._fileList=this._overlay.querySelector(".fb-file-list"),this._pathInput=this._overlay.querySelector(".fb-path-input"),this._errorDiv=this._overlay.querySelector(".modal-error"),this._okBtn=this._overlay.querySelector(".ok"),this._cancelBtn=this._overlay.querySelector(".cancel"),this._listen(this._pathInput,"input",()=>this._updateOkState()),this._listen(this._pathInput,"keydown",e=>{if(e.key==="Enter"){let i=this._pathInput.value.trim();i.endsWith("/")?this._navigate(i.replace(/\/+$/,"")||"/"):this._submit()}else e.key==="Escape"&&this.close()}),this._listen(this._okBtn,"click",()=>this._submit()),this._listen(this._cancelBtn,"click",()=>this.close()),this._listen(this._overlay,"click",e=>{e.target===this._overlay&&this.close()}),this._navigate("")}close(){if(!this._closed){this._closed=!0;for(let e of this._disposers)e();this._disposers.length=0,this._overlay&&(this._overlay.remove(),this._overlay=null)}}_listen(e,i,o){e.addEventListener(i,o),this._disposers.push(()=>e.removeEventListener(i,o))}_updateOkState(){this._okBtn.disabled=!this._pathInput.value.trim()}_renderBreadcrumb(e){this._breadcrumb.innerHTML="";let i=e.split("/").filter(Boolean),o=document.createElement("span");o.className="fb-crumb",o.textContent="/",this._listen(o,"click",()=>this._navigate("/")),this._breadcrumb.appendChild(o);let r="";for(let l of i){r+="/"+l;let h=document.createElement("span");h.className="fb-crumb-sep",h.textContent=" / ",this._breadcrumb.appendChild(h);let u=document.createElement("span");u.className="fb-crumb",u.textContent=l;let f=r;this._listen(u,"click",()=>this._navigate(f)),this._breadcrumb.appendChild(u)}}_renderEntries(e){if(this._fileList.innerHTML="",!e||e.length===0){let i=document.createElement("div");i.className="fb-empty",i.textContent="(empty directory)",this._fileList.appendChild(i);return}for(let i of e){let o=document.createElement("div");o.className="fb-entry",i.is_dir&&o.classList.add("fb-dir");let r=document.createElement("span");r.className="fb-icon",r.textContent=i.is_dir?"\u{1F4C1}":"\u{1F4C4}",o.appendChild(r);let l=document.createElement("span");l.className="fb-name",l.textContent=i.name,o.appendChild(l),i.is_dir?this._listen(o,"click",()=>this._navigate(this._currentPath+"/"+i.name)):(this._listen(o,"click",()=>{let h=this._fileList.querySelector(".fb-selected");h&&h.classList.remove("fb-selected"),o.classList.add("fb-selected"),this._pathInput.value=this._currentPath+"/"+i.name,this._updateOkState()}),this._listen(o,"dblclick",()=>{this._pathInput.value=this._currentPath+"/"+i.name,this._updateOkState(),this._submit()})),this._fileList.appendChild(o)}}async _navigate(e){this._errorDiv.style.display="none",this._fileList.innerHTML='
Loading...
';try{let i=await this._app.websocketManager.request({type:"list_dir",path:e||""});if(this._closed)return;this._currentPath=i.path,this._renderBreadcrumb(i.path),this._renderEntries(i.entries),this._pathInput.value="",this._updateOkState()}catch(i){if(this._closed)return;this._fileList.innerHTML="",this._errorDiv.textContent=i.message||String(i),this._errorDiv.style.display=""}}async _submit(){let e=this._pathInput.value.trim();if(e){this._okBtn.disabled=!0,this._okBtn.textContent="Loading...",this._errorDiv.style.display="none";try{let i=await this._app.websocketManager.request({type:"drc_load_report",path:e});if(this._closed)return;if(i.ok){let o=i.category;this.close(),this._onLoaded(o)}else this._errorDiv.textContent=i.error||"Failed to load report",this._errorDiv.style.display="",this._okBtn.disabled=!1,this._okBtn.textContent="Load"}catch(i){if(this._closed)return;this._errorDiv.textContent=i.message||"Request failed",this._errorDiv.style.display="",this._okBtn.disabled=!1,this._okBtn.textContent="Load"}}}};var Wd=` -\r[]{}`;var As=class{constructor(e,i){this._input=e,this._ws=i,this._popup=null,this._items=[],this._selectedIndex=-1,this._replaceStart=0,this._replaceEnd=0,this._debounceTimer=null,this._commandCache=null,this._history=[],this._historyIndex=-1,this._historyStash="",this._createPopup(),this._onInputBound=this._onInput.bind(this),this._onBlurBound=this._onBlur.bind(this),this._input.addEventListener("input",this._onInputBound),this._input.addEventListener("blur",this._onBlurBound)}_createPopup(){this._popup=document.createElement("div"),this._popup.className="tcl-complete-popup",this._popup.style.display="none",this._input.parentElement.appendChild(this._popup)}handleKeyDown(e){let i=this._popup.style.display!=="none";return e.key==="Tab"?(e.preventDefault(),i?this._tabAccept():this._tabComplete(this._input.value,this._input.selectionStart),!0):e.key==="Escape"?i?(this._hidePopup(),!0):!1:e.key==="ArrowDown"?i?(e.preventDefault(),this._selectItem(this._selectedIndex+1),!0):this._historyIndex>=0?(e.preventDefault(),this._historyIndex--,this._historyIndex<0?this._input.value=this._historyStash:this._input.value=this._history[this._historyIndex],!0):!1:e.key==="ArrowUp"?i?(e.preventDefault(),this._selectItem(this._selectedIndex-1),!0):this._historyIndex{let e=this._input.value,i=this._input.selectionStart,o=this._extractPrefix(e,i);o.length>=2||o.length>=1&&(o[0]==="$"||o[0]==="-")?this._requestCompletions(e,i):this._hidePopup()},100)}_onBlur(){setTimeout(()=>this._hidePopup(),150)}_extractPrefix(e,i){let o=i-1;for(;o>=0&&Wd.indexOf(e[o])===-1;)o--;return e.substring(o+1,i)}_fetchCompletions(e,i,o){let r=this._extractPrefix(e,i),l=r.length>0&&r[0]==="$",h=r.length>0&&r[0]==="-",u=!l&&!h,f=i-r.length,_=e.substring(0,f),y=/^[\s\[]*$/.test(_);if(u&&y&&this._commandCache){let g=r.toLowerCase(),v=this._commandCache.filter(w=>w.toLowerCase().startsWith(g));o(v,f,i);return}this._ws.request({type:"tcl_complete",line:e,cursor_pos:i}).then(g=>{g.mode==="commands"&&!this._commandCache&&r===""&&(this._commandCache=g.completions),g.mode==="commands"&&!this._commandCache&&this._ws.request({type:"tcl_complete",line:"",cursor_pos:0}).then(v=>{v.mode==="commands"&&(this._commandCache=v.completions)}).catch(()=>{}),o(g.completions,g.replace_start,g.replace_end)}).catch(()=>o([],0,0))}_requestCompletions(e,i){this._fetchCompletions(e,i,(o,r,l)=>{this._showPopup(o,r,l)})}_tabAccept(){if(this._items.length===0){this._hidePopup();return}if(this._items.length===1){this._selectedIndex=0,this._acceptCompletion();return}this._advanceToCommonPrefix()}_tabComplete(e,i){this._fetchCompletions(e,i,(o,r,l)=>{if(!o||o.length===0){this._hidePopup();return}if(o.length===1){this._items=o,this._replaceStart=r,this._replaceEnd=l,this._selectedIndex=0,this._acceptCompletion();return}this._items=o,this._replaceStart=r,this._replaceEnd=l,this._advanceToCommonPrefix(),this._showPopup(o,this._replaceStart,this._replaceEnd)})}_advanceToCommonPrefix(){if(this._items.length<2)return!1;let e=this._items[0];for(let h=1;h0;h++){let u=this._items[h],f=0;for(;f{let f=document.createElement("div");f.className="tcl-complete-item",f.textContent=h,f.addEventListener("mousedown",_=>{_.preventDefault(),this._selectedIndex=u,this._acceptCompletion()}),this._popup.appendChild(f)}),e.length>15){let h=document.createElement("div");h.className="tcl-complete-more",h.textContent=`... ${e.length-15} more`,this._popup.appendChild(h)}this._selectedIndex=0,this._highlightSelected(),this._popup.style.display="block"}_hidePopup(){this._popup.style.display="none",this._items=[],this._selectedIndex=-1}_selectItem(e){if(this._items.length===0)return;let i=Math.min(this._items.length,15)-1;this._selectedIndex=Math.max(0,Math.min(e,i)),this._highlightSelected()}_highlightSelected(){let e=this._popup.querySelectorAll(".tcl-complete-item");e.forEach((i,o)=>{i.classList.toggle("selected",o===this._selectedIndex)}),e[this._selectedIndex]&&e[this._selectedIndex].scrollIntoView&&e[this._selectedIndex].scrollIntoView({block:"nearest"})}_acceptCompletion(){if(this._selectedIndex<0||this._selectedIndex>=this._items.length){this._hidePopup();return}let e=this._items[this._selectedIndex],i=this._input.value.substring(0,this._replaceStart),o=this._input.value.substring(this._replaceEnd),l=!e.endsWith("/")&&!e.endsWith("::")&&(o.length===0||o[0]!==" ")?" ":"";this._input.value=i+e+l+o;let h=this._replaceStart+e.length+l.length;this._input.setSelectionRange(h,h),this._input.focus(),this._hidePopup()}};var Fl=[{key:"or_visibility",store:"cookie"},{key:"or_selectability",store:"cookie"},{key:"or_hidden_layers",store:"session"},{key:"or_nonselectable_layers",store:"session"},{key:"or_layer_patterns",store:"session"},{key:"or_hidden_chiplets",store:"cookie"},{key:"or_bg_color",store:"cookie"},{key:"or_show_dbu",store:"cookie"},{key:"or_theme",store:"theme"},{key:"or_use_true_z",store:"cookie"},{key:"or_ruler_style",store:"cookie"},{key:"or_wheel_zoom",store:"cookie"},{key:"or_arrow_step",store:"cookie"},{key:"or_font_family",store:"cookie"},{key:"or_font_scale",store:"cookie"}];function Ud(s,e){try{return window[s].getItem(e)}catch{return null}}function Gd(s,e,i){try{i===null?window[s].removeItem(e):window[s].setItem(e,i)}catch{}}function Vd({key:s,store:e}){return e==="session"?Ud("sessionStorage",s):Vt(s)}function Yd({key:s,store:e},i){e==="session"?Gd("sessionStorage",s,i):e==="theme"?i===null?cl():us(i):i===null?ds(s):Qt(s,i)}function Zl(){let s={};for(let e of Fl){let i=Vd(e);i&&(s[e.key]=i)}return{version:1,entries:s}}function Xd(s){return typeof s=="string"&&s!==""&&!/[;\r\n]/.test(s)}function ql(s){for(let e of Fl){let i=s[e.key];Yd(e,Xd(i)?i:null)}}function Wl(s,e=typeof document<"u"?document:null){let i="OpenROAD",o=s?`${i} - ${s}`:i;return e&&(e.title=o),o}var ht=globalThis.THREE,Ul=2,jd=.002,Kd=.9,Jd=1.1,Qd=.1,tu=20,eu=3,wi=2,Gl=2,iu=10,nu=1e4,su=.15,ou=300,ru=6,Is=Math.PI/180,Vl=[5025616,2201331,16750592,10233776,48340,16007990,2533018,7951688,15277667,4149685];function au(s){let e=new Array(s.length).fill(0),i=new Map;s.forEach((o,r)=>{let l=o.z;i.has(l)||i.set(l,[]),i.get(l).push({idx:r,chiplet:o})});for(let o of i.values()){if(o.length<=1)continue;let r=[];for(let{idx:l,chiplet:h}of o){let u=h.x,f=h.y,_=h.x+h.width,y=h.y+h.height,g=!1;for(let v=0;vub.x1&&fb.y1)){r[v].push({x1:u,y1:f,x2:_,y2:y}),e[l]=v,g=!0;break}g||(r.push([{x1:u,y1:f,x2:_,y2:y}]),e[l]=r.length-1)}}return e}var Bs=class{constructor(e,i){if(this._app=i,this._container=e,this._element=document.createElement("div"),this._element.className="three-d-viewer-widget",e.element.appendChild(this._element),!ht){wt(i)?this._showInfo("The 3D view is not available in saved reports."):this._showError("three.js is missing from the page."),this._destroyed=!0;return}this._canvasContainer=document.createElement("div"),this._canvasContainer.className="three-d-canvas-container",this._element.appendChild(this._canvasContainer),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._canvasContainer.appendChild(this._tooltip),this._optionsOverlay=this._createOptionsOverlay(),this._canvasContainer.appendChild(this._optionsOverlay),this._raycaster=new ht.Raycaster,this._scene=new ht.Scene,this._applyTheme(),this._themeObserver=new MutationObserver(()=>{this._applyTheme(),this.render()}),this._themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),this._camera=new ht.PerspectiveCamera(45,1,10,1e5),this._camera.position.set(0,0,1e3);try{this._renderer=new ht.WebGLRenderer({antialias:!0,preserveDrawingBuffer:!0})}catch(h){console.error("3D viewer: failed to create WebGL context:",h),this._showWebGLUnavailable(h),this._themeObserver&&(this._themeObserver.disconnect(),this._themeObserver=null),this._destroyed=!0;return}this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(e.width,e.height),this._canvasContainer.appendChild(this._renderer.domElement),this._rotation=new ht.Quaternion,this._distance=1e3,this._panX=0,this._panY=0,this._boundingRadius=1,this._sceneCenter=new ht.Vector3,this._mouseDown=!1,this._mouseButton=-1,this._lastMousePos={x:0,y:0},this._setupMouseHandlers();let o=new ht.AmbientLight(16777215,.5);this._scene.add(o);let r=new ht.DirectionalLight(16777215,.8);r.position.set(1,1,1).normalize(),this._scene.add(r);let l=new ht.DirectionalLight(16777215,.3);l.position.set(-1,-.5,.5).normalize(),this._scene.add(l),e.on("resize",this.onResize.bind(this)),e.on("open",this.onOpen.bind(this)),e.on("destroy",this.onDestroy.bind(this)),this._designGroup=new ht.Group,this._scene.add(this._designGroup),this._chipletMeshes=[],this._loading=!1,this._destroyed=!1,this._edgeMaterial=null}_setupMouseHandlers(){let e=this._renderer.domElement;e.addEventListener("mousedown",i=>{this._mouseDown=!0,this._mouseButton=i.button,this._lastMousePos.x=i.clientX,this._lastMousePos.y=i.clientY,e.focus(),i.preventDefault()}),e.addEventListener("contextmenu",i=>i.preventDefault()),this._onMouseMove=i=>{if(!this._mouseDown)return;let o=i.clientX-this._lastMousePos.x,r=i.clientY-this._lastMousePos.y;this._lastMousePos.x=i.clientX,this._lastMousePos.y=i.clientY,!(o===0&&r===0)&&(this._mouseButton===0?this._handleRotate(o,r):this._mouseButton===2&&this._handlePan(o,r),this._updateCamera())},this._onMouseUp=i=>{this._mouseDown&&i.button===this._mouseButton&&(this._mouseDown=!1,this._mouseButton=-1)},window.addEventListener("mousemove",this._onMouseMove),window.addEventListener("mouseup",this._onMouseUp),e.addEventListener("wheel",i=>{i.preventDefault(),i.deltaY<0?this._distance*=Kd:this._distance*=Jd;let o=Math.max(this._boundingRadius*Qd,1),r=Math.max(this._boundingRadius*tu,o);this._distance=Math.max(o,Math.min(r,this._distance)),this._updateCamera()},{passive:!1}),e.tabIndex=0,e.style.outline="none",e.addEventListener("keydown",i=>{i.key.toLowerCase()==="f"&&this.resetCamera()}),e.addEventListener("dblclick",i=>{i.preventDefault();let o=this._pickDrcMarkerId(i);if(o!=null&&this._app.drcWidget){this._app.drcWidget.highlightMarkerById(o,!0);return}this.resetCamera()}),e.addEventListener("mousemove",i=>{if(this._mouseDown){this._hideTooltip();return}this._updateTooltip(i)}),e.addEventListener("mouseleave",()=>{this._hideTooltip()})}_createOptionsOverlay(){let e=document.createElement("div");e.className="three-d-options";let i=document.createElement("label");i.title="Render chiplets at their true Z (disable stacking offset for overlapping chiplets at same Z).";let o=document.createElement("input");o.type="checkbox",o.checked=!!this._app.useTrueZ,o.addEventListener("change",()=>{this._app.useTrueZ=o.checked,Qt("or_use_true_z",o.checked?"1":"0"),this._app.syncDisplayState(),this.refreshSceneForOptions()}),i.appendChild(o),i.appendChild(document.createTextNode("True Z (no stacking)")),e.appendChild(i);let r=document.createElement("div");r.style.cssText="margin-top:4px; display:flex; gap:4px;";let l=document.createElement("button");l.className="or-btn or-btn-sm",l.textContent="Save PNG",l.title="Save the 3D view as a PNG image (2x resolution)",l.addEventListener("click",()=>this._exportPng(2));let h=document.createElement("button");return h.className="or-btn or-btn-sm",h.textContent="Copy",h.title="Copy the 3D view image to the clipboard",h.addEventListener("click",()=>this._copyImage(2)),r.appendChild(l),r.appendChild(h),e.appendChild(r),e}_capturePng(e=2){if(!this._renderer)return null;let i=this._renderer,o=i.domElement.clientWidth||i.domElement.width,r=i.domElement.clientHeight||i.domElement.height,l=i.getPixelRatio();try{return i.setPixelRatio(l*e),i.setSize(o,r,!1),this.render(),i.domElement.toDataURL("image/png")}finally{i.setPixelRatio(l),i.setSize(o,r,!1),this.render()}}_exportPng(e=2){let i=this._capturePng(e);i&&yi(i,"3d-view.png")}async _copyImage(e=2){let i=this._capturePng(e);i&&await ps(i)}_setRaycasterFromEvent(e){let o=this._renderer.domElement.getBoundingClientRect(),r=new ht.Vector2((e.clientX-o.left)/o.width*2-1,-((e.clientY-o.top)/o.height*2-1));this._raycaster.setFromCamera(r,this._camera)}_updateTooltip(e){if(!this._chipletMeshes.length){this._hideTooltip();return}this._setRaycasterFromEvent(e);let i=this._chipletMeshes.map(u=>u.mesh),o=this._raycaster.intersectObjects(i,!1);if(o.length===0){this._hideTooltip();return}let r=o[0].object,l=this._chipletMeshes.find(u=>u.mesh===r);if(!l){this._hideTooltip();return}this._tooltip.textContent=l.data.name,this._tooltip.style.display="block";let h=this._canvasContainer.getBoundingClientRect();this._tooltip.style.left=e.clientX-h.left+12+"px",this._tooltip.style.top=e.clientY-h.top+12+"px"}_hideTooltip(){this._tooltip&&(this._tooltip.style.display="none")}_pickDrcMarkerId(e){if(!this._drcHitboxMesh||!this._drcHitboxMarkerIds)return null;this._setRaycasterFromEvent(e);let i=this._raycaster.intersectObject(this._drcHitboxMesh,!1);if(i.length===0)return null;let o=i[0].instanceId;return o==null?null:this._drcHitboxMarkerIds[o]??null}_handleRotate(e,i){let o=Math.sqrt(e*e+i*i);if(o<.001)return;let r=new ht.Vector3(i/o,e/o,0),l=o/Ul,u=new ht.Quaternion().setFromAxisAngle(r,l*Is).clone().multiply(this._rotation);if(new ht.Vector3(0,0,1).applyQuaternion(u).z>=0)this._rotation.copy(u);else{let _=new ht.Vector3(0,1,0),y=e/Ul*Is,v=new ht.Quaternion().setFromAxisAngle(_,y).clone().multiply(this._rotation);new ht.Vector3(0,0,1).applyQuaternion(v).z>=0&&this._rotation.copy(v)}}_handlePan(e,i){let o=this._distance*jd;this._panX+=e*o,this._panY-=i*o}_updateCamera(){let e=Math.max(this._boundingRadius,1e3),i=Math.max(this._distance-e*Gl,iu),o=this._distance+e*Gl;o0;){let e=this._designGroup.children[0];this._designGroup.remove(e),e.geometry&&e.geometry.dispose(),e.material&&!e.material._shared&&e.material.dispose()}this._edgeMaterial&&(this._edgeMaterial.dispose(),this._edgeMaterial=null),this._onMouseMove&&(window.removeEventListener("mousemove",this._onMouseMove),this._onMouseMove=null),this._onMouseUp&&(window.removeEventListener("mouseup",this._onMouseUp),this._onMouseUp=null),this._renderer&&(this._renderer.dispose(),this._renderer=null),this._app.threeDViewerWidget===this&&(this._app.threeDViewerWidget=null)}}_setInitialCameraState(){this._distance=this._boundingRadius*eu;let e=new ht.Quaternion().setFromAxisAngle(new ht.Vector3(1,0,0),-45*Is),i=new ht.Quaternion().setFromAxisAngle(new ht.Vector3(0,0,1),45*Is);this._rotation=e.multiply(i),this._panX=0,this._panY=0}resetCamera(){this._sceneBounds&&(this._setInitialCameraState(),this._updateCamera())}onResize(){if(this._destroyed)return;let e=this._canvasContainer.getBoundingClientRect(),i=e.width,o=e.height;i===0||o===0||(this._camera.aspect=i/o,this._camera.updateProjectionMatrix(),this._renderer.setSize(i,o),this.render())}render(){this._destroyed||this._renderer&&this._scene&&this._camera&&this._renderer.render(this._scene,this._camera)}_applyTheme(){let i=gi().bgMap||"#000000";this._scene.background=new ht.Color(i)}async loadData(){if(!(this._loading||this._destroyed)){this._loading=!0;for(let e of[".three-d-error",".three-d-info"]){let i=this._element.querySelector(e);i&&i.remove()}try{await this._app.websocketManager.readyPromise;let e=await this._app.websocketManager.request({type:"get_3d_data"});if(this._destroyed)return;if(e&&e.error){this._showError(e.error);return}if(e&&e.info){this._showInfo(e.info);return}this.buildScene(e)}catch(e){if(this._destroyed)return;console.error("Failed to load 3D data:",e),this._showError(e.message||String(e))}finally{this._loading=!1}}}_showOverlay(e,i,o){let r=document.createElement("div");r.className=e,r.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-family:monospace;text-align:center;",r.style.color=o,r.textContent=i,this._element.appendChild(r)}_showError(e){this._showOverlay("three-d-error","Failed to load 3D data: "+e,"var(--error)")}_showInfo(e){this._showOverlay("three-d-info",e,"var(--fg-muted, #888)")}_showWebGLUnavailable(e){let i=document.createElement("div");i.className="three-d-error",i.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-family:monospace;text-align:center;max-width:80%;color:var(--error);";let o=e&&e.message?e.message:String(e||"");i.innerHTML='
3D viewer unavailable: WebGL context could not be created.
In Chrome, open chrome://flags/#ignore-gpu-blocklist and set Override software rendering list to Enabled, then relaunch the browser.
Otherwise enable hardware acceleration or try a different browser. See chrome://gpu for details.
'+(o?'
'+o+"
":""),this._element.appendChild(i)}buildScene(e){if(this._destroyed||(this._lastSceneData=e,this._clearScene(),!e||!e.chiplets||e.chiplets.length===0))return;let i=this._app.getDbuPerMicron(),o=this._buildChiplets(e.chiplets,i);o.minX!==1/0&&(this._buildGrid(o),this._setSceneBoundsAndCenter(o),this._setInitialCameraState(),this._updateCamera())}_clearScene(){for(this._chipletMeshes=[];this._designGroup.children.length>0;){let e=this._designGroup.children[0];this._designGroup.remove(e),e.geometry&&e.geometry.dispose(),e.material&&!e.material._shared&&e.material.dispose()}this._hideTooltip()}_buildChiplets(e,i){let o={minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0};this._edgeMaterial||(this._edgeMaterial=new ht.LineBasicMaterial({color:0,linewidth:1}),this._edgeMaterial._shared=!0);let r=this._app.useTrueZ?new Array(e.length).fill(0):au(e);return e.forEach((l,h)=>{let u=l.width/i,f=l.height/i,_=l.thickness/i*wi,y=Vl[h%Vl.length],g=new ht.MeshPhongMaterial({color:y,transparent:!1,opacity:1,side:ht.DoubleSide,shininess:40}),v=new ht.BoxGeometry(u,f,_),w=new ht.Mesh(v,g),b=l.x/i+u/2,C=l.y/i+f/2,R=_*su,A=l.z/i*wi+_/2+r[h]*(_+R);w.position.set(b,C,A),this._designGroup.add(w),this._chipletMeshes.push({mesh:w,data:l,color:y});let M=new ht.EdgesGeometry(v),q=new ht.LineSegments(M,this._edgeMaterial);q.position.set(b,C,A),this._designGroup.add(q),o.minX=Math.min(o.minX,l.x/i),o.minY=Math.min(o.minY,l.y/i),o.minZ=Math.min(o.minZ,A-_/2),o.maxX=Math.max(o.maxX,l.x/i+u),o.maxY=Math.max(o.maxY,l.y/i+f),o.maxZ=Math.max(o.maxZ,A+_/2)}),o}_buildGrid(e){let i=e.maxX-e.minX,o=e.maxY-e.minY,r=Math.max(i,o)*1.4,l=10,h=new ht.GridHelper(r,l,8947848,4473924);h.rotation.x=Math.PI/2,h.position.set((e.minX+e.maxX)/2,(e.minY+e.maxY)/2,e.minZ-1),this._designGroup.add(h)}_setSceneBoundsAndCenter(e){this._sceneBounds=e;let i=e.maxX-e.minX,o=e.maxY-e.minY,r=e.maxZ-e.minZ;this._boundingRadius=Math.sqrt(i*i+o*o+r*r)/2,this._sceneCenter.set((e.minX+e.maxX)/2,(e.minY+e.maxY)/2,(e.minZ+e.maxZ)/2)}_stackOffsetForPoint(e,i,o,r){for(let{mesh:l,data:h}of this._chipletMeshes){if(e!==h.z||ih.x+h.width||oh.y+h.height)continue;let u=h.thickness/r*wi,f=h.z/r*wi+u/2;return l.position.z-f}return 0}clearHighlightDRC(){this._drcBlinkInterval&&(clearInterval(this._drcBlinkInterval),this._drcBlinkInterval=null),this._drcMeshGroup&&(this._scene.remove(this._drcMeshGroup),this._drcMeshGroup.children.forEach(e=>{e.geometry&&e.geometry.dispose()}),this._drcMaterial&&(this._drcMaterial.dispose(),this._drcMaterial=null),this._drcHitboxMaterial&&(this._drcHitboxMaterial.dispose(),this._drcHitboxMaterial=null),this._drcHitboxMesh=null,this._drcHitboxMarkerIds=null,this._drcMeshGroup=null,this.render())}highlightDRC(e){if(this._destroyed||(this.clearHighlightDRC(),!e||e.length===0))return;let i=this._app.getDbuPerMicron(),o=0,r=1e4/i*wi;this._sceneBounds&&this._sceneBounds.minZ!==1/0&&(o=this._sceneBounds.minZ,r=this._sceneBounds.maxZ),o-=1,r+=1;let l=Math.max(r-o,1);this._drcMeshGroup=new ht.Group,this._drcMaterial=new ht.LineBasicMaterial({color:16776960,transparent:!0,opacity:1,depthTest:!1,depthWrite:!1}),this._drcHitboxMaterial=new ht.MeshBasicMaterial({transparent:!0,opacity:0,depthWrite:!1});let h=[];for(let _ of e){let y=_.rects&&_.rects.length>0?_.rects:[_.bbox];for(let g of y){let[v,w,b,C,R,A]=g,M=Math.max((b-v)/i,.001),q=Math.max((C-w)/i,.001),G=o,dt=l,gt=0;if(g.length>=6&&R!==void 0&&A!==void 0){G=R/i*wi;let tt=A/i*wi;dt=Math.max(tt-G,.001),gt=this._stackOffsetForPoint(R,(v+b)/2,(w+C)/2,i)}let it=v/i+M/2,Q=w/i+q/2,nt=G+dt/2+gt;h.push({cx:it,cy:Q,cz:nt,width:M,height:q,depth:dt,markerId:_.id})}}if(h.length>0){let _=new ht.BoxGeometry(1,1,1);this._drcHitboxMesh=new ht.InstancedMesh(_,this._drcHitboxMaterial,h.length),this._drcHitboxMarkerIds=new Array(h.length);let y=new ht.Matrix4,g=new ht.Vector3,v=new ht.Vector3,w=new ht.Quaternion;h.forEach((b,C)=>{v.set(b.cx,b.cy,b.cz),g.set(b.width,b.height,b.depth),y.compose(v,w,g),this._drcHitboxMesh.setMatrixAt(C,y),this._drcHitboxMarkerIds[C]=b.markerId;let R=new ht.BoxGeometry(b.width,b.height,b.depth),A=new ht.EdgesGeometry(R);R.dispose();let M=new ht.LineSegments(A,this._drcMaterial);M.position.set(b.cx,b.cy,b.cz),M.renderOrder=999,this._drcMeshGroup.add(M)}),this._drcHitboxMesh.instanceMatrix.needsUpdate=!0,this._drcMeshGroup.add(this._drcHitboxMesh)}this._drcMeshGroup.renderOrder=999,this._scene.add(this._drcMeshGroup),this.render();let u=!0,f=0;this._drcBlinkInterval=setInterval(()=>{if(!(!this._drcMeshGroup||!this._drcMaterial)){if(f+=1,f>=ru){this._drcMaterial.opacity=1,this.render(),clearInterval(this._drcBlinkInterval),this._drcBlinkInterval=null;return}u=!u,this._drcMaterial.opacity=u?1:.2,this.render()}},ou)}refreshSceneForOptions(){this._destroyed||this._lastSceneData&&(this.clearHighlightDRC(),this.buildScene(this._lastSceneData))}};var lu=[{name:"green",hex:"#00ff00"},{name:"yellow",hex:"#ffff00"},{name:"cyan",hex:"#00ffff"},{name:"magenta",hex:"#ff00ff"},{name:"red",hex:"#ff0000"},{name:"dark_green",hex:"#008000"},{name:"dark_magenta",hex:"#800080"},{name:"blue",hex:"#0000ff"},{name:"orange",hex:"#ffa500"},{name:"purple",hex:"#800080"},{name:"lime",hex:"#bfff00"},{name:"teal",hex:"#008080"},{name:"pink",hex:"#ffc0cb"},{name:"brown",hex:"#8b4513"},{name:"indigo",hex:"#4b0082"},{name:"turquoise",hex:"#40e0d0"}],cu=[{label:"Connected Insts",suffix:"connected_insts",needsNet:!0},{label:"Output Nets",suffix:"connected_nets",args:{output:!0,input:!1}},{label:"Input Nets",suffix:"connected_nets",args:{output:!1,input:!0}},{label:"All Nets",suffix:"connected_nets",args:{output:!0,input:!0}},{label:"All buffer trees",suffix:"connected_buffer_trees"},{label:"All buffer trees (incl. inverters)",suffix:"connected_buffer_trees",args:{include_inverters:!0}}],Ns=class{constructor(e){this._app=e,this._el=document.createElement("div"),this._el.className="context-menu",this._el.style.display="none",this._el.style.zIndex="10000",document.body.appendChild(this._el),this._bindEvents()}_bindEvents(){document.addEventListener("mousedown",e=>{this._el.contains(e.target)||this.hide()}),this._app.map&&this._app.map.on("movestart",()=>this.hide())}show(e){this._el.innerHTML="";let i=!!this._app.selHasInst,o=!!this._app.selHasNet,r=!(i||o),l=w=>cu.map(b=>({label:b.label,disabled:b.needsNet?!o:!i,...w(b.suffix,b.args||{})})),h=[{label:"Select",disabled:r,subMenu:l((w,b)=>({action:()=>this._sendContextAction("select_"+w,b)}))},{label:"Highlight",disabled:r,subMenu:l((w,b)=>({subMenu:this._buildColorSubmenu("highlight_"+w,b)}))},{label:"Save",subMenu:[{label:"Visible layout",action:()=>this._app.captureLayout?.({entire:!1})},{label:"Entire layout",action:()=>this._app.captureLayout?.({entire:!0})}]},{label:"Clear",subMenu:[{label:"Selections",action:()=>this._sendContextAction("clear_selections")},{label:"Highlights",action:()=>this._sendContextAction("clear_highlights")},{label:"Rulers",action:()=>{this._app.rulerManager?.clearAllRulers()}},{label:"Focus nets",action:()=>this._sendContextAction("clear_focus_nets")},{label:"Route Guides",action:()=>this._sendContextAction("clear_route_guides")},{label:"All",action:()=>{this._sendContextAction("clear_all"),this._app.rulerManager?.clearAllRulers()}}]}];this._buildMenu(h,this._el),this._el.style.display="block";let u=4,f=this._el.getBoundingClientRect(),_=window.innerWidth-f.width-u,y=window.innerHeight-f.height-u,g=Math.max(u,Math.min(e.originalEvent.clientX,_)),v=Math.max(u,Math.min(e.originalEvent.clientY,y));this._el.style.left=g+"px",this._el.style.top=v+"px"}hide(){this._el.style.display="none"}_buildColorSubmenu(e,i={}){return lu.map(({name:o,hex:r},l)=>({label:o,swatch:r,action:()=>this._sendContextAction(e,{...i,group:l})}))}_buildMenu(e,i){e.forEach(o=>{let r=document.createElement("div");if(r.className="cm-item",o.swatch){let l=document.createElement("span");l.className="cm-swatch",l.style.background=o.swatch,r.appendChild(l)}if(r.appendChild(document.createTextNode(o.label)),o.disabled){r.classList.add("disabled"),o.subMenu&&r.classList.add("has-submenu"),i.appendChild(r);return}if(o.subMenu){r.classList.add("has-submenu");let l=document.createElement("div");l.className="cm-submenu",this._buildMenu(o.subMenu,l),r.appendChild(l),r.addEventListener("mouseenter",()=>{l.classList.remove("flip-left"),l.getBoundingClientRect().right>window.innerWidth&&l.classList.add("flip-left")})}else o.action&&r.addEventListener("click",l=>{l.stopPropagation(),this.hide();try{o.action()}catch(h){console.error("Context menu item action threw:",o.label,h)}});i.appendChild(r)})}_sendContextAction(e,i={}){this._app.websocketManager&&this._app.websocketManager.request({type:"context_action",action:e,...i}).then(o=>{$i(this._app,o),o&&o.connected_count===0&&be('Nothing connected \u2014 select an instance (or a net for "Connected Insts") first.'),this._syncAfterAction(e)}).catch(o=>{console.error("Context action failed:",e,o)})}_syncAfterAction(e){let i=this._app;(e==="clear_focus_nets"||e==="clear_route_guides"||e==="clear_all")&&typeof i.redrawAllLayers=="function"&&i.redrawAllLayers(),e==="clear_selections"||e==="clear_all"?(i.updateInspector?.(null),i.stopSelectionAnimation?.(),i.highlightRect&&i.map&&(i.map.removeLayer(i.highlightRect),i.highlightRect=null),i.lastSelectionBounds=null):i.refreshInspector?.(),i.refreshOverlay?.()}};function Yl(s,e){if(!s)return;let i=URL.createObjectURL(s),o=document.createElement("a");o.href=i,o.download=e,o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o),setTimeout(()=>URL.revokeObjectURL(i),0)}function jl(s){return s.options&&s.options.opacity!=null?s.options.opacity:1}function Kl(s,e,i){if(!e||e.tagName==="IMG"&&(!e.complete||!e.naturalWidth))return;let o=e.getBoundingClientRect();if(!(o.width<=0||o.height<=0))try{s.drawImage(e,o.left-i.left,o.top-i.top,o.width,o.height)}catch{}}function hu(s,e,i){let o=[];s.map.eachLayer(r=>{r instanceof L.GridLayer&&r._tiles&&o.push(r)}),o.sort((r,l)=>(r.options&&r.options.zIndex||0)-(l.options&&l.options.zIndex||0));for(let r of o){let l=jl(r);if(!(l<=0)){e.globalAlpha=l;for(let h of Object.keys(r._tiles)){let u=r._tiles[h];!u||!u.current||Kl(e,u.el,i)}}}e.globalAlpha=1}function du(s,e,i){let o=s.map.getContainer().querySelectorAll(".leaflet-pane svg"),r=[];return o.forEach(l=>{let h=l.getBoundingClientRect();if(h.width<=0||h.height<=0)return;let u=l.cloneNode(!0);u.setAttribute("width",h.width),u.setAttribute("height",h.height);let f=new XMLSerializer().serializeToString(u),_="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(f);r.push(new Promise(y=>{let g=new Image;g.onload=()=>{try{e.drawImage(g,h.left-i.left,h.top-i.top,h.width,h.height)}catch{}y()},g.onerror=()=>y(),g.src=_}))}),Promise.all(r)}function uu(s,e,i){s.map.getContainer().querySelectorAll(".leaflet-pane .ruler-label").forEach(r=>{let l=r.getBoundingClientRect();if(l.width<=0||l.height<=0)return;let h=r.textContent;if(!h)return;let u=getComputedStyle(r),f=l.left-i.left,_=l.top-i.top;e.save(),e.fillStyle=u.backgroundColor||"rgba(0, 0, 0, 0.75)";let y=Math.min(parseFloat(u.borderTopLeftRadius)||0,l.height/2);y>0&&typeof e.roundRect=="function"?(e.beginPath(),e.roundRect(f,_,l.width,l.height,y),e.fill()):e.fillRect(f,_,l.width,l.height),e.fillStyle=u.color||"#eee",e.font=u.font||`${u.fontSize||"12px"} ${u.fontFamily||"monospace"}`,e.textAlign="left",e.textBaseline="middle",e.fillText(h,f+(parseFloat(u.paddingLeft)||0),_+l.height/2),e.restore()})}function pu(s){let e=0;return s.map.eachLayer(i=>{if(!(!(i instanceof L.GridLayer)||!i._tiles)){i._loading&&e++;for(let o of Object.keys(i._tiles)){let r=i._tiles[o],l=r&&r.el;r&&r.current&&l&&l.tagName==="IMG"&&(!l.complete||!l.naturalWidth)&&e++}}}),e}function fu(s,e=6e3,i=32){return new Promise(o=>{let r=Date.now()+e,l=0,h=()=>{if(pu(s)===0){if(++l>=2){o();return}}else l=0;if(Date.now()>=r){o();return}setTimeout(h,i)};setTimeout(h,i)})}function mu(s,e,i){s.map.eachLayer(o=>{if(!(o instanceof L.ImageOverlay))return;let r=jl(o);r<=0||(e.globalAlpha=r,Kl(e,o._image,i),e.globalAlpha=1)})}async function Xl(s){let e=s.map.getContainer(),i=e.getBoundingClientRect(),o=Math.max(1,Math.round(i.width)),r=Math.max(1,Math.round(i.height)),l=document.createElement("canvas");l.width=o,l.height=r;let h=l.getContext("2d"),u=getComputedStyle(e).backgroundColor;return h.fillStyle=u&&u!=="transparent"&&u!=="rgba(0, 0, 0, 0)"?u:"#000",h.fillRect(0,0,o,r),hu(s,h,i),mu(s,h,i),await du(s,h,i),uu(s,h,i),new Promise(f=>l.toBlob(f,"image/png"))}async function Jl(s,{entire:e=!1}={}){if(!s.map)return;if(!e||!s.fitBounds){Yl(await Xl(s),"layout_visible.png");return}let i=s.map.getCenter(),o=s.map.getZoom();try{s.map.fitBounds(s.fitBounds,{animate:!1}),await fu(s),Yl(await Xl(s),"layout_entire.png")}finally{s.map.setView(i,o,{animate:!1})}}var xi=document.getElementById("websocket-status"),Cn=null,_u=2e3,gu=20;function Yo(){let s=p.websocketManager&&p.websocketManager.isConnected,e=p.websocketManager?p.websocketManager.pendingCount:0;if(s)Cn&&(clearTimeout(Cn),Cn=null),e>gu?(xi.innerHTML=`
pending: ${e}
`,xi.style.display="block"):xi.style.display="none";else{if(p.websocketManager?._shutdown)return;Cn||(Cn=setTimeout(()=>{p.websocketManager?.isConnected||(xi.innerHTML='
\u26A0 OpenROAD disconnected \u2014 retrying\u2026
',xi.style.display="block")},_u))}yu(e)}function yu(s){let e=p.tileProgressEl;e&&(e.classList.toggle("active",s>0),e.title=s>0?`${s} tile requests pending`:"")}function vu(s){if(!s)return"";try{return decodeURIComponent(s)}catch{return""}}var p={map:null,fitBounds:null,lastSelectionBounds:null,selHasInst:!1,selHasNet:!1,displayControlsEl:null,allLayers:[],designScale:null,designMaxDXDY:null,designOriginX:0,designOriginY:0,websocketManager:null,goldenLayout:null,hasLiberty:!1,techData:null,inspectorEl:null,tclOutputEl:null,highlightRect:null,hoverHighlightLayer:null,hoverHighlightPane:"hover-highlight-pane",modulesLayer:null,pinsLayer:null,overlayLayers:[],hierarchyBrowser:null,focusNets:new Set,routeGuideNets:new Set,visibleLayers:new Set,visibleLayerNames:new Set,visibleChiplets:null,layerPatterns:{},useTrueZ:Vt("or_use_true_z")==="1",showDbu:Vt("or_show_dbu")==="1",rulerStyle:Vt("or_ruler_style")==="manhattan"?"manhattan":"euclidian",wheelZoom:Vt("or_wheel_zoom")!=="0",arrowStep:Hi(Vt("or_arrow_step")),fontFamily:vu(Vt("or_font_family")),fontScale:vn(Vt("or_font_scale")),polyDecomp:!1,labelManager:null,selectableLayers:new Set,heatMapData:null,activeHeatMap:"",heatMapLayer:null,heatMapLegendEl:null,renderHeatMapControls:null,rulerManager:null,selectionToken:0,selectionResetters:[],getDbuPerMicron(){return this.techData?.dbu_per_micron||1e3},unitOpts(){return{showDbu:this.showDbu,dbuPerMicron:this.getDbuPerMicron()}},formatDbu(s,e=!1){return el(s,this.unitOpts(),e)},parseDbu(s){return il(s,this.unitOpts())},formatDistance(s){return nl(s,this.unitOpts())},unitLabel(){return sl(this.unitOpts())}},te={stdcells:!0,macros:!0,pad_input:!0,pad_output:!0,pad_inout:!0,pad_power:!0,pad_spacer:!0,pad_areaio:!0,pad_other:!0,phys_fill:!1,phys_endcap:!0,phys_welltap:!0,phys_tie:!0,phys_antenna:!0,phys_cover:!0,phys_bump:!0,phys_other:!0,std_bufinv:!0,std_bufinv_timing:!0,std_clock_bufinv:!0,std_clock_gate:!0,std_level_shift:!0,std_sequential:!0,std_combinational:!0,net_signal:!0,net_power:!0,net_ground:!0,net_clock:!0,net_reset:!0,net_tieoff:!0,net_scan:!0,net_analog:!0,inst_names:!0,inst_pins:!0,inst_pin_names:!1,routing:!0,routing_segments:!0,routing_vias:!0,special_nets:!0,srouting_segments:!0,srouting_vias:!0,pins:!0,pin_names:!0,access_points:!1,regions:!0,mfg_grid:!1,gcell_grid:!1,flywires_only:!1,blockages:!0,placement_blockages:!0,routing_obstructions:!0,fills:!1,rows:!1,tracks_pref:!1,tracks_non_pref:!1,module_view:!1,detailed:!1,rulers:!0,labels:!0,scale_bar:!0,focused_nets_guides:!1,highlight_selected:!0,debug:!1};try{let s=Vt("or_visibility");if(s){let e=JSON.parse(decodeURIComponent(s));for(let[i,o]of Object.entries(e))te[i]=!!o}}catch{}var Ci={stdcells:!0,macros:!0,pad_input:!0,pad_output:!0,pad_inout:!0,pad_power:!0,pad_spacer:!0,pad_areaio:!0,pad_other:!0,phys_fill:!0,phys_endcap:!0,phys_welltap:!0,phys_tie:!0,phys_antenna:!0,phys_cover:!0,phys_bump:!0,phys_other:!0,std_bufinv:!0,std_bufinv_timing:!0,std_clock_bufinv:!0,std_clock_gate:!0,std_level_shift:!0,std_sequential:!0,std_combinational:!0,net_signal:!0,net_power:!0,net_ground:!0,net_clock:!0,net_reset:!0,net_tieoff:!0,net_scan:!0,net_analog:!0,pins:!0,inst_pins:!0,placement_blockages:!0,routing_obstructions:!0};p.visibility=te;p.selectability=Ci;try{let s=Vt("or_selectability");if(s){let e=JSON.parse(decodeURIComponent(s));for(let[i,o]of Object.entries(e))Ci[i]=!!o}}catch{}var bu=Ea(te,p.visibleLayerNames,Ci,p.selectableLayers,p);(function(){let e=null;try{e=new URLSearchParams(window.location.search)}catch{e=null}let i=l=>e?e.get(l):null;p.mergeTiles=i("mergetiles")!=="0";let o=Number(i("tilebudget"));Number.isFinite(o)&&o>0&&(p.tileBudgetBytes=Math.round(o*1024*1024));let r=Number(i("mergegroups"));Number.isFinite(r)&&r>0&&(p.mergeGroupCount=Math.floor(r)),p.tileDpr=di,p.MergedTileLayer=za({visibility:te,selectability:Ci,visibleLayers:p.visibleLayerNames,selectableLayers:p.selectableLayers,app:p},{dpr:di})})();var wu=L.GridLayer.extend({initialize:function(s,e,i){this._websocketManager=s,this._appState=e,L.GridLayer.prototype.initialize.call(this,hi(i))},_clampZoom:function(s){return L.GridLayer.prototype._clampZoom.call(this,zi(this,s))},createTile:function(s,e){let i=document.createElement("img");i.alt="",i.setAttribute("role","presentation"),i._tileDone=!1,i.onload=()=>{i.src&&i.src.startsWith("blob:")&&URL.revokeObjectURL(i.src),i._tileDone||(i._tileDone=!0,e(null,i))},i.onerror=()=>{i._tileDone||(i._tileDone=!0,e(new Error("heat map tile load error"),i))};let o=this._appState.activeHeatMap;return o?(this._websocketManager.request({type:"heatmap_tile",name:o,z:s.z,x:s.x,y:s.y,...Ri(di(),this.getTileSize().x)}).then(r=>{i.src=r?URL.createObjectURL(r):$e}).catch(()=>{i.src=$e}),i):(i.src=$e,i)},refreshTiles:function(){if(this._map)for(let s in this._tiles){let e=this._tiles[s];if(!e||!e.el)continue;let i=e.el,o=e.coords,r=this._appState.activeHeatMap;if(!r){i.src&&i.src.startsWith("blob:")&&URL.revokeObjectURL(i.src),i.src=$e;continue}this._websocketManager.request({type:"heatmap_tile",name:r,z:o.z,x:o.x,y:o.y,...Ri(di(),this.getTileSize().x)}).then(l=>{i.src&&i.src.startsWith("blob:")&&URL.revokeObjectURL(i.src),i.src=l?URL.createObjectURL(l):$e}).catch(()=>{i.src=$e})}}});function jo(s){p.heatMapData=s,p.activeHeatMap=s.active||"",p.heatMapLayer&&(p.activeHeatMap?p.map.hasLayer(p.heatMapLayer)||p.heatMapLayer.addTo(p.map):p.map.hasLayer(p.heatMapLayer)&&p.map.removeLayer(p.heatMapLayer),p.heatMapLayer.refreshTiles()),p.renderHeatMapControls&&p.renderHeatMapControls(s)}p.updateHeatMaps=jo;function Ko(){p.overlayLayer&&p.overlayLayer.refreshTiles()}var Li=gn(()=>{Ko(),p.selectionBrowser&&p.selectionBrowser.scheduleRefresh()});p.refreshOverlay=Li;function he(){Qt("or_visibility",encodeURIComponent(JSON.stringify(te))),Qt("or_selectability",encodeURIComponent(JSON.stringify(Ci))),He();let s=[[p.modulesLayer,te.module_view],[p.pinsLayer,te.pins],...p.overlayLayers.map(({def:e,layer:i})=>[i,Cs(e.shown_by,te)])];for(let[e,i]of s)e&&(i&&!p.map.hasLayer(e)?e.addTo(p.map):!i&&p.map.hasLayer(e)&&p.map.removeLayer(e));for(let e of p.allLayers)e.refreshTiles();if(p.heatMapLayer&&p.heatMapLayer.refreshTiles(),p.highlightRect){let e=te.highlight_selected!==!1;!e&&p.map.hasLayer(p.highlightRect)?p.map.removeLayer(p.highlightRect):e&&!p.map.hasLayer(p.highlightRect)&&p.highlightRect.addTo(p.map)}!te.highlight_selected&&p.clearSelectionPulse&&p.clearSelectionPulse(),Ko(),p.rulerManager&&p.rulerManager.updateVisibility(),p.labelManager&&p.labelManager.updateVisibility(),p.updateScaleBar&&p.updateScaleBar()}var Gi=gn(he),He=gn(()=>{!p.websocketManager||wt(p)||p.websocketManager.request({type:"set_display_state",state:Zl()}).catch(()=>{})});p.syncDisplayState=He;function xu(s){if(!s||typeof s!="object")return;let e=s.entries;if(!(!e||typeof e!="object")){ql(e);try{if(p.map&&typeof sessionStorage<"u"){let i=p.map.getCenter();sessionStorage.setItem("or_restore_view",JSON.stringify({lat:i.lat,lng:i.lng,zoom:p.map.getZoom()}))}}catch{}window.location.reload()}}p.redrawAllLayers=he;p.captureLayout=(s={})=>Jl(p,s);function Cu(s){let e=document.createElement("div");e.className="layout-viewer",e.style.width="100%",e.style.height="100%",e.style.backgroundColor="var(--bg-map)",s.element.appendChild(e);let i=document.createElement("div");i.className="or-hud or-hud-bottom-right heatmap-map-legend hidden",e.appendChild(i),p.heatMapLegendEl=i;let o=document.createElement("div");o.className="or-progress",e.appendChild(o),p.tileProgressEl=o,s.on("destroy",()=>{p.tileProgressEl=null,p.heatMapLegendEl=null}),p.map=L.map(e,Ka(void 0,{wheelZoom:p.wheelZoom,arrowStep:p.arrowStep})),wt(p)||ll(p.map,()=>p.wheelZoom),qa(p.map),ka(()=>he());let r=p.map.createPane(p.hoverHighlightPane);r.style.zIndex="650",r.style.pointerEvents="none";let l=L.Control.extend({onAdd:function(){let A=L.DomUtil.create("div","leaflet-bar leaflet-control leaflet-control-fit"),M=L.DomUtil.create("a","",A);return M.href="#",M.title="Fit",M.setAttribute("role","button"),M.setAttribute("aria-label","Fit"),M.textContent="\u2922",L.DomEvent.on(M,"click",L.DomEvent.stop).on(M,"click",()=>{p.fitBounds&&p.map.fitBounds(p.fitBounds)}),A}});new l({position:"topleft"}).addTo(p.map),new ResizeObserver(()=>{p.map.invalidateSize({animate:!1})}).observe(e);let h=document.createElement("div");h.className="or-hud or-hud-bottom-left hidden";let u=document.createElement("div");u.id="scale-bar";let f=document.createElement("span");f.className="or-hud-divider";let _=document.createElement("div");_.id="coord-bar",h.appendChild(u),h.appendChild(f),h.appendChild(_),e.appendChild(h);function y(){let A=u.style.display!=="none"&&u.childElementCount>0,M=_.textContent!=="";f.style.display=A&&M?"":"none",h.classList.toggle("hidden",!A&&!M)}y(),p.map.on("mousemove",A=>{if(p.lastMouseLatLng=A.latlng,!p.designScale)return;let{dbuX:M,dbuY:q}=ye(A.latlng.lat,A.latlng.lng,p.designScale,p.designMaxDXDY,p.designOriginX,p.designOriginY);_.textContent=`X: ${p.formatDbu(M)} Y: ${p.formatDbu(q)}`,y()}),p.map.on("mouseout",A=>{let M=A.originalEvent&&A.originalEvent.relatedTarget;M&&e.contains(M)||(p.lastMouseLatLng=null,_.textContent="",y())});let g=22,v=8,w=22;function b(A,M,q){let dt=2+v,gt=w,it=w+A,Q=g-2,nt=A>=40,tt=[];if(tt.push(``),nt&&q>1)for(let Ct=1;Ct`)}nt&&tt.push(`0`),tt.push(`${M}`),u.innerHTML=`${tt.join("")}`}function C(){if(!p.designScale||!te.scale_bar){u.style.display="none",y();return}let A=p.designScale*Math.pow(2,p.map.getZoom()),M=p.map.getContainer().clientWidth||400,q=rl({targetPx:M*.15,pxPerDbu:A,dbuPerMicron:p.techData?.dbu_per_micron,showDbu:p.showDbu});if(!q){u.style.display="none",y();return}u.style.display="",b(q.barPx,q.label,q.segments),y()}let R=gn(C);p.map.on("zoom zoomend resize",R),p.updateScaleBar=C,p.rulerManager=new Es(p,te,Ln,Ds),p.labelManager=new Ms(p,te,Ln,Ds)}function Lu(s){let e=document.createElement("div");e.className="display-controls",e.innerHTML='
Loading layers...
',s.element.appendChild(e),p.displayControlsEl=e}var Xo="or_restore_console",ku=1<<20;function Su(){try{if(p.tclOutputEl){let s=[...p.tclOutputEl.children].map(r=>[r.textContent,r.className]),e=s.length,i=0;for(;e>0&&i+s[e-1][0].length<=ku;)i+=s[--e][0].length;let o=s.slice(e);e>0&&o.unshift([`[earlier output not kept across reload] -`,""]),sessionStorage.setItem(Xo,JSON.stringify(o))}}catch{}window.location.reload()}function Eu(){try{let s=sessionStorage.getItem(Xo);if(!s)return;sessionStorage.removeItem(Xo);for(let[e,i]of JSON.parse(s))Xe(e,i)}catch{}}function Xe(s,e){if(!p.tclOutputEl)return;let i=document.createElement("span");e&&(i.className=e),i.textContent=s,p.tclOutputEl.appendChild(i),p.tclOutputEl.scrollTop=p.tclOutputEl.scrollHeight}function Mu(){if(p._shutdownHandled)return;p._shutdownHandled=!0,p.websocketManager&&(p.websocketManager._shutdown=!0,p.websocketManager.onPush=()=>{});let s=document.createElement("div");s.style.cssText="position:fixed;inset:0;z-index:99999;background:#1e1e1e;color:#ddd;display:flex;flex-direction:column;align-items:center;justify-content:center;font-family:system-ui,sans-serif;font-size:16px;padding:24px;text-align:center;",s.innerHTML='
OpenROAD exited
You can close this tab.
',document.body.appendChild(s),setTimeout(()=>{try{window.close()}catch{}},1500)}function Tu(s){let e=document.createElement("div");if(e.className="tcl-console",e.innerHTML='
%
',s.element.appendChild(e),p.tclOutputEl=e.querySelector(".tcl-output"),Eu(),wt(p)){e.querySelector(".tcl-input-row").style.display="none";let r=document.createElement("span");r.className="tcl-static-notice",r.setAttribute("role","status"),r.setAttribute("aria-live","polite"),r.textContent="Tcl console is not available in saved reports.",p.tclOutputEl.appendChild(r);return}let i=e.querySelector(".tcl-input"),o=new As(i,p.websocketManager);i.addEventListener("keydown",r=>{if(!o.handleKeyDown(r)&&r.key==="Enter"){let l=i.value.trim();if(!l)return;Xe(`>>> ${l} -`,"tcl-cmd"),o.addToHistory(l),i.value="",p.websocketManager.request({type:"tcl_eval",cmd:l}).then(h=>{h.result&&Xe(h.result+` -`,h.is_error?"tcl-error":""),h.action==="shutdown"&&Mu(),!h.is_error&&p.drcWidget&&p.drcWidget.refresh()}).catch(h=>Xe(`Error: ${h} -`,"tcl-error"))}})}p.visibility=te;var je=bl(p,he,Li),Pu=je.createInspector,Ln=je.updateInspector,Au=je.highlightBBox,Iu=je.pulseHighlight;p.updateInspector=Ln;p.navigateInspector=je.navigateInspector;p.refreshInspector=je.refreshInspector;p.animateSelection=je.animateSelection;p.stopSelectionAnimation=je.stopSelectionAnimation;function Bu(s){new ys(s,p,he)}function Nu(s){p.timingWidget=new _i(p,he,Li),s.element.appendChild(p.timingWidget.element)}function Du(s){p.drcWidget=new Ps(p,he,Li),s.element.appendChild(p.drcWidget.element)}function Ru(s){p.clockTreeWidget=new _s(s,p,he,Li)}function zu(s){p.chartsWidget=new gs(p,he),s.element.appendChild(p.chartsWidget.element)}function Ou(s){let e=document.createElement("div");e.className="help-panel",e.innerHTML="

Keyboard Shortcuts

fFit design to viewport
scrollZoom in/out
dragPan the view
right-dragRubber-band zoom
Shift+clickAdd object to selection
Ctrl/Cmd+clickSelect object and its connected nets
kToggle ruler mode
Shift+KClear all rulers
EscapeCancel ruler (when building)
",s.element.appendChild(e)}function $u(s){p.selectionBrowser=new vs(s,p,Li)}function Hu(s){new Ts(s,p)}function Fu(s){p.threeDViewerWidget=new Bs(s,p)}var Zu=28,qu={dimensions:{headerHeight:Zu},root:{type:"row",content:[{type:"component",componentType:"DisplayControls",title:"Display Controls",width:15},{type:"column",width:55,content:[{type:"stack",height:70,content:[{type:"component",componentType:"LayoutViewer",title:"Layout",isClosable:!1},{type:"component",componentType:"SchematicWidget",title:"Schematic"},{type:"component",componentType:"3DViewer",title:"3D Viewer"}]},{type:"component",componentType:"TclConsole",title:"Tcl Console",height:30}]},{type:"stack",width:30,content:[{type:"component",componentType:"Inspector",title:"Inspector"},{type:"component",componentType:"Browser",title:"Hierarchy"},{type:"component",componentType:"TimingWidget",title:"Timing"},{type:"component",componentType:"DRCWidget",title:"DRC"},{type:"component",componentType:"SelectHighlight",title:"Select Highlight"},{type:"component",componentType:"ClockWidget",title:"Clock Tree"},{type:"component",componentType:"ChartsWidget",title:"Charts"},{type:"component",componentType:"HelpWidget",title:"Help"}]}]}};p.goldenLayout=new rs(document.getElementById("gl-container"));p.goldenLayout.registerComponentFactoryFunction("LayoutViewer",Cu);p.goldenLayout.registerComponentFactoryFunction("DisplayControls",Lu);p.goldenLayout.registerComponentFactoryFunction("TclConsole",Tu);p.goldenLayout.registerComponentFactoryFunction("Inspector",Pu);p.goldenLayout.registerComponentFactoryFunction("Browser",Bu);p.goldenLayout.registerComponentFactoryFunction("TimingWidget",Nu);p.goldenLayout.registerComponentFactoryFunction("DRCWidget",Du);p.goldenLayout.registerComponentFactoryFunction("ClockWidget",Ru);p.goldenLayout.registerComponentFactoryFunction("ChartsWidget",zu);p.goldenLayout.registerComponentFactoryFunction("SchematicWidget",Hu);p.goldenLayout.registerComponentFactoryFunction("3DViewer",Fu);p.goldenLayout.registerComponentFactoryFunction("HelpWidget",Ou);p.goldenLayout.registerComponentFactoryFunction("SelectHighlight",$u);var Te=window.__STATIC_CACHE__||null;if(Te)Ca(),p.websocketManager=pn.fromCache(Te,Yo);else{let s=`ws://${window.location.host||"localhost:8080"}/ws`;p.websocketManager=new pn(s,Yo),p.layerExtents=new cs,p.websocketManager.onReconnected=()=>{Rs(),tr(null,null,{reloadOnChange:!0}).catch(()=>{})}}Yo();p.goldenLayout.loadLayout(qu);Ql();function Ql(){al(document.getElementById("gl-container"))>0&&p.goldenLayout.updateSize()}p.goldenLayout.on("stateChanged",()=>{Ql()});function Jo(){p.goldenLayout.updateSize()}p.syncLayoutSize=Jo;window.addEventListener("resize",Jo);function Ds(s){p.goldenLayout.focusComponent(s)}p.focusComponent=Ds;p.resetLayout=function(){p.goldenLayout&&typeof p.goldenLayout.resetLayout=="function"&&p.goldenLayout.resetLayout()};p.toggleTheme=function(){let s=document.documentElement.dataset.theme==="dark"?"light":"dark";document.documentElement.dataset.theme=s,Ro(s),us(s),p.chartsWidget&&p.chartsWidget.render(),p.clockTreeWidget&&p.clockTreeWidget.render(),He()};p.toggleShowDbu=function(){p.showDbu=!p.showDbu,Qt("or_show_dbu",p.showDbu?"1":"0"),p.rulerManager&&p.rulerManager._rerenderAll(),p.hierarchyBrowser&&p.hierarchyBrowser._render(),p.updateScaleBar&&p.updateScaleBar(),p.refreshInspector&&p.refreshInspector(),He()};p.toggleRulerStyle=function(){p.rulerStyle=p.rulerStyle==="manhattan"?"euclidian":"manhattan",Qt("or_ruler_style",p.rulerStyle),He()};p.toggleWheelZoom=function(){p.wheelZoom=!p.wheelZoom,Qt("or_wheel_zoom",p.wheelZoom?"1":"0"),He()};p.setArrowStep=function(s){p.arrowStep=Hi(s),Qt("or_arrow_step",String(p.arrowStep)),Ja(p.map,p.arrowStep),He()};p.setAppFont=function({family:s,scale:e}){p.fontFamily=s??p.fontFamily,p.fontScale=vn(e??p.fontScale),Qt("or_font_family",encodeURIComponent(p.fontFamily)),Qt("or_font_scale",String(p.fontScale)),p.applyAppFont(),He()};p.applyAppFont=function(){let s=document.documentElement;p.fontFamily?s.style.setProperty("--or-font-family",p.fontFamily):s.style.removeProperty("--or-font-family"),s.style.setProperty("--or-font-scale",String(p.fontScale/100)),p.chartsWidget&&p.chartsWidget.render(),p.clockTreeWidget&&p.clockTreeWidget.render()};p.showArrowStepDialog=()=>Cl(p);p.showAppFontDialog=()=>Ll(p);p.togglePolyDecomp=function(){p.websocketManager&&p.websocketManager.request({type:"poly_decomp",value:!p.polyDecomp}).then(s=>Qo(s.value)).catch(()=>{})};function Qo(s){p.polyDecomp=!!s,p.rebuildMenuBar&&p.rebuildMenuBar(),p.refreshOverlay&&p.refreshOverlay()}p.applyAppFont();p.echoTcl=s=>Xe(`>>> ${s} -`,"tcl-cmd");p.runTclScript=(s,e)=>s?(e&&p.echoTcl(s),p.websocketManager.request({type:"tcl_eval",cmd:s}).then(i=>(i&&i.result&&Xe(i.result+` -`,i.is_error?"tcl-error":""),i)).catch(i=>{Xe(`Error: ${i} -`,"tcl-error")})):Promise.resolve();function tc(s){s&&(p.customMenu=s.menu||[],p.customToolbar=s.toolbar||[],p.rebuildMenuBar&&p.rebuildMenuBar(),p.rebuildToolbar&&p.rebuildToolbar(),Jo())}p.customMenu=[];p.customToolbar=[];p.scheduleRedrawAllLayers=Gi;p.showGlobalConnectDialog=()=>Dl(p);p.showInsertBufferDialog=s=>Rl(p,s);Al(p);Il(p);p.contextMenu=new Ns(p);function Wu(){let s=document.getElementById("debug-continue-btn");return s||(s=document.createElement("button"),s.id="debug-continue-btn",s.className="debug-continue-btn",s.textContent="Continue",s.title="Advance the debugger (gpl, cts, ...)",s.addEventListener("click",()=>{p.websocketManager.request({type:"debug_continue"}).catch(()=>{})}),(document.getElementById("menu-bar")||document.body).appendChild(s),s)}function ec(s,e){let i=No(s,ve(),e);return i?(p.currentBounds=s,p.designScale=i.scale,p.designMaxDXDY=i.maxDXDY,p.designOriginX=i.originX,p.designOriginY=i.originY,p.fitBounds=i.fitBounds,p.map.setMaxZoom(Qa(i.scale)),!0):!1}async function tr(s,e,{reloadOnChange:i=!1}={}){if(wt(p)||!p.map)return!1;let o=s,r=e;if(!o)try{let u=await p.websocketManager.request({type:"bounds"});o=u.bounds,r=u.fit_bounds}catch{return!1}if(!o||Xa(p.currentBounds,o))return!1;if(i)return window.location.reload(),!0;let h=!!p.designScale?ye(p.map.getCenter().lat,p.map.getCenter().lng,p.designScale,p.designMaxDXDY,p.designOriginX,p.designOriginY):null;if(!ec(o,r))return!1;if(h){let u=Jt(h.dbuX,h.dbuY,p.designScale,p.designMaxDXDY,p.designOriginX,p.designOriginY);p.map.setView(u,p.map.getZoom(),{animate:!1})}return p.highlightRect&&(p.map.removeLayer(p.highlightRect),p.highlightRect=null),he(),!0}function Uu(){let s=document.getElementById("loading-overlay");s.style.display="flex";let e=()=>{s.style.display!=="none"&&p.websocketManager.request({type:"bounds"}).then(i=>{i.shapes_ready&&(s.style.display="none")}).catch(()=>{}).finally(()=>{s.style.display!=="none"&&setTimeout(e,1e3)})};setTimeout(e,1e3)}function Rs(){p.layerExtents&&p.layerExtents.refetch(s=>p.websocketManager.request(s))}function Gu(s){document.getElementById("loading-overlay").style.display="none",Rs(),tr(s.bounds,s.fit_bounds).then(e=>{e||he()}).catch(()=>he()),p.refreshInspector&&p.refreshInspector()}function Vu(){let s=document.getElementById("script-running-badge");return s||(s=document.createElement("span"),s.id="script-running-badge",s.className="script-running-badge",s.textContent="Script running",s.title="The view updates when the script pauses or finishes",(document.getElementById("menu-bar")||document.body).appendChild(s),s)}function Yu(s){if(p.scriptRunning=s,Vu().style.display=s?"block":"none",!s){if(!p.booted||!p.designScale){Su();return}p.refreshPending&&(p.refreshPending=!1,Rs(),p.refreshInspector&&p.refreshInspector()),tr().then(e=>{e||Gi()}).catch(()=>Gi())}}p.websocketManager.onPush=s=>{if(s.type==="refresh"){if(p.scriptRunning){p.refreshPending=!0;return}Gu(s)}else if(s.type==="script_running")Yu(!!s.running);else if(s.type==="renderer_controls_changed")p.refreshRendererControls&&p.refreshRendererControls(),Gi();else if(s.type==="selection_invalidated")p.updateInspector&&p.updateInspector(null),p.stopSelectionAnimation&&p.stopSelectionAnimation(),p.highlightRect&&p.map&&(p.map.removeLayer(p.highlightRect),p.highlightRect=null),Li();else if(s.type==="heatmaps_changed")p.websocketManager.request({type:"heatmaps"}).then(jo).catch(e=>console.error("Heat map refresh failed",e));else if(s.type==="labels_changed")p.labelManager&&p.labelManager.applyRemoteLabels(s.labels);else if(s.type==="drcUpdated")p._drcUpdateTimeout&&clearTimeout(p._drcUpdateTimeout),p._drcUpdateTimeout=setTimeout(()=>{p.drcWidget&&p.drcWidget.refresh()},500);else if(s.type==="debug_paused")p.refreshRendererControls&&p.refreshRendererControls(),Wu().style.display="block",Gi(),p.chartsWidget&&p.websocketManager.request({type:"debug_charts"}).then(e=>p.chartsWidget.setDebugCharts(e.charts||[])).catch(()=>{});else if(s.type==="debug_resumed"){let e=document.getElementById("debug-continue-btn");e&&(e.style.display="none")}else if(s.type==="debug_refresh"){if(p.scriptRunning)return;p.highlightRect&&(p.map.removeLayer(p.highlightRect),p.highlightRect=null),Gi()}else if(s.type==="log"){let e=s.text;e.endsWith(` -`)&&(e=e.slice(0,-1)),e&&Xe(e+` -`,"")}else s.type==="restore_display_state"?xu(s.state):s.type==="custom_ui"?tc(s):s.type==="poly_decomp"?Qo(s.value):s.type==="shutdown"&&(p.websocketManager._shutdown=!0,xi.innerHTML='
Server stopped
',xi.style.display="block")};p.websocketManager.readyPromise.then(async()=>{try{let h=function(u,f={}){let{addToSelection:_=!1,focusInspector:y=!0,context:g=!1,showConnectivity:v=!1}=f;if(!p.designScale)return Promise.resolve(null);let{dbuX:w,dbuY:b}=ye(u.lat,u.lng,p.designScale,p.designMaxDXDY,p.designOriginX,p.designOriginY);if(p.labelManager&&p.labelManager.isActive()){p.labelManager.handleMapClick(w,b);return}let C=Va(te,Ci),R={type:"select",dbu_x:w,dbu_y:b,zoom:Math.round(p.map.getZoom()),visible_layers:[...p.visibleLayerNames],selectable_layers:[...p.selectableLayers],use_dbu:p.showDbu,...C};_&&(R.add_to_selection=!0),g&&(R.context=!0),v&&(R.show_connectivity=!0),p.visibleChiplets instanceof Set&&(R.visible_chiplets=[...p.visibleChiplets]);let A=re(p);return p.websocketManager.request(R).then(M=>{if(ce(p,A)){if(console.log("Select response:",M,"at dbu",w,b),p.map.closePopup(),$i(p,M),M.selected&&M.selected.length>0){let q=M.selected[0];q.type==="Inst"&&(p.selectedInstanceName=q.name,p.schematicWidget&&p.schematicWidget.refresh()),Ln(M),y&&Ds("Inspector"),M.bbox&&(Au(M.bbox[0],M.bbox[1],M.bbox[2],M.bbox[3],M.type),Iu(M.bbox,M.type),p.lastSelectionBounds=Gt(M.bbox[0],M.bbox[1],M.bbox[2],M.bbox[3],p.designScale,p.designMaxDXDY,p.designOriginX,p.designOriginY)),R.show_connectivity&&M.connected_added>0&&be(`Selected ${M.connected_added} connected net`+(M.connected_added>1?"s":""))}else!_&&!g&&(Ln(null),p.highlightRect&&(p.map.removeLayer(p.highlightRect),p.highlightRect=null),p.lastSelectionBounds=null);return Ko(),M}}).catch(M=>(console.error("Select failed:",M),null))},[s,e,i]=await Promise.all([p.websocketManager.request({type:"tech"}),p.websocketManager.request({type:"bounds"}),p.websocketManager.request({type:"heatmaps"})]);Rs(),p.hasLiberty=s.has_liberty,p.techData=s,Wl(s.block_name),p.websocketManager.request({type:"custom_ui"}).then(tc).catch(()=>{}),p.websocketManager.request({type:"poly_decomp"}).then(u=>Qo(u.value)).catch(()=>{});let o=e.bounds,r=e.fit_bounds;if(!Te){let u=p.map.getSize();La(tl({designBounds:o,fitRect:r,viewW:u.x,viewH:u.y}))}let l=ec(o,r);if(l){if(p.labelManager&&p.labelManager.reload(),p.map.fitBounds(p.fitBounds),Te){let u=Te.zoom;p.map.setMinZoom(u),p.map.setMaxZoom(u),p.map.fitBounds(p.fitBounds),p.map.scrollWheelZoom.disable(),p.map.touchZoom.disable(),p.map.boxZoom.disable(),p.map.doubleClickZoom.disable(),p.pathOverlay=L.imageOverlay("",Gt(o[0][1],o[0][0],o[1][1],o[1][0],p.designScale,p.designMaxDXDY,p.designOriginX,p.designOriginY),{opacity:1,interactive:!1,zIndex:1e3}),Te.setPathOverlay=f=>{f?(p.pathOverlay.setUrl(f),p.pathOverlay.addTo(p.map)):p.map.removeLayer(p.pathOverlay)}}try{let u=sessionStorage.getItem("or_restore_view");if(u){sessionStorage.removeItem("or_restore_view");let f=JSON.parse(u);f&&isFinite(f.lat)&&isFinite(f.lng)&&isFinite(f.zoom)&&p.map.setView([f.lat,f.lng],f.zoom)}}catch{}}if(Te&&(document.getElementById("loading-overlay").style.display="none"),p.selectAtLatLng=h,Te||p.map.on("click",u=>{if(p.rulerManager&&p.rulerManager.isActive())return;let f=u.originalEvent;h(u.latlng,{addToSelection:!!(f&&f.shiftKey),showConnectivity:!!(f&&(f.ctrlKey||f.metaKey))})}),!Te){let u=p.map.getContainer(),f=null,_=null;u.addEventListener("contextmenu",y=>{y.preventDefault()}),u.addEventListener("mousedown",y=>{y.button===2&&(f={x:y.clientX,y:y.clientY},p.map.dragging.disable())}),window.addEventListener("mousemove",y=>{if(!f)return;let g=y.clientX-f.x,v=y.clientY-f.y;if(!_&&Math.abs(g)>=4&&Math.abs(v)>=4&&(_=document.createElement("div"),_.className="rubber-band",document.body.appendChild(_)),_){let w=Math.min(f.x,y.clientX),b=Math.min(f.y,y.clientY);_.style.left=w+"px",_.style.top=b+"px",_.style.width=Math.abs(g)+"px",_.style.height=Math.abs(v)+"px"}}),window.addEventListener("mouseup",y=>{if(!f)return;let g=!!_;_&&(_.remove(),_=null);let v=f;f=null,p.map.dragging.enable();let w=u.getBoundingClientRect();if(g){let R=p.map.containerPointToLatLng([v.x-w.left,v.y-w.top]),A=p.map.containerPointToLatLng([y.clientX-w.left,y.clientY-w.top]);p.map.fitBounds([[Math.min(R.lat,A.lat),Math.min(R.lng,A.lng)],[Math.max(R.lat,A.lat),Math.max(R.lng,A.lng)]]);return}if(!(y.clientX>=w.left&&y.clientX<=w.right&&y.clientY>=w.top&&y.clientY<=w.bottom)||p.rulerManager&&p.rulerManager.isActive())return;let C=p.map.containerPointToLatLng([y.clientX-w.left,y.clientY-w.top]);p.selectAtLatLng(C,{context:!0,focusInspector:!1}).then(()=>p.contextMenu.show({originalEvent:y}))})}if(El(p,te,Ci,bu,s,he,wu),!p.overlayLayer&&!Te){let u=Ma(te,p);p.overlayLayer=new u(p.websocketManager,{zIndex:p.allLayers.length+5,opacity:1}),p.overlayLayer.addTo(p.map)}jo(i),l&&!e.shapes_ready&&Uu(),He(),p.booted=!0}catch(s){p.scriptRunning||console.error("Failed to load initial data from server:",s)}});document.addEventListener("openroad-cone-sync",s=>{p.schematicWidget?.syncCone(s.detail||{})});document.addEventListener("keydown",s=>{let e=s.target.tagName;if(e==="INPUT"||e==="TEXTAREA"||s.target.isContentEditable)return;let i=s.key.toLowerCase();i==="escape"&&p.rulerManager&&p.rulerManager.isActive()?p.rulerManager.cancelRulerBuild():i==="escape"&&p.labelManager&&p.labelManager.isActive()?p.labelManager.cancelLabelMode():i==="k"&&!s.shiftKey&&!s.ctrlKey&&!s.metaKey?p.rulerManager&&p.rulerManager.toggleRulerMode():i==="k"&&s.shiftKey&&!s.ctrlKey&&!s.metaKey?p.rulerManager&&p.rulerManager.clearAllRulers():i==="l"&&!s.shiftKey&&!s.ctrlKey&&!s.metaKey?p.labelManager&&p.labelManager.toggleLabelMode():i==="f"&&!s.ctrlKey&&!s.metaKey&&p.fitBounds?p.map.fitBounds(p.fitBounds):i==="z"&&!s.shiftKey&&!s.ctrlKey&&p.map?p.lastMouseLatLng?p.map.setZoomAround(p.lastMouseLatLng,p.map.getZoom()+1):p.map.zoomIn():i==="z"&&s.shiftKey&&!s.ctrlKey&&p.map?p.lastMouseLatLng?p.map.setZoomAround(p.lastMouseLatLng,p.map.getZoom()-1):p.map.zoomOut():i==="f"&&(s.ctrlKey||s.metaKey)?(s.preventDefault(),p.designScale&&Ls(p)):i==="g"&&s.shiftKey&&!s.ctrlKey&&!s.metaKey?(s.preventDefault(),p.designScale&&ks(p)):i==="t"&&!s.shiftKey&&!s.ctrlKey&&!s.metaKey&&p.toggleTheme()},!0);})(); + `,document.body.appendChild(this._overlay),this._breadcrumb=this._overlay.querySelector(".fb-breadcrumb"),this._fileList=this._overlay.querySelector(".fb-file-list"),this._pathInput=this._overlay.querySelector(".fb-path-input"),this._errorDiv=this._overlay.querySelector(".modal-error"),this._okBtn=this._overlay.querySelector(".ok"),this._cancelBtn=this._overlay.querySelector(".cancel"),this._listen(this._pathInput,"input",()=>this._updateOkState()),this._listen(this._pathInput,"keydown",e=>{if(e.key==="Enter"){let t=this._pathInput.value.trim();t.endsWith("/")?this._navigate(t.replace(/\/+$/,"")||"/"):this._submit()}else e.key==="Escape"&&this.close()}),this._listen(this._okBtn,"click",()=>this._submit()),this._listen(this._cancelBtn,"click",()=>this.close()),this._listen(this._overlay,"click",e=>{e.target===this._overlay&&this.close()}),this._navigate("")}close(){if(!this._closed){this._closed=!0;for(let e of this._disposers)e();this._disposers.length=0,this._overlay&&(this._overlay.remove(),this._overlay=null)}}_listen(e,t,i){e.addEventListener(t,i),this._disposers.push(()=>e.removeEventListener(t,i))}_updateOkState(){this._okBtn.disabled=!this._pathInput.value.trim()}_renderBreadcrumb(e){this._breadcrumb.innerHTML="";let t=e.split("/").filter(Boolean),i=document.createElement("span");i.className="fb-crumb",i.textContent="/",this._listen(i,"click",()=>this._navigate("/")),this._breadcrumb.appendChild(i);let r="";for(let s of t){r+="/"+s;let o=document.createElement("span");o.className="fb-crumb-sep",o.textContent=" / ",this._breadcrumb.appendChild(o);let a=document.createElement("span");a.className="fb-crumb",a.textContent=s;let c=r;this._listen(a,"click",()=>this._navigate(c)),this._breadcrumb.appendChild(a)}}_renderEntries(e){if(this._fileList.innerHTML="",!e||e.length===0){let t=document.createElement("div");t.className="fb-empty",t.textContent="(empty directory)",this._fileList.appendChild(t);return}for(let t of e){let i=document.createElement("div");i.className="fb-entry",t.is_dir&&i.classList.add("fb-dir");let r=document.createElement("span");r.className="fb-icon",r.textContent=t.is_dir?"\u{1F4C1}":"\u{1F4C4}",i.appendChild(r);let s=document.createElement("span");s.className="fb-name",s.textContent=t.name,i.appendChild(s),t.is_dir?this._listen(i,"click",()=>this._navigate(this._currentPath+"/"+t.name)):(this._listen(i,"click",()=>{let o=this._fileList.querySelector(".fb-selected");o&&o.classList.remove("fb-selected"),i.classList.add("fb-selected"),this._pathInput.value=this._currentPath+"/"+t.name,this._updateOkState()}),this._listen(i,"dblclick",()=>{this._pathInput.value=this._currentPath+"/"+t.name,this._updateOkState(),this._submit()})),this._fileList.appendChild(i)}}async _navigate(e){this._errorDiv.style.display="none",this._fileList.innerHTML='
Loading...
';try{let t=await this._app.websocketManager.request({type:"list_dir",path:e||""});if(this._closed)return;this._currentPath=t.path,this._renderBreadcrumb(t.path),this._renderEntries(t.entries),this._pathInput.value="",this._updateOkState()}catch(t){if(this._closed)return;this._fileList.innerHTML="",this._errorDiv.textContent=t.message||String(t),this._errorDiv.style.display=""}}async _submit(){let e=this._pathInput.value.trim();if(e){this._okBtn.disabled=!0,this._okBtn.textContent="Loading...",this._errorDiv.style.display="none";try{let t=await this._app.websocketManager.request({type:"drc_load_report",path:e});if(this._closed)return;if(t.ok){let i=t.category;this.close(),this._onLoaded(i)}else this._errorDiv.textContent=t.error||"Failed to load report",this._errorDiv.style.display="",this._okBtn.disabled=!1,this._okBtn.textContent="Load"}catch(t){if(this._closed)return;this._errorDiv.textContent=t.message||"Request failed",this._errorDiv.style.display="",this._okBtn.disabled=!1,this._okBtn.textContent="Load"}}}};var qW=` +\r[]{}`;var np=class{constructor(e,t){this._input=e,this._ws=t,this._popup=null,this._items=[],this._selectedIndex=-1,this._replaceStart=0,this._replaceEnd=0,this._debounceTimer=null,this._commandCache=null,this._history=[],this._historyIndex=-1,this._historyStash="",this._createPopup(),this._onInputBound=this._onInput.bind(this),this._onBlurBound=this._onBlur.bind(this),this._input.addEventListener("input",this._onInputBound),this._input.addEventListener("blur",this._onBlurBound)}_createPopup(){this._popup=document.createElement("div"),this._popup.className="tcl-complete-popup",this._popup.style.display="none",this._input.parentElement.appendChild(this._popup)}handleKeyDown(e){let t=this._popup.style.display!=="none";return e.key==="Tab"?(e.preventDefault(),t?this._tabAccept():this._tabComplete(this._input.value,this._input.selectionStart),!0):e.key==="Escape"?t?(this._hidePopup(),!0):!1:e.key==="ArrowDown"?t?(e.preventDefault(),this._selectItem(this._selectedIndex+1),!0):this._historyIndex>=0?(e.preventDefault(),this._historyIndex--,this._historyIndex<0?this._input.value=this._historyStash:this._input.value=this._history[this._historyIndex],!0):!1:e.key==="ArrowUp"?t?(e.preventDefault(),this._selectItem(this._selectedIndex-1),!0):this._historyIndex{let e=this._input.value,t=this._input.selectionStart,i=this._extractPrefix(e,t);i.length>=2||i.length>=1&&(i[0]==="$"||i[0]==="-")?this._requestCompletions(e,t):this._hidePopup()},100)}_onBlur(){setTimeout(()=>this._hidePopup(),150)}_extractPrefix(e,t){let i=t-1;for(;i>=0&&qW.indexOf(e[i])===-1;)i--;return e.substring(i+1,t)}_fetchCompletions(e,t,i){let r=this._extractPrefix(e,t),s=r.length>0&&r[0]==="$",o=r.length>0&&r[0]==="-",a=!s&&!o,c=t-r.length,l=e.substring(0,c),u=/^[\s\[]*$/.test(l);if(a&&u&&this._commandCache){let f=r.toLowerCase(),d=this._commandCache.filter(h=>h.toLowerCase().startsWith(f));i(d,c,t);return}this._ws.request({type:"tcl_complete",line:e,cursor_pos:t}).then(f=>{f.mode==="commands"&&!this._commandCache&&r===""&&(this._commandCache=f.completions),f.mode==="commands"&&!this._commandCache&&this._ws.request({type:"tcl_complete",line:"",cursor_pos:0}).then(d=>{d.mode==="commands"&&(this._commandCache=d.completions)}).catch(()=>{}),i(f.completions,f.replace_start,f.replace_end)}).catch(()=>i([],0,0))}_requestCompletions(e,t){this._fetchCompletions(e,t,(i,r,s)=>{this._showPopup(i,r,s)})}_tabAccept(){if(this._items.length===0){this._hidePopup();return}if(this._items.length===1){this._selectedIndex=0,this._acceptCompletion();return}this._advanceToCommonPrefix()}_tabComplete(e,t){this._fetchCompletions(e,t,(i,r,s)=>{if(!i||i.length===0){this._hidePopup();return}if(i.length===1){this._items=i,this._replaceStart=r,this._replaceEnd=s,this._selectedIndex=0,this._acceptCompletion();return}this._items=i,this._replaceStart=r,this._replaceEnd=s,this._advanceToCommonPrefix(),this._showPopup(i,this._replaceStart,this._replaceEnd)})}_advanceToCommonPrefix(){if(this._items.length<2)return!1;let e=this._items[0];for(let o=1;o0;o++){let a=this._items[o],c=0;for(;c{let c=document.createElement("div");c.className="tcl-complete-item",c.textContent=o,c.addEventListener("mousedown",l=>{l.preventDefault(),this._selectedIndex=a,this._acceptCompletion()}),this._popup.appendChild(c)}),e.length>15){let o=document.createElement("div");o.className="tcl-complete-more",o.textContent=`... ${e.length-15} more`,this._popup.appendChild(o)}this._selectedIndex=0,this._highlightSelected(),this._popup.style.display="block"}_hidePopup(){this._popup.style.display="none",this._items=[],this._selectedIndex=-1}_selectItem(e){if(this._items.length===0)return;let t=Math.min(this._items.length,15)-1;this._selectedIndex=Math.max(0,Math.min(e,t)),this._highlightSelected()}_highlightSelected(){let e=this._popup.querySelectorAll(".tcl-complete-item");e.forEach((t,i)=>{t.classList.toggle("selected",i===this._selectedIndex)}),e[this._selectedIndex]&&e[this._selectedIndex].scrollIntoView&&e[this._selectedIndex].scrollIntoView({block:"nearest"})}_acceptCompletion(){if(this._selectedIndex<0||this._selectedIndex>=this._items.length){this._hidePopup();return}let e=this._items[this._selectedIndex],t=this._input.value.substring(0,this._replaceStart),i=this._input.value.substring(this._replaceEnd),s=!e.endsWith("/")&&!e.endsWith("::")&&(i.length===0||i[0]!==" ")?" ":"";this._input.value=t+e+s+i;let o=this._replaceStart+e.length+s.length;this._input.setSelectionRange(o,o),this._input.focus(),this._hidePopup()}};var kM=[{key:"or_visibility",store:"cookie"},{key:"or_selectability",store:"cookie"},{key:"or_hidden_layers",store:"session"},{key:"or_nonselectable_layers",store:"session"},{key:"or_layer_patterns",store:"session"},{key:"or_hidden_chiplets",store:"cookie"},{key:"or_bg_color",store:"cookie"},{key:"or_show_dbu",store:"cookie"},{key:"or_theme",store:"theme"},{key:"or_use_true_z",store:"cookie"},{key:"or_ruler_style",store:"cookie"},{key:"or_wheel_zoom",store:"cookie"},{key:"or_arrow_step",store:"cookie"},{key:"or_font_family",store:"cookie"},{key:"or_font_scale",store:"cookie"},{key:"or_control_smoothing",store:"cookie"},{key:"or_double_buffer",store:"cookie"},{key:"or_defer_tile_updates",store:"cookie"}];function ZW(n,e){try{return window[n].getItem(e)}catch{return null}}function XW(n,e,t){try{t===null?window[n].removeItem(e):window[n].setItem(e,t)}catch{}}function KW({key:n,store:e}){return e==="session"?ZW("sessionStorage",n):Be(n)}function QW({key:n,store:e},t){e==="session"?XW("sessionStorage",n,t):e==="theme"?t===null?K3():Dh(t):t===null?Oh(n):Ue(n,t)}function RM(){let n={};for(let e of kM){let t=KW(e);t&&(n[e.key]=t)}return{version:1,entries:n}}function JW(n){return typeof n=="string"&&n!==""&&!/[;\r\n]/.test(n)}function IM(n){for(let e of kM){let t=n[e.key];QW(e,JW(t)?t:null)}}function BM(n,e=typeof document<"u"?document:null){let t="OpenROAD",i=n?`${t} - ${n}`:t;return e&&(e.title=i),i}var ce=globalThis.THREE,OM=2,e5=.002,t5=.9,n5=1.1,i5=.1,r5=20,s5=3,As=2,DM=2,o5=10,a5=1e4,c5=.15,l5=300,u5=6,ip=Math.PI/180,NM=[5025616,2201331,16750592,10233776,48340,16007990,2533018,7951688,15277667,4149685];function f5(n){let e=new Array(n.length).fill(0),t=new Map;n.forEach((i,r)=>{let s=i.z;t.has(s)||t.set(s,[]),t.get(s).push({idx:r,chiplet:i})});for(let i of t.values()){if(i.length<=1)continue;let r=[];for(let{idx:s,chiplet:o}of i){let a=o.x,c=o.y,l=o.x+o.width,u=o.y+o.height,f=!1;for(let d=0;dap.x1&&cp.y1)){r[d].push({x1:a,y1:c,x2:l,y2:u}),e[s]=d,f=!0;break}f||(r.push([{x1:a,y1:c,x2:l,y2:u}]),e[s]=r.length-1)}}return e}var rp=class{constructor(e,t){if(this._app=t,this._container=e,this._element=document.createElement("div"),this._element.className="three-d-viewer-widget",e.element.appendChild(this._element),!ce){ue(t)?this._showInfo("The 3D view is not available in saved reports."):this._showError("three.js is missing from the page."),this._destroyed=!0;return}this._canvasContainer=document.createElement("div"),this._canvasContainer.className="three-d-canvas-container",this._element.appendChild(this._canvasContainer),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._canvasContainer.appendChild(this._tooltip),this._optionsOverlay=this._createOptionsOverlay(),this._canvasContainer.appendChild(this._optionsOverlay),this._raycaster=new ce.Raycaster,this._scene=new ce.Scene,this._applyTheme(),this._themeObserver=new MutationObserver(()=>{this._applyTheme(),this.render()}),this._themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),this._camera=new ce.PerspectiveCamera(45,1,10,1e5),this._camera.position.set(0,0,1e3);try{this._renderer=new ce.WebGLRenderer({antialias:!0,preserveDrawingBuffer:!0})}catch(o){console.error("3D viewer: failed to create WebGL context:",o),this._showWebGLUnavailable(o),this._themeObserver&&(this._themeObserver.disconnect(),this._themeObserver=null),this._destroyed=!0;return}this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(e.width,e.height),this._canvasContainer.appendChild(this._renderer.domElement),this._rotation=new ce.Quaternion,this._distance=1e3,this._panX=0,this._panY=0,this._boundingRadius=1,this._sceneCenter=new ce.Vector3,this._mouseDown=!1,this._mouseButton=-1,this._lastMousePos={x:0,y:0},this._setupMouseHandlers();let i=new ce.AmbientLight(16777215,.5);this._scene.add(i);let r=new ce.DirectionalLight(16777215,.8);r.position.set(1,1,1).normalize(),this._scene.add(r);let s=new ce.DirectionalLight(16777215,.3);s.position.set(-1,-.5,.5).normalize(),this._scene.add(s),e.on("resize",this.onResize.bind(this)),e.on("open",this.onOpen.bind(this)),e.on("destroy",this.onDestroy.bind(this)),this._designGroup=new ce.Group,this._scene.add(this._designGroup),this._chipletMeshes=[],this._loading=!1,this._destroyed=!1,this._edgeMaterial=null}_setupMouseHandlers(){let e=this._renderer.domElement;e.addEventListener("mousedown",t=>{this._mouseDown=!0,this._mouseButton=t.button,this._lastMousePos.x=t.clientX,this._lastMousePos.y=t.clientY,e.focus(),t.preventDefault()}),e.addEventListener("contextmenu",t=>t.preventDefault()),this._onMouseMove=t=>{if(!this._mouseDown)return;let i=t.clientX-this._lastMousePos.x,r=t.clientY-this._lastMousePos.y;this._lastMousePos.x=t.clientX,this._lastMousePos.y=t.clientY,!(i===0&&r===0)&&(this._mouseButton===0?this._handleRotate(i,r):this._mouseButton===2&&this._handlePan(i,r),this._updateCamera())},this._onMouseUp=t=>{this._mouseDown&&t.button===this._mouseButton&&(this._mouseDown=!1,this._mouseButton=-1)},window.addEventListener("mousemove",this._onMouseMove),window.addEventListener("mouseup",this._onMouseUp),e.addEventListener("wheel",t=>{t.preventDefault(),t.deltaY<0?this._distance*=t5:this._distance*=n5;let i=Math.max(this._boundingRadius*i5,1),r=Math.max(this._boundingRadius*r5,i);this._distance=Math.max(i,Math.min(r,this._distance)),this._updateCamera()},{passive:!1}),e.tabIndex=0,e.style.outline="none",e.addEventListener("keydown",t=>{t.key.toLowerCase()==="f"&&this.resetCamera()}),e.addEventListener("dblclick",t=>{t.preventDefault();let i=this._pickDrcMarkerId(t);if(i!=null&&this._app.drcWidget){this._app.drcWidget.highlightMarkerById(i,!0);return}this.resetCamera()}),e.addEventListener("mousemove",t=>{if(this._mouseDown){this._hideTooltip();return}this._updateTooltip(t)}),e.addEventListener("mouseleave",()=>{this._hideTooltip()})}_createOptionsOverlay(){let e=document.createElement("div");e.className="three-d-options";let t=document.createElement("label");t.title="Render chiplets at their true Z (disable stacking offset for overlapping chiplets at same Z).";let i=document.createElement("input");i.type="checkbox",i.checked=!!this._app.useTrueZ,i.addEventListener("change",()=>{this._app.useTrueZ=i.checked,Ue("or_use_true_z",i.checked?"1":"0"),this._app.syncDisplayState(),this.refreshSceneForOptions()}),t.appendChild(i),t.appendChild(document.createTextNode("True Z (no stacking)")),e.appendChild(t);let r=document.createElement("div");r.style.cssText="margin-top:4px; display:flex; gap:4px;";let s=document.createElement("button");s.className="or-btn or-btn-sm",s.textContent="Save PNG",s.title="Save the 3D view as a PNG image (2x resolution)",s.addEventListener("click",()=>this._exportPng(2));let o=document.createElement("button");return o.className="or-btn or-btn-sm",o.textContent="Copy",o.title="Copy the 3D view image to the clipboard",o.addEventListener("click",()=>this._copyImage(2)),r.appendChild(s),r.appendChild(o),e.appendChild(r),e}_capturePng(e=2){if(!this._renderer)return null;let t=this._renderer,i=t.domElement.clientWidth||t.domElement.width,r=t.domElement.clientHeight||t.domElement.height,s=t.getPixelRatio();try{return t.setPixelRatio(s*e),t.setSize(i,r,!1),this.render(),t.domElement.toDataURL("image/png")}finally{t.setPixelRatio(s),t.setSize(i,r,!1),this.render()}}_exportPng(e=2){let t=this._capturePng(e);t&&Ts(t,"3d-view.png")}async _copyImage(e=2){let t=this._capturePng(e);t&&await Nh(t)}_setRaycasterFromEvent(e){let i=this._renderer.domElement.getBoundingClientRect(),r=new ce.Vector2((e.clientX-i.left)/i.width*2-1,-((e.clientY-i.top)/i.height*2-1));this._raycaster.setFromCamera(r,this._camera)}_updateTooltip(e){if(!this._chipletMeshes.length){this._hideTooltip();return}this._setRaycasterFromEvent(e);let t=this._chipletMeshes.map(a=>a.mesh),i=this._raycaster.intersectObjects(t,!1);if(i.length===0){this._hideTooltip();return}let r=i[0].object,s=this._chipletMeshes.find(a=>a.mesh===r);if(!s){this._hideTooltip();return}this._tooltip.textContent=s.data.name,this._tooltip.style.display="block";let o=this._canvasContainer.getBoundingClientRect();this._tooltip.style.left=e.clientX-o.left+12+"px",this._tooltip.style.top=e.clientY-o.top+12+"px"}_hideTooltip(){this._tooltip&&(this._tooltip.style.display="none")}_pickDrcMarkerId(e){if(!this._drcHitboxMesh||!this._drcHitboxMarkerIds)return null;this._setRaycasterFromEvent(e);let t=this._raycaster.intersectObject(this._drcHitboxMesh,!1);if(t.length===0)return null;let i=t[0].instanceId;return i==null?null:this._drcHitboxMarkerIds[i]??null}_handleRotate(e,t){let i=Math.sqrt(e*e+t*t);if(i<.001)return;let r=new ce.Vector3(t/i,e/i,0),s=i/OM,a=new ce.Quaternion().setFromAxisAngle(r,s*ip).clone().multiply(this._rotation);if(new ce.Vector3(0,0,1).applyQuaternion(a).z>=0)this._rotation.copy(a);else{let l=new ce.Vector3(0,1,0),u=e/OM*ip,d=new ce.Quaternion().setFromAxisAngle(l,u).clone().multiply(this._rotation);new ce.Vector3(0,0,1).applyQuaternion(d).z>=0&&this._rotation.copy(d)}}_handlePan(e,t){let i=this._distance*e5;this._panX+=e*i,this._panY-=t*i}_updateCamera(){let e=Math.max(this._boundingRadius,1e3),t=Math.max(this._distance-e*DM,o5),i=this._distance+e*DM;i0;){let e=this._designGroup.children[0];this._designGroup.remove(e),e.geometry&&e.geometry.dispose(),e.material&&!e.material._shared&&e.material.dispose()}this._edgeMaterial&&(this._edgeMaterial.dispose(),this._edgeMaterial=null),this._onMouseMove&&(window.removeEventListener("mousemove",this._onMouseMove),this._onMouseMove=null),this._onMouseUp&&(window.removeEventListener("mouseup",this._onMouseUp),this._onMouseUp=null),this._renderer&&(this._renderer.dispose(),this._renderer=null),this._app.threeDViewerWidget===this&&(this._app.threeDViewerWidget=null)}}_setInitialCameraState(){this._distance=this._boundingRadius*s5;let e=new ce.Quaternion().setFromAxisAngle(new ce.Vector3(1,0,0),-45*ip),t=new ce.Quaternion().setFromAxisAngle(new ce.Vector3(0,0,1),45*ip);this._rotation=e.multiply(t),this._panX=0,this._panY=0}resetCamera(){this._sceneBounds&&(this._setInitialCameraState(),this._updateCamera())}onResize(){if(this._destroyed)return;let e=this._canvasContainer.getBoundingClientRect(),t=e.width,i=e.height;t===0||i===0||(this._camera.aspect=t/i,this._camera.updateProjectionMatrix(),this._renderer.setSize(t,i),this.render())}render(){this._destroyed||this._renderer&&this._scene&&this._camera&&this._renderer.render(this._scene,this._camera)}_applyTheme(){let t=Cs().bgMap||"#000000";this._scene.background=new ce.Color(t)}async loadData(){if(!(this._loading||this._destroyed)){this._loading=!0;for(let e of[".three-d-error",".three-d-info"]){let t=this._element.querySelector(e);t&&t.remove()}try{await this._app.websocketManager.readyPromise;let e=await this._app.websocketManager.request({type:"get_3d_data"});if(this._destroyed)return;if(e&&e.error){this._showError(e.error);return}if(e&&e.info){this._showInfo(e.info);return}this.buildScene(e)}catch(e){if(this._destroyed)return;console.error("Failed to load 3D data:",e),this._showError(e.message||String(e))}finally{this._loading=!1}}}_showOverlay(e,t,i){let r=document.createElement("div");r.className=e,r.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-family:monospace;text-align:center;",r.style.color=i,r.textContent=t,this._element.appendChild(r)}_showError(e){this._showOverlay("three-d-error","Failed to load 3D data: "+e,"var(--error)")}_showInfo(e){this._showOverlay("three-d-info",e,"var(--fg-muted, #888)")}_showWebGLUnavailable(e){let t=document.createElement("div");t.className="three-d-error",t.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-family:monospace;text-align:center;max-width:80%;color:var(--error);";let i=e&&e.message?e.message:String(e||"");t.innerHTML='
3D viewer unavailable: WebGL context could not be created.
In Chrome, open chrome://flags/#ignore-gpu-blocklist and set Override software rendering list to Enabled, then relaunch the browser.
Otherwise enable hardware acceleration or try a different browser. See chrome://gpu for details.
'+(i?'
'+i+"
":""),this._element.appendChild(t)}buildScene(e){if(this._destroyed||(this._lastSceneData=e,this._clearScene(),!e||!e.chiplets||e.chiplets.length===0))return;let t=this._app.getDbuPerMicron(),i=this._buildChiplets(e.chiplets,t);i.minX!==1/0&&(this._buildGrid(i),this._setSceneBoundsAndCenter(i),this._setInitialCameraState(),this._updateCamera())}_clearScene(){for(this._chipletMeshes=[];this._designGroup.children.length>0;){let e=this._designGroup.children[0];this._designGroup.remove(e),e.geometry&&e.geometry.dispose(),e.material&&!e.material._shared&&e.material.dispose()}this._hideTooltip()}_buildChiplets(e,t){let i={minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0};this._edgeMaterial||(this._edgeMaterial=new ce.LineBasicMaterial({color:0,linewidth:1}),this._edgeMaterial._shared=!0);let r=this._app.useTrueZ?new Array(e.length).fill(0):f5(e);return e.forEach((s,o)=>{let a=s.width/t,c=s.height/t,l=s.thickness/t*As,u=NM[o%NM.length],f=new ce.MeshPhongMaterial({color:u,transparent:!1,opacity:1,side:ce.DoubleSide,shininess:40}),d=new ce.BoxGeometry(a,c,l),h=new ce.Mesh(d,f),p=s.x/t+a/2,m=s.y/t+c/2,g=l*c5,v=s.z/t*As+l/2+r[o]*(l+g);h.position.set(p,m,v),this._designGroup.add(h),this._chipletMeshes.push({mesh:h,data:s,color:u});let y=new ce.EdgesGeometry(d),b=new ce.LineSegments(y,this._edgeMaterial);b.position.set(p,m,v),this._designGroup.add(b),i.minX=Math.min(i.minX,s.x/t),i.minY=Math.min(i.minY,s.y/t),i.minZ=Math.min(i.minZ,v-l/2),i.maxX=Math.max(i.maxX,s.x/t+a),i.maxY=Math.max(i.maxY,s.y/t+c),i.maxZ=Math.max(i.maxZ,v+l/2)}),i}_buildGrid(e){let t=e.maxX-e.minX,i=e.maxY-e.minY,r=Math.max(t,i)*1.4,s=10,o=new ce.GridHelper(r,s,8947848,4473924);o.rotation.x=Math.PI/2,o.position.set((e.minX+e.maxX)/2,(e.minY+e.maxY)/2,e.minZ-1),this._designGroup.add(o)}_setSceneBoundsAndCenter(e){this._sceneBounds=e;let t=e.maxX-e.minX,i=e.maxY-e.minY,r=e.maxZ-e.minZ;this._boundingRadius=Math.sqrt(t*t+i*i+r*r)/2,this._sceneCenter.set((e.minX+e.maxX)/2,(e.minY+e.maxY)/2,(e.minZ+e.maxZ)/2)}_stackOffsetForPoint(e,t,i,r){for(let{mesh:s,data:o}of this._chipletMeshes){if(e!==o.z||to.x+o.width||io.y+o.height)continue;let a=o.thickness/r*As,c=o.z/r*As+a/2;return s.position.z-c}return 0}clearHighlightDRC(){this._drcBlinkInterval&&(clearInterval(this._drcBlinkInterval),this._drcBlinkInterval=null),this._drcMeshGroup&&(this._scene.remove(this._drcMeshGroup),this._drcMeshGroup.children.forEach(e=>{e.geometry&&e.geometry.dispose()}),this._drcMaterial&&(this._drcMaterial.dispose(),this._drcMaterial=null),this._drcHitboxMaterial&&(this._drcHitboxMaterial.dispose(),this._drcHitboxMaterial=null),this._drcHitboxMesh=null,this._drcHitboxMarkerIds=null,this._drcMeshGroup=null,this.render())}highlightDRC(e){if(this._destroyed||(this.clearHighlightDRC(),!e||e.length===0))return;let t=this._app.getDbuPerMicron(),i=0,r=1e4/t*As;this._sceneBounds&&this._sceneBounds.minZ!==1/0&&(i=this._sceneBounds.minZ,r=this._sceneBounds.maxZ),i-=1,r+=1;let s=Math.max(r-i,1);this._drcMeshGroup=new ce.Group,this._drcMaterial=new ce.LineBasicMaterial({color:16776960,transparent:!0,opacity:1,depthTest:!1,depthWrite:!1}),this._drcHitboxMaterial=new ce.MeshBasicMaterial({transparent:!0,opacity:0,depthWrite:!1});let o=[];for(let l of e){let u=l.rects&&l.rects.length>0?l.rects:[l.bbox];for(let f of u){let[d,h,p,m,g,v]=f,y=Math.max((p-d)/t,.001),b=Math.max((m-h)/t,.001),w=i,E=s,x=0;if(f.length>=6&&g!==void 0&&v!==void 0){w=g/t*As;let D=v/t*As;E=Math.max(D-w,.001),x=this._stackOffsetForPoint(g,(d+p)/2,(h+m)/2,t)}let T=d/t+y/2,I=h/t+b/2,N=w+E/2+x;o.push({cx:T,cy:I,cz:N,width:y,height:b,depth:E,markerId:l.id})}}if(o.length>0){let l=new ce.BoxGeometry(1,1,1);this._drcHitboxMesh=new ce.InstancedMesh(l,this._drcHitboxMaterial,o.length),this._drcHitboxMarkerIds=new Array(o.length);let u=new ce.Matrix4,f=new ce.Vector3,d=new ce.Vector3,h=new ce.Quaternion;o.forEach((p,m)=>{d.set(p.cx,p.cy,p.cz),f.set(p.width,p.height,p.depth),u.compose(d,h,f),this._drcHitboxMesh.setMatrixAt(m,u),this._drcHitboxMarkerIds[m]=p.markerId;let g=new ce.BoxGeometry(p.width,p.height,p.depth),v=new ce.EdgesGeometry(g);g.dispose();let y=new ce.LineSegments(v,this._drcMaterial);y.position.set(p.cx,p.cy,p.cz),y.renderOrder=999,this._drcMeshGroup.add(y)}),this._drcHitboxMesh.instanceMatrix.needsUpdate=!0,this._drcMeshGroup.add(this._drcHitboxMesh)}this._drcMeshGroup.renderOrder=999,this._scene.add(this._drcMeshGroup),this.render();let a=!0,c=0;this._drcBlinkInterval=setInterval(()=>{if(!(!this._drcMeshGroup||!this._drcMaterial)){if(c+=1,c>=u5){this._drcMaterial.opacity=1,this.render(),clearInterval(this._drcBlinkInterval),this._drcBlinkInterval=null;return}a=!a,this._drcMaterial.opacity=a?1:.2,this.render()}},l5)}refreshSceneForOptions(){this._destroyed||this._lastSceneData&&(this.clearHighlightDRC(),this.buildScene(this._lastSceneData))}};var d5=[{name:"green",hex:"#00ff00"},{name:"yellow",hex:"#ffff00"},{name:"cyan",hex:"#00ffff"},{name:"magenta",hex:"#ff00ff"},{name:"red",hex:"#ff0000"},{name:"dark_green",hex:"#008000"},{name:"dark_magenta",hex:"#800080"},{name:"blue",hex:"#0000ff"},{name:"orange",hex:"#ffa500"},{name:"purple",hex:"#800080"},{name:"lime",hex:"#bfff00"},{name:"teal",hex:"#008080"},{name:"pink",hex:"#ffc0cb"},{name:"brown",hex:"#8b4513"},{name:"indigo",hex:"#4b0082"},{name:"turquoise",hex:"#40e0d0"}],h5=[{label:"Connected Insts",suffix:"connected_insts",needsNet:!0},{label:"Output Nets",suffix:"connected_nets",args:{output:!0,input:!1}},{label:"Input Nets",suffix:"connected_nets",args:{output:!1,input:!0}},{label:"All Nets",suffix:"connected_nets",args:{output:!0,input:!0}},{label:"All buffer trees",suffix:"connected_buffer_trees"},{label:"All buffer trees (incl. inverters)",suffix:"connected_buffer_trees",args:{include_inverters:!0}}],sp=class{constructor(e){this._app=e,this._el=document.createElement("div"),this._el.className="context-menu",this._el.style.display="none",this._el.style.zIndex="10000",document.body.appendChild(this._el),this._bindEvents()}_bindEvents(){document.addEventListener("mousedown",e=>{this._el.contains(e.target)||this.hide()}),this._app.view&&this._app.view.on("movestart",()=>this.hide())}show(e){this._el.innerHTML="";let t=!!this._app.selHasInst,i=!!this._app.selHasNet,r=!(t||i),s=h=>h5.map(p=>({label:p.label,disabled:p.needsNet?!i:!t,...h(p.suffix,p.args||{})})),o=[{label:"Select",disabled:r,subMenu:s((h,p)=>({action:()=>this._sendContextAction("select_"+h,p)}))},{label:"Highlight",disabled:r,subMenu:s((h,p)=>({subMenu:this._buildColorSubmenu("highlight_"+h,p)}))},{label:"Save",subMenu:[{label:"Visible layout",action:()=>this._app.captureLayout?.({entire:!1})},{label:"Entire layout",action:()=>this._app.captureLayout?.({entire:!0})}]},{label:"Clear",subMenu:[{label:"Selections",action:()=>this._sendContextAction("clear_selections")},{label:"Highlights",action:()=>this._sendContextAction("clear_highlights")},{label:"Rulers",action:()=>{this._app.rulerManager?.clearAllRulers()}},{label:"Focus nets",action:()=>this._sendContextAction("clear_focus_nets")},{label:"Route Guides",action:()=>this._sendContextAction("clear_route_guides")},{label:"All",action:()=>{this._sendContextAction("clear_all"),this._app.rulerManager?.clearAllRulers()}}]}];this._buildMenu(o,this._el),this._el.style.display="block";let a=4,c=this._el.getBoundingClientRect(),l=window.innerWidth-c.width-a,u=window.innerHeight-c.height-a,f=Math.max(a,Math.min(e.clientX,l)),d=Math.max(a,Math.min(e.clientY,u));this._el.style.left=f+"px",this._el.style.top=d+"px"}hide(){this._el.style.display="none"}_buildColorSubmenu(e,t={}){return d5.map(({name:i,hex:r},s)=>({label:i,swatch:r,action:()=>this._sendContextAction(e,{...t,group:s})}))}_buildMenu(e,t){e.forEach(i=>{let r=document.createElement("div");if(r.className="cm-item",i.swatch){let s=document.createElement("span");s.className="cm-swatch",s.style.background=i.swatch,r.appendChild(s)}if(r.appendChild(document.createTextNode(i.label)),i.disabled){r.classList.add("disabled"),i.subMenu&&r.classList.add("has-submenu"),t.appendChild(r);return}if(i.subMenu){r.classList.add("has-submenu");let s=document.createElement("div");s.className="cm-submenu",this._buildMenu(i.subMenu,s),r.appendChild(s),r.addEventListener("mouseenter",()=>{s.classList.remove("flip-left"),s.getBoundingClientRect().right>window.innerWidth&&s.classList.add("flip-left")})}else i.action&&r.addEventListener("click",s=>{s.stopPropagation(),this.hide();try{i.action()}catch(o){console.error("Context menu item action threw:",i.label,o)}});t.appendChild(r)})}_sendContextAction(e,t={}){this._app.websocketManager&&this._app.websocketManager.request({type:"context_action",action:e,...t}).then(i=>{qo(this._app,i),i&&i.connected_count===0&&nn('Nothing connected \u2014 select an instance (or a net for "Connected Insts") first.'),this._syncAfterAction(e)}).catch(i=>{console.error("Context action failed:",e,i)})}_syncAfterAction(e){let t=this._app;(e==="clear_focus_nets"||e==="clear_route_guides"||e==="clear_all")&&typeof t.redrawAllLayers=="function"&&t.redrawAllLayers(),e==="clear_selections"||e==="clear_all"?(t.updateInspector?.(null),t.stopSelectionAnimation?.(),t.clearSelectionOutline?.(),t.lastSelectionBounds=null):t.refreshInspector?.(),t.refreshOverlay?.()}};function FM(n,e){if(!n)return;let t=URL.createObjectURL(n),i=document.createElement("a");i.href=t,i.download=e,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(t),0)}function p5(n,e,t){n.view.getContainer().querySelectorAll(".or-view-markers .ruler-label").forEach(r=>{let s=r.getBoundingClientRect();if(s.width<=0||s.height<=0)return;let o=r.textContent;if(!o)return;let a=getComputedStyle(r),c=s.left-t.left,l=s.top-t.top;e.save(),e.fillStyle=a.backgroundColor||"rgba(0, 0, 0, 0.75)";let u=Math.min(parseFloat(a.borderTopLeftRadius)||0,s.height/2);u>0&&typeof e.roundRect=="function"?(e.beginPath(),e.roundRect(c,l,s.width,s.height,u),e.fill()):e.fillRect(c,l,s.width,s.height),e.fillStyle=a.color||"#eee",e.font=a.font||`${a.fontSize||"12px"} ${a.fontFamily||"monospace"}`,e.textAlign="left",e.textBaseline="middle",e.fillText(o,c+(parseFloat(a.paddingLeft)||0),l+s.height/2),e.restore()})}async function zM(n){let e=n.view.getContainer(),t=e.getBoundingClientRect(),i=Math.max(1,Math.round(t.width)),r=Math.max(1,Math.round(t.height)),s=document.createElement("canvas");s.width=i,s.height=r;let o=s.getContext("2d"),a=getComputedStyle(e).backgroundColor;o.fillStyle=a&&a!=="transparent"&&a!=="rgba(0, 0, 0, 0)"?a:"#000",o.fillRect(0,0,i,r);let c=await n.view.captureCanvas();if(c){let l=c.rect;try{o.drawImage(c.image,l.left-t.left,l.top-t.top,l.width,l.height)}catch{}}return p5(n,o,t),new Promise(l=>s.toBlob(l,"image/png"))}async function UM(n,{entire:e=!1}={}){if(!n.view)return;if(!e||!n.fitRect){FM(await zM(n),"layout_visible.png");return}let t=n.view.getCenter(),i=n.view.getZoom();try{n.view.fitWorldRect(n.fitRect,{animate:!1}),await n.view.whenTilesSettled(),FM(await zM(n),"layout_entire.png")}finally{n.view.setView(t,i,{animate:!1})}}var hr=document.getElementById("websocket-status"),ql=null,m5=2e3,g5=20;function GM(){let n=_.websocketManager&&_.websocketManager.isConnected,e=_.websocketManager?_.websocketManager.pendingCount:0;if(n)if(ql&&(clearTimeout(ql),ql=null),e>g5){let t=`pending: ${e}`,i=hr.firstElementChild;(!i?.classList.contains("pending-indicator")||i.textContent!==t)&&(hr.innerHTML=`
${t}
`),hr.style.display="block"}else hr.style.display="none";else{if(_.websocketManager?._shutdown)return;ql||(ql=setTimeout(()=>{_.websocketManager?.isConnected||(hr.innerHTML='
\u26A0 OpenROAD disconnected \u2014 retrying\u2026
',hr.style.display="block")},m5))}_5(e)}function _5(n){let e=_.tileProgressEl;if(!e)return;e.classList.toggle("active",n>0);let t=n>0?`${n} tile requests pending`:"";e.title!==t&&(e.title=t)}var $M=cr(GM);function y5(n){if(!n)return"";try{return decodeURIComponent(n)}catch{return""}}var _={view:null,fitRect:null,lastSelectionBounds:null,selHasInst:!1,selHasNet:!1,displayControlsEl:null,allLayers:[],designScale:null,designOriginX:0,designOriginY:0,websocketManager:null,goldenLayout:null,hasLiberty:!1,techData:null,inspectorEl:null,tclOutputEl:null,modulesLayer:null,pinsLayer:null,overlayLayers:[],hierarchyBrowser:null,focusNets:new Set,routeGuideNets:new Set,visibleLayers:new Set,visibleLayerNames:new Set,visibleChiplets:null,layerPatterns:{},useTrueZ:Be("or_use_true_z")==="1",showDbu:Be("or_show_dbu")==="1",rulerStyle:Be("or_ruler_style")==="manhattan"?"manhattan":"euclidian",wheelZoom:Be("or_wheel_zoom")!=="0",arrowStep:$l(Be("or_arrow_step")),controlSmoothing:Be("or_control_smoothing")!=="0",doubleBuffer:Be("or_double_buffer")!=="0",deferTileUpdates:Be("or_defer_tile_updates")==="1",fontFamily:y5(Be("or_font_family")),fontScale:Wl(Be("or_font_scale")),polyDecomp:!1,labelManager:null,selectableLayers:new Set,heatMapData:null,activeHeatMap:"",heatMapLayer:null,heatMapLegendEl:null,renderHeatMapControls:null,rulerManager:null,selectionToken:0,selectionResetters:[],getDbuPerMicron(){return this.techData?.dbu_per_micron||1e3},unitOpts(){return{showDbu:this.showDbu,dbuPerMicron:this.getDbuPerMicron()}},formatDbu(n,e=!1){return D3(n,this.unitOpts(),e)},parseDbu(n){return N3(n,this.unitOpts())},formatDistance(n){return F3(n,this.unitOpts())},unitLabel(){return z3(this.unitOpts())}},gt={stdcells:!0,macros:!0,pad_input:!0,pad_output:!0,pad_inout:!0,pad_power:!0,pad_spacer:!0,pad_areaio:!0,pad_other:!0,phys_fill:!1,phys_endcap:!0,phys_welltap:!0,phys_tie:!0,phys_antenna:!0,phys_cover:!0,phys_bump:!0,phys_other:!0,std_bufinv:!0,std_bufinv_timing:!0,std_clock_bufinv:!0,std_clock_gate:!0,std_level_shift:!0,std_sequential:!0,std_combinational:!0,net_signal:!0,net_power:!0,net_ground:!0,net_clock:!0,net_reset:!0,net_tieoff:!0,net_scan:!0,net_analog:!0,inst_names:!0,inst_pins:!0,inst_pin_names:!1,routing:!0,routing_segments:!0,routing_vias:!0,special_nets:!0,srouting_segments:!0,srouting_vias:!0,pins:!0,pin_names:!0,access_points:!1,regions:!0,mfg_grid:!1,gcell_grid:!1,flywires_only:!1,blockages:!0,placement_blockages:!0,routing_obstructions:!0,fills:!1,rows:!1,tracks_pref:!1,tracks_non_pref:!1,module_view:!1,detailed:!1,rulers:!0,labels:!0,scale_bar:!0,focused_nets_guides:!1,highlight_selected:!0,debug:!1};try{let n=Be("or_visibility");if(n){let e=JSON.parse(decodeURIComponent(n));for(let[t,i]of Object.entries(e))gt[t]=!!i}}catch{}var ta={stdcells:!0,macros:!0,pad_input:!0,pad_output:!0,pad_inout:!0,pad_power:!0,pad_spacer:!0,pad_areaio:!0,pad_other:!0,phys_fill:!0,phys_endcap:!0,phys_welltap:!0,phys_tie:!0,phys_antenna:!0,phys_cover:!0,phys_bump:!0,phys_other:!0,std_bufinv:!0,std_bufinv_timing:!0,std_clock_bufinv:!0,std_clock_gate:!0,std_level_shift:!0,std_sequential:!0,std_combinational:!0,net_signal:!0,net_power:!0,net_ground:!0,net_clock:!0,net_reset:!0,net_tieoff:!0,net_scan:!0,net_analog:!0,pins:!0,inst_pins:!0,placement_blockages:!0,routing_obstructions:!0};_.visibility=gt;_.selectability=ta;try{let n=Be("or_selectability");if(n){let e=JSON.parse(decodeURIComponent(n));for(let[t,i]of Object.entries(e))ta[t]=!!i}}catch{}(function(){let e=null;try{e=new URLSearchParams(window.location.search)}catch{return}_.forceComposite=e.get("composite")==="1",_.preserveBuffer=e.get("preservebuffer")==="1";let t=Number(e.get("grouplayers"));Number.isFinite(t)&&t>0&&(_.groupLayers=Math.floor(t))})();_.tileCtx={visibility:gt,selectability:ta,visibleLayers:_.visibleLayerNames,selectableLayers:_.selectableLayers,app:_};function b5(){return _.view.addTileSlot("heatmap",{order:at.heatmap,visible:!!_.activeHeatMap,source:qb({wm:_.websocketManager,dpr:Yo,tileSize:tn,buildRequest:(n,e,t)=>C3(n,e,t,_)})})}function fv(n){if(_.heatMapData=n,_.activeHeatMap=n.active||"",_.heatMapLayer){let e=_.heatMapLayer.isVisible();_.heatMapLayer.setVisible(!!_.activeHeatMap),e&&_.heatMapLayer.refresh()}_.renderHeatMapControls&&_.renderHeatMapControls(n)}_.updateHeatMaps=fv;function dv(){_.overlayLayer&&_.overlayLayer.refresh()}var ks=cr(()=>{dv(),_.selectionBrowser&&_.selectionBrowser.scheduleRefresh()});_.refreshOverlay=ks;function Ft(){Ue("or_visibility",encodeURIComponent(JSON.stringify(gt))),Ue("or_selectability",encodeURIComponent(JSON.stringify(ta))),rn();let n=[[_.modulesLayer,gt.module_view],[_.pinsLayer,gt.pins],..._.overlayLayers.map(({def:e,layer:t})=>[t,Yh(e.shown_by,gt)])];for(let[e,t]of n)e&&(e.visible=!!t);for(let e of _.allLayers)e.refresh();_.heatMapLayer&&_.heatMapLayer.refresh(),_.renderSelectionOutline&&_.renderSelectionOutline(),!gt.highlight_selected&&_.clearSelectionPulse&&_.clearSelectionPulse(),dv(),_.rulerManager&&_.rulerManager.updateVisibility(),_.labelManager&&_.labelManager.updateVisibility(),_.updateScaleBar&&_.updateScaleBar()}var ea=cr(Ft),rn=cr(()=>{!_.websocketManager||ue(_)||_.websocketManager.request({type:"set_display_state",state:RM()}).catch(()=>{})});_.syncDisplayState=rn;function v5(n){if(!n||typeof n!="object")return;let e=n.entries;if(!(!e||typeof e!="object")){IM(e);try{if(_.view&&_.designScale&&typeof sessionStorage<"u"){let[t,i]=_.view.getCenter(),{dbuX:r,dbuY:s}=wn(t,i,_.designScale,_.designOriginX,_.designOriginY);sessionStorage.setItem("or_restore_view",JSON.stringify({dbuX:r,dbuY:s,zoom:_.view.getZoom()}))}}catch{}window.location.reload()}}_.redrawAllLayers=Ft;_.captureLayout=(n={})=>UM(_,n);function x5(n){let e=document.createElement("div");e.className="layout-viewer",e.style.width="100%",e.style.height="100%",e.style.backgroundColor="var(--bg-map)",n.element.appendChild(e);let t=document.createElement("div");t.className="or-hud or-hud-bottom-right heatmap-map-legend hidden",e.appendChild(t),_.heatMapLegendEl=t;let i=document.createElement("div");i.className="or-progress",e.appendChild(i),_.tileProgressEl=i,n.on("destroy",()=>{_.tileProgressEl=null,_.heatMapLegendEl=null}),_.view=q3(e,{preserveDrawingBuffer:_.preserveBuffer,prefs:{smooth:()=>_.controlSmoothing,doubleBuffer:()=>_.doubleBuffer,defer:()=>_.deferTileUpdates},tileSize:tn,dpr:Yo,isStatic:ue(_)}),_.view.on("contextlost",()=>{console.warn("Layout view: WebGL context lost; rebuilding the view.")}),_.view.on("contextfailed",()=>{nn("The layout view lost its graphics context and could not get it back; reload the page.",15e3)}),window.__orView=_.view,p3(()=>{_.view.invalidateSize(),Ft()});let r=document.createElement("div");r.className="or-zoom-control";let s=[];for(let[y,b,w]of[["+","Zoom in",()=>_.view.zoomIn()],["\u2212","Zoom out",()=>_.view.zoomOut()],["\u2922","Fit",()=>{_.fitRect&&_.view.fitWorldRect(_.fitRect)}]]){let E=document.createElement("button");E.type="button",E.title=b,E.setAttribute("aria-label",b),E.textContent=y,E.addEventListener("click",x=>{x.stopPropagation(),w()}),r.appendChild(E),s.push(E)}e.appendChild(r);let o=()=>{let{minZoom:y,maxZoom:b}=_.view.getLimits(),w=_.view.getTargetZoom();s[0].disabled=w>=b,s[1].disabled=w<=y};_.view.on("zoom zoomend limits",o),o();let a=document.createElement("div");a.className="or-hud or-hud-bottom-left hidden";let c=document.createElement("div");c.id="scale-bar";let l=document.createElement("span");l.className="or-hud-divider";let u=document.createElement("div");u.id="coord-bar",a.appendChild(c),a.appendChild(l),a.appendChild(u),e.appendChild(a);function f(){let y=c.style.display!=="none"&&c.childElementCount>0,b=u.textContent!=="";l.style.display=y&&b?"":"none",a.classList.toggle("hidden",!y&&!b)}f(),X3(_.view,{isStatic:()=>ue(_),wheelZoom:()=>_.wheelZoom,arrowStep:()=>_.arrowStep,contextEnabled:()=>!(_.rulerManager&&_.rulerManager.isActive()),onClick:(y,b)=>{_.rulerManager&&_.rulerManager.isActive()?_.rulerManager.handleMapClick(y,b):_.rulerManager?.handleRulerClick(y)||_.onMapClick&&_.onMapClick(y,b)},onContextClick:(y,b)=>{_.onMapContextClick&&_.onMapContextClick(y,b)},onMove:(y,b)=>{if(_.lastMouseWorld=y,_.rulerManager&&_.rulerManager.isActive()&&_.rulerManager.handleMouseMove(y,b),!_.designScale)return;let{dbuX:w,dbuY:E}=wn(y[0],y[1],_.designScale,_.designOriginX,_.designOriginY);u.textContent=`X: ${_.formatDbu(w)} Y: ${_.formatDbu(E)}`,f()},onLeave:()=>{_.lastMouseWorld=null,u.textContent="",f()}});let d=22,h=8,p=22;function m(y,b,w){let x=2+h,T=p,I=p+y,N=d-2,D=y>=40,H=[];if(H.push(``),D&&w>1)for(let W=1;W`)}D&&H.push(`0`),H.push(`${b}`),c.innerHTML=`${H.join("")}`}function g(){if(!_.designScale||!gt.scale_bar){c.style.display="none",f();return}let y=_.designScale*Math.pow(2,_.view.getZoom()),b=_.view.getSize().width||400,w=$3({targetPx:b*.15,pxPerDbu:y,dbuPerMicron:_.techData?.dbu_per_micron,showDbu:_.showDbu});if(!w){c.style.display="none",f();return}c.style.display="",m(w.barPx,w.label,w.segments),f()}let v=cr(g);_.view.on("zoom zoomend resize",v),_.updateScaleBar=g,_.rulerManager=new Kh(_,gt,Zl,op),_.labelManager=new Jh(_,gt,Zl,op)}function w5(n){let e=document.createElement("div");e.className="display-controls",e.innerHTML='
Loading layers...
',n.element.appendChild(e),_.displayControlsEl=e}var uv="or_restore_console",E5=1<<20;function S5(){try{if(_.tclOutputEl){let n=[..._.tclOutputEl.children].map(r=>[r.textContent,r.className]),e=n.length,t=0;for(;e>0&&t+n[e-1][0].length<=E5;)t+=n[--e][0].length;let i=n.slice(e);e>0&&i.unshift([`[earlier output not kept across reload] +`,""]),sessionStorage.setItem(uv,JSON.stringify(i))}}catch{}window.location.reload()}function P5(){try{let n=sessionStorage.getItem(uv);if(!n)return;sessionStorage.removeItem(uv);for(let[e,t]of JSON.parse(n))pr(e,t)}catch{}}function pr(n,e){if(!_.tclOutputEl)return;let t=document.createElement("span");e&&(t.className=e),t.textContent=n,_.tclOutputEl.appendChild(t),_.tclOutputEl.scrollTop=_.tclOutputEl.scrollHeight}function C5(){if(_._shutdownHandled)return;_._shutdownHandled=!0,_.websocketManager&&(_.websocketManager._shutdown=!0,_.websocketManager.onPush=()=>{});let n=document.createElement("div");n.style.cssText="position:fixed;inset:0;z-index:99999;background:#1e1e1e;color:#ddd;display:flex;flex-direction:column;align-items:center;justify-content:center;font-family:system-ui,sans-serif;font-size:16px;padding:24px;text-align:center;",n.innerHTML='
OpenROAD exited
You can close this tab.
',document.body.appendChild(n),setTimeout(()=>{try{window.close()}catch{}},1500)}function T5(n){let e=document.createElement("div");if(e.className="tcl-console",e.innerHTML='
%
',n.element.appendChild(e),_.tclOutputEl=e.querySelector(".tcl-output"),P5(),ue(_)){e.querySelector(".tcl-input-row").style.display="none";let r=document.createElement("span");r.className="tcl-static-notice",r.setAttribute("role","status"),r.setAttribute("aria-live","polite"),r.textContent="Tcl console is not available in saved reports.",_.tclOutputEl.appendChild(r);return}let t=e.querySelector(".tcl-input"),i=new np(t,_.websocketManager);t.addEventListener("keydown",r=>{if(!i.handleKeyDown(r)&&r.key==="Enter"){let s=t.value.trim();if(!s)return;pr(`>>> ${s} +`,"tcl-cmd"),i.addToHistory(s),t.value="",_.websocketManager.request({type:"tcl_eval",cmd:s}).then(o=>{o.result&&pr(o.result+` +`,o.is_error?"tcl-error":""),o.action==="shutdown"&&C5(),!o.is_error&&_.drcWidget&&_.drcWidget.refresh()}).catch(o=>pr(`Error: ${o} +`,"tcl-error"))}})}_.visibility=gt;var mr=cM(_,Ft,ks),L5=mr.createInspector,Zl=mr.updateInspector,M5=mr.highlightBBox,A5=mr.pulseHighlight;_.updateInspector=Zl;_.navigateInspector=mr.navigateInspector;_.refreshInspector=mr.refreshInspector;_.animateSelection=mr.animateSelection;_.stopSelectionAnimation=mr.stopSelectionAnimation;function k5(n){new Gh(n,_,Ft)}function R5(n){_.timingWidget=new Ps(_,Ft,ks),n.element.appendChild(_.timingWidget.element)}function I5(n){_.drcWidget=new tp(_,Ft,ks),n.element.appendChild(_.drcWidget.element)}function B5(n){_.clockTreeWidget=new Uh(n,_,Ft,ks)}function O5(n){_.chartsWidget=new $h(_,Ft),n.element.appendChild(_.chartsWidget.element)}function D5(n){let e=document.createElement("div");e.className="help-panel",e.innerHTML="

Keyboard Shortcuts

fFit design to viewport
scrollZoom in/out
dragPan the view
right-dragRubber-band zoom
Shift+clickAdd object to selection
Ctrl/Cmd+clickSelect object and its connected nets
kToggle ruler mode
Shift+KClear all rulers
EscapeCancel ruler (when building)
",n.element.appendChild(e)}function N5(n){_.selectionBrowser=new Vh(n,_,ks)}function F5(n){new ep(n,_)}function z5(n){_.threeDViewerWidget=new rp(n,_)}var U5=28,$5={dimensions:{headerHeight:U5},root:{type:"row",content:[{type:"component",componentType:"DisplayControls",title:"Display Controls",width:15},{type:"column",width:55,content:[{type:"stack",height:70,content:[{type:"component",componentType:"LayoutViewer",title:"Layout",isClosable:!1},{type:"component",componentType:"SchematicWidget",title:"Schematic"},{type:"component",componentType:"3DViewer",title:"3D Viewer"}]},{type:"component",componentType:"TclConsole",title:"Tcl Console",height:30}]},{type:"stack",width:30,content:[{type:"component",componentType:"Inspector",title:"Inspector"},{type:"component",componentType:"Browser",title:"Hierarchy"},{type:"component",componentType:"TimingWidget",title:"Timing"},{type:"component",componentType:"DRCWidget",title:"DRC"},{type:"component",componentType:"SelectHighlight",title:"Select Highlight"},{type:"component",componentType:"ClockWidget",title:"Clock Tree"},{type:"component",componentType:"ChartsWidget",title:"Charts"},{type:"component",componentType:"HelpWidget",title:"Help"}]}]}};_.goldenLayout=new Ch(document.getElementById("gl-container"));_.goldenLayout.registerComponentFactoryFunction("LayoutViewer",x5);_.goldenLayout.registerComponentFactoryFunction("DisplayControls",w5);_.goldenLayout.registerComponentFactoryFunction("TclConsole",T5);_.goldenLayout.registerComponentFactoryFunction("Inspector",L5);_.goldenLayout.registerComponentFactoryFunction("Browser",k5);_.goldenLayout.registerComponentFactoryFunction("TimingWidget",R5);_.goldenLayout.registerComponentFactoryFunction("DRCWidget",I5);_.goldenLayout.registerComponentFactoryFunction("ClockWidget",B5);_.goldenLayout.registerComponentFactoryFunction("ChartsWidget",O5);_.goldenLayout.registerComponentFactoryFunction("SchematicWidget",F5);_.goldenLayout.registerComponentFactoryFunction("3DViewer",z5);_.goldenLayout.registerComponentFactoryFunction("HelpWidget",D5);_.goldenLayout.registerComponentFactoryFunction("SelectHighlight",N5);var ri=window.__STATIC_CACHE__||null;if(ri)c3(),_.websocketManager=Dl.fromCache(ri,$M);else{let n=`ws://${window.location.host||"localhost:8080"}/ws`;_.websocketManager=new Dl(n,$M),_.layerExtents=new Rh,_.websocketManager.onReconnected=()=>{ap(),mv(null,null,{reloadOnChange:!0}).catch(()=>{})}}GM();_.goldenLayout.loadLayout($5);VM();function VM(){G3(document.getElementById("gl-container"))>0&&_.goldenLayout.updateSize()}_.goldenLayout.on("stateChanged",()=>{VM()});function hv(){_.goldenLayout.updateSize()}_.syncLayoutSize=hv;window.addEventListener("resize",hv);function op(n){_.goldenLayout.focusComponent(n)}_.focusComponent=op;_.resetLayout=function(){_.goldenLayout&&typeof _.goldenLayout.resetLayout=="function"&&_.goldenLayout.resetLayout()};_.toggleTheme=function(){let n=document.documentElement.dataset.theme==="dark"?"light":"dark";document.documentElement.dataset.theme=n,Jb(n),Dh(n),_.chartsWidget&&_.chartsWidget.render(),_.clockTreeWidget&&_.clockTreeWidget.render(),rn()};_.toggleShowDbu=function(){_.showDbu=!_.showDbu,Ue("or_show_dbu",_.showDbu?"1":"0"),_.rulerManager&&_.rulerManager._renderAll(),_.hierarchyBrowser&&_.hierarchyBrowser._render(),_.updateScaleBar&&_.updateScaleBar(),_.refreshInspector&&_.refreshInspector(),rn()};_.toggleRulerStyle=function(){_.rulerStyle=_.rulerStyle==="manhattan"?"euclidian":"manhattan",Ue("or_ruler_style",_.rulerStyle),rn()};_.toggleWheelZoom=function(){_.wheelZoom=!_.wheelZoom,Ue("or_wheel_zoom",_.wheelZoom?"1":"0"),rn()};_.toggleControlSmoothing=function(){_.controlSmoothing=!_.controlSmoothing,Ue("or_control_smoothing",_.controlSmoothing?"1":"0"),rn()};_.toggleDoubleBuffer=function(){_.doubleBuffer=!_.doubleBuffer,Ue("or_double_buffer",_.doubleBuffer?"1":"0"),_.view?.applyPrefs(),rn()};_.toggleDeferTileUpdates=function(){_.deferTileUpdates=!_.deferTileUpdates,Ue("or_defer_tile_updates",_.deferTileUpdates?"1":"0"),_.view?.applyPrefs(),rn()};_.setArrowStep=function(n){_.arrowStep=$l(n),Ue("or_arrow_step",String(_.arrowStep)),rn()};_.setAppFont=function({family:n,scale:e}){_.fontFamily=n??_.fontFamily,_.fontScale=Wl(e??_.fontScale),Ue("or_font_family",encodeURIComponent(_.fontFamily)),Ue("or_font_scale",String(_.fontScale)),_.applyAppFont(),rn()};_.applyAppFont=function(){let n=document.documentElement;_.fontFamily?n.style.setProperty("--or-font-family",_.fontFamily):n.style.removeProperty("--or-font-family"),n.style.setProperty("--or-font-scale",String(_.fontScale/100)),_.chartsWidget&&_.chartsWidget.render(),_.clockTreeWidget&&_.clockTreeWidget.render()};_.showArrowStepDialog=()=>fM(_);_.showAppFontDialog=()=>dM(_);_.togglePolyDecomp=function(){_.websocketManager&&_.websocketManager.request({type:"poly_decomp",value:!_.polyDecomp}).then(n=>pv(n.value)).catch(()=>{})};function pv(n){_.polyDecomp=!!n,_.rebuildMenuBar&&_.rebuildMenuBar(),_.refreshOverlay&&_.refreshOverlay()}_.applyAppFont();_.echoTcl=n=>pr(`>>> ${n} +`,"tcl-cmd");_.runTclScript=(n,e)=>n?(e&&_.echoTcl(n),_.websocketManager.request({type:"tcl_eval",cmd:n}).then(t=>(t&&t.result&&pr(t.result+` +`,t.is_error?"tcl-error":""),t)).catch(t=>{pr(`Error: ${t} +`,"tcl-error")})):Promise.resolve();function WM(n){n&&(_.customMenu=n.menu||[],_.customToolbar=n.toolbar||[],_.rebuildMenuBar&&_.rebuildMenuBar(),_.rebuildToolbar&&_.rebuildToolbar(),hv())}_.customMenu=[];_.customToolbar=[];_.scheduleRedrawAllLayers=ea;_.showGlobalConnectDialog=()=>EM(_);_.showInsertBufferDialog=n=>SM(_,n);bM(_);vM(_);_.contextMenu=new sp(_);function G5(){let n=document.getElementById("debug-continue-btn");return n||(n=document.createElement("button"),n.id="debug-continue-btn",n.className="debug-continue-btn",n.textContent="Continue",n.title="Advance the debugger (gpl, cts, ...)",n.addEventListener("click",()=>{_.websocketManager.request({type:"debug_continue"}).catch(()=>{})}),(document.getElementById("menu-bar")||document.body).appendChild(n),n)}function jM(n,e){let t=Xb(n,tn(),e);return t?(_.currentBounds=n,_.designScale=t.scale,_.designOriginX=t.originX,_.designOriginY=t.originY,_.fitRect=t.fitRect,_.view.setLimits({minZoom:0,maxZoom:B3(t.scale)}),!0):!1}async function mv(n,e,{reloadOnChange:t=!1}={}){if(ue(_)||!_.view)return!1;let i=n,r=e;if(!i)try{let l=await _.websocketManager.request({type:"bounds"});i=l.bounds,r=l.fit_bounds}catch{return!1}if(!i||R3(_.currentBounds,i))return!1;if(t)return window.location.reload(),!0;let s=!!_.designScale,[o,a]=_.view.getCenter(),c=s?wn(o,a,_.designScale,_.designOriginX,_.designOriginY):null;return jM(i,r)?(c&&_.view.setView(xn(c.dbuX,c.dbuY,_.designScale,_.designOriginX,_.designOriginY),_.view.getZoom(),{animate:!1}),_.clearSelectionOutline&&_.clearSelectionOutline(),Ft(),!0):!1}function V5(){let n=document.getElementById("loading-overlay");n.style.display="flex";let e=()=>{n.style.display!=="none"&&_.websocketManager.request({type:"bounds"}).then(t=>{t.shapes_ready&&(n.style.display="none")}).catch(()=>{}).finally(()=>{n.style.display!=="none"&&setTimeout(e,1e3)})};setTimeout(e,1e3)}function ap(){_.layerExtents&&_.layerExtents.refetch(n=>_.websocketManager.request(n))}function W5(n){document.getElementById("loading-overlay").style.display="none",ap(),mv(n.bounds,n.fit_bounds).then(e=>{e||Ft()}).catch(()=>Ft()),_.refreshInspector&&_.refreshInspector()}function j5(){let n=document.getElementById("script-running-badge");return n||(n=document.createElement("span"),n.id="script-running-badge",n.className="script-running-badge",n.textContent="Script running",n.title="The view updates when the script pauses or finishes",(document.getElementById("menu-bar")||document.body).appendChild(n),n)}function H5(n){if(_.scriptRunning=n,j5().style.display=n?"block":"none",!n){if(!_.booted||!_.designScale){S5();return}_.refreshPending&&(_.refreshPending=!1,ap(),_.refreshInspector&&_.refreshInspector()),mv().then(e=>{e||ea()}).catch(()=>ea())}}_.websocketManager.onPush=n=>{if(n.type==="refresh"){if(_.scriptRunning){_.refreshPending=!0;return}W5(n)}else if(n.type==="script_running")H5(!!n.running);else if(n.type==="renderer_controls_changed")_.refreshRendererControls&&_.refreshRendererControls(),ea();else if(n.type==="selection_invalidated")_.updateInspector&&_.updateInspector(null),_.stopSelectionAnimation&&_.stopSelectionAnimation(),_.clearSelectionOutline&&_.clearSelectionOutline(),ks();else if(n.type==="heatmaps_changed")_.websocketManager.request({type:"heatmaps"}).then(fv).catch(e=>console.error("Heat map refresh failed",e));else if(n.type==="labels_changed")_.labelManager&&_.labelManager.applyRemoteLabels(n.labels);else if(n.type==="drcUpdated")_._drcUpdateTimeout&&clearTimeout(_._drcUpdateTimeout),_._drcUpdateTimeout=setTimeout(()=>{_.drcWidget&&_.drcWidget.refresh()},500);else if(n.type==="debug_paused")_.refreshRendererControls&&_.refreshRendererControls(),G5().style.display="block",ea(),_.chartsWidget&&_.websocketManager.request({type:"debug_charts"}).then(e=>_.chartsWidget.setDebugCharts(e.charts||[])).catch(()=>{});else if(n.type==="debug_resumed"){let e=document.getElementById("debug-continue-btn");e&&(e.style.display="none")}else if(n.type==="debug_refresh"){if(_.scriptRunning)return;_.clearSelectionOutline&&_.clearSelectionOutline(),ea()}else if(n.type==="log"){let e=n.text;e.endsWith(` +`)&&(e=e.slice(0,-1)),e&&pr(e+` +`,"")}else n.type==="restore_display_state"?v5(n.state):n.type==="custom_ui"?WM(n):n.type==="poly_decomp"?pv(n.value):n.type==="shutdown"&&(_.websocketManager._shutdown=!0,hr.innerHTML='
Server stopped
',hr.style.display="block")};_.websocketManager.readyPromise.then(async()=>{try{let o=function(a,c={}){let{addToSelection:l=!1,focusInspector:u=!0,context:f=!1,showConnectivity:d=!1}=c;if(!_.designScale)return Promise.resolve(null);let{dbuX:h,dbuY:p}=wn(a[0],a[1],_.designScale,_.designOriginX,_.designOriginY);if(_.labelManager&&_.labelManager.isActive())return _.labelManager.handleMapClick(h,p),Promise.resolve(null);let m=A3(gt,ta),g={type:"select",dbu_x:h,dbu_y:p,zoom:Math.round(_.view.getZoom()),visible_layers:[..._.visibleLayerNames],selectable_layers:[..._.selectableLayers],use_dbu:_.showDbu,...m};l&&(g.add_to_selection=!0),f&&(g.context=!0),d&&(g.show_connectivity=!0),_.visibleChiplets instanceof Set&&(g.visible_chiplets=[..._.visibleChiplets]);let v=St(_);return _.websocketManager.request(g).then(y=>{if(Dt(_,v)){if(console.log("Select response:",y,"at dbu",h,p),qo(_,y),y.selected&&y.selected.length>0){let b=y.selected[0];b.type==="Inst"&&(_.selectedInstanceName=b.name,_.schematicWidget&&_.schematicWidget.refresh()),Zl(y),u&&op("Inspector"),y.bbox&&(M5(y.bbox[0],y.bbox[1],y.bbox[2],y.bbox[3],y.type),A5(y.bbox,y.type),_.lastSelectionBounds=y.bbox.slice(0,4)),g.show_connectivity&&y.connected_added>0&&nn(`Selected ${y.connected_added} connected net`+(y.connected_added>1?"s":""))}else!l&&!f&&(Zl(null),_.clearSelectionOutline&&_.clearSelectionOutline(),_.lastSelectionBounds=null);return dv(),y}}).catch(y=>(console.error("Select failed:",y),null))},[n,e,t]=await Promise.all([_.websocketManager.request({type:"tech"}),_.websocketManager.request({type:"bounds"}),_.websocketManager.request({type:"heatmaps"})]);ap(),_.hasLiberty=n.has_liberty,_.techData=n,BM(n.block_name),_.websocketManager.request({type:"custom_ui"}).then(WM).catch(()=>{}),_.websocketManager.request({type:"poly_decomp"}).then(a=>pv(a.value)).catch(()=>{});let i=e.bounds,r=e.fit_bounds;if(!ri){let a=_.view.getSize();l3(O3({designBounds:i,fitRect:r,viewW:a.width,viewH:a.height}))}let s=jM(i,r);if(s){if(_.labelManager&&_.labelManager.reload(),ri){let a=ri.zoom;_.view.setLimits({minZoom:a,maxZoom:a})}if(_.view.fitWorldRect(_.fitRect,{animate:!1}),ri){let a=Ot(i[0][1],i[0][0],i[1][1],i[1][0],_.designScale,_.designOriginX,_.designOriginY);ri.setPathOverlay=c=>{_.view.setImageOverlay("timing-path",c?{image:c,rect:a}:null)}}try{let a=sessionStorage.getItem("or_restore_view");if(a){sessionStorage.removeItem("or_restore_view");let c=JSON.parse(a);c&&isFinite(c.dbuX)&&isFinite(c.dbuY)&&isFinite(c.zoom)&&_.view.setView(xn(c.dbuX,c.dbuY,_.designScale,_.designOriginX,_.designOriginY),c.zoom,{animate:!1})}}catch{}}ri&&(document.getElementById("loading-overlay").style.display="none"),_.selectAtWorld=o,ri||(_.onMapClick=(a,c)=>o(a,{addToSelection:!!c.shiftKey,showConnectivity:!!(c.ctrlKey||c.metaKey)}),_.onMapContextClick=(a,c)=>{o(a,{context:!0,focusInspector:!1}).then(()=>_.contextMenu.show(c))}),mM(_,gt,ta,n,Ft,b5),!_.overlayLayer&&!ri&&(_.overlayLayer=_.view.addTileSlot("overlay",{order:at.overlay,source:qb({wm:_.websocketManager,dpr:Yo,tileSize:tn,buildRequest:(a,c,l)=>P3(a,c,l,gt,_)})})),fv(t),s&&!e.shapes_ready&&V5(),rn(),_.booted=!0}catch(n){_.scriptRunning||console.error("Failed to load initial data from server:",n)}});document.addEventListener("openroad-cone-sync",n=>{_.schematicWidget?.syncCone(n.detail||{})});document.addEventListener("keydown",n=>{let e=n.target.tagName;if(e==="INPUT"||e==="TEXTAREA"||n.target.isContentEditable)return;let t=n.key.toLowerCase();if(t==="escape"&&_.rulerManager&&_.rulerManager.isActive())_.rulerManager.cancelRulerBuild();else if(t==="escape"&&_.labelManager&&_.labelManager.isActive())_.labelManager.cancelLabelMode();else if(t==="k"&&!n.shiftKey&&!n.ctrlKey&&!n.metaKey)_.rulerManager&&_.rulerManager.toggleRulerMode();else if(t==="k"&&n.shiftKey&&!n.ctrlKey&&!n.metaKey)_.rulerManager&&_.rulerManager.clearAllRulers();else if(t==="l"&&!n.shiftKey&&!n.ctrlKey&&!n.metaKey)_.labelManager&&_.labelManager.toggleLabelMode();else if(t==="f"&&!n.ctrlKey&&!n.metaKey&&_.fitRect)_.view.fitWorldRect(_.fitRect);else if(t==="z"&&!n.ctrlKey&&_.view){let i=n.shiftKey?-1:1;_.view.zoomAround(_.lastMouseWorld?_.view.project(_.lastMouseWorld):null,i)}else t==="f"&&(n.ctrlKey||n.metaKey)?(n.preventDefault(),_.designScale&&qh(_)):t==="g"&&n.shiftKey&&!n.ctrlKey&&!n.metaKey?(n.preventDefault(),_.designScale&&Zh(_)):t==="t"&&!n.shiftKey&&!n.ctrlKey&&!n.metaKey&&_.toggleTheme()},!0);})(); /*! Bundled license information: -leaflet/dist/leaflet-src.js: - (* @preserve - * Leaflet 1.9.4, a JS library for interactive maps. https://leafletjs.com - * (c) 2010-2023 Vladimir Agafonkin, (c) 2010-2011 CloudMade - *) - @lit/reactive-element/css-tag.js: (** * @license diff --git a/src/web/docs/server-api.md b/src/web/docs/server-api.md index b0e640a82e1..105e5fb9879 100644 --- a/src/web/docs/server-api.md +++ b/src/web/docs/server-api.md @@ -90,8 +90,8 @@ canonical JSON type; sending any other type for a present field yields a on the wire, which the server tolerates for double-typed fields only. - Strings are JSON strings; arrays are JSON arrays. - Two narrow exceptions documented inline: - - `select.zoom` accepts `int` or `double` (Leaflet's `zoomSnap: 0` - permits fractional zoom values). + - `select.zoom` accepts `int` or `double` (a client may send a + fractional zoom value). - `set_heatmap.value` for `int`-typed settings accepts `int` or `double` and rounds (the JS frontend always uses `parseFloat`). @@ -107,6 +107,7 @@ simply listening on the WebSocket; there's no opt-in. | `type` field | Trigger | Body | | -------------- | ----------------------------------------------------------------------- | ------------------------------- | +| `config` | First message on every connection. | `{"type":"config","max_in_flight":16}` | | `refresh` | Initial spatial-index build finished after a connection / `web_server`. | `{"type":"refresh"}` | | `log` | Buffered server log lines being flushed to clients. | `{"type":"log","text":""}` | | `debug_paused` | The graphics-debug pause hook entered (e.g. placer breakpoint). | `{"type":"debug_paused"}` | @@ -114,6 +115,8 @@ simply listening on the WebSocket; there's no opt-in. | `debug_refresh`| Debug overlay needs a re-render. | `{"type":"debug_refresh"}` | | `shutdown` | Server is exiting; client should not auto-reconnect. | `{"type":"shutdown"}` | +`config.max_in_flight` is how many requests the client keeps on the wire. + --- ## Tile rendering @@ -141,27 +144,56 @@ Render a single 256×256 PNG tile of the layout. | Field | Type | Required | Description | | ---------------- | -------- | :------: | ----------- | | `layer` | `string` | ✓ | Layer name (`metal1`, `metal2`, …) or one of the synthetic layers `_instances`, `_modules`, `_pins`, or `_overlay`. | -| `z` | `int` | ✓ | Leaflet tile zoom level (0 = whole design). | +| `z` | `int` | ✓ | Tile zoom level (0 = whole design). | | `x` | `int` | ✓ | Tile column at zoom `z`. | | `y` | `int` | ✓ | Tile row at zoom `z`. | | `visible_layers` | `string[]` | ✓ | Tech layers currently visible on the *pins* synthetic layer; empty array means hide all pin markers. | | *visibility flags* | `bool` | per-flag default | See *TileVisibility flags* below. Any flag may be omitted to take the default. | | `site_` | `bool` | — | Per-row-site visibility. Only consulted when `rows == true`. | +| `pattern` | `int` | — | Fill pattern for the layer's shapes: `0` none, `1` solid (default), `2` diagonal, `3` cross, `4` dots. Out-of-range values mean solid. | **Response:** PNG image (frame type `1`), or frame type `3` with no body when the layer has nothing to draw in this tile. +**Caching:** the server caches the response under the tile, the rendered +`dpr` and `tile_px`, and the parsed fields that can change this layer's +pixels. Selectability fields, keys the server does not parse, and flags that +only another layer draws (for example `pin_markers` outside `_pins`, or +`visible_layers` outside `_pins` and `_access_points`) do not split the cache. +Tiles that depend on per-session state (module colors, focused nets, debug +renderers) are not cached. + +### `tile_group` + +Render several tech layers into one PNG, composited bottom to top with +straight-alpha source-over. It is the image the client would get by stacking +the `tile` responses for the same layers, in one request instead of one per +layer. Accepts the same visibility fields and sizing fields as `tile`. The web +client sends it only when opened with `?composite=1`; by default it fetches one +`tile` per layer. + +| Field | Type | Required | Description | +| ---------- | ---------- | :------: | ----------- | +| `layers` | `string[]` | ✓ | Tech layer names, bottom first; 1 to 256. A name may repeat (one per chiplet in a multi-die design). Synthetic layers (`_…`) are rejected. | +| `patterns` | `int[]` | — | Fill pattern per layer, same length as `layers` (see `pattern` under `tile`). Default: solid. | +| `z`, `x`, `y` | `int` | ✓ | As for `tile`. | + +**Response:** PNG image (frame type `1`), frame type `3` when none of the +layers draws anything in this tile, or an error for a malformed request. A +request cancelled between two of its layers answers `cancelled`, like `tile`. +Cached like `tile`, under the ordered layer and pattern list. + ### `overlay_tile` Render one tile of the highlight overlay — selection, hover, timing paths, DRC markers, route guides, flight lines and user labels — on a transparent background, on the same tile grid as `tile`. Kept separate from the layer -tiles so a selection change repaints one pane instead of re-rendering every +tiles so a selection change repaints the overlay instead of re-rendering every layer's geometry. | Field | Type | Required | Description | | --------------------- | ---------- | :------: | ----------- | -| `z` | `int` | ✓ | Leaflet tile zoom level, as for `tile`. | +| `z` | `int` | ✓ | Tile zoom level, as for `tile`. | | `x` | `int` | ✓ | Tile column at zoom `z`. | | `y` | `int` | ✓ | Tile row at zoom `z`. | | `visible_layers` | `string[]` | — | Tech layers currently visible. Consulted so route guides respect layer visibility; omitted means draw guides on every layer. | @@ -303,7 +335,7 @@ overlapping objects on repeated calls at the same point. | ---------------- | -------- | :------: | ----------- | | `dbu_x` | `int` | ✓ | X coordinate in DBU. | | `dbu_y` | `int` | ✓ | Y coordinate in DBU. | -| `zoom` | `int` or `double` | ✓ | Current Leaflet zoom level. Server truncates fractional values. | +| `zoom` | `int` or `double` | ✓ | Current view zoom level. Server truncates fractional values. | | `visible_layers` | `string[]`| ✓ | Same semantics as `tile`. | | *visibility flags* | `bool` | per-flag default | Same as `tile`. | | `site_` | `bool` | — | Same as `tile`. | diff --git a/src/web/esbuild.config.mjs b/src/web/esbuild.config.mjs index 1b3edbe245f..b462419394a 100644 --- a/src/web/esbuild.config.mjs +++ b/src/web/esbuild.config.mjs @@ -31,6 +31,28 @@ const elkBrowserBuild = { }, }; +// loaders.gl fetches worker scripts and codec libraries from unpkg when it has +// no copy of its own. The layout view hands deck.gl decoded images and never +// loads through it, so that fallback is pointed at nothing remote. +const kLoadersCdn = 'https://unpkg.com/@loaders.gl'; +const noLoadersCdn = { + name: 'no-loaders-cdn', + setup(build) { + build.onLoad({ filter: /[\\/]@loaders\.gl[\\/].*\.js$/ }, + async ({ path }) => { + const text = await readFile(path, 'utf8'); + if (!text.includes(kLoadersCdn)) { + return undefined; + } + return { + contents: text.replaceAll(kLoadersCdn, + 'loaders.gl-cdn-disabled'), + loader: 'js', + }; + }); + }, +}; + export default { // iife: one self-contained script whose top-level names stay out of the // page's global scope, however the page loads it. @@ -38,9 +60,9 @@ export default { platform: 'browser', target: ['es2022'], loader: { - // leaflet.css and the golden-layout themes reach icons through relative + // The golden-layout stylesheets reach icons through relative // url(); inlined, the page needs no file besides the bundles. '.png': 'dataurl', }, - plugins: [compactSvg, elkBrowserBuild], + plugins: [compactSvg, elkBrowserBuild, noLoadersCdn], }; diff --git a/src/web/package.json b/src/web/package.json index 892947a385a..714309cd3d6 100644 --- a/src/web/package.json +++ b/src/web/package.json @@ -4,8 +4,10 @@ "type": "module", "description": "Browser libraries for the web viewer, bundled by esbuild into the assets embedded in the OpenROAD binary (issue #11065).", "dependencies": { + "@deck.gl/core": "9.4.0", + "@deck.gl/extensions": "9.4.0", + "@deck.gl/layers": "9.4.0", "golden-layout": "2.6.0", - "leaflet": "1.9.4", "lit": "^3.3.3", "netlistsvg": "1.0.2", "three": "0.160.0" diff --git a/src/web/pnpm-lock.yaml b/src/web/pnpm-lock.yaml index d7e11d4f8f3..ecb6b3d8d49 100644 --- a/src/web/pnpm-lock.yaml +++ b/src/web/pnpm-lock.yaml @@ -18,12 +18,18 @@ importers: .: dependencies: + '@deck.gl/core': + specifier: 9.4.0 + version: 9.4.0(@luma.gl/webgpu@9.4.2(@luma.gl/core@9.4.2)(@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2))) + '@deck.gl/extensions': + specifier: 9.4.0 + version: 9.4.0(@deck.gl/core@9.4.0(@luma.gl/webgpu@9.4.2(@luma.gl/core@9.4.2)(@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2))))(@luma.gl/core@9.4.2)(@luma.gl/engine@9.4.2(@luma.gl/core@9.4.2)(@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2))) + '@deck.gl/layers': + specifier: 9.4.0 + version: 9.4.0(@deck.gl/core@9.4.0(@luma.gl/webgpu@9.4.2(@luma.gl/core@9.4.2)(@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2))))(@loaders.gl/core@4.5.4)(@luma.gl/core@9.4.2)(@luma.gl/engine@9.4.2(@luma.gl/core@9.4.2)(@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2))) golden-layout: specifier: 2.6.0 version: 2.6.0 - leaflet: - specifier: 1.9.4 - version: 1.9.4 lit: specifier: ^3.3.3 version: 3.3.3 @@ -36,27 +42,154 @@ importers: packages: + '@deck.gl/core@9.4.0': + resolution: {integrity: sha512-0isP+x2eGNxteO7lT650lYO7oiAYXAu4aF1jG+BMi8aKYh38HtPugLq1TlQTravIXzBSi5Oe1oZNuVj8h4ZEjA==} + + '@deck.gl/extensions@9.4.0': + resolution: {integrity: sha512-KHtB0233PSVRac8oHTk0RDivOBORLRIvSQgMpteNxVUO1lRPEa3yoMj4AE2qcKa2w2jqwaT9zt881uyFEB0eSg==} + peerDependencies: + '@deck.gl/core': ~9.4.0 + '@luma.gl/core': ~9.4.0 + '@luma.gl/engine': ~9.4.0 + + '@deck.gl/layers@9.4.0': + resolution: {integrity: sha512-jSL/xje2Ez7DmnP8AAIdhhg6IAtfXMmnXiUAKNgpl/TTaEL+iL5TAnagCdt39H3azmKVcCG33kOlIoWFAuLuRg==} + peerDependencies: + '@deck.gl/core': ~9.4.0 + '@loaders.gl/core': ^4.4.3 + '@luma.gl/core': ~9.4.0 + '@luma.gl/engine': ~9.4.0 + '@lit-labs/ssr-dom-shim@1.6.0': resolution: {integrity: sha512-VHb0ALPMTlgKjM6yIxxoQNnpKyUKLD04VzeQdsiXkMqkvYlAHxq9glGLmgbb889/1GsohSOAjvQYoiBppXFqrQ==} '@lit/reactive-element@2.1.2': resolution: {integrity: sha512-pbCDiVMnne1lYUIaYNN5wrwQXDtHaYtg7YEFPeW+hws6U47WeFvISGUWekPGKWOP1ygrs0ef0o1VJMk1exos5A==} + '@loaders.gl/core@4.5.4': + resolution: {integrity: sha512-mhO2TT5KWU3GbFYSQ78nPAhoeCnoUfTYjzwxzhHAhd656U4MW/Rq5CxZxM6liKk0Jt11dCQ8VT4nXu8334CmqQ==} + + '@loaders.gl/images@4.5.4': + resolution: {integrity: sha512-Z/7SSC9v+iQdcpwkr7nSloCpgAREuO2/3yD4niAhk+ar7nrgRByaiBH16L51M5Juse8MG3oC67gaO85VuUb3jA==} + peerDependencies: + '@loaders.gl/core': ~4.5.0 + + '@loaders.gl/loader-utils@4.5.4': + resolution: {integrity: sha512-ZUNn/4+DEn8yTKGUKdjlbA7ok2JyNrica/Lvf1d8dwx7vCUSZ84PBB9cNtrx8VDXmVjkIClQzmnriz16QHjTMQ==} + + '@loaders.gl/schema-utils@4.5.4': + resolution: {integrity: sha512-vV52aT4RJiHzzbHlwdkX254d/ubdNzcxJuFfrfDeyUZkKDa//YPhVFjCxfNlxXgS+7pS0TGakfNB18vyYkk3FA==} + peerDependencies: + '@loaders.gl/core': ~4.5.0 + + '@loaders.gl/schema@4.5.4': + resolution: {integrity: sha512-5CO/TY2OkmM53+qfSvzMt17LwVJhBatqi/QaO45VOn8poTK1jqyZvnI0qvKFqOsMWzHh4yoQVUnxaWiV4CZ41w==} + + '@loaders.gl/worker-utils@4.5.4': + resolution: {integrity: sha512-OvVMMLh56QdBQgyMDxuho9doWq6oiz7paqP3rwidb+LqgJB5GvdqcoL+GbUcku2X8k0ZxCldvo+l46Yhpv0bfQ==} + peerDependencies: + '@loaders.gl/core': ~4.5.0 + + '@luma.gl/core@9.4.2': + resolution: {integrity: sha512-VFol6FUSHQeYR40NrkCM/mkP5DX7aI8pcDewxI8DBjtrcP4+ZJiJwnxWZnsMBzM4RuuvmDoHkPWCxj6Ob9yo+w==} + + '@luma.gl/engine@9.4.2': + resolution: {integrity: sha512-gBAcn+b1jOwE4pDF5zbuzMxCa/KGY3Q2Gq0gNUPU1AZHNk4aDgOEQaY2sqMsaoGHkDXB+pxneJQPw5c6Q5mnHA==} + peerDependencies: + '@luma.gl/core': ~9.4.0 + '@luma.gl/shadertools': ~9.4.0 + + '@luma.gl/gpgpu@9.4.2': + resolution: {integrity: sha512-LoEqoViPZqMHqQzvq/txFuOLsxI6sn8xmv+IZyovRFBqcWaV184PE/8Ieufww0pjVyJMfubhUCQmGuGrOME8oA==} + peerDependencies: + '@luma.gl/core': ~9.4.0 + '@luma.gl/engine': ~9.4.0 + '@luma.gl/shadertools': ~9.4.0 + '@luma.gl/webgpu': ~9.4.0 + + '@luma.gl/shadertools@9.4.2': + resolution: {integrity: sha512-0/6pLZSfnQnvcWdYePKKSwVet+gFtAAnKeGXNfxpgp3I8E3WsF/SbD6oEzgU7jdnRqONwGsoACWNpQHO0zZvIQ==} + peerDependencies: + '@luma.gl/core': ~9.4.0 + + '@luma.gl/webgl@9.4.2': + resolution: {integrity: sha512-D3GqnxTgQI+vsyH56hX5+jwqdVUhvhbpnPurTwbQOSlSQ8mshhNKcRdrZytTy10qiodDwrcjTnndPEAP6UgCzA==} + peerDependencies: + '@luma.gl/core': ~9.4.0 + + '@luma.gl/webgpu@9.4.2': + resolution: {integrity: sha512-24gDOmLyL81fVHxn+UXajnYN5jVln7XgB9fvobc1Yh3PAtXjlcAkmVTqYRvULVGeEamuqvqPDscAkaK/T+R1iQ==} + peerDependencies: + '@luma.gl/core': ~9.4.0 + '@luma.gl/shadertools': ~9.4.0 + + '@mapbox/tiny-sdf@2.3.0': + resolution: {integrity: sha512-gBvcNDBBB66bgQYvnaJ6Jk+VCaMmVq5+IZR2kWPisT88Z8s0kBQt6hfVi8QgRW8Vpg0UWZzBA4ZSyzHHC+VeRA==} + + '@math.gl/core@4.1.0': + resolution: {integrity: sha512-FrdHBCVG3QdrworwrUSzXIaK+/9OCRLscxI2OUy6sLOHyHgBMyfnEGs99/m3KNvs+95BsnQLWklVfpKfQzfwKA==} + + '@math.gl/polygon@4.1.0': + resolution: {integrity: sha512-YA/9PzaCRHbIP5/0E9uTYrqe+jsYTQoqoDWhf6/b0Ixz8bPZBaGDEafLg3z7ffBomZLacUty9U3TlPjqMtzPjA==} + + '@math.gl/sun@4.1.0': + resolution: {integrity: sha512-i3q6OCBLSZ5wgZVhXg+X7gsjY/TUtuFW/2KBiq/U1ypLso3S4sEykoU/MGjxUv1xiiGtr+v8TeMbO1OBIh/HmA==} + + '@math.gl/types@4.1.0': + resolution: {integrity: sha512-clYZdHcmRvMzVK5fjeDkQlHUzXQSNdZ7s4xOqC3nJPgz4C/TZkUecTo9YS4PruZqtDda/ag4erndP0MIn40dGA==} + + '@math.gl/web-mercator@4.1.0': + resolution: {integrity: sha512-HZo3vO5GCMkXJThxRJ5/QYUYRr3XumfT8CzNNCwoJfinxy5NtKUd7dusNTXn7yJ40UoB8FMIwkVwNlqaiRZZAw==} + + '@probe.gl/env@4.1.2': + resolution: {integrity: sha512-KIcdjrEiEZVIGX9nh7pZSmTMIKrd+wCb09gyXqpYYI4hs9WMqrQHvKZ7KD8ASutf6kwARwgd4WNQn8aucLSz3g==} + + '@probe.gl/log@4.1.2': + resolution: {integrity: sha512-2LqSq4CHhc/HJQasHMPOzA6c7rprlGz8CCREGebo19jxcuKdvXQo0DEmlfId076U6UldMp6jGhWvDHEFLX111Q==} + + '@probe.gl/stats@4.1.2': + resolution: {integrity: sha512-Hqc0UIHd0IZ2+JbovzTz7lYG7CY9D8yCB81zyP92Zl9UDSPcw2cLbTySW14keAQeAo1sjGjUw0+KHxr0Y2h/hA==} + + '@types/geojson@7946.0.16': + resolution: {integrity: sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==} + + '@types/node@25.9.9': + resolution: {integrity: sha512-b4e2xxj/yMeT2hNlD6x7zNFiQK2Dlmkb9CQ6v3/1G2RezKN4YS2lcEv8lzGm1mhs4f2lM4yNAMI/zUDBZBBt7w==} + + '@types/offscreencanvas@2019.7.3': + resolution: {integrity: sha512-ieXiYmgSRXUDeOntE1InxjWyvEelZGP63M+cGuquuRLuIKKT1osnkXjxev9B7d1nXSug5vpunx+gNlbVxMlC9A==} + '@types/trusted-types@2.0.7': resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==} + '@webgpu/types@0.1.74': + resolution: {integrity: sha512-lgiI4hbuLcI9unnm2cL/tvCaQU45dp0xcLWJh5uB/9MBGvIA4F8XIk7nSiBeg+K4xWGYwgZKn80LmERI5CxoTA==} + + apache-arrow@21.2.0: + resolution: {integrity: sha512-Hxe6Agq26gQOM954qpzYSllJBPJl+e16U5CkfuMUhLrNba+5nKkttIVlflaovN6oaTratqMGAO8H5u/aNhmHWQ==} + hasBin: true + clone@2.1.2: resolution: {integrity: sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==} engines: {node: '>=0.8'} + earcut@2.2.4: + resolution: {integrity: sha512-/pjZsA1b4RPHbeWZQn66SWS8nZZWLQQ23oE3Eam7aroEFGEvwKAsJfZ9ytiEMycfzXWpca4FA9QIOehf7PocBQ==} + elkjs@0.3.0: resolution: {integrity: sha512-bcO8RCIssdly316ou76QLsiuu1NCLbhhZwK/iuOdKTyQzKdCeX7sdIJOUdSsjlIDB203TN4NBpTiq4ugmLjR+Q==} + flatbuffers@25.9.23: + resolution: {integrity: sha512-MI1qs7Lo4Syw0EOzUl0xjs2lsoeqFku44KpngfIduHBYvzm8h2+7K8YMQh1JtVVVrUvhLpNwqVi4DERegUJhPQ==} + + gl-matrix@3.4.4: + resolution: {integrity: sha512-latSnyDNt/8zYUB6VIJ6PCh2jBjJX6gnDsoCZ7LyW7GkqrD51EWwa9qCoGixj8YqBtETQK/xY7OmpTF8xz1DdQ==} + golden-layout@2.6.0: resolution: {integrity: sha512-sIVQCiRWOymHbVD1Aw/T9/ijbPYAVGBlgGYd1N9MRKfcyBNSpjr87Vg9nSHm+RCT8ELrvK8IJYJV0QRJuVUkCQ==} - leaflet@1.9.4: - resolution: {integrity: sha512-nxS1ynzJOmOlHp+iL3FyWqK89GtNL8U8rvlMOsQdTTssxZwCXh8N2NB3GDQOL+YR3XnWyZAxwQixURb+FA74PA==} + json-with-bigint@3.5.12: + resolution: {integrity: sha512-uwbF/wSSuOgC7qqlq27Xp5B6a2MHVug3t0idZdTqu0JnlFvgJuH7ju+KAk/J06C7GfhoYy2gnb9wz2INqcne7w==} lit-element@4.2.2: resolution: {integrity: sha512-aFKhNToWxoyhkNDmWZwEva2SlQia+jfG0fjIWV//YeTaWrVnOxD89dPKfigCUspXFmjzOEUQpOkejH5Ly6sG0w==} @@ -70,6 +203,9 @@ packages: lodash@4.18.1: resolution: {integrity: sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==} + mjolnir.js@3.1.1: + resolution: {integrity: sha512-Em3+0p6n2RamaiiDenHByvaWNolr+K0fWsFpgUgUXRssFI59ramCMdp0crU6V75clbA4fDJBVTBXfBF5rlPB9A==} + netlistsvg@1.0.2: resolution: {integrity: sha512-g6E7Q58HLevr+ls7FZTMf1xT3iXXxUVD+s7I4ijGKH+bhaobjnZbzKAi+Ex1AlNWK7fzujz3x4V3xMKOGiWfQw==} hasBin: true @@ -84,23 +220,211 @@ packages: three@0.160.0: resolution: {integrity: sha512-DLU8lc0zNIPkM7rH5/e1Ks1Z8tWCGRq6g8mPowdDJpw1CFBJMU7UoJjC6PefXW7z//SSl0b2+GCw14LB+uDhng==} + tslib@2.8.1: + resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} + + undici-types@7.24.6: + resolution: {integrity: sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==} + snapshots: + '@deck.gl/core@9.4.0(@luma.gl/webgpu@9.4.2(@luma.gl/core@9.4.2)(@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2)))': + dependencies: + '@loaders.gl/core': 4.5.4 + '@loaders.gl/images': 4.5.4(@loaders.gl/core@4.5.4) + '@luma.gl/core': 9.4.2 + '@luma.gl/engine': 9.4.2(@luma.gl/core@9.4.2)(@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2)) + '@luma.gl/gpgpu': 9.4.2(@luma.gl/core@9.4.2)(@luma.gl/engine@9.4.2(@luma.gl/core@9.4.2)(@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2)))(@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2))(@luma.gl/webgpu@9.4.2(@luma.gl/core@9.4.2)(@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2))) + '@luma.gl/shadertools': 9.4.2(@luma.gl/core@9.4.2) + '@luma.gl/webgl': 9.4.2(@luma.gl/core@9.4.2) + '@math.gl/core': 4.1.0 + '@math.gl/sun': 4.1.0 + '@math.gl/types': 4.1.0 + '@math.gl/web-mercator': 4.1.0 + '@probe.gl/env': 4.1.2 + '@probe.gl/log': 4.1.2 + '@probe.gl/stats': 4.1.2 + '@types/offscreencanvas': 2019.7.3 + gl-matrix: 3.4.4 + mjolnir.js: 3.1.1 + transitivePeerDependencies: + - '@luma.gl/webgpu' + + '@deck.gl/extensions@9.4.0(@deck.gl/core@9.4.0(@luma.gl/webgpu@9.4.2(@luma.gl/core@9.4.2)(@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2))))(@luma.gl/core@9.4.2)(@luma.gl/engine@9.4.2(@luma.gl/core@9.4.2)(@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2)))': + dependencies: + '@deck.gl/core': 9.4.0(@luma.gl/webgpu@9.4.2(@luma.gl/core@9.4.2)(@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2))) + '@luma.gl/core': 9.4.2 + '@luma.gl/engine': 9.4.2(@luma.gl/core@9.4.2)(@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2)) + '@luma.gl/shadertools': 9.4.2(@luma.gl/core@9.4.2) + '@luma.gl/webgl': 9.4.2(@luma.gl/core@9.4.2) + '@math.gl/core': 4.1.0 + + '@deck.gl/layers@9.4.0(@deck.gl/core@9.4.0(@luma.gl/webgpu@9.4.2(@luma.gl/core@9.4.2)(@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2))))(@loaders.gl/core@4.5.4)(@luma.gl/core@9.4.2)(@luma.gl/engine@9.4.2(@luma.gl/core@9.4.2)(@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2)))': + dependencies: + '@deck.gl/core': 9.4.0(@luma.gl/webgpu@9.4.2(@luma.gl/core@9.4.2)(@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2))) + '@loaders.gl/core': 4.5.4 + '@loaders.gl/images': 4.5.4(@loaders.gl/core@4.5.4) + '@loaders.gl/schema': 4.5.4 + '@luma.gl/core': 9.4.2 + '@luma.gl/engine': 9.4.2(@luma.gl/core@9.4.2)(@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2)) + '@luma.gl/shadertools': 9.4.2(@luma.gl/core@9.4.2) + '@mapbox/tiny-sdf': 2.3.0 + '@math.gl/core': 4.1.0 + '@math.gl/polygon': 4.1.0 + '@math.gl/web-mercator': 4.1.0 + '@types/geojson': 7946.0.16 + earcut: 2.2.4 + '@lit-labs/ssr-dom-shim@1.6.0': {} '@lit/reactive-element@2.1.2': dependencies: '@lit-labs/ssr-dom-shim': 1.6.0 + '@loaders.gl/core@4.5.4': + dependencies: + '@loaders.gl/loader-utils': 4.5.4(@loaders.gl/core@4.5.4) + '@loaders.gl/schema': 4.5.4 + '@loaders.gl/schema-utils': 4.5.4(@loaders.gl/core@4.5.4) + '@loaders.gl/worker-utils': 4.5.4(@loaders.gl/core@4.5.4) + '@probe.gl/log': 4.1.2 + + '@loaders.gl/images@4.5.4(@loaders.gl/core@4.5.4)': + dependencies: + '@loaders.gl/core': 4.5.4 + '@loaders.gl/loader-utils': 4.5.4(@loaders.gl/core@4.5.4) + + '@loaders.gl/loader-utils@4.5.4(@loaders.gl/core@4.5.4)': + dependencies: + '@loaders.gl/schema': 4.5.4 + '@loaders.gl/worker-utils': 4.5.4(@loaders.gl/core@4.5.4) + '@probe.gl/log': 4.1.2 + '@probe.gl/stats': 4.1.2 + transitivePeerDependencies: + - '@loaders.gl/core' + + '@loaders.gl/schema-utils@4.5.4(@loaders.gl/core@4.5.4)': + dependencies: + '@loaders.gl/core': 4.5.4 + '@loaders.gl/schema': 4.5.4 + '@math.gl/types': 4.1.0 + '@types/geojson': 7946.0.16 + apache-arrow: 21.2.0 + + '@loaders.gl/schema@4.5.4': + dependencies: + '@types/geojson': 7946.0.16 + apache-arrow: 21.2.0 + + '@loaders.gl/worker-utils@4.5.4(@loaders.gl/core@4.5.4)': + dependencies: + '@loaders.gl/core': 4.5.4 + + '@luma.gl/core@9.4.2': + dependencies: + '@math.gl/types': 4.1.0 + '@probe.gl/env': 4.1.2 + '@probe.gl/log': 4.1.2 + '@probe.gl/stats': 4.1.2 + '@types/offscreencanvas': 2019.7.3 + + '@luma.gl/engine@9.4.2(@luma.gl/core@9.4.2)(@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2))': + dependencies: + '@luma.gl/core': 9.4.2 + '@luma.gl/shadertools': 9.4.2(@luma.gl/core@9.4.2) + '@math.gl/core': 4.1.0 + '@math.gl/types': 4.1.0 + '@probe.gl/log': 4.1.2 + '@probe.gl/stats': 4.1.2 + + '@luma.gl/gpgpu@9.4.2(@luma.gl/core@9.4.2)(@luma.gl/engine@9.4.2(@luma.gl/core@9.4.2)(@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2)))(@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2))(@luma.gl/webgpu@9.4.2(@luma.gl/core@9.4.2)(@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2)))': + dependencies: + '@luma.gl/core': 9.4.2 + '@luma.gl/engine': 9.4.2(@luma.gl/core@9.4.2)(@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2)) + '@luma.gl/shadertools': 9.4.2(@luma.gl/core@9.4.2) + '@luma.gl/webgpu': 9.4.2(@luma.gl/core@9.4.2)(@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2)) + '@math.gl/core': 4.1.0 + '@math.gl/types': 4.1.0 + '@probe.gl/log': 4.1.2 + '@probe.gl/stats': 4.1.2 + + '@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2)': + dependencies: + '@luma.gl/core': 9.4.2 + '@math.gl/core': 4.1.0 + '@math.gl/types': 4.1.0 + + '@luma.gl/webgl@9.4.2(@luma.gl/core@9.4.2)': + dependencies: + '@luma.gl/core': 9.4.2 + '@math.gl/types': 4.1.0 + '@probe.gl/env': 4.1.2 + + '@luma.gl/webgpu@9.4.2(@luma.gl/core@9.4.2)(@luma.gl/shadertools@9.4.2(@luma.gl/core@9.4.2))': + dependencies: + '@luma.gl/core': 9.4.2 + '@luma.gl/shadertools': 9.4.2(@luma.gl/core@9.4.2) + '@probe.gl/env': 4.1.2 + '@webgpu/types': 0.1.74 + + '@mapbox/tiny-sdf@2.3.0': {} + + '@math.gl/core@4.1.0': + dependencies: + '@math.gl/types': 4.1.0 + + '@math.gl/polygon@4.1.0': + dependencies: + '@math.gl/core': 4.1.0 + + '@math.gl/sun@4.1.0': {} + + '@math.gl/types@4.1.0': {} + + '@math.gl/web-mercator@4.1.0': + dependencies: + '@math.gl/core': 4.1.0 + + '@probe.gl/env@4.1.2': {} + + '@probe.gl/log@4.1.2': + dependencies: + '@probe.gl/env': 4.1.2 + + '@probe.gl/stats@4.1.2': {} + + '@types/geojson@7946.0.16': {} + + '@types/node@25.9.9': + dependencies: + undici-types: 7.24.6 + + '@types/offscreencanvas@2019.7.3': {} + '@types/trusted-types@2.0.7': {} + '@webgpu/types@0.1.74': {} + + apache-arrow@21.2.0: + dependencies: + '@types/node': 25.9.9 + flatbuffers: 25.9.23 + json-with-bigint: 3.5.12 + tslib: 2.8.1 + clone@2.1.2: {} + earcut@2.2.4: {} + elkjs@0.3.0: {} + flatbuffers@25.9.23: {} + + gl-matrix@3.4.4: {} + golden-layout@2.6.0: {} - leaflet@1.9.4: {} + json-with-bigint@3.5.12: {} lit-element@4.2.2: dependencies: @@ -120,6 +444,8 @@ snapshots: lodash@4.18.1: {} + mjolnir.js@3.1.1: {} + netlistsvg@1.0.2: dependencies: clone: 2.1.2 @@ -134,3 +460,7 @@ snapshots: sax@1.6.1: {} three@0.160.0: {} + + tslib@2.8.1: {} + + undici-types@7.24.6: {} diff --git a/src/web/src/capture.js b/src/web/src/capture.js index 1fc7316064d..b7bb0bc39d9 100644 --- a/src/web/src/capture.js +++ b/src/web/src/capture.js @@ -1,19 +1,13 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright (c) 2026, The OpenROAD Authors -// WYSIWYG layout capture. Composites the currently rendered Leaflet layers -// (base tiles, the highlight/selection overlay, the active heatmap) plus the -// SVG overlays (rulers, selection outline, labels) into a PNG and downloads -// it — mirroring the Qt GUI's "Save image", which saves the displayed scene. -// -// All tiles are same-origin (blob: URLs), so the canvas is not tainted -// and toBlob() works. Tile positions are read from getBoundingClientRect so -// the composite is correct under fractional zoom / CSS transforms. +// WYSIWYG layout capture. Copies the view's canvas (tiles, overlays, +// heatmap, selection, rulers) and the ruler distance labels into a PNG and +// downloads it — mirroring the Qt GUI's "Save image", which saves the +// displayed scene. The PNG is in CSS pixels. // // entire=true first fits the whole design (no animation), waits for every -// layer's tiles to settle, then composites — capturing the full design exactly -// as the window shows it (layers + heatmap + highlights + rulers), and restores -// the previous view afterwards. +// layer's tiles to settle, then captures, and restores the previous view. function downloadBlob(blob, filename) { if (!blob) { @@ -30,108 +24,16 @@ function downloadBlob(blob, filename) { setTimeout(() => URL.revokeObjectURL(url), 0); } -// A layer's effective opacity (default 1 when unset). -function layerOpacity(layer) { - return (layer.options && layer.options.opacity != null) - ? layer.options.opacity : 1; -} - -// Draw one /element at its on-screen position relative to the map. Skips -// an that hasn't decoded yet, and swallows a not-yet-drawable element. -function drawElementAt(ctx, el, mapRect) { - if (!el) { - return; - } - if (el.tagName === 'IMG' && (!el.complete || !el.naturalWidth)) { - return; // still loading - } - const r = el.getBoundingClientRect(); - if (r.width <= 0 || r.height <= 0) { - return; - } - try { - ctx.drawImage(el, r.left - mapRect.left, r.top - mapRect.top, - r.width, r.height); - } catch (err) { - // Skip an element that can't be drawn yet. - } -} - -// Draw every loaded GridLayer tile onto ctx, in z-index order, at its -// on-screen position relative to the map container. -function drawGridLayers(app, ctx, mapRect) { - const layers = []; - app.map.eachLayer((layer) => { - if (layer instanceof L.GridLayer && layer._tiles) { - layers.push(layer); - } - }); - layers.sort((a, b) => - ((a.options && a.options.zIndex) || 0) - - ((b.options && b.options.zIndex) || 0)); - - for (const layer of layers) { - const opacity = layerOpacity(layer); - if (opacity <= 0) { - continue; - } - ctx.globalAlpha = opacity; - for (const key of Object.keys(layer._tiles)) { - const t = layer._tiles[key]; - if (!t || !t.current) { - continue; - } - drawElementAt(ctx, t.el, mapRect); - } - } - ctx.globalAlpha = 1; -} - -// Rasterize the SVG overlay panes (rulers, selection outline, labels) on top. -// Async: each SVG is drawn through an data URL. -function drawSvgOverlays(app, ctx, mapRect) { - const svgs = app.map.getContainer().querySelectorAll('.leaflet-pane svg'); - const jobs = []; - svgs.forEach((svg) => { - const r = svg.getBoundingClientRect(); - if (r.width <= 0 || r.height <= 0) { - return; - } - const clone = svg.cloneNode(true); - clone.setAttribute('width', r.width); - clone.setAttribute('height', r.height); - const xml = new XMLSerializer().serializeToString(clone); - const url = 'data:image/svg+xml;charset=utf-8,' - + encodeURIComponent(xml); - jobs.push(new Promise((resolve) => { - const img = new Image(); - img.onload = () => { - try { - ctx.drawImage(img, r.left - mapRect.left, - r.top - mapRect.top, r.width, r.height); - } catch (err) { /* ignore */ } - resolve(); - }; - img.onerror = () => resolve(); - img.src = url; - })); - }); - return Promise.all(jobs); -} - -// Rasterize the HTML marker labels — the ruler distance readouts, which are -// L.divIcon
s in a marker pane rather than SVG, so drawSvgOverlays cannot -// see them. Without this the capture keeps a ruler's line and ticks but drops -// the measurement the ruler exists to show. +// Rasterize the ruler distance labels, which are DOM markers over the canvas. // // Painted directly onto the canvas rather than serialized through an -// data URL like the SVG panes: a detached document does not inherit the app's -// stylesheet, so a foreignObject copy of the label would come out unstyled -// (no background, default font). Reading the computed style and drawing the -// box and text keeps it looking like what is on screen. +// data URL: a detached document does not inherit the app's stylesheet, so a +// foreignObject copy of the label would come out unstyled (no background, +// default font). Reading the computed style and drawing the box and text +// keeps it looking like what is on screen. function drawHtmlLabels(app, ctx, mapRect) { - const labels = app.map.getContainer() - .querySelectorAll('.leaflet-pane .ruler-label'); + const labels = app.view.getContainer() + .querySelectorAll('.or-view-markers .ruler-label'); labels.forEach((el) => { const r = el.getBoundingClientRect(); if (r.width <= 0 || r.height <= 0) { @@ -167,75 +69,8 @@ function drawHtmlLabels(app, ctx, mapRect) { }); } -// Count tiles that haven't finished loading across every GridLayer (base, -// overlay/highlights, heatmap, ...): a layer still marked _loading, or a -// current tile whose hasn't decoded yet. Zero => the scene is painted. -function tilesPending(app) { - let pending = 0; - app.map.eachLayer((layer) => { - if (!(layer instanceof L.GridLayer) || !layer._tiles) { - return; - } - if (layer._loading) { - pending++; - } - for (const key of Object.keys(layer._tiles)) { - const t = layer._tiles[key]; - const el = t && t.el; - if (t && t.current && el && el.tagName === 'IMG' - && (!el.complete || !el.naturalWidth)) { - pending++; - } - } - }); - return pending; -} - -// Resolve once all layers' tiles have settled (stable across a couple of polls) -// or a timeout elapses. Used after a fit so the capture waits for the newly -// requested tiles (base + overlay + heatmap) to arrive. -function whenTilesSettled(app, timeoutMs = 6000, intervalMs = 32) { - return new Promise((resolve) => { - const deadline = Date.now() + timeoutMs; - let stable = 0; - const check = () => { - if (tilesPending(app) === 0) { - if (++stable >= 2) { - resolve(); - return; - } - } else { - stable = 0; - } - if (Date.now() >= deadline) { - resolve(); - return; - } - setTimeout(check, intervalMs); - }; - setTimeout(check, intervalMs); - }); -} - -// Draw single-image overlays (e.g. the timing-path L.ImageOverlay) at their -// on-screen position, so they land in the capture like the tile layers. -function drawImageOverlays(app, ctx, mapRect) { - app.map.eachLayer((layer) => { - if (!(layer instanceof L.ImageOverlay)) { - return; - } - const opacity = layerOpacity(layer); - if (opacity <= 0) { - return; - } - ctx.globalAlpha = opacity; - drawElementAt(ctx, layer._image, mapRect); - ctx.globalAlpha = 1; - }); -} - async function renderToBlob(app) { - const container = app.map.getContainer(); + const container = app.view.getContainer(); const mapRect = container.getBoundingClientRect(); const w = Math.max(1, Math.round(mapRect.width)); const h = Math.max(1, Math.round(mapRect.height)); @@ -250,36 +85,43 @@ async function renderToBlob(app) { ctx.fillStyle = (bg && bg !== 'transparent' && bg !== 'rgba(0, 0, 0, 0)') ? bg : '#000'; ctx.fillRect(0, 0, w, h); - drawGridLayers(app, ctx, mapRect); - drawImageOverlays(app, ctx, mapRect); - await drawSvgOverlays(app, ctx, mapRect); + const scene = await app.view.captureCanvas(); + if (scene) { + const r = scene.rect; + try { + ctx.drawImage(scene.image, r.left - mapRect.left, + r.top - mapRect.top, r.width, r.height); + } catch (err) { + // A canvas that cannot be drawn yet leaves the background only. + } + } // Last, so the labels sit above the ruler lines they annotate. drawHtmlLabels(app, ctx, mapRect); return new Promise((resolve) => canvas.toBlob(resolve, 'image/png')); } -// Public entry point. entire=false composites the current viewport; +// Public entry point. entire=false captures the current viewport; // entire=true fits the whole design first, waits for the newly requested tiles // to settle, captures, then restores the previous view. Both are WYSIWYG: // base layers + heatmap + highlights/selection + rulers, exactly as shown. export async function captureLayout(app, { entire = false } = {}) { - if (!app.map) { + if (!app.view) { return; } // Entire needs whole-design bounds; without them the capture would just be // the current viewport, so save it (honestly) as the visible layout. - if (!entire || !app.fitBounds) { + if (!entire || !app.fitRect) { downloadBlob(await renderToBlob(app), 'layout_visible.png'); return; } - const prevCenter = app.map.getCenter(); - const prevZoom = app.map.getZoom(); + const prevCenter = app.view.getCenter(); + const prevZoom = app.view.getZoom(); try { - app.map.fitBounds(app.fitBounds, { animate: false }); - await whenTilesSettled(app); + app.view.fitWorldRect(app.fitRect, { animate: false }); + await app.view.whenTilesSettled(); downloadBlob(await renderToBlob(app), 'layout_entire.png'); } finally { - app.map.setView(prevCenter, prevZoom, { animate: false }); + app.view.setView(prevCenter, prevZoom, { animate: false }); } } diff --git a/src/web/src/color.h b/src/web/src/color.h index fa498f1a4e2..344a2eeb641 100644 --- a/src/web/src/color.h +++ b/src/web/src/color.h @@ -3,6 +3,8 @@ #pragma once +#include + namespace web { struct Color @@ -32,6 +34,15 @@ enum class FillPattern kDots = 4, // dotted }; +// A pattern as sent on the wire; anything out of range is solid. +inline constexpr FillPattern toFillPattern(const int64_t value) +{ + return (value >= static_cast(FillPattern::kNone) + && value <= static_cast(FillPattern::kDots)) + ? static_cast(value) + : FillPattern::kSolid; +} + // Selection-highlight yellow shared by the tile highlight border // (TileGenerator::drawHighlight) and the selection flywires // (request_handler's collectNetFlightLines). diff --git a/src/web/src/context-menu.js b/src/web/src/context-menu.js index 130d1e94dde..b0522788d15 100644 --- a/src/web/src/context-menu.js +++ b/src/web/src/context-menu.js @@ -73,9 +73,9 @@ export class ContextMenu { } }); - // Hide the menu when the map moves. - if (this._app.map) { - this._app.map.on('movestart', () => this.hide()); + // Hide the menu when the view moves. + if (this._app.view) { + this._app.view.on('movestart', () => this.hide()); } } @@ -134,9 +134,9 @@ export class ContextMenu { const maxLeft = window.innerWidth - rect.width - margin; const maxTop = window.innerHeight - rect.height - margin; const left = Math.max(margin, - Math.min(e.originalEvent.clientX, maxLeft)); + Math.min(e.clientX, maxLeft)); const top = Math.max(margin, - Math.min(e.originalEvent.clientY, maxTop)); + Math.min(e.clientY, maxTop)); this._el.style.left = left + 'px'; this._el.style.top = top + 'px'; } @@ -259,10 +259,7 @@ export class ContextMenu { if (action === 'clear_selections' || action === 'clear_all') { app.updateInspector?.(null); app.stopSelectionAnimation?.(); - if (app.highlightRect && app.map) { - app.map.removeLayer(app.highlightRect); - app.highlightRect = null; - } + app.clearSelectionOutline?.(); app.lastSelectionBounds = null; } else { // Selection count/index and the highlight-group badge changed. diff --git a/src/web/src/coordinates.js b/src/web/src/coordinates.js index 61fdcc6b927..f702601d4e0 100644 --- a/src/web/src/coordinates.js +++ b/src/web/src/coordinates.js @@ -1,32 +1,27 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright (c) 2026, The OpenROAD Authors -// DBU <-> Leaflet coordinate conversion. -// -// The tile renderer uses two Y-flips (tile index + pixel row), so the -// correct mapping is: -// lat = (dbu_y - originY - maxDXDY) * scale -// lng = (dbu_x - originX) * scale +// DBU <-> layout-view world coordinates: world = (dbu - origin) * scale, y up, +// so the tile grid is the square [0, tileSize] on both axes. // // `scale` = tileSize / max(designWidth, designHeight) (pixels-per-DBU) -// `maxDXDY` = max(designWidth, designHeight) in DBU // `originX` = bounds.xMin() in DBU (tile grid origin) // `originY` = bounds.yMin() in DBU (tile grid origin) -export function dbuToLatLng(dbuX, dbuY, scale, maxDXDY, originX = 0, originY = 0) { - return [(dbuY - originY - maxDXDY) * scale, (dbuX - originX) * scale]; -} - -export function dbuRectToBounds(x1, y1, x2, y2, scale, maxDXDY, originX = 0, originY = 0) { - return [ - [(y1 - originY - maxDXDY) * scale, (x1 - originX) * scale], - [(y2 - originY - maxDXDY) * scale, (x2 - originX) * scale], - ]; +export function dbuToWorld(dbuX, dbuY, scale, originX = 0, originY = 0) { + return [(dbuX - originX) * scale, (dbuY - originY) * scale]; } -export function latLngToDbu(lat, lng, scale, maxDXDY, originX = 0, originY = 0) { +export function worldToDbu(wx, wy, scale, originX = 0, originY = 0) { return { - dbuX: Math.round(originX + lng / scale), - dbuY: Math.round(originY + maxDXDY + lat / scale), + dbuX: Math.round(originX + wx / scale), + dbuY: Math.round(originY + wy / scale), }; } + +// World rect [minX, minY, maxX, maxY] of a DBU rect given by two corners. +export function dbuRectToWorldRect(x1, y1, x2, y2, scale, originX = 0, originY = 0) { + const [ax, ay] = dbuToWorld(x1, y1, scale, originX, originY); + const [bx, by] = dbuToWorld(x2, y2, scale, originX, originY); + return [Math.min(ax, bx), Math.min(ay, by), Math.max(ax, bx), Math.max(ay, by)]; +} diff --git a/src/web/src/deck-global.js b/src/web/src/deck-global.js new file mode 100644 index 00000000000..5a73e078e72 --- /dev/null +++ b/src/web/src/deck-global.js @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: BSD-3-Clause +// Copyright (c) 2026, The OpenROAD Authors + +// The parts of deck.gl the layout view draws with, handed over as window.deck; +// the entries import this module first. layout-view.js reads the global, so +// its unit tests can hand it a stand-in instead. + +import { Deck, OrthographicView } from '@deck.gl/core'; +import { PathStyleExtension } from '@deck.gl/extensions'; +import { BitmapLayer, PathLayer, ScatterplotLayer, SolidPolygonLayer } + from '@deck.gl/layers'; + +window.deck = { + BitmapLayer, + Deck, + OrthographicView, + PathLayer, + PathStyleExtension, + ScatterplotLayer, + SolidPolygonLayer, +}; diff --git a/src/web/src/device-pixels.js b/src/web/src/device-pixels.js deleted file mode 100644 index 7ebe546b845..00000000000 --- a/src/web/src/device-pixels.js +++ /dev/null @@ -1,185 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// Copyright (c) 2026, The OpenROAD Authors - -// Keep the tile grid on whole device pixels. -// -// Leaflet lays everything out in whole CSS pixels: Map._getNewPixelOrigin and -// GridLayer._setZoomTransform both .round() their offsets. A whole CSS pixel is -// NOT a whole device pixel unless devicePixelRatio is an integer — at dpr 1.25 -// an odd CSS offset lands on a quarter of a pixel — so a tile's box gets its -// edges resampled into the device grid. Two neighbouring tiles then each paint -// partial coverage into the same device pixel column, and src-over compositing -// of two partial alphas does not add up to one: the pane background shows -// through. That is the dark hairline along every tile boundary. It explains why -// the seams come and go as you pan (at dpr 1.25 one offset in four is already -// exact) and why they reproduce on both the merged-canvas and the legacy -// path — this is the browser's layout, not anything either path draws. -// -// Overlapping the tiles instead would be worse: routing-layer pixels are -// semi-transparent, so an overlapping strip blends twice and a dark seam becomes -// a bright one. They have to abut exactly, which is what landing on the grid -// gives. -// -// Why this measures the DOM rather than patching Leaflet: leaflet-src.js keeps -// setTransform/setPosition as closure-local functions and only publishes -// references to them on L.DomUtil (`exports.DomUtil = DomUtil`, at the end of -// the bundle). GridLayer._setZoomTransform and the map's pan call the closure -// originals, so assigning to L.DomUtil.setTransform patches nothing that -// Leaflet itself goes through. The placement can be corrected, not intercepted. -// -// So: read where Leaflet actually put the tile container — .leaflet-tile-container, -// the element it transforms — and put the compensating offset on that container's -// parent, .leaflet-layer, which Leaflet only ever writes a z-index to. Neither -// side overwrites the other, and the correction survives every update Leaflet -// makes to the child. -// -// This removes the shared PHASE. The other half is the PITCH: tiles must also be -// a whole number of device pixels apart, or only every 1/frac-th boundary can be -// on the grid whatever the phase is — see TILE_SIZE_CSS in tile-request.js, -// which is why the tile size is 240 rather than 256. - -import { nativeDpr } from './tile-request.js'; - -// The element Leaflet positions, and the parent it leaves alone. -const TILE_CONTAINER = '.leaflet-tile-container'; -// What actually has to land on the grid. -const TILE = '.leaflet-tile'; - -// CSS pixels to subtract from `css_pos` to land it on a device pixel. Signed, -// and always less than half a device pixel. -export function deviceResidualCss(css_pos, dpr) { - if (!Number.isFinite(css_pos) || !(dpr > 0)) { - return 0; - } - const device = css_pos * dpr; - return (device - Math.round(device)) / dpr; -} - -// Correct one tile container by offsetting its parent. -// -// Measured on a TILE, not on the container. Leaflet's _getTilePos puts a tile at -// `coords*tileSize - level.origin`, and level.origin is an arbitrary rounded -// integer rather than a multiple of the tile size — so the container can sit -// exactly on the device grid while every tile inside it is a quarter pixel off. -// A tile's rect carries the whole chain: map pane, container transform, this -// correction, and that origin term. -// -// One tile per container is enough: tiles differ from each other by whole -// multiples of the tile size, and that size is chosen to be a whole number of -// device pixels at every real ratio (TILE_SIZE_CSS in tile-request.js). -// -// The measured rect already includes whatever correction is on the parent now, -// so the new correction is the old one minus what is still left over, with any -// whole device pixels dropped. That converges in one step. The dropping is what -// keeps it from drifting: a whole device pixel is never part of a correction -- -// the grid is the same one pixel further on -- but once one got in, every later -// step found the tiles on the grid and left it there, so a layer could wander -// off its neighbours by several pixels and stay. -// -// `rectOf` is injected so this is testable without a layout engine, and -// defaults to the real measurement for every other caller. -export function snapContainerToDeviceGrid(container, dpr, - rectOf = defaultRectOf) { - const holder = container && container.parentElement; - if (!holder) { - return null; - } - // An empty container has no seams to fix, and nothing to measure: a level - // gets its tiles during the same move/zoom that creates it, so the next - // event corrects it. - const tile = typeof container.querySelector === 'function' - ? container.querySelector(TILE) - : null; - if (!tile) { - return null; - } - const rect = rectOf(tile); - const dx = withinOneDevicePixel( - (holder._orSnapDx || 0) - deviceResidualCss(rect.left, dpr), dpr); - const dy = withinOneDevicePixel( - (holder._orSnapDy || 0) - deviceResidualCss(rect.top, dpr), dpr); - holder._orSnapDx = dx; - holder._orSnapDy = dy; - // Written on the PARENT: the container's own transform belongs to Leaflet, - // which rewrites it on every pan and zoom. - holder.style.transform - = (dx || dy) ? `translate3d(${dx}px, ${dy}px, 0)` : ''; - return { dx, dy }; -} - -// Correct every tile container under the map's tile pane. -// -// Rects are read for all of them before any style is written: interleaving -// reads and writes would force a layout flush per container, and this runs on -// every frame of a drag. -export function snapTileContainers(map, dpr, rectOf = defaultRectOf) { - // At an integer ratio a whole CSS pixel IS a whole device pixel, so every - // residual is zero and there is nothing to correct — skip the measuring - // entirely rather than pay for it on every move. - if (!map || typeof map.getPane !== 'function' || !(dpr > 0) - || Number.isInteger(dpr)) { - return 0; - } - const pane = map.getPane('tilePane'); - if (!pane || typeof pane.querySelectorAll !== 'function') { - return 0; - } - let snapped = 0; - // Read every rect before writing any style: interleaving them forces a - // layout flush per container, and this runs on every frame of a drag. - // - // Only the level at rest: a layer keeps one container per zoom level that - // Leaflet has not pruned yet, and they all share the .leaflet-layer the - // correction goes on. Snapping each of them into it made the levels take - // turns, leaving the one on screen off the grid on every other pass. - const measured = [...pane.querySelectorAll(TILE_CONTAINER)] - .filter(isLevelAtRest) - .map((container) => { - const tile = container.querySelector(TILE); - return { container, rect: tile ? rectOf(tile) : null }; - }); - for (const { container, rect } of measured) { - if (rect && snapContainerToDeviceGrid(container, dpr, () => rect)) { - snapped++; - } - } - return snapped; -} - -function defaultRectOf(el) { - return el.getBoundingClientRect(); -} - -// `css` less the whole device pixels in it, leaving less than half a device -// pixel either way. A value already that small comes back bit for bit, so a -// correction that has converged is written out unchanged. -function withinOneDevicePixel(css, dpr) { - return css - Math.round(css * dpr) / dpr; -} - -// Whether `container` is the zoom level Leaflet shows at rest. Leaflet writes -// `translate3d(...) scale(s)` on every level, and s is 1 only for the current -// one; the levels it is zooming away from, and every level mid-animation, are -// scaled. A container with no scale written yet counts as at rest. -function isLevelAtRest(container) { - const transform = (container.style && container.style.transform) || ''; - const scale = /scale\(([^)]*)\)/.exec(transform); - return !scale || Number(scale[1]) === 1; -} - -// Re-snap whenever Leaflet has moved the tiles. -// -// `zoomend` rather than `zoom`: during the zoom animation the container carries -// a CSS transition and a scale, and correcting mid-flight would fight it for no -// benefit — the frames are in motion and a quarter pixel is invisible there. -const SNAP_EVENTS = 'move zoomend viewreset resize load'; - -export function installDeviceGridSnapping(map, dprOf = nativeDpr) { - if (!map || typeof map.on !== 'function') { - return false; - } - const snap = () => snapTileContainers(map, dprOf()); - map.on(SNAP_EVENTS, snap); - snap(); - return true; -} diff --git a/src/web/src/display-controls.js b/src/web/src/display-controls.js index 3bb9682e619..2535b9f86b5 100644 --- a/src/web/src/display-controls.js +++ b/src/web/src/display-controls.js @@ -12,6 +12,10 @@ import { getCookie, setCookie, setBackgroundColor, resetBackgroundColor, import { isStaticMode, makeGroupHeader, attachGroupCollapse, beginSelection, isCurrentSelection, onSelectionReset, isValidHexColor } from './ui-utils.js'; +import { setItemVisible } from './tile-merge.js'; +import { nativeDpr, tileSizeCss } from './tile-request.js'; +import { DEFAULT_GROUP_LAYERS, createCompositeSource } from './tile-sources.js'; +import { DRAW_ORDER } from './layout-view.js'; // Compute a Set of layer indices around `center` within [0, count). // `lower` layers below and `upper` layers above are included. @@ -66,6 +70,10 @@ export function buildChipletFlatNodes(chipletData, savedHidden) { }); } +// The server's paint order puts the routing layers from here up +// (TileGenerator::saveImageLayerOrder); an overlay below it goes under them. +const kTechLayerZBase = 3; + // Fallback color used when the server didn't supply a layer color. const fallbackLayerPalette = [ [70, 130, 210], // moderate blue @@ -78,141 +86,115 @@ const fallbackLayerPalette = [ [180, 70, 150], // magenta ]; -import { - computeGroupCount, estimateTilesPerPane, measureViewport, - partitionIntoGroups, reserveForUnmergedPanes, setItemVisible, tileBytes, - DEFAULT_BUDGET_BYTES, UNMERGED_PANE_COUNT, -} from './tile-merge.js'; -import { buildMergedPanes } from './merged-tile-layer.js'; -import { tileSizeCss } from './tile-request.js'; +// Layers per server-composited group (tile_group), or 0 to fetch each layer: +// groups only with ?composite=1, and a saved report has per-layer tiles only. +export function serverGroupLayers(app) { + if (!app.forceComposite || isStaticMode(app)) { + return 0; + } + return app.groupLayers || DEFAULT_GROUP_LAYERS; +} // Populate display controls with layer checkboxes and visibility tree. export function populateDisplayControls(app, visibility, selectability, - WebSocketTileLayer, techData, redrawAllLayers, - HeatMapTileLayer) { + createHeatMapSlot) { if (!app.displayControlsEl) return; app.displayControlsEl.innerHTML = ''; - app.allLayers = []; // Column header (visibility / selectability icons), mirroring the Qt GUI's // QHeaderView. Added first so it is the panel's sticky top row. app.displayControlsEl.appendChild(makeColumnHeader()); - // ─── Tile grouping ─────────────────────────────────────────────────── + // ─── Tile slots ────────────────────────────────────────────────────── // - // Two modes. Legacy: one Leaflet pane per tech layer per chiplet, which on - // a multi-die design is ~97 panes holding ~582 MB of decoded tile images — - // past the browser's ~458 MB ceiling, where it starts discarding decodes and - // the discarded regions paint white. Merged: - // the routing layers are composited into N canvas panes, N chosen from a - // memory budget, so the total is bounded no matter how many layers or - // chiplets the design has. - // - // Only the routing layers are merged. The pseudo layers (_instances, - // _pins, _modules and the Misc overlays below) stay as their own panes: - // there is a fixed handful of them, they carry no meaningful memory, and - // they have their own add/remove rules driven by the Shapes, Module-view - // and Misc toggles which are not worth folding into the draw list. - const mergedLayerClass = app.mergeTiles ? app.MergedTileLayer : null; - // Panes whose draw list changed during one tree update, refreshed once at - // the end rather than per layer — a group toggle walks every node, and - // refreshing per node would re-request the same pane dozens of times. - const dirtyPanes = new Set(); - - function flushDirtyPanes() { - for (const pane of dirtyPanes) { - pane.refreshTiles(); + // Every layout layer is composited, in z-order, into one image per tile. + // The view draws one tile layer per tile per slot and each costs CPU on + // every frame, so one composite for the layout, plus one for the few + // layers that sit above the highlight overlay, keeps that bounded. A + // toggle flips its entry's `visible` and refreshes the slot once. + for (const slot of app.allLayers || []) { + slot.remove(); + } + app.allLayers = []; + app.baseSlot = null; + app.topSlot = null; + const dirtySlots = new Set(); + + function flushDirtySlots() { + for (const slot of dirtySlots) { + slot.refresh(); + } + dirtySlots.clear(); + } + + function markBaseDirty() { + if (app.baseSlot) { + dirtySlots.add(app.baseSlot); } - dirtyPanes.clear(); } - // A routing layer, as the tree sees it. In legacy mode this IS the Leaflet - // layer; in merged mode it is an adapter over one entry of a pane's draw - // list, exposing the same three things the tree uses. + // A routing layer: its entry in the base slot's draw list. // - // Routing layers are drawn at full pane opacity. The layer transparency is + // Routing layers are drawn at full opacity. The layer transparency is // already baked into the tile: the server paints layer shapes with the // palette alpha of 180/255 (tile_generator.cpp buildLayerColorMap), the same - // alpha displayControls.cpp gives the Qt GUI's brush. Dimming the pane on + // alpha displayControls.cpp gives the Qt GUI's brush. Dimming the layer on // top of that would apply the transparency a second time and render the // layout darker than the Qt GUI. - function makeRoutingLayer(name, zIndex) { - if (!mergedLayerClass) { - const layer = new WebSocketTileLayer(app.websocketManager, name, { - opacity: 1, - zIndex, - }); - layer._orShow = () => layer.addTo(app.map); - layer._orHide = () => app.map.removeLayer(layer); - return layer; + function makeRoutingLayer(name) { + return { layer: name, opacity: 1, visible: false }; + } + + // Only a real change dirties the slot: the tree's onChange re-asserts the + // state of every node, not just the one toggled. + function setRoutingVisible(item, visible) { + if (setItemVisible(item, visible)) { + markBaseDirty(); } - const item = { layer: name, opacity: 1, visible: false }; - return { - _orItem: item, - _orPane: null, - refreshTiles() { - if (this._orPane) { - dirtyPanes.add(this._orPane); - flushDirtyPanes(); - } - }, - // setItemVisible reports whether the state actually changed, and - // only a real change dirties the pane. The tree's onChange walks - // EVERY node and asserts the desired state on each, so dirtying - // unconditionally made one checkbox re-request every tile in every - // pane. - _orShow() { - if (setItemVisible(item, true) && this._orPane) { - dirtyPanes.add(this._orPane); - } - }, - _orHide() { - if (setItemVisible(item, false) && this._orPane) { - dirtyPanes.add(this._orPane); - } - }, - }; } - // Create a pseudo-layer tile layer and register it on the app. - // `appProp` names the app. slot (null = anonymous); `addToMap` - // attaches it immediately (layers whose toggle is default-ON). - function addPseudoLayer(name, appProp, zIndex, addToMap) { - const layer = new WebSocketTileLayer(app.websocketManager, name, { - zIndex, - }); - if (addToMap) layer.addTo(app.map); - if (appProp) app[appProp] = layer; - app.allLayers.push(layer); - return layer; + // A pseudo layer: a draw-list entry whose visibility redrawAllLayers sets + // from `visibility`. `appProp` names the app. it is published as. + // The initial state must follow `visibility`, which was already restored + // from the or_visibility cookie, or the checkbox and the view disagree + // until the first toggle. + function pseudoItem(name, appProp, visible) { + const item = { layer: name, opacity: 1, visible: !!visible }; + if (appProp) { + app[appProp] = item; + } + return item; } - // The initial attach state must follow `visibility`, which was already - // restored from the or_visibility cookie: a hardcoded attach leaves the - // checkbox (rendered from `visibility`) out of sync with the map until - // the first toggle runs redrawAllLayers. - - // Instance borders layer (always below routing layers; no toggle) - addPseudoLayer('_instances', null, 0, true); - // IO pin markers layer (between instances and routing layers) - addPseudoLayer('_pins', 'pinsLayer', 1, visibility.pins); - // Module coloring overlay (Module view) - addPseudoLayer('_modules', 'modulesLayer', 2, visibility.module_view); + // Under the routing layers: instance borders (no toggle), IO pins and + // module colouring. + const underItems = [ + pseudoItem('_instances', null, true), + pseudoItem('_pins', 'pinsLayer', visibility.pins), + pseudoItem('_modules', 'modulesLayer', visibility.module_view), + ]; // The self-painting overlays (access points, regions, grids, instance and - // pin names), as the server lists them: name, pane order and when each + // pin names), as the server lists them: name, paint order and when each // shows. It leaves out those the design gives nothing to draw, such as - // regions in a design without any. + // regions in a design without any. Those the server orders below the + // routing layers (the manufacturing grid) go under them; the rest go over + // the highlight overlay and the heat map, in the GUI paint order. + const topItems = []; app.overlayLayers = ((techData && techData.overlays) || []).map((def) => ({ def, - layer: addPseudoLayer(def.name, null, def.z_index, - anyGroupOn(def.shown_by, visibility)), + layer: pseudoItem(def.name, null, anyGroupOn(def.shown_by, visibility)), + under: def.z_index < kTechLayerZBase, })); + for (const { layer, under } of [...app.overlayLayers].sort( + (a, b) => a.def.z_index - b.def.z_index)) { + (under ? underItems : topItems).push(layer); + } // --- Layers group (using CheckboxTreeModel) --- - // Create Leaflet layers and build a model spec. - const leafletLayers = []; // index → WebSocketTileLayer + // Routing layers, in slot (z) order, and the model spec. + const routingLayers = []; // index → draw-list entry const layerIds = []; // index → model node id // Forward declaration so the layerModel callback can mirror chiplet @@ -257,17 +239,16 @@ export function populateDisplayControls(app, visibility, selectability, } catch (_) { /* ignore */ } } - // Apply a fill pattern to one layer and re-render just that layer's tiles. - function setLayerPattern(name, layer, value) { + // Apply a fill pattern to one layer and refresh the slot that draws it. + function setLayerPattern(name, value) { if (value === 1) { delete app.layerPatterns[name]; } else { app.layerPatterns[name] = value; } persistLayerPatterns(); - if (layer && typeof layer.refreshTiles === 'function') { - layer.refreshTiles(); - } + markBaseDirty(); + flushDirtySlots(); } // Fill-pattern choices for the layer context menu (values match the @@ -285,11 +266,6 @@ export function populateDisplayControls(app, visibility, selectability, // the tech's own layer order, so a flipped chiplet keeps the colors an // upright one would get. let nextLayerSlot = 0; - // Draw order, which is what a flip reverses: the stack of a face-down - // chiplet reaches the viewer backside-first. Kept apart from the palette - // slot so reversing the stack cannot recolor it. Starts at 3, above the - // _instances/_pins/_modules pseudo-layers. - let nextZIndex = 3; // `ownerPath` is the chiplet whose dbTech owns the layers rendered at this // level. Category nodes (Backside/Implant/Other) are pure UI folders with @@ -349,25 +325,17 @@ export function populateDisplayControls(app, visibility, selectability, const layerObj = layers[idx]; const name = layerObj.name || layerObj; const slot = paletteBase + idx; - const zIndex = nextZIndex++; - const layer = makeRoutingLayer(name, zIndex); + const layer = makeRoutingLayer(name); const id = `${parentId}/${name}`; - layer._nodeId = id; const visible = !savedHiddenLayers.has(id); if (visible) { - layer._orShow(); + setRoutingVisible(layer, true); app.visibleLayers.add(id); app.visibleLayerNames.add(name); } - // In merged mode the panes go into allLayers instead, once the - // grouping is known — a draw-list entry is not something - // redrawAllLayers() can refresh. - if (!mergedLayerClass) { - app.allLayers.push(layer); - } - leafletLayers.push(layer); + routingLayers.push(layer); layerIds.push(id); children.push({ @@ -387,8 +355,7 @@ export function populateDisplayControls(app, visibility, selectability, // node's own layers. Flipped: this die's own content turns over, so // its layers come first and the category folders land on top of them. // Child chiplets keep the backend's world-z order either way. The - // visit order IS the draw order — nextZIndex and leafletLayers (the - // merged-pane draw list) both advance with it. + // visit order IS the draw order: the base slot draws its items in it. emitNodes(childChiplets, /*reversed=*/false); if (flipped) { emitLayers(); @@ -429,21 +396,17 @@ export function populateDisplayControls(app, visibility, selectability, layerSpec = { id: 'layers_parent', children: techData.layers.map((name, index) => { - const layer = makeRoutingLayer(name, index + 3); + const layer = makeRoutingLayer(name); const id = `layers_parent/${name}`; - layer._nodeId = id; const visible = !savedHiddenLayers.has(id); if (visible) { - layer._orShow(); + setRoutingVisible(layer, true); app.visibleLayers.add(id); app.visibleLayerNames.add(name); } - if (!mergedLayerClass) { - app.allLayers.push(layer); - } - leafletLayers.push(layer); + routingLayers.push(layer); layerIds.push(id); return { id, data: { name, layer, colorIndex: index, nodeId: id }, checked: visible }; @@ -451,124 +414,29 @@ export function populateDisplayControls(app, visibility, selectability, }; } - // ─── Build the merged panes ────────────────────────────────────────── - // - // leafletLayers is in slot order, which IS the z-order, so it can be - // partitioned directly. Runs must be contiguous: each group becomes one - // image, and interleaved groups have no stacking that reproduces the - // original (see partitionIntoGroups). - if (mergedLayerClass && leafletLayers.length > 0) { - const items = leafletLayers.map(l => l._orItem); - const budget = app.tileBudgetBytes || DEFAULT_BUDGET_BYTES; - - // How many groups fit right now. measureViewport falls back to the - // window when the container has not been laid out yet: a 0x0 container - // yields 1 tile per pane, which makes the budget look big enough for - // one pane per layer and silently disables the merging entirely. - function wantedGroupCount() { - const { width, height } = measureViewport(app.map.getContainer()); - // Both from the size the layers actually use: the tile count and - // the bytes per tile move in opposite directions with it, and - // reading it on one side only would leave the product wrong. - const tile = tileSizeCss(); - const tilesPerPane = estimateTilesPerPane(width, height, tile); - const perTile = tileBytes(tile, app.tileDpr ? app.tileDpr() : 1); - // The panes that are NOT merged still hold full tile grids, and - // they are not free: at dpr 3 each costs ~54 MB, so the four of - // them would put the real total over the ceiling while the budget - // reported it as fitting. Charge them first. - const count = app.mergeGroupCount || computeGroupCount({ - budgetBytes: reserveForUnmergedPanes(budget, tilesPerPane, - perTile), - tilesPerPane, - bytesPerTile: perTile, - paneCount: items.length, - }); - return { count, tilesPerPane, perTile }; - } - - function describe(paneCount, tilesPerPane, perTile) { - // estimatedMB counts the unmerged panes too, so the reported figure - // is the whole viewer's tile memory rather than just the part this - // grouping controls. - const total = (paneCount + UNMERGED_PANE_COUNT) * tilesPerPane - * perTile; - return { - layers: items.length, - groups: paneCount, - tilesPerPane, - unmergedPanes: UNMERGED_PANE_COUNT, - budgetMB: Math.round(budget / (1024 * 1024)), - estimatedMB: Math.round(total / (1024 * 1024)), - }; - } - - // Hand each group to a pane and point every tree entry at the pane that - // owns its draw item. - function assign(panes, groups) { - let at = 0; - groups.forEach((group, gi) => { - for (let i = 0; i < group.length; i++) { - leafletLayers[at++]._orPane = panes[gi]; - } - }); - } - - const initial = wantedGroupCount(); - const groups = partitionIntoGroups(items, initial.count); - // zIndex 3 upwards, matching the slots the per-layer panes used, so the - // routing stack still sits above _instances/_pins/_modules. - const panes = buildMergedPanes(mergedLayerClass, app.websocketManager, - groups, app.map, 3); - assign(panes, groups); - // These are what redrawAllLayers() refreshes — the design-changed push, - // pattern changes and visibility changes all arrive through it. - app.allLayers.push(...panes); - app.mergedPanes = panes; - app.mergeStats - = describe(panes.length, initial.tilesPerPane, initial.perTile); - console.log('[tiles] merged %d layers into %d panes ' - + '(~%d MB of %d MB budget, %d tiles/pane)', - app.mergeStats.layers, app.mergeStats.groups, - app.mergeStats.estimatedMB, app.mergeStats.budgetMB, - initial.tilesPerPane); - - // A pane holds a full grid of tiles, so enlarging the window raises the - // per-pane cost and a grouping that fitted the budget at startup no - // longer does — the same failure, arriving later. Recompute on resize. - // - // Shrink only. Growing N back when the window shrinks would churn - // panes on every drag of a splitter for no safety benefit, and leaves - // the merge coarser than strictly necessary, which is the harmless - // direction. A layer toggle then re-merges a slightly larger group. - app.map.on('resize', () => { - const want = wantedGroupCount(); - if (want.count >= app.mergedPanes.length) { - return; - } - const regrouped = partitionIntoGroups(items, want.count); - // Reuse the surviving panes and drop the surplus, so z-order and - // pane identity stay stable for the ones that remain. - const keep = app.mergedPanes.slice(0, regrouped.length); - for (const pane of app.mergedPanes.slice(regrouped.length)) { - app.map.removeLayer(pane); - const at = app.allLayers.indexOf(pane); - if (at >= 0) { - app.allLayers.splice(at, 1); - } - } - app.mergedPanes = keep; - assign(keep, regrouped); - keep.forEach((pane, i) => pane.setItems(regrouped[i])); - app.mergeStats - = describe(keep.length, want.tilesPerPane, want.perTile); - console.log('[tiles] window grew — regrouped %d layers into %d ' - + 'panes (~%d MB of %d MB budget, %d tiles/pane)', - app.mergeStats.layers, app.mergeStats.groups, - app.mergeStats.estimatedMB, app.mergeStats.budgetMB, - want.tilesPerPane); + // ─── The slots ─────────────────────────────────────────────────────── + function compositeSlot(id, order, items) { + const slot = app.view.addTileSlot(id, { + order, + source: createCompositeSource({ + wm: app.websocketManager, + ctx: app.tileCtx, + getItems: () => items, + dpr: nativeDpr, + tileSize: tileSizeCss, + isDoubleBuffer: () => app.doubleBuffer, + groupLayers: () => serverGroupLayers(app), + }), }); + slot.items = items; // the draw list, bottom-most first + return slot; } + app.baseSlot = compositeSlot( + 'base', DRAW_ORDER.base, + [...underItems, ...routingLayers]); + app.topSlot = compositeSlot('top', DRAW_ORDER.top, topItems); + // What redrawAllLayers() refreshes. + app.allLayers = [app.baseSlot, app.topSlot]; // Parallel selectability model with the same node ids as layerSpec so // syncLayerSelDom() and buildLayerDOM() can pair each visibility node @@ -592,9 +460,9 @@ export function populateDisplayControls(app, visibility, selectability, const layerModel = new CheckboxTreeModel(() => { // Single pass over the tree: rebuild visibleLayerNames in place - // (the WebSocketTileLayer closure captured this Set by reference - // at startup, so we mutate rather than reassign), sync DOM and - // Leaflet, collect the cookie payload and accumulate any chiplet + // (app.tileCtx captured this Set by reference at startup, so we + // mutate rather than reassign), sync DOM and the draw lists, collect + // the cookie payload and accumulate any chiplet // toggles that need to mirror into the Chiplets panel. The // rebuild-from-scratch pattern avoids incrementally dropping a // layer name still owned by a checked sibling in multi-tech @@ -605,7 +473,7 @@ export function populateDisplayControls(app, visibility, selectability, // tri-state change for the UI checkboxes; visibilityChangedAny // tracks whether any toggle also moved the chiplet in or out // of visibleChiplets. Splitting them lets us skip the - // chipletModel.onChange path (which redraws every Leaflet tile) + // chipletModel.onChange path (which redraws every tile) // when the visible set is unchanged. const stateUpdates = {}; let stateChangedAny = false; @@ -621,12 +489,11 @@ export function populateDisplayControls(app, visibility, selectability, if (node.data && node.data.layer) { const id = node.data.nodeId || node.data.name; allLayerIds.push(id); + setRoutingVisible(node.data.layer, node.checked); if (node.checked) { - node.data.layer._orShow(); app.visibleLayers.add(id); app.visibleLayerNames.add(node.data.name); } else { - node.data.layer._orHide(); app.visibleLayers.delete(id); } } @@ -653,22 +520,21 @@ export function populateDisplayControls(app, visibility, selectability, } } }); - // One refresh per affected merged pane, after the whole walk: a group - // toggle touches many nodes that share a pane. - flushDirtyPanes(); - // Visibility off ⇒ selectability disabled — refresh selectability DOM. - syncLayerSelDom(); - // Refresh pins layer so it filters by the updated visible_layers. - if (app.pinsLayer && app.map.hasLayer(app.pinsLayer)) { - app.pinsLayer.refreshTiles(); - } - // And the overlays that draw by them under the current visibility. - for (const { def, layer } of app.overlayLayers || []) { - if (anyGroupOn(def.layers_by, visibility) - && app.map.hasLayer(layer)) { - layer.refreshTiles(); + // One refresh per affected slot, after the whole walk: a group + // toggle touches many nodes that share a slot. Pins filter by + // visible_layers, which only changes when some routing entry flips, + // and so do the overlays that draw by them under the current + // visibility. + if (app.baseSlot && dirtySlots.has(app.baseSlot)) { + for (const { def, under } of app.overlayLayers) { + if (anyGroupOn(def.layers_by, visibility)) { + dirtySlots.add(under ? app.baseSlot : app.topSlot); + } } } + flushDirtySlots(); + // Visibility off ⇒ selectability disabled — refresh selectability DOM. + syncLayerSelDom(); const hiddenNodes = allLayerIds.filter(n => !app.visibleLayers.has(n)); try { @@ -689,7 +555,7 @@ export function populateDisplayControls(app, visibility, selectability, // partially-selected chiplet keeps its tri-state checkbox AND // stays in visibleChiplets. When only the tri-state changed // (without entering/leaving the visible set) we take the quiet - // path so chipletModel.onChange — which redraws every Leaflet + // path so chipletModel.onChange — which redraws every // tile — is skipped; we sync the DOM checkboxes by hand instead. if (visibilityChangedAny) { // Every visibility flip is also a tri-state change, so @@ -721,7 +587,7 @@ export function populateDisplayControls(app, visibility, selectability, // share a layer name don't fall into last-writer-wins (an unchecked // M1 leaf in one subtree would otherwise delete the name even when // another M1 leaf is still checked). Mutate in place — the - // WebSocketTileLayer closure captured this Set by reference. + // tile request context (app.tileCtx) captured this Set by reference. app.selectableLayers.clear(); layerSelModel.forEach(node => { if (node.checked && node.data && node.data.name) { @@ -786,7 +652,7 @@ export function populateDisplayControls(app, visibility, selectability, contextMenu.appendChild(div); } - const n = leafletLayers.length; + const n = routingLayers.length; const menuItems = [ { label: 'Show only this layer', fn: (i) => layerRangeSet(i, 0, 0, n) }, { label: 'Show layer range \u2195', fn: (i) => layerRangeSet(i, 1, 1, n) }, @@ -950,8 +816,8 @@ export function populateDisplayControls(app, visibility, selectability, () => showOnlyLayers(item.fn(index))); } - // Fill-pattern submenu: choosing one re-renders only this - // layer's tiles and persists the choice. + // Fill-pattern submenu: choosing one re-renders the base + // slot's tiles and persists the choice. const sep = document.createElement('div'); sep.className = 'context-menu-separator'; sep.style.borderTop = '1px solid #555'; @@ -962,7 +828,7 @@ export function populateDisplayControls(app, visibility, selectability, const marker = current === opt.value ? '● ' : ' '; addContextMenuItem( marker + 'Fill: ' + opt.label, - () => setLayerPattern(name, node.data.layer, opt.value)); + () => setLayerPattern(name, opt.value)); } contextMenu.style.left = e.clientX + 'px'; @@ -1044,7 +910,7 @@ export function populateDisplayControls(app, visibility, selectability, // chip, it does not toggle per-chiplet visibility. Backend sends // one entry per dbChip / dbChipInst node with a unique `path` // ("top", "top/soc_inst", "top/soc_inst/sub_ip", …). Toggling a - // node refreshes every Leaflet tile so the server's chiplet + // node refreshes every tile so the server's chiplet // filter (`visible_chiplets`) takes effect on the next render. const chipletData = (techData && Array.isArray(techData.chiplets)) ? techData.chiplets : []; @@ -1149,7 +1015,7 @@ export function populateDisplayControls(app, visibility, selectability, encodeURIComponent(JSON.stringify(writeMap))); } - // Refresh every Leaflet tile so the server applies the + // Refresh every tile so the server applies the // updated `visible_chiplets` filter on the next request. redrawAllLayers(); }); @@ -1204,7 +1070,7 @@ export function populateDisplayControls(app, visibility, selectability, }); // Cascade a chiplet toggle down into the layerModel so the - // Layers panel checkboxes (and the Leaflet tiles, and the + // Layers panel checkboxes (and the tiles, and the // or_hidden_layers cookie) follow. cascadeQuiet skips the // layerModel's onChange; we fire it ourselves so the standard // sync path runs exactly once. No loop with the chipletModel @@ -1332,7 +1198,7 @@ export function populateDisplayControls(app, visibility, selectability, app.displayControlsEl.appendChild(chipletGroup); } else { // Single-chip designs render every chiplet (i.e. only the top). - // Clearing keeps WebSocketTileLayer's serializer from sending an + // Clearing keeps the tile request builder from sending an // empty array and accidentally enabling the filter. app.visibleChiplets = null; } @@ -1574,8 +1440,8 @@ export function populateDisplayControls(app, visibility, selectability, // Background color control (Qt GUI "Background" parity): a swatch that // opens the native color picker + a reset-to-theme link. The layout - // background is the CSS var --bg-map on the Leaflet container, so this - // is purely client-side (tiles are transparent). + // background is the CSS var --bg-map on the layout view, so this is + // purely client-side (tiles are transparent). const bgRow = document.createElement('div'); bgRow.className = 'bg-color-row'; const bgLabel = document.createElement('span'); @@ -1611,11 +1477,8 @@ export function populateDisplayControls(app, visibility, selectability, // Appended after the heat maps group below: Background is the panel's // footer, so every group — heat maps included — sits above it. - if (!app.heatMapLayer) { - app.heatMapLayer = new HeatMapTileLayer(app.websocketManager, app, { - zIndex: leafletLayers.length + 10, - opacity: 1, - }); + if (!app.heatMapLayer && createHeatMapSlot) { + app.heatMapLayer = createHeatMapSlot(); } const heatMapGroup = document.createElement('div'); diff --git a/src/web/src/display-state.js b/src/web/src/display-state.js index 7b19c6e8cc8..aac2f7a8f11 100644 --- a/src/web/src/display-state.js +++ b/src/web/src/display-state.js @@ -46,6 +46,9 @@ const DISPLAY_STATE_KEYS = [ { key: 'or_arrow_step', store: 'cookie' }, { key: 'or_font_family', store: 'cookie' }, { key: 'or_font_scale', store: 'cookie' }, + { key: 'or_control_smoothing', store: 'cookie' }, + { key: 'or_double_buffer', store: 'cookie' }, + { key: 'or_defer_tile_updates', store: 'cookie' }, ]; // Storage accessors, tolerant of a browser with Web Storage disabled (the diff --git a/src/web/src/drc-widget.js b/src/web/src/drc-widget.js index 422724d4675..ecfe675f2b3 100644 --- a/src/web/src/drc-widget.js +++ b/src/web/src/drc-widget.js @@ -4,7 +4,7 @@ // DRC viewer widget — category selector, violation tree, load/highlight. // Matches the capabilities of the Qt GUI DRCWidget. -import { dbuRectToBounds } from './coordinates.js'; +import { dbuRectToWorldRect } from './coordinates.js'; export class DrcWidget { constructor(app, redrawAllLayers, refreshOverlay) { @@ -369,7 +369,7 @@ export class DrcWidget { } _zoomToBBox(bbox) { - if (!this._app.designScale || !this._app.map) return; + if (!this._app.designScale || !this._app.view) return; const [xMin, yMin, xMax, yMax] = bbox; const dx = xMax - xMin; @@ -384,11 +384,11 @@ export class DrcWidget { const zoomoutBox = 2 * Math.max(dx, dy); const margin = Math.min(zoomoutDist, zoomoutBox); - this._app.map.fitBounds( - dbuRectToBounds( + this._app.view.fitWorldRect( + dbuRectToWorldRect( xMin - margin, yMin - margin, xMax + margin, yMax + margin, - this._app.designScale, this._app.designMaxDXDY, + this._app.designScale, this._app.designOriginX, this._app.designOriginY)); } @@ -412,15 +412,7 @@ export class DrcWidget { } _flashHighlight() { - const container = this._app.map?.getContainer(); - if (!container) return; - container.classList.remove('drc-flashing'); - // Force reflow so re-adding the class restarts the animation. - void container.offsetWidth; - container.classList.add('drc-flashing'); - container.addEventListener('animationend', () => { - container.classList.remove('drc-flashing'); - }, { once: true }); + this._app.view?.flashTiles(); } _update3DHighlights() { diff --git a/src/web/src/entry-app.js b/src/web/src/entry-app.js index f4b9d8844f4..609f004e82e 100644 --- a/src/web/src/entry-app.js +++ b/src/web/src/entry-app.js @@ -4,6 +4,6 @@ // The served page's bundle: the viewer and the libraries it is built on. // main.js builds the panels as it loads, after the globals they read. -import './leaflet-global.js'; +import './deck-global.js'; import './vendor-globals.js'; import './main.js'; diff --git a/src/web/src/entry-report.js b/src/web/src/entry-report.js index 36548fe7c00..5df1b84477c 100644 --- a/src/web/src/entry-report.js +++ b/src/web/src/entry-report.js @@ -4,5 +4,5 @@ // The saved report's bundle leaves out vendor-globals.js; the schematic and 3D // panels need a live server and say so when their libraries are missing. -import './leaflet-global.js'; +import './deck-global.js'; import './main.js'; diff --git a/src/web/src/inspector.js b/src/web/src/inspector.js index 99920cfae47..9a952bad52f 100644 --- a/src/web/src/inspector.js +++ b/src/web/src/inspector.js @@ -4,9 +4,10 @@ // Inspector panel — property tree, hover highlights, bbox display, // property editing (server descriptor editors). -import { dbuRectToBounds } from './coordinates.js'; -import { beginSelection, isCurrentSelection, isStaticMode, showConfirmModal, - showToast } from './ui-utils.js'; +import { dbuRectToWorldRect } from './coordinates.js'; +import { DRAW_ORDER, toRgba } from './layout-view.js'; +import { beginSelection, isCurrentSelection, isStaticMode, + prefersReducedMotion, showConfirmModal, showToast } from './ui-utils.js'; // Delete: trash can (Material "delete") const DELETE_SVG = @@ -181,9 +182,8 @@ export function createInspectorPanel(app, redrawAllLayers, refreshOverlay) { }); if (!resp.ok && resp.error) showToast(resp.error); updateInspector(resp.properties ? resp : null); - if (resp.deleted && app.highlightRect && app.map) { - app.map.removeLayer(app.highlightRect); - app.highlightRect = null; + if (resp.deleted) { + clearSelectionOutline(); } clearClientHoverHighlight(); refreshOverlay(); @@ -327,78 +327,134 @@ export function createInspectorPanel(app, redrawAllLayers, refreshOverlay) { if (lastInspectData) updateInspector(lastInspectData); } - function clearClientHoverHighlight() { - if (app.hoverHighlightLayer) { - app.map.removeLayer(app.hoverHighlightLayer); - app.hoverHighlightLayer = null; - } + // ─── Client-side shapes on the layout view ────────────────────────── + // + // The hover boxes, the selection outline, the selection pulse and the + // Qt-style selection animation. Kept in DBU and turned into world shapes + // when drawn, so a zoom can recompute the minimum on-screen hover size. + + function worldRect(x1, y1, x2, y2) { + return dbuRectToWorldRect(x1, y1, x2, y2, app.designScale, + app.designOriginX, app.designOriginY); } - function clearHoverHighlight() { - clearClientHoverHighlight(); - app.websocketManager.request({ type: 'hover', select_id: -1 }) - .then(() => {}) - .catch(() => {}); + function lerp(a, b, t) { + return a + (b - a) * t; } - function boundsWithMinimumScreenSize(x1, y1, x2, y2) { - const baseBounds = L.latLngBounds( - dbuRectToBounds(x1, y1, x2, y2, app.designScale, app.designMaxDXDY, app.designOriginX, app.designOriginY) - ); - if (!app.map) { - return baseBounds; + function lerpColor(a, b, t) { + return a.map((v, i) => Math.round(lerp(v, b[i], t))); + } + + // Value of a CSS-like keyframe list at fraction `t` of one cycle. + // `frames` is [{at, ...numbers or rgb arrays}], at in 0..1. + function keyframeAt(frames, t) { + let i = 0; + while (i < frames.length - 2 && t > frames[i + 1].at) { + i++; } + const a = frames[i]; + const b = frames[i + 1]; + const local = Math.max(0, Math.min(1, (t - a.at) / (b.at - a.at))); + const out = {}; + for (const key of Object.keys(a)) { + if (key === 'at') continue; + out[key] = Array.isArray(a[key]) ? lerpColor(a[key], b[key], local) + : lerp(a[key], b[key], local); + } + return out; + } - const southWest = baseBounds.getSouthWest(); - const northEast = baseBounds.getNorthEast(); - const swPoint = app.map.latLngToContainerPoint(southWest); - const nePoint = app.map.latLngToContainerPoint(northEast); - - const minX = Math.min(swPoint.x, nePoint.x); - const maxX = Math.max(swPoint.x, nePoint.x); - const minY = Math.min(swPoint.y, nePoint.y); - const maxY = Math.max(swPoint.y, nePoint.y); - - let expandedMinX = minX; - let expandedMaxX = maxX; - let expandedMinY = minY; - let expandedMaxY = maxY; - - if ((maxX - minX) < kMinHoverBoxPixels) { - const pad = (kMinHoverBoxPixels - (maxX - minX)) / 2; - expandedMinX -= pad; - expandedMaxX += pad; + // Run `draw(t)` every frame for `cycles` of `cycleMs`, then `done()`. + // Reduced motion jumps to the end, as the stylesheet's rule did. + function runKeyframes(cycleMs, cycles, draw, done) { + if (prefersReducedMotion() + || typeof requestAnimationFrame !== 'function') { + done(); + return () => {}; } - if ((maxY - minY) < kMinHoverBoxPixels) { - const pad = (kMinHoverBoxPixels - (maxY - minY)) / 2; - expandedMinY -= pad; - expandedMaxY += pad; + const start = performance.now(); + let stopped = false; + const step = () => { + if (stopped) return; + const elapsed = performance.now() - start; + if (elapsed >= cycleMs * cycles) { + done(); + return; + } + draw((elapsed % cycleMs) / cycleMs); + requestAnimationFrame(step); + }; + step(); + return () => { stopped = true; }; + } + + function setShapes(id, shapes, order = DRAW_ORDER.highlight) { + if (app.view) { + app.view.setOverlay(id, shapes, { order }); } + } + + // Hover boxes: at least kMinHoverBoxPixels on screen, so a tiny object + // still shows where it is. + let hoverRects = null; + let stopHoverPulse = () => {}; + const HOVER_FILL = [255, 242, 122]; + const HOVER_FRAMES = [ + { at: 0, stroke: [255, 246, 176], width: 7, alpha: 1, fill: 0.28 }, + { at: 0.55, stroke: [255, 255, 255], width: 5, alpha: 1, fill: 0.06 }, + { at: 1, stroke: [255, 232, 92], width: 3, alpha: 0.95, fill: 0.14 }, + ]; + const HOVER_REST = { stroke: [255, 232, 92], width: 3, alpha: 1, fill: 0.14 }; + + function hoverWorldRect(x1, y1, x2, y2) { + const [x0, y0, x3, y3] = worldRect(x1, y1, x2, y2); + // The view scales world units by 2^zoom on both axes. + const min = kMinHoverBoxPixels / 2 ** app.view.getZoom(); + const padX = Math.max(0, (min - (x3 - x0)) / 2); + const padY = Math.max(0, (min - (y3 - y0)) / 2); + return [x0 - padX, y0 - padY, x3 + padX, y3 + padY]; + } + + function drawHover(style) { + if (!hoverRects) return; + setShapes('hover', hoverRects.map(([x1, y1, x2, y2]) => ({ + kind: 'rect', + rect: hoverWorldRect(x1, y1, x2, y2), + stroke: toRgba(style.stroke, style.alpha), + width: style.width, + fill: toRgba(HOVER_FILL, style.fill), + }))); + } - const topLeft = app.map.containerPointToLatLng(L.point(expandedMinX, expandedMinY)); - const bottomRight = app.map.containerPointToLatLng(L.point(expandedMaxX, expandedMaxY)); - return L.latLngBounds(topLeft, bottomRight); + function redrawHoverOnZoom() { + drawHover(HOVER_REST); + } + + function clearClientHoverHighlight() { + stopHoverPulse(); + hoverRects = null; + setShapes('hover', null); + app.view?.off('zoom', redrawHoverOnZoom); + } + + function clearHoverHighlight() { + clearClientHoverHighlight(); + app.websocketManager.request({ type: 'hover', select_id: -1 }) + .then(() => {}) + .catch(() => {}); } function renderHoverRects(rects) { clearClientHoverHighlight(); - if (!app.map || !app.designScale || !rects || rects.length === 0) { + if (!app.view || !app.designScale || !rects || rects.length === 0) { return; } - - app.hoverHighlightLayer = L.layerGroup( - rects.map(([x1, y1, x2, y2]) => L.rectangle(boundsWithMinimumScreenSize(x1, y1, x2, y2), { - color: '#ffe85c', - weight: 3, - fill: true, - fillColor: '#fff27a', - fillOpacity: 0.14, - opacity: 1, - interactive: false, - className: 'hover-highlight', - pane: app.hoverHighlightPane, - })) - ).addTo(app.map); + hoverRects = rects; + app.view.on('zoom', redrawHoverOnZoom); + stopHoverPulse = runKeyframes(900, 3, + (t) => drawHover(keyframeAt(HOVER_FRAMES, 1 - Math.pow(1 - t, 2))), + () => drawHover(HOVER_REST)); } function makeClickable(el, selectId) { @@ -463,15 +519,9 @@ export function createInspectorPanel(app, redrawAllLayers, refreshOverlay) { app.schematicWidget.refresh(); } } - if (app.map) { - app.map.closePopup(); - } clearClientHoverHighlight(); - if (app.highlightRect && app.map) { - app.map.removeLayer(app.highlightRect); - app.highlightRect = null; - } - if (data.bbox && app.map && app.designScale) { + clearSelectionOutline(); + if (data.bbox && app.view && app.designScale) { const [x1, y1, x2, y2] = data.bbox; if (data.type !== 'Inst') { highlightBBox(x1, y1, x2, y2, data.type); @@ -517,13 +567,9 @@ export function createInspectorPanel(app, redrawAllLayers, refreshOverlay) { } updateInspector(data); - app.map.closePopup(); clearClientHoverHighlight(); - if (app.highlightRect) { - app.map.removeLayer(app.highlightRect); - app.highlightRect = null; - } - if (data.bbox && app.map && app.designScale) { + clearSelectionOutline(); + if (data.bbox && app.view && app.designScale) { const [x1, y1, x2, y2] = data.bbox; // For non-instance objects, show dashed bbox outline // (instances get the yellow tile-based highlight instead) @@ -563,13 +609,9 @@ export function createInspectorPanel(app, redrawAllLayers, refreshOverlay) { } updateInspector(data); - app.map.closePopup(); clearClientHoverHighlight(); - if (app.highlightRect) { - app.map.removeLayer(app.highlightRect); - app.highlightRect = null; - } - if (data.bbox && app.map && app.designScale) { + clearSelectionOutline(); + if (data.bbox && app.view && app.designScale) { if (data.type !== 'Inst') { const [x1, y1, x2, y2] = data.bbox; highlightBBox(x1, y1, x2, y2, data.type); @@ -584,116 +626,106 @@ export function createInspectorPanel(app, redrawAllLayers, refreshOverlay) { }); } + // The selection outline: kept in DBU, drawn while the "Highlight + // selected" toggle (Misc) is on, so turning it back on shows the current + // selection's outline again (redrawAllLayers -> renderSelectionOutline). + let selectionBBox = null; + + function renderSelectionOutline() { + const show = selectionBBox && app.designScale + && !(app.visibility && app.visibility.highlight_selected === false); + setShapes('selection', show ? [{ + kind: 'rect', + rect: worldRect(...selectionBBox), + stroke: toRgba('#ff0'), width: 2, dash: [6, 4], + }] : null, DRAW_ORDER.selection); + } + + function clearSelectionOutline() { + selectionBBox = null; + renderSelectionOutline(); + } + function highlightBBox(x1, y1, x2, y2, type) { - if (app.highlightRect) { - app.map.removeLayer(app.highlightRect); - app.highlightRect = null; - } // A net's bbox spans its whole extent, which is distracting; the net's // trace is already highlighted via the overlay, so skip the rectangle. - if (type === 'Net') { - return; - } - const bounds = dbuRectToBounds(x1, y1, x2, y2, app.designScale, app.designMaxDXDY, app.designOriginX, app.designOriginY); - // Always build the outline; only attach it while the "Highlight - // selected" toggle (Misc) is on, so toggling it back on can - // re-attach the current selection's outline (redrawAllLayers). - app.highlightRect = L.rectangle(bounds, { - color: '#ff0', weight: 2, fill: false, dashArray: '6,4', - }); - if (!(app.visibility && app.visibility.highlight_selected === false)) { - app.highlightRect.addTo(app.map); - } + selectionBBox = type === 'Net' ? null : [x1, y1, x2, y2]; + renderSelectionOutline(); } // Briefly pulse the object's bbox so the user can see which object // the inspector is now showing — mirrors the Qt GUI's selection // animation. The pulse is a filled rectangle that fades in and out - // several times, then removes itself. - let pulseLayer = null; + // three times, then removes itself. + let stopPulse = null; + const PULSE_FRAMES = [ + { at: 0, alpha: 0, fill: 0 }, + { at: 0.5, alpha: 1, fill: 0.28 }, + { at: 1, alpha: 0, fill: 0 }, + ]; + function clearPulse() { + if (stopPulse) { + stopPulse(); + stopPulse = null; + } + setShapes('pulse', null); + } function pulseHighlight(bbox, type) { - if (!bbox || !app.map || !app.designScale) return; + if (!bbox || !app.view || !app.designScale) return; // Clear any pulse in flight before honoring the toggle, so a call // while highlighting is off doesn't leave a stale pulse behind. if (animTimer !== null) stopSelectionAnimation(); - if (pulseLayer) { - app.map.removeLayer(pulseLayer); - pulseLayer = null; - } + clearPulse(); // Honor the "Highlight selected" toggle (Misc). if (app.visibility && app.visibility.highlight_selected === false) { return; } // A net's bbox spans the whole net; don't pulse a giant rectangle. if (type === 'Net') return; - const [x1, y1, x2, y2] = bbox; - const bounds = dbuRectToBounds( - x1, y1, x2, y2, app.designScale, app.designMaxDXDY, - app.designOriginX, app.designOriginY); - pulseLayer = L.rectangle(bounds, { - color: '#ff0', - weight: 3, - fill: true, - fillColor: '#ff0', - fillOpacity: 0.25, - opacity: 1, - interactive: false, - className: 'selection-pulse', - pane: app.hoverHighlightPane, - }).addTo(app.map); - // Remove after the animation finishes (3 cycles × 350ms = 1050ms). - const layerToRemove = pulseLayer; - setTimeout(() => { - if (layerToRemove && app.map && app.map.hasLayer(layerToRemove)) { - app.map.removeLayer(layerToRemove); - } - if (pulseLayer === layerToRemove) { - pulseLayer = null; - } - }, 1100); + const rect = worldRect(...bbox); + stopPulse = runKeyframes(350, 3, (t) => { + const k = keyframeAt(PULSE_FRAMES, + 0.5 - 0.5 * Math.cos(Math.PI * t)); + setShapes('pulse', [{ + kind: 'rect', rect, + stroke: toRgba('#ff0', k.alpha), width: 3, + fill: toRgba('#ff0', k.fill), + }]); + }, () => { + stopPulse = null; + setShapes('pulse', null); + }); } // Qt-style selection animation (layoutViewer.cpp selectionAnimation): // every tick the outline weight cycles 1→2→3 px with a yellow brush - // flash on the weight-1 tick. Unlike Qt, only this Leaflet path - // repaints — the layout tiles are untouched. repeats=0 animates - // until stopSelectionAnimation() or a new animation replaces it. - let animLayer = null; + // flash on the weight-1 tick. Unlike Qt, only this shape repaints — + // the layout tiles are untouched. repeats=0 animates until + // stopSelectionAnimation() or a new animation replaces it. let animTimer = null; + function drawAnim(rect, weight) { + setShapes('anim', [{ + kind: 'rect', rect, + stroke: toRgba('#ff0'), width: weight, + fill: toRgba('#ff0', weight === 1 ? 0.39 : 0), // ≈ Qt kHighlight 100/255 + }]); + } function stopSelectionAnimation() { if (animTimer !== null) { clearInterval(animTimer); animTimer = null; } - if (animLayer) { - if (app.map && app.map.hasLayer(animLayer)) { - app.map.removeLayer(animLayer); - } - animLayer = null; - } + setShapes('anim', null); } function animateSelection(bbox, { repeats = 6, intervalMs = 300 } = {}) { - if (!bbox || !app.map || !app.designScale) return; + if (!bbox || !app.view || !app.designScale) return; stopSelectionAnimation(); - if (typeof matchMedia === 'function' - && matchMedia('(prefers-reduced-motion: reduce)').matches) { + if (prefersReducedMotion()) { pulseHighlight(bbox); return; } - const [x1, y1, x2, y2] = bbox; - const bounds = dbuRectToBounds( - x1, y1, x2, y2, app.designScale, app.designMaxDXDY, - app.designOriginX, app.designOriginY); - animLayer = L.rectangle(bounds, { - color: '#ff0', - weight: 1, - fill: true, - fillColor: '#ff0', - fillOpacity: 0.39, // ≈ Qt kHighlight brush alpha 100/255 - opacity: 1, - interactive: false, - pane: app.hoverHighlightPane, - }).addTo(app.map); + const rect = worldRect(...bbox); + drawAnim(rect, 1); let state = 0; const maxState = repeats > 0 ? repeats * 3 : Infinity; animTimer = setInterval(() => { @@ -702,22 +734,15 @@ export function createInspectorPanel(app, redrawAllLayers, refreshOverlay) { stopSelectionAnimation(); return; } - const weight = (state % 3) + 1; - animLayer.setStyle({ - weight, - fillOpacity: weight === 1 ? 0.39 : 0, - }); + drawAnim(rect, (state % 3) + 1); }, intervalMs); } // Let redrawAllLayers cancel an in-flight pulse when the "Highlight - // selected" toggle is turned off (pulseLayer is private to this closure). - app.clearSelectionPulse = function() { - if (pulseLayer) { - app.map.removeLayer(pulseLayer); - pulseLayer = null; - } - }; + // selected" toggle is turned off, and keep the outline in step with it. + app.clearSelectionPulse = clearPulse; + app.renderSelectionOutline = renderSelectionOutline; + app.clearSelectionOutline = clearSelectionOutline; // Build the collapsible shell (header row + body) shared by the group and // table property renderers. `count` is the parenthesised badge after the @@ -970,10 +995,8 @@ export function createInspectorPanel(app, redrawAllLayers, refreshOverlay) { } function zoomToBBox(bbox) { - if (!bbox || !app.map || !app.designScale) return; - const [x1, y1, x2, y2] = bbox; - app.map.fitBounds(dbuRectToBounds(x1, y1, x2, y2, app.designScale, app.designMaxDXDY, app.designOriginX, app.designOriginY), - { padding: [20, 20] }); + if (!bbox || !app.view || !app.designScale) return; + app.view.fitWorldRect(worldRect(...bbox), { padding: [20, 20] }); } function updateInspector(data) { diff --git a/src/web/src/label-manager.js b/src/web/src/label-manager.js index 9dc1cc042dd..25b440b136a 100644 --- a/src/web/src/label-manager.js +++ b/src/web/src/label-manager.js @@ -5,11 +5,15 @@ // the shared TileGenerator) so they render into the overlay tiles and into // save_image, matching the Qt GUI. This client module provides the // interactive layer the Qt GUI lacks: create-by-click, drag-to-reposition, -// and edit/delete via the Inspector. Each label gets a small draggable handle -// marker in a dedicated Leaflet pane; the label text itself is drawn by the -// server on the overlay. +// and edit/delete via the Inspector. Each label gets a small draggable DOM +// handle pinned over the view; the label text itself is drawn by the server +// on the overlay. -import { dbuToLatLng, latLngToDbu } from './coordinates.js'; +import { dbuToWorld, worldToDbu } from './coordinates.js'; + +const HANDLES = 'label-handles'; +// A press that moves further than this drags the handle instead of clicking. +const kDragTolerancePx = 3; export class LabelManager { constructor(app, visibility, updateInspector, focusComponent) { @@ -22,19 +26,6 @@ export class LabelManager { this._anchors = []; // anchor names the server accepts this._mode = false; // placement mode (next click creates a label) this._selectedName = null; - - this._pane = null; - this._handleGroup = null; - this._initLayers(); - } - - _initLayers() { - const map = this._app.map; - if (!map) return; - this._pane = map.createPane('label-pane'); - this._pane.style.zIndex = '690'; - this._pane.style.pointerEvents = 'auto'; - this._handleGroup = L.layerGroup([], { pane: 'label-pane' }).addTo(map); } isActive() { @@ -42,9 +33,8 @@ export class LabelManager { } updateVisibility() { - if (this._pane) { - this._pane.style.display = this._visibility.labels ? '' : 'none'; - } + this._app.view?.setMarkerGroupVisible(HANDLES, + !!this._visibility.labels); } toggleLabelMode() { @@ -57,13 +47,8 @@ export class LabelManager { this._setCursor(false); } - // Toggled as a class, not an inline style: .leaflet-container carries - // `cursor: default !important`, which an inline declaration of normal - // priority cannot override. _setCursor(on) { - const c = this._app.map?.getContainer(); - if (!c) return; - c.classList.toggle('label-mode-cursor', on); + this._app.view?.setCursorMode('label', on); } _wm() { @@ -136,41 +121,73 @@ export class LabelManager { } _renderHandles() { - if (!this._handleGroup) return; - this._handleGroup.clearLayers(); - const scale = this._app.designScale; - if (!scale) return; - const maxDXDY = this._app.designMaxDXDY; - const ox = this._app.designOriginX; - const oy = this._app.designOriginY; + const view = this._app.view; + if (!view) return; + view.clearMarkers(HANDLES); + const app = this._app; + if (!app.designScale) return; for (const label of this._labels) { - const ll = dbuToLatLng(label.x, label.y, scale, maxDXDY, ox, oy); - const selected = label.name === this._selectedName; - const marker = L.marker(ll, { - pane: 'label-pane', - draggable: true, - keyboard: false, - icon: L.divIcon({ - className: 'label-handle' - + (selected ? ' label-handle-selected' : ''), - html: '', - iconSize: [10, 10], - }), - title: label.text, - }); - marker.on('click', (e) => { - L.DomEvent.stopPropagation(e); + const el = document.createElement('div'); + el.className = 'label-handle' + + (label.name === this._selectedName + ? ' label-handle-selected' : ''); + el.title = label.text; + this._installDrag(el, label); + view.addMarker(HANDLES, label.name, + dbuToWorld(label.x, label.y, app.designScale, + app.designOriginX, app.designOriginY), + el, { center: true }); + } + } + + // Press and release selects the label; a drag moves it. + _installDrag(el, label) { + const view = this._app.view; + const toWorld = (e) => { + const r = view.getContainer().getBoundingClientRect(); + return view.unproject([e.clientX - r.left, e.clientY - r.top]); + }; + let press = null; + el.addEventListener('pointerdown', (e) => { + if (e.button !== 0) return; + e.stopPropagation(); + e.preventDefault(); + el.setPointerCapture?.(e.pointerId); + press = { x: e.clientX, y: e.clientY, moved: false }; + }); + el.addEventListener('pointermove', (e) => { + if (!press) return; + if (Math.abs(e.clientX - press.x) > kDragTolerancePx + || Math.abs(e.clientY - press.y) > kDragTolerancePx) { + press.moved = true; + } + if (press.moved) { + view.moveMarker(HANDLES, label.name, toWorld(e)); + } + }); + const finish = (e, commit) => { + if (!press) return; + const p = press; + press = null; + el.releasePointerCapture?.(e.pointerId); + if (!commit) { + this._renderHandles(); + } else if (!p.moved) { this._select(label.name); - }); - marker.on('dragend', (e) => { - const p = e.target.getLatLng(); - const { dbuX, dbuY } = latLngToDbu( - p.lat, p.lng, scale, maxDXDY, ox, oy); + } else { + const app = this._app; + const [wx, wy] = toWorld(e); + const { dbuX, dbuY } = worldToDbu( + wx, wy, app.designScale, + app.designOriginX, app.designOriginY); this._commitMove(label, Math.round(dbuX), Math.round(dbuY)); - }); - this._handleGroup.addLayer(marker); - } + } + }; + el.addEventListener('pointerup', (e) => finish(e, true)); + el.addEventListener('pointercancel', (e) => finish(e, false)); + // The view's own click and double-click handling skips markers. + el.addEventListener('click', (e) => e.stopPropagation()); } // Move the label to a new position with a single atomic update (no diff --git a/src/web/src/layer-extents.js b/src/web/src/layer-extents.js index 06d2507ddbb..d1da2ad1525 100644 --- a/src/web/src/layer-extents.js +++ b/src/web/src/layer-extents.js @@ -171,8 +171,8 @@ export class LayerExtents { } } -// Whether a tile layer should request `layer` at `coords`. `ctx` is a tile -// layer's context ({ visibility, app }); app.layerExtents is absent until +// Whether a tile source should request `layer` at `coords`. `ctx` is the +// tile request context ({ visibility, app }); app.layerExtents is absent until // main.js installs it, and in that case everything is requested. export function tileMayHaveContent(ctx, layer, coords) { const extents = ctx && ctx.app && ctx.app.layerExtents; diff --git a/src/web/src/layout-view.js b/src/web/src/layout-view.js new file mode 100644 index 00000000000..ede01739684 --- /dev/null +++ b/src/web/src/layout-view.js @@ -0,0 +1,1222 @@ +// SPDX-License-Identifier: BSD-3-Clause +// Copyright (c) 2026, The OpenROAD Authors + +// The 2D layout view, drawn with deck.gl. +// +// Owns the Deck, the view state and its animations, the tile slots (each a +// TileGrid over a tile source, all changing zoom level together through one +// ZoomSwap), the client-side shapes (selection outline, hover, rulers), DOM +// markers and image overlays. The rest of the app talks to it through the +// methods returned by createLayoutView; nothing outside reads deck directly. +// +// World coordinates are view-math's: CSS px at zoom 0, y up, tile grid [0, T]. + +import { + clampZoom, fitView, flyPath, growRange, growRect, project, rectsOverlap, + snapTarget, + tileRange, tileWorldBounds, tileZoomFor, unproject, viewWorldRect, + zoomAround as zoomAroundTarget, +} from './view-math.js'; +import { TileGrid, tileKey } from './tile-grid.js'; +import { copyToCanvas2d } from './tile-sources.js'; +import { rafCoalesce } from './ui-utils.js'; +import { ZoomSwap } from './zoom-swap.js'; + +// Bottom to top. +export const DRAW_ORDER = Object.freeze({ + base: 10, overlay: 20, heatmap: 30, top: 40, pathImage: 50, + selection: 60, highlight: 70, ruler: 80, +}); + +// Layers stack in list order, never by depth. +const noDepth = { depthCompare: 'always', depthWriteEnabled: false }; + +const ANIMATION_MS = 250; // zoom and pan duration +const kMaxAnimatedZoomDelta = 4; // larger jumps are not animated +const kInertiaMs = 300; +// The level above is kept loaded this many views around the view, so a zoom +// out around any point finds its tiles there. +const kPrefetchMargin = 1; +// Jumps further than this many views, or than kMaxAnimatedZoomDelta, fly. +const kFlightViews = 2; +const kFlightWaitMs = 300; // longest wait for the apex level +const kFlightMsPerS = 300; // per unit of flyPath length +const kFlightMinMs = 400; +const kFlightMaxMs = 1000; +const kInertiaWindowMs = 100; // drag samples that set the speed +const kInertiaMinSpeed = 0.05; // px/ms; slower releases just stop +const kFlashMs = 1200; // three 400 ms pulses +const kMaxTileZoom = 30; + +// '#rgb', '#rrggbb' or [r, g, b(, a)] to [r, g, b, a] with alpha 0..255. +export function toRgba(color, opacity = 1) { + if (Array.isArray(color)) { + const a = color.length > 3 ? color[3] : 255; + return [color[0], color[1], color[2], Math.round(a * opacity)]; + } + let hex = String(color || '#000').replace('#', ''); + if (hex.length === 3) { + hex = hex.split('').map((c) => c + c).join(''); + } + const n = parseInt(hex.slice(0, 6), 16) || 0; + return [(n >> 16) & 255, (n >> 8) & 255, n & 255, Math.round(255 * opacity)]; +} + +function easeOut(t) { + // Close to cubic-bezier(0, 0, 0.25, 1). + return 1 - Math.pow(1 - t, 3); +} + +function easeInOut(t) { + return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(2 - 2 * t, 3) / 2; +} + +function makeEmitter() { + const handlers = new Map(); + return { + on(types, fn) { + for (const type of types.split(/\s+/)) { + if (!handlers.has(type)) { + handlers.set(type, new Set()); + } + handlers.get(type).add(fn); + } + }, + off(types, fn) { + for (const type of types.split(/\s+/)) { + handlers.get(type)?.delete(fn); + } + }, + emit(type, payload) { + for (const fn of [...(handlers.get(type) || [])]) { + fn(payload); + } + }, + }; +} + +// `opts`: +// deckApi the deck.gl namespace (window.deck); a missing one leaves a view +// that keeps its state but draws nothing +// prefs { smooth(), doubleBuffer(), defer() }, read live +// tileSize() CSS px of a tile; dpr() the device pixel ratio +// isStatic a saved report: no touch zoom +// raf, now injectable for tests +export function createLayoutView(container, opts = {}) { + const deckApi = opts.deckApi !== undefined ? opts.deckApi : globalThis.deck; + const copyCanvas = opts.copyCanvas || copyToCanvas2d; + const prefs = { + smooth: () => false, doubleBuffer: () => true, defer: () => false, + ...(opts.prefs || {}), + }; + const tileSize = opts.tileSize || (() => 240); + const dpr = opts.dpr || (() => (typeof devicePixelRatio === 'number' + ? devicePixelRatio : 1)); + const raf = opts.raf || ((fn) => requestAnimationFrame(fn)); + const now = opts.now || (() => performance.now()); + const events = makeEmitter(); + + const vs = { target: [0, 0], zoom: 0, width: 1, height: 1 }; + const limits = { minZoom: -Infinity, maxZoom: kMaxTileZoom }; + let anim = null; // { from, to, anchor, start, ms } + let interacting = false; // a drag or pinch from the controller + let afterFrame = []; // called once deck has drawn its next frame + let dragSamples = []; // { t, target, zoom } while interacting + let prefetchZ = null; // level loaded in the background for a zoom out + let flightTrail = null; // a landed flight's pulled-out level, kept under + // the view until the destination level shows + let prefetchPending = false; + let moving = false; // between movestart and moveend + let flashUntil = 0; + const cursorModes = new Set(); // 'ruler', 'label' + let destroyed = false; + + // ─── DOM ──────────────────────────────────────────────────────────── + container.classList.add('or-view'); + const canvasWrap = document.createElement('div'); + canvasWrap.className = 'or-view-canvas'; + container.appendChild(canvasWrap); + const markerLayer = document.createElement('div'); + markerLayer.className = 'or-view-markers'; + container.appendChild(markerLayer); + + // ─── Slots, shapes, markers ───────────────────────────────────────── + const slots = new Map(); // id -> slot + const overlays = new Map(); // id -> its layer specs + const images = new Map(); // id -> its layer spec + const markers = new Map(); // group -> { visible, items: Map id -> m } + let textures = new WeakMap(); // drawable -> texture on the current device + let doomedTextures = []; + + // One render per frame, however many changes ask for one. + const scheduleRender = rafCoalesce(render, raf); + + const swap = new ZoomSwap({ + isEnabled: () => prefs.doubleBuffer(), + isSmooth: () => prefs.smooth(), + now, + onChange: () => scheduleRender(), + }); + + // ─── Deck ─────────────────────────────────────────────────────────── + let deckgl = null; + function controllerProps() { + return { + dragPan: true, + dragRotate: false, + scrollZoom: false, + doubleClickZoom: false, + touchZoom: !opts.isStatic, + touchRotate: false, + keyboard: false, + // Inertia is startInertia's: deck's own only runs if its + // transition props come back through the controlled viewState. + inertia: false, + }; + } + function deckViewState() { + return { target: [vs.target[0], vs.target[1], 0], zoom: vs.zoom, + minZoom: limits.minZoom, maxZoom: limits.maxZoom }; + } + function createDeck() { + return new deckApi.Deck({ + parent: canvasWrap, + views: new deckApi.OrthographicView({ + id: 'main', flipY: false, controller: controllerProps(), + }), + viewState: deckViewState(), + layers: [], + useDevicePixels: true, + // Save image copies the frame as it is drawn; keeping the buffer + // readable outside it is for probes (?preservebuffer=1). + deviceProps: { webgl: { + preserveDrawingBuffer: !!opts.preserveDrawingBuffer } }, + getCursor: ({ isDragging }) => { + if (cursorModes.size) { + return 'crosshair'; + } + return isDragging ? 'grabbing' : 'default'; + }, + onViewStateChange: ({ viewState }) => { + anim = null; + setViewState(viewState.target, viewState.zoom); + if (interacting) { + const t = now(); + dragSamples.push({ t, target: [...vs.target], + zoom: vs.zoom }); + dragSamples = dragSamples.filter( + (d) => t - d.t <= kInertiaWindowMs); + } + return deckViewState(); + }, + onInteractionStateChange: (state) => { + const busy = !!(state.isDragging || state.isPanning + || state.isZooming || state.inTransition); + if (busy === interacting) { + return; + } + interacting = busy; + if (busy) { + dragSamples = []; + startMove(); + return; + } + // deck reports the end before the view state that goes with + // it, and that update would cancel the glide. + queueMicrotask(() => { + if (!interacting && !anim && !startInertia()) { + settleView(); + } + }); + }, + // The canvas only exists once the device is up. + onLoad: () => { + watchContext(); + scheduleRender(); + }, + onAfterRender: () => { + const waiting = afterFrame; + afterFrame = []; + waiting.forEach((fn) => fn()); + }, + }); + } + + // A lost WebGL context takes every texture with it. A new Deck gets a + // new canvas and context; the tiles' images are still here, so their + // textures are rebuilt from them and nothing is re-requested. + function watchContext() { + const canvas = deckgl.getCanvas && deckgl.getCanvas(); + canvas?.addEventListener('webglcontextlost', (e) => { + e.preventDefault(); + if (destroyed) { + return; + } + events.emit('contextlost'); + const old = deckgl; + deckgl = null; + textures = new WeakMap(); + doomedTextures = []; + try { + old.finalize?.(); + } catch (err) { + // The old device is already gone. + } + canvas.remove(); + try { + deckgl = createDeck(); + events.emit('contextrestored'); + } catch (err) { + events.emit('contextfailed', err); + } + scheduleRender(); + }); + } + + if (deckApi && typeof deckApi.Deck === 'function') { + deckgl = createDeck(); + } + + // ─── Size ─────────────────────────────────────────────────────────── + // The canvas is sized to whole device pixels so tiles map 1:1 at rest. + function measure() { + const r = dpr(); + const w = Math.max(1, Math.floor(container.clientWidth * r) / r); + const h = Math.max(1, Math.floor(container.clientHeight * r) / r); + const changed = w !== vs.width || h !== vs.height; + vs.width = w; + vs.height = h; + canvasWrap.style.width = w + 'px'; + canvasWrap.style.height = h + 'px'; + return changed; + } + measure(); + let resizeObserver = null; + if (typeof ResizeObserver === 'function') { + resizeObserver = new ResizeObserver(() => invalidateSize()); + resizeObserver.observe(container); + } + + function invalidateSize() { + if (measure()) { + applyView(); + events.emit('resize', getSize()); + } else { + scheduleRender(); + } + } + + // ─── View state ───────────────────────────────────────────────────── + function setViewState(target, zoom, { tiles = true } = {}) { + const z = clampZoom(zoom, limits); + const zoomChanged = z !== vs.zoom; + vs.target = [target[0], target[1]]; + vs.zoom = z; + applyView(zoomChanged, tiles); + } + + function applyView(zoomChanged = false, tiles = true) { + if (deckgl) { + deckgl.setProps({ viewState: deckViewState() }); + } + if (zoomChanged) { + events.emit('zoom'); + } + events.emit('move'); + if (tiles) { + updateTiles(); + } + scheduleRender(); + } + + function startMove() { + if (!moving) { + moving = true; + events.emit('movestart'); + } + } + + function settleView() { + if (anim || interacting) { + return; + } + // Touch zoom can leave a fractional level; rest on a whole one. + const whole = Math.round(vs.zoom); + if (Math.abs(whole - vs.zoom) > 1e-9) { + animateTo({ target: zoomAroundTarget(vs, [vs.width / 2, + vs.height / 2], whole), + zoom: whole }, { anchor: null }); + return; + } + vs.target = snapTarget(vs, dpr()); + const ended = moving; + moving = false; // at rest before the tile update: z-1 may load + applyView(); + if (ended) { + events.emit('moveend'); + events.emit('zoomend'); + } + } + + // A drag released while moving glides on, slowing to a stop. + function startInertia() { + const samples = dragSamples; + dragSamples = []; + if (!prefs.smooth() || samples.length < 2) { + return false; + } + const first = samples[0]; + const last = samples[samples.length - 1]; + const dt = last.t - first.t; + if (dt <= 0 || now() - last.t > kInertiaWindowMs + || first.zoom !== last.zoom) { + return false; + } + const vx = (last.target[0] - first.target[0]) / dt; + const vy = (last.target[1] - first.target[1]) / dt; + if (Math.hypot(vx, vy) * Math.pow(2, vs.zoom) < kInertiaMinSpeed) { + return false; + } + // Same reach as deck's inertia: half the release speed for its length. + animateTo({ target: [vs.target[0] + vx * kInertiaMs / 2, + vs.target[1] + vy * kInertiaMs / 2], + zoom: vs.zoom }, { ms: kInertiaMs }); + return true; + } + + function animationMs(to) { + if (!prefs.smooth()) { + return 0; + } + if (Math.abs(to.zoom - vs.zoom) > kMaxAnimatedZoomDelta) { + return 0; + } + return ANIMATION_MS; + } + + // Move to `to` = { target, zoom }, animated when smoothing is on. With + // `anchor` (a screen point) the world point under it stays still. + // `settle: false` leaves a jump unsettled, mid-gesture. `curve` lets a + // long jump fly (flyPath) instead of sliding or cutting. + function animateTo(to, { anchor = null, ms = undefined, settle = true, + curve = false } = {}) { + to = { target: to.target, zoom: clampZoom(to.zoom, limits) }; + const flight = curve && ms === undefined ? planFlight(to) : null; + if (ms === undefined) { + ms = flight ? flight.ms : animationMs(to); + } + startMove(); + if (to.zoom !== vs.zoom) { + events.emit('zoomstart'); + } + if (ms <= 0) { + anim = null; + // settleView updates the tiles once, at rest: an update while + // moving would cancel the z-1 prefetch just to request it again. + const atRest = settle && !interacting; + setViewState(to.target, to.zoom, { tiles: !atRest }); + if (settle) { + settleView(); + } + return; + } + // A flight starts once the level it pulls out to has arrived. + flightTrail = null; + anim = { from: { ...vs, target: [...vs.target] }, to, anchor, + start: flight ? null : now(), created: now(), ms, flight }; + updateTiles(); + stepAnimation(); + } + + // The path, duration and pulled-out level of a jump far enough to fly, + // or null. + function planFlight(to) { + if (!prefs.smooth()) { + return null; + } + const dist = Math.hypot(to.target[0] - vs.target[0], + to.target[1] - vs.target[1]); + const far = dist * Math.pow(2, Math.min(vs.zoom, to.zoom)) + > kFlightViews * Math.max(vs.width, vs.height); + if (!far && Math.abs(to.zoom - vs.zoom) <= kMaxAnimatedZoomDelta) { + return null; + } + const path = flyPath(vs, { ...vs, ...to }); + let zMin = Infinity; + let rect = null; + for (let i = 0; i <= 16; i++) { + const p = path.at(i / 16); + zMin = Math.min(zMin, p.zoom); + const r = viewWorldRect({ ...vs, ...p }); + rect = rect ? [Math.min(rect[0], r[0]), Math.min(rect[1], r[1]), + Math.max(rect[2], r[2]), Math.max(rect[3], r[3])] + : r; + } + const z = Math.max(0, tileZoomFor(zMin)); + const range = tileRange(rect, z, tileSize()); + return { + path, + ms: Math.min(kFlightMaxMs, Math.max(kFlightMinMs, + kFlightMsPerS * path.S)), + apex: range ? { z, range } : null, + }; + } + + function apexReady(apex) { + return !apex || [...slots.values()].every( + (slot) => !slot.visible || slot.grid.settledIn(apex.z, apex.range)); + } + + function stepAnimation() { + if (!anim || destroyed) { + return; + } + if (anim.start === null) { + if (!apexReady(anim.flight.apex) + && now() - anim.created < kFlightWaitMs) { + raf(stepAnimation); + return; + } + anim.start = now(); + } + const t = Math.min(1, (now() - anim.start) / anim.ms); + const e = easeOut(t); + let zoom = anim.from.zoom + (anim.to.zoom - anim.from.zoom) * e; + let target; + if (anim.flight) { + ({ target, zoom } = anim.flight.path.at(easeInOut(t))); + } else if (anim.anchor) { + target = zoomAroundTarget(anim.from, anim.anchor, zoom); + } else { + target = [anim.from.target[0] + (anim.to.target[0] + - anim.from.target[0]) * e, + anim.from.target[1] + (anim.to.target[1] + - anim.from.target[1]) * e]; + } + if (t >= 1) { + const to = anim.to; + flightTrail = anim.flight ? anim.flight.apex : null; + anim = null; + setViewState(to.target, to.zoom); + settleView(); + return; + } + setViewState(target, zoom); + raf(stepAnimation); + } + + // ─── Tiles ────────────────────────────────────────────────────────── + // The view the tiles are for: the destination of an animation. + function tileView() { + if (!anim) { + return vs; + } + return { ...vs, target: anim.to.target, zoom: anim.to.zoom }; + } + + function updateTiles() { + if (slots.size === 0) { + return; + } + const hiding = prefs.doubleBuffer(); + const z = clampZoom(tileZoomFor(vs.zoom, { + targetZoom: anim ? anim.to.zoom : null, + hidingNewLevels: hiding, + }), { minZoom: 0, maxZoom: kMaxTileZoom }); + const dest = tileView(); + const range = tileRange(viewWorldRect(dest), z, tileSize()); + const ring = growRange(range); + const shown = swap.shownZ; + const frozen = prefs.defer() && interacting; + // Frozen, the grids keep their old level, so the swap must too. + if (!frozen) { + swap.setZoom(z, { + hasContent: [...slots.values()].some( + (s) => s.visible && shown !== null + && s.grid.hasContentAt(shown)), + }); + } + // At rest only: it is background work and must not compete with the + // view while it moves. + const extra = []; + if (z > 0 && !anim && !interacting && !moving + && swap.pendingZ === null) { + prefetchZ = z - 1; + extra.push({ z: prefetchZ, range: tileRange( + growRect(viewWorldRect(dest), kPrefetchMargin), prefetchZ, + tileSize()) }); + } + const apex = flightApex(); + if (apex) { + extra.push({ ...apex, background: false }); + } + // On screen now, which differs from `range` while animating. + const hold = anim ? tileRange(viewWorldRect(vs), z, tileSize()) : null; + for (const slot of slots.values()) { + if (slot.visible && !frozen) { + slot.grid.update({ z, range, ring, extra, hold }); + } + } + checkSwap(); + } + + // The level a flight pulls out to, while it flies and until it lands. + function flightApex() { + return (anim && anim.flight && anim.flight.apex) || flightTrail; + } + + // Levels drawn under the shown ones where those have no tile: a flight's + // pulled-out level, then the level waiting to be revealed. + function underLevels(drawn) { + const out = []; + for (const z of [flightApex()?.z, swap.pendingZ]) { + if (z != null && !out.includes(z) + && !drawn.some((l) => l.z === z)) { + out.push(z); + } + } + return out; + } + + // Once a level change has landed, fetch the level above it too. + function schedulePrefetch() { + if (prefetchPending) { + return; + } + prefetchPending = true; + queueMicrotask(() => { + prefetchPending = false; + if (!destroyed) { + updateTiles(); + } + }); + } + + function allSettled() { + for (const slot of slots.values()) { + if (slot.visible && !slot.grid.isSettled()) { + return false; + } + } + return true; + } + + function checkSwap(tile) { + const changed = swap.check({ settled: allSettled(), animating: !!anim }); + if (changed && swap.pendingZ === null) { + schedulePrefetch(); + } + let landed = false; + if (flightTrail && !anim && swap.isIdle() && allSettled()) { + flightTrail = null; + landed = true; + } + // A tile of a level not drawn (the prefetch) changes nothing on screen. + if (changed || landed || !tile || drawsLevel(tile.z)) { + scheduleRender(); + } + } + + function drawsLevel(z) { + const drawn = swap.plan(now()).draw; + return drawn.some((l) => l.z === z) || underLevels(drawn).includes(z); + } + + function addTileSlot(id, { order, source, visible = true }) { + const wrapped = { + load: (coords, o) => source.load(coords, o), + release: (drawable) => { + const tex = drawable && textures.get(drawable); + if (tex) { + textures.delete(drawable); + doomedTextures.push(tex); + } + source.release?.(drawable); + }, + }; + const slot = { + id, order, visible, + grid: new TileGrid({ source: wrapped, + onChange: (tile) => checkSwap(tile) }), + }; + slots.set(id, slot); + updateTiles(); + return { + id, + setVisible(v) { + if (slot.visible === !!v) { + return; + } + slot.visible = !!v; + if (!slot.visible) { + slot.grid.clear(); + } + updateTiles(); + }, + isVisible: () => slot.visible, + refresh() { + if (slot.visible) { + slot.grid.refresh(); + scheduleRender(); + } + }, + remove() { + slot.grid.clear(); + slots.delete(id); + scheduleRender(); + }, + }; + } + + function textureFor(drawable) { + if (!deckgl || !deckgl.device) { + return drawable.image; + } + let tex = textures.get(drawable); + if (!tex) { + try { + tex = deckgl.device.createTexture({ + data: drawable.image, + width: drawable.width, + height: drawable.height, + mipLevels: 1, + sampler: { minFilter: 'linear', magFilter: 'linear', + addressModeU: 'clamp-to-edge', + addressModeV: 'clamp-to-edge' }, + }); + } catch (e) { + return drawable.image; + } + textures.set(drawable, tex); + } + return tex; + } + + // ─── Rendering ────────────────────────────────────────────────────── + function flashFactor(t) { + if (t >= flashUntil) { + return 1; + } + const phase = ((kFlashMs - (flashUntil - t)) % 400) / 400; + return 1 - 0.7 * (0.5 - 0.5 * Math.cos(2 * Math.PI * phase)); + } + + // World bounds per tile object: a tile keeps its z, x and y. + let tileBounds = new WeakMap(); + let tileBoundsSize = null; + function boundsOf(tile) { + const T = tileSize(); + if (T !== tileBoundsSize) { + tileBounds = new WeakMap(); + tileBoundsSize = T; + } + let bounds = tileBounds.get(tile); + if (!bounds) { + bounds = tileWorldBounds(tile.z, tile.x, tile.y, T); + tileBounds.set(tile, bounds); + } + return bounds; + } + + // A layer for each drawn tile of `slot` at level z that overlaps `view`; + // `tag` keeps the ids of the tiles under the shown levels apart. + function pushTileLayers(out, slot, z, view, tag, opacity) { + for (const tile of slot.grid.drawableTilesAt(z)) { + const bounds = boundsOf(tile); + if (rectsOverlap(bounds, view)) { + out.push({ order: slot.order, props: { + id: `${slot.id}:${tag}${tile.key}`, + image: textureFor(tile.drawable), bounds, opacity, + parameters: noDepth, + } }); + } + } + } + + function tileLayers(t, view) { + const out = []; + const plan = swap.plan(t); + if (!plan.fading && swap.pendingZ === null && plan.draw.length > 0) { + const keep = [...plan.draw.map((l) => l.z), prefetchZ, + flightApex()?.z].filter((z) => z != null); + for (const slot of slots.values()) { + slot.grid.prune(keep); + } + } + const flash = flashFactor(t); + const ordered = [...slots.values()].sort((a, b) => a.order - b.order); + const bottom = ordered.find((slot) => slot.visible); + const under = underLevels(plan.draw); + for (const slot of ordered) { + if (!slot.visible) { + continue; + } + if (slot === bottom && under.length > 0) { + out.push(...underlay(slot, under, plan.draw, view, flash)); + } + for (const level of plan.draw) { + pushTileLayers(out, slot, level.z, view, '', + level.opacity * flash); + } + } + return { layers: out, animate: plan.fading || t < flashUntil }; + } + + // While hidden levels load, their tiles fill what the shown levels do not + // cover, such as the new edges of a zoom out. A mask in the background + // colour keeps them from showing through the shown tiles' clear pixels. + function underlay(slot, zs, levels, view, flash) { + const out = []; + for (const z of zs) { + pushTileLayers(out, slot, z, view, 'under:', flash); + } + if (out.length === 0) { + return out; + } + // One CSS px of overlap, so no seam opens between two masks. + const pad = 1 / Math.pow(2, vs.zoom); + const masks = []; + for (const tile of slot.grid.tiles.values()) { + if (!levels.some((l) => l.z === tile.z) + || (tile.loading && !tile.drawable)) { + continue; + } + const bounds = boundsOf(tile); + if (rectsOverlap(bounds, view)) { + const [x0, y0, x1, y1] = bounds; + masks.push([[x0 - pad, y0 - pad], [x1 + pad, y0 - pad], + [x1 + pad, y1 + pad], [x0 - pad, y1 + pad]]); + } + } + if (masks.length) { + out.push({ order: slot.order, kind: 'SolidPolygonLayer', props: { + id: `${slot.id}:mask`, data: masks, + getPolygon: (d) => d, getFillColor: backgroundRgba(), + parameters: noDepth, + } }); + } + return out; + } + + function backgroundRgba() { + const m = (getComputedStyle(container).backgroundColor || '') + .match(/[\d.]+/g); + if (!m || m.length < 3 || (m.length > 3 && Number(m[3]) === 0)) { + return [0, 0, 0, 255]; + } + return [Number(m[0]), Number(m[1]), Number(m[2]), 255]; + } + + // The layer specs of one overlay, built when it is set so deck keeps the + // same data until the shapes change. + function overlaySpecs(id, shapes, order) { + const out = []; + const fills = []; + const strokes = []; + const circles = []; + for (const s of shapes) { + if (s.kind === 'circle') { + circles.push(s); + continue; + } + const pts = s.kind === 'rect' + ? [[s.rect[0], s.rect[1]], [s.rect[2], s.rect[1]], + [s.rect[2], s.rect[3]], [s.rect[0], s.rect[3]]] + : s.points; + if (s.fill) { + fills.push({ polygon: pts, color: s.fill }); + } + if (s.stroke) { + const closed = s.kind === 'rect' || s.closed; + strokes.push({ path: closed ? [...pts, pts[0]] : pts, + color: s.stroke, width: s.width || 1, + dash: s.dash || null }); + } + } + if (fills.length) { + out.push({ order, kind: 'SolidPolygonLayer', props: { + id: `${id}:fill`, data: fills, + getPolygon: (d) => d.polygon, getFillColor: (d) => d.color, + parameters: noDepth, + } }); + } + const solid = strokes.filter((d) => !d.dash); + const dashed = strokes.filter((d) => d.dash); + if (solid.length) { + out.push({ order, kind: 'PathLayer', props: { + id: `${id}:stroke`, data: solid, widthUnits: 'pixels', + getPath: (d) => d.path, getColor: (d) => d.color, + getWidth: (d) => d.width, + parameters: noDepth, + } }); + } + if (dashed.length) { + const props = { + id: `${id}:dash`, data: dashed, widthUnits: 'pixels', + getPath: (d) => d.path, getColor: (d) => d.color, + getWidth: (d) => d.width, + // The extension counts dashes in line widths. + getDashArray: (d) => d.dash.map((v) => v / d.width), + dashJustified: true, + parameters: noDepth, + }; + if (deckApi?.PathStyleExtension) { + props.extensions = [ + new deckApi.PathStyleExtension({ dash: true })]; + } + out.push({ order, kind: 'PathLayer', props }); + } + if (circles.length) { + out.push({ order, kind: 'ScatterplotLayer', props: { + id: `${id}:circle`, data: circles, + radiusUnits: 'pixels', lineWidthUnits: 'pixels', + getPosition: (d) => d.center, getRadius: (d) => d.radius, + stroked: true, filled: true, + getLineColor: (d) => d.stroke || [0, 0, 0, 0], + getFillColor: (d) => d.fill || [0, 0, 0, 0], + getLineWidth: (d) => d.width || 1, + parameters: noDepth, + } }); + } + return out; + } + + function shapeLayers() { + const out = []; + for (const specs of overlays.values()) { + out.push(...specs); + } + out.push(...images.values()); + return out; + } + + function buildDeckLayers(specs) { + return specs.map( + (spec) => new deckApi[spec.kind || 'BitmapLayer'](spec.props)); + } + + let lastLayerCount = 0; + function render() { + if (destroyed) { + return; + } + const t = now(); + // deck may draw a new view state before this runs again, so tiles + // half a view off screen are kept: a pan or a one-level zoom out + // then finds them already there. + const tiles = tileLayers(t, growRect(viewWorldRect(vs), 0.5)); + const specs = [...tiles.layers, ...shapeLayers()] + .sort((a, b) => a.order - b.order); + lastLayerCount = specs.length; + if (deckgl) { + deckgl.setProps({ layers: buildDeckLayers(specs) }); + } + for (const tex of doomedTextures.splice(0)) { + tex.destroy?.(); + } + positionMarkers(); + if (tiles.animate) { + scheduleRender(); + } + events.emit('render'); + } + + // Share of the view inside the tile grid that shows a settled base tile + // of a level being drawn: the browser probes' blank metric. + function coverage(nx = 32, ny = 20) { + const slot = slots.get('base'); + if (!slot) { + return null; + } + const T = tileSize(); + const drawn = swap.plan(now()).draw; + const levels = [...drawn, ...underLevels(drawn).map((z) => ({ z }))]; + let inGrid = 0; + let shown = 0; + for (let j = 0; j < ny; j++) { + for (let i = 0; i < nx; i++) { + const [wx, wy] = unproject([(i + 0.5) * vs.width / nx, + (j + 0.5) * vs.height / ny], vs); + if (wx < 0 || wy < 0 || wx >= T || wy >= T) { + continue; + } + inGrid++; + const hit = levels.some(({ z }) => { + const S = T / 2 ** z; + const tile = slot.grid.tiles.get(tileKey( + z, Math.floor(wx / S), Math.floor((T - wy) / S))); + return tile && (tile.drawable || !tile.loading); + }); + if (hit) { + shown++; + } + } + } + return inGrid ? shown / inGrid : null; + } + + // ─── Markers ──────────────────────────────────────────────────────── + function markerGroup(group) { + if (!markers.has(group)) { + markers.set(group, { visible: true, items: new Map() }); + } + return markers.get(group); + } + + function placeMarker(m, visible) { + const [x, y] = project(m.world, vs); + m.el.style.display = visible ? '' : 'none'; + m.el.style.transform = `translate(${x}px, ${y}px)` + + (m.center ? ' translate(-50%, -50%)' : ''); + } + + function placeGroup(g) { + for (const m of g.items.values()) { + placeMarker(m, g.visible); + } + } + + function positionMarkers() { + for (const g of markers.values()) { + placeGroup(g); + } + } + + // ─── Public API ───────────────────────────────────────────────────── + function getSize() { + return { width: vs.width, height: vs.height }; + } + + const view = { + DRAW_ORDER, + getContainer: () => container, + getSize, + getZoom: () => vs.zoom, + // The zoom an animation in flight will end on. + getTargetZoom: () => (anim ? anim.to.zoom : vs.zoom), + getCenter: () => [...vs.target], + getViewState: () => ({ ...vs, target: [...vs.target] }), + isAnimating: () => !!anim, + isMoving: () => moving, + project: (w) => project(w, vs), + unproject: (p) => unproject(p, vs), + on: events.on, + off: events.off, + + setLimits({ minZoom, maxZoom } = {}) { + if (minZoom !== undefined) { + limits.minZoom = minZoom; + } + if (maxZoom !== undefined) { + limits.maxZoom = maxZoom; + } + const z = clampZoom(vs.zoom, limits); + if (z !== vs.zoom) { + setViewState(vs.target, z); + } else if (deckgl) { + deckgl.setProps({ viewState: deckViewState() }); + } + events.emit('limits'); + }, + getLimits: () => ({ ...limits }), + + setView(center, zoom = vs.zoom, { animate } = {}) { + const to = { target: [center[0], center[1]], zoom }; + animateTo(to, animate === false ? { ms: 0 } : { curve: true }); + }, + + fitWorldRect(rect, { padding = [0, 0], animate } = {}) { + const fit = fitView(rect, vs, { padding, ...limits }); + animateTo(fit, animate === false ? { ms: 0 } : { curve: true }); + }, + + // Zoom by `delta` levels from the level an animation is heading to, + // keeping the point under `screenPt` still (the centre when null). + // `settle: false` (with `animate: false`) keeps a fractional zoom for + // a gesture still under way; a later call settles it. + zoomAround(screenPt, delta, { animate, settle = true } = {}) { + const zoom = clampZoom(view.getTargetZoom() + delta, limits); + const base = tileView(); + const pt = screenPt || [vs.width / 2, vs.height / 2]; + const target = zoomAroundTarget(base, pt, zoom); + animateTo({ target, zoom }, + animate === false ? { ms: 0, settle } : { anchor: screenPt + ? pt : null }); + }, + zoomIn: () => view.zoomAround(null, 1), + zoomOut: () => view.zoomAround(null, -1), + + panByPx(dx, dy, { animate } = {}) { + const base = tileView(); + const s = Math.pow(2, base.zoom); + const target = [base.target[0] + dx / s, base.target[1] - dy / s]; + const ms = (animate === false || !prefs.smooth()) ? 0 : ANIMATION_MS; + animateTo({ target, zoom: base.zoom }, { ms }); + }, + + invalidateSize, + // The preferences are read live; re-plan the tiles for defer and + // double buffering. + applyPrefs() { + updateTiles(); + }, + + addTileSlot, + + setOverlay(id, shapes, { order = DRAW_ORDER.selection } = {}) { + if (!shapes || shapes.length === 0) { + overlays.delete(id); + } else { + overlays.set(id, overlaySpecs(id, shapes, order)); + } + scheduleRender(); + }, + hasOverlay: (id) => overlays.has(id), + + setImageOverlay(id, spec, { order = DRAW_ORDER.pathImage } = {}) { + if (!spec) { + images.delete(id); + } else { + images.set(id, { order, kind: 'BitmapLayer', props: { + id: `image:${id}`, image: spec.image, bounds: spec.rect, + parameters: noDepth, + } }); + } + scheduleRender(); + }, + + // A DOM element pinned to a world point: its top-left corner, or its + // centre with `center`. + addMarker(group, id, world, el, { center = false } = {}) { + const g = markerGroup(group); + const old = g.items.get(id); + if (old) { + old.el.remove(); + } + el.classList.add('or-view-marker'); + markerLayer.appendChild(el); + const m = { el, world: [world[0], world[1]], center }; + g.items.set(id, m); + placeMarker(m, g.visible); + return el; + }, + moveMarker(group, id, world) { + const g = markerGroup(group); + const m = g.items.get(id); + if (m) { + m.world = [world[0], world[1]]; + placeMarker(m, g.visible); + } + }, + clearMarkers(group) { + const g = markerGroup(group); + for (const m of g.items.values()) { + m.el.remove(); + } + g.items.clear(); + }, + setMarkerGroupVisible(group, visible) { + const g = markerGroup(group); + g.visible = !!visible; + placeGroup(g); + }, + + // The ruler and label tools each hold a crosshair mode. + setCursorMode(mode, on = true) { + if (on) { + cursorModes.add(mode); + } else { + cursorModes.delete(mode); + } + container.classList.toggle(`${mode}-mode-cursor`, !!on); + // deck sets the cursor on its canvas from getCursor, but only on + // the next pointer event; apply the change now. + const canvas = deckgl && deckgl.getCanvas && deckgl.getCanvas(); + if (canvas) { + canvas.style.cursor = cursorModes.size ? 'crosshair' : 'default'; + } + }, + + // The DRC widget's attention pulse on the tiles. + flashTiles() { + flashUntil = now() + kFlashMs; + scheduleRender(); + }, + + // Resolves once every visible slot has loaded what is on screen and + // no level change or animation is in progress. + whenTilesSettled({ timeoutMs = 6000 } = {}) { + const deadline = now() + timeoutMs; + return new Promise((resolve) => { + const poll = () => { + if ((allSettled() && swap.isIdle() && !anim && !moving) + || now() >= deadline) { + resolve(); + return; + } + setTimeout(poll, 32); + }; + poll(); + }); + }, + + // `{ image, rect }`: a copy of the frame with the current layers and + // where the canvas sits, for Save image. deck applies new layers in + // its own frame, so wait for one and copy it while it is drawn. + captureCanvas({ timeoutMs = 500 } = {}) { + if (!deckgl?.getCanvas()) { + return Promise.resolve(null); + } + render(); + return new Promise((resolve) => { + let timer = null; + const done = () => { + clearTimeout(timer); + afterFrame = afterFrame.filter((fn) => fn !== done); + const canvas = deckgl?.getCanvas(); + resolve(canvas ? { image: copyCanvas(canvas), + rect: canvas.getBoundingClientRect() } + : null); + }; + afterFrame.push(done); + // A hidden page gets no frames. + timer = setTimeout(() => { + deckgl?.redraw('capture'); + done(); + }, timeoutMs); + }); + }, + + redraw: () => scheduleRender(), + + debugSnapshot() { + const plan = swap.plan(); + return { + zoom: vs.zoom, target: [...vs.target], + width: vs.width, height: vs.height, + animating: !!anim, moving, interacting, + shownZ: swap.shownZ, pendingZ: swap.pendingZ, + fading: plan.fading, drawLevels: plan.draw, + layers: lastLayerCount, coverage: coverage(), + overlays: [...overlays.keys()], + markers: Object.fromEntries([...markers].map( + ([group, g]) => [group, g.items.size])), + slots: [...slots.values()].map((s) => ({ + id: s.id, visible: s.visible, settled: s.grid.isSettled(), + ...s.grid.stats(), + })), + }; + }, + + destroy() { + destroyed = true; + resizeObserver?.disconnect(); + swap.dispose(); + for (const slot of slots.values()) { + slot.grid.clear(); + } + deckgl?.finalize?.(); + }, + }; + return view; +} diff --git a/src/web/src/leaflet-global.js b/src/web/src/leaflet-global.js deleted file mode 100644 index fc7949fe92c..00000000000 --- a/src/web/src/leaflet-global.js +++ /dev/null @@ -1,7 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// Copyright (c) 2026, The OpenROAD Authors - -// Leaflet sets window.L as it loads; the entries import this module first. The -// modules using L read the global, so their unit tests can load them with no DOM. - -import 'leaflet'; diff --git a/src/web/src/main.js b/src/web/src/main.js index 9b4306ec962..ed5add178ca 100644 --- a/src/web/src/main.js +++ b/src/web/src/main.js @@ -2,19 +2,16 @@ // Copyright (c) 2026, The OpenROAD Authors import { GridLayoutManager } from './grid-layout.js'; -import { latLngToDbu, dbuToLatLng, dbuRectToBounds } from './coordinates.js'; +import { dbuToWorld, dbuRectToWorldRect, worldToDbu } from './coordinates.js'; import { WebSocketManager } from './websocket-manager.js'; +import { createLayoutView, DRAW_ORDER } from './layout-view.js'; +import { installViewInput } from './view-input.js'; import { - createWebSocketTileLayer, - createOverlayTileLayer, - currentDpr, - floorClampZoom, -} from './websocket-tile-layer.js'; -import { createMergedTileLayer } from './merged-tile-layer.js'; -import { installDeviceGridSnapping } from './device-pixels.js'; + buildHeatmapRequest, buildOverlayRequest, createImageSource, +} from './tile-sources.js'; import { - BLANK_TILE, tileSizeCss, useFittedTileSize, useStaticTileSize, - withDeviceExactTileSize, watchDevicePixelRatio, tileSizeFields, + nativeDpr, tileSizeCss, useFittedTileSize, useStaticTileSize, + watchDevicePixelRatio, } from './tile-request.js'; import { TimingWidget } from './timing-widget.js'; import { ClockTreeWidget } from './clock-tree-widget.js'; @@ -22,12 +19,11 @@ import { ChartsWidget } from './charts-widget.js'; import { HierarchyBrowser } from './hierarchy-browser.js'; import { createInspectorPanel } from './inspector.js'; import { SelectionBrowser } from './selection-browser.js'; -import { applyArrowStep, applySelectionFlags, beginSelection, boundsEqual, - buildMapOptions, buildVisibilityFlags, clampArrowStep, - computeBoundsTransforms, computeScaleBar, decorateTabIcons, - fittedTileSizeCss, formatDbu, formatDistance, installWheelPanning, - isCurrentSelection, isStaticMode, maxUsefulZoom, parseDbu, - rafCoalesce, showToast, unitLabel } +import { applySelectionFlags, beginSelection, boundsEqual, + buildVisibilityFlags, clampArrowStep, computeBoundsTransforms, + computeScaleBar, decorateTabIcons, fittedTileSizeCss, formatDbu, + formatDistance, isCurrentSelection, isStaticMode, maxUsefulZoom, + parseDbu, rafCoalesce, showToast, unitLabel } from './ui-utils.js'; import { clampFontScale, showAppFontDialog, showArrowStepDialog } from './options-dialogs.js'; @@ -88,8 +84,13 @@ function updateStatus() { // earns space on screen once the queue is long enough to be the // explanation for a viewer that feels stuck. if (pendingCount > PENDING_BACKLOG) { - statusDiv.innerHTML = '
pending: ${pendingCount}
`; + const text = `pending: ${pendingCount}`; + const shown = statusDiv.firstElementChild; + if (!shown?.classList.contains('pending-indicator') + || shown.textContent !== text) { + statusDiv.innerHTML = '
${text}
`; + } statusDiv.style.display = 'block'; } else { statusDiv.style.display = 'none'; @@ -106,9 +107,17 @@ function setTileProgress(pendingCount) { el.classList.toggle('active', pendingCount > 0); // The count is worth keeping for anyone diagnosing a slow server, just not // worth a chip on screen. - el.title = pendingCount > 0 ? `${pendingCount} tile requests pending` : ''; + const title = pendingCount > 0 + ? `${pendingCount} tile requests pending` : ''; + if (el.title !== title) { + el.title = title; + } } +// The manager reports every request, reply and cancel; the DOM needs one +// update per frame. +const scheduleUpdateStatus = rafCoalesce(updateStatus); + // ─── Component Factories ──────────────────────────────────────────────────── // Cookies hold values verbatim (their writers encode), and a CSS font stack @@ -130,18 +139,17 @@ function decodeCookie(value) { // Components receive this via closure now; when extracted to separate files // they'll receive it as an explicit parameter. const app = { - map: null, - // Zoom-to-fit box in latlng, Qt's 5% margin per dimension already added - // (computeBoundsTransforms). Anything wanting the design's own extent - // has to work from the DBU rects, not from this. - fitBounds: null, - lastSelectionBounds: null, // Leaflet bounds of the last selected object + view: null, // the layout view (layout-view.js) + // Zoom-to-fit rect in world units, Qt's 5% margin per dimension already + // added (computeBoundsTransforms). Anything wanting the design's own + // extent has to work from the DBU rects, not from this. + fitRect: null, + lastSelectionBounds: null, // DBU rect of the last selected object selHasInst: false, // selection contains any instance selHasNet: false, // selection contains any net displayControlsEl: null, allLayers: [], designScale: null, // pixels-per-DBU for coordinate conversion - designMaxDXDY: null, // max(width, height) in DBU for Y-axis mapping designOriginX: 0, // bounds.xMin() in DBU (tile grid origin) designOriginY: 0, // bounds.yMin() in DBU (tile grid origin) websocketManager: null, // set after construction below @@ -150,9 +158,7 @@ const app = { techData: null, inspectorEl: null, tclOutputEl: null, - highlightRect: null, - hoverHighlightLayer: null, - hoverHighlightPane: 'hover-highlight-pane', + // Draw-list items of the pseudo layers (display-controls.js). modulesLayer: null, pinsLayer: null, // [{ def, layer }] per overlay the tech response lists. @@ -173,7 +179,7 @@ const app = { visibleChiplets: null, // Per-layer fill pattern, keyed by raw tech-layer name → int matching the // server's FillPattern enum (1 = solid). Populated/persisted by - // display-controls.js and read lazily by websocket-tile-layer.js. + // display-controls.js and read lazily by tile-request.js. layerPatterns: {}, useTrueZ: getCookie('or_use_true_z') === '1', showDbu: getCookie('or_show_dbu') === '1', @@ -186,6 +192,17 @@ const app = { wheelZoom: getCookie('or_wheel_zoom') !== '0', // Qt's "Arrow keys scroll step", in CSS px. arrowStep: clampArrowStep(getCookie('or_arrow_step')), + // ── Rendering preferences (#11340) ── + // Animated zoom and pan, and drag inertia. On by default; off makes + // navigation jump the way Qt's does. + controlSmoothing: getCookie('or_control_smoothing') !== '0', + // Show new content only once it is complete — a tile's whole composite, + // and on a zoom the whole view (zoom-swap.js) — Qt's draw_pixmap_ model. + doubleBuffer: getCookie('or_double_buffer') !== '0', + // Hold tile requests until a drag ends rather than issuing a fresh batch + // every updateInterval while the pointer is down. Opt-in: it leaves the + // area a drag exposes empty until the button is released. + deferTileUpdates: getCookie('or_defer_tile_updates') === '1', // Qt's "Application font", split into the CSS family and a percentage // scale over the stylesheet's authored sizes. Empty family = the // stylesheet default. @@ -199,7 +216,7 @@ const app = { selectableLayers: new Set(), heatMapData: null, activeHeatMap: '', - heatMapLayer: null, + heatMapLayer: null, // the heat-map tile slot heatMapLegendEl: null, renderHeatMapControls: null, rulerManager: null, @@ -390,172 +407,59 @@ try { // Ignore malformed cookie. } -// `app` is forwarded so the tile layer can read app.visibleChiplets -// lazily on every request — the field is populated by display-controls -// once the server's tech metadata arrives. -const WebSocketTileLayer = createWebSocketTileLayer( - visibility, app.visibleLayerNames, selectability, app.selectableLayers, - app); - -// ─── Tile grouping ────────────────────────────────────────────────────────── -// -// One pane per tech layer per chiplet puts a multi-die design at ~97 panes and -// ~582 MB of decoded tile images, past the browser's ~458 MB ceiling, where -// Chrome discards decodes and the discarded regions paint white until something -// forces a full invalidation. Merging the routing layers into N canvas panes, -// N derived from a memory budget, bounds the total regardless of how many layers -// or chiplets the design has. -// -// ?mergetiles=0 legacy one-pane-per-layer, for A/B comparison -// ?tilebudget= override the budget (default 350 MB) -// ?mergegroups= pin N directly, bypassing the budget -(function configureTileMerging() { +// Debug switches for the view and its tiles: +// ?composite=1 composite runs of layers on the server (tile_group; +// default: one request per layer, merged in the browser) +// ?grouplayers= layers per server-composited group +// ?preservebuffer=1 keep the canvas readable between frames (probes) +(function configureViewDebug() { let params = null; try { params = new URLSearchParams(window.location.search); } catch (_) { - params = null; - } - const param = (name) => (params ? params.get(name) : null); - - app.mergeTiles = param('mergetiles') !== '0'; - const budgetMB = Number(param('tilebudget')); - if (Number.isFinite(budgetMB) && budgetMB > 0) { - app.tileBudgetBytes = Math.round(budgetMB * 1024 * 1024); + return; } - const groups = Number(param('mergegroups')); - if (Number.isFinite(groups) && groups > 0) { - app.mergeGroupCount = Math.floor(groups); + app.forceComposite = params.get('composite') === '1'; + app.preserveBuffer = params.get('preservebuffer') === '1'; + const groupLayers = Number(params.get('grouplayers')); + if (Number.isFinite(groupLayers) && groupLayers > 0) { + app.groupLayers = Math.floor(groupLayers); } - // display-controls reads dpr through app so it does not have to import a - // layer module just to size the memory budget. - app.tileDpr = currentDpr; - app.MergedTileLayer = createMergedTileLayer({ - visibility, - selectability, - visibleLayers: app.visibleLayerNames, - selectableLayers: app.selectableLayers, - app, - }, { dpr: currentDpr }); })(); -const HeatMapTileLayer = L.GridLayer.extend({ - initialize: function(websocketManager, appState, options) { - this._websocketManager = websocketManager; - this._appState = appState; - // Same grid as the layer tiles it is drawn over. - L.GridLayer.prototype.initialize.call( - this, withDeviceExactTileSize(options)); - }, - - // Upscale-only display, same as the layout tile layer: the map rests on - // integer zoom so heatmap tiles show 1:1 with no fractional rescaling. - _clampZoom: function(zoom) { - return L.GridLayer.prototype._clampZoom.call( - this, floorClampZoom(this, zoom)); - }, - - createTile: function(coords, done) { - const tile = document.createElement('img'); - tile.alt = ''; - tile.setAttribute('role', 'presentation'); - tile._tileDone = false; - tile.onload = () => { - if (tile.src && tile.src.startsWith('blob:')) { - URL.revokeObjectURL(tile.src); - } - if (!tile._tileDone) { - tile._tileDone = true; - done(null, tile); - } - }; - tile.onerror = () => { - if (!tile._tileDone) { - tile._tileDone = true; - done(new Error('heat map tile load error'), tile); - } - }; - - const active = this._appState.activeHeatMap; - if (!active) { - tile.src = BLANK_TILE; - return tile; - } - - this._websocketManager.request({ - type: 'heatmap_tile', - name: active, - z: coords.z, - x: coords.x, - y: coords.y, - // Sized like the layer tiles beneath it; without this the heat map - // is a 256 px image stretched over crisp layers on any HiDPI - // display. - ...tileSizeFields(currentDpr(), this.getTileSize().x), - }).then(blob => { - // A null payload is an empty response: the heat map has no - // populated bin in this tile, or the tile is off the grid. The - // 1x1 BLANK_TILE stands in rather than an object URL, so nothing - // is decoded and onload still fires to complete the tile. - tile.src = blob ? URL.createObjectURL(blob) : BLANK_TILE; - }).catch(() => { - tile.src = BLANK_TILE; - }); - return tile; - }, +// What every layout tile request reads lazily (tile-request.js): the +// visibility flags, visible layers and chiplets change after startup. +app.tileCtx = { + visibility, selectability, visibleLayers: app.visibleLayerNames, + selectableLayers: app.selectableLayers, app, +}; - refreshTiles: function() { - if (!this._map) return; - for (const key in this._tiles) { - const tileInfo = this._tiles[key]; - if (!tileInfo || !tileInfo.el) continue; - const tile = tileInfo.el; - const coords = tileInfo.coords; - const active = this._appState.activeHeatMap; - if (!active) { - // Release the decode before dropping it: turning the heat map - // off walks every tile on screen, so skipping this strands one - // object URL per tile. - if (tile.src && tile.src.startsWith('blob:')) { - URL.revokeObjectURL(tile.src); - } - tile.src = BLANK_TILE; - continue; - } - this._websocketManager.request({ - type: 'heatmap_tile', - name: active, - z: coords.z, - x: coords.x, - y: coords.y, - ...tileSizeFields(currentDpr(), this.getTileSize().x), - }).then(blob => { - if (tile.src && tile.src.startsWith('blob:')) { - URL.revokeObjectURL(tile.src); - } - // Null means the tile is empty now; assigning BLANK_TILE also - // drops whatever image it was holding, which matters when a - // refresh follows an edit that emptied a bin. - tile.src = blob ? URL.createObjectURL(blob) : BLANK_TILE; - }).catch(() => { - tile.src = BLANK_TILE; - }); - } - }, -}); +// The heat map: one server image per tile, drawn over the layout and only +// while a heat map is active. +function createHeatMapSlot() { + return app.view.addTileSlot('heatmap', { + order: DRAW_ORDER.heatmap, + visible: !!app.activeHeatMap, + source: createImageSource({ + wm: app.websocketManager, + dpr: nativeDpr, + tileSize: tileSizeCss, + buildRequest: (c, dpr, t) => buildHeatmapRequest(c, dpr, t, app), + }), + }); +} function updateHeatMaps(data) { app.heatMapData = data; app.activeHeatMap = data.active || ''; if (app.heatMapLayer) { - if (app.activeHeatMap) { - if (!app.map.hasLayer(app.heatMapLayer)) { - app.heatMapLayer.addTo(app.map); - } - } else if (app.map.hasLayer(app.heatMapLayer)) { - app.map.removeLayer(app.heatMapLayer); + // Turning visible already requests the tiles; refresh only a map + // that was on screen and may have changed. + const wasVisible = app.heatMapLayer.isVisible(); + app.heatMapLayer.setVisible(!!app.activeHeatMap); + if (wasVisible) { + app.heatMapLayer.refresh(); } - app.heatMapLayer.refreshTiles(); } if (app.renderHeatMapControls) { app.renderHeatMapControls(data); @@ -568,7 +472,7 @@ app.updateHeatMaps = updateHeatMaps; // geometry tiles are not re-rendered. function refreshOverlay() { if (app.overlayLayer) { - app.overlayLayer.refreshTiles(); + app.overlayLayer.refresh(); } } // Every selection/highlight mutation refreshes the overlay, so this single @@ -589,39 +493,30 @@ function redrawAllLayers() { // Keep the server's saved-state snapshot current for save_display_controls. scheduleSyncDisplayState(); - // Show/hide the toggleable pseudo-layer tile layers. + // Show/hide the toggleable pseudo layers: entries in the composited slots' + // draw lists, refreshed with their slot below. const toggleableLayers = [ [app.modulesLayer, visibility.module_view], // Module view [app.pinsLayer, visibility.pins], // Shapes > Pins ...app.overlayLayers.map( ({ def, layer }) => [layer, anyGroupOn(def.shown_by, visibility)]), ]; - for (const [layer, visible] of toggleableLayers) { - if (!layer) continue; - if (visible && !app.map.hasLayer(layer)) { - layer.addTo(app.map); - } else if (!visible && app.map.hasLayer(layer)) { - app.map.removeLayer(layer); + for (const [item, visible] of toggleableLayers) { + if (item) { + item.visible = !!visible; } } - for (const layer of app.allLayers) { - layer.refreshTiles(); + for (const slot of app.allLayers) { + slot.refresh(); } if (app.heatMapLayer) { - app.heatMapLayer.refreshTiles(); + app.heatMapLayer.refresh(); } - // Keep the client-side selection outline in sync with the "Highlight - // selected" toggle: detach it when off, re-attach it when back on (the - // rectangle object is preserved so the current selection survives an - // off→on round trip; the server-side highlight is gated by the overlay - // refresh below). An in-flight selection pulse is cancelled on off. - if (app.highlightRect) { - const showHighlight = visibility.highlight_selected !== false; - if (!showHighlight && app.map.hasLayer(app.highlightRect)) { - app.map.removeLayer(app.highlightRect); - } else if (showHighlight && !app.map.hasLayer(app.highlightRect)) { - app.highlightRect.addTo(app.map); - } + // The client-side selection outline follows the "Highlight selected" + // toggle; the server-side highlight is gated by the overlay refresh below. + // An in-flight selection pulse is cancelled on off. + if (app.renderSelectionOutline) { + app.renderSelectionOutline(); } if (!visibility.highlight_selected && app.clearSelectionPulse) { app.clearSelectionPulse(); @@ -666,12 +561,14 @@ function applyDisplayState(state) { if (!entries || typeof entries !== 'object') return; applyDisplayStateEntries(entries); // Preserve the current view so restoring controls doesn't move the map. + // Kept in DBU: the world scale follows the tile size, which may change. try { - if (app.map && typeof sessionStorage !== 'undefined') { - const c = app.map.getCenter(); + if (app.view && app.designScale && typeof sessionStorage !== 'undefined') { + const [wx, wy] = app.view.getCenter(); + const { dbuX, dbuY } = worldToDbu(wx, wy, app.designScale, + app.designOriginX, app.designOriginY); sessionStorage.setItem('or_restore_view', - JSON.stringify({ lat: c.lat, lng: c.lng, - zoom: app.map.getZoom() })); + JSON.stringify({ dbuX, dbuY, zoom: app.view.getZoom() })); } } catch (_) { /* ignore */ } window.location.reload(); @@ -711,64 +608,76 @@ function createLayoutViewer(container) { // display-controls.js), and createLayoutViewer sets them again if the panel // is reopened. // - // app.map is deliberately left alone. Calling map.remove() and nulling it - // would be the matching cleanup, but ~140 call sites across eleven modules - // reach app.map, many of them unguarded -- the View menu's zoom items, the - // inspector's zoom-to, the rulers, the display controls -- so nulling it - // turns a detached-but-harmless map into a dozen ways to throw while the - // panel is closed. Guarding those is a lifecycle change, not a styling - // one. + // app.view is deliberately left alone: many call sites reach it unguarded + // (the View menu's zoom items, the inspector's zoom-to, the rulers), and a + // detached view is harmless while the panel is closed. container.on('destroy', () => { app.tileProgressEl = null; app.heatMapLegendEl = null; }); - app.map = L.map(mapDiv, buildMapOptions(undefined, { - wheelZoom: app.wheelZoom, - arrowStep: app.arrowStep, - })); - // Wheel pan/zoom per the Options preference (2.15). Skipped in a static - // report, which deliberately locks the zoom to the one pre-rendered level - // and turns Leaflet's own wheel zoom off. - if (!isStaticMode(app)) { - installWheelPanning(app.map, () => app.wheelZoom); - } - // On a fractional dpr, Leaflet's whole-CSS-pixel placement leaves tile - // boundaries mid-device-pixel and they show as dark hairlines; this nudges - // each tile container back onto the grid after every move. - installDeviceGridSnapping(app.map); + app.view = createLayoutView(mapDiv, { + preserveDrawingBuffer: app.preserveBuffer, + prefs: { + smooth: () => app.controlSmoothing, + doubleBuffer: () => app.doubleBuffer, + defer: () => app.deferTileUpdates, + }, + tileSize: tileSizeCss, + dpr: nativeDpr, + isStatic: isStaticMode(app), + }); + app.view.on('contextlost', () => { + console.warn('Layout view: WebGL context lost; rebuilding the view.'); + }); + app.view.on('contextfailed', () => { + showToast('The layout view lost its graphics context and could not ' + + 'get it back; reload the page.', 15000); + }); + // For the browser probes and debugging from the console. + window.__orView = app.view; // Tiles are rasterized for the ratio in force when they were requested and // are never revisited on their own, so a window moved to another monitor — // or a browser zoom change — leaves every tile stretched from the old ratio - // into the new box until something forces a refresh. Nothing did. - watchDevicePixelRatio(() => redrawAllLayers()); - const hoverPane = app.map.createPane(app.hoverHighlightPane); - hoverPane.style.zIndex = '650'; - hoverPane.style.pointerEvents = 'none'; - - // "Fit" button below the default zoom (+/-) control, top-left. - const FitControl = L.Control.extend({ - onAdd: function() { - const c = L.DomUtil.create( - 'div', 'leaflet-bar leaflet-control leaflet-control-fit'); - const a = L.DomUtil.create('a', '', c); - a.href = '#'; - a.title = 'Fit'; - a.setAttribute('role', 'button'); - a.setAttribute('aria-label', 'Fit'); - a.textContent = '⤢'; - L.DomEvent.on(a, 'click', L.DomEvent.stop) - .on(a, 'click', () => { - if (app.fitBounds) app.map.fitBounds(app.fitBounds); - }); - return c; - }, + // into the new box until something forces a refresh. + watchDevicePixelRatio(() => { + app.view.invalidateSize(); + redrawAllLayers(); }); - new FitControl({ position: 'topleft' }).addTo(app.map); - new ResizeObserver(() => { - app.map.invalidateSize({ animate: false }); - }).observe(mapDiv); + // Zoom in / out and Fit, top-left. + const zoomControl = document.createElement('div'); + zoomControl.className = 'or-zoom-control'; + const zoomButtons = []; + for (const [label, title, action] of [ + ['+', 'Zoom in', () => app.view.zoomIn()], + ['\u2212', 'Zoom out', () => app.view.zoomOut()], + ['\u2922', 'Fit', () => { + if (app.fitRect) app.view.fitWorldRect(app.fitRect); + }], + ]) { + const button = document.createElement('button'); + button.type = 'button'; + button.title = title; + button.setAttribute('aria-label', title); + button.textContent = label; + button.addEventListener('click', (e) => { + e.stopPropagation(); + action(); + }); + zoomControl.appendChild(button); + zoomButtons.push(button); + } + mapDiv.appendChild(zoomControl); + // Disabled at the zoom limits, so a press that cannot zoom says so. + const syncZoomButtons = () => { + const { minZoom, maxZoom } = app.view.getLimits(); + const z = app.view.getTargetZoom(); + zoomButtons[0].disabled = z >= maxZoom; + zoomButtons[1].disabled = z <= minZoom; + }; + app.view.on('zoom zoomend limits', syncZoomButtons); + syncZoomButtons(); // Scale bar and coordinate readout share one HUD at the bottom-left of // the viewer. The scale bar is a display option and hides on its own, so @@ -800,27 +709,47 @@ function createLayoutViewer(container) { } syncHud(); - app.map.on('mousemove', (e) => { - app.lastMouseLatLng = e.latlng; - if (!app.designScale) return; - const { dbuX, dbuY } = latLngToDbu( - e.latlng.lat, e.latlng.lng, app.designScale, app.designMaxDXDY, - app.designOriginX, app.designOriginY); - coordBar.textContent = `X: ${app.formatDbu(dbuX)} Y: ${app.formatDbu(dbuY)}`; - syncHud(); - }); - app.map.on('mouseout', (e) => { - // Leaflet raises mouseout for a move onto anything inside the - // container too -- a zoom control, a marker, the HUD itself -- and - // both the readout and the zoom anchor should hold their values for - // those. Only a move that actually leaves the viewer clears them. - const to = e.originalEvent && e.originalEvent.relatedTarget; - if (to && mapDiv.contains(to)) { - return; - } - app.lastMouseLatLng = null; - coordBar.textContent = ''; - syncHud(); + // Pointer input: wheel, keys, clicks, boxes. Drag-panning is the view's. + installViewInput(app.view, { + isStatic: () => isStaticMode(app), + wheelZoom: () => app.wheelZoom, + arrowStep: () => app.arrowStep, + contextEnabled: () => !(app.rulerManager && app.rulerManager.isActive()), + onClick: (world, e) => { + if (app.rulerManager && app.rulerManager.isActive()) { + app.rulerManager.handleMapClick(world, e); + } else if (app.rulerManager?.handleRulerClick(world)) { + // A ruler line took the click. + } else if (app.onMapClick) { + app.onMapClick(world, e); + } + }, + onContextClick: (world, e) => { + if (app.onMapContextClick) { + app.onMapContextClick(world, e); + } + }, + onMove: (world, e) => { + // The world point, not the screen one: the Z keys zoom around it + // even after the view has moved under a still pointer. + app.lastMouseWorld = world; + if (app.rulerManager && app.rulerManager.isActive()) { + app.rulerManager.handleMouseMove(world, e); + } + if (!app.designScale) return; + const { dbuX, dbuY } = worldToDbu( + world[0], world[1], app.designScale, + app.designOriginX, app.designOriginY); + coordBar.textContent = `X: ${app.formatDbu(dbuX)} Y: ${app.formatDbu(dbuY)}`; + syncHud(); + }, + // pointerleave does not fire for moves onto the zoom control or the + // HUD inside the viewer, so the readout holds for those. + onLeave: () => { + app.lastMouseWorld = null; + coordBar.textContent = ''; + syncHud(); + }, }); const SB_H = 22; // svg height @@ -864,9 +793,9 @@ function createLayoutViewer(container) { return; } // Pixels per DBU at current zoom: designScale * 2^zoom. - const pxPerDbu = app.designScale * Math.pow(2, app.map.getZoom()); - // Target bar width: ~15% of the map container width. - const containerWidth = app.map.getContainer().clientWidth || 400; + const pxPerDbu = app.designScale * Math.pow(2, app.view.getZoom()); + // Target bar width: ~15% of the view width. + const containerWidth = app.view.getSize().width || 400; const sb = computeScaleBar({ targetPx: containerWidth * 0.15, pxPerDbu, @@ -888,7 +817,7 @@ function createLayoutViewer(container) { // change the bar (geometry depends only on zoom and container width), // so 'move'/'moveend' are deliberately not listened to. const scheduleUpdateScaleBar = rafCoalesce(updateScaleBar); - app.map.on('zoom zoomend resize', scheduleUpdateScaleBar); + app.view.on('zoom zoomend resize', scheduleUpdateScaleBar); app.updateScaleBar = updateScaleBar; app.rulerManager = new RulerManager(app, visibility, updateInspector, focusComponent); @@ -1254,10 +1183,12 @@ if (staticCache) { // Before any layer or the map scale is built: a report's tiles are baked at // a fixed size and cannot be re-rendered to fit a different box. useStaticTileSize(); - app.websocketManager = WebSocketManager.fromCache(staticCache, updateStatus); + app.websocketManager = WebSocketManager.fromCache(staticCache, + scheduleUpdateStatus); } else { const websocketUrl = `ws://${window.location.host || 'localhost:8080'}/ws`; - app.websocketManager = new WebSocketManager(websocketUrl, updateStatus); + app.websocketManager = new WebSocketManager(websocketUrl, + scheduleUpdateStatus); // Where each tech layer has shapes, so tiles that would come back empty // are never requested (see layer-extents.js). Static reports have no // server to ask and keep requesting everything. @@ -1326,7 +1257,7 @@ app.toggleShowDbu = function() { app.showDbu = !app.showDbu; setCookie('or_show_dbu', app.showDbu ? '1' : '0'); // Re-render rulers so their labels update. - if (app.rulerManager) app.rulerManager._rerenderAll(); + if (app.rulerManager) app.rulerManager._renderAll(); // Re-render hierarchy browser if present. if (app.hierarchyBrowser) app.hierarchyBrowser._render(); // Update scale bar. @@ -1354,13 +1285,37 @@ app.toggleWheelZoom = function() { scheduleSyncDisplayState(); }; -// Qt's Options > "Arrow keys scroll step". Leaflet caches the pan distance in -// its keyboard handler's key map, so the new step has to be pushed into it: -// see applyArrowStep. +// ── Rendering preferences (#11340) ── +// +// The view reads all three live; double buffering and defer also re-plan the +// tiles at once, so a level held back by them is not left waiting. + +app.toggleControlSmoothing = function() { + app.controlSmoothing = !app.controlSmoothing; + setCookie('or_control_smoothing', app.controlSmoothing ? '1' : '0'); + scheduleSyncDisplayState(); +}; + +// Read per tile by the composite source and per zoom by the view. +app.toggleDoubleBuffer = function() { + app.doubleBuffer = !app.doubleBuffer; + setCookie('or_double_buffer', app.doubleBuffer ? '1' : '0'); + app.view?.applyPrefs(); + scheduleSyncDisplayState(); +}; + +// Read by the view on every move. +app.toggleDeferTileUpdates = function() { + app.deferTileUpdates = !app.deferTileUpdates; + setCookie('or_defer_tile_updates', app.deferTileUpdates ? '1' : '0'); + app.view?.applyPrefs(); + scheduleSyncDisplayState(); +}; + +// Qt's Options > "Arrow keys scroll step", read by view-input on every key. app.setArrowStep = function(step) { app.arrowStep = clampArrowStep(step); setCookie('or_arrow_step', String(app.arrowStep)); - applyArrowStep(app.map, app.arrowStep); scheduleSyncDisplayState(); }; @@ -1505,15 +1460,13 @@ function applyBounds(designBounds, fitRect) { if (!t) return false; app.currentBounds = designBounds; app.designScale = t.scale; - app.designMaxDXDY = t.maxDXDY; app.designOriginX = t.originX; app.designOriginY = t.originY; - app.fitBounds = t.fitBounds; - // Bound the zoom before the first fit: the tile layers are L.GridLayer, - // which contributes no maxZoom, so the map would otherwise let the user - // zoom until the tile math degenerates. Set per design, since the cap - // depends on this design's scale. - app.map.setMaxZoom(maxUsefulZoom(t.scale)); + app.fitRect = t.fitRect; + // Bound the zoom before the first fit, or it climbs until the tile math + // degenerates. Per design, since the cap depends on its scale. + // Zoom 0 shows the whole tile grid; there is nothing further out. + app.view.setLimits({ minZoom: 0, maxZoom: maxUsefulZoom(t.scale) }); return true; } @@ -1521,7 +1474,7 @@ async function resyncBounds(inlineBounds, inlineFitBounds, { reloadOnChange = false } = {}) { // Returns true when it already redrew the layers (bounds changed), so // callers can avoid a second redundant redraw. - if (isStaticMode(app) || !app.map) return false; + if (isStaticMode(app) || !app.view) return false; let designBounds = inlineBounds; let fitRect = inlineFitBounds; if (!designBounds) { @@ -1548,23 +1501,19 @@ async function resyncBounds(inlineBounds, inlineFitBounds, // Keep the DBU point at the center of the view where it is. const hadDesign = !!app.designScale; + const [cx, cy] = app.view.getCenter(); const center = hadDesign - ? latLngToDbu(app.map.getCenter().lat, app.map.getCenter().lng, - app.designScale, app.designMaxDXDY, - app.designOriginX, app.designOriginY) + ? worldToDbu(cx, cy, app.designScale, app.designOriginX, + app.designOriginY) : null; if (!applyBounds(designBounds, fitRect)) return false; if (center) { - const ll = dbuToLatLng(center.dbuX, center.dbuY, app.designScale, - app.designMaxDXDY, app.designOriginX, - app.designOriginY); - app.map.setView(ll, app.map.getZoom(), { animate: false }); - } - // Client-side rectangles hold latlngs from the old transforms. - if (app.highlightRect) { - app.map.removeLayer(app.highlightRect); - app.highlightRect = null; + app.view.setView(dbuToWorld(center.dbuX, center.dbuY, app.designScale, + app.designOriginX, app.designOriginY), + app.view.getZoom(), { animate: false }); } + // Client-side shapes hold world coordinates from the old transforms. + if (app.clearSelectionOutline) app.clearSelectionOutline(); redrawAllLayers(); return true; } @@ -1685,10 +1634,7 @@ app.websocketManager.onPush = (msg) => { // inspector and stale highlights. if (app.updateInspector) app.updateInspector(null); if (app.stopSelectionAnimation) app.stopSelectionAnimation(); - if (app.highlightRect && app.map) { - app.map.removeLayer(app.highlightRect); - app.highlightRect = null; - } + if (app.clearSelectionOutline) app.clearSelectionOutline(); scheduleRefreshOverlay(); } else if (msg.type === 'heatmaps_changed') { // A heat map was registered server-side after this client connected @@ -1738,12 +1684,9 @@ app.websocketManager.onPush = (msg) => { } else if (msg.type === 'debug_refresh') { // Tiles would be turned away until the next pause, which redraws. if (app.scriptRunning) return; - // Instance positions changed — clear the stale Leaflet highlight - // outline (the tile-based highlight updates automatically). - if (app.highlightRect) { - app.map.removeLayer(app.highlightRect); - app.highlightRect = null; - } + // Instance positions changed — clear the stale client-side outline + // (the tile-based highlight updates automatically). + if (app.clearSelectionOutline) app.clearSelectionOutline(); scheduleRedrawAllLayers(); } else if (msg.type === 'log') { // Logger output from the main Tcl thread (e.g. global_placement). @@ -1811,9 +1754,10 @@ app.websocketManager.readyPromise.then(async () => { // layers with it. Static reports are pre-rasterized at a fixed size // (useStaticTileSize above), so they are not free to choose. if (!staticCache) { - const viewport = app.map.getSize(); + const viewport = app.view.getSize(); useFittedTileSize(fittedTileSizeCss({ - designBounds, fitRect, viewW: viewport.x, viewH: viewport.y, + designBounds, fitRect, viewW: viewport.width, + viewH: viewport.height, })); } @@ -1825,38 +1769,26 @@ app.websocketManager.readyPromise.then(async () => { // placed. if (app.labelManager) app.labelManager.reload(); - app.map.fitBounds(app.fitBounds); - if (staticCache) { - // Lock to the pre-rendered tile zoom level and fit. + // Lock to the pre-rendered tile zoom level; the fit honours it. const cacheZoom = staticCache.zoom; - app.map.setMinZoom(cacheZoom); - app.map.setMaxZoom(cacheZoom); - app.map.fitBounds(app.fitBounds); - app.map.scrollWheelZoom.disable(); - app.map.touchZoom.disable(); - app.map.boxZoom.disable(); - app.map.doubleClickZoom.disable(); - - // Path highlight overlay image. NOT app.fitBounds, which + app.view.setLimits({ minZoom: cacheZoom, maxZoom: cacheZoom }); + } + app.view.fitWorldRect(app.fitRect, { animate: false }); + + if (staticCache) { + // Path highlight overlay image. NOT app.fitRect, which // carries Qt's framing margin: renderOverlayPng frames these // on the GEOREFERENCE rect, the one the tile grid is built // on, so the image has to be stretched over that same rect or // it lands offset from the tiles under it. - app.pathOverlay = L.imageOverlay( - '', - dbuRectToBounds(designBounds[0][1], designBounds[0][0], - designBounds[1][1], designBounds[1][0], - app.designScale, app.designMaxDXDY, - app.designOriginX, app.designOriginY), - { opacity: 1, interactive: false, zIndex: 1000 }); + const pathRect = dbuRectToWorldRect( + designBounds[0][1], designBounds[0][0], + designBounds[1][1], designBounds[1][0], + app.designScale, app.designOriginX, app.designOriginY); staticCache.setPathOverlay = (src) => { - if (src) { - app.pathOverlay.setUrl(src); - app.pathOverlay.addTo(app.map); - } else { - app.map.removeLayer(app.pathOverlay); - } + app.view.setImageOverlay('timing-path', + src ? { image: src, rect: pathRect } : null); }; } @@ -1867,9 +1799,12 @@ app.websocketManager.readyPromise.then(async () => { if (raw) { sessionStorage.removeItem('or_restore_view'); const v = JSON.parse(raw); - if (v && isFinite(v.lat) && isFinite(v.lng) + if (v && isFinite(v.dbuX) && isFinite(v.dbuY) && isFinite(v.zoom)) { - app.map.setView([v.lat, v.lng], v.zoom); + app.view.setView( + dbuToWorld(v.dbuX, v.dbuY, app.designScale, + app.designOriginX, app.designOriginY), + v.zoom, { animate: false }); } } } catch (_) { /* ignore */ } @@ -1885,19 +1820,19 @@ app.websocketManager.readyPromise.then(async () => { // panel to the Inspector (left-click); right-click keeps the current // panel and only updates the selection so the context menu can reflect // the object under the cursor. - function selectAtLatLng(latlng, opts = {}) { + function selectAtWorld(world, opts = {}) { const { addToSelection = false, focusInspector = true, context = false, showConnectivity = false } = opts; if (!app.designScale) return Promise.resolve(null); - const { dbuX: dbu_x, dbuY: dbu_y } = latLngToDbu( - latlng.lat, latlng.lng, app.designScale, app.designMaxDXDY, + const { dbuX: dbu_x, dbuY: dbu_y } = worldToDbu( + world[0], world[1], app.designScale, app.designOriginX, app.designOriginY); // In label-placement mode, a click creates a text annotation // instead of selecting (2.12). if (app.labelManager && app.labelManager.isActive()) { app.labelManager.handleMapClick(dbu_x, dbu_y); - return; + return Promise.resolve(null); } const vf = buildVisibilityFlags(visibility, selectability); @@ -1905,7 +1840,7 @@ app.websocketManager.readyPromise.then(async () => { type: 'select', dbu_x, dbu_y, - zoom: Math.round(app.map.getZoom()), + zoom: Math.round(app.view.getZoom()), visible_layers: [...app.visibleLayerNames], selectable_layers: [...app.selectableLayers], use_dbu: app.showDbu, @@ -1934,7 +1869,6 @@ app.websocketManager.readyPromise.then(async () => { // exists, so it must not drive the Inspector. if (!isCurrentSelection(app, token)) return; console.log('Select response:', data, 'at dbu', dbu_x, dbu_y); - app.map.closePopup(); // Type flags so the context menu can enable items by type. applySelectionFlags(app, data); if (data.selected && data.selected.length > 0) { @@ -1964,11 +1898,7 @@ app.websocketManager.readyPromise.then(async () => { data.bbox[2], data.bbox[3], data.type); pulseHighlight(data.bbox, data.type); // Remember bounds for "Zoom to Selection". - app.lastSelectionBounds = dbuRectToBounds( - data.bbox[0], data.bbox[1], - data.bbox[2], data.bbox[3], - app.designScale, app.designMaxDXDY, - app.designOriginX, app.designOriginY); + app.lastSelectionBounds = data.bbox.slice(0, 4); } if (selectRequest.show_connectivity && data.connected_added > 0) { @@ -1980,10 +1910,7 @@ app.websocketManager.readyPromise.then(async () => { // Empty left-click: clear inspector/highlight. An empty // right-click (context) keeps the current selection. updateInspector(null); - if (app.highlightRect) { - app.map.removeLayer(app.highlightRect); - app.highlightRect = null; - } + if (app.clearSelectionOutline) app.clearSelectionOutline(); app.lastSelectionBounds = null; } refreshOverlay(); @@ -1994,112 +1921,42 @@ app.websocketManager.readyPromise.then(async () => { return null; }); } - app.selectAtLatLng = selectAtLatLng; + app.selectAtWorld = selectAtWorld; - if (!staticCache) app.map.on('click', (e) => { - if (app.rulerManager && app.rulerManager.isActive()) return; - const ev = e.originalEvent; - selectAtLatLng(e.latlng, { - addToSelection: !!(ev && ev.shiftKey), + if (!staticCache) { + app.onMapClick = (world, e) => selectAtWorld(world, { + addToSelection: !!e.shiftKey, // Accept Cmd+click too: on macOS Ctrl+click is the // context-menu gesture, so metaKey is the reachable modifier. - showConnectivity: !!(ev && (ev.ctrlKey || ev.metaKey)), - }); - }); - - // ─── Right-click rubber-band zoom ────────────────────────────── - if (!staticCache) { - const container = app.map.getContainer(); - let rbStart = null; // {x, y} in client coords - let rbDiv = null; // overlay element - - container.addEventListener('contextmenu', (e) => { - e.preventDefault(); - }); - - container.addEventListener('mousedown', (e) => { - if (e.button !== 2) return; - rbStart = { x: e.clientX, y: e.clientY }; - app.map.dragging.disable(); - }); - - window.addEventListener('mousemove', (e) => { - if (!rbStart) return; - const dx = e.clientX - rbStart.x; - const dy = e.clientY - rbStart.y; - if (!rbDiv && Math.abs(dx) >= 4 && Math.abs(dy) >= 4) { - rbDiv = document.createElement('div'); - rbDiv.className = 'rubber-band'; - document.body.appendChild(rbDiv); - } - if (rbDiv) { - const left = Math.min(rbStart.x, e.clientX); - const top = Math.min(rbStart.y, e.clientY); - rbDiv.style.left = left + 'px'; - rbDiv.style.top = top + 'px'; - rbDiv.style.width = Math.abs(dx) + 'px'; - rbDiv.style.height = Math.abs(dy) + 'px'; - } - }); - - window.addEventListener('mouseup', (e) => { - if (!rbStart) return; - const wasShowing = !!rbDiv; - if (rbDiv) { - rbDiv.remove(); - rbDiv = null; - } - const start = rbStart; - rbStart = null; - app.map.dragging.enable(); - - const rect = container.getBoundingClientRect(); - - if (wasShowing) { - // Drag — rubber-band zoom. - const p1 = app.map.containerPointToLatLng([ - start.x - rect.left, start.y - rect.top]); - const p2 = app.map.containerPointToLatLng([ - e.clientX - rect.left, e.clientY - rect.top]); - app.map.fitBounds([ - [Math.min(p1.lat, p2.lat), Math.min(p1.lng, p2.lng)], - [Math.max(p1.lat, p2.lat), Math.max(p1.lng, p2.lng)], - ]); - return; - } - - // Pure click — select the object under the cursor, then show - // the context menu contextualized on it (Qt-like). Only over - // the map and not while a ruler is being placed. - const overMap = e.clientX >= rect.left && e.clientX <= rect.right - && e.clientY >= rect.top && e.clientY <= rect.bottom; - if (!overMap) return; - if (app.rulerManager && app.rulerManager.isActive()) return; - - const latlng = app.map.containerPointToLatLng([ - e.clientX - rect.left, e.clientY - rect.top]); - app.selectAtLatLng(latlng, { context: true, focusInspector: false }) - .then(() => app.contextMenu.show({ originalEvent: e })); + showConnectivity: !!(e.ctrlKey || e.metaKey), }); + // A right click selects the object under the cursor, then shows + // the context menu contextualized on it (Qt-like). A right drag + // is a rubber-band zoom (view-input.js). + app.onMapContextClick = (world, e) => { + selectAtWorld(world, { context: true, focusInspector: false }) + .then(() => app.contextMenu.show(e)); + }; } populateDisplayControls(app, visibility, selectability, - WebSocketTileLayer, - techData, redrawAllLayers, HeatMapTileLayer); - - // Create the highlight overlay layer — sits above all base/metal - // layers but below the heatmap. Only carries selection, hover, - // timing, DRC, and route-guide shapes on a transparent background, - // so base tiles stay cached when highlights change. - // Skip in static mode: there is no WebSocket server to serve - // overlay_tile requests. + techData, redrawAllLayers, createHeatMapSlot); + + // The highlight overlay: selection, hover, timing, DRC and route-guide + // shapes on a transparent background, above the layout and below the + // heat map, so base tiles stay cached when highlights change. Not in + // a saved report: there is no server to draw it. if (!app.overlayLayer && !staticCache) { - const OverlayTileLayer = createOverlayTileLayer(visibility, app); - app.overlayLayer = new OverlayTileLayer(app.websocketManager, { - zIndex: app.allLayers.length + 5, - opacity: 1, + app.overlayLayer = app.view.addTileSlot('overlay', { + order: DRAW_ORDER.overlay, + source: createImageSource({ + wm: app.websocketManager, + dpr: nativeDpr, + tileSize: tileSizeCss, + buildRequest: (c, dpr, t) => buildOverlayRequest( + c, dpr, t, visibility, app), + }), }); - app.overlayLayer.addTo(app.map); } updateHeatMaps(heatMapData); @@ -2152,20 +2009,13 @@ document.addEventListener('keydown', (e) => { if (app.rulerManager) app.rulerManager.clearAllRulers(); } else if (key === 'l' && !e.shiftKey && !e.ctrlKey && !e.metaKey) { if (app.labelManager) app.labelManager.toggleLabelMode(); - } else if (key === 'f' && !e.ctrlKey && !e.metaKey && app.fitBounds) { - app.map.fitBounds(app.fitBounds); - } else if (key === 'z' && !e.shiftKey && !e.ctrlKey && app.map) { - if (app.lastMouseLatLng) { - app.map.setZoomAround(app.lastMouseLatLng, app.map.getZoom() + 1); - } else { - app.map.zoomIn(); - } - } else if (key === 'z' && e.shiftKey && !e.ctrlKey && app.map) { - if (app.lastMouseLatLng) { - app.map.setZoomAround(app.lastMouseLatLng, app.map.getZoom() - 1); - } else { - app.map.zoomOut(); - } + } else if (key === 'f' && !e.ctrlKey && !e.metaKey && app.fitRect) { + app.view.fitWorldRect(app.fitRect); + } else if (key === 'z' && !e.ctrlKey && app.view) { + // Around the pointer when it is over the layout, else the centre. + const delta = e.shiftKey ? -1 : 1; + app.view.zoomAround(app.lastMouseWorld + ? app.view.project(app.lastMouseWorld) : null, delta); } else if (key === 'f' && (e.ctrlKey || e.metaKey)) { // Both dialog shortcuts must preventDefault. The dialog focuses and // select()s its first field synchronously, so this keystroke's own diff --git a/src/web/src/menu-bar.js b/src/web/src/menu-bar.js index ca4e7baa6f4..89dde10ea84 100644 --- a/src/web/src/menu-bar.js +++ b/src/web/src/menu-bar.js @@ -72,9 +72,9 @@ export function createMenuBar(app) { enabledWhen: () => !!app.designScale }, ]}, { label: 'View', items: [ - { label: 'Fit', shortcut: 'F', action: () => { if (app.fitBounds) app.map.fitBounds(app.fitBounds); } }, - { label: 'Zoom In', shortcut: 'Z', action: () => app.map.zoomIn() }, - { label: 'Zoom Out', shortcut: 'Shift+Z', action: () => app.map.zoomOut() }, + { label: 'Fit', shortcut: 'F', action: () => { if (app.fitRect) app.view.fitWorldRect(app.fitRect); } }, + { label: 'Zoom In', shortcut: 'Z', action: () => app.view.zoomIn() }, + { label: 'Zoom Out', shortcut: 'Shift+Z', action: () => app.view.zoomOut() }, { type: 'separator' }, { label: 'Toggle Theme', shortcut: 'T', action: () => app.toggleTheme() }, { type: 'separator' }, @@ -129,6 +129,18 @@ export function createMenuBar(app) { { label: 'Application font...', action: () => app.showAppFontDialog() }, { type: 'separator' }, + // Rendering preferences (#11340). Web-only: Qt has no smoothing + // to turn off and already draws off-screen. + { label: 'Smooth zoom and pan', + action: () => app.toggleControlSmoothing(), + checked: () => app.controlSmoothing }, + { label: 'Double buffering', + action: () => app.toggleDoubleBuffer(), + checked: () => app.doubleBuffer }, + { label: 'Defer tile updates while panning', + action: () => app.toggleDeferTileUpdates(), + checked: () => app.deferTileUpdates }, + { type: 'separator' }, { label: 'Show polygon decomposition', action: () => app.togglePolyDecomp(), checked: () => app.polyDecomp, diff --git a/src/web/src/merged-tile-layer.js b/src/web/src/merged-tile-layer.js deleted file mode 100644 index db64160fb45..00000000000 --- a/src/web/src/merged-tile-layer.js +++ /dev/null @@ -1,293 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// Copyright (c) 2026, The OpenROAD Authors - -// A Leaflet tile layer that composites several tech layers into ONE tile. -// -// The viewer's default is one pane per (tech layer x chiplet instance) — ~97 on -// a multi-die design — and every pane holds a full grid of tiles, each decoding -// to (256*dpr)^2 * 4 bytes. That measured 582 MB against a browser ceiling of -// ~458 MB, and over the ceiling Chrome discards decoded images: the discarded -// regions paint white and stay white until something forces a full -// invalidation. The symptom tracks decoded image bytes, not pane count: at a -// matched byte level, 86 and 97 content-bearing panes fail identically. -// -// This layer owns a contiguous run of the z-order and rasterizes it into a -// single per tile position, so N panes hold N grids instead of 97. -// See tile-merge.js for the budget arithmetic, why the run must be contiguous, -// and why the pane's own opacity must be 1. - -import { - closeAll, mergeOntoContext, mergedPaneOptions, renderMergedTile, -} from './tile-merge.js'; -import { - buildTileRequestFor, floorClampZoom, nativeDpr, tileDevicePx, - withDeviceExactTileSize, -} from './tile-request.js'; -import { tileMayHaveContent } from './layer-extents.js'; - -// Decode a websocket tile payload into something drawable. -// -// createImageBitmap is the point: an gives no control over when its -// decoded bitmap is released, and that is the whole problem this layer exists -// to solve. An ImageBitmap can be close()d the moment it has been drawn. -// -// A string payload is a data URI from the static-report cache, which has no -// Blob to hand to createImageBitmap — fall back to an there. Those -// reports are pre-rendered at one zoom and are not where the memory problem -// lives, so the weaker path is acceptable. -export function decodeTilePayload(payload) { - if (payload == null) { - return Promise.resolve(null); - } - if (typeof payload === 'string') { - return new Promise((resolve) => { - const img = document.createElement('img'); - img.onload = () => resolve(img); - img.onerror = () => resolve(null); - img.src = payload; - }); - } - if (typeof createImageBitmap === 'function') { - return createImageBitmap(payload).catch(() => null); - } - // No createImageBitmap (very old browser): fall back to a blob URL, and - // revoke it once the decode has happened. - return new Promise((resolve) => { - const url = URL.createObjectURL(payload); - const img = new Image(); - img.onload = () => { - URL.revokeObjectURL(url); - resolve(img); - }; - img.onerror = () => { - URL.revokeObjectURL(url); - resolve(null); - }; - img.src = url; - }); -} - -// `items` is the ordered draw list this pane owns: [{ layer, opacity, visible }], -// bottom-most first. It is read live on every request, so a visibility toggle -// only has to flip `visible` and call refreshTiles() — no layer is added to or -// removed from the map, and the pane count never changes. -export function createMergedTileLayer(ctx, options = {}) { - const decode = options.decode || decodeTilePayload; - const dprOf = options.dpr || nativeDpr; - - return L.GridLayer.extend({ - // Force upscale-only display (see floorClampZoom) so the browser never - // downscales a band-limited tile back into a moiré beat. - _clampZoom: function(zoom) { - return L.GridLayer.prototype._clampZoom.call( - this, floorClampZoom(this, zoom)); - }, - - initialize: function(websocketManager, items, opts) { - this._websocketManager = websocketManager; - this._items = items || []; - // Bumped on every refresh so in-flight renders for the previous - // generation can tell they have been superseded and drop their work - // instead of painting it. - this._generation = 0; - L.GridLayer.prototype.initialize.call( - this, withDeviceExactTileSize(opts)); - }, - - // Swap the draw list (a layer toggled, reordered, or regrouped after a - // resize changed the budget) and repaint in place. - setItems: function(items) { - this._items = items || []; - this.refreshTiles(); - }, - - visibleItems: function() { - return this._items.filter(item => item && item.visible !== false); - }, - - createTile: function(coords, done) { - const canvas = document.createElement('canvas'); - canvas.setAttribute('role', 'presentation'); - const dpr = dprOf(); - // Stored on the element rather than held only by this render, so - // whichever render paints first can complete the handshake. A - // refresh that lands before the first paint replaces the render but - // not the tile, and Leaflet keeps the tile hidden until done() is - // called — so a done that belonged to the superseded render would - // leave a painted canvas invisible until the tile was recreated. - canvas._orDone = done; - this._renderTile(canvas, coords, dpr); - return canvas; - }, - - // Backing store in device pixels, CSS box in layout pixels, so the - // canvas maps 1:1 onto the device grid and drawImage does not resample - // — the same invariant the path relies on. - // - // Re-applied on every render, not just at creation: devicePixelRatio - // changes when the window moves between monitors or the browser zoom - // changes, and a refresh then requests images at the new dpr. A canvas - // still sized for the old one would scale every incoming tile into the - // wrong backing store, leaving existing tiles blurry and inconsistent - // with any created afterwards. - // - // `empty` releases the backing store instead, for a tile with nothing - // to draw (see _renderTile); the CSS box stays, so the grid is intact. - _sizeCanvas: function(canvas, dpr, { empty = false } = {}) { - const size = this.getTileSize(); - // The same count the request asks the server for, so the image - // arrives at exactly the backing store's size and drawImage is a - // straight blit. - const w = empty ? 0 : tileDevicePx(size.x, dpr); - const h = empty ? 0 : tileDevicePx(size.y, dpr); - if (canvas.width !== w || canvas.height !== h) { - // Assigning width/height also clears the canvas, which is what - // we want here — the caller is about to redraw it. - canvas.width = w; - canvas.height = h; - } - canvas.style.width = size.x + 'px'; - canvas.style.height = size.y + 'px'; - }, - - // Mark the tile loaded, once. Leaflet reveals it only here - // (.leaflet-tile { visibility: hidden } until done() adds - // leaflet-tile-loaded), so every exit from a render has to reach this. - _finishTile: function(canvas, err) { - if (canvas._orTileDone || !canvas._orDone) { - return; - } - canvas._orTileDone = true; - canvas._orDone(err || null, canvas); - }, - - _renderTile: function(canvas, coords, dpr) { - const generation = this._generation; - const items = this.visibleItems().filter( - item => tileMayHaveContent(ctx, item.layer, coords)); - // A tile none of whose layers can draw here keeps no backing store - // at all. A full-size canvas per tile position per pane is what the - // browser pays for on a zoom -- allocating, clearing and compositing - // it -- whether or not anything is drawn into it, and most panes are - // empty in most views. - this._sizeCanvas(canvas, dpr, { empty: items.length === 0 }); - const context = canvas.getContext('2d'); - // Request ids are tracked per tile so _removeTile can cancel the - // whole group's in-flight work when the tile is pruned. - canvas._orRequestIds = []; - - // Superseded by a later refresh, or the tile was pruned while the - // requests were in flight. Pruning is tracked with an explicit flag - // rather than canvas.isConnected: Leaflet appends the element AFTER - // createTile returns, so attachment state conflates "pruned" with - // "not yet attached" and would drop the very first paint of every - // tile. - const isStale = () => this._generation !== generation - || canvas._orRemoved === true; - - renderMergedTile({ - items, - request: (item) => { - const id = this._websocketManager.nextId; - canvas._orRequestIds.push(id); - return this._websocketManager.request( - buildTileRequestFor(coords, item.layer, ctx, dpr, - this.getTileSize().x)); - }, - decode, - draw: (sources) => mergeOntoContext(context, sources, - canvas.width), - release: closeAll, - isStale, - // Reported on the FIRST paint, not on completion: Leaflet keeps - // a tile hidden (.leaflet-tile { visibility: hidden }) until - // done() adds leaflet-tile-loaded, so deferring it would make - // every incremental paint invisible and the tile would still - // appear only once its slowest layer had landed. - onFirstDraw: () => this._finishTile(canvas), - }).then(() => { - // A superseded render must not finish the tile: it painted - // nothing, so revealing the canvas here would show the state it - // had before the refresh. The render that replaced it owns the - // handshake. - if (!isStale()) { - this._finishTile(canvas); - } - }).catch((err) => { - // Reported as a load error so Leaflet stops waiting on it; the - // canvas keeps whatever it managed to paint. - if (!isStale()) { - this._finishTile(canvas, err); - } - }); - }, - - // Re-request every tile in place (no removal, no flash). Used for - // visibility toggles, pattern changes and the server's design-changed - // refresh push — the same contract as the per-layer layer's method, so - // redrawAllLayers() drives both without knowing which it has. - refreshTiles: function() { - if (!this._map) { - return; - } - this._generation++; - for (const key in this._tiles) { - const info = this._tiles[key]; - if (!info || !info.el) { - continue; - } - this._cancelTile(info.el); - const dpr = dprOf(); - this._renderTile(info.el, info.coords, dpr); - } - }, - - _cancelTile: function(el) { - const ids = el._orRequestIds; - if (!ids || !ids.length) { - return; - } - for (const id of ids) { - this._websocketManager.cancel(id); - } - el._orRequestIds = []; - }, - - _removeTile: function(key) { - const tile = this._tiles[key]; - if (tile && tile.el) { - // Flagged before the cancel so an in-flight render that is - // already past its request phase still sees the tile as gone - // and declines to paint a detached canvas. - tile.el._orRemoved = true; - this._cancelTile(tile.el); - // Drop the backing store now rather than waiting for GC: a - // pruned tile that keeps its canvas is the same unbounded - // growth in a different costume. - tile.el.width = 0; - tile.el.height = 0; - } - L.GridLayer.prototype._removeTile.call(this, key); - }, - }); -} - -// Build the N merged panes for an ordered draw list and put them on the map. -// -// `groups` is the output of partitionIntoGroups(): contiguous runs of the -// z-order, bottom-most first. z-indices are assigned from the group index so -// the panes stack in the same order the individual layers used to. -export function buildMergedPanes(MergedLayer, websocketManager, groups, map, - baseZIndex = 0) { - const panes = []; - groups.forEach((items, i) => { - const layer = new MergedLayer( - websocketManager, items, - mergedPaneOptions({ zIndex: baseZIndex + i })); - if (map) { - layer.addTo(map); - } - panes.push(layer); - }); - return panes; -} diff --git a/src/web/src/request_handler.cpp b/src/web/src/request_handler.cpp index f2291701c71..4b3d63d8a30 100644 --- a/src/web/src/request_handler.cpp +++ b/src/web/src/request_handler.cpp @@ -533,8 +533,8 @@ bool parseTileCoords(const boost::json::object& json, error = "\"z\" is outside [0, " + std::to_string(kMaxTileZoom) + "]"; return false; } - // x and y are deliberately NOT range-checked against the 2^z grid. Leaflet - // routinely asks for tiles off the edge of the world -- whenever the design + // x and y are deliberately NOT range-checked against the 2^z grid. A client + // may ask for tiles off the edge of the world -- whenever the design // is smaller than the viewport, or while panning at the border -- and the // renderers answer those with a transparent tile. Rejecting them turns // ordinary panning into a stream of errors: a first cut of this check @@ -1724,7 +1724,7 @@ WebSocketResponse SelectHandler::handleSelect(const WebSocketRequest& req, consumeStaleSelection(state); TileVisibility vis; vis.parseFromJson(req.json); - // Leaflet allows fractional zoom (zoomSnap: 0); accept either int or + // A client may send a fractional zoom; accept either int or // double on the wire and truncate to selectAt's integer zoom level. const auto& zoom_v = req.json.at("zoom"); const int zoom = zoom_v.is_int64() ? static_cast(zoom_v.get_int64()) @@ -4987,6 +4987,11 @@ void TileHandler::registerRequests(RequestDispatcher& d) [this](const WebSocketRequest& req, SessionState& state) { return handleTile(req, state); }); + d.add("tile_group", + WebSocketRequest::kTileGroup, + [this](const WebSocketRequest& req, SessionState& state) { + return handleTileGroup(req, state); + }); d.add("bounds", WebSocketRequest::kBounds, [this](const WebSocketRequest& req, SessionState& state) { @@ -5120,6 +5125,34 @@ void TileHandler::syncHeatMapsLocked(SessionState& state) } } +namespace { + +WebSocketResponse cancelledResponse(const uint32_t id) +{ + return errorResponse(id, "cancelled"); +} + +std::set snapshotFocusNets(SessionState& state) +{ + std::lock_guard lock(state.focus_nets_mutex); + return state.focus_net_ids; +} + +// An empty cache entry is a tile the renderer drew nothing into, stored +// without the bytes of a transparent PNG nobody would decode. +WebSocketResponse cachedTileResponse(const uint32_t id, + std::vector cached) +{ + WebSocketResponse resp; + resp.id = id; + resp.type + = cached.empty() ? WebSocketResponse::kEmpty : WebSocketResponse::kPng; + resp.payload = std::move(cached); + return resp; +} + +} // namespace + WebSocketResponse TileHandler::handleTile(const WebSocketRequest& req, SessionState& state) { @@ -5167,12 +5200,7 @@ WebSocketResponse TileHandler::handleTile(const WebSocketRequest& req, z, x, y); - WebSocketResponse resp; - resp.id = req.id; - resp.type = WebSocketResponse::kError; - const std::string msg = "cancelled"; - resp.payload.assign(msg.begin(), msg.end()); - return resp; + return cancelledResponse(req.id); } } @@ -5188,12 +5216,7 @@ WebSocketResponse TileHandler::handleTile(const WebSocketRequest& req, const std::map* mod_ptr = mod_colors.empty() ? nullptr : &mod_colors; - // Snapshot focus nets - std::set focus_nets; - { - std::lock_guard lock(state.focus_nets_mutex); - focus_nets = state.focus_net_ids; - } + const std::set focus_nets = snapshotFocusNets(state); const std::set* focus_ptr = focus_nets.empty() ? nullptr : &focus_nets; @@ -5217,39 +5240,20 @@ WebSocketResponse TileHandler::handleTile(const WebSocketRequest& req, std::string cache_key; if (cacheable) { - // Key = the full render determinant: the request JSON minus the per-call - // id, with dpr pinned to the quantized value actually rendered. - // Selectability (the s_* flags and selectable_layers) does NOT affect the - // rendered tile, so it is excluded — toggling "selectable" must not - // invalidate the cache. - boost::json::object key_obj = req.json; - key_obj.erase("id"); - key_obj.erase("selectable_layers"); - std::vector sel_keys; - for (const auto& kv : key_obj) { - const std::string_view k = kv.key(); - if (k.size() >= 2 && k[0] == 's' && k[1] == '_') { - sel_keys.emplace_back(k); - } - } - for (const std::string& k : sel_keys) { - key_obj.erase(k); - } - key_obj["dpr"] = dpr; - // Pinned like dpr: two clients on different displays ask for different - // pixel counts of the same tile, and they are different images. - key_obj["tile_px"] = tile_px; - cache_key = boost::json::serialize(key_obj); + // Key = what the render reads: the tile, the rendered dpr and pixel count, + // and the parsed visibility this layer depends on. Selectability and keys + // the server does not parse never reach it. + const boost::json::object tile_obj{{"layer", layer}, + {"z", z}, + {"x", x}, + {"y", y}, + {"dpr", dpr}, + {"tile_px", tile_px}}; + cache_key = boost::json::serialize(tile_obj) + + TileGenerator::tileCacheKey(vis, layer); std::vector cached; if (gen_->tileCacheGet(cache_key, cached)) { - WebSocketResponse resp; - resp.id = req.id; - // An empty cache entry is a tile the renderer drew nothing into; it is - // stored that way so a blank tile costs an LRU slot and not the bytes of - // a transparent PNG nobody will decode. - resp.type = cached.empty() ? WebSocketResponse::kEmpty - : WebSocketResponse::kPng; - resp.payload = std::move(cached); + WebSocketResponse resp = cachedTileResponse(req.id, std::move(cached)); debugPrint(gen_->getLogger(), utl::WEB, "tile", @@ -5316,6 +5320,153 @@ WebSocketResponse TileHandler::handleTile(const WebSocketRequest& req, return resp; } +namespace { + +// Bounds the work one tile_group request can ask for. +constexpr size_t kMaxGroupLayers = 256; + +// Reads a tile_group's layer list and its matching fill patterns. Returns an +// error message, empty on success. +std::string parseTileGroupLayers(const boost::json::object& json, + std::vector& layers, + std::vector& patterns) +{ + const auto layers_it = json.find("layers"); + if (layers_it == json.end() || !layers_it->value().is_array()) { + return "layers must be an array"; + } + const boost::json::array& names = layers_it->value().get_array(); + if (names.empty() || names.size() > kMaxGroupLayers) { + return "layers must hold 1 to " + std::to_string(kMaxGroupLayers) + + " names"; + } + for (const boost::json::value& name : names) { + // Pseudo layers ("_pins", ...) are always requested one by one. + if (!name.is_string() || name.get_string().empty() + || name.get_string().front() == '_') { + return "layers must be tech layer names"; + } + layers.emplace_back(name.get_string()); + } + const auto patterns_it = json.find("patterns"); + if (patterns_it == json.end()) { + patterns.assign(layers.size(), FillPattern::kSolid); + return {}; + } + if (!patterns_it->value().is_array() + || patterns_it->value().get_array().size() != layers.size()) { + return "patterns must match layers"; + } + for (const boost::json::value& pattern : patterns_it->value().get_array()) { + if (!pattern.is_int64()) { + return "patterns must be integers"; + } + patterns.push_back(toFillPattern(pattern.get_int64())); + } + return {}; +} + +} // namespace + +WebSocketResponse TileHandler::handleTileGroup(const WebSocketRequest& req, + SessionState& state) +{ + int z = 0; + int x = 0; + int y = 0; + if (std::string coord_error; + !parseTileCoords(req.json, z, x, y, coord_error)) { + return errorResponse(req.id, "bad tile_group request: " + coord_error); + } + std::vector layers; + std::vector patterns; + if (const std::string error + = parseTileGroupLayers(req.json, layers, patterns); + !error.empty()) { + return errorResponse(req.id, "bad tile_group request: " + error); + } + + // Abandoned while queued, or between two of the group's layers. + bool was_cancelled = false; + const auto cancelled = [&state, &was_cancelled, id = req.id] { + std::lock_guard lock(state.cancelled_mutex); + was_cancelled = state.cancelled_ids.erase(id) > 0; + return was_cancelled; + }; + if (cancelled()) { + return cancelledResponse(req.id); + } + + TileVisibility vis; + vis.parseFromJson(req.json); + + // Focused nets dim the others on tech layers; module colors only paint + // _modules, which never joins a group. + const std::set focus_nets = snapshotFocusNets(state); + const std::set* focus_ptr + = focus_nets.empty() ? nullptr : &focus_nets; + + const double dpr = quantizeDpr(jsonOr(req.json, "dpr", 1.0)); + const int tile_px = quantizeTilePx(jsonOr(req.json, "tile_px", 0.0)); + + const bool cacheable = focus_ptr == nullptr && !vis.debug + && !vis.debug_renderers && !vis.debug_live; + std::string cache_key; + if (cacheable) { + boost::json::array group; + for (size_t i = 0; i < layers.size(); ++i) { + group.push_back( + boost::json::array{layers[i], static_cast(patterns[i])}); + } + const boost::json::object tile_obj{{"group", std::move(group)}, + {"z", z}, + {"x", x}, + {"y", y}, + {"dpr", dpr}, + {"tile_px", tile_px}}; + // Every member is a tech layer, so they share one visibility key. + cache_key = boost::json::serialize(tile_obj) + + TileGenerator::tileCacheKey(vis, layers.front()); + std::vector cached; + if (gen_->tileCacheGet(cache_key, cached)) { + return cachedTileResponse(req.id, std::move(cached)); + } + } + + WebSocketResponse resp; + resp.id = req.id; + resp.type = WebSocketResponse::kPng; + resp.payload = gen_->generateGroupTile( + layers, patterns, z, x, y, vis, focus_ptr, dpr, tile_px, cancelled); + if (was_cancelled) { + return cancelledResponse(req.id); + } + if (resp.payload.empty()) { + return errorResponse(req.id, "tile_group: PNG encode failed"); + } + markEmptyIfBlank(resp); + if (cacheable) { + gen_->tileCachePut(std::move(cache_key), resp.payload); + } + + debugPrint(gen_->getLogger(), + utl::WEB, + "tile", + 1, + "tile_group: id={} layers={} z/x/y={}/{}/{} dpr={} tile_px={} " + "cache={} bytes={}", + req.id, + layers.size(), + z, + x, + y, + dpr, + tile_px, + cacheable ? "miss" : "off", + resp.payload.size()); + return resp; +} + WebSocketResponse TileHandler::handleOverlayTile(const WebSocketRequest& req, SessionState& state) { diff --git a/src/web/src/request_handler.h b/src/web/src/request_handler.h index 413ca1778f0..a61314ae0f8 100644 --- a/src/web/src/request_handler.h +++ b/src/web/src/request_handler.h @@ -278,6 +278,7 @@ struct WebSocketRequest enum Type { kTile, + kTileGroup, kBounds, kLayerExtents, kTech, @@ -586,8 +587,8 @@ constexpr int kMaxTileZoom = 30; // Read the z/x/y grid coordinates of a tile request into `z`/`x`/`y`. // Returns false, with `error` describing the offending field, when a // coordinate is missing, is not an integer, or the zoom is outside -// [0, kMaxTileZoom]. x and y are not bounded to the grid: Leaflet asks for -// off-grid tiles as a matter of course and the renderers answer with a +// [0, kMaxTileZoom]. x and y are not bounded to the grid: the client may +// ask for off-grid tiles and the renderers answer with a // transparent tile. // // The type check is not paranoia about hand-written clients: JSON.stringify @@ -792,6 +793,9 @@ class TileHandler void syncHeatMapsLocked(SessionState& state); WebSocketResponse handleTile(const WebSocketRequest& req, SessionState& state); + // One PNG for a run of tech layers, composited bottom to top. + WebSocketResponse handleTileGroup(const WebSocketRequest& req, + SessionState& state); WebSocketResponse handleOverlayTile(const WebSocketRequest& req, SessionState& state); WebSocketResponse handleModuleHierarchy(const WebSocketRequest& req); diff --git a/src/web/src/ruler.js b/src/web/src/ruler.js index 1edc3d5c858..af8d582be89 100644 --- a/src/web/src/ruler.js +++ b/src/web/src/ruler.js @@ -10,13 +10,17 @@ // Escape : cancel → IDLE // Shift+K : clear all rulers -import { dbuToLatLng, latLngToDbu } from './coordinates.js'; +import { dbuToWorld, worldToDbu } from './coordinates.js'; +import { DRAW_ORDER, toRgba } from './layout-view.js'; import { beginSelection } from './ui-utils.js'; const RULER_COLOR = '#00ffff'; const RULER_SELECTED_COLOR = '#ffff00'; const SNAP_INDICATOR_COLOR = '#ffffff'; +// Screen distance within which a click picks a ruler line. +const kRulerHitPx = 4; + const IDLE = 0; const FIRST_POINT = 1; const MEASURING = 2; @@ -38,34 +42,15 @@ export class RulerManager { this._ctrlHeld = false; this._shiftHeld = false; - // Leaflet layers - this._rulerPane = null; - this._rulerLayerGroup = null; - this._previewGroup = null; // rubber-band during MEASURING - this._snapGroup = null; // snap indicator - // Debounce state this._snapTimer = null; this._lastSnapResult = null; + this._snapShapes = null; + this._preview = null; // { shapes, label: { world, text } } - // Map event handlers (bound references for cleanup) - this._onMouseMove = this._handleMouseMove.bind(this); - this._onMapClick = this._handleMapClick.bind(this); - - this._initLayers(); - } - - _initLayers() { - const map = this._app.map; - if (!map) return; - - this._rulerPane = map.createPane('ruler-pane'); - this._rulerPane.style.zIndex = '700'; - this._rulerPane.style.pointerEvents = 'auto'; - - this._rulerLayerGroup = L.layerGroup([], { pane: 'ruler-pane' }).addTo(map); - this._previewGroup = L.layerGroup([], { pane: 'ruler-pane' }).addTo(map); - this._snapGroup = L.layerGroup([], { pane: 'ruler-pane' }).addTo(map); + // Tick lengths are in screen pixels, so a zoom redraws the rulers; + // the labels are world-anchored markers and follow on their own. + app.view?.on('zoom', () => this._renderRulerShapes()); } isActive() { @@ -73,9 +58,12 @@ export class RulerManager { } updateVisibility() { - if (this._rulerPane) { - this._rulerPane.style.display = this._visibility.rulers ? '' : 'none'; - } + this._renderAll(); + this._drawTransient(); + } + + _shown() { + return this._visibility.rulers !== false; } toggleRulerMode() { @@ -90,18 +78,15 @@ export class RulerManager { this._state = IDLE; this._pt0 = null; this._lastSnapResult = null; - this._clearPreview(); - this._clearSnap(); + this._clearTransient(); this._setCursor(false); - this._removeMapListeners(); } clearAllRulers() { this._rulers = []; this._selectedRulerId = null; - this._rulerLayerGroup.clearLayers(); - this._clearPreview(); - this._clearSnap(); + this._renderAll(); + this._clearTransient(); if (this._state !== IDLE) { this.cancelRulerBuild(); } @@ -114,7 +99,6 @@ export class RulerManager { this._pt0 = null; this._lastSnapResult = null; this._setCursor(true); - this._addMapListeners(); } _enterMeasuring(pt0) { @@ -122,36 +106,25 @@ export class RulerManager { this._pt0 = pt0; } - // ─── Map event wiring ──────────────────────────────────────────── + // ─── Pointer input (from view-input via main.js) ───────────────── - _addMapListeners() { - const map = this._app.map; - if (!map) return; - map.getContainer().addEventListener('mousemove', this._onMouseMove); - map.on('click', this._onMapClick); + _toDbu(world) { + return worldToDbu(world[0], world[1], this._app.designScale, + this._app.designOriginX, this._app.designOriginY); } - _removeMapListeners() { - const map = this._app.map; - if (!map) return; - map.getContainer().removeEventListener('mousemove', this._onMouseMove); - map.off('click', this._onMapClick); + _toWorld(x, y) { + return dbuToWorld(x, y, this._app.designScale, + this._app.designOriginX, this._app.designOriginY); } - _handleMouseMove(e) { + handleMouseMove(world, e) { if (this._state === IDLE) return; this._ctrlHeld = e.ctrlKey || e.metaKey; this._shiftHeld = e.shiftKey; - const map = this._app.map; - const rect = map.getContainer().getBoundingClientRect(); - const pt = map.containerPointToLatLng([ - e.clientX - rect.left, e.clientY - rect.top - ]); - const dbu = latLngToDbu(pt.lat, pt.lng, - this._app.designScale, this._app.designMaxDXDY, - this._app.designOriginX, this._app.designOriginY); + const dbu = this._toDbu(world); // Debounce snap requests at ~50ms if (this._snapTimer) clearTimeout(this._snapTimer); @@ -160,21 +133,13 @@ export class RulerManager { }, 50); } - _handleMapClick(e) { + handleMapClick(world, e) { if (this._state === IDLE) return; - L.DomEvent.stopPropagation(e); - - // Read modifier keys from the native DOM event - const orig = e.originalEvent; - if (orig) { - this._ctrlHeld = orig.ctrlKey || orig.metaKey; - this._shiftHeld = orig.shiftKey; - } + this._ctrlHeld = e.ctrlKey || e.metaKey; + this._shiftHeld = e.shiftKey; - const dbu = latLngToDbu(e.latlng.lat, e.latlng.lng, - this._app.designScale, this._app.designMaxDXDY, - this._app.designOriginX, this._app.designOriginY); + const dbu = this._toDbu(world); // Use the last snap result if available, otherwise raw click const snapped = this._getSnappedPoint(dbu.dbuX, dbu.dbuY); @@ -187,8 +152,7 @@ export class RulerManager { // where you can keep placing rulers until pressing 'k' or Escape) this._state = FIRST_POINT; this._pt0 = null; - this._clearPreview(); - this._clearSnap(); + this._clearTransient(); this._lastSnapResult = null; } } @@ -202,7 +166,7 @@ export class RulerManager { // Ctrl held: skip snap entirely, use raw cursor position if (this._ctrlHeld) { this._lastSnapResult = null; - this._clearSnap(); + this._snapShapes = null; this._updatePreview(dbuX, dbuY); return; } @@ -212,7 +176,7 @@ export class RulerManager { const radius = dbuPerMicron; // 1 micron search radius // Point snap threshold: max(10 pixels in DBU, 10 DBU) - const zoom = app.map.getZoom(); + const zoom = app.view.getZoom(); const numTiles = Math.pow(2, Math.max(0, zoom)); // designScale is CSS px per DBU at zoom 0, so it already carries the // tile size the map was built with -- which is not a constant. @@ -310,75 +274,67 @@ export class RulerManager { } _updateSnapIndicator(snap) { - this._clearSnap(); - if (!snap?.found) return; - - const scale = this._app.designScale; - const maxDXDY = this._app.designMaxDXDY; - const originX = this._app.designOriginX; - const originY = this._app.designOriginY; - - if (snap.is_point) { - const ll = dbuToLatLng(snap.edge[0][0], snap.edge[0][1], scale, maxDXDY, originX, originY); - const marker = L.circleMarker(ll, { - radius: 5, - color: SNAP_INDICATOR_COLOR, - fillColor: SNAP_INDICATOR_COLOR, - fillOpacity: 0.5, - weight: 1, - pane: 'ruler-pane', - interactive: false, - }); - this._snapGroup.addLayer(marker); - } else { - const p1 = dbuToLatLng(snap.edge[0][0], snap.edge[0][1], scale, maxDXDY, originX, originY); - const p2 = dbuToLatLng(snap.edge[1][0], snap.edge[1][1], scale, maxDXDY, originX, originY); - const line = L.polyline([p1, p2], { - color: SNAP_INDICATOR_COLOR, - weight: 1, - pane: 'ruler-pane', - interactive: false, - }); - this._snapGroup.addLayer(line); + this._snapShapes = null; + if (snap?.found) { + const white = toRgba(SNAP_INDICATOR_COLOR); + if (snap.is_point) { + this._snapShapes = [{ + kind: 'circle', + center: this._toWorld(snap.edge[0][0], snap.edge[0][1]), + radius: 5, stroke: white, width: 1, + fill: toRgba(SNAP_INDICATOR_COLOR, 0.5), + }]; + } else { + this._snapShapes = [{ + kind: 'path', + points: [this._toWorld(snap.edge[0][0], snap.edge[0][1]), + this._toWorld(snap.edge[1][0], snap.edge[1][1])], + stroke: white, width: 1, + }]; + } } + this._drawTransient(); } _updatePreview(rawX, rawY) { - this._clearPreview(); - if (this._state !== MEASURING || !this._pt0) return; - - const scale = this._app.designScale; - const maxDXDY = this._app.designMaxDXDY; - const originX = this._app.designOriginX; - const originY = this._app.designOriginY; - const snapped = this._getSnappedPoint(rawX, rawY); - - const p0 = dbuToLatLng(this._pt0.x, this._pt0.y, scale, maxDXDY, originX, originY); - const p1 = dbuToLatLng(snapped.x, snapped.y, scale, maxDXDY, originX, originY); - - const line = L.polyline([p0, p1], { - color: RULER_COLOR, - weight: 2, - dashArray: '6,4', - pane: 'ruler-pane', - interactive: false, - }); - this._previewGroup.addLayer(line); - - // Show distance label - const dist = this._computeDistance(this._pt0, snapped); - const midLat = (p0[0] + p1[0]) / 2; - const midLng = (p0[1] + p1[1]) / 2; - const label = L.marker([midLat, midLng], { - icon: L.divIcon({ - className: 'ruler-label', - html: this._formatDistance(dist), - iconSize: null, - }), - pane: 'ruler-pane', - interactive: false, - }); - this._previewGroup.addLayer(label); + this._preview = null; + if (this._state === MEASURING && this._pt0) { + const snapped = this._getSnappedPoint(rawX, rawY); + const p0 = this._toWorld(this._pt0.x, this._pt0.y); + const p1 = this._toWorld(snapped.x, snapped.y); + const dist = this._computeDistance(this._pt0, snapped); + this._preview = { + shapes: [{ kind: 'path', points: [p0, p1], + stroke: toRgba(RULER_COLOR), width: 2, + dash: [6, 4] }], + label: { world: [(p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2], + text: this._formatDistance(dist) }, + }; + } + this._drawTransient(); + } + + // The snap indicator and the rubber-band preview. + _drawTransient() { + const view = this._app.view; + if (!view) return; + const shown = this._shown(); + view.setOverlay('ruler-snap', shown ? this._snapShapes : null, + { order: DRAW_ORDER.ruler }); + view.setOverlay('ruler-preview', shown && this._preview + ? this._preview.shapes : null, { order: DRAW_ORDER.ruler }); + view.clearMarkers('ruler-preview'); + if (shown && this._preview) { + view.addMarker('ruler-preview', 'label', this._preview.label.world, + this._labelElement(this._preview.label.text)); + } + } + + _labelElement(text) { + const el = document.createElement('div'); + el.className = 'ruler-label'; + el.textContent = text; + return el; } // ─── Ruler creation and rendering ──────────────────────────────── @@ -395,65 +351,40 @@ export class RulerManager { euclidian: this._app.rulerStyle !== 'manhattan', }; this._rulers.push(ruler); - this._renderRuler(ruler); this._selectRuler(id); return ruler; } - _renderRuler(ruler) { - const scale = this._app.designScale; - const maxDXDY = this._app.designMaxDXDY; - const originX = this._app.designOriginX; - const originY = this._app.designOriginY; - - const p0 = dbuToLatLng(ruler.pt0.x, ruler.pt0.y, scale, maxDXDY, originX, originY); - const p1 = dbuToLatLng(ruler.pt1.x, ruler.pt1.y, scale, maxDXDY, originX, originY); - const isSelected = ruler.id === this._selectedRulerId; - const color = isSelected ? RULER_SELECTED_COLOR : RULER_COLOR; - - const group = L.layerGroup([], { pane: 'ruler-pane' }); - - // Build path points: straight line (euclidian) or L-shape (Manhattan) + // World points of a ruler's path: straight, or the Manhattan L. + _rulerPath(ruler) { const joinPt = ruler.euclidian ? null : this._getManhattanJoinPt(ruler.pt0, ruler.pt1); - const pJoin = joinPt - ? dbuToLatLng(joinPt.x, joinPt.y, scale, maxDXDY, originX, originY) - : null; - const pathPoints = pJoin ? [p0, pJoin, p1] : [p0, p1]; - - // Main ruler line - const mainLine = L.polyline(pathPoints, { - color, - weight: 2, - pane: 'ruler-pane', - interactive: true, - }); - mainLine.on('click', (e) => { - L.DomEvent.stopPropagation(e); - this._selectRuler(ruler.id); - }); - group.addLayer(mainLine); + const pts = joinPt ? [ruler.pt0, joinPt, ruler.pt1] + : [ruler.pt0, ruler.pt1]; + return { joinPt, points: pts.map((p) => this._toWorld(p.x, p.y)) }; + } + + _rulerShapes(ruler) { + const isSelected = ruler.id === this._selectedRulerId; + const color = toRgba(isSelected ? RULER_SELECTED_COLOR : RULER_COLOR); + const { joinPt, points } = this._rulerPath(ruler); + const shapes = [{ kind: 'path', points, stroke: color, width: 2 }]; - // Endcap ticks — perpendicular to each segment direction - const zoom = this._app.map.getZoom(); + // Endcap ticks, 8 px either side, perpendicular to each segment. + const zoom = this._app.view.getZoom(); const numTiles = Math.pow(2, Math.max(0, zoom)); - const dbuPerPixel = 1 / (scale * numTiles); + const dbuPerPixel = 1 / (this._app.designScale * numTiles); const tickLen = 8 * dbuPerPixel; - const addTick = (pt, segDx, segDy) => { const segLen = Math.sqrt(segDx * segDx + segDy * segDy); if (segLen === 0) return; const px = -segDy / segLen; const py = segDx / segLen; - const t0 = dbuToLatLng(pt.x + px * tickLen, pt.y + py * tickLen, scale, maxDXDY, originX, originY); - const t1 = dbuToLatLng(pt.x - px * tickLen, pt.y - py * tickLen, scale, maxDXDY, originX, originY); - group.addLayer(L.polyline([t0, t1], { - color, weight: 2, pane: 'ruler-pane', interactive: false, - })); + shapes.push({ kind: 'path', stroke: color, width: 2, points: [ + this._toWorld(pt.x + px * tickLen, pt.y + py * tickLen), + this._toWorld(pt.x - px * tickLen, pt.y - py * tickLen)] }); }; - if (joinPt) { - // Manhattan: ticks perpendicular to each segment addTick(ruler.pt0, joinPt.x - ruler.pt0.x, joinPt.y - ruler.pt0.y); addTick(ruler.pt1, ruler.pt1.x - joinPt.x, ruler.pt1.y - joinPt.y); } else { @@ -462,38 +393,65 @@ export class RulerManager { addTick(ruler.pt0, dx, dy); addTick(ruler.pt1, dx, dy); } + return shapes; + } - // Distance label at midpoint (or join point for Manhattan) - const dist = this._computeDistance(ruler.pt0, ruler.pt1, ruler.euclidian); - const midLat = pJoin ? pJoin[0] : (p0[0] + p1[0]) / 2; - const midLng = pJoin ? pJoin[1] : (p0[1] + p1[1]) / 2; - const label = L.marker([midLat, midLng], { - icon: L.divIcon({ - className: 'ruler-label', - html: this._formatDistance(dist), - iconSize: null, - }), - pane: 'ruler-pane', - interactive: false, - }); - group.addLayer(label); + _renderAll() { + this._renderRulerShapes(); + this._renderRulerLabels(); + } - ruler._layerGroup = group; - this._rulerLayerGroup.addLayer(group); + _renderRulerShapes() { + const view = this._app.view; + if (!view || !this._app.designScale) return; + view.setOverlay('rulers', this._shown() + ? this._rulers.flatMap((r) => this._rulerShapes(r)) : null, + { order: DRAW_ORDER.ruler }); } - _rerenderAll() { - this._rulerLayerGroup.clearLayers(); + _renderRulerLabels() { + const view = this._app.view; + if (!view || !this._app.designScale) return; + view.clearMarkers('ruler-labels'); + if (!this._shown()) return; + // Distance label at the midpoint, or at the join for Manhattan. for (const ruler of this._rulers) { - this._renderRuler(ruler); + const { joinPt, points } = this._rulerPath(ruler); + const at = joinPt ? points[1] + : [(points[0][0] + points[1][0]) / 2, + (points[0][1] + points[1][1]) / 2]; + const dist = this._computeDistance(ruler.pt0, ruler.pt1, + ruler.euclidian); + view.addMarker('ruler-labels', ruler.id, at, + this._labelElement(this._formatDistance(dist))); } } + // Select the ruler whose line passes within a few pixels of `world`. + // Returns true when one did, so the click is not also a selection. + handleRulerClick(world) { + const view = this._app.view; + if (!view || !this._shown() || this._rulers.length === 0) { + return false; + } + const p = view.project(world); + for (const ruler of this._rulers) { + const pts = this._rulerPath(ruler).points.map((w) => view.project(w)); + for (let i = 0; i + 1 < pts.length; i++) { + if (segmentDistance(p, pts[i], pts[i + 1]) <= kRulerHitPx) { + this._selectRuler(ruler.id); + return true; + } + } + } + return false; + } + // ─── Selection and inspector ───────────────────────────────────── _selectRuler(rulerId) { this._selectedRulerId = rulerId; - this._rerenderAll(); + this._renderAll(); const ruler = this._rulers.find(r => r.id === rulerId); if (!ruler) return; @@ -565,7 +523,7 @@ export class RulerManager { ruler.euclidian = newValue.trim().toLowerCase() === 'true'; break; } - this._rerenderAll(); + this._renderAll(); this._selectRuler(ruler.id); }, }; @@ -596,11 +554,8 @@ export class RulerManager { const idx = this._rulers.findIndex(r => r.id === rulerId); if (idx === -1) return; - const ruler = this._rulers[idx]; - if (ruler._layerGroup) { - this._rulerLayerGroup.removeLayer(ruler._layerGroup); - } this._rulers.splice(idx, 1); + this._renderAll(); if (this._selectedRulerId === rulerId) { this._selectedRulerId = null; @@ -630,20 +585,27 @@ export class RulerManager { } _setCursor(crosshair) { - const container = this._app.map?.getContainer(); - if (!container) return; - if (crosshair) { - container.classList.add('ruler-mode-cursor'); - } else { - container.classList.remove('ruler-mode-cursor'); - } + this._app.view?.setCursorMode('ruler', crosshair); } - _clearPreview() { - this._previewGroup?.clearLayers(); + _clearTransient() { + this._preview = null; + this._snapShapes = null; + this._drawTransient(); } _clearSnap() { - this._snapGroup?.clearLayers(); + this._snapShapes = null; + this._drawTransient(); } } + +// Distance in px from point p to segment ab. +function segmentDistance(p, a, b) { + const dx = b[0] - a[0]; + const dy = b[1] - a[1]; + const len2 = dx * dx + dy * dy; + let t = len2 > 0 ? ((p[0] - a[0]) * dx + (p[1] - a[1]) * dy) / len2 : 0; + t = Math.max(0, Math.min(1, t)); + return Math.hypot(p[0] - (a[0] + t * dx), p[1] - (a[1] + t * dy)); +} diff --git a/src/web/src/search-nav.js b/src/web/src/search-nav.js index 6138fa7750b..4e6d8601c7a 100644 --- a/src/web/src/search-nav.js +++ b/src/web/src/search-nav.js @@ -6,7 +6,7 @@ // - Go to position: jump the view to x,y in microns (mirrors Qt GotoDialog). // Both reuse the .modal-overlay/.modal-dialog pattern from menu-bar.js. -import { dbuToLatLng, dbuRectToBounds, latLngToDbu } from './coordinates.js'; +import { dbuRectToWorldRect, dbuToWorld, worldToDbu } from './coordinates.js'; import { applySelectionFlags, buildModal } from './ui-utils.js'; // The .search-nav-dialog rules size these two dialogs' rows; every caller here @@ -74,11 +74,10 @@ export function showFindDialog(app) { // Auto-zoom to the matched objects — an improvement over the Qt // Find dialog, which only selects without centering. if (Array.isArray(resp.bbox)) { - app.lastSelectionBounds = dbuRectToBounds( - resp.bbox[0], resp.bbox[1], resp.bbox[2], resp.bbox[3], - app.designScale, app.designMaxDXDY, - app.designOriginX, app.designOriginY); - app.map.fitBounds(app.lastSelectionBounds); + app.lastSelectionBounds = resp.bbox.slice(0, 4); + app.view.fitWorldRect(dbuRectToWorldRect( + ...app.lastSelectionBounds, app.designScale, + app.designOriginX, app.designOriginY)); } if (typeof app.updateInspector === 'function') { app.updateInspector(resp); @@ -104,7 +103,7 @@ export function showFindDialog(app) { // ── Go to position ────────────────────────────────────────────────────────── export function showGotoDialog(app) { - if (!app.designScale || !app.map) { + if (!app.designScale || !app.view) { return; } // Every field is read and written in whichever unit the "Show DBU" @@ -116,9 +115,9 @@ export function showGotoDialog(app) { // Prefill X/Y with the current view center, so "Go to" with no edits is // a no-op. - const c = app.map.getCenter(); - const centerDbu = latLngToDbu(c.lat, c.lng, app.designScale, - app.designMaxDXDY, app.designOriginX, app.designOriginY); + const c = app.view.getCenter(); + const centerDbu = worldToDbu(c[0], c[1], app.designScale, + app.designOriginX, app.designOriginY); const { overlay, close, okBtn, showError } = buildModal('Go to Position', `
@@ -142,20 +141,19 @@ export function showGotoDialog(app) { showError(`X and Y must be numbers (${unit}).`); return; } - const latlng = dbuToLatLng(dbuX, dbuY, app.designScale, - app.designMaxDXDY, app.designOriginX, app.designOriginY); // A size of 0 or less is not a window; fall through to the recentre. const sizeVal = sizeIn.value.trim(); const sizeDbu = sizeVal ? parse(sizeVal) : null; if (sizeDbu !== null && sizeDbu > 0) { const half = sizeDbu / 2; - app.map.fitBounds(dbuRectToBounds( + app.view.fitWorldRect(dbuRectToWorldRect( dbuX - half, dbuY - half, dbuX + half, dbuY + half, - app.designScale, app.designMaxDXDY, - app.designOriginX, app.designOriginY)); + app.designScale, app.designOriginX, app.designOriginY)); } else { - app.map.setView(latlng, app.map.getZoom()); + app.view.setView(dbuToWorld(dbuX, dbuY, app.designScale, + app.designOriginX, app.designOriginY), + app.view.getZoom()); } close(); } diff --git a/src/web/src/selection-browser.js b/src/web/src/selection-browser.js index 288a3876c4d..55d87471d8f 100644 --- a/src/web/src/selection-browser.js +++ b/src/web/src/selection-browser.js @@ -7,7 +7,7 @@ // never acts on the wrong object (the Qt dock's context menus use proxy // rows without mapToSource and mis-target under sorting). -import { dbuRectToBounds } from './coordinates.js'; +import { dbuRectToWorldRect } from './coordinates.js'; import { isStaticMode, makeResizableHeaders } from './ui-utils.js'; export class SelectionBrowser { @@ -180,16 +180,16 @@ export class SelectionBrowser { } _zoomToBBox(bbox) { - if (!bbox || !this._app.designScale || !this._app.map) return; + if (!bbox || !this._app.designScale || !this._app.view) return; const [xMin, yMin, xMax, yMax] = bbox; // Same margin rule as the DRC widget / Qt zoom-to handlers. const dbuPerMicron = this._app.getDbuPerMicron ? this._app.getDbuPerMicron() : 1000; const margin = Math.min(10 * dbuPerMicron, 2 * Math.max(xMax - xMin, yMax - yMin)); - this._app.map.fitBounds(dbuRectToBounds( + this._app.view.fitWorldRect(dbuRectToWorldRect( xMin - margin, yMin - margin, xMax + margin, yMax + margin, - this._app.designScale, this._app.designMaxDXDY, + this._app.designScale, this._app.designOriginX, this._app.designOriginY)); } diff --git a/src/web/src/style.css b/src/web/src/style.css index b62a04a24d8..2c5420e9f2d 100644 --- a/src/web/src/style.css +++ b/src/web/src/style.css @@ -42,7 +42,7 @@ --space-xl: 16px; /* Floating overlays on the layout canvas -- scale bar, coordinate - * readout, heat-map legend, Leaflet's zoom and Fit controls. These do + * readout, heat-map legend, the zoom and Fit buttons. These do * not flip with the theme: they sit on --bg-map, which is black in both * themes for Qt parity, so a light surface here would be a bright block * on black and light-theme ink on it would be unreadable. */ @@ -286,14 +286,11 @@ html[data-theme="light"] { /* ─── Ruler overlay ──────────────────────────────────────────────────────── */ -/* Placement-mode crosshair for the ruler and label tools. Qualified with - .leaflet-container so it outranks that element's own `cursor: default - !important` below on specificity; a bare .ruler-mode-cursor ties it and - loses the source-order tiebreak. .leaflet-dragging still wins over both, - so panning shows the grab cursor. */ -.leaflet-container.ruler-mode-cursor, -.leaflet-container.label-mode-cursor { - cursor: crosshair !important; +/* Placement-mode crosshair for the ruler and label tools. The canvas takes + its cursor from the view (setCursorMode); this covers the markers above it. */ +.or-view.ruler-mode-cursor, +.or-view.label-mode-cursor { + cursor: crosshair; } .ruler-label { background: var(--bg-hud); @@ -1477,66 +1474,87 @@ ide-tab.lm_active, background: var(--line-2); } -/* Leaflet map cursor */ -.leaflet-container { - cursor: default !important; +/* ─── Layout view ─────────────────────────────────────────────────────────── */ + +/* The view's container (layout-view.js): the deck.gl canvas, sized to whole + device pixels from the top-left corner, and DOM markers pinned over it. */ +.or-view { + position: relative; + overflow: hidden; + cursor: default; + touch-action: none; } -/* Leaflet draws its own control chrome (white background, dark border), which - is the app's theme only by coincidence. Restyle the bar rather than each - control, so the zoom buttons and the Fit button below them match. */ -.leaflet-bar { +.or-view-canvas { + position: absolute; + left: 0; + top: 0; +} +.or-view-markers { + position: absolute; + inset: 0; + z-index: 700; + overflow: hidden; + pointer-events: none; +} +.or-view-marker { + position: absolute; + left: 0; + top: 0; +} +.or-view-marker.label-handle { + pointer-events: auto; +} + +/* Zoom in / out and Fit, top-left of the view. */ +.or-zoom-control { + position: absolute; + top: 10px; + left: 10px; + z-index: 1000; + display: flex; + flex-direction: column; border: 1px solid var(--border-hud); border-radius: var(--radius-sm); box-shadow: 0 4px 14px var(--shadow-strong); overflow: hidden; } -.leaflet-bar a, -.leaflet-bar a:hover { +.or-zoom-control button { + width: 30px; + height: 30px; + padding: 0; + border: none; + border-bottom: 1px solid var(--border-hud); background: var(--bg-hud); color: var(--fg-hud); - border-bottom-color: var(--border-hud); + font: bold 18px/30px var(--font-mono); + text-align: center; + cursor: pointer; backdrop-filter: blur(3px); transition: background-color 120ms ease, color 120ms ease; } -.leaflet-bar a:hover { +.or-zoom-control button:last-child { + border-bottom: none; +} +.or-zoom-control button:hover { background: rgba(255, 255, 255, 0.14); color: #fff; } -.leaflet-bar a.leaflet-disabled { +.or-zoom-control button:disabled { background: var(--bg-hud); color: rgba(238, 244, 248, 0.4); -} -/* "Fit" control button — inherits .leaflet-bar sizing from Leaflet's CSS. */ -.leaflet-control-fit a { - font-size: var(--fs-16); - font-weight: bold; - line-height: 26px; - text-align: center; -} -.leaflet-dragging .leaflet-container { - cursor: grabbing !important; -} - -/* Leaflet tiles. - Keep `auto` (bilinear): tiles are band-limited server-side and displayed - 1:1 at rest (integer zoom) and HiDPI-exact (256*dpr image in a 256 CSS-px - box), so the only resampling is benign upscaling during zoom animation, - where bilinear is correct. `pixelated` would block-up that upscale. */ -.leaflet-tile { - image-rendering: auto; + cursor: default; } .layout-viewer { position: relative; } /* Drawn as an overlay rather than a border, for two reasons: a border on this - element would change the size Leaflet measures for the map, and an inset - box-shadow would be painted under the tile panes and never seen. z-index - 800 puts it over the panes (Leaflet's go up to 700) but under the HUD (900) - and Leaflet's own controls (1000), so it frames the canvas without drawing - a line across either. The inner shadow is invisible against the default - black and does its work when the Background control is set to something - light. */ + element would change the size the view measures, and an inset box-shadow + would be painted under the canvas and never seen. z-index 800 puts it over + the canvas and markers (700) but under the HUD (900) and the zoom buttons + (1000), so it frames the canvas without drawing a line across either. The + inner shadow is invisible against the default black and does its work when + the Background control is set to something light. */ .layout-viewer::after { content: ''; position: absolute; @@ -1579,19 +1597,6 @@ ide-tab.lm_active, to { left: 100%; } } -/* Leaflet popups */ -.leaflet-popup-content-wrapper { - background: var(--bg-context); - color: var(--fg-bright); - border-radius: var(--radius-sm); -} -.leaflet-popup-content { - font-family: var(--font-mono); -} -.leaflet-popup-content strong { - color: var(--accent-text); -} - /* Status overlay */ #websocket-status { position: fixed; @@ -2531,49 +2536,6 @@ ide-tab.lm_active, display: none; } -/* Hover highlight pulse animation */ -.hover-highlight { - stroke: #ffe85c; - stroke-width: 3px; - stroke-opacity: 1; - fill: #fff27a; - fill-opacity: 0.14; - vector-effect: non-scaling-stroke; - animation: hover-pulse 0.9s ease-out 3; -} -@keyframes hover-pulse { - 0% { - stroke: #fff6b0; - stroke-width: 7px; - stroke-opacity: 1; - fill-opacity: 0.28; - } - 55% { - stroke: #ffffff; - stroke-width: 5px; - stroke-opacity: 1; - fill-opacity: 0.06; - } - 100% { - stroke: #ffe85c; - stroke-width: 3px; - stroke-opacity: 0.95; - fill-opacity: 0.14; - } -} - -/* Selection pulse: brief flash when the inspector changes its target */ -.selection-pulse { - pointer-events: none; - animation: selection-pulse 350ms ease-in-out 3; - animation-fill-mode: forwards; -} -@keyframes selection-pulse { - 0% { stroke-opacity: 0; fill-opacity: 0; } - 50% { stroke-opacity: 1; fill-opacity: 0.28; } - 100% { stroke-opacity: 0; fill-opacity: 0; } -} - /* ─── Timing Widget ────────────────────────────────────────────────────── */ .timing-widget { @@ -3189,16 +3151,6 @@ html[data-theme="dark"] .schematic-widget svg { color: var(--error); } -/* DRC highlight flash animation — pulses tile opacity to mimic - the Qt GUI's yellow blinking highlight on visible markers. */ -@keyframes drc-pulse { - 0%, 100% { opacity: 1; } - 50% { opacity: 0.3; } -} -.drc-flashing .leaflet-tile-pane { - animation: drc-pulse 0.4s ease-in-out 3; -} - /* ─── Focus and motion ────────────────────────────────────────────────────── */ /* :focus-visible rather than :focus, so the ring appears for keyboard diff --git a/src/web/src/tile-grid.js b/src/web/src/tile-grid.js new file mode 100644 index 00000000000..222612f54d4 --- /dev/null +++ b/src/web/src/tile-grid.js @@ -0,0 +1,281 @@ +// SPDX-License-Identifier: BSD-3-Clause +// Copyright (c) 2026, The OpenROAD Authors + +// The tiles of one slot of the layout view: which to load for the view, which +// to cancel and which to drop. Pure: loading goes through `source`, drawing +// is the view's business. +// +// `source.load({z, x, y}, {background, onPartial})` returns +// `{ promise, cancel, promote }`; the promise resolves to a drawable, to null +// for an empty tile, or to undefined to keep the last partial. +// `source.release(drawable)` frees one. + +import { growRange, inRange, rangeTiles } from './view-math.js'; + +export function tileKey(z, x, y) { + return `${z}/${x}/${y}`; +} + +export class TileGrid { + constructor({ source, onChange = () => {}, keepBuffer = 2 } = {}) { + this.source = source; + this.onChange = onChange; + this.keepBuffer = keepBuffer; + this.tiles = new Map(); + this.z = null; + this.range = null; // on screen + this.ring = null; // on screen plus the prefetch ring + this.extra = []; // other levels kept loaded: [{ z, range }] + this._generation = 0; + this._loads = 0; // for debugSnapshot + this._cancels = 0; + } + + // Bring level z in line with the view: load what `ring` covers, on-screen + // tiles first and the rest at background priority, and cancel what left. + // `extra` levels load over their own ranges, in the background unless + // they say `background: false`. Loaded tiles in `hold`, what is on + // screen now when `range` is where the view is heading, are kept. + update({ z, range, ring = range, extra = [], hold = null }) { + this.z = z; + this.range = range; + this.ring = ring; + this.extra = extra.filter((e) => e.z !== z && e.range); + const extraOf = new Map(this.extra.map((e) => [e.z, e])); + for (const tile of [...this.tiles.values()]) { + if (tile.z !== z) { + const e = extraOf.get(tile.z); + const r = e && e.range; + // An extra level keeps a buffer like level z; any other level + // is left to prune(), which knows what is drawn. + const drop = r + ? !inRange(r, tile.x, tile.y) + && (tile.loading || !this._inKeepBuffer(tile, r)) + : tile.loading && !tile.drawable; + if (drop) { + this._drop(tile); + } else if (r && this._stale(tile) + && inRange(r, tile.x, tile.y)) { + this._load(tile, e.background !== false); + } + continue; + } + // Kept from before a refresh: fetch again once it is in the ring. + if (this._stale(tile) && inRange(ring, tile.x, tile.y)) { + this._load(tile, !inRange(range, tile.x, tile.y)); + } + if (inRange(ring, tile.x, tile.y)) { + if (tile.loading && tile.background + && inRange(range, tile.x, tile.y)) { + tile.background = false; + tile.handle?.promote?.(); + } + continue; + } + if (tile.loading || !(this._inKeepBuffer(tile) + || (hold && inRange(hold, tile.x, tile.y)))) { + this._drop(tile); + } + } + // On-screen tiles go out first, nearest the centre first. + const wanted = [...rangeTiles(range), + ...rangeTiles(ring).filter( + (t) => !inRange(range, t.x, t.y))]; + for (const { x, y } of wanted) { + if (!this.tiles.has(tileKey(z, x, y))) { + this._load(this._newTile(z, x, y), + !inRange(range, x, y)); + } + } + for (const e of this.extra) { + for (const { x, y } of rangeTiles(e.range)) { + if (!this.tiles.has(tileKey(e.z, x, y))) { + this._load(this._newTile(e.z, x, y), + e.background !== false); + } + } + } + } + + // Re-request the tiles of the ring and of the extra ranges in place: each + // keeps what it shows until its replacement arrives. The rest goes stale + // and is fetched when it is back in range; other levels wait for prune(). + refresh() { + this._generation++; + const extraOf = new Map(this.extra.map((e) => [e.z, e])); + for (const tile of [...this.tiles.values()]) { + const e = extraOf.get(tile.z); + const r = tile.z === this.z ? this.ring : e && e.range; + if (!r) { + continue; + } + if (inRange(r, tile.x, tile.y)) { + tile.handle?.cancel?.(); + this._load(tile, e ? e.background !== false + : !inRange(this.range, tile.x, tile.y)); + } else if (tile.loading) { + this._drop(tile); + } + } + } + + // True when no on-screen tile of the current level is still loading. + // Ring tiles do not count: they are off screen. + isSettled() { + for (const tile of this.tiles.values()) { + if (tile.z === this.z && tile.loading + && inRange(this.range, tile.x, tile.y)) { + return false; + } + } + return true; + } + + // True when every tile of level z in `range` has arrived. + settledIn(z, range) { + for (const { x, y } of rangeTiles(range)) { + const tile = this.tiles.get(tileKey(z, x, y)); + if (!tile || tile.loading) { + return false; + } + } + return true; + } + + // True when level z has at least one tile with something to draw. + hasContentAt(z) { + for (const tile of this.tiles.values()) { + if (tile.z === z && tile.drawable) { + return true; + } + } + return false; + } + + // Tiles of level z that have something to draw. + drawableTilesAt(z) { + const out = []; + for (const tile of this.tiles.values()) { + if (tile.z === z && tile.drawable) { + out.push(tile); + } + } + return out; + } + + // Drop every tile whose level is not in `keepZs`. + prune(keepZs) { + const keep = new Set(keepZs); + for (const tile of [...this.tiles.values()]) { + if (!keep.has(tile.z)) { + this._drop(tile); + } + } + } + + clear() { + for (const tile of [...this.tiles.values()]) { + this._drop(tile); + } + this.z = null; + this.range = null; + this.ring = null; + this.extra = []; + } + + stats() { + let loading = 0; + let drawable = 0; + for (const tile of this.tiles.values()) { + if (tile.loading) { + loading++; + } + if (tile.drawable) { + drawable++; + } + } + return { tiles: this.tiles.size, loading, drawable, + loads: this._loads, cancels: this._cancels }; + } + + _newTile(z, x, y) { + const tile = { z, x, y, key: tileKey(z, x, y), drawable: null, + loading: false, background: false, handle: null, + generation: -1 }; + this.tiles.set(tile.key, tile); + return tile; + } + + _load(tile, background) { + const generation = this._generation; + const current = () => this.tiles.get(tile.key) === tile + && tile.generation === generation; + tile.generation = generation; + tile.loading = true; + tile.background = background; + this._loads++; + const handle = this.source.load( + { z: tile.z, x: tile.x, y: tile.y }, + { + background, + // Progressive paints while the tile is still loading. + onPartial: (drawable) => { + if (!current()) { + this.source.release?.(drawable); + return; + } + this._setDrawable(tile, drawable); + this.onChange(tile); + }, + }); + tile.handle = handle; + handle.promise.then((drawable) => { + if (!current()) { + this.source.release?.(drawable); + return; + } + if (drawable !== undefined) { + this._setDrawable(tile, drawable); + } + tile.loading = false; + tile.handle = null; + this.onChange(tile); + }, () => { + // A failed tile counts as settled and keeps whatever it showed. + if (!current()) { + return; + } + tile.loading = false; + tile.handle = null; + this.onChange(tile); + }); + } + + _setDrawable(tile, drawable) { + if (tile.drawable && tile.drawable !== drawable) { + this.source.release?.(tile.drawable); + } + tile.drawable = drawable || null; + } + + _stale(tile) { + return !tile.loading && tile.generation !== this._generation; + } + + _inKeepBuffer(tile, r = this.range) { + return inRange(growRange(r, this.keepBuffer), tile.x, tile.y); + } + + _drop(tile) { + if (tile.loading) { + this._cancels++; + tile.handle?.cancel?.(); + } + if (tile.drawable) { + this.source.release?.(tile.drawable); + } + tile.drawable = null; + tile.loading = false; + this.tiles.delete(tile.key); + } +} diff --git a/src/web/src/tile-merge.js b/src/web/src/tile-merge.js index ca24c3ef3c0..b68223ce1f8 100644 --- a/src/web/src/tile-merge.js +++ b/src/web/src/tile-merge.js @@ -1,29 +1,15 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright (c) 2026, The OpenROAD Authors -// Client-side tile merging: collapse many single-layer tile panes into N -// composited panes, chosen from a decoded-image-memory budget. -// -// WHY -// -// The viewer keeps one Leaflet pane per (tech layer x chiplet instance). On a -// multi-die design that is ~97 panes, each holding a full grid of tiles, each -// tile decoding to (256*dpr)^2 * 4 bytes — 582 MB at dpr 1 in a 1240x999 -// window. Measured on that machine, Chrome starts discarding decoded images -// somewhere around 458 MB, and the discarded regions paint white and stay white -// until something forces a full invalidation. Established by measurement: the -// symptom is monotonic in decoded image bytes and indifferent to how they are -// distributed — at a matched 516 vs 517 MB, 86 and 97 content-bearing panes -// fail identically, which rules out pane count and stack depth. +// Client-side tile merging: composite the visible layout layers of one tile +// into a single image, so the view holds and draws one texture per tile +// instead of one per layer. // // WHY THE MERGE IS ON THE CLIENT // -// The client already knows the exact stacking order and per-pane opacity, so -// merging here reproduces precisely what the browser does today — one -// rasterization instead of K live layers — with no change to the renderer, no -// new wire format, and no decision about how chiplets should be ordered -// relative to each other. It also keeps the server's per-layer tile cache -// intact, which a server-side composite would coarsen. +// The client already knows the exact stacking order and per-layer opacity, so +// merging here is one rasterization instead of K live layers, and the server +// keeps one cached tile per layer, which a layer toggle reuses. // // The mechanism that makes it work is `ImageBitmap.close()`: an gives no // control over when its decoded bitmap is released, which is the whole problem. @@ -31,115 +17,14 @@ // draw them, release them immediately, and keep only the merged result. // // What it does NOT buy: bandwidth. The same K images are still fetched per -// tile. Only a server-side composite fixes that. - -// ─── Opacity ──────────────────────────────────────────────────────────────── -// -// Each layer's opacity is applied by Leaflet to the layer's CONTAINER div, not -// to the individual tile images: GridLayer._updateOpacity() calls -// setOpacity(this._container, this.options.opacity). Every layer is created at -// 1 — layer transparency lives in the tile pixels themselves, painted with the -// palette alpha the Qt GUI uses — but the merge still carries opacity per item -// rather than assuming one value, so a pane that does want partial opacity -// composites correctly. -// -// Group opacity on a container is NOT generally the same thing as per-image -// alpha: a group is rasterized at full alpha and then blended once, so anywhere -// two images inside the group overlap, group opacity blends the overlap once -// while per-image alpha blends it twice. It is safe here only because a -// layer's own tiles tile the plane without overlapping, which makes the two -// equivalent for a single layer — and that equivalence is what lets this module -// apply each source's opacity per-image with globalAlpha. -// -// (One transient exception: mid zoom-animation Leaflet keeps the outgoing zoom -// level's tiles alongside the incoming ones inside the same container, and those -// DO overlap. That is pre-existing behaviour at the layer level and applies -// equally to a merged pane, so it is not made worse here.) -// -// The trap: the merged result is itself a tile inside a pane. If that pane -// carried a source's opacity too, every source would be multiplied by it twice -// — 0.7 becomes 0.49 — and the view would wash out. The per-layer opacities -// live INSIDE the canvas, so the pane holding it must be fully opaque. -export const MERGED_PANE_OPACITY = 1; - -// Build the Leaflet options for a merged pane, so a caller cannot forget the -// above and silently double-apply opacity. -export function mergedPaneOptions({ zIndex = 0, tileSize } = {}) { - const opts = { opacity: MERGED_PANE_OPACITY, zIndex }; - if (tileSize !== undefined) { - opts.tileSize = tileSize; - } - return opts; -} - -// Bytes of decoded bitmap for one tile. Straight RGBA, which is what the -// browser holds regardless of the PNG's own bit depth — an 8-bit palette PNG -// still decodes to 32 bits per pixel, so compressing harder saves nothing here. -export const BYTES_PER_PIXEL = 4; - -// Default budget for decoded tile images. Chosen from the measurement, not from -// taste: ~458 MB was where the failure started on the machine that was profiled, -// 462 MB already showed flicker, and 456 MB was clean. 350 MB leaves ~23% margin -// under that, which matters because the real ceiling varies with the machine, the -// Chrome build and whatever else the renderer is holding. -// -// Deliberately not derived from `navigator.deviceMemory`: no API reports the -// image-cache budget, and the failure cannot be probed for without triggering -// it. A fixed conservative cap that is *enforced* beats a discovered number that -// might be wrong. Callers may scale this if they have better information. -export const DEFAULT_BUDGET_BYTES = 350 * 1024 * 1024; - -export function tileBytes(tileSizePx, dpr = 1) { - const side = Math.round(tileSizePx * Math.max(0, dpr)); - return side * side * BYTES_PER_PIXEL; -} - -// Tiles one pane holds for a viewport of this size. -// -// Leaflet covers the viewport and keeps a ring of tiles outside it, so this is -// (cols+1) x (rows+1) — deliberately an estimate, because the real count is only -// knowable once tiles exist and the budget has to be decided before then. It -// tracks window area, which is the factor that would otherwise make any fixed -// group count fail on a maximised 4K window. -export function estimateTilesPerPane(width, height, tileSizePx = 256) { - if (!(width > 0) || !(height > 0) || !(tileSizePx > 0)) { - return 1; - } - return (Math.ceil(width / tileSizePx) + 1) - * (Math.ceil(height / tileSizePx) + 1); -} - -// Viewport to size the budget against, with fallbacks. -// -// A container that is hidden or not yet laid out reports clientWidth 0, and a -// zero viewport is the dangerous direction: estimateTilesPerPane returns 1, -// computeGroupCount then divides the whole budget by one tile and comes back -// with groupCount == paneCount — one pane per layer, no merging at all, and the -// log cheerfully reports "merged 94 layers into 94 panes". The failure this -// exists to prevent then happens as soon as the panel is shown. -// -// Falling back to the window over-estimates (the map is a panel inside a -// layout, not the whole window), and over-estimating is safe: more tiles per -// pane means fewer panes, which is the conservative side of the budget. -export function measureViewport(container, win) { - const w = win || (typeof window !== 'undefined' ? window : null); - const width = (container && container.clientWidth > 0) - ? container.clientWidth - : ((w && w.innerWidth > 0) ? w.innerWidth : 1024); - const height = (container && container.clientHeight > 0) - ? container.clientHeight - : ((w && w.innerHeight > 0) ? w.innerHeight : 768); - return { width, height }; -} +// tile. With ?composite=1 the server composites runs of layers instead +// (tile_group, see tile-sources.js). // Set a draw item's visibility, returning whether it actually changed. // // The return value is the point. The layer tree's onChange walks EVERY node -// and asserts the desired state on each one, so a caller that marks its pane -// dirty unconditionally re-requests every tile in every pane on any checkbox -// click — roughly 2300 requests on the 97-layer design that motivated this. -// The per-layer panes never had that problem because Leaflet's addTo() is a -// no-op for a layer already on the map; this restores the same property. +// and asserts the desired state on each one, so a caller that marks its tiles +// dirty unconditionally re-requests every tile on any checkbox click. export function setItemVisible(item, visible) { if (!item) { return false; @@ -152,90 +37,17 @@ export function setItemVisible(item, visible) { return true; } -// Panes that stay unmerged and so are not counted by the grouping, but do hold -// a full grid of tiles each: _instances, _pins, _inst_labels (on with the -// instance names, the default) and the always-on highlight overlay. (_modules -// and the heatmap are only mounted when enabled, so they are not reserved for; -// they will push the total up when switched on.) -// -// At dpr 1 these are ~6 MB each and hardly matter. At dpr 3 a tile is 2.25 MB, -// so a pane is ~54 MB and the four together are ~216 MB — enough that a budget -// which ignored them would report a comfortable fit while the real total sat -// above the ceiling. -export const UNMERGED_PANE_COUNT = 4; - -// Budget left for the merged panes once the unmerged ones are charged for. -// -// Never returns less than one group's worth: the viewer has to render -// something, and a budget so small that no group fits would be a blank map -// rather than a slow one. -export function reserveForUnmergedPanes(budgetBytes, tilesPerPane, - bytesPerTile, - unmergedPanes = UNMERGED_PANE_COUNT) { - const perPane = tilesPerPane * bytesPerTile; - if (!(perPane > 0)) { - return budgetBytes; - } - return Math.max(perPane, budgetBytes - unmergedPanes * perPane); -} - -// How many merged panes fit in the budget. +// ─── Opacity ──────────────────────────────────────────────────────────────── // -// `tilesPerPane` must come from what Leaflet actually holds, not from the -// viewport size, because it includes the retained ring outside the view and -// grows with window area — the factor that would otherwise make any fixed N -// fail on a maximised 4K window (97 panes at 2560x1440 is ~1.9 GB). -export function computeGroupCount({ - budgetBytes = DEFAULT_BUDGET_BYTES, - tilesPerPane, - bytesPerTile, - paneCount, -} = {}) { - if (!(tilesPerPane > 0) || !(bytesPerTile > 0) || !(paneCount > 0)) { - return 1; - } - const perGroup = tilesPerPane * bytesPerTile; - // Never more groups than there are panes to put in them: merging cannot - // help past one pane per group, and asking for more would just recreate the - // situation this exists to avoid. - return Math.max(1, Math.min(paneCount, Math.floor(budgetBytes / perGroup))); -} - -// Split z-ordered draw items into `n` groups. -// -// Groups MUST be contiguous runs of the z-order. Each group is rasterized into -// a single image, and two images can only be stacked to reproduce the original -// if neither interleaves with the other: given z-order [1,2,3,4], the grouping -// {1,3},{2,4} has no stacking that yields the original, whereas {1,2},{3,4} -// does. So this slices the ordered list rather than distributing round-robin, -// even though round-robin would balance sizes better. -// -// `items` must already be sorted by ascending z-index (bottom-most first). -export function partitionIntoGroups(items, n) { - if (!Array.isArray(items) || items.length === 0) { - return []; - } - const groups = Math.max(1, Math.min(Math.floor(n) || 1, items.length)); - const base = Math.floor(items.length / groups); - let remainder = items.length % groups; - const out = []; - let at = 0; - for (let g = 0; g < groups; g++) { - let size = base; - if (remainder > 0) { - size++; - remainder--; - } - out.push(items.slice(at, at + size)); - at += size; - } - return out; -} +// Each source carries its own opacity, applied per image with globalAlpha. A +// layer's own tiles never overlap, so that equals opacity on the whole layer. +// The merged tile already holds those opacities and must be drawn at 1, or +// every source would be multiplied twice. // Draw `sources` onto a 2D context in order, each at its own opacity. // -// Straight src-over at the given alpha, which is what stacking the panes does -// today. Not bit-identical to CSS compositing — colour-space and rounding +// Straight src-over at the given alpha, which is what stacking the layers +// would do. Not bit-identical to GPU compositing — colour-space and rounding // details differ — so assert on visual equivalence, never on byte equality. // // `sources` is [{ image, opacity }], bottom-most first. A null image is skipped @@ -266,11 +78,11 @@ export function mergeOntoContext(ctx, sources, size) { // ─── Reference compositor ─────────────────────────────────────────────────── // -// Why grouping is exact at all: src-over is associative, so +// Why merging is exact at all: src-over is associative, so // (A over B) over C == A over (B over C). Rasterizing a contiguous run into one // image and compositing that image is therefore identical to compositing the run // member by member — PROVIDED the intermediate keeps its alpha (a transparent -// canvas does) and is composited at alpha 1 (hence MERGED_PANE_OPACITY). +// canvas does) and is composited at alpha 1. // // These helpers exist so that invariant is checked with numbers instead of // asserted in a comment. They are not used by the merge itself, which delegates @@ -327,11 +139,18 @@ export function closeAll(images) { // from scratch on every arrival, always walking the item list in order, so the // stacking cannot depend on the order responses happen to land in. // -// Incremental: the tile paints as soon as anything arrives rather than waiting -// for the slowest of its K layers, and keeps repainting as the rest land. A -// request that never settles therefore costs one missing layer instead of a -// blank tile — with the per-layer panes a stuck request blanked one layer, and -// waiting for the whole group would have made that a whole group. +// Incremental (the default): the tile paints as soon as anything arrives rather +// than waiting for the slowest of its K layers, and keeps repainting as the rest +// land. A request that never settles therefore costs one missing layer instead +// of a blank tile; waiting for the whole group would blank the whole tile. +// +// `incremental: false` is Options > "Double buffering" (#11340): every repaint +// clears the canvas first, so on a refresh of a tile already on screen the +// group is visibly rebuilt layer by layer. Painting once, after every request +// has settled, makes the swap atomic — the canvas is the buffer, since one +// synchronous clear-and-composite is never presented half done. It costs +// nothing in memory (the decodes were already held to the end, see Lifetime +// below) and the tile now appears at the pace of its slowest layer. // // Lifetime: every decoded image is released in a finally, including on a draw // failure or a stale abort. Explicit release is the entire reason for @@ -352,11 +171,11 @@ export async function renderMergedTile({ draw, release = closeAll, isStale = () => false, - onFirstDraw, + incremental = true, } = {}) { const list = Array.isArray(items) ? items : []; const stats = { requested: list.length, arrived: 0, decoded: 0, drawn: 0, - paints: 0, stale: false }; + paints: 0, failed: 0, stale: false }; if (list.length === 0) { // An empty group still has to paint: the canvas is reused across // refreshes, so skipping the draw would leave the previous content. @@ -389,15 +208,7 @@ export async function renderMergedTile({ opacity: item.opacity, }))) || 0; stats.paints++; - if (!painted) { - painted = true; - // Leaflet hides a tile until done() marks it loaded - // (.leaflet-tile { visibility: hidden }), so without this the - // incremental paints would not be visible at all. - if (onFirstDraw) { - onFirstDraw(); - } - } + painted = true; } try { @@ -406,6 +217,7 @@ export async function renderMergedTile({ try { payload = await request(item); } catch (e) { + stats.failed++; return; // cancelled or dropped: leave the slot transparent } if (payload == null) { @@ -425,11 +237,14 @@ export async function renderMergedTile({ // even when this render has been superseded. images[i] = image; stats.decoded++; - paint(); + if (incremental) { + paint(); + } })); - // Nothing arrived at all — paint the empty composite anyway, so the - // tile resolves as blank rather than staying invisible forever. + // The only paint when buffering; otherwise the case where nothing + // arrived at all, so the tile resolves as blank rather than staying + // invisible forever. if (!painted) { paint(); } @@ -437,29 +252,8 @@ export async function renderMergedTile({ // Held until the tile is complete rather than released per draw: a // later arrival belongs UNDERNEATH layers already drawn, so the canvas // is recomposited from scratch each time and every source has to still - // be available. Peak is the same K bitmaps the batch version held. + // be available. release(images); } return stats; } - -// Summary of what a grouping costs, for logging and for the HUD. -export function describePlan({ paneCount, groupCount, tilesPerPane, - bytesPerTile }) { - const mb = (bytes) => Math.round(bytes / (1024 * 1024)); - const before = paneCount * tilesPerPane * bytesPerTile; - const after = groupCount * tilesPerPane * bytesPerTile; - return { - paneCount, - groupCount, - tilesPerPane, - beforeMB: mb(before), - afterMB: mb(after), - // Peak extra while a group is being merged: its sources are decoded - // together, then closed. Worth reporting because a very small - // groupCount means very large groups, and the transient is what would - // bite if the merge held every source at once. - transientMB: mb(Math.ceil(paneCount / Math.max(1, groupCount)) - * bytesPerTile), - }; -} diff --git a/src/web/src/tile-request.js b/src/web/src/tile-request.js index 19b0d154e00..95d2d8a0547 100644 --- a/src/web/src/tile-request.js +++ b/src/web/src/tile-request.js @@ -1,18 +1,14 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright (c) 2026, The OpenROAD Authors -// Wire format for tile requests, shared by the per-layer tile layer and the -// merged (multi-layer) one. -// -// Split out of websocket-tile-layer.js so both layer types share one definition -// of the payload and cannot drift on the wire — a divergence would give the two -// paths different server-side tile-cache keys, and one of them would miss the -// cache entirely. +// Wire format for tile requests, shared by every tile source so they cannot +// drift on the wire — a divergence would give two paths different server-side +// tile-cache keys, and one of them would miss the cache entirely. // Normalize the display's device pixel ratio into the value sent on the wire. // // The pixel size of a tile no longer comes from this: `tile_px` carries the -// exact device-pixel square the tile will occupy (see buildTileRequestFor), so +// exact device-pixel square the tile will occupy (see tileRequestBuilder), so // the image maps 1:1 onto the device grid and the browser never resamples it — // which is what would otherwise reintroduce the moiré beat on HiDPI displays. // Rounding the ratio and multiplying by the tile size, as this once did, cannot @@ -38,47 +34,25 @@ export function quantizeDpr(raw) { // 256 is not such a number. At a 1.6667 display scale (166%, ordinary on // Windows and Linux) 256 CSS px is 426.67 device px, so the tile *pitch* is // fractional: boundaries land at 426.67k device px and only every third one can -// sit on the grid, whatever the pane offset is. The browser antialiases the +// sit on the grid, whatever the view offset is. The browser antialiases the // other two into their neighbours, src-over leaves the coverage short of 1, and -// the pane background shows through as a dark hairline on every seam. +// the background shows through as a dark hairline on every seam. // // 240 = 2^4 * 3 * 5 is divisible by the denominator of every real ratio — // 1.25 = 5/4, 1.5 = 3/2, 1.6667 = 5/3, 1.75 = 7/4, 1.375 = 11/8, 1.1 = 11/10, // 2.5 = 5/2 — so tileSize*dpr comes out whole and the pitch is exact. // // Total decoded bytes barely move: the tiles are 6% smaller on a side and there -// are ~14% more of them, so the pixel count is a wash (see tile-merge.js for the -// budget). The cost is the extra request per tile. +// are ~14% more of them, so the pixel count is a wash. The cost is the extra +// request per tile. export const TILE_SIZE_CSS = 240; // Static reports carry tiles pre-rasterized at 256 CSS px by whoever authored // them. Those are files, not requests, so that path keeps the old size. export const STATIC_TILE_SIZE_CSS = 256; -// What an tile holds when the server drew nothing into it: a 1x1 -// transparent GIF. -// -// It has to hold SOMETHING. An with no src attribute but a CSS width and -// height is not nothing to the browser -- Chrome paints the empty replaced -// element, and since most tiles in a viewport are empty that came out as a grey -// grid over the whole layout, one cell per tile. Clearing the attribute is the -// obvious way to say "no image" and it is the wrong one. -// -// This costs a 1x1 decode, 4 bytes, so it keeps what the empty response is for: -// the tile still does not decode a full-size transparent PNG or hold a bitmap -// the size of the tile. Its load event also fires, which is what completes the -// tile with Leaflet -- see the tile layers, which keep a tile hidden until then. -// -// It carries a Graphic Control Extension declaring colour 0 transparent. A 1x1 -// GIF without one is a common paste and is NOT transparent: an stretches -// its single opaque pixel over the whole tile, so a viewport of empty tiles -// comes out a solid wash instead of showing the layout underneath. -export const BLANK_TILE - = 'data:image/gif;base64,' - + 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'; - // The CSS tile size in force for this session. Resolved once rather than -// passed around: the map's coordinate scale, all three tile layers and the +// passed around: the view's coordinate scale, every tile slot and the // request payload must agree on it, and a value threaded through five call // sites is a value that eventually disagrees with itself. let tile_size_css = TILE_SIZE_CSS; @@ -112,7 +86,7 @@ const LAYOUT_UNIT = 1 / 64; // a size is whole in device pixels at ALL of them exactly when it is a // multiple of lcm(4,3,8,2,3,4,6,2,10) = 120. Sizes chosen for the current // ratio alone would come apart the moment devicePixelRatio changes -- browser -// zoom, or the window moving to another monitor -- and the tile panes are +// zoom, or the window moving to another monitor -- and the tile slots are // built once, so nothing re-picks the size. Keeping to the quantum makes the // choice independent of dpr and bounds the tile-cache key space the server // sees to two sizes instead of a continuum. @@ -142,16 +116,6 @@ export function useFittedTileSize(size) { tile_size_css = size; } -// Merge the device-exact tile size into a Leaflet options object without -// overriding an explicit choice (the static path passes its own). -export function withDeviceExactTileSize(options) { - const opts = { ...(options || {}) }; - if (opts.tileSize === undefined) { - opts.tileSize = tileSizeCss(); - } - return opts; -} - // Device pixels for one tile: what the server is asked to render, and what a // merged canvas sizes its backing store to. Sent explicitly rather than left to // the server to derive, so the image is exactly the box it will be drawn into. @@ -209,44 +173,71 @@ export function tileSizeFields(dpr, tileSize = tileSizeCss()) { // so the wire schema stays uniform with selectAt requests. // // `dpr` is passed in rather than read here so a caller can override it without -// this module knowing anything about why. -export function buildTileRequestFor(coords, layerName, ctx, dpr, - tileSize = tileSizeCss()) { - const { visibility, selectability, visibleLayers, selectableLayers, app } - = ctx; - const vf = {}; - for (const [k, v] of Object.entries(visibility || {})) { - vf[k] = !!v; - } +// this module knowing anything about why. Returns `layerName => request`, +// with the fields every layer shares built once. +export function tileRequestBuilder(coords, ctx, dpr, tileSize = tileSizeCss()) { + const { selectability, selectableLayers, app } = ctx; + const shared = { + ...renderFields(coords, ctx, dpr, tileSize), + selectable_layers: selectableLayers ? [...selectableLayers] : [], + }; if (selectability) { for (const [k, v] of Object.entries(selectability)) { - vf['s_' + k] = !!v; + shared['s_' + k] = !!v; } } + return (layerName) => { + const req = { type: 'tile', layer: layerName, ...shared }; + const p = layerPattern(app, layerName); + if (p !== 1) { + req.pattern = p; + } + return req; + }; +} + +// One request for a run of layers, which the server composites bottom to top +// into a single image. Selectability changes no pixel, so it is left off. +export function buildGroupTileRequestFor(coords, layerNames, ctx, dpr, + tileSize = tileSizeCss()) { const req = { - type: 'tile', - layer: layerName, + type: 'tile_group', + layers: [...layerNames], + ...renderFields(coords, ctx, dpr, tileSize), + }; + const patterns = layerNames.map(name => layerPattern(ctx.app, name)); + if (patterns.some(p => p !== 1)) { + req.patterns = patterns; + } + return req; +} + +// The fields a layer render reads, shared by 'tile' and 'tile_group' so the +// two cannot drift. +function renderFields(coords, ctx, dpr, tileSize) { + const { visibility, visibleLayers, app } = ctx; + const fields = { z: coords.z, x: coords.x, y: coords.y, ...tileSizeFields(dpr, tileSize), visible_layers: visibleLayers ? [...visibleLayers] : [], - selectable_layers: selectableLayers ? [...selectableLayers] : [], - ...vf, }; - if (app && app.visibleChiplets instanceof Set) { - req.visible_chiplets = [...app.visibleChiplets]; + for (const [k, v] of Object.entries(visibility || {})) { + fields[k] = !!v; } - // Per-layer fill pattern (int matching the server's FillPattern enum; - // 1 = solid). Read lazily so a change via the layer context menu is picked - // up on the next refresh without rebuilding the layer. - if (app && app.layerPatterns) { - const p = app.layerPatterns[layerName]; - if (p !== undefined && p !== 1) { - req.pattern = p; - } + if (app && app.visibleChiplets instanceof Set) { + fields.visible_chiplets = [...app.visibleChiplets]; } - return req; + return fields; +} + +// Per-layer fill pattern (int matching the server's FillPattern enum; 1 = +// solid). Read lazily so a change via the layer context menu is picked up on +// the next refresh without rebuilding the layer. +function layerPattern(app, layerName) { + const p = app && app.layerPatterns ? app.layerPatterns[layerName] : undefined; + return p === undefined ? 1 : p; } // Call `onChange` whenever devicePixelRatio changes — a window dragged to @@ -299,13 +290,3 @@ export function watchDevicePixelRatio(onChange) { handler = null; }; } - -// Floor the map's REAL (possibly fractional) zoom so the displayed tile pane is -// only ever UPSCALED (scale 2^(realZoom-floor) ∈ [1,2)), never downscaled. -// Upscaling a band-limited tile cannot reintroduce the moiré beat; downscaling -// can. Reading the live map zoom (not the passed arg) keeps this correct during -// zoom-animation frames and robust even if zoomSnap:0 is re-enabled. -export function floorClampZoom(layer, zoom) { - const real = (layer && layer._map) ? layer._map.getZoom() : zoom; - return Math.floor(real); -} diff --git a/src/web/src/tile-sources.js b/src/web/src/tile-sources.js new file mode 100644 index 00000000000..c0efaab5752 --- /dev/null +++ b/src/web/src/tile-sources.js @@ -0,0 +1,315 @@ +// SPDX-License-Identifier: BSD-3-Clause +// Copyright (c) 2026, The OpenROAD Authors + +// Where the layout view's tiles come from. Each source turns a tile (z, x, y) +// in the server's grid into a drawable `{ image, width, height }`, or null for +// a tile with nothing in it, and implements the TileGrid source contract: +// `load(coords, {background, onPartial}) -> {promise, cancel, promote}` and +// `release(drawable)`. + +import { + buildGroupTileRequestFor, tileDevicePx, tileRequestBuilder, tileSizeFields, +} from './tile-request.js'; +import { closeAll, mergeOntoContext, renderMergedTile } from './tile-merge.js'; +import { tileMayHaveContent } from './layer-extents.js'; + +// Decode a tile payload: a Blob from the server, or a data URI from a saved +// report. Straight alpha and no colour conversion, so the pixels reach the +// GPU as the server wrote them. +function decodeTilePayload(payload) { + if (payload == null) { + return Promise.resolve(null); + } + if (typeof payload === 'string') { + return new Promise((resolve) => { + const img = document.createElement('img'); + img.onload = () => resolve(img); + img.onerror = () => resolve(null); + img.src = payload; + }); + } + return createImageBitmap(payload, { premultiplyAlpha: 'none', + colorSpaceConversion: 'none' }) + .catch(() => null); +} + +export function releaseDrawable(drawable) { + closeAll([drawable && drawable.image]); +} + +function imageSize(image) { + return { + width: image.naturalWidth || image.width, + height: image.naturalHeight || image.height, + }; +} + +function asDrawable(image) { + return image ? { image, ...imageSize(image) } : null; +} + +function defaultCanvas(px) { + if (typeof OffscreenCanvas === 'function') { + return new OffscreenCanvas(px, px); + } + const canvas = document.createElement('canvas'); + canvas.width = px; + canvas.height = px; + return canvas; +} + +// A 2D canvas holding a copy of `src`. +export function copyToCanvas2d(src) { + const copy = document.createElement('canvas'); + copy.width = src.width; + copy.height = src.height; + copy.getContext('2d').drawImage(src, 0, 0); + return copy; +} + +// Snapshot of the composite. transferToImageBitmap empties the canvas, which +// is fine: every paint recomposites from scratch. +function defaultSnapshot(canvas) { + if (typeof canvas.transferToImageBitmap === 'function') { + return asDrawable(canvas.transferToImageBitmap()); + } + return asDrawable(copyToCanvas2d(canvas)); +} + +const NOTHING = Object.freeze({ + promise: Promise.resolve(null), cancel() {}, promote() {}, +}); + +// Issue one request through `wm`, tracking its id for cancel and promote. +function tracked(wm, ids, msg, background) { + const promise = wm.request(msg, { background }); + if (promise.requestId != null) { + ids.push(promise.requestId); + } + return promise; +} + +// The load handle over the requests in `ids`; `onCancel` runs before they are +// cancelled. +function loadHandle(wm, ids, promise, onCancel) { + return { + promise, + cancel() { + onCancel(); + for (const id of ids) { + wm.cancel(id); + } + }, + promote() { + for (const id of ids) { + wm.promote?.(id); + } + }, + }; +} + +// Layers per group when the server composites runs of layers (tile_group). +export const DEFAULT_GROUP_LAYERS = 3; + +// Each tech layer's run: the slot's whole list cut into runs of up to `perRun` +// between pseudo layers, so a toggle changes the request of its own run only. +// Pseudo layers ('_instances', ...) map to null: the server groups tech +// layers only. +function runOf(all, perRun) { + const runs = new Map(); + let segment = 0; + let n = 0; + for (const item of all) { + if (!item || runs.has(item.layer)) { + continue; + } + if (item.layer.startsWith('_')) { + runs.set(item.layer, null); + segment++; + n = 0; + continue; + } + runs.set(item.layer, `${segment}:${Math.floor(n++ / perRun)}`); + } + return runs; +} + +// One tile_group request per run present in the tile, bottom up, and a +// 'tile' request for each pseudo layer. +function groupRequests(all, items, perRun, build, coords, ctx, dpr, tileSize) { + const runs = runOf(all, perRun); + const parts = []; + let run = null; + const flush = () => { + if (run) { + parts.push({ opacity: 1, msg: buildGroupTileRequestFor( + coords, run.layers, ctx, dpr, tileSize) }); + run = null; + } + }; + for (const item of items) { + const id = runs.get(item.layer); + if (id == null) { + flush(); + parts.push({ opacity: 1, msg: build(item.layer) }); + continue; + } + if (run && run.id !== id) { + flush(); + } + run = run || { id, layers: [] }; + run.layers.push(item.layer); + } + flush(); + return parts; +} + +// The layout layers of a slot, composited into one image per tile in z-order +// (`getItems()` returns [{layer, opacity, visible}], bottom-most first). With +// double buffering the tile is drawn once, complete; otherwise every layer that +// lands is published as a partial composite. `groupLayers()` > 0 asks the +// server to composite runs of that many layers (tile_group). +export function createCompositeSource({ + wm, ctx, getItems, dpr = () => 1, tileSize = () => 240, + isDoubleBuffer = () => true, decode = decodeTilePayload, + makeCanvas = defaultCanvas, snapshot = defaultSnapshot, + groupLayers = () => 0, +}) { + return { + load({ z, x, y }, { background = false, onPartial } = {}) { + const all = getItems() || []; + // A layer with nothing in this tile is not requested at all + // (layer-extents.js). + const visible = all.filter( + (item) => item && item.visible !== false + && tileMayHaveContent(ctx, item.layer, { z, x, y })); + const d = dpr(); + const t = tileSize(); + // One request per layer: every chiplet lists its own copy of a + // shared tech layer, and the server answers each copy with the + // same image, which would be composited once per copy. + const seen = new Set(); + const items = visible.filter((item) => !seen.has(item.layer) + && seen.add(item.layer)); + if (items.length === 0) { + return NOTHING; + } + const build = tileRequestBuilder({ z, x, y }, ctx, d, t); + // The server composites at full opacity, so one translucent layer + // sends the whole tile per layer. + const perRun = groupLayers(); + const parts = perRun > 0 + && items.every((item) => (item.opacity ?? 1) === 1) + ? groupRequests(all, items, perRun, build, { z, x, y }, ctx, + d, t) + : items.map((item) => ({ opacity: item.opacity, + msg: build(item.layer) })); + const px = tileDevicePx(t, d); + // Made on the first draw with an image, so an empty or + // cancelled tile never allocates one. + let canvas = null; + let g = null; + const ids = []; + let cancelled = false; + const progressive = !isDoubleBuffer() + && typeof onPartial === 'function'; + const promise = renderMergedTile({ + items: parts, + request: (part) => tracked(wm, ids, part.msg, background), + decode, + draw: (sources) => { + if (!canvas) { + if (!sources.some((s) => s.image)) { + return 0; + } + canvas = makeCanvas(px); + g = canvas.getContext('2d'); + } + const drawn = mergeOntoContext(g, sources, px); + if (progressive && drawn > 0 && !cancelled) { + onPartial(snapshot(canvas)); + } + return drawn; + }, + isStale: () => cancelled, + incremental: progressive, + }).then((stats) => { + if (cancelled) { + throw new Error('Tile cancelled'); + } + // Disconnected: keep what the tile showed, not a blank. + if (stats.failed === stats.requested) { + throw new Error('Tile requests failed'); + } + if (stats.drawn === 0) { + return null; + } + // Progressive: the last partial already holds every layer, + // and undefined tells the grid to keep it. + return progressive ? undefined : snapshot(canvas); + }); + return loadHandle(wm, ids, promise, () => { cancelled = true; }); + }, + release: releaseDrawable, + }; +} + +// One server image per tile: `buildRequest({z, x, y}, dpr, tileSize)` returns +// the request, or null for a tile that needs none. +export function createImageSource({ + wm, buildRequest, dpr = () => 1, tileSize = () => 240, + decode = decodeTilePayload, +}) { + return { + load({ z, x, y }, { background = false } = {}) { + const msg = buildRequest({ z, x, y }, dpr(), tileSize()); + if (!msg) { + return NOTHING; + } + const ids = []; + let cancelled = false; + const promise = tracked(wm, ids, msg, background) + .then((payload) => decode(payload)) + .then((image) => { + if (cancelled) { + releaseDrawable(asDrawable(image)); + throw new Error('Tile cancelled'); + } + return asDrawable(image); + }); + return loadHandle(wm, ids, promise, () => { cancelled = true; }); + }, + release: releaseDrawable, + }; +} + +// The highlight overlay: selection, timing paths, DRC markers, route guides +// and label text, drawn by the server on a transparent tile. +export function buildOverlayRequest({ z, x, y }, dpr, tileSize, visibility, app) { + const req = { + type: 'overlay_tile', + z, x, y, + ...tileSizeFields(dpr, tileSize), + debug_renderers: !!visibility.debug_renderers, + debug_live: !!visibility.debug_live, + flywires_only: !!visibility.flywires_only, + poly_decomp: !!(app && app.polyDecomp), + focused_nets_guides: !!visibility.focused_nets_guides, + highlight_selected: visibility.highlight_selected !== false, + draw_labels: visibility.labels !== false, + }; + if (app && app.visibleLayerNames) { + req.visible_layers = [...app.visibleLayerNames]; + } + return req; +} + +// The active heat map, or no request at all when none is shown. +export function buildHeatmapRequest({ z, x, y }, dpr, tileSize, app) { + const name = app && app.activeHeatMap; + if (!name) { + return null; + } + return { type: 'heatmap_tile', name, z, x, y, + ...tileSizeFields(dpr, tileSize) }; +} diff --git a/src/web/src/tile_generator.cpp b/src/web/src/tile_generator.cpp index e01656b83b3..8c46b1261fb 100644 --- a/src/web/src/tile_generator.cpp +++ b/src/web/src/tile_generator.cpp @@ -34,6 +34,8 @@ #include #include "boost/json/array.hpp" +#include "boost/json/object.hpp" +#include "boost/json/serialize.hpp" #include "color.h" #include "db_sta/dbSta.hh" #include "font_atlas.h" @@ -1061,12 +1063,6 @@ inline int hairlineCss(const TileFrame& frame) return std::max(1, static_cast(std::lround(frame.px_per_css))); } -} // namespace - -namespace { - -// Every boolean TileVisibility field: its JSON key and the default an omitted -// key falls back to. struct BoolField { const char* key; @@ -1074,9 +1070,11 @@ struct BoolField bool default_val; }; +// Every visibility flag a tile render reads, with its default. Parsing and +// the tile-cache key walk the same list. // clang-format off // NOLINTBEGIN(modernize-use-designated-initializers) -const BoolField kBoolFields[] = { +const BoolField kVisibilityFields[] = { {"stdcells", &TileVisibility::stdcells, true}, {"macros", &TileVisibility::macros, true}, {"pad_input", &TileVisibility::pad_input, true}, @@ -1146,7 +1144,7 @@ const BoolField kBoolFields[] = { std::optional TileVisibility::flag(const std::string_view key) const { - for (const BoolField& f : kBoolFields) { + for (const BoolField& f : kVisibilityFields) { if (key == f.key) { return this->*(f.field); } @@ -1154,12 +1152,23 @@ std::optional TileVisibility::flag(const std::string_view key) const return std::nullopt; } +/* static */ +std::vector TileVisibility::flagKeys() +{ + std::vector keys; + keys.reserve(std::size(kVisibilityFields)); + for (const BoolField& f : kVisibilityFields) { + keys.emplace_back(f.key); + } + return keys; +} + void TileVisibility::parseFromJson(const boost::json::object& json) { // Visibility flags are nominally always sent by the web frontend, but // tests and the saveImage Tcl entry point can pass partial payloads; // fall back to the per-field default when a flag is omitted. - for (const auto& f : kBoolFields) { + for (const auto& f : kVisibilityFields) { this->*(f.field) = jsonOr(json, f.key, f.default_val); } @@ -1195,12 +1204,8 @@ void TileVisibility::parseFromJson(const boost::json::object& json) // Per-layer fill pattern for the requested layer (int mirrors FillPattern / // web::Painter::Brush). Defaults to solid; clamp unknown values so a bad // payload can't index outside the enum. - const int64_t pattern - = jsonOr(json, "pattern", static_cast(FillPattern::kSolid)); - fill_pattern = (pattern >= static_cast(FillPattern::kNone) - && pattern <= static_cast(FillPattern::kDots)) - ? static_cast(pattern) - : FillPattern::kSolid; + fill_pattern = toFillPattern( + jsonOr(json, "pattern", static_cast(FillPattern::kSolid))); // ── Selectability peers ── // clang-format off @@ -1678,6 +1683,7 @@ void TileGenerator::eagerInit() std::lock_guard lock(tile_cache_mutex_); tile_cache_lru_.clear(); tile_cache_index_.clear(); + tile_cache_bytes_ = 0; } // suppress_guard restores suppress_design_changed_ to false on return. } @@ -1701,6 +1707,7 @@ void TileGenerator::onDesignChanged() std::lock_guard lock(tile_cache_mutex_); tile_cache_lru_.clear(); tile_cache_index_.clear(); + tile_cache_bytes_ = 0; } // The geometry cache is NOT dropped here. This hook is debounced (see @@ -1741,18 +1748,27 @@ bool TileGenerator::tileCacheGet(const std::string& key, void TileGenerator::tileCachePut(std::string key, std::vector png) const { + // Keeping it would evict everything else. + if (png.size() > kTileCacheBytesCap) { + return; + } std::lock_guard lock(tile_cache_mutex_); const auto it = tile_cache_index_.find(key); if (it != tile_cache_index_.end()) { // Already present: refresh contents and promote to most-recent. + tile_cache_bytes_ -= it->second->second.size(); + tile_cache_bytes_ += png.size(); it->second->second = std::move(png); tile_cache_lru_.splice( tile_cache_lru_.begin(), tile_cache_lru_, it->second); - return; + } else { + tile_cache_bytes_ += png.size(); + tile_cache_lru_.emplace_front(key, std::move(png)); + tile_cache_index_[std::move(key)] = tile_cache_lru_.begin(); } - tile_cache_lru_.emplace_front(key, std::move(png)); - tile_cache_index_[std::move(key)] = tile_cache_lru_.begin(); - if (tile_cache_lru_.size() > kTileCacheCap) { + while (tile_cache_lru_.size() > kTileCacheCap + || tile_cache_bytes_ > kTileCacheBytesCap) { + tile_cache_bytes_ -= tile_cache_lru_.back().second.size(); tile_cache_index_.erase(tile_cache_lru_.back().first); tile_cache_lru_.pop_back(); } @@ -1764,6 +1780,80 @@ size_t TileGenerator::tileCacheSize() const return tile_cache_lru_.size(); } +size_t TileGenerator::tileCacheBytes() const +{ + std::lock_guard lock(tile_cache_mutex_); + return tile_cache_bytes_; +} + +/* static */ +std::string TileGenerator::tileCacheKey(const TileVisibility& vis, + const std::string_view layer) +{ + // A flag a pseudo layer shows by matters to that layer alone, and the + // others excepted here are each read by a single pass. Every other flag + // counts. + const auto affects = [layer](const BoolField& f) { + const std::string_view key = f.key; + // Also gates the cell-pin shapes drawn on the tech layers. + if (key == "inst_pins") { + return true; + } + for (const PseudoLayerDef& def : pseudoLayerDefs()) { + for (const auto& group : def.shown_by) { + if (std::ranges::find(group, key) != group.end()) { + return layer == def.name; + } + } + } + if (key == "pin_markers" || key == "pin_names") { + return layer == "_pins"; + } + if (key == "rows") { + return layer == "_instances"; + } + // Labels are drawn by the overlay tile. + return key != "labels"; + }; + + std::string flags; + flags.reserve(std::size(kVisibilityFields)); + for (const BoolField& f : kVisibilityFields) { + flags += !affects(f) ? '-' : (vis.*(f.field) ? '1' : '0'); + } + + boost::json::object key; + key["v"] = flags; + key["p"] = static_cast(vis.fill_pattern); + if (vis.has_visible_chiplets) { + key["c"] = boost::json::array(vis.visible_chiplets.begin(), + vis.visible_chiplets.end()); + } + // Only the pin markers and the overlays that draw by the visible layers + // under this visibility filter by tech layer. + const auto draws_by_layers = [&vis, layer]() { + return std::ranges::any_of( + pseudoLayerDefs(), [&vis, layer](const PseudoLayerDef& def) { + return layer == def.name && anyGroupOn(def.layers_by, vis); + }); + }; + if (vis.has_visible_layers && (layer == "_pins" || draws_by_layers())) { + key["l"] = boost::json::array(vis.visible_layers.begin(), + vis.visible_layers.end()); + } + if (vis.rows && layer == "_instances") { + std::vector> sites(vis.sites.begin(), + vis.sites.end()); + std::ranges::sort(sites); + boost::json::object site_flags; + for (const auto& [name, visible] : sites) { + site_flags[name] = visible; + } + key["s"] = std::move(site_flags); + } + return boost::json::serialize(key); +} + namespace { // Cheap-to-compute fingerprint of the current chiplet hierarchy: every @@ -2928,7 +3018,7 @@ std::vector TileGenerator::selectAt( } // Compute a search margin of 2 pixels at the current zoom level. // This accounts for coordinate conversion rounding between the client's - // Leaflet CRS.Simple coordinates and the server's DBU space. + // view coordinates and the server's DBU space. const int num_tiles = 1 << std::max(0, zoom); const int margin = std::max(1, getBounds().maxDXDY() / (kTileSizeInPixel * num_tiles) * 2); @@ -3420,6 +3510,66 @@ std::vector TileGenerator::generateTile( return png_data; } +std::vector TileGenerator::generateGroupTile( + const std::vector& layers, + const std::vector& patterns, + const int z, + const int x, + const int y, + const TileVisibility& vis, + const std::set* focus_net_ids, + const double dpr, + const int tile_px, + const std::function& aborted) const +{ + TileVisibility layer_vis = vis; + std::vector composite; + int dim = 0; + for (size_t i = 0; i < layers.size(); ++i) { + if (aborted()) { + return {}; + } + layer_vis.fill_pattern = patterns[i]; + std::vector layer_buffer = renderTileBuffer(layers[i], + z, + x, + y, + layer_vis, + {}, + {}, + {}, + {}, + nullptr, + focus_net_ids, + nullptr, + dpr, + tile_px); + // Transparent pixels come back all-zero, so the bottom layer is already + // its own composite onto an empty tile. + if (composite.empty()) { + dim = bufferDim(layer_buffer); + composite = std::move(layer_buffer); + } else { + compositeTile(layer_buffer, dim, composite.data(), dim, 0, 0); + } + } + if (composite.empty()) { + return {}; + } + + unsigned encode_error = 0; + std::vector png_data + = encodeImagePng(composite, dim, dim, &encode_error); + if (encode_error != 0) { + logger_->report("PNG encoder error on group tile {}/{}/{}: {}", + z, + x, + y, + lodepng_error_text(encode_error)); + } + return png_data; +} + std::vector TileGenerator::generateOverlayTile( const int z, const int x, @@ -4230,12 +4380,12 @@ std::vector TileGenerator::saveImageLayerOrder( const TileVisibility& vis, const std::vector& tech_layers) { - // Bottom to top, by the z order the client stacks the layers in on screen - // (addPseudoLayer / the layer loop in display-controls.js): Leaflet paints - // by zIndex, so a PNG composited in any other order is not the view the - // user saw. Compositing in registry order — every pseudo layer last — put - // the manufacturing grid over the routing and the pin markers over the tech - // layers. These three mirror the client's non-pseudo values; + // Bottom to top, by the SAME z order the client stacks the layers in on + // screen (the draw lists in display-controls.js): the view paints in + // that order, so a PNG composited in any other order is not the view + // the user saw. Compositing in registry order — every pseudo layer last — + // put the manufacturing grid over the routing and the pin markers over the + // tech layers. These three mirror the client's non-pseudo values; // PseudoLayerDef::z_index carries the overlays'. // // `tech_layers` arrives already in the client's paint order — see @@ -4277,10 +4427,11 @@ std::vector TileGenerator::saveImageLayerOrder( const std::array& TileGenerator::pseudoLayerDefs() { - // z_index follows the GUI's paint order (renderThread.cpp:1201-1298), where - // the manufacturing grid goes down before the routing layers, the instance - // names right after them, and access points, regions and the gcell grid on - // top. + // z_index mirrors the client's draw lists in display-controls.js (see + // saveImageLayerOrder); that order in turn follows the GUI's paint order + // (renderThread.cpp:1201-1298), where the manufacturing grid goes down before + // the routing layers, the instance names right after them, and access + // points, regions and the gcell grid on top. static const std::array defs = {{ {.name = "_access_points", .shown_by = {{"access_points"}}, @@ -4494,7 +4645,7 @@ std::vector TileGenerator::renderTileBuffer( : size_limit_dbu; // The geometry the tile request resolves to: which slice of the design it // covers and at what resolution. `y` here is already flipped out of the - // client's Leaflet convention, so it will not match the requested y. The + // client's top-down convention, so it will not match the requested y. The // micron window depends only on the design bounds and z; tile_px/draw_px // and the cull limits are the dpr-derived part. const double dbu_per_micron = db_->getDbuPerMicron(); @@ -6329,12 +6480,12 @@ std::vector TileGenerator::renderImageBuffer( const int out_ox = (tx - tx_min) * kTileSizeInPixel; // Y is flipped: ty is bottom-up, output is top-down. const int out_oy = (ty_max - ty) * kTileSizeInPixel; - // Leaflet-style y coordinate (before the flip in renderTileBuffer). - const int leaflet_y = num_tiles - 1 - ty; + // Client (top-down) y coordinate, before the flip in renderTileBuffer. + const int top_down_y = num_tiles - 1 - ty; for (const auto& layer : layers_to_render) { const auto tile_buf - = renderTileBuffer(layer, z, tx, leaflet_y, image_vis); + = renderTileBuffer(layer, z, tx, top_down_y, image_vis); compositeTile(tile_buf, kTileSizeInPixel, output.data(), @@ -6346,7 +6497,7 @@ std::vector TileGenerator::renderImageBuffer( // User text labels go on top of all layers (Qt parity: labels appear // in save_image). if (!labels.empty()) { - const auto label_buf = renderLabelTile(z, tx, leaflet_y, labels); + const auto label_buf = renderLabelTile(z, tx, top_down_y, labels); if (!label_buf.empty()) { compositeTile(label_buf, kTileSizeInPixel, @@ -6655,10 +6806,10 @@ std::vector TileGenerator::renderOverlayPng( for (int tx = 0; tx <= tx_max; ++tx) { const int out_ox = tx * kTileSizeInPixel; const int out_oy = (ty_max - ty) * kTileSizeInPixel; - const int leaflet_y = num_tiles - 1 - ty; + const int top_down_y = num_tiles - 1 - ty; auto tile_buf = renderTileBuffer( - "_instances", z, tx, leaflet_y, vis, {}, {}, rects, lines); + "_instances", z, tx, top_down_y, vis, {}, {}, rects, lines); for (int py = 0; py < kTileSizeInPixel; ++py) { for (int px = 0; px < kTileSizeInPixel; ++px) { diff --git a/src/web/src/tile_generator.h b/src/web/src/tile_generator.h index fd9644783ee..f84eb8113a8 100644 --- a/src/web/src/tile_generator.h +++ b/src/web/src/tile_generator.h @@ -130,7 +130,7 @@ std::string dbuToMicronString(int dbu, double dbu_per_micron); // // The tile grid step is maxDXDY / 2^z — a FRACTIONAL number of DBU — so a // tile's lower-left corner is fractional too, and `origin_x/origin_y` keep it -// that way. The client lays the tiles out on that exact grid (the DBU↔latLng +// that way. The client lays the tiles out on that exact grid (the DBU↔world // transform in coordinates.js), so rounding the corner here would shift a // tile's content by its own fractional part, a different amount in each tile. // Neighbours then disagree about where the shared edge is and a hairline seam @@ -467,6 +467,9 @@ struct TileVisibility void parseFromJson(const boost::json::object& json); + // JSON keys of every visibility flag parseFromJson reads. + static std::vector flagKeys(); + bool isNetVisible(odb::dbNet* net) const; bool isInstVisible(odb::dbInst* inst, sta::dbSta* sta) const; // Pin names show only together with the pins they name. @@ -748,6 +751,21 @@ class TileGenerator // back to the historical 256*dpr. int tile_px = 0) const; + // `layers` rendered bottom to top into one tile, each with its own fill + // pattern, and encoded once. Empty when `aborted` returns true between + // layers. + std::vector generateGroupTile( + const std::vector& layers, + const std::vector& patterns, + int z, + int x, + int y, + const TileVisibility& vis, + const std::set* focus_net_ids, + double dpr, + int tile_px, + const std::function& aborted) const; + // Render only highlight/overlay shapes (selection, hover, timing, DRC, // route guides, flight lines) on a fully transparent background. Used // by the overlay tile layer so base tiles can stay cached when only @@ -865,7 +883,7 @@ class TileGenerator // The layers saveImage composites, bottom to top, from `tech_layers` in // paintOrderLayers() order. Public so a test can pin the order down: - // it has to match the zIndex the client gives each layer in + // it has to match the draw order the client gives each layer in // display-controls.js, or the saved PNG is not the view on screen. static std::vector saveImageLayerOrder( const TileVisibility& vis, @@ -928,18 +946,29 @@ class TileGenerator // PNG-encoded "clean" tiles (no per-session overlays) keyed by a string // fingerprint of the full render determinant. Re-rendering tiles at // 256*dpr*S is expensive, so pan/zoom-back and visibility toggles reuse - // the cached bytes. LRU eviction at kTileCacheCap; cleared on design + // the cached bytes. LRU eviction at kTileCacheCap entries or + // kTileCacheBytesCap bytes, whichever comes first; cleared on design // reload via eagerInit(). Thread-safe (mirrors chiplets_mutex_). bool tileCacheGet(const std::string& key, std::vector& out) const; void tileCachePut(std::string key, std::vector png) const; + // Entries vary widely in size, so the bytes are bounded as well. + static constexpr size_t kTileCacheCap = 2048; + static constexpr size_t kTileCacheBytesCap = size_t{64} << 20; + + // The visibility part of `layer`'s tile-cache key: the parsed fields that + // can change its pixels, and none of the others. + static std::string tileCacheKey(const TileVisibility& vis, + std::string_view layer); + // Install (or clear with `{}`) a callback invoked after a design edit has // invalidated the tile cache — WebServer wires this to broadcast a // {"type":"refresh"} push so clients re-request tiles (mirrors the Qt GUI's // Search::modified → LayoutViewer::fullRepaint). Set at serve() startup. void setDesignChangedCallback(std::function cb); - size_t tileCacheSize() const; // for tests + size_t tileCacheSize() const; // for tests + size_t tileCacheBytes() const; // for tests private: // Render a single tile into a raw RGBA buffer (pre-PNG-encoding). @@ -1047,10 +1076,10 @@ class TileGenerator const TileFrame& frame) const; // Raw (un-encoded) RGBA tile with only the user labels drawn on a - // transparent background, for the given Leaflet z/x/y. Used to composite - // labels into save_image. `labels` is passed in (snapshot once per image) - // so the mutex isn't locked and copied per tile. Returns empty if `labels` - // is empty. + // transparent background, for the given client z/x/y (y top-down). Used to + // composite labels into save_image. `labels` is passed in (snapshot once + // per image) so the mutex isn't locked and copied per tile. Returns empty + // if `labels` is empty. std::vector renderLabelTile( int z, int x, @@ -1190,7 +1219,7 @@ class TileGenerator mutable std::list tile_cache_lru_; mutable std::unordered_map::iterator> tile_cache_index_; - static constexpr size_t kTileCacheCap = 512; + mutable size_t tile_cache_bytes_ = 0; // sum of the cached PNG sizes // Design-change → invalidation wiring. search_ fires on_modified (see // Search::setOnModified) on any geometry edit; onDesignChanged() drops the diff --git a/src/web/src/ui-utils.js b/src/web/src/ui-utils.js index 8c4c2203b50..2afa34a4730 100644 --- a/src/web/src/ui-utils.js +++ b/src/web/src/ui-utils.js @@ -3,7 +3,7 @@ // Shared UI utilities. -import { dbuRectToBounds } from './coordinates.js'; +import { dbuRectToWorldRect } from './coordinates.js'; import { TILE_SIZE_CSS, TILE_SIZE_QUANTUM } from './tile-request.js'; // True when the app was bootstrapped from a saved/static report @@ -146,8 +146,9 @@ export function computeBoundsTransforms(designBounds, tileSize = 256, maxDXDY, originX: minX, originY: minY, - fitBounds: dbuRectToBounds(fitXMin, fitYMin, fitXMax, fitYMax, - scale, maxDXDY, minX, minY), + // World rect [minX, minY, maxX, maxY] (layout-view.js). + fitRect: dbuRectToWorldRect(fitXMin, fitYMin, fitXMax, fitYMax, + scale, minX, minY), }; } @@ -197,50 +198,17 @@ export function onSelectionReset(app, fn) { app.selectionResetters.push(fn); } -// Leaflet map options for the 2D layout viewer. -// -// zoomSnap:1 + zoomDelta:1 force the map to rest only at INTEGER zoom levels, -// so server tiles are displayed 1:1 at rest with no fractional CSS rescaling -// of the tile pane. Downscaling a band-limited dense raster (bump arrays) -// re-introduces the moiré beat the server worked to remove; resting on integer -// zoom (combined with the floor _clampZoom override in the tile layers, which -// guarantees the pane is only ever upscaled) prevents that. -// -// `crs` is parameterized so this is unit-testable without the Leaflet global. -// `prefs` carries the two Options-menu preferences the map itself owns -// (see kArrowStepDefault and installWheelPanning). -export function buildMapOptions( - crs = (typeof L !== 'undefined' ? L.CRS.Simple : undefined), - prefs = {}) { - return { - crs, - zoom: 1, - zoomSnap: 1, - zoomDelta: 1, - fadeAnimation: false, - attributionControl: false, - // Qt Options > "Mouse wheel mapped to zoom by default". The live - // viewer never reads this: installWheelPanning turns Leaflet's own - // wheel handler off and implements both directions itself, because - // Leaflet cannot pan on the wheel. Kept so the option carries the - // preference for a consumer that does not install that handler, and - // absent preference keeps the wheel zooming, which is what shipped. - scrollWheelZoom: prefs.wheelZoom !== false, - keyboardPanDelta: clampArrowStep(prefs.arrowStep), - }; -} - // Qt Options > "Arrow keys scroll step": how far one arrow press pans, in CSS // px. Qt's dialog accepts 10..1000 with a default of 20; the default here -// stays at Leaflet's 80 because that is what the web viewer has always done -// and dropping to 20 would quietly make every arrow press a quarter as far. +// stays at 80 because that is what the web viewer has always done and +// dropping to 20 would quietly make every arrow press a quarter as far. export const kArrowStepDefault = 80; export const kArrowStepMin = 10; export const kArrowStepMax = 1000; // Coerce a stored or user-typed step to a usable number. Anything -// unparseable falls back to the default rather than to NaN, which Leaflet -// would turn into a map that ignores the arrow keys entirely. +// unparseable falls back to the default rather than to NaN, which would make +// the arrow keys move the view nowhere. export function clampArrowStep(value) { // Number('') and Number(null) are both 0, which would clamp to the // minimum; an unset cookie has to read as absent, not as "10 px". @@ -252,19 +220,6 @@ export function clampArrowStep(value) { return Math.min(kArrowStepMax, Math.max(kArrowStepMin, step)); } -// Push a new arrow-key step into an already-open map. -// -// Leaflet reads options.keyboardPanDelta once, in Keyboard.initialize, so -// assigning that option on a live map does nothing -- the distance lives in -// the handler's own key map, which _setPanDelta rebuilds from this argument -// (Leaflet 1.9.4, Map.Keyboard.js). Hence the push rather than an option -// write. _setPanDelta is private, so every hop is optional-chained: a static -// report has no keyboard handler, and setArrowStep can run before the map -// exists. buildMapOptions carries the value for the next map either way. -export function applyArrowStep(map, step) { - map?.keyboard?._setPanDelta?.(step); -} - // Build a display-controls group header row: an expand/collapse triangle and // a stretching name cell. Callers fill in `name.textContent` and append their // checkbox columns after it, which pins those columns to the row's right edge @@ -319,9 +274,8 @@ export function attachGroupCollapse(header, arrow, children, collapsed) { // Deepest zoom worth offering, given `designScale` (pixels per DBU at zoom 0). // -// Leaflet's default maxZoom is Infinity unless a layer supplies one, and -// L.GridLayer -- unlike L.TileLayer -- supplies none. Left unbounded the zoom -// keeps climbing past any useful magnification until the arithmetic gives out: +// Left unbounded the zoom keeps climbing past any useful magnification until +// the arithmetic gives out: // the server's tile span (maxDXDY / 2^z) underflows to zero, so tiles come back // empty and the design appears to vanish, and the map's own 2^z factors reach // Infinity, which JSON.stringify writes as `null` in the tile request. @@ -329,7 +283,7 @@ export function attachGroupCollapse(header, arrow, children, collapsed) { // The cap is where one DBU already covers `maxPxPerDbu` screen pixels: a DBU is // the smallest distance the database can express, so magnifying it further // shows nothing that was not already visible. Returned as an integer because -// the map rests on integer zoom levels (see buildMapOptions). +// the view rests on integer zoom levels (layout-view.js). // Must match kMaxTileZoom in request_handler.h: the server refuses a deeper // tile, so asking for one would only trade blank tiles for error responses. export const MAX_TILE_ZOOM = 30; @@ -349,8 +303,8 @@ export function maxUsefulZoom(designScale, maxPxPerDbu = 8) { // The CSS tile size that makes zoom-to-fit land on an integer zoom level. // -// The map rests only on integer zoom (buildMapOptions), and Leaflet's -// fitBounds FLOORS the zoom it computes, so the design is displayed anywhere +// The view rests only on integer zoom, and fitting FLOORS the zoom it computes +// (view-math.js fitView), so the design is shown // between half and all of what would fit — 52% of the viewport in the case // reported as issue #11338, against 91% in the Qt GUI. // @@ -373,7 +327,7 @@ export function maxUsefulZoom(designScale, maxPxPerDbu = 8) { // today's one. That leaves two sizes to pick from, so the design fills at // least 2/3 of the framed box rather than the 1/2 the bare floor allows. // -// Only the zoom-to-fit rect gets this: every other fitBounds caller (zoom to +// Only the zoom-to-fit rect gets this: every other fit caller (zoom to // selection, the DRC widget, rubber-band zoom) still loses up to a level to // the same floor, and a size picked for this rect cannot help theirs. // @@ -382,19 +336,19 @@ export function maxUsefulZoom(designScale, maxPxPerDbu = 8) { // level the fit loses today. export function fittedTileSizeCss({ designBounds, fitRect, viewW, viewH }) { // The framed box, margin and fit-rect fallback included, in the map units - // TILE_SIZE_CSS defines -- so this cannot drift from what fitBounds sees. + // TILE_SIZE_CSS defines -- so this cannot drift from what the fit sees. const t = computeBoundsTransforms(designBounds, TILE_SIZE_CSS, fitRect); const finitePositive = (v) => Number.isFinite(v) && v > 0; if (!t || !finitePositive(viewW) || !finitePositive(viewH)) { return TILE_SIZE_CSS; } - const framedW = t.fitBounds[1][1] - t.fitBounds[0][1]; - const framedH = t.fitBounds[1][0] - t.fitBounds[0][0]; + const framedW = t.fitRect[2] - t.fitRect[0]; + const framedH = t.fitRect[3] - t.fitRect[1]; // Pixels the framed box may grow by before it leaves the viewport, which - // is 2^(the zoom fitBounds wants) at tile size TILE_SIZE_CSS. + // is 2^(the zoom the fit wants) at tile size TILE_SIZE_CSS. const room = Math.min(viewW / framedW, viewH / framedH); const zStar = Math.log2(room); - // Below zoom 0 the map is already pinned at its minZoom and the fit has + // Below zoom 0 the view is already pinned at its minZoom and the fit has // nothing left to floor, so a bigger tile would only overflow the viewport. if (!Number.isFinite(zStar) || zStar < 0) { return TILE_SIZE_CSS; @@ -488,19 +442,27 @@ export function cssColorToHex(s) { // Wrap fn in a single-flight requestAnimationFrame scheduler: calls made // while a frame is already pending coalesce into one invocation of fn. -export function rafCoalesce(fn) { - let pending = null; +// `schedule` stands in for requestAnimationFrame (a view's injected one). +export function rafCoalesce(fn, schedule = (cb) => requestAnimationFrame(cb)) { + let pending = false; return () => { - if (pending !== null) { + if (pending) { return; } - pending = requestAnimationFrame(() => { - pending = null; + pending = true; + schedule(() => { + pending = false; fn(); }); }; } +// The user asked the system for less motion. +export function prefersReducedMotion() { + return typeof matchMedia === 'function' + && matchMedia('(prefers-reduced-motion: reduce)').matches; +} + // Round a positive value to the nearest 1/2/5/10 × 10^n, returning both the // rounded value and the chosen leading digit (used to pick tick subdivisions). export function niceRoundParts(value) { @@ -718,46 +680,6 @@ export function decorateTabIcons(root = document) { return added; } -// Qt's LayoutScroll::wheelEvent, ported. The preference and the Ctrl modifier -// pick between panning and zooming, so Ctrl always does whichever one the -// preference did not: with the preference off (Qt's default) the wheel pans and -// Ctrl+wheel zooms, and with it on they swap. -// -// Both branches live here and Leaflet's own scrollWheelZoom is left disabled: -// Leaflet has no pan-on-wheel option, and leaving its handler on would zoom in -// addition to whatever this one did. Zooming goes through setZoomAround so the -// point under the cursor stays put, matching Qt's zoomIn(mouse_pos, true) and -// the viewer's own Z / Shift+Z keys. -export function installWheelPanning(map, wheelZoomEnabled) { - map.scrollWheelZoom.disable(); - map.getContainer().addEventListener('wheel', (e) => { - e.preventDefault(); - if (wheelZoomEnabled() === e.ctrlKey) { - const [dx, dy] = wheelDeltaPx(e, map.getContainer()); - map.panBy([dx, dy], { animate: false }); - return; - } - // A wheel notch is one zoom level, like the Z / Shift+Z keys. - const step = e.deltaY < 0 ? 1 : -1; - map.setZoomAround(map.mouseEventToLatLng(e), map.getZoom() + step); - }, { passive: false }); -} - -// A wheel event's scroll amount in CSS pixels. deltaMode is not always pixels: -// Firefox reports lines, and a page-mode event (rare, but produced by some -// remote-desktop stacks) means a viewport at a time. Treating either as pixels -// would make one notch pan by a couple of pixels. -function wheelDeltaPx(e, container) { - const kLineHeightPx = 16; - let scale = 1; - if (e.deltaMode === 1) { - scale = kLineHeightPx; - } else if (e.deltaMode === 2) { - scale = container.clientHeight || kLineHeightPx; - } - return [e.deltaX * scale, e.deltaY * scale]; -} - // A modal dialog shell: title, caller-supplied body, an error line and // Cancel/OK. Closes on the X, Cancel, Escape and a click on the backdrop. // `dialogClass` selects the per-dialog CSS (width, row layout). diff --git a/src/web/src/vendor.css b/src/web/src/vendor.css index 5d4f210a5d9..4ec1a35952d 100644 --- a/src/web/src/vendor.css +++ b/src/web/src/vendor.css @@ -3,5 +3,4 @@ /* Bundled so esbuild inlines the icons their url()s reach. */ -@import 'leaflet/dist/leaflet.css'; @import 'golden-layout/dist/css/goldenlayout-base.css'; diff --git a/src/web/src/view-input.js b/src/web/src/view-input.js new file mode 100644 index 00000000000..5f4147d730b --- /dev/null +++ b/src/web/src/view-input.js @@ -0,0 +1,312 @@ +// SPDX-License-Identifier: BSD-3-Clause +// Copyright (c) 2026, The OpenROAD Authors + +// Mouse, wheel and keyboard on the layout view, as DOM listeners over the view +// API. Drag-panning is left to the renderer; everything that zooms, selects +// or draws a box is here. + +const kClickTolerancePx = 3; // a press that moves less is a click +const kBandMinPx = 4; // a smaller right-drag is a click +const kNotchMinPx = 50; // a mouse wheel step in pixels is at least this +const kPxPerLevel = 100; // trackpad scroll that zooms one level +const kGestureIdleMs = 200; // a pause this long ends a trackpad gesture +const kGestureMinLevels = 0.2; // a smaller gesture springs back +const kMacWheelStep = 4.000244140625; // Chrome on macOS: one mouse wheel step + +// Steps from a mouse wheel: lines or pages, whole pixel steps of at least +// kNotchMinPx, or multiples of kMacWheelStep, with no sideways part. A +// trackpad scroll or pinch is a stream of small deltas instead. +export function isWheelNotch(e) { + if (e.deltaMode !== 0) { + return true; + } + if (e.deltaX !== 0 || e.deltaY === 0) { + return false; + } + return (Number.isInteger(e.deltaY) && Math.abs(e.deltaY) >= kNotchMinPx) + || e.deltaY % kMacWheelStep === 0; +} + +// The whole levels a trackpad gesture of `d` levels ends on: at least one +// past kGestureMinLevels, the nearest after that. +export function gestureSteps(d) { + const a = Math.abs(d); + return a < kGestureMinLevels ? 0 : Math.sign(d) * Math.max(1, Math.round(a)); +} + +// A wheel event's scroll amount in CSS pixels. deltaMode is not always pixels: +// Firefox reports lines, and a page-mode event (some remote-desktop stacks) +// means a viewport at a time. +export function wheelDeltaPx(e, container) { + const kLineHeightPx = 16; + let scale = 1; + if (e.deltaMode === 1) { + scale = kLineHeightPx; + } else if (e.deltaMode === 2) { + scale = container.clientHeight || kLineHeightPx; + } + return [e.deltaX * scale, e.deltaY * scale]; +} + +// Arrow key -> pan in screen px; Shift pans 3x. +export function arrowPanOffset(key, step, shift) { + const s = shift ? 3 * step : step; + switch (key) { + case 'ArrowLeft': return [-s, 0]; + case 'ArrowRight': return [s, 0]; + case 'ArrowUp': return [0, -s]; + case 'ArrowDown': return [0, s]; + default: return null; + } +} + +// `opts`: +// isStatic() a saved report: only drag and the arrow keys stay on +// wheelZoom() Options > "Mouse wheel mapped to zoom" +// arrowStep() Options > "Arrow keys scroll step", CSS px +// onClick(world, event), onContextClick(world, event) +// onMove(world, event), onLeave(event) +// contextEnabled() false while a ruler is being placed +export function installViewInput(view, opts = {}) { + const container = view.getContainer(); + const isStatic = opts.isStatic || (() => false); + const wheelZoom = opts.wheelZoom || (() => true); + const arrowStep = opts.arrowStep || (() => 80); + const gestureIdleMs = opts.gestureIdleMs ?? kGestureIdleMs; + const contextEnabled = opts.contextEnabled || (() => true); + const listeners = []; + const on = (target, type, fn, options) => { + target.addEventListener(type, fn, options); + listeners.push(() => target.removeEventListener(type, fn, options)); + }; + const local = (e) => { + const r = container.getBoundingClientRect(); + return [e.clientX - r.left, e.clientY - r.top]; + }; + const worldAt = (e) => view.unproject(local(e)); + // On the layout itself: not on a control, HUD or marker over it, which + // handle their own input. + const onView = (e) => e.target === container + || !!e.target?.closest?.('.or-view-canvas'); + + if (container.tabIndex < 0) { + container.tabIndex = 0; + } + + // A trackpad zoom follows the fingers at fractional levels, then rests on + // a whole level once they stop. + let gesture = null; // { z0, pt, timer } + function zoomGesture(pt, levels) { + if (!gesture) { + gesture = { z0: view.getZoom() }; + } + gesture.pt = pt; + clearTimeout(gesture.timer); + gesture.timer = setTimeout(endGesture, gestureIdleMs); + view.zoomAround(pt, levels, { animate: false, settle: false }); + } + function endGesture() { + if (!gesture) { + return; + } + const g = gesture; + gesture = null; + clearTimeout(g.timer); + const z = view.getZoom(); + view.zoomAround(g.pt, g.z0 + gestureSteps(z - g.z0) - z); + } + listeners.push(() => { + clearTimeout(gesture?.timer); + gesture = null; + }); + + // Wheel: the preference and Ctrl pick between panning and zooming around + // the cursor (Qt's LayoutScroll::wheelEvent), one level per mouse step. + // A pinch always zooms. + on(container, 'wheel', (e) => { + e.preventDefault(); + if (isStatic()) { + return; + } + const notch = isWheelNotch(e); + if (!notch && e.ctrlKey) { + // Chrome and Firefox send a pinch as ctrl+wheel with + // deltaY = -100 ln(scale). + zoomGesture(local(e), -e.deltaY / (100 * Math.LN2)); + return; + } + if (wheelZoom() === e.ctrlKey) { + const [dx, dy] = wheelDeltaPx(e, container); + view.panByPx(dx, dy, { animate: false }); + return; + } + if (!notch) { + zoomGesture(local(e), -e.deltaY / kPxPerLevel); + return; + } + endGesture(); + view.zoomAround(local(e), e.deltaY < 0 ? 1 : -1); + }, { passive: false }); + + on(container, 'keydown', (e) => { + if (e.altKey || e.ctrlKey || e.metaKey) { + return; + } + const offset = arrowPanOffset(e.key, arrowStep(), e.shiftKey); + if (offset) { + e.preventDefault(); + view.panByPx(offset[0], offset[1]); + return; + } + if (isStatic()) { + return; + } + const zoomKeys = { '+': 1, '=': 1, '-': -1, '_': -1 }; + if (e.key in zoomKeys) { + e.preventDefault(); + view.zoomAround(null, zoomKeys[e.key] * (e.shiftKey ? 3 : 1)); + } + }); + + // Left button: a press that moves no more than the tolerance is a click, + // however long it is held. Shift+drag draws a zoom box instead of panning. + let press = null; + let box = null; + on(container, 'pointerdown', (e) => { + if (e.button !== 0 || !onView(e)) { + return; + } + container.focus({ preventScroll: true }); + press = { x: e.clientX, y: e.clientY, moved: false, + box: e.shiftKey && !isStatic() }; + if (press.box) { + e.stopPropagation(); // keep the renderer from panning + } + }, { capture: true }); + + on(window, 'pointermove', (e) => { + if (!press) { + return; + } + const dx = e.clientX - press.x; + const dy = e.clientY - press.y; + if (Math.abs(dx) > kClickTolerancePx + || Math.abs(dy) > kClickTolerancePx) { + press.moved = true; + } + if (press.box && press.moved) { + box = drawBand(box, press, e); + } + }); + + on(window, 'pointerup', (e) => { + if (!press || e.button !== 0) { + return; + } + const p = press; + press = null; + if (box) { + box.remove(); + box = null; + } + if (p.box && p.moved) { + fitScreenBox(p, e); + return; + } + if (!p.moved && opts.onClick && isInside(e)) { + opts.onClick(worldAt(e), e); + } + }); + + on(container, 'dblclick', (e) => { + if (isStatic() || !onView(e)) { + return; + } + view.zoomAround(local(e), e.shiftKey ? -1 : 1); + }); + + // Right button: drag for a rubber-band zoom, click for the context menu. + let band = null; + let bandEl = null; + on(container, 'contextmenu', (e) => e.preventDefault()); + on(container, 'pointerdown', (e) => { + if (e.button !== 2 || isStatic() || !onView(e)) { + return; + } + e.stopPropagation(); + band = { x: e.clientX, y: e.clientY }; + }, { capture: true }); + on(window, 'pointermove', (e) => { + if (!band) { + return; + } + const dx = e.clientX - band.x; + const dy = e.clientY - band.y; + if (bandEl || (Math.abs(dx) >= kBandMinPx && Math.abs(dy) >= kBandMinPx)) { + bandEl = drawBand(bandEl, band, e); + } + }); + on(window, 'pointerup', (e) => { + if (!band || e.button !== 2) { + return; + } + const start = band; + band = null; + if (bandEl) { + bandEl.remove(); + bandEl = null; + fitScreenBox(start, e); + return; + } + if (isInside(e) && contextEnabled() && opts.onContextClick) { + opts.onContextClick(worldAt(e), e); + } + }); + + on(container, 'pointermove', (e) => { + if (opts.onMove) { + opts.onMove(worldAt(e), e); + } + }); + on(container, 'pointerleave', (e) => { + if (opts.onLeave) { + opts.onLeave(e); + } + }); + + function isInside(e) { + const r = container.getBoundingClientRect(); + return e.clientX >= r.left && e.clientX <= r.right + && e.clientY >= r.top && e.clientY <= r.bottom; + } + + function fitScreenBox(start, e) { + const r = container.getBoundingClientRect(); + const a = view.unproject([start.x - r.left, start.y - r.top]); + const b = view.unproject([e.clientX - r.left, e.clientY - r.top]); + view.fitWorldRect([Math.min(a[0], b[0]), Math.min(a[1], b[1]), + Math.max(a[0], b[0]), Math.max(a[1], b[1])]); + } + + return { + dispose() { + for (const off of listeners.splice(0)) { + off(); + } + }, + }; +} + +// The rubber-band rectangle, in page coordinates. +function drawBand(el, start, e) { + if (!el) { + el = document.createElement('div'); + el.className = 'rubber-band'; + document.body.appendChild(el); + } + el.style.left = Math.min(start.x, e.clientX) + 'px'; + el.style.top = Math.min(start.y, e.clientY) + 'px'; + el.style.width = Math.abs(e.clientX - start.x) + 'px'; + el.style.height = Math.abs(e.clientY - start.y) + 'px'; + return el; +} diff --git a/src/web/src/view-math.js b/src/web/src/view-math.js new file mode 100644 index 00000000000..6fdc47fc181 --- /dev/null +++ b/src/web/src/view-math.js @@ -0,0 +1,195 @@ +// SPDX-License-Identifier: BSD-3-Clause +// Copyright (c) 2026, The OpenROAD Authors + +// Pure geometry of the 2D layout view. +// +// World units are CSS px at zoom 0 with y up, so the tile grid is the square +// [0, T] x [0, T] for a tile size of T. A view state is +// `{ target: [x, y], zoom, width, height }`, width and height in CSS px, and +// screen coordinates are CSS px from the view's top-left corner. Tile rows are +// the server's: y counts down from the top of the grid. + +const EPS = 1e-9; + +function scaleOf(zoom) { + return Math.pow(2, zoom); +} + +export function project([wx, wy], vs) { + const s = scaleOf(vs.zoom); + return [(wx - vs.target[0]) * s + vs.width / 2, + vs.height / 2 - (wy - vs.target[1]) * s]; +} + +export function unproject([px, py], vs) { + const s = scaleOf(vs.zoom); + return [vs.target[0] + (px - vs.width / 2) / s, + vs.target[1] - (py - vs.height / 2) / s]; +} + +// The world rect [minX, minY, maxX, maxY] the view shows. +export function viewWorldRect(vs) { + const [x0, y1] = unproject([0, 0], vs); + const [x1, y0] = unproject([vs.width, vs.height], vs); + return [x0, y0, x1, y1]; +} + +export function clampZoom(zoom, { minZoom = -Infinity, maxZoom = Infinity } = {}) { + return Math.max(minZoom, Math.min(maxZoom, zoom)); +} + +// The view that fits world `rect` with `padding` px on every side: the zoom is +// floored to a whole level after rounding to 1/100 of a level, and the rect is +// centred. +export function fitView(rect, vs, { padding = [0, 0], minZoom, maxZoom } = {}) { + const w = Math.max(1, vs.width - 2 * padding[0]); + const h = Math.max(1, vs.height - 2 * padding[1]); + const rw = Math.max(rect[2] - rect[0], EPS); + const rh = Math.max(rect[3] - rect[1], EPS); + const raw = Math.log2(Math.min(w / rw, h / rh)); + const zoom = clampZoom(Math.floor(Math.round(raw * 100) / 100), + { minZoom, maxZoom }); + return { target: [(rect[0] + rect[2]) / 2, (rect[1] + rect[3]) / 2], zoom }; +} + +// The target that keeps the world point under `screenPt` still at `zoom`. +export function zoomAround(vs, screenPt, zoom) { + const [wx, wy] = unproject(screenPt, vs); + const s = scaleOf(zoom); + return [wx - (screenPt[0] - vs.width / 2) / s, + wy + (screenPt[1] - vs.height / 2) / s]; +} + +// Tile level for a view zoom: floored, so tiles are only ever shown upscaled +// (the moiré fix of #10463). While an animation heads for `targetZoom` and the +// new level stays hidden until it is complete, that level may load early. +export function tileZoomFor(zoom, { targetZoom = null, hidingNewLevels = false } = {}) { + const z = (hidingNewLevels && targetZoom !== null) ? targetZoom : zoom; + return Math.floor(z + EPS); +} + +// Inclusive tile range at level z covering world `rect`, clamped to the 2^z +// grid; null when the rect misses the grid. +export function tileRange(rect, z, tileSize) { + const n = Math.pow(2, z); + const s = tileSize / n; + const x0 = Math.max(0, Math.floor(rect[0] / s)); + const x1 = Math.min(n - 1, Math.ceil(rect[2] / s) - 1); + const y0 = Math.max(0, n - Math.ceil(rect[3] / s)); + const y1 = Math.min(n - 1, n - 1 - Math.floor(rect[1] / s)); + if (x0 > x1 || y0 > y1) { + return null; + } + return { z, x0, x1, y0, y1 }; +} + +// `rect` grown by `f` times its width and height on every side. +export function growRect([x0, y0, x1, y1], f) { + const dx = (x1 - x0) * f; + const dy = (y1 - y0) * f; + return [x0 - dx, y0 - dy, x1 + dx, y1 + dy]; +} + +export function growRange(range, by = 1) { + if (!range) { + return null; + } + const n = Math.pow(2, range.z); + return { + z: range.z, + x0: Math.max(0, range.x0 - by), + x1: Math.min(n - 1, range.x1 + by), + y0: Math.max(0, range.y0 - by), + y1: Math.min(n - 1, range.y1 + by), + }; +} + +export function inRange(range, x, y) { + return !!range && x >= range.x0 && x <= range.x1 + && y >= range.y0 && y <= range.y1; +} + +// Tiles of `range`, nearest the range centre first. +export function rangeTiles(range) { + if (!range) { + return []; + } + const cx = (range.x0 + range.x1) / 2; + const cy = (range.y0 + range.y1) / 2; + const out = []; + for (let y = range.y0; y <= range.y1; y++) { + for (let x = range.x0; x <= range.x1; x++) { + out.push({ z: range.z, x, y, d: (x - cx) ** 2 + (y - cy) ** 2 }); + } + } + out.sort((a, b) => a.d - b.d); + return out.map(({ z, x, y }) => ({ z, x, y })); +} + +// World bounds [left, bottom, right, top] of tile (z, x, y). +export function tileWorldBounds(z, x, y, tileSize) { + const s = tileSize / Math.pow(2, z); + return [x * s, tileSize - (y + 1) * s, (x + 1) * s, tileSize - y * s]; +} + +export function rectsOverlap(a, b) { + return a[0] < b[2] && b[0] < a[2] && a[1] < b[3] && b[1] < a[3]; +} + +// The target nudged so world (0, 0) lands on a whole device pixel. Tile sizes +// are whole device pixels, so every tile edge then does too and a tile at rest +// maps 1:1 onto the device grid. +export function snapTarget(vs, dpr) { + const s = scaleOf(vs.zoom) * dpr; + const [px, py] = project([0, 0], vs); + const rx = px * dpr - Math.round(px * dpr); + const ry = py * dpr - Math.round(py * dpr); + return [vs.target[0] + rx / s, vs.target[1] - ry / s]; +} + +// The van Wijk & Nuij zoom-and-pan path from view `a` to view `b` (the one +// d3.interpolateZoom draws): it pulls out, travels and closes in at a constant +// apparent speed. Returns `at(t)` -> { target, zoom } for t in [0, 1] and the +// path length `S` (larger is a longer flight). +export function flyPath(a, b) { + const rho = Math.SQRT2; + const rho2 = 2; + const rho4 = 4; + const size = Math.max(a.width, a.height); + const [ux0, uy0] = a.target; + const [ux1, uy1] = b.target; + const w0 = size / scaleOf(a.zoom); // world units across the view + const w1 = size / scaleOf(b.zoom); + const dx = ux1 - ux0; + const dy = uy1 - uy0; + const d2 = dx * dx + dy * dy; + const zoomOf = (w) => Math.log2(size / w); + if (d2 < 1e-12) { + const S = Math.log(w1 / w0) / rho; + return { + S: Math.abs(S), + at: (t) => ({ target: [ux0 + t * dx, uy0 + t * dy], + zoom: zoomOf(w0 * Math.exp(rho * t * S)) }), + }; + } + const d1 = Math.sqrt(d2); + const b0 = (w1 * w1 - w0 * w0 + rho4 * d2) / (2 * w0 * rho2 * d1); + const b1 = (w1 * w1 - w0 * w0 - rho4 * d2) / (2 * w1 * rho2 * d1); + const r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0); + const r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1); + const S = (r1 - r0) / rho; + const coshr0 = Math.cosh(r0); + return { + S, + at: (t) => { + if (t >= 1) { + return { target: [ux1, uy1], zoom: b.zoom }; + } + const s = t * S; + const u = w0 / (rho2 * d1) + * (coshr0 * Math.tanh(rho * s + r0) - Math.sinh(r0)); + return { target: [ux0 + u * dx, uy0 + u * dy], + zoom: zoomOf(w0 * coshr0 / Math.cosh(rho * s + r0)) }; + }, + }; +} diff --git a/src/web/src/web.cpp b/src/web/src/web.cpp index 1d02b2185c4..6f7f871e6e3 100644 --- a/src/web/src/web.cpp +++ b/src/web/src/web.cpp @@ -1891,7 +1891,7 @@ void WebServer::saveReport(const std::string& filename, // ── Render tiles at a fixed zoom level ── // Pick z so the design fits in a typical panel (~500px). - // In Leaflet CRS.Simple, the design spans 256 units = 256*2^z pixels. + // At zoom z the design spans 256*2^z pixels (256 px tiles). // z=1 → 512px, a good fit for most panel sizes. constexpr int kZ = 1; const int num_tiles = 1 << kZ; diff --git a/src/web/src/websocket-manager.js b/src/web/src/websocket-manager.js index ce27e36b308..4fe060d8adb 100644 --- a/src/web/src/websocket-manager.js +++ b/src/web/src/websocket-manager.js @@ -54,6 +54,10 @@ export class WebSocketManager { // Requests waiting for an in-flight slot (insertion-ordered = FIFO). // Not yet on the wire, so cancel() can drop them for free. this._queue = new Map(); // id -> {msg, resolve, reject} + // Background requests (tiles prefetched around the view): sent only + // while _queue is empty, and left out of pendingCount. + this._bgQueue = new Map(); + this._bgSent = new Set(); // Requests sent but not yet answered by the server (the real wire // window). Incremented on send, decremented when a reply for that sent // id arrives — even a stale one for a cancelled request. @@ -86,7 +90,8 @@ export class WebSocketManager { // Total requests the user is still waiting on: those on the wire plus those // held back by the scheduler and not yet dispatched. get pendingCount() { - return this.pending.size + (this._queue ? this._queue.size : 0); + return this.pending.size - this._bgSent.size + + (this._queue ? this._queue.size : 0); } // Create a cache-backed instance (no WebSocket connection). @@ -97,6 +102,8 @@ export class WebSocketManager { mgr.nextId = 1; mgr.pending = new Map(); mgr._queue = new Map(); // unused in cache mode, but keeps cancel() safe + mgr._bgQueue = new Map(); + mgr._bgSent = new Set(); mgr._inFlight = 0; mgr._inFlightIds = new Set(); mgr._unknownPayloadTypes = new Set(); @@ -167,12 +174,15 @@ export class WebSocketManager { handler.reject(new Error('WebSocket closed')); } this.pending.clear(); + this._bgSent.clear(); // Drop anything still queued — it never reached the wire. Reject so // callers settle; tile callers .catch() and re-request on reconnect. - for (const [id, entry] of this._queue) { - entry.reject(new Error('WebSocket closed')); + for (const queue of [this._queue, this._bgQueue]) { + for (const [id, entry] of queue) { + entry.reject(new Error('WebSocket closed')); + } + queue.clear(); } - this._queue.clear(); if (this._shutdown) { console.log('WebSocket closed (server stopped)'); this._stopLivenessMonitor(); // no socket will reopen @@ -257,6 +267,7 @@ export class WebSocketManager { return; // stale response (e.g. tile scrolled away / cancelled) } this.pending.delete(id); + this._bgSent.delete(id); this._pump(); // let the next queued request go out this.onStatusChange(); @@ -280,7 +291,7 @@ export class WebSocketManager { handler.resolve(null); } else { // An unrecognised payload type must still settle the promise, or - // the tile it belongs to hangs unresolved forever and Leaflet + // the tile it belongs to hangs unresolved forever and the view // never reveals it. A server newer than this client lands here. // // Rejected rather than resolved with null: only type 3 carries @@ -304,7 +315,7 @@ export class WebSocketManager { } } - request(msg) { + request(msg, { background = false } = {}) { if (this._cache) { return this._cacheRequest(msg); } @@ -324,7 +335,8 @@ export class WebSocketManager { promise.requestId = id; // Enqueue rather than send directly; _pump() releases it onto the wire // once an in-flight slot is available. While queued it is cancellable. - this._queue.set(id, { msg, resolve: resolveFn, reject: rejectFn }); + (background ? this._bgQueue : this._queue) + .set(id, { msg, resolve: resolveFn, reject: rejectFn }); this._pump(); return promise; } @@ -337,14 +349,19 @@ export class WebSocketManager { return; } while (this._inFlight < this._maxInFlight - && this._queue.size > 0 + && (this._queue.size > 0 || this._bgQueue.size > 0) && this.socket.bufferedAmount < MAX_BUFFERED_BYTES) { - const [id, entry] = this._queue.entries().next().value; - this._queue.delete(id); + const background = this._queue.size === 0; + const queue = background ? this._bgQueue : this._queue; + const [id, entry] = queue.entries().next().value; + queue.delete(id); this.pending.set(id, { resolve: entry.resolve, reject: entry.reject, }); + if (background) { + this._bgSent.add(id); + } this.socket.send(JSON.stringify(entry.msg)); this._inFlightIds.add(id); this._inFlight++; @@ -352,19 +369,33 @@ export class WebSocketManager { this.onStatusChange(); } + // A background request that is now needed on screen moves to the back of + // the foreground queue, or, if already sent, counts as pending again. + promote(id) { + const entry = this._bgQueue.get(id); + if (entry) { + this._bgQueue.delete(id); + this._queue.set(id, entry); + this._pump(); + } else if (this._bgSent.delete(id)) { + this.onStatusChange(); + } + } + cancel(id) { // If still queued it never hit the wire — drop it for free (no server // work, no buffered bytes). This is the cancellation that actually // matters; cancelling an already-sent request can't recall the bytes. // Settle the promise so callers don't leak a forever-pending request. - const queued = this._queue.get(id); + const queued = this._queue.get(id) || this._bgQueue.get(id); if (queued) { this._queue.delete(id); + this._bgQueue.delete(id); queued.reject(new Error('Request cancelled')); this.onStatusChange(); return; } - + // Already sent: stop tracking the reply, but do NOT free the wire slot // or pump — the server still has to process those bytes, and the slot // frees only when its (now stale) reply arrives. Freeing it here would @@ -372,13 +403,14 @@ export class WebSocketManager { // // The promise is rejected as well, for the same reason as the queued // branch: dropping the handler without settling leaves the caller - // awaiting forever, and a caller with a `finally` never runs it. The - // merged tile layer frees its decoded ImageBitmaps there, so a silent + // awaiting forever, and a caller with a `finally` never runs it. + // renderMergedTile frees its decoded ImageBitmaps there, so a silent // drop here means every pruned or refreshed tile keeps its decodes // alive — the unbounded decoded-image growth the merge exists to bound. // The stale reply is still ignored: the handler is gone from `pending`. const sent = this.pending.get(id); const had = this.pending.delete(id); + this._bgSent.delete(id); if (sent) { sent.reject(new Error('Request cancelled')); } @@ -453,7 +485,7 @@ export class WebSocketManager { // Signature 2: saturated with work queued, yet silent for DEAD_MS. if (!wedged && this._inFlight >= this._maxInFlight - && this._queue.size > 0 + && this._queue.size + this._bgQueue.size > 0 && this._lastRecvAt > 0 && now - this._lastRecvAt > DEAD_MS) { wedged = true; diff --git a/src/web/src/websocket-tile-layer.js b/src/web/src/websocket-tile-layer.js deleted file mode 100644 index e80245f80c8..00000000000 --- a/src/web/src/websocket-tile-layer.js +++ /dev/null @@ -1,299 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// Copyright (c) 2026, The OpenROAD Authors - -// Leaflet tile layer that fetches tiles via WebSocket. - -import { - BLANK_TILE, buildTileRequestFor, floorClampZoom, nativeDpr, tileSizeCss, - tileSizeFields, withDeviceExactTileSize, -} from './tile-request.js'; -import { tileMayHaveContent } from './layer-extents.js'; - -// Imported AND re-exported: `export { x } from '...'` alone re-exports without -// creating a local binding, so _clampZoom below would reference an undefined -// name at runtime while importers still resolved it fine. -export { floorClampZoom }; - -// The display's real device pixel ratio. Sizes are computed from this; -// the wire payload rounds it for its cache-key field (see tile-request.js). -export function currentDpr() { - return nativeDpr(); -} - -// Kept as a named export because main.js and the tests import it from here. -// Delegates so the per-layer and merged paths cannot drift on the wire format. -export function buildTileRequest(coords, layerName, ctx) { - return buildTileRequestFor(coords, layerName, ctx, currentDpr(), - tileSizeCss()); -} - -// `app` (last arg) is read lazily on every request so that -// app.visibleChiplets, populated by display-controls.js after the tech -// metadata arrives, is reflected in tile requests without rebuilding -// the layer. When null or absent the field is omitted and the server -// renders every chiplet (default). -// Point an tile at a payload, or at the blank tile when the payload is -// null. -// -// Null is an empty tile (payload type 3): the server drew nothing there. The -// element keeps its place in the grid holding a 1x1 transparent GIF instead of -// a tile-sized transparent PNG, so the browser decodes 4 bytes and no bitmap -// worth the name counts against the budget tile-merge.js is bounding. See -// BLANK_TILE for why it is not simply left with no src. Reassigning matters on -// a refresh too -- a tile that had content before an edit removed it must drop -// the decode it is still holding. -function applyTilePayload(tile, data) { - if (tile.src && tile.src.startsWith('blob:')) { - URL.revokeObjectURL(tile.src); - } - if (data == null) { - tile.src = BLANK_TILE; - return; - } - tile.src = (typeof data === 'string') ? data : URL.createObjectURL(data); -} - -export function createWebSocketTileLayer(visibility, visibleLayers, - selectability, selectableLayers, - app) { - const ctx = { - visibility, selectability, visibleLayers, selectableLayers, app, - }; - return L.GridLayer.extend({ - // Force upscale-only display (see floorClampZoom) so the browser - // never downscales a band-limited tile back into a moiré beat. - _clampZoom: function(zoom) { - return L.GridLayer.prototype._clampZoom.call( - this, floorClampZoom(this, zoom)); - }, - - initialize: function(websocketManager, layerName, options) { - this._websocketManager = websocketManager; - this._layerName = layerName; - L.GridLayer.prototype.initialize.call( - this, withDeviceExactTileSize(options)); - }, - - createTile: function(coords, done) { - const tile = document.createElement('img'); - tile.alt = ''; - tile.setAttribute('role', 'presentation'); - - // Set up onload/onerror BEFORE any src assignment so that - // refreshTiles() can set tile.src and still trigger done(). - tile._tileDone = false; - tile.onload = () => { - if (tile.src && tile.src.startsWith('blob:')) { - URL.revokeObjectURL(tile.src); - } - if (!tile._tileDone) { - tile._tileDone = true; - done(null, tile); - } - }; - tile.onerror = () => { - if (!tile._tileDone) { - tile._tileDone = true; - done(new Error('tile image load error'), tile); - } - }; - - // Store the request ID so _removeTile() can cancel it - // when the tile is discarded (e.g. during zoom). - tile._websocketRequestId = this._websocketManager.nextId; - - if (!tileMayHaveContent(ctx, this._layerName, coords)) { - tile._websocketRequestId = undefined; - applyTilePayload(tile, null); - return tile; - } - - this._websocketManager.request( - buildTileRequest(coords, this._layerName, ctx) - ).then(data => { - applyTilePayload(tile, data); - }).catch(err => { - // Request was cancelled (e.g. by refreshTiles); ignore. Note - // that `done` is never called and no retry is issued, so this - // tile stays blank until Leaflet evicts it. - }); - - return tile; - }, - - // Re-request all existing tiles in place (no removal/flash). - // Use this instead of redraw() for visibility changes. - refreshTiles: function() { - if (!this._map) return; - - - for (const key in this._tiles) { - const tileInfo = this._tiles[key]; - if (!tileInfo || !tileInfo.el) continue; - - const tile = tileInfo.el; - const coords = tileInfo.coords; - - // Cancel any pending request for this tile - if (tile._websocketRequestId !== undefined) { - this._websocketManager.cancel(tile._websocketRequestId); - } - - if (!tileMayHaveContent(ctx, this._layerName, coords)) { - tile._websocketRequestId = undefined; - applyTilePayload(tile, null); - continue; - } - - tile._websocketRequestId = this._websocketManager.nextId; - - this._websocketManager.request( - buildTileRequest(coords, this._layerName, ctx) - ).then(data => { - applyTilePayload(tile, data); - }).catch(err => { - // Tile refresh failed; keep existing image - }); - } - }, - - _removeTile: function(key) { - const tile = this._tiles[key]; - if (tile && tile.el) { - if (tile.el._websocketRequestId !== undefined) { - this._websocketManager.cancel(tile.el._websocketRequestId); - } - if (tile.el.src && tile.el.src.startsWith('blob:')) { - URL.revokeObjectURL(tile.el.src); - } - } - L.GridLayer.prototype._removeTile.call(this, key); - } - }); -} - -// Lightweight tile layer that renders only highlight/overlay shapes -// (selection, hover, timing, DRC, route guides) on a transparent -// background. Separated from the base tile layers so that highlight -// changes don't trigger a full re-render of all geometry tiles. -export function createOverlayTileLayer(visibility, app) { - function buildOverlayRequest(coords, tileSize) { - const req = { - type: 'overlay_tile', - z: coords.z, - x: coords.x, - y: coords.y, - // Sized like the layer tiles it is drawn over: a highlight - // rendered at a different pixel count is rescaled by the browser - // and no longer sits exactly on the shape it highlights. - ...tileSizeFields(currentDpr(), tileSize), - debug_renderers: !!visibility.debug_renderers, - // The overlay tile carries the layer-independent - // Renderer::drawObjects pass, so it needs the same pause/live gate - // the layer tiles get through TileVisibility. - debug_live: !!visibility.debug_live, - flywires_only: !!visibility.flywires_only, - // Options > "Show polygon decomposition" (2.15). Not a display - // control: the server owns the value and hands it to every client, - // and echoing it back is how a session learns its highlight shapes - // were derived under the previous setting. - poly_decomp: !!(app && app.polyDecomp), - focused_nets_guides: !!visibility.focused_nets_guides, - highlight_selected: visibility.highlight_selected !== false, - // User labels (2.12) are server-drawn; honor the "Labels" toggle. - draw_labels: visibility.labels !== false, - }; - // Pass visible layers so route guides respect layer visibility. - if (app && app.visibleLayerNames) { - req.visible_layers = [...app.visibleLayerNames]; - } - return req; - } - return L.GridLayer.extend({ - initialize: function(websocketManager, options) { - this._websocketManager = websocketManager; - L.GridLayer.prototype.initialize.call( - this, withDeviceExactTileSize(options)); - }, - - createTile: function(coords, done) { - const tile = document.createElement('img'); - tile.alt = ''; - tile.setAttribute('role', 'presentation'); - - tile._tileDone = false; - tile.onload = () => { - if (tile.src && tile.src.startsWith('blob:')) { - URL.revokeObjectURL(tile.src); - } - if (!tile._tileDone) { - tile._tileDone = true; - done(null, tile); - } - }; - tile.onerror = () => { - if (!tile._tileDone) { - tile._tileDone = true; - done(new Error('overlay tile load error'), tile); - } - }; - - const requestId = this._websocketManager.nextId; - tile._websocketRequestId = requestId; - - this._websocketManager.request( - buildOverlayRequest(coords, this.getTileSize().x) - ).then(data => { - if (tile._websocketRequestId !== requestId) { - return; // stale response; a newer request superseded this one - } - applyTilePayload(tile, data); - }).catch(err => { - }); - - return tile; - }, - - refreshTiles: function() { - if (!this._map) return; - - for (const key in this._tiles) { - const tileInfo = this._tiles[key]; - if (!tileInfo || !tileInfo.el) continue; - - const tile = tileInfo.el; - const coords = tileInfo.coords; - - if (tile._websocketRequestId !== undefined) { - this._websocketManager.cancel(tile._websocketRequestId); - } - - const requestId = this._websocketManager.nextId; - tile._websocketRequestId = requestId; - - this._websocketManager.request( - buildOverlayRequest(coords, this.getTileSize().x) - ).then(data => { - if (tile._websocketRequestId !== requestId) { - return; // stale response superseded by a newer refresh - } - applyTilePayload(tile, data); - }).catch(() => {}); - } - }, - - _removeTile: function(key) { - const tile = this._tiles[key]; - if (tile && tile.el) { - if (tile.el._websocketRequestId !== undefined) { - this._websocketManager.cancel(tile.el._websocketRequestId); - tile.el._websocketRequestId = undefined; - } - if (tile.el.src && tile.el.src.startsWith('blob:')) { - URL.revokeObjectURL(tile.el.src); - } - } - L.GridLayer.prototype._removeTile.call(this, key); - } - }); -} diff --git a/src/web/src/zoom-swap.js b/src/web/src/zoom-swap.js new file mode 100644 index 00000000000..a5e2d74351a --- /dev/null +++ b/src/web/src/zoom-swap.js @@ -0,0 +1,166 @@ +// SPDX-License-Identifier: BSD-3-Clause +// Copyright (c) 2026, The OpenROAD Authors + +// Which tile levels the layout view draws while the zoom changes (#11340). +// +// Shared by every tile slot so they all change level together. With double +// buffering the new level stays hidden, under the old one scaled, until every +// slot has loaded what is on screen; it is then shown in one frame, fading in +// over the old level when smoothing is on. Without it the new level paints +// tile by tile over the old one, which stays underneath until the new level +// has settled. + +import { prefersReducedMotion } from './ui-utils.js'; + +const ATOMIC_ZOOM_TIMEOUT_MS = 10000; +export const ZOOM_FADE_MS = 150; +const kMaxUnder = 3; // levels kept under a loading one + +function easeOut(t) { + return 1 - (1 - t) * (1 - t); +} + +export class ZoomSwap { + constructor({ + isEnabled = () => true, + isSmooth = () => false, + reducedMotion = prefersReducedMotion, + now = () => performance.now(), + setTimer = (fn, ms) => setTimeout(fn, ms), + clearTimer = (id) => clearTimeout(id), + timeoutMs = ATOMIC_ZOOM_TIMEOUT_MS, + fadeMs = ZOOM_FADE_MS, + onChange = () => {}, + } = {}) { + Object.assign(this, { isEnabled, isSmooth, reducedMotion, now, setTimer, + clearTimer, timeoutMs, fadeMs, onChange }); + this.shownZ = null; // level drawn as complete + this.pendingZ = null; // level loading behind it (double buffering) + this.under = []; // old levels kept under a progressive one + this.fade = null; // { fromZ, toZ, start, ms } + this._timer = null; + } + + // The level the slots should be loading. + wantedZ() { + return this.pendingZ !== null ? this.pendingZ : this.shownZ; + } + + // The view moved to tile level z. `hasContent` says whether the level on + // screen still has tiles to keep showing. + setZoom(z, { hasContent = true } = {}) { + if (z === this.wantedZ()) { + return; + } + this.endFade(); + this._clearTimer(); + if (this.shownZ === null) { + this.shownZ = z; + this.pendingZ = null; + this.under = []; + } else if (!hasContent) { + // Nothing of the shown level to keep; what lies under it stays. + this.shownZ = z; + this.pendingZ = null; + this.under = this.under.filter((u) => u !== z); + } else if (z === this.shownZ) { + this.pendingZ = null; // zoomed back before the swap + } else if (this.isEnabled()) { + this.pendingZ = z; + this.under = []; + this._timer = this.setTimer(() => this.reveal(), this.timeoutMs); + } else { + // A level still loading covers only part of the view, so the + // ones under it stay too, as many as kMaxUnder. + this.under = [...this.under.filter((u) => u !== z), this.shownZ] + .slice(-kMaxUnder); + this.shownZ = z; + this.pendingZ = null; + } + this.onChange(); + } + + // Called whenever loading progresses. Returns true when it changed what + // is drawn. `animating` holds the reveal until the zoom animation ends. + check({ settled, animating = false }) { + if (this.pendingZ !== null) { + if (animating || (!settled && this.isEnabled())) { + return false; + } + this.reveal(); + return true; + } + if (this.under.length > 0 && settled && !animating) { + this.under = []; + this.onChange(); + return true; + } + return false; + } + + reveal() { + if (this.pendingZ === null) { + return; + } + this._clearTimer(); + const from = this.shownZ; + this.shownZ = this.pendingZ; + this.pendingZ = null; + const ms = this.isSmooth() && !this.reducedMotion() ? this.fadeMs : 0; + this.fade = (ms > 0 && from !== null) + ? { fromZ: from, toZ: this.shownZ, start: this.now(), ms } + : null; + this.onChange(); + } + + endFade() { + if (this.fade) { + this.fade = null; + this.onChange(); + } + } + + // What to draw now, bottom first. + plan(now = this.now()) { + if (this.fade) { + const t = (now - this.fade.start) / this.fade.ms; + if (t < 1) { + return { + draw: [{ z: this.fade.fromZ, opacity: 1 }, + { z: this.fade.toZ, opacity: easeOut(Math.max(0, t)) }], + fading: true, + }; + } + this.fade = null; + } + if (this.shownZ === null) { + return { draw: [], fading: false }; + } + if (this.pendingZ !== null) { + return { draw: [{ z: this.shownZ, opacity: 1 }], fading: false }; + } + if (this.under.length > 0) { + return { draw: [...this.under, this.shownZ].map( + (z) => ({ z, opacity: 1 })), + fading: false }; + } + return { draw: [{ z: this.shownZ, opacity: 1 }], fading: false }; + } + + // Nothing is waiting to be shown or fading in. + isIdle(now = this.now()) { + return this.pendingZ === null && this.under.length === 0 + && !this.plan(now).fading; + } + + dispose() { + this._clearTimer(); + } + + _clearTimer() { + if (this._timer !== null) { + this.clearTimer(this._timer); + this._timer = null; + } + } +} diff --git a/src/web/test/BUILD b/src/web/test/BUILD index 94951de955d..b6bcd771ad9 100644 --- a/src/web/test/BUILD +++ b/src/web/test/BUILD @@ -67,6 +67,9 @@ py_test( ], ) +# Tests that drive a module against a stand-in for layout-view.js. +VIEW_TEST_DATA = DOM_TEST_DATA + ["js/fake-view.js"] + test_suite( name = "cpp_tests", tests = [ @@ -144,7 +147,7 @@ js_test( js_test( name = "context_menu_test", - data = DOM_TEST_DATA, + data = VIEW_TEST_DATA, entry_point = "js/test-context-menu.js", no_copy_to_bin = JS_FILES, ) @@ -158,7 +161,7 @@ js_test( js_test( name = "capture_test", - data = DOM_TEST_DATA, + data = VIEW_TEST_DATA, entry_point = "js/test-capture.js", no_copy_to_bin = JS_FILES, ) @@ -177,13 +180,6 @@ js_test( no_copy_to_bin = JS_FILES, ) -js_test( - name = "websocket_tile_layer_test", - data = JS_FILES, - entry_point = "js/test-websocket-tile-layer.js", - no_copy_to_bin = JS_FILES, -) - js_test( name = "checkbox_tree_model_test", data = JS_FILES, @@ -193,7 +189,7 @@ js_test( js_test( name = "display_controls_test", - data = DOM_TEST_DATA, + data = VIEW_TEST_DATA, entry_point = "js/test-display-controls.js", no_copy_to_bin = JS_FILES, ) @@ -228,21 +224,21 @@ js_test( js_test( name = "inspector_test", - data = DOM_TEST_DATA, + data = VIEW_TEST_DATA, entry_point = "js/test-inspector.js", no_copy_to_bin = JS_FILES, ) js_test( name = "ruler_test", - data = JS_FILES, + data = VIEW_TEST_DATA, entry_point = "js/test-ruler.js", no_copy_to_bin = JS_FILES, ) js_test( name = "label_manager_test", - data = JS_FILES, + data = VIEW_TEST_DATA, entry_point = "js/test-label-manager.js", no_copy_to_bin = JS_FILES, ) @@ -256,21 +252,21 @@ js_test( js_test( name = "drc_widget_test", - data = DOM_TEST_DATA, + data = VIEW_TEST_DATA, entry_point = "js/test-drc-widget.js", no_copy_to_bin = JS_FILES, ) js_test( name = "selection_browser_test", - data = DOM_TEST_DATA, + data = VIEW_TEST_DATA, entry_point = "js/test-selection-browser.js", no_copy_to_bin = JS_FILES, ) js_test( name = "menu_bar_test", - data = DOM_TEST_DATA, + data = VIEW_TEST_DATA, entry_point = "js/test-menu-bar.js", no_copy_to_bin = JS_FILES, ) @@ -311,9 +307,51 @@ js_test( ) js_test( - name = "merged_tile_layer_test", + name = "view_math_test", + data = JS_FILES, + entry_point = "js/test-view-math.js", + no_copy_to_bin = JS_FILES, +) + +js_test( + name = "zoom_swap_test", + data = JS_FILES, + entry_point = "js/test-zoom-swap.js", + no_copy_to_bin = JS_FILES, +) + +js_test( + name = "tile_grid_test", + data = JS_FILES, + entry_point = "js/test-tile-grid.js", + no_copy_to_bin = JS_FILES, +) + +js_test( + name = "tile_sources_test", + data = JS_FILES, + entry_point = "js/test-tile-sources.js", + no_copy_to_bin = JS_FILES, +) + +js_test( + name = "view_input_test", data = DOM_TEST_DATA, - entry_point = "js/test-merged-tile-layer.js", + entry_point = "js/test-view-input.js", + no_copy_to_bin = JS_FILES, +) + +js_test( + name = "layout_view_test", + data = DOM_TEST_DATA + ["js/fake-deck.js"], + entry_point = "js/test-layout-view.js", + no_copy_to_bin = JS_FILES, +) + +js_test( + name = "imports_without_globals_test", + data = DOM_TEST_DATA, + entry_point = "js/test-imports-without-globals.js", no_copy_to_bin = JS_FILES, ) @@ -338,13 +376,6 @@ js_test( no_copy_to_bin = JS_FILES, ) -js_test( - name = "device_pixels_test", - data = JS_FILES, - entry_point = "js/test-device-pixels.js", - no_copy_to_bin = JS_FILES, -) - js_test( name = "theme_test", data = DOM_TEST_DATA, @@ -453,6 +484,7 @@ cc_test( "//src/utl", "//src/web", "//src/web:core", + "//third-party/lodepng", "@boost.asio", "@boost.beast", "@boost.json", diff --git a/src/web/test/bundle_test.py b/src/web/test/bundle_test.py index e983fb0eb72..6642ed39c04 100644 --- a/src/web/test/bundle_test.py +++ b/src/web/test/bundle_test.py @@ -40,6 +40,13 @@ "https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733", # The namespace netlistsvg stamps into the SVG it produces. "https://github.com/nturley/netlistsvg", + # Links in the comments of luma.gl's shader sources. + "https://en.wikipedia.org/wiki/find_first_set", + "https://en.wikipedia.org/wiki/single-precision_floating-point_format", + "https://en.wikipedia.org/wiki/double-precision_floating-point_format", + # The bare schemes loaders.gl tests a path against. + "http://", + "https://", } _URL = r"[^\"'`) >,;\n]*" @@ -133,10 +140,11 @@ def test_ships_the_bundled_licences(self): text = _read(_LICENSES) # netlistsvg's dependencies too: the bundle carries their code. for package in ( + "@deck.gl/core", + "@luma.gl/webgl", "clone", "elkjs", "golden-layout", - "leaflet", "lodash", "netlistsvg", "onml", diff --git a/src/web/test/cpp/TestRequestHandler.cpp b/src/web/test/cpp/TestRequestHandler.cpp index 5d49acf59d5..1428e18d2d0 100644 --- a/src/web/test/cpp/TestRequestHandler.cpp +++ b/src/web/test/cpp/TestRequestHandler.cpp @@ -4,7 +4,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -28,6 +30,7 @@ #include "gtest/gtest.h" #include "odb/db.h" #include "request_handler.h" +#include "third-party/lodepng/lodepng.h" #include "tile_generator.h" #include "tst/nangate45_fixture.h" #include "utl/Logger.h" @@ -743,7 +746,7 @@ TEST_F(TileHandlerTest, DrawnTileIsStillAPngResponse) EXPECT_FALSE(resp.payload.empty()); } -// The highlight overlay is one of the panes that never merges, and it holds +// The highlight overlay is a slot of its own that never merges, and it holds // nothing at all until something is selected -- so it is the single tile layer // most worth not sending an image for. TEST_F(TileHandlerTest, OverlayTileWithNothingSelectedIsEmpty) @@ -1027,6 +1030,206 @@ TEST_F(TileHandlerTest, PixelCountIsPartOfTheTileCacheKey) EXPECT_EQ(render("400"), 400u); } +// Requests `layer` and returns the cache size afterwards, so a hit shows as no +// growth. +size_t requestAndCount(TileHandler& handler, + SessionState& state, + const TileGenerator& gen, + const std::string& fields) +{ + WebSocketRequest req; + req.id = 1; + req.type = WebSocketRequest::kTile; + req.json = parseObj(R"({"z":0,"x":0,"y":0,)" + fields + "}"); + handler.handleTile(req, state); + return gen.tileCacheSize(); +} + +TEST_F(TileHandlerTest, ClientOnlyKeysHitTheCache) +{ + // The client sends its display options (scale bar, rulers...) with every + // tile; they draw nothing on the server and must not split the cache. + const size_t first = requestAndCount( + *handler_, state_, *gen_, R"("layer":"metal1","scale_bar":true)"); + EXPECT_EQ(requestAndCount(*handler_, + state_, + *gen_, + R"("layer":"metal1","scale_bar":false,)" + R"("rulers":true)"), + first); +} + +TEST_F(TileHandlerTest, VisibleLayersOnlyKeyThePinsLayer) +{ + const size_t metal1 = requestAndCount( + *handler_, state_, *gen_, R"("layer":"metal1","visible_layers":["m1"])"); + EXPECT_EQ(requestAndCount(*handler_, + state_, + *gen_, + R"("layer":"metal1","visible_layers":["m2"])"), + metal1); + const size_t pins = requestAndCount( + *handler_, state_, *gen_, R"("layer":"_pins","visible_layers":["m1"])"); + EXPECT_EQ(requestAndCount(*handler_, + state_, + *gen_, + R"("layer":"_pins","visible_layers":["m2"])"), + pins + 1); +} + +// ─── tile_group ───────────────────────────────────────────────────────────── + +// Overlapping pin shapes on metal1 and metal2, so a group's stacking order and +// blending both show in its pixels. +class TileGroupTest : public TileHandlerTest +{ + protected: + void SetUp() override + { + TileHandlerTest::SetUp(); + addPinBox("p1", "metal1", odb::Rect(20000, 20000, 60000, 60000)); + addPinBox("p2", "metal2", odb::Rect(40000, 40000, 80000, 80000)); + gen_->eagerInit(); + } + + void addPinBox(const char* name, const char* layer_name, const odb::Rect& box) + { + odb::dbNet* net = odb::dbNet::create(block_, name); + odb::dbBTerm* bterm = odb::dbBTerm::create(net, name); + odb::dbBPin* bpin = odb::dbBPin::create(bterm); + odb::dbTechLayer* layer = getDb()->getTech()->findLayer(layer_name); + ASSERT_NE(layer, nullptr); + odb::dbBox::create( + bpin, layer, box.xMin(), box.yMin(), box.xMax(), box.yMax()); + bpin->setPlacementStatus(odb::dbPlacementStatus::PLACED); + } + + WebSocketResponse group(const std::string& fields, const uint32_t id = 1) + { + WebSocketRequest req; + req.id = id; + req.type = WebSocketRequest::kTileGroup; + req.json = parseObj(R"({"z":0,"x":0,"y":0,"tile_px":256,)" + fields + "}"); + return handler_->handleTileGroup(req, state_); + } + + WebSocketResponse single(const std::string& layer) + { + WebSocketRequest req; + req.id = 1; + req.type = WebSocketRequest::kTile; + req.json = parseObj(R"({"z":0,"x":0,"y":0,"tile_px":256,"layer":")" + layer + + R"("})"); + return handler_->handleTile(req, state_); + } + + static std::vector pixels(const WebSocketResponse& resp) + { + std::vector rgba; + unsigned w = 0; + unsigned h = 0; + EXPECT_EQ(lodepng::decode(rgba, w, h, resp.payload), 0u); + return rgba; + } + + // Straight-alpha src-over, the model both the browser's canvas merge and the + // server compositor follow. + static void over(std::vector& dst, + const std::vector& src) + { + for (size_t i = 0; i + 3 < dst.size(); i += 4) { + const double sa = src[i + 3] / 255.0; + const double da = dst[i + 3] / 255.0; + const double oa = sa + (da * (1 - sa)); + for (size_t c = 0; c < 3; ++c) { + const double v + = oa > 0 ? ((src[i + c] * sa) + (dst[i + c] * da * (1 - sa))) / oa + : 0; + dst[i + c] = static_cast(std::lround(v)); + } + dst[i + 3] = static_cast(std::lround(oa * 255)); + } + } +}; + +TEST_F(TileGroupTest, OneLayerGroupIsThatLayersTile) +{ + const auto resp = group(R"("layers":["metal1"])"); + ASSERT_EQ(resp.type, WebSocketResponse::kPng); + EXPECT_EQ(pixels(resp), pixels(single("metal1"))); +} + +TEST_F(TileGroupTest, ComposesItsLayersBottomToTop) +{ + const auto resp = group(R"("layers":["metal1","metal2"])"); + ASSERT_EQ(resp.type, WebSocketResponse::kPng); + std::vector expected = pixels(single("metal1")); + over(expected, pixels(single("metal2"))); + const std::vector actual = pixels(resp); + ASSERT_EQ(actual.size(), expected.size()); + int worst = 0; + for (size_t i = 0; i < actual.size(); ++i) { + worst = std::max(worst, std::abs(actual[i] - expected[i])); + } + EXPECT_LE(worst, 1); + + EXPECT_NE(pixels(group(R"("layers":["metal2","metal1"])")), actual) + << "the overlap must depend on which layer is on top"; +} + +TEST_F(TileGroupTest, GroupOfEmptyLayersIsEmpty) +{ + const auto resp = group(R"("layers":["metal9","metal10"])"); + EXPECT_EQ(resp.type, WebSocketResponse::kEmpty); + EXPECT_TRUE(resp.payload.empty()); +} + +TEST_F(TileGroupTest, EachLayerKeepsItsFillPattern) +{ + const auto solid = pixels(group(R"("layers":["metal1"],"patterns":[1])")); + EXPECT_EQ(solid, pixels(group(R"("layers":["metal1"])"))); + EXPECT_NE(solid, pixels(group(R"("layers":["metal1"],"patterns":[3])"))); +} + +TEST_F(TileGroupTest, CachedByLayersInOrderAndPatterns) +{ + group(R"("layers":["metal1","metal2"])"); + const size_t size = gen_->tileCacheSize(); + group(R"("layers":["metal1","metal2"],"scale_bar":true)"); + EXPECT_EQ(gen_->tileCacheSize(), size); + group(R"("layers":["metal2","metal1"])"); + EXPECT_EQ(gen_->tileCacheSize(), size + 1); + group(R"("layers":["metal1","metal2"],"patterns":[1,3])"); + EXPECT_EQ(gen_->tileCacheSize(), size + 2); +} + +TEST_F(TileGroupTest, CancelledBeforeRender) +{ + { + std::lock_guard lock(state_.cancelled_mutex); + state_.cancelled_ids.insert(7); + } + const auto resp = group(R"("layers":["metal1"])", 7); + EXPECT_EQ(resp.type, WebSocketResponse::kError); + EXPECT_EQ(payloadStr(resp), "cancelled"); +} + +TEST_F(TileGroupTest, RejectsBadInput) +{ + for (const char* fields : {R"("nolayers":1)", + R"("layers":[])", + R"("layers":"metal1")", + R"("layers":["_pins"])", + R"("layers":[1])", + R"("layers":["metal1"],"patterns":[1,1])", + R"("layers":["metal1"],"patterns":["x"])"}) { + const auto resp = group(fields); + EXPECT_EQ(resp.type, WebSocketResponse::kError) << fields; + EXPECT_TRUE(payloadStr(resp).starts_with("bad tile_group request")) + << fields; + } +} + TEST_F(TileHandlerTest, TileReturnsPng) { // _instances rather than a tech layer: the die outline puts content on it, so @@ -1855,7 +2058,7 @@ TEST_F(TileHandlerTest, TileRejectsNonIntegerZoomInsteadOfThrowing) } } -// Leaflet asks for tiles beyond the 2^z grid whenever the design is smaller +// A client may ask for tiles beyond the 2^z grid when the design is smaller // than the viewport or while panning at the border, and the renderers answer // those with a transparent tile. A range check here would turn ordinary // panning into a stream of errors, so off-grid coordinates must still render. @@ -2236,9 +2439,9 @@ TEST_F(SelectHandlerTest, SelectAtEmptyAreaReturnsEmptyList) EXPECT_NE(json.find("\"selected\":[]"), std::string::npos); } -// Leaflet's zoomSnap=0 lets the client send fractional zoom values; the -// handler must accept them without erroring out. Regression test for the -// click-to-select breakage after strict-typing the request fields. +// A client may send fractional zoom values; the handler must accept them +// without erroring out. Regression test for the click-to-select breakage +// after strict-typing the request fields. TEST_F(SelectHandlerTest, SelectAcceptsFractionalZoom) { WebSocketRequest req; diff --git a/src/web/test/cpp/TestSaveImage.cpp b/src/web/test/cpp/TestSaveImage.cpp index 5d22e0c9f57..340a11af77a 100644 --- a/src/web/test/cpp/TestSaveImage.cpp +++ b/src/web/test/cpp/TestSaveImage.cpp @@ -633,9 +633,9 @@ TEST_F(SaveImageTest, MultipleLayersComposited) // ─── Composition order ─────────────────────────────────────────────────────── -// saveImage must composite in the same z order Leaflet stacks the layers in on -// screen (display-controls.js addPseudoLayer), otherwise the saved PNG is not -// the view the user was looking at. Before the fix every pseudo layer was +// saveImage must composite in the same z order the view stacks the layers in +// on screen (the draw lists in display-controls.js), otherwise the saved PNG is +// not the view the user was looking at. Before the fix every pseudo layer was // appended after the tech layers, which put the manufacturing grid over the // routing and the pin markers over the tech layers (PR #10806 review). // diff --git a/src/web/test/cpp/TestSaveReport.cpp b/src/web/test/cpp/TestSaveReport.cpp index b8dbc62a08c..2f2919fd9d0 100644 --- a/src/web/test/cpp/TestSaveReport.cpp +++ b/src/web/test/cpp/TestSaveReport.cpp @@ -168,8 +168,6 @@ TEST_F(SaveReportTest, ContainsRequiredHTMLElements) // The golden-layout themes theme.js switches between, by id. EXPECT_TRUE(contains(html, "id=\"gl-theme-dark\"")); EXPECT_TRUE(contains(html, "id=\"gl-theme-light\"")); - // leaflet's stylesheet, bundled into the report's own muxandnandornorxorxnornotbufdffinputconstantoutputhi:lohi:lohi:lohi:logenericout0out1in0in1aoi21aoi22aoi211aoi221aoi222aoi33oai21oai22oai211oai221oai222oai33and3nand3or3nor3and4nand4or4nor4`;window.netlistsvg=chn;window.openroadSkin=O2t;window.THREE=p5e;var _he=globalThis,xhe=_he.ShadowRoot&&(_he.ShadyCSS===void 0||_he.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,F2t=Symbol(),N2t=new WeakMap,yhe=class{constructor(n,r,c){if(this._$cssResult$=!0,c!==F2t)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=n,this.t=r}get styleSheet(){let n=this.o,r=this.t;if(xhe&&n===void 0){let c=r!==void 0&&r.length===1;c&&(n=N2t.get(r)),n===void 0&&((this.o=n=new CSSStyleSheet).replaceSync(this.cssText),c&&N2t.set(r,n))}return n}toString(){return this.cssText}},U2t=s=>new yhe(typeof s=="string"?s:s+"",void 0,F2t);var z2t=(s,n)=>{if(xhe)s.adoptedStyleSheets=n.map(r=>r instanceof CSSStyleSheet?r:r.styleSheet);else for(let r of n){let c=document.createElement("style"),u=_he.litNonce;u!==void 0&&c.setAttribute("nonce",u),c.textContent=r.cssText,s.appendChild(c)}},g5e=xhe?s=>s:s=>s instanceof CSSStyleSheet?(n=>{let r="";for(let c of n.cssRules)r+=c.cssText;return U2t(r)})(s):s;var{is:lhn,defineProperty:uhn,getOwnPropertyDescriptor:fhn,getOwnPropertyNames:hhn,getOwnPropertySymbols:dhn,getPrototypeOf:phn}=Object,Ehe=globalThis,G2t=Ehe.trustedTypes,ghn=G2t?G2t.emptyScript:"",mhn=Ehe.reactiveElementPolyfillSupport,$W=(s,n)=>s,m5e={toAttribute(s,n){switch(n){case Boolean:s=s?ghn:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,n){let r=s;switch(n){case Boolean:r=s!==null;break;case Number:r=s===null?null:Number(s);break;case Object:case Array:try{r=JSON.parse(s)}catch{r=null}}return r}},$2t=(s,n)=>!lhn(s,n),j2t={attribute:!0,type:String,converter:m5e,reflect:!1,useDefault:!1,hasChanged:$2t};Symbol.metadata??=Symbol("metadata"),Ehe.litPropertyMetadata??=new WeakMap;var J3=class extends HTMLElement{static addInitializer(n){this._$Ei(),(this.l??=[]).push(n)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(n,r=j2t){if(r.state&&(r.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(n)&&((r=Object.create(r)).wrapped=!0),this.elementProperties.set(n,r),!r.noAccessor){let c=Symbol(),u=this.getPropertyDescriptor(n,c,r);u!==void 0&&uhn(this.prototype,n,u)}}static getPropertyDescriptor(n,r,c){let{get:u,set:d}=fhn(this.prototype,n)??{get(){return this[r]},set(b){this[r]=b}};return{get:u,set(b){let w=u?.call(this);d?.call(this,b),this.requestUpdate(n,w,c)},configurable:!0,enumerable:!0}}static getPropertyOptions(n){return this.elementProperties.get(n)??j2t}static _$Ei(){if(this.hasOwnProperty($W("elementProperties")))return;let n=phn(this);n.finalize(),n.l!==void 0&&(this.l=[...n.l]),this.elementProperties=new Map(n.elementProperties)}static finalize(){if(this.hasOwnProperty($W("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty($W("properties"))){let r=this.properties,c=[...hhn(r),...dhn(r)];for(let u of c)this.createProperty(u,r[u])}let n=this[Symbol.metadata];if(n!==null){let r=litPropertyMetadata.get(n);if(r!==void 0)for(let[c,u]of r)this.elementProperties.set(c,u)}this._$Eh=new Map;for(let[r,c]of this.elementProperties){let u=this._$Eu(r,c);u!==void 0&&this._$Eh.set(u,r)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(n){let r=[];if(Array.isArray(n)){let c=new Set(n.flat(1/0).reverse());for(let u of c)r.unshift(g5e(u))}else n!==void 0&&r.push(g5e(n));return r}static _$Eu(n,r){let c=r.attribute;return c===!1?void 0:typeof c=="string"?c:typeof n=="string"?n.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(n=>this.enableUpdating=n),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(n=>n(this))}addController(n){(this._$EO??=new Set).add(n),this.renderRoot!==void 0&&this.isConnected&&n.hostConnected?.()}removeController(n){this._$EO?.delete(n)}_$E_(){let n=new Map,r=this.constructor.elementProperties;for(let c of r.keys())this.hasOwnProperty(c)&&(n.set(c,this[c]),delete this[c]);n.size>0&&(this._$Ep=n)}createRenderRoot(){let n=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return z2t(n,this.constructor.elementStyles),n}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(n=>n.hostConnected?.())}enableUpdating(n){}disconnectedCallback(){this._$EO?.forEach(n=>n.hostDisconnected?.())}attributeChangedCallback(n,r,c){this._$AK(n,c)}_$ET(n,r){let c=this.constructor.elementProperties.get(n),u=this.constructor._$Eu(n,c);if(u!==void 0&&c.reflect===!0){let d=(c.converter?.toAttribute!==void 0?c.converter:m5e).toAttribute(r,c.type);this._$Em=n,d==null?this.removeAttribute(u):this.setAttribute(u,d),this._$Em=null}}_$AK(n,r){let c=this.constructor,u=c._$Eh.get(n);if(u!==void 0&&this._$Em!==u){let d=c.getPropertyOptions(u),b=typeof d.converter=="function"?{fromAttribute:d.converter}:d.converter?.fromAttribute!==void 0?d.converter:m5e;this._$Em=u;let w=b.fromAttribute(r,d.type);this[u]=w??this._$Ej?.get(u)??w,this._$Em=null}}requestUpdate(n,r,c,u=!1,d){if(n!==void 0){let b=this.constructor;if(u===!1&&(d=this[n]),c??=b.getPropertyOptions(n),!((c.hasChanged??$2t)(d,r)||c.useDefault&&c.reflect&&d===this._$Ej?.get(n)&&!this.hasAttribute(b._$Eu(n,c))))return;this.C(n,r,c)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(n,r,{useDefault:c,reflect:u,wrapped:d},b){c&&!(this._$Ej??=new Map).has(n)&&(this._$Ej.set(n,b??r??this[n]),d!==!0||b!==void 0)||(this._$AL.has(n)||(this.hasUpdated||c||(r=void 0),this._$AL.set(n,r)),u===!0&&this._$Em!==n&&(this._$Eq??=new Set).add(n))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(r){Promise.reject(r)}let n=this.scheduleUpdate();return n!=null&&await n,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[u,d]of this._$Ep)this[u]=d;this._$Ep=void 0}let c=this.constructor.elementProperties;if(c.size>0)for(let[u,d]of c){let{wrapped:b}=d,w=this[u];b!==!0||this._$AL.has(u)||w===void 0||this.C(u,void 0,d,w)}}let n=!1,r=this._$AL;try{n=this.shouldUpdate(r),n?(this.willUpdate(r),this._$EO?.forEach(c=>c.hostUpdate?.()),this.update(r)):this._$EM()}catch(c){throw n=!1,this._$EM(),c}n&&this._$AE(r)}willUpdate(n){}_$AE(n){this._$EO?.forEach(r=>r.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(n)),this.updated(n)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(n){return!0}update(n){this._$Eq&&=this._$Eq.forEach(r=>this._$ET(r,this[r])),this._$EM()}updated(n){}firstUpdated(n){}};J3.elementStyles=[],J3.shadowRootOptions={mode:"open"},J3[$W("elementProperties")]=new Map,J3[$W("finalized")]=new Map,mhn?.({ReactiveElement:J3}),(Ehe.reactiveElementVersions??=[]).push("2.1.2");var w5e=globalThis,V2t=s=>s,She=w5e.trustedTypes,W2t=She?She.createPolicy("lit-html",{createHTML:s=>s}):void 0,v5e="$lit$",Q3=`lit$${Math.random().toFixed(9).slice(2)}$`,_5e="?"+Q3,bhn=`<${_5e}>`,Q4=document,WW=()=>Q4.createComment(""),HW=s=>s===null||typeof s!="object"&&typeof s!="function",y5e=Array.isArray,K2t=s=>y5e(s)||typeof s?.[Symbol.iterator]=="function",b5e=`[ + the output wire straight to it. -->aoi21aoi22aoi211aoi221aoi222aoi33oai21oai22oai211oai221oai222oai33and3nand3or3nor3and4nand4or4nor4`;window.netlistsvg=uhn;window.openroadSkin=O2t;window.THREE=p5e;var _he=globalThis,xhe=_he.ShadowRoot&&(_he.ShadyCSS===void 0||_he.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,F2t=Symbol(),N2t=new WeakMap,yhe=class{constructor(n,r,c){if(this._$cssResult$=!0,c!==F2t)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=n,this.t=r}get styleSheet(){let n=this.o,r=this.t;if(xhe&&n===void 0){let c=r!==void 0&&r.length===1;c&&(n=N2t.get(r)),n===void 0&&((this.o=n=new CSSStyleSheet).replaceSync(this.cssText),c&&N2t.set(r,n))}return n}toString(){return this.cssText}},U2t=s=>new yhe(typeof s=="string"?s:s+"",void 0,F2t);var z2t=(s,n)=>{if(xhe)s.adoptedStyleSheets=n.map(r=>r instanceof CSSStyleSheet?r:r.styleSheet);else for(let r of n){let c=document.createElement("style"),u=_he.litNonce;u!==void 0&&c.setAttribute("nonce",u),c.textContent=r.cssText,s.appendChild(c)}},g5e=xhe?s=>s:s=>s instanceof CSSStyleSheet?(n=>{let r="";for(let c of n.cssRules)r+=c.cssText;return U2t(r)})(s):s;var{is:fhn,defineProperty:hhn,getOwnPropertyDescriptor:dhn,getOwnPropertyNames:phn,getOwnPropertySymbols:ghn,getPrototypeOf:mhn}=Object,Ehe=globalThis,G2t=Ehe.trustedTypes,bhn=G2t?G2t.emptyScript:"",whn=Ehe.reactiveElementPolyfillSupport,$W=(s,n)=>s,m5e={toAttribute(s,n){switch(n){case Boolean:s=s?bhn:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,n){let r=s;switch(n){case Boolean:r=s!==null;break;case Number:r=s===null?null:Number(s);break;case Object:case Array:try{r=JSON.parse(s)}catch{r=null}}return r}},$2t=(s,n)=>!fhn(s,n),j2t={attribute:!0,type:String,converter:m5e,reflect:!1,useDefault:!1,hasChanged:$2t};Symbol.metadata??=Symbol("metadata"),Ehe.litPropertyMetadata??=new WeakMap;var Q3=class extends HTMLElement{static addInitializer(n){this._$Ei(),(this.l??=[]).push(n)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(n,r=j2t){if(r.state&&(r.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(n)&&((r=Object.create(r)).wrapped=!0),this.elementProperties.set(n,r),!r.noAccessor){let c=Symbol(),u=this.getPropertyDescriptor(n,c,r);u!==void 0&&hhn(this.prototype,n,u)}}static getPropertyDescriptor(n,r,c){let{get:u,set:d}=dhn(this.prototype,n)??{get(){return this[r]},set(b){this[r]=b}};return{get:u,set(b){let w=u?.call(this);d?.call(this,b),this.requestUpdate(n,w,c)},configurable:!0,enumerable:!0}}static getPropertyOptions(n){return this.elementProperties.get(n)??j2t}static _$Ei(){if(this.hasOwnProperty($W("elementProperties")))return;let n=mhn(this);n.finalize(),n.l!==void 0&&(this.l=[...n.l]),this.elementProperties=new Map(n.elementProperties)}static finalize(){if(this.hasOwnProperty($W("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty($W("properties"))){let r=this.properties,c=[...phn(r),...ghn(r)];for(let u of c)this.createProperty(u,r[u])}let n=this[Symbol.metadata];if(n!==null){let r=litPropertyMetadata.get(n);if(r!==void 0)for(let[c,u]of r)this.elementProperties.set(c,u)}this._$Eh=new Map;for(let[r,c]of this.elementProperties){let u=this._$Eu(r,c);u!==void 0&&this._$Eh.set(u,r)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(n){let r=[];if(Array.isArray(n)){let c=new Set(n.flat(1/0).reverse());for(let u of c)r.unshift(g5e(u))}else n!==void 0&&r.push(g5e(n));return r}static _$Eu(n,r){let c=r.attribute;return c===!1?void 0:typeof c=="string"?c:typeof n=="string"?n.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(n=>this.enableUpdating=n),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(n=>n(this))}addController(n){(this._$EO??=new Set).add(n),this.renderRoot!==void 0&&this.isConnected&&n.hostConnected?.()}removeController(n){this._$EO?.delete(n)}_$E_(){let n=new Map,r=this.constructor.elementProperties;for(let c of r.keys())this.hasOwnProperty(c)&&(n.set(c,this[c]),delete this[c]);n.size>0&&(this._$Ep=n)}createRenderRoot(){let n=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return z2t(n,this.constructor.elementStyles),n}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(n=>n.hostConnected?.())}enableUpdating(n){}disconnectedCallback(){this._$EO?.forEach(n=>n.hostDisconnected?.())}attributeChangedCallback(n,r,c){this._$AK(n,c)}_$ET(n,r){let c=this.constructor.elementProperties.get(n),u=this.constructor._$Eu(n,c);if(u!==void 0&&c.reflect===!0){let d=(c.converter?.toAttribute!==void 0?c.converter:m5e).toAttribute(r,c.type);this._$Em=n,d==null?this.removeAttribute(u):this.setAttribute(u,d),this._$Em=null}}_$AK(n,r){let c=this.constructor,u=c._$Eh.get(n);if(u!==void 0&&this._$Em!==u){let d=c.getPropertyOptions(u),b=typeof d.converter=="function"?{fromAttribute:d.converter}:d.converter?.fromAttribute!==void 0?d.converter:m5e;this._$Em=u;let w=b.fromAttribute(r,d.type);this[u]=w??this._$Ej?.get(u)??w,this._$Em=null}}requestUpdate(n,r,c,u=!1,d){if(n!==void 0){let b=this.constructor;if(u===!1&&(d=this[n]),c??=b.getPropertyOptions(n),!((c.hasChanged??$2t)(d,r)||c.useDefault&&c.reflect&&d===this._$Ej?.get(n)&&!this.hasAttribute(b._$Eu(n,c))))return;this.C(n,r,c)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(n,r,{useDefault:c,reflect:u,wrapped:d},b){c&&!(this._$Ej??=new Map).has(n)&&(this._$Ej.set(n,b??r??this[n]),d!==!0||b!==void 0)||(this._$AL.has(n)||(this.hasUpdated||c||(r=void 0),this._$AL.set(n,r)),u===!0&&this._$Em!==n&&(this._$Eq??=new Set).add(n))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(r){Promise.reject(r)}let n=this.scheduleUpdate();return n!=null&&await n,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[u,d]of this._$Ep)this[u]=d;this._$Ep=void 0}let c=this.constructor.elementProperties;if(c.size>0)for(let[u,d]of c){let{wrapped:b}=d,w=this[u];b!==!0||this._$AL.has(u)||w===void 0||this.C(u,void 0,d,w)}}let n=!1,r=this._$AL;try{n=this.shouldUpdate(r),n?(this.willUpdate(r),this._$EO?.forEach(c=>c.hostUpdate?.()),this.update(r)):this._$EM()}catch(c){throw n=!1,this._$EM(),c}n&&this._$AE(r)}willUpdate(n){}_$AE(n){this._$EO?.forEach(r=>r.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(n)),this.updated(n)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(n){return!0}update(n){this._$Eq&&=this._$Eq.forEach(r=>this._$ET(r,this[r])),this._$EM()}updated(n){}firstUpdated(n){}};Q3.elementStyles=[],Q3.shadowRootOptions={mode:"open"},Q3[$W("elementProperties")]=new Map,Q3[$W("finalized")]=new Map,whn?.({ReactiveElement:Q3}),(Ehe.reactiveElementVersions??=[]).push("2.1.2");var w5e=globalThis,V2t=s=>s,She=w5e.trustedTypes,W2t=She?She.createPolicy("lit-html",{createHTML:s=>s}):void 0,v5e="$lit$",eE=`lit$${Math.random().toFixed(9).slice(2)}$`,_5e="?"+eE,vhn=`<${_5e}>`,Q4=document,WW=()=>Q4.createComment(""),HW=s=>s===null||typeof s!="object"&&typeof s!="function",y5e=Array.isArray,K2t=s=>y5e(s)||typeof s?.[Symbol.iterator]=="function",b5e=`[ \f\r]`,VW=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,H2t=/-->/g,q2t=/>/g,K4=RegExp(`>|${b5e}(?:([^\\s"'>=/]+)(${b5e}*=${b5e}*(?:[^ -\f\r"'\`<>=]|("|')|))|$)`,"g"),X2t=/'/g,Y2t=/"/g,J2t=/^(?:script|style|textarea|title)$/i,x5e=s=>(n,...r)=>({_$litType$:s,strings:n,values:r}),ik=x5e(1),rci=x5e(2),sci=x5e(3),ek=Symbol.for("lit-noChange"),eu=Symbol.for("lit-nothing"),Z2t=new WeakMap,J4=Q4.createTreeWalker(Q4,129);function Q2t(s,n){if(!y5e(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return W2t!==void 0?W2t.createHTML(n):n}var ext=(s,n)=>{let r=s.length-1,c=[],u,d=n===2?"":n===3?"":"",b=VW;for(let w=0;w"?(b=u??VW,M=-1):T[1]===void 0?M=-2:(M=b.lastIndex-T[2].length,x=T[1],b=T[3]===void 0?K4:T[3]==='"'?Y2t:X2t):b===Y2t||b===X2t?b=K4:b===H2t||b===q2t?b=VW:(b=K4,u=void 0);let I=b===K4&&s[w+1].startsWith("/>")?" ":"";d+=b===VW?_+bhn:M>=0?(c.push(x),_.slice(0,M)+v5e+_.slice(M)+Q3+I):_+Q3+(M===-2?w:I)}return[Q2t(s,d+(s[r]||"")+(n===2?"":n===3?"":"")),c]},qW=class s{constructor({strings:n,_$litType$:r},c){let u;this.parts=[];let d=0,b=0,w=n.length-1,_=this.parts,[x,T]=ext(n,r);if(this.el=s.createElement(x,c),J4.currentNode=this.el.content,r===2||r===3){let M=this.el.content.firstChild;M.replaceWith(...M.childNodes)}for(;(u=J4.nextNode())!==null&&_.length0){u.textContent=She?She.emptyScript:"";for(let I=0;I2||c[0]!==""||c[1]!==""?(this._$AH=Array(c.length-1).fill(new String),this.strings=c):this._$AH=eu}_$AI(n,r=this,c,u){let d=this.strings,b=!1;if(d===void 0)n=tk(this,n,r,0),b=!HW(n)||n!==this._$AH&&n!==ek,b&&(this._$AH=n);else{let w=n,_,x;for(n=d[0],_=0;_{let c=r?.renderBefore??n,u=c._$litPart$;if(u===void 0){let d=r?.renderBefore??null;c._$litPart$=u=new bO(n.insertBefore(WW(),d),d,void 0,r??{})}return u._$AI(s),u};var E5e=globalThis,p2=class extends J3{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let n=super.createRenderRoot();return this.renderOptions.renderBefore??=n.firstChild,n}update(n){let r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(n),this._$Do=nxt(r,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return ek}};p2._$litElement$=!0,p2.finalized=!0,E5e.litElementHydrateSupport?.({LitElement:p2});var vhn=E5e.litElementPolyfillSupport;vhn?.({LitElement:p2});(E5e.litElementVersions??=[]).push("4.2.2");var{I:vci}=txt;var ixt=s=>s.strings===void 0;var rxt={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},S5e=s=>(...n)=>({_$litDirective$:s,values:n}),Lhe=class{constructor(n){}get _$AU(){return this._$AM._$AU}_$AT(n,r,c){this._$Ct=n,this._$AM=r,this._$Ci=c}_$AS(n,r){return this.update(n,r)}update(n,r){return this.render(...r)}};var XW=(s,n)=>{let r=s._$AN;if(r===void 0)return!1;for(let c of r)c._$AO?.(n,!1),XW(c,n);return!0},khe=s=>{let n,r;do{if((n=s._$AM)===void 0)break;r=n._$AN,r.delete(s),s=n}while(r?.size===0)},sxt=s=>{for(let n;n=s._$AM;s=n){let r=n._$AN;if(r===void 0)n._$AN=r=new Set;else if(r.has(s))break;r.add(s),xhn(n)}};function _hn(s){this._$AN!==void 0?(khe(this),this._$AM=s,sxt(this)):this._$AM=s}function yhn(s,n=!1,r=0){let c=this._$AH,u=this._$AN;if(u!==void 0&&u.size!==0)if(n)if(Array.isArray(c))for(let d=r;d{s.type==rxt.CHILD&&(s._$AP??=yhn,s._$AQ??=_hn)},Rhe=class extends Lhe{constructor(){super(...arguments),this._$AN=void 0}_$AT(n,r,c){super._$AT(n,r,c),sxt(this),this.isConnected=n._$AU}_$AO(n,r=!0){n!==this.isConnected&&(this.isConnected=n,n?this.reconnected?.():this.disconnected?.()),r&&(XW(this,n),khe(this))}setValue(n){if(ixt(this._$Ct))this._$Ct._$AI(n,this);else{let r=[...this._$Ct._$AH];r[this._$Ci]=n,this._$Ct._$AI(r,this,0)}}disconnected(){}reconnected(){}};var eE=()=>new T5e,T5e=class{},M5e=new WeakMap,tE=S5e(class extends Rhe{render(s){return eu}update(s,[n]){let r=n!==this.G;return r&&this.rt(void 0),(r||this.lt!==this.ct)&&(this.G=n,this.ht=s.options?.host,this.rt(this.ct=s.element)),eu}rt(s){if(this.G!==void 0)if(this.isConnected||(s=void 0),typeof this.G=="function"){let n=this.ht??globalThis,r=M5e.get(n);r===void 0&&(r=new WeakMap,M5e.set(n,r)),r.get(this.G)!==void 0&&this.G.call(this.ht,void 0),r.set(this.G,s),s!==void 0&&this.G.call(this.ht,s)}else this.G.value=s}get lt(){return typeof this.G=="function"?M5e.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});function YW(s,n,r){return s?n(s):r?.(s)}var C5e=s=>s??eu;var A5e=class extends p2{static properties={name:{type:String,reflect:!0},maximizable:{type:Boolean,reflect:!0},collapsible:{type:Boolean,reflect:!0},maximized:{type:Boolean,reflect:!0},collapsed:{type:Boolean,reflect:!0}};constructor(){super(),this.tabsRef=eE(),this.contentRef=eE(),this.headerRef=eE(),this.controlsRef=eE(),this.maximizeBtnRef=eE(),this.collapseBtnRef=eE(),this._onMaximizeClick=this._onMaximizeClick.bind(this),this._onCollapseClick=this._onCollapseClick.bind(this),this._onResetLayoutClick=this._onResetLayoutClick.bind(this)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.classList.add("ide-pane",`ide-pane-${this.paneName}`),this.performUpdate()}get paneName(){return this.name||this.getAttribute("name")||this.id.replace(/^pane-/,"")||"pane"}get tabsEl(){return this.hasUpdated||this.performUpdate(),this.tabsRef.value}get contentEl(){return this.hasUpdated||this.performUpdate(),this.contentRef.value}get headerEl(){return this.hasUpdated||this.performUpdate(),this.headerRef.value}get controlsEl(){return this.hasUpdated||this.performUpdate(),this.controlsRef.value}get maximizeBtn(){return this.hasUpdated||this.performUpdate(),this.maximizeBtnRef.value}get collapseBtn(){return this.hasUpdated||this.performUpdate(),this.collapseBtnRef.value}get _collapseIcon(){let n=this.paneName;return n==="bottom"?this.collapsed?"\u25B2":"\u25BC":n==="left"?this.collapsed?"\u25B6":"\u25C0":n==="right"?this.collapsed?"\u25C0":"\u25B6":"\u25BC"}get _collapseTitle(){let n=this.paneName,r=n.charAt(0).toUpperCase()+n.slice(1);return n==="bottom"?this.collapsed?"Expand Console":"Collapse Console":n==="left"?this.collapsed?"Expand Left Panel":"Collapse Left Panel":n==="right"?this.collapsed?"Expand Right Panel":"Collapse Right Panel":`Collapse ${r}`}_emit(n,r={}){this.dispatchEvent(new CustomEvent(n,{bubbles:!0,composed:!0,detail:r}))}_onMaximizeClick(n){n.stopPropagation(),this._emit("ide-pane-maximize",{pane:this.paneName})}_onCollapseClick(n){n.stopPropagation(),this._emit("ide-pane-collapse",{pane:this.paneName})}_onResetLayoutClick(n){n.stopPropagation(),this._emit("ide-layout-reset")}setMaximized(n){this.maximized=!!n,this.classList.toggle("maximized",this.maximized),this.maximizeBtn&&(this.maximizeBtn.textContent=this.maximized?"\u29C9":"\u2922",this.maximizeBtn.title=this.maximized?"Restore":"Maximize")}setCollapsed(n){this.collapsed=!!n,this.classList.toggle("collapsed",this.collapsed),this.collapseBtn&&(this.collapseBtn.textContent=this._collapseIcon,this.collapseBtn.title=this._collapseTitle)}build(){this.hasUpdated||this.performUpdate()}updated(n){super.updated(n),n.has("maximized")&&this.classList.toggle("maximized",!!this.maximized),n.has("collapsed")&&this.classList.toggle("collapsed",!!this.collapsed)}render(){let n=this.paneName,r=this.id||`pane-${n}`,c=this.maximizable||this.hasAttribute("maximizable"),u=this.collapsible||this.hasAttribute("collapsible");return ik` -
-
-
+\f\r"'\`<>=]|("|')|))|$)`,"g"),X2t=/'/g,Y2t=/"/g,J2t=/^(?:script|style|textarea|title)$/i,x5e=s=>(n,...r)=>({_$litType$:s,strings:n,values:r}),ik=x5e(1),cci=x5e(2),lci=x5e(3),ek=Symbol.for("lit-noChange"),tu=Symbol.for("lit-nothing"),Z2t=new WeakMap,J4=Q4.createTreeWalker(Q4,129);function Q2t(s,n){if(!y5e(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return W2t!==void 0?W2t.createHTML(n):n}var ext=(s,n)=>{let r=s.length-1,c=[],u,d=n===2?"":n===3?"":"",b=VW;for(let w=0;w"?(b=u??VW,M=-1):T[1]===void 0?M=-2:(M=b.lastIndex-T[2].length,x=T[1],b=T[3]===void 0?K4:T[3]==='"'?Y2t:X2t):b===Y2t||b===X2t?b=K4:b===H2t||b===q2t?b=VW:(b=K4,u=void 0);let I=b===K4&&s[w+1].startsWith("/>")?" ":"";d+=b===VW?_+vhn:M>=0?(c.push(x),_.slice(0,M)+v5e+_.slice(M)+eE+I):_+eE+(M===-2?w:I)}return[Q2t(s,d+(s[r]||"")+(n===2?"":n===3?"":"")),c]},qW=class s{constructor({strings:n,_$litType$:r},c){let u;this.parts=[];let d=0,b=0,w=n.length-1,_=this.parts,[x,T]=ext(n,r);if(this.el=s.createElement(x,c),J4.currentNode=this.el.content,r===2||r===3){let M=this.el.content.firstChild;M.replaceWith(...M.childNodes)}for(;(u=J4.nextNode())!==null&&_.length0){u.textContent=She?She.emptyScript:"";for(let I=0;I2||c[0]!==""||c[1]!==""?(this._$AH=Array(c.length-1).fill(new String),this.strings=c):this._$AH=tu}_$AI(n,r=this,c,u){let d=this.strings,b=!1;if(d===void 0)n=tk(this,n,r,0),b=!HW(n)||n!==this._$AH&&n!==ek,b&&(this._$AH=n);else{let w=n,_,x;for(n=d[0],_=0;_{let c=r?.renderBefore??n,u=c._$litPart$;if(u===void 0){let d=r?.renderBefore??null;c._$litPart$=u=new bO(n.insertBefore(WW(),d),d,void 0,r??{})}return u._$AI(s),u};var E5e=globalThis,p2=class extends Q3{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let n=super.createRenderRoot();return this.renderOptions.renderBefore??=n.firstChild,n}update(n){let r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(n),this._$Do=nxt(r,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return ek}};p2._$litElement$=!0,p2.finalized=!0,E5e.litElementHydrateSupport?.({LitElement:p2});var yhn=E5e.litElementPolyfillSupport;yhn?.({LitElement:p2});(E5e.litElementVersions??=[]).push("4.2.2");var{I:Eci}=txt;var ixt=s=>s.strings===void 0;var rxt={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},S5e=s=>(...n)=>({_$litDirective$:s,values:n}),Lhe=class{constructor(n){}get _$AU(){return this._$AM._$AU}_$AT(n,r,c){this._$Ct=n,this._$AM=r,this._$Ci=c}_$AS(n,r){return this.update(n,r)}update(n,r){return this.render(...r)}};var XW=(s,n)=>{let r=s._$AN;if(r===void 0)return!1;for(let c of r)c._$AO?.(n,!1),XW(c,n);return!0},khe=s=>{let n,r;do{if((n=s._$AM)===void 0)break;r=n._$AN,r.delete(s),s=n}while(r?.size===0)},sxt=s=>{for(let n;n=s._$AM;s=n){let r=n._$AN;if(r===void 0)n._$AN=r=new Set;else if(r.has(s))break;r.add(s),Shn(n)}};function xhn(s){this._$AN!==void 0?(khe(this),this._$AM=s,sxt(this)):this._$AM=s}function Ehn(s,n=!1,r=0){let c=this._$AH,u=this._$AN;if(u!==void 0&&u.size!==0)if(n)if(Array.isArray(c))for(let d=r;d{s.type==rxt.CHILD&&(s._$AP??=Ehn,s._$AQ??=xhn)},Rhe=class extends Lhe{constructor(){super(...arguments),this._$AN=void 0}_$AT(n,r,c){super._$AT(n,r,c),sxt(this),this.isConnected=n._$AU}_$AO(n,r=!0){n!==this.isConnected&&(this.isConnected=n,n?this.reconnected?.():this.disconnected?.()),r&&(XW(this,n),khe(this))}setValue(n){if(ixt(this._$Ct))this._$Ct._$AI(n,this);else{let r=[...this._$Ct._$AH];r[this._$Ci]=n,this._$Ct._$AI(r,this,0)}}disconnected(){}reconnected(){}};var tE=()=>new T5e,T5e=class{},M5e=new WeakMap,nE=S5e(class extends Rhe{render(s){return tu}update(s,[n]){let r=n!==this.G;return r&&this.rt(void 0),(r||this.lt!==this.ct)&&(this.G=n,this.ht=s.options?.host,this.rt(this.ct=s.element)),tu}rt(s){if(this.G!==void 0)if(this.isConnected||(s=void 0),typeof this.G=="function"){let n=this.ht??globalThis,r=M5e.get(n);r===void 0&&(r=new WeakMap,M5e.set(n,r)),r.get(this.G)!==void 0&&this.G.call(this.ht,void 0),r.set(this.G,s),s!==void 0&&this.G.call(this.ht,s)}else this.G.value=s}get lt(){return typeof this.G=="function"?M5e.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});function YW(s,n,r){return s?n(s):r?.(s)}var C5e=s=>s??tu;var A5e=class extends p2{static properties={name:{type:String,reflect:!0},maximizable:{type:Boolean,reflect:!0},collapsible:{type:Boolean,reflect:!0},maximized:{type:Boolean,reflect:!0},collapsed:{type:Boolean,reflect:!0}};constructor(){super(),this.tabsRef=tE(),this.contentRef=tE(),this.headerRef=tE(),this.controlsRef=tE(),this.maximizeBtnRef=tE(),this.collapseBtnRef=tE(),this._onMaximizeClick=this._onMaximizeClick.bind(this),this._onCollapseClick=this._onCollapseClick.bind(this),this._onResetLayoutClick=this._onResetLayoutClick.bind(this)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.classList.add("ide-pane",`ide-pane-${this.paneName}`),this.performUpdate()}get paneName(){return this.name||this.getAttribute("name")||this.id.replace(/^pane-/,"")||"pane"}get tabsEl(){return this.hasUpdated||this.performUpdate(),this.tabsRef.value}get contentEl(){return this.hasUpdated||this.performUpdate(),this.contentRef.value}get headerEl(){return this.hasUpdated||this.performUpdate(),this.headerRef.value}get controlsEl(){return this.hasUpdated||this.performUpdate(),this.controlsRef.value}get maximizeBtn(){return this.hasUpdated||this.performUpdate(),this.maximizeBtnRef.value}get collapseBtn(){return this.hasUpdated||this.performUpdate(),this.collapseBtnRef.value}get _collapseIcon(){let n=this.paneName;return n==="bottom"?this.collapsed?"\u25B2":"\u25BC":n==="left"?this.collapsed?"\u25B6":"\u25C0":n==="right"?this.collapsed?"\u25C0":"\u25B6":"\u25BC"}get _collapseTitle(){let n=this.paneName,r=n.charAt(0).toUpperCase()+n.slice(1);return n==="bottom"?this.collapsed?"Expand Console":"Collapse Console":n==="left"?this.collapsed?"Expand Left Panel":"Collapse Left Panel":n==="right"?this.collapsed?"Expand Right Panel":"Collapse Right Panel":`Collapse ${r}`}_emit(n,r={}){this.dispatchEvent(new CustomEvent(n,{bubbles:!0,composed:!0,detail:r}))}_onMaximizeClick(n){n.stopPropagation(),this._emit("ide-pane-maximize",{pane:this.paneName})}_onCollapseClick(n){n.stopPropagation(),this._emit("ide-pane-collapse",{pane:this.paneName})}_onResetLayoutClick(n){n.stopPropagation(),this._emit("ide-layout-reset")}setMaximized(n){this.maximized=!!n,this.classList.toggle("maximized",this.maximized),this.maximizeBtn&&(this.maximizeBtn.textContent=this.maximized?"\u29C9":"\u2922",this.maximizeBtn.title=this.maximized?"Restore":"Maximize")}setCollapsed(n){this.collapsed=!!n,this.classList.toggle("collapsed",this.collapsed),this.collapseBtn&&(this.collapseBtn.textContent=this._collapseIcon,this.collapseBtn.title=this._collapseTitle)}build(){this.hasUpdated||this.performUpdate()}updated(n){super.updated(n),n.has("maximized")&&this.classList.toggle("maximized",!!this.maximized),n.has("collapsed")&&this.classList.toggle("collapsed",!!this.collapsed)}render(){let n=this.paneName,r=this.id||`pane-${n}`,c=this.maximizable||this.hasAttribute("maximizable"),u=this.collapsible||this.hasAttribute("collapsible");return ik` +
+
+
${YW(c,()=>ik` `)} @@ -10162,13 +10162,13 @@ path, rect, circle, polygon { class="ide-btn ide-btn-collapse" id="btn-collapse-${n}" title=${C5e(this._collapseTitle)} - ${tE(this.collapseBtnRef)} + ${nE(this.collapseBtnRef)} @click=${this._onCollapseClick} >${this._collapseIcon} `)}
-
+
${YW(n==="main",()=>ik` `)}
- `}},P5e=class{constructor(n,r={}){(this.host=n).addController(this),this.options=r,this._abort=null,this.isDragging=!1,this.startPos=0}hostDisconnected(){this.stop()}start(n,r=!0){n.preventDefault();try{this.host.setPointerCapture(n.pointerId)}catch{}this.isDragging=!0,this.host.classList.add("dragging"),document.body&&document.body.classList.add("is-resizing",r?"is-resizing-v":"is-resizing-h"),this.startPos=r?n.clientX:n.clientY,this.options.onStart?.({startPos:this.startPos,event:n}),this._abort=new AbortController;let{signal:c}=this._abort;window.addEventListener("pointermove",d=>{let b=r?d.clientX:d.clientY,w=b-this.startPos;this.options.onDrag?.({delta:w,currentPos:b,startPos:this.startPos,event:d})},{signal:c});let u=d=>{try{this.host.releasePointerCapture(n.pointerId)}catch{}this.stop(r),this.options.onEnd?.({event:d})};window.addEventListener("pointerup",u,{signal:c}),window.addEventListener("pointercancel",u,{signal:c})}stop(n=!0){this.isDragging&&(this.isDragging=!1,this.host.classList.remove("dragging"),document.body&&document.body.classList.remove("is-resizing","is-resizing-v","is-resizing-h"),this._abort?.abort(),this._abort=null)}},Dhe=class extends p2{static properties={for:{type:String},orientation:{type:String,reflect:!0}};constructor(){super(),this.orientation="vertical",this._connectedAbort=null,this.drag=new P5e(this,{onStart:({startPos:n})=>this._emit("start",{startPos:n}),onDrag:({delta:n,currentPos:r,startPos:c})=>this._emit("drag",{delta:n,currentPos:r,startPos:c}),onEnd:()=>this._emit("end")})}connectedCallback(){super.connectedCallback(),this._connectedAbort=new AbortController;let{signal:n}=this._connectedAbort;this.setAttribute("role","separator"),this.classList.add("ide-splitter"),this.performUpdate(),this.addEventListener("pointerdown",r=>this.drag.start(r,this.isVertical),{signal:n}),this.addEventListener("dblclick",()=>this._emit("reset"),{signal:n})}disconnectedCallback(){super.disconnectedCallback(),this._connectedAbort?.abort()}build(){}updated(n){super.updated(n);let r=this.isVertical;this.setAttribute("aria-orientation",r?"vertical":"horizontal"),this.classList.toggle("ide-splitter-v",r),this.classList.toggle("ide-splitter-h",!r)}get targetPane(){return this.for||this.getAttribute("for")||""}get isVertical(){return(this.orientation||this.getAttribute("orientation")||"vertical")==="vertical"}_emit(n,r={}){this.dispatchEvent(new CustomEvent(`ide-splitter-${n}`,{bubbles:!0,composed:!0,detail:{for:this.targetPane,orientation:this.isVertical?"vertical":"horizontal",...r}}))}},L5e=class extends p2{static properties={title:{type:String,reflect:!0},closable:{type:Boolean,reflect:!0},for:{type:String},active:{type:Boolean,reflect:!0}};constructor(){super(),this._connectedAbort=null,this.titleRef=eE(),this.closeBtnRef=eE(),this._onClick=this._onClick.bind(this),this._onCloseClick=this._onCloseClick.bind(this)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this._connectedAbort=new AbortController;let{signal:n}=this._connectedAbort;this.classList.add("ide-tab","lm_tab"),this.setAttribute("role","tab"),this.hasAttribute("aria-selected")||this.setAttribute("aria-selected","false"),this.addEventListener("click",this._onClick,{signal:n}),this.performUpdate()}disconnectedCallback(){super.disconnectedCallback(),this._connectedAbort?.abort()}_emit(n,r={}){this.dispatchEvent(new CustomEvent(n,{bubbles:!0,composed:!0,detail:r}))}_onClick(n){n&&n.target&&n.target.closest(".ide-tab-close")||this._emit("tab-select",{componentType:this.targetComponent})}_onCloseClick(n){n.stopPropagation(),this._emit("tab-close",{componentType:this.targetComponent})}get targetComponent(){return this.for||this.getAttribute("for")||this.getAttribute("data-component")||this.id.replace(/^tab-/,"")||""}get titleText(){return this.title||""}set titleText(n){this.title=n}get titleEl(){return this.hasUpdated||this.performUpdate(),this.titleRef.value}get closeBtn(){return this.hasUpdated||this.performUpdate(),this.closeBtnRef.value}setActive(n){this.active=!!n,this.performUpdate()}updated(n){super.updated(n),n.has("active")&&(this.classList.toggle("active",this.active),this.classList.toggle("lm_active",this.active),this.setAttribute("aria-selected",this.active?"true":"false"))}render(){let n=this.title||"",r=!!this.closable;return ik` - ${n} + `}},P5e=class{constructor(n,r={}){(this.host=n).addController(this),this.options=r,this._abort=null,this.isDragging=!1,this.startPos=0}hostDisconnected(){this.stop()}start(n,r=!0){n.preventDefault();try{this.host.setPointerCapture(n.pointerId)}catch{}this.isDragging=!0,this.host.classList.add("dragging"),document.body&&document.body.classList.add("is-resizing",r?"is-resizing-v":"is-resizing-h"),this.startPos=r?n.clientX:n.clientY,this.options.onStart?.({startPos:this.startPos,event:n}),this._abort=new AbortController;let{signal:c}=this._abort;window.addEventListener("pointermove",d=>{let b=r?d.clientX:d.clientY,w=b-this.startPos;this.options.onDrag?.({delta:w,currentPos:b,startPos:this.startPos,event:d})},{signal:c});let u=d=>{try{this.host.releasePointerCapture(n.pointerId)}catch{}this.stop(r),this.options.onEnd?.({event:d})};window.addEventListener("pointerup",u,{signal:c}),window.addEventListener("pointercancel",u,{signal:c})}stop(n=!0){this.isDragging&&(this.isDragging=!1,this.host.classList.remove("dragging"),document.body&&document.body.classList.remove("is-resizing","is-resizing-v","is-resizing-h"),this._abort?.abort(),this._abort=null)}},Dhe=class extends p2{static properties={for:{type:String},orientation:{type:String,reflect:!0}};constructor(){super(),this.orientation="vertical",this._connectedAbort=null,this.drag=new P5e(this,{onStart:({startPos:n})=>this._emit("start",{startPos:n}),onDrag:({delta:n,currentPos:r,startPos:c})=>this._emit("drag",{delta:n,currentPos:r,startPos:c}),onEnd:()=>this._emit("end")})}connectedCallback(){super.connectedCallback(),this._connectedAbort=new AbortController;let{signal:n}=this._connectedAbort;this.setAttribute("role","separator"),this.classList.add("ide-splitter"),this.performUpdate(),this.addEventListener("pointerdown",r=>this.drag.start(r,this.isVertical),{signal:n}),this.addEventListener("dblclick",()=>this._emit("reset"),{signal:n})}disconnectedCallback(){super.disconnectedCallback(),this._connectedAbort?.abort()}build(){}updated(n){super.updated(n);let r=this.isVertical;this.setAttribute("aria-orientation",r?"vertical":"horizontal"),this.classList.toggle("ide-splitter-v",r),this.classList.toggle("ide-splitter-h",!r)}get targetPane(){return this.for||this.getAttribute("for")||""}get isVertical(){return(this.orientation||this.getAttribute("orientation")||"vertical")==="vertical"}_emit(n,r={}){this.dispatchEvent(new CustomEvent(`ide-splitter-${n}`,{bubbles:!0,composed:!0,detail:{for:this.targetPane,orientation:this.isVertical?"vertical":"horizontal",...r}}))}},L5e=class extends p2{static properties={title:{type:String,reflect:!0},closable:{type:Boolean,reflect:!0},for:{type:String},active:{type:Boolean,reflect:!0}};constructor(){super(),this._connectedAbort=null,this.titleRef=tE(),this.closeBtnRef=tE(),this._onClick=this._onClick.bind(this),this._onCloseClick=this._onCloseClick.bind(this)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this._connectedAbort=new AbortController;let{signal:n}=this._connectedAbort;this.classList.add("ide-tab","lm_tab"),this.setAttribute("role","tab"),this.hasAttribute("aria-selected")||this.setAttribute("aria-selected","false"),this.addEventListener("click",this._onClick,{signal:n}),this.performUpdate()}disconnectedCallback(){super.disconnectedCallback(),this._connectedAbort?.abort()}_emit(n,r={}){this.dispatchEvent(new CustomEvent(n,{bubbles:!0,composed:!0,detail:r}))}_onClick(n){n&&n.target&&n.target.closest(".ide-tab-close")||this._emit("tab-select",{componentType:this.targetComponent})}_onCloseClick(n){n.stopPropagation(),this._emit("tab-close",{componentType:this.targetComponent})}get targetComponent(){return this.for||this.getAttribute("for")||this.getAttribute("data-component")||this.id.replace(/^tab-/,"")||""}get titleText(){return this.title||""}set titleText(n){this.title=n}get titleEl(){return this.hasUpdated||this.performUpdate(),this.titleRef.value}get closeBtn(){return this.hasUpdated||this.performUpdate(),this.closeBtnRef.value}setActive(n){this.active=!!n,this.performUpdate()}updated(n){super.updated(n),n.has("active")&&(this.classList.toggle("active",this.active),this.classList.toggle("lm_active",this.active),this.setAttribute("aria-selected",this.active?"true":"false"))}render(){let n=this.title||"",r=!!this.closable;return ik` + ${n} ${YW(r,()=>ik` ✕ `)} - `}};customElements.get("ide-pane")||customElements.define("ide-pane",A5e);customElements.get("ide-splitter")||customElements.define("ide-splitter",Dhe);customElements.get("ide-tab")||customElements.define("ide-tab",L5e);var oxt={DisplayControls:{pane:"left",title:"Display Controls",closable:!1},LayoutViewer:{pane:"main",title:"Layout",closable:!1},SchematicWidget:{pane:"main",title:"Schematic",closable:!0},"3DViewer":{pane:"main",title:"3D Viewer",closable:!0},TclConsole:{pane:"bottom",title:"Tcl Console",closable:!1},Inspector:{pane:"right",title:"Inspector",closable:!0},Browser:{pane:"right",title:"Hierarchy",closable:!0},TimingWidget:{pane:"right",title:"Timing",closable:!0},DRCWidget:{pane:"right",title:"DRC",closable:!0},SelectHighlight:{pane:"right",title:"Select Highlight",closable:!0},ClockWidget:{pane:"right",title:"Clock Tree",closable:!0},ChartsWidget:{pane:"right",title:"Charts",closable:!0},HelpWidget:{pane:"right",title:"Help",closable:!0}},Ihe={left:{cssVar:"--pane-left-width",defaultSize:"240px",minSize:140,maxFraction:.45,dimension:"width",isVertical:!0,invertDelta:!1},right:{cssVar:"--pane-right-width",defaultSize:"340px",minSize:160,maxFraction:.5,dimension:"width",isVertical:!0,invertDelta:!0},bottom:{cssVar:"--pane-bottom-height",defaultSize:"220px",minSize:70,maxFraction:.75,dimension:"height",isVertical:!1,invertDelta:!0}},Bhe=class{constructor(n){this.containerEl=n,this.factories=new Map,this.components=new Map,this.activeTabs={left:null,main:null,bottom:null,right:null},this.closedComponents=new Set,this.eventListeners=new Map,this._resizeScheduled=!1,this._ensureDOM(),this._initSplitters(),this._initControls(),this._initResizeObserver()}on(n,r){this.eventListeners.has(n)||this.eventListeners.set(n,new Set),this.eventListeners.get(n).add(r)}off(n,r){this.eventListeners.get(n)?.delete(r)}emit(n,...r){let c=this.eventListeners.get(n);if(c)for(let u of c)try{u(...r)}catch(d){console.error(d)}}_ensureDOM(){this.containerEl.classList.add("ide-layout"),this.containerEl.querySelector("#pane-left")||this._buildInitialLayoutTree(),this._resolvePaneReferences()}_buildInitialLayoutTree(){this.containerEl.appendChild(this._createGutterButton("left","\u25B6 Display Controls","Restore Display Controls")),this.containerEl.appendChild(this._createGutterButton("right","\u25C0 Tools & Inspector","Restore Right Panel")),this.containerEl.appendChild(this._createPane("pane-left","left")),this.containerEl.appendChild(this._createSplitter("splitter-left","left","vertical","Drag to resize panel"));let n=document.createElement("main");n.id="pane-center",n.className="ide-center",n.appendChild(this._createPane("pane-main","main",{maximizable:!0})),n.appendChild(this._createSplitter("splitter-bottom","bottom","horizontal","Drag to resize console")),n.appendChild(this._createGutterButton("bottom","\u25B2 Tcl Console","Restore Tcl Console")),n.appendChild(this._createPane("pane-bottom","bottom",{maximizable:!0,collapsible:!0})),this.containerEl.appendChild(n),this.containerEl.appendChild(this._createSplitter("splitter-right","right","vertical","Drag to resize panel")),this.containerEl.appendChild(this._createPane("pane-right","right",{maximizable:!0,collapsible:!0}))}_createGutterButton(n,r,c){let u=document.createElement("button");u.id=`gutter-expand-${n}`,u.className=`ide-gutter-expand ide-gutter-${n}`,u.title=c;let d=document.createElement("span");return d.textContent=r,u.appendChild(d),u}_createPane(n,r,c={}){let u=document.createElement("ide-pane");return u.id=n,u.setAttribute("name",r),c.maximizable&&u.setAttribute("maximizable",""),c.collapsible&&u.setAttribute("collapsible",""),u}_createSplitter(n,r,c,u){let d=document.createElement("ide-splitter");return d.id=n,d.setAttribute("for",r),d.setAttribute("orientation",c),d.title=u,d}_resolvePaneReferences(){let n=["left","main","bottom","right"];this.panes={};for(let r of n){let c=this.containerEl.querySelector(`#pane-${r}`);c?.build&&c.build(),this.panes[r]={el:c,paneComponent:c,tabsEl:c?.tabsEl||this.containerEl.querySelector(`#pane-${r}-tabs`),contentEl:c?.contentEl||this.containerEl.querySelector(`#pane-${r}-content`)}}this.centerEl=this.containerEl.querySelector("#pane-center")}_initSplitters(){let n=null;this.containerEl.addEventListener("ide-splitter-start",r=>{let c=r.detail?.for,u=Ihe[c];if(!u)return;let b=(c==="bottom"?this.centerEl||this.containerEl:this.containerEl).getBoundingClientRect(),w=this.panes[c]?.el?.getBoundingClientRect()||{},_=u.dimension==="width"?b.width:b.height,x=u.dimension==="width"?w.width||240:w.height||220;n={paneName:c,cfg:u,startSize:x,maxLimit:Math.round(_*u.maxFraction)||500}}),this.containerEl.addEventListener("ide-splitter-drag",r=>{if(!n||n.paneName!==r.detail?.for)return;let{cfg:c,startSize:u,maxLimit:d}=n,b=c.invertDelta?-r.detail.delta:r.detail.delta,w=Math.round(u+b),_=Math.max(c.minSize,Math.min(d,w));this.containerEl.style.setProperty(c.cssVar,`${_}px`),this.notifyResize()}),this.containerEl.addEventListener("ide-splitter-end",()=>{n=null,this.saveLayout(),this.notifyResize()}),this.containerEl.addEventListener("ide-splitter-reset",r=>{let c=r.detail?.for;this._resetSplitterPane(c)}),this._setupFallbackSplitters()}_resetSplitterPane(n){let r=Ihe[n];r&&(this.containerEl.style.setProperty(r.cssVar,r.defaultSize),this.isPaneCollapsed(n)?this.restorePane(n):(this.saveLayout(),this.notifyResize()))}_setupFallbackSplitters(){for(let[n,r]of Object.entries(Ihe)){let c=this.containerEl.querySelector(`#splitter-${n}`);if(!c||c instanceof Dhe)continue;let u=!r.invertDelta,d=r.isVertical;c.addEventListener("pointerdown",b=>{b.preventDefault();try{c.setPointerCapture(b.pointerId)}catch{}c.classList.add("dragging"),document.body&&document.body.classList.add("is-resizing",d?"is-resizing-v":"is-resizing-h");let w=d?b.clientX:b.clientY,x=(n==="bottom"?this.centerEl||this.containerEl:this.containerEl).getBoundingClientRect(),T=this.panes[n]?.el?.getBoundingClientRect()||{},M=r.dimension==="width"?T.width||240:T.height||220,L=r.dimension==="width"?x.width:x.height,I=Math.round(L*r.maxFraction)||500,D=new AbortController,{signal:F}=D,O=Z=>{let H=d?Z.clientX:Z.clientY,te=u?H-w:w-H,se=Math.round(M+te),ne=Math.max(r.minSize,Math.min(I,se));this.containerEl.style.setProperty(r.cssVar,`${ne}px`),this.notifyResize()},z=Z=>{try{c.releasePointerCapture(Z.pointerId)}catch{}c.classList.remove("dragging"),document.body&&document.body.classList.remove("is-resizing","is-resizing-v","is-resizing-h"),D.abort(),this.saveLayout(),this.notifyResize()};window.addEventListener("pointermove",O,{signal:F}),window.addEventListener("pointerup",z,{signal:F}),window.addEventListener("pointercancel",z,{signal:F})}),c.addEventListener("dblclick",()=>{this._resetSplitterPane(n)})}}_initControls(){this.containerEl.addEventListener("ide-pane-maximize",r=>{this.toggleMaximize(r.detail?.pane)}),this.containerEl.addEventListener("ide-pane-collapse",r=>{this.toggleCollapse(r.detail?.pane)}),this.containerEl.addEventListener("ide-layout-reset",()=>{this.resetLayout()});for(let r of["left","right","bottom"]){let c=this.containerEl.querySelector(`#gutter-expand-${r}`);c&&c.addEventListener("click",()=>this.restorePane(r))}let n=[{sel:"#btn-collapse-left",handler:()=>this.toggleCollapse("left")},{sel:"#btn-collapse-right",handler:()=>this.toggleCollapse("right")},{sel:"#btn-collapse-bottom",handler:()=>this.toggleCollapse("bottom")},{sel:"#btn-maximize-main",handler:()=>this.toggleMaximize("main")},{sel:"#btn-maximize-bottom",handler:()=>this.toggleMaximize("bottom")},{sel:"#btn-maximize-right",handler:()=>this.toggleMaximize("right")},{sel:"#btn-empty-reset-layout",handler:()=>this.resetLayout()}];for(let{sel:r,handler:c}of n){let u=this.containerEl.querySelector(r);u&&!u.closest("ide-pane")&&u.addEventListener("click",c)}}isPaneMaximized(n){return n?this.containerEl.classList.contains(`maximized-${n}`):this.containerEl.classList.contains("maximized-main")||this.containerEl.classList.contains("maximized-bottom")||this.containerEl.classList.contains("maximized-right")}setMaximizedPane(n,r=!0){let c=["main","bottom","right"];if(n&&!c.includes(n))return!1;let u=r?n:null;for(let d of c){let b=d===u;this.containerEl.classList.toggle(`maximized-${d}`,b),this.panes[d]?.paneComponent?.setMaximized(b);let w=this.containerEl.querySelector(`#btn-maximize-${d}`);w&&(w.textContent=b?"\u29C9":"\u2922",w.title=b?"Restore":"Maximize")}return this.notifyResize(),!!u}maximizePane(n){return this.setMaximizedPane(n,!0)}restoreMaximized(){return this.setMaximizedPane(null,!1)}toggleMaximize(n){return this.setMaximizedPane(n,!this.isPaneMaximized(n))}isPaneCollapsed(n){let r=n==="bottom"?this.centerEl:this.containerEl;return r?r.classList.contains(`hide-${n}`):!1}_setPaneCollapsed(n,r){let c=n==="bottom"?this.centerEl:this.containerEl;if(!c)return;c.classList.toggle(`hide-${n}`,r),this.panes[n]?.paneComponent?.setCollapsed?.(r);let u=this.containerEl.querySelector(`#btn-collapse-${n}`);if(u){let b={bottom:{collapsed:"\u25B2",expanded:"\u25BC"},left:{collapsed:"\u25B6",expanded:"\u25C0"},right:{collapsed:"\u25C0",expanded:"\u25B6"}}[n]||{collapsed:"\u25B6",expanded:"\u25C0"};u.textContent=r?b.collapsed:b.expanded,u.title=r?`Expand ${n.charAt(0).toUpperCase()+n.slice(1)}`:`Collapse ${n.charAt(0).toUpperCase()+n.slice(1)}`}this.saveLayout(),this.notifyResize()}toggleCollapse(n){this._setPaneCollapsed(n,!this.isPaneCollapsed(n))}collapsePane(n){this._setPaneCollapsed(n,!0)}restorePane(n){this._setPaneCollapsed(n,!1)}_updateEmptyState(){let n=this.containerEl.querySelector("#ide-empty-state");if(!n)return;let r=!!this.activeTabs.main;n.style.display=r?"none":"flex"}resetLayout(){try{localStorage.removeItem("or_ide_layout")}catch{}for(let[n,r]of Object.entries(Ihe))this.containerEl.style.setProperty(r.cssVar,r.defaultSize);for(let n of["left","right","bottom"])this.restorePane(n);this.restoreMaximized(),this.closedComponents.clear();for(let n of this.components.values())n.tabEl.style.display="",n.contentDiv.style.display="";this.components.has("DisplayControls")&&this.activateTab("DisplayControls"),this.components.has("LayoutViewer")&&this.activateTab("LayoutViewer"),this.components.has("TclConsole")&&this.activateTab("TclConsole"),this.components.has("Inspector")&&this.activateTab("Inspector"),this._updateEmptyState(),this.saveLayout(),this.notifyResize(),this.emit("stateChanged"),typeof app<"u"&&app.map&&setTimeout(()=>app.map.invalidateSize({animate:!1}),0)}_initResizeObserver(){typeof ResizeObserver<"u"&&new ResizeObserver(()=>{this.notifyResize()}).observe(this.containerEl)}registerComponentFactoryFunction(n,r){this.factories.set(n,r)}loadLayout(n){for(let[c,u]of Object.entries(oxt)){let d=this.factories.get(c);d&&this._mountComponent(c,u.pane,u.title,u.closable,d)}let r=null;try{let c=localStorage.getItem("or_ide_layout");c&&(r=JSON.parse(c))}catch{}if(r){if(r.leftWidth&&this.containerEl.style.setProperty("--pane-left-width",`${r.leftWidth}px`),r.rightWidth&&this.containerEl.style.setProperty("--pane-right-width",`${r.rightWidth}px`),r.bottomHeight&&this.containerEl.style.setProperty("--pane-bottom-height",`${r.bottomHeight}px`),r.closed)for(let c of r.closed)this.closeComponent(c,!1);this.activateTab(r.activeTabs?.left||"DisplayControls"),this.activateTab(r.activeTabs?.main||"LayoutViewer"),this.activateTab(r.activeTabs?.bottom||"TclConsole"),this.activateTab(r.activeTabs?.right||"Inspector"),r.hideLeft&&this.collapsePane("left"),r.hideRight&&this.collapsePane("right"),r.hideBottom&&this.collapsePane("bottom")}else this.activateTab("DisplayControls"),this.activateTab("LayoutViewer"),this.activateTab("TclConsole"),this.activateTab("Inspector");this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}_mountComponent(n,r,c,u,d){if(this.components.has(n))return;let b=this.panes[r];if(!b)return;let w=document.createElement("div");w.className="ide-component-container",w.id=`cmp-${n}`,b.contentEl.appendChild(w);let _=document.createElement("ide-tab");_.id=`tab-${n}`,_.setAttribute("for",n),_.setAttribute("data-component",n),_.setAttribute("title",c),u&&_.setAttribute("closable",""),_.addEventListener("tab-select",()=>{this.activateTab(n)}),_.addEventListener("tab-close",()=>{this.closeComponent(n)}),b.tabsEl.appendChild(_);let x=new Map,T={element:w,get width(){return w.clientWidth},get height(){return w.clientHeight},title:c,on:(L,I)=>{x.has(L)||x.set(L,new Set),x.get(L).add(I)},off:(L,I)=>{x.get(L)?.delete(I)},fire:(L,...I)=>{let D=x.get(L);if(D)for(let F of D)try{F(...I)}catch(O){console.error(O)}},focus:()=>this.focusComponent(n),close:()=>this.closeComponent(n)},M={componentType:n,paneName:r,title:c,closable:u,tabEl:_,contentDiv:w,container:T};this.components.set(n,M);try{d(T)}catch(L){console.error(`Failed to initialize component ${n}:`,L)}}isComponentActive(n){return n?!!n.contentDiv?.classList.contains("active"):!1}_setComponentActive(n,r){if(!n)return;let c=!!r;n.tabEl?.setActive(c),n.contentDiv?.classList.toggle("active",c)}activateTab(n){let r=this.components.get(n);if(!r||!this.panes[r.paneName])return;["left","right","bottom"].includes(r.paneName)&&this.isPaneCollapsed(r.paneName)&&this.restorePane(r.paneName);let u=this.activeTabs[r.paneName];if(u&&u!==n){let d=this.components.get(u);d&&(this._setComponentActive(d,!1),d.container.fire("hide"))}this.activeTabs[r.paneName]=n,r.tabEl.style.display="",r.contentDiv.style.display="",this._setComponentActive(r,!0),this.closedComponents.delete(n),r.container.fire("show"),r.container.fire("open"),r.container.fire("resize"),typeof app<"u"&&(n==="LayoutViewer"&&app.map&&setTimeout(()=>app.map.invalidateSize({animate:!1}),0),n==="3DViewer"&&app.threeDViewerWidget&&setTimeout(()=>app.threeDViewerWidget.onOpen(),0));try{r.tabEl.scrollIntoView({behavior:"smooth",inline:"nearest",block:"nearest"})}catch{}this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}closeComponent(n,r=!0){let c=this.components.get(n);if(!(!c||!c.closable)){if(c.tabEl.style.display="none",c.contentDiv.style.display="none",this._setComponentActive(c,!1),c.container.fire("hide"),this.closedComponents.add(n),r&&this.activeTabs[c.paneName]===n){let u=null;for(let d of this.components.values())if(d.paneName===c.paneName&&!this.closedComponents.has(d.componentType)){u=d;break}u?this.activateTab(u.componentType):(this.activeTabs[c.paneName]=null,["left","right","bottom"].includes(c.paneName)&&this.collapsePane(c.paneName))}this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}}focusComponent(n){if(!this.components.get(n)){let c=this.factories.get(n);if(c){let u=oxt[n]||{pane:"right",title:n,closable:!0};this._mountComponent(n,u.pane,u.title,u.closable,c)}else return}this.activateTab(n)}saveLayout(){let n={leftWidth:parseInt(this.containerEl.style.getPropertyValue("--pane-left-width")||"240",10),rightWidth:parseInt(this.containerEl.style.getPropertyValue("--pane-right-width")||"340",10),bottomHeight:parseInt(this.containerEl.style.getPropertyValue("--pane-bottom-height")||"220",10),hideLeft:this.isPaneCollapsed("left"),hideRight:this.isPaneCollapsed("right"),hideBottom:this.isPaneCollapsed("bottom"),activeTabs:{...this.activeTabs},closed:Array.from(this.closedComponents)};try{localStorage.setItem("or_ide_layout",JSON.stringify(n))}catch{}return n}notifyResize(){if(this._resizeScheduled)return;this._resizeScheduled=!0,(typeof requestAnimationFrame=="function"?requestAnimationFrame:r=>{r()})(()=>{this._resizeScheduled=!1;for(let r of this.components.values())this.isComponentActive(r)&&r.container.fire("resize");typeof app<"u"&&app&&app.map&&app.map.invalidateSize({animate:!1}),window.dispatchEvent(new Event("resize"))})}updateSize(){this.notifyResize()}setSize(n,r){this.notifyResize()}addComponent(n,r,c){this.focusComponent(n)}get rootItem(){return{contentItems:Array.from(this.components.keys()).map(n=>({isComponent:!0,componentType:n,focus:()=>this.focusComponent(n)}))}}};function Av(s,n,r,c=0,u=0){return[(s-c)*r,(n-u)*r]}function Pv(s,n,r,c=0,u=0){return{dbuX:Math.round(c+s/r),dbuY:Math.round(u+n/r)}}function X1(s,n,r,c,u,d=0,b=0){let[w,_]=Av(s,n,u,d,b),[x,T]=Av(r,c,u,d,b);return[Math.min(w,x),Math.min(_,T),Math.max(w,x),Math.max(_,T)]}var ZW=class s{constructor(n,r){this.url=n,this.socket=null,this.nextId=1,this.pending=new Map,this._queue=new Map,this._bgQueue=new Map,this._bgSent=new Set,this._inFlight=0,this._inFlightIds=new Set,this._unknownPayloadTypes=new Set,this._maxInFlight=48,this._lastRecvAt=0,this._bufStuckSince=0,this._lastBuffered=0,this.reconnectDelay=1e3,this.readyPromise=null,this.readyResolve=null,this.onStatusChange=r||(()=>{}),this.onPush=null,this._cache=null,this._isConnected=!1,this._shutdown=!1,this._livenessTimer=void 0,this._startLivenessMonitor(),this.connect()}get isConnected(){return this._isConnected||this.socket&&this.socket.readyState===WebSocket.OPEN}get pendingCount(){return this.pending.size-this._bgSent.size+(this._queue?this._queue.size:0)}static fromCache(n,r){let c=Object.create(s.prototype);return c.url=null,c.socket=null,c.nextId=1,c.pending=new Map,c._queue=new Map,c._bgQueue=new Map,c._bgSent=new Set,c._inFlight=0,c._inFlightIds=new Set,c._unknownPayloadTypes=new Set,c._maxInFlight=48,c._lastRecvAt=0,c.reconnectDelay=0,c.onStatusChange=r||(()=>{}),c.onPush=null,c._cache=n,c._isConnected=!0,c.readyPromise=Promise.resolve(),c.readyResolve=null,c}get isStaticMode(){return!!this._cache}connect(){this.readyPromise=new Promise(n=>{this.readyResolve=n}),this.socket=new WebSocket(this.url),this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{console.log("WebSocket connected");let n=this._everConnected===!0;this._everConnected=!0,this._isConnected=!0,this.reconnectDelay=1e3,this._lastRecvAt=typeof performance<"u"?performance.now():0,this.readyResolve(),this.onStatusChange(),this._pump(),n&&this.onReconnected&&this.onReconnected()},this.socket.onmessage=n=>{this.handleMessage(n.data)},this.socket.onclose=()=>this._handleClose(),this.socket.onerror=n=>{console.error("WebSocket error:",n)}}_handleClose(){this._isConnected=!1,this._inFlight=0,this._inFlightIds.clear(),this._bufStuckSince=0,this.onStatusChange();for(let[n,r]of this.pending)r.reject(new Error("WebSocket closed"));this.pending.clear(),this._bgSent.clear();for(let n of[this._queue,this._bgQueue]){for(let[r,c]of n)c.reject(new Error("WebSocket closed"));n.clear()}if(this._shutdown){console.log("WebSocket closed (server stopped)"),this._stopLivenessMonitor();return}console.log("WebSocket closed, reconnecting..."),setTimeout(()=>this.connect(),this.reconnectDelay),this.reconnectDelay=Math.min(this.reconnectDelay*2,3e4)}_forceReconnect(){let n=this.socket;if(this.socket=null,n){n.onopen=null,n.onmessage=null,n.onclose=null,n.onerror=null;try{n.close()}catch{}}this._handleClose()}handleMessage(n){let r=new DataView(n),c=r.getUint32(0),u=r.getUint8(4);if(this._lastRecvAt=typeof performance<"u"?performance.now():0,c===0&&u===0){let w=n.slice(8),_;try{_=JSON.parse(new TextDecoder().decode(w))}catch(x){console.error("Failed to parse server push JSON:",x);return}if(_&&_.type==="config"){Number.isFinite(_.max_in_flight)&&(this._maxInFlight=Math.max(1,Math.min(4096,Math.floor(_.max_in_flight))),this._pump());return}this.onPush&&this.onPush(_);return}this._inFlightIds.delete(c)&&this._inFlight>0&&this._inFlight--;let d=this.pending.get(c);if(!d){this._pump();return}this.pending.delete(c),this._bgSent.delete(c),this._pump(),this.onStatusChange();let b=n.slice(8);if(u===2)d.reject(new Error(new TextDecoder().decode(b)));else if(u===0)try{d.resolve(JSON.parse(new TextDecoder().decode(b)))}catch(w){d.reject(new Error("JSON parse error: "+w.message))}else u===1?d.resolve(new Blob([b],{type:"image/png"})):u===3?d.resolve(null):(this._unknownPayloadTypes.has(u)||(this._unknownPayloadTypes.add(u),console.warn(`Unrecognized websocket payload type ${u}. The server is likely newer than this page \u2014 reload to pick up the current client.`)),d.reject(new Error(`Unsupported websocket payload type ${u}`)))}request(n,{background:r=!1}={}){if(this._cache)return this._cacheRequest(n);let c=this.nextId++;if(n.id=c,!this.socket||this.socket.readyState!==WebSocket.OPEN)return Promise.reject(new Error("WebSocket not connected"));let u,d,b=new Promise((w,_)=>{u=w,d=_});return b.requestId=c,(r?this._bgQueue:this._queue).set(c,{msg:n,resolve:u,reject:d}),this._pump(),b}_pump(){if(!(!this.socket||this.socket.readyState!==WebSocket.OPEN)){for(;this._inFlight0||this._bgQueue.size>0)&&this.socket.bufferedAmount<524288;){let n=this._queue.size===0,r=n?this._bgQueue:this._queue,[c,u]=r.entries().next().value;r.delete(c),this.pending.set(c,{resolve:u.resolve,reject:u.reject}),n&&this._bgSent.add(c),this.socket.send(JSON.stringify(u.msg)),this._inFlightIds.add(c),this._inFlight++}this.onStatusChange()}}promote(n){let r=this._bgQueue.get(n);r?(this._bgQueue.delete(n),this._queue.set(n,r),this._pump()):this._bgSent.delete(n)&&this.onStatusChange()}cancel(n){let r=this._queue.get(n)||this._bgQueue.get(n);if(r){this._queue.delete(n),this._bgQueue.delete(n),r.reject(new Error("Request cancelled")),this.onStatusChange();return}let c=this.pending.get(n),u=this.pending.delete(n);this._bgSent.delete(n),c&&c.reject(new Error("Request cancelled")),u&&!this._cache&&this.socket&&this.socket.readyState===WebSocket.OPEN&&this.socket.send(JSON.stringify({type:"cancel",cancel_id:n,id:this.nextId++})),this.onStatusChange()}_startLivenessMonitor(){typeof setInterval>"u"||(this._livenessTimer=setInterval(()=>this._checkLiveness(),3e3),this._livenessTimer&&typeof this._livenessTimer.unref=="function"&&this._livenessTimer.unref())}_stopLivenessMonitor(){this._livenessTimer!==void 0&&typeof clearInterval<"u"&&(clearInterval(this._livenessTimer),this._livenessTimer=void 0)}_checkLiveness(){if(this._cache)return;let n=this.socket;if(!n||n.readyState!==WebSocket.OPEN){this._bufStuckSince=0,this._lastBuffered=0;return}let r=n.bufferedAmount,c=typeof performance<"u"?performance.now():0,u=!1,d="";r<=262144||r12e3&&(u=!0,d=`send buffer stuck at ${r}B for ${Math.round(c-this._bufStuckSince)}ms`),this._lastBuffered=r,!u&&this._inFlight>=this._maxInFlight&&this._queue.size+this._bgQueue.size>0&&this._lastRecvAt>0&&c-this._lastRecvAt>3e4&&(u=!0,d=`saturated (${this._inFlight} in flight, ${this._queue.size} queued) but silent for ${Math.round(c-this._lastRecvAt)}ms`),u&&(console.warn(`WebSocket connection wedged \u2014 ${d}; reconnecting to recover`),this._bufStuckSince=0,this._forceReconnect())}_cacheRequest(n){let r=n.type;if(r==="tile"){let d=n.layer+"/"+n.z+"/"+n.x+"/"+n.y,b=this._cache.tiles&&this._cache.tiles[d];return b?Promise.resolve("data:image/png;base64,"+b):Promise.reject(new Error("Tile not cached: "+d))}if(r==="timing_highlight"){let d=n.path_index;if(d>=0&&this._cache.overlays){let b=n.is_setup?"setup":"hold",w=this._cache.overlays[b]?.[d];this._cache.setPathOverlay&&this._cache.setPathOverlay(w?"data:image/png;base64,"+w:null)}else this._cache.setPathOverlay&&this._cache.setPathOverlay(null);return Promise.resolve({})}if(r==="set_module_colors")return Promise.resolve({ok:1,count:0});let c=r;r==="timing_report"?c="timing_report:"+(n.is_setup?"setup":"hold"):r==="slack_histogram"&&(c="slack_histogram:"+(n.is_setup?"setup":"hold"));let u=this._cache.json&&this._cache.json[c];if(u!==void 0){if(r==="timing_report"&&n.slack_min!=null&&n.slack_max!=null&&u.paths){let d=[];return u.paths.forEach((b,w)=>{b.slack>=n.slack_min&&b.slackb||w>_?null:{z:n,x0:d,x1:b,y0:w,y1:_}}function R5e([s,n,r,c],u){let d=(r-s)*u,b=(c-n)*u;return[s-d,n-b,r+d,c+b]}function Fhe(s,n=1){if(!s)return null;let r=Math.pow(2,s.z);return{z:s.z,x0:Math.max(0,s.x0-n),x1:Math.min(r-1,s.x1+n),y0:Math.max(0,s.y0-n),y1:Math.min(r-1,s.y1+n)}}function Am(s,n,r){return!!s&&n>=s.x0&&n<=s.x1&&r>=s.y0&&r<=s.y1}function JW(s){if(!s)return[];let n=(s.x0+s.x1)/2,r=(s.y0+s.y1)/2,c=[];for(let u=s.y0;u<=s.y1;u++)for(let d=s.x0;d<=s.x1;d++)c.push({z:s.z,x:d,y:u,d:(d-n)**2+(u-r)**2});return c.sort((u,d)=>u.d-d.d),c.map(({z:u,x:d,y:b})=>({z:u,x:d,y:b}))}function cxt(s,n,r,c){let u=c/Math.pow(2,s);return[n*u,c-(r+1)*u,(n+1)*u,c-r*u]}function I5e(s,n){return s[0]Math.log2(d/ue);if(D<1e-12){let ue=Math.log(M/T)/r;return{S:Math.abs(ue),at:Ce=>({target:[b+Ce*L,w+Ce*I],zoom:F(T*Math.exp(r*Ce*ue))})}}let O=Math.sqrt(D),z=(M*M-T*T+u*D)/(2*T*c*O),Z=(M*M-T*T-u*D)/(2*M*c*O),H=Math.log(Math.sqrt(z*z+1)-z),se=(Math.log(Math.sqrt(Z*Z+1)-Z)-H)/r,ne=Math.cosh(H);return{S:se,at:ue=>{if(ue>=1)return{target:[_,x],zoom:n.zoom};let Ce=ue*se,Q=T/(c*O)*(ne*Math.tanh(r*Ce+H)-Math.sinh(H));return{target:[b+Q*L,w+Q*I],zoom:F(T*ne/Math.cosh(r*Ce+H))}}}}function yO(s,n,r){return`${s}/${n}/${r}`}var Uhe=class{constructor({source:n,onChange:r=()=>{},keepBuffer:c=2}={}){this.source=n,this.onChange=r,this.keepBuffer=c,this.tiles=new Map,this.z=null,this.range=null,this.ring=null,this.extra=[],this._generation=0,this._loads=0,this._cancels=0}update({z:n,range:r,ring:c=r,extra:u=[],hold:d=null}){this.z=n,this.range=r,this.ring=c,this.extra=u.filter(_=>_.z!==n&&_.range);let b=new Map(this.extra.map(_=>[_.z,_]));for(let _ of[...this.tiles.values()]){if(_.z!==n){let x=b.get(_.z),T=x&&x.range;(T?!Am(T,_.x,_.y)&&(_.loading||!this._inKeepBuffer(_,T)):_.loading&&!_.drawable)?this._drop(_):T&&this._stale(_)&&Am(T,_.x,_.y)&&this._load(_,x.background!==!1);continue}if(this._stale(_)&&Am(c,_.x,_.y)&&this._load(_,!Am(r,_.x,_.y)),Am(c,_.x,_.y)){_.loading&&_.background&&Am(r,_.x,_.y)&&(_.background=!1,_.handle?.promote?.());continue}(_.loading||!(this._inKeepBuffer(_)||d&&Am(d,_.x,_.y)))&&this._drop(_)}let w=[...JW(r),...JW(c).filter(_=>!Am(r,_.x,_.y))];for(let{x:_,y:x}of w)this.tiles.has(yO(n,_,x))||this._load(this._newTile(n,_,x),!Am(r,_,x));for(let _ of this.extra)for(let{x,y:T}of JW(_.range))this.tiles.has(yO(_.z,x,T))||this._load(this._newTile(_.z,x,T),_.background!==!1)}refresh(){this._generation++;let n=new Map(this.extra.map(r=>[r.z,r]));for(let r of[...this.tiles.values()]){let c=n.get(r.z),u=r.z===this.z?this.ring:c&&c.range;u&&(Am(u,r.x,r.y)?(r.handle?.cancel?.(),this._load(r,c?c.background!==!1:!Am(this.range,r.x,r.y))):r.loading&&this._drop(r))}}isSettled(){for(let n of this.tiles.values())if(n.z===this.z&&n.loading&&Am(this.range,n.x,n.y))return!1;return!0}settledIn(n,r){for(let{x:c,y:u}of JW(r)){let d=this.tiles.get(yO(n,c,u));if(!d||d.loading)return!1}return!0}hasContentAt(n){for(let r of this.tiles.values())if(r.z===n&&r.drawable)return!0;return!1}drawableTilesAt(n){let r=[];for(let c of this.tiles.values())c.z===n&&c.drawable&&r.push(c);return r}prune(n){let r=new Set(n);for(let c of[...this.tiles.values()])r.has(c.z)||this._drop(c)}clear(){for(let n of[...this.tiles.values()])this._drop(n);this.z=null,this.range=null,this.ring=null,this.extra=[]}stats(){let n=0,r=0;for(let c of this.tiles.values())c.loading&&n++,c.drawable&&r++;return{tiles:this.tiles.size,loading:n,drawable:r,loads:this._loads,cancels:this._cancels}}_newTile(n,r,c){let u={z:n,x:r,y:c,key:yO(n,r,c),drawable:null,loading:!1,background:!1,handle:null,generation:-1};return this.tiles.set(u.key,u),u}_load(n,r){let c=this._generation,u=()=>this.tiles.get(n.key)===n&&n.generation===c;n.generation=c,n.loading=!0,n.background=r,this._loads++;let d=this.source.load({z:n.z,x:n.x,y:n.y},{background:r,onPartial:b=>{if(!u()){this.source.release?.(b);return}this._setDrawable(n,b),this.onChange(n)}});n.handle=d,d.promise.then(b=>{if(!u()){this.source.release?.(b);return}b!==void 0&&this._setDrawable(n,b),n.loading=!1,n.handle=null,this.onChange(n)},()=>{u()&&(n.loading=!1,n.handle=null,this.onChange(n))})}_setDrawable(n,r){n.drawable&&n.drawable!==r&&this.source.release?.(n.drawable),n.drawable=r||null}_stale(n){return!n.loading&&n.generation!==this._generation}_inKeepBuffer(n,r=this.range){return Am(Fhe(r,this.keepBuffer),n.x,n.y)}_drop(n){n.loading&&(this._cancels++,n.handle?.cancel?.()),n.drawable&&this.source.release?.(n.drawable),n.drawable=null,n.loading=!1,this.tiles.delete(n.key)}};function Ehn(s){return!Number.isFinite(s)||s<=1?1:Math.round(Math.min(s,3)*100)/100}var nE=240,Shn=256,D5e=nE;function Ob(){return D5e}function fxt(){D5e=Shn}var Zci=1/64,B5e=120;function hxt(s){D5e=s}function O5e(s,n){return Math.max(1,Math.round(s*n))}function xO(){let s=typeof window<"u"&&window.devicePixelRatio?window.devicePixelRatio:1;return!Number.isFinite(s)||s<=1?1:Math.min(s,3)}function zhe(s,n=Ob()){return{dpr:Ehn(s),tile_px:O5e(n,s)}}function dxt(s,n,r,c=Ob()){let{selectability:u,selectableLayers:d,app:b}=n,w={...gxt(s,n,r,c),selectable_layers:d?[...d]:[]};if(u)for(let[_,x]of Object.entries(u))w["s_"+_]=!!x;return _=>{let x={type:"tile",layer:_,...w},T=mxt(b,_);return T!==1&&(x.pattern=T),x}}function pxt(s,n,r,c,u=Ob()){let d={type:"tile_group",layers:[...n],...gxt(s,r,c,u)},b=n.map(w=>mxt(r.app,w));return b.some(w=>w!==1)&&(d.patterns=b),d}function gxt(s,n,r,c){let{visibility:u,visibleLayers:d,app:b}=n,w={z:s.z,x:s.x,y:s.y,...zhe(r,c),visible_layers:d?[...d]:[]};for(let[_,x]of Object.entries(u||{}))w[_]=!!x;return b&&b.visibleChiplets instanceof Set&&(w.visible_chiplets=[...b.visibleChiplets]),w}function mxt(s,n){let r=s&&s.layerPatterns?s.layerPatterns[n]:void 0;return r===void 0?1:r}function bxt(s){if(typeof window>"u"||typeof window.matchMedia!="function"||typeof s!="function")return()=>{};let n=!1,r=null,c=null,u=()=>{if(n)return;let d=window.devicePixelRatio||1;r=window.matchMedia(`(resolution: ${d}dppx)`),c=()=>{n||(u(),s(window.devicePixelRatio||1))},r.addEventListener("change",c,{once:!0})};return u(),()=>{n=!0,r&&c&&r.removeEventListener("change",c),r=null,c=null}}function wxt(s,n){if(!s)return!1;let r=!!n;return!!s.visible===r?!1:(s.visible=r,!0)}function vxt(s,n,r){if(!s||!(r>0))return 0;s.clearRect(0,0,r,r);let c=0;for(let u of n||[]){let d=u?u.image:null;if(!d)continue;let b=u.opacity===void 0?1:u.opacity;b>0&&(s.globalAlpha=Math.min(1,b),s.drawImage(d,0,0,r,r),c++)}return s.globalAlpha=1,c}function N5e(s){for(let n of s||[])n&&typeof n.close=="function"&&n.close()}async function _xt({items:s,request:n,decode:r,draw:c,release:u=N5e,isStale:d=()=>!1,incremental:b=!0}={}){let w=Array.isArray(s)?s:[],_={requested:w.length,arrived:0,decoded:0,drawn:0,paints:0,failed:0,stale:!1};if(w.length===0)return typeof c=="function"&&c([]),_;let x=new Array(w.length).fill(null),T=!1;function M(){if(d()){_.stale=!0;return}_.drawn=c(w.map((L,I)=>({image:x[I],opacity:L.opacity})))||0,_.paints++,T=!0}try{await Promise.all(w.map(async(L,I)=>{let D=null;try{D=await n(L)}catch{_.failed++;return}if(D==null)return;_.arrived++;let F=null;try{F=await r(D)}catch{return}F&&(x[I]=F,_.decoded++,b&&M())})),T||M()}finally{u(x)}return _}var Mhn=["tracks_pref","tracks_non_pref","debug","debug_renderers"],Thn=1/16;function F5e(s,n){if(s==null)return!1;if(!Array.isArray(s)||s.length!==4||!n)return!0;let r=Math.pow(2,n.z),c=Thn/r,u=n.x/r-c,d=n.y/r-c,b=(n.x+1)/r+c,w=(n.y+1)/r+c,[_,x,T,M]=s;return _<=b&&T>=u&&x<=w&&M>=d}function Chn(s,n,r){let c=s&&Array.isArray(s.by_size)?s.by_size:[];if(c.length===0||!n||!(r>0))return!0;let u=s.min_css_px/(r*Math.pow(2,n.z)),d=c[0];for(let b of c)b[0]<=u&&(d=b);return F5e(d[1],n)}var Ghe=class{constructor(){this._layers=null,this._gated=new Map,this._sized=new Map,this._generation=0}invalidate(){return this._generation++,this._layers=null,this._gated=new Map,this._sized=new Map,this._generation}apply(n,r){if(n!==this._generation)return!1;if(!r||r.supported!==!0||!r.layers||typeof r.layers!="object")return this._layers=null,!1;let c=new Map;if(r.gated&&typeof r.gated=="object")for(let[u,d]of Object.entries(r.gated))d&&typeof d=="object"&&c.set(u,new Map(Object.entries(d)));return this._layers=new Map(Object.entries(r.layers)),this._gated=c,this._sized=new Map(r.sized&&typeof r.sized=="object"?Object.entries(r.sized):[]),!0}refetch(n){let r=this.invalidate();return Promise.resolve().then(()=>n({type:"layer_extents"})).then(c=>this.apply(r,c)).catch(()=>!1)}mayHaveContent(n,r,c,u=256){if(!this._layers||c&&Mhn.some(d=>c[d]))return!0;if(this._sized.has(n))return Chn(this._sized.get(n),r,u);if(!this._layers.has(n)||F5e(this._layers.get(n),r))return!0;for(let[d,b]of this._gated)if(!(c&&c[d]===!1)&&b.has(n)&&F5e(b.get(n),r))return!0;return!1}};function yxt(s,n,r){let c=s&&s.app&&s.app.layerExtents;return c?c.mayHaveContent(n,r,s.visibility,Ob()):!0}function xxt(s){return s==null?Promise.resolve(null):typeof s=="string"?new Promise(n=>{let r=document.createElement("img");r.onload=()=>n(r),r.onerror=()=>n(null),r.src=s}):createImageBitmap(s,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).catch(()=>null)}function U5e(s){N5e([s&&s.image])}function Ahn(s){return{width:s.naturalWidth||s.width,height:s.naturalHeight||s.height}}function jhe(s){return s?{image:s,...Ahn(s)}:null}function Phn(s){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(s,s);let n=document.createElement("canvas");return n.width=s,n.height=s,n}function z5e(s){let n=document.createElement("canvas");return n.width=s.width,n.height=s.height,n.getContext("2d").drawImage(s,0,0),n}function Lhn(s){return typeof s.transferToImageBitmap=="function"?jhe(s.transferToImageBitmap()):jhe(z5e(s))}var Ext=Object.freeze({promise:Promise.resolve(null),cancel(){},promote(){}});function Sxt(s,n,r,c){let u=s.request(r,{background:c});return u.requestId!=null&&n.push(u.requestId),u}function Mxt(s,n,r,c){return{promise:r,cancel(){c();for(let u of n)s.cancel(u)},promote(){for(let u of n)s.promote?.(u)}}}var Txt=3;function khn(s,n){let r=new Map,c=0,u=0;for(let d of s)if(!(!d||r.has(d.layer))){if(d.layer.startsWith("_")){r.set(d.layer,null),c++,u=0;continue}r.set(d.layer,`${c}:${Math.floor(u++/n)}`)}return r}function Rhn(s,n,r,c,u,d,b,w){let _=khn(s,r),x=[],T=null,M=()=>{T&&(x.push({opacity:1,msg:pxt(u,T.layers,d,b,w)}),T=null)};for(let L of n){let I=_.get(L.layer);if(I==null){M(),x.push({opacity:1,msg:c(L.layer)});continue}T&&T.id!==I&&M(),T=T||{id:I,layers:[]},T.layers.push(L.layer)}return M(),x}function Cxt({wm:s,ctx:n,getItems:r,dpr:c=()=>1,tileSize:u=()=>240,isDoubleBuffer:d=()=>!0,decode:b=xxt,makeCanvas:w=Phn,snapshot:_=Lhn,groupLayers:x=()=>0}){return{load({z:T,x:M,y:L},{background:I=!1,onPartial:D}={}){let F=r()||[],O=F.filter(Qe=>Qe&&Qe.visible!==!1&&yxt(n,Qe.layer,{z:T,x:M,y:L})),z=c(),Z=u(),H=new Set,te=O.filter(Qe=>!H.has(Qe.layer)&&H.add(Qe.layer));if(te.length===0)return Ext;let se=dxt({z:T,x:M,y:L},n,z,Z),ne=x(),ue=ne>0&&te.every(Qe=>(Qe.opacity??1)===1)?Rhn(F,te,ne,se,{z:T,x:M,y:L},n,z,Z):te.map(Qe=>({opacity:Qe.opacity,msg:se(Qe.layer)})),Ce=O5e(Z,z),Q=null,me=null,tt=[],st=!1,at=!d()&&typeof D=="function",Ne=_xt({items:ue,request:Qe=>Sxt(s,tt,Qe.msg,I),decode:b,draw:Qe=>{if(!Q){if(!Qe.some(xt=>xt.image))return 0;Q=w(Ce),me=Q.getContext("2d")}let ot=vxt(me,Qe,Ce);return at&&ot>0&&!st&&D(_(Q)),ot},isStale:()=>st,incremental:at}).then(Qe=>{if(st)throw new Error("Tile cancelled");if(Qe.failed===Qe.requested)throw new Error("Tile requests failed");return Qe.drawn===0?null:at?void 0:_(Q)});return Mxt(s,tt,Ne,()=>{st=!0})},release:U5e}}function G5e({wm:s,buildRequest:n,dpr:r=()=>1,tileSize:c=()=>240,decode:u=xxt}){return{load({z:d,x:b,y:w},{background:_=!1}={}){let x=n({z:d,x:b,y:w},r(),c());if(!x)return Ext;let T=[],M=!1,L=Sxt(s,T,x,_).then(I=>u(I)).then(I=>{if(M)throw U5e(jhe(I)),new Error("Tile cancelled");return jhe(I)});return Mxt(s,T,L,()=>{M=!0})},release:U5e}}function Axt({z:s,x:n,y:r},c,u,d,b){let w={type:"overlay_tile",z:s,x:n,y:r,...zhe(c,u),debug_renderers:!!d.debug_renderers,debug_live:!!d.debug_live,flywires_only:!!d.flywires_only,poly_decomp:!!(b&&b.polyDecomp),focused_nets_guides:!!d.focused_nets_guides,highlight_selected:d.highlight_selected!==!1,draw_labels:d.labels!==!1};return b&&b.visibleLayerNames&&(w.visible_layers=[...b.visibleLayerNames]),w}function Pxt({z:s,x:n,y:r},c,u,d){let b=d&&d.activeHeatMap;return b?{type:"heatmap_tile",name:b,z:s,x:n,y:r,...zhe(c,u)}:null}function la(s){return!!s?.websocketManager?.isStaticMode}function Ixt(s,n){let r={};for(let[c,u]of Object.entries(s||{}))r[c]=!!u;for(let[c,u]of Object.entries(n||{}))r["s_"+c]=!!u;return r}function EO(s,n){n&&typeof n.sel_has_inst=="boolean"&&(s.selHasInst=n.sel_has_inst,s.selHasNet=!!n.sel_has_net)}var j5e=null;function Nb(s,n=4e3){let r=document.getElementById("or-toast");return r||(r=document.createElement("div"),r.id="or-toast",document.body.appendChild(r)),r.textContent=s,r.classList.add("visible"),j5e&&clearTimeout(j5e),j5e=setTimeout(()=>r.classList.remove("visible"),n),r}function Dxt({title:s,message:n,confirmLabel:r="OK",danger:c=!1}){return new Promise(u=>{let d=document.createElement("div");d.className="or-modal-overlay";let b=document.createElement("div");b.className="or-modal";let w=document.createElement("div");w.className="or-modal-title",w.textContent=s;let _=document.createElement("div");_.className="or-modal-message",_.textContent=n;let x=document.createElement("div");x.className="or-modal-buttons";let T=document.createElement("button");T.className="or-btn",T.textContent="Cancel";let M=document.createElement("button");M.className="or-btn"+(c?" or-btn-danger":""),M.textContent=r;let L=D=>{document.removeEventListener("keydown",I,!0),d.remove(),u(D)},I=D=>{D.key==="Escape"&&(D.stopPropagation(),L(!1))};T.addEventListener("click",()=>L(!1)),M.addEventListener("click",()=>L(!0)),d.addEventListener("click",D=>{D.target===d&&L(!1)}),document.addEventListener("keydown",I,!0),x.appendChild(T),x.appendChild(M),b.appendChild(w),b.appendChild(_),b.appendChild(x),d.appendChild(b),document.body.appendChild(d),T.focus()})}var Ihn=.05;function Dhn([[s,n],[r,c]],u){let d=(c-n)*u,b=(r-s)*u;return[[s-b,n-d],[r+b,c+d]]}function $5e(s,n=256,r=null){if(!Lxt(s))return null;let c=s[0][0],u=s[0][1],d=Math.max(s[1][1]-u,s[1][0]-c),b=n/d,w=Lxt(r)?r:s,[[_,x],[T,M]]=Dhn(w,Ihn);return{scale:b,maxDXDY:d,originX:u,originY:c,fitRect:X1(x,_,M,T,b,u,c)}}function Lxt(s){return!!s&&s[1][0]>s[0][0]&&s[1][1]>s[0][1]}function Bxt(s,n){return!!s&&!!n&&s[0][0]===n[0][0]&&s[0][1]===n[0][1]&&s[1][0]===n[1][0]&&s[1][1]===n[1][1]}function Pm(s){s.selectionToken=(s.selectionToken||0)+1;for(let n of s.selectionResetters||[])n();return s.selectionToken}function Y1(s,n){return s.selectionToken===n}function Oxt(s,n){s.selectionResetters||(s.selectionResetters=[]),s.selectionResetters.push(n)}var V5e=80,QW=10,eH=1e3;function tH(s){let n=s===""||s===null?NaN:Math.round(Number(s));return Number.isFinite(n)?Math.min(eH,Math.max(QW,n)):V5e}function sk(s="vis-group-header"){let n=document.createElement("div");n.className=s;let r=document.createElement("span");r.className="vis-arrow",n.appendChild(r);let c=document.createElement("span");return c.className="vis-name",n.appendChild(c),{header:n,arrow:r,name:c}}function ok(s,n,r,c){let u=d=>{r.classList.toggle("collapsed",d),n.textContent=d?"\u25B6":"\u25BC"};u(!!c),s.addEventListener("click",d=>{let b=d.target&&d.target.parentNode===s&&d.target.classList&&d.target.classList.contains("vis-name");d.target!==s&&d.target!==n&&!b||u(!r.classList.contains("collapsed"))})}var kxt=30;function Nxt(s,n=8){if(!Number.isFinite(s)||s<=0)return kxt;let r=Math.ceil(Math.log2(n/s));return Math.max(1,Math.min(kxt,r))}function Fxt({designBounds:s,fitRect:n,viewW:r,viewH:c}){let u=$5e(s,nE,n),d=I=>Number.isFinite(I)&&I>0;if(!u||!d(r)||!d(c))return nE;let b=u.fitRect[2]-u.fitRect[0],w=u.fitRect[3]-u.fitRect[1],_=Math.min(r/b,c/w),x=Math.log2(_);if(!Number.isFinite(x)||x<0)return nE;let T=Math.floor(x),M=nE*2**(x-T),L=Math.floor(M/B5e)*B5e;return L>nE&&Math.log2(nE*_/L)>=T?L:nE}function Uxt(s,{showDbu:n,dbuPerMicron:r},c=!1){if(n)return String(Math.round(s));let u=r>0?r:1e3,d=Math.ceil(Math.log10(u)),b=(s/u).toFixed(d);return c?b+" \xB5m":b}function zxt(s,{showDbu:n,dbuPerMicron:r}){let c=parseFloat(s);if(!Number.isFinite(c))return null;if(n)return Math.round(c);let u=r>0?r:1e3;return Math.round(c*u)}function Gxt(s,{showDbu:n,dbuPerMicron:r}){if(n)return String(Math.round(s));let c=r>0?r:1e3,u=s/c;return u>=1e3?(u/1e3).toFixed(3)+" mm":u>=1?u.toFixed(3)+" um":(u*1e3).toFixed(1)+" nm"}function jxt({showDbu:s}){return s?"DBU":"\xB5m"}function SO(s){return typeof s=="string"&&/^#[0-9a-fA-F]{6}$/.test(s)}function $xt(s){if(typeof s!="string")return null;let n=s.trim();if(SO(n))return n.toLowerCase();let r=n.match(/^#([0-9a-fA-F]{3})$/);if(r)return"#"+r[1].split("").map(u=>u+u).join("").toLowerCase();let c=n.match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/);if(c){let u=c.slice(1).map(Number);return u.some(d=>d>255)?null:"#"+u.map(d=>d.toString(16).padStart(2,"0")).join("")}return null}function _T(s,n=r=>requestAnimationFrame(r)){let r=!1;return()=>{r||(r=!0,n(()=>{r=!1,s()}))}}function nH(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function Rxt(s){let n=Math.pow(10,Math.floor(Math.log10(s))),r=s/n,c;return r<1.5?c=1:r<3.5?c=2:r<7.5?c=5:c=10,{value:c*n,digit:c}}function Vxt({targetPx:s,pxPerDbu:n,dbuPerMicron:r,showDbu:c}){if(!Number.isFinite(n)||n<=0||!Number.isFinite(s)||s<=0)return null;let u,d,b;if(c){let _=Rxt(Math.max(1,s/n));b=_.digit,u=Math.round(_.value*n),d=String(Math.round(_.value))}else{let _=Number.isFinite(r)&&r>0?r:1e3,x=n*_,T=Rxt(s/x);b=T.digit;let M=T.value;u=Math.round(M*x);let L,I;M>=1e3?(L=1/1e3,I="mm"):M>=1?(L=1,I="\xB5m"):M>=.001?(L=1e3,I="nm"):(L=1e6,I="pm"),d=Math.round(M*L)+" "+I}return{barPx:u,label:d,segments:b===1?5:b}}function iH(s,n,r){return n?typeof s.runTclScript=="function"?s.runTclScript(n,r):(r&&typeof s.echoTcl=="function"&&s.echoTcl(n),s.websocketManager.request({type:"tcl_eval",cmd:n}).catch(()=>{})):Promise.resolve()}function ak(s,n){let r=s.querySelectorAll("thead th");(!n||!n[0])&&(s.style.tableLayout="auto",r.forEach(c=>c.style.width=""),n=Array.from(r,c=>c.offsetWidth+"px")),r.forEach((c,u)=>c.style.width=n[u]||""),s.style.tableLayout="fixed",r.forEach((c,u)=>{if(u===r.length-1)return;let d=document.createElement("div");d.className="col-resize-grip",c.style.position="relative",c.appendChild(d);let b,w,_=T=>{c.style.width=Math.max(30,w+T.clientX-b)+"px"},x=()=>{document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",x);let T=M=>M.stopPropagation();document.addEventListener("click",T,{capture:!0,once:!0}),setTimeout(()=>{document.removeEventListener("click",T,{capture:!0})},0)};d.addEventListener("mousedown",T=>{T.preventDefault(),b=T.clientX,w=c.offsetWidth,document.addEventListener("mousemove",_),document.addEventListener("mouseup",x)})})}var Bhn={Layout:'',Schematic:'',"3D Viewer":'',"Display Controls":'',Inspector:'',Hierarchy:'',Timing:'',DRC:'',"Select Highlight":'',"Clock Tree":'',Charts:'',"Tcl Console":'',Help:''};function Ohn(s){let n=Bhn[s];if(!n)return null;let r=document.createElement("span");return r.className="or-tab-icon",r.innerHTML='",r}function Wxt(s=document){let n=0;for(let r of s.querySelectorAll(".lm_tab:not([data-or-icon])")){let c=r.querySelector(".lm_title");if(!c)continue;let u=c.textContent.trim();if(!u)continue;r.setAttribute("data-or-icon","");let d=Ohn(u);d&&(r.insertBefore(d,c),n++)}return n}function MO(s,n,r,c){let u=document.createElement("div");u.className="modal-overlay",u.innerHTML=` + `}};customElements.get("ide-pane")||customElements.define("ide-pane",A5e);customElements.get("ide-splitter")||customElements.define("ide-splitter",Dhe);customElements.get("ide-tab")||customElements.define("ide-tab",L5e);var oxt={DisplayControls:{pane:"left",title:"Display Controls",closable:!1},LayoutViewer:{pane:"main",title:"Layout",closable:!1},SchematicWidget:{pane:"main",title:"Schematic",closable:!0},"3DViewer":{pane:"main",title:"3D Viewer",closable:!0},TclConsole:{pane:"bottom",title:"Tcl Console",closable:!1},Inspector:{pane:"right",title:"Inspector",closable:!0},Browser:{pane:"right",title:"Hierarchy",closable:!0},TimingWidget:{pane:"right",title:"Timing",closable:!0},DRCWidget:{pane:"right",title:"DRC",closable:!0},SelectHighlight:{pane:"right",title:"Select Highlight",closable:!0},ClockWidget:{pane:"right",title:"Clock Tree",closable:!0},ChartsWidget:{pane:"right",title:"Charts",closable:!0},HelpWidget:{pane:"right",title:"Help",closable:!0}},Ihe={left:{cssVar:"--pane-left-width",defaultSize:"240px",minSize:140,maxFraction:.45,dimension:"width",isVertical:!0,invertDelta:!1},right:{cssVar:"--pane-right-width",defaultSize:"340px",minSize:160,maxFraction:.5,dimension:"width",isVertical:!0,invertDelta:!0},bottom:{cssVar:"--pane-bottom-height",defaultSize:"220px",minSize:70,maxFraction:.75,dimension:"height",isVertical:!1,invertDelta:!0}},Bhe=class{constructor(n){this.containerEl=n,this.factories=new Map,this.components=new Map,this.activeTabs={left:null,main:null,bottom:null,right:null},this.closedComponents=new Set,this.eventListeners=new Map,this._resizeScheduled=!1,this._ensureDOM(),this._initSplitters(),this._initControls(),this._initResizeObserver()}on(n,r){this.eventListeners.has(n)||this.eventListeners.set(n,new Set),this.eventListeners.get(n).add(r)}off(n,r){this.eventListeners.get(n)?.delete(r)}emit(n,...r){let c=this.eventListeners.get(n);if(c)for(let u of c)try{u(...r)}catch(d){console.error(d)}}_ensureDOM(){this.containerEl.classList.add("ide-layout"),this.containerEl.querySelector("#pane-left")||this._buildInitialLayoutTree(),this._resolvePaneReferences()}_buildInitialLayoutTree(){this.containerEl.appendChild(this._createGutterButton("left","\u25B6 Display Controls","Restore Display Controls")),this.containerEl.appendChild(this._createGutterButton("right","\u25C0 Tools & Inspector","Restore Right Panel")),this.containerEl.appendChild(this._createPane("pane-left","left")),this.containerEl.appendChild(this._createSplitter("splitter-left","left","vertical","Drag to resize panel"));let n=document.createElement("main");n.id="pane-center",n.className="ide-center",n.appendChild(this._createPane("pane-main","main",{maximizable:!0})),n.appendChild(this._createSplitter("splitter-bottom","bottom","horizontal","Drag to resize console")),n.appendChild(this._createGutterButton("bottom","\u25B2 Tcl Console","Restore Tcl Console")),n.appendChild(this._createPane("pane-bottom","bottom",{maximizable:!0,collapsible:!0})),this.containerEl.appendChild(n),this.containerEl.appendChild(this._createSplitter("splitter-right","right","vertical","Drag to resize panel")),this.containerEl.appendChild(this._createPane("pane-right","right",{maximizable:!0,collapsible:!0}))}_createGutterButton(n,r,c){let u=document.createElement("button");u.id=`gutter-expand-${n}`,u.className=`ide-gutter-expand ide-gutter-${n}`,u.title=c;let d=document.createElement("span");return d.textContent=r,u.appendChild(d),u}_createPane(n,r,c={}){let u=document.createElement("ide-pane");return u.id=n,u.setAttribute("name",r),c.maximizable&&u.setAttribute("maximizable",""),c.collapsible&&u.setAttribute("collapsible",""),u}_createSplitter(n,r,c,u){let d=document.createElement("ide-splitter");return d.id=n,d.setAttribute("for",r),d.setAttribute("orientation",c),d.title=u,d}_resolvePaneReferences(){let n=["left","main","bottom","right"];this.panes={};for(let r of n){let c=this.containerEl.querySelector(`#pane-${r}`);c?.build&&c.build(),this.panes[r]={el:c,paneComponent:c,tabsEl:c?.tabsEl||this.containerEl.querySelector(`#pane-${r}-tabs`),contentEl:c?.contentEl||this.containerEl.querySelector(`#pane-${r}-content`)}}this.centerEl=this.containerEl.querySelector("#pane-center")}_initSplitters(){let n=null;this.containerEl.addEventListener("ide-splitter-start",r=>{let c=r.detail?.for,u=Ihe[c];if(!u)return;let b=(c==="bottom"?this.centerEl||this.containerEl:this.containerEl).getBoundingClientRect(),w=this.panes[c]?.el?.getBoundingClientRect()||{},_=u.dimension==="width"?b.width:b.height,x=u.dimension==="width"?w.width||240:w.height||220;n={paneName:c,cfg:u,startSize:x,maxLimit:Math.round(_*u.maxFraction)||500}}),this.containerEl.addEventListener("ide-splitter-drag",r=>{if(!n||n.paneName!==r.detail?.for)return;let{cfg:c,startSize:u,maxLimit:d}=n,b=c.invertDelta?-r.detail.delta:r.detail.delta,w=Math.round(u+b),_=Math.max(c.minSize,Math.min(d,w));this.containerEl.style.setProperty(c.cssVar,`${_}px`),this.notifyResize()}),this.containerEl.addEventListener("ide-splitter-end",()=>{n=null,this.saveLayout(),this.notifyResize()}),this.containerEl.addEventListener("ide-splitter-reset",r=>{let c=r.detail?.for;this._resetSplitterPane(c)}),this._setupFallbackSplitters()}_resetSplitterPane(n){let r=Ihe[n];r&&(this.containerEl.style.setProperty(r.cssVar,r.defaultSize),this.isPaneCollapsed(n)?this.restorePane(n):(this.saveLayout(),this.notifyResize()))}_setupFallbackSplitters(){for(let[n,r]of Object.entries(Ihe)){let c=this.containerEl.querySelector(`#splitter-${n}`);if(!c||c instanceof Dhe)continue;let u=!r.invertDelta,d=r.isVertical;c.addEventListener("pointerdown",b=>{b.preventDefault();try{c.setPointerCapture(b.pointerId)}catch{}c.classList.add("dragging"),document.body&&document.body.classList.add("is-resizing",d?"is-resizing-v":"is-resizing-h");let w=d?b.clientX:b.clientY,x=(n==="bottom"?this.centerEl||this.containerEl:this.containerEl).getBoundingClientRect(),T=this.panes[n]?.el?.getBoundingClientRect()||{},M=r.dimension==="width"?T.width||240:T.height||220,L=r.dimension==="width"?x.width:x.height,I=Math.round(L*r.maxFraction)||500,D=new AbortController,{signal:F}=D,O=Z=>{let H=d?Z.clientX:Z.clientY,te=u?H-w:w-H,oe=Math.round(M+te),ne=Math.max(r.minSize,Math.min(I,oe));this.containerEl.style.setProperty(r.cssVar,`${ne}px`),this.notifyResize()},z=Z=>{try{c.releasePointerCapture(Z.pointerId)}catch{}c.classList.remove("dragging"),document.body&&document.body.classList.remove("is-resizing","is-resizing-v","is-resizing-h"),D.abort(),this.saveLayout(),this.notifyResize()};window.addEventListener("pointermove",O,{signal:F}),window.addEventListener("pointerup",z,{signal:F}),window.addEventListener("pointercancel",z,{signal:F})}),c.addEventListener("dblclick",()=>{this._resetSplitterPane(n)})}}_initControls(){this.containerEl.addEventListener("ide-pane-maximize",r=>{this.toggleMaximize(r.detail?.pane)}),this.containerEl.addEventListener("ide-pane-collapse",r=>{this.toggleCollapse(r.detail?.pane)}),this.containerEl.addEventListener("ide-layout-reset",()=>{this.resetLayout()});for(let r of["left","right","bottom"]){let c=this.containerEl.querySelector(`#gutter-expand-${r}`);c&&c.addEventListener("click",()=>this.restorePane(r))}let n=[{sel:"#btn-collapse-left",handler:()=>this.toggleCollapse("left")},{sel:"#btn-collapse-right",handler:()=>this.toggleCollapse("right")},{sel:"#btn-collapse-bottom",handler:()=>this.toggleCollapse("bottom")},{sel:"#btn-maximize-main",handler:()=>this.toggleMaximize("main")},{sel:"#btn-maximize-bottom",handler:()=>this.toggleMaximize("bottom")},{sel:"#btn-maximize-right",handler:()=>this.toggleMaximize("right")},{sel:"#btn-empty-reset-layout",handler:()=>this.resetLayout()}];for(let{sel:r,handler:c}of n){let u=this.containerEl.querySelector(r);u&&!u.closest("ide-pane")&&u.addEventListener("click",c)}}isPaneMaximized(n){return n?this.containerEl.classList.contains(`maximized-${n}`):this.containerEl.classList.contains("maximized-main")||this.containerEl.classList.contains("maximized-bottom")||this.containerEl.classList.contains("maximized-right")}setMaximizedPane(n,r=!0){let c=["main","bottom","right"];if(n&&!c.includes(n))return!1;let u=r?n:null;for(let d of c){let b=d===u;this.containerEl.classList.toggle(`maximized-${d}`,b),this.panes[d]?.paneComponent?.setMaximized(b);let w=this.containerEl.querySelector(`#btn-maximize-${d}`);w&&(w.textContent=b?"\u29C9":"\u2922",w.title=b?"Restore":"Maximize")}return this.notifyResize(),!!u}maximizePane(n){return this.setMaximizedPane(n,!0)}restoreMaximized(){return this.setMaximizedPane(null,!1)}toggleMaximize(n){return this.setMaximizedPane(n,!this.isPaneMaximized(n))}isPaneCollapsed(n){let r=n==="bottom"?this.centerEl:this.containerEl;return r?r.classList.contains(`hide-${n}`):!1}_setPaneCollapsed(n,r){let c=n==="bottom"?this.centerEl:this.containerEl;if(!c)return;c.classList.toggle(`hide-${n}`,r),this.panes[n]?.paneComponent?.setCollapsed?.(r);let u=this.containerEl.querySelector(`#btn-collapse-${n}`);if(u){let b={bottom:{collapsed:"\u25B2",expanded:"\u25BC"},left:{collapsed:"\u25B6",expanded:"\u25C0"},right:{collapsed:"\u25C0",expanded:"\u25B6"}}[n]||{collapsed:"\u25B6",expanded:"\u25C0"};u.textContent=r?b.collapsed:b.expanded,u.title=r?`Expand ${n.charAt(0).toUpperCase()+n.slice(1)}`:`Collapse ${n.charAt(0).toUpperCase()+n.slice(1)}`}this.saveLayout(),this.notifyResize()}toggleCollapse(n){this._setPaneCollapsed(n,!this.isPaneCollapsed(n))}collapsePane(n){this._setPaneCollapsed(n,!0)}restorePane(n){this._setPaneCollapsed(n,!1)}_updateEmptyState(){let n=this.containerEl.querySelector("#ide-empty-state");if(!n)return;let r=!!this.activeTabs.main;n.style.display=r?"none":"flex"}resetLayout(){try{localStorage.removeItem("or_ide_layout")}catch{}for(let[n,r]of Object.entries(Ihe))this.containerEl.style.setProperty(r.cssVar,r.defaultSize);for(let n of["left","right","bottom"])this.restorePane(n);this.restoreMaximized(),this.closedComponents.clear();for(let n of this.components.values())n.tabEl.style.display="",n.contentDiv.style.display="";this.components.has("DisplayControls")&&this.activateTab("DisplayControls"),this.components.has("LayoutViewer")&&this.activateTab("LayoutViewer"),this.components.has("TclConsole")&&this.activateTab("TclConsole"),this.components.has("Inspector")&&this.activateTab("Inspector"),this._updateEmptyState(),this.saveLayout(),this.notifyResize(),this.emit("stateChanged"),typeof app<"u"&&app.map&&setTimeout(()=>app.map.invalidateSize({animate:!1}),0)}_initResizeObserver(){typeof ResizeObserver<"u"&&new ResizeObserver(()=>{this.notifyResize()}).observe(this.containerEl)}registerComponentFactoryFunction(n,r){this.factories.set(n,r)}loadLayout(n){for(let[c,u]of Object.entries(oxt)){let d=this.factories.get(c);d&&this._mountComponent(c,u.pane,u.title,u.closable,d)}let r=null;try{let c=localStorage.getItem("or_ide_layout");c&&(r=JSON.parse(c))}catch{}if(r){if(r.leftWidth&&this.containerEl.style.setProperty("--pane-left-width",`${r.leftWidth}px`),r.rightWidth&&this.containerEl.style.setProperty("--pane-right-width",`${r.rightWidth}px`),r.bottomHeight&&this.containerEl.style.setProperty("--pane-bottom-height",`${r.bottomHeight}px`),r.closed)for(let c of r.closed)this.closeComponent(c,!1);this.activateTab(r.activeTabs?.left||"DisplayControls"),this.activateTab(r.activeTabs?.main||"LayoutViewer"),this.activateTab(r.activeTabs?.bottom||"TclConsole"),this.activateTab(r.activeTabs?.right||"Inspector"),r.hideLeft&&this.collapsePane("left"),r.hideRight&&this.collapsePane("right"),r.hideBottom&&this.collapsePane("bottom")}else this.activateTab("DisplayControls"),this.activateTab("LayoutViewer"),this.activateTab("TclConsole"),this.activateTab("Inspector");this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}_mountComponent(n,r,c,u,d){if(this.components.has(n))return;let b=this.panes[r];if(!b)return;let w=document.createElement("div");w.className="ide-component-container",w.id=`cmp-${n}`,b.contentEl.appendChild(w);let _=document.createElement("ide-tab");_.id=`tab-${n}`,_.setAttribute("for",n),_.setAttribute("data-component",n),_.setAttribute("title",c),u&&_.setAttribute("closable",""),_.addEventListener("tab-select",()=>{this.activateTab(n)}),_.addEventListener("tab-close",()=>{this.closeComponent(n)}),b.tabsEl.appendChild(_);let x=new Map,T={element:w,get width(){return w.clientWidth},get height(){return w.clientHeight},title:c,on:(L,I)=>{x.has(L)||x.set(L,new Set),x.get(L).add(I)},off:(L,I)=>{x.get(L)?.delete(I)},fire:(L,...I)=>{let D=x.get(L);if(D)for(let F of D)try{F(...I)}catch(O){console.error(O)}},focus:()=>this.focusComponent(n),close:()=>this.closeComponent(n)},M={componentType:n,paneName:r,title:c,closable:u,tabEl:_,contentDiv:w,container:T};this.components.set(n,M);try{d(T)}catch(L){console.error(`Failed to initialize component ${n}:`,L)}}isComponentActive(n){return n?!!n.contentDiv?.classList.contains("active"):!1}_setComponentActive(n,r){if(!n)return;let c=!!r;n.tabEl?.setActive(c),n.contentDiv?.classList.toggle("active",c)}activateTab(n){let r=this.components.get(n);if(!r||!this.panes[r.paneName])return;["left","right","bottom"].includes(r.paneName)&&this.isPaneCollapsed(r.paneName)&&this.restorePane(r.paneName);let u=this.activeTabs[r.paneName];if(u&&u!==n){let d=this.components.get(u);d&&(this._setComponentActive(d,!1),d.container.fire("hide"))}this.activeTabs[r.paneName]=n,r.tabEl.style.display="",r.contentDiv.style.display="",this._setComponentActive(r,!0),this.closedComponents.delete(n),r.container.fire("show"),r.container.fire("open"),r.container.fire("resize"),typeof app<"u"&&(n==="LayoutViewer"&&app.map&&setTimeout(()=>app.map.invalidateSize({animate:!1}),0),n==="3DViewer"&&app.threeDViewerWidget&&setTimeout(()=>app.threeDViewerWidget.onOpen(),0));try{r.tabEl.scrollIntoView({behavior:"smooth",inline:"nearest",block:"nearest"})}catch{}this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}closeComponent(n,r=!0){let c=this.components.get(n);if(!(!c||!c.closable)){if(c.tabEl.style.display="none",c.contentDiv.style.display="none",this._setComponentActive(c,!1),c.container.fire("hide"),this.closedComponents.add(n),r&&this.activeTabs[c.paneName]===n){let u=null;for(let d of this.components.values())if(d.paneName===c.paneName&&!this.closedComponents.has(d.componentType)){u=d;break}u?this.activateTab(u.componentType):(this.activeTabs[c.paneName]=null,["left","right","bottom"].includes(c.paneName)&&this.collapsePane(c.paneName))}this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}}focusComponent(n){if(!this.components.get(n)){let c=this.factories.get(n);if(c){let u=oxt[n]||{pane:"right",title:n,closable:!0};this._mountComponent(n,u.pane,u.title,u.closable,c)}else return}this.activateTab(n)}saveLayout(){let n={leftWidth:parseInt(this.containerEl.style.getPropertyValue("--pane-left-width")||"240",10),rightWidth:parseInt(this.containerEl.style.getPropertyValue("--pane-right-width")||"340",10),bottomHeight:parseInt(this.containerEl.style.getPropertyValue("--pane-bottom-height")||"220",10),hideLeft:this.isPaneCollapsed("left"),hideRight:this.isPaneCollapsed("right"),hideBottom:this.isPaneCollapsed("bottom"),activeTabs:{...this.activeTabs},closed:Array.from(this.closedComponents)};try{localStorage.setItem("or_ide_layout",JSON.stringify(n))}catch{}return n}notifyResize(){if(this._resizeScheduled)return;this._resizeScheduled=!0,(typeof requestAnimationFrame=="function"?requestAnimationFrame:r=>{r()})(()=>{this._resizeScheduled=!1;for(let r of this.components.values())this.isComponentActive(r)&&r.container.fire("resize");typeof app<"u"&&app&&app.map&&app.map.invalidateSize({animate:!1}),window.dispatchEvent(new Event("resize"))})}updateSize(){this.notifyResize()}setSize(n,r){this.notifyResize()}addComponent(n,r,c){this.focusComponent(n)}get rootItem(){return{contentItems:Array.from(this.components.keys()).map(n=>({isComponent:!0,componentType:n,focus:()=>this.focusComponent(n)}))}}};function Lv(s,n,r,c=0,u=0){return[(s-c)*r,(n-u)*r]}function kv(s,n,r,c=0,u=0){return{dbuX:Math.round(c+s/r),dbuY:Math.round(u+n/r)}}function X1(s,n,r,c,u,d=0,b=0){let[w,_]=Lv(s,n,u,d,b),[x,T]=Lv(r,c,u,d,b);return[Math.min(w,x),Math.min(_,T),Math.max(w,x),Math.max(_,T)]}var ZW=class s{constructor(n,r){this.url=n,this.socket=null,this.nextId=1,this.pending=new Map,this._queue=new Map,this._bgQueue=new Map,this._bgSent=new Set,this._inFlight=0,this._inFlightIds=new Set,this._unknownPayloadTypes=new Set,this._maxInFlight=48,this._lastRecvAt=0,this._bufStuckSince=0,this._lastBuffered=0,this.reconnectDelay=1e3,this.readyPromise=null,this.readyResolve=null,this.onStatusChange=r||(()=>{}),this.onPush=null,this._cache=null,this._isConnected=!1,this._shutdown=!1,this._livenessTimer=void 0,this._startLivenessMonitor(),this.connect()}get isConnected(){return this._isConnected||this.socket&&this.socket.readyState===WebSocket.OPEN}get pendingCount(){return this.pending.size-this._bgSent.size+(this._queue?this._queue.size:0)}static fromCache(n,r){let c=Object.create(s.prototype);return c.url=null,c.socket=null,c.nextId=1,c.pending=new Map,c._queue=new Map,c._bgQueue=new Map,c._bgSent=new Set,c._inFlight=0,c._inFlightIds=new Set,c._unknownPayloadTypes=new Set,c._maxInFlight=48,c._lastRecvAt=0,c.reconnectDelay=0,c.onStatusChange=r||(()=>{}),c.onPush=null,c._cache=n,c._isConnected=!0,c.readyPromise=Promise.resolve(),c.readyResolve=null,c}get isStaticMode(){return!!this._cache}connect(){this.readyPromise=new Promise(n=>{this.readyResolve=n}),this.socket=new WebSocket(this.url),this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{console.log("WebSocket connected");let n=this._everConnected===!0;this._everConnected=!0,this._isConnected=!0,this.reconnectDelay=1e3,this._lastRecvAt=typeof performance<"u"?performance.now():0,this.readyResolve(),this.onStatusChange(),this._pump(),n&&this.onReconnected&&this.onReconnected()},this.socket.onmessage=n=>{this.handleMessage(n.data)},this.socket.onclose=()=>this._handleClose(),this.socket.onerror=n=>{console.error("WebSocket error:",n)}}_handleClose(){this._isConnected=!1,this._inFlight=0,this._inFlightIds.clear(),this._bufStuckSince=0,this.onStatusChange();for(let[n,r]of this.pending)r.reject(new Error("WebSocket closed"));this.pending.clear(),this._bgSent.clear();for(let n of[this._queue,this._bgQueue]){for(let[r,c]of n)c.reject(new Error("WebSocket closed"));n.clear()}if(this._shutdown){console.log("WebSocket closed (server stopped)"),this._stopLivenessMonitor();return}console.log("WebSocket closed, reconnecting..."),setTimeout(()=>this.connect(),this.reconnectDelay),this.reconnectDelay=Math.min(this.reconnectDelay*2,3e4)}_forceReconnect(){let n=this.socket;if(this.socket=null,n){n.onopen=null,n.onmessage=null,n.onclose=null,n.onerror=null;try{n.close()}catch{}}this._handleClose()}handleMessage(n){let r=new DataView(n),c=r.getUint32(0),u=r.getUint8(4);if(this._lastRecvAt=typeof performance<"u"?performance.now():0,c===0&&u===0){let w=n.slice(8),_;try{_=JSON.parse(new TextDecoder().decode(w))}catch(x){console.error("Failed to parse server push JSON:",x);return}if(_&&_.type==="config"){Number.isFinite(_.max_in_flight)&&(this._maxInFlight=Math.max(1,Math.min(4096,Math.floor(_.max_in_flight))),this._pump());return}this.onPush&&this.onPush(_);return}this._inFlightIds.delete(c)&&this._inFlight>0&&this._inFlight--;let d=this.pending.get(c);if(!d){this._pump();return}this.pending.delete(c),this._bgSent.delete(c),this._pump(),this.onStatusChange();let b=n.slice(8);if(u===2)d.reject(new Error(new TextDecoder().decode(b)));else if(u===0)try{d.resolve(JSON.parse(new TextDecoder().decode(b)))}catch(w){d.reject(new Error("JSON parse error: "+w.message))}else u===1?d.resolve(new Blob([b],{type:"image/png"})):u===3?d.resolve(null):(this._unknownPayloadTypes.has(u)||(this._unknownPayloadTypes.add(u),console.warn(`Unrecognized websocket payload type ${u}. The server is likely newer than this page \u2014 reload to pick up the current client.`)),d.reject(new Error(`Unsupported websocket payload type ${u}`)))}request(n,{background:r=!1}={}){if(this._cache)return this._cacheRequest(n);let c=this.nextId++;if(n.id=c,!this.socket||this.socket.readyState!==WebSocket.OPEN)return Promise.reject(new Error("WebSocket not connected"));let u,d,b=new Promise((w,_)=>{u=w,d=_});return b.requestId=c,(r?this._bgQueue:this._queue).set(c,{msg:n,resolve:u,reject:d}),this._pump(),b}_pump(){if(!(!this.socket||this.socket.readyState!==WebSocket.OPEN)){for(;this._inFlight0||this._bgQueue.size>0)&&this.socket.bufferedAmount<524288;){let n=this._queue.size===0,r=n?this._bgQueue:this._queue,[c,u]=r.entries().next().value;r.delete(c),this.pending.set(c,{resolve:u.resolve,reject:u.reject}),n&&this._bgSent.add(c),this.socket.send(JSON.stringify(u.msg)),this._inFlightIds.add(c),this._inFlight++}this.onStatusChange()}}promote(n){let r=this._bgQueue.get(n);r?(this._bgQueue.delete(n),this._queue.set(n,r),this._pump()):this._bgSent.delete(n)&&this.onStatusChange()}cancel(n){let r=this._queue.get(n)||this._bgQueue.get(n);if(r){this._queue.delete(n),this._bgQueue.delete(n),r.reject(new Error("Request cancelled")),this.onStatusChange();return}let c=this.pending.get(n),u=this.pending.delete(n);this._bgSent.delete(n),c&&c.reject(new Error("Request cancelled")),u&&!this._cache&&this.socket&&this.socket.readyState===WebSocket.OPEN&&this.socket.send(JSON.stringify({type:"cancel",cancel_id:n,id:this.nextId++})),this.onStatusChange()}_startLivenessMonitor(){typeof setInterval>"u"||(this._livenessTimer=setInterval(()=>this._checkLiveness(),3e3),this._livenessTimer&&typeof this._livenessTimer.unref=="function"&&this._livenessTimer.unref())}_stopLivenessMonitor(){this._livenessTimer!==void 0&&typeof clearInterval<"u"&&(clearInterval(this._livenessTimer),this._livenessTimer=void 0)}_checkLiveness(){if(this._cache)return;let n=this.socket;if(!n||n.readyState!==WebSocket.OPEN){this._bufStuckSince=0,this._lastBuffered=0;return}let r=n.bufferedAmount,c=typeof performance<"u"?performance.now():0,u=!1,d="";r<=262144||r12e3&&(u=!0,d=`send buffer stuck at ${r}B for ${Math.round(c-this._bufStuckSince)}ms`),this._lastBuffered=r,!u&&this._inFlight>=this._maxInFlight&&this._queue.size+this._bgQueue.size>0&&this._lastRecvAt>0&&c-this._lastRecvAt>3e4&&(u=!0,d=`saturated (${this._inFlight} in flight, ${this._queue.size} queued) but silent for ${Math.round(c-this._lastRecvAt)}ms`),u&&(console.warn(`WebSocket connection wedged \u2014 ${d}; reconnecting to recover`),this._bufStuckSince=0,this._forceReconnect())}_cacheRequest(n){let r=n.type;if(r==="tile"){let d=n.layer+"/"+n.z+"/"+n.x+"/"+n.y,b=this._cache.tiles&&this._cache.tiles[d];return b?Promise.resolve("data:image/png;base64,"+b):Promise.reject(new Error("Tile not cached: "+d))}if(r==="timing_highlight"){let d=n.path_index;if(d>=0&&this._cache.overlays){let b=n.is_setup?"setup":"hold",w=this._cache.overlays[b]?.[d];this._cache.setPathOverlay&&this._cache.setPathOverlay(w?"data:image/png;base64,"+w:null)}else this._cache.setPathOverlay&&this._cache.setPathOverlay(null);return Promise.resolve({})}if(r==="set_module_colors")return Promise.resolve({ok:1,count:0});let c=r;r==="timing_report"?c="timing_report:"+(n.is_setup?"setup":"hold"):r==="slack_histogram"&&(c="slack_histogram:"+(n.is_setup?"setup":"hold"));let u=this._cache.json&&this._cache.json[c];if(u!==void 0){if(r==="timing_report"&&n.slack_min!=null&&n.slack_max!=null&&u.paths){let d=[];return u.paths.forEach((b,w)=>{b.slack>=n.slack_min&&b.slackb||w>_?null:{z:n,x0:d,x1:b,y0:w,y1:_}}function R5e([s,n,r,c],u){let d=(r-s)*u,b=(c-n)*u;return[s-d,n-b,r+d,c+b]}function Fhe(s,n=1){if(!s)return null;let r=Math.pow(2,s.z);return{z:s.z,x0:Math.max(0,s.x0-n),x1:Math.min(r-1,s.x1+n),y0:Math.max(0,s.y0-n),y1:Math.min(r-1,s.y1+n)}}function Am(s,n,r){return!!s&&n>=s.x0&&n<=s.x1&&r>=s.y0&&r<=s.y1}function JW(s){if(!s)return[];let n=(s.x0+s.x1)/2,r=(s.y0+s.y1)/2,c=[];for(let u=s.y0;u<=s.y1;u++)for(let d=s.x0;d<=s.x1;d++)c.push({z:s.z,x:d,y:u,d:(d-n)**2+(u-r)**2});return c.sort((u,d)=>u.d-d.d),c.map(({z:u,x:d,y:b})=>({z:u,x:d,y:b}))}function cxt(s,n,r,c){let u=c/Math.pow(2,s);return[n*u,c-(r+1)*u,(n+1)*u,c-r*u]}function I5e(s,n){return s[0]Math.log2(d/ue);if(D<1e-12){let ue=Math.log(M/T)/r;return{S:Math.abs(ue),at:Te=>({target:[b+Te*L,w+Te*I],zoom:F(T*Math.exp(r*Te*ue))})}}let O=Math.sqrt(D),z=(M*M-T*T+u*D)/(2*T*c*O),Z=(M*M-T*T-u*D)/(2*M*c*O),H=Math.log(Math.sqrt(z*z+1)-z),oe=(Math.log(Math.sqrt(Z*Z+1)-Z)-H)/r,ne=Math.cosh(H);return{S:oe,at:ue=>{if(ue>=1)return{target:[_,x],zoom:n.zoom};let Te=ue*oe,Q=T/(c*O)*(ne*Math.tanh(r*Te+H)-Math.sinh(H));return{target:[b+Q*L,w+Q*I],zoom:F(T*ne/Math.cosh(r*Te+H))}}}}function yO(s,n,r){return`${s}/${n}/${r}`}var Uhe=class{constructor({source:n,onChange:r=()=>{},keepBuffer:c=2}={}){this.source=n,this.onChange=r,this.keepBuffer=c,this.tiles=new Map,this.z=null,this.range=null,this.ring=null,this.extra=[],this._generation=0,this._loads=0,this._cancels=0}update({z:n,range:r,ring:c=r,extra:u=[],hold:d=null}){this.z=n,this.range=r,this.ring=c,this.extra=u.filter(_=>_.z!==n&&_.range);let b=new Map(this.extra.map(_=>[_.z,_]));for(let _ of[...this.tiles.values()]){if(_.z!==n){let x=b.get(_.z),T=x&&x.range;(T?!Am(T,_.x,_.y)&&(_.loading||!this._inKeepBuffer(_,T)):_.loading&&!_.drawable)?this._drop(_):T&&this._stale(_)&&Am(T,_.x,_.y)&&this._load(_,x.background!==!1);continue}if(this._stale(_)&&Am(c,_.x,_.y)&&this._load(_,!Am(r,_.x,_.y)),Am(c,_.x,_.y)){_.loading&&_.background&&Am(r,_.x,_.y)&&(_.background=!1,_.handle?.promote?.());continue}(_.loading||!(this._inKeepBuffer(_)||d&&Am(d,_.x,_.y)))&&this._drop(_)}let w=[...JW(r),...JW(c).filter(_=>!Am(r,_.x,_.y))];for(let{x:_,y:x}of w)this.tiles.has(yO(n,_,x))||this._load(this._newTile(n,_,x),!Am(r,_,x));for(let _ of this.extra)for(let{x,y:T}of JW(_.range))this.tiles.has(yO(_.z,x,T))||this._load(this._newTile(_.z,x,T),_.background!==!1)}refresh(){this._generation++;let n=new Map(this.extra.map(r=>[r.z,r]));for(let r of[...this.tiles.values()]){let c=n.get(r.z),u=r.z===this.z?this.ring:c&&c.range;u&&(Am(u,r.x,r.y)?(r.handle?.cancel?.(),this._load(r,c?c.background!==!1:!Am(this.range,r.x,r.y))):r.loading&&this._drop(r))}}isSettled(){for(let n of this.tiles.values())if(n.z===this.z&&n.loading&&Am(this.range,n.x,n.y))return!1;return!0}settledIn(n,r){for(let{x:c,y:u}of JW(r)){let d=this.tiles.get(yO(n,c,u));if(!d||d.loading)return!1}return!0}hasContentAt(n){for(let r of this.tiles.values())if(r.z===n&&r.drawable)return!0;return!1}drawableTilesAt(n){let r=[];for(let c of this.tiles.values())c.z===n&&c.drawable&&r.push(c);return r}prune(n){let r=new Set(n);for(let c of[...this.tiles.values()])r.has(c.z)||this._drop(c)}clear(){for(let n of[...this.tiles.values()])this._drop(n);this.z=null,this.range=null,this.ring=null,this.extra=[]}stats(){let n=0,r=0;for(let c of this.tiles.values())c.loading&&n++,c.drawable&&r++;return{tiles:this.tiles.size,loading:n,drawable:r,loads:this._loads,cancels:this._cancels}}_newTile(n,r,c){let u={z:n,x:r,y:c,key:yO(n,r,c),drawable:null,loading:!1,background:!1,handle:null,generation:-1};return this.tiles.set(u.key,u),u}_load(n,r){let c=this._generation,u=()=>this.tiles.get(n.key)===n&&n.generation===c;n.generation=c,n.loading=!0,n.background=r,this._loads++;let d=this.source.load({z:n.z,x:n.x,y:n.y},{background:r,onPartial:b=>{if(!u()){this.source.release?.(b);return}this._setDrawable(n,b),this.onChange(n)}});n.handle=d,d.promise.then(b=>{if(!u()){this.source.release?.(b);return}b!==void 0&&this._setDrawable(n,b),n.loading=!1,n.handle=null,this.onChange(n)},()=>{u()&&(n.loading=!1,n.handle=null,this.onChange(n))})}_setDrawable(n,r){n.drawable&&n.drawable!==r&&this.source.release?.(n.drawable),n.drawable=r||null}_stale(n){return!n.loading&&n.generation!==this._generation}_inKeepBuffer(n,r=this.range){return Am(Fhe(r,this.keepBuffer),n.x,n.y)}_drop(n){n.loading&&(this._cancels++,n.handle?.cancel?.()),n.drawable&&this.source.release?.(n.drawable),n.drawable=null,n.loading=!1,this.tiles.delete(n.key)}};function Mhn(s){return!Number.isFinite(s)||s<=1?1:Math.round(Math.min(s,3)*100)/100}var iE=240,Thn=256,D5e=iE;function Fb(){return D5e}function fxt(){D5e=Thn}var eli=1/64,B5e=120;function hxt(s){D5e=s}function O5e(s,n){return Math.max(1,Math.round(s*n))}function xO(){let s=typeof window<"u"&&window.devicePixelRatio?window.devicePixelRatio:1;return!Number.isFinite(s)||s<=1?1:Math.min(s,3)}function zhe(s,n=Fb()){return{dpr:Mhn(s),tile_px:O5e(n,s)}}function dxt(s,n,r,c=Fb()){let{selectability:u,selectableLayers:d,app:b}=n,w={...gxt(s,n,r,c),selectable_layers:d?[...d]:[]};if(u)for(let[_,x]of Object.entries(u))w["s_"+_]=!!x;return _=>{let x={type:"tile",layer:_,...w},T=mxt(b,_);return T!==1&&(x.pattern=T),x}}function pxt(s,n,r,c,u=Fb()){let d={type:"tile_group",layers:[...n],...gxt(s,r,c,u)},b=n.map(w=>mxt(r.app,w));return b.some(w=>w!==1)&&(d.patterns=b),d}function gxt(s,n,r,c){let{visibility:u,visibleLayers:d,app:b}=n,w={z:s.z,x:s.x,y:s.y,...zhe(r,c),visible_layers:d?[...d]:[]};for(let[_,x]of Object.entries(u||{}))w[_]=!!x;return b&&b.visibleChiplets instanceof Set&&(w.visible_chiplets=[...b.visibleChiplets]),w}function mxt(s,n){let r=s&&s.layerPatterns?s.layerPatterns[n]:void 0;return r===void 0?1:r}function bxt(s){if(typeof window>"u"||typeof window.matchMedia!="function"||typeof s!="function")return()=>{};let n=!1,r=null,c=null,u=()=>{if(n)return;let d=window.devicePixelRatio||1;r=window.matchMedia(`(resolution: ${d}dppx)`),c=()=>{n||(u(),s(window.devicePixelRatio||1))},r.addEventListener("change",c,{once:!0})};return u(),()=>{n=!0,r&&c&&r.removeEventListener("change",c),r=null,c=null}}function wxt(s,n){if(!s)return!1;let r=!!n;return!!s.visible===r?!1:(s.visible=r,!0)}function vxt(s,n,r){if(!s||!(r>0))return 0;s.clearRect(0,0,r,r);let c=0;for(let u of n||[]){let d=u?u.image:null;if(!d)continue;let b=u.opacity===void 0?1:u.opacity;b>0&&(s.globalAlpha=Math.min(1,b),s.drawImage(d,0,0,r,r),c++)}return s.globalAlpha=1,c}function N5e(s){for(let n of s||[])n&&typeof n.close=="function"&&n.close()}async function _xt({items:s,request:n,decode:r,draw:c,release:u=N5e,isStale:d=()=>!1,incremental:b=!0}={}){let w=Array.isArray(s)?s:[],_={requested:w.length,arrived:0,decoded:0,drawn:0,paints:0,failed:0,stale:!1};if(w.length===0)return typeof c=="function"&&c([]),_;let x=new Array(w.length).fill(null),T=!1;function M(){if(d()){_.stale=!0;return}_.drawn=c(w.map((L,I)=>({image:x[I],opacity:L.opacity})))||0,_.paints++,T=!0}try{await Promise.all(w.map(async(L,I)=>{let D=null;try{D=await n(L)}catch{_.failed++;return}if(D==null)return;_.arrived++;let F=null;try{F=await r(D)}catch{return}F&&(x[I]=F,_.decoded++,b&&M())})),T||M()}finally{u(x)}return _}var Chn=["tracks_pref","tracks_non_pref","debug","debug_renderers"],Ahn=1/16;function F5e(s,n){if(s==null)return!1;if(!Array.isArray(s)||s.length!==4||!n)return!0;let r=Math.pow(2,n.z),c=Ahn/r,u=n.x/r-c,d=n.y/r-c,b=(n.x+1)/r+c,w=(n.y+1)/r+c,[_,x,T,M]=s;return _<=b&&T>=u&&x<=w&&M>=d}function Phn(s,n,r){let c=s&&Array.isArray(s.by_size)?s.by_size:[];if(c.length===0||!n||!(r>0))return!0;let u=s.min_css_px/(r*Math.pow(2,n.z)),d=c[0];for(let b of c)b[0]<=u&&(d=b);return F5e(d[1],n)}var Ghe=class{constructor(){this._layers=null,this._gated=new Map,this._sized=new Map,this._generation=0}invalidate(){return this._generation++,this._layers=null,this._gated=new Map,this._sized=new Map,this._generation}apply(n,r){if(n!==this._generation)return!1;if(!r||r.supported!==!0||!r.layers||typeof r.layers!="object")return this._layers=null,!1;let c=new Map;if(r.gated&&typeof r.gated=="object")for(let[u,d]of Object.entries(r.gated))d&&typeof d=="object"&&c.set(u,new Map(Object.entries(d)));return this._layers=new Map(Object.entries(r.layers)),this._gated=c,this._sized=new Map(r.sized&&typeof r.sized=="object"?Object.entries(r.sized):[]),!0}refetch(n){let r=this.invalidate();return Promise.resolve().then(()=>n({type:"layer_extents"})).then(c=>this.apply(r,c)).catch(()=>!1)}mayHaveContent(n,r,c,u=256){if(!this._layers||c&&Chn.some(d=>c[d]))return!0;if(this._sized.has(n))return Phn(this._sized.get(n),r,u);if(!this._layers.has(n)||F5e(this._layers.get(n),r))return!0;for(let[d,b]of this._gated)if(!(c&&c[d]===!1)&&b.has(n)&&F5e(b.get(n),r))return!0;return!1}};function yxt(s,n,r){let c=s&&s.app&&s.app.layerExtents;return c?c.mayHaveContent(n,r,s.visibility,Fb()):!0}function xxt(s){return s==null?Promise.resolve(null):typeof s=="string"?new Promise(n=>{let r=document.createElement("img");r.onload=()=>n(r),r.onerror=()=>n(null),r.src=s}):createImageBitmap(s,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).catch(()=>null)}function U5e(s){N5e([s&&s.image])}function Lhn(s){return{width:s.naturalWidth||s.width,height:s.naturalHeight||s.height}}function jhe(s){return s?{image:s,...Lhn(s)}:null}function khn(s){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(s,s);let n=document.createElement("canvas");return n.width=s,n.height=s,n}function z5e(s){let n=document.createElement("canvas");return n.width=s.width,n.height=s.height,n.getContext("2d").drawImage(s,0,0),n}function Rhn(s){return typeof s.transferToImageBitmap=="function"?jhe(s.transferToImageBitmap()):jhe(z5e(s))}var Ext=Object.freeze({promise:Promise.resolve(null),cancel(){},promote(){}});function Sxt(s,n,r,c){let u=s.request(r,{background:c});return u.requestId!=null&&n.push(u.requestId),u}function Mxt(s,n,r,c){return{promise:r,cancel(){c();for(let u of n)s.cancel(u)},promote(){for(let u of n)s.promote?.(u)}}}var Txt=3;function Ihn(s,n){let r=new Map,c=0,u=0;for(let d of s)if(!(!d||r.has(d.layer))){if(d.layer.startsWith("_")){r.set(d.layer,null),c++,u=0;continue}r.set(d.layer,`${c}:${Math.floor(u++/n)}`)}return r}function Dhn(s,n,r,c,u,d,b,w){let _=Ihn(s,r),x=[],T=null,M=()=>{T&&(x.push({opacity:1,msg:pxt(u,T.layers,d,b,w)}),T=null)};for(let L of n){let I=_.get(L.layer);if(I==null){M(),x.push({opacity:1,msg:c(L.layer)});continue}T&&T.id!==I&&M(),T=T||{id:I,layers:[]},T.layers.push(L.layer)}return M(),x}function Cxt({wm:s,ctx:n,getItems:r,dpr:c=()=>1,tileSize:u=()=>240,isDoubleBuffer:d=()=>!0,decode:b=xxt,makeCanvas:w=khn,snapshot:_=Rhn,groupLayers:x=()=>0}){return{load({z:T,x:M,y:L},{background:I=!1,onPartial:D}={}){let F=r()||[],O=F.filter(tt=>tt&&tt.visible!==!1&&yxt(n,tt.layer,{z:T,x:M,y:L})),z=c(),Z=u(),H=new Set,te=O.filter(tt=>!H.has(tt.layer)&&H.add(tt.layer));if(te.length===0)return Ext;let oe=dxt({z:T,x:M,y:L},n,z,Z),ne=x(),ue=ne>0&&te.every(tt=>(tt.opacity??1)===1)?Dhn(F,te,ne,oe,{z:T,x:M,y:L},n,z,Z):te.map(tt=>({opacity:tt.opacity,msg:oe(tt.layer)})),Te=O5e(Z,z),Q=null,ge=null,Qe=[],st=!1,at=!d()&&typeof D=="function",Ne=_xt({items:ue,request:tt=>Sxt(s,Qe,tt.msg,I),decode:b,draw:tt=>{if(!Q){if(!tt.some(Tt=>Tt.image))return 0;Q=w(Te),ge=Q.getContext("2d")}let ot=vxt(ge,tt,Te);return at&&ot>0&&!st&&D(_(Q)),ot},isStale:()=>st,incremental:at}).then(tt=>{if(st)throw new Error("Tile cancelled");if(tt.failed===tt.requested)throw new Error("Tile requests failed");return tt.drawn===0?null:at?void 0:_(Q)});return Mxt(s,Qe,Ne,()=>{st=!0})},release:U5e}}function G5e({wm:s,buildRequest:n,dpr:r=()=>1,tileSize:c=()=>240,decode:u=xxt}){return{load({z:d,x:b,y:w},{background:_=!1}={}){let x=n({z:d,x:b,y:w},r(),c());if(!x)return Ext;let T=[],M=!1,L=Sxt(s,T,x,_).then(I=>u(I)).then(I=>{if(M)throw U5e(jhe(I)),new Error("Tile cancelled");return jhe(I)});return Mxt(s,T,L,()=>{M=!0})},release:U5e}}function Axt({z:s,x:n,y:r},c,u,d,b){let w={type:"overlay_tile",z:s,x:n,y:r,...zhe(c,u),debug_renderers:!!d.debug_renderers,debug_live:!!d.debug_live,flywires_only:!!d.flywires_only,poly_decomp:!!(b&&b.polyDecomp),focused_nets_guides:!!d.focused_nets_guides,highlight_selected:d.highlight_selected!==!1,draw_labels:d.labels!==!1};return b&&b.visibleLayerNames&&(w.visible_layers=[...b.visibleLayerNames]),w}function Pxt({z:s,x:n,y:r},c,u,d){let b=d&&d.activeHeatMap;return b?{type:"heatmap_tile",name:b,z:s,x:n,y:r,...zhe(c,u)}:null}function ua(s){return!!s?.websocketManager?.isStaticMode}function Ixt(s,n){let r={};for(let[c,u]of Object.entries(s||{}))r[c]=!!u;for(let[c,u]of Object.entries(n||{}))r["s_"+c]=!!u;return r}function EO(s,n){n&&typeof n.sel_has_inst=="boolean"&&(s.selHasInst=n.sel_has_inst,s.selHasNet=!!n.sel_has_net)}var j5e=null;function Y1(s,n=4e3){let r=document.getElementById("or-toast");return r||(r=document.createElement("div"),r.id="or-toast",document.body.appendChild(r)),r.textContent=s,r.classList.add("visible"),j5e&&clearTimeout(j5e),j5e=setTimeout(()=>r.classList.remove("visible"),n),r}function Dxt(s){return!s||s.gpuType!=="cpu"?null:"Software rendering detected (reduced performance). Make sure 'Use graphics acceleration when available' (or 'Use hardware acceleration when available') is turned on in your browser settings, then restart the browser."}function Bxt({title:s,message:n,confirmLabel:r="OK",danger:c=!1}){return new Promise(u=>{let d=document.createElement("div");d.className="or-modal-overlay";let b=document.createElement("div");b.className="or-modal";let w=document.createElement("div");w.className="or-modal-title",w.textContent=s;let _=document.createElement("div");_.className="or-modal-message",_.textContent=n;let x=document.createElement("div");x.className="or-modal-buttons";let T=document.createElement("button");T.className="or-btn",T.textContent="Cancel";let M=document.createElement("button");M.className="or-btn"+(c?" or-btn-danger":""),M.textContent=r;let L=D=>{document.removeEventListener("keydown",I,!0),d.remove(),u(D)},I=D=>{D.key==="Escape"&&(D.stopPropagation(),L(!1))};T.addEventListener("click",()=>L(!1)),M.addEventListener("click",()=>L(!0)),d.addEventListener("click",D=>{D.target===d&&L(!1)}),document.addEventListener("keydown",I,!0),x.appendChild(T),x.appendChild(M),b.appendChild(w),b.appendChild(_),b.appendChild(x),d.appendChild(b),document.body.appendChild(d),T.focus()})}var Bhn=.05;function Ohn([[s,n],[r,c]],u){let d=(c-n)*u,b=(r-s)*u;return[[s-b,n-d],[r+b,c+d]]}function $5e(s,n=256,r=null){if(!Lxt(s))return null;let c=s[0][0],u=s[0][1],d=Math.max(s[1][1]-u,s[1][0]-c),b=n/d,w=Lxt(r)?r:s,[[_,x],[T,M]]=Ohn(w,Bhn);return{scale:b,maxDXDY:d,originX:u,originY:c,fitRect:X1(x,_,M,T,b,u,c)}}function Lxt(s){return!!s&&s[1][0]>s[0][0]&&s[1][1]>s[0][1]}function Oxt(s,n){return!!s&&!!n&&s[0][0]===n[0][0]&&s[0][1]===n[0][1]&&s[1][0]===n[1][0]&&s[1][1]===n[1][1]}function Pm(s){s.selectionToken=(s.selectionToken||0)+1;for(let n of s.selectionResetters||[])n();return s.selectionToken}function Z1(s,n){return s.selectionToken===n}function Nxt(s,n){s.selectionResetters||(s.selectionResetters=[]),s.selectionResetters.push(n)}var V5e=80,QW=10,eH=1e3;function tH(s){let n=s===""||s===null?NaN:Math.round(Number(s));return Number.isFinite(n)?Math.min(eH,Math.max(QW,n)):V5e}function sk(s="vis-group-header"){let n=document.createElement("div");n.className=s;let r=document.createElement("span");r.className="vis-arrow",n.appendChild(r);let c=document.createElement("span");return c.className="vis-name",n.appendChild(c),{header:n,arrow:r,name:c}}function ok(s,n,r,c){let u=d=>{r.classList.toggle("collapsed",d),n.textContent=d?"\u25B6":"\u25BC"};u(!!c),s.addEventListener("click",d=>{let b=d.target&&d.target.parentNode===s&&d.target.classList&&d.target.classList.contains("vis-name");d.target!==s&&d.target!==n&&!b||u(!r.classList.contains("collapsed"))})}var kxt=30;function Fxt(s,n=8){if(!Number.isFinite(s)||s<=0)return kxt;let r=Math.ceil(Math.log2(n/s));return Math.max(1,Math.min(kxt,r))}function Uxt({designBounds:s,fitRect:n,viewW:r,viewH:c}){let u=$5e(s,iE,n),d=I=>Number.isFinite(I)&&I>0;if(!u||!d(r)||!d(c))return iE;let b=u.fitRect[2]-u.fitRect[0],w=u.fitRect[3]-u.fitRect[1],_=Math.min(r/b,c/w),x=Math.log2(_);if(!Number.isFinite(x)||x<0)return iE;let T=Math.floor(x),M=iE*2**(x-T),L=Math.floor(M/B5e)*B5e;return L>iE&&Math.log2(iE*_/L)>=T?L:iE}function zxt(s,{showDbu:n,dbuPerMicron:r},c=!1){if(n)return String(Math.round(s));let u=r>0?r:1e3,d=Math.ceil(Math.log10(u)),b=(s/u).toFixed(d);return c?b+" \xB5m":b}function Gxt(s,{showDbu:n,dbuPerMicron:r}){let c=parseFloat(s);if(!Number.isFinite(c))return null;if(n)return Math.round(c);let u=r>0?r:1e3;return Math.round(c*u)}function jxt(s,{showDbu:n,dbuPerMicron:r}){if(n)return String(Math.round(s));let c=r>0?r:1e3,u=s/c;return u>=1e3?(u/1e3).toFixed(3)+" mm":u>=1?u.toFixed(3)+" um":(u*1e3).toFixed(1)+" nm"}function $xt({showDbu:s}){return s?"DBU":"\xB5m"}function SO(s){return typeof s=="string"&&/^#[0-9a-fA-F]{6}$/.test(s)}function Vxt(s){if(typeof s!="string")return null;let n=s.trim();if(SO(n))return n.toLowerCase();let r=n.match(/^#([0-9a-fA-F]{3})$/);if(r)return"#"+r[1].split("").map(u=>u+u).join("").toLowerCase();let c=n.match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/);if(c){let u=c.slice(1).map(Number);return u.some(d=>d>255)?null:"#"+u.map(d=>d.toString(16).padStart(2,"0")).join("")}return null}function yT(s,n=r=>requestAnimationFrame(r)){let r=!1;return()=>{r||(r=!0,n(()=>{r=!1,s()}))}}function nH(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function Rxt(s){let n=Math.pow(10,Math.floor(Math.log10(s))),r=s/n,c;return r<1.5?c=1:r<3.5?c=2:r<7.5?c=5:c=10,{value:c*n,digit:c}}function Wxt({targetPx:s,pxPerDbu:n,dbuPerMicron:r,showDbu:c}){if(!Number.isFinite(n)||n<=0||!Number.isFinite(s)||s<=0)return null;let u,d,b;if(c){let _=Rxt(Math.max(1,s/n));b=_.digit,u=Math.round(_.value*n),d=String(Math.round(_.value))}else{let _=Number.isFinite(r)&&r>0?r:1e3,x=n*_,T=Rxt(s/x);b=T.digit;let M=T.value;u=Math.round(M*x);let L,I;M>=1e3?(L=1/1e3,I="mm"):M>=1?(L=1,I="\xB5m"):M>=.001?(L=1e3,I="nm"):(L=1e6,I="pm"),d=Math.round(M*L)+" "+I}return{barPx:u,label:d,segments:b===1?5:b}}function iH(s,n,r){return n?typeof s.runTclScript=="function"?s.runTclScript(n,r):(r&&typeof s.echoTcl=="function"&&s.echoTcl(n),s.websocketManager.request({type:"tcl_eval",cmd:n}).catch(()=>{})):Promise.resolve()}function ak(s,n){let r=s.querySelectorAll("thead th");(!n||!n[0])&&(s.style.tableLayout="auto",r.forEach(c=>c.style.width=""),n=Array.from(r,c=>c.offsetWidth+"px")),r.forEach((c,u)=>c.style.width=n[u]||""),s.style.tableLayout="fixed",r.forEach((c,u)=>{if(u===r.length-1)return;let d=document.createElement("div");d.className="col-resize-grip",c.style.position="relative",c.appendChild(d);let b,w,_=T=>{c.style.width=Math.max(30,w+T.clientX-b)+"px"},x=()=>{document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",x);let T=M=>M.stopPropagation();document.addEventListener("click",T,{capture:!0,once:!0}),setTimeout(()=>{document.removeEventListener("click",T,{capture:!0})},0)};d.addEventListener("mousedown",T=>{T.preventDefault(),b=T.clientX,w=c.offsetWidth,document.addEventListener("mousemove",_),document.addEventListener("mouseup",x)})})}var Nhn={Layout:'',Schematic:'',"3D Viewer":'',"Display Controls":'',Inspector:'',Hierarchy:'',Timing:'',DRC:'',"Select Highlight":'',"Clock Tree":'',Charts:'',"Tcl Console":'',Help:''};function Fhn(s){let n=Nhn[s];if(!n)return null;let r=document.createElement("span");return r.className="or-tab-icon",r.innerHTML='",r}function Hxt(s=document){let n=0;for(let r of s.querySelectorAll(".lm_tab:not([data-or-icon])")){let c=r.querySelector(".lm_title");if(!c)continue;let u=c.textContent.trim();if(!u)continue;r.setAttribute("data-or-icon","");let d=Fhn(u);d&&(r.insertBefore(d,c),n++)}return n}function MO(s,n,r,c){let u=document.createElement("div");u.className="modal-overlay",u.innerHTML=` -
`,document.body.appendChild(u);let d=()=>u.remove();u.addEventListener("click",_=>{_.target===u&&d()}),u.addEventListener("keydown",_=>{_.key==="Escape"&&d()}),u.querySelector(".cancel").addEventListener("click",d),u.querySelector(".modal-close").addEventListener("click",d);let b=u.querySelector(".modal-error"),w=(_,x)=>{b.textContent=_,b.style.display=_?"block":"none",b.classList.toggle("info",!!x)};return{overlay:u,close:d,okBtn:u.querySelector(".ok"),showError:w}}var Nhn=1e4,Fhn=150,Uhn=3;function zhn(s){return 1-(1-s)*(1-s)}var $he=class{constructor({isEnabled:n=()=>!0,isSmooth:r=()=>!1,reducedMotion:c=nH,now:u=()=>performance.now(),setTimer:d=(T,M)=>setTimeout(T,M),clearTimer:b=T=>clearTimeout(T),timeoutMs:w=Nhn,fadeMs:_=Fhn,onChange:x=()=>{}}={}){Object.assign(this,{isEnabled:n,isSmooth:r,reducedMotion:c,now:u,setTimer:d,clearTimer:b,timeoutMs:w,fadeMs:_,onChange:x}),this.shownZ=null,this.pendingZ=null,this.under=[],this.fade=null,this._timer=null}wantedZ(){return this.pendingZ!==null?this.pendingZ:this.shownZ}setZoom(n,{hasContent:r=!0}={}){n!==this.wantedZ()&&(this.endFade(),this._clearTimer(),this.shownZ===null?(this.shownZ=n,this.pendingZ=null,this.under=[]):r?n===this.shownZ?this.pendingZ=null:this.isEnabled()?(this.pendingZ=n,this.under=[],this._timer=this.setTimer(()=>this.reveal(),this.timeoutMs)):(this.under=[...this.under.filter(c=>c!==n),this.shownZ].slice(-Uhn),this.shownZ=n,this.pendingZ=null):(this.shownZ=n,this.pendingZ=null,this.under=this.under.filter(c=>c!==n)),this.onChange())}check({settled:n,animating:r=!1}){return this.pendingZ!==null?r||!n&&this.isEnabled()?!1:(this.reveal(),!0):this.under.length>0&&n&&!r?(this.under=[],this.onChange(),!0):!1}reveal(){if(this.pendingZ===null)return;this._clearTimer();let n=this.shownZ;this.shownZ=this.pendingZ,this.pendingZ=null;let r=this.isSmooth()&&!this.reducedMotion()?this.fadeMs:0;this.fade=r>0&&n!==null?{fromZ:n,toZ:this.shownZ,start:this.now(),ms:r}:null,this.onChange()}endFade(){this.fade&&(this.fade=null,this.onChange())}plan(n=this.now()){if(this.fade){let r=(n-this.fade.start)/this.fade.ms;if(r<1)return{draw:[{z:this.fade.fromZ,opacity:1},{z:this.fade.toZ,opacity:zhn(Math.max(0,r))}],fading:!0};this.fade=null}return this.shownZ===null?{draw:[],fading:!1}:this.pendingZ!==null?{draw:[{z:this.shownZ,opacity:1}],fading:!1}:this.under.length>0?{draw:[...this.under,this.shownZ].map(r=>({z:r,opacity:1})),fading:!1}:{draw:[{z:this.shownZ,opacity:1}],fading:!1}}isIdle(n=this.now()){return this.pendingZ===null&&this.under.length===0&&!this.plan(n).fading}dispose(){this._clearTimer()}_clearTimer(){this._timer!==null&&(this.clearTimer(this._timer),this._timer=null)}};var mp=Object.freeze({base:10,overlay:20,heatmap:30,top:40,pathImage:50,selection:60,highlight:70,ruler:80}),ck={depthCompare:"always",depthWriteEnabled:!1},Hxt=250,qxt=4,W5e=300,Ghn=1,jhn=2,$hn=300,Vhn=300,Whn=400,Hhn=1e3,Xxt=100,qhn=.05,Yxt=1200,Zxt=30;function Z1(s,n=1){if(Array.isArray(s)){let u=s.length>3?s[3]:255;return[s[0],s[1],s[2],Math.round(u*n)]}let r=String(s||"#000").replace("#","");r.length===3&&(r=r.split("").map(u=>u+u).join(""));let c=parseInt(r.slice(0,6),16)||0;return[c>>16&255,c>>8&255,c&255,Math.round(255*n)]}function Xhn(s){return 1-Math.pow(1-s,3)}function Yhn(s){return s<.5?4*s*s*s:1-Math.pow(2-2*s,3)/2}function Zhn(){let s=new Map;return{on(n,r){for(let c of n.split(/\s+/))s.has(c)||s.set(c,new Set),s.get(c).add(r)},off(n,r){for(let c of n.split(/\s+/))s.get(c)?.delete(r)},emit(n,r){for(let c of[...s.get(n)||[]])c(r)}}}function Kxt(s,n={}){let r=n.deckApi!==void 0?n.deckApi:globalThis.deck,c=n.copyCanvas||z5e,u={smooth:()=>!1,doubleBuffer:()=>!0,defer:()=>!1,...n.prefs||{}},d=n.tileSize||(()=>240),b=n.dpr||(()=>typeof devicePixelRatio=="number"?devicePixelRatio:1),w=n.raf||(Me=>requestAnimationFrame(Me)),_=n.now||(()=>performance.now()),x=Zhn(),T={target:[0,0],zoom:0,width:1,height:1},M={minZoom:-1/0,maxZoom:Zxt},L=null,I=!1,D=[],F=[],O=null,z=null,Z=!1,H=!1,te=0,se=new Set,ne=!1;s.classList.add("or-view");let ue=document.createElement("div");ue.className="or-view-canvas",s.appendChild(ue);let Ce=document.createElement("div");Ce.className="or-view-markers",s.appendChild(Ce);let Q=new Map,me=new Map,tt=new Map,st=new Map,at=new WeakMap,Ne=[],Qe=_T(qn,w),ot=new $he({isEnabled:()=>u.doubleBuffer(),isSmooth:()=>u.smooth(),now:_,onChange:()=>Qe()}),xt=null;function fn(){return{dragPan:!0,dragRotate:!1,scrollZoom:!1,doubleClickZoom:!1,touchZoom:!n.isStatic,touchRotate:!1,keyboard:!1,inertia:!1}}function Xt(){return{target:[T.target[0],T.target[1],0],zoom:T.zoom,minZoom:M.minZoom,maxZoom:M.maxZoom}}function wn(){return new r.Deck({parent:ue,views:new r.OrthographicView({id:"main",flipY:!1,controller:fn()}),viewState:Xt(),layers:[],useDevicePixels:!0,deviceProps:{webgl:{preserveDrawingBuffer:!!n.preserveDrawingBuffer}},getCursor:({isDragging:Me})=>se.size?"crosshair":Me?"grabbing":"default",onViewStateChange:({viewState:Me})=>{if(L=null,Un(Me.target,Me.zoom),I){let et=_();F.push({t:et,target:[...T.target],zoom:T.zoom}),F=F.filter(ht=>et-ht.t<=Xxt)}return Xt()},onInteractionStateChange:Me=>{let et=!!(Me.isDragging||Me.isPanning||Me.isZooming||Me.inTransition);if(et!==I){if(I=et,et){F=[],Hi();return}queueMicrotask(()=>{!I&&!L&&!Tr()&&yr()})}},onLoad:()=>{cn(),Qe()},onAfterRender:()=>{let Me=D;D=[],Me.forEach(et=>et())}})}function cn(){let Me=xt.getCanvas&&xt.getCanvas();Me?.addEventListener("webglcontextlost",et=>{if(et.preventDefault(),ne)return;x.emit("contextlost");let ht=xt;xt=null,at=new WeakMap,Ne=[];try{ht.finalize?.()}catch{}Me.remove();try{xt=wn(),x.emit("contextrestored")}catch(on){x.emit("contextfailed",on)}Qe()})}r&&typeof r.Deck=="function"&&(xt=wn());function bi(){let Me=b(),et=Math.max(1,Math.floor(s.clientWidth*Me)/Me),ht=Math.max(1,Math.floor(s.clientHeight*Me)/Me),on=et!==T.width||ht!==T.height;return T.width=et,T.height=ht,ue.style.width=et+"px",ue.style.height=ht+"px",on}bi();let jt=null;typeof ResizeObserver=="function"&&(jt=new ResizeObserver(()=>gn()),jt.observe(s));function gn(){bi()?(Zi(),x.emit("resize",Zn())):Qe()}function Un(Me,et,{tiles:ht=!0}={}){let on=rk(et,M),Ri=on!==T.zoom;T.target=[Me[0],Me[1]],T.zoom=on,Zi(Ri,ht)}function Zi(Me=!1,et=!0){xt&&xt.setProps({viewState:Xt()}),Me&&x.emit("zoom"),x.emit("move"),et&&_n(),Qe()}function Hi(){H||(H=!0,x.emit("movestart"))}function yr(){if(L||I)return;let Me=Math.round(T.zoom);if(Math.abs(Me-T.zoom)>1e-9){xr({target:Nhe(T,[T.width/2,T.height/2],Me),zoom:Me},{anchor:null});return}T.target=lxt(T,b());let et=H;H=!1,Zi(),et&&(x.emit("moveend"),x.emit("zoomend"))}function Tr(){let Me=F;if(F=[],!u.smooth()||Me.length<2)return!1;let et=Me[0],ht=Me[Me.length-1],on=ht.t-et.t;if(on<=0||_()-ht.t>Xxt||et.zoom!==ht.zoom)return!1;let Ri=(ht.target[0]-et.target[0])/on,di=(ht.target[1]-et.target[1])/on;return Math.hypot(Ri,di)*Math.pow(2,T.zoom)qxt?0:Hxt}function xr(Me,{anchor:et=null,ms:ht=void 0,settle:on=!0,curve:Ri=!1}={}){Me={target:Me.target,zoom:rk(Me.zoom,M)};let di=Ri&&ht===void 0?oe(Me):null;if(ht===void 0&&(ht=di?di.ms:Ei(Me)),Hi(),Me.zoom!==T.zoom&&x.emit("zoomstart"),ht<=0){L=null;let er=on&&!I;Un(Me.target,Me.zoom,{tiles:!er}),on&&yr();return}z=null,L={from:{...T,target:[...T.target]},to:Me,anchor:et,start:di?null:_(),created:_(),ms:ht,flight:di},_n(),it()}function oe(Me){if(!u.smooth()||!(Math.hypot(Me.target[0]-T.target[0],Me.target[1]-T.target[1])*Math.pow(2,Math.min(T.zoom,Me.zoom))>jhn*Math.max(T.width,T.height))&&Math.abs(Me.zoom-T.zoom)<=qxt)return null;let on=uxt(T,{...T,...Me}),Ri=1/0,di=null;for(let Js=0;Js<=16;Js++){let $i=on.at(Js/16);Ri=Math.min(Ri,$i.zoom);let Vs=_O({...T,...$i});di=di?[Math.min(di[0],Vs[0]),Math.min(di[1],Vs[1]),Math.max(di[2],Vs[2]),Math.max(di[3],Vs[3])]:Vs}let er=Math.max(0,k5e(Ri)),ms=KW(di,er,d());return{path:on,ms:Math.min(Hhn,Math.max(Whn,Vhn*on.S)),apex:ms?{z:er,range:ms}:null}}function de(Me){return!Me||[...Q.values()].every(et=>!et.visible||et.grid.settledIn(Me.z,Me.range))}function it(){if(!L||ne)return;if(L.start===null){if(!de(L.flight.apex)&&_()-L.created<$hn){w(it);return}L.start=_()}let Me=Math.min(1,(_()-L.start)/L.ms),et=Xhn(Me),ht=L.from.zoom+(L.to.zoom-L.from.zoom)*et,on;if(L.flight?{target:on,zoom:ht}=L.flight.path.at(Yhn(Me)):L.anchor?on=Nhe(L.from,L.anchor,ht):on=[L.from.target[0]+(L.to.target[0]-L.from.target[0])*et,L.from.target[1]+(L.to.target[1]-L.from.target[1])*et],Me>=1){let Ri=L.to;z=L.flight?L.flight.apex:null,L=null,Un(Ri.target,Ri.zoom),yr();return}Un(on,ht),w(it)}function We(){return L?{...T,target:L.to.target,zoom:L.to.zoom}:T}function _n(){if(Q.size===0)return;let Me=u.doubleBuffer(),et=rk(k5e(T.zoom,{targetZoom:L?L.to.zoom:null,hidingNewLevels:Me}),{minZoom:0,maxZoom:Zxt}),ht=We(),on=KW(_O(ht),et,d()),Ri=Fhe(on),di=ot.shownZ,er=u.defer()&&I;er||ot.setZoom(et,{hasContent:[...Q.values()].some(Vs=>Vs.visible&&di!==null&&Vs.grid.hasContentAt(di))});let ms=[];et>0&&!L&&!I&&!H&&ot.pendingZ===null&&(O=et-1,ms.push({z:O,range:KW(R5e(_O(ht),Ghn),O,d())}));let Js=Er();Js&&ms.push({...Js,background:!1});let $i=L?KW(_O(T),et,d()):null;for(let Vs of Q.values())Vs.visible&&!er&&Vs.grid.update({z:et,range:on,ring:Ri,extra:ms,hold:$i});_t()}function Er(){return L&&L.flight&&L.flight.apex||z}function qi(Me){let et=[];for(let ht of[Er()?.z,ot.pendingZ])ht!=null&&!et.includes(ht)&&!Me.some(on=>on.z===ht)&&et.push(ht);return et}function Te(){Z||(Z=!0,queueMicrotask(()=>{Z=!1,ne||_n()}))}function ve(){for(let Me of Q.values())if(Me.visible&&!Me.grid.isSettled())return!1;return!0}function _t(Me){let et=ot.check({settled:ve(),animating:!!L});et&&ot.pendingZ===null&&Te();let ht=!1;z&&!L&&ot.isIdle()&&ve()&&(z=null,ht=!0),(et||ht||!Me||mn(Me.z))&&Qe()}function mn(Me){let et=ot.plan(_()).draw;return et.some(ht=>ht.z===Me)||qi(et).includes(Me)}function yn(Me,{order:et,source:ht,visible:on=!0}){let Ri={load:(er,ms)=>ht.load(er,ms),release:er=>{let ms=er&&at.get(er);ms&&(at.delete(er),Ne.push(ms)),ht.release?.(er)}},di={id:Me,order:et,visible:on,grid:new Uhe({source:Ri,onChange:er=>_t(er)})};return Q.set(Me,di),_n(),{id:Me,setVisible(er){di.visible!==!!er&&(di.visible=!!er,di.visible||di.grid.clear(),_n())},isVisible:()=>di.visible,refresh(){di.visible&&(di.grid.refresh(),Qe())},remove(){di.grid.clear(),Q.delete(Me),Qe()}}}function Sn(Me){if(!xt||!xt.device)return Me.image;let et=at.get(Me);if(!et){try{et=xt.device.createTexture({data:Me.image,width:Me.width,height:Me.height,mipLevels:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}})}catch{return Me.image}at.set(Me,et)}return et}function yi(Me){if(Me>=te)return 1;let et=(Yxt-(te-Me))%400/400;return 1-.7*(.5-.5*Math.cos(2*Math.PI*et))}let hi=new WeakMap,ri=null;function Ge(Me){let et=d();et!==ri&&(hi=new WeakMap,ri=et);let ht=hi.get(Me);return ht||(ht=cxt(Me.z,Me.x,Me.y,et),hi.set(Me,ht)),ht}function Pe(Me,et,ht,on,Ri,di){for(let er of et.grid.drawableTilesAt(ht)){let ms=Ge(er);I5e(ms,on)&&Me.push({order:et.order,props:{id:`${et.id}:${Ri}${er.key}`,image:Sn(er.drawable),bounds:ms,opacity:di,parameters:ck}})}}function ke(Me,et){let ht=[],on=ot.plan(Me);if(!on.fading&&ot.pendingZ===null&&on.draw.length>0){let Js=[...on.draw.map($i=>$i.z),O,Er()?.z].filter($i=>$i!=null);for(let $i of Q.values())$i.grid.prune(Js)}let Ri=yi(Me),di=[...Q.values()].sort((Js,$i)=>Js.order-$i.order),er=di.find(Js=>Js.visible),ms=qi(on.draw);for(let Js of di)if(Js.visible){Js===er&&ms.length>0&&ht.push(...dt(Js,ms,on.draw,et,Ri));for(let $i of on.draw)Pe(ht,Js,$i.z,et,"",$i.opacity*Ri)}return{layers:ht,animate:on.fading||MeVs.z===Js.z)||Js.loading&&!Js.drawable)continue;let $i=Ge(Js);if(I5e($i,on)){let[Vs,dh,Lm,mg]=$i;ms.push([[Vs-er,dh-er],[Lm+er,dh-er],[Lm+er,mg+er],[Vs-er,mg+er]])}}return ms.length&&di.push({order:Me.order,kind:"SolidPolygonLayer",props:{id:`${Me.id}:mask`,data:ms,getPolygon:Js=>Js,getFillColor:Ye(),parameters:ck}}),di}function Ye(){let Me=(getComputedStyle(s).backgroundColor||"").match(/[\d.]+/g);return!Me||Me.length<3||Me.length>3&&Number(Me[3])===0?[0,0,0,255]:[Number(Me[0]),Number(Me[1]),Number(Me[2]),255]}function ct(Me,et,ht){let on=[],Ri=[],di=[],er=[];for(let $i of et){if($i.kind==="circle"){er.push($i);continue}let Vs=$i.kind==="rect"?[[$i.rect[0],$i.rect[1]],[$i.rect[2],$i.rect[1]],[$i.rect[2],$i.rect[3]],[$i.rect[0],$i.rect[3]]]:$i.points;if($i.fill&&Ri.push({polygon:Vs,color:$i.fill}),$i.stroke){let dh=$i.kind==="rect"||$i.closed;di.push({path:dh?[...Vs,Vs[0]]:Vs,color:$i.stroke,width:$i.width||1,dash:$i.dash||null})}}Ri.length&&on.push({order:ht,kind:"SolidPolygonLayer",props:{id:`${Me}:fill`,data:Ri,getPolygon:$i=>$i.polygon,getFillColor:$i=>$i.color,parameters:ck}});let ms=di.filter($i=>!$i.dash),Js=di.filter($i=>$i.dash);if(ms.length&&on.push({order:ht,kind:"PathLayer",props:{id:`${Me}:stroke`,data:ms,widthUnits:"pixels",getPath:$i=>$i.path,getColor:$i=>$i.color,getWidth:$i=>$i.width,parameters:ck}}),Js.length){let $i={id:`${Me}:dash`,data:Js,widthUnits:"pixels",getPath:Vs=>Vs.path,getColor:Vs=>Vs.color,getWidth:Vs=>Vs.width,getDashArray:Vs=>Vs.dash.map(dh=>dh/Vs.width),dashJustified:!0,parameters:ck};r?.PathStyleExtension&&($i.extensions=[new r.PathStyleExtension({dash:!0})]),on.push({order:ht,kind:"PathLayer",props:$i})}return er.length&&on.push({order:ht,kind:"ScatterplotLayer",props:{id:`${Me}:circle`,data:er,radiusUnits:"pixels",lineWidthUnits:"pixels",getPosition:$i=>$i.center,getRadius:$i=>$i.radius,stroked:!0,filled:!0,getLineColor:$i=>$i.stroke||[0,0,0,0],getFillColor:$i=>$i.fill||[0,0,0,0],getLineWidth:$i=>$i.width||1,parameters:ck}}),on}function Ze(){let Me=[];for(let et of me.values())Me.push(...et);return Me.push(...tt.values()),Me}function Ke(Me){return Me.map(et=>new r[et.kind||"BitmapLayer"](et.props))}let gt=0;function qn(){if(ne)return;let Me=_(),et=ke(Me,R5e(_O(T),.5)),ht=[...et.layers,...Ze()].sort((on,Ri)=>on.order-Ri.order);gt=ht.length,xt&&xt.setProps({layers:Ke(ht)});for(let on of Ne.splice(0))on.destroy?.();ti(),et.animate&&Qe(),x.emit("render")}function xi(Me=32,et=20){let ht=Q.get("base");if(!ht)return null;let on=d(),Ri=ot.plan(_()).draw,di=[...Ri,...qi(Ri).map(Js=>({z:Js}))],er=0,ms=0;for(let Js=0;Js=on||dh>=on)continue;er++,di.some(({z:mg})=>{let kv=on/2**mg,Rv=ht.grid.tiles.get(yO(mg,Math.floor(Vs/kv),Math.floor((on-dh)/kv)));return Rv&&(Rv.drawable||!Rv.loading)})&&ms++}return er?ms/er:null}function Bi(Me){return st.has(Me)||st.set(Me,{visible:!0,items:new Map}),st.get(Me)}function xn(Me,et){let[ht,on]=Ohe(Me.world,T);Me.el.style.display=et?"":"none",Me.el.style.transform=`translate(${ht}px, ${on}px)`+(Me.center?" translate(-50%, -50%)":"")}function Je(Me){for(let et of Me.items.values())xn(et,Me.visible)}function ti(){for(let Me of st.values())Je(Me)}function Zn(){return{width:T.width,height:T.height}}let rr={DRAW_ORDER:mp,getContainer:()=>s,getSize:Zn,getZoom:()=>T.zoom,getTargetZoom:()=>L?L.to.zoom:T.zoom,getCenter:()=>[...T.target],getViewState:()=>({...T,target:[...T.target]}),isAnimating:()=>!!L,isMoving:()=>H,project:Me=>Ohe(Me,T),unproject:Me=>vO(Me,T),on:x.on,off:x.off,setLimits({minZoom:Me,maxZoom:et}={}){Me!==void 0&&(M.minZoom=Me),et!==void 0&&(M.maxZoom=et);let ht=rk(T.zoom,M);ht!==T.zoom?Un(T.target,ht):xt&&xt.setProps({viewState:Xt()}),x.emit("limits")},getLimits:()=>({...M}),setView(Me,et=T.zoom,{animate:ht}={}){let on={target:[Me[0],Me[1]],zoom:et};xr(on,ht===!1?{ms:0}:{curve:!0})},fitWorldRect(Me,{padding:et=[0,0],animate:ht}={}){let on=axt(Me,T,{padding:et,...M});xr(on,ht===!1?{ms:0}:{curve:!0})},zoomAround(Me,et,{animate:ht,settle:on=!0}={}){let Ri=rk(rr.getTargetZoom()+et,M),di=We(),er=Me||[T.width/2,T.height/2],ms=Nhe(di,er,Ri);xr({target:ms,zoom:Ri},ht===!1?{ms:0,settle:on}:{anchor:Me?er:null})},zoomIn:()=>rr.zoomAround(null,1),zoomOut:()=>rr.zoomAround(null,-1),panByPx(Me,et,{animate:ht}={}){let on=We(),Ri=Math.pow(2,on.zoom),di=[on.target[0]+Me/Ri,on.target[1]-et/Ri],er=ht===!1||!u.smooth()?0:Hxt;xr({target:di,zoom:on.zoom},{ms:er})},invalidateSize:gn,applyPrefs(){_n()},addTileSlot:yn,setOverlay(Me,et,{order:ht=mp.selection}={}){!et||et.length===0?me.delete(Me):me.set(Me,ct(Me,et,ht)),Qe()},hasOverlay:Me=>me.has(Me),setImageOverlay(Me,et,{order:ht=mp.pathImage}={}){et?tt.set(Me,{order:ht,kind:"BitmapLayer",props:{id:`image:${Me}`,image:et.image,bounds:et.rect,parameters:ck}}):tt.delete(Me),Qe()},addMarker(Me,et,ht,on,{center:Ri=!1}={}){let di=Bi(Me),er=di.items.get(et);er&&er.el.remove(),on.classList.add("or-view-marker"),Ce.appendChild(on);let ms={el:on,world:[ht[0],ht[1]],center:Ri};return di.items.set(et,ms),xn(ms,di.visible),on},moveMarker(Me,et,ht){let on=Bi(Me),Ri=on.items.get(et);Ri&&(Ri.world=[ht[0],ht[1]],xn(Ri,on.visible))},clearMarkers(Me){let et=Bi(Me);for(let ht of et.items.values())ht.el.remove();et.items.clear()},setMarkerGroupVisible(Me,et){let ht=Bi(Me);ht.visible=!!et,Je(ht)},setCursorMode(Me,et=!0){et?se.add(Me):se.delete(Me),s.classList.toggle(`${Me}-mode-cursor`,!!et);let ht=xt&&xt.getCanvas&&xt.getCanvas();ht&&(ht.style.cursor=se.size?"crosshair":"default")},flashTiles(){te=_()+Yxt,Qe()},whenTilesSettled({timeoutMs:Me=6e3}={}){let et=_()+Me;return new Promise(ht=>{let on=()=>{if(ve()&&ot.isIdle()&&!L&&!H||_()>=et){ht();return}setTimeout(on,32)};on()})},captureCanvas({timeoutMs:Me=500}={}){return xt?.getCanvas()?(qn(),new Promise(et=>{let ht=null,on=()=>{clearTimeout(ht),D=D.filter(di=>di!==on);let Ri=xt?.getCanvas();et(Ri?{image:c(Ri),rect:Ri.getBoundingClientRect()}:null)};D.push(on),ht=setTimeout(()=>{xt?.redraw("capture"),on()},Me)})):Promise.resolve(null)},redraw:()=>Qe(),debugSnapshot(){let Me=ot.plan();return{zoom:T.zoom,target:[...T.target],width:T.width,height:T.height,animating:!!L,moving:H,interacting:I,shownZ:ot.shownZ,pendingZ:ot.pendingZ,fading:Me.fading,drawLevels:Me.draw,layers:gt,coverage:xi(),overlays:[...me.keys()],markers:Object.fromEntries([...st].map(([et,ht])=>[et,ht.items.size])),slots:[...Q.values()].map(et=>({id:et.id,visible:et.visible,settled:et.grid.isSettled(),...et.grid.stats()}))}},destroy(){ne=!0,jt?.disconnect(),ot.dispose();for(let Me of Q.values())Me.grid.clear();xt?.finalize?.()}};return rr}var Khn=4.000244140625;function Jhn(s){return s.deltaMode!==0?!0:s.deltaX!==0||s.deltaY===0?!1:Number.isInteger(s.deltaY)&&Math.abs(s.deltaY)>=50||s.deltaY%Khn===0}function Qhn(s){let n=Math.abs(s);return n<.2?0:Math.sign(s)*Math.max(1,Math.round(n))}function edn(s,n){let c=1;return s.deltaMode===1?c=16:s.deltaMode===2&&(c=n.clientHeight||16),[s.deltaX*c,s.deltaY*c]}function tdn(s,n,r){let c=r?3*n:n;switch(s){case"ArrowLeft":return[-c,0];case"ArrowRight":return[c,0];case"ArrowUp":return[0,-c];case"ArrowDown":return[0,c];default:return null}}function Qxt(s,n={}){let r=s.getContainer(),c=n.isStatic||(()=>!1),u=n.wheelZoom||(()=>!0),d=n.arrowStep||(()=>80),b=n.gestureIdleMs??200,w=n.contextEnabled||(()=>!0),_=[],x=(ne,ue,Ce,Q)=>{ne.addEventListener(ue,Ce,Q),_.push(()=>ne.removeEventListener(ue,Ce,Q))},T=ne=>{let ue=r.getBoundingClientRect();return[ne.clientX-ue.left,ne.clientY-ue.top]},M=ne=>s.unproject(T(ne)),L=ne=>ne.target===r||!!ne.target?.closest?.(".or-view-canvas");r.tabIndex<0&&(r.tabIndex=0);let I=null;function D(ne,ue){I||(I={z0:s.getZoom()}),I.pt=ne,clearTimeout(I.timer),I.timer=setTimeout(F,b),s.zoomAround(ne,ue,{animate:!1,settle:!1})}function F(){if(!I)return;let ne=I;I=null,clearTimeout(ne.timer);let ue=s.getZoom();s.zoomAround(ne.pt,ne.z0+Qhn(ue-ne.z0)-ue)}_.push(()=>{clearTimeout(I?.timer),I=null}),x(r,"wheel",ne=>{if(ne.preventDefault(),c())return;let ue=Jhn(ne);if(!ue&&ne.ctrlKey){D(T(ne),-ne.deltaY/(100*Math.LN2));return}if(u()===ne.ctrlKey){let[Ce,Q]=edn(ne,r);s.panByPx(Ce,Q,{animate:!1});return}if(!ue){D(T(ne),-ne.deltaY/100);return}F(),s.zoomAround(T(ne),ne.deltaY<0?1:-1)},{passive:!1}),x(r,"keydown",ne=>{if(ne.altKey||ne.ctrlKey||ne.metaKey)return;let ue=tdn(ne.key,d(),ne.shiftKey);if(ue){ne.preventDefault(),s.panByPx(ue[0],ue[1]);return}if(c())return;let Ce={"+":1,"=":1,"-":-1,_:-1};ne.key in Ce&&(ne.preventDefault(),s.zoomAround(null,Ce[ne.key]*(ne.shiftKey?3:1)))});let O=null,z=null;x(r,"pointerdown",ne=>{ne.button!==0||!L(ne)||(r.focus({preventScroll:!0}),O={x:ne.clientX,y:ne.clientY,moved:!1,box:ne.shiftKey&&!c()},O.box&&ne.stopPropagation())},{capture:!0}),x(window,"pointermove",ne=>{if(!O)return;let ue=ne.clientX-O.x,Ce=ne.clientY-O.y;(Math.abs(ue)>3||Math.abs(Ce)>3)&&(O.moved=!0),O.box&&O.moved&&(z=Jxt(z,O,ne))}),x(window,"pointerup",ne=>{if(!O||ne.button!==0)return;let ue=O;if(O=null,z&&(z.remove(),z=null),ue.box&&ue.moved){se(ue,ne);return}!ue.moved&&n.onClick&&te(ne)&&n.onClick(M(ne),ne)}),x(r,"dblclick",ne=>{c()||!L(ne)||s.zoomAround(T(ne),ne.shiftKey?-1:1)});let Z=null,H=null;x(r,"contextmenu",ne=>ne.preventDefault()),x(r,"pointerdown",ne=>{ne.button!==2||c()||!L(ne)||(ne.stopPropagation(),Z={x:ne.clientX,y:ne.clientY})},{capture:!0}),x(window,"pointermove",ne=>{if(!Z)return;let ue=ne.clientX-Z.x,Ce=ne.clientY-Z.y;(H||Math.abs(ue)>=4&&Math.abs(Ce)>=4)&&(H=Jxt(H,Z,ne))}),x(window,"pointerup",ne=>{if(!Z||ne.button!==2)return;let ue=Z;if(Z=null,H){H.remove(),H=null,se(ue,ne);return}te(ne)&&w()&&n.onContextClick&&n.onContextClick(M(ne),ne)}),x(r,"pointermove",ne=>{n.onMove&&n.onMove(M(ne),ne)}),x(r,"pointerleave",ne=>{n.onLeave&&n.onLeave(ne)});function te(ne){let ue=r.getBoundingClientRect();return ne.clientX>=ue.left&&ne.clientX<=ue.right&&ne.clientY>=ue.top&&ne.clientY<=ue.bottom}function se(ne,ue){let Ce=r.getBoundingClientRect(),Q=s.unproject([ne.x-Ce.left,ne.y-Ce.top]),me=s.unproject([ue.clientX-Ce.left,ue.clientY-Ce.top]);s.fitWorldRect([Math.min(Q[0],me[0]),Math.min(Q[1],me[1]),Math.max(Q[0],me[0]),Math.max(Q[1],me[1])])}return{dispose(){for(let ne of _.splice(0))ne()}}}function Jxt(s,n,r){return s||(s=document.createElement("div"),s.className="rubber-band",document.body.appendChild(s)),s.style.left=Math.min(n.x,r.clientX)+"px",s.style.top=Math.min(n.y,r.clientY)+"px",s.style.width=Math.abs(r.clientX-n.x)+"px",s.style.height=Math.abs(r.clientY-n.y)+"px",s}var uk=class s{constructor(n,r,c){this._app=n,this._redrawAllLayers=r,this._refreshOverlay=c||r,this._currentTab="setup",this._setupPaths=[],this._holdPaths=[],this._selectedPathIndex=-1,this._detailTab="data",this._selectedDetailIndex=-1,this._sortCol="slack",this._sortAscending=!0,this._build()}_build(){let n=document.createElement("div");n.className="timing-widget";let r=document.createElement("div");r.className="timing-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",la(this._app)&&(this._updateBtn.style.display="none"),this._pathCountLabel=document.createElement("span"),this._pathCountLabel.className="timing-path-count",r.appendChild(this._updateBtn),r.appendChild(this._pathCountLabel),n.appendChild(r),n.appendChild(this._buildConePanel());let c=document.createElement("div");c.className="timing-tab-bar",this._setupTab=this._makeTab("Setup",!0),this._holdTab=this._makeTab("Hold",!1),c.appendChild(this._setupTab),c.appendChild(this._holdTab),n.appendChild(c),this._pathTableContainer=document.createElement("div"),this._pathTableContainer.className="timing-path-table-container",this._pathTable=document.createElement("table"),this._pathTable.className="timing-table",this._pathTableContainer.appendChild(this._pathTable),n.appendChild(this._pathTableContainer);let u=document.createElement("div");u.className="timing-tab-bar",this._dataTab=this._makeTab("Data Path",!0),this._captureTab=this._makeTab("Capture Path",!1),u.appendChild(this._dataTab),u.appendChild(this._captureTab),n.appendChild(u),this._detailTableContainer=document.createElement("div"),this._detailTableContainer.className="timing-detail-table-container",this._detailTable=document.createElement("table"),this._detailTable.className="timing-table",this._detailTableContainer.appendChild(this._detailTable),n.appendChild(this._detailTableContainer),this._headerTooltip=document.createElement("div"),this._headerTooltip.className="or-tooltip or-tooltip-fixed",n.appendChild(this._headerTooltip),this.element=n,this._bindEvents(),la(this._app)&&setTimeout(()=>this.update(),0)}_makeTab(n,r){let c=document.createElement("button");return c.className="timing-tab"+(r?" active":""),c.textContent=n,c}_bindEvents(){this._setupTab.addEventListener("click",()=>{this._currentTab="setup",this._setupTab.classList.add("active"),this._holdTab.classList.remove("active"),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}),this._holdTab.addEventListener("click",()=>{this._currentTab="hold",this._holdTab.classList.add("active"),this._setupTab.classList.remove("active"),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}),this._dataTab.addEventListener("click",()=>{this._detailTab="data",this._dataTab.classList.add("active"),this._captureTab.classList.remove("active"),this._renderDetailTable()}),this._captureTab.addEventListener("click",()=>{this._detailTab="capture",this._captureTab.classList.add("active"),this._dataTab.classList.remove("active"),this._renderDetailTable()}),this._updateBtn.addEventListener("click",()=>this.update()),this._pathTableContainer.setAttribute("tabindex","0"),this._pathTableContainer.style.outline="none",this._pathTableContainer.addEventListener("keydown",n=>{if(n.key==="ArrowDown"){n.preventDefault();let r=this._pathTable.querySelectorAll("tbody tr");this._selectedPathIndex0&&this._selectPathRow(this._selectedPathIndex-1))}),this._detailTableContainer.setAttribute("tabindex","0"),this._detailTableContainer.style.outline="none",this._detailTableContainer.addEventListener("keydown",n=>{if(n.key==="ArrowDown"){n.preventDefault();let r=this._detailTable.querySelectorAll("tbody tr");this._selectedDetailIndex0&&this._selectDetailRow(this._selectedDetailIndex-1))})}_buildConePanel(){let n=document.createElement("div");n.className="timing-cone-panel";let r=document.createElement("span");r.className="timing-cone-title",r.textContent="Timing cone:",n.appendChild(r);let c=(T,M,L=!1)=>{let I=document.createElement("input");I.type="checkbox",I.id=T,I.checked=L;let D=document.createElement("label");return D.htmlFor=T,D.textContent=M,{input:I,lbl:D}},u=c("cone-fanin","Fanin",!0),d=c("cone-fanout","Fanout",!0);this._coneFanin=u.input,this._coneFanout=d.input,n.append(u.input,u.lbl,d.input,d.lbl);let b=T=>{let M=document.createElement("label");M.className="timing-cone-depth-label",M.textContent=T;let L=document.createElement("input");return L.type="number",L.min="0",L.value="0",L.className="timing-cone-depth",L.title="0 = unlimited",M.appendChild(L),{lbl:M,input:L}},w=b("in\u2264"),_=b("out\u2264");this._coneFaninDepth=w.input,this._coneFanoutDepth=_.input,n.append(w.lbl,_.lbl),this._coneColorMode=document.createElement("select"),this._coneColorMode.className="timing-cone-colormode";for(let[T,M]of[["slack","by slack"],["depth","by depth"]]){let L=document.createElement("option");L.value=T,L.textContent=M,this._coneColorMode.appendChild(L)}n.appendChild(this._coneColorMode);let x=c("cone-sync-schematic","Sync schematic");return this._coneSyncSchematic=x.input,n.append(x.input,x.lbl),this._coneApplyBtn=document.createElement("button"),this._coneApplyBtn.className="or-btn",this._coneApplyBtn.textContent="Cone",this._coneApplyBtn.title="Show the timing cone for the selected instance",this._coneClearBtn=document.createElement("button"),this._coneClearBtn.className="or-btn",this._coneClearBtn.textContent="Clear",n.append(this._coneApplyBtn,this._coneClearBtn),this._coneStatus=document.createElement("span"),this._coneStatus.className="timing-cone-status",n.appendChild(this._coneStatus),this._coneApplyBtn.addEventListener("click",()=>this._applyCone()),this._coneClearBtn.addEventListener("click",()=>this._clearCone()),n}_coneTarget(){return this._app.selectedInstanceName||""}async _applyCone(){let n=this._coneFanin.checked,r=this._coneFanout.checked;if(!n&&!r){this._coneStatus.textContent="select fanin and/or fanout";return}let c=this._coneTarget();if(!c){this._coneStatus.textContent="select an instance first";return}let u={type:"timing_cone",fanin:n,fanout:r,fanin_depth:Math.max(0,parseInt(this._coneFaninDepth.value,10)||0),fanout_depth:Math.max(0,parseInt(this._coneFanoutDepth.value,10)||0),color_mode:this._coneColorMode.value,inst_name:c};this._coneApplyBtn.disabled=!0,this._coneStatus.textContent="computing\u2026";try{let d=await this._app.websocketManager.request(u);this._refreshOverlay(),this._renderConeStatus(d),this._coneSyncSchematic.checked&&c&&document.dispatchEvent(new CustomEvent("openroad-cone-sync",{detail:{inst_name:c,fanin:u.fanin,fanout:u.fanout,fanin_depth:u.fanin_depth,fanout_depth:u.fanout_depth}}))}catch(d){this._coneStatus.textContent="cone error: "+(d.message||d)}this._coneApplyBtn.disabled=!1}_renderConeStatus(n){if(!n){this._coneStatus.textContent="";return}let r=n.node_count||0;if(r===0){this._coneStatus.textContent="empty cone";return}let c=r+" pins";if(n.color_mode==="depth")c+=`, depth \xB1${n.max_depth}`;else if(n.constrained){let u=n.time_unit||"";c+=`, slack ${lk(n.min_slack)}\u2026${lk(n.max_slack)}${u}`}else c+=", unconstrained";this._coneStatus.textContent=c}_clearCone(){this._app.websocketManager.request({type:"timing_cone",clear:!0}).then(()=>this._refreshOverlay()),this._coneStatus.textContent=""}showPaths(n,r){this._currentTab=n,n==="setup"?(this._setupPaths=[...r],this._setupTab.classList.add("active"),this._holdTab.classList.remove("active")):(this._holdPaths=[...r],this._holdTab.classList.add("active"),this._setupTab.classList.remove("active")),this._applySort(),this._selectedPathIndex=-1,this._pathCountLabel.textContent=r.length+" paths",this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...";try{let[n,r]=await Promise.all([this._app.websocketManager.request({type:"timing_report",is_setup:!0,max_paths:100}),this._app.websocketManager.request({type:"timing_report",is_setup:!1,max_paths:100})]);this._setupPaths=[...n.paths||[]],this._holdPaths=[...r.paths||[]],this._applySort(),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}catch(n){console.error("Timing fetch failed:",n)}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}_applySort(){for(let n of[this._setupPaths,this._holdPaths]){n.forEach((u,d)=>{u._originalIndex===void 0&&(u._originalIndex=d)});let r=this._sortAscending?1:-1,c=this._sortCol;n.sort((u,d)=>{let b=u[c],w=d[c],_=typeof b=="number"&&typeof w=="number"?b-w:String(b).localeCompare(String(w));return r*_})}}_showHeaderTooltip(n,r){if(n.buttons!==0){this._hideHeaderTooltip();return}let c=this._headerTooltip;c.textContent=r,c.style.display="block";let u=Math.min(n.clientX+12,window.innerWidth-c.offsetWidth-8);c.style.left=Math.max(0,u)+"px",c.style.top=n.clientY+14+"px"}_hideHeaderTooltip(){this._headerTooltip.style.display="none"}_sortBy(n){this._sortCol===n?this._sortAscending=!this._sortAscending:(this._sortCol=n,this._sortAscending=!0),this._applySort(),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}_clearTimingHighlight(){this._app.websocketManager.request({type:"timing_highlight",path_index:-1}).then(()=>this._refreshOverlay())}_selectPathRow(n){let r=this._pathTable.querySelectorAll("tbody tr");if(n<0||n>=r.length)return;this._selectedPathIndex=n;for(let d of r)d.classList.remove("selected");r[n].classList.add("selected"),r[n].scrollIntoView({block:"nearest"}),this._pathTableContainer.focus(),this._renderDetailTable();let u=(this._currentTab==="setup"?this._setupPaths:this._holdPaths)[n]?._originalIndex??n;this._app.websocketManager.request({type:"timing_highlight",path_index:u,is_setup:this._currentTab==="setup"}).then(()=>this._refreshOverlay()).catch(d=>console.error("timing_highlight error:",d))}_renderPathTable(){this._hideHeaderTooltip();let n=this._currentTab==="setup"?this._setupPaths:this._holdPaths;this._pathCountLabel.textContent=n.length+" paths";let r=this._pathTable.querySelectorAll("thead th"),c=Array.from(r,_=>_.style.width);this._pathTable.innerHTML="";let u=document.createElement("thead"),d=document.createElement("tr");for(let _ of s.PATH_COLS){let x=document.createElement("th");x.classList.add("sortable"),_.num&&x.classList.add("num"),x.textContent=_.label+(_.key===this._sortCol?this._sortAscending?" \u25B2":" \u25BC":""),_.tooltip&&(x.addEventListener("mousemove",T=>this._showHeaderTooltip(T,_.tooltip)),x.addEventListener("mouseleave",()=>this._hideHeaderTooltip())),x.addEventListener("click",()=>this._sortBy(_.key)),d.appendChild(x)}u.appendChild(d),this._pathTable.appendChild(u);let b=document.createElement("tbody"),w=n.reduce((_,x)=>Math.max(_,Math.abs(Number(x.slack)||0)),0);if(n.forEach((_,x)=>{let T=document.createElement("tr");x===this._selectedPathIndex&&T.classList.add("selected");for(let M of s.PATH_COLS){let L=document.createElement("td"),I=_[M.key];if(L.textContent=M.time?lk(I):I,M.num&&L.classList.add("num"),M.key==="slack"){let D=Number(_.slack);D<0&&L.classList.add("slack-negative"),Number.isFinite(D)&&w>0&&(L.classList.add("slack-cell",D<0?"slack-under":"slack-over"),L.style.setProperty("--slack-frac",String(Math.abs(D)/w)))}T.appendChild(L)}T.style.cursor="pointer",T.addEventListener("click",()=>this._selectPathRow(x)),b.appendChild(T)}),n.length===0){let _=document.createElement("tr"),x=document.createElement("td");x.colSpan=s.PATH_COLS.length,x.style.textAlign="center",x.style.color="var(--fg-secondary)",x.textContent=la(this._app)?"No timing data available":'Click "Update" to load timing paths',_.appendChild(x),b.appendChild(_)}this._pathTable.appendChild(b),ak(this._pathTable,c)}_selectDetailRow(n){let r=this._detailTable.querySelectorAll("tbody tr");if(n<0||n>=r.length)return;this._selectedDetailIndex=n;for(let w of r)w.classList.remove("timing-selected-row");r[n].classList.add("timing-selected-row"),r[n].scrollIntoView({block:"nearest"}),this._detailTableContainer.focus();let u=(this._currentTab==="setup"?this._setupPaths:this._holdPaths)[this._selectedPathIndex],d=this._detailTab==="data"?u.data_nodes:u.capture_nodes,b=u._originalIndex??this._selectedPathIndex;this._app.websocketManager.request({type:"timing_highlight",path_index:b,is_setup:this._currentTab==="setup",pin_name:d[n].pin}).then(()=>this._refreshOverlay())}_renderDetailTable(){let n=this._detailTable.querySelectorAll("thead th"),r=Array.from(n,x=>x.style.width);this._detailTable.innerHTML="",this._selectedDetailIndex=-1;let c=this._currentTab==="setup"?this._setupPaths:this._holdPaths;if(this._selectedPathIndex<0||this._selectedPathIndex>=c.length)return;let u=c[this._selectedPathIndex],d=this._detailTab==="data"?u.data_nodes:u.capture_nodes,b=document.createElement("thead"),w=document.createElement("tr");for(let x of s.DETAIL_COLS){let T=document.createElement("th");s.DETAIL_NUM_COLS.has(x)&&T.classList.add("num"),T.textContent=x,w.appendChild(T)}b.appendChild(w),this._detailTable.appendChild(b);let _=document.createElement("tbody");if(d.forEach((x,T)=>{let M=document.createElement("tr");x.clk&&M.classList.add("timing-clock-row"),[x.pin,x.fanout,x.rise?"\u2191":"\u2193",lk(x.time),lk(x.delay),lk(x.slew),lk(x.load)].forEach((I,D)=>{let F=document.createElement("td");s.DETAIL_NUM_COLS.has(s.DETAIL_COLS[D])&&F.classList.add("num"),F.textContent=I,M.appendChild(F)}),M.style.cursor="pointer",M.addEventListener("click",()=>this._selectDetailRow(T)),_.appendChild(M)}),this._detailTable.appendChild(_),ak(this._detailTable,r),!r[0]){let x=this._detailTable.querySelector("thead th");x&&(x.style.width="30ch")}}};function lk(s){return s==null?"":typeof s=="number"?s.toFixed(4):String(s)}uk.PATH_COLS=[{label:"Clock",key:"end_clk"},{label:"Required",key:"required",time:!0,num:!0},{label:"Arrival",key:"arrival",time:!0,num:!0},{label:"Slack",key:"slack",time:!0,num:!0},{label:"Skew",key:"skew",time:!0,num:!0,tooltip:`The difference in arrival times between +
`,document.body.appendChild(u);let d=()=>u.remove();u.addEventListener("click",_=>{_.target===u&&d()}),u.addEventListener("keydown",_=>{_.key==="Escape"&&d()}),u.querySelector(".cancel").addEventListener("click",d),u.querySelector(".modal-close").addEventListener("click",d);let b=u.querySelector(".modal-error"),w=(_,x)=>{b.textContent=_,b.style.display=_?"block":"none",b.classList.toggle("info",!!x)};return{overlay:u,close:d,okBtn:u.querySelector(".ok"),showError:w}}var Uhn=1e4,zhn=150,Ghn=3;function jhn(s){return 1-(1-s)*(1-s)}var $he=class{constructor({isEnabled:n=()=>!0,isSmooth:r=()=>!1,reducedMotion:c=nH,now:u=()=>performance.now(),setTimer:d=(T,M)=>setTimeout(T,M),clearTimer:b=T=>clearTimeout(T),timeoutMs:w=Uhn,fadeMs:_=zhn,onChange:x=()=>{}}={}){Object.assign(this,{isEnabled:n,isSmooth:r,reducedMotion:c,now:u,setTimer:d,clearTimer:b,timeoutMs:w,fadeMs:_,onChange:x}),this.shownZ=null,this.pendingZ=null,this.under=[],this.fade=null,this._timer=null}wantedZ(){return this.pendingZ!==null?this.pendingZ:this.shownZ}setZoom(n,{hasContent:r=!0}={}){n!==this.wantedZ()&&(this.endFade(),this._clearTimer(),this.shownZ===null?(this.shownZ=n,this.pendingZ=null,this.under=[]):r?n===this.shownZ?this.pendingZ=null:this.isEnabled()?(this.pendingZ=n,this.under=[],this._timer=this.setTimer(()=>this.reveal(),this.timeoutMs)):(this.under=[...this.under.filter(c=>c!==n),this.shownZ].slice(-Ghn),this.shownZ=n,this.pendingZ=null):(this.shownZ=n,this.pendingZ=null,this.under=this.under.filter(c=>c!==n)),this.onChange())}check({settled:n,animating:r=!1}){return this.pendingZ!==null?r||!n&&this.isEnabled()?!1:(this.reveal(),!0):this.under.length>0&&n&&!r?(this.under=[],this.onChange(),!0):!1}reveal(){if(this.pendingZ===null)return;this._clearTimer();let n=this.shownZ;this.shownZ=this.pendingZ,this.pendingZ=null;let r=this.isSmooth()&&!this.reducedMotion()?this.fadeMs:0;this.fade=r>0&&n!==null?{fromZ:n,toZ:this.shownZ,start:this.now(),ms:r}:null,this.onChange()}endFade(){this.fade&&(this.fade=null,this.onChange())}plan(n=this.now()){if(this.fade){let r=(n-this.fade.start)/this.fade.ms;if(r<1)return{draw:[{z:this.fade.fromZ,opacity:1},{z:this.fade.toZ,opacity:jhn(Math.max(0,r))}],fading:!0};this.fade=null}return this.shownZ===null?{draw:[],fading:!1}:this.pendingZ!==null?{draw:[{z:this.shownZ,opacity:1}],fading:!1}:this.under.length>0?{draw:[...this.under,this.shownZ].map(r=>({z:r,opacity:1})),fading:!1}:{draw:[{z:this.shownZ,opacity:1}],fading:!1}}isIdle(n=this.now()){return this.pendingZ===null&&this.under.length===0&&!this.plan(n).fading}dispose(){this._clearTimer()}_clearTimer(){this._timer!==null&&(this.clearTimer(this._timer),this._timer=null)}};var bp=Object.freeze({base:10,overlay:20,heatmap:30,top:40,pathImage:50,selection:60,highlight:70,ruler:80}),ck={depthCompare:"always",depthWriteEnabled:!1},qxt=250,Xxt=4,W5e=300,$hn=1,Vhn=2,Whn=300,Hhn=300,qhn=400,Xhn=1e3,Yxt=100,Yhn=.05,Zxt=1200,Kxt=30;function K1(s,n=1){if(Array.isArray(s)){let u=s.length>3?s[3]:255;return[s[0],s[1],s[2],Math.round(u*n)]}let r=String(s||"#000").replace("#","");r.length===3&&(r=r.split("").map(u=>u+u).join(""));let c=parseInt(r.slice(0,6),16)||0;return[c>>16&255,c>>8&255,c&255,Math.round(255*n)]}function Zhn(s){return 1-Math.pow(1-s,3)}function Khn(s){return s<.5?4*s*s*s:1-Math.pow(2-2*s,3)/2}function Jhn(){let s=new Map;return{on(n,r){for(let c of n.split(/\s+/))s.has(c)||s.set(c,new Set),s.get(c).add(r)},off(n,r){for(let c of n.split(/\s+/))s.get(c)?.delete(r)},emit(n,r){for(let c of[...s.get(n)||[]])c(r)}}}function Qhn(s){let n=s&&s.device&&s.device.info||{};return{gpuType:n.gpuType||"unknown",renderer:n.renderer||"",vendor:n.vendor||""}}function Jxt(s,n={}){let r=n.deckApi!==void 0?n.deckApi:globalThis.deck,c=n.copyCanvas||z5e,u={smooth:()=>!1,doubleBuffer:()=>!0,defer:()=>!1,...n.prefs||{}},d=n.tileSize||(()=>240),b=n.dpr||(()=>typeof devicePixelRatio=="number"?devicePixelRatio:1),w=n.raf||(Re=>requestAnimationFrame(Re)),_=n.now||(()=>performance.now()),x=Jhn(),T={target:[0,0],zoom:0,width:1,height:1},M={minZoom:-1/0,maxZoom:Kxt},L=null,I=!1,D=[],F=null,O=[],z=null,Z=null,H=!1,te=!1,oe=0,ne=new Set,ue=!1;s.classList.add("or-view");let Te=document.createElement("div");Te.className="or-view-canvas",s.appendChild(Te);let Q=document.createElement("div");Q.className="or-view-markers",s.appendChild(Q);let ge=new Map,Qe=new Map,st=new Map,at=new Map,Ne=new WeakMap,tt=[],ot=yT(_i,w),Tt=new $he({isEnabled:()=>u.doubleBuffer(),isSmooth:()=>u.smooth(),now:_,onChange:()=>ot()}),jt=null;function en(){return{dragPan:!0,dragRotate:!1,scrollZoom:!1,doubleClickZoom:!1,touchZoom:!n.isStatic,touchRotate:!1,keyboard:!1,inertia:!1}}function mn(){return{target:[T.target[0],T.target[1],0],zoom:T.zoom,minZoom:M.minZoom,maxZoom:M.maxZoom}}function cn(){return new r.Deck({parent:Te,views:new r.OrthographicView({id:"main",flipY:!1,controller:en()}),viewState:mn(),layers:[],useDevicePixels:!0,deviceProps:{webgl:{preserveDrawingBuffer:!!n.preserveDrawingBuffer}},getCursor:({isDragging:Re})=>ne.size?"crosshair":Re?"grabbing":"default",onViewStateChange:({viewState:Re})=>{if(L=null,Yi(Re.target,Re.zoom),I){let nt=_();O.push({t:nt,target:[...T.target],zoom:T.zoom}),O=O.filter(kt=>nt-kt.t<=Yxt)}return mn()},onInteractionStateChange:Re=>{let nt=!!(Re.isDragging||Re.isPanning||Re.isZooming||Re.inTransition);if(nt!==I){if(I=nt,nt){O=[],Tr();return}queueMicrotask(()=>{!I&&!L&&!Si()&&wr()})}},onLoad:()=>{bi(),F=Qhn(jt),x.emit("renderer",F),ot()},onAfterRender:()=>{let Re=D;D=[],Re.forEach(nt=>nt())}})}function bi(){let Re=jt.getCanvas&&jt.getCanvas();Re?.addEventListener("webglcontextlost",nt=>{if(nt.preventDefault(),ue)return;x.emit("contextlost");let kt=jt;jt=null,Ne=new WeakMap,tt=[];try{kt.finalize?.()}catch{}Re.remove();try{jt=cn(),x.emit("contextrestored")}catch(xn){x.emit("contextfailed",xn)}ot()})}r&&typeof r.Deck=="function"&&(jt=cn());function Vt(){let Re=b(),nt=Math.max(1,Math.floor(s.clientWidth*Re)/Re),kt=Math.max(1,Math.floor(s.clientHeight*Re)/Re),xn=nt!==T.width||kt!==T.height;return T.width=nt,T.height=kt,Te.style.width=nt+"px",Te.style.height=kt+"px",xn}Vt();let pn=null;typeof ResizeObserver=="function"&&(pn=new ResizeObserver(()=>qn()),pn.observe(s));function qn(){Vt()?($i(),x.emit("resize",ar())):ot()}function Yi(Re,nt,{tiles:kt=!0}={}){let xn=rk(nt,M),Ei=xn!==T.zoom;T.target=[Re[0],Re[1]],T.zoom=xn,$i(Ei,kt)}function $i(Re=!1,nt=!0){jt&&jt.setProps({viewState:mn()}),Re&&x.emit("zoom"),x.emit("move"),nt&&hr(),ot()}function Tr(){te||(te=!0,x.emit("movestart"))}function wr(){if(L||I)return;let Re=Math.round(T.zoom);if(Math.abs(Re-T.zoom)>1e-9){se({target:Nhe(T,[T.width/2,T.height/2],Re),zoom:Re},{anchor:null});return}T.target=lxt(T,b());let nt=te;te=!1,$i(),nt&&(x.emit("moveend"),x.emit("zoomend"))}function Si(){let Re=O;if(O=[],!u.smooth()||Re.length<2)return!1;let nt=Re[0],kt=Re[Re.length-1],xn=kt.t-nt.t;if(xn<=0||_()-kt.t>Yxt||nt.zoom!==kt.zoom)return!1;let Ei=(kt.target[0]-nt.target[0])/xn,Xi=(kt.target[1]-nt.target[1])/xn;return Math.hypot(Ei,Xi)*Math.pow(2,T.zoom)Xxt?0:qxt}function se(Re,{anchor:nt=null,ms:kt=void 0,settle:xn=!0,curve:Ei=!1}={}){Re={target:Re.target,zoom:rk(Re.zoom,M)};let Xi=Ei&&kt===void 0?de(Re):null;if(kt===void 0&&(kt=Xi?Xi.ms:Fr(Re)),Tr(),Re.zoom!==T.zoom&&x.emit("zoomstart"),kt<=0){L=null;let cr=xn&&!I;Yi(Re.target,Re.zoom,{tiles:!cr}),xn&&wr();return}Z=null,L={from:{...T,target:[...T.target]},to:Re,anchor:nt,start:Xi?null:_(),created:_(),ms:kt,flight:Xi},hr(),We()}function de(Re){if(!u.smooth()||!(Math.hypot(Re.target[0]-T.target[0],Re.target[1]-T.target[1])*Math.pow(2,Math.min(T.zoom,Re.zoom))>Vhn*Math.max(T.width,T.height))&&Math.abs(Re.zoom-T.zoom)<=Xxt)return null;let xn=uxt(T,{...T,...Re}),Ei=1/0,Xi=null;for(let Ks=0;Ks<=16;Ks++){let Bi=xn.at(Ks/16);Ei=Math.min(Ei,Bi.zoom);let io=_O({...T,...Bi});Xi=Xi?[Math.min(Xi[0],io[0]),Math.min(Xi[1],io[1]),Math.max(Xi[2],io[2]),Math.max(Xi[3],io[3])]:io}let cr=Math.max(0,k5e(Ei)),So=KW(Xi,cr,d());return{path:xn,ms:Math.min(Xhn,Math.max(qhn,Hhn*xn.S)),apex:So?{z:cr,range:So}:null}}function it(Re){return!Re||[...ge.values()].every(nt=>!nt.visible||nt.grid.settledIn(Re.z,Re.range))}function We(){if(!L||ue)return;if(L.start===null){if(!it(L.flight.apex)&&_()-L.created=1){let Ei=L.to;Z=L.flight?L.flight.apex:null,L=null,Yi(Ei.target,Ei.zoom),wr();return}Yi(xn,kt),w(We)}function En(){return L?{...T,target:L.to.target,zoom:L.to.zoom}:T}function hr(){if(ge.size===0)return;let Re=u.doubleBuffer(),nt=rk(k5e(T.zoom,{targetZoom:L?L.to.zoom:null,hidingNewLevels:Re}),{minZoom:0,maxZoom:Kxt}),kt=En(),xn=KW(_O(kt),nt,d()),Ei=Fhe(xn),Xi=Tt.shownZ,cr=u.defer()&&I;cr||Tt.setZoom(nt,{hasContent:[...ge.values()].some(io=>io.visible&&Xi!==null&&io.grid.hasContentAt(Xi))});let So=[];nt>0&&!L&&!I&&!te&&Tt.pendingZ===null&&(z=nt-1,So.push({z,range:KW(R5e(_O(kt),$hn),z,d())}));let Ks=qi();Ks&&So.push({...Ks,background:!1});let Bi=L?KW(_O(T),nt,d()):null;for(let io of ge.values())io.visible&&!cr&&io.grid.update({z:nt,range:xn,ring:Ei,extra:So,hold:Bi});gn()}function qi(){return L&&L.flight&&L.flight.apex||Z}function Me(Re){let nt=[];for(let kt of[qi()?.z,Tt.pendingZ])kt!=null&&!nt.includes(kt)&&!Re.some(xn=>xn.z===kt)&&nt.push(kt);return nt}function ve(){H||(H=!0,queueMicrotask(()=>{H=!1,ue||hr()}))}function wt(){for(let Re of ge.values())if(Re.visible&&!Re.grid.isSettled())return!1;return!0}function gn(Re){let nt=Tt.check({settled:wt(),animating:!!L});nt&&Tt.pendingZ===null&&ve();let kt=!1;Z&&!L&&Tt.isIdle()&&wt()&&(Z=null,kt=!0),(nt||kt||!Re||vn(Re.z))&&ot()}function vn(Re){let nt=Tt.plan(_()).draw;return nt.some(kt=>kt.z===Re)||Me(nt).includes(Re)}function Mn(Re,{order:nt,source:kt,visible:xn=!0}){let Ei={load:(cr,So)=>kt.load(cr,So),release:cr=>{let So=cr&&Ne.get(cr);So&&(Ne.delete(cr),tt.push(So)),kt.release?.(cr)}},Xi={id:Re,order:nt,visible:xn,grid:new Uhe({source:Ei,onChange:cr=>gn(cr)})};return ge.set(Re,Xi),hr(),{id:Re,setVisible(cr){Xi.visible!==!!cr&&(Xi.visible=!!cr,Xi.visible||Xi.grid.clear(),hr())},isVisible:()=>Xi.visible,refresh(){Xi.visible&&(Xi.grid.refresh(),ot())},remove(){Xi.grid.clear(),ge.delete(Re),ot()}}}function xi(Re){if(!jt||!jt.device)return Re.image;let nt=Ne.get(Re);if(!nt){try{nt=jt.device.createTexture({data:Re.image,width:Re.width,height:Re.height,mipLevels:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}})}catch{return Re.image}Ne.set(Re,nt)}return nt}function mi(Re){if(Re>=oe)return 1;let nt=(Zxt-(oe-Re))%400/400;return 1-.7*(.5-.5*Math.cos(2*Math.PI*nt))}let ri=new WeakMap,Ge=null;function Ae(Re){let nt=d();nt!==Ge&&(ri=new WeakMap,Ge=nt);let kt=ri.get(Re);return kt||(kt=cxt(Re.z,Re.x,Re.y,nt),ri.set(Re,kt)),kt}function Le(Re,nt,kt,xn,Ei,Xi){for(let cr of nt.grid.drawableTilesAt(kt)){let So=Ae(cr);I5e(So,xn)&&Re.push({order:nt.order,props:{id:`${nt.id}:${Ei}${cr.key}`,image:xi(cr.drawable),bounds:So,opacity:Xi,parameters:ck}})}}function ht(Re,nt){let kt=[],xn=Tt.plan(Re);if(!xn.fading&&Tt.pendingZ===null&&xn.draw.length>0){let Ks=[...xn.draw.map(Bi=>Bi.z),z,qi()?.z].filter(Bi=>Bi!=null);for(let Bi of ge.values())Bi.grid.prune(Ks)}let Ei=mi(Re),Xi=[...ge.values()].sort((Ks,Bi)=>Ks.order-Bi.order),cr=Xi.find(Ks=>Ks.visible),So=Me(xn.draw);for(let Ks of Xi)if(Ks.visible){Ks===cr&&So.length>0&&kt.push(...Ye(Ks,So,xn.draw,nt,Ei));for(let Bi of xn.draw)Le(kt,Ks,Bi.z,nt,"",Bi.opacity*Ei)}return{layers:kt,animate:xn.fading||Reio.z===Ks.z)||Ks.loading&&!Ks.drawable)continue;let Bi=Ae(Ks);if(I5e(Bi,xn)){let[io,gf,Q1,Lm]=Bi;So.push([[io-cr,gf-cr],[Q1+cr,gf-cr],[Q1+cr,Lm+cr],[io-cr,Lm+cr]])}}return So.length&&Xi.push({order:Re.order,kind:"SolidPolygonLayer",props:{id:`${Re.id}:mask`,data:So,getPolygon:Ks=>Ks,getFillColor:ct(),parameters:ck}}),Xi}function ct(){let Re=(getComputedStyle(s).backgroundColor||"").match(/[\d.]+/g);return!Re||Re.length<3||Re.length>3&&Number(Re[3])===0?[0,0,0,255]:[Number(Re[0]),Number(Re[1]),Number(Re[2]),255]}function Ze(Re,nt,kt){let xn=[],Ei=[],Xi=[],cr=[];for(let Bi of nt){if(Bi.kind==="circle"){cr.push(Bi);continue}let io=Bi.kind==="rect"?[[Bi.rect[0],Bi.rect[1]],[Bi.rect[2],Bi.rect[1]],[Bi.rect[2],Bi.rect[3]],[Bi.rect[0],Bi.rect[3]]]:Bi.points;if(Bi.fill&&Ei.push({polygon:io,color:Bi.fill}),Bi.stroke){let gf=Bi.kind==="rect"||Bi.closed;Xi.push({path:gf?[...io,io[0]]:io,color:Bi.stroke,width:Bi.width||1,dash:Bi.dash||null})}}Ei.length&&xn.push({order:kt,kind:"SolidPolygonLayer",props:{id:`${Re}:fill`,data:Ei,getPolygon:Bi=>Bi.polygon,getFillColor:Bi=>Bi.color,parameters:ck}});let So=Xi.filter(Bi=>!Bi.dash),Ks=Xi.filter(Bi=>Bi.dash);if(So.length&&xn.push({order:kt,kind:"PathLayer",props:{id:`${Re}:stroke`,data:So,widthUnits:"pixels",getPath:Bi=>Bi.path,getColor:Bi=>Bi.color,getWidth:Bi=>Bi.width,parameters:ck}}),Ks.length){let Bi={id:`${Re}:dash`,data:Ks,widthUnits:"pixels",getPath:io=>io.path,getColor:io=>io.color,getWidth:io=>io.width,getDashArray:io=>io.dash.map(gf=>gf/io.width),dashJustified:!0,parameters:ck};r?.PathStyleExtension&&(Bi.extensions=[new r.PathStyleExtension({dash:!0})]),xn.push({order:kt,kind:"PathLayer",props:Bi})}return cr.length&&xn.push({order:kt,kind:"ScatterplotLayer",props:{id:`${Re}:circle`,data:cr,radiusUnits:"pixels",lineWidthUnits:"pixels",getPosition:Bi=>Bi.center,getRadius:Bi=>Bi.radius,stroked:!0,filled:!0,getLineColor:Bi=>Bi.stroke||[0,0,0,0],getFillColor:Bi=>Bi.fill||[0,0,0,0],getLineWidth:Bi=>Bi.width||1,parameters:ck}}),xn}function Ke(){let Re=[];for(let nt of Qe.values())Re.push(...nt);return Re.push(...st.values()),Re}function pt(Re){return Re.map(nt=>new r[nt.kind||"BitmapLayer"](nt.props))}let Xn=0;function _i(){if(ue)return;let Re=_(),nt=ht(Re,R5e(_O(T),.5)),kt=[...nt.layers,...Ke()].sort((xn,Ei)=>xn.order-Ei.order);Xn=kt.length,jt&&jt.setProps({layers:pt(kt)});for(let xn of tt.splice(0))xn.destroy?.();ei(),nt.animate&&ot(),x.emit("render")}function Hi(Re=32,nt=20){let kt=ge.get("base");if(!kt)return null;let xn=d(),Ei=Tt.plan(_()).draw,Xi=[...Ei,...Me(Ei).map(Ks=>({z:Ks}))],cr=0,So=0;for(let Ks=0;Ks=xn||gf>=xn)continue;cr++,Xi.some(({z:Lm})=>{let b2=xn/2**Lm,zb=kt.grid.tiles.get(yO(Lm,Math.floor(io/b2),Math.floor((xn-gf)/b2)));return zb&&(zb.drawable||!zb.loading)})&&So++}return cr?So/cr:null}function _n(Re){return at.has(Re)||at.set(Re,{visible:!0,items:new Map}),at.get(Re)}function Je(Re,nt){let[kt,xn]=Ohe(Re.world,T);Re.el.style.display=nt?"":"none",Re.el.style.transform=`translate(${kt}px, ${xn}px)`+(Re.center?" translate(-50%, -50%)":"")}function Qn(Re){for(let nt of Re.items.values())Je(nt,Re.visible)}function ei(){for(let Re of at.values())Qn(Re)}function ar(){return{width:T.width,height:T.height}}let yn={DRAW_ORDER:bp,getContainer:()=>s,getRendererInfo:()=>F,getSize:ar,getZoom:()=>T.zoom,getTargetZoom:()=>L?L.to.zoom:T.zoom,getCenter:()=>[...T.target],getViewState:()=>({...T,target:[...T.target]}),isAnimating:()=>!!L,isMoving:()=>te,project:Re=>Ohe(Re,T),unproject:Re=>vO(Re,T),on:x.on,off:x.off,setLimits({minZoom:Re,maxZoom:nt}={}){Re!==void 0&&(M.minZoom=Re),nt!==void 0&&(M.maxZoom=nt);let kt=rk(T.zoom,M);kt!==T.zoom?Yi(T.target,kt):jt&&jt.setProps({viewState:mn()}),x.emit("limits")},getLimits:()=>({...M}),setView(Re,nt=T.zoom,{animate:kt}={}){let xn={target:[Re[0],Re[1]],zoom:nt};se(xn,kt===!1?{ms:0}:{curve:!0})},fitWorldRect(Re,{padding:nt=[0,0],animate:kt}={}){let xn=axt(Re,T,{padding:nt,...M});se(xn,kt===!1?{ms:0}:{curve:!0})},zoomAround(Re,nt,{animate:kt,settle:xn=!0}={}){let Ei=rk(yn.getTargetZoom()+nt,M),Xi=En(),cr=Re||[T.width/2,T.height/2],So=Nhe(Xi,cr,Ei);se({target:So,zoom:Ei},kt===!1?{ms:0,settle:xn}:{anchor:Re?cr:null})},zoomIn:()=>yn.zoomAround(null,1),zoomOut:()=>yn.zoomAround(null,-1),panByPx(Re,nt,{animate:kt}={}){let xn=En(),Ei=Math.pow(2,xn.zoom),Xi=[xn.target[0]+Re/Ei,xn.target[1]-nt/Ei],cr=kt===!1||!u.smooth()?0:qxt;se({target:Xi,zoom:xn.zoom},{ms:cr})},invalidateSize:qn,applyPrefs(){hr()},addTileSlot:Mn,setOverlay(Re,nt,{order:kt=bp.selection}={}){!nt||nt.length===0?Qe.delete(Re):Qe.set(Re,Ze(Re,nt,kt)),ot()},hasOverlay:Re=>Qe.has(Re),setImageOverlay(Re,nt,{order:kt=bp.pathImage}={}){nt?st.set(Re,{order:kt,kind:"BitmapLayer",props:{id:`image:${Re}`,image:nt.image,bounds:nt.rect,parameters:ck}}):st.delete(Re),ot()},addMarker(Re,nt,kt,xn,{center:Ei=!1}={}){let Xi=_n(Re),cr=Xi.items.get(nt);cr&&cr.el.remove(),xn.classList.add("or-view-marker"),Q.appendChild(xn);let So={el:xn,world:[kt[0],kt[1]],center:Ei};return Xi.items.set(nt,So),Je(So,Xi.visible),xn},moveMarker(Re,nt,kt){let xn=_n(Re),Ei=xn.items.get(nt);Ei&&(Ei.world=[kt[0],kt[1]],Je(Ei,xn.visible))},clearMarkers(Re){let nt=_n(Re);for(let kt of nt.items.values())kt.el.remove();nt.items.clear()},setMarkerGroupVisible(Re,nt){let kt=_n(Re);kt.visible=!!nt,Qn(kt)},setCursorMode(Re,nt=!0){nt?ne.add(Re):ne.delete(Re),s.classList.toggle(`${Re}-mode-cursor`,!!nt);let kt=jt&&jt.getCanvas&&jt.getCanvas();kt&&(kt.style.cursor=ne.size?"crosshair":"default")},flashTiles(){oe=_()+Zxt,ot()},whenTilesSettled({timeoutMs:Re=6e3}={}){let nt=_()+Re;return new Promise(kt=>{let xn=()=>{if(wt()&&Tt.isIdle()&&!L&&!te||_()>=nt){kt();return}setTimeout(xn,32)};xn()})},captureCanvas({timeoutMs:Re=500}={}){return jt?.getCanvas()?(_i(),new Promise(nt=>{let kt=null,xn=()=>{clearTimeout(kt),D=D.filter(Xi=>Xi!==xn);let Ei=jt?.getCanvas();nt(Ei?{image:c(Ei),rect:Ei.getBoundingClientRect()}:null)};D.push(xn),kt=setTimeout(()=>{jt?.redraw("capture"),xn()},Re)})):Promise.resolve(null)},redraw:()=>ot(),debugSnapshot(){let Re=Tt.plan();return{zoom:T.zoom,target:[...T.target],width:T.width,height:T.height,animating:!!L,moving:te,interacting:I,shownZ:Tt.shownZ,pendingZ:Tt.pendingZ,fading:Re.fading,drawLevels:Re.draw,layers:Xn,coverage:Hi(),overlays:[...Qe.keys()],markers:Object.fromEntries([...at].map(([nt,kt])=>[nt,kt.items.size])),slots:[...ge.values()].map(nt=>({id:nt.id,visible:nt.visible,settled:nt.grid.isSettled(),...nt.grid.stats()}))}},destroy(){ue=!0,pn?.disconnect(),Tt.dispose();for(let Re of ge.values())Re.grid.clear();jt?.finalize?.()}};return yn}var edn=4.000244140625;function tdn(s){return s.deltaMode!==0?!0:s.deltaX!==0||s.deltaY===0?!1:Number.isInteger(s.deltaY)&&Math.abs(s.deltaY)>=50||s.deltaY%edn===0}function ndn(s){let n=Math.abs(s);return n<.2?0:Math.sign(s)*Math.max(1,Math.round(n))}function idn(s,n){let c=1;return s.deltaMode===1?c=16:s.deltaMode===2&&(c=n.clientHeight||16),[s.deltaX*c,s.deltaY*c]}function rdn(s,n,r){let c=r?3*n:n;switch(s){case"ArrowLeft":return[-c,0];case"ArrowRight":return[c,0];case"ArrowUp":return[0,-c];case"ArrowDown":return[0,c];default:return null}}function e3t(s,n={}){let r=s.getContainer(),c=n.isStatic||(()=>!1),u=n.wheelZoom||(()=>!0),d=n.arrowStep||(()=>80),b=n.gestureIdleMs??200,w=n.contextEnabled||(()=>!0),_=[],x=(ne,ue,Te,Q)=>{ne.addEventListener(ue,Te,Q),_.push(()=>ne.removeEventListener(ue,Te,Q))},T=ne=>{let ue=r.getBoundingClientRect();return[ne.clientX-ue.left,ne.clientY-ue.top]},M=ne=>s.unproject(T(ne)),L=ne=>ne.target===r||!!ne.target?.closest?.(".or-view-canvas");r.tabIndex<0&&(r.tabIndex=0);let I=null;function D(ne,ue){I||(I={z0:s.getZoom()}),I.pt=ne,clearTimeout(I.timer),I.timer=setTimeout(F,b),s.zoomAround(ne,ue,{animate:!1,settle:!1})}function F(){if(!I)return;let ne=I;I=null,clearTimeout(ne.timer);let ue=s.getZoom();s.zoomAround(ne.pt,ne.z0+ndn(ue-ne.z0)-ue)}_.push(()=>{clearTimeout(I?.timer),I=null}),x(r,"wheel",ne=>{if(ne.preventDefault(),c())return;let ue=tdn(ne);if(!ue&&ne.ctrlKey){D(T(ne),-ne.deltaY/(100*Math.LN2));return}if(u()===ne.ctrlKey){let[Te,Q]=idn(ne,r);s.panByPx(Te,Q,{animate:!1});return}if(!ue){D(T(ne),-ne.deltaY/100);return}F(),s.zoomAround(T(ne),ne.deltaY<0?1:-1)},{passive:!1}),x(r,"keydown",ne=>{if(ne.altKey||ne.ctrlKey||ne.metaKey)return;let ue=rdn(ne.key,d(),ne.shiftKey);if(ue){ne.preventDefault(),s.panByPx(ue[0],ue[1]);return}if(c())return;let Te={"+":1,"=":1,"-":-1,_:-1};ne.key in Te&&(ne.preventDefault(),s.zoomAround(null,Te[ne.key]*(ne.shiftKey?3:1)))});let O=null,z=null;x(r,"pointerdown",ne=>{ne.button!==0||!L(ne)||(r.focus({preventScroll:!0}),O={x:ne.clientX,y:ne.clientY,moved:!1,box:ne.shiftKey&&!c()},O.box&&ne.stopPropagation())},{capture:!0}),x(window,"pointermove",ne=>{if(!O)return;let ue=ne.clientX-O.x,Te=ne.clientY-O.y;(Math.abs(ue)>3||Math.abs(Te)>3)&&(O.moved=!0),O.box&&O.moved&&(z=Qxt(z,O,ne))}),x(window,"pointerup",ne=>{if(!O||ne.button!==0)return;let ue=O;if(O=null,z&&(z.remove(),z=null),ue.box&&ue.moved){oe(ue,ne);return}!ue.moved&&n.onClick&&te(ne)&&n.onClick(M(ne),ne)}),x(r,"dblclick",ne=>{c()||!L(ne)||s.zoomAround(T(ne),ne.shiftKey?-1:1)});let Z=null,H=null;x(r,"contextmenu",ne=>ne.preventDefault()),x(r,"pointerdown",ne=>{ne.button!==2||c()||!L(ne)||(ne.stopPropagation(),Z={x:ne.clientX,y:ne.clientY})},{capture:!0}),x(window,"pointermove",ne=>{if(!Z)return;let ue=ne.clientX-Z.x,Te=ne.clientY-Z.y;(H||Math.abs(ue)>=4&&Math.abs(Te)>=4)&&(H=Qxt(H,Z,ne))}),x(window,"pointerup",ne=>{if(!Z||ne.button!==2)return;let ue=Z;if(Z=null,H){H.remove(),H=null,oe(ue,ne);return}te(ne)&&w()&&n.onContextClick&&n.onContextClick(M(ne),ne)}),x(r,"pointermove",ne=>{n.onMove&&n.onMove(M(ne),ne)}),x(r,"pointerleave",ne=>{n.onLeave&&n.onLeave(ne)});function te(ne){let ue=r.getBoundingClientRect();return ne.clientX>=ue.left&&ne.clientX<=ue.right&&ne.clientY>=ue.top&&ne.clientY<=ue.bottom}function oe(ne,ue){let Te=r.getBoundingClientRect(),Q=s.unproject([ne.x-Te.left,ne.y-Te.top]),ge=s.unproject([ue.clientX-Te.left,ue.clientY-Te.top]);s.fitWorldRect([Math.min(Q[0],ge[0]),Math.min(Q[1],ge[1]),Math.max(Q[0],ge[0]),Math.max(Q[1],ge[1])])}return{dispose(){for(let ne of _.splice(0))ne()}}}function Qxt(s,n,r){return s||(s=document.createElement("div"),s.className="rubber-band",document.body.appendChild(s)),s.style.left=Math.min(n.x,r.clientX)+"px",s.style.top=Math.min(n.y,r.clientY)+"px",s.style.width=Math.abs(r.clientX-n.x)+"px",s.style.height=Math.abs(r.clientY-n.y)+"px",s}var uk=class s{constructor(n,r,c){this._app=n,this._redrawAllLayers=r,this._refreshOverlay=c||r,this._currentTab="setup",this._setupPaths=[],this._holdPaths=[],this._selectedPathIndex=-1,this._detailTab="data",this._selectedDetailIndex=-1,this._sortCol="slack",this._sortAscending=!0,this._build()}_build(){let n=document.createElement("div");n.className="timing-widget";let r=document.createElement("div");r.className="timing-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",ua(this._app)&&(this._updateBtn.style.display="none"),this._pathCountLabel=document.createElement("span"),this._pathCountLabel.className="timing-path-count",r.appendChild(this._updateBtn),r.appendChild(this._pathCountLabel),n.appendChild(r),n.appendChild(this._buildConePanel());let c=document.createElement("div");c.className="timing-tab-bar",this._setupTab=this._makeTab("Setup",!0),this._holdTab=this._makeTab("Hold",!1),c.appendChild(this._setupTab),c.appendChild(this._holdTab),n.appendChild(c),this._pathTableContainer=document.createElement("div"),this._pathTableContainer.className="timing-path-table-container",this._pathTable=document.createElement("table"),this._pathTable.className="timing-table",this._pathTableContainer.appendChild(this._pathTable),n.appendChild(this._pathTableContainer);let u=document.createElement("div");u.className="timing-tab-bar",this._dataTab=this._makeTab("Data Path",!0),this._captureTab=this._makeTab("Capture Path",!1),u.appendChild(this._dataTab),u.appendChild(this._captureTab),n.appendChild(u),this._detailTableContainer=document.createElement("div"),this._detailTableContainer.className="timing-detail-table-container",this._detailTable=document.createElement("table"),this._detailTable.className="timing-table",this._detailTableContainer.appendChild(this._detailTable),n.appendChild(this._detailTableContainer),this._headerTooltip=document.createElement("div"),this._headerTooltip.className="or-tooltip or-tooltip-fixed",n.appendChild(this._headerTooltip),this.element=n,this._bindEvents(),ua(this._app)&&setTimeout(()=>this.update(),0)}_makeTab(n,r){let c=document.createElement("button");return c.className="timing-tab"+(r?" active":""),c.textContent=n,c}_bindEvents(){this._setupTab.addEventListener("click",()=>{this._currentTab="setup",this._setupTab.classList.add("active"),this._holdTab.classList.remove("active"),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}),this._holdTab.addEventListener("click",()=>{this._currentTab="hold",this._holdTab.classList.add("active"),this._setupTab.classList.remove("active"),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}),this._dataTab.addEventListener("click",()=>{this._detailTab="data",this._dataTab.classList.add("active"),this._captureTab.classList.remove("active"),this._renderDetailTable()}),this._captureTab.addEventListener("click",()=>{this._detailTab="capture",this._captureTab.classList.add("active"),this._dataTab.classList.remove("active"),this._renderDetailTable()}),this._updateBtn.addEventListener("click",()=>this.update()),this._pathTableContainer.setAttribute("tabindex","0"),this._pathTableContainer.style.outline="none",this._pathTableContainer.addEventListener("keydown",n=>{if(n.key==="ArrowDown"){n.preventDefault();let r=this._pathTable.querySelectorAll("tbody tr");this._selectedPathIndex0&&this._selectPathRow(this._selectedPathIndex-1))}),this._detailTableContainer.setAttribute("tabindex","0"),this._detailTableContainer.style.outline="none",this._detailTableContainer.addEventListener("keydown",n=>{if(n.key==="ArrowDown"){n.preventDefault();let r=this._detailTable.querySelectorAll("tbody tr");this._selectedDetailIndex0&&this._selectDetailRow(this._selectedDetailIndex-1))})}_buildConePanel(){let n=document.createElement("div");n.className="timing-cone-panel";let r=document.createElement("span");r.className="timing-cone-title",r.textContent="Timing cone:",n.appendChild(r);let c=(T,M,L=!1)=>{let I=document.createElement("input");I.type="checkbox",I.id=T,I.checked=L;let D=document.createElement("label");return D.htmlFor=T,D.textContent=M,{input:I,lbl:D}},u=c("cone-fanin","Fanin",!0),d=c("cone-fanout","Fanout",!0);this._coneFanin=u.input,this._coneFanout=d.input,n.append(u.input,u.lbl,d.input,d.lbl);let b=T=>{let M=document.createElement("label");M.className="timing-cone-depth-label",M.textContent=T;let L=document.createElement("input");return L.type="number",L.min="0",L.value="0",L.className="timing-cone-depth",L.title="0 = unlimited",M.appendChild(L),{lbl:M,input:L}},w=b("in\u2264"),_=b("out\u2264");this._coneFaninDepth=w.input,this._coneFanoutDepth=_.input,n.append(w.lbl,_.lbl),this._coneColorMode=document.createElement("select"),this._coneColorMode.className="timing-cone-colormode";for(let[T,M]of[["slack","by slack"],["depth","by depth"]]){let L=document.createElement("option");L.value=T,L.textContent=M,this._coneColorMode.appendChild(L)}n.appendChild(this._coneColorMode);let x=c("cone-sync-schematic","Sync schematic");return this._coneSyncSchematic=x.input,n.append(x.input,x.lbl),this._coneApplyBtn=document.createElement("button"),this._coneApplyBtn.className="or-btn",this._coneApplyBtn.textContent="Cone",this._coneApplyBtn.title="Show the timing cone for the selected instance",this._coneClearBtn=document.createElement("button"),this._coneClearBtn.className="or-btn",this._coneClearBtn.textContent="Clear",n.append(this._coneApplyBtn,this._coneClearBtn),this._coneStatus=document.createElement("span"),this._coneStatus.className="timing-cone-status",n.appendChild(this._coneStatus),this._coneApplyBtn.addEventListener("click",()=>this._applyCone()),this._coneClearBtn.addEventListener("click",()=>this._clearCone()),n}_coneTarget(){return this._app.selectedInstanceName||""}async _applyCone(){let n=this._coneFanin.checked,r=this._coneFanout.checked;if(!n&&!r){this._coneStatus.textContent="select fanin and/or fanout";return}let c=this._coneTarget();if(!c){this._coneStatus.textContent="select an instance first";return}let u={type:"timing_cone",fanin:n,fanout:r,fanin_depth:Math.max(0,parseInt(this._coneFaninDepth.value,10)||0),fanout_depth:Math.max(0,parseInt(this._coneFanoutDepth.value,10)||0),color_mode:this._coneColorMode.value,inst_name:c};this._coneApplyBtn.disabled=!0,this._coneStatus.textContent="computing\u2026";try{let d=await this._app.websocketManager.request(u);this._refreshOverlay(),this._renderConeStatus(d),this._coneSyncSchematic.checked&&c&&document.dispatchEvent(new CustomEvent("openroad-cone-sync",{detail:{inst_name:c,fanin:u.fanin,fanout:u.fanout,fanin_depth:u.fanin_depth,fanout_depth:u.fanout_depth}}))}catch(d){this._coneStatus.textContent="cone error: "+(d.message||d)}this._coneApplyBtn.disabled=!1}_renderConeStatus(n){if(!n){this._coneStatus.textContent="";return}let r=n.node_count||0;if(r===0){this._coneStatus.textContent="empty cone";return}let c=r+" pins";if(n.color_mode==="depth")c+=`, depth \xB1${n.max_depth}`;else if(n.constrained){let u=n.time_unit||"";c+=`, slack ${lk(n.min_slack)}\u2026${lk(n.max_slack)}${u}`}else c+=", unconstrained";this._coneStatus.textContent=c}_clearCone(){this._app.websocketManager.request({type:"timing_cone",clear:!0}).then(()=>this._refreshOverlay()),this._coneStatus.textContent=""}showPaths(n,r){this._currentTab=n,n==="setup"?(this._setupPaths=[...r],this._setupTab.classList.add("active"),this._holdTab.classList.remove("active")):(this._holdPaths=[...r],this._holdTab.classList.add("active"),this._setupTab.classList.remove("active")),this._applySort(),this._selectedPathIndex=-1,this._pathCountLabel.textContent=r.length+" paths",this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...";try{let[n,r]=await Promise.all([this._app.websocketManager.request({type:"timing_report",is_setup:!0,max_paths:100}),this._app.websocketManager.request({type:"timing_report",is_setup:!1,max_paths:100})]);this._setupPaths=[...n.paths||[]],this._holdPaths=[...r.paths||[]],this._applySort(),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}catch(n){console.error("Timing fetch failed:",n)}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}_applySort(){for(let n of[this._setupPaths,this._holdPaths]){n.forEach((u,d)=>{u._originalIndex===void 0&&(u._originalIndex=d)});let r=this._sortAscending?1:-1,c=this._sortCol;n.sort((u,d)=>{let b=u[c],w=d[c],_=typeof b=="number"&&typeof w=="number"?b-w:String(b).localeCompare(String(w));return r*_})}}_showHeaderTooltip(n,r){if(n.buttons!==0){this._hideHeaderTooltip();return}let c=this._headerTooltip;c.textContent=r,c.style.display="block";let u=Math.min(n.clientX+12,window.innerWidth-c.offsetWidth-8);c.style.left=Math.max(0,u)+"px",c.style.top=n.clientY+14+"px"}_hideHeaderTooltip(){this._headerTooltip.style.display="none"}_sortBy(n){this._sortCol===n?this._sortAscending=!this._sortAscending:(this._sortCol=n,this._sortAscending=!0),this._applySort(),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}_clearTimingHighlight(){this._app.websocketManager.request({type:"timing_highlight",path_index:-1}).then(()=>this._refreshOverlay())}_selectPathRow(n){let r=this._pathTable.querySelectorAll("tbody tr");if(n<0||n>=r.length)return;this._selectedPathIndex=n;for(let d of r)d.classList.remove("selected");r[n].classList.add("selected"),r[n].scrollIntoView({block:"nearest"}),this._pathTableContainer.focus(),this._renderDetailTable();let u=(this._currentTab==="setup"?this._setupPaths:this._holdPaths)[n]?._originalIndex??n;this._app.websocketManager.request({type:"timing_highlight",path_index:u,is_setup:this._currentTab==="setup"}).then(()=>this._refreshOverlay()).catch(d=>console.error("timing_highlight error:",d))}_renderPathTable(){this._hideHeaderTooltip();let n=this._currentTab==="setup"?this._setupPaths:this._holdPaths;this._pathCountLabel.textContent=n.length+" paths";let r=this._pathTable.querySelectorAll("thead th"),c=Array.from(r,_=>_.style.width);this._pathTable.innerHTML="";let u=document.createElement("thead"),d=document.createElement("tr");for(let _ of s.PATH_COLS){let x=document.createElement("th");x.classList.add("sortable"),_.num&&x.classList.add("num"),x.textContent=_.label+(_.key===this._sortCol?this._sortAscending?" \u25B2":" \u25BC":""),_.tooltip&&(x.addEventListener("mousemove",T=>this._showHeaderTooltip(T,_.tooltip)),x.addEventListener("mouseleave",()=>this._hideHeaderTooltip())),x.addEventListener("click",()=>this._sortBy(_.key)),d.appendChild(x)}u.appendChild(d),this._pathTable.appendChild(u);let b=document.createElement("tbody"),w=n.reduce((_,x)=>Math.max(_,Math.abs(Number(x.slack)||0)),0);if(n.forEach((_,x)=>{let T=document.createElement("tr");x===this._selectedPathIndex&&T.classList.add("selected");for(let M of s.PATH_COLS){let L=document.createElement("td"),I=_[M.key];if(L.textContent=M.time?lk(I):I,M.num&&L.classList.add("num"),M.key==="slack"){let D=Number(_.slack);D<0&&L.classList.add("slack-negative"),Number.isFinite(D)&&w>0&&(L.classList.add("slack-cell",D<0?"slack-under":"slack-over"),L.style.setProperty("--slack-frac",String(Math.abs(D)/w)))}T.appendChild(L)}T.style.cursor="pointer",T.addEventListener("click",()=>this._selectPathRow(x)),b.appendChild(T)}),n.length===0){let _=document.createElement("tr"),x=document.createElement("td");x.colSpan=s.PATH_COLS.length,x.style.textAlign="center",x.style.color="var(--fg-secondary)",x.textContent=ua(this._app)?"No timing data available":'Click "Update" to load timing paths',_.appendChild(x),b.appendChild(_)}this._pathTable.appendChild(b),ak(this._pathTable,c)}_selectDetailRow(n){let r=this._detailTable.querySelectorAll("tbody tr");if(n<0||n>=r.length)return;this._selectedDetailIndex=n;for(let w of r)w.classList.remove("timing-selected-row");r[n].classList.add("timing-selected-row"),r[n].scrollIntoView({block:"nearest"}),this._detailTableContainer.focus();let u=(this._currentTab==="setup"?this._setupPaths:this._holdPaths)[this._selectedPathIndex],d=this._detailTab==="data"?u.data_nodes:u.capture_nodes,b=u._originalIndex??this._selectedPathIndex;this._app.websocketManager.request({type:"timing_highlight",path_index:b,is_setup:this._currentTab==="setup",pin_name:d[n].pin}).then(()=>this._refreshOverlay())}_renderDetailTable(){let n=this._detailTable.querySelectorAll("thead th"),r=Array.from(n,x=>x.style.width);this._detailTable.innerHTML="",this._selectedDetailIndex=-1;let c=this._currentTab==="setup"?this._setupPaths:this._holdPaths;if(this._selectedPathIndex<0||this._selectedPathIndex>=c.length)return;let u=c[this._selectedPathIndex],d=this._detailTab==="data"?u.data_nodes:u.capture_nodes,b=document.createElement("thead"),w=document.createElement("tr");for(let x of s.DETAIL_COLS){let T=document.createElement("th");s.DETAIL_NUM_COLS.has(x)&&T.classList.add("num"),T.textContent=x,w.appendChild(T)}b.appendChild(w),this._detailTable.appendChild(b);let _=document.createElement("tbody");if(d.forEach((x,T)=>{let M=document.createElement("tr");x.clk&&M.classList.add("timing-clock-row"),[x.pin,x.fanout,x.rise?"\u2191":"\u2193",lk(x.time),lk(x.delay),lk(x.slew),lk(x.load)].forEach((I,D)=>{let F=document.createElement("td");s.DETAIL_NUM_COLS.has(s.DETAIL_COLS[D])&&F.classList.add("num"),F.textContent=I,M.appendChild(F)}),M.style.cursor="pointer",M.addEventListener("click",()=>this._selectDetailRow(T)),_.appendChild(M)}),this._detailTable.appendChild(_),ak(this._detailTable,r),!r[0]){let x=this._detailTable.querySelector("thead th");x&&(x.style.width="30ch")}}};function lk(s){return s==null?"":typeof s=="number"?s.toFixed(4):String(s)}uk.PATH_COLS=[{label:"Clock",key:"end_clk"},{label:"Required",key:"required",time:!0,num:!0},{label:"Arrival",key:"arrival",time:!0,num:!0},{label:"Slack",key:"slack",time:!0,num:!0},{label:"Skew",key:"skew",time:!0,num:!0,tooltip:`The difference in arrival times between source and destination clock pins of a macro/register, adjusted for CRPR and subtracting a clock period. -Setup and hold times account for internal clock delays.`},{label:"Logic Delay",key:"path_delay",time:!0,num:!0,tooltip:"Path delay from instances (excluding buffers and consecutive inverter pairs)"},{label:"Logic Depth",key:"logic_depth",num:!0,tooltip:"Path instances (excluding buffers and consecutive inverter pairs)"},{label:"Fanout",key:"fanout",num:!0},{label:"Start",key:"start_pin"},{label:"End",key:"end_pin"}];uk.DETAIL_COLS=["Pin","Fanout","R/F","Time","Delay","Slew","Load"];uk.DETAIL_NUM_COLS=new Set(["Fanout","Time","Delay","Slew","Load"]);function pf(s){let n=document.cookie.match("(?:^|; )"+s+"=([^;]*)");return n?n[1]:null}function Ff(s,n){document.cookie=s+"="+n+"; path=/; max-age=31536000; SameSite=Lax"}function Vhe(s){document.cookie=s+"=; path=/; max-age=0; SameSite=Lax"}function Whe(s){Ff("or_theme",s);try{window.localStorage.setItem("or_theme",s)}catch{}}function e3t(){Vhe("or_theme");try{window.localStorage.removeItem("or_theme")}catch{}}function H5e(s){let n=document.getElementById("gl-theme-dark"),r=document.getElementById("gl-theme-light");!n||!r||(n.disabled=s!=="dark",r.disabled=s!=="light")}function t3t(s,n){SO(s)&&(document.documentElement.style.setProperty("--bg-map",s),Ff("or_bg_color",s),i3t(n),n.syncDisplayState())}function n3t(s){document.documentElement.style.removeProperty("--bg-map"),Vhe("or_bg_color"),i3t(s),s.syncDisplayState()}function q5e(){return $xt(getComputedStyle(document.documentElement).getPropertyValue("--bg-map"))??"#000000"}function i3t(s){s.threeDViewerWidget?.render?.()}if(typeof document<"u"){let s=pf("or_theme")||typeof localStorage<"u"&&localStorage.getItem("or_theme")||(matchMedia("(prefers-color-scheme: light)").matches?"light":"dark");document.documentElement.dataset.theme=s,H5e(s);let n=pf("or_bg_color");SO(n)&&document.documentElement.style.setProperty("--bg-map",n)}function fk(){let s=getComputedStyle(document.documentElement),n=r=>s.getPropertyValue(r).trim();return{canvasBg:n("--canvas-bg"),canvasText:n("--canvas-text"),canvasAxis:n("--canvas-axis"),canvasLabel:n("--canvas-label"),canvasGrid:n("--canvas-grid"),canvasTitle:n("--canvas-title"),fgPrimary:n("--fg-primary"),fgMuted:n("--fg-muted"),bgPanel:n("--bg-panel"),bgMap:n("--bg-map"),fontMono:n("--font-mono"),fontSans:n("--font-sans")}}function hk(s,n){let r=document.createElement("a");r.href=s,r.download=n,document.body.appendChild(r),r.click(),r.remove()}function r3t(s,n){let r=URL.createObjectURL(s);hk(r,n),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function X5e(s){let n=s.cloneNode(!0);if(n.getAttribute("xmlns")||n.setAttribute("xmlns","http://www.w3.org/2000/svg"),n.getAttribute("xmlns:xlink")||n.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),!n.getAttribute("width")||!n.getAttribute("height")){let r=s.viewBox&&s.viewBox.baseVal;r&&r.width&&r.height&&(n.setAttribute("width",r.width),n.setAttribute("height",r.height))}return` -`+new XMLSerializer().serializeToString(n)}function ndn(s){let n=s.viewBox&&s.viewBox.baseVal;if(n&&n.width&&n.height)return{width:n.width,height:n.height};let r=parseFloat(s.getAttribute("width")),c=parseFloat(s.getAttribute("height"));if(r&&c)return{width:r,height:c};let u=s.getBoundingClientRect();return{width:u.width||800,height:u.height||600}}function Y5e(s,n=2){let{width:r,height:c}=ndn(s),u=X5e(s),d=new Blob([u],{type:"image/svg+xml;charset=utf-8"}),b=URL.createObjectURL(d);return new Promise((w,_)=>{let x=new Image;x.onload=()=>{let T=document.createElement("canvas");T.width=Math.max(1,Math.round(r*n)),T.height=Math.max(1,Math.round(c*n));let M=T.getContext("2d");M.fillStyle="#ffffff",M.fillRect(0,0,T.width,T.height),M.drawImage(x,0,0,T.width,T.height),URL.revokeObjectURL(b),w(T.toDataURL("image/png"))},x.onerror=T=>{URL.revokeObjectURL(b),_(T)},x.src=b})}async function Hhe(s){try{if(!navigator.clipboard||!window.ClipboardItem)return!1;let n=await(await fetch(s)).blob();return await navigator.clipboard.write([new ClipboardItem({"image/png":n})]),!0}catch{return!1}}function idn(s){return(String(s||"").replace(/[^A-Za-z0-9._-]/g,"_").replace(/^_+|_+$/g,"")||"clock_tree")+".png"}var Z5e=24,K5e=10,Xhe=40,rdn=40,J5e=70,sdn=20,qhe={root:"#ff4444",buffer:"#4488ff",inverter:"#00b0b0",clock_gate:"#cc44cc",register:"#ff4444",macro:"#00b0b0",unknown:"#888888"};function odn(s){let n=parseInt(s.slice(1,3),16),r=parseInt(s.slice(3,5),16),c=parseInt(s.slice(5,7),16),u=b=>Math.round((b+255)/2),d=b=>b.toString(16).padStart(2,"0");return"#"+d(u(n))+d(u(r))+d(u(c))}function adn(s){let n=s.nodes;if(!n||n.length===0)return{layout:[],layoutWidth:0,layoutHeight:0,timeMin:0,timeMax:0,timeUnit:"",sceneHeight:0,layoutById:new Map};let r=new Map;for(let Z of n)r.set(Z.id,[]);for(let Z of n)Z.parent_id>=0&&r.has(Z.parent_id)&&r.get(Z.parent_id).push(Z.id);let c=new Map;for(let Z of n)c.set(Z.id,Z);let u=new Map,d=Z=>{let H=r.get(Z)||[];if(H.length===0)return u.set(Z,1),1;let te=0;for(let se of H)te+=d(se);return u.set(Z,te),te},b=n.filter(Z=>Z.parent_id===-1),w=0;for(let Z of b)w+=d(Z.id);let _=s.min_arrival,x=s.max_arrival,T=x-_||1,M=Math.max(200,w*Z5e*.6),L=[],I=(Z,H)=>{let te=c.get(Z),se=u.get(Z),ne=J5e+(H+se/2)*Z5e,ue=Xhe+(te.arrival-_)/T*M;L.push({id:te.id,x:ne,y:ue,type:te.type,name:te.name,pin_name:te.pin_name,arrival:te.arrival,delay:te.delay,fanout:te.fanout,level:te.level,parent_id:te.parent_id});let Ce=H,Q=r.get(Z)||[];for(let me of Q)I(me,Ce),Ce+=u.get(me)},D=0;for(let Z of b)I(Z.id,D),D+=u.get(Z.id);let F=J5e+w*Z5e+sdn,O=Xhe+M+rdn,z=new Map;for(let Z of L)z.set(Z.id,Z);return{layout:L,layoutWidth:F,layoutHeight:O,timeMin:_,timeMax:x,timeUnit:s.time_unit||"",sceneHeight:M,layoutById:z}}var Yhe=class{constructor(n,r,c,u){this._app=r,this._redrawAllLayers=c,this._refreshOverlay=u||c,this._clockData=[],this._selectedClockIdx=0,this._selectedNodeId=-1,this._tx=0,this._ty=0,this._scale=1,this._layout=[],this._dragging=!1,this._dragStartX=0,this._dragStartY=0,this._dragStartTx=0,this._dragStartTy=0,this._build(n)}_build(n){let r=document.createElement("div");r.className="clock-tree-widget";let c=document.createElement("div");c.className="clock-tree-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",la(this._app)&&(this._updateBtn.style.display="none"),this._fitBtn=document.createElement("button"),this._fitBtn.className="or-btn",this._fitBtn.textContent="Fit",this._pngBtn=document.createElement("button"),this._pngBtn.className="or-btn",this._pngBtn.textContent="PNG",this._pngBtn.title="Export the clock tree as a PNG image",this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",c.appendChild(this._updateBtn),c.appendChild(this._fitBtn),c.appendChild(this._pngBtn),c.appendChild(this._statusLabel),r.appendChild(c),this._tabBar=document.createElement("div"),this._tabBar.className="timing-tab-bar",r.appendChild(this._tabBar),this._canvas=document.createElement("canvas"),this._canvas.className="clock-tree-canvas",r.appendChild(this._canvas),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._tooltip.style.display="none",r.appendChild(this._tooltip),n.element.appendChild(r),this._el=r,this._ctx=this._canvas.getContext("2d"),this._bindEvents(),la(this._app)&&setTimeout(()=>this.update(),0)}_fit(){this._sizeCanvas(),this._fitToView(),this._render()}_pngFileName(){let n=this._clockData[this._selectedClockIdx];return idn(n&&n.name)}_exportPng(){try{hk(this._canvas.toDataURL("image/png"),this._pngFileName())}catch(n){console.error("PNG export failed:",n)}}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update()),this._fitBtn.addEventListener("click",()=>this._fit()),this._pngBtn.addEventListener("click",()=>this._exportPng()),this._canvas.addEventListener("keydown",n=>{n.key==="f"&&this._fit()}),this._canvas.tabIndex=0,this._canvas.addEventListener("wheel",n=>{n.preventDefault();let r=this._canvas.getBoundingClientRect(),c=n.clientX-r.left,u=n.clientY-r.top,d=n.deltaY<0?1.15:1/1.15;this._tx=c-(c-this._tx)*d,this._ty=u-(u-this._ty)*d,this._scale*=d,this._render()}),this._canvas.addEventListener("mousedown",n=>{this._dragging=!0,this._dragStartX=n.clientX,this._dragStartY=n.clientY,this._dragStartTx=this._tx,this._dragStartTy=this._ty,this._canvas.style.cursor="grabbing"}),window.addEventListener("mousemove",n=>{this._dragging?(this._tx=this._dragStartTx+(n.clientX-this._dragStartX),this._ty=this._dragStartTy+(n.clientY-this._dragStartY),this._render()):this._handleHover(n)}),window.addEventListener("mouseup",()=>{this._dragging&&(this._dragging=!1,this._canvas.style.cursor="grab")}),this._canvas.addEventListener("click",n=>this._handleClick(n)),this._resizeObserver=new ResizeObserver(()=>{this._sizeCanvas(),this._render()}),this._resizeObserver.observe(this._canvas)}_sizeCanvas(){let n=this._canvas.getBoundingClientRect(),r=window.devicePixelRatio||1;this._canvas.width=n.width*r,this._canvas.height=n.height*r,this._ctx.setTransform(r,0,0,r,0,0)}async update(){this._statusLabel.textContent="Loading...";try{let n=await this._app.websocketManager.request({type:"clock_tree"});this._clockData=n.clocks||[],this._buildTabs(),this._selectClock(0),this._statusLabel.textContent=this._clockData.length+" clock"+(this._clockData.length!==1?"s":"")}catch(n){console.error("Clock tree error:",n),this._statusLabel.textContent="Error: "+n.message}}_buildTabs(){this._tabBar.innerHTML="",this._clockData.forEach((n,r)=>{let c=document.createElement("button");c.className="timing-tab"+(r===this._selectedClockIdx?" active":""),c.textContent=n.name,c.addEventListener("click",()=>this._selectClock(r)),this._tabBar.appendChild(c)})}_selectClock(n){if(n<0||n>=this._clockData.length)return;this._selectedClockIdx=n,this._selectedNodeId=-1,this._tabBar.querySelectorAll(".timing-tab").forEach((c,u)=>{c.classList.toggle("active",u===n)}),this._computeLayout(this._clockData[n]),requestAnimationFrame(()=>{this._sizeCanvas(),this._fitToView(),this._render()})}_computeLayout(n){let r=adn(n);this._layout=r.layout,this._layoutWidth=r.layoutWidth,this._layoutHeight=r.layoutHeight,this._timeMin=r.timeMin,this._timeMax=r.timeMax,this._timeUnit=r.timeUnit,this._sceneHeight=r.sceneHeight,this._layoutById=r.layoutById}_fitToView(){if(!this._layout.length)return;let n=this._canvas.getBoundingClientRect(),r=n.width,c=n.height,u=r/this._layoutWidth,d=c/this._layoutHeight;this._scale=Math.min(u,d)*.9,this._tx=(r-this._layoutWidth*this._scale)/2,this._ty=(c-this._layoutHeight*this._scale)/2}render(){this._render()}_render(){let n=this._ctx,r=this._canvas.getBoundingClientRect(),c=r.width,u=r.height,d=fk();if(n.clearRect(0,0,c,u),n.fillStyle=d.canvasBg,n.fillRect(0,0,c,u),!this._layout.length){n.fillStyle=d.canvasText,n.font="14px "+d.fontSans,n.textAlign="center";let b=la(this._app)?"No clock tree data available":'Click "Update" to load clock tree data';n.fillText(b,c/2,u/2);return}n.save(),n.translate(this._tx,this._ty),n.scale(this._scale,this._scale),this._drawConnections(n);for(let b of this._layout)this._drawNode(n,b,b.id===this._selectedNodeId);n.restore(),this._drawTimeScale(n,c,u,d)}_drawConnections(n){let r=1.5/this._scale,c=K5e,u=this._timeMax-this._timeMin||1;for(let d of this._layout){if(d.parent_id<0)continue;let b=this._layoutById.get(d.parent_id);if(!b)continue;let w=b.x,_=d.x,x=(b.delay||0)/u*this._sceneHeight,T=b.y+x,M=d.y,L=b.type==="root"?b.y:b.y+c;if(T>L){let D=qhe[b.type]||qhe.unknown;n.strokeStyle=D,n.lineWidth=r,n.beginPath(),n.moveTo(w,L),n.lineTo(w,T);let F=c/20;n.moveTo(w-F,T),n.lineTo(w+F,T),n.stroke()}n.strokeStyle="#006400",n.lineWidth=r;let I=(T+M)/2;n.beginPath(),n.moveTo(w,T),n.bezierCurveTo(w,I,_,I,_,M),n.stroke()}}_drawNode(n,r,c){let u=r.x,d=r.y,b=K5e,w=qhe[r.type]||qhe.unknown;switch(n.fillStyle=odn(w),n.strokeStyle=w,n.lineWidth=1/this._scale,r.type){case"root":{n.beginPath(),n.moveTo(u-b/2,d-b),n.lineTo(u+b/2,d-b),n.lineTo(u,d),n.closePath(),n.fill(),n.stroke();break}case"buffer":{n.beginPath(),n.moveTo(u-b/2,d),n.lineTo(u+b/2,d),n.lineTo(u,d+b),n.closePath(),n.fill(),n.stroke();break}case"inverter":{let _=b*.1,x=d+b-_;n.beginPath(),n.moveTo(u-b/2,d),n.lineTo(u+b/2,d),n.lineTo(u,x),n.closePath(),n.fill(),n.stroke(),n.beginPath(),n.arc(u,x+_/2,_/2,0,Math.PI*2),n.fill(),n.stroke();break}case"clock_gate":{n.beginPath(),n.arc(u,d+b/2,b/2,0,Math.PI*2),n.fill(),n.stroke();break}case"register":case"macro":{n.beginPath(),n.rect(u-b/2,d,b,b),n.fill(),n.stroke(),n.beginPath(),n.moveTo(u-b/8,d),n.lineTo(u+b/8,d),n.lineTo(u,d+b/4),n.closePath(),n.stroke();break}default:{n.beginPath(),n.arc(u,d+b/2,b/2,0,Math.PI*2),n.fill(),n.stroke();break}}if(c){n.strokeStyle="#ffff00",n.lineWidth=2/this._scale;let _=r.type==="root"?d-b/2:d+b/2;n.beginPath(),n.arc(u,_,b/2+3,0,Math.PI*2),n.stroke()}}_drawTimeScale(n,r,c,u){if(!this._sceneHeight)return;let d=F=>F*this._scale+this._ty,b=d(Xhe),w=d(Xhe+this._sceneHeight);if(w<0||b>c)return;n.save(),n.fillStyle=u.canvasLabel,n.strokeStyle=u.canvasAxis,n.font="11px "+u.fontMono,n.textAlign="right",n.textBaseline="middle";let _=this._timeMax-this._timeMin;if(_<=0){n.restore();return}let x=w-b,T=Math.max(2,Math.floor(x/40)),M=_/T,L=Math.pow(10,Math.floor(Math.log10(M))),I=L;M/L>5?I=10*L:M/L>2?I=5*L:M/L>1&&(I=2*L);let D=Math.ceil(this._timeMin/I)*I;n.beginPath();for(let F=D;F<=this._timeMax;F+=I){let O=(F-this._timeMin)/_,z=b+O*(w-b);n.moveTo(0,z),n.lineTo(r,z);let Z=F.toFixed(I<.01?3:I<.1?2:1)+" "+this._timeUnit;n.fillText(Z,J5e-4,z)}n.stroke(),n.restore()}_screenToLayout(n,r){return{x:(n-this._tx)/this._scale,y:(r-this._ty)/this._scale}}_hitTest(n,r){let c=this._screenToLayout(n,r),u=K5e;for(let d of this._layout){let b=d.type==="root"?d.y-u:d.y,w=d.type==="root"?d.y:d.y+u;if(c.x>=d.x-u/2&&c.x<=d.x+u/2&&c.y>=b&&c.y<=w)return d}return null}_handleClick(n){let r=this._canvas.getBoundingClientRect(),c=n.clientX-r.left,u=n.clientY-r.top,d=this._hitTest(c,u);d?(this._selectedNodeId=d.id,this._render(),this._app.websocketManager.request({type:"clock_tree_highlight",inst_name:d.name}).then(()=>this._refreshOverlay())):this._selectedNodeId>=0&&(this._selectedNodeId=-1,this._render(),this._app.websocketManager.request({type:"clock_tree_highlight",inst_name:""}).then(()=>this._refreshOverlay()))}_handleHover(n){let r=this._canvas.getBoundingClientRect(),c=n.clientX-r.left,u=n.clientY-r.top;if(c<0||u<0||c>r.width||u>r.height){this._tooltip.style.display="none";return}let d=this._hitTest(c,u);if(d){let b=[d.name,"Type: "+d.type,"Arrival: "+d.arrival.toFixed(3)+" "+(this._timeUnit||"")];d.delay&&b.push("Delay: "+d.delay.toFixed(3)+" "+(this._timeUnit||"")),d.fanout&&b.push("Fanout: "+d.fanout),this._tooltip.textContent=b.join(` -`),this._tooltip.style.display="block",this._tooltip.style.left=n.clientX+12+"px",this._tooltip.style.top=n.clientY+12+"px"}else this._tooltip.style.display="none"}};var o3t=60,a3t=20,c3t=30,l3t=50,s3t=2,cdn="#f08080",ldn="#8b0000",udn="#90ee90",fdn="#006400",yT=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7"],hdn="rgba(240,128,128,0.12)",ddn="rgba(144,238,144,0.12)",pdn="#ff9999",gdn="#b0ffb0",mdn=[{value:"setup",label:"Setup Slack"},{value:"hold",label:"Hold Slack"},{value:"fanout",label:"Net Fanout"},{value:"netlength",label:"Net Length (HPWL)"}];function bdn(s,n,r,c){if(!s||!n||cn.bottom)return null;for(let u of s)if(r>=u.x&&r<=u.x+u.width)return u;return null}function wdn(s,n,r){return r?Math.log10(s+1)/Math.log10(n+1):s/n}function vdn(s,n,r,c={}){let u=!!c.logY,d=s?.bins;if(!d||d.length===0)return{bars:[],yMax:0,yTicks:[],chartArea:null,logY:u};let b=o3t,w=n-a3t,_=c3t,x=r-l3t,T=w-b,M=x-_;if(T<=0||M<=0)return{bars:[],yMax:0,yTicks:[],chartArea:null,logY:u};let L={left:b,right:w,top:_,bottom:x},I=0;for(let Z of d)Z.count>I&&(I=Z.count);I===0&&(I=1);let{yMax:D,yTicks:F}=u?ydn(I):_dn(I),O=(T-s3t*(d.length-1))/d.length,z=[];for(let Z=0;Z[x.x,...x.ys||[]].join(","));return[w,..._].join(` +Setup and hold times account for internal clock delays.`},{label:"Logic Delay",key:"path_delay",time:!0,num:!0,tooltip:"Path delay from instances (excluding buffers and consecutive inverter pairs)"},{label:"Logic Depth",key:"logic_depth",num:!0,tooltip:"Path instances (excluding buffers and consecutive inverter pairs)"},{label:"Fanout",key:"fanout",num:!0},{label:"Start",key:"start_pin"},{label:"End",key:"end_pin"}];uk.DETAIL_COLS=["Pin","Fanout","R/F","Time","Delay","Slew","Load"];uk.DETAIL_NUM_COLS=new Set(["Fanout","Time","Delay","Slew","Load"]);function ph(s){let n=document.cookie.match("(?:^|; )"+s+"=([^;]*)");return n?n[1]:null}function Uf(s,n){document.cookie=s+"="+n+"; path=/; max-age=31536000; SameSite=Lax"}function Vhe(s){document.cookie=s+"=; path=/; max-age=0; SameSite=Lax"}function Whe(s){Uf("or_theme",s);try{window.localStorage.setItem("or_theme",s)}catch{}}function t3t(){Vhe("or_theme");try{window.localStorage.removeItem("or_theme")}catch{}}function H5e(s){let n=document.getElementById("gl-theme-dark"),r=document.getElementById("gl-theme-light");!n||!r||(n.disabled=s!=="dark",r.disabled=s!=="light")}function n3t(s,n){SO(s)&&(document.documentElement.style.setProperty("--bg-map",s),Uf("or_bg_color",s),r3t(n),n.syncDisplayState())}function i3t(s){document.documentElement.style.removeProperty("--bg-map"),Vhe("or_bg_color"),r3t(s),s.syncDisplayState()}function q5e(){return Vxt(getComputedStyle(document.documentElement).getPropertyValue("--bg-map"))??"#000000"}function r3t(s){s.threeDViewerWidget?.render?.()}if(typeof document<"u"){let s=ph("or_theme")||typeof localStorage<"u"&&localStorage.getItem("or_theme")||(matchMedia("(prefers-color-scheme: light)").matches?"light":"dark");document.documentElement.dataset.theme=s,H5e(s);let n=ph("or_bg_color");SO(n)&&document.documentElement.style.setProperty("--bg-map",n)}function fk(){let s=getComputedStyle(document.documentElement),n=r=>s.getPropertyValue(r).trim();return{canvasBg:n("--canvas-bg"),canvasText:n("--canvas-text"),canvasAxis:n("--canvas-axis"),canvasLabel:n("--canvas-label"),canvasGrid:n("--canvas-grid"),canvasTitle:n("--canvas-title"),fgPrimary:n("--fg-primary"),fgMuted:n("--fg-muted"),bgPanel:n("--bg-panel"),bgMap:n("--bg-map"),fontMono:n("--font-mono"),fontSans:n("--font-sans")}}function hk(s,n){let r=document.createElement("a");r.href=s,r.download=n,document.body.appendChild(r),r.click(),r.remove()}function s3t(s,n){let r=URL.createObjectURL(s);hk(r,n),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function X5e(s){let n=s.cloneNode(!0);if(n.getAttribute("xmlns")||n.setAttribute("xmlns","http://www.w3.org/2000/svg"),n.getAttribute("xmlns:xlink")||n.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),!n.getAttribute("width")||!n.getAttribute("height")){let r=s.viewBox&&s.viewBox.baseVal;r&&r.width&&r.height&&(n.setAttribute("width",r.width),n.setAttribute("height",r.height))}return` +`+new XMLSerializer().serializeToString(n)}function sdn(s){let n=s.viewBox&&s.viewBox.baseVal;if(n&&n.width&&n.height)return{width:n.width,height:n.height};let r=parseFloat(s.getAttribute("width")),c=parseFloat(s.getAttribute("height"));if(r&&c)return{width:r,height:c};let u=s.getBoundingClientRect();return{width:u.width||800,height:u.height||600}}function Y5e(s,n=2){let{width:r,height:c}=sdn(s),u=X5e(s),d=new Blob([u],{type:"image/svg+xml;charset=utf-8"}),b=URL.createObjectURL(d);return new Promise((w,_)=>{let x=new Image;x.onload=()=>{let T=document.createElement("canvas");T.width=Math.max(1,Math.round(r*n)),T.height=Math.max(1,Math.round(c*n));let M=T.getContext("2d");M.fillStyle="#ffffff",M.fillRect(0,0,T.width,T.height),M.drawImage(x,0,0,T.width,T.height),URL.revokeObjectURL(b),w(T.toDataURL("image/png"))},x.onerror=T=>{URL.revokeObjectURL(b),_(T)},x.src=b})}async function Hhe(s){try{if(!navigator.clipboard||!window.ClipboardItem)return!1;let n=await(await fetch(s)).blob();return await navigator.clipboard.write([new ClipboardItem({"image/png":n})]),!0}catch{return!1}}function odn(s){return(String(s||"").replace(/[^A-Za-z0-9._-]/g,"_").replace(/^_+|_+$/g,"")||"clock_tree")+".png"}var Z5e=24,K5e=10,Xhe=40,adn=40,J5e=70,cdn=20,qhe={root:"#ff4444",buffer:"#4488ff",inverter:"#00b0b0",clock_gate:"#cc44cc",register:"#ff4444",macro:"#00b0b0",unknown:"#888888"};function ldn(s){let n=parseInt(s.slice(1,3),16),r=parseInt(s.slice(3,5),16),c=parseInt(s.slice(5,7),16),u=b=>Math.round((b+255)/2),d=b=>b.toString(16).padStart(2,"0");return"#"+d(u(n))+d(u(r))+d(u(c))}function udn(s){let n=s.nodes;if(!n||n.length===0)return{layout:[],layoutWidth:0,layoutHeight:0,timeMin:0,timeMax:0,timeUnit:"",sceneHeight:0,layoutById:new Map};let r=new Map;for(let Z of n)r.set(Z.id,[]);for(let Z of n)Z.parent_id>=0&&r.has(Z.parent_id)&&r.get(Z.parent_id).push(Z.id);let c=new Map;for(let Z of n)c.set(Z.id,Z);let u=new Map,d=Z=>{let H=r.get(Z)||[];if(H.length===0)return u.set(Z,1),1;let te=0;for(let oe of H)te+=d(oe);return u.set(Z,te),te},b=n.filter(Z=>Z.parent_id===-1),w=0;for(let Z of b)w+=d(Z.id);let _=s.min_arrival,x=s.max_arrival,T=x-_||1,M=Math.max(200,w*Z5e*.6),L=[],I=(Z,H)=>{let te=c.get(Z),oe=u.get(Z),ne=J5e+(H+oe/2)*Z5e,ue=Xhe+(te.arrival-_)/T*M;L.push({id:te.id,x:ne,y:ue,type:te.type,name:te.name,pin_name:te.pin_name,arrival:te.arrival,delay:te.delay,fanout:te.fanout,level:te.level,parent_id:te.parent_id});let Te=H,Q=r.get(Z)||[];for(let ge of Q)I(ge,Te),Te+=u.get(ge)},D=0;for(let Z of b)I(Z.id,D),D+=u.get(Z.id);let F=J5e+w*Z5e+cdn,O=Xhe+M+adn,z=new Map;for(let Z of L)z.set(Z.id,Z);return{layout:L,layoutWidth:F,layoutHeight:O,timeMin:_,timeMax:x,timeUnit:s.time_unit||"",sceneHeight:M,layoutById:z}}var Yhe=class{constructor(n,r,c,u){this._app=r,this._redrawAllLayers=c,this._refreshOverlay=u||c,this._clockData=[],this._selectedClockIdx=0,this._selectedNodeId=-1,this._tx=0,this._ty=0,this._scale=1,this._layout=[],this._dragging=!1,this._dragStartX=0,this._dragStartY=0,this._dragStartTx=0,this._dragStartTy=0,this._build(n)}_build(n){let r=document.createElement("div");r.className="clock-tree-widget";let c=document.createElement("div");c.className="clock-tree-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",ua(this._app)&&(this._updateBtn.style.display="none"),this._fitBtn=document.createElement("button"),this._fitBtn.className="or-btn",this._fitBtn.textContent="Fit",this._pngBtn=document.createElement("button"),this._pngBtn.className="or-btn",this._pngBtn.textContent="PNG",this._pngBtn.title="Export the clock tree as a PNG image",this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",c.appendChild(this._updateBtn),c.appendChild(this._fitBtn),c.appendChild(this._pngBtn),c.appendChild(this._statusLabel),r.appendChild(c),this._tabBar=document.createElement("div"),this._tabBar.className="timing-tab-bar",r.appendChild(this._tabBar),this._canvas=document.createElement("canvas"),this._canvas.className="clock-tree-canvas",r.appendChild(this._canvas),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._tooltip.style.display="none",r.appendChild(this._tooltip),n.element.appendChild(r),this._el=r,this._ctx=this._canvas.getContext("2d"),this._bindEvents(),ua(this._app)&&setTimeout(()=>this.update(),0)}_fit(){this._sizeCanvas(),this._fitToView(),this._render()}_pngFileName(){let n=this._clockData[this._selectedClockIdx];return odn(n&&n.name)}_exportPng(){try{hk(this._canvas.toDataURL("image/png"),this._pngFileName())}catch(n){console.error("PNG export failed:",n)}}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update()),this._fitBtn.addEventListener("click",()=>this._fit()),this._pngBtn.addEventListener("click",()=>this._exportPng()),this._canvas.addEventListener("keydown",n=>{n.key==="f"&&this._fit()}),this._canvas.tabIndex=0,this._canvas.addEventListener("wheel",n=>{n.preventDefault();let r=this._canvas.getBoundingClientRect(),c=n.clientX-r.left,u=n.clientY-r.top,d=n.deltaY<0?1.15:1/1.15;this._tx=c-(c-this._tx)*d,this._ty=u-(u-this._ty)*d,this._scale*=d,this._render()}),this._canvas.addEventListener("mousedown",n=>{this._dragging=!0,this._dragStartX=n.clientX,this._dragStartY=n.clientY,this._dragStartTx=this._tx,this._dragStartTy=this._ty,this._canvas.style.cursor="grabbing"}),window.addEventListener("mousemove",n=>{this._dragging?(this._tx=this._dragStartTx+(n.clientX-this._dragStartX),this._ty=this._dragStartTy+(n.clientY-this._dragStartY),this._render()):this._handleHover(n)}),window.addEventListener("mouseup",()=>{this._dragging&&(this._dragging=!1,this._canvas.style.cursor="grab")}),this._canvas.addEventListener("click",n=>this._handleClick(n)),this._resizeObserver=new ResizeObserver(()=>{this._sizeCanvas(),this._render()}),this._resizeObserver.observe(this._canvas)}_sizeCanvas(){let n=this._canvas.getBoundingClientRect(),r=window.devicePixelRatio||1;this._canvas.width=n.width*r,this._canvas.height=n.height*r,this._ctx.setTransform(r,0,0,r,0,0)}async update(){this._statusLabel.textContent="Loading...";try{let n=await this._app.websocketManager.request({type:"clock_tree"});this._clockData=n.clocks||[],this._buildTabs(),this._selectClock(0),this._statusLabel.textContent=this._clockData.length+" clock"+(this._clockData.length!==1?"s":"")}catch(n){console.error("Clock tree error:",n),this._statusLabel.textContent="Error: "+n.message}}_buildTabs(){this._tabBar.innerHTML="",this._clockData.forEach((n,r)=>{let c=document.createElement("button");c.className="timing-tab"+(r===this._selectedClockIdx?" active":""),c.textContent=n.name,c.addEventListener("click",()=>this._selectClock(r)),this._tabBar.appendChild(c)})}_selectClock(n){if(n<0||n>=this._clockData.length)return;this._selectedClockIdx=n,this._selectedNodeId=-1,this._tabBar.querySelectorAll(".timing-tab").forEach((c,u)=>{c.classList.toggle("active",u===n)}),this._computeLayout(this._clockData[n]),requestAnimationFrame(()=>{this._sizeCanvas(),this._fitToView(),this._render()})}_computeLayout(n){let r=udn(n);this._layout=r.layout,this._layoutWidth=r.layoutWidth,this._layoutHeight=r.layoutHeight,this._timeMin=r.timeMin,this._timeMax=r.timeMax,this._timeUnit=r.timeUnit,this._sceneHeight=r.sceneHeight,this._layoutById=r.layoutById}_fitToView(){if(!this._layout.length)return;let n=this._canvas.getBoundingClientRect(),r=n.width,c=n.height,u=r/this._layoutWidth,d=c/this._layoutHeight;this._scale=Math.min(u,d)*.9,this._tx=(r-this._layoutWidth*this._scale)/2,this._ty=(c-this._layoutHeight*this._scale)/2}render(){this._render()}_render(){let n=this._ctx,r=this._canvas.getBoundingClientRect(),c=r.width,u=r.height,d=fk();if(n.clearRect(0,0,c,u),n.fillStyle=d.canvasBg,n.fillRect(0,0,c,u),!this._layout.length){n.fillStyle=d.canvasText,n.font="14px "+d.fontSans,n.textAlign="center";let b=ua(this._app)?"No clock tree data available":'Click "Update" to load clock tree data';n.fillText(b,c/2,u/2);return}n.save(),n.translate(this._tx,this._ty),n.scale(this._scale,this._scale),this._drawConnections(n);for(let b of this._layout)this._drawNode(n,b,b.id===this._selectedNodeId);n.restore(),this._drawTimeScale(n,c,u,d)}_drawConnections(n){let r=1.5/this._scale,c=K5e,u=this._timeMax-this._timeMin||1;for(let d of this._layout){if(d.parent_id<0)continue;let b=this._layoutById.get(d.parent_id);if(!b)continue;let w=b.x,_=d.x,x=(b.delay||0)/u*this._sceneHeight,T=b.y+x,M=d.y,L=b.type==="root"?b.y:b.y+c;if(T>L){let D=qhe[b.type]||qhe.unknown;n.strokeStyle=D,n.lineWidth=r,n.beginPath(),n.moveTo(w,L),n.lineTo(w,T);let F=c/20;n.moveTo(w-F,T),n.lineTo(w+F,T),n.stroke()}n.strokeStyle="#006400",n.lineWidth=r;let I=(T+M)/2;n.beginPath(),n.moveTo(w,T),n.bezierCurveTo(w,I,_,I,_,M),n.stroke()}}_drawNode(n,r,c){let u=r.x,d=r.y,b=K5e,w=qhe[r.type]||qhe.unknown;switch(n.fillStyle=ldn(w),n.strokeStyle=w,n.lineWidth=1/this._scale,r.type){case"root":{n.beginPath(),n.moveTo(u-b/2,d-b),n.lineTo(u+b/2,d-b),n.lineTo(u,d),n.closePath(),n.fill(),n.stroke();break}case"buffer":{n.beginPath(),n.moveTo(u-b/2,d),n.lineTo(u+b/2,d),n.lineTo(u,d+b),n.closePath(),n.fill(),n.stroke();break}case"inverter":{let _=b*.1,x=d+b-_;n.beginPath(),n.moveTo(u-b/2,d),n.lineTo(u+b/2,d),n.lineTo(u,x),n.closePath(),n.fill(),n.stroke(),n.beginPath(),n.arc(u,x+_/2,_/2,0,Math.PI*2),n.fill(),n.stroke();break}case"clock_gate":{n.beginPath(),n.arc(u,d+b/2,b/2,0,Math.PI*2),n.fill(),n.stroke();break}case"register":case"macro":{n.beginPath(),n.rect(u-b/2,d,b,b),n.fill(),n.stroke(),n.beginPath(),n.moveTo(u-b/8,d),n.lineTo(u+b/8,d),n.lineTo(u,d+b/4),n.closePath(),n.stroke();break}default:{n.beginPath(),n.arc(u,d+b/2,b/2,0,Math.PI*2),n.fill(),n.stroke();break}}if(c){n.strokeStyle="#ffff00",n.lineWidth=2/this._scale;let _=r.type==="root"?d-b/2:d+b/2;n.beginPath(),n.arc(u,_,b/2+3,0,Math.PI*2),n.stroke()}}_drawTimeScale(n,r,c,u){if(!this._sceneHeight)return;let d=F=>F*this._scale+this._ty,b=d(Xhe),w=d(Xhe+this._sceneHeight);if(w<0||b>c)return;n.save(),n.fillStyle=u.canvasLabel,n.strokeStyle=u.canvasAxis,n.font="11px "+u.fontMono,n.textAlign="right",n.textBaseline="middle";let _=this._timeMax-this._timeMin;if(_<=0){n.restore();return}let x=w-b,T=Math.max(2,Math.floor(x/40)),M=_/T,L=Math.pow(10,Math.floor(Math.log10(M))),I=L;M/L>5?I=10*L:M/L>2?I=5*L:M/L>1&&(I=2*L);let D=Math.ceil(this._timeMin/I)*I;n.beginPath();for(let F=D;F<=this._timeMax;F+=I){let O=(F-this._timeMin)/_,z=b+O*(w-b);n.moveTo(0,z),n.lineTo(r,z);let Z=F.toFixed(I<.01?3:I<.1?2:1)+" "+this._timeUnit;n.fillText(Z,J5e-4,z)}n.stroke(),n.restore()}_screenToLayout(n,r){return{x:(n-this._tx)/this._scale,y:(r-this._ty)/this._scale}}_hitTest(n,r){let c=this._screenToLayout(n,r),u=K5e;for(let d of this._layout){let b=d.type==="root"?d.y-u:d.y,w=d.type==="root"?d.y:d.y+u;if(c.x>=d.x-u/2&&c.x<=d.x+u/2&&c.y>=b&&c.y<=w)return d}return null}_handleClick(n){let r=this._canvas.getBoundingClientRect(),c=n.clientX-r.left,u=n.clientY-r.top,d=this._hitTest(c,u);d?(this._selectedNodeId=d.id,this._render(),this._app.websocketManager.request({type:"clock_tree_highlight",inst_name:d.name}).then(()=>this._refreshOverlay())):this._selectedNodeId>=0&&(this._selectedNodeId=-1,this._render(),this._app.websocketManager.request({type:"clock_tree_highlight",inst_name:""}).then(()=>this._refreshOverlay()))}_handleHover(n){let r=this._canvas.getBoundingClientRect(),c=n.clientX-r.left,u=n.clientY-r.top;if(c<0||u<0||c>r.width||u>r.height){this._tooltip.style.display="none";return}let d=this._hitTest(c,u);if(d){let b=[d.name,"Type: "+d.type,"Arrival: "+d.arrival.toFixed(3)+" "+(this._timeUnit||"")];d.delay&&b.push("Delay: "+d.delay.toFixed(3)+" "+(this._timeUnit||"")),d.fanout&&b.push("Fanout: "+d.fanout),this._tooltip.textContent=b.join(` +`),this._tooltip.style.display="block",this._tooltip.style.left=n.clientX+12+"px",this._tooltip.style.top=n.clientY+12+"px"}else this._tooltip.style.display="none"}};var a3t=60,c3t=20,l3t=30,u3t=50,o3t=2,fdn="#f08080",hdn="#8b0000",ddn="#90ee90",pdn="#006400",xT=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7"],gdn="rgba(240,128,128,0.12)",mdn="rgba(144,238,144,0.12)",bdn="#ff9999",wdn="#b0ffb0",vdn=[{value:"setup",label:"Setup Slack"},{value:"hold",label:"Hold Slack"},{value:"fanout",label:"Net Fanout"},{value:"netlength",label:"Net Length (HPWL)"}];function _dn(s,n,r,c){if(!s||!n||cn.bottom)return null;for(let u of s)if(r>=u.x&&r<=u.x+u.width)return u;return null}function ydn(s,n,r){return r?Math.log10(s+1)/Math.log10(n+1):s/n}function xdn(s,n,r,c={}){let u=!!c.logY,d=s?.bins;if(!d||d.length===0)return{bars:[],yMax:0,yTicks:[],chartArea:null,logY:u};let b=a3t,w=n-c3t,_=l3t,x=r-u3t,T=w-b,M=x-_;if(T<=0||M<=0)return{bars:[],yMax:0,yTicks:[],chartArea:null,logY:u};let L={left:b,right:w,top:_,bottom:x},I=0;for(let Z of d)Z.count>I&&(I=Z.count);I===0&&(I=1);let{yMax:D,yTicks:F}=u?Sdn(I):Edn(I),O=(T-o3t*(d.length-1))/d.length,z=[];for(let Z=0;Z[x.x,...x.ys||[]].join(","));return[w,..._].join(` `)}let r=n.bins||[],c=Array.isArray(n.series)?n.series:[],u=["lower","upper","count",...c.map(b=>b.name||"group")].join(","),d=r.map((b,w)=>{let _=[b.lower,b.upper,b.count];for(let x of c)_.push(x.counts&&x.counts[w]||0);return _.join(",")});return[u,...d].join(` -`)}var Zhe=class{constructor(n,r){this._app=n,this._redrawAllLayers=r,this._currentTab="setup",this._histogramData=null,this._bars=[],this._yMax=0,this._yTicks=[],this._chartArea=null,this._hoveredBar=null,this._debugCharts=[],this._activeDebugChart=-1,this._build()}_build(){let n=document.createElement("div");n.className="charts-widget";let r=document.createElement("div");r.className="charts-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",la(this._app)&&(this._updateBtn.style.display="none"),this._chartSelect=document.createElement("select"),this._chartSelect.className="charts-select",this._csvBtn=document.createElement("button"),this._csvBtn.className="or-btn",this._csvBtn.textContent="CSV",this._csvBtn.title="Export the current chart data as CSV",this._pngBtn=document.createElement("button"),this._pngBtn.className="or-btn",this._pngBtn.textContent="PNG",this._pngBtn.title="Export the current chart as a PNG image",this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",r.appendChild(this._updateBtn),r.appendChild(this._chartSelect),r.appendChild(this._csvBtn),r.appendChild(this._pngBtn),r.appendChild(this._statusLabel),n.appendChild(r);let c=document.createElement("div");c.className="charts-toolbar";let u=document.createElement("span");u.textContent="Path Groups:",u.style.color="var(--fg-muted)",u.style.fontSize="var(--fs-12)",this._pathGroupSelect=document.createElement("select"),this._pathGroupSelect.className="charts-select",this._pathGroupSelect.multiple=!0,this._pathGroupSelect.size=1,this._pathGroupSelect.title="Select 0 = all, or \u22651 to stack by group";let d=document.createElement("span");d.textContent="Clock:",d.style.color="var(--fg-muted)",d.style.fontSize="var(--fs-12)",this._clockSelect=document.createElement("select"),this._clockSelect.className="charts-select",this._clockSelect.innerHTML='',c.appendChild(u),c.appendChild(this._pathGroupSelect),c.appendChild(d),c.appendChild(this._clockSelect),n.appendChild(c),this._canvas=document.createElement("canvas"),this._canvas.className="charts-canvas",n.appendChild(this._canvas),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._tooltip.style.display="none",n.appendChild(this._tooltip),this._filterRow=c,this.element=n,this._ctx=this._canvas.getContext("2d"),this._rebuildSelect(),this._bindEvents(),la(this._app)&&setTimeout(()=>this.update(),0)}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update()),this._chartSelect.addEventListener("change",()=>this._onSelectChange()),this._csvBtn.addEventListener("click",()=>this._exportCsv()),this._pngBtn.addEventListener("click",()=>this._exportPng()),this._pathGroupSelect.addEventListener("change",()=>this._fetchHistogram()),this._clockSelect.addEventListener("change",()=>this._fetchHistogram()),this._canvas.addEventListener("mousemove",r=>this._handleHover(r)),this._canvas.addEventListener("mouseleave",()=>{this._hoveredBar=null,this._tooltip.style.display="none",this._syncView()}),this._canvas.addEventListener("click",r=>this._handleClick(r)),this._canvas.addEventListener("dblclick",r=>this._handleDblClick(r)),new ResizeObserver(()=>this._syncView()).observe(this._canvas)}_sizeCanvas(){let n=this._canvas.getBoundingClientRect(),r=window.devicePixelRatio||1;this._canvas.width=n.width*r,this._canvas.height=n.height*r,this._ctx.setTransform(r,0,0,r,0,0)}_rebuildSelect(){let n=this._chartSelect;n.innerHTML="";for(let r of mdn){let c=document.createElement("option");c.value=r.value,c.textContent=r.label,n.appendChild(c)}this._debugCharts.forEach((r,c)=>{let u=document.createElement("option");u.value="gen:"+c,u.textContent=r.name||"Chart "+c,n.appendChild(u)}),n.value=this._activeDebugChart>=0?"gen:"+this._activeDebugChart:this._currentTab}_onSelectChange(){let n=this._chartSelect.value;n.startsWith("gen:")?(this._activeDebugChart=parseInt(n.slice(4),10)||0,this._hoveredBar=null,this._tooltip.style.display="none",this._syncView()):this._selectTab(n)}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...",this._statusLabel.textContent="";try{this._activeDebugChart<0?((this._currentTab==="setup"||this._currentTab==="hold")&&await this._fetchFilters(),await Promise.all([this._fetchHistogram(),this._fetchGenericCharts()])):await this._fetchGenericCharts()}catch(n){this._statusLabel.textContent="Error: "+n.message}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}async _fetchFilters(){let n=await this._app.websocketManager.request({type:"chart_filters"});this._populatePathGroups(n.path_groups||[]),this._populateClocks(n.clocks||[])}_populatePathGroups(n){let r=new Set(Array.from(this._pathGroupSelect.selectedOptions,c=>c.value));this._pathGroupSelect.innerHTML="";for(let c of n){let u=document.createElement("option");u.value=c,u.textContent=c,u.selected=r.has(c),this._pathGroupSelect.appendChild(u)}}_populateClocks(n){let r=this._clockSelect.value;this._clockSelect.innerHTML='';for(let c of n){let u=document.createElement("option");u.value=c,u.textContent=c,this._clockSelect.appendChild(u)}n.includes(r)&&(this._clockSelect.value=r)}async _fetchGenericCharts(){try{let n=await this._app.websocketManager.request({type:"debug_charts"});this.setDebugCharts(n.charts||[])}catch{}}async _fetchHistogram(){try{let n=this._currentTab,r;if(n==="fanout")r={type:"fanout_histogram"};else if(n==="netlength")r={type:"net_length_histogram",use_dbu:!!this._app.showDbu};else{r={type:"slack_histogram",is_setup:n==="setup"};let u=Array.from(this._pathGroupSelect.selectedOptions,d=>d.value).filter(Boolean);u.length>0&&(r.path_groups=u),this._clockSelect.value&&(r.clock_name=this._clockSelect.value)}let c=await this._app.websocketManager.request(r);if(this._currentTab!==n)return;if(this._histogramData=c,this._syncView(),n==="fanout"||n==="netlength"){let u=c.total_nets||0;this._statusLabel.textContent=`${u} nets`}else{let u=c.total_endpoints||0,d=c.unconstrained_count||0,b=u-d;this._statusLabel.textContent=`${b} endpoints`+(d>0?`, ${d} unconstrained`:"")}}catch(n){this._statusLabel.textContent="Error: "+n.message}}_selectTab(n){this._currentTab===n&&this._activeDebugChart<0||(this._currentTab=n,this._activeDebugChart=-1,this._chartSelect&&(this._chartSelect.value=n),this._filterRow.style.display=n==="setup"||n==="hold"?"":"none",this._hoveredBar=null,this._tooltip.style.display="none",this.update())}_computeLayout(){if(!this._histogramData)return;let n=this._canvas.getBoundingClientRect(),r=vdn(this._histogramData,n.width,n.height,{logY:this._currentTab==="fanout"});this._bars=r.bars,this._yMax=r.yMax,this._yTicks=r.yTicks,this._chartArea=r.chartArea,this._logY=!!r.logY}render(){this._syncView()}_stackedSeries(){let n=this._histogramData?.series;return Array.isArray(n)&&n.length>1?n:null}_render(){let n=this._canvas.getBoundingClientRect(),r=n.width,c=n.height,u=this._ctx,d=fk();if(u.clearRect(0,0,r,c),u.fillStyle=d.canvasBg,u.fillRect(0,0,r,c),!this._bars||this._bars.length===0){u.fillStyle=d.canvasText,u.font="14px "+d.fontSans,u.textAlign="center",u.textBaseline="middle";let b=la(this._app)?"No histogram data available":'Click "Update" to load histogram';u.fillText(b,r/2,c/2);return}this._drawAxes(u,d),this._drawBars(u),this._drawTitle(u,r,d),this._stackedSeries()&&this._drawSeriesLegend(u,d)}_drawAxes(n,r){let c=this._chartArea;if(!c)return;n.strokeStyle=r.canvasAxis,n.lineWidth=1,n.beginPath(),n.moveTo(c.left,c.top),n.lineTo(c.left,c.bottom),n.stroke(),n.beginPath(),n.moveTo(c.left,c.bottom),n.lineTo(c.right,c.bottom),n.stroke(),n.fillStyle=r.canvasLabel,n.font="11px "+r.fontMono,n.textAlign="right",n.textBaseline="middle";let u=c.bottom-c.top;for(let L of this._yTicks){let I=this._logY?Math.log10(L+1)/Math.log10(this._yMax+1):L/this._yMax,D=c.bottom-I*u;n.fillText(this._formatCount(L),c.left-6,D),L>0&&(n.strokeStyle=r.canvasGrid,n.beginPath(),n.moveTo(c.left,D),n.lineTo(c.right,D),n.stroke(),n.strokeStyle=r.canvasAxis)}let d=this._currentTab,b=d==="fanout"||d==="netlength";n.save(),n.translate(14,(c.top+c.bottom)/2),n.rotate(-Math.PI/2),n.textAlign="center",n.textBaseline="middle",n.fillStyle=r.canvasTitle,n.font="11px "+r.fontMono,n.fillText(this._logY?"Nets (log)":b?"Nets":"Endpoints",0,0),n.restore(),n.textAlign="center",n.textBaseline="top",n.fillStyle=r.canvasLabel,n.font="10px "+r.fontMono;let w=this._histogramData.bins,_=this._histogramData.time_unit||this._histogramData.length_unit||"",x=w.length>0?w[0].upper-w[0].lower:1,T=d==="fanout"?0:Math.max(0,-Math.floor(Math.log10(x)));for(let L=0;L<=this._bars.length;L++){let I=L=0){this._hoveredBar=null,this._tooltip.style.display="none";return}let r=this._hitTestBar(n);if(r!==this._hoveredBar&&(this._hoveredBar=r,this._render()),r){let c=this._currentTab,u=r.upper-r.lower;if(c==="fanout"){let L=r.upper-1,I=r.lower===L?`${r.lower}`:`[${r.lower}, ${L}]`;this._tooltip.textContent=`Nets: ${r.count} +`)}var Zhe=class{constructor(n,r){this._app=n,this._redrawAllLayers=r,this._currentTab="setup",this._histogramData=null,this._bars=[],this._yMax=0,this._yTicks=[],this._chartArea=null,this._hoveredBar=null,this._debugCharts=[],this._activeDebugChart=-1,this._build()}_build(){let n=document.createElement("div");n.className="charts-widget";let r=document.createElement("div");r.className="charts-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",ua(this._app)&&(this._updateBtn.style.display="none"),this._chartSelect=document.createElement("select"),this._chartSelect.className="charts-select",this._csvBtn=document.createElement("button"),this._csvBtn.className="or-btn",this._csvBtn.textContent="CSV",this._csvBtn.title="Export the current chart data as CSV",this._pngBtn=document.createElement("button"),this._pngBtn.className="or-btn",this._pngBtn.textContent="PNG",this._pngBtn.title="Export the current chart as a PNG image",this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",r.appendChild(this._updateBtn),r.appendChild(this._chartSelect),r.appendChild(this._csvBtn),r.appendChild(this._pngBtn),r.appendChild(this._statusLabel),n.appendChild(r);let c=document.createElement("div");c.className="charts-toolbar";let u=document.createElement("span");u.textContent="Path Groups:",u.style.color="var(--fg-muted)",u.style.fontSize="var(--fs-12)",this._pathGroupSelect=document.createElement("select"),this._pathGroupSelect.className="charts-select",this._pathGroupSelect.multiple=!0,this._pathGroupSelect.size=1,this._pathGroupSelect.title="Select 0 = all, or \u22651 to stack by group";let d=document.createElement("span");d.textContent="Clock:",d.style.color="var(--fg-muted)",d.style.fontSize="var(--fs-12)",this._clockSelect=document.createElement("select"),this._clockSelect.className="charts-select",this._clockSelect.innerHTML='',c.appendChild(u),c.appendChild(this._pathGroupSelect),c.appendChild(d),c.appendChild(this._clockSelect),n.appendChild(c),this._canvas=document.createElement("canvas"),this._canvas.className="charts-canvas",n.appendChild(this._canvas),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._tooltip.style.display="none",n.appendChild(this._tooltip),this._filterRow=c,this.element=n,this._ctx=this._canvas.getContext("2d"),this._rebuildSelect(),this._bindEvents(),ua(this._app)&&setTimeout(()=>this.update(),0)}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update()),this._chartSelect.addEventListener("change",()=>this._onSelectChange()),this._csvBtn.addEventListener("click",()=>this._exportCsv()),this._pngBtn.addEventListener("click",()=>this._exportPng()),this._pathGroupSelect.addEventListener("change",()=>this._fetchHistogram()),this._clockSelect.addEventListener("change",()=>this._fetchHistogram()),this._canvas.addEventListener("mousemove",r=>this._handleHover(r)),this._canvas.addEventListener("mouseleave",()=>{this._hoveredBar=null,this._tooltip.style.display="none",this._syncView()}),this._canvas.addEventListener("click",r=>this._handleClick(r)),this._canvas.addEventListener("dblclick",r=>this._handleDblClick(r)),new ResizeObserver(()=>this._syncView()).observe(this._canvas)}_sizeCanvas(){let n=this._canvas.getBoundingClientRect(),r=window.devicePixelRatio||1;this._canvas.width=n.width*r,this._canvas.height=n.height*r,this._ctx.setTransform(r,0,0,r,0,0)}_rebuildSelect(){let n=this._chartSelect;n.innerHTML="";for(let r of vdn){let c=document.createElement("option");c.value=r.value,c.textContent=r.label,n.appendChild(c)}this._debugCharts.forEach((r,c)=>{let u=document.createElement("option");u.value="gen:"+c,u.textContent=r.name||"Chart "+c,n.appendChild(u)}),n.value=this._activeDebugChart>=0?"gen:"+this._activeDebugChart:this._currentTab}_onSelectChange(){let n=this._chartSelect.value;n.startsWith("gen:")?(this._activeDebugChart=parseInt(n.slice(4),10)||0,this._hoveredBar=null,this._tooltip.style.display="none",this._syncView()):this._selectTab(n)}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...",this._statusLabel.textContent="";try{this._activeDebugChart<0?((this._currentTab==="setup"||this._currentTab==="hold")&&await this._fetchFilters(),await Promise.all([this._fetchHistogram(),this._fetchGenericCharts()])):await this._fetchGenericCharts()}catch(n){this._statusLabel.textContent="Error: "+n.message}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}async _fetchFilters(){let n=await this._app.websocketManager.request({type:"chart_filters"});this._populatePathGroups(n.path_groups||[]),this._populateClocks(n.clocks||[])}_populatePathGroups(n){let r=new Set(Array.from(this._pathGroupSelect.selectedOptions,c=>c.value));this._pathGroupSelect.innerHTML="";for(let c of n){let u=document.createElement("option");u.value=c,u.textContent=c,u.selected=r.has(c),this._pathGroupSelect.appendChild(u)}}_populateClocks(n){let r=this._clockSelect.value;this._clockSelect.innerHTML='';for(let c of n){let u=document.createElement("option");u.value=c,u.textContent=c,this._clockSelect.appendChild(u)}n.includes(r)&&(this._clockSelect.value=r)}async _fetchGenericCharts(){try{let n=await this._app.websocketManager.request({type:"debug_charts"});this.setDebugCharts(n.charts||[])}catch{}}async _fetchHistogram(){try{let n=this._currentTab,r;if(n==="fanout")r={type:"fanout_histogram"};else if(n==="netlength")r={type:"net_length_histogram",use_dbu:!!this._app.showDbu};else{r={type:"slack_histogram",is_setup:n==="setup"};let u=Array.from(this._pathGroupSelect.selectedOptions,d=>d.value).filter(Boolean);u.length>0&&(r.path_groups=u),this._clockSelect.value&&(r.clock_name=this._clockSelect.value)}let c=await this._app.websocketManager.request(r);if(this._currentTab!==n)return;if(this._histogramData=c,this._syncView(),n==="fanout"||n==="netlength"){let u=c.total_nets||0;this._statusLabel.textContent=`${u} nets`}else{let u=c.total_endpoints||0,d=c.unconstrained_count||0,b=u-d;this._statusLabel.textContent=`${b} endpoints`+(d>0?`, ${d} unconstrained`:"")}}catch(n){this._statusLabel.textContent="Error: "+n.message}}_selectTab(n){this._currentTab===n&&this._activeDebugChart<0||(this._currentTab=n,this._activeDebugChart=-1,this._chartSelect&&(this._chartSelect.value=n),this._filterRow.style.display=n==="setup"||n==="hold"?"":"none",this._hoveredBar=null,this._tooltip.style.display="none",this.update())}_computeLayout(){if(!this._histogramData)return;let n=this._canvas.getBoundingClientRect(),r=xdn(this._histogramData,n.width,n.height,{logY:this._currentTab==="fanout"});this._bars=r.bars,this._yMax=r.yMax,this._yTicks=r.yTicks,this._chartArea=r.chartArea,this._logY=!!r.logY}render(){this._syncView()}_stackedSeries(){let n=this._histogramData?.series;return Array.isArray(n)&&n.length>1?n:null}_render(){let n=this._canvas.getBoundingClientRect(),r=n.width,c=n.height,u=this._ctx,d=fk();if(u.clearRect(0,0,r,c),u.fillStyle=d.canvasBg,u.fillRect(0,0,r,c),!this._bars||this._bars.length===0){u.fillStyle=d.canvasText,u.font="14px "+d.fontSans,u.textAlign="center",u.textBaseline="middle";let b=ua(this._app)?"No histogram data available":'Click "Update" to load histogram';u.fillText(b,r/2,c/2);return}this._drawAxes(u,d),this._drawBars(u),this._drawTitle(u,r,d),this._stackedSeries()&&this._drawSeriesLegend(u,d)}_drawAxes(n,r){let c=this._chartArea;if(!c)return;n.strokeStyle=r.canvasAxis,n.lineWidth=1,n.beginPath(),n.moveTo(c.left,c.top),n.lineTo(c.left,c.bottom),n.stroke(),n.beginPath(),n.moveTo(c.left,c.bottom),n.lineTo(c.right,c.bottom),n.stroke(),n.fillStyle=r.canvasLabel,n.font="11px "+r.fontMono,n.textAlign="right",n.textBaseline="middle";let u=c.bottom-c.top;for(let L of this._yTicks){let I=this._logY?Math.log10(L+1)/Math.log10(this._yMax+1):L/this._yMax,D=c.bottom-I*u;n.fillText(this._formatCount(L),c.left-6,D),L>0&&(n.strokeStyle=r.canvasGrid,n.beginPath(),n.moveTo(c.left,D),n.lineTo(c.right,D),n.stroke(),n.strokeStyle=r.canvasAxis)}let d=this._currentTab,b=d==="fanout"||d==="netlength";n.save(),n.translate(14,(c.top+c.bottom)/2),n.rotate(-Math.PI/2),n.textAlign="center",n.textBaseline="middle",n.fillStyle=r.canvasTitle,n.font="11px "+r.fontMono,n.fillText(this._logY?"Nets (log)":b?"Nets":"Endpoints",0,0),n.restore(),n.textAlign="center",n.textBaseline="top",n.fillStyle=r.canvasLabel,n.font="10px "+r.fontMono;let w=this._histogramData.bins,_=this._histogramData.time_unit||this._histogramData.length_unit||"",x=w.length>0?w[0].upper-w[0].lower:1,T=d==="fanout"?0:Math.max(0,-Math.floor(Math.log10(x)));for(let L=0;L<=this._bars.length;L++){let I=L=0){this._hoveredBar=null,this._tooltip.style.display="none";return}let r=this._hitTestBar(n);if(r!==this._hoveredBar&&(this._hoveredBar=r,this._render()),r){let c=this._currentTab,u=r.upper-r.lower;if(c==="fanout"){let L=r.upper-1,I=r.lower===L?`${r.lower}`:`[${r.lower}, ${L}]`;this._tooltip.textContent=`Nets: ${r.count} Fanout: ${I}`}else if(c==="netlength"){let L=this._histogramData?.length_unit||"",I=Math.max(0,-Math.floor(Math.log10(u)));this._tooltip.textContent=`Nets: ${r.count} Length: [${r.lower.toFixed(I)}, ${r.upper.toFixed(I)}) ${L}`}else{let L=this._histogramData?.time_unit||"",I=Math.max(0,-Math.floor(Math.log10(u)));this._tooltip.textContent=`Endpoints: ${r.count} -Slack: [${r.lower.toFixed(I)}, ${r.upper.toFixed(I)}) ${L}`}this._tooltip.style.display="block";let d=this.element.getBoundingClientRect(),b=this._tooltip.getBoundingClientRect(),w=4,_=n.clientX-d.left,x=n.clientY-d.top,T=_+12;T+b.width>d.width-w&&(T=_-12-b.width),T=Math.max(w,T);let M=x-10;M=Math.min(d.height-b.height-w,Math.max(w,M)),this._tooltip.style.left=T+"px",this._tooltip.style.top=M+"px"}else this._tooltip.style.display="none"}async _handleClick(n){if(this._activeDebugChart>=0||this._currentTab==="fanout"||this._currentTab==="netlength")return;let r=this._hitTestBar(n);if(!(!r||r.count===0))try{let c=await this._app.websocketManager.request({type:"timing_report",is_setup:this._currentTab==="setup",max_paths:50,slack_min:r.lower,slack_max:r.upper});this._app.timingWidget&&(this._app.timingWidget.showPaths(this._currentTab,c.paths||[]),this._app.focusComponent&&this._app.focusComponent("TimingWidget"))}catch(c){console.error("Charts bar click error:",c)}}async _handleDblClick(n){if(this._activeDebugChart>=0)return;let r;if(this._currentTab==="fanout")r="select_fanout_bin";else if(this._currentTab==="netlength")r="select_net_length_bin";else return;let c=this._hitTestBar(n);if(!c||c.count===0)return;let u=Pm(this._app);try{let d=await this._app.websocketManager.request({type:r,lower:c.lower,upper:c.upper,use_dbu:this._app.showDbu});if(!Y1(this._app,u))return;d&&d.truncated&&console.warn(`Bin has ${d.count} nets; selection capped at ${d.selection_limit} for performance.`),this._app.updateInspector&&this._app.updateInspector(d),this._app.focusComponent&&this._app.focusComponent("Inspector"),this._redrawAllLayers&&this._redrawAllLayers()}catch(d){console.error("Net bin select failed:",d)}}_activeChartData(){return this._activeDebugChart>=0?{kind:"generic",data:this._debugCharts[this._activeDebugChart]}:{kind:"histogram",data:this._histogramData}}_chartBaseName(){return this._activeDebugChart>=0?this._debugCharts[this._activeDebugChart].name||"chart":this._currentTab}_triggerDownload(n,r,{revoke:c=!1}={}){let u=document.createElement("a");u.href=r,u.download=n,document.body.appendChild(u),u.click(),u.remove(),c&&URL.revokeObjectURL(r)}_download(n,r,c){try{let u=URL.createObjectURL(new Blob([c],{type:r}));this._triggerDownload(n,u,{revoke:!0})}catch(u){console.error("Download failed:",u)}}_exportCsv(){let{kind:n,data:r}=this._activeChartData();if(!r)return;let c=xdn(n,r);this._download(this._chartBaseName()+".csv","text/csv",c)}_exportPng(){try{let n=this._canvas.toDataURL("image/png");this._triggerDownload(this._chartBaseName()+".png",n)}catch(n){console.error("PNG export failed:",n)}}setDebugCharts(n){this._debugCharts=n,n.length===0?this._activeDebugChart=-1:this._activeDebugChart>=n.length&&(this._activeDebugChart=0),this._rebuildSelect(),this._syncView()}_syncView(){let n=this._activeDebugChart>=0;n&&(this._hoveredBar=null,this._tooltip.style.display="none");let r=!n&&(this._currentTab==="setup"||this._currentTab==="hold");this._filterRow&&(this._filterRow.style.display=r?"":"none"),this._sizeCanvas(),n?this._renderLineChart(this._debugCharts[this._activeDebugChart]):(this._computeLayout(),this._render())}_renderLineChart(n){let r=this._canvas.getBoundingClientRect(),c=r.width,u=r.height,d=this._ctx,b=fk();d.clearRect(0,0,c,u),d.fillStyle=b.canvasBg,d.fillRect(0,0,c,u);let w=n.points;if(!w||w.length===0){d.fillStyle=b.canvasText,d.font="14px "+b.fontSans,d.textAlign="center",d.textBaseline="middle",d.fillText("No data points yet",c/2,u/2);return}let _=n.y_labels?n.y_labels.length:1,x=o3t,T=c-a3t,M=c3t,L=u-l3t,I=T-x,D=L-M;if(I<=0||D<=0)return;let F=w[0].x,O=w[0].x,z=1/0,Z=-1/0;for(let ue of w){ue.xO&&(O=ue.x);for(let Ce of ue.ys)CeZ&&(Z=Ce)}F===O&&(O=F+1),(!isFinite(z)||!isFinite(Z))&&(z=0,Z=1);let H=(Z-z)*.05||1;z-=H,Z+=H;let te=ue=>x+(ue-F)/(O-F)*I,se=ue=>L-(ue-z)/(Z-z)*D;d.strokeStyle=b.canvasAxis,d.lineWidth=1,d.beginPath(),d.moveTo(x,M),d.lineTo(x,L),d.lineTo(T,L),d.stroke(),d.fillStyle=b.canvasLabel,d.font="10px "+b.fontMono,d.textAlign="right",d.textBaseline="middle";let ne=5;for(let ue=0;ue<=ne;ue++){let Ce=z+(Z-z)*ue/ne,Q=se(Ce);d.fillText(this._formatNum(Ce),x-4,Q),ue>0&&ue1&&n.y_labels){d.font="10px "+b.fontMono,d.textAlign="left",d.textBaseline="top";let ue=x+8,Ce=M+4;for(let Q=0;Q<_;Q++){let me=yT[Q%yT.length];d.fillStyle=me,d.fillRect(ue,Ce+Q*14,12,10),d.fillStyle=b.canvasLabel,d.fillText(n.y_labels[Q],ue+16,Ce+Q*14)}}}_formatNum(n){let r=Math.abs(n);return r===0?"0":r>=1e6?(n/1e6).toFixed(1)+"M":r>=1e3?(n/1e3).toFixed(1)+"k":r>=1?n.toFixed(1):n.toPrecision(3)}_formatCount(n){return n===0?"0":n>=1e6?n/1e6+"M":n>=1e3?n/1e3+"k":String(n)}};var Lv=class{constructor(n){this.onChange=n,this.roots=[],this._nodeMap=new Map}addFromSpec(n,r=null){let c=this._makeNode(n.id,r,n);if(c.checked=n.checked!==!1,n.children){for(let u of n.children)c.children.push(this.addFromSpec(u,c));c.hasCheckbox&&this._computeParent(c)}return r||this.roots.push(c),c}buildFromNodes(n){this._nodeMap.clear(),this.roots=[];for(let r of n)this._makeNode(r.id,null,r);for(let r of n){let c=this._nodeMap.get(r.id);if(r.parentId!=null&&this._nodeMap.has(r.parentId)){let u=this._nodeMap.get(r.parentId);c.parent=u,u.children.push(c)}else this.roots.push(c)}for(let r=n.length-1;r>=0;r--){let c=this._nodeMap.get(n[r].id);c.hasCheckbox&&c.children.length>0&&this._computeParent(c)}return this.roots}get(n){return this._nodeMap.get(n)}isVisible(n){let r=this.get(n);return r?r.checked:!1}check(n,r){let c=this._nodeMap.get(n);if(c){c.checked=r,c.indeterminate=!1;for(let u of c.children)this._setSubtree(u,r);for(let u=c.parent;u;u=u.parent)u.hasCheckbox&&this._computeParent(u);this.onChange()}}cascadeQuiet(n,r){let c=this._nodeMap.get(n);if(c){c.checked=r,c.indeterminate=!1;for(let u of c.children)this._setSubtree(u,r);for(let u=c.parent;u;u=u.parent)u.hasCheckbox&&this._computeParent(u)}}checkSet(n){for(let[r,c]of Object.entries(n)){let u=this._nodeMap.get(r);u&&(u.checked=c,u.indeterminate=!1)}this._recomputeAllParents(),this.onChange()}mirrorStates(n){this._applyMirror(n),this.onChange()}mirrorStatesQuiet(n){this._applyMirror(n)}_applyMirror(n){for(let[r,c]of Object.entries(n)){let u=this._nodeMap.get(r);u&&(u.checked=!!c.checked,u.indeterminate=!!c.indeterminate)}}forEach(n){let r=c=>{n(c);for(let u of c.children)r(u)};for(let c of this.roots)r(c)}_makeNode(n,r,c){let u={id:n,parent:r,children:[],hasCheckbox:c.hasCheckbox!==!1,checked:c.checked!==!1,indeterminate:!1,data:c.data!=null?c.data:c};return this._nodeMap.set(n,u),u}_checkboxDescendants(n){let r=[];for(let c of n.children)c.hasCheckbox?r.push(c):r.push(...this._checkboxDescendants(c));return r}_computeParent(n){let r=this._checkboxDescendants(n);if(r.length===0)return;let c=r.every(d=>d.checked&&!d.indeterminate),u=r.every(d=>!d.checked&&!d.indeterminate);n.checked=c,n.indeterminate=!c&&!u}_setSubtree(n,r){n.hasCheckbox&&(n.checked=r,n.indeterminate=!1);for(let c of n.children)this._setSubtree(c,r)}_recomputeAllParents(){let n=r=>{for(let c of r.children)n(c);r.hasCheckbox&&r.children.length>0&&this._computeParent(r)};for(let r of this.roots)n(r)}};var u3t=["Instance","Module","Instances","Macros","Modules","Area","Local Inst","Local Macros","Local Modules"],xT={MODULE:0,LEAF_GROUP:1,TYPE_GROUP:2,INSTANCE:3,NAME_GROUP:4};function dk(s){return s===xT.MODULE||s===xT.NAME_GROUP}var Khe=class{constructor(n,r,c){this._app=r,this._redrawAllLayers=c,this._nodes=[],this._nameGrouped=!1,this._nameGroupsCapped=!1,this._rows=[],this._childrenMap=new Map,this._collapsed=new Set,this._moduleState=new Map,this._checkModel=null,this._build(n),r.hierarchyBrowser=this,la(r)&&this.update()}_build(n){let r=document.createElement("div");r.className="hierarchy-widget";let c=document.createElement("div");c.className="timing-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",la(this._app)&&(this._updateBtn.style.display="none"),this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",c.appendChild(this._updateBtn),c.appendChild(this._statusLabel),r.appendChild(c),this._tableContainer=document.createElement("div"),this._tableContainer.className="hierarchy-table-container",this._table=document.createElement("table"),this._table.className="timing-table",this._tableContainer.appendChild(this._table),r.appendChild(this._tableContainer),n.element.appendChild(r),this._bindEvents()}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update())}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...",this._statusLabel.textContent="";try{let n=await this._app.websocketManager.request({type:"module_hierarchy"});this._nodes=n.nodes||[],this._nameGrouped=!!n.name_grouped,this._nameGroupsCapped=!!n.name_groups_capped,this._buildTree(),this._readServerColors(),this._computeEffectiveColors(),this._render(),this._statusLabel.textContent=this._statusText(),await this._sendModuleColors()}catch(n){this._statusLabel.textContent="Error: "+n.message}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}_statusText(){let n=this._nodes.filter(u=>dk(u.node_kind||0)).length;if(!this._nameGrouped)return n+" modules";let c=Math.max(0,n-1)+" groups from instance names \u2014 this design has no module hierarchy";return this._nameGroupsCapped&&(c+=" (truncated: too many groups)"),c}_buildTree(){this._childrenMap.clear(),this._collapsed.clear();for(let r of this._nodes)this._childrenMap.set(r.id,[]);for(let r of this._nodes)r.parent_id>=0&&this._childrenMap.has(r.parent_id)&&this._childrenMap.get(r.parent_id).push(r.id);this._nodeMap=new Map;for(let r of this._nodes)this._nodeMap.set(r.id,r);for(let r of this._nodes){let c=this._childrenMap.get(r.id);if(!c||c.length===0)continue;let u=r.node_kind||0;u===xT.LEAF_GROUP||u===xT.TYPE_GROUP?this._collapsed.add(r.id):dk(u)&&r.parent_id>=0&&this._collapsed.add(r.id)}this._rows=[];let n=this._nodes.filter(r=>r.parent_id<0);for(let r of n)this._dfs(r.id,0);this._checkModel=new Lv(()=>{this._checkModel.forEach(r=>{if(!r.hasCheckbox)return;let c=this._moduleState.get(r.data.odb_id);c&&(c.visible=r.checked)}),this._sendModuleColors()}),this._checkModel.buildFromNodes(this._nodes.map(r=>({id:r.id,parentId:r.parent_id,hasCheckbox:dk(r.node_kind||0)&&r.odb_id!=null,checked:!0,data:r})))}_readServerColors(){this._moduleState.clear();for(let n of this._rows){let r=this._nodeMap.get(n.id);if(!r||!dk(r.node_kind||0)||r.odb_id==null)continue;let c=r.color||[128,128,128];this._moduleState.set(r.odb_id,{color:c,effectiveColor:c,visible:!0,nodeId:r.id})}}_computeEffectiveColors(){for(let n of this._rows){let r=this._nodeMap.get(n.id);if(!r||!dk(r.node_kind||0))continue;let c=this._moduleState.get(r.odb_id);if(!c)continue;let u=r.parent_id,d=null;for(;u>=0;){let b=this._nodeMap.get(u);if(!b)break;if(dk(b.node_kind||0)){let w=this._moduleState.get(b.odb_id);w&&this._collapsed.has(b.id)&&(d=w.effectiveColor)}u=b.parent_id}c.effectiveColor=d||c.color}}async _sendModuleColors(){let n=[];for(let[c,u]of this._moduleState){if(!u.visible)continue;let[d,b,w]=u.effectiveColor;n.push(`${c}:${d},${b},${w},100`)}let r=n.join(";");try{let c=await this._app.websocketManager.request({type:"set_module_colors",colors:r});console.log("set_module_colors:",c.count,"modules,",n.length,"sent")}catch(c){console.error("set_module_colors failed:",c)}this._redrawAllLayers()}_dfs(n,r){this._rows.push({id:n,depth:r});let c=this._childrenMap.get(n)||[];for(let u of c)this._dfs(u,r+1)}_render(){this._table.innerHTML="";let n=document.createElement("thead"),r=document.createElement("tr");for(let u of u3t){let d=document.createElement("th");d.textContent=u,r.appendChild(d)}n.appendChild(r),this._table.appendChild(n);let c=document.createElement("tbody");for(let u of this._rows){let d=this._nodeMap.get(u.id);if(!d||this._isHidden(d))continue;let b=document.createElement("tr"),w=d.node_kind||0,x=(this._childrenMap.get(u.id)||[]).length>0,T=this._collapsed.has(u.id);w===xT.LEAF_GROUP||w===xT.TYPE_GROUP?(b.style.fontStyle="italic",b.style.color="var(--fg-disabled)"):w===xT.INSTANCE?b.style.color="var(--fg-secondary)":w===xT.NAME_GROUP&&(b.classList.add("hierarchy-name-group"),b.title="Recovered from instance names \u2014 this design has no module hierarchy");let M=document.createElement("td");if(M.style.paddingLeft=8+u.depth*16+"px",M.style.whiteSpace="nowrap",dk(w)&&d.odb_id!=null){let D=this._moduleState.get(d.odb_id),F=this._checkModel?this._checkModel.get(d.id):null;if(D&&F){let O=document.createElement("input");O.type="checkbox",O.checked=F.checked,O.indeterminate=F.indeterminate,O.className="hierarchy-module-cb",F.cb=O,O.addEventListener("change",se=>{se.stopPropagation(),this._checkModel.check(d.id,O.checked),this._render()}),M.appendChild(O);let z=document.createElement("span");z.className="hierarchy-color-swatch";let[Z,H,te]=D.effectiveColor;z.style.backgroundColor=`rgb(${Z},${H},${te})`,M.appendChild(z)}}if(x){let D=document.createElement("span");D.className="hierarchy-arrow",D.textContent=T?"\u25B6":"\u25BC",D.addEventListener("click",F=>{F.stopPropagation(),this._toggleNode(u.id)}),M.appendChild(D)}else{let D=document.createElement("span");D.className="hierarchy-arrow",D.style.visibility="hidden",D.textContent="\u25B6",M.appendChild(D)}let L=document.createElement("span");L.textContent=d.inst_name,M.appendChild(L),b.appendChild(M);let I=[d.module_name,TO(d.insts),TO(d.macros),TO(d.modules),this._fmtArea(d.area),TO(d.local_insts),TO(d.local_macros),TO(d.local_modules)];for(let D of I){let F=document.createElement("td");F.textContent=D,F.style.textAlign="right",b.appendChild(F)}b.children[1].style.textAlign="left",c.appendChild(b)}if(this._rows.length===0){let u=document.createElement("tr"),d=document.createElement("td");d.colSpan=u3t.length,d.style.textAlign="center",d.style.color="var(--fg-secondary)",d.textContent=la(this._app)?"No hierarchy data available":'Click "Update" to load hierarchy',u.appendChild(d),c.appendChild(u)}this._table.appendChild(c),ak(this._table)}_isHidden(n){let r=n.parent_id;for(;r>=0;){if(this._collapsed.has(r))return!0;let c=this._nodeMap.get(r);if(!c)break;r=c.parent_id}return!1}_toggleNode(n){this._collapsed.has(n)?this._collapsed.delete(n):this._collapsed.add(n),this._computeEffectiveColors(),this._render(),this._sendModuleColors()}_fmtArea(n){if(n==null)return"";if(this._app.showDbu){let r=this._app.getDbuPerMicron();return String(Math.round(n*r*r))}return n>=1e6?(n/1e6).toFixed(3)+" mm\xB2":n.toFixed(3)+" \u03BCm\xB2"}};function TO(s){return s!=null?String(s):""}var Edn='',Sdn='',Mdn='',Tdn='',Cdn='',Adn='',Pdn='',Ldn='',kdn='',Rdn='',Idn='',Ddn='';function f3t(s,n,r){r=r||n;let c=null,u=null,d=null,b=!1,w=10;function _(Ge,Pe){return b?Promise.resolve():(b=!0,s.websocketManager.request({type:"set_property",name:Ge,use_dbu:s.showDbu,...Pe}).then(ke=>{!ke.ok&&ke.error&&Nb(ke.error),yi(ke),ke.ok&&ke.bbox&&Ei(ke.bbox)}).catch(ke=>{console.error("set_property failed:",ke),Nb("Edit failed: "+ke),c&&yi(c)}).finally(()=>{b=!1}))}function x(Ge,Pe){let ke=document.createElement("select");ke.className="inspector-editor-select";let dt=Ge.editor.type==="bool"?["True","False"]:Ge.editor.options||[];for(let Ye of dt){let ct=document.createElement("option");ct.value=Ye,ct.textContent=Ye,Ye===Ge.value&&(ct.selected=!0),ke.appendChild(ct)}if(!dt.includes(Ge.value)){let Ye=document.createElement("option");Ye.value=Ge.value||"",Ye.textContent=Ge.value||"",Ye.selected=!0,Ye.disabled=!0,ke.insertBefore(Ye,ke.firstChild)}return ke.addEventListener("change",()=>{if(Pe.onPropertyChange){Pe.onPropertyChange(Ge.name,ke.value);return}if(Ge.editor.type==="bool")Pe.onPropertyEdit(Ge,{value:ke.value==="True"});else{let Ye=(Ge.editor.options||[]).indexOf(ke.value);Pe.onPropertyEdit(Ge,{option_index:Ye,option_name:ke.value})}}),ke}async function T(Ge,Pe){if(!b&&!(Ge==="Delete"&&!await Dxt({title:"Delete "+(Pe.type||"object"),message:"Delete "+(Pe.type||"object")+' "'+(Pe.name||"")+'"? This cannot be undone.',confirmLabel:"Delete",danger:!0}))){b=!0;try{let ke=await s.websocketManager.request({type:"trigger_action",name:Ge,use_dbu:s.showDbu});!ke.ok&&ke.error&&Nb(ke.error),yi(ke.properties?ke:null),ke.deleted&&Un(),ot(),r()}catch(ke){console.error("trigger_action failed:",ke),Nb("Action failed: "+ke)}finally{b=!1}}}function M(Ge){s.websocketManager.request({...Ge,use_dbu:s.showDbu}).then(Pe=>{!Pe.ok&&Pe.error&&Nb(Pe.error),yi(Pe),r()}).catch(Pe=>{console.error(Ge.type+" failed:",Pe)})}function L(){let Ge=document.getElementById("highlight-picker");Ge&&Ge.remove()}function I(Ge,Pe){L();let ke=s.techData?.highlight_colors||[];if(!ke.length)return;let dt=document.createElement("div");dt.id="highlight-picker";let Ye=document.createElement("div");if(Ye.className="highlight-swatch-grid",ke.forEach((Ke,gt)=>{let qn=document.createElement("button");qn.className="highlight-swatch",qn.title="Group "+(gt+1),qn.style.backgroundColor=`rgb(${Ke[0]}, ${Ke[1]}, ${Ke[2]})`,gt===Pe.highlight_group&&qn.classList.add("active"),qn.addEventListener("click",()=>{L(),M({type:"highlight",group:gt})}),Ye.appendChild(qn)}),dt.appendChild(Ye),Pe.highlight_group>=0){let Ke=document.createElement("button");Ke.className="highlight-remove",Ke.textContent="Remove highlight",Ke.addEventListener("click",()=>{L(),M({type:"unhighlight"})}),dt.appendChild(Ke)}document.body.appendChild(dt);let ct=Ge.getBoundingClientRect();dt.style.left=ct.left+"px",dt.style.top=ct.bottom+4+"px";let Ze=Ke=>{Ke.type==="keydown"&&Ke.key!=="Escape"||Ke.type==="mousedown"&&dt.contains(Ke.target)||(L(),document.removeEventListener("mousedown",Ze,!0),document.removeEventListener("keydown",Ze,!0))};setTimeout(()=>{document.addEventListener("mousedown",Ze,!0),document.addEventListener("keydown",Ze,!0)},0)}function D(){if(!s.inspectorEl)return;s.inspectorEl.innerHTML="";let Ge=document.createElement("div");Ge.className="stub-panel",Ge.innerHTML='
Loading\u2026
Fetching properties from server.
',s.inspectorEl.appendChild(Ge)}async function F(Ge){let Pe=s.focusNets.has(Ge)?"remove":"add";Pe==="add"?s.focusNets.add(Ge):s.focusNets.delete(Ge);try{await s.websocketManager.request({type:"set_focus_nets",action:Pe,net_name:Ge})}catch(ke){console.error("set_focus_nets failed:",ke)}n(),c&&yi(c)}async function O(){s.focusNets.clear();try{await s.websocketManager.request({type:"set_focus_nets",action:"clear",net_name:""})}catch(Ge){console.error("set_focus_nets clear failed:",Ge)}n(),c&&yi(c)}async function z(Ge){let Pe=s.routeGuideNets.has(Ge)?"remove":"add";Pe==="add"?s.routeGuideNets.add(Ge):s.routeGuideNets.delete(Ge);try{await s.websocketManager.request({type:"set_route_guides",action:Pe,net_name:Ge})}catch(ke){console.error("set_route_guides failed:",ke)}r(),c&&yi(c)}function Z(Ge,Pe,ke,dt){return X1(Ge,Pe,ke,dt,s.designScale,s.designOriginX,s.designOriginY)}function H(Ge,Pe,ke){return Ge+(Pe-Ge)*ke}function te(Ge,Pe,ke){return Ge.map((dt,Ye)=>Math.round(H(dt,Pe[Ye],ke)))}function se(Ge,Pe){let ke=0;for(;keGe[ke+1].at;)ke++;let dt=Ge[ke],Ye=Ge[ke+1],ct=Math.max(0,Math.min(1,(Pe-dt.at)/(Ye.at-dt.at))),Ze={};for(let Ke of Object.keys(dt))Ke!=="at"&&(Ze[Ke]=Array.isArray(dt[Ke])?te(dt[Ke],Ye[Ke],ct):H(dt[Ke],Ye[Ke],ct));return Ze}function ne(Ge,Pe,ke,dt){if(nH()||typeof requestAnimationFrame!="function")return dt(),()=>{};let Ye=performance.now(),ct=!1,Ze=()=>{if(ct)return;let Ke=performance.now()-Ye;if(Ke>=Ge*Pe){dt();return}ke(Ke%Ge/Ge),requestAnimationFrame(Ze)};return Ze(),()=>{ct=!0}}function ue(Ge,Pe,ke=mp.highlight){s.view&&s.view.setOverlay(Ge,Pe,{order:ke})}let Ce=null,Q=()=>{},me=[255,242,122],tt=[{at:0,stroke:[255,246,176],width:7,alpha:1,fill:.28},{at:.55,stroke:[255,255,255],width:5,alpha:1,fill:.06},{at:1,stroke:[255,232,92],width:3,alpha:.95,fill:.14}],st={stroke:[255,232,92],width:3,alpha:1,fill:.14};function at(Ge,Pe,ke,dt){let[Ye,ct,Ze,Ke]=Z(Ge,Pe,ke,dt),gt=w/2**s.view.getZoom(),qn=Math.max(0,(gt-(Ze-Ye))/2),xi=Math.max(0,(gt-(Ke-ct))/2);return[Ye-qn,ct-xi,Ze+qn,Ke+xi]}function Ne(Ge){Ce&&ue("hover",Ce.map(([Pe,ke,dt,Ye])=>({kind:"rect",rect:at(Pe,ke,dt,Ye),stroke:Z1(Ge.stroke,Ge.alpha),width:Ge.width,fill:Z1(me,Ge.fill)})))}function Qe(){Ne(st)}function ot(){Q(),Ce=null,ue("hover",null),s.view?.off("zoom",Qe)}function xt(){ot(),s.websocketManager.request({type:"hover",select_id:-1}).then(()=>{}).catch(()=>{})}function fn(Ge){ot(),!(!s.view||!s.designScale||!Ge||Ge.length===0)&&(Ce=Ge,s.view.on("zoom",Qe),Q=ne(900,3,Pe=>Ne(se(tt,1-Math.pow(1-Pe,2))),()=>Ne(st)))}function Xt(Ge,Pe){Ge.classList.add("inspector-link"),Ge.addEventListener("click",ke=>{ke.stopPropagation(),cn(Pe)}),Ge.addEventListener("mouseenter",()=>{d!==null&&(s.websocketManager.cancel(d),d=null);let ke=s.websocketManager.request({type:"hover",select_id:Pe});d=ke.requestId,ke.then(dt=>{d=null,fn(dt.rects||[]),r()}).catch(()=>{d=null})}),Ge.addEventListener("mouseleave",()=>{xt(),r()})}function wn(Ge){let Pe=Ge>0?"select_next":"select_prev";u!==null&&(s.websocketManager.cancel(u),u=null),D();let ke=Pm(s),dt=s.websocketManager.request({type:Pe,use_dbu:s.showDbu});u=dt.requestId,dt.then(Ye=>{if(u=null,!!Y1(s,ke)){if(Ye.error){console.error("Selection cycle error:",Ye.error),yi(c);return}if(yi(Ye),Ye.type==="Inst"&&Ye.name&&(s.selectedInstanceName=Ye.name,s.schematicWidget&&s.schematicWidget.refresh()),ot(),Un(),Ye.bbox&&s.view&&s.designScale){let[ct,Ze,Ke,gt]=Ye.bbox;Ye.type!=="Inst"&&Zi(ct,Ze,Ke,gt,Ye.type),Ye.selection_count>1?it(Ye.bbox):Ei(Ye.bbox,Ye.type)}n()}}).catch(Ye=>{u=null,console.error("Selection cycle failed:",Ye),yi(c)})}function cn(Ge){u!==null&&(s.websocketManager.cancel(u),u=null),D();let Pe=Pm(s),ke=s.websocketManager.request({type:"inspect",select_id:Ge,use_dbu:s.showDbu});u=ke.requestId,ke.then(dt=>{if(u=null,!!Y1(s,Pe)){if(dt.error){console.error("Inspect error:",dt.error);return}if(yi(dt),ot(),Un(),dt.bbox&&s.view&&s.designScale){let[Ye,ct,Ze,Ke]=dt.bbox;dt.type!=="Inst"&&Zi(Ye,ct,Ze,Ke,dt.type),Ei(dt.bbox,dt.type)}r()}}).catch(dt=>{u=null,console.error("Inspect failed:",dt)})}function bi(){u!==null&&(s.websocketManager.cancel(u),u=null),D();let Ge=Pm(s),Pe=s.websocketManager.request({type:"inspect_back",use_dbu:s.showDbu});u=Pe.requestId,Pe.then(ke=>{if(u=null,!!Y1(s,Ge)){if(ke.error){console.error("Inspect back error:",ke.error);return}if(yi(ke),ot(),Un(),ke.bbox&&s.view&&s.designScale){if(ke.type!=="Inst"){let[dt,Ye,ct,Ze]=ke.bbox;Zi(dt,Ye,ct,Ze,ke.type)}Ei(ke.bbox,ke.type)}r()}}).catch(ke=>{u=null,console.error("Inspect back failed:",ke)})}let jt=null;function gn(){let Ge=jt&&s.designScale&&!(s.visibility&&s.visibility.highlight_selected===!1);ue("selection",Ge?[{kind:"rect",rect:Z(...jt),stroke:Z1("#ff0"),width:2,dash:[6,4]}]:null,mp.selection)}function Un(){jt=null,gn()}function Zi(Ge,Pe,ke,dt,Ye){jt=Ye==="Net"?null:[Ge,Pe,ke,dt],gn()}let Hi=null,yr=[{at:0,alpha:0,fill:0},{at:.5,alpha:1,fill:.28},{at:1,alpha:0,fill:0}];function Tr(){Hi&&(Hi(),Hi=null),ue("pulse",null)}function Ei(Ge,Pe){if(!Ge||!s.view||!s.designScale||(xr!==null&&de(),Tr(),s.visibility&&s.visibility.highlight_selected===!1)||Pe==="Net")return;let ke=Z(...Ge);Hi=ne(350,3,dt=>{let Ye=se(yr,.5-.5*Math.cos(Math.PI*dt));ue("pulse",[{kind:"rect",rect:ke,stroke:Z1("#ff0",Ye.alpha),width:3,fill:Z1("#ff0",Ye.fill)}])},()=>{Hi=null,ue("pulse",null)})}let xr=null;function oe(Ge,Pe){ue("anim",[{kind:"rect",rect:Ge,stroke:Z1("#ff0"),width:Pe,fill:Z1("#ff0",Pe===1?.39:0)}])}function de(){xr!==null&&(clearInterval(xr),xr=null),ue("anim",null)}function it(Ge,{repeats:Pe=6,intervalMs:ke=300}={}){if(!Ge||!s.view||!s.designScale)return;if(de(),nH()){Ei(Ge);return}let dt=Z(...Ge);oe(dt,1);let Ye=0,ct=Pe>0?Pe*3:1/0;xr=setInterval(()=>{if(Ye+=1,Ye>=ct){de();return}oe(dt,Ye%3+1)},ke)}s.clearSelectionPulse=Tr,s.renderSelectionOutline=gn,s.clearSelectionOutline=Un;function We(Ge,Pe,ke){let dt=document.createElement("div");dt.className="inspector-group";let Ye=document.createElement("div");Ye.className="inspector-group-header";let ct=document.createElement("span");ct.className="vis-arrow";let Ze=document.createElement("span");if(Ze.className="inspector-prop-name",Ze.textContent=Ge,Ze.title=Ge,Ye.appendChild(ct),Ye.appendChild(Ze),Pe!==null){let gt=document.createElement("span");gt.className="inspector-count",gt.textContent=`(${Pe})`,Ye.appendChild(gt)}dt.appendChild(Ye);let Ke=document.createElement("div");return Ke.className="inspector-group-children"+(ke?" collapsed":""),ct.textContent=ke?"\u25B6":"\u25BC",dt.appendChild(Ke),Ye.addEventListener("click",()=>{Ke.classList.toggle("collapsed"),ct.textContent=Ke.classList.contains("collapsed")?"\u25B6":"\u25BC"}),{group:dt,header:Ye,arrow:ct,body:Ke}}function _n(Ge){let Pe=Ge.column_headers||[],ke=Ge.row_headers||[],dt=Ge.data||[],Ye=Pe.some(gt=>gt!==""),ct=ke.some(gt=>gt!==""),Ze=document.createElement("table");if(Ze.className="inspector-table",Ye){let gt=document.createElement("thead"),qn=document.createElement("tr");ct&&qn.appendChild(document.createElement("th"));for(let xi of Pe){let Bi=document.createElement("th");Bi.textContent=xi,qn.appendChild(Bi)}gt.appendChild(qn),Ze.appendChild(gt)}let Ke=document.createElement("tbody");return dt.forEach((gt,qn)=>{let xi=document.createElement("tr");if(ct){let Bi=document.createElement("th");Bi.textContent=ke[qn]||"",xi.appendChild(Bi)}for(let Bi of gt){let xn=document.createElement("td");xn.textContent=Bi,xi.appendChild(xn)}Ke.appendChild(xi)}),Ze.appendChild(Ke),Ze}function Er(Ge,Pe){if(Ge.table){let Ze=(Ge.table.data||[]).length,{group:Ke,body:gt}=We(Ge.name,Ze,Ze>=10),qn=document.createElement("div");return qn.className="inspector-table-scroll",qn.appendChild(_n(Ge.table)),gt.appendChild(qn),Ke}if(Ge.children){let Ze=Ge.children.length<10,{group:Ke,body:gt}=We(Ge.name,Ge.children.length,!Ze);for(let qn of Ge.children)gt.appendChild(Er(qn,Pe));return Ke}let ke=document.createElement("div");ke.className="inspector-prop";let dt=document.createElement("span");dt.className="inspector-prop-name",dt.textContent=Ge.name||"",dt.title=Ge.name||"";let Ye=document.createElement("span");Ye.className="inspector-prop-value",Ye.textContent=Ge.value||"",ke.appendChild(dt),ke.appendChild(Ye);let ct=Ge.editable&&Pe&&(Pe.onPropertyEdit||Pe.onPropertyChange)&&Ge.editor&&(Ge.editor.type==="list"||Ge.editor.type==="bool");if(ct&&Ge.value_select_id===void 0)ke.replaceChild(x(Ge,Pe),Ye);else if(ct){let Ze=document.createElement("button");Ze.className="inspector-edit-btn",Ze.title="Edit "+Ge.name,Ze.textContent="\u270E",Ze.addEventListener("click",Ke=>{Ke.stopPropagation();let gt=x(Ge,Pe);ke.replaceChild(gt,Ye),Ze.remove(),gt.focus()}),ke.appendChild(Ze)}else Ge.editable&&Pe&&(Pe.onPropertyChange||Pe.onPropertyEdit)&&(Ye.contentEditable=!0,Ye.classList.add("inspector-editable"),Ye.addEventListener("blur",()=>{let Ze=Ye.textContent;if(Ze!==Ge.value){if(Pe.onPropertyChange){Pe.onPropertyChange(Ge.name,Ze);return}if(Ge.editor&&Ge.editor.type==="number"){let Ke=Number(Ze);if(Ze.trim()===""||Number.isNaN(Ke)){Nb("Not a number: "+Ze),Ye.textContent=Ge.value;return}Pe.onPropertyEdit(Ge,{value:Ke});return}Pe.onPropertyEdit(Ge,{value:Ze})}}),Ye.addEventListener("keydown",Ze=>{Ze.key==="Enter"&&(Ze.preventDefault(),Ye.blur()),Ze.key==="Escape"&&(Ye.textContent=Ge.value,Ye.blur())}));return Ge.name_select_id!==void 0&&Ge.value_select_id===void 0?(Xt(ke,Ge.name_select_id),dt.classList.add("inspector-link")):Ge.name_select_id!==void 0&&Xt(dt,Ge.name_select_id),Ge.value_select_id!==void 0&&Xt(Ye,Ge.value_select_id),ke}let qi=140,Te=60,ve=500,_t=qi;function mn(){s.inspectorEl&&s.inspectorEl.style.setProperty("--inspector-name-w",_t+"px")}function yn(){let Ge=document.createElement("div");return Ge.className="inspector-col-resizer",Ge.title="Drag to resize the name column",Ge.addEventListener("mousedown",Pe=>{Pe.preventDefault();let ke=Pe.clientX,dt=_t;Ge.classList.add("dragging");let Ye=Ze=>{_t=Math.max(Te,Math.min(ve,dt+Ze.clientX-ke)),mn()},ct=()=>{Ge.classList.remove("dragging"),document.removeEventListener("mousemove",Ye),document.removeEventListener("mouseup",ct)};document.addEventListener("mousemove",Ye),document.addEventListener("mouseup",ct)}),Ge}function Sn(Ge){!Ge||!s.view||!s.designScale||s.view.fitWorldRect(Z(...Ge),{padding:[20,20]})}function yi(Ge){if(!s.inspectorEl)return;if(c=Ge,s.inspectorEl.innerHTML="",!Ge||!Ge.properties||Ge.properties.length===0){de();let Ye=document.createElement("div");Ye.className="stub-panel",Ye.innerHTML='
Inspector
Select an object in the layout to inspect its properties.
',s.inspectorEl.appendChild(Ye);return}if(!Ge.onPropertyChange&&!Ge.onPropertyEdit&&!la(s)&&(Ge.onPropertyEdit=(Ye,ct)=>_(Ye.name,ct)),Ge){let Ye=document.createElement("div");Ye.className="inspector-toolbar";let ct=document.createElement("button");if(ct.className="or-btn or-btn-icon",ct.title="Back",ct.innerHTML=Tdn,ct.disabled=!Ge.can_navigate_back,ct.addEventListener("click",()=>bi()),Ye.appendChild(ct),Ge.bbox){let Ze=document.createElement("button");Ze.className="or-btn or-btn-icon",Ze.title="Zoom to",Ze.innerHTML=Mdn,Ze.addEventListener("click",()=>Sn(Ge.bbox)),Ye.appendChild(Ze)}if(Ge.type==="Net"&&Ge.name){let Ze=s.focusNets.has(Ge.name),Ke=document.createElement("button");Ke.className="or-btn or-btn-icon",Ke.title=Ze?"De-focus net":"Focus net",Ke.innerHTML=Ze?Adn:Cdn,Ke.addEventListener("click",()=>F(Ge.name)),Ye.appendChild(Ke)}if(Ge.type==="Net"&&Ge.name&&Ge.has_guides){let Ze=s.routeGuideNets.has(Ge.name),Ke=document.createElement("button");Ke.className="or-btn or-btn-icon",Ke.title=Ze?"Hide route guides":"Show route guides",Ke.innerHTML=Ze?Ldn:Pdn,Ke.addEventListener("click",()=>z(Ge.name)),Ye.appendChild(Ke)}if(Ge.type==="Net"&&Ge.name&&s.showInsertBufferDialog){let Ze=document.createElement("button");Ze.className="or-btn or-btn-icon",Ze.title="Insert buffer",Ze.innerHTML=Ddn,Ze.addEventListener("click",()=>s.showInsertBufferDialog(Ge.name)),Ye.appendChild(Ze)}if(s.focusNets.size>0){let Ze=document.createElement("button");Ze.className="or-btn or-btn-icon",Ze.title="Clear focus nets",Ze.innerHTML=kdn,Ze.addEventListener("click",()=>O()),Ye.appendChild(Ze)}if(typeof Ge.highlight_group=="number"&&!la(s)&&(s.techData?.highlight_colors||[]).length){let Ze=document.createElement("button");Ze.className="or-btn or-btn-icon inspector-highlight-btn";let Ke=Ge.highlight_group;if(Ze.title=Ke>=0?"Highlight group "+(Ke+1):"Add to highlight group",Ze.innerHTML=Sdn,Ke>=0){let gt=s.techData.highlight_colors[Ke];Ze.style.backgroundColor=`rgba(${gt[0]}, ${gt[1]}, ${gt[2]}, 0.45)`,Ze.style.borderColor=`rgb(${gt[0]}, ${gt[1]}, ${gt[2]})`}Ze.addEventListener("click",()=>I(Ze,Ge)),Ye.appendChild(Ze)}if(Array.isArray(Ge.actions)&&!la(s))for(let Ze of Ge.actions){let Ke=document.createElement("button");Ke.className="or-btn inspector-action-btn",Ke.title=Ze,Ze==="Delete"?(Ke.classList.add("or-btn-icon","or-btn-danger-hover"),Ke.innerHTML=Edn):(Ke.classList.add("or-btn-sm"),Ke.textContent=Ze),Ke.addEventListener("click",()=>T(Ze,Ge)),Ye.appendChild(Ke)}s.inspectorEl.appendChild(Ye)}let Pe=Ge.selection_count||0,ke=typeof Ge.selection_index=="number"?Ge.selection_index:-1;if(Pe>1&&ke>=0){let Ye=document.createElement("div");Ye.className="inspector-selection-nav";let ct=document.createElement("button");ct.className="or-btn or-btn-icon",ct.title="Previous (Shift+click to multi-select)",ct.innerHTML=Rdn,ct.addEventListener("click",()=>wn(-1));let Ze=document.createElement("span");Ze.className="inspector-selection-label",Ze.textContent=ke+1+" / "+Pe;let Ke=document.createElement("button");Ke.className="or-btn or-btn-icon",Ke.title="Next",Ke.innerHTML=Idn,Ke.addEventListener("click",()=>wn(1)),Ye.appendChild(ct),Ye.appendChild(Ze),Ye.appendChild(Ke),s.inspectorEl.appendChild(Ye)}let dt=document.createElement("div");dt.className="inspector-rows";for(let Ye of Ge.properties)dt.appendChild(Er(Ye,Ge));dt.appendChild(yn()),s.inspectorEl.appendChild(dt),mn()}function hi(Ge){let Pe=document.createElement("div");Pe.className="inspector",s.inspectorEl=Pe,Ge.element.appendChild(Pe),yi(null)}function ri(){if(c){if(c.type==="Ruler"){s.rulerManager&&s.rulerManager._selectedRulerId!==null&&s.rulerManager._selectRuler(s.rulerManager._selectedRulerId);return}s.websocketManager&&cn(-1)}}return{createInspector:hi,updateInspector:yi,highlightBBox:Zi,pulseHighlight:Ei,animateSelection:it,stopSelectionAnimation:de,navigateInspector:cn,refreshInspector:ri}}var Jhe=class{constructor(n,r,c){this._app=r,this._refreshOverlay=c||(()=>{}),this._data={selection:[],groups:[],truncated:!1},this._tab="selected",this._filter="",this._sortKey=null,this._sortAsc=!0,this._pendingRefresh=null,this._inFlight=!1,this._staleWhileInFlight=!1,this._visible=!0,this._el=document.createElement("div"),this._el.className="selection-browser",n.element.appendChild(this._el),n.on?.("show",()=>{this._visible=!0,this.refresh()}),n.on?.("hide",()=>{this._visible=!1}),n.on?.("destroy",()=>{this._visible=!1,this._staleWhileInFlight=!1,this._pendingRefresh!==null&&(clearTimeout(this._pendingRefresh),this._pendingRefresh=null)}),this._render(),this.refresh()}scheduleRefresh(){!this._visible||this._pendingRefresh!==null||(this._pendingRefresh=setTimeout(()=>{this._pendingRefresh=null,this.refresh()},150))}refresh(){if(!this._visible||la(this._app))return;if(this._inFlight){this._staleWhileInFlight=!0;return}this._inFlight=!0;let n=()=>{this._inFlight=!1,this._staleWhileInFlight&&(this._staleWhileInFlight=!1,this.refresh())};this._app.websocketManager.request({type:"list_selection"}).then(r=>{r.ok&&(this._data=r,this._render()),n()}).catch(n)}_entries(){let n;this._tab==="selected"?n=(this._data.selection||[]).map((c,u)=>({row:c,index:u,group:-1})):n=(this._data.groups||[]).flatMap((c,u)=>c.map((d,b)=>({row:d,index:b,group:u})));let r=this._filter.trim().toLowerCase();if(r&&(n=n.filter(({row:c})=>(c.name||"").toLowerCase().includes(r)||(c.type||"").toLowerCase().includes(r))),this._sortKey){let c=this._sortKey,u=this._sortAsc?1:-1;n=n.slice().sort((d,b)=>u*String(d.row[c]||"").localeCompare(String(b.row[c]||"")))}return n}_fmtCoord(n){if(this._app.showDbu)return String(n);let r=this._app.getDbuPerMicron?this._app.getDbuPerMicron():1e3;return(n/r).toFixed(3)}_fmtBounds(n){if(!n)return"";let[r,c,u,d]=n;return`(${this._fmtCoord(r)}, ${this._fmtCoord(c)}), (${this._fmtCoord(u)}, ${this._fmtCoord(d)})`}_inspectRow(n,r){let c=n.group<0?{type:"inspect_selection",index:n.index,use_dbu:this._app.showDbu}:{type:"inspect_group",group:n.group,index:n.index,use_dbu:this._app.showDbu};this._app.websocketManager.request(c).then(u=>{if(!u.ok){this.refresh();return}this._app.updateInspector&&this._app.updateInspector(u),r&&this._app.focusComponent&&this._app.focusComponent("Inspector"),this._refreshOverlay()}).catch(()=>{})}_deselectRow(n){this._app.websocketManager.request({type:"deselect",index:n.index}).then(()=>{this.refresh(),this._refreshOverlay()}).catch(()=>{})}_clearHighlights(){this._app.websocketManager.request({type:"clear_highlights",group:-1}).then(()=>{this.refresh(),this._refreshOverlay(),this._app.refreshInspector&&this._app.refreshInspector()}).catch(()=>{})}_zoomToBBox(n){if(!n||!this._app.designScale||!this._app.view)return;let[r,c,u,d]=n,b=this._app.getDbuPerMicron?this._app.getDbuPerMicron():1e3,w=Math.min(10*b,2*Math.max(u-r,d-c));this._app.view.fitWorldRect(X1(r-w,c-w,u+w,d+w,this._app.designScale,this._app.designOriginX,this._app.designOriginY))}_render(){this._app.stopSelectionAnimation&&this._app.stopSelectionAnimation(),this._el.innerHTML="";let n=(this._data.selection||[]).length,r=(this._data.groups||[]).reduce((b,w)=>b+w.length,0),c=document.createElement("div");c.className="sb-tabs";for(let[b,w,_]of[["selected","Selected",n],["highlighted","Highlighted",r]]){let x=document.createElement("button");x.className="sb-tab"+(this._tab===b?" active":""),x.textContent=`${w} (${_})`,x.addEventListener("click",()=>{this._tab=b,this._render()}),c.appendChild(x)}let u=document.createElement("button");if(u.className="or-btn or-btn-sm sb-tool",u.title="Refresh",u.textContent="\u27F3",u.addEventListener("click",()=>this.refresh()),c.appendChild(u),this._tab==="highlighted"&&r>0){let b=document.createElement("button");b.className="or-btn or-btn-sm sb-tool",b.title="Clear all highlights",b.textContent="Clear",b.addEventListener("click",()=>this._clearHighlights()),c.appendChild(b)}this._el.appendChild(c);let d=document.createElement("input");if(d.type="text",d.className="sb-filter",d.placeholder="Filter by name or type\u2026",d.value=this._filter,d.addEventListener("input",()=>{this._filter=d.value,this._renderTable()}),this._el.appendChild(d),this._data.truncated){let b=document.createElement("div");b.className="sb-truncated",b.textContent="List truncated \u2014 showing the first 1000 entries per set.",this._el.appendChild(b)}this._tableWrap=document.createElement("div"),this._tableWrap.className="sb-table-wrap",this._el.appendChild(this._tableWrap),this._renderTable()}_renderTable(){this._tableWrap.innerHTML="";let n=this._entries();if(!n.length){let _=document.createElement("div");_.className="sb-empty",_.textContent=this._tab==="selected"?"Nothing selected.":"Nothing highlighted.",this._tableWrap.appendChild(_);return}let r=document.createElement("table");r.className="sb-table";let c=document.createElement("thead"),u=document.createElement("tr"),d=[["name","Object"],["type","Type"],[null,"Bounds"]];this._tab==="highlighted"&&d.push([null,"Group"]),d.push([null,""]);for(let[_,x]of d){let T=document.createElement("th");T.textContent=x,_&&(T.classList.add("sb-sortable"),this._sortKey===_&&(T.textContent+=this._sortAsc?" \u25B2":" \u25BC"),T.addEventListener("click",()=>{this._sortKey===_?this._sortAsc=!this._sortAsc:(this._sortKey=_,this._sortAsc=!0),this._renderTable()})),u.appendChild(T)}c.appendChild(u),r.appendChild(c);let b=document.createElement("tbody"),w=this._app.techData?.highlight_colors||[];for(let _ of n){let x=document.createElement("tr");x.className="sb-row";let T=document.createElement("td");T.textContent=_.row.name||"";let M=document.createElement("td");M.textContent=_.row.type||"";let L=document.createElement("td");if(L.textContent=this._fmtBounds(_.row.bbox),x.appendChild(T),x.appendChild(M),x.appendChild(L),this._tab==="highlighted"){let D=document.createElement("td"),F=document.createElement("span");F.className="sb-chip";let O=w[_.group];O&&(F.style.backgroundColor=`rgb(${O[0]}, ${O[1]}, ${O[2]})`),D.appendChild(F),D.appendChild(document.createTextNode(` Group ${_.group+1}`)),x.appendChild(D)}let I=document.createElement("td");if(I.className="sb-actions",_.row.bbox){let D=document.createElement("button");D.className="sb-row-btn",D.title="Zoom to",D.textContent="\u2316",D.addEventListener("click",F=>{F.stopPropagation(),this._zoomToBBox(_.row.bbox)}),I.appendChild(D)}if(this._tab==="selected"){let D=document.createElement("button");D.className="sb-row-btn",D.title="De-select",D.textContent="\u2715",D.addEventListener("click",F=>{F.stopPropagation(),this._deselectRow(_)}),I.appendChild(D)}x.appendChild(I),x.addEventListener("click",()=>this._inspectRow(_,!1)),x.addEventListener("dblclick",()=>this._inspectRow(_,!0)),_.row.bbox&&(x.addEventListener("mouseenter",()=>{this._app.animateSelection&&this._app.animateSelection(_.row.bbox,{repeats:0})}),x.addEventListener("mouseleave",()=>{this._app.stopSelectionAnimation&&this._app.stopSelectionAnimation()})),b.appendChild(x)}r.appendChild(b),this._tableWrap.appendChild(r),ak(r)}};var d3t="options-dialog",h3t=[{label:"System default",value:""},{label:"Sans-serif",value:"sans-serif"},{label:"Serif",value:"serif"},{label:"Monospace",value:"monospace"},{label:"Helvetica / Arial",value:"Helvetica, Arial, sans-serif"},{label:"Georgia",value:"Georgia, 'Times New Roman', serif"},{label:"Courier",value:"'Courier New', Courier, monospace"}],Bdn=100,Qhe=70,ede=200;function rH(s){let n=s===""||s===null?NaN:Math.round(Number(s));return Number.isFinite(n)?Math.min(ede,Math.max(Qhe,n)):Bdn}function p3t(s){let{overlay:n,close:r,okBtn:c,showError:u}=MO("Arrow keys scroll step",` +Slack: [${r.lower.toFixed(I)}, ${r.upper.toFixed(I)}) ${L}`}this._tooltip.style.display="block";let d=this.element.getBoundingClientRect(),b=this._tooltip.getBoundingClientRect(),w=4,_=n.clientX-d.left,x=n.clientY-d.top,T=_+12;T+b.width>d.width-w&&(T=_-12-b.width),T=Math.max(w,T);let M=x-10;M=Math.min(d.height-b.height-w,Math.max(w,M)),this._tooltip.style.left=T+"px",this._tooltip.style.top=M+"px"}else this._tooltip.style.display="none"}async _handleClick(n){if(this._activeDebugChart>=0||this._currentTab==="fanout"||this._currentTab==="netlength")return;let r=this._hitTestBar(n);if(!(!r||r.count===0))try{let c=await this._app.websocketManager.request({type:"timing_report",is_setup:this._currentTab==="setup",max_paths:50,slack_min:r.lower,slack_max:r.upper});this._app.timingWidget&&(this._app.timingWidget.showPaths(this._currentTab,c.paths||[]),this._app.focusComponent&&this._app.focusComponent("TimingWidget"))}catch(c){console.error("Charts bar click error:",c)}}async _handleDblClick(n){if(this._activeDebugChart>=0)return;let r;if(this._currentTab==="fanout")r="select_fanout_bin";else if(this._currentTab==="netlength")r="select_net_length_bin";else return;let c=this._hitTestBar(n);if(!c||c.count===0)return;let u=Pm(this._app);try{let d=await this._app.websocketManager.request({type:r,lower:c.lower,upper:c.upper,use_dbu:this._app.showDbu});if(!Z1(this._app,u))return;d&&d.truncated&&console.warn(`Bin has ${d.count} nets; selection capped at ${d.selection_limit} for performance.`),this._app.updateInspector&&this._app.updateInspector(d),this._app.focusComponent&&this._app.focusComponent("Inspector"),this._redrawAllLayers&&this._redrawAllLayers()}catch(d){console.error("Net bin select failed:",d)}}_activeChartData(){return this._activeDebugChart>=0?{kind:"generic",data:this._debugCharts[this._activeDebugChart]}:{kind:"histogram",data:this._histogramData}}_chartBaseName(){return this._activeDebugChart>=0?this._debugCharts[this._activeDebugChart].name||"chart":this._currentTab}_triggerDownload(n,r,{revoke:c=!1}={}){let u=document.createElement("a");u.href=r,u.download=n,document.body.appendChild(u),u.click(),u.remove(),c&&URL.revokeObjectURL(r)}_download(n,r,c){try{let u=URL.createObjectURL(new Blob([c],{type:r}));this._triggerDownload(n,u,{revoke:!0})}catch(u){console.error("Download failed:",u)}}_exportCsv(){let{kind:n,data:r}=this._activeChartData();if(!r)return;let c=Mdn(n,r);this._download(this._chartBaseName()+".csv","text/csv",c)}_exportPng(){try{let n=this._canvas.toDataURL("image/png");this._triggerDownload(this._chartBaseName()+".png",n)}catch(n){console.error("PNG export failed:",n)}}setDebugCharts(n){this._debugCharts=n,n.length===0?this._activeDebugChart=-1:this._activeDebugChart>=n.length&&(this._activeDebugChart=0),this._rebuildSelect(),this._syncView()}_syncView(){let n=this._activeDebugChart>=0;n&&(this._hoveredBar=null,this._tooltip.style.display="none");let r=!n&&(this._currentTab==="setup"||this._currentTab==="hold");this._filterRow&&(this._filterRow.style.display=r?"":"none"),this._sizeCanvas(),n?this._renderLineChart(this._debugCharts[this._activeDebugChart]):(this._computeLayout(),this._render())}_renderLineChart(n){let r=this._canvas.getBoundingClientRect(),c=r.width,u=r.height,d=this._ctx,b=fk();d.clearRect(0,0,c,u),d.fillStyle=b.canvasBg,d.fillRect(0,0,c,u);let w=n.points;if(!w||w.length===0){d.fillStyle=b.canvasText,d.font="14px "+b.fontSans,d.textAlign="center",d.textBaseline="middle",d.fillText("No data points yet",c/2,u/2);return}let _=n.y_labels?n.y_labels.length:1,x=a3t,T=c-c3t,M=l3t,L=u-u3t,I=T-x,D=L-M;if(I<=0||D<=0)return;let F=w[0].x,O=w[0].x,z=1/0,Z=-1/0;for(let ue of w){ue.xO&&(O=ue.x);for(let Te of ue.ys)TeZ&&(Z=Te)}F===O&&(O=F+1),(!isFinite(z)||!isFinite(Z))&&(z=0,Z=1);let H=(Z-z)*.05||1;z-=H,Z+=H;let te=ue=>x+(ue-F)/(O-F)*I,oe=ue=>L-(ue-z)/(Z-z)*D;d.strokeStyle=b.canvasAxis,d.lineWidth=1,d.beginPath(),d.moveTo(x,M),d.lineTo(x,L),d.lineTo(T,L),d.stroke(),d.fillStyle=b.canvasLabel,d.font="10px "+b.fontMono,d.textAlign="right",d.textBaseline="middle";let ne=5;for(let ue=0;ue<=ne;ue++){let Te=z+(Z-z)*ue/ne,Q=oe(Te);d.fillText(this._formatNum(Te),x-4,Q),ue>0&&ue1&&n.y_labels){d.font="10px "+b.fontMono,d.textAlign="left",d.textBaseline="top";let ue=x+8,Te=M+4;for(let Q=0;Q<_;Q++){let ge=xT[Q%xT.length];d.fillStyle=ge,d.fillRect(ue,Te+Q*14,12,10),d.fillStyle=b.canvasLabel,d.fillText(n.y_labels[Q],ue+16,Te+Q*14)}}}_formatNum(n){let r=Math.abs(n);return r===0?"0":r>=1e6?(n/1e6).toFixed(1)+"M":r>=1e3?(n/1e3).toFixed(1)+"k":r>=1?n.toFixed(1):n.toPrecision(3)}_formatCount(n){return n===0?"0":n>=1e6?n/1e6+"M":n>=1e3?n/1e3+"k":String(n)}};var Rv=class{constructor(n){this.onChange=n,this.roots=[],this._nodeMap=new Map}addFromSpec(n,r=null){let c=this._makeNode(n.id,r,n);if(c.checked=n.checked!==!1,n.children){for(let u of n.children)c.children.push(this.addFromSpec(u,c));c.hasCheckbox&&this._computeParent(c)}return r||this.roots.push(c),c}buildFromNodes(n){this._nodeMap.clear(),this.roots=[];for(let r of n)this._makeNode(r.id,null,r);for(let r of n){let c=this._nodeMap.get(r.id);if(r.parentId!=null&&this._nodeMap.has(r.parentId)){let u=this._nodeMap.get(r.parentId);c.parent=u,u.children.push(c)}else this.roots.push(c)}for(let r=n.length-1;r>=0;r--){let c=this._nodeMap.get(n[r].id);c.hasCheckbox&&c.children.length>0&&this._computeParent(c)}return this.roots}get(n){return this._nodeMap.get(n)}isVisible(n){let r=this.get(n);return r?r.checked:!1}check(n,r){let c=this._nodeMap.get(n);if(c){c.checked=r,c.indeterminate=!1;for(let u of c.children)this._setSubtree(u,r);for(let u=c.parent;u;u=u.parent)u.hasCheckbox&&this._computeParent(u);this.onChange()}}cascadeQuiet(n,r){let c=this._nodeMap.get(n);if(c){c.checked=r,c.indeterminate=!1;for(let u of c.children)this._setSubtree(u,r);for(let u=c.parent;u;u=u.parent)u.hasCheckbox&&this._computeParent(u)}}checkSet(n){for(let[r,c]of Object.entries(n)){let u=this._nodeMap.get(r);u&&(u.checked=c,u.indeterminate=!1)}this._recomputeAllParents(),this.onChange()}mirrorStates(n){this._applyMirror(n),this.onChange()}mirrorStatesQuiet(n){this._applyMirror(n)}_applyMirror(n){for(let[r,c]of Object.entries(n)){let u=this._nodeMap.get(r);u&&(u.checked=!!c.checked,u.indeterminate=!!c.indeterminate)}}forEach(n){let r=c=>{n(c);for(let u of c.children)r(u)};for(let c of this.roots)r(c)}_makeNode(n,r,c){let u={id:n,parent:r,children:[],hasCheckbox:c.hasCheckbox!==!1,checked:c.checked!==!1,indeterminate:!1,data:c.data!=null?c.data:c};return this._nodeMap.set(n,u),u}_checkboxDescendants(n){let r=[];for(let c of n.children)c.hasCheckbox?r.push(c):r.push(...this._checkboxDescendants(c));return r}_computeParent(n){let r=this._checkboxDescendants(n);if(r.length===0)return;let c=r.every(d=>d.checked&&!d.indeterminate),u=r.every(d=>!d.checked&&!d.indeterminate);n.checked=c,n.indeterminate=!c&&!u}_setSubtree(n,r){n.hasCheckbox&&(n.checked=r,n.indeterminate=!1);for(let c of n.children)this._setSubtree(c,r)}_recomputeAllParents(){let n=r=>{for(let c of r.children)n(c);r.hasCheckbox&&r.children.length>0&&this._computeParent(r)};for(let r of this.roots)n(r)}};var f3t=["Instance","Module","Instances","Macros","Modules","Area","Local Inst","Local Macros","Local Modules"],ET={MODULE:0,LEAF_GROUP:1,TYPE_GROUP:2,INSTANCE:3,NAME_GROUP:4};function dk(s){return s===ET.MODULE||s===ET.NAME_GROUP}var Khe=class{constructor(n,r,c){this._app=r,this._redrawAllLayers=c,this._nodes=[],this._nameGrouped=!1,this._nameGroupsCapped=!1,this._rows=[],this._childrenMap=new Map,this._collapsed=new Set,this._moduleState=new Map,this._checkModel=null,this._build(n),r.hierarchyBrowser=this,ua(r)&&this.update()}_build(n){let r=document.createElement("div");r.className="hierarchy-widget";let c=document.createElement("div");c.className="timing-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",ua(this._app)&&(this._updateBtn.style.display="none"),this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",c.appendChild(this._updateBtn),c.appendChild(this._statusLabel),r.appendChild(c),this._tableContainer=document.createElement("div"),this._tableContainer.className="hierarchy-table-container",this._table=document.createElement("table"),this._table.className="timing-table",this._tableContainer.appendChild(this._table),r.appendChild(this._tableContainer),n.element.appendChild(r),this._bindEvents()}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update())}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...",this._statusLabel.textContent="";try{let n=await this._app.websocketManager.request({type:"module_hierarchy"});this._nodes=n.nodes||[],this._nameGrouped=!!n.name_grouped,this._nameGroupsCapped=!!n.name_groups_capped,this._buildTree(),this._readServerColors(),this._computeEffectiveColors(),this._render(),this._statusLabel.textContent=this._statusText(),await this._sendModuleColors()}catch(n){this._statusLabel.textContent="Error: "+n.message}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}_statusText(){let n=this._nodes.filter(u=>dk(u.node_kind||0)).length;if(!this._nameGrouped)return n+" modules";let c=Math.max(0,n-1)+" groups from instance names \u2014 this design has no module hierarchy";return this._nameGroupsCapped&&(c+=" (truncated: too many groups)"),c}_buildTree(){this._childrenMap.clear(),this._collapsed.clear();for(let r of this._nodes)this._childrenMap.set(r.id,[]);for(let r of this._nodes)r.parent_id>=0&&this._childrenMap.has(r.parent_id)&&this._childrenMap.get(r.parent_id).push(r.id);this._nodeMap=new Map;for(let r of this._nodes)this._nodeMap.set(r.id,r);for(let r of this._nodes){let c=this._childrenMap.get(r.id);if(!c||c.length===0)continue;let u=r.node_kind||0;u===ET.LEAF_GROUP||u===ET.TYPE_GROUP?this._collapsed.add(r.id):dk(u)&&r.parent_id>=0&&this._collapsed.add(r.id)}this._rows=[];let n=this._nodes.filter(r=>r.parent_id<0);for(let r of n)this._dfs(r.id,0);this._checkModel=new Rv(()=>{this._checkModel.forEach(r=>{if(!r.hasCheckbox)return;let c=this._moduleState.get(r.data.odb_id);c&&(c.visible=r.checked)}),this._sendModuleColors()}),this._checkModel.buildFromNodes(this._nodes.map(r=>({id:r.id,parentId:r.parent_id,hasCheckbox:dk(r.node_kind||0)&&r.odb_id!=null,checked:!0,data:r})))}_readServerColors(){this._moduleState.clear();for(let n of this._rows){let r=this._nodeMap.get(n.id);if(!r||!dk(r.node_kind||0)||r.odb_id==null)continue;let c=r.color||[128,128,128];this._moduleState.set(r.odb_id,{color:c,effectiveColor:c,visible:!0,nodeId:r.id})}}_computeEffectiveColors(){for(let n of this._rows){let r=this._nodeMap.get(n.id);if(!r||!dk(r.node_kind||0))continue;let c=this._moduleState.get(r.odb_id);if(!c)continue;let u=r.parent_id,d=null;for(;u>=0;){let b=this._nodeMap.get(u);if(!b)break;if(dk(b.node_kind||0)){let w=this._moduleState.get(b.odb_id);w&&this._collapsed.has(b.id)&&(d=w.effectiveColor)}u=b.parent_id}c.effectiveColor=d||c.color}}async _sendModuleColors(){let n=[];for(let[c,u]of this._moduleState){if(!u.visible)continue;let[d,b,w]=u.effectiveColor;n.push(`${c}:${d},${b},${w},100`)}let r=n.join(";");try{let c=await this._app.websocketManager.request({type:"set_module_colors",colors:r});console.log("set_module_colors:",c.count,"modules,",n.length,"sent")}catch(c){console.error("set_module_colors failed:",c)}this._redrawAllLayers()}_dfs(n,r){this._rows.push({id:n,depth:r});let c=this._childrenMap.get(n)||[];for(let u of c)this._dfs(u,r+1)}_render(){this._table.innerHTML="";let n=document.createElement("thead"),r=document.createElement("tr");for(let u of f3t){let d=document.createElement("th");d.textContent=u,r.appendChild(d)}n.appendChild(r),this._table.appendChild(n);let c=document.createElement("tbody");for(let u of this._rows){let d=this._nodeMap.get(u.id);if(!d||this._isHidden(d))continue;let b=document.createElement("tr"),w=d.node_kind||0,x=(this._childrenMap.get(u.id)||[]).length>0,T=this._collapsed.has(u.id);w===ET.LEAF_GROUP||w===ET.TYPE_GROUP?(b.style.fontStyle="italic",b.style.color="var(--fg-disabled)"):w===ET.INSTANCE?b.style.color="var(--fg-secondary)":w===ET.NAME_GROUP&&(b.classList.add("hierarchy-name-group"),b.title="Recovered from instance names \u2014 this design has no module hierarchy");let M=document.createElement("td");if(M.style.paddingLeft=8+u.depth*16+"px",M.style.whiteSpace="nowrap",dk(w)&&d.odb_id!=null){let D=this._moduleState.get(d.odb_id),F=this._checkModel?this._checkModel.get(d.id):null;if(D&&F){let O=document.createElement("input");O.type="checkbox",O.checked=F.checked,O.indeterminate=F.indeterminate,O.className="hierarchy-module-cb",F.cb=O,O.addEventListener("change",oe=>{oe.stopPropagation(),this._checkModel.check(d.id,O.checked),this._render()}),M.appendChild(O);let z=document.createElement("span");z.className="hierarchy-color-swatch";let[Z,H,te]=D.effectiveColor;z.style.backgroundColor=`rgb(${Z},${H},${te})`,M.appendChild(z)}}if(x){let D=document.createElement("span");D.className="hierarchy-arrow",D.textContent=T?"\u25B6":"\u25BC",D.addEventListener("click",F=>{F.stopPropagation(),this._toggleNode(u.id)}),M.appendChild(D)}else{let D=document.createElement("span");D.className="hierarchy-arrow",D.style.visibility="hidden",D.textContent="\u25B6",M.appendChild(D)}let L=document.createElement("span");L.textContent=d.inst_name,M.appendChild(L),b.appendChild(M);let I=[d.module_name,TO(d.insts),TO(d.macros),TO(d.modules),this._fmtArea(d.area),TO(d.local_insts),TO(d.local_macros),TO(d.local_modules)];for(let D of I){let F=document.createElement("td");F.textContent=D,F.style.textAlign="right",b.appendChild(F)}b.children[1].style.textAlign="left",c.appendChild(b)}if(this._rows.length===0){let u=document.createElement("tr"),d=document.createElement("td");d.colSpan=f3t.length,d.style.textAlign="center",d.style.color="var(--fg-secondary)",d.textContent=ua(this._app)?"No hierarchy data available":'Click "Update" to load hierarchy',u.appendChild(d),c.appendChild(u)}this._table.appendChild(c),ak(this._table)}_isHidden(n){let r=n.parent_id;for(;r>=0;){if(this._collapsed.has(r))return!0;let c=this._nodeMap.get(r);if(!c)break;r=c.parent_id}return!1}_toggleNode(n){this._collapsed.has(n)?this._collapsed.delete(n):this._collapsed.add(n),this._computeEffectiveColors(),this._render(),this._sendModuleColors()}_fmtArea(n){if(n==null)return"";if(this._app.showDbu){let r=this._app.getDbuPerMicron();return String(Math.round(n*r*r))}return n>=1e6?(n/1e6).toFixed(3)+" mm\xB2":n.toFixed(3)+" \u03BCm\xB2"}};function TO(s){return s!=null?String(s):""}var Tdn='',Cdn='',Adn='',Pdn='',Ldn='',kdn='',Rdn='',Idn='',Ddn='',Bdn='',Odn='',Ndn='';function h3t(s,n,r){r=r||n;let c=null,u=null,d=null,b=!1,w=10;function _(Ge,Ae){return b?Promise.resolve():(b=!0,s.websocketManager.request({type:"set_property",name:Ge,use_dbu:s.showDbu,...Ae}).then(Le=>{!Le.ok&&Le.error&&Y1(Le.error),xi(Le),Le.ok&&Le.bbox&&Si(Le.bbox)}).catch(Le=>{console.error("set_property failed:",Le),Y1("Edit failed: "+Le),c&&xi(c)}).finally(()=>{b=!1}))}function x(Ge,Ae){let Le=document.createElement("select");Le.className="inspector-editor-select";let ht=Ge.editor.type==="bool"?["True","False"]:Ge.editor.options||[];for(let Ye of ht){let ct=document.createElement("option");ct.value=Ye,ct.textContent=Ye,Ye===Ge.value&&(ct.selected=!0),Le.appendChild(ct)}if(!ht.includes(Ge.value)){let Ye=document.createElement("option");Ye.value=Ge.value||"",Ye.textContent=Ge.value||"",Ye.selected=!0,Ye.disabled=!0,Le.insertBefore(Ye,Le.firstChild)}return Le.addEventListener("change",()=>{if(Ae.onPropertyChange){Ae.onPropertyChange(Ge.name,Le.value);return}if(Ge.editor.type==="bool")Ae.onPropertyEdit(Ge,{value:Le.value==="True"});else{let Ye=(Ge.editor.options||[]).indexOf(Le.value);Ae.onPropertyEdit(Ge,{option_index:Ye,option_name:Le.value})}}),Le}async function T(Ge,Ae){if(!b&&!(Ge==="Delete"&&!await Bxt({title:"Delete "+(Ae.type||"object"),message:"Delete "+(Ae.type||"object")+' "'+(Ae.name||"")+'"? This cannot be undone.',confirmLabel:"Delete",danger:!0}))){b=!0;try{let Le=await s.websocketManager.request({type:"trigger_action",name:Ge,use_dbu:s.showDbu});!Le.ok&&Le.error&&Y1(Le.error),xi(Le.properties?Le:null),Le.deleted&&qn(),ot(),r()}catch(Le){console.error("trigger_action failed:",Le),Y1("Action failed: "+Le)}finally{b=!1}}}function M(Ge){s.websocketManager.request({...Ge,use_dbu:s.showDbu}).then(Ae=>{!Ae.ok&&Ae.error&&Y1(Ae.error),xi(Ae),r()}).catch(Ae=>{console.error(Ge.type+" failed:",Ae)})}function L(){let Ge=document.getElementById("highlight-picker");Ge&&Ge.remove()}function I(Ge,Ae){L();let Le=s.techData?.highlight_colors||[];if(!Le.length)return;let ht=document.createElement("div");ht.id="highlight-picker";let Ye=document.createElement("div");if(Ye.className="highlight-swatch-grid",Le.forEach((Ke,pt)=>{let Xn=document.createElement("button");Xn.className="highlight-swatch",Xn.title="Group "+(pt+1),Xn.style.backgroundColor=`rgb(${Ke[0]}, ${Ke[1]}, ${Ke[2]})`,pt===Ae.highlight_group&&Xn.classList.add("active"),Xn.addEventListener("click",()=>{L(),M({type:"highlight",group:pt})}),Ye.appendChild(Xn)}),ht.appendChild(Ye),Ae.highlight_group>=0){let Ke=document.createElement("button");Ke.className="highlight-remove",Ke.textContent="Remove highlight",Ke.addEventListener("click",()=>{L(),M({type:"unhighlight"})}),ht.appendChild(Ke)}document.body.appendChild(ht);let ct=Ge.getBoundingClientRect();ht.style.left=ct.left+"px",ht.style.top=ct.bottom+4+"px";let Ze=Ke=>{Ke.type==="keydown"&&Ke.key!=="Escape"||Ke.type==="mousedown"&&ht.contains(Ke.target)||(L(),document.removeEventListener("mousedown",Ze,!0),document.removeEventListener("keydown",Ze,!0))};setTimeout(()=>{document.addEventListener("mousedown",Ze,!0),document.addEventListener("keydown",Ze,!0)},0)}function D(){if(!s.inspectorEl)return;s.inspectorEl.innerHTML="";let Ge=document.createElement("div");Ge.className="stub-panel",Ge.innerHTML='
Loading\u2026
Fetching properties from server.
',s.inspectorEl.appendChild(Ge)}async function F(Ge){let Ae=s.focusNets.has(Ge)?"remove":"add";Ae==="add"?s.focusNets.add(Ge):s.focusNets.delete(Ge);try{await s.websocketManager.request({type:"set_focus_nets",action:Ae,net_name:Ge})}catch(Le){console.error("set_focus_nets failed:",Le)}n(),c&&xi(c)}async function O(){s.focusNets.clear();try{await s.websocketManager.request({type:"set_focus_nets",action:"clear",net_name:""})}catch(Ge){console.error("set_focus_nets clear failed:",Ge)}n(),c&&xi(c)}async function z(Ge){let Ae=s.routeGuideNets.has(Ge)?"remove":"add";Ae==="add"?s.routeGuideNets.add(Ge):s.routeGuideNets.delete(Ge);try{await s.websocketManager.request({type:"set_route_guides",action:Ae,net_name:Ge})}catch(Le){console.error("set_route_guides failed:",Le)}r(),c&&xi(c)}function Z(Ge,Ae,Le,ht){return X1(Ge,Ae,Le,ht,s.designScale,s.designOriginX,s.designOriginY)}function H(Ge,Ae,Le){return Ge+(Ae-Ge)*Le}function te(Ge,Ae,Le){return Ge.map((ht,Ye)=>Math.round(H(ht,Ae[Ye],Le)))}function oe(Ge,Ae){let Le=0;for(;LeGe[Le+1].at;)Le++;let ht=Ge[Le],Ye=Ge[Le+1],ct=Math.max(0,Math.min(1,(Ae-ht.at)/(Ye.at-ht.at))),Ze={};for(let Ke of Object.keys(ht))Ke!=="at"&&(Ze[Ke]=Array.isArray(ht[Ke])?te(ht[Ke],Ye[Ke],ct):H(ht[Ke],Ye[Ke],ct));return Ze}function ne(Ge,Ae,Le,ht){if(nH()||typeof requestAnimationFrame!="function")return ht(),()=>{};let Ye=performance.now(),ct=!1,Ze=()=>{if(ct)return;let Ke=performance.now()-Ye;if(Ke>=Ge*Ae){ht();return}Le(Ke%Ge/Ge),requestAnimationFrame(Ze)};return Ze(),()=>{ct=!0}}function ue(Ge,Ae,Le=bp.highlight){s.view&&s.view.setOverlay(Ge,Ae,{order:Le})}let Te=null,Q=()=>{},ge=[255,242,122],Qe=[{at:0,stroke:[255,246,176],width:7,alpha:1,fill:.28},{at:.55,stroke:[255,255,255],width:5,alpha:1,fill:.06},{at:1,stroke:[255,232,92],width:3,alpha:.95,fill:.14}],st={stroke:[255,232,92],width:3,alpha:1,fill:.14};function at(Ge,Ae,Le,ht){let[Ye,ct,Ze,Ke]=Z(Ge,Ae,Le,ht),pt=w/2**s.view.getZoom(),Xn=Math.max(0,(pt-(Ze-Ye))/2),_i=Math.max(0,(pt-(Ke-ct))/2);return[Ye-Xn,ct-_i,Ze+Xn,Ke+_i]}function Ne(Ge){Te&&ue("hover",Te.map(([Ae,Le,ht,Ye])=>({kind:"rect",rect:at(Ae,Le,ht,Ye),stroke:K1(Ge.stroke,Ge.alpha),width:Ge.width,fill:K1(ge,Ge.fill)})))}function tt(){Ne(st)}function ot(){Q(),Te=null,ue("hover",null),s.view?.off("zoom",tt)}function Tt(){ot(),s.websocketManager.request({type:"hover",select_id:-1}).then(()=>{}).catch(()=>{})}function jt(Ge){ot(),!(!s.view||!s.designScale||!Ge||Ge.length===0)&&(Te=Ge,s.view.on("zoom",tt),Q=ne(900,3,Ae=>Ne(oe(Qe,1-Math.pow(1-Ae,2))),()=>Ne(st)))}function en(Ge,Ae){Ge.classList.add("inspector-link"),Ge.addEventListener("click",Le=>{Le.stopPropagation(),cn(Ae)}),Ge.addEventListener("mouseenter",()=>{d!==null&&(s.websocketManager.cancel(d),d=null);let Le=s.websocketManager.request({type:"hover",select_id:Ae});d=Le.requestId,Le.then(ht=>{d=null,jt(ht.rects||[]),r()}).catch(()=>{d=null})}),Ge.addEventListener("mouseleave",()=>{Tt(),r()})}function mn(Ge){let Ae=Ge>0?"select_next":"select_prev";u!==null&&(s.websocketManager.cancel(u),u=null),D();let Le=Pm(s),ht=s.websocketManager.request({type:Ae,use_dbu:s.showDbu});u=ht.requestId,ht.then(Ye=>{if(u=null,!!Z1(s,Le)){if(Ye.error){console.error("Selection cycle error:",Ye.error),xi(c);return}if(xi(Ye),Ye.type==="Inst"&&Ye.name&&(s.selectedInstanceName=Ye.name,s.schematicWidget&&s.schematicWidget.refresh()),ot(),qn(),Ye.bbox&&s.view&&s.designScale){let[ct,Ze,Ke,pt]=Ye.bbox;Ye.type!=="Inst"&&Yi(ct,Ze,Ke,pt,Ye.type),Ye.selection_count>1?it(Ye.bbox):Si(Ye.bbox,Ye.type)}n()}}).catch(Ye=>{u=null,console.error("Selection cycle failed:",Ye),xi(c)})}function cn(Ge){u!==null&&(s.websocketManager.cancel(u),u=null),D();let Ae=Pm(s),Le=s.websocketManager.request({type:"inspect",select_id:Ge,use_dbu:s.showDbu});u=Le.requestId,Le.then(ht=>{if(u=null,!!Z1(s,Ae)){if(ht.error){console.error("Inspect error:",ht.error);return}if(xi(ht),ot(),qn(),ht.bbox&&s.view&&s.designScale){let[Ye,ct,Ze,Ke]=ht.bbox;ht.type!=="Inst"&&Yi(Ye,ct,Ze,Ke,ht.type),Si(ht.bbox,ht.type)}r()}}).catch(ht=>{u=null,console.error("Inspect failed:",ht)})}function bi(){u!==null&&(s.websocketManager.cancel(u),u=null),D();let Ge=Pm(s),Ae=s.websocketManager.request({type:"inspect_back",use_dbu:s.showDbu});u=Ae.requestId,Ae.then(Le=>{if(u=null,!!Z1(s,Ge)){if(Le.error){console.error("Inspect back error:",Le.error);return}if(xi(Le),ot(),qn(),Le.bbox&&s.view&&s.designScale){if(Le.type!=="Inst"){let[ht,Ye,ct,Ze]=Le.bbox;Yi(ht,Ye,ct,Ze,Le.type)}Si(Le.bbox,Le.type)}r()}}).catch(Le=>{u=null,console.error("Inspect back failed:",Le)})}let Vt=null;function pn(){let Ge=Vt&&s.designScale&&!(s.visibility&&s.visibility.highlight_selected===!1);ue("selection",Ge?[{kind:"rect",rect:Z(...Vt),stroke:K1("#ff0"),width:2,dash:[6,4]}]:null,bp.selection)}function qn(){Vt=null,pn()}function Yi(Ge,Ae,Le,ht,Ye){Vt=Ye==="Net"?null:[Ge,Ae,Le,ht],pn()}let $i=null,Tr=[{at:0,alpha:0,fill:0},{at:.5,alpha:1,fill:.28},{at:1,alpha:0,fill:0}];function wr(){$i&&($i(),$i=null),ue("pulse",null)}function Si(Ge,Ae){if(!Ge||!s.view||!s.designScale||(Fr!==null&&de(),wr(),s.visibility&&s.visibility.highlight_selected===!1)||Ae==="Net")return;let Le=Z(...Ge);$i=ne(350,3,ht=>{let Ye=oe(Tr,.5-.5*Math.cos(Math.PI*ht));ue("pulse",[{kind:"rect",rect:Le,stroke:K1("#ff0",Ye.alpha),width:3,fill:K1("#ff0",Ye.fill)}])},()=>{$i=null,ue("pulse",null)})}let Fr=null;function se(Ge,Ae){ue("anim",[{kind:"rect",rect:Ge,stroke:K1("#ff0"),width:Ae,fill:K1("#ff0",Ae===1?.39:0)}])}function de(){Fr!==null&&(clearInterval(Fr),Fr=null),ue("anim",null)}function it(Ge,{repeats:Ae=6,intervalMs:Le=300}={}){if(!Ge||!s.view||!s.designScale)return;if(de(),nH()){Si(Ge);return}let ht=Z(...Ge);se(ht,1);let Ye=0,ct=Ae>0?Ae*3:1/0;Fr=setInterval(()=>{if(Ye+=1,Ye>=ct){de();return}se(ht,Ye%3+1)},Le)}s.clearSelectionPulse=wr,s.renderSelectionOutline=pn,s.clearSelectionOutline=qn;function We(Ge,Ae,Le){let ht=document.createElement("div");ht.className="inspector-group";let Ye=document.createElement("div");Ye.className="inspector-group-header";let ct=document.createElement("span");ct.className="vis-arrow";let Ze=document.createElement("span");if(Ze.className="inspector-prop-name",Ze.textContent=Ge,Ze.title=Ge,Ye.appendChild(ct),Ye.appendChild(Ze),Ae!==null){let pt=document.createElement("span");pt.className="inspector-count",pt.textContent=`(${Ae})`,Ye.appendChild(pt)}ht.appendChild(Ye);let Ke=document.createElement("div");return Ke.className="inspector-group-children"+(Le?" collapsed":""),ct.textContent=Le?"\u25B6":"\u25BC",ht.appendChild(Ke),Ye.addEventListener("click",()=>{Ke.classList.toggle("collapsed"),ct.textContent=Ke.classList.contains("collapsed")?"\u25B6":"\u25BC"}),{group:ht,header:Ye,arrow:ct,body:Ke}}function En(Ge){let Ae=Ge.column_headers||[],Le=Ge.row_headers||[],ht=Ge.data||[],Ye=Ae.some(pt=>pt!==""),ct=Le.some(pt=>pt!==""),Ze=document.createElement("table");if(Ze.className="inspector-table",Ye){let pt=document.createElement("thead"),Xn=document.createElement("tr");ct&&Xn.appendChild(document.createElement("th"));for(let _i of Ae){let Hi=document.createElement("th");Hi.textContent=_i,Xn.appendChild(Hi)}pt.appendChild(Xn),Ze.appendChild(pt)}let Ke=document.createElement("tbody");return ht.forEach((pt,Xn)=>{let _i=document.createElement("tr");if(ct){let Hi=document.createElement("th");Hi.textContent=Le[Xn]||"",_i.appendChild(Hi)}for(let Hi of pt){let _n=document.createElement("td");_n.textContent=Hi,_i.appendChild(_n)}Ke.appendChild(_i)}),Ze.appendChild(Ke),Ze}function hr(Ge,Ae){if(Ge.table){let Ze=(Ge.table.data||[]).length,{group:Ke,body:pt}=We(Ge.name,Ze,Ze>=10),Xn=document.createElement("div");return Xn.className="inspector-table-scroll",Xn.appendChild(En(Ge.table)),pt.appendChild(Xn),Ke}if(Ge.children){let Ze=Ge.children.length<10,{group:Ke,body:pt}=We(Ge.name,Ge.children.length,!Ze);for(let Xn of Ge.children)pt.appendChild(hr(Xn,Ae));return Ke}let Le=document.createElement("div");Le.className="inspector-prop";let ht=document.createElement("span");ht.className="inspector-prop-name",ht.textContent=Ge.name||"",ht.title=Ge.name||"";let Ye=document.createElement("span");Ye.className="inspector-prop-value",Ye.textContent=Ge.value||"",Le.appendChild(ht),Le.appendChild(Ye);let ct=Ge.editable&&Ae&&(Ae.onPropertyEdit||Ae.onPropertyChange)&&Ge.editor&&(Ge.editor.type==="list"||Ge.editor.type==="bool");if(ct&&Ge.value_select_id===void 0)Le.replaceChild(x(Ge,Ae),Ye);else if(ct){let Ze=document.createElement("button");Ze.className="inspector-edit-btn",Ze.title="Edit "+Ge.name,Ze.textContent="\u270E",Ze.addEventListener("click",Ke=>{Ke.stopPropagation();let pt=x(Ge,Ae);Le.replaceChild(pt,Ye),Ze.remove(),pt.focus()}),Le.appendChild(Ze)}else Ge.editable&&Ae&&(Ae.onPropertyChange||Ae.onPropertyEdit)&&(Ye.contentEditable=!0,Ye.classList.add("inspector-editable"),Ye.addEventListener("blur",()=>{let Ze=Ye.textContent;if(Ze!==Ge.value){if(Ae.onPropertyChange){Ae.onPropertyChange(Ge.name,Ze);return}if(Ge.editor&&Ge.editor.type==="number"){let Ke=Number(Ze);if(Ze.trim()===""||Number.isNaN(Ke)){Y1("Not a number: "+Ze),Ye.textContent=Ge.value;return}Ae.onPropertyEdit(Ge,{value:Ke});return}Ae.onPropertyEdit(Ge,{value:Ze})}}),Ye.addEventListener("keydown",Ze=>{Ze.key==="Enter"&&(Ze.preventDefault(),Ye.blur()),Ze.key==="Escape"&&(Ye.textContent=Ge.value,Ye.blur())}));return Ge.name_select_id!==void 0&&Ge.value_select_id===void 0?(en(Le,Ge.name_select_id),ht.classList.add("inspector-link")):Ge.name_select_id!==void 0&&en(ht,Ge.name_select_id),Ge.value_select_id!==void 0&&en(Ye,Ge.value_select_id),Le}let qi=140,Me=60,ve=500,wt=qi;function gn(){s.inspectorEl&&s.inspectorEl.style.setProperty("--inspector-name-w",wt+"px")}function vn(){let Ge=document.createElement("div");return Ge.className="inspector-col-resizer",Ge.title="Drag to resize the name column",Ge.addEventListener("mousedown",Ae=>{Ae.preventDefault();let Le=Ae.clientX,ht=wt;Ge.classList.add("dragging");let Ye=Ze=>{wt=Math.max(Me,Math.min(ve,ht+Ze.clientX-Le)),gn()},ct=()=>{Ge.classList.remove("dragging"),document.removeEventListener("mousemove",Ye),document.removeEventListener("mouseup",ct)};document.addEventListener("mousemove",Ye),document.addEventListener("mouseup",ct)}),Ge}function Mn(Ge){!Ge||!s.view||!s.designScale||s.view.fitWorldRect(Z(...Ge),{padding:[20,20]})}function xi(Ge){if(!s.inspectorEl)return;if(c=Ge,s.inspectorEl.innerHTML="",!Ge||!Ge.properties||Ge.properties.length===0){de();let Ye=document.createElement("div");Ye.className="stub-panel",Ye.innerHTML='
Inspector
Select an object in the layout to inspect its properties.
',s.inspectorEl.appendChild(Ye);return}if(!Ge.onPropertyChange&&!Ge.onPropertyEdit&&!ua(s)&&(Ge.onPropertyEdit=(Ye,ct)=>_(Ye.name,ct)),Ge){let Ye=document.createElement("div");Ye.className="inspector-toolbar";let ct=document.createElement("button");if(ct.className="or-btn or-btn-icon",ct.title="Back",ct.innerHTML=Pdn,ct.disabled=!Ge.can_navigate_back,ct.addEventListener("click",()=>bi()),Ye.appendChild(ct),Ge.bbox){let Ze=document.createElement("button");Ze.className="or-btn or-btn-icon",Ze.title="Zoom to",Ze.innerHTML=Adn,Ze.addEventListener("click",()=>Mn(Ge.bbox)),Ye.appendChild(Ze)}if(Ge.type==="Net"&&Ge.name){let Ze=s.focusNets.has(Ge.name),Ke=document.createElement("button");Ke.className="or-btn or-btn-icon",Ke.title=Ze?"De-focus net":"Focus net",Ke.innerHTML=Ze?kdn:Ldn,Ke.addEventListener("click",()=>F(Ge.name)),Ye.appendChild(Ke)}if(Ge.type==="Net"&&Ge.name&&Ge.has_guides){let Ze=s.routeGuideNets.has(Ge.name),Ke=document.createElement("button");Ke.className="or-btn or-btn-icon",Ke.title=Ze?"Hide route guides":"Show route guides",Ke.innerHTML=Ze?Idn:Rdn,Ke.addEventListener("click",()=>z(Ge.name)),Ye.appendChild(Ke)}if(Ge.type==="Net"&&Ge.name&&s.showInsertBufferDialog){let Ze=document.createElement("button");Ze.className="or-btn or-btn-icon",Ze.title="Insert buffer",Ze.innerHTML=Ndn,Ze.addEventListener("click",()=>s.showInsertBufferDialog(Ge.name)),Ye.appendChild(Ze)}if(s.focusNets.size>0){let Ze=document.createElement("button");Ze.className="or-btn or-btn-icon",Ze.title="Clear focus nets",Ze.innerHTML=Ddn,Ze.addEventListener("click",()=>O()),Ye.appendChild(Ze)}if(typeof Ge.highlight_group=="number"&&!ua(s)&&(s.techData?.highlight_colors||[]).length){let Ze=document.createElement("button");Ze.className="or-btn or-btn-icon inspector-highlight-btn";let Ke=Ge.highlight_group;if(Ze.title=Ke>=0?"Highlight group "+(Ke+1):"Add to highlight group",Ze.innerHTML=Cdn,Ke>=0){let pt=s.techData.highlight_colors[Ke];Ze.style.backgroundColor=`rgba(${pt[0]}, ${pt[1]}, ${pt[2]}, 0.45)`,Ze.style.borderColor=`rgb(${pt[0]}, ${pt[1]}, ${pt[2]})`}Ze.addEventListener("click",()=>I(Ze,Ge)),Ye.appendChild(Ze)}if(Array.isArray(Ge.actions)&&!ua(s))for(let Ze of Ge.actions){let Ke=document.createElement("button");Ke.className="or-btn inspector-action-btn",Ke.title=Ze,Ze==="Delete"?(Ke.classList.add("or-btn-icon","or-btn-danger-hover"),Ke.innerHTML=Tdn):(Ke.classList.add("or-btn-sm"),Ke.textContent=Ze),Ke.addEventListener("click",()=>T(Ze,Ge)),Ye.appendChild(Ke)}s.inspectorEl.appendChild(Ye)}let Ae=Ge.selection_count||0,Le=typeof Ge.selection_index=="number"?Ge.selection_index:-1;if(Ae>1&&Le>=0){let Ye=document.createElement("div");Ye.className="inspector-selection-nav";let ct=document.createElement("button");ct.className="or-btn or-btn-icon",ct.title="Previous (Shift+click to multi-select)",ct.innerHTML=Bdn,ct.addEventListener("click",()=>mn(-1));let Ze=document.createElement("span");Ze.className="inspector-selection-label",Ze.textContent=Le+1+" / "+Ae;let Ke=document.createElement("button");Ke.className="or-btn or-btn-icon",Ke.title="Next",Ke.innerHTML=Odn,Ke.addEventListener("click",()=>mn(1)),Ye.appendChild(ct),Ye.appendChild(Ze),Ye.appendChild(Ke),s.inspectorEl.appendChild(Ye)}let ht=document.createElement("div");ht.className="inspector-rows";for(let Ye of Ge.properties)ht.appendChild(hr(Ye,Ge));ht.appendChild(vn()),s.inspectorEl.appendChild(ht),gn()}function mi(Ge){let Ae=document.createElement("div");Ae.className="inspector",s.inspectorEl=Ae,Ge.element.appendChild(Ae),xi(null)}function ri(){if(c){if(c.type==="Ruler"){s.rulerManager&&s.rulerManager._selectedRulerId!==null&&s.rulerManager._selectRuler(s.rulerManager._selectedRulerId);return}s.websocketManager&&cn(-1)}}return{createInspector:mi,updateInspector:xi,highlightBBox:Yi,pulseHighlight:Si,animateSelection:it,stopSelectionAnimation:de,navigateInspector:cn,refreshInspector:ri}}var Jhe=class{constructor(n,r,c){this._app=r,this._refreshOverlay=c||(()=>{}),this._data={selection:[],groups:[],truncated:!1},this._tab="selected",this._filter="",this._sortKey=null,this._sortAsc=!0,this._pendingRefresh=null,this._inFlight=!1,this._staleWhileInFlight=!1,this._visible=!0,this._el=document.createElement("div"),this._el.className="selection-browser",n.element.appendChild(this._el),n.on?.("show",()=>{this._visible=!0,this.refresh()}),n.on?.("hide",()=>{this._visible=!1}),n.on?.("destroy",()=>{this._visible=!1,this._staleWhileInFlight=!1,this._pendingRefresh!==null&&(clearTimeout(this._pendingRefresh),this._pendingRefresh=null)}),this._render(),this.refresh()}scheduleRefresh(){!this._visible||this._pendingRefresh!==null||(this._pendingRefresh=setTimeout(()=>{this._pendingRefresh=null,this.refresh()},150))}refresh(){if(!this._visible||ua(this._app))return;if(this._inFlight){this._staleWhileInFlight=!0;return}this._inFlight=!0;let n=()=>{this._inFlight=!1,this._staleWhileInFlight&&(this._staleWhileInFlight=!1,this.refresh())};this._app.websocketManager.request({type:"list_selection"}).then(r=>{r.ok&&(this._data=r,this._render()),n()}).catch(n)}_entries(){let n;this._tab==="selected"?n=(this._data.selection||[]).map((c,u)=>({row:c,index:u,group:-1})):n=(this._data.groups||[]).flatMap((c,u)=>c.map((d,b)=>({row:d,index:b,group:u})));let r=this._filter.trim().toLowerCase();if(r&&(n=n.filter(({row:c})=>(c.name||"").toLowerCase().includes(r)||(c.type||"").toLowerCase().includes(r))),this._sortKey){let c=this._sortKey,u=this._sortAsc?1:-1;n=n.slice().sort((d,b)=>u*String(d.row[c]||"").localeCompare(String(b.row[c]||"")))}return n}_fmtCoord(n){if(this._app.showDbu)return String(n);let r=this._app.getDbuPerMicron?this._app.getDbuPerMicron():1e3;return(n/r).toFixed(3)}_fmtBounds(n){if(!n)return"";let[r,c,u,d]=n;return`(${this._fmtCoord(r)}, ${this._fmtCoord(c)}), (${this._fmtCoord(u)}, ${this._fmtCoord(d)})`}_inspectRow(n,r){let c=n.group<0?{type:"inspect_selection",index:n.index,use_dbu:this._app.showDbu}:{type:"inspect_group",group:n.group,index:n.index,use_dbu:this._app.showDbu};this._app.websocketManager.request(c).then(u=>{if(!u.ok){this.refresh();return}this._app.updateInspector&&this._app.updateInspector(u),r&&this._app.focusComponent&&this._app.focusComponent("Inspector"),this._refreshOverlay()}).catch(()=>{})}_deselectRow(n){this._app.websocketManager.request({type:"deselect",index:n.index}).then(()=>{this.refresh(),this._refreshOverlay()}).catch(()=>{})}_clearHighlights(){this._app.websocketManager.request({type:"clear_highlights",group:-1}).then(()=>{this.refresh(),this._refreshOverlay(),this._app.refreshInspector&&this._app.refreshInspector()}).catch(()=>{})}_zoomToBBox(n){if(!n||!this._app.designScale||!this._app.view)return;let[r,c,u,d]=n,b=this._app.getDbuPerMicron?this._app.getDbuPerMicron():1e3,w=Math.min(10*b,2*Math.max(u-r,d-c));this._app.view.fitWorldRect(X1(r-w,c-w,u+w,d+w,this._app.designScale,this._app.designOriginX,this._app.designOriginY))}_render(){this._app.stopSelectionAnimation&&this._app.stopSelectionAnimation(),this._el.innerHTML="";let n=(this._data.selection||[]).length,r=(this._data.groups||[]).reduce((b,w)=>b+w.length,0),c=document.createElement("div");c.className="sb-tabs";for(let[b,w,_]of[["selected","Selected",n],["highlighted","Highlighted",r]]){let x=document.createElement("button");x.className="sb-tab"+(this._tab===b?" active":""),x.textContent=`${w} (${_})`,x.addEventListener("click",()=>{this._tab=b,this._render()}),c.appendChild(x)}let u=document.createElement("button");if(u.className="or-btn or-btn-sm sb-tool",u.title="Refresh",u.textContent="\u27F3",u.addEventListener("click",()=>this.refresh()),c.appendChild(u),this._tab==="highlighted"&&r>0){let b=document.createElement("button");b.className="or-btn or-btn-sm sb-tool",b.title="Clear all highlights",b.textContent="Clear",b.addEventListener("click",()=>this._clearHighlights()),c.appendChild(b)}this._el.appendChild(c);let d=document.createElement("input");if(d.type="text",d.className="sb-filter",d.placeholder="Filter by name or type\u2026",d.value=this._filter,d.addEventListener("input",()=>{this._filter=d.value,this._renderTable()}),this._el.appendChild(d),this._data.truncated){let b=document.createElement("div");b.className="sb-truncated",b.textContent="List truncated \u2014 showing the first 1000 entries per set.",this._el.appendChild(b)}this._tableWrap=document.createElement("div"),this._tableWrap.className="sb-table-wrap",this._el.appendChild(this._tableWrap),this._renderTable()}_renderTable(){this._tableWrap.innerHTML="";let n=this._entries();if(!n.length){let _=document.createElement("div");_.className="sb-empty",_.textContent=this._tab==="selected"?"Nothing selected.":"Nothing highlighted.",this._tableWrap.appendChild(_);return}let r=document.createElement("table");r.className="sb-table";let c=document.createElement("thead"),u=document.createElement("tr"),d=[["name","Object"],["type","Type"],[null,"Bounds"]];this._tab==="highlighted"&&d.push([null,"Group"]),d.push([null,""]);for(let[_,x]of d){let T=document.createElement("th");T.textContent=x,_&&(T.classList.add("sb-sortable"),this._sortKey===_&&(T.textContent+=this._sortAsc?" \u25B2":" \u25BC"),T.addEventListener("click",()=>{this._sortKey===_?this._sortAsc=!this._sortAsc:(this._sortKey=_,this._sortAsc=!0),this._renderTable()})),u.appendChild(T)}c.appendChild(u),r.appendChild(c);let b=document.createElement("tbody"),w=this._app.techData?.highlight_colors||[];for(let _ of n){let x=document.createElement("tr");x.className="sb-row";let T=document.createElement("td");T.textContent=_.row.name||"";let M=document.createElement("td");M.textContent=_.row.type||"";let L=document.createElement("td");if(L.textContent=this._fmtBounds(_.row.bbox),x.appendChild(T),x.appendChild(M),x.appendChild(L),this._tab==="highlighted"){let D=document.createElement("td"),F=document.createElement("span");F.className="sb-chip";let O=w[_.group];O&&(F.style.backgroundColor=`rgb(${O[0]}, ${O[1]}, ${O[2]})`),D.appendChild(F),D.appendChild(document.createTextNode(` Group ${_.group+1}`)),x.appendChild(D)}let I=document.createElement("td");if(I.className="sb-actions",_.row.bbox){let D=document.createElement("button");D.className="sb-row-btn",D.title="Zoom to",D.textContent="\u2316",D.addEventListener("click",F=>{F.stopPropagation(),this._zoomToBBox(_.row.bbox)}),I.appendChild(D)}if(this._tab==="selected"){let D=document.createElement("button");D.className="sb-row-btn",D.title="De-select",D.textContent="\u2715",D.addEventListener("click",F=>{F.stopPropagation(),this._deselectRow(_)}),I.appendChild(D)}x.appendChild(I),x.addEventListener("click",()=>this._inspectRow(_,!1)),x.addEventListener("dblclick",()=>this._inspectRow(_,!0)),_.row.bbox&&(x.addEventListener("mouseenter",()=>{this._app.animateSelection&&this._app.animateSelection(_.row.bbox,{repeats:0})}),x.addEventListener("mouseleave",()=>{this._app.stopSelectionAnimation&&this._app.stopSelectionAnimation()})),b.appendChild(x)}r.appendChild(b),this._tableWrap.appendChild(r),ak(r)}};var p3t="options-dialog",d3t=[{label:"System default",value:""},{label:"Sans-serif",value:"sans-serif"},{label:"Serif",value:"serif"},{label:"Monospace",value:"monospace"},{label:"Helvetica / Arial",value:"Helvetica, Arial, sans-serif"},{label:"Georgia",value:"Georgia, 'Times New Roman', serif"},{label:"Courier",value:"'Courier New', Courier, monospace"}],Fdn=100,Qhe=70,ede=200;function rH(s){let n=s===""||s===null?NaN:Math.round(Number(s));return Number.isFinite(n)?Math.min(ede,Math.max(Qhe,n)):Fdn}function g3t(s){let{overlay:n,close:r,okBtn:c,showError:u}=MO("Arrow keys scroll step",`
How far one arrow-key press pans the layout. - Default ${V5e}.
`,"Apply",d3t),d=n.querySelector(".opt-step");d.focus(),d.select();function b(){let w=d.value.trim(),_=Number(w);if(w===""||!Number.isFinite(_)){u("Step must be a number.");return}if(_eH){u(`Step must be between ${QW} and ${eH} px.`);return}s.setArrowStep(_),r()}return c.addEventListener("click",b),d.addEventListener("keydown",w=>{w.key==="Enter"&&(w.preventDefault(),b())}),{close:r}}function g3t(s){let n=s.fontFamily||"",r=h3t.some(D=>D.value===n),c=h3t.map(D=>``).join("")+(r?"":``),{overlay:u,close:d,okBtn:b,showError:w}=MO("Application font",` + Default ${V5e}.
`,"Apply",p3t),d=n.querySelector(".opt-step");d.focus(),d.select();function b(){let w=d.value.trim(),_=Number(w);if(w===""||!Number.isFinite(_)){u("Step must be a number.");return}if(_eH){u(`Step must be between ${QW} and ${eH} px.`);return}s.setArrowStep(_),r()}return c.addEventListener("click",b),d.addEventListener("keydown",w=>{w.key==="Enter"&&(w.preventDefault(),b())}),{close:r}}function m3t(s){let n=s.fontFamily||"",r=d3t.some(D=>D.value===n),c=d3t.map(D=>``).join("")+(r?"":``),{overlay:u,close:d,okBtn:b,showError:w}=MO("Application font",`
@@ -10241,7 +10241,7 @@ Slack: [${r.lower.toFixed(I)}, ${r.upper.toFixed(I)}) ${L}`}this._tooltip.style. 0123456789
Applies to the panels, menus and console. Text drawn into the layout is rendered on the server and is not - affected.
`,"Apply",d3t),_=u.querySelector(".opt-family"),x=u.querySelector(".opt-custom"),T=u.querySelector(".opt-scale"),M=u.querySelector(".opt-preview");function L(){M.style.fontFamily=x.value.trim()||_.value,M.style.fontSize=`calc(13px * ${rH(T.value)/100})`}for(let D of[_,x,T])D.addEventListener("input",L);L();function I(){let D=T.value.trim(),F=Number(D);if(D===""||!Number.isFinite(F)){w("Size must be a number.");return}if(Fede){w(`Size must be between ${Qhe} and ${ede} %.`);return}s.setAppFont({family:x.value.trim()||_.value,scale:F}),d()}b.addEventListener("click",I);for(let D of[x,T])D.addEventListener("keydown",F=>{F.key==="Enter"&&(F.preventDefault(),I())});return{close:d}}function Q5e(s){return String(s).replace(/&/g,"&").replace(/"/g,""").replace(//g,">")}var Odn='',Ndn='';function CO(s){let n=document.createElement("span");return n.className="vis-name",s!=null&&(n.textContent=s),n}function ET(){let s=document.createElement("span");return s.className="vis-sel-cb vis-sel-spacer",s}function m3t(){let s=document.createElement("div");s.className="display-controls-header",s.appendChild(CO(""));for(let[n,r]of[[Odn,"Visible"],[Ndn,"Selectable"]]){let c=document.createElement("span");c.className="vis-header-icon",c.title=r,c.innerHTML=n,s.appendChild(c)}return s}var tde=class{constructor(n,r,c){this.visibility=n,this.selectability=r,this.onChange=c;let u=()=>{this._syncAll(),this.onChange()};this.model=new Lv(u),this.selModel=new Lv(u)}add(n){return this.model.addFromSpec(this._enrichSpec(n,"")),this.selModel.addFromSpec(this._enrichSelSpec(n,"",!1)),this}render(n){for(let r of this.model.roots)n.appendChild(this._dom(r));this._syncAll()}_nodeId(n,r){let c=n.key||n.label;return r?r+"/"+c:c}_enrichSpec(n,r){let c=this._nodeId(n,r),u={id:c,data:n};return n.children?u.children=n.children.map(d=>this._enrichSpec(d,c)):n.key&&(u.checked=!!this.visibility[n.key]),n.disabled!=null&&(u.disabled=n.disabled),u}_enrichSelSpec(n,r,c){let u=n.addSelectable===!0?!0:n.addSelectable===!1?!1:c,d=this._nodeId(n,r),b={id:d,data:n,hasCheckbox:!1};if(n.children){b.children=n.children.map(_=>this._enrichSelSpec(_,d,u));let w=_=>_.some(x=>x.hasCheckbox||x.children&&w(x.children));b.hasCheckbox=w(b.children),b.hasCheckbox&&(b.checked=!0)}else if(n.key){let w=n.selectable===!0||n.selectable!==!1&&c;b.hasCheckbox=w,w&&(b.checked=this.selectability[n.key]!==!1)}return b}_syncAll(){this.model.forEach(n=>{n.cb&&(n.cb.checked=n.checked,n.cb.indeterminate=n.indeterminate);let r=n.data;r.key&&(this.visibility[r.key]=n.checked),r.visKey&&(this.visibility[r.visKey]=n.checked||n.indeterminate)}),this.selModel.forEach(n=>{if(!n.hasCheckbox)return;let r=n.data;if(r.key&&(this.selectability[r.key]=n.checked),!n.selCb)return;n.selCb.checked=n.checked,n.selCb.indeterminate=n.indeterminate;let c=this.model.get(n.id),u=c&&!c.checked&&!c.indeterminate;n.selCb.disabled=u,n.selLabel&&n.selLabel.classList.toggle("vis-sel-disabled",u)}),this.model.forEach(n=>{let r=n.data;if(r.disabledBy&&n.el){let c=!this.visibility[r.disabledBy];n.el.classList.toggle("disabled",c)}})}_buildSelCheckbox(n){let r=this.selModel.get(n.id);if(!r||!r.hasCheckbox)return null;let c=document.createElement("input");return c.type="checkbox",c.className="vis-sel-cb",c.title="Selectable",c.addEventListener("change",()=>{this.selModel.check(r.id,c.checked)}),r.selCb=c,c}_dom(n){let r=n.data,c=document.createElement("input");c.type="checkbox",c.className="vis-cb",c.title="Visible",n.cb=c,c.addEventListener("change",()=>this.model.check(n.id,c.checked));let u=this._buildSelCheckbox(n),d=M=>{if(M.appendChild(c),u){M.appendChild(u);let L=this.selModel.get(n.id);L&&(L.selLabel=M)}else M.appendChild(ET())};if(!n.children.length){let M=document.createElement("div");M.className="vis-leaf";let L=document.createElement("span");return L.className="vis-arrow",L.style.visibility="hidden",L.textContent="\u25B6",M.appendChild(L),M.appendChild(CO(r.label)),d(M),n.el=M,M}let b=document.createElement("div");b.className="vis-group";let{header:w,arrow:_,name:x}=sk();x.textContent=r.label,d(w),b.appendChild(w);let T=document.createElement("div");T.className="vis-group-children",r.disabled&&T.classList.add("disabled");for(let M of n.children)T.appendChild(this._dom(M));return b.appendChild(T),ok(w,_,T,!0),b}};function sH(s,n,r,c){let u=new Set,d=Math.max(0,s-n),b=Math.min(c-1,s+r);for(let w=d;w<=b;w++)u.add(w);return u}function Fdn(s){let n={};for(let[r,c]of Object.entries(s||{}))c!==1&&(n[r]=c);return n}function nde(s,n){return(s||[]).some(r=>r.every(c=>!!n[c]))}function Udn(s,n){return s.map(r=>{let c=!n.has(r.path);return{id:r.path,parentId:r.parent!=null?r.parent:null,hasCheckbox:r.parent!=null,checked:c,data:{path:r.path,name:r.name,master:r.master,depth:r.depth}}})}var zdn=3,b3t=[[70,130,210],[200,50,50],[50,180,80],[200,160,40],[160,60,200],[40,190,190],[220,120,50],[180,70,150]];function Gdn(s){return!s.forceComposite||la(s)?0:s.groupLayers||Txt}function w3t(s,n,r,c,u,d){if(!s.displayControlsEl)return;s.displayControlsEl.innerHTML="",s.displayControlsEl.appendChild(m3t());for(let Pe of s.allLayers||[])Pe.remove();s.allLayers=[],s.baseSlot=null,s.topSlot=null;let b=new Set;function w(){for(let Pe of b)Pe.refresh();b.clear()}function _(){s.baseSlot&&b.add(s.baseSlot)}function x(Pe){return{layer:Pe,opacity:1,visible:!1}}function T(Pe,ke){wxt(Pe,ke)&&_()}function M(Pe,ke,dt){let Ye={layer:Pe,opacity:1,visible:!!dt};return ke&&(s[ke]=Ye),Ye}let L=[M("_instances",null,!0),M("_pins","pinsLayer",n.pins),M("_modules","modulesLayer",n.module_view)],I=[];s.overlayLayers=(c&&c.overlays||[]).map(Pe=>({def:Pe,layer:M(Pe.name,null,nde(Pe.shown_by,n)),under:Pe.z_indexdt.def.z_index-Ye.def.z_index))(ke?L:I).push(Pe);let D=[],F=[],O=null,z=new Set,Z=new Set;try{let Pe=window.sessionStorage.getItem("or_hidden_layers");Pe&&(z=new Set(JSON.parse(Pe)))}catch{}try{let Pe=window.sessionStorage.getItem("or_nonselectable_layers");Pe&&(Z=new Set(JSON.parse(Pe)))}catch{}try{let Pe=window.sessionStorage.getItem("or_layer_patterns");Pe&&Object.assign(s.layerPatterns,JSON.parse(Pe))}catch{}function H(){try{window.sessionStorage.setItem("or_layer_patterns",JSON.stringify(Fdn(s.layerPatterns)))}catch{}}function te(Pe,ke){ke===1?delete s.layerPatterns[Pe]:s.layerPatterns[Pe]=ke,H(),_(),w()}let se=[{label:"Solid",value:1},{label:"Diagonal",value:2},{label:"Cross",value:3},{label:"Dots",value:4},{label:"None (no fill)",value:0}],ne=0;function ue(Pe,ke="layers",dt=void 0){let Ye=[],ct=Pe.type==="category"?dt:Pe.path,Ze=Pe.flipped===!0,Ke=Pe.instances||[],gt=Ke.filter(Zn=>Zn.type!=="category"),qn=Ke.filter(Zn=>Zn.type==="category"),xi=Pe.layers||[],Bi=ne;ne+=xi.length;function xn(Zn,rr){let Me=Zn.map((et,ht)=>ht);rr&&Me.reverse(),Me.forEach(et=>{let ht=Zn[et],on=ke+"/"+(ht.name||et);Ye.push(ue(ht,on,ct))})}function Je(){(Ze?xi.map((rr,Me)=>Me).reverse():xi.map((rr,Me)=>Me)).forEach(rr=>{let Me=xi[rr],et=Me.name||Me,ht=Bi+rr,on=x(et),Ri=`${ke}/${et}`,di=!z.has(Ri);di&&(T(on,!0),s.visibleLayers.add(Ri),s.visibleLayerNames.add(et)),D.push(on),F.push(Ri),Ye.push({id:Ri,data:{name:et,layer:on,color:Me.color,colorIndex:ht,nodeId:Ri,ownerChipletPath:ct},checked:di})})}xn(gt,!1),Ze&&Je(),xn(qn,Ze),Ze||Je();let ti={name:Pe.name,isInstance:!0};return Pe.type==="category"&&(Pe.name==="Implant"||Pe.name==="Other")&&(ti.startCollapsed=!0),Pe.type!=="category"&&(ti.chipletPath=Pe.path),{id:ke,data:ti,children:Ye}}let Ce;c.layer_hierarchy?Ce=ue(c.layer_hierarchy,"layers_parent"):Ce={id:"layers_parent",children:c.layers.map((Pe,ke)=>{let dt=x(Pe),Ye=`layers_parent/${Pe}`,ct=!z.has(Ye);return ct&&(T(dt,!0),s.visibleLayers.add(Ye),s.visibleLayerNames.add(Pe)),D.push(dt),F.push(Ye),{id:Ye,data:{name:Pe,layer:dt,colorIndex:ke,nodeId:Ye},checked:ct}})};function Q(Pe,ke,dt){let Ye=s.view.addTileSlot(Pe,{order:ke,source:Cxt({wm:s.websocketManager,ctx:s.tileCtx,getItems:()=>dt,dpr:xO,tileSize:Ob,isDoubleBuffer:()=>s.doubleBuffer,groupLayers:()=>Gdn(s)})});return Ye.items=dt,Ye}s.baseSlot=Q("base",mp.base,[...L,...D]),s.topSlot=Q("top",mp.top,I),s.allLayers=[s.baseSlot,s.topSlot];function me(Pe){if(!Pe.children||Pe.children.length===0){let ke=Pe.data&&Pe.data.name,dt=ke?!Z.has(ke):!0;return dt&&ke&&s.selectableLayers.add(ke),{id:Pe.id,data:{name:ke},checked:dt}}return{id:Pe.id,data:{name:Pe.data&&Pe.data.name},children:Pe.children.map(me)}}let tt=me(Ce),st=new Lv(()=>{s.visibleLayerNames.clear();let Pe=[],ke={},dt=!1,Ye=!1,ct=O&&s.visibleChiplets instanceof Set;if(st.forEach(Ke=>{if(Ke.cb&&(Ke.cb.checked=Ke.checked,Ke.cb.indeterminate=Ke.indeterminate),Ke.data&&Ke.data.layer){let gt=Ke.data.nodeId||Ke.data.name;Pe.push(gt),T(Ke.data.layer,Ke.checked),Ke.checked?(s.visibleLayers.add(gt),s.visibleLayerNames.add(Ke.data.name)):s.visibleLayers.delete(gt)}if(ct&&Ke.data&&Ke.data.chipletPath){let gt=Ke.data.chipletPath,qn=O.get(gt);if(qn){let xi=Ke.checked||Ke.indeterminate,Bi={checked:Ke.checked,indeterminate:Ke.indeterminate};(qn.checked!==Ke.checked||qn.indeterminate!==Ke.indeterminate)&&(ke[gt]=Bi,dt=!0),s.visibleChiplets.has(gt)!==xi&&(Ye=!0)}}}),s.baseSlot&&b.has(s.baseSlot))for(let{def:Ke,under:gt}of s.overlayLayers)nde(Ke.layers_by,n)&&b.add(gt?s.baseSlot:s.topSlot);w(),Ne();let Ze=Pe.filter(Ke=>!s.visibleLayers.has(Ke));try{window.sessionStorage.setItem("or_hidden_layers",JSON.stringify(Ze))}catch{}s.syncDisplayState(),Ye?O.mirrorStates(ke):dt&&(O.mirrorStatesQuiet(ke),O.forEach(Ke=>{Ke.cb&&(Ke.cb.checked=Ke.checked,Ke.cb.indeterminate=Ke.indeterminate)}))});s.layerModel=st,st.addFromSpec(Ce);let at=new Lv(()=>{s.selectableLayers.clear(),at.forEach(ke=>{ke.checked&&ke.data&&ke.data.name&&s.selectableLayers.add(ke.data.name)}),Ne();let Pe=c.layers.filter(ke=>!s.selectableLayers.has(ke));try{window.sessionStorage.setItem("or_nonselectable_layers",JSON.stringify(Pe))}catch{}s.syncDisplayState()});at.addFromSpec(tt);function Ne(){at.forEach(Pe=>{if(!Pe.selCb)return;Pe.selCb.checked=Pe.checked,Pe.selCb.indeterminate=Pe.indeterminate;let ke=st.get(Pe.id),dt=ke&&!ke.checked&&!ke.indeterminate;Pe.selCb.disabled=dt})}let Qe=document.createElement("div");Qe.className="context-menu",Qe.style.display="none",document.body.appendChild(Qe);function ot(Pe){let ke={};F.forEach((dt,Ye)=>{dt&&(ke[dt]=Pe.has(Ye))}),st.checkSet(ke)}function xt(){Qe.style.display="none"}function fn(Pe,ke){let dt=document.createElement("div");dt.className="context-menu-item",dt.textContent=Pe,dt.addEventListener("click",()=>{ke(),xt()}),Qe.appendChild(dt)}let Xt=D.length,wn=[{label:"Show only this layer",fn:Pe=>sH(Pe,0,0,Xt)},{label:"Show layer range \u2195",fn:Pe=>sH(Pe,1,1,Xt)},{label:"Show layer range \u2195\u2195",fn:Pe=>sH(Pe,2,2,Xt)},{label:"Show layer range \u2193",fn:Pe=>sH(Pe,1,0,Xt)},{label:"Show layer range \u2191",fn:Pe=>sH(Pe,0,1,Xt)}];document.addEventListener("click",Pe=>{Qe.contains(Pe.target)||xt()}),document.addEventListener("keydown",Pe=>{Pe.key==="Escape"&&xt()});let cn=!la(s),bi=null;function jt(){bi&&(bi.classList.remove("vis-row-selected"),bi=null)}cn&&Oxt(s,jt);function gn(Pe,ke,dt){let Ye=Pm(s);bi=Pe,Pe.classList.add("vis-row-selected");let ct={type:"select_layer",layer:ke,use_dbu:s.showDbu};dt&&(ct.chiplet=dt),s.websocketManager.request(ct).then(Ze=>{Y1(s,Ye)&&(s.updateInspector&&s.updateInspector(Ze),s.focusComponent&&s.focusComponent("Inspector"),s.refreshOverlay&&s.refreshOverlay())}).catch(Ze=>{console.error("select_layer failed:",Ze),Y1(s,Ye)&&jt()})}function Un(Pe,ke=!1){let dt=at.get(Pe.id);if(!Pe.children||Pe.children.length===0){let Ye=document.createElement("div");Ye.className=cn?"vis-leaf vis-leaf-selectable":"vis-leaf";let ct=document.createElement("span");ct.className="vis-arrow",ct.style.visibility="hidden",ct.textContent="\u25B6",Ye.appendChild(ct);let Ze=Pe.data.colorIndex,Ke=Pe.data.name,gt=CO(),qn=document.createElement("span");qn.className="layer-color";let xi=Pe.data.color||c.layer_colors&&c.layer_colors[Ze]||b3t[Ze%b3t.length];qn.style.backgroundColor=`rgb(${xi[0]},${xi[1]},${xi[2]})`,gt.appendChild(qn),gt.appendChild(document.createTextNode(Ke)),Ye.appendChild(gt),cn&>.addEventListener("click",()=>{gn(Ye,Ke,Pe.data.ownerChipletPath)});let Bi=document.createElement("input");if(Bi.type="checkbox",Bi.className="vis-cb",Bi.title="Visible",Bi.checked=Pe.checked,Pe.cb=Bi,Bi.addEventListener("change",()=>{st.check(Pe.id,Bi.checked)}),Ye.appendChild(Bi),dt){let xn=document.createElement("input");xn.type="checkbox",xn.className="vis-sel-cb",xn.title="Selectable",xn.checked=dt.checked,dt.selCb=xn,xn.addEventListener("change",()=>{at.check(Pe.id,xn.checked)}),Ye.appendChild(xn)}else Ye.appendChild(ET());return Ye.addEventListener("contextmenu",xn=>{xn.preventDefault(),xn.stopPropagation(),Qe.innerHTML="";for(let Zn of wn)fn(Zn.label,()=>ot(Zn.fn(Ze)));let Je=document.createElement("div");Je.className="context-menu-separator",Je.style.borderTop="1px solid #555",Je.style.margin="4px 0",Qe.appendChild(Je);let ti=s.layerPatterns[Ke]??1;for(let Zn of se){let rr=ti===Zn.value?"\u25CF ":" ";fn(rr+"Fill: "+Zn.label,()=>te(Ke,Zn.value))}Qe.style.left=xn.clientX+"px",Qe.style.top=xn.clientY+"px",Qe.style.display="block"}),Ye}else{let Ye=document.createElement("div");Ye.className="vis-group";let{header:ct,arrow:Ze,name:Ke}=sk();Ke.textContent=ke?"Layers":Pe.data.name||"Group";let gt=document.createElement("input");if(gt.type="checkbox",gt.className="vis-cb",gt.title="Visible",gt.checked=Pe.checked,gt.indeterminate=Pe.indeterminate,Pe.cb=gt,gt.addEventListener("change",()=>{st.check(Pe.id,gt.checked)}),ct.appendChild(gt),dt){let xi=document.createElement("input");xi.type="checkbox",xi.className="vis-sel-cb",xi.title="Selectable",xi.checked=dt.checked,xi.indeterminate=dt.indeterminate,dt.selCb=xi,xi.addEventListener("change",()=>{at.check(Pe.id,xi.checked)}),ct.appendChild(xi)}else ct.appendChild(ET());Ye.appendChild(ct);let qn=document.createElement("div");qn.className="vis-group-children";for(let xi of Pe.children)qn.appendChild(Un(xi,!1));return Ye.appendChild(qn),ok(ct,Ze,qn,!!(Pe.data&&Pe.data.startCollapsed)),Ye}}let Zi=st.roots[0]||st.get("layers_parent"),Hi=Un(Zi,!0);s.displayControlsEl.appendChild(Hi),Ne();let yr=c&&Array.isArray(c.chiplets)?c.chiplets:[];if(yr.length>1){let qn=function(Me,et){let ht=gt.get(Me);ht&&(st.cascadeQuiet(ht.id,et),st.onChange())},rr=function(Me){let et=Me.data;if(Me!==ti){let ht=document.createElement("div");ht.className="vis-leaf",ht.style.paddingLeft=8*(et.depth-1)+"px",ht.title=et.path+(et.master?` (${et.master})`:""),ht.appendChild(CO(et.name));let on=document.createElement("input");on.type="checkbox",on.className="vis-cb",on.checked=Me.checked,on.indeterminate=Me.indeterminate,Me.cb=on,on.addEventListener("change",()=>{O.check(Me.id,on.checked),qn(et.path,on.checked)}),ht.appendChild(on),ht.appendChild(ET()),Zn.appendChild(ht)}Me.children&&Me.children.forEach(rr)},Pe=c&&c.block_name||"",ke=Pe!=="",dt={};if(ke)try{let Me=pf("or_hidden_chiplets");if(Me){let et=JSON.parse(decodeURIComponent(Me));et&&typeof et=="object"&&!Array.isArray(et)&&(dt=et)}}catch{}let Ye=new Set(Array.isArray(dt[Pe])?dt[Pe]:[]),ct=Udn(yr,Ye),Ze=ct.findIndex(Me=>Me.parentId===null),Ke=Ze>=0?ct[Ze].id:null;if(Ze>=0&&(ct[Ze].hasCheckbox=!0),s.visibleChiplets=new Set(yr.filter(Me=>!Ye.has(Me.path)).map(Me=>Me.path)),O=new Lv(()=>{let Me=new Set;if(O.forEach(et=>{et.cb&&(et.cb.checked=et.checked,et.cb.indeterminate=et.indeterminate),et.data&&et.data.path&&(et.checked||et.indeterminate)&&Me.add(et.data.path)}),s.visibleChiplets=Me,ke){let et=yr.filter(on=>!Me.has(on.path)).map(on=>on.path),ht={};try{let on=pf("or_hidden_chiplets");if(on){let Ri=JSON.parse(decodeURIComponent(on));Ri&&typeof Ri=="object"&&!Array.isArray(Ri)&&(ht=Ri)}}catch{}et.length===0?delete ht[Pe]:ht[Pe]=et,Ff("or_hidden_chiplets",encodeURIComponent(JSON.stringify(ht)))}u()}),O.buildFromNodes(ct),typeof console<"u"&&console.warn){let Me=new Set;st.forEach(ht=>{ht.data&&ht.data.chipletPath&&Me.add(ht.data.chipletPath)});let et=new Set;O.forEach(ht=>{ht.data&&ht.data.path&&et.add(ht.data.path)});for(let ht of et)Me.has(ht)||console.warn(`[display-controls] chiplet "${ht}" missing from layer_hierarchy \u2014 Layers/Chiplets sync may drift`);for(let ht of Me)et.has(ht)||console.warn(`[display-controls] layer hierarchy node "${ht}" has no matching chiplet \u2014 Layers/Chiplets sync may drift`)}let gt=new Map;st.forEach(Me=>{Me.data&&Me.data.chipletPath&>.set(Me.data.chipletPath,Me)});{let Me={};if(st.forEach(et=>{if(!et.data||!et.data.chipletPath)return;let ht=et.data.chipletPath;Ye.has(ht)||O.get(ht)&&(Me[ht]={checked:et.checked,indeterminate:et.indeterminate})}),Object.keys(Me).length>0){O.mirrorStatesQuiet(Me);let et=new Set;O.forEach(ht=>{ht.data&&ht.data.path&&(ht.checked||ht.indeterminate)&&et.add(ht.data.path)}),s.visibleChiplets=et}}let xi=document.createElement("div");xi.className="vis-group";let{header:Bi,arrow:xn,name:Je}=sk();Je.textContent="Chiplets";let ti=Ke!=null?O.get(Ke):null;if(ti){let Me=document.createElement("input");Me.type="checkbox",Me.className="vis-cb",Me.checked=ti.checked,Me.indeterminate=ti.indeterminate,ti.cb=Me,Me.addEventListener("change",et=>{et.stopPropagation(),O.check(Ke,Me.checked),ti.data&&ti.data.path&&qn(ti.data.path,Me.checked)}),Bi.appendChild(Me)}Bi.appendChild(ET()),xi.appendChild(Bi);let Zn=document.createElement("div");Zn.className="vis-group-children",O.roots.forEach(rr),xi.appendChild(Zn),ok(Bi,xn,Zn,!1),s.displayControlsEl.appendChild(xi)}else s.visibleChiplets=null;let Tr=!!n.debug_renderers,Ei=new tde(n,r,()=>{u(),!!n.debug_renderers!==Tr&&(Tr=!!n.debug_renderers,s.refreshRendererControls&&s.refreshRendererControls())});Ei.add({label:"Nets",addSelectable:!0,children:[{key:"net_signal",label:"Signal"},{key:"net_power",label:"Power"},{key:"net_ground",label:"Ground"},{key:"net_clock",label:"Clock"},{key:"net_reset",label:"Reset"},{key:"net_tieoff",label:"Tie off"},{key:"net_scan",label:"Scan"},{key:"net_analog",label:"Analog"}]}),Ei.add({label:"Instances",addSelectable:!0,children:[{label:"Std Cells",visKey:"stdcells",disabled:!s.hasLiberty,children:[{label:"Bufs/Invs",children:[{key:"std_bufinv_timing",label:"Timing opt."},{key:"std_bufinv",label:"Netlist"}]},{key:"std_combinational",label:"Combinational"},{key:"std_sequential",label:"Sequential"},{label:"Clock tree",children:[{key:"std_clock_bufinv",label:"Buffer/Inverter"},{key:"std_clock_gate",label:"Clock gate"}]},{key:"std_level_shift",label:"Level shifter"}]},{key:"macros",label:"Macros"},{label:"Pads",children:[{key:"pad_input",label:"Input"},{key:"pad_output",label:"Output"},{key:"pad_inout",label:"Inout"},{key:"pad_power",label:"Power"},{key:"pad_spacer",label:"Spacer"},{key:"pad_areaio",label:"Area IO"},{key:"pad_other",label:"Other"}]},{label:"Physical",children:[{key:"phys_fill",label:"Fill"},{key:"phys_endcap",label:"Endcap"},{key:"phys_welltap",label:"Welltap"},{key:"phys_tie",label:"Tie Hi/Lo"},{key:"phys_antenna",label:"Antenna"},{key:"phys_cover",label:"Cover"},{key:"phys_bump",label:"Bump"},{key:"phys_other",label:"Other"}]}]}),Ei.add({label:"Blockages",addSelectable:!0,children:[{key:"placement_blockages",label:"Placement"},{key:"routing_obstructions",label:"Routing"}]}),c.sites&&c.sites.length>0&&Ei.add({label:"Rows",visKey:"rows",addSelectable:!0,children:c.sites.map(Pe=>({key:"site_"+Pe,label:Pe}))}),Ei.add({label:"Tracks",children:[{key:"tracks_pref",label:"Pref"},{key:"tracks_non_pref",label:"Non Pref"}]}),Ei.add({label:"Shapes",children:[{label:"Routing",visKey:"routing",children:[{key:"routing_segments",label:"Segments"},{key:"routing_vias",label:"Vias"}]},{label:"Special Routing",visKey:"special_nets",children:[{key:"srouting_segments",label:"Segments"},{key:"srouting_vias",label:"Vias"}]},{key:"pins",label:"Pins",selectable:!0},{key:"pin_names",label:"Pin Names",disabledBy:"pins"},{key:"fills",label:"Fills"}]}),Ei.add({label:"Misc",children:[{label:"Instances",children:[{key:"inst_names",label:"Names"},{key:"inst_pins",label:"Pins",selectable:!0},{key:"inst_pin_names",label:"Pin Names",disabledBy:"inst_pins"},{key:"blockages",label:"Blockages"}]},{key:"detailed",label:"Detailed view"},{key:"rulers",label:"Rulers"},{key:"labels",label:"Labels"},{key:"scale_bar",label:"Scale bar"},{key:"access_points",label:"Access Points"},{key:"regions",label:"Regions"},{key:"mfg_grid",label:"Manufacturing grid"},{key:"gcell_grid",label:"GCell grid"},{key:"flywires_only",label:"Flywires only"},{key:"focused_nets_guides",label:"Focused nets guides"},{key:"highlight_selected",label:"Highlight selected"}]}),Ei.add({key:"module_view",label:"Module view"}),Ei.add({label:"Debug Graphics",children:[{key:"debug_renderers",label:"Renderers"},{key:"debug_live",label:"Live (don't require pause)",disabledBy:"debug_renderers"},{key:"debug",label:"Tiles"}]}),Ei.render(s.displayControlsEl);let xr=document.createElement("div");xr.className="renderer-controls",s.displayControlsEl.appendChild(xr);function oe(Pe){return Promise.all(Pe.map(({path:ke,value:dt})=>s.websocketManager.request({type:"set_renderer_control",path:ke,value:dt}))).catch(()=>{})}function de(Pe){xr.innerHTML="";let ke=new Map;for(let dt of Pe||[]){let Ye=dt.group||"";ke.has(Ye)||ke.set(Ye,[]),ke.get(Ye).push(dt)}for(let[dt,Ye]of ke){let ct=xr;if(dt){let Ze=document.createElement("div");Ze.className="vis-group";let{header:Ke,arrow:gt,name:qn}=sk();qn.textContent=dt;let xi=document.createElement("input");xi.type="checkbox",xi.className="vis-cb",xi.title="Visible";let Bi=Ye.filter(Je=>Je.visible).length;xi.checked=Bi===Ye.length,xi.indeterminate=Bi>0&&Bi{let Je=xi.checked;oe(Ye.filter(ti=>!!ti.visible!==Je).map(ti=>({path:ti.path,value:Je})))}),Ke.appendChild(xi),Ke.appendChild(ET()),Ze.appendChild(Ke);let xn=document.createElement("div");xn.className="vis-group-children",Ze.appendChild(xn),ok(Ke,gt,xn,!1),xr.appendChild(Ze),ct=xn}for(let Ze of Ye){let Ke=document.createElement("div");Ke.className="vis-leaf";let gt=document.createElement("span");gt.className="vis-arrow",gt.style.visibility="hidden",gt.textContent="\u25B6",Ke.appendChild(gt),Ke.appendChild(CO(Ze.name));let qn=document.createElement("input");qn.type="checkbox",qn.className="vis-cb",qn.title="Visible",qn.checked=!!Ze.visible,qn.addEventListener("change",()=>oe([{path:Ze.path,value:qn.checked}])),Ke.appendChild(qn),Ke.appendChild(ET()),ct.appendChild(Ke)}}}s.refreshRendererControls=function(){return!s.websocketManager||la(s)||!n.debug_renderers?(xr.innerHTML="",Promise.resolve()):s.websocketManager.request({type:"renderer_controls"}).then(Pe=>de(Pe.controls)).catch(()=>{})},s.refreshRendererControls();let it=document.createElement("div");it.className="bg-color-row";let We=document.createElement("span");We.textContent="Background";let _n=document.createElement("input");_n.type="color",_n.className="bg-color-input",_n.title="Layout background color";let Er=pf("or_bg_color");_n.value=SO(Er)?Er:q5e(),_n.addEventListener("input",()=>{document.documentElement.style.setProperty("--bg-map",_n.value)}),_n.addEventListener("change",()=>{t3t(_n.value,s)});let qi=document.createElement("button");qi.className="bg-color-reset",qi.textContent="Reset",qi.title="Reset background to the theme default",qi.addEventListener("click",()=>{n3t(s),_n.value=q5e()}),it.appendChild(We),it.appendChild(_n),it.appendChild(qi),!s.heatMapLayer&&d&&(s.heatMapLayer=d());let Te=document.createElement("div");Te.className="vis-group heatmap-controls",s.displayControlsEl.appendChild(Te);let{header:ve,arrow:_t,name:mn}=sk("vis-group-header heatmap-header");mn.textContent="Heat Maps",Te.appendChild(ve);let yn=document.createElement("div");yn.className="vis-group-children heatmap-group-children",Te.appendChild(yn),ok(ve,_t,yn,!0),s.displayControlsEl.appendChild(it);function Sn(Pe,ke,dt,Ye){let ct=document.createElement("label");ct.className="heatmap-setting";let Ze=document.createElement("input");Ze.type="checkbox",Ze.checked=dt,Ze.addEventListener("change",()=>Ye(Ze.checked)),ct.appendChild(Ze),ct.appendChild(document.createTextNode(ke)),Pe.appendChild(ct)}function yi(Pe,ke,dt,Ye,ct){let Ze=document.createElement("label");Ze.className="heatmap-setting";let Ke=document.createElement("span");Ke.textContent=ke;let gt=document.createElement("input");gt.type="number",gt.value=String(dt),gt.step=String(Ye||1),gt.addEventListener("change",()=>ct(parseFloat(gt.value))),Ze.appendChild(Ke),Ze.appendChild(gt),Pe.appendChild(Ze)}function hi(Pe,ke,dt,Ye,ct){let Ze=document.createElement("label");Ze.className="heatmap-setting";let Ke=document.createElement("span");Ke.textContent=ke;let gt=document.createElement("select");for(let qn of Ye){let xi=document.createElement("option");xi.value=qn,xi.textContent=qn,qn===dt&&(xi.selected=!0),gt.appendChild(xi)}gt.addEventListener("change",()=>ct(gt.value)),Ze.appendChild(Ke),Ze.appendChild(gt),Pe.appendChild(Ze)}function ri(Pe){s.websocketManager.request(Pe).then(ke=>{s.updateHeatMaps&&s.updateHeatMaps(ke)}).catch(ke=>console.error("Heat map update failed",ke))}function Ge(Pe){if(!s.heatMapLegendEl)return;let ke=s.heatMapLegendEl;if(ke.innerHTML="",!Pe||!Pe.show_legend||!Pe.legend||Pe.legend.length===0){ke.classList.add("hidden");return}let dt=document.createElement("div");dt.className="heatmap-map-legend-title",dt.textContent=Pe.title,ke.appendChild(dt);let Ye=document.createElement("div");Ye.className="heatmap-map-legend-units",Ye.textContent=Pe.units||"",ke.appendChild(Ye);let ct=document.createElement("div");ct.className="heatmap-map-legend-list";for(let Ze of Pe.legend){let Ke=document.createElement("div");Ke.className="heatmap-legend-row";let gt=document.createElement("span");gt.className="heatmap-legend-swatch",gt.style.backgroundColor=`rgba(${Ze.color[0]}, ${Ze.color[1]}, ${Ze.color[2]}, ${Ze.color[3]/255})`;let qn=document.createElement("span");qn.textContent=Ze.value,Ke.appendChild(gt),Ke.appendChild(qn),ct.appendChild(Ke)}ke.appendChild(ct),ke.classList.remove("hidden")}s.renderHeatMapControls=Pe=>{yn.innerHTML="";let ke=document.createElement("div");ke.className="heatmap-list",yn.appendChild(ke);let dt=document.createElement("label");dt.className="heatmap-setting";let Ye=document.createElement("input");Ye.type="radio",Ye.name="active-heatmap",Ye.checked=!Pe.active,Ye.addEventListener("change",()=>{ri({type:"set_active_heatmap",name:""})}),dt.appendChild(Ye),dt.appendChild(document.createTextNode("Off")),ke.appendChild(dt);for(let gt of Pe.heatmaps||[]){let qn=document.createElement("label");qn.className="heatmap-setting";let xi=document.createElement("input");xi.type="radio",xi.name="active-heatmap",xi.checked=gt.name===Pe.active,xi.addEventListener("change",()=>{ri({type:"set_active_heatmap",name:gt.name})}),qn.appendChild(xi),qn.appendChild(document.createTextNode(gt.title)),ke.appendChild(qn)}let ct=(Pe.heatmaps||[]).find(gt=>gt.name===Pe.active);if(Ge(ct),!ct)return;let Ze=document.createElement("div");Ze.className="heatmap-settings",yn.appendChild(Ze),yi(Ze,"Display min",ct.display_min,ct.display_range_increment,gt=>{ri({type:"set_heatmap",name:ct.name,option:"DisplayMin",value:gt})}),yi(Ze,"Display max",ct.display_max,ct.display_range_increment,gt=>{ri({type:"set_heatmap",name:ct.name,option:"DisplayMax",value:gt})}),Sn(Ze,"Show below min",ct.draw_below_min,gt=>{ri({type:"set_heatmap",name:ct.name,option:"ShowMin",value:gt})}),Sn(Ze,"Show above max",ct.draw_above_max,gt=>{ri({type:"set_heatmap",name:ct.name,option:"ShowMax",value:gt})}),Sn(Ze,"Log scale",ct.log_scale,gt=>{ri({type:"set_heatmap",name:ct.name,option:"LogScale",value:gt})}),Sn(Ze,"Reverse log",ct.reverse_log,gt=>{ri({type:"set_heatmap",name:ct.name,option:"ReverseLog",value:gt})}),ct.can_adjust_grid&&(yi(Ze,"Grid X",ct.grid_x,.1,gt=>{ri({type:"set_heatmap",name:ct.name,option:"GridX",value:gt})}),yi(Ze,"Grid Y",ct.grid_y,.1,gt=>{ri({type:"set_heatmap",name:ct.name,option:"GridY",value:gt})})),yi(Ze,"Alpha",ct.alpha,1,gt=>{ri({type:"set_heatmap",name:ct.name,option:"Alpha",value:gt})}),Sn(Ze,"Legend",ct.show_legend,gt=>{ri({type:"set_heatmap",name:ct.name,option:"ShowLegend",value:gt})}),ct.supports_numbers&&Sn(Ze,"Show numbers",ct.show_numbers,gt=>{ri({type:"set_heatmap",name:ct.name,option:"ShowNumbers",value:gt})});for(let gt of ct.options||[])gt.type==="bool"?Sn(Ze,gt.label,gt.value,qn=>{ri({type:"set_heatmap",name:ct.name,option:gt.name,value:qn})}):gt.type==="choice"&&hi(Ze,gt.label,gt.value,gt.choices||[],qn=>{ri({type:"set_heatmap",name:ct.name,option:gt.name,value:qn})});ct.selection_filter_label&&Sn(Ze,ct.selection_filter_label,ct.use_selected_only,gt=>{ri({type:"set_heatmap",name:ct.name,option:"use_selected_only",value:gt})});let Ke=document.createElement("button");Ke.className="or-btn or-btn-sm heatmap-rebuild",Ke.textContent="Rebuild data",Ke.addEventListener("click",()=>{ri({type:"set_heatmap",name:ct.name,option:"rebuild",value:1})}),Ze.appendChild(Ke)}}var v3t="search-nav-dialog",jdn=[{label:"Instance",value:"inst"},{label:"Net",value:"net"},{label:"Port",value:"port"}];function ide(s){if(!s.designScale)return;let n=jdn.map(T=>``).join(""),{overlay:r,close:c,okBtn:u,showError:d}=MO("Find Object",` + affected.
`,"Apply",p3t),_=u.querySelector(".opt-family"),x=u.querySelector(".opt-custom"),T=u.querySelector(".opt-scale"),M=u.querySelector(".opt-preview");function L(){M.style.fontFamily=x.value.trim()||_.value,M.style.fontSize=`calc(13px * ${rH(T.value)/100})`}for(let D of[_,x,T])D.addEventListener("input",L);L();function I(){let D=T.value.trim(),F=Number(D);if(D===""||!Number.isFinite(F)){w("Size must be a number.");return}if(Fede){w(`Size must be between ${Qhe} and ${ede} %.`);return}s.setAppFont({family:x.value.trim()||_.value,scale:F}),d()}b.addEventListener("click",I);for(let D of[x,T])D.addEventListener("keydown",F=>{F.key==="Enter"&&(F.preventDefault(),I())});return{close:d}}function Q5e(s){return String(s).replace(/&/g,"&").replace(/"/g,""").replace(//g,">")}var Udn='',zdn='';function CO(s){let n=document.createElement("span");return n.className="vis-name",s!=null&&(n.textContent=s),n}function ST(){let s=document.createElement("span");return s.className="vis-sel-cb vis-sel-spacer",s}function b3t(){let s=document.createElement("div");s.className="display-controls-header",s.appendChild(CO(""));for(let[n,r]of[[Udn,"Visible"],[zdn,"Selectable"]]){let c=document.createElement("span");c.className="vis-header-icon",c.title=r,c.innerHTML=n,s.appendChild(c)}return s}var tde=class{constructor(n,r,c){this.visibility=n,this.selectability=r,this.onChange=c;let u=()=>{this._syncAll(),this.onChange()};this.model=new Rv(u),this.selModel=new Rv(u)}add(n){return this.model.addFromSpec(this._enrichSpec(n,"")),this.selModel.addFromSpec(this._enrichSelSpec(n,"",!1)),this}render(n){for(let r of this.model.roots)n.appendChild(this._dom(r));this._syncAll()}_nodeId(n,r){let c=n.key||n.label;return r?r+"/"+c:c}_enrichSpec(n,r){let c=this._nodeId(n,r),u={id:c,data:n};return n.children?u.children=n.children.map(d=>this._enrichSpec(d,c)):n.key&&(u.checked=!!this.visibility[n.key]),n.disabled!=null&&(u.disabled=n.disabled),u}_enrichSelSpec(n,r,c){let u=n.addSelectable===!0?!0:n.addSelectable===!1?!1:c,d=this._nodeId(n,r),b={id:d,data:n,hasCheckbox:!1};if(n.children){b.children=n.children.map(_=>this._enrichSelSpec(_,d,u));let w=_=>_.some(x=>x.hasCheckbox||x.children&&w(x.children));b.hasCheckbox=w(b.children),b.hasCheckbox&&(b.checked=!0)}else if(n.key){let w=n.selectable===!0||n.selectable!==!1&&c;b.hasCheckbox=w,w&&(b.checked=this.selectability[n.key]!==!1)}return b}_syncAll(){this.model.forEach(n=>{n.cb&&(n.cb.checked=n.checked,n.cb.indeterminate=n.indeterminate);let r=n.data;r.key&&(this.visibility[r.key]=n.checked),r.visKey&&(this.visibility[r.visKey]=n.checked||n.indeterminate)}),this.selModel.forEach(n=>{if(!n.hasCheckbox)return;let r=n.data;if(r.key&&(this.selectability[r.key]=n.checked),!n.selCb)return;n.selCb.checked=n.checked,n.selCb.indeterminate=n.indeterminate;let c=this.model.get(n.id),u=c&&!c.checked&&!c.indeterminate;n.selCb.disabled=u,n.selLabel&&n.selLabel.classList.toggle("vis-sel-disabled",u)}),this.model.forEach(n=>{let r=n.data;if(r.disabledBy&&n.el){let c=!this.visibility[r.disabledBy];n.el.classList.toggle("disabled",c)}})}_buildSelCheckbox(n){let r=this.selModel.get(n.id);if(!r||!r.hasCheckbox)return null;let c=document.createElement("input");return c.type="checkbox",c.className="vis-sel-cb",c.title="Selectable",c.addEventListener("change",()=>{this.selModel.check(r.id,c.checked)}),r.selCb=c,c}_dom(n){let r=n.data,c=document.createElement("input");c.type="checkbox",c.className="vis-cb",c.title="Visible",n.cb=c,c.addEventListener("change",()=>this.model.check(n.id,c.checked));let u=this._buildSelCheckbox(n),d=M=>{if(M.appendChild(c),u){M.appendChild(u);let L=this.selModel.get(n.id);L&&(L.selLabel=M)}else M.appendChild(ST())};if(!n.children.length){let M=document.createElement("div");M.className="vis-leaf";let L=document.createElement("span");return L.className="vis-arrow",L.style.visibility="hidden",L.textContent="\u25B6",M.appendChild(L),M.appendChild(CO(r.label)),d(M),n.el=M,M}let b=document.createElement("div");b.className="vis-group";let{header:w,arrow:_,name:x}=sk();x.textContent=r.label,d(w),b.appendChild(w);let T=document.createElement("div");T.className="vis-group-children",r.disabled&&T.classList.add("disabled");for(let M of n.children)T.appendChild(this._dom(M));return b.appendChild(T),ok(w,_,T,!0),b}};function sH(s,n,r,c){let u=new Set,d=Math.max(0,s-n),b=Math.min(c-1,s+r);for(let w=d;w<=b;w++)u.add(w);return u}function Gdn(s){let n={};for(let[r,c]of Object.entries(s||{}))c!==1&&(n[r]=c);return n}function nde(s,n){return(s||[]).some(r=>r.every(c=>!!n[c]))}function jdn(s,n){return s.map(r=>{let c=!n.has(r.path);return{id:r.path,parentId:r.parent!=null?r.parent:null,hasCheckbox:r.parent!=null,checked:c,data:{path:r.path,name:r.name,master:r.master,depth:r.depth}}})}var $dn=3,w3t=[[70,130,210],[200,50,50],[50,180,80],[200,160,40],[160,60,200],[40,190,190],[220,120,50],[180,70,150]];function Vdn(s){return!s.forceComposite||ua(s)?0:s.groupLayers||Txt}function v3t(s,n,r,c,u,d){if(!s.displayControlsEl)return;s.displayControlsEl.innerHTML="",s.displayControlsEl.appendChild(b3t());for(let Ae of s.allLayers||[])Ae.remove();s.allLayers=[],s.baseSlot=null,s.topSlot=null;let b=new Set;function w(){for(let Ae of b)Ae.refresh();b.clear()}function _(){s.baseSlot&&b.add(s.baseSlot)}function x(Ae){return{layer:Ae,opacity:1,visible:!1}}function T(Ae,Le){wxt(Ae,Le)&&_()}function M(Ae,Le,ht){let Ye={layer:Ae,opacity:1,visible:!!ht};return Le&&(s[Le]=Ye),Ye}let L=[M("_instances",null,!0),M("_pins","pinsLayer",n.pins),M("_modules","modulesLayer",n.module_view)],I=[];s.overlayLayers=(c&&c.overlays||[]).map(Ae=>({def:Ae,layer:M(Ae.name,null,nde(Ae.shown_by,n)),under:Ae.z_index<$dn}));for(let{layer:Ae,under:Le}of[...s.overlayLayers].sort((ht,Ye)=>ht.def.z_index-Ye.def.z_index))(Le?L:I).push(Ae);let D=[],F=[],O=null,z=new Set,Z=new Set;try{let Ae=window.sessionStorage.getItem("or_hidden_layers");Ae&&(z=new Set(JSON.parse(Ae)))}catch{}try{let Ae=window.sessionStorage.getItem("or_nonselectable_layers");Ae&&(Z=new Set(JSON.parse(Ae)))}catch{}try{let Ae=window.sessionStorage.getItem("or_layer_patterns");Ae&&Object.assign(s.layerPatterns,JSON.parse(Ae))}catch{}function H(){try{window.sessionStorage.setItem("or_layer_patterns",JSON.stringify(Gdn(s.layerPatterns)))}catch{}}function te(Ae,Le){Le===1?delete s.layerPatterns[Ae]:s.layerPatterns[Ae]=Le,H(),_(),w()}let oe=[{label:"Solid",value:1},{label:"Diagonal",value:2},{label:"Cross",value:3},{label:"Dots",value:4},{label:"None (no fill)",value:0}],ne=0;function ue(Ae,Le="layers",ht=void 0){let Ye=[],ct=Ae.type==="category"?ht:Ae.path,Ze=Ae.flipped===!0,Ke=Ae.instances||[],pt=Ke.filter(ei=>ei.type!=="category"),Xn=Ke.filter(ei=>ei.type==="category"),_i=Ae.layers||[],Hi=ne;ne+=_i.length;function _n(ei,ar){let yn=ei.map((Re,nt)=>nt);ar&&yn.reverse(),yn.forEach(Re=>{let nt=ei[Re],kt=Le+"/"+(nt.name||Re);Ye.push(ue(nt,kt,ct))})}function Je(){(Ze?_i.map((ar,yn)=>yn).reverse():_i.map((ar,yn)=>yn)).forEach(ar=>{let yn=_i[ar],Re=yn.name||yn,nt=Hi+ar,kt=x(Re),xn=`${Le}/${Re}`,Ei=!z.has(xn);Ei&&(T(kt,!0),s.visibleLayers.add(xn),s.visibleLayerNames.add(Re)),D.push(kt),F.push(xn),Ye.push({id:xn,data:{name:Re,layer:kt,color:yn.color,colorIndex:nt,nodeId:xn,ownerChipletPath:ct},checked:Ei})})}_n(pt,!1),Ze&&Je(),_n(Xn,Ze),Ze||Je();let Qn={name:Ae.name,isInstance:!0};return Ae.type==="category"&&(Ae.name==="Implant"||Ae.name==="Other")&&(Qn.startCollapsed=!0),Ae.type!=="category"&&(Qn.chipletPath=Ae.path),{id:Le,data:Qn,children:Ye}}let Te;c.layer_hierarchy?Te=ue(c.layer_hierarchy,"layers_parent"):Te={id:"layers_parent",children:c.layers.map((Ae,Le)=>{let ht=x(Ae),Ye=`layers_parent/${Ae}`,ct=!z.has(Ye);return ct&&(T(ht,!0),s.visibleLayers.add(Ye),s.visibleLayerNames.add(Ae)),D.push(ht),F.push(Ye),{id:Ye,data:{name:Ae,layer:ht,colorIndex:Le,nodeId:Ye},checked:ct}})};function Q(Ae,Le,ht){let Ye=s.view.addTileSlot(Ae,{order:Le,source:Cxt({wm:s.websocketManager,ctx:s.tileCtx,getItems:()=>ht,dpr:xO,tileSize:Fb,isDoubleBuffer:()=>s.doubleBuffer,groupLayers:()=>Vdn(s)})});return Ye.items=ht,Ye}s.baseSlot=Q("base",bp.base,[...L,...D]),s.topSlot=Q("top",bp.top,I),s.allLayers=[s.baseSlot,s.topSlot];function ge(Ae){if(!Ae.children||Ae.children.length===0){let Le=Ae.data&&Ae.data.name,ht=Le?!Z.has(Le):!0;return ht&&Le&&s.selectableLayers.add(Le),{id:Ae.id,data:{name:Le},checked:ht}}return{id:Ae.id,data:{name:Ae.data&&Ae.data.name},children:Ae.children.map(ge)}}let Qe=ge(Te),st=new Rv(()=>{s.visibleLayerNames.clear();let Ae=[],Le={},ht=!1,Ye=!1,ct=O&&s.visibleChiplets instanceof Set;if(st.forEach(Ke=>{if(Ke.cb&&(Ke.cb.checked=Ke.checked,Ke.cb.indeterminate=Ke.indeterminate),Ke.data&&Ke.data.layer){let pt=Ke.data.nodeId||Ke.data.name;Ae.push(pt),T(Ke.data.layer,Ke.checked),Ke.checked?(s.visibleLayers.add(pt),s.visibleLayerNames.add(Ke.data.name)):s.visibleLayers.delete(pt)}if(ct&&Ke.data&&Ke.data.chipletPath){let pt=Ke.data.chipletPath,Xn=O.get(pt);if(Xn){let _i=Ke.checked||Ke.indeterminate,Hi={checked:Ke.checked,indeterminate:Ke.indeterminate};(Xn.checked!==Ke.checked||Xn.indeterminate!==Ke.indeterminate)&&(Le[pt]=Hi,ht=!0),s.visibleChiplets.has(pt)!==_i&&(Ye=!0)}}}),s.baseSlot&&b.has(s.baseSlot))for(let{def:Ke,under:pt}of s.overlayLayers)nde(Ke.layers_by,n)&&b.add(pt?s.baseSlot:s.topSlot);w(),Ne();let Ze=Ae.filter(Ke=>!s.visibleLayers.has(Ke));try{window.sessionStorage.setItem("or_hidden_layers",JSON.stringify(Ze))}catch{}s.syncDisplayState(),Ye?O.mirrorStates(Le):ht&&(O.mirrorStatesQuiet(Le),O.forEach(Ke=>{Ke.cb&&(Ke.cb.checked=Ke.checked,Ke.cb.indeterminate=Ke.indeterminate)}))});s.layerModel=st,st.addFromSpec(Te);let at=new Rv(()=>{s.selectableLayers.clear(),at.forEach(Le=>{Le.checked&&Le.data&&Le.data.name&&s.selectableLayers.add(Le.data.name)}),Ne();let Ae=c.layers.filter(Le=>!s.selectableLayers.has(Le));try{window.sessionStorage.setItem("or_nonselectable_layers",JSON.stringify(Ae))}catch{}s.syncDisplayState()});at.addFromSpec(Qe);function Ne(){at.forEach(Ae=>{if(!Ae.selCb)return;Ae.selCb.checked=Ae.checked,Ae.selCb.indeterminate=Ae.indeterminate;let Le=st.get(Ae.id),ht=Le&&!Le.checked&&!Le.indeterminate;Ae.selCb.disabled=ht})}let tt=document.createElement("div");tt.className="context-menu",tt.style.display="none",document.body.appendChild(tt);function ot(Ae){let Le={};F.forEach((ht,Ye)=>{ht&&(Le[ht]=Ae.has(Ye))}),st.checkSet(Le)}function Tt(){tt.style.display="none"}function jt(Ae,Le){let ht=document.createElement("div");ht.className="context-menu-item",ht.textContent=Ae,ht.addEventListener("click",()=>{Le(),Tt()}),tt.appendChild(ht)}let en=D.length,mn=[{label:"Show only this layer",fn:Ae=>sH(Ae,0,0,en)},{label:"Show layer range \u2195",fn:Ae=>sH(Ae,1,1,en)},{label:"Show layer range \u2195\u2195",fn:Ae=>sH(Ae,2,2,en)},{label:"Show layer range \u2193",fn:Ae=>sH(Ae,1,0,en)},{label:"Show layer range \u2191",fn:Ae=>sH(Ae,0,1,en)}];document.addEventListener("click",Ae=>{tt.contains(Ae.target)||Tt()}),document.addEventListener("keydown",Ae=>{Ae.key==="Escape"&&Tt()});let cn=!ua(s),bi=null;function Vt(){bi&&(bi.classList.remove("vis-row-selected"),bi=null)}cn&&Nxt(s,Vt);function pn(Ae,Le,ht){let Ye=Pm(s);bi=Ae,Ae.classList.add("vis-row-selected");let ct={type:"select_layer",layer:Le,use_dbu:s.showDbu};ht&&(ct.chiplet=ht),s.websocketManager.request(ct).then(Ze=>{Z1(s,Ye)&&(s.updateInspector&&s.updateInspector(Ze),s.focusComponent&&s.focusComponent("Inspector"),s.refreshOverlay&&s.refreshOverlay())}).catch(Ze=>{console.error("select_layer failed:",Ze),Z1(s,Ye)&&Vt()})}function qn(Ae,Le=!1){let ht=at.get(Ae.id);if(!Ae.children||Ae.children.length===0){let Ye=document.createElement("div");Ye.className=cn?"vis-leaf vis-leaf-selectable":"vis-leaf";let ct=document.createElement("span");ct.className="vis-arrow",ct.style.visibility="hidden",ct.textContent="\u25B6",Ye.appendChild(ct);let Ze=Ae.data.colorIndex,Ke=Ae.data.name,pt=CO(),Xn=document.createElement("span");Xn.className="layer-color";let _i=Ae.data.color||c.layer_colors&&c.layer_colors[Ze]||w3t[Ze%w3t.length];Xn.style.backgroundColor=`rgb(${_i[0]},${_i[1]},${_i[2]})`,pt.appendChild(Xn),pt.appendChild(document.createTextNode(Ke)),Ye.appendChild(pt),cn&&pt.addEventListener("click",()=>{pn(Ye,Ke,Ae.data.ownerChipletPath)});let Hi=document.createElement("input");if(Hi.type="checkbox",Hi.className="vis-cb",Hi.title="Visible",Hi.checked=Ae.checked,Ae.cb=Hi,Hi.addEventListener("change",()=>{st.check(Ae.id,Hi.checked)}),Ye.appendChild(Hi),ht){let _n=document.createElement("input");_n.type="checkbox",_n.className="vis-sel-cb",_n.title="Selectable",_n.checked=ht.checked,ht.selCb=_n,_n.addEventListener("change",()=>{at.check(Ae.id,_n.checked)}),Ye.appendChild(_n)}else Ye.appendChild(ST());return Ye.addEventListener("contextmenu",_n=>{_n.preventDefault(),_n.stopPropagation(),tt.innerHTML="";for(let ei of mn)jt(ei.label,()=>ot(ei.fn(Ze)));let Je=document.createElement("div");Je.className="context-menu-separator",Je.style.borderTop="1px solid #555",Je.style.margin="4px 0",tt.appendChild(Je);let Qn=s.layerPatterns[Ke]??1;for(let ei of oe){let ar=Qn===ei.value?"\u25CF ":" ";jt(ar+"Fill: "+ei.label,()=>te(Ke,ei.value))}tt.style.left=_n.clientX+"px",tt.style.top=_n.clientY+"px",tt.style.display="block"}),Ye}else{let Ye=document.createElement("div");Ye.className="vis-group";let{header:ct,arrow:Ze,name:Ke}=sk();Ke.textContent=Le?"Layers":Ae.data.name||"Group";let pt=document.createElement("input");if(pt.type="checkbox",pt.className="vis-cb",pt.title="Visible",pt.checked=Ae.checked,pt.indeterminate=Ae.indeterminate,Ae.cb=pt,pt.addEventListener("change",()=>{st.check(Ae.id,pt.checked)}),ct.appendChild(pt),ht){let _i=document.createElement("input");_i.type="checkbox",_i.className="vis-sel-cb",_i.title="Selectable",_i.checked=ht.checked,_i.indeterminate=ht.indeterminate,ht.selCb=_i,_i.addEventListener("change",()=>{at.check(Ae.id,_i.checked)}),ct.appendChild(_i)}else ct.appendChild(ST());Ye.appendChild(ct);let Xn=document.createElement("div");Xn.className="vis-group-children";for(let _i of Ae.children)Xn.appendChild(qn(_i,!1));return Ye.appendChild(Xn),ok(ct,Ze,Xn,!!(Ae.data&&Ae.data.startCollapsed)),Ye}}let Yi=st.roots[0]||st.get("layers_parent"),$i=qn(Yi,!0);s.displayControlsEl.appendChild($i),Ne();let Tr=c&&Array.isArray(c.chiplets)?c.chiplets:[];if(Tr.length>1){let Xn=function(yn,Re){let nt=pt.get(yn);nt&&(st.cascadeQuiet(nt.id,Re),st.onChange())},ar=function(yn){let Re=yn.data;if(yn!==Qn){let nt=document.createElement("div");nt.className="vis-leaf",nt.style.paddingLeft=8*(Re.depth-1)+"px",nt.title=Re.path+(Re.master?` (${Re.master})`:""),nt.appendChild(CO(Re.name));let kt=document.createElement("input");kt.type="checkbox",kt.className="vis-cb",kt.checked=yn.checked,kt.indeterminate=yn.indeterminate,yn.cb=kt,kt.addEventListener("change",()=>{O.check(yn.id,kt.checked),Xn(Re.path,kt.checked)}),nt.appendChild(kt),nt.appendChild(ST()),ei.appendChild(nt)}yn.children&&yn.children.forEach(ar)},Ae=c&&c.block_name||"",Le=Ae!=="",ht={};if(Le)try{let yn=ph("or_hidden_chiplets");if(yn){let Re=JSON.parse(decodeURIComponent(yn));Re&&typeof Re=="object"&&!Array.isArray(Re)&&(ht=Re)}}catch{}let Ye=new Set(Array.isArray(ht[Ae])?ht[Ae]:[]),ct=jdn(Tr,Ye),Ze=ct.findIndex(yn=>yn.parentId===null),Ke=Ze>=0?ct[Ze].id:null;if(Ze>=0&&(ct[Ze].hasCheckbox=!0),s.visibleChiplets=new Set(Tr.filter(yn=>!Ye.has(yn.path)).map(yn=>yn.path)),O=new Rv(()=>{let yn=new Set;if(O.forEach(Re=>{Re.cb&&(Re.cb.checked=Re.checked,Re.cb.indeterminate=Re.indeterminate),Re.data&&Re.data.path&&(Re.checked||Re.indeterminate)&&yn.add(Re.data.path)}),s.visibleChiplets=yn,Le){let Re=Tr.filter(kt=>!yn.has(kt.path)).map(kt=>kt.path),nt={};try{let kt=ph("or_hidden_chiplets");if(kt){let xn=JSON.parse(decodeURIComponent(kt));xn&&typeof xn=="object"&&!Array.isArray(xn)&&(nt=xn)}}catch{}Re.length===0?delete nt[Ae]:nt[Ae]=Re,Uf("or_hidden_chiplets",encodeURIComponent(JSON.stringify(nt)))}u()}),O.buildFromNodes(ct),typeof console<"u"&&console.warn){let yn=new Set;st.forEach(nt=>{nt.data&&nt.data.chipletPath&&yn.add(nt.data.chipletPath)});let Re=new Set;O.forEach(nt=>{nt.data&&nt.data.path&&Re.add(nt.data.path)});for(let nt of Re)yn.has(nt)||console.warn(`[display-controls] chiplet "${nt}" missing from layer_hierarchy \u2014 Layers/Chiplets sync may drift`);for(let nt of yn)Re.has(nt)||console.warn(`[display-controls] layer hierarchy node "${nt}" has no matching chiplet \u2014 Layers/Chiplets sync may drift`)}let pt=new Map;st.forEach(yn=>{yn.data&&yn.data.chipletPath&&pt.set(yn.data.chipletPath,yn)});{let yn={};if(st.forEach(Re=>{if(!Re.data||!Re.data.chipletPath)return;let nt=Re.data.chipletPath;Ye.has(nt)||O.get(nt)&&(yn[nt]={checked:Re.checked,indeterminate:Re.indeterminate})}),Object.keys(yn).length>0){O.mirrorStatesQuiet(yn);let Re=new Set;O.forEach(nt=>{nt.data&&nt.data.path&&(nt.checked||nt.indeterminate)&&Re.add(nt.data.path)}),s.visibleChiplets=Re}}let _i=document.createElement("div");_i.className="vis-group";let{header:Hi,arrow:_n,name:Je}=sk();Je.textContent="Chiplets";let Qn=Ke!=null?O.get(Ke):null;if(Qn){let yn=document.createElement("input");yn.type="checkbox",yn.className="vis-cb",yn.checked=Qn.checked,yn.indeterminate=Qn.indeterminate,Qn.cb=yn,yn.addEventListener("change",Re=>{Re.stopPropagation(),O.check(Ke,yn.checked),Qn.data&&Qn.data.path&&Xn(Qn.data.path,yn.checked)}),Hi.appendChild(yn)}Hi.appendChild(ST()),_i.appendChild(Hi);let ei=document.createElement("div");ei.className="vis-group-children",O.roots.forEach(ar),_i.appendChild(ei),ok(Hi,_n,ei,!1),s.displayControlsEl.appendChild(_i)}else s.visibleChiplets=null;let wr=!!n.debug_renderers,Si=new tde(n,r,()=>{u(),!!n.debug_renderers!==wr&&(wr=!!n.debug_renderers,s.refreshRendererControls&&s.refreshRendererControls())});Si.add({label:"Nets",addSelectable:!0,children:[{key:"net_signal",label:"Signal"},{key:"net_power",label:"Power"},{key:"net_ground",label:"Ground"},{key:"net_clock",label:"Clock"},{key:"net_reset",label:"Reset"},{key:"net_tieoff",label:"Tie off"},{key:"net_scan",label:"Scan"},{key:"net_analog",label:"Analog"}]}),Si.add({label:"Instances",addSelectable:!0,children:[{label:"Std Cells",visKey:"stdcells",disabled:!s.hasLiberty,children:[{label:"Bufs/Invs",children:[{key:"std_bufinv_timing",label:"Timing opt."},{key:"std_bufinv",label:"Netlist"}]},{key:"std_combinational",label:"Combinational"},{key:"std_sequential",label:"Sequential"},{label:"Clock tree",children:[{key:"std_clock_bufinv",label:"Buffer/Inverter"},{key:"std_clock_gate",label:"Clock gate"}]},{key:"std_level_shift",label:"Level shifter"}]},{key:"macros",label:"Macros"},{label:"Pads",children:[{key:"pad_input",label:"Input"},{key:"pad_output",label:"Output"},{key:"pad_inout",label:"Inout"},{key:"pad_power",label:"Power"},{key:"pad_spacer",label:"Spacer"},{key:"pad_areaio",label:"Area IO"},{key:"pad_other",label:"Other"}]},{label:"Physical",children:[{key:"phys_fill",label:"Fill"},{key:"phys_endcap",label:"Endcap"},{key:"phys_welltap",label:"Welltap"},{key:"phys_tie",label:"Tie Hi/Lo"},{key:"phys_antenna",label:"Antenna"},{key:"phys_cover",label:"Cover"},{key:"phys_bump",label:"Bump"},{key:"phys_other",label:"Other"}]}]}),Si.add({label:"Blockages",addSelectable:!0,children:[{key:"placement_blockages",label:"Placement"},{key:"routing_obstructions",label:"Routing"}]}),c.sites&&c.sites.length>0&&Si.add({label:"Rows",visKey:"rows",addSelectable:!0,children:c.sites.map(Ae=>({key:"site_"+Ae,label:Ae}))}),Si.add({label:"Tracks",children:[{key:"tracks_pref",label:"Pref"},{key:"tracks_non_pref",label:"Non Pref"}]}),Si.add({label:"Shapes",children:[{label:"Routing",visKey:"routing",children:[{key:"routing_segments",label:"Segments"},{key:"routing_vias",label:"Vias"}]},{label:"Special Routing",visKey:"special_nets",children:[{key:"srouting_segments",label:"Segments"},{key:"srouting_vias",label:"Vias"}]},{key:"pins",label:"Pins",selectable:!0},{key:"pin_names",label:"Pin Names",disabledBy:"pins"},{key:"fills",label:"Fills"}]}),Si.add({label:"Misc",children:[{label:"Instances",children:[{key:"inst_names",label:"Names"},{key:"inst_pins",label:"Pins",selectable:!0},{key:"inst_pin_names",label:"Pin Names",disabledBy:"inst_pins"},{key:"blockages",label:"Blockages"}]},{key:"detailed",label:"Detailed view"},{key:"rulers",label:"Rulers"},{key:"labels",label:"Labels"},{key:"scale_bar",label:"Scale bar"},{key:"access_points",label:"Access Points"},{key:"regions",label:"Regions"},{key:"mfg_grid",label:"Manufacturing grid"},{key:"gcell_grid",label:"GCell grid"},{key:"flywires_only",label:"Flywires only"},{key:"focused_nets_guides",label:"Focused nets guides"},{key:"highlight_selected",label:"Highlight selected"}]}),Si.add({key:"module_view",label:"Module view"}),Si.add({label:"Debug Graphics",children:[{key:"debug_renderers",label:"Renderers"},{key:"debug_live",label:"Live (don't require pause)",disabledBy:"debug_renderers"},{key:"debug",label:"Tiles"}]}),Si.render(s.displayControlsEl);let Fr=document.createElement("div");Fr.className="renderer-controls",s.displayControlsEl.appendChild(Fr);function se(Ae){return Promise.all(Ae.map(({path:Le,value:ht})=>s.websocketManager.request({type:"set_renderer_control",path:Le,value:ht}))).catch(()=>{})}function de(Ae){Fr.innerHTML="";let Le=new Map;for(let ht of Ae||[]){let Ye=ht.group||"";Le.has(Ye)||Le.set(Ye,[]),Le.get(Ye).push(ht)}for(let[ht,Ye]of Le){let ct=Fr;if(ht){let Ze=document.createElement("div");Ze.className="vis-group";let{header:Ke,arrow:pt,name:Xn}=sk();Xn.textContent=ht;let _i=document.createElement("input");_i.type="checkbox",_i.className="vis-cb",_i.title="Visible";let Hi=Ye.filter(Je=>Je.visible).length;_i.checked=Hi===Ye.length,_i.indeterminate=Hi>0&&Hi{let Je=_i.checked;se(Ye.filter(Qn=>!!Qn.visible!==Je).map(Qn=>({path:Qn.path,value:Je})))}),Ke.appendChild(_i),Ke.appendChild(ST()),Ze.appendChild(Ke);let _n=document.createElement("div");_n.className="vis-group-children",Ze.appendChild(_n),ok(Ke,pt,_n,!1),Fr.appendChild(Ze),ct=_n}for(let Ze of Ye){let Ke=document.createElement("div");Ke.className="vis-leaf";let pt=document.createElement("span");pt.className="vis-arrow",pt.style.visibility="hidden",pt.textContent="\u25B6",Ke.appendChild(pt),Ke.appendChild(CO(Ze.name));let Xn=document.createElement("input");Xn.type="checkbox",Xn.className="vis-cb",Xn.title="Visible",Xn.checked=!!Ze.visible,Xn.addEventListener("change",()=>se([{path:Ze.path,value:Xn.checked}])),Ke.appendChild(Xn),Ke.appendChild(ST()),ct.appendChild(Ke)}}}s.refreshRendererControls=function(){return!s.websocketManager||ua(s)||!n.debug_renderers?(Fr.innerHTML="",Promise.resolve()):s.websocketManager.request({type:"renderer_controls"}).then(Ae=>de(Ae.controls)).catch(()=>{})},s.refreshRendererControls();let it=document.createElement("div");it.className="bg-color-row";let We=document.createElement("span");We.textContent="Background";let En=document.createElement("input");En.type="color",En.className="bg-color-input",En.title="Layout background color";let hr=ph("or_bg_color");En.value=SO(hr)?hr:q5e(),En.addEventListener("input",()=>{document.documentElement.style.setProperty("--bg-map",En.value)}),En.addEventListener("change",()=>{n3t(En.value,s)});let qi=document.createElement("button");qi.className="bg-color-reset",qi.textContent="Reset",qi.title="Reset background to the theme default",qi.addEventListener("click",()=>{i3t(s),En.value=q5e()}),it.appendChild(We),it.appendChild(En),it.appendChild(qi),!s.heatMapLayer&&d&&(s.heatMapLayer=d());let Me=document.createElement("div");Me.className="vis-group heatmap-controls",s.displayControlsEl.appendChild(Me);let{header:ve,arrow:wt,name:gn}=sk("vis-group-header heatmap-header");gn.textContent="Heat Maps",Me.appendChild(ve);let vn=document.createElement("div");vn.className="vis-group-children heatmap-group-children",Me.appendChild(vn),ok(ve,wt,vn,!0),s.displayControlsEl.appendChild(it);function Mn(Ae,Le,ht,Ye){let ct=document.createElement("label");ct.className="heatmap-setting";let Ze=document.createElement("input");Ze.type="checkbox",Ze.checked=ht,Ze.addEventListener("change",()=>Ye(Ze.checked)),ct.appendChild(Ze),ct.appendChild(document.createTextNode(Le)),Ae.appendChild(ct)}function xi(Ae,Le,ht,Ye,ct){let Ze=document.createElement("label");Ze.className="heatmap-setting";let Ke=document.createElement("span");Ke.textContent=Le;let pt=document.createElement("input");pt.type="number",pt.value=String(ht),pt.step=String(Ye||1),pt.addEventListener("change",()=>ct(parseFloat(pt.value))),Ze.appendChild(Ke),Ze.appendChild(pt),Ae.appendChild(Ze)}function mi(Ae,Le,ht,Ye,ct){let Ze=document.createElement("label");Ze.className="heatmap-setting";let Ke=document.createElement("span");Ke.textContent=Le;let pt=document.createElement("select");for(let Xn of Ye){let _i=document.createElement("option");_i.value=Xn,_i.textContent=Xn,Xn===ht&&(_i.selected=!0),pt.appendChild(_i)}pt.addEventListener("change",()=>ct(pt.value)),Ze.appendChild(Ke),Ze.appendChild(pt),Ae.appendChild(Ze)}function ri(Ae){s.websocketManager.request(Ae).then(Le=>{s.updateHeatMaps&&s.updateHeatMaps(Le)}).catch(Le=>console.error("Heat map update failed",Le))}function Ge(Ae){if(!s.heatMapLegendEl)return;let Le=s.heatMapLegendEl;if(Le.innerHTML="",!Ae||!Ae.show_legend||!Ae.legend||Ae.legend.length===0){Le.classList.add("hidden");return}let ht=document.createElement("div");ht.className="heatmap-map-legend-title",ht.textContent=Ae.title,Le.appendChild(ht);let Ye=document.createElement("div");Ye.className="heatmap-map-legend-units",Ye.textContent=Ae.units||"",Le.appendChild(Ye);let ct=document.createElement("div");ct.className="heatmap-map-legend-list";for(let Ze of Ae.legend){let Ke=document.createElement("div");Ke.className="heatmap-legend-row";let pt=document.createElement("span");pt.className="heatmap-legend-swatch",pt.style.backgroundColor=`rgba(${Ze.color[0]}, ${Ze.color[1]}, ${Ze.color[2]}, ${Ze.color[3]/255})`;let Xn=document.createElement("span");Xn.textContent=Ze.value,Ke.appendChild(pt),Ke.appendChild(Xn),ct.appendChild(Ke)}Le.appendChild(ct),Le.classList.remove("hidden")}s.renderHeatMapControls=Ae=>{vn.innerHTML="";let Le=document.createElement("div");Le.className="heatmap-list",vn.appendChild(Le);let ht=document.createElement("label");ht.className="heatmap-setting";let Ye=document.createElement("input");Ye.type="radio",Ye.name="active-heatmap",Ye.checked=!Ae.active,Ye.addEventListener("change",()=>{ri({type:"set_active_heatmap",name:""})}),ht.appendChild(Ye),ht.appendChild(document.createTextNode("Off")),Le.appendChild(ht);for(let pt of Ae.heatmaps||[]){let Xn=document.createElement("label");Xn.className="heatmap-setting";let _i=document.createElement("input");_i.type="radio",_i.name="active-heatmap",_i.checked=pt.name===Ae.active,_i.addEventListener("change",()=>{ri({type:"set_active_heatmap",name:pt.name})}),Xn.appendChild(_i),Xn.appendChild(document.createTextNode(pt.title)),Le.appendChild(Xn)}let ct=(Ae.heatmaps||[]).find(pt=>pt.name===Ae.active);if(Ge(ct),!ct)return;let Ze=document.createElement("div");Ze.className="heatmap-settings",vn.appendChild(Ze),xi(Ze,"Display min",ct.display_min,ct.display_range_increment,pt=>{ri({type:"set_heatmap",name:ct.name,option:"DisplayMin",value:pt})}),xi(Ze,"Display max",ct.display_max,ct.display_range_increment,pt=>{ri({type:"set_heatmap",name:ct.name,option:"DisplayMax",value:pt})}),Mn(Ze,"Show below min",ct.draw_below_min,pt=>{ri({type:"set_heatmap",name:ct.name,option:"ShowMin",value:pt})}),Mn(Ze,"Show above max",ct.draw_above_max,pt=>{ri({type:"set_heatmap",name:ct.name,option:"ShowMax",value:pt})}),Mn(Ze,"Log scale",ct.log_scale,pt=>{ri({type:"set_heatmap",name:ct.name,option:"LogScale",value:pt})}),Mn(Ze,"Reverse log",ct.reverse_log,pt=>{ri({type:"set_heatmap",name:ct.name,option:"ReverseLog",value:pt})}),ct.can_adjust_grid&&(xi(Ze,"Grid X",ct.grid_x,.1,pt=>{ri({type:"set_heatmap",name:ct.name,option:"GridX",value:pt})}),xi(Ze,"Grid Y",ct.grid_y,.1,pt=>{ri({type:"set_heatmap",name:ct.name,option:"GridY",value:pt})})),xi(Ze,"Alpha",ct.alpha,1,pt=>{ri({type:"set_heatmap",name:ct.name,option:"Alpha",value:pt})}),Mn(Ze,"Legend",ct.show_legend,pt=>{ri({type:"set_heatmap",name:ct.name,option:"ShowLegend",value:pt})}),ct.supports_numbers&&Mn(Ze,"Show numbers",ct.show_numbers,pt=>{ri({type:"set_heatmap",name:ct.name,option:"ShowNumbers",value:pt})});for(let pt of ct.options||[])pt.type==="bool"?Mn(Ze,pt.label,pt.value,Xn=>{ri({type:"set_heatmap",name:ct.name,option:pt.name,value:Xn})}):pt.type==="choice"&&mi(Ze,pt.label,pt.value,pt.choices||[],Xn=>{ri({type:"set_heatmap",name:ct.name,option:pt.name,value:Xn})});ct.selection_filter_label&&Mn(Ze,ct.selection_filter_label,ct.use_selected_only,pt=>{ri({type:"set_heatmap",name:ct.name,option:"use_selected_only",value:pt})});let Ke=document.createElement("button");Ke.className="or-btn or-btn-sm heatmap-rebuild",Ke.textContent="Rebuild data",Ke.addEventListener("click",()=>{ri({type:"set_heatmap",name:ct.name,option:"rebuild",value:1})}),Ze.appendChild(Ke)}}var _3t="search-nav-dialog",Wdn=[{label:"Instance",value:"inst"},{label:"Net",value:"net"},{label:"Port",value:"port"}];function ide(s){if(!s.designScale)return;let n=Wdn.map(T=>``).join(""),{overlay:r,close:c,okBtn:u,showError:d}=MO("Find Object",`
`,"Find",v3t),b=r.querySelector(".sn-pattern"),w=r.querySelector(".sn-type"),_=r.querySelector(".sn-case");b.focus();function x(){let T=b.value.trim();if(!T){d("Enter a name or glob pattern.");return}s.websocketManager&&(d("Searching\u2026",!0),s.websocketManager.request({type:"find",obj_type:w.value,pattern:T,match_case:_.checked}).then(M=>{EO(s,M);let L=M&&M.count?M.count:0;if(!L){d("No objects found.");return}Array.isArray(M.bbox)&&(s.lastSelectionBounds=M.bbox.slice(0,4),s.view.fitWorldRect(X1(...s.lastSelectionBounds,s.designScale,s.designOriginX,s.designOriginY))),typeof s.updateInspector=="function"&&s.updateInspector(M),typeof s.redrawAllLayers=="function"&&s.redrawAllLayers();let I=M.selection_count||L;d(M.truncated?`${L} found (showing first ${I}).`:`${L} found.`,!0)}).catch(M=>d("Find failed: "+M)))}return u.addEventListener("click",x),b.addEventListener("keydown",T=>{T.key==="Enter"&&(T.preventDefault(),x())}),{close:c}}function rde(s){if(!s.designScale||!s.view)return;let n=D=>s.formatDbu(D),r=D=>s.parseDbu(D),c=s.unitLabel(),u=s.view.getCenter(),d=Pv(u[0],u[1],s.designScale,s.designOriginX,s.designOriginY),{overlay:b,close:w,okBtn:_,showError:x}=MO("Go to Position",` + `,"Find",_3t),b=r.querySelector(".sn-pattern"),w=r.querySelector(".sn-type"),_=r.querySelector(".sn-case");b.focus();function x(){let T=b.value.trim();if(!T){d("Enter a name or glob pattern.");return}s.websocketManager&&(d("Searching\u2026",!0),s.websocketManager.request({type:"find",obj_type:w.value,pattern:T,match_case:_.checked}).then(M=>{EO(s,M);let L=M&&M.count?M.count:0;if(!L){d("No objects found.");return}Array.isArray(M.bbox)&&(s.lastSelectionBounds=M.bbox.slice(0,4),s.view.fitWorldRect(X1(...s.lastSelectionBounds,s.designScale,s.designOriginX,s.designOriginY))),typeof s.updateInspector=="function"&&s.updateInspector(M),typeof s.redrawAllLayers=="function"&&s.redrawAllLayers();let I=M.selection_count||L;d(M.truncated?`${L} found (showing first ${I}).`:`${L} found.`,!0)}).catch(M=>d("Find failed: "+M)))}return u.addEventListener("click",x),b.addEventListener("keydown",T=>{T.key==="Enter"&&(T.preventDefault(),x())}),{close:c}}function rde(s){if(!s.designScale||!s.view)return;let n=D=>s.formatDbu(D),r=D=>s.parseDbu(D),c=s.unitLabel(),u=s.view.getCenter(),d=kv(u[0],u[1],s.designScale,s.designOriginX,s.designOriginY),{overlay:b,close:w,okBtn:_,showError:x}=MO("Go to Position",`
-
`,"Go to",v3t),T=b.querySelector(".sn-x"),M=b.querySelector(".sn-y"),L=b.querySelector(".sn-size");T.focus(),T.select();function I(){let D=r(T.value),F=r(M.value);if(D===null||F===null){x(`X and Y must be numbers (${c}).`);return}let O=L.value.trim(),z=O?r(O):null;if(z!==null&&z>0){let Z=z/2;s.view.fitWorldRect(X1(D-Z,F-Z,D+Z,F+Z,s.designScale,s.designOriginX,s.designOriginY))}else s.view.setView(Av(D,F,s.designScale,s.designOriginX,s.designOriginY),s.view.getZoom());w()}_.addEventListener("click",I);for(let D of[T,M,L])D.addEventListener("keydown",F=>{F.key==="Enter"&&(F.preventDefault(),I())});return{close:w}}var _3t={ctrl:"ctrl",control:"ctrl",shift:"shift",alt:"alt",meta:"meta",cmd:"meta",command:"meta",super:"meta"};function $dn(s){if(typeof s!="string")return null;let n=s.split("+").map(d=>d.trim().toLowerCase()).filter(Boolean);if(n.length===0)return null;let r=n.pop();if(_3t[r]!==void 0)return null;let c=new Set;for(let d of n){let b=_3t[d];if(b===void 0)return null;c.add(b)}return[...["ctrl","alt","shift","meta"].filter(d=>c.has(d)),r].join("+")}function Vdn(s){let n=[];return s.ctrlKey&&n.push("ctrl"),s.altKey&&n.push("alt"),s.shiftKey&&n.push("shift"),s.metaKey&&n.push("meta"),[...n,String(s.key).toLowerCase()].join("+")}function x3t(s){let n=[{label:"File",items:[{label:"Open DB...",action:()=>y3t(s,"Open DB","read_db"),enabledWhen:()=>!s.designScale},{label:"Save DB...",action:()=>y3t(s,"Save DB","write_db"),enabledWhen:()=>!!s.designScale}]},{label:"View",items:[{label:"Fit",shortcut:"F",action:()=>{s.fitRect&&s.view.fitWorldRect(s.fitRect)}},{label:"Zoom In",shortcut:"Z",action:()=>s.view.zoomIn()},{label:"Zoom Out",shortcut:"Shift+Z",action:()=>s.view.zoomOut()},{type:"separator"},{label:"Toggle Theme",shortcut:"T",action:()=>s.toggleTheme()},{type:"separator"},{label:"Find...",shortcut:"Ctrl+F",action:()=>ide(s),enabledWhen:()=>!!s.designScale},{label:"Go to Position...",shortcut:"Shift+G",action:()=>rde(s),enabledWhen:()=>!!s.designScale}]},{label:"Tools",items:[{label:"Ruler",shortcut:"K",action:()=>{s.rulerManager&&s.rulerManager.toggleRulerMode()}},{label:"Clear Rulers",shortcut:"Shift+K",action:()=>{s.rulerManager&&s.rulerManager.clearAllRulers()}},{type:"separator"},{label:"Add Label",shortcut:"L",action:()=>{s.labelManager&&s.labelManager.toggleLabelMode()}},{label:"Clear Labels",action:()=>{s.labelManager&&s.labelManager.clearAllLabels()}},{type:"separator"},{label:"Clear Highlights",action:()=>{s.websocketManager.request({type:"clear_highlights",group:-1}).then(()=>{s.refreshOverlay&&s.refreshOverlay(),s.refreshInspector&&s.refreshInspector()}).catch(()=>{})}},{type:"separator"},{label:"Global Connect...",action:()=>{s.showGlobalConnectDialog&&s.showGlobalConnectDialog()},enabledWhen:()=>!!s.designScale}]},{label:"Options",items:[{label:"Show DBU",action:()=>s.toggleShowDbu(),checked:()=>s.showDbu},{label:"Make euclidian rulers",action:()=>s.toggleRulerStyle(),checked:()=>s.rulerStyle!=="manhattan"},{type:"separator"},{label:"Mouse wheel mapped to zoom by default",action:()=>s.toggleWheelZoom(),checked:()=>s.wheelZoom},{label:"Arrow keys scroll step...",action:()=>s.showArrowStepDialog()},{label:"Application font...",action:()=>s.showAppFontDialog()},{type:"separator"},{label:"Smooth zoom and pan",action:()=>s.toggleControlSmoothing(),checked:()=>s.controlSmoothing},{label:"Double buffering",action:()=>s.toggleDoubleBuffer(),checked:()=>s.doubleBuffer},{label:"Defer tile updates while panning",action:()=>s.toggleDeferTileUpdates(),checked:()=>s.deferTileUpdates},{type:"separator"},{label:"Show polygon decomposition",action:()=>s.togglePolyDecomp(),checked:()=>s.polyDecomp,enabledWhen:()=>!!s.designScale}]},{label:"Windows",items:[{label:"Layout Viewer",action:()=>s.focusComponent("LayoutViewer")},{label:"3D Viewer",action:()=>s.focusComponent("3DViewer")},{label:"Display Controls",action:()=>s.focusComponent("DisplayControls")},{label:"Inspector",action:()=>s.focusComponent("Inspector")},{label:"Selection Browser",action:()=>s.focusComponent("SelectHighlight")},{label:"Tcl Console",action:()=>s.focusComponent("TclConsole")},{label:"Hierarchy Browser",action:()=>s.focusComponent("Browser")},{label:"Timing",action:()=>s.focusComponent("TimingWidget")},{label:"DRC Viewer",action:()=>s.focusComponent("DRCWidget")},{label:"Clock Tree",action:()=>s.focusComponent("ClockWidget")},{label:"Charts",action:()=>s.focusComponent("ChartsWidget")},{label:"Help",action:()=>s.focusComponent("HelpWidget")},{type:"separator"},{label:"Reset to Default Layout",action:()=>s.resetLayout()}]},{label:"Help",items:[{label:"Keyboard Shortcuts",action:()=>s.focusComponent("HelpWidget")}]}],r=document.getElementById("menu-bar"),c=null,u=new Map;function d(){c&&(c.classList.remove("open"),c=null)}function b(){let x=n.map(I=>({label:I.label,items:I.items.slice()})),T=new Map(x.map(I=>[I.label,I]));function M(I){let D=T.get(I);return D||(D={label:I,items:[]},T.set(I,D),x.push(D)),D}function L(I,D){let F=I.items.find(O=>O.submenu&&O.label===D);return F||(F={label:D,submenu:{label:D,items:[]}},I.items.push(F)),F.submenu}for(let I of s.customMenu||[]){let D=String(I.path||"Custom Scripts").split("/").map(Z=>Z.trim()).filter(Boolean);D.length===0&&D.push("Custom Scripts");let F=M(D[0]);for(let Z=1;ZiH(s,I.script,I.echo);F.items.push({label:I.text,shortcut:I.shortcut,action:O});let z=$dn(I.shortcut);z&&u.set(z,O)}return x}function w(x,T){for(let M of T){if(M.type==="separator"){let D=document.createElement("div");D.className="menu-separator",x.appendChild(D);continue}let L=document.createElement("div");if(L.className="menu-item",M.submenu){L.classList.add("submenu-item");let D=document.createElement("span");D.textContent=M.label,L.appendChild(D);let F=document.createElement("span");F.className="submenu-arrow",F.textContent="\u25B8",L.appendChild(F);let O=document.createElement("div");O.className="menu-dropdown submenu",w(O,M.submenu.items),L.appendChild(O),x.appendChild(L);continue}if(M.disabled&&L.classList.add("disabled"),M.enabledWhen&&(L._enabledWhen=M.enabledWhen),M.checked){let D=document.createElement("span");D.className="menu-check",D.textContent=M.checked()?"\u2713":"",L.appendChild(D),L._checkedFn=M.checked}let I=document.createElement("span");if(I.textContent=M.label,L.appendChild(I),M.shortcut){let D=document.createElement("span");D.className="shortcut",D.textContent=M.shortcut,L.appendChild(D)}M.action&&L.addEventListener("click",D=>{L.classList.contains("disabled")||(D.stopPropagation(),d(),M.action())}),x.appendChild(L)}}function _(){for(let T of r.querySelectorAll(":scope > .menu-label"))T.remove();let x=r.firstChild;c=null,u.clear();for(let T of b()){let I=function(){for(let D of L.querySelectorAll(".menu-item"))if(D._enabledWhen&&D.classList.toggle("disabled",!D._enabledWhen()),D._checkedFn){let F=D.querySelector(".menu-check");F&&(F.textContent=D._checkedFn()?"\u2713":"")}},M=document.createElement("div");M.className="menu-label",M.textContent=T.label;let L=document.createElement("div");L.className="menu-dropdown",w(L,T.items),M.appendChild(L),M.addEventListener("click",D=>{D.stopPropagation(),c===M?d():(d(),I(),M.classList.add("open"),c=M)}),M.addEventListener("mouseenter",()=>{c&&c!==M&&(d(),I(),M.classList.add("open"),c=M)}),r.insertBefore(M,x)}}_(),s.rebuildMenuBar=_,document.addEventListener("click",d),Wdn(u)}function Wdn(s){document.addEventListener("keydown",n=>{if(s.size===0)return;let r=n.target.tagName;if(r==="INPUT"||r==="TEXTAREA"||n.target.isContentEditable)return;let c=s.get(Vdn(n));c&&(n.preventDefault(),n.stopImmediatePropagation(),c())},!0)}function y3t(s,n,r){let c=r==="write_db",u=document.createElement("div");u.className="modal-overlay",u.innerHTML=` +
`,"Go to",_3t),T=b.querySelector(".sn-x"),M=b.querySelector(".sn-y"),L=b.querySelector(".sn-size");T.focus(),T.select();function I(){let D=r(T.value),F=r(M.value);if(D===null||F===null){x(`X and Y must be numbers (${c}).`);return}let O=L.value.trim(),z=O?r(O):null;if(z!==null&&z>0){let Z=z/2;s.view.fitWorldRect(X1(D-Z,F-Z,D+Z,F+Z,s.designScale,s.designOriginX,s.designOriginY))}else s.view.setView(Lv(D,F,s.designScale,s.designOriginX,s.designOriginY),s.view.getZoom());w()}_.addEventListener("click",I);for(let D of[T,M,L])D.addEventListener("keydown",F=>{F.key==="Enter"&&(F.preventDefault(),I())});return{close:w}}var y3t={ctrl:"ctrl",control:"ctrl",shift:"shift",alt:"alt",meta:"meta",cmd:"meta",command:"meta",super:"meta"};function Hdn(s){if(typeof s!="string")return null;let n=s.split("+").map(d=>d.trim().toLowerCase()).filter(Boolean);if(n.length===0)return null;let r=n.pop();if(y3t[r]!==void 0)return null;let c=new Set;for(let d of n){let b=y3t[d];if(b===void 0)return null;c.add(b)}return[...["ctrl","alt","shift","meta"].filter(d=>c.has(d)),r].join("+")}function qdn(s){let n=[];return s.ctrlKey&&n.push("ctrl"),s.altKey&&n.push("alt"),s.shiftKey&&n.push("shift"),s.metaKey&&n.push("meta"),[...n,String(s.key).toLowerCase()].join("+")}function E3t(s){let n=[{label:"File",items:[{label:"Open DB...",action:()=>x3t(s,"Open DB","read_db"),enabledWhen:()=>!s.designScale},{label:"Save DB...",action:()=>x3t(s,"Save DB","write_db"),enabledWhen:()=>!!s.designScale}]},{label:"View",items:[{label:"Fit",shortcut:"F",action:()=>{s.fitRect&&s.view.fitWorldRect(s.fitRect)}},{label:"Zoom In",shortcut:"Z",action:()=>s.view.zoomIn()},{label:"Zoom Out",shortcut:"Shift+Z",action:()=>s.view.zoomOut()},{type:"separator"},{label:"Toggle Theme",shortcut:"T",action:()=>s.toggleTheme()},{type:"separator"},{label:"Find...",shortcut:"Ctrl+F",action:()=>ide(s),enabledWhen:()=>!!s.designScale},{label:"Go to Position...",shortcut:"Shift+G",action:()=>rde(s),enabledWhen:()=>!!s.designScale}]},{label:"Tools",items:[{label:"Ruler",shortcut:"K",action:()=>{s.rulerManager&&s.rulerManager.toggleRulerMode()}},{label:"Clear Rulers",shortcut:"Shift+K",action:()=>{s.rulerManager&&s.rulerManager.clearAllRulers()}},{type:"separator"},{label:"Add Label",shortcut:"L",action:()=>{s.labelManager&&s.labelManager.toggleLabelMode()}},{label:"Clear Labels",action:()=>{s.labelManager&&s.labelManager.clearAllLabels()}},{type:"separator"},{label:"Clear Highlights",action:()=>{s.websocketManager.request({type:"clear_highlights",group:-1}).then(()=>{s.refreshOverlay&&s.refreshOverlay(),s.refreshInspector&&s.refreshInspector()}).catch(()=>{})}},{type:"separator"},{label:"Global Connect...",action:()=>{s.showGlobalConnectDialog&&s.showGlobalConnectDialog()},enabledWhen:()=>!!s.designScale}]},{label:"Options",items:[{label:"Show DBU",action:()=>s.toggleShowDbu(),checked:()=>s.showDbu},{label:"Make euclidian rulers",action:()=>s.toggleRulerStyle(),checked:()=>s.rulerStyle!=="manhattan"},{type:"separator"},{label:"Mouse wheel mapped to zoom by default",action:()=>s.toggleWheelZoom(),checked:()=>s.wheelZoom},{label:"Arrow keys scroll step...",action:()=>s.showArrowStepDialog()},{label:"Application font...",action:()=>s.showAppFontDialog()},{type:"separator"},{label:"Smooth zoom and pan",action:()=>s.toggleControlSmoothing(),checked:()=>s.controlSmoothing},{label:"Double buffering",action:()=>s.toggleDoubleBuffer(),checked:()=>s.doubleBuffer},{label:"Defer tile updates while panning",action:()=>s.toggleDeferTileUpdates(),checked:()=>s.deferTileUpdates},{type:"separator"},{label:"Show polygon decomposition",action:()=>s.togglePolyDecomp(),checked:()=>s.polyDecomp,enabledWhen:()=>!!s.designScale}]},{label:"Windows",items:[{label:"Layout Viewer",action:()=>s.focusComponent("LayoutViewer")},{label:"3D Viewer",action:()=>s.focusComponent("3DViewer")},{label:"Display Controls",action:()=>s.focusComponent("DisplayControls")},{label:"Inspector",action:()=>s.focusComponent("Inspector")},{label:"Selection Browser",action:()=>s.focusComponent("SelectHighlight")},{label:"Tcl Console",action:()=>s.focusComponent("TclConsole")},{label:"Hierarchy Browser",action:()=>s.focusComponent("Browser")},{label:"Timing",action:()=>s.focusComponent("TimingWidget")},{label:"DRC Viewer",action:()=>s.focusComponent("DRCWidget")},{label:"Clock Tree",action:()=>s.focusComponent("ClockWidget")},{label:"Charts",action:()=>s.focusComponent("ChartsWidget")},{label:"Help",action:()=>s.focusComponent("HelpWidget")},{type:"separator"},{label:"Reset to Default Layout",action:()=>s.resetLayout()}]},{label:"Help",items:[{label:"Keyboard Shortcuts",action:()=>s.focusComponent("HelpWidget")}]}],r=document.getElementById("menu-bar"),c=null,u=new Map;function d(){c&&(c.classList.remove("open"),c=null)}function b(){let x=n.map(I=>({label:I.label,items:I.items.slice()})),T=new Map(x.map(I=>[I.label,I]));function M(I){let D=T.get(I);return D||(D={label:I,items:[]},T.set(I,D),x.push(D)),D}function L(I,D){let F=I.items.find(O=>O.submenu&&O.label===D);return F||(F={label:D,submenu:{label:D,items:[]}},I.items.push(F)),F.submenu}for(let I of s.customMenu||[]){let D=String(I.path||"Custom Scripts").split("/").map(Z=>Z.trim()).filter(Boolean);D.length===0&&D.push("Custom Scripts");let F=M(D[0]);for(let Z=1;ZiH(s,I.script,I.echo);F.items.push({label:I.text,shortcut:I.shortcut,action:O});let z=Hdn(I.shortcut);z&&u.set(z,O)}return x}function w(x,T){for(let M of T){if(M.type==="separator"){let D=document.createElement("div");D.className="menu-separator",x.appendChild(D);continue}let L=document.createElement("div");if(L.className="menu-item",M.submenu){L.classList.add("submenu-item");let D=document.createElement("span");D.textContent=M.label,L.appendChild(D);let F=document.createElement("span");F.className="submenu-arrow",F.textContent="\u25B8",L.appendChild(F);let O=document.createElement("div");O.className="menu-dropdown submenu",w(O,M.submenu.items),L.appendChild(O),x.appendChild(L);continue}if(M.disabled&&L.classList.add("disabled"),M.enabledWhen&&(L._enabledWhen=M.enabledWhen),M.checked){let D=document.createElement("span");D.className="menu-check",D.textContent=M.checked()?"\u2713":"",L.appendChild(D),L._checkedFn=M.checked}let I=document.createElement("span");if(I.textContent=M.label,L.appendChild(I),M.shortcut){let D=document.createElement("span");D.className="shortcut",D.textContent=M.shortcut,L.appendChild(D)}M.action&&L.addEventListener("click",D=>{L.classList.contains("disabled")||(D.stopPropagation(),d(),M.action())}),x.appendChild(L)}}function _(){for(let T of r.querySelectorAll(":scope > .menu-label"))T.remove();let x=r.firstChild;c=null,u.clear();for(let T of b()){let I=function(){for(let D of L.querySelectorAll(".menu-item"))if(D._enabledWhen&&D.classList.toggle("disabled",!D._enabledWhen()),D._checkedFn){let F=D.querySelector(".menu-check");F&&(F.textContent=D._checkedFn()?"\u2713":"")}},M=document.createElement("div");M.className="menu-label",M.textContent=T.label;let L=document.createElement("div");L.className="menu-dropdown",w(L,T.items),M.appendChild(L),M.addEventListener("click",D=>{D.stopPropagation(),c===M?d():(d(),I(),M.classList.add("open"),c=M)}),M.addEventListener("mouseenter",()=>{c&&c!==M&&(d(),I(),M.classList.add("open"),c=M)}),r.insertBefore(M,x)}}_(),s.rebuildMenuBar=_,document.addEventListener("click",d),Xdn(u)}function Xdn(s){document.addEventListener("keydown",n=>{if(s.size===0)return;let r=n.target.tagName;if(r==="INPUT"||r==="TEXTAREA"||n.target.isContentEditable)return;let c=s.get(qdn(n));c&&(n.preventDefault(),n.stopImmediatePropagation(),c())},!0)}function x3t(s,n,r){let c=r==="write_db",u=document.createElement("div");u.className="modal-overlay",u.innerHTML=` -
`,document.body.appendChild(u);let d=u.querySelector(".fb-breadcrumb"),b=u.querySelector(".fb-file-list"),w=u.querySelector(".fb-path-input"),_=u.querySelector(".modal-error"),x=u.querySelector(".ok"),T=u.querySelector(".cancel"),M="",L=null;function I(){u.remove()}function D(){let H=w.value.trim();x.disabled=!H}function F(H){d.innerHTML="";let te=H.split("/").filter(Boolean),se=document.createElement("span");se.className="fb-crumb",se.textContent="/",se.addEventListener("click",()=>z("/")),d.appendChild(se);let ne="";for(let ue of te){ne+="/"+ue;let Ce=document.createElement("span");Ce.className="fb-crumb-sep",Ce.textContent=" / ",d.appendChild(Ce);let Q=document.createElement("span");Q.className="fb-crumb",Q.textContent=ue;let me=ne;Q.addEventListener("click",()=>z(me)),d.appendChild(Q)}}function O(H){if(b.innerHTML="",L=null,!H||H.length===0){let te=document.createElement("div");te.className="fb-empty",te.textContent="(empty directory)",b.appendChild(te);return}for(let te of H){let se=document.createElement("div");se.className="fb-entry",te.is_dir&&se.classList.add("fb-dir");let ne=document.createElement("span");ne.className="fb-icon",ne.textContent=te.is_dir?"\u{1F4C1}":"\u{1F4C4}",se.appendChild(ne);let ue=document.createElement("span");if(ue.className="fb-name",ue.textContent=te.name,se.appendChild(ue),!te.is_dir&&te.size!==void 0){let Ce=document.createElement("span");Ce.className="fb-size",Ce.textContent=Hdn(te.size),se.appendChild(Ce)}te.is_dir?se.addEventListener("click",()=>{z(M+"/"+te.name)}):(se.addEventListener("click",()=>{let Ce=b.querySelector(".fb-selected");Ce&&Ce.classList.remove("fb-selected"),se.classList.add("fb-selected"),L=te,w.value=M+"/"+te.name,D()}),se.addEventListener("dblclick",()=>{w.value=M+"/"+te.name,D(),Z()})),b.appendChild(se)}}async function z(H){_.style.display="none",b.innerHTML='
Loading...
';try{let te=await s.websocketManager.request({type:"list_dir",path:H||""});if(M=te.path,F(te.path),O(te.entries),c){let ne=w.value.trim().split("/").pop();ne&&!ne.includes("/")?w.value=M+"/"+ne:w.value=M+"/"}else w.value="",L=null;D()}catch(te){b.innerHTML="",_.textContent=te.message||String(te),_.style.display=""}}async function Z(){let H=w.value.trim();if(H){x.disabled=!0,x.textContent="Working...",_.style.display="none";try{let te=await s.websocketManager.request({type:"tcl_eval",cmd:`${r} ${H}`});if(te.is_error){_.textContent=te.output||te.result||"Command failed",_.style.display="",x.disabled=!1,x.textContent=c?"Save":"Open";return}if(I(),r==="read_db"){window.location.reload();return}}catch(te){_.textContent=te.message||"Request failed",_.style.display="",x.disabled=!1,x.textContent=c?"Save":"Open"}}}w.addEventListener("input",D),w.addEventListener("keydown",H=>{if(H.key==="Enter"){let te=w.value.trim();te.endsWith("/")?z(te.replace(/\/+$/,"")||"/"):Z()}H.key==="Escape"&&I()}),x.addEventListener("click",Z),T.addEventListener("click",I),u.addEventListener("click",H=>{H.target===u&&I()}),z("")}function Hdn(s){return s<1024?s+" B":s<1024*1024?(s/1024).toFixed(1)+" KB":s<1024*1024*1024?(s/(1024*1024)).toFixed(1)+" MB":(s/(1024*1024*1024)).toFixed(1)+" GB"}function E3t(s){let n=document.getElementById("toolbar");if(!n)return;s._toolbarToggleState||(s._toolbarToggleState={});function r(){n.innerHTML="";let c=s.customToolbar||[],u=new Set(c.map(d=>d.key));for(let d of Object.keys(s._toolbarToggleState))u.has(d)||delete s._toolbarToggleState[d];for(let d of c){let b=document.createElement("button");if(b.className="or-btn or-btn-sm toolbar-button",b.dataset.key=d.key,d.tooltip&&(b.title=d.tooltip),d.icon){let w=document.createElement("span");if(w.className="toolbar-icon",/^(data:|https?:|\.?\/)/.test(d.icon)){let _=document.createElement("img");_.src=d.icon,_.alt="",w.appendChild(_)}else w.textContent=d.icon;b.appendChild(w)}if(d.text){let w=document.createElement("span");w.className="toolbar-label",w.textContent=d.text,b.appendChild(w)}d.toggle&&s._toolbarToggleState[d.key]&&b.classList.add("active"),b.addEventListener("click",()=>{if(d.toggle){let w=!s._toolbarToggleState[d.key];s._toolbarToggleState[d.key]=w,b.classList.toggle("active",w),iH(s,w?d.script:d.script_off,d.echo)}else iH(s,d.script,d.echo)}),n.appendChild(b)}}return r(),s.rebuildToolbar=r,{rebuild:r}}function M3t(s,n=""){let r=document.createElement("div");r.className="modal-overlay",r.innerHTML=` + `,document.body.appendChild(u);let d=u.querySelector(".fb-breadcrumb"),b=u.querySelector(".fb-file-list"),w=u.querySelector(".fb-path-input"),_=u.querySelector(".modal-error"),x=u.querySelector(".ok"),T=u.querySelector(".cancel"),M="",L=null;function I(){u.remove()}function D(){let H=w.value.trim();x.disabled=!H}function F(H){d.innerHTML="";let te=H.split("/").filter(Boolean),oe=document.createElement("span");oe.className="fb-crumb",oe.textContent="/",oe.addEventListener("click",()=>z("/")),d.appendChild(oe);let ne="";for(let ue of te){ne+="/"+ue;let Te=document.createElement("span");Te.className="fb-crumb-sep",Te.textContent=" / ",d.appendChild(Te);let Q=document.createElement("span");Q.className="fb-crumb",Q.textContent=ue;let ge=ne;Q.addEventListener("click",()=>z(ge)),d.appendChild(Q)}}function O(H){if(b.innerHTML="",L=null,!H||H.length===0){let te=document.createElement("div");te.className="fb-empty",te.textContent="(empty directory)",b.appendChild(te);return}for(let te of H){let oe=document.createElement("div");oe.className="fb-entry",te.is_dir&&oe.classList.add("fb-dir");let ne=document.createElement("span");ne.className="fb-icon",ne.textContent=te.is_dir?"\u{1F4C1}":"\u{1F4C4}",oe.appendChild(ne);let ue=document.createElement("span");if(ue.className="fb-name",ue.textContent=te.name,oe.appendChild(ue),!te.is_dir&&te.size!==void 0){let Te=document.createElement("span");Te.className="fb-size",Te.textContent=Ydn(te.size),oe.appendChild(Te)}te.is_dir?oe.addEventListener("click",()=>{z(M+"/"+te.name)}):(oe.addEventListener("click",()=>{let Te=b.querySelector(".fb-selected");Te&&Te.classList.remove("fb-selected"),oe.classList.add("fb-selected"),L=te,w.value=M+"/"+te.name,D()}),oe.addEventListener("dblclick",()=>{w.value=M+"/"+te.name,D(),Z()})),b.appendChild(oe)}}async function z(H){_.style.display="none",b.innerHTML='
Loading...
';try{let te=await s.websocketManager.request({type:"list_dir",path:H||""});if(M=te.path,F(te.path),O(te.entries),c){let ne=w.value.trim().split("/").pop();ne&&!ne.includes("/")?w.value=M+"/"+ne:w.value=M+"/"}else w.value="",L=null;D()}catch(te){b.innerHTML="",_.textContent=te.message||String(te),_.style.display=""}}async function Z(){let H=w.value.trim();if(H){x.disabled=!0,x.textContent="Working...",_.style.display="none";try{let te=await s.websocketManager.request({type:"tcl_eval",cmd:`${r} ${H}`});if(te.is_error){_.textContent=te.output||te.result||"Command failed",_.style.display="",x.disabled=!1,x.textContent=c?"Save":"Open";return}if(I(),r==="read_db"){window.location.reload();return}}catch(te){_.textContent=te.message||"Request failed",_.style.display="",x.disabled=!1,x.textContent=c?"Save":"Open"}}}w.addEventListener("input",D),w.addEventListener("keydown",H=>{if(H.key==="Enter"){let te=w.value.trim();te.endsWith("/")?z(te.replace(/\/+$/,"")||"/"):Z()}H.key==="Escape"&&I()}),x.addEventListener("click",Z),T.addEventListener("click",I),u.addEventListener("click",H=>{H.target===u&&I()}),z("")}function Ydn(s){return s<1024?s+" B":s<1024*1024?(s/1024).toFixed(1)+" KB":s<1024*1024*1024?(s/(1024*1024)).toFixed(1)+" MB":(s/(1024*1024*1024)).toFixed(1)+" GB"}function S3t(s){let n=document.getElementById("toolbar");if(!n)return;s._toolbarToggleState||(s._toolbarToggleState={});function r(){n.innerHTML="";let c=s.customToolbar||[],u=new Set(c.map(d=>d.key));for(let d of Object.keys(s._toolbarToggleState))u.has(d)||delete s._toolbarToggleState[d];for(let d of c){let b=document.createElement("button");if(b.className="or-btn or-btn-sm toolbar-button",b.dataset.key=d.key,d.tooltip&&(b.title=d.tooltip),d.icon){let w=document.createElement("span");if(w.className="toolbar-icon",/^(data:|https?:|\.?\/)/.test(d.icon)){let _=document.createElement("img");_.src=d.icon,_.alt="",w.appendChild(_)}else w.textContent=d.icon;b.appendChild(w)}if(d.text){let w=document.createElement("span");w.className="toolbar-label",w.textContent=d.text,b.appendChild(w)}d.toggle&&s._toolbarToggleState[d.key]&&b.classList.add("active"),b.addEventListener("click",()=>{if(d.toggle){let w=!s._toolbarToggleState[d.key];s._toolbarToggleState[d.key]=w,b.classList.toggle("active",w),iH(s,w?d.script:d.script_off,d.echo)}else iH(s,d.script,d.echo)}),n.appendChild(b)}}return r(),s.rebuildToolbar=r,{rebuild:r}}function T3t(s,n=""){let r=document.createElement("div");r.className="modal-overlay",r.innerHTML=` `,document.body.appendChild(r);function c(d){d.key==="Escape"&&u()}let u=()=>{r.remove(),document.removeEventListener("keydown",c)};return r.addEventListener("click",d=>{d.target===r&&u()}),document.addEventListener("keydown",c),{overlay:r,body:r.querySelector(".modal-body"),errorDiv:r.querySelector(".modal-error"),buttons:r.querySelector(".modal-buttons"),close:u}}function g2(s,n){s.textContent=n,s.style.display=n?"":"none"}function AO(s,n,{primary:r=!1}={}){let c=document.createElement("button");return c.textContent=n,c.className="or-btn"+(r?" or-btn-primary":""),s.appendChild(c),c}function sde(s){return"{"+String(s)+"}"}function T3t(s){let n=M3t("Global Connect","gc-dialog"),r=document.createElement("div");r.className="gc-table",n.body.appendChild(r);let c=document.createElement("div");c.className="gc-form";let u=document.createElement("input");u.placeholder="Instance pattern (regex)",u.value=".*";let d=document.createElement("input");d.placeholder="Pin pattern (regex)";let b=document.createElement("select"),w=document.createElement("select"),_=document.createElement("span");_.innerHTML='',c.append(ST("Instance",u),ST("Pin",d),ST("Net",b),ST("Region",w),_);let x=AO(c,"Add rule");n.body.appendChild(c);function T(){let D=d.value.trim()!==""&&b.value!=="";for(let F of[u,d])try{new RegExp(F.value),F.classList.remove("gc-invalid")}catch{F.classList.add("gc-invalid"),D=!1}x.disabled=!D}u.addEventListener("input",T),d.addEventListener("input",T),b.addEventListener("change",T);function M(){s.websocketManager.request({type:"global_connect_info"}).then(D=>{r.innerHTML='
InstancePinNetRegion
',(D.rules||[]).forEach(F=>{let O=document.createElement("div");O.className="gc-row",O.innerHTML=`${oH(F.inst)}${oH(F.pin)}${oH(F.net)}${oH(F.region||"All")}`;let z=document.createElement("button");z.className="or-btn or-btn-sm or-btn-icon",z.textContent="\u2715",z.title="Delete rule",z.addEventListener("click",()=>{s.websocketManager.request({type:"global_connect_delete",inst:F.inst,pin:F.pin,net:F.net,region:F.region||""}).then(M).catch(Z=>g2(n.errorDiv,String(Z)))}),O.appendChild(z),r.appendChild(O)}),eDe(b,D.nets||[]),eDe(w,["All",...D.regions||[]]),T()}).catch(D=>g2(n.errorDiv,String(D)))}x.addEventListener("click",()=>{let D=c.querySelector('input[name="gc-pg"]:checked').value,F=`add_global_connection -net ${sde(b.value)} -inst_pattern ${sde(u.value||".*")} -pin_pattern ${sde(d.value)} -${D}`;w.value&&w.value!=="All"&&(F+=` -region ${sde(w.value)}`),S3t(s,F,n.errorDiv,"Rule added.",M)}),AO(n.buttons,"Apply (force)").addEventListener("click",()=>{s.websocketManager.request({type:"global_connect_apply",force:!0}).then(D=>{if(!D.had_rules){g2(n.errorDiv,"No global-connect rules defined \u2014 add a rule first.");return}g2(n.errorDiv,`Connected ${D.connected} pin(s).`),s.scheduleRedrawAllLayers&&s.scheduleRedrawAllLayers(),M()}).catch(D=>g2(n.errorDiv,D.message||String(D)))}),AO(n.buttons,"Clear all").addEventListener("click",()=>S3t(s,"clear_global_connect",n.errorDiv,"Rules cleared.",M)),AO(n.buttons,"Close").addEventListener("click",n.close),M()}function S3t(s,n,r,c,u){s.websocketManager.request({type:"tcl_eval",cmd:n}).then(d=>{if(d.is_error){g2(r,d.output||d.result||"Command failed");return}g2(r,c||""),s.scheduleRedrawAllLayers&&s.scheduleRedrawAllLayers(),u&&u()}).catch(d=>g2(r,d.message||String(d)))}function C3t(s,n){let r=M3t(`Insert Buffer \u2014 ${oH(n)}`,"buf-dialog"),c=AO(r.buttons,"Insert",{primary:!0});c.disabled=!0,AO(r.buttons,"Cancel").addEventListener("click",r.close),s.websocketManager.request({type:"buffer_info",net:n}).then(d=>{if(!d.can_buffer){r.body.textContent=d.error||"This net has multiple drivers and cannot be buffered.";return}qdn(s,r,n,d,c)}).catch(d=>{r.body.textContent=String(d)})}function qdn(s,n,r,c,u){let d=document.createElement("div");d.className="buf-pins";let b=c.drivers||[],w=c.loads||[],_=new Set;function x(){d.innerHTML="";let D=(F,O)=>{let z=document.createElement("label");z.className="buf-pin";let Z=document.createElement("input");Z.type="checkbox",Z.checked=_.has(F.id),Z.addEventListener("change",()=>{if(Z.checked){if(O)_.clear();else for(let H of b)_.delete(H.id);_.add(F.id)}else _.delete(F.id);x(),I()}),z.append(Z,document.createTextNode(" "+F.label)),d.appendChild(z)};b.forEach(F=>D(F,!0)),w.forEach(F=>D(F,!1))}b.length&&_.add(b[0].id),x();let T=document.createElement("select");eDe(T,c.masters||[]);let M=document.createElement("input");M.placeholder="Optional: new buffer name";let L=document.createElement("input");L.placeholder="Optional: new net name",n.body.append(ST("Pins to buffer",d),ST("Buffer master",T),ST("Buffer name",M),ST("Net name",L));function I(){u.disabled=_.size===0||!T.value}T.addEventListener("change",I),I(),u.addEventListener("click",()=>{let D=new Set(b.map(z=>z.id)),F=[..._],O=F.some(z=>D.has(z))?"driver":"loads";s.websocketManager.request({type:"insert_buffer",net:r,mode:O,pins:F,master:T.value,buf_name:M.value.trim(),net_name:L.value.trim()}).then(z=>{if(z.is_error||z.ok===!1){g2(n.errorDiv,z.error||z.result||"Insertion failed");return}n.close(),z.inst&&(s.selectedInstanceName=z.inst),s.scheduleRedrawAllLayers&&s.scheduleRedrawAllLayers()}).catch(z=>g2(n.errorDiv,z.message||String(z)))})}function ST(s,n){let r=document.createElement("label");r.className="edit-field";let c=document.createElement("span");return c.textContent=s,r.append(c,n),r}function eDe(s,n){let r=s.value;s.innerHTML="";for(let c of n){let u=document.createElement("option");u.value=c,u.textContent=c,s.appendChild(u)}n.includes(r)&&(s.value=r)}function oH(s){return String(s??"").replace(/&/g,"&").replace(//g,">")}var A3t="#00ffff",Xdn="#ffff00",P3t="#ffffff",Ydn=4,pk=0,tDe=1,aH=2,ode=class{constructor(n,r,c,u){this._app=n,this._visibility=r,this._updateInspector=c,this._focusComponent=u,this._state=pk,this._rulers=[],this._nextId=0,this._pt0=null,this._selectedRulerId=null,this._ctrlHeld=!1,this._shiftHeld=!1,this._snapTimer=null,this._lastSnapResult=null,this._snapShapes=null,this._preview=null,n.view?.on("zoom",()=>this._renderRulerShapes())}isActive(){return this._state!==pk}updateVisibility(){this._renderAll(),this._drawTransient()}_shown(){return this._visibility.rulers!==!1}toggleRulerMode(){this._state===pk?this._enterFirstPoint():this.cancelRulerBuild()}cancelRulerBuild(){this._state=pk,this._pt0=null,this._lastSnapResult=null,this._clearTransient(),this._setCursor(!1)}clearAllRulers(){this._rulers=[],this._selectedRulerId=null,this._renderAll(),this._clearTransient(),this._state!==pk&&this.cancelRulerBuild()}_enterFirstPoint(){this._state=tDe,this._pt0=null,this._lastSnapResult=null,this._setCursor(!0)}_enterMeasuring(n){this._state=aH,this._pt0=n}_toDbu(n){return Pv(n[0],n[1],this._app.designScale,this._app.designOriginX,this._app.designOriginY)}_toWorld(n,r){return Av(n,r,this._app.designScale,this._app.designOriginX,this._app.designOriginY)}handleMouseMove(n,r){if(this._state===pk)return;this._ctrlHeld=r.ctrlKey||r.metaKey,this._shiftHeld=r.shiftKey;let c=this._toDbu(n);this._snapTimer&&clearTimeout(this._snapTimer),this._snapTimer=setTimeout(()=>{this._requestSnap(c.dbuX,c.dbuY)},50)}handleMapClick(n,r){if(this._state===pk)return;this._ctrlHeld=r.ctrlKey||r.metaKey,this._shiftHeld=r.shiftKey;let c=this._toDbu(n),u=this._getSnappedPoint(c.dbuX,c.dbuY);this._state===tDe?this._enterMeasuring(u):this._state===aH&&(this._createRuler(this._pt0,u),this._state=tDe,this._pt0=null,this._clearTransient(),this._lastSnapResult=null)}async _requestSnap(n,r){let c=this._app;if(!c.websocketManager||!c.designScale)return;if(this._ctrlHeld){this._lastSnapResult=null,this._snapShapes=null,this._updatePreview(n,r);return}let d=c.techData?.dbu_per_micron||1e3,b=c.view.getZoom(),w=Math.pow(2,Math.max(0,b)),_=1/(c.designScale*w),x=Math.max(Math.round(10*_),10),T=!0,M=!0;if(this._shiftHeld)T=!0,M=!0;else if(this._state===aH&&this._pt0){let I=Math.abs(n-this._pt0.x),D=Math.abs(r-this._pt0.y);I>D?(T=!1,M=!0):D>I&&(T=!0,M=!1)}let L={};for(let[I,D]of Object.entries(this._visibility))L[I]=!!D;try{let I=await c.websocketManager.request({type:"snap",dbu_x:n,dbu_y:r,radius:d,point_threshold:x,horizontal:!!T,vertical:!!M,visible_layers:[...c.visibleLayerNames],...L});this._lastSnapResult=I,this._updateSnapIndicator(I),this._updatePreview(n,r)}catch{this._lastSnapResult=null,this._clearSnap()}}_getSnappedPoint(n,r){if(this._ctrlHeld)return{x:n,y:r};let c=this._lastSnapResult,u;if(c?.found&&c.is_point)u={x:c.edge[0][0],y:c.edge[0][1]};else if(c?.found){let d=c.edge;d[0][1]===d[1][1]?u={x:n,y:d[0][1]}:u={x:d[0][0],y:r}}else u={x:n,y:r};if(!this._shiftHeld&&this._state===aH&&this._pt0){let d=Math.abs(u.x-this._pt0.x),b=Math.abs(u.y-this._pt0.y);dthis._toWorld(u.x,u.y))}}_rulerShapes(n){let r=n.id===this._selectedRulerId,c=Z1(r?Xdn:A3t),{joinPt:u,points:d}=this._rulerPath(n),b=[{kind:"path",points:d,stroke:c,width:2}],w=this._app.view.getZoom(),_=Math.pow(2,Math.max(0,w)),T=8*(1/(this._app.designScale*_)),M=(L,I,D)=>{let F=Math.sqrt(I*I+D*D);if(F===0)return;let O=-D/F,z=I/F;b.push({kind:"path",stroke:c,width:2,points:[this._toWorld(L.x+O*T,L.y+z*T),this._toWorld(L.x-O*T,L.y-z*T)]})};if(u)M(n.pt0,u.x-n.pt0.x,u.y-n.pt0.y),M(n.pt1,n.pt1.x-u.x,n.pt1.y-u.y);else{let L=n.pt1.x-n.pt0.x,I=n.pt1.y-n.pt0.y;M(n.pt0,L,I),M(n.pt1,L,I)}return b}_renderAll(){this._renderRulerShapes(),this._renderRulerLabels()}_renderRulerShapes(){let n=this._app.view;!n||!this._app.designScale||n.setOverlay("rulers",this._shown()?this._rulers.flatMap(r=>this._rulerShapes(r)):null,{order:mp.ruler})}_renderRulerLabels(){let n=this._app.view;if(!(!n||!this._app.designScale)&&(n.clearMarkers("ruler-labels"),!!this._shown()))for(let r of this._rulers){let{joinPt:c,points:u}=this._rulerPath(r),d=c?u[1]:[(u[0][0]+u[1][0])/2,(u[0][1]+u[1][1])/2],b=this._computeDistance(r.pt0,r.pt1,r.euclidian);n.addMarker("ruler-labels",r.id,d,this._labelElement(this._formatDistance(b)))}}handleRulerClick(n){let r=this._app.view;if(!r||!this._shown()||this._rulers.length===0)return!1;let c=r.project(n);for(let u of this._rulers){let d=this._rulerPath(u).points.map(b=>r.project(b));for(let b=0;b+1x.id===n);if(!r)return;Pm(this._app);let c=Math.abs(r.pt1.x-r.pt0.x),u=Math.abs(r.pt1.y-r.pt0.y),d=r.euclidian?Math.sqrt(c*c+u*u):c+u,b=x=>this._app.formatDbu(x,!0),w=x=>this._app.parseDbu(x),_={type:"Ruler",name:r.name,bbox:[Math.min(r.pt0.x,r.pt1.x),Math.min(r.pt0.y,r.pt1.y),Math.max(r.pt0.x,r.pt1.x),Math.max(r.pt0.y,r.pt1.y)],properties:[{name:"Name",value:r.name,editable:!0},{name:"Label",value:r.label||"",editable:!0},{name:"Point 0 - x",value:b(r.pt0.x),editable:!0},{name:"Point 0 - y",value:b(r.pt0.y),editable:!0},{name:"Point 1 - x",value:b(r.pt1.x),editable:!0},{name:"Point 1 - y",value:b(r.pt1.y),editable:!0},{name:"Delta x",value:b(c)},{name:"Delta y",value:b(u)},{name:"Length",value:b(d)},{name:"Euclidian",value:r.euclidian?"True":"False",editable:!0,editor:{type:"bool"}}],onPropertyChange:(x,T)=>{switch(x){case"Name":r.name=T;break;case"Label":r.label=T;break;case"Point 0 - x":{let M=w(T);M!==null&&(r.pt0.x=M);break}case"Point 0 - y":{let M=w(T);M!==null&&(r.pt0.y=M);break}case"Point 1 - x":{let M=w(T);M!==null&&(r.pt1.x=M);break}case"Point 1 - y":{let M=w(T);M!==null&&(r.pt1.y=M);break}case"Euclidian":r.euclidian=T.trim().toLowerCase()==="true";break}this._renderAll(),this._selectRuler(r.id)}};this._updateInspector(_),this._focusComponent("Inspector"),requestAnimationFrame(()=>{let x=this._app.inspectorEl?.querySelector(".inspector-toolbar");if(!x)return;let T=document.createElement("button");T.className="or-btn or-btn-icon",T.title="Delete ruler",T.innerHTML='',T.addEventListener("click",()=>{this.deleteRuler(n)}),x.appendChild(T)})}deleteRuler(n){let r=this._rulers.findIndex(c=>c.id===n);r!==-1&&(this._rulers.splice(r,1),this._renderAll(),this._selectedRulerId===n&&(this._selectedRulerId=null,this._updateInspector(null)))}_getManhattanJoinPt(n,r){return{x:r.x,y:n.y}}_computeDistance(n,r,c=!0){let u=Math.abs(r.x-n.x),d=Math.abs(r.y-n.y);return c?Math.sqrt(u*u+d*d):u+d}_formatDistance(n){return this._app.formatDistance(n)}_setCursor(n){this._app.view?.setCursorMode("ruler",n)}_clearTransient(){this._preview=null,this._snapShapes=null,this._drawTransient()}_clearSnap(){this._snapShapes=null,this._drawTransient()}};function Zdn(s,n,r){let c=r[0]-n[0],u=r[1]-n[1],d=c*c+u*u,b=d>0?((s[0]-n[0])*c+(s[1]-n[1])*u)/d:0;return b=Math.max(0,Math.min(1,b)),Math.hypot(s[0]-(n[0]+b*c),s[1]-(n[1]+b*u))}var ade="label-handles",L3t=3,cde=class{constructor(n,r,c,u){this._app=n,this._visibility=r,this._updateInspector=c,this._focusComponent=u,this._labels=[],this._anchors=[],this._mode=!1,this._selectedName=null}isActive(){return this._mode}updateVisibility(){this._app.view?.setMarkerGroupVisible(ade,!!this._visibility.labels)}toggleLabelMode(){this._mode=!this._mode,this._setCursor(this._mode)}cancelLabelMode(){this._mode=!1,this._setCursor(!1)}_setCursor(n){this._app.view?.setCursorMode("label",n)}_wm(){return this._app.websocketManager}_applyLabels(n){this._labels=n||[],this._renderHandles()}_refresh(n){this._applyLabels(n&&n.labels),this._app.refreshOverlay()}applyRemoteLabels(n){this._applyLabels(n),this._selectedName&&!this._labels.some(r=>r.name===this._selectedName)&&(this._selectedName=null,this._updateInspector(null),this._renderHandles()),this._app.refreshOverlay()}_updateLabel(n,r){return this._wm().request({type:"update_label",name:n,...r})}async reload(){let n=this._wm();if(n)try{let r=await n.request({type:"list_labels"});this._anchors=r.anchors||[],this._applyLabels(r.labels)}catch{this._applyLabels([])}}async handleMapClick(n,r){let c=window.prompt("Label text:");if(this._mode=!1,this._setCursor(!1),!!c)try{let u=await this._wm().request({type:"add_label",x:Math.round(n),y:Math.round(r),text:c});this._refresh(u)}catch(u){console.error("add_label failed:",u)}}_renderHandles(){let n=this._app.view;if(!n)return;n.clearMarkers(ade);let r=this._app;if(r.designScale)for(let c of this._labels){let u=document.createElement("div");u.className="label-handle"+(c.name===this._selectedName?" label-handle-selected":""),u.title=c.text,this._installDrag(u,c),n.addMarker(ade,c.name,Av(c.x,c.y,r.designScale,r.designOriginX,r.designOriginY),u,{center:!0})}}_installDrag(n,r){let c=this._app.view,u=w=>{let _=c.getContainer().getBoundingClientRect();return c.unproject([w.clientX-_.left,w.clientY-_.top])},d=null;n.addEventListener("pointerdown",w=>{w.button===0&&(w.stopPropagation(),w.preventDefault(),n.setPointerCapture?.(w.pointerId),d={x:w.clientX,y:w.clientY,moved:!1})}),n.addEventListener("pointermove",w=>{d&&((Math.abs(w.clientX-d.x)>L3t||Math.abs(w.clientY-d.y)>L3t)&&(d.moved=!0),d.moved&&c.moveMarker(ade,r.name,u(w)))});let b=(w,_)=>{if(!d)return;let x=d;if(d=null,n.releasePointerCapture?.(w.pointerId),!_)this._renderHandles();else if(!x.moved)this._select(r.name);else{let T=this._app,[M,L]=u(w),{dbuX:I,dbuY:D}=Pv(M,L,T.designScale,T.designOriginX,T.designOriginY);this._commitMove(r,Math.round(I),Math.round(D))}};n.addEventListener("pointerup",w=>b(w,!0)),n.addEventListener("pointercancel",w=>b(w,!1)),n.addEventListener("click",w=>w.stopPropagation())}async _commitMove(n,r,c){try{let u=await this._updateLabel(n.name,{x:r,y:c,text:n.text,size:n.size||0,anchor:n.anchor||"center",color:n.color});this._refresh(u)}catch(u){console.error("move label failed:",u)}}_select(n){this._selectedName=n,this._renderHandles();let r=this._labels.find(d=>d.name===n);if(!r)return;let c=d=>this._app.formatDbu(d,!0),u={type:"Label",name:r.name,bbox:[r.x,r.y,r.x,r.y],properties:[{name:"Name",value:r.name},{name:"Text",value:r.text,editable:!0},{name:"x",value:c(r.x)},{name:"y",value:c(r.y)},{name:"Font size",value:String(r.size||0),editable:!0},{name:"Anchor",value:r.anchor||"center",editable:!0,editor:{type:"list",options:this._anchors}}],onPropertyChange:(d,b)=>{let w={text:r.text,size:r.size||0,anchor:r.anchor||"center"};d==="Text"?w.text=b:d==="Font size"?w.size=parseInt(b,10)||0:d==="Anchor"&&(w.anchor=b.trim()),this._edit(r,w)}};this._updateInspector(u),this._focusComponent("Inspector"),requestAnimationFrame(()=>{let d=this._app.inspectorEl?.querySelector(".inspector-toolbar");if(!d||d.querySelector(".delete-label-btn"))return;let b=document.createElement("button");b.className="or-btn or-btn-icon delete-label-btn",b.title="Delete label",b.innerHTML='',b.addEventListener("click",()=>this.deleteLabel(n)),d.appendChild(b)})}async _edit(n,r){try{let c=await this._updateLabel(n.name,{x:n.x,y:n.y,text:r.text,size:r.size,anchor:r.anchor,color:n.color});this._refresh(c),this._select(n.name)}catch(c){console.error("edit label failed:",c)}}async deleteLabel(n){try{let r=await this._wm().request({type:"delete_label",name:n});this._selectedName===n&&(this._selectedName=null,this._updateInspector(null)),this._refresh(r)}catch(r){console.error("delete_label failed:",r)}}async clearAllLabels(){try{let n=await this._wm().request({type:"clear_labels"});this._selectedName=null,this._refresh(n)}catch(n){console.error("clear_labels failed:",n)}}};var k3t="Select an instance in the layout to view its schematic.",lde=class{constructor(n,r){this.container=n,this.appState=r,this.element=document.createElement("div"),this.element.className="schematic-widget",this.element.style.cssText="width:100%; height:100%; display:flex; flex-direction:column; background:var(--bg-panel); color:var(--fg-primary); overflow:hidden;",this.controls=document.createElement("div"),this.controls.style.cssText="padding:4px 8px; background:var(--bg-header); border-bottom:1px solid var(--border);flex-shrink:0; display:flex; align-items:center; gap:8px; flex-wrap:wrap;",this.controls.innerHTML='',this.element.appendChild(this.controls),this.svgContainer=document.createElement("div"),this.svgContainer.style.cssText="flex:1; overflow:hidden; position:relative; cursor:grab; background:var(--bg-main);",this.element.appendChild(this.svgContainer),this.container.element.appendChild(this.element),this.controls.querySelector("#schematic-refresh").addEventListener("click",()=>this.refresh()),this.controls.querySelector("#schematic-fit").addEventListener("click",()=>this.fitView()),this.controls.querySelector("#schematic-zoom-in").addEventListener("click",()=>this._zoomStep(1.5)),this.controls.querySelector("#schematic-zoom-out").addEventListener("click",()=>this._zoomStep(1/1.5)),this.controls.querySelector("#schematic-select").addEventListener("click",()=>this._toggleSelectMode()),this.controls.querySelector("#schematic-zoom-to").addEventListener("click",()=>this._zoomToSelected()),this.controls.querySelector("#schematic-save-svg").addEventListener("click",()=>this._exportSvg()),this.controls.querySelector("#schematic-save-png").addEventListener("click",()=>this._exportPng()),this.controls.querySelector("#schematic-copy").addEventListener("click",()=>this._copyImage()),this.appState.schematicWidget=this,this.netlistsvg=null,this.skin=null,this._svgEl=null,this._scale=1,this._panX=0,this._panY=0,this._selectMode=!1,this._selectedCell=null,this._svgIdToInstName=new Map,this._setupPanZoom(),this.initNetlistSVG()}_setupPanZoom(){let n=this.svgContainer,r=!1,c,u,d,b;n.addEventListener("wheel",w=>{if(!this._svgEl)return;w.preventDefault();let _=w.deltaY<0?1.2:1/1.2,x=n.getBoundingClientRect(),T=w.clientX-x.left,M=w.clientY-x.top;this._panX=T+(this._panX-T)*_,this._panY=M+(this._panY-M)*_,this._scale*=_,this._applyTransform()},{passive:!1}),n.addEventListener("mousedown",w=>{if(!(!this._svgEl||w.button!==0)){if(this._selectMode){this._handleSelectClick(w);return}r=!0,c=w.clientX,u=w.clientY,d=this._panX,b=this._panY,n.style.cursor="grabbing",w.preventDefault()}}),window.addEventListener("mousemove",w=>{r&&(this._panX=d+(w.clientX-c),this._panY=b+(w.clientY-u),this._applyTransform())}),window.addEventListener("mouseup",()=>{r&&(r=!1,n.style.cursor=this._selectMode?"default":"grab")})}_zoomStep(n){if(!this._svgEl)return;let r=this.svgContainer.getBoundingClientRect(),c=r.width/2,u=r.height/2;this._panX=c+(this._panX-c)*n,this._panY=u+(this._panY-u)*n,this._scale*=n,this._applyTransform()}_toggleSelectMode(){this._selectMode=!this._selectMode;let n=this.controls.querySelector("#schematic-select");this._selectMode?(n.style.background="var(--accent)",n.style.color="var(--fg-white)",this.svgContainer.style.cursor="default"):(n.style.background="",n.style.color="",this.svgContainer.style.cursor="grab",this._clearCellHighlight())}_handleSelectClick(n){if(!this._svgEl)return;let r=n.target,c=null;for(;r&&r!==this._svgEl;){if(r.tagName==="g"&&r.id&&this._svgIdToInstName.has(r.id)){c=r;break}r=r.parentElement}if(this._clearCellHighlight(),!c)return;let u=this._svgIdToInstName.get(c.id);try{let d=c.getBBox(),b=3,w=document.createElementNS("http://www.w3.org/2000/svg","rect");w.setAttribute("x",d.x-b),w.setAttribute("y",d.y-b),w.setAttribute("width",d.width+b*2),w.setAttribute("height",d.height+b*2),w.setAttribute("fill","none"),w.setAttribute("stroke","#e05a00"),w.setAttribute("stroke-width","1.5"),w.setAttribute("rx","3"),w.id="_schematic_highlight",c.appendChild(w),this._selectedCell=c}catch{}this.controls.querySelector("#schematic-zoom-to").disabled=!1,this.setStatus(`Selected: ${u}`),this._fetchInspect(u)}_fetchInspect(n){let r=this.appState.websocketManager;if(!r)return;console.log("[Schematic] inspect:",n);let c=Pm(this.appState);r.request({type:"schematic_inspect",inst_name:n,use_dbu:this.appState.showDbu}).then(u=>{Y1(this.appState,c)&&(this.appState.updateInspector&&this.appState.updateInspector(u),this.appState.focusComponent&&this.appState.focusComponent("Inspector"),this.appState.refreshOverlay&&this.appState.refreshOverlay())}).catch(u=>{console.error("schematic_inspect failed:",u),this.setStatus(`Inspect error: ${u}`)})}_clearCellHighlight(){if(this._svgEl){let n=this._svgEl.querySelector("#_schematic_highlight");n&&n.remove()}this._selectedCell=null,this.controls.querySelector("#schematic-zoom-to").disabled=!0}_zoomToSelected(){if(!this._selectedCell||!this._svgEl)return;let n=this.svgContainer.getBoundingClientRect(),r=this._selectedCell.getBoundingClientRect(),c=(r.left-n.left-this._panX)/this._scale,u=(r.top-n.top-this._panY)/this._scale,d=r.width/this._scale,b=r.height/this._scale,w=Math.min(n.width/d,n.height/b)*.9;this._scale=w,this._panX=n.width/2-(c+d/2)*w,this._panY=n.height/2-(u+b/2)*w,this._applyTransform()}_applyTransform(){this._svgEl&&(this._svgEl.style.transform=`translate(${this._panX}px, ${this._panY}px) scale(${this._scale})`,this._svgEl.style.transformOrigin="0 0")}fitView(){if(!this._svgEl)return;let n=this.svgContainer.getBoundingClientRect();if(n.width===0||n.height===0)return;let r=this._svgEl.viewBox&&this._svgEl.viewBox.baseVal,c=r&&r.width||this._svgEl.clientWidth||1,u=r&&r.height||this._svgEl.clientHeight||1;this._scale=Math.min(n.width/c,n.height/u)*.95,this._panX=(n.width-c*this._scale)/2,this._panY=(n.height-u*this._scale)/2,this._applyTransform()}initNetlistSVG(){this.netlistsvg=globalThis.netlistsvg,this.skin=globalThis.openroadSkin,this._netlistsvgReady=!!(this.netlistsvg&&this.skin),this._netlistsvgReady&&console.log("NetlistSVG ready."),this.setStatus(this._unreadyStatus()??k3t)}_unreadyStatus(){return this._netlistsvgReady?null:la(this.appState)?"The schematic is not available in saved reports.":"Init error: netlistsvg or its skin is missing from the page."}syncCone(n={}){let r=this.controls.querySelector("#schematic-fanin-depth"),c=this.controls.querySelector("#schematic-fanout-depth"),u=(d,b,w)=>{if(!d)return;let _=parseInt(d.max,10)||10;b===!1?d.value=0:w!==void 0&&(d.value=w>0?Math.min(w,_):_)};u(r,n.fanin,n.fanin_depth),u(c,n.fanout,n.fanout_depth),this.refresh(),this.appState.focusComponent&&this.appState.focusComponent("SchematicWidget")}refresh(){if(!this._netlistsvgReady){this.setStatus(this._unreadyStatus());return}let n=this.appState.selectedInstanceName;if(!n){this.setStatus(k3t);return}let r=this.appState.websocketManager;if(!r){this.setStatus("Waiting for server connection\u2026");return}this.setStatus(`Loading schematic for ${n}\u2026`);let c=parseInt(this.controls.querySelector("#schematic-fanin-depth").value,10),u=parseInt(this.controls.querySelector("#schematic-fanout-depth").value,10),d=isNaN(c)?1:c,b=isNaN(u)?1:u;r.readyPromise.then(()=>{r.request({type:"schematic_cone",inst_name:n,fanin_depth:d,fanout_depth:b}).then(w=>{let _=w.modules&&w.modules.top&&w.modules.top.cells;if(!_||Object.keys(_).length===0){this.setStatus("No cells found for selected instance.");return}this.renderNetlist(w)}).catch(w=>{this.setStatus(`Error: ${w}`)})})}setStatus(n){this.controls.querySelector("#schematic-status").textContent=n}_exportSvg(){if(!this._svgEl){this.setStatus("No schematic to export.");return}let n=X5e(this._svgEl);r3t(new Blob([n],{type:"image/svg+xml;charset=utf-8"}),"schematic.svg")}async _exportPng(){if(!this._svgEl){this.setStatus("No schematic to export.");return}try{let n=await Y5e(this._svgEl,2);hk(n,"schematic.png")}catch{this.setStatus("PNG export failed.")}}async _copyImage(){if(!this._svgEl){this.setStatus("No schematic to export.");return}try{let n=await Y5e(this._svgEl,2),r=await Hhe(n);this.setStatus(r?"Schematic copied to clipboard.":"Clipboard not available.")}catch{this.setStatus("Copy failed.")}}async renderNetlist(n){try{this.setStatus("Rendering\u2026"),typeof window<"u"&&(window.__lastSchematic=n);let r=tpn(n),c,u=this.netlistsvg.render(this.skin,r);if(u&&typeof u.then=="function"?c=await u:c=await new Promise((w,_)=>{this.netlistsvg.render(this.skin,r,(x,T)=>{x?_(x):w(T)})}),typeof c!="string"||!c.includes("requestAnimationFrame(()=>this.fitView()));let b=Object.keys(n.modules.top.cells).length;this.setStatus(`${b} cell${b!==1?"s":""}`)}catch(r){console.error("NetlistSVG render failed:",r),this.setStatus(`Render error: ${r.message||r}`)}}_applyPinLabels(n){if(!this._svgEl)return;let r="http://www.w3.org/2000/svg",c="https://github.com/nturley/netlistsvg",u=n.modules&&n.modules.top&&n.modules.top.cells||{},d=(b,w)=>b.getAttribute("s:"+w)??b.getAttributeNS(c,w);for(let[b,w]of Object.entries(u)){let _=w.port_labels;if(!_)continue;let x=this._svgEl.querySelector("#"+CSS.escape("cell_"+b))||this._svgEl.querySelector("#"+CSS.escape(b));if(!x)continue;let T=w.port_directions||{};for(let M of Array.from(x.children)){if(M.tagName!=="g")continue;let L=d(M,"pid");if(!L||!(L in _))continue;let I=parseFloat(d(M,"x")),D=parseFloat(d(M,"y"));if(!isFinite(I)||!isFinite(D))continue;let F=document.createElementNS(r,"text");T[L]==="input"?(F.setAttribute("class","inputPortLabel"),F.setAttribute("x",I-3)):F.setAttribute("x",I+4),F.setAttribute("y",D-4),F.setAttribute("style","font-size:5px"),F.setAttribute("pointer-events","none"),F.textContent=_[L],x.appendChild(F)}}}_scopeSkinStyles(){if(!this._svgEl)return;let n=".schematic-widget",r=c=>{for(let u of c)u.selectorText?u.selectorText=Kdn(u.selectorText,n):u.cssRules&&r(u.cssRules)};for(let c of this._svgEl.querySelectorAll("style")){let u=c.sheet;if(u)try{r(u.cssRules)}catch{continue}}}};function Kdn(s,n){return s.split(",").map(r=>{let c=r.trim();if(!c)return"";let u=c.charAt(n.length);return c.startsWith(n)&&(u===""||!/[\w-]/.test(u))?c:`${n} ${c}`}).filter(Boolean).join(", ")}var R3t={and:"$_AND_",nand:"$_NAND_",or:"$_OR_",nor:"$_NOR_",xor:"$_XOR_",xnor:"$_XNOR_",not:"$_NOT_",buf:"$_BUF_"},Jdn=new Set(["aoi21","aoi22","aoi211","aoi221","aoi222","aoi33","oai21","oai22","oai211","oai221","oai222","oai33"]),Qdn=new Set(["and3","and4","or3","or4","nand3","nand4","nor3","nor4"]),I3t=["A","B","C","D","E","F"];function epn(s){let n=s&&s.gate_kind;if(!n)return s;let r=s.port_directions||{},c=null,u=[];for(let[M,L]of Object.entries(r))L==="output"&&c===null?c=M:L==="input"&&u.push(M);let d,b={};if(n==="aoi"||n==="oai"){let M=Array.isArray(s.gate_terms)?s.gate_terms:[];if(!M.length)return s;let L=M.map(F=>F.length);if(d=n+L.slice().sort((F,O)=>O-F).join(""),!Jdn.has(d))return s;let I=M.map(F=>F.slice()).sort((F,O)=>F.length-O.length),D=0;for(let F of I)for(let O of F)b[O]=I3t[D]||"I"+D,D++}else{let M=u.length;if(n==="not"||n==="buf")d=R3t[n];else if(M<=2)d=R3t[n];else if(d=n+M,!Qdn.has(d))return s;if(!d)return s;u.forEach((L,I)=>{b[L]=I3t[I]||"I"+I})}c!==null&&(b[c]="Y");let w=s.connections||{},_={},x={};for(let[M,L]of Object.entries(w))b[M]&&(_[b[M]]=L);for(let[M,L]of Object.entries(r))b[M]&&(x[b[M]]=L);let T={};for(let[M,L]of Object.entries(b))T[L]=M;return{...s,type:d,connections:_,port_directions:x,port_labels:T}}function tpn(s){let n=s&&s.modules&&s.modules.top;if(!n||!n.cells)return s;let r={};for(let[c,u]of Object.entries(n.cells))r[c]=epn(u);return{...s,modules:{...s.modules,top:{...n,cells:r}}}}var ude=class{constructor(n,r,c){this._app=n,this._redrawAllLayers=r,this._refreshOverlay=c||r,this._categories=[],this._activeCategory="",this._markerTree=null,this._expandedNodes=new Set,this._build(),this._app.websocketManager.readyPromise.then(()=>this.refresh())}_build(){let n=document.createElement("div");n.className="drc-widget";let r=document.createElement("div");r.className="drc-toolbar",this._categorySelect=document.createElement("select"),this._categorySelect.className="drc-category-select",r.appendChild(this._categorySelect),this._loadBtn=document.createElement("button"),this._loadBtn.className="or-btn or-btn-sm",this._loadBtn.textContent="Load...",r.appendChild(this._loadBtn),n.appendChild(r),this._infoBar=document.createElement("div"),this._infoBar.className="drc-info-bar",n.appendChild(this._infoBar),this._treeContainer=document.createElement("div"),this._treeContainer.className="drc-tree-container",n.appendChild(this._treeContainer),this.element=n,this._bindEvents()}_bindEvents(){this._categorySelect.addEventListener("change",()=>{this._activeCategory=this._categorySelect.value,this._loadMarkers()}),this._loadBtn.addEventListener("click",()=>{this._showLoadDialog()})}_loadCategories(){return this._app.websocketManager.request({type:"drc_categories"}).then(n=>{this._categories=n.categories||[],this._renderCategorySelect()}).catch(n=>{console.error("Failed to load DRC categories:",n)})}refresh(){this._loadCategories().then(()=>{!this._activeCategory&&this._categories.length>0&&(this._activeCategory=this._categories[0].name,this._categorySelect.value=this._activeCategory),this._activeCategory&&this._loadMarkers()})}_renderCategorySelect(){let n=this._categorySelect,r=n.value;n.innerHTML="";let c=document.createElement("option");c.value="",c.textContent="(none)",n.appendChild(c);for(let u of this._categories){let d=document.createElement("option");d.value=u.name,d.textContent=`${u.name} (${u.count})`,n.appendChild(d)}this._activeCategory&&this._categories.some(u=>u.name===this._activeCategory)?n.value=this._activeCategory:r&&this._categories.some(u=>u.name===r)?(n.value=r,this._activeCategory=r):this._activeCategory=""}_loadMarkers(){if(!this._activeCategory){this._markerTree=null,this._treeContainer.innerHTML="",this._infoBar.textContent="",this._refreshOverlay();return}this._treeContainer.innerHTML='
Loading...
',this._app.websocketManager.request({type:"drc_markers",category:this._activeCategory}).then(n=>{this._markerTree=n,this._renderTree(),this._refreshOverlay()}).catch(n=>{this._treeContainer.innerHTML="";let r=document.createElement("div");r.className="drc-error",r.textContent=`Error: ${n}`,this._treeContainer.appendChild(r),console.error("Failed to load DRC markers:",n)})}_renderTree(){if(this._treeContainer.innerHTML="",!this._markerTree)return;if(this._markerTree.error){let b=document.createElement("div");b.className="drc-error",b.textContent=this._markerTree.error,this._treeContainer.appendChild(b);return}let n=this._markerTree.total_count||0;this._infoBar.textContent=`${n} total violation${n!==1?"s":""}`;let r=this._markerTree.name||this._activeCategory,c=this._markerTree.subcategories||[],u=this._markerTree.markers||[];if(c.length===0&&u.length===0){this._treeContainer.innerHTML='
No violations
';return}let d=document.createElement("div");d.className="drc-tree",u.length>0&&d.appendChild(this._buildCategoryNode({name:r||"Markers",count:u.length,markers:u},[]));for(let b of c)d.appendChild(this._buildCategoryNode(b,[r]));this._treeContainer.appendChild(d)}_buildCategoryNode(n,r=[]){let c=[...r,n.name],u=document.createElement("div");u.className="drc-tree-node";let d=document.createElement("div");d.className="drc-tree-header";let b=document.createElement("span");b.className="drc-toggle";let w=n.subcategories&&n.subcategories.length>0||n.markers&&n.markers.length>0,_=JSON.stringify(c),x=this._expandedNodes.has(_);b.textContent=w?x?"\u25BC":"\u25B6":" ",d.appendChild(b);let T=document.createElement("input");T.type="checkbox",T.checked=this._allMarkersVisible(n),T.className="drc-visibility-check",T.addEventListener("change",D=>{D.stopPropagation(),this._toggleCategoryVisibility(n,T.checked,c)}),d.appendChild(T);let M=document.createElement("span");M.className="drc-category-label",M.textContent=n.name,d.appendChild(M);let L=document.createElement("span");L.className="drc-count",L.textContent=`${n.count} markers`,d.appendChild(L),u.appendChild(d);let I=document.createElement("div");if(I.className="drc-tree-children",I.style.display=x?"":"none",n.subcategories)for(let D of n.subcategories)I.appendChild(this._buildCategoryNode(D,c));if(n.markers)for(let D of n.markers)I.appendChild(this._buildMarkerNode(D));return u.appendChild(I),w&&(d.addEventListener("click",D=>{if(D.target===T)return;let F=I.style.display!=="none";I.style.display=F?"none":"",b.textContent=F?"\u25B6":"\u25BC",F?this._expandedNodes.delete(_):this._expandedNodes.add(_)}),d.style.cursor="pointer"),u}_buildMarkerNode(n){let r=document.createElement("div");r.className="drc-marker-row",r.dataset.markerId=n.id,n.visited||r.classList.add("drc-unvisited");let c=document.createElement("input");c.type="checkbox",c.checked=n.visible,c.className="drc-visibility-check",c.addEventListener("change",b=>{b.stopPropagation(),n.visible=c.checked,this._updateMarker(n.id,"visible",c.checked)}),r.appendChild(c);let u=document.createElement("span");u.className="drc-marker-index",u.textContent=n.index,r.appendChild(u);let d=document.createElement("span");if(d.className="drc-marker-name",d.textContent=n.name,n.layer&&(d.title=`Layer: ${n.layer}`),r.appendChild(d),n.layer){let b=document.createElement("span");b.className="drc-layer-badge",b.textContent=n.layer,r.appendChild(b)}return r.addEventListener("click",b=>{b.target!==c&&this._highlightMarker(n)}),r.addEventListener("dblclick",b=>{b.target!==c&&this._highlightMarker(n,!0)}),r}highlightMarkerById(n,r=!1){let c=this._findMarkerById(n);c&&this._highlightMarker(c,r)}_findMarkerById(n){let r=c=>{if(!c)return null;if(c.markers){for(let u of c.markers)if(u.id===n)return u}if(c.subcategories)for(let u of c.subcategories){let d=r(u);if(d)return d}return null};return r(this._markerTree)}_highlightMarker(n,r=!1){this._app.websocketManager.request({type:"drc_highlight",marker_id:n.id,open_inspector:r}).then(c=>{if(c.ok&&c.bbox){n.visited=!0;let u=this._treeContainer.querySelector(`.drc-marker-row[data-marker-id="${n.id}"]`);u&&u.classList.remove("drc-unvisited"),this._zoomToBBox(c.bbox),this._refreshOverlay(),r&&(c.select_id!=null&&this._app.navigateInspector&&this._app.navigateInspector(c.select_id),this._app.focusComponent&&this._app.focusComponent("Inspector"))}}).catch(c=>{console.error("Failed to highlight DRC marker:",c)})}_zoomToBBox(n){if(!this._app.designScale||!this._app.view)return;let[r,c,u,d]=n,b=u-r,w=d-c,x=10*this._app.getDbuPerMicron(),T=2*Math.max(b,w),M=Math.min(x,T);this._app.view.fitWorldRect(X1(r-M,c-M,u+M,d+M,this._app.designScale,this._app.designOriginX,this._app.designOriginY))}_updateMarker(n,r,c){this._app.websocketManager.request({type:"drc_update_marker",marker_id:n,field:r,value:!!c}).then(()=>{this._refreshOverlay(),r==="visible"&&(this._update3DHighlights(),c&&this._flashHighlight())}).catch(u=>{console.error("Failed to update DRC marker:",u)})}_flashHighlight(){this._app.view?.flashTiles()}_update3DHighlights(){let n=this._app.threeDViewerWidget;if(!n)return;let r=[];this._collectVisibleMarkers(this._markerTree,r),r.length>0?n.highlightDRC(r):n.clearHighlightDRC()}_collectVisibleMarkers(n,r){if(n){if(n.markers)for(let c of n.markers)c.visible&&r.push(c);if(n.subcategories)for(let c of n.subcategories)this._collectVisibleMarkers(c,r)}}_setMarkersVisible(n,r){if(n){if(n.markers)for(let c of n.markers)c.visible=r;if(n.subcategories)for(let c of n.subcategories)this._setMarkersVisible(c,r)}}_snapshotMarkerVisibility(n,r=new Map){if(!n)return r;if(n.markers)for(let c of n.markers)r.set(c.id,c.visible);if(n.subcategories)for(let c of n.subcategories)this._snapshotMarkerVisibility(c,r);return r}_restoreMarkerVisibility(n,r){if(n){if(n.markers)for(let c of n.markers)r.has(c.id)&&(c.visible=r.get(c.id));if(n.subcategories)for(let c of n.subcategories)this._restoreMarkerVisibility(c,r)}}_allMarkersVisible(n){if(n.markers){for(let r of n.markers)if(!r.visible)return!1}if(n.subcategories){for(let r of n.subcategories)if(!this._allMarkersVisible(r))return!1}return!0}_toggleCategoryVisibility(n,r,c){let u=this._snapshotMarkerVisibility(n);this._setMarkersVisible(n,r),this._renderTree(),this._app.websocketManager.request({type:"drc_update_category_visibility",category:n.name,path:c||[n.name],visible:!!r}).then(()=>{this._refreshOverlay(),this._update3DHighlights(),r&&this._flashHighlight()}).catch(d=>{console.error("Failed to update category visibility:",d),this._restoreMarkerVisibility(n,u),this._renderTree()})}_showLoadDialog(){new nDe(this._app,r=>{this._activeCategory=r,this._loadCategories().then(()=>{this._categorySelect.value=this._activeCategory,this._loadMarkers()})}).open()}selectCategory(n){this._activeCategory=n,this._categorySelect.value=n,this._loadMarkers()}},nDe=class{constructor(n,r){this._app=n,this._onLoaded=r,this._currentPath="",this._disposers=[],this._closed=!1}open(){this._overlay=document.createElement("div"),this._overlay.className="modal-overlay",this._overlay.innerHTML=` + `,document.body.appendChild(r);function c(d){d.key==="Escape"&&u()}let u=()=>{r.remove(),document.removeEventListener("keydown",c)};return r.addEventListener("click",d=>{d.target===r&&u()}),document.addEventListener("keydown",c),{overlay:r,body:r.querySelector(".modal-body"),errorDiv:r.querySelector(".modal-error"),buttons:r.querySelector(".modal-buttons"),close:u}}function g2(s,n){s.textContent=n,s.style.display=n?"":"none"}function AO(s,n,{primary:r=!1}={}){let c=document.createElement("button");return c.textContent=n,c.className="or-btn"+(r?" or-btn-primary":""),s.appendChild(c),c}function sde(s){return"{"+String(s)+"}"}function C3t(s){let n=T3t("Global Connect","gc-dialog"),r=document.createElement("div");r.className="gc-table",n.body.appendChild(r);let c=document.createElement("div");c.className="gc-form";let u=document.createElement("input");u.placeholder="Instance pattern (regex)",u.value=".*";let d=document.createElement("input");d.placeholder="Pin pattern (regex)";let b=document.createElement("select"),w=document.createElement("select"),_=document.createElement("span");_.innerHTML='',c.append(MT("Instance",u),MT("Pin",d),MT("Net",b),MT("Region",w),_);let x=AO(c,"Add rule");n.body.appendChild(c);function T(){let D=d.value.trim()!==""&&b.value!=="";for(let F of[u,d])try{new RegExp(F.value),F.classList.remove("gc-invalid")}catch{F.classList.add("gc-invalid"),D=!1}x.disabled=!D}u.addEventListener("input",T),d.addEventListener("input",T),b.addEventListener("change",T);function M(){s.websocketManager.request({type:"global_connect_info"}).then(D=>{r.innerHTML='
InstancePinNetRegion
',(D.rules||[]).forEach(F=>{let O=document.createElement("div");O.className="gc-row",O.innerHTML=`${oH(F.inst)}${oH(F.pin)}${oH(F.net)}${oH(F.region||"All")}`;let z=document.createElement("button");z.className="or-btn or-btn-sm or-btn-icon",z.textContent="\u2715",z.title="Delete rule",z.addEventListener("click",()=>{s.websocketManager.request({type:"global_connect_delete",inst:F.inst,pin:F.pin,net:F.net,region:F.region||""}).then(M).catch(Z=>g2(n.errorDiv,String(Z)))}),O.appendChild(z),r.appendChild(O)}),eDe(b,D.nets||[]),eDe(w,["All",...D.regions||[]]),T()}).catch(D=>g2(n.errorDiv,String(D)))}x.addEventListener("click",()=>{let D=c.querySelector('input[name="gc-pg"]:checked').value,F=`add_global_connection -net ${sde(b.value)} -inst_pattern ${sde(u.value||".*")} -pin_pattern ${sde(d.value)} -${D}`;w.value&&w.value!=="All"&&(F+=` -region ${sde(w.value)}`),M3t(s,F,n.errorDiv,"Rule added.",M)}),AO(n.buttons,"Apply (force)").addEventListener("click",()=>{s.websocketManager.request({type:"global_connect_apply",force:!0}).then(D=>{if(!D.had_rules){g2(n.errorDiv,"No global-connect rules defined \u2014 add a rule first.");return}g2(n.errorDiv,`Connected ${D.connected} pin(s).`),s.scheduleRedrawAllLayers&&s.scheduleRedrawAllLayers(),M()}).catch(D=>g2(n.errorDiv,D.message||String(D)))}),AO(n.buttons,"Clear all").addEventListener("click",()=>M3t(s,"clear_global_connect",n.errorDiv,"Rules cleared.",M)),AO(n.buttons,"Close").addEventListener("click",n.close),M()}function M3t(s,n,r,c,u){s.websocketManager.request({type:"tcl_eval",cmd:n}).then(d=>{if(d.is_error){g2(r,d.output||d.result||"Command failed");return}g2(r,c||""),s.scheduleRedrawAllLayers&&s.scheduleRedrawAllLayers(),u&&u()}).catch(d=>g2(r,d.message||String(d)))}function A3t(s,n){let r=T3t(`Insert Buffer \u2014 ${oH(n)}`,"buf-dialog"),c=AO(r.buttons,"Insert",{primary:!0});c.disabled=!0,AO(r.buttons,"Cancel").addEventListener("click",r.close),s.websocketManager.request({type:"buffer_info",net:n}).then(d=>{if(!d.can_buffer){r.body.textContent=d.error||"This net has multiple drivers and cannot be buffered.";return}Zdn(s,r,n,d,c)}).catch(d=>{r.body.textContent=String(d)})}function Zdn(s,n,r,c,u){let d=document.createElement("div");d.className="buf-pins";let b=c.drivers||[],w=c.loads||[],_=new Set;function x(){d.innerHTML="";let D=(F,O)=>{let z=document.createElement("label");z.className="buf-pin";let Z=document.createElement("input");Z.type="checkbox",Z.checked=_.has(F.id),Z.addEventListener("change",()=>{if(Z.checked){if(O)_.clear();else for(let H of b)_.delete(H.id);_.add(F.id)}else _.delete(F.id);x(),I()}),z.append(Z,document.createTextNode(" "+F.label)),d.appendChild(z)};b.forEach(F=>D(F,!0)),w.forEach(F=>D(F,!1))}b.length&&_.add(b[0].id),x();let T=document.createElement("select");eDe(T,c.masters||[]);let M=document.createElement("input");M.placeholder="Optional: new buffer name";let L=document.createElement("input");L.placeholder="Optional: new net name",n.body.append(MT("Pins to buffer",d),MT("Buffer master",T),MT("Buffer name",M),MT("Net name",L));function I(){u.disabled=_.size===0||!T.value}T.addEventListener("change",I),I(),u.addEventListener("click",()=>{let D=new Set(b.map(z=>z.id)),F=[..._],O=F.some(z=>D.has(z))?"driver":"loads";s.websocketManager.request({type:"insert_buffer",net:r,mode:O,pins:F,master:T.value,buf_name:M.value.trim(),net_name:L.value.trim()}).then(z=>{if(z.is_error||z.ok===!1){g2(n.errorDiv,z.error||z.result||"Insertion failed");return}n.close(),z.inst&&(s.selectedInstanceName=z.inst),s.scheduleRedrawAllLayers&&s.scheduleRedrawAllLayers()}).catch(z=>g2(n.errorDiv,z.message||String(z)))})}function MT(s,n){let r=document.createElement("label");r.className="edit-field";let c=document.createElement("span");return c.textContent=s,r.append(c,n),r}function eDe(s,n){let r=s.value;s.innerHTML="";for(let c of n){let u=document.createElement("option");u.value=c,u.textContent=c,s.appendChild(u)}n.includes(r)&&(s.value=r)}function oH(s){return String(s??"").replace(/&/g,"&").replace(//g,">")}var P3t="#00ffff",Kdn="#ffff00",L3t="#ffffff",Jdn=4,pk=0,tDe=1,aH=2,ode=class{constructor(n,r,c,u){this._app=n,this._visibility=r,this._updateInspector=c,this._focusComponent=u,this._state=pk,this._rulers=[],this._nextId=0,this._pt0=null,this._selectedRulerId=null,this._ctrlHeld=!1,this._shiftHeld=!1,this._snapTimer=null,this._lastSnapResult=null,this._snapShapes=null,this._preview=null,n.view?.on("zoom",()=>this._renderRulerShapes())}isActive(){return this._state!==pk}updateVisibility(){this._renderAll(),this._drawTransient()}_shown(){return this._visibility.rulers!==!1}toggleRulerMode(){this._state===pk?this._enterFirstPoint():this.cancelRulerBuild()}cancelRulerBuild(){this._state=pk,this._pt0=null,this._lastSnapResult=null,this._clearTransient(),this._setCursor(!1)}clearAllRulers(){this._rulers=[],this._selectedRulerId=null,this._renderAll(),this._clearTransient(),this._state!==pk&&this.cancelRulerBuild()}_enterFirstPoint(){this._state=tDe,this._pt0=null,this._lastSnapResult=null,this._setCursor(!0)}_enterMeasuring(n){this._state=aH,this._pt0=n}_toDbu(n){return kv(n[0],n[1],this._app.designScale,this._app.designOriginX,this._app.designOriginY)}_toWorld(n,r){return Lv(n,r,this._app.designScale,this._app.designOriginX,this._app.designOriginY)}handleMouseMove(n,r){if(this._state===pk)return;this._ctrlHeld=r.ctrlKey||r.metaKey,this._shiftHeld=r.shiftKey;let c=this._toDbu(n);this._snapTimer&&clearTimeout(this._snapTimer),this._snapTimer=setTimeout(()=>{this._requestSnap(c.dbuX,c.dbuY)},50)}handleMapClick(n,r){if(this._state===pk)return;this._ctrlHeld=r.ctrlKey||r.metaKey,this._shiftHeld=r.shiftKey;let c=this._toDbu(n),u=this._getSnappedPoint(c.dbuX,c.dbuY);this._state===tDe?this._enterMeasuring(u):this._state===aH&&(this._createRuler(this._pt0,u),this._state=tDe,this._pt0=null,this._clearTransient(),this._lastSnapResult=null)}async _requestSnap(n,r){let c=this._app;if(!c.websocketManager||!c.designScale)return;if(this._ctrlHeld){this._lastSnapResult=null,this._snapShapes=null,this._updatePreview(n,r);return}let d=c.techData?.dbu_per_micron||1e3,b=c.view.getZoom(),w=Math.pow(2,Math.max(0,b)),_=1/(c.designScale*w),x=Math.max(Math.round(10*_),10),T=!0,M=!0;if(this._shiftHeld)T=!0,M=!0;else if(this._state===aH&&this._pt0){let I=Math.abs(n-this._pt0.x),D=Math.abs(r-this._pt0.y);I>D?(T=!1,M=!0):D>I&&(T=!0,M=!1)}let L={};for(let[I,D]of Object.entries(this._visibility))L[I]=!!D;try{let I=await c.websocketManager.request({type:"snap",dbu_x:n,dbu_y:r,radius:d,point_threshold:x,horizontal:!!T,vertical:!!M,visible_layers:[...c.visibleLayerNames],...L});this._lastSnapResult=I,this._updateSnapIndicator(I),this._updatePreview(n,r)}catch{this._lastSnapResult=null,this._clearSnap()}}_getSnappedPoint(n,r){if(this._ctrlHeld)return{x:n,y:r};let c=this._lastSnapResult,u;if(c?.found&&c.is_point)u={x:c.edge[0][0],y:c.edge[0][1]};else if(c?.found){let d=c.edge;d[0][1]===d[1][1]?u={x:n,y:d[0][1]}:u={x:d[0][0],y:r}}else u={x:n,y:r};if(!this._shiftHeld&&this._state===aH&&this._pt0){let d=Math.abs(u.x-this._pt0.x),b=Math.abs(u.y-this._pt0.y);dthis._toWorld(u.x,u.y))}}_rulerShapes(n){let r=n.id===this._selectedRulerId,c=K1(r?Kdn:P3t),{joinPt:u,points:d}=this._rulerPath(n),b=[{kind:"path",points:d,stroke:c,width:2}],w=this._app.view.getZoom(),_=Math.pow(2,Math.max(0,w)),T=8*(1/(this._app.designScale*_)),M=(L,I,D)=>{let F=Math.sqrt(I*I+D*D);if(F===0)return;let O=-D/F,z=I/F;b.push({kind:"path",stroke:c,width:2,points:[this._toWorld(L.x+O*T,L.y+z*T),this._toWorld(L.x-O*T,L.y-z*T)]})};if(u)M(n.pt0,u.x-n.pt0.x,u.y-n.pt0.y),M(n.pt1,n.pt1.x-u.x,n.pt1.y-u.y);else{let L=n.pt1.x-n.pt0.x,I=n.pt1.y-n.pt0.y;M(n.pt0,L,I),M(n.pt1,L,I)}return b}_renderAll(){this._renderRulerShapes(),this._renderRulerLabels()}_renderRulerShapes(){let n=this._app.view;!n||!this._app.designScale||n.setOverlay("rulers",this._shown()?this._rulers.flatMap(r=>this._rulerShapes(r)):null,{order:bp.ruler})}_renderRulerLabels(){let n=this._app.view;if(!(!n||!this._app.designScale)&&(n.clearMarkers("ruler-labels"),!!this._shown()))for(let r of this._rulers){let{joinPt:c,points:u}=this._rulerPath(r),d=c?u[1]:[(u[0][0]+u[1][0])/2,(u[0][1]+u[1][1])/2],b=this._computeDistance(r.pt0,r.pt1,r.euclidian);n.addMarker("ruler-labels",r.id,d,this._labelElement(this._formatDistance(b)))}}handleRulerClick(n){let r=this._app.view;if(!r||!this._shown()||this._rulers.length===0)return!1;let c=r.project(n);for(let u of this._rulers){let d=this._rulerPath(u).points.map(b=>r.project(b));for(let b=0;b+1x.id===n);if(!r)return;Pm(this._app);let c=Math.abs(r.pt1.x-r.pt0.x),u=Math.abs(r.pt1.y-r.pt0.y),d=r.euclidian?Math.sqrt(c*c+u*u):c+u,b=x=>this._app.formatDbu(x,!0),w=x=>this._app.parseDbu(x),_={type:"Ruler",name:r.name,bbox:[Math.min(r.pt0.x,r.pt1.x),Math.min(r.pt0.y,r.pt1.y),Math.max(r.pt0.x,r.pt1.x),Math.max(r.pt0.y,r.pt1.y)],properties:[{name:"Name",value:r.name,editable:!0},{name:"Label",value:r.label||"",editable:!0},{name:"Point 0 - x",value:b(r.pt0.x),editable:!0},{name:"Point 0 - y",value:b(r.pt0.y),editable:!0},{name:"Point 1 - x",value:b(r.pt1.x),editable:!0},{name:"Point 1 - y",value:b(r.pt1.y),editable:!0},{name:"Delta x",value:b(c)},{name:"Delta y",value:b(u)},{name:"Length",value:b(d)},{name:"Euclidian",value:r.euclidian?"True":"False",editable:!0,editor:{type:"bool"}}],onPropertyChange:(x,T)=>{switch(x){case"Name":r.name=T;break;case"Label":r.label=T;break;case"Point 0 - x":{let M=w(T);M!==null&&(r.pt0.x=M);break}case"Point 0 - y":{let M=w(T);M!==null&&(r.pt0.y=M);break}case"Point 1 - x":{let M=w(T);M!==null&&(r.pt1.x=M);break}case"Point 1 - y":{let M=w(T);M!==null&&(r.pt1.y=M);break}case"Euclidian":r.euclidian=T.trim().toLowerCase()==="true";break}this._renderAll(),this._selectRuler(r.id)}};this._updateInspector(_),this._focusComponent("Inspector"),requestAnimationFrame(()=>{let x=this._app.inspectorEl?.querySelector(".inspector-toolbar");if(!x)return;let T=document.createElement("button");T.className="or-btn or-btn-icon",T.title="Delete ruler",T.innerHTML='',T.addEventListener("click",()=>{this.deleteRuler(n)}),x.appendChild(T)})}deleteRuler(n){let r=this._rulers.findIndex(c=>c.id===n);r!==-1&&(this._rulers.splice(r,1),this._renderAll(),this._selectedRulerId===n&&(this._selectedRulerId=null,this._updateInspector(null)))}_getManhattanJoinPt(n,r){return{x:r.x,y:n.y}}_computeDistance(n,r,c=!0){let u=Math.abs(r.x-n.x),d=Math.abs(r.y-n.y);return c?Math.sqrt(u*u+d*d):u+d}_formatDistance(n){return this._app.formatDistance(n)}_setCursor(n){this._app.view?.setCursorMode("ruler",n)}_clearTransient(){this._preview=null,this._snapShapes=null,this._drawTransient()}_clearSnap(){this._snapShapes=null,this._drawTransient()}};function Qdn(s,n,r){let c=r[0]-n[0],u=r[1]-n[1],d=c*c+u*u,b=d>0?((s[0]-n[0])*c+(s[1]-n[1])*u)/d:0;return b=Math.max(0,Math.min(1,b)),Math.hypot(s[0]-(n[0]+b*c),s[1]-(n[1]+b*u))}var ade="label-handles",k3t=3,cde=class{constructor(n,r,c,u){this._app=n,this._visibility=r,this._updateInspector=c,this._focusComponent=u,this._labels=[],this._anchors=[],this._mode=!1,this._selectedName=null}isActive(){return this._mode}updateVisibility(){this._app.view?.setMarkerGroupVisible(ade,!!this._visibility.labels)}toggleLabelMode(){this._mode=!this._mode,this._setCursor(this._mode)}cancelLabelMode(){this._mode=!1,this._setCursor(!1)}_setCursor(n){this._app.view?.setCursorMode("label",n)}_wm(){return this._app.websocketManager}_applyLabels(n){this._labels=n||[],this._renderHandles()}_refresh(n){this._applyLabels(n&&n.labels),this._app.refreshOverlay()}applyRemoteLabels(n){this._applyLabels(n),this._selectedName&&!this._labels.some(r=>r.name===this._selectedName)&&(this._selectedName=null,this._updateInspector(null),this._renderHandles()),this._app.refreshOverlay()}_updateLabel(n,r){return this._wm().request({type:"update_label",name:n,...r})}async reload(){let n=this._wm();if(n)try{let r=await n.request({type:"list_labels"});this._anchors=r.anchors||[],this._applyLabels(r.labels)}catch{this._applyLabels([])}}async handleMapClick(n,r){let c=window.prompt("Label text:");if(this._mode=!1,this._setCursor(!1),!!c)try{let u=await this._wm().request({type:"add_label",x:Math.round(n),y:Math.round(r),text:c});this._refresh(u)}catch(u){console.error("add_label failed:",u)}}_renderHandles(){let n=this._app.view;if(!n)return;n.clearMarkers(ade);let r=this._app;if(r.designScale)for(let c of this._labels){let u=document.createElement("div");u.className="label-handle"+(c.name===this._selectedName?" label-handle-selected":""),u.title=c.text,this._installDrag(u,c),n.addMarker(ade,c.name,Lv(c.x,c.y,r.designScale,r.designOriginX,r.designOriginY),u,{center:!0})}}_installDrag(n,r){let c=this._app.view,u=w=>{let _=c.getContainer().getBoundingClientRect();return c.unproject([w.clientX-_.left,w.clientY-_.top])},d=null;n.addEventListener("pointerdown",w=>{w.button===0&&(w.stopPropagation(),w.preventDefault(),n.setPointerCapture?.(w.pointerId),d={x:w.clientX,y:w.clientY,moved:!1})}),n.addEventListener("pointermove",w=>{d&&((Math.abs(w.clientX-d.x)>k3t||Math.abs(w.clientY-d.y)>k3t)&&(d.moved=!0),d.moved&&c.moveMarker(ade,r.name,u(w)))});let b=(w,_)=>{if(!d)return;let x=d;if(d=null,n.releasePointerCapture?.(w.pointerId),!_)this._renderHandles();else if(!x.moved)this._select(r.name);else{let T=this._app,[M,L]=u(w),{dbuX:I,dbuY:D}=kv(M,L,T.designScale,T.designOriginX,T.designOriginY);this._commitMove(r,Math.round(I),Math.round(D))}};n.addEventListener("pointerup",w=>b(w,!0)),n.addEventListener("pointercancel",w=>b(w,!1)),n.addEventListener("click",w=>w.stopPropagation())}async _commitMove(n,r,c){try{let u=await this._updateLabel(n.name,{x:r,y:c,text:n.text,size:n.size||0,anchor:n.anchor||"center",color:n.color});this._refresh(u)}catch(u){console.error("move label failed:",u)}}_select(n){this._selectedName=n,this._renderHandles();let r=this._labels.find(d=>d.name===n);if(!r)return;let c=d=>this._app.formatDbu(d,!0),u={type:"Label",name:r.name,bbox:[r.x,r.y,r.x,r.y],properties:[{name:"Name",value:r.name},{name:"Text",value:r.text,editable:!0},{name:"x",value:c(r.x)},{name:"y",value:c(r.y)},{name:"Font size",value:String(r.size||0),editable:!0},{name:"Anchor",value:r.anchor||"center",editable:!0,editor:{type:"list",options:this._anchors}}],onPropertyChange:(d,b)=>{let w={text:r.text,size:r.size||0,anchor:r.anchor||"center"};d==="Text"?w.text=b:d==="Font size"?w.size=parseInt(b,10)||0:d==="Anchor"&&(w.anchor=b.trim()),this._edit(r,w)}};this._updateInspector(u),this._focusComponent("Inspector"),requestAnimationFrame(()=>{let d=this._app.inspectorEl?.querySelector(".inspector-toolbar");if(!d||d.querySelector(".delete-label-btn"))return;let b=document.createElement("button");b.className="or-btn or-btn-icon delete-label-btn",b.title="Delete label",b.innerHTML='',b.addEventListener("click",()=>this.deleteLabel(n)),d.appendChild(b)})}async _edit(n,r){try{let c=await this._updateLabel(n.name,{x:n.x,y:n.y,text:r.text,size:r.size,anchor:r.anchor,color:n.color});this._refresh(c),this._select(n.name)}catch(c){console.error("edit label failed:",c)}}async deleteLabel(n){try{let r=await this._wm().request({type:"delete_label",name:n});this._selectedName===n&&(this._selectedName=null,this._updateInspector(null)),this._refresh(r)}catch(r){console.error("delete_label failed:",r)}}async clearAllLabels(){try{let n=await this._wm().request({type:"clear_labels"});this._selectedName=null,this._refresh(n)}catch(n){console.error("clear_labels failed:",n)}}};var R3t="Select an instance in the layout to view its schematic.",lde=class{constructor(n,r){this.container=n,this.appState=r,this.element=document.createElement("div"),this.element.className="schematic-widget",this.element.style.cssText="width:100%; height:100%; display:flex; flex-direction:column; background:var(--bg-panel); color:var(--fg-primary); overflow:hidden;",this.controls=document.createElement("div"),this.controls.style.cssText="padding:4px 8px; background:var(--bg-header); border-bottom:1px solid var(--border);flex-shrink:0; display:flex; align-items:center; gap:8px; flex-wrap:wrap;",this.controls.innerHTML='',this.element.appendChild(this.controls),this.svgContainer=document.createElement("div"),this.svgContainer.style.cssText="flex:1; overflow:hidden; position:relative; cursor:grab; background:var(--bg-main);",this.element.appendChild(this.svgContainer),this.container.element.appendChild(this.element),this.controls.querySelector("#schematic-refresh").addEventListener("click",()=>this.refresh()),this.controls.querySelector("#schematic-fit").addEventListener("click",()=>this.fitView()),this.controls.querySelector("#schematic-zoom-in").addEventListener("click",()=>this._zoomStep(1.5)),this.controls.querySelector("#schematic-zoom-out").addEventListener("click",()=>this._zoomStep(1/1.5)),this.controls.querySelector("#schematic-select").addEventListener("click",()=>this._toggleSelectMode()),this.controls.querySelector("#schematic-zoom-to").addEventListener("click",()=>this._zoomToSelected()),this.controls.querySelector("#schematic-save-svg").addEventListener("click",()=>this._exportSvg()),this.controls.querySelector("#schematic-save-png").addEventListener("click",()=>this._exportPng()),this.controls.querySelector("#schematic-copy").addEventListener("click",()=>this._copyImage()),this.appState.schematicWidget=this,this.netlistsvg=null,this.skin=null,this._svgEl=null,this._scale=1,this._panX=0,this._panY=0,this._selectMode=!1,this._selectedCell=null,this._svgIdToInstName=new Map,this._setupPanZoom(),this.initNetlistSVG()}_setupPanZoom(){let n=this.svgContainer,r=!1,c,u,d,b;n.addEventListener("wheel",w=>{if(!this._svgEl)return;w.preventDefault();let _=w.deltaY<0?1.2:1/1.2,x=n.getBoundingClientRect(),T=w.clientX-x.left,M=w.clientY-x.top;this._panX=T+(this._panX-T)*_,this._panY=M+(this._panY-M)*_,this._scale*=_,this._applyTransform()},{passive:!1}),n.addEventListener("mousedown",w=>{if(!(!this._svgEl||w.button!==0)){if(this._selectMode){this._handleSelectClick(w);return}r=!0,c=w.clientX,u=w.clientY,d=this._panX,b=this._panY,n.style.cursor="grabbing",w.preventDefault()}}),window.addEventListener("mousemove",w=>{r&&(this._panX=d+(w.clientX-c),this._panY=b+(w.clientY-u),this._applyTransform())}),window.addEventListener("mouseup",()=>{r&&(r=!1,n.style.cursor=this._selectMode?"default":"grab")})}_zoomStep(n){if(!this._svgEl)return;let r=this.svgContainer.getBoundingClientRect(),c=r.width/2,u=r.height/2;this._panX=c+(this._panX-c)*n,this._panY=u+(this._panY-u)*n,this._scale*=n,this._applyTransform()}_toggleSelectMode(){this._selectMode=!this._selectMode;let n=this.controls.querySelector("#schematic-select");this._selectMode?(n.style.background="var(--accent)",n.style.color="var(--fg-white)",this.svgContainer.style.cursor="default"):(n.style.background="",n.style.color="",this.svgContainer.style.cursor="grab",this._clearCellHighlight())}_handleSelectClick(n){if(!this._svgEl)return;let r=n.target,c=null;for(;r&&r!==this._svgEl;){if(r.tagName==="g"&&r.id&&this._svgIdToInstName.has(r.id)){c=r;break}r=r.parentElement}if(this._clearCellHighlight(),!c)return;let u=this._svgIdToInstName.get(c.id);try{let d=c.getBBox(),b=3,w=document.createElementNS("http://www.w3.org/2000/svg","rect");w.setAttribute("x",d.x-b),w.setAttribute("y",d.y-b),w.setAttribute("width",d.width+b*2),w.setAttribute("height",d.height+b*2),w.setAttribute("fill","none"),w.setAttribute("stroke","#e05a00"),w.setAttribute("stroke-width","1.5"),w.setAttribute("rx","3"),w.id="_schematic_highlight",c.appendChild(w),this._selectedCell=c}catch{}this.controls.querySelector("#schematic-zoom-to").disabled=!1,this.setStatus(`Selected: ${u}`),this._fetchInspect(u)}_fetchInspect(n){let r=this.appState.websocketManager;if(!r)return;console.log("[Schematic] inspect:",n);let c=Pm(this.appState);r.request({type:"schematic_inspect",inst_name:n,use_dbu:this.appState.showDbu}).then(u=>{Z1(this.appState,c)&&(this.appState.updateInspector&&this.appState.updateInspector(u),this.appState.focusComponent&&this.appState.focusComponent("Inspector"),this.appState.refreshOverlay&&this.appState.refreshOverlay())}).catch(u=>{console.error("schematic_inspect failed:",u),this.setStatus(`Inspect error: ${u}`)})}_clearCellHighlight(){if(this._svgEl){let n=this._svgEl.querySelector("#_schematic_highlight");n&&n.remove()}this._selectedCell=null,this.controls.querySelector("#schematic-zoom-to").disabled=!0}_zoomToSelected(){if(!this._selectedCell||!this._svgEl)return;let n=this.svgContainer.getBoundingClientRect(),r=this._selectedCell.getBoundingClientRect(),c=(r.left-n.left-this._panX)/this._scale,u=(r.top-n.top-this._panY)/this._scale,d=r.width/this._scale,b=r.height/this._scale,w=Math.min(n.width/d,n.height/b)*.9;this._scale=w,this._panX=n.width/2-(c+d/2)*w,this._panY=n.height/2-(u+b/2)*w,this._applyTransform()}_applyTransform(){this._svgEl&&(this._svgEl.style.transform=`translate(${this._panX}px, ${this._panY}px) scale(${this._scale})`,this._svgEl.style.transformOrigin="0 0")}fitView(){if(!this._svgEl)return;let n=this.svgContainer.getBoundingClientRect();if(n.width===0||n.height===0)return;let r=this._svgEl.viewBox&&this._svgEl.viewBox.baseVal,c=r&&r.width||this._svgEl.clientWidth||1,u=r&&r.height||this._svgEl.clientHeight||1;this._scale=Math.min(n.width/c,n.height/u)*.95,this._panX=(n.width-c*this._scale)/2,this._panY=(n.height-u*this._scale)/2,this._applyTransform()}initNetlistSVG(){this.netlistsvg=globalThis.netlistsvg,this.skin=globalThis.openroadSkin,this._netlistsvgReady=!!(this.netlistsvg&&this.skin),this._netlistsvgReady&&console.log("NetlistSVG ready."),this.setStatus(this._unreadyStatus()??R3t)}_unreadyStatus(){return this._netlistsvgReady?null:ua(this.appState)?"The schematic is not available in saved reports.":"Init error: netlistsvg or its skin is missing from the page."}syncCone(n={}){let r=this.controls.querySelector("#schematic-fanin-depth"),c=this.controls.querySelector("#schematic-fanout-depth"),u=(d,b,w)=>{if(!d)return;let _=parseInt(d.max,10)||10;b===!1?d.value=0:w!==void 0&&(d.value=w>0?Math.min(w,_):_)};u(r,n.fanin,n.fanin_depth),u(c,n.fanout,n.fanout_depth),this.refresh(),this.appState.focusComponent&&this.appState.focusComponent("SchematicWidget")}refresh(){if(!this._netlistsvgReady){this.setStatus(this._unreadyStatus());return}let n=this.appState.selectedInstanceName;if(!n){this.setStatus(R3t);return}let r=this.appState.websocketManager;if(!r){this.setStatus("Waiting for server connection\u2026");return}this.setStatus(`Loading schematic for ${n}\u2026`);let c=parseInt(this.controls.querySelector("#schematic-fanin-depth").value,10),u=parseInt(this.controls.querySelector("#schematic-fanout-depth").value,10),d=isNaN(c)?1:c,b=isNaN(u)?1:u;r.readyPromise.then(()=>{r.request({type:"schematic_cone",inst_name:n,fanin_depth:d,fanout_depth:b}).then(w=>{let _=w.modules&&w.modules.top&&w.modules.top.cells;if(!_||Object.keys(_).length===0){this.setStatus("No cells found for selected instance.");return}this.renderNetlist(w)}).catch(w=>{this.setStatus(`Error: ${w}`)})})}setStatus(n){this.controls.querySelector("#schematic-status").textContent=n}_exportSvg(){if(!this._svgEl){this.setStatus("No schematic to export.");return}let n=X5e(this._svgEl);s3t(new Blob([n],{type:"image/svg+xml;charset=utf-8"}),"schematic.svg")}async _exportPng(){if(!this._svgEl){this.setStatus("No schematic to export.");return}try{let n=await Y5e(this._svgEl,2);hk(n,"schematic.png")}catch{this.setStatus("PNG export failed.")}}async _copyImage(){if(!this._svgEl){this.setStatus("No schematic to export.");return}try{let n=await Y5e(this._svgEl,2),r=await Hhe(n);this.setStatus(r?"Schematic copied to clipboard.":"Clipboard not available.")}catch{this.setStatus("Copy failed.")}}async renderNetlist(n){try{this.setStatus("Rendering\u2026"),typeof window<"u"&&(window.__lastSchematic=n);let r=rpn(n),c,u=this.netlistsvg.render(this.skin,r);if(u&&typeof u.then=="function"?c=await u:c=await new Promise((w,_)=>{this.netlistsvg.render(this.skin,r,(x,T)=>{x?_(x):w(T)})}),typeof c!="string"||!c.includes("requestAnimationFrame(()=>this.fitView()));let b=Object.keys(n.modules.top.cells).length;this.setStatus(`${b} cell${b!==1?"s":""}`)}catch(r){console.error("NetlistSVG render failed:",r),this.setStatus(`Render error: ${r.message||r}`)}}_applyPinLabels(n){if(!this._svgEl)return;let r="http://www.w3.org/2000/svg",c="https://github.com/nturley/netlistsvg",u=n.modules&&n.modules.top&&n.modules.top.cells||{},d=(b,w)=>b.getAttribute("s:"+w)??b.getAttributeNS(c,w);for(let[b,w]of Object.entries(u)){let _=w.port_labels;if(!_)continue;let x=this._svgEl.querySelector("#"+CSS.escape("cell_"+b))||this._svgEl.querySelector("#"+CSS.escape(b));if(!x)continue;let T=w.port_directions||{};for(let M of Array.from(x.children)){if(M.tagName!=="g")continue;let L=d(M,"pid");if(!L||!(L in _))continue;let I=parseFloat(d(M,"x")),D=parseFloat(d(M,"y"));if(!isFinite(I)||!isFinite(D))continue;let F=document.createElementNS(r,"text");T[L]==="input"?(F.setAttribute("class","inputPortLabel"),F.setAttribute("x",I-3)):F.setAttribute("x",I+4),F.setAttribute("y",D-4),F.setAttribute("style","font-size:5px"),F.setAttribute("pointer-events","none"),F.textContent=_[L],x.appendChild(F)}}}_scopeSkinStyles(){if(!this._svgEl)return;let n=".schematic-widget",r=c=>{for(let u of c)u.selectorText?u.selectorText=epn(u.selectorText,n):u.cssRules&&r(u.cssRules)};for(let c of this._svgEl.querySelectorAll("style")){let u=c.sheet;if(u)try{r(u.cssRules)}catch{continue}}}};function epn(s,n){return s.split(",").map(r=>{let c=r.trim();if(!c)return"";let u=c.charAt(n.length);return c.startsWith(n)&&(u===""||!/[\w-]/.test(u))?c:`${n} ${c}`}).filter(Boolean).join(", ")}var I3t={and:"$_AND_",nand:"$_NAND_",or:"$_OR_",nor:"$_NOR_",xor:"$_XOR_",xnor:"$_XNOR_",not:"$_NOT_",buf:"$_BUF_"},tpn=new Set(["aoi21","aoi22","aoi211","aoi221","aoi222","aoi33","oai21","oai22","oai211","oai221","oai222","oai33"]),npn=new Set(["and3","and4","or3","or4","nand3","nand4","nor3","nor4"]),D3t=["A","B","C","D","E","F"];function ipn(s){let n=s&&s.gate_kind;if(!n)return s;let r=s.port_directions||{},c=null,u=[];for(let[M,L]of Object.entries(r))L==="output"&&c===null?c=M:L==="input"&&u.push(M);let d,b={};if(n==="aoi"||n==="oai"){let M=Array.isArray(s.gate_terms)?s.gate_terms:[];if(!M.length)return s;let L=M.map(F=>F.length);if(d=n+L.slice().sort((F,O)=>O-F).join(""),!tpn.has(d))return s;let I=M.map(F=>F.slice()).sort((F,O)=>F.length-O.length),D=0;for(let F of I)for(let O of F)b[O]=D3t[D]||"I"+D,D++}else{let M=u.length;if(n==="not"||n==="buf")d=I3t[n];else if(M<=2)d=I3t[n];else if(d=n+M,!npn.has(d))return s;if(!d)return s;u.forEach((L,I)=>{b[L]=D3t[I]||"I"+I})}c!==null&&(b[c]="Y");let w=s.connections||{},_={},x={};for(let[M,L]of Object.entries(w))b[M]&&(_[b[M]]=L);for(let[M,L]of Object.entries(r))b[M]&&(x[b[M]]=L);let T={};for(let[M,L]of Object.entries(b))T[L]=M;return{...s,type:d,connections:_,port_directions:x,port_labels:T}}function rpn(s){let n=s&&s.modules&&s.modules.top;if(!n||!n.cells)return s;let r={};for(let[c,u]of Object.entries(n.cells))r[c]=ipn(u);return{...s,modules:{...s.modules,top:{...n,cells:r}}}}var ude=class{constructor(n,r,c){this._app=n,this._redrawAllLayers=r,this._refreshOverlay=c||r,this._categories=[],this._activeCategory="",this._markerTree=null,this._expandedNodes=new Set,this._build(),this._app.websocketManager.readyPromise.then(()=>this.refresh())}_build(){let n=document.createElement("div");n.className="drc-widget";let r=document.createElement("div");r.className="drc-toolbar",this._categorySelect=document.createElement("select"),this._categorySelect.className="drc-category-select",r.appendChild(this._categorySelect),this._loadBtn=document.createElement("button"),this._loadBtn.className="or-btn or-btn-sm",this._loadBtn.textContent="Load...",r.appendChild(this._loadBtn),n.appendChild(r),this._infoBar=document.createElement("div"),this._infoBar.className="drc-info-bar",n.appendChild(this._infoBar),this._treeContainer=document.createElement("div"),this._treeContainer.className="drc-tree-container",n.appendChild(this._treeContainer),this.element=n,this._bindEvents()}_bindEvents(){this._categorySelect.addEventListener("change",()=>{this._activeCategory=this._categorySelect.value,this._loadMarkers()}),this._loadBtn.addEventListener("click",()=>{this._showLoadDialog()})}_loadCategories(){return this._app.websocketManager.request({type:"drc_categories"}).then(n=>{this._categories=n.categories||[],this._renderCategorySelect()}).catch(n=>{console.error("Failed to load DRC categories:",n)})}refresh(){this._loadCategories().then(()=>{!this._activeCategory&&this._categories.length>0&&(this._activeCategory=this._categories[0].name,this._categorySelect.value=this._activeCategory),this._activeCategory&&this._loadMarkers()})}_renderCategorySelect(){let n=this._categorySelect,r=n.value;n.innerHTML="";let c=document.createElement("option");c.value="",c.textContent="(none)",n.appendChild(c);for(let u of this._categories){let d=document.createElement("option");d.value=u.name,d.textContent=`${u.name} (${u.count})`,n.appendChild(d)}this._activeCategory&&this._categories.some(u=>u.name===this._activeCategory)?n.value=this._activeCategory:r&&this._categories.some(u=>u.name===r)?(n.value=r,this._activeCategory=r):this._activeCategory=""}_loadMarkers(){if(!this._activeCategory){this._markerTree=null,this._treeContainer.innerHTML="",this._infoBar.textContent="",this._refreshOverlay();return}this._treeContainer.innerHTML='
Loading...
',this._app.websocketManager.request({type:"drc_markers",category:this._activeCategory}).then(n=>{this._markerTree=n,this._renderTree(),this._refreshOverlay()}).catch(n=>{this._treeContainer.innerHTML="";let r=document.createElement("div");r.className="drc-error",r.textContent=`Error: ${n}`,this._treeContainer.appendChild(r),console.error("Failed to load DRC markers:",n)})}_renderTree(){if(this._treeContainer.innerHTML="",!this._markerTree)return;if(this._markerTree.error){let b=document.createElement("div");b.className="drc-error",b.textContent=this._markerTree.error,this._treeContainer.appendChild(b);return}let n=this._markerTree.total_count||0;this._infoBar.textContent=`${n} total violation${n!==1?"s":""}`;let r=this._markerTree.name||this._activeCategory,c=this._markerTree.subcategories||[],u=this._markerTree.markers||[];if(c.length===0&&u.length===0){this._treeContainer.innerHTML='
No violations
';return}let d=document.createElement("div");d.className="drc-tree",u.length>0&&d.appendChild(this._buildCategoryNode({name:r||"Markers",count:u.length,markers:u},[]));for(let b of c)d.appendChild(this._buildCategoryNode(b,[r]));this._treeContainer.appendChild(d)}_buildCategoryNode(n,r=[]){let c=[...r,n.name],u=document.createElement("div");u.className="drc-tree-node";let d=document.createElement("div");d.className="drc-tree-header";let b=document.createElement("span");b.className="drc-toggle";let w=n.subcategories&&n.subcategories.length>0||n.markers&&n.markers.length>0,_=JSON.stringify(c),x=this._expandedNodes.has(_);b.textContent=w?x?"\u25BC":"\u25B6":" ",d.appendChild(b);let T=document.createElement("input");T.type="checkbox",T.checked=this._allMarkersVisible(n),T.className="drc-visibility-check",T.addEventListener("change",D=>{D.stopPropagation(),this._toggleCategoryVisibility(n,T.checked,c)}),d.appendChild(T);let M=document.createElement("span");M.className="drc-category-label",M.textContent=n.name,d.appendChild(M);let L=document.createElement("span");L.className="drc-count",L.textContent=`${n.count} markers`,d.appendChild(L),u.appendChild(d);let I=document.createElement("div");if(I.className="drc-tree-children",I.style.display=x?"":"none",n.subcategories)for(let D of n.subcategories)I.appendChild(this._buildCategoryNode(D,c));if(n.markers)for(let D of n.markers)I.appendChild(this._buildMarkerNode(D));return u.appendChild(I),w&&(d.addEventListener("click",D=>{if(D.target===T)return;let F=I.style.display!=="none";I.style.display=F?"none":"",b.textContent=F?"\u25B6":"\u25BC",F?this._expandedNodes.delete(_):this._expandedNodes.add(_)}),d.style.cursor="pointer"),u}_buildMarkerNode(n){let r=document.createElement("div");r.className="drc-marker-row",r.dataset.markerId=n.id,n.visited||r.classList.add("drc-unvisited");let c=document.createElement("input");c.type="checkbox",c.checked=n.visible,c.className="drc-visibility-check",c.addEventListener("change",b=>{b.stopPropagation(),n.visible=c.checked,this._updateMarker(n.id,"visible",c.checked)}),r.appendChild(c);let u=document.createElement("span");u.className="drc-marker-index",u.textContent=n.index,r.appendChild(u);let d=document.createElement("span");if(d.className="drc-marker-name",d.textContent=n.name,n.layer&&(d.title=`Layer: ${n.layer}`),r.appendChild(d),n.layer){let b=document.createElement("span");b.className="drc-layer-badge",b.textContent=n.layer,r.appendChild(b)}return r.addEventListener("click",b=>{b.target!==c&&this._highlightMarker(n)}),r.addEventListener("dblclick",b=>{b.target!==c&&this._highlightMarker(n,!0)}),r}highlightMarkerById(n,r=!1){let c=this._findMarkerById(n);c&&this._highlightMarker(c,r)}_findMarkerById(n){let r=c=>{if(!c)return null;if(c.markers){for(let u of c.markers)if(u.id===n)return u}if(c.subcategories)for(let u of c.subcategories){let d=r(u);if(d)return d}return null};return r(this._markerTree)}_highlightMarker(n,r=!1){this._app.websocketManager.request({type:"drc_highlight",marker_id:n.id,open_inspector:r}).then(c=>{if(c.ok&&c.bbox){n.visited=!0;let u=this._treeContainer.querySelector(`.drc-marker-row[data-marker-id="${n.id}"]`);u&&u.classList.remove("drc-unvisited"),this._zoomToBBox(c.bbox),this._refreshOverlay(),r&&(c.select_id!=null&&this._app.navigateInspector&&this._app.navigateInspector(c.select_id),this._app.focusComponent&&this._app.focusComponent("Inspector"))}}).catch(c=>{console.error("Failed to highlight DRC marker:",c)})}_zoomToBBox(n){if(!this._app.designScale||!this._app.view)return;let[r,c,u,d]=n,b=u-r,w=d-c,x=10*this._app.getDbuPerMicron(),T=2*Math.max(b,w),M=Math.min(x,T);this._app.view.fitWorldRect(X1(r-M,c-M,u+M,d+M,this._app.designScale,this._app.designOriginX,this._app.designOriginY))}_updateMarker(n,r,c){this._app.websocketManager.request({type:"drc_update_marker",marker_id:n,field:r,value:!!c}).then(()=>{this._refreshOverlay(),r==="visible"&&(this._update3DHighlights(),c&&this._flashHighlight())}).catch(u=>{console.error("Failed to update DRC marker:",u)})}_flashHighlight(){this._app.view?.flashTiles()}_update3DHighlights(){let n=this._app.threeDViewerWidget;if(!n)return;let r=[];this._collectVisibleMarkers(this._markerTree,r),r.length>0?n.highlightDRC(r):n.clearHighlightDRC()}_collectVisibleMarkers(n,r){if(n){if(n.markers)for(let c of n.markers)c.visible&&r.push(c);if(n.subcategories)for(let c of n.subcategories)this._collectVisibleMarkers(c,r)}}_setMarkersVisible(n,r){if(n){if(n.markers)for(let c of n.markers)c.visible=r;if(n.subcategories)for(let c of n.subcategories)this._setMarkersVisible(c,r)}}_snapshotMarkerVisibility(n,r=new Map){if(!n)return r;if(n.markers)for(let c of n.markers)r.set(c.id,c.visible);if(n.subcategories)for(let c of n.subcategories)this._snapshotMarkerVisibility(c,r);return r}_restoreMarkerVisibility(n,r){if(n){if(n.markers)for(let c of n.markers)r.has(c.id)&&(c.visible=r.get(c.id));if(n.subcategories)for(let c of n.subcategories)this._restoreMarkerVisibility(c,r)}}_allMarkersVisible(n){if(n.markers){for(let r of n.markers)if(!r.visible)return!1}if(n.subcategories){for(let r of n.subcategories)if(!this._allMarkersVisible(r))return!1}return!0}_toggleCategoryVisibility(n,r,c){let u=this._snapshotMarkerVisibility(n);this._setMarkersVisible(n,r),this._renderTree(),this._app.websocketManager.request({type:"drc_update_category_visibility",category:n.name,path:c||[n.name],visible:!!r}).then(()=>{this._refreshOverlay(),this._update3DHighlights(),r&&this._flashHighlight()}).catch(d=>{console.error("Failed to update category visibility:",d),this._restoreMarkerVisibility(n,u),this._renderTree()})}_showLoadDialog(){new nDe(this._app,r=>{this._activeCategory=r,this._loadCategories().then(()=>{this._categorySelect.value=this._activeCategory,this._loadMarkers()})}).open()}selectCategory(n){this._activeCategory=n,this._categorySelect.value=n,this._loadMarkers()}},nDe=class{constructor(n,r){this._app=n,this._onLoaded=r,this._currentPath="",this._disposers=[],this._closed=!1}open(){this._overlay=document.createElement("div"),this._overlay.className="modal-overlay",this._overlay.innerHTML=` - `,document.body.appendChild(this._overlay),this._breadcrumb=this._overlay.querySelector(".fb-breadcrumb"),this._fileList=this._overlay.querySelector(".fb-file-list"),this._pathInput=this._overlay.querySelector(".fb-path-input"),this._errorDiv=this._overlay.querySelector(".modal-error"),this._okBtn=this._overlay.querySelector(".ok"),this._cancelBtn=this._overlay.querySelector(".cancel"),this._listen(this._pathInput,"input",()=>this._updateOkState()),this._listen(this._pathInput,"keydown",n=>{if(n.key==="Enter"){let r=this._pathInput.value.trim();r.endsWith("/")?this._navigate(r.replace(/\/+$/,"")||"/"):this._submit()}else n.key==="Escape"&&this.close()}),this._listen(this._okBtn,"click",()=>this._submit()),this._listen(this._cancelBtn,"click",()=>this.close()),this._listen(this._overlay,"click",n=>{n.target===this._overlay&&this.close()}),this._navigate("")}close(){if(!this._closed){this._closed=!0;for(let n of this._disposers)n();this._disposers.length=0,this._overlay&&(this._overlay.remove(),this._overlay=null)}}_listen(n,r,c){n.addEventListener(r,c),this._disposers.push(()=>n.removeEventListener(r,c))}_updateOkState(){this._okBtn.disabled=!this._pathInput.value.trim()}_renderBreadcrumb(n){this._breadcrumb.innerHTML="";let r=n.split("/").filter(Boolean),c=document.createElement("span");c.className="fb-crumb",c.textContent="/",this._listen(c,"click",()=>this._navigate("/")),this._breadcrumb.appendChild(c);let u="";for(let d of r){u+="/"+d;let b=document.createElement("span");b.className="fb-crumb-sep",b.textContent=" / ",this._breadcrumb.appendChild(b);let w=document.createElement("span");w.className="fb-crumb",w.textContent=d;let _=u;this._listen(w,"click",()=>this._navigate(_)),this._breadcrumb.appendChild(w)}}_renderEntries(n){if(this._fileList.innerHTML="",!n||n.length===0){let r=document.createElement("div");r.className="fb-empty",r.textContent="(empty directory)",this._fileList.appendChild(r);return}for(let r of n){let c=document.createElement("div");c.className="fb-entry",r.is_dir&&c.classList.add("fb-dir");let u=document.createElement("span");u.className="fb-icon",u.textContent=r.is_dir?"\u{1F4C1}":"\u{1F4C4}",c.appendChild(u);let d=document.createElement("span");d.className="fb-name",d.textContent=r.name,c.appendChild(d),r.is_dir?this._listen(c,"click",()=>this._navigate(this._currentPath+"/"+r.name)):(this._listen(c,"click",()=>{let b=this._fileList.querySelector(".fb-selected");b&&b.classList.remove("fb-selected"),c.classList.add("fb-selected"),this._pathInput.value=this._currentPath+"/"+r.name,this._updateOkState()}),this._listen(c,"dblclick",()=>{this._pathInput.value=this._currentPath+"/"+r.name,this._updateOkState(),this._submit()})),this._fileList.appendChild(c)}}async _navigate(n){this._errorDiv.style.display="none",this._fileList.innerHTML='
Loading...
';try{let r=await this._app.websocketManager.request({type:"list_dir",path:n||""});if(this._closed)return;this._currentPath=r.path,this._renderBreadcrumb(r.path),this._renderEntries(r.entries),this._pathInput.value="",this._updateOkState()}catch(r){if(this._closed)return;this._fileList.innerHTML="",this._errorDiv.textContent=r.message||String(r),this._errorDiv.style.display=""}}async _submit(){let n=this._pathInput.value.trim();if(n){this._okBtn.disabled=!0,this._okBtn.textContent="Loading...",this._errorDiv.style.display="none";try{let r=await this._app.websocketManager.request({type:"drc_load_report",path:n});if(this._closed)return;if(r.ok){let c=r.category;this.close(),this._onLoaded(c)}else this._errorDiv.textContent=r.error||"Failed to load report",this._errorDiv.style.display="",this._okBtn.disabled=!1,this._okBtn.textContent="Load"}catch(r){if(this._closed)return;this._errorDiv.textContent=r.message||"Request failed",this._errorDiv.style.display="",this._okBtn.disabled=!1,this._okBtn.textContent="Load"}}}};var npn=` -\r[]{}`;var fde=class{constructor(n,r){this._input=n,this._ws=r,this._popup=null,this._items=[],this._selectedIndex=-1,this._replaceStart=0,this._replaceEnd=0,this._debounceTimer=null,this._commandCache=null,this._history=[],this._historyIndex=-1,this._historyStash="",this._createPopup(),this._onInputBound=this._onInput.bind(this),this._onBlurBound=this._onBlur.bind(this),this._input.addEventListener("input",this._onInputBound),this._input.addEventListener("blur",this._onBlurBound)}_createPopup(){this._popup=document.createElement("div"),this._popup.className="tcl-complete-popup",this._popup.style.display="none",this._input.parentElement.appendChild(this._popup)}handleKeyDown(n){let r=this._popup.style.display!=="none";return n.key==="Tab"?(n.preventDefault(),r?this._tabAccept():this._tabComplete(this._input.value,this._input.selectionStart),!0):n.key==="Escape"?r?(this._hidePopup(),!0):!1:n.key==="ArrowDown"?r?(n.preventDefault(),this._selectItem(this._selectedIndex+1),!0):this._historyIndex>=0?(n.preventDefault(),this._historyIndex--,this._historyIndex<0?this._input.value=this._historyStash:this._input.value=this._history[this._historyIndex],!0):!1:n.key==="ArrowUp"?r?(n.preventDefault(),this._selectItem(this._selectedIndex-1),!0):this._historyIndex{let n=this._input.value,r=this._input.selectionStart,c=this._extractPrefix(n,r);c.length>=2||c.length>=1&&(c[0]==="$"||c[0]==="-")?this._requestCompletions(n,r):this._hidePopup()},100)}_onBlur(){setTimeout(()=>this._hidePopup(),150)}_extractPrefix(n,r){let c=r-1;for(;c>=0&&npn.indexOf(n[c])===-1;)c--;return n.substring(c+1,r)}_fetchCompletions(n,r,c){let u=this._extractPrefix(n,r),d=u.length>0&&u[0]==="$",b=u.length>0&&u[0]==="-",w=!d&&!b,_=r-u.length,x=n.substring(0,_),T=/^[\s\[]*$/.test(x);if(w&&T&&this._commandCache){let M=u.toLowerCase(),L=this._commandCache.filter(I=>I.toLowerCase().startsWith(M));c(L,_,r);return}this._ws.request({type:"tcl_complete",line:n,cursor_pos:r}).then(M=>{M.mode==="commands"&&!this._commandCache&&u===""&&(this._commandCache=M.completions),M.mode==="commands"&&!this._commandCache&&this._ws.request({type:"tcl_complete",line:"",cursor_pos:0}).then(L=>{L.mode==="commands"&&(this._commandCache=L.completions)}).catch(()=>{}),c(M.completions,M.replace_start,M.replace_end)}).catch(()=>c([],0,0))}_requestCompletions(n,r){this._fetchCompletions(n,r,(c,u,d)=>{this._showPopup(c,u,d)})}_tabAccept(){if(this._items.length===0){this._hidePopup();return}if(this._items.length===1){this._selectedIndex=0,this._acceptCompletion();return}this._advanceToCommonPrefix()}_tabComplete(n,r){this._fetchCompletions(n,r,(c,u,d)=>{if(!c||c.length===0){this._hidePopup();return}if(c.length===1){this._items=c,this._replaceStart=u,this._replaceEnd=d,this._selectedIndex=0,this._acceptCompletion();return}this._items=c,this._replaceStart=u,this._replaceEnd=d,this._advanceToCommonPrefix(),this._showPopup(c,this._replaceStart,this._replaceEnd)})}_advanceToCommonPrefix(){if(this._items.length<2)return!1;let n=this._items[0];for(let b=1;b0;b++){let w=this._items[b],_=0;for(;_{let _=document.createElement("div");_.className="tcl-complete-item",_.textContent=b,_.addEventListener("mousedown",x=>{x.preventDefault(),this._selectedIndex=w,this._acceptCompletion()}),this._popup.appendChild(_)}),n.length>15){let b=document.createElement("div");b.className="tcl-complete-more",b.textContent=`... ${n.length-15} more`,this._popup.appendChild(b)}this._selectedIndex=0,this._highlightSelected(),this._popup.style.display="block"}_hidePopup(){this._popup.style.display="none",this._items=[],this._selectedIndex=-1}_selectItem(n){if(this._items.length===0)return;let r=Math.min(this._items.length,15)-1;this._selectedIndex=Math.max(0,Math.min(n,r)),this._highlightSelected()}_highlightSelected(){let n=this._popup.querySelectorAll(".tcl-complete-item");n.forEach((r,c)=>{r.classList.toggle("selected",c===this._selectedIndex)}),n[this._selectedIndex]&&n[this._selectedIndex].scrollIntoView&&n[this._selectedIndex].scrollIntoView({block:"nearest"})}_acceptCompletion(){if(this._selectedIndex<0||this._selectedIndex>=this._items.length){this._hidePopup();return}let n=this._items[this._selectedIndex],r=this._input.value.substring(0,this._replaceStart),c=this._input.value.substring(this._replaceEnd),d=!n.endsWith("/")&&!n.endsWith("::")&&(c.length===0||c[0]!==" ")?" ":"";this._input.value=r+n+d+c;let b=this._replaceStart+n.length+d.length;this._input.setSelectionRange(b,b),this._input.focus(),this._hidePopup()}};var D3t=[{key:"or_visibility",store:"cookie"},{key:"or_selectability",store:"cookie"},{key:"or_hidden_layers",store:"session"},{key:"or_nonselectable_layers",store:"session"},{key:"or_layer_patterns",store:"session"},{key:"or_hidden_chiplets",store:"cookie"},{key:"or_bg_color",store:"cookie"},{key:"or_show_dbu",store:"cookie"},{key:"or_theme",store:"theme"},{key:"or_use_true_z",store:"cookie"},{key:"or_ruler_style",store:"cookie"},{key:"or_wheel_zoom",store:"cookie"},{key:"or_arrow_step",store:"cookie"},{key:"or_font_family",store:"cookie"},{key:"or_font_scale",store:"cookie"},{key:"or_control_smoothing",store:"cookie"},{key:"or_double_buffer",store:"cookie"},{key:"or_defer_tile_updates",store:"cookie"}];function ipn(s,n){try{return window[s].getItem(n)}catch{return null}}function rpn(s,n,r){try{r===null?window[s].removeItem(n):window[s].setItem(n,r)}catch{}}function spn({key:s,store:n}){return n==="session"?ipn("sessionStorage",s):pf(s)}function opn({key:s,store:n},r){n==="session"?rpn("sessionStorage",s,r):n==="theme"?r===null?e3t():Whe(r):r===null?Vhe(s):Ff(s,r)}function B3t(){let s={};for(let n of D3t){let r=spn(n);r&&(s[n.key]=r)}return{version:1,entries:s}}function apn(s){return typeof s=="string"&&s!==""&&!/[;\r\n]/.test(s)}function O3t(s){for(let n of D3t){let r=s[n.key];opn(n,apn(r)?r:null)}}function N3t(s,n=typeof document<"u"?document:null){let r="OpenROAD",c=s?`${r} - ${s}`:r;return n&&(n.title=c),c}var $s=globalThis.THREE,F3t=2,cpn=.002,lpn=.9,upn=1.1,fpn=.1,hpn=20,dpn=3,gk=2,U3t=2,ppn=10,gpn=1e4,mpn=.15,bpn=300,wpn=6,hde=Math.PI/180,z3t=[5025616,2201331,16750592,10233776,48340,16007990,2533018,7951688,15277667,4149685];function vpn(s){let n=new Array(s.length).fill(0),r=new Map;s.forEach((c,u)=>{let d=c.z;r.has(d)||r.set(d,[]),r.get(d).push({idx:u,chiplet:c})});for(let c of r.values()){if(c.length<=1)continue;let u=[];for(let{idx:d,chiplet:b}of c){let w=b.x,_=b.y,x=b.x+b.width,T=b.y+b.height,M=!1;for(let L=0;LwD.x1&&_D.y1)){u[L].push({x1:w,y1:_,x2:x,y2:T}),n[d]=L,M=!0;break}M||(u.push([{x1:w,y1:_,x2:x,y2:T}]),n[d]=u.length-1)}}return n}var dde=class{constructor(n,r){if(this._app=r,this._container=n,this._element=document.createElement("div"),this._element.className="three-d-viewer-widget",n.element.appendChild(this._element),!$s){la(r)?this._showInfo("The 3D view is not available in saved reports."):this._showError("three.js is missing from the page."),this._destroyed=!0;return}this._canvasContainer=document.createElement("div"),this._canvasContainer.className="three-d-canvas-container",this._element.appendChild(this._canvasContainer),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._canvasContainer.appendChild(this._tooltip),this._optionsOverlay=this._createOptionsOverlay(),this._canvasContainer.appendChild(this._optionsOverlay),this._raycaster=new $s.Raycaster,this._scene=new $s.Scene,this._applyTheme(),this._themeObserver=new MutationObserver(()=>{this._applyTheme(),this.render()}),this._themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),this._camera=new $s.PerspectiveCamera(45,1,10,1e5),this._camera.position.set(0,0,1e3);try{this._renderer=new $s.WebGLRenderer({antialias:!0,preserveDrawingBuffer:!0})}catch(b){console.error("3D viewer: failed to create WebGL context:",b),this._showWebGLUnavailable(b),this._themeObserver&&(this._themeObserver.disconnect(),this._themeObserver=null),this._destroyed=!0;return}this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(n.width,n.height),this._canvasContainer.appendChild(this._renderer.domElement),this._rotation=new $s.Quaternion,this._distance=1e3,this._panX=0,this._panY=0,this._boundingRadius=1,this._sceneCenter=new $s.Vector3,this._mouseDown=!1,this._mouseButton=-1,this._lastMousePos={x:0,y:0},this._setupMouseHandlers();let c=new $s.AmbientLight(16777215,.5);this._scene.add(c);let u=new $s.DirectionalLight(16777215,.8);u.position.set(1,1,1).normalize(),this._scene.add(u);let d=new $s.DirectionalLight(16777215,.3);d.position.set(-1,-.5,.5).normalize(),this._scene.add(d),n.on("resize",this.onResize.bind(this)),n.on("open",this.onOpen.bind(this)),n.on("destroy",this.onDestroy.bind(this)),this._designGroup=new $s.Group,this._scene.add(this._designGroup),this._chipletMeshes=[],this._loading=!1,this._destroyed=!1,this._edgeMaterial=null}_setupMouseHandlers(){let n=this._renderer.domElement;n.addEventListener("mousedown",r=>{this._mouseDown=!0,this._mouseButton=r.button,this._lastMousePos.x=r.clientX,this._lastMousePos.y=r.clientY,n.focus(),r.preventDefault()}),n.addEventListener("contextmenu",r=>r.preventDefault()),this._onMouseMove=r=>{if(!this._mouseDown)return;let c=r.clientX-this._lastMousePos.x,u=r.clientY-this._lastMousePos.y;this._lastMousePos.x=r.clientX,this._lastMousePos.y=r.clientY,!(c===0&&u===0)&&(this._mouseButton===0?this._handleRotate(c,u):this._mouseButton===2&&this._handlePan(c,u),this._updateCamera())},this._onMouseUp=r=>{this._mouseDown&&r.button===this._mouseButton&&(this._mouseDown=!1,this._mouseButton=-1)},window.addEventListener("mousemove",this._onMouseMove),window.addEventListener("mouseup",this._onMouseUp),n.addEventListener("wheel",r=>{r.preventDefault(),r.deltaY<0?this._distance*=lpn:this._distance*=upn;let c=Math.max(this._boundingRadius*fpn,1),u=Math.max(this._boundingRadius*hpn,c);this._distance=Math.max(c,Math.min(u,this._distance)),this._updateCamera()},{passive:!1}),n.tabIndex=0,n.style.outline="none",n.addEventListener("keydown",r=>{r.key.toLowerCase()==="f"&&this.resetCamera()}),n.addEventListener("dblclick",r=>{r.preventDefault();let c=this._pickDrcMarkerId(r);if(c!=null&&this._app.drcWidget){this._app.drcWidget.highlightMarkerById(c,!0);return}this.resetCamera()}),n.addEventListener("mousemove",r=>{if(this._mouseDown){this._hideTooltip();return}this._updateTooltip(r)}),n.addEventListener("mouseleave",()=>{this._hideTooltip()})}_createOptionsOverlay(){let n=document.createElement("div");n.className="three-d-options";let r=document.createElement("label");r.title="Render chiplets at their true Z (disable stacking offset for overlapping chiplets at same Z).";let c=document.createElement("input");c.type="checkbox",c.checked=!!this._app.useTrueZ,c.addEventListener("change",()=>{this._app.useTrueZ=c.checked,Ff("or_use_true_z",c.checked?"1":"0"),this._app.syncDisplayState(),this.refreshSceneForOptions()}),r.appendChild(c),r.appendChild(document.createTextNode("True Z (no stacking)")),n.appendChild(r);let u=document.createElement("div");u.style.cssText="margin-top:4px; display:flex; gap:4px;";let d=document.createElement("button");d.className="or-btn or-btn-sm",d.textContent="Save PNG",d.title="Save the 3D view as a PNG image (2x resolution)",d.addEventListener("click",()=>this._exportPng(2));let b=document.createElement("button");return b.className="or-btn or-btn-sm",b.textContent="Copy",b.title="Copy the 3D view image to the clipboard",b.addEventListener("click",()=>this._copyImage(2)),u.appendChild(d),u.appendChild(b),n.appendChild(u),n}_capturePng(n=2){if(!this._renderer)return null;let r=this._renderer,c=r.domElement.clientWidth||r.domElement.width,u=r.domElement.clientHeight||r.domElement.height,d=r.getPixelRatio();try{return r.setPixelRatio(d*n),r.setSize(c,u,!1),this.render(),r.domElement.toDataURL("image/png")}finally{r.setPixelRatio(d),r.setSize(c,u,!1),this.render()}}_exportPng(n=2){let r=this._capturePng(n);r&&hk(r,"3d-view.png")}async _copyImage(n=2){let r=this._capturePng(n);r&&await Hhe(r)}_setRaycasterFromEvent(n){let c=this._renderer.domElement.getBoundingClientRect(),u=new $s.Vector2((n.clientX-c.left)/c.width*2-1,-((n.clientY-c.top)/c.height*2-1));this._raycaster.setFromCamera(u,this._camera)}_updateTooltip(n){if(!this._chipletMeshes.length){this._hideTooltip();return}this._setRaycasterFromEvent(n);let r=this._chipletMeshes.map(w=>w.mesh),c=this._raycaster.intersectObjects(r,!1);if(c.length===0){this._hideTooltip();return}let u=c[0].object,d=this._chipletMeshes.find(w=>w.mesh===u);if(!d){this._hideTooltip();return}this._tooltip.textContent=d.data.name,this._tooltip.style.display="block";let b=this._canvasContainer.getBoundingClientRect();this._tooltip.style.left=n.clientX-b.left+12+"px",this._tooltip.style.top=n.clientY-b.top+12+"px"}_hideTooltip(){this._tooltip&&(this._tooltip.style.display="none")}_pickDrcMarkerId(n){if(!this._drcHitboxMesh||!this._drcHitboxMarkerIds)return null;this._setRaycasterFromEvent(n);let r=this._raycaster.intersectObject(this._drcHitboxMesh,!1);if(r.length===0)return null;let c=r[0].instanceId;return c==null?null:this._drcHitboxMarkerIds[c]??null}_handleRotate(n,r){let c=Math.sqrt(n*n+r*r);if(c<.001)return;let u=new $s.Vector3(r/c,n/c,0),d=c/F3t,w=new $s.Quaternion().setFromAxisAngle(u,d*hde).clone().multiply(this._rotation);if(new $s.Vector3(0,0,1).applyQuaternion(w).z>=0)this._rotation.copy(w);else{let x=new $s.Vector3(0,1,0),T=n/F3t*hde,L=new $s.Quaternion().setFromAxisAngle(x,T).clone().multiply(this._rotation);new $s.Vector3(0,0,1).applyQuaternion(L).z>=0&&this._rotation.copy(L)}}_handlePan(n,r){let c=this._distance*cpn;this._panX+=n*c,this._panY-=r*c}_updateCamera(){let n=Math.max(this._boundingRadius,1e3),r=Math.max(this._distance-n*U3t,ppn),c=this._distance+n*U3t;c0;){let n=this._designGroup.children[0];this._designGroup.remove(n),n.geometry&&n.geometry.dispose(),n.material&&!n.material._shared&&n.material.dispose()}this._edgeMaterial&&(this._edgeMaterial.dispose(),this._edgeMaterial=null),this._onMouseMove&&(window.removeEventListener("mousemove",this._onMouseMove),this._onMouseMove=null),this._onMouseUp&&(window.removeEventListener("mouseup",this._onMouseUp),this._onMouseUp=null),this._renderer&&(this._renderer.dispose(),this._renderer=null),this._app.threeDViewerWidget===this&&(this._app.threeDViewerWidget=null)}}_setInitialCameraState(){this._distance=this._boundingRadius*dpn;let n=new $s.Quaternion().setFromAxisAngle(new $s.Vector3(1,0,0),-45*hde),r=new $s.Quaternion().setFromAxisAngle(new $s.Vector3(0,0,1),45*hde);this._rotation=n.multiply(r),this._panX=0,this._panY=0}resetCamera(){this._sceneBounds&&(this._setInitialCameraState(),this._updateCamera())}onResize(){if(this._destroyed)return;let n=this._canvasContainer.getBoundingClientRect(),r=n.width,c=n.height;r===0||c===0||(this._camera.aspect=r/c,this._camera.updateProjectionMatrix(),this._renderer.setSize(r,c),this.render())}render(){this._destroyed||this._renderer&&this._scene&&this._camera&&this._renderer.render(this._scene,this._camera)}_applyTheme(){let r=fk().bgMap||"#000000";this._scene.background=new $s.Color(r)}async loadData(){if(!(this._loading||this._destroyed)){this._loading=!0;for(let n of[".three-d-error",".three-d-info"]){let r=this._element.querySelector(n);r&&r.remove()}try{await this._app.websocketManager.readyPromise;let n=await this._app.websocketManager.request({type:"get_3d_data"});if(this._destroyed)return;if(n&&n.error){this._showError(n.error);return}if(n&&n.info){this._showInfo(n.info);return}this.buildScene(n)}catch(n){if(this._destroyed)return;console.error("Failed to load 3D data:",n),this._showError(n.message||String(n))}finally{this._loading=!1}}}_showOverlay(n,r,c){let u=document.createElement("div");u.className=n,u.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-family:monospace;text-align:center;",u.style.color=c,u.textContent=r,this._element.appendChild(u)}_showError(n){this._showOverlay("three-d-error","Failed to load 3D data: "+n,"var(--error)")}_showInfo(n){this._showOverlay("three-d-info",n,"var(--fg-muted, #888)")}_showWebGLUnavailable(n){let r=document.createElement("div");r.className="three-d-error",r.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-family:monospace;text-align:center;max-width:80%;color:var(--error);";let c=n&&n.message?n.message:String(n||"");r.innerHTML='
3D viewer unavailable: WebGL context could not be created.
In Chrome, open chrome://flags/#ignore-gpu-blocklist and set Override software rendering list to Enabled, then relaunch the browser.
Otherwise enable hardware acceleration or try a different browser. See chrome://gpu for details.
'+(c?'
'+c+"
":""),this._element.appendChild(r)}buildScene(n){if(this._destroyed||(this._lastSceneData=n,this._clearScene(),!n||!n.chiplets||n.chiplets.length===0))return;let r=this._app.getDbuPerMicron(),c=this._buildChiplets(n.chiplets,r);c.minX!==1/0&&(this._buildGrid(c),this._setSceneBoundsAndCenter(c),this._setInitialCameraState(),this._updateCamera())}_clearScene(){for(this._chipletMeshes=[];this._designGroup.children.length>0;){let n=this._designGroup.children[0];this._designGroup.remove(n),n.geometry&&n.geometry.dispose(),n.material&&!n.material._shared&&n.material.dispose()}this._hideTooltip()}_buildChiplets(n,r){let c={minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0};this._edgeMaterial||(this._edgeMaterial=new $s.LineBasicMaterial({color:0,linewidth:1}),this._edgeMaterial._shared=!0);let u=this._app.useTrueZ?new Array(n.length).fill(0):vpn(n);return n.forEach((d,b)=>{let w=d.width/r,_=d.height/r,x=d.thickness/r*gk,T=z3t[b%z3t.length],M=new $s.MeshPhongMaterial({color:T,transparent:!1,opacity:1,side:$s.DoubleSide,shininess:40}),L=new $s.BoxGeometry(w,_,x),I=new $s.Mesh(L,M),D=d.x/r+w/2,F=d.y/r+_/2,O=x*mpn,z=d.z/r*gk+x/2+u[b]*(x+O);I.position.set(D,F,z),this._designGroup.add(I),this._chipletMeshes.push({mesh:I,data:d,color:T});let Z=new $s.EdgesGeometry(L),H=new $s.LineSegments(Z,this._edgeMaterial);H.position.set(D,F,z),this._designGroup.add(H),c.minX=Math.min(c.minX,d.x/r),c.minY=Math.min(c.minY,d.y/r),c.minZ=Math.min(c.minZ,z-x/2),c.maxX=Math.max(c.maxX,d.x/r+w),c.maxY=Math.max(c.maxY,d.y/r+_),c.maxZ=Math.max(c.maxZ,z+x/2)}),c}_buildGrid(n){let r=n.maxX-n.minX,c=n.maxY-n.minY,u=Math.max(r,c)*1.4,d=10,b=new $s.GridHelper(u,d,8947848,4473924);b.rotation.x=Math.PI/2,b.position.set((n.minX+n.maxX)/2,(n.minY+n.maxY)/2,n.minZ-1),this._designGroup.add(b)}_setSceneBoundsAndCenter(n){this._sceneBounds=n;let r=n.maxX-n.minX,c=n.maxY-n.minY,u=n.maxZ-n.minZ;this._boundingRadius=Math.sqrt(r*r+c*c+u*u)/2,this._sceneCenter.set((n.minX+n.maxX)/2,(n.minY+n.maxY)/2,(n.minZ+n.maxZ)/2)}_stackOffsetForPoint(n,r,c,u){for(let{mesh:d,data:b}of this._chipletMeshes){if(n!==b.z||rb.x+b.width||cb.y+b.height)continue;let w=b.thickness/u*gk,_=b.z/u*gk+w/2;return d.position.z-_}return 0}clearHighlightDRC(){this._drcBlinkInterval&&(clearInterval(this._drcBlinkInterval),this._drcBlinkInterval=null),this._drcMeshGroup&&(this._scene.remove(this._drcMeshGroup),this._drcMeshGroup.children.forEach(n=>{n.geometry&&n.geometry.dispose()}),this._drcMaterial&&(this._drcMaterial.dispose(),this._drcMaterial=null),this._drcHitboxMaterial&&(this._drcHitboxMaterial.dispose(),this._drcHitboxMaterial=null),this._drcHitboxMesh=null,this._drcHitboxMarkerIds=null,this._drcMeshGroup=null,this.render())}highlightDRC(n){if(this._destroyed||(this.clearHighlightDRC(),!n||n.length===0))return;let r=this._app.getDbuPerMicron(),c=0,u=1e4/r*gk;this._sceneBounds&&this._sceneBounds.minZ!==1/0&&(c=this._sceneBounds.minZ,u=this._sceneBounds.maxZ),c-=1,u+=1;let d=Math.max(u-c,1);this._drcMeshGroup=new $s.Group,this._drcMaterial=new $s.LineBasicMaterial({color:16776960,transparent:!0,opacity:1,depthTest:!1,depthWrite:!1}),this._drcHitboxMaterial=new $s.MeshBasicMaterial({transparent:!0,opacity:0,depthWrite:!1});let b=[];for(let x of n){let T=x.rects&&x.rects.length>0?x.rects:[x.bbox];for(let M of T){let[L,I,D,F,O,z]=M,Z=Math.max((D-L)/r,.001),H=Math.max((F-I)/r,.001),te=c,se=d,ne=0;if(M.length>=6&&O!==void 0&&z!==void 0){te=O/r*gk;let me=z/r*gk;se=Math.max(me-te,.001),ne=this._stackOffsetForPoint(O,(L+D)/2,(I+F)/2,r)}let ue=L/r+Z/2,Ce=I/r+H/2,Q=te+se/2+ne;b.push({cx:ue,cy:Ce,cz:Q,width:Z,height:H,depth:se,markerId:x.id})}}if(b.length>0){let x=new $s.BoxGeometry(1,1,1);this._drcHitboxMesh=new $s.InstancedMesh(x,this._drcHitboxMaterial,b.length),this._drcHitboxMarkerIds=new Array(b.length);let T=new $s.Matrix4,M=new $s.Vector3,L=new $s.Vector3,I=new $s.Quaternion;b.forEach((D,F)=>{L.set(D.cx,D.cy,D.cz),M.set(D.width,D.height,D.depth),T.compose(L,I,M),this._drcHitboxMesh.setMatrixAt(F,T),this._drcHitboxMarkerIds[F]=D.markerId;let O=new $s.BoxGeometry(D.width,D.height,D.depth),z=new $s.EdgesGeometry(O);O.dispose();let Z=new $s.LineSegments(z,this._drcMaterial);Z.position.set(D.cx,D.cy,D.cz),Z.renderOrder=999,this._drcMeshGroup.add(Z)}),this._drcHitboxMesh.instanceMatrix.needsUpdate=!0,this._drcMeshGroup.add(this._drcHitboxMesh)}this._drcMeshGroup.renderOrder=999,this._scene.add(this._drcMeshGroup),this.render();let w=!0,_=0;this._drcBlinkInterval=setInterval(()=>{if(!(!this._drcMeshGroup||!this._drcMaterial)){if(_+=1,_>=wpn){this._drcMaterial.opacity=1,this.render(),clearInterval(this._drcBlinkInterval),this._drcBlinkInterval=null;return}w=!w,this._drcMaterial.opacity=w?1:.2,this.render()}},bpn)}refreshSceneForOptions(){this._destroyed||this._lastSceneData&&(this.clearHighlightDRC(),this.buildScene(this._lastSceneData))}};var _pn=[{name:"green",hex:"#00ff00"},{name:"yellow",hex:"#ffff00"},{name:"cyan",hex:"#00ffff"},{name:"magenta",hex:"#ff00ff"},{name:"red",hex:"#ff0000"},{name:"dark_green",hex:"#008000"},{name:"dark_magenta",hex:"#800080"},{name:"blue",hex:"#0000ff"},{name:"orange",hex:"#ffa500"},{name:"purple",hex:"#800080"},{name:"lime",hex:"#bfff00"},{name:"teal",hex:"#008080"},{name:"pink",hex:"#ffc0cb"},{name:"brown",hex:"#8b4513"},{name:"indigo",hex:"#4b0082"},{name:"turquoise",hex:"#40e0d0"}],ypn=[{label:"Connected Insts",suffix:"connected_insts",needsNet:!0},{label:"Output Nets",suffix:"connected_nets",args:{output:!0,input:!1}},{label:"Input Nets",suffix:"connected_nets",args:{output:!1,input:!0}},{label:"All Nets",suffix:"connected_nets",args:{output:!0,input:!0}},{label:"All buffer trees",suffix:"connected_buffer_trees"},{label:"All buffer trees (incl. inverters)",suffix:"connected_buffer_trees",args:{include_inverters:!0}}],pde=class{constructor(n){this._app=n,this._el=document.createElement("div"),this._el.className="context-menu",this._el.style.display="none",this._el.style.zIndex="10000",document.body.appendChild(this._el),this._bindEvents()}_bindEvents(){document.addEventListener("mousedown",n=>{this._el.contains(n.target)||this.hide()}),this._app.view&&this._app.view.on("movestart",()=>this.hide())}show(n){this._el.innerHTML="";let r=!!this._app.selHasInst,c=!!this._app.selHasNet,u=!(r||c),d=I=>ypn.map(D=>({label:D.label,disabled:D.needsNet?!c:!r,...I(D.suffix,D.args||{})})),b=[{label:"Select",disabled:u,subMenu:d((I,D)=>({action:()=>this._sendContextAction("select_"+I,D)}))},{label:"Highlight",disabled:u,subMenu:d((I,D)=>({subMenu:this._buildColorSubmenu("highlight_"+I,D)}))},{label:"Save",subMenu:[{label:"Visible layout",action:()=>this._app.captureLayout?.({entire:!1})},{label:"Entire layout",action:()=>this._app.captureLayout?.({entire:!0})}]},{label:"Clear",subMenu:[{label:"Selections",action:()=>this._sendContextAction("clear_selections")},{label:"Highlights",action:()=>this._sendContextAction("clear_highlights")},{label:"Rulers",action:()=>{this._app.rulerManager?.clearAllRulers()}},{label:"Focus nets",action:()=>this._sendContextAction("clear_focus_nets")},{label:"Route Guides",action:()=>this._sendContextAction("clear_route_guides")},{label:"All",action:()=>{this._sendContextAction("clear_all"),this._app.rulerManager?.clearAllRulers()}}]}];this._buildMenu(b,this._el),this._el.style.display="block";let w=4,_=this._el.getBoundingClientRect(),x=window.innerWidth-_.width-w,T=window.innerHeight-_.height-w,M=Math.max(w,Math.min(n.clientX,x)),L=Math.max(w,Math.min(n.clientY,T));this._el.style.left=M+"px",this._el.style.top=L+"px"}hide(){this._el.style.display="none"}_buildColorSubmenu(n,r={}){return _pn.map(({name:c,hex:u},d)=>({label:c,swatch:u,action:()=>this._sendContextAction(n,{...r,group:d})}))}_buildMenu(n,r){n.forEach(c=>{let u=document.createElement("div");if(u.className="cm-item",c.swatch){let d=document.createElement("span");d.className="cm-swatch",d.style.background=c.swatch,u.appendChild(d)}if(u.appendChild(document.createTextNode(c.label)),c.disabled){u.classList.add("disabled"),c.subMenu&&u.classList.add("has-submenu"),r.appendChild(u);return}if(c.subMenu){u.classList.add("has-submenu");let d=document.createElement("div");d.className="cm-submenu",this._buildMenu(c.subMenu,d),u.appendChild(d),u.addEventListener("mouseenter",()=>{d.classList.remove("flip-left"),d.getBoundingClientRect().right>window.innerWidth&&d.classList.add("flip-left")})}else c.action&&u.addEventListener("click",d=>{d.stopPropagation(),this.hide();try{c.action()}catch(b){console.error("Context menu item action threw:",c.label,b)}});r.appendChild(u)})}_sendContextAction(n,r={}){this._app.websocketManager&&this._app.websocketManager.request({type:"context_action",action:n,...r}).then(c=>{EO(this._app,c),c&&c.connected_count===0&&Nb('Nothing connected \u2014 select an instance (or a net for "Connected Insts") first.'),this._syncAfterAction(n)}).catch(c=>{console.error("Context action failed:",n,c)})}_syncAfterAction(n){let r=this._app;(n==="clear_focus_nets"||n==="clear_route_guides"||n==="clear_all")&&typeof r.redrawAllLayers=="function"&&r.redrawAllLayers(),n==="clear_selections"||n==="clear_all"?(r.updateInspector?.(null),r.stopSelectionAnimation?.(),r.clearSelectionOutline?.(),r.lastSelectionBounds=null):r.refreshInspector?.(),r.refreshOverlay?.()}};function G3t(s,n){if(!s)return;let r=URL.createObjectURL(s),c=document.createElement("a");c.href=r,c.download=n,c.style.display="none",document.body.appendChild(c),c.click(),document.body.removeChild(c),setTimeout(()=>URL.revokeObjectURL(r),0)}function xpn(s,n,r){s.view.getContainer().querySelectorAll(".or-view-markers .ruler-label").forEach(u=>{let d=u.getBoundingClientRect();if(d.width<=0||d.height<=0)return;let b=u.textContent;if(!b)return;let w=getComputedStyle(u),_=d.left-r.left,x=d.top-r.top;n.save(),n.fillStyle=w.backgroundColor||"rgba(0, 0, 0, 0.75)";let T=Math.min(parseFloat(w.borderTopLeftRadius)||0,d.height/2);T>0&&typeof n.roundRect=="function"?(n.beginPath(),n.roundRect(_,x,d.width,d.height,T),n.fill()):n.fillRect(_,x,d.width,d.height),n.fillStyle=w.color||"#eee",n.font=w.font||`${w.fontSize||"12px"} ${w.fontFamily||"monospace"}`,n.textAlign="left",n.textBaseline="middle",n.fillText(b,_+(parseFloat(w.paddingLeft)||0),x+d.height/2),n.restore()})}async function j3t(s){let n=s.view.getContainer(),r=n.getBoundingClientRect(),c=Math.max(1,Math.round(r.width)),u=Math.max(1,Math.round(r.height)),d=document.createElement("canvas");d.width=c,d.height=u;let b=d.getContext("2d"),w=getComputedStyle(n).backgroundColor;b.fillStyle=w&&w!=="transparent"&&w!=="rgba(0, 0, 0, 0)"?w:"#000",b.fillRect(0,0,c,u);let _=await s.view.captureCanvas();if(_){let x=_.rect;try{b.drawImage(_.image,x.left-r.left,x.top-r.top,x.width,x.height)}catch{}}return xpn(s,b,r),new Promise(x=>d.toBlob(x,"image/png"))}async function $3t(s,{entire:n=!1}={}){if(!s.view)return;if(!n||!s.fitRect){G3t(await j3t(s),"layout_visible.png");return}let r=s.view.getCenter(),c=s.view.getZoom();try{s.view.fitWorldRect(s.fitRect,{animate:!1}),await s.view.whenTilesSettled(),G3t(await j3t(s),"layout_entire.png")}finally{s.view.setView(r,c,{animate:!1})}}var MT=document.getElementById("websocket-status"),cH=null,Epn=2e3,Spn=20;function W3t(){let s=he.websocketManager&&he.websocketManager.isConnected,n=he.websocketManager?he.websocketManager.pendingCount:0;if(s)if(cH&&(clearTimeout(cH),cH=null),n>Spn){let r=`pending: ${n}`,c=MT.firstElementChild;(!c?.classList.contains("pending-indicator")||c.textContent!==r)&&(MT.innerHTML=`
${r}
`),MT.style.display="block"}else MT.style.display="none";else{if(he.websocketManager?._shutdown)return;cH||(cH=setTimeout(()=>{he.websocketManager?.isConnected||(MT.innerHTML='
\u26A0 OpenROAD disconnected \u2014 retrying\u2026
',MT.style.display="block")},Epn))}Mpn(n)}function Mpn(s){let n=he.tileProgressEl;if(!n)return;n.classList.toggle("active",s>0);let r=s>0?`${s} tile requests pending`:"";n.title!==r&&(n.title=r)}var V3t=_T(W3t);function Tpn(s){if(!s)return"";try{return decodeURIComponent(s)}catch{return""}}var he={view:null,fitRect:null,lastSelectionBounds:null,selHasInst:!1,selHasNet:!1,displayControlsEl:null,allLayers:[],designScale:null,designOriginX:0,designOriginY:0,websocketManager:null,goldenLayout:null,hasLiberty:!1,techData:null,inspectorEl:null,tclOutputEl:null,modulesLayer:null,pinsLayer:null,overlayLayers:[],hierarchyBrowser:null,focusNets:new Set,routeGuideNets:new Set,visibleLayers:new Set,visibleLayerNames:new Set,visibleChiplets:null,layerPatterns:{},useTrueZ:pf("or_use_true_z")==="1",showDbu:pf("or_show_dbu")==="1",rulerStyle:pf("or_ruler_style")==="manhattan"?"manhattan":"euclidian",wheelZoom:pf("or_wheel_zoom")!=="0",arrowStep:tH(pf("or_arrow_step")),controlSmoothing:pf("or_control_smoothing")!=="0",doubleBuffer:pf("or_double_buffer")!=="0",deferTileUpdates:pf("or_defer_tile_updates")==="1",fontFamily:Tpn(pf("or_font_family")),fontScale:rH(pf("or_font_scale")),polyDecomp:!1,labelManager:null,selectableLayers:new Set,heatMapData:null,activeHeatMap:"",heatMapLayer:null,heatMapLegendEl:null,renderHeatMapControls:null,rulerManager:null,selectionToken:0,selectionResetters:[],getDbuPerMicron(){return this.techData?.dbu_per_micron||1e3},unitOpts(){return{showDbu:this.showDbu,dbuPerMicron:this.getDbuPerMicron()}},formatDbu(s,n=!1){return Uxt(s,this.unitOpts(),n)},parseDbu(s){return zxt(s,this.unitOpts())},formatDistance(s){return Gxt(s,this.unitOpts())},unitLabel(){return jxt(this.unitOpts())}},gg={stdcells:!0,macros:!0,pad_input:!0,pad_output:!0,pad_inout:!0,pad_power:!0,pad_spacer:!0,pad_areaio:!0,pad_other:!0,phys_fill:!1,phys_endcap:!0,phys_welltap:!0,phys_tie:!0,phys_antenna:!0,phys_cover:!0,phys_bump:!0,phys_other:!0,std_bufinv:!0,std_bufinv_timing:!0,std_clock_bufinv:!0,std_clock_gate:!0,std_level_shift:!0,std_sequential:!0,std_combinational:!0,net_signal:!0,net_power:!0,net_ground:!0,net_clock:!0,net_reset:!0,net_tieoff:!0,net_scan:!0,net_analog:!0,inst_names:!0,inst_pins:!0,inst_pin_names:!1,routing:!0,routing_segments:!0,routing_vias:!0,special_nets:!0,srouting_segments:!0,srouting_vias:!0,pins:!0,pin_names:!0,access_points:!1,regions:!0,mfg_grid:!1,gcell_grid:!1,flywires_only:!1,blockages:!0,placement_blockages:!0,routing_obstructions:!0,fills:!1,rows:!1,tracks_pref:!1,tracks_non_pref:!1,module_view:!1,detailed:!1,rulers:!0,labels:!0,scale_bar:!0,focused_nets_guides:!1,highlight_selected:!0,debug:!1};try{let s=pf("or_visibility");if(s){let n=JSON.parse(decodeURIComponent(s));for(let[r,c]of Object.entries(n))gg[r]=!!c}}catch{}var LO={stdcells:!0,macros:!0,pad_input:!0,pad_output:!0,pad_inout:!0,pad_power:!0,pad_spacer:!0,pad_areaio:!0,pad_other:!0,phys_fill:!0,phys_endcap:!0,phys_welltap:!0,phys_tie:!0,phys_antenna:!0,phys_cover:!0,phys_bump:!0,phys_other:!0,std_bufinv:!0,std_bufinv_timing:!0,std_clock_bufinv:!0,std_clock_gate:!0,std_level_shift:!0,std_sequential:!0,std_combinational:!0,net_signal:!0,net_power:!0,net_ground:!0,net_clock:!0,net_reset:!0,net_tieoff:!0,net_scan:!0,net_analog:!0,pins:!0,inst_pins:!0,placement_blockages:!0,routing_obstructions:!0};he.visibility=gg;he.selectability=LO;try{let s=pf("or_selectability");if(s){let n=JSON.parse(decodeURIComponent(s));for(let[r,c]of Object.entries(n))LO[r]=!!c}}catch{}(function(){let n=null;try{n=new URLSearchParams(window.location.search)}catch{return}he.forceComposite=n.get("composite")==="1",he.preserveBuffer=n.get("preservebuffer")==="1";let r=Number(n.get("grouplayers"));Number.isFinite(r)&&r>0&&(he.groupLayers=Math.floor(r))})();he.tileCtx={visibility:gg,selectability:LO,visibleLayers:he.visibleLayerNames,selectableLayers:he.selectableLayers,app:he};function Cpn(){return he.view.addTileSlot("heatmap",{order:mp.heatmap,visible:!!he.activeHeatMap,source:G5e({wm:he.websocketManager,dpr:xO,tileSize:Ob,buildRequest:(s,n,r)=>Pxt(s,n,r,he)})})}function rDe(s){if(he.heatMapData=s,he.activeHeatMap=s.active||"",he.heatMapLayer){let n=he.heatMapLayer.isVisible();he.heatMapLayer.setVisible(!!he.activeHeatMap),n&&he.heatMapLayer.refresh()}he.renderHeatMapControls&&he.renderHeatMapControls(s)}he.updateHeatMaps=rDe;function sDe(){he.overlayLayer&&he.overlayLayer.refresh()}var mk=_T(()=>{sDe(),he.selectionBrowser&&he.selectionBrowser.scheduleRefresh()});he.refreshOverlay=mk;function K1(){Ff("or_visibility",encodeURIComponent(JSON.stringify(gg))),Ff("or_selectability",encodeURIComponent(JSON.stringify(LO))),Fb();let s=[[he.modulesLayer,gg.module_view],[he.pinsLayer,gg.pins],...he.overlayLayers.map(({def:n,layer:r})=>[r,nde(n.shown_by,gg)])];for(let[n,r]of s)n&&(n.visible=!!r);for(let n of he.allLayers)n.refresh();he.heatMapLayer&&he.heatMapLayer.refresh(),he.renderSelectionOutline&&he.renderSelectionOutline(),!gg.highlight_selected&&he.clearSelectionPulse&&he.clearSelectionPulse(),sDe(),he.rulerManager&&he.rulerManager.updateVisibility(),he.labelManager&&he.labelManager.updateVisibility(),he.updateScaleBar&&he.updateScaleBar()}var PO=_T(K1),Fb=_T(()=>{!he.websocketManager||la(he)||he.websocketManager.request({type:"set_display_state",state:B3t()}).catch(()=>{})});he.syncDisplayState=Fb;function Apn(s){if(!s||typeof s!="object")return;let n=s.entries;if(!(!n||typeof n!="object")){O3t(n);try{if(he.view&&he.designScale&&typeof sessionStorage<"u"){let[r,c]=he.view.getCenter(),{dbuX:u,dbuY:d}=Pv(r,c,he.designScale,he.designOriginX,he.designOriginY);sessionStorage.setItem("or_restore_view",JSON.stringify({dbuX:u,dbuY:d,zoom:he.view.getZoom()}))}}catch{}window.location.reload()}}he.redrawAllLayers=K1;he.captureLayout=(s={})=>$3t(he,s);function Ppn(s){let n=document.createElement("div");n.className="layout-viewer",n.style.width="100%",n.style.height="100%",n.style.backgroundColor="var(--bg-map)",s.element.appendChild(n);let r=document.createElement("div");r.className="or-hud or-hud-bottom-right heatmap-map-legend hidden",n.appendChild(r),he.heatMapLegendEl=r;let c=document.createElement("div");c.className="or-progress",n.appendChild(c),he.tileProgressEl=c,s.on("destroy",()=>{he.tileProgressEl=null,he.heatMapLegendEl=null}),he.view=Kxt(n,{preserveDrawingBuffer:he.preserveBuffer,prefs:{smooth:()=>he.controlSmoothing,doubleBuffer:()=>he.doubleBuffer,defer:()=>he.deferTileUpdates},tileSize:Ob,dpr:xO,isStatic:la(he)}),he.view.on("contextlost",()=>{console.warn("Layout view: WebGL context lost; rebuilding the view.")}),he.view.on("contextfailed",()=>{Nb("The layout view lost its graphics context and could not get it back; reload the page.",15e3)}),window.__orView=he.view,bxt(()=>{he.view.invalidateSize(),K1()});let u=document.createElement("div");u.className="or-zoom-control";let d=[];for(let[Z,H,te]of[["+","Zoom in",()=>he.view.zoomIn()],["\u2212","Zoom out",()=>he.view.zoomOut()],["\u2922","Fit",()=>{he.fitRect&&he.view.fitWorldRect(he.fitRect)}]]){let se=document.createElement("button");se.type="button",se.title=H,se.setAttribute("aria-label",H),se.textContent=Z,se.addEventListener("click",ne=>{ne.stopPropagation(),te()}),u.appendChild(se),d.push(se)}n.appendChild(u);let b=()=>{let{minZoom:Z,maxZoom:H}=he.view.getLimits(),te=he.view.getTargetZoom();d[0].disabled=te>=H,d[1].disabled=te<=Z};he.view.on("zoom zoomend limits",b),b();let w=document.createElement("div");w.className="or-hud or-hud-bottom-left hidden";let _=document.createElement("div");_.id="scale-bar";let x=document.createElement("span");x.className="or-hud-divider";let T=document.createElement("div");T.id="coord-bar",w.appendChild(_),w.appendChild(x),w.appendChild(T),n.appendChild(w);function M(){let Z=_.style.display!=="none"&&_.childElementCount>0,H=T.textContent!=="";x.style.display=Z&&H?"":"none",w.classList.toggle("hidden",!Z&&!H)}M(),Qxt(he.view,{isStatic:()=>la(he),wheelZoom:()=>he.wheelZoom,arrowStep:()=>he.arrowStep,contextEnabled:()=>!(he.rulerManager&&he.rulerManager.isActive()),onClick:(Z,H)=>{he.rulerManager&&he.rulerManager.isActive()?he.rulerManager.handleMapClick(Z,H):he.rulerManager?.handleRulerClick(Z)||he.onMapClick&&he.onMapClick(Z,H)},onContextClick:(Z,H)=>{he.onMapContextClick&&he.onMapContextClick(Z,H)},onMove:(Z,H)=>{if(he.lastMouseWorld=Z,he.rulerManager&&he.rulerManager.isActive()&&he.rulerManager.handleMouseMove(Z,H),!he.designScale)return;let{dbuX:te,dbuY:se}=Pv(Z[0],Z[1],he.designScale,he.designOriginX,he.designOriginY);T.textContent=`X: ${he.formatDbu(te)} Y: ${he.formatDbu(se)}`,M()},onLeave:()=>{he.lastMouseWorld=null,T.textContent="",M()}});let L=22,I=8,D=22;function F(Z,H,te){let ne=2+I,ue=D,Ce=D+Z,Q=L-2,me=Z>=40,tt=[];if(tt.push(``),me&&te>1)for(let st=1;st`)}me&&tt.push(`0`),tt.push(`${H}`),_.innerHTML=`${tt.join("")}`}function O(){if(!he.designScale||!gg.scale_bar){_.style.display="none",M();return}let Z=he.designScale*Math.pow(2,he.view.getZoom()),H=he.view.getSize().width||400,te=Vxt({targetPx:H*.15,pxPerDbu:Z,dbuPerMicron:he.techData?.dbu_per_micron,showDbu:he.showDbu});if(!te){_.style.display="none",M();return}_.style.display="",F(te.barPx,te.label,te.segments),M()}let z=_T(O);he.view.on("zoom zoomend resize",z),he.updateScaleBar=O,he.rulerManager=new ode(he,gg,lH,gde),he.labelManager=new cde(he,gg,lH,gde)}function Lpn(s){let n=document.createElement("div");n.className="display-controls",n.innerHTML='
Loading layers...
',s.element.appendChild(n),he.displayControlsEl=n}var iDe="or_restore_console",kpn=1<<20;function Rpn(){try{if(he.tclOutputEl){let s=[...he.tclOutputEl.children].map(u=>[u.textContent,u.className]),n=s.length,r=0;for(;n>0&&r+s[n-1][0].length<=kpn;)r+=s[--n][0].length;let c=s.slice(n);n>0&&c.unshift([`[earlier output not kept across reload] -`,""]),sessionStorage.setItem(iDe,JSON.stringify(c))}}catch{}window.location.reload()}function Ipn(){try{let s=sessionStorage.getItem(iDe);if(!s)return;sessionStorage.removeItem(iDe);for(let[n,r]of JSON.parse(s))TT(n,r)}catch{}}function TT(s,n){if(!he.tclOutputEl)return;let r=document.createElement("span");n&&(r.className=n),r.textContent=s,he.tclOutputEl.appendChild(r),he.tclOutputEl.scrollTop=he.tclOutputEl.scrollHeight}function Dpn(){if(he._shutdownHandled)return;he._shutdownHandled=!0,he.websocketManager&&(he.websocketManager._shutdown=!0,he.websocketManager.onPush=()=>{});let s=document.createElement("div");s.style.cssText="position:fixed;inset:0;z-index:99999;background:#1e1e1e;color:#ddd;display:flex;flex-direction:column;align-items:center;justify-content:center;font-family:system-ui,sans-serif;font-size:16px;padding:24px;text-align:center;",s.innerHTML='
OpenROAD exited
You can close this tab.
',document.body.appendChild(s),setTimeout(()=>{try{window.close()}catch{}},1500)}function Bpn(s){let n=document.createElement("div");if(n.className="tcl-console",n.innerHTML='
%
',s.element.appendChild(n),he.tclOutputEl=n.querySelector(".tcl-output"),Ipn(),la(he)){n.querySelector(".tcl-input-row").style.display="none";let u=document.createElement("span");u.className="tcl-static-notice",u.setAttribute("role","status"),u.setAttribute("aria-live","polite"),u.textContent="Tcl console is not available in saved reports.",he.tclOutputEl.appendChild(u);return}let r=n.querySelector(".tcl-input"),c=new fde(r,he.websocketManager);r.addEventListener("keydown",u=>{if(!c.handleKeyDown(u)&&u.key==="Enter"){let d=r.value.trim();if(!d)return;TT(`>>> ${d} -`,"tcl-cmd"),c.addToHistory(d),r.value="",he.websocketManager.request({type:"tcl_eval",cmd:d}).then(b=>{b.result&&TT(b.result+` -`,b.is_error?"tcl-error":""),b.action==="shutdown"&&Dpn(),!b.is_error&&he.drcWidget&&he.drcWidget.refresh()}).catch(b=>TT(`Error: ${b} -`,"tcl-error"))}})}he.visibility=gg;var CT=f3t(he,K1,mk),Opn=CT.createInspector,lH=CT.updateInspector,Npn=CT.highlightBBox,Fpn=CT.pulseHighlight;he.updateInspector=lH;he.navigateInspector=CT.navigateInspector;he.refreshInspector=CT.refreshInspector;he.animateSelection=CT.animateSelection;he.stopSelectionAnimation=CT.stopSelectionAnimation;function Upn(s){new Khe(s,he,K1)}function zpn(s){he.timingWidget=new uk(he,K1,mk),s.element.appendChild(he.timingWidget.element)}function Gpn(s){he.drcWidget=new ude(he,K1,mk),s.element.appendChild(he.drcWidget.element)}function jpn(s){he.clockTreeWidget=new Yhe(s,he,K1,mk)}function $pn(s){he.chartsWidget=new Zhe(he,K1),s.element.appendChild(he.chartsWidget.element)}function Vpn(s){let n=document.createElement("div");n.className="help-panel",n.innerHTML="

Keyboard Shortcuts

fFit design to viewport
scrollZoom in/out
dragPan the view
right-dragRubber-band zoom
Shift+clickAdd object to selection
Ctrl/Cmd+clickSelect object and its connected nets
kToggle ruler mode
Shift+KClear all rulers
EscapeCancel ruler (when building)
",s.element.appendChild(n)}function Wpn(s){he.selectionBrowser=new Jhe(s,he,mk)}function Hpn(s){new lde(s,he)}function qpn(s){he.threeDViewerWidget=new dde(s,he)}var Xpn=28,Ypn={dimensions:{headerHeight:Xpn},root:{type:"row",content:[{type:"component",componentType:"DisplayControls",title:"Display Controls",width:15},{type:"column",width:55,content:[{type:"stack",height:70,content:[{type:"component",componentType:"LayoutViewer",title:"Layout",isClosable:!1},{type:"component",componentType:"SchematicWidget",title:"Schematic"},{type:"component",componentType:"3DViewer",title:"3D Viewer"}]},{type:"component",componentType:"TclConsole",title:"Tcl Console",height:30}]},{type:"stack",width:30,content:[{type:"component",componentType:"Inspector",title:"Inspector"},{type:"component",componentType:"Browser",title:"Hierarchy"},{type:"component",componentType:"TimingWidget",title:"Timing"},{type:"component",componentType:"DRCWidget",title:"DRC"},{type:"component",componentType:"SelectHighlight",title:"Select Highlight"},{type:"component",componentType:"ClockWidget",title:"Clock Tree"},{type:"component",componentType:"ChartsWidget",title:"Charts"},{type:"component",componentType:"HelpWidget",title:"Help"}]}]}};he.goldenLayout=new Bhe(document.getElementById("gl-container"));he.goldenLayout.registerComponentFactoryFunction("LayoutViewer",Ppn);he.goldenLayout.registerComponentFactoryFunction("DisplayControls",Lpn);he.goldenLayout.registerComponentFactoryFunction("TclConsole",Bpn);he.goldenLayout.registerComponentFactoryFunction("Inspector",Opn);he.goldenLayout.registerComponentFactoryFunction("Browser",Upn);he.goldenLayout.registerComponentFactoryFunction("TimingWidget",zpn);he.goldenLayout.registerComponentFactoryFunction("DRCWidget",Gpn);he.goldenLayout.registerComponentFactoryFunction("ClockWidget",jpn);he.goldenLayout.registerComponentFactoryFunction("ChartsWidget",$pn);he.goldenLayout.registerComponentFactoryFunction("SchematicWidget",Hpn);he.goldenLayout.registerComponentFactoryFunction("3DViewer",qpn);he.goldenLayout.registerComponentFactoryFunction("HelpWidget",Vpn);he.goldenLayout.registerComponentFactoryFunction("SelectHighlight",Wpn);var m2=window.__STATIC_CACHE__||null;if(m2)fxt(),he.websocketManager=ZW.fromCache(m2,V3t);else{let s=`ws://${window.location.host||"localhost:8080"}/ws`;he.websocketManager=new ZW(s,V3t),he.layerExtents=new Ghe,he.websocketManager.onReconnected=()=>{mde(),cDe(null,null,{reloadOnChange:!0}).catch(()=>{})}}W3t();he.goldenLayout.loadLayout(Ypn);H3t();function H3t(){Wxt(document.getElementById("gl-container"))>0&&he.goldenLayout.updateSize()}he.goldenLayout.on("stateChanged",()=>{H3t()});function oDe(){he.goldenLayout.updateSize()}he.syncLayoutSize=oDe;window.addEventListener("resize",oDe);function gde(s){he.goldenLayout.focusComponent(s)}he.focusComponent=gde;he.resetLayout=function(){he.goldenLayout&&typeof he.goldenLayout.resetLayout=="function"&&he.goldenLayout.resetLayout()};he.toggleTheme=function(){let s=document.documentElement.dataset.theme==="dark"?"light":"dark";document.documentElement.dataset.theme=s,H5e(s),Whe(s),he.chartsWidget&&he.chartsWidget.render(),he.clockTreeWidget&&he.clockTreeWidget.render(),Fb()};he.toggleShowDbu=function(){he.showDbu=!he.showDbu,Ff("or_show_dbu",he.showDbu?"1":"0"),he.rulerManager&&he.rulerManager._renderAll(),he.hierarchyBrowser&&he.hierarchyBrowser._render(),he.updateScaleBar&&he.updateScaleBar(),he.refreshInspector&&he.refreshInspector(),Fb()};he.toggleRulerStyle=function(){he.rulerStyle=he.rulerStyle==="manhattan"?"euclidian":"manhattan",Ff("or_ruler_style",he.rulerStyle),Fb()};he.toggleWheelZoom=function(){he.wheelZoom=!he.wheelZoom,Ff("or_wheel_zoom",he.wheelZoom?"1":"0"),Fb()};he.toggleControlSmoothing=function(){he.controlSmoothing=!he.controlSmoothing,Ff("or_control_smoothing",he.controlSmoothing?"1":"0"),Fb()};he.toggleDoubleBuffer=function(){he.doubleBuffer=!he.doubleBuffer,Ff("or_double_buffer",he.doubleBuffer?"1":"0"),he.view?.applyPrefs(),Fb()};he.toggleDeferTileUpdates=function(){he.deferTileUpdates=!he.deferTileUpdates,Ff("or_defer_tile_updates",he.deferTileUpdates?"1":"0"),he.view?.applyPrefs(),Fb()};he.setArrowStep=function(s){he.arrowStep=tH(s),Ff("or_arrow_step",String(he.arrowStep)),Fb()};he.setAppFont=function({family:s,scale:n}){he.fontFamily=s??he.fontFamily,he.fontScale=rH(n??he.fontScale),Ff("or_font_family",encodeURIComponent(he.fontFamily)),Ff("or_font_scale",String(he.fontScale)),he.applyAppFont(),Fb()};he.applyAppFont=function(){let s=document.documentElement;he.fontFamily?s.style.setProperty("--or-font-family",he.fontFamily):s.style.removeProperty("--or-font-family"),s.style.setProperty("--or-font-scale",String(he.fontScale/100)),he.chartsWidget&&he.chartsWidget.render(),he.clockTreeWidget&&he.clockTreeWidget.render()};he.showArrowStepDialog=()=>p3t(he);he.showAppFontDialog=()=>g3t(he);he.togglePolyDecomp=function(){he.websocketManager&&he.websocketManager.request({type:"poly_decomp",value:!he.polyDecomp}).then(s=>aDe(s.value)).catch(()=>{})};function aDe(s){he.polyDecomp=!!s,he.rebuildMenuBar&&he.rebuildMenuBar(),he.refreshOverlay&&he.refreshOverlay()}he.applyAppFont();he.echoTcl=s=>TT(`>>> ${s} -`,"tcl-cmd");he.runTclScript=(s,n)=>s?(n&&he.echoTcl(s),he.websocketManager.request({type:"tcl_eval",cmd:s}).then(r=>(r&&r.result&&TT(r.result+` -`,r.is_error?"tcl-error":""),r)).catch(r=>{TT(`Error: ${r} -`,"tcl-error")})):Promise.resolve();function q3t(s){s&&(he.customMenu=s.menu||[],he.customToolbar=s.toolbar||[],he.rebuildMenuBar&&he.rebuildMenuBar(),he.rebuildToolbar&&he.rebuildToolbar(),oDe())}he.customMenu=[];he.customToolbar=[];he.scheduleRedrawAllLayers=PO;he.showGlobalConnectDialog=()=>T3t(he);he.showInsertBufferDialog=s=>C3t(he,s);x3t(he);E3t(he);he.contextMenu=new pde(he);function Zpn(){let s=document.getElementById("debug-continue-btn");return s||(s=document.createElement("button"),s.id="debug-continue-btn",s.className="debug-continue-btn",s.textContent="Continue",s.title="Advance the debugger (gpl, cts, ...)",s.addEventListener("click",()=>{he.websocketManager.request({type:"debug_continue"}).catch(()=>{})}),(document.getElementById("menu-bar")||document.body).appendChild(s),s)}function X3t(s,n){let r=$5e(s,Ob(),n);return r?(he.currentBounds=s,he.designScale=r.scale,he.designOriginX=r.originX,he.designOriginY=r.originY,he.fitRect=r.fitRect,he.view.setLimits({minZoom:0,maxZoom:Nxt(r.scale)}),!0):!1}async function cDe(s,n,{reloadOnChange:r=!1}={}){if(la(he)||!he.view)return!1;let c=s,u=n;if(!c)try{let x=await he.websocketManager.request({type:"bounds"});c=x.bounds,u=x.fit_bounds}catch{return!1}if(!c||Bxt(he.currentBounds,c))return!1;if(r)return window.location.reload(),!0;let d=!!he.designScale,[b,w]=he.view.getCenter(),_=d?Pv(b,w,he.designScale,he.designOriginX,he.designOriginY):null;return X3t(c,u)?(_&&he.view.setView(Av(_.dbuX,_.dbuY,he.designScale,he.designOriginX,he.designOriginY),he.view.getZoom(),{animate:!1}),he.clearSelectionOutline&&he.clearSelectionOutline(),K1(),!0):!1}function Kpn(){let s=document.getElementById("loading-overlay");s.style.display="flex";let n=()=>{s.style.display!=="none"&&he.websocketManager.request({type:"bounds"}).then(r=>{r.shapes_ready&&(s.style.display="none")}).catch(()=>{}).finally(()=>{s.style.display!=="none"&&setTimeout(n,1e3)})};setTimeout(n,1e3)}function mde(){he.layerExtents&&he.layerExtents.refetch(s=>he.websocketManager.request(s))}function Jpn(s){document.getElementById("loading-overlay").style.display="none",mde(),cDe(s.bounds,s.fit_bounds).then(n=>{n||K1()}).catch(()=>K1()),he.refreshInspector&&he.refreshInspector()}function Qpn(){let s=document.getElementById("script-running-badge");return s||(s=document.createElement("span"),s.id="script-running-badge",s.className="script-running-badge",s.textContent="Script running",s.title="The view updates when the script pauses or finishes",(document.getElementById("menu-bar")||document.body).appendChild(s),s)}function egn(s){if(he.scriptRunning=s,Qpn().style.display=s?"block":"none",!s){if(!he.booted||!he.designScale){Rpn();return}he.refreshPending&&(he.refreshPending=!1,mde(),he.refreshInspector&&he.refreshInspector()),cDe().then(n=>{n||PO()}).catch(()=>PO())}}he.websocketManager.onPush=s=>{if(s.type==="refresh"){if(he.scriptRunning){he.refreshPending=!0;return}Jpn(s)}else if(s.type==="script_running")egn(!!s.running);else if(s.type==="renderer_controls_changed")he.refreshRendererControls&&he.refreshRendererControls(),PO();else if(s.type==="selection_invalidated")he.updateInspector&&he.updateInspector(null),he.stopSelectionAnimation&&he.stopSelectionAnimation(),he.clearSelectionOutline&&he.clearSelectionOutline(),mk();else if(s.type==="heatmaps_changed")he.websocketManager.request({type:"heatmaps"}).then(rDe).catch(n=>console.error("Heat map refresh failed",n));else if(s.type==="labels_changed")he.labelManager&&he.labelManager.applyRemoteLabels(s.labels);else if(s.type==="drcUpdated")he._drcUpdateTimeout&&clearTimeout(he._drcUpdateTimeout),he._drcUpdateTimeout=setTimeout(()=>{he.drcWidget&&he.drcWidget.refresh()},500);else if(s.type==="debug_paused")he.refreshRendererControls&&he.refreshRendererControls(),Zpn().style.display="block",PO(),he.chartsWidget&&he.websocketManager.request({type:"debug_charts"}).then(n=>he.chartsWidget.setDebugCharts(n.charts||[])).catch(()=>{});else if(s.type==="debug_resumed"){let n=document.getElementById("debug-continue-btn");n&&(n.style.display="none")}else if(s.type==="debug_refresh"){if(he.scriptRunning)return;he.clearSelectionOutline&&he.clearSelectionOutline(),PO()}else if(s.type==="log"){let n=s.text;n.endsWith(` -`)&&(n=n.slice(0,-1)),n&&TT(n+` -`,"")}else s.type==="restore_display_state"?Apn(s.state):s.type==="custom_ui"?q3t(s):s.type==="poly_decomp"?aDe(s.value):s.type==="shutdown"&&(he.websocketManager._shutdown=!0,MT.innerHTML='
Server stopped
',MT.style.display="block")};he.websocketManager.readyPromise.then(async()=>{try{let b=function(w,_={}){let{addToSelection:x=!1,focusInspector:T=!0,context:M=!1,showConnectivity:L=!1}=_;if(!he.designScale)return Promise.resolve(null);let{dbuX:I,dbuY:D}=Pv(w[0],w[1],he.designScale,he.designOriginX,he.designOriginY);if(he.labelManager&&he.labelManager.isActive())return he.labelManager.handleMapClick(I,D),Promise.resolve(null);let F=Ixt(gg,LO),O={type:"select",dbu_x:I,dbu_y:D,zoom:Math.round(he.view.getZoom()),visible_layers:[...he.visibleLayerNames],selectable_layers:[...he.selectableLayers],use_dbu:he.showDbu,...F};x&&(O.add_to_selection=!0),M&&(O.context=!0),L&&(O.show_connectivity=!0),he.visibleChiplets instanceof Set&&(O.visible_chiplets=[...he.visibleChiplets]);let z=Pm(he);return he.websocketManager.request(O).then(Z=>{if(Y1(he,z)){if(console.log("Select response:",Z,"at dbu",I,D),EO(he,Z),Z.selected&&Z.selected.length>0){let H=Z.selected[0];H.type==="Inst"&&(he.selectedInstanceName=H.name,he.schematicWidget&&he.schematicWidget.refresh()),lH(Z),T&&gde("Inspector"),Z.bbox&&(Npn(Z.bbox[0],Z.bbox[1],Z.bbox[2],Z.bbox[3],Z.type),Fpn(Z.bbox,Z.type),he.lastSelectionBounds=Z.bbox.slice(0,4)),O.show_connectivity&&Z.connected_added>0&&Nb(`Selected ${Z.connected_added} connected net`+(Z.connected_added>1?"s":""))}else!x&&!M&&(lH(null),he.clearSelectionOutline&&he.clearSelectionOutline(),he.lastSelectionBounds=null);return sDe(),Z}}).catch(Z=>(console.error("Select failed:",Z),null))},[s,n,r]=await Promise.all([he.websocketManager.request({type:"tech"}),he.websocketManager.request({type:"bounds"}),he.websocketManager.request({type:"heatmaps"})]);mde(),he.hasLiberty=s.has_liberty,he.techData=s,N3t(s.block_name),he.websocketManager.request({type:"custom_ui"}).then(q3t).catch(()=>{}),he.websocketManager.request({type:"poly_decomp"}).then(w=>aDe(w.value)).catch(()=>{});let c=n.bounds,u=n.fit_bounds;if(!m2){let w=he.view.getSize();hxt(Fxt({designBounds:c,fitRect:u,viewW:w.width,viewH:w.height}))}let d=X3t(c,u);if(d){if(he.labelManager&&he.labelManager.reload(),m2){let w=m2.zoom;he.view.setLimits({minZoom:w,maxZoom:w})}if(he.view.fitWorldRect(he.fitRect,{animate:!1}),m2){let w=X1(c[0][1],c[0][0],c[1][1],c[1][0],he.designScale,he.designOriginX,he.designOriginY);m2.setPathOverlay=_=>{he.view.setImageOverlay("timing-path",_?{image:_,rect:w}:null)}}try{let w=sessionStorage.getItem("or_restore_view");if(w){sessionStorage.removeItem("or_restore_view");let _=JSON.parse(w);_&&isFinite(_.dbuX)&&isFinite(_.dbuY)&&isFinite(_.zoom)&&he.view.setView(Av(_.dbuX,_.dbuY,he.designScale,he.designOriginX,he.designOriginY),_.zoom,{animate:!1})}}catch{}}m2&&(document.getElementById("loading-overlay").style.display="none"),he.selectAtWorld=b,m2||(he.onMapClick=(w,_)=>b(w,{addToSelection:!!_.shiftKey,showConnectivity:!!(_.ctrlKey||_.metaKey)}),he.onMapContextClick=(w,_)=>{b(w,{context:!0,focusInspector:!1}).then(()=>he.contextMenu.show(_))}),w3t(he,gg,LO,s,K1,Cpn),!he.overlayLayer&&!m2&&(he.overlayLayer=he.view.addTileSlot("overlay",{order:mp.overlay,source:G5e({wm:he.websocketManager,dpr:xO,tileSize:Ob,buildRequest:(w,_,x)=>Axt(w,_,x,gg,he)})})),rDe(r),d&&!n.shapes_ready&&Kpn(),Fb(),he.booted=!0}catch(s){he.scriptRunning||console.error("Failed to load initial data from server:",s)}});document.addEventListener("openroad-cone-sync",s=>{he.schematicWidget?.syncCone(s.detail||{})});document.addEventListener("keydown",s=>{let n=s.target.tagName;if(n==="INPUT"||n==="TEXTAREA"||s.target.isContentEditable)return;let r=s.key.toLowerCase();if(r==="escape"&&he.rulerManager&&he.rulerManager.isActive())he.rulerManager.cancelRulerBuild();else if(r==="escape"&&he.labelManager&&he.labelManager.isActive())he.labelManager.cancelLabelMode();else if(r==="k"&&!s.shiftKey&&!s.ctrlKey&&!s.metaKey)he.rulerManager&&he.rulerManager.toggleRulerMode();else if(r==="k"&&s.shiftKey&&!s.ctrlKey&&!s.metaKey)he.rulerManager&&he.rulerManager.clearAllRulers();else if(r==="l"&&!s.shiftKey&&!s.ctrlKey&&!s.metaKey)he.labelManager&&he.labelManager.toggleLabelMode();else if(r==="f"&&!s.ctrlKey&&!s.metaKey&&he.fitRect)he.view.fitWorldRect(he.fitRect);else if(r==="z"&&!s.ctrlKey&&he.view){let c=s.shiftKey?-1:1;he.view.zoomAround(he.lastMouseWorld?he.view.project(he.lastMouseWorld):null,c)}else r==="f"&&(s.ctrlKey||s.metaKey)?(s.preventDefault(),he.designScale&&ide(he)):r==="g"&&s.shiftKey&&!s.ctrlKey&&!s.metaKey?(s.preventDefault(),he.designScale&&rde(he)):r==="t"&&!s.shiftKey&&!s.ctrlKey&&!s.metaKey&&he.toggleTheme()},!0);})(); + `,document.body.appendChild(this._overlay),this._breadcrumb=this._overlay.querySelector(".fb-breadcrumb"),this._fileList=this._overlay.querySelector(".fb-file-list"),this._pathInput=this._overlay.querySelector(".fb-path-input"),this._errorDiv=this._overlay.querySelector(".modal-error"),this._okBtn=this._overlay.querySelector(".ok"),this._cancelBtn=this._overlay.querySelector(".cancel"),this._listen(this._pathInput,"input",()=>this._updateOkState()),this._listen(this._pathInput,"keydown",n=>{if(n.key==="Enter"){let r=this._pathInput.value.trim();r.endsWith("/")?this._navigate(r.replace(/\/+$/,"")||"/"):this._submit()}else n.key==="Escape"&&this.close()}),this._listen(this._okBtn,"click",()=>this._submit()),this._listen(this._cancelBtn,"click",()=>this.close()),this._listen(this._overlay,"click",n=>{n.target===this._overlay&&this.close()}),this._navigate("")}close(){if(!this._closed){this._closed=!0;for(let n of this._disposers)n();this._disposers.length=0,this._overlay&&(this._overlay.remove(),this._overlay=null)}}_listen(n,r,c){n.addEventListener(r,c),this._disposers.push(()=>n.removeEventListener(r,c))}_updateOkState(){this._okBtn.disabled=!this._pathInput.value.trim()}_renderBreadcrumb(n){this._breadcrumb.innerHTML="";let r=n.split("/").filter(Boolean),c=document.createElement("span");c.className="fb-crumb",c.textContent="/",this._listen(c,"click",()=>this._navigate("/")),this._breadcrumb.appendChild(c);let u="";for(let d of r){u+="/"+d;let b=document.createElement("span");b.className="fb-crumb-sep",b.textContent=" / ",this._breadcrumb.appendChild(b);let w=document.createElement("span");w.className="fb-crumb",w.textContent=d;let _=u;this._listen(w,"click",()=>this._navigate(_)),this._breadcrumb.appendChild(w)}}_renderEntries(n){if(this._fileList.innerHTML="",!n||n.length===0){let r=document.createElement("div");r.className="fb-empty",r.textContent="(empty directory)",this._fileList.appendChild(r);return}for(let r of n){let c=document.createElement("div");c.className="fb-entry",r.is_dir&&c.classList.add("fb-dir");let u=document.createElement("span");u.className="fb-icon",u.textContent=r.is_dir?"\u{1F4C1}":"\u{1F4C4}",c.appendChild(u);let d=document.createElement("span");d.className="fb-name",d.textContent=r.name,c.appendChild(d),r.is_dir?this._listen(c,"click",()=>this._navigate(this._currentPath+"/"+r.name)):(this._listen(c,"click",()=>{let b=this._fileList.querySelector(".fb-selected");b&&b.classList.remove("fb-selected"),c.classList.add("fb-selected"),this._pathInput.value=this._currentPath+"/"+r.name,this._updateOkState()}),this._listen(c,"dblclick",()=>{this._pathInput.value=this._currentPath+"/"+r.name,this._updateOkState(),this._submit()})),this._fileList.appendChild(c)}}async _navigate(n){this._errorDiv.style.display="none",this._fileList.innerHTML='
Loading...
';try{let r=await this._app.websocketManager.request({type:"list_dir",path:n||""});if(this._closed)return;this._currentPath=r.path,this._renderBreadcrumb(r.path),this._renderEntries(r.entries),this._pathInput.value="",this._updateOkState()}catch(r){if(this._closed)return;this._fileList.innerHTML="",this._errorDiv.textContent=r.message||String(r),this._errorDiv.style.display=""}}async _submit(){let n=this._pathInput.value.trim();if(n){this._okBtn.disabled=!0,this._okBtn.textContent="Loading...",this._errorDiv.style.display="none";try{let r=await this._app.websocketManager.request({type:"drc_load_report",path:n});if(this._closed)return;if(r.ok){let c=r.category;this.close(),this._onLoaded(c)}else this._errorDiv.textContent=r.error||"Failed to load report",this._errorDiv.style.display="",this._okBtn.disabled=!1,this._okBtn.textContent="Load"}catch(r){if(this._closed)return;this._errorDiv.textContent=r.message||"Request failed",this._errorDiv.style.display="",this._okBtn.disabled=!1,this._okBtn.textContent="Load"}}}};var spn=` +\r[]{}`;var fde=class{constructor(n,r){this._input=n,this._ws=r,this._popup=null,this._items=[],this._selectedIndex=-1,this._replaceStart=0,this._replaceEnd=0,this._debounceTimer=null,this._commandCache=null,this._history=[],this._historyIndex=-1,this._historyStash="",this._createPopup(),this._onInputBound=this._onInput.bind(this),this._onBlurBound=this._onBlur.bind(this),this._input.addEventListener("input",this._onInputBound),this._input.addEventListener("blur",this._onBlurBound)}_createPopup(){this._popup=document.createElement("div"),this._popup.className="tcl-complete-popup",this._popup.style.display="none",this._input.parentElement.appendChild(this._popup)}handleKeyDown(n){let r=this._popup.style.display!=="none";return n.key==="Tab"?(n.preventDefault(),r?this._tabAccept():this._tabComplete(this._input.value,this._input.selectionStart),!0):n.key==="Escape"?r?(this._hidePopup(),!0):!1:n.key==="ArrowDown"?r?(n.preventDefault(),this._selectItem(this._selectedIndex+1),!0):this._historyIndex>=0?(n.preventDefault(),this._historyIndex--,this._historyIndex<0?this._input.value=this._historyStash:this._input.value=this._history[this._historyIndex],!0):!1:n.key==="ArrowUp"?r?(n.preventDefault(),this._selectItem(this._selectedIndex-1),!0):this._historyIndex{let n=this._input.value,r=this._input.selectionStart,c=this._extractPrefix(n,r);c.length>=2||c.length>=1&&(c[0]==="$"||c[0]==="-")?this._requestCompletions(n,r):this._hidePopup()},100)}_onBlur(){setTimeout(()=>this._hidePopup(),150)}_extractPrefix(n,r){let c=r-1;for(;c>=0&&spn.indexOf(n[c])===-1;)c--;return n.substring(c+1,r)}_fetchCompletions(n,r,c){let u=this._extractPrefix(n,r),d=u.length>0&&u[0]==="$",b=u.length>0&&u[0]==="-",w=!d&&!b,_=r-u.length,x=n.substring(0,_),T=/^[\s\[]*$/.test(x);if(w&&T&&this._commandCache){let M=u.toLowerCase(),L=this._commandCache.filter(I=>I.toLowerCase().startsWith(M));c(L,_,r);return}this._ws.request({type:"tcl_complete",line:n,cursor_pos:r}).then(M=>{M.mode==="commands"&&!this._commandCache&&u===""&&(this._commandCache=M.completions),M.mode==="commands"&&!this._commandCache&&this._ws.request({type:"tcl_complete",line:"",cursor_pos:0}).then(L=>{L.mode==="commands"&&(this._commandCache=L.completions)}).catch(()=>{}),c(M.completions,M.replace_start,M.replace_end)}).catch(()=>c([],0,0))}_requestCompletions(n,r){this._fetchCompletions(n,r,(c,u,d)=>{this._showPopup(c,u,d)})}_tabAccept(){if(this._items.length===0){this._hidePopup();return}if(this._items.length===1){this._selectedIndex=0,this._acceptCompletion();return}this._advanceToCommonPrefix()}_tabComplete(n,r){this._fetchCompletions(n,r,(c,u,d)=>{if(!c||c.length===0){this._hidePopup();return}if(c.length===1){this._items=c,this._replaceStart=u,this._replaceEnd=d,this._selectedIndex=0,this._acceptCompletion();return}this._items=c,this._replaceStart=u,this._replaceEnd=d,this._advanceToCommonPrefix(),this._showPopup(c,this._replaceStart,this._replaceEnd)})}_advanceToCommonPrefix(){if(this._items.length<2)return!1;let n=this._items[0];for(let b=1;b0;b++){let w=this._items[b],_=0;for(;_{let _=document.createElement("div");_.className="tcl-complete-item",_.textContent=b,_.addEventListener("mousedown",x=>{x.preventDefault(),this._selectedIndex=w,this._acceptCompletion()}),this._popup.appendChild(_)}),n.length>15){let b=document.createElement("div");b.className="tcl-complete-more",b.textContent=`... ${n.length-15} more`,this._popup.appendChild(b)}this._selectedIndex=0,this._highlightSelected(),this._popup.style.display="block"}_hidePopup(){this._popup.style.display="none",this._items=[],this._selectedIndex=-1}_selectItem(n){if(this._items.length===0)return;let r=Math.min(this._items.length,15)-1;this._selectedIndex=Math.max(0,Math.min(n,r)),this._highlightSelected()}_highlightSelected(){let n=this._popup.querySelectorAll(".tcl-complete-item");n.forEach((r,c)=>{r.classList.toggle("selected",c===this._selectedIndex)}),n[this._selectedIndex]&&n[this._selectedIndex].scrollIntoView&&n[this._selectedIndex].scrollIntoView({block:"nearest"})}_acceptCompletion(){if(this._selectedIndex<0||this._selectedIndex>=this._items.length){this._hidePopup();return}let n=this._items[this._selectedIndex],r=this._input.value.substring(0,this._replaceStart),c=this._input.value.substring(this._replaceEnd),d=!n.endsWith("/")&&!n.endsWith("::")&&(c.length===0||c[0]!==" ")?" ":"";this._input.value=r+n+d+c;let b=this._replaceStart+n.length+d.length;this._input.setSelectionRange(b,b),this._input.focus(),this._hidePopup()}};var B3t=[{key:"or_visibility",store:"cookie"},{key:"or_selectability",store:"cookie"},{key:"or_hidden_layers",store:"session"},{key:"or_nonselectable_layers",store:"session"},{key:"or_layer_patterns",store:"session"},{key:"or_hidden_chiplets",store:"cookie"},{key:"or_bg_color",store:"cookie"},{key:"or_show_dbu",store:"cookie"},{key:"or_theme",store:"theme"},{key:"or_use_true_z",store:"cookie"},{key:"or_ruler_style",store:"cookie"},{key:"or_wheel_zoom",store:"cookie"},{key:"or_arrow_step",store:"cookie"},{key:"or_font_family",store:"cookie"},{key:"or_font_scale",store:"cookie"},{key:"or_control_smoothing",store:"cookie"},{key:"or_double_buffer",store:"cookie"},{key:"or_defer_tile_updates",store:"cookie"}];function O3t(s){return{controlSmoothing:s("or_control_smoothing")==="1",doubleBuffer:s("or_double_buffer")!=="0",deferTileUpdates:s("or_defer_tile_updates")==="1"}}function opn(s,n){try{return window[s].getItem(n)}catch{return null}}function apn(s,n,r){try{r===null?window[s].removeItem(n):window[s].setItem(n,r)}catch{}}function cpn({key:s,store:n}){return n==="session"?opn("sessionStorage",s):ph(s)}function lpn({key:s,store:n},r){n==="session"?apn("sessionStorage",s,r):n==="theme"?r===null?t3t():Whe(r):r===null?Vhe(s):Uf(s,r)}function N3t(){let s={};for(let n of B3t){let r=cpn(n);r&&(s[n.key]=r)}return{version:1,entries:s}}function upn(s){return typeof s=="string"&&s!==""&&!/[;\r\n]/.test(s)}function F3t(s){for(let n of B3t){let r=s[n.key];lpn(n,upn(r)?r:null)}}function U3t(s,n=typeof document<"u"?document:null){let r="OpenROAD",c=s?`${r} - ${s}`:r;return n&&(n.title=c),c}var $s=globalThis.THREE,z3t=2,fpn=.002,hpn=.9,dpn=1.1,ppn=.1,gpn=20,mpn=3,gk=2,G3t=2,bpn=10,wpn=1e4,vpn=.15,_pn=300,ypn=6,hde=Math.PI/180,j3t=[5025616,2201331,16750592,10233776,48340,16007990,2533018,7951688,15277667,4149685];function xpn(s){let n=new Array(s.length).fill(0),r=new Map;s.forEach((c,u)=>{let d=c.z;r.has(d)||r.set(d,[]),r.get(d).push({idx:u,chiplet:c})});for(let c of r.values()){if(c.length<=1)continue;let u=[];for(let{idx:d,chiplet:b}of c){let w=b.x,_=b.y,x=b.x+b.width,T=b.y+b.height,M=!1;for(let L=0;LwD.x1&&_D.y1)){u[L].push({x1:w,y1:_,x2:x,y2:T}),n[d]=L,M=!0;break}M||(u.push([{x1:w,y1:_,x2:x,y2:T}]),n[d]=u.length-1)}}return n}var dde=class{constructor(n,r){if(this._app=r,this._container=n,this._element=document.createElement("div"),this._element.className="three-d-viewer-widget",n.element.appendChild(this._element),!$s){ua(r)?this._showInfo("The 3D view is not available in saved reports."):this._showError("three.js is missing from the page."),this._destroyed=!0;return}this._canvasContainer=document.createElement("div"),this._canvasContainer.className="three-d-canvas-container",this._element.appendChild(this._canvasContainer),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._canvasContainer.appendChild(this._tooltip),this._optionsOverlay=this._createOptionsOverlay(),this._canvasContainer.appendChild(this._optionsOverlay),this._raycaster=new $s.Raycaster,this._scene=new $s.Scene,this._applyTheme(),this._themeObserver=new MutationObserver(()=>{this._applyTheme(),this.render()}),this._themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),this._camera=new $s.PerspectiveCamera(45,1,10,1e5),this._camera.position.set(0,0,1e3);try{this._renderer=new $s.WebGLRenderer({antialias:!0,preserveDrawingBuffer:!0})}catch(b){console.error("3D viewer: failed to create WebGL context:",b),this._showWebGLUnavailable(b),this._themeObserver&&(this._themeObserver.disconnect(),this._themeObserver=null),this._destroyed=!0;return}this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(n.width,n.height),this._canvasContainer.appendChild(this._renderer.domElement),this._rotation=new $s.Quaternion,this._distance=1e3,this._panX=0,this._panY=0,this._boundingRadius=1,this._sceneCenter=new $s.Vector3,this._mouseDown=!1,this._mouseButton=-1,this._lastMousePos={x:0,y:0},this._setupMouseHandlers();let c=new $s.AmbientLight(16777215,.5);this._scene.add(c);let u=new $s.DirectionalLight(16777215,.8);u.position.set(1,1,1).normalize(),this._scene.add(u);let d=new $s.DirectionalLight(16777215,.3);d.position.set(-1,-.5,.5).normalize(),this._scene.add(d),n.on("resize",this.onResize.bind(this)),n.on("open",this.onOpen.bind(this)),n.on("destroy",this.onDestroy.bind(this)),this._designGroup=new $s.Group,this._scene.add(this._designGroup),this._chipletMeshes=[],this._loading=!1,this._destroyed=!1,this._edgeMaterial=null}_setupMouseHandlers(){let n=this._renderer.domElement;n.addEventListener("mousedown",r=>{this._mouseDown=!0,this._mouseButton=r.button,this._lastMousePos.x=r.clientX,this._lastMousePos.y=r.clientY,n.focus(),r.preventDefault()}),n.addEventListener("contextmenu",r=>r.preventDefault()),this._onMouseMove=r=>{if(!this._mouseDown)return;let c=r.clientX-this._lastMousePos.x,u=r.clientY-this._lastMousePos.y;this._lastMousePos.x=r.clientX,this._lastMousePos.y=r.clientY,!(c===0&&u===0)&&(this._mouseButton===0?this._handleRotate(c,u):this._mouseButton===2&&this._handlePan(c,u),this._updateCamera())},this._onMouseUp=r=>{this._mouseDown&&r.button===this._mouseButton&&(this._mouseDown=!1,this._mouseButton=-1)},window.addEventListener("mousemove",this._onMouseMove),window.addEventListener("mouseup",this._onMouseUp),n.addEventListener("wheel",r=>{r.preventDefault(),r.deltaY<0?this._distance*=hpn:this._distance*=dpn;let c=Math.max(this._boundingRadius*ppn,1),u=Math.max(this._boundingRadius*gpn,c);this._distance=Math.max(c,Math.min(u,this._distance)),this._updateCamera()},{passive:!1}),n.tabIndex=0,n.style.outline="none",n.addEventListener("keydown",r=>{r.key.toLowerCase()==="f"&&this.resetCamera()}),n.addEventListener("dblclick",r=>{r.preventDefault();let c=this._pickDrcMarkerId(r);if(c!=null&&this._app.drcWidget){this._app.drcWidget.highlightMarkerById(c,!0);return}this.resetCamera()}),n.addEventListener("mousemove",r=>{if(this._mouseDown){this._hideTooltip();return}this._updateTooltip(r)}),n.addEventListener("mouseleave",()=>{this._hideTooltip()})}_createOptionsOverlay(){let n=document.createElement("div");n.className="three-d-options";let r=document.createElement("label");r.title="Render chiplets at their true Z (disable stacking offset for overlapping chiplets at same Z).";let c=document.createElement("input");c.type="checkbox",c.checked=!!this._app.useTrueZ,c.addEventListener("change",()=>{this._app.useTrueZ=c.checked,Uf("or_use_true_z",c.checked?"1":"0"),this._app.syncDisplayState(),this.refreshSceneForOptions()}),r.appendChild(c),r.appendChild(document.createTextNode("True Z (no stacking)")),n.appendChild(r);let u=document.createElement("div");u.style.cssText="margin-top:4px; display:flex; gap:4px;";let d=document.createElement("button");d.className="or-btn or-btn-sm",d.textContent="Save PNG",d.title="Save the 3D view as a PNG image (2x resolution)",d.addEventListener("click",()=>this._exportPng(2));let b=document.createElement("button");return b.className="or-btn or-btn-sm",b.textContent="Copy",b.title="Copy the 3D view image to the clipboard",b.addEventListener("click",()=>this._copyImage(2)),u.appendChild(d),u.appendChild(b),n.appendChild(u),n}_capturePng(n=2){if(!this._renderer)return null;let r=this._renderer,c=r.domElement.clientWidth||r.domElement.width,u=r.domElement.clientHeight||r.domElement.height,d=r.getPixelRatio();try{return r.setPixelRatio(d*n),r.setSize(c,u,!1),this.render(),r.domElement.toDataURL("image/png")}finally{r.setPixelRatio(d),r.setSize(c,u,!1),this.render()}}_exportPng(n=2){let r=this._capturePng(n);r&&hk(r,"3d-view.png")}async _copyImage(n=2){let r=this._capturePng(n);r&&await Hhe(r)}_setRaycasterFromEvent(n){let c=this._renderer.domElement.getBoundingClientRect(),u=new $s.Vector2((n.clientX-c.left)/c.width*2-1,-((n.clientY-c.top)/c.height*2-1));this._raycaster.setFromCamera(u,this._camera)}_updateTooltip(n){if(!this._chipletMeshes.length){this._hideTooltip();return}this._setRaycasterFromEvent(n);let r=this._chipletMeshes.map(w=>w.mesh),c=this._raycaster.intersectObjects(r,!1);if(c.length===0){this._hideTooltip();return}let u=c[0].object,d=this._chipletMeshes.find(w=>w.mesh===u);if(!d){this._hideTooltip();return}this._tooltip.textContent=d.data.name,this._tooltip.style.display="block";let b=this._canvasContainer.getBoundingClientRect();this._tooltip.style.left=n.clientX-b.left+12+"px",this._tooltip.style.top=n.clientY-b.top+12+"px"}_hideTooltip(){this._tooltip&&(this._tooltip.style.display="none")}_pickDrcMarkerId(n){if(!this._drcHitboxMesh||!this._drcHitboxMarkerIds)return null;this._setRaycasterFromEvent(n);let r=this._raycaster.intersectObject(this._drcHitboxMesh,!1);if(r.length===0)return null;let c=r[0].instanceId;return c==null?null:this._drcHitboxMarkerIds[c]??null}_handleRotate(n,r){let c=Math.sqrt(n*n+r*r);if(c<.001)return;let u=new $s.Vector3(r/c,n/c,0),d=c/z3t,w=new $s.Quaternion().setFromAxisAngle(u,d*hde).clone().multiply(this._rotation);if(new $s.Vector3(0,0,1).applyQuaternion(w).z>=0)this._rotation.copy(w);else{let x=new $s.Vector3(0,1,0),T=n/z3t*hde,L=new $s.Quaternion().setFromAxisAngle(x,T).clone().multiply(this._rotation);new $s.Vector3(0,0,1).applyQuaternion(L).z>=0&&this._rotation.copy(L)}}_handlePan(n,r){let c=this._distance*fpn;this._panX+=n*c,this._panY-=r*c}_updateCamera(){let n=Math.max(this._boundingRadius,1e3),r=Math.max(this._distance-n*G3t,bpn),c=this._distance+n*G3t;c0;){let n=this._designGroup.children[0];this._designGroup.remove(n),n.geometry&&n.geometry.dispose(),n.material&&!n.material._shared&&n.material.dispose()}this._edgeMaterial&&(this._edgeMaterial.dispose(),this._edgeMaterial=null),this._onMouseMove&&(window.removeEventListener("mousemove",this._onMouseMove),this._onMouseMove=null),this._onMouseUp&&(window.removeEventListener("mouseup",this._onMouseUp),this._onMouseUp=null),this._renderer&&(this._renderer.dispose(),this._renderer=null),this._app.threeDViewerWidget===this&&(this._app.threeDViewerWidget=null)}}_setInitialCameraState(){this._distance=this._boundingRadius*mpn;let n=new $s.Quaternion().setFromAxisAngle(new $s.Vector3(1,0,0),-45*hde),r=new $s.Quaternion().setFromAxisAngle(new $s.Vector3(0,0,1),45*hde);this._rotation=n.multiply(r),this._panX=0,this._panY=0}resetCamera(){this._sceneBounds&&(this._setInitialCameraState(),this._updateCamera())}onResize(){if(this._destroyed)return;let n=this._canvasContainer.getBoundingClientRect(),r=n.width,c=n.height;r===0||c===0||(this._camera.aspect=r/c,this._camera.updateProjectionMatrix(),this._renderer.setSize(r,c),this.render())}render(){this._destroyed||this._renderer&&this._scene&&this._camera&&this._renderer.render(this._scene,this._camera)}_applyTheme(){let r=fk().bgMap||"#000000";this._scene.background=new $s.Color(r)}async loadData(){if(!(this._loading||this._destroyed)){this._loading=!0;for(let n of[".three-d-error",".three-d-info"]){let r=this._element.querySelector(n);r&&r.remove()}try{await this._app.websocketManager.readyPromise;let n=await this._app.websocketManager.request({type:"get_3d_data"});if(this._destroyed)return;if(n&&n.error){this._showError(n.error);return}if(n&&n.info){this._showInfo(n.info);return}this.buildScene(n)}catch(n){if(this._destroyed)return;console.error("Failed to load 3D data:",n),this._showError(n.message||String(n))}finally{this._loading=!1}}}_showOverlay(n,r,c){let u=document.createElement("div");u.className=n,u.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-family:monospace;text-align:center;",u.style.color=c,u.textContent=r,this._element.appendChild(u)}_showError(n){this._showOverlay("three-d-error","Failed to load 3D data: "+n,"var(--error)")}_showInfo(n){this._showOverlay("three-d-info",n,"var(--fg-muted, #888)")}_showWebGLUnavailable(n){let r=document.createElement("div");r.className="three-d-error",r.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-family:monospace;text-align:center;max-width:80%;color:var(--error);";let c=n&&n.message?n.message:String(n||"");r.innerHTML='
3D viewer unavailable: WebGL context could not be created.
In Chrome, open chrome://flags/#ignore-gpu-blocklist and set Override software rendering list to Enabled, then relaunch the browser.
Otherwise enable hardware acceleration or try a different browser. See chrome://gpu for details.
'+(c?'
'+c+"
":""),this._element.appendChild(r)}buildScene(n){if(this._destroyed||(this._lastSceneData=n,this._clearScene(),!n||!n.chiplets||n.chiplets.length===0))return;let r=this._app.getDbuPerMicron(),c=this._buildChiplets(n.chiplets,r);c.minX!==1/0&&(this._buildGrid(c),this._setSceneBoundsAndCenter(c),this._setInitialCameraState(),this._updateCamera())}_clearScene(){for(this._chipletMeshes=[];this._designGroup.children.length>0;){let n=this._designGroup.children[0];this._designGroup.remove(n),n.geometry&&n.geometry.dispose(),n.material&&!n.material._shared&&n.material.dispose()}this._hideTooltip()}_buildChiplets(n,r){let c={minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0};this._edgeMaterial||(this._edgeMaterial=new $s.LineBasicMaterial({color:0,linewidth:1}),this._edgeMaterial._shared=!0);let u=this._app.useTrueZ?new Array(n.length).fill(0):xpn(n);return n.forEach((d,b)=>{let w=d.width/r,_=d.height/r,x=d.thickness/r*gk,T=j3t[b%j3t.length],M=new $s.MeshPhongMaterial({color:T,transparent:!1,opacity:1,side:$s.DoubleSide,shininess:40}),L=new $s.BoxGeometry(w,_,x),I=new $s.Mesh(L,M),D=d.x/r+w/2,F=d.y/r+_/2,O=x*vpn,z=d.z/r*gk+x/2+u[b]*(x+O);I.position.set(D,F,z),this._designGroup.add(I),this._chipletMeshes.push({mesh:I,data:d,color:T});let Z=new $s.EdgesGeometry(L),H=new $s.LineSegments(Z,this._edgeMaterial);H.position.set(D,F,z),this._designGroup.add(H),c.minX=Math.min(c.minX,d.x/r),c.minY=Math.min(c.minY,d.y/r),c.minZ=Math.min(c.minZ,z-x/2),c.maxX=Math.max(c.maxX,d.x/r+w),c.maxY=Math.max(c.maxY,d.y/r+_),c.maxZ=Math.max(c.maxZ,z+x/2)}),c}_buildGrid(n){let r=n.maxX-n.minX,c=n.maxY-n.minY,u=Math.max(r,c)*1.4,d=10,b=new $s.GridHelper(u,d,8947848,4473924);b.rotation.x=Math.PI/2,b.position.set((n.minX+n.maxX)/2,(n.minY+n.maxY)/2,n.minZ-1),this._designGroup.add(b)}_setSceneBoundsAndCenter(n){this._sceneBounds=n;let r=n.maxX-n.minX,c=n.maxY-n.minY,u=n.maxZ-n.minZ;this._boundingRadius=Math.sqrt(r*r+c*c+u*u)/2,this._sceneCenter.set((n.minX+n.maxX)/2,(n.minY+n.maxY)/2,(n.minZ+n.maxZ)/2)}_stackOffsetForPoint(n,r,c,u){for(let{mesh:d,data:b}of this._chipletMeshes){if(n!==b.z||rb.x+b.width||cb.y+b.height)continue;let w=b.thickness/u*gk,_=b.z/u*gk+w/2;return d.position.z-_}return 0}clearHighlightDRC(){this._drcBlinkInterval&&(clearInterval(this._drcBlinkInterval),this._drcBlinkInterval=null),this._drcMeshGroup&&(this._scene.remove(this._drcMeshGroup),this._drcMeshGroup.children.forEach(n=>{n.geometry&&n.geometry.dispose()}),this._drcMaterial&&(this._drcMaterial.dispose(),this._drcMaterial=null),this._drcHitboxMaterial&&(this._drcHitboxMaterial.dispose(),this._drcHitboxMaterial=null),this._drcHitboxMesh=null,this._drcHitboxMarkerIds=null,this._drcMeshGroup=null,this.render())}highlightDRC(n){if(this._destroyed||(this.clearHighlightDRC(),!n||n.length===0))return;let r=this._app.getDbuPerMicron(),c=0,u=1e4/r*gk;this._sceneBounds&&this._sceneBounds.minZ!==1/0&&(c=this._sceneBounds.minZ,u=this._sceneBounds.maxZ),c-=1,u+=1;let d=Math.max(u-c,1);this._drcMeshGroup=new $s.Group,this._drcMaterial=new $s.LineBasicMaterial({color:16776960,transparent:!0,opacity:1,depthTest:!1,depthWrite:!1}),this._drcHitboxMaterial=new $s.MeshBasicMaterial({transparent:!0,opacity:0,depthWrite:!1});let b=[];for(let x of n){let T=x.rects&&x.rects.length>0?x.rects:[x.bbox];for(let M of T){let[L,I,D,F,O,z]=M,Z=Math.max((D-L)/r,.001),H=Math.max((F-I)/r,.001),te=c,oe=d,ne=0;if(M.length>=6&&O!==void 0&&z!==void 0){te=O/r*gk;let ge=z/r*gk;oe=Math.max(ge-te,.001),ne=this._stackOffsetForPoint(O,(L+D)/2,(I+F)/2,r)}let ue=L/r+Z/2,Te=I/r+H/2,Q=te+oe/2+ne;b.push({cx:ue,cy:Te,cz:Q,width:Z,height:H,depth:oe,markerId:x.id})}}if(b.length>0){let x=new $s.BoxGeometry(1,1,1);this._drcHitboxMesh=new $s.InstancedMesh(x,this._drcHitboxMaterial,b.length),this._drcHitboxMarkerIds=new Array(b.length);let T=new $s.Matrix4,M=new $s.Vector3,L=new $s.Vector3,I=new $s.Quaternion;b.forEach((D,F)=>{L.set(D.cx,D.cy,D.cz),M.set(D.width,D.height,D.depth),T.compose(L,I,M),this._drcHitboxMesh.setMatrixAt(F,T),this._drcHitboxMarkerIds[F]=D.markerId;let O=new $s.BoxGeometry(D.width,D.height,D.depth),z=new $s.EdgesGeometry(O);O.dispose();let Z=new $s.LineSegments(z,this._drcMaterial);Z.position.set(D.cx,D.cy,D.cz),Z.renderOrder=999,this._drcMeshGroup.add(Z)}),this._drcHitboxMesh.instanceMatrix.needsUpdate=!0,this._drcMeshGroup.add(this._drcHitboxMesh)}this._drcMeshGroup.renderOrder=999,this._scene.add(this._drcMeshGroup),this.render();let w=!0,_=0;this._drcBlinkInterval=setInterval(()=>{if(!(!this._drcMeshGroup||!this._drcMaterial)){if(_+=1,_>=ypn){this._drcMaterial.opacity=1,this.render(),clearInterval(this._drcBlinkInterval),this._drcBlinkInterval=null;return}w=!w,this._drcMaterial.opacity=w?1:.2,this.render()}},_pn)}refreshSceneForOptions(){this._destroyed||this._lastSceneData&&(this.clearHighlightDRC(),this.buildScene(this._lastSceneData))}};var Epn=[{name:"green",hex:"#00ff00"},{name:"yellow",hex:"#ffff00"},{name:"cyan",hex:"#00ffff"},{name:"magenta",hex:"#ff00ff"},{name:"red",hex:"#ff0000"},{name:"dark_green",hex:"#008000"},{name:"dark_magenta",hex:"#800080"},{name:"blue",hex:"#0000ff"},{name:"orange",hex:"#ffa500"},{name:"purple",hex:"#800080"},{name:"lime",hex:"#bfff00"},{name:"teal",hex:"#008080"},{name:"pink",hex:"#ffc0cb"},{name:"brown",hex:"#8b4513"},{name:"indigo",hex:"#4b0082"},{name:"turquoise",hex:"#40e0d0"}],Spn=[{label:"Connected Insts",suffix:"connected_insts",needsNet:!0},{label:"Output Nets",suffix:"connected_nets",args:{output:!0,input:!1}},{label:"Input Nets",suffix:"connected_nets",args:{output:!1,input:!0}},{label:"All Nets",suffix:"connected_nets",args:{output:!0,input:!0}},{label:"All buffer trees",suffix:"connected_buffer_trees"},{label:"All buffer trees (incl. inverters)",suffix:"connected_buffer_trees",args:{include_inverters:!0}}],pde=class{constructor(n){this._app=n,this._el=document.createElement("div"),this._el.className="context-menu",this._el.style.display="none",this._el.style.zIndex="10000",document.body.appendChild(this._el),this._bindEvents()}_bindEvents(){document.addEventListener("mousedown",n=>{this._el.contains(n.target)||this.hide()}),this._app.view&&this._app.view.on("movestart",()=>this.hide())}show(n){this._el.innerHTML="";let r=!!this._app.selHasInst,c=!!this._app.selHasNet,u=!(r||c),d=I=>Spn.map(D=>({label:D.label,disabled:D.needsNet?!c:!r,...I(D.suffix,D.args||{})})),b=[{label:"Select",disabled:u,subMenu:d((I,D)=>({action:()=>this._sendContextAction("select_"+I,D)}))},{label:"Highlight",disabled:u,subMenu:d((I,D)=>({subMenu:this._buildColorSubmenu("highlight_"+I,D)}))},{label:"Save",subMenu:[{label:"Visible layout",action:()=>this._app.captureLayout?.({entire:!1})},{label:"Entire layout",action:()=>this._app.captureLayout?.({entire:!0})}]},{label:"Clear",subMenu:[{label:"Selections",action:()=>this._sendContextAction("clear_selections")},{label:"Highlights",action:()=>this._sendContextAction("clear_highlights")},{label:"Rulers",action:()=>{this._app.rulerManager?.clearAllRulers()}},{label:"Focus nets",action:()=>this._sendContextAction("clear_focus_nets")},{label:"Route Guides",action:()=>this._sendContextAction("clear_route_guides")},{label:"All",action:()=>{this._sendContextAction("clear_all"),this._app.rulerManager?.clearAllRulers()}}]}];this._buildMenu(b,this._el),this._el.style.display="block";let w=4,_=this._el.getBoundingClientRect(),x=window.innerWidth-_.width-w,T=window.innerHeight-_.height-w,M=Math.max(w,Math.min(n.clientX,x)),L=Math.max(w,Math.min(n.clientY,T));this._el.style.left=M+"px",this._el.style.top=L+"px"}hide(){this._el.style.display="none"}_buildColorSubmenu(n,r={}){return Epn.map(({name:c,hex:u},d)=>({label:c,swatch:u,action:()=>this._sendContextAction(n,{...r,group:d})}))}_buildMenu(n,r){n.forEach(c=>{let u=document.createElement("div");if(u.className="cm-item",c.swatch){let d=document.createElement("span");d.className="cm-swatch",d.style.background=c.swatch,u.appendChild(d)}if(u.appendChild(document.createTextNode(c.label)),c.disabled){u.classList.add("disabled"),c.subMenu&&u.classList.add("has-submenu"),r.appendChild(u);return}if(c.subMenu){u.classList.add("has-submenu");let d=document.createElement("div");d.className="cm-submenu",this._buildMenu(c.subMenu,d),u.appendChild(d),u.addEventListener("mouseenter",()=>{d.classList.remove("flip-left"),d.getBoundingClientRect().right>window.innerWidth&&d.classList.add("flip-left")})}else c.action&&u.addEventListener("click",d=>{d.stopPropagation(),this.hide();try{c.action()}catch(b){console.error("Context menu item action threw:",c.label,b)}});r.appendChild(u)})}_sendContextAction(n,r={}){this._app.websocketManager&&this._app.websocketManager.request({type:"context_action",action:n,...r}).then(c=>{EO(this._app,c),c&&c.connected_count===0&&Y1('Nothing connected \u2014 select an instance (or a net for "Connected Insts") first.'),this._syncAfterAction(n)}).catch(c=>{console.error("Context action failed:",n,c)})}_syncAfterAction(n){let r=this._app;(n==="clear_focus_nets"||n==="clear_route_guides"||n==="clear_all")&&typeof r.redrawAllLayers=="function"&&r.redrawAllLayers(),n==="clear_selections"||n==="clear_all"?(r.updateInspector?.(null),r.stopSelectionAnimation?.(),r.clearSelectionOutline?.(),r.lastSelectionBounds=null):r.refreshInspector?.(),r.refreshOverlay?.()}};function $3t(s,n){if(!s)return;let r=URL.createObjectURL(s),c=document.createElement("a");c.href=r,c.download=n,c.style.display="none",document.body.appendChild(c),c.click(),document.body.removeChild(c),setTimeout(()=>URL.revokeObjectURL(r),0)}function Mpn(s,n,r){s.view.getContainer().querySelectorAll(".or-view-markers .ruler-label").forEach(u=>{let d=u.getBoundingClientRect();if(d.width<=0||d.height<=0)return;let b=u.textContent;if(!b)return;let w=getComputedStyle(u),_=d.left-r.left,x=d.top-r.top;n.save(),n.fillStyle=w.backgroundColor||"rgba(0, 0, 0, 0.75)";let T=Math.min(parseFloat(w.borderTopLeftRadius)||0,d.height/2);T>0&&typeof n.roundRect=="function"?(n.beginPath(),n.roundRect(_,x,d.width,d.height,T),n.fill()):n.fillRect(_,x,d.width,d.height),n.fillStyle=w.color||"#eee",n.font=w.font||`${w.fontSize||"12px"} ${w.fontFamily||"monospace"}`,n.textAlign="left",n.textBaseline="middle",n.fillText(b,_+(parseFloat(w.paddingLeft)||0),x+d.height/2),n.restore()})}async function V3t(s){let n=s.view.getContainer(),r=n.getBoundingClientRect(),c=Math.max(1,Math.round(r.width)),u=Math.max(1,Math.round(r.height)),d=document.createElement("canvas");d.width=c,d.height=u;let b=d.getContext("2d"),w=getComputedStyle(n).backgroundColor;b.fillStyle=w&&w!=="transparent"&&w!=="rgba(0, 0, 0, 0)"?w:"#000",b.fillRect(0,0,c,u);let _=await s.view.captureCanvas();if(_){let x=_.rect;try{b.drawImage(_.image,x.left-r.left,x.top-r.top,x.width,x.height)}catch{}}return Mpn(s,b,r),new Promise(x=>d.toBlob(x,"image/png"))}async function W3t(s,{entire:n=!1}={}){if(!s.view)return;if(!n||!s.fitRect){$3t(await V3t(s),"layout_visible.png");return}let r=s.view.getCenter(),c=s.view.getZoom();try{s.view.fitWorldRect(s.fitRect,{animate:!1}),await s.view.whenTilesSettled(),$3t(await V3t(s),"layout_entire.png")}finally{s.view.setView(r,c,{animate:!1})}}var TT=document.getElementById("websocket-status"),cH=null,Tpn=2e3,Cpn=20;function q3t(){let s=he.websocketManager&&he.websocketManager.isConnected,n=he.websocketManager?he.websocketManager.pendingCount:0;if(s)if(cH&&(clearTimeout(cH),cH=null),n>Cpn){let r=`pending: ${n}`,c=TT.firstElementChild;(!c?.classList.contains("pending-indicator")||c.textContent!==r)&&(TT.innerHTML=`
${r}
`),TT.style.display="block"}else TT.style.display="none";else{if(he.websocketManager?._shutdown)return;cH||(cH=setTimeout(()=>{he.websocketManager?.isConnected||(TT.innerHTML='
\u26A0 OpenROAD disconnected \u2014 retrying\u2026
',TT.style.display="block")},Tpn))}Apn(n)}function Apn(s){let n=he.tileProgressEl;if(!n)return;n.classList.toggle("active",s>0);let r=s>0?`${s} tile requests pending`:"";n.title!==r&&(n.title=r)}var H3t=yT(q3t);function Ppn(s){if(!s)return"";try{return decodeURIComponent(s)}catch{return""}}var he={view:null,fitRect:null,lastSelectionBounds:null,selHasInst:!1,selHasNet:!1,displayControlsEl:null,allLayers:[],designScale:null,designOriginX:0,designOriginY:0,websocketManager:null,goldenLayout:null,hasLiberty:!1,techData:null,inspectorEl:null,tclOutputEl:null,modulesLayer:null,pinsLayer:null,overlayLayers:[],hierarchyBrowser:null,focusNets:new Set,routeGuideNets:new Set,visibleLayers:new Set,visibleLayerNames:new Set,visibleChiplets:null,layerPatterns:{},useTrueZ:ph("or_use_true_z")==="1",showDbu:ph("or_show_dbu")==="1",rulerStyle:ph("or_ruler_style")==="manhattan"?"manhattan":"euclidian",wheelZoom:ph("or_wheel_zoom")!=="0",arrowStep:tH(ph("or_arrow_step")),...O3t(ph),fontFamily:Ppn(ph("or_font_family")),fontScale:rH(ph("or_font_scale")),polyDecomp:!1,labelManager:null,selectableLayers:new Set,heatMapData:null,activeHeatMap:"",heatMapLayer:null,heatMapLegendEl:null,renderHeatMapControls:null,rulerManager:null,selectionToken:0,selectionResetters:[],getDbuPerMicron(){return this.techData?.dbu_per_micron||1e3},unitOpts(){return{showDbu:this.showDbu,dbuPerMicron:this.getDbuPerMicron()}},formatDbu(s,n=!1){return zxt(s,this.unitOpts(),n)},parseDbu(s){return Gxt(s,this.unitOpts())},formatDistance(s){return jxt(s,this.unitOpts())},unitLabel(){return $xt(this.unitOpts())}},mg={stdcells:!0,macros:!0,pad_input:!0,pad_output:!0,pad_inout:!0,pad_power:!0,pad_spacer:!0,pad_areaio:!0,pad_other:!0,phys_fill:!1,phys_endcap:!0,phys_welltap:!0,phys_tie:!0,phys_antenna:!0,phys_cover:!0,phys_bump:!0,phys_other:!0,std_bufinv:!0,std_bufinv_timing:!0,std_clock_bufinv:!0,std_clock_gate:!0,std_level_shift:!0,std_sequential:!0,std_combinational:!0,net_signal:!0,net_power:!0,net_ground:!0,net_clock:!0,net_reset:!0,net_tieoff:!0,net_scan:!0,net_analog:!0,inst_names:!0,inst_pins:!0,inst_pin_names:!1,routing:!0,routing_segments:!0,routing_vias:!0,special_nets:!0,srouting_segments:!0,srouting_vias:!0,pins:!0,pin_names:!0,access_points:!1,regions:!0,mfg_grid:!1,gcell_grid:!1,flywires_only:!1,blockages:!0,placement_blockages:!0,routing_obstructions:!0,fills:!1,rows:!1,tracks_pref:!1,tracks_non_pref:!1,module_view:!1,detailed:!1,rulers:!0,labels:!0,scale_bar:!0,focused_nets_guides:!1,highlight_selected:!0,debug:!1};try{let s=ph("or_visibility");if(s){let n=JSON.parse(decodeURIComponent(s));for(let[r,c]of Object.entries(n))mg[r]=!!c}}catch{}var LO={stdcells:!0,macros:!0,pad_input:!0,pad_output:!0,pad_inout:!0,pad_power:!0,pad_spacer:!0,pad_areaio:!0,pad_other:!0,phys_fill:!0,phys_endcap:!0,phys_welltap:!0,phys_tie:!0,phys_antenna:!0,phys_cover:!0,phys_bump:!0,phys_other:!0,std_bufinv:!0,std_bufinv_timing:!0,std_clock_bufinv:!0,std_clock_gate:!0,std_level_shift:!0,std_sequential:!0,std_combinational:!0,net_signal:!0,net_power:!0,net_ground:!0,net_clock:!0,net_reset:!0,net_tieoff:!0,net_scan:!0,net_analog:!0,pins:!0,inst_pins:!0,placement_blockages:!0,routing_obstructions:!0};he.visibility=mg;he.selectability=LO;try{let s=ph("or_selectability");if(s){let n=JSON.parse(decodeURIComponent(s));for(let[r,c]of Object.entries(n))LO[r]=!!c}}catch{}(function(){let n=null;try{n=new URLSearchParams(window.location.search)}catch{return}he.forceComposite=n.get("composite")==="1",he.preserveBuffer=n.get("preservebuffer")==="1";let r=Number(n.get("grouplayers"));Number.isFinite(r)&&r>0&&(he.groupLayers=Math.floor(r))})();he.tileCtx={visibility:mg,selectability:LO,visibleLayers:he.visibleLayerNames,selectableLayers:he.selectableLayers,app:he};function Lpn(){return he.view.addTileSlot("heatmap",{order:bp.heatmap,visible:!!he.activeHeatMap,source:G5e({wm:he.websocketManager,dpr:xO,tileSize:Fb,buildRequest:(s,n,r)=>Pxt(s,n,r,he)})})}function rDe(s){if(he.heatMapData=s,he.activeHeatMap=s.active||"",he.heatMapLayer){let n=he.heatMapLayer.isVisible();he.heatMapLayer.setVisible(!!he.activeHeatMap),n&&he.heatMapLayer.refresh()}he.renderHeatMapControls&&he.renderHeatMapControls(s)}he.updateHeatMaps=rDe;function sDe(){he.overlayLayer&&he.overlayLayer.refresh()}var mk=yT(()=>{sDe(),he.selectionBrowser&&he.selectionBrowser.scheduleRefresh()});he.refreshOverlay=mk;function J1(){Uf("or_visibility",encodeURIComponent(JSON.stringify(mg))),Uf("or_selectability",encodeURIComponent(JSON.stringify(LO))),Ub();let s=[[he.modulesLayer,mg.module_view],[he.pinsLayer,mg.pins],...he.overlayLayers.map(({def:n,layer:r})=>[r,nde(n.shown_by,mg)])];for(let[n,r]of s)n&&(n.visible=!!r);for(let n of he.allLayers)n.refresh();he.heatMapLayer&&he.heatMapLayer.refresh(),he.renderSelectionOutline&&he.renderSelectionOutline(),!mg.highlight_selected&&he.clearSelectionPulse&&he.clearSelectionPulse(),sDe(),he.rulerManager&&he.rulerManager.updateVisibility(),he.labelManager&&he.labelManager.updateVisibility(),he.updateScaleBar&&he.updateScaleBar()}var PO=yT(J1),Ub=yT(()=>{!he.websocketManager||ua(he)||he.websocketManager.request({type:"set_display_state",state:N3t()}).catch(()=>{})});he.syncDisplayState=Ub;function kpn(s){if(!s||typeof s!="object")return;let n=s.entries;if(!(!n||typeof n!="object")){F3t(n);try{if(he.view&&he.designScale&&typeof sessionStorage<"u"){let[r,c]=he.view.getCenter(),{dbuX:u,dbuY:d}=kv(r,c,he.designScale,he.designOriginX,he.designOriginY);sessionStorage.setItem("or_restore_view",JSON.stringify({dbuX:u,dbuY:d,zoom:he.view.getZoom()}))}}catch{}window.location.reload()}}he.redrawAllLayers=J1;he.captureLayout=(s={})=>W3t(he,s);function Rpn(s){let n=Dxt(s);if(n){try{if(sessionStorage.getItem("or_sw_render_warned"))return;sessionStorage.setItem("or_sw_render_warned","1")}catch{}Y1(n,15e3)}}function Ipn(s){let n=document.createElement("div");n.className="layout-viewer",n.style.width="100%",n.style.height="100%",n.style.backgroundColor="var(--bg-map)",s.element.appendChild(n);let r=document.createElement("div");r.className="or-hud or-hud-bottom-right heatmap-map-legend hidden",n.appendChild(r),he.heatMapLegendEl=r;let c=document.createElement("div");c.className="or-progress",n.appendChild(c),he.tileProgressEl=c,s.on("destroy",()=>{he.tileProgressEl=null,he.heatMapLegendEl=null}),he.view=Jxt(n,{preserveDrawingBuffer:he.preserveBuffer,prefs:{smooth:()=>he.controlSmoothing,doubleBuffer:()=>he.doubleBuffer,defer:()=>he.deferTileUpdates},tileSize:Fb,dpr:xO,isStatic:ua(he)}),he.view.on("contextlost",()=>{console.warn("Layout view: WebGL context lost; rebuilding the view.")}),he.view.on("contextfailed",()=>{Y1("The layout view lost its graphics context and could not get it back; reload the page.",15e3)}),he.view.on("renderer",Rpn),window.__orView=he.view,bxt(()=>{he.view.invalidateSize(),J1()});let u=document.createElement("div");u.className="or-zoom-control";let d=[];for(let[Z,H,te]of[["+","Zoom in",()=>he.view.zoomIn()],["\u2212","Zoom out",()=>he.view.zoomOut()],["\u2922","Fit",()=>{he.fitRect&&he.view.fitWorldRect(he.fitRect)}]]){let oe=document.createElement("button");oe.type="button",oe.title=H,oe.setAttribute("aria-label",H),oe.textContent=Z,oe.addEventListener("click",ne=>{ne.stopPropagation(),te()}),u.appendChild(oe),d.push(oe)}n.appendChild(u);let b=()=>{let{minZoom:Z,maxZoom:H}=he.view.getLimits(),te=he.view.getTargetZoom();d[0].disabled=te>=H,d[1].disabled=te<=Z};he.view.on("zoom zoomend limits",b),b();let w=document.createElement("div");w.className="or-hud or-hud-bottom-left hidden";let _=document.createElement("div");_.id="scale-bar";let x=document.createElement("span");x.className="or-hud-divider";let T=document.createElement("div");T.id="coord-bar",w.appendChild(_),w.appendChild(x),w.appendChild(T),n.appendChild(w);function M(){let Z=_.style.display!=="none"&&_.childElementCount>0,H=T.textContent!=="";x.style.display=Z&&H?"":"none",w.classList.toggle("hidden",!Z&&!H)}M(),e3t(he.view,{isStatic:()=>ua(he),wheelZoom:()=>he.wheelZoom,arrowStep:()=>he.arrowStep,contextEnabled:()=>!(he.rulerManager&&he.rulerManager.isActive()),onClick:(Z,H)=>{he.rulerManager&&he.rulerManager.isActive()?he.rulerManager.handleMapClick(Z,H):he.rulerManager?.handleRulerClick(Z)||he.onMapClick&&he.onMapClick(Z,H)},onContextClick:(Z,H)=>{he.onMapContextClick&&he.onMapContextClick(Z,H)},onMove:(Z,H)=>{if(he.lastMouseWorld=Z,he.rulerManager&&he.rulerManager.isActive()&&he.rulerManager.handleMouseMove(Z,H),!he.designScale)return;let{dbuX:te,dbuY:oe}=kv(Z[0],Z[1],he.designScale,he.designOriginX,he.designOriginY);T.textContent=`X: ${he.formatDbu(te)} Y: ${he.formatDbu(oe)}`,M()},onLeave:()=>{he.lastMouseWorld=null,T.textContent="",M()}});let L=22,I=8,D=22;function F(Z,H,te){let ne=2+I,ue=D,Te=D+Z,Q=L-2,ge=Z>=40,Qe=[];if(Qe.push(``),ge&&te>1)for(let st=1;st`)}ge&&Qe.push(`0`),Qe.push(`${H}`),_.innerHTML=`${Qe.join("")}`}function O(){if(!he.designScale||!mg.scale_bar){_.style.display="none",M();return}let Z=he.designScale*Math.pow(2,he.view.getZoom()),H=he.view.getSize().width||400,te=Wxt({targetPx:H*.15,pxPerDbu:Z,dbuPerMicron:he.techData?.dbu_per_micron,showDbu:he.showDbu});if(!te){_.style.display="none",M();return}_.style.display="",F(te.barPx,te.label,te.segments),M()}let z=yT(O);he.view.on("zoom zoomend resize",z),he.updateScaleBar=O,he.rulerManager=new ode(he,mg,lH,gde),he.labelManager=new cde(he,mg,lH,gde)}function Dpn(s){let n=document.createElement("div");n.className="display-controls",n.innerHTML='
Loading layers...
',s.element.appendChild(n),he.displayControlsEl=n}var iDe="or_restore_console",Bpn=1<<20;function Opn(){try{if(he.tclOutputEl){let s=[...he.tclOutputEl.children].map(u=>[u.textContent,u.className]),n=s.length,r=0;for(;n>0&&r+s[n-1][0].length<=Bpn;)r+=s[--n][0].length;let c=s.slice(n);n>0&&c.unshift([`[earlier output not kept across reload] +`,""]),sessionStorage.setItem(iDe,JSON.stringify(c))}}catch{}window.location.reload()}function Npn(){try{let s=sessionStorage.getItem(iDe);if(!s)return;sessionStorage.removeItem(iDe);for(let[n,r]of JSON.parse(s))CT(n,r)}catch{}}function CT(s,n){if(!he.tclOutputEl)return;let r=document.createElement("span");n&&(r.className=n),r.textContent=s,he.tclOutputEl.appendChild(r),he.tclOutputEl.scrollTop=he.tclOutputEl.scrollHeight}function Fpn(){if(he._shutdownHandled)return;he._shutdownHandled=!0,he.websocketManager&&(he.websocketManager._shutdown=!0,he.websocketManager.onPush=()=>{});let s=document.createElement("div");s.style.cssText="position:fixed;inset:0;z-index:99999;background:#1e1e1e;color:#ddd;display:flex;flex-direction:column;align-items:center;justify-content:center;font-family:system-ui,sans-serif;font-size:16px;padding:24px;text-align:center;",s.innerHTML='
OpenROAD exited
You can close this tab.
',document.body.appendChild(s),setTimeout(()=>{try{window.close()}catch{}},1500)}function Upn(s){let n=document.createElement("div");if(n.className="tcl-console",n.innerHTML='
%
',s.element.appendChild(n),he.tclOutputEl=n.querySelector(".tcl-output"),Npn(),ua(he)){n.querySelector(".tcl-input-row").style.display="none";let u=document.createElement("span");u.className="tcl-static-notice",u.setAttribute("role","status"),u.setAttribute("aria-live","polite"),u.textContent="Tcl console is not available in saved reports.",he.tclOutputEl.appendChild(u);return}let r=n.querySelector(".tcl-input"),c=new fde(r,he.websocketManager);r.addEventListener("keydown",u=>{if(!c.handleKeyDown(u)&&u.key==="Enter"){let d=r.value.trim();if(!d)return;CT(`>>> ${d} +`,"tcl-cmd"),c.addToHistory(d),r.value="",he.websocketManager.request({type:"tcl_eval",cmd:d}).then(b=>{b.result&&CT(b.result+` +`,b.is_error?"tcl-error":""),b.action==="shutdown"&&Fpn(),!b.is_error&&he.drcWidget&&he.drcWidget.refresh()}).catch(b=>CT(`Error: ${b} +`,"tcl-error"))}})}he.visibility=mg;var AT=h3t(he,J1,mk),zpn=AT.createInspector,lH=AT.updateInspector,Gpn=AT.highlightBBox,jpn=AT.pulseHighlight;he.updateInspector=lH;he.navigateInspector=AT.navigateInspector;he.refreshInspector=AT.refreshInspector;he.animateSelection=AT.animateSelection;he.stopSelectionAnimation=AT.stopSelectionAnimation;function $pn(s){new Khe(s,he,J1)}function Vpn(s){he.timingWidget=new uk(he,J1,mk),s.element.appendChild(he.timingWidget.element)}function Wpn(s){he.drcWidget=new ude(he,J1,mk),s.element.appendChild(he.drcWidget.element)}function Hpn(s){he.clockTreeWidget=new Yhe(s,he,J1,mk)}function qpn(s){he.chartsWidget=new Zhe(he,J1),s.element.appendChild(he.chartsWidget.element)}function Xpn(s){let n=document.createElement("div");n.className="help-panel",n.innerHTML="

Keyboard Shortcuts

fFit design to viewport
scrollZoom in/out
dragPan the view
right-dragRubber-band zoom
Shift+clickAdd object to selection
Ctrl/Cmd+clickSelect object and its connected nets
kToggle ruler mode
Shift+KClear all rulers
EscapeCancel ruler (when building)
",s.element.appendChild(n)}function Ypn(s){he.selectionBrowser=new Jhe(s,he,mk)}function Zpn(s){new lde(s,he)}function Kpn(s){he.threeDViewerWidget=new dde(s,he)}var Jpn=28,Qpn={dimensions:{headerHeight:Jpn},root:{type:"row",content:[{type:"component",componentType:"DisplayControls",title:"Display Controls",width:15},{type:"column",width:55,content:[{type:"stack",height:70,content:[{type:"component",componentType:"LayoutViewer",title:"Layout",isClosable:!1},{type:"component",componentType:"SchematicWidget",title:"Schematic"},{type:"component",componentType:"3DViewer",title:"3D Viewer"}]},{type:"component",componentType:"TclConsole",title:"Tcl Console",height:30}]},{type:"stack",width:30,content:[{type:"component",componentType:"Inspector",title:"Inspector"},{type:"component",componentType:"Browser",title:"Hierarchy"},{type:"component",componentType:"TimingWidget",title:"Timing"},{type:"component",componentType:"DRCWidget",title:"DRC"},{type:"component",componentType:"SelectHighlight",title:"Select Highlight"},{type:"component",componentType:"ClockWidget",title:"Clock Tree"},{type:"component",componentType:"ChartsWidget",title:"Charts"},{type:"component",componentType:"HelpWidget",title:"Help"}]}]}};he.goldenLayout=new Bhe(document.getElementById("gl-container"));he.goldenLayout.registerComponentFactoryFunction("LayoutViewer",Ipn);he.goldenLayout.registerComponentFactoryFunction("DisplayControls",Dpn);he.goldenLayout.registerComponentFactoryFunction("TclConsole",Upn);he.goldenLayout.registerComponentFactoryFunction("Inspector",zpn);he.goldenLayout.registerComponentFactoryFunction("Browser",$pn);he.goldenLayout.registerComponentFactoryFunction("TimingWidget",Vpn);he.goldenLayout.registerComponentFactoryFunction("DRCWidget",Wpn);he.goldenLayout.registerComponentFactoryFunction("ClockWidget",Hpn);he.goldenLayout.registerComponentFactoryFunction("ChartsWidget",qpn);he.goldenLayout.registerComponentFactoryFunction("SchematicWidget",Zpn);he.goldenLayout.registerComponentFactoryFunction("3DViewer",Kpn);he.goldenLayout.registerComponentFactoryFunction("HelpWidget",Xpn);he.goldenLayout.registerComponentFactoryFunction("SelectHighlight",Ypn);var m2=window.__STATIC_CACHE__||null;if(m2)fxt(),he.websocketManager=ZW.fromCache(m2,H3t);else{let s=`ws://${window.location.host||"localhost:8080"}/ws`;he.websocketManager=new ZW(s,H3t),he.layerExtents=new Ghe,he.websocketManager.onReconnected=()=>{mde(),cDe(null,null,{reloadOnChange:!0}).catch(()=>{})}}q3t();he.goldenLayout.loadLayout(Qpn);X3t();function X3t(){Hxt(document.getElementById("gl-container"))>0&&he.goldenLayout.updateSize()}he.goldenLayout.on("stateChanged",()=>{X3t()});function oDe(){he.goldenLayout.updateSize()}he.syncLayoutSize=oDe;window.addEventListener("resize",oDe);function gde(s){he.goldenLayout.focusComponent(s)}he.focusComponent=gde;he.resetLayout=function(){he.goldenLayout&&typeof he.goldenLayout.resetLayout=="function"&&he.goldenLayout.resetLayout()};he.toggleTheme=function(){let s=document.documentElement.dataset.theme==="dark"?"light":"dark";document.documentElement.dataset.theme=s,H5e(s),Whe(s),he.chartsWidget&&he.chartsWidget.render(),he.clockTreeWidget&&he.clockTreeWidget.render(),Ub()};he.toggleShowDbu=function(){he.showDbu=!he.showDbu,Uf("or_show_dbu",he.showDbu?"1":"0"),he.rulerManager&&he.rulerManager._renderAll(),he.hierarchyBrowser&&he.hierarchyBrowser._render(),he.updateScaleBar&&he.updateScaleBar(),he.refreshInspector&&he.refreshInspector(),Ub()};he.toggleRulerStyle=function(){he.rulerStyle=he.rulerStyle==="manhattan"?"euclidian":"manhattan",Uf("or_ruler_style",he.rulerStyle),Ub()};he.toggleWheelZoom=function(){he.wheelZoom=!he.wheelZoom,Uf("or_wheel_zoom",he.wheelZoom?"1":"0"),Ub()};he.toggleControlSmoothing=function(){he.controlSmoothing=!he.controlSmoothing,Uf("or_control_smoothing",he.controlSmoothing?"1":"0"),Ub()};he.toggleDoubleBuffer=function(){he.doubleBuffer=!he.doubleBuffer,Uf("or_double_buffer",he.doubleBuffer?"1":"0"),he.view?.applyPrefs(),Ub()};he.toggleDeferTileUpdates=function(){he.deferTileUpdates=!he.deferTileUpdates,Uf("or_defer_tile_updates",he.deferTileUpdates?"1":"0"),he.view?.applyPrefs(),Ub()};he.setArrowStep=function(s){he.arrowStep=tH(s),Uf("or_arrow_step",String(he.arrowStep)),Ub()};he.setAppFont=function({family:s,scale:n}){he.fontFamily=s??he.fontFamily,he.fontScale=rH(n??he.fontScale),Uf("or_font_family",encodeURIComponent(he.fontFamily)),Uf("or_font_scale",String(he.fontScale)),he.applyAppFont(),Ub()};he.applyAppFont=function(){let s=document.documentElement;he.fontFamily?s.style.setProperty("--or-font-family",he.fontFamily):s.style.removeProperty("--or-font-family"),s.style.setProperty("--or-font-scale",String(he.fontScale/100)),he.chartsWidget&&he.chartsWidget.render(),he.clockTreeWidget&&he.clockTreeWidget.render()};he.showArrowStepDialog=()=>g3t(he);he.showAppFontDialog=()=>m3t(he);he.togglePolyDecomp=function(){he.websocketManager&&he.websocketManager.request({type:"poly_decomp",value:!he.polyDecomp}).then(s=>aDe(s.value)).catch(()=>{})};function aDe(s){he.polyDecomp=!!s,he.rebuildMenuBar&&he.rebuildMenuBar(),he.refreshOverlay&&he.refreshOverlay()}he.applyAppFont();he.echoTcl=s=>CT(`>>> ${s} +`,"tcl-cmd");he.runTclScript=(s,n)=>s?(n&&he.echoTcl(s),he.websocketManager.request({type:"tcl_eval",cmd:s}).then(r=>(r&&r.result&&CT(r.result+` +`,r.is_error?"tcl-error":""),r)).catch(r=>{CT(`Error: ${r} +`,"tcl-error")})):Promise.resolve();function Y3t(s){s&&(he.customMenu=s.menu||[],he.customToolbar=s.toolbar||[],he.rebuildMenuBar&&he.rebuildMenuBar(),he.rebuildToolbar&&he.rebuildToolbar(),oDe())}he.customMenu=[];he.customToolbar=[];he.scheduleRedrawAllLayers=PO;he.showGlobalConnectDialog=()=>C3t(he);he.showInsertBufferDialog=s=>A3t(he,s);E3t(he);S3t(he);he.contextMenu=new pde(he);function egn(){let s=document.getElementById("debug-continue-btn");return s||(s=document.createElement("button"),s.id="debug-continue-btn",s.className="debug-continue-btn",s.textContent="Continue",s.title="Advance the debugger (gpl, cts, ...)",s.addEventListener("click",()=>{he.websocketManager.request({type:"debug_continue"}).catch(()=>{})}),(document.getElementById("menu-bar")||document.body).appendChild(s),s)}function Z3t(s,n){let r=$5e(s,Fb(),n);return r?(he.currentBounds=s,he.designScale=r.scale,he.designOriginX=r.originX,he.designOriginY=r.originY,he.fitRect=r.fitRect,he.view.setLimits({minZoom:0,maxZoom:Fxt(r.scale)}),!0):!1}async function cDe(s,n,{reloadOnChange:r=!1}={}){if(ua(he)||!he.view)return!1;let c=s,u=n;if(!c)try{let x=await he.websocketManager.request({type:"bounds"});c=x.bounds,u=x.fit_bounds}catch{return!1}if(!c||Oxt(he.currentBounds,c))return!1;if(r)return window.location.reload(),!0;let d=!!he.designScale,[b,w]=he.view.getCenter(),_=d?kv(b,w,he.designScale,he.designOriginX,he.designOriginY):null;return Z3t(c,u)?(_&&he.view.setView(Lv(_.dbuX,_.dbuY,he.designScale,he.designOriginX,he.designOriginY),he.view.getZoom(),{animate:!1}),he.clearSelectionOutline&&he.clearSelectionOutline(),J1(),!0):!1}function tgn(){let s=document.getElementById("loading-overlay");s.style.display="flex";let n=()=>{s.style.display!=="none"&&he.websocketManager.request({type:"bounds"}).then(r=>{r.shapes_ready&&(s.style.display="none")}).catch(()=>{}).finally(()=>{s.style.display!=="none"&&setTimeout(n,1e3)})};setTimeout(n,1e3)}function mde(){he.layerExtents&&he.layerExtents.refetch(s=>he.websocketManager.request(s))}function ngn(s){document.getElementById("loading-overlay").style.display="none",mde(),cDe(s.bounds,s.fit_bounds).then(n=>{n||J1()}).catch(()=>J1()),he.refreshInspector&&he.refreshInspector()}function ign(){let s=document.getElementById("script-running-badge");return s||(s=document.createElement("span"),s.id="script-running-badge",s.className="script-running-badge",s.textContent="Script running",s.title="The view updates when the script pauses or finishes",(document.getElementById("menu-bar")||document.body).appendChild(s),s)}function rgn(s){if(he.scriptRunning=s,ign().style.display=s?"block":"none",!s){if(!he.booted||!he.designScale){Opn();return}he.refreshPending&&(he.refreshPending=!1,mde(),he.refreshInspector&&he.refreshInspector()),cDe().then(n=>{n||PO()}).catch(()=>PO())}}he.websocketManager.onPush=s=>{if(s.type==="refresh"){if(he.scriptRunning){he.refreshPending=!0;return}ngn(s)}else if(s.type==="script_running")rgn(!!s.running);else if(s.type==="renderer_controls_changed")he.refreshRendererControls&&he.refreshRendererControls(),PO();else if(s.type==="selection_invalidated")he.updateInspector&&he.updateInspector(null),he.stopSelectionAnimation&&he.stopSelectionAnimation(),he.clearSelectionOutline&&he.clearSelectionOutline(),mk();else if(s.type==="heatmaps_changed")he.websocketManager.request({type:"heatmaps"}).then(rDe).catch(n=>console.error("Heat map refresh failed",n));else if(s.type==="labels_changed")he.labelManager&&he.labelManager.applyRemoteLabels(s.labels);else if(s.type==="drcUpdated")he._drcUpdateTimeout&&clearTimeout(he._drcUpdateTimeout),he._drcUpdateTimeout=setTimeout(()=>{he.drcWidget&&he.drcWidget.refresh()},500);else if(s.type==="debug_paused")he.refreshRendererControls&&he.refreshRendererControls(),egn().style.display="block",PO(),he.chartsWidget&&he.websocketManager.request({type:"debug_charts"}).then(n=>he.chartsWidget.setDebugCharts(n.charts||[])).catch(()=>{});else if(s.type==="debug_resumed"){let n=document.getElementById("debug-continue-btn");n&&(n.style.display="none")}else if(s.type==="debug_refresh"){if(he.scriptRunning)return;he.clearSelectionOutline&&he.clearSelectionOutline(),PO()}else if(s.type==="log"){let n=s.text;n.endsWith(` +`)&&(n=n.slice(0,-1)),n&&CT(n+` +`,"")}else s.type==="restore_display_state"?kpn(s.state):s.type==="custom_ui"?Y3t(s):s.type==="poly_decomp"?aDe(s.value):s.type==="shutdown"&&(he.websocketManager._shutdown=!0,TT.innerHTML='
Server stopped
',TT.style.display="block")};he.websocketManager.readyPromise.then(async()=>{try{let b=function(w,_={}){let{addToSelection:x=!1,focusInspector:T=!0,context:M=!1,showConnectivity:L=!1}=_;if(!he.designScale)return Promise.resolve(null);let{dbuX:I,dbuY:D}=kv(w[0],w[1],he.designScale,he.designOriginX,he.designOriginY);if(he.labelManager&&he.labelManager.isActive())return he.labelManager.handleMapClick(I,D),Promise.resolve(null);let F=Ixt(mg,LO),O={type:"select",dbu_x:I,dbu_y:D,zoom:Math.round(he.view.getZoom()),visible_layers:[...he.visibleLayerNames],selectable_layers:[...he.selectableLayers],use_dbu:he.showDbu,...F};x&&(O.add_to_selection=!0),M&&(O.context=!0),L&&(O.show_connectivity=!0),he.visibleChiplets instanceof Set&&(O.visible_chiplets=[...he.visibleChiplets]);let z=Pm(he);return he.websocketManager.request(O).then(Z=>{if(Z1(he,z)){if(console.log("Select response:",Z,"at dbu",I,D),EO(he,Z),Z.selected&&Z.selected.length>0){let H=Z.selected[0];H.type==="Inst"&&(he.selectedInstanceName=H.name,he.schematicWidget&&he.schematicWidget.refresh()),lH(Z),T&&gde("Inspector"),Z.bbox&&(Gpn(Z.bbox[0],Z.bbox[1],Z.bbox[2],Z.bbox[3],Z.type),jpn(Z.bbox,Z.type),he.lastSelectionBounds=Z.bbox.slice(0,4)),O.show_connectivity&&Z.connected_added>0&&Y1(`Selected ${Z.connected_added} connected net`+(Z.connected_added>1?"s":""))}else!x&&!M&&(lH(null),he.clearSelectionOutline&&he.clearSelectionOutline(),he.lastSelectionBounds=null);return sDe(),Z}}).catch(Z=>(console.error("Select failed:",Z),null))},[s,n,r]=await Promise.all([he.websocketManager.request({type:"tech"}),he.websocketManager.request({type:"bounds"}),he.websocketManager.request({type:"heatmaps"})]);mde(),he.hasLiberty=s.has_liberty,he.techData=s,U3t(s.block_name),he.websocketManager.request({type:"custom_ui"}).then(Y3t).catch(()=>{}),he.websocketManager.request({type:"poly_decomp"}).then(w=>aDe(w.value)).catch(()=>{});let c=n.bounds,u=n.fit_bounds;if(!m2){let w=he.view.getSize();hxt(Uxt({designBounds:c,fitRect:u,viewW:w.width,viewH:w.height}))}let d=Z3t(c,u);if(d){if(he.labelManager&&he.labelManager.reload(),m2){let w=m2.zoom;he.view.setLimits({minZoom:w,maxZoom:w})}if(he.view.fitWorldRect(he.fitRect,{animate:!1}),m2){let w=X1(c[0][1],c[0][0],c[1][1],c[1][0],he.designScale,he.designOriginX,he.designOriginY);m2.setPathOverlay=_=>{he.view.setImageOverlay("timing-path",_?{image:_,rect:w}:null)}}try{let w=sessionStorage.getItem("or_restore_view");if(w){sessionStorage.removeItem("or_restore_view");let _=JSON.parse(w);_&&isFinite(_.dbuX)&&isFinite(_.dbuY)&&isFinite(_.zoom)&&he.view.setView(Lv(_.dbuX,_.dbuY,he.designScale,he.designOriginX,he.designOriginY),_.zoom,{animate:!1})}}catch{}}m2&&(document.getElementById("loading-overlay").style.display="none"),he.selectAtWorld=b,m2||(he.onMapClick=(w,_)=>b(w,{addToSelection:!!_.shiftKey,showConnectivity:!!(_.ctrlKey||_.metaKey)}),he.onMapContextClick=(w,_)=>{b(w,{context:!0,focusInspector:!1}).then(()=>he.contextMenu.show(_))}),v3t(he,mg,LO,s,J1,Lpn),!he.overlayLayer&&!m2&&(he.overlayLayer=he.view.addTileSlot("overlay",{order:bp.overlay,source:G5e({wm:he.websocketManager,dpr:xO,tileSize:Fb,buildRequest:(w,_,x)=>Axt(w,_,x,mg,he)})})),rDe(r),d&&!n.shapes_ready&&tgn(),Ub(),he.booted=!0}catch(s){he.scriptRunning||console.error("Failed to load initial data from server:",s)}});document.addEventListener("openroad-cone-sync",s=>{he.schematicWidget?.syncCone(s.detail||{})});document.addEventListener("keydown",s=>{let n=s.target.tagName;if(n==="INPUT"||n==="TEXTAREA"||s.target.isContentEditable)return;let r=s.key.toLowerCase();if(r==="escape"&&he.rulerManager&&he.rulerManager.isActive())he.rulerManager.cancelRulerBuild();else if(r==="escape"&&he.labelManager&&he.labelManager.isActive())he.labelManager.cancelLabelMode();else if(r==="k"&&!s.shiftKey&&!s.ctrlKey&&!s.metaKey)he.rulerManager&&he.rulerManager.toggleRulerMode();else if(r==="k"&&s.shiftKey&&!s.ctrlKey&&!s.metaKey)he.rulerManager&&he.rulerManager.clearAllRulers();else if(r==="l"&&!s.shiftKey&&!s.ctrlKey&&!s.metaKey)he.labelManager&&he.labelManager.toggleLabelMode();else if(r==="f"&&!s.ctrlKey&&!s.metaKey&&he.fitRect)he.view.fitWorldRect(he.fitRect);else if(r==="z"&&!s.ctrlKey&&he.view){let c=s.shiftKey?-1:1;he.view.zoomAround(he.lastMouseWorld?he.view.project(he.lastMouseWorld):null,c)}else r==="f"&&(s.ctrlKey||s.metaKey)?(s.preventDefault(),he.designScale&&ide(he)):r==="g"&&s.shiftKey&&!s.ctrlKey&&!s.metaKey?(s.preventDefault(),he.designScale&&rde(he)):r==="t"&&!s.shiftKey&&!s.ctrlKey&&!s.metaKey&&he.toggleTheme()},!0);})(); /*! Bundled license information: sax/lib/sax.js: diff --git a/src/web/dist/report.min.js b/src/web/dist/report.min.js index f6343535b46..28f8c9d06a0 100644 --- a/src/web/dist/report.min.js +++ b/src/web/dist/report.min.js @@ -1,9 +1,9 @@ -(()=>{var HM=Object.create;var up=Object.defineProperty;var YM=Object.getOwnPropertyDescriptor;var qM=Object.getOwnPropertyNames;var ZM=Object.getPrototypeOf,XM=Object.prototype.hasOwnProperty;var C=(n,e)=>()=>(n&&(e=n(n=0)),e);var KM=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),ui=(n,e)=>{for(var t in e)up(n,t,{get:e[t],enumerable:!0})},QM=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of qM(e))!XM.call(n,r)&&r!==t&&up(n,r,{get:()=>e[r],enumerable:!(i=YM(e,r))||i.enumerable});return n};var JM=(n,e,t)=>(t=n!=null?HM(ZM(n)):{},QM(e||!n||!n.__esModule?up(t,"default",{value:n,enumerable:!0}):t,n));var ia,sA,Xl,oA,yv,fp=C(()=>{ia=globalThis,sA=globalThis.document||{},Xl=globalThis.process||{},oA=globalThis.console,yv=globalThis.navigator||{}});function Kl(n){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&process.versions?.electron)return!0;let e=typeof navigator<"u"&&navigator.userAgent,t=n||e;return!!(t&&t.indexOf("Electron")>=0)}var dp=C(()=>{});function Pt(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Kl()}var hp=C(()=>{dp()});function pp(n){return!n&&!Pt()?"Node":Kl(n)?"Electron":(n||yv.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var bv=C(()=>{hp();dp();fp()});var mp,vr=C(()=>{fp();hp();bv();mp="4.1.2"});function Is(n,e){if(!n)throw new Error(e||"Assertion failed")}var gp=C(()=>{});function _p(n){if(!n)return 0;let e;switch(typeof n){case"number":e=n;break;case"object":e=n.logLevel||n.priority||0;break;default:return 0}return Is(Number.isFinite(e)&&e>=0),e}function vv(n){let{logLevel:e,message:t}=n;n.logLevel=_p(e);let i=n.args?Array.from(n.args):[];for(;i.length&&i.shift()!==t;);switch(typeof e){case"string":case"function":t!==void 0&&i.unshift(t),n.message=e;break;case"object":Object.assign(n,e);break;default:}typeof n.message=="function"&&(n.message=n.message());let r=typeof n.message;return Is(r==="string"||r==="object"),Object.assign(n,{args:i},n.opts)}var xv=C(()=>{gp()});var xr,Ql,wv=C(()=>{xv();xr=()=>{},Ql=class{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...t){return this._log("warn",0,e,t,{once:!0})}error(e,...t){return this._log("error",0,e,t)}log(e,t,...i){return this._log("log",e,t,i)}info(e,t,...i){return this._log("info",e,t,i)}once(e,t,...i){return this._log("once",e,t,i,{once:!0})}_log(e,t,i,r,s={}){let o=vv({logLevel:t,message:i,args:this._buildArgs(t,i,r),opts:s});return this._createLogFunction(e,o,s)}_buildArgs(e,t,i){return[e,t,...i]}_createLogFunction(e,t,i){if(!this._shouldLog(t.logLevel))return xr;let r=this._getOnceTag(i.tag??t.tag??t.message);if((i.once||t.once)&&r!==void 0){if(this._onceCache.has(r))return xr;this._onceCache.add(r)}return this._emit(e,t)}_shouldLog(e){return this.getLevel()>=_p(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}}});function cA(n){try{let e=window[n],t="__storage_test__";return e.setItem(t,t),e.removeItem(t),e}catch{return null}}var Jl,Ev=C(()=>{Jl=class{constructor(e,t,i="sessionStorage"){this.storage=cA(i),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}}_loadConfiguration(){let e={};if(this.storage){let t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}});function Sv(n){let e;return n<10?e=`${n.toFixed(2)}ms`:n<100?e=`${n.toFixed(1)}ms`:n<1e3?e=`${n.toFixed(0)}ms`:e=`${(n/1e3).toFixed(2)}s`,e}function Pv(n,e=8){let t=Math.max(e-n.length,0);return`${" ".repeat(t)}${n}`}var Cv=C(()=>{});function Tv(n){return typeof n!="string"?n:(n=n.toUpperCase(),eu[n]||eu.WHITE)}function Lv(n,e,t){return!Pt&&typeof n=="string"&&(e&&(n=`\x1B[${Tv(e)}m${n}\x1B[39m`),t&&(n=`\x1B[${Tv(t)+lA}m${n}\x1B[49m`)),n}var eu,lA,Mv=C(()=>{vr();(function(n){n[n.BLACK=30]="BLACK",n[n.RED=31]="RED",n[n.GREEN=32]="GREEN",n[n.YELLOW=33]="YELLOW",n[n.BLUE=34]="BLUE",n[n.MAGENTA=35]="MAGENTA",n[n.CYAN=36]="CYAN",n[n.WHITE=37]="WHITE",n[n.BRIGHT_BLACK=90]="BRIGHT_BLACK",n[n.BRIGHT_RED=91]="BRIGHT_RED",n[n.BRIGHT_GREEN=92]="BRIGHT_GREEN",n[n.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",n[n.BRIGHT_BLUE=94]="BRIGHT_BLUE",n[n.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",n[n.BRIGHT_CYAN=96]="BRIGHT_CYAN",n[n.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(eu||(eu={}));lA=10});function Av(n,e=["constructor"]){let t=Object.getPrototypeOf(n),i=Object.getOwnPropertyNames(t),r=n;for(let s of i){let o=r[s];typeof o=="function"&&(e.find(a=>s===a)||(r[s]=o.bind(n)))}}var kv=C(()=>{});var tu,An,yp=C(()=>{vr();tu=class{getHighResolutionTimer(){let e;if(Pt()&&ia.performance)e=ia?.performance?.now?.();else if("hrtime"in Xl){let t=Xl?.hrtime?.();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}getMemoryUsageMB(){let t=ia?.performance?.memory?.usedJSHeapSize;return t==null?null:Math.trunc(t/1024/1024)}},An=new tu;globalThis.Probe=tu;globalThis.probe=An});function uA(n,e,t){if(typeof e=="string"){let i=t.time?Pv(Sv(t.total)):"";e=t.time?`${n}: ${i} ${e}`:`${n}: ${e}`,e=Lv(e,t.color,t.background)}return e}function fA(n){for(let e in n)for(let t in n[e])return t||"untitled";return"empty"}var Bs,bp,ct,vp=C(()=>{vr();wv();Ev();Cv();Mv();kv();gp();yp();Bs={debug:Pt()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},bp={enabled:!0,level:0},ct=class extends Ql{constructor({id:e}={id:""}){super({level:0}),this.VERSION=mp,this._startTs=An.getHighResolutionTimer(),this._deltaTs=An.getHighResolutionTimer(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Jl(`__probe-${this.id}__`,{[this.id]:bp}),this.timeStamp(`${this.id} started`),Av(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((An.getHighResolutionTimer()-this._startTs).toPrecision(10))}getDelta(){return Number((An.getHighResolutionTimer()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,t){this._updateConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw new Error(t||"Assertion failed")}warn(e,...t){return this._log("warn",0,e,t,{method:Bs.warn,once:!0})}error(e,...t){return this._log("error",0,e,t,{method:Bs.error})}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t,...i){let r=An.getMemoryUsageMB();if(r!==null){let s=`${r}MB `;typeof t=="function"?t=()=>`${s}${t()}`:typeof t=="string"&&(t=`${s}${t}`)}return this._log("log",e,t,i,{method:Bs.log,time:!0,once:!0})}log(e,t,...i){return this._log("log",e,t,i,{method:Bs.debug})}info(e,t,...i){return this._log("info",e,t,i,{method:console.info})}once(e,t,...i){return this._log("once",e,t,i,{method:Bs.debug||Bs.info,once:!0})}table(e,t,i){return t?this._log("table",e,t,i&&[i]||[],{method:console.table||xr,tag:fA(t)}):xr}time(e,t){return this._log("time",e,t,[],{method:console.time?console.time:console.info})}timeEnd(e,t){return this._log("time",e,t,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,t){return this._log("time",e,t,[],{method:console.timeStamp||xr})}group(e,t,i={collapsed:!1}){let r=(i.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,t,[],{method:r})}groupCollapsed(e,t,i={}){return this.group(e,t,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||xr})}withGroup(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,t){let i=t.method;Is(i),t.total=this.getTotal(),t.delta=this.getDelta(),this._deltaTs=An.getHighResolutionTimer();let r=uA(this.id,t.message,t);return i.bind(console,r,...t.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(bp),this._storage.config[this.id]}_updateConfiguration(e){let t=this._storage.config[this.id]||{...bp};this._storage.setConfiguration({[this.id]:{...t,...e}})}};ct.VERSION=mp});var Rv=C(()=>{yp();globalThis.probe||(globalThis.probe=An)});var Rj,ra=C(()=>{vp();vp();Rv();Rj=new ct({id:"@probe.gl/log"})});function ca(){let n;if(typeof window<"u"&&window.performance)n=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();n=e[0]*1e3+e[1]/1e6}else n=Date.now();return n}var Np=C(()=>{});var Er,Fp=C(()=>{Np();Er=class{constructor(e,t){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=ca(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(ca()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}});var Vt,jv=C(()=>{Fp();Vt=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let t of Object.values(this.stats))e(t)}getTable(){let e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(t=>this._getOrCreate(t))}_getOrCreate(e){let{name:t,type:i}=e,r=this.stats[t];return r||(e instanceof Er?r=e:r=new Er(t,i),this.stats[t]=r),r}}});var la=C(()=>{jv();Fp();Np()});function xx(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function wx(n){return Array.isArray(n)?n.length===0||typeof n[0]=="number":!1}function ga(n){return xx(n)||wx(n)}var Ex=C(()=>{});var Qp=C(()=>{Ex()});function $s(n){let e=n.split(""),t=0,i=0,r=!1,s=!1,o=!1;for(;t{var ZM=Object.create;var fp=Object.defineProperty;var XM=Object.getOwnPropertyDescriptor;var KM=Object.getOwnPropertyNames;var QM=Object.getPrototypeOf,JM=Object.prototype.hasOwnProperty;var C=(n,e)=>()=>(n&&(e=n(n=0)),e);var eA=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),mi=(n,e)=>{for(var t in e)fp(n,t,{get:e[t],enumerable:!0})},tA=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of KM(e))!JM.call(n,r)&&r!==t&&fp(n,r,{get:()=>e[r],enumerable:!(i=XM(e,r))||i.enumerable});return n};var nA=(n,e,t)=>(t=n!=null?ZM(QM(n)):{},tA(e||!n||!n.__esModule?fp(t,"default",{value:n,enumerable:!0}):t,n));var ra,cA,Kl,lA,bv,dp=C(()=>{ra=globalThis,cA=globalThis.document||{},Kl=globalThis.process||{},lA=globalThis.console,bv=globalThis.navigator||{}});function Ql(n){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&process.versions?.electron)return!0;let e=typeof navigator<"u"&&navigator.userAgent,t=n||e;return!!(t&&t.indexOf("Electron")>=0)}var hp=C(()=>{});function Tt(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Ql()}var pp=C(()=>{hp()});function mp(n){return!n&&!Tt()?"Node":Ql(n)?"Electron":(n||bv.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var vv=C(()=>{pp();hp();dp()});var gp,vr=C(()=>{dp();pp();vv();gp="4.1.2"});function Is(n,e){if(!n)throw new Error(e||"Assertion failed")}var _p=C(()=>{});function yp(n){if(!n)return 0;let e;switch(typeof n){case"number":e=n;break;case"object":e=n.logLevel||n.priority||0;break;default:return 0}return Is(Number.isFinite(e)&&e>=0),e}function xv(n){let{logLevel:e,message:t}=n;n.logLevel=yp(e);let i=n.args?Array.from(n.args):[];for(;i.length&&i.shift()!==t;);switch(typeof e){case"string":case"function":t!==void 0&&i.unshift(t),n.message=e;break;case"object":Object.assign(n,e);break;default:}typeof n.message=="function"&&(n.message=n.message());let r=typeof n.message;return Is(r==="string"||r==="object"),Object.assign(n,{args:i},n.opts)}var wv=C(()=>{_p()});var xr,Jl,Ev=C(()=>{wv();xr=()=>{},Jl=class{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...t){return this._log("warn",0,e,t,{once:!0})}error(e,...t){return this._log("error",0,e,t)}log(e,t,...i){return this._log("log",e,t,i)}info(e,t,...i){return this._log("info",e,t,i)}once(e,t,...i){return this._log("once",e,t,i,{once:!0})}_log(e,t,i,r,s={}){let o=xv({logLevel:t,message:i,args:this._buildArgs(t,i,r),opts:s});return this._createLogFunction(e,o,s)}_buildArgs(e,t,i){return[e,t,...i]}_createLogFunction(e,t,i){if(!this._shouldLog(t.logLevel))return xr;let r=this._getOnceTag(i.tag??t.tag??t.message);if((i.once||t.once)&&r!==void 0){if(this._onceCache.has(r))return xr;this._onceCache.add(r)}return this._emit(e,t)}_shouldLog(e){return this.getLevel()>=yp(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}}});function fA(n){try{let e=window[n],t="__storage_test__";return e.setItem(t,t),e.removeItem(t),e}catch{return null}}var eu,Sv=C(()=>{eu=class{constructor(e,t,i="sessionStorage"){this.storage=fA(i),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}}_loadConfiguration(){let e={};if(this.storage){let t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}});function Pv(n){let e;return n<10?e=`${n.toFixed(2)}ms`:n<100?e=`${n.toFixed(1)}ms`:n<1e3?e=`${n.toFixed(0)}ms`:e=`${(n/1e3).toFixed(2)}s`,e}function Cv(n,e=8){let t=Math.max(e-n.length,0);return`${" ".repeat(t)}${n}`}var Tv=C(()=>{});function Lv(n){return typeof n!="string"?n:(n=n.toUpperCase(),tu[n]||tu.WHITE)}function Mv(n,e,t){return!Tt&&typeof n=="string"&&(e&&(n=`\x1B[${Lv(e)}m${n}\x1B[39m`),t&&(n=`\x1B[${Lv(t)+dA}m${n}\x1B[49m`)),n}var tu,dA,Av=C(()=>{vr();(function(n){n[n.BLACK=30]="BLACK",n[n.RED=31]="RED",n[n.GREEN=32]="GREEN",n[n.YELLOW=33]="YELLOW",n[n.BLUE=34]="BLUE",n[n.MAGENTA=35]="MAGENTA",n[n.CYAN=36]="CYAN",n[n.WHITE=37]="WHITE",n[n.BRIGHT_BLACK=90]="BRIGHT_BLACK",n[n.BRIGHT_RED=91]="BRIGHT_RED",n[n.BRIGHT_GREEN=92]="BRIGHT_GREEN",n[n.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",n[n.BRIGHT_BLUE=94]="BRIGHT_BLUE",n[n.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",n[n.BRIGHT_CYAN=96]="BRIGHT_CYAN",n[n.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(tu||(tu={}));dA=10});function kv(n,e=["constructor"]){let t=Object.getPrototypeOf(n),i=Object.getOwnPropertyNames(t),r=n;for(let s of i){let o=r[s];typeof o=="function"&&(e.find(a=>s===a)||(r[s]=o.bind(n)))}}var Rv=C(()=>{});var nu,Bn,bp=C(()=>{vr();nu=class{getHighResolutionTimer(){let e;if(Tt()&&ra.performance)e=ra?.performance?.now?.();else if("hrtime"in Kl){let t=Kl?.hrtime?.();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}getMemoryUsageMB(){let t=ra?.performance?.memory?.usedJSHeapSize;return t==null?null:Math.trunc(t/1024/1024)}},Bn=new nu;globalThis.Probe=nu;globalThis.probe=Bn});function hA(n,e,t){if(typeof e=="string"){let i=t.time?Cv(Pv(t.total)):"";e=t.time?`${n}: ${i} ${e}`:`${n}: ${e}`,e=Mv(e,t.color,t.background)}return e}function pA(n){for(let e in n)for(let t in n[e])return t||"untitled";return"empty"}var Bs,vp,ct,xp=C(()=>{vr();Ev();Sv();Tv();Av();Rv();_p();bp();Bs={debug:Tt()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},vp={enabled:!0,level:0},ct=class extends Jl{constructor({id:e}={id:""}){super({level:0}),this.VERSION=gp,this._startTs=Bn.getHighResolutionTimer(),this._deltaTs=Bn.getHighResolutionTimer(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new eu(`__probe-${this.id}__`,{[this.id]:vp}),this.timeStamp(`${this.id} started`),kv(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((Bn.getHighResolutionTimer()-this._startTs).toPrecision(10))}getDelta(){return Number((Bn.getHighResolutionTimer()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,t){this._updateConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw new Error(t||"Assertion failed")}warn(e,...t){return this._log("warn",0,e,t,{method:Bs.warn,once:!0})}error(e,...t){return this._log("error",0,e,t,{method:Bs.error})}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t,...i){let r=Bn.getMemoryUsageMB();if(r!==null){let s=`${r}MB `;typeof t=="function"?t=()=>`${s}${t()}`:typeof t=="string"&&(t=`${s}${t}`)}return this._log("log",e,t,i,{method:Bs.log,time:!0,once:!0})}log(e,t,...i){return this._log("log",e,t,i,{method:Bs.debug})}info(e,t,...i){return this._log("info",e,t,i,{method:console.info})}once(e,t,...i){return this._log("once",e,t,i,{method:Bs.debug||Bs.info,once:!0})}table(e,t,i){return t?this._log("table",e,t,i&&[i]||[],{method:console.table||xr,tag:pA(t)}):xr}time(e,t){return this._log("time",e,t,[],{method:console.time?console.time:console.info})}timeEnd(e,t){return this._log("time",e,t,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,t){return this._log("time",e,t,[],{method:console.timeStamp||xr})}group(e,t,i={collapsed:!1}){let r=(i.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,t,[],{method:r})}groupCollapsed(e,t,i={}){return this.group(e,t,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||xr})}withGroup(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,t){let i=t.method;Is(i),t.total=this.getTotal(),t.delta=this.getDelta(),this._deltaTs=Bn.getHighResolutionTimer();let r=hA(this.id,t.message,t);return i.bind(console,r,...t.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(vp),this._storage.config[this.id]}_updateConfiguration(e){let t=this._storage.config[this.id]||{...vp};this._storage.setConfiguration({[this.id]:{...t,...e}})}};ct.VERSION=gp});var Iv=C(()=>{bp();globalThis.probe||(globalThis.probe=Bn)});var Nj,sa=C(()=>{xp();xp();Iv();Nj=new ct({id:"@probe.gl/log"})});function la(){let n;if(typeof window<"u"&&window.performance)n=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();n=e[0]*1e3+e[1]/1e6}else n=Date.now();return n}var Fp=C(()=>{});var Er,zp=C(()=>{Fp();Er=class{constructor(e,t){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=la(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(la()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}});var Yt,Hv=C(()=>{zp();Yt=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let t of Object.values(this.stats))e(t)}getTable(){let e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(t=>this._getOrCreate(t))}_getOrCreate(e){let{name:t,type:i}=e,r=this.stats[t];return r||(e instanceof Er?r=e:r=new Er(t,i),this.stats[t]=r),r}}});var ua=C(()=>{Hv();zp();Fp()});function wx(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Ex(n){return Array.isArray(n)?n.length===0||typeof n[0]=="number":!1}function _a(n){return wx(n)||Ex(n)}var Sx=C(()=>{});var Jp=C(()=>{Sx()});function $s(n){let e=n.split(""),t=0,i=0,r=!1,s=!1,o=!1;for(;t0){if(a==="/"&&c==="*"){e[t]=" ",e[t+1]=" ",i++,t+=2;continue}if(a==="*"&&c==="/"){e[t]=" ",e[t+1]=" ",i--,t+=2;continue}a!==` -`&&a!=="\r"&&(e[t]=" "),t++;continue}if(a==='"'){s=!0,t++;continue}if(a==="/"&&c==="/"){e[t]=" ",e[t+1]=" ",r=!0,t+=2;continue}if(a==="/"&&c==="*"){e[t]=" ",e[t+1]=" ",i=1,t+=2;continue}t++}return e.join("")}function Pr(n,e){let t=$s(n),i=[];for(let r of e){r.lastIndex=0;let s;for(s=r.exec(t);s;){let o=r===e[0],a=s.index,c=s[0].length;i.push({match:n.slice(a,a+c),index:a,length:c,bindingToken:s[o?1:2],groupToken:s[o?2:1],accessDeclaration:s[3]?.trim(),name:s[4]}),s=r.exec(t)}}return i.sort((r,s)=>r.index-s.index)}function sm(n,e,t){let i=Pr(n,e);if(!i.length)return n;let r="",s=0;for(let o of i)r+=n.slice(s,o.index),r+=t(o),s=o.index+o.length;return r+=n.slice(s),r}function om(n){return/@binding\(\s*auto\s*\)/.test($s(n))}function Fx(n,e){return Pr(n,e===Us||e===mu?Lk:e).find(i=>i.bindingToken==="auto")}var Lt,Wt,Us,mu,Nx,Lk,gu=C(()=>{Lt="(?:var<\\s*(uniform|storage(?:\\s*,\\s*[A-Za-z_][A-Za-z0-9_]*)?)\\s*>|var)\\s+([A-Za-z_][A-Za-z0-9_]*)",Wt="\\s*",Us=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${Wt}@group\\(\\s*(\\d+)\\s*\\)${Wt}${Lt}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${Wt}@binding\\(\\s*(auto|\\d+)\\s*\\)${Wt}${Lt}`,"g")],mu=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${Wt}@group\\(\\s*(\\d+)\\s*\\)${Wt}${Lt}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${Wt}@binding\\(\\s*(auto|\\d+)\\s*\\)${Wt}${Lt}`,"g")],Nx=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)${Wt}@group\\(\\s*(\\d+)\\s*\\)${Wt}${Lt}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${Wt}@binding\\(\\s*(\\d+)\\s*\\)${Wt}${Lt}`,"g")],Lk=[new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${Lt}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)\\s*${Lt}`,"g"),new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${Lt}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${Lt}`,"g")]});function yu(n,e={}){let t=zx(n),i=Mk(t);if(!i)return null;let r=Ak(t,i);if(!r)return null;let s=Rk(t,i,r);if(!s)return null;if(e.scanVertexAttributes===!1)return{attributes:[],bindings:s};let o=kk(t,i);if(!o)return null;let a=Nk(t,i,r,o,e.vertexEntryPoint);return a?{attributes:a,bindings:s}:null}function zx(n){let e=$s(n),t=/[A-Za-z_][A-Za-z0-9_]*|(?:0[xX][0-9A-Fa-f]+|\d+)|[@(){}<>\[\]:,;=]/g,i=[],r=t.exec(e);for(;r;)i.push({value:r[0],index:r.index}),r=t.exec(e);return i}function Mk(n){let e=[],t=0;for(let i of n){if(i.value==="}"&&t===0)return null;e.push(t),i.value==="{"?t++:i.value==="}"&&t--}return t===0?e:null}function Ak(n,e){let t=new Map;for(let i=0;i");if(y<0)return null;let b=bu(n.slice(f+1,y),",");if(!b)return null;d=b.map(_u),f=y+1}let h=n[f]?.value;if(!ba(h)||n[f+1]?.value!==":")return null;let p=Gx(n,e,f+2,";");if(p<0||p===f+2)return null;let m=lm(_u(n.slice(f+2,p)),t);if(!m)return null;let g=Ik({name:h,group:l,location:u,addressSpace:d,resourceType:m}),v=`${l}:${u}`;if(!g||r.has(v)||s.has(h))return null;i.push(g),r.add(v),s.add(h),o=p}return Dk(i),i.sort((o,a)=>o.group-a.group||o.location-a.location||o.name.localeCompare(a.name))}function Ik(n){let{name:e,group:t,location:i,addressSpace:r,resourceType:s}=n,o={name:e,group:t,location:i};if(r[0]==="uniform"&&r.length===1)return{...o,type:"uniform"};if(r[0]==="storage"&&r.length<=2){let a=r[1]||"read";return a==="read"?{...o,type:"read-only-storage"}:a==="read_write"?{...o,type:"storage"}:null}return r.length>0?null:s==="sampler"||s==="sampler_comparison"?{...o,type:"sampler",...s==="sampler_comparison"?{samplerType:"comparison"}:{}}:s==="texture_external"?{...o,type:"external-texture"}:Bk(o,s)||Ok(o,s)}function Bk(n,e){let t=/^texture_storage_(1d|2d|2d_array|3d)<([A-Za-z0-9_]+),(read|write|read_write)>$/.exec(e);if(!t)return null;let i={read:"read-only",write:"write-only",read_write:"read-write"}[t[3]];return{...n,type:"storage",format:t[2],access:i,viewDimension:cm(t[1])}}function Ok(n,e){let t=/^texture_(multisampled_)?(1d|2d|2d_array|cube|cube_array|3d)<(f32|i32|u32)>$/.exec(e);if(t){if(t[1]&&t[2]!=="2d")return null;let r={f32:"float",i32:"sint",u32:"uint"}[t[3]];return{...n,type:"texture",viewDimension:cm(t[2]),sampleType:r,multisampled:!!t[1]}}let i=/^texture_depth_(multisampled_)?(2d|2d_array|cube|cube_array)$/.exec(e);return!i||i[1]&&i[2]!=="2d"?null:{...n,type:"texture",viewDimension:cm(i[2]),sampleType:"depth",multisampled:!!i[1]}}function Dk(n){for(let e of n){if(e.type!=="sampler"||e.samplerType||!e.name.endsWith("Sampler"))continue;let t=e.name.slice(0,-7);n.find(r=>r.type==="texture"&&r.name===t&&r.group===e.group)?.sampleType==="depth"&&(e.samplerType="non-filtering")}}function Nk(n,e,t,i,r){let s=Fk(n,e);if(!s)return null;let o=s.filter(h=>h.vertex),a=r?o.find(h=>h.name===r):o.length===1?o[0]:void 0;if(!a)return o.length===0&&!r?[]:null;let c=bu(a.parameters,",");if(!c)return null;let l=[],u=new Set,f=new Set,d=new Set;for(let h of c)if(h.length>0&&!Ux({declaration:h,aliases:t,structures:i,attributes:l,attributeLocations:u,attributeNames:f,visitedStructures:d}))return null;return l.sort((h,p)=>h.location-p.location||h.name.localeCompare(p.name))}function Fk(n,e){let t=[],i=new Set;for(let r=0;r0&&!Ux({...n,declaration:m}))return!1;return a.delete(d),!0}function lm(n,e,t=new Set){let i=zx(n),r="";for(let s of i){let o=e.get(s.value);if(!o){r+=zk(s.value);continue}if(t.has(s.value))return null;let a=new Set(t);a.add(s.value);let c=lm(o,e,a);if(!c)return null;r+=c}return r}function zk(n){let e=/^(vec[234]|mat[234]x[234])([fiuh])$/.exec(n);if(!e)return n;let t={f:"f32",i:"i32",u:"u32",h:"f16"}[e[2]];return`${e[1]}<${t}>`}function Uk(n){return/^(?:i32|u32|f32|f16|vec[234]<(?:i32|u32|f32|f16)>)$/.test(n)?n:null}function am(n,e){let t;for(let i=0;it.value==="@"&&n[i+1]?.value===e)}function cm(n){return n.replace("_","-")}function um(n,e,t,i){let r=0;for(let s=e;s":"<","]":"[","}":"{"};for(let a=0;ar[l]===0)){t.push(n.slice(i,a)),i=a+1;continue}if(c in r)r[c]++;else if(c in o){let l=o[c];if(r[l]--,r[l]<0)return null}}return s.every(a=>r[a]===0)?(t.push(n.slice(i)),t):null}function $k(n,e){let t=bu(n,e);return t&&t.length===2?t[0].length:-1}function Gx(n,e,t,i){for(let r=t;r=0;i--)if(n[i].value===";"&&e[i]===0||n[i].value==="}"&&e[i]===1)return i+1;return 0}function Gk(n){for(let e=n.length-1;e>=0;e--)if(ba(n[e].value))return n[e].value;return null}function _u(n){return n.map(e=>e.value).join("")}function ba(n){return!!(n&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(n))}var fm=C(()=>{gu()});function hi(n,e){if(!n){let t=new Error(e||"shadertools: assertion failed.");throw Error.captureStackTrace?.(t,hi),t}}var vu=C(()=>{});function jx(n){let e={};for(let[t,i]of Object.entries(n))e[t]=Vk(i);return e}function Vk(n){let e=Wx(n);if(e!=="object")return{value:n,...dm[e],type:e};if(typeof n=="object")return n?n.type!==void 0?{...n,...dm[n.type],type:n.type}:n.value===void 0?{type:"object",value:n}:(e=Wx(n.value),{...n,...dm[e],type:e}):{type:"object",value:null};throw new Error("props")}function Wx(n){return Array.isArray(n)||ArrayBuffer.isView(n)?"array":typeof n}var dm,Hx=C(()=>{dm={number:{type:"number",validate(n,e){return Number.isFinite(n)&&typeof e=="object"&&(e.max===void 0||n<=e.max)&&(e.min===void 0||n>=e.min)}},array:{type:"array",validate(n,e){return Array.isArray(n)||ArrayBuffer.isView(n)}}}});var Yx,qx,Zx=C(()=>{Yx=`#ifdef MODULE_LOGDEPTH +`&&a!=="\r"&&(e[t]=" "),t++;continue}if(a==='"'){s=!0,t++;continue}if(a==="/"&&c==="/"){e[t]=" ",e[t+1]=" ",r=!0,t+=2;continue}if(a==="/"&&c==="*"){e[t]=" ",e[t+1]=" ",i=1,t+=2;continue}t++}return e.join("")}function Pr(n,e){let t=$s(n),i=[];for(let r of e){r.lastIndex=0;let s;for(s=r.exec(t);s;){let o=r===e[0],a=s.index,c=s[0].length;i.push({match:n.slice(a,a+c),index:a,length:c,bindingToken:s[o?1:2],groupToken:s[o?2:1],accessDeclaration:s[3]?.trim(),name:s[4]}),s=r.exec(t)}}return i.sort((r,s)=>r.index-s.index)}function om(n,e,t){let i=Pr(n,e);if(!i.length)return n;let r="",s=0;for(let o of i)r+=n.slice(s,o.index),r+=t(o),s=o.index+o.length;return r+=n.slice(s),r}function am(n){return/@binding\(\s*auto\s*\)/.test($s(n))}function zx(n,e){return Pr(n,e===Us||e===gu?kk:e).find(i=>i.bindingToken==="auto")}var At,qt,Us,gu,Fx,kk,_u=C(()=>{At="(?:var<\\s*(uniform|storage(?:\\s*,\\s*[A-Za-z_][A-Za-z0-9_]*)?)\\s*>|var)\\s+([A-Za-z_][A-Za-z0-9_]*)",qt="\\s*",Us=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${qt}@group\\(\\s*(\\d+)\\s*\\)${qt}${At}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${qt}@binding\\(\\s*(auto|\\d+)\\s*\\)${qt}${At}`,"g")],gu=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${qt}@group\\(\\s*(\\d+)\\s*\\)${qt}${At}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${qt}@binding\\(\\s*(auto|\\d+)\\s*\\)${qt}${At}`,"g")],Fx=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)${qt}@group\\(\\s*(\\d+)\\s*\\)${qt}${At}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${qt}@binding\\(\\s*(\\d+)\\s*\\)${qt}${At}`,"g")],kk=[new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${At}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)\\s*${At}`,"g"),new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${At}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${At}`,"g")]});function bu(n,e={}){let t=Ux(n),i=Rk(t);if(!i)return null;let r=Ik(t,i);if(!r)return null;let s=Ok(t,i,r);if(!s)return null;if(e.scanVertexAttributes===!1)return{attributes:[],bindings:s};let o=Bk(t,i);if(!o)return null;let a=Uk(t,i,r,o,e.vertexEntryPoint);return a?{attributes:a,bindings:s}:null}function Ux(n){let e=$s(n),t=/[A-Za-z_][A-Za-z0-9_]*|(?:0[xX][0-9A-Fa-f]+|\d+)|[@(){}<>\[\]:,;=]/g,i=[],r=t.exec(e);for(;r;)i.push({value:r[0],index:r.index}),r=t.exec(e);return i}function Rk(n){let e=[],t=0;for(let i of n){if(i.value==="}"&&t===0)return null;e.push(t),i.value==="{"?t++:i.value==="}"&&t--}return t===0?e:null}function Ik(n,e){let t=new Map;for(let i=0;i");if(y<0)return null;let b=vu(n.slice(f+1,y),",");if(!b)return null;d=b.map(yu),f=y+1}let h=n[f]?.value;if(!va(h)||n[f+1]?.value!==":")return null;let p=Vx(n,e,f+2,";");if(p<0||p===f+2)return null;let m=um(yu(n.slice(f+2,p)),t);if(!m)return null;let g=Dk({name:h,group:l,location:u,addressSpace:d,resourceType:m}),v=`${l}:${u}`;if(!g||r.has(v)||s.has(h))return null;i.push(g),r.add(v),s.add(h),o=p}return zk(i),i.sort((o,a)=>o.group-a.group||o.location-a.location||o.name.localeCompare(a.name))}function Dk(n){let{name:e,group:t,location:i,addressSpace:r,resourceType:s}=n,o={name:e,group:t,location:i};if(r[0]==="uniform"&&r.length===1)return{...o,type:"uniform"};if(r[0]==="storage"&&r.length<=2){let a=r[1]||"read";return a==="read"?{...o,type:"read-only-storage"}:a==="read_write"?{...o,type:"storage"}:null}return r.length>0?null:s==="sampler"||s==="sampler_comparison"?{...o,type:"sampler",...s==="sampler_comparison"?{samplerType:"comparison"}:{}}:s==="texture_external"?{...o,type:"external-texture"}:Nk(o,s)||Fk(o,s)}function Nk(n,e){let t=/^texture_storage_(1d|2d|2d_array|3d)<([A-Za-z0-9_]+),(read|write|read_write)>$/.exec(e);if(!t)return null;let i={read:"read-only",write:"write-only",read_write:"read-write"}[t[3]];return{...n,type:"storage",format:t[2],access:i,viewDimension:lm(t[1])}}function Fk(n,e){let t=/^texture_(multisampled_)?(1d|2d|2d_array|cube|cube_array|3d)<(f32|i32|u32)>$/.exec(e);if(t){if(t[1]&&t[2]!=="2d")return null;let r={f32:"float",i32:"sint",u32:"uint"}[t[3]];return{...n,type:"texture",viewDimension:lm(t[2]),sampleType:r,multisampled:!!t[1]}}let i=/^texture_depth_(multisampled_)?(2d|2d_array|cube|cube_array)$/.exec(e);return!i||i[1]&&i[2]!=="2d"?null:{...n,type:"texture",viewDimension:lm(i[2]),sampleType:"depth",multisampled:!!i[1]}}function zk(n){for(let e of n){if(e.type!=="sampler"||e.samplerType||!e.name.endsWith("Sampler"))continue;let t=e.name.slice(0,-7);n.find(r=>r.type==="texture"&&r.name===t&&r.group===e.group)?.sampleType==="depth"&&(e.samplerType="non-filtering")}}function Uk(n,e,t,i,r){let s=$k(n,e);if(!s)return null;let o=s.filter(h=>h.vertex),a=r?o.find(h=>h.name===r):o.length===1?o[0]:void 0;if(!a)return o.length===0&&!r?[]:null;let c=vu(a.parameters,",");if(!c)return null;let l=[],u=new Set,f=new Set,d=new Set;for(let h of c)if(h.length>0&&!$x({declaration:h,aliases:t,structures:i,attributes:l,attributeLocations:u,attributeNames:f,visitedStructures:d}))return null;return l.sort((h,p)=>h.location-p.location||h.name.localeCompare(p.name))}function $k(n,e){let t=[],i=new Set;for(let r=0;r0&&!$x({...n,declaration:m}))return!1;return a.delete(d),!0}function um(n,e,t=new Set){let i=Ux(n),r="";for(let s of i){let o=e.get(s.value);if(!o){r+=Gk(s.value);continue}if(t.has(s.value))return null;let a=new Set(t);a.add(s.value);let c=um(o,e,a);if(!c)return null;r+=c}return r}function Gk(n){let e=/^(vec[234]|mat[234]x[234])([fiuh])$/.exec(n);if(!e)return n;let t={f:"f32",i:"i32",u:"u32",h:"f16"}[e[2]];return`${e[1]}<${t}>`}function Vk(n){return/^(?:i32|u32|f32|f16|vec[234]<(?:i32|u32|f32|f16)>)$/.test(n)?n:null}function cm(n,e){let t;for(let i=0;it.value==="@"&&n[i+1]?.value===e)}function lm(n){return n.replace("_","-")}function fm(n,e,t,i){let r=0;for(let s=e;s":"<","]":"[","}":"{"};for(let a=0;ar[l]===0)){t.push(n.slice(i,a)),i=a+1;continue}if(c in r)r[c]++;else if(c in o){let l=o[c];if(r[l]--,r[l]<0)return null}}return s.every(a=>r[a]===0)?(t.push(n.slice(i)),t):null}function Wk(n,e){let t=vu(n,e);return t&&t.length===2?t[0].length:-1}function Vx(n,e,t,i){for(let r=t;r=0;i--)if(n[i].value===";"&&e[i]===0||n[i].value==="}"&&e[i]===1)return i+1;return 0}function jk(n){for(let e=n.length-1;e>=0;e--)if(va(n[e].value))return n[e].value;return null}function yu(n){return n.map(e=>e.value).join("")}function va(n){return!!(n&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(n))}var dm=C(()=>{_u()});function yi(n,e){if(!n){let t=new Error(e||"shadertools: assertion failed.");throw Error.captureStackTrace?.(t,yi),t}}var xu=C(()=>{});function Hx(n){let e={};for(let[t,i]of Object.entries(n))e[t]=Hk(i);return e}function Hk(n){let e=jx(n);if(e!=="object")return{value:n,...hm[e],type:e};if(typeof n=="object")return n?n.type!==void 0?{...n,...hm[n.type],type:n.type}:n.value===void 0?{type:"object",value:n}:(e=jx(n.value),{...n,...hm[e],type:e}):{type:"object",value:null};throw new Error("props")}function jx(n){return Array.isArray(n)||ArrayBuffer.isView(n)?"array":typeof n}var hm,Yx=C(()=>{hm={number:{type:"number",validate(n,e){return Number.isFinite(n)&&typeof e=="object"&&(e.max===void 0||n<=e.max)&&(e.min===void 0||n>=e.min)}},array:{type:"array",validate(n,e){return Array.isArray(n)||ArrayBuffer.isView(n)}}}});var qx,Zx,Xx=C(()=>{qx=`#ifdef MODULE_LOGDEPTH logdepth_adjustPosition(gl_Position); #endif -`,qx=`#ifdef MODULE_MATERIAL +`,Zx=`#ifdef MODULE_MATERIAL fragColor = material_filterColor(fragColor); #endif @@ -23,22 +23,22 @@ #ifdef MODULE_LOGDEPTH logdepth_setFragDepth(); #endif -`});function Qx(n){let e={vertex:{},fragment:{}};for(let t in n){let i=n[t],r=jk(t);typeof i=="string"&&(i={order:0,injection:i}),e[r][t]=i}return e}function jk(n){let e=n.slice(0,2);switch(e){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(e)}}function xa(n,e,t,i=!1,r="glsl",s={}){let o=e==="vertex";for(let a in t){let c=t[a];c.sort((u,f)=>u.order-f.order),hm.length=c.length;for(let u=0,f=c.length;uu.order-f.order),pm.length=c.length;for(let u=0,f=c.length;uu+l));break;case"vs:#main-end":(r==="wgsl"||o)&&(n=r==="wgsl"?xu(n,"vertex",l,"end",s.vertex):n.replace(Kx,u=>l+u));break;case"fs:#decl":(r==="wgsl"||!o)&&(n=n.replace(va,l));break;case"fs:#main-start":(r==="wgsl"||!o)&&(n=r==="wgsl"?xu(n,"fragment",l,"start",s.fragment):n.replace(Xx,u=>u+l));break;case"fs:#main-end":(r==="wgsl"||!o)&&(n=r==="wgsl"?xu(n,"fragment",l,"end",s.fragment):n.replace(Kx,u=>l+u));break;default:n=n.replace(a,u=>u+l)}}return n=n.replace(va,""),i&&(n=n.replace(/\}\s*$/,a=>a+Wk[e])),n}function xu(n,e,t,i,r){let s=Hk(n,e,r);if(!s)return n;if(i==="start"){let o=s.openBraceIndex+1;return`${n.slice(0,o)} -${t}${n.slice(o)}`}return`${n.slice(0,s.closeBraceIndex)}${t}${n.slice(s.closeBraceIndex)}`}function Hk(n,e,t){let i=e==="vertex"?"@vertex":"@fragment",r=n.indexOf(i);if(r<0)return null;let s=t?n.search(new RegExp(`\\bfn\\s+${Yk(t)}\\s*\\(`)):n.indexOf("fn",r);if(s<0)return null;let o=n.indexOf("{",s);if(o<0)return null;let a=0;for(let c=o;c{Zx();Wk={vertex:Yx,fragment:qx},Xx=/void\s+main\s*\([^)]*\)\s*\{\n?/,Kx=/}\n?[^{}]*$/,hm=[],va="__LUMA_INJECT_DECLARATIONS__"});function Gs(n){n.map(e=>qk(e))}function qk(n){if(n.instance)return;Gs(n.dependencies||[]);let{propTypes:e={},deprecations:t=[],inject:i={}}=n,r={normalizedInjections:Qx(i),parsedDeprecations:Zk(t)};e&&(r.propValidators=jx(e)),n.instance=r;let s={};e&&(s=Object.entries(e).reduce((o,[a,c])=>{let l=c?.value;return l&&(o[a]=l),o},{})),n.defaultUniforms={...n.defaultUniforms,...s}}function mm(n,e,t){n.deprecations?.forEach(i=>{i.regex?.test(e)&&(i.deprecated?t.deprecated(i.old,i.new)():t.removed(i.old,i.new)())})}function Zk(n){return n.forEach(e=>{switch(e.type){case"function":e.regex=new RegExp(`\\b${e.old}\\(`);break;default:e.regex=new RegExp(`${e.type} ${e.old};`)}}),n}var wu=C(()=>{Hx();pm()});function Cr(n){Gs(n);let e={},t={};Jx({modules:n,level:0,moduleMap:e,moduleDepth:t});let i=Object.keys(t).sort((r,s)=>t[s]-t[r]).map(r=>e[r]);return Gs(i),i}function Jx(n){let{modules:e,level:t,moduleMap:i,moduleDepth:r}=n;if(t>=5)throw new Error("Possible loop in shader dependency graph");for(let s of e)i[s.name]=s,(r[s.name]===void 0||r[s.name]{wu()});var z,ut=C(()=>{ra();z=new ct({id:"luma.gl"})});function Xk(n,e){return n!=null?!!n:e!==void 0?e!=="production":!1}function Kk(){return Xk(z.get("debug"),Qk())}function Qk(){let n=globalThis.process;if(n?.env)return n.env.NODE_ENV}var Eu,_m=C(()=>{ut();Eu={id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,featureLevel:void 0,optionalFeatures:[],xrCompatible:!1,createCanvasContext:void 0,webgl:{},onError:(n,e)=>{},onResize:(n,e)=>{let[t,i]=n.getDevicePixelSize();z.log(1,`${n} resized => ${t}x${i}px`)()},onPositionChange:(n,e)=>{let[t,i]=n.getPosition();z.log(1,`${n} repositioned => ${t},${i}`)()},onVisibilityChange:n=>z.log(1,`${n} Visibility changed ${n.isVisible}`)(),onDevicePixelRatioChange:(n,e)=>z.log(1,`${n} DPR changed ${e.oldRatio} => ${n.devicePixelRatio}`)(),debug:Kk(),debugGPUTime:!1,debugShaders:z.get("debug-shaders")||void 0,debugFramebuffers:!!z.get("debug-framebuffers"),debugFactories:!!z.get("debug-factories"),debugWebGL:!!z.get("debug-webgl"),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0}});function tR(n,e){let t=n.stats,i=!1;for(let c of e)t[c]||(n.get(c),i=!0);let r=Object.keys(t).length,s=e0.get(n);if(!i&&s?.orderedStatNames===e&&s.statCount===r)return;let o={},a=t0.get(e);a||(a=new Set(e),t0.set(e,a));for(let c of e)t[c]&&(o[c]=t[c]);for(let[c,l]of Object.entries(t))a.has(c)||(o[c]=l);for(let c of Object.keys(t))delete t[c];Object.assign(t,o),e0.set(n,{orderedStatNames:e,statCount:r})}var Jk,eR,e0,t0,ym,Su,bm=C(()=>{la();Jk="GPU Time and Memory",eR=["Adapter","GPU","GPU Type","GPU Backend","Frame Rate","CPU Time","GPU Time","GPU Memory","Buffer Memory","Texture Memory","External Buffer Memory","External Texture Memory","Swap Chain Texture"],e0=new WeakMap,t0=new WeakMap,ym=class{stats=new Map;getStats(e){return this.get(e)}get(e){this.stats.has(e)||this.stats.set(e,new Vt({id:e}));let t=this.stats.get(e);return e===Jk&&tR(t,eR),t}},Su=new ym});var nR,n0,vm,Vs,i0=C(()=>{_m();bm();ut();nR="set luma.log.level=1 (or higher) to trace rendering",n0="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",vm=class n{static defaultProps={...Eu,type:"best-available",adapters:void 0,waitForPageLoad:!0};stats=Su;log=z;VERSION="9.4.2";spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw z.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),z.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");z.error("This version of luma.gl has already been initialized")()}z.log(1,`${this.VERSION} - ${nR}`)(),globalThis.luma=this}async createDevice(e={}){let t={...n.defaultProps,...e},i=this.selectAdapter(t.type,t.adapters);if(!i)throw new Error(n0);return t.waitForPageLoad&&await i.pageLoaded,await i.create(t)}async attachDevice(e,t){let i=this._getTypeFromHandle(e,t.adapters),r=i&&this.selectAdapter(i,t.adapters);if(!r)throw new Error(n0);return await r?.attach?.(e,t)}registerAdapters(e){for(let t of e)this.preregisteredAdapters.set(t.type,t)}getSupportedAdapters(e=[]){let t=this._getAdapterMap(e);return Array.from(t).map(([,i])=>i).filter(i=>i.isSupported?.()).map(i=>i.type)}getBestAvailableAdapterType(e=[]){let t=["webgpu","webgl","null"],i=this._getAdapterMap(e);for(let r of t)if(i.get(r)?.isSupported?.())return r;return null}selectAdapter(e,t=[]){let i=e;e==="best-available"&&(i=this.getBestAvailableAdapterType(t));let r=this._getAdapterMap(t);return i&&r.get(i)||null}enforceWebGL2(e=!0,t=[]){let r=this._getAdapterMap(t).get("webgl");r||z.warn("enforceWebGL2: webgl adapter not found")(),r?.enforceWebGL2?.(e)}setDefaultDeviceProps(e){Object.assign(n.defaultProps,e)}_getAdapterMap(e=[]){let t=new Map(this.preregisteredAdapters);for(let i of e)t.set(i.type,i);return t}_getTypeFromHandle(e,t=[]){return e instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&e instanceof GPUDevice||e?.queue?"webgpu":e===null?"null":(e instanceof WebGLRenderingContext?z.warn("WebGL1 is not supported",e)():z.warn("Unknown handle type",e)(),null)}},Vs=new vm});function sR(){return Pu||(rR()||typeof window>"u"?Pu=Promise.resolve():Pu=new Promise(n=>window.addEventListener("load",()=>n()))),Pu}var wa,iR,rR,Pu,r0=C(()=>{vr();wa=class{get pageLoaded(){return sR()}},iR=Pt()&&typeof document<"u",rR=()=>iR&&document.readyState==="complete",Pu=null});function On(n="id"){xm[n]=xm[n]||1;let e=xm[n]++;return`${n}-${e}`}var xm,Ws=C(()=>{xm={}});function fR(n,e){let t={...e};for(let i in n)n[i]!==void 0&&(t[i]=n[i]);return t}function u0(n,e){let t=n.stats,i=!1;for(let c of e)t[c]||(n.get(c),i=!0);let r=Object.keys(t).length,s=c0.get(n);if(!i&&s?.orderedStatNames===e&&s.statCount===r)return;let o={},a=l0.get(e);a||(a=new Set(e),l0.set(e,a));for(let c of e)t[c]&&(o[c]=t[c]);for(let[c,l]of Object.entries(t))a.has(c)||(o[c]=l);for(let c of Object.keys(t))delete t[c];Object.assign(t,o),c0.set(n,{orderedStatNames:e,statCount:r})}function f0(n){return n.type==="webgl"?uR:lR}function Ea(n){let e=n.userData[oR];return e?.enabled?e:null}function zi(){return globalThis.performance?.now?.()??Date.now()}function dR(n,e){let t=Ea(n);if(!(!t||!t.activeDefaultFramebufferAcquireDepth))switch(t.transientCanvasResourceCreates=(t.transientCanvasResourceCreates||0)+1,e){case"Texture":t.transientCanvasTextureCreates=(t.transientCanvasTextureCreates||0)+1;break;case"TextureView":t.transientCanvasTextureViewCreates=(t.transientCanvasTextureViewCreates||0)+1;break;case"Sampler":t.transientCanvasSamplerCreates=(t.transientCanvasSamplerCreates||0)+1;break;case"Framebuffer":t.transientCanvasFramebufferCreates=(t.transientCanvasFramebufferCreates||0)+1;break;default:break}}function hR(n){let e=Object.getPrototypeOf(n);for(;e;){let t=Object.getPrototypeOf(e);if(!t||t===te.prototype)return pR(e)||n[Symbol.toStringTag]||n.constructor.name;e=t}return n[Symbol.toStringTag]||n.constructor.name}function pR(n){let e=Object.getOwnPropertyDescriptor(n,Symbol.toStringTag);return typeof e?.get=="function"?e.get.call(n):typeof e?.value=="string"?e.value:null}var oR,s0,o0,a0,aR,cR,lR,uR,c0,l0,te,He=C(()=>{Ws();oR="cpu-hotspot-profiler",s0="GPU Resource Counts",o0="Resource Counts",a0="GPU Time and Memory",aR=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","RenderBundleEncoders","RenderBundles","ComputePasss","CommandEncoders","CommandBuffers"],cR=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","SharedRenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","RenderBundleEncoders","RenderBundles","ComputePasss","CommandEncoders","CommandBuffers"],lR=aR.flatMap(n=>[`${n} Created`,`${n} Active`]),uR=cR.flatMap(n=>[`${n} Created`,`${n} Active`]),c0=new WeakMap,l0=new WeakMap,te=class{static defaultProps={id:"undefined",handle:void 0,_isHandleBorrowed:!1,userData:void 0};toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}toJSON(){return this.toString()}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;allocatedBytesName=null;_attachedResources=new Set;get ownsHandle(){return(this.props.handle===void 0||this.props.handle===null)&&!this.isHandleBorrowed}get isHandleBorrowed(){return!!this.props._isHandleBorrowed}constructor(e,t,i){if(!e)throw new Error("no device");this._device=e,this.props=fR(t,i);let r=this.props.id!=="undefined"?this.props.id:On(this[Symbol.toStringTag]);this.props.id=r,this.id=r,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyed||this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of this._attachedResources)e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyed||(this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0)}removeStats(){let e=Ea(this._device),t=e?zi():0,i=[this._device.statsManager.getStats(s0),this._device.statsManager.getStats(o0)],r=f0(this._device);for(let o of i)u0(o,r);let s=this.getStatsName();for(let o of i)o.get("Resources Active").decrementCount(),o.get(`${s}s Active`).decrementCount();e&&(e.statsBookkeepingCalls=(e.statsBookkeepingCalls||0)+1,e.statsBookkeepingTimeMs=(e.statsBookkeepingTimeMs||0)+(zi()-t))}trackAllocatedMemory(e,t=this.getStatsName()){let i=Ea(this._device),r=i?zi():0,s=this._device.statsManager.getStats(a0);this.allocatedBytes>0&&this.allocatedBytesName&&(s.get("GPU Memory").subtractCount(this.allocatedBytes),s.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes)),s.get("GPU Memory").addCount(e),s.get(`${t} Memory`).addCount(e),i&&(i.statsBookkeepingCalls=(i.statsBookkeepingCalls||0)+1,i.statsBookkeepingTimeMs=(i.statsBookkeepingTimeMs||0)+(zi()-r)),this.allocatedBytes=e,this.allocatedBytesName=t}trackReferencedMemory(e,t=this.getStatsName()){this.trackAllocatedMemory(e,`External ${t}`)}trackDeallocatedMemory(e=this.getStatsName()){if(this.allocatedBytes===0){this.allocatedBytesName=null;return}let t=Ea(this._device),i=t?zi():0,r=this._device.statsManager.getStats(a0);r.get("GPU Memory").subtractCount(this.allocatedBytes),r.get(`${this.allocatedBytesName||e} Memory`).subtractCount(this.allocatedBytes),t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+(zi()-i)),this.allocatedBytes=0,this.allocatedBytesName=null}trackDeallocatedReferencedMemory(e=this.getStatsName()){this.trackDeallocatedMemory(`Referenced ${e}`)}addStats(){let e=this.getStatsName(),t=Ea(this._device),i=t?zi():0,r=[this._device.statsManager.getStats(s0),this._device.statsManager.getStats(o0)],s=f0(this._device);for(let o of r)u0(o,s);for(let o of r)o.get("Resources Created").incrementCount(),o.get("Resources Active").incrementCount(),o.get(`${e}s Created`).incrementCount(),o.get(`${e}s Active`).incrementCount();t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+(zi()-i)),dR(this._device,e)}getStatsName(){return hR(this)}}});var re,Cu=C(()=>{He();re=class n extends te{static INDEX=16;static VERTEX=32;static UNIFORM=64;static STORAGE=128;static INDIRECT=256;static QUERY_RESOLVE=512;static MAP_READ=1;static MAP_WRITE=2;static COPY_SRC=4;static COPY_DST=8;get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,t){let i={...t};(t.usage||0)&n.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?i.indexType="uint32":t.data instanceof Uint16Array?i.indexType="uint16":t.data instanceof Uint8Array&&(i.indexType="uint8")),delete i.data,super(e,i,n.defaultProps),this.usage=i.usage||0,this.indexType=i.indexType,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}static DEBUG_DATA_MAX_LENGTH=32;debugData=new ArrayBuffer(0);_setDebugData(e,t,i){if(!this.device.props.debug)return;let r=null,s;ArrayBuffer.isView(e)?(r=e,s=e.buffer):s=e;let o=Math.min(e?e.byteLength:i,n.DEBUG_DATA_MAX_LENGTH);if(s===null)this.debugData=new ArrayBuffer(o);else{let a=Math.min(r?.byteOffset||0,s.byteLength),c=Math.max(0,s.byteLength-a),l=Math.min(o,c);this.debugData=new Uint8Array(s,a,l).slice().buffer}}static defaultProps={...te.defaultProps,handle:void 0,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0}}});function d0(){return wm??Uint16Array}function h0(n){return!!(wm&&n===wm)}var wm,p0=C(()=>{wm=globalThis.Float16Array});function m0(n){let e=n.includes("norm"),t=!e&&!n.startsWith("float"),i=n.startsWith("s"),r=Em[n],[s,o,a]=r||["uint8 ","i32",1];return{signedType:s,primitiveType:o,byteLength:a,normalized:e,integer:t,signed:i}}function g0(n){let e=n;switch(e){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return e}}function jt(n,e){switch(e){case 1:return n;case 2:return n+n%2;default:return n+(4-n%4)%4}}function Tu(n){let e=ArrayBuffer.isView(n)?n.constructor:n;if(h0(e))return"float16";if(e===Uint8ClampedArray)return"uint8";let t=Object.values(Em).find(i=>e===i[4]);if(!t)throw new Error(e.name);return t[0]}function _0(n){return Tu(n)}function Tr(n){if(n==="float16")return d0();let e=Em[n];if(!e)throw new Error(n);let[,,,,t]=e;return t}function Lr(n){return Tr(n)}var Em,Lu=C(()=>{p0();Em={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]}});var Sm,Ke,Mu=C(()=>{Lu();Sm=class{getDataTypeInfo(e){return m0(e)}getNormalizedDataType(e){return g0(e)}alignTo(e,t){return jt(e,t)}getDataType(e){return _0(e)}getTypedArrayConstructor(e){return Lr(e)}},Ke=new Sm});function mR(n,e){try{return Ke.getDataTypeInfo(e)}catch{throw new Error(`Unsupported vertex format: ${n}`)}}function gR(n,e){if(!e)return 1;let t=Number(e);if(t===2||t===3||t===4)return t;throw new Error(`Unsupported vertex format: ${n}`)}function _R(n,e,t){if(t!==3)throw new Error(`Unsupported vertex format: ${n}`);switch(e){case"uint8":case"sint8":case"unorm8":case"snorm8":case"uint16":case"sint16":case"unorm16":case"snorm16":return`${e}x3-webgl`;default:throw new Error(`Unsupported vertex format: ${n}`)}}var Pm,Ee,Sa=C(()=>{Mu();Pm=class{getVertexFormatInfo(e){if(e==="unorm10-10-10-2")return{type:"unorm8",components:4,byteLength:4,integer:!1,signed:!1,normalized:!0};let t=e==="unorm8x4-bgra"?"unorm8x4":e,i;t.endsWith("-webgl")&&(t=t.slice(0,-6),i=!0);let r=t.split("x");if(r.length>2)throw new Error(`Unsupported vertex format: ${e}`);let[s,o]=r,a=s,c=gR(e,o),l=mR(e,a),u;try{u=i?_R(e,a,c):this.makeVertexFormat(l.signedType,c,l.normalized)}catch{throw new Error(`Unsupported vertex format: ${e}`)}if(u!==(i?e:t))throw new Error(`Unsupported vertex format: ${e}`);let f={type:a,components:c,byteLength:l.byteLength*c,integer:l.integer,signed:l.signed,normalized:l.normalized};return i&&(f.webglOnly=!0),f}makeVertexFormat(e,t,i){let r=i?Ke.getNormalizedDataType(e):e;switch(r){case"unorm8":return t===1?"unorm8":t===3?"unorm8x3-webgl":`${r}x${t}`;case"snorm8":return t===1?"snorm8":t===3?"snorm8x3-webgl":`${r}x${t}`;case"uint8":case"sint8":if(t===3)throw new Error(`size: ${t}`);return t===1?r:`${r}x${t}`;case"uint16":return t===1?"uint16":t===3?"uint16x3-webgl":`${r}x${t}`;case"sint16":return t===1?"sint16":t===3?"sint16x3-webgl":`${r}x${t}`;case"unorm16":return t===1?"unorm16":t===3?"unorm16x3-webgl":`${r}x${t}`;case"snorm16":return t===1?"snorm16":t===3?"snorm16x3-webgl":`${r}x${t}`;case"float16":if(t===3)throw new Error(`size: ${t}`);return t===1?r:`${r}x${t}`;default:return t===1?r:`${r}x${t}`}}getVertexFormatFromAttribute(e,t,i){if(!t||t>4)throw new Error(`size ${t}`);let r=t,s=Ke.getDataType(e);return this.makeVertexFormat(s,r,i)}getCompatibleVertexFormat(e){let t;switch(e.primitiveType){case"f32":t="float32";break;case"i32":t="sint32";break;case"u32":t="uint32";break;case"f16":return e.components<=2?"float16x2":"float16x4"}return e.components===1?t:`${t}x${e.components}`}},Ee=new Pm});function Iu(n){let e=v0[n];if(!e)throw new Error(`Unsupported texture format ${n}`);return e}function b0(){return v0}var Je,be,Dn,yR,Au,Cm,ku,Tm,bR,Lm,Ui,Mm,Am,Ru,y0,vR,xR,v0,km=C(()=>{Je="texture-compression-bc",be="texture-compression-astc",Dn="texture-compression-etc2",yR="texture-compression-etc1-webgl",Au="texture-compression-pvrtc-webgl",Cm="texture-compression-atc-webgl",ku="float32-renderable-webgl",Tm="float16-renderable-webgl",bR="rgb9e5ufloat-renderable-webgl",Lm="snorm8-renderable-webgl",Ui="norm16-webgl",Mm="norm16-renderable-webgl",Am="snorm16-renderable-webgl",Ru="float32-filterable",y0="float16-filterable-webgl";vR={r8unorm:{webgpu:527},rg8unorm:{webgpu:527},"rgb8unorm-webgl":{},rgba8unorm:{webgpu:31},"rgba8unorm-srgb":{webgpu:15},r8snorm:{render:Lm,webgpu:837},rg8snorm:{render:Lm,webgpu:837},"rgb8snorm-webgl":{},rgba8snorm:{render:Lm,webgpu:341},r8uint:{webgpu:515},rg8uint:{webgpu:515},rgba8uint:{webgpu:19},r8sint:{webgpu:515},rg8sint:{webgpu:515},rgba8sint:{webgpu:19},bgra8unorm:{webgpu:15},"bgra8unorm-srgb":{webgpu:15360},r16unorm:{f:Ui,render:Mm,webgpu:992},rg16unorm:{f:Ui,render:Mm,webgpu:992},"rgb16unorm-webgl":{f:Ui,render:!1},rgba16unorm:{f:Ui,render:Mm,webgpu:992},r16snorm:{f:Ui,render:Am,webgpu:992},rg16snorm:{f:Ui,render:Am,webgpu:992},"rgb16snorm-webgl":{f:Ui,render:!1},rgba16snorm:{f:Ui,render:Am,webgpu:992},r16uint:{webgpu:515},rg16uint:{webgpu:515},rgba16uint:{webgpu:19},r16sint:{webgpu:515},rg16sint:{webgpu:515},rgba16sint:{webgpu:19},r16float:{render:Tm,filter:"float16-filterable-webgl",webgpu:527},rg16float:{render:Tm,filter:y0,webgpu:527},rgba16float:{render:Tm,filter:y0,webgpu:31},r32uint:{webgpu:19},rg32uint:{webgpu:16387},rgba32uint:{webgpu:19},r32sint:{webgpu:19},rg32sint:{webgpu:16387},rgba32sint:{webgpu:19},r32float:{render:ku,filter:Ru,webgpu:19},rg32float:{render:!1,filter:Ru,webgpu:16387},"rgb32float-webgl":{render:ku,filter:Ru},rgba32float:{render:ku,filter:Ru,webgpu:19},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:bR,webgpu:5},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:ku,webgpu:517},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:527},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:515},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8",webgpu:3},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16",webgpu:3},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32",webgpu:3},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32",webgpu:3},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0,webgpu:3},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0,f:"depth32float-stencil8",webgpu:3}},xR={"bc1-rgb-unorm-webgl":{f:Je},"bc1-rgb-unorm-srgb-webgl":{f:Je},"bc1-rgba-unorm":{f:Je},"bc1-rgba-unorm-srgb":{f:Je},"bc2-rgba-unorm":{f:Je},"bc2-rgba-unorm-srgb":{f:Je},"bc3-rgba-unorm":{f:Je},"bc3-rgba-unorm-srgb":{f:Je},"bc4-r-unorm":{f:Je},"bc4-r-snorm":{f:Je},"bc5-rg-unorm":{f:Je},"bc5-rg-snorm":{f:Je},"bc6h-rgb-ufloat":{f:Je},"bc6h-rgb-float":{f:Je},"bc7-rgba-unorm":{f:Je},"bc7-rgba-unorm-srgb":{f:Je},"etc2-rgb8unorm":{f:Dn},"etc2-rgb8unorm-srgb":{f:Dn},"etc2-rgb8a1unorm":{f:Dn},"etc2-rgb8a1unorm-srgb":{f:Dn},"etc2-rgba8unorm":{f:Dn},"etc2-rgba8unorm-srgb":{f:Dn},"eac-r11unorm":{f:Dn},"eac-r11snorm":{f:Dn},"eac-rg11unorm":{f:Dn},"eac-rg11snorm":{f:Dn},"astc-4x4-unorm":{f:be},"astc-4x4-unorm-srgb":{f:be},"astc-5x4-unorm":{f:be},"astc-5x4-unorm-srgb":{f:be},"astc-5x5-unorm":{f:be},"astc-5x5-unorm-srgb":{f:be},"astc-6x5-unorm":{f:be},"astc-6x5-unorm-srgb":{f:be},"astc-6x6-unorm":{f:be},"astc-6x6-unorm-srgb":{f:be},"astc-8x5-unorm":{f:be},"astc-8x5-unorm-srgb":{f:be},"astc-8x6-unorm":{f:be},"astc-8x6-unorm-srgb":{f:be},"astc-8x8-unorm":{f:be},"astc-8x8-unorm-srgb":{f:be},"astc-10x5-unorm":{f:be},"astc-10x5-unorm-srgb":{f:be},"astc-10x6-unorm":{f:be},"astc-10x6-unorm-srgb":{f:be},"astc-10x8-unorm":{f:be},"astc-10x8-unorm-srgb":{f:be},"astc-10x10-unorm":{f:be},"astc-10x10-unorm-srgb":{f:be},"astc-12x10-unorm":{f:be},"astc-12x10-unorm-srgb":{f:be},"astc-12x12-unorm":{f:be},"astc-12x12-unorm-srgb":{f:be},"pvrtc-rgb4unorm-webgl":{f:Au},"pvrtc-rgba4unorm-webgl":{f:Au},"pvrtc-rgb2unorm-webgl":{f:Au},"pvrtc-rgba2unorm-webgl":{f:Au},"etc1-rbg-unorm-webgl":{f:yR},"atc-rgb-unorm-webgl":{f:Cm},"atc-rgba-unorm-webgl":{f:Cm},"atc-rgbai-unorm-webgl":{f:Cm}},v0={...vR,...xR}});function TR({format:n,width:e,height:t,depth:i,byteAlignment:r}){let s=ft.getInfo(n),{bytesPerPixel:o,bytesPerBlock:a=o,blockWidth:c=1,blockHeight:l=1,compressed:u=!1}=s,f=u?Math.ceil(e/c):e,d=u?Math.ceil(t/l):t,h=f*a,p=Math.ceil(h/r)*r,m=d,g=p*m*i;return{bytesPerPixel:o,bytesPerRow:p,rowsPerImage:m,depthOrArrayLayers:i,bytesPerImage:p*m,byteLength:g}}function LR(n){let e=Iu(n),t={format:n,create:e.f??!0,render:e.render??!0,filter:e.filter??!0,blend:e.blend??!0,store:e.store??!0},i=x0(n),r=n.startsWith("depth")||n.startsWith("stencil"),s=i?.signed,o=i?.integer,a=i?.webgl,c=!!i?.compressed;return t.render&&=!r&&!c,t.filter&&=!r&&!s&&!o&&!a,t}function x0(n){let e=MR(n);if(ft.isCompressed(n)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0,e.bytesPerBlock=kR(n);let i=AR(n);i&&(e.blockWidth=i.blockWidth,e.blockHeight=i.blockHeight)}let t=e.packed?null:wR.exec(n);if(t){let[,i,r,s,o,a]=t,c=`${s}${r}`,l=Ke.getDataTypeInfo(c),u=l.byteLength*8,f=i?.length??1,d=[u,f>=2?u:0,f>=3?u:0,f>=4?u:0];e={format:n,attachment:e.attachment,dataType:l.signedType,components:f,channels:i,integer:l.integer,signed:l.signed,normalized:l.normalized,bitsPerChannel:d,bytesPerPixel:l.byteLength*f,packed:e.packed,srgb:e.srgb},a==="-webgl"&&(e.webgl=!0),o==="-srgb"&&(e.srgb=!0)}return n.endsWith("-webgl")&&(e.webgl=!0),n.endsWith("-srgb")&&(e.srgb=!0),e}function MR(n){let e={...Iu(n)},t=e.bytesPerPixel||1,i=e.bitsPerChannel||[8,8,8,8];return delete e.bitsPerChannel,delete e.bytesPerPixel,delete e.f,delete e.render,delete e.filter,delete e.blend,delete e.store,delete e.webgpu,{...e,format:n,attachment:e.attachment||"color",channels:e.channels||"r",components:e.components||e.channels?.length||1,bytesPerPixel:t,bitsPerChannel:i,dataType:e.dataType||"uint8",srgb:e.srgb??!1,packed:e.packed??!1,webgl:e.webgl??!1,integer:e.integer??!1,signed:e.signed??!1,normalized:e.normalized??!1,compressed:e.compressed??!1}}function AR(n){let t=/.*-(\d+)x(\d+)-.*/.exec(n);if(t){let[,i,r]=t;return{blockWidth:Number(i),blockHeight:Number(r)}}return n.startsWith("bc")||n.startsWith("etc1")||n.startsWith("etc2")||n.startsWith("eac")||n.startsWith("atc")?{blockWidth:4,blockHeight:4}:n.startsWith("pvrtc-rgb4")||n.startsWith("pvrtc-rgba4")?{blockWidth:4,blockHeight:4}:n.startsWith("pvrtc-rgb2")||n.startsWith("pvrtc-rgba2")?{blockWidth:8,blockHeight:4}:null}function kR(n){return n.startsWith("bc1")||n.startsWith("bc4")||n.startsWith("etc1")||n.startsWith("etc2-rgb8")||n.startsWith("etc2-rgb8a1")||n.startsWith("eac-r11")||n==="atc-rgb-unorm-webgl"?8:n.startsWith("bc2")||n.startsWith("bc3")||n.startsWith("bc5")||n.startsWith("bc6h")||n.startsWith("bc7")||n.startsWith("etc2-rgba8")||n.startsWith("eac-rg11")||n.startsWith("astc")||n==="atc-rgba-unorm-webgl"||n==="atc-rgbai-unorm-webgl"?16:n.startsWith("pvrtc")?8:16}var wR,ER,SR,PR,CR,Rm,ft,Bu=C(()=>{Mu();km();wR=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,ER=["rgb","rgba","bgra"],SR=["depth","stencil"],PR=5,CR=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],Rm=class{isColor(e){return ER.some(t=>e.startsWith(t))}isDepthStencil(e){return SR.some(t=>e.startsWith(t))}isCompressed(e){return CR.some(t=>e.startsWith(t))}getInfo(e){return x0(e)}getCapabilities(e){return LR(e)}getWebGPUCapabilities(e){let t=Iu(e);return t.webgpu!==void 0?t.webgpu:this.isCompressed(e)&&!e.endsWith("-webgl")?PR:0}computeMemoryLayout(e){return TR(e)}},ft=new Rm});function w0(n){return typeof ImageData<"u"&&n instanceof ImageData||typeof ImageBitmap<"u"&&n instanceof ImageBitmap||typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement||typeof VideoFrame<"u"&&n instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas}function E0(n){if(typeof ImageData<"u"&&n instanceof ImageData||typeof ImageBitmap<"u"&&n instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas)return{width:n.width,height:n.height};if(typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement)return{width:n.naturalWidth,height:n.naturalHeight};if(typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement)return{width:n.videoWidth,height:n.videoHeight};if(typeof VideoFrame<"u"&&n instanceof VideoFrame)return{width:n.displayWidth,height:n.displayHeight};throw new Error("Unknown image type")}var S0=C(()=>{});function RR(n,e){let t=Im(n),i=e.map(Im).filter(r=>r!==void 0);return[t,...i].filter(r=>r!==void 0)}function Im(n){if(n!==void 0){if(n===null||typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n;if(n instanceof Error)return n.message;if(Array.isArray(n))return n.map(Im);if(typeof n=="object"){if(IR(n)){let e=String(n);if(e!=="[object Object]")return e}return BR(n)?OR(n):n.constructor?.name||"Object"}return String(n)}}function IR(n){return"toString"in n&&typeof n.toString=="function"&&n.toString!==Object.prototype.toString}function BR(n){return"message"in n&&"type"in n}function OR(n){let e=typeof n.type=="string"?n.type:"message",t=typeof n.message=="string"?n.message:"",i=typeof n.lineNum=="number"?n.lineNum:null,r=typeof n.linePos=="number"?n.linePos:null,s=i!==null&&r!==null?` @ ${i}:${r}`:i!==null?` @ ${i}`:"";return`${e}${s}: ${t}`.trim()}function Bm(){if(typeof HTMLCanvasElement>"u")return!1;let n=HTMLCanvasElement.prototype;return"layoutSubtree"in n&&typeof n.requestPaint=="function"}var Pa,Ca,pi,P0=C(()=>{bm();ut();Ws();Cu();Sa();Bu();S0();km();_m();Pa=class{};Ca=class{features;disabledFeatures;constructor(e=[],t){this.features=new Set(e),this.disabledFeatures=t||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures?.[e]&&this.features.has(e)}};pi=class n{static defaultProps={...Eu};get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}toJSON(){return this.toString()}id;props;userData={};statsManager=Su;_factories={};timestamp=0;_reused=!1;_moduleData={};wgslLanguageFeatures=new Set;_textureCaps={};_debugGPUTimeQuery=null;constructor(e){this.props={...n.defaultProps,...e},this.id=this.props.id||On(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(e){return Ee.getVertexFormatInfo(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return ft.getInfo(e)}getTextureFormatCapabilities(e){let t=this._textureCaps[e];if(!t){let i=this._getDeviceTextureFormatCapabilities(e);t=this._getDeviceSpecificTextureFormatCapabilities(i),this._textureCaps[e]=t}return t}getMipLevelCount(e,t,i=1){let r=Math.max(e,t,i);return 1+Math.floor(Math.log2(r))}isExternalImage(e){return w0(e)}getExternalImageSize(e){return E0(e)}isTextureFormatSupported(e){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return ft.isCompressed(e)}getSupportedCompressedTextureFormats(){let e=[];for(let t of Object.keys(b0()))this.isTextureFormatCompressed(t)&&this.isTextureFormatSupported(t)&&e.push(t);return e}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){this.commandEncoder?.popDebugGroup()}insertDebugMarker(e){this.commandEncoder?.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,t,...i){if(!this.props.onError(e,t)){let s=RR(t,i);return z.error(this.type==="webgl"?"%cWebGL":"%cWebGPU","color: white; background: red; padding: 2px 6px; border-radius: 3px;",e.message,...s)}return()=>{}}debug(){if(this.props.debug)debugger;else{let e=`'Type luma.log.set({debug: true}) in console to enable debug breakpoints', -or create a device with the 'debug: true' prop.`;z.once(0,e)()}}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}createFence(){throw new Error("createFence() not implemented")}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}writeBufferViaCommandEncoder(e,t,i,r=0){throw new Error("writeBufferViaCommandEncoder() not implemented")}generateMipmapsWebGPU(e){throw new Error("not implemented")}_createSharedRenderPipelineWebGL(e){throw new Error("_createSharedRenderPipelineWebGL() not implemented")}_createBindGroupLayoutWebGPU(e,t){throw new Error("_createBindGroupLayoutWebGPU() not implemented")}_createBindGroupWebGPU(e,t,i,r,s){throw new Error("_createBindGroupWebGPU() not implemented")}_supportsDebugGPUTime(){return this.features.has("timestamp-query")&&!!(this.props.debug||this.props.debugGPUTime)}_enableDebugGPUTime(e=256){if(!this._supportsDebugGPUTime())return null;if(this._debugGPUTimeQuery)return this._debugGPUTimeQuery;try{this._debugGPUTimeQuery=this.createQuerySet({type:"timestamp",count:e}),this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id,timeProfilingQuerySet:this._debugGPUTimeQuery})}catch{this._debugGPUTimeQuery=null}return this._debugGPUTimeQuery}_disableDebugGPUTime(){this._debugGPUTimeQuery&&(this.commandEncoder.getTimeProfilingQuerySet()===this._debugGPUTimeQuery&&(this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id})),this._debugGPUTimeQuery.destroy(),this._debugGPUTimeQuery=null)}_isDebugGPUTimeEnabled(){return this._debugGPUTimeQuery!==null}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}getModuleData(e){return this._moduleData[e]||={},this._moduleData[e]}static _getCanvasContextProps(e){return e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){let t=ft.getCapabilities(e),i=s=>(typeof s=="string"?this.features.has(s):s)??!0,r=i(t.create);return{format:e,create:r,render:r&&i(t.render),filter:r&&i(t.filter),blend:r&&i(t.blend),store:r&&i(t.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let t={...e};if((e.usage||0)&re.INDEX&&(e.indexType||(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array?t.indexType="uint16":e.data instanceof Uint8Array&&(t.data=new Uint16Array(e.data),t.indexType="uint16")),!t.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return t}}});var Ou,C0=C(()=>{Ou=class{props;_resizeObserver;_intersectionObserver;_observeDevicePixelRatioTimeout=null;_observeDevicePixelRatioMediaQuery=null;_handleDevicePixelRatioChange=()=>this._refreshDevicePixelRatio();_trackPositionInterval=null;_started=!1;get started(){return this._started}constructor(e){this.props=e}start(){if(this._started||!this.props.canvas)return;this._started=!0,this._intersectionObserver||=new IntersectionObserver(t=>this.props.onIntersection(t)),this._resizeObserver||=new ResizeObserver(t=>this.props.onResize(t)),this._intersectionObserver.observe(this.props.canvas);let e=this.props.resizeObserverBox;try{this._resizeObserver.observe(this.props.canvas,{box:e})}catch{this._resizeObserver.observe(this.props.canvas,{box:"content-box"})}this._observeDevicePixelRatioTimeout=setTimeout(()=>this._refreshDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}stop(){this._started&&(this._started=!1,this._observeDevicePixelRatioTimeout&&(clearTimeout(this._observeDevicePixelRatioTimeout),this._observeDevicePixelRatioTimeout=null),this._observeDevicePixelRatioMediaQuery&&(this._observeDevicePixelRatioMediaQuery.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=null),this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null),this._resizeObserver?.disconnect(),this._intersectionObserver?.disconnect())}_refreshDevicePixelRatio(){this._started&&(this.props.onDevicePixelRatioChange(),this._observeDevicePixelRatioMediaQuery?.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._observeDevicePixelRatioMediaQuery.addEventListener("change",this._handleDevicePixelRatioChange,{once:!0}))}_trackPosition(e=100){this._trackPositionInterval||(this._trackPositionInterval=setInterval(()=>{this._started?this.props.onPositionChange():this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null)},e))}}});function T0(){let n,e;return{promise:new Promise((i,r)=>{n=i,e=r}),resolve:n,reject:e}}var L0=C(()=>{});function $i(n,e){if(!n){let t=new Error(e??"luma.gl assertion failed.");throw Error.captureStackTrace?.(t,$i),t}}function Gi(n,e){return $i(n,e),n}var Om=C(()=>{});function DR(n){if(typeof n=="string"){let e=document.getElementById(n);if(!e)throw new Error(`${n} is not an HTML element`);return e}return n||document.body}function NR(n){let e=document.getElementById(n);if(!Vi.isHTMLCanvas(e))throw new Error("Object is not a canvas element");return e}function FR(n){let{width:e,height:t}=n,i=document.createElement("canvas");i.id=On("lumagl-auto-created-canvas"),i.width=e||1,i.height=t||1,i.style.width=Number.isFinite(e)?`${e}px`:"100%",i.style.height=Number.isFinite(t)?`${t}px`:"100%",n?.visible||(i.style.visibility="hidden");let r=DR(n?.container||null);return r.insertBefore(i,r.firstChild),i}function zR(n,e,t,i,r){let s=n,o=M0(s[0],e,t),a=A0(s[1],e,i,r),c=M0(s[0]+1,e,t),l=c===t-1?c:c-1;c=A0(s[1]+1,e,i,r);let u;return r?(c=c===0?c:c+1,u=a,a=c):u=c===i-1?c:c-1,{x:o,y:a,width:Math.max(l-o+1,1),height:Math.max(u-a+1,1)}}function M0(n,e,t){return Math.min(Math.round(n*e),t-1)}function A0(n,e,t,i){return i?Math.max(0,t-1-Math.round(n*e)):Math.min(Math.round(n*e),t-1)}var Vi,Dm=C(()=>{vr();C0();Ws();L0();Om();Vi=class n{static isHTMLCanvas(e){return typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}static defaultProps={id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,pixelSizeSource:"exact",autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",colorFormat:void 0,toneMapping:"standard",trackPosition:!1};id;props;canvas;htmlCanvas;offscreenCanvas;type;initialized;isInitialized=!1;isVisible=!0;cssWidth;cssHeight;devicePixelRatio;devicePixelWidth;devicePixelHeight;drawingBufferWidth;drawingBufferHeight;_initializedResolvers=T0();_canvasObserver;_position=[0,0];destroyed=!1;_needsDrawingBufferResize=!0;_configuredDrawingBufferSize=[0,0];toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(e){this.props={...n.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,Pt()?e.canvas?typeof e.canvas=="string"?this.canvas=NR(e.canvas):this.canvas=e.canvas:this.canvas=FR(e):this.canvas={width:e.width||1,height:e.height||1},n.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):n.isOffscreenCanvas(this.canvas)?(this.id=e.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=e.id||"node-canvas-context",this.type="node"),this.cssWidth=this.htmlCanvas?.clientWidth||this.canvas.width,this.cssHeight=this.htmlCanvas?.clientHeight||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this._configuredDrawingBufferSize=[this.canvas.width,this.canvas.height],this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],this._canvasObserver=new Ou({canvas:this.htmlCanvas,trackPosition:this.props.trackPosition,resizeObserverBox:this.props.pixelSizeSource==="css-dpr"?"content-box":"device-pixel-content-box",onResize:t=>this._handleResize(t),onIntersection:t=>this._handleIntersection(t),onDevicePixelRatioChange:()=>this._observeDevicePixelRatio(),onPositionChange:()=>this.updatePosition()})}destroy(){this.destroyed||(this.destroyed=!0,this._stopObservers(),this.device=null)}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCurrentFramebuffer(e){return this._resizeDrawingBufferIfNeeded(),this._getCurrentFramebuffer(e)}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){let e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,t){e=Math.floor(e),t=Math.floor(t),!(this.drawingBufferWidth===e&&this.drawingBufferHeight===t)&&(this.drawingBufferWidth=e,this.drawingBufferHeight=t,this._needsDrawingBufferResize=!0)}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(e,t=!0){let i=this.cssToDeviceRatio(),[r,s]=this.getDrawingBufferSize();return zR(e,i,r,s,t)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){let[e,t]=this.getDrawingBufferSize();return e>0&&t>0?e/t:1}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),[t]=this.getCSSSize();return t?e/t:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}_startObservers(){this.destroyed||this._canvasObserver.start()}_stopObservers(){this._canvasObserver.stop()}_handleIntersection(e){if(this.destroyed)return;let t=e.find(r=>r.target===this.canvas);if(!t)return;let i=t.isIntersecting;this.isVisible!==i&&(this.isVisible=i,this.device.props.onVisibilityChange(this))}_handleResize(e){if(this.destroyed)return;let t=e.find(s=>s.target===this.canvas);if(!t)return;let i=Gi(t.contentBoxSize?.[0]);this.cssWidth=i.inlineSize,this.cssHeight=i.blockSize;let r=this.getDevicePixelSize();this._setDevicePixelSize(this._getDevicePixelSizeFromResizeEntry(t)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:r})}_updateDrawingBufferSize(){if(this.props.autoResize)if(typeof this.props.useDevicePixels=="number"){let e=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*e,this.cssHeight*e)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_getDevicePixelSizeFromResizeEntry(e){let t=Gi(e.contentBoxSize?.[0]);return this.props.pixelSizeSource==="css-dpr"?this._getDevicePixelSizeFromCSSSize(t.inlineSize,t.blockSize):{devicePixelWidth:e.devicePixelContentBoxSize?.[0]?.inlineSize||t.inlineSize*devicePixelRatio,devicePixelHeight:e.devicePixelContentBoxSize?.[0]?.blockSize||t.blockSize*devicePixelRatio}}_getDevicePixelSizeFromCSSSize(e,t){let i=this.getDevicePixelRatio();return{devicePixelWidth:Math.floor(e*i),devicePixelHeight:Math.floor(t*i)}}_setDevicePixelSize({devicePixelWidth:e,devicePixelHeight:t}){let[i,r]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(e,i)),this.devicePixelHeight=Math.max(1,Math.min(t,r))}_resizeDrawingBufferIfNeeded(){if(this._needsDrawingBufferResize){this._needsDrawingBufferResize=!1,(this.drawingBufferWidth!==this.canvas.width||this.drawingBufferHeight!==this.canvas.height)&&(this.canvas.width=this.drawingBufferWidth,this.canvas.height=this.drawingBufferHeight);let[t,i]=this._configuredDrawingBufferSize;(this.drawingBufferWidth!==t||this.drawingBufferHeight!==i)&&(this._configureDevice(),this._configuredDrawingBufferSize=[this.drawingBufferWidth,this.drawingBufferHeight])}}_observeDevicePixelRatio(){if(this.destroyed||!this._canvasObserver.started)return;let e=this.devicePixelRatio;if(this.devicePixelRatio=window.devicePixelRatio,this.props.pixelSizeSource==="css-dpr"){let t=this.getDevicePixelSize();this._setDevicePixelSize(this._getDevicePixelSizeFromCSSSize(this.cssWidth,this.cssHeight)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:t})}this.updatePosition(),this.device.props.onDevicePixelRatioChange?.(this,{oldRatio:e})}updatePosition(){if(this.destroyed)return;let e=this.htmlCanvas?.getBoundingClientRect();if(e){let t=[e.left,e.top];if(this._position??=t,t[0]!==this._position[0]||t[1]!==this._position[1]){let r=this._position;this._position=t,this.device.props.onPositionChange?.(this,{oldPosition:r})}}}}});var Ta,k0=C(()=>{Dm();Ta=class extends Vi{static defaultProps=Vi.defaultProps}});var La,R0=C(()=>{Dm();La=class extends Vi{}});var Mr,Nm=C(()=>{He();Mr=class n extends te{static defaultProps={...te.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1};get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){t=n.normalizeProps(e,t),super(e,t,n.defaultProps)}static normalizeProps(e,t){return t}}});var UR,pe,Fm=C(()=>{He();Nm();ut();Bu();UR={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},pe=class n extends te{static SAMPLE=4;static STORAGE=8;static RENDER=16;static COPY_SRC=1;static COPY_DST=2;static TEXTURE=4;static RENDER_ATTACHMENT=16;dimension;baseDimension;format;width;height;depth;mipLevels;samples;byteAlignment;ready=Promise.resolve(this);isReady=!0;updateTimestamp;get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(e,t,i){if(t=n.normalizeProps(e,t),super(e,t,n.defaultProps),this.dimension=this.props.dimension,this.baseDimension=UR[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.samples=this.props.samples||1,this.dimension==="cube"&&(this.depth=6),this.props.width===void 0||this.props.height===void 0)if(e.isExternalImage(t.data)){let r=e.getExternalImageSize(t.data);this.width=r?.width||1,this.height=r?.height||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&z.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=i?.byteAlignment||1,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createTexture({...this.props,...e})}setSampler(e){this.sampler=e instanceof Mr?e:this.device.createSampler(e)}copyImageData(e){let{data:t,depth:i,...r}=e;this.writeData(t,{...r,depthOrArrayLayers:r.depthOrArrayLayers??i})}computeMemoryLayout(e={}){let t=this._normalizeTextureReadOptions(e),{width:i=this.width,height:r=this.height,depthOrArrayLayers:s=this.depth}=t,{format:o,byteAlignment:a}=this;return ft.computeMemoryLayout({format:o,width:i,height:r,depth:s,byteAlignment:a})}readBuffer(e,t){throw new Error("readBuffer not implemented")}readDataAsync(e){throw new Error("readBuffer not implemented")}writeBuffer(e,t){throw new Error("readBuffer not implemented")}writeData(e,t){throw new Error("readBuffer not implemented")}readDataSyncWebGL(e){throw new Error("readDataSyncWebGL not available")}generateMipmapsWebGL(){throw new Error("generateMipmapsWebGL not available")}static normalizeProps(e,t){let i={...t},{width:r,height:s}=i;return typeof r=="number"&&(i.width=Math.max(1,Math.ceil(r))),typeof s=="number"&&(i.height=Math.max(1,Math.ceil(s))),i}_initializeData(e){this.device.isExternalImage(e)?this.copyExternalImage({image:e,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):e&&this.copyImageData({data:e,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(e){let{data:t,depth:i,...r}=e,s=this._normalizeTextureWriteOptions({...r,depthOrArrayLayers:r.depthOrArrayLayers??i});return{data:t,depth:s.depthOrArrayLayers,...s}}_normalizeCopyExternalImageOptions(e){let t=n._omitUndefined(e),i=t.mipLevel??0,r=this._getMipLevelSize(i),s=this.device.getExternalImageSize(e.image),o={...n.defaultCopyExternalImageOptions,...r,...s,...t};return o.width=Math.min(o.width,r.width-o.x),o.height=Math.min(o.height,r.height-o.y),o.depth=Math.min(o.depth,r.depthOrArrayLayers-o.z),o}_normalizeCopyElementImageOptions(e){let t=n._omitUndefined(e),i=t.mipLevel??0,r=this._getMipLevelSize(i),s={...n.defaultCopyElementImageOptions,...r,...t};return s.width=Math.min(s.width,r.width-s.x),s.height=Math.min(s.height,r.height-s.y),s.depth=Math.min(s.depth,r.depthOrArrayLayers-s.z),s}_normalizeTextureReadOptions(e){let t=n._omitUndefined(e),i=t.mipLevel??0,r=this._getMipLevelSize(i),s={...n.defaultTextureReadOptions,...r,...t};return s.width=Math.min(s.width,r.width-s.x),s.height=Math.min(s.height,r.height-s.y),s.depthOrArrayLayers=Math.min(s.depthOrArrayLayers,r.depthOrArrayLayers-s.z),s}_getSupportedColorReadOptions(e){let t=this._normalizeTextureReadOptions(e),i=ft.getInfo(this.format);switch(this._validateColorReadAspect(t),this._validateColorReadFormat(i),this.dimension){case"2d":case"cube":case"cube-array":case"2d-array":case"3d":return t;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}}_validateColorReadAspect(e){if(e.aspect!=="all")throw new Error(`${this} color readback only supports aspect 'all'`)}_validateColorReadFormat(e){if(e.compressed)throw new Error(`${this} color readback does not support compressed formats (${this.format})`);switch(e.attachment){case"color":return;case"depth":throw new Error(`${this} color readback does not support depth formats (${this.format})`);case"stencil":throw new Error(`${this} color readback does not support stencil formats (${this.format})`);case"depth-stencil":throw new Error(`${this} color readback does not support depth-stencil formats (${this.format})`);default:throw new Error(`${this} color readback does not support format ${this.format}`)}}_normalizeTextureWriteOptions(e){let t=n._omitUndefined(e),i=t.mipLevel??0,r=this._getMipLevelSize(i),s={...n.defaultTextureWriteOptions,...r,...t};s.width=Math.min(s.width,r.width-s.x),s.height=Math.min(s.height,r.height-s.y),s.depthOrArrayLayers=Math.min(s.depthOrArrayLayers,r.depthOrArrayLayers-s.z);let o=ft.computeMemoryLayout({format:this.format,width:s.width,height:s.height,depth:s.depthOrArrayLayers,byteAlignment:this.byteAlignment}),a=o.bytesPerPixel*s.width;if(s.bytesPerRow=t.bytesPerRow??o.bytesPerRow,s.rowsPerImage=t.rowsPerImage??s.height,s.bytesPerRow>e),i=this.baseDimension==="1d"?1:Math.max(1,this.height>>e),r=this.dimension==="3d"?Math.max(1,this.depth>>e):this.depth;return{width:t,height:i,depthOrArrayLayers:r}}getAllocatedByteLength(){let e=0;for(let t=0;tt!==void 0))}static defaultProps={...te.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:n.SAMPLE|n.RENDER|n.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0};static defaultCopyDataOptions={data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,width:void 0,height:void 0,depthOrArrayLayers:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all"};static defaultCopyExternalImageOptions={image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultCopyElementImageOptions={element:void 0,width:void 0,height:void 0,sourceX:0,sourceY:0,sourceWidth:void 0,sourceHeight:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultTextureReadOptions={x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"};static defaultTextureWriteOptions={byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"}}});var Ar,I0=C(()=>{He();Ar=class n extends te{get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,n.defaultProps)}static defaultProps={...te.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0}}});var Ma,B0=C(()=>{He();Ma=class n extends te{width;height;updateTimestamp;get[Symbol.toStringTag](){return"ExternalTexture"}constructor(e,t){super(e,t,n.defaultProps);let i=this.props.source?e.getExternalImageSize(this.props.source):null;this.width=this.props.width||i?.width||0,this.height=this.props.height||i?.height||0,this.updateTimestamp=e.incrementTimestamp()}static defaultProps={...te.defaultProps,source:void 0,width:0,height:0,colorSpace:"srgb",sampler:{}}}});function O0(n,e,t){let i="",r=e.split(/\r?\n/),s=n.slice().sort((o,a)=>o.lineNum-a.lineNum);switch(t?.showSourceCode||"no"){case"all":let o=0;for(let a=1;a<=r.length;a++){let c=r[a-1],l=s[o];for(c&&l&&(i+=D0(c,a,t));s.length>o&&l.lineNum===a;){let u=s[o++];u&&(i+=zm(u,r,u.lineNum,{...t,inlineSource:!1}))}}for(;s.length>o;){let a=s[o++];a&&(i+=zm(a,[],0,{...t,inlineSource:!1}))}return i;case"issues":case"no":for(let a of n)i+=zm(a,r,a.lineNum,{inlineSource:t?.showSourceCode!=="no"});return i}}function zm(n,e,t,i){if(i?.inlineSource){let s=$R(e,t),o=n.linePos>0?`${" ".repeat(n.linePos+5)}^^^ +`;switch(a){case"vs:#decl":(r==="wgsl"||o)&&(n=n.replace(xa,l));break;case"vs:#main-start":(r==="wgsl"||o)&&(n=r==="wgsl"?wu(n,"vertex",l,"start",s.vertex):n.replace(Kx,u=>u+l));break;case"vs:#main-end":(r==="wgsl"||o)&&(n=r==="wgsl"?wu(n,"vertex",l,"end",s.vertex):n.replace(Qx,u=>l+u));break;case"fs:#decl":(r==="wgsl"||!o)&&(n=n.replace(xa,l));break;case"fs:#main-start":(r==="wgsl"||!o)&&(n=r==="wgsl"?wu(n,"fragment",l,"start",s.fragment):n.replace(Kx,u=>u+l));break;case"fs:#main-end":(r==="wgsl"||!o)&&(n=r==="wgsl"?wu(n,"fragment",l,"end",s.fragment):n.replace(Qx,u=>l+u));break;default:n=n.replace(a,u=>u+l)}}return n=n.replace(xa,""),i&&(n=n.replace(/\}\s*$/,a=>a+Yk[e])),n}function wu(n,e,t,i,r){let s=Zk(n,e,r);if(!s)return n;if(i==="start"){let o=s.openBraceIndex+1;return`${n.slice(0,o)} +${t}${n.slice(o)}`}return`${n.slice(0,s.closeBraceIndex)}${t}${n.slice(s.closeBraceIndex)}`}function Zk(n,e,t){let i=e==="vertex"?"@vertex":"@fragment",r=n.indexOf(i);if(r<0)return null;let s=t?n.search(new RegExp(`\\bfn\\s+${Xk(t)}\\s*\\(`)):n.indexOf("fn",r);if(s<0)return null;let o=n.indexOf("{",s);if(o<0)return null;let a=0;for(let c=o;c{Xx();Yk={vertex:qx,fragment:Zx},Kx=/void\s+main\s*\([^)]*\)\s*\{\n?/,Qx=/}\n?[^{}]*$/,pm=[],xa="__LUMA_INJECT_DECLARATIONS__"});function Gs(n){n.map(e=>Kk(e))}function Kk(n){if(n.instance)return;Gs(n.dependencies||[]);let{propTypes:e={},deprecations:t=[],inject:i={}}=n,r={normalizedInjections:Jx(i),parsedDeprecations:Qk(t)};e&&(r.propValidators=Hx(e)),n.instance=r;let s={};e&&(s=Object.entries(e).reduce((o,[a,c])=>{let l=c?.value;return l&&(o[a]=l),o},{})),n.defaultUniforms={...n.defaultUniforms,...s}}function gm(n,e,t){n.deprecations?.forEach(i=>{i.regex?.test(e)&&(i.deprecated?t.deprecated(i.old,i.new)():t.removed(i.old,i.new)())})}function Qk(n){return n.forEach(e=>{switch(e.type){case"function":e.regex=new RegExp(`\\b${e.old}\\(`);break;default:e.regex=new RegExp(`${e.type} ${e.old};`)}}),n}var Eu=C(()=>{Yx();mm()});function Cr(n){Gs(n);let e={},t={};e0({modules:n,level:0,moduleMap:e,moduleDepth:t});let i=Object.keys(t).sort((r,s)=>t[s]-t[r]).map(r=>e[r]);return Gs(i),i}function e0(n){let{modules:e,level:t,moduleMap:i,moduleDepth:r}=n;if(t>=5)throw new Error("Possible loop in shader dependency graph");for(let s of e)i[s.name]=s,(r[s.name]===void 0||r[s.name]{Eu()});var N,ut=C(()=>{sa();N=new ct({id:"luma.gl"})});function Jk(n,e){return n!=null?!!n:e!==void 0?e!=="production":!1}function eR(){return Jk(N.get("debug"),tR())}function tR(){let n=globalThis.process;if(n?.env)return n.env.NODE_ENV}var Su,ym=C(()=>{ut();Su={id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,featureLevel:void 0,optionalFeatures:[],xrCompatible:!1,createCanvasContext:void 0,webgl:{},onError:(n,e)=>{},onResize:(n,e)=>{let[t,i]=n.getDevicePixelSize();N.log(1,`${n} resized => ${t}x${i}px`)()},onPositionChange:(n,e)=>{let[t,i]=n.getPosition();N.log(1,`${n} repositioned => ${t},${i}`)()},onVisibilityChange:n=>N.log(1,`${n} Visibility changed ${n.isVisible}`)(),onDevicePixelRatioChange:(n,e)=>N.log(1,`${n} DPR changed ${e.oldRatio} => ${n.devicePixelRatio}`)(),debug:eR(),debugGPUTime:!1,debugShaders:N.get("debug-shaders")||void 0,debugFramebuffers:!!N.get("debug-framebuffers"),debugFactories:!!N.get("debug-factories"),debugWebGL:!!N.get("debug-webgl"),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0}});function rR(n,e){let t=n.stats,i=!1;for(let c of e)t[c]||(n.get(c),i=!0);let r=Object.keys(t).length,s=t0.get(n);if(!i&&s?.orderedStatNames===e&&s.statCount===r)return;let o={},a=n0.get(e);a||(a=new Set(e),n0.set(e,a));for(let c of e)t[c]&&(o[c]=t[c]);for(let[c,l]of Object.entries(t))a.has(c)||(o[c]=l);for(let c of Object.keys(t))delete t[c];Object.assign(t,o),t0.set(n,{orderedStatNames:e,statCount:r})}var nR,iR,t0,n0,bm,Pu,vm=C(()=>{ua();nR="GPU Time and Memory",iR=["Adapter","GPU","GPU Type","GPU Backend","Frame Rate","CPU Time","GPU Time","GPU Memory","Buffer Memory","Texture Memory","External Buffer Memory","External Texture Memory","Swap Chain Texture"],t0=new WeakMap,n0=new WeakMap,bm=class{stats=new Map;getStats(e){return this.get(e)}get(e){this.stats.has(e)||this.stats.set(e,new Yt({id:e}));let t=this.stats.get(e);return e===nR&&rR(t,iR),t}},Pu=new bm});var sR,i0,xm,Vs,r0=C(()=>{ym();vm();ut();sR="set luma.log.level=1 (or higher) to trace rendering",i0="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",xm=class n{static defaultProps={...Su,type:"best-available",adapters:void 0,waitForPageLoad:!0};stats=Pu;log=N;VERSION="9.4.2";spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw N.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),N.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");N.error("This version of luma.gl has already been initialized")()}N.log(1,`${this.VERSION} - ${sR}`)(),globalThis.luma=this}async createDevice(e={}){let t={...n.defaultProps,...e},i=this.selectAdapter(t.type,t.adapters);if(!i)throw new Error(i0);return t.waitForPageLoad&&await i.pageLoaded,await i.create(t)}async attachDevice(e,t){let i=this._getTypeFromHandle(e,t.adapters),r=i&&this.selectAdapter(i,t.adapters);if(!r)throw new Error(i0);return await r?.attach?.(e,t)}registerAdapters(e){for(let t of e)this.preregisteredAdapters.set(t.type,t)}getSupportedAdapters(e=[]){let t=this._getAdapterMap(e);return Array.from(t).map(([,i])=>i).filter(i=>i.isSupported?.()).map(i=>i.type)}getBestAvailableAdapterType(e=[]){let t=["webgpu","webgl","null"],i=this._getAdapterMap(e);for(let r of t)if(i.get(r)?.isSupported?.())return r;return null}selectAdapter(e,t=[]){let i=e;e==="best-available"&&(i=this.getBestAvailableAdapterType(t));let r=this._getAdapterMap(t);return i&&r.get(i)||null}enforceWebGL2(e=!0,t=[]){let r=this._getAdapterMap(t).get("webgl");r||N.warn("enforceWebGL2: webgl adapter not found")(),r?.enforceWebGL2?.(e)}setDefaultDeviceProps(e){Object.assign(n.defaultProps,e)}_getAdapterMap(e=[]){let t=new Map(this.preregisteredAdapters);for(let i of e)t.set(i.type,i);return t}_getTypeFromHandle(e,t=[]){return e instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&e instanceof GPUDevice||e?.queue?"webgpu":e===null?"null":(e instanceof WebGLRenderingContext?N.warn("WebGL1 is not supported",e)():N.warn("Unknown handle type",e)(),null)}},Vs=new xm});function cR(){return Cu||(aR()||typeof window>"u"?Cu=Promise.resolve():Cu=new Promise(n=>window.addEventListener("load",()=>n()))),Cu}var Ea,oR,aR,Cu,s0=C(()=>{vr();Ea=class{get pageLoaded(){return cR()}},oR=Tt()&&typeof document<"u",aR=()=>oR&&document.readyState==="complete",Cu=null});function zn(n="id"){wm[n]=wm[n]||1;let e=wm[n]++;return`${n}-${e}`}var wm,Ws=C(()=>{wm={}});function pR(n,e){let t={...e};for(let i in n)n[i]!==void 0&&(t[i]=n[i]);return t}function f0(n,e){let t=n.stats,i=!1;for(let c of e)t[c]||(n.get(c),i=!0);let r=Object.keys(t).length,s=l0.get(n);if(!i&&s?.orderedStatNames===e&&s.statCount===r)return;let o={},a=u0.get(e);a||(a=new Set(e),u0.set(e,a));for(let c of e)t[c]&&(o[c]=t[c]);for(let[c,l]of Object.entries(t))a.has(c)||(o[c]=l);for(let c of Object.keys(t))delete t[c];Object.assign(t,o),l0.set(n,{orderedStatNames:e,statCount:r})}function d0(n){return n.type==="webgl"?hR:dR}function Sa(n){let e=n.userData[lR];return e?.enabled?e:null}function $i(){return globalThis.performance?.now?.()??Date.now()}function mR(n,e){let t=Sa(n);if(!(!t||!t.activeDefaultFramebufferAcquireDepth))switch(t.transientCanvasResourceCreates=(t.transientCanvasResourceCreates||0)+1,e){case"Texture":t.transientCanvasTextureCreates=(t.transientCanvasTextureCreates||0)+1;break;case"TextureView":t.transientCanvasTextureViewCreates=(t.transientCanvasTextureViewCreates||0)+1;break;case"Sampler":t.transientCanvasSamplerCreates=(t.transientCanvasSamplerCreates||0)+1;break;case"Framebuffer":t.transientCanvasFramebufferCreates=(t.transientCanvasFramebufferCreates||0)+1;break;default:break}}function gR(n){let e=Object.getPrototypeOf(n);for(;e;){let t=Object.getPrototypeOf(e);if(!t||t===te.prototype)return _R(e)||n[Symbol.toStringTag]||n.constructor.name;e=t}return n[Symbol.toStringTag]||n.constructor.name}function _R(n){let e=Object.getOwnPropertyDescriptor(n,Symbol.toStringTag);return typeof e?.get=="function"?e.get.call(n):typeof e?.value=="string"?e.value:null}var lR,o0,a0,c0,uR,fR,dR,hR,l0,u0,te,He=C(()=>{Ws();lR="cpu-hotspot-profiler",o0="GPU Resource Counts",a0="Resource Counts",c0="GPU Time and Memory",uR=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","RenderBundleEncoders","RenderBundles","ComputePasss","CommandEncoders","CommandBuffers"],fR=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","SharedRenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","RenderBundleEncoders","RenderBundles","ComputePasss","CommandEncoders","CommandBuffers"],dR=uR.flatMap(n=>[`${n} Created`,`${n} Active`]),hR=fR.flatMap(n=>[`${n} Created`,`${n} Active`]),l0=new WeakMap,u0=new WeakMap,te=class{static defaultProps={id:"undefined",handle:void 0,_isHandleBorrowed:!1,userData:void 0};toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}toJSON(){return this.toString()}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;allocatedBytesName=null;_attachedResources=new Set;get ownsHandle(){return(this.props.handle===void 0||this.props.handle===null)&&!this.isHandleBorrowed}get isHandleBorrowed(){return!!this.props._isHandleBorrowed}constructor(e,t,i){if(!e)throw new Error("no device");this._device=e,this.props=pR(t,i);let r=this.props.id!=="undefined"?this.props.id:zn(this[Symbol.toStringTag]);this.props.id=r,this.id=r,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyed||this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of this._attachedResources)e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyed||(this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0)}removeStats(){let e=Sa(this._device),t=e?$i():0,i=[this._device.statsManager.getStats(o0),this._device.statsManager.getStats(a0)],r=d0(this._device);for(let o of i)f0(o,r);let s=this.getStatsName();for(let o of i)o.get("Resources Active").decrementCount(),o.get(`${s}s Active`).decrementCount();e&&(e.statsBookkeepingCalls=(e.statsBookkeepingCalls||0)+1,e.statsBookkeepingTimeMs=(e.statsBookkeepingTimeMs||0)+($i()-t))}trackAllocatedMemory(e,t=this.getStatsName()){let i=Sa(this._device),r=i?$i():0,s=this._device.statsManager.getStats(c0);this.allocatedBytes>0&&this.allocatedBytesName&&(s.get("GPU Memory").subtractCount(this.allocatedBytes),s.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes)),s.get("GPU Memory").addCount(e),s.get(`${t} Memory`).addCount(e),i&&(i.statsBookkeepingCalls=(i.statsBookkeepingCalls||0)+1,i.statsBookkeepingTimeMs=(i.statsBookkeepingTimeMs||0)+($i()-r)),this.allocatedBytes=e,this.allocatedBytesName=t}trackReferencedMemory(e,t=this.getStatsName()){this.trackAllocatedMemory(e,`External ${t}`)}trackDeallocatedMemory(e=this.getStatsName()){if(this.allocatedBytes===0){this.allocatedBytesName=null;return}let t=Sa(this._device),i=t?$i():0,r=this._device.statsManager.getStats(c0);r.get("GPU Memory").subtractCount(this.allocatedBytes),r.get(`${this.allocatedBytesName||e} Memory`).subtractCount(this.allocatedBytes),t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+($i()-i)),this.allocatedBytes=0,this.allocatedBytesName=null}trackDeallocatedReferencedMemory(e=this.getStatsName()){this.trackDeallocatedMemory(`Referenced ${e}`)}addStats(){let e=this.getStatsName(),t=Sa(this._device),i=t?$i():0,r=[this._device.statsManager.getStats(o0),this._device.statsManager.getStats(a0)],s=d0(this._device);for(let o of r)f0(o,s);for(let o of r)o.get("Resources Created").incrementCount(),o.get("Resources Active").incrementCount(),o.get(`${e}s Created`).incrementCount(),o.get(`${e}s Active`).incrementCount();t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+($i()-i)),mR(this._device,e)}getStatsName(){return gR(this)}}});var ie,Tu=C(()=>{He();ie=class n extends te{static INDEX=16;static VERTEX=32;static UNIFORM=64;static STORAGE=128;static INDIRECT=256;static QUERY_RESOLVE=512;static MAP_READ=1;static MAP_WRITE=2;static COPY_SRC=4;static COPY_DST=8;get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,t){let i={...t};(t.usage||0)&n.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?i.indexType="uint32":t.data instanceof Uint16Array?i.indexType="uint16":t.data instanceof Uint8Array&&(i.indexType="uint8")),delete i.data,super(e,i,n.defaultProps),this.usage=i.usage||0,this.indexType=i.indexType,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}static DEBUG_DATA_MAX_LENGTH=32;debugData=new ArrayBuffer(0);_setDebugData(e,t,i){if(!this.device.props.debug)return;let r=null,s;ArrayBuffer.isView(e)?(r=e,s=e.buffer):s=e;let o=Math.min(e?e.byteLength:i,n.DEBUG_DATA_MAX_LENGTH);if(s===null)this.debugData=new ArrayBuffer(o);else{let a=Math.min(r?.byteOffset||0,s.byteLength),c=Math.max(0,s.byteLength-a),l=Math.min(o,c);this.debugData=new Uint8Array(s,a,l).slice().buffer}}static defaultProps={...te.defaultProps,handle:void 0,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0}}});function h0(){return Em??Uint16Array}function p0(n){return!!(Em&&n===Em)}var Em,m0=C(()=>{Em=globalThis.Float16Array});function g0(n){let e=n.includes("norm"),t=!e&&!n.startsWith("float"),i=n.startsWith("s"),r=Sm[n],[s,o,a]=r||["uint8 ","i32",1];return{signedType:s,primitiveType:o,byteLength:a,normalized:e,integer:t,signed:i}}function _0(n){let e=n;switch(e){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return e}}function Zt(n,e){switch(e){case 1:return n;case 2:return n+n%2;default:return n+(4-n%4)%4}}function Lu(n){let e=ArrayBuffer.isView(n)?n.constructor:n;if(p0(e))return"float16";if(e===Uint8ClampedArray)return"uint8";let t=Object.values(Sm).find(i=>e===i[4]);if(!t)throw new Error(e.name);return t[0]}function y0(n){return Lu(n)}function Tr(n){if(n==="float16")return h0();let e=Sm[n];if(!e)throw new Error(n);let[,,,,t]=e;return t}function Lr(n){return Tr(n)}var Sm,Mu=C(()=>{m0();Sm={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]}});var Pm,Xe,Au=C(()=>{Mu();Pm=class{getDataTypeInfo(e){return g0(e)}getNormalizedDataType(e){return _0(e)}alignTo(e,t){return Zt(e,t)}getDataType(e){return y0(e)}getTypedArrayConstructor(e){return Lr(e)}},Xe=new Pm});function yR(n,e){try{return Xe.getDataTypeInfo(e)}catch{throw new Error(`Unsupported vertex format: ${n}`)}}function bR(n,e){if(!e)return 1;let t=Number(e);if(t===2||t===3||t===4)return t;throw new Error(`Unsupported vertex format: ${n}`)}function vR(n,e,t){if(t!==3)throw new Error(`Unsupported vertex format: ${n}`);switch(e){case"uint8":case"sint8":case"unorm8":case"snorm8":case"uint16":case"sint16":case"unorm16":case"snorm16":return`${e}x3-webgl`;default:throw new Error(`Unsupported vertex format: ${n}`)}}var Cm,Pe,Pa=C(()=>{Au();Cm=class{getVertexFormatInfo(e){if(e==="unorm10-10-10-2")return{type:"unorm8",components:4,byteLength:4,integer:!1,signed:!1,normalized:!0};let t=e==="unorm8x4-bgra"?"unorm8x4":e,i;t.endsWith("-webgl")&&(t=t.slice(0,-6),i=!0);let r=t.split("x");if(r.length>2)throw new Error(`Unsupported vertex format: ${e}`);let[s,o]=r,a=s,c=bR(e,o),l=yR(e,a),u;try{u=i?vR(e,a,c):this.makeVertexFormat(l.signedType,c,l.normalized)}catch{throw new Error(`Unsupported vertex format: ${e}`)}if(u!==(i?e:t))throw new Error(`Unsupported vertex format: ${e}`);let f={type:a,components:c,byteLength:l.byteLength*c,integer:l.integer,signed:l.signed,normalized:l.normalized};return i&&(f.webglOnly=!0),f}makeVertexFormat(e,t,i){let r=i?Xe.getNormalizedDataType(e):e;switch(r){case"unorm8":return t===1?"unorm8":t===3?"unorm8x3-webgl":`${r}x${t}`;case"snorm8":return t===1?"snorm8":t===3?"snorm8x3-webgl":`${r}x${t}`;case"uint8":case"sint8":if(t===3)throw new Error(`size: ${t}`);return t===1?r:`${r}x${t}`;case"uint16":return t===1?"uint16":t===3?"uint16x3-webgl":`${r}x${t}`;case"sint16":return t===1?"sint16":t===3?"sint16x3-webgl":`${r}x${t}`;case"unorm16":return t===1?"unorm16":t===3?"unorm16x3-webgl":`${r}x${t}`;case"snorm16":return t===1?"snorm16":t===3?"snorm16x3-webgl":`${r}x${t}`;case"float16":if(t===3)throw new Error(`size: ${t}`);return t===1?r:`${r}x${t}`;default:return t===1?r:`${r}x${t}`}}getVertexFormatFromAttribute(e,t,i){if(!t||t>4)throw new Error(`size ${t}`);let r=t,s=Xe.getDataType(e);return this.makeVertexFormat(s,r,i)}getCompatibleVertexFormat(e){let t;switch(e.primitiveType){case"f32":t="float32";break;case"i32":t="sint32";break;case"u32":t="uint32";break;case"f16":return e.components<=2?"float16x2":"float16x4"}return e.components===1?t:`${t}x${e.components}`}},Pe=new Cm});function Bu(n){let e=x0[n];if(!e)throw new Error(`Unsupported texture format ${n}`);return e}function v0(){return x0}var Qe,xe,Un,xR,ku,Tm,Ru,Lm,wR,Mm,Gi,Am,km,Iu,b0,ER,SR,x0,Rm=C(()=>{Qe="texture-compression-bc",xe="texture-compression-astc",Un="texture-compression-etc2",xR="texture-compression-etc1-webgl",ku="texture-compression-pvrtc-webgl",Tm="texture-compression-atc-webgl",Ru="float32-renderable-webgl",Lm="float16-renderable-webgl",wR="rgb9e5ufloat-renderable-webgl",Mm="snorm8-renderable-webgl",Gi="norm16-webgl",Am="norm16-renderable-webgl",km="snorm16-renderable-webgl",Iu="float32-filterable",b0="float16-filterable-webgl";ER={r8unorm:{webgpu:527},rg8unorm:{webgpu:527},"rgb8unorm-webgl":{},rgba8unorm:{webgpu:31},"rgba8unorm-srgb":{webgpu:15},r8snorm:{render:Mm,webgpu:837},rg8snorm:{render:Mm,webgpu:837},"rgb8snorm-webgl":{},rgba8snorm:{render:Mm,webgpu:341},r8uint:{webgpu:515},rg8uint:{webgpu:515},rgba8uint:{webgpu:19},r8sint:{webgpu:515},rg8sint:{webgpu:515},rgba8sint:{webgpu:19},bgra8unorm:{webgpu:15},"bgra8unorm-srgb":{webgpu:15360},r16unorm:{f:Gi,render:Am,webgpu:992},rg16unorm:{f:Gi,render:Am,webgpu:992},"rgb16unorm-webgl":{f:Gi,render:!1},rgba16unorm:{f:Gi,render:Am,webgpu:992},r16snorm:{f:Gi,render:km,webgpu:992},rg16snorm:{f:Gi,render:km,webgpu:992},"rgb16snorm-webgl":{f:Gi,render:!1},rgba16snorm:{f:Gi,render:km,webgpu:992},r16uint:{webgpu:515},rg16uint:{webgpu:515},rgba16uint:{webgpu:19},r16sint:{webgpu:515},rg16sint:{webgpu:515},rgba16sint:{webgpu:19},r16float:{render:Lm,filter:"float16-filterable-webgl",webgpu:527},rg16float:{render:Lm,filter:b0,webgpu:527},rgba16float:{render:Lm,filter:b0,webgpu:31},r32uint:{webgpu:19},rg32uint:{webgpu:16387},rgba32uint:{webgpu:19},r32sint:{webgpu:19},rg32sint:{webgpu:16387},rgba32sint:{webgpu:19},r32float:{render:Ru,filter:Iu,webgpu:19},rg32float:{render:!1,filter:Iu,webgpu:16387},"rgb32float-webgl":{render:Ru,filter:Iu},rgba32float:{render:Ru,filter:Iu,webgpu:19},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:wR,webgpu:5},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:Ru,webgpu:517},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:527},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:515},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8",webgpu:3},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16",webgpu:3},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32",webgpu:3},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32",webgpu:3},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0,webgpu:3},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0,f:"depth32float-stencil8",webgpu:3}},SR={"bc1-rgb-unorm-webgl":{f:Qe},"bc1-rgb-unorm-srgb-webgl":{f:Qe},"bc1-rgba-unorm":{f:Qe},"bc1-rgba-unorm-srgb":{f:Qe},"bc2-rgba-unorm":{f:Qe},"bc2-rgba-unorm-srgb":{f:Qe},"bc3-rgba-unorm":{f:Qe},"bc3-rgba-unorm-srgb":{f:Qe},"bc4-r-unorm":{f:Qe},"bc4-r-snorm":{f:Qe},"bc5-rg-unorm":{f:Qe},"bc5-rg-snorm":{f:Qe},"bc6h-rgb-ufloat":{f:Qe},"bc6h-rgb-float":{f:Qe},"bc7-rgba-unorm":{f:Qe},"bc7-rgba-unorm-srgb":{f:Qe},"etc2-rgb8unorm":{f:Un},"etc2-rgb8unorm-srgb":{f:Un},"etc2-rgb8a1unorm":{f:Un},"etc2-rgb8a1unorm-srgb":{f:Un},"etc2-rgba8unorm":{f:Un},"etc2-rgba8unorm-srgb":{f:Un},"eac-r11unorm":{f:Un},"eac-r11snorm":{f:Un},"eac-rg11unorm":{f:Un},"eac-rg11snorm":{f:Un},"astc-4x4-unorm":{f:xe},"astc-4x4-unorm-srgb":{f:xe},"astc-5x4-unorm":{f:xe},"astc-5x4-unorm-srgb":{f:xe},"astc-5x5-unorm":{f:xe},"astc-5x5-unorm-srgb":{f:xe},"astc-6x5-unorm":{f:xe},"astc-6x5-unorm-srgb":{f:xe},"astc-6x6-unorm":{f:xe},"astc-6x6-unorm-srgb":{f:xe},"astc-8x5-unorm":{f:xe},"astc-8x5-unorm-srgb":{f:xe},"astc-8x6-unorm":{f:xe},"astc-8x6-unorm-srgb":{f:xe},"astc-8x8-unorm":{f:xe},"astc-8x8-unorm-srgb":{f:xe},"astc-10x5-unorm":{f:xe},"astc-10x5-unorm-srgb":{f:xe},"astc-10x6-unorm":{f:xe},"astc-10x6-unorm-srgb":{f:xe},"astc-10x8-unorm":{f:xe},"astc-10x8-unorm-srgb":{f:xe},"astc-10x10-unorm":{f:xe},"astc-10x10-unorm-srgb":{f:xe},"astc-12x10-unorm":{f:xe},"astc-12x10-unorm-srgb":{f:xe},"astc-12x12-unorm":{f:xe},"astc-12x12-unorm-srgb":{f:xe},"pvrtc-rgb4unorm-webgl":{f:ku},"pvrtc-rgba4unorm-webgl":{f:ku},"pvrtc-rgb2unorm-webgl":{f:ku},"pvrtc-rgba2unorm-webgl":{f:ku},"etc1-rbg-unorm-webgl":{f:xR},"atc-rgb-unorm-webgl":{f:Tm},"atc-rgba-unorm-webgl":{f:Tm},"atc-rgbai-unorm-webgl":{f:Tm}},x0={...ER,...SR}});function AR({format:n,width:e,height:t,depth:i,byteAlignment:r}){let s=ft.getInfo(n),{bytesPerPixel:o,bytesPerBlock:a=o,blockWidth:c=1,blockHeight:l=1,compressed:u=!1}=s,f=u?Math.ceil(e/c):e,d=u?Math.ceil(t/l):t,h=f*a,p=Math.ceil(h/r)*r,m=d,g=p*m*i;return{bytesPerPixel:o,bytesPerRow:p,rowsPerImage:m,depthOrArrayLayers:i,bytesPerImage:p*m,byteLength:g}}function kR(n){let e=Bu(n),t={format:n,create:e.f??!0,render:e.render??!0,filter:e.filter??!0,blend:e.blend??!0,store:e.store??!0},i=w0(n),r=n.startsWith("depth")||n.startsWith("stencil"),s=i?.signed,o=i?.integer,a=i?.webgl,c=!!i?.compressed;return t.render&&=!r&&!c,t.filter&&=!r&&!s&&!o&&!a,t}function w0(n){let e=RR(n);if(ft.isCompressed(n)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0,e.bytesPerBlock=BR(n);let i=IR(n);i&&(e.blockWidth=i.blockWidth,e.blockHeight=i.blockHeight)}let t=e.packed?null:PR.exec(n);if(t){let[,i,r,s,o,a]=t,c=`${s}${r}`,l=Xe.getDataTypeInfo(c),u=l.byteLength*8,f=i?.length??1,d=[u,f>=2?u:0,f>=3?u:0,f>=4?u:0];e={format:n,attachment:e.attachment,dataType:l.signedType,components:f,channels:i,integer:l.integer,signed:l.signed,normalized:l.normalized,bitsPerChannel:d,bytesPerPixel:l.byteLength*f,packed:e.packed,srgb:e.srgb},a==="-webgl"&&(e.webgl=!0),o==="-srgb"&&(e.srgb=!0)}return n.endsWith("-webgl")&&(e.webgl=!0),n.endsWith("-srgb")&&(e.srgb=!0),e}function RR(n){let e={...Bu(n)},t=e.bytesPerPixel||1,i=e.bitsPerChannel||[8,8,8,8];return delete e.bitsPerChannel,delete e.bytesPerPixel,delete e.f,delete e.render,delete e.filter,delete e.blend,delete e.store,delete e.webgpu,{...e,format:n,attachment:e.attachment||"color",channels:e.channels||"r",components:e.components||e.channels?.length||1,bytesPerPixel:t,bitsPerChannel:i,dataType:e.dataType||"uint8",srgb:e.srgb??!1,packed:e.packed??!1,webgl:e.webgl??!1,integer:e.integer??!1,signed:e.signed??!1,normalized:e.normalized??!1,compressed:e.compressed??!1}}function IR(n){let t=/.*-(\d+)x(\d+)-.*/.exec(n);if(t){let[,i,r]=t;return{blockWidth:Number(i),blockHeight:Number(r)}}return n.startsWith("bc")||n.startsWith("etc1")||n.startsWith("etc2")||n.startsWith("eac")||n.startsWith("atc")?{blockWidth:4,blockHeight:4}:n.startsWith("pvrtc-rgb4")||n.startsWith("pvrtc-rgba4")?{blockWidth:4,blockHeight:4}:n.startsWith("pvrtc-rgb2")||n.startsWith("pvrtc-rgba2")?{blockWidth:8,blockHeight:4}:null}function BR(n){return n.startsWith("bc1")||n.startsWith("bc4")||n.startsWith("etc1")||n.startsWith("etc2-rgb8")||n.startsWith("etc2-rgb8a1")||n.startsWith("eac-r11")||n==="atc-rgb-unorm-webgl"?8:n.startsWith("bc2")||n.startsWith("bc3")||n.startsWith("bc5")||n.startsWith("bc6h")||n.startsWith("bc7")||n.startsWith("etc2-rgba8")||n.startsWith("eac-rg11")||n.startsWith("astc")||n==="atc-rgba-unorm-webgl"||n==="atc-rgbai-unorm-webgl"?16:n.startsWith("pvrtc")?8:16}var PR,CR,TR,LR,MR,Im,ft,Ou=C(()=>{Au();Rm();PR=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,CR=["rgb","rgba","bgra"],TR=["depth","stencil"],LR=5,MR=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],Im=class{isColor(e){return CR.some(t=>e.startsWith(t))}isDepthStencil(e){return TR.some(t=>e.startsWith(t))}isCompressed(e){return MR.some(t=>e.startsWith(t))}getInfo(e){return w0(e)}getCapabilities(e){return kR(e)}getWebGPUCapabilities(e){let t=Bu(e);return t.webgpu!==void 0?t.webgpu:this.isCompressed(e)&&!e.endsWith("-webgl")?LR:0}computeMemoryLayout(e){return AR(e)}},ft=new Im});function E0(n){return typeof ImageData<"u"&&n instanceof ImageData||typeof ImageBitmap<"u"&&n instanceof ImageBitmap||typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement||typeof VideoFrame<"u"&&n instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas}function S0(n){if(typeof ImageData<"u"&&n instanceof ImageData||typeof ImageBitmap<"u"&&n instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas)return{width:n.width,height:n.height};if(typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement)return{width:n.naturalWidth,height:n.naturalHeight};if(typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement)return{width:n.videoWidth,height:n.videoHeight};if(typeof VideoFrame<"u"&&n instanceof VideoFrame)return{width:n.displayWidth,height:n.displayHeight};throw new Error("Unknown image type")}var P0=C(()=>{});function OR(n,e){let t=Bm(n),i=e.map(Bm).filter(r=>r!==void 0);return[t,...i].filter(r=>r!==void 0)}function Bm(n){if(n!==void 0){if(n===null||typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n;if(n instanceof Error)return n.message;if(Array.isArray(n))return n.map(Bm);if(typeof n=="object"){if(DR(n)){let e=String(n);if(e!=="[object Object]")return e}return NR(n)?FR(n):n.constructor?.name||"Object"}return String(n)}}function DR(n){return"toString"in n&&typeof n.toString=="function"&&n.toString!==Object.prototype.toString}function NR(n){return"message"in n&&"type"in n}function FR(n){let e=typeof n.type=="string"?n.type:"message",t=typeof n.message=="string"?n.message:"",i=typeof n.lineNum=="number"?n.lineNum:null,r=typeof n.linePos=="number"?n.linePos:null,s=i!==null&&r!==null?` @ ${i}:${r}`:i!==null?` @ ${i}`:"";return`${e}${s}: ${t}`.trim()}function Om(){if(typeof HTMLCanvasElement>"u")return!1;let n=HTMLCanvasElement.prototype;return"layoutSubtree"in n&&typeof n.requestPaint=="function"}var Ca,Ta,bi,C0=C(()=>{vm();ut();Ws();Tu();Pa();Ou();P0();Rm();ym();Ca=class{};Ta=class{features;disabledFeatures;constructor(e=[],t){this.features=new Set(e),this.disabledFeatures=t||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures?.[e]&&this.features.has(e)}};bi=class n{static defaultProps={...Su};get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}toJSON(){return this.toString()}id;props;userData={};statsManager=Pu;_factories={};timestamp=0;_reused=!1;_moduleData={};wgslLanguageFeatures=new Set;_textureCaps={};_debugGPUTimeQuery=null;constructor(e){this.props={...n.defaultProps,...e},this.id=this.props.id||zn(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(e){return Pe.getVertexFormatInfo(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return ft.getInfo(e)}getTextureFormatCapabilities(e){let t=this._textureCaps[e];if(!t){let i=this._getDeviceTextureFormatCapabilities(e);t=this._getDeviceSpecificTextureFormatCapabilities(i),this._textureCaps[e]=t}return t}getMipLevelCount(e,t,i=1){let r=Math.max(e,t,i);return 1+Math.floor(Math.log2(r))}isExternalImage(e){return E0(e)}getExternalImageSize(e){return S0(e)}isTextureFormatSupported(e){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return ft.isCompressed(e)}getSupportedCompressedTextureFormats(){let e=[];for(let t of Object.keys(v0()))this.isTextureFormatCompressed(t)&&this.isTextureFormatSupported(t)&&e.push(t);return e}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){this.commandEncoder?.popDebugGroup()}insertDebugMarker(e){this.commandEncoder?.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,t,...i){if(!this.props.onError(e,t)){let s=OR(t,i);return N.error(this.type==="webgl"?"%cWebGL":"%cWebGPU","color: white; background: red; padding: 2px 6px; border-radius: 3px;",e.message,...s)}return()=>{}}debug(){if(this.props.debug)debugger;else{let e=`'Type luma.log.set({debug: true}) in console to enable debug breakpoints', +or create a device with the 'debug: true' prop.`;N.once(0,e)()}}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}createFence(){throw new Error("createFence() not implemented")}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}writeBufferViaCommandEncoder(e,t,i,r=0){throw new Error("writeBufferViaCommandEncoder() not implemented")}generateMipmapsWebGPU(e){throw new Error("not implemented")}_createSharedRenderPipelineWebGL(e){throw new Error("_createSharedRenderPipelineWebGL() not implemented")}_createBindGroupLayoutWebGPU(e,t){throw new Error("_createBindGroupLayoutWebGPU() not implemented")}_createBindGroupWebGPU(e,t,i,r,s){throw new Error("_createBindGroupWebGPU() not implemented")}_supportsDebugGPUTime(){return this.features.has("timestamp-query")&&!!(this.props.debug||this.props.debugGPUTime)}_enableDebugGPUTime(e=256){if(!this._supportsDebugGPUTime())return null;if(this._debugGPUTimeQuery)return this._debugGPUTimeQuery;try{this._debugGPUTimeQuery=this.createQuerySet({type:"timestamp",count:e}),this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id,timeProfilingQuerySet:this._debugGPUTimeQuery})}catch{this._debugGPUTimeQuery=null}return this._debugGPUTimeQuery}_disableDebugGPUTime(){this._debugGPUTimeQuery&&(this.commandEncoder.getTimeProfilingQuerySet()===this._debugGPUTimeQuery&&(this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id})),this._debugGPUTimeQuery.destroy(),this._debugGPUTimeQuery=null)}_isDebugGPUTimeEnabled(){return this._debugGPUTimeQuery!==null}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}getModuleData(e){return this._moduleData[e]||={},this._moduleData[e]}static _getCanvasContextProps(e){return e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){let t=ft.getCapabilities(e),i=s=>(typeof s=="string"?this.features.has(s):s)??!0,r=i(t.create);return{format:e,create:r,render:r&&i(t.render),filter:r&&i(t.filter),blend:r&&i(t.blend),store:r&&i(t.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let t={...e};if((e.usage||0)&ie.INDEX&&(e.indexType||(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array?t.indexType="uint16":e.data instanceof Uint8Array&&(t.data=new Uint16Array(e.data),t.indexType="uint16")),!t.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return t}}});var Du,T0=C(()=>{Du=class{props;_resizeObserver;_intersectionObserver;_observeDevicePixelRatioTimeout=null;_observeDevicePixelRatioMediaQuery=null;_handleDevicePixelRatioChange=()=>this._refreshDevicePixelRatio();_trackPositionInterval=null;_started=!1;get started(){return this._started}constructor(e){this.props=e}start(){if(this._started||!this.props.canvas)return;this._started=!0,this._intersectionObserver||=new IntersectionObserver(t=>this.props.onIntersection(t)),this._resizeObserver||=new ResizeObserver(t=>this.props.onResize(t)),this._intersectionObserver.observe(this.props.canvas);let e=this.props.resizeObserverBox;try{this._resizeObserver.observe(this.props.canvas,{box:e})}catch{this._resizeObserver.observe(this.props.canvas,{box:"content-box"})}this._observeDevicePixelRatioTimeout=setTimeout(()=>this._refreshDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}stop(){this._started&&(this._started=!1,this._observeDevicePixelRatioTimeout&&(clearTimeout(this._observeDevicePixelRatioTimeout),this._observeDevicePixelRatioTimeout=null),this._observeDevicePixelRatioMediaQuery&&(this._observeDevicePixelRatioMediaQuery.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=null),this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null),this._resizeObserver?.disconnect(),this._intersectionObserver?.disconnect())}_refreshDevicePixelRatio(){this._started&&(this.props.onDevicePixelRatioChange(),this._observeDevicePixelRatioMediaQuery?.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._observeDevicePixelRatioMediaQuery.addEventListener("change",this._handleDevicePixelRatioChange,{once:!0}))}_trackPosition(e=100){this._trackPositionInterval||(this._trackPositionInterval=setInterval(()=>{this._started?this.props.onPositionChange():this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null)},e))}}});function L0(){let n,e;return{promise:new Promise((i,r)=>{n=i,e=r}),resolve:n,reject:e}}var M0=C(()=>{});function Vi(n,e){if(!n){let t=new Error(e??"luma.gl assertion failed.");throw Error.captureStackTrace?.(t,Vi),t}}function Wi(n,e){return Vi(n,e),n}var Dm=C(()=>{});function zR(n){if(typeof n=="string"){let e=document.getElementById(n);if(!e)throw new Error(`${n} is not an HTML element`);return e}return n||document.body}function UR(n){let e=document.getElementById(n);if(!ji.isHTMLCanvas(e))throw new Error("Object is not a canvas element");return e}function $R(n){let{width:e,height:t}=n,i=document.createElement("canvas");i.id=zn("lumagl-auto-created-canvas"),i.width=e||1,i.height=t||1,i.style.width=Number.isFinite(e)?`${e}px`:"100%",i.style.height=Number.isFinite(t)?`${t}px`:"100%",n?.visible||(i.style.visibility="hidden");let r=zR(n?.container||null);return r.insertBefore(i,r.firstChild),i}function GR(n,e,t,i,r){let s=n,o=A0(s[0],e,t),a=k0(s[1],e,i,r),c=A0(s[0]+1,e,t),l=c===t-1?c:c-1;c=k0(s[1]+1,e,i,r);let u;return r?(c=c===0?c:c+1,u=a,a=c):u=c===i-1?c:c-1,{x:o,y:a,width:Math.max(l-o+1,1),height:Math.max(u-a+1,1)}}function A0(n,e,t){return Math.min(Math.round(n*e),t-1)}function k0(n,e,t,i){return i?Math.max(0,t-1-Math.round(n*e)):Math.min(Math.round(n*e),t-1)}var ji,Nm=C(()=>{vr();T0();Ws();M0();Dm();ji=class n{static isHTMLCanvas(e){return typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}static defaultProps={id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,pixelSizeSource:"exact",autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",colorFormat:void 0,toneMapping:"standard",trackPosition:!1};id;props;canvas;htmlCanvas;offscreenCanvas;type;initialized;isInitialized=!1;isVisible=!0;cssWidth;cssHeight;devicePixelRatio;devicePixelWidth;devicePixelHeight;drawingBufferWidth;drawingBufferHeight;_initializedResolvers=L0();_canvasObserver;_position=[0,0];destroyed=!1;_needsDrawingBufferResize=!0;_configuredDrawingBufferSize=[0,0];toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(e){this.props={...n.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,Tt()?e.canvas?typeof e.canvas=="string"?this.canvas=UR(e.canvas):this.canvas=e.canvas:this.canvas=$R(e):this.canvas={width:e.width||1,height:e.height||1},n.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):n.isOffscreenCanvas(this.canvas)?(this.id=e.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=e.id||"node-canvas-context",this.type="node"),this.cssWidth=this.htmlCanvas?.clientWidth||this.canvas.width,this.cssHeight=this.htmlCanvas?.clientHeight||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this._configuredDrawingBufferSize=[this.canvas.width,this.canvas.height],this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],this._canvasObserver=new Du({canvas:this.htmlCanvas,trackPosition:this.props.trackPosition,resizeObserverBox:this.props.pixelSizeSource==="css-dpr"?"content-box":"device-pixel-content-box",onResize:t=>this._handleResize(t),onIntersection:t=>this._handleIntersection(t),onDevicePixelRatioChange:()=>this._observeDevicePixelRatio(),onPositionChange:()=>this.updatePosition()})}destroy(){this.destroyed||(this.destroyed=!0,this._stopObservers(),this.device=null)}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCurrentFramebuffer(e){return this._resizeDrawingBufferIfNeeded(),this._getCurrentFramebuffer(e)}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){let e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,t){e=Math.floor(e),t=Math.floor(t),!(this.drawingBufferWidth===e&&this.drawingBufferHeight===t)&&(this.drawingBufferWidth=e,this.drawingBufferHeight=t,this._needsDrawingBufferResize=!0)}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(e,t=!0){let i=this.cssToDeviceRatio(),[r,s]=this.getDrawingBufferSize();return GR(e,i,r,s,t)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){let[e,t]=this.getDrawingBufferSize();return e>0&&t>0?e/t:1}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),[t]=this.getCSSSize();return t?e/t:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}_startObservers(){this.destroyed||this._canvasObserver.start()}_stopObservers(){this._canvasObserver.stop()}_handleIntersection(e){if(this.destroyed)return;let t=e.find(r=>r.target===this.canvas);if(!t)return;let i=t.isIntersecting;this.isVisible!==i&&(this.isVisible=i,this.device.props.onVisibilityChange(this))}_handleResize(e){if(this.destroyed)return;let t=e.find(s=>s.target===this.canvas);if(!t)return;let i=Wi(t.contentBoxSize?.[0]);this.cssWidth=i.inlineSize,this.cssHeight=i.blockSize;let r=this.getDevicePixelSize();this._setDevicePixelSize(this._getDevicePixelSizeFromResizeEntry(t)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:r})}_updateDrawingBufferSize(){if(this.props.autoResize)if(typeof this.props.useDevicePixels=="number"){let e=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*e,this.cssHeight*e)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_getDevicePixelSizeFromResizeEntry(e){let t=Wi(e.contentBoxSize?.[0]);return this.props.pixelSizeSource==="css-dpr"?this._getDevicePixelSizeFromCSSSize(t.inlineSize,t.blockSize):{devicePixelWidth:e.devicePixelContentBoxSize?.[0]?.inlineSize||t.inlineSize*devicePixelRatio,devicePixelHeight:e.devicePixelContentBoxSize?.[0]?.blockSize||t.blockSize*devicePixelRatio}}_getDevicePixelSizeFromCSSSize(e,t){let i=this.getDevicePixelRatio();return{devicePixelWidth:Math.floor(e*i),devicePixelHeight:Math.floor(t*i)}}_setDevicePixelSize({devicePixelWidth:e,devicePixelHeight:t}){let[i,r]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(e,i)),this.devicePixelHeight=Math.max(1,Math.min(t,r))}_resizeDrawingBufferIfNeeded(){if(this._needsDrawingBufferResize){this._needsDrawingBufferResize=!1,(this.drawingBufferWidth!==this.canvas.width||this.drawingBufferHeight!==this.canvas.height)&&(this.canvas.width=this.drawingBufferWidth,this.canvas.height=this.drawingBufferHeight);let[t,i]=this._configuredDrawingBufferSize;(this.drawingBufferWidth!==t||this.drawingBufferHeight!==i)&&(this._configureDevice(),this._configuredDrawingBufferSize=[this.drawingBufferWidth,this.drawingBufferHeight])}}_observeDevicePixelRatio(){if(this.destroyed||!this._canvasObserver.started)return;let e=this.devicePixelRatio;if(this.devicePixelRatio=window.devicePixelRatio,this.props.pixelSizeSource==="css-dpr"){let t=this.getDevicePixelSize();this._setDevicePixelSize(this._getDevicePixelSizeFromCSSSize(this.cssWidth,this.cssHeight)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:t})}this.updatePosition(),this.device.props.onDevicePixelRatioChange?.(this,{oldRatio:e})}updatePosition(){if(this.destroyed)return;let e=this.htmlCanvas?.getBoundingClientRect();if(e){let t=[e.left,e.top];if(this._position??=t,t[0]!==this._position[0]||t[1]!==this._position[1]){let r=this._position;this._position=t,this.device.props.onPositionChange?.(this,{oldPosition:r})}}}}});var La,R0=C(()=>{Nm();La=class extends ji{static defaultProps=ji.defaultProps}});var Ma,I0=C(()=>{Nm();Ma=class extends ji{}});var Mr,Fm=C(()=>{He();Mr=class n extends te{static defaultProps={...te.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1};get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){t=n.normalizeProps(e,t),super(e,t,n.defaultProps)}static normalizeProps(e,t){return t}}});var VR,me,zm=C(()=>{He();Fm();ut();Ou();VR={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},me=class n extends te{static SAMPLE=4;static STORAGE=8;static RENDER=16;static COPY_SRC=1;static COPY_DST=2;static TEXTURE=4;static RENDER_ATTACHMENT=16;dimension;baseDimension;format;width;height;depth;mipLevels;samples;byteAlignment;ready=Promise.resolve(this);isReady=!0;updateTimestamp;get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(e,t,i){if(t=n.normalizeProps(e,t),super(e,t,n.defaultProps),this.dimension=this.props.dimension,this.baseDimension=VR[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.samples=this.props.samples||1,this.dimension==="cube"&&(this.depth=6),this.props.width===void 0||this.props.height===void 0)if(e.isExternalImage(t.data)){let r=e.getExternalImageSize(t.data);this.width=r?.width||1,this.height=r?.height||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&N.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=i?.byteAlignment||1,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createTexture({...this.props,...e})}setSampler(e){this.sampler=e instanceof Mr?e:this.device.createSampler(e)}copyImageData(e){let{data:t,depth:i,...r}=e;this.writeData(t,{...r,depthOrArrayLayers:r.depthOrArrayLayers??i})}computeMemoryLayout(e={}){let t=this._normalizeTextureReadOptions(e),{width:i=this.width,height:r=this.height,depthOrArrayLayers:s=this.depth}=t,{format:o,byteAlignment:a}=this;return ft.computeMemoryLayout({format:o,width:i,height:r,depth:s,byteAlignment:a})}readBuffer(e,t){throw new Error("readBuffer not implemented")}readDataAsync(e){throw new Error("readBuffer not implemented")}writeBuffer(e,t){throw new Error("readBuffer not implemented")}writeData(e,t){throw new Error("readBuffer not implemented")}readDataSyncWebGL(e){throw new Error("readDataSyncWebGL not available")}generateMipmapsWebGL(){throw new Error("generateMipmapsWebGL not available")}static normalizeProps(e,t){let i={...t},{width:r,height:s}=i;return typeof r=="number"&&(i.width=Math.max(1,Math.ceil(r))),typeof s=="number"&&(i.height=Math.max(1,Math.ceil(s))),i}_initializeData(e){this.device.isExternalImage(e)?this.copyExternalImage({image:e,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):e&&this.copyImageData({data:e,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(e){let{data:t,depth:i,...r}=e,s=this._normalizeTextureWriteOptions({...r,depthOrArrayLayers:r.depthOrArrayLayers??i});return{data:t,depth:s.depthOrArrayLayers,...s}}_normalizeCopyExternalImageOptions(e){let t=n._omitUndefined(e),i=t.mipLevel??0,r=this._getMipLevelSize(i),s=this.device.getExternalImageSize(e.image),o={...n.defaultCopyExternalImageOptions,...r,...s,...t};return o.width=Math.min(o.width,r.width-o.x),o.height=Math.min(o.height,r.height-o.y),o.depth=Math.min(o.depth,r.depthOrArrayLayers-o.z),o}_normalizeCopyElementImageOptions(e){let t=n._omitUndefined(e),i=t.mipLevel??0,r=this._getMipLevelSize(i),s={...n.defaultCopyElementImageOptions,...r,...t};return s.width=Math.min(s.width,r.width-s.x),s.height=Math.min(s.height,r.height-s.y),s.depth=Math.min(s.depth,r.depthOrArrayLayers-s.z),s}_normalizeTextureReadOptions(e){let t=n._omitUndefined(e),i=t.mipLevel??0,r=this._getMipLevelSize(i),s={...n.defaultTextureReadOptions,...r,...t};return s.width=Math.min(s.width,r.width-s.x),s.height=Math.min(s.height,r.height-s.y),s.depthOrArrayLayers=Math.min(s.depthOrArrayLayers,r.depthOrArrayLayers-s.z),s}_getSupportedColorReadOptions(e){let t=this._normalizeTextureReadOptions(e),i=ft.getInfo(this.format);switch(this._validateColorReadAspect(t),this._validateColorReadFormat(i),this.dimension){case"2d":case"cube":case"cube-array":case"2d-array":case"3d":return t;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}}_validateColorReadAspect(e){if(e.aspect!=="all")throw new Error(`${this} color readback only supports aspect 'all'`)}_validateColorReadFormat(e){if(e.compressed)throw new Error(`${this} color readback does not support compressed formats (${this.format})`);switch(e.attachment){case"color":return;case"depth":throw new Error(`${this} color readback does not support depth formats (${this.format})`);case"stencil":throw new Error(`${this} color readback does not support stencil formats (${this.format})`);case"depth-stencil":throw new Error(`${this} color readback does not support depth-stencil formats (${this.format})`);default:throw new Error(`${this} color readback does not support format ${this.format}`)}}_normalizeTextureWriteOptions(e){let t=n._omitUndefined(e),i=t.mipLevel??0,r=this._getMipLevelSize(i),s={...n.defaultTextureWriteOptions,...r,...t};s.width=Math.min(s.width,r.width-s.x),s.height=Math.min(s.height,r.height-s.y),s.depthOrArrayLayers=Math.min(s.depthOrArrayLayers,r.depthOrArrayLayers-s.z);let o=ft.computeMemoryLayout({format:this.format,width:s.width,height:s.height,depth:s.depthOrArrayLayers,byteAlignment:this.byteAlignment}),a=o.bytesPerPixel*s.width;if(s.bytesPerRow=t.bytesPerRow??o.bytesPerRow,s.rowsPerImage=t.rowsPerImage??s.height,s.bytesPerRow>e),i=this.baseDimension==="1d"?1:Math.max(1,this.height>>e),r=this.dimension==="3d"?Math.max(1,this.depth>>e):this.depth;return{width:t,height:i,depthOrArrayLayers:r}}getAllocatedByteLength(){let e=0;for(let t=0;tt!==void 0))}static defaultProps={...te.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:n.SAMPLE|n.RENDER|n.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0};static defaultCopyDataOptions={data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,width:void 0,height:void 0,depthOrArrayLayers:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all"};static defaultCopyExternalImageOptions={image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultCopyElementImageOptions={element:void 0,width:void 0,height:void 0,sourceX:0,sourceY:0,sourceWidth:void 0,sourceHeight:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultTextureReadOptions={x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"};static defaultTextureWriteOptions={byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"}}});var Ar,B0=C(()=>{He();Ar=class n extends te{get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,n.defaultProps)}static defaultProps={...te.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0}}});var Aa,O0=C(()=>{He();Aa=class n extends te{width;height;updateTimestamp;get[Symbol.toStringTag](){return"ExternalTexture"}constructor(e,t){super(e,t,n.defaultProps);let i=this.props.source?e.getExternalImageSize(this.props.source):null;this.width=this.props.width||i?.width||0,this.height=this.props.height||i?.height||0,this.updateTimestamp=e.incrementTimestamp()}static defaultProps={...te.defaultProps,source:void 0,width:0,height:0,colorSpace:"srgb",sampler:{}}}});function D0(n,e,t){let i="",r=e.split(/\r?\n/),s=n.slice().sort((o,a)=>o.lineNum-a.lineNum);switch(t?.showSourceCode||"no"){case"all":let o=0;for(let a=1;a<=r.length;a++){let c=r[a-1],l=s[o];for(c&&l&&(i+=N0(c,a,t));s.length>o&&l.lineNum===a;){let u=s[o++];u&&(i+=Um(u,r,u.lineNum,{...t,inlineSource:!1}))}}for(;s.length>o;){let a=s[o++];a&&(i+=Um(a,[],0,{...t,inlineSource:!1}))}return i;case"issues":case"no":for(let a of n)i+=Um(a,r,a.lineNum,{inlineSource:t?.showSourceCode!=="no"});return i}}function Um(n,e,t,i){if(i?.inlineSource){let s=WR(e,t),o=n.linePos>0?`${" ".repeat(n.linePos+5)}^^^ `:"";return` ${s}${o}${n.type.toUpperCase()}: ${n.message} -`}let r=n.type==="error"?"red":"orange";return i?.html?`
${n.type.toUpperCase()}: ${n.message}
`:`${n.type.toUpperCase()}: ${n.message}`}function $R(n,e,t){let i="";for(let r=e-2;r<=e;r++){let s=n[r-1];s!==void 0&&(i+=D0(s,e,t))}return i}function D0(n,e,t){let i=t?.html?VR(n):n;return`${GR(String(e),4)}: ${i}${t?.html?"
":` -`}`}function GR(n,e){let t="";for(let i=n.length;i",">").replaceAll('"',""").replaceAll("'","'")}var N0=C(()=>{});function WR(n){return jR(n.source)||n.id||On(`unnamed ${n.stage}-shader`)}function jR(n,e="unnamed"){return/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(n)?.[1]??e}var kr,Um=C(()=>{He();ut();Ws();N0();kr=class n extends te{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,t){t={...t,debugShaders:t.debugShaders||e.props.debugShaders||"errors"},super(e,{id:WR(t),...t},n.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(){let e=this.props.debugShaders;switch(e){case"never":return;case"errors":if(this.compilationStatus==="success")return;break;case"warnings":case"always":break}try{let t=await this.getCompilationInfo();if(e==="warnings"&&t?.length===0)return;this._displayShaderLog(t,this.id)}catch(t){z.warn(`Shader ${this.id}: failed to fetch compilation info during debug logging`,t)()}}_displayShaderLog(e,t){if(typeof document>"u"||!document?.createElement)return;let i=t,r=`${this.stage} shader "${i}"`,s=O0(e,this.source,{showSourceCode:"all",html:!0}),o=this.getTranslatedSource(),a=document.createElement("div");a.innerHTML=`

Compilation error in ${r}

+`}let r=n.type==="error"?"red":"orange";return i?.html?`
${n.type.toUpperCase()}: ${n.message}
`:`${n.type.toUpperCase()}: ${n.message}`}function WR(n,e,t){let i="";for(let r=e-2;r<=e;r++){let s=n[r-1];s!==void 0&&(i+=N0(s,e,t))}return i}function N0(n,e,t){let i=t?.html?HR(n):n;return`${jR(String(e),4)}: ${i}${t?.html?"
":` +`}`}function jR(n,e){let t="";for(let i=n.length;i",">").replaceAll('"',""").replaceAll("'","'")}var F0=C(()=>{});function YR(n){return qR(n.source)||n.id||zn(`unnamed ${n.stage}-shader`)}function qR(n,e="unnamed"){return/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(n)?.[1]??e}var kr,$m=C(()=>{He();ut();Ws();F0();kr=class n extends te{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,t){t={...t,debugShaders:t.debugShaders||e.props.debugShaders||"errors"},super(e,{id:YR(t),...t},n.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(){let e=this.props.debugShaders;switch(e){case"never":return;case"errors":if(this.compilationStatus==="success")return;break;case"warnings":case"always":break}try{let t=await this.getCompilationInfo();if(e==="warnings"&&t?.length===0)return;this._displayShaderLog(t,this.id)}catch(t){N.warn(`Shader ${this.id}: failed to fetch compilation info during debug logging`,t)()}}_displayShaderLog(e,t){if(typeof document>"u"||!document?.createElement)return;let i=t,r=`${this.stage} shader "${i}"`,s=D0(e,this.source,{showSourceCode:"all",html:!0}),o=this.getTranslatedSource(),a=document.createElement("div");a.innerHTML=`

Compilation error in ${r}


-
${s}
`,o&&(a.innerHTML+=`

Translated Source



${o}
`),a.style.top="0",a.style.left="0",a.style.background="white",a.style.position="fixed",a.style.zIndex="9999",a.style.maxWidth="100vw",a.style.maxHeight="100vh",a.style.overflowY="auto",document.body.appendChild(a),a.querySelector(".luma-compiler-log-error")?.scrollIntoView(),a.querySelector("button#close").onclick=()=>{a.remove()},a.querySelector("button#copy").onclick=()=>{navigator.clipboard.writeText(this.source)}}static defaultProps={...te.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0}}});var Rr,F0=C(()=>{He();Fm();ut();Rr=class n extends te{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(e,t={}){super(e,t,n.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(e){let t=this.colorAttachments.map(r=>r.texture.clone(e)),i=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,...e,colorAttachments:t,depthStencilAttachment:i})}resize(e){let t=!e;if(e){let[i,r]=Array.isArray(e)?e:[e.width,e.height];t=t||r!==this.height||i!==this.width,this.width=i,this.height=r}t&&(z.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map((t,i)=>{if(typeof t=="string"){let r=this.createColorTexture(t,i);return this.attachResource(r),r.view}return t instanceof pe?t.view:t});let e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){let t=this.createDepthStencilTexture(e);this.attachResource(t),this.depthStencilAttachment=t.view}else e instanceof pe?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,t){return this.device.createTexture({id:`${this.id}-color-attachment-${t}`,usage:pe.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(e){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:pe.RENDER_ATTACHMENT|pe.SAMPLE,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){if(this.colorAttachments.forEach((i,r)=>{let s=i.texture.clone({width:e,height:t});this.destroyAttachedResource(i),this.colorAttachments[r]=s.view,this.attachResource(s.view)}),this.depthStencilAttachment){let i=this.depthStencilAttachment.texture.clone({width:e,height:t});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=i.view,this.attachResource(i)}this.updateAttachments()}static defaultProps={...te.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null}}});var Ht,$m=C(()=>{He();Ht=class n extends te{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";sharedRenderPipeline=null;get isPending(){return this.linkStatus==="pending"||this.vs.compilationStatus==="pending"||this.fs?.compilationStatus==="pending"}get isErrored(){return this.linkStatus==="error"||this.vs.compilationStatus==="error"||this.fs?.compilationStatus==="error"}constructor(e,t){super(e,t,n.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[],this.sharedRenderPipeline=this.props._sharedRenderPipeline||null}static defaultProps={...te.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},varyings:void 0,bufferMode:void 0,disableWarnings:!1,_sharedRenderPipeline:void 0,_uniformBlockLayouts:[],bindings:void 0,bindGroups:void 0}}});var Aa,z0=C(()=>{He();Aa=class extends te{get[Symbol.toStringTag](){return"SharedRenderPipeline"}constructor(e,t){super(e,t,{...te.defaultProps,handle:void 0,vs:void 0,fs:void 0,varyings:void 0,bufferMode:void 0})}}});var Wi,Gm=C(()=>{He();Wi=class n extends te{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(e,t){super(e,t,n.defaultProps),this.shaderLayout=t.shaderLayout}static defaultProps={...te.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0}}});var Ir,U0=C(()=>{Gm();$m();ut();Ws();Ir=class n{static defaultProps={...Ht.defaultProps};static getDefaultPipelineFactory(e){let t=e.getModuleData("@luma.gl/core");return t.defaultPipelineFactory||=new n(e),t.defaultPipelineFactory}device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};_sharedRenderPipelineCache={};get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}constructor(e){this.device=e}createRenderPipeline(e){if(!this.device.props._cachePipelines)return this.device.createRenderPipeline(e);let t={...Ht.defaultProps,...e},i=this._renderPipelineCache,r=this._hashRenderPipeline(t),s=i[r]?.resource;if(s)i[r].useCount++,this.device.props.debugFactories&&z.log(3,`${this}: ${i[r].resource} reused, count=${i[r].useCount}, (id=${e.id})`)();else{let o=this.device.type==="webgl"&&this.device.props._sharePipelines?this.createSharedRenderPipeline(t):void 0;s=this.device.createRenderPipeline({...t,id:t.id?`${t.id}-cached`:On("unnamed-cached"),_sharedRenderPipeline:o}),s.hash=r,i[r]={resource:s,useCount:1},this.device.props.debugFactories&&z.log(3,`${this}: ${s} created, count=${i[r].useCount}`)()}return s}createComputePipeline(e){if(!this.device.props._cachePipelines)return this.device.createComputePipeline(e);let t={...Wi.defaultProps,...e},i=this._computePipelineCache,r=this._hashComputePipeline(t),s=i[r]?.resource;return s?(i[r].useCount++,this.device.props.debugFactories&&z.log(3,`${this}: ${i[r].resource} reused, count=${i[r].useCount}, (id=${e.id})`)()):(s=this.device.createComputePipeline({...t,id:t.id?`${t.id}-cached`:void 0}),s.hash=r,i[r]={resource:s,useCount:1},this.device.props.debugFactories&&z.log(3,`${this}: ${s} created, count=${i[r].useCount}`)()),s}release(e){if(!this.device.props._cachePipelines){e.destroy();return}let t=this._getCache(e),i=e.hash;t[i].useCount--,t[i].useCount===0?(this._destroyPipeline(e),this.device.props.debugFactories&&z.log(3,`${this}: ${e} released and destroyed`)()):t[i].useCount<0?(z.error(`${this}: ${e} released, useCount < 0, resetting`)(),t[i].useCount=0):this.device.props.debugFactories&&z.log(3,`${this}: ${e} released, count=${t[i].useCount}`)()}createSharedRenderPipeline(e){let t=this._hashSharedRenderPipeline(e),i=this._sharedRenderPipelineCache[t];return i||(i={resource:this.device._createSharedRenderPipelineWebGL(e),useCount:0},this._sharedRenderPipelineCache[t]=i),i.useCount++,i.resource}releaseSharedRenderPipeline(e){if(!e.sharedRenderPipeline)return;let t=this._hashSharedRenderPipeline(e.sharedRenderPipeline.props),i=this._sharedRenderPipelineCache[t];i&&(i.useCount--,i.useCount===0&&(i.resource.destroy(),delete this._sharedRenderPipelineCache[t]))}_destroyPipeline(e){let t=this._getCache(e);return this.device.props._destroyPipelines?(delete t[e.hash],e.destroy(),e instanceof Ht&&this.releaseSharedRenderPipeline(e),!0):!1}_getCache(e){let t;if(e instanceof Wi&&(t=this._computePipelineCache),e instanceof Ht&&(t=this._renderPipelineCache),!t)throw new Error(`${this}`);if(!t[e.hash])throw new Error(`${this}: ${e} matched incorrect entry`);return t}_hashComputePipeline(e){let{type:t}=this.device,i=this._getHash(e.shader.source),r=this._getHash(JSON.stringify(e.shaderLayout));return`${t}/C/${i}SL${r}`}_hashRenderPipeline(e){let t=e.vs?this._getHash(e.vs.source):0,i=e.fs?this._getHash(e.fs.source):0,r=this._getWebGLVaryingHash(e),s=this._getHash(JSON.stringify(e.shaderLayout)),o=this._getHash(JSON.stringify(e._uniformBlockLayouts)),a=this._getHash(JSON.stringify(e.bufferLayout)),{type:c}=this.device;switch(c){case"webgl":let l=this._getHash(JSON.stringify(e.parameters));return`${c}/R/${t}/${i}V${r}T${e.topology}P${l}SL${s}UBL${o}BL${a}`;case"webgpu":default:let u=this._getHash(JSON.stringify({vertexEntryPoint:e.vertexEntryPoint,fragmentEntryPoint:e.fragmentEntryPoint})),f=this._getHash(JSON.stringify(e.parameters)),d=this._getWebGPUAttachmentHash(e);return`${c}/R/${t}/${i}V${r}T${e.topology}EP${u}P${f}SL${s}BL${a}A${d}`}}_hashSharedRenderPipeline(e){let t=e.vs?this._getHash(e.vs.source):0,i=e.fs?this._getHash(e.fs.source):0,r=this._getWebGLVaryingHash(e);return`webgl/S/${t}/${i}V${r}`}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}_getWebGLVaryingHash(e){let{varyings:t=[],bufferMode:i=null}=e;return this._getHash(JSON.stringify({varyings:t,bufferMode:i}))}_getWebGPUAttachmentHash(e){let t=e.colorAttachmentFormats??[this.device.preferredColorFormat],i=e.depthStencilAttachmentFormat??(e.parameters?.depthWriteEnabled?this.device.preferredDepthFormat:null);return this._getHash(JSON.stringify({colorAttachmentFormats:t,depthStencilAttachmentFormat:i}))}}});var Br,$0=C(()=>{Um();ut();Br=class n{static defaultProps={...kr.defaultProps};static getDefaultShaderFactory(e){let t=e.getModuleData("@luma.gl/core");return t.defaultShaderFactory||=new n(e),t.defaultShaderFactory}device;_cache={};get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}constructor(e){this.device=e}createShader(e){if(!this.device.props._cacheShaders)return this.device.createShader(e);let t=this._hashShader(e),i=this._cache[t];if(i)i.useCount++,this.device.props.debugFactories&&z.log(3,`${this}: Reusing shader ${i.resource.id} count=${i.useCount}`)();else{let r=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[t]=i={resource:r,useCount:1},this.device.props.debugFactories&&z.log(3,`${this}: Created new shader ${r.id}`)()}return i.resource}release(e){if(!this.device.props._cacheShaders){e.destroy();return}let t=this._hashShader(e),i=this._cache[t];if(i)if(i.useCount--,i.useCount===0)this.device.props._destroyShaders&&(delete this._cache[t],i.resource.destroy(),this.device.props.debugFactories&&z.log(3,`${this}: Releasing shader ${e.id}, destroyed`)());else{if(i.useCount<0)throw new Error(`ShaderFactory: Shader ${e.id} released too many times`);this.device.props.debugFactories&&z.log(3,`${this}: Releasing shader ${e.id} count=${i.useCount}`)()}}_hashShader(e){return`${e.stage}:${e.source}`}}});function Du(n,e,t){let i=n.bindings.find(r=>r.name===e||`${r.name.toLocaleLowerCase()}uniforms`===e.toLocaleLowerCase());return!i&&!t?.ignoreWarnings&&z.warn(`Binding ${e} not set: Not found in shader layout.`)(),i||null}function Or(n,e){if(!e)return{};if(HR(e))return Object.fromEntries(Object.entries(e).map(([r,s])=>[Number(r),{...s}]));let t={};for(let[i,r]of Object.entries(e)){let o=Du(n,i)?.group??0;t[o]||={},t[o][i]=r}return t}function js(n){let e={};for(let t of Object.values(n))Object.assign(e,t);return e}function HR(n){let e=Object.keys(n);return e.length>0&&e.every(t=>/^\d+$/.test(t))}var G0=C(()=>{ut()});var ka,V0=C(()=>{He();ka=class n extends te{static defaultClearColor=[0,0,0,1];static defaultClearDepth=1;static defaultClearStencil=0;get[Symbol.toStringTag](){return"RenderPass"}constructor(e,t,i=n.defaultProps){t=n.normalizeProps(e,t),super(e,t,i)}static normalizeProps(e,t){return t}static defaultProps={...te.defaultProps,framebuffer:null,resolveTargets:void 0,parameters:void 0,clearColor:n.defaultClearColor,clearColors:void 0,clearDepth:n.defaultClearDepth,clearStencil:n.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0}}});var Ra,W0=C(()=>{He();Ra=class n extends te{get[Symbol.toStringTag](){return"CommandEncoder"}_timeProfilingQuerySet=null;_timeProfilingSlotCount=0;_gpuTimeMs;constructor(e,t){super(e,t,n.defaultProps),this._timeProfilingQuerySet=t.timeProfilingQuerySet??null,this._timeProfilingSlotCount=0,this._gpuTimeMs=void 0}async resolveTimeProfilingQuerySet(){if(this._gpuTimeMs=void 0,!this._timeProfilingQuerySet)return;let e=Math.floor(this._timeProfilingSlotCount/2);if(e<=0)return;let t=e*2,i=await this._timeProfilingQuerySet.readResults({firstQuery:0,queryCount:t}),r=0n;for(let s=0;s=this._timeProfilingQuerySet.props.count?t:(this._timeProfilingSlotCount+=2,{...t,timestampQuerySet:this._timeProfilingQuerySet,beginTimestampIndex:i,endTimestampIndex:i+1})}_supportsTimestampQueries(){return this.device.features.has("timestamp-query")}static defaultProps={...te.defaultProps,measureExecutionTime:void 0,timeProfilingQuerySet:void 0}}});var Ia,j0=C(()=>{He();Ia=class n extends te{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,t){super(e,t,n.defaultProps)}static defaultProps={...te.defaultProps}}});var Ba,H0=C(()=>{He();Ba=class n extends te{static defaultProps={...te.defaultProps,shaderLayout:void 0,bufferLayout:[]};get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;indexBuffer=null;attributes;constructor(e,t){super(e,t,n.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null)}getBufferSlot(e){return null}getDrawValidationError(){return null}setConstantWebGL(e,t){this.device.reportError(new Error("constant attributes not supported"),this)()}}});var Oa,Y0=C(()=>{He();Oa=class n extends te{static defaultProps={...te.defaultProps,layout:void 0,buffers:{}};get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,n.defaultProps)}}});var Da,q0=C(()=>{He();Da=class n extends te{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){super(e,t,n.defaultProps)}static defaultProps={...te.defaultProps,type:void 0,count:void 0}}});var Na,Z0=C(()=>{He();Na=class n extends te{static defaultProps={...te.defaultProps};get[Symbol.toStringTag](){return"Fence"}constructor(e,t={}){super(e,t,n.defaultProps)}}});function Hs(n){let e=Nu(n),t=XR[e];if(!t)throw new Error(`Unsupported variable shader type: ${n}`);return t}function X0(n){let e=K0(n),t=ZR[e];if(!t)throw new Error(`Unsupported attribute shader type: ${n}`);let[i,r]=t,s=i==="i32"||i==="u32",o=i!=="u32",a=qR[i]*r;return{primitiveType:i,components:r,byteLength:a,integer:s,signed:o}}function YR(n,e){return e===1?n:`vec${e}<${n}>`}function K0(n){return KR[n]||n}function Nu(n){return QR[n]||n}var Vm,Mt,qR,ZR,XR,KR,QR,Fa=C(()=>{Vm=class{getVariableShaderTypeInfo(e){return Hs(e)}getAttributeShaderTypeInfo(e){return X0(e)}makeShaderAttributeType(e,t){return YR(e,t)}resolveAttributeShaderTypeAlias(e){return K0(e)}resolveVariableShaderTypeAlias(e){return Nu(e)}};Mt=new Vm,qR={f32:4,f16:2,i32:4,u32:4},ZR={f32:["f32",1],"vec2":["f32",2],"vec3":["f32",3],"vec4":["f32",4],f16:["f16",1],"vec2":["f16",2],"vec3":["f16",3],"vec4":["f16",4],i32:["i32",1],"vec2":["i32",2],"vec3":["i32",3],"vec4":["i32",4],u32:["u32",1],"vec2":["u32",2],"vec3":["u32",3],"vec4":["u32",4]},XR={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2":{type:"f32",components:2},"vec3":{type:"f32",components:3},"vec4":{type:"f32",components:4},"vec2":{type:"f16",components:2},"vec3":{type:"f16",components:3},"vec4":{type:"f16",components:4},"vec2":{type:"i32",components:2},"vec3":{type:"i32",components:3},"vec4":{type:"i32",components:4},"vec2":{type:"u32",components:2},"vec3":{type:"u32",components:3},"vec4":{type:"u32",components:4},"mat2x2":{type:"f32",components:4},"mat2x3":{type:"f32",components:6},"mat2x4":{type:"f32",components:8},"mat3x2":{type:"f32",components:6},"mat3x3":{type:"f32",components:9},"mat3x4":{type:"f32",components:12},"mat4x2":{type:"f32",components:8},"mat4x3":{type:"f32",components:12},"mat4x4":{type:"f32",components:16},"mat2x2":{type:"f16",components:4},"mat2x3":{type:"f16",components:6},"mat2x4":{type:"f16",components:8},"mat3x2":{type:"f16",components:6},"mat3x3":{type:"f16",components:9},"mat3x4":{type:"f16",components:12},"mat4x2":{type:"f16",components:8},"mat4x3":{type:"f16",components:12},"mat4x4":{type:"f16",components:16},"mat2x2":{type:"i32",components:4},"mat2x3":{type:"i32",components:6},"mat2x4":{type:"i32",components:8},"mat3x2":{type:"i32",components:6},"mat3x3":{type:"i32",components:9},"mat3x4":{type:"i32",components:12},"mat4x2":{type:"i32",components:8},"mat4x3":{type:"i32",components:12},"mat4x4":{type:"i32",components:16},"mat2x2":{type:"u32",components:4},"mat2x3":{type:"u32",components:6},"mat2x4":{type:"u32",components:8},"mat3x2":{type:"u32",components:6},"mat3x3":{type:"u32",components:9},"mat3x4":{type:"u32",components:12},"mat4x2":{type:"u32",components:8},"mat4x3":{type:"u32",components:12},"mat4x4":{type:"u32",components:16}},KR={vec2i:"vec2",vec3i:"vec3",vec4i:"vec4",vec2u:"vec2",vec3u:"vec3",vec4u:"vec4",vec2f:"vec2",vec3f:"vec3",vec4f:"vec4",vec2h:"vec2",vec3h:"vec3",vec4h:"vec4"},QR={vec2i:"vec2",vec3i:"vec3",vec4i:"vec4",vec2u:"vec2",vec3u:"vec3",vec4u:"vec4",vec2f:"vec2",vec3f:"vec3",vec4f:"vec4",vec2h:"vec2",vec3h:"vec3",vec4h:"vec4",mat2x2f:"mat2x2",mat2x3f:"mat2x3",mat2x4f:"mat2x4",mat3x2f:"mat3x2",mat3x3f:"mat3x3",mat3x4f:"mat3x4",mat4x2f:"mat4x2",mat4x3f:"mat4x3",mat4x4f:"mat4x4",mat2x2i:"mat2x2",mat2x3i:"mat2x3",mat2x4i:"mat2x4",mat3x2i:"mat3x2",mat3x3i:"mat3x3",mat3x4i:"mat3x4",mat4x2i:"mat4x2",mat4x3i:"mat4x3",mat4x4i:"mat4x4",mat2x2u:"mat2x2",mat2x3u:"mat2x3",mat2x4u:"mat2x4",mat3x2u:"mat3x2",mat3x3u:"mat3x3",mat3x4u:"mat3x4",mat4x2u:"mat4x2",mat4x3u:"mat4x3",mat4x4u:"mat4x4",mat2x2h:"mat2x2",mat2x3h:"mat2x3",mat2x4h:"mat2x4",mat3x2h:"mat3x2",mat3x3h:"mat3x3",mat3x4h:"mat3x4",mat4x2h:"mat4x2",mat4x3h:"mat4x3",mat4x4h:"mat4x4"}});function Dr(n,e={}){let t={...n},i=e.layout??"std140",r={},s=0;for(let[o,a]of Object.entries(t))s=Wm(r,o,a,s,i);return s=jt(s,ji(t,i)),{layout:i,byteLength:s*4,uniformTypes:t,fields:r}}function za(n,e){let t=Nu(n),i=Hs(t),r=/^mat(\d)x(\d)<.+>$/.exec(t);if(r){let o=Number(r[1]),a=Number(r[2]),c=Q0(a,t,i.type,e),l=eI(c.size,c.alignment,e);return{alignment:c.alignment,size:o*l,components:o*a,columns:o,rows:a,columnStride:l,shaderType:t,type:i.type}}let s=/^vec(\d)<.+>$/.exec(t);return s?Q0(Number(s[1]),t,i.type,e):{alignment:1,size:1,components:1,columns:1,rows:1,columnStride:1,shaderType:t,type:i.type}}function jm(n){return!!n&&typeof n=="object"&&!Array.isArray(n)}function Wm(n,e,t,i,r){if(typeof t=="string"){let s=za(t,r),o=jt(i,s.alignment);return n[e]={offset:o,...s},o+s.size}if(Array.isArray(t)){if(Array.isArray(t[0]))throw new Error(`Nested arrays are not supported for ${e}`);let s=t[0],o=t[1],a=ew(s,r),c=jt(i,ji(t,r));for(let l=0;l{Lu();Fa()});function Hm(n){return(!zu||zu.byteLength{});function nI(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Ys(n){return Array.isArray(n)?n.length===0||typeof n[0]=="number":nI(n)}var Zm=C(()=>{});function iI(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&!ArrayBuffer.isView(n)}function rI(n,e,t){return Array.prototype.slice.call(n,e,t)}var Uu,nw=C(()=>{qm();Zm();ut();Fu();Uu=class{layout;constructor(e){this.layout=e}has(e){return!!this.layout.fields[e]}get(e){let t=this.layout.fields[e];return t?{offset:t.offset,size:t.size}:void 0}getFlatUniformValues(e){let t={};for(let[i,r]of Object.entries(e)){let s=this.layout.uniformTypes[i];s?this._flattenCompositeValue(t,i,s,r):this.layout.fields[i]&&(t[i]=r)}return t}getData(e){let t=Hm(this.layout.byteLength);new Uint8Array(t,0,this.layout.byteLength).fill(0);let i={i32:new Int32Array(t),u32:new Uint32Array(t),f32:new Float32Array(t),f16:new Uint16Array(t)},r=this.getFlatUniformValues(e);for(let[s,o]of Object.entries(r))this._writeLeafValue(i,s,o);return new Uint8Array(t,0,this.layout.byteLength)}_flattenCompositeValue(e,t,i,r){if(r!==void 0){if(typeof i=="string"||this.layout.fields[t]){e[t]=r;return}if(Array.isArray(i)){let s=i[0],o=i[1];if(Array.isArray(s))throw new Error(`Nested arrays are not supported for ${t}`);if(typeof s=="string"&&Ys(r)){this._flattenPackedArray(e,t,s,o,r);return}if(!Array.isArray(r)){z.warn(`Unsupported uniform array value for ${t}:`,r)();return}for(let a=0;a=o.length)break;c===1?e[`${t}[${l}]`]=Number(o[u]):e[`${t}[${l}]`]=rI(s,u,u+c)}}_writeLeafValue(e,t,i){let r=this.layout.fields[t];if(!r){z.warn(`Uniform ${t} not found in layout`)();return}let{type:s,components:o,columns:a,rows:c,offset:l,columnStride:u}=r,f=e[s];if(o===1){f[l]=Number(i);return}let d=i;if(a===1){for(let p=0;ps)return!1;for(let o=0;o{Zm();sI=128});var $u,ow=C(()=>{sw();$u=class{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(e){if(this.name=e?.name||"unnamed",e?.name&&e?.shaderLayout){let t=e?.shaderLayout.bindings?.find(r=>r.type==="uniform"&&r.name===e?.name);if(!t)throw new Error(e?.name);let i=t;for(let r of i.uniforms||[])this.bindingLayout[r.name]=r}}setUniforms(e){for(let[t,i]of Object.entries(e))this._setUniform(t,i)&&!this.needsRedraw&&this.setNeedsRedraw(`${this.name}.${t}=${i}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){return iw(this.uniforms[e],t)?!1:(this.uniforms[e]=rw(t),this.modifiedUniforms[e]=!0,this.modified=!0,!0)}}});function aI(n){return n.type==="webgpu"?"wgsl-uniform":"std140"}var oI,Nr,aw=C(()=>{Cu();ut();Fu();ow();nw();oI=1024,Nr=class{device;uniformBlocks=new Map;shaderBlockLayouts=new Map;shaderBlockWriters=new Map;uniformBuffers=new Map;constructor(e,t){this.device=e;for(let[i,r]of Object.entries(t)){let s=i,o=Dr(r.uniformTypes??{},{layout:r.layout??aI(e)}),a=new Uu(o);this.shaderBlockLayouts.set(s,o),this.shaderBlockWriters.set(s,a);let c=new $u({name:i});c.setUniforms(a.getFlatUniformValues(r.defaultUniforms||{})),this.uniformBlocks.set(s,c)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e,t){for(let[i,r]of Object.entries(e)){let s=i,a=this.shaderBlockWriters.get(s)?.getFlatUniformValues(r||{});this.uniformBlocks.get(s)?.setUniforms(a||{})}this.updateUniformBuffers(t)}getUniformBufferByteLength(e){let t=this.shaderBlockLayouts.get(e)?.byteLength||0;return Math.max(t,oI)}getUniformBufferData(e){let t=this.uniformBlocks.get(e)?.getAllUniforms()||{};return this.shaderBlockWriters.get(e)?.getData(t)||new Uint8Array(0)}createUniformBuffer(e,t){t&&this.setUniforms(t);let i=this.getUniformBufferByteLength(e),r=this.device.createBuffer({usage:re.UNIFORM|re.COPY_DST,byteLength:i}),s=this.getUniformBufferData(e);return r.write(s),r}getManagedUniformBuffer(e){if(!this.uniformBuffers.get(e)){let t=this.getUniformBufferByteLength(e),i=this.device.createBuffer({usage:re.UNIFORM|re.COPY_DST,byteLength:t});this.uniformBuffers.set(e,i)}return this.uniformBuffers.get(e)}updateUniformBuffers(e){let t=!1;for(let i of this.uniformBlocks.keys()){let r=this.updateUniformBuffer(i,e);t||=r}return t&&z.log(3,`UniformStore.updateUniformBuffers(): ${t}`)(),t}updateUniformBuffer(e,t){let i=this.uniformBlocks.get(e),r=this.uniformBuffers.get(e),s=!1;if(r&&i?.needsRedraw){s||=i.needsRedraw;let o=this.getUniformBufferData(e);if(r=this.uniformBuffers.get(e),r&&(t?this.device.writeBufferViaCommandEncoder(t,r,o):r.write(o)),z.level>=4){let a=this.uniformBlocks.get(e)?.getAllUniforms();z.log(4,`Writing to uniform buffer ${String(e)}`,o,a)()}}return s}}});function qs(n){return n.attributes?n.attributes.map(e=>e.attribute):[n.name]}function Xm(n){return Object.fromEntries(n.attributes.map(e=>[e.name,e.location]))}function Gu(n){let e=1/0;for(let t of n)t!==void 0&&(e=Math.min(e,t));return e}function Km(n,e,t){cI(e);let i=new Map;for(let r of e){let s=lI(r);if(r.attributes)for(let o of r.attributes)i.has(o.attribute)||i.set(o.attribute,{bufferName:r.name,stepMode:r.stepMode,vertexFormat:o.format,byteOffset:o.byteOffset,byteStride:s});else r.format&&!i.has(r.name)&&i.set(r.name,{bufferName:r.name,stepMode:r.stepMode,vertexFormat:r.format,byteOffset:0,byteStride:s})}return n.attributes.map(r=>{let s=i.get(r.name);!s&&t?.warnOnMissingBufferLayout&&z.warn(`layout for attribute "${r.name}" not present in buffer layout`)();let o=Mt.getAttributeShaderTypeInfo(r.type),a=s?.vertexFormat||Ee.getCompatibleVertexFormat(o);return{attributeName:r.name,bufferName:s?.bufferName||r.name,location:r.location,vertexFormat:a,byteOffset:s?.byteOffset??0,byteStride:s?.byteStride??Ee.getVertexFormatInfo(a).byteLength,stepMode:s?.stepMode||r.stepMode||(r.name.startsWith("instance")?"instance":"vertex")}}).sort((r,s)=>r.location-s.location)}function cI(n){for(let e of n)(e.attributes&&e.format||!e.attributes&&!e.format)&&z.warn(`BufferLayout ${e.name} must have either 'attributes' or 'format' field`)()}function lI(n){if(typeof n.byteStride=="number")return n.byteStride;if(n.attributes){let e=0;for(let t of n.attributes)e+=Ee.getVertexFormatInfo(t.format).byteLength;return e}return Ee.getVertexFormatInfo(n.format).byteLength}var Qm=C(()=>{ut();Fa();Sa()});function Ua(n,e){let t={},i=Km(n,e,{warnOnMissingBufferLayout:!0});for(let r of i){let s=uI(n,r);t[r.attributeName]=s}return t}function uI(n,e){let t=fI(n,e.attributeName),i=Mt.getAttributeShaderTypeInfo(t.type),r=e.vertexFormat,s=Ee.getVertexFormatInfo(r);return{attributeName:e.attributeName,bufferName:e.bufferName,location:t.location,shaderType:t.type,primitiveType:i.primitiveType,shaderComponents:i.components,vertexFormat:r,bufferDataType:s.type,bufferComponents:s.components,normalized:s.normalized,integer:i.integer,stepMode:e.stepMode,byteOffset:e.byteOffset,byteStride:e.byteStride}}function fI(n,e){let t=n.attributes.find(i=>i.name===e);return t||z.warn(`shader layout attribute "${e}" not present in shader`)(),t||null}var cw=C(()=>{ut();Fa();Sa();Qm()});var ee=C(()=>{i0();r0();P0();k0();R0();Cu();Fm();I0();B0();Um();Nm();F0();$m();z0();U0();$0();V0();Gm();W0();j0();H0();Y0();q0();Z0();Fu();aw();Mu();Lu();Fa();Sa();Bu();ut();G0();Om();qm();cw();Qm()});function $a(n=[],e){let t=[],i={},r={},s={},o={};for(let a of n)lw({modules:t,defines:i,injections:r,vertexInputs:s,varyings:o},a),lw({modules:t,defines:i,injections:r,vertexInputs:s,varyings:o},a[e]);for(let a of Object.keys(o))if(s[a])throw new Error(`ShaderPlugin name "${a}" cannot be both a vertex input and a varying`);return{modules:t,defines:i,injections:r,vertexInputs:s,varyings:o}}function Ga(n=[],e=[]){let t=[...n],i=new Set(t.map(r=>r.name));for(let r of e)i.has(r.name)||(t.push(r),i.add(r.name));return t}function lw(n,e){if(e){e.modules?.length&&n.modules.push(...e.modules),e.defines&&Object.assign(n.defines,e.defines);for(let[t,i]of Object.entries(e.vertexInputs||{})){uw(t,"vertex input");let r=n.vertexInputs[t];if(r&&r!==i)throw new Error(`ShaderPlugin vertex input "${t}" has conflicting types "${r}" and "${i}"`);n.vertexInputs[t]=i}for(let[t,i]of Object.entries(e.varyings||{})){uw(t,"varying");let r=hI(t,i),s=n.varyings[t];if(s&&(s.type!==r.type||s.interpolation!==r.interpolation))throw new Error(`ShaderPlugin varying "${t}" has conflicting declarations "${s.type}/${s.interpolation}" and "${r.type}/${r.interpolation}"`);n.varyings[t]=r}for(let t of e.injections||[])pI(t.target),n.injections[t.target]||(n.injections[t.target]=[]),n.injections[t.target].push({injection:t.injection,order:t.order??0})}}function uw(n,e){if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(n)||n.startsWith("_luma_"))throw new Error(`ShaderPlugin ${e} "${n}" must be a valid non-reserved identifier`)}function hI(n,e){let{primitiveType:t}=Mt.getAttributeShaderTypeInfo(e.type),i=t==="i32"||t==="u32",r=e.interpolation||(i?"flat":"smooth");if(i&&r==="smooth")throw new Error(`ShaderPlugin integer varying "${n}" must use flat interpolation`);return{type:e.type,interpolation:r}}function pI(n){if(!dI.test(n))throw new Error(`ShaderPlugin injection target "${n}" must be a named shader anchor or hook`)}var dI,fw=C(()=>{ee();dI=/^(vs|fs):(?:#(?:decl|main-start|main-end)|[A-Za-z_][\w-]*)$/});function Va(n){return`${n.name}Uniforms`}function hw(n,e){let t=e==="wgsl"?n.source:e==="vertex"?n.vs:n.fs;if(!t)return null;let i=Va(n);return _I(t,e==="wgsl"?"wgsl":"glsl",i)}function pw(n,e){let t=Object.keys(n.uniformTypes||{});if(!t.length)return null;let i=hw(n,e);return i?{moduleName:n.name,uniformBlockName:Va(n),stage:e,expectedUniformNames:t,actualUniformNames:i,matches:vI(t,i)}:null}function Jm(n,e,t={}){let i=pw(n,e);if(!i||i.matches)return i;let r=xI(i);return t.log?.error?.(r,i)(),t.throwOnError!==!1&&hi(!1,r),i}function Wa(n){let e=[],t=wI(n);for(let i of t.matchAll(gI)){let r=i[1]?.trim()||null;e.push({blockName:i[2],body:i[3],instanceName:i[4]||null,layoutQualifier:r,hasLayoutQualifier:!!r,isStd140:!!(r&&/\blayout\s*\([^)]*\bstd140\b[^)]*\)/.exec(r))})}return e}function eg(n,e,t,i){let r=Wa(n).filter(o=>!o.isStd140),s=new Set;for(let o of r){if(s.has(o.blockName))continue;s.add(o.blockName);let a=i?.label?`${i.label} `:"",c=o.hasLayoutQualifier?`declares ${EI(o.layoutQualifier)} instead of layout(std140)`:"does not declare layout(std140)",l=`${a}${e} shader uniform block ${o.blockName} ${c}. luma.gl host-side shader block packing assumes explicit layout(std140) for GLSL uniform blocks. Add \`layout(std140)\` to the block declaration.`;t?.warn?.(l,o)()}return r}function _I(n,e,t){let i=e==="wgsl"?yI(n,t):bI(n,t);if(!i)return null;let r=[];for(let s of i.split(` -`)){let o=s.replace(/\/\/.*$/,"").trim();if(!o||o.startsWith("#"))continue;let a=e==="wgsl"?o.match(/^([A-Za-z0-9_]+)\s*:/):o.match(mI);a&&r.push(a[1])}return r}function yI(n,e){let t=new RegExp(`\\bstruct\\s+${e}\\b`,"m").exec(n);if(!t)return null;let i=n.indexOf("{",t.index);if(i<0)return null;let r=0;for(let s=i;si.blockName===e)?.body||null}function vI(n,e){if(n.length!==e.length)return!1;for(let t=0;t!t.includes(a)),r=t.filter(a=>!e.includes(a)),s=[`Expected ${e.length} fields, found ${t.length}.`],o=SI(e,t);return o&&s.push(o),i.length&&s.push(`Missing from shader block (${i.length}): ${dw(i)}.`),r.length&&s.push(`Unexpected in shader block (${r.length}): ${dw(r)}.`),e.length<=12&&t.length<=12&&(i.length||r.length)&&(s.push(`Expected: ${e.join(", ")}.`),s.push(`Actual: ${t.join(", ")}.`)),`${n.moduleName}: ${n.stage} shader uniform block ${n.uniformBlockName} does not match module.uniformTypes. ${s.join(" ")}`}function wI(n){return n.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"")}function EI(n){return n.replace(/\s+/g," ").trim()}function SI(n,e){let t=Math.min(n.length,e.length);for(let i=0;ie.length?`Shader block ends after field ${e.length}; expected next field ${n[e.length]}.`:e.length>n.length?`Shader block has extra field ${e.length}: ${e[n.length]}.`:null}function dw(n,e=8){if(n.length<=e)return n.join(", ");let t=n.length-e;return`${n.slice(0,e).join(", ")}, ... (${t} more)`}var mI,gI,tg=C(()=>{vu();mI=/^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/,gI=/((?:layout\s*\([^)]*\)\s*)*)uniform\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([\s\S]*?)\}\s*([A-Za-z_][A-Za-z0-9_]*)?\s*;/g});function mw(n){switch(n?.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU +
${s}
`,o&&(a.innerHTML+=`

Translated Source



${o}
`),a.style.top="0",a.style.left="0",a.style.background="white",a.style.position="fixed",a.style.zIndex="9999",a.style.maxWidth="100vw",a.style.maxHeight="100vh",a.style.overflowY="auto",document.body.appendChild(a),a.querySelector(".luma-compiler-log-error")?.scrollIntoView(),a.querySelector("button#close").onclick=()=>{a.remove()},a.querySelector("button#copy").onclick=()=>{navigator.clipboard.writeText(this.source)}}static defaultProps={...te.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0}}});var Rr,z0=C(()=>{He();zm();ut();Rr=class n extends te{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(e,t={}){super(e,t,n.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(e){let t=this.colorAttachments.map(r=>r.texture.clone(e)),i=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,...e,colorAttachments:t,depthStencilAttachment:i})}resize(e){let t=!e;if(e){let[i,r]=Array.isArray(e)?e:[e.width,e.height];t=t||r!==this.height||i!==this.width,this.width=i,this.height=r}t&&(N.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map((t,i)=>{if(typeof t=="string"){let r=this.createColorTexture(t,i);return this.attachResource(r),r.view}return t instanceof me?t.view:t});let e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){let t=this.createDepthStencilTexture(e);this.attachResource(t),this.depthStencilAttachment=t.view}else e instanceof me?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,t){return this.device.createTexture({id:`${this.id}-color-attachment-${t}`,usage:me.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(e){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:me.RENDER_ATTACHMENT|me.SAMPLE,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){if(this.colorAttachments.forEach((i,r)=>{let s=i.texture.clone({width:e,height:t});this.destroyAttachedResource(i),this.colorAttachments[r]=s.view,this.attachResource(s.view)}),this.depthStencilAttachment){let i=this.depthStencilAttachment.texture.clone({width:e,height:t});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=i.view,this.attachResource(i)}this.updateAttachments()}static defaultProps={...te.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null}}});var Xt,Gm=C(()=>{He();Xt=class n extends te{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";sharedRenderPipeline=null;get isPending(){return this.linkStatus==="pending"||this.vs.compilationStatus==="pending"||this.fs?.compilationStatus==="pending"}get isErrored(){return this.linkStatus==="error"||this.vs.compilationStatus==="error"||this.fs?.compilationStatus==="error"}constructor(e,t){super(e,t,n.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[],this.sharedRenderPipeline=this.props._sharedRenderPipeline||null}static defaultProps={...te.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},varyings:void 0,bufferMode:void 0,disableWarnings:!1,_sharedRenderPipeline:void 0,_uniformBlockLayouts:[],bindings:void 0,bindGroups:void 0}}});var ka,U0=C(()=>{He();ka=class extends te{get[Symbol.toStringTag](){return"SharedRenderPipeline"}constructor(e,t){super(e,t,{...te.defaultProps,handle:void 0,vs:void 0,fs:void 0,varyings:void 0,bufferMode:void 0})}}});var Hi,Vm=C(()=>{He();Hi=class n extends te{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(e,t){super(e,t,n.defaultProps),this.shaderLayout=t.shaderLayout}static defaultProps={...te.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0}}});var Ir,$0=C(()=>{Vm();Gm();ut();Ws();Ir=class n{static defaultProps={...Xt.defaultProps};static getDefaultPipelineFactory(e){let t=e.getModuleData("@luma.gl/core");return t.defaultPipelineFactory||=new n(e),t.defaultPipelineFactory}device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};_sharedRenderPipelineCache={};get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}constructor(e){this.device=e}createRenderPipeline(e){if(!this.device.props._cachePipelines)return this.device.createRenderPipeline(e);let t={...Xt.defaultProps,...e},i=this._renderPipelineCache,r=this._hashRenderPipeline(t),s=i[r]?.resource;if(s)i[r].useCount++,this.device.props.debugFactories&&N.log(3,`${this}: ${i[r].resource} reused, count=${i[r].useCount}, (id=${e.id})`)();else{let o=this.device.type==="webgl"&&this.device.props._sharePipelines?this.createSharedRenderPipeline(t):void 0;s=this.device.createRenderPipeline({...t,id:t.id?`${t.id}-cached`:zn("unnamed-cached"),_sharedRenderPipeline:o}),s.hash=r,i[r]={resource:s,useCount:1},this.device.props.debugFactories&&N.log(3,`${this}: ${s} created, count=${i[r].useCount}`)()}return s}createComputePipeline(e){if(!this.device.props._cachePipelines)return this.device.createComputePipeline(e);let t={...Hi.defaultProps,...e},i=this._computePipelineCache,r=this._hashComputePipeline(t),s=i[r]?.resource;return s?(i[r].useCount++,this.device.props.debugFactories&&N.log(3,`${this}: ${i[r].resource} reused, count=${i[r].useCount}, (id=${e.id})`)()):(s=this.device.createComputePipeline({...t,id:t.id?`${t.id}-cached`:void 0}),s.hash=r,i[r]={resource:s,useCount:1},this.device.props.debugFactories&&N.log(3,`${this}: ${s} created, count=${i[r].useCount}`)()),s}release(e){if(!this.device.props._cachePipelines){e.destroy();return}let t=this._getCache(e),i=e.hash;t[i].useCount--,t[i].useCount===0?(this._destroyPipeline(e),this.device.props.debugFactories&&N.log(3,`${this}: ${e} released and destroyed`)()):t[i].useCount<0?(N.error(`${this}: ${e} released, useCount < 0, resetting`)(),t[i].useCount=0):this.device.props.debugFactories&&N.log(3,`${this}: ${e} released, count=${t[i].useCount}`)()}createSharedRenderPipeline(e){let t=this._hashSharedRenderPipeline(e),i=this._sharedRenderPipelineCache[t];return i||(i={resource:this.device._createSharedRenderPipelineWebGL(e),useCount:0},this._sharedRenderPipelineCache[t]=i),i.useCount++,i.resource}releaseSharedRenderPipeline(e){if(!e.sharedRenderPipeline)return;let t=this._hashSharedRenderPipeline(e.sharedRenderPipeline.props),i=this._sharedRenderPipelineCache[t];i&&(i.useCount--,i.useCount===0&&(i.resource.destroy(),delete this._sharedRenderPipelineCache[t]))}_destroyPipeline(e){let t=this._getCache(e);return this.device.props._destroyPipelines?(delete t[e.hash],e.destroy(),e instanceof Xt&&this.releaseSharedRenderPipeline(e),!0):!1}_getCache(e){let t;if(e instanceof Hi&&(t=this._computePipelineCache),e instanceof Xt&&(t=this._renderPipelineCache),!t)throw new Error(`${this}`);if(!t[e.hash])throw new Error(`${this}: ${e} matched incorrect entry`);return t}_hashComputePipeline(e){let{type:t}=this.device,i=this._getHash(e.shader.source),r=this._getHash(JSON.stringify(e.shaderLayout));return`${t}/C/${i}SL${r}`}_hashRenderPipeline(e){let t=e.vs?this._getHash(e.vs.source):0,i=e.fs?this._getHash(e.fs.source):0,r=this._getWebGLVaryingHash(e),s=this._getHash(JSON.stringify(e.shaderLayout)),o=this._getHash(JSON.stringify(e._uniformBlockLayouts)),a=this._getHash(JSON.stringify(e.bufferLayout)),{type:c}=this.device;switch(c){case"webgl":let l=this._getHash(JSON.stringify(e.parameters));return`${c}/R/${t}/${i}V${r}T${e.topology}P${l}SL${s}UBL${o}BL${a}`;case"webgpu":default:let u=this._getHash(JSON.stringify({vertexEntryPoint:e.vertexEntryPoint,fragmentEntryPoint:e.fragmentEntryPoint})),f=this._getHash(JSON.stringify(e.parameters)),d=this._getWebGPUAttachmentHash(e);return`${c}/R/${t}/${i}V${r}T${e.topology}EP${u}P${f}SL${s}BL${a}A${d}`}}_hashSharedRenderPipeline(e){let t=e.vs?this._getHash(e.vs.source):0,i=e.fs?this._getHash(e.fs.source):0,r=this._getWebGLVaryingHash(e);return`webgl/S/${t}/${i}V${r}`}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}_getWebGLVaryingHash(e){let{varyings:t=[],bufferMode:i=null}=e;return this._getHash(JSON.stringify({varyings:t,bufferMode:i}))}_getWebGPUAttachmentHash(e){let t=e.colorAttachmentFormats??[this.device.preferredColorFormat],i=e.depthStencilAttachmentFormat??(e.parameters?.depthWriteEnabled?this.device.preferredDepthFormat:null);return this._getHash(JSON.stringify({colorAttachmentFormats:t,depthStencilAttachmentFormat:i}))}}});var Br,G0=C(()=>{$m();ut();Br=class n{static defaultProps={...kr.defaultProps};static getDefaultShaderFactory(e){let t=e.getModuleData("@luma.gl/core");return t.defaultShaderFactory||=new n(e),t.defaultShaderFactory}device;_cache={};get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}constructor(e){this.device=e}createShader(e){if(!this.device.props._cacheShaders)return this.device.createShader(e);let t=this._hashShader(e),i=this._cache[t];if(i)i.useCount++,this.device.props.debugFactories&&N.log(3,`${this}: Reusing shader ${i.resource.id} count=${i.useCount}`)();else{let r=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[t]=i={resource:r,useCount:1},this.device.props.debugFactories&&N.log(3,`${this}: Created new shader ${r.id}`)()}return i.resource}release(e){if(!this.device.props._cacheShaders){e.destroy();return}let t=this._hashShader(e),i=this._cache[t];if(i)if(i.useCount--,i.useCount===0)this.device.props._destroyShaders&&(delete this._cache[t],i.resource.destroy(),this.device.props.debugFactories&&N.log(3,`${this}: Releasing shader ${e.id}, destroyed`)());else{if(i.useCount<0)throw new Error(`ShaderFactory: Shader ${e.id} released too many times`);this.device.props.debugFactories&&N.log(3,`${this}: Releasing shader ${e.id} count=${i.useCount}`)()}}_hashShader(e){return`${e.stage}:${e.source}`}}});function Nu(n,e,t){let i=n.bindings.find(r=>r.name===e||`${r.name.toLocaleLowerCase()}uniforms`===e.toLocaleLowerCase());return!i&&!t?.ignoreWarnings&&N.warn(`Binding ${e} not set: Not found in shader layout.`)(),i||null}function Or(n,e){if(!e)return{};if(ZR(e))return Object.fromEntries(Object.entries(e).map(([r,s])=>[Number(r),{...s}]));let t={};for(let[i,r]of Object.entries(e)){let o=Nu(n,i)?.group??0;t[o]||={},t[o][i]=r}return t}function js(n){let e={};for(let t of Object.values(n))Object.assign(e,t);return e}function ZR(n){let e=Object.keys(n);return e.length>0&&e.every(t=>/^\d+$/.test(t))}var V0=C(()=>{ut()});var Ra,W0=C(()=>{He();Ra=class n extends te{static defaultClearColor=[0,0,0,1];static defaultClearDepth=1;static defaultClearStencil=0;get[Symbol.toStringTag](){return"RenderPass"}constructor(e,t,i=n.defaultProps){t=n.normalizeProps(e,t),super(e,t,i)}static normalizeProps(e,t){return t}static defaultProps={...te.defaultProps,framebuffer:null,resolveTargets:void 0,parameters:void 0,clearColor:n.defaultClearColor,clearColors:void 0,clearDepth:n.defaultClearDepth,clearStencil:n.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0}}});var Ia,j0=C(()=>{He();Ia=class n extends te{get[Symbol.toStringTag](){return"CommandEncoder"}_timeProfilingQuerySet=null;_timeProfilingSlotCount=0;_gpuTimeMs;constructor(e,t){super(e,t,n.defaultProps),this._timeProfilingQuerySet=t.timeProfilingQuerySet??null,this._timeProfilingSlotCount=0,this._gpuTimeMs=void 0}async resolveTimeProfilingQuerySet(){if(this._gpuTimeMs=void 0,!this._timeProfilingQuerySet)return;let e=Math.floor(this._timeProfilingSlotCount/2);if(e<=0)return;let t=e*2,i=await this._timeProfilingQuerySet.readResults({firstQuery:0,queryCount:t}),r=0n;for(let s=0;s=this._timeProfilingQuerySet.props.count?t:(this._timeProfilingSlotCount+=2,{...t,timestampQuerySet:this._timeProfilingQuerySet,beginTimestampIndex:i,endTimestampIndex:i+1})}_supportsTimestampQueries(){return this.device.features.has("timestamp-query")}static defaultProps={...te.defaultProps,measureExecutionTime:void 0,timeProfilingQuerySet:void 0}}});var Ba,H0=C(()=>{He();Ba=class n extends te{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,t){super(e,t,n.defaultProps)}static defaultProps={...te.defaultProps}}});var Oa,Y0=C(()=>{He();Oa=class n extends te{static defaultProps={...te.defaultProps,shaderLayout:void 0,bufferLayout:[]};get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;indexBuffer=null;attributes;constructor(e,t){super(e,t,n.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null)}getBufferSlot(e){return null}getDrawValidationError(){return null}setConstantWebGL(e,t){this.device.reportError(new Error("constant attributes not supported"),this)()}}});var Da,q0=C(()=>{He();Da=class n extends te{static defaultProps={...te.defaultProps,layout:void 0,buffers:{}};get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,n.defaultProps)}}});var Na,Z0=C(()=>{He();Na=class n extends te{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){super(e,t,n.defaultProps)}static defaultProps={...te.defaultProps,type:void 0,count:void 0}}});var Fa,X0=C(()=>{He();Fa=class n extends te{static defaultProps={...te.defaultProps};get[Symbol.toStringTag](){return"Fence"}constructor(e,t={}){super(e,t,n.defaultProps)}}});function Hs(n){let e=Fu(n),t=JR[e];if(!t)throw new Error(`Unsupported variable shader type: ${n}`);return t}function K0(n){let e=Q0(n),t=QR[e];if(!t)throw new Error(`Unsupported attribute shader type: ${n}`);let[i,r]=t,s=i==="i32"||i==="u32",o=i!=="u32",a=KR[i]*r;return{primitiveType:i,components:r,byteLength:a,integer:s,signed:o}}function XR(n,e){return e===1?n:`vec${e}<${n}>`}function Q0(n){return eI[n]||n}function Fu(n){return tI[n]||n}var Wm,kt,KR,QR,JR,eI,tI,za=C(()=>{Wm=class{getVariableShaderTypeInfo(e){return Hs(e)}getAttributeShaderTypeInfo(e){return K0(e)}makeShaderAttributeType(e,t){return XR(e,t)}resolveAttributeShaderTypeAlias(e){return Q0(e)}resolveVariableShaderTypeAlias(e){return Fu(e)}};kt=new Wm,KR={f32:4,f16:2,i32:4,u32:4},QR={f32:["f32",1],"vec2":["f32",2],"vec3":["f32",3],"vec4":["f32",4],f16:["f16",1],"vec2":["f16",2],"vec3":["f16",3],"vec4":["f16",4],i32:["i32",1],"vec2":["i32",2],"vec3":["i32",3],"vec4":["i32",4],u32:["u32",1],"vec2":["u32",2],"vec3":["u32",3],"vec4":["u32",4]},JR={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2":{type:"f32",components:2},"vec3":{type:"f32",components:3},"vec4":{type:"f32",components:4},"vec2":{type:"f16",components:2},"vec3":{type:"f16",components:3},"vec4":{type:"f16",components:4},"vec2":{type:"i32",components:2},"vec3":{type:"i32",components:3},"vec4":{type:"i32",components:4},"vec2":{type:"u32",components:2},"vec3":{type:"u32",components:3},"vec4":{type:"u32",components:4},"mat2x2":{type:"f32",components:4},"mat2x3":{type:"f32",components:6},"mat2x4":{type:"f32",components:8},"mat3x2":{type:"f32",components:6},"mat3x3":{type:"f32",components:9},"mat3x4":{type:"f32",components:12},"mat4x2":{type:"f32",components:8},"mat4x3":{type:"f32",components:12},"mat4x4":{type:"f32",components:16},"mat2x2":{type:"f16",components:4},"mat2x3":{type:"f16",components:6},"mat2x4":{type:"f16",components:8},"mat3x2":{type:"f16",components:6},"mat3x3":{type:"f16",components:9},"mat3x4":{type:"f16",components:12},"mat4x2":{type:"f16",components:8},"mat4x3":{type:"f16",components:12},"mat4x4":{type:"f16",components:16},"mat2x2":{type:"i32",components:4},"mat2x3":{type:"i32",components:6},"mat2x4":{type:"i32",components:8},"mat3x2":{type:"i32",components:6},"mat3x3":{type:"i32",components:9},"mat3x4":{type:"i32",components:12},"mat4x2":{type:"i32",components:8},"mat4x3":{type:"i32",components:12},"mat4x4":{type:"i32",components:16},"mat2x2":{type:"u32",components:4},"mat2x3":{type:"u32",components:6},"mat2x4":{type:"u32",components:8},"mat3x2":{type:"u32",components:6},"mat3x3":{type:"u32",components:9},"mat3x4":{type:"u32",components:12},"mat4x2":{type:"u32",components:8},"mat4x3":{type:"u32",components:12},"mat4x4":{type:"u32",components:16}},eI={vec2i:"vec2",vec3i:"vec3",vec4i:"vec4",vec2u:"vec2",vec3u:"vec3",vec4u:"vec4",vec2f:"vec2",vec3f:"vec3",vec4f:"vec4",vec2h:"vec2",vec3h:"vec3",vec4h:"vec4"},tI={vec2i:"vec2",vec3i:"vec3",vec4i:"vec4",vec2u:"vec2",vec3u:"vec3",vec4u:"vec4",vec2f:"vec2",vec3f:"vec3",vec4f:"vec4",vec2h:"vec2",vec3h:"vec3",vec4h:"vec4",mat2x2f:"mat2x2",mat2x3f:"mat2x3",mat2x4f:"mat2x4",mat3x2f:"mat3x2",mat3x3f:"mat3x3",mat3x4f:"mat3x4",mat4x2f:"mat4x2",mat4x3f:"mat4x3",mat4x4f:"mat4x4",mat2x2i:"mat2x2",mat2x3i:"mat2x3",mat2x4i:"mat2x4",mat3x2i:"mat3x2",mat3x3i:"mat3x3",mat3x4i:"mat3x4",mat4x2i:"mat4x2",mat4x3i:"mat4x3",mat4x4i:"mat4x4",mat2x2u:"mat2x2",mat2x3u:"mat2x3",mat2x4u:"mat2x4",mat3x2u:"mat3x2",mat3x3u:"mat3x3",mat3x4u:"mat3x4",mat4x2u:"mat4x2",mat4x3u:"mat4x3",mat4x4u:"mat4x4",mat2x2h:"mat2x2",mat2x3h:"mat2x3",mat2x4h:"mat2x4",mat3x2h:"mat3x2",mat3x3h:"mat3x3",mat3x4h:"mat3x4",mat4x2h:"mat4x2",mat4x3h:"mat4x3",mat4x4h:"mat4x4"}});function Dr(n,e={}){let t={...n},i=e.layout??"std140",r={},s=0;for(let[o,a]of Object.entries(t))s=jm(r,o,a,s,i);return s=Zt(s,Yi(t,i)),{layout:i,byteLength:s*4,uniformTypes:t,fields:r}}function Ua(n,e){let t=Fu(n),i=Hs(t),r=/^mat(\d)x(\d)<.+>$/.exec(t);if(r){let o=Number(r[1]),a=Number(r[2]),c=J0(a,t,i.type,e),l=iI(c.size,c.alignment,e);return{alignment:c.alignment,size:o*l,components:o*a,columns:o,rows:a,columnStride:l,shaderType:t,type:i.type}}let s=/^vec(\d)<.+>$/.exec(t);return s?J0(Number(s[1]),t,i.type,e):{alignment:1,size:1,components:1,columns:1,rows:1,columnStride:1,shaderType:t,type:i.type}}function Hm(n){return!!n&&typeof n=="object"&&!Array.isArray(n)}function jm(n,e,t,i,r){if(typeof t=="string"){let s=Ua(t,r),o=Zt(i,s.alignment);return n[e]={offset:o,...s},o+s.size}if(Array.isArray(t)){if(Array.isArray(t[0]))throw new Error(`Nested arrays are not supported for ${e}`);let s=t[0],o=t[1],a=tw(s,r),c=Zt(i,Yi(t,r));for(let l=0;l{Mu();za()});function Ym(n){return(!Uu||Uu.byteLength{});function sI(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Ys(n){return Array.isArray(n)?n.length===0||typeof n[0]=="number":sI(n)}var Xm=C(()=>{});function oI(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&!ArrayBuffer.isView(n)}function aI(n,e,t){return Array.prototype.slice.call(n,e,t)}var $u,iw=C(()=>{Zm();Xm();ut();zu();$u=class{layout;constructor(e){this.layout=e}has(e){return!!this.layout.fields[e]}get(e){let t=this.layout.fields[e];return t?{offset:t.offset,size:t.size}:void 0}getFlatUniformValues(e){let t={};for(let[i,r]of Object.entries(e)){let s=this.layout.uniformTypes[i];s?this._flattenCompositeValue(t,i,s,r):this.layout.fields[i]&&(t[i]=r)}return t}getData(e){let t=Ym(this.layout.byteLength);new Uint8Array(t,0,this.layout.byteLength).fill(0);let i={i32:new Int32Array(t),u32:new Uint32Array(t),f32:new Float32Array(t),f16:new Uint16Array(t)},r=this.getFlatUniformValues(e);for(let[s,o]of Object.entries(r))this._writeLeafValue(i,s,o);return new Uint8Array(t,0,this.layout.byteLength)}_flattenCompositeValue(e,t,i,r){if(r!==void 0){if(typeof i=="string"||this.layout.fields[t]){e[t]=r;return}if(Array.isArray(i)){let s=i[0],o=i[1];if(Array.isArray(s))throw new Error(`Nested arrays are not supported for ${t}`);if(typeof s=="string"&&Ys(r)){this._flattenPackedArray(e,t,s,o,r);return}if(!Array.isArray(r)){N.warn(`Unsupported uniform array value for ${t}:`,r)();return}for(let a=0;a=o.length)break;c===1?e[`${t}[${l}]`]=Number(o[u]):e[`${t}[${l}]`]=aI(s,u,u+c)}}_writeLeafValue(e,t,i){let r=this.layout.fields[t];if(!r){N.warn(`Uniform ${t} not found in layout`)();return}let{type:s,components:o,columns:a,rows:c,offset:l,columnStride:u}=r,f=e[s];if(o===1){f[l]=Number(i);return}let d=i;if(a===1){for(let p=0;ps)return!1;for(let o=0;o{Xm();cI=128});var Gu,aw=C(()=>{ow();Gu=class{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(e){if(this.name=e?.name||"unnamed",e?.name&&e?.shaderLayout){let t=e?.shaderLayout.bindings?.find(r=>r.type==="uniform"&&r.name===e?.name);if(!t)throw new Error(e?.name);let i=t;for(let r of i.uniforms||[])this.bindingLayout[r.name]=r}}setUniforms(e){for(let[t,i]of Object.entries(e))this._setUniform(t,i)&&!this.needsRedraw&&this.setNeedsRedraw(`${this.name}.${t}=${i}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){return rw(this.uniforms[e],t)?!1:(this.uniforms[e]=sw(t),this.modifiedUniforms[e]=!0,this.modified=!0,!0)}}});function uI(n){return n.type==="webgpu"?"wgsl-uniform":"std140"}var lI,Nr,cw=C(()=>{Tu();ut();zu();aw();iw();lI=1024,Nr=class{device;uniformBlocks=new Map;shaderBlockLayouts=new Map;shaderBlockWriters=new Map;uniformBuffers=new Map;constructor(e,t){this.device=e;for(let[i,r]of Object.entries(t)){let s=i,o=Dr(r.uniformTypes??{},{layout:r.layout??uI(e)}),a=new $u(o);this.shaderBlockLayouts.set(s,o),this.shaderBlockWriters.set(s,a);let c=new Gu({name:i});c.setUniforms(a.getFlatUniformValues(r.defaultUniforms||{})),this.uniformBlocks.set(s,c)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e,t){for(let[i,r]of Object.entries(e)){let s=i,a=this.shaderBlockWriters.get(s)?.getFlatUniformValues(r||{});this.uniformBlocks.get(s)?.setUniforms(a||{})}this.updateUniformBuffers(t)}getUniformBufferByteLength(e){let t=this.shaderBlockLayouts.get(e)?.byteLength||0;return Math.max(t,lI)}getUniformBufferData(e){let t=this.uniformBlocks.get(e)?.getAllUniforms()||{};return this.shaderBlockWriters.get(e)?.getData(t)||new Uint8Array(0)}createUniformBuffer(e,t){t&&this.setUniforms(t);let i=this.getUniformBufferByteLength(e),r=this.device.createBuffer({usage:ie.UNIFORM|ie.COPY_DST,byteLength:i}),s=this.getUniformBufferData(e);return r.write(s),r}getManagedUniformBuffer(e){if(!this.uniformBuffers.get(e)){let t=this.getUniformBufferByteLength(e),i=this.device.createBuffer({usage:ie.UNIFORM|ie.COPY_DST,byteLength:t});this.uniformBuffers.set(e,i)}return this.uniformBuffers.get(e)}updateUniformBuffers(e){let t=!1;for(let i of this.uniformBlocks.keys()){let r=this.updateUniformBuffer(i,e);t||=r}return t&&N.log(3,`UniformStore.updateUniformBuffers(): ${t}`)(),t}updateUniformBuffer(e,t){let i=this.uniformBlocks.get(e),r=this.uniformBuffers.get(e),s=!1;if(r&&i?.needsRedraw){s||=i.needsRedraw;let o=this.getUniformBufferData(e);if(r=this.uniformBuffers.get(e),r&&(t?this.device.writeBufferViaCommandEncoder(t,r,o):r.write(o)),N.level>=4){let a=this.uniformBlocks.get(e)?.getAllUniforms();N.log(4,`Writing to uniform buffer ${String(e)}`,o,a)()}}return s}}});function qs(n){return n.attributes?n.attributes.map(e=>e.attribute):[n.name]}function Km(n){return Object.fromEntries(n.attributes.map(e=>[e.name,e.location]))}function Vu(n){let e=1/0;for(let t of n)t!==void 0&&(e=Math.min(e,t));return e}function Qm(n,e,t){fI(e);let i=new Map;for(let r of e){let s=dI(r);if(r.attributes)for(let o of r.attributes)i.has(o.attribute)||i.set(o.attribute,{bufferName:r.name,stepMode:r.stepMode,vertexFormat:o.format,byteOffset:o.byteOffset,byteStride:s});else r.format&&!i.has(r.name)&&i.set(r.name,{bufferName:r.name,stepMode:r.stepMode,vertexFormat:r.format,byteOffset:0,byteStride:s})}return n.attributes.map(r=>{let s=i.get(r.name);!s&&t?.warnOnMissingBufferLayout&&N.warn(`layout for attribute "${r.name}" not present in buffer layout`)();let o=kt.getAttributeShaderTypeInfo(r.type),a=s?.vertexFormat||Pe.getCompatibleVertexFormat(o);return{attributeName:r.name,bufferName:s?.bufferName||r.name,location:r.location,vertexFormat:a,byteOffset:s?.byteOffset??0,byteStride:s?.byteStride??Pe.getVertexFormatInfo(a).byteLength,stepMode:s?.stepMode||r.stepMode||(r.name.startsWith("instance")?"instance":"vertex")}}).sort((r,s)=>r.location-s.location)}function fI(n){for(let e of n)(e.attributes&&e.format||!e.attributes&&!e.format)&&N.warn(`BufferLayout ${e.name} must have either 'attributes' or 'format' field`)()}function dI(n){if(typeof n.byteStride=="number")return n.byteStride;if(n.attributes){let e=0;for(let t of n.attributes)e+=Pe.getVertexFormatInfo(t.format).byteLength;return e}return Pe.getVertexFormatInfo(n.format).byteLength}var Jm=C(()=>{ut();za();Pa()});function $a(n,e){let t={},i=Qm(n,e,{warnOnMissingBufferLayout:!0});for(let r of i){let s=hI(n,r);t[r.attributeName]=s}return t}function hI(n,e){let t=pI(n,e.attributeName),i=kt.getAttributeShaderTypeInfo(t.type),r=e.vertexFormat,s=Pe.getVertexFormatInfo(r);return{attributeName:e.attributeName,bufferName:e.bufferName,location:t.location,shaderType:t.type,primitiveType:i.primitiveType,shaderComponents:i.components,vertexFormat:r,bufferDataType:s.type,bufferComponents:s.components,normalized:s.normalized,integer:i.integer,stepMode:e.stepMode,byteOffset:e.byteOffset,byteStride:e.byteStride}}function pI(n,e){let t=n.attributes.find(i=>i.name===e);return t||N.warn(`shader layout attribute "${e}" not present in shader`)(),t||null}var lw=C(()=>{ut();za();Pa();Jm()});var J=C(()=>{r0();s0();C0();R0();I0();Tu();zm();B0();O0();$m();Fm();z0();Gm();U0();$0();G0();W0();Vm();j0();H0();Y0();q0();Z0();X0();zu();cw();Au();Mu();za();Pa();Ou();ut();V0();Dm();Zm();lw();Jm()});function Ga(n=[],e){let t=[],i={},r={},s={},o={};for(let a of n)uw({modules:t,defines:i,injections:r,vertexInputs:s,varyings:o},a),uw({modules:t,defines:i,injections:r,vertexInputs:s,varyings:o},a[e]);for(let a of Object.keys(o))if(s[a])throw new Error(`ShaderPlugin name "${a}" cannot be both a vertex input and a varying`);return{modules:t,defines:i,injections:r,vertexInputs:s,varyings:o}}function Va(n=[],e=[]){let t=[...n],i=new Set(t.map(r=>r.name));for(let r of e)i.has(r.name)||(t.push(r),i.add(r.name));return t}function uw(n,e){if(e){e.modules?.length&&n.modules.push(...e.modules),e.defines&&Object.assign(n.defines,e.defines);for(let[t,i]of Object.entries(e.vertexInputs||{})){fw(t,"vertex input");let r=n.vertexInputs[t];if(r&&r!==i)throw new Error(`ShaderPlugin vertex input "${t}" has conflicting types "${r}" and "${i}"`);n.vertexInputs[t]=i}for(let[t,i]of Object.entries(e.varyings||{})){fw(t,"varying");let r=gI(t,i),s=n.varyings[t];if(s&&(s.type!==r.type||s.interpolation!==r.interpolation))throw new Error(`ShaderPlugin varying "${t}" has conflicting declarations "${s.type}/${s.interpolation}" and "${r.type}/${r.interpolation}"`);n.varyings[t]=r}for(let t of e.injections||[])_I(t.target),n.injections[t.target]||(n.injections[t.target]=[]),n.injections[t.target].push({injection:t.injection,order:t.order??0})}}function fw(n,e){if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(n)||n.startsWith("_luma_"))throw new Error(`ShaderPlugin ${e} "${n}" must be a valid non-reserved identifier`)}function gI(n,e){let{primitiveType:t}=kt.getAttributeShaderTypeInfo(e.type),i=t==="i32"||t==="u32",r=e.interpolation||(i?"flat":"smooth");if(i&&r==="smooth")throw new Error(`ShaderPlugin integer varying "${n}" must use flat interpolation`);return{type:e.type,interpolation:r}}function _I(n){if(!mI.test(n))throw new Error(`ShaderPlugin injection target "${n}" must be a named shader anchor or hook`)}var mI,dw=C(()=>{J();mI=/^(vs|fs):(?:#(?:decl|main-start|main-end)|[A-Za-z_][\w-]*)$/});function Wa(n){return`${n.name}Uniforms`}function pw(n,e){let t=e==="wgsl"?n.source:e==="vertex"?n.vs:n.fs;if(!t)return null;let i=Wa(n);return vI(t,e==="wgsl"?"wgsl":"glsl",i)}function mw(n,e){let t=Object.keys(n.uniformTypes||{});if(!t.length)return null;let i=pw(n,e);return i?{moduleName:n.name,uniformBlockName:Wa(n),stage:e,expectedUniformNames:t,actualUniformNames:i,matches:EI(t,i)}:null}function eg(n,e,t={}){let i=mw(n,e);if(!i||i.matches)return i;let r=SI(i);return t.log?.error?.(r,i)(),t.throwOnError!==!1&&yi(!1,r),i}function ja(n){let e=[],t=PI(n);for(let i of t.matchAll(bI)){let r=i[1]?.trim()||null;e.push({blockName:i[2],body:i[3],instanceName:i[4]||null,layoutQualifier:r,hasLayoutQualifier:!!r,isStd140:!!(r&&/\blayout\s*\([^)]*\bstd140\b[^)]*\)/.exec(r))})}return e}function tg(n,e,t,i){let r=ja(n).filter(o=>!o.isStd140),s=new Set;for(let o of r){if(s.has(o.blockName))continue;s.add(o.blockName);let a=i?.label?`${i.label} `:"",c=o.hasLayoutQualifier?`declares ${CI(o.layoutQualifier)} instead of layout(std140)`:"does not declare layout(std140)",l=`${a}${e} shader uniform block ${o.blockName} ${c}. luma.gl host-side shader block packing assumes explicit layout(std140) for GLSL uniform blocks. Add \`layout(std140)\` to the block declaration.`;t?.warn?.(l,o)()}return r}function vI(n,e,t){let i=e==="wgsl"?xI(n,t):wI(n,t);if(!i)return null;let r=[];for(let s of i.split(` +`)){let o=s.replace(/\/\/.*$/,"").trim();if(!o||o.startsWith("#"))continue;let a=e==="wgsl"?o.match(/^([A-Za-z0-9_]+)\s*:/):o.match(yI);a&&r.push(a[1])}return r}function xI(n,e){let t=new RegExp(`\\bstruct\\s+${e}\\b`,"m").exec(n);if(!t)return null;let i=n.indexOf("{",t.index);if(i<0)return null;let r=0;for(let s=i;si.blockName===e)?.body||null}function EI(n,e){if(n.length!==e.length)return!1;for(let t=0;t!t.includes(a)),r=t.filter(a=>!e.includes(a)),s=[`Expected ${e.length} fields, found ${t.length}.`],o=TI(e,t);return o&&s.push(o),i.length&&s.push(`Missing from shader block (${i.length}): ${hw(i)}.`),r.length&&s.push(`Unexpected in shader block (${r.length}): ${hw(r)}.`),e.length<=12&&t.length<=12&&(i.length||r.length)&&(s.push(`Expected: ${e.join(", ")}.`),s.push(`Actual: ${t.join(", ")}.`)),`${n.moduleName}: ${n.stage} shader uniform block ${n.uniformBlockName} does not match module.uniformTypes. ${s.join(" ")}`}function PI(n){return n.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"")}function CI(n){return n.replace(/\s+/g," ").trim()}function TI(n,e){let t=Math.min(n.length,e.length);for(let i=0;ie.length?`Shader block ends after field ${e.length}; expected next field ${n[e.length]}.`:e.length>n.length?`Shader block has extra field ${e.length}: ${e[n.length]}.`:null}function hw(n,e=8){if(n.length<=e)return n.join(", ");let t=n.length-e;return`${n.slice(0,e).join(", ")}, ... (${t} more)`}var yI,bI,ng=C(()=>{xu();yI=/^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/,bI=/((?:layout\s*\([^)]*\)\s*)*)uniform\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([\s\S]*?)\}\s*([A-Za-z_][A-Za-z0-9_]*)?\s*;/g});function gw(n){switch(n?.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU // Apple optimizes away the calculation necessary for emulated fp64 #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 @@ -62,72 +62,72 @@ ${s}${o}${n.type.toUpperCase()}: ${n.message} #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 // If the GPU doesn't have full 32 bits precision, will causes overflow #define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 -`}}var gw=C(()=>{});function yw(n,e){if(Number(n.match(/^#version[ \t]+(\d+)/m)?.[1]||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(e){case"vertex":return n=_w(n,PI),n;case"fragment":return n=_w(n,CI),n;default:throw new Error(e)}}function _w(n,e){for(let[t,i]of e)n=n.replace(t,i);return n}function ng(n){return new RegExp(`\\b${n}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}var bw,PI,CI,vw=C(()=>{bw=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es -`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],PI=[...bw,[ng("attribute"),"in $1"],[ng("varying"),"out $1"]],CI=[...bw,[ng("varying"),"in $1"]]});function Vu(n,e,t="glsl"){let i="";for(let r in n){let s=n[r];if(i+=`${t==="wgsl"?"fn":"void"} ${s.signature} { +`}}var _w=C(()=>{});function bw(n,e){if(Number(n.match(/^#version[ \t]+(\d+)/m)?.[1]||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(e){case"vertex":return n=yw(n,LI),n;case"fragment":return n=yw(n,MI),n;default:throw new Error(e)}}function yw(n,e){for(let[t,i]of e)n=n.replace(t,i);return n}function ig(n){return new RegExp(`\\b${n}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}var vw,LI,MI,xw=C(()=>{vw=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es +`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],LI=[...vw,[ig("attribute"),"in $1"],[ig("varying"),"out $1"]],MI=[...vw,[ig("varying"),"in $1"]]});function Wu(n,e,t="glsl"){let i="";for(let r in n){let s=n[r];if(i+=`${t==="wgsl"?"fn":"void"} ${s.signature} { `,s.header&&(i+=` ${s.header}`),e[r]){let a=e[r];a.sort((c,l)=>c.order-l.order);for(let c of a)i+=` ${c.injection} `}s.footer&&(i+=` ${s.footer}`),i+=`} -`}return i}function ig(n){let e={vertex:{},fragment:{}};for(let t of n){let i,r;typeof t!="string"?(i=t,r=i.hook):(i={},r=t),r=r.trim();let s=r.indexOf(":"),o=r.slice(0,s),a=r.slice(s+1),c=r.replace(/\(.+/,""),l=Object.assign(i,{signature:a});switch(o){case"vs":e.vertex[c]=l;break;case"fs":e.fragment[c]=l;break;default:throw new Error(o)}}return e}var xw=C(()=>{});function ww(n,e){return{name:TI(n,e),language:"glsl",version:LI(n)}}function TI(n,e="unnamed"){let i=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(n);return i?i[1]:e}function LI(n){let e=100,t=n.match(/[^\s]+/g);if(t&&t.length>=2&&t[0]==="#version"){let i=parseInt(t[1],10);Number.isFinite(i)&&(e=i)}if(e!==100&&e!==300)throw new Error(`Invalid GLSL version ${e}`);return e}var Ew=C(()=>{});function Wu(n,e=[]){let t=$s(n),i=new Map;for(let s of e)i.set(Pw(s.name,s.group,s.location),s.moduleName);let r=[];for(let s of Sw){s.lastIndex=0;let o;for(o=s.exec(t);o;){let a=s===Sw[0],c=Number(o[a?1:2]),l=Number(o[a?2:1]),u=o[3]?.trim(),f=o[4],d=o[5].trim(),h=i.get(Pw(f,l,c));r.push(MI({name:f,group:l,binding:c,owner:h?"module":"application",moduleName:h,accessDeclaration:u,resourceType:d})),o=s.exec(t)}}return r.sort((s,o)=>s.group!==o.group?s.group-o.group:s.binding!==o.binding?s.binding-o.binding:s.name.localeCompare(o.name))}function MI(n){let e={name:n.name,group:n.group,binding:n.binding,owner:n.owner,kind:"unknown",moduleName:n.moduleName,resourceType:n.resourceType};if(n.accessDeclaration){let t=n.accessDeclaration.split(",").map(i=>i.trim());if(t[0]==="uniform")return{...e,kind:"uniform",access:"uniform"};if(t[0]==="storage"){let i=t[1]||"read_write";return{...e,kind:i==="read"?"read-only-storage":"storage",access:i}}}return n.resourceType==="sampler"||n.resourceType==="sampler_comparison"?{...e,kind:"sampler",samplerKind:n.resourceType==="sampler_comparison"?"comparison":"filtering"}:n.resourceType.startsWith("texture_storage_")?{...e,kind:"storage-texture",access:kI(n.resourceType),viewDimension:Cw(n.resourceType)}:n.resourceType.startsWith("texture_")?{...e,kind:"texture",viewDimension:Cw(n.resourceType),sampleType:AI(n.resourceType),multisampled:n.resourceType.startsWith("texture_multisampled_")}:e}function Pw(n,e,t){return`${e}:${t}:${n}`}function Cw(n){if(n.includes("cube_array"))return"cube-array";if(n.includes("2d_array"))return"2d-array";if(n.includes("cube"))return"cube";if(n.includes("3d"))return"3d";if(n.includes("2d"))return"2d";if(n.includes("1d"))return"1d"}function AI(n){if(n.startsWith("texture_depth_"))return"depth";if(n.includes(""))return"sint";if(n.includes(""))return"uint";if(n.includes(""))return"float"}function kI(n){return/,\s*([A-Za-z_][A-Za-z0-9_]*)\s*>$/.exec(n)?.[1]}var Sw,rg=C(()=>{gu();Sw=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${Lt}\\s*:\\s*([^;]+);`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(\\d+)\\s*\\)\\s*${Lt}\\s*:\\s*([^;]+);`,"g")]});function zr(n,e){let t=n.split(` -`),i=[],r=[],s=!0;for(let o of t){let a=o.match(RI),c=o.match(NI)||o.match(II),l=o.match(BI),u=o.match(OI),f=o.match(FI)||o.match(DI);if(a){let d=zI(a[1],e?.defines||{}),h=s&&d;r.push({parentActive:s,branchTaken:d,active:h}),s=h}else if(c||l){let d=(c||l)?.[1],h=!!e?.defines?.[d],p=c?h:!h,m=s&&p;r.push({parentActive:s,branchTaken:p,active:m}),s=m}else if(u){let d=r[r.length-1];if(!d)throw new Error("Encountered #else without matching #if, #ifdef or #ifndef");d.active=d.parentActive&&!d.branchTaken,d.branchTaken=!0,s=d.active}else f?(r.pop(),s=r.length?r[r.length-1].active:!0):s&&i.push(o)}if(r.length>0)throw new Error("Unterminated conditional block in shader source");return i.join(` -`)}function zI(n,e){let t=n.trim();if(/^[+-]?\d+(?:\.\d+)?$/.test(t))return Number(t)!==0;if(t==="true")return!0;if(t==="false")return!1;let i=t.match(new RegExp(`^!\\s*${Fr}$`));if(i)return!e[i[1]];let r=t.match(new RegExp(`^${Fr}$`));if(r)return!!e[r[1]];let s=t.match(new RegExp(`^defined\\s*\\(\\s*${Fr}\\s*\\)$`));if(s)return e[s[1]]!==void 0;let o=t.match(new RegExp(`^!\\s*defined\\s*\\(\\s*${Fr}\\s*\\)$`));if(o)return e[o[1]]===void 0;throw new Error(`Unsupported #if expression "${n}"`)}var Fr,RI,II,BI,OI,DI,NI,FI,sg=C(()=>{Fr="([a-zA-Z_][a-zA-Z0-9_]*)",RI=/^\s*\#\s*if\s+(.+?)\s*(?:\/\/.*)?$/,II=new RegExp(`^\\s*\\#\\s*ifdef\\s*${Fr}\\s*$`),BI=new RegExp(`^\\s*\\#\\s*ifndef\\s*${Fr}\\s*(?:\\/\\/.*)?$`),OI=/^\s*\#\s*else\s*(?:\/\/.*)?$/,DI=/^\s*\#\s*endif\s*$/,NI=new RegExp(`^\\s*\\#\\s*ifdef\\s*${Fr}\\s*(?:\\/\\/.*)?$`),FI=/^\s*\#\s*endif\s*(?:\/\/.*)?$/});function Mw(n,e){let t=[];for(let[i,r]of Object.entries(e))UI(n,i),t.push(`in ${ju(r)} ${i};`);return t.join(` -`)}function Aw(n,e,t){let i=Object.entries(t);if(i.length===0)return{source:n,declarations:"",initialization:""};let r=$I(n,e),s=n.slice(r.openParenthesis+1,r.closeParenthesis),o=GI(n,s),a=new Set(o.locations),c=[],l=[],u=[];for(let[m,g]of i){if(o.names.has(m)||jI(n,m))throw new Error(`ShaderPlugin vertex input "${m}" conflicts with an existing WGSL shader input or variable`);let v=HI(a);a.add(v);let y=`_luma_${m}`;c.push(`@location(${v}) ${y}: ${g}`),l.push(`var ${m}: ${g};`),u.push(`${m} = ${y};`)}let f=s.trim()?`, +`}return i}function rg(n){let e={vertex:{},fragment:{}};for(let t of n){let i,r;typeof t!="string"?(i=t,r=i.hook):(i={},r=t),r=r.trim();let s=r.indexOf(":"),o=r.slice(0,s),a=r.slice(s+1),c=r.replace(/\(.+/,""),l=Object.assign(i,{signature:a});switch(o){case"vs":e.vertex[c]=l;break;case"fs":e.fragment[c]=l;break;default:throw new Error(o)}}return e}var ww=C(()=>{});function Ew(n,e){return{name:AI(n,e),language:"glsl",version:kI(n)}}function AI(n,e="unnamed"){let i=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(n);return i?i[1]:e}function kI(n){let e=100,t=n.match(/[^\s]+/g);if(t&&t.length>=2&&t[0]==="#version"){let i=parseInt(t[1],10);Number.isFinite(i)&&(e=i)}if(e!==100&&e!==300)throw new Error(`Invalid GLSL version ${e}`);return e}var Sw=C(()=>{});function ju(n,e=[]){let t=$s(n),i=new Map;for(let s of e)i.set(Cw(s.name,s.group,s.location),s.moduleName);let r=[];for(let s of Pw){s.lastIndex=0;let o;for(o=s.exec(t);o;){let a=s===Pw[0],c=Number(o[a?1:2]),l=Number(o[a?2:1]),u=o[3]?.trim(),f=o[4],d=o[5].trim(),h=i.get(Cw(f,l,c));r.push(RI({name:f,group:l,binding:c,owner:h?"module":"application",moduleName:h,accessDeclaration:u,resourceType:d})),o=s.exec(t)}}return r.sort((s,o)=>s.group!==o.group?s.group-o.group:s.binding!==o.binding?s.binding-o.binding:s.name.localeCompare(o.name))}function RI(n){let e={name:n.name,group:n.group,binding:n.binding,owner:n.owner,kind:"unknown",moduleName:n.moduleName,resourceType:n.resourceType};if(n.accessDeclaration){let t=n.accessDeclaration.split(",").map(i=>i.trim());if(t[0]==="uniform")return{...e,kind:"uniform",access:"uniform"};if(t[0]==="storage"){let i=t[1]||"read_write";return{...e,kind:i==="read"?"read-only-storage":"storage",access:i}}}return n.resourceType==="sampler"||n.resourceType==="sampler_comparison"?{...e,kind:"sampler",samplerKind:n.resourceType==="sampler_comparison"?"comparison":"filtering"}:n.resourceType.startsWith("texture_storage_")?{...e,kind:"storage-texture",access:BI(n.resourceType),viewDimension:Tw(n.resourceType)}:n.resourceType.startsWith("texture_")?{...e,kind:"texture",viewDimension:Tw(n.resourceType),sampleType:II(n.resourceType),multisampled:n.resourceType.startsWith("texture_multisampled_")}:e}function Cw(n,e,t){return`${e}:${t}:${n}`}function Tw(n){if(n.includes("cube_array"))return"cube-array";if(n.includes("2d_array"))return"2d-array";if(n.includes("cube"))return"cube";if(n.includes("3d"))return"3d";if(n.includes("2d"))return"2d";if(n.includes("1d"))return"1d"}function II(n){if(n.startsWith("texture_depth_"))return"depth";if(n.includes(""))return"sint";if(n.includes(""))return"uint";if(n.includes(""))return"float"}function BI(n){return/,\s*([A-Za-z_][A-Za-z0-9_]*)\s*>$/.exec(n)?.[1]}var Pw,sg=C(()=>{_u();Pw=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${At}\\s*:\\s*([^;]+);`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(\\d+)\\s*\\)\\s*${At}\\s*:\\s*([^;]+);`,"g")]});function zr(n,e){let t=n.split(` +`),i=[],r=[],s=!0;for(let o of t){let a=o.match(OI),c=o.match(UI)||o.match(DI),l=o.match(NI),u=o.match(FI),f=o.match($I)||o.match(zI);if(a){let d=GI(a[1],e?.defines||{}),h=s&&d;r.push({parentActive:s,branchTaken:d,active:h}),s=h}else if(c||l){let d=(c||l)?.[1],h=!!e?.defines?.[d],p=c?h:!h,m=s&&p;r.push({parentActive:s,branchTaken:p,active:m}),s=m}else if(u){let d=r[r.length-1];if(!d)throw new Error("Encountered #else without matching #if, #ifdef or #ifndef");d.active=d.parentActive&&!d.branchTaken,d.branchTaken=!0,s=d.active}else f?(r.pop(),s=r.length?r[r.length-1].active:!0):s&&i.push(o)}if(r.length>0)throw new Error("Unterminated conditional block in shader source");return i.join(` +`)}function GI(n,e){let t=n.trim();if(/^[+-]?\d+(?:\.\d+)?$/.test(t))return Number(t)!==0;if(t==="true")return!0;if(t==="false")return!1;let i=t.match(new RegExp(`^!\\s*${Fr}$`));if(i)return!e[i[1]];let r=t.match(new RegExp(`^${Fr}$`));if(r)return!!e[r[1]];let s=t.match(new RegExp(`^defined\\s*\\(\\s*${Fr}\\s*\\)$`));if(s)return e[s[1]]!==void 0;let o=t.match(new RegExp(`^!\\s*defined\\s*\\(\\s*${Fr}\\s*\\)$`));if(o)return e[o[1]]===void 0;throw new Error(`Unsupported #if expression "${n}"`)}var Fr,OI,DI,NI,FI,zI,UI,$I,og=C(()=>{Fr="([a-zA-Z_][a-zA-Z0-9_]*)",OI=/^\s*\#\s*if\s+(.+?)\s*(?:\/\/.*)?$/,DI=new RegExp(`^\\s*\\#\\s*ifdef\\s*${Fr}\\s*$`),NI=new RegExp(`^\\s*\\#\\s*ifndef\\s*${Fr}\\s*(?:\\/\\/.*)?$`),FI=/^\s*\#\s*else\s*(?:\/\/.*)?$/,zI=/^\s*\#\s*endif\s*$/,UI=new RegExp(`^\\s*\\#\\s*ifdef\\s*${Fr}\\s*(?:\\/\\/.*)?$`),$I=/^\s*\#\s*endif\s*(?:\/\/.*)?$/});function Aw(n,e){let t=[];for(let[i,r]of Object.entries(e))VI(n,i),t.push(`in ${Hu(r)} ${i};`);return t.join(` +`)}function kw(n,e,t){let i=Object.entries(t);if(i.length===0)return{source:n,declarations:"",initialization:""};let r=WI(n,e),s=n.slice(r.openParenthesis+1,r.closeParenthesis),o=jI(n,s),a=new Set(o.locations),c=[],l=[],u=[];for(let[m,g]of i){if(o.names.has(m)||qI(n,m))throw new Error(`ShaderPlugin vertex input "${m}" conflicts with an existing WGSL shader input or variable`);let v=ZI(a);a.add(v);let y=`_luma_${m}`;c.push(`@location(${v}) ${y}: ${g}`),l.push(`var ${m}: ${g};`),u.push(`${m} = ${y};`)}let f=s.trim()?`, `:` `,d=s.trim()?"":` `,h=`${s}${f}${c.join(`, `)}${d}`;return{source:n.slice(0,r.openParenthesis+1)+h+n.slice(r.closeParenthesis),declarations:l.join(` `),initialization:u.join(` -`)}}function ju(n){let{primitiveType:e,components:t}=Mt.getAttributeShaderTypeInfo(n),i=e==="i32"?"int":e==="u32"?"uint":"float";return t===1?i:`${i==="int"?"i":i==="uint"?"u":""}vec${t}`}function UI(n,e){let t=Hu(e);if(new RegExp(`\\b(?:in|attribute)\\s+(?:(?:lowp|mediump|highp)\\s+)?[A-Za-z_][A-Za-z0-9_]*\\s+${t}\\s*(?:\\[|;)`).test(n))throw new Error(`ShaderPlugin vertex input "${e}" conflicts with an existing GLSL input`)}function $I(n,e){let i=new RegExp(`\\bfn\\s+${Hu(e)}\\s*\\(`,"g").exec(n);if(!i)throw new Error(`ShaderPlugin vertex inputs require WGSL vertex entry point "${e}"`);let r=n.indexOf("(",i.index),s=kw(n,r,"(",")");if(s<0)throw new Error(`Unable to parse WGSL vertex entry point "${e}" parameters`);return{openParenthesis:r,closeParenthesis:s}}function GI(n,e){let t=Tw(e),i=new Set(Lw(e)),r=VI(e);for(let s of r){let o=WI(n,s);if(o!==null){t.push(...Tw(o));for(let a of Lw(o))i.add(a)}}return{locations:t,names:i}}function Tw(n){let e=[],t=/@location\s*\(\s*(\d+)\s*\)/g,i=t.exec(n);for(;i;)e.push(Number(i[1])),i=t.exec(n);return e}function Lw(n){let e=[],t=/(?:^|,)\s*(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:/gm,i=t.exec(n);for(;i;)e.push(i[1]),i=t.exec(n);return e}function VI(n){let e=[],t=/:\s*([A-Za-z_][\w]*)\b/g,i=t.exec(n);for(;i;)e.push(i[1]),i=t.exec(n);return e}function WI(n,e){let i=new RegExp(`\\bstruct\\s+${Hu(e)}\\s*\\{`,"g").exec(n);if(!i)return null;let r=n.indexOf("{",i.index),s=kw(n,r,"{","}");return s<0?null:n.slice(r+1,s)}function jI(n,e){let t=Hu(e),i=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${t}\\b`,"g"),r=i.exec(n);for(;r;){if(YI(n,r.index)===0)return!0;r=i.exec(n)}return!1}function HI(n){let e=0;for(;n.has(e);)e++;return e}function kw(n,e,t,i){let r=0,s=0,o=!1;for(let a=e;a0){c==="/"&&l==="*"?(s++,a++):c==="*"&&l==="/"&&(s--,a++);continue}if(c==="/"&&l==="/"){o=!0,a++;continue}if(c==="/"&&l==="*"){s=1,a++;continue}if(c===t&&r++,c===i&&--r===0)return a}return-1}function YI(n,e){let t=0,i=0,r=!1;for(let s=0;s0){o==="/"&&a==="*"?(i++,s++):o==="*"&&a==="/"&&(i--,s++);continue}o==="/"&&a==="/"?(r=!0,s++):o==="/"&&a==="*"?(i=1,s++):o==="{"?t++:o==="}"&&t--}return t}function Hu(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var og=C(()=>{ee()});function Iw(n,e,t){let i=[],r=[];for(let[s,o]of Object.entries(t)){oB(n,s);let a=o.interpolation==="flat"?"flat ":"",c=e==="vertex"?"out":"in";i.push(`${a}${c} ${ju(o.type)} ${s};`),e==="vertex"&&r.push(`${s} = ${rB(o.type)};`)}return{declarations:i.join(` +`)}}function Hu(n){let{primitiveType:e,components:t}=kt.getAttributeShaderTypeInfo(n),i=e==="i32"?"int":e==="u32"?"uint":"float";return t===1?i:`${i==="int"?"i":i==="uint"?"u":""}vec${t}`}function VI(n,e){let t=Yu(e);if(new RegExp(`\\b(?:in|attribute)\\s+(?:(?:lowp|mediump|highp)\\s+)?[A-Za-z_][A-Za-z0-9_]*\\s+${t}\\s*(?:\\[|;)`).test(n))throw new Error(`ShaderPlugin vertex input "${e}" conflicts with an existing GLSL input`)}function WI(n,e){let i=new RegExp(`\\bfn\\s+${Yu(e)}\\s*\\(`,"g").exec(n);if(!i)throw new Error(`ShaderPlugin vertex inputs require WGSL vertex entry point "${e}"`);let r=n.indexOf("(",i.index),s=Rw(n,r,"(",")");if(s<0)throw new Error(`Unable to parse WGSL vertex entry point "${e}" parameters`);return{openParenthesis:r,closeParenthesis:s}}function jI(n,e){let t=Lw(e),i=new Set(Mw(e)),r=HI(e);for(let s of r){let o=YI(n,s);if(o!==null){t.push(...Lw(o));for(let a of Mw(o))i.add(a)}}return{locations:t,names:i}}function Lw(n){let e=[],t=/@location\s*\(\s*(\d+)\s*\)/g,i=t.exec(n);for(;i;)e.push(Number(i[1])),i=t.exec(n);return e}function Mw(n){let e=[],t=/(?:^|,)\s*(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:/gm,i=t.exec(n);for(;i;)e.push(i[1]),i=t.exec(n);return e}function HI(n){let e=[],t=/:\s*([A-Za-z_][\w]*)\b/g,i=t.exec(n);for(;i;)e.push(i[1]),i=t.exec(n);return e}function YI(n,e){let i=new RegExp(`\\bstruct\\s+${Yu(e)}\\s*\\{`,"g").exec(n);if(!i)return null;let r=n.indexOf("{",i.index),s=Rw(n,r,"{","}");return s<0?null:n.slice(r+1,s)}function qI(n,e){let t=Yu(e),i=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${t}\\b`,"g"),r=i.exec(n);for(;r;){if(XI(n,r.index)===0)return!0;r=i.exec(n)}return!1}function ZI(n){let e=0;for(;n.has(e);)e++;return e}function Rw(n,e,t,i){let r=0,s=0,o=!1;for(let a=e;a0){c==="/"&&l==="*"?(s++,a++):c==="*"&&l==="/"&&(s--,a++);continue}if(c==="/"&&l==="/"){o=!0,a++;continue}if(c==="/"&&l==="*"){s=1,a++;continue}if(c===t&&r++,c===i&&--r===0)return a}return-1}function XI(n,e){let t=0,i=0,r=!1;for(let s=0;s0){o==="/"&&a==="*"?(i++,s++):o==="*"&&a==="/"&&(i--,s++);continue}o==="/"&&a==="/"?(r=!0,s++):o==="/"&&a==="*"?(i=1,s++):o==="{"?t++:o==="}"&&t--}return t}function Yu(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var ag=C(()=>{J()});function Bw(n,e,t){let i=[],r=[];for(let[s,o]of Object.entries(t)){lB(n,s);let a=o.interpolation==="flat"?"flat ":"",c=e==="vertex"?"out":"in";i.push(`${a}${c} ${Hu(o.type)} ${s};`),e==="vertex"&&r.push(`${s} = ${aB(o.type)};`)}return{declarations:i.join(` `),initialization:r.join(` -`)}}function Bw(n,e,t,i){let r=Object.entries(i);if(r.length===0)return{source:n,declarations:"",vertexInitialization:"",fragmentInitialization:""};let s=n,o=Yu(s,e,"vertex"),a=qI(s,o),c=Yu(s,t,"fragment"),l=ZI(s,c),u=ag(s,a),f=ag(s,l.type),d=new Set([...qu(o.parameters),...qu(u.body),...qu(c.parameters),...qu(f.body)]),h=new Set([...Rw(u.body),...Rw(f.body)]),p=[],m=[],g=[],v=[];for(let[E,x]of r){if(d.has(E)||nB(s,E))throw new Error(`ShaderPlugin varying "${E}" conflicts with existing WGSL stage I/O or a module variable`);let T=iB(h);h.add(T);let I=x.interpolation==="flat"?" @interpolate(flat)":"";p.push(` @location(${T})${I} ${E}: ${x.type},`),m.push(`var ${E}: ${x.type};`),g.push(`${E} = ${sB(x.type)};`),v.push(`${E} = ${l.name}.${E};`)}XI(s,a,o.openBrace,o.closeBrace),s=KI(s,a,o,r.map(([E])=>E)),o=Yu(s,e,"vertex"),s=QI(s,o,r.map(([E])=>E));let b=(a===l.type?[a]:[a,l.type]).map(E=>ag(s,E).closeBrace).sort((E,x)=>x-E);for(let E of b)s=s.slice(0,E)+`${p.join(` +`)}}function Ow(n,e,t,i){let r=Object.entries(i);if(r.length===0)return{source:n,declarations:"",vertexInitialization:"",fragmentInitialization:""};let s=n,o=qu(s,e,"vertex"),a=KI(s,o),c=qu(s,t,"fragment"),l=QI(s,c),u=cg(s,a),f=cg(s,l.type),d=new Set([...Zu(o.parameters),...Zu(u.body),...Zu(c.parameters),...Zu(f.body)]),h=new Set([...Iw(u.body),...Iw(f.body)]),p=[],m=[],g=[],v=[];for(let[E,w]of r){if(d.has(E)||sB(s,E))throw new Error(`ShaderPlugin varying "${E}" conflicts with existing WGSL stage I/O or a module variable`);let T=oB(h);h.add(T);let R=w.interpolation==="flat"?" @interpolate(flat)":"";p.push(` @location(${T})${R} ${E}: ${w.type},`),m.push(`var ${E}: ${w.type};`),g.push(`${E} = ${cB(w.type)};`),v.push(`${E} = ${l.name}.${E};`)}JI(s,a,o.openBrace,o.closeBrace),s=eB(s,a,o,r.map(([E])=>E)),o=qu(s,e,"vertex"),s=tB(s,o,r.map(([E])=>E));let b=(a===l.type?[a]:[a,l.type]).map(E=>cg(s,E).closeBrace).sort((E,w)=>w-E);for(let E of b)s=s.slice(0,E)+`${p.join(` `)} -`+s.slice(E);if(c=Yu(s,t,"fragment"),!new RegExp(`\\b${Ur(l.name)}\\s*:`).test(c.parameters))throw new Error(`Unable to preserve WGSL fragment input "${l.name}"`);return{source:s,declarations:m.join(` +`+s.slice(E);if(c=qu(s,t,"fragment"),!new RegExp(`\\b${Ur(l.name)}\\s*:`).test(c.parameters))throw new Error(`Unable to preserve WGSL fragment input "${l.name}"`);return{source:s,declarations:m.join(` `),vertexInitialization:g.join(` `),fragmentInitialization:v.join(` -`)}}function Yu(n,e,t){let r=new RegExp(`\\bfn\\s+${Ur(e)}\\s*\\(`,"g").exec(n);if(!r)throw new Error(`ShaderPlugin varyings require WGSL ${t} entry point "${e}"`);let s=n.indexOf("(",r.index),o=Zu(n,s,"(",")"),a=n.indexOf("{",o),c=Zu(n,a,"{","}");if(o<0||a<0||c<0)throw new Error(`Unable to parse WGSL ${t} entry point "${e}"`);return{openParenthesis:s,closeParenthesis:o,openBrace:a,closeBrace:c,parameters:n.slice(s+1,o)}}function qI(n,e){let t=n.slice(e.closeParenthesis+1,e.openBrace),i=/->\s*([A-Za-z_][\w]*)\s*$/.exec(t.trim());if(!i||cg(n,i[1])===null)throw new Error("ShaderPlugin varyings require the WGSL vertex entry point to return a named struct");return i[1]}function ZI(n,e){let t=[];for(let i of tB(e.parameters,",")){let r=/(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:\s*([A-Za-z_][\w]*)\s*$/.exec(i.trim());r&&cg(n,r[2])&&t.push({name:r[1],type:r[2]})}if(t.length!==1)throw new Error(`ShaderPlugin varyings require exactly one named WGSL fragment input struct; found ${t.length}`);return t[0]}function ag(n,e){let t=cg(n,e);if(!t)throw new Error(`Unable to find WGSL stage I/O struct "${e}"`);return t}function cg(n,e){let i=new RegExp(`\\bstruct\\s+${Ur(e)}\\s*\\{`,"g").exec(n);if(!i)return null;let r=n.indexOf("{",i.index),s=Zu(n,r,"{","}");return s<0?null:{openBrace:r,closeBrace:s,body:n.slice(r+1,s)}}function XI(n,e,t,i){let r=new RegExp(`\\b${Ur(e)}\\s*\\(`,"g"),s=r.exec(n);for(;s;){if(s.indexi)throw new Error(`ShaderPlugin varying output struct "${e}" is constructed outside the selected vertex entry point`);s=r.exec(n)}}function KI(n,e,t,i){let r=new RegExp(`\\b${Ur(e)}\\s*\\(`,"g"),s=[],o=r.exec(n);for(;o;){if(o.index>t.openBrace&&o.indext.closeBrace)throw new Error(`Unable to parse WGSL output constructor "${e}"`);s.push({openParenthesis:a,closeParenthesis:c})}o=r.exec(n)}for(let a of s.sort((c,l)=>l.closeParenthesis-c.closeParenthesis)){let l=n.slice(a.openParenthesis+1,a.closeParenthesis).trim()?", ":"";n=n.slice(0,a.closeParenthesis)+l+i.join(", ")+n.slice(a.closeParenthesis)}return n}function QI(n,e,t){let i=JI(n,e.openBrace+1,e.closeBrace);for(let r=i.length-1;r>=0;r--){let s=i[r],o=n.slice(s.expressionStart,s.semicolon).trim();if(!o)throw new Error("ShaderPlugin varying vertex entry point cannot use an empty return");let a=`_luma_vertexOutput${r}`,c=t.map(u=>`${a}.${u} = ${u};`).join(` +`)}}function qu(n,e,t){let r=new RegExp(`\\bfn\\s+${Ur(e)}\\s*\\(`,"g").exec(n);if(!r)throw new Error(`ShaderPlugin varyings require WGSL ${t} entry point "${e}"`);let s=n.indexOf("(",r.index),o=Xu(n,s,"(",")"),a=n.indexOf("{",o),c=Xu(n,a,"{","}");if(o<0||a<0||c<0)throw new Error(`Unable to parse WGSL ${t} entry point "${e}"`);return{openParenthesis:s,closeParenthesis:o,openBrace:a,closeBrace:c,parameters:n.slice(s+1,o)}}function KI(n,e){let t=n.slice(e.closeParenthesis+1,e.openBrace),i=/->\s*([A-Za-z_][\w]*)\s*$/.exec(t.trim());if(!i||lg(n,i[1])===null)throw new Error("ShaderPlugin varyings require the WGSL vertex entry point to return a named struct");return i[1]}function QI(n,e){let t=[];for(let i of rB(e.parameters,",")){let r=/(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:\s*([A-Za-z_][\w]*)\s*$/.exec(i.trim());r&&lg(n,r[2])&&t.push({name:r[1],type:r[2]})}if(t.length!==1)throw new Error(`ShaderPlugin varyings require exactly one named WGSL fragment input struct; found ${t.length}`);return t[0]}function cg(n,e){let t=lg(n,e);if(!t)throw new Error(`Unable to find WGSL stage I/O struct "${e}"`);return t}function lg(n,e){let i=new RegExp(`\\bstruct\\s+${Ur(e)}\\s*\\{`,"g").exec(n);if(!i)return null;let r=n.indexOf("{",i.index),s=Xu(n,r,"{","}");return s<0?null:{openBrace:r,closeBrace:s,body:n.slice(r+1,s)}}function JI(n,e,t,i){let r=new RegExp(`\\b${Ur(e)}\\s*\\(`,"g"),s=r.exec(n);for(;s;){if(s.indexi)throw new Error(`ShaderPlugin varying output struct "${e}" is constructed outside the selected vertex entry point`);s=r.exec(n)}}function eB(n,e,t,i){let r=new RegExp(`\\b${Ur(e)}\\s*\\(`,"g"),s=[],o=r.exec(n);for(;o;){if(o.index>t.openBrace&&o.indext.closeBrace)throw new Error(`Unable to parse WGSL output constructor "${e}"`);s.push({openParenthesis:a,closeParenthesis:c})}o=r.exec(n)}for(let a of s.sort((c,l)=>l.closeParenthesis-c.closeParenthesis)){let l=n.slice(a.openParenthesis+1,a.closeParenthesis).trim()?", ":"";n=n.slice(0,a.closeParenthesis)+l+i.join(", ")+n.slice(a.closeParenthesis)}return n}function tB(n,e,t){let i=nB(n,e.openBrace+1,e.closeBrace);for(let r=i.length-1;r>=0;r--){let s=i[r],o=n.slice(s.expressionStart,s.semicolon).trim();if(!o)throw new Error("ShaderPlugin varying vertex entry point cannot use an empty return");let a=`_luma_vertexOutput${r}`,c=t.map(u=>`${a}.${u} = ${u};`).join(` `),l=`{ var ${a} = ${o}; ${c} return ${a}; -}`;n=n.slice(0,s.start)+l+n.slice(s.semicolon+1)}return n}function JI(n,e,t){let i=[],r=e;for(;rt?t:r+1}if(n[i]==="/"&&n[i+1]==="*"){let r=1;for(i+=2;i0;)n[i]==="/"&&n[i+1]==="*"?(r++,i+=2):n[i]==="*"&&n[i+1]==="/"?(r--,i+=2):i++}return i}function tB(n,e){let t=[],i=0,r=0,s=0;for(let o=0;o"&&s--,a===e&&r===0&&s===0&&(t.push(n.slice(i,o)),i=o+1)}return t.push(n.slice(i)),t}function Rw(n){let e=[],t=/@location\s*\(\s*(\d+)\s*\)/g,i=t.exec(n);for(;i;)e.push(Number(i[1])),i=t.exec(n);return e}function qu(n){let e=[],t=/(?:^|,)\s*(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:/gm,i=t.exec(n);for(;i;)e.push(i[1]),i=t.exec(n);return e}function nB(n,e){let t=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${Ur(e)}\\b`,"g"),i=t.exec(n);for(;i;){if(aB(n,i.index)===0)return!0;i=t.exec(n)}return!1}function iB(n){let e=0;for(;n.has(e);)e++;return e}function rB(n){let{primitiveType:e,components:t}=Mt.getAttributeShaderTypeInfo(n),i=e==="u32"?"0u":e==="i32"?"0":"0.0";return t===1?i:`${ju(n)}(${i})`}function sB(n){let{primitiveType:e,components:t}=Mt.getAttributeShaderTypeInfo(n),i=`${e}(0)`;return t===1?i:`${n}(${i})`}function oB(n,e){if(new RegExp(`\\b(?:flat\\s+|smooth\\s+)?(?:in|out|varying)\\s+(?:(?:lowp|mediump|highp)\\s+)?[A-Za-z_][A-Za-z0-9_]*\\s+${Ur(e)}\\s*(?:\\[|;)`).test(n))throw new Error(`ShaderPlugin varying "${e}" conflicts with existing GLSL stage I/O`)}function Zu(n,e,t,i){let r=0,s=0,o=!1;for(let a=e;a0){c==="/"&&l==="*"?(s++,a++):c==="*"&&l==="/"&&(s--,a++);continue}if(c==="/"&&l==="/"){o=!0,a++;continue}if(c==="/"&&l==="*"){s=1,a++;continue}if(c===t&&r++,c===i&&--r===0)return a}return-1}function aB(n,e){let t=0;for(let i=0;i{ee();og()});function Fw(n){let e=Cr(n.modules||[]),{source:t,bindingAssignments:i}=lB(n.platformInfo,{...n,source:n.source,stage:"vertex",modules:e});return{source:t,getUniforms:Uw(e),bindingAssignments:i,bindingTable:Wu(t,i),shaderLayout:yu(t,{vertexEntryPoint:n.vertexEntryPoint,scanVertexAttributes:n.scanVertexAttributes})}}function zw(n){let{vs:e,fs:t}=n,i=Cr(n.modules||[]);return{vs:Dw(n.platformInfo,{...n,source:e,stage:"vertex",modules:i}),fs:Dw(n.platformInfo,{...n,source:t,stage:"fragment",modules:i}),getUniforms:Uw(i)}}function lB(n,e){let{source:t,stage:i,modules:r,defines:s={},hookFunctions:o=[],inject:a={},pluginInjections:c={},pluginVertexInputs:l={},pluginVaryings:u={},vertexEntryPoint:f="vertexMain",fragmentEntryPoint:d="fragmentMain",log:h}=e;hi(typeof t=="string","shader source must be a string");let p=zr(t,{defines:s}),m=Aw(p,f,l),g=Bw(m.source,f,d,u),v=g.source,y="",b=ig(o),w={},E={},x={};$w(c,w,E,x);for(let W in a){let V=typeof a[W]=="string"?{injection:a[W],order:0}:a[W],X=/^(v|f)s:(#)?([\w-]+)$/.exec(W);if(X){let Y=X[2],ie=X[3];Y?ie==="decl"?E[W]=[V]:x[W]=[V]:w[W]=[V]}else x[W]=[V]}uB(m.declarations,m.initialization,E,x),fB(g,E,x);let T=r,I=_B(v),N=gB(I.source),D=xB(T,e._bindingRegistry,N,s),H=[];for(let W of T){h&&mm(W,v,h);let V=zr(Gw(W,"wgsl",h),{defines:s}),X=yB(V,W,{usedBindingsByGroup:N,bindingRegistry:e._bindingRegistry,reservedBindingKeysByGroup:D});H.push(...X.bindingAssignments);let Y=X.source;y+=Y;let ie=dB(W);for(let oe in ie){let zt=/^(v|f)s:#([\w-]+)$/.exec(oe);if(zt){let sn=zt[2]==="decl"?E:x;sn[oe]=sn[oe]||[],sn[oe].push(ie[oe])}else w[oe]=w[oe]||[],w[oe].push(ie[oe])}}return y+=ug,y=xa(y,i,hB(E),!1,"wgsl",{vertex:f,fragment:d}),y+=pB(b,w),y+=TB(H),y+=I.source,y=xa(y,i,x,!1,"wgsl",{vertex:f,fragment:d}),CB(y),{source:y,bindingAssignments:H}}function Dw(n,e){let{source:t,stage:i,language:r="glsl",modules:s,defines:o={},hookFunctions:a=[],inject:c={},pluginInjections:l={},pluginVertexInputs:u={},pluginVaryings:f={},prologue:d=!0,log:h}=e;hi(typeof t=="string","shader source must be a string");let p=r==="glsl"?ww(t).version:-1,m=n.shaderLanguageVersion,g=p===100?"#version 100":"#version 300 es",y=t.split(` +}`;n=n.slice(0,s.start)+l+n.slice(s.semicolon+1)}return n}function nB(n,e,t){let i=[],r=e;for(;rt?t:r+1}if(n[i]==="/"&&n[i+1]==="*"){let r=1;for(i+=2;i0;)n[i]==="/"&&n[i+1]==="*"?(r++,i+=2):n[i]==="*"&&n[i+1]==="/"?(r--,i+=2):i++}return i}function rB(n,e){let t=[],i=0,r=0,s=0;for(let o=0;o"&&s--,a===e&&r===0&&s===0&&(t.push(n.slice(i,o)),i=o+1)}return t.push(n.slice(i)),t}function Iw(n){let e=[],t=/@location\s*\(\s*(\d+)\s*\)/g,i=t.exec(n);for(;i;)e.push(Number(i[1])),i=t.exec(n);return e}function Zu(n){let e=[],t=/(?:^|,)\s*(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:/gm,i=t.exec(n);for(;i;)e.push(i[1]),i=t.exec(n);return e}function sB(n,e){let t=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${Ur(e)}\\b`,"g"),i=t.exec(n);for(;i;){if(uB(n,i.index)===0)return!0;i=t.exec(n)}return!1}function oB(n){let e=0;for(;n.has(e);)e++;return e}function aB(n){let{primitiveType:e,components:t}=kt.getAttributeShaderTypeInfo(n),i=e==="u32"?"0u":e==="i32"?"0":"0.0";return t===1?i:`${Hu(n)}(${i})`}function cB(n){let{primitiveType:e,components:t}=kt.getAttributeShaderTypeInfo(n),i=`${e}(0)`;return t===1?i:`${n}(${i})`}function lB(n,e){if(new RegExp(`\\b(?:flat\\s+|smooth\\s+)?(?:in|out|varying)\\s+(?:(?:lowp|mediump|highp)\\s+)?[A-Za-z_][A-Za-z0-9_]*\\s+${Ur(e)}\\s*(?:\\[|;)`).test(n))throw new Error(`ShaderPlugin varying "${e}" conflicts with existing GLSL stage I/O`)}function Xu(n,e,t,i){let r=0,s=0,o=!1;for(let a=e;a0){c==="/"&&l==="*"?(s++,a++):c==="*"&&l==="/"&&(s--,a++);continue}if(c==="/"&&l==="/"){o=!0,a++;continue}if(c==="/"&&l==="*"){s=1,a++;continue}if(c===t&&r++,c===i&&--r===0)return a}return-1}function uB(n,e){let t=0;for(let i=0;i{J();ag()});function zw(n){let e=Cr(n.modules||[]),{source:t,bindingAssignments:i}=dB(n.platformInfo,{...n,source:n.source,stage:"vertex",modules:e});return{source:t,getUniforms:$w(e),bindingAssignments:i,bindingTable:ju(t,i),shaderLayout:bu(t,{vertexEntryPoint:n.vertexEntryPoint,scanVertexAttributes:n.scanVertexAttributes})}}function Uw(n){let{vs:e,fs:t}=n,i=Cr(n.modules||[]);return{vs:Nw(n.platformInfo,{...n,source:e,stage:"vertex",modules:i}),fs:Nw(n.platformInfo,{...n,source:t,stage:"fragment",modules:i}),getUniforms:$w(i)}}function dB(n,e){let{source:t,stage:i,modules:r,defines:s={},hookFunctions:o=[],inject:a={},pluginInjections:c={},pluginVertexInputs:l={},pluginVaryings:u={},vertexEntryPoint:f="vertexMain",fragmentEntryPoint:d="fragmentMain",log:h}=e;yi(typeof t=="string","shader source must be a string");let p=zr(t,{defines:s}),m=kw(p,f,l),g=Ow(m.source,f,d,u),v=g.source,y="",b=rg(o),x={},E={},w={};Gw(c,x,E,w);for(let V in a){let G=typeof a[V]=="string"?{injection:a[V],order:0}:a[V],q=/^(v|f)s:(#)?([\w-]+)$/.exec(V);if(q){let X=q[2],se=q[3];X?se==="decl"?E[V]=[G]:w[V]=[G]:x[V]=[G]}else w[V]=[G]}hB(m.declarations,m.initialization,E,w),pB(g,E,w);let T=r,R=vB(v),F=bB(R.source),O=SB(T,e._bindingRegistry,F,s),j=[];for(let V of T){h&&gm(V,v,h);let G=zr(Vw(V,"wgsl",h),{defines:s}),q=xB(G,V,{usedBindingsByGroup:F,bindingRegistry:e._bindingRegistry,reservedBindingKeysByGroup:O});j.push(...q.bindingAssignments);let X=q.source;y+=X;let se=mB(V);for(let le in se){let he=/^(v|f)s:#([\w-]+)$/.exec(le);if(he){let Ct=he[2]==="decl"?E:w;Ct[le]=Ct[le]||[],Ct[le].push(se[le])}else x[le]=x[le]||[],x[le].push(se[le])}}return y+=fg,y=wa(y,i,gB(E),!1,"wgsl",{vertex:f,fragment:d}),y+=_B(b,x),y+=AB(j),y+=R.source,y=wa(y,i,w,!1,"wgsl",{vertex:f,fragment:d}),MB(y),{source:y,bindingAssignments:j}}function Nw(n,e){let{source:t,stage:i,language:r="glsl",modules:s,defines:o={},hookFunctions:a=[],inject:c={},pluginInjections:l={},pluginVertexInputs:u={},pluginVaryings:f={},prologue:d=!0,log:h}=e;yi(typeof t=="string","shader source must be a string");let p=r==="glsl"?Ew(t).version:-1,m=n.shaderLanguageVersion,g=p===100?"#version 100":"#version 300 es",y=t.split(` `).slice(1).join(` -`),b={};s.forEach(D=>{Object.assign(b,D.defines)}),Object.assign(b,o);let w="";switch(r){case"wgsl":break;case"glsl":w=d?`${g} +`),b={};s.forEach(O=>{Object.assign(b,O.defines)}),Object.assign(b,o);let x="";switch(r){case"wgsl":break;case"glsl":x=d?`${g} // ----- PROLOGUE ------------------------- ${`#define SHADER_TYPE_${i.toUpperCase()}`} -${mw(n)} -${i==="fragment"?cB:""} +${gw(n)} +${i==="fragment"?fB:""} // ----- APPLICATION DEFINES ------------------------- -${mB(b)} +${yB(b)} `:`${g} -`;break}let E=ig(a),x={},T={},I={};$w(l,x,T,I);for(let D in c){let H=typeof c[D]=="string"?{injection:c[D],order:0}:c[D],W=/^(v|f)s:(#)?([\w-]+)$/.exec(D);if(W){let V=W[2],X=W[3];V?X==="decl"?T[D]=[H]:I[D]=[H]:x[D]=[H]}else I[D]=[H]}if(i==="vertex"){let D=Mw(y,u);D&&(T["vs:#decl"]=T["vs:#decl"]||[],T["vs:#decl"].push({injection:D,order:Number.MIN_SAFE_INTEGER}))}let N=Iw(y,i,f);if(N.declarations){let D=i==="vertex"?"vs:#decl":"fs:#decl";T[D]=T[D]||[],T[D].push({injection:N.declarations,order:Number.MIN_SAFE_INTEGER})}N.initialization&&(I["vs:#main-start"]=I["vs:#main-start"]||[],I["vs:#main-start"].push({injection:N.initialization,order:Number.MIN_SAFE_INTEGER}));for(let D of s){h&&mm(D,y,h);let H=Gw(D,i,h);w+=H;let W=D.instance?.normalizedInjections[i]||{};for(let V in W){let X=/^(v|f)s:#([\w-]+)$/.exec(V);if(X){let ie=X[2]==="decl"?T:I;ie[V]=ie[V]||[],ie[V].push(W[V])}else x[V]=x[V]||[],x[V].push(W[V])}}return w+="// ----- MAIN SHADER SOURCE -------------------------",w+=ug,w=xa(w,i,T),w+=Vu(E[i],x),w+=y,w=xa(w,i,I),r==="glsl"&&p!==m&&(w=yw(w,i)),r==="glsl"&&eg(w,i,h),w.trim()}function Uw(n){return function(t){let i={};for(let r of n){let s=r.getUniforms?.(t,i);Object.assign(i,s)}return i}}function $w(n,e,t,i){for(let r in n){let s=/^(v|f)s:(#)?([\w-]+)$/.exec(r);if(s){let o=s[2],a=s[3],c=o?a==="decl"?t:i:e;c[r]=c[r]||[],c[r].push(...n[r])}else i[r]=i[r]||[],i[r].push(...n[r])}}function uB(n,e,t,i){n&&(t["vs:#decl"]=t["vs:#decl"]||[],t["vs:#decl"].push({injection:n,order:Number.MIN_SAFE_INTEGER})),e&&(i["vs:#main-start"]=i["vs:#main-start"]||[],i["vs:#main-start"].push({injection:e,order:Number.MIN_SAFE_INTEGER}))}function fB(n,e,t){n.declarations&&(e["vs:#decl"]=e["vs:#decl"]||[],e["vs:#decl"].push({injection:n.declarations,order:Number.MIN_SAFE_INTEGER})),n.vertexInitialization&&(t["vs:#main-start"]=t["vs:#main-start"]||[],t["vs:#main-start"].push({injection:n.vertexInitialization,order:Number.MIN_SAFE_INTEGER})),n.fragmentInitialization&&(t["fs:#main-start"]=t["fs:#main-start"]||[],t["fs:#main-start"].push({injection:n.fragmentInitialization,order:Number.MIN_SAFE_INTEGER}))}function dB(n){return{...n.instance?.normalizedInjections.vertex||{},...n.instance?.normalizedInjections.fragment||{}}}function hB(n){let e=[...n["vs:#decl"]||[],...n["fs:#decl"]||[]];return e.length?{"vs:#decl":e}:{}}function pB(n,e){return Vu(n.vertex,e,"wgsl")+Vu(n.fragment,e,"wgsl")}function mB(n={}){let e="";for(let t in n){let i=n[t];(i||Number.isFinite(i))&&(e+=`#define ${t.toUpperCase()} ${n[t]} -`)}return e}function Gw(n,e,t){let i;switch(e){case"vertex":i=n.vs||"";break;case"fragment":i=n.fs||"";break;case"wgsl":i=n.source||"";break;default:hi(!1)}if(!n.name)throw new Error("Shader module must have a name");Jm(n,e,{log:t});let r=n.name.toUpperCase().replace(/[^0-9a-z]/gi,"_"),s=`// ----- MODULE ${n.name} --------------- +`;break}let E=rg(a),w={},T={},R={};Gw(l,w,T,R);for(let O in c){let j=typeof c[O]=="string"?{injection:c[O],order:0}:c[O],V=/^(v|f)s:(#)?([\w-]+)$/.exec(O);if(V){let G=V[2],q=V[3];G?q==="decl"?T[O]=[j]:R[O]=[j]:w[O]=[j]}else R[O]=[j]}if(i==="vertex"){let O=Aw(y,u);O&&(T["vs:#decl"]=T["vs:#decl"]||[],T["vs:#decl"].push({injection:O,order:Number.MIN_SAFE_INTEGER}))}let F=Bw(y,i,f);if(F.declarations){let O=i==="vertex"?"vs:#decl":"fs:#decl";T[O]=T[O]||[],T[O].push({injection:F.declarations,order:Number.MIN_SAFE_INTEGER})}F.initialization&&(R["vs:#main-start"]=R["vs:#main-start"]||[],R["vs:#main-start"].push({injection:F.initialization,order:Number.MIN_SAFE_INTEGER}));for(let O of s){h&&gm(O,y,h);let j=Vw(O,i,h);x+=j;let V=O.instance?.normalizedInjections[i]||{};for(let G in V){let q=/^(v|f)s:#([\w-]+)$/.exec(G);if(q){let se=q[2]==="decl"?T:R;se[G]=se[G]||[],se[G].push(V[G])}else w[G]=w[G]||[],w[G].push(V[G])}}return x+="// ----- MAIN SHADER SOURCE -------------------------",x+=fg,x=wa(x,i,T),x+=Wu(E[i],w),x+=y,x=wa(x,i,R),r==="glsl"&&p!==m&&(x=bw(x,i)),r==="glsl"&&tg(x,i,h),x.trim()}function $w(n){return function(t){let i={};for(let r of n){let s=r.getUniforms?.(t,i);Object.assign(i,s)}return i}}function Gw(n,e,t,i){for(let r in n){let s=/^(v|f)s:(#)?([\w-]+)$/.exec(r);if(s){let o=s[2],a=s[3],c=o?a==="decl"?t:i:e;c[r]=c[r]||[],c[r].push(...n[r])}else i[r]=i[r]||[],i[r].push(...n[r])}}function hB(n,e,t,i){n&&(t["vs:#decl"]=t["vs:#decl"]||[],t["vs:#decl"].push({injection:n,order:Number.MIN_SAFE_INTEGER})),e&&(i["vs:#main-start"]=i["vs:#main-start"]||[],i["vs:#main-start"].push({injection:e,order:Number.MIN_SAFE_INTEGER}))}function pB(n,e,t){n.declarations&&(e["vs:#decl"]=e["vs:#decl"]||[],e["vs:#decl"].push({injection:n.declarations,order:Number.MIN_SAFE_INTEGER})),n.vertexInitialization&&(t["vs:#main-start"]=t["vs:#main-start"]||[],t["vs:#main-start"].push({injection:n.vertexInitialization,order:Number.MIN_SAFE_INTEGER})),n.fragmentInitialization&&(t["fs:#main-start"]=t["fs:#main-start"]||[],t["fs:#main-start"].push({injection:n.fragmentInitialization,order:Number.MIN_SAFE_INTEGER}))}function mB(n){return{...n.instance?.normalizedInjections.vertex||{},...n.instance?.normalizedInjections.fragment||{}}}function gB(n){let e=[...n["vs:#decl"]||[],...n["fs:#decl"]||[]];return e.length?{"vs:#decl":e}:{}}function _B(n,e){return Wu(n.vertex,e,"wgsl")+Wu(n.fragment,e,"wgsl")}function yB(n={}){let e="";for(let t in n){let i=n[t];(i||Number.isFinite(i))&&(e+=`#define ${t.toUpperCase()} ${n[t]} +`)}return e}function Vw(n,e,t){let i;switch(e){case"vertex":i=n.vs||"";break;case"fragment":i=n.fs||"";break;case"wgsl":i=n.source||"";break;default:yi(!1)}if(!n.name)throw new Error("Shader module must have a name");eg(n,e,{log:t});let r=n.name.toUpperCase().replace(/[^0-9a-z]/gi,"_"),s=`// ----- MODULE ${n.name} --------------- `;return e!=="wgsl"&&(s+=`#define MODULE_${r} `),s+=`${i} -`,s}function gB(n){let e=new Map;for(let t of Pr(n,Nx)){let i=Number(t.bindingToken),r=Number(t.groupToken);fg(r,i,t.name),Zs(e,r,i,`application binding "${t.name}"`)}return e}function _B(n){let e=Pr(n,mu),t=new Map;for(let s of e){if(s.bindingToken==="auto")continue;let o=Number(s.bindingToken),a=Number(s.groupToken);fg(a,o,s.name),Zs(t,a,o,`application binding "${s.name}"`)}let i={sawSupportedBindingDeclaration:e.length>0},r=sm(n,mu,s=>vB(s,t,i));if(om(n)&&!i.sawSupportedBindingDeclaration)throw new Error('Unsupported @binding(auto) declaration form in application WGSL. Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.');return{source:r}}function yB(n,e,t){let i=[],s={sawSupportedBindingDeclaration:Pr(n,Us).length>0,nextHintedBindingLocation:typeof e.firstBindingSlot=="number"?e.firstBindingSlot:null},o=sm(n,Us,a=>bB(a,{module:e,context:t,bindingAssignments:i,relocationState:s}));if(om(n)&&!s.sawSupportedBindingDeclaration)throw new Error(`Unsupported @binding(auto) declaration form in module "${e.name}". Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.`);return{source:o,bindingAssignments:i}}function bB(n,e){let{module:t,context:i,bindingAssignments:r,relocationState:s}=e,{match:o,bindingToken:a,groupToken:c,name:l}=n,u=Number(c);if(a==="auto"){let d=Vw(u,t.name,l),h=i.bindingRegistry?.get(d),p=h!==void 0?h:SB(u,i.usedBindingsByGroup,t.name,s.nextHintedBindingLocation??void 0,i.bindingRegistry);return Nw(t.name,u,p,l),h!==void 0&&wB(i.reservedBindingKeysByGroup,u,p,d)?(r.push({moduleName:t.name,name:l,group:u,location:p}),o.replace(/@binding\(\s*auto\s*\)/,`@binding(${p})`)):(Zs(i.usedBindingsByGroup,u,p,`module "${t.name}" binding "${l}"`),i.bindingRegistry?.set(d,p),r.push({moduleName:t.name,name:l,group:u,location:p}),s.nextHintedBindingLocation!==null&&h===void 0&&(s.nextHintedBindingLocation=p+1),o.replace(/@binding\(\s*auto\s*\)/,`@binding(${p})`))}let f=Number(a);return Nw(t.name,u,f,l),Zs(i.usedBindingsByGroup,u,f,`module "${t.name}" binding "${l}"`),r.push({moduleName:t.name,name:l,group:u,location:f}),o}function vB(n,e,t){let{match:i,bindingToken:r,groupToken:s,name:o}=n,a=Number(s);if(r==="auto"){let c=PB(a,e);return fg(a,c,o),Zs(e,a,c,`application binding "${o}"`),i.replace(/@binding\(\s*auto\s*\)/,`@binding(${c})`)}return t.sawSupportedBindingDeclaration=!0,i}function xB(n,e,t,i){let r=new Map;if(!e)return r;for(let s of n)for(let o of EB(s,i)){let a=Vw(o.group,s.name,o.name),c=e.get(a);if(c!==void 0){let l=r.get(o.group)||new Map,u=l.get(c);if(u&&u!==a)throw new Error(`Duplicate WGSL binding reservation for modules "${u}" and "${a}": group ${o.group}, binding ${c}.`);Zs(t,o.group,c,`registered module binding "${a}"`),l.set(c,a),r.set(o.group,l)}}return r}function wB(n,e,t,i){let r=n.get(e);if(!r)return!1;let s=r.get(t);if(!s)return!1;if(s!==i)throw new Error(`Registered module binding "${i}" collided with "${s}": group ${e}, binding ${t}.`);return!0}function EB(n,e){let t=[],i=zr(n.source||"",{defines:e});for(let r of Pr(i,Us))t.push({name:r.name,group:Number(r.groupToken)});return t}function fg(n,e,t){if(n===0&&e>=ja)throw new Error(`Application binding "${t}" in group 0 uses reserved binding ${e}. Application-owned explicit group-0 bindings must stay below ${ja}.`)}function Nw(n,e,t,i){if(e===0&&t0?Math.max(...s)+1:0);for(;s.has(l)||o.has(l);)l++;for(let[u,f]of r||[])f===l&&u.startsWith(a)&&r?.delete(u);return l}function PB(n,e){let t=e.get(n)||new Set,i=0;for(;t.has(i);)i++;return i}function CB(n){let e=Fx(n,Us);if(!e)return;let t=LB(n,e.index);throw t?new Error(`Unresolved @binding(auto) for module "${t}" binding "${e.name}" remained in assembled WGSL source.`):MB(n,e.index)?new Error(`Unresolved @binding(auto) for application binding "${e.name}" remained in assembled WGSL source.`):new Error(`Unresolved @binding(auto) remained in assembled WGSL source near "${AB(e.match)}".`)}function TB(n){if(n.length===0)return"";let e=`// ----- MODULE WGSL BINDING ASSIGNMENTS --------------- +`,s}function bB(n){let e=new Map;for(let t of Pr(n,Fx)){let i=Number(t.bindingToken),r=Number(t.groupToken);dg(r,i,t.name),Zs(e,r,i,`application binding "${t.name}"`)}return e}function vB(n){let e=Pr(n,gu),t=new Map;for(let s of e){if(s.bindingToken==="auto")continue;let o=Number(s.bindingToken),a=Number(s.groupToken);dg(a,o,s.name),Zs(t,a,o,`application binding "${s.name}"`)}let i={sawSupportedBindingDeclaration:e.length>0},r=om(n,gu,s=>EB(s,t,i));if(am(n)&&!i.sawSupportedBindingDeclaration)throw new Error('Unsupported @binding(auto) declaration form in application WGSL. Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.');return{source:r}}function xB(n,e,t){let i=[],s={sawSupportedBindingDeclaration:Pr(n,Us).length>0,nextHintedBindingLocation:typeof e.firstBindingSlot=="number"?e.firstBindingSlot:null},o=om(n,Us,a=>wB(a,{module:e,context:t,bindingAssignments:i,relocationState:s}));if(am(n)&&!s.sawSupportedBindingDeclaration)throw new Error(`Unsupported @binding(auto) declaration form in module "${e.name}". Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.`);return{source:o,bindingAssignments:i}}function wB(n,e){let{module:t,context:i,bindingAssignments:r,relocationState:s}=e,{match:o,bindingToken:a,groupToken:c,name:l}=n,u=Number(c);if(a==="auto"){let d=Ww(u,t.name,l),h=i.bindingRegistry?.get(d),p=h!==void 0?h:TB(u,i.usedBindingsByGroup,t.name,s.nextHintedBindingLocation??void 0,i.bindingRegistry);return Fw(t.name,u,p,l),h!==void 0&&PB(i.reservedBindingKeysByGroup,u,p,d)?(r.push({moduleName:t.name,name:l,group:u,location:p}),o.replace(/@binding\(\s*auto\s*\)/,`@binding(${p})`)):(Zs(i.usedBindingsByGroup,u,p,`module "${t.name}" binding "${l}"`),i.bindingRegistry?.set(d,p),r.push({moduleName:t.name,name:l,group:u,location:p}),s.nextHintedBindingLocation!==null&&h===void 0&&(s.nextHintedBindingLocation=p+1),o.replace(/@binding\(\s*auto\s*\)/,`@binding(${p})`))}let f=Number(a);return Fw(t.name,u,f,l),Zs(i.usedBindingsByGroup,u,f,`module "${t.name}" binding "${l}"`),r.push({moduleName:t.name,name:l,group:u,location:f}),o}function EB(n,e,t){let{match:i,bindingToken:r,groupToken:s,name:o}=n,a=Number(s);if(r==="auto"){let c=LB(a,e);return dg(a,c,o),Zs(e,a,c,`application binding "${o}"`),i.replace(/@binding\(\s*auto\s*\)/,`@binding(${c})`)}return t.sawSupportedBindingDeclaration=!0,i}function SB(n,e,t,i){let r=new Map;if(!e)return r;for(let s of n)for(let o of CB(s,i)){let a=Ww(o.group,s.name,o.name),c=e.get(a);if(c!==void 0){let l=r.get(o.group)||new Map,u=l.get(c);if(u&&u!==a)throw new Error(`Duplicate WGSL binding reservation for modules "${u}" and "${a}": group ${o.group}, binding ${c}.`);Zs(t,o.group,c,`registered module binding "${a}"`),l.set(c,a),r.set(o.group,l)}}return r}function PB(n,e,t,i){let r=n.get(e);if(!r)return!1;let s=r.get(t);if(!s)return!1;if(s!==i)throw new Error(`Registered module binding "${i}" collided with "${s}": group ${e}, binding ${t}.`);return!0}function CB(n,e){let t=[],i=zr(n.source||"",{defines:e});for(let r of Pr(i,Us))t.push({name:r.name,group:Number(r.groupToken)});return t}function dg(n,e,t){if(n===0&&e>=Ha)throw new Error(`Application binding "${t}" in group 0 uses reserved binding ${e}. Application-owned explicit group-0 bindings must stay below ${Ha}.`)}function Fw(n,e,t,i){if(e===0&&t0?Math.max(...s)+1:0);for(;s.has(l)||o.has(l);)l++;for(let[u,f]of r||[])f===l&&u.startsWith(a)&&r?.delete(u);return l}function LB(n,e){let t=e.get(n)||new Set,i=0;for(;t.has(i);)i++;return i}function MB(n){let e=zx(n,Us);if(!e)return;let t=kB(n,e.index);throw t?new Error(`Unresolved @binding(auto) for module "${t}" binding "${e.name}" remained in assembled WGSL source.`):RB(n,e.index)?new Error(`Unresolved @binding(auto) for application binding "${e.name}" remained in assembled WGSL source.`):new Error(`Unresolved @binding(auto) remained in assembled WGSL source near "${IB(e.match)}".`)}function AB(n){if(n.length===0)return"";let e=`// ----- MODULE WGSL BINDING ASSIGNMENTS --------------- `;for(let t of n)e+=`// ${t.moduleName}.${t.name} -> @group(${t.group}) @binding(${t.location}) `;return e+=` -`,e}function Vw(n,e,t){return`${n}:${e}:${t}`}function LB(n,e){let t=/^\/\/ ----- MODULE ([^\n]+) ---------------$/gm,i,r;for(r=t.exec(n);r&&r.index<=e;)i=r[1],r=t.exec(n);return i}function MB(n,e){let t=n.indexOf(ug);return t>=0?e>t:!0}function AB(n){return n.replace(/\s+/g," ").trim()}var ug,ja,cB,Ww=C(()=>{gm();gw();pm();vw();wu();tg();xw();vu();Ew();rg();fm();sg();og();Ow();gu();ug=` +`,e}function Ww(n,e,t){return`${n}:${e}:${t}`}function kB(n,e){let t=/^\/\/ ----- MODULE ([^\n]+) ---------------$/gm,i,r;for(r=t.exec(n);r&&r.index<=e;)i=r[1],r=t.exec(n);return i}function RB(n,e){let t=n.indexOf(fg);return t>=0?e>t:!0}function IB(n){return n.replace(/\s+/g," ").trim()}var fg,Ha,fB,jw=C(()=>{_m();_w();mm();xw();Eu();ng();ww();xu();Sw();sg();dm();og();ag();Dw();_u();fg=` -${va} -`,ja=100,cB=`precision highp float; -`});var Yt,Xs,Hi,jw=C(()=>{wu();Ww();rg();sg();fm();vu();Yt=class n{static defaultShaderAssemblers={};_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(e){return hi(e==="glsl"||e==="wgsl"),e==="wgsl"?(n.defaultShaderAssemblers.wgsl=n.defaultShaderAssemblers.wgsl||new Hi,n.defaultShaderAssemblers.wgsl):(n.defaultShaderAssemblers.glsl=n.defaultShaderAssemblers.glsl||new Xs,n.defaultShaderAssemblers.glsl)}addDefaultModule(e){this._defaultModules.find(t=>t.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){let t=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(i=>i.name!==t)}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e)}_getModuleList(e=[]){let t=new Array(this._defaultModules.length+e.length),i={},r=0;for(let s=0,o=this._defaultModules.length;s(Object.assign(i,r.defines),i),{}),...e.defines}}static getPlatformPreprocessorDefines(e){let t=e.limits||{};return{LUMA_SUPPORTS_VERTEX_STORAGE_BUFFERS:e.type==="webgpu"&&(t.maxStorageBuffersInVertexStage||0)>0,LUMA_FP32_TAN_PRECISION_WORKAROUND:e.type==="webgpu"&&e.gpu.toLowerCase()!=="nvidia"&&e.gpu.toLowerCase()!=="amd",LUMA_FP64_INTEGER_ARITHMETIC:e.type==="webgpu"&&e.gpu.toLowerCase()==="apple"}}}});function dg(n){let{input:e,inputChannels:t,output:i}=n||{};if(!e)return RB;if(!t)throw new Error("inputChannels");let r=IB(t),s=Hw(e,t);return`#version 300 es +${xa} +`,Ha=100,fB=`precision highp float; +`});var Kt,Xs,qi,Hw=C(()=>{Eu();jw();sg();og();dm();xu();Kt=class n{static defaultShaderAssemblers={};_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(e){return yi(e==="glsl"||e==="wgsl"),e==="wgsl"?(n.defaultShaderAssemblers.wgsl=n.defaultShaderAssemblers.wgsl||new qi,n.defaultShaderAssemblers.wgsl):(n.defaultShaderAssemblers.glsl=n.defaultShaderAssemblers.glsl||new Xs,n.defaultShaderAssemblers.glsl)}addDefaultModule(e){this._defaultModules.find(t=>t.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){let t=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(i=>i.name!==t)}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e)}_getModuleList(e=[]){let t=new Array(this._defaultModules.length+e.length),i={},r=0;for(let s=0,o=this._defaultModules.length;s(Object.assign(i,r.defines),i),{}),...e.defines}}static getPlatformPreprocessorDefines(e){let t=e.limits||{};return{LUMA_SUPPORTS_VERTEX_STORAGE_BUFFERS:e.type==="webgpu"&&(t.maxStorageBuffersInVertexStage||0)>0,LUMA_FP32_TAN_PRECISION_WORKAROUND:e.type==="webgpu"&&e.gpu.toLowerCase()!=="nvidia"&&e.gpu.toLowerCase()!=="amd",LUMA_FP64_INTEGER_ARITHMETIC:e.type==="webgpu"&&e.gpu.toLowerCase()==="apple"}}}});function hg(n){let{input:e,inputChannels:t,output:i}=n||{};if(!e)return OB;if(!t)throw new Error("inputChannels");let r=DB(t),s=Yw(e,t);return`#version 300 es in ${r} ${e}; out vec4 ${i}; void main() { ${i} = ${s}; -}`}function IB(n){switch(n){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${n}`)}}function Hw(n,e){switch(e){case 1:return`vec4(${n}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${n}, 0.0, 1.0)`;case 3:return`vec4(${n}, 1.0)`;case 4:return n;default:throw new Error(`invalid channels: ${e}`)}}var kB,RB,Yw=C(()=>{kB=`out vec4 transform_output; +}`}function DB(n){switch(n){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${n}`)}}function Yw(n,e){switch(e){case 1:return`vec4(${n}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${n}, 0.0, 1.0)`;case 3:return`vec4(${n}, 1.0)`;case 4:return n;default:throw new Error(`invalid channels: ${e}`)}}var BB,OB,qw=C(()=>{BB=`out vec4 transform_output; void main() { transform_output = vec4(0); -}`,RB=`#version 300 es -${kB}`});function hg(n,{precision:e=Ye.precision}={}){return n=OB(n),`${parseFloat(n.toPrecision(e))}`}function mi(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Se(n,e,t){return NB(n,i=>Math.max(e,Math.min(t,i)))}function cn(n,e,t){return mi(n)?n.map((i,r)=>cn(i,e[r],t)):t*e+(1-t)*n}function Nn(n,e,t){let i=Ye.EPSILON;t&&(Ye.EPSILON=t);try{if(n===e)return!0;if(mi(n)&&mi(e)){if(n.length!==e.length)return!1;for(let r=0;r{HX=1/Math.PI*180,YX=1/180*Math.PI,BB={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...BB}};Ye=globalThis.mathgl.config});var Qs,pg=C(()=>{Ks();Qs=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,t=0){for(let i=0;i0?", ":"")+hg(this[i],e);return`${e.printTypes?this.constructor.name:""}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t{Ks()});function mg(n,e){if(!n)throw new Error(`math.gl assertion ${e}`)}var qw=C(()=>{});var Ku,Zw=C(()=>{pg();Ha();qw();Ku=class extends Qs{get x(){return this[0]}set x(e){this[0]=et(e)}get y(){return this[1]}set y(e){this[1]=et(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let t=0;t=0&&e=0&&e=0?Math.round(n):n%.5===0?Math.floor(n):Math.round(n)}var ve,Fn,rK,$r=C(()=>{ve=typeof Float32Array<"u"?Float32Array:Array,Fn=Math.random;rK=Math.PI/180});var dt={};ui(dt,{add:()=>VB,angle:()=>cO,ceil:()=>WB,clone:()=>zB,copy:()=>$B,create:()=>Xw,cross:()=>tO,dist:()=>_O,distance:()=>eE,div:()=>gO,divide:()=>Jw,dot:()=>eO,equals:()=>dO,exactEquals:()=>fO,floor:()=>jB,forEach:()=>vO,fromValues:()=>UB,inverse:()=>QB,len:()=>hO,length:()=>nE,lerp:()=>nO,max:()=>YB,min:()=>HB,mul:()=>mO,multiply:()=>Qw,negate:()=>KB,normalize:()=>JB,random:()=>iO,rotate:()=>aO,round:()=>qB,scale:()=>ZB,scaleAndAdd:()=>XB,set:()=>GB,sqrDist:()=>yO,sqrLen:()=>bO,squaredDistance:()=>tE,squaredLength:()=>iE,str:()=>uO,sub:()=>pO,subtract:()=>Kw,transformMat2:()=>rO,transformMat2d:()=>sO,transformMat3:()=>oO,transformMat4:()=>gg,zero:()=>lO});function Xw(){let n=new ve(2);return ve!=Float32Array&&(n[0]=0,n[1]=0),n}function zB(n){let e=new ve(2);return e[0]=n[0],e[1]=n[1],e}function UB(n,e){let t=new ve(2);return t[0]=n,t[1]=e,t}function $B(n,e){return n[0]=e[0],n[1]=e[1],n}function GB(n,e,t){return n[0]=e,n[1]=t,n}function VB(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n}function Kw(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n}function Qw(n,e,t){return n[0]=e[0]*t[0],n[1]=e[1]*t[1],n}function Jw(n,e,t){return n[0]=e[0]/t[0],n[1]=e[1]/t[1],n}function WB(n,e){return n[0]=Math.ceil(e[0]),n[1]=Math.ceil(e[1]),n}function jB(n,e){return n[0]=Math.floor(e[0]),n[1]=Math.floor(e[1]),n}function HB(n,e,t){return n[0]=Math.min(e[0],t[0]),n[1]=Math.min(e[1],t[1]),n}function YB(n,e,t){return n[0]=Math.max(e[0],t[0]),n[1]=Math.max(e[1],t[1]),n}function qB(n,e){return n[0]=qt(e[0]),n[1]=qt(e[1]),n}function ZB(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n}function XB(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n}function eE(n,e){let t=e[0]-n[0],i=e[1]-n[1];return Math.sqrt(t*t+i*i)}function tE(n,e){let t=e[0]-n[0],i=e[1]-n[1];return t*t+i*i}function nE(n){let e=n[0],t=n[1];return Math.sqrt(e*e+t*t)}function iE(n){let e=n[0],t=n[1];return e*e+t*t}function KB(n,e){return n[0]=-e[0],n[1]=-e[1],n}function QB(n,e){return n[0]=1/e[0],n[1]=1/e[1],n}function JB(n,e){let t=e[0],i=e[1],r=t*t+i*i;return r>0&&(r=1/Math.sqrt(r)),n[0]=e[0]*r,n[1]=e[1]*r,n}function eO(n,e){return n[0]*e[0]+n[1]*e[1]}function tO(n,e,t){let i=e[0]*t[1]-e[1]*t[0];return n[0]=n[1]=0,n[2]=i,n}function nO(n,e,t,i){let r=e[0],s=e[1];return n[0]=r+i*(t[0]-r),n[1]=s+i*(t[1]-s),n}function iO(n,e){e=e===void 0?1:e;let t=Fn()*2*Math.PI;return n[0]=Math.cos(t)*e,n[1]=Math.sin(t)*e,n}function rO(n,e,t){let i=e[0],r=e[1];return n[0]=t[0]*i+t[2]*r,n[1]=t[1]*i+t[3]*r,n}function sO(n,e,t){let i=e[0],r=e[1];return n[0]=t[0]*i+t[2]*r+t[4],n[1]=t[1]*i+t[3]*r+t[5],n}function oO(n,e,t){let i=e[0],r=e[1];return n[0]=t[0]*i+t[3]*r+t[6],n[1]=t[1]*i+t[4]*r+t[7],n}function gg(n,e,t){let i=e[0],r=e[1];return n[0]=t[0]*i+t[4]*r+t[12],n[1]=t[1]*i+t[5]*r+t[13],n}function aO(n,e,t,i){let r=e[0]-t[0],s=e[1]-t[1],o=Math.sin(i),a=Math.cos(i);return n[0]=r*a-s*o+t[0],n[1]=r*o+s*a+t[1],n}function cO(n,e){let t=n[0],i=n[1],r=e[0],s=e[1],o=Math.sqrt((t*t+i*i)*(r*r+s*s)),a=o&&(t*r+i*s)/o;return Math.acos(Math.min(Math.max(a,-1),1))}function lO(n){return n[0]=0,n[1]=0,n}function uO(n){return`vec2(${n[0]}, ${n[1]})`}function fO(n,e){return n[0]===e[0]&&n[1]===e[1]}function dO(n,e){let t=n[0],i=n[1],r=e[0],s=e[1];return Math.abs(t-r)<=1e-6*Math.max(1,Math.abs(t),Math.abs(r))&&Math.abs(i-s)<=1e-6*Math.max(1,Math.abs(i),Math.abs(s))}var hO,pO,mO,gO,_O,yO,bO,vO,_g=C(()=>{$r();hO=nE,pO=Kw,mO=Qw,gO=Jw,_O=eE,yO=tE,bO=iE,vO=function(){let n=Xw();return function(e,t,i,r,s,o){let a,c;for(t||(t=2),i||(i=0),r?c=Math.min(r*t+i,e.length):c=e.length,a=i;a{});var yt={};ui(yt,{add:()=>SO,angle:()=>Pg,bezier:()=>NO,ceil:()=>PO,clone:()=>xO,copy:()=>wO,create:()=>Ju,cross:()=>Gr,dist:()=>HO,distance:()=>uE,div:()=>jO,divide:()=>lE,dot:()=>Ya,equals:()=>GO,exactEquals:()=>$O,floor:()=>CO,forEach:()=>ZO,fromValues:()=>ef,hermite:()=>DO,inverse:()=>IO,len:()=>Cg,length:()=>oE,lerp:()=>BO,max:()=>LO,min:()=>TO,mul:()=>WO,multiply:()=>cE,negate:()=>RO,normalize:()=>bg,random:()=>FO,rotateX:()=>wg,rotateY:()=>Eg,rotateZ:()=>Sg,round:()=>MO,scale:()=>AO,scaleAndAdd:()=>kO,set:()=>EO,slerp:()=>OO,sqrDist:()=>YO,sqrLen:()=>qO,squaredDistance:()=>fE,squaredLength:()=>dE,str:()=>UO,sub:()=>VO,subtract:()=>aE,transformMat3:()=>vg,transformMat4:()=>qa,transformQuat:()=>xg,zero:()=>zO});function Ju(){let n=new ve(3);return ve!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n}function xO(n){let e=new ve(3);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e}function oE(n){let e=n[0],t=n[1],i=n[2];return Math.sqrt(e*e+t*t+i*i)}function ef(n,e,t){let i=new ve(3);return i[0]=n,i[1]=e,i[2]=t,i}function wO(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n}function EO(n,e,t,i){return n[0]=e,n[1]=t,n[2]=i,n}function SO(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n}function aE(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n}function cE(n,e,t){return n[0]=e[0]*t[0],n[1]=e[1]*t[1],n[2]=e[2]*t[2],n}function lE(n,e,t){return n[0]=e[0]/t[0],n[1]=e[1]/t[1],n[2]=e[2]/t[2],n}function PO(n,e){return n[0]=Math.ceil(e[0]),n[1]=Math.ceil(e[1]),n[2]=Math.ceil(e[2]),n}function CO(n,e){return n[0]=Math.floor(e[0]),n[1]=Math.floor(e[1]),n[2]=Math.floor(e[2]),n}function TO(n,e,t){return n[0]=Math.min(e[0],t[0]),n[1]=Math.min(e[1],t[1]),n[2]=Math.min(e[2],t[2]),n}function LO(n,e,t){return n[0]=Math.max(e[0],t[0]),n[1]=Math.max(e[1],t[1]),n[2]=Math.max(e[2],t[2]),n}function MO(n,e){return n[0]=qt(e[0]),n[1]=qt(e[1]),n[2]=qt(e[2]),n}function AO(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n}function kO(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n[2]=e[2]+t[2]*i,n}function uE(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2];return Math.sqrt(t*t+i*i+r*r)}function fE(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2];return t*t+i*i+r*r}function dE(n){let e=n[0],t=n[1],i=n[2];return e*e+t*t+i*i}function RO(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n}function IO(n,e){return n[0]=1/e[0],n[1]=1/e[1],n[2]=1/e[2],n}function bg(n,e){let t=e[0],i=e[1],r=e[2],s=t*t+i*i+r*r;return s>0&&(s=1/Math.sqrt(s)),n[0]=e[0]*s,n[1]=e[1]*s,n[2]=e[2]*s,n}function Ya(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]}function Gr(n,e,t){let i=e[0],r=e[1],s=e[2],o=t[0],a=t[1],c=t[2];return n[0]=r*c-s*a,n[1]=s*o-i*c,n[2]=i*a-r*o,n}function BO(n,e,t,i){let r=e[0],s=e[1],o=e[2];return n[0]=r+i*(t[0]-r),n[1]=s+i*(t[1]-s),n[2]=o+i*(t[2]-o),n}function OO(n,e,t,i){let r=Math.acos(Math.min(Math.max(Ya(e,t),-1),1)),s=Math.sin(r),o=Math.sin((1-i)*r)/s,a=Math.sin(i*r)/s;return n[0]=o*e[0]+a*t[0],n[1]=o*e[1]+a*t[1],n[2]=o*e[2]+a*t[2],n}function DO(n,e,t,i,r,s){let o=s*s,a=o*(2*s-3)+1,c=o*(s-2)+s,l=o*(s-1),u=o*(3-2*s);return n[0]=e[0]*a+t[0]*c+i[0]*l+r[0]*u,n[1]=e[1]*a+t[1]*c+i[1]*l+r[1]*u,n[2]=e[2]*a+t[2]*c+i[2]*l+r[2]*u,n}function NO(n,e,t,i,r,s){let o=1-s,a=o*o,c=s*s,l=a*o,u=3*s*a,f=3*c*o,d=c*s;return n[0]=e[0]*l+t[0]*u+i[0]*f+r[0]*d,n[1]=e[1]*l+t[1]*u+i[1]*f+r[1]*d,n[2]=e[2]*l+t[2]*u+i[2]*f+r[2]*d,n}function FO(n,e){e=e===void 0?1:e;let t=Fn()*2*Math.PI,i=Fn()*2-1,r=Math.sqrt(1-i*i)*e;return n[0]=Math.cos(t)*r,n[1]=Math.sin(t)*r,n[2]=i*e,n}function qa(n,e,t){let i=e[0],r=e[1],s=e[2],o=t[3]*i+t[7]*r+t[11]*s+t[15];return o=o||1,n[0]=(t[0]*i+t[4]*r+t[8]*s+t[12])/o,n[1]=(t[1]*i+t[5]*r+t[9]*s+t[13])/o,n[2]=(t[2]*i+t[6]*r+t[10]*s+t[14])/o,n}function vg(n,e,t){let i=e[0],r=e[1],s=e[2];return n[0]=i*t[0]+r*t[3]+s*t[6],n[1]=i*t[1]+r*t[4]+s*t[7],n[2]=i*t[2]+r*t[5]+s*t[8],n}function xg(n,e,t){let i=t[0],r=t[1],s=t[2],o=t[3],a=e[0],c=e[1],l=e[2],u=r*l-s*c,f=s*a-i*l,d=i*c-r*a,h=r*d-s*f,p=s*u-i*d,m=i*f-r*u,g=o*2;return u*=g,f*=g,d*=g,h*=2,p*=2,m*=2,n[0]=a+u+h,n[1]=c+f+p,n[2]=l+d+m,n}function wg(n,e,t,i){let r=[],s=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],s[0]=r[0],s[1]=r[1]*Math.cos(i)-r[2]*Math.sin(i),s[2]=r[1]*Math.sin(i)+r[2]*Math.cos(i),n[0]=s[0]+t[0],n[1]=s[1]+t[1],n[2]=s[2]+t[2],n}function Eg(n,e,t,i){let r=[],s=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],s[0]=r[2]*Math.sin(i)+r[0]*Math.cos(i),s[1]=r[1],s[2]=r[2]*Math.cos(i)-r[0]*Math.sin(i),n[0]=s[0]+t[0],n[1]=s[1]+t[1],n[2]=s[2]+t[2],n}function Sg(n,e,t,i){let r=[],s=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],s[0]=r[0]*Math.cos(i)-r[1]*Math.sin(i),s[1]=r[0]*Math.sin(i)+r[1]*Math.cos(i),s[2]=r[2],n[0]=s[0]+t[0],n[1]=s[1]+t[1],n[2]=s[2]+t[2],n}function Pg(n,e){let t=n[0],i=n[1],r=n[2],s=e[0],o=e[1],a=e[2],c=Math.sqrt((t*t+i*i+r*r)*(s*s+o*o+a*a)),l=c&&Ya(n,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function zO(n){return n[0]=0,n[1]=0,n[2]=0,n}function UO(n){return`vec3(${n[0]}, ${n[1]}, ${n[2]})`}function $O(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]}function GO(n,e){let t=n[0],i=n[1],r=n[2],s=e[0],o=e[1],a=e[2];return Math.abs(t-s)<=1e-6*Math.max(1,Math.abs(t),Math.abs(s))&&Math.abs(i-o)<=1e-6*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(r-a)<=1e-6*Math.max(1,Math.abs(r),Math.abs(a))}var VO,WO,jO,HO,YO,Cg,qO,ZO,Za=C(()=>{$r();VO=aE,WO=cE,jO=lE,HO=uE,YO=fE,Cg=oE,qO=dE,ZO=function(){let n=Ju();return function(e,t,i,r,s,o){let a,c;for(t||(t=3),i||(i=0),r?c=Math.min(r*t+i,e.length):c=e.length,a=i;a{Zw();Ks();Ha();Za();yg();Tg=[0,0,0],tt=class n extends Ku{static get ZERO(){return tf||(tf=new n(0,0,0),Object.freeze(tf)),tf}constructor(e=0,t=0,i=0){super(-0,-0,-0),arguments.length===1&&mi(e)?this.copy(e):(Ye.debug&&(et(e),et(t),et(i)),this[0]=e,this[1]=t,this[2]=i)}set(e,t,i){return this[0]=e,this[1]=t,this[2]=i,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return Ye.debug&&(et(e.x),et(e.y),et(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=et(e)}angle(e){return Pg(this,e)}cross(e){return Gr(this,this,e),this.check()}rotateX({radians:e,origin:t=Tg}){return wg(this,this,t,e),this.check()}rotateY({radians:e,origin:t=Tg}){return Eg(this,this,t,e),this.check()}rotateZ({radians:e,origin:t=Tg}){return Sg(this,this,t,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return qa(this,this,e),this.check()}transformAsVector(e){return Qu(this,this,e),this.check()}transformByMatrix3(e){return vg(this,this,e),this.check()}transformByMatrix2(e){return sE(this,this,e),this.check()}transformByQuaternion(e){return xg(this,this,e),this.check()}}});var nf,pE=C(()=>{pg();Ha();Ks();nf=class extends Qs{toString(){let e="[";if(Ye.printRowMajor){e+="row-major:";for(let t=0;t{$r()});var We={};ui(We,{add:()=>vD,adjoint:()=>tD,clone:()=>KO,copy:()=>QO,create:()=>XO,decompose:()=>fD,determinant:()=>kg,equals:()=>SD,exactEquals:()=>ED,frob:()=>bD,fromQuat:()=>Fg,fromQuat2:()=>cD,fromRotation:()=>rD,fromRotationTranslation:()=>yE,fromRotationTranslationScale:()=>dD,fromRotationTranslationScaleOrigin:()=>hD,fromScaling:()=>iD,fromTranslation:()=>nD,fromValues:()=>JO,fromXRotation:()=>sD,fromYRotation:()=>oD,fromZRotation:()=>aD,frustum:()=>zg,getRotation:()=>uD,getScaling:()=>bE,getTranslation:()=>lD,identity:()=>_E,invert:()=>Ag,lookAt:()=>Gg,mul:()=>PD,multiply:()=>Xa,multiplyScalar:()=>xD,multiplyScalarAndAdd:()=>wD,ortho:()=>$g,orthoNO:()=>xE,orthoZO:()=>gD,perspective:()=>Ug,perspectiveFromFieldOfView:()=>mD,perspectiveNO:()=>vE,perspectiveZO:()=>pD,rotate:()=>Bg,rotateX:()=>Og,rotateY:()=>Dg,rotateZ:()=>Ng,scale:()=>Ig,set:()=>eD,str:()=>yD,sub:()=>CD,subtract:()=>wE,targetTo:()=>_D,translate:()=>Rg,transpose:()=>Mg});function XO(){let n=new ve(16);return ve!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0),n[0]=1,n[5]=1,n[10]=1,n[15]=1,n}function KO(n){let e=new ve(16);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],e}function QO(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function JO(n,e,t,i,r,s,o,a,c,l,u,f,d,h,p,m){let g=new ve(16);return g[0]=n,g[1]=e,g[2]=t,g[3]=i,g[4]=r,g[5]=s,g[6]=o,g[7]=a,g[8]=c,g[9]=l,g[10]=u,g[11]=f,g[12]=d,g[13]=h,g[14]=p,g[15]=m,g}function eD(n,e,t,i,r,s,o,a,c,l,u,f,d,h,p,m,g){return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n[4]=s,n[5]=o,n[6]=a,n[7]=c,n[8]=l,n[9]=u,n[10]=f,n[11]=d,n[12]=h,n[13]=p,n[14]=m,n[15]=g,n}function _E(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Mg(n,e){if(n===e){let t=e[1],i=e[2],r=e[3],s=e[6],o=e[7],a=e[11];n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=t,n[6]=e[9],n[7]=e[13],n[8]=i,n[9]=s,n[11]=e[14],n[12]=r,n[13]=o,n[14]=a}else n[0]=e[0],n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=e[1],n[5]=e[5],n[6]=e[9],n[7]=e[13],n[8]=e[2],n[9]=e[6],n[10]=e[10],n[11]=e[14],n[12]=e[3],n[13]=e[7],n[14]=e[11],n[15]=e[15];return n}function Ag(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],d=e[10],h=e[11],p=e[12],m=e[13],g=e[14],v=e[15],y=t*a-i*o,b=t*c-r*o,w=t*l-s*o,E=i*c-r*a,x=i*l-s*a,T=r*l-s*c,I=u*m-f*p,N=u*g-d*p,D=u*v-h*p,H=f*g-d*m,W=f*v-h*m,V=d*v-h*g,X=y*V-b*W+w*H+E*D-x*N+T*I;return X?(X=1/X,n[0]=(a*V-c*W+l*H)*X,n[1]=(r*W-i*V-s*H)*X,n[2]=(m*T-g*x+v*E)*X,n[3]=(d*x-f*T-h*E)*X,n[4]=(c*D-o*V-l*N)*X,n[5]=(t*V-r*D+s*N)*X,n[6]=(g*w-p*T-v*b)*X,n[7]=(u*T-d*w+h*b)*X,n[8]=(o*W-a*D+l*I)*X,n[9]=(i*D-t*W-s*I)*X,n[10]=(p*x-m*w+v*y)*X,n[11]=(f*w-u*x-h*y)*X,n[12]=(a*N-o*H-c*I)*X,n[13]=(t*H-i*N+r*I)*X,n[14]=(m*b-p*E-g*y)*X,n[15]=(u*E-f*b+d*y)*X,n):null}function tD(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],d=e[10],h=e[11],p=e[12],m=e[13],g=e[14],v=e[15],y=t*a-i*o,b=t*c-r*o,w=t*l-s*o,E=i*c-r*a,x=i*l-s*a,T=r*l-s*c,I=u*m-f*p,N=u*g-d*p,D=u*v-h*p,H=f*g-d*m,W=f*v-h*m,V=d*v-h*g;return n[0]=a*V-c*W+l*H,n[1]=r*W-i*V-s*H,n[2]=m*T-g*x+v*E,n[3]=d*x-f*T-h*E,n[4]=c*D-o*V-l*N,n[5]=t*V-r*D+s*N,n[6]=g*w-p*T-v*b,n[7]=u*T-d*w+h*b,n[8]=o*W-a*D+l*I,n[9]=i*D-t*W-s*I,n[10]=p*x-m*w+v*y,n[11]=f*w-u*x-h*y,n[12]=a*N-o*H-c*I,n[13]=t*H-i*N+r*I,n[14]=m*b-p*E-g*y,n[15]=u*E-f*b+d*y,n}function kg(n){let e=n[0],t=n[1],i=n[2],r=n[3],s=n[4],o=n[5],a=n[6],c=n[7],l=n[8],u=n[9],f=n[10],d=n[11],h=n[12],p=n[13],m=n[14],g=n[15],v=e*o-t*s,y=e*a-i*s,b=t*a-i*o,w=l*p-u*h,E=l*m-f*h,x=u*m-f*p,T=e*x-t*E+i*w,I=s*x-o*E+a*w,N=l*b-u*y+f*v,D=h*b-p*y+m*v;return c*T-r*I+g*N-d*D}function Xa(n,e,t){let i=e[0],r=e[1],s=e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=e[8],d=e[9],h=e[10],p=e[11],m=e[12],g=e[13],v=e[14],y=e[15],b=t[0],w=t[1],E=t[2],x=t[3];return n[0]=b*i+w*a+E*f+x*m,n[1]=b*r+w*c+E*d+x*g,n[2]=b*s+w*l+E*h+x*v,n[3]=b*o+w*u+E*p+x*y,b=t[4],w=t[5],E=t[6],x=t[7],n[4]=b*i+w*a+E*f+x*m,n[5]=b*r+w*c+E*d+x*g,n[6]=b*s+w*l+E*h+x*v,n[7]=b*o+w*u+E*p+x*y,b=t[8],w=t[9],E=t[10],x=t[11],n[8]=b*i+w*a+E*f+x*m,n[9]=b*r+w*c+E*d+x*g,n[10]=b*s+w*l+E*h+x*v,n[11]=b*o+w*u+E*p+x*y,b=t[12],w=t[13],E=t[14],x=t[15],n[12]=b*i+w*a+E*f+x*m,n[13]=b*r+w*c+E*d+x*g,n[14]=b*s+w*l+E*h+x*v,n[15]=b*o+w*u+E*p+x*y,n}function Rg(n,e,t){let i=t[0],r=t[1],s=t[2],o,a,c,l,u,f,d,h,p,m,g,v;return e===n?(n[12]=e[0]*i+e[4]*r+e[8]*s+e[12],n[13]=e[1]*i+e[5]*r+e[9]*s+e[13],n[14]=e[2]*i+e[6]*r+e[10]*s+e[14],n[15]=e[3]*i+e[7]*r+e[11]*s+e[15]):(o=e[0],a=e[1],c=e[2],l=e[3],u=e[4],f=e[5],d=e[6],h=e[7],p=e[8],m=e[9],g=e[10],v=e[11],n[0]=o,n[1]=a,n[2]=c,n[3]=l,n[4]=u,n[5]=f,n[6]=d,n[7]=h,n[8]=p,n[9]=m,n[10]=g,n[11]=v,n[12]=o*i+u*r+p*s+e[12],n[13]=a*i+f*r+m*s+e[13],n[14]=c*i+d*r+g*s+e[14],n[15]=l*i+h*r+v*s+e[15]),n}function Ig(n,e,t){let i=t[0],r=t[1],s=t[2];return n[0]=e[0]*i,n[1]=e[1]*i,n[2]=e[2]*i,n[3]=e[3]*i,n[4]=e[4]*r,n[5]=e[5]*r,n[6]=e[6]*r,n[7]=e[7]*r,n[8]=e[8]*s,n[9]=e[9]*s,n[10]=e[10]*s,n[11]=e[11]*s,n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function Bg(n,e,t,i){let r=i[0],s=i[1],o=i[2],a=Math.sqrt(r*r+s*s+o*o),c,l,u,f,d,h,p,m,g,v,y,b,w,E,x,T,I,N,D,H,W,V,X,Y;return a<1e-6?null:(a=1/a,r*=a,s*=a,o*=a,l=Math.sin(t),c=Math.cos(t),u=1-c,f=e[0],d=e[1],h=e[2],p=e[3],m=e[4],g=e[5],v=e[6],y=e[7],b=e[8],w=e[9],E=e[10],x=e[11],T=r*r*u+c,I=s*r*u+o*l,N=o*r*u-s*l,D=r*s*u-o*l,H=s*s*u+c,W=o*s*u+r*l,V=r*o*u+s*l,X=s*o*u-r*l,Y=o*o*u+c,n[0]=f*T+m*I+b*N,n[1]=d*T+g*I+w*N,n[2]=h*T+v*I+E*N,n[3]=p*T+y*I+x*N,n[4]=f*D+m*H+b*W,n[5]=d*D+g*H+w*W,n[6]=h*D+v*H+E*W,n[7]=p*D+y*H+x*W,n[8]=f*V+m*X+b*Y,n[9]=d*V+g*X+w*Y,n[10]=h*V+v*X+E*Y,n[11]=p*V+y*X+x*Y,e!==n&&(n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n)}function Og(n,e,t){let i=Math.sin(t),r=Math.cos(t),s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],f=e[10],d=e[11];return e!==n&&(n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[4]=s*r+l*i,n[5]=o*r+u*i,n[6]=a*r+f*i,n[7]=c*r+d*i,n[8]=l*r-s*i,n[9]=u*r-o*i,n[10]=f*r-a*i,n[11]=d*r-c*i,n}function Dg(n,e,t){let i=Math.sin(t),r=Math.cos(t),s=e[0],o=e[1],a=e[2],c=e[3],l=e[8],u=e[9],f=e[10],d=e[11];return e!==n&&(n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=s*r-l*i,n[1]=o*r-u*i,n[2]=a*r-f*i,n[3]=c*r-d*i,n[8]=s*i+l*r,n[9]=o*i+u*r,n[10]=a*i+f*r,n[11]=c*i+d*r,n}function Ng(n,e,t){let i=Math.sin(t),r=Math.cos(t),s=e[0],o=e[1],a=e[2],c=e[3],l=e[4],u=e[5],f=e[6],d=e[7];return e!==n&&(n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=s*r+l*i,n[1]=o*r+u*i,n[2]=a*r+f*i,n[3]=c*r+d*i,n[4]=l*r-s*i,n[5]=u*r-o*i,n[6]=f*r-a*i,n[7]=d*r-c*i,n}function nD(n,e){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=e[0],n[13]=e[1],n[14]=e[2],n[15]=1,n}function iD(n,e){return n[0]=e[0],n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=e[1],n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=e[2],n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function rD(n,e,t){let i=t[0],r=t[1],s=t[2],o=Math.sqrt(i*i+r*r+s*s),a,c,l;return o<1e-6?null:(o=1/o,i*=o,r*=o,s*=o,c=Math.sin(e),a=Math.cos(e),l=1-a,n[0]=i*i*l+a,n[1]=r*i*l+s*c,n[2]=s*i*l-r*c,n[3]=0,n[4]=i*r*l-s*c,n[5]=r*r*l+a,n[6]=s*r*l+i*c,n[7]=0,n[8]=i*s*l+r*c,n[9]=r*s*l-i*c,n[10]=s*s*l+a,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n)}function sD(n,e){let t=Math.sin(e),i=Math.cos(e);return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i,n[6]=t,n[7]=0,n[8]=0,n[9]=-t,n[10]=i,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function oD(n,e){let t=Math.sin(e),i=Math.cos(e);return n[0]=i,n[1]=0,n[2]=-t,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=t,n[9]=0,n[10]=i,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function aD(n,e){let t=Math.sin(e),i=Math.cos(e);return n[0]=i,n[1]=t,n[2]=0,n[3]=0,n[4]=-t,n[5]=i,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function yE(n,e,t){let i=e[0],r=e[1],s=e[2],o=e[3],a=i+i,c=r+r,l=s+s,u=i*a,f=i*c,d=i*l,h=r*c,p=r*l,m=s*l,g=o*a,v=o*c,y=o*l;return n[0]=1-(h+m),n[1]=f+y,n[2]=d-v,n[3]=0,n[4]=f-y,n[5]=1-(u+m),n[6]=p+g,n[7]=0,n[8]=d+v,n[9]=p-g,n[10]=1-(u+h),n[11]=0,n[12]=t[0],n[13]=t[1],n[14]=t[2],n[15]=1,n}function cD(n,e){let t=new ve(3),i=-e[0],r=-e[1],s=-e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=i*i+r*r+s*s+o*o;return f>0?(t[0]=(a*o+u*i+c*s-l*r)*2/f,t[1]=(c*o+u*r+l*i-a*s)*2/f,t[2]=(l*o+u*s+a*r-c*i)*2/f):(t[0]=(a*o+u*i+c*s-l*r)*2,t[1]=(c*o+u*r+l*i-a*s)*2,t[2]=(l*o+u*s+a*r-c*i)*2),yE(n,e,t),n}function lD(n,e){return n[0]=e[12],n[1]=e[13],n[2]=e[14],n}function bE(n,e){let t=e[0],i=e[1],r=e[2],s=e[4],o=e[5],a=e[6],c=e[8],l=e[9],u=e[10];return n[0]=Math.sqrt(t*t+i*i+r*r),n[1]=Math.sqrt(s*s+o*o+a*a),n[2]=Math.sqrt(c*c+l*l+u*u),n}function uD(n,e){let t=new ve(3);bE(t,e);let i=1/t[0],r=1/t[1],s=1/t[2],o=e[0]*i,a=e[1]*r,c=e[2]*s,l=e[4]*i,u=e[5]*r,f=e[6]*s,d=e[8]*i,h=e[9]*r,p=e[10]*s,m=o+u+p,g=0;return m>0?(g=Math.sqrt(m+1)*2,n[3]=.25*g,n[0]=(f-h)/g,n[1]=(d-c)/g,n[2]=(a-l)/g):o>u&&o>p?(g=Math.sqrt(1+o-u-p)*2,n[3]=(f-h)/g,n[0]=.25*g,n[1]=(a+l)/g,n[2]=(d+c)/g):u>p?(g=Math.sqrt(1+u-o-p)*2,n[3]=(d-c)/g,n[0]=(a+l)/g,n[1]=.25*g,n[2]=(f+h)/g):(g=Math.sqrt(1+p-o-u)*2,n[3]=(a-l)/g,n[0]=(d+c)/g,n[1]=(f+h)/g,n[2]=.25*g),n}function fD(n,e,t,i){e[0]=i[12],e[1]=i[13],e[2]=i[14];let r=i[0],s=i[1],o=i[2],a=i[4],c=i[5],l=i[6],u=i[8],f=i[9],d=i[10];t[0]=Math.sqrt(r*r+s*s+o*o),t[1]=Math.sqrt(a*a+c*c+l*l),t[2]=Math.sqrt(u*u+f*f+d*d);let h=1/t[0],p=1/t[1],m=1/t[2],g=r*h,v=s*p,y=o*m,b=a*h,w=c*p,E=l*m,x=u*h,T=f*p,I=d*m,N=g+w+I,D=0;return N>0?(D=Math.sqrt(N+1)*2,n[3]=.25*D,n[0]=(E-T)/D,n[1]=(x-y)/D,n[2]=(v-b)/D):g>w&&g>I?(D=Math.sqrt(1+g-w-I)*2,n[3]=(E-T)/D,n[0]=.25*D,n[1]=(v+b)/D,n[2]=(x+y)/D):w>I?(D=Math.sqrt(1+w-g-I)*2,n[3]=(x-y)/D,n[0]=(v+b)/D,n[1]=.25*D,n[2]=(E+T)/D):(D=Math.sqrt(1+I-g-w)*2,n[3]=(v-b)/D,n[0]=(x+y)/D,n[1]=(E+T)/D,n[2]=.25*D),n}function dD(n,e,t,i){let r=e[0],s=e[1],o=e[2],a=e[3],c=r+r,l=s+s,u=o+o,f=r*c,d=r*l,h=r*u,p=s*l,m=s*u,g=o*u,v=a*c,y=a*l,b=a*u,w=i[0],E=i[1],x=i[2];return n[0]=(1-(p+g))*w,n[1]=(d+b)*w,n[2]=(h-y)*w,n[3]=0,n[4]=(d-b)*E,n[5]=(1-(f+g))*E,n[6]=(m+v)*E,n[7]=0,n[8]=(h+y)*x,n[9]=(m-v)*x,n[10]=(1-(f+p))*x,n[11]=0,n[12]=t[0],n[13]=t[1],n[14]=t[2],n[15]=1,n}function hD(n,e,t,i,r){let s=e[0],o=e[1],a=e[2],c=e[3],l=s+s,u=o+o,f=a+a,d=s*l,h=s*u,p=s*f,m=o*u,g=o*f,v=a*f,y=c*l,b=c*u,w=c*f,E=i[0],x=i[1],T=i[2],I=r[0],N=r[1],D=r[2],H=(1-(m+v))*E,W=(h+w)*E,V=(p-b)*E,X=(h-w)*x,Y=(1-(d+v))*x,ie=(g+y)*x,oe=(p+b)*T,zt=(g-y)*T,je=(1-(d+m))*T;return n[0]=H,n[1]=W,n[2]=V,n[3]=0,n[4]=X,n[5]=Y,n[6]=ie,n[7]=0,n[8]=oe,n[9]=zt,n[10]=je,n[11]=0,n[12]=t[0]+I-(H*I+X*N+oe*D),n[13]=t[1]+N-(W*I+Y*N+zt*D),n[14]=t[2]+D-(V*I+ie*N+je*D),n[15]=1,n}function Fg(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],o=t+t,a=i+i,c=r+r,l=t*o,u=i*o,f=i*a,d=r*o,h=r*a,p=r*c,m=s*o,g=s*a,v=s*c;return n[0]=1-f-p,n[1]=u+v,n[2]=d-g,n[3]=0,n[4]=u-v,n[5]=1-l-p,n[6]=h+m,n[7]=0,n[8]=d+g,n[9]=h-m,n[10]=1-l-f,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function zg(n,e,t,i,r,s,o){let a=1/(t-e),c=1/(r-i),l=1/(s-o);return n[0]=s*2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=s*2*c,n[6]=0,n[7]=0,n[8]=(t+e)*a,n[9]=(r+i)*c,n[10]=(o+s)*l,n[11]=-1,n[12]=0,n[13]=0,n[14]=o*s*2*l,n[15]=0,n}function vE(n,e,t,i,r){let s=1/Math.tan(e/2);if(n[0]=s/t,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=s,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,r!=null&&r!==1/0){let o=1/(i-r);n[10]=(r+i)*o,n[14]=2*r*i*o}else n[10]=-1,n[14]=-2*i;return n}function pD(n,e,t,i,r){let s=1/Math.tan(e/2);if(n[0]=s/t,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=s,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,r!=null&&r!==1/0){let o=1/(i-r);n[10]=r*o,n[14]=r*i*o}else n[10]=-1,n[14]=-i;return n}function mD(n,e,t,i){let r=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),o=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),c=2/(o+a),l=2/(r+s);return n[0]=c,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=l,n[6]=0,n[7]=0,n[8]=-((o-a)*c*.5),n[9]=(r-s)*l*.5,n[10]=i/(t-i),n[11]=-1,n[12]=0,n[13]=0,n[14]=i*t/(t-i),n[15]=0,n}function xE(n,e,t,i,r,s,o){let a=1/(e-t),c=1/(i-r),l=1/(s-o);return n[0]=-2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*c,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*l,n[11]=0,n[12]=(e+t)*a,n[13]=(r+i)*c,n[14]=(o+s)*l,n[15]=1,n}function gD(n,e,t,i,r,s,o){let a=1/(e-t),c=1/(i-r),l=1/(s-o);return n[0]=-2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*c,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=l,n[11]=0,n[12]=(e+t)*a,n[13]=(r+i)*c,n[14]=s*l,n[15]=1,n}function Gg(n,e,t,i){let r,s,o,a,c,l,u,f,d,h,p=e[0],m=e[1],g=e[2],v=i[0],y=i[1],b=i[2],w=t[0],E=t[1],x=t[2];return Math.abs(p-w)<1e-6&&Math.abs(m-E)<1e-6&&Math.abs(g-x)<1e-6?_E(n):(f=p-w,d=m-E,h=g-x,r=1/Math.sqrt(f*f+d*d+h*h),f*=r,d*=r,h*=r,s=y*h-b*d,o=b*f-v*h,a=v*d-y*f,r=Math.sqrt(s*s+o*o+a*a),r?(r=1/r,s*=r,o*=r,a*=r):(s=0,o=0,a=0),c=d*a-h*o,l=h*s-f*a,u=f*o-d*s,r=Math.sqrt(c*c+l*l+u*u),r?(r=1/r,c*=r,l*=r,u*=r):(c=0,l=0,u=0),n[0]=s,n[1]=c,n[2]=f,n[3]=0,n[4]=o,n[5]=l,n[6]=d,n[7]=0,n[8]=a,n[9]=u,n[10]=h,n[11]=0,n[12]=-(s*p+o*m+a*g),n[13]=-(c*p+l*m+u*g),n[14]=-(f*p+d*m+h*g),n[15]=1,n)}function _D(n,e,t,i){let r=e[0],s=e[1],o=e[2],a=i[0],c=i[1],l=i[2],u=r-t[0],f=s-t[1],d=o-t[2],h=u*u+f*f+d*d;h>0&&(h=1/Math.sqrt(h),u*=h,f*=h,d*=h);let p=c*d-l*f,m=l*u-a*d,g=a*f-c*u;return h=p*p+m*m+g*g,h>0&&(h=1/Math.sqrt(h),p*=h,m*=h,g*=h),n[0]=p,n[1]=m,n[2]=g,n[3]=0,n[4]=f*g-d*m,n[5]=d*p-u*g,n[6]=u*m-f*p,n[7]=0,n[8]=u,n[9]=f,n[10]=d,n[11]=0,n[12]=r,n[13]=s,n[14]=o,n[15]=1,n}function yD(n){return`mat4(${n[0]}, ${n[1]}, ${n[2]}, ${n[3]}, ${n[4]}, ${n[5]}, ${n[6]}, ${n[7]}, ${n[8]}, ${n[9]}, ${n[10]}, ${n[11]}, ${n[12]}, ${n[13]}, ${n[14]}, ${n[15]})`}function bD(n){return Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]+n[3]*n[3]+n[4]*n[4]+n[5]*n[5]+n[6]*n[6]+n[7]*n[7]+n[8]*n[8]+n[9]*n[9]+n[10]*n[10]+n[11]*n[11]+n[12]*n[12]+n[13]*n[13]+n[14]*n[14]+n[15]*n[15])}function vD(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n[3]=e[3]+t[3],n[4]=e[4]+t[4],n[5]=e[5]+t[5],n[6]=e[6]+t[6],n[7]=e[7]+t[7],n[8]=e[8]+t[8],n[9]=e[9]+t[9],n[10]=e[10]+t[10],n[11]=e[11]+t[11],n[12]=e[12]+t[12],n[13]=e[13]+t[13],n[14]=e[14]+t[14],n[15]=e[15]+t[15],n}function wE(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n[3]=e[3]-t[3],n[4]=e[4]-t[4],n[5]=e[5]-t[5],n[6]=e[6]-t[6],n[7]=e[7]-t[7],n[8]=e[8]-t[8],n[9]=e[9]-t[9],n[10]=e[10]-t[10],n[11]=e[11]-t[11],n[12]=e[12]-t[12],n[13]=e[13]-t[13],n[14]=e[14]-t[14],n[15]=e[15]-t[15],n}function xD(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n[3]=e[3]*t,n[4]=e[4]*t,n[5]=e[5]*t,n[6]=e[6]*t,n[7]=e[7]*t,n[8]=e[8]*t,n[9]=e[9]*t,n[10]=e[10]*t,n[11]=e[11]*t,n[12]=e[12]*t,n[13]=e[13]*t,n[14]=e[14]*t,n[15]=e[15]*t,n}function wD(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n[2]=e[2]+t[2]*i,n[3]=e[3]+t[3]*i,n[4]=e[4]+t[4]*i,n[5]=e[5]+t[5]*i,n[6]=e[6]+t[6]*i,n[7]=e[7]+t[7]*i,n[8]=e[8]+t[8]*i,n[9]=e[9]+t[9]*i,n[10]=e[10]+t[10]*i,n[11]=e[11]+t[11]*i,n[12]=e[12]+t[12]*i,n[13]=e[13]+t[13]*i,n[14]=e[14]+t[14]*i,n[15]=e[15]+t[15]*i,n}function ED(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]&&n[3]===e[3]&&n[4]===e[4]&&n[5]===e[5]&&n[6]===e[6]&&n[7]===e[7]&&n[8]===e[8]&&n[9]===e[9]&&n[10]===e[10]&&n[11]===e[11]&&n[12]===e[12]&&n[13]===e[13]&&n[14]===e[14]&&n[15]===e[15]}function SD(n,e){let t=n[0],i=n[1],r=n[2],s=n[3],o=n[4],a=n[5],c=n[6],l=n[7],u=n[8],f=n[9],d=n[10],h=n[11],p=n[12],m=n[13],g=n[14],v=n[15],y=e[0],b=e[1],w=e[2],E=e[3],x=e[4],T=e[5],I=e[6],N=e[7],D=e[8],H=e[9],W=e[10],V=e[11],X=e[12],Y=e[13],ie=e[14],oe=e[15];return Math.abs(t-y)<=1e-6*Math.max(1,Math.abs(t),Math.abs(y))&&Math.abs(i-b)<=1e-6*Math.max(1,Math.abs(i),Math.abs(b))&&Math.abs(r-w)<=1e-6*Math.max(1,Math.abs(r),Math.abs(w))&&Math.abs(s-E)<=1e-6*Math.max(1,Math.abs(s),Math.abs(E))&&Math.abs(o-x)<=1e-6*Math.max(1,Math.abs(o),Math.abs(x))&&Math.abs(a-T)<=1e-6*Math.max(1,Math.abs(a),Math.abs(T))&&Math.abs(c-I)<=1e-6*Math.max(1,Math.abs(c),Math.abs(I))&&Math.abs(l-N)<=1e-6*Math.max(1,Math.abs(l),Math.abs(N))&&Math.abs(u-D)<=1e-6*Math.max(1,Math.abs(u),Math.abs(D))&&Math.abs(f-H)<=1e-6*Math.max(1,Math.abs(f),Math.abs(H))&&Math.abs(d-W)<=1e-6*Math.max(1,Math.abs(d),Math.abs(W))&&Math.abs(h-V)<=1e-6*Math.max(1,Math.abs(h),Math.abs(V))&&Math.abs(p-X)<=1e-6*Math.max(1,Math.abs(p),Math.abs(X))&&Math.abs(m-Y)<=1e-6*Math.max(1,Math.abs(m),Math.abs(Y))&&Math.abs(g-ie)<=1e-6*Math.max(1,Math.abs(g),Math.abs(ie))&&Math.abs(v-oe)<=1e-6*Math.max(1,Math.abs(v),Math.abs(oe))}var Ug,$g,PD,CD,Vg=C(()=>{$r();Ug=vE;$g=xE;PD=Xa,CD=wE});var At={};ui(At,{add:()=>LE,ceil:()=>TD,clone:()=>SE,copy:()=>CE,create:()=>EE,cross:()=>OD,dist:()=>WD,distance:()=>IE,div:()=>VD,divide:()=>kE,dot:()=>OE,equals:()=>UD,exactEquals:()=>NE,floor:()=>LD,forEach:()=>qD,fromValues:()=>PE,inverse:()=>BD,len:()=>HD,length:()=>Wg,lerp:()=>DE,max:()=>AD,min:()=>MD,mul:()=>GD,multiply:()=>AE,negate:()=>ID,normalize:()=>Hg,random:()=>DD,round:()=>kD,scale:()=>RE,scaleAndAdd:()=>RD,set:()=>TE,sqrDist:()=>jD,sqrLen:()=>YD,squaredDistance:()=>BE,squaredLength:()=>jg,str:()=>zD,sub:()=>$D,subtract:()=>ME,transformMat4:()=>Yg,transformQuat:()=>ND,zero:()=>FD});function EE(){let n=new ve(4);return ve!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0,n[3]=0),n}function SE(n){let e=new ve(4);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e}function PE(n,e,t,i){let r=new ve(4);return r[0]=n,r[1]=e,r[2]=t,r[3]=i,r}function CE(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n}function TE(n,e,t,i,r){return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n}function LE(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n[3]=e[3]+t[3],n}function ME(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n[3]=e[3]-t[3],n}function AE(n,e,t){return n[0]=e[0]*t[0],n[1]=e[1]*t[1],n[2]=e[2]*t[2],n[3]=e[3]*t[3],n}function kE(n,e,t){return n[0]=e[0]/t[0],n[1]=e[1]/t[1],n[2]=e[2]/t[2],n[3]=e[3]/t[3],n}function TD(n,e){return n[0]=Math.ceil(e[0]),n[1]=Math.ceil(e[1]),n[2]=Math.ceil(e[2]),n[3]=Math.ceil(e[3]),n}function LD(n,e){return n[0]=Math.floor(e[0]),n[1]=Math.floor(e[1]),n[2]=Math.floor(e[2]),n[3]=Math.floor(e[3]),n}function MD(n,e,t){return n[0]=Math.min(e[0],t[0]),n[1]=Math.min(e[1],t[1]),n[2]=Math.min(e[2],t[2]),n[3]=Math.min(e[3],t[3]),n}function AD(n,e,t){return n[0]=Math.max(e[0],t[0]),n[1]=Math.max(e[1],t[1]),n[2]=Math.max(e[2],t[2]),n[3]=Math.max(e[3],t[3]),n}function kD(n,e){return n[0]=qt(e[0]),n[1]=qt(e[1]),n[2]=qt(e[2]),n[3]=qt(e[3]),n}function RE(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n[3]=e[3]*t,n}function RD(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n[2]=e[2]+t[2]*i,n[3]=e[3]+t[3]*i,n}function IE(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2],s=e[3]-n[3];return Math.sqrt(t*t+i*i+r*r+s*s)}function BE(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2],s=e[3]-n[3];return t*t+i*i+r*r+s*s}function Wg(n){let e=n[0],t=n[1],i=n[2],r=n[3];return Math.sqrt(e*e+t*t+i*i+r*r)}function jg(n){let e=n[0],t=n[1],i=n[2],r=n[3];return e*e+t*t+i*i+r*r}function ID(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n[3]=-e[3],n}function BD(n,e){return n[0]=1/e[0],n[1]=1/e[1],n[2]=1/e[2],n[3]=1/e[3],n}function Hg(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],o=t*t+i*i+r*r+s*s;return o>0&&(o=1/Math.sqrt(o)),n[0]=t*o,n[1]=i*o,n[2]=r*o,n[3]=s*o,n}function OE(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]+n[3]*e[3]}function OD(n,e,t,i){let r=t[0]*i[1]-t[1]*i[0],s=t[0]*i[2]-t[2]*i[0],o=t[0]*i[3]-t[3]*i[0],a=t[1]*i[2]-t[2]*i[1],c=t[1]*i[3]-t[3]*i[1],l=t[2]*i[3]-t[3]*i[2],u=e[0],f=e[1],d=e[2],h=e[3];return n[0]=f*l-d*c+h*a,n[1]=-(u*l)+d*o-h*s,n[2]=u*c-f*o+h*r,n[3]=-(u*a)+f*s-d*r,n}function DE(n,e,t,i){let r=e[0],s=e[1],o=e[2],a=e[3];return n[0]=r+i*(t[0]-r),n[1]=s+i*(t[1]-s),n[2]=o+i*(t[2]-o),n[3]=a+i*(t[3]-a),n}function DD(n,e){e=e===void 0?1:e;let t,i,r,s,o,a;do t=Fn()*2-1,i=Fn()*2-1,o=t*t+i*i;while(o>=1);do r=Fn()*2-1,s=Fn()*2-1,a=r*r+s*s;while(a>=1);let c=Math.sqrt((1-o)/a);return n[0]=e*t,n[1]=e*i,n[2]=e*r*c,n[3]=e*s*c,n}function Yg(n,e,t){let i=e[0],r=e[1],s=e[2],o=e[3];return n[0]=t[0]*i+t[4]*r+t[8]*s+t[12]*o,n[1]=t[1]*i+t[5]*r+t[9]*s+t[13]*o,n[2]=t[2]*i+t[6]*r+t[10]*s+t[14]*o,n[3]=t[3]*i+t[7]*r+t[11]*s+t[15]*o,n}function ND(n,e,t){let i=e[0],r=e[1],s=e[2],o=t[0],a=t[1],c=t[2],l=t[3],u=l*i+a*s-c*r,f=l*r+c*i-o*s,d=l*s+o*r-a*i,h=-o*i-a*r-c*s;return n[0]=u*l+h*-o+f*-c-d*-a,n[1]=f*l+h*-a+d*-o-u*-c,n[2]=d*l+h*-c+u*-a-f*-o,n[3]=e[3],n}function FD(n){return n[0]=0,n[1]=0,n[2]=0,n[3]=0,n}function zD(n){return`vec4(${n[0]}, ${n[1]}, ${n[2]}, ${n[3]})`}function NE(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]&&n[3]===e[3]}function UD(n,e){let t=n[0],i=n[1],r=n[2],s=n[3],o=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(t-o)<=1e-6*Math.max(1,Math.abs(t),Math.abs(o))&&Math.abs(i-a)<=1e-6*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(r-c)<=1e-6*Math.max(1,Math.abs(r),Math.abs(c))&&Math.abs(s-l)<=1e-6*Math.max(1,Math.abs(s),Math.abs(l))}var $D,GD,VD,WD,jD,HD,YD,qD,rf=C(()=>{$r();$D=ME,GD=AE,VD=kE,WD=IE,jD=BE,HD=Wg,YD=jg,qD=function(){let n=EE();return function(e,t,i,r,s,o){let a,c;for(t||(t=4),i||(i=0),r?c=Math.min(r*t+i,e.length):c=e.length,a=i;aMath.PI*2)throw Error("expected radians")}function e4(n,e,t,i,r,s){let o=2*s/(t-e),a=2*s/(r-i),c=(t+e)/(t-e),l=(r+i)/(r-i),u=-1,f=-1,d=-2*s;return n[0]=o,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=a,n[6]=0,n[7]=0,n[8]=c,n[9]=l,n[10]=u,n[11]=f,n[12]=0,n[13]=0,n[14]=d,n[15]=0,n}var Xg,ZD,XD,qg,Zg,KD,Ne,sf,of,zE=C(()=>{pE();Ha();yg();Vg();_g();Za();rf();(function(n){n[n.COL0ROW0=0]="COL0ROW0",n[n.COL0ROW1=1]="COL0ROW1",n[n.COL0ROW2=2]="COL0ROW2",n[n.COL0ROW3=3]="COL0ROW3",n[n.COL1ROW0=4]="COL1ROW0",n[n.COL1ROW1=5]="COL1ROW1",n[n.COL1ROW2=6]="COL1ROW2",n[n.COL1ROW3=7]="COL1ROW3",n[n.COL2ROW0=8]="COL2ROW0",n[n.COL2ROW1=9]="COL2ROW1",n[n.COL2ROW2=10]="COL2ROW2",n[n.COL2ROW3=11]="COL2ROW3",n[n.COL3ROW0=12]="COL3ROW0",n[n.COL3ROW1=13]="COL3ROW1",n[n.COL3ROW2=14]="COL3ROW2",n[n.COL3ROW3=15]="COL3ROW3"})(Xg||(Xg={}));ZD=45*Math.PI/180,XD=1,qg=.1,Zg=500,KD=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),Ne=class extends nf{static get IDENTITY(){return JD()}static get ZERO(){return QD()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Xg}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,i,r,s,o,a,c,l,u,f,d,h,p,m,g){return this[0]=e,this[1]=t,this[2]=i,this[3]=r,this[4]=s,this[5]=o,this[6]=a,this[7]=c,this[8]=l,this[9]=u,this[10]=f,this[11]=d,this[12]=h,this[13]=p,this[14]=m,this[15]=g,this.check()}setRowMajor(e,t,i,r,s,o,a,c,l,u,f,d,h,p,m,g){return this[0]=e,this[1]=s,this[2]=l,this[3]=h,this[4]=t,this[5]=o,this[6]=u,this[7]=p,this[8]=i,this[9]=a,this[10]=f,this[11]=m,this[12]=r,this[13]=c,this[14]=d,this[15]=g,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(KD)}fromObject(e){return this.check()}fromQuaternion(e){return Fg(this,e),this.check()}frustum(e){let{left:t,right:i,bottom:r,top:s,near:o=qg,far:a=Zg}=e;return a===1/0?e4(this,t,i,r,s,o):zg(this,t,i,r,s,o,a),this.check()}lookAt(e){let{eye:t,center:i=[0,0,0],up:r=[0,1,0]}=e;return Gg(this,t,i,r),this.check()}ortho(e){let{left:t,right:i,bottom:r,top:s,near:o=qg,far:a=Zg}=e;return $g(this,t,i,r,s,o,a),this.check()}orthographic(e){let{fovy:t=ZD,aspect:i=XD,focalDistance:r=1,near:s=qg,far:o=Zg}=e;FE(t);let a=t/2,c=r*Math.tan(a),l=c*i;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:s,far:o})}perspective(e){let{fovy:t=45*Math.PI/180,aspect:i=1,near:r=.1,far:s=500}=e;return FE(t),Ug(this,t,i,r,s),this.check()}determinant(){return kg(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let i=this.getScale(t),r=1/i[0],s=1/i[1],o=1/i[2];return e[0]=this[0]*r,e[1]=this[1]*s,e[2]=this[2]*o,e[3]=0,e[4]=this[4]*r,e[5]=this[5]*s,e[6]=this[6]*o,e[7]=0,e[8]=this[8]*r,e[9]=this[9]*s,e[10]=this[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let i=this.getScale(t),r=1/i[0],s=1/i[1],o=1/i[2];return e[0]=this[0]*r,e[1]=this[1]*s,e[2]=this[2]*o,e[3]=this[4]*r,e[4]=this[5]*s,e[5]=this[6]*o,e[6]=this[8]*r,e[7]=this[9]*s,e[8]=this[10]*o,e}transpose(){return Mg(this,this),this.check()}invert(){return Ag(this,this),this.check()}multiplyLeft(e){return Xa(this,e,this),this.check()}multiplyRight(e){return Xa(this,this,e),this.check()}rotateX(e){return Og(this,this,e),this.check()}rotateY(e){return Dg(this,this,e),this.check()}rotateZ(e){return Ng(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return Bg(this,this,e,t),this.check()}scale(e){return Ig(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return Rg(this,this,e),this.check()}transform(e,t){return e.length===4?(t=Yg(t||[-0,-0,-0,-0],e,this),Xu(t,4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){let{length:i}=e,r;switch(i){case 2:r=gg(t||[-0,-0],e,this);break;case 3:r=qa(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Xu(r,e.length),r}transformAsVector(e,t){let i;switch(e.length){case 2:i=rE(t||[-0,-0],e,this);break;case 3:i=Qu(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Xu(i,e.length),i}transformPoint(e,t){return this.transformAsPoint(e,t)}transformVector(e,t){return this.transformAsPoint(e,t)}transformDirection(e,t){return this.transformAsVector(e,t)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,i){return this.identity().translate([e,t,i])}}});function UE(){let n=new ve(4);return ve!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n[3]=1,n}function t4(n,e,t){t=t*.5;let i=Math.sin(t);return n[0]=i*e[0],n[1]=i*e[1],n[2]=i*e[2],n[3]=Math.cos(t),n}function Kg(n,e,t,i){let r=e[0],s=e[1],o=e[2],a=e[3],c=t[0],l=t[1],u=t[2],f=t[3],d,h,p,m,g;return d=r*c+s*l+o*u+a*f,d<0&&(d=-d,c=-c,l=-l,u=-u,f=-f),1-d>1e-6?(h=Math.acos(d),g=Math.sin(h),p=Math.sin((1-i)*h)/g,m=Math.sin(i*h)/g):(p=1-i,m=i),n[0]=p*r+m*c,n[1]=p*s+m*l,n[2]=p*o+m*u,n[3]=p*a+m*f,n}function n4(n,e){let t=e[0]+e[4]+e[8],i;if(t>0)i=Math.sqrt(t+1),n[3]=.5*i,i=.5/i,n[0]=(e[5]-e[7])*i,n[1]=(e[6]-e[2])*i,n[2]=(e[1]-e[3])*i;else{let r=0;e[4]>e[0]&&(r=1),e[8]>e[r*3+r]&&(r=2);let s=(r+1)%3,o=(r+2)%3;i=Math.sqrt(e[r*3+r]-e[s*3+s]-e[o*3+o]+1),n[r]=.5*i,i=.5/i,n[3]=(e[s*3+o]-e[o*3+s])*i,n[s]=(e[s*3+r]+e[r*3+s])*i,n[o]=(e[o*3+r]+e[r*3+o])*i}return n}var $E,SK,PK,CK,GE=C(()=>{$r();Lg();Za();rf();$E=Hg,SK=function(){let n=Ju(),e=ef(1,0,0),t=ef(0,1,0);return function(i,r,s){let o=Ya(r,s);return o<-.999999?(Gr(n,e,r),Cg(n)<1e-6&&Gr(n,t,r),bg(n,n),t4(i,n,Math.PI),i):o>.999999?(i[0]=0,i[1]=0,i[2]=0,i[3]=1,i):(Gr(n,r,s),i[0]=n[0],i[1]=n[1],i[2]=n[2],i[3]=1+o,$E(i,i))}}(),PK=function(){let n=UE(),e=UE();return function(t,i,r,s,o,a){return Kg(n,i,o,a),Kg(e,r,s,a),Kg(t,n,e,2*a*(1-a)),t}}(),CK=function(){let n=mE();return function(e,t,i,r){return n[0]=i[0],n[3]=i[1],n[6]=i[2],n[1]=r[0],n[4]=r[1],n[7]=r[2],n[2]=-t[0],n[5]=-t[1],n[8]=-t[2],$E(e,n4(e,n))}}()});var TK,LK,MK,AK,VE=C(()=>{TK=Math.PI/2,LK=Math.PI/4,MK=Math.PI/6,AK=Math.PI*2});var Fe=C(()=>{hE();zE();VE();Ks();Lg();Vg();GE();_g();Za();rf()});function Qg(n,e=[],t=0){let i=Math.fround(n),r=n-i;return e[t]=i,e[t+1]=r,e}function WE(n){return n-Math.fround(n)}function jE(n){let e=new Float32Array(32);for(let t=0;t<4;++t)for(let i=0;i<4;++i){let r=t*4+i;Qg(n[i*4+t],e,r*2)}return e}var HE=C(()=>{});function af(n,e=!0){return n??e}function Jg(n=[0,0,0],e=!0){return e?n.map(t=>t/255):[...n]}function YE(n,e=!0){let t=Jg(n.slice(0,3),e),i=Number.isFinite(n[3]),r=i?n[3]:1;return[t[0],t[1],t[2],e&&i?r/255:r]}var e_=C(()=>{});var s4,o4,Vr,qE=C(()=>{s4=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND +}`,OB=`#version 300 es +${BB}`});function pg(n,{precision:e=Ye.precision}={}){return n=FB(n),`${parseFloat(n.toPrecision(e))}`}function vi(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Te(n,e,t){return UB(n,i=>Math.max(e,Math.min(t,i)))}function fn(n,e,t){return vi(n)?n.map((i,r)=>fn(i,e[r],t)):t*e+(1-t)*n}function $n(n,e,t){let i=Ye.EPSILON;t&&(Ye.EPSILON=t);try{if(n===e)return!0;if(vi(n)&&vi(e)){if(n.length!==e.length)return!1;for(let r=0;r{KX=1/Math.PI*180,QX=1/180*Math.PI,NB={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...NB}};Ye=globalThis.mathgl.config});var Qs,mg=C(()=>{Ks();Qs=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,t=0){for(let i=0;i0?", ":"")+pg(this[i],e);return`${e.printTypes?this.constructor.name:""}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t{Ks()});function gg(n,e){if(!n)throw new Error(`math.gl assertion ${e}`)}var Zw=C(()=>{});var Qu,Xw=C(()=>{mg();Ya();Zw();Qu=class extends Qs{get x(){return this[0]}set x(e){this[0]=Je(e)}get y(){return this[1]}set y(e){this[1]=Je(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let t=0;t=0&&e=0&&e=0?Math.round(n):n%.5===0?Math.floor(n):Math.round(n)}var we,Gn,lK,$r=C(()=>{we=typeof Float32Array<"u"?Float32Array:Array,Gn=Math.random;lK=Math.PI/180});var dt={};mi(dt,{add:()=>HB,angle:()=>fO,ceil:()=>YB,clone:()=>GB,copy:()=>WB,create:()=>Kw,cross:()=>rO,dist:()=>vO,distance:()=>tE,div:()=>bO,divide:()=>eE,dot:()=>iO,equals:()=>mO,exactEquals:()=>pO,floor:()=>qB,forEach:()=>EO,fromValues:()=>VB,inverse:()=>tO,len:()=>gO,length:()=>iE,lerp:()=>sO,max:()=>XB,min:()=>ZB,mul:()=>yO,multiply:()=>Jw,negate:()=>eO,normalize:()=>nO,random:()=>oO,rotate:()=>uO,round:()=>KB,scale:()=>QB,scaleAndAdd:()=>JB,set:()=>jB,sqrDist:()=>xO,sqrLen:()=>wO,squaredDistance:()=>nE,squaredLength:()=>rE,str:()=>hO,sub:()=>_O,subtract:()=>Qw,transformMat2:()=>aO,transformMat2d:()=>cO,transformMat3:()=>lO,transformMat4:()=>_g,zero:()=>dO});function Kw(){let n=new we(2);return we!=Float32Array&&(n[0]=0,n[1]=0),n}function GB(n){let e=new we(2);return e[0]=n[0],e[1]=n[1],e}function VB(n,e){let t=new we(2);return t[0]=n,t[1]=e,t}function WB(n,e){return n[0]=e[0],n[1]=e[1],n}function jB(n,e,t){return n[0]=e,n[1]=t,n}function HB(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n}function Qw(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n}function Jw(n,e,t){return n[0]=e[0]*t[0],n[1]=e[1]*t[1],n}function eE(n,e,t){return n[0]=e[0]/t[0],n[1]=e[1]/t[1],n}function YB(n,e){return n[0]=Math.ceil(e[0]),n[1]=Math.ceil(e[1]),n}function qB(n,e){return n[0]=Math.floor(e[0]),n[1]=Math.floor(e[1]),n}function ZB(n,e,t){return n[0]=Math.min(e[0],t[0]),n[1]=Math.min(e[1],t[1]),n}function XB(n,e,t){return n[0]=Math.max(e[0],t[0]),n[1]=Math.max(e[1],t[1]),n}function KB(n,e){return n[0]=Qt(e[0]),n[1]=Qt(e[1]),n}function QB(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n}function JB(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n}function tE(n,e){let t=e[0]-n[0],i=e[1]-n[1];return Math.sqrt(t*t+i*i)}function nE(n,e){let t=e[0]-n[0],i=e[1]-n[1];return t*t+i*i}function iE(n){let e=n[0],t=n[1];return Math.sqrt(e*e+t*t)}function rE(n){let e=n[0],t=n[1];return e*e+t*t}function eO(n,e){return n[0]=-e[0],n[1]=-e[1],n}function tO(n,e){return n[0]=1/e[0],n[1]=1/e[1],n}function nO(n,e){let t=e[0],i=e[1],r=t*t+i*i;return r>0&&(r=1/Math.sqrt(r)),n[0]=e[0]*r,n[1]=e[1]*r,n}function iO(n,e){return n[0]*e[0]+n[1]*e[1]}function rO(n,e,t){let i=e[0]*t[1]-e[1]*t[0];return n[0]=n[1]=0,n[2]=i,n}function sO(n,e,t,i){let r=e[0],s=e[1];return n[0]=r+i*(t[0]-r),n[1]=s+i*(t[1]-s),n}function oO(n,e){e=e===void 0?1:e;let t=Gn()*2*Math.PI;return n[0]=Math.cos(t)*e,n[1]=Math.sin(t)*e,n}function aO(n,e,t){let i=e[0],r=e[1];return n[0]=t[0]*i+t[2]*r,n[1]=t[1]*i+t[3]*r,n}function cO(n,e,t){let i=e[0],r=e[1];return n[0]=t[0]*i+t[2]*r+t[4],n[1]=t[1]*i+t[3]*r+t[5],n}function lO(n,e,t){let i=e[0],r=e[1];return n[0]=t[0]*i+t[3]*r+t[6],n[1]=t[1]*i+t[4]*r+t[7],n}function _g(n,e,t){let i=e[0],r=e[1];return n[0]=t[0]*i+t[4]*r+t[12],n[1]=t[1]*i+t[5]*r+t[13],n}function uO(n,e,t,i){let r=e[0]-t[0],s=e[1]-t[1],o=Math.sin(i),a=Math.cos(i);return n[0]=r*a-s*o+t[0],n[1]=r*o+s*a+t[1],n}function fO(n,e){let t=n[0],i=n[1],r=e[0],s=e[1],o=Math.sqrt((t*t+i*i)*(r*r+s*s)),a=o&&(t*r+i*s)/o;return Math.acos(Math.min(Math.max(a,-1),1))}function dO(n){return n[0]=0,n[1]=0,n}function hO(n){return`vec2(${n[0]}, ${n[1]})`}function pO(n,e){return n[0]===e[0]&&n[1]===e[1]}function mO(n,e){let t=n[0],i=n[1],r=e[0],s=e[1];return Math.abs(t-r)<=1e-6*Math.max(1,Math.abs(t),Math.abs(r))&&Math.abs(i-s)<=1e-6*Math.max(1,Math.abs(i),Math.abs(s))}var gO,_O,yO,bO,vO,xO,wO,EO,yg=C(()=>{$r();gO=iE,_O=Qw,yO=Jw,bO=eE,vO=tE,xO=nE,wO=rE,EO=function(){let n=Kw();return function(e,t,i,r,s,o){let a,c;for(t||(t=2),i||(i=0),r?c=Math.min(r*t+i,e.length):c=e.length,a=i;a{});var bt={};mi(bt,{add:()=>TO,angle:()=>Cg,bezier:()=>UO,ceil:()=>LO,clone:()=>SO,copy:()=>PO,create:()=>ef,cross:()=>Gr,dist:()=>ZO,distance:()=>fE,div:()=>qO,divide:()=>uE,dot:()=>qa,equals:()=>jO,exactEquals:()=>WO,floor:()=>MO,forEach:()=>QO,fromValues:()=>tf,hermite:()=>zO,inverse:()=>DO,len:()=>Tg,length:()=>aE,lerp:()=>NO,max:()=>kO,min:()=>AO,mul:()=>YO,multiply:()=>lE,negate:()=>OO,normalize:()=>vg,random:()=>$O,rotateX:()=>Eg,rotateY:()=>Sg,rotateZ:()=>Pg,round:()=>RO,scale:()=>IO,scaleAndAdd:()=>BO,set:()=>CO,slerp:()=>FO,sqrDist:()=>XO,sqrLen:()=>KO,squaredDistance:()=>dE,squaredLength:()=>hE,str:()=>VO,sub:()=>HO,subtract:()=>cE,transformMat3:()=>xg,transformMat4:()=>Za,transformQuat:()=>wg,zero:()=>GO});function ef(){let n=new we(3);return we!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n}function SO(n){let e=new we(3);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e}function aE(n){let e=n[0],t=n[1],i=n[2];return Math.sqrt(e*e+t*t+i*i)}function tf(n,e,t){let i=new we(3);return i[0]=n,i[1]=e,i[2]=t,i}function PO(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n}function CO(n,e,t,i){return n[0]=e,n[1]=t,n[2]=i,n}function TO(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n}function cE(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n}function lE(n,e,t){return n[0]=e[0]*t[0],n[1]=e[1]*t[1],n[2]=e[2]*t[2],n}function uE(n,e,t){return n[0]=e[0]/t[0],n[1]=e[1]/t[1],n[2]=e[2]/t[2],n}function LO(n,e){return n[0]=Math.ceil(e[0]),n[1]=Math.ceil(e[1]),n[2]=Math.ceil(e[2]),n}function MO(n,e){return n[0]=Math.floor(e[0]),n[1]=Math.floor(e[1]),n[2]=Math.floor(e[2]),n}function AO(n,e,t){return n[0]=Math.min(e[0],t[0]),n[1]=Math.min(e[1],t[1]),n[2]=Math.min(e[2],t[2]),n}function kO(n,e,t){return n[0]=Math.max(e[0],t[0]),n[1]=Math.max(e[1],t[1]),n[2]=Math.max(e[2],t[2]),n}function RO(n,e){return n[0]=Qt(e[0]),n[1]=Qt(e[1]),n[2]=Qt(e[2]),n}function IO(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n}function BO(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n[2]=e[2]+t[2]*i,n}function fE(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2];return Math.sqrt(t*t+i*i+r*r)}function dE(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2];return t*t+i*i+r*r}function hE(n){let e=n[0],t=n[1],i=n[2];return e*e+t*t+i*i}function OO(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n}function DO(n,e){return n[0]=1/e[0],n[1]=1/e[1],n[2]=1/e[2],n}function vg(n,e){let t=e[0],i=e[1],r=e[2],s=t*t+i*i+r*r;return s>0&&(s=1/Math.sqrt(s)),n[0]=e[0]*s,n[1]=e[1]*s,n[2]=e[2]*s,n}function qa(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]}function Gr(n,e,t){let i=e[0],r=e[1],s=e[2],o=t[0],a=t[1],c=t[2];return n[0]=r*c-s*a,n[1]=s*o-i*c,n[2]=i*a-r*o,n}function NO(n,e,t,i){let r=e[0],s=e[1],o=e[2];return n[0]=r+i*(t[0]-r),n[1]=s+i*(t[1]-s),n[2]=o+i*(t[2]-o),n}function FO(n,e,t,i){let r=Math.acos(Math.min(Math.max(qa(e,t),-1),1)),s=Math.sin(r),o=Math.sin((1-i)*r)/s,a=Math.sin(i*r)/s;return n[0]=o*e[0]+a*t[0],n[1]=o*e[1]+a*t[1],n[2]=o*e[2]+a*t[2],n}function zO(n,e,t,i,r,s){let o=s*s,a=o*(2*s-3)+1,c=o*(s-2)+s,l=o*(s-1),u=o*(3-2*s);return n[0]=e[0]*a+t[0]*c+i[0]*l+r[0]*u,n[1]=e[1]*a+t[1]*c+i[1]*l+r[1]*u,n[2]=e[2]*a+t[2]*c+i[2]*l+r[2]*u,n}function UO(n,e,t,i,r,s){let o=1-s,a=o*o,c=s*s,l=a*o,u=3*s*a,f=3*c*o,d=c*s;return n[0]=e[0]*l+t[0]*u+i[0]*f+r[0]*d,n[1]=e[1]*l+t[1]*u+i[1]*f+r[1]*d,n[2]=e[2]*l+t[2]*u+i[2]*f+r[2]*d,n}function $O(n,e){e=e===void 0?1:e;let t=Gn()*2*Math.PI,i=Gn()*2-1,r=Math.sqrt(1-i*i)*e;return n[0]=Math.cos(t)*r,n[1]=Math.sin(t)*r,n[2]=i*e,n}function Za(n,e,t){let i=e[0],r=e[1],s=e[2],o=t[3]*i+t[7]*r+t[11]*s+t[15];return o=o||1,n[0]=(t[0]*i+t[4]*r+t[8]*s+t[12])/o,n[1]=(t[1]*i+t[5]*r+t[9]*s+t[13])/o,n[2]=(t[2]*i+t[6]*r+t[10]*s+t[14])/o,n}function xg(n,e,t){let i=e[0],r=e[1],s=e[2];return n[0]=i*t[0]+r*t[3]+s*t[6],n[1]=i*t[1]+r*t[4]+s*t[7],n[2]=i*t[2]+r*t[5]+s*t[8],n}function wg(n,e,t){let i=t[0],r=t[1],s=t[2],o=t[3],a=e[0],c=e[1],l=e[2],u=r*l-s*c,f=s*a-i*l,d=i*c-r*a,h=r*d-s*f,p=s*u-i*d,m=i*f-r*u,g=o*2;return u*=g,f*=g,d*=g,h*=2,p*=2,m*=2,n[0]=a+u+h,n[1]=c+f+p,n[2]=l+d+m,n}function Eg(n,e,t,i){let r=[],s=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],s[0]=r[0],s[1]=r[1]*Math.cos(i)-r[2]*Math.sin(i),s[2]=r[1]*Math.sin(i)+r[2]*Math.cos(i),n[0]=s[0]+t[0],n[1]=s[1]+t[1],n[2]=s[2]+t[2],n}function Sg(n,e,t,i){let r=[],s=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],s[0]=r[2]*Math.sin(i)+r[0]*Math.cos(i),s[1]=r[1],s[2]=r[2]*Math.cos(i)-r[0]*Math.sin(i),n[0]=s[0]+t[0],n[1]=s[1]+t[1],n[2]=s[2]+t[2],n}function Pg(n,e,t,i){let r=[],s=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],s[0]=r[0]*Math.cos(i)-r[1]*Math.sin(i),s[1]=r[0]*Math.sin(i)+r[1]*Math.cos(i),s[2]=r[2],n[0]=s[0]+t[0],n[1]=s[1]+t[1],n[2]=s[2]+t[2],n}function Cg(n,e){let t=n[0],i=n[1],r=n[2],s=e[0],o=e[1],a=e[2],c=Math.sqrt((t*t+i*i+r*r)*(s*s+o*o+a*a)),l=c&&qa(n,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function GO(n){return n[0]=0,n[1]=0,n[2]=0,n}function VO(n){return`vec3(${n[0]}, ${n[1]}, ${n[2]})`}function WO(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]}function jO(n,e){let t=n[0],i=n[1],r=n[2],s=e[0],o=e[1],a=e[2];return Math.abs(t-s)<=1e-6*Math.max(1,Math.abs(t),Math.abs(s))&&Math.abs(i-o)<=1e-6*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(r-a)<=1e-6*Math.max(1,Math.abs(r),Math.abs(a))}var HO,YO,qO,ZO,XO,Tg,KO,QO,Xa=C(()=>{$r();HO=cE,YO=lE,qO=uE,ZO=fE,XO=dE,Tg=aE,KO=hE,QO=function(){let n=ef();return function(e,t,i,r,s,o){let a,c;for(t||(t=3),i||(i=0),r?c=Math.min(r*t+i,e.length):c=e.length,a=i;a{Xw();Ks();Ya();Xa();bg();Lg=[0,0,0],et=class n extends Qu{static get ZERO(){return nf||(nf=new n(0,0,0),Object.freeze(nf)),nf}constructor(e=0,t=0,i=0){super(-0,-0,-0),arguments.length===1&&vi(e)?this.copy(e):(Ye.debug&&(Je(e),Je(t),Je(i)),this[0]=e,this[1]=t,this[2]=i)}set(e,t,i){return this[0]=e,this[1]=t,this[2]=i,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return Ye.debug&&(Je(e.x),Je(e.y),Je(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=Je(e)}angle(e){return Cg(this,e)}cross(e){return Gr(this,this,e),this.check()}rotateX({radians:e,origin:t=Lg}){return Eg(this,this,t,e),this.check()}rotateY({radians:e,origin:t=Lg}){return Sg(this,this,t,e),this.check()}rotateZ({radians:e,origin:t=Lg}){return Pg(this,this,t,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return Za(this,this,e),this.check()}transformAsVector(e){return Ju(this,this,e),this.check()}transformByMatrix3(e){return xg(this,this,e),this.check()}transformByMatrix2(e){return oE(this,this,e),this.check()}transformByQuaternion(e){return wg(this,this,e),this.check()}}});var rf,mE=C(()=>{mg();Ya();Ks();rf=class extends Qs{toString(){let e="[";if(Ye.printRowMajor){e+="row-major:";for(let t=0;t{$r()});var Ve={};mi(Ve,{add:()=>ED,adjoint:()=>rD,clone:()=>eD,copy:()=>tD,create:()=>JO,decompose:()=>pD,determinant:()=>Rg,equals:()=>TD,exactEquals:()=>CD,frob:()=>wD,fromQuat:()=>zg,fromQuat2:()=>fD,fromRotation:()=>aD,fromRotationTranslation:()=>bE,fromRotationTranslationScale:()=>mD,fromRotationTranslationScaleOrigin:()=>gD,fromScaling:()=>oD,fromTranslation:()=>sD,fromValues:()=>nD,fromXRotation:()=>cD,fromYRotation:()=>lD,fromZRotation:()=>uD,frustum:()=>Ug,getRotation:()=>hD,getScaling:()=>vE,getTranslation:()=>dD,identity:()=>yE,invert:()=>kg,lookAt:()=>Vg,mul:()=>LD,multiply:()=>Ka,multiplyScalar:()=>SD,multiplyScalarAndAdd:()=>PD,ortho:()=>Gg,orthoNO:()=>wE,orthoZO:()=>bD,perspective:()=>$g,perspectiveFromFieldOfView:()=>yD,perspectiveNO:()=>xE,perspectiveZO:()=>_D,rotate:()=>Og,rotateX:()=>Dg,rotateY:()=>Ng,rotateZ:()=>Fg,scale:()=>Bg,set:()=>iD,str:()=>xD,sub:()=>MD,subtract:()=>EE,targetTo:()=>vD,translate:()=>Ig,transpose:()=>Ag});function JO(){let n=new we(16);return we!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0),n[0]=1,n[5]=1,n[10]=1,n[15]=1,n}function eD(n){let e=new we(16);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],e}function tD(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function nD(n,e,t,i,r,s,o,a,c,l,u,f,d,h,p,m){let g=new we(16);return g[0]=n,g[1]=e,g[2]=t,g[3]=i,g[4]=r,g[5]=s,g[6]=o,g[7]=a,g[8]=c,g[9]=l,g[10]=u,g[11]=f,g[12]=d,g[13]=h,g[14]=p,g[15]=m,g}function iD(n,e,t,i,r,s,o,a,c,l,u,f,d,h,p,m,g){return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n[4]=s,n[5]=o,n[6]=a,n[7]=c,n[8]=l,n[9]=u,n[10]=f,n[11]=d,n[12]=h,n[13]=p,n[14]=m,n[15]=g,n}function yE(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Ag(n,e){if(n===e){let t=e[1],i=e[2],r=e[3],s=e[6],o=e[7],a=e[11];n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=t,n[6]=e[9],n[7]=e[13],n[8]=i,n[9]=s,n[11]=e[14],n[12]=r,n[13]=o,n[14]=a}else n[0]=e[0],n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=e[1],n[5]=e[5],n[6]=e[9],n[7]=e[13],n[8]=e[2],n[9]=e[6],n[10]=e[10],n[11]=e[14],n[12]=e[3],n[13]=e[7],n[14]=e[11],n[15]=e[15];return n}function kg(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],d=e[10],h=e[11],p=e[12],m=e[13],g=e[14],v=e[15],y=t*a-i*o,b=t*c-r*o,x=t*l-s*o,E=i*c-r*a,w=i*l-s*a,T=r*l-s*c,R=u*m-f*p,F=u*g-d*p,O=u*v-h*p,j=f*g-d*m,V=f*v-h*m,G=d*v-h*g,q=y*G-b*V+x*j+E*O-w*F+T*R;return q?(q=1/q,n[0]=(a*G-c*V+l*j)*q,n[1]=(r*V-i*G-s*j)*q,n[2]=(m*T-g*w+v*E)*q,n[3]=(d*w-f*T-h*E)*q,n[4]=(c*O-o*G-l*F)*q,n[5]=(t*G-r*O+s*F)*q,n[6]=(g*x-p*T-v*b)*q,n[7]=(u*T-d*x+h*b)*q,n[8]=(o*V-a*O+l*R)*q,n[9]=(i*O-t*V-s*R)*q,n[10]=(p*w-m*x+v*y)*q,n[11]=(f*x-u*w-h*y)*q,n[12]=(a*F-o*j-c*R)*q,n[13]=(t*j-i*F+r*R)*q,n[14]=(m*b-p*E-g*y)*q,n[15]=(u*E-f*b+d*y)*q,n):null}function rD(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],d=e[10],h=e[11],p=e[12],m=e[13],g=e[14],v=e[15],y=t*a-i*o,b=t*c-r*o,x=t*l-s*o,E=i*c-r*a,w=i*l-s*a,T=r*l-s*c,R=u*m-f*p,F=u*g-d*p,O=u*v-h*p,j=f*g-d*m,V=f*v-h*m,G=d*v-h*g;return n[0]=a*G-c*V+l*j,n[1]=r*V-i*G-s*j,n[2]=m*T-g*w+v*E,n[3]=d*w-f*T-h*E,n[4]=c*O-o*G-l*F,n[5]=t*G-r*O+s*F,n[6]=g*x-p*T-v*b,n[7]=u*T-d*x+h*b,n[8]=o*V-a*O+l*R,n[9]=i*O-t*V-s*R,n[10]=p*w-m*x+v*y,n[11]=f*x-u*w-h*y,n[12]=a*F-o*j-c*R,n[13]=t*j-i*F+r*R,n[14]=m*b-p*E-g*y,n[15]=u*E-f*b+d*y,n}function Rg(n){let e=n[0],t=n[1],i=n[2],r=n[3],s=n[4],o=n[5],a=n[6],c=n[7],l=n[8],u=n[9],f=n[10],d=n[11],h=n[12],p=n[13],m=n[14],g=n[15],v=e*o-t*s,y=e*a-i*s,b=t*a-i*o,x=l*p-u*h,E=l*m-f*h,w=u*m-f*p,T=e*w-t*E+i*x,R=s*w-o*E+a*x,F=l*b-u*y+f*v,O=h*b-p*y+m*v;return c*T-r*R+g*F-d*O}function Ka(n,e,t){let i=e[0],r=e[1],s=e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=e[8],d=e[9],h=e[10],p=e[11],m=e[12],g=e[13],v=e[14],y=e[15],b=t[0],x=t[1],E=t[2],w=t[3];return n[0]=b*i+x*a+E*f+w*m,n[1]=b*r+x*c+E*d+w*g,n[2]=b*s+x*l+E*h+w*v,n[3]=b*o+x*u+E*p+w*y,b=t[4],x=t[5],E=t[6],w=t[7],n[4]=b*i+x*a+E*f+w*m,n[5]=b*r+x*c+E*d+w*g,n[6]=b*s+x*l+E*h+w*v,n[7]=b*o+x*u+E*p+w*y,b=t[8],x=t[9],E=t[10],w=t[11],n[8]=b*i+x*a+E*f+w*m,n[9]=b*r+x*c+E*d+w*g,n[10]=b*s+x*l+E*h+w*v,n[11]=b*o+x*u+E*p+w*y,b=t[12],x=t[13],E=t[14],w=t[15],n[12]=b*i+x*a+E*f+w*m,n[13]=b*r+x*c+E*d+w*g,n[14]=b*s+x*l+E*h+w*v,n[15]=b*o+x*u+E*p+w*y,n}function Ig(n,e,t){let i=t[0],r=t[1],s=t[2],o,a,c,l,u,f,d,h,p,m,g,v;return e===n?(n[12]=e[0]*i+e[4]*r+e[8]*s+e[12],n[13]=e[1]*i+e[5]*r+e[9]*s+e[13],n[14]=e[2]*i+e[6]*r+e[10]*s+e[14],n[15]=e[3]*i+e[7]*r+e[11]*s+e[15]):(o=e[0],a=e[1],c=e[2],l=e[3],u=e[4],f=e[5],d=e[6],h=e[7],p=e[8],m=e[9],g=e[10],v=e[11],n[0]=o,n[1]=a,n[2]=c,n[3]=l,n[4]=u,n[5]=f,n[6]=d,n[7]=h,n[8]=p,n[9]=m,n[10]=g,n[11]=v,n[12]=o*i+u*r+p*s+e[12],n[13]=a*i+f*r+m*s+e[13],n[14]=c*i+d*r+g*s+e[14],n[15]=l*i+h*r+v*s+e[15]),n}function Bg(n,e,t){let i=t[0],r=t[1],s=t[2];return n[0]=e[0]*i,n[1]=e[1]*i,n[2]=e[2]*i,n[3]=e[3]*i,n[4]=e[4]*r,n[5]=e[5]*r,n[6]=e[6]*r,n[7]=e[7]*r,n[8]=e[8]*s,n[9]=e[9]*s,n[10]=e[10]*s,n[11]=e[11]*s,n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function Og(n,e,t,i){let r=i[0],s=i[1],o=i[2],a=Math.sqrt(r*r+s*s+o*o),c,l,u,f,d,h,p,m,g,v,y,b,x,E,w,T,R,F,O,j,V,G,q,X;return a<1e-6?null:(a=1/a,r*=a,s*=a,o*=a,l=Math.sin(t),c=Math.cos(t),u=1-c,f=e[0],d=e[1],h=e[2],p=e[3],m=e[4],g=e[5],v=e[6],y=e[7],b=e[8],x=e[9],E=e[10],w=e[11],T=r*r*u+c,R=s*r*u+o*l,F=o*r*u-s*l,O=r*s*u-o*l,j=s*s*u+c,V=o*s*u+r*l,G=r*o*u+s*l,q=s*o*u-r*l,X=o*o*u+c,n[0]=f*T+m*R+b*F,n[1]=d*T+g*R+x*F,n[2]=h*T+v*R+E*F,n[3]=p*T+y*R+w*F,n[4]=f*O+m*j+b*V,n[5]=d*O+g*j+x*V,n[6]=h*O+v*j+E*V,n[7]=p*O+y*j+w*V,n[8]=f*G+m*q+b*X,n[9]=d*G+g*q+x*X,n[10]=h*G+v*q+E*X,n[11]=p*G+y*q+w*X,e!==n&&(n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n)}function Dg(n,e,t){let i=Math.sin(t),r=Math.cos(t),s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],f=e[10],d=e[11];return e!==n&&(n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[4]=s*r+l*i,n[5]=o*r+u*i,n[6]=a*r+f*i,n[7]=c*r+d*i,n[8]=l*r-s*i,n[9]=u*r-o*i,n[10]=f*r-a*i,n[11]=d*r-c*i,n}function Ng(n,e,t){let i=Math.sin(t),r=Math.cos(t),s=e[0],o=e[1],a=e[2],c=e[3],l=e[8],u=e[9],f=e[10],d=e[11];return e!==n&&(n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=s*r-l*i,n[1]=o*r-u*i,n[2]=a*r-f*i,n[3]=c*r-d*i,n[8]=s*i+l*r,n[9]=o*i+u*r,n[10]=a*i+f*r,n[11]=c*i+d*r,n}function Fg(n,e,t){let i=Math.sin(t),r=Math.cos(t),s=e[0],o=e[1],a=e[2],c=e[3],l=e[4],u=e[5],f=e[6],d=e[7];return e!==n&&(n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=s*r+l*i,n[1]=o*r+u*i,n[2]=a*r+f*i,n[3]=c*r+d*i,n[4]=l*r-s*i,n[5]=u*r-o*i,n[6]=f*r-a*i,n[7]=d*r-c*i,n}function sD(n,e){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=e[0],n[13]=e[1],n[14]=e[2],n[15]=1,n}function oD(n,e){return n[0]=e[0],n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=e[1],n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=e[2],n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function aD(n,e,t){let i=t[0],r=t[1],s=t[2],o=Math.sqrt(i*i+r*r+s*s),a,c,l;return o<1e-6?null:(o=1/o,i*=o,r*=o,s*=o,c=Math.sin(e),a=Math.cos(e),l=1-a,n[0]=i*i*l+a,n[1]=r*i*l+s*c,n[2]=s*i*l-r*c,n[3]=0,n[4]=i*r*l-s*c,n[5]=r*r*l+a,n[6]=s*r*l+i*c,n[7]=0,n[8]=i*s*l+r*c,n[9]=r*s*l-i*c,n[10]=s*s*l+a,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n)}function cD(n,e){let t=Math.sin(e),i=Math.cos(e);return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i,n[6]=t,n[7]=0,n[8]=0,n[9]=-t,n[10]=i,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function lD(n,e){let t=Math.sin(e),i=Math.cos(e);return n[0]=i,n[1]=0,n[2]=-t,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=t,n[9]=0,n[10]=i,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function uD(n,e){let t=Math.sin(e),i=Math.cos(e);return n[0]=i,n[1]=t,n[2]=0,n[3]=0,n[4]=-t,n[5]=i,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function bE(n,e,t){let i=e[0],r=e[1],s=e[2],o=e[3],a=i+i,c=r+r,l=s+s,u=i*a,f=i*c,d=i*l,h=r*c,p=r*l,m=s*l,g=o*a,v=o*c,y=o*l;return n[0]=1-(h+m),n[1]=f+y,n[2]=d-v,n[3]=0,n[4]=f-y,n[5]=1-(u+m),n[6]=p+g,n[7]=0,n[8]=d+v,n[9]=p-g,n[10]=1-(u+h),n[11]=0,n[12]=t[0],n[13]=t[1],n[14]=t[2],n[15]=1,n}function fD(n,e){let t=new we(3),i=-e[0],r=-e[1],s=-e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=i*i+r*r+s*s+o*o;return f>0?(t[0]=(a*o+u*i+c*s-l*r)*2/f,t[1]=(c*o+u*r+l*i-a*s)*2/f,t[2]=(l*o+u*s+a*r-c*i)*2/f):(t[0]=(a*o+u*i+c*s-l*r)*2,t[1]=(c*o+u*r+l*i-a*s)*2,t[2]=(l*o+u*s+a*r-c*i)*2),bE(n,e,t),n}function dD(n,e){return n[0]=e[12],n[1]=e[13],n[2]=e[14],n}function vE(n,e){let t=e[0],i=e[1],r=e[2],s=e[4],o=e[5],a=e[6],c=e[8],l=e[9],u=e[10];return n[0]=Math.sqrt(t*t+i*i+r*r),n[1]=Math.sqrt(s*s+o*o+a*a),n[2]=Math.sqrt(c*c+l*l+u*u),n}function hD(n,e){let t=new we(3);vE(t,e);let i=1/t[0],r=1/t[1],s=1/t[2],o=e[0]*i,a=e[1]*r,c=e[2]*s,l=e[4]*i,u=e[5]*r,f=e[6]*s,d=e[8]*i,h=e[9]*r,p=e[10]*s,m=o+u+p,g=0;return m>0?(g=Math.sqrt(m+1)*2,n[3]=.25*g,n[0]=(f-h)/g,n[1]=(d-c)/g,n[2]=(a-l)/g):o>u&&o>p?(g=Math.sqrt(1+o-u-p)*2,n[3]=(f-h)/g,n[0]=.25*g,n[1]=(a+l)/g,n[2]=(d+c)/g):u>p?(g=Math.sqrt(1+u-o-p)*2,n[3]=(d-c)/g,n[0]=(a+l)/g,n[1]=.25*g,n[2]=(f+h)/g):(g=Math.sqrt(1+p-o-u)*2,n[3]=(a-l)/g,n[0]=(d+c)/g,n[1]=(f+h)/g,n[2]=.25*g),n}function pD(n,e,t,i){e[0]=i[12],e[1]=i[13],e[2]=i[14];let r=i[0],s=i[1],o=i[2],a=i[4],c=i[5],l=i[6],u=i[8],f=i[9],d=i[10];t[0]=Math.sqrt(r*r+s*s+o*o),t[1]=Math.sqrt(a*a+c*c+l*l),t[2]=Math.sqrt(u*u+f*f+d*d);let h=1/t[0],p=1/t[1],m=1/t[2],g=r*h,v=s*p,y=o*m,b=a*h,x=c*p,E=l*m,w=u*h,T=f*p,R=d*m,F=g+x+R,O=0;return F>0?(O=Math.sqrt(F+1)*2,n[3]=.25*O,n[0]=(E-T)/O,n[1]=(w-y)/O,n[2]=(v-b)/O):g>x&&g>R?(O=Math.sqrt(1+g-x-R)*2,n[3]=(E-T)/O,n[0]=.25*O,n[1]=(v+b)/O,n[2]=(w+y)/O):x>R?(O=Math.sqrt(1+x-g-R)*2,n[3]=(w-y)/O,n[0]=(v+b)/O,n[1]=.25*O,n[2]=(E+T)/O):(O=Math.sqrt(1+R-g-x)*2,n[3]=(v-b)/O,n[0]=(w+y)/O,n[1]=(E+T)/O,n[2]=.25*O),n}function mD(n,e,t,i){let r=e[0],s=e[1],o=e[2],a=e[3],c=r+r,l=s+s,u=o+o,f=r*c,d=r*l,h=r*u,p=s*l,m=s*u,g=o*u,v=a*c,y=a*l,b=a*u,x=i[0],E=i[1],w=i[2];return n[0]=(1-(p+g))*x,n[1]=(d+b)*x,n[2]=(h-y)*x,n[3]=0,n[4]=(d-b)*E,n[5]=(1-(f+g))*E,n[6]=(m+v)*E,n[7]=0,n[8]=(h+y)*w,n[9]=(m-v)*w,n[10]=(1-(f+p))*w,n[11]=0,n[12]=t[0],n[13]=t[1],n[14]=t[2],n[15]=1,n}function gD(n,e,t,i,r){let s=e[0],o=e[1],a=e[2],c=e[3],l=s+s,u=o+o,f=a+a,d=s*l,h=s*u,p=s*f,m=o*u,g=o*f,v=a*f,y=c*l,b=c*u,x=c*f,E=i[0],w=i[1],T=i[2],R=r[0],F=r[1],O=r[2],j=(1-(m+v))*E,V=(h+x)*E,G=(p-b)*E,q=(h-x)*w,X=(1-(d+v))*w,se=(g+y)*w,le=(p+b)*T,he=(g-y)*T,at=(1-(d+m))*T;return n[0]=j,n[1]=V,n[2]=G,n[3]=0,n[4]=q,n[5]=X,n[6]=se,n[7]=0,n[8]=le,n[9]=he,n[10]=at,n[11]=0,n[12]=t[0]+R-(j*R+q*F+le*O),n[13]=t[1]+F-(V*R+X*F+he*O),n[14]=t[2]+O-(G*R+se*F+at*O),n[15]=1,n}function zg(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],o=t+t,a=i+i,c=r+r,l=t*o,u=i*o,f=i*a,d=r*o,h=r*a,p=r*c,m=s*o,g=s*a,v=s*c;return n[0]=1-f-p,n[1]=u+v,n[2]=d-g,n[3]=0,n[4]=u-v,n[5]=1-l-p,n[6]=h+m,n[7]=0,n[8]=d+g,n[9]=h-m,n[10]=1-l-f,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Ug(n,e,t,i,r,s,o){let a=1/(t-e),c=1/(r-i),l=1/(s-o);return n[0]=s*2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=s*2*c,n[6]=0,n[7]=0,n[8]=(t+e)*a,n[9]=(r+i)*c,n[10]=(o+s)*l,n[11]=-1,n[12]=0,n[13]=0,n[14]=o*s*2*l,n[15]=0,n}function xE(n,e,t,i,r){let s=1/Math.tan(e/2);if(n[0]=s/t,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=s,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,r!=null&&r!==1/0){let o=1/(i-r);n[10]=(r+i)*o,n[14]=2*r*i*o}else n[10]=-1,n[14]=-2*i;return n}function _D(n,e,t,i,r){let s=1/Math.tan(e/2);if(n[0]=s/t,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=s,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,r!=null&&r!==1/0){let o=1/(i-r);n[10]=r*o,n[14]=r*i*o}else n[10]=-1,n[14]=-i;return n}function yD(n,e,t,i){let r=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),o=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),c=2/(o+a),l=2/(r+s);return n[0]=c,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=l,n[6]=0,n[7]=0,n[8]=-((o-a)*c*.5),n[9]=(r-s)*l*.5,n[10]=i/(t-i),n[11]=-1,n[12]=0,n[13]=0,n[14]=i*t/(t-i),n[15]=0,n}function wE(n,e,t,i,r,s,o){let a=1/(e-t),c=1/(i-r),l=1/(s-o);return n[0]=-2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*c,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*l,n[11]=0,n[12]=(e+t)*a,n[13]=(r+i)*c,n[14]=(o+s)*l,n[15]=1,n}function bD(n,e,t,i,r,s,o){let a=1/(e-t),c=1/(i-r),l=1/(s-o);return n[0]=-2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*c,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=l,n[11]=0,n[12]=(e+t)*a,n[13]=(r+i)*c,n[14]=s*l,n[15]=1,n}function Vg(n,e,t,i){let r,s,o,a,c,l,u,f,d,h,p=e[0],m=e[1],g=e[2],v=i[0],y=i[1],b=i[2],x=t[0],E=t[1],w=t[2];return Math.abs(p-x)<1e-6&&Math.abs(m-E)<1e-6&&Math.abs(g-w)<1e-6?yE(n):(f=p-x,d=m-E,h=g-w,r=1/Math.sqrt(f*f+d*d+h*h),f*=r,d*=r,h*=r,s=y*h-b*d,o=b*f-v*h,a=v*d-y*f,r=Math.sqrt(s*s+o*o+a*a),r?(r=1/r,s*=r,o*=r,a*=r):(s=0,o=0,a=0),c=d*a-h*o,l=h*s-f*a,u=f*o-d*s,r=Math.sqrt(c*c+l*l+u*u),r?(r=1/r,c*=r,l*=r,u*=r):(c=0,l=0,u=0),n[0]=s,n[1]=c,n[2]=f,n[3]=0,n[4]=o,n[5]=l,n[6]=d,n[7]=0,n[8]=a,n[9]=u,n[10]=h,n[11]=0,n[12]=-(s*p+o*m+a*g),n[13]=-(c*p+l*m+u*g),n[14]=-(f*p+d*m+h*g),n[15]=1,n)}function vD(n,e,t,i){let r=e[0],s=e[1],o=e[2],a=i[0],c=i[1],l=i[2],u=r-t[0],f=s-t[1],d=o-t[2],h=u*u+f*f+d*d;h>0&&(h=1/Math.sqrt(h),u*=h,f*=h,d*=h);let p=c*d-l*f,m=l*u-a*d,g=a*f-c*u;return h=p*p+m*m+g*g,h>0&&(h=1/Math.sqrt(h),p*=h,m*=h,g*=h),n[0]=p,n[1]=m,n[2]=g,n[3]=0,n[4]=f*g-d*m,n[5]=d*p-u*g,n[6]=u*m-f*p,n[7]=0,n[8]=u,n[9]=f,n[10]=d,n[11]=0,n[12]=r,n[13]=s,n[14]=o,n[15]=1,n}function xD(n){return`mat4(${n[0]}, ${n[1]}, ${n[2]}, ${n[3]}, ${n[4]}, ${n[5]}, ${n[6]}, ${n[7]}, ${n[8]}, ${n[9]}, ${n[10]}, ${n[11]}, ${n[12]}, ${n[13]}, ${n[14]}, ${n[15]})`}function wD(n){return Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]+n[3]*n[3]+n[4]*n[4]+n[5]*n[5]+n[6]*n[6]+n[7]*n[7]+n[8]*n[8]+n[9]*n[9]+n[10]*n[10]+n[11]*n[11]+n[12]*n[12]+n[13]*n[13]+n[14]*n[14]+n[15]*n[15])}function ED(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n[3]=e[3]+t[3],n[4]=e[4]+t[4],n[5]=e[5]+t[5],n[6]=e[6]+t[6],n[7]=e[7]+t[7],n[8]=e[8]+t[8],n[9]=e[9]+t[9],n[10]=e[10]+t[10],n[11]=e[11]+t[11],n[12]=e[12]+t[12],n[13]=e[13]+t[13],n[14]=e[14]+t[14],n[15]=e[15]+t[15],n}function EE(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n[3]=e[3]-t[3],n[4]=e[4]-t[4],n[5]=e[5]-t[5],n[6]=e[6]-t[6],n[7]=e[7]-t[7],n[8]=e[8]-t[8],n[9]=e[9]-t[9],n[10]=e[10]-t[10],n[11]=e[11]-t[11],n[12]=e[12]-t[12],n[13]=e[13]-t[13],n[14]=e[14]-t[14],n[15]=e[15]-t[15],n}function SD(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n[3]=e[3]*t,n[4]=e[4]*t,n[5]=e[5]*t,n[6]=e[6]*t,n[7]=e[7]*t,n[8]=e[8]*t,n[9]=e[9]*t,n[10]=e[10]*t,n[11]=e[11]*t,n[12]=e[12]*t,n[13]=e[13]*t,n[14]=e[14]*t,n[15]=e[15]*t,n}function PD(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n[2]=e[2]+t[2]*i,n[3]=e[3]+t[3]*i,n[4]=e[4]+t[4]*i,n[5]=e[5]+t[5]*i,n[6]=e[6]+t[6]*i,n[7]=e[7]+t[7]*i,n[8]=e[8]+t[8]*i,n[9]=e[9]+t[9]*i,n[10]=e[10]+t[10]*i,n[11]=e[11]+t[11]*i,n[12]=e[12]+t[12]*i,n[13]=e[13]+t[13]*i,n[14]=e[14]+t[14]*i,n[15]=e[15]+t[15]*i,n}function CD(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]&&n[3]===e[3]&&n[4]===e[4]&&n[5]===e[5]&&n[6]===e[6]&&n[7]===e[7]&&n[8]===e[8]&&n[9]===e[9]&&n[10]===e[10]&&n[11]===e[11]&&n[12]===e[12]&&n[13]===e[13]&&n[14]===e[14]&&n[15]===e[15]}function TD(n,e){let t=n[0],i=n[1],r=n[2],s=n[3],o=n[4],a=n[5],c=n[6],l=n[7],u=n[8],f=n[9],d=n[10],h=n[11],p=n[12],m=n[13],g=n[14],v=n[15],y=e[0],b=e[1],x=e[2],E=e[3],w=e[4],T=e[5],R=e[6],F=e[7],O=e[8],j=e[9],V=e[10],G=e[11],q=e[12],X=e[13],se=e[14],le=e[15];return Math.abs(t-y)<=1e-6*Math.max(1,Math.abs(t),Math.abs(y))&&Math.abs(i-b)<=1e-6*Math.max(1,Math.abs(i),Math.abs(b))&&Math.abs(r-x)<=1e-6*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(s-E)<=1e-6*Math.max(1,Math.abs(s),Math.abs(E))&&Math.abs(o-w)<=1e-6*Math.max(1,Math.abs(o),Math.abs(w))&&Math.abs(a-T)<=1e-6*Math.max(1,Math.abs(a),Math.abs(T))&&Math.abs(c-R)<=1e-6*Math.max(1,Math.abs(c),Math.abs(R))&&Math.abs(l-F)<=1e-6*Math.max(1,Math.abs(l),Math.abs(F))&&Math.abs(u-O)<=1e-6*Math.max(1,Math.abs(u),Math.abs(O))&&Math.abs(f-j)<=1e-6*Math.max(1,Math.abs(f),Math.abs(j))&&Math.abs(d-V)<=1e-6*Math.max(1,Math.abs(d),Math.abs(V))&&Math.abs(h-G)<=1e-6*Math.max(1,Math.abs(h),Math.abs(G))&&Math.abs(p-q)<=1e-6*Math.max(1,Math.abs(p),Math.abs(q))&&Math.abs(m-X)<=1e-6*Math.max(1,Math.abs(m),Math.abs(X))&&Math.abs(g-se)<=1e-6*Math.max(1,Math.abs(g),Math.abs(se))&&Math.abs(v-le)<=1e-6*Math.max(1,Math.abs(v),Math.abs(le))}var $g,Gg,LD,MD,Wg=C(()=>{$r();$g=xE;Gg=wE;LD=Ka,MD=EE});var Rt={};mi(Rt,{add:()=>ME,ceil:()=>AD,clone:()=>PE,copy:()=>TE,create:()=>SE,cross:()=>FD,dist:()=>YD,distance:()=>BE,div:()=>HD,divide:()=>RE,dot:()=>DE,equals:()=>VD,exactEquals:()=>FE,floor:()=>kD,forEach:()=>KD,fromValues:()=>CE,inverse:()=>ND,len:()=>ZD,length:()=>jg,lerp:()=>NE,max:()=>ID,min:()=>RD,mul:()=>jD,multiply:()=>kE,negate:()=>DD,normalize:()=>Yg,random:()=>zD,round:()=>BD,scale:()=>IE,scaleAndAdd:()=>OD,set:()=>LE,sqrDist:()=>qD,sqrLen:()=>XD,squaredDistance:()=>OE,squaredLength:()=>Hg,str:()=>GD,sub:()=>WD,subtract:()=>AE,transformMat4:()=>qg,transformQuat:()=>UD,zero:()=>$D});function SE(){let n=new we(4);return we!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0,n[3]=0),n}function PE(n){let e=new we(4);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e}function CE(n,e,t,i){let r=new we(4);return r[0]=n,r[1]=e,r[2]=t,r[3]=i,r}function TE(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n}function LE(n,e,t,i,r){return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n}function ME(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n[3]=e[3]+t[3],n}function AE(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n[3]=e[3]-t[3],n}function kE(n,e,t){return n[0]=e[0]*t[0],n[1]=e[1]*t[1],n[2]=e[2]*t[2],n[3]=e[3]*t[3],n}function RE(n,e,t){return n[0]=e[0]/t[0],n[1]=e[1]/t[1],n[2]=e[2]/t[2],n[3]=e[3]/t[3],n}function AD(n,e){return n[0]=Math.ceil(e[0]),n[1]=Math.ceil(e[1]),n[2]=Math.ceil(e[2]),n[3]=Math.ceil(e[3]),n}function kD(n,e){return n[0]=Math.floor(e[0]),n[1]=Math.floor(e[1]),n[2]=Math.floor(e[2]),n[3]=Math.floor(e[3]),n}function RD(n,e,t){return n[0]=Math.min(e[0],t[0]),n[1]=Math.min(e[1],t[1]),n[2]=Math.min(e[2],t[2]),n[3]=Math.min(e[3],t[3]),n}function ID(n,e,t){return n[0]=Math.max(e[0],t[0]),n[1]=Math.max(e[1],t[1]),n[2]=Math.max(e[2],t[2]),n[3]=Math.max(e[3],t[3]),n}function BD(n,e){return n[0]=Qt(e[0]),n[1]=Qt(e[1]),n[2]=Qt(e[2]),n[3]=Qt(e[3]),n}function IE(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n[3]=e[3]*t,n}function OD(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n[2]=e[2]+t[2]*i,n[3]=e[3]+t[3]*i,n}function BE(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2],s=e[3]-n[3];return Math.sqrt(t*t+i*i+r*r+s*s)}function OE(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2],s=e[3]-n[3];return t*t+i*i+r*r+s*s}function jg(n){let e=n[0],t=n[1],i=n[2],r=n[3];return Math.sqrt(e*e+t*t+i*i+r*r)}function Hg(n){let e=n[0],t=n[1],i=n[2],r=n[3];return e*e+t*t+i*i+r*r}function DD(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n[3]=-e[3],n}function ND(n,e){return n[0]=1/e[0],n[1]=1/e[1],n[2]=1/e[2],n[3]=1/e[3],n}function Yg(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],o=t*t+i*i+r*r+s*s;return o>0&&(o=1/Math.sqrt(o)),n[0]=t*o,n[1]=i*o,n[2]=r*o,n[3]=s*o,n}function DE(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]+n[3]*e[3]}function FD(n,e,t,i){let r=t[0]*i[1]-t[1]*i[0],s=t[0]*i[2]-t[2]*i[0],o=t[0]*i[3]-t[3]*i[0],a=t[1]*i[2]-t[2]*i[1],c=t[1]*i[3]-t[3]*i[1],l=t[2]*i[3]-t[3]*i[2],u=e[0],f=e[1],d=e[2],h=e[3];return n[0]=f*l-d*c+h*a,n[1]=-(u*l)+d*o-h*s,n[2]=u*c-f*o+h*r,n[3]=-(u*a)+f*s-d*r,n}function NE(n,e,t,i){let r=e[0],s=e[1],o=e[2],a=e[3];return n[0]=r+i*(t[0]-r),n[1]=s+i*(t[1]-s),n[2]=o+i*(t[2]-o),n[3]=a+i*(t[3]-a),n}function zD(n,e){e=e===void 0?1:e;let t,i,r,s,o,a;do t=Gn()*2-1,i=Gn()*2-1,o=t*t+i*i;while(o>=1);do r=Gn()*2-1,s=Gn()*2-1,a=r*r+s*s;while(a>=1);let c=Math.sqrt((1-o)/a);return n[0]=e*t,n[1]=e*i,n[2]=e*r*c,n[3]=e*s*c,n}function qg(n,e,t){let i=e[0],r=e[1],s=e[2],o=e[3];return n[0]=t[0]*i+t[4]*r+t[8]*s+t[12]*o,n[1]=t[1]*i+t[5]*r+t[9]*s+t[13]*o,n[2]=t[2]*i+t[6]*r+t[10]*s+t[14]*o,n[3]=t[3]*i+t[7]*r+t[11]*s+t[15]*o,n}function UD(n,e,t){let i=e[0],r=e[1],s=e[2],o=t[0],a=t[1],c=t[2],l=t[3],u=l*i+a*s-c*r,f=l*r+c*i-o*s,d=l*s+o*r-a*i,h=-o*i-a*r-c*s;return n[0]=u*l+h*-o+f*-c-d*-a,n[1]=f*l+h*-a+d*-o-u*-c,n[2]=d*l+h*-c+u*-a-f*-o,n[3]=e[3],n}function $D(n){return n[0]=0,n[1]=0,n[2]=0,n[3]=0,n}function GD(n){return`vec4(${n[0]}, ${n[1]}, ${n[2]}, ${n[3]})`}function FE(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]&&n[3]===e[3]}function VD(n,e){let t=n[0],i=n[1],r=n[2],s=n[3],o=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(t-o)<=1e-6*Math.max(1,Math.abs(t),Math.abs(o))&&Math.abs(i-a)<=1e-6*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(r-c)<=1e-6*Math.max(1,Math.abs(r),Math.abs(c))&&Math.abs(s-l)<=1e-6*Math.max(1,Math.abs(s),Math.abs(l))}var WD,jD,HD,YD,qD,ZD,XD,KD,sf=C(()=>{$r();WD=AE,jD=kE,HD=RE,YD=BE,qD=OE,ZD=jg,XD=Hg,KD=function(){let n=SE();return function(e,t,i,r,s,o){let a,c;for(t||(t=4),i||(i=0),r?c=Math.min(r*t+i,e.length):c=e.length,a=i;aMath.PI*2)throw Error("expected radians")}function i4(n,e,t,i,r,s){let o=2*s/(t-e),a=2*s/(r-i),c=(t+e)/(t-e),l=(r+i)/(r-i),u=-1,f=-1,d=-2*s;return n[0]=o,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=a,n[6]=0,n[7]=0,n[8]=c,n[9]=l,n[10]=u,n[11]=f,n[12]=0,n[13]=0,n[14]=d,n[15]=0,n}var Kg,QD,JD,Zg,Xg,e4,Fe,of,af,UE=C(()=>{mE();Ya();bg();Wg();yg();Xa();sf();(function(n){n[n.COL0ROW0=0]="COL0ROW0",n[n.COL0ROW1=1]="COL0ROW1",n[n.COL0ROW2=2]="COL0ROW2",n[n.COL0ROW3=3]="COL0ROW3",n[n.COL1ROW0=4]="COL1ROW0",n[n.COL1ROW1=5]="COL1ROW1",n[n.COL1ROW2=6]="COL1ROW2",n[n.COL1ROW3=7]="COL1ROW3",n[n.COL2ROW0=8]="COL2ROW0",n[n.COL2ROW1=9]="COL2ROW1",n[n.COL2ROW2=10]="COL2ROW2",n[n.COL2ROW3=11]="COL2ROW3",n[n.COL3ROW0=12]="COL3ROW0",n[n.COL3ROW1=13]="COL3ROW1",n[n.COL3ROW2=14]="COL3ROW2",n[n.COL3ROW3=15]="COL3ROW3"})(Kg||(Kg={}));QD=45*Math.PI/180,JD=1,Zg=.1,Xg=500,e4=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),Fe=class extends rf{static get IDENTITY(){return n4()}static get ZERO(){return t4()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Kg}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,i,r,s,o,a,c,l,u,f,d,h,p,m,g){return this[0]=e,this[1]=t,this[2]=i,this[3]=r,this[4]=s,this[5]=o,this[6]=a,this[7]=c,this[8]=l,this[9]=u,this[10]=f,this[11]=d,this[12]=h,this[13]=p,this[14]=m,this[15]=g,this.check()}setRowMajor(e,t,i,r,s,o,a,c,l,u,f,d,h,p,m,g){return this[0]=e,this[1]=s,this[2]=l,this[3]=h,this[4]=t,this[5]=o,this[6]=u,this[7]=p,this[8]=i,this[9]=a,this[10]=f,this[11]=m,this[12]=r,this[13]=c,this[14]=d,this[15]=g,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(e4)}fromObject(e){return this.check()}fromQuaternion(e){return zg(this,e),this.check()}frustum(e){let{left:t,right:i,bottom:r,top:s,near:o=Zg,far:a=Xg}=e;return a===1/0?i4(this,t,i,r,s,o):Ug(this,t,i,r,s,o,a),this.check()}lookAt(e){let{eye:t,center:i=[0,0,0],up:r=[0,1,0]}=e;return Vg(this,t,i,r),this.check()}ortho(e){let{left:t,right:i,bottom:r,top:s,near:o=Zg,far:a=Xg}=e;return Gg(this,t,i,r,s,o,a),this.check()}orthographic(e){let{fovy:t=QD,aspect:i=JD,focalDistance:r=1,near:s=Zg,far:o=Xg}=e;zE(t);let a=t/2,c=r*Math.tan(a),l=c*i;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:s,far:o})}perspective(e){let{fovy:t=45*Math.PI/180,aspect:i=1,near:r=.1,far:s=500}=e;return zE(t),$g(this,t,i,r,s),this.check()}determinant(){return Rg(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let i=this.getScale(t),r=1/i[0],s=1/i[1],o=1/i[2];return e[0]=this[0]*r,e[1]=this[1]*s,e[2]=this[2]*o,e[3]=0,e[4]=this[4]*r,e[5]=this[5]*s,e[6]=this[6]*o,e[7]=0,e[8]=this[8]*r,e[9]=this[9]*s,e[10]=this[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let i=this.getScale(t),r=1/i[0],s=1/i[1],o=1/i[2];return e[0]=this[0]*r,e[1]=this[1]*s,e[2]=this[2]*o,e[3]=this[4]*r,e[4]=this[5]*s,e[5]=this[6]*o,e[6]=this[8]*r,e[7]=this[9]*s,e[8]=this[10]*o,e}transpose(){return Ag(this,this),this.check()}invert(){return kg(this,this),this.check()}multiplyLeft(e){return Ka(this,e,this),this.check()}multiplyRight(e){return Ka(this,this,e),this.check()}rotateX(e){return Dg(this,this,e),this.check()}rotateY(e){return Ng(this,this,e),this.check()}rotateZ(e){return Fg(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return Og(this,this,e,t),this.check()}scale(e){return Bg(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return Ig(this,this,e),this.check()}transform(e,t){return e.length===4?(t=qg(t||[-0,-0,-0,-0],e,this),Ku(t,4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){let{length:i}=e,r;switch(i){case 2:r=_g(t||[-0,-0],e,this);break;case 3:r=Za(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Ku(r,e.length),r}transformAsVector(e,t){let i;switch(e.length){case 2:i=sE(t||[-0,-0],e,this);break;case 3:i=Ju(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Ku(i,e.length),i}transformPoint(e,t){return this.transformAsPoint(e,t)}transformVector(e,t){return this.transformAsPoint(e,t)}transformDirection(e,t){return this.transformAsVector(e,t)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,i){return this.identity().translate([e,t,i])}}});function $E(){let n=new we(4);return we!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n[3]=1,n}function r4(n,e,t){t=t*.5;let i=Math.sin(t);return n[0]=i*e[0],n[1]=i*e[1],n[2]=i*e[2],n[3]=Math.cos(t),n}function Qg(n,e,t,i){let r=e[0],s=e[1],o=e[2],a=e[3],c=t[0],l=t[1],u=t[2],f=t[3],d,h,p,m,g;return d=r*c+s*l+o*u+a*f,d<0&&(d=-d,c=-c,l=-l,u=-u,f=-f),1-d>1e-6?(h=Math.acos(d),g=Math.sin(h),p=Math.sin((1-i)*h)/g,m=Math.sin(i*h)/g):(p=1-i,m=i),n[0]=p*r+m*c,n[1]=p*s+m*l,n[2]=p*o+m*u,n[3]=p*a+m*f,n}function s4(n,e){let t=e[0]+e[4]+e[8],i;if(t>0)i=Math.sqrt(t+1),n[3]=.5*i,i=.5/i,n[0]=(e[5]-e[7])*i,n[1]=(e[6]-e[2])*i,n[2]=(e[1]-e[3])*i;else{let r=0;e[4]>e[0]&&(r=1),e[8]>e[r*3+r]&&(r=2);let s=(r+1)%3,o=(r+2)%3;i=Math.sqrt(e[r*3+r]-e[s*3+s]-e[o*3+o]+1),n[r]=.5*i,i=.5/i,n[3]=(e[s*3+o]-e[o*3+s])*i,n[s]=(e[s*3+r]+e[r*3+s])*i,n[o]=(e[o*3+r]+e[r*3+o])*i}return n}var GE,MK,AK,kK,VE=C(()=>{$r();Mg();Xa();sf();GE=Yg,MK=function(){let n=ef(),e=tf(1,0,0),t=tf(0,1,0);return function(i,r,s){let o=qa(r,s);return o<-.999999?(Gr(n,e,r),Tg(n)<1e-6&&Gr(n,t,r),vg(n,n),r4(i,n,Math.PI),i):o>.999999?(i[0]=0,i[1]=0,i[2]=0,i[3]=1,i):(Gr(n,r,s),i[0]=n[0],i[1]=n[1],i[2]=n[2],i[3]=1+o,GE(i,i))}}(),AK=function(){let n=$E(),e=$E();return function(t,i,r,s,o,a){return Qg(n,i,o,a),Qg(e,r,s,a),Qg(t,n,e,2*a*(1-a)),t}}(),kK=function(){let n=gE();return function(e,t,i,r){return n[0]=i[0],n[3]=i[1],n[6]=i[2],n[1]=r[0],n[4]=r[1],n[7]=r[2],n[2]=-t[0],n[5]=-t[1],n[8]=-t[2],GE(e,s4(e,n))}}()});var RK,IK,BK,OK,WE=C(()=>{RK=Math.PI/2,IK=Math.PI/4,BK=Math.PI/6,OK=Math.PI*2});var ze=C(()=>{pE();UE();WE();Ks();Mg();Wg();VE();yg();Xa();sf()});function Jg(n,e=[],t=0){let i=Math.fround(n),r=n-i;return e[t]=i,e[t+1]=r,e}function jE(n){return n-Math.fround(n)}function HE(n){let e=new Float32Array(32);for(let t=0;t<4;++t)for(let i=0;i<4;++i){let r=t*4+i;Jg(n[i*4+t],e,r*2)}return e}var YE=C(()=>{});function cf(n,e=!0){return n??e}function e_(n=[0,0,0],e=!0){return e?n.map(t=>t/255):[...n]}function qE(n,e=!0){let t=e_(n.slice(0,3),e),i=Number.isFinite(n[3]),r=i?n[3]:1;return[t[0],t[1],t[2],e&&i?r/255:r]}var t_=C(()=>{});var c4,l4,Vr,ZE=C(()=>{c4=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND // All these functions are for substituting tan() function from Intel GPU only const float TWO_PI = 6.2831854820251465; @@ -277,7 +277,7 @@ float tan_fp32(float a) { return tan(a); #endif } -`,o4=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND +`,l4=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND const FP32_TWO_PI: f32 = 6.2831854820251465; const FP32_PI_2: f32 = 1.5707963705062866; const FP32_PI_16: f32 = 0.1963495463132858; @@ -398,7 +398,7 @@ fn tan_fp32(a: f32) -> f32 { return tan(a); } #endif -`,Vr={name:"fp32",source:o4,vs:s4}});var t_,ZE=C(()=>{t_=` +`,Vr={name:"fp32",source:l4,vs:c4}});var n_,XE=C(()=>{n_=` layout(std140) uniform fp64arithmeticUniforms { uniform float ONE; uniform float SPLIT; @@ -597,7 +597,7 @@ vec2 sqrt_fp64(vec2 a) { return sum_fp64(vec2(yn, 0.0), prod); #endif } -`});var XE,KE=C(()=>{XE=`struct Fp64F32Bits { +`});var KE,QE=C(()=>{KE=`struct Fp64F32Bits { sign: u32, baseExponent: i32, significand: u32, @@ -1047,7 +1047,7 @@ fn sqrt_fp64(a: vec2f) -> vec2f { return fp64_scale_fp64_integer(normalizedRoot, evenExponent / 2); } #endif -`});var QE,JE=C(()=>{KE();QE=`struct Fp64ArithmeticUniforms { +`});var JE,eS=C(()=>{QE();JE=`struct Fp64ArithmeticUniforms { ONE: f32, SPLIT: f32, }; @@ -1670,7 +1670,7 @@ fn prevent_fp64_optimization(value: f32) -> f32 { #endif #ifdef LUMA_FP64_INTEGER_ARITHMETIC -${XE} +${KE} #else fn split(a: f32) -> vec2f { let splitValue = prevent_fp64_optimization(fp64arithmetic.SPLIT + fp64_runtime_zero()); @@ -1946,7 +1946,7 @@ fn compare_fp64(a: vec2f, b: vec2f) -> i32 { return fp64_compare_f32_bits(aLowBits, bLowBits); } #endif -`});var a4,n_,eS=C(()=>{HE();ZE();JE();a4={ONE:1,SPLIT:4097},n_={name:"fp64arithmetic",source:QE,fs:t_,vs:t_,defaultUniforms:a4,uniformTypes:{ONE:"f32",SPLIT:"f32"},fp64ify:Qg,fp64LowPart:WE,fp64ifyMatrix4:jE}});function nS(n){return`layout(std140) uniform ${n}Uniforms { +`});var u4,i_,tS=C(()=>{YE();XE();eS();u4={ONE:1,SPLIT:4097},i_={name:"fp64arithmetic",source:JE,fs:n_,vs:n_,defaultUniforms:u4,uniformTypes:{ONE:"f32",SPLIT:"f32"},fp64ify:Jg,fp64LowPart:jE,fp64ifyMatrix4:HE}});function iS(n){return`layout(std140) uniform ${n}Uniforms { float useByteColors; } ${n}; @@ -1973,7 +1973,7 @@ vec4 ${n}_premultiply_alpha(vec4 inputColor) { vec4 ${n}_unpremultiply_alpha(vec4 inputColor) { return ${n}_unpremultiplyAlpha(inputColor); } -`}function iS(n){return`struct ${n}Uniforms { +`}function rS(n){return`struct ${n}Uniforms { useByteColors: f32 }; @@ -2006,7 +2006,7 @@ fn ${n}_premultiply_alpha(inputColor: vec4) -> vec4 { fn ${n}_unpremultiply_alpha(inputColor: vec4) -> vec4 { return ${n}_unpremultiplyAlpha(inputColor); } -`}var gi,c4,l4,oQ,aQ,u4,f4,cQ,lQ,tS,uQ,d4,fQ,rS,sS=C(()=>{gi={RGBA8UNORM:0,RGBA16FLOAT:1,RGBA32FLOAT:2},c4={rgba8unorm:4,rgba16float:8,rgba32float:16},l4={...c4},oQ={rgba8unorm:gi.RGBA8UNORM,rgba16float:gi.RGBA16FLOAT,rgba32float:gi.RGBA32FLOAT},aQ={[gi.RGBA8UNORM]:"rgba8unorm",[gi.RGBA16FLOAT]:"rgba16float",[gi.RGBA32FLOAT]:"rgba32float"},u4={useByteColors:"f32"},f4={useByteColors:!0},cQ={format:gi.RGBA8UNORM,wordStride:l4.rgba8unorm/Uint32Array.BYTES_PER_ELEMENT,wordOffset:0,_padding:0},lQ=nS("colors"),tS=nS("floatColors"),uQ=iS("colors"),d4=iS("floatColors"),fQ=`struct storageColorsUniforms { +`}var xi,f4,d4,fQ,dQ,h4,p4,hQ,pQ,nS,mQ,m4,gQ,sS,oS=C(()=>{xi={RGBA8UNORM:0,RGBA16FLOAT:1,RGBA32FLOAT:2},f4={rgba8unorm:4,rgba16float:8,rgba32float:16},d4={...f4},fQ={rgba8unorm:xi.RGBA8UNORM,rgba16float:xi.RGBA16FLOAT,rgba32float:xi.RGBA32FLOAT},dQ={[xi.RGBA8UNORM]:"rgba8unorm",[xi.RGBA16FLOAT]:"rgba16float",[xi.RGBA32FLOAT]:"rgba32float"},h4={useByteColors:"f32"},p4={useByteColors:!0},hQ={format:xi.RGBA8UNORM,wordStride:d4.rgba8unorm/Uint32Array.BYTES_PER_ELEMENT,wordOffset:0,_padding:0},pQ=iS("colors"),nS=iS("floatColors"),mQ=rS("colors"),m4=rS("floatColors"),gQ=`struct storageColorsUniforms { format: u32, wordStride: u32, wordOffset: u32, @@ -2016,8 +2016,8 @@ fn ${n}_unpremultiply_alpha(inputColor: vec4) -> vec4 { @group(0) @binding(auto) var storageColors : storageColorsUniforms; @group(0) @binding(auto) var storageColorsBuffer : array; -const STORAGE_COLOR_FORMAT_RGBA8UNORM : u32 = ${gi.RGBA8UNORM}u; -const STORAGE_COLOR_FORMAT_RGBA16FLOAT : u32 = ${gi.RGBA16FLOAT}u; +const STORAGE_COLOR_FORMAT_RGBA8UNORM : u32 = ${xi.RGBA8UNORM}u; +const STORAGE_COLOR_FORMAT_RGBA16FLOAT : u32 = ${xi.RGBA16FLOAT}u; fn storageColors_getWordIndex(rowIndex: u32) -> u32 { return storageColors.wordOffset + rowIndex * storageColors.wordStride; @@ -2052,7 +2052,7 @@ fn storageColors_readColor(rowIndex: u32) -> vec4 { } return storageColors_readRgba32FloatColor(wordIndex); } -`;rS={name:"floatColors",props:{},uniforms:{},vs:tS,fs:tS,source:d4,uniformTypes:u4,defaultUniforms:f4}});function g4(n={},e){let t={},i=af(n.useByteColors,!0);if(n.highlightedObjectColor!==void 0)if(n.highlightedObjectColor===null)t.isHighlightActive=!1;else{t.isHighlightActive=!0;let r=n.highlightedObjectColor.slice(0,3);t.highlightedObjectColor=r}return n.highlightColor&&(t.highlightColor=YE(n.highlightColor,i)),n.isActive!==void 0&&(t.isActive=!!n.isActive,t.isAttribute=!!n.isAttribute),n.useByteColors!==void 0&&(t.useByteColors=!!n.useByteColors),t}var h4,p4,m4,Yi,oS=C(()=>{e_();h4=[0,1,1,1],p4=`layout(std140) uniform pickingUniforms { +`;sS={name:"floatColors",props:{},uniforms:{},vs:nS,fs:nS,source:m4,uniformTypes:h4,defaultUniforms:p4}});function b4(n={},e){let t={},i=cf(n.useByteColors,!0);if(n.highlightedObjectColor!==void 0)if(n.highlightedObjectColor===null)t.isHighlightActive=!1;else{t.isHighlightActive=!0;let r=n.highlightedObjectColor.slice(0,3);t.highlightedObjectColor=r}return n.highlightColor&&(t.highlightColor=qE(n.highlightColor,i)),n.isActive!==void 0&&(t.isActive=!!n.isActive,t.isAttribute=!!n.isAttribute),n.useByteColors!==void 0&&(t.useByteColors=!!n.useByteColors),t}var g4,_4,y4,Zi,aS=C(()=>{t_();g4=[0,1,1,1],_4=`layout(std140) uniform pickingUniforms { float isActive; float isAttribute; float isHighlightActive; @@ -2123,7 +2123,7 @@ void picking_setPickingAttribute(vec3 value) { picking_vRGBcolor_Avalid.rgb = value; } } -`,m4=`layout(std140) uniform pickingUniforms { +`,y4=`layout(std140) uniform pickingUniforms { float isActive; float isAttribute; float isHighlightActive; @@ -2179,7 +2179,7 @@ vec4 picking_filterColor(vec4 color) { vec4 highlightColor = picking_filterHighlightColor(color); return picking_filterPickingColor(highlightColor); } -`,Yi={props:{},uniforms:{},name:"picking",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useByteColors:"f32",highlightedObjectColor:"vec3",highlightColor:"vec4"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useByteColors:!0,highlightedObjectColor:[0,0,0],highlightColor:h4},vs:p4,fs:m4,getUniforms:g4}});var i_,aS=C(()=>{i_=`precision highp int; +`,Zi={props:{},uniforms:{},name:"picking",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useByteColors:"f32",highlightedObjectColor:"vec3",highlightColor:"vec4"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useByteColors:!0,highlightedObjectColor:[0,0,0],highlightColor:g4},vs:_4,fs:y4,getUniforms:b4}});var r_,cS=C(()=>{r_=`precision highp int; // #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) struct AmbientLight { @@ -2259,7 +2259,7 @@ float getSpotLightAttenuation(SpotLight spotLight, vec3 positionWorldspace) { } // #endif -`});var cS,lS=C(()=>{cS=`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) +`});var lS,uS=C(()=>{lS=`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) const MAX_LIGHTS: i32 = 5; struct AmbientLight { @@ -2338,14 +2338,14 @@ fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3) ); return distanceAttenuation / max(coneFactor, 0.0001); } -`});function y4(n,e={}){if(n=n&&{...n},!n)return lf();n.lights&&(n={...n,...v4(n.lights),lights:void 0});let{useByteColors:t,ambientLight:i,pointLights:r,spotLights:s,directionalLights:o}=n||{};if(!(i||r&&r.length>0||s&&s.length>0||o&&o.length>0))return{...lf(),enabled:0};let c={...lf(),...b4({useByteColors:t,ambientLight:i,pointLights:r,spotLights:s,directionalLights:o})};return n.enabled!==void 0&&(c.enabled=n.enabled?1:0),c}function b4({useByteColors:n,ambientLight:e,pointLights:t=[],spotLights:i=[],directionalLights:r=[]}){let s=fS(),o=0,a=0,c=0,l=0;for(let u of t){if(o>=Wr)break;s[o]={...s[o],color:cf(u,n),position:u.position,attenuation:u.attenuation||[1,0,0]},o++,a++}for(let u of i){if(o>=Wr)break;s[o]={...s[o],color:cf(u,n),position:u.position,direction:u.direction,attenuation:u.attenuation||[1,0,0],coneCos:w4(u)},o++,c++}for(let u of r){if(o>=Wr)break;s[o]={...s[o],color:cf(u,n),direction:u.direction},o++,l++}return t.length+i.length+r.length>Wr&&z.warn(`MAX_LIGHTS exceeded, truncating to ${Wr}`)(),{ambientColor:cf(e,n),directionalLightCount:l,pointLightCount:a,spotLightCount:c,lights:s}}function v4(n){let e={pointLights:[],spotLights:[],directionalLights:[]};for(let t of n||[])switch(t.type){case"ambient":e.ambientLight=t;break;case"directional":e.directionalLights?.push(t);break;case"point":e.pointLights?.push(t);break;case"spot":e.spotLights?.push(t);break;default:}return e}function cf(n={},e){let{color:t=[0,0,0],intensity:i=1}=n;return Jg(t,af(e,!0)).map(s=>s*i)}function lf(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:fS()}}function fS(){return Array.from({length:Wr},()=>x4())}function x4(){return{color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}}function w4(n){let e=n.innerConeAngle??0,t=n.outerConeAngle??Math.PI/4;return[Math.cos(e),Math.cos(t)]}var Wr,_4,uS,dS=C(()=>{ee();aS();lS();e_();Wr=5,_4={color:"vec3",position:"vec3",direction:"vec3",attenuation:"vec3",coneCos:"vec2"},uS={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",directionalLightCount:"i32",pointLightCount:"i32",spotLightCount:"i32",ambientColor:"vec3",lights:[_4,Wr]},defaultUniforms:lf(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:cS,vs:i_,fs:i_,getUniforms:y4}});var hS,pS,mS=C(()=>{hS=`layout(std140) uniform phongMaterialUniforms { +`});function x4(n,e={}){if(n=n&&{...n},!n)return uf();n.lights&&(n={...n,...E4(n.lights),lights:void 0});let{useByteColors:t,ambientLight:i,pointLights:r,spotLights:s,directionalLights:o}=n||{};if(!(i||r&&r.length>0||s&&s.length>0||o&&o.length>0))return{...uf(),enabled:0};let c={...uf(),...w4({useByteColors:t,ambientLight:i,pointLights:r,spotLights:s,directionalLights:o})};return n.enabled!==void 0&&(c.enabled=n.enabled?1:0),c}function w4({useByteColors:n,ambientLight:e,pointLights:t=[],spotLights:i=[],directionalLights:r=[]}){let s=dS(),o=0,a=0,c=0,l=0;for(let u of t){if(o>=Wr)break;s[o]={...s[o],color:lf(u,n),position:u.position,attenuation:u.attenuation||[1,0,0]},o++,a++}for(let u of i){if(o>=Wr)break;s[o]={...s[o],color:lf(u,n),position:u.position,direction:u.direction,attenuation:u.attenuation||[1,0,0],coneCos:P4(u)},o++,c++}for(let u of r){if(o>=Wr)break;s[o]={...s[o],color:lf(u,n),direction:u.direction},o++,l++}return t.length+i.length+r.length>Wr&&N.warn(`MAX_LIGHTS exceeded, truncating to ${Wr}`)(),{ambientColor:lf(e,n),directionalLightCount:l,pointLightCount:a,spotLightCount:c,lights:s}}function E4(n){let e={pointLights:[],spotLights:[],directionalLights:[]};for(let t of n||[])switch(t.type){case"ambient":e.ambientLight=t;break;case"directional":e.directionalLights?.push(t);break;case"point":e.pointLights?.push(t);break;case"spot":e.spotLights?.push(t);break;default:}return e}function lf(n={},e){let{color:t=[0,0,0],intensity:i=1}=n;return e_(t,cf(e,!0)).map(s=>s*i)}function uf(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:dS()}}function dS(){return Array.from({length:Wr},()=>S4())}function S4(){return{color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}}function P4(n){let e=n.innerConeAngle??0,t=n.outerConeAngle??Math.PI/4;return[Math.cos(e),Math.cos(t)]}var Wr,v4,fS,hS=C(()=>{J();cS();uS();t_();Wr=5,v4={color:"vec3",position:"vec3",direction:"vec3",attenuation:"vec3",coneCos:"vec2"},fS={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",directionalLightCount:"i32",pointLightCount:"i32",spotLightCount:"i32",ambientColor:"vec3",lights:[v4,Wr]},defaultUniforms:uf(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:lS,vs:r_,fs:r_,getUniforms:x4}});var pS,mS,gS=C(()=>{pS=`layout(std140) uniform phongMaterialUniforms { uniform bool unlit; uniform float ambient; uniform float diffuse; uniform float shininess; uniform vec3 specularColor; } material; -`,pS=`layout(std140) uniform phongMaterialUniforms { +`,mS=`layout(std140) uniform phongMaterialUniforms { uniform bool unlit; uniform float ambient; uniform float diffuse; @@ -2402,7 +2402,7 @@ vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 positio return lightColor; } -`});var gS,_S=C(()=>{gS=`struct phongMaterialUniforms { +`});var _S,yS=C(()=>{_S=`struct phongMaterialUniforms { unlit: u32, ambient: f32, diffuse: f32, @@ -2525,11 +2525,11 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3, position_worldspace } return lightColor; } -`});var E4,eo,yS=C(()=>{sS();dS();mS();_S();E4=[38.25,38.25,38.25],eo={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:pS.replace("phongMaterial","gouraudMaterial"),fs:hS.replace("phongMaterial","gouraudMaterial"),source:gS.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[uS,rS],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:E4},getUniforms(n){return{...eo.defaultUniforms,...n}}}});var bt=C(()=>{gm();fw();tg();jw();Yw();qE();eS();oS();yS()});function jn(n="id"){C_[n]=C_[n]||1;let e=C_[n]++;return`${n}-${e}`}var C_,_o=C(()=>{C_={}});function Kr(n){switch(n){case"POSITION":return"positions";case"NORMAL":return"normals";case"TEXCOORD_0":return"texCoords";case"TEXCOORD_1":return"texCoords1";case"COLOR_0":return"colors";default:return n}}function bF(n){let e=[];for(let[t,i]of Object.entries(n)){if(!i)continue;let{value:r,size:s,normalized:o}=i;if(s===void 0)throw new Error(`Attribute ${t} is missing a size`);e.push({name:Kr(t),format:Ee.getVertexFormatFromAttribute(r,s,o)})}return e}var Kt,kf=C(()=>{ee();_o();Kt=class{id;topology;vertexCount;indices;attributes;bufferLayout;userData={};constructor(e){let{attributes:t={},indices:i=null,vertexCount:r=null}=e;this.id=e.id||jn("geometry"),this.topology=e.topology,i&&(this.indices=ArrayBuffer.isView(i)?{value:i,size:1}:i),this.attributes={};for(let[s,o]of Object.entries(t)){let a=ArrayBuffer.isView(o)?{value:o}:o;if(!ArrayBuffer.isView(a.value))throw new Error(`${this._print(s)}: must be typed array or object with value as typed array`);if((s==="POSITION"||s==="positions")&&!a.size&&(a.size=3),s==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=a}else{let c=Kr(s),l=Object.keys(this.attributes).find(u=>Kr(u)===c);l&&delete this.attributes[l],this.attributes[s]=a}}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=r||this._calculateVertexCount(this.attributes,this.indices),this.bufferLayout=e.bufferLayout||bF(this.attributes)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,t){return this}_calculateVertexCount(e,t){if(t)return t.value.length;let i=1/0;for(let r of Object.values(e)){if(!r)continue;let{value:s,size:o,constant:a}=r;!a&&s&&o!==void 0&&o>=1&&(i=Math.min(i,s.length/o))}return i}}});function h1(n,e={}){let t=e.bufferName||"geometry";if(vF(n,t))return n;let i=e.minAttributeAlignment||4,r=xF(n,e.attributes),s=[],o=0,a=1/0;for(let[u,f]of r){if(!f)continue;if(f.constant)throw new Error(`Attribute ${u} is constant`);let{value:d,size:h,normalized:p}=f;if(!ArrayBuffer.isView(d))throw new Error(`Attribute ${u} is missing typed array data`);if(h===void 0)throw new Error(`Attribute ${u} is missing a size`);let m=Ee.getVertexFormatFromAttribute(d,h,p),g=Ee.getVertexFormatInfo(m);o=d1(o,i),s.push({sourceName:u,attributeName:Kr(u),value:d,size:h,format:m,byteOffset:o,byteLength:g.byteLength}),o+=g.byteLength;let v=d.length/h;if(!Number.isInteger(v))throw new Error(`Attribute ${u} length is not divisible by size`);a=Math.min(a,v)}if(s.length===0||!Number.isFinite(a))throw new Error(`Geometry ${n.id} has no interleavable attributes`);let c=d1(o,i),l=new ArrayBuffer(a*c);for(let u of s)wF(l,a,c,u);return new Kt({id:n.id,topology:n.topology||"triangle-list",vertexCount:n.vertexCount,indices:n.indices,attributes:{[t]:{value:new Uint8Array(l),size:c,byteStride:c}},bufferLayout:[{name:t,stepMode:"vertex",byteStride:c,attributes:s.map(u=>({attribute:u.attributeName,format:u.format,byteOffset:u.byteOffset}))}]})}function vF(n,e){if(n.bufferLayout.length!==1)return!1;let t=n.bufferLayout[0];return t.name===e&&!!t.attributes?.length&&!!n.attributes[e]}function xF(n,e){return e?e.map(t=>[t,n.attributes[t]]):Object.entries(n.attributes)}function wF(n,e,t,i){let r=i.value.constructor,s=r.BYTES_PER_ELEMENT;if(i.byteOffset%s!==0||t%s!==0)throw new Error(`Attribute ${i.sourceName} is not aligned to its component type`);let o=new r(n),a=i.value,c=i.byteOffset/s,l=t/s;for(let u=0;u{ee();kf()});var EF,SF,Qr,m1=C(()=>{EF=1,SF=1,Qr=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){let{delay:t=0,duration:i=Number.POSITIVE_INFINITY,rate:r=1,repeat:s=1}=e,o=EF++,a={time:0,delay:t,duration:i,rate:r,repeat:s};return this._setChannelTime(a,this.time),this.channels.set(o,a),o}removeChannel(e){this.channels.delete(e);for(let[t,i]of this.animations)i.channel===e&&this.detachAnimation(t)}isFinished(e){let t=this.channels.get(e);return t===void 0?!1:this.time>=t.delay+t.duration*t.repeat}getTime(e){if(e===void 0)return this.time;let t=this.channels.get(e);return t===void 0?-1:t.time}setTime(e){this.time=Math.max(0,e);let t=this.channels.values();for(let r of t)this._setChannelTime(r,this.time);let i=this.animations.values();for(let r of i){let{animation:s,channel:o}=r;s.setTime(this.getTime(o))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,t){let i=SF++;return this.animations.set(i,{animation:e,channel:t}),e.setTime(this.getTime(t)),i}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,t){let i=t-e.delay,r=e.duration*e.repeat;i>=r?e.time=e.duration*e.rate:(e.time=Math.max(0,i)%e.duration,e.time*=e.rate)}}});function g1(n){let e=typeof window<"u"?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame:null;return e?e.call(window,n):setTimeout(()=>n(typeof performance<"u"?performance.now():Date.now()),1e3/60)}function _1(n){let e=typeof window<"u"?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame:null;if(e){e.call(window,n);return}clearTimeout(n)}var y1=C(()=>{});var PF,CF,b1,mc,v1=C(()=>{ee();y1();la();PF=0,CF="Animation Loop",b1={requestAnimationFrame:n=>g1(n),cancelAnimationFrame:n=>_1(n)},mc=class n{static defaultAnimationLoopProps={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>{console.error(e)},stats:void 0,autoResizeViewport:!1,animationFrameProvider:b1};device=null;canvas=null;props;animationProps=null;timeline=null;stats;sharedStats;cpuTime;gpuTime;frameRate;display;_needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;_lastFrameTime=0;constructor(e){if(this.props={...n.defaultAnimationLoopProps,...e},e=this.props,!e.device)throw new Error("No device provided");this.stats=e.stats||new Vt({id:`animation-loop-${PF++}`}),this.sharedStats=Vs.stats.get(CF),this.frameRate=this.stats.get("Frame Rate"),this.frameRate.setSampleSize(1),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.setProps({autoResizeViewport:e.autoResizeViewport,animationFrameProvider:e.animationFrameProvider}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null),this.device?._disableDebugGPUTime()}delete(){this.destroy()}reportError(e){this._error=e,this.props.onError(e),this.props.onError===n.defaultAnimationLoopProps.onError&&typeof window<"u"&&typeof ErrorEvent<"u"&&window.dispatchEvent(new ErrorEvent("error",{error:e,message:e.message}))}setNeedsRedraw(e){return this._needsRedraw=this._needsRedraw||e,this}needsRedraw(){let e=this._needsRedraw;return this._needsRedraw=!1,e}setProps(e){if("autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),"animationFrameProvider"in e){let t=e.animationFrameProvider||b1;if(t!==this.props.animationFrameProvider){let i=this._animationFrameId!==null;i&&this._cancelAnimationFrame(),this.props.animationFrameProvider=t,i&&this._requestAnimationFrame()}}return this}async start(){if(this._running)return this;this._running=!0;try{let e;if(!this._initialized){if(this._initialized=!0,await this._initDevice(),this._initialize(),!this._running)return null;await this.props.onInitialize(this._getAnimationProps())}return this._running?(e!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){let t=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(t),t}}stop(){if(this._running){let e=this.animationProps;this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1,this._lastFrameTime=0,e&&this.props.onFinalize(e)}return this}redraw(e,t=null){return this.device?.isLost||this._error?this:(this._beginFrameTimers(e),this._setupFrame(),this.animationProps&&(this.animationProps.animationFrame=t),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeViewport(),this.device?._enableDebugGPUTime()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=this.props.animationFrameProvider.requestAnimationFrame(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(this.props.animationFrameProvider.cancelAnimationFrame(this._animationFrameId),this._animationFrameId=null)}_animationFrame(e,t){if(this._running)try{this.redraw(e,t??null),this._requestAnimationFrame()}catch(i){let r=i instanceof Error?i:new Error(String(i));this.reportError(r),this.stop()}}_renderFrame(e){if(this.display){this.display._renderFrame(e);return}let t=this.props.onRender(this._getAnimationProps());this.device&&t!==!1&&this.device.submit()}_clearNeedsRedraw(){this._needsRedraw=!1}_setupFrame(){this._resizeViewport()}_initializeAnimationProps(){let e=this.device?.getDefaultCanvasContext();if(!this.device||!e)throw new Error("loop");let t=e?.canvas,i=e.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:e,canvas:t,useDevicePixels:i,timeline:this.timeline,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,animationFrame:null,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:e,height:t,aspect:i}=this._getSizeAndAspect();(e!==this.animationProps.width||t!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),i!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=t,this.animationProps.aspect=i,this.animationProps.needsRedraw=this._needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.getDefaultCanvasContext().canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";let t=document.createElement("div");t.style.position="absolute",t.style.left="10px",t.style.bottom="10px",t.style.width="300px",t.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(t);let i=this.props.onAddHTML(t);i&&(t.innerHTML=i)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[e,t]=this.device.getDefaultCanvasContext().getDrawingBufferSize(),i=e>0&&t>0?e/t:1;return{width:e,height:t,aspect:i}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(e){let t=e??(typeof performance<"u"?performance.now():Date.now());if(this._lastFrameTime){let i=t-this._lastFrameTime;i>0&&this.frameRate.addTime(i)}this._lastFrameTime=t,this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeStart()}_endFrameTimers(){this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeEnd(),this._updateSharedStats()}_consumeEncodedGpuTime(){if(!this.device)return;let e=this.device.commandEncoder._gpuTimeMs;e!==void 0&&(this.gpuTime.addTime(e),this.device.commandEncoder._gpuTimeMs=void 0)}_updateSharedStats(){if(this.stats!==this.sharedStats){for(let e of Object.keys(this.sharedStats.stats))this.stats.stats[e]||delete this.sharedStats.stats[e];this.stats.forEach(e=>{let t=this.sharedStats.get(e.name,e.type);t.sampleSize=e.sampleSize,t.time=e.time,t.count=e.count,t.samples=e.samples,t.lastTiming=e.lastTiming,t.lastSampleTime=e.lastSampleTime,t.lastSampleCount=e.lastSampleCount,t._count=e._count,t._time=e._time,t._samples=e._samples,t._startTime=e._startTime,t._timerPending=e._timerPending})}}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}}});function x1(n,e){if(e instanceof Rf)return e;let t=h1(e),i=TF(n,t),{attributes:r,bufferLayout:s}=LF(n,t);return new Rf({topology:t.topology||"triangle-list",bufferLayout:s,vertexCount:t.vertexCount,indices:i,attributes:r})}function TF(n,e){if(!e.indices)return;let t=e.indices.value;return n.createBuffer({usage:re.INDEX,data:t})}function LF(n,e){let t={};for(let[i,r]of Object.entries(e.attributes)){let s=e.bufferLayout.find(o=>o.name===i)?.name||Kr(i);r&&(t[s]=n.createBuffer({data:r.value,id:`${i}-buffer`}))}return{attributes:t,bufferLayout:e.bufferLayout,vertexCount:e.vertexCount}}var Rf,w1=C(()=>{ee();kf();p1();_o();Rf=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){if(this.id=e.id||jn("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&!(this.indices.usage&re.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){this.indices?.destroy();for(let e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(e){return e.byteLength/12}}});function E1(n,e){let t={},i="Values";if(n.attributes.length===0&&!n.varyings?.length)return{"No attributes or varyings":{[i]:"N/A"}};for(let r of n.attributes)if(r){let s=`${r.location} ${r.name}: ${r.type}`;t[`in ${s}`]={[i]:r.stepMode||"vertex"}}for(let r of n.varyings||[]){let s=`${r.location} ${r.name}`;t[`out ${s}`]={[i]:JSON.stringify(r)}}return t}var S1=C(()=>{});function T1(n,e,t){if(n.device.type!=="webgl")return;let i=kF(n.device);if(!i.flushing){if(IF(n)){MF(n,t,i);return}e&&RF(e)&&e.handle!==null&&(i.queuedFramebuffers.includes(e)||i.queuedFramebuffers.push(e))}}function MF(n,e,t){if(t.queuedFramebuffers.length===0)return;let i=n.device,{gl:r}=i,s=r.getParameter(36010),o=r.getParameter(36006),[a,c]=n.device.getDefaultCanvasContext().getDrawingBufferSize(),l=C1(e.top,8),u=C1(e.left,8);t.flushing=!0;try{for(let f of t.queuedFramebuffers){let[d,h,p,m,g]=AF({framebuffer:f,targetWidth:a,targetHeight:c,topPx:l,leftPx:u,minimap:e.minimap});r.bindFramebuffer(36008,f.handle),r.bindFramebuffer(36009,null),r.blitFramebuffer(0,0,f.width,f.height,d,h,p,m,16384,9728),l+=g+8}}finally{r.bindFramebuffer(36008,s),r.bindFramebuffer(36009,o),t.flushing=!1}}function AF(n){let{framebuffer:e,targetWidth:t,targetHeight:i,topPx:r,leftPx:s,minimap:o}=n,a=o?Math.max(Math.floor(t/4),1):t,c=o?Math.max(Math.floor(i/4),1):i,l=Math.min(a/e.width,c/e.height),u=Math.max(Math.floor(e.width*l),1),f=Math.max(Math.floor(e.height*l),1),d=s,h=Math.max(i-r-f,0),p=d+u,m=h+f;return[d,h,p,m,f]}function kF(n){return n.userData[P1]||={flushing:!1,queuedFramebuffers:[]},n.userData[P1]}function RF(n){return"colorAttachments"in n}function IF(n){let e=n.props.framebuffer;return!e||e.handle===null}function C1(n,e){if(!n)return e;let t=Number.parseInt(n,10);return Number.isFinite(t)?t:e}var P1,L1=C(()=>{P1="__debugFramebufferState"});function yo(n,e,t){if(n===e)return!0;if(!t||!n||!e)return!1;if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let i=0;i{});var bo,A1=C(()=>{ee();bo=class{bufferLayouts;constructor(e){this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(t=>t.name===e)||null}getAttributeNamesForBuffer(e){return qs(e)}mergeBufferLayouts(e,t){let i=[...e];for(let r of t){let s=i.findIndex(o=>o.name===r.name);s<0?i.push(r):i[s]=r}return i}}});function k1(n,e){let t=Xm(n),i=e.slice();return i.sort((r,s)=>{let o=Gu(qs(r).map(c=>t[c])),a=Gu(qs(s).map(c=>t[c]));return o-a}),i}var R1=C(()=>{ee()});function vo(n,e){if(!n||!e.some(i=>i.bindingLayout?.length))return n;let t={...n,bindings:n.bindings.map(i=>({...i}))};"attributes"in(n||{})&&(t.attributes=n?.attributes||[]);for(let i of e)for(let r of i.bindingLayout||[])for(let s of BF(r.name)){let o=t.bindings.find(a=>a.name===s);o?.group===0&&(o.group=r.group),o&&r.visibility!==void 0&&(o.visibility=r.visibility)}return t}function I1(n,e,t=[]){return n?e?{...n,attributes:n.attributes.length?NF(n.attributes,e.attributes.filter(i=>t.includes(i.name))):e.attributes,bindings:DF(n.bindings,e.bindings)}:n:e}function gc(n){return!!(n.uniformTypes&&!OF(n.uniformTypes))}function B1(n){let e=[];for(let t of n){let i=Va(t),r=new Set([t.vs,t.fs].flatMap(o=>o?Wa(o).filter(a=>a.isStd140).map(a=>a.blockName):[])),s=r.has(i)?i:r.size===1?r.values().next().value:void 0;gc(t)&&s&&e.push({name:s,uniformTypes:t.uniformTypes})}return e}function If(n,e){let t=[],i=new Set;for(let r of[...n||[],...e||[]])i.has(r.name)||(i.add(r.name),t.push(r));return t}function BF(n){let e=new Set([n,`${n}Uniforms`]);return n.endsWith("Uniforms")||e.add(`${n}Sampler`),[...e]}function OF(n){for(let e in n)return!1;return!0}function DF(n,e){let t=n.map(s=>({...s})),i=new Set(n.map(s=>s.name)),r=new Set(n.map(s=>`${s.group}:${s.location}`));for(let s of e){let o=`${s.group}:${s.location}`;!i.has(s.name)&&!r.has(o)&&t.push({...s})}return t}function NF(n,e){let t=n.map(s=>({...s})),i=new Map(n.map(s=>[s.name,s])),r=new Map(n.map(s=>[s.location,s]));for(let s of e){let o=i.get(s.name);if(o){if(o.type!==s.type||o.location!==s.location)throw new Error(`Shader attribute "${s.name}" conflicts with its inferred type or location`);continue}let a=r.get(s.location);if(a)throw new Error(`Shader attributes "${a.name}" and "${s.name}" both use location ${s.location}`);t.push({...s})}return t}var T_=C(()=>{bt()});function FF(n){return ga(n)||typeof n=="number"||typeof n=="boolean"}function O1(n,e={}){let t={bindings:{},uniforms:{}};return Object.keys(n).forEach(i=>{let r=n[i];Object.prototype.hasOwnProperty.call(e,i)||FF(r)?t.uniforms[i]=r:t.bindings[i]=r}),t}var D1=C(()=>{Qp()});function N1(n={},e={},t={}){let i={...n};for(let[r,s]of Object.entries(e))s!==void 0&&(i[r]=L_(n[r],s,t[r]));return i}function L_(n,e,t){if(!t||typeof t=="string")return _c(e);if(Array.isArray(t)){if(M_(e)||!Array.isArray(e))return _c(e);let o=Array.isArray(n)&&!M_(n)?[...n]:[],a=o.slice();for(let c=0;ct===void 0?void 0:_c(t)):A_(n)?Object.fromEntries(Object.entries(n).map(([e,t])=>[e,t===void 0?void 0:_c(t)])):n}function M_(n){return ArrayBuffer.isView(n)||Array.isArray(n)&&(n.length===0||typeof n[0]=="number")}function A_(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&!ArrayBuffer.isView(n)}function zF(n){return!!n?.dependencies}var xo,k_=C(()=>{ee();bt();D1();xo=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;directBindings={};constructor(e,t){Object.assign(this.options,t);let i=Cr(Object.values(e).filter(zF));for(let r of i)e[r.name]=r;z.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(let[r,s]of Object.entries(e))s&&(this._addModule(s),s.name&&r!==s.name&&!this.options.disableWarnings&&z.warn(`Module name: ${r} vs ${s.name}`)())}destroy(){}setProps(e){e.bindings&&Object.assign(this.directBindings,e.bindings);for(let t of Object.keys(e)){if(t==="bindings")continue;let i=t,r=e[i]||{},s=this.modules[i];if(!s)this.options.disableWarnings||z.warn(`Module ${t} not found`)();else{let o=this.moduleUniforms[i],a=this.moduleBindings[i],c=s.getUniforms?.(r,o)||r,{uniforms:l,bindings:u}=O1(c,s.uniformTypes);this.moduleUniforms[i]=N1(o,l,s.uniformTypes),this.moduleBindings[i]={...a,...u}}}}getModules(){return Object.values(this.modules)}addModules(e){let t=Cr(e);for(let i of t){let r=i.name;this.modules[r]||(this.modules[r]=i,this._addModule(i))}}getUniformValues(){return this.moduleUniforms}getBindingValues(){let e={};for(let t of Object.values(this.moduleBindings))Object.assign(e,t);return Object.assign(e,this.directBindings),e}getModuleBindingValues(e){let t=this.moduleBindings[e];return t?{...t}:{}}getDebugTable(){let e={};for(let[t,i]of Object.entries(this.moduleUniforms))for(let[r,s]of Object.entries(i))e[`${t}.${r}`]={type:this.modules[t].uniformTypes?.[r],value:String(s)};return e}_addModule(e){let t=e.name;this.moduleUniforms[t]=N1({},e.defaultUniforms||{},e.uniformTypes),this.moduleBindings[t]={}}}});function R_(n){return n!==null&&typeof n=="object"&&"buffer"in n}function $F(n){return n instanceof nt?n.buffer:n}function F1(n){return{buffer:$F(n.buffer),offset:n.offset,size:n.size}}var UF,nt,I_=C(()=>{ee();_o();UF=re.DEBUG_DATA_MAX_LENGTH,nt=class{device;id;ready;usage;props;isReady=!0;destroyed=!1;generation=0;updateTimestamp;debugData=new ArrayBuffer(0);_debugDataEnabled;_maxDebugDataByteLength;_ownsBuffer;_buffer;get buffer(){return this._buffer}get byteLength(){return this._buffer.byteLength}get[Symbol.toStringTag](){return"DynamicBuffer"}toString(){return`DynamicBuffer:"${this.id}":${this.byteLength}B`}toJSON(){return this.toString()}constructor(e,t){let{debugData:i=!1,buffer:r,ownsBuffer:s=!0,...o}=t;if(r&&r.device!==e)throw new Error("DynamicBuffer adopted buffers must belong to the supplied device");if(r&&(o.byteLength!==void 0||o.data!==void 0))throw new Error("DynamicBuffer cannot combine an adopted buffer with byteLength or data");let a=t.id||r?.id||jn("dynamic-buffer"),c={...o,id:a,usage:o.usage??r?.usage,indexType:o.indexType??r?.indexType};(c.usage||0)&re.INDEX&&!c.indexType&&(o.data instanceof Uint32Array?c.indexType="uint32":o.data instanceof Uint16Array?c.indexType="uint16":o.data instanceof Uint8Array&&(c.indexType="uint8")),delete c.data,delete c.byteOffset,this.device=e,this.id=a,this.props=c,this.usage=c.usage||0,this._debugDataEnabled=!!i,this._maxDebugDataByteLength=typeof i=="object"&&i.maxByteLength!==void 0?i.maxByteLength:UF,this._ownsBuffer=s,this._buffer=r??this.device.createBuffer({...o,id:a}),this.ready=Promise.resolve(this._buffer),this.updateTimestamp=this._buffer.updateTimestamp,this._resetDebugData(this._buffer.byteLength),o.data&&this._writeDebugData(o.data,o.byteOffset||0)}write(e,t=0){this._buffer.write(e,t),this._touch(),this._writeDebugData(e,t)}async mapAndWriteAsync(e,t=0,i=this.byteLength-t){let r=null;await this._buffer.mapAndWriteAsync(async(s,o)=>{await e(s,o),r=new Uint8Array(s.slice(0,i))},t,i),this._touch(),r&&this._writeDebugData(r,t)}async readAsync(e=0,t=this.byteLength-e){let i=await this._buffer.readAsync(e,t);return this._writeDebugData(i,e)&&this._touch(),i}async mapAndReadAsync(e,t=0,i=this.byteLength-t){let r=null,s=await this._buffer.mapAndReadAsync(async(o,a)=>(r=new Uint8Array(o.slice(0)),await e(o,a)),t,i);return r&&this._writeDebugData(r,t)&&this._touch(),s}resize(e){let{byteLength:t,preserveData:i=!1}=e;if(t===this.byteLength)return!1;let r=Math.min(e.copyByteLength??Math.min(this.byteLength,t),this.byteLength,t),s=this._buffer,o=this.debugData.slice(0),{data:a,byteOffset:c,...l}=this.props,u=this.device.createBuffer({...l,byteLength:t});return i&&r>0&&this._copyBufferContents(s,u,r),this._buffer=u,this._resetDebugData(t),i&&o.byteLength>0&&this._writeDebugData(o,0),this._ownsBuffer&&s.destroy(),this._ownsBuffer=!0,this.generation++,this._touch(),!0}ensureSize(e,t){return e<=this.byteLength?!1:this.resize({byteLength:e,preserveData:t?.preserveData})}getBinding(e){return e?.offset===void 0&&e?.size===void 0?this._buffer:{buffer:this._buffer,offset:e?.offset,size:e?.size}}destroy(){this.destroyed||(this._ownsBuffer&&this._buffer.destroy(),this.destroyed=!0,this.debugData=new ArrayBuffer(0))}_copyBufferContents(e,t,i){let r=this.device.type==="webgpu"?Math.ceil(i/4)*4:i,s=this.device.createCommandEncoder();s.copyBufferToBuffer({sourceBuffer:e,destinationBuffer:t,size:r}),this.device.submit(s.finish())}_touch(){this.updateTimestamp=this.device.incrementTimestamp()}_resetDebugData(e){if(!this._debugDataEnabled){this.debugData=new ArrayBuffer(0);return}this.debugData=new ArrayBuffer(Math.min(e,this._maxDebugDataByteLength))}_writeDebugData(e,t){if(!this._debugDataEnabled||this.debugData.byteLength===0||t>=this.debugData.byteLength)return!1;let i=ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),r=new Uint8Array(this.debugData),s=Math.min(i.byteLength,r.byteLength-t);return r.set(i.subarray(0,s),t),s>0}}});function yc(n){return n!==null&&typeof n=="object"&&"resolveTextureBinding"in n&&typeof n.resolveTextureBinding=="function"}function GF(n){return n?.type==="texture"||n?.type==="external-texture"}function z1(n,e,t){let i=Du(n,e,{ignoreWarnings:!0});return GF(i)?i:n.bindings.length===0&&t?.fallbackGroup!==void 0?{type:"texture",name:e,group:t.fallbackGroup,location:0}:null}var U1=C(()=>{ee()});function O_(n,e){return n.shaderLanguage!==void 0&&n.shaderLanguage!==e?!1:e==="glsl"?"assembleGLSLShaderPair"in n&&typeof n.assembleGLSLShaderPair=="function":"assembleWGSLShader"in n&&typeof n.assembleWGSLShader=="function"}function jF(n,e){return!n||Object.keys(e).length===0?n:{...n,attributes:n.attributes.map(t=>{let i=t.name.startsWith("_luma_")?t.name.slice(6):null;return i&&e[i]?{...t,name:i}:t})}}function HF(n,e,t){if(yc(e)){let i=z1(t,n,{fallbackGroup:0});return i?e.resolveTextureBinding(i):null}return e instanceof nt?e.buffer:R_(e)?F1(e):e}function YF(n){return n&&!$1(n)?n:null}function qF(n){return n&&$1(n)?n:void 0}function $1(n){return WF.includes(n)}function ZF(n){return{type:n.type,shaderLanguage:n.info.shadingLanguage,shaderLanguageVersion:n.info.shadingLanguageVersion,gpu:n.info.gpu,limits:n.limits,features:n.features}}var Hn,VF,B_,WF,Ze,D_=C(()=>{ee();bt();w1();S1();L1();M1();A1();R1();T_();_o();k_();I_();U1();Hn=2,VF=1e4,B_="render pipeline initialization failed",WF=["stencil8","depth16unorm","depth24plus","depth24plus-stencil8","depth32float","depth32float-stencil8"],Ze=class n{static defaultProps={...Ht.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],plugins:[],geometry:null,indexBuffer:null,indexCount:void 0,firstVertex:0,firstIndex:0,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,material:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:Yt.getDefaultShaderAssembler("glsl"),debugShaders:void 0,disableWarnings:void 0};device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexCount;firstVertex;firstIndex;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;material=null;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_dynamicIndexBufferSource=null;_dynamicAttributeBufferSources={};_colorAttachmentFormats;_depthStencilAttachmentFormat;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_drawBlockedReason=!1;_destroyed=!1;_vertexCountSet=!1;_lastDrawTimestamp=-1;_bindingTable=[];get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(e,t){let i=n.defaultProps.shaderAssembler,r=t.vertexCount!==void 0;this.props={...n.defaultProps,...t,shaderAssembler:t.shaderAssembler??(O_(i,e.info.shadingLanguage)?i:Yt.getDefaultShaderAssembler(e.info.shadingLanguage))},this._vertexCountSet=r,t=this.props,this.id=t.id||jn("model"),this.device=e,Object.assign(this.userData,t.userData),this.material=t.material||null;let s=ZF(e),o=$a(this.props.plugins,s.shaderLanguage),a=Ga(this.props.modules,o.modules),c=Object.fromEntries(a.map(h=>[h.name,h])),l=t.shaderInputs||new xo(c,{disableWarnings:this.props.disableWarnings});t.shaderInputs&&o.modules.length>0&&l.addModules(o.modules),this.setShaderInputs(l);let u=If(this.props.modules,l.getModules()),f={...o.defines,...this.props.defines};if(this.device.type==="webgl"&&(this.props._uniformBlockLayouts=B1(u)),this.props.shaderLayout=vo(this.props.shaderLayout,u)||null,this.device.type==="webgpu"&&this.props.source){let h=this.props.shaderAssembler;$i(O_(h,"wgsl"));let{source:p,getUniforms:m,bindingTable:g,shaderLayout:v}=h.assembleWGSLShader({platformInfo:s,...this.props,modules:u,defines:f,pluginInjections:o.injections,pluginVertexInputs:o.vertexInputs,pluginVaryings:o.varyings});this.source=p,this._getModuleUniforms=m,this._bindingTable=g;let y=v??e.getShaderLayout?.(this.source),b=jF(y,o.vertexInputs),w=I1(this.props.shaderLayout,b,Object.keys(o.vertexInputs));this.props.shaderLayout=vo(w||null,u)||null}else{let h=this.props.shaderAssembler;$i(O_(h,"glsl"));let{vs:p,fs:m,getUniforms:g}=h.assembleGLSLShaderPair({platformInfo:s,...this.props,modules:u,defines:f,pluginInjections:o.injections,pluginVertexInputs:o.vertexInputs,pluginVaryings:o.varyings});this.vs=p,this.fs=m,this._getModuleUniforms=g,this._bindingTable=[]}this.vertexCount=this.props.vertexCount,this.indexCount=this.props.indexCount,this.firstVertex=this.props.firstVertex,this.firstIndex=this.props.firstIndex,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,this._colorAttachmentFormats=this.props.colorAttachmentFormats,this._depthStencilAttachmentFormat=this.props.depthStencilAttachmentFormat,t.geometry&&this.setGeometry(t.geometry),this.pipelineFactory=t.pipelineFactory||Ir.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||Br.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in t&&(this.isInstanced=t.isInstanced),t.instanceCount&&this.setInstanceCount(t.instanceCount),t.vertexCount&&this.setVertexCount(t.vertexCount),t.indexBuffer&&this.setIndexBuffer(t.indexBuffer),t.attributes&&this.setAttributes(t.attributes),t.constantAttributes&&this.setConstantAttributes(t.constantAttributes),t.bindings&&this.setBindings(t.bindings),t.transformFeedback&&(this.transformFeedback=t.transformFeedback)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}getBindingDebugTable(){return this._bindingTable}predraw(e){this._syncDynamicBuffers(),this.updateShaderInputs(e),this.material?.updateShaderInputs(e),this.pipeline=this._updatePipeline()}draw(e){if(this._drawBlockedReason&&!this._pipelineNeedsUpdate)return z.info(Hn,`>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)(),!1;let t=this._areBindingsLoading();if(t)return z.info(Hn,`>>> DRAWING ABORTED ${this.id}: ${t} not loaded`)(),!1;this._syncAttachmentFormats(e);try{e.pushDebugGroup(`${this}.predraw(${e})`),this.device.type==="webgpu"?(this.updateShaderInputs(),this.material?.updateShaderInputs(),this._syncDynamicBuffers(),this.pipeline=this._updatePipeline()):this.predraw(this.device.commandEncoder)}finally{e.popDebugGroup()}let i,r=this.pipeline.isErrored;try{if(e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline(),r=this.pipeline.isErrored,r)z.info(Hn,`>>> DRAWING ABORTED ${this.id}: ${B_}`)(),i=!1;else{let s=this.vertexArray.getDrawValidationError();if(s)z.info(Hn,`>>> DRAWING ABORTED ${this.id}: ${s}`)(),this._drawBlockedReason=s,i=!1;else{let o=this._getCurrentShaderLayout(),a=this._getBindings(o),c=this._getBindGroups(o,a),{indexBuffer:l}=this.vertexArray,u=l?this.indexCount??(this._vertexCountSet?this.vertexCount:l.byteLength/(l.indexType==="uint32"?4:2)):void 0;e.setPipeline(this.pipeline),e.setBindings(c,{_bindGroupCacheKeys:this._getBindGroupCacheKeys()}),e.setVertexArray(this.vertexArray),i=this.isInstanced===!0&&this.instanceCount===0?!0:e.draw({isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.isInstanced?this.instanceCount:void 0,indexCount:u,firstVertex:this.firstVertex,firstIndex:this.firstIndex,transformFeedback:this.transformFeedback||void 0,uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}}}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),i?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):r?(this._needsRedraw=B_,this._drawBlockedReason=B_):this._drawBlockedReason?this._needsRedraw=this._drawBlockedReason:this._needsRedraw="waiting for resource initialization",i}setGeometry(e){this._gpuGeometry?.destroy();let t=e&&x1(this.device,e);if(t){this.setTopology(t.topology||"triangle-list");let i=new bo(this.bufferLayout);this.bufferLayout=i.mergeBufferLayouts(t.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(t)}this._gpuGeometry=t}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){let t=new bo(this.bufferLayout),i=this._gpuGeometry?t.mergeBufferLayouts(e,this._gpuGeometry.bufferLayout):e;yo(i,this.bufferLayout,-1)||(this.bufferLayout=i,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry))}setParameters(e){yo(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,this.isInstanced===void 0&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this._vertexCountSet=!0,this.setNeedsRedraw("vertexCount")}setIndexCount(e){this.indexCount=e,this.setNeedsRedraw("indexCount")}setDrawOffsets({firstVertex:e,firstIndex:t}){this.firstVertex=e,this.firstIndex=t,this.setNeedsRedraw("drawOffsets")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new Nr(this.device,this.shaderInputs.modules);for(let[t,i]of Object.entries(this.shaderInputs.modules))if(gc(i)&&!this.material?.ownsModule(t)){let r=this._uniformStore.getManagedUniformBuffer(t);this.bindings[`${t}Uniforms`]=r}this.setNeedsRedraw("shaderInputs")}setMaterial(e){this.material=e,this.setNeedsRedraw("material")}updateShaderInputs(e){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),e),this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues())),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){let t=e instanceof nt?e.buffer:e;this.indexBuffer=t,this._dynamicIndexBufferSource=e instanceof nt?{source:e,generation:e.generation}:null,this.vertexArray.setIndexBuffer(t),this.setNeedsRedraw("indexBuffer")}setAttributes(e,t){this._drawBlockedReason=!1;let i=t?.disableWarnings??this.props.disableWarnings;e.indices&&z.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=k1(this.pipeline.shaderLayout,this.bufferLayout);let r=new bo(this.bufferLayout);for(let[s,o]of Object.entries(e)){let a=o instanceof nt?o.buffer:o,c=r.getBufferLayout(s);if(!c){i||z.warn(`Model(${this.id}): Missing layout for buffer "${s}".`)();continue}let l=r.getAttributeNamesForBuffer(c),u=!1;for(let f of l){let d=this._attributeInfos[f];if(d){let h=this.device.type==="webgpu"?this.vertexArray.getBufferSlot(d.bufferName):d.location;if(h===null){i||z.warn(`Model(${this.id}): Missing vertex array slot for buffer "${d.bufferName}".`)();continue}this.vertexArray.setBuffer(h,a),o instanceof nt?this._dynamicAttributeBufferSources[h]={source:o,generation:o.generation}:delete this._dynamicAttributeBufferSources[h],u=!0}}!u&&!i&&z.warn(`Model(${this.id}): Ignoring buffer "${a.id}" for unknown attribute "${s}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,t){for(let[i,r]of Object.entries(e)){let s=this._attributeInfos[i];s?this.vertexArray.setConstantWebGL(s.location,r):(t?.disableWarnings??this.props.disableWarnings)||z.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(let e of Object.values(this.bindings))if(yc(e)&&!e.isReady)return e.id;for(let e of Object.values(this.material?.bindings||{}))if(yc(e)&&!e.isReady)return e.id;return!1}_getBindings(e=this._getCurrentShaderLayout()){let t={};for(let[i,r]of Object.entries(this.bindings)){let s=HF(i,r,e);s&&(t[i]=s)}return t}_getBindGroups(e=this._getCurrentShaderLayout(),t=this._getBindings(e)){let i=e.bindings.length?Or(e,t):{0:t};if(!this.material)return i;for(let[r,s]of Object.entries(this.material.getBindingsByGroup(e))){let o=Number(r);i[o]={...i[o]||{},...s}}return i}_getBindGroupCacheKeys(){let e=this.material?.getBindGroupCacheKey(3);return e?{3:e}:{}}_getBindingsUpdateTimestamp(){let e=0;this._dynamicIndexBufferSource&&(e=Math.max(e,this._dynamicIndexBufferSource.source.updateTimestamp));for(let t of Object.values(this._dynamicAttributeBufferSources))e=Math.max(e,t.source.updateTimestamp);for(let t of Object.values(this.bindings))t instanceof Ar?e=Math.max(e,t.texture.updateTimestamp):t instanceof re||t instanceof pe||t instanceof Ma||t instanceof nt?e=Math.max(e,t.updateTimestamp):yc(t)?e=t.isReady?Math.max(e,t.updateTimestamp):1/0:R_(t)&&(e=Math.max(e,(t.buffer instanceof nt,t.buffer.updateTimestamp)));return Math.max(e,this.material?.getBindingsUpdateTimestamp()||0)}_setGeometryAttributes(e){let t={...e.attributes};for(let[i]of Object.entries(t))!this.pipeline.shaderLayout.attributes.find(r=>r.name===i)&&i!=="positions"&&delete t[i];this.vertexCount=e.vertexCount,this._vertexCountSet=!0,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(t,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this._drawBlockedReason=!1,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,t=null;this.pipeline&&(z.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,t=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let i=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders}),r=null;this.source?r=i:this.fs&&(r=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bindings:void 0,bufferLayout:this.bufferLayout,colorAttachmentFormats:this._colorAttachmentFormats,depthStencilAttachmentFormat:this._depthStencilAttachmentFormat,topology:this.topology,parameters:this.parameters,bindGroups:void 0,vs:i,fs:r}),this._attributeInfos=Ua(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&t!==e&&this.shaderFactory.release(t)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=z.level>3?0:VF;z.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:z.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=E1(this.pipeline.shaderLayout,this.id);z.table(Hn,e)();let t=this.shaderInputs.getDebugTable();z.table(Hn,t)();let i=this._getAttributeDebugTable();z.table(Hn,this._attributeInfos)(),z.table(Hn,i)(),z.groupEnd(Hn)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){let t=this.device.props.debugFramebuffers;if(this._drawCount++,!t)return;let i=e.props.framebuffer;T1(e,i,{id:i?.id||`${this.id}-framebuffer`,minimap:!0})}_getAttributeDebugTable(){let e={};for(let[t,i]of Object.entries(this._attributeInfos)){let r=this.vertexArray.attributes[i.location];e[i.location]={name:t,type:i.shaderType,values:r?this._getBufferOrConstantValues(r,i.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:t}=this.vertexArray,i=t.indexType==="uint32"?new Uint32Array(t.debugData):new Uint16Array(t.debugData);e.indices={name:"indices",type:t.indexType,values:i.toString()}}return e}_getBufferOrConstantValues(e,t){let i=Ke.getTypedArrayConstructor(t);return(e instanceof re?new i(e.debugData):e).toString()}_getNonMaterialBindings(e){if(!this.material)return e;let t={};for(let[i,r]of Object.entries(e))this.material.ownsBinding(i)||(t[i]=r);return t}_getCurrentShaderLayout(){return this.pipeline?.shaderLayout||this.props.shaderLayout||{bindings:[]}}_syncDynamicBuffers(){if(this._dynamicIndexBufferSource&&this._dynamicIndexBufferSource.generation!==this._dynamicIndexBufferSource.source.generation){let e=this._dynamicIndexBufferSource.source.buffer;this.indexBuffer=e,this.vertexArray.setIndexBuffer(e),this._dynamicIndexBufferSource.generation=this._dynamicIndexBufferSource.source.generation,this.setNeedsRedraw("dynamic index buffer")}for(let[e,t]of Object.entries(this._dynamicAttributeBufferSources))t.generation!==t.source.generation&&(this.vertexArray.setBuffer(Number(e),t.source.buffer),t.generation=t.source.generation,this.setNeedsRedraw("dynamic attribute buffer"))}_syncAttachmentFormats(e){if(this.device.type!=="webgpu")return;let t=e.framebuffer||e.props.framebuffer,i=e.props,r=i.colorAttachmentFormats??t?.colorAttachments?.map(o=>YF(o?.texture?.format)),s=i.depthStencilAttachmentFormat===!1?void 0:i.depthStencilAttachmentFormat??qF(t?.depthStencilAttachment?.texture?.format);(!yo(this._colorAttachmentFormats,r,1)||this._depthStencilAttachmentFormat!==s)&&(this._colorAttachmentFormats=r,this._depthStencilAttachmentFormat=s,this._setPipelineNeedsUpdate("attachment formats"))}}});var XF,KF,it,G1=C(()=>{ee();bt();D_();XF=35980,KF=35981,it=class n{device;model;transformFeedback;static defaultProps={...Ze.defaultProps,feedbackBufferMode:"separate",outputs:void 0,feedbackBuffers:void 0};static isSupported(e){return e?.info?.type==="webgl"}constructor(e,t=n.defaultProps){if(!n.isSupported(e))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=e,this.model=new Ze(this.device,{id:t.id||"buffer-transform-model",fs:t.fs||dg(),topology:t.topology||"point-list",varyings:t.outputs||t.varyings,...t,bufferMode:t.bufferMode||(t.feedbackBufferMode==="interleaved"?XF:KF)}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:t.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){e?.inputBuffers&&this.model.setAttributes(e.inputBuffers),e?.outputBuffers&&this.transformFeedback.setBuffers(e.outputBuffers);let t=this.device.beginRenderPass({discard:!0,...e});this.model.draw(t),t.end()}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){let t=this.getBuffer(e);if(!t)throw new Error("BufferTransform#getBuffer");if(t instanceof re)return t.readAsync();let{buffer:i,byteOffset:r=0,byteLength:s=i.byteLength}=t;return i.readAsync(r,s)}}});function JF(n){return{type:n.type,shaderLanguage:n.info.shadingLanguage,shaderLanguageVersion:n.info.shadingLanguageVersion,gpu:n.info.gpu,limits:n.limits,features:n.features}}var N_,QF,Rt,V1=C(()=>{ee();bt();Qp();k_();T_();_o();N_=2,QF=1e4,Rt=class n{static defaultProps={...Wi.defaultProps,id:"unnamed",handle:void 0,userData:{},source:"",modules:[],defines:{},plugins:[],bindings:void 0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,shaderAssembler:Yt.getDefaultShaderAssembler("wgsl"),debugShaders:void 0};device;id;pipelineFactory;shaderFactory;userData={};bindings={};pipeline;source;shader;shaderInputs;_uniformStore;_pipelineNeedsUpdate="newly created";_getModuleUniforms;props;_destroyed=!1;constructor(e,t){if(e.type!=="webgpu")throw new Error("Computation is only supported in WebGPU");this.props={...n.defaultProps,...t},t=this.props,this.id=t.id||jn("model"),this.device=e,Object.assign(this.userData,t.userData);let i=JF(e),r=$a(this.props.plugins,i.shaderLanguage);if(Object.keys(r.vertexInputs).length>0||Object.keys(r.varyings).length>0)throw new Error("Computation does not support ShaderPlugin vertex inputs or varyings");let s=Ga(this.props.modules,r.modules),o=Object.fromEntries(s.map(p=>[p.name,p]));this.shaderInputs=t.shaderInputs||new xo(o),t.shaderInputs&&r.modules.length>0&&this.shaderInputs.addModules(r.modules),this.setShaderInputs(this.shaderInputs);let a=If(this.props.modules,this.shaderInputs?.getModules()),c={...r.defines,...this.props.defines};this.props.shaderLayout=vo(this.props.shaderLayout,a)||null,this.pipelineFactory=t.pipelineFactory||Ir.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||Br.getDefaultShaderFactory(this.device);let l=this.props.shaderAssembler;$i(l instanceof Hi);let{source:u,getUniforms:f,shaderLayout:d}=l.assembleWGSLShader({platformInfo:i,...this.props,modules:a,defines:c,scanVertexAttributes:!1,pluginInjections:r.injections});this.source=u,this._getModuleUniforms=f;let h=d??e.getShaderLayout?.(this.source,{scanVertexAttributes:!1});this.props.shaderLayout=vo(this.props.shaderLayout||h||null,a)||null,this.pipeline=this._updatePipeline(),t.bindings&&this.setBindings(t.bindings)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.shader),this._uniformStore.destroy(),this._destroyed=!0)}predraw(e){this.updateShaderInputs(e)}dispatch(e,t,i,r){try{this._logDrawCallStart(),this._setPipeline(e),e.dispatch(t,i,r)}finally{this._logDrawCallEnd()}}dispatchIndirect(e,t,i=0){try{this._logDrawCallStart(),this._setPipeline(e),e.dispatchIndirect(t,i)}finally{this._logDrawCallEnd()}}_setPipeline(e){this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings),e.setPipeline(this.pipeline),e.setBindings({})}setVertexCount(e){}setInstanceCount(e){}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new Nr(this.device,this.shaderInputs.modules);for(let[t,i]of Object.entries(this.shaderInputs.modules))if(gc(i)){let r=this._uniformStore.getManagedUniformBuffer(t);this.bindings[`${t}Uniforms`]=r}}setShaderModuleProps(e){let t=this._getModuleUniforms(e),i=Object.keys(t).filter(s=>{let o=t[s];return!ga(o)&&typeof o!="number"&&typeof o!="boolean"}),r={};for(let s of i)r[s]=t[s],delete t[s]}updateShaderInputs(e){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),e)}setBindings(e){Object.assign(this.bindings,e)}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate=this._pipelineNeedsUpdate||e}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null;this.pipeline&&(z.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.shader),this._pipelineNeedsUpdate=!1,this.shader=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"compute",source:this.source,debugShaders:this.props.debugShaders}),this.pipeline=this.pipelineFactory.createComputePipeline({...this.props,shader:this.shader}),e&&this.shaderFactory.release(e)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=z.level>3?0:QF;z.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:z.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=this.shaderInputs.getDebugTable();z.table(N_,e)(),z.groupEnd(N_)(),this._logOpen=!1}}_drawCount=0;_getBufferOrConstantValues(e,t){let i=Ke.getTypedArrayConstructor(t);return(e instanceof re?new i(e.debugData):e).toString()}}});var Ce=C(()=>{m1();v1();D_();G1();kf();I_();V1()});function r2(n=!0){let e=HTMLCanvasElement.prototype;if(!n&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(t,i){if(t==="webgl"||t==="experimental-webgl"){let r=this.originalGetContext("webgl2",i);return r instanceof HTMLElement&&A6(r),r}return this.originalGetContext(t,i)}}function A6(n){n.getExtension("EXT_color_buffer_float");let e={...C6,WEBGL_disjoint_timer_query:n.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:T6(n),OES_vertex_array_object:L6(n),ANGLE_instanced_arrays:M6(n)},t=n.getExtension.bind(n);n.getExtension=function(r){let s=t(r);return s||(r in e?e[r]:null)};let i=n.getSupportedExtensions;n.getSupportedExtensions=function(){return(i.apply(n)||[])?.concat(Object.keys(e))}}var C6,T6,L6,M6,s2=C(()=>{C6={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},T6=n=>({drawBuffersWEBGL(e){return n.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),L6=n=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return n.createVertexArray()},deleteVertexArrayOES(e){return n.deleteVertexArray(e)},isVertexArrayOES(e){return n.isVertexArray(e)},bindVertexArrayOES(e){return n.bindVertexArray(e)}}),M6=n=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return n.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return n.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return n.vertexAttribDivisor(...e)}})});async function a2(){if(!$f){q_();return}await $f.load()}function c2(n,e){return $f?$f.makeDebugContext(n,e):(q_(),n)}async function l2(n){if(!Y_){q_();return}await Y_.load(n)}function u2(n){return Y_?.initialize(n)||null}function q_(){o2||(o2=!0,z.warn("Import @luma.gl/webgl/debug before enabling WebGL debugging.")())}var $f,Y_,o2,Z_=C(()=>{ee();$f=null,Y_=null,o2=!1});function X_(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Re(n,e,t){return e[n]!==void 0?e[n]:t[n]}var Bc,ze,f2,It,d2,Ic,h2,p2,K_,Xn,Q_,m2,J_=C(()=>{Bc={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},ze=(n,e,t)=>e?n.enable(t):n.disable(t),f2=(n,e,t)=>n.hint(t,e),It=(n,e,t)=>n.pixelStorei(t,e),d2=(n,e,t)=>{let i=t===36006?36009:36008;return n.bindFramebuffer(i,e)},Ic=(n,e,t)=>{let r={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[t];n.bindBuffer(r,e)};h2={3042:ze,32773:(n,e)=>n.blendColor(...e),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(n,e)=>n.clearColor(...e),3107:(n,e)=>n.colorMask(...e),2884:ze,2885:(n,e)=>n.cullFace(e),2929:ze,2931:(n,e)=>n.clearDepth(e),2932:(n,e)=>n.depthFunc(e),2928:(n,e)=>n.depthRange(...e),2930:(n,e)=>n.depthMask(e),3024:ze,35723:f2,35725:(n,e)=>n.useProgram(e),36007:(n,e)=>n.bindRenderbuffer(36161,e),36389:(n,e)=>n.bindTransformFeedback?.(36386,e),34229:(n,e)=>n.bindVertexArray(e),36006:d2,36010:d2,34964:Ic,36662:Ic,36663:Ic,35053:Ic,35055:Ic,2886:(n,e)=>n.frontFace(e),33170:f2,2849:(n,e)=>n.lineWidth(e),32823:ze,32824:"polygonOffset",10752:"polygonOffset",35977:ze,32926:ze,32928:ze,32938:"sampleCoverage",32939:"sampleCoverage",3089:ze,3088:(n,e)=>n.scissor(...e),2960:ze,2961:(n,e)=>n.clearStencil(e),2968:(n,e)=>n.stencilMaskSeparate(1028,e),36005:(n,e)=>n.stencilMaskSeparate(1029,e),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(n,e)=>n.viewport(...e),34383:ze,10754:ze,12288:ze,12289:ze,12290:ze,12291:ze,12292:ze,12293:ze,12294:ze,12295:ze,3333:It,3317:It,37440:It,37441:It,37443:It,3330:It,3332:It,3331:It,3314:It,32878:It,3316:It,3315:It,32877:It,framebuffer:(n,e)=>{let t=e&&"handle"in e?e.handle:e;return n.bindFramebuffer(36160,t)},blend:(n,e)=>e?n.enable(3042):n.disable(3042),blendColor:(n,e)=>n.blendColor(...e),blendEquation:(n,e)=>{let t=typeof e=="number"?[e,e]:e;n.blendEquationSeparate(...t)},blendFunc:(n,e)=>{let t=e?.length===2?[...e,...e]:e;n.blendFuncSeparate(...t)},clearColor:(n,e)=>n.clearColor(...e),clearDepth:(n,e)=>n.clearDepth(e),clearStencil:(n,e)=>n.clearStencil(e),colorMask:(n,e)=>n.colorMask(...e),cull:(n,e)=>e?n.enable(2884):n.disable(2884),cullFace:(n,e)=>n.cullFace(e),depthTest:(n,e)=>e?n.enable(2929):n.disable(2929),depthFunc:(n,e)=>n.depthFunc(e),depthMask:(n,e)=>n.depthMask(e),depthRange:(n,e)=>n.depthRange(...e),dither:(n,e)=>e?n.enable(3024):n.disable(3024),derivativeHint:(n,e)=>{n.hint(35723,e)},frontFace:(n,e)=>n.frontFace(e),mipmapHint:(n,e)=>n.hint(33170,e),lineWidth:(n,e)=>n.lineWidth(e),polygonOffsetFill:(n,e)=>e?n.enable(32823):n.disable(32823),polygonOffset:(n,e)=>n.polygonOffset(...e),sampleCoverage:(n,e)=>n.sampleCoverage(e[0],e[1]||!1),scissorTest:(n,e)=>e?n.enable(3089):n.disable(3089),scissor:(n,e)=>n.scissor(...e),stencilTest:(n,e)=>e?n.enable(2960):n.disable(2960),stencilMask:(n,e)=>{e=X_(e)?e:[e,e];let[t,i]=e;n.stencilMaskSeparate(1028,t),n.stencilMaskSeparate(1029,i)},stencilFunc:(n,e)=>{e=X_(e)&&e.length===3?[...e,...e]:e;let[t,i,r,s,o,a]=e;n.stencilFuncSeparate(1028,t,i,r),n.stencilFuncSeparate(1029,s,o,a)},stencilOp:(n,e)=>{e=X_(e)&&e.length===3?[...e,...e]:e;let[t,i,r,s,o,a]=e;n.stencilOpSeparate(1028,t,i,r),n.stencilOpSeparate(1029,s,o,a)},viewport:(n,e)=>n.viewport(...e)};p2={blendEquation:(n,e,t)=>n.blendEquationSeparate(Re(32777,e,t),Re(34877,e,t)),blendFunc:(n,e,t)=>n.blendFuncSeparate(Re(32969,e,t),Re(32968,e,t),Re(32971,e,t),Re(32970,e,t)),polygonOffset:(n,e,t)=>n.polygonOffset(Re(32824,e,t),Re(10752,e,t)),sampleCoverage:(n,e,t)=>n.sampleCoverage(Re(32938,e,t),Re(32939,e,t)),stencilFuncFront:(n,e,t)=>n.stencilFuncSeparate(1028,Re(2962,e,t),Re(2967,e,t),Re(2963,e,t)),stencilFuncBack:(n,e,t)=>n.stencilFuncSeparate(1029,Re(34816,e,t),Re(36003,e,t),Re(36004,e,t)),stencilOpFront:(n,e,t)=>n.stencilOpSeparate(1028,Re(2964,e,t),Re(2965,e,t),Re(2966,e,t)),stencilOpBack:(n,e,t)=>n.stencilOpSeparate(1029,Re(34817,e,t),Re(34818,e,t),Re(34819,e,t))},K_={enable:(n,e)=>n({[e]:!0}),disable:(n,e)=>n({[e]:!1}),pixelStorei:(n,e,t)=>n({[e]:t}),hint:(n,e,t)=>n({[e]:t}),useProgram:(n,e)=>n({35725:e}),bindRenderbuffer:(n,e,t)=>n({36007:t}),bindTransformFeedback:(n,e,t)=>n({36389:t}),bindVertexArray:(n,e)=>n({34229:e}),bindFramebuffer:(n,e,t)=>{switch(e){case 36160:return n({36006:t,36010:t});case 36009:return n({36006:t});case 36008:return n({36010:t});default:return null}},bindBuffer:(n,e,t)=>{let i={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[e];return i?n({[i]:t}):{valueChanged:!0}},blendColor:(n,e,t,i,r)=>n({32773:new Float32Array([e,t,i,r])}),blendEquation:(n,e)=>n({32777:e,34877:e}),blendEquationSeparate:(n,e,t)=>n({32777:e,34877:t}),blendFunc:(n,e,t)=>n({32969:e,32968:t,32971:e,32970:t}),blendFuncSeparate:(n,e,t,i,r)=>n({32969:e,32968:t,32971:i,32970:r}),clearColor:(n,e,t,i,r)=>n({3106:new Float32Array([e,t,i,r])}),clearDepth:(n,e)=>n({2931:e}),clearStencil:(n,e)=>n({2961:e}),colorMask:(n,e,t,i,r)=>n({3107:[e,t,i,r]}),cullFace:(n,e)=>n({2885:e}),depthFunc:(n,e)=>n({2932:e}),depthRange:(n,e,t)=>n({2928:new Float32Array([e,t])}),depthMask:(n,e)=>n({2930:e}),frontFace:(n,e)=>n({2886:e}),lineWidth:(n,e)=>n({2849:e}),polygonOffset:(n,e,t)=>n({32824:e,10752:t}),sampleCoverage:(n,e,t)=>n({32938:e,32939:t}),scissor:(n,e,t,i,r)=>n({3088:new Int32Array([e,t,i,r])}),stencilMask:(n,e)=>n({2968:e,36005:e}),stencilMaskSeparate:(n,e,t)=>n({[e===1028?2968:36005]:t}),stencilFunc:(n,e,t,i)=>n({2962:e,2967:t,2963:i,34816:e,36003:t,36004:i}),stencilFuncSeparate:(n,e,t,i,r)=>n({[e===1028?2962:34816]:t,[e===1028?2967:36003]:i,[e===1028?2963:36004]:r}),stencilOp:(n,e,t,i)=>n({2964:e,2965:t,2966:i,34817:e,34818:t,34819:i}),stencilOpSeparate:(n,e,t,i,r)=>n({[e===1028?2964:34817]:t,[e===1028?2965:34818]:i,[e===1028?2966:34819]:r}),viewport:(n,e,t,i,r)=>n({2978:[e,t,i,r]})},Xn=(n,e)=>n.isEnabled(e),Q_={3042:Xn,2884:Xn,2929:Xn,3024:Xn,32823:Xn,32926:Xn,32928:Xn,3089:Xn,2960:Xn,35977:Xn},m2=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068])});function gn(n,e){if(k6(e))return;let t={};for(let r in e){let s=Number(r),o=h2[r];o&&(typeof o=="string"?t[o]=!0:o(n,e[r],s))}let i=n.lumaState?.cache;if(i)for(let r in t){let s=p2[r];s(n,e,i)}}function Gf(n,e=Bc){if(typeof e=="number"){let r=e,s=Q_[r];return s?s(n,r):n.getParameter(r)}let t=Array.isArray(e)?e:Object.keys(e),i={};for(let r of t){let s=Q_[r];i[r]=s?s(n,Number(r)):n.getParameter(Number(r))}return i}function g2(n){gn(n,Bc)}function k6(n){for(let e in n)return!1;return!0}var Po=C(()=>{J_()});function y2(n,e){if(n===e)return!0;if(_2(n)&&_2(e)&&n.length===e.length){for(let t=0;t{});function v2(n,e){let t=n[e].bind(n);n[e]=function(r){if(r===void 0||m2.has(r))return t(r);let s=_n.get(n);return r in s.cache||(s.cache[r]=t(r)),s.enable?s.cache[r]:t(r)},Object.defineProperty(n[e],"name",{value:`${e}-from-cache`,configurable:!1})}function R6(n,e,t){if(!n[e])return;let i=n[e].bind(n);n[e]=function(...s){let o=_n.get(n),{valueChanged:a,oldValue:c}=t(o._updateCache,...s);return a&&i(...s),c},Object.defineProperty(n[e],"name",{value:`${e}-to-cache`,configurable:!1})}function I6(n){let e=n.useProgram.bind(n);n.useProgram=function(i){let r=_n.get(n);r.program!==i&&(e(i),r.program=i)}}var _n,ey=C(()=>{Po();b2();J_();_n=class{static get(e){return e.lumaState}gl;program=null;stateStack=[];enable=!0;cache=null;log;initialized=!1;constructor(e,t){this.gl=e,this.log=t?.log||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){let e=this.stateStack[this.stateStack.length-1];gn(this.gl,e),this.stateStack.pop()}trackState(e,t){if(this.cache=t?.copyState?Gf(e):Object.assign({},Bc),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.lumaState=this,I6(e);for(let i in K_){let r=K_[i];R6(e,i,r)}v2(e,"getParameter"),v2(e,"isEnabled")}_updateCache(e){let t=!1,i,r=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let s in e){let o=e[s],a=this.cache[s];y2(o,a)||(t=!0,i=a,r&&!(s in r)&&(r[s]=a),this.cache[s]=o)}return{valueChanged:t,oldValue:i}}}});function Oc(n){let e=n.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return e._polyfilled??=!1,e.extensions||={},n.luma=e,e}var ty=C(()=>{});function x2(n,e,t){let i="",r=c=>{let l=c.statusMessage;l&&(i||=l)};n.addEventListener("webglcontextcreationerror",r,!1);let s=t.failIfMajorPerformanceCaveat!==!0,o={preserveDrawingBuffer:!0,...t,failIfMajorPerformanceCaveat:!0},a=null;try{a||=n.getContext("webgl2",o),!a&&o.failIfMajorPerformanceCaveat&&(i||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.");let c=!1;if(!a&&s&&(o.failIfMajorPerformanceCaveat=!1,a=n.getContext("webgl2",o),c=!0),a||(a=n.getContext("webgl",{}),a&&(a=null,i||="Your browser only supports WebGL1")),!a)throw i||="Your browser does not support WebGL",new Error(`Failed to create WebGL context: ${i}`);let l=Oc(a);l.softwareRenderer=c;let{onContextLost:u,onContextRestored:f}=e;return n.addEventListener("webglcontextlost",d=>u(d),!1),n.addEventListener("webglcontextrestored",d=>f(d),!1),a}finally{n.removeEventListener("webglcontextcreationerror",r,!1)}}var w2=C(()=>{ty()});function yn(n,e,t){return t[e]===void 0&&(t[e]=n.getExtension(e)||null),t[e]}var Dc=C(()=>{});function E2(n,e){let t=n.getParameter(7936),i=n.getParameter(7937);yn(n,"WEBGL_debug_renderer_info",e);let r=e.WEBGL_debug_renderer_info,s=n.getParameter(r?r.UNMASKED_VENDOR_WEBGL:7936),o=n.getParameter(r?r.UNMASKED_RENDERER_WEBGL:7937),a=s||t,c=o||i,l=n.getParameter(7938),u=S2(a,c),f=B6(a,c),d=O6(a,c);return{type:"webgl",gpu:u,gpuType:d,gpuBackend:f,vendor:a,renderer:c,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function S2(n,e){return/NVIDIA/i.exec(n)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(n)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(n)||/Apple/i.exec(e)?"apple":/AMD/i.exec(n)||/AMD/i.exec(e)||/ATI/i.exec(n)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(n)||/SwiftShader/i.exec(e)?"software":"unknown"}function B6(n,e){return/Metal/i.exec(n)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(n)||/ANGLE/i.exec(e)?"opengl":"unknown"}function O6(n,e){if(/SwiftShader/i.exec(n)||/SwiftShader/i.exec(e))return"cpu";switch(S2(n,e)){case"apple":return D6(n,e)?"integrated":"unknown";case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function D6(n,e){return/Apple (M\d|A\d|GPU)/i.test(`${n} ${e}`)}var P2=C(()=>{Dc()});function Vf(n){switch(n){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(n))}var ny=C(()=>{});function L2(n){return n in jf}function ay(n,e,t){return M2(n,e,t,new Set)}function M2(n,e,t,i){let r=jf[e];if(!r||i.has(e))return!1;i.add(e);let s=(r.features||[]).every(o=>M2(n,o,t,i));return i.delete(e),s?(r.extensions||[]).every(o=>!!yn(n,o,t)):!1}function A2(n,e,t){let i=e.create,r=Hf[e.format];r?.gl===void 0&&(i=!1),r?.x&&(i=i&&!!yn(n,r.x,t)),e.format==="stencil8"&&(i=!1);let s=r?.r===!1?!1:r?.r===void 0||ay(n,r.r,t),o=i&&e.render&&s&&W6(n,e.format,t);return{format:e.format,create:i&&e.create,render:o,filter:i&&e.filter,blend:i&&e.blend,store:i&&e.store}}function W6(n,e,t){let i=Hf[e],r=i?.gl;if(r===void 0||i?.x&&!yn(n,i.x,t))return!1;let s=n.getParameter(32873),o=n.getParameter(36006),a=n.createTexture(),c=n.createFramebuffer();if(!a||!c)return!1;let l=0,u=Number(n.getError());for(;u!==l;)u=n.getError();let f=!1;try{if(n.bindTexture(3553,a),n.texStorage2D(3553,1,r,1,1),Number(n.getError())!==l)return!1;n.bindFramebuffer(36160,c),n.framebufferTexture2D(36160,36064,3553,a,0),f=Number(n.checkFramebufferStatus(36160))===36053&&Number(n.getError())===l}finally{n.bindFramebuffer(36160,o),n.deleteFramebuffer(c),n.bindTexture(3553,s),n.deleteTexture(a)}return f}function Yf(n){let e=Hf[n],t=H6(n),i=ft.getInfo(n);return i.compressed&&(e.dataFormat=t),{internalFormat:t,format:e?.dataFormat||j6(i.channels,i.integer,i.normalized,t),type:i.dataType?Vf(i.dataType):e?.types?.[0]||5121,compressed:i.compressed||!1}}function k2(n){switch(ft.getInfo(n).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${n}`)}}function j6(n,e,t,i){if(i===6408||i===6407)return i;switch(n){case"r":return e&&!t?36244:6403;case"rg":return e&&!t?33320:33319;case"rgb":return e&&!t?36248:6407;case"rgba":return e&&!t?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function H6(n){let t=Hf[n]?.gl;if(t===void 0)throw new Error(`Unsupported texture format ${n}`);return t}var Nc,Fc,Co,To,N6,F6,z6,U6,$6,G6,C2,T2,iy,ry,sy,oy,Wf,V6,jf,Hf,Lo=C(()=>{ee();Dc();ny();Nc="WEBGL_compressed_texture_s3tc",Fc="WEBGL_compressed_texture_s3tc_srgb",Co="EXT_texture_compression_rgtc",To="EXT_texture_compression_bptc",N6="WEBGL_compressed_texture_etc",F6="WEBGL_compressed_texture_astc",z6="WEBGL_compressed_texture_etc1",U6="WEBGL_compressed_texture_pvrtc",$6="WEBGL_compressed_texture_atc",G6="EXT_texture_norm16",C2="EXT_render_snorm",T2="EXT_color_buffer_float",iy="snorm8-renderable-webgl",ry="norm16-renderable-webgl",sy="snorm16-renderable-webgl",oy="float16-renderable-webgl",Wf="float32-renderable-webgl",V6="rgb9e5ufloat-renderable-webgl",jf={"float32-renderable-webgl":{extensions:[T2]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[C2]},"norm16-webgl":{extensions:[G6]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[C2]},"float32-filterable":{extensions:["OES_texture_float_linear"]},"float16-filterable-webgl":{extensions:["OES_texture_half_float_linear"]},"texture-filterable-anisotropic-webgl":{extensions:["EXT_texture_filter_anisotropic"]},"texture-blend-float-webgl":{extensions:["EXT_float_blend"]},"texture-compression-bc":{extensions:[Nc,Fc,Co,To]},"texture-compression-bc5-webgl":{extensions:[Co]},"texture-compression-bc7-webgl":{extensions:[To]},"texture-compression-etc2":{extensions:[N6]},"texture-compression-astc":{extensions:[F6]},"texture-compression-etc1-webgl":{extensions:[z6]},"texture-compression-pvrtc-webgl":{extensions:[U6]},"texture-compression-atc-webgl":{extensions:[$6]}};Hf={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:iy},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:iy},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0,r:oy},r16unorm:{gl:33322,rb:!0,r:ry},r16snorm:{gl:36760,r:sy},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759,r:iy},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:oy},rg16unorm:{gl:33324,r:ry},rg16snorm:{gl:36761,r:sy},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:Wf},rgb9e5ufloat:{gl:35901,r:V6},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852,r:!1},"rgb16snorm-webgl":{gl:36762,r:!1},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0,r:Wf},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:oy},rgba16unorm:{gl:32859,rb:!0,r:ry},rgba16snorm:{gl:36763,r:sy},"rgb32float-webgl":{gl:34837,x:T2,r:Wf,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:Wf},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:Nc},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:Fc},"bc1-rgba-unorm":{gl:33777,x:Nc},"bc1-rgba-unorm-srgb":{gl:35916,x:Fc},"bc2-rgba-unorm":{gl:33778,x:Nc},"bc2-rgba-unorm-srgb":{gl:35918,x:Fc},"bc3-rgba-unorm":{gl:33779,x:Nc},"bc3-rgba-unorm-srgb":{gl:35919,x:Fc},"bc4-r-unorm":{gl:36283,x:Co},"bc4-r-snorm":{gl:36284,x:Co},"bc5-rg-unorm":{gl:36285,x:Co},"bc5-rg-snorm":{gl:36286,x:Co},"bc6h-rgb-ufloat":{gl:36495,x:To},"bc6h-rgb-float":{gl:36494,x:To},"bc7-rgba-unorm":{gl:36492,x:To},"bc7-rgba-unorm-srgb":{gl:36493,x:To},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37816},"astc-10x5-unorm-srgb":{gl:37848},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rgb2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}}});var R2,qf,I2=C(()=>{ee();Dc();Lo();R2={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","html-in-canvas":n=>Bm()&&typeof n.texElementImage2D=="function","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},qf=class extends Ca{gl;extensions;testedFeatures=new Set;constructor(e,t,i){super([],i),this.gl=e,this.extensions=t,yn(e,"EXT_color_buffer_float",t)}*[Symbol.iterator](){let e=this.getFeatures();for(let t of e)this.has(t)&&(yield t);return[]}has(e){return this.disabledFeatures?.[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),L2(e)&&ay(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){let e=this.getFeatures().filter(t=>t!=="polygon-mode-webgl");for(let t of e)this.has(t)}getFeatures(){return[...Object.keys(R2),...Object.keys(jf)]}getWebGLFeature(e){let t=R2[e];return typeof t=="string"?!!yn(this.gl,t,this.extensions):typeof t=="function"?t(this.gl):!!t}}});var Zf,B2=C(()=>{ee();Zf=class extends Pa{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxBindGroupsPlusVertexBuffers(){return 0}get maxBindingsPerBindGroup(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageBuffersInVertexStage(){return 0}get maxStorageBuffersInFragmentStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxStorageTexturesInVertexStage(){return 0}get maxStorageTexturesInFragmentStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get maxBufferSize(){return Number.MAX_SAFE_INTEGER}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxColorAttachments(){return this.getParameter(36063)}get maxColorAttachmentBytesPerSample(){return 0}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]||0}}});function Y6(n){return n<34069?n+34069:n}function q6(n){switch(n){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${n}`}}var Kn,Xf=C(()=>{ee();Lo();Kn=class extends Rr{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(e,t){super(e,t);let i=t.handle,r=i===null;this.device=e,this.gl=e.gl,this.handle=i||r?i:this.gl.createFramebuffer(),r||(e._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),t.handle||(this.autoCreateAttachmentTextures(),this.updateAttachments()))}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&!this.props.handle&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){let e=this.gl.bindFramebuffer(36160,this.handle);for(let t=0;t{ee();Xf();Kf=class extends Ta{device;handle=null;_framebuffer=null;get[Symbol.toStringTag](){return"WebGLCanvasContext"}constructor(e,t){super(t),this.device=e,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._configureDevice()}_configureDevice(){(this.drawingBufferWidth!==this._framebuffer?.width||this.drawingBufferHeight!==this._framebuffer?.height)&&this._framebuffer?.resize([this.drawingBufferWidth,this.drawingBufferHeight])}_getCurrentFramebuffer(){return this._framebuffer||=new Kn(this.device,{id:"canvas-context-framebuffer",handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}}});var Qf,D2=C(()=>{ee();Qf=class extends La{device;handle=null;context2d;get[Symbol.toStringTag](){return"WebGLPresentationContext"}constructor(e,t={}){super(t),this.device=e;let i=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw new Error(`${i}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);let s=this.canvas.getContext("2d");if(!s)throw new Error(`${i}: Failed to create 2d presentation context`);this.context2d=s,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();let e=this.device.getDefaultCanvasContext(),[t,i]=e.getDrawingBufferSize();if(!(this.drawingBufferWidth===0||this.drawingBufferHeight===0||t===0||i===0||e.canvas.width===0||e.canvas.height===0)){if(t!==this.drawingBufferWidth||i!==this.drawingBufferHeight||e.canvas.width!==this.drawingBufferWidth||e.canvas.height!==this.drawingBufferHeight)throw new Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${t}x${i} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(e.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(e){let t=this.device.getDefaultCanvasContext();return t.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),t.getCurrentFramebuffer(e)}}});function N2(n="id"){cy[n]=cy[n]||1;let e=cy[n]++;return`${n}-${e}`}var cy,F2=C(()=>{cy={}});function Z6(n){return n&re.INDEX?34963:n&re.VERTEX?34962:n&re.UNIFORM?35345:34962}function X6(n){return n&re.INDEX||n&re.VERTEX?35044:n&re.UNIFORM?35048:35044}var bn,Jf=C(()=>{ee();bn=class extends re{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength=0;bytesUsed=0;constructor(e,t={}){super(e,t),this.device=e,this.gl=this.device.gl;let i=typeof t=="object"?t.handle:void 0;this.handle=i||this.gl.createBuffer(),e._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=Z6(this.props.usage),this.glUsage=X6(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,t.data?this._initWithData(t.data,t.byteOffset,t.byteLength):this._initWithByteLength(t.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Buffer"):(this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle)),this.destroyed=!0,this.handle=null)}_initWithData(e,t=0,i=e.byteLength+t){let r=this.glTarget;this.gl.bindBuffer(r,this.handle),this.gl.bufferData(r,i,this.glUsage),this.gl.bufferSubData(r,t,e),this.gl.bindBuffer(r,null),this.bytesUsed=i,this.byteLength=i,this._setDebugData(e,t,i),this.props.handle?this.trackReferencedMemory(i,"Buffer"):this.trackAllocatedMemory(i)}_initWithByteLength(e){let t=e;e===0&&(t=new Float32Array(0));let i=this.glTarget;return this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,t,this.glUsage),this.gl.bindBuffer(i,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.props.handle?this.trackReferencedMemory(e,"Buffer"):this.trackAllocatedMemory(e),this}write(e,t=0){let i=ArrayBuffer.isView(e)?e:new Uint8Array(e),r=0,s=void 0,o=36663;this.gl.bindBuffer(o,this.handle),r!==0||s!==void 0?this.gl.bufferSubData(o,t,i,r,s):this.gl.bufferSubData(o,t,i),this.gl.bindBuffer(o,null),this._setDebugData(e,t,e.byteLength)}async mapAndWriteAsync(e,t=0,i=this.byteLength-t){let r=new ArrayBuffer(i);await e(r,"copied"),this.write(r,t)}async readAsync(e=0,t){return this.readSyncWebGL(e,t)}async mapAndReadAsync(e,t=0,i){let r=await this.readAsync(t,i);return await e(r.buffer,"copied")}readSyncWebGL(e=0,t){t=t??this.byteLength-e;let i=new Uint8Array(t),r=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,i,r,t),this.gl.bindBuffer(36662,null),this._setDebugData(i,e,t),i}}});function z2(n){let e=n.split(/\r?\n/),t=[];for(let i of e){if(i.length<=1)continue;let r=i.trim(),s=i.split(":"),o=s[0]?.trim();if(s.length===2){let[h,p]=s;if(!h||!p){t.push({message:r,type:ed(o||"info"),lineNum:0,linePos:0});continue}t.push({message:p.trim(),type:ed(h),lineNum:0,linePos:0});continue}let[a,c,l,...u]=s;if(!a||!c||!l){t.push({message:s.slice(1).join(":").trim()||r,type:ed(o||"info"),lineNum:0,linePos:0});continue}let f=parseInt(l,10);Number.isNaN(f)&&(f=0);let d=parseInt(c,10);Number.isNaN(d)&&(d=0),t.push({message:u.join(":").trim(),type:ed(a),lineNum:f,linePos:d})}return t}function ed(n){let e=["warning","error","info"],t=n.toLowerCase();return e.includes(t)?t:"info"}var U2=C(()=>{});function K6(n){return n.split(/\r?\n/).find(e=>e.trim())?.trim()}var td,$2=C(()=>{ee();U2();td=class extends kr{device;handle;_compilationInfoLog="";constructor(e,t){super(e,t),this.device=e;let i=this.props.handle;switch(this.props.stage){case"vertex":this.handle=i||this.device.gl.createShader(35633);break;case"fragment":this.handle=i||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}e._setWebGLDebugMetadata(this.handle,this,{spector:this.props});let r=this._compile(this.source);r&&typeof r.catch=="function"&&r.catch(()=>{this.compilationStatus="error"})}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this._getCompilationInfoLog();return e?z2(e):[]}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)||null}_compile(e){e=e.startsWith("#version ")?e:`#version 300 es -${e}`;let{gl:t}=this.device;if(t.shaderSource(this.handle,e),t.compileShader(this.handle),!this.device.props.debug){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus==="error")throw new Error(this._getCompilationErrorMessage(e));return}return z.once(1,"Shader compilation is asynchronous")(),this._waitForCompilationComplete().then(()=>{z.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()})}async _waitForCompilationComplete(){let e=async r=>await new Promise(s=>setTimeout(s,r));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error",this.compilationStatus==="error"&&this._getCompilationInfoLog()}_getCompilationErrorMessage(e){let t=`${this.props.stage} shader ${this.props.id}`,i=K6(this._getCompilationInfoLog()),r=this.getCompilationInfoSync(),s=r.find(u=>u.type==="error"&&u.message.trim())||r.find(u=>u.message.trim())||r.find(u=>u.type==="error")||r[0];if(!s)return i?`GLSL compilation errors in ${t}: ${i}`:`GLSL compilation errors in ${t}: WebGL did not provide a shader compiler log`;let o=s.lineNum?e.split(/\r?\n/)[s.lineNum-1]?.trim():void 0,a=s.lineNum?` line ${s.lineNum}`:"",c=o?` -Source: ${o}`:"",l=s.message.trim()||i||"WebGL did not provide a shader compiler log";return`GLSL compilation errors in ${t}:${a}: ${l}${c}`}_getCompilationInfoLog(){let e=this.device.gl.getShaderInfoLog(this.handle)?.trim();return e&&(this._compilationInfoLog=e),this._compilationInfoLog}}});function V2(n,e,t,i){if(tz(e))return i(n);let r=n;r.pushState();try{return Q6(n,e),gn(r.gl,t),i(n)}finally{r.popState()}}function Q6(n,e){let t=n,{gl:i}=t;if(e.cullMode)switch(e.cullMode){case"none":i.disable(2884);break;case"front":i.enable(2884),i.cullFace(1028);break;case"back":i.enable(2884),i.cullFace(1029);break}if(e.frontFace&&i.frontFace(ss("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&n.features.has("depth-clip-control")&&i.enable(34383),e.depthBias!==void 0&&(i.enable(32823),i.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&n.features.has("provoking-vertex-webgl")){let s=t.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,o=ss("provokingVertex",e.provokingVertex,{first:36429,last:36430});s?.provokingVertexWEBGL(o)}if((e.polygonMode||e.polygonOffsetLine)&&n.features.has("polygon-mode-webgl")){if(e.polygonMode){let s=t.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,o=ss("polygonMode",e.polygonMode,{fill:6914,line:6913});s?.polygonModeWEBGL(1028,o),s?.polygonModeWEBGL(1029,o)}e.polygonOffsetLine&&i.enable(10754)}if(n.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&i.enable(12288),e.clipDistance1&&i.enable(12289),e.clipDistance2&&i.enable(12290),e.clipDistance3&&i.enable(12291),e.clipDistance4&&i.enable(12292),e.clipDistance5&&i.enable(12293),e.clipDistance6&&i.enable(12294),e.clipDistance7&&i.enable(12295)),e.depthWriteEnabled!==void 0&&i.depthMask(ez("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?i.enable(2929):i.disable(2929),i.depthFunc(id("depthCompare",e.depthCompare))),e.clearDepth!==void 0&&i.clearDepth(e.clearDepth),e.stencilWriteMask){let r=e.stencilWriteMask;i.stencilMaskSeparate(1028,r),i.stencilMaskSeparate(1029,r)}if(e.stencilReadMask&&z.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){let r=e.stencilReadMask||4294967295,s=id("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?i.enable(2960):i.disable(2960),i.stencilFuncSeparate(1028,s,0,r),i.stencilFuncSeparate(1029,s,0,r)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){let r=ly("stencilPassOperation",e.stencilPassOperation),s=ly("stencilFailOperation",e.stencilFailOperation),o=ly("stencilDepthFailOperation",e.stencilDepthFailOperation);i.stencilOpSeparate(1028,s,o,r),i.stencilOpSeparate(1029,s,o,r)}switch(e.blend){case!0:i.enable(3042);break;case!1:i.disable(3042);break;default:}if(e.blendColorOperation||e.blendAlphaOperation){let r=G2("blendColorOperation",e.blendColorOperation||"add"),s=G2("blendAlphaOperation",e.blendAlphaOperation||"add");i.blendEquationSeparate(r,s);let o=nd("blendColorSrcFactor",e.blendColorSrcFactor||"one"),a=nd("blendColorDstFactor",e.blendColorDstFactor||"zero"),c=nd("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),l=nd("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");i.blendFuncSeparate(o,a,c,l)}}function id(n,e){return ss(n,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function ly(n,e){return ss(n,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function G2(n,e){return ss(n,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function nd(n,e,t="color"){return ss(n,e,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:t==="color"?32769:32771,"one-minus-constant":t==="color"?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function J6(n,e){return`Illegal parameter ${e} for ${n}`}function ss(n,e,t){if(!(e in t))throw new Error(J6(n,e));return t[e]}function ez(n,e){return e}function tz(n){let e=!0;for(let t in n){e=!1;break}return e}var uy=C(()=>{ee();Po()});function rd(n){let e={};return n.addressModeU&&(e[10242]=fy(n.addressModeU)),n.addressModeV&&(e[10243]=fy(n.addressModeV)),n.addressModeW&&(e[32882]=fy(n.addressModeW)),n.magFilter&&(e[10240]=dy(n.magFilter)),(n.minFilter||n.mipmapFilter)&&(e[10241]=nz(n.minFilter||"linear",n.mipmapFilter)),n.lodMinClamp!==void 0&&(e[33082]=n.lodMinClamp),n.lodMaxClamp!==void 0&&(e[33083]=n.lodMaxClamp),n.type==="comparison-sampler"&&(e[34892]=34894),n.compare&&(e[34893]=id("compare",n.compare)),n.maxAnisotropy&&(e[34046]=n.maxAnisotropy),e}function fy(n){switch(n){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function dy(n){switch(n){case"nearest":return 9728;case"linear":return 9729}}function nz(n,e="none"){if(!e)return dy(n);switch(e){case"none":return dy(n);case"nearest":switch(n){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(n){case"nearest":return 9986;case"linear":return 9987}}}var hy=C(()=>{uy()});var sd,W2=C(()=>{ee();hy();sd=class extends Mr{device;handle;parameters;constructor(e,t){super(e,t),this.device=e,this.parameters=rd(t),this.handle=t.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(let[t,i]of Object.entries(e)){let r=Number(t);switch(r){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,r,i);break;default:this.device.gl.samplerParameteri(this.handle,r,i);break}}}}});function vn(n,e,t){if(iz(e))return t(n);let{nocatch:i=!0}=e,r=_n.get(n);r.push(),gn(n,e);let s;if(i)s=t(n),r.pop();else try{s=t(n)}finally{r.pop()}return s}function iz(n){for(let e in n)return!1;return!0}var od=C(()=>{Po();ey()});var Qn,py=C(()=>{ee();Qn=class extends Ar{device;gl;handle;texture;constructor(e,t){super(e,{...pe.defaultProps,...t}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=t.texture}}});function ad(n){return rz[n]}var rz,my=C(()=>{rz={5124:"sint32",5125:"uint32",5122:"sint16",5123:"uint16",5120:"sint8",5121:"uint8",5126:"float32",5131:"float16",33635:"uint16",32819:"uint16",32820:"uint16",33640:"uint32",35899:"uint32",35902:"uint32",34042:"uint32",36269:"uint32"}});function sz(n,e=0){return e?new n.constructor(n.buffer,n.byteOffset+e,(n.byteLength-e)/n.BYTES_PER_ELEMENT):n}function oz(n,e){if(e%n.BYTES_PER_ELEMENT!==0)throw new Error(`Texture byteOffset ${e} must align to typed array element size ${n.BYTES_PER_ELEMENT}`);return e/n.BYTES_PER_ELEMENT}function az(n){switch(n){case"1d":break;case"2d":return 3553;case"3d":return 32879;case"cube":return 34067;case"2d-array":return 35866;case"cube-array":break}throw new Error(n)}function zc(n,e,t){return e==="cube"?34069+t:n}var Jn,cd=C(()=>{ee();Lo();hy();od();py();my();Jn=class extends pe{device;gl;handle;sampler=void 0;view;glTarget;glFormat;glType;glInternalFormat;compressed;_textureUnit=0;_framebuffer=null;_framebufferAttachmentKey=null;constructor(e,t){super(e,t,{byteAlignment:1}),this.device=e,this.gl=this.device.gl;let i=Yf(this.props.format);if(this.glTarget=az(this.props.dimension),this.glInternalFormat=i.internalFormat,this.glFormat=i.format,this.glType=i.type,this.compressed=i.compressed,this.isHandleBorrowed&&this.props.handle===void 0)throw new Error("Borrowed WebGL textures require a texture handle");if(this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),!this.isHandleBorrowed){this.gl.bindTexture(this.glTarget,this.handle);let{dimension:r,width:s,height:o,depth:a,mipLevels:c,glTarget:l,glInternalFormat:u}=this;if(!this.compressed)switch(r){case"2d":case"cube":this.gl.texStorage2D(l,c,u,s,o);break;case"2d-array":case"3d":this.gl.texStorage3D(l,c,u,s,o,a);break;default:throw new Error(r)}this.gl.bindTexture(this.glTarget,null),this._initializeData(t.data)}this.ownsHandle?this.trackAllocatedMemory(this.getAllocatedByteLength(),"Texture"):this.trackReferencedMemory(this.getAllocatedByteLength(),"Texture"),this.isHandleBorrowed||this.setSampler(this.props.sampler),this.view=new Qn(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this._framebuffer?.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.ownsHandle?(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory("Texture")):this.trackDeallocatedReferencedMemory("Texture"),this.destroyed=!0)}createView(e){return new Qn(this.device,{...e,texture:this})}clone(e){if(this.isHandleBorrowed&&e&&(e.width!==this.width||e.height!==this.height))throw new Error(`Cannot resize borrowed read-only ${this}`);return super.clone(e)}setSampler(e={}){this._assertWritable("set sampler parameters on"),super.setSampler(e);let t=rd(this.sampler.props);this._setSamplerParameters(t)}copyExternalImage(e){this._assertWritable("copy external image data into");let t=this._normalizeCopyExternalImageOptions(e);if(t.sourceX||t.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");let{glFormat:i,glType:r}=this,{image:s,depth:o,mipLevel:a,x:c,y:l,z:u,width:f,height:d}=t,h=zc(this.glTarget,this.dimension,u),p=t.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),vn(this.gl,p,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(h,a,c,l,f,d,i,r,s);break;case"2d-array":case"3d":this.gl.texSubImage3D(h,a,c,l,u,f,d,o,i,r,s);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:t.width,height:t.height}}copyElementImage(e){this._assertWritable("copy element image data into");let t=this._normalizeCopyElementImageOptions(e),{glFormat:i}=this,{element:r,depth:s,mipLevel:o,sourceX:a,sourceY:c,sourceWidth:l,sourceHeight:u,x:f,y:d,z:h,width:p,height:m}=t,g=zc(this.glTarget,this.dimension,h),v=t.flipY?{37440:!0}:{},y=this.gl;if(s!==1||this.dimension!=="2d"&&this.dimension!=="cube")throw new Error(`${this} copyElementImage only supports 2d and cube textures on WebGL`);if(o!==0||f!==0||d!==0)throw new Error(`${this} copyElementImage only supports full base-level uploads on WebGL`);if(typeof y.texElementImage2D!="function")throw new Error(`${this} copyElementImage is not supported by this WebGL implementation`);return this.gl.bindTexture(this.glTarget,this.handle),vn(this.gl,v,()=>{y.texElementImage2D?.(g,i,r,{sx:a,sy:c,swidth:l??p,sheight:u??m,width:p,height:m})}),this.gl.bindTexture(this.glTarget,null),{width:t.width,height:t.height}}copyImageData(e){super.copyImageData(e)}readBuffer(e={},t){if(!t)throw new Error(`${this} readBuffer requires a destination buffer`);let i=this._getSupportedColorReadOptions(e),r=e.byteOffset??0,s=this.computeMemoryLayout(i);if(t.byteLength{this.gl.readPixels(i.x,i.y,i.width,i.height,this.glFormat,this.glType,r+a)})}finally{this.gl.bindBuffer(35051,null)}return t}async readDataAsync(e={}){throw new Error(`${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`)}writeBuffer(e,t={}){this._assertWritable("write buffer data into");let i=this._normalizeTextureWriteOptions(t),{width:r,height:s,depthOrArrayLayers:o,mipLevel:a,byteOffset:c,x:l,y:u,z:f}=i,{glFormat:d,glType:h,compressed:p}=this,m=zc(this.glTarget,this.dimension,f);if(p)throw new Error("writeBuffer for compressed textures is not implemented in WebGL");let{bytesPerPixel:g}=this.device.getTextureFormatInfo(this.format),v=g?i.bytesPerRow/g:void 0,y={3317:this.byteAlignment,...v!==void 0?{3314:v}:{},32878:i.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,e.handle),vn(this.gl,y,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(m,a,l,u,r,s,d,h,c);break;case"2d-array":case"3d":this.gl.texSubImage3D(m,a,l,u,f,r,s,o,d,h,c);break;default:}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(e,t={}){this._assertWritable("write data into");let i=this._normalizeTextureWriteOptions(t),r=ArrayBuffer.isView(e)?e:new Uint8Array(e),{width:s,height:o,depthOrArrayLayers:a,mipLevel:c,x:l,y:u,z:f,byteOffset:d}=i,{glFormat:h,glType:p,compressed:m}=this,g=zc(this.glTarget,this.dimension,f),v;if(!m){let{bytesPerPixel:T}=this.device.getTextureFormatInfo(this.format);T&&(v=i.bytesPerRow/T)}let y=this.compressed?{}:{3317:this.byteAlignment,...v!==void 0?{3314:v}:{},32878:i.rowsPerImage},b=oz(r,d),w=m?sz(r,d):r,E=this._getMipLevelSize(c),x=l===0&&u===0&&f===0&&s===E.width&&o===E.height&&a===E.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),vn(this.gl,y,()=>{switch(this.dimension){case"2d":case"cube":m?x?this.gl.compressedTexImage2D(g,c,h,s,o,0,w):this.gl.compressedTexSubImage2D(g,c,l,u,s,o,h,w):this.gl.texSubImage2D(g,c,l,u,s,o,h,p,r,b);break;case"2d-array":case"3d":m?x?this.gl.compressedTexImage3D(g,c,h,s,o,a,0,w):this.gl.compressedTexSubImage3D(g,c,l,u,f,s,o,a,h,w):this.gl.texSubImage3D(g,c,l,u,f,s,o,a,h,p,r,b);break;default:}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(e,t){return 1}_getFramebuffer(){return this._framebuffer||=this.device.createFramebuffer({id:`framebuffer-for-${this.id}`,width:this.width,height:this.height,colorAttachments:[this]}),this._framebuffer}readDataSyncWebGL(e={}){let t=this._getSupportedColorReadOptions(e),i=this.computeMemoryLayout(t),r=ad(this.glType),s=Lr(r),o=new s(i.byteLength/s.BYTES_PER_ELEMENT);return this._readColorTextureLayers(t,i,a=>{let c=new s(o.buffer,o.byteOffset+a,i.bytesPerImage/s.BYTES_PER_ELEMENT);this.gl.readPixels(t.x,t.y,t.width,t.height,this.glFormat,this.glType,c)}),o.buffer}_readColorTextureLayers(e,t,i){let r=this._getFramebuffer(),s=t.bytesPerRow/t.bytesPerPixel,o={3333:this.byteAlignment,...s!==e.width?{3330:s}:{}},a=this.gl.getParameter(3074),c=this.gl.bindFramebuffer(36160,r.handle);try{this.gl.readBuffer(36064),vn(this.gl,o,()=>{for(let l=0;l=2&&z.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(e))(),this.gl.bindTexture(this.glTarget,this.handle);for(let[t,i]of Object.entries(e)){let r=Number(t),s=i;switch(r){case 33082:case 33083:this.gl.texParameterf(this.glTarget,r,s);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,r,s);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,r,s);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,r,s);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,r,s);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(e){let{gl:t}=this;return e!==void 0&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,this.handle),e}_unbind(e){let{gl:t}=this;return e!==void 0&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,null),e}_assertWritable(e){if(this.isHandleBorrowed)throw new Error(`Cannot ${e} borrowed read-only ${this}`)}}});function j2(n,e,t,i){let r=n,s=i;s===!0&&(s=1),s===!1&&(s=0);let o=typeof s=="number"?[s]:s;switch(t){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof i!="number")throw new Error("samplers must be set to integers");return n.uniform1i(e,i);case 5126:return n.uniform1fv(e,o);case 35664:return n.uniform2fv(e,o);case 35665:return n.uniform3fv(e,o);case 35666:return n.uniform4fv(e,o);case 5124:return n.uniform1iv(e,o);case 35667:return n.uniform2iv(e,o);case 35668:return n.uniform3iv(e,o);case 35669:return n.uniform4iv(e,o);case 35670:return n.uniform1iv(e,o);case 35671:return n.uniform2iv(e,o);case 35672:return n.uniform3iv(e,o);case 35673:return n.uniform4iv(e,o);case 5125:return r.uniform1uiv(e,o,1);case 36294:return r.uniform2uiv(e,o,2);case 36295:return r.uniform3uiv(e,o,3);case 36296:return r.uniform4uiv(e,o,4);case 35674:return n.uniformMatrix2fv(e,!1,o);case 35675:return n.uniformMatrix3fv(e,!1,o);case 35676:return n.uniformMatrix4fv(e,!1,o);case 35685:return r.uniformMatrix2x3fv(e,!1,o);case 35686:return r.uniformMatrix2x4fv(e,!1,o);case 35687:return r.uniformMatrix3x2fv(e,!1,o);case 35688:return r.uniformMatrix3x4fv(e,!1,o);case 35689:return r.uniformMatrix4x2fv(e,!1,o);case 35690:return r.uniformMatrix4x3fv(e,!1,o)}throw new Error("Illegal uniform")}var H2=C(()=>{});function Y2(n){return lz[n]}function ld(n){return cz[n]}function ud(n){return!!Z2[n]}function q2(n){return Z2[n]}var cz,Z2,lz,fd=C(()=>{cz={5126:"f32",35664:"vec2",35665:"vec3",35666:"vec4",5124:"i32",35667:"vec2",35668:"vec3",35669:"vec4",5125:"u32",36294:"vec2",36295:"vec3",36296:"vec4",35670:"f32",35671:"vec2",35672:"vec3",35673:"vec4",35674:"mat2x2",35685:"mat2x3",35686:"mat2x4",35687:"mat3x2",35675:"mat3x3",35688:"mat3x4",35689:"mat4x2",35690:"mat4x3",35676:"mat4x4"},Z2={35678:{viewDimension:"2d",sampleType:"float"},35680:{viewDimension:"cube",sampleType:"float"},35679:{viewDimension:"3d",sampleType:"float"},35682:{viewDimension:"3d",sampleType:"depth"},36289:{viewDimension:"2d-array",sampleType:"float"},36292:{viewDimension:"2d-array",sampleType:"depth"},36293:{viewDimension:"cube",sampleType:"float"},36298:{viewDimension:"2d",sampleType:"sint"},36299:{viewDimension:"3d",sampleType:"sint"},36300:{viewDimension:"cube",sampleType:"sint"},36303:{viewDimension:"2d-array",sampleType:"uint"},36306:{viewDimension:"2d",sampleType:"uint"},36307:{viewDimension:"3d",sampleType:"uint"},36308:{viewDimension:"cube",sampleType:"uint"},36311:{viewDimension:"2d-array",sampleType:"uint"}},lz={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126}});function K2(n,e,t={}){let i={attributes:[],bindings:[]};i.attributes=uz(n,e);let r=hz(n,e,t);for(let c of r){let l=c.uniforms.map(u=>({name:u.name,format:u.format,byteOffset:u.byteOffset,byteStride:u.byteStride,arrayLength:u.arrayLength}));i.bindings.push({type:"uniform",name:c.name,group:0,location:c.location,visibility:(c.vertex?1:0)|(c.fragment?2:0),minBindingSize:c.byteLength,uniforms:l})}let s=dz(n,e),o=0;for(let c of s)if(ud(c.type)){let{viewDimension:l,sampleType:u}=q2(c.type);i.bindings.push({type:"texture",name:c.name,group:0,location:o,viewDimension:l,sampleType:u}),c.textureUnit=o,o+=1}s.length&&(i.uniforms=s);let a=fz(n,e);return a?.length&&(i.varyings=a),i}function uz(n,e){let t=[],i=n.getProgramParameter(e,35721);for(let r=0;r=0){let l=ld(a),u=/instance/i.test(o)?"instance":"vertex";t.push({name:o,location:c,stepMode:u,type:l})}}return t.sort((r,s)=>r.location-s.location),t}function fz(n,e){let t=[],i=n.getProgramParameter(e,35971);for(let r=0;rr.location-s.location),t}function dz(n,e){let t=[],i=n.getProgramParameter(e,35718);for(let r=0;r1)for(let h=0;ho.location-a.location),i}function pz(n,e){for(let t of n.uniforms){let i=e.uniforms.find(r=>t.name===r.name||t.name.endsWith(`.${r.name}`));if(!i)throw new Error(`Failed to validate WebGL uniform block "${e.name}": reflected unexpected member "${t.name}"`);if(t.format!==i.format||t.arrayLength!==i.arrayLength||t.byteOffset!==i.byteOffset||t.byteStride!==i.byteStride)throw new Error(`Failed to validate WebGL uniform block "${e.name}": reflected layout for "${t.name}" does not match supplied std140 metadata`)}}function mz(n,e,t){let i=new Map;for(let s of t.uniformBlockLayouts||[])i.set(s.name,_z(s));for(let s of t.shaderLayout?.bindings||[])bz(s)&&i.set(s.name,s);let r=new Map;for(let s of i.values()){let o=gz(n,e,s.name);if(!o)continue;let{blockIndex:a,blockName:c}=o;if(r.has(a))throw new Error(`Multiple supplied uniform block layouts resolve to active WebGL block "${c}"`);r.set(a,{name:c,location:a,byteLength:s.minBindingSize,vertex:!!(s.visibility&&s.visibility&1),fragment:!!(s.visibility&&s.visibility&2),uniformCount:s.uniforms.length,uniforms:s.uniforms.map(l=>({...l}))})}return r}function gz(n,e,t){let i=t.endsWith("Uniforms")?[t,t.slice(0,-8)]:[t,`${t}Uniforms`];for(let r of i){let s=n.getUniformBlockIndex(e,r);if(s!==4294967295){if(!Number.isInteger(s)||s<0)throw new Error(`Failed to resolve WebGL uniform block "${r}": getUniformBlockIndex returned ${String(s)}`);return{blockIndex:s,blockName:r}}}return null}function X2(n,e,t,i){let r=i||n.getActiveUniformBlockName(e,t);if(!r)throw new Error(`Failed to reflect WebGL uniform block at index ${t}: missing block name`);let s=(b,w)=>{let E=n.getActiveUniformBlockParameter(e,t,b);if(E==null)throw new Error(`Failed to reflect WebGL uniform block "${r}": ${w} returned null`);return E},o=os(s(35391,"UNIFORM_BLOCK_BINDING"),r,"UNIFORM_BLOCK_BINDING",0),a=os(s(35392,"UNIFORM_BLOCK_DATA_SIZE"),r,"UNIFORM_BLOCK_DATA_SIZE",0),c=os(s(35394,"UNIFORM_BLOCK_ACTIVE_UNIFORMS"),r,"UNIFORM_BLOCK_ACTIVE_UNIFORMS",0),l=Q2(s(35395,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES"),r,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",c),u=Uc(n,e,l,35383,"UNIFORM_TYPE",r,c),f=Uc(n,e,l,35384,"UNIFORM_SIZE",r,c),d=Uc(n,e,l,35386,"UNIFORM_BLOCK_INDEX",r,c),h=Uc(n,e,l,35387,"UNIFORM_OFFSET",r,c),p=Uc(n,e,l,35388,"UNIFORM_ARRAY_STRIDE",r,c),m=[];for(let b=0;bb.name.split(".")[0]).filter(b=>!!b)),y=g.name.replace(/Uniforms$/,"");if(v.size===1&&!v.has(g.name)&&!v.has(y)){let[b]=v;z.warn(`Uniform block "${g.name}" uses GLSL instance "${b}". luma.gl binds uniform buffers by block name ("${g.name}") and alias ("${y}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}return g}function Uc(n,e,t,i,r,s,o){let a=n.getActiveUniforms(e,t,i);if(a===null)throw new Error(`Failed to reflect WebGL uniform block "${s}": ${r} returned null`);return Q2(a,s,r,o)}function Q2(n,e,t,i){if(!Array.isArray(n)&&!ArrayBuffer.isView(n))throw new Error(`Failed to reflect WebGL uniform block "${e}": ${t} returned a non-array value`);let r=Array.from(n);if(r.length!==i||r.some(s=>!Number.isInteger(s)))throw new Error(`Failed to reflect WebGL uniform block "${e}": ${t} returned ${r.length} invalid values, expected ${i}`);return r}function os(n,e,t,i){if(!Number.isInteger(n)||n{if(typeof o=="string"){let a=e[s];if(!a)throw new Error(`Missing std140 layout field ${s}`);t.push({name:s,format:a.shaderType,arrayLength:1,byteOffset:a.offset*4,byteStride:0});return}if(Array.isArray(o)){r(s,o[0],o[1]);return}for(let[a,c]of Object.entries(o))i(`${s}.${a}`,c)},r=(s,o,a)=>{if(typeof o=="string"){let c=e[`${s}[0]`],l=a>1?e[`${s}[1]`]:void 0;if(!c)throw new Error(`Missing std140 array layout field ${s}[0]`);t.push({name:`${s}[0]`,format:c.shaderType,arrayLength:a,byteOffset:c.offset*4,byteStride:l?(l.offset-c.offset)*4:0});return}if(Array.isArray(o))throw new Error(`Nested uniform arrays are not supported for ${s}`);for(let[c,l]of Object.entries(o)){if(typeof l!="string")throw new Error(`Composite uniform array members are not supported for ${s}`);let u=`${s}[0].${c}`,f=`${s}[1].${c}`,d=e[u],h=a>1?e[f]:void 0;if(!d)throw new Error(`Missing std140 array layout field ${u}`);t.push({name:u,format:d.shaderType,arrayLength:a,byteOffset:d.offset*4,byteStride:h?(h.offset-d.offset)*4:0})}};for(let[s,o]of Object.entries(n))i(s,o);return t}function bz(n){return n.type==="uniform"&&Number.isInteger(n.minBindingSize)&&n.minBindingSize>=0&&Array.isArray(n.uniforms)&&n.uniforms.every(e=>typeof e.name=="string"&&typeof e.format=="string"&&Number.isInteger(e.arrayLength)&&e.arrayLength>0&&Number.isInteger(e.byteOffset)&&e.byteOffset>=0&&Number.isInteger(e.byteStride)&&e.byteStride>=0)}function vz(n){if(n[n.length-1]!=="]")return{name:n,length:1,isArray:!1};let t=/([^[]*)(\[[0-9]+\])?/.exec(n);return{name:Gi(t?.[1],`Failed to parse GLSL uniform name ${n}`),length:t?.[2]?1:0,isArray:!!t?.[2]}}var J2=C(()=>{ee();fd()});function xz(n,e){let t={...n,attributes:n.attributes.map(i=>({...i})),bindings:n.bindings.map(i=>({...i}))};for(let i of e?.attributes||[]){let r=t.attributes.find(s=>s.name===i.name);r?(r.type=i.type||r.type,r.stepMode=i.stepMode||r.stepMode):z.warn(`shader layout attribute ${i.name} not present in shader`)}for(let i of e?.bindings||[]){let r=tP(t,i.name);if(!r){z.warn(`shader layout binding ${i.name} not present in shader`);continue}Object.assign(r,i)}return t}function tP(n,e){return n.bindings.find(t=>t.name===e||t.name===`${e}Uniforms`||`${t.name}Uniforms`===e)}function eP(n,e){return n[e]||n[`${e}Uniforms`]||n[e.replace(/Uniforms$/,"")]}var dd,nP=C(()=>{ee();H2();Jf();Xf();cd();py();J2();dd=class extends Ht{device;handle;vs;fs;introspectedLayout;bindings={};uniforms={};varyings=null;_uniformCount=0;_uniformSetters={};get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}constructor(e,t){super(e,t),this.device=e;let i=this.sharedRenderPipeline||this.device._createSharedRenderPipelineWebGL(t);this.sharedRenderPipeline=i,this.handle=i.handle,this.vs=i.vs,this.fs=i.fs,this.linkStatus=i.linkStatus,this.introspectedLayout=K2(this.device.gl,this.handle,{uniformBlockLayouts:t._uniformBlockLayouts,shaderLayout:t.shaderLayout}),this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.shaderLayout=t.shaderLayout?xz(this.introspectedLayout,t.shaderLayout):this.introspectedLayout}destroy(){this.destroyed||(this.sharedRenderPipeline&&!this.props._sharedRenderPipeline&&this.sharedRenderPipeline.destroy(),this.destroyResource())}setBindings(e,t){let i=js(Or(this.shaderLayout,e));for(let[r,s]of Object.entries(i)){let o=tP(this.shaderLayout,r);if(o){switch(s||z.warn(`Unsetting binding "${r}" in render pipeline "${this.id}"`)(),o.type){case"uniform":if(!(s instanceof bn)&&!(s.buffer instanceof bn))throw new Error("buffer value");break;case"texture":if(!(s instanceof Qn||s instanceof Jn||s instanceof Kn))throw new Error(`${this} Bad texture binding for ${r}`);break;case"sampler":z.warn(`Ignoring sampler ${r}`)();break;default:throw new Error(o.type)}this.bindings[r]=s}else{let a=this.shaderLayout.bindings.map(c=>`"${c.name}"`).join(", ");t?.disableWarnings||z.warn(`No binding "${r}" in render pipeline "${this.id}", expected one of ${a}`,s)()}}}draw(e){let t=e.renderPass,i=e.bindGroups?js(e.bindGroups):e.bindings||this.bindings;return t.setPipeline(this),t.setBindings(i),t.setVertexArray(e.vertexArray),t.draw({parameters:e.parameters,topology:e.topology,isInstanced:e.isInstanced,vertexCount:e.vertexCount,indexCount:e.indexCount,instanceCount:e.instanceCount,firstVertex:e.firstVertex,firstIndex:e.firstIndex,firstInstance:e.firstInstance,baseVertex:e.baseVertex,transformFeedback:e.transformFeedback,uniforms:e.uniforms})}_areTexturesRenderable(e){let t=!0;for(let i of this.shaderLayout.bindings)eP(e,i.name)||(z.warn(`Binding ${i.name} not found in ${this.id}`)(),t=!1);return t}_applyBindings(e,t){if(this._syncLinkStatus(),this.linkStatus!=="success")return;let{gl:i}=this.device;i.useProgram(this.handle);let r=0,s=0;for(let o of this.shaderLayout.bindings){let a=eP(e,o.name);if(!a)throw new Error(`No value for binding ${o.name} in ${this.id}`);switch(o.type){case"uniform":let{name:c}=o,l=i.getUniformBlockIndex(this.handle,c);if(l===4294967295)throw new Error(`Invalid uniform block name ${c}`);if(i.uniformBlockBinding(this.handle,l,s),a instanceof bn)i.bindBufferBase(35345,s,a.handle);else{let f=a;i.bindBufferRange(35345,s,f.buffer.handle,f.offset||0,f.size||f.buffer.byteLength-(f.offset||0))}s+=1;break;case"texture":if(!(a instanceof Qn||a instanceof Jn||a instanceof Kn))throw new Error("texture");let u;if(a instanceof Qn)u=a.texture;else if(a instanceof Jn)u=a;else if(a instanceof Kn&&a.colorAttachments[0]instanceof Qn)z.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),u=a.colorAttachments[0].texture;else throw new Error("No texture");i.activeTexture(33984+r),i.bindTexture(u.glTarget,u.handle),r+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${o.type}' not supported in WebGL`)}}}_applyUniforms(e){for(let t of this.shaderLayout.uniforms||[]){let{name:i,location:r,type:s,textureUnit:o}=t,a=e[i]??o;a!==void 0&&j2(this.device.gl,r,s,a)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}}});var iP,hd,rP=C(()=>{ee();fd();iP=4,hd=class extends Aa{device;handle;vs;fs;linkStatus="pending";constructor(e,t){super(e,t),this.device=e,this.handle=t.handle||this.device.gl.createProgram(),this.vs=t.vs,this.fs=t.fs,t.varyings&&t.varyings.length>0&&this.device.gl.transformFeedbackVaryings(this.handle,t.varyings,t.bufferMode||35981),this._linkShaders()}destroy(){this.destroyed||(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.handle.destroyed=!0,this.destroyResource())}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),z.time(iP,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),z.timeEnd(iP,`linkProgram for ${this.id}`)(),!this.device.features.has("compilation-status-async-webgl")){let i=this._getLinkStatus();this._reportLinkStatus(i);return}z.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),z.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let t=this._getLinkStatus();this._reportLinkStatus(t)}async _reportLinkStatus(e){switch(e){case"success":return;default:let t=e==="link-error"?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${t} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader();break;case"success":break}switch(this.fs?.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`${this} ${t} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader();break;case"success":break}let i=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${t} during ${e}: ${i}`),this)(),this.device.debug()}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(this._initializeSamplerUniforms(),e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}_initializeSamplerUniforms(){let{gl:e}=this.device;e.useProgram(this.handle);let t=0,i=e.getProgramParameter(this.handle,35718);for(let r=0;r1){let o=Int32Array.from({length:t.size},(a,c)=>r+c);return s.uniform1iv(e,o),r+t.size}return s.uniform1i(e,r),r+1}async _waitForLinkComplete(){let e=async r=>await new Promise(s=>setTimeout(s,r));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getProgramParameter(this.handle,37297))return;await e(10)}}}});function wz(n,e){let t=e.sourceBuffer,i=e.destinationBuffer;n.gl.bindBuffer(36662,t.handle),n.gl.bindBuffer(36663,i.handle),n.gl.copyBufferSubData(36662,36663,e.sourceOffset??0,e.destinationOffset??0,e.size),n.gl.bindBuffer(36662,null),n.gl.bindBuffer(36663,null)}function Ez(n,e){let{sourceBuffer:t,byteOffset:i=0,destinationTexture:r,mipLevel:s=0,origin:o=[0,0,0],aspect:a="all",bytesPerRow:c,rowsPerImage:l,size:u}=e;if(a!=="all")throw new Error("copyBufferToTexture aspect is not supported in WebGL");r.writeBuffer(t,{byteOffset:i,bytesPerRow:c,rowsPerImage:l,mipLevel:s,x:o[0]??0,y:o[1]??0,z:o[2]??0,width:u[0],height:u[1],depthOrArrayLayers:u[2]})}function Sz(n,e){let{sourceTexture:t,mipLevel:i=0,aspect:r="all",width:s=e.sourceTexture.width,height:o=e.sourceTexture.height,depthOrArrayLayers:a,origin:c=[0,0,0],destinationBuffer:l,byteOffset:u=0,bytesPerRow:f,rowsPerImage:d}=e;if(t instanceof pe){t.readBuffer({x:c[0]??0,y:c[1]??0,z:c[2]??0,width:s,height:o,depthOrArrayLayers:a,mipLevel:i,aspect:r,byteOffset:u},l);return}if(r!=="all")throw new Error("aspect not supported in WebGL");if(i!==0||a!==void 0||f||d)throw new Error("not implemented");let{framebuffer:h,destroyFramebuffer:p}=sP(t),m;try{let g=l,v=s||h.width,y=o||h.height,b=Gi(h.colorAttachments[0]),w=Yf(b.texture.props.format),E=w.format,x=w.type;n.gl.bindBuffer(35051,g.handle),m=n.gl.bindFramebuffer(36160,h.handle),n.gl.readPixels(c[0],c[1],v,y,E,x,u)}finally{n.gl.bindBuffer(35051,null),m!==void 0&&n.gl.bindFramebuffer(36160,m),p&&h.destroy()}}function Pz(n,e){let{sourceTexture:t,destinationMipLevel:i=0,origin:r=[0,0],destinationOrigin:s=[0,0,0],destinationTexture:o}=e,{width:a=e.destinationTexture.width,height:c=e.destinationTexture.height}=e,{framebuffer:l,destroyFramebuffer:u}=sP(t),[f=0,d=0]=r,[h,p,m]=s,g=n.gl.bindFramebuffer(36160,l.handle),v,y;if(o instanceof Jn)v=o,a=Number.isFinite(a)?a:v.width,c=Number.isFinite(c)?c:v.height,v._bind(0),y=v.glTarget;else throw new Error("invalid destination");switch(y){case 3553:case 34067:n.gl.copyTexSubImage2D(y,i,h,p,f,d,a,c);break;case 35866:case 32879:n.gl.copyTexSubImage3D(y,i,h,p,m,f,d,a,c);break;default:}v&&v._unbind(),n.gl.bindFramebuffer(36160,g),u&&l.destroy()}function sP(n){if(n instanceof pe){let{width:e,height:t,id:i}=n;return{framebuffer:n.device.createFramebuffer({id:`framebuffer-for-${i}`,width:e,height:t,colorAttachments:[n]}),destroyFramebuffer:!0}}return{framebuffer:n,destroyFramebuffer:!1}}var pd,oP=C(()=>{ee();Lo();cd();pd=class extends Ia{device;handle=null;commands=[];constructor(e,t={}){super(e,t),this.device=e}_executeCommands(e=this.commands){for(let t of e)switch(t.name){case"copy-buffer-to-buffer":wz(this.device,t.options);break;case"copy-buffer-to-texture":Ez(this.device,t.options);break;case"copy-texture-to-buffer":Sz(this.device,t.options);break;case"copy-texture-to-texture":Pz(this.device,t.options);break;default:throw new Error(t.name)}}}});function aP(n){switch(n){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"triangle-list":return 4;case"triangle-strip":return 5;default:throw new Error(n)}}function cP(n){switch(n){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;default:throw new Error(n)}}var gy=C(()=>{});var Cz,md,lP=C(()=>{ee();od();Po();gy();uy();Cz=[1,2,4,8],md=class extends ka{device;handle=null;glParameters={};pipeline=null;bindings={};bindingsPipeline=null;vertexArray=null;constructor(e,t){super(e,t),this.device=e;let i=this.props.framebuffer,r=!i||i.handle===null;r&&e.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();let s;if(!t?.parameters?.viewport)if(!r&&i){let{width:o,height:a}=i;s=[0,0,o,a]}else{let[o,a]=e.getDefaultCanvasContext().getDrawingBufferSize();s=[0,0,o,a]}if(this.device.pushState(),this.setParameters({viewport:s,...this.props.parameters}),!r&&i?.colorAttachments.length){let o=i.colorAttachments.map((a,c)=>36064+c);this.device.gl.drawBuffers(o)}else r&&this.device.gl.drawBuffers([1029]);this.clear(),this.props.timestampQuerySet&&this.props.beginTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.beginTimestampIndex)}end(){this.destroyed||(this.props.timestampQuerySet&&this.props.endTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.endTimestampIndex),this.device.popState(),this.destroy())}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}executeBundles(e){throw new Error("Render bundles are only supported in WebGPU")}setParameters(e={}){let t={...this.glParameters};t.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(t.depthMask=!this.props.depthReadOnly),t.stencilMask=this.props.stencilReadOnly?0:1,t[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(t.viewport=e.viewport.slice(0,4),t.depthRange=[e.viewport[4],e.viewport[5]]):t.viewport=e.viewport),e.scissorRect&&(t.scissorTest=!0,t.scissor=e.scissorRect),e.blendConstant&&(t.blendColor=e.blendConstant),e.stencilReference!==void 0&&(t[2967]=e.stencilReference,t[36003]=e.stencilReference),"colorMask"in e&&(t.colorMask=Cz.map(i=>!!(i&e.colorMask))),this.glParameters=t,gn(this.device.gl,t)}setPipeline(e){this.pipeline=e}setBindings(e,t){if(!this.pipeline)throw new Error("RenderPass.setPipeline() must be called before setBindings()");this.bindings=js(Or(this.pipeline.shaderLayout,e)),this.bindingsPipeline=this.pipeline}setVertexArray(e){this.vertexArray=e}draw(e){let t=this.pipeline,i=this.vertexArray;if(!t)throw new Error("RenderPass.setPipeline() must be called before draw()");if(!i)throw new Error("RenderPass.setVertexArray() must be called before draw()");if(t.shaderLayout.bindings.length>0&&this.bindingsPipeline!==t)throw new Error("RenderPass.setBindings() must be called after setPipeline() before draw()");t._syncLinkStatus();let{parameters:r=t.props.parameters,topology:s=t.props.topology,vertexCount:o,indexCount:a,instanceCount:c,isInstanced:l=!1,firstVertex:u=0,transformFeedback:f,uniforms:d=t.uniforms}=e,h=aP(s),p=!!i.indexBuffer,m=i.indexBuffer?.glIndexType,g=a??o??0;if(t.linkStatus!=="success")return z.info(2,`RenderPipeline:${t.id}.draw() aborted - waiting for shader linking`)(),!1;if(!t._areTexturesRenderable(this.bindings))return z.info(2,`RenderPipeline:${t.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(t.handle),i.bindBeforeRender(this);let v=f;return v&&v.begin(t.props.topology),t._applyBindings(this.bindings,{disableWarnings:t.props.disableWarnings}),t._applyUniforms(d),V2(this.device,r,this.glParameters,()=>{p&&l?this.device.gl.drawElementsInstanced(h,g,m,u,c||0):p?this.device.gl.drawElements(h,g,m,u):l?this.device.gl.drawArraysInstanced(h,u,o||0,c||0):this.device.gl.drawArrays(h,u,o||0),v&&v.end()}),i.unbindAfterRender(this),!0}drawIndirect(e,t=0){throw new Error("Indirect drawing is only supported in WebGPU")}drawIndexedIndirect(e,t=0){throw new Error("Indirect drawing is only supported in WebGPU")}beginOcclusionQuery(e){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let e={...this.glParameters},t=0;this.props.clearColors&&this.props.clearColors.forEach((i,r)=>{i&&this.clearColorBuffer(r,i)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(t|=16384,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(t|=256,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(t|=1024,e.clearStencil=this.props.clearStencil),t!==0&&vn(this.device.gl,e,()=>{this.device.gl.clear(t)})}clearColorBuffer(e=0,t=[0,0,0,0]){vn(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,e,t);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,e,t);break;case Float32Array:this.device.gl.clearBufferfv(6144,e,t);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}});var $c,uP=C(()=>{ee();oP();lP();$c=class extends Ra{device;handle=null;commandBuffer;constructor(e,t){super(e,t),this.device=e,this.commandBuffer=new pd(e,{id:this.id,userData:this.userData})}destroy(){this.destroyResource()}finish(){return this.destroy(),this.commandBuffer}beginRenderPass(e={}){return new md(this.device,this._applyTimeProfilingToPassProps(e))}beginComputePass(e={}){throw new Error("ComputePass not supported in WebGL")}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,t,i){throw new Error("resolveQuerySet is not supported in WebGL")}writeTimestamp(e,t){e.writeTimestamp(t)}}});function fP(n){let{target:e,source:t,start:i=0,count:r=1}=n,s=t.length,o=r*s,a=0;for(let c=i;a{});function Tz(n){return Array.isArray(n)?new Float32Array(n):n}function Lz(n,e){if(!n||!e||n.length!==e.length||n.constructor!==e.constructor)return!1;for(let t=0;t{ee();vr();ny();dP();gd=class n extends Ba{get[Symbol.toStringTag](){return"VertexArray"}device;handle;attributeInfosByLocation;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return pp()==="Chrome"}constructor(e,t){super(e,t),this.device=e,this.handle=this.device.gl.createVertexArray(),this.attributeInfosByLocation=new Array(this.maxVertexAttributes).fill(null);for(let i of Object.values(Ua(t.shaderLayout,t.bufferLayout)))this.attributeInfosByLocation[i.location]=i}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){let t=e;if(t&&t.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,t?t.handle:null),this.indexBuffer=t,this.device.gl.bindVertexArray(null)}setBuffer(e,t){let i=t;if(i.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:r,type:s,stride:o,offset:a,normalized:c,integer:l,divisor:u}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,i.handle),l?this.device.gl.vertexAttribIPointer(e,r,s,o,a):this.device.gl.vertexAttribPointer(e,r,s,c,o,a),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,u||0),this.attributes[e]=i,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,t){this._enable(e,!1),this.attributes[e]=t}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e{ee();yd();gy();_d=class extends Oa{device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(e,t){super(e,t),this.device=e,this.gl=e.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,t.buffers&&this.setBuffers(t.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(e="point-list"){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(cP(e))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(e){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let[t,i]of Object.entries(e))this.setBuffer(t,i)})}setBuffer(e,t){let i=this._getVaryingIndex(e),{buffer:r,byteLength:s,byteOffset:o}=this._getBufferRange(t);if(i<0){this.unusedBuffers[e]=r,z.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[i]={buffer:r,byteLength:s,byteOffset:o},this.bindOnUse||this._bindBuffer(i,r,o,s)}getBuffer(e){if(pP(e))return this.buffers[e]||null;let t=this._getVaryingIndex(e);return this.buffers[t]??null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(36386,e),this;let t;return this._bound?t=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,t=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),t}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof bn)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:t,byteOffset:i=0,byteLength:r=e.buffer.byteLength}=e;return{buffer:t,byteOffset:i,byteLength:r}}_getVaryingIndex(e){if(pP(e))return Number(e);for(let t of this.layout.varyings||[])if(e===t.name)return t.location;return-1}_bindBuffers(){for(let[e,t]of Object.entries(this.buffers)){let{buffer:i,byteLength:r,byteOffset:s}=this._getBufferRange(t);this._bindBuffer(Number(e),i,s,r)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,t,i=0,r){let s=t&&t.handle;!s||r===void 0?this.gl.bindBufferBase(35982,e,s):this.gl.bindBufferRange(35982,e,s,i,r)}}});var bd,gP=C(()=>{ee();bd=class extends Da{device;handle;_timestampPairs=[];_pendingReads=new Set;_occlusionQuery=null;_occlusionActive=!1;get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){if(super(e,t),this.device=e,t.type==="timestamp"){if(t.count<2)throw new Error("Timestamp QuerySet requires at least two query slots");this._timestampPairs=new Array(Math.ceil(t.count/2)).fill(null).map(()=>({activeQuery:null,completedQueries:[]})),this.handle=null}else{if(t.count>1)throw new Error("WebGL occlusion QuerySet can only have one value");let i=this.device.gl.createQuery();if(!i)throw new Error("WebGL query not supported");this.handle=i}Object.seal(this)}destroy(){if(!this.destroyed){this.handle&&this.device.gl.deleteQuery(this.handle);for(let e of this._timestampPairs){e.activeQuery&&(this._cancelPendingQuery(e.activeQuery),this.device.gl.deleteQuery(e.activeQuery.handle));for(let t of e.completedQueries)this._cancelPendingQuery(t),this.device.gl.deleteQuery(t.handle)}this._occlusionQuery&&(this._cancelPendingQuery(this._occlusionQuery),this.device.gl.deleteQuery(this._occlusionQuery.handle));for(let e of Array.from(this._pendingReads))this._cancelPendingQuery(e);this.destroyResource()}}isResultAvailable(e){return this.props.type==="timestamp"?e===void 0?this._timestampPairs.some((t,i)=>this._isTimestampPairAvailable(i)):this._isTimestampPairAvailable(this._getTimestampPairIndex(e)):this._occlusionQuery?this._pollQueryAvailability(this._occlusionQuery):!1}async readResults(e){let t=e?.firstQuery||0,i=e?.queryCount||this.props.count-t;if(this._validateRange(t,i),this.props.type==="timestamp"){let r=new Array(i).fill(0n),s=Math.floor(t/2),o=Math.floor((t+i-1)/2);for(let a=s;a<=o;a++){let c=await this._consumeTimestampPairResult(a),l=a*2,u=l+1;l>=t&&l=t&&u=this.props.count||t<=e)throw new Error("Timestamp duration range is out of bounds");if(e%2!==0||t!==e+1)throw new Error("WebGL timestamp durations require adjacent even/odd query indices");let i=await this._consumeTimestampPairResult(this._getTimestampPairIndex(e));return Number(i)/1e6}beginOcclusionQuery(){if(this.props.type!=="occlusion")throw new Error("Occlusion queries require an occlusion QuerySet");if(!this.handle)throw new Error("WebGL occlusion query is not available");if(this._occlusionActive)throw new Error("Occlusion query is already active");this.device.gl.beginQuery(35887,this.handle),this._occlusionQuery={handle:this.handle,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null},this._occlusionActive=!0}endOcclusionQuery(){if(!this._occlusionActive)throw new Error("Occlusion query is not active");this.device.gl.endQuery(35887),this._occlusionActive=!1}writeTimestamp(e){if(this.props.type!=="timestamp")throw new Error("Timestamp writes require a timestamp QuerySet");let t=this._getTimestampPairIndex(e),i=this._timestampPairs[t];if(e%2===0){if(i.activeQuery)throw new Error("Timestamp query pair is already active");let r=this.device.gl.createQuery();if(!r)throw new Error("WebGL query not supported");let s={handle:r,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null};this.device.gl.beginQuery(35007,r),i.activeQuery=s;return}if(!i.activeQuery)throw new Error("Timestamp query pair was ended before it was started");this.device.gl.endQuery(35007),i.completedQueries.push(i.activeQuery),i.activeQuery=null}_validateRange(e,t){if(e<0||t<0||e+t>this.props.count)throw new Error("Query read range is out of bounds")}_getTimestampPairIndex(e){if(e<0||e>=this.props.count)throw new Error("Query index is out of bounds");return Math.floor(e/2)}_isTimestampPairAvailable(e){let t=this._timestampPairs[e];return!t||t.completedQueries.length===0?!1:this._pollQueryAvailability(t.completedQueries[0])}_pollQueryAvailability(e){if(e.cancelled||this.destroyed)return e.result=0n,!0;if(e.result!==null||e.disjoint)return!0;if(!this.device.gl.getQueryParameter(e.handle,34919))return!1;let i=!!this.device.gl.getParameter(36795);return e.disjoint=i,e.result=i?0n:BigInt(this.device.gl.getQueryParameter(e.handle,34918)),!0}async _consumeTimestampPairResult(e){let t=this._timestampPairs[e];if(!t||t.completedQueries.length===0)throw new Error("Timestamp query pair has no completed result");let i=t.completedQueries.shift();try{return await this._consumeQueryResult(i)}finally{this.device.gl.deleteQuery(i.handle)}}_consumeQueryResult(e){return e.promise||(this._pendingReads.add(e),e.promise=new Promise((t,i)=>{e.resolve=t,e.reject=i;let r=()=>{if(e.pollRequestId=null,e.cancelled||this.destroyed){this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,t(0n);return}if(!this._pollQueryAvailability(e)){e.pollRequestId=this._requestAnimationFrame(r);return}this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,e.disjoint?i(new Error("GPU timestamp query was invalidated by a disjoint event")):t(e.result||0n)};r()})),e.promise}_cancelPendingQuery(e){if(this._pendingReads.delete(e),e.cancelled=!0,e.pollRequestId!==null&&(this._cancelAnimationFrame(e.pollRequestId),e.pollRequestId=null),e.resolve){let t=e.resolve;e.promise=null,e.resolve=null,e.reject=null,t(0n)}}_requestAnimationFrame(e){return requestAnimationFrame(e)}_cancelAnimationFrame(e){cancelAnimationFrame(e)}}});var vd,_P=C(()=>{ee();vd=class extends Na{device;gl;handle;signaled;_signaled=!1;constructor(e,t={}){super(e,{}),this.device=e,this.gl=e.gl;let i=this.props.handle||this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE,0);if(!i)throw new Error("Failed to create WebGL fence");this.handle=i,this.signaled=new Promise(r=>{let s=()=>{let o=this.gl.clientWaitSync(this.handle,0,0);o===this.gl.ALREADY_SIGNALED||o===this.gl.CONDITION_SATISFIED?(this._signaled=!0,r()):setTimeout(s,1)};s()})}isSignaled(){if(this._signaled)return!0;let e=this.gl.getSyncParameter(this.handle,this.gl.SYNC_STATUS);return this._signaled=e===this.gl.SIGNALED,this._signaled}destroy(){this.destroyed||this.gl.deleteSync(this.handle)}}});function _y(n){switch(n){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function yP(n){switch(n){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}var bP=C(()=>{});function vP(n,e){let{sourceX:t=0,sourceY:i=0,sourceAttachment:r=0}=e||{},{target:s=null,sourceWidth:o,sourceHeight:a,sourceDepth:c,sourceFormat:l,sourceType:u}=e||{},{framebuffer:f,deleteFramebuffer:d}=wP(n),{gl:h,handle:p}=f;o||=f.width,a||=f.height;let m=f.colorAttachments[r]?.texture;if(!m)throw new Error(`Invalid framebuffer attachment ${r}`);c=m?.depth||1,l||=m?.glFormat||6408,u||=m?.glType||5121,s=Az(s,u,l,o,a,c);let g=Ke.getDataType(s);u=u||Y2(g);let v=h.bindFramebuffer(36160,p);return h.readBuffer(36064+r),h.readPixels(t,i,o,a,l,u,s),h.readBuffer(36064),h.bindFramebuffer(36160,v||null),d&&f.destroy(),s}function xP(n,e){let{target:t,sourceX:i=0,sourceY:r=0,sourceFormat:s=6408,targetByteOffset:o=0}=e||{},{sourceWidth:a,sourceHeight:c,sourceType:l}=e||{},{framebuffer:u,deleteFramebuffer:f}=wP(n);a=a||u.width,c=c||u.height;let d=u;l=l||5121;let h=t;if(!h){let m=_y(s),g=yP(l),v=o+a*c*m*g;h=d.device.createBuffer({byteLength:v})}let p=n.device.createCommandEncoder();return p.copyTextureToBuffer({sourceTexture:n,width:a,height:c,origin:[i,r],destinationBuffer:h,byteOffset:o}),p.destroy(),f&&u.destroy(),h}function wP(n){return n instanceof Rr?{framebuffer:n,deleteFramebuffer:!1}:{framebuffer:Mz(n),deleteFramebuffer:!0}}function Mz(n,e){let{device:t,width:i,height:r,id:s}=n;return t.createFramebuffer({...e,id:`framebuffer-for-${s}`,width:i,height:r,colorAttachments:[n]})}function Az(n,e,t,i,r,s){if(n)return n;e||=5121;let o=ad(e),a=Ke.getTypedArrayConstructor(o),c=_y(t);return new a(i*r*c)}var EP=C(()=>{ee();fd();bP();my()});function SP(n){let e=new Map;for(let t in n){let i=n[t];if(t<"a"){let r=e.get(i);e.set(i,r?`${r}, GL.${t}`:`GL.${t}`)}}return e}var PP=C(()=>{});var yy={};ui(yy,{WebGLDevice:()=>er});function kz(n,e,t){switch(t.length){case 1:n.gl.vertexAttrib1fv(e,t);break;case 2:n.gl.vertexAttrib2fv(e,t);break;case 3:n.gl.vertexAttrib3fv(e,t);break;case 4:n.gl.vertexAttrib4fv(e,t);break;default:}}function Rz(n,e,t){n.gl.vertexAttribI4iv(e,t)}function Iz(n,e,t){n.gl.vertexAttribI4uiv(e,t)}function Bz(n,e){if(!n||!e||n.length!==e.length||n.constructor!==e.constructor)return!1;for(let t=0;t{ee();ey();w2();ty();P2();I2();B2();O2();D2();Z_();Lo();F2();Jf();$2();W2();cd();Xf();nP();rP();uP();hP();mP();gP();_P();EP();Po();od();Dc();PP();er=class n extends pi{static getDeviceFromContext(e){return e?e.luma?.device??null:null}type="webgl";handle;features;limits;info;canvasContext;preferredColorFormat="rgba8unorm";preferredDepthFormat="depth24plus";commandEncoder;lost;_resolveContextLost;_isLost=!1;gl;_glKeyByValue=null;_constants;extensions;_polyfilled=!1;spectorJS;get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(e){switch(e){case"unorm8x4-bgra":return!1;default:return!0}}constructor(e){super({...e,id:e.id||N2("webgl-device")});let t=pi._getCanvasContextProps(e);if(!t)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let i=t.canvas?.gl??null,r=n.getDeviceFromContext(i);if(r)throw new Error(`WebGL context already attached to device ${r.id}`);this.canvasContext=new Kf(this,t),this.lost=new Promise(u=>{this._resolveContextLost=u});let s={...e.webgl};t.alphaMode==="premultiplied"&&(s.premultipliedAlpha=!0),e.powerPreference!==void 0&&(s.powerPreference=e.powerPreference),e.failIfMajorPerformanceCaveat!==void 0&&(s.failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat);let a=this.props._handle||x2(this.canvasContext.canvas,{onContextLost:u=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."}),onContextRestored:u=>{console.log("WebGL context restored")}},s);if(!a)throw new Error("WebGL context creation failed");if(r=n.getDeviceFromContext(a),r){if(e._reuseDevices)return z.log(1,`Not creating a new Device, instead returning a reference to Device ${r.id} already attached to WebGL context`,r)(),this.canvasContext.destroy(),r._reused=!0,r;throw new Error(`WebGL context already attached to device ${r.id}`)}this.handle=a,this.gl=a,this.spectorJS=u2({...this.props,gl:this.handle});let c=Oc(this.handle);c.device=this,c.extensions||(c.extensions={}),this.extensions=c.extensions,this.info=E2(this.gl,this.extensions),this.limits=new Zf(this.gl),this.features=new qf(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new _n(this.gl,{log:(...u)=>z.log(1,...u)()}).trackState(this.gl,{copyState:!1}),(e.debug||e.debugWebGL)&&(this.gl=c2(this.gl,{debugWebGL:!0,traceWebGL:e.debugWebGL}),z.warn("WebGL debug mode activated. Performance reduced.")()),e.debugWebGL&&(z.level=Math.max(z.level,1)),this.commandEncoder=new $c(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}destroy(){if(!this.props._reuseDevices&&!this._reused){this._isLost=!0,this.commandEncoder?.destroy();let e=Oc(this.handle);e.device=null}}get isLost(){return this._isLost||this.gl.isContextLost()}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createPresentationContext(e){return new Qf(this,e||{})}createBuffer(e){let t=this._normalizeBufferProps(e);return new bn(this,t)}createTexture(e){return new Jn(this,e)}createExternalTexture(e){throw new Error("ExternalTexture is not available on WebGL")}createSampler(e){return new sd(this,e)}createShader(e){return new td(this,e)}createFramebuffer(e){return new Kn(this,e)}createVertexArray(e){return new gd(this,e)}createTransformFeedback(e){return new _d(this,e)}createQuerySet(e){return new bd(this,e)}createFence(){return new vd(this)}createRenderPipeline(e){return new dd(this,e)}_createSharedRenderPipelineWebGL(e){return new hd(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}createRenderBundleEncoder(e){throw new Error("Render bundles are only supported in WebGPU")}createCommandEncoder(e={}){return new $c(this,e)}submit(e){let t=null;e||({submittedCommandEncoder:t,commandBuffer:e}=this._finalizeDefaultCommandEncoderForSubmit());try{e._executeCommands(),t&&t.resolveTimeProfilingQuerySet().then(()=>{this.commandEncoder._gpuTimeMs=t._gpuTimeMs}).catch(()=>{})}finally{e.destroy()}}writeBufferViaCommandEncoder(e,t,i,r=0){t.write(i,r)}_finalizeDefaultCommandEncoderForSubmit(){let e=this.commandEncoder,t=e.finish();return this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:e.props.id,timeProfilingQuerySet:e.getTimeProfilingQuerySet()}),{submittedCommandEncoder:e,commandBuffer:t}}readPixelsToArrayWebGL(e,t){return vP(e,t)}readPixelsToBufferWebGL(e,t){return xP(e,t)}setParametersWebGL(e){gn(this.gl,e)}getParametersWebGL(e){return Gf(this.gl,e)}withParametersWebGL(e,t){return vn(this.gl,e,t)}resetWebGL(){z.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),g2(this.gl)}_getDeviceSpecificTextureFormatCapabilities(e){return A2(this.gl,e,this.extensions)}loseDevice(){let e=!1,i=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return i&&(e=!0,i.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){_n.get(this.gl).push()}popState(){_n.get(this.gl).pop()}getGLKey(e,t){let i=this._getGLKeyByValue().get(Number(e));return i||(t?.emptyIfUnknown?"":String(e))}getGLKeys(e){let t={emptyIfUnknown:!0};return Object.entries(e).reduce((i,[r,s])=>(i[`${r}:${this.getGLKey(r,t)}`]=`${s}:${this.getGLKey(s,t)}`,i),{})}_getGLKeyByValue(){return this._glKeyByValue??=SP(this.gl),this._glKeyByValue}setConstantAttributeWebGL(e,t){let i=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(i).fill(null);let r=this._constants[e];switch(r&&Bz(r,t)&&z.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=t,t.constructor){case Float32Array:kz(this,e,t);break;case Int32Array:Rz(this,e,t);break;case Uint32Array:Iz(this,e,t);break;default:throw new Error("constant")}}getExtension(e){return yn(this.gl,e,this.extensions),this.extensions}_setWebGLDebugMetadata(e,t,i){e.luma=t;let r={props:i.spector,id:i.spector.id};e.__SPECTOR_Metadata=r}}});function Oz(n){return typeof WebGL2RenderingContext<"u"&&n instanceof WebGL2RenderingContext?!0:!!(n&&typeof n.createVertexArray=="function")}function CP(n){return{...n,debug:n.debug??pi.defaultProps.debug,debugWebGL:n.debugWebGL??pi.defaultProps.debugWebGL,debugSpectorJS:n.debugSpectorJS??!!z.get("debug-spectorjs")}}async function TP(n){let e=[];(n.debugWebGL||n.debug)&&e.push(a2()),n.debugSpectorJS&&e.push(l2(n));let t=await Promise.allSettled(e);for(let i of t)i.status==="rejected"&&z.error(`Failed to initialize debug libraries ${i.reason}`)()}var Gc,by,Vc,LP=C(()=>{ee();s2();Z_();Gc=1,by=class extends wa{type="webgl";enforceWebGL2(e){r2(e)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext&&z.warn("WebGL1 is not supported",e)(),!1)}async attach(e,t={}){let{WebGLDevice:i}=await Promise.resolve().then(()=>(xd(),yy));if(e instanceof i)return e;let r=i.getDeviceFromContext(e);if(r)return r;if(!Oz(e))throw new Error("Invalid WebGL2RenderingContext");t=CP(t),await TP(t);let s=t.createCanvasContext===!0?{}:t.createCanvasContext;return new i({...t,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...s}})}async create(e={}){let{WebGLDevice:t}=await Promise.resolve().then(()=>(xd(),yy));e=CP(e),await TP(e);try{let i=new t(e);z.groupCollapsed(Gc,`WebGLDevice ${i.id} created`)();let r=`${i._reused?"Reusing":"Created"} device with WebGL2 ${i.props.debug?"debug ":""}context: ${i.info.vendor}, ${i.info.renderer} for canvas: ${i.canvasContext.id}`;return z.probe(Gc,r)(),z.table(Gc,i.info)(),i}finally{z.groupEnd(Gc)(),z.info(Gc,"%cWebGL call tracing: luma.log.set('debug-webgl') ","color: white; background: blue; padding: 2px 6px; border-radius: 3px;")()}}};Vc=new by});var yd=C(()=>{LP();xd();Jf()});function Cd(n){return NP.test(n)}function Td(n){return FP.test(n)}function zP(n){let e=NP.exec(n),t=FP.exec(n),i=e?.[1]??t?.[1]??n;try{Ee.getVertexFormatInfo(i)}catch{throw new Error(`Unsupported GPUVector format ${n}`)}return i}function wi(n){let e=zP(n),t=Cd(n),i=Td(n),r=Ee.getVertexFormatInfo(e),s=r.type,o=r.normalized,a=Uz(s,o);return{format:n,elementFormat:e,vertexList:t,valueList:i,type:s,signedDataType:$z(e,s),primitiveType:a,components:r.components,byteLength:r.byteLength,integer:r.integer,signed:r.signed,normalized:o,...r.webglOnly?{webglOnly:!0}:{}}}function Uz(n,e){if(e)return"f32";switch(n){case"float32":return"f32";case"float16":return"f16";case"uint8":case"uint16":case"uint32":return"u32";case"sint8":case"sint16":case"sint32":return"i32";default:throw new Error(`Unsupported GPUVector component type ${n}`)}}function $z(n,e){if(n==="unorm10-10-10-2")return"uint32";switch(e){case"unorm8":return"uint8";case"snorm8":return"sint8";case"unorm16":return"uint16";case"snorm16":return"sint16";default:return e}}var NP,FP,Ld=C(()=>{ee();NP=/^vertex-list<([^<>]+)>$/,FP=/^value-list<([^<>]+)>$/});function wy(n,e){if(!Number.isSafeInteger(n)||n<0)throw new Error(`${e} must be a non-negative safe integer`)}var Ei,Ey=C(()=>{ee();Ei=class{buffer;format;length;byteOffset;byteStride;constructor(e){let t=Ee.getVertexFormatInfo(e.format).byteLength,i=e.byteOffset??0,r=e.byteStride??t;if(wy(e.length,"GPUDataView length"),wy(i,"GPUDataView byteOffset"),wy(r,"GPUDataView byteStride"),re.buffer.byteLength)throw new Error("GPUDataView exceeds its backing buffer byte length");this.buffer=e.buffer,this.format=e.format,this.length=e.length,this.byteOffset=i,this.byteStride=r}get elementByteLength(){return Ee.getVertexFormatInfo(this.format).byteLength}get byteLength(){return this.length===0?0:(this.length-1)*this.byteStride+this.elementByteLength}}});function Ad(n){return!!(n&&typeof n=="object"&&n.type==="struct")}function $P(n,e){let t=Object.entries(n);if(t.length===0)throw new Error("GPUData struct format must declare at least one field");return e==="packed"?Gz(t):Vz(t)}function Gz(n){let e=[],t=0,i=0;for(let[r,s]of n){let o=Ee.getVertexFormatInfo(s);if(o.webglOnly)throw new Error(`Packed GPUData struct field "${r}" uses WebGL-only format ${s}`);t=UP(t,Math.min(4,o.byteLength)),e.push([r,Object.freeze({format:s,byteOffset:t,byteLength:o.byteLength})]),t+=o.byteLength,i+=o.components}return Object.freeze({type:"struct",layout:"packed",fields:Object.freeze(Object.fromEntries(e)),components:i,byteStride:UP(t,4),rowByteLength:t})}function Vz(n){let e=Object.fromEntries(n.map(([o,a])=>[o,Wz(a)])),t=Dr(e,{layout:"wgsl-storage"}),i=[],r=0,s=0;for(let[o,a]of n){let c=Ee.getVertexFormatInfo(a),l=t.fields[o].offset*4;i.push([o,Object.freeze({format:a,byteOffset:l,byteLength:c.byteLength})]),r=Math.max(r,l+c.byteLength),s+=c.components}return Object.freeze({type:"struct",layout:"wgsl-storage",fields:Object.freeze(Object.fromEntries(i)),components:s,byteStride:t.byteLength,rowByteLength:r})}function Wz(n){let e=Ee.getVertexFormatInfo(n);switch(e.type){case"float32":return Md("f32",e.components);case"sint32":return Md("i32",e.components);case"uint32":return Md("u32",e.components);default:{let t=Math.ceil(e.byteLength/4);return Md("u32",t)}}}function Md(n,e){return e===1?n:`vec${e}<${n}>`}function UP(n,e){return Math.ceil(n/e)*e}var GP=C(()=>{ee()});var Sy,Py,Mo,Cy=C(()=>{Ey();GP();Ld();Sy=class{buffer;ownsDataBuffer;constructor(e,t){this.buffer=e,this.ownsDataBuffer=t}get ownsBuffer(){return this.ownsDataBuffer}transferBufferOwnership(e){if(e.buffer!==this.buffer)throw new Error("GPUData ownership can only be transferred to the same buffer");e.ownsDataBuffer=this.ownsDataBuffer,this.ownsDataBuffer=!1}destroy(){this.ownsDataBuffer&&(this.buffer.destroy(),this.ownsDataBuffer=!1)}},Py=class extends Sy{dataType;format;length;valueLength;stride;byteOffset;byteStride;rowByteLength;readbackMetadata;valueOffsets;nullBitmap;valueByteLength;constructor(e){let{buffer:t,format:i,length:r,valueLength:s,stride:o,byteOffset:a=0,byteStride:c,rowByteLength:l,ownsBuffer:u=!1,readbackMetadata:f,valueOffsets:d,nullBitmap:h,valueByteLength:p,dataType:m}=e;super(t,u);let g;i?typeof i=="string"?g=i:g=$P(i,e.layout??"wgsl-storage"):g=void 0;let v=Ad(g)?g:void 0,y=typeof g=="string"?wi(g):void 0;if(this.dataType=m,this.format=g,this.length=r,this.valueLength=s??r,this.stride=o??y?.components??v?.components??c??l??1,this.byteOffset=a,this.rowByteLength=l??v?.rowByteLength??y?.byteLength??c??this.stride,this.byteStride=c??v?.byteStride??this.rowByteLength,v){if(this.rowByteLengthi.format!==e))throw new Error("GPUVector data chunks must share the declared format")}var ei,WP=C(()=>{Cy();Ld();ei=class{name;dataType;format;length;valueLength;stride;byteOffset;byteStride;rowByteLength;bufferLayout;data=[];device;bufferProps;isAppendable=!1;ownsDataChunks=!0;ownedVectors=[];appendableByteLength=0;constructor(e){switch(e.type){case"buffer":{let{name:t,buffer:i,format:r,length:s,valueLength:o=s,byteOffset:a=0,ownsBuffer:c=!1}=e,{stride:l,byteStride:u,rowByteLength:f}=VP(e);this.name=t,this.dataType=e.dataType,this.format=r,this.length=s,this.valueLength=o,this.stride=l,this.byteOffset=a,this.byteStride=u,this.rowByteLength=f,this.data.push(new Mo({buffer:i,format:r,length:s,valueLength:o,stride:l,byteOffset:a,byteStride:u,rowByteLength:f,ownsBuffer:c,dataType:e.dataType}));return}case"interleaved":{let{name:t,buffer:i,format:r,length:s,valueLength:o=s,byteOffset:a=0,byteStride:c,attributes:l,ownsBuffer:u=!1}=e;this.name=t,this.dataType=e.dataType,this.format=r,this.length=s,this.valueLength=o,this.stride=c,this.byteOffset=a,this.byteStride=c,this.rowByteLength=c,this.bufferLayout={name:t,byteStride:c,attributes:l},this.data.push(new Mo({buffer:i,format:r,length:s,valueLength:o,stride:c,byteOffset:a,byteStride:c,rowByteLength:c,ownsBuffer:u,dataType:e.dataType}));return}case"data":{let t=e.format??jz(e.data),i=t?wi(t):void 0,{name:r,data:s,stride:o=s[0]?.stride??i?.components??1,valueLength:a=s.reduce((d,h)=>d+h.valueLength,0),byteStride:c=s[0]?.byteStride??i?.byteLength,rowByteLength:l=s[0]?.rowByteLength??i?.byteLength,bufferLayout:u,ownsData:f=!1}=e;if(c===void 0||l===void 0)throw new Error("GPUVector requires format or explicit byte layout metadata");t&&Hz(s,t),this.name=r,this.dataType=e.dataType,this.format=t,this.length=s.reduce((d,h)=>d+h.length,0),this.valueLength=a,this.stride=o,this.byteOffset=s.length===1?s[0].byteOffset:0,this.byteStride=c,this.rowByteLength=l,this.bufferLayout=u,this.ownsDataChunks=f,this.data.push(...s);return}case"appendable":{let{name:t,device:i,format:r,valueLength:s=0,bufferProps:o}=e,{stride:a,byteStride:c,rowByteLength:l}=VP(e);this.name=t,this.dataType=e.dataType,this.format=r,this.length=0,this.valueLength=s,this.stride=a,this.byteOffset=0,this.byteStride=c,this.rowByteLength=l,this.device=i,this.bufferProps=o,this.isAppendable=!0;return}}}get ownsBuffer(){return this.ownsDataChunks&&this.data.some(e=>e.ownsBuffer)||this.ownedVectors.some(e=>e.ownsBuffer)}get capacityRows(){return this.isAppendable?this.length:void 0}get appendedByteLength(){return this.appendableByteLength}addData(e){if(this.format&&e.format!==this.format)throw new Error("GPUVector.addData() requires matching formats");if(e.byteStride!==this.byteStride)throw new Error("GPUVector.addData() requires matching byteStride");if(e.rowByteLength!==this.rowByteLength)throw new Error("GPUVector.addData() requires matching rowByteLength");return this.data.push(e),this.length+=e.length,this.valueLength+=e.valueLength,this}appendDataChunk(e,t=this.appendableByteLength+e.buffer.byteLength){if(!this.isAppendable)throw new Error("GPUVector.appendDataChunk() requires appendable vector storage");if(this.format&&e.format!==this.format)throw new Error("GPUVector.appendDataChunk() requires matching formats");if(e.byteStride!==this.byteStride||e.rowByteLength!==this.rowByteLength)throw new Error("GPUVector.appendDataChunk() requires matching byte layout metadata");return this.data.push(e),this.length+=e.length,this.valueLength+=e.valueLength,this.appendableByteLength=t,this}resetLastBatch(){if(!this.isAppendable)throw new Error("GPUVector.resetLastBatch() requires appendable vector storage");for(let e of this.data.splice(0))e.destroy();return this.length=0,this.valueLength=0,this.appendableByteLength=0,this}retainOwnedVectors(e){return this.ownedVectors.push(...e),this}transferBufferOwnership(e){let t=this.data[0],i=e.data[0];if(!t||!i||t.buffer!==i.buffer)throw new Error("GPUVector ownership can only be transferred to the same buffer");t.transferBufferOwnership(i)}destroy(){if(this.ownsDataChunks)for(let e of this.data)e.destroy();for(let e of this.ownedVectors.splice(0))e.destroy()}}});var Ty=C(()=>{Cy();Ey();WP();Ld()});var Ly,pt,qc=C(()=>{ee();Ly=class{poolSize=20;bufferPools;constructor(){this.bufferPools=new Map}createOrReuse(e,t){if(t>e.limits.maxBufferSize)throw new Error(`Buffer pool cannot allocate ${t} bytes: device.limits.maxBufferSize is ${e.limits.maxBufferSize}`);let i=this.bufferPools.get(e),r=i?i.findIndex(o=>o.byteLength>=t):-1;if(r<0)return e.createBuffer({usage:re.VERTEX|re.STORAGE|re.COPY_DST|re.COPY_SRC,byteLength:t});let[s]=i.splice(r,1);return s}recycle(e){let t=e.device;this.bufferPools.has(t)||this.bufferPools.set(t,[]);let i=this.bufferPools.get(t),r=i.findIndex(s=>s.byteLength>e.byteLength);r<0?i.push(e):i.splice(r,0,e),this.purge()}purge(){for(let[e,t]of this.bufferPools){let i=e.isLost?0:this.poolSize;for(;t.length>i;)t.shift().destroy();t.length===0&&this.bufferPools.delete(e)}}},pt=new Ly});function Yz(n,e,t,i){let{ValueType:r,size:s,offset:o,stride:a}=n,c=a/r.BYTES_PER_ELEMENT,l=o/r.BYTES_PER_ELEMENT,u=i-t;if(c===s){let d=l+t*c;return e.subarray(d,d+u*s)}let f=new r(u*s);for(let d=0;d0)throw new Error(`GPUDataEvaluator requires exactly one GPUData chunk for "${n.name}"`);return e}function Xz(n){let e=[];return HP(n,e,{byteOffset:0}),e}function HP(n,e,t){let i=n.source;if(i&&!(i instanceof ye)&&i.name==="interleave"){for(let r of Object.values(i.inputs))r instanceof ye&&HP(r,e,t);return}e.push({attribute:n.id??n.toString(),format:YP(n.type,n.size,n.normalized),byteOffset:t.byteOffset}),t.byteOffset+=n.ValueType.BYTES_PER_ELEMENT*n.size}function YP(n,e,t=!1){if(e<1||e>4)throw new Error(`Cannot synthesize a GPUVector vertex format with ${e} components`);let i=n;if(t)switch(n){case"uint8":i="unorm8";break;case"sint8":i="snorm8";break;case"uint16":i="unorm16";break;case"sint16":i="snorm16";break;case"float32":i="float32";break;default:throw new Error(`Unsupported normalized vertex format for ${n}`)}return(i==="uint8"||i==="sint8"||i==="uint16"||i==="sint16"||i==="unorm8"||i==="snorm8"||i==="unorm16"||i==="snorm16")&&e===3?`${i}x3-webgl`:`${i}${e===1?"":`x${e}`}`}function Kz(n,e,t=!1){return e>=1&&e<=4?YP(n,e,t):void 0}var ye,Si=C(()=>{ee();Ce();Ty();qc();ye=class n{static get bufferPoolSize(){return pt.poolSize}static set bufferPoolSize(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("GPUDataEvaluator.bufferPoolSize must be a non-negative safe integer");pt.poolSize=e,pt.purge()}type;size;get offset(){return this._offset}get stride(){return this._stride}normalized;isConstant;length;get byteLength(){return this._byteLength}ValueType;source=null;format;_id;_destroyed=!1;_value;_offset;_stride;_byteLength;_gpuVector;_bufferOwnership="owned";_targetBuffer;static fromArray(e,{type:t,size:i=1,offset:r=0,stride:s=0,normalized:o=!1}){let a=t,c;if(Array.isArray(e)){a=a||"float32";let u=Tr(a);c=new u(e)}else e instanceof Float64Array?(a="uint32",i*=2,r*=2,s*=2,c=new Uint32Array(e.buffer,e.byteOffset,e.byteLength/4)):(a=a||Tu(e),c=e);let l=`<${a} * ${i}>`;return new n({id:l,type:a,size:i,offset:r,stride:s,normalized:o,value:c})}static fromConstant(e,t="float32"){let i=Tr(t),r;return Array.isArray(e)?r=`[${e.join(",")}]`:(r=String(e),e=[e]),new n({id:r,isConstant:!0,type:t,size:e.length,value:new i(e)})}static fromGPUData(e,t={}){qz(e);let i=new Ei({buffer:e.buffer,format:e.format,length:e.length,byteOffset:e.byteOffset,byteStride:e.byteStride});return new n({...jP(i),id:t.id,gpuData:e})}static fromGPUDataView(e,t={}){return new n({...jP(e),id:t.id,buffer:e.buffer})}constructor(e){let{id:t,value:i,buffer:r,gpuData:s,format:o,source:a=null,isConstant:c=!1}=e;if(!a&&!i&&!r&&!s)throw new Error("GPUDataEvaluator must have a value source");let{type:l,size:u,offset:f,stride:d,normalized:h,length:p}=e;if(a instanceof n?(l=l??a.type,u=u??a.size,f=f??a.offset,d=d??a.stride,h=h??a.normalized,p=p??a.length):(u=u??1,f=f??0,h=h??!1,p=c?1:p),!l)throw new Error("GPUDataEvaluator: type not defined");if(this._id=t,this.type=l,this.size=u,this.ValueType=Tr(this.type),this._offset=f,this._stride=d||this.ValueType.BYTES_PER_ELEMENT*u,this.normalized=h,this.source=a,this.format=o,p===void 0)if(c)p=1;else{if(!i)throw new Error("GPUDataEvaluator: length not defined");p=Math.ceil(i.byteLength/this.stride)}this.isConstant=c,this.length=p;let m=this.ValueType.BYTES_PER_ELEMENT*this.size;this._byteLength=p===0?0:(p-1)*this.stride+m,this._value=i,this._bufferOwnership=a instanceof n||r||s?"borrowed":"owned",s?this._gpuVector=new ei({type:"data",name:this._id??"data",format:s.format,data:[s],stride:s.stride,byteStride:s.byteStride,rowByteLength:s.rowByteLength}):r&&(this._gpuVector=this.createGPUVectorView({buffer:r,name:this._id,format:this.format}))}get value(){return this._value||(this.source instanceof n?this.source.value:void 0)}get evaluated(){return!!this._gpuVector}get id(){return this._id}get gpuVector(){if(!this._gpuVector)throw new Error(`${this} not evaluated`);return this._gpuVector}get buffer(){return kd(this.gpuVector)}setTargetBuffer({buffer:e,byteOffset:t=0,byteStride:i=this.stride}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)throw new Error(`GPUDataEvaluator ${this} already evaluated`);if(!this.source||this.source instanceof n)throw new Error("GPUDataEvaluator target buffers require a deferred operation source");this._targetBuffer={buffer:e,byteOffset:t,byteStride:i}}async evaluate(e,t={}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let i;if(this.source instanceof n){let r=await this.source.evaluate(e);return this._gpuVector=this.createGPUVectorView({...t,buffer:kd(r)}),this._gpuVector}if(i=this._getEvaluationBuffer(e),this._value)i.write(this._value);else{let r=await this.source.execute(e,i);if(!r.success)throw r.error||new Error(`${this.source} evaluation failed`);r.value&&(this._value=r.value)}return this._gpuVector=this.createGPUVectorView({...t,buffer:i}),this._gpuVector}evaluateSync(e,t={}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let i;if(this.source instanceof n){let r=this.source.evaluateSync(e);return this._gpuVector=this.createGPUVectorView({...t,buffer:kd(r)}),this._gpuVector}if(i=this._getEvaluationBuffer(e),this._value)i.write(this._value);else{let r=this.source.executeSync(e,i);if(!r.success)throw r.error||new Error(`${this.source} evaluation failed`);r.value&&(this._value=r.value)}return this._gpuVector=this.createGPUVectorView({...t,buffer:i}),this._gpuVector}createGPUVectorView(e){let t=e.name??this._id??"vector",i=e.format??this.format??Kz(this.type,this.size,this.normalized);if(e.interleaved){let r=typeof e.interleaved=="object"&&e.interleaved.attributes?e.interleaved.attributes:Xz(this);return new ei({type:"interleaved",name:t,buffer:e.buffer,format:e.format??this.format,length:this.length,byteOffset:this.offset,byteStride:this.stride,attributes:r,ownsBuffer:!1})}return new ei({type:"buffer",name:t,buffer:e.buffer,format:i,length:this.length,stride:this.size,byteOffset:this.offset,byteStride:this.stride,rowByteLength:this.ValueType.BYTES_PER_ELEMENT*this.size,ownsBuffer:!1})}_getEvaluationBuffer(e){let t=this._targetBuffer;if(!t)return pt.createOrReuse(e,this.byteLength);if(t.buffer.device!==e)throw new Error("GPUDataEvaluator target buffer belongs to a different device");let i=this.ValueType.BYTES_PER_ELEMENT*this.size,r=this.length===0?0:(this.length-1)*t.byteStride+i;if(t.byteOffset+r>t.buffer.byteLength)throw new Error("GPUDataEvaluator target buffer is too small for the output layout");return this._offset=t.byteOffset,this._stride=t.byteStride,this._byteLength=r,this._bufferOwnership="borrowed",this._targetBuffer=void 0,t.buffer}async readValue(e=0,t){let{ValueType:i}=this,{size:r,offset:s,stride:o,length:a}=this,c=i.BYTES_PER_ELEMENT*r;if(t=t??a,e=Math.max(0,Math.min(a,e)),t=Math.max(e,Math.min(a,t)),this._value)return Yz(this,this._value,e,t);let l=t-e;if(l===0)return new i(0);let u=s+e*o,f=o===c?l*c:(l-1)*o+c,d=await this.buffer.readAsync(u,f),h=new i(d.buffer,d.byteOffset,d.byteLength/i.BYTES_PER_ELEMENT);if(o===c)return h;let p=new Uint8Array(c*l);for(let m=0;m{Ao={add:{arity:2,symbol:"arithmetic_add"},subtract:{arity:2,symbol:"arithmetic_subtract"},multiply:{arity:2,symbol:"arithmetic_multiply"},divide:{arity:2,symbol:"arithmetic_divide"},pow:{arity:2,symbol:"pow"},sqrt:{arity:1,symbol:"sqrt"},abs:{arity:1,symbol:"abs"},sin:{arity:1,symbol:"sin"},cos:{arity:1,symbol:"cos"},tan:{arity:1,symbol:"arithmetic_tan"},exp:{arity:1,symbol:"exp"},log:{arity:1,symbol:"log"}}});function cC(n,{operations:e,inputs:t}){switch(n.kind){case"input":if(!(n.name in t))throw new Error(`Unknown expression input '${n.name}'`);return;case"literal":if(Array.isArray(n.value)){for(let i of n.value)if(!Number.isFinite(i))throw new Error(`Expression literal array must contain only finite values, got ${i}`)}else if(!Number.isFinite(n.value))throw new Error(`Expression literal must be finite, got ${n.value}`);return;case"call":{let i=e[n.op];if(!i)throw new Error(`Unknown expression op '${n.op}'`);if(n.args.length!==i.arity)throw new Error(`Expression op '${n.op}' expects ${i.arity} args, got ${n.args.length}`);for(let r of n.args)cC(r,{operations:e,inputs:t});return}default:{let i=n;throw new Error(`Unsupported expression node ${i.kind}`)}}}function Bd(n,e){return cC(n,e),lC(n,e)}function lC(n,e){switch(n.kind){case"input":{let t=e.inputs[n.name];return e.laneIndexlC(r,e));return e.formatCall(t.symbol,i)}default:{let t=n;throw new Error(`Unsupported expression node ${t.kind}`)}}}var Ry=C(()=>{});function rt(n,e,t=!1){if(t)return e===1?"float":`vec${e}`;switch(n){case"uint8":case"uint16":case"uint32":return e===1?"uint":`uvec${e}`;case"sint8":case"sint16":case"sint32":return e===1?"int":`ivec${e}`;default:return e===1?"float":`vec${e}`}}function Od(n,e,t=!1){let i;if(t)switch(n){case"uint8":i="unorm8";break;case"sint8":i="snorm8";break;case"uint16":i="unorm16";break;case"sint16":i="snorm16";break;case"float32":i="float32";break;default:throw new Error(`Unsupported normalized vertex format for ${n}`)}else i=n;return e===1?i:e===3&&!i.startsWith("float32")&&!i.endsWith("32")?`${i}x3-webgl`:`${i}x${e}`}function tr(n){switch(n[0]){case"u":return"0u";case"s":return"0";default:return"0."}}function uC(n,e){switch(n){case"uint8":case"uint16":case"uint32":return`${Math.trunc(e)}u`;case"sint8":case"sint16":case"sint32":return`${Math.trunc(e)}`;default:return Number.isInteger(e)?`${e}.0`:`${e}`}}function fC(n){switch(n){case"uint8":return"r8uint";case"sint8":return"r8sint";case"uint16":return"r16uint";case"sint16":return"r16sint";case"uint32":return"r32uint";case"sint32":return"r32sint";case"float32":return"r32float";default:throw new Error(`Unsupported WebGL gather texture format for ${n}`)}}function dC(n){switch(n){case"uint32":return"usampler2D";case"sint32":return"isampler2D";case"float32":return"sampler2D";default:throw new Error(`Unsupported WebGL gather sampler type for ${n}`)}}var Ro=C(()=>{});function st({module:n,elementWise:e=!1,expression:t,inputs:i,output:r,operationType:s=r.type,outputBuffer:o}){let a=o.device,c=cs("result",r.type,r.size,r.normalized),l=[n,c],u=[],f={},d=rt(r.type,1,r.normalized),h=rt(s,1,r.normalized),p="",m=null,g={TYPE:h,RESULT_LEN:r.size.toString()},v=oU(i);for(let[E,x]of v)l.push(Iy(E,x.type,x.size,x.normalized,s)),u.push(By(E,x)),x instanceof ye?f[E]=x.buffer:(m=m||pt.createOrReuse(a,o.byteLength),f[E]=m),p+=`TYPE ${E}[${x.size}]; get_${E}(${E}); -`,g[`${E.toUpperCase()}_LEN`]=x.size.toString();let y="";if(t)for(let E=0;EE{oS();hS();gS();yS();C4=[38.25,38.25,38.25],eo={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:mS.replace("phongMaterial","gouraudMaterial"),fs:pS.replace("phongMaterial","gouraudMaterial"),source:_S.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[fS,sS],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:C4},getUniforms(n){return{...eo.defaultUniforms,...n}}}});var vt=C(()=>{_m();dw();ng();Hw();qw();ZE();tS();aS();bS()});function Zn(n="id"){T_[n]=T_[n]||1;let e=T_[n]++;return`${n}-${e}`}var T_,_o=C(()=>{T_={}});function Kr(n){switch(n){case"POSITION":return"positions";case"NORMAL":return"normals";case"TEXCOORD_0":return"texCoords";case"TEXCOORD_1":return"texCoords1";case"COLOR_0":return"colors";default:return n}}function wF(n){let e=[];for(let[t,i]of Object.entries(n)){if(!i)continue;let{value:r,size:s,normalized:o}=i;if(s===void 0)throw new Error(`Attribute ${t} is missing a size`);e.push({name:Kr(t),format:Pe.getVertexFormatFromAttribute(r,s,o)})}return e}var tn,Rf=C(()=>{J();_o();tn=class{id;topology;vertexCount;indices;attributes;bufferLayout;userData={};constructor(e){let{attributes:t={},indices:i=null,vertexCount:r=null}=e;this.id=e.id||Zn("geometry"),this.topology=e.topology,i&&(this.indices=ArrayBuffer.isView(i)?{value:i,size:1}:i),this.attributes={};for(let[s,o]of Object.entries(t)){let a=ArrayBuffer.isView(o)?{value:o}:o;if(!ArrayBuffer.isView(a.value))throw new Error(`${this._print(s)}: must be typed array or object with value as typed array`);if((s==="POSITION"||s==="positions")&&!a.size&&(a.size=3),s==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=a}else{let c=Kr(s),l=Object.keys(this.attributes).find(u=>Kr(u)===c);l&&delete this.attributes[l],this.attributes[s]=a}}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=r||this._calculateVertexCount(this.attributes,this.indices),this.bufferLayout=e.bufferLayout||wF(this.attributes)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,t){return this}_calculateVertexCount(e,t){if(t)return t.value.length;let i=1/0;for(let r of Object.values(e)){if(!r)continue;let{value:s,size:o,constant:a}=r;!a&&s&&o!==void 0&&o>=1&&(i=Math.min(i,s.length/o))}return i}}});function p1(n,e={}){let t=e.bufferName||"geometry";if(EF(n,t))return n;let i=e.minAttributeAlignment||4,r=SF(n,e.attributes),s=[],o=0,a=1/0;for(let[u,f]of r){if(!f)continue;if(f.constant)throw new Error(`Attribute ${u} is constant`);let{value:d,size:h,normalized:p}=f;if(!ArrayBuffer.isView(d))throw new Error(`Attribute ${u} is missing typed array data`);if(h===void 0)throw new Error(`Attribute ${u} is missing a size`);let m=Pe.getVertexFormatFromAttribute(d,h,p),g=Pe.getVertexFormatInfo(m);o=h1(o,i),s.push({sourceName:u,attributeName:Kr(u),value:d,size:h,format:m,byteOffset:o,byteLength:g.byteLength}),o+=g.byteLength;let v=d.length/h;if(!Number.isInteger(v))throw new Error(`Attribute ${u} length is not divisible by size`);a=Math.min(a,v)}if(s.length===0||!Number.isFinite(a))throw new Error(`Geometry ${n.id} has no interleavable attributes`);let c=h1(o,i),l=new ArrayBuffer(a*c);for(let u of s)PF(l,a,c,u);return new tn({id:n.id,topology:n.topology||"triangle-list",vertexCount:n.vertexCount,indices:n.indices,attributes:{[t]:{value:new Uint8Array(l),size:c,byteStride:c}},bufferLayout:[{name:t,stepMode:"vertex",byteStride:c,attributes:s.map(u=>({attribute:u.attributeName,format:u.format,byteOffset:u.byteOffset}))}]})}function EF(n,e){if(n.bufferLayout.length!==1)return!1;let t=n.bufferLayout[0];return t.name===e&&!!t.attributes?.length&&!!n.attributes[e]}function SF(n,e){return e?e.map(t=>[t,n.attributes[t]]):Object.entries(n.attributes)}function PF(n,e,t,i){let r=i.value.constructor,s=r.BYTES_PER_ELEMENT;if(i.byteOffset%s!==0||t%s!==0)throw new Error(`Attribute ${i.sourceName} is not aligned to its component type`);let o=new r(n),a=i.value,c=i.byteOffset/s,l=t/s;for(let u=0;u{J();Rf()});var CF,TF,Qr,g1=C(()=>{CF=1,TF=1,Qr=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){let{delay:t=0,duration:i=Number.POSITIVE_INFINITY,rate:r=1,repeat:s=1}=e,o=CF++,a={time:0,delay:t,duration:i,rate:r,repeat:s};return this._setChannelTime(a,this.time),this.channels.set(o,a),o}removeChannel(e){this.channels.delete(e);for(let[t,i]of this.animations)i.channel===e&&this.detachAnimation(t)}isFinished(e){let t=this.channels.get(e);return t===void 0?!1:this.time>=t.delay+t.duration*t.repeat}getTime(e){if(e===void 0)return this.time;let t=this.channels.get(e);return t===void 0?-1:t.time}setTime(e){this.time=Math.max(0,e);let t=this.channels.values();for(let r of t)this._setChannelTime(r,this.time);let i=this.animations.values();for(let r of i){let{animation:s,channel:o}=r;s.setTime(this.getTime(o))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,t){let i=TF++;return this.animations.set(i,{animation:e,channel:t}),e.setTime(this.getTime(t)),i}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,t){let i=t-e.delay,r=e.duration*e.repeat;i>=r?e.time=e.duration*e.rate:(e.time=Math.max(0,i)%e.duration,e.time*=e.rate)}}});function _1(n){let e=typeof window<"u"?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame:null;return e?e.call(window,n):setTimeout(()=>n(typeof performance<"u"?performance.now():Date.now()),1e3/60)}function y1(n){let e=typeof window<"u"?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame:null;if(e){e.call(window,n);return}clearTimeout(n)}var b1=C(()=>{});var LF,MF,v1,gc,x1=C(()=>{J();b1();ua();LF=0,MF="Animation Loop",v1={requestAnimationFrame:n=>_1(n),cancelAnimationFrame:n=>y1(n)},gc=class n{static defaultAnimationLoopProps={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>{console.error(e)},stats:void 0,autoResizeViewport:!1,animationFrameProvider:v1};device=null;canvas=null;props;animationProps=null;timeline=null;stats;sharedStats;cpuTime;gpuTime;frameRate;display;_needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;_lastFrameTime=0;constructor(e){if(this.props={...n.defaultAnimationLoopProps,...e},e=this.props,!e.device)throw new Error("No device provided");this.stats=e.stats||new Yt({id:`animation-loop-${LF++}`}),this.sharedStats=Vs.stats.get(MF),this.frameRate=this.stats.get("Frame Rate"),this.frameRate.setSampleSize(1),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.setProps({autoResizeViewport:e.autoResizeViewport,animationFrameProvider:e.animationFrameProvider}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null),this.device?._disableDebugGPUTime()}delete(){this.destroy()}reportError(e){this._error=e,this.props.onError(e),this.props.onError===n.defaultAnimationLoopProps.onError&&typeof window<"u"&&typeof ErrorEvent<"u"&&window.dispatchEvent(new ErrorEvent("error",{error:e,message:e.message}))}setNeedsRedraw(e){return this._needsRedraw=this._needsRedraw||e,this}needsRedraw(){let e=this._needsRedraw;return this._needsRedraw=!1,e}setProps(e){if("autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),"animationFrameProvider"in e){let t=e.animationFrameProvider||v1;if(t!==this.props.animationFrameProvider){let i=this._animationFrameId!==null;i&&this._cancelAnimationFrame(),this.props.animationFrameProvider=t,i&&this._requestAnimationFrame()}}return this}async start(){if(this._running)return this;this._running=!0;try{let e;if(!this._initialized){if(this._initialized=!0,await this._initDevice(),this._initialize(),!this._running)return null;await this.props.onInitialize(this._getAnimationProps())}return this._running?(e!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){let t=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(t),t}}stop(){if(this._running){let e=this.animationProps;this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1,this._lastFrameTime=0,e&&this.props.onFinalize(e)}return this}redraw(e,t=null){return this.device?.isLost||this._error?this:(this._beginFrameTimers(e),this._setupFrame(),this.animationProps&&(this.animationProps.animationFrame=t),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeViewport(),this.device?._enableDebugGPUTime()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=this.props.animationFrameProvider.requestAnimationFrame(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(this.props.animationFrameProvider.cancelAnimationFrame(this._animationFrameId),this._animationFrameId=null)}_animationFrame(e,t){if(this._running)try{this.redraw(e,t??null),this._requestAnimationFrame()}catch(i){let r=i instanceof Error?i:new Error(String(i));this.reportError(r),this.stop()}}_renderFrame(e){if(this.display){this.display._renderFrame(e);return}let t=this.props.onRender(this._getAnimationProps());this.device&&t!==!1&&this.device.submit()}_clearNeedsRedraw(){this._needsRedraw=!1}_setupFrame(){this._resizeViewport()}_initializeAnimationProps(){let e=this.device?.getDefaultCanvasContext();if(!this.device||!e)throw new Error("loop");let t=e?.canvas,i=e.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:e,canvas:t,useDevicePixels:i,timeline:this.timeline,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,animationFrame:null,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:e,height:t,aspect:i}=this._getSizeAndAspect();(e!==this.animationProps.width||t!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),i!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=t,this.animationProps.aspect=i,this.animationProps.needsRedraw=this._needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.getDefaultCanvasContext().canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";let t=document.createElement("div");t.style.position="absolute",t.style.left="10px",t.style.bottom="10px",t.style.width="300px",t.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(t);let i=this.props.onAddHTML(t);i&&(t.innerHTML=i)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[e,t]=this.device.getDefaultCanvasContext().getDrawingBufferSize(),i=e>0&&t>0?e/t:1;return{width:e,height:t,aspect:i}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(e){let t=e??(typeof performance<"u"?performance.now():Date.now());if(this._lastFrameTime){let i=t-this._lastFrameTime;i>0&&this.frameRate.addTime(i)}this._lastFrameTime=t,this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeStart()}_endFrameTimers(){this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeEnd(),this._updateSharedStats()}_consumeEncodedGpuTime(){if(!this.device)return;let e=this.device.commandEncoder._gpuTimeMs;e!==void 0&&(this.gpuTime.addTime(e),this.device.commandEncoder._gpuTimeMs=void 0)}_updateSharedStats(){if(this.stats!==this.sharedStats){for(let e of Object.keys(this.sharedStats.stats))this.stats.stats[e]||delete this.sharedStats.stats[e];this.stats.forEach(e=>{let t=this.sharedStats.get(e.name,e.type);t.sampleSize=e.sampleSize,t.time=e.time,t.count=e.count,t.samples=e.samples,t.lastTiming=e.lastTiming,t.lastSampleTime=e.lastSampleTime,t.lastSampleCount=e.lastSampleCount,t._count=e._count,t._time=e._time,t._samples=e._samples,t._startTime=e._startTime,t._timerPending=e._timerPending})}}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}}});function w1(n,e){if(e instanceof If)return e;let t=p1(e),i=AF(n,t),{attributes:r,bufferLayout:s}=kF(n,t);return new If({topology:t.topology||"triangle-list",bufferLayout:s,vertexCount:t.vertexCount,indices:i,attributes:r})}function AF(n,e){if(!e.indices)return;let t=e.indices.value;return n.createBuffer({usage:ie.INDEX,data:t})}function kF(n,e){let t={};for(let[i,r]of Object.entries(e.attributes)){let s=e.bufferLayout.find(o=>o.name===i)?.name||Kr(i);r&&(t[s]=n.createBuffer({data:r.value,id:`${i}-buffer`}))}return{attributes:t,bufferLayout:e.bufferLayout,vertexCount:e.vertexCount}}var If,E1=C(()=>{J();Rf();m1();_o();If=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){if(this.id=e.id||Zn("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&!(this.indices.usage&ie.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){this.indices?.destroy();for(let e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(e){return e.byteLength/12}}});function S1(n,e){let t={},i="Values";if(n.attributes.length===0&&!n.varyings?.length)return{"No attributes or varyings":{[i]:"N/A"}};for(let r of n.attributes)if(r){let s=`${r.location} ${r.name}: ${r.type}`;t[`in ${s}`]={[i]:r.stepMode||"vertex"}}for(let r of n.varyings||[]){let s=`${r.location} ${r.name}`;t[`out ${s}`]={[i]:JSON.stringify(r)}}return t}var P1=C(()=>{});function L1(n,e,t){if(n.device.type!=="webgl")return;let i=BF(n.device);if(!i.flushing){if(DF(n)){RF(n,t,i);return}e&&OF(e)&&e.handle!==null&&(i.queuedFramebuffers.includes(e)||i.queuedFramebuffers.push(e))}}function RF(n,e,t){if(t.queuedFramebuffers.length===0)return;let i=n.device,{gl:r}=i,s=r.getParameter(36010),o=r.getParameter(36006),[a,c]=n.device.getDefaultCanvasContext().getDrawingBufferSize(),l=T1(e.top,8),u=T1(e.left,8);t.flushing=!0;try{for(let f of t.queuedFramebuffers){let[d,h,p,m,g]=IF({framebuffer:f,targetWidth:a,targetHeight:c,topPx:l,leftPx:u,minimap:e.minimap});r.bindFramebuffer(36008,f.handle),r.bindFramebuffer(36009,null),r.blitFramebuffer(0,0,f.width,f.height,d,h,p,m,16384,9728),l+=g+8}}finally{r.bindFramebuffer(36008,s),r.bindFramebuffer(36009,o),t.flushing=!1}}function IF(n){let{framebuffer:e,targetWidth:t,targetHeight:i,topPx:r,leftPx:s,minimap:o}=n,a=o?Math.max(Math.floor(t/4),1):t,c=o?Math.max(Math.floor(i/4),1):i,l=Math.min(a/e.width,c/e.height),u=Math.max(Math.floor(e.width*l),1),f=Math.max(Math.floor(e.height*l),1),d=s,h=Math.max(i-r-f,0),p=d+u,m=h+f;return[d,h,p,m,f]}function BF(n){return n.userData[C1]||={flushing:!1,queuedFramebuffers:[]},n.userData[C1]}function OF(n){return"colorAttachments"in n}function DF(n){let e=n.props.framebuffer;return!e||e.handle===null}function T1(n,e){if(!n)return e;let t=Number.parseInt(n,10);return Number.isFinite(t)?t:e}var C1,M1=C(()=>{C1="__debugFramebufferState"});function yo(n,e,t){if(n===e)return!0;if(!t||!n||!e)return!1;if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let i=0;i{});var bo,k1=C(()=>{J();bo=class{bufferLayouts;constructor(e){this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(t=>t.name===e)||null}getAttributeNamesForBuffer(e){return qs(e)}mergeBufferLayouts(e,t){let i=[...e];for(let r of t){let s=i.findIndex(o=>o.name===r.name);s<0?i.push(r):i[s]=r}return i}}});function R1(n,e){let t=Km(n),i=e.slice();return i.sort((r,s)=>{let o=Vu(qs(r).map(c=>t[c])),a=Vu(qs(s).map(c=>t[c]));return o-a}),i}var I1=C(()=>{J()});function vo(n,e){if(!n||!e.some(i=>i.bindingLayout?.length))return n;let t={...n,bindings:n.bindings.map(i=>({...i}))};"attributes"in(n||{})&&(t.attributes=n?.attributes||[]);for(let i of e)for(let r of i.bindingLayout||[])for(let s of NF(r.name)){let o=t.bindings.find(a=>a.name===s);o?.group===0&&(o.group=r.group),o&&r.visibility!==void 0&&(o.visibility=r.visibility)}return t}function B1(n,e,t=[]){return n?e?{...n,attributes:n.attributes.length?UF(n.attributes,e.attributes.filter(i=>t.includes(i.name))):e.attributes,bindings:zF(n.bindings,e.bindings)}:n:e}function _c(n){return!!(n.uniformTypes&&!FF(n.uniformTypes))}function O1(n){let e=[];for(let t of n){let i=Wa(t),r=new Set([t.vs,t.fs].flatMap(o=>o?ja(o).filter(a=>a.isStd140).map(a=>a.blockName):[])),s=r.has(i)?i:r.size===1?r.values().next().value:void 0;_c(t)&&s&&e.push({name:s,uniformTypes:t.uniformTypes})}return e}function Bf(n,e){let t=[],i=new Set;for(let r of[...n||[],...e||[]])i.has(r.name)||(i.add(r.name),t.push(r));return t}function NF(n){let e=new Set([n,`${n}Uniforms`]);return n.endsWith("Uniforms")||e.add(`${n}Sampler`),[...e]}function FF(n){for(let e in n)return!1;return!0}function zF(n,e){let t=n.map(s=>({...s})),i=new Set(n.map(s=>s.name)),r=new Set(n.map(s=>`${s.group}:${s.location}`));for(let s of e){let o=`${s.group}:${s.location}`;!i.has(s.name)&&!r.has(o)&&t.push({...s})}return t}function UF(n,e){let t=n.map(s=>({...s})),i=new Map(n.map(s=>[s.name,s])),r=new Map(n.map(s=>[s.location,s]));for(let s of e){let o=i.get(s.name);if(o){if(o.type!==s.type||o.location!==s.location)throw new Error(`Shader attribute "${s.name}" conflicts with its inferred type or location`);continue}let a=r.get(s.location);if(a)throw new Error(`Shader attributes "${a.name}" and "${s.name}" both use location ${s.location}`);t.push({...s})}return t}var L_=C(()=>{vt()});function $F(n){return _a(n)||typeof n=="number"||typeof n=="boolean"}function D1(n,e={}){let t={bindings:{},uniforms:{}};return Object.keys(n).forEach(i=>{let r=n[i];Object.prototype.hasOwnProperty.call(e,i)||$F(r)?t.uniforms[i]=r:t.bindings[i]=r}),t}var N1=C(()=>{Jp()});function F1(n={},e={},t={}){let i={...n};for(let[r,s]of Object.entries(e))s!==void 0&&(i[r]=M_(n[r],s,t[r]));return i}function M_(n,e,t){if(!t||typeof t=="string")return yc(e);if(Array.isArray(t)){if(A_(e)||!Array.isArray(e))return yc(e);let o=Array.isArray(n)&&!A_(n)?[...n]:[],a=o.slice();for(let c=0;ct===void 0?void 0:yc(t)):k_(n)?Object.fromEntries(Object.entries(n).map(([e,t])=>[e,t===void 0?void 0:yc(t)])):n}function A_(n){return ArrayBuffer.isView(n)||Array.isArray(n)&&(n.length===0||typeof n[0]=="number")}function k_(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&!ArrayBuffer.isView(n)}function GF(n){return!!n?.dependencies}var xo,R_=C(()=>{J();vt();N1();xo=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;directBindings={};constructor(e,t){Object.assign(this.options,t);let i=Cr(Object.values(e).filter(GF));for(let r of i)e[r.name]=r;N.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(let[r,s]of Object.entries(e))s&&(this._addModule(s),s.name&&r!==s.name&&!this.options.disableWarnings&&N.warn(`Module name: ${r} vs ${s.name}`)())}destroy(){}setProps(e){e.bindings&&Object.assign(this.directBindings,e.bindings);for(let t of Object.keys(e)){if(t==="bindings")continue;let i=t,r=e[i]||{},s=this.modules[i];if(!s)this.options.disableWarnings||N.warn(`Module ${t} not found`)();else{let o=this.moduleUniforms[i],a=this.moduleBindings[i],c=s.getUniforms?.(r,o)||r,{uniforms:l,bindings:u}=D1(c,s.uniformTypes);this.moduleUniforms[i]=F1(o,l,s.uniformTypes),this.moduleBindings[i]={...a,...u}}}}getModules(){return Object.values(this.modules)}addModules(e){let t=Cr(e);for(let i of t){let r=i.name;this.modules[r]||(this.modules[r]=i,this._addModule(i))}}getUniformValues(){return this.moduleUniforms}getBindingValues(){let e={};for(let t of Object.values(this.moduleBindings))Object.assign(e,t);return Object.assign(e,this.directBindings),e}getModuleBindingValues(e){let t=this.moduleBindings[e];return t?{...t}:{}}getDebugTable(){let e={};for(let[t,i]of Object.entries(this.moduleUniforms))for(let[r,s]of Object.entries(i))e[`${t}.${r}`]={type:this.modules[t].uniformTypes?.[r],value:String(s)};return e}_addModule(e){let t=e.name;this.moduleUniforms[t]=F1({},e.defaultUniforms||{},e.uniformTypes),this.moduleBindings[t]={}}}});function I_(n){return n!==null&&typeof n=="object"&&"buffer"in n}function WF(n){return n instanceof tt?n.buffer:n}function z1(n){return{buffer:WF(n.buffer),offset:n.offset,size:n.size}}var VF,tt,B_=C(()=>{J();_o();VF=ie.DEBUG_DATA_MAX_LENGTH,tt=class{device;id;ready;usage;props;isReady=!0;destroyed=!1;generation=0;updateTimestamp;debugData=new ArrayBuffer(0);_debugDataEnabled;_maxDebugDataByteLength;_ownsBuffer;_buffer;get buffer(){return this._buffer}get byteLength(){return this._buffer.byteLength}get[Symbol.toStringTag](){return"DynamicBuffer"}toString(){return`DynamicBuffer:"${this.id}":${this.byteLength}B`}toJSON(){return this.toString()}constructor(e,t){let{debugData:i=!1,buffer:r,ownsBuffer:s=!0,...o}=t;if(r&&r.device!==e)throw new Error("DynamicBuffer adopted buffers must belong to the supplied device");if(r&&(o.byteLength!==void 0||o.data!==void 0))throw new Error("DynamicBuffer cannot combine an adopted buffer with byteLength or data");let a=t.id||r?.id||Zn("dynamic-buffer"),c={...o,id:a,usage:o.usage??r?.usage,indexType:o.indexType??r?.indexType};(c.usage||0)&ie.INDEX&&!c.indexType&&(o.data instanceof Uint32Array?c.indexType="uint32":o.data instanceof Uint16Array?c.indexType="uint16":o.data instanceof Uint8Array&&(c.indexType="uint8")),delete c.data,delete c.byteOffset,this.device=e,this.id=a,this.props=c,this.usage=c.usage||0,this._debugDataEnabled=!!i,this._maxDebugDataByteLength=typeof i=="object"&&i.maxByteLength!==void 0?i.maxByteLength:VF,this._ownsBuffer=s,this._buffer=r??this.device.createBuffer({...o,id:a}),this.ready=Promise.resolve(this._buffer),this.updateTimestamp=this._buffer.updateTimestamp,this._resetDebugData(this._buffer.byteLength),o.data&&this._writeDebugData(o.data,o.byteOffset||0)}write(e,t=0){this._buffer.write(e,t),this._touch(),this._writeDebugData(e,t)}async mapAndWriteAsync(e,t=0,i=this.byteLength-t){let r=null;await this._buffer.mapAndWriteAsync(async(s,o)=>{await e(s,o),r=new Uint8Array(s.slice(0,i))},t,i),this._touch(),r&&this._writeDebugData(r,t)}async readAsync(e=0,t=this.byteLength-e){let i=await this._buffer.readAsync(e,t);return this._writeDebugData(i,e)&&this._touch(),i}async mapAndReadAsync(e,t=0,i=this.byteLength-t){let r=null,s=await this._buffer.mapAndReadAsync(async(o,a)=>(r=new Uint8Array(o.slice(0)),await e(o,a)),t,i);return r&&this._writeDebugData(r,t)&&this._touch(),s}resize(e){let{byteLength:t,preserveData:i=!1}=e;if(t===this.byteLength)return!1;let r=Math.min(e.copyByteLength??Math.min(this.byteLength,t),this.byteLength,t),s=this._buffer,o=this.debugData.slice(0),{data:a,byteOffset:c,...l}=this.props,u=this.device.createBuffer({...l,byteLength:t});return i&&r>0&&this._copyBufferContents(s,u,r),this._buffer=u,this._resetDebugData(t),i&&o.byteLength>0&&this._writeDebugData(o,0),this._ownsBuffer&&s.destroy(),this._ownsBuffer=!0,this.generation++,this._touch(),!0}ensureSize(e,t){return e<=this.byteLength?!1:this.resize({byteLength:e,preserveData:t?.preserveData})}getBinding(e){return e?.offset===void 0&&e?.size===void 0?this._buffer:{buffer:this._buffer,offset:e?.offset,size:e?.size}}destroy(){this.destroyed||(this._ownsBuffer&&this._buffer.destroy(),this.destroyed=!0,this.debugData=new ArrayBuffer(0))}_copyBufferContents(e,t,i){let r=this.device.type==="webgpu"?Math.ceil(i/4)*4:i,s=this.device.createCommandEncoder();s.copyBufferToBuffer({sourceBuffer:e,destinationBuffer:t,size:r}),this.device.submit(s.finish())}_touch(){this.updateTimestamp=this.device.incrementTimestamp()}_resetDebugData(e){if(!this._debugDataEnabled){this.debugData=new ArrayBuffer(0);return}this.debugData=new ArrayBuffer(Math.min(e,this._maxDebugDataByteLength))}_writeDebugData(e,t){if(!this._debugDataEnabled||this.debugData.byteLength===0||t>=this.debugData.byteLength)return!1;let i=ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),r=new Uint8Array(this.debugData),s=Math.min(i.byteLength,r.byteLength-t);return r.set(i.subarray(0,s),t),s>0}}});function bc(n){return n!==null&&typeof n=="object"&&"resolveTextureBinding"in n&&typeof n.resolveTextureBinding=="function"}function jF(n){return n?.type==="texture"||n?.type==="external-texture"}function U1(n,e,t){let i=Nu(n,e,{ignoreWarnings:!0});return jF(i)?i:n.bindings.length===0&&t?.fallbackGroup!==void 0?{type:"texture",name:e,group:t.fallbackGroup,location:0}:null}var $1=C(()=>{J()});function D_(n,e){return n.shaderLanguage!==void 0&&n.shaderLanguage!==e?!1:e==="glsl"?"assembleGLSLShaderPair"in n&&typeof n.assembleGLSLShaderPair=="function":"assembleWGSLShader"in n&&typeof n.assembleWGSLShader=="function"}function qF(n,e){return!n||Object.keys(e).length===0?n:{...n,attributes:n.attributes.map(t=>{let i=t.name.startsWith("_luma_")?t.name.slice(6):null;return i&&e[i]?{...t,name:i}:t})}}function ZF(n,e,t){if(bc(e)){let i=U1(t,n,{fallbackGroup:0});return i?e.resolveTextureBinding(i):null}return e instanceof tt?e.buffer:I_(e)?z1(e):e}function XF(n){return n&&!G1(n)?n:null}function KF(n){return n&&G1(n)?n:void 0}function G1(n){return YF.includes(n)}function QF(n){return{type:n.type,shaderLanguage:n.info.shadingLanguage,shaderLanguageVersion:n.info.shadingLanguageVersion,gpu:n.info.gpu,limits:n.limits,features:n.features}}var Xn,HF,O_,YF,Ze,N_=C(()=>{J();vt();E1();P1();M1();A1();k1();I1();L_();_o();R_();B_();$1();Xn=2,HF=1e4,O_="render pipeline initialization failed",YF=["stencil8","depth16unorm","depth24plus","depth24plus-stencil8","depth32float","depth32float-stencil8"],Ze=class n{static defaultProps={...Xt.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],plugins:[],geometry:null,indexBuffer:null,indexCount:void 0,firstVertex:0,firstIndex:0,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,material:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:Kt.getDefaultShaderAssembler("glsl"),debugShaders:void 0,disableWarnings:void 0};device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexCount;firstVertex;firstIndex;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;material=null;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_dynamicIndexBufferSource=null;_dynamicAttributeBufferSources={};_colorAttachmentFormats;_depthStencilAttachmentFormat;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_drawBlockedReason=!1;_destroyed=!1;_vertexCountSet=!1;_lastDrawTimestamp=-1;_bindingTable=[];get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(e,t){let i=n.defaultProps.shaderAssembler,r=t.vertexCount!==void 0;this.props={...n.defaultProps,...t,shaderAssembler:t.shaderAssembler??(D_(i,e.info.shadingLanguage)?i:Kt.getDefaultShaderAssembler(e.info.shadingLanguage))},this._vertexCountSet=r,t=this.props,this.id=t.id||Zn("model"),this.device=e,Object.assign(this.userData,t.userData),this.material=t.material||null;let s=QF(e),o=Ga(this.props.plugins,s.shaderLanguage),a=Va(this.props.modules,o.modules),c=Object.fromEntries(a.map(h=>[h.name,h])),l=t.shaderInputs||new xo(c,{disableWarnings:this.props.disableWarnings});t.shaderInputs&&o.modules.length>0&&l.addModules(o.modules),this.setShaderInputs(l);let u=Bf(this.props.modules,l.getModules()),f={...o.defines,...this.props.defines};if(this.device.type==="webgl"&&(this.props._uniformBlockLayouts=O1(u)),this.props.shaderLayout=vo(this.props.shaderLayout,u)||null,this.device.type==="webgpu"&&this.props.source){let h=this.props.shaderAssembler;Vi(D_(h,"wgsl"));let{source:p,getUniforms:m,bindingTable:g,shaderLayout:v}=h.assembleWGSLShader({platformInfo:s,...this.props,modules:u,defines:f,pluginInjections:o.injections,pluginVertexInputs:o.vertexInputs,pluginVaryings:o.varyings});this.source=p,this._getModuleUniforms=m,this._bindingTable=g;let y=v??e.getShaderLayout?.(this.source),b=qF(y,o.vertexInputs),x=B1(this.props.shaderLayout,b,Object.keys(o.vertexInputs));this.props.shaderLayout=vo(x||null,u)||null}else{let h=this.props.shaderAssembler;Vi(D_(h,"glsl"));let{vs:p,fs:m,getUniforms:g}=h.assembleGLSLShaderPair({platformInfo:s,...this.props,modules:u,defines:f,pluginInjections:o.injections,pluginVertexInputs:o.vertexInputs,pluginVaryings:o.varyings});this.vs=p,this.fs=m,this._getModuleUniforms=g,this._bindingTable=[]}this.vertexCount=this.props.vertexCount,this.indexCount=this.props.indexCount,this.firstVertex=this.props.firstVertex,this.firstIndex=this.props.firstIndex,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,this._colorAttachmentFormats=this.props.colorAttachmentFormats,this._depthStencilAttachmentFormat=this.props.depthStencilAttachmentFormat,t.geometry&&this.setGeometry(t.geometry),this.pipelineFactory=t.pipelineFactory||Ir.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||Br.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in t&&(this.isInstanced=t.isInstanced),t.instanceCount&&this.setInstanceCount(t.instanceCount),t.vertexCount&&this.setVertexCount(t.vertexCount),t.indexBuffer&&this.setIndexBuffer(t.indexBuffer),t.attributes&&this.setAttributes(t.attributes),t.constantAttributes&&this.setConstantAttributes(t.constantAttributes),t.bindings&&this.setBindings(t.bindings),t.transformFeedback&&(this.transformFeedback=t.transformFeedback)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}getBindingDebugTable(){return this._bindingTable}predraw(e){this._syncDynamicBuffers(),this.updateShaderInputs(e),this.material?.updateShaderInputs(e),this.pipeline=this._updatePipeline()}draw(e){if(this._drawBlockedReason&&!this._pipelineNeedsUpdate)return N.info(Xn,`>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)(),!1;let t=this._areBindingsLoading();if(t)return N.info(Xn,`>>> DRAWING ABORTED ${this.id}: ${t} not loaded`)(),!1;this._syncAttachmentFormats(e);try{e.pushDebugGroup(`${this}.predraw(${e})`),this.device.type==="webgpu"?(this.updateShaderInputs(),this.material?.updateShaderInputs(),this._syncDynamicBuffers(),this.pipeline=this._updatePipeline()):this.predraw(this.device.commandEncoder)}finally{e.popDebugGroup()}let i,r=this.pipeline.isErrored;try{if(e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline(),r=this.pipeline.isErrored,r)N.info(Xn,`>>> DRAWING ABORTED ${this.id}: ${O_}`)(),i=!1;else{let s=this.vertexArray.getDrawValidationError();if(s)N.info(Xn,`>>> DRAWING ABORTED ${this.id}: ${s}`)(),this._drawBlockedReason=s,i=!1;else{let o=this._getCurrentShaderLayout(),a=this._getBindings(o),c=this._getBindGroups(o,a),{indexBuffer:l}=this.vertexArray,u=l?this.indexCount??(this._vertexCountSet?this.vertexCount:l.byteLength/(l.indexType==="uint32"?4:2)):void 0;e.setPipeline(this.pipeline),e.setBindings(c,{_bindGroupCacheKeys:this._getBindGroupCacheKeys()}),e.setVertexArray(this.vertexArray),i=this.isInstanced===!0&&this.instanceCount===0?!0:e.draw({isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.isInstanced?this.instanceCount:void 0,indexCount:u,firstVertex:this.firstVertex,firstIndex:this.firstIndex,transformFeedback:this.transformFeedback||void 0,uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}}}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),i?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):r?(this._needsRedraw=O_,this._drawBlockedReason=O_):this._drawBlockedReason?this._needsRedraw=this._drawBlockedReason:this._needsRedraw="waiting for resource initialization",i}setGeometry(e){this._gpuGeometry?.destroy();let t=e&&w1(this.device,e);if(t){this.setTopology(t.topology||"triangle-list");let i=new bo(this.bufferLayout);this.bufferLayout=i.mergeBufferLayouts(t.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(t)}this._gpuGeometry=t}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){let t=new bo(this.bufferLayout),i=this._gpuGeometry?t.mergeBufferLayouts(e,this._gpuGeometry.bufferLayout):e;yo(i,this.bufferLayout,-1)||(this.bufferLayout=i,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry))}setParameters(e){yo(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,this.isInstanced===void 0&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this._vertexCountSet=!0,this.setNeedsRedraw("vertexCount")}setIndexCount(e){this.indexCount=e,this.setNeedsRedraw("indexCount")}setDrawOffsets({firstVertex:e,firstIndex:t}){this.firstVertex=e,this.firstIndex=t,this.setNeedsRedraw("drawOffsets")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new Nr(this.device,this.shaderInputs.modules);for(let[t,i]of Object.entries(this.shaderInputs.modules))if(_c(i)&&!this.material?.ownsModule(t)){let r=this._uniformStore.getManagedUniformBuffer(t);this.bindings[`${t}Uniforms`]=r}this.setNeedsRedraw("shaderInputs")}setMaterial(e){this.material=e,this.setNeedsRedraw("material")}updateShaderInputs(e){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),e),this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues())),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){let t=e instanceof tt?e.buffer:e;this.indexBuffer=t,this._dynamicIndexBufferSource=e instanceof tt?{source:e,generation:e.generation}:null,this.vertexArray.setIndexBuffer(t),this.setNeedsRedraw("indexBuffer")}setAttributes(e,t){this._drawBlockedReason=!1;let i=t?.disableWarnings??this.props.disableWarnings;e.indices&&N.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=R1(this.pipeline.shaderLayout,this.bufferLayout);let r=new bo(this.bufferLayout);for(let[s,o]of Object.entries(e)){let a=o instanceof tt?o.buffer:o,c=r.getBufferLayout(s);if(!c){i||N.warn(`Model(${this.id}): Missing layout for buffer "${s}".`)();continue}let l=r.getAttributeNamesForBuffer(c),u=!1;for(let f of l){let d=this._attributeInfos[f];if(d){let h=this.device.type==="webgpu"?this.vertexArray.getBufferSlot(d.bufferName):d.location;if(h===null){i||N.warn(`Model(${this.id}): Missing vertex array slot for buffer "${d.bufferName}".`)();continue}this.vertexArray.setBuffer(h,a),o instanceof tt?this._dynamicAttributeBufferSources[h]={source:o,generation:o.generation}:delete this._dynamicAttributeBufferSources[h],u=!0}}!u&&!i&&N.warn(`Model(${this.id}): Ignoring buffer "${a.id}" for unknown attribute "${s}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,t){for(let[i,r]of Object.entries(e)){let s=this._attributeInfos[i];s?this.vertexArray.setConstantWebGL(s.location,r):(t?.disableWarnings??this.props.disableWarnings)||N.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(let e of Object.values(this.bindings))if(bc(e)&&!e.isReady)return e.id;for(let e of Object.values(this.material?.bindings||{}))if(bc(e)&&!e.isReady)return e.id;return!1}_getBindings(e=this._getCurrentShaderLayout()){let t={};for(let[i,r]of Object.entries(this.bindings)){let s=ZF(i,r,e);s&&(t[i]=s)}return t}_getBindGroups(e=this._getCurrentShaderLayout(),t=this._getBindings(e)){let i=e.bindings.length?Or(e,t):{0:t};if(!this.material)return i;for(let[r,s]of Object.entries(this.material.getBindingsByGroup(e))){let o=Number(r);i[o]={...i[o]||{},...s}}return i}_getBindGroupCacheKeys(){let e=this.material?.getBindGroupCacheKey(3);return e?{3:e}:{}}_getBindingsUpdateTimestamp(){let e=0;this._dynamicIndexBufferSource&&(e=Math.max(e,this._dynamicIndexBufferSource.source.updateTimestamp));for(let t of Object.values(this._dynamicAttributeBufferSources))e=Math.max(e,t.source.updateTimestamp);for(let t of Object.values(this.bindings))t instanceof Ar?e=Math.max(e,t.texture.updateTimestamp):t instanceof ie||t instanceof me||t instanceof Aa||t instanceof tt?e=Math.max(e,t.updateTimestamp):bc(t)?e=t.isReady?Math.max(e,t.updateTimestamp):1/0:I_(t)&&(e=Math.max(e,(t.buffer instanceof tt,t.buffer.updateTimestamp)));return Math.max(e,this.material?.getBindingsUpdateTimestamp()||0)}_setGeometryAttributes(e){let t={...e.attributes};for(let[i]of Object.entries(t))!this.pipeline.shaderLayout.attributes.find(r=>r.name===i)&&i!=="positions"&&delete t[i];this.vertexCount=e.vertexCount,this._vertexCountSet=!0,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(t,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this._drawBlockedReason=!1,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,t=null;this.pipeline&&(N.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,t=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let i=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders}),r=null;this.source?r=i:this.fs&&(r=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bindings:void 0,bufferLayout:this.bufferLayout,colorAttachmentFormats:this._colorAttachmentFormats,depthStencilAttachmentFormat:this._depthStencilAttachmentFormat,topology:this.topology,parameters:this.parameters,bindGroups:void 0,vs:i,fs:r}),this._attributeInfos=$a(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&t!==e&&this.shaderFactory.release(t)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=N.level>3?0:HF;N.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:N.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=S1(this.pipeline.shaderLayout,this.id);N.table(Xn,e)();let t=this.shaderInputs.getDebugTable();N.table(Xn,t)();let i=this._getAttributeDebugTable();N.table(Xn,this._attributeInfos)(),N.table(Xn,i)(),N.groupEnd(Xn)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){let t=this.device.props.debugFramebuffers;if(this._drawCount++,!t)return;let i=e.props.framebuffer;L1(e,i,{id:i?.id||`${this.id}-framebuffer`,minimap:!0})}_getAttributeDebugTable(){let e={};for(let[t,i]of Object.entries(this._attributeInfos)){let r=this.vertexArray.attributes[i.location];e[i.location]={name:t,type:i.shaderType,values:r?this._getBufferOrConstantValues(r,i.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:t}=this.vertexArray,i=t.indexType==="uint32"?new Uint32Array(t.debugData):new Uint16Array(t.debugData);e.indices={name:"indices",type:t.indexType,values:i.toString()}}return e}_getBufferOrConstantValues(e,t){let i=Xe.getTypedArrayConstructor(t);return(e instanceof ie?new i(e.debugData):e).toString()}_getNonMaterialBindings(e){if(!this.material)return e;let t={};for(let[i,r]of Object.entries(e))this.material.ownsBinding(i)||(t[i]=r);return t}_getCurrentShaderLayout(){return this.pipeline?.shaderLayout||this.props.shaderLayout||{bindings:[]}}_syncDynamicBuffers(){if(this._dynamicIndexBufferSource&&this._dynamicIndexBufferSource.generation!==this._dynamicIndexBufferSource.source.generation){let e=this._dynamicIndexBufferSource.source.buffer;this.indexBuffer=e,this.vertexArray.setIndexBuffer(e),this._dynamicIndexBufferSource.generation=this._dynamicIndexBufferSource.source.generation,this.setNeedsRedraw("dynamic index buffer")}for(let[e,t]of Object.entries(this._dynamicAttributeBufferSources))t.generation!==t.source.generation&&(this.vertexArray.setBuffer(Number(e),t.source.buffer),t.generation=t.source.generation,this.setNeedsRedraw("dynamic attribute buffer"))}_syncAttachmentFormats(e){if(this.device.type!=="webgpu")return;let t=e.framebuffer||e.props.framebuffer,i=e.props,r=i.colorAttachmentFormats??t?.colorAttachments?.map(o=>XF(o?.texture?.format)),s=i.depthStencilAttachmentFormat===!1?void 0:i.depthStencilAttachmentFormat??KF(t?.depthStencilAttachment?.texture?.format);(!yo(this._colorAttachmentFormats,r,1)||this._depthStencilAttachmentFormat!==s)&&(this._colorAttachmentFormats=r,this._depthStencilAttachmentFormat=s,this._setPipelineNeedsUpdate("attachment formats"))}}});var JF,e6,nt,V1=C(()=>{J();vt();N_();JF=35980,e6=35981,nt=class n{device;model;transformFeedback;static defaultProps={...Ze.defaultProps,feedbackBufferMode:"separate",outputs:void 0,feedbackBuffers:void 0};static isSupported(e){return e?.info?.type==="webgl"}constructor(e,t=n.defaultProps){if(!n.isSupported(e))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=e,this.model=new Ze(this.device,{id:t.id||"buffer-transform-model",fs:t.fs||hg(),topology:t.topology||"point-list",varyings:t.outputs||t.varyings,...t,bufferMode:t.bufferMode||(t.feedbackBufferMode==="interleaved"?JF:e6)}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:t.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){e?.inputBuffers&&this.model.setAttributes(e.inputBuffers),e?.outputBuffers&&this.transformFeedback.setBuffers(e.outputBuffers);let t=this.device.beginRenderPass({discard:!0,...e});this.model.draw(t),t.end()}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){let t=this.getBuffer(e);if(!t)throw new Error("BufferTransform#getBuffer");if(t instanceof ie)return t.readAsync();let{buffer:i,byteOffset:r=0,byteLength:s=i.byteLength}=t;return i.readAsync(r,s)}}});function n6(n){return{type:n.type,shaderLanguage:n.info.shadingLanguage,shaderLanguageVersion:n.info.shadingLanguageVersion,gpu:n.info.gpu,limits:n.limits,features:n.features}}var F_,t6,Bt,W1=C(()=>{J();vt();Jp();R_();L_();_o();F_=2,t6=1e4,Bt=class n{static defaultProps={...Hi.defaultProps,id:"unnamed",handle:void 0,userData:{},source:"",modules:[],defines:{},plugins:[],bindings:void 0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,shaderAssembler:Kt.getDefaultShaderAssembler("wgsl"),debugShaders:void 0};device;id;pipelineFactory;shaderFactory;userData={};bindings={};pipeline;source;shader;shaderInputs;_uniformStore;_pipelineNeedsUpdate="newly created";_getModuleUniforms;props;_destroyed=!1;constructor(e,t){if(e.type!=="webgpu")throw new Error("Computation is only supported in WebGPU");this.props={...n.defaultProps,...t},t=this.props,this.id=t.id||Zn("model"),this.device=e,Object.assign(this.userData,t.userData);let i=n6(e),r=Ga(this.props.plugins,i.shaderLanguage);if(Object.keys(r.vertexInputs).length>0||Object.keys(r.varyings).length>0)throw new Error("Computation does not support ShaderPlugin vertex inputs or varyings");let s=Va(this.props.modules,r.modules),o=Object.fromEntries(s.map(p=>[p.name,p]));this.shaderInputs=t.shaderInputs||new xo(o),t.shaderInputs&&r.modules.length>0&&this.shaderInputs.addModules(r.modules),this.setShaderInputs(this.shaderInputs);let a=Bf(this.props.modules,this.shaderInputs?.getModules()),c={...r.defines,...this.props.defines};this.props.shaderLayout=vo(this.props.shaderLayout,a)||null,this.pipelineFactory=t.pipelineFactory||Ir.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||Br.getDefaultShaderFactory(this.device);let l=this.props.shaderAssembler;Vi(l instanceof qi);let{source:u,getUniforms:f,shaderLayout:d}=l.assembleWGSLShader({platformInfo:i,...this.props,modules:a,defines:c,scanVertexAttributes:!1,pluginInjections:r.injections});this.source=u,this._getModuleUniforms=f;let h=d??e.getShaderLayout?.(this.source,{scanVertexAttributes:!1});this.props.shaderLayout=vo(this.props.shaderLayout||h||null,a)||null,this.pipeline=this._updatePipeline(),t.bindings&&this.setBindings(t.bindings)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.shader),this._uniformStore.destroy(),this._destroyed=!0)}predraw(e){this.updateShaderInputs(e)}dispatch(e,t,i,r){try{this._logDrawCallStart(),this._setPipeline(e),e.dispatch(t,i,r)}finally{this._logDrawCallEnd()}}dispatchIndirect(e,t,i=0){try{this._logDrawCallStart(),this._setPipeline(e),e.dispatchIndirect(t,i)}finally{this._logDrawCallEnd()}}_setPipeline(e){this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings),e.setPipeline(this.pipeline),e.setBindings({})}setVertexCount(e){}setInstanceCount(e){}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new Nr(this.device,this.shaderInputs.modules);for(let[t,i]of Object.entries(this.shaderInputs.modules))if(_c(i)){let r=this._uniformStore.getManagedUniformBuffer(t);this.bindings[`${t}Uniforms`]=r}}setShaderModuleProps(e){let t=this._getModuleUniforms(e),i=Object.keys(t).filter(s=>{let o=t[s];return!_a(o)&&typeof o!="number"&&typeof o!="boolean"}),r={};for(let s of i)r[s]=t[s],delete t[s]}updateShaderInputs(e){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),e)}setBindings(e){Object.assign(this.bindings,e)}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate=this._pipelineNeedsUpdate||e}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null;this.pipeline&&(N.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.shader),this._pipelineNeedsUpdate=!1,this.shader=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"compute",source:this.source,debugShaders:this.props.debugShaders}),this.pipeline=this.pipelineFactory.createComputePipeline({...this.props,shader:this.shader}),e&&this.shaderFactory.release(e)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=N.level>3?0:t6;N.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:N.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=this.shaderInputs.getDebugTable();N.table(F_,e)(),N.groupEnd(F_)(),this._logOpen=!1}}_drawCount=0;_getBufferOrConstantValues(e,t){let i=Xe.getTypedArrayConstructor(t);return(e instanceof ie?new i(e.debugData):e).toString()}}});var Me=C(()=>{g1();x1();N_();V1();Rf();B_();W1()});function s2(n=!0){let e=HTMLCanvasElement.prototype;if(!n&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(t,i){if(t==="webgl"||t==="experimental-webgl"){let r=this.originalGetContext("webgl2",i);return r instanceof HTMLElement&&I6(r),r}return this.originalGetContext(t,i)}}function I6(n){n.getExtension("EXT_color_buffer_float");let e={...M6,WEBGL_disjoint_timer_query:n.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:A6(n),OES_vertex_array_object:k6(n),ANGLE_instanced_arrays:R6(n)},t=n.getExtension.bind(n);n.getExtension=function(r){let s=t(r);return s||(r in e?e[r]:null)};let i=n.getSupportedExtensions;n.getSupportedExtensions=function(){return(i.apply(n)||[])?.concat(Object.keys(e))}}var M6,A6,k6,R6,o2=C(()=>{M6={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},A6=n=>({drawBuffersWEBGL(e){return n.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),k6=n=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return n.createVertexArray()},deleteVertexArrayOES(e){return n.deleteVertexArray(e)},isVertexArrayOES(e){return n.isVertexArray(e)},bindVertexArrayOES(e){return n.bindVertexArray(e)}}),R6=n=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return n.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return n.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return n.vertexAttribDivisor(...e)}})});async function c2(){if(!Gf){Z_();return}await Gf.load()}function l2(n,e){return Gf?Gf.makeDebugContext(n,e):(Z_(),n)}async function u2(n){if(!q_){Z_();return}await q_.load(n)}function f2(n){return q_?.initialize(n)||null}function Z_(){a2||(a2=!0,N.warn("Import @luma.gl/webgl/debug before enabling WebGL debugging.")())}var Gf,q_,a2,X_=C(()=>{J();Gf=null,q_=null,a2=!1});function K_(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Ie(n,e,t){return e[n]!==void 0?e[n]:t[n]}var Oc,Ue,d2,Ot,h2,Bc,p2,m2,Q_,ei,J_,g2,ey=C(()=>{Oc={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},Ue=(n,e,t)=>e?n.enable(t):n.disable(t),d2=(n,e,t)=>n.hint(t,e),Ot=(n,e,t)=>n.pixelStorei(t,e),h2=(n,e,t)=>{let i=t===36006?36009:36008;return n.bindFramebuffer(i,e)},Bc=(n,e,t)=>{let r={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[t];n.bindBuffer(r,e)};p2={3042:Ue,32773:(n,e)=>n.blendColor(...e),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(n,e)=>n.clearColor(...e),3107:(n,e)=>n.colorMask(...e),2884:Ue,2885:(n,e)=>n.cullFace(e),2929:Ue,2931:(n,e)=>n.clearDepth(e),2932:(n,e)=>n.depthFunc(e),2928:(n,e)=>n.depthRange(...e),2930:(n,e)=>n.depthMask(e),3024:Ue,35723:d2,35725:(n,e)=>n.useProgram(e),36007:(n,e)=>n.bindRenderbuffer(36161,e),36389:(n,e)=>n.bindTransformFeedback?.(36386,e),34229:(n,e)=>n.bindVertexArray(e),36006:h2,36010:h2,34964:Bc,36662:Bc,36663:Bc,35053:Bc,35055:Bc,2886:(n,e)=>n.frontFace(e),33170:d2,2849:(n,e)=>n.lineWidth(e),32823:Ue,32824:"polygonOffset",10752:"polygonOffset",35977:Ue,32926:Ue,32928:Ue,32938:"sampleCoverage",32939:"sampleCoverage",3089:Ue,3088:(n,e)=>n.scissor(...e),2960:Ue,2961:(n,e)=>n.clearStencil(e),2968:(n,e)=>n.stencilMaskSeparate(1028,e),36005:(n,e)=>n.stencilMaskSeparate(1029,e),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(n,e)=>n.viewport(...e),34383:Ue,10754:Ue,12288:Ue,12289:Ue,12290:Ue,12291:Ue,12292:Ue,12293:Ue,12294:Ue,12295:Ue,3333:Ot,3317:Ot,37440:Ot,37441:Ot,37443:Ot,3330:Ot,3332:Ot,3331:Ot,3314:Ot,32878:Ot,3316:Ot,3315:Ot,32877:Ot,framebuffer:(n,e)=>{let t=e&&"handle"in e?e.handle:e;return n.bindFramebuffer(36160,t)},blend:(n,e)=>e?n.enable(3042):n.disable(3042),blendColor:(n,e)=>n.blendColor(...e),blendEquation:(n,e)=>{let t=typeof e=="number"?[e,e]:e;n.blendEquationSeparate(...t)},blendFunc:(n,e)=>{let t=e?.length===2?[...e,...e]:e;n.blendFuncSeparate(...t)},clearColor:(n,e)=>n.clearColor(...e),clearDepth:(n,e)=>n.clearDepth(e),clearStencil:(n,e)=>n.clearStencil(e),colorMask:(n,e)=>n.colorMask(...e),cull:(n,e)=>e?n.enable(2884):n.disable(2884),cullFace:(n,e)=>n.cullFace(e),depthTest:(n,e)=>e?n.enable(2929):n.disable(2929),depthFunc:(n,e)=>n.depthFunc(e),depthMask:(n,e)=>n.depthMask(e),depthRange:(n,e)=>n.depthRange(...e),dither:(n,e)=>e?n.enable(3024):n.disable(3024),derivativeHint:(n,e)=>{n.hint(35723,e)},frontFace:(n,e)=>n.frontFace(e),mipmapHint:(n,e)=>n.hint(33170,e),lineWidth:(n,e)=>n.lineWidth(e),polygonOffsetFill:(n,e)=>e?n.enable(32823):n.disable(32823),polygonOffset:(n,e)=>n.polygonOffset(...e),sampleCoverage:(n,e)=>n.sampleCoverage(e[0],e[1]||!1),scissorTest:(n,e)=>e?n.enable(3089):n.disable(3089),scissor:(n,e)=>n.scissor(...e),stencilTest:(n,e)=>e?n.enable(2960):n.disable(2960),stencilMask:(n,e)=>{e=K_(e)?e:[e,e];let[t,i]=e;n.stencilMaskSeparate(1028,t),n.stencilMaskSeparate(1029,i)},stencilFunc:(n,e)=>{e=K_(e)&&e.length===3?[...e,...e]:e;let[t,i,r,s,o,a]=e;n.stencilFuncSeparate(1028,t,i,r),n.stencilFuncSeparate(1029,s,o,a)},stencilOp:(n,e)=>{e=K_(e)&&e.length===3?[...e,...e]:e;let[t,i,r,s,o,a]=e;n.stencilOpSeparate(1028,t,i,r),n.stencilOpSeparate(1029,s,o,a)},viewport:(n,e)=>n.viewport(...e)};m2={blendEquation:(n,e,t)=>n.blendEquationSeparate(Ie(32777,e,t),Ie(34877,e,t)),blendFunc:(n,e,t)=>n.blendFuncSeparate(Ie(32969,e,t),Ie(32968,e,t),Ie(32971,e,t),Ie(32970,e,t)),polygonOffset:(n,e,t)=>n.polygonOffset(Ie(32824,e,t),Ie(10752,e,t)),sampleCoverage:(n,e,t)=>n.sampleCoverage(Ie(32938,e,t),Ie(32939,e,t)),stencilFuncFront:(n,e,t)=>n.stencilFuncSeparate(1028,Ie(2962,e,t),Ie(2967,e,t),Ie(2963,e,t)),stencilFuncBack:(n,e,t)=>n.stencilFuncSeparate(1029,Ie(34816,e,t),Ie(36003,e,t),Ie(36004,e,t)),stencilOpFront:(n,e,t)=>n.stencilOpSeparate(1028,Ie(2964,e,t),Ie(2965,e,t),Ie(2966,e,t)),stencilOpBack:(n,e,t)=>n.stencilOpSeparate(1029,Ie(34817,e,t),Ie(34818,e,t),Ie(34819,e,t))},Q_={enable:(n,e)=>n({[e]:!0}),disable:(n,e)=>n({[e]:!1}),pixelStorei:(n,e,t)=>n({[e]:t}),hint:(n,e,t)=>n({[e]:t}),useProgram:(n,e)=>n({35725:e}),bindRenderbuffer:(n,e,t)=>n({36007:t}),bindTransformFeedback:(n,e,t)=>n({36389:t}),bindVertexArray:(n,e)=>n({34229:e}),bindFramebuffer:(n,e,t)=>{switch(e){case 36160:return n({36006:t,36010:t});case 36009:return n({36006:t});case 36008:return n({36010:t});default:return null}},bindBuffer:(n,e,t)=>{let i={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[e];return i?n({[i]:t}):{valueChanged:!0}},blendColor:(n,e,t,i,r)=>n({32773:new Float32Array([e,t,i,r])}),blendEquation:(n,e)=>n({32777:e,34877:e}),blendEquationSeparate:(n,e,t)=>n({32777:e,34877:t}),blendFunc:(n,e,t)=>n({32969:e,32968:t,32971:e,32970:t}),blendFuncSeparate:(n,e,t,i,r)=>n({32969:e,32968:t,32971:i,32970:r}),clearColor:(n,e,t,i,r)=>n({3106:new Float32Array([e,t,i,r])}),clearDepth:(n,e)=>n({2931:e}),clearStencil:(n,e)=>n({2961:e}),colorMask:(n,e,t,i,r)=>n({3107:[e,t,i,r]}),cullFace:(n,e)=>n({2885:e}),depthFunc:(n,e)=>n({2932:e}),depthRange:(n,e,t)=>n({2928:new Float32Array([e,t])}),depthMask:(n,e)=>n({2930:e}),frontFace:(n,e)=>n({2886:e}),lineWidth:(n,e)=>n({2849:e}),polygonOffset:(n,e,t)=>n({32824:e,10752:t}),sampleCoverage:(n,e,t)=>n({32938:e,32939:t}),scissor:(n,e,t,i,r)=>n({3088:new Int32Array([e,t,i,r])}),stencilMask:(n,e)=>n({2968:e,36005:e}),stencilMaskSeparate:(n,e,t)=>n({[e===1028?2968:36005]:t}),stencilFunc:(n,e,t,i)=>n({2962:e,2967:t,2963:i,34816:e,36003:t,36004:i}),stencilFuncSeparate:(n,e,t,i,r)=>n({[e===1028?2962:34816]:t,[e===1028?2967:36003]:i,[e===1028?2963:36004]:r}),stencilOp:(n,e,t,i)=>n({2964:e,2965:t,2966:i,34817:e,34818:t,34819:i}),stencilOpSeparate:(n,e,t,i,r)=>n({[e===1028?2964:34817]:t,[e===1028?2965:34818]:i,[e===1028?2966:34819]:r}),viewport:(n,e,t,i,r)=>n({2978:[e,t,i,r]})},ei=(n,e)=>n.isEnabled(e),J_={3042:ei,2884:ei,2929:ei,3024:ei,32823:ei,32926:ei,32928:ei,3089:ei,2960:ei,35977:ei},g2=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068])});function bn(n,e){if(B6(e))return;let t={};for(let r in e){let s=Number(r),o=p2[r];o&&(typeof o=="string"?t[o]=!0:o(n,e[r],s))}let i=n.lumaState?.cache;if(i)for(let r in t){let s=m2[r];s(n,e,i)}}function Vf(n,e=Oc){if(typeof e=="number"){let r=e,s=J_[r];return s?s(n,r):n.getParameter(r)}let t=Array.isArray(e)?e:Object.keys(e),i={};for(let r of t){let s=J_[r];i[r]=s?s(n,Number(r)):n.getParameter(Number(r))}return i}function _2(n){bn(n,Oc)}function B6(n){for(let e in n)return!1;return!0}var Po=C(()=>{ey()});function b2(n,e){if(n===e)return!0;if(y2(n)&&y2(e)&&n.length===e.length){for(let t=0;t{});function x2(n,e){let t=n[e].bind(n);n[e]=function(r){if(r===void 0||g2.has(r))return t(r);let s=vn.get(n);return r in s.cache||(s.cache[r]=t(r)),s.enable?s.cache[r]:t(r)},Object.defineProperty(n[e],"name",{value:`${e}-from-cache`,configurable:!1})}function O6(n,e,t){if(!n[e])return;let i=n[e].bind(n);n[e]=function(...s){let o=vn.get(n),{valueChanged:a,oldValue:c}=t(o._updateCache,...s);return a&&i(...s),c},Object.defineProperty(n[e],"name",{value:`${e}-to-cache`,configurable:!1})}function D6(n){let e=n.useProgram.bind(n);n.useProgram=function(i){let r=vn.get(n);r.program!==i&&(e(i),r.program=i)}}var vn,ty=C(()=>{Po();v2();ey();vn=class{static get(e){return e.lumaState}gl;program=null;stateStack=[];enable=!0;cache=null;log;initialized=!1;constructor(e,t){this.gl=e,this.log=t?.log||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){let e=this.stateStack[this.stateStack.length-1];bn(this.gl,e),this.stateStack.pop()}trackState(e,t){if(this.cache=t?.copyState?Vf(e):Object.assign({},Oc),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.lumaState=this,D6(e);for(let i in Q_){let r=Q_[i];O6(e,i,r)}x2(e,"getParameter"),x2(e,"isEnabled")}_updateCache(e){let t=!1,i,r=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let s in e){let o=e[s],a=this.cache[s];b2(o,a)||(t=!0,i=a,r&&!(s in r)&&(r[s]=a),this.cache[s]=o)}return{valueChanged:t,oldValue:i}}}});function Dc(n){let e=n.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return e._polyfilled??=!1,e.extensions||={},n.luma=e,e}var ny=C(()=>{});function w2(n,e,t){let i="",r=c=>{let l=c.statusMessage;l&&(i||=l)};n.addEventListener("webglcontextcreationerror",r,!1);let s=t.failIfMajorPerformanceCaveat!==!0,o={preserveDrawingBuffer:!0,...t,failIfMajorPerformanceCaveat:!0},a=null;try{a||=n.getContext("webgl2",o),!a&&o.failIfMajorPerformanceCaveat&&(i||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.");let c=!1;if(!a&&s&&(o.failIfMajorPerformanceCaveat=!1,a=n.getContext("webgl2",o),c=!0),a||(a=n.getContext("webgl",{}),a&&(a=null,i||="Your browser only supports WebGL1")),!a)throw i||="Your browser does not support WebGL",new Error(`Failed to create WebGL context: ${i}`);let l=Dc(a);l.softwareRenderer=c;let{onContextLost:u,onContextRestored:f}=e;return n.addEventListener("webglcontextlost",d=>u(d),!1),n.addEventListener("webglcontextrestored",d=>f(d),!1),a}finally{n.removeEventListener("webglcontextcreationerror",r,!1)}}var E2=C(()=>{ny()});function xn(n,e,t){return t[e]===void 0&&(t[e]=n.getExtension(e)||null),t[e]}var Nc=C(()=>{});function S2(n,e){let t=n.getParameter(7936),i=n.getParameter(7937);xn(n,"WEBGL_debug_renderer_info",e);let r=e.WEBGL_debug_renderer_info,s=n.getParameter(r?r.UNMASKED_VENDOR_WEBGL:7936),o=n.getParameter(r?r.UNMASKED_RENDERER_WEBGL:7937),a=s||t,c=o||i,l=n.getParameter(7938),u=P2(a,c),f=N6(a,c),d=F6(a,c);return{type:"webgl",gpu:u,gpuType:d,gpuBackend:f,vendor:a,renderer:c,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function P2(n,e){return/NVIDIA/i.exec(n)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(n)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(n)||/Apple/i.exec(e)?"apple":/AMD/i.exec(n)||/AMD/i.exec(e)||/ATI/i.exec(n)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(n)||/SwiftShader/i.exec(e)?"software":"unknown"}function N6(n,e){return/Metal/i.exec(n)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(n)||/ANGLE/i.exec(e)?"opengl":"unknown"}function F6(n,e){if(/SwiftShader/i.exec(n)||/SwiftShader/i.exec(e))return"cpu";switch(P2(n,e)){case"apple":return z6(n,e)?"integrated":"unknown";case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function z6(n,e){return/Apple (M\d|A\d|GPU)/i.test(`${n} ${e}`)}var C2=C(()=>{Nc()});function Wf(n){switch(n){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(n))}var iy=C(()=>{});function M2(n){return n in Hf}function cy(n,e,t){return A2(n,e,t,new Set)}function A2(n,e,t,i){let r=Hf[e];if(!r||i.has(e))return!1;i.add(e);let s=(r.features||[]).every(o=>A2(n,o,t,i));return i.delete(e),s?(r.extensions||[]).every(o=>!!xn(n,o,t)):!1}function k2(n,e,t){let i=e.create,r=Yf[e.format];r?.gl===void 0&&(i=!1),r?.x&&(i=i&&!!xn(n,r.x,t)),e.format==="stencil8"&&(i=!1);let s=r?.r===!1?!1:r?.r===void 0||cy(n,r.r,t),o=i&&e.render&&s&&Y6(n,e.format,t);return{format:e.format,create:i&&e.create,render:o,filter:i&&e.filter,blend:i&&e.blend,store:i&&e.store}}function Y6(n,e,t){let i=Yf[e],r=i?.gl;if(r===void 0||i?.x&&!xn(n,i.x,t))return!1;let s=n.getParameter(32873),o=n.getParameter(36006),a=n.createTexture(),c=n.createFramebuffer();if(!a||!c)return!1;let l=0,u=Number(n.getError());for(;u!==l;)u=n.getError();let f=!1;try{if(n.bindTexture(3553,a),n.texStorage2D(3553,1,r,1,1),Number(n.getError())!==l)return!1;n.bindFramebuffer(36160,c),n.framebufferTexture2D(36160,36064,3553,a,0),f=Number(n.checkFramebufferStatus(36160))===36053&&Number(n.getError())===l}finally{n.bindFramebuffer(36160,o),n.deleteFramebuffer(c),n.bindTexture(3553,s),n.deleteTexture(a)}return f}function qf(n){let e=Yf[n],t=Z6(n),i=ft.getInfo(n);return i.compressed&&(e.dataFormat=t),{internalFormat:t,format:e?.dataFormat||q6(i.channels,i.integer,i.normalized,t),type:i.dataType?Wf(i.dataType):e?.types?.[0]||5121,compressed:i.compressed||!1}}function R2(n){switch(ft.getInfo(n).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${n}`)}}function q6(n,e,t,i){if(i===6408||i===6407)return i;switch(n){case"r":return e&&!t?36244:6403;case"rg":return e&&!t?33320:33319;case"rgb":return e&&!t?36248:6407;case"rgba":return e&&!t?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function Z6(n){let t=Yf[n]?.gl;if(t===void 0)throw new Error(`Unsupported texture format ${n}`);return t}var Fc,zc,Co,To,U6,$6,G6,V6,W6,j6,T2,L2,ry,sy,oy,ay,jf,H6,Hf,Yf,Lo=C(()=>{J();Nc();iy();Fc="WEBGL_compressed_texture_s3tc",zc="WEBGL_compressed_texture_s3tc_srgb",Co="EXT_texture_compression_rgtc",To="EXT_texture_compression_bptc",U6="WEBGL_compressed_texture_etc",$6="WEBGL_compressed_texture_astc",G6="WEBGL_compressed_texture_etc1",V6="WEBGL_compressed_texture_pvrtc",W6="WEBGL_compressed_texture_atc",j6="EXT_texture_norm16",T2="EXT_render_snorm",L2="EXT_color_buffer_float",ry="snorm8-renderable-webgl",sy="norm16-renderable-webgl",oy="snorm16-renderable-webgl",ay="float16-renderable-webgl",jf="float32-renderable-webgl",H6="rgb9e5ufloat-renderable-webgl",Hf={"float32-renderable-webgl":{extensions:[L2]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[T2]},"norm16-webgl":{extensions:[j6]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[T2]},"float32-filterable":{extensions:["OES_texture_float_linear"]},"float16-filterable-webgl":{extensions:["OES_texture_half_float_linear"]},"texture-filterable-anisotropic-webgl":{extensions:["EXT_texture_filter_anisotropic"]},"texture-blend-float-webgl":{extensions:["EXT_float_blend"]},"texture-compression-bc":{extensions:[Fc,zc,Co,To]},"texture-compression-bc5-webgl":{extensions:[Co]},"texture-compression-bc7-webgl":{extensions:[To]},"texture-compression-etc2":{extensions:[U6]},"texture-compression-astc":{extensions:[$6]},"texture-compression-etc1-webgl":{extensions:[G6]},"texture-compression-pvrtc-webgl":{extensions:[V6]},"texture-compression-atc-webgl":{extensions:[W6]}};Yf={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:ry},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:ry},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0,r:ay},r16unorm:{gl:33322,rb:!0,r:sy},r16snorm:{gl:36760,r:oy},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759,r:ry},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:ay},rg16unorm:{gl:33324,r:sy},rg16snorm:{gl:36761,r:oy},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:jf},rgb9e5ufloat:{gl:35901,r:H6},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852,r:!1},"rgb16snorm-webgl":{gl:36762,r:!1},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0,r:jf},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:ay},rgba16unorm:{gl:32859,rb:!0,r:sy},rgba16snorm:{gl:36763,r:oy},"rgb32float-webgl":{gl:34837,x:L2,r:jf,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:jf},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:Fc},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:zc},"bc1-rgba-unorm":{gl:33777,x:Fc},"bc1-rgba-unorm-srgb":{gl:35916,x:zc},"bc2-rgba-unorm":{gl:33778,x:Fc},"bc2-rgba-unorm-srgb":{gl:35918,x:zc},"bc3-rgba-unorm":{gl:33779,x:Fc},"bc3-rgba-unorm-srgb":{gl:35919,x:zc},"bc4-r-unorm":{gl:36283,x:Co},"bc4-r-snorm":{gl:36284,x:Co},"bc5-rg-unorm":{gl:36285,x:Co},"bc5-rg-snorm":{gl:36286,x:Co},"bc6h-rgb-ufloat":{gl:36495,x:To},"bc6h-rgb-float":{gl:36494,x:To},"bc7-rgba-unorm":{gl:36492,x:To},"bc7-rgba-unorm-srgb":{gl:36493,x:To},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37816},"astc-10x5-unorm-srgb":{gl:37848},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rgb2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}}});var I2,Zf,B2=C(()=>{J();Nc();Lo();I2={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","html-in-canvas":n=>Om()&&typeof n.texElementImage2D=="function","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},Zf=class extends Ta{gl;extensions;testedFeatures=new Set;constructor(e,t,i){super([],i),this.gl=e,this.extensions=t,xn(e,"EXT_color_buffer_float",t)}*[Symbol.iterator](){let e=this.getFeatures();for(let t of e)this.has(t)&&(yield t);return[]}has(e){return this.disabledFeatures?.[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),M2(e)&&cy(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){let e=this.getFeatures().filter(t=>t!=="polygon-mode-webgl");for(let t of e)this.has(t)}getFeatures(){return[...Object.keys(I2),...Object.keys(Hf)]}getWebGLFeature(e){let t=I2[e];return typeof t=="string"?!!xn(this.gl,t,this.extensions):typeof t=="function"?t(this.gl):!!t}}});var Xf,O2=C(()=>{J();Xf=class extends Ca{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxBindGroupsPlusVertexBuffers(){return 0}get maxBindingsPerBindGroup(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageBuffersInVertexStage(){return 0}get maxStorageBuffersInFragmentStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxStorageTexturesInVertexStage(){return 0}get maxStorageTexturesInFragmentStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get maxBufferSize(){return Number.MAX_SAFE_INTEGER}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxColorAttachments(){return this.getParameter(36063)}get maxColorAttachmentBytesPerSample(){return 0}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]||0}}});function X6(n){return n<34069?n+34069:n}function K6(n){switch(n){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${n}`}}var ti,Kf=C(()=>{J();Lo();ti=class extends Rr{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(e,t){super(e,t);let i=t.handle,r=i===null;this.device=e,this.gl=e.gl,this.handle=i||r?i:this.gl.createFramebuffer(),r||(e._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),t.handle||(this.autoCreateAttachmentTextures(),this.updateAttachments()))}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&!this.props.handle&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){let e=this.gl.bindFramebuffer(36160,this.handle);for(let t=0;t{J();Kf();Qf=class extends La{device;handle=null;_framebuffer=null;get[Symbol.toStringTag](){return"WebGLCanvasContext"}constructor(e,t){super(t),this.device=e,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._configureDevice()}_configureDevice(){(this.drawingBufferWidth!==this._framebuffer?.width||this.drawingBufferHeight!==this._framebuffer?.height)&&this._framebuffer?.resize([this.drawingBufferWidth,this.drawingBufferHeight])}_getCurrentFramebuffer(){return this._framebuffer||=new ti(this.device,{id:"canvas-context-framebuffer",handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}}});var Jf,N2=C(()=>{J();Jf=class extends Ma{device;handle=null;context2d;get[Symbol.toStringTag](){return"WebGLPresentationContext"}constructor(e,t={}){super(t),this.device=e;let i=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw new Error(`${i}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);let s=this.canvas.getContext("2d");if(!s)throw new Error(`${i}: Failed to create 2d presentation context`);this.context2d=s,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();let e=this.device.getDefaultCanvasContext(),[t,i]=e.getDrawingBufferSize();if(!(this.drawingBufferWidth===0||this.drawingBufferHeight===0||t===0||i===0||e.canvas.width===0||e.canvas.height===0)){if(t!==this.drawingBufferWidth||i!==this.drawingBufferHeight||e.canvas.width!==this.drawingBufferWidth||e.canvas.height!==this.drawingBufferHeight)throw new Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${t}x${i} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(e.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(e){let t=this.device.getDefaultCanvasContext();return t.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),t.getCurrentFramebuffer(e)}}});function F2(n="id"){ly[n]=ly[n]||1;let e=ly[n]++;return`${n}-${e}`}var ly,z2=C(()=>{ly={}});function Q6(n){return n&ie.INDEX?34963:n&ie.VERTEX?34962:n&ie.UNIFORM?35345:34962}function J6(n){return n&ie.INDEX||n&ie.VERTEX?35044:n&ie.UNIFORM?35048:35044}var wn,ed=C(()=>{J();wn=class extends ie{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength=0;bytesUsed=0;constructor(e,t={}){super(e,t),this.device=e,this.gl=this.device.gl;let i=typeof t=="object"?t.handle:void 0;this.handle=i||this.gl.createBuffer(),e._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=Q6(this.props.usage),this.glUsage=J6(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,t.data?this._initWithData(t.data,t.byteOffset,t.byteLength):this._initWithByteLength(t.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Buffer"):(this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle)),this.destroyed=!0,this.handle=null)}_initWithData(e,t=0,i=e.byteLength+t){let r=this.glTarget;this.gl.bindBuffer(r,this.handle),this.gl.bufferData(r,i,this.glUsage),this.gl.bufferSubData(r,t,e),this.gl.bindBuffer(r,null),this.bytesUsed=i,this.byteLength=i,this._setDebugData(e,t,i),this.props.handle?this.trackReferencedMemory(i,"Buffer"):this.trackAllocatedMemory(i)}_initWithByteLength(e){let t=e;e===0&&(t=new Float32Array(0));let i=this.glTarget;return this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,t,this.glUsage),this.gl.bindBuffer(i,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.props.handle?this.trackReferencedMemory(e,"Buffer"):this.trackAllocatedMemory(e),this}write(e,t=0){let i=ArrayBuffer.isView(e)?e:new Uint8Array(e),r=0,s=void 0,o=36663;this.gl.bindBuffer(o,this.handle),r!==0||s!==void 0?this.gl.bufferSubData(o,t,i,r,s):this.gl.bufferSubData(o,t,i),this.gl.bindBuffer(o,null),this._setDebugData(e,t,e.byteLength)}async mapAndWriteAsync(e,t=0,i=this.byteLength-t){let r=new ArrayBuffer(i);await e(r,"copied"),this.write(r,t)}async readAsync(e=0,t){return this.readSyncWebGL(e,t)}async mapAndReadAsync(e,t=0,i){let r=await this.readAsync(t,i);return await e(r.buffer,"copied")}readSyncWebGL(e=0,t){t=t??this.byteLength-e;let i=new Uint8Array(t),r=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,i,r,t),this.gl.bindBuffer(36662,null),this._setDebugData(i,e,t),i}}});function U2(n){let e=n.split(/\r?\n/),t=[];for(let i of e){if(i.length<=1)continue;let r=i.trim(),s=i.split(":"),o=s[0]?.trim();if(s.length===2){let[h,p]=s;if(!h||!p){t.push({message:r,type:td(o||"info"),lineNum:0,linePos:0});continue}t.push({message:p.trim(),type:td(h),lineNum:0,linePos:0});continue}let[a,c,l,...u]=s;if(!a||!c||!l){t.push({message:s.slice(1).join(":").trim()||r,type:td(o||"info"),lineNum:0,linePos:0});continue}let f=parseInt(l,10);Number.isNaN(f)&&(f=0);let d=parseInt(c,10);Number.isNaN(d)&&(d=0),t.push({message:u.join(":").trim(),type:td(a),lineNum:f,linePos:d})}return t}function td(n){let e=["warning","error","info"],t=n.toLowerCase();return e.includes(t)?t:"info"}var $2=C(()=>{});function ez(n){return n.split(/\r?\n/).find(e=>e.trim())?.trim()}var nd,G2=C(()=>{J();$2();nd=class extends kr{device;handle;_compilationInfoLog="";constructor(e,t){super(e,t),this.device=e;let i=this.props.handle;switch(this.props.stage){case"vertex":this.handle=i||this.device.gl.createShader(35633);break;case"fragment":this.handle=i||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}e._setWebGLDebugMetadata(this.handle,this,{spector:this.props});let r=this._compile(this.source);r&&typeof r.catch=="function"&&r.catch(()=>{this.compilationStatus="error"})}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this._getCompilationInfoLog();return e?U2(e):[]}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)||null}_compile(e){e=e.startsWith("#version ")?e:`#version 300 es +${e}`;let{gl:t}=this.device;if(t.shaderSource(this.handle,e),t.compileShader(this.handle),!this.device.props.debug){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus==="error")throw new Error(this._getCompilationErrorMessage(e));return}return N.once(1,"Shader compilation is asynchronous")(),this._waitForCompilationComplete().then(()=>{N.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()})}async _waitForCompilationComplete(){let e=async r=>await new Promise(s=>setTimeout(s,r));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error",this.compilationStatus==="error"&&this._getCompilationInfoLog()}_getCompilationErrorMessage(e){let t=`${this.props.stage} shader ${this.props.id}`,i=ez(this._getCompilationInfoLog()),r=this.getCompilationInfoSync(),s=r.find(u=>u.type==="error"&&u.message.trim())||r.find(u=>u.message.trim())||r.find(u=>u.type==="error")||r[0];if(!s)return i?`GLSL compilation errors in ${t}: ${i}`:`GLSL compilation errors in ${t}: WebGL did not provide a shader compiler log`;let o=s.lineNum?e.split(/\r?\n/)[s.lineNum-1]?.trim():void 0,a=s.lineNum?` line ${s.lineNum}`:"",c=o?` +Source: ${o}`:"",l=s.message.trim()||i||"WebGL did not provide a shader compiler log";return`GLSL compilation errors in ${t}:${a}: ${l}${c}`}_getCompilationInfoLog(){let e=this.device.gl.getShaderInfoLog(this.handle)?.trim();return e&&(this._compilationInfoLog=e),this._compilationInfoLog}}});function W2(n,e,t,i){if(rz(e))return i(n);let r=n;r.pushState();try{return tz(n,e),bn(r.gl,t),i(n)}finally{r.popState()}}function tz(n,e){let t=n,{gl:i}=t;if(e.cullMode)switch(e.cullMode){case"none":i.disable(2884);break;case"front":i.enable(2884),i.cullFace(1028);break;case"back":i.enable(2884),i.cullFace(1029);break}if(e.frontFace&&i.frontFace(ss("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&n.features.has("depth-clip-control")&&i.enable(34383),e.depthBias!==void 0&&(i.enable(32823),i.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&n.features.has("provoking-vertex-webgl")){let s=t.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,o=ss("provokingVertex",e.provokingVertex,{first:36429,last:36430});s?.provokingVertexWEBGL(o)}if((e.polygonMode||e.polygonOffsetLine)&&n.features.has("polygon-mode-webgl")){if(e.polygonMode){let s=t.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,o=ss("polygonMode",e.polygonMode,{fill:6914,line:6913});s?.polygonModeWEBGL(1028,o),s?.polygonModeWEBGL(1029,o)}e.polygonOffsetLine&&i.enable(10754)}if(n.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&i.enable(12288),e.clipDistance1&&i.enable(12289),e.clipDistance2&&i.enable(12290),e.clipDistance3&&i.enable(12291),e.clipDistance4&&i.enable(12292),e.clipDistance5&&i.enable(12293),e.clipDistance6&&i.enable(12294),e.clipDistance7&&i.enable(12295)),e.depthWriteEnabled!==void 0&&i.depthMask(iz("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?i.enable(2929):i.disable(2929),i.depthFunc(rd("depthCompare",e.depthCompare))),e.clearDepth!==void 0&&i.clearDepth(e.clearDepth),e.stencilWriteMask){let r=e.stencilWriteMask;i.stencilMaskSeparate(1028,r),i.stencilMaskSeparate(1029,r)}if(e.stencilReadMask&&N.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){let r=e.stencilReadMask||4294967295,s=rd("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?i.enable(2960):i.disable(2960),i.stencilFuncSeparate(1028,s,0,r),i.stencilFuncSeparate(1029,s,0,r)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){let r=uy("stencilPassOperation",e.stencilPassOperation),s=uy("stencilFailOperation",e.stencilFailOperation),o=uy("stencilDepthFailOperation",e.stencilDepthFailOperation);i.stencilOpSeparate(1028,s,o,r),i.stencilOpSeparate(1029,s,o,r)}switch(e.blend){case!0:i.enable(3042);break;case!1:i.disable(3042);break;default:}if(e.blendColorOperation||e.blendAlphaOperation){let r=V2("blendColorOperation",e.blendColorOperation||"add"),s=V2("blendAlphaOperation",e.blendAlphaOperation||"add");i.blendEquationSeparate(r,s);let o=id("blendColorSrcFactor",e.blendColorSrcFactor||"one"),a=id("blendColorDstFactor",e.blendColorDstFactor||"zero"),c=id("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),l=id("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");i.blendFuncSeparate(o,a,c,l)}}function rd(n,e){return ss(n,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function uy(n,e){return ss(n,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function V2(n,e){return ss(n,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function id(n,e,t="color"){return ss(n,e,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:t==="color"?32769:32771,"one-minus-constant":t==="color"?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function nz(n,e){return`Illegal parameter ${e} for ${n}`}function ss(n,e,t){if(!(e in t))throw new Error(nz(n,e));return t[e]}function iz(n,e){return e}function rz(n){let e=!0;for(let t in n){e=!1;break}return e}var fy=C(()=>{J();Po()});function sd(n){let e={};return n.addressModeU&&(e[10242]=dy(n.addressModeU)),n.addressModeV&&(e[10243]=dy(n.addressModeV)),n.addressModeW&&(e[32882]=dy(n.addressModeW)),n.magFilter&&(e[10240]=hy(n.magFilter)),(n.minFilter||n.mipmapFilter)&&(e[10241]=sz(n.minFilter||"linear",n.mipmapFilter)),n.lodMinClamp!==void 0&&(e[33082]=n.lodMinClamp),n.lodMaxClamp!==void 0&&(e[33083]=n.lodMaxClamp),n.type==="comparison-sampler"&&(e[34892]=34894),n.compare&&(e[34893]=rd("compare",n.compare)),n.maxAnisotropy&&(e[34046]=n.maxAnisotropy),e}function dy(n){switch(n){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function hy(n){switch(n){case"nearest":return 9728;case"linear":return 9729}}function sz(n,e="none"){if(!e)return hy(n);switch(e){case"none":return hy(n);case"nearest":switch(n){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(n){case"nearest":return 9986;case"linear":return 9987}}}var py=C(()=>{fy()});var od,j2=C(()=>{J();py();od=class extends Mr{device;handle;parameters;constructor(e,t){super(e,t),this.device=e,this.parameters=sd(t),this.handle=t.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(let[t,i]of Object.entries(e)){let r=Number(t);switch(r){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,r,i);break;default:this.device.gl.samplerParameteri(this.handle,r,i);break}}}}});function En(n,e,t){if(oz(e))return t(n);let{nocatch:i=!0}=e,r=vn.get(n);r.push(),bn(n,e);let s;if(i)s=t(n),r.pop();else try{s=t(n)}finally{r.pop()}return s}function oz(n){for(let e in n)return!1;return!0}var ad=C(()=>{Po();ty()});var ni,my=C(()=>{J();ni=class extends Ar{device;gl;handle;texture;constructor(e,t){super(e,{...me.defaultProps,...t}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=t.texture}}});function cd(n){return az[n]}var az,gy=C(()=>{az={5124:"sint32",5125:"uint32",5122:"sint16",5123:"uint16",5120:"sint8",5121:"uint8",5126:"float32",5131:"float16",33635:"uint16",32819:"uint16",32820:"uint16",33640:"uint32",35899:"uint32",35902:"uint32",34042:"uint32",36269:"uint32"}});function cz(n,e=0){return e?new n.constructor(n.buffer,n.byteOffset+e,(n.byteLength-e)/n.BYTES_PER_ELEMENT):n}function lz(n,e){if(e%n.BYTES_PER_ELEMENT!==0)throw new Error(`Texture byteOffset ${e} must align to typed array element size ${n.BYTES_PER_ELEMENT}`);return e/n.BYTES_PER_ELEMENT}function uz(n){switch(n){case"1d":break;case"2d":return 3553;case"3d":return 32879;case"cube":return 34067;case"2d-array":return 35866;case"cube-array":break}throw new Error(n)}function Uc(n,e,t){return e==="cube"?34069+t:n}var ii,ld=C(()=>{J();Lo();py();ad();my();gy();ii=class extends me{device;gl;handle;sampler=void 0;view;glTarget;glFormat;glType;glInternalFormat;compressed;_textureUnit=0;_framebuffer=null;_framebufferAttachmentKey=null;constructor(e,t){super(e,t,{byteAlignment:1}),this.device=e,this.gl=this.device.gl;let i=qf(this.props.format);if(this.glTarget=uz(this.props.dimension),this.glInternalFormat=i.internalFormat,this.glFormat=i.format,this.glType=i.type,this.compressed=i.compressed,this.isHandleBorrowed&&this.props.handle===void 0)throw new Error("Borrowed WebGL textures require a texture handle");if(this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),!this.isHandleBorrowed){this.gl.bindTexture(this.glTarget,this.handle);let{dimension:r,width:s,height:o,depth:a,mipLevels:c,glTarget:l,glInternalFormat:u}=this;if(!this.compressed)switch(r){case"2d":case"cube":this.gl.texStorage2D(l,c,u,s,o);break;case"2d-array":case"3d":this.gl.texStorage3D(l,c,u,s,o,a);break;default:throw new Error(r)}this.gl.bindTexture(this.glTarget,null),this._initializeData(t.data)}this.ownsHandle?this.trackAllocatedMemory(this.getAllocatedByteLength(),"Texture"):this.trackReferencedMemory(this.getAllocatedByteLength(),"Texture"),this.isHandleBorrowed||this.setSampler(this.props.sampler),this.view=new ni(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this._framebuffer?.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.ownsHandle?(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory("Texture")):this.trackDeallocatedReferencedMemory("Texture"),this.destroyed=!0)}createView(e){return new ni(this.device,{...e,texture:this})}clone(e){if(this.isHandleBorrowed&&e&&(e.width!==this.width||e.height!==this.height))throw new Error(`Cannot resize borrowed read-only ${this}`);return super.clone(e)}setSampler(e={}){this._assertWritable("set sampler parameters on"),super.setSampler(e);let t=sd(this.sampler.props);this._setSamplerParameters(t)}copyExternalImage(e){this._assertWritable("copy external image data into");let t=this._normalizeCopyExternalImageOptions(e);if(t.sourceX||t.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");let{glFormat:i,glType:r}=this,{image:s,depth:o,mipLevel:a,x:c,y:l,z:u,width:f,height:d}=t,h=Uc(this.glTarget,this.dimension,u),p=t.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),En(this.gl,p,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(h,a,c,l,f,d,i,r,s);break;case"2d-array":case"3d":this.gl.texSubImage3D(h,a,c,l,u,f,d,o,i,r,s);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:t.width,height:t.height}}copyElementImage(e){this._assertWritable("copy element image data into");let t=this._normalizeCopyElementImageOptions(e),{glFormat:i}=this,{element:r,depth:s,mipLevel:o,sourceX:a,sourceY:c,sourceWidth:l,sourceHeight:u,x:f,y:d,z:h,width:p,height:m}=t,g=Uc(this.glTarget,this.dimension,h),v=t.flipY?{37440:!0}:{},y=this.gl;if(s!==1||this.dimension!=="2d"&&this.dimension!=="cube")throw new Error(`${this} copyElementImage only supports 2d and cube textures on WebGL`);if(o!==0||f!==0||d!==0)throw new Error(`${this} copyElementImage only supports full base-level uploads on WebGL`);if(typeof y.texElementImage2D!="function")throw new Error(`${this} copyElementImage is not supported by this WebGL implementation`);return this.gl.bindTexture(this.glTarget,this.handle),En(this.gl,v,()=>{y.texElementImage2D?.(g,i,r,{sx:a,sy:c,swidth:l??p,sheight:u??m,width:p,height:m})}),this.gl.bindTexture(this.glTarget,null),{width:t.width,height:t.height}}copyImageData(e){super.copyImageData(e)}readBuffer(e={},t){if(!t)throw new Error(`${this} readBuffer requires a destination buffer`);let i=this._getSupportedColorReadOptions(e),r=e.byteOffset??0,s=this.computeMemoryLayout(i);if(t.byteLength{this.gl.readPixels(i.x,i.y,i.width,i.height,this.glFormat,this.glType,r+a)})}finally{this.gl.bindBuffer(35051,null)}return t}async readDataAsync(e={}){throw new Error(`${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`)}writeBuffer(e,t={}){this._assertWritable("write buffer data into");let i=this._normalizeTextureWriteOptions(t),{width:r,height:s,depthOrArrayLayers:o,mipLevel:a,byteOffset:c,x:l,y:u,z:f}=i,{glFormat:d,glType:h,compressed:p}=this,m=Uc(this.glTarget,this.dimension,f);if(p)throw new Error("writeBuffer for compressed textures is not implemented in WebGL");let{bytesPerPixel:g}=this.device.getTextureFormatInfo(this.format),v=g?i.bytesPerRow/g:void 0,y={3317:this.byteAlignment,...v!==void 0?{3314:v}:{},32878:i.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,e.handle),En(this.gl,y,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(m,a,l,u,r,s,d,h,c);break;case"2d-array":case"3d":this.gl.texSubImage3D(m,a,l,u,f,r,s,o,d,h,c);break;default:}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(e,t={}){this._assertWritable("write data into");let i=this._normalizeTextureWriteOptions(t),r=ArrayBuffer.isView(e)?e:new Uint8Array(e),{width:s,height:o,depthOrArrayLayers:a,mipLevel:c,x:l,y:u,z:f,byteOffset:d}=i,{glFormat:h,glType:p,compressed:m}=this,g=Uc(this.glTarget,this.dimension,f),v;if(!m){let{bytesPerPixel:T}=this.device.getTextureFormatInfo(this.format);T&&(v=i.bytesPerRow/T)}let y=this.compressed?{}:{3317:this.byteAlignment,...v!==void 0?{3314:v}:{},32878:i.rowsPerImage},b=lz(r,d),x=m?cz(r,d):r,E=this._getMipLevelSize(c),w=l===0&&u===0&&f===0&&s===E.width&&o===E.height&&a===E.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),En(this.gl,y,()=>{switch(this.dimension){case"2d":case"cube":m?w?this.gl.compressedTexImage2D(g,c,h,s,o,0,x):this.gl.compressedTexSubImage2D(g,c,l,u,s,o,h,x):this.gl.texSubImage2D(g,c,l,u,s,o,h,p,r,b);break;case"2d-array":case"3d":m?w?this.gl.compressedTexImage3D(g,c,h,s,o,a,0,x):this.gl.compressedTexSubImage3D(g,c,l,u,f,s,o,a,h,x):this.gl.texSubImage3D(g,c,l,u,f,s,o,a,h,p,r,b);break;default:}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(e,t){return 1}_getFramebuffer(){return this._framebuffer||=this.device.createFramebuffer({id:`framebuffer-for-${this.id}`,width:this.width,height:this.height,colorAttachments:[this]}),this._framebuffer}readDataSyncWebGL(e={}){let t=this._getSupportedColorReadOptions(e),i=this.computeMemoryLayout(t),r=cd(this.glType),s=Lr(r),o=new s(i.byteLength/s.BYTES_PER_ELEMENT);return this._readColorTextureLayers(t,i,a=>{let c=new s(o.buffer,o.byteOffset+a,i.bytesPerImage/s.BYTES_PER_ELEMENT);this.gl.readPixels(t.x,t.y,t.width,t.height,this.glFormat,this.glType,c)}),o.buffer}_readColorTextureLayers(e,t,i){let r=this._getFramebuffer(),s=t.bytesPerRow/t.bytesPerPixel,o={3333:this.byteAlignment,...s!==e.width?{3330:s}:{}},a=this.gl.getParameter(3074),c=this.gl.bindFramebuffer(36160,r.handle);try{this.gl.readBuffer(36064),En(this.gl,o,()=>{for(let l=0;l=2&&N.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(e))(),this.gl.bindTexture(this.glTarget,this.handle);for(let[t,i]of Object.entries(e)){let r=Number(t),s=i;switch(r){case 33082:case 33083:this.gl.texParameterf(this.glTarget,r,s);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,r,s);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,r,s);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,r,s);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,r,s);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(e){let{gl:t}=this;return e!==void 0&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,this.handle),e}_unbind(e){let{gl:t}=this;return e!==void 0&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,null),e}_assertWritable(e){if(this.isHandleBorrowed)throw new Error(`Cannot ${e} borrowed read-only ${this}`)}}});function H2(n,e,t,i){let r=n,s=i;s===!0&&(s=1),s===!1&&(s=0);let o=typeof s=="number"?[s]:s;switch(t){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof i!="number")throw new Error("samplers must be set to integers");return n.uniform1i(e,i);case 5126:return n.uniform1fv(e,o);case 35664:return n.uniform2fv(e,o);case 35665:return n.uniform3fv(e,o);case 35666:return n.uniform4fv(e,o);case 5124:return n.uniform1iv(e,o);case 35667:return n.uniform2iv(e,o);case 35668:return n.uniform3iv(e,o);case 35669:return n.uniform4iv(e,o);case 35670:return n.uniform1iv(e,o);case 35671:return n.uniform2iv(e,o);case 35672:return n.uniform3iv(e,o);case 35673:return n.uniform4iv(e,o);case 5125:return r.uniform1uiv(e,o,1);case 36294:return r.uniform2uiv(e,o,2);case 36295:return r.uniform3uiv(e,o,3);case 36296:return r.uniform4uiv(e,o,4);case 35674:return n.uniformMatrix2fv(e,!1,o);case 35675:return n.uniformMatrix3fv(e,!1,o);case 35676:return n.uniformMatrix4fv(e,!1,o);case 35685:return r.uniformMatrix2x3fv(e,!1,o);case 35686:return r.uniformMatrix2x4fv(e,!1,o);case 35687:return r.uniformMatrix3x2fv(e,!1,o);case 35688:return r.uniformMatrix3x4fv(e,!1,o);case 35689:return r.uniformMatrix4x2fv(e,!1,o);case 35690:return r.uniformMatrix4x3fv(e,!1,o)}throw new Error("Illegal uniform")}var Y2=C(()=>{});function q2(n){return dz[n]}function ud(n){return fz[n]}function fd(n){return!!X2[n]}function Z2(n){return X2[n]}var fz,X2,dz,dd=C(()=>{fz={5126:"f32",35664:"vec2",35665:"vec3",35666:"vec4",5124:"i32",35667:"vec2",35668:"vec3",35669:"vec4",5125:"u32",36294:"vec2",36295:"vec3",36296:"vec4",35670:"f32",35671:"vec2",35672:"vec3",35673:"vec4",35674:"mat2x2",35685:"mat2x3",35686:"mat2x4",35687:"mat3x2",35675:"mat3x3",35688:"mat3x4",35689:"mat4x2",35690:"mat4x3",35676:"mat4x4"},X2={35678:{viewDimension:"2d",sampleType:"float"},35680:{viewDimension:"cube",sampleType:"float"},35679:{viewDimension:"3d",sampleType:"float"},35682:{viewDimension:"3d",sampleType:"depth"},36289:{viewDimension:"2d-array",sampleType:"float"},36292:{viewDimension:"2d-array",sampleType:"depth"},36293:{viewDimension:"cube",sampleType:"float"},36298:{viewDimension:"2d",sampleType:"sint"},36299:{viewDimension:"3d",sampleType:"sint"},36300:{viewDimension:"cube",sampleType:"sint"},36303:{viewDimension:"2d-array",sampleType:"uint"},36306:{viewDimension:"2d",sampleType:"uint"},36307:{viewDimension:"3d",sampleType:"uint"},36308:{viewDimension:"cube",sampleType:"uint"},36311:{viewDimension:"2d-array",sampleType:"uint"}},dz={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126}});function Q2(n,e,t={}){let i={attributes:[],bindings:[]};i.attributes=hz(n,e);let r=gz(n,e,t);for(let c of r){let l=c.uniforms.map(u=>({name:u.name,format:u.format,byteOffset:u.byteOffset,byteStride:u.byteStride,arrayLength:u.arrayLength}));i.bindings.push({type:"uniform",name:c.name,group:0,location:c.location,visibility:(c.vertex?1:0)|(c.fragment?2:0),minBindingSize:c.byteLength,uniforms:l})}let s=mz(n,e),o=0;for(let c of s)if(fd(c.type)){let{viewDimension:l,sampleType:u}=Z2(c.type);i.bindings.push({type:"texture",name:c.name,group:0,location:o,viewDimension:l,sampleType:u}),c.textureUnit=o,o+=1}s.length&&(i.uniforms=s);let a=pz(n,e);return a?.length&&(i.varyings=a),i}function hz(n,e){let t=[],i=n.getProgramParameter(e,35721);for(let r=0;r=0){let l=ud(a),u=/instance/i.test(o)?"instance":"vertex";t.push({name:o,location:c,stepMode:u,type:l})}}return t.sort((r,s)=>r.location-s.location),t}function pz(n,e){let t=[],i=n.getProgramParameter(e,35971);for(let r=0;rr.location-s.location),t}function mz(n,e){let t=[],i=n.getProgramParameter(e,35718);for(let r=0;r1)for(let h=0;ho.location-a.location),i}function _z(n,e){for(let t of n.uniforms){let i=e.uniforms.find(r=>t.name===r.name||t.name.endsWith(`.${r.name}`));if(!i)throw new Error(`Failed to validate WebGL uniform block "${e.name}": reflected unexpected member "${t.name}"`);if(t.format!==i.format||t.arrayLength!==i.arrayLength||t.byteOffset!==i.byteOffset||t.byteStride!==i.byteStride)throw new Error(`Failed to validate WebGL uniform block "${e.name}": reflected layout for "${t.name}" does not match supplied std140 metadata`)}}function yz(n,e,t){let i=new Map;for(let s of t.uniformBlockLayouts||[])i.set(s.name,vz(s));for(let s of t.shaderLayout?.bindings||[])wz(s)&&i.set(s.name,s);let r=new Map;for(let s of i.values()){let o=bz(n,e,s.name);if(!o)continue;let{blockIndex:a,blockName:c}=o;if(r.has(a))throw new Error(`Multiple supplied uniform block layouts resolve to active WebGL block "${c}"`);r.set(a,{name:c,location:a,byteLength:s.minBindingSize,vertex:!!(s.visibility&&s.visibility&1),fragment:!!(s.visibility&&s.visibility&2),uniformCount:s.uniforms.length,uniforms:s.uniforms.map(l=>({...l}))})}return r}function bz(n,e,t){let i=t.endsWith("Uniforms")?[t,t.slice(0,-8)]:[t,`${t}Uniforms`];for(let r of i){let s=n.getUniformBlockIndex(e,r);if(s!==4294967295){if(!Number.isInteger(s)||s<0)throw new Error(`Failed to resolve WebGL uniform block "${r}": getUniformBlockIndex returned ${String(s)}`);return{blockIndex:s,blockName:r}}}return null}function K2(n,e,t,i){let r=i||n.getActiveUniformBlockName(e,t);if(!r)throw new Error(`Failed to reflect WebGL uniform block at index ${t}: missing block name`);let s=(b,x)=>{let E=n.getActiveUniformBlockParameter(e,t,b);if(E==null)throw new Error(`Failed to reflect WebGL uniform block "${r}": ${x} returned null`);return E},o=os(s(35391,"UNIFORM_BLOCK_BINDING"),r,"UNIFORM_BLOCK_BINDING",0),a=os(s(35392,"UNIFORM_BLOCK_DATA_SIZE"),r,"UNIFORM_BLOCK_DATA_SIZE",0),c=os(s(35394,"UNIFORM_BLOCK_ACTIVE_UNIFORMS"),r,"UNIFORM_BLOCK_ACTIVE_UNIFORMS",0),l=J2(s(35395,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES"),r,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",c),u=$c(n,e,l,35383,"UNIFORM_TYPE",r,c),f=$c(n,e,l,35384,"UNIFORM_SIZE",r,c),d=$c(n,e,l,35386,"UNIFORM_BLOCK_INDEX",r,c),h=$c(n,e,l,35387,"UNIFORM_OFFSET",r,c),p=$c(n,e,l,35388,"UNIFORM_ARRAY_STRIDE",r,c),m=[];for(let b=0;bb.name.split(".")[0]).filter(b=>!!b)),y=g.name.replace(/Uniforms$/,"");if(v.size===1&&!v.has(g.name)&&!v.has(y)){let[b]=v;N.warn(`Uniform block "${g.name}" uses GLSL instance "${b}". luma.gl binds uniform buffers by block name ("${g.name}") and alias ("${y}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}return g}function $c(n,e,t,i,r,s,o){let a=n.getActiveUniforms(e,t,i);if(a===null)throw new Error(`Failed to reflect WebGL uniform block "${s}": ${r} returned null`);return J2(a,s,r,o)}function J2(n,e,t,i){if(!Array.isArray(n)&&!ArrayBuffer.isView(n))throw new Error(`Failed to reflect WebGL uniform block "${e}": ${t} returned a non-array value`);let r=Array.from(n);if(r.length!==i||r.some(s=>!Number.isInteger(s)))throw new Error(`Failed to reflect WebGL uniform block "${e}": ${t} returned ${r.length} invalid values, expected ${i}`);return r}function os(n,e,t,i){if(!Number.isInteger(n)||n{if(typeof o=="string"){let a=e[s];if(!a)throw new Error(`Missing std140 layout field ${s}`);t.push({name:s,format:a.shaderType,arrayLength:1,byteOffset:a.offset*4,byteStride:0});return}if(Array.isArray(o)){r(s,o[0],o[1]);return}for(let[a,c]of Object.entries(o))i(`${s}.${a}`,c)},r=(s,o,a)=>{if(typeof o=="string"){let c=e[`${s}[0]`],l=a>1?e[`${s}[1]`]:void 0;if(!c)throw new Error(`Missing std140 array layout field ${s}[0]`);t.push({name:`${s}[0]`,format:c.shaderType,arrayLength:a,byteOffset:c.offset*4,byteStride:l?(l.offset-c.offset)*4:0});return}if(Array.isArray(o))throw new Error(`Nested uniform arrays are not supported for ${s}`);for(let[c,l]of Object.entries(o)){if(typeof l!="string")throw new Error(`Composite uniform array members are not supported for ${s}`);let u=`${s}[0].${c}`,f=`${s}[1].${c}`,d=e[u],h=a>1?e[f]:void 0;if(!d)throw new Error(`Missing std140 array layout field ${u}`);t.push({name:u,format:d.shaderType,arrayLength:a,byteOffset:d.offset*4,byteStride:h?(h.offset-d.offset)*4:0})}};for(let[s,o]of Object.entries(n))i(s,o);return t}function wz(n){return n.type==="uniform"&&Number.isInteger(n.minBindingSize)&&n.minBindingSize>=0&&Array.isArray(n.uniforms)&&n.uniforms.every(e=>typeof e.name=="string"&&typeof e.format=="string"&&Number.isInteger(e.arrayLength)&&e.arrayLength>0&&Number.isInteger(e.byteOffset)&&e.byteOffset>=0&&Number.isInteger(e.byteStride)&&e.byteStride>=0)}function Ez(n){if(n[n.length-1]!=="]")return{name:n,length:1,isArray:!1};let t=/([^[]*)(\[[0-9]+\])?/.exec(n);return{name:Wi(t?.[1],`Failed to parse GLSL uniform name ${n}`),length:t?.[2]?1:0,isArray:!!t?.[2]}}var eP=C(()=>{J();dd()});function Sz(n,e){let t={...n,attributes:n.attributes.map(i=>({...i})),bindings:n.bindings.map(i=>({...i}))};for(let i of e?.attributes||[]){let r=t.attributes.find(s=>s.name===i.name);r?(r.type=i.type||r.type,r.stepMode=i.stepMode||r.stepMode):N.warn(`shader layout attribute ${i.name} not present in shader`)}for(let i of e?.bindings||[]){let r=nP(t,i.name);if(!r){N.warn(`shader layout binding ${i.name} not present in shader`);continue}Object.assign(r,i)}return t}function nP(n,e){return n.bindings.find(t=>t.name===e||t.name===`${e}Uniforms`||`${t.name}Uniforms`===e)}function tP(n,e){return n[e]||n[`${e}Uniforms`]||n[e.replace(/Uniforms$/,"")]}var hd,iP=C(()=>{J();Y2();ed();Kf();ld();my();eP();hd=class extends Xt{device;handle;vs;fs;introspectedLayout;bindings={};uniforms={};varyings=null;_uniformCount=0;_uniformSetters={};get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}constructor(e,t){super(e,t),this.device=e;let i=this.sharedRenderPipeline||this.device._createSharedRenderPipelineWebGL(t);this.sharedRenderPipeline=i,this.handle=i.handle,this.vs=i.vs,this.fs=i.fs,this.linkStatus=i.linkStatus,this.introspectedLayout=Q2(this.device.gl,this.handle,{uniformBlockLayouts:t._uniformBlockLayouts,shaderLayout:t.shaderLayout}),this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.shaderLayout=t.shaderLayout?Sz(this.introspectedLayout,t.shaderLayout):this.introspectedLayout}destroy(){this.destroyed||(this.sharedRenderPipeline&&!this.props._sharedRenderPipeline&&this.sharedRenderPipeline.destroy(),this.destroyResource())}setBindings(e,t){let i=js(Or(this.shaderLayout,e));for(let[r,s]of Object.entries(i)){let o=nP(this.shaderLayout,r);if(o){switch(s||N.warn(`Unsetting binding "${r}" in render pipeline "${this.id}"`)(),o.type){case"uniform":if(!(s instanceof wn)&&!(s.buffer instanceof wn))throw new Error("buffer value");break;case"texture":if(!(s instanceof ni||s instanceof ii||s instanceof ti))throw new Error(`${this} Bad texture binding for ${r}`);break;case"sampler":N.warn(`Ignoring sampler ${r}`)();break;default:throw new Error(o.type)}this.bindings[r]=s}else{let a=this.shaderLayout.bindings.map(c=>`"${c.name}"`).join(", ");t?.disableWarnings||N.warn(`No binding "${r}" in render pipeline "${this.id}", expected one of ${a}`,s)()}}}draw(e){let t=e.renderPass,i=e.bindGroups?js(e.bindGroups):e.bindings||this.bindings;return t.setPipeline(this),t.setBindings(i),t.setVertexArray(e.vertexArray),t.draw({parameters:e.parameters,topology:e.topology,isInstanced:e.isInstanced,vertexCount:e.vertexCount,indexCount:e.indexCount,instanceCount:e.instanceCount,firstVertex:e.firstVertex,firstIndex:e.firstIndex,firstInstance:e.firstInstance,baseVertex:e.baseVertex,transformFeedback:e.transformFeedback,uniforms:e.uniforms})}_areTexturesRenderable(e){let t=!0;for(let i of this.shaderLayout.bindings)tP(e,i.name)||(N.warn(`Binding ${i.name} not found in ${this.id}`)(),t=!1);return t}_applyBindings(e,t){if(this._syncLinkStatus(),this.linkStatus!=="success")return;let{gl:i}=this.device;i.useProgram(this.handle);let r=0,s=0;for(let o of this.shaderLayout.bindings){let a=tP(e,o.name);if(!a)throw new Error(`No value for binding ${o.name} in ${this.id}`);switch(o.type){case"uniform":let{name:c}=o,l=i.getUniformBlockIndex(this.handle,c);if(l===4294967295)throw new Error(`Invalid uniform block name ${c}`);if(i.uniformBlockBinding(this.handle,l,s),a instanceof wn)i.bindBufferBase(35345,s,a.handle);else{let f=a;i.bindBufferRange(35345,s,f.buffer.handle,f.offset||0,f.size||f.buffer.byteLength-(f.offset||0))}s+=1;break;case"texture":if(!(a instanceof ni||a instanceof ii||a instanceof ti))throw new Error("texture");let u;if(a instanceof ni)u=a.texture;else if(a instanceof ii)u=a;else if(a instanceof ti&&a.colorAttachments[0]instanceof ni)N.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),u=a.colorAttachments[0].texture;else throw new Error("No texture");i.activeTexture(33984+r),i.bindTexture(u.glTarget,u.handle),r+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${o.type}' not supported in WebGL`)}}}_applyUniforms(e){for(let t of this.shaderLayout.uniforms||[]){let{name:i,location:r,type:s,textureUnit:o}=t,a=e[i]??o;a!==void 0&&H2(this.device.gl,r,s,a)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}}});var rP,pd,sP=C(()=>{J();dd();rP=4,pd=class extends ka{device;handle;vs;fs;linkStatus="pending";constructor(e,t){super(e,t),this.device=e,this.handle=t.handle||this.device.gl.createProgram(),this.vs=t.vs,this.fs=t.fs,t.varyings&&t.varyings.length>0&&this.device.gl.transformFeedbackVaryings(this.handle,t.varyings,t.bufferMode||35981),this._linkShaders()}destroy(){this.destroyed||(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.handle.destroyed=!0,this.destroyResource())}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),N.time(rP,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),N.timeEnd(rP,`linkProgram for ${this.id}`)(),!this.device.features.has("compilation-status-async-webgl")){let i=this._getLinkStatus();this._reportLinkStatus(i);return}N.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),N.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let t=this._getLinkStatus();this._reportLinkStatus(t)}async _reportLinkStatus(e){switch(e){case"success":return;default:let t=e==="link-error"?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${t} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader();break;case"success":break}switch(this.fs?.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`${this} ${t} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader();break;case"success":break}let i=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${t} during ${e}: ${i}`),this)(),this.device.debug()}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(this._initializeSamplerUniforms(),e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}_initializeSamplerUniforms(){let{gl:e}=this.device;e.useProgram(this.handle);let t=0,i=e.getProgramParameter(this.handle,35718);for(let r=0;r1){let o=Int32Array.from({length:t.size},(a,c)=>r+c);return s.uniform1iv(e,o),r+t.size}return s.uniform1i(e,r),r+1}async _waitForLinkComplete(){let e=async r=>await new Promise(s=>setTimeout(s,r));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getProgramParameter(this.handle,37297))return;await e(10)}}}});function Pz(n,e){let t=e.sourceBuffer,i=e.destinationBuffer;n.gl.bindBuffer(36662,t.handle),n.gl.bindBuffer(36663,i.handle),n.gl.copyBufferSubData(36662,36663,e.sourceOffset??0,e.destinationOffset??0,e.size),n.gl.bindBuffer(36662,null),n.gl.bindBuffer(36663,null)}function Cz(n,e){let{sourceBuffer:t,byteOffset:i=0,destinationTexture:r,mipLevel:s=0,origin:o=[0,0,0],aspect:a="all",bytesPerRow:c,rowsPerImage:l,size:u}=e;if(a!=="all")throw new Error("copyBufferToTexture aspect is not supported in WebGL");r.writeBuffer(t,{byteOffset:i,bytesPerRow:c,rowsPerImage:l,mipLevel:s,x:o[0]??0,y:o[1]??0,z:o[2]??0,width:u[0],height:u[1],depthOrArrayLayers:u[2]})}function Tz(n,e){let{sourceTexture:t,mipLevel:i=0,aspect:r="all",width:s=e.sourceTexture.width,height:o=e.sourceTexture.height,depthOrArrayLayers:a,origin:c=[0,0,0],destinationBuffer:l,byteOffset:u=0,bytesPerRow:f,rowsPerImage:d}=e;if(t instanceof me){t.readBuffer({x:c[0]??0,y:c[1]??0,z:c[2]??0,width:s,height:o,depthOrArrayLayers:a,mipLevel:i,aspect:r,byteOffset:u},l);return}if(r!=="all")throw new Error("aspect not supported in WebGL");if(i!==0||a!==void 0||f||d)throw new Error("not implemented");let{framebuffer:h,destroyFramebuffer:p}=oP(t),m;try{let g=l,v=s||h.width,y=o||h.height,b=Wi(h.colorAttachments[0]),x=qf(b.texture.props.format),E=x.format,w=x.type;n.gl.bindBuffer(35051,g.handle),m=n.gl.bindFramebuffer(36160,h.handle),n.gl.readPixels(c[0],c[1],v,y,E,w,u)}finally{n.gl.bindBuffer(35051,null),m!==void 0&&n.gl.bindFramebuffer(36160,m),p&&h.destroy()}}function Lz(n,e){let{sourceTexture:t,destinationMipLevel:i=0,origin:r=[0,0],destinationOrigin:s=[0,0,0],destinationTexture:o}=e,{width:a=e.destinationTexture.width,height:c=e.destinationTexture.height}=e,{framebuffer:l,destroyFramebuffer:u}=oP(t),[f=0,d=0]=r,[h,p,m]=s,g=n.gl.bindFramebuffer(36160,l.handle),v,y;if(o instanceof ii)v=o,a=Number.isFinite(a)?a:v.width,c=Number.isFinite(c)?c:v.height,v._bind(0),y=v.glTarget;else throw new Error("invalid destination");switch(y){case 3553:case 34067:n.gl.copyTexSubImage2D(y,i,h,p,f,d,a,c);break;case 35866:case 32879:n.gl.copyTexSubImage3D(y,i,h,p,m,f,d,a,c);break;default:}v&&v._unbind(),n.gl.bindFramebuffer(36160,g),u&&l.destroy()}function oP(n){if(n instanceof me){let{width:e,height:t,id:i}=n;return{framebuffer:n.device.createFramebuffer({id:`framebuffer-for-${i}`,width:e,height:t,colorAttachments:[n]}),destroyFramebuffer:!0}}return{framebuffer:n,destroyFramebuffer:!1}}var md,aP=C(()=>{J();Lo();ld();md=class extends Ba{device;handle=null;commands=[];constructor(e,t={}){super(e,t),this.device=e}_executeCommands(e=this.commands){for(let t of e)switch(t.name){case"copy-buffer-to-buffer":Pz(this.device,t.options);break;case"copy-buffer-to-texture":Cz(this.device,t.options);break;case"copy-texture-to-buffer":Tz(this.device,t.options);break;case"copy-texture-to-texture":Lz(this.device,t.options);break;default:throw new Error(t.name)}}}});function cP(n){switch(n){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"triangle-list":return 4;case"triangle-strip":return 5;default:throw new Error(n)}}function lP(n){switch(n){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;default:throw new Error(n)}}var _y=C(()=>{});var Mz,gd,uP=C(()=>{J();ad();Po();_y();fy();Mz=[1,2,4,8],gd=class extends Ra{device;handle=null;glParameters={};pipeline=null;bindings={};bindingsPipeline=null;vertexArray=null;constructor(e,t){super(e,t),this.device=e;let i=this.props.framebuffer,r=!i||i.handle===null;r&&e.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();let s;if(!t?.parameters?.viewport)if(!r&&i){let{width:o,height:a}=i;s=[0,0,o,a]}else{let[o,a]=e.getDefaultCanvasContext().getDrawingBufferSize();s=[0,0,o,a]}if(this.device.pushState(),this.setParameters({viewport:s,...this.props.parameters}),!r&&i?.colorAttachments.length){let o=i.colorAttachments.map((a,c)=>36064+c);this.device.gl.drawBuffers(o)}else r&&this.device.gl.drawBuffers([1029]);this.clear(),this.props.timestampQuerySet&&this.props.beginTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.beginTimestampIndex)}end(){this.destroyed||(this.props.timestampQuerySet&&this.props.endTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.endTimestampIndex),this.device.popState(),this.destroy())}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}executeBundles(e){throw new Error("Render bundles are only supported in WebGPU")}setParameters(e={}){let t={...this.glParameters};t.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(t.depthMask=!this.props.depthReadOnly),t.stencilMask=this.props.stencilReadOnly?0:1,t[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(t.viewport=e.viewport.slice(0,4),t.depthRange=[e.viewport[4],e.viewport[5]]):t.viewport=e.viewport),e.scissorRect&&(t.scissorTest=!0,t.scissor=e.scissorRect),e.blendConstant&&(t.blendColor=e.blendConstant),e.stencilReference!==void 0&&(t[2967]=e.stencilReference,t[36003]=e.stencilReference),"colorMask"in e&&(t.colorMask=Mz.map(i=>!!(i&e.colorMask))),this.glParameters=t,bn(this.device.gl,t)}setPipeline(e){this.pipeline=e}setBindings(e,t){if(!this.pipeline)throw new Error("RenderPass.setPipeline() must be called before setBindings()");this.bindings=js(Or(this.pipeline.shaderLayout,e)),this.bindingsPipeline=this.pipeline}setVertexArray(e){this.vertexArray=e}draw(e){let t=this.pipeline,i=this.vertexArray;if(!t)throw new Error("RenderPass.setPipeline() must be called before draw()");if(!i)throw new Error("RenderPass.setVertexArray() must be called before draw()");if(t.shaderLayout.bindings.length>0&&this.bindingsPipeline!==t)throw new Error("RenderPass.setBindings() must be called after setPipeline() before draw()");t._syncLinkStatus();let{parameters:r=t.props.parameters,topology:s=t.props.topology,vertexCount:o,indexCount:a,instanceCount:c,isInstanced:l=!1,firstVertex:u=0,transformFeedback:f,uniforms:d=t.uniforms}=e,h=cP(s),p=!!i.indexBuffer,m=i.indexBuffer?.glIndexType,g=a??o??0;if(t.linkStatus!=="success")return N.info(2,`RenderPipeline:${t.id}.draw() aborted - waiting for shader linking`)(),!1;if(!t._areTexturesRenderable(this.bindings))return N.info(2,`RenderPipeline:${t.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(t.handle),i.bindBeforeRender(this);let v=f;return v&&v.begin(t.props.topology),t._applyBindings(this.bindings,{disableWarnings:t.props.disableWarnings}),t._applyUniforms(d),W2(this.device,r,this.glParameters,()=>{p&&l?this.device.gl.drawElementsInstanced(h,g,m,u,c||0):p?this.device.gl.drawElements(h,g,m,u):l?this.device.gl.drawArraysInstanced(h,u,o||0,c||0):this.device.gl.drawArrays(h,u,o||0),v&&v.end()}),i.unbindAfterRender(this),!0}drawIndirect(e,t=0){throw new Error("Indirect drawing is only supported in WebGPU")}drawIndexedIndirect(e,t=0){throw new Error("Indirect drawing is only supported in WebGPU")}beginOcclusionQuery(e){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let e={...this.glParameters},t=0;this.props.clearColors&&this.props.clearColors.forEach((i,r)=>{i&&this.clearColorBuffer(r,i)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(t|=16384,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(t|=256,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(t|=1024,e.clearStencil=this.props.clearStencil),t!==0&&En(this.device.gl,e,()=>{this.device.gl.clear(t)})}clearColorBuffer(e=0,t=[0,0,0,0]){En(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,e,t);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,e,t);break;case Float32Array:this.device.gl.clearBufferfv(6144,e,t);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}});var Gc,fP=C(()=>{J();aP();uP();Gc=class extends Ia{device;handle=null;commandBuffer;constructor(e,t){super(e,t),this.device=e,this.commandBuffer=new md(e,{id:this.id,userData:this.userData})}destroy(){this.destroyResource()}finish(){return this.destroy(),this.commandBuffer}beginRenderPass(e={}){return new gd(this.device,this._applyTimeProfilingToPassProps(e))}beginComputePass(e={}){throw new Error("ComputePass not supported in WebGL")}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,t,i){throw new Error("resolveQuerySet is not supported in WebGL")}writeTimestamp(e,t){e.writeTimestamp(t)}}});function dP(n){let{target:e,source:t,start:i=0,count:r=1}=n,s=t.length,o=r*s,a=0;for(let c=i;a{});function Az(n){return Array.isArray(n)?new Float32Array(n):n}function kz(n,e){if(!n||!e||n.length!==e.length||n.constructor!==e.constructor)return!1;for(let t=0;t{J();vr();iy();hP();_d=class n extends Oa{get[Symbol.toStringTag](){return"VertexArray"}device;handle;attributeInfosByLocation;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return mp()==="Chrome"}constructor(e,t){super(e,t),this.device=e,this.handle=this.device.gl.createVertexArray(),this.attributeInfosByLocation=new Array(this.maxVertexAttributes).fill(null);for(let i of Object.values($a(t.shaderLayout,t.bufferLayout)))this.attributeInfosByLocation[i.location]=i}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){let t=e;if(t&&t.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,t?t.handle:null),this.indexBuffer=t,this.device.gl.bindVertexArray(null)}setBuffer(e,t){let i=t;if(i.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:r,type:s,stride:o,offset:a,normalized:c,integer:l,divisor:u}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,i.handle),l?this.device.gl.vertexAttribIPointer(e,r,s,o,a):this.device.gl.vertexAttribPointer(e,r,s,c,o,a),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,u||0),this.attributes[e]=i,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,t){this._enable(e,!1),this.attributes[e]=t}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e{J();bd();_y();yd=class extends Da{device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(e,t){super(e,t),this.device=e,this.gl=e.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,t.buffers&&this.setBuffers(t.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(e="point-list"){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(lP(e))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(e){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let[t,i]of Object.entries(e))this.setBuffer(t,i)})}setBuffer(e,t){let i=this._getVaryingIndex(e),{buffer:r,byteLength:s,byteOffset:o}=this._getBufferRange(t);if(i<0){this.unusedBuffers[e]=r,N.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[i]={buffer:r,byteLength:s,byteOffset:o},this.bindOnUse||this._bindBuffer(i,r,o,s)}getBuffer(e){if(mP(e))return this.buffers[e]||null;let t=this._getVaryingIndex(e);return this.buffers[t]??null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(36386,e),this;let t;return this._bound?t=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,t=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),t}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof wn)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:t,byteOffset:i=0,byteLength:r=e.buffer.byteLength}=e;return{buffer:t,byteOffset:i,byteLength:r}}_getVaryingIndex(e){if(mP(e))return Number(e);for(let t of this.layout.varyings||[])if(e===t.name)return t.location;return-1}_bindBuffers(){for(let[e,t]of Object.entries(this.buffers)){let{buffer:i,byteLength:r,byteOffset:s}=this._getBufferRange(t);this._bindBuffer(Number(e),i,s,r)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,t,i=0,r){let s=t&&t.handle;!s||r===void 0?this.gl.bindBufferBase(35982,e,s):this.gl.bindBufferRange(35982,e,s,i,r)}}});var vd,_P=C(()=>{J();vd=class extends Na{device;handle;_timestampPairs=[];_pendingReads=new Set;_occlusionQuery=null;_occlusionActive=!1;get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){if(super(e,t),this.device=e,t.type==="timestamp"){if(t.count<2)throw new Error("Timestamp QuerySet requires at least two query slots");this._timestampPairs=new Array(Math.ceil(t.count/2)).fill(null).map(()=>({activeQuery:null,completedQueries:[]})),this.handle=null}else{if(t.count>1)throw new Error("WebGL occlusion QuerySet can only have one value");let i=this.device.gl.createQuery();if(!i)throw new Error("WebGL query not supported");this.handle=i}Object.seal(this)}destroy(){if(!this.destroyed){this.handle&&this.device.gl.deleteQuery(this.handle);for(let e of this._timestampPairs){e.activeQuery&&(this._cancelPendingQuery(e.activeQuery),this.device.gl.deleteQuery(e.activeQuery.handle));for(let t of e.completedQueries)this._cancelPendingQuery(t),this.device.gl.deleteQuery(t.handle)}this._occlusionQuery&&(this._cancelPendingQuery(this._occlusionQuery),this.device.gl.deleteQuery(this._occlusionQuery.handle));for(let e of Array.from(this._pendingReads))this._cancelPendingQuery(e);this.destroyResource()}}isResultAvailable(e){return this.props.type==="timestamp"?e===void 0?this._timestampPairs.some((t,i)=>this._isTimestampPairAvailable(i)):this._isTimestampPairAvailable(this._getTimestampPairIndex(e)):this._occlusionQuery?this._pollQueryAvailability(this._occlusionQuery):!1}async readResults(e){let t=e?.firstQuery||0,i=e?.queryCount||this.props.count-t;if(this._validateRange(t,i),this.props.type==="timestamp"){let r=new Array(i).fill(0n),s=Math.floor(t/2),o=Math.floor((t+i-1)/2);for(let a=s;a<=o;a++){let c=await this._consumeTimestampPairResult(a),l=a*2,u=l+1;l>=t&&l=t&&u=this.props.count||t<=e)throw new Error("Timestamp duration range is out of bounds");if(e%2!==0||t!==e+1)throw new Error("WebGL timestamp durations require adjacent even/odd query indices");let i=await this._consumeTimestampPairResult(this._getTimestampPairIndex(e));return Number(i)/1e6}beginOcclusionQuery(){if(this.props.type!=="occlusion")throw new Error("Occlusion queries require an occlusion QuerySet");if(!this.handle)throw new Error("WebGL occlusion query is not available");if(this._occlusionActive)throw new Error("Occlusion query is already active");this.device.gl.beginQuery(35887,this.handle),this._occlusionQuery={handle:this.handle,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null},this._occlusionActive=!0}endOcclusionQuery(){if(!this._occlusionActive)throw new Error("Occlusion query is not active");this.device.gl.endQuery(35887),this._occlusionActive=!1}writeTimestamp(e){if(this.props.type!=="timestamp")throw new Error("Timestamp writes require a timestamp QuerySet");let t=this._getTimestampPairIndex(e),i=this._timestampPairs[t];if(e%2===0){if(i.activeQuery)throw new Error("Timestamp query pair is already active");let r=this.device.gl.createQuery();if(!r)throw new Error("WebGL query not supported");let s={handle:r,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null};this.device.gl.beginQuery(35007,r),i.activeQuery=s;return}if(!i.activeQuery)throw new Error("Timestamp query pair was ended before it was started");this.device.gl.endQuery(35007),i.completedQueries.push(i.activeQuery),i.activeQuery=null}_validateRange(e,t){if(e<0||t<0||e+t>this.props.count)throw new Error("Query read range is out of bounds")}_getTimestampPairIndex(e){if(e<0||e>=this.props.count)throw new Error("Query index is out of bounds");return Math.floor(e/2)}_isTimestampPairAvailable(e){let t=this._timestampPairs[e];return!t||t.completedQueries.length===0?!1:this._pollQueryAvailability(t.completedQueries[0])}_pollQueryAvailability(e){if(e.cancelled||this.destroyed)return e.result=0n,!0;if(e.result!==null||e.disjoint)return!0;if(!this.device.gl.getQueryParameter(e.handle,34919))return!1;let i=!!this.device.gl.getParameter(36795);return e.disjoint=i,e.result=i?0n:BigInt(this.device.gl.getQueryParameter(e.handle,34918)),!0}async _consumeTimestampPairResult(e){let t=this._timestampPairs[e];if(!t||t.completedQueries.length===0)throw new Error("Timestamp query pair has no completed result");let i=t.completedQueries.shift();try{return await this._consumeQueryResult(i)}finally{this.device.gl.deleteQuery(i.handle)}}_consumeQueryResult(e){return e.promise||(this._pendingReads.add(e),e.promise=new Promise((t,i)=>{e.resolve=t,e.reject=i;let r=()=>{if(e.pollRequestId=null,e.cancelled||this.destroyed){this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,t(0n);return}if(!this._pollQueryAvailability(e)){e.pollRequestId=this._requestAnimationFrame(r);return}this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,e.disjoint?i(new Error("GPU timestamp query was invalidated by a disjoint event")):t(e.result||0n)};r()})),e.promise}_cancelPendingQuery(e){if(this._pendingReads.delete(e),e.cancelled=!0,e.pollRequestId!==null&&(this._cancelAnimationFrame(e.pollRequestId),e.pollRequestId=null),e.resolve){let t=e.resolve;e.promise=null,e.resolve=null,e.reject=null,t(0n)}}_requestAnimationFrame(e){return requestAnimationFrame(e)}_cancelAnimationFrame(e){cancelAnimationFrame(e)}}});var xd,yP=C(()=>{J();xd=class extends Fa{device;gl;handle;signaled;_signaled=!1;constructor(e,t={}){super(e,{}),this.device=e,this.gl=e.gl;let i=this.props.handle||this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE,0);if(!i)throw new Error("Failed to create WebGL fence");this.handle=i,this.signaled=new Promise(r=>{let s=()=>{let o=this.gl.clientWaitSync(this.handle,0,0);o===this.gl.ALREADY_SIGNALED||o===this.gl.CONDITION_SATISFIED?(this._signaled=!0,r()):setTimeout(s,1)};s()})}isSignaled(){if(this._signaled)return!0;let e=this.gl.getSyncParameter(this.handle,this.gl.SYNC_STATUS);return this._signaled=e===this.gl.SIGNALED,this._signaled}destroy(){this.destroyed||this.gl.deleteSync(this.handle)}}});function yy(n){switch(n){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function bP(n){switch(n){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}var vP=C(()=>{});function xP(n,e){let{sourceX:t=0,sourceY:i=0,sourceAttachment:r=0}=e||{},{target:s=null,sourceWidth:o,sourceHeight:a,sourceDepth:c,sourceFormat:l,sourceType:u}=e||{},{framebuffer:f,deleteFramebuffer:d}=EP(n),{gl:h,handle:p}=f;o||=f.width,a||=f.height;let m=f.colorAttachments[r]?.texture;if(!m)throw new Error(`Invalid framebuffer attachment ${r}`);c=m?.depth||1,l||=m?.glFormat||6408,u||=m?.glType||5121,s=Iz(s,u,l,o,a,c);let g=Xe.getDataType(s);u=u||q2(g);let v=h.bindFramebuffer(36160,p);return h.readBuffer(36064+r),h.readPixels(t,i,o,a,l,u,s),h.readBuffer(36064),h.bindFramebuffer(36160,v||null),d&&f.destroy(),s}function wP(n,e){let{target:t,sourceX:i=0,sourceY:r=0,sourceFormat:s=6408,targetByteOffset:o=0}=e||{},{sourceWidth:a,sourceHeight:c,sourceType:l}=e||{},{framebuffer:u,deleteFramebuffer:f}=EP(n);a=a||u.width,c=c||u.height;let d=u;l=l||5121;let h=t;if(!h){let m=yy(s),g=bP(l),v=o+a*c*m*g;h=d.device.createBuffer({byteLength:v})}let p=n.device.createCommandEncoder();return p.copyTextureToBuffer({sourceTexture:n,width:a,height:c,origin:[i,r],destinationBuffer:h,byteOffset:o}),p.destroy(),f&&u.destroy(),h}function EP(n){return n instanceof Rr?{framebuffer:n,deleteFramebuffer:!1}:{framebuffer:Rz(n),deleteFramebuffer:!0}}function Rz(n,e){let{device:t,width:i,height:r,id:s}=n;return t.createFramebuffer({...e,id:`framebuffer-for-${s}`,width:i,height:r,colorAttachments:[n]})}function Iz(n,e,t,i,r,s){if(n)return n;e||=5121;let o=cd(e),a=Xe.getTypedArrayConstructor(o),c=yy(t);return new a(i*r*c)}var SP=C(()=>{J();dd();vP();gy()});function PP(n){let e=new Map;for(let t in n){let i=n[t];if(t<"a"){let r=e.get(i);e.set(i,r?`${r}, GL.${t}`:`GL.${t}`)}}return e}var CP=C(()=>{});var by={};mi(by,{WebGLDevice:()=>nr});function Bz(n,e,t){switch(t.length){case 1:n.gl.vertexAttrib1fv(e,t);break;case 2:n.gl.vertexAttrib2fv(e,t);break;case 3:n.gl.vertexAttrib3fv(e,t);break;case 4:n.gl.vertexAttrib4fv(e,t);break;default:}}function Oz(n,e,t){n.gl.vertexAttribI4iv(e,t)}function Dz(n,e,t){n.gl.vertexAttribI4uiv(e,t)}function Nz(n,e){if(!n||!e||n.length!==e.length||n.constructor!==e.constructor)return!1;for(let t=0;t{J();ty();E2();ny();C2();B2();O2();D2();N2();X_();Lo();z2();ed();G2();j2();ld();Kf();iP();sP();fP();pP();gP();_P();yP();SP();Po();ad();Nc();CP();nr=class n extends bi{static getDeviceFromContext(e){return e?e.luma?.device??null:null}type="webgl";handle;features;limits;info;canvasContext;preferredColorFormat="rgba8unorm";preferredDepthFormat="depth24plus";commandEncoder;lost;_resolveContextLost;_isLost=!1;gl;_glKeyByValue=null;_constants;extensions;_polyfilled=!1;spectorJS;get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(e){switch(e){case"unorm8x4-bgra":return!1;default:return!0}}constructor(e){super({...e,id:e.id||F2("webgl-device")});let t=bi._getCanvasContextProps(e);if(!t)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let i=t.canvas?.gl??null,r=n.getDeviceFromContext(i);if(r)throw new Error(`WebGL context already attached to device ${r.id}`);this.canvasContext=new Qf(this,t),this.lost=new Promise(u=>{this._resolveContextLost=u});let s={...e.webgl};t.alphaMode==="premultiplied"&&(s.premultipliedAlpha=!0),e.powerPreference!==void 0&&(s.powerPreference=e.powerPreference),e.failIfMajorPerformanceCaveat!==void 0&&(s.failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat);let a=this.props._handle||w2(this.canvasContext.canvas,{onContextLost:u=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."}),onContextRestored:u=>{console.log("WebGL context restored")}},s);if(!a)throw new Error("WebGL context creation failed");if(r=n.getDeviceFromContext(a),r){if(e._reuseDevices)return N.log(1,`Not creating a new Device, instead returning a reference to Device ${r.id} already attached to WebGL context`,r)(),this.canvasContext.destroy(),r._reused=!0,r;throw new Error(`WebGL context already attached to device ${r.id}`)}this.handle=a,this.gl=a,this.spectorJS=f2({...this.props,gl:this.handle});let c=Dc(this.handle);c.device=this,c.extensions||(c.extensions={}),this.extensions=c.extensions,this.info=S2(this.gl,this.extensions),this.limits=new Xf(this.gl),this.features=new Zf(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new vn(this.gl,{log:(...u)=>N.log(1,...u)()}).trackState(this.gl,{copyState:!1}),(e.debug||e.debugWebGL)&&(this.gl=l2(this.gl,{debugWebGL:!0,traceWebGL:e.debugWebGL}),N.warn("WebGL debug mode activated. Performance reduced.")()),e.debugWebGL&&(N.level=Math.max(N.level,1)),this.commandEncoder=new Gc(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}destroy(){if(!this.props._reuseDevices&&!this._reused){this._isLost=!0,this.commandEncoder?.destroy();let e=Dc(this.handle);e.device=null}}get isLost(){return this._isLost||this.gl.isContextLost()}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createPresentationContext(e){return new Jf(this,e||{})}createBuffer(e){let t=this._normalizeBufferProps(e);return new wn(this,t)}createTexture(e){return new ii(this,e)}createExternalTexture(e){throw new Error("ExternalTexture is not available on WebGL")}createSampler(e){return new od(this,e)}createShader(e){return new nd(this,e)}createFramebuffer(e){return new ti(this,e)}createVertexArray(e){return new _d(this,e)}createTransformFeedback(e){return new yd(this,e)}createQuerySet(e){return new vd(this,e)}createFence(){return new xd(this)}createRenderPipeline(e){return new hd(this,e)}_createSharedRenderPipelineWebGL(e){return new pd(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}createRenderBundleEncoder(e){throw new Error("Render bundles are only supported in WebGPU")}createCommandEncoder(e={}){return new Gc(this,e)}submit(e){let t=null;e||({submittedCommandEncoder:t,commandBuffer:e}=this._finalizeDefaultCommandEncoderForSubmit());try{e._executeCommands(),t&&t.resolveTimeProfilingQuerySet().then(()=>{this.commandEncoder._gpuTimeMs=t._gpuTimeMs}).catch(()=>{})}finally{e.destroy()}}writeBufferViaCommandEncoder(e,t,i,r=0){t.write(i,r)}_finalizeDefaultCommandEncoderForSubmit(){let e=this.commandEncoder,t=e.finish();return this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:e.props.id,timeProfilingQuerySet:e.getTimeProfilingQuerySet()}),{submittedCommandEncoder:e,commandBuffer:t}}readPixelsToArrayWebGL(e,t){return xP(e,t)}readPixelsToBufferWebGL(e,t){return wP(e,t)}setParametersWebGL(e){bn(this.gl,e)}getParametersWebGL(e){return Vf(this.gl,e)}withParametersWebGL(e,t){return En(this.gl,e,t)}resetWebGL(){N.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),_2(this.gl)}_getDeviceSpecificTextureFormatCapabilities(e){return k2(this.gl,e,this.extensions)}loseDevice(){let e=!1,i=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return i&&(e=!0,i.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){vn.get(this.gl).push()}popState(){vn.get(this.gl).pop()}getGLKey(e,t){let i=this._getGLKeyByValue().get(Number(e));return i||(t?.emptyIfUnknown?"":String(e))}getGLKeys(e){let t={emptyIfUnknown:!0};return Object.entries(e).reduce((i,[r,s])=>(i[`${r}:${this.getGLKey(r,t)}`]=`${s}:${this.getGLKey(s,t)}`,i),{})}_getGLKeyByValue(){return this._glKeyByValue??=PP(this.gl),this._glKeyByValue}setConstantAttributeWebGL(e,t){let i=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(i).fill(null);let r=this._constants[e];switch(r&&Nz(r,t)&&N.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=t,t.constructor){case Float32Array:Bz(this,e,t);break;case Int32Array:Oz(this,e,t);break;case Uint32Array:Dz(this,e,t);break;default:throw new Error("constant")}}getExtension(e){return xn(this.gl,e,this.extensions),this.extensions}_setWebGLDebugMetadata(e,t,i){e.luma=t;let r={props:i.spector,id:i.spector.id};e.__SPECTOR_Metadata=r}}});function Fz(n){return typeof WebGL2RenderingContext<"u"&&n instanceof WebGL2RenderingContext?!0:!!(n&&typeof n.createVertexArray=="function")}function TP(n){return{...n,debug:n.debug??bi.defaultProps.debug,debugWebGL:n.debugWebGL??bi.defaultProps.debugWebGL,debugSpectorJS:n.debugSpectorJS??!!N.get("debug-spectorjs")}}async function LP(n){let e=[];(n.debugWebGL||n.debug)&&e.push(c2()),n.debugSpectorJS&&e.push(u2(n));let t=await Promise.allSettled(e);for(let i of t)i.status==="rejected"&&N.error(`Failed to initialize debug libraries ${i.reason}`)()}var Vc,vy,Wc,MP=C(()=>{J();o2();X_();Vc=1,vy=class extends Ea{type="webgl";enforceWebGL2(e){s2(e)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext&&N.warn("WebGL1 is not supported",e)(),!1)}async attach(e,t={}){let{WebGLDevice:i}=await Promise.resolve().then(()=>(wd(),by));if(e instanceof i)return e;let r=i.getDeviceFromContext(e);if(r)return r;if(!Fz(e))throw new Error("Invalid WebGL2RenderingContext");t=TP(t),await LP(t);let s=t.createCanvasContext===!0?{}:t.createCanvasContext;return new i({...t,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...s}})}async create(e={}){let{WebGLDevice:t}=await Promise.resolve().then(()=>(wd(),by));e=TP(e),await LP(e);try{let i=new t(e);N.groupCollapsed(Vc,`WebGLDevice ${i.id} created`)();let r=`${i._reused?"Reusing":"Created"} device with WebGL2 ${i.props.debug?"debug ":""}context: ${i.info.vendor}, ${i.info.renderer} for canvas: ${i.canvasContext.id}`;return N.probe(Vc,r)(),N.table(Vc,i.info)(),i}finally{N.groupEnd(Vc)(),N.info(Vc,"%cWebGL call tracing: luma.log.set('debug-webgl') ","color: white; background: blue; padding: 2px 6px; border-radius: 3px;")()}}};Wc=new vy});var bd=C(()=>{MP();wd();ed()});function Td(n){return FP.test(n)}function Ld(n){return zP.test(n)}function UP(n){let e=FP.exec(n),t=zP.exec(n),i=e?.[1]??t?.[1]??n;try{Pe.getVertexFormatInfo(i)}catch{throw new Error(`Unsupported GPUVector format ${n}`)}return i}function Ti(n){let e=UP(n),t=Td(n),i=Ld(n),r=Pe.getVertexFormatInfo(e),s=r.type,o=r.normalized,a=Vz(s,o);return{format:n,elementFormat:e,vertexList:t,valueList:i,type:s,signedDataType:Wz(e,s),primitiveType:a,components:r.components,byteLength:r.byteLength,integer:r.integer,signed:r.signed,normalized:o,...r.webglOnly?{webglOnly:!0}:{}}}function Vz(n,e){if(e)return"f32";switch(n){case"float32":return"f32";case"float16":return"f16";case"uint8":case"uint16":case"uint32":return"u32";case"sint8":case"sint16":case"sint32":return"i32";default:throw new Error(`Unsupported GPUVector component type ${n}`)}}function Wz(n,e){if(n==="unorm10-10-10-2")return"uint32";switch(e){case"unorm8":return"uint8";case"snorm8":return"sint8";case"unorm16":return"uint16";case"snorm16":return"sint16";default:return e}}var FP,zP,Md=C(()=>{J();FP=/^vertex-list<([^<>]+)>$/,zP=/^value-list<([^<>]+)>$/});function Ey(n,e){if(!Number.isSafeInteger(n)||n<0)throw new Error(`${e} must be a non-negative safe integer`)}var Li,Sy=C(()=>{J();Li=class{buffer;format;length;byteOffset;byteStride;constructor(e){let t=Pe.getVertexFormatInfo(e.format).byteLength,i=e.byteOffset??0,r=e.byteStride??t;if(Ey(e.length,"GPUDataView length"),Ey(i,"GPUDataView byteOffset"),Ey(r,"GPUDataView byteStride"),re.buffer.byteLength)throw new Error("GPUDataView exceeds its backing buffer byte length");this.buffer=e.buffer,this.format=e.format,this.length=e.length,this.byteOffset=i,this.byteStride=r}get elementByteLength(){return Pe.getVertexFormatInfo(this.format).byteLength}get byteLength(){return this.length===0?0:(this.length-1)*this.byteStride+this.elementByteLength}}});function kd(n){return!!(n&&typeof n=="object"&&n.type==="struct")}function GP(n,e){let t=Object.entries(n);if(t.length===0)throw new Error("GPUData struct format must declare at least one field");return e==="packed"?jz(t):Hz(t)}function jz(n){let e=[],t=0,i=0;for(let[r,s]of n){let o=Pe.getVertexFormatInfo(s);if(o.webglOnly)throw new Error(`Packed GPUData struct field "${r}" uses WebGL-only format ${s}`);t=$P(t,Math.min(4,o.byteLength)),e.push([r,Object.freeze({format:s,byteOffset:t,byteLength:o.byteLength})]),t+=o.byteLength,i+=o.components}return Object.freeze({type:"struct",layout:"packed",fields:Object.freeze(Object.fromEntries(e)),components:i,byteStride:$P(t,4),rowByteLength:t})}function Hz(n){let e=Object.fromEntries(n.map(([o,a])=>[o,Yz(a)])),t=Dr(e,{layout:"wgsl-storage"}),i=[],r=0,s=0;for(let[o,a]of n){let c=Pe.getVertexFormatInfo(a),l=t.fields[o].offset*4;i.push([o,Object.freeze({format:a,byteOffset:l,byteLength:c.byteLength})]),r=Math.max(r,l+c.byteLength),s+=c.components}return Object.freeze({type:"struct",layout:"wgsl-storage",fields:Object.freeze(Object.fromEntries(i)),components:s,byteStride:t.byteLength,rowByteLength:r})}function Yz(n){let e=Pe.getVertexFormatInfo(n);switch(e.type){case"float32":return Ad("f32",e.components);case"sint32":return Ad("i32",e.components);case"uint32":return Ad("u32",e.components);default:{let t=Math.ceil(e.byteLength/4);return Ad("u32",t)}}}function Ad(n,e){return e===1?n:`vec${e}<${n}>`}function $P(n,e){return Math.ceil(n/e)*e}var VP=C(()=>{J()});var Py,Cy,Mo,Ty=C(()=>{Sy();VP();Md();Py=class{buffer;ownsDataBuffer;constructor(e,t){this.buffer=e,this.ownsDataBuffer=t}get ownsBuffer(){return this.ownsDataBuffer}transferBufferOwnership(e){if(e.buffer!==this.buffer)throw new Error("GPUData ownership can only be transferred to the same buffer");e.ownsDataBuffer=this.ownsDataBuffer,this.ownsDataBuffer=!1}destroy(){this.ownsDataBuffer&&(this.buffer.destroy(),this.ownsDataBuffer=!1)}},Cy=class extends Py{dataType;format;length;valueLength;stride;byteOffset;byteStride;rowByteLength;readbackMetadata;valueOffsets;nullBitmap;valueByteLength;constructor(e){let{buffer:t,format:i,length:r,valueLength:s,stride:o,byteOffset:a=0,byteStride:c,rowByteLength:l,ownsBuffer:u=!1,readbackMetadata:f,valueOffsets:d,nullBitmap:h,valueByteLength:p,dataType:m}=e;super(t,u);let g;i?typeof i=="string"?g=i:g=GP(i,e.layout??"wgsl-storage"):g=void 0;let v=kd(g)?g:void 0,y=typeof g=="string"?Ti(g):void 0;if(this.dataType=m,this.format=g,this.length=r,this.valueLength=s??r,this.stride=o??y?.components??v?.components??c??l??1,this.byteOffset=a,this.rowByteLength=l??v?.rowByteLength??y?.byteLength??c??this.stride,this.byteStride=c??v?.byteStride??this.rowByteLength,v){if(this.rowByteLengthi.format!==e))throw new Error("GPUVector data chunks must share the declared format")}var ri,jP=C(()=>{Ty();Md();ri=class{name;dataType;format;length;valueLength;stride;byteOffset;byteStride;rowByteLength;bufferLayout;data=[];device;bufferProps;isAppendable=!1;ownsDataChunks=!0;ownedVectors=[];appendableByteLength=0;constructor(e){switch(e.type){case"buffer":{let{name:t,buffer:i,format:r,length:s,valueLength:o=s,byteOffset:a=0,ownsBuffer:c=!1}=e,{stride:l,byteStride:u,rowByteLength:f}=WP(e);this.name=t,this.dataType=e.dataType,this.format=r,this.length=s,this.valueLength=o,this.stride=l,this.byteOffset=a,this.byteStride=u,this.rowByteLength=f,this.data.push(new Mo({buffer:i,format:r,length:s,valueLength:o,stride:l,byteOffset:a,byteStride:u,rowByteLength:f,ownsBuffer:c,dataType:e.dataType}));return}case"interleaved":{let{name:t,buffer:i,format:r,length:s,valueLength:o=s,byteOffset:a=0,byteStride:c,attributes:l,ownsBuffer:u=!1}=e;this.name=t,this.dataType=e.dataType,this.format=r,this.length=s,this.valueLength=o,this.stride=c,this.byteOffset=a,this.byteStride=c,this.rowByteLength=c,this.bufferLayout={name:t,byteStride:c,attributes:l},this.data.push(new Mo({buffer:i,format:r,length:s,valueLength:o,stride:c,byteOffset:a,byteStride:c,rowByteLength:c,ownsBuffer:u,dataType:e.dataType}));return}case"data":{let t=e.format??qz(e.data),i=t?Ti(t):void 0,{name:r,data:s,stride:o=s[0]?.stride??i?.components??1,valueLength:a=s.reduce((d,h)=>d+h.valueLength,0),byteStride:c=s[0]?.byteStride??i?.byteLength,rowByteLength:l=s[0]?.rowByteLength??i?.byteLength,bufferLayout:u,ownsData:f=!1}=e;if(c===void 0||l===void 0)throw new Error("GPUVector requires format or explicit byte layout metadata");t&&Zz(s,t),this.name=r,this.dataType=e.dataType,this.format=t,this.length=s.reduce((d,h)=>d+h.length,0),this.valueLength=a,this.stride=o,this.byteOffset=s.length===1?s[0].byteOffset:0,this.byteStride=c,this.rowByteLength=l,this.bufferLayout=u,this.ownsDataChunks=f,this.data.push(...s);return}case"appendable":{let{name:t,device:i,format:r,valueLength:s=0,bufferProps:o}=e,{stride:a,byteStride:c,rowByteLength:l}=WP(e);this.name=t,this.dataType=e.dataType,this.format=r,this.length=0,this.valueLength=s,this.stride=a,this.byteOffset=0,this.byteStride=c,this.rowByteLength=l,this.device=i,this.bufferProps=o,this.isAppendable=!0;return}}}get ownsBuffer(){return this.ownsDataChunks&&this.data.some(e=>e.ownsBuffer)||this.ownedVectors.some(e=>e.ownsBuffer)}get capacityRows(){return this.isAppendable?this.length:void 0}get appendedByteLength(){return this.appendableByteLength}addData(e){if(this.format&&e.format!==this.format)throw new Error("GPUVector.addData() requires matching formats");if(e.byteStride!==this.byteStride)throw new Error("GPUVector.addData() requires matching byteStride");if(e.rowByteLength!==this.rowByteLength)throw new Error("GPUVector.addData() requires matching rowByteLength");return this.data.push(e),this.length+=e.length,this.valueLength+=e.valueLength,this}appendDataChunk(e,t=this.appendableByteLength+e.buffer.byteLength){if(!this.isAppendable)throw new Error("GPUVector.appendDataChunk() requires appendable vector storage");if(this.format&&e.format!==this.format)throw new Error("GPUVector.appendDataChunk() requires matching formats");if(e.byteStride!==this.byteStride||e.rowByteLength!==this.rowByteLength)throw new Error("GPUVector.appendDataChunk() requires matching byte layout metadata");return this.data.push(e),this.length+=e.length,this.valueLength+=e.valueLength,this.appendableByteLength=t,this}resetLastBatch(){if(!this.isAppendable)throw new Error("GPUVector.resetLastBatch() requires appendable vector storage");for(let e of this.data.splice(0))e.destroy();return this.length=0,this.valueLength=0,this.appendableByteLength=0,this}retainOwnedVectors(e){return this.ownedVectors.push(...e),this}transferBufferOwnership(e){let t=this.data[0],i=e.data[0];if(!t||!i||t.buffer!==i.buffer)throw new Error("GPUVector ownership can only be transferred to the same buffer");t.transferBufferOwnership(i)}destroy(){if(this.ownsDataChunks)for(let e of this.data)e.destroy();for(let e of this.ownedVectors.splice(0))e.destroy()}}});var Ly=C(()=>{Ty();Sy();jP();Md()});var My,pt,Zc=C(()=>{J();My=class{poolSize=20;bufferPools;constructor(){this.bufferPools=new Map}createOrReuse(e,t){if(t>e.limits.maxBufferSize)throw new Error(`Buffer pool cannot allocate ${t} bytes: device.limits.maxBufferSize is ${e.limits.maxBufferSize}`);let i=this.bufferPools.get(e),r=i?i.findIndex(o=>o.byteLength>=t):-1;if(r<0)return e.createBuffer({usage:ie.VERTEX|ie.STORAGE|ie.COPY_DST|ie.COPY_SRC,byteLength:t});let[s]=i.splice(r,1);return s}recycle(e){let t=e.device;this.bufferPools.has(t)||this.bufferPools.set(t,[]);let i=this.bufferPools.get(t),r=i.findIndex(s=>s.byteLength>e.byteLength);r<0?i.push(e):i.splice(r,0,e),this.purge()}purge(){for(let[e,t]of this.bufferPools){let i=e.isLost?0:this.poolSize;for(;t.length>i;)t.shift().destroy();t.length===0&&this.bufferPools.delete(e)}}},pt=new My});function Xz(n,e,t,i){let{ValueType:r,size:s,offset:o,stride:a}=n,c=a/r.BYTES_PER_ELEMENT,l=o/r.BYTES_PER_ELEMENT,u=i-t;if(c===s){let d=l+t*c;return e.subarray(d,d+u*s)}let f=new r(u*s);for(let d=0;d0)throw new Error(`GPUDataEvaluator requires exactly one GPUData chunk for "${n.name}"`);return e}function Jz(n){let e=[];return YP(n,e,{byteOffset:0}),e}function YP(n,e,t){let i=n.source;if(i&&!(i instanceof ve)&&i.name==="interleave"){for(let r of Object.values(i.inputs))r instanceof ve&&YP(r,e,t);return}e.push({attribute:n.id??n.toString(),format:qP(n.type,n.size,n.normalized),byteOffset:t.byteOffset}),t.byteOffset+=n.ValueType.BYTES_PER_ELEMENT*n.size}function qP(n,e,t=!1){if(e<1||e>4)throw new Error(`Cannot synthesize a GPUVector vertex format with ${e} components`);let i=n;if(t)switch(n){case"uint8":i="unorm8";break;case"sint8":i="snorm8";break;case"uint16":i="unorm16";break;case"sint16":i="snorm16";break;case"float32":i="float32";break;default:throw new Error(`Unsupported normalized vertex format for ${n}`)}return(i==="uint8"||i==="sint8"||i==="uint16"||i==="sint16"||i==="unorm8"||i==="snorm8"||i==="unorm16"||i==="snorm16")&&e===3?`${i}x3-webgl`:`${i}${e===1?"":`x${e}`}`}function eU(n,e,t=!1){return e>=1&&e<=4?qP(n,e,t):void 0}var ve,Mi=C(()=>{J();Me();Ly();Zc();ve=class n{static get bufferPoolSize(){return pt.poolSize}static set bufferPoolSize(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("GPUDataEvaluator.bufferPoolSize must be a non-negative safe integer");pt.poolSize=e,pt.purge()}type;size;get offset(){return this._offset}get stride(){return this._stride}normalized;isConstant;length;get byteLength(){return this._byteLength}ValueType;source=null;format;_id;_destroyed=!1;_value;_offset;_stride;_byteLength;_gpuVector;_bufferOwnership="owned";_targetBuffer;static fromArray(e,{type:t,size:i=1,offset:r=0,stride:s=0,normalized:o=!1}){let a=t,c;if(Array.isArray(e)){a=a||"float32";let u=Tr(a);c=new u(e)}else e instanceof Float64Array?(a="uint32",i*=2,r*=2,s*=2,c=new Uint32Array(e.buffer,e.byteOffset,e.byteLength/4)):(a=a||Lu(e),c=e);let l=`<${a} * ${i}>`;return new n({id:l,type:a,size:i,offset:r,stride:s,normalized:o,value:c})}static fromConstant(e,t="float32"){let i=Tr(t),r;return Array.isArray(e)?r=`[${e.join(",")}]`:(r=String(e),e=[e]),new n({id:r,isConstant:!0,type:t,size:e.length,value:new i(e)})}static fromGPUData(e,t={}){Kz(e);let i=new Li({buffer:e.buffer,format:e.format,length:e.length,byteOffset:e.byteOffset,byteStride:e.byteStride});return new n({...HP(i),id:t.id,gpuData:e})}static fromGPUDataView(e,t={}){return new n({...HP(e),id:t.id,buffer:e.buffer})}constructor(e){let{id:t,value:i,buffer:r,gpuData:s,format:o,source:a=null,isConstant:c=!1}=e;if(!a&&!i&&!r&&!s)throw new Error("GPUDataEvaluator must have a value source");let{type:l,size:u,offset:f,stride:d,normalized:h,length:p}=e;if(a instanceof n?(l=l??a.type,u=u??a.size,f=f??a.offset,d=d??a.stride,h=h??a.normalized,p=p??a.length):(u=u??1,f=f??0,h=h??!1,p=c?1:p),!l)throw new Error("GPUDataEvaluator: type not defined");if(this._id=t,this.type=l,this.size=u,this.ValueType=Tr(this.type),this._offset=f,this._stride=d||this.ValueType.BYTES_PER_ELEMENT*u,this.normalized=h,this.source=a,this.format=o,p===void 0)if(c)p=1;else{if(!i)throw new Error("GPUDataEvaluator: length not defined");p=Math.ceil(i.byteLength/this.stride)}this.isConstant=c,this.length=p;let m=this.ValueType.BYTES_PER_ELEMENT*this.size;this._byteLength=p===0?0:(p-1)*this.stride+m,this._value=i,this._bufferOwnership=a instanceof n||r||s?"borrowed":"owned",s?this._gpuVector=new ri({type:"data",name:this._id??"data",format:s.format,data:[s],stride:s.stride,byteStride:s.byteStride,rowByteLength:s.rowByteLength}):r&&(this._gpuVector=this.createGPUVectorView({buffer:r,name:this._id,format:this.format}))}get value(){return this._value||(this.source instanceof n?this.source.value:void 0)}get evaluated(){return!!this._gpuVector}get id(){return this._id}get gpuVector(){if(!this._gpuVector)throw new Error(`${this} not evaluated`);return this._gpuVector}get buffer(){return Rd(this.gpuVector)}setTargetBuffer({buffer:e,byteOffset:t=0,byteStride:i=this.stride}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)throw new Error(`GPUDataEvaluator ${this} already evaluated`);if(!this.source||this.source instanceof n)throw new Error("GPUDataEvaluator target buffers require a deferred operation source");this._targetBuffer={buffer:e,byteOffset:t,byteStride:i}}async evaluate(e,t={}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let i;if(this.source instanceof n){let r=await this.source.evaluate(e);return this._gpuVector=this.createGPUVectorView({...t,buffer:Rd(r)}),this._gpuVector}if(i=this._getEvaluationBuffer(e),this._value)i.write(this._value);else{let r=await this.source.execute(e,i);if(!r.success)throw r.error||new Error(`${this.source} evaluation failed`);r.value&&(this._value=r.value)}return this._gpuVector=this.createGPUVectorView({...t,buffer:i}),this._gpuVector}evaluateSync(e,t={}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let i;if(this.source instanceof n){let r=this.source.evaluateSync(e);return this._gpuVector=this.createGPUVectorView({...t,buffer:Rd(r)}),this._gpuVector}if(i=this._getEvaluationBuffer(e),this._value)i.write(this._value);else{let r=this.source.executeSync(e,i);if(!r.success)throw r.error||new Error(`${this.source} evaluation failed`);r.value&&(this._value=r.value)}return this._gpuVector=this.createGPUVectorView({...t,buffer:i}),this._gpuVector}createGPUVectorView(e){let t=e.name??this._id??"vector",i=e.format??this.format??eU(this.type,this.size,this.normalized);if(e.interleaved){let r=typeof e.interleaved=="object"&&e.interleaved.attributes?e.interleaved.attributes:Jz(this);return new ri({type:"interleaved",name:t,buffer:e.buffer,format:e.format??this.format,length:this.length,byteOffset:this.offset,byteStride:this.stride,attributes:r,ownsBuffer:!1})}return new ri({type:"buffer",name:t,buffer:e.buffer,format:i,length:this.length,stride:this.size,byteOffset:this.offset,byteStride:this.stride,rowByteLength:this.ValueType.BYTES_PER_ELEMENT*this.size,ownsBuffer:!1})}_getEvaluationBuffer(e){let t=this._targetBuffer;if(!t)return pt.createOrReuse(e,this.byteLength);if(t.buffer.device!==e)throw new Error("GPUDataEvaluator target buffer belongs to a different device");let i=this.ValueType.BYTES_PER_ELEMENT*this.size,r=this.length===0?0:(this.length-1)*t.byteStride+i;if(t.byteOffset+r>t.buffer.byteLength)throw new Error("GPUDataEvaluator target buffer is too small for the output layout");return this._offset=t.byteOffset,this._stride=t.byteStride,this._byteLength=r,this._bufferOwnership="borrowed",this._targetBuffer=void 0,t.buffer}async readValue(e=0,t){let{ValueType:i}=this,{size:r,offset:s,stride:o,length:a}=this,c=i.BYTES_PER_ELEMENT*r;if(t=t??a,e=Math.max(0,Math.min(a,e)),t=Math.max(e,Math.min(a,t)),this._value)return Xz(this,this._value,e,t);let l=t-e;if(l===0)return new i(0);let u=s+e*o,f=o===c?l*c:(l-1)*o+c,d=await this.buffer.readAsync(u,f),h=new i(d.buffer,d.byteOffset,d.byteLength/i.BYTES_PER_ELEMENT);if(o===c)return h;let p=new Uint8Array(c*l);for(let m=0;m{Ao={add:{arity:2,symbol:"arithmetic_add"},subtract:{arity:2,symbol:"arithmetic_subtract"},multiply:{arity:2,symbol:"arithmetic_multiply"},divide:{arity:2,symbol:"arithmetic_divide"},pow:{arity:2,symbol:"pow"},sqrt:{arity:1,symbol:"sqrt"},abs:{arity:1,symbol:"abs"},sin:{arity:1,symbol:"sin"},cos:{arity:1,symbol:"cos"},tan:{arity:1,symbol:"arithmetic_tan"},exp:{arity:1,symbol:"exp"},log:{arity:1,symbol:"log"}}});function lC(n,{operations:e,inputs:t}){switch(n.kind){case"input":if(!(n.name in t))throw new Error(`Unknown expression input '${n.name}'`);return;case"literal":if(Array.isArray(n.value)){for(let i of n.value)if(!Number.isFinite(i))throw new Error(`Expression literal array must contain only finite values, got ${i}`)}else if(!Number.isFinite(n.value))throw new Error(`Expression literal must be finite, got ${n.value}`);return;case"call":{let i=e[n.op];if(!i)throw new Error(`Unknown expression op '${n.op}'`);if(n.args.length!==i.arity)throw new Error(`Expression op '${n.op}' expects ${i.arity} args, got ${n.args.length}`);for(let r of n.args)lC(r,{operations:e,inputs:t});return}default:{let i=n;throw new Error(`Unsupported expression node ${i.kind}`)}}}function Od(n,e){return lC(n,e),uC(n,e)}function uC(n,e){switch(n.kind){case"input":{let t=e.inputs[n.name];return e.laneIndexuC(r,e));return e.formatCall(t.symbol,i)}default:{let t=n;throw new Error(`Unsupported expression node ${t.kind}`)}}}var Iy=C(()=>{});function it(n,e,t=!1){if(t)return e===1?"float":`vec${e}`;switch(n){case"uint8":case"uint16":case"uint32":return e===1?"uint":`uvec${e}`;case"sint8":case"sint16":case"sint32":return e===1?"int":`ivec${e}`;default:return e===1?"float":`vec${e}`}}function Dd(n,e,t=!1){let i;if(t)switch(n){case"uint8":i="unorm8";break;case"sint8":i="snorm8";break;case"uint16":i="unorm16";break;case"sint16":i="snorm16";break;case"float32":i="float32";break;default:throw new Error(`Unsupported normalized vertex format for ${n}`)}else i=n;return e===1?i:e===3&&!i.startsWith("float32")&&!i.endsWith("32")?`${i}x3-webgl`:`${i}x${e}`}function ir(n){switch(n[0]){case"u":return"0u";case"s":return"0";default:return"0."}}function fC(n,e){switch(n){case"uint8":case"uint16":case"uint32":return`${Math.trunc(e)}u`;case"sint8":case"sint16":case"sint32":return`${Math.trunc(e)}`;default:return Number.isInteger(e)?`${e}.0`:`${e}`}}function dC(n){switch(n){case"uint8":return"r8uint";case"sint8":return"r8sint";case"uint16":return"r16uint";case"sint16":return"r16sint";case"uint32":return"r32uint";case"sint32":return"r32sint";case"float32":return"r32float";default:throw new Error(`Unsupported WebGL gather texture format for ${n}`)}}function hC(n){switch(n){case"uint32":return"usampler2D";case"sint32":return"isampler2D";case"float32":return"sampler2D";default:throw new Error(`Unsupported WebGL gather sampler type for ${n}`)}}var Ro=C(()=>{});function rt({module:n,elementWise:e=!1,expression:t,inputs:i,output:r,operationType:s=r.type,outputBuffer:o}){let a=o.device,c=cs("result",r.type,r.size,r.normalized),l=[n,c],u=[],f={},d=it(r.type,1,r.normalized),h=it(s,1,r.normalized),p="",m=null,g={TYPE:h,RESULT_LEN:r.size.toString()},v=lU(i);for(let[E,w]of v)l.push(By(E,w.type,w.size,w.normalized,s)),u.push(Oy(E,w)),w instanceof ve?f[E]=w.buffer:(m=m||pt.createOrReuse(a,o.byteLength),f[E]=m),p+=`TYPE ${E}[${w.size}]; get_${E}(${E}); +`,g[`${E.toUpperCase()}_LEN`]=w.size.toString();let y="";if(t)for(let E=0;EEE).join(", ")}, result);`;let b=`#version 300 es void main() { @@ -2538,21 +2538,21 @@ ${d} result[${r.size}]; ${y} set_result(result); } - `,w=new it(a,{vs:b,shaderAssembler:sU,defines:g,modules:l,bufferLayout:u,vertexCount:1,instanceCount:r.length,attributes:f,feedbackBufferMode:"interleaved",outputs:c.varyings});a.statsManager.getStats(iU).get(rU).incrementCount(),w.run({inputBuffers:f,outputBuffers:{[c.varyings[0]]:r.offset===0?o:{buffer:o,byteOffset:r.offset,byteLength:r.byteLength}}}),m&&pt.recycle(m)}function oU(n){return Array.isArray(n)?n.map((e,t)=>[`x${t}`,e]):Object.entries(n)}function Iy(n,e,t,i=!1,r=e){let s="",o="";for(let c=0;c[`x${t}`,e]):Object.entries(n)}function By(n,e,t,i=!1,r=e){let s="",o="";for(let c=0;c1&&(d=`${d}[${f}]`),(i||e!==r)&&(d=`TYPE(${d})`),o+=`v[${c+f}]=${d}; `}}let a=` ${s} void get_${n}(out TYPE v[${t}]) { ${o} } -`;return{name:n,vs:a}}function By(n,e){let t={name:n,stepMode:e.isConstant?"vertex":"instance",byteStride:e.stride,attributes:[]};for(let i=0;ic+h);a+=`${n}_${c} = ${u}(${f.map(d=>`v[${d}]`).join(",")}); `}return{name:n,varyings:r,vs:` ${o} void set_${n}(in ${s} v[${t}]) { ${a} } -`}}var iU,rU,sU,Bt=C(()=>{Ce();bt();Si();qc();Ro();iU="GPGPU Operation Counts",rU="Transform Runs",sU=new Xs});var aU,Dd,Oy=C(()=>{bt();Ry();Id();Bt();Ro();aU=`TYPE arithmetic_add(TYPE x, TYPE y) { +`}}var oU,aU,cU,Dt=C(()=>{Me();vt();Mi();Zc();Ro();oU="GPGPU Operation Counts",aU="Transform Runs",cU=new Xs});var uU,Nd,Dy=C(()=>{vt();Iy();Bd();Dt();Ro();uU=`TYPE arithmetic_add(TYPE x, TYPE y) { return x + y; } @@ -2571,7 +2571,7 @@ TYPE arithmetic_divide(TYPE x, TYPE y) { float arithmetic_tan(float x) { return tan_fp32(x); } -`,Dd=({inputs:n,output:e,target:t})=>{let i=e.type,r=rt(i,1,e.normalized),s=tr(r),o=n.namedInputs;return st({module:{name:"arithmetic",dependencies:[Vr],vs:aU},inputs:o,output:e,operationType:i,outputBuffer:t,expression:a=>Bd(n.expression,{operations:Ao,inputs:o,laneIndex:a,formatInput:c=>`${c}[${a}]`,formatOutOfBoundsInput:c=>o[c].size===1?`${c}[0]`:s,formatLiteral:c=>{let l=Array.isArray(c)?c[a]??0:c;return`${r}(${uC(i,l)})`},formatCall:(c,l)=>`${c}(${l.join(", ")})`})}),{success:!0}}});var cU,lU,pC,hC,mC=C(()=>{ee();Ce();Si();qc();Oy();Bt();cU="GPGPU Operation Counts",lU="Transform Runs",pC=({inputs:n,output:e,target:t})=>{let{sourceValues:i}=n,r=t.device;if(i.length===0){let f=new e.ValueType(e.length*e.size);return t.write(f),{success:!0,value:f}}if(i.isConstant){let f=i.value,d=new e.ValueType(e.length*e.size);for(let h=0;h{let i=e.type,r=it(i,1,e.normalized),s=ir(r),o=n.namedInputs;return rt({module:{name:"arithmetic",dependencies:[Vr],vs:uU},inputs:o,output:e,operationType:i,outputBuffer:t,expression:a=>Od(n.expression,{operations:Ao,inputs:o,laneIndex:a,formatInput:c=>`${c}[${a}]`,formatOutOfBoundsInput:c=>o[c].size===1?`${c}[0]`:s,formatLiteral:c=>{let l=Array.isArray(c)?c[a]??0:c;return`${r}(${fC(i,l)})`},formatCall:(c,l)=>`${c}(${l.join(", ")})`})}),{success:!0}}});var fU,dU,mC,pC,gC=C(()=>{J();Me();Mi();Zc();Dy();Dt();fU="GPGPU Operation Counts",dU="Transform Runs",mC=({inputs:n,output:e,target:t})=>{let{sourceValues:i}=n,r=t.device;if(i.length===0){let f=new e.ValueType(e.length*e.size);return t.write(f),{success:!0,value:f}}if(i.isConstant){let f=i.value,d=new e.ValueType(e.length*e.size);for(let h=0;hi+Math.ceil(r.size/4),0);if(t>n)throw new Error(`interleave() requires ${t} vertex attributes, exceeding device limit ${n}`)}function fU(n,e){if(e.size>n)throw new Error(`interleave() output size ${e.size} exceeds device inter-stage component limit ${n}`)}var gC,_C=C(()=>{Bt();gC=({inputs:n,output:e,target:t})=>{let i=n.map((c,l)=>[`x${l}`,c]);uU(t.device.limits.maxVertexAttributes,i),fU(t.device.limits.maxInterStageShaderVariables,e);let r=i.map(([c,l])=>`in TYPE ${c}[${l.size}]`).join(", "),s=0,o=i.map(([c,l])=>{let u=Array.from({length:l.size},(f,d)=>` result[${s+d}] = ${c}[${d}];`).join(` + `,l=new Ze(r,{vs:a,fs:c,topology:"point-list",parameters:{depthCompare:"always",blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one",blendColorOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",blendAlphaOperation:"max"},modules:[By("sourceValues",i.type,i.size,i.normalized)],defines:{TYPE:"float",SOURCE_VALUES_LEN:i.size.toString(),CHANNEL_COUNT:e.length.toString()},attributes:{sourceValues:i.buffer},bufferLayout:[Oy("sourceValues",i)],instanceCount:i.length,vertexCount:e.length,disableWarnings:!0}),u=pt.createOrReuse(r,e.byteLength);try{let f=r.beginRenderPass({framebuffer:o,parameters:{viewport:[0,0,1,e.length]},clearColor:[-pC,-pC,0,0],clearDepth:!1,clearStencil:!1});r.statsManager.getStats(fU).get(dU).incrementCount(),l.draw(f),f.end();let d=r.createCommandEncoder();return d.copyTextureToBuffer({sourceTexture:s,width:1,height:e.length,destinationBuffer:u,byteOffset:0,bytesPerRow:8}),r.submit(d.finish()),Nd({device:r,inputs:{expression:{kind:"call",op:"multiply",args:[{kind:"input",name:"x"},{kind:"literal",value:[-1,1]}]},namedInputs:{x:new ve({buffer:u,size:2,type:"float32",length:e.length})}},output:e,target:t})}finally{l.destroy(),pt.recycle(u),o.destroy(),s.destroy()}},pC=3e38});function hU(n,e){let t=e.reduce((i,[,r])=>i+Math.ceil(r.size/4),0);if(t>n)throw new Error(`interleave() requires ${t} vertex attributes, exceeding device limit ${n}`)}function pU(n,e){if(e.size>n)throw new Error(`interleave() output size ${e.size} exceeds device inter-stage component limit ${n}`)}var _C,yC=C(()=>{Dt();_C=({inputs:n,output:e,target:t})=>{let i=n.map((c,l)=>[`x${l}`,c]);hU(t.device.limits.maxVertexAttributes,i),pU(t.device.limits.maxInterStageShaderVariables,e);let r=i.map(([c,l])=>`in TYPE ${c}[${l.size}]`).join(", "),s=0,o=i.map(([c,l])=>{let u=Array.from({length:l.size},(f,d)=>` result[${s+d}] = ${c}[${d}];`).join(` `);return s+=l.size,u}).join(` `),a=`void interleave(${r}, out TYPE result[RESULT_LEN]) { ${o} } -`;return st({module:{name:"interleave",vs:a},inputs:n,output:e,outputBuffer:t}),{success:!0}}});function dU(){let n=new Uint16Array([255]);return new Uint8Array(n.buffer)[0]>0}var hU,yC,bC=C(()=>{Bt();hU=`#define LE ${dU()?1:0} +`;return rt({module:{name:"interleave",vs:a},inputs:n,output:e,outputBuffer:t}),{success:!0}}});function mU(){let n=new Uint16Array([255]);return new Uint8Array(n.buffer)[0]>0}var gU,bC,vC=C(()=>{Dt();gU=`#define LE ${mU()?1:0} const uint F32_NAN = 0xffffffffu; const uint F32_INF = 0x7f800000u; @@ -2773,21 +2773,21 @@ void fround(in uint x[X_LEN], out float result[X_LEN]) { result[i + n] = uintBitsToFloat(f.y); } } -`,yC=({inputs:n,output:e,target:t})=>(st({module:{name:"fround",vs:hU},inputs:n,output:e,operationType:"uint32",outputBuffer:t}),{success:!0})});function Nd(n,e,t){let i=dC(t),r=rt(e,1),s=Array.from({length:n.size},(o,a)=>` v[${a}] = ${r}(texelFetch(source_values_texture, ivec2(${a}, rowIndex), 0).r);`).join(` +`,bC=({inputs:n,output:e,target:t})=>(rt({module:{name:"fround",vs:gU},inputs:n,output:e,operationType:"uint32",outputBuffer:t}),{success:!0})});function Fd(n,e,t){let i=hC(t),r=it(e,1),s=Array.from({length:n.size},(o,a)=>` v[${a}] = ${r}(texelFetch(source_values_texture, ivec2(${a}, rowIndex), 0).r);`).join(` `);return{name:"source_values_texture",vs:` uniform highp ${i} source_values_texture; void read_source_values(int rowIndex, out TYPE v[${n.size}]) { ${s} } -`}}function Fd(n,e,t){let i=t.createTexture({width:Math.max(n.size,1),height:n.length,format:fC(e),usage:pe.SAMPLE|pe.COPY_DST});if(n.length===0)return i;let r=t.createCommandEncoder();return r.copyBufferToTexture({sourceBuffer:n.buffer,destinationTexture:i,byteOffset:n.offset,bytesPerRow:n.stride,rowsPerImage:n.length,size:[n.size,n.length,1]}),t.submit(r.finish()),i}var Dy=C(()=>{ee();Ro()});function pU(n,e){let t=rt(n.type,1),i="aids_0";return n.type!==_U(e)&&(i=`${e}(${i})`),{name:"ids",vs:` +`}}function zd(n,e,t){let i=t.createTexture({width:Math.max(n.size,1),height:n.length,format:dC(e),usage:me.SAMPLE|me.COPY_DST});if(n.length===0)return i;let r=t.createCommandEncoder();return r.copyBufferToTexture({sourceBuffer:n.buffer,destinationTexture:i,byteOffset:n.offset,bytesPerRow:n.stride,rowsPerImage:n.length,size:[n.size,n.length,1]}),t.submit(r.finish()),i}var Ny=C(()=>{J();Ro()});function _U(n,e){let t=it(n.type,1),i="aids_0";return n.type!==vU(e)&&(i=`${e}(${i})`),{name:"ids",vs:` in ${t} aids_0; void get_ids(out INDEX_TYPE v[1]) { v[0] = ${i}; } -`}}function mU(n){return{name:"ids",stepMode:n.isConstant?"vertex":"instance",byteStride:n.stride,attributes:[{attribute:"aids_0",format:Od(n.type,1,n.normalized),byteOffset:n.offset}]}}function gU(n){return{name:"gather",vs:` +`}}function yU(n){return{name:"ids",stepMode:n.isConstant?"vertex":"instance",byteStride:n.stride,attributes:[{attribute:"aids_0",format:Dd(n.type,1,n.normalized),byteOffset:n.offset}]}}function bU(n){return{name:"gather",vs:` void zero_result(out TYPE result[RESULT_LEN]) { for (int i = 0; i < RESULT_LEN; i++) { - result[i] = ${tr(n)}; + result[i] = ${ir(n)}; } } @@ -2799,7 +2799,7 @@ void gather(in INDEX_TYPE ids[1], out TYPE result[RESULT_LEN]) { } read_source_values(sourceIndex, result); } -`}}function _U(n){switch(n){case"uint":return"uint32";case"int":return"sint32";default:return"float32"}}var vC,xC=C(()=>{Ce();Ro();Bt();Dy();vC=async({inputs:n,output:e,target:t})=>{let{ids:i,sourceValues:r}=n,s=t.device,o=cs("result",e.type,e.size),a=rt(i.type,1),c=rt(e.type,1),l=e.type,u=Fd(r,l,s),f=`#version 300 es +`}}function vU(n){switch(n){case"uint":return"uint32";case"int":return"sint32";default:return"float32"}}var xC,wC=C(()=>{Me();Ro();Dt();Ny();xC=async({inputs:n,output:e,target:t})=>{let{ids:i,sourceValues:r}=n,s=t.device,o=cs("result",e.type,e.size),a=it(i.type,1),c=it(e.type,1),l=e.type,u=zd(r,l,s),f=`#version 300 es void main() { INDEX_TYPE ids[1]; @@ -2808,14 +2808,14 @@ void main() { gather(ids, result); set_result(result); } - `,d=new it(s,{vs:f,defines:{INDEX_TYPE:a,TYPE:c,RESULT_LEN:e.size.toString(),SOURCE_VALUES_ROWS:r.length.toString()},modules:[pU(i,a),Nd(r,e.type,l),gU(e.type),o],bindings:{source_values_texture:u},bufferLayout:[mU(i)],vertexCount:1,instanceCount:e.length,feedbackBufferMode:"interleaved",outputs:o.varyings});try{return d.run({inputBuffers:{ids:i.buffer},outputBuffers:{[o.varyings[0]]:t}}),{success:!0}}finally{d.destroy(),u.destroy()}}});var yU,wC,EC=C(()=>{Bt();yU=`void row_dot(in TYPE x[X_LEN], in TYPE y[Y_LEN], out float result[1]) { + `,d=new nt(s,{vs:f,defines:{INDEX_TYPE:a,TYPE:c,RESULT_LEN:e.size.toString(),SOURCE_VALUES_ROWS:r.length.toString()},modules:[_U(i,a),Fd(r,e.type,l),bU(e.type),o],bindings:{source_values_texture:u},bufferLayout:[yU(i)],vertexCount:1,instanceCount:e.length,feedbackBufferMode:"interleaved",outputs:o.varyings});try{return d.run({inputBuffers:{ids:i.buffer},outputBuffers:{[o.varyings[0]]:t}}),{success:!0}}finally{d.destroy(),u.destroy()}}});var xU,EC,SC=C(()=>{Dt();xU=`void row_dot(in TYPE x[X_LEN], in TYPE y[Y_LEN], out float result[1]) { float sum = 0.0; for (int i = 0; i < X_LEN; i++) { sum += float(x[i]) * float(y[i]); } result[0] = sum; } -`,wC=({inputs:n,output:e,target:t})=>(st({module:{name:"row_dot",vs:yU},inputs:n,output:e,operationType:"float32",outputBuffer:t}),{success:!0})});var bU,SC,PC=C(()=>{Bt();bU=`void equalAll(in TYPE x[X_LEN], in TYPE y[Y_LEN], out uint result[1]) { +`,EC=({inputs:n,output:e,target:t})=>(rt({module:{name:"row_dot",vs:xU},inputs:n,output:e,operationType:"float32",outputBuffer:t}),{success:!0})});var wU,PC,CC=C(()=>{Dt();wU=`void equalAll(in TYPE x[X_LEN], in TYPE y[Y_LEN], out uint result[1]) { uint allEqual = uint(1); for (int i = 0; i < X_LEN; i++) { if (x[i] != y[i]) { @@ -2825,14 +2825,14 @@ void main() { } result[0] = allEqual; } -`,SC=({inputs:n,output:e,target:t})=>(st({module:{name:"equalAll",vs:bU},inputs:n,output:e,operationType:e.type==="uint32"?n.x.type:e.type,outputBuffer:t}),{success:!0})});var vU,CC,TC=C(()=>{Bt();vU=`void row_length(in TYPE x[X_LEN], out float result[1]) { +`,PC=({inputs:n,output:e,target:t})=>(rt({module:{name:"equalAll",vs:wU},inputs:n,output:e,operationType:e.type==="uint32"?n.x.type:e.type,outputBuffer:t}),{success:!0})});var EU,TC,LC=C(()=>{Dt();EU=`void row_length(in TYPE x[X_LEN], out float result[1]) { float sum = 0.0; for (int i = 0; i < X_LEN; i++) { sum += float(x[i]) * float(x[i]); } result[0] = sqrt(sum); } -`,CC=({inputs:n,output:e,target:t})=>(st({module:{name:"row_length",vs:vU},inputs:n,output:e,operationType:"float32",outputBuffer:t}),{success:!0})});function xU(){return{name:"segmentedMap",vs:` +`,TC=({inputs:n,output:e,target:t})=>(rt({module:{name:"row_length",vs:EU},inputs:n,output:e,operationType:"float32",outputBuffer:t}),{success:!0})});function SU(){return{name:"segmentedMap",vs:` uint read_segment_start(int segmentIndex) { TYPE value[1]; read_source_values(segmentIndex, value); @@ -2859,34 +2859,34 @@ void segmentedMap(out TYPE result[RESULT_LEN]) { result[0] = segmentIndex; result[1] = vertexIndex - segmentStart; } -`}}var LC,MC=C(()=>{Ce();Dy();Bt();LC=async({inputs:n,output:e,target:t})=>{let{segments:i}=n,r=t.device,s=cs("result",e.type,e.size),o=i.type,a=Fd(i,o,r),c=new it(r,{vs:`#version 300 es +`}}var MC,AC=C(()=>{Me();Ny();Dt();MC=async({inputs:n,output:e,target:t})=>{let{segments:i}=n,r=t.device,s=cs("result",e.type,e.size),o=i.type,a=zd(i,o,r),c=new nt(r,{vs:`#version 300 es void main() { TYPE result[RESULT_LEN]; segmentedMap(result); set_result(result); } -`,defines:{TYPE:"uint",RESULT_LEN:e.size.toString(),SEGMENTS_LENGTH:i.length.toString()},modules:[Nd(i,e.type,o),xU(),s],bindings:{source_values_texture:a},vertexCount:1,instanceCount:e.length,feedbackBufferMode:"interleaved",outputs:s.varyings});try{return c.run({outputBuffers:{[s.varyings[0]]:t}}),{success:!0}}finally{c.destroy(),a.destroy()}}});function Ny(n,e,t,i){return t{Bt();Ro();AC=async({inputs:n,output:e,target:t})=>{let i=rt(e.type,1,e.normalized),r=tr(i);return st({module:{name:"select",vs:""},inputs:n,output:e,operationType:e.type,outputBuffer:t,expression:s=>{let o=Ny("condition",n.condition,s,r),a=Ny("whenTrue",n.whenTrue,s,r),c=Ny("whenFalse",n.whenFalse,s,r);return`(${o} != ${r} ? ${a} : ${c})`}}),{success:!0}}});var RC,IC=C(()=>{Ce();Bt();RC=({inputs:n,output:e,target:t})=>{let i=cs("result",e.type,e.size),r=new it(t.device,{vs:`#version 300 es +`,defines:{TYPE:"uint",RESULT_LEN:e.size.toString(),SEGMENTS_LENGTH:i.length.toString()},modules:[Fd(i,e.type,o),SU(),s],bindings:{source_values_texture:a},vertexCount:1,instanceCount:e.length,feedbackBufferMode:"interleaved",outputs:s.varyings});try{return c.run({outputBuffers:{[s.varyings[0]]:t}}),{success:!0}}finally{c.destroy(),a.destroy()}}});function Fy(n,e,t,i){return t{Dt();Ro();kC=async({inputs:n,output:e,target:t})=>{let i=it(e.type,1,e.normalized),r=ir(i);return rt({module:{name:"select",vs:""},inputs:n,output:e,operationType:e.type,outputBuffer:t,expression:s=>{let o=Fy("condition",n.condition,s,r),a=Fy("whenTrue",n.whenTrue,s,r),c=Fy("whenFalse",n.whenFalse,s,r);return`(${o} != ${r} ? ${a} : ${c})`}}),{success:!0}}});var IC,BC=C(()=>{Me();Dt();IC=({inputs:n,output:e,target:t})=>{let i=cs("result",e.type,e.size),r=new nt(t.device,{vs:`#version 300 es void main() { int result[1]; result[0] = START + gl_InstanceID * STEP; set_result(result); } -`,defines:{START:n.start.toString(),STEP:n.step.toString()},modules:[i],vertexCount:1,instanceCount:e.length,feedbackBufferMode:"interleaved",outputs:i.varyings});try{return r.run({outputBuffers:{[i.varyings[0]]:t}}),{success:!0}}finally{r.destroy()}}});var BC,OC=C(()=>{Bt();BC=({inputs:n,output:e,target:t})=>{let{columns:i}=n;return st({module:{name:"swizzle",vs:"// swizzle expression handled inline"},expression:r=>`x[${i[r]}]`,inputs:{x:n.x},output:e,outputBuffer:t}),{success:!0}}});var DC={};ui(DC,{arithmetic:()=>Dd,dot:()=>wC,equalAll:()=>SC,extent:()=>pC,fround:()=>yC,gather:()=>vC,interleave:()=>gC,length:()=>CC,segmentedMap:()=>LC,select:()=>AC,sequence:()=>RC,swizzle:()=>BC});var NC=C(()=>{Oy();mC();_C();bC();xC();EC();PC();TC();MC();kC();IC();OC()});function ti(n,e){let t=wU(e),i=Math.max(1,Math.ceil(n)),r=Math.min(i,t),s=Math.min(Math.ceil(i/r),t),o=Math.ceil(i/r/s);if(o>t)throw new Error(`WebGPU dispatch requires ${i} workgroups, exceeding the 3D dispatch limit of ${t} per dimension`);return{x:r,y:s,z:o}}function Fy(n,e="workgroupId"){return`((${e}.z * ${n.y}u + ${e}.y) * ${n.x}u + ${e}.x)`}function nr(n,e,t="workgroupId",i="localId"){return`(${Fy(n,t)} * ${e}u + ${i}.x)`}function wU(n){return Number.isFinite(n)&&n>0?Math.floor(n):65535}var Io=C(()=>{});function ir(n,e){switch(n){case"u32":return`${e}u`;case"f32":return Number.isInteger(e)?`${e}.0`:`${e}`;default:return`${e}`}}function FC(n,e){switch(n){case"uint32":return ir("u32",Math.trunc(e));case"sint32":return`${Math.trunc(e)}`;case"float32":return ir("f32",e);default:throw new Error(`WebGPU operations only support 32-bit output types, got ${n}`)}}function rr(n){switch(n){case"uint32":return"0u";case"sint32":return"0";case"float32":return"0.0";default:throw new Error(`WebGPU operations only support 32-bit output types, got ${n}`)}}function we(n){switch(n){case"uint32":return"u32";case"sint32":return"i32";case"float32":return"f32";default:throw new Error(`WebGPU operations only support 32-bit storage types, got ${n}`)}}var ls=C(()=>{});function ot({module:n,elementWise:e=!1,expression:t,inputs:i,output:r,operationType:s=r.type,outputBuffer:o}){if(!n.source)throw new Error(`WebGPU computation ${n.name} requires WGSL source`);let a=kU(i),c=a.map(([y,b])=>({name:y,input:b})),l=c.filter(({input:y})=>!y.isConstant).map((y,b)=>({...y,index:b})),u=we(s),f=we(r.type),d={TYPE:u,RESULT_LEN:r.size.toString()},h=ti(Math.ceil(r.length/zy),o.device.limits.maxComputeWorkgroupsPerDimension);for(let[y,b]of a)d[`${y.toUpperCase()}_LEN`]=b.size.toString();let p=` -${IU(n.source,d)} -${l.map(({name:y,input:b,index:w})=>CU(y,b,w)).join(` +`,defines:{START:n.start.toString(),STEP:n.step.toString()},modules:[i],vertexCount:1,instanceCount:e.length,feedbackBufferMode:"interleaved",outputs:i.varyings});try{return r.run({outputBuffers:{[i.varyings[0]]:t}}),{success:!0}}finally{r.destroy()}}});var OC,DC=C(()=>{Dt();OC=({inputs:n,output:e,target:t})=>{let{columns:i}=n;return rt({module:{name:"swizzle",vs:"// swizzle expression handled inline"},expression:r=>`x[${i[r]}]`,inputs:{x:n.x},output:e,outputBuffer:t}),{success:!0}}});var NC={};mi(NC,{arithmetic:()=>Nd,dot:()=>EC,equalAll:()=>PC,extent:()=>mC,fround:()=>bC,gather:()=>xC,interleave:()=>_C,length:()=>TC,segmentedMap:()=>MC,select:()=>kC,sequence:()=>IC,swizzle:()=>OC});var FC=C(()=>{Dy();gC();yC();vC();wC();SC();CC();LC();AC();RC();BC();DC()});function si(n,e){let t=PU(e),i=Math.max(1,Math.ceil(n)),r=Math.min(i,t),s=Math.min(Math.ceil(i/r),t),o=Math.ceil(i/r/s);if(o>t)throw new Error(`WebGPU dispatch requires ${i} workgroups, exceeding the 3D dispatch limit of ${t} per dimension`);return{x:r,y:s,z:o}}function zy(n,e="workgroupId"){return`((${e}.z * ${n.y}u + ${e}.y) * ${n.x}u + ${e}.x)`}function rr(n,e,t="workgroupId",i="localId"){return`(${zy(n,t)} * ${e}u + ${i}.x)`}function PU(n){return Number.isFinite(n)&&n>0?Math.floor(n):65535}var Io=C(()=>{});function sr(n,e){switch(n){case"u32":return`${e}u`;case"f32":return Number.isInteger(e)?`${e}.0`:`${e}`;default:return`${e}`}}function zC(n,e){switch(n){case"uint32":return sr("u32",Math.trunc(e));case"sint32":return`${Math.trunc(e)}`;case"float32":return sr("f32",e);default:throw new Error(`WebGPU operations only support 32-bit output types, got ${n}`)}}function or(n){switch(n){case"uint32":return"0u";case"sint32":return"0";case"float32":return"0.0";default:throw new Error(`WebGPU operations only support 32-bit output types, got ${n}`)}}function Se(n){switch(n){case"uint32":return"u32";case"sint32":return"i32";case"float32":return"f32";default:throw new Error(`WebGPU operations only support 32-bit storage types, got ${n}`)}}var ls=C(()=>{});function st({module:n,elementWise:e=!1,expression:t,inputs:i,output:r,operationType:s=r.type,outputBuffer:o}){if(!n.source)throw new Error(`WebGPU computation ${n.name} requires WGSL source`);let a=BU(i),c=a.map(([y,b])=>({name:y,input:b})),l=c.filter(({input:y})=>!y.isConstant).map((y,b)=>({...y,index:b})),u=Se(s),f=Se(r.type),d={TYPE:u,RESULT_LEN:r.size.toString()},h=si(Math.ceil(r.length/Uy),o.device.limits.maxComputeWorkgroupsPerDimension);for(let[y,b]of a)d[`${y.toUpperCase()}_LEN`]=b.size.toString();let p=` +${DU(n.source,d)} +${l.map(({name:y,input:b,index:x})=>MU(y,b,x)).join(` `)} -${c.map(({name:y,input:b})=>TU(y,b,s)).join(` +${c.map(({name:y,input:b})=>AU(y,b,s)).join(` `)} -${LU(r,l.length)} -${MU(r)} +${kU(r,l.length)} +${RU(r)} -@compute @workgroup_size(${zy}) fn main( +@compute @workgroup_size(${Uy}) fn main( @builtin(workgroup_id) workgroupId: vec3, @builtin(local_invocation_id) localId: vec3 ) { - let rowIndex = ${nr(h,zy)}; + let rowIndex = ${rr(h,Uy)}; if (rowIndex >= ${r.length}u) { return; } @@ -2894,24 +2894,24 @@ ${MU(r)} ${c.map(({name:y})=>` let ${y} = read_${y}(rowIndex);`).join(` `)} var result: array<${f}, ${r.size}>; -${AU(n.name,a,r,e,t)} +${IU(n.name,a,r,e,t)} write_result(rowIndex, result); } -`,m=new Rt(o.device,{source:p,modules:n.dependencies,shaderAssembler:PU,shaderLayout:{bindings:[...l.map(({name:y},b)=>({name:y,type:"storage",group:0,location:b})),{name:"result",type:"storage",group:0,location:l.length}]}}),g=Object.fromEntries(l.map(({name:y,input:b})=>[y,b.buffer]));g.result=o,m.setBindings(g);let v=o.device.beginComputePass({});o.device.statsManager.getStats(EU).get(SU).incrementCount(),m.dispatch(v,h.x,h.y,h.z),v.end(),o.device.submit(),m.destroy()}function CU(n,e,t){if(e.isConstant)return"";let i=we(e.type);return`@group(0) @binding(${t}) var ${n}: array<${i}>;`}function TU(n,e,t){let i=we(t),r=e.type===t?"":i,s=e.stride/e.ValueType.BYTES_PER_ELEMENT,o=e.offset/e.ValueType.BYTES_PER_ELEMENT;return e.isConstant?`fn read_${n}(_rowIndex: u32) -> array<${i}, ${e.size}> { - return array<${i}, ${e.size}>(${RU(e,r)}); +`,m=new Bt(o.device,{source:p,modules:n.dependencies,shaderAssembler:LU,shaderLayout:{bindings:[...l.map(({name:y},b)=>({name:y,type:"storage",group:0,location:b})),{name:"result",type:"storage",group:0,location:l.length}]}}),g=Object.fromEntries(l.map(({name:y,input:b})=>[y,b.buffer]));g.result=o,m.setBindings(g);let v=o.device.beginComputePass({});o.device.statsManager.getStats(CU).get(TU).incrementCount(),m.dispatch(v,h.x,h.y,h.z),v.end(),o.device.submit(),m.destroy()}function MU(n,e,t){if(e.isConstant)return"";let i=Se(e.type);return`@group(0) @binding(${t}) var ${n}: array<${i}>;`}function AU(n,e,t){let i=Se(t),r=e.type===t?"":i,s=e.stride/e.ValueType.BYTES_PER_ELEMENT,o=e.offset/e.ValueType.BYTES_PER_ELEMENT;return e.isConstant?`fn read_${n}(_rowIndex: u32) -> array<${i}, ${e.size}> { + return array<${i}, ${e.size}>(${OU(e,r)}); }`:`fn read_${n}(rowIndex: u32) -> array<${i}, ${e.size}> { var value: array<${i}, ${e.size}>; let rowOffset = ${o}u + rowIndex * ${s}u; ${Array.from({length:e.size},(a,c)=>r?` value[${c}] = ${r}(${n}[rowOffset + ${c}u]);`:` value[${c}] = ${n}[rowOffset + ${c}u];`).join(` `)} return value; -}`}function LU(n,e){let t=we(n.type);return`@group(0) @binding(${e}) var result: array<${t}>;`}function MU(n){let e=n.stride/n.ValueType.BYTES_PER_ELEMENT,t=n.offset/n.ValueType.BYTES_PER_ELEMENT;return`fn write_result(rowIndex: u32, value: array<${we(n.type)}, ${n.size}>) { +}`}function kU(n,e){let t=Se(n.type);return`@group(0) @binding(${e}) var result: array<${t}>;`}function RU(n){let e=n.stride/n.ValueType.BYTES_PER_ELEMENT,t=n.offset/n.ValueType.BYTES_PER_ELEMENT;return`fn write_result(rowIndex: u32, value: array<${Se(n.type)}, ${n.size}>) { let rowOffset = ${t}u + rowIndex * ${e}u; ${Array.from({length:n.size},(r,s)=>` result[rowOffset + ${s}u] = value[${s}];`).join(` `)} -}`}function AU(n,e,t,i,r){let s="";if(r)for(let o=0;oco).join(", ")});`;return s.trimEnd()}function kU(n){return Array.isArray(n)?n.map((e,t)=>[`x${t}`,e]):Object.entries(n)}function RU(n,e){let t=n.value;if(!t)throw new Error(`Constant input ${n} is missing CPU values`);return Array.from({length:n.size},(i,r)=>ir(e,t[r]??0)).join(", ")}function IU(n,e){for(let t in e)n=n.replaceAll(`{${t}}`,e[t]);return n}var zy,EU,SU,PU,Pi=C(()=>{Ce();bt();Io();ls();zy=64,EU="GPGPU Operation Counts",SU="Computation Runs",PU=new Hi});var BU,zC,UC=C(()=>{bt();Ry();Id();Pi();ls();BU=`fn arithmetic_add(x: {TYPE}, y: {TYPE}) -> {TYPE} { +}`}function IU(n,e,t,i,r){let s="";if(r)for(let o=0;oco).join(", ")});`;return s.trimEnd()}function BU(n){return Array.isArray(n)?n.map((e,t)=>[`x${t}`,e]):Object.entries(n)}function OU(n,e){let t=n.value;if(!t)throw new Error(`Constant input ${n} is missing CPU values`);return Array.from({length:n.size},(i,r)=>sr(e,t[r]??0)).join(", ")}function DU(n,e){for(let t in e)n=n.replaceAll(`{${t}}`,e[t]);return n}var Uy,CU,TU,LU,Ai=C(()=>{Me();vt();Io();ls();Uy=64,CU="GPGPU Operation Counts",TU="Computation Runs",LU=new qi});var NU,UC,$C=C(()=>{vt();Iy();Bd();Ai();ls();NU=`fn arithmetic_add(x: {TYPE}, y: {TYPE}) -> {TYPE} { return x + y; } @@ -2930,14 +2930,14 @@ fn arithmetic_divide(x: {TYPE}, y: {TYPE}) -> {TYPE} { fn arithmetic_tan(x: f32) -> f32 { return tan_fp32(x); } -`,zC=({inputs:n,output:e,target:t})=>{let i=e.type,r=we(i),s=rr(i),o=n.namedInputs;return ot({module:{name:"arithmetic",source:BU,dependencies:[Vr]},inputs:o,output:e,operationType:i,outputBuffer:t,expression:a=>Bd(n.expression,{operations:Ao,inputs:o,laneIndex:a,formatInput:c=>`${c}[${a}]`,formatOutOfBoundsInput:c=>o[c].size===1?`${c}[0]`:s,formatLiteral:c=>{let l=Array.isArray(c)?c[a]??0:c;return`${r}(${FC(i,l)})`},formatCall:(c,l)=>`${c}(${l.join(", ")})`})}),{success:!0}}});var OU,$C,GC=C(()=>{Pi();OU=`fn row_dot(x: array<{TYPE}, {X_LEN}>, y: array<{TYPE}, {Y_LEN}>) -> array { +`,UC=({inputs:n,output:e,target:t})=>{let i=e.type,r=Se(i),s=or(i),o=n.namedInputs;return st({module:{name:"arithmetic",source:NU,dependencies:[Vr]},inputs:o,output:e,operationType:i,outputBuffer:t,expression:a=>Od(n.expression,{operations:Ao,inputs:o,laneIndex:a,formatInput:c=>`${c}[${a}]`,formatOutOfBoundsInput:c=>o[c].size===1?`${c}[0]`:s,formatLiteral:c=>{let l=Array.isArray(c)?c[a]??0:c;return`${r}(${zC(i,l)})`},formatCall:(c,l)=>`${c}(${l.join(", ")})`})}),{success:!0}}});var FU,GC,VC=C(()=>{Ai();FU=`fn row_dot(x: array<{TYPE}, {X_LEN}>, y: array<{TYPE}, {Y_LEN}>) -> array { var sum = 0.0; for (var i = 0u; i < {X_LEN}u; i = i + 1u) { sum += f32(x[i]) * f32(y[i]); } return array(sum); } -`,$C=({inputs:n,output:e,target:t})=>(ot({module:{name:"row_dot",source:OU},inputs:n,output:e,operationType:"float32",outputBuffer:t}),{success:!0})});var DU,VC,WC=C(()=>{Pi();DU=`fn equalAll(x: array<{TYPE}, {X_LEN}>, y: array<{TYPE}, {Y_LEN}>) -> array { +`,GC=({inputs:n,output:e,target:t})=>(st({module:{name:"row_dot",source:FU},inputs:n,output:e,operationType:"float32",outputBuffer:t}),{success:!0})});var zU,WC,jC=C(()=>{Ai();zU=`fn equalAll(x: array<{TYPE}, {X_LEN}>, y: array<{TYPE}, {Y_LEN}>) -> array { var allEqual = 1u; for (var i = 0u; i < {X_LEN}u; i = i + 1u) { if (x[i] != y[i]) { @@ -2947,29 +2947,29 @@ fn arithmetic_tan(x: f32) -> f32 { } return array(allEqual); } -`,VC=({inputs:n,output:e,target:t})=>(ot({module:{name:"equalAll",source:DU},inputs:n,output:e,operationType:n.x.type,outputBuffer:t}),{success:!0})});function Bo(n,e,t){let i=we(e.type);return`@group(0) @binding(${t}) var ${n}: array<${i}>;`}function Uy(n,e,t,i=n){let r=we(t);if(e.isConstant){let l=e.value;if(!l)throw new Error(`Constant input ${e} is missing CPU values`);return`fn read_${i}(_sourceIndex: u32) -> array<${r}, ${e.size}> { - return array<${r}, ${e.size}>(${Array.from({length:e.size},(u,f)=>ir(r,l[f]??0)).join(", ")}); -}`}let s=e.stride/e.ValueType.BYTES_PER_ELEMENT,o=e.offset/e.ValueType.BYTES_PER_ELEMENT,c=we(e.type)===r?"":`${r}`;return`fn read_${i}(sourceIndex: u32) -> array<${r}, ${e.size}> { +`,WC=({inputs:n,output:e,target:t})=>(st({module:{name:"equalAll",source:zU},inputs:n,output:e,operationType:n.x.type,outputBuffer:t}),{success:!0})});function Bo(n,e,t){let i=Se(e.type);return`@group(0) @binding(${t}) var ${n}: array<${i}>;`}function $y(n,e,t,i=n){let r=Se(t);if(e.isConstant){let l=e.value;if(!l)throw new Error(`Constant input ${e} is missing CPU values`);return`fn read_${i}(_sourceIndex: u32) -> array<${r}, ${e.size}> { + return array<${r}, ${e.size}>(${Array.from({length:e.size},(u,f)=>sr(r,l[f]??0)).join(", ")}); +}`}let s=e.stride/e.ValueType.BYTES_PER_ELEMENT,o=e.offset/e.ValueType.BYTES_PER_ELEMENT,c=Se(e.type)===r?"":`${r}`;return`fn read_${i}(sourceIndex: u32) -> array<${r}, ${e.size}> { var value: array<${r}, ${e.size}>; let rowOffset = ${o}u + sourceIndex * ${s}u; ${Array.from({length:e.size},(l,u)=>c?` value[${u}] = ${c}(${n}[rowOffset + ${u}u]);`:` value[${u}] = ${n}[rowOffset + ${u}u];`).join(` `)} return value; -}`}function zd(n,e){return Uy("sourceValues",n,e,"source_values")}function Oo(n,e){let t=we(n.type);return`@group(0) @binding(${e}) var result: array<${t}>;`}function Do(n){let e=n.stride/n.ValueType.BYTES_PER_ELEMENT,t=n.offset/n.ValueType.BYTES_PER_ELEMENT;return`fn write_result(rowIndex: u32, value: array<${we(n.type)}, ${n.size}>) { +}`}function Ud(n,e){return $y("sourceValues",n,e,"source_values")}function Oo(n,e){let t=Se(n.type);return`@group(0) @binding(${e}) var result: array<${t}>;`}function Do(n){let e=n.stride/n.ValueType.BYTES_PER_ELEMENT,t=n.offset/n.ValueType.BYTES_PER_ELEMENT;return`fn write_result(rowIndex: u32, value: array<${Se(n.type)}, ${n.size}>) { let rowOffset = ${t}u + rowIndex * ${e}u; ${Array.from({length:n.size},(r,s)=>` result[rowOffset + ${s}u] = value[${s}];`).join(` `)} -}`}function jC(n,e){let t=rr(n);return`fn zero_result() -> array<${we(n)}, ${e}> { - var result: array<${we(n)}, ${e}>; +}`}function HC(n,e){let t=or(n);return`fn zero_result() -> array<${Se(n)}, ${e}> { + var result: array<${Se(n)}, ${e}>; ${Array.from({length:e},(i,r)=>` result[${r}] = ${t};`).join(` `)} return result; -}`}var mt,Ud=C(()=>{ls();mt=64});function NU({input:n,inputMode:e,inputGroupCount:t,channelCount:i,outputType:r,outputBuffer:s,outputLength:o,outputStride:a,outputOffset:c}){let l=we(r),u=ti(o,s.device.limits.maxComputeWorkgroupsPerDimension),f=new ye({buffer:s,type:r,size:2,length:o,stride:a,offset:c}),d=` +}`}var mt,$d=C(()=>{ls();mt=64});function UU({input:n,inputMode:e,inputGroupCount:t,channelCount:i,outputType:r,outputBuffer:s,outputLength:o,outputStride:a,outputOffset:c}){let l=Se(r),u=si(o,s.device.limits.maxComputeWorkgroupsPerDimension),f=new ve({buffer:s,type:r,size:2,length:o,stride:a,offset:c}),d=` ${n.isConstant?"":Bo("sourceValues",n,0)} -${zd(n,r)} +${Ud(n,r)} ${Oo(f,n.isConstant?0:1)} ${Do(f)} -${FU(e,r,i,t)} +${$U(e,r,i,t)} var sharedMin: array<${l}, ${mt}>; var sharedMax: array<${l}, ${mt}>; @@ -2978,7 +2978,7 @@ var sharedMax: array<${l}, ${mt}>; @builtin(workgroup_id) workgroupId: vec3, @builtin(local_invocation_id) localId: vec3 ) { - let outputRowIndex = ${Fy(u)}; + let outputRowIndex = ${zy(u)}; if (outputRowIndex >= ${o}u) { return; } @@ -3014,7 +3014,7 @@ var sharedMax: array<${l}, ${mt}>; write_result(outputRowIndex, array<${l}, 2>(sharedMin[0], sharedMax[0])); } } -`,h=new Rt(s.device,{source:d,shaderLayout:{bindings:[...n.isConstant?[]:[{name:"sourceValues",type:"storage",group:0,location:0}],{name:"result",type:"storage",group:0,location:n.isConstant?0:1}]}}),p={result:s};n.isConstant||(p.sourceValues=n.buffer),h.setBindings(p);let m=s.device.beginComputePass({});h.dispatch(m,u.x,u.y,u.z),m.end(),s.device.submit(),h.destroy()}function FU(n,e,t,i){let r=we(e),[s,o]=zU(e);return n==="raw"?`fn extent_pass(channelIndex: u32, inputGroupIndex: u32) -> array<${r}, 2> { +`,h=new Bt(s.device,{source:d,shaderLayout:{bindings:[...n.isConstant?[]:[{name:"sourceValues",type:"storage",group:0,location:0}],{name:"result",type:"storage",group:0,location:n.isConstant?0:1}]}}),p={result:s};n.isConstant||(p.sourceValues=n.buffer),h.setBindings(p);let m=s.device.beginComputePass({});h.dispatch(m,u.x,u.y,u.z),m.end(),s.device.submit(),h.destroy()}function $U(n,e,t,i){let r=Se(e),[s,o]=GU(e);return n==="raw"?`fn extent_pass(channelIndex: u32, inputGroupIndex: u32) -> array<${r}, 2> { var result: array<${r}, 2>; result[0] = ${s}; result[1] = ${o}; @@ -3039,7 +3039,7 @@ var sharedMax: array<${l}, ${mt}>; } return result; -}`}function zU(n){switch(n){case"uint32":return["0xffffffffu","0u"];case"sint32":return["2147483647","-2147483648"];case"float32":return["3.402823e38","-3.402823e38"];default:throw new Error(`Unsupported WebGPU extent type for ${n}`)}}var HC,YC=C(()=>{Ce();Si();qc();Io();ls();Ud();HC=({inputs:n,output:e,target:t})=>{let{sourceValues:i}=n;if(i.length===0){let c=new e.ValueType(e.length*e.size);return t.write(c),{success:!0,value:c}}if(i.isConstant){let c=i.value;if(!c)throw new Error(`Constant input ${i} is missing CPU values`);let l=new e.ValueType(e.length*e.size);for(let u=0;u1&&r.push(u),NU({input:s,inputMode:o,inputGroupCount:a,channelCount:e.length,outputType:e.type,outputBuffer:u,outputLength:l,outputStride:e.stride,outputOffset:e.offset}),c===1)break;s=new ye({buffer:u,type:e.type,size:2,length:l}),o="partial",a=c}return{success:!0}}finally{for(let c of r)pt.recycle(c)}}});function UU(){let n=new Uint16Array([255]);return new Uint8Array(n.buffer)[0]>0}var $U,qC,ZC=C(()=>{Pi();$U=`const LE: bool = ${UU()?"true":"false"}; +}`}function GU(n){switch(n){case"uint32":return["0xffffffffu","0u"];case"sint32":return["2147483647","-2147483648"];case"float32":return["3.402823e38","-3.402823e38"];default:throw new Error(`Unsupported WebGPU extent type for ${n}`)}}var YC,qC=C(()=>{Me();Mi();Zc();Io();ls();$d();YC=({inputs:n,output:e,target:t})=>{let{sourceValues:i}=n;if(i.length===0){let c=new e.ValueType(e.length*e.size);return t.write(c),{success:!0,value:c}}if(i.isConstant){let c=i.value;if(!c)throw new Error(`Constant input ${i} is missing CPU values`);let l=new e.ValueType(e.length*e.size);for(let u=0;u1&&r.push(u),UU({input:s,inputMode:o,inputGroupCount:a,channelCount:e.length,outputType:e.type,outputBuffer:u,outputLength:l,outputStride:e.stride,outputOffset:e.offset}),c===1)break;s=new ve({buffer:u,type:e.type,size:2,length:l}),o="partial",a=c}return{success:!0}}finally{for(let c of r)pt.recycle(c)}}});function VU(){let n=new Uint16Array([255]);return new Uint8Array(n.buffer)[0]>0}var WU,ZC,XC=C(()=>{Ai();WU=`const LE: bool = ${VU()?"true":"false"}; const F32_NAN: u32 = 0xffffffffu; const F32_INF: u32 = 0x7f800000u; @@ -3178,32 +3178,32 @@ fn fround(x: array) -> array { } return result; } -`,qC=({inputs:n,output:e,target:t})=>(ot({module:{name:"fround",source:$U},inputs:n,output:e,operationType:"uint32",outputBuffer:t}),{success:!0})});function GU(n,e){if(n.isConstant){let r=n.value;if(!r)throw new Error(`Constant input ${n} is missing CPU values`);return`fn read_ids(_rowIndex: u32) -> ${e} { - return ${ir(e,r[0]??0)}; +`,ZC=({inputs:n,output:e,target:t})=>(st({module:{name:"fround",source:WU},inputs:n,output:e,operationType:"uint32",outputBuffer:t}),{success:!0})});function jU(n,e){if(n.isConstant){let r=n.value;if(!r)throw new Error(`Constant input ${n} is missing CPU values`);return`fn read_ids(_rowIndex: u32) -> ${e} { + return ${sr(e,r[0]??0)}; }`}let t=n.stride/n.ValueType.BYTES_PER_ELEMENT,i=n.offset/n.ValueType.BYTES_PER_ELEMENT;return`fn read_ids(rowIndex: u32) -> ${e} { let rowOffset = ${i}u + rowIndex * ${t}u; return ids[rowOffset]; -}`}function VU(n,e,t,i){let r=we(n),s=we(e);return`fn gather(idsValue: ${r}) -> array<${s}, ${t}> { +}`}function HU(n,e,t,i){let r=Se(n),s=Se(e);return`fn gather(idsValue: ${r}) -> array<${s}, ${t}> { let sourceIndex = ${r==="u32"?"i32(idsValue)":r==="i32"?"idsValue":"i32(idsValue)"}; if (sourceIndex < 0 || sourceIndex >= ${i}) { return zero_result(); } return read_source_values(u32(sourceIndex)); -}`}var XC,KC=C(()=>{Ce();Io();ls();Ud();XC=async({inputs:n,output:e,target:t})=>{let{ids:i,sourceValues:r}=n,s=we(i.type),o=[];i.isConstant||o.push({name:"ids",input:i,index:o.length}),r.isConstant||o.push({name:"sourceValues",input:r,index:o.length});let a=ti(Math.ceil(e.length/mt),t.device.limits.maxComputeWorkgroupsPerDimension),c=` +}`}var KC,QC=C(()=>{Me();Io();ls();$d();KC=async({inputs:n,output:e,target:t})=>{let{ids:i,sourceValues:r}=n,s=Se(i.type),o=[];i.isConstant||o.push({name:"ids",input:i,index:o.length}),r.isConstant||o.push({name:"sourceValues",input:r,index:o.length});let a=si(Math.ceil(e.length/mt),t.device.limits.maxComputeWorkgroupsPerDimension),c=` ${o.map(({name:d,input:h,index:p})=>Bo(d,h,p)).join(` `)} -${GU(i,s)} -${zd(r,e.type)} +${jU(i,s)} +${Ud(r,e.type)} ${Oo(e,o.length)} ${Do(e)} -${jC(e.type,e.size)} -${VU(i.type,e.type,e.size,r.length)} +${HC(e.type,e.size)} +${HU(i.type,e.type,e.size,r.length)} @compute @workgroup_size(${mt}) fn main( @builtin(workgroup_id) workgroupId: vec3, @builtin(local_invocation_id) localId: vec3 ) { - let rowIndex = ${nr(a,mt)}; + let rowIndex = ${rr(a,mt)}; if (rowIndex >= ${e.length}u) { return; } @@ -3212,7 +3212,7 @@ ${VU(i.type,e.type,e.size,r.length)} let result = gather(idsValue); write_result(rowIndex, result); } -`,l=new Rt(t.device,{source:c,shaderLayout:{bindings:[...o.map(({name:d,index:h})=>({name:d,type:"storage",group:0,location:h})),{name:"result",type:"storage",group:0,location:o.length}]}}),u={};i.isConstant||(u.ids=i.buffer),r.isConstant||(u.sourceValues=r.buffer),u.result=t,l.setBindings(u);let f=t.device.beginComputePass({});return l.dispatch(f,a.x,a.y,a.z),f.end(),t.device.submit(),l.destroy(),{success:!0}}});function WU(n){return`fn segmented_map(vertexIndex: u32) -> array { +`,l=new Bt(t.device,{source:c,shaderLayout:{bindings:[...o.map(({name:d,index:h})=>({name:d,type:"storage",group:0,location:h})),{name:"result",type:"storage",group:0,location:o.length}]}}),u={};i.isConstant||(u.ids=i.buffer),r.isConstant||(u.sourceValues=r.buffer),u.result=t,l.setBindings(u);let f=t.device.beginComputePass({});return l.dispatch(f,a.x,a.y,a.z),f.end(),t.device.submit(),l.destroy(),{success:!0}}});function YU(n){return`fn segmented_map(vertexIndex: u32) -> array { var low = 0i; var high = ${n}i; while (low < high) { @@ -3228,19 +3228,19 @@ ${VU(i.type,e.type,e.size,r.length)} let segmentIndex = u32(max(low - 1i, 0i)); let segmentStart = read_segments(segmentIndex)[0]; return array(segmentIndex, vertexIndex - segmentStart); -}`}var QC,JC=C(()=>{Ce();Io();Ud();QC=async({inputs:n,output:e,target:t})=>{let{segments:i}=n,r=i.isConstant?[]:[{name:"segments",input:i,index:0}],s=ti(Math.ceil(e.length/mt),t.device.limits.maxComputeWorkgroupsPerDimension),o=` +}`}var JC,eT=C(()=>{Me();Io();$d();JC=async({inputs:n,output:e,target:t})=>{let{segments:i}=n,r=i.isConstant?[]:[{name:"segments",input:i,index:0}],s=si(Math.ceil(e.length/mt),t.device.limits.maxComputeWorkgroupsPerDimension),o=` ${r.map(({name:u,input:f,index:d})=>Bo(u,f,d)).join(` `)} -${Uy("segments",i,"uint32")} +${$y("segments",i,"uint32")} ${Oo(e,r.length)} ${Do(e)} -${WU(i.length)} +${YU(i.length)} @compute @workgroup_size(${mt}) fn main( @builtin(workgroup_id) workgroupId: vec3, @builtin(local_invocation_id) localId: vec3 ) { - let rowIndex = ${nr(s,mt)}; + let rowIndex = ${rr(s,mt)}; if (rowIndex >= ${e.length}u) { return; } @@ -3248,28 +3248,28 @@ ${WU(i.length)} let result = segmented_map(rowIndex); write_result(rowIndex, result); } -`,a=new Rt(t.device,{source:o,shaderLayout:{bindings:[...r.map(({name:u,index:f})=>({name:u,type:"storage",group:0,location:f})),{name:"result",type:"storage",group:0,location:r.length}]}}),c=Object.fromEntries(r.map(({name:u,input:f})=>[u,f.buffer]));c.result=t,a.setBindings(c);let l=t.device.beginComputePass({});return a.dispatch(l,s.x,s.y,s.z),l.end(),t.device.submit(),a.destroy(),{success:!0}}});function jU(n,e){let i=e.filter(([,r])=>!r.isConstant).length+1;if(i>n.maxStorageBuffersPerShaderStage)throw new Error(`interleave() requires ${i} storage buffers, exceeding device limit ${n.maxStorageBuffersPerShaderStage}`);if(i>n.maxBindingsPerBindGroup)throw new Error(`interleave() requires ${i} bindings, exceeding bind group limit ${n.maxBindingsPerBindGroup}`)}var $d,eT=C(()=>{Pi();$d=({inputs:n,output:e,target:t})=>{let i=n.map((c,l)=>[`x${l}`,c]);jU(t.device.limits,i);let r=i.map(([c,l])=>`${c}: array<{TYPE}, ${l.size}>`).join(", "),s=0,o=i.map(([c,l])=>{let u=Array.from({length:l.size},(f,d)=>` out[${s+d}] = ${c}[${d}];`).join(` +`,a=new Bt(t.device,{source:o,shaderLayout:{bindings:[...r.map(({name:u,index:f})=>({name:u,type:"storage",group:0,location:f})),{name:"result",type:"storage",group:0,location:r.length}]}}),c=Object.fromEntries(r.map(({name:u,input:f})=>[u,f.buffer]));c.result=t,a.setBindings(c);let l=t.device.beginComputePass({});return a.dispatch(l,s.x,s.y,s.z),l.end(),t.device.submit(),a.destroy(),{success:!0}}});function qU(n,e){let i=e.filter(([,r])=>!r.isConstant).length+1;if(i>n.maxStorageBuffersPerShaderStage)throw new Error(`interleave() requires ${i} storage buffers, exceeding device limit ${n.maxStorageBuffersPerShaderStage}`);if(i>n.maxBindingsPerBindGroup)throw new Error(`interleave() requires ${i} bindings, exceeding bind group limit ${n.maxBindingsPerBindGroup}`)}var Gd,tT=C(()=>{Ai();Gd=({inputs:n,output:e,target:t})=>{let i=n.map((c,l)=>[`x${l}`,c]);qU(t.device.limits,i);let r=i.map(([c,l])=>`${c}: array<{TYPE}, ${l.size}>`).join(", "),s=0,o=i.map(([c,l])=>{let u=Array.from({length:l.size},(f,d)=>` out[${s+d}] = ${c}[${d}];`).join(` `);return s+=l.size,u}).join(` `),a=`fn interleave(${r}) -> array<{TYPE}, {RESULT_LEN}> { var out: array<{TYPE}, {RESULT_LEN}>; ${o} return out; } -`;return ot({module:{name:"interleave",source:a},inputs:n,output:e,outputBuffer:t}),{success:!0}}});var HU,tT,nT=C(()=>{Pi();HU=`fn row_length(x: array<{TYPE}, {X_LEN}>) -> array { +`;return st({module:{name:"interleave",source:a},inputs:n,output:e,outputBuffer:t}),{success:!0}}});var ZU,nT,iT=C(()=>{Ai();ZU=`fn row_length(x: array<{TYPE}, {X_LEN}>) -> array { var sum = 0.0; for (var i = 0u; i < {X_LEN}u; i = i + 1u) { sum += f32(x[i]) * f32(x[i]); } return array(sqrt(sum)); } -`,tT=({inputs:n,output:e,target:t})=>(ot({module:{name:"row_length",source:HU},inputs:n,output:e,operationType:"float32",outputBuffer:t}),{success:!0})});function $y(n,e,t,i){return t{Pi();ls();iT=async({inputs:n,output:e,target:t})=>{let i=rr(e.type);return ot({module:{name:"select",source:`// inline expression select -`},inputs:n,output:e,operationType:e.type,outputBuffer:t,expression:r=>{let s=$y("condition",n.condition,r,i),o=$y("whenTrue",n.whenTrue,r,i);return`select(${$y("whenFalse",n.whenFalse,r,i)}, ${o}, ${s} != ${i})`}}),{success:!0}}});var Gy,sT,oT=C(()=>{Ce();Io();Gy=64,sT=({inputs:n,output:e,target:t})=>{let i=ti(Math.ceil(e.length/Gy),t.device.limits.maxComputeWorkgroupsPerDimension),r=`@group(0) @binding(0) var result: array; +`,nT=({inputs:n,output:e,target:t})=>(st({module:{name:"row_length",source:ZU},inputs:n,output:e,operationType:"float32",outputBuffer:t}),{success:!0})});function Gy(n,e,t,i){return t{Ai();ls();rT=async({inputs:n,output:e,target:t})=>{let i=or(e.type);return st({module:{name:"select",source:`// inline expression select +`},inputs:n,output:e,operationType:e.type,outputBuffer:t,expression:r=>{let s=Gy("condition",n.condition,r,i),o=Gy("whenTrue",n.whenTrue,r,i);return`select(${Gy("whenFalse",n.whenFalse,r,i)}, ${o}, ${s} != ${i})`}}),{success:!0}}});var Vy,oT,aT=C(()=>{Me();Io();Vy=64,oT=({inputs:n,output:e,target:t})=>{let i=si(Math.ceil(e.length/Vy),t.device.limits.maxComputeWorkgroupsPerDimension),r=`@group(0) @binding(0) var result: array; -@compute @workgroup_size(${Gy}) fn main( +@compute @workgroup_size(${Vy}) fn main( @builtin(workgroup_id) workgroupId: vec3, @builtin(local_invocation_id) localId: vec3 ) { - let rowIndex = ${nr(i,Gy)}; + let rowIndex = ${rr(i,Vy)}; if (rowIndex >= ${e.length}u) { return; } @@ -3277,27 +3277,27 @@ ${o} let rowOffset = ${e.offset/e.ValueType.BYTES_PER_ELEMENT}u + rowIndex * ${e.stride/e.ValueType.BYTES_PER_ELEMENT}u; result[rowOffset] = ${n.start} + i32(rowIndex) * ${n.step}; } -`,s=new Rt(t.device,{source:r,shaderLayout:{bindings:[{name:"result",type:"storage",group:0,location:0}]}});s.setBindings({result:t});let o=t.device.beginComputePass({});return s.dispatch(o,i.x,i.y,i.z),o.end(),t.device.submit(),s.destroy(),{success:!0}}});var aT,cT=C(()=>{Pi();aT=({inputs:n,output:e,target:t})=>{let{columns:i}=n;return ot({module:{name:"swizzle",source:"// swizzle expression handled inline"},expression:r=>`x[${i[r]}]`,inputs:{x:n.x},output:e,outputBuffer:t}),{success:!0}}});var lT={};ui(lT,{arithmetic:()=>zC,dot:()=>$C,equalAll:()=>VC,extent:()=>HC,fround:()=>qC,gather:()=>XC,interleave:()=>$d,length:()=>tT,segmentedMap:()=>QC,select:()=>iT,sequence:()=>sT,swizzle:()=>aT});var Vy=C(()=>{UC();GC();WC();YC();ZC();KC();JC();eT();nT();rT();oT();cT()});var _L=KM((eye,bb)=>{"use strict";bb.exports=sh;bb.exports.default=sh;function sh(n,e,t){t=t||2;var i=e&&e.length,r=i?e[0]*t:n.length,s=pL(n,0,r,t,!0),o=[];if(!s||s.next===s.prev)return o;var a,c,l,u,f,d,h;if(i&&(s=BG(n,e,s,t)),n.length>80*t){a=l=n[0],c=u=n[1];for(var p=t;pl&&(l=f),d>u&&(u=d);h=Math.max(l-a,u-c),h=h!==0?32767/h:0}return El(s,o,t,a,c,h,0),o}function pL(n,e,t,i,r){var s,o;if(r===yb(n,e,t,i)>0)for(s=e;s=e;s-=i)o=hL(s,n[s],n[s+1],o);return o&&oh(o,o.next)&&(Pl(o),o=o.next),o}function fs(n,e){if(!n)return n;e||(e=n);var t=n,i;do if(i=!1,!t.steiner&&(oh(t,t.next)||Te(t.prev,t,t.next)===0)){if(Pl(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function El(n,e,t,i,r,s,o){if(n){!o&&s&&zG(n,i,r,s);for(var a=n,c,l;n.prev!==n.next;){if(c=n.prev,l=n.next,s?kG(n,i,r,s):AG(n)){e.push(c.i/t|0),e.push(n.i/t|0),e.push(l.i/t|0),Pl(n),n=l.next,a=l.next;continue}if(n=l,n===a){o?o===1?(n=RG(fs(n),e,t),El(n,e,t,i,r,s,2)):o===2&&IG(n,e,t,i,r,s):El(fs(n),e,t,i,r,s,1);break}}}}function AG(n){var e=n.prev,t=n,i=n.next;if(Te(e,t,i)>=0)return!1;for(var r=e.x,s=t.x,o=i.x,a=e.y,c=t.y,l=i.y,u=rs?r>o?r:o:s>o?s:o,h=a>c?a>l?a:l:c>l?c:l,p=i.next;p!==e;){if(p.x>=u&&p.x<=d&&p.y>=f&&p.y<=h&&Uo(r,a,s,c,o,l,p.x,p.y)&&Te(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function kG(n,e,t,i){var r=n.prev,s=n,o=n.next;if(Te(r,s,o)>=0)return!1;for(var a=r.x,c=s.x,l=o.x,u=r.y,f=s.y,d=o.y,h=ac?a>l?a:l:c>l?c:l,g=u>f?u>d?u:d:f>d?f:d,v=gb(h,p,e,t,i),y=gb(m,g,e,t,i),b=n.prevZ,w=n.nextZ;b&&b.z>=v&&w&&w.z<=y;){if(b.x>=h&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==o&&Uo(a,u,c,f,l,d,b.x,b.y)&&Te(b.prev,b,b.next)>=0||(b=b.prevZ,w.x>=h&&w.x<=m&&w.y>=p&&w.y<=g&&w!==r&&w!==o&&Uo(a,u,c,f,l,d,w.x,w.y)&&Te(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;b&&b.z>=v;){if(b.x>=h&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==o&&Uo(a,u,c,f,l,d,b.x,b.y)&&Te(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;w&&w.z<=y;){if(w.x>=h&&w.x<=m&&w.y>=p&&w.y<=g&&w!==r&&w!==o&&Uo(a,u,c,f,l,d,w.x,w.y)&&Te(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function RG(n,e,t){var i=n;do{var r=i.prev,s=i.next.next;!oh(r,s)&&mL(r,i,i.next,s)&&Sl(r,s)&&Sl(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),Pl(i),Pl(i.next),i=n=s),i=i.next}while(i!==n);return fs(i)}function IG(n,e,t,i,r,s){var o=n;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&GG(o,a)){var c=gL(o,a);o=fs(o,o.next),c=fs(c,c.next),El(o,e,t,i,r,s,0),El(c,e,t,i,r,s,0);return}a=a.next}o=o.next}while(o!==n)}function BG(n,e,t,i){var r=[],s,o,a,c,l;for(s=0,o=e.length;s=t.next.y&&t.next.y!==t.y){var a=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(a<=i&&a>s&&(s=a,o=t.x=t.x&&t.x>=l&&i!==t.x&&Uo(ro.x||t.x===o.x&&FG(o,t)))&&(o=t,f=d)),t=t.next;while(t!==c);return o}function FG(n,e){return Te(n.prev,n,e.prev)<0&&Te(e.next,n,n.next)<0}function zG(n,e,t,i){var r=n;do r.z===0&&(r.z=gb(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,UG(r)}function UG(n){var e,t,i,r,s,o,a,c,l=1;do{for(t=n,n=null,s=null,o=0;t;){for(o++,i=t,a=0,e=0;e0||c>0&&i;)a!==0&&(c===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,a--):(r=i,i=i.nextZ,c--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,l*=2}while(o>1);return n}function gb(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function $G(n){var e=n,t=n;do(e.x=(n-o)*(s-a)&&(n-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(i-a)}function GG(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!VG(n,e)&&(Sl(n,e)&&Sl(e,n)&&WG(n,e)&&(Te(n.prev,n,e.prev)||Te(n,e.prev,e))||oh(n,e)&&Te(n.prev,n,n.next)>0&&Te(e.prev,e,e.next)>0)}function Te(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function oh(n,e){return n.x===e.x&&n.y===e.y}function mL(n,e,t,i){var r=rh(Te(n,e,t)),s=rh(Te(n,e,i)),o=rh(Te(t,i,n)),a=rh(Te(t,i,e));return!!(r!==s&&o!==a||r===0&&ih(n,t,e)||s===0&&ih(n,i,e)||o===0&&ih(t,n,i)||a===0&&ih(t,e,i))}function ih(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function rh(n){return n>0?1:n<0?-1:0}function VG(n,e){var t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&mL(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Sl(n,e){return Te(n.prev,n,n.next)<0?Te(n,e,n.next)>=0&&Te(n,n.prev,e)>=0:Te(n,e,n.prev)<0||Te(n,n.next,e)<0}function WG(n,e){var t=n,i=!1,r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function gL(n,e){var t=new _b(n.i,n.x,n.y),i=new _b(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function hL(n,e,t,i){var r=new _b(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Pl(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function _b(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}sh.deviation=function(n,e,t,i){var r=e&&e.length,s=r?e[0]*t:n.length,o=Math.abs(yb(n,0,s,t));if(r)for(var a=0,c=e.length;a0&&(i+=n[r-1].length,t.holes.push(i))}return t}});function Di(n,e){if(!n)throw new Error(e||"loader assertion failed.")}var Mn={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},eA=Mn.self||Mn.window||Mn.global||{},tA=Mn.window||Mn.self||Mn.global||{},nA=Mn.global||Mn.self||Mn.window||{},iA=Mn.document||{};var br=!!(typeof process!="object"||String(process)!=="[object process]"||process.browser);var _v=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),rA=_v&&parseFloat(_v[1])||0;ra();var xp="4.5.4",dA=xp[0]>="0"&&xp[0]<="9"?`v${xp}`:"";function hA(){let n=new ct({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=n,globalThis.loaders.version=dA,globalThis.probe||={},globalThis.probe.loaders=n,n}var wp=hA();var pA=n=>typeof n=="boolean",kn=n=>typeof n=="function",Rn=n=>n!==null&&typeof n=="object",nu=n=>Rn(n)&&n.constructor==={}.constructor;var Ep=n=>typeof SharedArrayBuffer<"u"&&n instanceof SharedArrayBuffer,Os=n=>Rn(n)&&typeof n.byteLength=="number"&&typeof n.slice=="function";var Sp=n=>!!n&&kn(n[Symbol.iterator]),Pp=n=>!!n&&kn(n[Symbol.asyncIterator]);var Ct=n=>typeof Response<"u"&&n instanceof Response||Rn(n)&&kn(n.arrayBuffer)&&kn(n.text)&&kn(n.json);var Tt=n=>typeof Blob<"u"&&n instanceof Blob;var Iv=n=>typeof ReadableStream<"u"&&n instanceof ReadableStream||Rn(n)&&kn(n.tee)&&kn(n.cancel)&&kn(n.getReader);var Bv=n=>Rn(n)&&kn(n.read)&&kn(n.pipe)&&pA(n.readable),sa=n=>Iv(n)||Bv(n);function Cp(n,e){return Ov(n||{},e)}function Ov(n,e,t=0){if(t>3)return e;let i={...n};for(let[r,s]of Object.entries(e))s&&typeof s=="object"&&!Array.isArray(s)?i[r]=Ov(i[r]||{},e[r],t+1):i[r]=e[r];return i}var Dv="latest";function mA(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.5.4"),globalThis._loadersgl_.version}var Nv=mA();function lt(n,e){if(!n)throw new Error(e||"loaders.gl assertion failed.")}var In={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},Vj=In.self||In.window||In.global||{},Wj=In.window||In.self||In.global||{},jj=In.global||In.self||In.window||{},Hj=In.document||{};var Gt=typeof process!="object"||String(process)!=="[object process]"||process.browser;var zv=typeof window<"u"&&typeof window.orientation<"u",Fv=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),Yj=Fv&&parseFloat(Fv[1])||0;var oa=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,t){this.name=e,this.workerThread=t,this.result=new Promise((i,r)=>{this._resolve=i,this._reject=r})}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){lt(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){lt(this.isRunning),this.isRunning=!1,this._reject(e)}};var Ds=class{terminate(){}};var Tp=new Map;function Uv(n){lt(n.source&&!n.url||!n.source&&n.url);let e=Tp.get(n.source||n.url);return e||(n.url&&(e=gA(n.url),Tp.set(n.url,e)),n.source&&(e=$v(n.source),Tp.set(n.source,e))),lt(e),e}function gA(n){if(!n.startsWith("http"))return n;let e=_A(n);return $v(e)}function $v(n){let e=new Blob([n],{type:"application/javascript"});return URL.createObjectURL(e)}function _A(n){return`try { +`,s=new Bt(t.device,{source:r,shaderLayout:{bindings:[{name:"result",type:"storage",group:0,location:0}]}});s.setBindings({result:t});let o=t.device.beginComputePass({});return s.dispatch(o,i.x,i.y,i.z),o.end(),t.device.submit(),s.destroy(),{success:!0}}});var cT,lT=C(()=>{Ai();cT=({inputs:n,output:e,target:t})=>{let{columns:i}=n;return st({module:{name:"swizzle",source:"// swizzle expression handled inline"},expression:r=>`x[${i[r]}]`,inputs:{x:n.x},output:e,outputBuffer:t}),{success:!0}}});var uT={};mi(uT,{arithmetic:()=>UC,dot:()=>GC,equalAll:()=>WC,extent:()=>YC,fround:()=>ZC,gather:()=>KC,interleave:()=>Gd,length:()=>nT,segmentedMap:()=>JC,select:()=>rT,sequence:()=>oT,swizzle:()=>cT});var Wy=C(()=>{$C();VC();jC();qC();XC();QC();eT();tT();iT();sT();aT();lT()});var yL=eA((sye,vb)=>{"use strict";vb.exports=oh;vb.exports.default=oh;function oh(n,e,t){t=t||2;var i=e&&e.length,r=i?e[0]*t:n.length,s=mL(n,0,r,t,!0),o=[];if(!s||s.next===s.prev)return o;var a,c,l,u,f,d,h;if(i&&(s=NG(n,e,s,t)),n.length>80*t){a=l=n[0],c=u=n[1];for(var p=t;pl&&(l=f),d>u&&(u=d);h=Math.max(l-a,u-c),h=h!==0?32767/h:0}return Sl(s,o,t,a,c,h,0),o}function mL(n,e,t,i,r){var s,o;if(r===bb(n,e,t,i)>0)for(s=e;s=e;s-=i)o=pL(s,n[s],n[s+1],o);return o&&ah(o,o.next)&&(Cl(o),o=o.next),o}function fs(n,e){if(!n)return n;e||(e=n);var t=n,i;do if(i=!1,!t.steiner&&(ah(t,t.next)||Ae(t.prev,t,t.next)===0)){if(Cl(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Sl(n,e,t,i,r,s,o){if(n){!o&&s&&GG(n,i,r,s);for(var a=n,c,l;n.prev!==n.next;){if(c=n.prev,l=n.next,s?BG(n,i,r,s):IG(n)){e.push(c.i/t|0),e.push(n.i/t|0),e.push(l.i/t|0),Cl(n),n=l.next,a=l.next;continue}if(n=l,n===a){o?o===1?(n=OG(fs(n),e,t),Sl(n,e,t,i,r,s,2)):o===2&&DG(n,e,t,i,r,s):Sl(fs(n),e,t,i,r,s,1);break}}}}function IG(n){var e=n.prev,t=n,i=n.next;if(Ae(e,t,i)>=0)return!1;for(var r=e.x,s=t.x,o=i.x,a=e.y,c=t.y,l=i.y,u=rs?r>o?r:o:s>o?s:o,h=a>c?a>l?a:l:c>l?c:l,p=i.next;p!==e;){if(p.x>=u&&p.x<=d&&p.y>=f&&p.y<=h&&Uo(r,a,s,c,o,l,p.x,p.y)&&Ae(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function BG(n,e,t,i){var r=n.prev,s=n,o=n.next;if(Ae(r,s,o)>=0)return!1;for(var a=r.x,c=s.x,l=o.x,u=r.y,f=s.y,d=o.y,h=ac?a>l?a:l:c>l?c:l,g=u>f?u>d?u:d:f>d?f:d,v=_b(h,p,e,t,i),y=_b(m,g,e,t,i),b=n.prevZ,x=n.nextZ;b&&b.z>=v&&x&&x.z<=y;){if(b.x>=h&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==o&&Uo(a,u,c,f,l,d,b.x,b.y)&&Ae(b.prev,b,b.next)>=0||(b=b.prevZ,x.x>=h&&x.x<=m&&x.y>=p&&x.y<=g&&x!==r&&x!==o&&Uo(a,u,c,f,l,d,x.x,x.y)&&Ae(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;b&&b.z>=v;){if(b.x>=h&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==o&&Uo(a,u,c,f,l,d,b.x,b.y)&&Ae(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;x&&x.z<=y;){if(x.x>=h&&x.x<=m&&x.y>=p&&x.y<=g&&x!==r&&x!==o&&Uo(a,u,c,f,l,d,x.x,x.y)&&Ae(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function OG(n,e,t){var i=n;do{var r=i.prev,s=i.next.next;!ah(r,s)&&gL(r,i,i.next,s)&&Pl(r,s)&&Pl(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),Cl(i),Cl(i.next),i=n=s),i=i.next}while(i!==n);return fs(i)}function DG(n,e,t,i,r,s){var o=n;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&jG(o,a)){var c=_L(o,a);o=fs(o,o.next),c=fs(c,c.next),Sl(o,e,t,i,r,s,0),Sl(c,e,t,i,r,s,0);return}a=a.next}o=o.next}while(o!==n)}function NG(n,e,t,i){var r=[],s,o,a,c,l;for(s=0,o=e.length;s=t.next.y&&t.next.y!==t.y){var a=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(a<=i&&a>s&&(s=a,o=t.x=t.x&&t.x>=l&&i!==t.x&&Uo(ro.x||t.x===o.x&&$G(o,t)))&&(o=t,f=d)),t=t.next;while(t!==c);return o}function $G(n,e){return Ae(n.prev,n,e.prev)<0&&Ae(e.next,n,n.next)<0}function GG(n,e,t,i){var r=n;do r.z===0&&(r.z=_b(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,VG(r)}function VG(n){var e,t,i,r,s,o,a,c,l=1;do{for(t=n,n=null,s=null,o=0;t;){for(o++,i=t,a=0,e=0;e0||c>0&&i;)a!==0&&(c===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,a--):(r=i,i=i.nextZ,c--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,l*=2}while(o>1);return n}function _b(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function WG(n){var e=n,t=n;do(e.x=(n-o)*(s-a)&&(n-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(i-a)}function jG(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!HG(n,e)&&(Pl(n,e)&&Pl(e,n)&&YG(n,e)&&(Ae(n.prev,n,e.prev)||Ae(n,e.prev,e))||ah(n,e)&&Ae(n.prev,n,n.next)>0&&Ae(e.prev,e,e.next)>0)}function Ae(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function ah(n,e){return n.x===e.x&&n.y===e.y}function gL(n,e,t,i){var r=sh(Ae(n,e,t)),s=sh(Ae(n,e,i)),o=sh(Ae(t,i,n)),a=sh(Ae(t,i,e));return!!(r!==s&&o!==a||r===0&&rh(n,t,e)||s===0&&rh(n,i,e)||o===0&&rh(t,n,i)||a===0&&rh(t,e,i))}function rh(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function sh(n){return n>0?1:n<0?-1:0}function HG(n,e){var t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&gL(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Pl(n,e){return Ae(n.prev,n,n.next)<0?Ae(n,e,n.next)>=0&&Ae(n,n.prev,e)>=0:Ae(n,e,n.prev)<0||Ae(n,n.next,e)<0}function YG(n,e){var t=n,i=!1,r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function _L(n,e){var t=new yb(n.i,n.x,n.y),i=new yb(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function pL(n,e,t,i){var r=new yb(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Cl(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function yb(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}oh.deviation=function(n,e,t,i){var r=e&&e.length,s=r?e[0]*t:n.length,o=Math.abs(bb(n,0,s,t));if(r)for(var a=0,c=e.length;a0&&(i+=n[r-1].length,t.holes.push(i))}return t}});function Fi(n,e){if(!n)throw new Error(e||"loader assertion failed.")}var In={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},iA=In.self||In.window||In.global||{},rA=In.window||In.self||In.global||{},sA=In.global||In.self||In.window||{},oA=In.document||{};var br=!!(typeof process!="object"||String(process)!=="[object process]"||process.browser);var yv=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),aA=yv&&parseFloat(yv[1])||0;sa();var wp="4.5.4",mA=wp[0]>="0"&&wp[0]<="9"?`v${wp}`:"";function gA(){let n=new ct({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=n,globalThis.loaders.version=mA,globalThis.probe||={},globalThis.probe.loaders=n,n}var Ep=gA();var _A=n=>typeof n=="boolean",On=n=>typeof n=="function",Dn=n=>n!==null&&typeof n=="object",iu=n=>Dn(n)&&n.constructor==={}.constructor;var Sp=n=>typeof SharedArrayBuffer<"u"&&n instanceof SharedArrayBuffer,Os=n=>Dn(n)&&typeof n.byteLength=="number"&&typeof n.slice=="function";var Pp=n=>!!n&&On(n[Symbol.iterator]),Cp=n=>!!n&&On(n[Symbol.asyncIterator]);var Lt=n=>typeof Response<"u"&&n instanceof Response||Dn(n)&&On(n.arrayBuffer)&&On(n.text)&&On(n.json);var Mt=n=>typeof Blob<"u"&&n instanceof Blob;var Bv=n=>typeof ReadableStream<"u"&&n instanceof ReadableStream||Dn(n)&&On(n.tee)&&On(n.cancel)&&On(n.getReader);var Ov=n=>Dn(n)&&On(n.read)&&On(n.pipe)&&_A(n.readable),oa=n=>Bv(n)||Ov(n);function Tp(n,e){return Dv(n||{},e)}function Dv(n,e,t=0){if(t>3)return e;let i={...n};for(let[r,s]of Object.entries(e))s&&typeof s=="object"&&!Array.isArray(s)?i[r]=Dv(i[r]||{},e[r],t+1):i[r]=e[r];return i}var Nv="latest";function yA(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.5.4"),globalThis._loadersgl_.version}var Fv=yA();function lt(n,e){if(!n)throw new Error(e||"loaders.gl assertion failed.")}var Nn={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},qj=Nn.self||Nn.window||Nn.global||{},Zj=Nn.window||Nn.self||Nn.global||{},Xj=Nn.global||Nn.self||Nn.window||{},Kj=Nn.document||{};var Ht=typeof process!="object"||String(process)!=="[object process]"||process.browser;var Uv=typeof window<"u"&&typeof window.orientation<"u",zv=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),Qj=zv&&parseFloat(zv[1])||0;var aa=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,t){this.name=e,this.workerThread=t,this.result=new Promise((i,r)=>{this._resolve=i,this._reject=r})}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){lt(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){lt(this.isRunning),this.isRunning=!1,this._reject(e)}};var Ds=class{terminate(){}};var Lp=new Map;function $v(n){lt(n.source&&!n.url||!n.source&&n.url);let e=Lp.get(n.source||n.url);return e||(n.url&&(e=bA(n.url),Lp.set(n.url,e)),n.source&&(e=Gv(n.source),Lp.set(n.source,e))),lt(e),e}function bA(n){if(!n.startsWith("http"))return n;let e=vA(n);return Gv(e)}function Gv(n){let e=new Blob([n],{type:"application/javascript"});return URL.createObjectURL(e)}function vA(n){return`try { importScripts('${n}'); } catch (error) { console.error(error); throw error; -}`}function Lp(n,e=!0,t){let i=t||new Set;if(n){if(Gv(n))i.add(n);else if(Gv(n.buffer))i.add(n.buffer);else if(!ArrayBuffer.isView(n)){if(e&&typeof n=="object")for(let r in n)Lp(n[r],e,i)}}return t===void 0?Array.from(i):[]}function Gv(n){return n?n instanceof ArrayBuffer||typeof MessagePort<"u"&&n instanceof MessagePort||typeof ImageBitmap<"u"&&n instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas:!1}var Mp=()=>{},Ni=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&Gt||typeof Ds<"u"&&!Gt}constructor(e){let{name:t,source:i,url:r}=e;lt(i||r),this.name=t,this.source=i,this.url=r,this.onMessage=Mp,this.onError=s=>console.log(s),this.worker=Gt?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=Mp,this.onError=Mp,this.worker.terminate(),this.terminated=!0}get isRunning(){return!!this.onMessage}postMessage(e,t){t=t||Lp(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+=`worker ${this.name} from ${this.url}. `,e.message&&(t+=`${e.message} in `),e.lineno&&(t+=`:${e.lineno}:${e.colno}`),new Error(t)}_createBrowserWorker(){this._loadableURL=Uv({source:this.source,url:this.url});let e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=t=>{t.data?this.onMessage(t.data):this.onError(new Error("No data received"))},e.onerror=t=>{this.onError(this._getErrorFromErrorEvent(t)),this.terminated=!0},e.onmessageerror=t=>console.error(t),e}_createNodeWorker(){let e;if(this.url){let i=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`,r=this.url.endsWith(".ts")||this.url.endsWith(".mjs")?"module":"commonjs";e=new Ds(i,{eval:!1,type:r})}else if(this.source)e=new Ds(this.source,{eval:!0});else throw new Error("no worker");return e.on("message",t=>{this.onMessage(t)}),e.on("error",t=>{this.onError(t)}),e.on("exit",t=>{}),e}};var aa=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return Ni.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},e.name!==void 0&&(this.name=e.name),e.maxConcurrency!==void 0&&(this.maxConcurrency=e.maxConcurrency),e.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=e.maxMobileConcurrency),e.reuseWorkers!==void 0&&(this.reuseWorkers=e.reuseWorkers),e.onDebug!==void 0&&(this.onDebug=e.onDebug)}async startJob(e,t=(r,s,o)=>r.done(o),i=(r,s)=>r.error(s)){let r=new Promise(s=>(this.jobQueue.push({name:e,onMessage:t,onError:i,onStart:s}),this));return this._startQueuedJob(),await r}async _startQueuedJob(){if(!this.jobQueue.length)return;let e=this._getAvailableWorker();if(!e)return;let t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});let i=new oa(t.name,e);e.onMessage=r=>t.onMessage(i,r.type,r.payload),e.onError=r=>t.onError(i,r),t.onStart(i);try{await i.result}catch(r){console.error(`Worker exception: ${r}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!Gt||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count{}},wr=class n{props;workerPools=new Map;static _workerFarm;static isSupported(){return Ni.isSupported()}static getWorkerFarm(e={}){return n._workerFarm=n._workerFarm||new n({}),n._workerFarm.setProps(e),n._workerFarm}constructor(e){this.props={...yA},this.setProps(e),this.workerPools=new Map}destroy(){for(let e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(let t of this.workerPools.values())t.setProps(this._getWorkerPoolProps())}getWorkerPool(e){let{name:t,source:i,url:r}=e,s=this.workerPools.get(t);return s||(s=new aa({name:t,source:i,url:r}),s.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,s)),s}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}};function Ap(n,e={}){let t=e[n.id]||{},i=Gt?n.workerFile||`${n.id}-worker.js`:`${n.id}-worker-node.js`,r=t.workerUrl;if(!r&&n.id==="compression"&&(r=e.workerUrl),(e._workerType||e?.core?._workerType)==="test"&&(Gt?r=`modules/${n.module}/dist/${i}`:r=`modules/${n.module}/src/workers/${n.id}-worker-node.ts`),!r){let o=n.version;o==="latest"&&(o=Dv);let a=o?`@${o}`:"";r=`loaders.gl-cdn-disabled/${n.module}${a}/dist/${i}`}return lt(r),r}function kp(n,e=Nv){lt(n,"no worker provided");let t=n.version;return!(!e||!t)}function Rp(n,e){if(!wr.isSupported())return!1;let t=e?._nodeWorkers??e?.core?._nodeWorkers;if(!Gt&&!t)return!1;let i=e?.worker??e?.core?.worker;return!!(n.worker&&i)}async function Ip(n,e,t,i,r){let s=n.id,o=Ap(n,t),c=wr.getWorkerFarm(t?.core).getWorkerPool({name:s,url:o});t=JSON.parse(JSON.stringify(t||{})),t._workerLoaderId=n.id,i=JSON.parse(JSON.stringify(i||{}));let l=await c.startJob("process-on-worker",bA.bind(null,r));return l.postMessage("process",{input:e,options:t,context:i}),await(await l.result).result}async function bA(n,e,t,i){switch(t){case"done":e.done(i);break;case"error":e.error(new Error(i.error));break;case"process":let{id:r,input:s,options:o}=i;try{let a=await n(s,o);e.postMessage("done",{id:r,result:a})}catch(a){let c=a instanceof Error?a.message:"unknown error";e.postMessage("error",{id:r,error:c})}break;default:console.warn(`parse-with-worker unknown message ${t}`)}}function Bp(n,e,t){if(t=t||n.byteLength,n.byteLengths instanceof ArrayBuffer?new Uint8Array(s):s),t=e.reduce((s,o)=>s+o.byteLength,0),i=new Uint8Array(t),r=0;for(let s of e)i.set(s,r),r+=s.byteLength;return i.buffer}async function Dp(n){let e=[];for await(let t of n)e.push(vA(t));return Op(...e)}function vA(n){if(n instanceof ArrayBuffer)return n;if(ArrayBuffer.isView(n)){let{buffer:e,byteOffset:t,byteLength:i}=n;return Wv(e,t,i)}return Wv(n)}function Wv(n,e=0,t=n.byteLength-e){let i=new Uint8Array(n,e,t),r=new Uint8Array(i.length);return r.set(i),r.buffer}var xA="",Hv={};function zp(n){for(let e in Hv)if(n.startsWith(e)){let t=Hv[e];n=n.replace(e,t)}return!n.startsWith("http://")&&!n.startsWith("https://")&&(n=`${xA}${n}`),n}function ru(n){return n&&typeof n=="object"&&n.isBuffer}function Ns(n){if(ru(n))return n;if(n instanceof ArrayBuffer)return n;if(Ep(n))return iu(n);if(ArrayBuffer.isView(n)){let e=n.buffer;return n.byteOffset===0&&n.byteLength===n.buffer.byteLength?e:e.slice(n.byteOffset,n.byteOffset+n.byteLength)}if(typeof n=="string"){let e=n;return new TextEncoder().encode(e).buffer}if(n&&typeof n=="object"&&n._toArrayBuffer)return n._toArrayBuffer();throw new Error("toArrayBuffer")}function ua(n){if(n instanceof ArrayBuffer)return n;if(Ep(n))return iu(n);let{buffer:e,byteOffset:t,byteLength:i}=n;return e instanceof ArrayBuffer&&t===0&&i===e.byteLength?e:iu(e,t,i)}function iu(n,e=0,t=n.byteLength-e){let i=new Uint8Array(n,e,t),r=new Uint8Array(i.length);return r.set(i),r.buffer}function Up(n){return ArrayBuffer.isView(n)?n:new Uint8Array(n)}var fi={};ui(fi,{dirname:()=>EA,filename:()=>wA,join:()=>SA,resolve:()=>PA});function Yv(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let n=window.location?.pathname;return n?.slice(0,n.lastIndexOf("/")+1)||""}function wA(n){let e=n?n.lastIndexOf("/"):-1;return e>=0?n.substr(e+1):n}function EA(n){let e=n?n.lastIndexOf("/"):-1;return e>=0?n.substr(0,e):""}function SA(...n){let e="/";return n=n.map((t,i)=>(i&&(t=t.replace(new RegExp(`^${e}`),"")),i!==n.length-1&&(t=t.replace(new RegExp(`${e}$`),"")),t)),n.join(e)}function PA(...n){let e=[];for(let s=0;s=-1&&!i;s--){let o;s>=0?o=e[s]:(r===void 0&&(r=Yv()),o=r),o.length!==0&&(t=`${o}/${t}`,i=o.charCodeAt(0)===fa)}return t=CA(t,!i),i?`/${t}`:t.length>0?t:"."}var fa=47,$p=46;function CA(n,e){let t="",i=-1,r=0,s,o=!1;for(let a=0;a<=n.length;++a){if(a2){let c=t.length-1,l=c;for(;l>=0&&t.charCodeAt(l)!==fa;--l);if(l!==c){t=l===-1?"":t.slice(0,l),i=a,r=0,o=!1;continue}}else if(t.length===2||t.length===1){t="",i=a,r=0,o=!1;continue}}e&&(t.length>0?t+="/..":t="..",o=!0)}else{let c=n.slice(i+1,a);t.length>0?t+=`/${c}`:t=c,o=!1}i=a,r=0}else s===$p&&r!==-1?++r:r=-1}return t}var su=class extends Error{constructor(e,t){super(e),this.reason=t.reason,this.url=t.url,this.response=t.response}reason;url;response};var MA=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,AA=/^([-\w.]+\/[-\w.+]+)/;function Gp(n,e){return n.toLowerCase()===e.toLowerCase()}function qv(n){let e=AA.exec(n);return e?e[1]:n}function Vp(n){let e=MA.exec(n);return e?e[1]:""}var Zv=/\?.*/;function Xv(n){let e=n.match(Zv);return e&&e[0]}function Fi(n){return n.replace(Zv,"")}function Kv(n){if(n.length<50)return n;let e=n.slice(n.length-15);return`${n.substr(0,32)}...${e}`}function Sr(n){return Ct(n)?n.url:Tt(n)?("name"in n?n.name:"")||"":typeof n=="string"?n:""}function Fs(n){if(Ct(n)){let e=n.headers.get("content-type")||"",t=Fi(n.url);return qv(e)||Vp(t)}return Tt(n)?n.type||"":typeof n=="string"?Vp(n):""}function Qv(n){return Ct(n)?n.headers["content-length"]||-1:Tt(n)?n.size:typeof n=="string"?n.length:n instanceof ArrayBuffer||ArrayBuffer.isView(n)?n.byteLength:-1}async function ou(n){if(Ct(n))return n;let e={},t=Qv(n);t>=0&&(e["content-length"]=String(t));let i=Sr(n),r=Fs(n);r&&(e["content-type"]=r);let s=await RA(n);s&&(e["x-first-bytes"]=s),typeof n=="string"&&(n=new TextEncoder().encode(n));let o=new Response(n,{headers:e});return Object.defineProperty(o,"url",{value:i}),o}async function Jv(n){if(!n.ok)throw await kA(n)}async function kA(n){let e=Kv(n.url),t=`Failed to fetch resource (${n.status}) ${n.statusText}: ${e}`;t=t.length>100?`${t.slice(0,100)}...`:t;let i={reason:n.statusText,url:n.url,response:n};try{let r=n.headers.get("Content-Type");i.reason=!n.bodyUsed&&r?.includes("application/json")?await n.json():await n.text()}catch{}return new su(t,i)}async function RA(n){if(typeof n=="string")return`data:,${n.slice(0,5)}`;if(n instanceof Blob){let t=n.slice(0,5);return await new Promise(i=>{let r=new FileReader;r.onload=s=>i(s?.target?.result),r.readAsDataURL(t)})}if(n instanceof ArrayBuffer){let t=n.slice(0,5);return`data:base64,${IA(t)}`}return null}function IA(n){let e="",t=new Uint8Array(n);for(let i=0;i{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},cu=class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}};var lu={core:{baseUrl:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new cu,useLocalLibraries:!1,CDN:"loaders.gl-cdn-disabled",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:br,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]}},ex={baseUri:"core.baseUrl",fetch:"core.fetch",mimeType:"core.mimeType",fallbackMimeType:"core.fallbackMimeType",ignoreRegisteredLoaders:"core.ignoreRegisteredLoaders",nothrow:"core.nothrow",log:"core.log",useLocalLibraries:"core.useLocalLibraries",CDN:"core.CDN",worker:"core.worker",maxConcurrency:"core.maxConcurrency",maxMobileConcurrency:"core.maxMobileConcurrency",reuseWorkers:"core.reuseWorkers",_nodeWorkers:"core.nodeWorkers",_workerType:"core._workerType",_worker:"core._workerType",limit:"core.limit",_limitMB:"core._limitMB",batchSize:"core.batchSize",batchDebounceMs:"core.batchDebounceMs",metadata:"core.metadata",transforms:"core.transforms",throws:"nothrow",dataType:"(no longer used)",uri:"core.baseUrl",method:"core.fetch.method",headers:"core.fetch.headers",body:"core.fetch.body",mode:"core.fetch.mode",credentials:"core.fetch.credentials",cache:"core.fetch.cache",redirect:"core.fetch.redirect",referrer:"core.fetch.referrer",referrerPolicy:"core.fetch.referrerPolicy",integrity:"core.fetch.integrity",keepalive:"core.fetch.keepalive",signal:"core.fetch.signal"};var jp=["baseUrl","fetch","mimeType","fallbackMimeType","ignoreRegisteredLoaders","nothrow","log","useLocalLibraries","CDN","worker","maxConcurrency","maxMobileConcurrency","reuseWorkers","_nodeWorkers","_workerType","limit","_limitMB","batchSize","batchDebounceMs","metadata","transforms"];function Hp(){globalThis.loaders=globalThis.loaders||{};let{loaders:n}=globalThis;return n._state||(n._state={}),n._state}function Yp(){let n=Hp();return n.globalOptions=n.globalOptions||{...lu,core:{...lu.core}},di(n.globalOptions)}function ix(n,e,t,i){return t=t||[],t=Array.isArray(t)?t:[t],NA(n,t),di(zA(e,n,i))}function di(n){let e=$A(n);rx(e);for(let t of jp)e.core&&e.core[t]!==void 0&&delete e[t];return e.core&&e.core._workerType!==void 0&&delete e._worker,e}function NA(n,e){tx(n,null,lu,ex,e);for(let t of e){let i=n&&n[t.id]||{},r=t.options&&t.options[t.id]||{},s=t.deprecatedOptions&&t.deprecatedOptions[t.id]||{};tx(i,t.id,r,s,e)}}function tx(n,e,t,i,r){let s=e||"Top level",o=e?`${e}.`:"";for(let a in n){let c=!e&&Rn(n[a]),l=a==="baseUri"&&!e,u=a==="workerUrl"&&e;if(!(a in t)&&!l&&!u){if(a in i)da.level>0&&da.warn(`${s} loader option '${o}${a}' no longer supported, use '${i[a]}'`)();else if(!c&&da.level>0){let f=FA(a,r);da.warn(`${s} loader option '${o}${a}' not recognized. ${f}`)()}}}}function FA(n,e){let t=n.toLowerCase(),i="";for(let r of e)for(let s in r.options){if(n===s)return`Did you mean '${r.id}.${s}'?`;let o=s.toLowerCase();(t.startsWith(o)||o.startsWith(t))&&(i=i||`Did you mean '${r.id}.${s}'?`)}return i}function zA(n,e,t){let i=n.options||{},r={...i};i.core&&(r.core={...i.core}),rx(r),r.core?.log===null&&(r.core={...r.core,log:new au}),nx(r,di(Yp()));let s=di(e);return nx(r,s),UA(r,t),GA(r),r}function nx(n,e){for(let t in e)if(t in e){let i=e[t];nu(i)&&nu(n[t])?n[t]={...n[t],...e[t]}:n[t]=e[t]}}function UA(n,e){if(!e)return;n.core?.baseUrl!==void 0||(n.core||={},n.core.baseUrl=fi.dirname(Fi(e)))}function $A(n){let e={...n};return n.core&&(e.core={...n.core}),e}function rx(n){n.baseUri!==void 0&&(n.core||={},n.core.baseUrl===void 0&&(n.core.baseUrl=n.baseUri));for(let t of jp)if(n[t]!==void 0){let r=n.core=n.core||{};r[t]===void 0&&(r[t]=n[t])}let e=n._worker;e!==void 0&&(n.core||={},n.core._workerType===void 0&&(n.core._workerType=e))}function GA(n){let e=n.core;if(e)for(let t of jp)e[t]!==void 0&&(n[t]=e[t])}function ha(n){return n?(Array.isArray(n)&&(n=n[0]),Array.isArray(n?.extensions)):!1}function pa(n){Di(n,"null loader"),Di(ha(n),"invalid loader");let e;return Array.isArray(n)&&(e=n[1],n=n[0],n={...n,options:{...n.options,...e}}),(n?.parseTextSync||n?.parseText)&&(n.text=!0),n.text||(n.binary=!0),n}var sx=()=>{let n=Hp();return n.loaderRegistry=n.loaderRegistry||[],n.loaderRegistry};function qp(n){let e=sx();n=Array.isArray(n)?n:[n];for(let t of n){let i=pa(t);e.find(r=>i===r)||e.unshift(i)}}function ox(){return sx()}var VA=/\.([^.]+)$/;async function lx(n,e=[],t,i){if(!ux(n))return null;let r=di(t||{});if(r.core||={},n instanceof Response&&ax(n)){let o=await n.clone().text(),a=uu(o,e,{...r,core:{...r.core,nothrow:!0}},i);if(a)return a}let s=uu(n,e,{...r,core:{...r.core,nothrow:!0}},i);if(s)return s;if(Tt(n)&&(n=await n.slice(0,10).arrayBuffer(),s=uu(n,e,r,i)),!s&&n instanceof Response&&ax(n)){let o=await n.clone().text();s=uu(o,e,r,i)}if(!s&&!r.core.nothrow)throw new Error(fx(n));return s}function ax(n){let e=Fs(n);return!!(e&&(e.startsWith("text/")||e==="application/json"||e.endsWith("+json")))}function uu(n,e=[],t,i){if(!ux(n))return null;let r=di(t||{});if(r.core||={},e&&!Array.isArray(e))return pa(e);let s=[];e&&(s=s.concat(e)),r.core.ignoreRegisteredLoaders||s.push(...ox()),jA(s);let o=WA(n,s,r,i);if(!o&&!r.core.nothrow)throw new Error(fx(n));return o}function WA(n,e,t,i){let r=Sr(n),s=Fs(n),o=Fi(r)||i?.url,a=null,c="";return t?.core?.mimeType&&(a=Zp(e,t?.core?.mimeType),c=`match forced by supplied MIME type ${t?.core?.mimeType}`),a=a||HA(e,o),c=c||(a?`matched url ${o}`:""),a=a||Zp(e,s),c=c||(a?`matched MIME type ${s}`:""),a=a||qA(e,n),c=c||(a?`matched initial data ${dx(n)}`:""),t?.core?.fallbackMimeType&&(a=a||Zp(e,t?.core?.fallbackMimeType),c=c||(a?`matched fallback MIME type ${s}`:"")),c&&wp.log(1,`selectLoader selected ${a?.name}: ${c}.`),a}function ux(n){return!(n instanceof Response&&n.status===204)}function fx(n){let e=Sr(n),t=Fs(n),i="No valid loader found (";i+=e?`${fi.filename(e)}, `:"no url provided, ",i+=`MIME type: ${t?`"${t}"`:"not provided"}, `;let r=n?dx(n):"";return i+=r?` first bytes: "${r}"`:"first bytes: not available",i+=")",i}function jA(n){for(let e of n)pa(e)}function HA(n,e){let t=e&&VA.exec(e),i=t&&t[1];return i?YA(n,i):null}function YA(n,e){e=e.toLowerCase();for(let t of n)for(let i of t.extensions)if(i.toLowerCase()===e)return t;return null}function Zp(n,e){for(let t of n)if(t.mimeTypes?.some(i=>Gp(e,i))||Gp(e,`application/x.${t.id}`))return t;return null}function qA(n,e){if(!e)return null;for(let t of n)if(typeof e=="string"){if(ZA(e,t))return t}else if(ArrayBuffer.isView(e)){if(cx(e.buffer,e.byteOffset,t))return t}else if(e instanceof ArrayBuffer&&cx(e,0,t))return t;return null}function ZA(n,e){return e.testText?e.testText(n):(Array.isArray(e.tests)?e.tests:[e.tests]).some(i=>n.startsWith(i))}function cx(n,e,t){return(Array.isArray(t.tests)?t.tests:[t.tests]).some(r=>XA(n,e,t,r))}function XA(n,e,t,i){if(Os(i))return Bp(i,n,i.byteLength);switch(typeof i){case"function":return i(ua(n));case"string":let r=Xp(n,e,i.length);return i===r;default:return!1}}function dx(n,e=5){return typeof n=="string"?n.slice(0,e):ArrayBuffer.isView(n)?Xp(n.buffer,n.byteOffset,e):n instanceof ArrayBuffer?Xp(n,0,e):""}function Xp(n,e,t){if(n.byteLengthWp(s,r):e?.fetch?e?.fetch:Wp}function bx(n,e,t){if(t)return t;let i={fetch:fu(e,n),...n};if(i.url){let r=Fi(i.url);i.baseUrl=r,i.queryString=Xv(i.url),i.filename=fi.filename(r),i.baseUrl=fi.dirname(r)}return Array.isArray(i.loaders)||(i.loaders=null),i}function vx(n,e){if(n&&!Array.isArray(n))return n;let t;if(n&&(t=Array.isArray(n)?n:[n]),e&&e.loaders){let i=Array.isArray(e.loaders)?e.loaders:[e.loaders];t=t?[...t,...i]:i}return t&&t.length?t:void 0}async function ma(n,e,t,i){e&&!Array.isArray(e)&&!ha(e)&&(i=void 0,t=e,e=void 0),n=await n,t=t||{};let r=Sr(n),o=vx(e,i),a=await lx(n,o,t);if(!a)return null;let c=ix(t,a,o,r);return i=bx({url:r,_parse:ma,loaders:o},c,i||null),await tk(a,n,c,i)}async function tk(n,e,t,i){if(kp(n),t=Cp(n.options,t),Ct(e)){let{ok:s,redirected:o,status:a,statusText:c,type:l,url:u}=e,f=Object.fromEntries(e.headers.entries());i.response={headers:f,ok:s,redirected:o,status:a,statusText:c,type:l,url:u}}e=await yx(e,n,t);let r=n;if(r.parseTextSync&&typeof e=="string")return r.parseTextSync(e,t,i);if(Rp(n,t))return await Ip(n,e,t,i,ma);if(r.parseText&&typeof e=="string")return await r.parseText(e,t,i);if(r.parse)return await r.parse(e,t,i);throw lt(!r.parseSync),new Error(`${n.id} loader - no parser found and worker is disabled`)}async function zs(n,e,t,i){let r,s;!Array.isArray(e)&&!ha(e)?(r=[],s=e,i=void 0):(r=e,s=t);let o=fu(s),a=n;return typeof n=="string"&&(a=await o(n)),Tt(n)&&(a=await o(n)),typeof n=="string"&&(di(s||{}).core?.baseUrl||(s={...s,core:{...s?.core,baseUrl:n}})),Array.isArray(r)?await ma(a,r,s):await ma(a,r,s)}var Sx="4.5.4";var nk=globalThis.loaders?.parseImageNode,Jp=typeof Image<"u",em=typeof ImageBitmap<"u",ik=!!nk,tm=br?!0:ik;function Px(n){switch(n){case"auto":return em||Jp||tm;case"imagebitmap":return em;case"image":return Jp;case"data":return tm;default:throw new Error(`@loaders.gl/images: image ${n} not supported in this environment`)}}function Cx(){if(em)return"imagebitmap";if(Jp)return"image";if(tm)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function rk(n){let e=sk(n);if(!e)throw new Error("Not an image");return e}function Tx(n){switch(rk(n)){case"data":return n;case"image":case"imagebitmap":let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)throw new Error("getImageData");return e.width=n.width,e.height=n.height,t.drawImage(n,0,0),t.getImageData(0,0,n.width,n.height);default:throw new Error("getImageData")}}function sk(n){return typeof ImageBitmap<"u"&&n instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&n instanceof Image?"image":n&&typeof n=="object"&&n.data&&n.width&&n.height?"data":null}var ok=/^data:image\/svg\+xml/,ak=/\.svg((\?|#).*)?$/;function du(n){return n&&(ok.test(n)||ak.test(n))}function Lx(n,e){if(du(e)){let i=new TextDecoder().decode(n);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(i=unescape(encodeURIComponent(i)))}catch(s){throw new Error(s.message)}return`data:image/svg+xml;base64,${btoa(i)}`}return nm(n,e)}function nm(n,e){if(du(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(n)])}async function hu(n,e,t){let i=Lx(n,t),r=self.URL||self.webkitURL,s=typeof i!="string"&&r.createObjectURL(i);try{return await ck(s||i,e)}finally{s&&r.revokeObjectURL(s)}}async function ck(n,e){let t=new Image;return t.src=n,e.image&&e.image.decode&&t.decode?(await t.decode(),t):await new Promise((i,r)=>{try{t.onload=()=>i(t),t.onerror=s=>{let o=s instanceof Error?s.message:"error";r(new Error(o))}}catch(s){r(s)}})}var Mx=!0;async function Ax(n,e,t){let i;du(t)?i=await hu(n,e,t):i=nm(n,t);let r=e&&e.imagebitmap;return await lk(i,r)}async function lk(n,e=null){if((uk(e)||!Mx)&&(e=null),e)try{return await createImageBitmap(n,e)}catch(t){console.warn(t),Mx=!1}return await createImageBitmap(n)}function uk(n){if(!n)return!0;for(let e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}function kx(n){return!pk(n,"ftyp",4)||!(n[8]&96)?null:fk(n)}function fk(n){switch(dk(n,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function dk(n,e,t){return String.fromCharCode(...n.slice(e,t))}function hk(n){return[...n].map(e=>e.charCodeAt(0))}function pk(n,e,t=0){let i=hk(e);for(let r=0;r=24&&e.getUint32(0,Bn)===2303741511?{mimeType:"image/png",width:e.getUint32(16,Bn),height:e.getUint32(20,Bn)}:null}function _k(n){let e=ya(n);return e.byteLength>=10&&e.getUint32(0,Bn)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,_a),height:e.getUint16(8,_a)}:null}function yk(n){let e=ya(n);return e.byteLength>=14&&e.getUint16(0,Bn)===16973&&e.getUint32(2,_a)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,_a),height:e.getUint32(22,_a)}:null}function bk(n){let e=ya(n);if(!(e.byteLength>=3&&e.getUint16(0,Bn)===65496&&e.getUint8(2)===255))return null;let{tableMarkers:i,sofMarkers:r}=vk(),s=2;for(;s+9!!pu(new DataView(n))],options:Sk};ra();var Pk=new ct({id:"deck"}),ae=Pk;var rm={};function Bx(n){rm=n}function De(n,e,t,i){ae.level>0&&rm[n]&&rm[n].call(null,e,t,i)}function Ck(n){let e=n[0],t=n[n.length-1];return e==="{"&&t==="}"||e==="["&&t==="]"}var Ox={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:Ck,parseTextSync:JSON.parse};function Tk(){let n="9.4.0",e=globalThis.deck&&globalThis.deck.VERSION;if(e&&e!==n)throw new Error(`deck.gl - multiple versions detected: ${e} vs ${n}`);return e||(ae.log(1,`deck.gl ${n}`)(),globalThis.deck={...globalThis.deck,VERSION:n,version:n,log:ae,_registerLoggers:Bx},qp([Ox,[im,{imagebitmap:{premultiplyAlpha:"none"}}]])),n}var Dx=Tk();bt();var S4=`struct LayerUniforms { +}`}function Mp(n,e=!0,t){let i=t||new Set;if(n){if(Vv(n))i.add(n);else if(Vv(n.buffer))i.add(n.buffer);else if(!ArrayBuffer.isView(n)){if(e&&typeof n=="object")for(let r in n)Mp(n[r],e,i)}}return t===void 0?Array.from(i):[]}function Vv(n){return n?n instanceof ArrayBuffer||typeof MessagePort<"u"&&n instanceof MessagePort||typeof ImageBitmap<"u"&&n instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas:!1}var Ap=()=>{},zi=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&Ht||typeof Ds<"u"&&!Ht}constructor(e){let{name:t,source:i,url:r}=e;lt(i||r),this.name=t,this.source=i,this.url=r,this.onMessage=Ap,this.onError=s=>console.log(s),this.worker=Ht?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=Ap,this.onError=Ap,this.worker.terminate(),this.terminated=!0}get isRunning(){return!!this.onMessage}postMessage(e,t){t=t||Mp(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+=`worker ${this.name} from ${this.url}. `,e.message&&(t+=`${e.message} in `),e.lineno&&(t+=`:${e.lineno}:${e.colno}`),new Error(t)}_createBrowserWorker(){this._loadableURL=$v({source:this.source,url:this.url});let e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=t=>{t.data?this.onMessage(t.data):this.onError(new Error("No data received"))},e.onerror=t=>{this.onError(this._getErrorFromErrorEvent(t)),this.terminated=!0},e.onmessageerror=t=>console.error(t),e}_createNodeWorker(){let e;if(this.url){let i=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`,r=this.url.endsWith(".ts")||this.url.endsWith(".mjs")?"module":"commonjs";e=new Ds(i,{eval:!1,type:r})}else if(this.source)e=new Ds(this.source,{eval:!0});else throw new Error("no worker");return e.on("message",t=>{this.onMessage(t)}),e.on("error",t=>{this.onError(t)}),e.on("exit",t=>{}),e}};var ca=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return zi.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},e.name!==void 0&&(this.name=e.name),e.maxConcurrency!==void 0&&(this.maxConcurrency=e.maxConcurrency),e.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=e.maxMobileConcurrency),e.reuseWorkers!==void 0&&(this.reuseWorkers=e.reuseWorkers),e.onDebug!==void 0&&(this.onDebug=e.onDebug)}async startJob(e,t=(r,s,o)=>r.done(o),i=(r,s)=>r.error(s)){let r=new Promise(s=>(this.jobQueue.push({name:e,onMessage:t,onError:i,onStart:s}),this));return this._startQueuedJob(),await r}async _startQueuedJob(){if(!this.jobQueue.length)return;let e=this._getAvailableWorker();if(!e)return;let t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});let i=new aa(t.name,e);e.onMessage=r=>t.onMessage(i,r.type,r.payload),e.onError=r=>t.onError(i,r),t.onStart(i);try{await i.result}catch(r){console.error(`Worker exception: ${r}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!Ht||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count{}},wr=class n{props;workerPools=new Map;static _workerFarm;static isSupported(){return zi.isSupported()}static getWorkerFarm(e={}){return n._workerFarm=n._workerFarm||new n({}),n._workerFarm.setProps(e),n._workerFarm}constructor(e){this.props={...xA},this.setProps(e),this.workerPools=new Map}destroy(){for(let e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(let t of this.workerPools.values())t.setProps(this._getWorkerPoolProps())}getWorkerPool(e){let{name:t,source:i,url:r}=e,s=this.workerPools.get(t);return s||(s=new ca({name:t,source:i,url:r}),s.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,s)),s}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}};function kp(n,e={}){let t=e[n.id]||{},i=Ht?n.workerFile||`${n.id}-worker.js`:`${n.id}-worker-node.js`,r=t.workerUrl;if(!r&&n.id==="compression"&&(r=e.workerUrl),(e._workerType||e?.core?._workerType)==="test"&&(Ht?r=`modules/${n.module}/dist/${i}`:r=`modules/${n.module}/src/workers/${n.id}-worker-node.ts`),!r){let o=n.version;o==="latest"&&(o=Nv);let a=o?`@${o}`:"";r=`loaders.gl-cdn-disabled/${n.module}${a}/dist/${i}`}return lt(r),r}function Rp(n,e=Fv){lt(n,"no worker provided");let t=n.version;return!(!e||!t)}function Ip(n,e){if(!wr.isSupported())return!1;let t=e?._nodeWorkers??e?.core?._nodeWorkers;if(!Ht&&!t)return!1;let i=e?.worker??e?.core?.worker;return!!(n.worker&&i)}async function Bp(n,e,t,i,r){let s=n.id,o=kp(n,t),c=wr.getWorkerFarm(t?.core).getWorkerPool({name:s,url:o});t=JSON.parse(JSON.stringify(t||{})),t._workerLoaderId=n.id,i=JSON.parse(JSON.stringify(i||{}));let l=await c.startJob("process-on-worker",wA.bind(null,r));return l.postMessage("process",{input:e,options:t,context:i}),await(await l.result).result}async function wA(n,e,t,i){switch(t){case"done":e.done(i);break;case"error":e.error(new Error(i.error));break;case"process":let{id:r,input:s,options:o}=i;try{let a=await n(s,o);e.postMessage("done",{id:r,result:a})}catch(a){let c=a instanceof Error?a.message:"unknown error";e.postMessage("error",{id:r,error:c})}break;default:console.warn(`parse-with-worker unknown message ${t}`)}}function Op(n,e,t){if(t=t||n.byteLength,n.byteLengths instanceof ArrayBuffer?new Uint8Array(s):s),t=e.reduce((s,o)=>s+o.byteLength,0),i=new Uint8Array(t),r=0;for(let s of e)i.set(s,r),r+=s.byteLength;return i.buffer}async function Np(n){let e=[];for await(let t of n)e.push(EA(t));return Dp(...e)}function EA(n){if(n instanceof ArrayBuffer)return n;if(ArrayBuffer.isView(n)){let{buffer:e,byteOffset:t,byteLength:i}=n;return jv(e,t,i)}return jv(n)}function jv(n,e=0,t=n.byteLength-e){let i=new Uint8Array(n,e,t),r=new Uint8Array(i.length);return r.set(i),r.buffer}var SA="",Yv={};function Up(n){for(let e in Yv)if(n.startsWith(e)){let t=Yv[e];n=n.replace(e,t)}return!n.startsWith("http://")&&!n.startsWith("https://")&&(n=`${SA}${n}`),n}function su(n){return n&&typeof n=="object"&&n.isBuffer}function Ns(n){if(su(n))return n;if(n instanceof ArrayBuffer)return n;if(Sp(n))return ru(n);if(ArrayBuffer.isView(n)){let e=n.buffer;return n.byteOffset===0&&n.byteLength===n.buffer.byteLength?e:e.slice(n.byteOffset,n.byteOffset+n.byteLength)}if(typeof n=="string"){let e=n;return new TextEncoder().encode(e).buffer}if(n&&typeof n=="object"&&n._toArrayBuffer)return n._toArrayBuffer();throw new Error("toArrayBuffer")}function fa(n){if(n instanceof ArrayBuffer)return n;if(Sp(n))return ru(n);let{buffer:e,byteOffset:t,byteLength:i}=n;return e instanceof ArrayBuffer&&t===0&&i===e.byteLength?e:ru(e,t,i)}function ru(n,e=0,t=n.byteLength-e){let i=new Uint8Array(n,e,t),r=new Uint8Array(i.length);return r.set(i),r.buffer}function $p(n){return ArrayBuffer.isView(n)?n:new Uint8Array(n)}var gi={};mi(gi,{dirname:()=>CA,filename:()=>PA,join:()=>TA,resolve:()=>LA});function qv(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let n=window.location?.pathname;return n?.slice(0,n.lastIndexOf("/")+1)||""}function PA(n){let e=n?n.lastIndexOf("/"):-1;return e>=0?n.substr(e+1):n}function CA(n){let e=n?n.lastIndexOf("/"):-1;return e>=0?n.substr(0,e):""}function TA(...n){let e="/";return n=n.map((t,i)=>(i&&(t=t.replace(new RegExp(`^${e}`),"")),i!==n.length-1&&(t=t.replace(new RegExp(`${e}$`),"")),t)),n.join(e)}function LA(...n){let e=[];for(let s=0;s=-1&&!i;s--){let o;s>=0?o=e[s]:(r===void 0&&(r=qv()),o=r),o.length!==0&&(t=`${o}/${t}`,i=o.charCodeAt(0)===da)}return t=MA(t,!i),i?`/${t}`:t.length>0?t:"."}var da=47,Gp=46;function MA(n,e){let t="",i=-1,r=0,s,o=!1;for(let a=0;a<=n.length;++a){if(a2){let c=t.length-1,l=c;for(;l>=0&&t.charCodeAt(l)!==da;--l);if(l!==c){t=l===-1?"":t.slice(0,l),i=a,r=0,o=!1;continue}}else if(t.length===2||t.length===1){t="",i=a,r=0,o=!1;continue}}e&&(t.length>0?t+="/..":t="..",o=!0)}else{let c=n.slice(i+1,a);t.length>0?t+=`/${c}`:t=c,o=!1}i=a,r=0}else s===Gp&&r!==-1?++r:r=-1}return t}var ou=class extends Error{constructor(e,t){super(e),this.reason=t.reason,this.url=t.url,this.response=t.response}reason;url;response};var RA=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,IA=/^([-\w.]+\/[-\w.+]+)/;function Vp(n,e){return n.toLowerCase()===e.toLowerCase()}function Zv(n){let e=IA.exec(n);return e?e[1]:n}function Wp(n){let e=RA.exec(n);return e?e[1]:""}var Xv=/\?.*/;function Kv(n){let e=n.match(Xv);return e&&e[0]}function Ui(n){return n.replace(Xv,"")}function Qv(n){if(n.length<50)return n;let e=n.slice(n.length-15);return`${n.substr(0,32)}...${e}`}function Sr(n){return Lt(n)?n.url:Mt(n)?("name"in n?n.name:"")||"":typeof n=="string"?n:""}function Fs(n){if(Lt(n)){let e=n.headers.get("content-type")||"",t=Ui(n.url);return Zv(e)||Wp(t)}return Mt(n)?n.type||"":typeof n=="string"?Wp(n):""}function Jv(n){return Lt(n)?n.headers["content-length"]||-1:Mt(n)?n.size:typeof n=="string"?n.length:n instanceof ArrayBuffer||ArrayBuffer.isView(n)?n.byteLength:-1}async function au(n){if(Lt(n))return n;let e={},t=Jv(n);t>=0&&(e["content-length"]=String(t));let i=Sr(n),r=Fs(n);r&&(e["content-type"]=r);let s=await OA(n);s&&(e["x-first-bytes"]=s),typeof n=="string"&&(n=new TextEncoder().encode(n));let o=new Response(n,{headers:e});return Object.defineProperty(o,"url",{value:i}),o}async function ex(n){if(!n.ok)throw await BA(n)}async function BA(n){let e=Qv(n.url),t=`Failed to fetch resource (${n.status}) ${n.statusText}: ${e}`;t=t.length>100?`${t.slice(0,100)}...`:t;let i={reason:n.statusText,url:n.url,response:n};try{let r=n.headers.get("Content-Type");i.reason=!n.bodyUsed&&r?.includes("application/json")?await n.json():await n.text()}catch{}return new ou(t,i)}async function OA(n){if(typeof n=="string")return`data:,${n.slice(0,5)}`;if(n instanceof Blob){let t=n.slice(0,5);return await new Promise(i=>{let r=new FileReader;r.onload=s=>i(s?.target?.result),r.readAsDataURL(t)})}if(n instanceof ArrayBuffer){let t=n.slice(0,5);return`data:base64,${DA(t)}`}return null}function DA(n){let e="",t=new Uint8Array(n);for(let i=0;i{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},lu=class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}};var uu={core:{baseUrl:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new lu,useLocalLibraries:!1,CDN:"loaders.gl-cdn-disabled",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:br,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]}},tx={baseUri:"core.baseUrl",fetch:"core.fetch",mimeType:"core.mimeType",fallbackMimeType:"core.fallbackMimeType",ignoreRegisteredLoaders:"core.ignoreRegisteredLoaders",nothrow:"core.nothrow",log:"core.log",useLocalLibraries:"core.useLocalLibraries",CDN:"core.CDN",worker:"core.worker",maxConcurrency:"core.maxConcurrency",maxMobileConcurrency:"core.maxMobileConcurrency",reuseWorkers:"core.reuseWorkers",_nodeWorkers:"core.nodeWorkers",_workerType:"core._workerType",_worker:"core._workerType",limit:"core.limit",_limitMB:"core._limitMB",batchSize:"core.batchSize",batchDebounceMs:"core.batchDebounceMs",metadata:"core.metadata",transforms:"core.transforms",throws:"nothrow",dataType:"(no longer used)",uri:"core.baseUrl",method:"core.fetch.method",headers:"core.fetch.headers",body:"core.fetch.body",mode:"core.fetch.mode",credentials:"core.fetch.credentials",cache:"core.fetch.cache",redirect:"core.fetch.redirect",referrer:"core.fetch.referrer",referrerPolicy:"core.fetch.referrerPolicy",integrity:"core.fetch.integrity",keepalive:"core.fetch.keepalive",signal:"core.fetch.signal"};var Hp=["baseUrl","fetch","mimeType","fallbackMimeType","ignoreRegisteredLoaders","nothrow","log","useLocalLibraries","CDN","worker","maxConcurrency","maxMobileConcurrency","reuseWorkers","_nodeWorkers","_workerType","limit","_limitMB","batchSize","batchDebounceMs","metadata","transforms"];function Yp(){globalThis.loaders=globalThis.loaders||{};let{loaders:n}=globalThis;return n._state||(n._state={}),n._state}function qp(){let n=Yp();return n.globalOptions=n.globalOptions||{...uu,core:{...uu.core}},_i(n.globalOptions)}function rx(n,e,t,i){return t=t||[],t=Array.isArray(t)?t:[t],UA(n,t),_i(GA(e,n,i))}function _i(n){let e=WA(n);sx(e);for(let t of Hp)e.core&&e.core[t]!==void 0&&delete e[t];return e.core&&e.core._workerType!==void 0&&delete e._worker,e}function UA(n,e){nx(n,null,uu,tx,e);for(let t of e){let i=n&&n[t.id]||{},r=t.options&&t.options[t.id]||{},s=t.deprecatedOptions&&t.deprecatedOptions[t.id]||{};nx(i,t.id,r,s,e)}}function nx(n,e,t,i,r){let s=e||"Top level",o=e?`${e}.`:"";for(let a in n){let c=!e&&Dn(n[a]),l=a==="baseUri"&&!e,u=a==="workerUrl"&&e;if(!(a in t)&&!l&&!u){if(a in i)ha.level>0&&ha.warn(`${s} loader option '${o}${a}' no longer supported, use '${i[a]}'`)();else if(!c&&ha.level>0){let f=$A(a,r);ha.warn(`${s} loader option '${o}${a}' not recognized. ${f}`)()}}}}function $A(n,e){let t=n.toLowerCase(),i="";for(let r of e)for(let s in r.options){if(n===s)return`Did you mean '${r.id}.${s}'?`;let o=s.toLowerCase();(t.startsWith(o)||o.startsWith(t))&&(i=i||`Did you mean '${r.id}.${s}'?`)}return i}function GA(n,e,t){let i=n.options||{},r={...i};i.core&&(r.core={...i.core}),sx(r),r.core?.log===null&&(r.core={...r.core,log:new cu}),ix(r,_i(qp()));let s=_i(e);return ix(r,s),VA(r,t),jA(r),r}function ix(n,e){for(let t in e)if(t in e){let i=e[t];iu(i)&&iu(n[t])?n[t]={...n[t],...e[t]}:n[t]=e[t]}}function VA(n,e){if(!e)return;n.core?.baseUrl!==void 0||(n.core||={},n.core.baseUrl=gi.dirname(Ui(e)))}function WA(n){let e={...n};return n.core&&(e.core={...n.core}),e}function sx(n){n.baseUri!==void 0&&(n.core||={},n.core.baseUrl===void 0&&(n.core.baseUrl=n.baseUri));for(let t of Hp)if(n[t]!==void 0){let r=n.core=n.core||{};r[t]===void 0&&(r[t]=n[t])}let e=n._worker;e!==void 0&&(n.core||={},n.core._workerType===void 0&&(n.core._workerType=e))}function jA(n){let e=n.core;if(e)for(let t of Hp)e[t]!==void 0&&(n[t]=e[t])}function pa(n){return n?(Array.isArray(n)&&(n=n[0]),Array.isArray(n?.extensions)):!1}function ma(n){Fi(n,"null loader"),Fi(pa(n),"invalid loader");let e;return Array.isArray(n)&&(e=n[1],n=n[0],n={...n,options:{...n.options,...e}}),(n?.parseTextSync||n?.parseText)&&(n.text=!0),n.text||(n.binary=!0),n}var ox=()=>{let n=Yp();return n.loaderRegistry=n.loaderRegistry||[],n.loaderRegistry};function Zp(n){let e=ox();n=Array.isArray(n)?n:[n];for(let t of n){let i=ma(t);e.find(r=>i===r)||e.unshift(i)}}function ax(){return ox()}var HA=/\.([^.]+)$/;async function ux(n,e=[],t,i){if(!fx(n))return null;let r=_i(t||{});if(r.core||={},n instanceof Response&&cx(n)){let o=await n.clone().text(),a=fu(o,e,{...r,core:{...r.core,nothrow:!0}},i);if(a)return a}let s=fu(n,e,{...r,core:{...r.core,nothrow:!0}},i);if(s)return s;if(Mt(n)&&(n=await n.slice(0,10).arrayBuffer(),s=fu(n,e,r,i)),!s&&n instanceof Response&&cx(n)){let o=await n.clone().text();s=fu(o,e,r,i)}if(!s&&!r.core.nothrow)throw new Error(dx(n));return s}function cx(n){let e=Fs(n);return!!(e&&(e.startsWith("text/")||e==="application/json"||e.endsWith("+json")))}function fu(n,e=[],t,i){if(!fx(n))return null;let r=_i(t||{});if(r.core||={},e&&!Array.isArray(e))return ma(e);let s=[];e&&(s=s.concat(e)),r.core.ignoreRegisteredLoaders||s.push(...ax()),qA(s);let o=YA(n,s,r,i);if(!o&&!r.core.nothrow)throw new Error(dx(n));return o}function YA(n,e,t,i){let r=Sr(n),s=Fs(n),o=Ui(r)||i?.url,a=null,c="";return t?.core?.mimeType&&(a=Xp(e,t?.core?.mimeType),c=`match forced by supplied MIME type ${t?.core?.mimeType}`),a=a||ZA(e,o),c=c||(a?`matched url ${o}`:""),a=a||Xp(e,s),c=c||(a?`matched MIME type ${s}`:""),a=a||KA(e,n),c=c||(a?`matched initial data ${hx(n)}`:""),t?.core?.fallbackMimeType&&(a=a||Xp(e,t?.core?.fallbackMimeType),c=c||(a?`matched fallback MIME type ${s}`:"")),c&&Ep.log(1,`selectLoader selected ${a?.name}: ${c}.`),a}function fx(n){return!(n instanceof Response&&n.status===204)}function dx(n){let e=Sr(n),t=Fs(n),i="No valid loader found (";i+=e?`${gi.filename(e)}, `:"no url provided, ",i+=`MIME type: ${t?`"${t}"`:"not provided"}, `;let r=n?hx(n):"";return i+=r?` first bytes: "${r}"`:"first bytes: not available",i+=")",i}function qA(n){for(let e of n)ma(e)}function ZA(n,e){let t=e&&HA.exec(e),i=t&&t[1];return i?XA(n,i):null}function XA(n,e){e=e.toLowerCase();for(let t of n)for(let i of t.extensions)if(i.toLowerCase()===e)return t;return null}function Xp(n,e){for(let t of n)if(t.mimeTypes?.some(i=>Vp(e,i))||Vp(e,`application/x.${t.id}`))return t;return null}function KA(n,e){if(!e)return null;for(let t of n)if(typeof e=="string"){if(QA(e,t))return t}else if(ArrayBuffer.isView(e)){if(lx(e.buffer,e.byteOffset,t))return t}else if(e instanceof ArrayBuffer&&lx(e,0,t))return t;return null}function QA(n,e){return e.testText?e.testText(n):(Array.isArray(e.tests)?e.tests:[e.tests]).some(i=>n.startsWith(i))}function lx(n,e,t){return(Array.isArray(t.tests)?t.tests:[t.tests]).some(r=>JA(n,e,t,r))}function JA(n,e,t,i){if(Os(i))return Op(i,n,i.byteLength);switch(typeof i){case"function":return i(fa(n));case"string":let r=Kp(n,e,i.length);return i===r;default:return!1}}function hx(n,e=5){return typeof n=="string"?n.slice(0,e):ArrayBuffer.isView(n)?Kp(n.buffer,n.byteOffset,e):n instanceof ArrayBuffer?Kp(n,0,e):""}function Kp(n,e,t){if(n.byteLengthjp(s,r):e?.fetch?e?.fetch:jp}function vx(n,e,t){if(t)return t;let i={fetch:du(e,n),...n};if(i.url){let r=Ui(i.url);i.baseUrl=r,i.queryString=Kv(i.url),i.filename=gi.filename(r),i.baseUrl=gi.dirname(r)}return Array.isArray(i.loaders)||(i.loaders=null),i}function xx(n,e){if(n&&!Array.isArray(n))return n;let t;if(n&&(t=Array.isArray(n)?n:[n]),e&&e.loaders){let i=Array.isArray(e.loaders)?e.loaders:[e.loaders];t=t?[...t,...i]:i}return t&&t.length?t:void 0}async function ga(n,e,t,i){e&&!Array.isArray(e)&&!pa(e)&&(i=void 0,t=e,e=void 0),n=await n,t=t||{};let r=Sr(n),o=xx(e,i),a=await ux(n,o,t);if(!a)return null;let c=rx(t,a,o,r);return i=vx({url:r,_parse:ga,loaders:o},c,i||null),await rk(a,n,c,i)}async function rk(n,e,t,i){if(Rp(n),t=Tp(n.options,t),Lt(e)){let{ok:s,redirected:o,status:a,statusText:c,type:l,url:u}=e,f=Object.fromEntries(e.headers.entries());i.response={headers:f,ok:s,redirected:o,status:a,statusText:c,type:l,url:u}}e=await bx(e,n,t);let r=n;if(r.parseTextSync&&typeof e=="string")return r.parseTextSync(e,t,i);if(Ip(n,t))return await Bp(n,e,t,i,ga);if(r.parseText&&typeof e=="string")return await r.parseText(e,t,i);if(r.parse)return await r.parse(e,t,i);throw lt(!r.parseSync),new Error(`${n.id} loader - no parser found and worker is disabled`)}async function zs(n,e,t,i){let r,s;!Array.isArray(e)&&!pa(e)?(r=[],s=e,i=void 0):(r=e,s=t);let o=du(s),a=n;return typeof n=="string"&&(a=await o(n)),Mt(n)&&(a=await o(n)),typeof n=="string"&&(_i(s||{}).core?.baseUrl||(s={...s,core:{...s?.core,baseUrl:n}})),Array.isArray(r)?await ga(a,r,s):await ga(a,r,s)}var Px="4.5.4";var sk=globalThis.loaders?.parseImageNode,em=typeof Image<"u",tm=typeof ImageBitmap<"u",ok=!!sk,nm=br?!0:ok;function Cx(n){switch(n){case"auto":return tm||em||nm;case"imagebitmap":return tm;case"image":return em;case"data":return nm;default:throw new Error(`@loaders.gl/images: image ${n} not supported in this environment`)}}function Tx(){if(tm)return"imagebitmap";if(em)return"image";if(nm)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function ak(n){let e=ck(n);if(!e)throw new Error("Not an image");return e}function Lx(n){switch(ak(n)){case"data":return n;case"image":case"imagebitmap":let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)throw new Error("getImageData");return e.width=n.width,e.height=n.height,t.drawImage(n,0,0),t.getImageData(0,0,n.width,n.height);default:throw new Error("getImageData")}}function ck(n){return typeof ImageBitmap<"u"&&n instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&n instanceof Image?"image":n&&typeof n=="object"&&n.data&&n.width&&n.height?"data":null}var lk=/^data:image\/svg\+xml/,uk=/\.svg((\?|#).*)?$/;function hu(n){return n&&(lk.test(n)||uk.test(n))}function Mx(n,e){if(hu(e)){let i=new TextDecoder().decode(n);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(i=unescape(encodeURIComponent(i)))}catch(s){throw new Error(s.message)}return`data:image/svg+xml;base64,${btoa(i)}`}return im(n,e)}function im(n,e){if(hu(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(n)])}async function pu(n,e,t){let i=Mx(n,t),r=self.URL||self.webkitURL,s=typeof i!="string"&&r.createObjectURL(i);try{return await fk(s||i,e)}finally{s&&r.revokeObjectURL(s)}}async function fk(n,e){let t=new Image;return t.src=n,e.image&&e.image.decode&&t.decode?(await t.decode(),t):await new Promise((i,r)=>{try{t.onload=()=>i(t),t.onerror=s=>{let o=s instanceof Error?s.message:"error";r(new Error(o))}}catch(s){r(s)}})}var Ax=!0;async function kx(n,e,t){let i;hu(t)?i=await pu(n,e,t):i=im(n,t);let r=e&&e.imagebitmap;return await dk(i,r)}async function dk(n,e=null){if((hk(e)||!Ax)&&(e=null),e)try{return await createImageBitmap(n,e)}catch(t){console.warn(t),Ax=!1}return await createImageBitmap(n)}function hk(n){if(!n)return!0;for(let e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}function Rx(n){return!_k(n,"ftyp",4)||!(n[8]&96)?null:pk(n)}function pk(n){switch(mk(n,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function mk(n,e,t){return String.fromCharCode(...n.slice(e,t))}function gk(n){return[...n].map(e=>e.charCodeAt(0))}function _k(n,e,t=0){let i=gk(e);for(let r=0;r=24&&e.getUint32(0,Fn)===2303741511?{mimeType:"image/png",width:e.getUint32(16,Fn),height:e.getUint32(20,Fn)}:null}function vk(n){let e=ba(n);return e.byteLength>=10&&e.getUint32(0,Fn)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,ya),height:e.getUint16(8,ya)}:null}function xk(n){let e=ba(n);return e.byteLength>=14&&e.getUint16(0,Fn)===16973&&e.getUint32(2,ya)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,ya),height:e.getUint32(22,ya)}:null}function wk(n){let e=ba(n);if(!(e.byteLength>=3&&e.getUint16(0,Fn)===65496&&e.getUint8(2)===255))return null;let{tableMarkers:i,sofMarkers:r}=Ek(),s=2;for(;s+9!!mu(new DataView(n))],options:Tk};sa();var Lk=new ct({id:"deck"}),ae=Lk;var sm={};function Ox(n){sm=n}function Ne(n,e,t,i){ae.level>0&&sm[n]&&sm[n].call(null,e,t,i)}function Mk(n){let e=n[0],t=n[n.length-1];return e==="{"&&t==="}"||e==="["&&t==="]"}var Dx={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:Mk,parseTextSync:JSON.parse};function Ak(){let n="9.4.0",e=globalThis.deck&&globalThis.deck.VERSION;if(e&&e!==n)throw new Error(`deck.gl - multiple versions detected: ${e} vs ${n}`);return e||(ae.log(1,`deck.gl ${n}`)(),globalThis.deck={...globalThis.deck,VERSION:n,version:n,log:ae,_registerLoggers:Ox},Zp([Dx,[rm,{imagebitmap:{premultiplyAlpha:"none"}}]])),n}var Nx=Ak();vt();var T4=`struct LayerUniforms { opacity: f32, }; @group(0) @binding(auto) var layer: LayerUniforms; -`,bS=`layout(std140) uniform layerUniforms { +`,vS=`layout(std140) uniform layerUniforms { uniform float opacity; } layer; -`,r_={name:"layer",source:S4,vs:bS,fs:bS,getUniforms:n=>({opacity:Math.pow(n.opacity,.45454545454545453)}),uniformTypes:{opacity:"f32"}};var P4=` +`,s_={name:"layer",source:T4,vs:vS,fs:vS,getUniforms:n=>({opacity:Math.pow(n.opacity,.45454545454545453)}),uniformTypes:{opacity:"f32"}};var L4=` @must_use fn deckgl_premultiplied_alpha(fragColor: vec4) -> vec4 { return vec4(fragColor.rgb * fragColor.a, fragColor.a); }; -`,zn={name:"color",dependencies:[],source:P4,getUniforms:n=>({})};var C4=`const SMOOTH_EDGE_RADIUS: f32 = 0.5; +`,Vn={name:"color",dependencies:[],source:L4,getUniforms:n=>({})};var M4=`const SMOOTH_EDGE_RADIUS: f32 = 0.5; struct VertexGeometry { position: vec4, @@ -3326,7 +3326,7 @@ var fragmentGeometry: FragmentGeometry; fn smoothedge(edge: f32, x: f32) -> f32 { return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x); } -`,vS="#define SMOOTH_EDGE_RADIUS 0.5",T4=`${vS} +`,xS="#define SMOOTH_EDGE_RADIUS 0.5",A4=`${xS} struct VertexGeometry { vec4 position; @@ -3343,7 +3343,7 @@ struct VertexGeometry { vec2(0.0), vec3(0.0) ); -`,L4=`${vS} +`,k4=`${xS} struct FragmentGeometry { vec2 uv; @@ -3353,9 +3353,9 @@ FragmentGeometry geometry; float smoothedge(float edge, float x) { return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x); } -`,uf={name:"geometry",source:C4,vs:T4,fs:L4};bt();Fe();var ne;(function(n){n[n.Start=1]="Start",n[n.Move=2]="Move",n[n.End=4]="End",n[n.Cancel=8]="Cancel"})(ne||(ne={}));var Pe;(function(n){n[n.None=0]="None",n[n.Left=1]="Left",n[n.Right=2]="Right",n[n.Up=4]="Up",n[n.Down=8]="Down",n[n.Horizontal=3]="Horizontal",n[n.Vertical=12]="Vertical",n[n.All=15]="All"})(Pe||(Pe={}));var j;(function(n){n[n.Possible=1]="Possible",n[n.Began=2]="Began",n[n.Changed=4]="Changed",n[n.Ended=8]="Ended",n[n.Recognized=8]="Recognized",n[n.Cancelled=16]="Cancelled",n[n.Failed=32]="Failed"})(j||(j={}));var xS="compute",s_="auto",jr="manipulation",Hr="none",Ka="pan-x",Qa="pan-y";function o_(n){if(n.includes(Hr))return Hr;let e=n.includes(Ka),t=n.includes(Qa);return e&&t?Hr:e||t?e?Ka:Qa:n.includes(jr)?jr:s_}var Ja=class{constructor(e,t){this.actions="",this.manager=e,this.set(t)}set(e){e===xS&&(e=this.compute()),this.manager.element&&(this.manager.element.style.touchAction=e,this.actions=e)}update(){this.set(this.manager.options.touchAction)}compute(){let e=[];for(let t of this.manager.recognizers)t.options.enable&&(e=e.concat(t.getTouchAction()));return o_(e.join(" "))}};function to(n){return n.trim().split(/\s+/g)}function ff(n,e,t){if(n)for(let i of to(e))n.addEventListener(i,t,!1)}function df(n,e,t){if(n)for(let i of to(e))n.removeEventListener(i,t,!1)}function a_(n){return(n.ownerDocument||n).defaultView}function c_(n,e){let t=n;for(;t;){if(t===e)return!0;t=t.parentNode}return!1}function hf(n){let e=n.length;if(e===1)return{x:Math.round(n[0].clientX),y:Math.round(n[0].clientY)};let t=0,i=0,r=0;for(;r=Math.abs(e)?n<0?Pe.Left:Pe.Right:e<0?Pe.Up:Pe.Down}function ES(n,e){let t=e.center,i=n.offsetDelta,r=n.prevDelta,s=n.prevInput;return(e.eventType===ne.Start||s?.eventType===ne.End)&&(r=n.prevDelta={x:s?.deltaX||0,y:s?.deltaY||0},i=n.offsetDelta={x:t.x,y:t.y}),{deltaX:r.x+(t.x-i.x),deltaY:r.y+(t.y-i.y)}}function pf(n,e,t){return{x:e/n||0,y:t/n||0}}function SS(n,e){return ec(e[0],e[1])/ec(n[0],n[1])}function PS(n,e){return u_(e[1],e[0])-u_(n[1],n[0])}function CS(n,e){let t=n.lastInterval||e,i=e.timeStamp-t.timeStamp,r,s,o,a;if(e.eventType!==ne.Cancel&&(i>25||t.velocity===void 0)){let c=e.deltaX-t.deltaX,l=e.deltaY-t.deltaY,u=pf(i,c,l);s=u.x,o=u.y,r=Math.abs(u.x)>Math.abs(u.y)?u.x:u.y,a=io(c,l),n.lastInterval=e}else r=t.velocity,s=t.velocityX,o=t.velocityY,a=t.direction;e.velocity=r,e.velocityX=s,e.velocityY=o,e.direction=a}function f_(n,e){return"pointerId"in n?n.pointerId:e}function TS(n,e){n.movementOrigin=new Map(e.map((t,i)=>[f_(t,i),{clientX:t.clientX,clientY:t.clientY}])),n.firstMovementTime=void 0}function A4(n,e){let t=e.pointers.map(f_);if(n.movementOrigin?.size===t.length&&t.every(r=>n.movementOrigin.has(r))||TS(n,e.pointers),e.distancePerPointer=e.pointers.map((r,s)=>ec(n.movementOrigin.get(t[s]),r)),e.eventType&ne.Move&&e.distancePerPointer.some(r=>r>0)&&(n.firstMovementTime??(n.firstMovementTime=e.timeStamp)),e.movementDeltaTime=n.firstMovementTime===void 0?0:e.timeStamp-n.firstMovementTime,e.eventType&(ne.End|ne.Cancel)){let r=e.changedPointers.map(s=>f_(s,e.pointers.indexOf(s)));TS(n,e.pointers.filter((s,o)=>!r.includes(t[o])))}}function LS(n,e){let{session:t}=n,{pointers:i}=e,{length:r}=i;t.firstInput||(t.firstInput=l_(e)),r>1&&!t.firstMultiple?t.firstMultiple=l_(e):r===1&&(t.firstMultiple=!1);let{firstInput:s,firstMultiple:o}=t,a=o?o.center:s.center,c=e.center=hf(i);e.timeStamp=Date.now(),e.deltaTime=e.timeStamp-s.timeStamp,A4(t,e),e.angle=wS(a,c),e.distance=no(a,c);let{deltaX:l,deltaY:u}=ES(t,e);e.deltaX=l,e.deltaY=u,e.offsetDirection=io(e.deltaX,e.deltaY);let f=pf(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=f.x,e.overallVelocityY=f.y,e.overallVelocity=Math.abs(f.x)>Math.abs(f.y)?f.x:f.y,e.scale=o?SS(o.pointers,i):1,e.rotation=o?PS(o.pointers,i):0,e.maxPointers=t.prevInput?e.pointers.length>t.prevInput.maxPointers?e.pointers.length:t.prevInput.maxPointers:e.pointers.length;let d=n.element;return c_(e.srcEvent.target,d)&&(d=e.srcEvent.target),e.target=d,CS(t,e),e}function MS(n,e,t){let i=t.pointers.length,r=t.changedPointers.length,s=e&ne.Start&&i-r===0,o=e&(ne.End|ne.Cancel)&&i-r===0;t.isFirst=!!s,t.isFinal=!!o,s&&(n.session={}),t.eventType=e;let a=LS(n,t);n.emit("hammer.input",a),n.recognize(a),n.session.prevInput=a}var tc=class{constructor(e){this.evEl="",this.evWin="",this.evTarget="",this.domHandler=t=>{this.manager.options.enable&&this.handler(t)},this.manager=e,this.element=e.element,this.target=e.options.inputTarget||e.element}callback(e,t){MS(this.manager,e,t)}init(){ff(this.element,this.evEl,this.domHandler),ff(this.target,this.evTarget,this.domHandler),ff(a_(this.element),this.evWin,this.domHandler)}destroy(){df(this.element,this.evEl,this.domHandler),df(this.target,this.evTarget,this.domHandler),df(a_(this.element),this.evWin,this.domHandler)}};var k4={pointerdown:ne.Start,pointermove:ne.Move,pointerup:ne.End,pointercancel:ne.Cancel,pointerout:ne.Cancel},R4="pointerdown",I4="pointermove pointerup pointercancel",nc=class extends tc{constructor(e){super(e),this.evEl=R4,this.evWin=I4,this.store=this.manager.session.pointerEvents=[],this.init()}handler(e){let{store:t}=this,i=!1,r=k4[e.type],s=e.pointerType,o=s==="touch",a=t.findIndex(c=>c.pointerId===e.pointerId);r&ne.Start&&(e.buttons||o)?a<0&&(t.push(e),a=t.length-1):r&(ne.End|ne.Cancel)&&(i=!0),!(a<0)&&(t[a]=e,this.callback(r,{pointers:t,changedPointers:[e],eventType:r,pointerType:s,srcEvent:e}),i&&t.splice(a,1))}};var B4=["","webkit","Moz","MS","ms","o"];function AS(n,e){let t=e[0].toUpperCase()+e.slice(1);for(let i of B4){let r=i?i+t:e;if(r in n)return r}}var O4=1,kS=2,RS={touchAction:"compute",enable:!0,inputTarget:null,cssProps:{userSelect:"none",userDrag:"none",touchCallout:"none",tapHighlightColor:"rgba(0,0,0,0)"}},ic=class{constructor(e,t){this.options={...RS,...t,cssProps:{...RS.cssProps,...t.cssProps},inputTarget:t.inputTarget||e},this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=new nc(this),this.touchAction=new Ja(this,this.options.touchAction),this.toggleCssProps(!0)}set(e){return Object.assign(this.options,e),e.touchAction&&this.touchAction.update(),e.inputTarget&&(this.input.destroy(),this.input.target=e.inputTarget,this.input.init()),this}stop(e){this.session.stopped=e?kS:O4}recognize(e){let{session:t}=this;if(t.stopped)return;this.session.prevented&&e.srcEvent.preventDefault();let i,{recognizers:r}=this,{curRecognizer:s}=t;(!s||s&&s.state&j.Recognized)&&(s=t.curRecognizer=null);let o=0;for(;o-1&&this.requireFail.splice(i,1)}return this}hasRequireFailures(){return!!this.requireFail.find(e=>e.options.enable)}canRecognizeWith(e){return!!this.simultaneous[e.id]}emit(e){if(!e)return;let{state:t}=this;t=j.Ended&&this.manager.emit(this.options.event+d_(t),e)}tryEmit(e){this.canEmit()?this.emit(e):this.state=j.Failed}canEmit(){let e=0;for(;e=e.distance)&&(e.distancePerPointer===void 0||n.distancePerPointer.length>0&&n.distancePerPointer.every(t=>t>=e.distancePerPointer))&&(e.movementDeltaTime===void 0||n.movementDeltaTime>=e.movementDeltaTime)&&(e.rotation===void 0||N4(n.rotation)>=e.rotation)&&(e.scale===void 0||Math.abs(n.scale-1)>=e.scale)}var Yr=class extends ln{attrTest(e){let t=this.options.pointers;return t===0||e.pointers.length===t}coherentTest(e){let t=this.options.coherent;return!t?.length||t.some(i=>F4(e,i))}process(e){let{state:t}=this,{eventType:i}=e,r=t&(j.Began|j.Changed),s=this.attrTest(e);return r&&(i&ne.Cancel||!s)?t|j.Cancelled:r||s?i&ne.End?t|j.Ended:t&j.Began?t|j.Changed:j.Began:j.Failed}};var z4=["","start","move","end","cancel"],ro=class extends ln{constructor(e={}){super({enable:!0,event:"doubleclickdrag",pointers:1,interval:500,time:350,threshold:28,dragThreshold:1,pixelsPerScale:120,...e}),this._tapStart=null,this._lastTap=null,this._drag=null,this._emittedStart=!1}getTouchAction(){return[jr]}getEventNames(){return z4.map(e=>this.options.event+e)}process(e){let{options:t}=this;return e.pointers.length===t.pointers?e.eventType&ne.Start?this._handleStart(e):e.eventType&ne.Move?this._handleMove(e):e.eventType&ne.Cancel?this._handleEnd(e,!0):e.eventType&ne.End?this._handleEnd(e,!1):j.Failed:(this.reset(),j.Failed)}reset(){this._tapStart=null,this._lastTap=null,this._drag=null,this._emittedStart=!1}emit(e){if(e){if(this.state===j.Began){if(!this._drag?.active||this._emittedStart)return;this._emittedStart=!0,this.manager.emit(`${this.options.event}start`,e),this.manager.emit(this.options.event,e);return}if(this.state===j.Changed){if(!this._emittedStart)return;this.manager.emit(`${this.options.event}move`,e),this.manager.emit(this.options.event,e);return}if(this.state===j.Ended){if(!this._emittedStart)return;this.manager.emit(this.options.event,e),this.manager.emit(`${this.options.event}end`,e),this._emittedStart=!1;return}if(this.state===j.Cancelled){if(!this._emittedStart)return;this.manager.emit(this.options.event,e),this.manager.emit(`${this.options.event}cancel`,e),this._emittedStart=!1}}}_handleStart(e){let t=this._getPointerId(e);return this._lastTap&&this._isTapMatch(e,this._lastTap)?(this._tapStart=null,this._lastTap=null,this._drag={startCenter:e.center,pointerId:t,active:!1},this._emittedStart=!1,j.Began):(this._tapStart={center:e.center,timeStamp:e.timeStamp,pointerId:t},this._lastTap=null,this._drag=null,this._emittedStart=!1,j.Failed)}_handleMove(e){if(!this._drag||!this._isSamePointer(e,this._drag.pointerId))return j.Failed;let t=this._drag.startCenter.y-e.center.y;return!this._drag.active&&Math.abs(t){this.state=j.Recognized,this.tryEmit(this._input)},t.interval),j.Began):j.Recognized}return j.Failed}failTimeout(){return this._timer=setTimeout(()=>{this.state=j.Failed},this.options.interval),j.Failed}reset(){clearTimeout(this._timer)}emit(e){this.state===j.Recognized&&(e.tapCount=this.count,this.manager.emit(this.options.event,e))}};var so=class extends Yr{constructor(){super(...arguments),this.wheelSession=null,this.wheelSessionUnsubscribe=null,this.handleWheelSessionEvent=e=>{e.device==="trackpad"&&this.handleTrackpadEvent(e)}}set(e){let{wheelSession:t,...i}=e;return t&&t!==this.wheelSession&&(this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=null,this.wheelSession=t),super.set(i),this.updateWheelSessionSubscription(),this}getTrackpadInput(e,t={}){let{srcEvent:i}=e,r=t.deltaX??e.deltaX,s=t.deltaY??e.deltaY,o=io(r,s),a=Math.sqrt(e.deltaX*e.deltaX+e.deltaY*e.deltaY),c=i;return{pointers:[c,c],changedPointers:[c,c],pointerType:"trackpad",srcEvent:c,eventType:e.eventType,timeStamp:e.timeStamp,deltaTime:e.deltaTime,center:e.center,deltaX:r,deltaY:s,angle:Math.atan2(s,r)*180/Math.PI,distance:Math.sqrt(r*r+s*s),distancePerPointer:[a,a],movementDeltaTime:e.deltaTime,scale:1,rotation:0,direction:o,offsetDirection:o,velocity:e.velocity,velocityX:e.velocityX,velocityY:e.velocityY,overallVelocity:e.overallVelocity,overallVelocityX:e.overallVelocityX,overallVelocityY:e.overallVelocityY,maxPointers:2,target:i.target||this.manager.element,additionalEvent:"",...t}}updateWheelSessionSubscription(){let e=!!(this.wheelSession&&this.options.enable&&this.options.trackpad&&this.options.pointers===2);e&&!this.wheelSessionUnsubscribe?this.wheelSessionUnsubscribe=this.wheelSession.on(this.handleWheelSessionEvent):!e&&this.wheelSessionUnsubscribe&&(this.wheelSessionUnsubscribe(),this.wheelSessionUnsubscribe=null)}};var U4=["","start","move","end","cancel","up","down","left","right"],qi=class extends so{constructor(e={}){super({enable:!0,pointers:1,event:"pan",threshold:10,direction:Pe.All,trackpad:!1,coherent:[],...e}),this.trackpadGesture=!1,this.pX=null,this.pY=null}getTouchAction(){let{options:{direction:e}}=this,t=[];return e&Pe.Horizontal&&t.push(Qa),e&Pe.Vertical&&t.push(Ka),t}getEventNames(){return U4.map(e=>this.options.event+e)}directionTest(e){let{options:t}=this,i=!0,{distance:r}=e,{direction:s}=e,o=e.deltaX,a=e.deltaY;return s&t.direction||(t.direction&Pe.Horizontal?(s=o===0?Pe.None:o<0?Pe.Left:Pe.Right,i=o!==this.pX,r=Math.abs(e.deltaX)):(s=a===0?Pe.None:a<0?Pe.Up:Pe.Down,i=a!==this.pY,r=Math.abs(e.deltaY))),e.direction=s,i&&r>t.threshold&&!!(s&t.direction)}attrTest(e){let t=!!(this.state&j.Began),i=!(this.options.coherent?.length&&e.eventType&(ne.End|ne.Cancel));return super.attrTest(e)&&(t||i&&this.coherentTest(e)&&this.directionTest(e))}emit(e){this.pX=e.deltaX,this.pY=e.deltaY;let t=Pe[e.direction].toLowerCase();t&&(e.additionalEvent=this.options.event+t),super.emit(e)}handleTrackpadEvent(e){e.isFirst&&(this.trackpadGesture=!e.srcEvent.ctrlKey,!this.trackpadGesture&&this.state&(j.Recognized|j.Cancelled|j.Failed)&&(this.state=j.Possible)),this.trackpadGesture&&(this.recognize(this.getTrackpadInput(e,{deltaX:-e.deltaX,deltaY:-e.deltaY,velocity:-e.velocity,velocityX:-e.velocityX,velocityY:-e.velocityY,overallVelocity:-e.overallVelocity,overallVelocityX:-e.overallVelocityX,overallVelocityY:-e.overallVelocityY})),e.isFinal&&(this.trackpadGesture=!1))}};var $4=["","start","move","end","cancel","in","out"],oo=class extends so{constructor(e={}){super({enable:!0,event:"pinch",threshold:0,pointers:2,trackpad:!1,coherent:[],...e}),this.trackpadGesture=!1}getTouchAction(){return[Hr]}getEventNames(){return $4.map(e=>this.options.event+e)}attrTest(e){let t=!!this.options.coherent?.length,i=!!(this.state&j.Began),r=!(t&&e.eventType&(ne.End|ne.Cancel));return super.attrTest(e)&&(i||r&&(t?this.coherentTest(e):Math.abs(e.scale-1)>this.options.threshold))}emit(e){if(e.scale!==1){let t=e.scale<1?"in":"out";e.additionalEvent=this.options.event+t}super.emit(e)}handleTrackpadEvent(e){e.isFirst&&(this.trackpadGesture=e.srcEvent.ctrlKey,!this.trackpadGesture&&this.state&(j.Recognized|j.Cancelled|j.Failed)&&(this.state=j.Possible)),this.trackpadGesture&&(this.recognize(this.getTrackpadInput(e,{deltaX:0,deltaY:0,velocity:0,velocityX:0,velocityY:0,overallVelocity:0,overallVelocityX:0,overallVelocityY:0,scale:Math.exp(-e.deltaY/100)})),e.isFinal&&(this.trackpadGesture=!1))}};var Un=class{constructor(e,t,i){this.element=e,this.callback=t,this.options=i}listen(e,t){t?this.element.addEventListener(e,this.handleEvent,{passive:!1}):this.element.removeEventListener(e,this.handleEvent)}};var BS=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"";var j4=BS.indexOf("firefox")!==-1,H4=40,Y4=.25,mf=class extends Un{constructor(e,t,i){i.enable=i.enable??!1,super(e,t,i),this.handleEvent=r=>{if(!this.options.enable)return;let s=r.deltaY;globalThis.WheelEvent&&(j4&&r.deltaMode===globalThis.WheelEvent.DOM_DELTA_PIXEL&&(s/=globalThis.devicePixelRatio),r.deltaMode===globalThis.WheelEvent.DOM_DELTA_LINE&&(s*=H4)),r.shiftKey&&s&&(s=s*Y4),this.callback({type:"wheel",center:{x:r.clientX,y:r.clientY},delta:-s,device:this.options.wheelSession?.device??"unknown",srcEvent:r,pointerType:"mouse",target:r.target})},i.enable&&(this.wheelSessionUnsubscribe=this.options.wheelSession?.on(()=>{}),this.listen("wheel",!0))}destroy(){this.listen("wheel",!1),this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=void 0}enableEventType(e,t){e==="wheel"&&this.options.enable!==t&&(this.options.enable=t,t&&!this.wheelSessionUnsubscribe&&(this.wheelSessionUnsubscribe=this.options.wheelSession?.on(()=>{})),this.listen("wheel",t),t||(this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=void 0))}};var q4=4.000244140625,OS=40,Z4=0,X4=1,K4=40,DS=40,Q4=120,J4={classificationDelay:32,endDelay:80},gf=class{constructor(e,t={}){this.subscriptions=new Map,this.session=null,this.classificationTimer=null,this.endTimer=null,this.pressedControlKeys=new Set,this.listeningForControlKeys=!1,this.handleEvent=i=>{if(!this.hasSubscribers)return"unknown";let r=tN(i,this.pressedControlKeys.size>0),s=this.session;if(s&&r.timeStamp-s.lastTimeStamp>=this.options.endDelay){if(this.end(),!this.hasSubscribers)return"unknown";s=null}s?(this.scheduleEnd(),this.addSample(s,r)):(s=this.startPendingSession(r),this.scheduleEnd());let{device:o}=s;return o==="unknown"&&(o=h_(s.samples,!1),o!=="unknown"&&this.begin(s,o)),o},this.finishClassification=()=>{if(this.classificationTimer=null,!this.session||this.session.device!=="unknown")return;let i=this.session,r=h_(i.samples,!0);this.begin(i,r==="unknown"?"mouse":r)},this.end=()=>{if(!this.session)return;if(this.session.device==="unknown"){let r=this.session,s=h_(r.samples,!0);this.begin(r,s==="unknown"?"mouse":s)}if(!this.session)return;let i=this.session;this.emit(ne.End,i.lastEvent),this.reset()},this.handleKeyDown=i=>{i.key==="Control"&&this.pressedControlKeys.add(i.code||i.key)},this.handleKeyUp=i=>{i.key==="Control"&&(i.code?this.pressedControlKeys.delete(i.code):this.pressedControlKeys.clear())},this.handleWindowBlur=()=>{this.pressedControlKeys.clear()},this.element=e,this.options={...J4,...t},this.element?.addEventListener("wheel",this.handleEvent,{passive:!0})}get hasSubscribers(){return this.subscriptions.size>0}get device(){return this.session?.device??"unknown"}on(e){let t={listener:e};return this.subscriptions.set(e,t),this.updateControlKeyEventListeners(),()=>{this.subscriptions.get(e)===t&&this.off(e)}}off(e){this.subscriptions.delete(e),this.updateControlKeyEventListeners(),this.hasSubscribers||this.reset()}cancel(){let e=this.session;e&&e.device!=="unknown"&&this.emit(ne.Cancel,e.lastEvent),this.reset()}destroy(){this.cancel(),this.subscriptions.clear(),this.updateControlKeyEventListeners(),this.element?.removeEventListener("wheel",this.handleEvent)}startPendingSession(e){let t={samples:[e],device:"unknown",firstTimeStamp:e.timeStamp,lastTimeStamp:e.timeStamp,totalDeltaX:e.deltaX,totalDeltaY:e.deltaY,velocityX:0,velocityY:0,lastEvent:e.event};return this.session=t,this.classificationTimer=globalThis.setTimeout(this.finishClassification,this.options.classificationDelay),t}addSample(e,t){if(e.samples.push(t),e.lastTimeStamp=t.timeStamp,e.lastEvent=t.event,e.totalDeltaX+=t.deltaX,e.totalDeltaY+=t.deltaY,e.device!=="unknown"){let i=e.samples[e.samples.length-2],r=t.timeStamp-i.timeStamp;e.velocityX=r>0?t.deltaX/r:0,e.velocityY=r>0?t.deltaY/r:0,this.emit(ne.Move,t.event,{velocityX:e.velocityX,velocityY:e.velocityY})}}begin(e,t){e.device=t,this.clearClassificationTimer(),this.emit(ne.Start,e.samples[0].event);let i=e.lastTimeStamp-e.firstTimeStamp;e.velocityX=i>0?e.totalDeltaX/i:0,e.velocityY=i>0?e.totalDeltaY/i:0,this.emit(ne.Move,e.lastEvent,{velocityX:e.velocityX,velocityY:e.velocityY})}scheduleEnd(){this.clearEndTimer(),this.endTimer=globalThis.setTimeout(this.end,this.options.endDelay)}emit(e,t,i){let r=this.session;if(!r||r.device==="unknown")return;let s=e===ne.Start,o=e===ne.End||e===ne.Cancel,a=s?r.firstTimeStamp:r.lastTimeStamp,c=s?0:Math.max(0,a-r.firstTimeStamp),l=s?0:r.totalDeltaX,u=s?0:r.totalDeltaY,f=c>0?l/c:0,d=c>0?u/c:0,h=s?0:i?.velocityX??r.velocityX,p=s?0:i?.velocityY??r.velocityY,m={eventType:e,device:r.device,srcEvent:t,timeStamp:a,center:{x:t.clientX,y:t.clientY},deltaX:l,deltaY:u,deltaTime:c,velocity:Math.abs(h)>Math.abs(p)?h:p,velocityX:h,velocityY:p,overallVelocity:Math.abs(f)>Math.abs(d)?f:d,overallVelocityX:f,overallVelocityY:d,isFirst:s,isFinal:o};for(let{listener:g}of[...this.subscriptions.values()])g(m)}reset(){this.clearClassificationTimer(),this.clearEndTimer(),this.session=null}clearClassificationTimer(){this.classificationTimer!==null&&(globalThis.clearTimeout(this.classificationTimer),this.classificationTimer=null)}clearEndTimer(){this.endTimer!==null&&(globalThis.clearTimeout(this.endTimer),this.endTimer=null)}updateControlKeyEventListeners(){let e=this.hasSubscribers,t=eN();!t||e===this.listeningForControlKeys||(this.listeningForControlKeys=e,e?(t.addEventListener("keydown",this.handleKeyDown,!0),t.addEventListener("keyup",this.handleKeyUp,!0),t.addEventListener("blur",this.handleWindowBlur)):(t.removeEventListener("keydown",this.handleKeyDown,!0),t.removeEventListener("keyup",this.handleKeyUp,!0),t.removeEventListener("blur",this.handleWindowBlur),this.pressedControlKeys.clear()))}};function eN(){return typeof window<"u"?window:globalThis.document?.defaultView}function tN(n,e){let t=n.deltaX,i=n.deltaY;return n.deltaMode===X4&&(t*=OS,i*=OS),{event:n,timeStamp:n.timeStamp,deltaX:t,deltaY:i,isControlKeyDown:e}}function h_(n,e){return n.some(({event:t,isControlKeyDown:i})=>t.ctrlKey&&!i)?"trackpad":n.some(({event:t})=>t.deltaMode!==Z4)||n.some(nN)||n.every(({event:t})=>{let i=t.wheelDelta;return i!==void 0&&Math.abs(i)%40===0})?"mouse":n.some(({deltaX:t})=>t!==0)||n.length>1&&iN(n)?"trackpad":e?"mouse":"unknown"}function nN({event:n,deltaX:e,deltaY:t}){if(e!==0||t===0)return!1;let i=Math.abs(t/q4);if(Number.isInteger(i))return!0;let r=n.wheelDelta;return typeof r=="number"&&r!==0&&r%Q4===0}function iN(n){for(let e=0;eDS||Math.abs(t.deltaY)>DS||e>0&&t.timeStamp-n[e-1].timeStamp>K4)return!1}return!0}var NS=["mousedown","mousemove","mouseup","mouseover","mouseout","mouseenter","mouseleave"],_f=class extends Un{constructor(e,t,i){super(e,t,{enable:!0,...i}),this.handleEvent=s=>{this.handleOverEvent(s),this.handleOutEvent(s),this.handleEnterEvent(s),this.handleLeaveEvent(s),this.handleMoveEvent(s)},this.pressed=!1;let{enable:r=!1}=this.options;this.enableMoveEvent=r,this.enableLeaveEvent=r,this.enableEnterEvent=r,this.enableOutEvent=r,this.enableOverEvent=r,r&&NS.forEach(s=>this.listen(s,!0))}destroy(){NS.forEach(e=>this.listen(e,!1))}enableEventType(e,t){switch(e){case"pointermove":this.enableMoveEvent!==t&&(this.enableMoveEvent=t,this.listen("mousedown",t),this.listen("mousemove",t),this.listen("mouseup",t));break;case"pointerover":this.enableOverEvent!==t&&(this.enableOverEvent=t,this.listen("mouseover",t));break;case"pointerout":this.enableOutEvent!==t&&(this.enableOutEvent=t,this.listen("mouseout",t));break;case"pointerenter":this.enableEnterEvent!==t&&(this.enableEnterEvent=t,this.listen("mouseenter",t));break;case"pointerleave":this.enableLeaveEvent!==t&&(this.enableLeaveEvent=t,this.listen("mouseleave",t));break;default:}}handleOverEvent(e){this.enableOverEvent&&e.type==="mouseover"&&this._emit("pointerover",e)}handleOutEvent(e){this.enableOutEvent&&e.type==="mouseout"&&this._emit("pointerout",e)}handleEnterEvent(e){this.enableEnterEvent&&e.type==="mouseenter"&&this._emit("pointerenter",e)}handleLeaveEvent(e){this.enableLeaveEvent&&e.type==="mouseleave"&&this._emit("pointerleave",e)}handleMoveEvent(e){if(this.enableMoveEvent)switch(e.type){case"mousedown":e.button>=0&&(this.pressed=!0);break;case"mousemove":e.buttons===0&&(this.pressed=!1),this.pressed||this._emit("pointermove",e);break;case"mouseup":this.pressed=!1;break;default:}}_emit(e,t){this.callback({type:e,center:{x:t.clientX,y:t.clientY},srcEvent:t,pointerType:"mouse",target:t.target})}};var FS=["keydown","keyup"],yf=class extends Un{constructor(e,t,i){super(e,t,{enable:!0,tabIndex:0,...i}),this.handleEvent=s=>{let o=s.target||s.srcElement;o.tagName==="INPUT"&&o.type==="text"||o.tagName==="TEXTAREA"||(this.enableDownEvent&&s.type==="keydown"&&this.callback({type:"keydown",srcEvent:s,key:s.key,target:s.target}),this.enableUpEvent&&s.type==="keyup"&&this.callback({type:"keyup",srcEvent:s,key:s.key,target:s.target}))};let{enable:r=!1}=this.options;this.enableDownEvent=r,this.enableUpEvent=r,e.tabIndex=this.options.tabIndex,e.style.outline="none",r&&FS.forEach(s=>this.listen(s,!0))}destroy(){FS.forEach(e=>this.listen(e,!1))}enableEventType(e,t){e==="keydown"&&this.enableDownEvent!==t&&(this.enableDownEvent=t,this.listen(e,t)),e==="keyup"&&this.enableUpEvent!==t&&(this.enableUpEvent=t,this.listen(e,t))}};var bf=class extends Un{constructor(e,t,i){i.enable=i.enable??!1,super(e,t,i),this.handleEvent=r=>{this.options.enable&&this.callback({type:"contextmenu",center:{x:r.clientX,y:r.clientY},srcEvent:r,pointerType:"mouse",target:r.target})},i.enable&&this.listen("contextmenu",!0)}destroy(){this.listen("contextmenu",!1)}enableEventType(e,t){e==="contextmenu"&&this.options.enable!==t&&(this.options.enable=t,this.listen("contextmenu",t))}};var rN={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},sN=0,oN=1,aN=2,cN=1,lN=2,uN=4;function zS(n){let e=rN[n.srcEvent.type];if(!e)return null;let{buttons:t,button:i}=n.srcEvent,r=!1,s=!1,o=!1;return e===2?(r=!!(t&cN),s=!!(t&uN),o=!!(t&lN)):(r=i===sN,s=i===oN,o=i===aN),{leftButton:r,middleButton:s,rightButton:o}}function US(n,e){let t=n.center;if(!t)return null;let i=e.getBoundingClientRect(),r=i.width/e.offsetWidth||1,s=i.height/e.offsetHeight||1,o={x:(t.x-i.left-e.clientLeft)/r,y:(t.y-i.top-e.clientTop)/s};return{center:t,offsetCenter:o}}var fN={srcElement:"root",priority:0},vf=class{constructor(e,t){this.handleEvent=i=>{if(this.isEmpty())return;let r=this._normalizeEvent(i),s=i.srcEvent.target;for(;s&&s!==r.rootElement;){if(this._emit(r,s),r.handled)return;s=s.parentNode}this._emit(r,"root")},this.eventManager=e,this.recognizerName=t,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(e,t,i,r=!1,s=!1){let{handlers:o,handlersByElement:a}=this,c={...fN,...i},l=a.get(c.srcElement);l||(l=[],a.set(c.srcElement,l));let u={type:e,handler:t,srcElement:c.srcElement,priority:c.priority};r&&(u.once=!0),s&&(u.passive=!0),o.push(u),this._active=this._active||!u.passive;let f=l.length-1;for(;f>=0&&!(l[f].priority>=u.priority);)f--;l.splice(f+1,0,u)}remove(e,t){let{handlers:i,handlersByElement:r}=this;for(let s=i.length-1;s>=0;s--){let o=i[s];if(o.type===e&&o.handler===t){i.splice(s,1);let a=r.get(o.srcElement);a.splice(a.indexOf(o),1),a.length===0&&r.delete(o.srcElement)}}this._active=i.some(s=>!s.passive)}_emit(e,t){let i=this.handlersByElement.get(t);if(i){let r=!1,s=()=>{e.handled=!0},o=()=>{e.handled=!0,r=!0},a=[];for(let c=0;c{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:t}}};function dN(n){if("recognizer"in n)return n;let e,t=Array.isArray(n)?[...n]:[n];if(typeof t[0]=="function"){let i=t.shift(),r=t.shift()||{};e=new i(r)}else e=t.shift();return{recognizer:e,recognizeWith:typeof t[0]=="string"?[t[0]]:t[0],requireFailure:typeof t[1]=="string"?[t[1]]:t[1]}}var rc=class{constructor(e=null,t={}){if(this._onBasicInput=i=>{this.manager.emit(i.srcEvent.type,i)},this._onOtherEvent=i=>{this.manager.emit(i.type,i)},this.options={recognizers:[],events:{},touchAction:"compute",tabIndex:0,cssProps:{},...t},this.events=new Map,this.element=e,this.wheelSession=new gf(e),!!e){this.manager=new ic(e,this.options);for(let i of this.options.recognizers){let{recognizer:r,recognizeWith:s,requireFailure:o}=dN(i);this.manager.add(r),s&&r.recognizeWith(s),o&&r.requireFailure(o)}this.manager.on("hammer.input",this._onBasicInput),this.wheelInput=new mf(e,this._onOtherEvent,{enable:!1,wheelSession:this.wheelSession}),this.moveInput=new _f(e,this._onOtherEvent,{enable:!1}),this.keyInput=new yf(e,this._onOtherEvent,{enable:!1,tabIndex:t.tabIndex}),this.contextmenuInput=new bf(e,this._onOtherEvent,{enable:!1}),this.on(this.options.events)}}getElement(){return this.element}destroy(){if(!this.element){this.wheelSession.destroy();return}this.wheelInput.destroy(),this.wheelSession.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy()}on(e,t,i){this._addEventHandler(e,t,i,!1)}once(e,t,i){this._addEventHandler(e,t,i,!0)}watch(e,t,i){this._addEventHandler(e,t,i,!1,!0)}off(e,t){this._removeEventHandler(e,t)}emit(e){this.manager?.emit(e.type,e)}_toggleRecognizer(e,t){let{manager:i}=this;if(!i)return;let r=i.get(e);r&&(r.set({enable:t,wheelSession:this.wheelSession}),i.touchAction.update()),this.wheelInput?.enableEventType(e,t),this.moveInput?.enableEventType(e,t),this.keyInput?.enableEventType(e,t),this.contextmenuInput?.enableEventType(e,t)}_addEventHandler(e,t,i,r,s){if(typeof e!="string"){i=t;for(let[l,u]of Object.entries(e))this._addEventHandler(l,u,i,r,s);return}let{manager:o,events:a}=this;if(!o)return;let c=a.get(e);if(!c){let l=this._getRecognizerName(e)||e;c=new vf(this,l),a.set(e,c),o&&o.on(e,c.handleEvent)}c.add(e,t,i,r,s),c.isEmpty()||this._toggleRecognizer(c.recognizerName,!0)}_removeEventHandler(e,t){if(typeof e!="string"){for(let[s,o]of Object.entries(e))this._removeEventHandler(s,o);return}let{events:i}=this,r=i.get(e);if(r&&(r.remove(e,t),r.isEmpty())){let{recognizerName:s}=r,o=!1;for(let a of i.values())if(a.recognizerName===s&&!a.isEmpty()){o=!0;break}o||this._toggleRecognizer(s,!1)}}_getRecognizerName(e){return this.manager.recognizers.find(t=>t.getEventNames().includes(e))?.options.event}};var p_={DEFAULT:"default",LNGLAT:"lnglat",METER_OFFSETS:"meter-offsets",LNGLAT_OFFSETS:"lnglat-offsets",CARTESIAN:"cartesian"};Object.defineProperty(p_,"IDENTITY",{get:()=>(ae.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),p_.CARTESIAN)});var qe={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},Zt={common:0,meters:1,pixels:2},ao={click:"onClick",dblclick:"onClick",panstart:"onDragStart",panmove:"onDrag",panend:"onDragEnd"},m_={multipan:[qi,{threshold:10,pointers:2,trackpad:!0}],pinch:[oo,{trackpad:!0},null,["multipan"]],pan:[qi,{threshold:1},["pinch"],["multipan"]],dblclick:[qr,{event:"dblclick",taps:2,enable:!1}],dblclickdrag:[ro,{event:"dblclickdrag",enable:!1},["dblclick"],null],click:[qr,{event:"click"},["dblclickdrag"],["dblclick","dblclickdrag"]]};function hN(n,e){if(n===e)return!0;if(Array.isArray(n)){let t=n.length;if(!e||e.length!==t)return!1;for(let i=0;i{for(let r in i)if(!hN(i[r],e[r])){t=n(i),e=i;break}return t}}var $S=[0,0,0,0],pN=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],GS=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],mN=[0,0,0],VS=[0,0,0],gN={default:-1,cartesian:0,lnglat:1,"meter-offsets":2,"lnglat-offsets":3};function Zr(n){let e=gN[n];if(e===void 0)throw new Error(`Invalid coordinateSystem: ${n}`);return e}var _N=$n(bN);function g_(n,e,t=VS){t.length<3&&(t=[t[0],t[1],0]);let i=t,r,s=!0;switch(e==="lnglat-offsets"||e==="meter-offsets"?r=t:r=n.isGeospatial?[Math.fround(n.longitude),Math.fround(n.latitude),0]:null,n.projectionMode){case qe.WEB_MERCATOR:(e==="lnglat"||e==="cartesian")&&(r=[0,0,0],s=!1);break;case qe.WEB_MERCATOR_AUTO_OFFSET:e==="lnglat"?i=r:e==="cartesian"&&(i=[Math.fround(n.center[0]),Math.fround(n.center[1]),0],r=n.unprojectPosition(i),i[0]-=t[0],i[1]-=t[1],i[2]-=t[2]);break;case qe.IDENTITY:i=n.position.map(Math.fround),i[2]=i[2]||0;break;case qe.GLOBE:s=!1,r=null;break;default:s=!1}return{geospatialOrigin:r,shaderCoordinateOrigin:i,offsetMode:s}}function yN(n,e,t){let{viewMatrixUncentered:i,projectionMatrix:r}=n,{viewMatrix:s,viewProjectionMatrix:o}=n,a=$S,c=$S,l=n.cameraPosition,{geospatialOrigin:u,shaderCoordinateOrigin:f,offsetMode:d}=g_(n,e,t);return d&&(c=n.projectPosition(u||f),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,a=At.transformMat4([],c,o),s=i||s,o=We.multiply([],r,s),o=We.multiply([],o,pN)),{viewMatrix:s,viewProjectionMatrix:o,projectionCenter:a,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:f,geospatialOrigin:u}}function WS({viewport:n,devicePixelRatio:e=1,modelMatrix:t=null,coordinateSystem:i="default",coordinateOrigin:r=VS,autoWrapLongitude:s=!1}){i==="default"&&(i=n.isGeospatial?"lnglat":"cartesian");let o=_N({viewport:n,devicePixelRatio:e,coordinateSystem:i,coordinateOrigin:r});return o.wrapLongitude=s,o.modelMatrix=t||GS,o}function bN({viewport:n,devicePixelRatio:e,coordinateSystem:t,coordinateOrigin:i}){let{projectionCenter:r,viewProjectionMatrix:s,originCommon:o,cameraPosCommon:a,shaderCoordinateOrigin:c,geospatialOrigin:l}=yN(n,t,i),u=n.getDistanceScales(),f=[n.width*e,n.height*e],d=At.transformMat4([],[0,0,-n.focalDistance,1],n.projectionMatrix)[3]||1,h={coordinateSystem:Zr(t),projectionMode:n.projectionMode,coordinateOrigin:c,commonOrigin:o.slice(0,3),center:r,pseudoMeters:!!n._pseudoMeters,viewportSize:f,devicePixelRatio:e,focalDistance:d,commonUnitsPerMeter:u.unitsPerMeter,commonUnitsPerWorldUnit:u.unitsPerMeter,commonUnitsPerWorldUnit2:mN,scale:n.scale,wrapLongitude:!1,viewProjectionMatrix:s,modelMatrix:GS,cameraPosition:a};if(l){let p=n.getDistanceScales(l);switch(t){case"meter-offsets":h.commonUnitsPerWorldUnit=p.unitsPerMeter,h.commonUnitsPerWorldUnit2=p.unitsPerMeter2;break;case"lnglat":case"lnglat-offsets":n._pseudoMeters||(h.commonUnitsPerMeter=p.unitsPerMeter),h.commonUnitsPerWorldUnit=p.unitsPerDegree,h.commonUnitsPerWorldUnit2=p.unitsPerDegree2;break;case"cartesian":h.commonUnitsPerWorldUnit=[1,1,p.unitsPerMeter[2]],h.commonUnitsPerWorldUnit2=[0,0,p.unitsPerMeter2[2]];break;default:break}}if(n.projectionMode===qe.GLOBE&&t==="meter-offsets"){let g=i[0]*Math.PI/180,v=i[1]*Math.PI/180,y=Math.cos(v),b=((i[2]||0)/6370972+1)*256;h.commonOrigin=[Math.sin(g)*y*b,-Math.cos(g)*y*b,Math.sin(v)*b]}return h}var vN=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],xN=vN.map(n=>`const COORDINATE_SYSTEM_${n.toUpperCase().replaceAll("-","_")}: i32 = ${Zr(n)};`).join(""),wN=Object.keys(qe).map(n=>`const PROJECTION_MODE_${n}: i32 = ${qe[n]};`).join(""),EN=Object.keys(Zt).map(n=>`const UNIT_${n.toUpperCase()}: i32 = ${Zt[n]};`).join(""),SN=`${xN} -${wN} -${EN} +`,ff={name:"geometry",source:M4,vs:A4,fs:k4};vt();ze();var ne;(function(n){n[n.Start=1]="Start",n[n.Move=2]="Move",n[n.End=4]="End",n[n.Cancel=8]="Cancel"})(ne||(ne={}));var Le;(function(n){n[n.None=0]="None",n[n.Left=1]="Left",n[n.Right=2]="Right",n[n.Up=4]="Up",n[n.Down=8]="Down",n[n.Horizontal=3]="Horizontal",n[n.Vertical=12]="Vertical",n[n.All=15]="All"})(Le||(Le={}));var H;(function(n){n[n.Possible=1]="Possible",n[n.Began=2]="Began",n[n.Changed=4]="Changed",n[n.Ended=8]="Ended",n[n.Recognized=8]="Recognized",n[n.Cancelled=16]="Cancelled",n[n.Failed=32]="Failed"})(H||(H={}));var wS="compute",o_="auto",jr="manipulation",Hr="none",Qa="pan-x",Ja="pan-y";function a_(n){if(n.includes(Hr))return Hr;let e=n.includes(Qa),t=n.includes(Ja);return e&&t?Hr:e||t?e?Qa:Ja:n.includes(jr)?jr:o_}var ec=class{constructor(e,t){this.actions="",this.manager=e,this.set(t)}set(e){e===wS&&(e=this.compute()),this.manager.element&&(this.manager.element.style.touchAction=e,this.actions=e)}update(){this.set(this.manager.options.touchAction)}compute(){let e=[];for(let t of this.manager.recognizers)t.options.enable&&(e=e.concat(t.getTouchAction()));return a_(e.join(" "))}};function to(n){return n.trim().split(/\s+/g)}function df(n,e,t){if(n)for(let i of to(e))n.addEventListener(i,t,!1)}function hf(n,e,t){if(n)for(let i of to(e))n.removeEventListener(i,t,!1)}function c_(n){return(n.ownerDocument||n).defaultView}function l_(n,e){let t=n;for(;t;){if(t===e)return!0;t=t.parentNode}return!1}function pf(n){let e=n.length;if(e===1)return{x:Math.round(n[0].clientX),y:Math.round(n[0].clientY)};let t=0,i=0,r=0;for(;r=Math.abs(e)?n<0?Le.Left:Le.Right:e<0?Le.Up:Le.Down}function SS(n,e){let t=e.center,i=n.offsetDelta,r=n.prevDelta,s=n.prevInput;return(e.eventType===ne.Start||s?.eventType===ne.End)&&(r=n.prevDelta={x:s?.deltaX||0,y:s?.deltaY||0},i=n.offsetDelta={x:t.x,y:t.y}),{deltaX:r.x+(t.x-i.x),deltaY:r.y+(t.y-i.y)}}function mf(n,e,t){return{x:e/n||0,y:t/n||0}}function PS(n,e){return tc(e[0],e[1])/tc(n[0],n[1])}function CS(n,e){return f_(e[1],e[0])-f_(n[1],n[0])}function TS(n,e){let t=n.lastInterval||e,i=e.timeStamp-t.timeStamp,r,s,o,a;if(e.eventType!==ne.Cancel&&(i>25||t.velocity===void 0)){let c=e.deltaX-t.deltaX,l=e.deltaY-t.deltaY,u=mf(i,c,l);s=u.x,o=u.y,r=Math.abs(u.x)>Math.abs(u.y)?u.x:u.y,a=io(c,l),n.lastInterval=e}else r=t.velocity,s=t.velocityX,o=t.velocityY,a=t.direction;e.velocity=r,e.velocityX=s,e.velocityY=o,e.direction=a}function d_(n,e){return"pointerId"in n?n.pointerId:e}function LS(n,e){n.movementOrigin=new Map(e.map((t,i)=>[d_(t,i),{clientX:t.clientX,clientY:t.clientY}])),n.firstMovementTime=void 0}function I4(n,e){let t=e.pointers.map(d_);if(n.movementOrigin?.size===t.length&&t.every(r=>n.movementOrigin.has(r))||LS(n,e.pointers),e.distancePerPointer=e.pointers.map((r,s)=>tc(n.movementOrigin.get(t[s]),r)),e.eventType&ne.Move&&e.distancePerPointer.some(r=>r>0)&&(n.firstMovementTime??(n.firstMovementTime=e.timeStamp)),e.movementDeltaTime=n.firstMovementTime===void 0?0:e.timeStamp-n.firstMovementTime,e.eventType&(ne.End|ne.Cancel)){let r=e.changedPointers.map(s=>d_(s,e.pointers.indexOf(s)));LS(n,e.pointers.filter((s,o)=>!r.includes(t[o])))}}function MS(n,e){let{session:t}=n,{pointers:i}=e,{length:r}=i;t.firstInput||(t.firstInput=u_(e)),r>1&&!t.firstMultiple?t.firstMultiple=u_(e):r===1&&(t.firstMultiple=!1);let{firstInput:s,firstMultiple:o}=t,a=o?o.center:s.center,c=e.center=pf(i);e.timeStamp=Date.now(),e.deltaTime=e.timeStamp-s.timeStamp,I4(t,e),e.angle=ES(a,c),e.distance=no(a,c);let{deltaX:l,deltaY:u}=SS(t,e);e.deltaX=l,e.deltaY=u,e.offsetDirection=io(e.deltaX,e.deltaY);let f=mf(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=f.x,e.overallVelocityY=f.y,e.overallVelocity=Math.abs(f.x)>Math.abs(f.y)?f.x:f.y,e.scale=o?PS(o.pointers,i):1,e.rotation=o?CS(o.pointers,i):0,e.maxPointers=t.prevInput?e.pointers.length>t.prevInput.maxPointers?e.pointers.length:t.prevInput.maxPointers:e.pointers.length;let d=n.element;return l_(e.srcEvent.target,d)&&(d=e.srcEvent.target),e.target=d,TS(t,e),e}function AS(n,e,t){let i=t.pointers.length,r=t.changedPointers.length,s=e&ne.Start&&i-r===0,o=e&(ne.End|ne.Cancel)&&i-r===0;t.isFirst=!!s,t.isFinal=!!o,s&&(n.session={}),t.eventType=e;let a=MS(n,t);n.emit("hammer.input",a),n.recognize(a),n.session.prevInput=a}var nc=class{constructor(e){this.evEl="",this.evWin="",this.evTarget="",this.domHandler=t=>{this.manager.options.enable&&this.handler(t)},this.manager=e,this.element=e.element,this.target=e.options.inputTarget||e.element}callback(e,t){AS(this.manager,e,t)}init(){df(this.element,this.evEl,this.domHandler),df(this.target,this.evTarget,this.domHandler),df(c_(this.element),this.evWin,this.domHandler)}destroy(){hf(this.element,this.evEl,this.domHandler),hf(this.target,this.evTarget,this.domHandler),hf(c_(this.element),this.evWin,this.domHandler)}};var B4={pointerdown:ne.Start,pointermove:ne.Move,pointerup:ne.End,pointercancel:ne.Cancel,pointerout:ne.Cancel},O4="pointerdown",D4="pointermove pointerup pointercancel",ic=class extends nc{constructor(e){super(e),this.evEl=O4,this.evWin=D4,this.store=this.manager.session.pointerEvents=[],this.init()}handler(e){let{store:t}=this,i=!1,r=B4[e.type],s=e.pointerType,o=s==="touch",a=t.findIndex(c=>c.pointerId===e.pointerId);r&ne.Start&&(e.buttons||o)?a<0&&(t.push(e),a=t.length-1):r&(ne.End|ne.Cancel)&&(i=!0),!(a<0)&&(t[a]=e,this.callback(r,{pointers:t,changedPointers:[e],eventType:r,pointerType:s,srcEvent:e}),i&&t.splice(a,1))}};var N4=["","webkit","Moz","MS","ms","o"];function kS(n,e){let t=e[0].toUpperCase()+e.slice(1);for(let i of N4){let r=i?i+t:e;if(r in n)return r}}var F4=1,RS=2,IS={touchAction:"compute",enable:!0,inputTarget:null,cssProps:{userSelect:"none",userDrag:"none",touchCallout:"none",tapHighlightColor:"rgba(0,0,0,0)"}},rc=class{constructor(e,t){this.options={...IS,...t,cssProps:{...IS.cssProps,...t.cssProps},inputTarget:t.inputTarget||e},this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=new ic(this),this.touchAction=new ec(this,this.options.touchAction),this.toggleCssProps(!0)}set(e){return Object.assign(this.options,e),e.touchAction&&this.touchAction.update(),e.inputTarget&&(this.input.destroy(),this.input.target=e.inputTarget,this.input.init()),this}stop(e){this.session.stopped=e?RS:F4}recognize(e){let{session:t}=this;if(t.stopped)return;this.session.prevented&&e.srcEvent.preventDefault();let i,{recognizers:r}=this,{curRecognizer:s}=t;(!s||s&&s.state&H.Recognized)&&(s=t.curRecognizer=null);let o=0;for(;o-1&&this.requireFail.splice(i,1)}return this}hasRequireFailures(){return!!this.requireFail.find(e=>e.options.enable)}canRecognizeWith(e){return!!this.simultaneous[e.id]}emit(e){if(!e)return;let{state:t}=this;t=H.Ended&&this.manager.emit(this.options.event+h_(t),e)}tryEmit(e){this.canEmit()?this.emit(e):this.state=H.Failed}canEmit(){let e=0;for(;e=e.distance)&&(e.distancePerPointer===void 0||n.distancePerPointer.length>0&&n.distancePerPointer.every(t=>t>=e.distancePerPointer))&&(e.movementDeltaTime===void 0||n.movementDeltaTime>=e.movementDeltaTime)&&(e.rotation===void 0||U4(n.rotation)>=e.rotation)&&(e.scale===void 0||Math.abs(n.scale-1)>=e.scale)}var Yr=class extends dn{attrTest(e){let t=this.options.pointers;return t===0||e.pointers.length===t}coherentTest(e){let t=this.options.coherent;return!t?.length||t.some(i=>$4(e,i))}process(e){let{state:t}=this,{eventType:i}=e,r=t&(H.Began|H.Changed),s=this.attrTest(e);return r&&(i&ne.Cancel||!s)?t|H.Cancelled:r||s?i&ne.End?t|H.Ended:t&H.Began?t|H.Changed:H.Began:H.Failed}};var G4=["","start","move","end","cancel"],ro=class extends dn{constructor(e={}){super({enable:!0,event:"doubleclickdrag",pointers:1,interval:500,time:350,threshold:28,dragThreshold:1,pixelsPerScale:120,...e}),this._tapStart=null,this._lastTap=null,this._drag=null,this._emittedStart=!1}getTouchAction(){return[jr]}getEventNames(){return G4.map(e=>this.options.event+e)}process(e){let{options:t}=this;return e.pointers.length===t.pointers?e.eventType&ne.Start?this._handleStart(e):e.eventType&ne.Move?this._handleMove(e):e.eventType&ne.Cancel?this._handleEnd(e,!0):e.eventType&ne.End?this._handleEnd(e,!1):H.Failed:(this.reset(),H.Failed)}reset(){this._tapStart=null,this._lastTap=null,this._drag=null,this._emittedStart=!1}emit(e){if(e){if(this.state===H.Began){if(!this._drag?.active||this._emittedStart)return;this._emittedStart=!0,this.manager.emit(`${this.options.event}start`,e),this.manager.emit(this.options.event,e);return}if(this.state===H.Changed){if(!this._emittedStart)return;this.manager.emit(`${this.options.event}move`,e),this.manager.emit(this.options.event,e);return}if(this.state===H.Ended){if(!this._emittedStart)return;this.manager.emit(this.options.event,e),this.manager.emit(`${this.options.event}end`,e),this._emittedStart=!1;return}if(this.state===H.Cancelled){if(!this._emittedStart)return;this.manager.emit(this.options.event,e),this.manager.emit(`${this.options.event}cancel`,e),this._emittedStart=!1}}}_handleStart(e){let t=this._getPointerId(e);return this._lastTap&&this._isTapMatch(e,this._lastTap)?(this._tapStart=null,this._lastTap=null,this._drag={startCenter:e.center,pointerId:t,active:!1},this._emittedStart=!1,H.Began):(this._tapStart={center:e.center,timeStamp:e.timeStamp,pointerId:t},this._lastTap=null,this._drag=null,this._emittedStart=!1,H.Failed)}_handleMove(e){if(!this._drag||!this._isSamePointer(e,this._drag.pointerId))return H.Failed;let t=this._drag.startCenter.y-e.center.y;return!this._drag.active&&Math.abs(t){this.state=H.Recognized,this.tryEmit(this._input)},t.interval),H.Began):H.Recognized}return H.Failed}failTimeout(){return this._timer=setTimeout(()=>{this.state=H.Failed},this.options.interval),H.Failed}reset(){clearTimeout(this._timer)}emit(e){this.state===H.Recognized&&(e.tapCount=this.count,this.manager.emit(this.options.event,e))}};var so=class extends Yr{constructor(){super(...arguments),this.wheelSession=null,this.wheelSessionUnsubscribe=null,this.handleWheelSessionEvent=e=>{e.device==="trackpad"&&this.handleTrackpadEvent(e)}}set(e){let{wheelSession:t,...i}=e;return t&&t!==this.wheelSession&&(this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=null,this.wheelSession=t),super.set(i),this.updateWheelSessionSubscription(),this}getTrackpadInput(e,t={}){let{srcEvent:i}=e,r=t.deltaX??e.deltaX,s=t.deltaY??e.deltaY,o=io(r,s),a=Math.sqrt(e.deltaX*e.deltaX+e.deltaY*e.deltaY),c=i;return{pointers:[c,c],changedPointers:[c,c],pointerType:"trackpad",srcEvent:c,eventType:e.eventType,timeStamp:e.timeStamp,deltaTime:e.deltaTime,center:e.center,deltaX:r,deltaY:s,angle:Math.atan2(s,r)*180/Math.PI,distance:Math.sqrt(r*r+s*s),distancePerPointer:[a,a],movementDeltaTime:e.deltaTime,scale:1,rotation:0,direction:o,offsetDirection:o,velocity:e.velocity,velocityX:e.velocityX,velocityY:e.velocityY,overallVelocity:e.overallVelocity,overallVelocityX:e.overallVelocityX,overallVelocityY:e.overallVelocityY,maxPointers:2,target:i.target||this.manager.element,additionalEvent:"",...t}}updateWheelSessionSubscription(){let e=!!(this.wheelSession&&this.options.enable&&this.options.trackpad&&this.options.pointers===2);e&&!this.wheelSessionUnsubscribe?this.wheelSessionUnsubscribe=this.wheelSession.on(this.handleWheelSessionEvent):!e&&this.wheelSessionUnsubscribe&&(this.wheelSessionUnsubscribe(),this.wheelSessionUnsubscribe=null)}};var V4=["","start","move","end","cancel","up","down","left","right"],Xi=class extends so{constructor(e={}){super({enable:!0,pointers:1,event:"pan",threshold:10,direction:Le.All,trackpad:!1,coherent:[],...e}),this.trackpadGesture=!1,this.pX=null,this.pY=null}getTouchAction(){let{options:{direction:e}}=this,t=[];return e&Le.Horizontal&&t.push(Ja),e&Le.Vertical&&t.push(Qa),t}getEventNames(){return V4.map(e=>this.options.event+e)}directionTest(e){let{options:t}=this,i=!0,{distance:r}=e,{direction:s}=e,o=e.deltaX,a=e.deltaY;return s&t.direction||(t.direction&Le.Horizontal?(s=o===0?Le.None:o<0?Le.Left:Le.Right,i=o!==this.pX,r=Math.abs(e.deltaX)):(s=a===0?Le.None:a<0?Le.Up:Le.Down,i=a!==this.pY,r=Math.abs(e.deltaY))),e.direction=s,i&&r>t.threshold&&!!(s&t.direction)}attrTest(e){let t=!!(this.state&H.Began),i=!(this.options.coherent?.length&&e.eventType&(ne.End|ne.Cancel));return super.attrTest(e)&&(t||i&&this.coherentTest(e)&&this.directionTest(e))}emit(e){this.pX=e.deltaX,this.pY=e.deltaY;let t=Le[e.direction].toLowerCase();t&&(e.additionalEvent=this.options.event+t),super.emit(e)}handleTrackpadEvent(e){e.isFirst&&(this.trackpadGesture=!e.srcEvent.ctrlKey,!this.trackpadGesture&&this.state&(H.Recognized|H.Cancelled|H.Failed)&&(this.state=H.Possible)),this.trackpadGesture&&(this.recognize(this.getTrackpadInput(e,{deltaX:-e.deltaX,deltaY:-e.deltaY,velocity:-e.velocity,velocityX:-e.velocityX,velocityY:-e.velocityY,overallVelocity:-e.overallVelocity,overallVelocityX:-e.overallVelocityX,overallVelocityY:-e.overallVelocityY})),e.isFinal&&(this.trackpadGesture=!1))}};var W4=["","start","move","end","cancel","in","out"],oo=class extends so{constructor(e={}){super({enable:!0,event:"pinch",threshold:0,pointers:2,trackpad:!1,coherent:[],...e}),this.trackpadGesture=!1}getTouchAction(){return[Hr]}getEventNames(){return W4.map(e=>this.options.event+e)}attrTest(e){let t=!!this.options.coherent?.length,i=!!(this.state&H.Began),r=!(t&&e.eventType&(ne.End|ne.Cancel));return super.attrTest(e)&&(i||r&&(t?this.coherentTest(e):Math.abs(e.scale-1)>this.options.threshold))}emit(e){if(e.scale!==1){let t=e.scale<1?"in":"out";e.additionalEvent=this.options.event+t}super.emit(e)}handleTrackpadEvent(e){e.isFirst&&(this.trackpadGesture=e.srcEvent.ctrlKey,!this.trackpadGesture&&this.state&(H.Recognized|H.Cancelled|H.Failed)&&(this.state=H.Possible)),this.trackpadGesture&&(this.recognize(this.getTrackpadInput(e,{deltaX:0,deltaY:0,velocity:0,velocityX:0,velocityY:0,overallVelocity:0,overallVelocityX:0,overallVelocityY:0,scale:Math.exp(-e.deltaY/100)})),e.isFinal&&(this.trackpadGesture=!1))}};var Wn=class{constructor(e,t,i){this.element=e,this.callback=t,this.options=i}listen(e,t){t?this.element.addEventListener(e,this.handleEvent,{passive:!1}):this.element.removeEventListener(e,this.handleEvent)}};var OS=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"";var q4=OS.indexOf("firefox")!==-1,Z4=40,X4=.25,gf=class extends Wn{constructor(e,t,i){i.enable=i.enable??!1,super(e,t,i),this.handleEvent=r=>{if(!this.options.enable)return;let s=r.deltaY;globalThis.WheelEvent&&(q4&&r.deltaMode===globalThis.WheelEvent.DOM_DELTA_PIXEL&&(s/=globalThis.devicePixelRatio),r.deltaMode===globalThis.WheelEvent.DOM_DELTA_LINE&&(s*=Z4)),r.shiftKey&&s&&(s=s*X4),this.callback({type:"wheel",center:{x:r.clientX,y:r.clientY},delta:-s,device:this.options.wheelSession?.device??"unknown",srcEvent:r,pointerType:"mouse",target:r.target})},i.enable&&(this.wheelSessionUnsubscribe=this.options.wheelSession?.on(()=>{}),this.listen("wheel",!0))}destroy(){this.listen("wheel",!1),this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=void 0}enableEventType(e,t){e==="wheel"&&this.options.enable!==t&&(this.options.enable=t,t&&!this.wheelSessionUnsubscribe&&(this.wheelSessionUnsubscribe=this.options.wheelSession?.on(()=>{})),this.listen("wheel",t),t||(this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=void 0))}};var K4=4.000244140625,DS=40,Q4=0,J4=1,eN=40,NS=40,tN=120,nN={classificationDelay:32,endDelay:80},_f=class{constructor(e,t={}){this.subscriptions=new Map,this.session=null,this.classificationTimer=null,this.endTimer=null,this.pressedControlKeys=new Set,this.listeningForControlKeys=!1,this.handleEvent=i=>{if(!this.hasSubscribers)return"unknown";let r=rN(i,this.pressedControlKeys.size>0),s=this.session;if(s&&r.timeStamp-s.lastTimeStamp>=this.options.endDelay){if(this.end(),!this.hasSubscribers)return"unknown";s=null}s?(this.scheduleEnd(),this.addSample(s,r)):(s=this.startPendingSession(r),this.scheduleEnd());let{device:o}=s;return o==="unknown"&&(o=p_(s.samples,!1),o!=="unknown"&&this.begin(s,o)),o},this.finishClassification=()=>{if(this.classificationTimer=null,!this.session||this.session.device!=="unknown")return;let i=this.session,r=p_(i.samples,!0);this.begin(i,r==="unknown"?"mouse":r)},this.end=()=>{if(!this.session)return;if(this.session.device==="unknown"){let r=this.session,s=p_(r.samples,!0);this.begin(r,s==="unknown"?"mouse":s)}if(!this.session)return;let i=this.session;this.emit(ne.End,i.lastEvent),this.reset()},this.handleKeyDown=i=>{i.key==="Control"&&this.pressedControlKeys.add(i.code||i.key)},this.handleKeyUp=i=>{i.key==="Control"&&(i.code?this.pressedControlKeys.delete(i.code):this.pressedControlKeys.clear())},this.handleWindowBlur=()=>{this.pressedControlKeys.clear()},this.element=e,this.options={...nN,...t},this.element?.addEventListener("wheel",this.handleEvent,{passive:!0})}get hasSubscribers(){return this.subscriptions.size>0}get device(){return this.session?.device??"unknown"}on(e){let t={listener:e};return this.subscriptions.set(e,t),this.updateControlKeyEventListeners(),()=>{this.subscriptions.get(e)===t&&this.off(e)}}off(e){this.subscriptions.delete(e),this.updateControlKeyEventListeners(),this.hasSubscribers||this.reset()}cancel(){let e=this.session;e&&e.device!=="unknown"&&this.emit(ne.Cancel,e.lastEvent),this.reset()}destroy(){this.cancel(),this.subscriptions.clear(),this.updateControlKeyEventListeners(),this.element?.removeEventListener("wheel",this.handleEvent)}startPendingSession(e){let t={samples:[e],device:"unknown",firstTimeStamp:e.timeStamp,lastTimeStamp:e.timeStamp,totalDeltaX:e.deltaX,totalDeltaY:e.deltaY,velocityX:0,velocityY:0,lastEvent:e.event};return this.session=t,this.classificationTimer=globalThis.setTimeout(this.finishClassification,this.options.classificationDelay),t}addSample(e,t){if(e.samples.push(t),e.lastTimeStamp=t.timeStamp,e.lastEvent=t.event,e.totalDeltaX+=t.deltaX,e.totalDeltaY+=t.deltaY,e.device!=="unknown"){let i=e.samples[e.samples.length-2],r=t.timeStamp-i.timeStamp;e.velocityX=r>0?t.deltaX/r:0,e.velocityY=r>0?t.deltaY/r:0,this.emit(ne.Move,t.event,{velocityX:e.velocityX,velocityY:e.velocityY})}}begin(e,t){e.device=t,this.clearClassificationTimer(),this.emit(ne.Start,e.samples[0].event);let i=e.lastTimeStamp-e.firstTimeStamp;e.velocityX=i>0?e.totalDeltaX/i:0,e.velocityY=i>0?e.totalDeltaY/i:0,this.emit(ne.Move,e.lastEvent,{velocityX:e.velocityX,velocityY:e.velocityY})}scheduleEnd(){this.clearEndTimer(),this.endTimer=globalThis.setTimeout(this.end,this.options.endDelay)}emit(e,t,i){let r=this.session;if(!r||r.device==="unknown")return;let s=e===ne.Start,o=e===ne.End||e===ne.Cancel,a=s?r.firstTimeStamp:r.lastTimeStamp,c=s?0:Math.max(0,a-r.firstTimeStamp),l=s?0:r.totalDeltaX,u=s?0:r.totalDeltaY,f=c>0?l/c:0,d=c>0?u/c:0,h=s?0:i?.velocityX??r.velocityX,p=s?0:i?.velocityY??r.velocityY,m={eventType:e,device:r.device,srcEvent:t,timeStamp:a,center:{x:t.clientX,y:t.clientY},deltaX:l,deltaY:u,deltaTime:c,velocity:Math.abs(h)>Math.abs(p)?h:p,velocityX:h,velocityY:p,overallVelocity:Math.abs(f)>Math.abs(d)?f:d,overallVelocityX:f,overallVelocityY:d,isFirst:s,isFinal:o};for(let{listener:g}of[...this.subscriptions.values()])g(m)}reset(){this.clearClassificationTimer(),this.clearEndTimer(),this.session=null}clearClassificationTimer(){this.classificationTimer!==null&&(globalThis.clearTimeout(this.classificationTimer),this.classificationTimer=null)}clearEndTimer(){this.endTimer!==null&&(globalThis.clearTimeout(this.endTimer),this.endTimer=null)}updateControlKeyEventListeners(){let e=this.hasSubscribers,t=iN();!t||e===this.listeningForControlKeys||(this.listeningForControlKeys=e,e?(t.addEventListener("keydown",this.handleKeyDown,!0),t.addEventListener("keyup",this.handleKeyUp,!0),t.addEventListener("blur",this.handleWindowBlur)):(t.removeEventListener("keydown",this.handleKeyDown,!0),t.removeEventListener("keyup",this.handleKeyUp,!0),t.removeEventListener("blur",this.handleWindowBlur),this.pressedControlKeys.clear()))}};function iN(){return typeof window<"u"?window:globalThis.document?.defaultView}function rN(n,e){let t=n.deltaX,i=n.deltaY;return n.deltaMode===J4&&(t*=DS,i*=DS),{event:n,timeStamp:n.timeStamp,deltaX:t,deltaY:i,isControlKeyDown:e}}function p_(n,e){return n.some(({event:t,isControlKeyDown:i})=>t.ctrlKey&&!i)?"trackpad":n.some(({event:t})=>t.deltaMode!==Q4)||n.some(sN)||n.every(({event:t})=>{let i=t.wheelDelta;return i!==void 0&&Math.abs(i)%40===0})?"mouse":n.some(({deltaX:t})=>t!==0)||n.length>1&&oN(n)?"trackpad":e?"mouse":"unknown"}function sN({event:n,deltaX:e,deltaY:t}){if(e!==0||t===0)return!1;let i=Math.abs(t/K4);if(Number.isInteger(i))return!0;let r=n.wheelDelta;return typeof r=="number"&&r!==0&&r%tN===0}function oN(n){for(let e=0;eNS||Math.abs(t.deltaY)>NS||e>0&&t.timeStamp-n[e-1].timeStamp>eN)return!1}return!0}var FS=["mousedown","mousemove","mouseup","mouseover","mouseout","mouseenter","mouseleave"],yf=class extends Wn{constructor(e,t,i){super(e,t,{enable:!0,...i}),this.handleEvent=s=>{this.handleOverEvent(s),this.handleOutEvent(s),this.handleEnterEvent(s),this.handleLeaveEvent(s),this.handleMoveEvent(s)},this.pressed=!1;let{enable:r=!1}=this.options;this.enableMoveEvent=r,this.enableLeaveEvent=r,this.enableEnterEvent=r,this.enableOutEvent=r,this.enableOverEvent=r,r&&FS.forEach(s=>this.listen(s,!0))}destroy(){FS.forEach(e=>this.listen(e,!1))}enableEventType(e,t){switch(e){case"pointermove":this.enableMoveEvent!==t&&(this.enableMoveEvent=t,this.listen("mousedown",t),this.listen("mousemove",t),this.listen("mouseup",t));break;case"pointerover":this.enableOverEvent!==t&&(this.enableOverEvent=t,this.listen("mouseover",t));break;case"pointerout":this.enableOutEvent!==t&&(this.enableOutEvent=t,this.listen("mouseout",t));break;case"pointerenter":this.enableEnterEvent!==t&&(this.enableEnterEvent=t,this.listen("mouseenter",t));break;case"pointerleave":this.enableLeaveEvent!==t&&(this.enableLeaveEvent=t,this.listen("mouseleave",t));break;default:}}handleOverEvent(e){this.enableOverEvent&&e.type==="mouseover"&&this._emit("pointerover",e)}handleOutEvent(e){this.enableOutEvent&&e.type==="mouseout"&&this._emit("pointerout",e)}handleEnterEvent(e){this.enableEnterEvent&&e.type==="mouseenter"&&this._emit("pointerenter",e)}handleLeaveEvent(e){this.enableLeaveEvent&&e.type==="mouseleave"&&this._emit("pointerleave",e)}handleMoveEvent(e){if(this.enableMoveEvent)switch(e.type){case"mousedown":e.button>=0&&(this.pressed=!0);break;case"mousemove":e.buttons===0&&(this.pressed=!1),this.pressed||this._emit("pointermove",e);break;case"mouseup":this.pressed=!1;break;default:}}_emit(e,t){this.callback({type:e,center:{x:t.clientX,y:t.clientY},srcEvent:t,pointerType:"mouse",target:t.target})}};var zS=["keydown","keyup"],bf=class extends Wn{constructor(e,t,i){super(e,t,{enable:!0,tabIndex:0,...i}),this.handleEvent=s=>{let o=s.target||s.srcElement;o.tagName==="INPUT"&&o.type==="text"||o.tagName==="TEXTAREA"||(this.enableDownEvent&&s.type==="keydown"&&this.callback({type:"keydown",srcEvent:s,key:s.key,target:s.target}),this.enableUpEvent&&s.type==="keyup"&&this.callback({type:"keyup",srcEvent:s,key:s.key,target:s.target}))};let{enable:r=!1}=this.options;this.enableDownEvent=r,this.enableUpEvent=r,e.tabIndex=this.options.tabIndex,e.style.outline="none",r&&zS.forEach(s=>this.listen(s,!0))}destroy(){zS.forEach(e=>this.listen(e,!1))}enableEventType(e,t){e==="keydown"&&this.enableDownEvent!==t&&(this.enableDownEvent=t,this.listen(e,t)),e==="keyup"&&this.enableUpEvent!==t&&(this.enableUpEvent=t,this.listen(e,t))}};var vf=class extends Wn{constructor(e,t,i){i.enable=i.enable??!1,super(e,t,i),this.handleEvent=r=>{this.options.enable&&this.callback({type:"contextmenu",center:{x:r.clientX,y:r.clientY},srcEvent:r,pointerType:"mouse",target:r.target})},i.enable&&this.listen("contextmenu",!0)}destroy(){this.listen("contextmenu",!1)}enableEventType(e,t){e==="contextmenu"&&this.options.enable!==t&&(this.options.enable=t,this.listen("contextmenu",t))}};var aN={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},cN=0,lN=1,uN=2,fN=1,dN=2,hN=4;function US(n){let e=aN[n.srcEvent.type];if(!e)return null;let{buttons:t,button:i}=n.srcEvent,r=!1,s=!1,o=!1;return e===2?(r=!!(t&fN),s=!!(t&hN),o=!!(t&dN)):(r=i===cN,s=i===lN,o=i===uN),{leftButton:r,middleButton:s,rightButton:o}}function $S(n,e){let t=n.center;if(!t)return null;let i=e.getBoundingClientRect(),r=i.width/e.offsetWidth||1,s=i.height/e.offsetHeight||1,o={x:(t.x-i.left-e.clientLeft)/r,y:(t.y-i.top-e.clientTop)/s};return{center:t,offsetCenter:o}}var pN={srcElement:"root",priority:0},xf=class{constructor(e,t){this.handleEvent=i=>{if(this.isEmpty())return;let r=this._normalizeEvent(i),s=i.srcEvent.target;for(;s&&s!==r.rootElement;){if(this._emit(r,s),r.handled)return;s=s.parentNode}this._emit(r,"root")},this.eventManager=e,this.recognizerName=t,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(e,t,i,r=!1,s=!1){let{handlers:o,handlersByElement:a}=this,c={...pN,...i},l=a.get(c.srcElement);l||(l=[],a.set(c.srcElement,l));let u={type:e,handler:t,srcElement:c.srcElement,priority:c.priority};r&&(u.once=!0),s&&(u.passive=!0),o.push(u),this._active=this._active||!u.passive;let f=l.length-1;for(;f>=0&&!(l[f].priority>=u.priority);)f--;l.splice(f+1,0,u)}remove(e,t){let{handlers:i,handlersByElement:r}=this;for(let s=i.length-1;s>=0;s--){let o=i[s];if(o.type===e&&o.handler===t){i.splice(s,1);let a=r.get(o.srcElement);a.splice(a.indexOf(o),1),a.length===0&&r.delete(o.srcElement)}}this._active=i.some(s=>!s.passive)}_emit(e,t){let i=this.handlersByElement.get(t);if(i){let r=!1,s=()=>{e.handled=!0},o=()=>{e.handled=!0,r=!0},a=[];for(let c=0;c{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:t}}};function mN(n){if("recognizer"in n)return n;let e,t=Array.isArray(n)?[...n]:[n];if(typeof t[0]=="function"){let i=t.shift(),r=t.shift()||{};e=new i(r)}else e=t.shift();return{recognizer:e,recognizeWith:typeof t[0]=="string"?[t[0]]:t[0],requireFailure:typeof t[1]=="string"?[t[1]]:t[1]}}var sc=class{constructor(e=null,t={}){if(this._onBasicInput=i=>{this.manager.emit(i.srcEvent.type,i)},this._onOtherEvent=i=>{this.manager.emit(i.type,i)},this.options={recognizers:[],events:{},touchAction:"compute",tabIndex:0,cssProps:{},...t},this.events=new Map,this.element=e,this.wheelSession=new _f(e),!!e){this.manager=new rc(e,this.options);for(let i of this.options.recognizers){let{recognizer:r,recognizeWith:s,requireFailure:o}=mN(i);this.manager.add(r),s&&r.recognizeWith(s),o&&r.requireFailure(o)}this.manager.on("hammer.input",this._onBasicInput),this.wheelInput=new gf(e,this._onOtherEvent,{enable:!1,wheelSession:this.wheelSession}),this.moveInput=new yf(e,this._onOtherEvent,{enable:!1}),this.keyInput=new bf(e,this._onOtherEvent,{enable:!1,tabIndex:t.tabIndex}),this.contextmenuInput=new vf(e,this._onOtherEvent,{enable:!1}),this.on(this.options.events)}}getElement(){return this.element}destroy(){if(!this.element){this.wheelSession.destroy();return}this.wheelInput.destroy(),this.wheelSession.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy()}on(e,t,i){this._addEventHandler(e,t,i,!1)}once(e,t,i){this._addEventHandler(e,t,i,!0)}watch(e,t,i){this._addEventHandler(e,t,i,!1,!0)}off(e,t){this._removeEventHandler(e,t)}emit(e){this.manager?.emit(e.type,e)}_toggleRecognizer(e,t){let{manager:i}=this;if(!i)return;let r=i.get(e);r&&(r.set({enable:t,wheelSession:this.wheelSession}),i.touchAction.update()),this.wheelInput?.enableEventType(e,t),this.moveInput?.enableEventType(e,t),this.keyInput?.enableEventType(e,t),this.contextmenuInput?.enableEventType(e,t)}_addEventHandler(e,t,i,r,s){if(typeof e!="string"){i=t;for(let[l,u]of Object.entries(e))this._addEventHandler(l,u,i,r,s);return}let{manager:o,events:a}=this;if(!o)return;let c=a.get(e);if(!c){let l=this._getRecognizerName(e)||e;c=new xf(this,l),a.set(e,c),o&&o.on(e,c.handleEvent)}c.add(e,t,i,r,s),c.isEmpty()||this._toggleRecognizer(c.recognizerName,!0)}_removeEventHandler(e,t){if(typeof e!="string"){for(let[s,o]of Object.entries(e))this._removeEventHandler(s,o);return}let{events:i}=this,r=i.get(e);if(r&&(r.remove(e,t),r.isEmpty())){let{recognizerName:s}=r,o=!1;for(let a of i.values())if(a.recognizerName===s&&!a.isEmpty()){o=!0;break}o||this._toggleRecognizer(s,!1)}}_getRecognizerName(e){return this.manager.recognizers.find(t=>t.getEventNames().includes(e))?.options.event}};var m_={DEFAULT:"default",LNGLAT:"lnglat",METER_OFFSETS:"meter-offsets",LNGLAT_OFFSETS:"lnglat-offsets",CARTESIAN:"cartesian"};Object.defineProperty(m_,"IDENTITY",{get:()=>(ae.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),m_.CARTESIAN)});var qe={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},Jt={common:0,meters:1,pixels:2},ao={click:"onClick",dblclick:"onClick",panstart:"onDragStart",panmove:"onDrag",panend:"onDragEnd"},g_={multipan:[Xi,{threshold:10,pointers:2,trackpad:!0}],pinch:[oo,{trackpad:!0},null,["multipan"]],pan:[Xi,{threshold:1},["pinch"],["multipan"]],dblclick:[qr,{event:"dblclick",taps:2,enable:!1}],dblclickdrag:[ro,{event:"dblclickdrag",enable:!1},["dblclick"],null],click:[qr,{event:"click"},["dblclickdrag"],["dblclick","dblclickdrag"]]};function gN(n,e){if(n===e)return!0;if(Array.isArray(n)){let t=n.length;if(!e||e.length!==t)return!1;for(let i=0;i{for(let r in i)if(!gN(i[r],e[r])){t=n(i),e=i;break}return t}}var GS=[0,0,0,0],_N=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],VS=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],yN=[0,0,0],WS=[0,0,0],bN={default:-1,cartesian:0,lnglat:1,"meter-offsets":2,"lnglat-offsets":3};function Zr(n){let e=bN[n];if(e===void 0)throw new Error(`Invalid coordinateSystem: ${n}`);return e}var vN=jn(wN);function __(n,e,t=WS){t.length<3&&(t=[t[0],t[1],0]);let i=t,r,s=!0;switch(e==="lnglat-offsets"||e==="meter-offsets"?r=t:r=n.isGeospatial?[Math.fround(n.longitude),Math.fround(n.latitude),0]:null,n.projectionMode){case qe.WEB_MERCATOR:(e==="lnglat"||e==="cartesian")&&(r=[0,0,0],s=!1);break;case qe.WEB_MERCATOR_AUTO_OFFSET:e==="lnglat"?i=r:e==="cartesian"&&(i=[Math.fround(n.center[0]),Math.fround(n.center[1]),0],r=n.unprojectPosition(i),i[0]-=t[0],i[1]-=t[1],i[2]-=t[2]);break;case qe.IDENTITY:i=n.position.map(Math.fround),i[2]=i[2]||0;break;case qe.GLOBE:s=!1,r=null;break;default:s=!1}return{geospatialOrigin:r,shaderCoordinateOrigin:i,offsetMode:s}}function xN(n,e,t){let{viewMatrixUncentered:i,projectionMatrix:r}=n,{viewMatrix:s,viewProjectionMatrix:o}=n,a=GS,c=GS,l=n.cameraPosition,{geospatialOrigin:u,shaderCoordinateOrigin:f,offsetMode:d}=__(n,e,t);return d&&(c=n.projectPosition(u||f),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,a=Rt.transformMat4([],c,o),s=i||s,o=Ve.multiply([],r,s),o=Ve.multiply([],o,_N)),{viewMatrix:s,viewProjectionMatrix:o,projectionCenter:a,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:f,geospatialOrigin:u}}function jS({viewport:n,devicePixelRatio:e=1,modelMatrix:t=null,coordinateSystem:i="default",coordinateOrigin:r=WS,autoWrapLongitude:s=!1}){i==="default"&&(i=n.isGeospatial?"lnglat":"cartesian");let o=vN({viewport:n,devicePixelRatio:e,coordinateSystem:i,coordinateOrigin:r});return o.wrapLongitude=s,o.modelMatrix=t||VS,o}function wN({viewport:n,devicePixelRatio:e,coordinateSystem:t,coordinateOrigin:i}){let{projectionCenter:r,viewProjectionMatrix:s,originCommon:o,cameraPosCommon:a,shaderCoordinateOrigin:c,geospatialOrigin:l}=xN(n,t,i),u=n.getDistanceScales(),f=[n.width*e,n.height*e],d=Rt.transformMat4([],[0,0,-n.focalDistance,1],n.projectionMatrix)[3]||1,h={coordinateSystem:Zr(t),projectionMode:n.projectionMode,coordinateOrigin:c,commonOrigin:o.slice(0,3),center:r,pseudoMeters:!!n._pseudoMeters,viewportSize:f,devicePixelRatio:e,focalDistance:d,commonUnitsPerMeter:u.unitsPerMeter,commonUnitsPerWorldUnit:u.unitsPerMeter,commonUnitsPerWorldUnit2:yN,scale:n.scale,wrapLongitude:!1,viewProjectionMatrix:s,modelMatrix:VS,cameraPosition:a};if(l){let p=n.getDistanceScales(l);switch(t){case"meter-offsets":h.commonUnitsPerWorldUnit=p.unitsPerMeter,h.commonUnitsPerWorldUnit2=p.unitsPerMeter2;break;case"lnglat":case"lnglat-offsets":n._pseudoMeters||(h.commonUnitsPerMeter=p.unitsPerMeter),h.commonUnitsPerWorldUnit=p.unitsPerDegree,h.commonUnitsPerWorldUnit2=p.unitsPerDegree2;break;case"cartesian":h.commonUnitsPerWorldUnit=[1,1,p.unitsPerMeter[2]],h.commonUnitsPerWorldUnit2=[0,0,p.unitsPerMeter2[2]];break;default:break}}if(n.projectionMode===qe.GLOBE&&t==="meter-offsets"){let g=i[0]*Math.PI/180,v=i[1]*Math.PI/180,y=Math.cos(v),b=((i[2]||0)/6370972+1)*256;h.commonOrigin=[Math.sin(g)*y*b,-Math.cos(g)*y*b,Math.sin(v)*b]}return h}var EN=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],SN=EN.map(n=>`const COORDINATE_SYSTEM_${n.toUpperCase().replaceAll("-","_")}: i32 = ${Zr(n)};`).join(""),PN=Object.keys(qe).map(n=>`const PROJECTION_MODE_${n}: i32 = ${qe[n]};`).join(""),CN=Object.keys(Jt).map(n=>`const UNIT_${n.toUpperCase()}: i32 = ${Jt[n]};`).join(""),TN=`${SN} +${PN} +${CN} const TILE_SIZE: f32 = 512.0; const PI: f32 = 3.1415926536; @@ -3407,7 +3407,7 @@ struct Geometry { }; var geometry: Geometry; -`,jS=`${SN} +`,HS=`${TN} // ----------------------------------------------------------------------------- // Functions @@ -3643,9 +3643,9 @@ fn project_pixel_size_float(pixels: f32) -> f32 { fn project_pixel_size_vec2(pixels: vec2) -> vec2 { return pixels / project.scale; } -`;var PN=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],CN=PN.map(n=>`const int COORDINATE_SYSTEM_${n.toUpperCase().replaceAll("-","_")} = ${Zr(n)};`).join(""),TN=Object.keys(qe).map(n=>`const int PROJECTION_MODE_${n} = ${qe[n]};`).join(""),LN=Object.keys(Zt).map(n=>`const int UNIT_${n.toUpperCase()} = ${Zt[n]};`).join(""),HS=`${CN} -${TN} -${LN} +`;var LN=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],MN=LN.map(n=>`const int COORDINATE_SYSTEM_${n.toUpperCase().replaceAll("-","_")} = ${Zr(n)};`).join(""),AN=Object.keys(qe).map(n=>`const int PROJECTION_MODE_${n} = ${qe[n]};`).join(""),kN=Object.keys(Jt).map(n=>`const int UNIT_${n.toUpperCase()} = ${Jt[n]};`).join(""),YS=`${MN} +${AN} +${kN} layout(std140) uniform projectUniforms { bool wrapLongitude; int coordinateSystem; @@ -3843,7 +3843,7 @@ return pixels / project.scale; vec2 project_pixel_size(vec2 pixels) { return pixels / project.scale; } -`;var MN={};function AN(n=MN){return"viewport"in n?WS(n):{}}var un={name:"project",dependencies:[Vr,uf],source:jS,vs:HS,getUniforms:AN,uniformTypes:{wrapLongitude:"f32",coordinateSystem:"i32",commonUnitsPerMeter:"vec3",projectionMode:"i32",scale:"f32",commonUnitsPerWorldUnit:"vec3",commonUnitsPerWorldUnit2:"vec3",center:"vec4",modelMatrix:"mat4x4",viewProjectionMatrix:"mat4x4",viewportSize:"vec2",devicePixelRatio:"f32",focalDistance:"f32",cameraPosition:"vec3",coordinateOrigin:"vec3",commonOrigin:"vec3",pseudoMeters:"f32"}};var kN=`// Define a structure to hold both the clip-space position and the common position. +`;var RN={};function IN(n=RN){return"viewport"in n?jS(n):{}}var hn={name:"project",dependencies:[Vr,ff],source:HS,vs:YS,getUniforms:IN,uniformTypes:{wrapLongitude:"f32",coordinateSystem:"i32",commonUnitsPerMeter:"vec3",projectionMode:"i32",scale:"f32",commonUnitsPerWorldUnit:"vec3",commonUnitsPerWorldUnit2:"vec3",center:"vec4",modelMatrix:"mat4x4",viewProjectionMatrix:"mat4x4",viewportSize:"vec2",devicePixelRatio:"f32",focalDistance:"f32",cameraPosition:"vec3",coordinateOrigin:"vec3",commonOrigin:"vec3",pseudoMeters:"f32"}};var BN=`// Define a structure to hold both the clip-space position and the common position. struct ProjectResult { clipPosition: vec4, commonPosition: vec4, @@ -3886,7 +3886,7 @@ fn project_position_to_clipspace( ) -> vec4 { return project_position_to_clipspace_and_commonspace(position, position64Low, offset).clipPosition; } -`,RN=`vec4 project_position_to_clipspace( +`,ON=`vec4 project_position_to_clipspace( vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition ) { vec3 projectedPosition = project_position(position, position64Low); @@ -3906,7 +3906,7 @@ vec4 project_position_to_clipspace( vec4 commonPosition; return project_position_to_clipspace(position, position64Low, offset, commonPosition); } -`,Gn={name:"project32",dependencies:[un],source:kN,vs:RN};Fe();Fe();function __(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Zi(n,e){let t=At.transformMat4([],e,n);return At.scale(t,t,1/t[3]),t}function sc(n,e,t){return nt?t:n}function IN(n){return Math.log(n)*Math.LOG2E}var oc=Math.log2||IN;Fe();function fn(n,e){if(!n)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}var dn=Math.PI,YS=dn/4,Xt=dn/180,y_=180/dn,co=512,xf=4003e4,lo=85.051129,qS=1.5;function b_(n){return oc(n)}function ht(n){let[e,t]=n;fn(Number.isFinite(e)),fn(Number.isFinite(t)&&t>=-90&&t<=90,"invalid latitude");let i=e*Xt,r=t*Xt,s=co*(i+dn)/(2*dn),o=co*(dn+Math.log(Math.tan(YS+r*.5)))/(2*dn);return[s,o]}function kt(n){let[e,t]=n,i=e/co*(2*dn)-dn,r=2*(Math.atan(Math.exp(t/co*(2*dn)-dn))-YS);return[i*y_,r*y_]}function v_(n){let{latitude:e}=n;fn(Number.isFinite(e));let t=Math.cos(e*Xt);return b_(xf*t)-9}function ac(n){let e=Math.cos(n*Xt);return co/xf/e}function uo(n){let{latitude:e,longitude:t,highPrecision:i=!1}=n;fn(Number.isFinite(e)&&Number.isFinite(t));let r=co,s=Math.cos(e*Xt),o=r/360,a=o/s,c=r/xf/s,l={unitsPerMeter:[c,c,c],metersPerUnit:[1/c,1/c,1/c],unitsPerDegree:[o,a,c],degreesPerUnit:[1/o,1/a,1/c]};if(i){let u=Xt*Math.tan(e*Xt)/s,f=o*u/2,d=r/xf*u,h=d/a*c;l.unitsPerDegree2=[0,f,d],l.unitsPerMeter2=[h,0,h]}return l}function cc(n,e){let[t,i,r]=n,[s,o,a]=e,{unitsPerMeter:c,unitsPerMeter2:l}=uo({longitude:t,latitude:i,highPrecision:!0}),u=ht(n);u[0]+=s*(c[0]+l[0]*o),u[1]+=o*(c[1]+l[1]*o);let f=kt(u),d=(r||0)+(a||0);return Number.isFinite(r)||Number.isFinite(a)?[f[0],f[1],d]:f}function wf(n){let{height:e,pitch:t,bearing:i,altitude:r,scale:s,center:o}=n,a=__();We.translate(a,a,[0,0,-r]),We.rotateX(a,a,-t*Xt),We.rotateZ(a,a,i*Xt);let c=s/e;return We.scale(a,a,[c,c,c]),o&&We.translate(a,a,yt.negate([],o)),a}function x_(n){let{width:e,height:t,altitude:i,pitch:r=0,offset:s,center:o,scale:a,nearZMultiplier:c=1,farZMultiplier:l=1}=n,{fovy:u=Xr(qS)}=n;i!==void 0&&(u=Xr(i));let f=u*Xt,d=r*Xt,h=lc(u),p=h;o&&(p+=o[2]*a/Math.cos(d)/t);let m=f*(.5+(s?s[1]:0)/t),g=Math.sin(m)*p/Math.sin(sc(Math.PI/2-d-m,.01,Math.PI-.01)),v=Math.sin(d)*g+p,y=p*10,b=Math.min(v*l,y);return{fov:f,aspect:e/t,focalDistance:h,near:c,far:b}}function Xr(n){return 2*Math.atan(.5/n)*y_}function lc(n){return .5/Math.tan(.5*n*Xt)}function Xi(n,e){let[t,i,r=0]=n;return fn(Number.isFinite(t)&&Number.isFinite(i)&&Number.isFinite(r)),Zi(e,[t,i,r,1])}function Vn(n,e,t=0){let[i,r,s]=n;if(fn(Number.isFinite(i)&&Number.isFinite(r),"invalid pixel coordinate"),Number.isFinite(s))return Zi(e,[i,r,s,1]);let o=Zi(e,[i,r,0,1]),a=Zi(e,[i,r,1,1]),c=o[2],l=a[2],u=c===l?0:((t||0)-c)/(l-c);return dt.lerp([],o,a,u)}function Ef(n){let{width:e,height:t,bounds:i,minExtent:r=0,maxZoom:s=24,offset:o=[0,0]}=n,[[a,c],[l,u]]=i,f=BN(n.padding),d=ht([a,sc(u,-lo,lo)]),h=ht([l,sc(c,-lo,lo)]),p=[Math.max(Math.abs(h[0]-d[0]),r),Math.max(Math.abs(h[1]-d[1]),r)],m=[e-f.left-f.right-Math.abs(o[0])*2,t-f.top-f.bottom-Math.abs(o[1])*2];fn(m[0]>0&&m[1]>0);let g=m[0]/p[0],v=m[1]/p[1],y=(f.right-f.left)/2/g,b=(f.top-f.bottom)/2/v,w=[(h[0]+d[0])/2+y,(h[1]+d[1])/2+b],E=kt(w),x=Math.min(s,oc(Math.abs(Math.min(g,v))));return fn(Number.isFinite(x)),{longitude:E[0],latitude:E[1],zoom:x}}function BN(n=0){return typeof n=="number"?{top:n,bottom:n,left:n,right:n}:(fn(Number.isFinite(n.top)&&Number.isFinite(n.bottom)&&Number.isFinite(n.left)&&Number.isFinite(n.right)),n)}Fe();var ZS=Math.PI/180;function Sf(n,e=0){let{width:t,height:i,unproject:r}=n,s={targetZ:e},o=r([0,i],s),a=r([t,i],s),c,l,u=n.fovy?.5*n.fovy*ZS:Math.atan(.5/n.altitude),f=(90-n.pitch)*ZS;return u>f-.01?(c=XS(n,0,e),l=XS(n,t,e)):(c=r([0,0],s),l=r([t,0],s)),[o,a,l,c]}function XS(n,e,t){let{pixelUnprojectionMatrix:i}=n,r=Zi(i,[e,0,1,1]),s=Zi(i,[e,n.height,1,1]),a=(t*n.distanceScales.unitsPerMeter[2]-r[2])/(s[2]-r[2]),c=dt.lerp([],r,s,a),l=kt(c);return l.push(t),l}var QS=` +`,Hn={name:"project32",dependencies:[hn],source:BN,vs:ON};ze();ze();function y_(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Ki(n,e){let t=Rt.transformMat4([],e,n);return Rt.scale(t,t,1/t[3]),t}function oc(n,e,t){return nt?t:n}function DN(n){return Math.log(n)*Math.LOG2E}var ac=Math.log2||DN;ze();function pn(n,e){if(!n)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}var mn=Math.PI,qS=mn/4,en=mn/180,b_=180/mn,co=512,wf=4003e4,lo=85.051129,ZS=1.5;function v_(n){return ac(n)}function ht(n){let[e,t]=n;pn(Number.isFinite(e)),pn(Number.isFinite(t)&&t>=-90&&t<=90,"invalid latitude");let i=e*en,r=t*en,s=co*(i+mn)/(2*mn),o=co*(mn+Math.log(Math.tan(qS+r*.5)))/(2*mn);return[s,o]}function It(n){let[e,t]=n,i=e/co*(2*mn)-mn,r=2*(Math.atan(Math.exp(t/co*(2*mn)-mn))-qS);return[i*b_,r*b_]}function x_(n){let{latitude:e}=n;pn(Number.isFinite(e));let t=Math.cos(e*en);return v_(wf*t)-9}function cc(n){let e=Math.cos(n*en);return co/wf/e}function uo(n){let{latitude:e,longitude:t,highPrecision:i=!1}=n;pn(Number.isFinite(e)&&Number.isFinite(t));let r=co,s=Math.cos(e*en),o=r/360,a=o/s,c=r/wf/s,l={unitsPerMeter:[c,c,c],metersPerUnit:[1/c,1/c,1/c],unitsPerDegree:[o,a,c],degreesPerUnit:[1/o,1/a,1/c]};if(i){let u=en*Math.tan(e*en)/s,f=o*u/2,d=r/wf*u,h=d/a*c;l.unitsPerDegree2=[0,f,d],l.unitsPerMeter2=[h,0,h]}return l}function lc(n,e){let[t,i,r]=n,[s,o,a]=e,{unitsPerMeter:c,unitsPerMeter2:l}=uo({longitude:t,latitude:i,highPrecision:!0}),u=ht(n);u[0]+=s*(c[0]+l[0]*o),u[1]+=o*(c[1]+l[1]*o);let f=It(u),d=(r||0)+(a||0);return Number.isFinite(r)||Number.isFinite(a)?[f[0],f[1],d]:f}function Ef(n){let{height:e,pitch:t,bearing:i,altitude:r,scale:s,center:o}=n,a=y_();Ve.translate(a,a,[0,0,-r]),Ve.rotateX(a,a,-t*en),Ve.rotateZ(a,a,i*en);let c=s/e;return Ve.scale(a,a,[c,c,c]),o&&Ve.translate(a,a,bt.negate([],o)),a}function w_(n){let{width:e,height:t,altitude:i,pitch:r=0,offset:s,center:o,scale:a,nearZMultiplier:c=1,farZMultiplier:l=1}=n,{fovy:u=Xr(ZS)}=n;i!==void 0&&(u=Xr(i));let f=u*en,d=r*en,h=uc(u),p=h;o&&(p+=o[2]*a/Math.cos(d)/t);let m=f*(.5+(s?s[1]:0)/t),g=Math.sin(m)*p/Math.sin(oc(Math.PI/2-d-m,.01,Math.PI-.01)),v=Math.sin(d)*g+p,y=p*10,b=Math.min(v*l,y);return{fov:f,aspect:e/t,focalDistance:h,near:c,far:b}}function Xr(n){return 2*Math.atan(.5/n)*b_}function uc(n){return .5/Math.tan(.5*n*en)}function Qi(n,e){let[t,i,r=0]=n;return pn(Number.isFinite(t)&&Number.isFinite(i)&&Number.isFinite(r)),Ki(e,[t,i,r,1])}function Yn(n,e,t=0){let[i,r,s]=n;if(pn(Number.isFinite(i)&&Number.isFinite(r),"invalid pixel coordinate"),Number.isFinite(s))return Ki(e,[i,r,s,1]);let o=Ki(e,[i,r,0,1]),a=Ki(e,[i,r,1,1]),c=o[2],l=a[2],u=c===l?0:((t||0)-c)/(l-c);return dt.lerp([],o,a,u)}function Sf(n){let{width:e,height:t,bounds:i,minExtent:r=0,maxZoom:s=24,offset:o=[0,0]}=n,[[a,c],[l,u]]=i,f=NN(n.padding),d=ht([a,oc(u,-lo,lo)]),h=ht([l,oc(c,-lo,lo)]),p=[Math.max(Math.abs(h[0]-d[0]),r),Math.max(Math.abs(h[1]-d[1]),r)],m=[e-f.left-f.right-Math.abs(o[0])*2,t-f.top-f.bottom-Math.abs(o[1])*2];pn(m[0]>0&&m[1]>0);let g=m[0]/p[0],v=m[1]/p[1],y=(f.right-f.left)/2/g,b=(f.top-f.bottom)/2/v,x=[(h[0]+d[0])/2+y,(h[1]+d[1])/2+b],E=It(x),w=Math.min(s,ac(Math.abs(Math.min(g,v))));return pn(Number.isFinite(w)),{longitude:E[0],latitude:E[1],zoom:w}}function NN(n=0){return typeof n=="number"?{top:n,bottom:n,left:n,right:n}:(pn(Number.isFinite(n.top)&&Number.isFinite(n.bottom)&&Number.isFinite(n.left)&&Number.isFinite(n.right)),n)}ze();var XS=Math.PI/180;function Pf(n,e=0){let{width:t,height:i,unproject:r}=n,s={targetZ:e},o=r([0,i],s),a=r([t,i],s),c,l,u=n.fovy?.5*n.fovy*XS:Math.atan(.5/n.altitude),f=(90-n.pitch)*XS;return u>f-.01?(c=KS(n,0,e),l=KS(n,t,e)):(c=r([0,0],s),l=r([t,0],s)),[o,a,l,c]}function KS(n,e,t){let{pixelUnprojectionMatrix:i}=n,r=Ki(i,[e,0,1,1]),s=Ki(i,[e,n.height,1,1]),a=(t*n.distanceScales.unitsPerMeter[2]-r[2])/(s[2]-r[2]),c=dt.lerp([],r,s,a),l=It(c);return l.push(t),l}var JS=` layout(std140) uniform shadowUniforms { bool drawShadowMap; bool useShadowMap; @@ -3918,7 +3918,7 @@ layout(std140) uniform shadowUniforms { vec4 projectCenter0; vec4 projectCenter1; } shadow; -`,NN=` +`,UN=` const int max_lights = 2; out vec3 shadow_vPosition[max_lights]; @@ -3944,10 +3944,10 @@ vec4 shadow_setVertexPosition(vec4 position_commonspace) { } return gl_Position; } -`,FN=` -${QS} -${NN} -`,zN=` +`,$N=` +${JS} +${UN} +`,GN=` const int max_lights = 2; uniform sampler2D shadow_uShadowMap0; uniform sampler2D shadow_uShadowMap1; @@ -3987,25 +3987,25 @@ vec4 shadow_filterShadowColor(vec4 color) { } return color; } -`,UN=` -${QS} -${zN} -`,$N=$n(HN),GN=$n(YN),VN=[0,0,0,1],WN=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];function jN(n,e){let[t,i,r]=n,s=Vn([t,i,r],e);return Number.isFinite(r)?s:[s[0],s[1],0]}function HN({viewport:n,center:e}){return new Ne(n.viewProjectionMatrix).invert().transform(e)}function YN({viewport:n,shadowMatrices:e}){let t=[],i=n.pixelUnprojectionMatrix,r=n.isGeospatial?void 0:1,s=[[0,0,r],[n.width,0,r],[0,n.height,r],[n.width,n.height,r],[0,0,-1],[n.width,0,-1],[0,n.height,-1],[n.width,n.height,-1]].map(o=>jN(o,i));for(let o of e){let a=o.clone().translate(new tt(n.center).negate()),c=s.map(u=>a.transform(u)),l=new Ne().ortho({left:Math.min(...c.map(u=>u[0])),right:Math.max(...c.map(u=>u[0])),bottom:Math.min(...c.map(u=>u[1])),top:Math.max(...c.map(u=>u[1])),near:Math.min(...c.map(u=>-u[2])),far:Math.max(...c.map(u=>-u[2]))});t.push(l.multiplyRight(o))}return t}function qN(n){let{shadowEnabled:e=!0,project:t}=n;if(!e||!t||!n.shadowMatrices||!n.shadowMatrices.length)return{drawShadowMap:!1,useShadowMap:!1,shadow_uShadowMap0:n.dummyShadowMap,shadow_uShadowMap1:n.dummyShadowMap};let i=un.getUniforms(t),r=$N({viewport:t.viewport,center:i.center}),s=[],o=GN({shadowMatrices:n.shadowMatrices,viewport:t.viewport}).slice();for(let c=0;c0:!1,color:n.shadowColor||VN,lightId:n.shadowLightId||0,lightCount:n.shadowMatrices.length,shadow_uShadowMap0:n.dummyShadowMap,shadow_uShadowMap1:n.dummyShadowMap};for(let c=0;cqN(o,i));for(let o of e){let a=o.clone().translate(new et(n.center).negate()),c=s.map(u=>a.transform(u)),l=new Fe().ortho({left:Math.min(...c.map(u=>u[0])),right:Math.max(...c.map(u=>u[0])),bottom:Math.min(...c.map(u=>u[1])),top:Math.max(...c.map(u=>u[1])),near:Math.min(...c.map(u=>-u[2])),far:Math.max(...c.map(u=>-u[2]))});t.push(l.multiplyRight(o))}return t}function KN(n){let{shadowEnabled:e=!0,project:t}=n;if(!e||!t||!n.shadowMatrices||!n.shadowMatrices.length)return{drawShadowMap:!1,useShadowMap:!1,shadow_uShadowMap0:n.dummyShadowMap,shadow_uShadowMap1:n.dummyShadowMap};let i=hn.getUniforms(t),r=WN({viewport:t.viewport,center:i.center}),s=[],o=jN({shadowMatrices:n.shadowMatrices,viewport:t.viewport}).slice();for(let c=0;c0:!1,color:n.shadowColor||HN,lightId:n.shadowLightId||0,lightCount:n.shadowMatrices.length,shadow_uShadowMap0:n.dummyShadowMap,shadow_uShadowMap1:n.dummyShadowMap};for(let c=0;c",lightId:"i32",lightCount:"f32",viewProjectionMatrix0:"mat4x4",viewProjectionMatrix1:"mat4x4",projectCenter0:"vec4",projectCenter1:"vec4"}};bt();var Cf=10,uc=16777215;function e1(n,e){n.length===Cf?ae.warn(`pickMultipleObjects can only exclude ${Cf} previously picked objects for layers without picking buffers`)():n.push(e)}var ZN=` float disabledPickingIndexCount; + `},getUniforms:KN,uniformTypes:{drawShadowMap:"f32",useShadowMap:"f32",color:"vec4",lightId:"i32",lightCount:"f32",viewProjectionMatrix0:"mat4x4",viewProjectionMatrix1:"mat4x4",projectCenter0:"vec4",projectCenter1:"vec4"}};vt();var Tf=10,fc=16777215;function t1(n,e){n.length===Tf?ae.warn(`pickMultipleObjects can only exclude ${Tf} previously picked objects for layers without picking buffers`)():n.push(e)}var QN=` float disabledPickingIndexCount; vec4 disabledPickingIndices0; vec4 disabledPickingIndices1; vec4 disabledPickingIndices2; -`;function JS(n){return n.replace(` vec4 highlightColor; +`;function e1(n){return n.replace(` vec4 highlightColor; } picking;`,` vec4 highlightColor; -${ZN}} picking;`)}function w_(n,e){return[n[e]||0,n[e+1]||0,n[e+2]||0,n[e+3]||0]}var XN=`vec3 picking_getPickingColorFromIndex(float objectIndex) { - if (objectIndex < 0.0 || objectIndex >= ${uc}.0) { +${QN}} picking;`)}function E_(n,e){return[n[e]||0,n[e+1]||0,n[e+2]||0,n[e+3]||0]}var JN=`vec3 picking_getPickingColorFromIndex(float objectIndex) { + if (objectIndex < 0.0 || objectIndex >= ${fc}.0) { return vec3(0.0); } - for (int i = 0; i < ${Cf}; i++) { + for (int i = 0; i < ${Tf}; i++) { if (float(i) >= picking.disabledPickingIndexCount) { break; } @@ -4037,7 +4037,7 @@ vec3 picking_getPickingColorFromInstanceID() { void picking_setPickingColorFromInstanceID() { picking_setPickingColor(picking_getPickingColorFromInstanceID()); } -`,KN=`struct pickingUniforms { +`,eF=`struct pickingUniforms { isActive: f32, isAttribute: f32, isHighlightActive: f32, @@ -4069,11 +4069,11 @@ fn picking_isColorValid(color: vec3) -> bool { } fn picking_getPickingColorFromIndex(objectIndex: u32) -> vec3 { - if (objectIndex >= ${uc}u) { + if (objectIndex >= ${fc}u) { return vec3(0.0); } - for (var i = 0; i < ${Cf}; i = i + 1) { + for (var i = 0; i < ${Tf}; i = i + 1) { if (f32(i) >= picking.disabledPickingIndexCount) { break; } @@ -4095,8 +4095,8 @@ fn picking_getPickingColorFromIndex(objectIndex: u32) -> vec3 { f32((encodedIndex / 65536u) % 256u) ) / 255.0; } -`,Wn={...Yi,vs:`${JS(Yi.vs)} -${XN}`,fs:JS(Yi.fs),source:KN,uniformTypes:{...Yi.uniformTypes,disabledPickingIndexCount:"f32",disabledPickingIndices0:"vec4",disabledPickingIndices1:"vec4",disabledPickingIndices2:"vec4"},defaultUniforms:{...Yi.defaultUniforms,useByteColors:!0,disabledPickingIndexCount:0,disabledPickingIndices0:[0,0,0,0],disabledPickingIndices1:[0,0,0,0],disabledPickingIndices2:[0,0,0,0]},getUniforms(n,e){let t=Yi.getUniforms(n,e),i=n.disabledPickingIndices||[];return t.disabledPickingIndexCount=i.length,t.disabledPickingIndices0=w_(i,0),t.disabledPickingIndices1=w_(i,4),t.disabledPickingIndices2=w_(i,8),t},inject:{"vs:DECKGL_FILTER_GL_POSITION":` +`,qn={...Zi,vs:`${e1(Zi.vs)} +${JN}`,fs:e1(Zi.fs),source:eF,uniformTypes:{...Zi.uniformTypes,disabledPickingIndexCount:"f32",disabledPickingIndices0:"vec4",disabledPickingIndices1:"vec4",disabledPickingIndices2:"vec4"},defaultUniforms:{...Zi.defaultUniforms,useByteColors:!0,disabledPickingIndexCount:0,disabledPickingIndices0:[0,0,0,0],disabledPickingIndices1:[0,0,0,0],disabledPickingIndices2:[0,0,0,0]},getUniforms(n,e){let t=Zi.getUniforms(n,e),i=n.disabledPickingIndices||[];return t.disabledPickingIndexCount=i.length,t.disabledPickingIndices0=E_(i,0),t.disabledPickingIndices1=E_(i,4),t.disabledPickingIndices2=E_(i,8),t},inject:{"vs:DECKGL_FILTER_GL_POSITION":` // for picking depth values picking_setPickingAttribute(position.z / position.w); `,"vs:DECKGL_FILTER_COLOR":` @@ -4107,10 +4107,10 @@ ${XN}`,fs:JS(Yi.fs),source:KN,uniformTypes:{...Yi.uniformTypes,disabledPickingIn // use picking color if rendering to picking FBO. color = picking_filterPickingColor(color); - `}}};var JN=[uf],eF=["vs:DECKGL_FILTER_SIZE(inout vec3 size, VertexGeometry geometry)","vs:DECKGL_FILTER_GL_POSITION(inout vec4 position, VertexGeometry geometry)","vs:DECKGL_FILTER_COLOR(inout vec4 color, VertexGeometry geometry)","fs:DECKGL_FILTER_COLOR(inout vec4 color, FragmentGeometry geometry)"],tF=[];function t1(n){let e=Yt.getDefaultShaderAssembler(n);for(let i of JN)e.addDefaultModule(i);e._hookFunctions.length=0;let t=n==="glsl"?eF:tF;for(let i of t)e.addShaderHook(i);return e}var nF=[255,255,255],iF=1,rF=0,Tf=class{constructor(e={}){this.type="ambient";let{color:t=nF}=e,{intensity:i=iF}=e;this.id=e.id||`ambient-${rF++}`,this.color=t,this.intensity=i}};Fe();var sF=[255,255,255],oF=1,aF=[0,0,-1],cF=0,fc=class{constructor(e={}){this.type="directional";let{color:t=sF}=e,{intensity:i=oF}=e,{direction:r=aF}=e,{_shadow:s=!1}=e;this.id=e.id||`directional-${cF++}`,this.color=t,this.intensity=i,this.type="directional",this.direction=new tt(r).normalize().toArray(),this.shadow=s}getProjectedLight(e){return this}};Fe();var dc=class{constructor(e,t={id:"pass"}){let{id:i}=t;this.id=i,this.device=e,this.props={...t}}setProps(e){Object.assign(this.props,e)}render(e){}cleanup(){}};var lF={depthWriteEnabled:!0,depthCompare:"less-equal",blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one-minus-src-alpha",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha"},_i=class extends dc{constructor(){super(...arguments),this._lastRenderIndex=-1}render(e){this._render(e)}_render(e){let{canvasContext:t=this.device.canvasContext}=e,i=e.target??t.getCurrentFramebuffer(),[r,s]=t.getDrawingBufferSize(),o=e.clearCanvas??!0,a=e.clearColor??(o?[0,0,0,0]:!1),c=o?1:!1,l=o?0:!1,u=e.colorMask??15,f={viewport:[0,0,r,s]};e.colorMask&&(f.colorMask=u),e.scissorRect&&(f.scissorRect=e.scissorRect);let{shaderModuleProps:d,viewports:h,views:p,onViewportActive:m,clearStack:g=!0}=e,v=e.pass||"unknown",y=this.device.type==="webgpu";g&&(this._lastRenderIndex=-1);let b=[];if(!h.length)return this.device.beginRenderPass({framebuffer:i,parameters:f,clearColor:a,clearDepth:c,clearStencil:l}).end(),this.device.submit(),b;try{for(let w of h){m?.(w);let E=this._getDrawLayerParams(w,e),x=p&&p[w.id],T=w.subViewports||[w],I=y?T.map(N=>[N]):[T];for(let N of I){let D=this.device.beginRenderPass({framebuffer:i,parameters:f,clearColor:a,clearDepth:c,clearStencil:l});try{for(let H of N){let W=this._drawLayersInViewport(D,{target:i,canvasContext:t,shaderModuleProps:d,viewport:H,view:x,pass:v,layers:e.layers,isPicking:e.isPicking},E);b.push(W)}}finally{D.end(),y&&this.device.submit()}a=!1,c=!1,l=!1}}return b}finally{y||this.device.submit()}}_getDrawLayerParams(e,{layers:t,pass:i,isPicking:r=!1,layerFilter:s,cullRect:o,views:a,effects:c,canvasContext:l=this.device.canvasContext,shaderModuleProps:u},f=!1){let d=[],h=i1(this._lastRenderIndex+1),p={layer:t[0],viewport:e,isPicking:r,renderPass:i,cullRect:o},m={};for(let g=0;gE/255):p===!1&&(v=!1),m!==void 0&&(y=m),g!==void 0&&(b=g),this.device.beginRenderPass({framebuffer:s,parameters:{viewport:f,scissorRect:f},clearColor:v,clearDepth:y,clearStencil:b}).end()}}let d={totalCount:t.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:f});for(let h=0;h{let o=r.props._offset,a=r.id,c=r.parent&&r.parent.id,l;if(c&&!(c in e)&&i(r.parent,!1),c in t){let u=t[c]=t[c]||i1(e[c],e);l=u(r,s),t[a]=u}else Number.isFinite(o)?(l=o+(e[c]||0),t[a]=null):l=n;return s&&l>=n&&(n=l+1),e[a]=l,l};return i}function uF(n,{canvasContext:e=n.canvasContext,shaderModuleProps:t,target:i,viewport:r}){let s=t?.project?.devicePixelRatio??e.cssToDeviceRatio(),[,o]=e.getDrawingBufferSize(),a=i?i.height:o,c=r;return[c.x*s,a-(c.y+c.height)*s,c.width*s,c.height*s]}function n1(n,...e){for(let t of e)if(t)for(let i in t)n[i]?Object.assign(n[i],t[i]):n[i]=t[i];return n}var hc=class extends _i{constructor(e,t){super(e,t);let i=e.createTexture({format:"rgba8unorm",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),r=e.createTexture({format:"depth16unorm",width:1,height:1});this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[i],depthStencilAttachment:r})}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null)}getShadowMap(){return this.fbo.colorAttachments[0].texture}render(e){let t=this.fbo,i=this.device.canvasContext.cssToDeviceRatio(),r=e.viewports[0],s=r.width*i,o=r.height*i,a=[1,1,1,1];(s!==t.width||o!==t.height)&&t.resize({width:s,height:o}),super.render({...e,clearColor:a,target:t,pass:"shadow"})}getLayerParameters(e,t,i){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal"}}shouldDrawLayer(e){return e.props.shadowEnabled!==!1}getShaderModuleProps(e,t,i){return{shadow:{project:i.project,drawToShadowMap:!0}}}};var fF={color:[255,255,255],intensity:1},r1=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],dF=[0,0,0,200/255],fo=class{constructor(e={}){this.id="lighting-effect",this.shadowColor=dF,this.shadow=!1,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;let{device:t,deck:i}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(t),i._addDefaultShaderModule(Pf),this.dummyShadowMap=t.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=void 0,this.directionalLights=[],this.pointLights=[];for(let t in e){let i=e[t];switch(i.type){case"ambient":this.ambientLight=i;break;case"directional":this.directionalLights.push(i);break;case"point":this.pointLights.push(i);break;default:}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(t=>t.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:t,viewports:i,onViewportActive:r,views:s}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let o=0;oo.getShadowMap()),dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{},r={enabled:!0,lights:this._getLights(e)},s=e.props.material;return{shadow:i,lighting:r,phongMaterial:s,gouraudMaterial:s}}cleanup(e){for(let t of this.shadowPasses)t.delete();this.shadowPasses.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(Pf))}_calculateMatrices(){let e=[];for(let t of this.directionalLights){let i=new Ne().lookAt({eye:new tt(t.direction).negate()});e.push(i)}return e}_createShadowPasses(e){for(let t=0;tr&&(s=r);let o=this._pool,a=e.BYTES_PER_ELEMENT*s,c=o.findIndex(l=>l.byteLength>=a);if(c>=0){let l=new e(o.splice(c,1)[0],0,s);return i&&l.fill(0),l}return new e(s)}_release(e){if(!ArrayBuffer.isView(e))return;let t=this._pool,{buffer:i}=e,{byteLength:r}=i,s=t.findIndex(o=>o.byteLength>=r);s<0?t.push(i):(s>0||t.lengththis.opts.poolSize&&t.shift()}},hn=new E_;Fe();function po(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function S_(n,e){let t=n%e;return t<0?e+t:t}function o1(n){return[n[12],n[13],n[14]]}function a1(n){return{left:ho(n[3]+n[0],n[7]+n[4],n[11]+n[8],n[15]+n[12]),right:ho(n[3]-n[0],n[7]-n[4],n[11]-n[8],n[15]-n[12]),bottom:ho(n[3]+n[1],n[7]+n[5],n[11]+n[9],n[15]+n[13]),top:ho(n[3]-n[1],n[7]-n[5],n[11]-n[9],n[15]-n[13]),near:ho(n[3]+n[2],n[7]+n[6],n[11]+n[10],n[15]+n[14]),far:ho(n[3]-n[2],n[7]-n[6],n[11]-n[10],n[15]-n[14])}}var s1=new tt;function ho(n,e,t,i){s1.set(n,e,t);let r=s1.len();return{distance:i/r,normal:new tt(-n/r,-e/r,-t/r)}}function hF(n){return n-Math.fround(n)}var pc;function mo(n,e){let{size:t=1,startIndex:i=0}=e,r=e.endIndex!==void 0?e.endIndex:n.length,s=(r-i)/t;pc=hn.allocate(pc,s,{type:Float32Array,size:t*2});let o=i,a=0;for(;ox.useInPicking),pass:h,canvasContext:m,isPicking:!0,shaderModuleProps:g,clearColor:v??[0,0,0,0],colorMask:15,scissorRect:b});return this._colorEncoderState=null,{decodePickingColor:y&&t6.bind(null,y),stats:w}}shouldDrawLayer(e){let{pickable:t,operation:i}=e.props;return t&&i.includes("draw")||i.includes("terrain")||i.includes("mask")}getShaderModuleProps(e,t,i){return{picking:{isActive:1,isAttribute:this.pickZ,disabledPickingIndices:e.internalState?.disabledPickingIndices},lighting:{enabled:!1}}}getLayerParameters(e,t,i){let r={...e.props.parameters},{pickable:s,operation:o}=e.props;return this._colorEncoderState?s&&o.includes("draw")?(Object.assign(r,e6),r.blend=!0,this.device.type==="webgpu"?r.blendConstant=W1(this._colorEncoderState,e,i):r.blendColor=W1(this._colorEncoderState,e,i),o.includes("terrain")&&e.state?._hasPickingCover&&(r.blendAlphaSrcFactor="one")):o.includes("terrain")&&(r.blend=!1):r.blend=!1,r}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}};function W1(n,e,t){let{byLayer:i,byAlpha:r}=n,s,o=i.get(e);return o?(o.viewports.push(t),s=o.a):(s=i.size+1,s<=255?(o={a:s,layer:e,viewports:[t]},i.set(e,o),r[s]=o):(ae.warn("Too many pickable layers, only picking the first 255")(),s=0)),[0,0,0,s/255]}function t6(n,e){let t=n.byAlpha[e[3]];return t&&{pickedLayer:t.layer,pickedViewports:t.viewports,pickedObjectIndex:t.layer.decodePickingColor(e)}}Ce();var Ki={NO_STATE:"Awaiting state",MATCHED:"Matched. State transferred from previous layer",INITIALIZED:"Initialized",AWAITING_GC:"Discarded. Awaiting garbage collection",AWAITING_FINALIZATION:"No longer matched. Awaiting garbage collection",FINALIZED:"Finalized! Awaiting garbage collection"},wo=Symbol.for("component"),Yn=Symbol.for("propTypes"),Bf=Symbol.for("deprecatedProps"),bi=Symbol.for("asyncPropDefaults"),qn=Symbol.for("asyncPropOriginal"),pn=Symbol.for("asyncPropResolved");function Of(n,e=()=>!0){return Array.isArray(n)?j1(n,e,[]):e(n)?[n]:[]}function j1(n,e,t){let i=-1;for(;++i0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,t){if(e===this._data&&!t)return;this._data=e;let i=++this._loadCount,r=e;typeof e=="string"&&(r=zs(e)),r instanceof Promise?(this.isLoaded=!1,this._loader=r.then(s=>{this._loadCount===i&&(this.isLoaded=!0,this._error=void 0,this._content=s)}).catch(s=>{this._loadCount===i&&(this.isLoaded=!0,this._error=s||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(let s of this._subscribers)s.onChange(this.getData())}};var vc=class{constructor(e){this.protocol=e.protocol||"resource://",this._context={device:e.device,gl:e.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return e.startsWith(this.protocol)?!0:e in this._resources}add({resourceId:e,data:t,forceUpdate:i=!1,persistent:r=!0}){let s=this._resources[e];s?s.setData(t,i):(s=new bc(e,t,this._context),this._resources[e]=s),s.persistent=r}remove(e){let t=this._resources[e];t&&(t.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){let t=this._consumers[e];if(t){for(let i in t){let r=t[i],s=this._resources[r.resourceId];s&&s.unsubscribe(r)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:t,consumerId:i,requestId:r="default"}){let{_resources:s,protocol:o}=this;e.startsWith(o)&&(e=e.replace(o,""),s[e]||this.add({resourceId:e,data:null,persistent:!1}));let a=s[e];if(this._track(i,r,a,t),a)return a.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(let e in this._resources)this._resources[e].delete()}_track(e,t,i,r){let s=this._consumers,o=s[e]=s[e]||{},a=o[t],c=a&&a.resourceId&&this._resources[a.resourceId];c&&(c.unsubscribe(a),this.prune()),i&&(a?(a.onChange=r,a.resourceId=i.id):a={onChange:r,resourceId:i.id},o[t]=a,i.subscribe(a))}_prune(){this._pruneRequest=null;for(let e of Object.keys(this._resources)){let t=this._resources[e];!t.persistent&&!t.inUse()&&(t.delete(),delete this._resources[e])}}};var n6="layerManager.setLayers",i6="layerManager.activateViewport",xc=class{constructor(e,t){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=a=>{De(i6,this,a),a&&(this.context.viewport=a)};let{deck:i,stats:r,viewport:s,timeline:o}=t||{};this.layers=[],this.resourceManager=new vc({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e?.gl,deck:i,shaderAssembler:t1(e?.info?.shadingLanguage||"glsl"),defaultShaderModules:[r_],renderPass:void 0,stats:r||new Vt({id:"deck.gl"}),viewport:s||new go({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:o||new Qr,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(let e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(let i of this.layers){let r=i.getNeedsRedraw(e);t=t||r}return t}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(t=>e.find(i=>t.id.indexOf(i)===0)):this.layers}setProps(e){"debug"in e&&(this._debug=e.debug),"userData"in e&&(this.context.userData=e.userData),"layers"in e&&(this._nextLayers=e.layers),"onError"in e&&(this.context.onError=e.onError)}setLayers(e,t){De(n6,this,t,e),this._lastRenderedLayers=e;let i=Of(e,Boolean);for(let r of i)r.context=this.context;this._updateLayers(this.layers,i)}updateLayers(){let e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){let{defaultShaderModules:t}=this.context;t.find(i=>i.name===e.name)||(t.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){let{defaultShaderModules:t}=this.context,i=t.findIndex(r=>r.name===e.name);i>=0&&(t.splice(i,1),this._defaultShaderModulesChanged=!0)}_handleError(e,t,i){i.raiseError(t,`${e} of ${i}`)}_updateLayers(e,t){let i={};for(let o of e)i[o.id]?ae.warn(`Multiple old layers with same id ${o.id}`)():i[o.id]=o;if(this._defaultShaderModulesChanged){for(let o of e)o.setNeedsUpdate(),o.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}let r=[];this._updateSublayersRecursively(t,i,r),this._finalizeOldLayers(i);let s=!1;for(let o of r)if(o.hasUniformTransition()){s=`Uniform transition in ${o}`;break}this._needsUpdate=s,this.layers=r}_updateSublayersRecursively(e,t,i){for(let r of e){r.context=this.context;let s=t[r.id];s===null&&ae.warn(`Multiple new layers with same id ${r.id}`)(),t[r.id]=null;let o=null;try{this._debug&&s!==r&&r.validateProps(),s?(this._transferLayerState(s,r),this._updateLayer(r)):this._initializeLayer(r),i.push(r),o=r.isComposite?r.getSubLayers():null}catch(a){this._handleError("matching",a,r)}o&&this._updateSublayersRecursively(o,t,i)}}_finalizeOldLayers(e){for(let t in e){let i=e[t];i&&this._finalizeLayer(i)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=Ki.INITIALIZED}catch(t){this._handleError("initialization",t,e)}}_transferLayerState(e,t){t._transferState(e),t.lifecycle=Ki.MATCHED,t!==e&&(e.lifecycle=Ki.AWAITING_GC)}_updateLayer(e){try{e._update()}catch(t){this._handleError("update",t,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=Ki.AWAITING_FINALIZATION;try{e._finalize(),e.lifecycle=Ki.FINALIZED}catch(t){this._handleError("finalization",t,e)}}};function xe(n,e,t){if(n===e)return!0;if(!t||!n||!e)return!1;if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let i=0;i{let i=!e.canvasId||this.getCanvasId(t.id)===e.canvasId,r=!("x"in e)||t.containsPixel(e);return i&&r}):this._viewports}getViews(){let e={};return this.views.forEach(t=>{e[t.id]=t}),e}getView(e){return this.views.find(t=>t.id===e)}getViewState(e){let t=typeof e=="string"?this.getView(e):e,i=t&&this.viewState[t.getViewStateId()]||this.viewState;return t?t.filterViewState(i):i}getViewport(e){return this._viewportMap[e]}getCanvasId(e){let t=typeof e=="string"?this.getView(e):e;return t?this._viewEventManagers[t.id]?.canvasId||this._getCanvasIdFromView(t):void 0}unproject(e,t){let i=this.getViewports(),r={x:e[0],y:e[1]};for(let s=i.length-1;s>=0;--s){let o=i[s];if(o.containsPixel(r)){let a=e.slice();return a[0]-=o.x,a[1]-=o.y,o.unproject(a,t)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),("width"in e||"height"in e)&&this._setSize(e.width,e.height),"pickPosition"in e&&(this._pickPosition=e.pickPosition),"eventManagers"in e&&this._setEventManagers(e.eventManagers||{}),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,t){(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.setNeedsUpdate("Size changed"))}_setViews(e){e=Of(e,Boolean),this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){e?(!xe(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e):ae.warn("missing `viewState` or `initialViewState`")()}_setEventManagers(e){this._eventManagers!==e&&(this._eventManagers=e,this.setNeedsUpdate("eventManagers changed"))}_getCanvasIdFromView(e){return e.props.canvasId||this._getCanvasContext?.(e.id)?.id||Qi}_getCanvasDimensions(e){let t=this._getCanvasContext?.(e.id),[i,r]=t?.getCSSSize()||[this.width,this.height];return{width:i,height:r}}_getViewEventManager(e){let t=this.getCanvasId(e)||Qi;return{canvasId:t,eventManager:this._eventManagers[t]||this._eventManager}}_startViewportRebuild(){let e=this.controllers,t=this._viewEventManagers;return this._viewports=[],this.controllers={},this._viewEventManagers={},{oldControllers:e,oldViewEventManagers:t}}_getReusableController(e,t,i){return e&&(t?.canvasId!==i.canvasId||t?.eventManager!==i.eventManager)?(e.finalize(),null):e}_createController(e,t){let i=t.type;return new i({timeline:this.timeline,eventManager:this._getViewEventManager(e).eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:s=>this.getView(e.id)?.makeViewport({viewState:s,...this._getCanvasDimensions(e)}),pickPosition:(s,o)=>this._pickPosition?.(s,o,e.id)})}_updateController(e,t,i,r){let s=e.controller;if(s&&i){let o={...t,...s,id:e.id,x:i.x,y:i.y,width:i.width,height:i.height};return(!r||r.constructor!==s.type)&&(r=this._createController(e,o)),r&&r.setProps(o),r}return null}_rebuildViewports(){let{views:e}=this,{oldControllers:t,oldViewEventManagers:i}=this._startViewportRebuild(),r=!1;for(let s=e.length;s--;){let o=e[s],{width:a,height:c}=this._getCanvasDimensions(o),l=this._getViewEventManager(o);this._viewEventManagers[o.id]=l;let u=this.getViewState(o),f=o.makeViewport({viewState:u,width:a,height:c}),d=this._getReusableController(t[o.id],i[o.id],l),h=!!o.controller;h&&!d&&(r=!0),(r||!h)&&d&&(d.finalize(),d=null),this.controllers[o.id]=this._updateController(o,u,f,d),f&&this._viewports.unshift(f)}for(let s in t){let o=t[s];o&&!this.controllers[s]&&o.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,t){return e.length!==t.length?!0:e.some((i,r)=>!e[r].equals(t[r]))}};var r6=/^(?:\d+\.?\d*|\.\d+)$/;function vt(n){switch(typeof n){case"number":if(!Number.isFinite(n))throw new Error(`Could not parse position string ${n}`);return{type:"literal",value:n};case"string":try{let e=s6(n);return new z_(e).parseExpression()}catch(e){let t=e instanceof Error?e.message:String(e);throw new Error(`Could not parse position string ${n}: ${t}`)}default:throw new Error(`Could not parse position string ${n}`)}}function F_(n,e){switch(n.type){case"literal":return n.value;case"percentage":return Math.round(n.value*e);case"binary":let t=F_(n.left,e),i=F_(n.right,e);return n.operator==="+"?t+i:t-i;default:throw new Error("Unknown layout expression type")}}function xt(n,e){return F_(n,e)}function s6(n){let e=[],t=0;for(;t="0"&&n<="9"}function q1(n){return n>="a"&&n<="z"||n>="A"&&n<="Z"}function o6(n){return!!(n&&n.type==="symbol"&&(n.value==="+"||n.value==="-"))}function Z1(n,e){let t={...n};for(let i in e)i!=="id"&&(Array.isArray(t[i])&&Array.isArray(e[i])?t[i]=a6(t[i],e[i]):t[i]=e[i]);return t}function a6(n,e){n=n.slice();for(let t=0;t{},K1={mode:"preserve"},c6={mode:"hard"},U_={BREAK:1,SNAP_TO_END:2,IGNORE:3},l6=n=>n,u6=U_.BREAK,Ec=class{constructor(e){this._onTransitionUpdate=t=>{let{time:i,settings:{interpolator:r,startProps:s,endProps:o,duration:a,easing:c}}=t,l=c(i/a),u=r.interpolateProps(s,o,l);this.propsInTransition=this.getControllerState({...this.props,...u},K1).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new mn(e.timeline),this.onViewStateChange=e.onViewStateChange||X1,this.onStateChange=e.onStateChange||X1}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let t=!1,i=this.props;if(this.props=e,!i||this._shouldIgnoreViewportChange(i,e))return!1;if(this._isTransitionEnabled(e)){let r=i;if(this.transition.inProgress){let{interruption:s,endProps:o}=this.transition.settings;r={...i,...s===U_.SNAP_TO_END?o:this.propsInTransition||i}}this._triggerTransition(r,e),t=!0}else this.transition.cancel();return t}updateTransition(){this.transition.update()}_isTransitionEnabled(e){let{transitionDuration:t,transitionInterpolator:i}=e;return(t>0||t==="auto")&&!!i}_isUpdateDueToCurrentTransition(e){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition):!1}_shouldIgnoreViewportChange(e,t){return this.transition.inProgress?this.transition.settings.interruption===U_.IGNORE||this._isUpdateDueToCurrentTransition(t):this._isTransitionEnabled(t)?t.transitionInterpolator.arePropsEqual(e,t):!0}_triggerTransition(e,t){let i=this.getControllerState(e,K1),r=this.getControllerState(t,c6).shortestPathFrom(i),s=t.transitionInterpolator,o=s.getDuration?s.getDuration(e,t):t.transitionDuration;if(o===0)return;let a=s.initializeProps(e,r);this.propsInTransition={};let c={duration:o,easing:t.transitionEasing||l6,interpolator:s,interruption:t.transitionInterruption||u6,startProps:a.start,endProps:a.end,onStart:t.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(t.onTransitionInterrupt),onEnd:this._onTransitionEnd(t.onTransitionEnd)};this.transition.start(c),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return t=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e?.(t)}}};Fe();function me(n,e){if(!n)throw new Error(e||"deck.gl: assertion failed.")}var Sc=class{constructor(e){let{compare:t,extract:i,required:r}=e;this._propsToCompare=t,this._propsToExtract=i||t,this._requiredProps=r}arePropsEqual(e,t){for(let i of this._propsToCompare)if(!(i in e)||!(i in t)||!Nn(e[i],t[i]))return!1;return!0}initializeProps(e,t){let i={},r={};for(let s of this._propsToExtract)(s in e||s in t)&&(i[s]=e[s],r[s]=t[s]);return this._checkRequiredProps(i),this._checkRequiredProps(r),{start:i,end:r}}getDuration(e,t){return t.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(t=>{let i=e[t];me(Number.isFinite(i)||Array.isArray(i),`${t} is required for transition`)})}};Fe();var f6=["longitude","latitude","zoom","bearing","pitch"],d6=["longitude","latitude","zoom"],vi=class extends Sc{constructor(e={}){let t=Array.isArray(e)?e:e.transitionProps,i=Array.isArray(e)?{}:e;i.transitionProps=Array.isArray(t)?{compare:t,required:t}:t||{compare:f6,required:d6},super(i.transitionProps),this.opts=i}initializeProps(e,t){let i=super.initializeProps(e,t),{makeViewport:r,around:s}=this.opts;if(r&&s){let o=r(e),a=r(t),c=o.unproject(s);i.start.around=s,Object.assign(i.end,{around:a.project(c),aroundPosition:c,width:t.width,height:t.height})}return i}interpolateProps(e,t,i){let r={};for(let s of this._propsToExtract)r[s]=cn(e[s]||0,t[s]||0,i);if(t.aroundPosition&&this.opts.makeViewport){let s=this.opts.makeViewport({...t,...r});Object.assign(r,s.panByPosition(t.aroundPosition,cn(e.around,t.around,i)))}return r}};var Zn={transitionDuration:0},h6=300,p6=300,$_=n=>1-(1-n)*(1-n),m6=n=>n===1?1:1-Math.pow(2,-10*n),ts={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],MULTI_PAN:["multipanstart","multipanmove","multipanend"],DOUBLE_CLICK:["dblclick"],DOUBLE_CLICK_DRAG:["dblclickdragstart","dblclickdragmove","dblclickdragend","dblclickdragcancel"],KEYBOARD:["keydown"]},ns={},is=class{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this._multiPanMode=null,this._multiPanStartCenter=null,this._doubleClickDragAnchor=null,this._suppressDoubleClickUntil=0,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.doubleClickDragZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.multiTouchDrag=null,this.trackpadGesture=!1,this.zoomAround="pointer",this.keyboard=!0,this.transitionManager=new Ec({...e,getControllerState:(t,i)=>new this.ControllerState({...t,constraintContext:i,makeViewport:e.makeViewport}),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport,this.pickPosition=e.pickPosition}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){for(let e in this._events)this._events[e]&&this.eventManager?.off(e,this.handleEvent);this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;let t=this._eventStartBlocked;switch(e.type){case"panstart":return t?!1:this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return t||!this._isTrackpadGestureAllowed(e)?!1:this._onPinchStart(e);case"pinchmove":return this._isTrackpadGestureAllowed(e)?this._onPinch(e):!1;case"pinchend":return this._isTrackpadGestureAllowed(e)?this._onPinchEnd(e):!1;case"multipanstart":return t?!1:this._onMultiPanStart(e);case"multipanmove":return this._onMultiPan(e);case"multipanend":return this._onMultiPanEnd(e);case"dblclick":return this._onDoubleClick(e);case"dblclickdragstart":return t?!1:this._onDoubleClickDragStart(e);case"dblclickdragmove":return this._onDoubleClickDrag(e);case"dblclickdragend":case"dblclickdragcancel":return this._onDoubleClickDragEnd(e);case"wheel":return this._onWheel(e);case"keydown":return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){let{x:t,y:i}=this.props,{offsetCenter:r}=e;return[r.x-t,r.y-i]}getZoomPosition(e){if(this.zoomAround==="pointer")return e;let t=this.makeViewport(this.controllerState.getViewportProps()),[i,r]=Xi(t.center,t.pixelProjectionMatrix);return[i,r]}isPointInBounds(e,t){let{width:i,height:r}=this.props;if(t&&t.handled)return!1;let s=e[0]>=0&&e[0]<=i&&e[1]>=0&&e[1]<=r;return s&&t&&t.stopPropagation(),s}isFunctionKeyPressed(e){let{srcEvent:t}=e;return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){let t=setTimeout(()=>{this._eventStartBlocked===t&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=t}setProps(e){e.maxBoundsPadding===void 0&&(e.maxBoundsPadding=null),e.dragMode&&(this.dragMode=e.dragMode);let t=this.props;this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);let{inertia:i}=e;this.inertia=Number.isFinite(i)?i:i===!0?h6:0;let{scrollZoom:r=!0,dragPan:s=!0,dragRotate:o=!0,doubleClickZoom:a=!0,doubleClickDragZoom:c=!1,touchZoom:l=!0,touchRotate:u=!1,multiTouchDrag:f=u?"rotate":null,trackpadGesture:d=!1,zoomAround:h="pointer",keyboard:p=!0}=e,m=!!this.onViewStateChange;if(this.toggleEvents(ts.WHEEL,m&&r),this.toggleEvents(ts.PAN,m),this.toggleEvents(ts.PINCH,m&&(l||f==="rotate")),this.toggleEvents(ts.MULTI_PAN,m&&!!f),this.toggleEvents(ts.DOUBLE_CLICK,m&&a),this.toggleEvents(ts.DOUBLE_CLICK_DRAG,m&&c),this.toggleEvents(ts.KEYBOARD,m&&p),this.scrollZoom=r,this.dragPan=s,this.dragRotate=o,this.doubleClickZoom=a,this.doubleClickDragZoom=c,this.touchZoom=l,this.touchRotate=f==="rotate",this.multiTouchDrag=f,this.trackpadGesture=d,this.zoomAround=h,this.keyboard=p,(!t||t.height!==e.height||t.width!==e.width||t.maxBounds!==e.maxBounds||t.maxBoundsPadding!==e.maxBoundsPadding)&&e.maxBounds){let v=new this.ControllerState({...e,makeViewport:this.makeViewport}),y=v.getViewportProps();Object.keys(y).some(w=>!xe(y[w],e[w],1))&&this.updateViewport(v)}}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,t){this.eventManager&&e.forEach(i=>{this._events[i]!==t&&(this._events[i]=t,t?this.eventManager.on(i,this.handleEvent):this.eventManager.off(i,this.handleEvent))})}updateViewport(e,t=null,i={}){let r={...e.getViewportProps(),...t},s=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(i),s){let o=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:r,interactionState:this._interactionState,oldViewState:o,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_getConstraintContext(e,t){return this.props.rubberBand?{mode:t==="update"?"elastic":t==="end"?"rebound":"hard"}:{mode:"hard"}}_getReboundTransition(e,t){if(e.mode!=="rebound")return null;let i=t.getViewportProps();return Object.keys(i).some(s=>!xe(this.props[s],i[s],1))?{...this._getTransitionProps(),transitionDuration:p6,transitionEasing:m6}:null}_onPanStart(e){let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let i=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(i=!i);let r=i?"pan":"rotate",s=this._getConstraintContext(r,"start"),o=i?this.controllerState.panStart({pos:t},s):this.controllerState.rotateStart({pos:t},s);return this._panMove=i,this.updateViewport(o,Zn,{isDragging:!0}),!0}_onPan(e){return this.isDragging()?this._panMove?this._onPanMove(e):this._onPanRotate(e):!1}_onPanEnd(e){return this.isDragging()?this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e):!1}_onPanMove(e){if(!this.dragPan)return!1;let t=this.getCenter(e),i=this.controllerState.pan({pos:t},this._getConstraintContext("pan","update"));return this.updateViewport(i,Zn,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){let{inertia:t}=this;if(this.dragPan&&t&&e.velocity){let i=this.getCenter(e),r=[i[0]+e.velocityX*t/2,i[1]+e.velocityY*t/2],s=this.controllerState.pan({pos:r}).panEnd();this.updateViewport(s,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:$_},{isDragging:!1,isPanning:!0})}else{let i=this.controllerState,r=this._getConstraintContext("pan","end"),s=i.panEnd(r),o=this._getReboundTransition(r,s);this.updateViewport(s,o,{isDragging:!1,isPanning:!!o})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;let t=this.getCenter(e),i=this.controllerState.rotate({pos:t},this._getConstraintContext("rotate","update"));return this.updateViewport(i,Zn,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){let{inertia:t}=this;if(this.dragRotate&&t&&e.velocity){let i=this.getCenter(e),r=[i[0]+e.velocityX*t/2,i[1]+e.velocityY*t/2],s=this.controllerState.rotate({pos:r}).rotateEnd();this.updateViewport(s,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:$_},{isDragging:!1,isRotating:!0})}else{let i=this.controllerState,r=this._getConstraintContext("rotate","end"),s=i.rotateEnd(r),o=this._getReboundTransition(r,s);this.updateViewport(s,o,{isDragging:!1,isRotating:!!o})}return!0}_onWheel(e){if(!this.scrollZoom||this.trackpadGesture&&e.device!=="mouse")return!1;let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;e.srcEvent.preventDefault();let{speed:i=.01,smooth:r=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:s}=e,o=2/(1+Math.exp(-Math.abs(s*i)));s<0&&o!==0&&(o=1/o);let a=this.getZoomPosition(t),c=r?{...this._getTransitionProps({around:a}),transitionDuration:250}:Zn,l=this.controllerState.zoom({pos:a,scale:o});return this.updateViewport(l,c,{isZooming:!0,isPanning:!0}),r||this._setInteractionState({isZooming:!1,isPanning:!1}),!0}_onMultiPanStart(e){let{multiTouchDrag:t}=this;if(!t||!this._isMultiPanEventAllowed(e,t))return!1;let i=e.offsetCenter;if(!this.isPointInBounds(this.getCenter(e),e))return!1;let r=e.pointerType==="trackpad",s={x:i.x-(r?0:e.deltaX),y:i.y-(r?0:e.deltaY)},o={...e,offsetCenter:s},a=this.getCenter(o),c=t==="pan"?this.controllerState.panStart({pos:a},this._getConstraintContext("pan","start")):this.controllerState.rotateStart({pos:a},this._getConstraintContext("rotate","start"));return this._multiPanMode=t,this._multiPanStartCenter=s,this.updateViewport(c,Zn,{isDragging:!0}),!0}_onMultiPan(e){let{mode:t,event:i}=this._getMultiPanEvent(e);return!t||!i||!this.isDragging()?!1:t==="pan"?this._onPanMove(i):this._onPanRotate(i)}_onMultiPanEnd(e){let{mode:t,event:i}=this._getMultiPanEvent(e);if(!t||!i||!this.isDragging())return this._resetMultiPan(),!1;let r=t==="pan"?this._onPanMoveEnd(i):this._onPanRotateEnd(i);return this._resetMultiPan(),r}_isTrackpadGestureAllowed(e){return e.pointerType!=="trackpad"||this.trackpadGesture}_isMultiPanEventAllowed(e,t){return e.pointerType==="trackpad"?this.trackpadGesture&&(t==="pan"?this.dragPan:this.dragRotate):e.pointerType==="touch"&&(t==="pan"?this.dragPan:this.dragRotate)}_getMultiPanEvent(e){let t=this._multiPanMode,i=this._multiPanStartCenter;return!t||!i?{mode:null,event:null}:{mode:t,event:{...e,offsetCenter:{x:i.x+e.deltaX,y:i.y+e.deltaY}}}}_resetMultiPan(){this._multiPanMode=null,this._multiPanStartCenter=null}_onPinchStart(e){this._doubleClickDragAnchor=null;let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let i=this.controllerState.zoomStart({pos:this.getZoomPosition(t)},this._getConstraintContext("zoom","start")).rotateStart({pos:t},this._getConstraintContext("rotate","start"));return ns._startPinchRotation=e.rotation,ns._lastPinchEvent=e,this.updateViewport(i,Zn,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let t=this.controllerState;if(this.touchZoom){let{scale:i}=e,r=this.getCenter(e);t=t.zoom({pos:this.getZoomPosition(r),scale:i},this._getConstraintContext("zoom","update"))}if(this.touchRotate){let{rotation:i}=e;t=t.rotate({deltaAngleX:ns._startPinchRotation-i},this._getConstraintContext("rotate","update"))}return this.updateViewport(t,Zn,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),ns._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;let{inertia:t}=this,{_lastPinchEvent:i}=ns;if(this.touchZoom&&t&&i&&e.scale!==i.scale){let r=this.getCenter(e),s=this.getZoomPosition(r),o=this.controllerState.rotateEnd(),a=Math.log2(e.scale),c=(a-Math.log2(i.scale))/(e.deltaTime-i.deltaTime),l=Math.pow(2,a+c*t/2);o=o.zoom({pos:s,scale:l}).zoomEnd(),this.updateViewport(o,{...this._getTransitionProps({around:s}),transitionDuration:t,transitionEasing:$_},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(t)}else{let r=this.controllerState,s=this._getConstraintContext("zoom","end"),o=this._getConstraintContext("rotate","end"),a=r.zoomEnd(s).rotateEnd(o),c=this._getReboundTransition(this.touchZoom?s:o,a);this.updateViewport(a,c,{isDragging:!1,isPanning:!!c&&this.touchZoom,isZooming:!!c&&this.touchZoom,isRotating:!!c&&this.touchRotate})}return ns._startPinchRotation=null,ns._lastPinchEvent=null,!0}_onDoubleClick(e){if(!this.doubleClickZoom||Date.now()90&&(e=Math.sign(e)*90),Number.isFinite(n)){let[i,r]=ht([n,e]);return[i,Se(r,0,J1)]}let[,t]=ht([0,e]);return[n,Se(t,0,J1)]}var G_=class extends rs{constructor(e){let{width:t,height:i,latitude:r,longitude:s,zoom:o,bearing:a=0,pitch:c=0,altitude:l=1.5,position:u=[0,0,0],maxZoom:f=20,minZoom:d=0,maxPitch:h=60,minPitch:p=0,startPanLngLat:m,startZoomLngLat:g,startRotatePos:v,startRotateLngLat:y,startBearing:b,startPitch:w,startZoom:E,normalize:x=!0,rubberBand:T=!1}=e,{[Qt]:I}=e;me(Number.isFinite(s)),me(Number.isFinite(r)),me(Number.isFinite(o));let N=e.maxBounds||(x?e2:null),D=e.maxBoundsPadding||null;super({width:t,height:i,latitude:r,longitude:s,zoom:o,bearing:a,pitch:c,altitude:l,maxZoom:f,minZoom:d,maxPitch:h,minPitch:p,normalize:x,position:u,maxBounds:N,maxBoundsPadding:D,rubberBand:T,[Qt]:I},{startPanLngLat:m,startZoomLngLat:g,startRotatePos:v,startRotateLngLat:y,startBearing:b,startPitch:w,startZoom:E},e.makeViewport,e.constraintContext),this.getAltitude=e.getAltitude}panStart({pos:e},t){return this._getUpdatedState({startPanLngLat:this._unproject(e)},t)}pan({pos:e,startPos:t},i){let r=this.getState().startPanLngLat||this._unproject(t);if(!r)return this;let o=this.makeViewport(this.getViewportProps()).panByPosition(r,e);return this._getUpdatedState(o,i)}panEnd(e){return this._getUpdatedState({startPanLngLat:null},e)}rotateStart({pos:e}){let t=this.getAltitude?.(e);return this._getUpdatedState({startRotatePos:e,startRotateLngLat:t!==void 0?this._unproject3D(e,t):void 0,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:t=0,deltaAngleY:i=0}){let{startRotatePos:r,startRotateLngLat:s,startBearing:o,startPitch:a}=this.getState();if(!r||o===void 0||a===void 0)return this;let c;if(e?c=this._getNewRotation(e,r,a,o):c={bearing:o+t,pitch:a+i},s){let l=this.makeViewport({...this.getViewportProps(),...c}),u="panByPosition3D"in l?"panByPosition3D":"panByPosition";return this._getUpdatedState({...c,...l[u](s,r)})}return this._getUpdatedState(c)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startRotateLngLat:null,startBearing:null,startPitch:null})}zoomStart({pos:e},t){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom},t)}zoom({pos:e,startPos:t,scale:i},r){let{startZoom:s,startZoomLngLat:o}=this.getState();return o||(s=this.getViewportProps().zoom,o=this._unproject(t)||this._unproject(e)),o?this._getUpdatedState({zoom:s+Math.log2(i),[Qt]:{position:o,screenPosition:e}},r):this}zoomEnd(e){return this._getUpdatedState({startZoomLngLat:null,startZoom:null},e)}zoomIn(e=2,t){return this._zoomFromCenter(e,t)}zoomOut(e=2,t){return this._zoomFromCenter(1/e,t)}moveLeft(e=100,t){return this._panFromCenter([e,0],t)}moveRight(e=100,t){return this._panFromCenter([-e,0],t)}moveUp(e=100,t){return this._panFromCenter([0,e],t)}moveDown(e=100,t){return this._panFromCenter([0,-e],t)}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){let t=e.getViewportProps(),i={...this.getViewportProps()},{bearing:r,longitude:s}=i;return Math.abs(r-t.bearing)>180&&(i.bearing=r<0?r+360:r-360),Math.abs(s-t.longitude)>180&&(i.longitude=s<0?s+360:s-360),i}applyConstraints(e,t){let i=e,r=i[Qt];delete i[Qt];let{maxPitch:s,minPitch:o,pitch:a,bearing:c,normalize:l,maxBounds:u,rubberBand:f}=e;l&&(c<-180||c>180)&&(e.bearing=S_(c+180,360)-180),e.pitch=Se(a,o,s);let d=this._constrainZoom(e.zoom,e),h=f&&t?.mode==="elastic";if(e.zoom=t?.mode==="preserve"?e.zoom:h?Ji(e.zoom,d,_6):d,r){let p=this.makeViewport(e);Object.assign(e,p.panByPosition(r.position,r.screenPosition))}if(l&&(e.longitude<-180||e.longitude>180)&&(e.longitude=S_(e.longitude+180,360)-180),u){let p=Eo(e.width,e.height,e.maxBoundsPadding),m=this.makeViewport({...e,bearing:0,pitch:0}),g=Df(m,[e.longitude,e.latitude],p),v=Pc(u[0]),y=Pc(u[1]),b=2**e.zoom,w=[v[0]+g.left/b,v[1]+g.bottom/b],E=[y[0]-g.right/b,y[1]-g.top/b],x=Pc([e.longitude,e.latitude]),T=[Se(x[0],w[0],E[0]),Se(x[1],w[1],E[1])],I=x.slice();if(p.width>=0&&(I[0]=t?.mode==="preserve"?x[0]:h?Ji(x[0],T[0],p.width/2/b):T[0]),p.height>=0&&(I[1]=t?.mode==="preserve"?x[1]:h?Ji(x[1],T[1],p.height/2/b):T[1]),I[0]!==x[0]||I[1]!==x[1]){let[N,D]=kt(I);I[0]!==x[0]&&(e.longitude=N),I[1]!==x[1]&&(e.latitude=D)}}return e}_constrainZoom(e,t){t||(t=this.getViewportProps());let{maxZoom:i,maxBounds:r}=t,s=r!==null&&t.width>0&&t.height>0,{minZoom:o}=t;if(s){let a=Eo(t.width,t.height,t.maxBoundsPadding),c=Pc(r[0]),l=Pc(r[1]),u=l[0]-c[0],f=l[1]-c[1];a.width>0&&Number.isFinite(u)&&u>0&&(o=Math.max(o,Math.log2(a.width/u))),a.height>0&&Number.isFinite(f)&&f>0&&(o=Math.max(o,Math.log2(a.height/f))),o>i&&(o=i)}return Se(e,o,i)}_zoomFromCenter(e,t){let{width:i,height:r}=this.getViewportProps();return this.zoom({pos:[i/2,r/2],scale:e},t)}_panFromCenter(e,t){let{width:i,height:r}=this.getViewportProps();return this.pan({startPos:[i/2,r/2],pos:[i/2+e[0],r/2+e[1]]},t)}_getUpdatedState(e,t){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e,constraintContext:t})}_unproject(e){let t=this.makeViewport(this.getViewportProps());return e&&t.unproject(e)}_unproject3D(e,t){return this.makeViewport(this.getViewportProps()).unproject(e,{targetZ:t})}_getNewRotation(e,t,i,r){let s=e[0]-t[0],o=e[1]-t[1],a=e[1],c=t[1],{width:l,height:u}=this.getViewportProps(),f=s/l,d=0;o>0?Math.abs(u-c)>Q1&&(d=o/(c-u)*g6):o<0&&c>Q1&&(d=1-a/c),d=Se(d,-1,1);let{minPitch:h,maxPitch:p}=this.getViewportProps(),m=r+180*f,g=i;return d>0?g=i+d*(p-i):d<0&&(g=i-d*(h-i)),{pitch:g,bearing:m}}},Cc=class extends is{constructor(){super(...arguments),this.ControllerState=G_,this.transition={transitionDuration:300,transitionInterpolator:new vi({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan",this.rotationPivot="center",this._getAltitude=e=>{if(this.rotationPivot==="2d")return 0;if(this.rotationPivot==="3d"&&this.pickPosition){let{x:t,y:i}=this.props,r=this.pickPosition(t+e[0],i+e[1]);if(r&&r.coordinate&&r.coordinate.length>=3)return r.coordinate[2]}}}setProps(e){"rotationPivot"in e&&(this.rotationPivot=e.rotationPivot||"center"),e.getAltitude=this._getAltitude,e.position=e.position||[0,0,0],e.maxBounds=e.maxBounds||(e.normalize===!1?null:e2),super.setProps(e)}updateViewport(e,t=null,i={}){let r=e.getState();i.isDragging&&r.startRotateLngLat?i={...i,rotationPivotPosition:r.startRotateLngLat}:i.isDragging===!1&&(i={...i,rotationPivotPosition:void 0}),super.updateViewport(e,t,i)}};var Nf=class extends es{constructor(e={}){super(e)}getViewportType(){return yi}get ControllerType(){return Cc}};Nf.displayName="MapView";var t2=Nf;var y6=new fo;function b6(n,e){let t=n.order??1/0,i=e.order??1/0;return t-i}var Tc=class{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){let t=this._defaultEffects;if(!t.find(i=>i.id===e.id)){let i=t.findIndex(r=>b6(r,e)>0);i<0?t.push(e):t.splice(i,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&(xe(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}getEffects(){return this._resolvedEffects}_setEffects(e){let t={};for(let r of this.effects)t[r.id]=r;let i=[];for(let r of e){let s=t[r.id],o=r;s&&s!==r?s.setProps?(s.setProps(r.props),o=s):s.cleanup(this._context):s||r.setup(this._context),i.push(o),delete t[r.id]}for(let r in t)t[r].cleanup(this._context);this.effects=i,this._resolvedEffects=i.concat(this._defaultEffects),e.some(r=>r instanceof fo)||this._resolvedEffects.push(y6),this._needsRedraw="effects changed"}finalize(){for(let e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}};var Lc=class extends _i{shouldDrawLayer(e){let{operation:t}=e.props;return t.includes("draw")||t.includes("terrain")}render(e){return this._render(e)}};var v6="deckRenderer.renderLayers",Mc=class{constructor(e,t={}){this.device=e,this.stats=t.stats,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new Lc(e),this.pickLayersPass=new Jr(e),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(e){let t=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,i={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};if(!e.viewports.length){let a=t.render(i),c="stats"in a?a.stats:a;this._updateStats(c);return}i.effects&&this._preRender(i.effects,i);let r=this.lastPostProcessEffect?this.renderBuffers[0]:i.target;this.lastPostProcessEffect&&(i.clearColor=[0,0,0,0],i.clearCanvas=!0);let s=t.render({...i,target:r}),o="stats"in s?s.stats:s;i.effects&&(this.lastPostProcessEffect&&(i.clearCanvas=e.clearCanvas===void 0?!0:e.clearCanvas),this._postRender(i.effects,i)),this.renderCount++,De(v6,this,o,e),this._updateStats(o)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}finalize(){let{renderBuffers:e}=this;for(let t of e)t.delete();e.length=0}_updateStats(e){if(!this.stats)return;let t=0;for(let{visibleCount:i}of e)t+=i;this.stats.get("Layers rendered").addCount(t)}_preRender(e,t){this.lastPostProcessEffect=null,t.preRenderStats=t.preRenderStats||{};for(let i of e)t.preRenderStats[i.id]=i.preRender(t),i.postRender&&(this.lastPostProcessEffect=i.id);this.lastPostProcessEffect&&this._resizeRenderBuffers(t.canvasContext)}_resizeRenderBuffers(e=this.device.canvasContext){let{renderBuffers:t}=this,i=e.getDrawingBufferSize(),[r,s]=i;t.length===0&&[0,1].map(o=>{let a=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"},width:r,height:s});t.push(this.device.createFramebuffer({id:`deck-renderbuffer-${o}`,colorAttachments:[a]}))});for(let o of t)o.resize(i)}_postRender(e,t){let{renderBuffers:i}=this,r=t.target??t.canvasContext?.getCurrentFramebuffer()??t.target,s={...t,inputBuffer:i[0],swapBuffer:i[1]};for(let o of e)if(o.postRender){s.target=o.id===this.lastPostProcessEffect?r:void 0;let a=o.postRender(s);s.inputBuffer=a,s.swapBuffer=a===i[0]?i[1]:i[0]}}};ee();var x6={pickedColor:null,pickedObjectIndex:-1};function V_({pickedColors:n,decodePickingColor:e,deviceX:t,deviceY:i,deviceRadius:r,deviceRect:s}){let{x:o,y:a,width:c,height:l}=s,u=r*r,f=-1,d=0;for(let h=0;hu)d+=4*c;else for(let g=0;g=0){let y=g+o-t,b=y*y+m;b<=u&&(u=b,f=d)}d+=4}}if(f>=0){let h=n.slice(f,f+4),p=e(h);if(p){let m=Math.floor(f/4/c),g=f/4-m*c;return{...p,pickedColor:h,pickedX:o+g,pickedY:a+m}}ae.error("Picked non-existent layer. Is picking buffer corrupt?")()}return x6}function W_({pickedColors:n,decodePickingColor:e}){let t=new Map;if(n){for(let i=0;i=0){let s=n.slice(i,i+4),o=s.join(",");if(!t.has(o)){let a=e(s);a?t.set(o,{...a,color:s}):ae.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(t.values())}function Ff({pickInfo:n,viewports:e,pixelRatio:t,x:i,y:r,z:s}){let o=e[0];e.length>1&&(o=w6(n?.pickedViewports||e,{x:i,y:r}));let a;if(o){let c=[i-o.x,r-o.y];s!==void 0&&(c[2]=s),a=o.unproject(c)}return{color:null,layer:null,viewport:o,index:-1,picked:!1,x:i,y:r,pixel:[i,r],coordinate:a,devicePixel:n&&"pickedX"in n?[n.pickedX,n.pickedY]:void 0,pixelRatio:t}}function j_(n){let{pickInfo:e,lastPickedInfo:t,mode:i,layers:r}=n,{pickedColor:s,pickedLayer:o,pickedObjectIndex:a}=e,c=o?[o]:[];if(i==="hover"){let f=t.index,d=t.layerId,h=o?o.props.id:null;if(h!==d||a!==f){if(h!==d){let p=r.find(m=>m.props.id===d);p&&c.unshift(p)}t.layerId=h,t.index=a,t.info=null}}let l=Ff(n),u=new Map;return u.set(null,l),c.forEach(f=>{let d={...l};f===o&&(d.color=s,d.index=a,d.picked=!0),d=zf({layer:f,info:d,mode:i});let h=d.layer;f===o&&i==="hover"&&(t.info=d),u.set(h.id,d),i==="hover"&&h.updateAutoHighlight(d)}),u}function zf({layer:n,info:e,mode:t}){for(;n&&e;){let i=e.layer||null;e.sourceLayer=i,e.layer=n,e=n.getPickingInfo({info:e,mode:t,sourceLayer:i}),n=n.parent}return e}function w6(n,e){for(let t=n.length-1;t>=0;t--){let i=n[t];if(i.containsPixel(e))return i}return n[0]}var Ac=class{constructor(e,t={}){this._pickable=!0,this.device=e,this.stats=t.stats,this.pickLayersPass=new Jr(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){"layerFilter"in e&&(this.layerFilter=e.layerFilter),"_pickable"in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObjectAsync(e){return this._pickClosestObjectAsync(e)}pickObjectsAsync(e){return this._pickVisibleObjectsAsync(e)}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:t,layers:i,viewports:r},s=this.lastPickedInfo.info){let o=s&&s.layer&&s.layer.id,a=s&&s.viewport&&s.viewport.id,c=o?i.find(d=>d.id===o):null,l=a&&r.find(d=>d.id===a)||r[0],u=l&&l.unproject([e-l.x,t-l.y]);return{...s,...{x:e,y:t,viewport:l,coordinate:u,layer:c}}}_resizeBuffer(e=this.device.getDefaultCanvasContext()){if(!this.pickingFBO){let r=this.device.createTexture({format:"rgba8unorm",width:1,height:1,usage:pe.RENDER_ATTACHMENT|pe.COPY_SRC});if(this.pickingFBO=this.device.createFramebuffer({colorAttachments:[r],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float")){let s=this.device.createTexture({format:"rgba32float",width:1,height:1,usage:pe.RENDER_ATTACHMENT|pe.COPY_SRC}),o=this.device.createFramebuffer({colorAttachments:[s],depthStencilAttachment:"depth16unorm"});this.depthFBO=o}}let[t,i]=e.getDrawingBufferSize();this.pickingFBO?.resize({width:t,height:i}),this.depthFBO?.resize({width:t,height:i})}_getPickable(e){if(this._pickable===!1)return null;let t=e.filter(i=>this.pickLayersPass.shouldDrawLayer(i)&&!i.isComposite);return t.length?t:null}async _pickClosestObjectAsync({layers:e,views:t,viewports:i,x:r,y:s,radius:o=0,depth:a=1,mode:c="query",unproject3D:l,canvasContext:u=this.device.getDefaultCanvasContext(),onViewportActive:f,effects:d}){let h=u.cssToDeviceRatio(),p=this._getPickable(e);if(!p||i.length===0)return{result:[],emptyInfo:Ff({viewports:i,x:r,y:s,pixelRatio:h})};this._resizeBuffer(u);let m=u.cssToDevicePixels([r,s],!0),g=[m.x+Math.floor(m.width/2),m.y+Math.floor(m.height/2)],v=Math.round(o*h),{width:y,height:b}=this.pickingFBO,w=this._getPickingRect({deviceX:g[0],deviceY:g[1],deviceRadius:v,deviceWidth:y,deviceHeight:b}),E={x:r-o,y:s-o,width:o*2+1,height:o*2+1},x,T=[],I=new Set;for(let N=0;N0){let{pickedColors:V}=await this._drawAndSampleAsync({layers:W,views:t,viewports:i,onViewportActive:f,deviceRect:{x:D.pickedX??g[0],y:D.pickedY??g[1],width:1,height:1},cullRect:E,effects:d,pass:`picking:${c}:z`,canvasContext:u},!0);V[3]&&(H=V[0])}D.pickedLayer&&N+10){let{pickedColors:V}=this._drawAndSample({layers:W,views:t,viewports:i,onViewportActive:f,deviceRect:{x:D.pickedX??g[0],y:D.pickedY??g[1],width:1,height:1},cullRect:E,effects:d,pass:`picking:${c}:z`,canvasContext:u},!0);V[3]&&(H=V[0])}D.pickedLayer&&N+1=l);H++){let W=T[H],V={color:W.pickedColor,layer:null,index:W.pickedObjectIndex,picked:!0,x:r,y:s,pixelRatio:p};V=zf({layer:W.pickedLayer,info:V,mode:c});let X=V.layer.id;I.has(X)||I.set(X,new Set);let Y=I.get(X),ie=V.object??V.index;Y.has(ie)||(Y.add(ie),N.push(V))}return N}_pickVisibleObjects({layers:e,views:t,viewports:i,x:r,y:s,width:o=1,height:a=1,mode:c="query",maxObjects:l=null,canvasContext:u=this.device.getDefaultCanvasContext(),onViewportActive:f,effects:d}){let h=this._getPickable(e);if(!h||i.length===0)return[];this._resizeBuffer(u);let p=u.cssToDeviceRatio(),m=u.cssToDevicePixels([r,s],!0),g=m.x,v=m.y+m.height,y=u.cssToDevicePixels([r+o,s+a],!0),b=y.x+y.width,w=y.y,E={x:g,y:w,width:b-g,height:v-w},x=this._drawAndSample({layers:h,views:t,viewports:i,onViewportActive:f,deviceRect:E,cullRect:{x:r,y:s,width:o,height:a},effects:d,pass:`picking:${c}`,canvasContext:u}),T=W_(x),I=new Map,N=[],D=Number.isFinite(l);for(let H=0;H=l);H++){let W=T[H],V={color:W.pickedColor,layer:null,index:W.pickedObjectIndex,picked:!0,x:r,y:s,pixelRatio:p};V=zf({layer:W.pickedLayer,info:V,mode:c});let X=V.layer.id;I.has(X)||I.set(X,new Set);let Y=I.get(X),ie=V.object??V.index;Y.has(ie)||(Y.add(ie),N.push(V))}return N}async _drawAndSampleAsync({layers:e,views:t,viewports:i,onViewportActive:r,deviceRect:s,cullRect:o,effects:a,pass:c,canvasContext:l},u=!1){let f=u?this.depthFBO:this.pickingFBO,d={layers:e,layerFilter:this.layerFilter,views:t,viewports:i,onViewportActive:r,pickingFBO:f,deviceRect:s,cullRect:o,effects:a,pass:c,canvasContext:l,pickZ:u,preRenderStats:{},isPicking:!0};for(let E of a)E.useInPicking&&(d.preRenderStats[E.id]=E.preRender(d));let{decodePickingColor:h,stats:p}=this.pickLayersPass.render(d);this._updateStats(p);let{x:m,y:g,width:v,height:y}=s,b=f.colorAttachments[0]?.texture;if(!b)throw new Error("Picking framebuffer color attachment is missing");let w=await this._readTextureDataAsync(b,{x:m,y:g,width:v,height:y},u?Float32Array:Uint8Array);if(!u){let E=!1;for(let x=3;x0&&ae.warn("Async pick readback returned only zero alpha values",{deviceRect:s,bytes:Array.from(w.subarray(0,Math.min(w.length,16)))})()}return{pickedColors:w,decodePickingColor:h}}async _readTextureDataAsync(e,t,i){let{width:r,height:s}=t,o=e.computeMemoryLayout(t),a=this.device.createBuffer({byteLength:o.byteLength,usage:re.COPY_DST|re.MAP_READ});try{e.readBuffer(t,a);let c=await a.readAsync(0,o.byteLength),l=i.BYTES_PER_ELEMENT;if(o.bytesPerRow%l!==0)throw new Error(`Texture readback row stride ${o.bytesPerRow} is not aligned to ${l}-byte elements.`);let u=new i(c.buffer,c.byteOffset,o.byteLength/l),f=r*4,d=o.bytesPerRow/l;if(do.props.operation.includes("terrain"))}_getPickingRect({deviceX:e,deviceY:t,deviceRadius:i,deviceWidth:r,deviceHeight:s}){let o=Math.max(0,e-i),a=Math.max(0,t-i),c=Math.min(r,e+i+1)-o,l=Math.min(s,t+i+1)-a;return c<=0||l<=0?null:{x:o,y:a,width:c,height:l}}};var E6={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},S6="top-left",n2="root",Uf=class{constructor({deck:e,parentElement:t}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,t?.classList.add("deck-widget-container"),this.parentElement=t}getWidgets(){return this.resolvedWidgets}setProps(e){if(e.widgets&&!xe(e.widgets,this.widgets,1)){let t=e.widgets.filter(Boolean);this._setWidgets(t)}}finalize(){for(let e of this.getWidgets())this._removeWidget(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(let e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(t=>t.id===e.id)||(this._addWidget(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}onRedraw({viewports:e,layers:t}){let i=e.reduce((r,s)=>(r[s.id]=s,r),{});for(let r of this.getWidgets()){let{viewId:s}=r;if(s){let o=i[s];o&&(r.onViewportChange&&r.onViewportChange(o),r.onRedraw?.({viewports:[o],layers:t}))}else{if(r.onViewportChange)for(let o of e)r.onViewportChange(o);r.onRedraw?.({viewports:e,layers:t})}}this.lastViewports=i,this._updateContainers()}onHover(e,t){for(let i of this.getWidgets()){let{viewId:r}=i;(!r||r===e.viewport?.id)&&i.onHover?.(e,t)}}getCanvasBounds(e){let i=this.deck?.getCanvas?.()?.getBoundingClientRect(),r=this.parentElement?.getBoundingClientRect(),s=this.deck?.getCanvasContext?.(e?.id);if(s&&r){s.updatePosition();let[o,a]=s.getPosition(),[c,l]=s.getCSSSize();return{x:o-r.left,y:a-r.top,width:c,height:l}}return{x:i&&r?i.left-r.left:0,y:i&&r?i.top-r.top:0,width:i?.width||this.deck?.width||0,height:i?.height||this.deck?.height||0}}onEvent(e,t){let i=ao[t.type];if(i)for(let r of this.getWidgets()){let{viewId:s}=r;(!s||s===e.viewport?.id)&&r[i]?.(e,t)}}_setWidgets(e){let t={};for(let i of this.resolvedWidgets)t[i.id]=i;this.resolvedWidgets.length=0;for(let i of this.defaultWidgets)t[i.id]=null,this.resolvedWidgets.push(i);for(let i of e){let r=t[i.id];r?r.viewId!==i.viewId||r.placement!==i.placement?(this._removeWidget(r),this._addWidget(i)):i!==r&&(r.setProps(i.props),i=r):this._addWidget(i),t[i.id]=null,this.resolvedWidgets.push(i)}for(let i in t){let r=t[i];r&&this._removeWidget(r)}this.widgets=e}_addWidget(e){let{viewId:t=null,placement:i=S6}=e,r=e.props._container??t;e.widgetManager=this,e.deck=this.deck,e.rootElement=e._onAdd({deck:this.deck,viewId:t}),e.rootElement&&this._getContainer(r,i).append(e.rootElement),e.updateHTML()}_removeWidget(e){e.onRemove?.(),e.rootElement&&e.rootElement.remove(),e.rootElement=void 0,e.deck=void 0,e.widgetManager=void 0}_getContainer(e,t){if(e&&typeof e!="string")return e;let i=e||n2,r=this.containers[i];r||(r=document.createElement("div"),r.style.pointerEvents="none",r.style.position="absolute",r.style.overflow="hidden",this.parentElement?.append(r),this.containers[i]=r);let s=r.querySelector(`.${t}`);return s||(s=globalThis.document.createElement("div"),s.className=t,s.style.position="absolute",s.style.zIndex="2",Object.assign(s.style,E6[t]),r.append(s)),s}_updateContainers(){for(let e in this.containers){let t=this.lastViewports[e]||null,i=e===n2||t,r=this.containers[e];if(i){let s=this._getContainerBounds(t);r.style.display="block",r.style.left=`${s.x}px`,r.style.top=`${s.y}px`,r.style.width=`${s.width}px`,r.style.height=`${s.height}px`}else r.style.display="none"}}_getContainerBounds(e){if(!e)return{x:0,y:0,width:this.parentElement?.clientWidth||this.deck.width,height:this.parentElement?.clientHeight||this.deck.height};let t=this.getCanvasBounds(e);return{x:t.x+e.x,y:t.y+e.y,width:e.width,height:e.height}}};function H_(n,e){e&&Object.entries(e).map(([t,i])=>{t.startsWith("--")?n.style.setProperty(t,i):n.style[t]=i})}function i2(n,e){e&&Object.keys(e).map(t=>{t.startsWith("--")?n.style.removeProperty(t):n.style[t]=""})}var So=class{constructor(e){this.viewId=null,this.props={...this.constructor.defaultProps,...e},this.id=this.props.id}setProps(e){let t=this.props,i=this.rootElement;i&&t.className!==e.className&&(t.className&&i.classList.remove(t.className),e.className&&i.classList.add(e.className)),i&&!xe(t.style,e.style,1)&&(i2(i,t.style),H_(i,e.style)),Object.assign(this.props,e),this.updateHTML()}updateHTML(){this.rootElement&&this.onRenderHTML(this.rootElement)}get viewIds(){return this.viewId?[this.viewId]:this.deck?.getViews().map(e=>e.id)??[]}getViewState(e){return this.deck?.viewManager?.getViewState(e)||{}}setViewState(e,t){this.deck?._onViewStateChange({viewId:e,viewState:t,interactionState:{}})}onCreateRootElement(){let e=["deck-widget",this.className,this.props.className],t=document.createElement("div");return e.filter(i=>typeof i=="string"&&i.length>0).forEach(i=>t.classList.add(i)),H_(t,this.props.style),t}_onAdd(e){return this.onAdd(e)??this.onCreateRootElement()}onAdd(e){}onRemove(){}onViewportChange(e){}onRedraw(e){}onHover(e,t){}onClick(e,t){}onDrag(e,t){}onDragStart(e,t){}onDragEnd(e,t){}};So.defaultProps={id:"widget",style:{},_container:null,className:""};var P6={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"},kc=class extends So{constructor(e={}){super(e),this.id="default-tooltip",this.placement="fill",this.className="deck-tooltip",this.isVisible=!1,this.setProps(e)}onCreateRootElement(){let e=document.createElement("div");return e.className=this.className,Object.assign(e.style,P6),e}onRenderHTML(e){}onViewportChange(e){this.isVisible&&e.id===this.lastViewport?.id&&!e.equals(this.lastViewport)&&this.setTooltip(null),this.lastViewport=e}onHover(e){let{deck:t}=this,i=t&&t.props.getTooltip;if(!i)return;let r=i(e),s=this.widgetManager?.getCanvasBounds(e.viewport),o=e.x+(s?.x||0),a=e.y+(s?.y||0);this.setTooltip(r,o,a)}setTooltip(e,t,i){let r=this.rootElement;if(r){if(typeof e=="string")r.innerText=e;else if(e)e.text&&(r.innerText=e.text),e.html&&(r.innerHTML=e.html),e.className&&(r.className=e.className);else{this.isVisible=!1,r.style.display="none";return}this.isVisible=!0,r.style.display="block",r.style.transform=`translate(${t}px, ${i}px)`,e&&typeof e=="object"&&"style"in e&&Object.assign(r.style,e.style)}}};kc.defaultProps={...So.defaultProps};var Rc=class{constructor(e){this.targets={},this.order=[],this.eventManagers={},this._eventRootToCanvasId=new WeakMap,this._createEventManager=e.createEventManager,this._getEventRoot=e.getEventRoot}finalize(){for(let e of Object.values(this.targets))e.eventManager.destroy(),e.presentationContext.destroy();this.targets={},this.order=[],this.eventManagers={},this._eventRootToCanvasId=new WeakMap}syncCanvasEntries(e){let t=this._normalizeCanvasList(e.canvases),i={},r=[],s=new Map;for(let{canvas:a}of t){let c=this._getEventRoot(a);s.set(c,(s.get(c)||0)+1)}for(let{id:a,canvas:c}of t){let l=this._getEventRoot(c),u=s.get(l)===1?l:c,f=this.targets[a];if(!f||f.device!==e.device||f.canvas!==c||f.eventRoot!==u){f?.eventManager.destroy(),f?.presentationContext.destroy();let d=e.device.createPresentationContext({id:a,canvas:c,useDevicePixels:e.useDevicePixels,autoResize:!0});f={id:a,device:e.device,canvas:c,eventRoot:u,presentationContext:d,eventManager:this._createEventManager(u)}}this._eventRootToCanvasId.set(u,a),this._eventRootToCanvasId.set(c,a),i[a]=f,r.push(a)}for(let[a,c]of Object.entries(this.targets))i[a]||(c.eventManager.destroy(),c.presentationContext.destroy());this.targets=i,this.order=r;let o=Object.fromEntries(Object.entries(i).map(([a,c])=>[a,c.eventManager]));this._haveSameEventManagers(o)||(this.eventManagers=o)}getCanvasIdFromEvent(e){return e?this._eventRootToCanvasId.get(e):void 0}getTarget(e){return this.targets[e||this.order[0]||Qi]||null}_normalizeCanvasList(e=[]){let t=new Set;return e.map((i,r)=>{let s,o;return typeof i=="string"?(s=document.getElementById(i),me(s,`Canvas with id ${i} not found`),o=i):(s=i,o=s.id||`deckgl-canvas-${r}`),me(!t.has(o),`Duplicate canvas id ${o}`),t.add(o),{id:o,canvas:s}})}_haveSameEventManagers(e){let t=Object.keys(e),i=Object.keys(this.eventManagers);return t.length===i.length&&t.every(r=>e[r]===this.eventManagers[r])}};ee();yd();Ce();Ce();la();function xi(){}var Dz=({isDragging:n})=>n?"grabbing":"grab",MP={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,pickAsync:"auto",layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{},gl:null,canvas:null,_canvases:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:xi,onWebGLInitialized:xi,onResize:xi,onViewStateChange:xi,onInteractionStateChange:xi,onBeforeRender:xi,onAfterRender:xi,onLoad:xi,onError:n=>ae.error(n.message,n.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:Dz,getTooltip:null,debug:!1,drawPickingColors:!1},Wc=class{constructor(e){this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.eventManagers={},this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this._canvasContext=null,this._deviceResizeHandler=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new Vt({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,layersCount:0,drawLayersCount:0,updateLayersCount:0,updateAttributesCount:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,pickLayersCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._hoverPickSequence=0,this._pointerDownPickSequence=0,this._needsRedraw="Initial render",this._canvasManager=new Rc({createEventManager:r=>this._createEventManager(r),getEventRoot:r=>this._getEventRoot(r)}),this._ownedCanvas=null,this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,canvasId:void 0,event:null,unproject3D:!1},this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this._onPointerMove=r=>{let{_pickRequest:s}=this,o=this._getCanvasIdFromEvent(r);if(r.type==="pointerleave")s.x=-1,s.y=-1,s.radius=0,s.canvasId=o;else{if(r.leftButton||r.rightButton)return;{let a=r.offsetCenter;if(!a)return;s.x=a.x,s.y=a.y,s.radius=this.props.pickingRadius,s.canvasId=o}}this.layerManager&&(this.layerManager.context.mousePosition={x:s.x,y:s.y}),s.event=r},this._onEvent=r=>{let s=ao[r.type],o=r.offsetCenter,a=this._getCanvasIdFromEvent(r);if(!s||!o||!this.layerManager)return;let c=this.layerManager.getLayers(),l=this._getInternalPickingMode();if(!l)return;if(l==="sync"){let f=r.type==="click"&&this._shouldUnproject3D(c)?this._getFirstPickedInfo(this._pickPointSync(this._getPointPickOptions(o.x,o.y,{unproject3D:!0,canvasId:a},c))):this._getLastPointerDownPickingInfo(o.x,o.y,a,c);this._dispatchPickingEvent(f,r);return}(this._lastPointerDownInfoPromise||Promise.resolve(this._getLastPointerDownPickingInfo(o.x,o.y,a,c))).then(f=>{this._dispatchPickingEvent(f,r)}).catch(f=>this.props.onError?.(f))},this._onPointerDown=r=>{let s=r.offsetCenter,o=this._getCanvasIdFromEvent(r);if(!s)return;let a=this._getInternalPickingMode();if(!a)return;let c=this.layerManager?.getLayers()||[],l=++this._pointerDownPickSequence;if(a==="sync"){let f=this._pickPointSync({x:s.x,y:s.y,canvasId:o,radius:this.props.pickingRadius}),d=this._getFirstPickedInfo(f);this._lastPointerDownInfo=d,this._lastPointerDownInfoPromise=Promise.resolve(d);return}let u=this._pickPointAsync(this._getPointPickOptions(s.x,s.y,{canvasId:o},c)).then(f=>this._getFirstPickedInfo(f)).then(f=>(l===this._pointerDownPickSequence&&(this._lastPointerDownInfo=f),f)).catch(f=>{this.props.onError?.(f);let d=this.deckPicker&&this.viewManager?this._getLastPointerDownPickingInfo(s.x,s.y,o,c):{};return l===this._pointerDownPickSequence&&(this._lastPointerDownInfo=d),d});this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=u};let t=e;this.props={...MP,...e},e=this.props,this._validateCanvasConfiguration(e),e.viewState&&e.initialViewState&&ae.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,e.device&&(this.device=e.device,this._setDeviceCanvasContext(e.device));let i=this.device;!i&&e.gl&&(e.gl instanceof WebGLRenderingContext&&ae.error("WebGL1 context not supported.")(),i=Vc.attach(e.gl,{_cacheShaders:!0,_cachePipelines:!0,...this.props.deviceProps})),i||(i=this._createDevice(e)),this.animationLoop=this._createAnimationLoop(i,e),this.setProps(t),e._typedArrayManagerProps&&hn.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){this._restoreDeviceResizeHandler(),this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._hoverPickSequence++,this._pointerDownPickSequence++,this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this.layerManager?.finalize(),this.layerManager=null,this.viewManager?.finalize(),this.viewManager=null,this.effectManager?.finalize(),this.effectManager=null,this.deckRenderer?.finalize(),this.deckRenderer=null,this.deckPicker?.finalize(),this.deckPicker=null,Object.keys(this._canvasManager.targets).length||this.eventManager?.destroy(),this.eventManager=null,this.eventManagers={},this.widgetManager?.finalize(),this.widgetManager=null,this._canvasManager.finalize(),this._isMultiCanvasMode()?this.canvas=null:this.canvas&&this.canvas===this._ownedCanvas&&(this.canvas.parentElement?.removeChild(this.canvas),this.canvas=null,this._ownedCanvas=null),this._canvasContext=null}setProps(e){this.stats.get("setProps Time").timeStart(),"onLayerHover"in e&&ae.removed("onLayerHover","onHover")(),"onLayerClick"in e&&ae.removed("onLayerClick","onClick")(),e.initialViewState&&!xe(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),me(!("_canvases"in e)||Array.isArray(e._canvases)===this._isMultiCanvasMode()),Object.assign(this.props,e),this._validateCanvasConfiguration(this.props),this._validateInternalPickingMode(),this.device&&this._isMultiCanvasMode()&&this._syncCanvasTargets(),this._setCanvasSize(this.props);let t=Object.create(this.props);if(Object.assign(t,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState(),eventManagers:this.eventManagers}),e.device&&e.device.id!==this.device?.id){let i=e.device.getDefaultCanvasContext();this.animationLoop?.stop(),!this._isMultiCanvasMode()&&this.canvas!==i.canvas&&(this.canvas?.remove(),this.eventManager?.destroy(),this.canvas=null),this._setDeviceCanvasContext(e.device),ae.log(`recreating animation loop for new device! id=${e.device.id}`)(),this.animationLoop=this._createAnimationLoop(e.device,e),this.animationLoop.start()}if(this.animationLoop?.setProps(t),e.useDevicePixels!==void 0&&this._canvasContext?.setProps){this._canvasContext.setProps({useDevicePixels:e.useDevicePixels});for(let i of Object.values(this._canvasManager.targets))i.presentationContext.setProps({useDevicePixels:e.useDevicePixels})}this.layerManager&&(this.viewManager.setProps(t),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(t),this.effectManager.setProps(t),this.deckRenderer.setProps(t),this.deckPicker.setProps(t),this.widgetManager.setProps(t)),this.stats.get("setProps Time").timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);let i=this.viewManager.needsRedraw(e),r=this.layerManager.needsRedraw(e),s=this.effectManager.needsRedraw(e),o=this.deckRenderer.needsRedraw(e);return t=t||i||r||s||o,t}redraw(e){if(!this.layerManager)return;let t=this.needsRedraw({clearRedrawFlags:!0});t=e||t,t&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(t):this._drawLayers(t))}get isInitialized(){return this.viewManager!==null}getViews(){return me(this.viewManager),this.viewManager.views}getView(e){return me(this.viewManager),this.viewManager.getView(e)}getViewports(e){return me(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}getCanvasContext(e){let t=e?this.viewManager?.getView(e)?.props.canvasId:void 0;return this._getCanvasContext(t)}getEventManager(e){if(!e||!this.viewManager)return this.eventManager;let t=this.viewManager.getCanvasId(e)||Qi;return this.eventManagers[t]||this.eventManager}async pickObjectAsync(e){let t=(await this._pickAsync("pickObjectAsync","pickObject Time",e)).result;return t.length?t[0]:null}async pickObjectsAsync(e){return await this._pickAsync("pickObjectsAsync","pickObjects Time",e)}pickObject(e){let t=this._pick("pickObject","pickObject Time",e).result;return t.length?t[0]:null}pickMultipleObjects(e){return e.depth=e.depth||10,this._pick("pickObject","pickMultipleObjects Time",e).result}pickObjects(e){return this._pick("pickObjects","pickObjects Time",e)}_pickPositionForController(e,t,i){return this._getInternalPickingMode()!=="sync"?null:this.pickObject({x:e,y:t,radius:0,unproject3D:!0,canvasId:i?this.viewManager?.getCanvasId(i):void 0})}_addResources(e,t=!1){for(let i in e)this.layerManager.resourceManager.add({resourceId:i,data:e[i],forceUpdate:t})}_removeResources(e){for(let t of e)this.layerManager.resourceManager.remove(t)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_addDefaultShaderModule(e){this.layerManager.addDefaultShaderModule(e)}_removeDefaultShaderModule(e){this.layerManager?.removeDefaultShaderModule(e)}_resolveInternalPickingMode(){let{pickAsync:e}=this.props,t=this.device?.type||this.props.deviceProps?.type;if(e==="auto")return t==="webgpu"?"async":"sync";if(e==="sync"&&t==="webgpu")throw new Error('`pickAsync: "sync"` is not supported when Deck is using a WebGPU device.');return e}_getInternalPickingMode(){try{return this._resolveInternalPickingMode()}catch(e){return this.props.onError?.(e),null}}_validateInternalPickingMode(){this._getInternalPickingMode()}_getFirstPickedInfo({result:e,emptyInfo:t}){return e[0]||t}_shouldUnproject3D(e=this.layerManager?.getLayers()||[]){return e.some(t=>t.props.pickable==="3d")}_getPointPickOptions(e,t,i={},r=this.layerManager?.getLayers()||[]){return{x:e,y:t,canvasId:i.canvasId,radius:this.props.pickingRadius,unproject3D:this._shouldUnproject3D(r),...i}}_pickPointSync(e){return this._pick("pickObject","pickObject Time",e)}_pickPointAsync(e){return this._pickAsync("pickObjectAsync","pickObject Time",e)}_getLastPointerDownPickingInfo(e,t,i,r=this.layerManager?.getLayers()||[]){return this.deckPicker.getLastPickedObject({x:e,y:t,layers:r,viewports:this.getViewports({x:e,y:t,canvasId:i})},this._lastPointerDownInfo)}_applyHoverCallbacks({result:e,emptyInfo:t},i){if(!this.widgetManager)return;this.cursorState.isHovering=e.length>0;let r=t,s=!1;for(let o of e)r=o,s=o.layer?.onHover(o,i)||s;s||(this.props.onHover?.(r,i),this.widgetManager.onHover(r,i))}_dispatchPickingEvent(e,t){if(!this.layerManager||!this.widgetManager)return;let i=ao[t.type];if(!i)return;let{layer:r}=e,s=r&&(r[i]||r.props[i]),o=this.props[i],a=!1;s&&(a=s.call(r,e,t)),a||(o?.(e,t),this.widgetManager.onEvent(e,t))}_pickAsync(e,t,i){me(this.deckPicker);let{stats:r}=this,s=this._isMultiCanvasMode()?i.canvasId||this._getDefaultCanvasId():i.canvasId,o=this._getCanvasContext(s)||void 0;r.get("Pick Count").incrementCount(),r.get(t).timeStart(),this._resizeForCanvasTarget(s);let a=this.deckPicker[e]({layers:this.layerManager.getLayers(i),views:this.viewManager.getViews(),viewports:this.getViewports({...i,canvasId:s}),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...i,canvasId:s,canvasContext:o});return r.get(t).timeEnd(),a}_pick(e,t,i){me(this.deckPicker);let{stats:r}=this,s=this._isMultiCanvasMode()?i.canvasId||this._getDefaultCanvasId():i.canvasId,o=this._getCanvasContext(s)||void 0;r.get("Pick Count").incrementCount(),r.get(t).timeStart(),this._resizeForCanvasTarget(s);let a=this.deckPicker[e]({layers:this.layerManager.getLayers(i),views:this.viewManager.getViews(),viewports:this.getViewports({...i,canvasId:s}),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...i,canvasId:s,canvasContext:o});return r.get(t).timeEnd(),a}_createCanvas(e){let t=e.canvas;return typeof t=="string"&&(t=document.getElementById(t),me(t)),t?this._ownedCanvas=null:(t=document.createElement("canvas"),t.id=e.id||"deckgl-overlay",e.width&&typeof e.width=="number"&&(t.width=e.width),e.height&&typeof e.height=="number"&&(t.height=e.height),(e.parent||document.body).appendChild(t),this._ownedCanvas=t),Object.assign(t.style,e.style),t}_isMultiCanvasMode(){return Array.isArray(this.props._canvases)}_getDefaultCanvasId(){return this._canvasManager.order[0]||Qi}_validateCanvasConfiguration(e){Array.isArray(e._canvases)&&(me(!e.canvas),me(!e.gl),me(!e.device?.canvasContext||e.device.getDefaultCanvasContext().offscreenCanvas))}_createEventManager(e){let t=new rc(e,{touchAction:this.props.touchAction,recognizers:Object.keys(m_).map(i=>{let[r,s,o,a]=m_[i],c=this.props.eventRecognizerOptions?.[i],l={...s,...c,event:i};return{recognizer:new r(l),recognizeWith:o,requireFailure:a}}),events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(let i in ao)i==="dblclick"?t.watch(i,this._onEvent):t.on(i,this._onEvent);return t}_getEventRoot(e){return e.closest(".deck-events-root")||this.props.parent?.querySelector(".deck-events-root")||e}_syncCanvasTargets(){if(!this.device||!this._isMultiCanvasMode())return;this._canvasManager.syncCanvasEntries({device:this.device,canvases:this.props._canvases||[],useDevicePixels:this.props.useDevicePixels}),this.eventManagers=this._canvasManager.eventManagers;let e=this._getDefaultCanvasId();this.eventManager=this.eventManagers[e]||null,this.canvas=this._canvasManager.targets[e]?.canvas||null}_setCanvasContext(e){this._canvasContext=e,"style"in e.canvas&&(this.canvas=e.canvas)}_setDeviceCanvasContext(e,t={}){let i=e.getDefaultCanvasContext();this._setCanvasContext(i),this._setDeviceResizeHandler(e,t)}_setDeviceResizeHandler(e,t={}){let i=!!t.syncDrawingBuffer;if(this._deviceResizeHandler?.device===e){this._deviceResizeHandler.syncDrawingBuffer=i;return}this._restoreDeviceResizeHandler();let r=s=>{this._isMultiCanvasMode()?this._updateMultiCanvasDimensions():s===this._canvasContext&&this._canvasContext&&this._onCanvasContextResize(this._canvasContext,{syncDrawingBuffer:this._deviceResizeHandler?.syncDrawingBuffer})};e.props.onResize=r,this._deviceResizeHandler={device:e,onResize:r,syncDrawingBuffer:i}}_restoreDeviceResizeHandler(){let e=this._deviceResizeHandler;e&&e.device.props?.onResize===e.onResize&&(e.device.props.onResize=xi),this._deviceResizeHandler=null}_setCanvasSize(e){if(this._isMultiCanvasMode()||!this.canvas)return;let{width:t,height:i}=e;if(t||t===0){let r=Number.isFinite(t)?`${t}px`:t;this.canvas.style.width=r}if(i||i===0){let r=Number.isFinite(i)?`${i}px`:i;this.canvas.style.position=e.style?.position||"absolute",this.canvas.style.height=r}}_getCanvasIdFromEvent(e){return this._canvasManager.getCanvasIdFromEvent(e?.rootElement)}_getCanvasContext(e){return this._canvasManager.getTarget(e)?.presentationContext||this._canvasContext}_resizeForCanvasTarget(e){let t=this._canvasManager.getTarget(e);if(!t||!this.device?.canvasContext)return;let[i,r]=t.presentationContext.getDrawingBufferSize();this.device.canvasContext.setDrawingBufferSize(i,r)}_createDeviceCanvas(e){if(this._isMultiCanvasMode()){let t=globalThis.OffscreenCanvas;if(!t)throw new Error("`_canvases` requires OffscreenCanvas support.");let i=typeof e.width=="number"&&Number.isFinite(e.width)?e.width:1,r=typeof e.height=="number"&&Number.isFinite(e.height)?e.height:1;return new t(i,r)}return this._createCanvas(e)}_updateCanvasSize(e=this._canvasContext){if(this._isMultiCanvasMode()){this._updateMultiCanvasDimensions();return}let{canvas:t}=this,[i,r]=e?e.getCSSSize():[t?.clientWidth??t?.width??0,t?.clientHeight??t?.height??0];(i!==this.width||r!==this.height)&&(this.width=i,this.height=r,this.viewManager?.setProps({width:i,height:r}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:i,height:r},e||void 0))}_onCanvasContextResize(e,t={}){if(t.syncDrawingBuffer){let{width:i,height:r}=e.canvas;e.setDrawingBufferSize(i,r)}this._needsRedraw="Canvas resized",this._updateCanvasSize(e)}_updateMultiCanvasDimensions(){let[e,t]=this._getCanvasContext()?.getCSSSize()||[0,0];(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.props.onResize({width:e,height:t})),this._needsRedraw="Canvas resized",this.viewManager?.setNeedsUpdate("Canvas resized"),this.viewManager?.setProps({width:this.width,height:this.height})}_createAnimationLoop(e,t){let{gl:i,onError:r}=t;return new mc({device:e,autoResizeDrawingBuffer:!i&&!Array.isArray(t._canvases),autoResizeViewport:!1,onInitialize:s=>this._setDevice(s.device),onRender:this._onRenderFrame.bind(this),onError:r})}_createDevice(e){let t=this.props.deviceProps?.createCanvasContext,i=typeof t=="object"?t:void 0,r={adapters:[],_cacheShaders:!0,_cachePipelines:!0,...e.deviceProps};r.adapters.includes(Vc)||r.adapters.push(Vc);let s={alphaMode:this.props.deviceProps?.type==="webgpu"?"premultiplied":void 0};return Vs.createDevice({_reuseDevices:!0,type:"webgl",...r,createCanvasContext:{...s,...i,canvas:this._createDeviceCanvas(e),useDevicePixels:this.props.useDevicePixels,autoResize:!0}})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let{views:e}=this.props,t=Array.isArray(e)?e:e?[e]:[new t2({id:"default-view"})];return t.length&&this.props.controller&&(t[0]=t[0].clone({controller:this.props.controller})),t}_onContextLost(){let{onError:e}=this.props;this.animationLoop&&e&&e(new Error("WebGL context is lost"))}_pickAndCallback(){let{_pickRequest:e}=this;if(e.event){let t=e.event,i=this.layerManager?.getLayers()||[],r=this._getPointPickOptions(e.x,e.y,{canvasId:e.canvasId,radius:e.radius,mode:e.mode},i),s=this._getInternalPickingMode(),o=++this._hoverPickSequence;if(e.event=null,e.canvasId=void 0,!s)return;if(s==="sync"){this._applyHoverCallbacks(this._pickPointSync(r),t);return}this._pickPointAsync(r).then(({result:a,emptyInfo:c})=>{o===this._hoverPickSequence&&this._applyHoverCallbacks({result:a,emptyInfo:c},t)}).catch(a=>this.props.onError?.(a))}}_updateCursor(){let e=this.props.getCursor(this.cursorState);if(this._isMultiCanvasMode()){for(let i of Object.values(this._canvasManager.targets))i.canvas.style.cursor=e;return}let t=this.props.parent||this.canvas;t&&(t.style.cursor=e)}_setDevice(e){if(this.device=e,this._validateInternalPickingMode(),!this.animationLoop)return;this._setDeviceCanvasContext(e,{syncDrawingBuffer:!!(this.props.gl&&this.props.device!==e)}),this._isMultiCanvasMode()?this._syncCanvasTargets():this.canvas&&!this.canvas.isConnected&&this.props.parent&&this.props.parent.insertBefore(this.canvas,this.props.parent.firstChild),this.device.type==="webgl"&&this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),this.device.type==="webgl"&&this.props.onWebGLInitialized(this.device.gl);let t=new Qr;if(t.play(),this.animationLoop.attachTimeline(t),!this._isMultiCanvasMode()){let s=this.canvas&&this._getEventRoot(this.canvas);me(s),this.eventManager=this._createEventManager(s),this.eventManagers={[Qi]:this.eventManager}}this.viewManager=new wc({timeline:t,eventManager:this.eventManager,eventManagers:this.eventManagers,getCanvasContext:this._isMultiCanvasMode()?this.getCanvasContext.bind(this):void 0,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),pickPosition:this._pickPositionForController.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});let i=this.viewManager.getViewports()[0];this.layerManager=new xc(this.device,{deck:this,stats:this.stats,viewport:i,timeline:t}),this.effectManager=new Tc({deck:this,device:this.device}),this.deckRenderer=new Mc(this.device,{stats:this.stats}),this.deckPicker=new Ac(this.device,{stats:this.stats});let r=this.props.parent?.querySelector(".deck-widgets-root")||(this._isMultiCanvasMode()?this.props.parent||this.canvas?.parentElement:null)||this.canvas?.parentElement;this.widgetManager=new Uf({deck:this,parentElement:r}),this.widgetManager.addDefault(new kc),this.setProps({}),this._updateCanvasSize(this._canvasContext),this.props.onLoad()}_drawLayers(e,t){let{device:i,gl:r}=this.layerManager.context;this.props.onBeforeRender({device:i,gl:r});let s={target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:"screen",effects:this.effectManager.getEffects(),...t};if(this._isMultiCanvasMode()&&s.pass==="screen"&&!s.target&&this._canvasManager.order.length)for(let o of this._canvasManager.order){let a=s.viewports.filter(u=>this.viewManager.getCanvasId(u.id)===o);if(!a.length){let u=this._canvasManager.targets[o];this._resizeForCanvasTarget(o),this.deckRenderer?.renderLayers({...s,canvasContext:u.presentationContext,target:u.presentationContext.getCurrentFramebuffer(),viewports:[],clearCanvas:!0}),u.presentationContext.present();continue}let c=this._canvasManager.targets[o];this._resizeForCanvasTarget(o);let l=c.presentationContext.getCurrentFramebuffer();this.deckRenderer?.renderLayers({...s,canvasContext:c.presentationContext,target:l,viewports:a}),c.presentationContext.present()}else this.deckRenderer?.renderLayers(s);s.pass==="screen"&&this.widgetManager.onRedraw({viewports:s.viewports,layers:s.layers}),this.props.onAfterRender({device:i,gl:r})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60===0&&(this._getMetrics(),this.stats.reset(),ae.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCursor(),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){let t=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:t},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(e){this.cursorState.isDragging=e.isDragging||!1,this.props.onInteractionStateChange(e)}_getFrameStats(){let{stats:e}=this;e.get("frameRate").timeEnd(),e.get("frameRate").timeStart();let t=this.animationLoop.stats;e.get("GPU Time").addTime(t.get("GPU Time").lastTiming),e.get("CPU Time").addTime(t.get("CPU Time").lastTiming)}_getMetrics(){let{metrics:e,stats:t}=this;e.fps=t.get("frameRate").getHz(),e.setPropsTime=t.get("setProps Time").time,e.updateAttributesTime=t.get("Update Attributes").time,e.framesRedrawn=t.get("Redraw Count").count,e.pickTime=t.get("pickObject Time").time+t.get("pickMultipleObjects Time").time+t.get("pickObjects Time").time,e.pickCount=t.get("Pick Count").count,e.layersCount=this.layerManager?.layers.length??0,e.drawLayersCount=t.get("Layers rendered").lastSampleCount,e.pickLayersCount=t.get("Layers picked").lastSampleCount,e.updateLayersCount=t.get("Layer updates").count,e.updateAttributesCount=t.get("Attributes updated").count,e.gpuTime=t.get("GPU Time").time,e.cpuTime=t.get("CPU Time").time,e.gpuTimePerFrame=t.get("GPU Time").getAverageTime(),e.cpuTimePerFrame=t.get("CPU Time").getAverageTime();let i=Vs.stats.get("GPU Time and Memory");e.bufferMemory=i.get("Buffer Memory").count,e.textureMemory=i.get("Texture Memory").count,e.renderbufferMemory=i.get("Renderbuffer Memory").count,e.gpuMemory=i.get("GPU Memory").count}};Wc.defaultProps=MP;Wc.VERSION=Dx;var vy=Wc;ee();ee();function AP(n){switch(n){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return Lr(n)}}var kP=Ke.getDataType.bind(Ke);function jc(n,e,t){if(e.size>4)return null;let i=t==="webgpu"&&e.type==="uint8"?"unorm8":e.type,r=e.size,s=!!(t!=="webgpu"&&r===3&&i&&["uint8","sint8","unorm8","snorm8","uint16","sint16","unorm16","snorm16"].includes(i));return{attribute:n,format:r>1?`${i}x${r}${s?"-webgl":""}`:e.type,byteOffset:e.offset||0}}function Jt(n){return n.stride||n.size*n.bytesPerElement}function RP(n,e){return n.type===e.type&&n.size===e.size&&Jt(n)===Jt(e)&&(n.offset||0)===(e.offset||0)}function xy(n,e){e.offset&&ae.removed("shaderAttribute.offset","vertexOffset, elementOffset")();let t=Jt(n),i=e.vertexOffset!==void 0?e.vertexOffset:n.vertexOffset||0,r=e.elementOffset||0,s=i*t+r*n.bytesPerElement+(n.offset||0);return{...e,offset:s,stride:t}}function Nz(n,e){let t=xy(n,e);return{high:t,low:{...t,offset:t.offset+n.size*4}}}var Hc=class{constructor(e,t,i){this._buffer=null,this.device=e,this.id=t.id||"",this.size=t.size||1;let r=t.logicalType||t.type,s=r==="float64",{defaultValue:o}=t;o=Number.isFinite(o)?[o]:o||new Array(this.size).fill(0);let a;s?a="float32":!r&&t.isIndexed?a="uint32":a=r||"float32";let c=AP(r||a);this.doublePrecision=s,s&&t.fp64===!1&&(c=Float32Array),this.value=null,this.settings={...t,defaultType:c,defaultValue:o,logicalType:r,type:a,normalized:a.includes("norm"),size:this.size,bytesPerElement:c.BYTES_PER_ELEMENT},this.state={...i,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){let e=this.getAccessor();return e.vertexOffset?e.vertexOffset*Jt(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}get isDoublePrecisionBuffer(){return this._shouldSplitDoublePrecisionValue(this.value)}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),hn.release(this.state.allocatedValue),this.state.allocatedValue=null}getBuffer(){return this.state.constant&&this.device.type!=="webgpu"?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,t=null){let i={};if(this.state.constant){let r=this.value;if(this.device.type==="webgpu"&&this._buffer)i[e]=this._buffer;else if(t){let s=xy(this.getAccessor(),t),o=s.offset/r.BYTES_PER_ELEMENT,a=s.size||this.size;i[e]=r.subarray(o,o+a)}else i[e]=r}else i[e]=this.getBuffer();return this.doublePrecision&&(this.isDoublePrecisionBuffer?i[`${e}64Low`]=i[e]:i[`${e}64Low`]=new Float32Array(this.size)),i}_getBufferLayout(e=this.id,t=null){let i=this.getAccessor(),r=[],s={name:this.id,byteStride:this.device.type==="webgpu"&&this.state.constant?0:Jt(i)};if(this.doublePrecision){let o=Nz(i,t||{});r.push(jc(e,{...i,...o.high},this.device.type),jc(`${e}64Low`,{...i,...o.low},this.device.type))}else if(t){let o=xy(i,t);r.push(jc(e,{...i,...o},this.device.type))}else r.push(jc(e,i,this.device.type));return s.attributes=r.filter(Boolean),s}setAccessor(e){this.state.bufferAccessor=e}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let e=null;if(this.state.constant&&this.value){let t=Array.from(this.value);e=[t,t]}else{let{value:t,numInstances:i,size:r}=this,s=i*r;if(t&&s&&t.length>=s){let o=new Array(r).fill(1/0),a=new Array(r).fill(-1/0);for(let c=0;ca[l]&&(a[l]=u)}e=[o,a]}}return this.state.bounds=e,e}setData(e){let{state:t}=this,i;ArrayBuffer.isView(e)?i={value:e}:e instanceof re?i={buffer:e}:i=e;let r={...this.settings,...i};if(ArrayBuffer.isView(i.value)){if(!i.type)if(this.doublePrecision&&i.value instanceof Float64Array)r.type="float32";else{let o=kP(i.value);r.type=r.normalized?o.replace("int","norm"):o}r.bytesPerElement=i.value.BYTES_PER_ELEMENT,r.stride=Jt(r)}if(t.bounds=null,i.constant){let s=i.value;if(s=this._normalizeValue(s,[],0),this.settings.normalized&&(s=this.normalizeConstant(s)),!(!t.constant||!this._areValuesEqual(s,this.value)))return!1;t.externalBuffer=null,t.constant=!0,this.value=ArrayBuffer.isView(s)?s:new Float32Array(s)}else if(i.buffer){let s=i.buffer;t.externalBuffer=s,t.constant=!1,this.value=i.value||null}else if(i.value){this._checkExternalBuffer(i);let s=i.value,o=s;t.externalBuffer=null,t.constant=!1,this.value=s,this._shouldSplitDoublePrecisionValue(o)&&(o=mo(o,r),s instanceof Float32Array&&(r.stride=r.size*2*Float32Array.BYTES_PER_ELEMENT));let{buffer:a}=this,c=Jt(r),l=(r.vertexOffset||0)*c;if(this.settings.isIndexed){let f=this.settings.defaultType;o.constructor!==f&&(o=new f(o))}let u=o.byteLength+l+c*2;(!a||a.byteLength(t+128)/255*2-1);case"snorm16":return new Float32Array(e).map(t=>(t+32768)/65535*2-1);case"unorm8":return new Float32Array(e).map(t=>t/255);case"unorm16":return new Float32Array(e).map(t=>t/65535);default:return e}}_normalizeValue(e,t,i){let{defaultValue:r,size:s}=this.settings;if(Number.isFinite(e))return t[i]=e,t;if(!e){let o=s;for(;--o>=0;)t[i+o]=r[o];return t}switch(s){case 4:t[i+3]=Number.isFinite(e[3])?e[3]:r[3];case 3:t[i+2]=Number.isFinite(e[2])?e[2]:r[2];case 2:t[i+1]=Number.isFinite(e[1])?e[1]:r[1];case 1:t[i+0]=Number.isFinite(e[0])?e[0]:r[0];break;default:let o=s;for(;--o>=0;)t[i+o]=Number.isFinite(e[o])?e[o]:r[o]}return t}_areValuesEqual(e,t){if(!e||!t)return!1;let{size:i}=this;for(let r=0;r0&&(BP.length=n.length,i=BP):i=IP,(e>0||Number.isFinite(t))&&(i=(Array.isArray(i)?i:Array.from(i)).slice(e,t),r.index=e-1),{iterable:i,objectInfo:r}}function Ed(n){return n&&n[Symbol.asyncIterator]}function Sd(n,e){let{size:t,stride:i,offset:r,startIndices:s,nested:o}=e,a=n.BYTES_PER_ELEMENT,c=i?i/a:t,l=r?r/a:0,u=Math.floor((n.length-l)/c);return(f,{index:d,target:h})=>{if(!s){let v=d*c+l;for(let y=0;y=e[1]))return n;let t=[],i=n.length,r=0;for(let s=0;se[1]?t.push(o):e=[Math.min(o[0],e[0]),Math.max(o[1],e[1])]}return t.splice(r,0,e),t}var zz={interpolation:{duration:0,easing:n=>n},spring:{stiffness:.05,damping:.5}};function Pd(n,e){if(!n)return null;Number.isFinite(n)&&(n={type:"interpolation",duration:n});let t=n.type||"interpolation";return{...zz[t],...e,...n,type:t}}var as=class extends Hc{constructor(e,t){super(e,t,{startIndices:null,constantValue:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:Yc}),this.constant=!1,this.settings.update=t.update||(t.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(e){this.state.startIndices=e}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:e=!1}={}){let t=this.state.needsRedraw;return this.state.needsRedraw=t&&!e,t}layoutChanged(){return this.state.layoutChanged}setAccessor(e){var t;(t=this.state).layoutChanged||(t.layoutChanged=!RP(e,this.getAccessor())),super.setAccessor(e)}getUpdateTriggers(){let{accessor:e}=this.settings;return[this.id].concat(typeof e!="function"&&e||[])}supportsTransition(){return!!this.settings.transition}getTransitionSetting(e){if(!e||!this.supportsTransition())return null;let{accessor:t}=this.settings,i=this.settings.transition,r=Array.isArray(t)?e[t.find(s=>e[s])]:e[t];return Pd(r,i)}setNeedsUpdate(e=this.id,t){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),t){let{startRow:i=0,endRow:r=1/0}=t;this.state.updateRanges=DP(this.state.updateRanges,[i,r])}else this.state.updateRanges=Yc}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=OP}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){let{state:t,settings:i}=this;if(i.noAlloc)return!1;if(i.update){let r=this.isConstant;return super.allocate(e,t.updateRanges!==Yc),t.layoutChanged||(t.layoutChanged=r&&this.device.type==="webgpu"),!0}return!1}updateBuffer({numInstances:e,data:t,props:i,context:r}){if(!this.needsUpdate())return!1;let{state:{updateRanges:s},settings:{update:o,noAlloc:a}}=this,c=!0;if(o){for(let[l,u]of s)o.call(r,this,{data:t,startRow:l,endRow:u,props:i,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLengthu?l.set(b,m):(e._normalizeValue(b,v.target,0),H1({target:l,source:v.target,start:m,count:w}));m+=w*u}else e._normalizeValue(b,l,m),m+=u}}_validateAttributeUpdaters(){let{settings:e}=this;if(!(e.noAlloc||typeof e.update=="function"))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){let{value:e}=this,t=Math.min(4,this.size);if(e&&e.length>=t){let i=!0;switch(t){case 4:i=i&&Number.isFinite(e[3]);case 3:i=i&&Number.isFinite(e[2]);case 2:i=i&&Number.isFinite(e[1]);case 1:i=i&&Number.isFinite(e[0]);break;default:i=!1}if(!i)throw new Error(`Illegal attribute generated for ${this.id}`)}}};Si();Ty();Si();var Zc=class n{gpuDataEvaluators;format;length;id;_gpuVector;_ownsGPUDataEvaluators;_destroyed=!1;static fromGPUVector(e){if(e.bufferLayout)throw new Error(`GPUVectorEvaluator.fromGPUVector() does not accept interleaved vector "${e.name}"`);if(e.data.length===0)throw new Error(`GPUVectorEvaluator.fromGPUVector() requires GPUData for "${e.name}"`);return new n({id:e.name,gpuDataEvaluators:e.data.map(t=>ye.fromGPUData(t,{id:e.name})),gpuVector:e,format:e.format})}static fromGPUDataEvaluators(e,t={}){return new n({id:t.id,gpuDataEvaluators:e,format:t.format})}constructor({id:e,gpuDataEvaluators:t,gpuVector:i,format:r}){if(t.length===0)throw new Error("GPUVectorEvaluator requires at least one GPUData evaluator");Qz(t),this.id=e,this.gpuDataEvaluators=t,this.format=r??t[0].format,this.length=t.reduce((s,o)=>s+o.length,0),this._gpuVector=i,this._ownsGPUDataEvaluators=!i}get evaluated(){return!!this._gpuVector}get gpuVector(){if(!this._gpuVector)throw new Error(`${this} not evaluated`);return this._gpuVector}mapGPUData(e){return n.fromGPUDataEvaluators(this.gpuDataEvaluators.map((t,i)=>e(t,i)),{id:this.id})}async evaluate(e,t={}){if(this._destroyed)throw new Error(`GPUVectorEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let i=await Promise.all(this.gpuDataEvaluators.map(a=>a.evaluate(e,t))),r=i[0],s=i.map(qP),o=t.format??this.format??r.format;return this._gpuVector=new ei({type:"data",name:t.name??this.id??"vector",format:o,data:s,stride:r.stride,byteStride:r.byteStride,rowByteLength:r.rowByteLength,bufferLayout:r.bufferLayout}),this._gpuVector}evaluateSync(e,t={}){if(this._destroyed)throw new Error(`GPUVectorEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let i=this.gpuDataEvaluators.map(a=>a.evaluateSync(e,t)),r=i[0],s=i.map(qP),o=t.format??this.format??r.format;return this._gpuVector=new ei({type:"data",name:t.name??this.id??"vector",format:o,data:s,stride:r.stride,byteStride:r.byteStride,rowByteLength:r.rowByteLength,bufferLayout:r.bufferLayout}),this._gpuVector}destroy(){if(this._ownsGPUDataEvaluators)for(let e of this.gpuDataEvaluators)e.destroy();this._gpuVector=void 0,this._destroyed=!0}toString(){return this.id??this.constructor.name}};function Qz(n){let e=n[0];for(let t of n.slice(1))if(t.type!==e.type||t.size!==e.size||t.normalized!==e.normalized||t.format!==e.format)throw new Error("GPUVectorEvaluator requires matching GPUData evaluator layouts")}function qP(n){let[e,...t]=n.data;if(!e||t.length>0)throw new Error(`GPUVectorEvaluator requires one GPUData chunk for "${n.name}"`);return e}Si();ee();var ky={};ui(ky,{arithmetic:()=>ZP,dot:()=>tC,equalAll:()=>nC,extent:()=>KP,fround:()=>QP,gather:()=>JP,interleave:()=>eC,length:()=>iC,segmentedMap:()=>rC,select:()=>sC,sequence:()=>oC,swizzle:()=>aC});Id();function ko({elementWise:n,func:e,inputs:t,output:i,outputBuffer:r}){let s=Array.isArray(t)?t:Object.values(t);for(let p of s)if(!p.value)throw new Error(`${p} does not have CPU value`);let o=i.length,a=i.size,c=new i.ValueType(o*a);for(let p=0;pIe(g,p));if(n)for(let g=0;gv[g]));else e.call(null,c.subarray(p*a,p*a+a),...m)}let l=i.ValueType.BYTES_PER_ELEMENT,u=i.offset/l,f=i.stride/l,d=a,h=c;if(u!==0||f!==d){h=new i.ValueType(u+i.byteLength/l);for(let p=0;p{for(let r of Object.values(n.namedInputs))if(!r.value)throw new Error(`${r} does not have CPU value`);let i=new e.ValueType(e.length*e.size);for(let r=0;r[o,Ie(a,r)]));for(let o=0;oXP(r,e,t));switch(n.op){case"add":return i[0]+i[1];case"subtract":return i[0]-i[1];case"multiply":return i[0]*i[1];case"divide":return i[0]/i[1];case"pow":return Math.pow(i[0],i[1]);case"sqrt":return Math.sqrt(i[0]);case"abs":return Math.abs(i[0]);case"sin":return Math.sin(i[0]);case"cos":return Math.cos(i[0]);case"tan":return Math.tan(i[0]);case"exp":return Math.exp(i[0]);case"log":return Math.log(i[0]);default:{let r=n.op;throw new Error(`Unsupported arithmetic op ${r}`)}}}default:{let i=n;throw new Error(`Unsupported expression node ${i.kind}`)}}}function eU(n,e){let t=Ao[n].arity;if(e!==t)throw new Error(`Arithmetic op '${n}' expects ${t} args, got ${e}`)}var KP=({inputs:n,output:e,target:t})=>{let{sourceValues:i}=n;if(!i.value)throw new Error(`${i} does not have CPU value`);let s=new e.ValueType(e.length*e.size);if(i.length===0)return{success:!1,error:new Error(`${i} is empty`)};for(let o=0;os[l]&&(s[l]=f)}}return t.write(s),{success:!0,value:s}};var QP=({inputs:n,output:e,target:t})=>ko({func:(i,r)=>{let s=i.length/2,o=new Float64Array(r.buffer);for(let a=0;a{let{ids:i,sourceValues:r}=n,s=i.value,o=r.value;if(!s)throw new Error(`${i} does not have CPU value`);if(!o)throw new Error(`${r} does not have CPU value`);let a=new e.ValueType(e.length*e.size),c=new Array(e.size).fill(0);for(let l=0;l=0&&nko({func:(i,...r)=>{let s=0;for(let o of r)i.set(o,s),s+=o.length},inputs:n,output:e,outputBuffer:t});var tC=({inputs:n,output:e,target:t})=>{let{x:i,y:r}=n,s=new e.ValueType(e.length);for(let o=0;o{let{x:i,y:r}=n,s=new e.ValueType(e.length);for(let o=0;o{let{x:i}=n,r=new e.ValueType(e.length);for(let s=0;s{let{segments:i,vertexCount:r}=n,s=i.value;if(!s)throw new Error(`${i} does not have CPU value`);nU(s,i,r);let o=new e.ValueType(e.length*e.size),a=0;for(let c=0;c0&&st)throw new Error(`segmentedMap last segment start must be <= vertexCount, got ${i} > ${t}`)}function My(n,e){return n.offset/n.ValueType.BYTES_PER_ELEMENT+e*(n.stride/n.ValueType.BYTES_PER_ELEMENT)}var sC=async({inputs:n,output:e,target:t})=>{let{condition:i,whenTrue:r,whenFalse:s}=n,o=new e.ValueType(e.length*e.size);for(let a=0;a{let i=new e.ValueType(e.length);for(let r=0;r{let{columns:i}=n;return ko({func:(r,s)=>{for(let o=0;o({...o,...a}));return this._modules[e]=s,s.then(o=>{this._modules[e]=o}).catch(o=>{z.error(`Failed to register ${e} backend: ${o}`)()}),s}if(i&&typeof i.then=="function"){let s=Promise.resolve(i).then(o=>({...o,...t})).then(o=>(this._modules[e]=o,o)).catch(o=>{throw z.error(`Failed to register ${e} backend: ${o}`)(),o});return this._modules[e]=s,s}let r={...i||{},...t};return this._modules[e]=r,Promise.resolve(r)}async get(e,t){let i=this._modules[e];if(!i)if(e==="webgl")i=this.add("webgl",Promise.resolve().then(()=>(NC(),DC)));else if(e==="webgpu")i=this.add("webgpu",Promise.resolve().then(()=>(Vy(),lT)));else throw new Error(`${e} backend not registered`);let s=(await i)[t];if(typeof s!="function")throw new Error(`${e} backend does not implement ${t}`);return s}getSync(e,t){let i=this._modules[e];if(!i)throw new Error(`${e} backend not registered`);if(typeof i.then=="function")throw new Error(`${e} backend is not loaded yet`);let s=i[t];if(typeof s!="function")throw new Error(`${e} backend does not implement ${t}`);return s}clear(){this._modules={}}},No=new Wy;var Gd=class{inputs;dependencies;constructor(e){this.inputs=e,this.dependencies=Array.from(e instanceof Array?e:Object.values(e)).filter(t=>t instanceof ye)}async execute(e,t){return await this._resolveDependencies(e),await this._executeWithHandler(await No.get(this._getHandlerRegistry(e),this.name),t)}executeSync(e,t){this._resolveDependenciesSync(e);let i=this._executeWithHandler(No.getSync(this._getHandlerRegistry(e),this.name),t);if(YU(i))throw new Error(`${this.name} returned a Promise in executeSync()`);return i}shouldExecuteOnCPU(){return this.output.length<=1&&Array.from(this.dependencies).every(e=>!!e.value)}_getHandlerRegistry(e){return this.shouldExecuteOnCPU()?"cpu":e.type}async _resolveDependencies(e){for(let i of this.dependencies)await i.evaluate(e);if(this._getHandlerRegistry(e)==="cpu"||e.type==="null")for(let i of this.dependencies)await i.ensureCPUValue()}_resolveDependenciesSync(e){for(let i of this.dependencies)i.evaluateSync(e);if(this._getHandlerRegistry(e)==="cpu"||e.type==="null")for(let i of this.dependencies)i.ensureCPUValueSync()}_executeWithHandler(e,t){return e({device:t.device,inputs:this.inputs,output:this.output,target:t})}};function YU(n){return typeof n?.then=="function"}function uT(...n){let e=qU(n.map(t=>t.type));return e[0]!=="f"&&n.some(t=>t.normalized)&&(e="float32"),{isConstant:n.every(t=>t.isConstant),type:e,size:n.reduce((t,i)=>Math.max(t,i.size),0),length:n.reduce((t,i)=>Math.max(t,i.length),0)}}function qU(n){let e=0,t=0;for(let i of n){if(i[0]==="f")return"float32";let r=i.endsWith("8")?8:i.endsWith("6")?16:32;i[0]==="u"?e=Math.max(e,r):t=Math.max(t,r)}return e&&!t?`uint${e}`:t&&e<32?`sint${Math.max(t,e*2)}`:"float32"}Si();var jy=class extends Gd{name="interleave";output;constructor(e){super(e);let{isConstant:t,type:i,length:r}=uT(...e);this.output=new ye({isConstant:t,type:i,size:e.reduce((s,o)=>s+o.size,0),length:r,source:this})}toString(){return`_${this.inputs.join("_")}_`}};function Hy(...n){if(n.length===0)throw new Error("interleave() requires at least one input");return n.length===1?Rd(n[0]):new jy(n.map(Rd)).output}Ce();Si();function qy(n,e){let t=XU(e);for(let i of t)i.evaluateSync(n);return ZU(t),e}function ZU(n){let e=new Set(n.flatMap(QU)),t=new Set;for(let i of n)Vd(i,t);for(let i of t)i.evaluated&&!e.has(i.buffer)&&i.destroy()}function XU(n){let e=new Set;return Yy(n,e,new Set),Array.from(e)}function Yy(n,e,t){if(JU(n)){e.add(n);return}if(!(!n||typeof n!="object"||t.has(n))){if(t.add(n),Array.isArray(n)){for(let i of n)Yy(i,e,t);return}if(KU(n))for(let i of Object.values(n))Yy(i,e,t)}}function KU(n){let e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function Vd(n,e){if(n instanceof Zc){for(let i of n.gpuDataEvaluators)Vd(i,e);return}let t=n.source;if(t){if(t instanceof ye){e.has(t)||(e.add(t),Vd(t,e));return}for(let i of t.dependencies)e.has(i)||(e.add(i),Vd(i,e))}}function QU(n){return n instanceof ye?[n.buffer]:n.gpuVector.data.map(e=>e.buffer instanceof nt?e.buffer.buffer:e.buffer)}function JU(n){return n instanceof ye||n instanceof Zc}Vy();var Kc=class{constructor(e,{id:t,isTransitionAttribute:i}){this.packedBuffers={},this.device=e,this.id=t,this.isTransitionAttribute=i,this.device.type==="webgpu"&&No.add("webgpu",{interleave:$d})}hasGroups(e){return this.device.type==="webgpu"&&Object.values(e).some(t=>!!t.settings.bufferGroup)}finalize(){for(let e of Object.values(this.packedBuffers))e.packed.destroy();this.packedBuffers={}}getBufferLayouts(e,t){let i=this._getPackedGroups(e,t,{requireValues:!1,excludeAttributes:{}});return this._getBufferLayouts(e,i,t)}getBindings(e,t,i,r){let s=this._getPackedGroups(e,i,{requireValues:!0,excludeAttributes:r}),o={},a=new Set;for(let c of s.values()){let l=!this.packedBuffers[c.id]||c.attributes.some(u=>!!t[u.id]);o[c.id]=this._getPackedBuffer(c,l);for(let u of c.attributes)a.add(u.id)}return{bufferLayouts:this._getBufferLayouts(e,s,i).filter(c=>!r[c.name]&&!e[c.name]?.settings.isIndexed),buffers:o,groupedAttributeIds:a}}_getPackedGroups(e,t,{requireValues:i,excludeAttributes:r}){let s=new Map;for(let a of Object.values(e)){let c=a.settings.bufferGroup;if(!c)continue;let l=s.get(c)||[];l.push(a),s.set(c,l)}let o=new Map;for(let[a,c]of s){let l=this._getPackedGroup(a,c,t,i,r);l&&o.set(a,l)}return o}_getPackedGroup(e,t,i,r,s){if(t.length<2)return null;let o=t.map(h=>h.getBufferLayout(i)),a=o[0].stepMode,c=Math.max(1,t[0].numInstances),l=r&&t.every(h=>h.isConstant);for(let h=0;hthis._getInterleaveInput(e,r)),i=Hy(...t);return qy(this.device,i),i}_getInterleaveInput(e,t){let i=Jt(t.getAccessor()),r=e.byteOffsets[t.id];if(Xc(`${e.id}.${t.id} rowByteLength`,i),Xc(`${e.id}.${t.id} groupByteOffset`,r),t.isConstant){let c=t.getConstantValue();if(!c)throw new Error(`Attribute group ${e.id} is missing constant value ${t.id}`);return Xc(`${e.id}.${t.id} constant byteOffset`,c.byteOffset),new ye({id:t.id,type:"uint32",size:i/4,isConstant:!0,value:new Uint32Array(c.buffer,c.byteOffset,i/Uint32Array.BYTES_PER_ELEMENT)})}let s=t.getBuffer(),o=t.byteOffset,a=t.getAccessor().stride||i;if(Xc(`${e.id}.${t.id} byteOffset`,o),Xc(`${e.id}.${t.id} stride`,a),!s)throw new Error(`Attribute group ${e.id} cannot interleave missing buffer ${t.id}`);return new ye({id:t.id,type:"uint32",size:i/4,offset:o,stride:a,length:e.rowCount,buffer:s})}};function fT(n){return Math.ceil(n/4)*4}function Xc(n,e){if(e%4!==0)throw new Error(`Attribute buffer groups require 32-bit alignment: ${n}=${e}`)}Ce();bt();function Zy(n){let{source:e,target:t,start:i=0,size:r,getData:s}=n,o=n.end||t.length,a=e.length,c=o-i;if(a>c){t.set(e.subarray(0,c),i);return}if(t.set(e,i),!s)return;let l=a;for(;li(u+a,f)),l=Math.min(r.length,s.length);for(let u=1;ua}){let a=t.isDoublePrecisionBuffer?2:1,c=t.size*a,l=t.byteOffset,u=t.settings.bytesPerElement<4?l/t.settings.bytesPerElement*4:l,f=t.startIndices,d=s&&f,h=t.isConstant;if(!d&&e&&i>=r)return e;let p=t.value instanceof Float64Array?Float32Array:t.value.constructor,m=h?t.value:new p(t.getBuffer().readSyncWebGL(l,r*p.BYTES_PER_ELEMENT).buffer);if(t.settings.normalized&&!h){let b=o;o=(w,E)=>t.normalizeConstant(b(w,E))}let g=h?(b,w)=>o(m,w):(b,w)=>o(m.subarray(b+l,b+l+c),w),v=e?new Float32Array(e.readSyncWebGL(u,i*4).buffer):new Float32Array(0),y=new Float32Array(r);return dT({source:v,target:y,sourceStartIndices:s,targetStartIndices:f,size:c,getData:g}),(!e||e.byteLength[F]):[T];for(let F of R){let O=this.device.beginRenderPass({framebuffer:i,parameters:f,clearColor:a,clearDepth:c,clearStencil:l});try{for(let j of F){let V=this._drawLayersInViewport(O,{target:i,canvasContext:t,shaderModuleProps:d,viewport:j,view:w,pass:v,layers:e.layers,isPicking:e.isPicking},E);b.push(V)}}finally{O.end(),y&&this.device.submit()}a=!1,c=!1,l=!1}}return b}finally{y||this.device.submit()}}_getDrawLayerParams(e,{layers:t,pass:i,isPicking:r=!1,layerFilter:s,cullRect:o,views:a,effects:c,canvasContext:l=this.device.canvasContext,shaderModuleProps:u},f=!1){let d=[],h=r1(this._lastRenderIndex+1),p={layer:t[0],viewport:e,isPicking:r,renderPass:i,cullRect:o},m={};for(let g=0;gE/255):p===!1&&(v=!1),m!==void 0&&(y=m),g!==void 0&&(b=g),this.device.beginRenderPass({framebuffer:s,parameters:{viewport:f,scissorRect:f},clearColor:v,clearDepth:y,clearStencil:b}).end()}}let d={totalCount:t.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:f});for(let h=0;h{let o=r.props._offset,a=r.id,c=r.parent&&r.parent.id,l;if(c&&!(c in e)&&i(r.parent,!1),c in t){let u=t[c]=t[c]||r1(e[c],e);l=u(r,s),t[a]=u}else Number.isFinite(o)?(l=o+(e[c]||0),t[a]=null):l=n;return s&&l>=n&&(n=l+1),e[a]=l,l};return i}function hF(n,{canvasContext:e=n.canvasContext,shaderModuleProps:t,target:i,viewport:r}){let s=t?.project?.devicePixelRatio??e.cssToDeviceRatio(),[,o]=e.getDrawingBufferSize(),a=i?i.height:o,c=r;return[c.x*s,a-(c.y+c.height)*s,c.width*s,c.height*s]}function i1(n,...e){for(let t of e)if(t)for(let i in t)n[i]?Object.assign(n[i],t[i]):n[i]=t[i];return n}var pc=class extends wi{constructor(e,t){super(e,t);let i=e.createTexture({format:"rgba8unorm",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),r=e.createTexture({format:"depth16unorm",width:1,height:1});this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[i],depthStencilAttachment:r})}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null)}getShadowMap(){return this.fbo.colorAttachments[0].texture}render(e){let t=this.fbo,i=this.device.canvasContext.cssToDeviceRatio(),r=e.viewports[0],s=r.width*i,o=r.height*i,a=[1,1,1,1];(s!==t.width||o!==t.height)&&t.resize({width:s,height:o}),super.render({...e,clearColor:a,target:t,pass:"shadow"})}getLayerParameters(e,t,i){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal"}}shouldDrawLayer(e){return e.props.shadowEnabled!==!1}getShaderModuleProps(e,t,i){return{shadow:{project:i.project,drawToShadowMap:!0}}}};var pF={color:[255,255,255],intensity:1},s1=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],mF=[0,0,0,200/255],fo=class{constructor(e={}){this.id="lighting-effect",this.shadowColor=mF,this.shadow=!1,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;let{device:t,deck:i}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(t),i._addDefaultShaderModule(Cf),this.dummyShadowMap=t.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=void 0,this.directionalLights=[],this.pointLights=[];for(let t in e){let i=e[t];switch(i.type){case"ambient":this.ambientLight=i;break;case"directional":this.directionalLights.push(i);break;case"point":this.pointLights.push(i);break;default:}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(t=>t.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:t,viewports:i,onViewportActive:r,views:s}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let o=0;oo.getShadowMap()),dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{},r={enabled:!0,lights:this._getLights(e)},s=e.props.material;return{shadow:i,lighting:r,phongMaterial:s,gouraudMaterial:s}}cleanup(e){for(let t of this.shadowPasses)t.delete();this.shadowPasses.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(Cf))}_calculateMatrices(){let e=[];for(let t of this.directionalLights){let i=new Fe().lookAt({eye:new et(t.direction).negate()});e.push(i)}return e}_createShadowPasses(e){for(let t=0;tr&&(s=r);let o=this._pool,a=e.BYTES_PER_ELEMENT*s,c=o.findIndex(l=>l.byteLength>=a);if(c>=0){let l=new e(o.splice(c,1)[0],0,s);return i&&l.fill(0),l}return new e(s)}_release(e){if(!ArrayBuffer.isView(e))return;let t=this._pool,{buffer:i}=e,{byteLength:r}=i,s=t.findIndex(o=>o.byteLength>=r);s<0?t.push(i):(s>0||t.lengththis.opts.poolSize&&t.shift()}},gn=new S_;ze();function po(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function P_(n,e){let t=n%e;return t<0?e+t:t}function a1(n){return[n[12],n[13],n[14]]}function c1(n){return{left:ho(n[3]+n[0],n[7]+n[4],n[11]+n[8],n[15]+n[12]),right:ho(n[3]-n[0],n[7]-n[4],n[11]-n[8],n[15]-n[12]),bottom:ho(n[3]+n[1],n[7]+n[5],n[11]+n[9],n[15]+n[13]),top:ho(n[3]-n[1],n[7]-n[5],n[11]-n[9],n[15]-n[13]),near:ho(n[3]+n[2],n[7]+n[6],n[11]+n[10],n[15]+n[14]),far:ho(n[3]-n[2],n[7]-n[6],n[11]-n[10],n[15]-n[14])}}var o1=new et;function ho(n,e,t,i){o1.set(n,e,t);let r=o1.len();return{distance:i/r,normal:new et(-n/r,-e/r,-t/r)}}function gF(n){return n-Math.fround(n)}var mc;function mo(n,e){let{size:t=1,startIndex:i=0}=e,r=e.endIndex!==void 0?e.endIndex:n.length,s=(r-i)/t;mc=gn.allocate(mc,s,{type:Float32Array,size:t*2});let o=i,a=0;for(;ow.useInPicking),pass:h,canvasContext:m,isPicking:!0,shaderModuleProps:g,clearColor:v??[0,0,0,0],colorMask:15,scissorRect:b});return this._colorEncoderState=null,{decodePickingColor:y&&r6.bind(null,y),stats:x}}shouldDrawLayer(e){let{pickable:t,operation:i}=e.props;return t&&i.includes("draw")||i.includes("terrain")||i.includes("mask")}getShaderModuleProps(e,t,i){return{picking:{isActive:1,isAttribute:this.pickZ,disabledPickingIndices:e.internalState?.disabledPickingIndices},lighting:{enabled:!1}}}getLayerParameters(e,t,i){let r={...e.props.parameters},{pickable:s,operation:o}=e.props;return this._colorEncoderState?s&&o.includes("draw")?(Object.assign(r,i6),r.blend=!0,this.device.type==="webgpu"?r.blendConstant=j1(this._colorEncoderState,e,i):r.blendColor=j1(this._colorEncoderState,e,i),o.includes("terrain")&&e.state?._hasPickingCover&&(r.blendAlphaSrcFactor="one")):o.includes("terrain")&&(r.blend=!1):r.blend=!1,r}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}};function j1(n,e,t){let{byLayer:i,byAlpha:r}=n,s,o=i.get(e);return o?(o.viewports.push(t),s=o.a):(s=i.size+1,s<=255?(o={a:s,layer:e,viewports:[t]},i.set(e,o),r[s]=o):(ae.warn("Too many pickable layers, only picking the first 255")(),s=0)),[0,0,0,s/255]}function r6(n,e){let t=n.byAlpha[e[3]];return t&&{pickedLayer:t.layer,pickedViewports:t.viewports,pickedObjectIndex:t.layer.decodePickingColor(e)}}Me();var Ji={NO_STATE:"Awaiting state",MATCHED:"Matched. State transferred from previous layer",INITIALIZED:"Initialized",AWAITING_GC:"Discarded. Awaiting garbage collection",AWAITING_FINALIZATION:"No longer matched. Awaiting garbage collection",FINALIZED:"Finalized! Awaiting garbage collection"},wo=Symbol.for("component"),Kn=Symbol.for("propTypes"),Of=Symbol.for("deprecatedProps"),Si=Symbol.for("asyncPropDefaults"),Qn=Symbol.for("asyncPropOriginal"),_n=Symbol.for("asyncPropResolved");function Df(n,e=()=>!0){return Array.isArray(n)?H1(n,e,[]):e(n)?[n]:[]}function H1(n,e,t){let i=-1;for(;++i0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,t){if(e===this._data&&!t)return;this._data=e;let i=++this._loadCount,r=e;typeof e=="string"&&(r=zs(e)),r instanceof Promise?(this.isLoaded=!1,this._loader=r.then(s=>{this._loadCount===i&&(this.isLoaded=!0,this._error=void 0,this._content=s)}).catch(s=>{this._loadCount===i&&(this.isLoaded=!0,this._error=s||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(let s of this._subscribers)s.onChange(this.getData())}};var xc=class{constructor(e){this.protocol=e.protocol||"resource://",this._context={device:e.device,gl:e.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return e.startsWith(this.protocol)?!0:e in this._resources}add({resourceId:e,data:t,forceUpdate:i=!1,persistent:r=!0}){let s=this._resources[e];s?s.setData(t,i):(s=new vc(e,t,this._context),this._resources[e]=s),s.persistent=r}remove(e){let t=this._resources[e];t&&(t.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){let t=this._consumers[e];if(t){for(let i in t){let r=t[i],s=this._resources[r.resourceId];s&&s.unsubscribe(r)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:t,consumerId:i,requestId:r="default"}){let{_resources:s,protocol:o}=this;e.startsWith(o)&&(e=e.replace(o,""),s[e]||this.add({resourceId:e,data:null,persistent:!1}));let a=s[e];if(this._track(i,r,a,t),a)return a.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(let e in this._resources)this._resources[e].delete()}_track(e,t,i,r){let s=this._consumers,o=s[e]=s[e]||{},a=o[t],c=a&&a.resourceId&&this._resources[a.resourceId];c&&(c.unsubscribe(a),this.prune()),i&&(a?(a.onChange=r,a.resourceId=i.id):a={onChange:r,resourceId:i.id},o[t]=a,i.subscribe(a))}_prune(){this._pruneRequest=null;for(let e of Object.keys(this._resources)){let t=this._resources[e];!t.persistent&&!t.inUse()&&(t.delete(),delete this._resources[e])}}};var s6="layerManager.setLayers",o6="layerManager.activateViewport",wc=class{constructor(e,t){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=a=>{Ne(o6,this,a),a&&(this.context.viewport=a)};let{deck:i,stats:r,viewport:s,timeline:o}=t||{};this.layers=[],this.resourceManager=new xc({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e?.gl,deck:i,shaderAssembler:n1(e?.info?.shadingLanguage||"glsl"),defaultShaderModules:[s_],renderPass:void 0,stats:r||new Yt({id:"deck.gl"}),viewport:s||new go({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:o||new Qr,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(let e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(let i of this.layers){let r=i.getNeedsRedraw(e);t=t||r}return t}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(t=>e.find(i=>t.id.indexOf(i)===0)):this.layers}setProps(e){"debug"in e&&(this._debug=e.debug),"userData"in e&&(this.context.userData=e.userData),"layers"in e&&(this._nextLayers=e.layers),"onError"in e&&(this.context.onError=e.onError)}setLayers(e,t){Ne(s6,this,t,e),this._lastRenderedLayers=e;let i=Df(e,Boolean);for(let r of i)r.context=this.context;this._updateLayers(this.layers,i)}updateLayers(){let e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){let{defaultShaderModules:t}=this.context;t.find(i=>i.name===e.name)||(t.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){let{defaultShaderModules:t}=this.context,i=t.findIndex(r=>r.name===e.name);i>=0&&(t.splice(i,1),this._defaultShaderModulesChanged=!0)}_handleError(e,t,i){i.raiseError(t,`${e} of ${i}`)}_updateLayers(e,t){let i={};for(let o of e)i[o.id]?ae.warn(`Multiple old layers with same id ${o.id}`)():i[o.id]=o;if(this._defaultShaderModulesChanged){for(let o of e)o.setNeedsUpdate(),o.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}let r=[];this._updateSublayersRecursively(t,i,r),this._finalizeOldLayers(i);let s=!1;for(let o of r)if(o.hasUniformTransition()){s=`Uniform transition in ${o}`;break}this._needsUpdate=s,this.layers=r}_updateSublayersRecursively(e,t,i){for(let r of e){r.context=this.context;let s=t[r.id];s===null&&ae.warn(`Multiple new layers with same id ${r.id}`)(),t[r.id]=null;let o=null;try{this._debug&&s!==r&&r.validateProps(),s?(this._transferLayerState(s,r),this._updateLayer(r)):this._initializeLayer(r),i.push(r),o=r.isComposite?r.getSubLayers():null}catch(a){this._handleError("matching",a,r)}o&&this._updateSublayersRecursively(o,t,i)}}_finalizeOldLayers(e){for(let t in e){let i=e[t];i&&this._finalizeLayer(i)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=Ji.INITIALIZED}catch(t){this._handleError("initialization",t,e)}}_transferLayerState(e,t){t._transferState(e),t.lifecycle=Ji.MATCHED,t!==e&&(e.lifecycle=Ji.AWAITING_GC)}_updateLayer(e){try{e._update()}catch(t){this._handleError("update",t,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=Ji.AWAITING_FINALIZATION;try{e._finalize(),e.lifecycle=Ji.FINALIZED}catch(t){this._handleError("finalization",t,e)}}};function Ee(n,e,t){if(n===e)return!0;if(!t||!n||!e)return!1;if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let i=0;i{let i=!e.canvasId||this.getCanvasId(t.id)===e.canvasId,r=!("x"in e)||t.containsPixel(e);return i&&r}):this._viewports}getViews(){let e={};return this.views.forEach(t=>{e[t.id]=t}),e}getView(e){return this.views.find(t=>t.id===e)}getViewState(e){let t=typeof e=="string"?this.getView(e):e,i=t&&this.viewState[t.getViewStateId()]||this.viewState;return t?t.filterViewState(i):i}getViewport(e){return this._viewportMap[e]}getCanvasId(e){let t=typeof e=="string"?this.getView(e):e;return t?this._viewEventManagers[t.id]?.canvasId||this._getCanvasIdFromView(t):void 0}unproject(e,t){let i=this.getViewports(),r={x:e[0],y:e[1]};for(let s=i.length-1;s>=0;--s){let o=i[s];if(o.containsPixel(r)){let a=e.slice();return a[0]-=o.x,a[1]-=o.y,o.unproject(a,t)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),("width"in e||"height"in e)&&this._setSize(e.width,e.height),"pickPosition"in e&&(this._pickPosition=e.pickPosition),"eventManagers"in e&&this._setEventManagers(e.eventManagers||{}),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,t){(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.setNeedsUpdate("Size changed"))}_setViews(e){e=Df(e,Boolean),this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){e?(!Ee(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e):ae.warn("missing `viewState` or `initialViewState`")()}_setEventManagers(e){this._eventManagers!==e&&(this._eventManagers=e,this.setNeedsUpdate("eventManagers changed"))}_getCanvasIdFromView(e){return e.props.canvasId||this._getCanvasContext?.(e.id)?.id||er}_getCanvasDimensions(e){let t=this._getCanvasContext?.(e.id),[i,r]=t?.getCSSSize()||[this.width,this.height];return{width:i,height:r}}_getViewEventManager(e){let t=this.getCanvasId(e)||er;return{canvasId:t,eventManager:this._eventManagers[t]||this._eventManager}}_startViewportRebuild(){let e=this.controllers,t=this._viewEventManagers;return this._viewports=[],this.controllers={},this._viewEventManagers={},{oldControllers:e,oldViewEventManagers:t}}_getReusableController(e,t,i){return e&&(t?.canvasId!==i.canvasId||t?.eventManager!==i.eventManager)?(e.finalize(),null):e}_createController(e,t){let i=t.type;return new i({timeline:this.timeline,eventManager:this._getViewEventManager(e).eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:s=>this.getView(e.id)?.makeViewport({viewState:s,...this._getCanvasDimensions(e)}),pickPosition:(s,o)=>this._pickPosition?.(s,o,e.id)})}_updateController(e,t,i,r){let s=e.controller;if(s&&i){let o={...t,...s,id:e.id,x:i.x,y:i.y,width:i.width,height:i.height};return(!r||r.constructor!==s.type)&&(r=this._createController(e,o)),r&&r.setProps(o),r}return null}_rebuildViewports(){let{views:e}=this,{oldControllers:t,oldViewEventManagers:i}=this._startViewportRebuild(),r=!1;for(let s=e.length;s--;){let o=e[s],{width:a,height:c}=this._getCanvasDimensions(o),l=this._getViewEventManager(o);this._viewEventManagers[o.id]=l;let u=this.getViewState(o),f=o.makeViewport({viewState:u,width:a,height:c}),d=this._getReusableController(t[o.id],i[o.id],l),h=!!o.controller;h&&!d&&(r=!0),(r||!h)&&d&&(d.finalize(),d=null),this.controllers[o.id]=this._updateController(o,u,f,d),f&&this._viewports.unshift(f)}for(let s in t){let o=t[s];o&&!this.controllers[s]&&o.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,t){return e.length!==t.length?!0:e.some((i,r)=>!e[r].equals(t[r]))}};var a6=/^(?:\d+\.?\d*|\.\d+)$/;function xt(n){switch(typeof n){case"number":if(!Number.isFinite(n))throw new Error(`Could not parse position string ${n}`);return{type:"literal",value:n};case"string":try{let e=c6(n);return new U_(e).parseExpression()}catch(e){let t=e instanceof Error?e.message:String(e);throw new Error(`Could not parse position string ${n}: ${t}`)}default:throw new Error(`Could not parse position string ${n}`)}}function z_(n,e){switch(n.type){case"literal":return n.value;case"percentage":return Math.round(n.value*e);case"binary":let t=z_(n.left,e),i=z_(n.right,e);return n.operator==="+"?t+i:t-i;default:throw new Error("Unknown layout expression type")}}function wt(n,e){return z_(n,e)}function c6(n){let e=[],t=0;for(;t="0"&&n<="9"}function Z1(n){return n>="a"&&n<="z"||n>="A"&&n<="Z"}function l6(n){return!!(n&&n.type==="symbol"&&(n.value==="+"||n.value==="-"))}function X1(n,e){let t={...n};for(let i in e)i!=="id"&&(Array.isArray(t[i])&&Array.isArray(e[i])?t[i]=u6(t[i],e[i]):t[i]=e[i]);return t}function u6(n,e){n=n.slice();for(let t=0;t{},Q1={mode:"preserve"},f6={mode:"hard"},$_={BREAK:1,SNAP_TO_END:2,IGNORE:3},d6=n=>n,h6=$_.BREAK,Sc=class{constructor(e){this._onTransitionUpdate=t=>{let{time:i,settings:{interpolator:r,startProps:s,endProps:o,duration:a,easing:c}}=t,l=c(i/a),u=r.interpolateProps(s,o,l);this.propsInTransition=this.getControllerState({...this.props,...u},Q1).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new yn(e.timeline),this.onViewStateChange=e.onViewStateChange||K1,this.onStateChange=e.onStateChange||K1}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let t=!1,i=this.props;if(this.props=e,!i||this._shouldIgnoreViewportChange(i,e))return!1;if(this._isTransitionEnabled(e)){let r=i;if(this.transition.inProgress){let{interruption:s,endProps:o}=this.transition.settings;r={...i,...s===$_.SNAP_TO_END?o:this.propsInTransition||i}}this._triggerTransition(r,e),t=!0}else this.transition.cancel();return t}updateTransition(){this.transition.update()}_isTransitionEnabled(e){let{transitionDuration:t,transitionInterpolator:i}=e;return(t>0||t==="auto")&&!!i}_isUpdateDueToCurrentTransition(e){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition):!1}_shouldIgnoreViewportChange(e,t){return this.transition.inProgress?this.transition.settings.interruption===$_.IGNORE||this._isUpdateDueToCurrentTransition(t):this._isTransitionEnabled(t)?t.transitionInterpolator.arePropsEqual(e,t):!0}_triggerTransition(e,t){let i=this.getControllerState(e,Q1),r=this.getControllerState(t,f6).shortestPathFrom(i),s=t.transitionInterpolator,o=s.getDuration?s.getDuration(e,t):t.transitionDuration;if(o===0)return;let a=s.initializeProps(e,r);this.propsInTransition={};let c={duration:o,easing:t.transitionEasing||d6,interpolator:s,interruption:t.transitionInterruption||h6,startProps:a.start,endProps:a.end,onStart:t.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(t.onTransitionInterrupt),onEnd:this._onTransitionEnd(t.onTransitionEnd)};this.transition.start(c),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return t=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e?.(t)}}};ze();function ge(n,e){if(!n)throw new Error(e||"deck.gl: assertion failed.")}var Pc=class{constructor(e){let{compare:t,extract:i,required:r}=e;this._propsToCompare=t,this._propsToExtract=i||t,this._requiredProps=r}arePropsEqual(e,t){for(let i of this._propsToCompare)if(!(i in e)||!(i in t)||!$n(e[i],t[i]))return!1;return!0}initializeProps(e,t){let i={},r={};for(let s of this._propsToExtract)(s in e||s in t)&&(i[s]=e[s],r[s]=t[s]);return this._checkRequiredProps(i),this._checkRequiredProps(r),{start:i,end:r}}getDuration(e,t){return t.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(t=>{let i=e[t];ge(Number.isFinite(i)||Array.isArray(i),`${t} is required for transition`)})}};ze();var p6=["longitude","latitude","zoom","bearing","pitch"],m6=["longitude","latitude","zoom"],Pi=class extends Pc{constructor(e={}){let t=Array.isArray(e)?e:e.transitionProps,i=Array.isArray(e)?{}:e;i.transitionProps=Array.isArray(t)?{compare:t,required:t}:t||{compare:p6,required:m6},super(i.transitionProps),this.opts=i}initializeProps(e,t){let i=super.initializeProps(e,t),{makeViewport:r,around:s}=this.opts;if(r&&s){let o=r(e),a=r(t),c=o.unproject(s);i.start.around=s,Object.assign(i.end,{around:a.project(c),aroundPosition:c,width:t.width,height:t.height})}return i}interpolateProps(e,t,i){let r={};for(let s of this._propsToExtract)r[s]=fn(e[s]||0,t[s]||0,i);if(t.aroundPosition&&this.opts.makeViewport){let s=this.opts.makeViewport({...t,...r});Object.assign(r,s.panByPosition(t.aroundPosition,fn(e.around,t.around,i)))}return r}};var Jn={transitionDuration:0},g6=300,_6=300,G_=n=>1-(1-n)*(1-n),y6=n=>n===1?1:1-Math.pow(2,-10*n),ts={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],MULTI_PAN:["multipanstart","multipanmove","multipanend"],DOUBLE_CLICK:["dblclick"],DOUBLE_CLICK_DRAG:["dblclickdragstart","dblclickdragmove","dblclickdragend","dblclickdragcancel"],KEYBOARD:["keydown"]},ns={},is=class{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this._multiPanMode=null,this._multiPanStartCenter=null,this._doubleClickDragAnchor=null,this._suppressDoubleClickUntil=0,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.doubleClickDragZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.multiTouchDrag=null,this.trackpadGesture=!1,this.zoomAround="pointer",this.keyboard=!0,this.transitionManager=new Sc({...e,getControllerState:(t,i)=>new this.ControllerState({...t,constraintContext:i,makeViewport:e.makeViewport}),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport,this.pickPosition=e.pickPosition}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){for(let e in this._events)this._events[e]&&this.eventManager?.off(e,this.handleEvent);this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;let t=this._eventStartBlocked;switch(e.type){case"panstart":return t?!1:this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return t||!this._isTrackpadGestureAllowed(e)?!1:this._onPinchStart(e);case"pinchmove":return this._isTrackpadGestureAllowed(e)?this._onPinch(e):!1;case"pinchend":return this._isTrackpadGestureAllowed(e)?this._onPinchEnd(e):!1;case"multipanstart":return t?!1:this._onMultiPanStart(e);case"multipanmove":return this._onMultiPan(e);case"multipanend":return this._onMultiPanEnd(e);case"dblclick":return this._onDoubleClick(e);case"dblclickdragstart":return t?!1:this._onDoubleClickDragStart(e);case"dblclickdragmove":return this._onDoubleClickDrag(e);case"dblclickdragend":case"dblclickdragcancel":return this._onDoubleClickDragEnd(e);case"wheel":return this._onWheel(e);case"keydown":return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){let{x:t,y:i}=this.props,{offsetCenter:r}=e;return[r.x-t,r.y-i]}getZoomPosition(e){if(this.zoomAround==="pointer")return e;let t=this.makeViewport(this.controllerState.getViewportProps()),[i,r]=Qi(t.center,t.pixelProjectionMatrix);return[i,r]}isPointInBounds(e,t){let{width:i,height:r}=this.props;if(t&&t.handled)return!1;let s=e[0]>=0&&e[0]<=i&&e[1]>=0&&e[1]<=r;return s&&t&&t.stopPropagation(),s}isFunctionKeyPressed(e){let{srcEvent:t}=e;return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){let t=setTimeout(()=>{this._eventStartBlocked===t&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=t}setProps(e){e.maxBoundsPadding===void 0&&(e.maxBoundsPadding=null),e.dragMode&&(this.dragMode=e.dragMode);let t=this.props;this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);let{inertia:i}=e;this.inertia=Number.isFinite(i)?i:i===!0?g6:0;let{scrollZoom:r=!0,dragPan:s=!0,dragRotate:o=!0,doubleClickZoom:a=!0,doubleClickDragZoom:c=!1,touchZoom:l=!0,touchRotate:u=!1,multiTouchDrag:f=u?"rotate":null,trackpadGesture:d=!1,zoomAround:h="pointer",keyboard:p=!0}=e,m=!!this.onViewStateChange;if(this.toggleEvents(ts.WHEEL,m&&r),this.toggleEvents(ts.PAN,m),this.toggleEvents(ts.PINCH,m&&(l||f==="rotate")),this.toggleEvents(ts.MULTI_PAN,m&&!!f),this.toggleEvents(ts.DOUBLE_CLICK,m&&a),this.toggleEvents(ts.DOUBLE_CLICK_DRAG,m&&c),this.toggleEvents(ts.KEYBOARD,m&&p),this.scrollZoom=r,this.dragPan=s,this.dragRotate=o,this.doubleClickZoom=a,this.doubleClickDragZoom=c,this.touchZoom=l,this.touchRotate=f==="rotate",this.multiTouchDrag=f,this.trackpadGesture=d,this.zoomAround=h,this.keyboard=p,(!t||t.height!==e.height||t.width!==e.width||t.maxBounds!==e.maxBounds||t.maxBoundsPadding!==e.maxBoundsPadding)&&e.maxBounds){let v=new this.ControllerState({...e,makeViewport:this.makeViewport}),y=v.getViewportProps();Object.keys(y).some(x=>!Ee(y[x],e[x],1))&&this.updateViewport(v)}}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,t){this.eventManager&&e.forEach(i=>{this._events[i]!==t&&(this._events[i]=t,t?this.eventManager.on(i,this.handleEvent):this.eventManager.off(i,this.handleEvent))})}updateViewport(e,t=null,i={}){let r={...e.getViewportProps(),...t},s=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(i),s){let o=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:r,interactionState:this._interactionState,oldViewState:o,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_getConstraintContext(e,t){return this.props.rubberBand?{mode:t==="update"?"elastic":t==="end"?"rebound":"hard"}:{mode:"hard"}}_getReboundTransition(e,t){if(e.mode!=="rebound")return null;let i=t.getViewportProps();return Object.keys(i).some(s=>!Ee(this.props[s],i[s],1))?{...this._getTransitionProps(),transitionDuration:_6,transitionEasing:y6}:null}_onPanStart(e){let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let i=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(i=!i);let r=i?"pan":"rotate",s=this._getConstraintContext(r,"start"),o=i?this.controllerState.panStart({pos:t},s):this.controllerState.rotateStart({pos:t},s);return this._panMove=i,this.updateViewport(o,Jn,{isDragging:!0}),!0}_onPan(e){return this.isDragging()?this._panMove?this._onPanMove(e):this._onPanRotate(e):!1}_onPanEnd(e){return this.isDragging()?this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e):!1}_onPanMove(e){if(!this.dragPan)return!1;let t=this.getCenter(e),i=this.controllerState.pan({pos:t},this._getConstraintContext("pan","update"));return this.updateViewport(i,Jn,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){let{inertia:t}=this;if(this.dragPan&&t&&e.velocity){let i=this.getCenter(e),r=[i[0]+e.velocityX*t/2,i[1]+e.velocityY*t/2],s=this.controllerState.pan({pos:r}).panEnd();this.updateViewport(s,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:G_},{isDragging:!1,isPanning:!0})}else{let i=this.controllerState,r=this._getConstraintContext("pan","end"),s=i.panEnd(r),o=this._getReboundTransition(r,s);this.updateViewport(s,o,{isDragging:!1,isPanning:!!o})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;let t=this.getCenter(e),i=this.controllerState.rotate({pos:t},this._getConstraintContext("rotate","update"));return this.updateViewport(i,Jn,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){let{inertia:t}=this;if(this.dragRotate&&t&&e.velocity){let i=this.getCenter(e),r=[i[0]+e.velocityX*t/2,i[1]+e.velocityY*t/2],s=this.controllerState.rotate({pos:r}).rotateEnd();this.updateViewport(s,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:G_},{isDragging:!1,isRotating:!0})}else{let i=this.controllerState,r=this._getConstraintContext("rotate","end"),s=i.rotateEnd(r),o=this._getReboundTransition(r,s);this.updateViewport(s,o,{isDragging:!1,isRotating:!!o})}return!0}_onWheel(e){if(!this.scrollZoom||this.trackpadGesture&&e.device!=="mouse")return!1;let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;e.srcEvent.preventDefault();let{speed:i=.01,smooth:r=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:s}=e,o=2/(1+Math.exp(-Math.abs(s*i)));s<0&&o!==0&&(o=1/o);let a=this.getZoomPosition(t),c=r?{...this._getTransitionProps({around:a}),transitionDuration:250}:Jn,l=this.controllerState.zoom({pos:a,scale:o});return this.updateViewport(l,c,{isZooming:!0,isPanning:!0}),r||this._setInteractionState({isZooming:!1,isPanning:!1}),!0}_onMultiPanStart(e){let{multiTouchDrag:t}=this;if(!t||!this._isMultiPanEventAllowed(e,t))return!1;let i=e.offsetCenter;if(!this.isPointInBounds(this.getCenter(e),e))return!1;let r=e.pointerType==="trackpad",s={x:i.x-(r?0:e.deltaX),y:i.y-(r?0:e.deltaY)},o={...e,offsetCenter:s},a=this.getCenter(o),c=t==="pan"?this.controllerState.panStart({pos:a},this._getConstraintContext("pan","start")):this.controllerState.rotateStart({pos:a},this._getConstraintContext("rotate","start"));return this._multiPanMode=t,this._multiPanStartCenter=s,this.updateViewport(c,Jn,{isDragging:!0}),!0}_onMultiPan(e){let{mode:t,event:i}=this._getMultiPanEvent(e);return!t||!i||!this.isDragging()?!1:t==="pan"?this._onPanMove(i):this._onPanRotate(i)}_onMultiPanEnd(e){let{mode:t,event:i}=this._getMultiPanEvent(e);if(!t||!i||!this.isDragging())return this._resetMultiPan(),!1;let r=t==="pan"?this._onPanMoveEnd(i):this._onPanRotateEnd(i);return this._resetMultiPan(),r}_isTrackpadGestureAllowed(e){return e.pointerType!=="trackpad"||this.trackpadGesture}_isMultiPanEventAllowed(e,t){return e.pointerType==="trackpad"?this.trackpadGesture&&(t==="pan"?this.dragPan:this.dragRotate):e.pointerType==="touch"&&(t==="pan"?this.dragPan:this.dragRotate)}_getMultiPanEvent(e){let t=this._multiPanMode,i=this._multiPanStartCenter;return!t||!i?{mode:null,event:null}:{mode:t,event:{...e,offsetCenter:{x:i.x+e.deltaX,y:i.y+e.deltaY}}}}_resetMultiPan(){this._multiPanMode=null,this._multiPanStartCenter=null}_onPinchStart(e){this._doubleClickDragAnchor=null;let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let i=this.controllerState.zoomStart({pos:this.getZoomPosition(t)},this._getConstraintContext("zoom","start")).rotateStart({pos:t},this._getConstraintContext("rotate","start"));return ns._startPinchRotation=e.rotation,ns._lastPinchEvent=e,this.updateViewport(i,Jn,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let t=this.controllerState;if(this.touchZoom){let{scale:i}=e,r=this.getCenter(e);t=t.zoom({pos:this.getZoomPosition(r),scale:i},this._getConstraintContext("zoom","update"))}if(this.touchRotate){let{rotation:i}=e;t=t.rotate({deltaAngleX:ns._startPinchRotation-i},this._getConstraintContext("rotate","update"))}return this.updateViewport(t,Jn,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),ns._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;let{inertia:t}=this,{_lastPinchEvent:i}=ns;if(this.touchZoom&&t&&i&&e.scale!==i.scale){let r=this.getCenter(e),s=this.getZoomPosition(r),o=this.controllerState.rotateEnd(),a=Math.log2(e.scale),c=(a-Math.log2(i.scale))/(e.deltaTime-i.deltaTime),l=Math.pow(2,a+c*t/2);o=o.zoom({pos:s,scale:l}).zoomEnd(),this.updateViewport(o,{...this._getTransitionProps({around:s}),transitionDuration:t,transitionEasing:G_},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(t)}else{let r=this.controllerState,s=this._getConstraintContext("zoom","end"),o=this._getConstraintContext("rotate","end"),a=r.zoomEnd(s).rotateEnd(o),c=this._getReboundTransition(this.touchZoom?s:o,a);this.updateViewport(a,c,{isDragging:!1,isPanning:!!c&&this.touchZoom,isZooming:!!c&&this.touchZoom,isRotating:!!c&&this.touchRotate})}return ns._startPinchRotation=null,ns._lastPinchEvent=null,!0}_onDoubleClick(e){if(!this.doubleClickZoom||Date.now()90&&(e=Math.sign(e)*90),Number.isFinite(n)){let[i,r]=ht([n,e]);return[i,Te(r,0,e2)]}let[,t]=ht([0,e]);return[n,Te(t,0,e2)]}var V_=class extends rs{constructor(e){let{width:t,height:i,latitude:r,longitude:s,zoom:o,bearing:a=0,pitch:c=0,altitude:l=1.5,position:u=[0,0,0],maxZoom:f=20,minZoom:d=0,maxPitch:h=60,minPitch:p=0,startPanLngLat:m,startZoomLngLat:g,startRotatePos:v,startRotateLngLat:y,startBearing:b,startPitch:x,startZoom:E,normalize:w=!0,rubberBand:T=!1}=e,{[nn]:R}=e;ge(Number.isFinite(s)),ge(Number.isFinite(r)),ge(Number.isFinite(o));let F=e.maxBounds||(w?t2:null),O=e.maxBoundsPadding||null;super({width:t,height:i,latitude:r,longitude:s,zoom:o,bearing:a,pitch:c,altitude:l,maxZoom:f,minZoom:d,maxPitch:h,minPitch:p,normalize:w,position:u,maxBounds:F,maxBoundsPadding:O,rubberBand:T,[nn]:R},{startPanLngLat:m,startZoomLngLat:g,startRotatePos:v,startRotateLngLat:y,startBearing:b,startPitch:x,startZoom:E},e.makeViewport,e.constraintContext),this.getAltitude=e.getAltitude}panStart({pos:e},t){return this._getUpdatedState({startPanLngLat:this._unproject(e)},t)}pan({pos:e,startPos:t},i){let r=this.getState().startPanLngLat||this._unproject(t);if(!r)return this;let o=this.makeViewport(this.getViewportProps()).panByPosition(r,e);return this._getUpdatedState(o,i)}panEnd(e){return this._getUpdatedState({startPanLngLat:null},e)}rotateStart({pos:e}){let t=this.getAltitude?.(e);return this._getUpdatedState({startRotatePos:e,startRotateLngLat:t!==void 0?this._unproject3D(e,t):void 0,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:t=0,deltaAngleY:i=0}){let{startRotatePos:r,startRotateLngLat:s,startBearing:o,startPitch:a}=this.getState();if(!r||o===void 0||a===void 0)return this;let c;if(e?c=this._getNewRotation(e,r,a,o):c={bearing:o+t,pitch:a+i},s){let l=this.makeViewport({...this.getViewportProps(),...c}),u="panByPosition3D"in l?"panByPosition3D":"panByPosition";return this._getUpdatedState({...c,...l[u](s,r)})}return this._getUpdatedState(c)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startRotateLngLat:null,startBearing:null,startPitch:null})}zoomStart({pos:e},t){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom},t)}zoom({pos:e,startPos:t,scale:i},r){let{startZoom:s,startZoomLngLat:o}=this.getState();return o||(s=this.getViewportProps().zoom,o=this._unproject(t)||this._unproject(e)),o?this._getUpdatedState({zoom:s+Math.log2(i),[nn]:{position:o,screenPosition:e}},r):this}zoomEnd(e){return this._getUpdatedState({startZoomLngLat:null,startZoom:null},e)}zoomIn(e=2,t){return this._zoomFromCenter(e,t)}zoomOut(e=2,t){return this._zoomFromCenter(1/e,t)}moveLeft(e=100,t){return this._panFromCenter([e,0],t)}moveRight(e=100,t){return this._panFromCenter([-e,0],t)}moveUp(e=100,t){return this._panFromCenter([0,e],t)}moveDown(e=100,t){return this._panFromCenter([0,-e],t)}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){let t=e.getViewportProps(),i={...this.getViewportProps()},{bearing:r,longitude:s}=i;return Math.abs(r-t.bearing)>180&&(i.bearing=r<0?r+360:r-360),Math.abs(s-t.longitude)>180&&(i.longitude=s<0?s+360:s-360),i}applyConstraints(e,t){let i=e,r=i[nn];delete i[nn];let{maxPitch:s,minPitch:o,pitch:a,bearing:c,normalize:l,maxBounds:u,rubberBand:f}=e;l&&(c<-180||c>180)&&(e.bearing=P_(c+180,360)-180),e.pitch=Te(a,o,s);let d=this._constrainZoom(e.zoom,e),h=f&&t?.mode==="elastic";if(e.zoom=t?.mode==="preserve"?e.zoom:h?tr(e.zoom,d,v6):d,r){let p=this.makeViewport(e);Object.assign(e,p.panByPosition(r.position,r.screenPosition))}if(l&&(e.longitude<-180||e.longitude>180)&&(e.longitude=P_(e.longitude+180,360)-180),u){let p=Eo(e.width,e.height,e.maxBoundsPadding),m=this.makeViewport({...e,bearing:0,pitch:0}),g=Nf(m,[e.longitude,e.latitude],p),v=Cc(u[0]),y=Cc(u[1]),b=2**e.zoom,x=[v[0]+g.left/b,v[1]+g.bottom/b],E=[y[0]-g.right/b,y[1]-g.top/b],w=Cc([e.longitude,e.latitude]),T=[Te(w[0],x[0],E[0]),Te(w[1],x[1],E[1])],R=w.slice();if(p.width>=0&&(R[0]=t?.mode==="preserve"?w[0]:h?tr(w[0],T[0],p.width/2/b):T[0]),p.height>=0&&(R[1]=t?.mode==="preserve"?w[1]:h?tr(w[1],T[1],p.height/2/b):T[1]),R[0]!==w[0]||R[1]!==w[1]){let[F,O]=It(R);R[0]!==w[0]&&(e.longitude=F),R[1]!==w[1]&&(e.latitude=O)}}return e}_constrainZoom(e,t){t||(t=this.getViewportProps());let{maxZoom:i,maxBounds:r}=t,s=r!==null&&t.width>0&&t.height>0,{minZoom:o}=t;if(s){let a=Eo(t.width,t.height,t.maxBoundsPadding),c=Cc(r[0]),l=Cc(r[1]),u=l[0]-c[0],f=l[1]-c[1];a.width>0&&Number.isFinite(u)&&u>0&&(o=Math.max(o,Math.log2(a.width/u))),a.height>0&&Number.isFinite(f)&&f>0&&(o=Math.max(o,Math.log2(a.height/f))),o>i&&(o=i)}return Te(e,o,i)}_zoomFromCenter(e,t){let{width:i,height:r}=this.getViewportProps();return this.zoom({pos:[i/2,r/2],scale:e},t)}_panFromCenter(e,t){let{width:i,height:r}=this.getViewportProps();return this.pan({startPos:[i/2,r/2],pos:[i/2+e[0],r/2+e[1]]},t)}_getUpdatedState(e,t){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e,constraintContext:t})}_unproject(e){let t=this.makeViewport(this.getViewportProps());return e&&t.unproject(e)}_unproject3D(e,t){return this.makeViewport(this.getViewportProps()).unproject(e,{targetZ:t})}_getNewRotation(e,t,i,r){let s=e[0]-t[0],o=e[1]-t[1],a=e[1],c=t[1],{width:l,height:u}=this.getViewportProps(),f=s/l,d=0;o>0?Math.abs(u-c)>J1&&(d=o/(c-u)*b6):o<0&&c>J1&&(d=1-a/c),d=Te(d,-1,1);let{minPitch:h,maxPitch:p}=this.getViewportProps(),m=r+180*f,g=i;return d>0?g=i+d*(p-i):d<0&&(g=i-d*(h-i)),{pitch:g,bearing:m}}},Tc=class extends is{constructor(){super(...arguments),this.ControllerState=V_,this.transition={transitionDuration:300,transitionInterpolator:new Pi({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan",this.rotationPivot="center",this._getAltitude=e=>{if(this.rotationPivot==="2d")return 0;if(this.rotationPivot==="3d"&&this.pickPosition){let{x:t,y:i}=this.props,r=this.pickPosition(t+e[0],i+e[1]);if(r&&r.coordinate&&r.coordinate.length>=3)return r.coordinate[2]}}}setProps(e){"rotationPivot"in e&&(this.rotationPivot=e.rotationPivot||"center"),e.getAltitude=this._getAltitude,e.position=e.position||[0,0,0],e.maxBounds=e.maxBounds||(e.normalize===!1?null:t2),super.setProps(e)}updateViewport(e,t=null,i={}){let r=e.getState();i.isDragging&&r.startRotateLngLat?i={...i,rotationPivotPosition:r.startRotateLngLat}:i.isDragging===!1&&(i={...i,rotationPivotPosition:void 0}),super.updateViewport(e,t,i)}};var Ff=class extends es{constructor(e={}){super(e)}getViewportType(){return Ei}get ControllerType(){return Tc}};Ff.displayName="MapView";var n2=Ff;var x6=new fo;function w6(n,e){let t=n.order??1/0,i=e.order??1/0;return t-i}var Lc=class{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){let t=this._defaultEffects;if(!t.find(i=>i.id===e.id)){let i=t.findIndex(r=>w6(r,e)>0);i<0?t.push(e):t.splice(i,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&(Ee(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}getEffects(){return this._resolvedEffects}_setEffects(e){let t={};for(let r of this.effects)t[r.id]=r;let i=[];for(let r of e){let s=t[r.id],o=r;s&&s!==r?s.setProps?(s.setProps(r.props),o=s):s.cleanup(this._context):s||r.setup(this._context),i.push(o),delete t[r.id]}for(let r in t)t[r].cleanup(this._context);this.effects=i,this._resolvedEffects=i.concat(this._defaultEffects),e.some(r=>r instanceof fo)||this._resolvedEffects.push(x6),this._needsRedraw="effects changed"}finalize(){for(let e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}};var Mc=class extends wi{shouldDrawLayer(e){let{operation:t}=e.props;return t.includes("draw")||t.includes("terrain")}render(e){return this._render(e)}};var E6="deckRenderer.renderLayers",Ac=class{constructor(e,t={}){this.device=e,this.stats=t.stats,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new Mc(e),this.pickLayersPass=new Jr(e),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(e){let t=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,i={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};if(!e.viewports.length){let a=t.render(i),c="stats"in a?a.stats:a;this._updateStats(c);return}i.effects&&this._preRender(i.effects,i);let r=this.lastPostProcessEffect?this.renderBuffers[0]:i.target;this.lastPostProcessEffect&&(i.clearColor=[0,0,0,0],i.clearCanvas=!0);let s=t.render({...i,target:r}),o="stats"in s?s.stats:s;i.effects&&(this.lastPostProcessEffect&&(i.clearCanvas=e.clearCanvas===void 0?!0:e.clearCanvas),this._postRender(i.effects,i)),this.renderCount++,Ne(E6,this,o,e),this._updateStats(o)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}finalize(){let{renderBuffers:e}=this;for(let t of e)t.delete();e.length=0}_updateStats(e){if(!this.stats)return;let t=0;for(let{visibleCount:i}of e)t+=i;this.stats.get("Layers rendered").addCount(t)}_preRender(e,t){this.lastPostProcessEffect=null,t.preRenderStats=t.preRenderStats||{};for(let i of e)t.preRenderStats[i.id]=i.preRender(t),i.postRender&&(this.lastPostProcessEffect=i.id);this.lastPostProcessEffect&&this._resizeRenderBuffers(t.canvasContext)}_resizeRenderBuffers(e=this.device.canvasContext){let{renderBuffers:t}=this,i=e.getDrawingBufferSize(),[r,s]=i;t.length===0&&[0,1].map(o=>{let a=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"},width:r,height:s});t.push(this.device.createFramebuffer({id:`deck-renderbuffer-${o}`,colorAttachments:[a]}))});for(let o of t)o.resize(i)}_postRender(e,t){let{renderBuffers:i}=this,r=t.target??t.canvasContext?.getCurrentFramebuffer()??t.target,s={...t,inputBuffer:i[0],swapBuffer:i[1]};for(let o of e)if(o.postRender){s.target=o.id===this.lastPostProcessEffect?r:void 0;let a=o.postRender(s);s.inputBuffer=a,s.swapBuffer=a===i[0]?i[1]:i[0]}}};J();var S6={pickedColor:null,pickedObjectIndex:-1};function W_({pickedColors:n,decodePickingColor:e,deviceX:t,deviceY:i,deviceRadius:r,deviceRect:s}){let{x:o,y:a,width:c,height:l}=s,u=r*r,f=-1,d=0;for(let h=0;hu)d+=4*c;else for(let g=0;g=0){let y=g+o-t,b=y*y+m;b<=u&&(u=b,f=d)}d+=4}}if(f>=0){let h=n.slice(f,f+4),p=e(h);if(p){let m=Math.floor(f/4/c),g=f/4-m*c;return{...p,pickedColor:h,pickedX:o+g,pickedY:a+m}}ae.error("Picked non-existent layer. Is picking buffer corrupt?")()}return S6}function j_({pickedColors:n,decodePickingColor:e}){let t=new Map;if(n){for(let i=0;i=0){let s=n.slice(i,i+4),o=s.join(",");if(!t.has(o)){let a=e(s);a?t.set(o,{...a,color:s}):ae.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(t.values())}function zf({pickInfo:n,viewports:e,pixelRatio:t,x:i,y:r,z:s}){let o=e[0];e.length>1&&(o=P6(n?.pickedViewports||e,{x:i,y:r}));let a;if(o){let c=[i-o.x,r-o.y];s!==void 0&&(c[2]=s),a=o.unproject(c)}return{color:null,layer:null,viewport:o,index:-1,picked:!1,x:i,y:r,pixel:[i,r],coordinate:a,devicePixel:n&&"pickedX"in n?[n.pickedX,n.pickedY]:void 0,pixelRatio:t}}function H_(n){let{pickInfo:e,lastPickedInfo:t,mode:i,layers:r}=n,{pickedColor:s,pickedLayer:o,pickedObjectIndex:a}=e,c=o?[o]:[];if(i==="hover"){let f=t.index,d=t.layerId,h=o?o.props.id:null;if(h!==d||a!==f){if(h!==d){let p=r.find(m=>m.props.id===d);p&&c.unshift(p)}t.layerId=h,t.index=a,t.info=null}}let l=zf(n),u=new Map;return u.set(null,l),c.forEach(f=>{let d={...l};f===o&&(d.color=s,d.index=a,d.picked=!0),d=Uf({layer:f,info:d,mode:i});let h=d.layer;f===o&&i==="hover"&&(t.info=d),u.set(h.id,d),i==="hover"&&h.updateAutoHighlight(d)}),u}function Uf({layer:n,info:e,mode:t}){for(;n&&e;){let i=e.layer||null;e.sourceLayer=i,e.layer=n,e=n.getPickingInfo({info:e,mode:t,sourceLayer:i}),n=n.parent}return e}function P6(n,e){for(let t=n.length-1;t>=0;t--){let i=n[t];if(i.containsPixel(e))return i}return n[0]}var kc=class{constructor(e,t={}){this._pickable=!0,this.device=e,this.stats=t.stats,this.pickLayersPass=new Jr(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){"layerFilter"in e&&(this.layerFilter=e.layerFilter),"_pickable"in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObjectAsync(e){return this._pickClosestObjectAsync(e)}pickObjectsAsync(e){return this._pickVisibleObjectsAsync(e)}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:t,layers:i,viewports:r},s=this.lastPickedInfo.info){let o=s&&s.layer&&s.layer.id,a=s&&s.viewport&&s.viewport.id,c=o?i.find(d=>d.id===o):null,l=a&&r.find(d=>d.id===a)||r[0],u=l&&l.unproject([e-l.x,t-l.y]);return{...s,...{x:e,y:t,viewport:l,coordinate:u,layer:c}}}_resizeBuffer(e=this.device.getDefaultCanvasContext()){if(!this.pickingFBO){let r=this.device.createTexture({format:"rgba8unorm",width:1,height:1,usage:me.RENDER_ATTACHMENT|me.COPY_SRC});if(this.pickingFBO=this.device.createFramebuffer({colorAttachments:[r],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float")){let s=this.device.createTexture({format:"rgba32float",width:1,height:1,usage:me.RENDER_ATTACHMENT|me.COPY_SRC}),o=this.device.createFramebuffer({colorAttachments:[s],depthStencilAttachment:"depth16unorm"});this.depthFBO=o}}let[t,i]=e.getDrawingBufferSize();this.pickingFBO?.resize({width:t,height:i}),this.depthFBO?.resize({width:t,height:i})}_getPickable(e){if(this._pickable===!1)return null;let t=e.filter(i=>this.pickLayersPass.shouldDrawLayer(i)&&!i.isComposite);return t.length?t:null}async _pickClosestObjectAsync({layers:e,views:t,viewports:i,x:r,y:s,radius:o=0,depth:a=1,mode:c="query",unproject3D:l,canvasContext:u=this.device.getDefaultCanvasContext(),onViewportActive:f,effects:d}){let h=u.cssToDeviceRatio(),p=this._getPickable(e);if(!p||i.length===0)return{result:[],emptyInfo:zf({viewports:i,x:r,y:s,pixelRatio:h})};this._resizeBuffer(u);let m=u.cssToDevicePixels([r,s],!0),g=[m.x+Math.floor(m.width/2),m.y+Math.floor(m.height/2)],v=Math.round(o*h),{width:y,height:b}=this.pickingFBO,x=this._getPickingRect({deviceX:g[0],deviceY:g[1],deviceRadius:v,deviceWidth:y,deviceHeight:b}),E={x:r-o,y:s-o,width:o*2+1,height:o*2+1},w,T=[],R=new Set;for(let F=0;F0){let{pickedColors:G}=await this._drawAndSampleAsync({layers:V,views:t,viewports:i,onViewportActive:f,deviceRect:{x:O.pickedX??g[0],y:O.pickedY??g[1],width:1,height:1},cullRect:E,effects:d,pass:`picking:${c}:z`,canvasContext:u},!0);G[3]&&(j=G[0])}O.pickedLayer&&F+10){let{pickedColors:G}=this._drawAndSample({layers:V,views:t,viewports:i,onViewportActive:f,deviceRect:{x:O.pickedX??g[0],y:O.pickedY??g[1],width:1,height:1},cullRect:E,effects:d,pass:`picking:${c}:z`,canvasContext:u},!0);G[3]&&(j=G[0])}O.pickedLayer&&F+1=l);j++){let V=T[j],G={color:V.pickedColor,layer:null,index:V.pickedObjectIndex,picked:!0,x:r,y:s,pixelRatio:p};G=Uf({layer:V.pickedLayer,info:G,mode:c});let q=G.layer.id;R.has(q)||R.set(q,new Set);let X=R.get(q),se=G.object??G.index;X.has(se)||(X.add(se),F.push(G))}return F}_pickVisibleObjects({layers:e,views:t,viewports:i,x:r,y:s,width:o=1,height:a=1,mode:c="query",maxObjects:l=null,canvasContext:u=this.device.getDefaultCanvasContext(),onViewportActive:f,effects:d}){let h=this._getPickable(e);if(!h||i.length===0)return[];this._resizeBuffer(u);let p=u.cssToDeviceRatio(),m=u.cssToDevicePixels([r,s],!0),g=m.x,v=m.y+m.height,y=u.cssToDevicePixels([r+o,s+a],!0),b=y.x+y.width,x=y.y,E={x:g,y:x,width:b-g,height:v-x},w=this._drawAndSample({layers:h,views:t,viewports:i,onViewportActive:f,deviceRect:E,cullRect:{x:r,y:s,width:o,height:a},effects:d,pass:`picking:${c}`,canvasContext:u}),T=j_(w),R=new Map,F=[],O=Number.isFinite(l);for(let j=0;j=l);j++){let V=T[j],G={color:V.pickedColor,layer:null,index:V.pickedObjectIndex,picked:!0,x:r,y:s,pixelRatio:p};G=Uf({layer:V.pickedLayer,info:G,mode:c});let q=G.layer.id;R.has(q)||R.set(q,new Set);let X=R.get(q),se=G.object??G.index;X.has(se)||(X.add(se),F.push(G))}return F}async _drawAndSampleAsync({layers:e,views:t,viewports:i,onViewportActive:r,deviceRect:s,cullRect:o,effects:a,pass:c,canvasContext:l},u=!1){let f=u?this.depthFBO:this.pickingFBO,d={layers:e,layerFilter:this.layerFilter,views:t,viewports:i,onViewportActive:r,pickingFBO:f,deviceRect:s,cullRect:o,effects:a,pass:c,canvasContext:l,pickZ:u,preRenderStats:{},isPicking:!0};for(let E of a)E.useInPicking&&(d.preRenderStats[E.id]=E.preRender(d));let{decodePickingColor:h,stats:p}=this.pickLayersPass.render(d);this._updateStats(p);let{x:m,y:g,width:v,height:y}=s,b=f.colorAttachments[0]?.texture;if(!b)throw new Error("Picking framebuffer color attachment is missing");let x=await this._readTextureDataAsync(b,{x:m,y:g,width:v,height:y},u?Float32Array:Uint8Array);if(!u){let E=!1;for(let w=3;w0&&ae.warn("Async pick readback returned only zero alpha values",{deviceRect:s,bytes:Array.from(x.subarray(0,Math.min(x.length,16)))})()}return{pickedColors:x,decodePickingColor:h}}async _readTextureDataAsync(e,t,i){let{width:r,height:s}=t,o=e.computeMemoryLayout(t),a=this.device.createBuffer({byteLength:o.byteLength,usage:ie.COPY_DST|ie.MAP_READ});try{e.readBuffer(t,a);let c=await a.readAsync(0,o.byteLength),l=i.BYTES_PER_ELEMENT;if(o.bytesPerRow%l!==0)throw new Error(`Texture readback row stride ${o.bytesPerRow} is not aligned to ${l}-byte elements.`);let u=new i(c.buffer,c.byteOffset,o.byteLength/l),f=r*4,d=o.bytesPerRow/l;if(do.props.operation.includes("terrain"))}_getPickingRect({deviceX:e,deviceY:t,deviceRadius:i,deviceWidth:r,deviceHeight:s}){let o=Math.max(0,e-i),a=Math.max(0,t-i),c=Math.min(r,e+i+1)-o,l=Math.min(s,t+i+1)-a;return c<=0||l<=0?null:{x:o,y:a,width:c,height:l}}};var C6={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},T6="top-left",i2="root",$f=class{constructor({deck:e,parentElement:t}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,t?.classList.add("deck-widget-container"),this.parentElement=t}getWidgets(){return this.resolvedWidgets}setProps(e){if(e.widgets&&!Ee(e.widgets,this.widgets,1)){let t=e.widgets.filter(Boolean);this._setWidgets(t)}}finalize(){for(let e of this.getWidgets())this._removeWidget(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(let e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(t=>t.id===e.id)||(this._addWidget(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}onRedraw({viewports:e,layers:t}){let i=e.reduce((r,s)=>(r[s.id]=s,r),{});for(let r of this.getWidgets()){let{viewId:s}=r;if(s){let o=i[s];o&&(r.onViewportChange&&r.onViewportChange(o),r.onRedraw?.({viewports:[o],layers:t}))}else{if(r.onViewportChange)for(let o of e)r.onViewportChange(o);r.onRedraw?.({viewports:e,layers:t})}}this.lastViewports=i,this._updateContainers()}onHover(e,t){for(let i of this.getWidgets()){let{viewId:r}=i;(!r||r===e.viewport?.id)&&i.onHover?.(e,t)}}getCanvasBounds(e){let i=this.deck?.getCanvas?.()?.getBoundingClientRect(),r=this.parentElement?.getBoundingClientRect(),s=this.deck?.getCanvasContext?.(e?.id);if(s&&r){s.updatePosition();let[o,a]=s.getPosition(),[c,l]=s.getCSSSize();return{x:o-r.left,y:a-r.top,width:c,height:l}}return{x:i&&r?i.left-r.left:0,y:i&&r?i.top-r.top:0,width:i?.width||this.deck?.width||0,height:i?.height||this.deck?.height||0}}onEvent(e,t){let i=ao[t.type];if(i)for(let r of this.getWidgets()){let{viewId:s}=r;(!s||s===e.viewport?.id)&&r[i]?.(e,t)}}_setWidgets(e){let t={};for(let i of this.resolvedWidgets)t[i.id]=i;this.resolvedWidgets.length=0;for(let i of this.defaultWidgets)t[i.id]=null,this.resolvedWidgets.push(i);for(let i of e){let r=t[i.id];r?r.viewId!==i.viewId||r.placement!==i.placement?(this._removeWidget(r),this._addWidget(i)):i!==r&&(r.setProps(i.props),i=r):this._addWidget(i),t[i.id]=null,this.resolvedWidgets.push(i)}for(let i in t){let r=t[i];r&&this._removeWidget(r)}this.widgets=e}_addWidget(e){let{viewId:t=null,placement:i=T6}=e,r=e.props._container??t;e.widgetManager=this,e.deck=this.deck,e.rootElement=e._onAdd({deck:this.deck,viewId:t}),e.rootElement&&this._getContainer(r,i).append(e.rootElement),e.updateHTML()}_removeWidget(e){e.onRemove?.(),e.rootElement&&e.rootElement.remove(),e.rootElement=void 0,e.deck=void 0,e.widgetManager=void 0}_getContainer(e,t){if(e&&typeof e!="string")return e;let i=e||i2,r=this.containers[i];r||(r=document.createElement("div"),r.style.pointerEvents="none",r.style.position="absolute",r.style.overflow="hidden",this.parentElement?.append(r),this.containers[i]=r);let s=r.querySelector(`.${t}`);return s||(s=globalThis.document.createElement("div"),s.className=t,s.style.position="absolute",s.style.zIndex="2",Object.assign(s.style,C6[t]),r.append(s)),s}_updateContainers(){for(let e in this.containers){let t=this.lastViewports[e]||null,i=e===i2||t,r=this.containers[e];if(i){let s=this._getContainerBounds(t);r.style.display="block",r.style.left=`${s.x}px`,r.style.top=`${s.y}px`,r.style.width=`${s.width}px`,r.style.height=`${s.height}px`}else r.style.display="none"}}_getContainerBounds(e){if(!e)return{x:0,y:0,width:this.parentElement?.clientWidth||this.deck.width,height:this.parentElement?.clientHeight||this.deck.height};let t=this.getCanvasBounds(e);return{x:t.x+e.x,y:t.y+e.y,width:e.width,height:e.height}}};function Y_(n,e){e&&Object.entries(e).map(([t,i])=>{t.startsWith("--")?n.style.setProperty(t,i):n.style[t]=i})}function r2(n,e){e&&Object.keys(e).map(t=>{t.startsWith("--")?n.style.removeProperty(t):n.style[t]=""})}var So=class{constructor(e){this.viewId=null,this.props={...this.constructor.defaultProps,...e},this.id=this.props.id}setProps(e){let t=this.props,i=this.rootElement;i&&t.className!==e.className&&(t.className&&i.classList.remove(t.className),e.className&&i.classList.add(e.className)),i&&!Ee(t.style,e.style,1)&&(r2(i,t.style),Y_(i,e.style)),Object.assign(this.props,e),this.updateHTML()}updateHTML(){this.rootElement&&this.onRenderHTML(this.rootElement)}get viewIds(){return this.viewId?[this.viewId]:this.deck?.getViews().map(e=>e.id)??[]}getViewState(e){return this.deck?.viewManager?.getViewState(e)||{}}setViewState(e,t){this.deck?._onViewStateChange({viewId:e,viewState:t,interactionState:{}})}onCreateRootElement(){let e=["deck-widget",this.className,this.props.className],t=document.createElement("div");return e.filter(i=>typeof i=="string"&&i.length>0).forEach(i=>t.classList.add(i)),Y_(t,this.props.style),t}_onAdd(e){return this.onAdd(e)??this.onCreateRootElement()}onAdd(e){}onRemove(){}onViewportChange(e){}onRedraw(e){}onHover(e,t){}onClick(e,t){}onDrag(e,t){}onDragStart(e,t){}onDragEnd(e,t){}};So.defaultProps={id:"widget",style:{},_container:null,className:""};var L6={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"},Rc=class extends So{constructor(e={}){super(e),this.id="default-tooltip",this.placement="fill",this.className="deck-tooltip",this.isVisible=!1,this.setProps(e)}onCreateRootElement(){let e=document.createElement("div");return e.className=this.className,Object.assign(e.style,L6),e}onRenderHTML(e){}onViewportChange(e){this.isVisible&&e.id===this.lastViewport?.id&&!e.equals(this.lastViewport)&&this.setTooltip(null),this.lastViewport=e}onHover(e){let{deck:t}=this,i=t&&t.props.getTooltip;if(!i)return;let r=i(e),s=this.widgetManager?.getCanvasBounds(e.viewport),o=e.x+(s?.x||0),a=e.y+(s?.y||0);this.setTooltip(r,o,a)}setTooltip(e,t,i){let r=this.rootElement;if(r){if(typeof e=="string")r.innerText=e;else if(e)e.text&&(r.innerText=e.text),e.html&&(r.innerHTML=e.html),e.className&&(r.className=e.className);else{this.isVisible=!1,r.style.display="none";return}this.isVisible=!0,r.style.display="block",r.style.transform=`translate(${t}px, ${i}px)`,e&&typeof e=="object"&&"style"in e&&Object.assign(r.style,e.style)}}};Rc.defaultProps={...So.defaultProps};var Ic=class{constructor(e){this.targets={},this.order=[],this.eventManagers={},this._eventRootToCanvasId=new WeakMap,this._createEventManager=e.createEventManager,this._getEventRoot=e.getEventRoot}finalize(){for(let e of Object.values(this.targets))e.eventManager.destroy(),e.presentationContext.destroy();this.targets={},this.order=[],this.eventManagers={},this._eventRootToCanvasId=new WeakMap}syncCanvasEntries(e){let t=this._normalizeCanvasList(e.canvases),i={},r=[],s=new Map;for(let{canvas:a}of t){let c=this._getEventRoot(a);s.set(c,(s.get(c)||0)+1)}for(let{id:a,canvas:c}of t){let l=this._getEventRoot(c),u=s.get(l)===1?l:c,f=this.targets[a];if(!f||f.device!==e.device||f.canvas!==c||f.eventRoot!==u){f?.eventManager.destroy(),f?.presentationContext.destroy();let d=e.device.createPresentationContext({id:a,canvas:c,useDevicePixels:e.useDevicePixels,autoResize:!0});f={id:a,device:e.device,canvas:c,eventRoot:u,presentationContext:d,eventManager:this._createEventManager(u)}}this._eventRootToCanvasId.set(u,a),this._eventRootToCanvasId.set(c,a),i[a]=f,r.push(a)}for(let[a,c]of Object.entries(this.targets))i[a]||(c.eventManager.destroy(),c.presentationContext.destroy());this.targets=i,this.order=r;let o=Object.fromEntries(Object.entries(i).map(([a,c])=>[a,c.eventManager]));this._haveSameEventManagers(o)||(this.eventManagers=o)}getCanvasIdFromEvent(e){return e?this._eventRootToCanvasId.get(e):void 0}getTarget(e){return this.targets[e||this.order[0]||er]||null}_normalizeCanvasList(e=[]){let t=new Set;return e.map((i,r)=>{let s,o;return typeof i=="string"?(s=document.getElementById(i),ge(s,`Canvas with id ${i} not found`),o=i):(s=i,o=s.id||`deckgl-canvas-${r}`),ge(!t.has(o),`Duplicate canvas id ${o}`),t.add(o),{id:o,canvas:s}})}_haveSameEventManagers(e){let t=Object.keys(e),i=Object.keys(this.eventManagers);return t.length===i.length&&t.every(r=>e[r]===this.eventManagers[r])}};J();bd();Me();Me();ua();function Ci(){}var zz=({isDragging:n})=>n?"grabbing":"grab",AP={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,pickAsync:"auto",layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{},gl:null,canvas:null,_canvases:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:Ci,onWebGLInitialized:Ci,onResize:Ci,onViewStateChange:Ci,onInteractionStateChange:Ci,onBeforeRender:Ci,onAfterRender:Ci,onLoad:Ci,onError:n=>ae.error(n.message,n.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:zz,getTooltip:null,debug:!1,drawPickingColors:!1},jc=class{constructor(e){this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.eventManagers={},this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this._canvasContext=null,this._deviceResizeHandler=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new Yt({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,layersCount:0,drawLayersCount:0,updateLayersCount:0,updateAttributesCount:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,pickLayersCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._hoverPickSequence=0,this._pointerDownPickSequence=0,this._needsRedraw="Initial render",this._canvasManager=new Ic({createEventManager:r=>this._createEventManager(r),getEventRoot:r=>this._getEventRoot(r)}),this._ownedCanvas=null,this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,canvasId:void 0,event:null,unproject3D:!1},this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this._onPointerMove=r=>{let{_pickRequest:s}=this,o=this._getCanvasIdFromEvent(r);if(r.type==="pointerleave")s.x=-1,s.y=-1,s.radius=0,s.canvasId=o;else{if(r.leftButton||r.rightButton)return;{let a=r.offsetCenter;if(!a)return;s.x=a.x,s.y=a.y,s.radius=this.props.pickingRadius,s.canvasId=o}}this.layerManager&&(this.layerManager.context.mousePosition={x:s.x,y:s.y}),s.event=r},this._onEvent=r=>{let s=ao[r.type],o=r.offsetCenter,a=this._getCanvasIdFromEvent(r);if(!s||!o||!this.layerManager)return;let c=this.layerManager.getLayers(),l=this._getInternalPickingMode();if(!l)return;if(l==="sync"){let f=r.type==="click"&&this._shouldUnproject3D(c)?this._getFirstPickedInfo(this._pickPointSync(this._getPointPickOptions(o.x,o.y,{unproject3D:!0,canvasId:a},c))):this._getLastPointerDownPickingInfo(o.x,o.y,a,c);this._dispatchPickingEvent(f,r);return}(this._lastPointerDownInfoPromise||Promise.resolve(this._getLastPointerDownPickingInfo(o.x,o.y,a,c))).then(f=>{this._dispatchPickingEvent(f,r)}).catch(f=>this.props.onError?.(f))},this._onPointerDown=r=>{let s=r.offsetCenter,o=this._getCanvasIdFromEvent(r);if(!s)return;let a=this._getInternalPickingMode();if(!a)return;let c=this.layerManager?.getLayers()||[],l=++this._pointerDownPickSequence;if(a==="sync"){let f=this._pickPointSync({x:s.x,y:s.y,canvasId:o,radius:this.props.pickingRadius}),d=this._getFirstPickedInfo(f);this._lastPointerDownInfo=d,this._lastPointerDownInfoPromise=Promise.resolve(d);return}let u=this._pickPointAsync(this._getPointPickOptions(s.x,s.y,{canvasId:o},c)).then(f=>this._getFirstPickedInfo(f)).then(f=>(l===this._pointerDownPickSequence&&(this._lastPointerDownInfo=f),f)).catch(f=>{this.props.onError?.(f);let d=this.deckPicker&&this.viewManager?this._getLastPointerDownPickingInfo(s.x,s.y,o,c):{};return l===this._pointerDownPickSequence&&(this._lastPointerDownInfo=d),d});this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=u};let t=e;this.props={...AP,...e},e=this.props,this._validateCanvasConfiguration(e),e.viewState&&e.initialViewState&&ae.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,e.device&&(this.device=e.device,this._setDeviceCanvasContext(e.device));let i=this.device;!i&&e.gl&&(e.gl instanceof WebGLRenderingContext&&ae.error("WebGL1 context not supported.")(),i=Wc.attach(e.gl,{_cacheShaders:!0,_cachePipelines:!0,...this.props.deviceProps})),i||(i=this._createDevice(e)),this.animationLoop=this._createAnimationLoop(i,e),this.setProps(t),e._typedArrayManagerProps&&gn.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){this._restoreDeviceResizeHandler(),this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._hoverPickSequence++,this._pointerDownPickSequence++,this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this.layerManager?.finalize(),this.layerManager=null,this.viewManager?.finalize(),this.viewManager=null,this.effectManager?.finalize(),this.effectManager=null,this.deckRenderer?.finalize(),this.deckRenderer=null,this.deckPicker?.finalize(),this.deckPicker=null,Object.keys(this._canvasManager.targets).length||this.eventManager?.destroy(),this.eventManager=null,this.eventManagers={},this.widgetManager?.finalize(),this.widgetManager=null,this._canvasManager.finalize(),this._isMultiCanvasMode()?this.canvas=null:this.canvas&&this.canvas===this._ownedCanvas&&(this.canvas.parentElement?.removeChild(this.canvas),this.canvas=null,this._ownedCanvas=null),this._canvasContext=null}setProps(e){this.stats.get("setProps Time").timeStart(),"onLayerHover"in e&&ae.removed("onLayerHover","onHover")(),"onLayerClick"in e&&ae.removed("onLayerClick","onClick")(),e.initialViewState&&!Ee(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),ge(!("_canvases"in e)||Array.isArray(e._canvases)===this._isMultiCanvasMode()),Object.assign(this.props,e),this._validateCanvasConfiguration(this.props),this._validateInternalPickingMode(),this.device&&this._isMultiCanvasMode()&&this._syncCanvasTargets(),this._setCanvasSize(this.props);let t=Object.create(this.props);if(Object.assign(t,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState(),eventManagers:this.eventManagers}),e.device&&e.device.id!==this.device?.id){let i=e.device.getDefaultCanvasContext();this.animationLoop?.stop(),!this._isMultiCanvasMode()&&this.canvas!==i.canvas&&(this.canvas?.remove(),this.eventManager?.destroy(),this.canvas=null),this._setDeviceCanvasContext(e.device),ae.log(`recreating animation loop for new device! id=${e.device.id}`)(),this.animationLoop=this._createAnimationLoop(e.device,e),this.animationLoop.start()}if(this.animationLoop?.setProps(t),e.useDevicePixels!==void 0&&this._canvasContext?.setProps){this._canvasContext.setProps({useDevicePixels:e.useDevicePixels});for(let i of Object.values(this._canvasManager.targets))i.presentationContext.setProps({useDevicePixels:e.useDevicePixels})}this.layerManager&&(this.viewManager.setProps(t),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(t),this.effectManager.setProps(t),this.deckRenderer.setProps(t),this.deckPicker.setProps(t),this.widgetManager.setProps(t)),this.stats.get("setProps Time").timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);let i=this.viewManager.needsRedraw(e),r=this.layerManager.needsRedraw(e),s=this.effectManager.needsRedraw(e),o=this.deckRenderer.needsRedraw(e);return t=t||i||r||s||o,t}redraw(e){if(!this.layerManager)return;let t=this.needsRedraw({clearRedrawFlags:!0});t=e||t,t&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(t):this._drawLayers(t))}get isInitialized(){return this.viewManager!==null}getViews(){return ge(this.viewManager),this.viewManager.views}getView(e){return ge(this.viewManager),this.viewManager.getView(e)}getViewports(e){return ge(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}getCanvasContext(e){let t=e?this.viewManager?.getView(e)?.props.canvasId:void 0;return this._getCanvasContext(t)}getEventManager(e){if(!e||!this.viewManager)return this.eventManager;let t=this.viewManager.getCanvasId(e)||er;return this.eventManagers[t]||this.eventManager}async pickObjectAsync(e){let t=(await this._pickAsync("pickObjectAsync","pickObject Time",e)).result;return t.length?t[0]:null}async pickObjectsAsync(e){return await this._pickAsync("pickObjectsAsync","pickObjects Time",e)}pickObject(e){let t=this._pick("pickObject","pickObject Time",e).result;return t.length?t[0]:null}pickMultipleObjects(e){return e.depth=e.depth||10,this._pick("pickObject","pickMultipleObjects Time",e).result}pickObjects(e){return this._pick("pickObjects","pickObjects Time",e)}_pickPositionForController(e,t,i){return this._getInternalPickingMode()!=="sync"?null:this.pickObject({x:e,y:t,radius:0,unproject3D:!0,canvasId:i?this.viewManager?.getCanvasId(i):void 0})}_addResources(e,t=!1){for(let i in e)this.layerManager.resourceManager.add({resourceId:i,data:e[i],forceUpdate:t})}_removeResources(e){for(let t of e)this.layerManager.resourceManager.remove(t)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_addDefaultShaderModule(e){this.layerManager.addDefaultShaderModule(e)}_removeDefaultShaderModule(e){this.layerManager?.removeDefaultShaderModule(e)}_resolveInternalPickingMode(){let{pickAsync:e}=this.props,t=this.device?.type||this.props.deviceProps?.type;if(e==="auto")return t==="webgpu"?"async":"sync";if(e==="sync"&&t==="webgpu")throw new Error('`pickAsync: "sync"` is not supported when Deck is using a WebGPU device.');return e}_getInternalPickingMode(){try{return this._resolveInternalPickingMode()}catch(e){return this.props.onError?.(e),null}}_validateInternalPickingMode(){this._getInternalPickingMode()}_getFirstPickedInfo({result:e,emptyInfo:t}){return e[0]||t}_shouldUnproject3D(e=this.layerManager?.getLayers()||[]){return e.some(t=>t.props.pickable==="3d")}_getPointPickOptions(e,t,i={},r=this.layerManager?.getLayers()||[]){return{x:e,y:t,canvasId:i.canvasId,radius:this.props.pickingRadius,unproject3D:this._shouldUnproject3D(r),...i}}_pickPointSync(e){return this._pick("pickObject","pickObject Time",e)}_pickPointAsync(e){return this._pickAsync("pickObjectAsync","pickObject Time",e)}_getLastPointerDownPickingInfo(e,t,i,r=this.layerManager?.getLayers()||[]){return this.deckPicker.getLastPickedObject({x:e,y:t,layers:r,viewports:this.getViewports({x:e,y:t,canvasId:i})},this._lastPointerDownInfo)}_applyHoverCallbacks({result:e,emptyInfo:t},i){if(!this.widgetManager)return;this.cursorState.isHovering=e.length>0;let r=t,s=!1;for(let o of e)r=o,s=o.layer?.onHover(o,i)||s;s||(this.props.onHover?.(r,i),this.widgetManager.onHover(r,i))}_dispatchPickingEvent(e,t){if(!this.layerManager||!this.widgetManager)return;let i=ao[t.type];if(!i)return;let{layer:r}=e,s=r&&(r[i]||r.props[i]),o=this.props[i],a=!1;s&&(a=s.call(r,e,t)),a||(o?.(e,t),this.widgetManager.onEvent(e,t))}_pickAsync(e,t,i){ge(this.deckPicker);let{stats:r}=this,s=this._isMultiCanvasMode()?i.canvasId||this._getDefaultCanvasId():i.canvasId,o=this._getCanvasContext(s)||void 0;r.get("Pick Count").incrementCount(),r.get(t).timeStart(),this._resizeForCanvasTarget(s);let a=this.deckPicker[e]({layers:this.layerManager.getLayers(i),views:this.viewManager.getViews(),viewports:this.getViewports({...i,canvasId:s}),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...i,canvasId:s,canvasContext:o});return r.get(t).timeEnd(),a}_pick(e,t,i){ge(this.deckPicker);let{stats:r}=this,s=this._isMultiCanvasMode()?i.canvasId||this._getDefaultCanvasId():i.canvasId,o=this._getCanvasContext(s)||void 0;r.get("Pick Count").incrementCount(),r.get(t).timeStart(),this._resizeForCanvasTarget(s);let a=this.deckPicker[e]({layers:this.layerManager.getLayers(i),views:this.viewManager.getViews(),viewports:this.getViewports({...i,canvasId:s}),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...i,canvasId:s,canvasContext:o});return r.get(t).timeEnd(),a}_createCanvas(e){let t=e.canvas;return typeof t=="string"&&(t=document.getElementById(t),ge(t)),t?this._ownedCanvas=null:(t=document.createElement("canvas"),t.id=e.id||"deckgl-overlay",e.width&&typeof e.width=="number"&&(t.width=e.width),e.height&&typeof e.height=="number"&&(t.height=e.height),(e.parent||document.body).appendChild(t),this._ownedCanvas=t),Object.assign(t.style,e.style),t}_isMultiCanvasMode(){return Array.isArray(this.props._canvases)}_getDefaultCanvasId(){return this._canvasManager.order[0]||er}_validateCanvasConfiguration(e){Array.isArray(e._canvases)&&(ge(!e.canvas),ge(!e.gl),ge(!e.device?.canvasContext||e.device.getDefaultCanvasContext().offscreenCanvas))}_createEventManager(e){let t=new sc(e,{touchAction:this.props.touchAction,recognizers:Object.keys(g_).map(i=>{let[r,s,o,a]=g_[i],c=this.props.eventRecognizerOptions?.[i],l={...s,...c,event:i};return{recognizer:new r(l),recognizeWith:o,requireFailure:a}}),events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(let i in ao)i==="dblclick"?t.watch(i,this._onEvent):t.on(i,this._onEvent);return t}_getEventRoot(e){return e.closest(".deck-events-root")||this.props.parent?.querySelector(".deck-events-root")||e}_syncCanvasTargets(){if(!this.device||!this._isMultiCanvasMode())return;this._canvasManager.syncCanvasEntries({device:this.device,canvases:this.props._canvases||[],useDevicePixels:this.props.useDevicePixels}),this.eventManagers=this._canvasManager.eventManagers;let e=this._getDefaultCanvasId();this.eventManager=this.eventManagers[e]||null,this.canvas=this._canvasManager.targets[e]?.canvas||null}_setCanvasContext(e){this._canvasContext=e,"style"in e.canvas&&(this.canvas=e.canvas)}_setDeviceCanvasContext(e,t={}){let i=e.getDefaultCanvasContext();this._setCanvasContext(i),this._setDeviceResizeHandler(e,t)}_setDeviceResizeHandler(e,t={}){let i=!!t.syncDrawingBuffer;if(this._deviceResizeHandler?.device===e){this._deviceResizeHandler.syncDrawingBuffer=i;return}this._restoreDeviceResizeHandler();let r=s=>{this._isMultiCanvasMode()?this._updateMultiCanvasDimensions():s===this._canvasContext&&this._canvasContext&&this._onCanvasContextResize(this._canvasContext,{syncDrawingBuffer:this._deviceResizeHandler?.syncDrawingBuffer})};e.props.onResize=r,this._deviceResizeHandler={device:e,onResize:r,syncDrawingBuffer:i}}_restoreDeviceResizeHandler(){let e=this._deviceResizeHandler;e&&e.device.props?.onResize===e.onResize&&(e.device.props.onResize=Ci),this._deviceResizeHandler=null}_setCanvasSize(e){if(this._isMultiCanvasMode()||!this.canvas)return;let{width:t,height:i}=e;if(t||t===0){let r=Number.isFinite(t)?`${t}px`:t;this.canvas.style.width=r}if(i||i===0){let r=Number.isFinite(i)?`${i}px`:i;this.canvas.style.position=e.style?.position||"absolute",this.canvas.style.height=r}}_getCanvasIdFromEvent(e){return this._canvasManager.getCanvasIdFromEvent(e?.rootElement)}_getCanvasContext(e){return this._canvasManager.getTarget(e)?.presentationContext||this._canvasContext}_resizeForCanvasTarget(e){let t=this._canvasManager.getTarget(e);if(!t||!this.device?.canvasContext)return;let[i,r]=t.presentationContext.getDrawingBufferSize();this.device.canvasContext.setDrawingBufferSize(i,r)}_createDeviceCanvas(e){if(this._isMultiCanvasMode()){let t=globalThis.OffscreenCanvas;if(!t)throw new Error("`_canvases` requires OffscreenCanvas support.");let i=typeof e.width=="number"&&Number.isFinite(e.width)?e.width:1,r=typeof e.height=="number"&&Number.isFinite(e.height)?e.height:1;return new t(i,r)}return this._createCanvas(e)}_updateCanvasSize(e=this._canvasContext){if(this._isMultiCanvasMode()){this._updateMultiCanvasDimensions();return}let{canvas:t}=this,[i,r]=e?e.getCSSSize():[t?.clientWidth??t?.width??0,t?.clientHeight??t?.height??0];(i!==this.width||r!==this.height)&&(this.width=i,this.height=r,this.viewManager?.setProps({width:i,height:r}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:i,height:r},e||void 0))}_onCanvasContextResize(e,t={}){if(t.syncDrawingBuffer){let{width:i,height:r}=e.canvas;e.setDrawingBufferSize(i,r)}this._needsRedraw="Canvas resized",this._updateCanvasSize(e)}_updateMultiCanvasDimensions(){let[e,t]=this._getCanvasContext()?.getCSSSize()||[0,0];(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.props.onResize({width:e,height:t})),this._needsRedraw="Canvas resized",this.viewManager?.setNeedsUpdate("Canvas resized"),this.viewManager?.setProps({width:this.width,height:this.height})}_createAnimationLoop(e,t){let{gl:i,onError:r}=t;return new gc({device:e,autoResizeDrawingBuffer:!i&&!Array.isArray(t._canvases),autoResizeViewport:!1,onInitialize:s=>this._setDevice(s.device),onRender:this._onRenderFrame.bind(this),onError:r})}_createDevice(e){let t=this.props.deviceProps?.createCanvasContext,i=typeof t=="object"?t:void 0,r={adapters:[],_cacheShaders:!0,_cachePipelines:!0,...e.deviceProps};r.adapters.includes(Wc)||r.adapters.push(Wc);let s={alphaMode:this.props.deviceProps?.type==="webgpu"?"premultiplied":void 0};return Vs.createDevice({_reuseDevices:!0,type:"webgl",...r,createCanvasContext:{...s,...i,canvas:this._createDeviceCanvas(e),useDevicePixels:this.props.useDevicePixels,autoResize:!0}})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let{views:e}=this.props,t=Array.isArray(e)?e:e?[e]:[new n2({id:"default-view"})];return t.length&&this.props.controller&&(t[0]=t[0].clone({controller:this.props.controller})),t}_onContextLost(){let{onError:e}=this.props;this.animationLoop&&e&&e(new Error("WebGL context is lost"))}_pickAndCallback(){let{_pickRequest:e}=this;if(e.event){let t=e.event,i=this.layerManager?.getLayers()||[],r=this._getPointPickOptions(e.x,e.y,{canvasId:e.canvasId,radius:e.radius,mode:e.mode},i),s=this._getInternalPickingMode(),o=++this._hoverPickSequence;if(e.event=null,e.canvasId=void 0,!s)return;if(s==="sync"){this._applyHoverCallbacks(this._pickPointSync(r),t);return}this._pickPointAsync(r).then(({result:a,emptyInfo:c})=>{o===this._hoverPickSequence&&this._applyHoverCallbacks({result:a,emptyInfo:c},t)}).catch(a=>this.props.onError?.(a))}}_updateCursor(){let e=this.props.getCursor(this.cursorState);if(this._isMultiCanvasMode()){for(let i of Object.values(this._canvasManager.targets))i.canvas.style.cursor=e;return}let t=this.props.parent||this.canvas;t&&(t.style.cursor=e)}_setDevice(e){if(this.device=e,this._validateInternalPickingMode(),!this.animationLoop)return;this._setDeviceCanvasContext(e,{syncDrawingBuffer:!!(this.props.gl&&this.props.device!==e)}),this._isMultiCanvasMode()?this._syncCanvasTargets():this.canvas&&!this.canvas.isConnected&&this.props.parent&&this.props.parent.insertBefore(this.canvas,this.props.parent.firstChild),this.device.type==="webgl"&&this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),this.device.type==="webgl"&&this.props.onWebGLInitialized(this.device.gl);let t=new Qr;if(t.play(),this.animationLoop.attachTimeline(t),!this._isMultiCanvasMode()){let s=this.canvas&&this._getEventRoot(this.canvas);ge(s),this.eventManager=this._createEventManager(s),this.eventManagers={[er]:this.eventManager}}this.viewManager=new Ec({timeline:t,eventManager:this.eventManager,eventManagers:this.eventManagers,getCanvasContext:this._isMultiCanvasMode()?this.getCanvasContext.bind(this):void 0,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),pickPosition:this._pickPositionForController.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});let i=this.viewManager.getViewports()[0];this.layerManager=new wc(this.device,{deck:this,stats:this.stats,viewport:i,timeline:t}),this.effectManager=new Lc({deck:this,device:this.device}),this.deckRenderer=new Ac(this.device,{stats:this.stats}),this.deckPicker=new kc(this.device,{stats:this.stats});let r=this.props.parent?.querySelector(".deck-widgets-root")||(this._isMultiCanvasMode()?this.props.parent||this.canvas?.parentElement:null)||this.canvas?.parentElement;this.widgetManager=new $f({deck:this,parentElement:r}),this.widgetManager.addDefault(new Rc),this.setProps({}),this._updateCanvasSize(this._canvasContext),this.props.onLoad()}_drawLayers(e,t){let{device:i,gl:r}=this.layerManager.context;this.props.onBeforeRender({device:i,gl:r});let s={target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:"screen",effects:this.effectManager.getEffects(),...t};if(this._isMultiCanvasMode()&&s.pass==="screen"&&!s.target&&this._canvasManager.order.length)for(let o of this._canvasManager.order){let a=s.viewports.filter(u=>this.viewManager.getCanvasId(u.id)===o);if(!a.length){let u=this._canvasManager.targets[o];this._resizeForCanvasTarget(o),this.deckRenderer?.renderLayers({...s,canvasContext:u.presentationContext,target:u.presentationContext.getCurrentFramebuffer(),viewports:[],clearCanvas:!0}),u.presentationContext.present();continue}let c=this._canvasManager.targets[o];this._resizeForCanvasTarget(o);let l=c.presentationContext.getCurrentFramebuffer();this.deckRenderer?.renderLayers({...s,canvasContext:c.presentationContext,target:l,viewports:a}),c.presentationContext.present()}else this.deckRenderer?.renderLayers(s);s.pass==="screen"&&this.widgetManager.onRedraw({viewports:s.viewports,layers:s.layers}),this.props.onAfterRender({device:i,gl:r})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60===0&&(this._getMetrics(),this.stats.reset(),ae.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCursor(),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){let t=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:t},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(e){this.cursorState.isDragging=e.isDragging||!1,this.props.onInteractionStateChange(e)}_getFrameStats(){let{stats:e}=this;e.get("frameRate").timeEnd(),e.get("frameRate").timeStart();let t=this.animationLoop.stats;e.get("GPU Time").addTime(t.get("GPU Time").lastTiming),e.get("CPU Time").addTime(t.get("CPU Time").lastTiming)}_getMetrics(){let{metrics:e,stats:t}=this;e.fps=t.get("frameRate").getHz(),e.setPropsTime=t.get("setProps Time").time,e.updateAttributesTime=t.get("Update Attributes").time,e.framesRedrawn=t.get("Redraw Count").count,e.pickTime=t.get("pickObject Time").time+t.get("pickMultipleObjects Time").time+t.get("pickObjects Time").time,e.pickCount=t.get("Pick Count").count,e.layersCount=this.layerManager?.layers.length??0,e.drawLayersCount=t.get("Layers rendered").lastSampleCount,e.pickLayersCount=t.get("Layers picked").lastSampleCount,e.updateLayersCount=t.get("Layer updates").count,e.updateAttributesCount=t.get("Attributes updated").count,e.gpuTime=t.get("GPU Time").time,e.cpuTime=t.get("CPU Time").time,e.gpuTimePerFrame=t.get("GPU Time").getAverageTime(),e.cpuTimePerFrame=t.get("CPU Time").getAverageTime();let i=Vs.stats.get("GPU Time and Memory");e.bufferMemory=i.get("Buffer Memory").count,e.textureMemory=i.get("Texture Memory").count,e.renderbufferMemory=i.get("Renderbuffer Memory").count,e.gpuMemory=i.get("GPU Memory").count}};jc.defaultProps=AP;jc.VERSION=Nx;var xy=jc;J();J();function kP(n){switch(n){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return Lr(n)}}var RP=Xe.getDataType.bind(Xe);function Hc(n,e,t){if(e.size>4)return null;let i=t==="webgpu"&&e.type==="uint8"?"unorm8":e.type,r=e.size,s=!!(t!=="webgpu"&&r===3&&i&&["uint8","sint8","unorm8","snorm8","uint16","sint16","unorm16","snorm16"].includes(i));return{attribute:n,format:r>1?`${i}x${r}${s?"-webgl":""}`:e.type,byteOffset:e.offset||0}}function rn(n){return n.stride||n.size*n.bytesPerElement}function IP(n,e){return n.type===e.type&&n.size===e.size&&rn(n)===rn(e)&&(n.offset||0)===(e.offset||0)}function wy(n,e){e.offset&&ae.removed("shaderAttribute.offset","vertexOffset, elementOffset")();let t=rn(n),i=e.vertexOffset!==void 0?e.vertexOffset:n.vertexOffset||0,r=e.elementOffset||0,s=i*t+r*n.bytesPerElement+(n.offset||0);return{...e,offset:s,stride:t}}function Uz(n,e){let t=wy(n,e);return{high:t,low:{...t,offset:t.offset+n.size*4}}}var Yc=class{constructor(e,t,i){this._buffer=null,this.device=e,this.id=t.id||"",this.size=t.size||1;let r=t.logicalType||t.type,s=r==="float64",{defaultValue:o}=t;o=Number.isFinite(o)?[o]:o||new Array(this.size).fill(0);let a;s?a="float32":!r&&t.isIndexed?a="uint32":a=r||"float32";let c=kP(r||a);this.doublePrecision=s,s&&t.fp64===!1&&(c=Float32Array),this.value=null,this.settings={...t,defaultType:c,defaultValue:o,logicalType:r,type:a,normalized:a.includes("norm"),size:this.size,bytesPerElement:c.BYTES_PER_ELEMENT},this.state={...i,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){let e=this.getAccessor();return e.vertexOffset?e.vertexOffset*rn(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}get isDoublePrecisionBuffer(){return this._shouldSplitDoublePrecisionValue(this.value)}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),gn.release(this.state.allocatedValue),this.state.allocatedValue=null}getBuffer(){return this.state.constant&&this.device.type!=="webgpu"?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,t=null){let i={};if(this.state.constant){let r=this.value;if(this.device.type==="webgpu"&&this._buffer)i[e]=this._buffer;else if(t){let s=wy(this.getAccessor(),t),o=s.offset/r.BYTES_PER_ELEMENT,a=s.size||this.size;i[e]=r.subarray(o,o+a)}else i[e]=r}else i[e]=this.getBuffer();return this.doublePrecision&&(this.isDoublePrecisionBuffer?i[`${e}64Low`]=i[e]:i[`${e}64Low`]=new Float32Array(this.size)),i}_getBufferLayout(e=this.id,t=null){let i=this.getAccessor(),r=[],s={name:this.id,byteStride:this.device.type==="webgpu"&&this.state.constant?0:rn(i)};if(this.doublePrecision){let o=Uz(i,t||{});r.push(Hc(e,{...i,...o.high},this.device.type),Hc(`${e}64Low`,{...i,...o.low},this.device.type))}else if(t){let o=wy(i,t);r.push(Hc(e,{...i,...o},this.device.type))}else r.push(Hc(e,i,this.device.type));return s.attributes=r.filter(Boolean),s}setAccessor(e){this.state.bufferAccessor=e}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let e=null;if(this.state.constant&&this.value){let t=Array.from(this.value);e=[t,t]}else{let{value:t,numInstances:i,size:r}=this,s=i*r;if(t&&s&&t.length>=s){let o=new Array(r).fill(1/0),a=new Array(r).fill(-1/0);for(let c=0;ca[l]&&(a[l]=u)}e=[o,a]}}return this.state.bounds=e,e}setData(e){let{state:t}=this,i;ArrayBuffer.isView(e)?i={value:e}:e instanceof ie?i={buffer:e}:i=e;let r={...this.settings,...i};if(ArrayBuffer.isView(i.value)){if(!i.type)if(this.doublePrecision&&i.value instanceof Float64Array)r.type="float32";else{let o=RP(i.value);r.type=r.normalized?o.replace("int","norm"):o}r.bytesPerElement=i.value.BYTES_PER_ELEMENT,r.stride=rn(r)}if(t.bounds=null,i.constant){let s=i.value;if(s=this._normalizeValue(s,[],0),this.settings.normalized&&(s=this.normalizeConstant(s)),!(!t.constant||!this._areValuesEqual(s,this.value)))return!1;t.externalBuffer=null,t.constant=!0,this.value=ArrayBuffer.isView(s)?s:new Float32Array(s)}else if(i.buffer){let s=i.buffer;t.externalBuffer=s,t.constant=!1,this.value=i.value||null}else if(i.value){this._checkExternalBuffer(i);let s=i.value,o=s;t.externalBuffer=null,t.constant=!1,this.value=s,this._shouldSplitDoublePrecisionValue(o)&&(o=mo(o,r),s instanceof Float32Array&&(r.stride=r.size*2*Float32Array.BYTES_PER_ELEMENT));let{buffer:a}=this,c=rn(r),l=(r.vertexOffset||0)*c;if(this.settings.isIndexed){let f=this.settings.defaultType;o.constructor!==f&&(o=new f(o))}let u=o.byteLength+l+c*2;(!a||a.byteLength(t+128)/255*2-1);case"snorm16":return new Float32Array(e).map(t=>(t+32768)/65535*2-1);case"unorm8":return new Float32Array(e).map(t=>t/255);case"unorm16":return new Float32Array(e).map(t=>t/65535);default:return e}}_normalizeValue(e,t,i){let{defaultValue:r,size:s}=this.settings;if(Number.isFinite(e))return t[i]=e,t;if(!e){let o=s;for(;--o>=0;)t[i+o]=r[o];return t}switch(s){case 4:t[i+3]=Number.isFinite(e[3])?e[3]:r[3];case 3:t[i+2]=Number.isFinite(e[2])?e[2]:r[2];case 2:t[i+1]=Number.isFinite(e[1])?e[1]:r[1];case 1:t[i+0]=Number.isFinite(e[0])?e[0]:r[0];break;default:let o=s;for(;--o>=0;)t[i+o]=Number.isFinite(e[o])?e[o]:r[o]}return t}_areValuesEqual(e,t){if(!e||!t)return!1;let{size:i}=this;for(let r=0;r0&&(OP.length=n.length,i=OP):i=BP,(e>0||Number.isFinite(t))&&(i=(Array.isArray(i)?i:Array.from(i)).slice(e,t),r.index=e-1),{iterable:i,objectInfo:r}}function Sd(n){return n&&n[Symbol.asyncIterator]}function Pd(n,e){let{size:t,stride:i,offset:r,startIndices:s,nested:o}=e,a=n.BYTES_PER_ELEMENT,c=i?i/a:t,l=r?r/a:0,u=Math.floor((n.length-l)/c);return(f,{index:d,target:h})=>{if(!s){let v=d*c+l;for(let y=0;y=e[1]))return n;let t=[],i=n.length,r=0;for(let s=0;se[1]?t.push(o):e=[Math.min(o[0],e[0]),Math.max(o[1],e[1])]}return t.splice(r,0,e),t}var Gz={interpolation:{duration:0,easing:n=>n},spring:{stiffness:.05,damping:.5}};function Cd(n,e){if(!n)return null;Number.isFinite(n)&&(n={type:"interpolation",duration:n});let t=n.type||"interpolation";return{...Gz[t],...e,...n,type:t}}var as=class extends Yc{constructor(e,t){super(e,t,{startIndices:null,constantValue:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:qc}),this.constant=!1,this.settings.update=t.update||(t.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(e){this.state.startIndices=e}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:e=!1}={}){let t=this.state.needsRedraw;return this.state.needsRedraw=t&&!e,t}layoutChanged(){return this.state.layoutChanged}setAccessor(e){var t;(t=this.state).layoutChanged||(t.layoutChanged=!IP(e,this.getAccessor())),super.setAccessor(e)}getUpdateTriggers(){let{accessor:e}=this.settings;return[this.id].concat(typeof e!="function"&&e||[])}supportsTransition(){return!!this.settings.transition}getTransitionSetting(e){if(!e||!this.supportsTransition())return null;let{accessor:t}=this.settings,i=this.settings.transition,r=Array.isArray(t)?e[t.find(s=>e[s])]:e[t];return Cd(r,i)}setNeedsUpdate(e=this.id,t){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),t){let{startRow:i=0,endRow:r=1/0}=t;this.state.updateRanges=NP(this.state.updateRanges,[i,r])}else this.state.updateRanges=qc}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=DP}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){let{state:t,settings:i}=this;if(i.noAlloc)return!1;if(i.update){let r=this.isConstant;return super.allocate(e,t.updateRanges!==qc),t.layoutChanged||(t.layoutChanged=r&&this.device.type==="webgpu"),!0}return!1}updateBuffer({numInstances:e,data:t,props:i,context:r}){if(!this.needsUpdate())return!1;let{state:{updateRanges:s},settings:{update:o,noAlloc:a}}=this,c=!0;if(o){for(let[l,u]of s)o.call(r,this,{data:t,startRow:l,endRow:u,props:i,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLengthu?l.set(b,m):(e._normalizeValue(b,v.target,0),Y1({target:l,source:v.target,start:m,count:x}));m+=x*u}else e._normalizeValue(b,l,m),m+=u}}_validateAttributeUpdaters(){let{settings:e}=this;if(!(e.noAlloc||typeof e.update=="function"))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){let{value:e}=this,t=Math.min(4,this.size);if(e&&e.length>=t){let i=!0;switch(t){case 4:i=i&&Number.isFinite(e[3]);case 3:i=i&&Number.isFinite(e[2]);case 2:i=i&&Number.isFinite(e[1]);case 1:i=i&&Number.isFinite(e[0]);break;default:i=!1}if(!i)throw new Error(`Illegal attribute generated for ${this.id}`)}}};Mi();Ly();Mi();var Xc=class n{gpuDataEvaluators;format;length;id;_gpuVector;_ownsGPUDataEvaluators;_destroyed=!1;static fromGPUVector(e){if(e.bufferLayout)throw new Error(`GPUVectorEvaluator.fromGPUVector() does not accept interleaved vector "${e.name}"`);if(e.data.length===0)throw new Error(`GPUVectorEvaluator.fromGPUVector() requires GPUData for "${e.name}"`);return new n({id:e.name,gpuDataEvaluators:e.data.map(t=>ve.fromGPUData(t,{id:e.name})),gpuVector:e,format:e.format})}static fromGPUDataEvaluators(e,t={}){return new n({id:t.id,gpuDataEvaluators:e,format:t.format})}constructor({id:e,gpuDataEvaluators:t,gpuVector:i,format:r}){if(t.length===0)throw new Error("GPUVectorEvaluator requires at least one GPUData evaluator");tU(t),this.id=e,this.gpuDataEvaluators=t,this.format=r??t[0].format,this.length=t.reduce((s,o)=>s+o.length,0),this._gpuVector=i,this._ownsGPUDataEvaluators=!i}get evaluated(){return!!this._gpuVector}get gpuVector(){if(!this._gpuVector)throw new Error(`${this} not evaluated`);return this._gpuVector}mapGPUData(e){return n.fromGPUDataEvaluators(this.gpuDataEvaluators.map((t,i)=>e(t,i)),{id:this.id})}async evaluate(e,t={}){if(this._destroyed)throw new Error(`GPUVectorEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let i=await Promise.all(this.gpuDataEvaluators.map(a=>a.evaluate(e,t))),r=i[0],s=i.map(ZP),o=t.format??this.format??r.format;return this._gpuVector=new ri({type:"data",name:t.name??this.id??"vector",format:o,data:s,stride:r.stride,byteStride:r.byteStride,rowByteLength:r.rowByteLength,bufferLayout:r.bufferLayout}),this._gpuVector}evaluateSync(e,t={}){if(this._destroyed)throw new Error(`GPUVectorEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let i=this.gpuDataEvaluators.map(a=>a.evaluateSync(e,t)),r=i[0],s=i.map(ZP),o=t.format??this.format??r.format;return this._gpuVector=new ri({type:"data",name:t.name??this.id??"vector",format:o,data:s,stride:r.stride,byteStride:r.byteStride,rowByteLength:r.rowByteLength,bufferLayout:r.bufferLayout}),this._gpuVector}destroy(){if(this._ownsGPUDataEvaluators)for(let e of this.gpuDataEvaluators)e.destroy();this._gpuVector=void 0,this._destroyed=!0}toString(){return this.id??this.constructor.name}};function tU(n){let e=n[0];for(let t of n.slice(1))if(t.type!==e.type||t.size!==e.size||t.normalized!==e.normalized||t.format!==e.format)throw new Error("GPUVectorEvaluator requires matching GPUData evaluator layouts")}function ZP(n){let[e,...t]=n.data;if(!e||t.length>0)throw new Error(`GPUVectorEvaluator requires one GPUData chunk for "${n.name}"`);return e}Mi();J();var Ry={};mi(Ry,{arithmetic:()=>XP,dot:()=>nC,equalAll:()=>iC,extent:()=>QP,fround:()=>JP,gather:()=>eC,interleave:()=>tC,length:()=>rC,segmentedMap:()=>sC,select:()=>oC,sequence:()=>aC,swizzle:()=>cC});Bd();function ko({elementWise:n,func:e,inputs:t,output:i,outputBuffer:r}){let s=Array.isArray(t)?t:Object.values(t);for(let p of s)if(!p.value)throw new Error(`${p} does not have CPU value`);let o=i.length,a=i.size,c=new i.ValueType(o*a);for(let p=0;pDe(g,p));if(n)for(let g=0;gv[g]));else e.call(null,c.subarray(p*a,p*a+a),...m)}let l=i.ValueType.BYTES_PER_ELEMENT,u=i.offset/l,f=i.stride/l,d=a,h=c;if(u!==0||f!==d){h=new i.ValueType(u+i.byteLength/l);for(let p=0;p{for(let r of Object.values(n.namedInputs))if(!r.value)throw new Error(`${r} does not have CPU value`);let i=new e.ValueType(e.length*e.size);for(let r=0;r[o,De(a,r)]));for(let o=0;oKP(r,e,t));switch(n.op){case"add":return i[0]+i[1];case"subtract":return i[0]-i[1];case"multiply":return i[0]*i[1];case"divide":return i[0]/i[1];case"pow":return Math.pow(i[0],i[1]);case"sqrt":return Math.sqrt(i[0]);case"abs":return Math.abs(i[0]);case"sin":return Math.sin(i[0]);case"cos":return Math.cos(i[0]);case"tan":return Math.tan(i[0]);case"exp":return Math.exp(i[0]);case"log":return Math.log(i[0]);default:{let r=n.op;throw new Error(`Unsupported arithmetic op ${r}`)}}}default:{let i=n;throw new Error(`Unsupported expression node ${i.kind}`)}}}function iU(n,e){let t=Ao[n].arity;if(e!==t)throw new Error(`Arithmetic op '${n}' expects ${t} args, got ${e}`)}var QP=({inputs:n,output:e,target:t})=>{let{sourceValues:i}=n;if(!i.value)throw new Error(`${i} does not have CPU value`);let s=new e.ValueType(e.length*e.size);if(i.length===0)return{success:!1,error:new Error(`${i} is empty`)};for(let o=0;os[l]&&(s[l]=f)}}return t.write(s),{success:!0,value:s}};var JP=({inputs:n,output:e,target:t})=>ko({func:(i,r)=>{let s=i.length/2,o=new Float64Array(r.buffer);for(let a=0;a{let{ids:i,sourceValues:r}=n,s=i.value,o=r.value;if(!s)throw new Error(`${i} does not have CPU value`);if(!o)throw new Error(`${r} does not have CPU value`);let a=new e.ValueType(e.length*e.size),c=new Array(e.size).fill(0);for(let l=0;l=0&&nko({func:(i,...r)=>{let s=0;for(let o of r)i.set(o,s),s+=o.length},inputs:n,output:e,outputBuffer:t});var nC=({inputs:n,output:e,target:t})=>{let{x:i,y:r}=n,s=new e.ValueType(e.length);for(let o=0;o{let{x:i,y:r}=n,s=new e.ValueType(e.length);for(let o=0;o{let{x:i}=n,r=new e.ValueType(e.length);for(let s=0;s{let{segments:i,vertexCount:r}=n,s=i.value;if(!s)throw new Error(`${i} does not have CPU value`);sU(s,i,r);let o=new e.ValueType(e.length*e.size),a=0;for(let c=0;c0&&st)throw new Error(`segmentedMap last segment start must be <= vertexCount, got ${i} > ${t}`)}function Ay(n,e){return n.offset/n.ValueType.BYTES_PER_ELEMENT+e*(n.stride/n.ValueType.BYTES_PER_ELEMENT)}var oC=async({inputs:n,output:e,target:t})=>{let{condition:i,whenTrue:r,whenFalse:s}=n,o=new e.ValueType(e.length*e.size);for(let a=0;a{let i=new e.ValueType(e.length);for(let r=0;r{let{columns:i}=n;return ko({func:(r,s)=>{for(let o=0;o({...o,...a}));return this._modules[e]=s,s.then(o=>{this._modules[e]=o}).catch(o=>{N.error(`Failed to register ${e} backend: ${o}`)()}),s}if(i&&typeof i.then=="function"){let s=Promise.resolve(i).then(o=>({...o,...t})).then(o=>(this._modules[e]=o,o)).catch(o=>{throw N.error(`Failed to register ${e} backend: ${o}`)(),o});return this._modules[e]=s,s}let r={...i||{},...t};return this._modules[e]=r,Promise.resolve(r)}async get(e,t){let i=this._modules[e];if(!i)if(e==="webgl")i=this.add("webgl",Promise.resolve().then(()=>(FC(),NC)));else if(e==="webgpu")i=this.add("webgpu",Promise.resolve().then(()=>(Wy(),uT)));else throw new Error(`${e} backend not registered`);let s=(await i)[t];if(typeof s!="function")throw new Error(`${e} backend does not implement ${t}`);return s}getSync(e,t){let i=this._modules[e];if(!i)throw new Error(`${e} backend not registered`);if(typeof i.then=="function")throw new Error(`${e} backend is not loaded yet`);let s=i[t];if(typeof s!="function")throw new Error(`${e} backend does not implement ${t}`);return s}clear(){this._modules={}}},No=new jy;var Vd=class{inputs;dependencies;constructor(e){this.inputs=e,this.dependencies=Array.from(e instanceof Array?e:Object.values(e)).filter(t=>t instanceof ve)}async execute(e,t){return await this._resolveDependencies(e),await this._executeWithHandler(await No.get(this._getHandlerRegistry(e),this.name),t)}executeSync(e,t){this._resolveDependenciesSync(e);let i=this._executeWithHandler(No.getSync(this._getHandlerRegistry(e),this.name),t);if(XU(i))throw new Error(`${this.name} returned a Promise in executeSync()`);return i}shouldExecuteOnCPU(){return this.output.length<=1&&Array.from(this.dependencies).every(e=>!!e.value)}_getHandlerRegistry(e){return this.shouldExecuteOnCPU()?"cpu":e.type}async _resolveDependencies(e){for(let i of this.dependencies)await i.evaluate(e);if(this._getHandlerRegistry(e)==="cpu"||e.type==="null")for(let i of this.dependencies)await i.ensureCPUValue()}_resolveDependenciesSync(e){for(let i of this.dependencies)i.evaluateSync(e);if(this._getHandlerRegistry(e)==="cpu"||e.type==="null")for(let i of this.dependencies)i.ensureCPUValueSync()}_executeWithHandler(e,t){return e({device:t.device,inputs:this.inputs,output:this.output,target:t})}};function XU(n){return typeof n?.then=="function"}function fT(...n){let e=KU(n.map(t=>t.type));return e[0]!=="f"&&n.some(t=>t.normalized)&&(e="float32"),{isConstant:n.every(t=>t.isConstant),type:e,size:n.reduce((t,i)=>Math.max(t,i.size),0),length:n.reduce((t,i)=>Math.max(t,i.length),0)}}function KU(n){let e=0,t=0;for(let i of n){if(i[0]==="f")return"float32";let r=i.endsWith("8")?8:i.endsWith("6")?16:32;i[0]==="u"?e=Math.max(e,r):t=Math.max(t,r)}return e&&!t?`uint${e}`:t&&e<32?`sint${Math.max(t,e*2)}`:"float32"}Mi();var Hy=class extends Vd{name="interleave";output;constructor(e){super(e);let{isConstant:t,type:i,length:r}=fT(...e);this.output=new ve({isConstant:t,type:i,size:e.reduce((s,o)=>s+o.size,0),length:r,source:this})}toString(){return`_${this.inputs.join("_")}_`}};function Yy(...n){if(n.length===0)throw new Error("interleave() requires at least one input");return n.length===1?Id(n[0]):new Hy(n.map(Id)).output}Me();Mi();function Zy(n,e){let t=JU(e);for(let i of t)i.evaluateSync(n);return QU(t),e}function QU(n){let e=new Set(n.flatMap(t$)),t=new Set;for(let i of n)Wd(i,t);for(let i of t)i.evaluated&&!e.has(i.buffer)&&i.destroy()}function JU(n){let e=new Set;return qy(n,e,new Set),Array.from(e)}function qy(n,e,t){if(n$(n)){e.add(n);return}if(!(!n||typeof n!="object"||t.has(n))){if(t.add(n),Array.isArray(n)){for(let i of n)qy(i,e,t);return}if(e$(n))for(let i of Object.values(n))qy(i,e,t)}}function e$(n){let e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function Wd(n,e){if(n instanceof Xc){for(let i of n.gpuDataEvaluators)Wd(i,e);return}let t=n.source;if(t){if(t instanceof ve){e.has(t)||(e.add(t),Wd(t,e));return}for(let i of t.dependencies)e.has(i)||(e.add(i),Wd(i,e))}}function t$(n){return n instanceof ve?[n.buffer]:n.gpuVector.data.map(e=>e.buffer instanceof tt?e.buffer.buffer:e.buffer)}function n$(n){return n instanceof ve||n instanceof Xc}Wy();var Qc=class{constructor(e,{id:t,isTransitionAttribute:i}){this.packedBuffers={},this.device=e,this.id=t,this.isTransitionAttribute=i,this.device.type==="webgpu"&&No.add("webgpu",{interleave:Gd})}hasGroups(e){return this.device.type==="webgpu"&&Object.values(e).some(t=>!!t.settings.bufferGroup)}finalize(){for(let e of Object.values(this.packedBuffers))e.packed.destroy();this.packedBuffers={}}getBufferLayouts(e,t){let i=this._getPackedGroups(e,t,{requireValues:!1,excludeAttributes:{}});return this._getBufferLayouts(e,i,t)}getBindings(e,t,i,r){let s=this._getPackedGroups(e,i,{requireValues:!0,excludeAttributes:r}),o={},a=new Set;for(let c of s.values()){let l=!this.packedBuffers[c.id]||c.attributes.some(u=>!!t[u.id]);o[c.id]=this._getPackedBuffer(c,l);for(let u of c.attributes)a.add(u.id)}return{bufferLayouts:this._getBufferLayouts(e,s,i).filter(c=>!r[c.name]&&!e[c.name]?.settings.isIndexed),buffers:o,groupedAttributeIds:a}}_getPackedGroups(e,t,{requireValues:i,excludeAttributes:r}){let s=new Map;for(let a of Object.values(e)){let c=a.settings.bufferGroup;if(!c)continue;let l=s.get(c)||[];l.push(a),s.set(c,l)}let o=new Map;for(let[a,c]of s){let l=this._getPackedGroup(a,c,t,i,r);l&&o.set(a,l)}return o}_getPackedGroup(e,t,i,r,s){if(t.length<2)return null;let o=t.map(h=>h.getBufferLayout(i)),a=o[0].stepMode,c=Math.max(1,t[0].numInstances),l=r&&t.every(h=>h.isConstant);for(let h=0;hthis._getInterleaveInput(e,r)),i=Yy(...t);return Zy(this.device,i),i}_getInterleaveInput(e,t){let i=rn(t.getAccessor()),r=e.byteOffsets[t.id];if(Kc(`${e.id}.${t.id} rowByteLength`,i),Kc(`${e.id}.${t.id} groupByteOffset`,r),t.isConstant){let c=t.getConstantValue();if(!c)throw new Error(`Attribute group ${e.id} is missing constant value ${t.id}`);return Kc(`${e.id}.${t.id} constant byteOffset`,c.byteOffset),new ve({id:t.id,type:"uint32",size:i/4,isConstant:!0,value:new Uint32Array(c.buffer,c.byteOffset,i/Uint32Array.BYTES_PER_ELEMENT)})}let s=t.getBuffer(),o=t.byteOffset,a=t.getAccessor().stride||i;if(Kc(`${e.id}.${t.id} byteOffset`,o),Kc(`${e.id}.${t.id} stride`,a),!s)throw new Error(`Attribute group ${e.id} cannot interleave missing buffer ${t.id}`);return new ve({id:t.id,type:"uint32",size:i/4,offset:o,stride:a,length:e.rowCount,buffer:s})}};function dT(n){return Math.ceil(n/4)*4}function Kc(n,e){if(e%4!==0)throw new Error(`Attribute buffer groups require 32-bit alignment: ${n}=${e}`)}Me();vt();function Xy(n){let{source:e,target:t,start:i=0,size:r,getData:s}=n,o=n.end||t.length,a=e.length,c=o-i;if(a>c){t.set(e.subarray(0,c),i);return}if(t.set(e,i),!s)return;let l=a;for(;li(u+a,f)),l=Math.min(r.length,s.length);for(let u=1;ua}){let a=t.isDoublePrecisionBuffer?2:1,c=t.size*a,l=t.byteOffset,u=t.settings.bytesPerElement<4?l/t.settings.bytesPerElement*4:l,f=t.startIndices,d=s&&f,h=t.isConstant;if(!d&&e&&i>=r)return e;let p=t.value instanceof Float64Array?Float32Array:t.value.constructor,m=h?t.value:new p(t.getBuffer().readSyncWebGL(l,r*p.BYTES_PER_ELEMENT).buffer);if(t.settings.normalized&&!h){let b=o;o=(x,E)=>t.normalizeConstant(b(x,E))}let g=h?(b,x)=>o(m,x):(b,x)=>o(m.subarray(b+l,b+l+c),x),v=e?new Float32Array(e.readSyncWebGL(u,i*4).buffer):new Float32Array(0),y=new Float32Array(r);return hT({source:v,target:y,sourceStartIndices:s,targetStartIndices:f,size:c,getData:g}),(!e||e.byteLength0||r.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}},r$=`layout(std140) uniform springUniforms { +`;function _T(n){return n.isDoublePrecisionBuffer}function o$(n,e){let t=e.size,i=jd(t),r=Hd(t),s=e.getBufferLayout();return _T(e)?new nt(n,{vs:s$,bufferLayout:[{name:"aFrom",byteStride:8*t,attributes:[{attribute:"aFrom",format:r,byteOffset:0},{attribute:"aFrom64Low",format:r,byteOffset:4*t}]},{name:"aTo",byteStride:8*t,attributes:[{attribute:"aTo",format:r,byteOffset:0},{attribute:"aTo64Low",format:r,byteOffset:4*t}]}],modules:[i_,gT],defines:{ATTRIBUTE_TYPE:i,ATTRIBUTE_SIZE:t},moduleSettings:{},varyings:["vCurrent","vCurrent64Low"],bufferMode:35980,disableWarnings:!0}):new nt(n,{vs:r$,bufferLayout:[{name:"aFrom",format:r},{name:"aTo",format:s.attributes[0].format}],modules:[gT],defines:{ATTRIBUTE_TYPE:i},varyings:["vCurrent"],disableWarnings:!0})}Me();var el=class extends Fo{constructor({device:e,attribute:t,timeline:i}){super({device:e,attribute:t,timeline:i}),this.type="spring",this.texture=d$(e),this.framebuffer=h$(e,this.texture),this.transform=f$(e,t)}start(e,t){let i=this.currentLength,r=this.currentStartIndices;super.start(e,t);let{buffers:s,attribute:o}=this;for(let c=0;c<2;c++)s[c]=Zd({device:this.device,buffer:s[c],attribute:o,fromLength:i,toLength:this.currentLength,fromStartIndices:r,getData:e.enter});s[2]=qd({device:this.device,source:s[0],target:s[2]}),this.setBuffer(s[1]);let{model:a}=this.transform;a.setVertexCount(Math.floor(this.currentLength/o.size)),o.isConstant?a.setConstantAttributes({aTo:o.value}):a.setAttributes({aTo:o.getBuffer()})}onUpdate(){let{buffers:e,transform:t,framebuffer:i,transition:r}=this,s=this.settings;t.model.setAttributes({aPrev:e[0],aCur:e[1]}),t.transformFeedback.setBuffers({vNext:e[2]});let o={stiffness:s.stiffness,damping:s.damping};t.model.shaderInputs.setProps({spring:o}),t.run({framebuffer:i,discard:!1,parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]}),Yd(e),this.setBuffer(e[1]),this.device.readPixelsToArrayWebGL(i)[0]>0||r.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}},a$=`layout(std140) uniform springUniforms { float damping; float stiffness; } spring; -`,s$={name:"spring",vs:r$,uniformTypes:{damping:"f32",stiffness:"f32"}},o$=`#version 300 es +`,c$={name:"spring",vs:a$,uniformTypes:{damping:"f32",stiffness:"f32"}},l$=`#version 300 es #define SHADER_NAME spring-transition-vertex-shader #define EPSILON 0.00001 @@ -4175,7 +4175,7 @@ void main(void) { gl_Position = vec4(0, 0, 0, 1); gl_PointSize = 100.0; } -`,a$=`#version 300 es +`,u$=`#version 300 es #define SHADER_NAME spring-transition-is-transitioning-fragment-shader in float vIsTransitioningFlag; @@ -4187,7 +4187,7 @@ void main(void) { discard; } fragColor = vec4(1.0); -}`;function c$(n,e){let t=Wd(e.size),i=jd(e.size);return new it(n,{vs:o$,fs:a$,bufferLayout:[{name:"aPrev",format:i},{name:"aCur",format:i},{name:"aTo",format:e.getBufferLayout().attributes[0].format}],varyings:["vNext"],modules:[s$],defines:{ATTRIBUTE_TYPE:t},parameters:{depthCompare:"always",blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}})}function l$(n){return n.createTexture({data:new Uint8Array(4),format:"rgba8unorm",width:1,height:1})}function u$(n,e){return n.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[e]})}var f$={interpolation:Qc,spring:Jc},el=class{constructor(e,{id:t,timeline:i}){if(!e)throw new Error("AttributeTransitionManager is constructed without device");this.id=t,this.device=e,this.timeline=i,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(let e in this.transitions)this._removeTransition(e)}update({attributes:e,transitions:t,numInstances:i}){this.numInstances=i||1;for(let r in e){let s=e[r],o=s.getTransitionSetting(t);o&&this._updateAttribute(r,s,o)}for(let r in this.transitions){let s=e[r];(!s||!s.getTransitionSetting(t))&&this._removeTransition(r)}}hasAttribute(e){let t=this.transitions[e];return t&&t.inProgress}getAttributes(){let e={};for(let t in this.transitions){let i=this.transitions[t];i.inProgress&&(e[t]=i.attributeInTransition)}return e}run(){if(this.numInstances===0)return!1;for(let t in this.transitions)this.transitions[t].update()&&(this.needsRedraw=!0);let e=this.needsRedraw;return this.needsRedraw=!1,e}_removeTransition(e){this.transitions[e].delete(),delete this.transitions[e]}_updateAttribute(e,t,i){let r=this.transitions[e],s=!r||r.type!==i.type;if(s){r&&this._removeTransition(e);let o=f$[i.type];o?this.transitions[e]=new o({attribute:t,timeline:this.timeline,device:this.device}):(ae.error(`unsupported transition type '${i.type}'`)(),s=!1)}(s||t.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(i,this.numInstances))}};var _T="attributeManager.invalidate",d$="attributeManager.updateStart",h$="attributeManager.updateEnd",p$="attribute.updateStart",m$="attribute.allocate",g$="attribute.updateEnd",tl=class{constructor(e,{id:t="attribute-manager",stats:i,timeline:r}={}){this.mergeBoundsMemoized=$n(c1),this.id=t,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=i,this.attributeTransitionManager=new el(e,{id:`${t}-transitions`,timeline:r}),this.attributeBufferGroups=e.type==="webgpu"?new Kc(e,{id:t,isTransitionAttribute:s=>this.attributeTransitionManager.hasAttribute(s)}):null,Object.seal(this)}finalize(){this.attributeBufferGroups?.finalize();for(let e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){let t=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,t&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:"instance"})}remove(e){for(let t of e)this.attributes[t]!==void 0&&(this.attributes[t].delete(),delete this.attributes[t])}invalidate(e,t){let i=this._invalidateTrigger(e,t);De(_T,this,e,i)}invalidateAll(e){for(let t in this.attributes)this.attributes[t].setNeedsUpdate(t,e);De(_T,this,"all")}update({data:e,numInstances:t,startIndices:i=null,transitions:r,props:s={},buffers:o={},context:a={}}){let c=!1;De(d$,this),this.stats&&this.stats.get("Update Attributes").timeStart();for(let l in this.attributes){let u=this.attributes[l],f=u.settings.accessor;u.startIndices=i,u.numInstances=t,s[l]&&ae.removed(`props.${l}`,`data.attributes.${l}`)(),u.setExternalBuffer(o[l])||u.setBinaryValue(typeof f=="string"?o[f]:void 0,e.startIndices)||typeof f=="string"&&!o[f]&&u.setConstantValue(a,s[f])||u.needsUpdate()&&(c=!0,this._updateAttribute({attribute:u,numInstances:t,data:e,props:s,context:a})),this.needsRedraw=this.needsRedraw||u.needsRedraw()}c&&De(h$,this,t),this.stats&&(this.stats.get("Update Attributes").timeEnd(),c&&this.stats.get("Attributes updated").incrementCount()),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:t,transitions:r})}updateTransition(){let{attributeTransitionManager:e}=this,t=e.run();return this.needsRedraw=this.needsRedraw||t,t}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){let t=e.map(i=>this.attributes[i]?.getBounds());return this.mergeBoundsMemoized(t)}getChangedAttributes(e={clearChangedFlags:!1}){let{attributes:t,attributeTransitionManager:i}=this,r={...i.getAttributes()};for(let s in t){let o=t[s];o.needsRedraw(e)&&!i.hasAttribute(s)&&(r[s]=o)}return r}getBufferLayouts(e){return this.hasBufferGroups()?this.attributeBufferGroups.getBufferLayouts(this.getAttributes(),e):Object.values(this.getAttributes()).map(t=>t.getBufferLayout(e))}hasBufferGroups(){return!!this.attributeBufferGroups?.hasGroups(this.attributes)}getBufferGroupBindings(e,t,i={}){return this.attributeBufferGroups?this.attributeBufferGroups.getBindings(this.getAttributes(),e,t,i):{bufferLayouts:this.getBufferLayouts(t),buffers:{},groupedAttributeIds:new Set}}_add(e,t){for(let i in e){let r=e[i],s={...r,id:i,size:r.isIndexed&&1||r.size||1,...t};this.attributes[i]=new as(this.device,s)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){let e={};for(let t in this.attributes)this.attributes[t].getUpdateTriggers().forEach(r=>{e[r]||(e[r]=[]),e[r].push(t)});this.updateTriggers=e}_invalidateTrigger(e,t){let{attributes:i,updateTriggers:r}=this,s=r[e];return s&&s.forEach(o=>{let a=i[o];a&&a.setNeedsUpdate(a.id,t)}),s}_updateAttribute(e){let{attribute:t,numInstances:i}=e;if(De(p$,t),t.constant){t.setConstantValue(e.context,t.value);return}t.allocate(i)&&De(m$,t,i),t.updateBuffer(e)&&(this.needsRedraw=!0,De(g$,t,i))}};ee();yd();Fe();var nl=class extends mn{get value(){return this._value}_onUpdate(){let{time:e,settings:{fromValue:t,toValue:i,duration:r,easing:s}}=this,o=s(e/r);this._value=cn(t,i,o)}};var yT=1e-5;function bT(n,e,t,i,r){let s=e-n,a=(t-e)*r,c=-s*i;return a+c+s+e}function _$(n,e,t,i,r){if(Array.isArray(t)){let s=[];for(let o=0;o0}add(e,t,i,r){let{transitions:s}=this;if(s.has(e)){let c=s.get(e),{value:l=c.settings.fromValue}=c;t=l,this.remove(e)}if(r=Pd(r),!r)return;let o=y$[r.type];if(!o){ae.error(`unsupported transition type '${r.type}'`)();return}let a=new o(this.timeline);a.start({...r,fromValue:t,toValue:i}),s.set(e,a)}remove(e){let{transitions:t}=this;t.has(e)&&(t.get(e).cancel(),t.delete(e))}update(){let e={};for(let[t,i]of this.transitions)i.update(),e[t]=i.value,i.inProgress||this.remove(t);return e}clear(){for(let e of this.transitions.keys())this.remove(e)}};function wT(n){let e=n[Yn];for(let t in e){let i=e[t],{validate:r}=i;if(r&&!r(n[t],i))throw new Error(`Invalid prop ${t}: ${n[t]}`)}}function ET(n,e){let t=ST({newProps:n,oldProps:e,propTypes:n[Yn],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),i=v$(n,e),r=!1;return i||(r=x$(n,e)),{dataChanged:i,propsChanged:t,updateTriggersChanged:r,extensionsChanged:w$(n,e),transitionsChanged:b$(n,e)}}function b$(n,e){if(!n.transitions)return!1;let t={},i=n[Yn],r=!1;for(let s in n.transitions){let o=i[s],a=o&&o.type;(a==="number"||a==="color"||a==="array")&&Xy(n[s],e[s],o)&&(t[s]=!0,r=!0)}return r?t:!1}function ST({newProps:n,oldProps:e,ignoreProps:t={},propTypes:i={},triggerName:r="props"}){if(e===n)return!1;if(typeof n!="object"||n===null)return`${r} changed shallowly`;if(typeof e!="object"||e===null)return`${r} changed shallowly`;for(let s of Object.keys(n))if(!(s in t)){if(!(s in e))return`${r}.${s} added`;let o=Xy(n[s],e[s],i[s]);if(o)return`${r}.${s} ${o}`}for(let s of Object.keys(e))if(!(s in t)){if(!(s in n))return`${r}.${s} dropped`;if(!Object.hasOwnProperty.call(n,s)){let o=Xy(n[s],e[s],i[s]);if(o)return`${r}.${s} ${o}`}}return!1}function Xy(n,e,t){let i=t&&t.equal;return i&&!i(n,e,t)||!i&&(i=n&&e&&n.equals,i&&!i.call(n,e))?"changed deeply":!i&&e!==n?"changed shallowly":null}function v$(n,e){if(e===null)return"oldProps is null, initial diff";let t=!1,{dataComparator:i,_dataDiff:r}=n;return i?i(n.data,e.data)||(t="Data comparator detected a change"):n.data!==e.data&&(t="A new data container was supplied"),t&&r&&(t=r(n.data,e.data)||t),t}function x$(n,e){if(e===null)return{all:!0};if("all"in n.updateTriggers&&xT(n,e,"all"))return{all:!0};let t={},i=!1;for(let r in n.updateTriggers)r!=="all"&&xT(n,e,r)&&(t[r]=!0,i=!0);return i?t:!1}function w$(n,e){if(e===null)return!0;let t=e.extensions,{extensions:i}=n;if(i===t)return!1;if(!t||!i||i.length!==t.length)return!0;for(let r=0;ri.name==="project64"))){let i=t.modules.findIndex(r=>r.name==="project32");i>=0&&t.modules.splice(i,1)}if("inject"in e)if(!n.inject)t.inject=e.inject;else{let i={...n.inject};for(let r in e.inject)i[r]=(i[r]||"")+e.inject[r];t.inject=i}return t}ee();var T$={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},Ky={};function CT(n,e,t,i){if(t instanceof pe)return t;t.constructor&&t.constructor.name!=="Object"&&(t={data:t});let r=null;t.compressed&&(r={minFilter:"linear",mipmapFilter:t.data.length>1?"nearest":"linear"});let{width:s,height:o}=t.data,a=e.createTexture({...t,sampler:{...T$,...r,...i},mipLevels:e.getMipLevelCount(s,o)});return e.type==="webgl"?a.generateMipmapsWebGL():e.type==="webgpu"&&e.generateMipmapsWebGPU(a),Ky[a.id]=n,a}function TT(n,e){!e||!(e instanceof pe)||Ky[e.id]===n&&(e.delete(),delete Ky[e.id])}var L$={boolean:{validate(n,e){return!0},equal(n,e,t){return!!n==!!e}},number:{validate(n,e){return Number.isFinite(n)&&(!("max"in e)||n<=e.max)&&(!("min"in e)||n>=e.min)}},color:{validate(n,e){return e.optional&&!n||Qy(n)&&(n.length===3||n.length===4)},equal(n,e,t){return xe(n,e,1)}},accessor:{validate(n,e){let t=Zd(n);return t==="function"||t===Zd(e.value)},equal(n,e,t){return typeof e=="function"?!0:xe(n,e,1)}},array:{validate(n,e){return e.optional&&!n||Qy(n)},equal(n,e,t){let{compare:i}=t,r=Number.isInteger(i)?i:i?1:0;return i?xe(n,e,r):n===e}},object:{equal(n,e,t){if(t.ignore)return!0;let{compare:i}=t,r=Number.isInteger(i)?i:i?1:0;return i?xe(n,e,r):n===e}},function:{validate(n,e){return e.optional&&!n||typeof n=="function"},equal(n,e,t){return!t.compare&&t.ignore!==!1||n===e}},data:{transform:(n,e,t)=>{if(!n)return n;let{dataTransform:i}=t.props;return i?i(n):typeof n.shape=="string"&&n.shape.endsWith("-table")&&Array.isArray(n.data)?n.data:n}},image:{transform:(n,e,t)=>{let i=t.context;return!i||!i.device?null:CT(t.id,i.device,n,{...e.parameters,...t.props.textureParameters})},release:(n,e,t)=>{TT(t.id,n)}}};function LT(n){let e={},t={},i={};for(let[r,s]of Object.entries(n)){let o=s?.deprecatedFor;if(o)i[r]=Array.isArray(o)?o:[o];else{let a=M$(r,s);e[r]=a,t[r]=a.value}}return{propTypes:e,defaultProps:t,deprecatedProps:i}}function M$(n,e){switch(Zd(e)){case"object":return sl(n,e);case"array":return sl(n,{type:"array",value:e,compare:!1});case"boolean":return sl(n,{type:"boolean",value:e});case"number":return sl(n,{type:"number",value:e});case"function":return sl(n,{type:"function",value:e,compare:!0});default:return{name:n,type:"unknown",value:e}}}function sl(n,e){return"type"in e?{name:n,...L$[e.type],...e}:"value"in e?{name:n,type:Zd(e.value),...e}:{name:n,type:"object",value:e}}function Qy(n){return Array.isArray(n)||ArrayBuffer.isView(n)}function Zd(n){return Qy(n)?"array":n===null?"null":typeof n}function MT(n,e){let t;for(let s=e.length-1;s>=0;s--){let o=e[s];"extensions"in o&&(t=o.extensions)}let i=Jy(n.constructor,t),r=Object.create(i);r[wo]=n,r[qn]={},r[pn]={};for(let s=0;s{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(let e in this.asyncProps){let t=this.asyncProps[e];t&&t.type&&t.type.release&&t.type.release(t.resolvedValue,t.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||F$}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){let t=this.asyncProps[e];return t&&t.resolvedValue}isAsyncPropLoading(e){if(e){let t=this.asyncProps[e];return!!(t&&t.pendingLoadCount>0&&t.pendingLoadCount!==t.resolvedLoadCount)}for(let t in this.asyncProps)if(this.isAsyncPropLoading(t))return!0;return!1}reloadAsyncProp(e,t){this._watchPromise(e,Promise.resolve(t))}setAsyncProps(e){this.component=e[wo]||this.component;let t=e[pn]||{},i=e[qn]||e,r=e[bi]||{};for(let s in t){let o=t[s];this._createAsyncPropData(s,r[s]),this._updateAsyncProp(s,o),t[s]=this.getAsyncProp(s)}for(let s in i){let o=i[s];this._createAsyncPropData(s,r[s]),this._updateAsyncProp(s,o)}}_fetch(e,t){return null}_onResolve(e,t){}_onError(e,t){}_updateAsyncProp(e,t){if(this._didAsyncInputValueChange(e,t)){if(typeof t=="string"&&(t=this._fetch(e,t)),t instanceof Promise){this._watchPromise(e,t);return}if(Ed(t)){this._resolveAsyncIterable(e,t);return}this._setPropValue(e,t)}}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(let e in this.asyncProps)Object.defineProperty(this.oldAsyncProps,e,{enumerable:!0,value:this.oldProps[e]})}}_didAsyncInputValueChange(e,t){let i=this.asyncProps[e];return t===i.resolvedValue||t===i.lastValue?!1:(i.lastValue=t,!0)}_setPropValue(e,t){this._freezeAsyncOldProps();let i=this.asyncProps[e];i&&(t=this._postProcessValue(i,t),i.resolvedValue=t,i.pendingLoadCount++,i.resolvedLoadCount=i.pendingLoadCount)}_setAsyncPropValue(e,t,i){let r=this.asyncProps[e];r&&i>=r.resolvedLoadCount&&t!==void 0&&(this._freezeAsyncOldProps(),r.resolvedValue=t,r.resolvedLoadCount=i,this.onAsyncPropUpdated(e,t))}_watchPromise(e,t){let i=this.asyncProps[e];if(i){i.pendingLoadCount++;let r=i.pendingLoadCount;t.then(s=>{this.component&&(s=this._postProcessValue(i,s),this._setAsyncPropValue(e,s,r),this._onResolve(e,s))}).catch(s=>{this._onError(e,s)})}}async _resolveAsyncIterable(e,t){if(e!=="data"){this._setPropValue(e,t);return}let i=this.asyncProps[e];if(!i)return;i.pendingLoadCount++;let r=i.pendingLoadCount,s=[],o=0;for await(let a of t){if(!this.component)return;let{dataTransform:c}=this.component.props;c?s=c(a,s):s=s.concat(a),Object.defineProperty(s,"__diff",{enumerable:!1,value:[{startRow:o,endRow:s.length}]}),o=s.length,this._setAsyncPropValue(e,s,r)}this._onResolve(e,s)}_postProcessValue(e,t){let i=e.type;return i&&this.component&&(i.release&&i.release(e.resolvedValue,i,this.component),i.transform)?i.transform(t,i,this.component):t}_createAsyncPropData(e,t){if(!this.asyncProps[e]){let r=this.component&&this.component.props[Yn];this.asyncProps[e]={type:r&&r[e],lastValue:null,resolvedValue:t,pendingLoadCount:0,resolvedLoadCount:0}}}};var cl=class extends al{constructor({attributeManager:e,layer:t}){super(t),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1,this.disabledPickingIndices=[]}get layer(){return this.component}_fetch(e,t){let i=this.layer,r=i?.props.fetch;return r?r(t,{propName:e,layer:i}):super._fetch(e,t)}_onResolve(e,t){let i=this.layer;if(i){let r=i.props.onDataLoad;e==="data"&&r&&r(t,{propName:e,layer:i})}}_onError(e,t){let i=this.layer;i&&i.raiseError(t,`loading ${e} of ${this.layer}`)}};var z$="layer.changeFlag",U$="layer.initialize",$$="layer.update",G$="layer.finalize",V$="layer.matched",kT=2**24-1,W$=Object.freeze([]),j$=$n(({oldViewport:n,viewport:e})=>n.equals(e)),en=new Uint8ClampedArray(0);function RT(n){return n.rowIndexes||n.pickingColors||n.instancePickingColors}function tb(n){return n.rowIndexes}function nb(n){return n.pickingColors||n.instancePickingColors}var H$={data:{type:"data",value:W$,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:n=>n&&n.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(n,{propName:e,layer:t,loaders:i,loadOptions:r,signal:s})=>{let{resourceManager:o}=t.context;r=r||t.getLoadOptions(),i=i||t.props.loaders,s&&(r={...r,core:{...r?.core,fetch:{...r?.core?.fetch,signal:s}}});let a=o.contains(n);return!a&&!r&&(o.add({resourceId:n,data:zs(n,i),persistent:!1}),a=!0),a?o.subscribe({resourceId:n,onChange:c=>t.internalState?.reloadAsyncProp(e,c),consumerId:t.id,requestId:e}):zs(n,i,r)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:"default",coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:n})=>[0,-n*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}},ll=class extends Xd{constructor(){super(...arguments),this.internalState=null,this.lifecycle=Ki.NO_STATE,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let e=this;for(;e.parent;)e=e.parent;return e}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(e){me(this.internalState);let t=this.internalState.viewport||this.context.viewport,i=Af(e,{viewport:t,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[r,s,o]=Xi(i,t.pixelProjectionMatrix);return e.length===2?[r,s]:[r,s,o]}unproject(e){return me(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,t){me(this.internalState);let i=this.internalState.viewport||this.context.viewport;return f1(e,{viewport:i,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...t})}get isComposite(){return!1}get isDrawable(){return!0}setState(e){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,e),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return this.internalState?!this.internalState.isAsyncPropLoading():!1}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){let e=this.state;return e&&(e.models||e.model&&[e.model])||[]}setShaderModuleProps(...e){for(let t of this.getModels())t.shaderInputs.setProps(...e)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){let{coordinateSystem:e}=this.props;return e==="default"||e==="lnglat"||e==="cartesian"}onHover(e,t){return this.props.onHover&&this.props.onHover(e,t)||!1}onClick(e,t){return this.props.onClick&&this.props.onClick(e,t)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,t=[]){return t[0]=e+1&255,t[1]=e+1>>8&255,t[2]=e+1>>8>>8&255,t}decodePickingColor(e){me(e instanceof Uint8Array);let[t,i,r]=e;return t+i*256+r*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:PT(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds(["positions","instancePositions"])}getShaders(e){e=us(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(let t of this.props.extensions)e=us(e,t.getShaders.call(this,t));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){let t=this.getAttributeManager(),{dataChanged:i}=e.changeFlags;if(i&&t)if(Array.isArray(i))for(let r of i)t.invalidateAll(r);else t.invalidateAll();if(t){let{props:r}=e,s=this.internalState.hasPickingBuffer,o=Number.isInteger(r.highlightedObjectIndex)||!!r.pickable||r.extensions.some(a=>a.getNeedsPickingBuffer.call(this,a));if(s!==o){this.internalState.hasPickingBuffer=o;let a=RT(t.attributes);a&&(o&&a.constant&&(a.constant=!1,t.invalidate(a.id)),!a.value&&!o&&(a.constant=!0,a.value=tb(t.attributes)?[uc]:[0,0,0]))}}}finalizeState(e){for(let i of this.getModels())i.destroy();let t=this.getAttributeManager();t&&t.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(let t of this.getModels())t.draw(e.renderPass)}getPickingInfo({info:e,mode:t,sourceLayer:i}){let{index:r}=e;return r>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[r]),e}raiseError(e,t){t&&(e=new Error(`${t}: ${e.message}`,{cause:e})),this.props.onError?.(e)||this.context?.onError?.(e,this)}getNeedsRedraw(e={clearRedrawFlags:!1}){return this._getNeedsRedraw(e)}needsUpdate(){return this.internalState?this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()):!1}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(e){if(!this.internalState)return;let t=this.internalState.viewport;this.internalState.viewport=e,(!t||!j$({oldViewport:t,viewport:e}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e="all"){let t=this.getAttributeManager();t&&(e==="all"?t.invalidateAll():t.invalidate(e))}updateAttributes(e){let t=!1;for(let i in e)e[i].layoutChanged()&&(t=!0);for(let i of this.getModels())this._setModelAttributes(i,e,t)}_updateAttributes(){let e=this.getAttributeManager();if(!e)return;let t=this.props,i=this.getNumInstances(),r=this.getStartIndices();e.update({data:t.data,numInstances:i,startIndices:r,props:t,transitions:t.transitions,buffers:t.data.attributes,context:this});let s=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(s)}_updateAttributeTransition(){let e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){let{uniformTransitions:e}=this.internalState;if(e.active){let t=e.update(),i=Object.create(this.props);for(let r in t)Object.defineProperty(i,r,{value:t[r]});return i}return this.props}calculateInstancePickingColors(e,{numInstances:t}){if(e.constant)return;let i=Math.floor(en.length/4);this.internalState.usesPickingColorCache=!0;let r=t>0&&en[0]===0;if(ikT&&ae.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),en=hn.allocate(en,t,{size:4,copy:!0,maxCount:Math.max(t,kT)});let s=Math.floor(en.length/4),o=[0,0,0],a=r?0:i;for(let c=a;c(ae.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new rl(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(let t of this.props.extensions)t.initializeState.call(this,this.context,t);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){De(V$,this,this===e);let{state:t,internalState:i}=e;this!==e&&(this.internalState=i,this.state=t,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){let e=this.needsUpdate();if(De($$,this,e),!e)return;this.context.stats.get("Layer updates").incrementCount();let t=this.props,i=this.context,r=this.internalState,s=i.viewport,o=this._updateUniformTransition();r.propsInTransition=o,i.viewport=r.viewport||s,this.props=o;try{let a=this._getUpdateParams(),c=this.getModels();if(i.device)this.updateState(a);else try{this.updateState(a)}catch{}for(let u of this.props.extensions)u.updateState.call(this,a,u);this.setNeedsRedraw(),this._updateAttributes();let l=this.getModels()[0]!==c[0];this._postUpdate(a,l)}finally{i.viewport=s,this.props=t,this._clearChangeFlags(),r.needsUpdate=!1,r.resetOldProps()}}_finalize(){De(G$,this),this.finalizeState(this.context);for(let e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,shaderModuleProps:t=null,uniforms:i={},parameters:r={}}){this._updateAttributeTransition();let s=this.props,o=this.context;this.props=this.internalState.propsInTransition||s;try{t&&this.setShaderModuleProps(t);let{getPolygonOffset:a}=this.props,c=a&&a(i)||[0,0];o.device instanceof er&&o.device.setParametersWebGL({polygonOffset:c});let l=o.device instanceof er?null:Y$(r);if(q$(this.getModels(),e,r,l),o.device instanceof er)o.device.withParametersWebGL(r,()=>{let u={renderPass:e,shaderModuleProps:t,uniforms:i,parameters:r,context:o};for(let f of this.props.extensions)f.draw.call(this,u,f);this.draw(u)});else{l?.renderPassParameters&&e.setParameters(l.renderPassParameters);let u={renderPass:e,shaderModuleProps:t,uniforms:i,parameters:r,context:o};for(let f of this.props.extensions)f.draw.call(this,u,f);this.draw(u)}}finally{this.props=s}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;let{changeFlags:t}=this.internalState;for(let r in e)if(e[r]){let s=!1;switch(r){case"dataChanged":let o=e[r],a=t[r];o&&Array.isArray(a)&&(t.dataChanged=Array.isArray(o)?a.concat(o):o,s=!0);default:t[r]||(t[r]=e[r],s=!0)}s&&De(z$,this,r,e)}let i=!!(t.dataChanged||t.updateTriggersChanged||t.propsChanged||t.extensionsChanged);t.propsOrDataChanged=i,t.somethingChanged=i||t.viewportChanged||t.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,t){let i=ET(e,t);if(i.updateTriggersChanged)for(let r in i.updateTriggersChanged)i.updateTriggersChanged[r]&&this.invalidateAttribute(r);if(i.transitionsChanged)for(let r in i.transitionsChanged)this.internalState.uniformTransitions.add(r,t[r],e[r],e.transitions?.[r]);return this.setChangeFlags(i)}validateProps(){wT(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){let t={highlightedObjectColor:e.picked?e.color:null},{highlightColor:i}=this.props;e.picked&&typeof i=="function"&&(t.highlightColor=i(e)),this.setShaderModuleProps({picking:t}),this.setNeedsRedraw()}_getAttributeManager(){let e=this.context;return new tl(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,t){let{props:i,oldProps:r}=e,s=this.state.model;s?.isInstanced&&s.setInstanceCount(this.getNumInstances());let{autoHighlight:o,highlightedObjectIndex:a,highlightColor:c}=i;if(t||r.autoHighlight!==o||r.highlightedObjectIndex!==a||r.highlightColor!==c){let l={};Array.isArray(c)&&(l.highlightColor=c),(t||r.autoHighlight!==o||a!==r.highlightedObjectIndex)&&(l.highlightedObjectColor=Number.isFinite(a)&&a>=0?this.encodePickingColor(a):null),this.setShaderModuleProps({picking:l})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(e){if(!this.internalState)return!1;let t=!1;t=t||this.internalState.needsRedraw&&this.id;let i=this.getAttributeManager(),r=i?i.getNeedsRedraw(e):!1;if(t=t||r,t)for(let s of this.props.extensions)s.onNeedsRedraw.call(this,s);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,t}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}};ll.defaultProps=H$;ll.layerName="Layer";var Ci=ll;function Y$(n){let{blendConstant:e,...t}=n;return e?{pipelineParameters:t,renderPassParameters:{blendConstant:e}}:{pipelineParameters:t}}function q$(n,e,t,i){for(let r of n)r.device.type==="webgpu"?(Z$(r,e),r.setParameters({...r.parameters,...i?.pipelineParameters})):r.setParameters(t)}function Z$(n,e){let t=e.props.framebuffer||(e.framebuffer??null);if(!t)return;let i=t.colorAttachments.map(o=>o?.texture?.format??null),r=t.depthStencilAttachment?.texture?.format,s=n;(!X$(s.props.colorAttachmentFormats,i)||s.props.depthStencilAttachmentFormat!==r)&&(s.props.colorAttachmentFormats=i,s.props.depthStencilAttachmentFormat=r,s._setPipelineNeedsUpdate("attachment formats"))}function X$(n,e){if(n===e)return!0;if(!n||!e||n.length!==e.length)return!1;for(let t=0;t{let x=d.slice();x[E]+=1;let T=p.project(x)[E]-g[E];return Number.isFinite(T)?T:2**(E===0?c:l)*(E===0?1:-1)}),y=v.map((E,x)=>{let T=x===0?m.left:m.top,I=x===0?m.right:m.bottom,N=Math.abs(E);return E>=0?[T/N,I/N]:[I/N,T/N]}),b=d.slice(),w=[h.width,h.height];for(let[E,[x,T]]of y.entries()){if(w[E]<0)continue;let{minimum:I,maximum:N,midpoint:D,settledTarget:H}=J$(u,E,x,T,d[E]);if(t?.mode!=="preserve"&&f&&(!Number.isFinite(x)||!Number.isFinite(T))){b[E]=D;continue}let W=f?H:Se(d[E],I,N);b[E]=t?.mode==="preserve"?d[E]:a?Ji(d[E],W,(E===0?h.width:h.height)/2/Math.abs(v[E])):W}(b[0]!==d[0]||b[1]!==d[1])&&(e.target=b)}return e}_constrainZoom({zoomX:e,zoomY:t},i){i||(i=this.getViewportProps());let{zoomAxis:r,maxZoomX:s,maxZoomY:o,maxBounds:a}=i,{minZoomX:c,minZoomY:l}=i;if(a!==null&&i.width>0&&i.height>0){let f=Eo(i.width,i.height,i.maxBoundsPadding),d=a[0],h=a[1],p=h[0]-d[0],m=h[1]-d[1];f.width>0&&Number.isFinite(p)&&p>0&&(c=Math.max(c,Math.log2(f.width/p)),c>s&&(c=s)),f.height>0&&Number.isFinite(m)&&m>0&&(l=Math.max(l,Math.log2(f.height/m)),l>o&&(l=o))}switch(r){case"X":e=Se(e,c,s);break;case"Y":t=Se(t,l,o);break;default:let f=Math.min(s-e,o-t,0);f===0&&(f=Math.max(c-e,l-t,0)),f!==0&&(e+=f,t+=f)}return{zoomX:e,zoomY:t}}},ul=class extends is{constructor(){super(...arguments),this.ControllerState=rb,this.transition={transitionDuration:300,transitionInterpolator:new vi(["target","zoomX","zoomY"])},this.dragMode="pan"}setProps(e){Object.assign(e,ib(e)),super.setProps(e)}_onMultiPanStart(e){return this.multiTouchDrag==="pan"&&super._onMultiPanStart(e)}_onPanRotate(){return!1}};var Qd=class extends es{constructor(e={}){super(e)}getViewportType(){return IT}get ControllerType(){return ul}};Qd.displayName="OrthographicView";var sb=Qd;var fl=class{static get componentName(){return Object.prototype.hasOwnProperty.call(this,"extensionName")?this.extensionName:""}constructor(e){e&&(this.opts=e)}equals(e){return this===e?!0:this.constructor===e.constructor&&xe(this.opts,e.opts,1)}getShaders(e){return null}getSubLayerProps(e){let{defaultProps:t}=e.constructor,i={updateTriggers:{}};for(let r in t)if(r in this.props){let s=t[r],o=this.props[r];i[r]=o,s&&s.type==="accessor"&&(i.updateTriggers[r]=this.props.updateTriggers[r],typeof o=="function"&&(i[r]=this.getSubLayerAccessor(o)))}return i}initializeState(e,t){}updateState(e,t){}onNeedsRedraw(e){}getNeedsPickingBuffer(e){return!1}draw(e,t){}finalizeState(e,t){}};fl.defaultProps={};fl.extensionName="LayerExtension";var ob=fl;ee();var sr=class{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;let{attributes:t={}}=e;this.typedArrayManager=hn,this.attributes={},this._attributeDefs=t,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);let{data:t,buffers:i={},getGeometry:r,geometryBuffer:s,positionFormat:o,dataChanged:a,normalize:c=!0}=this.opts;if(this.data=t,this.getGeometry=r,this.positionSize=s&&s.size||(o==="XY"?2:3),this.buffers=i,this.normalize=c,s&&(me(t.startIndices),this.getGeometry=this.getGeometryFromBuffer(s),c||(i.vertexPositions=s)),this.geometryBuffer=i.vertexPositions,Array.isArray(a))for(let l of a)this._rebuildGeometry(l);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:t}){this._rebuildGeometry({startRow:e,endRow:t})}getGeometryFromBuffer(e){let t=e.value||e;return ArrayBuffer.isView(t)?Sd(t,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,t){let{attributes:i,buffers:r,_attributeDefs:s,typedArrayManager:o}=this;for(let a in s)if(a in r)o.release(i[a]),i[a]=null;else{let c=s[a];c.copy=t,i[a]=o.allocate(i[a],e,c)}}_forEachGeometry(e,t,i){let{data:r,getGeometry:s}=this,{iterable:o,objectInfo:a}=wd(r,t,i);for(let c of o){a.index++;let l=s?s(c,a):null;e(l,a.index)}}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:t,vertexStarts:i,instanceCount:r}=this,{data:s,geometryBuffer:o}=this,{startRow:a=0,endRow:c=1/0}=e||{},l={};if(e||(t=[0],i=[0]),this.normalize||!o)this._forEachGeometry((f,d)=>{let h=f&&this.normalizeGeometry(f);l[d]=h,i[d+1]=i[d]+(h?this.getGeometrySize(h):0)},a,c),r=i[i.length-1];else if(i=s.startIndices,r=i[s.length]||0,ArrayBuffer.isView(o))r=r||o.length/this.positionSize;else if(o instanceof re){let f=this.positionSize*4;r=r||o.byteLength/f}else if(o.buffer){let f=o.stride||this.positionSize*4;r=r||o.buffer.byteLength/f}else if(o.value){let f=o.value,d=o.stride/f.BYTES_PER_ELEMENT||this.positionSize;r=r||f.length/d}this._allocate(r,!!e),this.indexStarts=t,this.vertexStarts=i,this.instanceCount=r;let u={};this._forEachGeometry((f,d)=>{let h=l[d]||f;u.vertexStart=i[d],u.indexStart=t[d];let p=dthis.attributeTransitionManager.hasAttribute(s)}):null,Object.seal(this)}finalize(){this.attributeBufferGroups?.finalize();for(let e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){let t=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,t&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:"instance"})}remove(e){for(let t of e)this.attributes[t]!==void 0&&(this.attributes[t].delete(),delete this.attributes[t])}invalidate(e,t){let i=this._invalidateTrigger(e,t);Ne(yT,this,e,i)}invalidateAll(e){for(let t in this.attributes)this.attributes[t].setNeedsUpdate(t,e);Ne(yT,this,"all")}update({data:e,numInstances:t,startIndices:i=null,transitions:r,props:s={},buffers:o={},context:a={}}){let c=!1;Ne(m$,this),this.stats&&this.stats.get("Update Attributes").timeStart();for(let l in this.attributes){let u=this.attributes[l],f=u.settings.accessor;u.startIndices=i,u.numInstances=t,s[l]&&ae.removed(`props.${l}`,`data.attributes.${l}`)(),u.setExternalBuffer(o[l])||u.setBinaryValue(typeof f=="string"?o[f]:void 0,e.startIndices)||typeof f=="string"&&!o[f]&&u.setConstantValue(a,s[f])||u.needsUpdate()&&(c=!0,this._updateAttribute({attribute:u,numInstances:t,data:e,props:s,context:a})),this.needsRedraw=this.needsRedraw||u.needsRedraw()}c&&Ne(g$,this,t),this.stats&&(this.stats.get("Update Attributes").timeEnd(),c&&this.stats.get("Attributes updated").incrementCount()),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:t,transitions:r})}updateTransition(){let{attributeTransitionManager:e}=this,t=e.run();return this.needsRedraw=this.needsRedraw||t,t}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){let t=e.map(i=>this.attributes[i]?.getBounds());return this.mergeBoundsMemoized(t)}getChangedAttributes(e={clearChangedFlags:!1}){let{attributes:t,attributeTransitionManager:i}=this,r={...i.getAttributes()};for(let s in t){let o=t[s];o.needsRedraw(e)&&!i.hasAttribute(s)&&(r[s]=o)}return r}getBufferLayouts(e){return this.hasBufferGroups()?this.attributeBufferGroups.getBufferLayouts(this.getAttributes(),e):Object.values(this.getAttributes()).map(t=>t.getBufferLayout(e))}hasBufferGroups(){return!!this.attributeBufferGroups?.hasGroups(this.attributes)}getBufferGroupBindings(e,t,i={}){return this.attributeBufferGroups?this.attributeBufferGroups.getBindings(this.getAttributes(),e,t,i):{bufferLayouts:this.getBufferLayouts(t),buffers:{},groupedAttributeIds:new Set}}_add(e,t){for(let i in e){let r=e[i],s={...r,id:i,size:r.isIndexed&&1||r.size||1,...t};this.attributes[i]=new as(this.device,s)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){let e={};for(let t in this.attributes)this.attributes[t].getUpdateTriggers().forEach(r=>{e[r]||(e[r]=[]),e[r].push(t)});this.updateTriggers=e}_invalidateTrigger(e,t){let{attributes:i,updateTriggers:r}=this,s=r[e];return s&&s.forEach(o=>{let a=i[o];a&&a.setNeedsUpdate(a.id,t)}),s}_updateAttribute(e){let{attribute:t,numInstances:i}=e;if(Ne(_$,t),t.constant){t.setConstantValue(e.context,t.value);return}t.allocate(i)&&Ne(y$,t,i),t.updateBuffer(e)&&(this.needsRedraw=!0,Ne(b$,t,i))}};J();bd();ze();var il=class extends yn{get value(){return this._value}_onUpdate(){let{time:e,settings:{fromValue:t,toValue:i,duration:r,easing:s}}=this,o=s(e/r);this._value=fn(t,i,o)}};var bT=1e-5;function vT(n,e,t,i,r){let s=e-n,a=(t-e)*r,c=-s*i;return a+c+s+e}function v$(n,e,t,i,r){if(Array.isArray(t)){let s=[];for(let o=0;o0}add(e,t,i,r){let{transitions:s}=this;if(s.has(e)){let c=s.get(e),{value:l=c.settings.fromValue}=c;t=l,this.remove(e)}if(r=Cd(r),!r)return;let o=x$[r.type];if(!o){ae.error(`unsupported transition type '${r.type}'`)();return}let a=new o(this.timeline);a.start({...r,fromValue:t,toValue:i}),s.set(e,a)}remove(e){let{transitions:t}=this;t.has(e)&&(t.get(e).cancel(),t.delete(e))}update(){let e={};for(let[t,i]of this.transitions)i.update(),e[t]=i.value,i.inProgress||this.remove(t);return e}clear(){for(let e of this.transitions.keys())this.remove(e)}};function ET(n){let e=n[Kn];for(let t in e){let i=e[t],{validate:r}=i;if(r&&!r(n[t],i))throw new Error(`Invalid prop ${t}: ${n[t]}`)}}function ST(n,e){let t=PT({newProps:n,oldProps:e,propTypes:n[Kn],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),i=E$(n,e),r=!1;return i||(r=S$(n,e)),{dataChanged:i,propsChanged:t,updateTriggersChanged:r,extensionsChanged:P$(n,e),transitionsChanged:w$(n,e)}}function w$(n,e){if(!n.transitions)return!1;let t={},i=n[Kn],r=!1;for(let s in n.transitions){let o=i[s],a=o&&o.type;(a==="number"||a==="color"||a==="array")&&Ky(n[s],e[s],o)&&(t[s]=!0,r=!0)}return r?t:!1}function PT({newProps:n,oldProps:e,ignoreProps:t={},propTypes:i={},triggerName:r="props"}){if(e===n)return!1;if(typeof n!="object"||n===null)return`${r} changed shallowly`;if(typeof e!="object"||e===null)return`${r} changed shallowly`;for(let s of Object.keys(n))if(!(s in t)){if(!(s in e))return`${r}.${s} added`;let o=Ky(n[s],e[s],i[s]);if(o)return`${r}.${s} ${o}`}for(let s of Object.keys(e))if(!(s in t)){if(!(s in n))return`${r}.${s} dropped`;if(!Object.hasOwnProperty.call(n,s)){let o=Ky(n[s],e[s],i[s]);if(o)return`${r}.${s} ${o}`}}return!1}function Ky(n,e,t){let i=t&&t.equal;return i&&!i(n,e,t)||!i&&(i=n&&e&&n.equals,i&&!i.call(n,e))?"changed deeply":!i&&e!==n?"changed shallowly":null}function E$(n,e){if(e===null)return"oldProps is null, initial diff";let t=!1,{dataComparator:i,_dataDiff:r}=n;return i?i(n.data,e.data)||(t="Data comparator detected a change"):n.data!==e.data&&(t="A new data container was supplied"),t&&r&&(t=r(n.data,e.data)||t),t}function S$(n,e){if(e===null)return{all:!0};if("all"in n.updateTriggers&&wT(n,e,"all"))return{all:!0};let t={},i=!1;for(let r in n.updateTriggers)r!=="all"&&wT(n,e,r)&&(t[r]=!0,i=!0);return i?t:!1}function P$(n,e){if(e===null)return!0;let t=e.extensions,{extensions:i}=n;if(i===t)return!1;if(!t||!i||i.length!==t.length)return!0;for(let r=0;ri.name==="project64"))){let i=t.modules.findIndex(r=>r.name==="project32");i>=0&&t.modules.splice(i,1)}if("inject"in e)if(!n.inject)t.inject=e.inject;else{let i={...n.inject};for(let r in e.inject)i[r]=(i[r]||"")+e.inject[r];t.inject=i}return t}J();var A$={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},Qy={};function TT(n,e,t,i){if(t instanceof me)return t;t.constructor&&t.constructor.name!=="Object"&&(t={data:t});let r=null;t.compressed&&(r={minFilter:"linear",mipmapFilter:t.data.length>1?"nearest":"linear"});let{width:s,height:o}=t.data,a=e.createTexture({...t,sampler:{...A$,...r,...i},mipLevels:e.getMipLevelCount(s,o)});return e.type==="webgl"?a.generateMipmapsWebGL():e.type==="webgpu"&&e.generateMipmapsWebGPU(a),Qy[a.id]=n,a}function LT(n,e){!e||!(e instanceof me)||Qy[e.id]===n&&(e.delete(),delete Qy[e.id])}var k$={boolean:{validate(n,e){return!0},equal(n,e,t){return!!n==!!e}},number:{validate(n,e){return Number.isFinite(n)&&(!("max"in e)||n<=e.max)&&(!("min"in e)||n>=e.min)}},color:{validate(n,e){return e.optional&&!n||Jy(n)&&(n.length===3||n.length===4)},equal(n,e,t){return Ee(n,e,1)}},accessor:{validate(n,e){let t=Xd(n);return t==="function"||t===Xd(e.value)},equal(n,e,t){return typeof e=="function"?!0:Ee(n,e,1)}},array:{validate(n,e){return e.optional&&!n||Jy(n)},equal(n,e,t){let{compare:i}=t,r=Number.isInteger(i)?i:i?1:0;return i?Ee(n,e,r):n===e}},object:{equal(n,e,t){if(t.ignore)return!0;let{compare:i}=t,r=Number.isInteger(i)?i:i?1:0;return i?Ee(n,e,r):n===e}},function:{validate(n,e){return e.optional&&!n||typeof n=="function"},equal(n,e,t){return!t.compare&&t.ignore!==!1||n===e}},data:{transform:(n,e,t)=>{if(!n)return n;let{dataTransform:i}=t.props;return i?i(n):typeof n.shape=="string"&&n.shape.endsWith("-table")&&Array.isArray(n.data)?n.data:n}},image:{transform:(n,e,t)=>{let i=t.context;return!i||!i.device?null:TT(t.id,i.device,n,{...e.parameters,...t.props.textureParameters})},release:(n,e,t)=>{LT(t.id,n)}}};function MT(n){let e={},t={},i={};for(let[r,s]of Object.entries(n)){let o=s?.deprecatedFor;if(o)i[r]=Array.isArray(o)?o:[o];else{let a=R$(r,s);e[r]=a,t[r]=a.value}}return{propTypes:e,defaultProps:t,deprecatedProps:i}}function R$(n,e){switch(Xd(e)){case"object":return ol(n,e);case"array":return ol(n,{type:"array",value:e,compare:!1});case"boolean":return ol(n,{type:"boolean",value:e});case"number":return ol(n,{type:"number",value:e});case"function":return ol(n,{type:"function",value:e,compare:!0});default:return{name:n,type:"unknown",value:e}}}function ol(n,e){return"type"in e?{name:n,...k$[e.type],...e}:"value"in e?{name:n,type:Xd(e.value),...e}:{name:n,type:"object",value:e}}function Jy(n){return Array.isArray(n)||ArrayBuffer.isView(n)}function Xd(n){return Jy(n)?"array":n===null?"null":typeof n}function AT(n,e){let t;for(let s=e.length-1;s>=0;s--){let o=e[s];"extensions"in o&&(t=o.extensions)}let i=eb(n.constructor,t),r=Object.create(i);r[wo]=n,r[Qn]={},r[_n]={};for(let s=0;s{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(let e in this.asyncProps){let t=this.asyncProps[e];t&&t.type&&t.type.release&&t.type.release(t.resolvedValue,t.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||$$}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){let t=this.asyncProps[e];return t&&t.resolvedValue}isAsyncPropLoading(e){if(e){let t=this.asyncProps[e];return!!(t&&t.pendingLoadCount>0&&t.pendingLoadCount!==t.resolvedLoadCount)}for(let t in this.asyncProps)if(this.isAsyncPropLoading(t))return!0;return!1}reloadAsyncProp(e,t){this._watchPromise(e,Promise.resolve(t))}setAsyncProps(e){this.component=e[wo]||this.component;let t=e[_n]||{},i=e[Qn]||e,r=e[Si]||{};for(let s in t){let o=t[s];this._createAsyncPropData(s,r[s]),this._updateAsyncProp(s,o),t[s]=this.getAsyncProp(s)}for(let s in i){let o=i[s];this._createAsyncPropData(s,r[s]),this._updateAsyncProp(s,o)}}_fetch(e,t){return null}_onResolve(e,t){}_onError(e,t){}_updateAsyncProp(e,t){if(this._didAsyncInputValueChange(e,t)){if(typeof t=="string"&&(t=this._fetch(e,t)),t instanceof Promise){this._watchPromise(e,t);return}if(Sd(t)){this._resolveAsyncIterable(e,t);return}this._setPropValue(e,t)}}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(let e in this.asyncProps)Object.defineProperty(this.oldAsyncProps,e,{enumerable:!0,value:this.oldProps[e]})}}_didAsyncInputValueChange(e,t){let i=this.asyncProps[e];return t===i.resolvedValue||t===i.lastValue?!1:(i.lastValue=t,!0)}_setPropValue(e,t){this._freezeAsyncOldProps();let i=this.asyncProps[e];i&&(t=this._postProcessValue(i,t),i.resolvedValue=t,i.pendingLoadCount++,i.resolvedLoadCount=i.pendingLoadCount)}_setAsyncPropValue(e,t,i){let r=this.asyncProps[e];r&&i>=r.resolvedLoadCount&&t!==void 0&&(this._freezeAsyncOldProps(),r.resolvedValue=t,r.resolvedLoadCount=i,this.onAsyncPropUpdated(e,t))}_watchPromise(e,t){let i=this.asyncProps[e];if(i){i.pendingLoadCount++;let r=i.pendingLoadCount;t.then(s=>{this.component&&(s=this._postProcessValue(i,s),this._setAsyncPropValue(e,s,r),this._onResolve(e,s))}).catch(s=>{this._onError(e,s)})}}async _resolveAsyncIterable(e,t){if(e!=="data"){this._setPropValue(e,t);return}let i=this.asyncProps[e];if(!i)return;i.pendingLoadCount++;let r=i.pendingLoadCount,s=[],o=0;for await(let a of t){if(!this.component)return;let{dataTransform:c}=this.component.props;c?s=c(a,s):s=s.concat(a),Object.defineProperty(s,"__diff",{enumerable:!1,value:[{startRow:o,endRow:s.length}]}),o=s.length,this._setAsyncPropValue(e,s,r)}this._onResolve(e,s)}_postProcessValue(e,t){let i=e.type;return i&&this.component&&(i.release&&i.release(e.resolvedValue,i,this.component),i.transform)?i.transform(t,i,this.component):t}_createAsyncPropData(e,t){if(!this.asyncProps[e]){let r=this.component&&this.component.props[Kn];this.asyncProps[e]={type:r&&r[e],lastValue:null,resolvedValue:t,pendingLoadCount:0,resolvedLoadCount:0}}}};var ll=class extends cl{constructor({attributeManager:e,layer:t}){super(t),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1,this.disabledPickingIndices=[]}get layer(){return this.component}_fetch(e,t){let i=this.layer,r=i?.props.fetch;return r?r(t,{propName:e,layer:i}):super._fetch(e,t)}_onResolve(e,t){let i=this.layer;if(i){let r=i.props.onDataLoad;e==="data"&&r&&r(t,{propName:e,layer:i})}}_onError(e,t){let i=this.layer;i&&i.raiseError(t,`loading ${e} of ${this.layer}`)}};var G$="layer.changeFlag",V$="layer.initialize",W$="layer.update",j$="layer.finalize",H$="layer.matched",RT=2**24-1,Y$=Object.freeze([]),q$=jn(({oldViewport:n,viewport:e})=>n.equals(e)),sn=new Uint8ClampedArray(0);function IT(n){return n.rowIndexes||n.pickingColors||n.instancePickingColors}function nb(n){return n.rowIndexes}function ib(n){return n.pickingColors||n.instancePickingColors}var Z$={data:{type:"data",value:Y$,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:n=>n&&n.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(n,{propName:e,layer:t,loaders:i,loadOptions:r,signal:s})=>{let{resourceManager:o}=t.context;r=r||t.getLoadOptions(),i=i||t.props.loaders,s&&(r={...r,core:{...r?.core,fetch:{...r?.core?.fetch,signal:s}}});let a=o.contains(n);return!a&&!r&&(o.add({resourceId:n,data:zs(n,i),persistent:!1}),a=!0),a?o.subscribe({resourceId:n,onChange:c=>t.internalState?.reloadAsyncProp(e,c),consumerId:t.id,requestId:e}):zs(n,i,r)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:"default",coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:n})=>[0,-n*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}},ul=class extends Kd{constructor(){super(...arguments),this.internalState=null,this.lifecycle=Ji.NO_STATE,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let e=this;for(;e.parent;)e=e.parent;return e}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(e){ge(this.internalState);let t=this.internalState.viewport||this.context.viewport,i=kf(e,{viewport:t,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[r,s,o]=Qi(i,t.pixelProjectionMatrix);return e.length===2?[r,s]:[r,s,o]}unproject(e){return ge(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,t){ge(this.internalState);let i=this.internalState.viewport||this.context.viewport;return d1(e,{viewport:i,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...t})}get isComposite(){return!1}get isDrawable(){return!0}setState(e){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,e),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return this.internalState?!this.internalState.isAsyncPropLoading():!1}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){let e=this.state;return e&&(e.models||e.model&&[e.model])||[]}setShaderModuleProps(...e){for(let t of this.getModels())t.shaderInputs.setProps(...e)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){let{coordinateSystem:e}=this.props;return e==="default"||e==="lnglat"||e==="cartesian"}onHover(e,t){return this.props.onHover&&this.props.onHover(e,t)||!1}onClick(e,t){return this.props.onClick&&this.props.onClick(e,t)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,t=[]){return t[0]=e+1&255,t[1]=e+1>>8&255,t[2]=e+1>>8>>8&255,t}decodePickingColor(e){ge(e instanceof Uint8Array);let[t,i,r]=e;return t+i*256+r*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:CT(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds(["positions","instancePositions"])}getShaders(e){e=us(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(let t of this.props.extensions)e=us(e,t.getShaders.call(this,t));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){let t=this.getAttributeManager(),{dataChanged:i}=e.changeFlags;if(i&&t)if(Array.isArray(i))for(let r of i)t.invalidateAll(r);else t.invalidateAll();if(t){let{props:r}=e,s=this.internalState.hasPickingBuffer,o=Number.isInteger(r.highlightedObjectIndex)||!!r.pickable||r.extensions.some(a=>a.getNeedsPickingBuffer.call(this,a));if(s!==o){this.internalState.hasPickingBuffer=o;let a=IT(t.attributes);a&&(o&&a.constant&&(a.constant=!1,t.invalidate(a.id)),!a.value&&!o&&(a.constant=!0,a.value=nb(t.attributes)?[fc]:[0,0,0]))}}}finalizeState(e){for(let i of this.getModels())i.destroy();let t=this.getAttributeManager();t&&t.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(let t of this.getModels())t.draw(e.renderPass)}getPickingInfo({info:e,mode:t,sourceLayer:i}){let{index:r}=e;return r>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[r]),e}raiseError(e,t){t&&(e=new Error(`${t}: ${e.message}`,{cause:e})),this.props.onError?.(e)||this.context?.onError?.(e,this)}getNeedsRedraw(e={clearRedrawFlags:!1}){return this._getNeedsRedraw(e)}needsUpdate(){return this.internalState?this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()):!1}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(e){if(!this.internalState)return;let t=this.internalState.viewport;this.internalState.viewport=e,(!t||!q$({oldViewport:t,viewport:e}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e="all"){let t=this.getAttributeManager();t&&(e==="all"?t.invalidateAll():t.invalidate(e))}updateAttributes(e){let t=!1;for(let i in e)e[i].layoutChanged()&&(t=!0);for(let i of this.getModels())this._setModelAttributes(i,e,t)}_updateAttributes(){let e=this.getAttributeManager();if(!e)return;let t=this.props,i=this.getNumInstances(),r=this.getStartIndices();e.update({data:t.data,numInstances:i,startIndices:r,props:t,transitions:t.transitions,buffers:t.data.attributes,context:this});let s=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(s)}_updateAttributeTransition(){let e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){let{uniformTransitions:e}=this.internalState;if(e.active){let t=e.update(),i=Object.create(this.props);for(let r in t)Object.defineProperty(i,r,{value:t[r]});return i}return this.props}calculateInstancePickingColors(e,{numInstances:t}){if(e.constant)return;let i=Math.floor(sn.length/4);this.internalState.usesPickingColorCache=!0;let r=t>0&&sn[0]===0;if(iRT&&ae.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),sn=gn.allocate(sn,t,{size:4,copy:!0,maxCount:Math.max(t,RT)});let s=Math.floor(sn.length/4),o=[0,0,0],a=r?0:i;for(let c=a;c(ae.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new sl(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(let t of this.props.extensions)t.initializeState.call(this,this.context,t);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){Ne(H$,this,this===e);let{state:t,internalState:i}=e;this!==e&&(this.internalState=i,this.state=t,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){let e=this.needsUpdate();if(Ne(W$,this,e),!e)return;this.context.stats.get("Layer updates").incrementCount();let t=this.props,i=this.context,r=this.internalState,s=i.viewport,o=this._updateUniformTransition();r.propsInTransition=o,i.viewport=r.viewport||s,this.props=o;try{let a=this._getUpdateParams(),c=this.getModels();if(i.device)this.updateState(a);else try{this.updateState(a)}catch{}for(let u of this.props.extensions)u.updateState.call(this,a,u);this.setNeedsRedraw(),this._updateAttributes();let l=this.getModels()[0]!==c[0];this._postUpdate(a,l)}finally{i.viewport=s,this.props=t,this._clearChangeFlags(),r.needsUpdate=!1,r.resetOldProps()}}_finalize(){Ne(j$,this),this.finalizeState(this.context);for(let e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,shaderModuleProps:t=null,uniforms:i={},parameters:r={}}){this._updateAttributeTransition();let s=this.props,o=this.context;this.props=this.internalState.propsInTransition||s;try{t&&this.setShaderModuleProps(t);let{getPolygonOffset:a}=this.props,c=a&&a(i)||[0,0];o.device instanceof nr&&o.device.setParametersWebGL({polygonOffset:c});let l=o.device instanceof nr?null:X$(r);if(K$(this.getModels(),e,r,l),o.device instanceof nr)o.device.withParametersWebGL(r,()=>{let u={renderPass:e,shaderModuleProps:t,uniforms:i,parameters:r,context:o};for(let f of this.props.extensions)f.draw.call(this,u,f);this.draw(u)});else{l?.renderPassParameters&&e.setParameters(l.renderPassParameters);let u={renderPass:e,shaderModuleProps:t,uniforms:i,parameters:r,context:o};for(let f of this.props.extensions)f.draw.call(this,u,f);this.draw(u)}}finally{this.props=s}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;let{changeFlags:t}=this.internalState;for(let r in e)if(e[r]){let s=!1;switch(r){case"dataChanged":let o=e[r],a=t[r];o&&Array.isArray(a)&&(t.dataChanged=Array.isArray(o)?a.concat(o):o,s=!0);default:t[r]||(t[r]=e[r],s=!0)}s&&Ne(G$,this,r,e)}let i=!!(t.dataChanged||t.updateTriggersChanged||t.propsChanged||t.extensionsChanged);t.propsOrDataChanged=i,t.somethingChanged=i||t.viewportChanged||t.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,t){let i=ST(e,t);if(i.updateTriggersChanged)for(let r in i.updateTriggersChanged)i.updateTriggersChanged[r]&&this.invalidateAttribute(r);if(i.transitionsChanged)for(let r in i.transitionsChanged)this.internalState.uniformTransitions.add(r,t[r],e[r],e.transitions?.[r]);return this.setChangeFlags(i)}validateProps(){ET(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){let t={highlightedObjectColor:e.picked?e.color:null},{highlightColor:i}=this.props;e.picked&&typeof i=="function"&&(t.highlightColor=i(e)),this.setShaderModuleProps({picking:t}),this.setNeedsRedraw()}_getAttributeManager(){let e=this.context;return new nl(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,t){let{props:i,oldProps:r}=e,s=this.state.model;s?.isInstanced&&s.setInstanceCount(this.getNumInstances());let{autoHighlight:o,highlightedObjectIndex:a,highlightColor:c}=i;if(t||r.autoHighlight!==o||r.highlightedObjectIndex!==a||r.highlightColor!==c){let l={};Array.isArray(c)&&(l.highlightColor=c),(t||r.autoHighlight!==o||a!==r.highlightedObjectIndex)&&(l.highlightedObjectColor=Number.isFinite(a)&&a>=0?this.encodePickingColor(a):null),this.setShaderModuleProps({picking:l})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(e){if(!this.internalState)return!1;let t=!1;t=t||this.internalState.needsRedraw&&this.id;let i=this.getAttributeManager(),r=i?i.getNeedsRedraw(e):!1;if(t=t||r,t)for(let s of this.props.extensions)s.onNeedsRedraw.call(this,s);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,t}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}};ul.defaultProps=Z$;ul.layerName="Layer";var ki=ul;function X$(n){let{blendConstant:e,...t}=n;return e?{pipelineParameters:t,renderPassParameters:{blendConstant:e}}:{pipelineParameters:t}}function K$(n,e,t,i){for(let r of n)r.device.type==="webgpu"?(Q$(r,e),r.setParameters({...r.parameters,...i?.pipelineParameters})):r.setParameters(t)}function Q$(n,e){let t=e.props.framebuffer||(e.framebuffer??null);if(!t)return;let i=t.colorAttachments.map(o=>o?.texture?.format??null),r=t.depthStencilAttachment?.texture?.format,s=n;(!J$(s.props.colorAttachmentFormats,i)||s.props.depthStencilAttachmentFormat!==r)&&(s.props.colorAttachmentFormats=i,s.props.depthStencilAttachmentFormat=r,s._setPipelineNeedsUpdate("attachment formats"))}function J$(n,e){if(n===e)return!0;if(!n||!e||n.length!==e.length)return!1;for(let t=0;t{let w=d.slice();w[E]+=1;let T=p.project(w)[E]-g[E];return Number.isFinite(T)?T:2**(E===0?c:l)*(E===0?1:-1)}),y=v.map((E,w)=>{let T=w===0?m.left:m.top,R=w===0?m.right:m.bottom,F=Math.abs(E);return E>=0?[T/F,R/F]:[R/F,T/F]}),b=d.slice(),x=[h.width,h.height];for(let[E,[w,T]]of y.entries()){if(x[E]<0)continue;let{minimum:R,maximum:F,midpoint:O,settledTarget:j}=nG(u,E,w,T,d[E]);if(t?.mode!=="preserve"&&f&&(!Number.isFinite(w)||!Number.isFinite(T))){b[E]=O;continue}let V=f?j:Te(d[E],R,F);b[E]=t?.mode==="preserve"?d[E]:a?tr(d[E],V,(E===0?h.width:h.height)/2/Math.abs(v[E])):V}(b[0]!==d[0]||b[1]!==d[1])&&(e.target=b)}return e}_constrainZoom({zoomX:e,zoomY:t},i){i||(i=this.getViewportProps());let{zoomAxis:r,maxZoomX:s,maxZoomY:o,maxBounds:a}=i,{minZoomX:c,minZoomY:l}=i;if(a!==null&&i.width>0&&i.height>0){let f=Eo(i.width,i.height,i.maxBoundsPadding),d=a[0],h=a[1],p=h[0]-d[0],m=h[1]-d[1];f.width>0&&Number.isFinite(p)&&p>0&&(c=Math.max(c,Math.log2(f.width/p)),c>s&&(c=s)),f.height>0&&Number.isFinite(m)&&m>0&&(l=Math.max(l,Math.log2(f.height/m)),l>o&&(l=o))}switch(r){case"X":e=Te(e,c,s);break;case"Y":t=Te(t,l,o);break;default:let f=Math.min(s-e,o-t,0);f===0&&(f=Math.max(c-e,l-t,0)),f!==0&&(e+=f,t+=f)}return{zoomX:e,zoomY:t}}},fl=class extends is{constructor(){super(...arguments),this.ControllerState=sb,this.transition={transitionDuration:300,transitionInterpolator:new Pi(["target","zoomX","zoomY"])},this.dragMode="pan"}setProps(e){Object.assign(e,rb(e)),super.setProps(e)}_onMultiPanStart(e){return this.multiTouchDrag==="pan"&&super._onMultiPanStart(e)}_onPanRotate(){return!1}};var Jd=class extends es{constructor(e={}){super(e)}getViewportType(){return BT}get ControllerType(){return fl}};Jd.displayName="OrthographicView";var ob=Jd;var dl=class{static get componentName(){return Object.prototype.hasOwnProperty.call(this,"extensionName")?this.extensionName:""}constructor(e){e&&(this.opts=e)}equals(e){return this===e?!0:this.constructor===e.constructor&&Ee(this.opts,e.opts,1)}getShaders(e){return null}getSubLayerProps(e){let{defaultProps:t}=e.constructor,i={updateTriggers:{}};for(let r in t)if(r in this.props){let s=t[r],o=this.props[r];i[r]=o,s&&s.type==="accessor"&&(i.updateTriggers[r]=this.props.updateTriggers[r],typeof o=="function"&&(i[r]=this.getSubLayerAccessor(o)))}return i}initializeState(e,t){}updateState(e,t){}onNeedsRedraw(e){}getNeedsPickingBuffer(e){return!1}draw(e,t){}finalizeState(e,t){}};dl.defaultProps={};dl.extensionName="LayerExtension";var ab=dl;J();var ar=class{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;let{attributes:t={}}=e;this.typedArrayManager=gn,this.attributes={},this._attributeDefs=t,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);let{data:t,buffers:i={},getGeometry:r,geometryBuffer:s,positionFormat:o,dataChanged:a,normalize:c=!0}=this.opts;if(this.data=t,this.getGeometry=r,this.positionSize=s&&s.size||(o==="XY"?2:3),this.buffers=i,this.normalize=c,s&&(ge(t.startIndices),this.getGeometry=this.getGeometryFromBuffer(s),c||(i.vertexPositions=s)),this.geometryBuffer=i.vertexPositions,Array.isArray(a))for(let l of a)this._rebuildGeometry(l);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:t}){this._rebuildGeometry({startRow:e,endRow:t})}getGeometryFromBuffer(e){let t=e.value||e;return ArrayBuffer.isView(t)?Pd(t,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,t){let{attributes:i,buffers:r,_attributeDefs:s,typedArrayManager:o}=this;for(let a in s)if(a in r)o.release(i[a]),i[a]=null;else{let c=s[a];c.copy=t,i[a]=o.allocate(i[a],e,c)}}_forEachGeometry(e,t,i){let{data:r,getGeometry:s}=this,{iterable:o,objectInfo:a}=Ed(r,t,i);for(let c of o){a.index++;let l=s?s(c,a):null;e(l,a.index)}}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:t,vertexStarts:i,instanceCount:r}=this,{data:s,geometryBuffer:o}=this,{startRow:a=0,endRow:c=1/0}=e||{},l={};if(e||(t=[0],i=[0]),this.normalize||!o)this._forEachGeometry((f,d)=>{let h=f&&this.normalizeGeometry(f);l[d]=h,i[d+1]=i[d]+(h?this.getGeometrySize(h):0)},a,c),r=i[i.length-1];else if(i=s.startIndices,r=i[s.length]||0,ArrayBuffer.isView(o))r=r||o.length/this.positionSize;else if(o instanceof ie){let f=this.positionSize*4;r=r||o.byteLength/f}else if(o.buffer){let f=o.stride||this.positionSize*4;r=r||o.buffer.byteLength/f}else if(o.value){let f=o.value,d=o.stride/f.BYTES_PER_ELEMENT||this.positionSize;r=r||f.length/d}this._allocate(r,!!e),this.indexStarts=t,this.vertexStarts=i,this.instanceCount=r;let u={};this._forEachGeometry((f,d)=>{let h=l[d]||f;u.vertexStart=i[d],u.indexStart=t[d];let p=d 1.0) { discard; } #endif -`}};var eG={getDashArray:{type:"accessor",value:[0,0]},getOffset:{type:"accessor",value:0},dashJustified:!1,dashGapPickable:!1,dashUnits:"widths"},tG={widths:0,pixels:1,meters:2,common:3},nG=["instanceDashArrays","instanceDashOffsets","instanceOffsets"];function iG({props:n,oldProps:e}){return!xe(n.modelMatrix,e.modelMatrix,2)||n.coordinateSystem!==e.coordinateSystem||!xe(n.coordinateOrigin,e.coordinateOrigin,1)}function zT(n,e,t){let i=n.context.viewport;if(!(i instanceof yi)||i.zoom<12)return n.projectPosition(e,{autoOffset:!1});let r=At.transformMat4([],[e[0],e[1],e[2]||0,1],t.modelMatrix),s=n.props.coordinateSystem==="default"?"lnglat":n.props.coordinateSystem;if(s==="lnglat"){if(Math.abs(r[1]-t.coordinateOrigin[1])>.25){let c=r[0];t.wrapLongitude&&(c=((c+180)%360+360)%360-180);let l=i.projectPosition([c,r[1],0]);return[l[0]-t.commonOrigin[0],l[1]-t.commonOrigin[1],r[2]*t.commonUnitsPerMeter[2]]}yt.sub(r,r,t.coordinateOrigin)}else s==="cartesian"&&yt.sub(r,r,t.coordinateOrigin);let o=r[1],a=yt.scaleAndAdd([],t.commonUnitsPerWorldUnit,t.commonUnitsPerWorldUnit2,o);return yt.multiply([],r,a)}var dl=class extends ob{constructor({dash:e=!1,offset:t=!1,dashMode:i,highPrecisionDash:r=!1}={}){let s=i??(r?"path":"segment");super({dash:e||r||i!==void 0,offset:t,dashMode:s,highPrecisionDash:s==="path"})}getLayerType(e){if("pathTesselator"in e.state)return"path";let t=e.constructor.layerName;return t==="ScatterplotLayer"?"scatterplot":t==="TextBackgroundLayer"?"textBackground":null}synchronizeAttributes(e){let t=e.getAttributeManager(),i=this.getLayerType(e);if(!t||!i)return!1;let r=t.getAttributes(),s=new Set;this.opts.dash&&s.add("instanceDashArrays"),i==="path"&&this.opts.dash&&this.opts.dashMode==="path"&&s.add("instanceDashOffsets"),i==="path"&&this.opts.offset&&s.add("instanceOffsets");let o=!1;for(let a of nG)r[a]&&!s.has(a)&&(t.remove([a]),o=!0);return s.has("instanceDashArrays")&&!r.instanceDashArrays&&(t.addInstanced({instanceDashArrays:{size:2,accessor:"getDashArray"}}),o=!0),s.has("instanceDashOffsets")&&!r.instanceDashOffsets&&(t.addInstanced({instanceDashOffsets:{size:2,accessor:["getPath"],update:this.calculateDashMetrics}}),o=!0),s.has("instanceOffsets")&&!r.instanceOffsets&&(t.addInstanced({instanceOffsets:{size:1,accessor:"getOffset"}}),o=!0),o}isEnabled(e){return this.getLayerType(e)!==null}getShaders(e){let t=e.getLayerType(this);if(!t)return null;if(t==="scatterplot"||t==="textBackground")return e.opts.dash?{modules:[{name:"pathStyle",inject:t==="scatterplot"?DT.inject:NT.inject,uniformTypes:{dashGapPickable:"i32"}}]}:null;let i={},r={};e.opts.dash&&(i=us(i,OT),r.DASH_ENABLED=!0,e.opts.dashMode==="path"&&(r.HIGH_PRECISION_DASH=!0)),e.opts.offset&&(i=us(i,FT),r.PATH_STYLE_OFFSET=!0);let{inject:s}=i,o={name:"pathStyle",inject:s};return e.opts.dash&&(o.uniformTypes={dashAlignMode:"f32",dashGapPickable:"i32",dashUnits:"i32"}),{modules:[o],defines:r}}initializeState(e,t){t.synchronizeAttributes(this)}updateState(e,t){if(t.isEnabled(this)){if(e.changeFlags.extensionsChanged){let i=t.synchronizeAttributes(this),r=this.getAttributeManager();if(r&&i){r.invalidateAll();for(let s of this.getModels())s.setBufferLayout(r.getBufferLayouts(s))}}if(t.opts.dash){let i=t.getLayerType(this);if(i==="path"&&t.opts.dashMode==="path"&&iG(e)&&this.getAttributeManager()?.invalidate("instanceDashOffsets"),i==="scatterplot"||i==="textBackground"){let r={dashGapPickable:!!this.props.dashGapPickable};this.setShaderModuleProps({pathStyle:r})}else{let r={dashAlignMode:this.props.dashJustified?1:0,dashGapPickable:!!this.props.dashGapPickable,dashUnits:tG[this.props.dashUnits??"widths"]};this.setShaderModuleProps({pathStyle:r})}}}}calculateDashMetrics(e,{startRow:t,endRow:i}){let r=this.state.pathTesselator,s=r?.vertexStarts,o=r?.instanceCount,a=r?.get("positions");if(!s||o===void 0||typeof r?.getPathSegmentIndices!="function")throw new Error("PathStyleExtension requires PathLayer tessellation data for path dashes.");let c=this.props.data?.attributes?.getPath,l=ArrayBuffer.isView(c)?c:c?.value,u=ArrayBuffer.isView(l),f=a&&(!c||r.normalize||r.opts?.isWebGPU);if(c&&!u||!f&&!u)throw new Error("PathStyleExtension cannot calculate whole-path dash metrics from GPU-only getPath data; supply data.attributes.instanceDashOffsets.");let d=e.value,h=e.size,p=Math.max(0,t),m=Math.min(i,s.length-1),g=3,v=3,y=0;if(!f){let x=l.BYTES_PER_ELEMENT;g=c?.size||(this.props.positionFormat==="XY"?2:3),v=c?.stride?c.stride/x:g,y=c?.offset?c.offset/x:0}let b=new Array(3),w=un.getUniforms({viewport:this.context.viewport,modelMatrix:this.props.modelMatrix,coordinateSystem:this.props.coordinateSystem,coordinateOrigin:this.props.coordinateOrigin,autoWrapLongitude:this.wrapLongitude}),E=x=>{if(f)b[0]=a[x*3],b[1]=a[x*3+1],b[2]=a[x*3+2];else{let T=y+x*v;b[0]=l[T],b[1]=l[T+1],b[2]=g===3?l[T+2]:0}return b};e.startIndices=s;for(let x=p;x1)for(let V=T;V0&&(t[c]=t[c-1]+yt.dist(a,o)),a=o;return t[s-1]=0,t}};dl.defaultProps=eG;dl.extensionName="PathStyleExtension";var ab=dl;Ce();Fe();var rG=new Uint32Array([0,2,1,0,3,2]),sG=new Float32Array([0,1,0,0,1,0,1,1]);function cb(n,e){if(!e)return oG(n);let t=Math.max(Math.abs(n[0][0]-n[3][0]),Math.abs(n[1][0]-n[2][0])),i=Math.max(Math.abs(n[1][1]-n[0][1]),Math.abs(n[2][1]-n[3][1])),r=Math.ceil(t/e)+1,s=Math.ceil(i/e)+1,o=(r-1)*(s-1)*6,a=new Uint32Array(o),c=new Float32Array(r*s*2),l=new Float64Array(r*s*3),u=0,f=0;for(let d=0;d0&&p>0&&(a[f++]=u-s,a[f++]=u-s-1,a[f++]=u-1,a[f++]=u-s,a[f++]=u-1,a[f++]=u),u++}}return{vertexCount:o,positions:l,indices:a,texCoords:c}}function oG(n){let e=new Float64Array(12);for(let t=0;t.25){let c=r[0];t.wrapLongitude&&(c=((c+180)%360+360)%360-180);let l=i.projectPosition([c,r[1],0]);return[l[0]-t.commonOrigin[0],l[1]-t.commonOrigin[1],r[2]*t.commonUnitsPerMeter[2]]}bt.sub(r,r,t.coordinateOrigin)}else s==="cartesian"&&bt.sub(r,r,t.coordinateOrigin);let o=r[1],a=bt.scaleAndAdd([],t.commonUnitsPerWorldUnit,t.commonUnitsPerWorldUnit2,o);return bt.multiply([],r,a)}var hl=class extends ab{constructor({dash:e=!1,offset:t=!1,dashMode:i,highPrecisionDash:r=!1}={}){let s=i??(r?"path":"segment");super({dash:e||r||i!==void 0,offset:t,dashMode:s,highPrecisionDash:s==="path"})}getLayerType(e){if("pathTesselator"in e.state)return"path";let t=e.constructor.layerName;return t==="ScatterplotLayer"?"scatterplot":t==="TextBackgroundLayer"?"textBackground":null}synchronizeAttributes(e){let t=e.getAttributeManager(),i=this.getLayerType(e);if(!t||!i)return!1;let r=t.getAttributes(),s=new Set;this.opts.dash&&s.add("instanceDashArrays"),i==="path"&&this.opts.dash&&this.opts.dashMode==="path"&&s.add("instanceDashOffsets"),i==="path"&&this.opts.offset&&s.add("instanceOffsets");let o=!1;for(let a of sG)r[a]&&!s.has(a)&&(t.remove([a]),o=!0);return s.has("instanceDashArrays")&&!r.instanceDashArrays&&(t.addInstanced({instanceDashArrays:{size:2,accessor:"getDashArray"}}),o=!0),s.has("instanceDashOffsets")&&!r.instanceDashOffsets&&(t.addInstanced({instanceDashOffsets:{size:2,accessor:["getPath"],update:this.calculateDashMetrics}}),o=!0),s.has("instanceOffsets")&&!r.instanceOffsets&&(t.addInstanced({instanceOffsets:{size:1,accessor:"getOffset"}}),o=!0),o}isEnabled(e){return this.getLayerType(e)!==null}getShaders(e){let t=e.getLayerType(this);if(!t)return null;if(t==="scatterplot"||t==="textBackground")return e.opts.dash?{modules:[{name:"pathStyle",inject:t==="scatterplot"?NT.inject:FT.inject,uniformTypes:{dashGapPickable:"i32"}}]}:null;let i={},r={};e.opts.dash&&(i=us(i,DT),r.DASH_ENABLED=!0,e.opts.dashMode==="path"&&(r.HIGH_PRECISION_DASH=!0)),e.opts.offset&&(i=us(i,zT),r.PATH_STYLE_OFFSET=!0);let{inject:s}=i,o={name:"pathStyle",inject:s};return e.opts.dash&&(o.uniformTypes={dashAlignMode:"f32",dashGapPickable:"i32",dashUnits:"i32"}),{modules:[o],defines:r}}initializeState(e,t){t.synchronizeAttributes(this)}updateState(e,t){if(t.isEnabled(this)){if(e.changeFlags.extensionsChanged){let i=t.synchronizeAttributes(this),r=this.getAttributeManager();if(r&&i){r.invalidateAll();for(let s of this.getModels())s.setBufferLayout(r.getBufferLayouts(s))}}if(t.opts.dash){let i=t.getLayerType(this);if(i==="path"&&t.opts.dashMode==="path"&&oG(e)&&this.getAttributeManager()?.invalidate("instanceDashOffsets"),i==="scatterplot"||i==="textBackground"){let r={dashGapPickable:!!this.props.dashGapPickable};this.setShaderModuleProps({pathStyle:r})}else{let r={dashAlignMode:this.props.dashJustified?1:0,dashGapPickable:!!this.props.dashGapPickable,dashUnits:rG[this.props.dashUnits??"widths"]};this.setShaderModuleProps({pathStyle:r})}}}}calculateDashMetrics(e,{startRow:t,endRow:i}){let r=this.state.pathTesselator,s=r?.vertexStarts,o=r?.instanceCount,a=r?.get("positions");if(!s||o===void 0||typeof r?.getPathSegmentIndices!="function")throw new Error("PathStyleExtension requires PathLayer tessellation data for path dashes.");let c=this.props.data?.attributes?.getPath,l=ArrayBuffer.isView(c)?c:c?.value,u=ArrayBuffer.isView(l),f=a&&(!c||r.normalize||r.opts?.isWebGPU);if(c&&!u||!f&&!u)throw new Error("PathStyleExtension cannot calculate whole-path dash metrics from GPU-only getPath data; supply data.attributes.instanceDashOffsets.");let d=e.value,h=e.size,p=Math.max(0,t),m=Math.min(i,s.length-1),g=3,v=3,y=0;if(!f){let w=l.BYTES_PER_ELEMENT;g=c?.size||(this.props.positionFormat==="XY"?2:3),v=c?.stride?c.stride/w:g,y=c?.offset?c.offset/w:0}let b=new Array(3),x=hn.getUniforms({viewport:this.context.viewport,modelMatrix:this.props.modelMatrix,coordinateSystem:this.props.coordinateSystem,coordinateOrigin:this.props.coordinateOrigin,autoWrapLongitude:this.wrapLongitude}),E=w=>{if(f)b[0]=a[w*3],b[1]=a[w*3+1],b[2]=a[w*3+2];else{let T=y+w*v;b[0]=l[T],b[1]=l[T+1],b[2]=g===3?l[T+2]:0}return b};e.startIndices=s;for(let w=p;w1)for(let G=T;G0&&(t[c]=t[c-1]+bt.dist(a,o)),a=o;return t[s-1]=0,t}};hl.defaultProps=iG;hl.extensionName="PathStyleExtension";var cb=hl;Me();ze();var aG=new Uint32Array([0,2,1,0,3,2]),cG=new Float32Array([0,1,0,0,1,0,1,1]);function lb(n,e){if(!e)return lG(n);let t=Math.max(Math.abs(n[0][0]-n[3][0]),Math.abs(n[1][0]-n[2][0])),i=Math.max(Math.abs(n[1][1]-n[0][1]),Math.abs(n[2][1]-n[3][1])),r=Math.ceil(t/e)+1,s=Math.ceil(i/e)+1,o=(r-1)*(s-1)*6,a=new Uint32Array(o),c=new Float32Array(r*s*2),l=new Float64Array(r*s*3),u=0,f=0;for(let d=0;d0&&p>0&&(a[f++]=u-s,a[f++]=u-s-1,a[f++]=u-1,a[f++]=u-s,a[f++]=u-1,a[f++]=u),u++}}return{vertexCount:o,positions:l,indices:a,texCoords:c}}function lG(n){let e=new Float64Array(12);for(let t=0;t, coordinateConversion: f32, @@ -4546,14 +4546,14 @@ struct BitmapUniforms { @group(0) @binding(auto) var bitmap: BitmapUniforms; @group(0) @binding(auto) var bitmapTexture: texture_2d; @group(0) @binding(auto) var bitmapTextureSampler: sampler; -`,UT=`layout(std140) uniform bitmapUniforms { +`,$T=`layout(std140) uniform bitmapUniforms { vec4 bounds; float coordinateConversion; float desaturate; vec3 tintColor; vec4 transparentColor; } bitmap; -`,$T={name:"bitmap",source:cG,vs:UT,fs:UT,uniformTypes:{bounds:"vec4",coordinateConversion:"f32",desaturate:"f32",tintColor:"vec3",transparentColor:"vec4"}};var GT=`struct Attributes { +`,GT={name:"bitmap",source:fG,vs:$T,fs:$T,uniformTypes:{bounds:"vec4",coordinateConversion:"f32",desaturate:"f32",tintColor:"vec3",transparentColor:"vec4"}};var VT=`struct Attributes { @location(0) positions: vec3, @location(1) positions64Low: vec3, @location(2) texCoords: vec2, @@ -4692,7 +4692,7 @@ fn fragmentMain(input: Varyings) -> @location(0) vec4 { return deckgl_premultiplied_alpha(fragColor); } -`;var VT=`#version 300 es +`;var WT=`#version 300 es #define SHADER_NAME bitmap-layer-vertex-shader in vec2 texCoords; @@ -4723,7 +4723,7 @@ void main(void) { vec4 color = vec4(0.0); DECKGL_FILTER_COLOR(color, geometry); } -`;var lG=` +`;var dG=` vec3 packUVsIntoRGB(vec2 uv) { // Extract the top 8 bits. We want values to be truncated down so we can add a fraction vec2 uv8bit = floor(uv * 256.); @@ -4738,7 +4738,7 @@ vec3 packUVsIntoRGB(vec2 uv) { return vec3(uv8bit, fractions) / 255.; } -`,WT=`#version 300 es +`,jT=`#version 300 es #define SHADER_NAME bitmap-layer-fragment-shader #ifdef GL_ES @@ -4806,7 +4806,7 @@ vec2 getUV(vec2 pos) { ); } -${lG} +${dG} void main(void) { vec2 uv = vTexCoord; @@ -4829,7 +4829,7 @@ void main(void) { fragColor.rgb = packUVsIntoRGB(uv); } } -`;var uG={image:{type:"image",value:null,async:!0},bounds:{type:"array",value:[1,0,0,1],compare:!0},_imageCoordinateSystem:"default",desaturate:{type:"number",min:0,max:1,value:0},transparentColor:{type:"color",value:[0,0,0,0]},tintColor:{type:"color",value:[255,255,255]},textureParameters:{type:"object",ignore:!0,value:null}},hl=class extends Ci{getShaders(){return super.getShaders({vs:VT,fs:WT,source:GT,modules:[zn,Gn,Wn,$T]})}initializeState(){let e=this.getAttributeManager(),t=!0;e.add({indices:{size:1,isIndexed:!0,update:i=>i.value=this.state.mesh.indices,noAlloc:t},positions:{size:3,type:"float64",fp64:this.use64bitPositions(),update:i=>i.value=this.state.mesh.positions,noAlloc:t},texCoords:{size:2,update:i=>i.value=this.state.mesh.texCoords,noAlloc:t}})}updateState({props:e,oldProps:t,changeFlags:i}){let r=this.getAttributeManager();if(i.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),r.invalidateAll()),e.bounds!==t.bounds){let s=this.state.mesh,o=this._createMesh();this.state.model.setVertexCount(o.vertexCount);for(let a in o)s&&s[a]!==o[a]&&r.invalidate(a);this.setState({mesh:o,...this._getCoordinateUniforms()})}else e._imageCoordinateSystem!==t._imageCoordinateSystem&&this.setState(this._getCoordinateUniforms())}getPickingInfo(e){let{image:t}=this.props,i=e.info;if(!i.color||!t)return i.bitmap=null,i;let{width:r,height:s}=t;i.index=0;let o=fG(i.color);return i.bitmap={size:{width:r,height:s},uv:o,pixel:[Math.floor(o[0]*r),Math.floor(o[1]*s)]},i}disablePickingIndex(){this.setState({disablePicking:!0})}restorePickingColors(){this.setState({disablePicking:!1})}_updateAutoHighlight(e){super._updateAutoHighlight({...e,color:this.encodePickingColor(0)})}_createMesh(){let{bounds:e}=this.props,t=e;return jT(e)&&(t=[[e[0],e[1]],[e[0],e[3]],[e[2],e[3]],[e[2],e[1]]]),cb(t,this.context.viewport.resolution)}_getModel(){let e=this.context.device.type==="webgpu"?this.getAttributeManager().getBufferLayouts({isInstanced:!1}).filter(t=>t.name!=="indices"):this.getAttributeManager().getBufferLayouts();return new Ze(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:e,topology:"triangle-list",isInstanced:!1})}draw(e){let{shaderModuleProps:t}=e,{model:i,coordinateConversion:r,bounds:s,disablePicking:o}=this.state,{image:a,desaturate:c,transparentColor:l,tintColor:u}=this.props;if(!(t.picking.isActive&&o)&&a&&i){let f={bitmapTexture:a,bounds:s,coordinateConversion:r,desaturate:c,tintColor:u.slice(0,3).map(d=>d/255),transparentColor:l.map(d=>d/255)};i.shaderInputs.setProps({bitmap:f}),i.draw(this.context.renderPass)}}_getCoordinateUniforms(){let{_imageCoordinateSystem:e}=this.props;if(e!=="default"){let{bounds:t}=this.props;if(!jT(t))throw new Error("_imageCoordinateSystem only supports rectangular bounds");let i=this.context.viewport.resolution?"lnglat":"cartesian";if(e=e==="lnglat"?"lnglat":"cartesian",e==="lnglat"&&i==="cartesian")return{coordinateConversion:-1,bounds:t};if(e==="cartesian"&&i==="lnglat"){let r=ht([t[0],t[1]]),s=ht([t[2],t[3]]);return{coordinateConversion:1,bounds:[r[0],r[1],s[0],s[1]]}}}return{coordinateConversion:0,bounds:[0,0,0,0]}}};hl.layerName="BitmapLayer";hl.defaultProps=uG;var lb=hl;function fG(n){let[e,t,i]=n,r=(i&240)/256,s=(i&15)/16;return[(e+s)/256,(t+r)/256]}function jT(n){return Number.isFinite(n[0])}Ce();var HT=`layout(std140) uniform scatterplotUniforms { +`;var hG={image:{type:"image",value:null,async:!0},bounds:{type:"array",value:[1,0,0,1],compare:!0},_imageCoordinateSystem:"default",desaturate:{type:"number",min:0,max:1,value:0},transparentColor:{type:"color",value:[0,0,0,0]},tintColor:{type:"color",value:[255,255,255]},textureParameters:{type:"object",ignore:!0,value:null}},pl=class extends ki{getShaders(){return super.getShaders({vs:WT,fs:jT,source:VT,modules:[Vn,Hn,qn,GT]})}initializeState(){let e=this.getAttributeManager(),t=!0;e.add({indices:{size:1,isIndexed:!0,update:i=>i.value=this.state.mesh.indices,noAlloc:t},positions:{size:3,type:"float64",fp64:this.use64bitPositions(),update:i=>i.value=this.state.mesh.positions,noAlloc:t},texCoords:{size:2,update:i=>i.value=this.state.mesh.texCoords,noAlloc:t}})}updateState({props:e,oldProps:t,changeFlags:i}){let r=this.getAttributeManager();if(i.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),r.invalidateAll()),e.bounds!==t.bounds){let s=this.state.mesh,o=this._createMesh();this.state.model.setVertexCount(o.vertexCount);for(let a in o)s&&s[a]!==o[a]&&r.invalidate(a);this.setState({mesh:o,...this._getCoordinateUniforms()})}else e._imageCoordinateSystem!==t._imageCoordinateSystem&&this.setState(this._getCoordinateUniforms())}getPickingInfo(e){let{image:t}=this.props,i=e.info;if(!i.color||!t)return i.bitmap=null,i;let{width:r,height:s}=t;i.index=0;let o=pG(i.color);return i.bitmap={size:{width:r,height:s},uv:o,pixel:[Math.floor(o[0]*r),Math.floor(o[1]*s)]},i}disablePickingIndex(){this.setState({disablePicking:!0})}restorePickingColors(){this.setState({disablePicking:!1})}_updateAutoHighlight(e){super._updateAutoHighlight({...e,color:this.encodePickingColor(0)})}_createMesh(){let{bounds:e}=this.props,t=e;return HT(e)&&(t=[[e[0],e[1]],[e[0],e[3]],[e[2],e[3]],[e[2],e[1]]]),lb(t,this.context.viewport.resolution)}_getModel(){let e=this.context.device.type==="webgpu"?this.getAttributeManager().getBufferLayouts({isInstanced:!1}).filter(t=>t.name!=="indices"):this.getAttributeManager().getBufferLayouts();return new Ze(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:e,topology:"triangle-list",isInstanced:!1})}draw(e){let{shaderModuleProps:t}=e,{model:i,coordinateConversion:r,bounds:s,disablePicking:o}=this.state,{image:a,desaturate:c,transparentColor:l,tintColor:u}=this.props;if(!(t.picking.isActive&&o)&&a&&i){let f={bitmapTexture:a,bounds:s,coordinateConversion:r,desaturate:c,tintColor:u.slice(0,3).map(d=>d/255),transparentColor:l.map(d=>d/255)};i.shaderInputs.setProps({bitmap:f}),i.draw(this.context.renderPass)}}_getCoordinateUniforms(){let{_imageCoordinateSystem:e}=this.props;if(e!=="default"){let{bounds:t}=this.props;if(!HT(t))throw new Error("_imageCoordinateSystem only supports rectangular bounds");let i=this.context.viewport.resolution?"lnglat":"cartesian";if(e=e==="lnglat"?"lnglat":"cartesian",e==="lnglat"&&i==="cartesian")return{coordinateConversion:-1,bounds:t};if(e==="cartesian"&&i==="lnglat"){let r=ht([t[0],t[1]]),s=ht([t[2],t[3]]);return{coordinateConversion:1,bounds:[r[0],r[1],s[0],s[1]]}}}return{coordinateConversion:0,bounds:[0,0,0,0]}}};pl.layerName="BitmapLayer";pl.defaultProps=hG;var ub=pl;function pG(n){let[e,t,i]=n,r=(i&240)/256,s=(i&15)/16;return[(e+s)/256,(t+r)/256]}function HT(n){return Number.isFinite(n[0])}Me();var YT=`layout(std140) uniform scatterplotUniforms { float radiusScale; float radiusMinPixels; float radiusMaxPixels; @@ -4843,7 +4843,7 @@ void main(void) { highp int radiusUnits; highp int lineWidthUnits; } scatterplot; -`,YT={name:"scatterplot",vs:HT,fs:HT,source:"",uniformTypes:{radiusScale:"f32",radiusMinPixels:"f32",radiusMaxPixels:"f32",lineWidthScale:"f32",lineWidthMinPixels:"f32",lineWidthMaxPixels:"f32",stroked:"f32",filled:"f32",antialiasing:"f32",billboard:"f32",radiusUnits:"i32",lineWidthUnits:"i32"}};var qT=`#version 300 es +`,qT={name:"scatterplot",vs:YT,fs:YT,source:"",uniformTypes:{radiusScale:"f32",radiusMinPixels:"f32",radiusMaxPixels:"f32",lineWidthScale:"f32",lineWidthMinPixels:"f32",lineWidthMaxPixels:"f32",stroked:"f32",filled:"f32",antialiasing:"f32",billboard:"f32",radiusUnits:"i32",lineWidthUnits:"i32"}};var ZT=`#version 300 es #define SHADER_NAME scatterplot-layer-vertex-shader in vec3 positions; in vec3 instancePositions; @@ -4900,7 +4900,7 @@ DECKGL_FILTER_COLOR(vFillColor, geometry); vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity); DECKGL_FILTER_COLOR(vLineColor, geometry); } -`;var ZT=`#version 300 es +`;var XT=`#version 300 es #define SHADER_NAME scatterplot-layer-fragment-shader precision highp float; in vec4 vFillColor; @@ -4938,7 +4938,7 @@ fragColor = vFillColor; fragColor.a *= inCircle; DECKGL_FILTER_COLOR(fragColor, geometry); } -`;var dG=`// Main shaders +`;var mG=`// Main shaders struct ScatterplotUniforms { radiusScale: f32, @@ -5142,7 +5142,7 @@ fn fragmentMain(varyings: Varyings) -> @location(0) vec4 { return fragColor; // return vec4(0, 0, 1, 1); } -`;function XT(n){return dG.replace("PICKING_COLOR_ATTRIBUTE",n?"@location(8) rowIndexes: u32,":"").replace("PICKING_COLOR_VALUE",n?"picking_getPickingColorFromIndex(attributes.rowIndexes)":"picking_getPickingColorFromIndex(attributes.instanceIndex)")}var hG=`struct ClipUniforms { +`;function KT(n){return mG.replace("PICKING_COLOR_ATTRIBUTE",n?"@location(8) rowIndexes: u32,":"").replace("PICKING_COLOR_VALUE",n?"picking_getPickingColorFromIndex(attributes.rowIndexes)":"picking_getPickingColorFromIndex(attributes.instanceIndex)")}var gG=`struct ClipUniforms { enabled: i32, mode: i32, bounds: vec4, @@ -5176,7 +5176,7 @@ fn clip_filterColor(geometryCoordinates: vec2) { discard; } } -`,pG={name:"clip",source:hG,props:{},uniforms:{},bindingLayout:[{name:"clip",group:2}],uniformTypes:{enabled:"i32",mode:"i32",bounds:"vec4"},defaultUniforms:{enabled:0,mode:0,bounds:[0,0,1,1]},getUniforms(n={}){let e={};return n.enabled!==void 0&&(e.enabled=n.enabled?1:0),n.mode!==void 0&&(e.mode=n.mode==="instance"?1:0),n.bounds!==void 0&&(e.bounds=n.bounds),e}},zo=pG;var KT=[0,0,0,255],mG={radiusUnits:"meters",radiusScale:{type:"number",min:0,value:1},radiusMinPixels:{type:"number",min:0,value:0},radiusMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},lineWidthUnits:"meters",lineWidthScale:{type:"number",min:0,value:1},lineWidthMinPixels:{type:"number",min:0,value:0},lineWidthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,getPosition:{type:"accessor",value:n=>n.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:KT},getLineColor:{type:"accessor",value:KT},getLineWidth:{type:"accessor",value:1},getPixelOffset:{type:"accessor",value:[0,0]},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}},pl=class extends Ci{getShaders(){let e=!!this.props.data?.attributes?.rowIndexes;return super.getShaders({vs:qT,fs:ZT,source:XT(e),defines:e?{USE_ROW_INDEXES:!0}:{},modules:[Gn,zn,Wn,YT,...this.context.device.type==="webgpu"?[zo]:[]]})}initializeState(){let e=this.props.data?.attributes?.rowIndexes?{rowIndexes:{size:1,type:"uint32",noAlloc:!0}}:{};this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceRadius:{size:1,transition:!0,accessor:"getRadius",defaultValue:1,bufferGroup:"scatterplot-instance-data"},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255],bufferGroup:"scatterplot-instance-data"},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255],bufferGroup:"scatterplot-instance-data"},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1,bufferGroup:"scatterplot-instance-data"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset",bufferGroup:"scatterplot-instance-data"},...e})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{radiusUnits:t,radiusScale:i,radiusMinPixels:r,radiusMaxPixels:s,stroked:o,filled:a,billboard:c,antialiasing:l,lineWidthUnits:u,lineWidthScale:f,lineWidthMinPixels:d,lineWidthMaxPixels:h}=this.props,p={stroked:o,filled:a,billboard:c,antialiasing:l,radiusUnits:Zt[t],radiusScale:i,radiusMinPixels:r,radiusMaxPixels:s,lineWidthUnits:Zt[u],lineWidthScale:f,lineWidthMinPixels:d,lineWidthMaxPixels:h},m=this.state.model;m.shaderInputs.setProps({scatterplot:p}),m.draw(this.context.renderPass)}_getModel(){let e=[-1,-1,0,1,-1,0,-1,1,0,1,1,0];return new Ze(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Kt({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(e)}}}),isInstanced:!0})}};pl.defaultProps=mG;pl.layerName="ScatterplotLayer";var ub=pl;var Jd={CLOCKWISE:1,COUNTER_CLOCKWISE:-1};function ml(n,e,t={}){return QT(n,t)!==e?(gG(n,t),!0):!1}function QT(n,e={}){return Math.sign(eh(n,e))}var fb={x:0,y:1,z:2};function eh(n,e={}){let{start:t=0,end:i=n.length,plane:r="xy"}=e,s=e.size||2,o=0,a=fb[r[0]],c=fb[r[1]];for(let l=t,u=i-s;l0){let r=!0;for(let s=0;se[2]&&(t|=2),n[1]e[3]&&(t|=8),t}function yl(n,e){let{size:t=2,broken:i=!1,gridResolution:r=10,gridOffset:s=[0,0],startIndex:o=0,endIndex:a=n.length}=e||{},c=(a-o)/t,l=[],u=[l],f=or(n,0,t,o),d,h,p=tL(f,r,s,[]),m=[];wt(l,f);for(let g=1;gt&&(l=[],u.push(l),wt(l,f)),h=_l(d,p)}wt(l,d),gl(f,d)}return i?u:u[0]}var JT=0,yG=1;function bl(n,e=null,t){if(!n.length)return[];let{size:i=2,gridResolution:r=10,gridOffset:s=[0,0],edgeTypes:o=!1}=t||{},a=[],c=[{pos:n,types:o?new Array(n.length/i).fill(yG):null,holes:e||[]}],l=[[],[]],u=[];for(;c.length;){let{pos:f,types:d,holes:h}=c.shift();vG(f,i,h[0]||f.length,l),u=tL(l[0],r,s,u);let p=_l(l[1],u);if(p){let m=eL(f,d,i,0,h[0]||f.length,u,p),g={pos:m[0].pos,types:m[0].types,holes:[]},v={pos:m[1].pos,types:m[1].types,holes:[]};c.push(g,v);for(let y=0;y=0?(wt(l,h)&&f.push(m),w+=p):f.length&&(f[f.length-1]=JT),gl(g,h),v=p,y=m;return[b?{pos:c,types:e&&u}:null,w?{pos:l,types:e&&f}:null]}function tL(n,e,t,i){let r=Math.floor((n[0]-t[0])/e)*e+t[0],s=Math.floor((n[1]-t[1])/e)*e+t[1];return i[0]=r,i[1]=s,i[2]=r+e,i[3]=s+e,i}function bG(n,e,t){t&8?(n[1]+=e,n[3]+=e):t&4?(n[1]-=e,n[3]-=e):t&2?(n[0]+=e,n[2]+=e):t&1&&(n[0]-=e,n[2]-=e)}function vG(n,e,t,i){let r=1/0,s=-1/0,o=1/0,a=-1/0;for(let c=0;cs?l:s,o=ua?u:a}return i[0][0]=r,i[0][1]=o,i[1][0]=s,i[1][1]=a,i}function nh(n,e){for(let t=0;tr&&(r=a,s=o-1)}return s}function EG(n,e,t,i,r=xG){let s=n[t],o=n[i-e];if(Math.abs(s-o)>180){let a=or(n,0,e,t);a[0]+=Math.round((o-s)/360)*360,wt(n,a),a[1]=Math.sign(a[1])*r,wt(n,a),a[0]=s,wt(n,a)}}function nL(n,e,t,i){let r=n[0],s;for(let o=t;o180||a<-180)&&(s-=Math.round(a/360)*360),n[o]=r=s}}function iL(n,e){let t,i=n.length/e;for(let s=0;s=e.length&&(t+=1-e.length/r);let s=t*r;return i[0]=e[s],i[1]=e[s+1],i[2]=r===3&&e[s+2]||0,i}isClosed(e){if(!this.normalize)return!!this.opts.loop;let{positionSize:t}=this,i=e.length-t;return e[0]===e[i]&&e[1]===e[i+1]&&(t===2||e[2]===e[i+2])}};function sL(n){return Array.isArray(n[0])}var TG=`struct PathUniforms { +`,_G={name:"clip",source:gG,props:{},uniforms:{},bindingLayout:[{name:"clip",group:2}],uniformTypes:{enabled:"i32",mode:"i32",bounds:"vec4"},defaultUniforms:{enabled:0,mode:0,bounds:[0,0,1,1]},getUniforms(n={}){let e={};return n.enabled!==void 0&&(e.enabled=n.enabled?1:0),n.mode!==void 0&&(e.mode=n.mode==="instance"?1:0),n.bounds!==void 0&&(e.bounds=n.bounds),e}},zo=_G;var QT=[0,0,0,255],yG={radiusUnits:"meters",radiusScale:{type:"number",min:0,value:1},radiusMinPixels:{type:"number",min:0,value:0},radiusMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},lineWidthUnits:"meters",lineWidthScale:{type:"number",min:0,value:1},lineWidthMinPixels:{type:"number",min:0,value:0},lineWidthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,getPosition:{type:"accessor",value:n=>n.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:QT},getLineColor:{type:"accessor",value:QT},getLineWidth:{type:"accessor",value:1},getPixelOffset:{type:"accessor",value:[0,0]},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}},ml=class extends ki{getShaders(){let e=!!this.props.data?.attributes?.rowIndexes;return super.getShaders({vs:ZT,fs:XT,source:KT(e),defines:e?{USE_ROW_INDEXES:!0}:{},modules:[Hn,Vn,qn,qT,...this.context.device.type==="webgpu"?[zo]:[]]})}initializeState(){let e=this.props.data?.attributes?.rowIndexes?{rowIndexes:{size:1,type:"uint32",noAlloc:!0}}:{};this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceRadius:{size:1,transition:!0,accessor:"getRadius",defaultValue:1,bufferGroup:"scatterplot-instance-data"},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255],bufferGroup:"scatterplot-instance-data"},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255],bufferGroup:"scatterplot-instance-data"},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1,bufferGroup:"scatterplot-instance-data"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset",bufferGroup:"scatterplot-instance-data"},...e})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{radiusUnits:t,radiusScale:i,radiusMinPixels:r,radiusMaxPixels:s,stroked:o,filled:a,billboard:c,antialiasing:l,lineWidthUnits:u,lineWidthScale:f,lineWidthMinPixels:d,lineWidthMaxPixels:h}=this.props,p={stroked:o,filled:a,billboard:c,antialiasing:l,radiusUnits:Jt[t],radiusScale:i,radiusMinPixels:r,radiusMaxPixels:s,lineWidthUnits:Jt[u],lineWidthScale:f,lineWidthMinPixels:d,lineWidthMaxPixels:h},m=this.state.model;m.shaderInputs.setProps({scatterplot:p}),m.draw(this.context.renderPass)}_getModel(){let e=[-1,-1,0,1,-1,0,-1,1,0,1,1,0];return new Ze(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new tn({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(e)}}}),isInstanced:!0})}};ml.defaultProps=yG;ml.layerName="ScatterplotLayer";var fb=ml;var eh={CLOCKWISE:1,COUNTER_CLOCKWISE:-1};function gl(n,e,t={}){return JT(n,t)!==e?(bG(n,t),!0):!1}function JT(n,e={}){return Math.sign(th(n,e))}var db={x:0,y:1,z:2};function th(n,e={}){let{start:t=0,end:i=n.length,plane:r="xy"}=e,s=e.size||2,o=0,a=db[r[0]],c=db[r[1]];for(let l=t,u=i-s;l0){let r=!0;for(let s=0;se[2]&&(t|=2),n[1]e[3]&&(t|=8),t}function bl(n,e){let{size:t=2,broken:i=!1,gridResolution:r=10,gridOffset:s=[0,0],startIndex:o=0,endIndex:a=n.length}=e||{},c=(a-o)/t,l=[],u=[l],f=cr(n,0,t,o),d,h,p=nL(f,r,s,[]),m=[];Et(l,f);for(let g=1;gt&&(l=[],u.push(l),Et(l,f)),h=yl(d,p)}Et(l,d),_l(f,d)}return i?u:u[0]}var eL=0,xG=1;function vl(n,e=null,t){if(!n.length)return[];let{size:i=2,gridResolution:r=10,gridOffset:s=[0,0],edgeTypes:o=!1}=t||{},a=[],c=[{pos:n,types:o?new Array(n.length/i).fill(xG):null,holes:e||[]}],l=[[],[]],u=[];for(;c.length;){let{pos:f,types:d,holes:h}=c.shift();EG(f,i,h[0]||f.length,l),u=nL(l[0],r,s,u);let p=yl(l[1],u);if(p){let m=tL(f,d,i,0,h[0]||f.length,u,p),g={pos:m[0].pos,types:m[0].types,holes:[]},v={pos:m[1].pos,types:m[1].types,holes:[]};c.push(g,v);for(let y=0;y=0?(Et(l,h)&&f.push(m),x+=p):f.length&&(f[f.length-1]=eL),_l(g,h),v=p,y=m;return[b?{pos:c,types:e&&u}:null,x?{pos:l,types:e&&f}:null]}function nL(n,e,t,i){let r=Math.floor((n[0]-t[0])/e)*e+t[0],s=Math.floor((n[1]-t[1])/e)*e+t[1];return i[0]=r,i[1]=s,i[2]=r+e,i[3]=s+e,i}function wG(n,e,t){t&8?(n[1]+=e,n[3]+=e):t&4?(n[1]-=e,n[3]-=e):t&2?(n[0]+=e,n[2]+=e):t&1&&(n[0]-=e,n[2]-=e)}function EG(n,e,t,i){let r=1/0,s=-1/0,o=1/0,a=-1/0;for(let c=0;cs?l:s,o=ua?u:a}return i[0][0]=r,i[0][1]=o,i[1][0]=s,i[1][1]=a,i}function ih(n,e){for(let t=0;tr&&(r=a,s=o-1)}return s}function CG(n,e,t,i,r=SG){let s=n[t],o=n[i-e];if(Math.abs(s-o)>180){let a=cr(n,0,e,t);a[0]+=Math.round((o-s)/360)*360,Et(n,a),a[1]=Math.sign(a[1])*r,Et(n,a),a[0]=s,Et(n,a)}}function iL(n,e,t,i){let r=n[0],s;for(let o=t;o180||a<-180)&&(s-=Math.round(a/360)*360),n[o]=r=s}}function rL(n,e){let t,i=n.length/e;for(let s=0;s=e.length&&(t+=1-e.length/r);let s=t*r;return i[0]=e[s],i[1]=e[s+1],i[2]=r===3&&e[s+2]||0,i}isClosed(e){if(!this.normalize)return!!this.opts.loop;let{positionSize:t}=this,i=e.length-t;return e[0]===e[i]&&e[1]===e[i+1]&&(t===2||e[2]===e[i+2])}};function oL(n){return Array.isArray(n[0])}var AG=`struct PathUniforms { widthScale: f32, widthMinPixels: f32, widthMaxPixels: f32, @@ -5189,7 +5189,7 @@ fn clip_filterColor(geometryCoordinates: vec2) { @group(0) @binding(auto) var path: PathUniforms; -`,oL=`layout(std140) uniform pathUniforms { +`,aL=`layout(std140) uniform pathUniforms { float widthScale; float widthMinPixels; float widthMaxPixels; @@ -5199,7 +5199,7 @@ var path: PathUniforms; bool billboard; highp int widthUnits; } path; -`,aL={name:"path",source:TG,vs:oL,fs:oL,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",jointType:"f32",capType:"f32",miterLimit:"f32",billboard:"f32",widthUnits:"i32"}};var cL=`const EPSILON: f32 = 0.001; +`,cL={name:"path",source:AG,vs:aL,fs:aL,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",jointType:"f32",capType:"f32",miterLimit:"f32",billboard:"f32",widthUnits:"i32"}};var lL=`const EPSILON: f32 = 0.001; const ZERO_OFFSET: vec3 = vec3(0.0, 0.0, 0.0); struct JoinResult { @@ -5690,7 +5690,7 @@ fn fragmentMain(varyings: Varyings) -> @location(0) vec4 { return deckgl_premultiplied_alpha(varyings.vColor); #endif } -`;var lL=`#version 300 es +`;var uL=`#version 300 es #define SHADER_NAME path-layer-vertex-shader in vec2 positions; in float instanceTypes; @@ -5973,7 +5973,7 @@ DECKGL_FILTER_GL_POSITION(gl_Position, geometry); } DECKGL_FILTER_COLOR(vColor, geometry); } -`;var uL=`#version 300 es +`;var fL=`#version 300 es #define SHADER_NAME path-layer-fragment-shader precision highp float; in vec4 vColor; @@ -6031,19 +6031,19 @@ fragColor = vColor; #endif DECKGL_FILTER_COLOR(fragColor, geometry); } -`;var dL=[0,0,0,255],LG={widthUnits:"meters",widthScale:{type:"number",min:0,value:1},widthMinPixels:{type:"number",min:0,value:0},widthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},jointRounded:!1,capRounded:!1,miterLimit:{type:"number",min:0,value:4},antialiasing:!1,billboard:!1,_pathType:null,getPath:{type:"accessor",value:n=>n.path},getColor:{type:"accessor",value:dL},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},pb={enter:(n,e)=>e.length?e.subarray(e.length-n.length):n};function MG(n){if(n.isGeospatial)return null;let{unitsPerMeter:e}=n.distanceScales;return[e[0],e[1],e[2]]}function fL(n,e){return n===e||!!(n&&e&&n.length===e.length&&n.every((t,i)=>t===e[i]))}var wl=class extends Ci{getShaders(){let{antialiasing:e}=this.props;return super.getShaders({vs:lL,fs:uL,source:cL,defines:e?{ANTIALIASING:1}:{},modules:[Gn,zn,Wn,aL,...this.context.device.type==="webgpu"?[zo]:[]]})}get wrapLongitude(){return!1}getBounds(){return this.context.device.type==="webgpu"?null:this.getAttributeManager()?.getBounds(["vertexPositions"])}getPathProjectionScale(e){let t=this.props.coordinateSystem;if(!!!this.getAttributeManager()?.getAttributes().instanceDashOffsets)return null;if(e instanceof yi&&e.zoom>=12&&(t==="default"||t==="lnglat"||t==="cartesian")){let o=un.getUniforms({viewport:e,coordinateSystem:t,coordinateOrigin:this.props.coordinateOrigin,autoWrapLongitude:this.wrapLongitude});return[e.projectionMode,o.coordinateOrigin[1],o.commonOrigin[1],...o.commonUnitsPerWorldUnit,...o.commonUnitsPerWorldUnit2,o.commonUnitsPerMeter[2]]}let s=MG(e);return s?[e.projectionMode,...s]:[e.projectionMode]}shouldUpdateState(e){let{viewport:t}=this.context;return super.shouldUpdateState(e)||this.state?.tessellationResolution!==t.resolution||!fL(this.state?.pathProjectionScale,this.getPathProjectionScale(t))}initializeState(){let t=this.context.device.type==="webgpu";this.getAttributeManager().addInstanced({...t?{pathPositions:{size:24,type:"float32",transition:!1,accessor:"getPath",update:this.calculateWebGPUPositions,shaderAttributes:{instanceLeftPositions:{size:3,elementOffset:0},instanceStartPositions:{size:3,elementOffset:3},instanceEndPositions:{size:3,elementOffset:6},instanceRightPositions:{size:3,elementOffset:9},instanceLeftPositions64Low:{size:3,elementOffset:12},instanceStartPositions64Low:{size:3,elementOffset:15},instanceEndPositions64Low:{size:3,elementOffset:18},instanceRightPositions64Low:{size:3,elementOffset:21}},noAlloc:!0}}:{vertexPositions:{size:3,vertexOffset:1,type:"float64",fp64:this.use64bitPositions(),transition:pb,accessor:"getPath",update:this.calculatePositions,noAlloc:!0,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}}},instanceTypes:{size:1,type:t?"float32":"uint8",update:this.calculateSegmentTypes,noAlloc:!0},instanceStrokeWidths:{size:1,accessor:"getWidth",transition:t?!1:pb,defaultValue:1,bufferGroup:"path-instance-data"},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",accessor:"getColor",transition:t?!1:pb,defaultValue:dL,bufferGroup:"path-instance-data"},rowIndexes:{size:1,type:"uint32",accessor:(r,{index:s})=>r&&r.__source?r.__source.index:s,bufferGroup:"path-instance-data"}}),this.setState({pathTesselator:new xl({fp64:this.use64bitPositions(),isWebGPU:t}),tessellationResolution:this.context.viewport.resolution,pathProjectionScale:this.getPathProjectionScale(this.context.viewport)})}updateState(e){super.updateState(e);let{props:t,oldProps:i,changeFlags:r}=e,s=this.getAttributeManager(),{viewport:o}=this.context,a=this.state.tessellationResolution!==o.resolution,c=this.getPathProjectionScale(o),l=!fL(this.state.pathProjectionScale,c),f=r.updateTriggersChanged&&(r.updateTriggersChanged.all||r.updateTriggersChanged.getPath)||t._pathType!==i._pathType||t.positionFormat!==i.positionFormat||t.wrapLongitude!==i.wrapLongitude||a;if(r.dataChanged||f){let{pathTesselator:h}=this.state,p=t.data.attributes||{};h.updateGeometry({data:t.data,geometryBuffer:p.getPath,buffers:p,normalize:!t._pathType,loop:t._pathType==="loop",getGeometry:t.getPath,positionFormat:t.positionFormat,wrapLongitude:t.wrapLongitude,resolution:o.resolution,dataChanged:f?void 0:r.dataChanged}),this.setState({numInstances:h.instanceCount,startIndices:h.vertexStarts,tessellationResolution:o.resolution,pathProjectionScale:c}),!r.dataChanged||f?s.invalidateAll():l&&s.invalidate("instanceDashOffsets")}else l&&(this.setState({pathProjectionScale:c}),s.invalidate("instanceDashOffsets"));(r.extensionsChanged||t.antialiasing!==i.antialiasing)&&(this.state.model?.destroy(),this.state.model=this._getModel(),s.invalidateAll())}getPickingInfo(e){let t=super.getPickingInfo(e),{index:i}=t,r=this.props.data;return r[0]&&r[0].__source&&(t.object=r.find(s=>s.__source.index===i)),t}disablePickingIndex(e){let t=this.props.data;if(t[0]&&t[0].__source)for(let i=0;i=0&&u=1&&n[0].length>=2&&Number.isFinite(n[0][0])}function qG(n){let e=n[0],t=n[n.length-1];return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function ZG(n,e,t,i){for(let r=0;ra/e));let s=$o(n),o=i&&e===3;if(t){let a=s.length;s=s.slice();let c=[];for(let l=0;lc&&a>l||(c>l?(t||(s=s.slice()),xL(s,0,2,1)):(t||(s=s.slice()),xL(s,2,0,1)))}return(0,wL.default)(s,r,e)}var Tl=class extends sr{constructor(e){let{fp64:t,IndexType:i=Uint32Array}=e;super({...e,attributes:{positions:{size:3,type:t?Float64Array:Float32Array},vertexValid:{type:Uint16Array,size:1},indices:{type:i,size:1}}})}get(e){let{attributes:t}=this;return e==="indices"?t.indices&&t.indices.subarray(0,this.vertexCount):t[e]}updateGeometry(e){super.updateGeometry(e);let t=this.buffers.indices;if(t)this.vertexCount=(t.value||t).length;else if(this.data&&!this.getGeometry)throw new Error("missing indices buffer")}normalizeGeometry(e){if(this.normalize){let t=EL(e,this.positionSize);return this.opts.resolution?bl($o(t),Cl(t),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?hb($o(t),Cl(t),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):t}return e}getGeometrySize(e){if(PL(e)){let t=0;for(let i of e)t+=this.getGeometrySize(i);return t}return $o(e).length/this.positionSize}getGeometryFromBuffer(e){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(e):null}updateGeometryAttributes(e,t){if(e&&PL(e))for(let i of e){let r=this.getGeometrySize(i);t.geometrySize=r,this.updateGeometryAttributes(i,t),t.vertexStart+=r,t.indexStart=this.indexStarts[t.geometryIndex+1]}else{let i=e;this._updateIndices(i,t),this._updatePositions(i,t),this._updateVertexValid(i,t)}}_updateIndices(e,{geometryIndex:t,vertexStart:i,indexStart:r}){let{attributes:s,indexStarts:o,typedArrayManager:a}=this,c=s.indices;if(!c||!e)return;let l=r,u=SL(e,this.positionSize,this.opts.preproject,this.opts.full3d);c=a.allocate(c,r+u.length,{copy:!0});for(let f=0;f2?o[c*s+2]:0;r[a*3]=l,r[a*3+1]=u,r[a*3+2]=f}}_updateVertexValid(e,{vertexStart:t,geometrySize:i}){let{positionSize:r}=this,s=this.attributes.vertexValid,o=e&&Cl(e);if(e&&e.edgeTypes?s.set(e.edgeTypes,t):s.fill(1,t,t+i),o)for(let a=0;a0&&!Number.isFinite(n[0])}var KG=`struct SolidPolygonUniforms { +`;var hL=[0,0,0,255],kG={widthUnits:"meters",widthScale:{type:"number",min:0,value:1},widthMinPixels:{type:"number",min:0,value:0},widthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},jointRounded:!1,capRounded:!1,miterLimit:{type:"number",min:0,value:4},antialiasing:!1,billboard:!1,_pathType:null,getPath:{type:"accessor",value:n=>n.path},getColor:{type:"accessor",value:hL},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},mb={enter:(n,e)=>e.length?e.subarray(e.length-n.length):n};function RG(n){if(n.isGeospatial)return null;let{unitsPerMeter:e}=n.distanceScales;return[e[0],e[1],e[2]]}function dL(n,e){return n===e||!!(n&&e&&n.length===e.length&&n.every((t,i)=>t===e[i]))}var El=class extends ki{getShaders(){let{antialiasing:e}=this.props;return super.getShaders({vs:uL,fs:fL,source:lL,defines:e?{ANTIALIASING:1}:{},modules:[Hn,Vn,qn,cL,...this.context.device.type==="webgpu"?[zo]:[]]})}get wrapLongitude(){return!1}getBounds(){return this.context.device.type==="webgpu"?null:this.getAttributeManager()?.getBounds(["vertexPositions"])}getPathProjectionScale(e){let t=this.props.coordinateSystem;if(!!!this.getAttributeManager()?.getAttributes().instanceDashOffsets)return null;if(e instanceof Ei&&e.zoom>=12&&(t==="default"||t==="lnglat"||t==="cartesian")){let o=hn.getUniforms({viewport:e,coordinateSystem:t,coordinateOrigin:this.props.coordinateOrigin,autoWrapLongitude:this.wrapLongitude});return[e.projectionMode,o.coordinateOrigin[1],o.commonOrigin[1],...o.commonUnitsPerWorldUnit,...o.commonUnitsPerWorldUnit2,o.commonUnitsPerMeter[2]]}let s=RG(e);return s?[e.projectionMode,...s]:[e.projectionMode]}shouldUpdateState(e){let{viewport:t}=this.context;return super.shouldUpdateState(e)||this.state?.tessellationResolution!==t.resolution||!dL(this.state?.pathProjectionScale,this.getPathProjectionScale(t))}initializeState(){let t=this.context.device.type==="webgpu";this.getAttributeManager().addInstanced({...t?{pathPositions:{size:24,type:"float32",transition:!1,accessor:"getPath",update:this.calculateWebGPUPositions,shaderAttributes:{instanceLeftPositions:{size:3,elementOffset:0},instanceStartPositions:{size:3,elementOffset:3},instanceEndPositions:{size:3,elementOffset:6},instanceRightPositions:{size:3,elementOffset:9},instanceLeftPositions64Low:{size:3,elementOffset:12},instanceStartPositions64Low:{size:3,elementOffset:15},instanceEndPositions64Low:{size:3,elementOffset:18},instanceRightPositions64Low:{size:3,elementOffset:21}},noAlloc:!0}}:{vertexPositions:{size:3,vertexOffset:1,type:"float64",fp64:this.use64bitPositions(),transition:mb,accessor:"getPath",update:this.calculatePositions,noAlloc:!0,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}}},instanceTypes:{size:1,type:t?"float32":"uint8",update:this.calculateSegmentTypes,noAlloc:!0},instanceStrokeWidths:{size:1,accessor:"getWidth",transition:t?!1:mb,defaultValue:1,bufferGroup:"path-instance-data"},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",accessor:"getColor",transition:t?!1:mb,defaultValue:hL,bufferGroup:"path-instance-data"},rowIndexes:{size:1,type:"uint32",accessor:(r,{index:s})=>r&&r.__source?r.__source.index:s,bufferGroup:"path-instance-data"}}),this.setState({pathTesselator:new wl({fp64:this.use64bitPositions(),isWebGPU:t}),tessellationResolution:this.context.viewport.resolution,pathProjectionScale:this.getPathProjectionScale(this.context.viewport)})}updateState(e){super.updateState(e);let{props:t,oldProps:i,changeFlags:r}=e,s=this.getAttributeManager(),{viewport:o}=this.context,a=this.state.tessellationResolution!==o.resolution,c=this.getPathProjectionScale(o),l=!dL(this.state.pathProjectionScale,c),f=r.updateTriggersChanged&&(r.updateTriggersChanged.all||r.updateTriggersChanged.getPath)||t._pathType!==i._pathType||t.positionFormat!==i.positionFormat||t.wrapLongitude!==i.wrapLongitude||a;if(r.dataChanged||f){let{pathTesselator:h}=this.state,p=t.data.attributes||{};h.updateGeometry({data:t.data,geometryBuffer:p.getPath,buffers:p,normalize:!t._pathType,loop:t._pathType==="loop",getGeometry:t.getPath,positionFormat:t.positionFormat,wrapLongitude:t.wrapLongitude,resolution:o.resolution,dataChanged:f?void 0:r.dataChanged}),this.setState({numInstances:h.instanceCount,startIndices:h.vertexStarts,tessellationResolution:o.resolution,pathProjectionScale:c}),!r.dataChanged||f?s.invalidateAll():l&&s.invalidate("instanceDashOffsets")}else l&&(this.setState({pathProjectionScale:c}),s.invalidate("instanceDashOffsets"));(r.extensionsChanged||t.antialiasing!==i.antialiasing)&&(this.state.model?.destroy(),this.state.model=this._getModel(),s.invalidateAll())}getPickingInfo(e){let t=super.getPickingInfo(e),{index:i}=t,r=this.props.data;return r[0]&&r[0].__source&&(t.object=r.find(s=>s.__source.index===i)),t}disablePickingIndex(e){let t=this.props.data;if(t[0]&&t[0].__source)for(let i=0;i=0&&u=1&&n[0].length>=2&&Number.isFinite(n[0][0])}function KG(n){let e=n[0],t=n[n.length-1];return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function QG(n,e,t,i){for(let r=0;ra/e));let s=$o(n),o=i&&e===3;if(t){let a=s.length;s=s.slice();let c=[];for(let l=0;lc&&a>l||(c>l?(t||(s=s.slice()),wL(s,0,2,1)):(t||(s=s.slice()),wL(s,2,0,1)))}return(0,EL.default)(s,r,e)}var Ll=class extends ar{constructor(e){let{fp64:t,IndexType:i=Uint32Array}=e;super({...e,attributes:{positions:{size:3,type:t?Float64Array:Float32Array},vertexValid:{type:Uint16Array,size:1},indices:{type:i,size:1}}})}get(e){let{attributes:t}=this;return e==="indices"?t.indices&&t.indices.subarray(0,this.vertexCount):t[e]}updateGeometry(e){super.updateGeometry(e);let t=this.buffers.indices;if(t)this.vertexCount=(t.value||t).length;else if(this.data&&!this.getGeometry)throw new Error("missing indices buffer")}normalizeGeometry(e){if(this.normalize){let t=SL(e,this.positionSize);return this.opts.resolution?vl($o(t),Tl(t),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?pb($o(t),Tl(t),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):t}return e}getGeometrySize(e){if(CL(e)){let t=0;for(let i of e)t+=this.getGeometrySize(i);return t}return $o(e).length/this.positionSize}getGeometryFromBuffer(e){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(e):null}updateGeometryAttributes(e,t){if(e&&CL(e))for(let i of e){let r=this.getGeometrySize(i);t.geometrySize=r,this.updateGeometryAttributes(i,t),t.vertexStart+=r,t.indexStart=this.indexStarts[t.geometryIndex+1]}else{let i=e;this._updateIndices(i,t),this._updatePositions(i,t),this._updateVertexValid(i,t)}}_updateIndices(e,{geometryIndex:t,vertexStart:i,indexStart:r}){let{attributes:s,indexStarts:o,typedArrayManager:a}=this,c=s.indices;if(!c||!e)return;let l=r,u=PL(e,this.positionSize,this.opts.preproject,this.opts.full3d);c=a.allocate(c,r+u.length,{copy:!0});for(let f=0;f2?o[c*s+2]:0;r[a*3]=l,r[a*3+1]=u,r[a*3+2]=f}}_updateVertexValid(e,{vertexStart:t,geometrySize:i}){let{positionSize:r}=this,s=this.attributes.vertexValid,o=e&&Tl(e);if(e&&e.edgeTypes?s.set(e.edgeTypes,t):s.fill(1,t,t+i),o)for(let a=0;a0&&!Number.isFinite(n[0])}var eV=`struct SolidPolygonUniforms { extruded: f32, isWireframe: f32, elevationScale: f32, }; @group(0) @binding(auto) var solidPolygon: SolidPolygonUniforms; -`,CL=`layout(std140) uniform solidPolygonUniforms { +`,TL=`layout(std140) uniform solidPolygonUniforms { bool extruded; bool isWireframe; float elevationScale; } solidPolygon; -`,TL={name:"solidPolygon",source:KG,vs:CL,fs:CL,uniformTypes:{extruded:"f32",isWireframe:"f32",elevationScale:"f32"}};var ch=`in vec4 fillColors; +`,LL={name:"solidPolygon",source:eV,vs:TL,fs:TL,uniformTypes:{extruded:"f32",isWireframe:"f32",elevationScale:"f32"}};var lh=`in vec4 fillColors; in vec4 lineColors; in float rowIndexes; out vec4 vColor; @@ -6086,12 +6086,12 @@ vColor = vec4(colors.rgb, colors.a * layer.opacity); } DECKGL_FILTER_COLOR(vColor, geometry); } -`;var LL=`#version 300 es +`;var ML=`#version 300 es #define SHADER_NAME solid-polygon-layer-vertex-shader in vec3 vertexPositions; in vec3 vertexPositions64Low; in float elevations; -${ch} +${lh} void main(void) { PolygonProps props; props.positions = vertexPositions; @@ -6100,7 +6100,7 @@ props.elevations = elevations; props.normal = vec3(0.0, 0.0, 1.0); calculatePosition(props); } -`;var ML=`#version 300 es +`;var AL=`#version 300 es #define SHADER_NAME solid-polygon-layer-vertex-shader-side #define IS_SIDE_VERTEX in vec2 positions; @@ -6110,7 +6110,7 @@ in vec3 vertexPositions64Low; in vec3 nextVertexPositions64Low; in float elevations; in float instanceVertexValid; -${ch} +${lh} void main(void) { if(instanceVertexValid < 0.5){ gl_Position = vec4(0.); @@ -6141,7 +6141,7 @@ nextPos.x - pos.x + (nextPos64Low.x - pos64Low.x), props.elevations = elevations * positions.y; calculatePosition(props); } -`;var AL=`#version 300 es +`;var kL=`#version 300 es #define SHADER_NAME solid-polygon-layer-fragment-shader precision highp float; in vec4 vColor; @@ -6151,7 +6151,7 @@ fragColor = vColor; geometry.uv = vec2(0.); DECKGL_FILTER_COLOR(fragColor, geometry); } -`;function kL(){return`fn project_offset_normal(vector: vec3) -> vec3 { +`;function RL(){return`fn project_offset_normal(vector: vec3) -> vec3 { if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT || project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSETS) { return normalize(vector * project.commonUnitsPerWorldUnit); @@ -6175,7 +6175,7 @@ fn apply_polygon_color( } return vec4(colors.rgb, colors.a * layer.opacity); } -`}function RL(){return`@fragment +`}function IL(){return`@fragment fn fragmentMain(inp: Varyings) -> @location(0) vec4 { geometry.uv = vec2(0.0, 0.0); @@ -6209,7 +6209,7 @@ fn fragmentMain(inp: Varyings) -> @location(0) vec4 { return deckgl_premultiplied_alpha(fragColor); } -`}function QG(){return`${kL()} +`}function tV(){return`${RL()} struct Attributes { @location(0) vertexPositions: vec3, @@ -6264,10 +6264,10 @@ fn vertexMain(attributes: Attributes) -> Varyings { return outp; } -${RL()} -`}function JG(n){return`const RING_WINDING_ORDER_CW: bool = ${n?"true":"false"}; +${IL()} +`}function nV(n){return`const RING_WINDING_ORDER_CW: bool = ${n?"true":"false"}; -${kL()} +${RL()} struct Attributes { @location(0) positions: vec2, @@ -6354,35 +6354,35 @@ fn vertexMain(attributes: Attributes) -> Varyings { return outp; } -${RL()} -`}function IL(n,e){return n==="top"?QG():JG(e)}var uh=[0,0,0,255],eV={filled:!0,extruded:!1,wireframe:!1,_normalize:!0,_windingOrder:"CW",_full3d:!1,elevationScale:{type:"number",min:0,value:1},getPolygon:{type:"accessor",value:n=>n.polygon},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:uh},getLineColor:{type:"accessor",value:uh},material:!0},lh={enter:(n,e)=>e.length?e.subarray(e.length-n.length):n},Ll=class extends Ci{getShaders(e){let t=!this.props._normalize&&this.props._windingOrder==="CCW"?0:1;return super.getShaders({vs:e==="top"?LL:ML,fs:AL,source:IL(e,!!t),defines:{RING_WINDING_ORDER_CW:t},modules:[Gn,zn,eo,Wn,TL,...this.context.device.type==="webgpu"?[zo]:[]]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){let{viewport:e}=this.context,{coordinateSystem:t}=this.props,{_full3d:i}=this.props;e.isGeospatial&&t==="default"&&(t="lnglat");let r;t==="lnglat"&&(i?r=e.projectPosition.bind(e):r=e.projectFlat.bind(e)),this.setState({numInstances:0,polygonTesselator:new Tl({preproject:r,fp64:this.use64bitPositions(),IndexType:Uint32Array})});let s=this.getAttributeManager(),o=!0,a=this.context.device.type==="webgpu";s.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:o},vertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:lh,accessor:"getPolygon",update:this.calculatePositions,noAlloc:o,...a?{}:{shaderAttributes:{nextVertexPositions:{vertexOffset:1}}}},...a?{nextVertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:!1,update:this.calculateNextPositions,noAlloc:o}}:{},[a?"vertexValid":"instanceVertexValid"]:{size:1,type:a?"float32":"uint16",stepMode:"instance",update:this.calculateVertexValid,noAlloc:o},elevations:{size:1,stepMode:"dynamic",transition:lh,accessor:"getElevation",bufferGroup:"solid-polygon-instance-data"},fillColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:lh,accessor:"getFillColor",defaultValue:uh,bufferGroup:"solid-polygon-instance-data"},lineColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:lh,accessor:"getLineColor",defaultValue:uh,bufferGroup:"solid-polygon-instance-data"},rowIndexes:{size:1,type:"uint32",stepMode:"dynamic",accessor:(c,{index:l})=>c&&c.__source?c.__source.index:l,bufferGroup:"solid-polygon-instance-data"}})}getPickingInfo(e){let t=super.getPickingInfo(e),{index:i}=t,r=this.props.data;return r[0]&&r[0].__source&&(t.object=r.find(s=>s.__source.index===i)),t}disablePickingIndex(e){let t=this.props.data;if(t[0]&&t[0].__source)for(let i=0;ia.destroy()),this.setState(this._getModels()),s.invalidateAll())}updateGeometry({props:e,oldProps:t,changeFlags:i}){if(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getPolygon)){let{polygonTesselator:s}=this.state,o=e.data.attributes||{};s.updateGeometry({data:e.data,normalize:e._normalize,geometryBuffer:o.getPolygon,buffers:this.context.device.type==="webgpu"?{...o}:o,getGeometry:e.getPolygon,positionFormat:e.positionFormat,wrapLongitude:e.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:i.dataChanged,full3d:e._full3d}),this.setState({numInstances:s.instanceCount,startIndices:s.vertexStarts}),i.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(){let{id:e,filled:t,extruded:i}=this.props,r,s,o;if(t){let a=this.getShaders("top");a.defines={...a.defines,NON_INSTANCED_MODEL:1};let c=this.getAttributeManager().getBufferLayouts({isInstanced:!1});this.context.device.type==="webgpu"&&(c=c.filter(l=>l.name!=="indices"&&l.name!=="vertexValid"&&l.name!=="instanceVertexValid"&&l.name!=="nextVertexPositions")),r=new Ze(this.context.device,{...a,id:`${e}-top`,topology:"triangle-list",bufferLayout:c,isIndexed:!0,userData:{excludeAttributes:{vertexValid:!0,instanceVertexValid:!0,nextVertexPositions:!0}}})}if(i){let a=this.getAttributeManager().getBufferLayouts({isInstanced:!0});this.context.device.type==="webgpu"&&(a=a.filter(c=>c.name!=="indices")),s=new Ze(this.context.device,{...this.getShaders("side"),id:`${e}-side`,bufferLayout:a,geometry:new Kt({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,1,1,0,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}}),o=new Ze(this.context.device,{...this.getShaders("side"),id:`${e}-wireframe`,bufferLayout:a,geometry:new Kt({topology:"line-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,0,1,1,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}})}return{models:[s,o,r].filter(Boolean),topModel:r,sideModel:s,wireframeModel:o}}calculateIndices(e){let{polygonTesselator:t}=this.state;e.startIndices=t.indexStarts,e.value=t.get("indices")}calculatePositions(e){let{polygonTesselator:t}=this.state;e.startIndices=t.vertexStarts;let i=this.props.data.attributes?.getPolygon;if(this.context.device.type==="webgpu"&&ArrayBuffer.isView(i?.value)){let{value:r,size:s=3,offset:o=0,stride:a}=i,c=o/r.BYTES_PER_ELEMENT,l=a?a/r.BYTES_PER_ELEMENT:s,u=new Float64Array(t.instanceCount*3);for(let f=0;f2?r[d+2]:0}e.value=u;return}e.value=t.get("positions")}calculateVertexValid(e){let t=this.props.data.attributes?.instanceVertexValid?.value,i=this.context.device.type==="webgpu"&&t?t:this.state.polygonTesselator.get("vertexValid");e.value=this.context.device.type==="webgpu"&&i?Float32Array.from(i):i}calculateNextPositions(e){let{polygonTesselator:t}=this.state,i=this.getAttributeManager().getAttributes(),r=i.vertexPositions.value,s=this.props.data.attributes?.instanceVertexValid?.value||i.vertexValid?.value||t.get("vertexValid");if(e.startIndices=t.vertexStarts,!r){e.value=r;return}let o=r.length/3,a=new r.constructor(r.length);for(let c=0;cnew dh(typeof n=="string"?n:n+"",void 0,OL);var NL=(n,e)=>{if(hh)n.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(let t of e){let i=document.createElement("style"),r=fh.litNonce;r!==void 0&&i.setAttribute("nonce",r),i.textContent=t.cssText,n.appendChild(i)}},wb=hh?n=>n:n=>n instanceof CSSStyleSheet?(e=>{let t="";for(let i of e.cssRules)t+=i.cssText;return DL(t)})(n):n;var{is:tV,defineProperty:nV,getOwnPropertyDescriptor:iV,getOwnPropertyNames:rV,getOwnPropertySymbols:sV,getPrototypeOf:oV}=Object,ph=globalThis,FL=ph.trustedTypes,aV=FL?FL.emptyScript:"",cV=ph.reactiveElementPolyfillSupport,Ml=(n,e)=>n,Eb={toAttribute(n,e){switch(e){case Boolean:n=n?aV:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,e){let t=n;switch(e){case Boolean:t=n!==null;break;case Number:t=n===null?null:Number(n);break;case Object:case Array:try{t=JSON.parse(n)}catch{t=null}}return t}},UL=(n,e)=>!tV(n,e),zL={attribute:!0,type:String,converter:Eb,reflect:!1,useDefault:!1,hasChanged:UL};Symbol.metadata??=Symbol("metadata"),ph.litPropertyMetadata??=new WeakMap;var Ti=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=zL){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let i=Symbol(),r=this.getPropertyDescriptor(e,i,t);r!==void 0&&nV(this.prototype,e,r)}}static getPropertyDescriptor(e,t,i){let{get:r,set:s}=iV(this.prototype,e)??{get(){return this[t]},set(o){this[t]=o}};return{get:r,set(o){let a=r?.call(this);s?.call(this,o),this.requestUpdate(e,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??zL}static _$Ei(){if(this.hasOwnProperty(Ml("elementProperties")))return;let e=oV(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Ml("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Ml("properties"))){let t=this.properties,i=[...rV(t),...sV(t)];for(let r of i)this.createProperty(r,t[r])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[i,r]of t)this.elementProperties.set(i,r)}this._$Eh=new Map;for(let[t,i]of this.elementProperties){let r=this._$Eu(t,i);r!==void 0&&this._$Eh.set(r,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let i=new Set(e.flat(1/0).reverse());for(let r of i)t.unshift(wb(r))}else e!==void 0&&t.push(wb(e));return t}static _$Eu(e,t){let i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return NL(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$ET(e,t){let i=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,i);if(r!==void 0&&i.reflect===!0){let s=(i.converter?.toAttribute!==void 0?i.converter:Eb).toAttribute(t,i.type);this._$Em=e,s==null?this.removeAttribute(r):this.setAttribute(r,s),this._$Em=null}}_$AK(e,t){let i=this.constructor,r=i._$Eh.get(e);if(r!==void 0&&this._$Em!==r){let s=i.getPropertyOptions(r),o=typeof s.converter=="function"?{fromAttribute:s.converter}:s.converter?.fromAttribute!==void 0?s.converter:Eb;this._$Em=r;let a=o.fromAttribute(t,s.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(e,t,i,r=!1,s){if(e!==void 0){let o=this.constructor;if(r===!1&&(s=this[e]),i??=o.getPropertyOptions(e),!((i.hasChanged??UL)(s,t)||i.useDefault&&i.reflect&&s===this._$Ej?.get(e)&&!this.hasAttribute(o._$Eu(e,i))))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:i,reflect:r,wrapped:s},o){i&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,o??t??this[e]),s!==!0||o!==void 0)||(this._$AL.has(e)||(this.hasUpdated||i||(t=void 0),this._$AL.set(e,t)),r===!0&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[r,s]of this._$Ep)this[r]=s;this._$Ep=void 0}let i=this.constructor.elementProperties;if(i.size>0)for(let[r,s]of i){let{wrapped:o}=s,a=this[r];o!==!0||this._$AL.has(r)||a===void 0||this.C(r,void 0,s,a)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(i=>i.hostUpdate?.()),this.update(t)):this._$EM()}catch(i){throw e=!1,this._$EM(),i}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(e){}firstUpdated(e){}};Ti.elementStyles=[],Ti.shadowRootOptions={mode:"open"},Ti[Ml("elementProperties")]=new Map,Ti[Ml("finalized")]=new Map,cV?.({ReactiveElement:Ti}),(ph.reactiveElementVersions??=[]).push("2.1.2");var Pb=globalThis,$L=n=>n,mh=Pb.trustedTypes,GL=mh?mh.createPolicy("lit-html",{createHTML:n=>n}):void 0,Cb="$lit$",Li=`lit$${Math.random().toFixed(9).slice(2)}$`,Tb="?"+Li,lV=`<${Tb}>`,ps=document,kl=()=>ps.createComment(""),Rl=n=>n===null||typeof n!="object"&&typeof n!="function",Lb=Array.isArray,qL=n=>Lb(n)||typeof n?.[Symbol.iterator]=="function",Sb=`[ -\f\r]`,Al=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,VL=/-->/g,WL=/>/g,ds=RegExp(`>|${Sb}(?:([^\\s"'>=/]+)(${Sb}*=${Sb}*(?:[^ -\f\r"'\`<>=]|("|')|))|$)`,"g"),jL=/'/g,HL=/"/g,ZL=/^(?:script|style|textarea|title)$/i,Mb=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),ys=Mb(1),Dye=Mb(2),Nye=Mb(3),ms=Symbol.for("lit-noChange"),Le=Symbol.for("lit-nothing"),YL=new WeakMap,hs=ps.createTreeWalker(ps,129);function XL(n,e){if(!Lb(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return GL!==void 0?GL.createHTML(e):e}var KL=(n,e)=>{let t=n.length-1,i=[],r,s=e===2?"":e===3?"":"",o=Al;for(let a=0;a"?(o=r??Al,f=-1):u[1]===void 0?f=-2:(f=o.lastIndex-u[2].length,l=u[1],o=u[3]===void 0?ds:u[3]==='"'?HL:jL):o===HL||o===jL?o=ds:o===VL||o===WL?o=Al:(o=ds,r=void 0);let h=o===ds&&n[a+1].startsWith("/>")?" ":"";s+=o===Al?c+lV:f>=0?(i.push(l),c.slice(0,f)+Cb+c.slice(f)+Li+h):c+Li+(f===-2?a:h)}return[XL(n,s+(n[t]||"")+(e===2?"":e===3?"":"")),i]},Il=class n{constructor({strings:e,_$litType$:t},i){let r;this.parts=[];let s=0,o=0,a=e.length-1,c=this.parts,[l,u]=KL(e,t);if(this.el=n.createElement(l,i),hs.currentNode=this.el.content,t===2||t===3){let f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(r=hs.nextNode())!==null&&c.length0){r.textContent=mh?mh.emptyScript:"";for(let h=0;h2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Le}_$AI(e,t=this,i,r){let s=this.strings,o=!1;if(s===void 0)e=gs(this,e,t,0),o=!Rl(e)||e!==this._$AH&&e!==ms,o&&(this._$AH=e);else{let a=e,c,l;for(e=s[0],c=0;c{let i=t?.renderBefore??e,r=i._$litPart$;if(r===void 0){let s=t?.renderBefore??null;i._$litPart$=r=new Go(e.insertBefore(kl(),s),s,void 0,t??{})}return r._$AI(n),r};var Ab=globalThis,ni=class extends Ti{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=JL(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return ms}};ni._$litElement$=!0,ni.finalized=!0,Ab.litElementHydrateSupport?.({LitElement:ni});var fV=Ab.litElementPolyfillSupport;fV?.({LitElement:ni});(Ab.litElementVersions??=[]).push("4.2.2");var{I:Kye}=QL;var e3=n=>n.strings===void 0;var t3={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},kb=n=>(...e)=>({_$litDirective$:n,values:e}),xh=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}};var Bl=(n,e)=>{let t=n._$AN;if(t===void 0)return!1;for(let i of t)i._$AO?.(e,!1),Bl(i,e);return!0},wh=n=>{let e,t;do{if((e=n._$AM)===void 0)break;t=e._$AN,t.delete(n),n=e}while(t?.size===0)},n3=n=>{for(let e;e=n._$AM;n=e){let t=e._$AN;if(t===void 0)e._$AN=t=new Set;else if(t.has(n))break;t.add(n),pV(e)}};function dV(n){this._$AN!==void 0?(wh(this),this._$AM=n,n3(this)):this._$AM=n}function hV(n,e=!1,t=0){let i=this._$AH,r=this._$AN;if(r!==void 0&&r.size!==0)if(e)if(Array.isArray(i))for(let s=t;s{n.type==t3.CHILD&&(n._$AP??=hV,n._$AQ??=dV)},Eh=class extends xh{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,i){super._$AT(e,t,i),n3(this),this.isConnected=e._$AU}_$AO(e,t=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),t&&(Bl(this,e),wh(this))}setValue(e){if(e3(this._$Ct))this._$Ct._$AI(e,this);else{let t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}};var Mi=()=>new Ib,Ib=class{},Rb=new WeakMap,Ai=kb(class extends Eh{render(n){return Le}update(n,[e]){let t=e!==this.G;return t&&this.rt(void 0),(t||this.lt!==this.ct)&&(this.G=e,this.ht=n.options?.host,this.rt(this.ct=n.element)),Le}rt(n){if(this.G!==void 0)if(this.isConnected||(n=void 0),typeof this.G=="function"){let e=this.ht??globalThis,t=Rb.get(e);t===void 0&&(t=new WeakMap,Rb.set(e,t)),t.get(this.G)!==void 0&&this.G.call(this.ht,void 0),t.set(this.G,n),n!==void 0&&this.G.call(this.ht,n)}else this.G.value=n}get lt(){return typeof this.G=="function"?Rb.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});function Ol(n,e,t){return n?e(n):t?.(n)}var Bb=n=>n??Le;var Ob=class extends ni{static properties={name:{type:String,reflect:!0},maximizable:{type:Boolean,reflect:!0},collapsible:{type:Boolean,reflect:!0},maximized:{type:Boolean,reflect:!0},collapsed:{type:Boolean,reflect:!0}};constructor(){super(),this.tabsRef=Mi(),this.contentRef=Mi(),this.headerRef=Mi(),this.controlsRef=Mi(),this.maximizeBtnRef=Mi(),this.collapseBtnRef=Mi(),this._onMaximizeClick=this._onMaximizeClick.bind(this),this._onCollapseClick=this._onCollapseClick.bind(this),this._onResetLayoutClick=this._onResetLayoutClick.bind(this)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.classList.add("ide-pane",`ide-pane-${this.paneName}`),this.performUpdate()}get paneName(){return this.name||this.getAttribute("name")||this.id.replace(/^pane-/,"")||"pane"}get tabsEl(){return this.hasUpdated||this.performUpdate(),this.tabsRef.value}get contentEl(){return this.hasUpdated||this.performUpdate(),this.contentRef.value}get headerEl(){return this.hasUpdated||this.performUpdate(),this.headerRef.value}get controlsEl(){return this.hasUpdated||this.performUpdate(),this.controlsRef.value}get maximizeBtn(){return this.hasUpdated||this.performUpdate(),this.maximizeBtnRef.value}get collapseBtn(){return this.hasUpdated||this.performUpdate(),this.collapseBtnRef.value}get _collapseIcon(){let e=this.paneName;return e==="bottom"?this.collapsed?"\u25B2":"\u25BC":e==="left"?this.collapsed?"\u25B6":"\u25C0":e==="right"?this.collapsed?"\u25C0":"\u25B6":"\u25BC"}get _collapseTitle(){let e=this.paneName,t=e.charAt(0).toUpperCase()+e.slice(1);return e==="bottom"?this.collapsed?"Expand Console":"Collapse Console":e==="left"?this.collapsed?"Expand Left Panel":"Collapse Left Panel":e==="right"?this.collapsed?"Expand Right Panel":"Collapse Right Panel":`Collapse ${t}`}_emit(e,t={}){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}_onMaximizeClick(e){e.stopPropagation(),this._emit("ide-pane-maximize",{pane:this.paneName})}_onCollapseClick(e){e.stopPropagation(),this._emit("ide-pane-collapse",{pane:this.paneName})}_onResetLayoutClick(e){e.stopPropagation(),this._emit("ide-layout-reset")}setMaximized(e){this.maximized=!!e,this.classList.toggle("maximized",this.maximized),this.maximizeBtn&&(this.maximizeBtn.textContent=this.maximized?"\u29C9":"\u2922",this.maximizeBtn.title=this.maximized?"Restore":"Maximize")}setCollapsed(e){this.collapsed=!!e,this.classList.toggle("collapsed",this.collapsed),this.collapseBtn&&(this.collapseBtn.textContent=this._collapseIcon,this.collapseBtn.title=this._collapseTitle)}build(){this.hasUpdated||this.performUpdate()}updated(e){super.updated(e),e.has("maximized")&&this.classList.toggle("maximized",!!this.maximized),e.has("collapsed")&&this.classList.toggle("collapsed",!!this.collapsed)}render(){let e=this.paneName,t=this.id||`pane-${e}`,i=this.maximizable||this.hasAttribute("maximizable"),r=this.collapsible||this.hasAttribute("collapsible");return ys` -
-
-
- ${Ol(i,()=>ys` +${IL()} +`}function BL(n,e){return n==="top"?tV():nV(e)}var fh=[0,0,0,255],iV={filled:!0,extruded:!1,wireframe:!1,_normalize:!0,_windingOrder:"CW",_full3d:!1,elevationScale:{type:"number",min:0,value:1},getPolygon:{type:"accessor",value:n=>n.polygon},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:fh},getLineColor:{type:"accessor",value:fh},material:!0},uh={enter:(n,e)=>e.length?e.subarray(e.length-n.length):n},Ml=class extends ki{getShaders(e){let t=!this.props._normalize&&this.props._windingOrder==="CCW"?0:1;return super.getShaders({vs:e==="top"?ML:AL,fs:kL,source:BL(e,!!t),defines:{RING_WINDING_ORDER_CW:t},modules:[Hn,Vn,eo,qn,LL,...this.context.device.type==="webgpu"?[zo]:[]]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){let{viewport:e}=this.context,{coordinateSystem:t}=this.props,{_full3d:i}=this.props;e.isGeospatial&&t==="default"&&(t="lnglat");let r;t==="lnglat"&&(i?r=e.projectPosition.bind(e):r=e.projectFlat.bind(e)),this.setState({numInstances:0,polygonTesselator:new Ll({preproject:r,fp64:this.use64bitPositions(),IndexType:Uint32Array})});let s=this.getAttributeManager(),o=!0,a=this.context.device.type==="webgpu";s.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:o},vertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:uh,accessor:"getPolygon",update:this.calculatePositions,noAlloc:o,...a?{}:{shaderAttributes:{nextVertexPositions:{vertexOffset:1}}}},...a?{nextVertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:!1,update:this.calculateNextPositions,noAlloc:o}}:{},[a?"vertexValid":"instanceVertexValid"]:{size:1,type:a?"float32":"uint16",stepMode:"instance",update:this.calculateVertexValid,noAlloc:o},elevations:{size:1,stepMode:"dynamic",transition:uh,accessor:"getElevation",bufferGroup:"solid-polygon-instance-data"},fillColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:uh,accessor:"getFillColor",defaultValue:fh,bufferGroup:"solid-polygon-instance-data"},lineColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:uh,accessor:"getLineColor",defaultValue:fh,bufferGroup:"solid-polygon-instance-data"},rowIndexes:{size:1,type:"uint32",stepMode:"dynamic",accessor:(c,{index:l})=>c&&c.__source?c.__source.index:l,bufferGroup:"solid-polygon-instance-data"}})}getPickingInfo(e){let t=super.getPickingInfo(e),{index:i}=t,r=this.props.data;return r[0]&&r[0].__source&&(t.object=r.find(s=>s.__source.index===i)),t}disablePickingIndex(e){let t=this.props.data;if(t[0]&&t[0].__source)for(let i=0;ia.destroy()),this.setState(this._getModels()),s.invalidateAll())}updateGeometry({props:e,oldProps:t,changeFlags:i}){if(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getPolygon)){let{polygonTesselator:s}=this.state,o=e.data.attributes||{};s.updateGeometry({data:e.data,normalize:e._normalize,geometryBuffer:o.getPolygon,buffers:this.context.device.type==="webgpu"?{...o}:o,getGeometry:e.getPolygon,positionFormat:e.positionFormat,wrapLongitude:e.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:i.dataChanged,full3d:e._full3d}),this.setState({numInstances:s.instanceCount,startIndices:s.vertexStarts}),i.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(){let{id:e,filled:t,extruded:i}=this.props,r,s,o;if(t){let a=this.getShaders("top");a.defines={...a.defines,NON_INSTANCED_MODEL:1};let c=this.getAttributeManager().getBufferLayouts({isInstanced:!1});this.context.device.type==="webgpu"&&(c=c.filter(l=>l.name!=="indices"&&l.name!=="vertexValid"&&l.name!=="instanceVertexValid"&&l.name!=="nextVertexPositions")),r=new Ze(this.context.device,{...a,id:`${e}-top`,topology:"triangle-list",bufferLayout:c,isIndexed:!0,userData:{excludeAttributes:{vertexValid:!0,instanceVertexValid:!0,nextVertexPositions:!0}}})}if(i){let a=this.getAttributeManager().getBufferLayouts({isInstanced:!0});this.context.device.type==="webgpu"&&(a=a.filter(c=>c.name!=="indices")),s=new Ze(this.context.device,{...this.getShaders("side"),id:`${e}-side`,bufferLayout:a,geometry:new tn({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,1,1,0,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}}),o=new Ze(this.context.device,{...this.getShaders("side"),id:`${e}-wireframe`,bufferLayout:a,geometry:new tn({topology:"line-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,0,1,1,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}})}return{models:[s,o,r].filter(Boolean),topModel:r,sideModel:s,wireframeModel:o}}calculateIndices(e){let{polygonTesselator:t}=this.state;e.startIndices=t.indexStarts,e.value=t.get("indices")}calculatePositions(e){let{polygonTesselator:t}=this.state;e.startIndices=t.vertexStarts;let i=this.props.data.attributes?.getPolygon;if(this.context.device.type==="webgpu"&&ArrayBuffer.isView(i?.value)){let{value:r,size:s=3,offset:o=0,stride:a}=i,c=o/r.BYTES_PER_ELEMENT,l=a?a/r.BYTES_PER_ELEMENT:s,u=new Float64Array(t.instanceCount*3);for(let f=0;f2?r[d+2]:0}e.value=u;return}e.value=t.get("positions")}calculateVertexValid(e){let t=this.props.data.attributes?.instanceVertexValid?.value,i=this.context.device.type==="webgpu"&&t?t:this.state.polygonTesselator.get("vertexValid");e.value=this.context.device.type==="webgpu"&&i?Float32Array.from(i):i}calculateNextPositions(e){let{polygonTesselator:t}=this.state,i=this.getAttributeManager().getAttributes(),r=i.vertexPositions.value,s=this.props.data.attributes?.instanceVertexValid?.value||i.vertexValid?.value||t.get("vertexValid");if(e.startIndices=t.vertexStarts,!r){e.value=r;return}let o=r.length/3,a=new r.constructor(r.length);for(let c=0;cnew hh(typeof n=="string"?n:n+"",void 0,DL);var FL=(n,e)=>{if(ph)n.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(let t of e){let i=document.createElement("style"),r=dh.litNonce;r!==void 0&&i.setAttribute("nonce",r),i.textContent=t.cssText,n.appendChild(i)}},Eb=ph?n=>n:n=>n instanceof CSSStyleSheet?(e=>{let t="";for(let i of e.cssRules)t+=i.cssText;return NL(t)})(n):n;var{is:rV,defineProperty:sV,getOwnPropertyDescriptor:oV,getOwnPropertyNames:aV,getOwnPropertySymbols:cV,getPrototypeOf:lV}=Object,mh=globalThis,zL=mh.trustedTypes,uV=zL?zL.emptyScript:"",fV=mh.reactiveElementPolyfillSupport,Al=(n,e)=>n,Sb={toAttribute(n,e){switch(e){case Boolean:n=n?uV:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,e){let t=n;switch(e){case Boolean:t=n!==null;break;case Number:t=n===null?null:Number(n);break;case Object:case Array:try{t=JSON.parse(n)}catch{t=null}}return t}},$L=(n,e)=>!rV(n,e),UL={attribute:!0,type:String,converter:Sb,reflect:!1,useDefault:!1,hasChanged:$L};Symbol.metadata??=Symbol("metadata"),mh.litPropertyMetadata??=new WeakMap;var Ri=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=UL){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let i=Symbol(),r=this.getPropertyDescriptor(e,i,t);r!==void 0&&sV(this.prototype,e,r)}}static getPropertyDescriptor(e,t,i){let{get:r,set:s}=oV(this.prototype,e)??{get(){return this[t]},set(o){this[t]=o}};return{get:r,set(o){let a=r?.call(this);s?.call(this,o),this.requestUpdate(e,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??UL}static _$Ei(){if(this.hasOwnProperty(Al("elementProperties")))return;let e=lV(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Al("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Al("properties"))){let t=this.properties,i=[...aV(t),...cV(t)];for(let r of i)this.createProperty(r,t[r])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[i,r]of t)this.elementProperties.set(i,r)}this._$Eh=new Map;for(let[t,i]of this.elementProperties){let r=this._$Eu(t,i);r!==void 0&&this._$Eh.set(r,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let i=new Set(e.flat(1/0).reverse());for(let r of i)t.unshift(Eb(r))}else e!==void 0&&t.push(Eb(e));return t}static _$Eu(e,t){let i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return FL(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$ET(e,t){let i=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,i);if(r!==void 0&&i.reflect===!0){let s=(i.converter?.toAttribute!==void 0?i.converter:Sb).toAttribute(t,i.type);this._$Em=e,s==null?this.removeAttribute(r):this.setAttribute(r,s),this._$Em=null}}_$AK(e,t){let i=this.constructor,r=i._$Eh.get(e);if(r!==void 0&&this._$Em!==r){let s=i.getPropertyOptions(r),o=typeof s.converter=="function"?{fromAttribute:s.converter}:s.converter?.fromAttribute!==void 0?s.converter:Sb;this._$Em=r;let a=o.fromAttribute(t,s.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(e,t,i,r=!1,s){if(e!==void 0){let o=this.constructor;if(r===!1&&(s=this[e]),i??=o.getPropertyOptions(e),!((i.hasChanged??$L)(s,t)||i.useDefault&&i.reflect&&s===this._$Ej?.get(e)&&!this.hasAttribute(o._$Eu(e,i))))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:i,reflect:r,wrapped:s},o){i&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,o??t??this[e]),s!==!0||o!==void 0)||(this._$AL.has(e)||(this.hasUpdated||i||(t=void 0),this._$AL.set(e,t)),r===!0&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[r,s]of this._$Ep)this[r]=s;this._$Ep=void 0}let i=this.constructor.elementProperties;if(i.size>0)for(let[r,s]of i){let{wrapped:o}=s,a=this[r];o!==!0||this._$AL.has(r)||a===void 0||this.C(r,void 0,s,a)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(i=>i.hostUpdate?.()),this.update(t)):this._$EM()}catch(i){throw e=!1,this._$EM(),i}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(e){}firstUpdated(e){}};Ri.elementStyles=[],Ri.shadowRootOptions={mode:"open"},Ri[Al("elementProperties")]=new Map,Ri[Al("finalized")]=new Map,fV?.({ReactiveElement:Ri}),(mh.reactiveElementVersions??=[]).push("2.1.2");var Cb=globalThis,GL=n=>n,gh=Cb.trustedTypes,VL=gh?gh.createPolicy("lit-html",{createHTML:n=>n}):void 0,Tb="$lit$",Ii=`lit$${Math.random().toFixed(9).slice(2)}$`,Lb="?"+Ii,dV=`<${Lb}>`,ps=document,Rl=()=>ps.createComment(""),Il=n=>n===null||typeof n!="object"&&typeof n!="function",Mb=Array.isArray,ZL=n=>Mb(n)||typeof n?.[Symbol.iterator]=="function",Pb=`[ +\f\r]`,kl=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,WL=/-->/g,jL=/>/g,ds=RegExp(`>|${Pb}(?:([^\\s"'>=/]+)(${Pb}*=${Pb}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`,"g"),HL=/'/g,YL=/"/g,XL=/^(?:script|style|textarea|title)$/i,Ab=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),ys=Ab(1),$ye=Ab(2),Gye=Ab(3),ms=Symbol.for("lit-noChange"),ke=Symbol.for("lit-nothing"),qL=new WeakMap,hs=ps.createTreeWalker(ps,129);function KL(n,e){if(!Mb(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return VL!==void 0?VL.createHTML(e):e}var QL=(n,e)=>{let t=n.length-1,i=[],r,s=e===2?"":e===3?"":"",o=kl;for(let a=0;a"?(o=r??kl,f=-1):u[1]===void 0?f=-2:(f=o.lastIndex-u[2].length,l=u[1],o=u[3]===void 0?ds:u[3]==='"'?YL:HL):o===YL||o===HL?o=ds:o===WL||o===jL?o=kl:(o=ds,r=void 0);let h=o===ds&&n[a+1].startsWith("/>")?" ":"";s+=o===kl?c+dV:f>=0?(i.push(l),c.slice(0,f)+Tb+c.slice(f)+Ii+h):c+Ii+(f===-2?a:h)}return[KL(n,s+(n[t]||"")+(e===2?"":e===3?"":"")),i]},Bl=class n{constructor({strings:e,_$litType$:t},i){let r;this.parts=[];let s=0,o=0,a=e.length-1,c=this.parts,[l,u]=QL(e,t);if(this.el=n.createElement(l,i),hs.currentNode=this.el.content,t===2||t===3){let f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(r=hs.nextNode())!==null&&c.length0){r.textContent=gh?gh.emptyScript:"";for(let h=0;h2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=ke}_$AI(e,t=this,i,r){let s=this.strings,o=!1;if(s===void 0)e=gs(this,e,t,0),o=!Il(e)||e!==this._$AH&&e!==ms,o&&(this._$AH=e);else{let a=e,c,l;for(e=s[0],c=0;c{let i=t?.renderBefore??e,r=i._$litPart$;if(r===void 0){let s=t?.renderBefore??null;i._$litPart$=r=new Go(e.insertBefore(Rl(),s),s,void 0,t??{})}return r._$AI(n),r};var kb=globalThis,oi=class extends Ri{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=e3(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return ms}};oi._$litElement$=!0,oi.finalized=!0,kb.litElementHydrateSupport?.({LitElement:oi});var pV=kb.litElementPolyfillSupport;pV?.({LitElement:oi});(kb.litElementVersions??=[]).push("4.2.2");var{I:nbe}=JL;var t3=n=>n.strings===void 0;var n3={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Rb=n=>(...e)=>({_$litDirective$:n,values:e}),wh=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}};var Ol=(n,e)=>{let t=n._$AN;if(t===void 0)return!1;for(let i of t)i._$AO?.(e,!1),Ol(i,e);return!0},Eh=n=>{let e,t;do{if((e=n._$AM)===void 0)break;t=e._$AN,t.delete(n),n=e}while(t?.size===0)},i3=n=>{for(let e;e=n._$AM;n=e){let t=e._$AN;if(t===void 0)e._$AN=t=new Set;else if(t.has(n))break;t.add(n),_V(e)}};function mV(n){this._$AN!==void 0?(Eh(this),this._$AM=n,i3(this)):this._$AM=n}function gV(n,e=!1,t=0){let i=this._$AH,r=this._$AN;if(r!==void 0&&r.size!==0)if(e)if(Array.isArray(i))for(let s=t;s{n.type==n3.CHILD&&(n._$AP??=gV,n._$AQ??=mV)},Sh=class extends wh{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,i){super._$AT(e,t,i),i3(this),this.isConnected=e._$AU}_$AO(e,t=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),t&&(Ol(this,e),Eh(this))}setValue(e){if(t3(this._$Ct))this._$Ct._$AI(e,this);else{let t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}};var Bi=()=>new Bb,Bb=class{},Ib=new WeakMap,Oi=Rb(class extends Sh{render(n){return ke}update(n,[e]){let t=e!==this.G;return t&&this.rt(void 0),(t||this.lt!==this.ct)&&(this.G=e,this.ht=n.options?.host,this.rt(this.ct=n.element)),ke}rt(n){if(this.G!==void 0)if(this.isConnected||(n=void 0),typeof this.G=="function"){let e=this.ht??globalThis,t=Ib.get(e);t===void 0&&(t=new WeakMap,Ib.set(e,t)),t.get(this.G)!==void 0&&this.G.call(this.ht,void 0),t.set(this.G,n),n!==void 0&&this.G.call(this.ht,n)}else this.G.value=n}get lt(){return typeof this.G=="function"?Ib.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});function Dl(n,e,t){return n?e(n):t?.(n)}var Ob=n=>n??ke;var Db=class extends oi{static properties={name:{type:String,reflect:!0},maximizable:{type:Boolean,reflect:!0},collapsible:{type:Boolean,reflect:!0},maximized:{type:Boolean,reflect:!0},collapsed:{type:Boolean,reflect:!0}};constructor(){super(),this.tabsRef=Bi(),this.contentRef=Bi(),this.headerRef=Bi(),this.controlsRef=Bi(),this.maximizeBtnRef=Bi(),this.collapseBtnRef=Bi(),this._onMaximizeClick=this._onMaximizeClick.bind(this),this._onCollapseClick=this._onCollapseClick.bind(this),this._onResetLayoutClick=this._onResetLayoutClick.bind(this)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.classList.add("ide-pane",`ide-pane-${this.paneName}`),this.performUpdate()}get paneName(){return this.name||this.getAttribute("name")||this.id.replace(/^pane-/,"")||"pane"}get tabsEl(){return this.hasUpdated||this.performUpdate(),this.tabsRef.value}get contentEl(){return this.hasUpdated||this.performUpdate(),this.contentRef.value}get headerEl(){return this.hasUpdated||this.performUpdate(),this.headerRef.value}get controlsEl(){return this.hasUpdated||this.performUpdate(),this.controlsRef.value}get maximizeBtn(){return this.hasUpdated||this.performUpdate(),this.maximizeBtnRef.value}get collapseBtn(){return this.hasUpdated||this.performUpdate(),this.collapseBtnRef.value}get _collapseIcon(){let e=this.paneName;return e==="bottom"?this.collapsed?"\u25B2":"\u25BC":e==="left"?this.collapsed?"\u25B6":"\u25C0":e==="right"?this.collapsed?"\u25C0":"\u25B6":"\u25BC"}get _collapseTitle(){let e=this.paneName,t=e.charAt(0).toUpperCase()+e.slice(1);return e==="bottom"?this.collapsed?"Expand Console":"Collapse Console":e==="left"?this.collapsed?"Expand Left Panel":"Collapse Left Panel":e==="right"?this.collapsed?"Expand Right Panel":"Collapse Right Panel":`Collapse ${t}`}_emit(e,t={}){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}_onMaximizeClick(e){e.stopPropagation(),this._emit("ide-pane-maximize",{pane:this.paneName})}_onCollapseClick(e){e.stopPropagation(),this._emit("ide-pane-collapse",{pane:this.paneName})}_onResetLayoutClick(e){e.stopPropagation(),this._emit("ide-layout-reset")}setMaximized(e){this.maximized=!!e,this.classList.toggle("maximized",this.maximized),this.maximizeBtn&&(this.maximizeBtn.textContent=this.maximized?"\u29C9":"\u2922",this.maximizeBtn.title=this.maximized?"Restore":"Maximize")}setCollapsed(e){this.collapsed=!!e,this.classList.toggle("collapsed",this.collapsed),this.collapseBtn&&(this.collapseBtn.textContent=this._collapseIcon,this.collapseBtn.title=this._collapseTitle)}build(){this.hasUpdated||this.performUpdate()}updated(e){super.updated(e),e.has("maximized")&&this.classList.toggle("maximized",!!this.maximized),e.has("collapsed")&&this.classList.toggle("collapsed",!!this.collapsed)}render(){let e=this.paneName,t=this.id||`pane-${e}`,i=this.maximizable||this.hasAttribute("maximizable"),r=this.collapsible||this.hasAttribute("collapsible");return ys` +
+
+
+ ${Dl(i,()=>ys` `)} - ${Ol(r,()=>ys` + ${Dl(r,()=>ys` `)}
-
- ${Ol(e==="main",()=>ys` +
+ ${Dl(e==="main",()=>ys` `)}
- `}},Db=class{constructor(e,t={}){(this.host=e).addController(this),this.options=t,this._abort=null,this.isDragging=!1,this.startPos=0}hostDisconnected(){this.stop()}start(e,t=!0){e.preventDefault();try{this.host.setPointerCapture(e.pointerId)}catch{}this.isDragging=!0,this.host.classList.add("dragging"),document.body&&document.body.classList.add("is-resizing",t?"is-resizing-v":"is-resizing-h"),this.startPos=t?e.clientX:e.clientY,this.options.onStart?.({startPos:this.startPos,event:e}),this._abort=new AbortController;let{signal:i}=this._abort;window.addEventListener("pointermove",s=>{let o=t?s.clientX:s.clientY,a=o-this.startPos;this.options.onDrag?.({delta:a,currentPos:o,startPos:this.startPos,event:s})},{signal:i});let r=s=>{try{this.host.releasePointerCapture(e.pointerId)}catch{}this.stop(t),this.options.onEnd?.({event:s})};window.addEventListener("pointerup",r,{signal:i}),window.addEventListener("pointercancel",r,{signal:i})}stop(e=!0){this.isDragging&&(this.isDragging=!1,this.host.classList.remove("dragging"),document.body&&document.body.classList.remove("is-resizing","is-resizing-v","is-resizing-h"),this._abort?.abort(),this._abort=null)}},Ph=class extends ni{static properties={for:{type:String},orientation:{type:String,reflect:!0}};constructor(){super(),this.orientation="vertical",this._connectedAbort=null,this.drag=new Db(this,{onStart:({startPos:e})=>this._emit("start",{startPos:e}),onDrag:({delta:e,currentPos:t,startPos:i})=>this._emit("drag",{delta:e,currentPos:t,startPos:i}),onEnd:()=>this._emit("end")})}connectedCallback(){super.connectedCallback(),this._connectedAbort=new AbortController;let{signal:e}=this._connectedAbort;this.setAttribute("role","separator"),this.classList.add("ide-splitter"),this.performUpdate(),this.addEventListener("pointerdown",t=>this.drag.start(t,this.isVertical),{signal:e}),this.addEventListener("dblclick",()=>this._emit("reset"),{signal:e})}disconnectedCallback(){super.disconnectedCallback(),this._connectedAbort?.abort()}build(){}updated(e){super.updated(e);let t=this.isVertical;this.setAttribute("aria-orientation",t?"vertical":"horizontal"),this.classList.toggle("ide-splitter-v",t),this.classList.toggle("ide-splitter-h",!t)}get targetPane(){return this.for||this.getAttribute("for")||""}get isVertical(){return(this.orientation||this.getAttribute("orientation")||"vertical")==="vertical"}_emit(e,t={}){this.dispatchEvent(new CustomEvent(`ide-splitter-${e}`,{bubbles:!0,composed:!0,detail:{for:this.targetPane,orientation:this.isVertical?"vertical":"horizontal",...t}}))}},Nb=class extends ni{static properties={title:{type:String,reflect:!0},closable:{type:Boolean,reflect:!0},for:{type:String},active:{type:Boolean,reflect:!0}};constructor(){super(),this._connectedAbort=null,this.titleRef=Mi(),this.closeBtnRef=Mi(),this._onClick=this._onClick.bind(this),this._onCloseClick=this._onCloseClick.bind(this)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this._connectedAbort=new AbortController;let{signal:e}=this._connectedAbort;this.classList.add("ide-tab","lm_tab"),this.setAttribute("role","tab"),this.hasAttribute("aria-selected")||this.setAttribute("aria-selected","false"),this.addEventListener("click",this._onClick,{signal:e}),this.performUpdate()}disconnectedCallback(){super.disconnectedCallback(),this._connectedAbort?.abort()}_emit(e,t={}){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}_onClick(e){e&&e.target&&e.target.closest(".ide-tab-close")||this._emit("tab-select",{componentType:this.targetComponent})}_onCloseClick(e){e.stopPropagation(),this._emit("tab-close",{componentType:this.targetComponent})}get targetComponent(){return this.for||this.getAttribute("for")||this.getAttribute("data-component")||this.id.replace(/^tab-/,"")||""}get titleText(){return this.title||""}set titleText(e){this.title=e}get titleEl(){return this.hasUpdated||this.performUpdate(),this.titleRef.value}get closeBtn(){return this.hasUpdated||this.performUpdate(),this.closeBtnRef.value}setActive(e){this.active=!!e,this.performUpdate()}updated(e){super.updated(e),e.has("active")&&(this.classList.toggle("active",this.active),this.classList.toggle("lm_active",this.active),this.setAttribute("aria-selected",this.active?"true":"false"))}render(){let e=this.title||"",t=!!this.closable;return ys` - ${e} - ${Ol(t,()=>ys` + `}},Nb=class{constructor(e,t={}){(this.host=e).addController(this),this.options=t,this._abort=null,this.isDragging=!1,this.startPos=0}hostDisconnected(){this.stop()}start(e,t=!0){e.preventDefault();try{this.host.setPointerCapture(e.pointerId)}catch{}this.isDragging=!0,this.host.classList.add("dragging"),document.body&&document.body.classList.add("is-resizing",t?"is-resizing-v":"is-resizing-h"),this.startPos=t?e.clientX:e.clientY,this.options.onStart?.({startPos:this.startPos,event:e}),this._abort=new AbortController;let{signal:i}=this._abort;window.addEventListener("pointermove",s=>{let o=t?s.clientX:s.clientY,a=o-this.startPos;this.options.onDrag?.({delta:a,currentPos:o,startPos:this.startPos,event:s})},{signal:i});let r=s=>{try{this.host.releasePointerCapture(e.pointerId)}catch{}this.stop(t),this.options.onEnd?.({event:s})};window.addEventListener("pointerup",r,{signal:i}),window.addEventListener("pointercancel",r,{signal:i})}stop(e=!0){this.isDragging&&(this.isDragging=!1,this.host.classList.remove("dragging"),document.body&&document.body.classList.remove("is-resizing","is-resizing-v","is-resizing-h"),this._abort?.abort(),this._abort=null)}},Ch=class extends oi{static properties={for:{type:String},orientation:{type:String,reflect:!0}};constructor(){super(),this.orientation="vertical",this._connectedAbort=null,this.drag=new Nb(this,{onStart:({startPos:e})=>this._emit("start",{startPos:e}),onDrag:({delta:e,currentPos:t,startPos:i})=>this._emit("drag",{delta:e,currentPos:t,startPos:i}),onEnd:()=>this._emit("end")})}connectedCallback(){super.connectedCallback(),this._connectedAbort=new AbortController;let{signal:e}=this._connectedAbort;this.setAttribute("role","separator"),this.classList.add("ide-splitter"),this.performUpdate(),this.addEventListener("pointerdown",t=>this.drag.start(t,this.isVertical),{signal:e}),this.addEventListener("dblclick",()=>this._emit("reset"),{signal:e})}disconnectedCallback(){super.disconnectedCallback(),this._connectedAbort?.abort()}build(){}updated(e){super.updated(e);let t=this.isVertical;this.setAttribute("aria-orientation",t?"vertical":"horizontal"),this.classList.toggle("ide-splitter-v",t),this.classList.toggle("ide-splitter-h",!t)}get targetPane(){return this.for||this.getAttribute("for")||""}get isVertical(){return(this.orientation||this.getAttribute("orientation")||"vertical")==="vertical"}_emit(e,t={}){this.dispatchEvent(new CustomEvent(`ide-splitter-${e}`,{bubbles:!0,composed:!0,detail:{for:this.targetPane,orientation:this.isVertical?"vertical":"horizontal",...t}}))}},Fb=class extends oi{static properties={title:{type:String,reflect:!0},closable:{type:Boolean,reflect:!0},for:{type:String},active:{type:Boolean,reflect:!0}};constructor(){super(),this._connectedAbort=null,this.titleRef=Bi(),this.closeBtnRef=Bi(),this._onClick=this._onClick.bind(this),this._onCloseClick=this._onCloseClick.bind(this)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this._connectedAbort=new AbortController;let{signal:e}=this._connectedAbort;this.classList.add("ide-tab","lm_tab"),this.setAttribute("role","tab"),this.hasAttribute("aria-selected")||this.setAttribute("aria-selected","false"),this.addEventListener("click",this._onClick,{signal:e}),this.performUpdate()}disconnectedCallback(){super.disconnectedCallback(),this._connectedAbort?.abort()}_emit(e,t={}){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}_onClick(e){e&&e.target&&e.target.closest(".ide-tab-close")||this._emit("tab-select",{componentType:this.targetComponent})}_onCloseClick(e){e.stopPropagation(),this._emit("tab-close",{componentType:this.targetComponent})}get targetComponent(){return this.for||this.getAttribute("for")||this.getAttribute("data-component")||this.id.replace(/^tab-/,"")||""}get titleText(){return this.title||""}set titleText(e){this.title=e}get titleEl(){return this.hasUpdated||this.performUpdate(),this.titleRef.value}get closeBtn(){return this.hasUpdated||this.performUpdate(),this.closeBtnRef.value}setActive(e){this.active=!!e,this.performUpdate()}updated(e){super.updated(e),e.has("active")&&(this.classList.toggle("active",this.active),this.classList.toggle("lm_active",this.active),this.setAttribute("aria-selected",this.active?"true":"false"))}render(){let e=this.title||"",t=!!this.closable;return ys` + ${e} + ${Dl(t,()=>ys` ✕ `)} - `}};customElements.get("ide-pane")||customElements.define("ide-pane",Ob);customElements.get("ide-splitter")||customElements.define("ide-splitter",Ph);customElements.get("ide-tab")||customElements.define("ide-tab",Nb);var i3={DisplayControls:{pane:"left",title:"Display Controls",closable:!1},LayoutViewer:{pane:"main",title:"Layout",closable:!1},SchematicWidget:{pane:"main",title:"Schematic",closable:!0},"3DViewer":{pane:"main",title:"3D Viewer",closable:!0},TclConsole:{pane:"bottom",title:"Tcl Console",closable:!1},Inspector:{pane:"right",title:"Inspector",closable:!0},Browser:{pane:"right",title:"Hierarchy",closable:!0},TimingWidget:{pane:"right",title:"Timing",closable:!0},DRCWidget:{pane:"right",title:"DRC",closable:!0},SelectHighlight:{pane:"right",title:"Select Highlight",closable:!0},ClockWidget:{pane:"right",title:"Clock Tree",closable:!0},ChartsWidget:{pane:"right",title:"Charts",closable:!0},HelpWidget:{pane:"right",title:"Help",closable:!0}},Sh={left:{cssVar:"--pane-left-width",defaultSize:"240px",minSize:140,maxFraction:.45,dimension:"width",isVertical:!0,invertDelta:!1},right:{cssVar:"--pane-right-width",defaultSize:"340px",minSize:160,maxFraction:.5,dimension:"width",isVertical:!0,invertDelta:!0},bottom:{cssVar:"--pane-bottom-height",defaultSize:"220px",minSize:70,maxFraction:.75,dimension:"height",isVertical:!1,invertDelta:!0}},Ch=class{constructor(e){this.containerEl=e,this.factories=new Map,this.components=new Map,this.activeTabs={left:null,main:null,bottom:null,right:null},this.closedComponents=new Set,this.eventListeners=new Map,this._resizeScheduled=!1,this._ensureDOM(),this._initSplitters(),this._initControls(),this._initResizeObserver()}on(e,t){this.eventListeners.has(e)||this.eventListeners.set(e,new Set),this.eventListeners.get(e).add(t)}off(e,t){this.eventListeners.get(e)?.delete(t)}emit(e,...t){let i=this.eventListeners.get(e);if(i)for(let r of i)try{r(...t)}catch(s){console.error(s)}}_ensureDOM(){this.containerEl.classList.add("ide-layout"),this.containerEl.querySelector("#pane-left")||this._buildInitialLayoutTree(),this._resolvePaneReferences()}_buildInitialLayoutTree(){this.containerEl.appendChild(this._createGutterButton("left","\u25B6 Display Controls","Restore Display Controls")),this.containerEl.appendChild(this._createGutterButton("right","\u25C0 Tools & Inspector","Restore Right Panel")),this.containerEl.appendChild(this._createPane("pane-left","left")),this.containerEl.appendChild(this._createSplitter("splitter-left","left","vertical","Drag to resize panel"));let e=document.createElement("main");e.id="pane-center",e.className="ide-center",e.appendChild(this._createPane("pane-main","main",{maximizable:!0})),e.appendChild(this._createSplitter("splitter-bottom","bottom","horizontal","Drag to resize console")),e.appendChild(this._createGutterButton("bottom","\u25B2 Tcl Console","Restore Tcl Console")),e.appendChild(this._createPane("pane-bottom","bottom",{maximizable:!0,collapsible:!0})),this.containerEl.appendChild(e),this.containerEl.appendChild(this._createSplitter("splitter-right","right","vertical","Drag to resize panel")),this.containerEl.appendChild(this._createPane("pane-right","right",{maximizable:!0,collapsible:!0}))}_createGutterButton(e,t,i){let r=document.createElement("button");r.id=`gutter-expand-${e}`,r.className=`ide-gutter-expand ide-gutter-${e}`,r.title=i;let s=document.createElement("span");return s.textContent=t,r.appendChild(s),r}_createPane(e,t,i={}){let r=document.createElement("ide-pane");return r.id=e,r.setAttribute("name",t),i.maximizable&&r.setAttribute("maximizable",""),i.collapsible&&r.setAttribute("collapsible",""),r}_createSplitter(e,t,i,r){let s=document.createElement("ide-splitter");return s.id=e,s.setAttribute("for",t),s.setAttribute("orientation",i),s.title=r,s}_resolvePaneReferences(){let e=["left","main","bottom","right"];this.panes={};for(let t of e){let i=this.containerEl.querySelector(`#pane-${t}`);i?.build&&i.build(),this.panes[t]={el:i,paneComponent:i,tabsEl:i?.tabsEl||this.containerEl.querySelector(`#pane-${t}-tabs`),contentEl:i?.contentEl||this.containerEl.querySelector(`#pane-${t}-content`)}}this.centerEl=this.containerEl.querySelector("#pane-center")}_initSplitters(){let e=null;this.containerEl.addEventListener("ide-splitter-start",t=>{let i=t.detail?.for,r=Sh[i];if(!r)return;let o=(i==="bottom"?this.centerEl||this.containerEl:this.containerEl).getBoundingClientRect(),a=this.panes[i]?.el?.getBoundingClientRect()||{},c=r.dimension==="width"?o.width:o.height,l=r.dimension==="width"?a.width||240:a.height||220;e={paneName:i,cfg:r,startSize:l,maxLimit:Math.round(c*r.maxFraction)||500}}),this.containerEl.addEventListener("ide-splitter-drag",t=>{if(!e||e.paneName!==t.detail?.for)return;let{cfg:i,startSize:r,maxLimit:s}=e,o=i.invertDelta?-t.detail.delta:t.detail.delta,a=Math.round(r+o),c=Math.max(i.minSize,Math.min(s,a));this.containerEl.style.setProperty(i.cssVar,`${c}px`),this.notifyResize()}),this.containerEl.addEventListener("ide-splitter-end",()=>{e=null,this.saveLayout(),this.notifyResize()}),this.containerEl.addEventListener("ide-splitter-reset",t=>{let i=t.detail?.for;this._resetSplitterPane(i)}),this._setupFallbackSplitters()}_resetSplitterPane(e){let t=Sh[e];t&&(this.containerEl.style.setProperty(t.cssVar,t.defaultSize),this.isPaneCollapsed(e)?this.restorePane(e):(this.saveLayout(),this.notifyResize()))}_setupFallbackSplitters(){for(let[e,t]of Object.entries(Sh)){let i=this.containerEl.querySelector(`#splitter-${e}`);if(!i||i instanceof Ph)continue;let r=!t.invertDelta,s=t.isVertical;i.addEventListener("pointerdown",o=>{o.preventDefault();try{i.setPointerCapture(o.pointerId)}catch{}i.classList.add("dragging"),document.body&&document.body.classList.add("is-resizing",s?"is-resizing-v":"is-resizing-h");let a=s?o.clientX:o.clientY,l=(e==="bottom"?this.centerEl||this.containerEl:this.containerEl).getBoundingClientRect(),u=this.panes[e]?.el?.getBoundingClientRect()||{},f=t.dimension==="width"?u.width||240:u.height||220,d=t.dimension==="width"?l.width:l.height,h=Math.round(d*t.maxFraction)||500,p=new AbortController,{signal:m}=p,g=y=>{let b=s?y.clientX:y.clientY,w=r?b-a:a-b,E=Math.round(f+w),x=Math.max(t.minSize,Math.min(h,E));this.containerEl.style.setProperty(t.cssVar,`${x}px`),this.notifyResize()},v=y=>{try{i.releasePointerCapture(y.pointerId)}catch{}i.classList.remove("dragging"),document.body&&document.body.classList.remove("is-resizing","is-resizing-v","is-resizing-h"),p.abort(),this.saveLayout(),this.notifyResize()};window.addEventListener("pointermove",g,{signal:m}),window.addEventListener("pointerup",v,{signal:m}),window.addEventListener("pointercancel",v,{signal:m})}),i.addEventListener("dblclick",()=>{this._resetSplitterPane(e)})}}_initControls(){this.containerEl.addEventListener("ide-pane-maximize",t=>{this.toggleMaximize(t.detail?.pane)}),this.containerEl.addEventListener("ide-pane-collapse",t=>{this.toggleCollapse(t.detail?.pane)}),this.containerEl.addEventListener("ide-layout-reset",()=>{this.resetLayout()});for(let t of["left","right","bottom"]){let i=this.containerEl.querySelector(`#gutter-expand-${t}`);i&&i.addEventListener("click",()=>this.restorePane(t))}let e=[{sel:"#btn-collapse-left",handler:()=>this.toggleCollapse("left")},{sel:"#btn-collapse-right",handler:()=>this.toggleCollapse("right")},{sel:"#btn-collapse-bottom",handler:()=>this.toggleCollapse("bottom")},{sel:"#btn-maximize-main",handler:()=>this.toggleMaximize("main")},{sel:"#btn-maximize-bottom",handler:()=>this.toggleMaximize("bottom")},{sel:"#btn-maximize-right",handler:()=>this.toggleMaximize("right")},{sel:"#btn-empty-reset-layout",handler:()=>this.resetLayout()}];for(let{sel:t,handler:i}of e){let r=this.containerEl.querySelector(t);r&&!r.closest("ide-pane")&&r.addEventListener("click",i)}}isPaneMaximized(e){return e?this.containerEl.classList.contains(`maximized-${e}`):this.containerEl.classList.contains("maximized-main")||this.containerEl.classList.contains("maximized-bottom")||this.containerEl.classList.contains("maximized-right")}setMaximizedPane(e,t=!0){let i=["main","bottom","right"];if(e&&!i.includes(e))return!1;let r=t?e:null;for(let s of i){let o=s===r;this.containerEl.classList.toggle(`maximized-${s}`,o),this.panes[s]?.paneComponent?.setMaximized(o);let a=this.containerEl.querySelector(`#btn-maximize-${s}`);a&&(a.textContent=o?"\u29C9":"\u2922",a.title=o?"Restore":"Maximize")}return this.notifyResize(),!!r}maximizePane(e){return this.setMaximizedPane(e,!0)}restoreMaximized(){return this.setMaximizedPane(null,!1)}toggleMaximize(e){return this.setMaximizedPane(e,!this.isPaneMaximized(e))}isPaneCollapsed(e){let t=e==="bottom"?this.centerEl:this.containerEl;return t?t.classList.contains(`hide-${e}`):!1}_setPaneCollapsed(e,t){let i=e==="bottom"?this.centerEl:this.containerEl;if(!i)return;i.classList.toggle(`hide-${e}`,t),this.panes[e]?.paneComponent?.setCollapsed?.(t);let r=this.containerEl.querySelector(`#btn-collapse-${e}`);if(r){let o={bottom:{collapsed:"\u25B2",expanded:"\u25BC"},left:{collapsed:"\u25B6",expanded:"\u25C0"},right:{collapsed:"\u25C0",expanded:"\u25B6"}}[e]||{collapsed:"\u25B6",expanded:"\u25C0"};r.textContent=t?o.collapsed:o.expanded,r.title=t?`Expand ${e.charAt(0).toUpperCase()+e.slice(1)}`:`Collapse ${e.charAt(0).toUpperCase()+e.slice(1)}`}this.saveLayout(),this.notifyResize()}toggleCollapse(e){this._setPaneCollapsed(e,!this.isPaneCollapsed(e))}collapsePane(e){this._setPaneCollapsed(e,!0)}restorePane(e){this._setPaneCollapsed(e,!1)}_updateEmptyState(){let e=this.containerEl.querySelector("#ide-empty-state");if(!e)return;let t=!!this.activeTabs.main;e.style.display=t?"none":"flex"}resetLayout(){try{localStorage.removeItem("or_ide_layout")}catch{}for(let[e,t]of Object.entries(Sh))this.containerEl.style.setProperty(t.cssVar,t.defaultSize);for(let e of["left","right","bottom"])this.restorePane(e);this.restoreMaximized(),this.closedComponents.clear();for(let e of this.components.values())e.tabEl.style.display="",e.contentDiv.style.display="";this.components.has("DisplayControls")&&this.activateTab("DisplayControls"),this.components.has("LayoutViewer")&&this.activateTab("LayoutViewer"),this.components.has("TclConsole")&&this.activateTab("TclConsole"),this.components.has("Inspector")&&this.activateTab("Inspector"),this._updateEmptyState(),this.saveLayout(),this.notifyResize(),this.emit("stateChanged"),typeof app<"u"&&app.map&&setTimeout(()=>app.map.invalidateSize({animate:!1}),0)}_initResizeObserver(){typeof ResizeObserver<"u"&&new ResizeObserver(()=>{this.notifyResize()}).observe(this.containerEl)}registerComponentFactoryFunction(e,t){this.factories.set(e,t)}loadLayout(e){for(let[i,r]of Object.entries(i3)){let s=this.factories.get(i);s&&this._mountComponent(i,r.pane,r.title,r.closable,s)}let t=null;try{let i=localStorage.getItem("or_ide_layout");i&&(t=JSON.parse(i))}catch{}if(t){if(t.leftWidth&&this.containerEl.style.setProperty("--pane-left-width",`${t.leftWidth}px`),t.rightWidth&&this.containerEl.style.setProperty("--pane-right-width",`${t.rightWidth}px`),t.bottomHeight&&this.containerEl.style.setProperty("--pane-bottom-height",`${t.bottomHeight}px`),t.closed)for(let i of t.closed)this.closeComponent(i,!1);this.activateTab(t.activeTabs?.left||"DisplayControls"),this.activateTab(t.activeTabs?.main||"LayoutViewer"),this.activateTab(t.activeTabs?.bottom||"TclConsole"),this.activateTab(t.activeTabs?.right||"Inspector"),t.hideLeft&&this.collapsePane("left"),t.hideRight&&this.collapsePane("right"),t.hideBottom&&this.collapsePane("bottom")}else this.activateTab("DisplayControls"),this.activateTab("LayoutViewer"),this.activateTab("TclConsole"),this.activateTab("Inspector");this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}_mountComponent(e,t,i,r,s){if(this.components.has(e))return;let o=this.panes[t];if(!o)return;let a=document.createElement("div");a.className="ide-component-container",a.id=`cmp-${e}`,o.contentEl.appendChild(a);let c=document.createElement("ide-tab");c.id=`tab-${e}`,c.setAttribute("for",e),c.setAttribute("data-component",e),c.setAttribute("title",i),r&&c.setAttribute("closable",""),c.addEventListener("tab-select",()=>{this.activateTab(e)}),c.addEventListener("tab-close",()=>{this.closeComponent(e)}),o.tabsEl.appendChild(c);let l=new Map,u={element:a,get width(){return a.clientWidth},get height(){return a.clientHeight},title:i,on:(d,h)=>{l.has(d)||l.set(d,new Set),l.get(d).add(h)},off:(d,h)=>{l.get(d)?.delete(h)},fire:(d,...h)=>{let p=l.get(d);if(p)for(let m of p)try{m(...h)}catch(g){console.error(g)}},focus:()=>this.focusComponent(e),close:()=>this.closeComponent(e)},f={componentType:e,paneName:t,title:i,closable:r,tabEl:c,contentDiv:a,container:u};this.components.set(e,f);try{s(u)}catch(d){console.error(`Failed to initialize component ${e}:`,d)}}isComponentActive(e){return e?!!e.contentDiv?.classList.contains("active"):!1}_setComponentActive(e,t){if(!e)return;let i=!!t;e.tabEl?.setActive(i),e.contentDiv?.classList.toggle("active",i)}activateTab(e){let t=this.components.get(e);if(!t||!this.panes[t.paneName])return;["left","right","bottom"].includes(t.paneName)&&this.isPaneCollapsed(t.paneName)&&this.restorePane(t.paneName);let r=this.activeTabs[t.paneName];if(r&&r!==e){let s=this.components.get(r);s&&(this._setComponentActive(s,!1),s.container.fire("hide"))}this.activeTabs[t.paneName]=e,t.tabEl.style.display="",t.contentDiv.style.display="",this._setComponentActive(t,!0),this.closedComponents.delete(e),t.container.fire("show"),t.container.fire("open"),t.container.fire("resize"),typeof app<"u"&&(e==="LayoutViewer"&&app.map&&setTimeout(()=>app.map.invalidateSize({animate:!1}),0),e==="3DViewer"&&app.threeDViewerWidget&&setTimeout(()=>app.threeDViewerWidget.onOpen(),0));try{t.tabEl.scrollIntoView({behavior:"smooth",inline:"nearest",block:"nearest"})}catch{}this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}closeComponent(e,t=!0){let i=this.components.get(e);if(!(!i||!i.closable)){if(i.tabEl.style.display="none",i.contentDiv.style.display="none",this._setComponentActive(i,!1),i.container.fire("hide"),this.closedComponents.add(e),t&&this.activeTabs[i.paneName]===e){let r=null;for(let s of this.components.values())if(s.paneName===i.paneName&&!this.closedComponents.has(s.componentType)){r=s;break}r?this.activateTab(r.componentType):(this.activeTabs[i.paneName]=null,["left","right","bottom"].includes(i.paneName)&&this.collapsePane(i.paneName))}this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}}focusComponent(e){if(!this.components.get(e)){let i=this.factories.get(e);if(i){let r=i3[e]||{pane:"right",title:e,closable:!0};this._mountComponent(e,r.pane,r.title,r.closable,i)}else return}this.activateTab(e)}saveLayout(){let e={leftWidth:parseInt(this.containerEl.style.getPropertyValue("--pane-left-width")||"240",10),rightWidth:parseInt(this.containerEl.style.getPropertyValue("--pane-right-width")||"340",10),bottomHeight:parseInt(this.containerEl.style.getPropertyValue("--pane-bottom-height")||"220",10),hideLeft:this.isPaneCollapsed("left"),hideRight:this.isPaneCollapsed("right"),hideBottom:this.isPaneCollapsed("bottom"),activeTabs:{...this.activeTabs},closed:Array.from(this.closedComponents)};try{localStorage.setItem("or_ide_layout",JSON.stringify(e))}catch{}return e}notifyResize(){if(this._resizeScheduled)return;this._resizeScheduled=!0,(typeof requestAnimationFrame=="function"?requestAnimationFrame:t=>{t()})(()=>{this._resizeScheduled=!1;for(let t of this.components.values())this.isComponentActive(t)&&t.container.fire("resize");typeof app<"u"&&app&&app.map&&app.map.invalidateSize({animate:!1}),window.dispatchEvent(new Event("resize"))})}updateSize(){this.notifyResize()}setSize(e,t){this.notifyResize()}addComponent(e,t,i){this.focusComponent(e)}get rootItem(){return{contentItems:Array.from(this.components.keys()).map(e=>({isComponent:!0,componentType:e,focus:()=>this.focusComponent(e)}))}}};function xn(n,e,t,i=0,r=0){return[(n-i)*t,(e-r)*t]}function wn(n,e,t,i=0,r=0){return{dbuX:Math.round(i+n/t),dbuY:Math.round(r+e/t)}}function Ot(n,e,t,i,r,s=0,o=0){let[a,c]=xn(n,e,r,s,o),[l,u]=xn(t,i,r,s,o);return[Math.min(a,l),Math.min(c,u),Math.max(a,l),Math.max(c,u)]}var Dl=class n{constructor(e,t){this.url=e,this.socket=null,this.nextId=1,this.pending=new Map,this._queue=new Map,this._bgQueue=new Map,this._bgSent=new Set,this._inFlight=0,this._inFlightIds=new Set,this._unknownPayloadTypes=new Set,this._maxInFlight=48,this._lastRecvAt=0,this._bufStuckSince=0,this._lastBuffered=0,this.reconnectDelay=1e3,this.readyPromise=null,this.readyResolve=null,this.onStatusChange=t||(()=>{}),this.onPush=null,this._cache=null,this._isConnected=!1,this._shutdown=!1,this._livenessTimer=void 0,this._startLivenessMonitor(),this.connect()}get isConnected(){return this._isConnected||this.socket&&this.socket.readyState===WebSocket.OPEN}get pendingCount(){return this.pending.size-this._bgSent.size+(this._queue?this._queue.size:0)}static fromCache(e,t){let i=Object.create(n.prototype);return i.url=null,i.socket=null,i.nextId=1,i.pending=new Map,i._queue=new Map,i._bgQueue=new Map,i._bgSent=new Set,i._inFlight=0,i._inFlightIds=new Set,i._unknownPayloadTypes=new Set,i._maxInFlight=48,i._lastRecvAt=0,i.reconnectDelay=0,i.onStatusChange=t||(()=>{}),i.onPush=null,i._cache=e,i._isConnected=!0,i.readyPromise=Promise.resolve(),i.readyResolve=null,i}get isStaticMode(){return!!this._cache}connect(){this.readyPromise=new Promise(e=>{this.readyResolve=e}),this.socket=new WebSocket(this.url),this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{console.log("WebSocket connected");let e=this._everConnected===!0;this._everConnected=!0,this._isConnected=!0,this.reconnectDelay=1e3,this._lastRecvAt=typeof performance<"u"?performance.now():0,this.readyResolve(),this.onStatusChange(),this._pump(),e&&this.onReconnected&&this.onReconnected()},this.socket.onmessage=e=>{this.handleMessage(e.data)},this.socket.onclose=()=>this._handleClose(),this.socket.onerror=e=>{console.error("WebSocket error:",e)}}_handleClose(){this._isConnected=!1,this._inFlight=0,this._inFlightIds.clear(),this._bufStuckSince=0,this.onStatusChange();for(let[e,t]of this.pending)t.reject(new Error("WebSocket closed"));this.pending.clear(),this._bgSent.clear();for(let e of[this._queue,this._bgQueue]){for(let[t,i]of e)i.reject(new Error("WebSocket closed"));e.clear()}if(this._shutdown){console.log("WebSocket closed (server stopped)"),this._stopLivenessMonitor();return}console.log("WebSocket closed, reconnecting..."),setTimeout(()=>this.connect(),this.reconnectDelay),this.reconnectDelay=Math.min(this.reconnectDelay*2,3e4)}_forceReconnect(){let e=this.socket;if(this.socket=null,e){e.onopen=null,e.onmessage=null,e.onclose=null,e.onerror=null;try{e.close()}catch{}}this._handleClose()}handleMessage(e){let t=new DataView(e),i=t.getUint32(0),r=t.getUint8(4);if(this._lastRecvAt=typeof performance<"u"?performance.now():0,i===0&&r===0){let a=e.slice(8),c;try{c=JSON.parse(new TextDecoder().decode(a))}catch(l){console.error("Failed to parse server push JSON:",l);return}if(c&&c.type==="config"){Number.isFinite(c.max_in_flight)&&(this._maxInFlight=Math.max(1,Math.min(4096,Math.floor(c.max_in_flight))),this._pump());return}this.onPush&&this.onPush(c);return}this._inFlightIds.delete(i)&&this._inFlight>0&&this._inFlight--;let s=this.pending.get(i);if(!s){this._pump();return}this.pending.delete(i),this._bgSent.delete(i),this._pump(),this.onStatusChange();let o=e.slice(8);if(r===2)s.reject(new Error(new TextDecoder().decode(o)));else if(r===0)try{s.resolve(JSON.parse(new TextDecoder().decode(o)))}catch(a){s.reject(new Error("JSON parse error: "+a.message))}else r===1?s.resolve(new Blob([o],{type:"image/png"})):r===3?s.resolve(null):(this._unknownPayloadTypes.has(r)||(this._unknownPayloadTypes.add(r),console.warn(`Unrecognized websocket payload type ${r}. The server is likely newer than this page \u2014 reload to pick up the current client.`)),s.reject(new Error(`Unsupported websocket payload type ${r}`)))}request(e,{background:t=!1}={}){if(this._cache)return this._cacheRequest(e);let i=this.nextId++;if(e.id=i,!this.socket||this.socket.readyState!==WebSocket.OPEN)return Promise.reject(new Error("WebSocket not connected"));let r,s,o=new Promise((a,c)=>{r=a,s=c});return o.requestId=i,(t?this._bgQueue:this._queue).set(i,{msg:e,resolve:r,reject:s}),this._pump(),o}_pump(){if(!(!this.socket||this.socket.readyState!==WebSocket.OPEN)){for(;this._inFlight0||this._bgQueue.size>0)&&this.socket.bufferedAmount<524288;){let e=this._queue.size===0,t=e?this._bgQueue:this._queue,[i,r]=t.entries().next().value;t.delete(i),this.pending.set(i,{resolve:r.resolve,reject:r.reject}),e&&this._bgSent.add(i),this.socket.send(JSON.stringify(r.msg)),this._inFlightIds.add(i),this._inFlight++}this.onStatusChange()}}promote(e){let t=this._bgQueue.get(e);t?(this._bgQueue.delete(e),this._queue.set(e,t),this._pump()):this._bgSent.delete(e)&&this.onStatusChange()}cancel(e){let t=this._queue.get(e)||this._bgQueue.get(e);if(t){this._queue.delete(e),this._bgQueue.delete(e),t.reject(new Error("Request cancelled")),this.onStatusChange();return}let i=this.pending.get(e),r=this.pending.delete(e);this._bgSent.delete(e),i&&i.reject(new Error("Request cancelled")),r&&!this._cache&&this.socket&&this.socket.readyState===WebSocket.OPEN&&this.socket.send(JSON.stringify({type:"cancel",cancel_id:e,id:this.nextId++})),this.onStatusChange()}_startLivenessMonitor(){typeof setInterval>"u"||(this._livenessTimer=setInterval(()=>this._checkLiveness(),3e3),this._livenessTimer&&typeof this._livenessTimer.unref=="function"&&this._livenessTimer.unref())}_stopLivenessMonitor(){this._livenessTimer!==void 0&&typeof clearInterval<"u"&&(clearInterval(this._livenessTimer),this._livenessTimer=void 0)}_checkLiveness(){if(this._cache)return;let e=this.socket;if(!e||e.readyState!==WebSocket.OPEN){this._bufStuckSince=0,this._lastBuffered=0;return}let t=e.bufferedAmount,i=typeof performance<"u"?performance.now():0,r=!1,s="";t<=262144||t12e3&&(r=!0,s=`send buffer stuck at ${t}B for ${Math.round(i-this._bufStuckSince)}ms`),this._lastBuffered=t,!r&&this._inFlight>=this._maxInFlight&&this._queue.size+this._bgQueue.size>0&&this._lastRecvAt>0&&i-this._lastRecvAt>3e4&&(r=!0,s=`saturated (${this._inFlight} in flight, ${this._queue.size} queued) but silent for ${Math.round(i-this._lastRecvAt)}ms`),r&&(console.warn(`WebSocket connection wedged \u2014 ${s}; reconnecting to recover`),this._bufStuckSince=0,this._forceReconnect())}_cacheRequest(e){let t=e.type;if(t==="tile"){let s=e.layer+"/"+e.z+"/"+e.x+"/"+e.y,o=this._cache.tiles&&this._cache.tiles[s];return o?Promise.resolve("data:image/png;base64,"+o):Promise.reject(new Error("Tile not cached: "+s))}if(t==="timing_highlight"){let s=e.path_index;if(s>=0&&this._cache.overlays){let o=e.is_setup?"setup":"hold",a=this._cache.overlays[o]?.[s];this._cache.setPathOverlay&&this._cache.setPathOverlay(a?"data:image/png;base64,"+a:null)}else this._cache.setPathOverlay&&this._cache.setPathOverlay(null);return Promise.resolve({})}if(t==="set_module_colors")return Promise.resolve({ok:1,count:0});let i=t;t==="timing_report"?i="timing_report:"+(e.is_setup?"setup":"hold"):t==="slack_histogram"&&(i="slack_histogram:"+(e.is_setup?"setup":"hold"));let r=this._cache.json&&this._cache.json[i];if(r!==void 0){if(t==="timing_report"&&e.slack_min!=null&&e.slack_max!=null&&r.paths){let s=[];return r.paths.forEach((o,a)=>{o.slack>=e.slack_min&&o.slacko||a>c?null:{z:e,x0:s,x1:o,y0:a,y1:c}}function zb([n,e,t,i],r){let s=(t-n)*r,o=(i-e)*r;return[n-s,e-o,t+s,i+o]}function Mh(n,e=1){if(!n)return null;let t=Math.pow(2,n.z);return{z:n.z,x0:Math.max(0,n.x0-e),x1:Math.min(t-1,n.x1+e),y0:Math.max(0,n.y0-e),y1:Math.min(t-1,n.y1+e)}}function Et(n,e,t){return!!n&&e>=n.x0&&e<=n.x1&&t>=n.y0&&t<=n.y1}function Fl(n){if(!n)return[];let e=(n.x0+n.x1)/2,t=(n.y0+n.y1)/2,i=[];for(let r=n.y0;r<=n.y1;r++)for(let s=n.x0;s<=n.x1;s++)i.push({z:n.z,x:s,y:r,d:(s-e)**2+(r-t)**2});return i.sort((r,s)=>r.d-s.d),i.map(({z:r,x:s,y:o})=>({z:r,x:s,y:o}))}function s3(n,e,t,i){let r=i/Math.pow(2,n);return[e*r,i-(t+1)*r,(e+1)*r,i-t*r]}function Ub(n,e){return n[0]Math.log2(s/T);if(p<1e-12){let T=Math.log(f/u)/t;return{S:Math.abs(T),at:I=>({target:[o+I*d,a+I*h],zoom:m(u*Math.exp(t*I*T))})}}let g=Math.sqrt(p),v=(f*f-u*u+r*p)/(2*u*i*g),y=(f*f-u*u-r*p)/(2*f*i*g),b=Math.log(Math.sqrt(v*v+1)-v),E=(Math.log(Math.sqrt(y*y+1)-y)-b)/t,x=Math.cosh(b);return{S:E,at:T=>{if(T>=1)return{target:[c,l],zoom:e.zoom};let I=T*E,N=u/(i*g)*(x*Math.tanh(t*I+b)-Math.sinh(b));return{target:[o+N*d,a+N*h],zoom:m(u*x/Math.cosh(t*I+b))}}}}function Ho(n,e,t){return`${n}/${e}/${t}`}var Ah=class{constructor({source:e,onChange:t=()=>{},keepBuffer:i=2}={}){this.source=e,this.onChange=t,this.keepBuffer=i,this.tiles=new Map,this.z=null,this.range=null,this.ring=null,this.extra=[],this._generation=0,this._loads=0,this._cancels=0}update({z:e,range:t,ring:i=t,extra:r=[],hold:s=null}){this.z=e,this.range=t,this.ring=i,this.extra=r.filter(c=>c.z!==e&&c.range);let o=new Map(this.extra.map(c=>[c.z,c]));for(let c of[...this.tiles.values()]){if(c.z!==e){let l=o.get(c.z),u=l&&l.range;(u?!Et(u,c.x,c.y)&&(c.loading||!this._inKeepBuffer(c,u)):c.loading&&!c.drawable)?this._drop(c):u&&this._stale(c)&&Et(u,c.x,c.y)&&this._load(c,l.background!==!1);continue}if(this._stale(c)&&Et(i,c.x,c.y)&&this._load(c,!Et(t,c.x,c.y)),Et(i,c.x,c.y)){c.loading&&c.background&&Et(t,c.x,c.y)&&(c.background=!1,c.handle?.promote?.());continue}(c.loading||!(this._inKeepBuffer(c)||s&&Et(s,c.x,c.y)))&&this._drop(c)}let a=[...Fl(t),...Fl(i).filter(c=>!Et(t,c.x,c.y))];for(let{x:c,y:l}of a)this.tiles.has(Ho(e,c,l))||this._load(this._newTile(e,c,l),!Et(t,c,l));for(let c of this.extra)for(let{x:l,y:u}of Fl(c.range))this.tiles.has(Ho(c.z,l,u))||this._load(this._newTile(c.z,l,u),c.background!==!1)}refresh(){this._generation++;let e=new Map(this.extra.map(t=>[t.z,t]));for(let t of[...this.tiles.values()]){let i=e.get(t.z),r=t.z===this.z?this.ring:i&&i.range;r&&(Et(r,t.x,t.y)?(t.handle?.cancel?.(),this._load(t,i?i.background!==!1:!Et(this.range,t.x,t.y))):t.loading&&this._drop(t))}}isSettled(){for(let e of this.tiles.values())if(e.z===this.z&&e.loading&&Et(this.range,e.x,e.y))return!1;return!0}settledIn(e,t){for(let{x:i,y:r}of Fl(t)){let s=this.tiles.get(Ho(e,i,r));if(!s||s.loading)return!1}return!0}hasContentAt(e){for(let t of this.tiles.values())if(t.z===e&&t.drawable)return!0;return!1}drawableTilesAt(e){let t=[];for(let i of this.tiles.values())i.z===e&&i.drawable&&t.push(i);return t}prune(e){let t=new Set(e);for(let i of[...this.tiles.values()])t.has(i.z)||this._drop(i)}clear(){for(let e of[...this.tiles.values()])this._drop(e);this.z=null,this.range=null,this.ring=null,this.extra=[]}stats(){let e=0,t=0;for(let i of this.tiles.values())i.loading&&e++,i.drawable&&t++;return{tiles:this.tiles.size,loading:e,drawable:t,loads:this._loads,cancels:this._cancels}}_newTile(e,t,i){let r={z:e,x:t,y:i,key:Ho(e,t,i),drawable:null,loading:!1,background:!1,handle:null,generation:-1};return this.tiles.set(r.key,r),r}_load(e,t){let i=this._generation,r=()=>this.tiles.get(e.key)===e&&e.generation===i;e.generation=i,e.loading=!0,e.background=t,this._loads++;let s=this.source.load({z:e.z,x:e.x,y:e.y},{background:t,onPartial:o=>{if(!r()){this.source.release?.(o);return}this._setDrawable(e,o),this.onChange(e)}});e.handle=s,s.promise.then(o=>{if(!r()){this.source.release?.(o);return}o!==void 0&&this._setDrawable(e,o),e.loading=!1,e.handle=null,this.onChange(e)},()=>{r()&&(e.loading=!1,e.handle=null,this.onChange(e))})}_setDrawable(e,t){e.drawable&&e.drawable!==t&&this.source.release?.(e.drawable),e.drawable=t||null}_stale(e){return!e.loading&&e.generation!==this._generation}_inKeepBuffer(e,t=this.range){return Et(Mh(t,this.keepBuffer),e.x,e.y)}_drop(e){e.loading&&(this._cancels++,e.handle?.cancel?.()),e.drawable&&this.source.release?.(e.drawable),e.drawable=null,e.loading=!1,this.tiles.delete(e.key)}};function mV(n){return!Number.isFinite(n)||n<=1?1:Math.round(Math.min(n,3)*100)/100}var ki=240,gV=256,$b=ki;function tn(){return $b}function c3(){$b=gV}var Lbe=1/64,Gb=120;function l3(n){$b=n}function Vb(n,e){return Math.max(1,Math.round(n*e))}function Yo(){let n=typeof window<"u"&&window.devicePixelRatio?window.devicePixelRatio:1;return!Number.isFinite(n)||n<=1?1:Math.min(n,3)}function kh(n,e=tn()){return{dpr:mV(n),tile_px:Vb(e,n)}}function u3(n,e,t,i=tn()){let{selectability:r,selectableLayers:s,app:o}=e,a={...d3(n,e,t,i),selectable_layers:s?[...s]:[]};if(r)for(let[c,l]of Object.entries(r))a["s_"+c]=!!l;return c=>{let l={type:"tile",layer:c,...a},u=h3(o,c);return u!==1&&(l.pattern=u),l}}function f3(n,e,t,i,r=tn()){let s={type:"tile_group",layers:[...e],...d3(n,t,i,r)},o=e.map(a=>h3(t.app,a));return o.some(a=>a!==1)&&(s.patterns=o),s}function d3(n,e,t,i){let{visibility:r,visibleLayers:s,app:o}=e,a={z:n.z,x:n.x,y:n.y,...kh(t,i),visible_layers:s?[...s]:[]};for(let[c,l]of Object.entries(r||{}))a[c]=!!l;return o&&o.visibleChiplets instanceof Set&&(a.visible_chiplets=[...o.visibleChiplets]),a}function h3(n,e){let t=n&&n.layerPatterns?n.layerPatterns[e]:void 0;return t===void 0?1:t}function p3(n){if(typeof window>"u"||typeof window.matchMedia!="function"||typeof n!="function")return()=>{};let e=!1,t=null,i=null,r=()=>{if(e)return;let s=window.devicePixelRatio||1;t=window.matchMedia(`(resolution: ${s}dppx)`),i=()=>{e||(r(),n(window.devicePixelRatio||1))},t.addEventListener("change",i,{once:!0})};return r(),()=>{e=!0,t&&i&&t.removeEventListener("change",i),t=null,i=null}}function m3(n,e){if(!n)return!1;let t=!!e;return!!n.visible===t?!1:(n.visible=t,!0)}function g3(n,e,t){if(!n||!(t>0))return 0;n.clearRect(0,0,t,t);let i=0;for(let r of e||[]){let s=r?r.image:null;if(!s)continue;let o=r.opacity===void 0?1:r.opacity;o>0&&(n.globalAlpha=Math.min(1,o),n.drawImage(s,0,0,t,t),i++)}return n.globalAlpha=1,i}function Wb(n){for(let e of n||[])e&&typeof e.close=="function"&&e.close()}async function _3({items:n,request:e,decode:t,draw:i,release:r=Wb,isStale:s=()=>!1,incremental:o=!0}={}){let a=Array.isArray(n)?n:[],c={requested:a.length,arrived:0,decoded:0,drawn:0,paints:0,failed:0,stale:!1};if(a.length===0)return typeof i=="function"&&i([]),c;let l=new Array(a.length).fill(null),u=!1;function f(){if(s()){c.stale=!0;return}c.drawn=i(a.map((d,h)=>({image:l[h],opacity:d.opacity})))||0,c.paints++,u=!0}try{await Promise.all(a.map(async(d,h)=>{let p=null;try{p=await e(d)}catch{c.failed++;return}if(p==null)return;c.arrived++;let m=null;try{m=await t(p)}catch{return}m&&(l[h]=m,c.decoded++,o&&f())})),u||f()}finally{r(l)}return c}var _V=["tracks_pref","tracks_non_pref","debug","debug_renderers"],yV=1/16;function jb(n,e){if(n==null)return!1;if(!Array.isArray(n)||n.length!==4||!e)return!0;let t=Math.pow(2,e.z),i=yV/t,r=e.x/t-i,s=e.y/t-i,o=(e.x+1)/t+i,a=(e.y+1)/t+i,[c,l,u,f]=n;return c<=o&&u>=r&&l<=a&&f>=s}function bV(n,e,t){let i=n&&Array.isArray(n.by_size)?n.by_size:[];if(i.length===0||!e||!(t>0))return!0;let r=n.min_css_px/(t*Math.pow(2,e.z)),s=i[0];for(let o of i)o[0]<=r&&(s=o);return jb(s[1],e)}var Rh=class{constructor(){this._layers=null,this._gated=new Map,this._sized=new Map,this._generation=0}invalidate(){return this._generation++,this._layers=null,this._gated=new Map,this._sized=new Map,this._generation}apply(e,t){if(e!==this._generation)return!1;if(!t||t.supported!==!0||!t.layers||typeof t.layers!="object")return this._layers=null,!1;let i=new Map;if(t.gated&&typeof t.gated=="object")for(let[r,s]of Object.entries(t.gated))s&&typeof s=="object"&&i.set(r,new Map(Object.entries(s)));return this._layers=new Map(Object.entries(t.layers)),this._gated=i,this._sized=new Map(t.sized&&typeof t.sized=="object"?Object.entries(t.sized):[]),!0}refetch(e){let t=this.invalidate();return Promise.resolve().then(()=>e({type:"layer_extents"})).then(i=>this.apply(t,i)).catch(()=>!1)}mayHaveContent(e,t,i,r=256){if(!this._layers||i&&_V.some(s=>i[s]))return!0;if(this._sized.has(e))return bV(this._sized.get(e),t,r);if(!this._layers.has(e)||jb(this._layers.get(e),t))return!0;for(let[s,o]of this._gated)if(!(i&&i[s]===!1)&&o.has(e)&&jb(o.get(e),t))return!0;return!1}};function y3(n,e,t){let i=n&&n.app&&n.app.layerExtents;return i?i.mayHaveContent(e,t,n.visibility,tn()):!0}function b3(n){return n==null?Promise.resolve(null):typeof n=="string"?new Promise(e=>{let t=document.createElement("img");t.onload=()=>e(t),t.onerror=()=>e(null),t.src=n}):createImageBitmap(n,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).catch(()=>null)}function Hb(n){Wb([n&&n.image])}function vV(n){return{width:n.naturalWidth||n.width,height:n.naturalHeight||n.height}}function Ih(n){return n?{image:n,...vV(n)}:null}function xV(n){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(n,n);let e=document.createElement("canvas");return e.width=n,e.height=n,e}function Yb(n){let e=document.createElement("canvas");return e.width=n.width,e.height=n.height,e.getContext("2d").drawImage(n,0,0),e}function wV(n){return typeof n.transferToImageBitmap=="function"?Ih(n.transferToImageBitmap()):Ih(Yb(n))}var v3=Object.freeze({promise:Promise.resolve(null),cancel(){},promote(){}});function x3(n,e,t,i){let r=n.request(t,{background:i});return r.requestId!=null&&e.push(r.requestId),r}function w3(n,e,t,i){return{promise:t,cancel(){i();for(let r of e)n.cancel(r)},promote(){for(let r of e)n.promote?.(r)}}}var E3=3;function EV(n,e){let t=new Map,i=0,r=0;for(let s of n)if(!(!s||t.has(s.layer))){if(s.layer.startsWith("_")){t.set(s.layer,null),i++,r=0;continue}t.set(s.layer,`${i}:${Math.floor(r++/e)}`)}return t}function SV(n,e,t,i,r,s,o,a){let c=EV(n,t),l=[],u=null,f=()=>{u&&(l.push({opacity:1,msg:f3(r,u.layers,s,o,a)}),u=null)};for(let d of e){let h=c.get(d.layer);if(h==null){f(),l.push({opacity:1,msg:i(d.layer)});continue}u&&u.id!==h&&f(),u=u||{id:h,layers:[]},u.layers.push(d.layer)}return f(),l}function S3({wm:n,ctx:e,getItems:t,dpr:i=()=>1,tileSize:r=()=>240,isDoubleBuffer:s=()=>!0,decode:o=b3,makeCanvas:a=xV,snapshot:c=wV,groupLayers:l=()=>0}){return{load({z:u,x:f,y:d},{background:h=!1,onPartial:p}={}){let m=t()||[],g=m.filter(Y=>Y&&Y.visible!==!1&&y3(e,Y.layer,{z:u,x:f,y:d})),v=i(),y=r(),b=new Set,w=g.filter(Y=>!b.has(Y.layer)&&b.add(Y.layer));if(w.length===0)return v3;let E=u3({z:u,x:f,y:d},e,v,y),x=l(),T=x>0&&w.every(Y=>(Y.opacity??1)===1)?SV(m,w,x,E,{z:u,x:f,y:d},e,v,y):w.map(Y=>({opacity:Y.opacity,msg:E(Y.layer)})),I=Vb(y,v),N=null,D=null,H=[],W=!1,V=!s()&&typeof p=="function",X=_3({items:T,request:Y=>x3(n,H,Y.msg,h),decode:o,draw:Y=>{if(!N){if(!Y.some(oe=>oe.image))return 0;N=a(I),D=N.getContext("2d")}let ie=g3(D,Y,I);return V&&ie>0&&!W&&p(c(N)),ie},isStale:()=>W,incremental:V}).then(Y=>{if(W)throw new Error("Tile cancelled");if(Y.failed===Y.requested)throw new Error("Tile requests failed");return Y.drawn===0?null:V?void 0:c(N)});return w3(n,H,X,()=>{W=!0})},release:Hb}}function qb({wm:n,buildRequest:e,dpr:t=()=>1,tileSize:i=()=>240,decode:r=b3}){return{load({z:s,x:o,y:a},{background:c=!1}={}){let l=e({z:s,x:o,y:a},t(),i());if(!l)return v3;let u=[],f=!1,d=x3(n,u,l,c).then(h=>r(h)).then(h=>{if(f)throw Hb(Ih(h)),new Error("Tile cancelled");return Ih(h)});return w3(n,u,d,()=>{f=!0})},release:Hb}}function P3({z:n,x:e,y:t},i,r,s,o){let a={type:"overlay_tile",z:n,x:e,y:t,...kh(i,r),debug_renderers:!!s.debug_renderers,debug_live:!!s.debug_live,flywires_only:!!s.flywires_only,poly_decomp:!!(o&&o.polyDecomp),focused_nets_guides:!!s.focused_nets_guides,highlight_selected:s.highlight_selected!==!1,draw_labels:s.labels!==!1};return o&&o.visibleLayerNames&&(a.visible_layers=[...o.visibleLayerNames]),a}function C3({z:n,x:e,y:t},i,r,s){let o=s&&s.activeHeatMap;return o?{type:"heatmap_tile",name:o,z:n,x:e,y:t,...kh(i,r)}:null}function ue(n){return!!n?.websocketManager?.isStaticMode}function A3(n,e){let t={};for(let[i,r]of Object.entries(n||{}))t[i]=!!r;for(let[i,r]of Object.entries(e||{}))t["s_"+i]=!!r;return t}function qo(n,e){e&&typeof e.sel_has_inst=="boolean"&&(n.selHasInst=e.sel_has_inst,n.selHasNet=!!e.sel_has_net)}var Zb=null;function nn(n,e=4e3){let t=document.getElementById("or-toast");return t||(t=document.createElement("div"),t.id="or-toast",document.body.appendChild(t)),t.textContent=n,t.classList.add("visible"),Zb&&clearTimeout(Zb),Zb=setTimeout(()=>t.classList.remove("visible"),e),t}function k3({title:n,message:e,confirmLabel:t="OK",danger:i=!1}){return new Promise(r=>{let s=document.createElement("div");s.className="or-modal-overlay";let o=document.createElement("div");o.className="or-modal";let a=document.createElement("div");a.className="or-modal-title",a.textContent=n;let c=document.createElement("div");c.className="or-modal-message",c.textContent=e;let l=document.createElement("div");l.className="or-modal-buttons";let u=document.createElement("button");u.className="or-btn",u.textContent="Cancel";let f=document.createElement("button");f.className="or-btn"+(i?" or-btn-danger":""),f.textContent=t;let d=p=>{document.removeEventListener("keydown",h,!0),s.remove(),r(p)},h=p=>{p.key==="Escape"&&(p.stopPropagation(),d(!1))};u.addEventListener("click",()=>d(!1)),f.addEventListener("click",()=>d(!0)),s.addEventListener("click",p=>{p.target===s&&d(!1)}),document.addEventListener("keydown",h,!0),l.appendChild(u),l.appendChild(f),o.appendChild(a),o.appendChild(c),o.appendChild(l),s.appendChild(o),document.body.appendChild(s),u.focus()})}var PV=.05;function CV([[n,e],[t,i]],r){let s=(i-e)*r,o=(t-n)*r;return[[n-o,e-s],[t+o,i+s]]}function Xb(n,e=256,t=null){if(!T3(n))return null;let i=n[0][0],r=n[0][1],s=Math.max(n[1][1]-r,n[1][0]-i),o=e/s,a=T3(t)?t:n,[[c,l],[u,f]]=CV(a,PV);return{scale:o,maxDXDY:s,originX:r,originY:i,fitRect:Ot(l,c,f,u,o,r,i)}}function T3(n){return!!n&&n[1][0]>n[0][0]&&n[1][1]>n[0][1]}function R3(n,e){return!!n&&!!e&&n[0][0]===e[0][0]&&n[0][1]===e[0][1]&&n[1][0]===e[1][0]&&n[1][1]===e[1][1]}function St(n){n.selectionToken=(n.selectionToken||0)+1;for(let e of n.selectionResetters||[])e();return n.selectionToken}function Dt(n,e){return n.selectionToken===e}function I3(n,e){n.selectionResetters||(n.selectionResetters=[]),n.selectionResetters.push(e)}var Kb=80,zl=10,Ul=1e3;function $l(n){let e=n===""||n===null?NaN:Math.round(Number(n));return Number.isFinite(e)?Math.min(Ul,Math.max(zl,e)):Kb}function vs(n="vis-group-header"){let e=document.createElement("div");e.className=n;let t=document.createElement("span");t.className="vis-arrow",e.appendChild(t);let i=document.createElement("span");return i.className="vis-name",e.appendChild(i),{header:e,arrow:t,name:i}}function xs(n,e,t,i){let r=s=>{t.classList.toggle("collapsed",s),e.textContent=s?"\u25B6":"\u25BC"};r(!!i),n.addEventListener("click",s=>{let o=s.target&&s.target.parentNode===n&&s.target.classList&&s.target.classList.contains("vis-name");s.target!==n&&s.target!==e&&!o||r(!t.classList.contains("collapsed"))})}var L3=30;function B3(n,e=8){if(!Number.isFinite(n)||n<=0)return L3;let t=Math.ceil(Math.log2(e/n));return Math.max(1,Math.min(L3,t))}function O3({designBounds:n,fitRect:e,viewW:t,viewH:i}){let r=Xb(n,ki,e),s=h=>Number.isFinite(h)&&h>0;if(!r||!s(t)||!s(i))return ki;let o=r.fitRect[2]-r.fitRect[0],a=r.fitRect[3]-r.fitRect[1],c=Math.min(t/o,i/a),l=Math.log2(c);if(!Number.isFinite(l)||l<0)return ki;let u=Math.floor(l),f=ki*2**(l-u),d=Math.floor(f/Gb)*Gb;return d>ki&&Math.log2(ki*c/d)>=u?d:ki}function D3(n,{showDbu:e,dbuPerMicron:t},i=!1){if(e)return String(Math.round(n));let r=t>0?t:1e3,s=Math.ceil(Math.log10(r)),o=(n/r).toFixed(s);return i?o+" \xB5m":o}function N3(n,{showDbu:e,dbuPerMicron:t}){let i=parseFloat(n);if(!Number.isFinite(i))return null;if(e)return Math.round(i);let r=t>0?t:1e3;return Math.round(i*r)}function F3(n,{showDbu:e,dbuPerMicron:t}){if(e)return String(Math.round(n));let i=t>0?t:1e3,r=n/i;return r>=1e3?(r/1e3).toFixed(3)+" mm":r>=1?r.toFixed(3)+" um":(r*1e3).toFixed(1)+" nm"}function z3({showDbu:n}){return n?"DBU":"\xB5m"}function Zo(n){return typeof n=="string"&&/^#[0-9a-fA-F]{6}$/.test(n)}function U3(n){if(typeof n!="string")return null;let e=n.trim();if(Zo(e))return e.toLowerCase();let t=e.match(/^#([0-9a-fA-F]{3})$/);if(t)return"#"+t[1].split("").map(r=>r+r).join("").toLowerCase();let i=e.match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/);if(i){let r=i.slice(1).map(Number);return r.some(s=>s>255)?null:"#"+r.map(s=>s.toString(16).padStart(2,"0")).join("")}return null}function cr(n,e=t=>requestAnimationFrame(t)){let t=!1;return()=>{t||(t=!0,e(()=>{t=!1,n()}))}}function Gl(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function M3(n){let e=Math.pow(10,Math.floor(Math.log10(n))),t=n/e,i;return t<1.5?i=1:t<3.5?i=2:t<7.5?i=5:i=10,{value:i*e,digit:i}}function $3({targetPx:n,pxPerDbu:e,dbuPerMicron:t,showDbu:i}){if(!Number.isFinite(e)||e<=0||!Number.isFinite(n)||n<=0)return null;let r,s,o;if(i){let c=M3(Math.max(1,n/e));o=c.digit,r=Math.round(c.value*e),s=String(Math.round(c.value))}else{let c=Number.isFinite(t)&&t>0?t:1e3,l=e*c,u=M3(n/l);o=u.digit;let f=u.value;r=Math.round(f*l);let d,h;f>=1e3?(d=1/1e3,h="mm"):f>=1?(d=1,h="\xB5m"):f>=.001?(d=1e3,h="nm"):(d=1e6,h="pm"),s=Math.round(f*d)+" "+h}return{barPx:r,label:s,segments:o===1?5:o}}function Vl(n,e,t){return e?typeof n.runTclScript=="function"?n.runTclScript(e,t):(t&&typeof n.echoTcl=="function"&&n.echoTcl(e),n.websocketManager.request({type:"tcl_eval",cmd:e}).catch(()=>{})):Promise.resolve()}function ws(n,e){let t=n.querySelectorAll("thead th");(!e||!e[0])&&(n.style.tableLayout="auto",t.forEach(i=>i.style.width=""),e=Array.from(t,i=>i.offsetWidth+"px")),t.forEach((i,r)=>i.style.width=e[r]||""),n.style.tableLayout="fixed",t.forEach((i,r)=>{if(r===t.length-1)return;let s=document.createElement("div");s.className="col-resize-grip",i.style.position="relative",i.appendChild(s);let o,a,c=u=>{i.style.width=Math.max(30,a+u.clientX-o)+"px"},l=()=>{document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",l);let u=f=>f.stopPropagation();document.addEventListener("click",u,{capture:!0,once:!0}),setTimeout(()=>{document.removeEventListener("click",u,{capture:!0})},0)};s.addEventListener("mousedown",u=>{u.preventDefault(),o=u.clientX,a=i.offsetWidth,document.addEventListener("mousemove",c),document.addEventListener("mouseup",l)})})}var TV={Layout:'',Schematic:'',"3D Viewer":'',"Display Controls":'',Inspector:'',Hierarchy:'',Timing:'',DRC:'',"Select Highlight":'',"Clock Tree":'',Charts:'',"Tcl Console":'',Help:''};function LV(n){let e=TV[n];if(!e)return null;let t=document.createElement("span");return t.className="or-tab-icon",t.innerHTML='",t}function G3(n=document){let e=0;for(let t of n.querySelectorAll(".lm_tab:not([data-or-icon])")){let i=t.querySelector(".lm_title");if(!i)continue;let r=i.textContent.trim();if(!r)continue;t.setAttribute("data-or-icon","");let s=LV(r);s&&(t.insertBefore(s,i),e++)}return e}function Xo(n,e,t,i){let r=document.createElement("div");r.className="modal-overlay",r.innerHTML=` + `}};customElements.get("ide-pane")||customElements.define("ide-pane",Db);customElements.get("ide-splitter")||customElements.define("ide-splitter",Ch);customElements.get("ide-tab")||customElements.define("ide-tab",Fb);var r3={DisplayControls:{pane:"left",title:"Display Controls",closable:!1},LayoutViewer:{pane:"main",title:"Layout",closable:!1},SchematicWidget:{pane:"main",title:"Schematic",closable:!0},"3DViewer":{pane:"main",title:"3D Viewer",closable:!0},TclConsole:{pane:"bottom",title:"Tcl Console",closable:!1},Inspector:{pane:"right",title:"Inspector",closable:!0},Browser:{pane:"right",title:"Hierarchy",closable:!0},TimingWidget:{pane:"right",title:"Timing",closable:!0},DRCWidget:{pane:"right",title:"DRC",closable:!0},SelectHighlight:{pane:"right",title:"Select Highlight",closable:!0},ClockWidget:{pane:"right",title:"Clock Tree",closable:!0},ChartsWidget:{pane:"right",title:"Charts",closable:!0},HelpWidget:{pane:"right",title:"Help",closable:!0}},Ph={left:{cssVar:"--pane-left-width",defaultSize:"240px",minSize:140,maxFraction:.45,dimension:"width",isVertical:!0,invertDelta:!1},right:{cssVar:"--pane-right-width",defaultSize:"340px",minSize:160,maxFraction:.5,dimension:"width",isVertical:!0,invertDelta:!0},bottom:{cssVar:"--pane-bottom-height",defaultSize:"220px",minSize:70,maxFraction:.75,dimension:"height",isVertical:!1,invertDelta:!0}},Th=class{constructor(e){this.containerEl=e,this.factories=new Map,this.components=new Map,this.activeTabs={left:null,main:null,bottom:null,right:null},this.closedComponents=new Set,this.eventListeners=new Map,this._resizeScheduled=!1,this._ensureDOM(),this._initSplitters(),this._initControls(),this._initResizeObserver()}on(e,t){this.eventListeners.has(e)||this.eventListeners.set(e,new Set),this.eventListeners.get(e).add(t)}off(e,t){this.eventListeners.get(e)?.delete(t)}emit(e,...t){let i=this.eventListeners.get(e);if(i)for(let r of i)try{r(...t)}catch(s){console.error(s)}}_ensureDOM(){this.containerEl.classList.add("ide-layout"),this.containerEl.querySelector("#pane-left")||this._buildInitialLayoutTree(),this._resolvePaneReferences()}_buildInitialLayoutTree(){this.containerEl.appendChild(this._createGutterButton("left","\u25B6 Display Controls","Restore Display Controls")),this.containerEl.appendChild(this._createGutterButton("right","\u25C0 Tools & Inspector","Restore Right Panel")),this.containerEl.appendChild(this._createPane("pane-left","left")),this.containerEl.appendChild(this._createSplitter("splitter-left","left","vertical","Drag to resize panel"));let e=document.createElement("main");e.id="pane-center",e.className="ide-center",e.appendChild(this._createPane("pane-main","main",{maximizable:!0})),e.appendChild(this._createSplitter("splitter-bottom","bottom","horizontal","Drag to resize console")),e.appendChild(this._createGutterButton("bottom","\u25B2 Tcl Console","Restore Tcl Console")),e.appendChild(this._createPane("pane-bottom","bottom",{maximizable:!0,collapsible:!0})),this.containerEl.appendChild(e),this.containerEl.appendChild(this._createSplitter("splitter-right","right","vertical","Drag to resize panel")),this.containerEl.appendChild(this._createPane("pane-right","right",{maximizable:!0,collapsible:!0}))}_createGutterButton(e,t,i){let r=document.createElement("button");r.id=`gutter-expand-${e}`,r.className=`ide-gutter-expand ide-gutter-${e}`,r.title=i;let s=document.createElement("span");return s.textContent=t,r.appendChild(s),r}_createPane(e,t,i={}){let r=document.createElement("ide-pane");return r.id=e,r.setAttribute("name",t),i.maximizable&&r.setAttribute("maximizable",""),i.collapsible&&r.setAttribute("collapsible",""),r}_createSplitter(e,t,i,r){let s=document.createElement("ide-splitter");return s.id=e,s.setAttribute("for",t),s.setAttribute("orientation",i),s.title=r,s}_resolvePaneReferences(){let e=["left","main","bottom","right"];this.panes={};for(let t of e){let i=this.containerEl.querySelector(`#pane-${t}`);i?.build&&i.build(),this.panes[t]={el:i,paneComponent:i,tabsEl:i?.tabsEl||this.containerEl.querySelector(`#pane-${t}-tabs`),contentEl:i?.contentEl||this.containerEl.querySelector(`#pane-${t}-content`)}}this.centerEl=this.containerEl.querySelector("#pane-center")}_initSplitters(){let e=null;this.containerEl.addEventListener("ide-splitter-start",t=>{let i=t.detail?.for,r=Ph[i];if(!r)return;let o=(i==="bottom"?this.centerEl||this.containerEl:this.containerEl).getBoundingClientRect(),a=this.panes[i]?.el?.getBoundingClientRect()||{},c=r.dimension==="width"?o.width:o.height,l=r.dimension==="width"?a.width||240:a.height||220;e={paneName:i,cfg:r,startSize:l,maxLimit:Math.round(c*r.maxFraction)||500}}),this.containerEl.addEventListener("ide-splitter-drag",t=>{if(!e||e.paneName!==t.detail?.for)return;let{cfg:i,startSize:r,maxLimit:s}=e,o=i.invertDelta?-t.detail.delta:t.detail.delta,a=Math.round(r+o),c=Math.max(i.minSize,Math.min(s,a));this.containerEl.style.setProperty(i.cssVar,`${c}px`),this.notifyResize()}),this.containerEl.addEventListener("ide-splitter-end",()=>{e=null,this.saveLayout(),this.notifyResize()}),this.containerEl.addEventListener("ide-splitter-reset",t=>{let i=t.detail?.for;this._resetSplitterPane(i)}),this._setupFallbackSplitters()}_resetSplitterPane(e){let t=Ph[e];t&&(this.containerEl.style.setProperty(t.cssVar,t.defaultSize),this.isPaneCollapsed(e)?this.restorePane(e):(this.saveLayout(),this.notifyResize()))}_setupFallbackSplitters(){for(let[e,t]of Object.entries(Ph)){let i=this.containerEl.querySelector(`#splitter-${e}`);if(!i||i instanceof Ch)continue;let r=!t.invertDelta,s=t.isVertical;i.addEventListener("pointerdown",o=>{o.preventDefault();try{i.setPointerCapture(o.pointerId)}catch{}i.classList.add("dragging"),document.body&&document.body.classList.add("is-resizing",s?"is-resizing-v":"is-resizing-h");let a=s?o.clientX:o.clientY,l=(e==="bottom"?this.centerEl||this.containerEl:this.containerEl).getBoundingClientRect(),u=this.panes[e]?.el?.getBoundingClientRect()||{},f=t.dimension==="width"?u.width||240:u.height||220,d=t.dimension==="width"?l.width:l.height,h=Math.round(d*t.maxFraction)||500,p=new AbortController,{signal:m}=p,g=y=>{let b=s?y.clientX:y.clientY,x=r?b-a:a-b,E=Math.round(f+x),w=Math.max(t.minSize,Math.min(h,E));this.containerEl.style.setProperty(t.cssVar,`${w}px`),this.notifyResize()},v=y=>{try{i.releasePointerCapture(y.pointerId)}catch{}i.classList.remove("dragging"),document.body&&document.body.classList.remove("is-resizing","is-resizing-v","is-resizing-h"),p.abort(),this.saveLayout(),this.notifyResize()};window.addEventListener("pointermove",g,{signal:m}),window.addEventListener("pointerup",v,{signal:m}),window.addEventListener("pointercancel",v,{signal:m})}),i.addEventListener("dblclick",()=>{this._resetSplitterPane(e)})}}_initControls(){this.containerEl.addEventListener("ide-pane-maximize",t=>{this.toggleMaximize(t.detail?.pane)}),this.containerEl.addEventListener("ide-pane-collapse",t=>{this.toggleCollapse(t.detail?.pane)}),this.containerEl.addEventListener("ide-layout-reset",()=>{this.resetLayout()});for(let t of["left","right","bottom"]){let i=this.containerEl.querySelector(`#gutter-expand-${t}`);i&&i.addEventListener("click",()=>this.restorePane(t))}let e=[{sel:"#btn-collapse-left",handler:()=>this.toggleCollapse("left")},{sel:"#btn-collapse-right",handler:()=>this.toggleCollapse("right")},{sel:"#btn-collapse-bottom",handler:()=>this.toggleCollapse("bottom")},{sel:"#btn-maximize-main",handler:()=>this.toggleMaximize("main")},{sel:"#btn-maximize-bottom",handler:()=>this.toggleMaximize("bottom")},{sel:"#btn-maximize-right",handler:()=>this.toggleMaximize("right")},{sel:"#btn-empty-reset-layout",handler:()=>this.resetLayout()}];for(let{sel:t,handler:i}of e){let r=this.containerEl.querySelector(t);r&&!r.closest("ide-pane")&&r.addEventListener("click",i)}}isPaneMaximized(e){return e?this.containerEl.classList.contains(`maximized-${e}`):this.containerEl.classList.contains("maximized-main")||this.containerEl.classList.contains("maximized-bottom")||this.containerEl.classList.contains("maximized-right")}setMaximizedPane(e,t=!0){let i=["main","bottom","right"];if(e&&!i.includes(e))return!1;let r=t?e:null;for(let s of i){let o=s===r;this.containerEl.classList.toggle(`maximized-${s}`,o),this.panes[s]?.paneComponent?.setMaximized(o);let a=this.containerEl.querySelector(`#btn-maximize-${s}`);a&&(a.textContent=o?"\u29C9":"\u2922",a.title=o?"Restore":"Maximize")}return this.notifyResize(),!!r}maximizePane(e){return this.setMaximizedPane(e,!0)}restoreMaximized(){return this.setMaximizedPane(null,!1)}toggleMaximize(e){return this.setMaximizedPane(e,!this.isPaneMaximized(e))}isPaneCollapsed(e){let t=e==="bottom"?this.centerEl:this.containerEl;return t?t.classList.contains(`hide-${e}`):!1}_setPaneCollapsed(e,t){let i=e==="bottom"?this.centerEl:this.containerEl;if(!i)return;i.classList.toggle(`hide-${e}`,t),this.panes[e]?.paneComponent?.setCollapsed?.(t);let r=this.containerEl.querySelector(`#btn-collapse-${e}`);if(r){let o={bottom:{collapsed:"\u25B2",expanded:"\u25BC"},left:{collapsed:"\u25B6",expanded:"\u25C0"},right:{collapsed:"\u25C0",expanded:"\u25B6"}}[e]||{collapsed:"\u25B6",expanded:"\u25C0"};r.textContent=t?o.collapsed:o.expanded,r.title=t?`Expand ${e.charAt(0).toUpperCase()+e.slice(1)}`:`Collapse ${e.charAt(0).toUpperCase()+e.slice(1)}`}this.saveLayout(),this.notifyResize()}toggleCollapse(e){this._setPaneCollapsed(e,!this.isPaneCollapsed(e))}collapsePane(e){this._setPaneCollapsed(e,!0)}restorePane(e){this._setPaneCollapsed(e,!1)}_updateEmptyState(){let e=this.containerEl.querySelector("#ide-empty-state");if(!e)return;let t=!!this.activeTabs.main;e.style.display=t?"none":"flex"}resetLayout(){try{localStorage.removeItem("or_ide_layout")}catch{}for(let[e,t]of Object.entries(Ph))this.containerEl.style.setProperty(t.cssVar,t.defaultSize);for(let e of["left","right","bottom"])this.restorePane(e);this.restoreMaximized(),this.closedComponents.clear();for(let e of this.components.values())e.tabEl.style.display="",e.contentDiv.style.display="";this.components.has("DisplayControls")&&this.activateTab("DisplayControls"),this.components.has("LayoutViewer")&&this.activateTab("LayoutViewer"),this.components.has("TclConsole")&&this.activateTab("TclConsole"),this.components.has("Inspector")&&this.activateTab("Inspector"),this._updateEmptyState(),this.saveLayout(),this.notifyResize(),this.emit("stateChanged"),typeof app<"u"&&app.map&&setTimeout(()=>app.map.invalidateSize({animate:!1}),0)}_initResizeObserver(){typeof ResizeObserver<"u"&&new ResizeObserver(()=>{this.notifyResize()}).observe(this.containerEl)}registerComponentFactoryFunction(e,t){this.factories.set(e,t)}loadLayout(e){for(let[i,r]of Object.entries(r3)){let s=this.factories.get(i);s&&this._mountComponent(i,r.pane,r.title,r.closable,s)}let t=null;try{let i=localStorage.getItem("or_ide_layout");i&&(t=JSON.parse(i))}catch{}if(t){if(t.leftWidth&&this.containerEl.style.setProperty("--pane-left-width",`${t.leftWidth}px`),t.rightWidth&&this.containerEl.style.setProperty("--pane-right-width",`${t.rightWidth}px`),t.bottomHeight&&this.containerEl.style.setProperty("--pane-bottom-height",`${t.bottomHeight}px`),t.closed)for(let i of t.closed)this.closeComponent(i,!1);this.activateTab(t.activeTabs?.left||"DisplayControls"),this.activateTab(t.activeTabs?.main||"LayoutViewer"),this.activateTab(t.activeTabs?.bottom||"TclConsole"),this.activateTab(t.activeTabs?.right||"Inspector"),t.hideLeft&&this.collapsePane("left"),t.hideRight&&this.collapsePane("right"),t.hideBottom&&this.collapsePane("bottom")}else this.activateTab("DisplayControls"),this.activateTab("LayoutViewer"),this.activateTab("TclConsole"),this.activateTab("Inspector");this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}_mountComponent(e,t,i,r,s){if(this.components.has(e))return;let o=this.panes[t];if(!o)return;let a=document.createElement("div");a.className="ide-component-container",a.id=`cmp-${e}`,o.contentEl.appendChild(a);let c=document.createElement("ide-tab");c.id=`tab-${e}`,c.setAttribute("for",e),c.setAttribute("data-component",e),c.setAttribute("title",i),r&&c.setAttribute("closable",""),c.addEventListener("tab-select",()=>{this.activateTab(e)}),c.addEventListener("tab-close",()=>{this.closeComponent(e)}),o.tabsEl.appendChild(c);let l=new Map,u={element:a,get width(){return a.clientWidth},get height(){return a.clientHeight},title:i,on:(d,h)=>{l.has(d)||l.set(d,new Set),l.get(d).add(h)},off:(d,h)=>{l.get(d)?.delete(h)},fire:(d,...h)=>{let p=l.get(d);if(p)for(let m of p)try{m(...h)}catch(g){console.error(g)}},focus:()=>this.focusComponent(e),close:()=>this.closeComponent(e)},f={componentType:e,paneName:t,title:i,closable:r,tabEl:c,contentDiv:a,container:u};this.components.set(e,f);try{s(u)}catch(d){console.error(`Failed to initialize component ${e}:`,d)}}isComponentActive(e){return e?!!e.contentDiv?.classList.contains("active"):!1}_setComponentActive(e,t){if(!e)return;let i=!!t;e.tabEl?.setActive(i),e.contentDiv?.classList.toggle("active",i)}activateTab(e){let t=this.components.get(e);if(!t||!this.panes[t.paneName])return;["left","right","bottom"].includes(t.paneName)&&this.isPaneCollapsed(t.paneName)&&this.restorePane(t.paneName);let r=this.activeTabs[t.paneName];if(r&&r!==e){let s=this.components.get(r);s&&(this._setComponentActive(s,!1),s.container.fire("hide"))}this.activeTabs[t.paneName]=e,t.tabEl.style.display="",t.contentDiv.style.display="",this._setComponentActive(t,!0),this.closedComponents.delete(e),t.container.fire("show"),t.container.fire("open"),t.container.fire("resize"),typeof app<"u"&&(e==="LayoutViewer"&&app.map&&setTimeout(()=>app.map.invalidateSize({animate:!1}),0),e==="3DViewer"&&app.threeDViewerWidget&&setTimeout(()=>app.threeDViewerWidget.onOpen(),0));try{t.tabEl.scrollIntoView({behavior:"smooth",inline:"nearest",block:"nearest"})}catch{}this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}closeComponent(e,t=!0){let i=this.components.get(e);if(!(!i||!i.closable)){if(i.tabEl.style.display="none",i.contentDiv.style.display="none",this._setComponentActive(i,!1),i.container.fire("hide"),this.closedComponents.add(e),t&&this.activeTabs[i.paneName]===e){let r=null;for(let s of this.components.values())if(s.paneName===i.paneName&&!this.closedComponents.has(s.componentType)){r=s;break}r?this.activateTab(r.componentType):(this.activeTabs[i.paneName]=null,["left","right","bottom"].includes(i.paneName)&&this.collapsePane(i.paneName))}this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}}focusComponent(e){if(!this.components.get(e)){let i=this.factories.get(e);if(i){let r=r3[e]||{pane:"right",title:e,closable:!0};this._mountComponent(e,r.pane,r.title,r.closable,i)}else return}this.activateTab(e)}saveLayout(){let e={leftWidth:parseInt(this.containerEl.style.getPropertyValue("--pane-left-width")||"240",10),rightWidth:parseInt(this.containerEl.style.getPropertyValue("--pane-right-width")||"340",10),bottomHeight:parseInt(this.containerEl.style.getPropertyValue("--pane-bottom-height")||"220",10),hideLeft:this.isPaneCollapsed("left"),hideRight:this.isPaneCollapsed("right"),hideBottom:this.isPaneCollapsed("bottom"),activeTabs:{...this.activeTabs},closed:Array.from(this.closedComponents)};try{localStorage.setItem("or_ide_layout",JSON.stringify(e))}catch{}return e}notifyResize(){if(this._resizeScheduled)return;this._resizeScheduled=!0,(typeof requestAnimationFrame=="function"?requestAnimationFrame:t=>{t()})(()=>{this._resizeScheduled=!1;for(let t of this.components.values())this.isComponentActive(t)&&t.container.fire("resize");typeof app<"u"&&app&&app.map&&app.map.invalidateSize({animate:!1}),window.dispatchEvent(new Event("resize"))})}updateSize(){this.notifyResize()}setSize(e,t){this.notifyResize()}addComponent(e,t,i){this.focusComponent(e)}get rootItem(){return{contentItems:Array.from(this.components.keys()).map(e=>({isComponent:!0,componentType:e,focus:()=>this.focusComponent(e)}))}}};function Sn(n,e,t,i=0,r=0){return[(n-i)*t,(e-r)*t]}function Pn(n,e,t,i=0,r=0){return{dbuX:Math.round(i+n/t),dbuY:Math.round(r+e/t)}}function Nt(n,e,t,i,r,s=0,o=0){let[a,c]=Sn(n,e,r,s,o),[l,u]=Sn(t,i,r,s,o);return[Math.min(a,l),Math.min(c,u),Math.max(a,l),Math.max(c,u)]}var Nl=class n{constructor(e,t){this.url=e,this.socket=null,this.nextId=1,this.pending=new Map,this._queue=new Map,this._bgQueue=new Map,this._bgSent=new Set,this._inFlight=0,this._inFlightIds=new Set,this._unknownPayloadTypes=new Set,this._maxInFlight=48,this._lastRecvAt=0,this._bufStuckSince=0,this._lastBuffered=0,this.reconnectDelay=1e3,this.readyPromise=null,this.readyResolve=null,this.onStatusChange=t||(()=>{}),this.onPush=null,this._cache=null,this._isConnected=!1,this._shutdown=!1,this._livenessTimer=void 0,this._startLivenessMonitor(),this.connect()}get isConnected(){return this._isConnected||this.socket&&this.socket.readyState===WebSocket.OPEN}get pendingCount(){return this.pending.size-this._bgSent.size+(this._queue?this._queue.size:0)}static fromCache(e,t){let i=Object.create(n.prototype);return i.url=null,i.socket=null,i.nextId=1,i.pending=new Map,i._queue=new Map,i._bgQueue=new Map,i._bgSent=new Set,i._inFlight=0,i._inFlightIds=new Set,i._unknownPayloadTypes=new Set,i._maxInFlight=48,i._lastRecvAt=0,i.reconnectDelay=0,i.onStatusChange=t||(()=>{}),i.onPush=null,i._cache=e,i._isConnected=!0,i.readyPromise=Promise.resolve(),i.readyResolve=null,i}get isStaticMode(){return!!this._cache}connect(){this.readyPromise=new Promise(e=>{this.readyResolve=e}),this.socket=new WebSocket(this.url),this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{console.log("WebSocket connected");let e=this._everConnected===!0;this._everConnected=!0,this._isConnected=!0,this.reconnectDelay=1e3,this._lastRecvAt=typeof performance<"u"?performance.now():0,this.readyResolve(),this.onStatusChange(),this._pump(),e&&this.onReconnected&&this.onReconnected()},this.socket.onmessage=e=>{this.handleMessage(e.data)},this.socket.onclose=()=>this._handleClose(),this.socket.onerror=e=>{console.error("WebSocket error:",e)}}_handleClose(){this._isConnected=!1,this._inFlight=0,this._inFlightIds.clear(),this._bufStuckSince=0,this.onStatusChange();for(let[e,t]of this.pending)t.reject(new Error("WebSocket closed"));this.pending.clear(),this._bgSent.clear();for(let e of[this._queue,this._bgQueue]){for(let[t,i]of e)i.reject(new Error("WebSocket closed"));e.clear()}if(this._shutdown){console.log("WebSocket closed (server stopped)"),this._stopLivenessMonitor();return}console.log("WebSocket closed, reconnecting..."),setTimeout(()=>this.connect(),this.reconnectDelay),this.reconnectDelay=Math.min(this.reconnectDelay*2,3e4)}_forceReconnect(){let e=this.socket;if(this.socket=null,e){e.onopen=null,e.onmessage=null,e.onclose=null,e.onerror=null;try{e.close()}catch{}}this._handleClose()}handleMessage(e){let t=new DataView(e),i=t.getUint32(0),r=t.getUint8(4);if(this._lastRecvAt=typeof performance<"u"?performance.now():0,i===0&&r===0){let a=e.slice(8),c;try{c=JSON.parse(new TextDecoder().decode(a))}catch(l){console.error("Failed to parse server push JSON:",l);return}if(c&&c.type==="config"){Number.isFinite(c.max_in_flight)&&(this._maxInFlight=Math.max(1,Math.min(4096,Math.floor(c.max_in_flight))),this._pump());return}this.onPush&&this.onPush(c);return}this._inFlightIds.delete(i)&&this._inFlight>0&&this._inFlight--;let s=this.pending.get(i);if(!s){this._pump();return}this.pending.delete(i),this._bgSent.delete(i),this._pump(),this.onStatusChange();let o=e.slice(8);if(r===2)s.reject(new Error(new TextDecoder().decode(o)));else if(r===0)try{s.resolve(JSON.parse(new TextDecoder().decode(o)))}catch(a){s.reject(new Error("JSON parse error: "+a.message))}else r===1?s.resolve(new Blob([o],{type:"image/png"})):r===3?s.resolve(null):(this._unknownPayloadTypes.has(r)||(this._unknownPayloadTypes.add(r),console.warn(`Unrecognized websocket payload type ${r}. The server is likely newer than this page \u2014 reload to pick up the current client.`)),s.reject(new Error(`Unsupported websocket payload type ${r}`)))}request(e,{background:t=!1}={}){if(this._cache)return this._cacheRequest(e);let i=this.nextId++;if(e.id=i,!this.socket||this.socket.readyState!==WebSocket.OPEN)return Promise.reject(new Error("WebSocket not connected"));let r,s,o=new Promise((a,c)=>{r=a,s=c});return o.requestId=i,(t?this._bgQueue:this._queue).set(i,{msg:e,resolve:r,reject:s}),this._pump(),o}_pump(){if(!(!this.socket||this.socket.readyState!==WebSocket.OPEN)){for(;this._inFlight0||this._bgQueue.size>0)&&this.socket.bufferedAmount<524288;){let e=this._queue.size===0,t=e?this._bgQueue:this._queue,[i,r]=t.entries().next().value;t.delete(i),this.pending.set(i,{resolve:r.resolve,reject:r.reject}),e&&this._bgSent.add(i),this.socket.send(JSON.stringify(r.msg)),this._inFlightIds.add(i),this._inFlight++}this.onStatusChange()}}promote(e){let t=this._bgQueue.get(e);t?(this._bgQueue.delete(e),this._queue.set(e,t),this._pump()):this._bgSent.delete(e)&&this.onStatusChange()}cancel(e){let t=this._queue.get(e)||this._bgQueue.get(e);if(t){this._queue.delete(e),this._bgQueue.delete(e),t.reject(new Error("Request cancelled")),this.onStatusChange();return}let i=this.pending.get(e),r=this.pending.delete(e);this._bgSent.delete(e),i&&i.reject(new Error("Request cancelled")),r&&!this._cache&&this.socket&&this.socket.readyState===WebSocket.OPEN&&this.socket.send(JSON.stringify({type:"cancel",cancel_id:e,id:this.nextId++})),this.onStatusChange()}_startLivenessMonitor(){typeof setInterval>"u"||(this._livenessTimer=setInterval(()=>this._checkLiveness(),3e3),this._livenessTimer&&typeof this._livenessTimer.unref=="function"&&this._livenessTimer.unref())}_stopLivenessMonitor(){this._livenessTimer!==void 0&&typeof clearInterval<"u"&&(clearInterval(this._livenessTimer),this._livenessTimer=void 0)}_checkLiveness(){if(this._cache)return;let e=this.socket;if(!e||e.readyState!==WebSocket.OPEN){this._bufStuckSince=0,this._lastBuffered=0;return}let t=e.bufferedAmount,i=typeof performance<"u"?performance.now():0,r=!1,s="";t<=262144||t12e3&&(r=!0,s=`send buffer stuck at ${t}B for ${Math.round(i-this._bufStuckSince)}ms`),this._lastBuffered=t,!r&&this._inFlight>=this._maxInFlight&&this._queue.size+this._bgQueue.size>0&&this._lastRecvAt>0&&i-this._lastRecvAt>3e4&&(r=!0,s=`saturated (${this._inFlight} in flight, ${this._queue.size} queued) but silent for ${Math.round(i-this._lastRecvAt)}ms`),r&&(console.warn(`WebSocket connection wedged \u2014 ${s}; reconnecting to recover`),this._bufStuckSince=0,this._forceReconnect())}_cacheRequest(e){let t=e.type;if(t==="tile"){let s=e.layer+"/"+e.z+"/"+e.x+"/"+e.y,o=this._cache.tiles&&this._cache.tiles[s];return o?Promise.resolve("data:image/png;base64,"+o):Promise.reject(new Error("Tile not cached: "+s))}if(t==="timing_highlight"){let s=e.path_index;if(s>=0&&this._cache.overlays){let o=e.is_setup?"setup":"hold",a=this._cache.overlays[o]?.[s];this._cache.setPathOverlay&&this._cache.setPathOverlay(a?"data:image/png;base64,"+a:null)}else this._cache.setPathOverlay&&this._cache.setPathOverlay(null);return Promise.resolve({})}if(t==="set_module_colors")return Promise.resolve({ok:1,count:0});let i=t;t==="timing_report"?i="timing_report:"+(e.is_setup?"setup":"hold"):t==="slack_histogram"&&(i="slack_histogram:"+(e.is_setup?"setup":"hold"));let r=this._cache.json&&this._cache.json[i];if(r!==void 0){if(t==="timing_report"&&e.slack_min!=null&&e.slack_max!=null&&r.paths){let s=[];return r.paths.forEach((o,a)=>{o.slack>=e.slack_min&&o.slacko||a>c?null:{z:e,x0:s,x1:o,y0:a,y1:c}}function Ub([n,e,t,i],r){let s=(t-n)*r,o=(i-e)*r;return[n-s,e-o,t+s,i+o]}function Ah(n,e=1){if(!n)return null;let t=Math.pow(2,n.z);return{z:n.z,x0:Math.max(0,n.x0-e),x1:Math.min(t-1,n.x1+e),y0:Math.max(0,n.y0-e),y1:Math.min(t-1,n.y1+e)}}function St(n,e,t){return!!n&&e>=n.x0&&e<=n.x1&&t>=n.y0&&t<=n.y1}function zl(n){if(!n)return[];let e=(n.x0+n.x1)/2,t=(n.y0+n.y1)/2,i=[];for(let r=n.y0;r<=n.y1;r++)for(let s=n.x0;s<=n.x1;s++)i.push({z:n.z,x:s,y:r,d:(s-e)**2+(r-t)**2});return i.sort((r,s)=>r.d-s.d),i.map(({z:r,x:s,y:o})=>({z:r,x:s,y:o}))}function o3(n,e,t,i){let r=i/Math.pow(2,n);return[e*r,i-(t+1)*r,(e+1)*r,i-t*r]}function $b(n,e){return n[0]Math.log2(s/T);if(p<1e-12){let T=Math.log(f/u)/t;return{S:Math.abs(T),at:R=>({target:[o+R*d,a+R*h],zoom:m(u*Math.exp(t*R*T))})}}let g=Math.sqrt(p),v=(f*f-u*u+r*p)/(2*u*i*g),y=(f*f-u*u-r*p)/(2*f*i*g),b=Math.log(Math.sqrt(v*v+1)-v),E=(Math.log(Math.sqrt(y*y+1)-y)-b)/t,w=Math.cosh(b);return{S:E,at:T=>{if(T>=1)return{target:[c,l],zoom:e.zoom};let R=T*E,F=u/(i*g)*(w*Math.tanh(t*R+b)-Math.sinh(b));return{target:[o+F*d,a+F*h],zoom:m(u*w/Math.cosh(t*R+b))}}}}function Ho(n,e,t){return`${n}/${e}/${t}`}var kh=class{constructor({source:e,onChange:t=()=>{},keepBuffer:i=2}={}){this.source=e,this.onChange=t,this.keepBuffer=i,this.tiles=new Map,this.z=null,this.range=null,this.ring=null,this.extra=[],this._generation=0,this._loads=0,this._cancels=0}update({z:e,range:t,ring:i=t,extra:r=[],hold:s=null}){this.z=e,this.range=t,this.ring=i,this.extra=r.filter(c=>c.z!==e&&c.range);let o=new Map(this.extra.map(c=>[c.z,c]));for(let c of[...this.tiles.values()]){if(c.z!==e){let l=o.get(c.z),u=l&&l.range;(u?!St(u,c.x,c.y)&&(c.loading||!this._inKeepBuffer(c,u)):c.loading&&!c.drawable)?this._drop(c):u&&this._stale(c)&&St(u,c.x,c.y)&&this._load(c,l.background!==!1);continue}if(this._stale(c)&&St(i,c.x,c.y)&&this._load(c,!St(t,c.x,c.y)),St(i,c.x,c.y)){c.loading&&c.background&&St(t,c.x,c.y)&&(c.background=!1,c.handle?.promote?.());continue}(c.loading||!(this._inKeepBuffer(c)||s&&St(s,c.x,c.y)))&&this._drop(c)}let a=[...zl(t),...zl(i).filter(c=>!St(t,c.x,c.y))];for(let{x:c,y:l}of a)this.tiles.has(Ho(e,c,l))||this._load(this._newTile(e,c,l),!St(t,c,l));for(let c of this.extra)for(let{x:l,y:u}of zl(c.range))this.tiles.has(Ho(c.z,l,u))||this._load(this._newTile(c.z,l,u),c.background!==!1)}refresh(){this._generation++;let e=new Map(this.extra.map(t=>[t.z,t]));for(let t of[...this.tiles.values()]){let i=e.get(t.z),r=t.z===this.z?this.ring:i&&i.range;r&&(St(r,t.x,t.y)?(t.handle?.cancel?.(),this._load(t,i?i.background!==!1:!St(this.range,t.x,t.y))):t.loading&&this._drop(t))}}isSettled(){for(let e of this.tiles.values())if(e.z===this.z&&e.loading&&St(this.range,e.x,e.y))return!1;return!0}settledIn(e,t){for(let{x:i,y:r}of zl(t)){let s=this.tiles.get(Ho(e,i,r));if(!s||s.loading)return!1}return!0}hasContentAt(e){for(let t of this.tiles.values())if(t.z===e&&t.drawable)return!0;return!1}drawableTilesAt(e){let t=[];for(let i of this.tiles.values())i.z===e&&i.drawable&&t.push(i);return t}prune(e){let t=new Set(e);for(let i of[...this.tiles.values()])t.has(i.z)||this._drop(i)}clear(){for(let e of[...this.tiles.values()])this._drop(e);this.z=null,this.range=null,this.ring=null,this.extra=[]}stats(){let e=0,t=0;for(let i of this.tiles.values())i.loading&&e++,i.drawable&&t++;return{tiles:this.tiles.size,loading:e,drawable:t,loads:this._loads,cancels:this._cancels}}_newTile(e,t,i){let r={z:e,x:t,y:i,key:Ho(e,t,i),drawable:null,loading:!1,background:!1,handle:null,generation:-1};return this.tiles.set(r.key,r),r}_load(e,t){let i=this._generation,r=()=>this.tiles.get(e.key)===e&&e.generation===i;e.generation=i,e.loading=!0,e.background=t,this._loads++;let s=this.source.load({z:e.z,x:e.x,y:e.y},{background:t,onPartial:o=>{if(!r()){this.source.release?.(o);return}this._setDrawable(e,o),this.onChange(e)}});e.handle=s,s.promise.then(o=>{if(!r()){this.source.release?.(o);return}o!==void 0&&this._setDrawable(e,o),e.loading=!1,e.handle=null,this.onChange(e)},()=>{r()&&(e.loading=!1,e.handle=null,this.onChange(e))})}_setDrawable(e,t){e.drawable&&e.drawable!==t&&this.source.release?.(e.drawable),e.drawable=t||null}_stale(e){return!e.loading&&e.generation!==this._generation}_inKeepBuffer(e,t=this.range){return St(Ah(t,this.keepBuffer),e.x,e.y)}_drop(e){e.loading&&(this._cancels++,e.handle?.cancel?.()),e.drawable&&this.source.release?.(e.drawable),e.drawable=null,e.loading=!1,this.tiles.delete(e.key)}};function yV(n){return!Number.isFinite(n)||n<=1?1:Math.round(Math.min(n,3)*100)/100}var Di=240,bV=256,Gb=Di;function on(){return Gb}function l3(){Gb=bV}var Ibe=1/64,Vb=120;function u3(n){Gb=n}function Wb(n,e){return Math.max(1,Math.round(n*e))}function Yo(){let n=typeof window<"u"&&window.devicePixelRatio?window.devicePixelRatio:1;return!Number.isFinite(n)||n<=1?1:Math.min(n,3)}function Rh(n,e=on()){return{dpr:yV(n),tile_px:Wb(e,n)}}function f3(n,e,t,i=on()){let{selectability:r,selectableLayers:s,app:o}=e,a={...h3(n,e,t,i),selectable_layers:s?[...s]:[]};if(r)for(let[c,l]of Object.entries(r))a["s_"+c]=!!l;return c=>{let l={type:"tile",layer:c,...a},u=p3(o,c);return u!==1&&(l.pattern=u),l}}function d3(n,e,t,i,r=on()){let s={type:"tile_group",layers:[...e],...h3(n,t,i,r)},o=e.map(a=>p3(t.app,a));return o.some(a=>a!==1)&&(s.patterns=o),s}function h3(n,e,t,i){let{visibility:r,visibleLayers:s,app:o}=e,a={z:n.z,x:n.x,y:n.y,...Rh(t,i),visible_layers:s?[...s]:[]};for(let[c,l]of Object.entries(r||{}))a[c]=!!l;return o&&o.visibleChiplets instanceof Set&&(a.visible_chiplets=[...o.visibleChiplets]),a}function p3(n,e){let t=n&&n.layerPatterns?n.layerPatterns[e]:void 0;return t===void 0?1:t}function m3(n){if(typeof window>"u"||typeof window.matchMedia!="function"||typeof n!="function")return()=>{};let e=!1,t=null,i=null,r=()=>{if(e)return;let s=window.devicePixelRatio||1;t=window.matchMedia(`(resolution: ${s}dppx)`),i=()=>{e||(r(),n(window.devicePixelRatio||1))},t.addEventListener("change",i,{once:!0})};return r(),()=>{e=!0,t&&i&&t.removeEventListener("change",i),t=null,i=null}}function g3(n,e){if(!n)return!1;let t=!!e;return!!n.visible===t?!1:(n.visible=t,!0)}function _3(n,e,t){if(!n||!(t>0))return 0;n.clearRect(0,0,t,t);let i=0;for(let r of e||[]){let s=r?r.image:null;if(!s)continue;let o=r.opacity===void 0?1:r.opacity;o>0&&(n.globalAlpha=Math.min(1,o),n.drawImage(s,0,0,t,t),i++)}return n.globalAlpha=1,i}function jb(n){for(let e of n||[])e&&typeof e.close=="function"&&e.close()}async function y3({items:n,request:e,decode:t,draw:i,release:r=jb,isStale:s=()=>!1,incremental:o=!0}={}){let a=Array.isArray(n)?n:[],c={requested:a.length,arrived:0,decoded:0,drawn:0,paints:0,failed:0,stale:!1};if(a.length===0)return typeof i=="function"&&i([]),c;let l=new Array(a.length).fill(null),u=!1;function f(){if(s()){c.stale=!0;return}c.drawn=i(a.map((d,h)=>({image:l[h],opacity:d.opacity})))||0,c.paints++,u=!0}try{await Promise.all(a.map(async(d,h)=>{let p=null;try{p=await e(d)}catch{c.failed++;return}if(p==null)return;c.arrived++;let m=null;try{m=await t(p)}catch{return}m&&(l[h]=m,c.decoded++,o&&f())})),u||f()}finally{r(l)}return c}var vV=["tracks_pref","tracks_non_pref","debug","debug_renderers"],xV=1/16;function Hb(n,e){if(n==null)return!1;if(!Array.isArray(n)||n.length!==4||!e)return!0;let t=Math.pow(2,e.z),i=xV/t,r=e.x/t-i,s=e.y/t-i,o=(e.x+1)/t+i,a=(e.y+1)/t+i,[c,l,u,f]=n;return c<=o&&u>=r&&l<=a&&f>=s}function wV(n,e,t){let i=n&&Array.isArray(n.by_size)?n.by_size:[];if(i.length===0||!e||!(t>0))return!0;let r=n.min_css_px/(t*Math.pow(2,e.z)),s=i[0];for(let o of i)o[0]<=r&&(s=o);return Hb(s[1],e)}var Ih=class{constructor(){this._layers=null,this._gated=new Map,this._sized=new Map,this._generation=0}invalidate(){return this._generation++,this._layers=null,this._gated=new Map,this._sized=new Map,this._generation}apply(e,t){if(e!==this._generation)return!1;if(!t||t.supported!==!0||!t.layers||typeof t.layers!="object")return this._layers=null,!1;let i=new Map;if(t.gated&&typeof t.gated=="object")for(let[r,s]of Object.entries(t.gated))s&&typeof s=="object"&&i.set(r,new Map(Object.entries(s)));return this._layers=new Map(Object.entries(t.layers)),this._gated=i,this._sized=new Map(t.sized&&typeof t.sized=="object"?Object.entries(t.sized):[]),!0}refetch(e){let t=this.invalidate();return Promise.resolve().then(()=>e({type:"layer_extents"})).then(i=>this.apply(t,i)).catch(()=>!1)}mayHaveContent(e,t,i,r=256){if(!this._layers||i&&vV.some(s=>i[s]))return!0;if(this._sized.has(e))return wV(this._sized.get(e),t,r);if(!this._layers.has(e)||Hb(this._layers.get(e),t))return!0;for(let[s,o]of this._gated)if(!(i&&i[s]===!1)&&o.has(e)&&Hb(o.get(e),t))return!0;return!1}};function b3(n,e,t){let i=n&&n.app&&n.app.layerExtents;return i?i.mayHaveContent(e,t,n.visibility,on()):!0}function v3(n){return n==null?Promise.resolve(null):typeof n=="string"?new Promise(e=>{let t=document.createElement("img");t.onload=()=>e(t),t.onerror=()=>e(null),t.src=n}):createImageBitmap(n,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).catch(()=>null)}function Yb(n){jb([n&&n.image])}function EV(n){return{width:n.naturalWidth||n.width,height:n.naturalHeight||n.height}}function Bh(n){return n?{image:n,...EV(n)}:null}function SV(n){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(n,n);let e=document.createElement("canvas");return e.width=n,e.height=n,e}function qb(n){let e=document.createElement("canvas");return e.width=n.width,e.height=n.height,e.getContext("2d").drawImage(n,0,0),e}function PV(n){return typeof n.transferToImageBitmap=="function"?Bh(n.transferToImageBitmap()):Bh(qb(n))}var x3=Object.freeze({promise:Promise.resolve(null),cancel(){},promote(){}});function w3(n,e,t,i){let r=n.request(t,{background:i});return r.requestId!=null&&e.push(r.requestId),r}function E3(n,e,t,i){return{promise:t,cancel(){i();for(let r of e)n.cancel(r)},promote(){for(let r of e)n.promote?.(r)}}}var S3=3;function CV(n,e){let t=new Map,i=0,r=0;for(let s of n)if(!(!s||t.has(s.layer))){if(s.layer.startsWith("_")){t.set(s.layer,null),i++,r=0;continue}t.set(s.layer,`${i}:${Math.floor(r++/e)}`)}return t}function TV(n,e,t,i,r,s,o,a){let c=CV(n,t),l=[],u=null,f=()=>{u&&(l.push({opacity:1,msg:d3(r,u.layers,s,o,a)}),u=null)};for(let d of e){let h=c.get(d.layer);if(h==null){f(),l.push({opacity:1,msg:i(d.layer)});continue}u&&u.id!==h&&f(),u=u||{id:h,layers:[]},u.layers.push(d.layer)}return f(),l}function P3({wm:n,ctx:e,getItems:t,dpr:i=()=>1,tileSize:r=()=>240,isDoubleBuffer:s=()=>!0,decode:o=v3,makeCanvas:a=SV,snapshot:c=PV,groupLayers:l=()=>0}){return{load({z:u,x:f,y:d},{background:h=!1,onPartial:p}={}){let m=t()||[],g=m.filter(X=>X&&X.visible!==!1&&b3(e,X.layer,{z:u,x:f,y:d})),v=i(),y=r(),b=new Set,x=g.filter(X=>!b.has(X.layer)&&b.add(X.layer));if(x.length===0)return x3;let E=f3({z:u,x:f,y:d},e,v,y),w=l(),T=w>0&&x.every(X=>(X.opacity??1)===1)?TV(m,x,w,E,{z:u,x:f,y:d},e,v,y):x.map(X=>({opacity:X.opacity,msg:E(X.layer)})),R=Wb(y,v),F=null,O=null,j=[],V=!1,G=!s()&&typeof p=="function",q=y3({items:T,request:X=>w3(n,j,X.msg,h),decode:o,draw:X=>{if(!F){if(!X.some(le=>le.image))return 0;F=a(R),O=F.getContext("2d")}let se=_3(O,X,R);return G&&se>0&&!V&&p(c(F)),se},isStale:()=>V,incremental:G}).then(X=>{if(V)throw new Error("Tile cancelled");if(X.failed===X.requested)throw new Error("Tile requests failed");return X.drawn===0?null:G?void 0:c(F)});return E3(n,j,q,()=>{V=!0})},release:Yb}}function Zb({wm:n,buildRequest:e,dpr:t=()=>1,tileSize:i=()=>240,decode:r=v3}){return{load({z:s,x:o,y:a},{background:c=!1}={}){let l=e({z:s,x:o,y:a},t(),i());if(!l)return x3;let u=[],f=!1,d=w3(n,u,l,c).then(h=>r(h)).then(h=>{if(f)throw Yb(Bh(h)),new Error("Tile cancelled");return Bh(h)});return E3(n,u,d,()=>{f=!0})},release:Yb}}function C3({z:n,x:e,y:t},i,r,s,o){let a={type:"overlay_tile",z:n,x:e,y:t,...Rh(i,r),debug_renderers:!!s.debug_renderers,debug_live:!!s.debug_live,flywires_only:!!s.flywires_only,poly_decomp:!!(o&&o.polyDecomp),focused_nets_guides:!!s.focused_nets_guides,highlight_selected:s.highlight_selected!==!1,draw_labels:s.labels!==!1};return o&&o.visibleLayerNames&&(a.visible_layers=[...o.visibleLayerNames]),a}function T3({z:n,x:e,y:t},i,r,s){let o=s&&s.activeHeatMap;return o?{type:"heatmap_tile",name:o,z:n,x:e,y:t,...Rh(i,r)}:null}function fe(n){return!!n?.websocketManager?.isStaticMode}function k3(n,e){let t={};for(let[i,r]of Object.entries(n||{}))t[i]=!!r;for(let[i,r]of Object.entries(e||{}))t["s_"+i]=!!r;return t}function qo(n,e){e&&typeof e.sel_has_inst=="boolean"&&(n.selHasInst=e.sel_has_inst,n.selHasNet=!!e.sel_has_net)}var Xb=null;function Ft(n,e=4e3){let t=document.getElementById("or-toast");return t||(t=document.createElement("div"),t.id="or-toast",document.body.appendChild(t)),t.textContent=n,t.classList.add("visible"),Xb&&clearTimeout(Xb),Xb=setTimeout(()=>t.classList.remove("visible"),e),t}function R3(n){return!n||n.gpuType!=="cpu"?null:"Software rendering detected (reduced performance). Make sure 'Use graphics acceleration when available' (or 'Use hardware acceleration when available') is turned on in your browser settings, then restart the browser."}function I3({title:n,message:e,confirmLabel:t="OK",danger:i=!1}){return new Promise(r=>{let s=document.createElement("div");s.className="or-modal-overlay";let o=document.createElement("div");o.className="or-modal";let a=document.createElement("div");a.className="or-modal-title",a.textContent=n;let c=document.createElement("div");c.className="or-modal-message",c.textContent=e;let l=document.createElement("div");l.className="or-modal-buttons";let u=document.createElement("button");u.className="or-btn",u.textContent="Cancel";let f=document.createElement("button");f.className="or-btn"+(i?" or-btn-danger":""),f.textContent=t;let d=p=>{document.removeEventListener("keydown",h,!0),s.remove(),r(p)},h=p=>{p.key==="Escape"&&(p.stopPropagation(),d(!1))};u.addEventListener("click",()=>d(!1)),f.addEventListener("click",()=>d(!0)),s.addEventListener("click",p=>{p.target===s&&d(!1)}),document.addEventListener("keydown",h,!0),l.appendChild(u),l.appendChild(f),o.appendChild(a),o.appendChild(c),o.appendChild(l),s.appendChild(o),document.body.appendChild(s),u.focus()})}var LV=.05;function MV([[n,e],[t,i]],r){let s=(i-e)*r,o=(t-n)*r;return[[n-o,e-s],[t+o,i+s]]}function Kb(n,e=256,t=null){if(!L3(n))return null;let i=n[0][0],r=n[0][1],s=Math.max(n[1][1]-r,n[1][0]-i),o=e/s,a=L3(t)?t:n,[[c,l],[u,f]]=MV(a,LV);return{scale:o,maxDXDY:s,originX:r,originY:i,fitRect:Nt(l,c,f,u,o,r,i)}}function L3(n){return!!n&&n[1][0]>n[0][0]&&n[1][1]>n[0][1]}function B3(n,e){return!!n&&!!e&&n[0][0]===e[0][0]&&n[0][1]===e[0][1]&&n[1][0]===e[1][0]&&n[1][1]===e[1][1]}function Pt(n){n.selectionToken=(n.selectionToken||0)+1;for(let e of n.selectionResetters||[])e();return n.selectionToken}function zt(n,e){return n.selectionToken===e}function O3(n,e){n.selectionResetters||(n.selectionResetters=[]),n.selectionResetters.push(e)}var Qb=80,Ul=10,$l=1e3;function Gl(n){let e=n===""||n===null?NaN:Math.round(Number(n));return Number.isFinite(e)?Math.min($l,Math.max(Ul,e)):Qb}function vs(n="vis-group-header"){let e=document.createElement("div");e.className=n;let t=document.createElement("span");t.className="vis-arrow",e.appendChild(t);let i=document.createElement("span");return i.className="vis-name",e.appendChild(i),{header:e,arrow:t,name:i}}function xs(n,e,t,i){let r=s=>{t.classList.toggle("collapsed",s),e.textContent=s?"\u25B6":"\u25BC"};r(!!i),n.addEventListener("click",s=>{let o=s.target&&s.target.parentNode===n&&s.target.classList&&s.target.classList.contains("vis-name");s.target!==n&&s.target!==e&&!o||r(!t.classList.contains("collapsed"))})}var M3=30;function D3(n,e=8){if(!Number.isFinite(n)||n<=0)return M3;let t=Math.ceil(Math.log2(e/n));return Math.max(1,Math.min(M3,t))}function N3({designBounds:n,fitRect:e,viewW:t,viewH:i}){let r=Kb(n,Di,e),s=h=>Number.isFinite(h)&&h>0;if(!r||!s(t)||!s(i))return Di;let o=r.fitRect[2]-r.fitRect[0],a=r.fitRect[3]-r.fitRect[1],c=Math.min(t/o,i/a),l=Math.log2(c);if(!Number.isFinite(l)||l<0)return Di;let u=Math.floor(l),f=Di*2**(l-u),d=Math.floor(f/Vb)*Vb;return d>Di&&Math.log2(Di*c/d)>=u?d:Di}function F3(n,{showDbu:e,dbuPerMicron:t},i=!1){if(e)return String(Math.round(n));let r=t>0?t:1e3,s=Math.ceil(Math.log10(r)),o=(n/r).toFixed(s);return i?o+" \xB5m":o}function z3(n,{showDbu:e,dbuPerMicron:t}){let i=parseFloat(n);if(!Number.isFinite(i))return null;if(e)return Math.round(i);let r=t>0?t:1e3;return Math.round(i*r)}function U3(n,{showDbu:e,dbuPerMicron:t}){if(e)return String(Math.round(n));let i=t>0?t:1e3,r=n/i;return r>=1e3?(r/1e3).toFixed(3)+" mm":r>=1?r.toFixed(3)+" um":(r*1e3).toFixed(1)+" nm"}function $3({showDbu:n}){return n?"DBU":"\xB5m"}function Zo(n){return typeof n=="string"&&/^#[0-9a-fA-F]{6}$/.test(n)}function G3(n){if(typeof n!="string")return null;let e=n.trim();if(Zo(e))return e.toLowerCase();let t=e.match(/^#([0-9a-fA-F]{3})$/);if(t)return"#"+t[1].split("").map(r=>r+r).join("").toLowerCase();let i=e.match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/);if(i){let r=i.slice(1).map(Number);return r.some(s=>s>255)?null:"#"+r.map(s=>s.toString(16).padStart(2,"0")).join("")}return null}function ur(n,e=t=>requestAnimationFrame(t)){let t=!1;return()=>{t||(t=!0,e(()=>{t=!1,n()}))}}function Vl(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function A3(n){let e=Math.pow(10,Math.floor(Math.log10(n))),t=n/e,i;return t<1.5?i=1:t<3.5?i=2:t<7.5?i=5:i=10,{value:i*e,digit:i}}function V3({targetPx:n,pxPerDbu:e,dbuPerMicron:t,showDbu:i}){if(!Number.isFinite(e)||e<=0||!Number.isFinite(n)||n<=0)return null;let r,s,o;if(i){let c=A3(Math.max(1,n/e));o=c.digit,r=Math.round(c.value*e),s=String(Math.round(c.value))}else{let c=Number.isFinite(t)&&t>0?t:1e3,l=e*c,u=A3(n/l);o=u.digit;let f=u.value;r=Math.round(f*l);let d,h;f>=1e3?(d=1/1e3,h="mm"):f>=1?(d=1,h="\xB5m"):f>=.001?(d=1e3,h="nm"):(d=1e6,h="pm"),s=Math.round(f*d)+" "+h}return{barPx:r,label:s,segments:o===1?5:o}}function Wl(n,e,t){return e?typeof n.runTclScript=="function"?n.runTclScript(e,t):(t&&typeof n.echoTcl=="function"&&n.echoTcl(e),n.websocketManager.request({type:"tcl_eval",cmd:e}).catch(()=>{})):Promise.resolve()}function ws(n,e){let t=n.querySelectorAll("thead th");(!e||!e[0])&&(n.style.tableLayout="auto",t.forEach(i=>i.style.width=""),e=Array.from(t,i=>i.offsetWidth+"px")),t.forEach((i,r)=>i.style.width=e[r]||""),n.style.tableLayout="fixed",t.forEach((i,r)=>{if(r===t.length-1)return;let s=document.createElement("div");s.className="col-resize-grip",i.style.position="relative",i.appendChild(s);let o,a,c=u=>{i.style.width=Math.max(30,a+u.clientX-o)+"px"},l=()=>{document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",l);let u=f=>f.stopPropagation();document.addEventListener("click",u,{capture:!0,once:!0}),setTimeout(()=>{document.removeEventListener("click",u,{capture:!0})},0)};s.addEventListener("mousedown",u=>{u.preventDefault(),o=u.clientX,a=i.offsetWidth,document.addEventListener("mousemove",c),document.addEventListener("mouseup",l)})})}var AV={Layout:'',Schematic:'',"3D Viewer":'',"Display Controls":'',Inspector:'',Hierarchy:'',Timing:'',DRC:'',"Select Highlight":'',"Clock Tree":'',Charts:'',"Tcl Console":'',Help:''};function kV(n){let e=AV[n];if(!e)return null;let t=document.createElement("span");return t.className="or-tab-icon",t.innerHTML='",t}function W3(n=document){let e=0;for(let t of n.querySelectorAll(".lm_tab:not([data-or-icon])")){let i=t.querySelector(".lm_title");if(!i)continue;let r=i.textContent.trim();if(!r)continue;t.setAttribute("data-or-icon","");let s=kV(r);s&&(t.insertBefore(s,i),e++)}return e}function Xo(n,e,t,i){let r=document.createElement("div");r.className="modal-overlay",r.innerHTML=` -
`,document.body.appendChild(r);let s=()=>r.remove();r.addEventListener("click",c=>{c.target===r&&s()}),r.addEventListener("keydown",c=>{c.key==="Escape"&&s()}),r.querySelector(".cancel").addEventListener("click",s),r.querySelector(".modal-close").addEventListener("click",s);let o=r.querySelector(".modal-error"),a=(c,l)=>{o.textContent=c,o.style.display=c?"block":"none",o.classList.toggle("info",!!l)};return{overlay:r,close:s,okBtn:r.querySelector(".ok"),showError:a}}var MV=1e4,AV=150,kV=3;function RV(n){return 1-(1-n)*(1-n)}var Bh=class{constructor({isEnabled:e=()=>!0,isSmooth:t=()=>!1,reducedMotion:i=Gl,now:r=()=>performance.now(),setTimer:s=(u,f)=>setTimeout(u,f),clearTimer:o=u=>clearTimeout(u),timeoutMs:a=MV,fadeMs:c=AV,onChange:l=()=>{}}={}){Object.assign(this,{isEnabled:e,isSmooth:t,reducedMotion:i,now:r,setTimer:s,clearTimer:o,timeoutMs:a,fadeMs:c,onChange:l}),this.shownZ=null,this.pendingZ=null,this.under=[],this.fade=null,this._timer=null}wantedZ(){return this.pendingZ!==null?this.pendingZ:this.shownZ}setZoom(e,{hasContent:t=!0}={}){e!==this.wantedZ()&&(this.endFade(),this._clearTimer(),this.shownZ===null?(this.shownZ=e,this.pendingZ=null,this.under=[]):t?e===this.shownZ?this.pendingZ=null:this.isEnabled()?(this.pendingZ=e,this.under=[],this._timer=this.setTimer(()=>this.reveal(),this.timeoutMs)):(this.under=[...this.under.filter(i=>i!==e),this.shownZ].slice(-kV),this.shownZ=e,this.pendingZ=null):(this.shownZ=e,this.pendingZ=null,this.under=this.under.filter(i=>i!==e)),this.onChange())}check({settled:e,animating:t=!1}){return this.pendingZ!==null?t||!e&&this.isEnabled()?!1:(this.reveal(),!0):this.under.length>0&&e&&!t?(this.under=[],this.onChange(),!0):!1}reveal(){if(this.pendingZ===null)return;this._clearTimer();let e=this.shownZ;this.shownZ=this.pendingZ,this.pendingZ=null;let t=this.isSmooth()&&!this.reducedMotion()?this.fadeMs:0;this.fade=t>0&&e!==null?{fromZ:e,toZ:this.shownZ,start:this.now(),ms:t}:null,this.onChange()}endFade(){this.fade&&(this.fade=null,this.onChange())}plan(e=this.now()){if(this.fade){let t=(e-this.fade.start)/this.fade.ms;if(t<1)return{draw:[{z:this.fade.fromZ,opacity:1},{z:this.fade.toZ,opacity:RV(Math.max(0,t))}],fading:!0};this.fade=null}return this.shownZ===null?{draw:[],fading:!1}:this.pendingZ!==null?{draw:[{z:this.shownZ,opacity:1}],fading:!1}:this.under.length>0?{draw:[...this.under,this.shownZ].map(t=>({z:t,opacity:1})),fading:!1}:{draw:[{z:this.shownZ,opacity:1}],fading:!1}}isIdle(e=this.now()){return this.pendingZ===null&&this.under.length===0&&!this.plan(e).fading}dispose(){this._clearTimer()}_clearTimer(){this._timer!==null&&(this.clearTimer(this._timer),this._timer=null)}};var at=Object.freeze({base:10,overlay:20,heatmap:30,top:40,pathImage:50,selection:60,highlight:70,ruler:80}),Es={depthCompare:"always",depthWriteEnabled:!1},V3=250,W3=4,Qb=300,IV=1,BV=2,OV=300,DV=300,NV=400,FV=1e3,j3=100,zV=.05,H3=1200,Y3=30;function Nt(n,e=1){if(Array.isArray(n)){let r=n.length>3?n[3]:255;return[n[0],n[1],n[2],Math.round(r*e)]}let t=String(n||"#000").replace("#","");t.length===3&&(t=t.split("").map(r=>r+r).join(""));let i=parseInt(t.slice(0,6),16)||0;return[i>>16&255,i>>8&255,i&255,Math.round(255*e)]}function UV(n){return 1-Math.pow(1-n,3)}function $V(n){return n<.5?4*n*n*n:1-Math.pow(2-2*n,3)/2}function GV(){let n=new Map;return{on(e,t){for(let i of e.split(/\s+/))n.has(i)||n.set(i,new Set),n.get(i).add(t)},off(e,t){for(let i of e.split(/\s+/))n.get(i)?.delete(t)},emit(e,t){for(let i of[...n.get(e)||[]])i(t)}}}function q3(n,e={}){let t=e.deckApi!==void 0?e.deckApi:globalThis.deck,i=e.copyCanvas||Yb,r={smooth:()=>!1,doubleBuffer:()=>!0,defer:()=>!1,...e.prefs||{}},s=e.tileSize||(()=>240),o=e.dpr||(()=>typeof devicePixelRatio=="number"?devicePixelRatio:1),a=e.raf||(P=>requestAnimationFrame(P)),c=e.now||(()=>performance.now()),l=GV(),u={target:[0,0],zoom:0,width:1,height:1},f={minZoom:-1/0,maxZoom:Y3},d=null,h=!1,p=[],m=[],g=null,v=null,y=!1,b=!1,w=0,E=new Set,x=!1;n.classList.add("or-view");let T=document.createElement("div");T.className="or-view-canvas",n.appendChild(T);let I=document.createElement("div");I.className="or-view-markers",n.appendChild(I);let N=new Map,D=new Map,H=new Map,W=new Map,V=new WeakMap,X=[],Y=cr(Z,a),ie=new Bh({isEnabled:()=>r.doubleBuffer(),isSmooth:()=>r.smooth(),now:c,onChange:()=>Y()}),oe=null;function zt(){return{dragPan:!0,dragRotate:!1,scrollZoom:!1,doubleClickZoom:!1,touchZoom:!e.isStatic,touchRotate:!1,keyboard:!1,inertia:!1}}function je(){return{target:[u.target[0],u.target[1],0],zoom:u.zoom,minZoom:f.minZoom,maxZoom:f.maxZoom}}function sn(){return new t.Deck({parent:T,views:new t.OrthographicView({id:"main",flipY:!1,controller:zt()}),viewState:je(),layers:[],useDevicePixels:!0,deviceProps:{webgl:{preserveDrawingBuffer:!!e.preserveDrawingBuffer}},getCursor:({isDragging:P})=>E.size?"crosshair":P?"grabbing":"default",onViewStateChange:({viewState:P})=>{if(d=null,_t(P.target,P.zoom),h){let A=c();m.push({t:A,target:[...u.target],zoom:u.zoom}),m=m.filter(O=>A-O.t<=j3)}return je()},onInteractionStateChange:P=>{let A=!!(P.isDragging||P.isPanning||P.isZooming||P.inTransition);if(A!==h){if(h=A,A){m=[],Pn();return}queueMicrotask(()=>{!h&&!d&&!gr()&&Cn()})}},onLoad:()=>{si(),Y()},onAfterRender:()=>{let P=p;p=[],P.forEach(A=>A())}})}function si(){let P=oe.getCanvas&&oe.getCanvas();P?.addEventListener("webglcontextlost",A=>{if(A.preventDefault(),x)return;l.emit("contextlost");let O=oe;oe=null,V=new WeakMap,X=[];try{O.finalize?.()}catch{}P.remove();try{oe=sn(),l.emit("contextrestored")}catch(G){l.emit("contextfailed",G)}Y()})}t&&typeof t.Deck=="function"&&(oe=sn());function oi(){let P=o(),A=Math.max(1,Math.floor(n.clientWidth*P)/P),O=Math.max(1,Math.floor(n.clientHeight*P)/P),G=A!==u.width||O!==u.height;return u.width=A,u.height=O,T.style.width=A+"px",T.style.height=O+"px",G}oi();let on=null;typeof ResizeObserver=="function"&&(on=new ResizeObserver(()=>Ri()),on.observe(n));function Ri(){oi()?(Sn(),l.emit("resize",ke())):Y()}function _t(P,A,{tiles:O=!0}={}){let G=bs(A,f),K=G!==u.zoom;u.target=[P[0],P[1]],u.zoom=G,Sn(K,O)}function Sn(P=!1,A=!0){oe&&oe.setProps({viewState:je()}),P&&l.emit("zoom"),l.emit("move"),A&&Ve(),Y()}function Pn(){b||(b=!0,l.emit("movestart"))}function Cn(){if(d||h)return;let P=Math.round(u.zoom);if(Math.abs(P-u.zoom)>1e-9){Ge({target:Lh(u,[u.width/2,u.height/2],P),zoom:P},{anchor:null});return}u.target=o3(u,o());let A=b;b=!1,Sn(),A&&(l.emit("moveend"),l.emit("zoomend"))}function gr(){let P=m;if(m=[],!r.smooth()||P.length<2)return!1;let A=P[0],O=P[P.length-1],G=O.t-A.t;if(G<=0||c()-O.t>j3||A.zoom!==O.zoom)return!1;let K=(O.target[0]-A.target[0])/G,J=(O.target[1]-A.target[1])/G;return Math.hypot(K,J)*Math.pow(2,u.zoom)W3?0:V3}function Ge(P,{anchor:A=null,ms:O=void 0,settle:G=!0,curve:K=!1}={}){P={target:P.target,zoom:bs(P.zoom,f)};let J=K&&O===void 0?_r(P):null;if(O===void 0&&(O=J?J.ms:$e(P)),Pn(),P.zoom!==u.zoom&&l.emit("zoomstart"),O<=0){d=null;let se=G&&!h;_t(P.target,P.zoom,{tiles:!se}),G&&Cn();return}v=null,d={from:{...u,target:[...u.target]},to:P,anchor:A,start:J?null:c(),created:c(),ms:O,flight:J},Ve(),Ut()}function _r(P){if(!r.smooth()||!(Math.hypot(P.target[0]-u.target[0],P.target[1]-u.target[1])*Math.pow(2,Math.min(u.zoom,P.zoom))>BV*Math.max(u.width,u.height))&&Math.abs(P.zoom-u.zoom)<=W3)return null;let G=a3(u,{...u,...P}),K=1/0,J=null;for(let fe=0;fe<=16;fe++){let q=G.at(fe/16);K=Math.min(K,q.zoom);let he=jo({...u,...q});J=J?[Math.min(J[0],he[0]),Math.min(J[1],he[1]),Math.max(J[2],he[2]),Math.max(J[3],he[3])]:he}let se=Math.max(0,Fb(K)),ge=Nl(J,se,s());return{path:G,ms:Math.min(FV,Math.max(NV,DV*G.S)),apex:ge?{z:se,range:ge}:null}}function ai(P){return!P||[...N.values()].every(A=>!A.visible||A.grid.settledIn(P.z,P.range))}function Ut(){if(!d||x)return;if(d.start===null){if(!ai(d.flight.apex)&&c()-d.created=1){let K=d.to;v=d.flight?d.flight.apex:null,d=null,_t(K.target,K.zoom),Cn();return}_t(G,O),a(Ut)}function ci(){return d?{...u,target:d.to.target,zoom:d.to.zoom}:u}function Ve(){if(N.size===0)return;let P=r.doubleBuffer(),A=bs(Fb(u.zoom,{targetZoom:d?d.to.zoom:null,hidingNewLevels:P}),{minZoom:0,maxZoom:Y3}),O=ci(),G=Nl(jo(O),A,s()),K=Mh(G),J=ie.shownZ,se=r.defer()&&h;se||ie.setZoom(A,{hasContent:[...N.values()].some(he=>he.visible&&J!==null&&he.grid.hasContentAt(J))});let ge=[];A>0&&!d&&!h&&!b&&ie.pendingZ===null&&(g=A-1,ge.push({z:g,range:Nl(zb(jo(O),IV),g,s())}));let fe=li();fe&&ge.push({...fe,background:!1});let q=d?Nl(jo(u),A,s()):null;for(let he of N.values())he.visible&&!se&&he.grid.update({z:A,range:G,ring:K,extra:ge,hold:q});Oi()}function li(){return d&&d.flight&&d.flight.apex||v}function an(P){let A=[];for(let O of[li()?.z,ie.pendingZ])O!=null&&!A.includes(O)&&!P.some(G=>G.z===O)&&A.push(O);return A}function Ii(){y||(y=!0,queueMicrotask(()=>{y=!1,x||Ve()}))}function Bi(){for(let P of N.values())if(P.visible&&!P.grid.isSettled())return!1;return!0}function Oi(P){let A=ie.check({settled:Bi(),animating:!!d});A&&ie.pendingZ===null&&Ii();let O=!1;v&&!d&&ie.isIdle()&&Bi()&&(v=null,O=!0),(A||O||!P||Rs(P.z))&&Y()}function Rs(P){let A=ie.plan(c()).draw;return A.some(O=>O.z===P)||an(A).includes(P)}function Tn(P,{order:A,source:O,visible:G=!0}){let K={load:(se,ge)=>O.load(se,ge),release:se=>{let ge=se&&V.get(se);ge&&(V.delete(se),X.push(ge)),O.release?.(se)}},J={id:P,order:A,visible:G,grid:new Ah({source:K,onChange:se=>Oi(se)})};return N.set(P,J),Ve(),{id:P,setVisible(se){J.visible!==!!se&&(J.visible=!!se,J.visible||J.grid.clear(),Ve())},isVisible:()=>J.visible,refresh(){J.visible&&(J.grid.refresh(),Y())},remove(){J.grid.clear(),N.delete(P),Y()}}}function $t(P){if(!oe||!oe.device)return P.image;let A=V.get(P);if(!A){try{A=oe.device.createTexture({data:P.image,width:P.width,height:P.height,mipLevels:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}})}catch{return P.image}V.set(P,A)}return A}function Me(P){if(P>=w)return 1;let A=(H3-(w-P))%400/400;return 1-.7*(.5-.5*Math.cos(2*Math.PI*A))}let yr=new WeakMap,Ae=null;function M(P){let A=s();A!==Ae&&(yr=new WeakMap,Ae=A);let O=yr.get(P);return O||(O=s3(P.z,P.x,P.y,A),yr.set(P,O)),O}function S(P,A,O,G,K,J){for(let se of A.grid.drawableTilesAt(O)){let ge=M(se);Ub(ge,G)&&P.push({order:A.order,props:{id:`${A.id}:${K}${se.key}`,image:$t(se.drawable),bounds:ge,opacity:J,parameters:Es}})}}function L(P,A){let O=[],G=ie.plan(P);if(!G.fading&&ie.pendingZ===null&&G.draw.length>0){let fe=[...G.draw.map(q=>q.z),g,li()?.z].filter(q=>q!=null);for(let q of N.values())q.grid.prune(fe)}let K=Me(P),J=[...N.values()].sort((fe,q)=>fe.order-q.order),se=J.find(fe=>fe.visible),ge=an(G.draw);for(let fe of J)if(fe.visible){fe===se&&ge.length>0&&O.push(...F(fe,ge,G.draw,A,K));for(let q of G.draw)S(O,fe,q.z,A,"",q.opacity*K)}return{layers:O,animate:G.fading||Phe.z===fe.z)||fe.loading&&!fe.drawable)continue;let q=M(fe);if(Ub(q,G)){let[he,Ln,cp,na]=q;ge.push([[he-se,Ln-se],[cp+se,Ln-se],[cp+se,na+se],[he-se,na+se]])}}return ge.length&&J.push({order:P.order,kind:"SolidPolygonLayer",props:{id:`${P.id}:mask`,data:ge,getPolygon:fe=>fe,getFillColor:k(),parameters:Es}}),J}function k(){let P=(getComputedStyle(n).backgroundColor||"").match(/[\d.]+/g);return!P||P.length<3||P.length>3&&Number(P[3])===0?[0,0,0,255]:[Number(P[0]),Number(P[1]),Number(P[2]),255]}function U(P,A,O){let G=[],K=[],J=[],se=[];for(let q of A){if(q.kind==="circle"){se.push(q);continue}let he=q.kind==="rect"?[[q.rect[0],q.rect[1]],[q.rect[2],q.rect[1]],[q.rect[2],q.rect[3]],[q.rect[0],q.rect[3]]]:q.points;if(q.fill&&K.push({polygon:he,color:q.fill}),q.stroke){let Ln=q.kind==="rect"||q.closed;J.push({path:Ln?[...he,he[0]]:he,color:q.stroke,width:q.width||1,dash:q.dash||null})}}K.length&&G.push({order:O,kind:"SolidPolygonLayer",props:{id:`${P}:fill`,data:K,getPolygon:q=>q.polygon,getFillColor:q=>q.color,parameters:Es}});let ge=J.filter(q=>!q.dash),fe=J.filter(q=>q.dash);if(ge.length&&G.push({order:O,kind:"PathLayer",props:{id:`${P}:stroke`,data:ge,widthUnits:"pixels",getPath:q=>q.path,getColor:q=>q.color,getWidth:q=>q.width,parameters:Es}}),fe.length){let q={id:`${P}:dash`,data:fe,widthUnits:"pixels",getPath:he=>he.path,getColor:he=>he.color,getWidth:he=>he.width,getDashArray:he=>he.dash.map(Ln=>Ln/he.width),dashJustified:!0,parameters:Es};t?.PathStyleExtension&&(q.extensions=[new t.PathStyleExtension({dash:!0})]),G.push({order:O,kind:"PathLayer",props:q})}return se.length&&G.push({order:O,kind:"ScatterplotLayer",props:{id:`${P}:circle`,data:se,radiusUnits:"pixels",lineWidthUnits:"pixels",getPosition:q=>q.center,getRadius:q=>q.radius,stroked:!0,filled:!0,getLineColor:q=>q.stroke||[0,0,0,0],getFillColor:q=>q.fill||[0,0,0,0],getLineWidth:q=>q.width||1,parameters:Es}}),G}function R(){let P=[];for(let A of D.values())P.push(...A);return P.push(...H.values()),P}function B(P){return P.map(A=>new t[A.kind||"BitmapLayer"](A.props))}let $=0;function Z(){if(x)return;let P=c(),A=L(P,zb(jo(u),.5)),O=[...A.layers,...R()].sort((G,K)=>G.order-K.order);$=O.length,oe&&oe.setProps({layers:B(O)});for(let G of X.splice(0))G.destroy?.();Oe(),A.animate&&Y(),l.emit("render")}function Q(P=32,A=20){let O=N.get("base");if(!O)return null;let G=s(),K=ie.plan(c()).draw,J=[...K,...an(K).map(fe=>({z:fe}))],se=0,ge=0;for(let fe=0;fe=G||Ln>=G)continue;se++,J.some(({z:na})=>{let gv=G/2**na,lp=O.grid.tiles.get(Ho(na,Math.floor(he/gv),Math.floor((G-Ln)/gv)));return lp&&(lp.drawable||!lp.loading)})&&ge++}return se?ge/se:null}function de(P){return W.has(P)||W.set(P,{visible:!0,items:new Map}),W.get(P)}function _e(P,A){let[O,G]=Th(P.world,u);P.el.style.display=A?"":"none",P.el.style.transform=`translate(${O}px, ${G}px)`+(P.center?" translate(-50%, -50%)":"")}function Xe(P){for(let A of P.items.values())_e(A,P.visible)}function Oe(){for(let P of W.values())Xe(P)}function ke(){return{width:u.width,height:u.height}}let Qe={DRAW_ORDER:at,getContainer:()=>n,getSize:ke,getZoom:()=>u.zoom,getTargetZoom:()=>d?d.to.zoom:u.zoom,getCenter:()=>[...u.target],getViewState:()=>({...u,target:[...u.target]}),isAnimating:()=>!!d,isMoving:()=>b,project:P=>Th(P,u),unproject:P=>Wo(P,u),on:l.on,off:l.off,setLimits({minZoom:P,maxZoom:A}={}){P!==void 0&&(f.minZoom=P),A!==void 0&&(f.maxZoom=A);let O=bs(u.zoom,f);O!==u.zoom?_t(u.target,O):oe&&oe.setProps({viewState:je()}),l.emit("limits")},getLimits:()=>({...f}),setView(P,A=u.zoom,{animate:O}={}){let G={target:[P[0],P[1]],zoom:A};Ge(G,O===!1?{ms:0}:{curve:!0})},fitWorldRect(P,{padding:A=[0,0],animate:O}={}){let G=r3(P,u,{padding:A,...f});Ge(G,O===!1?{ms:0}:{curve:!0})},zoomAround(P,A,{animate:O,settle:G=!0}={}){let K=bs(Qe.getTargetZoom()+A,f),J=ci(),se=P||[u.width/2,u.height/2],ge=Lh(J,se,K);Ge({target:ge,zoom:K},O===!1?{ms:0,settle:G}:{anchor:P?se:null})},zoomIn:()=>Qe.zoomAround(null,1),zoomOut:()=>Qe.zoomAround(null,-1),panByPx(P,A,{animate:O}={}){let G=ci(),K=Math.pow(2,G.zoom),J=[G.target[0]+P/K,G.target[1]-A/K],se=O===!1||!r.smooth()?0:V3;Ge({target:J,zoom:G.zoom},{ms:se})},invalidateSize:Ri,applyPrefs(){Ve()},addTileSlot:Tn,setOverlay(P,A,{order:O=at.selection}={}){!A||A.length===0?D.delete(P):D.set(P,U(P,A,O)),Y()},hasOverlay:P=>D.has(P),setImageOverlay(P,A,{order:O=at.pathImage}={}){A?H.set(P,{order:O,kind:"BitmapLayer",props:{id:`image:${P}`,image:A.image,bounds:A.rect,parameters:Es}}):H.delete(P),Y()},addMarker(P,A,O,G,{center:K=!1}={}){let J=de(P),se=J.items.get(A);se&&se.el.remove(),G.classList.add("or-view-marker"),I.appendChild(G);let ge={el:G,world:[O[0],O[1]],center:K};return J.items.set(A,ge),_e(ge,J.visible),G},moveMarker(P,A,O){let G=de(P),K=G.items.get(A);K&&(K.world=[O[0],O[1]],_e(K,G.visible))},clearMarkers(P){let A=de(P);for(let O of A.items.values())O.el.remove();A.items.clear()},setMarkerGroupVisible(P,A){let O=de(P);O.visible=!!A,Xe(O)},setCursorMode(P,A=!0){A?E.add(P):E.delete(P),n.classList.toggle(`${P}-mode-cursor`,!!A);let O=oe&&oe.getCanvas&&oe.getCanvas();O&&(O.style.cursor=E.size?"crosshair":"default")},flashTiles(){w=c()+H3,Y()},whenTilesSettled({timeoutMs:P=6e3}={}){let A=c()+P;return new Promise(O=>{let G=()=>{if(Bi()&&ie.isIdle()&&!d&&!b||c()>=A){O();return}setTimeout(G,32)};G()})},captureCanvas({timeoutMs:P=500}={}){return oe?.getCanvas()?(Z(),new Promise(A=>{let O=null,G=()=>{clearTimeout(O),p=p.filter(J=>J!==G);let K=oe?.getCanvas();A(K?{image:i(K),rect:K.getBoundingClientRect()}:null)};p.push(G),O=setTimeout(()=>{oe?.redraw("capture"),G()},P)})):Promise.resolve(null)},redraw:()=>Y(),debugSnapshot(){let P=ie.plan();return{zoom:u.zoom,target:[...u.target],width:u.width,height:u.height,animating:!!d,moving:b,interacting:h,shownZ:ie.shownZ,pendingZ:ie.pendingZ,fading:P.fading,drawLevels:P.draw,layers:$,coverage:Q(),overlays:[...D.keys()],markers:Object.fromEntries([...W].map(([A,O])=>[A,O.items.size])),slots:[...N.values()].map(A=>({id:A.id,visible:A.visible,settled:A.grid.isSettled(),...A.grid.stats()}))}},destroy(){x=!0,on?.disconnect(),ie.dispose();for(let P of N.values())P.grid.clear();oe?.finalize?.()}};return Qe}var VV=4.000244140625;function WV(n){return n.deltaMode!==0?!0:n.deltaX!==0||n.deltaY===0?!1:Number.isInteger(n.deltaY)&&Math.abs(n.deltaY)>=50||n.deltaY%VV===0}function jV(n){let e=Math.abs(n);return e<.2?0:Math.sign(n)*Math.max(1,Math.round(e))}function HV(n,e){let i=1;return n.deltaMode===1?i=16:n.deltaMode===2&&(i=e.clientHeight||16),[n.deltaX*i,n.deltaY*i]}function YV(n,e,t){let i=t?3*e:e;switch(n){case"ArrowLeft":return[-i,0];case"ArrowRight":return[i,0];case"ArrowUp":return[0,-i];case"ArrowDown":return[0,i];default:return null}}function X3(n,e={}){let t=n.getContainer(),i=e.isStatic||(()=>!1),r=e.wheelZoom||(()=>!0),s=e.arrowStep||(()=>80),o=e.gestureIdleMs??200,a=e.contextEnabled||(()=>!0),c=[],l=(x,T,I,N)=>{x.addEventListener(T,I,N),c.push(()=>x.removeEventListener(T,I,N))},u=x=>{let T=t.getBoundingClientRect();return[x.clientX-T.left,x.clientY-T.top]},f=x=>n.unproject(u(x)),d=x=>x.target===t||!!x.target?.closest?.(".or-view-canvas");t.tabIndex<0&&(t.tabIndex=0);let h=null;function p(x,T){h||(h={z0:n.getZoom()}),h.pt=x,clearTimeout(h.timer),h.timer=setTimeout(m,o),n.zoomAround(x,T,{animate:!1,settle:!1})}function m(){if(!h)return;let x=h;h=null,clearTimeout(x.timer);let T=n.getZoom();n.zoomAround(x.pt,x.z0+jV(T-x.z0)-T)}c.push(()=>{clearTimeout(h?.timer),h=null}),l(t,"wheel",x=>{if(x.preventDefault(),i())return;let T=WV(x);if(!T&&x.ctrlKey){p(u(x),-x.deltaY/(100*Math.LN2));return}if(r()===x.ctrlKey){let[I,N]=HV(x,t);n.panByPx(I,N,{animate:!1});return}if(!T){p(u(x),-x.deltaY/100);return}m(),n.zoomAround(u(x),x.deltaY<0?1:-1)},{passive:!1}),l(t,"keydown",x=>{if(x.altKey||x.ctrlKey||x.metaKey)return;let T=YV(x.key,s(),x.shiftKey);if(T){x.preventDefault(),n.panByPx(T[0],T[1]);return}if(i())return;let I={"+":1,"=":1,"-":-1,_:-1};x.key in I&&(x.preventDefault(),n.zoomAround(null,I[x.key]*(x.shiftKey?3:1)))});let g=null,v=null;l(t,"pointerdown",x=>{x.button!==0||!d(x)||(t.focus({preventScroll:!0}),g={x:x.clientX,y:x.clientY,moved:!1,box:x.shiftKey&&!i()},g.box&&x.stopPropagation())},{capture:!0}),l(window,"pointermove",x=>{if(!g)return;let T=x.clientX-g.x,I=x.clientY-g.y;(Math.abs(T)>3||Math.abs(I)>3)&&(g.moved=!0),g.box&&g.moved&&(v=Z3(v,g,x))}),l(window,"pointerup",x=>{if(!g||x.button!==0)return;let T=g;if(g=null,v&&(v.remove(),v=null),T.box&&T.moved){E(T,x);return}!T.moved&&e.onClick&&w(x)&&e.onClick(f(x),x)}),l(t,"dblclick",x=>{i()||!d(x)||n.zoomAround(u(x),x.shiftKey?-1:1)});let y=null,b=null;l(t,"contextmenu",x=>x.preventDefault()),l(t,"pointerdown",x=>{x.button!==2||i()||!d(x)||(x.stopPropagation(),y={x:x.clientX,y:x.clientY})},{capture:!0}),l(window,"pointermove",x=>{if(!y)return;let T=x.clientX-y.x,I=x.clientY-y.y;(b||Math.abs(T)>=4&&Math.abs(I)>=4)&&(b=Z3(b,y,x))}),l(window,"pointerup",x=>{if(!y||x.button!==2)return;let T=y;if(y=null,b){b.remove(),b=null,E(T,x);return}w(x)&&a()&&e.onContextClick&&e.onContextClick(f(x),x)}),l(t,"pointermove",x=>{e.onMove&&e.onMove(f(x),x)}),l(t,"pointerleave",x=>{e.onLeave&&e.onLeave(x)});function w(x){let T=t.getBoundingClientRect();return x.clientX>=T.left&&x.clientX<=T.right&&x.clientY>=T.top&&x.clientY<=T.bottom}function E(x,T){let I=t.getBoundingClientRect(),N=n.unproject([x.x-I.left,x.y-I.top]),D=n.unproject([T.clientX-I.left,T.clientY-I.top]);n.fitWorldRect([Math.min(N[0],D[0]),Math.min(N[1],D[1]),Math.max(N[0],D[0]),Math.max(N[1],D[1])])}return{dispose(){for(let x of c.splice(0))x()}}}function Z3(n,e,t){return n||(n=document.createElement("div"),n.className="rubber-band",document.body.appendChild(n)),n.style.left=Math.min(e.x,t.clientX)+"px",n.style.top=Math.min(e.y,t.clientY)+"px",n.style.width=Math.abs(t.clientX-e.x)+"px",n.style.height=Math.abs(t.clientY-e.y)+"px",n}var Ps=class n{constructor(e,t,i){this._app=e,this._redrawAllLayers=t,this._refreshOverlay=i||t,this._currentTab="setup",this._setupPaths=[],this._holdPaths=[],this._selectedPathIndex=-1,this._detailTab="data",this._selectedDetailIndex=-1,this._sortCol="slack",this._sortAscending=!0,this._build()}_build(){let e=document.createElement("div");e.className="timing-widget";let t=document.createElement("div");t.className="timing-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",ue(this._app)&&(this._updateBtn.style.display="none"),this._pathCountLabel=document.createElement("span"),this._pathCountLabel.className="timing-path-count",t.appendChild(this._updateBtn),t.appendChild(this._pathCountLabel),e.appendChild(t),e.appendChild(this._buildConePanel());let i=document.createElement("div");i.className="timing-tab-bar",this._setupTab=this._makeTab("Setup",!0),this._holdTab=this._makeTab("Hold",!1),i.appendChild(this._setupTab),i.appendChild(this._holdTab),e.appendChild(i),this._pathTableContainer=document.createElement("div"),this._pathTableContainer.className="timing-path-table-container",this._pathTable=document.createElement("table"),this._pathTable.className="timing-table",this._pathTableContainer.appendChild(this._pathTable),e.appendChild(this._pathTableContainer);let r=document.createElement("div");r.className="timing-tab-bar",this._dataTab=this._makeTab("Data Path",!0),this._captureTab=this._makeTab("Capture Path",!1),r.appendChild(this._dataTab),r.appendChild(this._captureTab),e.appendChild(r),this._detailTableContainer=document.createElement("div"),this._detailTableContainer.className="timing-detail-table-container",this._detailTable=document.createElement("table"),this._detailTable.className="timing-table",this._detailTableContainer.appendChild(this._detailTable),e.appendChild(this._detailTableContainer),this._headerTooltip=document.createElement("div"),this._headerTooltip.className="or-tooltip or-tooltip-fixed",e.appendChild(this._headerTooltip),this.element=e,this._bindEvents(),ue(this._app)&&setTimeout(()=>this.update(),0)}_makeTab(e,t){let i=document.createElement("button");return i.className="timing-tab"+(t?" active":""),i.textContent=e,i}_bindEvents(){this._setupTab.addEventListener("click",()=>{this._currentTab="setup",this._setupTab.classList.add("active"),this._holdTab.classList.remove("active"),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}),this._holdTab.addEventListener("click",()=>{this._currentTab="hold",this._holdTab.classList.add("active"),this._setupTab.classList.remove("active"),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}),this._dataTab.addEventListener("click",()=>{this._detailTab="data",this._dataTab.classList.add("active"),this._captureTab.classList.remove("active"),this._renderDetailTable()}),this._captureTab.addEventListener("click",()=>{this._detailTab="capture",this._captureTab.classList.add("active"),this._dataTab.classList.remove("active"),this._renderDetailTable()}),this._updateBtn.addEventListener("click",()=>this.update()),this._pathTableContainer.setAttribute("tabindex","0"),this._pathTableContainer.style.outline="none",this._pathTableContainer.addEventListener("keydown",e=>{if(e.key==="ArrowDown"){e.preventDefault();let t=this._pathTable.querySelectorAll("tbody tr");this._selectedPathIndex0&&this._selectPathRow(this._selectedPathIndex-1))}),this._detailTableContainer.setAttribute("tabindex","0"),this._detailTableContainer.style.outline="none",this._detailTableContainer.addEventListener("keydown",e=>{if(e.key==="ArrowDown"){e.preventDefault();let t=this._detailTable.querySelectorAll("tbody tr");this._selectedDetailIndex0&&this._selectDetailRow(this._selectedDetailIndex-1))})}_buildConePanel(){let e=document.createElement("div");e.className="timing-cone-panel";let t=document.createElement("span");t.className="timing-cone-title",t.textContent="Timing cone:",e.appendChild(t);let i=(u,f,d=!1)=>{let h=document.createElement("input");h.type="checkbox",h.id=u,h.checked=d;let p=document.createElement("label");return p.htmlFor=u,p.textContent=f,{input:h,lbl:p}},r=i("cone-fanin","Fanin",!0),s=i("cone-fanout","Fanout",!0);this._coneFanin=r.input,this._coneFanout=s.input,e.append(r.input,r.lbl,s.input,s.lbl);let o=u=>{let f=document.createElement("label");f.className="timing-cone-depth-label",f.textContent=u;let d=document.createElement("input");return d.type="number",d.min="0",d.value="0",d.className="timing-cone-depth",d.title="0 = unlimited",f.appendChild(d),{lbl:f,input:d}},a=o("in\u2264"),c=o("out\u2264");this._coneFaninDepth=a.input,this._coneFanoutDepth=c.input,e.append(a.lbl,c.lbl),this._coneColorMode=document.createElement("select"),this._coneColorMode.className="timing-cone-colormode";for(let[u,f]of[["slack","by slack"],["depth","by depth"]]){let d=document.createElement("option");d.value=u,d.textContent=f,this._coneColorMode.appendChild(d)}e.appendChild(this._coneColorMode);let l=i("cone-sync-schematic","Sync schematic");return this._coneSyncSchematic=l.input,e.append(l.input,l.lbl),this._coneApplyBtn=document.createElement("button"),this._coneApplyBtn.className="or-btn",this._coneApplyBtn.textContent="Cone",this._coneApplyBtn.title="Show the timing cone for the selected instance",this._coneClearBtn=document.createElement("button"),this._coneClearBtn.className="or-btn",this._coneClearBtn.textContent="Clear",e.append(this._coneApplyBtn,this._coneClearBtn),this._coneStatus=document.createElement("span"),this._coneStatus.className="timing-cone-status",e.appendChild(this._coneStatus),this._coneApplyBtn.addEventListener("click",()=>this._applyCone()),this._coneClearBtn.addEventListener("click",()=>this._clearCone()),e}_coneTarget(){return this._app.selectedInstanceName||""}async _applyCone(){let e=this._coneFanin.checked,t=this._coneFanout.checked;if(!e&&!t){this._coneStatus.textContent="select fanin and/or fanout";return}let i=this._coneTarget();if(!i){this._coneStatus.textContent="select an instance first";return}let r={type:"timing_cone",fanin:e,fanout:t,fanin_depth:Math.max(0,parseInt(this._coneFaninDepth.value,10)||0),fanout_depth:Math.max(0,parseInt(this._coneFanoutDepth.value,10)||0),color_mode:this._coneColorMode.value,inst_name:i};this._coneApplyBtn.disabled=!0,this._coneStatus.textContent="computing\u2026";try{let s=await this._app.websocketManager.request(r);this._refreshOverlay(),this._renderConeStatus(s),this._coneSyncSchematic.checked&&i&&document.dispatchEvent(new CustomEvent("openroad-cone-sync",{detail:{inst_name:i,fanin:r.fanin,fanout:r.fanout,fanin_depth:r.fanin_depth,fanout_depth:r.fanout_depth}}))}catch(s){this._coneStatus.textContent="cone error: "+(s.message||s)}this._coneApplyBtn.disabled=!1}_renderConeStatus(e){if(!e){this._coneStatus.textContent="";return}let t=e.node_count||0;if(t===0){this._coneStatus.textContent="empty cone";return}let i=t+" pins";if(e.color_mode==="depth")i+=`, depth \xB1${e.max_depth}`;else if(e.constrained){let r=e.time_unit||"";i+=`, slack ${Ss(e.min_slack)}\u2026${Ss(e.max_slack)}${r}`}else i+=", unconstrained";this._coneStatus.textContent=i}_clearCone(){this._app.websocketManager.request({type:"timing_cone",clear:!0}).then(()=>this._refreshOverlay()),this._coneStatus.textContent=""}showPaths(e,t){this._currentTab=e,e==="setup"?(this._setupPaths=[...t],this._setupTab.classList.add("active"),this._holdTab.classList.remove("active")):(this._holdPaths=[...t],this._holdTab.classList.add("active"),this._setupTab.classList.remove("active")),this._applySort(),this._selectedPathIndex=-1,this._pathCountLabel.textContent=t.length+" paths",this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...";try{let[e,t]=await Promise.all([this._app.websocketManager.request({type:"timing_report",is_setup:!0,max_paths:100}),this._app.websocketManager.request({type:"timing_report",is_setup:!1,max_paths:100})]);this._setupPaths=[...e.paths||[]],this._holdPaths=[...t.paths||[]],this._applySort(),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}catch(e){console.error("Timing fetch failed:",e)}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}_applySort(){for(let e of[this._setupPaths,this._holdPaths]){e.forEach((r,s)=>{r._originalIndex===void 0&&(r._originalIndex=s)});let t=this._sortAscending?1:-1,i=this._sortCol;e.sort((r,s)=>{let o=r[i],a=s[i],c=typeof o=="number"&&typeof a=="number"?o-a:String(o).localeCompare(String(a));return t*c})}}_showHeaderTooltip(e,t){if(e.buttons!==0){this._hideHeaderTooltip();return}let i=this._headerTooltip;i.textContent=t,i.style.display="block";let r=Math.min(e.clientX+12,window.innerWidth-i.offsetWidth-8);i.style.left=Math.max(0,r)+"px",i.style.top=e.clientY+14+"px"}_hideHeaderTooltip(){this._headerTooltip.style.display="none"}_sortBy(e){this._sortCol===e?this._sortAscending=!this._sortAscending:(this._sortCol=e,this._sortAscending=!0),this._applySort(),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}_clearTimingHighlight(){this._app.websocketManager.request({type:"timing_highlight",path_index:-1}).then(()=>this._refreshOverlay())}_selectPathRow(e){let t=this._pathTable.querySelectorAll("tbody tr");if(e<0||e>=t.length)return;this._selectedPathIndex=e;for(let s of t)s.classList.remove("selected");t[e].classList.add("selected"),t[e].scrollIntoView({block:"nearest"}),this._pathTableContainer.focus(),this._renderDetailTable();let r=(this._currentTab==="setup"?this._setupPaths:this._holdPaths)[e]?._originalIndex??e;this._app.websocketManager.request({type:"timing_highlight",path_index:r,is_setup:this._currentTab==="setup"}).then(()=>this._refreshOverlay()).catch(s=>console.error("timing_highlight error:",s))}_renderPathTable(){this._hideHeaderTooltip();let e=this._currentTab==="setup"?this._setupPaths:this._holdPaths;this._pathCountLabel.textContent=e.length+" paths";let t=this._pathTable.querySelectorAll("thead th"),i=Array.from(t,c=>c.style.width);this._pathTable.innerHTML="";let r=document.createElement("thead"),s=document.createElement("tr");for(let c of n.PATH_COLS){let l=document.createElement("th");l.classList.add("sortable"),c.num&&l.classList.add("num"),l.textContent=c.label+(c.key===this._sortCol?this._sortAscending?" \u25B2":" \u25BC":""),c.tooltip&&(l.addEventListener("mousemove",u=>this._showHeaderTooltip(u,c.tooltip)),l.addEventListener("mouseleave",()=>this._hideHeaderTooltip())),l.addEventListener("click",()=>this._sortBy(c.key)),s.appendChild(l)}r.appendChild(s),this._pathTable.appendChild(r);let o=document.createElement("tbody"),a=e.reduce((c,l)=>Math.max(c,Math.abs(Number(l.slack)||0)),0);if(e.forEach((c,l)=>{let u=document.createElement("tr");l===this._selectedPathIndex&&u.classList.add("selected");for(let f of n.PATH_COLS){let d=document.createElement("td"),h=c[f.key];if(d.textContent=f.time?Ss(h):h,f.num&&d.classList.add("num"),f.key==="slack"){let p=Number(c.slack);p<0&&d.classList.add("slack-negative"),Number.isFinite(p)&&a>0&&(d.classList.add("slack-cell",p<0?"slack-under":"slack-over"),d.style.setProperty("--slack-frac",String(Math.abs(p)/a)))}u.appendChild(d)}u.style.cursor="pointer",u.addEventListener("click",()=>this._selectPathRow(l)),o.appendChild(u)}),e.length===0){let c=document.createElement("tr"),l=document.createElement("td");l.colSpan=n.PATH_COLS.length,l.style.textAlign="center",l.style.color="var(--fg-secondary)",l.textContent=ue(this._app)?"No timing data available":'Click "Update" to load timing paths',c.appendChild(l),o.appendChild(c)}this._pathTable.appendChild(o),ws(this._pathTable,i)}_selectDetailRow(e){let t=this._detailTable.querySelectorAll("tbody tr");if(e<0||e>=t.length)return;this._selectedDetailIndex=e;for(let a of t)a.classList.remove("timing-selected-row");t[e].classList.add("timing-selected-row"),t[e].scrollIntoView({block:"nearest"}),this._detailTableContainer.focus();let r=(this._currentTab==="setup"?this._setupPaths:this._holdPaths)[this._selectedPathIndex],s=this._detailTab==="data"?r.data_nodes:r.capture_nodes,o=r._originalIndex??this._selectedPathIndex;this._app.websocketManager.request({type:"timing_highlight",path_index:o,is_setup:this._currentTab==="setup",pin_name:s[e].pin}).then(()=>this._refreshOverlay())}_renderDetailTable(){let e=this._detailTable.querySelectorAll("thead th"),t=Array.from(e,l=>l.style.width);this._detailTable.innerHTML="",this._selectedDetailIndex=-1;let i=this._currentTab==="setup"?this._setupPaths:this._holdPaths;if(this._selectedPathIndex<0||this._selectedPathIndex>=i.length)return;let r=i[this._selectedPathIndex],s=this._detailTab==="data"?r.data_nodes:r.capture_nodes,o=document.createElement("thead"),a=document.createElement("tr");for(let l of n.DETAIL_COLS){let u=document.createElement("th");n.DETAIL_NUM_COLS.has(l)&&u.classList.add("num"),u.textContent=l,a.appendChild(u)}o.appendChild(a),this._detailTable.appendChild(o);let c=document.createElement("tbody");if(s.forEach((l,u)=>{let f=document.createElement("tr");l.clk&&f.classList.add("timing-clock-row"),[l.pin,l.fanout,l.rise?"\u2191":"\u2193",Ss(l.time),Ss(l.delay),Ss(l.slew),Ss(l.load)].forEach((h,p)=>{let m=document.createElement("td");n.DETAIL_NUM_COLS.has(n.DETAIL_COLS[p])&&m.classList.add("num"),m.textContent=h,f.appendChild(m)}),f.style.cursor="pointer",f.addEventListener("click",()=>this._selectDetailRow(u)),c.appendChild(f)}),this._detailTable.appendChild(c),ws(this._detailTable,t),!t[0]){let l=this._detailTable.querySelector("thead th");l&&(l.style.width="30ch")}}};function Ss(n){return n==null?"":typeof n=="number"?n.toFixed(4):String(n)}Ps.PATH_COLS=[{label:"Clock",key:"end_clk"},{label:"Required",key:"required",time:!0,num:!0},{label:"Arrival",key:"arrival",time:!0,num:!0},{label:"Slack",key:"slack",time:!0,num:!0},{label:"Skew",key:"skew",time:!0,num:!0,tooltip:`The difference in arrival times between +
`,document.body.appendChild(r);let s=()=>r.remove();r.addEventListener("click",c=>{c.target===r&&s()}),r.addEventListener("keydown",c=>{c.key==="Escape"&&s()}),r.querySelector(".cancel").addEventListener("click",s),r.querySelector(".modal-close").addEventListener("click",s);let o=r.querySelector(".modal-error"),a=(c,l)=>{o.textContent=c,o.style.display=c?"block":"none",o.classList.toggle("info",!!l)};return{overlay:r,close:s,okBtn:r.querySelector(".ok"),showError:a}}var RV=1e4,IV=150,BV=3;function OV(n){return 1-(1-n)*(1-n)}var Oh=class{constructor({isEnabled:e=()=>!0,isSmooth:t=()=>!1,reducedMotion:i=Vl,now:r=()=>performance.now(),setTimer:s=(u,f)=>setTimeout(u,f),clearTimer:o=u=>clearTimeout(u),timeoutMs:a=RV,fadeMs:c=IV,onChange:l=()=>{}}={}){Object.assign(this,{isEnabled:e,isSmooth:t,reducedMotion:i,now:r,setTimer:s,clearTimer:o,timeoutMs:a,fadeMs:c,onChange:l}),this.shownZ=null,this.pendingZ=null,this.under=[],this.fade=null,this._timer=null}wantedZ(){return this.pendingZ!==null?this.pendingZ:this.shownZ}setZoom(e,{hasContent:t=!0}={}){e!==this.wantedZ()&&(this.endFade(),this._clearTimer(),this.shownZ===null?(this.shownZ=e,this.pendingZ=null,this.under=[]):t?e===this.shownZ?this.pendingZ=null:this.isEnabled()?(this.pendingZ=e,this.under=[],this._timer=this.setTimer(()=>this.reveal(),this.timeoutMs)):(this.under=[...this.under.filter(i=>i!==e),this.shownZ].slice(-BV),this.shownZ=e,this.pendingZ=null):(this.shownZ=e,this.pendingZ=null,this.under=this.under.filter(i=>i!==e)),this.onChange())}check({settled:e,animating:t=!1}){return this.pendingZ!==null?t||!e&&this.isEnabled()?!1:(this.reveal(),!0):this.under.length>0&&e&&!t?(this.under=[],this.onChange(),!0):!1}reveal(){if(this.pendingZ===null)return;this._clearTimer();let e=this.shownZ;this.shownZ=this.pendingZ,this.pendingZ=null;let t=this.isSmooth()&&!this.reducedMotion()?this.fadeMs:0;this.fade=t>0&&e!==null?{fromZ:e,toZ:this.shownZ,start:this.now(),ms:t}:null,this.onChange()}endFade(){this.fade&&(this.fade=null,this.onChange())}plan(e=this.now()){if(this.fade){let t=(e-this.fade.start)/this.fade.ms;if(t<1)return{draw:[{z:this.fade.fromZ,opacity:1},{z:this.fade.toZ,opacity:OV(Math.max(0,t))}],fading:!0};this.fade=null}return this.shownZ===null?{draw:[],fading:!1}:this.pendingZ!==null?{draw:[{z:this.shownZ,opacity:1}],fading:!1}:this.under.length>0?{draw:[...this.under,this.shownZ].map(t=>({z:t,opacity:1})),fading:!1}:{draw:[{z:this.shownZ,opacity:1}],fading:!1}}isIdle(e=this.now()){return this.pendingZ===null&&this.under.length===0&&!this.plan(e).fading}dispose(){this._clearTimer()}_clearTimer(){this._timer!==null&&(this.clearTimer(this._timer),this._timer=null)}};var ot=Object.freeze({base:10,overlay:20,heatmap:30,top:40,pathImage:50,selection:60,highlight:70,ruler:80}),Es={depthCompare:"always",depthWriteEnabled:!1},j3=250,H3=4,Jb=300,DV=1,NV=2,FV=300,zV=300,UV=400,$V=1e3,Y3=100,GV=.05,q3=1200,Z3=30;function Ut(n,e=1){if(Array.isArray(n)){let r=n.length>3?n[3]:255;return[n[0],n[1],n[2],Math.round(r*e)]}let t=String(n||"#000").replace("#","");t.length===3&&(t=t.split("").map(r=>r+r).join(""));let i=parseInt(t.slice(0,6),16)||0;return[i>>16&255,i>>8&255,i&255,Math.round(255*e)]}function VV(n){return 1-Math.pow(1-n,3)}function WV(n){return n<.5?4*n*n*n:1-Math.pow(2-2*n,3)/2}function jV(){let n=new Map;return{on(e,t){for(let i of e.split(/\s+/))n.has(i)||n.set(i,new Set),n.get(i).add(t)},off(e,t){for(let i of e.split(/\s+/))n.get(i)?.delete(t)},emit(e,t){for(let i of[...n.get(e)||[]])i(t)}}}function HV(n){let e=n&&n.device&&n.device.info||{};return{gpuType:e.gpuType||"unknown",renderer:e.renderer||"",vendor:e.vendor||""}}function X3(n,e={}){let t=e.deckApi!==void 0?e.deckApi:globalThis.deck,i=e.copyCanvas||qb,r={smooth:()=>!1,doubleBuffer:()=>!0,defer:()=>!1,...e.prefs||{}},s=e.tileSize||(()=>240),o=e.dpr||(()=>typeof devicePixelRatio=="number"?devicePixelRatio:1),a=e.raf||(P=>requestAnimationFrame(P)),c=e.now||(()=>performance.now()),l=jV(),u={target:[0,0],zoom:0,width:1,height:1},f={minZoom:-1/0,maxZoom:Z3},d=null,h=!1,p=[],m=null,g=[],v=null,y=null,b=!1,x=!1,E=0,w=new Set,T=!1;n.classList.add("or-view");let R=document.createElement("div");R.className="or-view-canvas",n.appendChild(R);let F=document.createElement("div");F.className="or-view-markers",n.appendChild(F);let O=new Map,j=new Map,V=new Map,G=new Map,q=new WeakMap,X=[],se=ur(Q,a),le=new Oh({isEnabled:()=>r.doubleBuffer(),isSmooth:()=>r.smooth(),now:c,onChange:()=>se()}),he=null;function at(){return{dragPan:!0,dragRotate:!1,scrollZoom:!1,doubleClickZoom:!1,touchZoom:!e.isStatic,touchRotate:!1,keyboard:!1,inertia:!1}}function Ct(){return{target:[u.target[0],u.target[1],0],zoom:u.zoom,minZoom:f.minZoom,maxZoom:f.maxZoom}}function Tn(){return new t.Deck({parent:R,views:new t.OrthographicView({id:"main",flipY:!1,controller:at()}),viewState:Ct(),layers:[],useDevicePixels:!0,deviceProps:{webgl:{preserveDrawingBuffer:!!e.preserveDrawingBuffer}},getCursor:({isDragging:P})=>w.size?"crosshair":P?"grabbing":"default",onViewStateChange:({viewState:P})=>{if(d=null,Gt(P.target,P.zoom),h){let k=c();g.push({t:k,target:[...u.target],zoom:u.zoom}),g=g.filter($=>k-$.t<=Y3)}return Ct()},onInteractionStateChange:P=>{let k=!!(P.isDragging||P.isPanning||P.isZooming||P.inTransition);if(k!==h){if(h=k,k){g=[],ui();return}queueMicrotask(()=>{!h&&!d&&!Ge()&&fi()})}},onLoad:()=>{Ni(),m=HV(he),l.emit("renderer",m),se()},onAfterRender:()=>{let P=p;p=[],P.forEach(k=>k())}})}function Ni(){let P=he.getCanvas&&he.getCanvas();P?.addEventListener("webglcontextlost",k=>{if(k.preventDefault(),T)return;l.emit("contextlost");let $=he;he=null,q=new WeakMap,X=[];try{$.finalize?.()}catch{}P.remove();try{he=Tn(),l.emit("contextrestored")}catch(W){l.emit("contextfailed",W)}se()})}t&&typeof t.Deck=="function"&&(he=Tn());function Ln(){let P=o(),k=Math.max(1,Math.floor(n.clientWidth*P)/P),$=Math.max(1,Math.floor(n.clientHeight*P)/P),W=k!==u.width||$!==u.height;return u.width=k,u.height=$,R.style.width=k+"px",R.style.height=$+"px",W}Ln();let li=null;typeof ResizeObserver=="function"&&(li=new ResizeObserver(()=>cn()),li.observe(n));function cn(){Ln()?(ln(),l.emit("resize",yt())):se()}function Gt(P,k,{tiles:$=!0}={}){let W=bs(k,f),re=W!==u.zoom;u.target=[P[0],P[1]],u.zoom=W,ln(re,$)}function ln(P=!1,k=!0){he&&he.setProps({viewState:Ct()}),P&&l.emit("zoom"),l.emit("move"),k&&Wt(),se()}function ui(){x||(x=!0,l.emit("movestart"))}function fi(){if(d||h)return;let P=Math.round(u.zoom);if(Math.abs(P-u.zoom)>1e-9){Vt({target:Mh(u,[u.width/2,u.height/2],P),zoom:P},{anchor:null});return}u.target=a3(u,o());let k=x;x=!1,ln(),k&&(l.emit("moveend"),l.emit("zoomend"))}function Ge(){let P=g;if(g=[],!r.smooth()||P.length<2)return!1;let k=P[0],$=P[P.length-1],W=$.t-k.t;if(W<=0||c()-$.t>Y3||k.zoom!==$.zoom)return!1;let re=($.target[0]-k.target[0])/W,ee=($.target[1]-k.target[1])/W;return Math.hypot(re,ee)*Math.pow(2,u.zoom)H3?0:j3}function Vt(P,{anchor:k=null,ms:$=void 0,settle:W=!0,curve:re=!1}={}){P={target:P.target,zoom:bs(P.zoom,f)};let ee=re&&$===void 0?di(P):null;if($===void 0&&($=ee?ee.ms:_t(P)),ui(),P.zoom!==u.zoom&&l.emit("zoomstart"),$<=0){d=null;let oe=W&&!h;Gt(P.target,P.zoom,{tiles:!oe}),W&&fi();return}y=null,d={from:{...u,target:[...u.target]},to:P,anchor:k,start:ee?null:c(),created:c(),ms:$,flight:ee},Wt(),hi()}function di(P){if(!r.smooth()||!(Math.hypot(P.target[0]-u.target[0],P.target[1]-u.target[1])*Math.pow(2,Math.min(u.zoom,P.zoom))>NV*Math.max(u.width,u.height))&&Math.abs(P.zoom-u.zoom)<=H3)return null;let W=c3(u,{...u,...P}),re=1/0,ee=null;for(let de=0;de<=16;de++){let Y=W.at(de/16);re=Math.min(re,Y.zoom);let pe=jo({...u,...Y});ee=ee?[Math.min(ee[0],pe[0]),Math.min(ee[1],pe[1]),Math.max(ee[2],pe[2]),Math.max(ee[3],pe[3])]:pe}let oe=Math.max(0,zb(re)),_e=Fl(ee,oe,s());return{path:W,ms:Math.min($V,Math.max(UV,zV*W.S)),apex:_e?{z:oe,range:_e}:null}}function Mn(P){return!P||[...O.values()].every(k=>!k.visible||k.grid.settledIn(P.z,P.range))}function hi(){if(!d||T)return;if(d.start===null){if(!Mn(d.flight.apex)&&c()-d.created=1){let re=d.to;y=d.flight?d.flight.apex:null,d=null,Gt(re.target,re.zoom),fi();return}Gt(W,$),a(hi)}function Ke(){return d?{...u,target:d.to.target,zoom:d.to.zoom}:u}function Wt(){if(O.size===0)return;let P=r.doubleBuffer(),k=bs(zb(u.zoom,{targetZoom:d?d.to.zoom:null,hidingNewLevels:P}),{minZoom:0,maxZoom:Z3}),$=Ke(),W=Fl(jo($),k,s()),re=Ah(W),ee=le.shownZ,oe=r.defer()&&h;oe||le.setZoom(k,{hasContent:[...O.values()].some(pe=>pe.visible&&ee!==null&&pe.grid.hasContentAt(ee))});let _e=[];k>0&&!d&&!h&&!x&&le.pendingZ===null&&(v=k-1,_e.push({z:v,range:Fl(Ub(jo($),DV),v,s())}));let de=un();de&&_e.push({...de,background:!1});let Y=d?Fl(jo(u),k,s()):null;for(let pe of O.values())pe.visible&&!oe&&pe.grid.update({z:k,range:W,ring:re,extra:_e,hold:Y});yr()}function un(){return d&&d.flight&&d.flight.apex||y}function An(P){let k=[];for(let $ of[un()?.z,le.pendingZ])$!=null&&!k.includes($)&&!P.some(W=>W.z===$)&&k.push($);return k}function Rs(){b||(b=!0,queueMicrotask(()=>{b=!1,T||Wt()}))}function pi(){for(let P of O.values())if(P.visible&&!P.grid.isSettled())return!1;return!0}function yr(P){let k=le.check({settled:pi(),animating:!!d});k&&le.pendingZ===null&&Rs();let $=!1;y&&!d&&le.isIdle()&&pi()&&(y=null,$=!0),(k||$||!P||kn(P.z))&&se()}function kn(P){let k=le.plan(c()).draw;return k.some($=>$.z===P)||An(k).includes(P)}function jt(P,{order:k,source:$,visible:W=!0}){let re={load:(oe,_e)=>$.load(oe,_e),release:oe=>{let _e=oe&&q.get(oe);_e&&(q.delete(oe),X.push(_e)),$.release?.(oe)}},ee={id:P,order:k,visible:W,grid:new kh({source:re,onChange:oe=>yr(oe)})};return O.set(P,ee),Wt(),{id:P,setVisible(oe){ee.visible!==!!oe&&(ee.visible=!!oe,ee.visible||ee.grid.clear(),Wt())},isVisible:()=>ee.visible,refresh(){ee.visible&&(ee.grid.refresh(),se())},remove(){ee.grid.clear(),O.delete(P),se()}}}function Re(P){if(!he||!he.device)return P.image;let k=q.get(P);if(!k){try{k=he.device.createTexture({data:P.image,width:P.width,height:P.height,mipLevels:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}})}catch{return P.image}q.set(P,k)}return k}function na(P){if(P>=E)return 1;let k=(q3-(E-P))%400/400;return 1-.7*(.5-.5*Math.cos(2*Math.PI*k))}let Ce=new WeakMap,M=null;function S(P){let k=s();k!==M&&(Ce=new WeakMap,M=k);let $=Ce.get(P);return $||($=o3(P.z,P.x,P.y,k),Ce.set(P,$)),$}function L(P,k,$,W,re,ee){for(let oe of k.grid.drawableTilesAt($)){let _e=S(oe);$b(_e,W)&&P.push({order:k.order,props:{id:`${k.id}:${re}${oe.key}`,image:Re(oe.drawable),bounds:_e,opacity:ee,parameters:Es}})}}function D(P,k){let $=[],W=le.plan(P);if(!W.fading&&le.pendingZ===null&&W.draw.length>0){let de=[...W.draw.map(Y=>Y.z),v,un()?.z].filter(Y=>Y!=null);for(let Y of O.values())Y.grid.prune(de)}let re=na(P),ee=[...O.values()].sort((de,Y)=>de.order-Y.order),oe=ee.find(de=>de.visible),_e=An(W.draw);for(let de of ee)if(de.visible){de===oe&&_e.length>0&&$.push(...A(de,_e,W.draw,k,re));for(let Y of W.draw)L($,de,Y.z,k,"",Y.opacity*re)}return{layers:$,animate:W.fading||Ppe.z===de.z)||de.loading&&!de.drawable)continue;let Y=S(de);if($b(Y,W)){let[pe,Rn,lp,ia]=Y;_e.push([[pe-oe,Rn-oe],[lp+oe,Rn-oe],[lp+oe,ia+oe],[pe-oe,ia+oe]])}}return _e.length&&ee.push({order:P.order,kind:"SolidPolygonLayer",props:{id:`${P.id}:mask`,data:_e,getPolygon:de=>de,getFillColor:z(),parameters:Es}}),ee}function z(){let P=(getComputedStyle(n).backgroundColor||"").match(/[\d.]+/g);return!P||P.length<3||P.length>3&&Number(P[3])===0?[0,0,0,255]:[Number(P[0]),Number(P[1]),Number(P[2]),255]}function I(P,k,$){let W=[],re=[],ee=[],oe=[];for(let Y of k){if(Y.kind==="circle"){oe.push(Y);continue}let pe=Y.kind==="rect"?[[Y.rect[0],Y.rect[1]],[Y.rect[2],Y.rect[1]],[Y.rect[2],Y.rect[3]],[Y.rect[0],Y.rect[3]]]:Y.points;if(Y.fill&&re.push({polygon:pe,color:Y.fill}),Y.stroke){let Rn=Y.kind==="rect"||Y.closed;ee.push({path:Rn?[...pe,pe[0]]:pe,color:Y.stroke,width:Y.width||1,dash:Y.dash||null})}}re.length&&W.push({order:$,kind:"SolidPolygonLayer",props:{id:`${P}:fill`,data:re,getPolygon:Y=>Y.polygon,getFillColor:Y=>Y.color,parameters:Es}});let _e=ee.filter(Y=>!Y.dash),de=ee.filter(Y=>Y.dash);if(_e.length&&W.push({order:$,kind:"PathLayer",props:{id:`${P}:stroke`,data:_e,widthUnits:"pixels",getPath:Y=>Y.path,getColor:Y=>Y.color,getWidth:Y=>Y.width,parameters:Es}}),de.length){let Y={id:`${P}:dash`,data:de,widthUnits:"pixels",getPath:pe=>pe.path,getColor:pe=>pe.color,getWidth:pe=>pe.width,getDashArray:pe=>pe.dash.map(Rn=>Rn/pe.width),dashJustified:!0,parameters:Es};t?.PathStyleExtension&&(Y.extensions=[new t.PathStyleExtension({dash:!0})]),W.push({order:$,kind:"PathLayer",props:Y})}return oe.length&&W.push({order:$,kind:"ScatterplotLayer",props:{id:`${P}:circle`,data:oe,radiusUnits:"pixels",lineWidthUnits:"pixels",getPosition:Y=>Y.center,getRadius:Y=>Y.radius,stroked:!0,filled:!0,getLineColor:Y=>Y.stroke||[0,0,0,0],getFillColor:Y=>Y.fill||[0,0,0,0],getLineWidth:Y=>Y.width||1,parameters:Es}}),W}function B(){let P=[];for(let k of j.values())P.push(...k);return P.push(...V.values()),P}function U(P){return P.map(k=>new t[k.kind||"BitmapLayer"](k.props))}let Z=0;function Q(){if(T)return;let P=c(),k=D(P,Ub(jo(u),.5)),$=[...k.layers,...B()].sort((W,re)=>W.order-re.order);Z=$.length,he&&he.setProps({layers:U($)});for(let W of X.splice(0))W.destroy?.();Oe(),k.animate&&se(),l.emit("render")}function ye(P=32,k=20){let $=O.get("base");if(!$)return null;let W=s(),re=le.plan(c()).draw,ee=[...re,...An(re).map(de=>({z:de}))],oe=0,_e=0;for(let de=0;de=W||Rn>=W)continue;oe++,ee.some(({z:ia})=>{let _v=W/2**ia,up=$.grid.tiles.get(Ho(ia,Math.floor(pe/_v),Math.floor((W-Rn)/_v)));return up&&(up.drawable||!up.loading)})&&_e++}return oe?_e/oe:null}function be(P){return G.has(P)||G.set(P,{visible:!0,items:new Map}),G.get(P)}function je(P,k){let[$,W]=Lh(P.world,u);P.el.style.display=k?"":"none",P.el.style.transform=`translate(${$}px, ${W}px)`+(P.center?" translate(-50%, -50%)":"")}function Be(P){for(let k of P.items.values())je(k,P.visible)}function Oe(){for(let P of G.values())Be(P)}function yt(){return{width:u.width,height:u.height}}let K={DRAW_ORDER:ot,getContainer:()=>n,getRendererInfo:()=>m,getSize:yt,getZoom:()=>u.zoom,getTargetZoom:()=>d?d.to.zoom:u.zoom,getCenter:()=>[...u.target],getViewState:()=>({...u,target:[...u.target]}),isAnimating:()=>!!d,isMoving:()=>x,project:P=>Lh(P,u),unproject:P=>Wo(P,u),on:l.on,off:l.off,setLimits({minZoom:P,maxZoom:k}={}){P!==void 0&&(f.minZoom=P),k!==void 0&&(f.maxZoom=k);let $=bs(u.zoom,f);$!==u.zoom?Gt(u.target,$):he&&he.setProps({viewState:Ct()}),l.emit("limits")},getLimits:()=>({...f}),setView(P,k=u.zoom,{animate:$}={}){let W={target:[P[0],P[1]],zoom:k};Vt(W,$===!1?{ms:0}:{curve:!0})},fitWorldRect(P,{padding:k=[0,0],animate:$}={}){let W=s3(P,u,{padding:k,...f});Vt(W,$===!1?{ms:0}:{curve:!0})},zoomAround(P,k,{animate:$,settle:W=!0}={}){let re=bs(K.getTargetZoom()+k,f),ee=Ke(),oe=P||[u.width/2,u.height/2],_e=Mh(ee,oe,re);Vt({target:_e,zoom:re},$===!1?{ms:0,settle:W}:{anchor:P?oe:null})},zoomIn:()=>K.zoomAround(null,1),zoomOut:()=>K.zoomAround(null,-1),panByPx(P,k,{animate:$}={}){let W=Ke(),re=Math.pow(2,W.zoom),ee=[W.target[0]+P/re,W.target[1]-k/re],oe=$===!1||!r.smooth()?0:j3;Vt({target:ee,zoom:W.zoom},{ms:oe})},invalidateSize:cn,applyPrefs(){Wt()},addTileSlot:jt,setOverlay(P,k,{order:$=ot.selection}={}){!k||k.length===0?j.delete(P):j.set(P,I(P,k,$)),se()},hasOverlay:P=>j.has(P),setImageOverlay(P,k,{order:$=ot.pathImage}={}){k?V.set(P,{order:$,kind:"BitmapLayer",props:{id:`image:${P}`,image:k.image,bounds:k.rect,parameters:Es}}):V.delete(P),se()},addMarker(P,k,$,W,{center:re=!1}={}){let ee=be(P),oe=ee.items.get(k);oe&&oe.el.remove(),W.classList.add("or-view-marker"),F.appendChild(W);let _e={el:W,world:[$[0],$[1]],center:re};return ee.items.set(k,_e),je(_e,ee.visible),W},moveMarker(P,k,$){let W=be(P),re=W.items.get(k);re&&(re.world=[$[0],$[1]],je(re,W.visible))},clearMarkers(P){let k=be(P);for(let $ of k.items.values())$.el.remove();k.items.clear()},setMarkerGroupVisible(P,k){let $=be(P);$.visible=!!k,Be($)},setCursorMode(P,k=!0){k?w.add(P):w.delete(P),n.classList.toggle(`${P}-mode-cursor`,!!k);let $=he&&he.getCanvas&&he.getCanvas();$&&($.style.cursor=w.size?"crosshair":"default")},flashTiles(){E=c()+q3,se()},whenTilesSettled({timeoutMs:P=6e3}={}){let k=c()+P;return new Promise($=>{let W=()=>{if(pi()&&le.isIdle()&&!d&&!x||c()>=k){$();return}setTimeout(W,32)};W()})},captureCanvas({timeoutMs:P=500}={}){return he?.getCanvas()?(Q(),new Promise(k=>{let $=null,W=()=>{clearTimeout($),p=p.filter(ee=>ee!==W);let re=he?.getCanvas();k(re?{image:i(re),rect:re.getBoundingClientRect()}:null)};p.push(W),$=setTimeout(()=>{he?.redraw("capture"),W()},P)})):Promise.resolve(null)},redraw:()=>se(),debugSnapshot(){let P=le.plan();return{zoom:u.zoom,target:[...u.target],width:u.width,height:u.height,animating:!!d,moving:x,interacting:h,shownZ:le.shownZ,pendingZ:le.pendingZ,fading:P.fading,drawLevels:P.draw,layers:Z,coverage:ye(),overlays:[...j.keys()],markers:Object.fromEntries([...G].map(([k,$])=>[k,$.items.size])),slots:[...O.values()].map(k=>({id:k.id,visible:k.visible,settled:k.grid.isSettled(),...k.grid.stats()}))}},destroy(){T=!0,li?.disconnect(),le.dispose();for(let P of O.values())P.grid.clear();he?.finalize?.()}};return K}var YV=4.000244140625;function qV(n){return n.deltaMode!==0?!0:n.deltaX!==0||n.deltaY===0?!1:Number.isInteger(n.deltaY)&&Math.abs(n.deltaY)>=50||n.deltaY%YV===0}function ZV(n){let e=Math.abs(n);return e<.2?0:Math.sign(n)*Math.max(1,Math.round(e))}function XV(n,e){let i=1;return n.deltaMode===1?i=16:n.deltaMode===2&&(i=e.clientHeight||16),[n.deltaX*i,n.deltaY*i]}function KV(n,e,t){let i=t?3*e:e;switch(n){case"ArrowLeft":return[-i,0];case"ArrowRight":return[i,0];case"ArrowUp":return[0,-i];case"ArrowDown":return[0,i];default:return null}}function Q3(n,e={}){let t=n.getContainer(),i=e.isStatic||(()=>!1),r=e.wheelZoom||(()=>!0),s=e.arrowStep||(()=>80),o=e.gestureIdleMs??200,a=e.contextEnabled||(()=>!0),c=[],l=(w,T,R,F)=>{w.addEventListener(T,R,F),c.push(()=>w.removeEventListener(T,R,F))},u=w=>{let T=t.getBoundingClientRect();return[w.clientX-T.left,w.clientY-T.top]},f=w=>n.unproject(u(w)),d=w=>w.target===t||!!w.target?.closest?.(".or-view-canvas");t.tabIndex<0&&(t.tabIndex=0);let h=null;function p(w,T){h||(h={z0:n.getZoom()}),h.pt=w,clearTimeout(h.timer),h.timer=setTimeout(m,o),n.zoomAround(w,T,{animate:!1,settle:!1})}function m(){if(!h)return;let w=h;h=null,clearTimeout(w.timer);let T=n.getZoom();n.zoomAround(w.pt,w.z0+ZV(T-w.z0)-T)}c.push(()=>{clearTimeout(h?.timer),h=null}),l(t,"wheel",w=>{if(w.preventDefault(),i())return;let T=qV(w);if(!T&&w.ctrlKey){p(u(w),-w.deltaY/(100*Math.LN2));return}if(r()===w.ctrlKey){let[R,F]=XV(w,t);n.panByPx(R,F,{animate:!1});return}if(!T){p(u(w),-w.deltaY/100);return}m(),n.zoomAround(u(w),w.deltaY<0?1:-1)},{passive:!1}),l(t,"keydown",w=>{if(w.altKey||w.ctrlKey||w.metaKey)return;let T=KV(w.key,s(),w.shiftKey);if(T){w.preventDefault(),n.panByPx(T[0],T[1]);return}if(i())return;let R={"+":1,"=":1,"-":-1,_:-1};w.key in R&&(w.preventDefault(),n.zoomAround(null,R[w.key]*(w.shiftKey?3:1)))});let g=null,v=null;l(t,"pointerdown",w=>{w.button!==0||!d(w)||(t.focus({preventScroll:!0}),g={x:w.clientX,y:w.clientY,moved:!1,box:w.shiftKey&&!i()},g.box&&w.stopPropagation())},{capture:!0}),l(window,"pointermove",w=>{if(!g)return;let T=w.clientX-g.x,R=w.clientY-g.y;(Math.abs(T)>3||Math.abs(R)>3)&&(g.moved=!0),g.box&&g.moved&&(v=K3(v,g,w))}),l(window,"pointerup",w=>{if(!g||w.button!==0)return;let T=g;if(g=null,v&&(v.remove(),v=null),T.box&&T.moved){E(T,w);return}!T.moved&&e.onClick&&x(w)&&e.onClick(f(w),w)}),l(t,"dblclick",w=>{i()||!d(w)||n.zoomAround(u(w),w.shiftKey?-1:1)});let y=null,b=null;l(t,"contextmenu",w=>w.preventDefault()),l(t,"pointerdown",w=>{w.button!==2||i()||!d(w)||(w.stopPropagation(),y={x:w.clientX,y:w.clientY})},{capture:!0}),l(window,"pointermove",w=>{if(!y)return;let T=w.clientX-y.x,R=w.clientY-y.y;(b||Math.abs(T)>=4&&Math.abs(R)>=4)&&(b=K3(b,y,w))}),l(window,"pointerup",w=>{if(!y||w.button!==2)return;let T=y;if(y=null,b){b.remove(),b=null,E(T,w);return}x(w)&&a()&&e.onContextClick&&e.onContextClick(f(w),w)}),l(t,"pointermove",w=>{e.onMove&&e.onMove(f(w),w)}),l(t,"pointerleave",w=>{e.onLeave&&e.onLeave(w)});function x(w){let T=t.getBoundingClientRect();return w.clientX>=T.left&&w.clientX<=T.right&&w.clientY>=T.top&&w.clientY<=T.bottom}function E(w,T){let R=t.getBoundingClientRect(),F=n.unproject([w.x-R.left,w.y-R.top]),O=n.unproject([T.clientX-R.left,T.clientY-R.top]);n.fitWorldRect([Math.min(F[0],O[0]),Math.min(F[1],O[1]),Math.max(F[0],O[0]),Math.max(F[1],O[1])])}return{dispose(){for(let w of c.splice(0))w()}}}function K3(n,e,t){return n||(n=document.createElement("div"),n.className="rubber-band",document.body.appendChild(n)),n.style.left=Math.min(e.x,t.clientX)+"px",n.style.top=Math.min(e.y,t.clientY)+"px",n.style.width=Math.abs(t.clientX-e.x)+"px",n.style.height=Math.abs(t.clientY-e.y)+"px",n}var Ps=class n{constructor(e,t,i){this._app=e,this._redrawAllLayers=t,this._refreshOverlay=i||t,this._currentTab="setup",this._setupPaths=[],this._holdPaths=[],this._selectedPathIndex=-1,this._detailTab="data",this._selectedDetailIndex=-1,this._sortCol="slack",this._sortAscending=!0,this._build()}_build(){let e=document.createElement("div");e.className="timing-widget";let t=document.createElement("div");t.className="timing-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",fe(this._app)&&(this._updateBtn.style.display="none"),this._pathCountLabel=document.createElement("span"),this._pathCountLabel.className="timing-path-count",t.appendChild(this._updateBtn),t.appendChild(this._pathCountLabel),e.appendChild(t),e.appendChild(this._buildConePanel());let i=document.createElement("div");i.className="timing-tab-bar",this._setupTab=this._makeTab("Setup",!0),this._holdTab=this._makeTab("Hold",!1),i.appendChild(this._setupTab),i.appendChild(this._holdTab),e.appendChild(i),this._pathTableContainer=document.createElement("div"),this._pathTableContainer.className="timing-path-table-container",this._pathTable=document.createElement("table"),this._pathTable.className="timing-table",this._pathTableContainer.appendChild(this._pathTable),e.appendChild(this._pathTableContainer);let r=document.createElement("div");r.className="timing-tab-bar",this._dataTab=this._makeTab("Data Path",!0),this._captureTab=this._makeTab("Capture Path",!1),r.appendChild(this._dataTab),r.appendChild(this._captureTab),e.appendChild(r),this._detailTableContainer=document.createElement("div"),this._detailTableContainer.className="timing-detail-table-container",this._detailTable=document.createElement("table"),this._detailTable.className="timing-table",this._detailTableContainer.appendChild(this._detailTable),e.appendChild(this._detailTableContainer),this._headerTooltip=document.createElement("div"),this._headerTooltip.className="or-tooltip or-tooltip-fixed",e.appendChild(this._headerTooltip),this.element=e,this._bindEvents(),fe(this._app)&&setTimeout(()=>this.update(),0)}_makeTab(e,t){let i=document.createElement("button");return i.className="timing-tab"+(t?" active":""),i.textContent=e,i}_bindEvents(){this._setupTab.addEventListener("click",()=>{this._currentTab="setup",this._setupTab.classList.add("active"),this._holdTab.classList.remove("active"),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}),this._holdTab.addEventListener("click",()=>{this._currentTab="hold",this._holdTab.classList.add("active"),this._setupTab.classList.remove("active"),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}),this._dataTab.addEventListener("click",()=>{this._detailTab="data",this._dataTab.classList.add("active"),this._captureTab.classList.remove("active"),this._renderDetailTable()}),this._captureTab.addEventListener("click",()=>{this._detailTab="capture",this._captureTab.classList.add("active"),this._dataTab.classList.remove("active"),this._renderDetailTable()}),this._updateBtn.addEventListener("click",()=>this.update()),this._pathTableContainer.setAttribute("tabindex","0"),this._pathTableContainer.style.outline="none",this._pathTableContainer.addEventListener("keydown",e=>{if(e.key==="ArrowDown"){e.preventDefault();let t=this._pathTable.querySelectorAll("tbody tr");this._selectedPathIndex0&&this._selectPathRow(this._selectedPathIndex-1))}),this._detailTableContainer.setAttribute("tabindex","0"),this._detailTableContainer.style.outline="none",this._detailTableContainer.addEventListener("keydown",e=>{if(e.key==="ArrowDown"){e.preventDefault();let t=this._detailTable.querySelectorAll("tbody tr");this._selectedDetailIndex0&&this._selectDetailRow(this._selectedDetailIndex-1))})}_buildConePanel(){let e=document.createElement("div");e.className="timing-cone-panel";let t=document.createElement("span");t.className="timing-cone-title",t.textContent="Timing cone:",e.appendChild(t);let i=(u,f,d=!1)=>{let h=document.createElement("input");h.type="checkbox",h.id=u,h.checked=d;let p=document.createElement("label");return p.htmlFor=u,p.textContent=f,{input:h,lbl:p}},r=i("cone-fanin","Fanin",!0),s=i("cone-fanout","Fanout",!0);this._coneFanin=r.input,this._coneFanout=s.input,e.append(r.input,r.lbl,s.input,s.lbl);let o=u=>{let f=document.createElement("label");f.className="timing-cone-depth-label",f.textContent=u;let d=document.createElement("input");return d.type="number",d.min="0",d.value="0",d.className="timing-cone-depth",d.title="0 = unlimited",f.appendChild(d),{lbl:f,input:d}},a=o("in\u2264"),c=o("out\u2264");this._coneFaninDepth=a.input,this._coneFanoutDepth=c.input,e.append(a.lbl,c.lbl),this._coneColorMode=document.createElement("select"),this._coneColorMode.className="timing-cone-colormode";for(let[u,f]of[["slack","by slack"],["depth","by depth"]]){let d=document.createElement("option");d.value=u,d.textContent=f,this._coneColorMode.appendChild(d)}e.appendChild(this._coneColorMode);let l=i("cone-sync-schematic","Sync schematic");return this._coneSyncSchematic=l.input,e.append(l.input,l.lbl),this._coneApplyBtn=document.createElement("button"),this._coneApplyBtn.className="or-btn",this._coneApplyBtn.textContent="Cone",this._coneApplyBtn.title="Show the timing cone for the selected instance",this._coneClearBtn=document.createElement("button"),this._coneClearBtn.className="or-btn",this._coneClearBtn.textContent="Clear",e.append(this._coneApplyBtn,this._coneClearBtn),this._coneStatus=document.createElement("span"),this._coneStatus.className="timing-cone-status",e.appendChild(this._coneStatus),this._coneApplyBtn.addEventListener("click",()=>this._applyCone()),this._coneClearBtn.addEventListener("click",()=>this._clearCone()),e}_coneTarget(){return this._app.selectedInstanceName||""}async _applyCone(){let e=this._coneFanin.checked,t=this._coneFanout.checked;if(!e&&!t){this._coneStatus.textContent="select fanin and/or fanout";return}let i=this._coneTarget();if(!i){this._coneStatus.textContent="select an instance first";return}let r={type:"timing_cone",fanin:e,fanout:t,fanin_depth:Math.max(0,parseInt(this._coneFaninDepth.value,10)||0),fanout_depth:Math.max(0,parseInt(this._coneFanoutDepth.value,10)||0),color_mode:this._coneColorMode.value,inst_name:i};this._coneApplyBtn.disabled=!0,this._coneStatus.textContent="computing\u2026";try{let s=await this._app.websocketManager.request(r);this._refreshOverlay(),this._renderConeStatus(s),this._coneSyncSchematic.checked&&i&&document.dispatchEvent(new CustomEvent("openroad-cone-sync",{detail:{inst_name:i,fanin:r.fanin,fanout:r.fanout,fanin_depth:r.fanin_depth,fanout_depth:r.fanout_depth}}))}catch(s){this._coneStatus.textContent="cone error: "+(s.message||s)}this._coneApplyBtn.disabled=!1}_renderConeStatus(e){if(!e){this._coneStatus.textContent="";return}let t=e.node_count||0;if(t===0){this._coneStatus.textContent="empty cone";return}let i=t+" pins";if(e.color_mode==="depth")i+=`, depth \xB1${e.max_depth}`;else if(e.constrained){let r=e.time_unit||"";i+=`, slack ${Ss(e.min_slack)}\u2026${Ss(e.max_slack)}${r}`}else i+=", unconstrained";this._coneStatus.textContent=i}_clearCone(){this._app.websocketManager.request({type:"timing_cone",clear:!0}).then(()=>this._refreshOverlay()),this._coneStatus.textContent=""}showPaths(e,t){this._currentTab=e,e==="setup"?(this._setupPaths=[...t],this._setupTab.classList.add("active"),this._holdTab.classList.remove("active")):(this._holdPaths=[...t],this._holdTab.classList.add("active"),this._setupTab.classList.remove("active")),this._applySort(),this._selectedPathIndex=-1,this._pathCountLabel.textContent=t.length+" paths",this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...";try{let[e,t]=await Promise.all([this._app.websocketManager.request({type:"timing_report",is_setup:!0,max_paths:100}),this._app.websocketManager.request({type:"timing_report",is_setup:!1,max_paths:100})]);this._setupPaths=[...e.paths||[]],this._holdPaths=[...t.paths||[]],this._applySort(),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}catch(e){console.error("Timing fetch failed:",e)}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}_applySort(){for(let e of[this._setupPaths,this._holdPaths]){e.forEach((r,s)=>{r._originalIndex===void 0&&(r._originalIndex=s)});let t=this._sortAscending?1:-1,i=this._sortCol;e.sort((r,s)=>{let o=r[i],a=s[i],c=typeof o=="number"&&typeof a=="number"?o-a:String(o).localeCompare(String(a));return t*c})}}_showHeaderTooltip(e,t){if(e.buttons!==0){this._hideHeaderTooltip();return}let i=this._headerTooltip;i.textContent=t,i.style.display="block";let r=Math.min(e.clientX+12,window.innerWidth-i.offsetWidth-8);i.style.left=Math.max(0,r)+"px",i.style.top=e.clientY+14+"px"}_hideHeaderTooltip(){this._headerTooltip.style.display="none"}_sortBy(e){this._sortCol===e?this._sortAscending=!this._sortAscending:(this._sortCol=e,this._sortAscending=!0),this._applySort(),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}_clearTimingHighlight(){this._app.websocketManager.request({type:"timing_highlight",path_index:-1}).then(()=>this._refreshOverlay())}_selectPathRow(e){let t=this._pathTable.querySelectorAll("tbody tr");if(e<0||e>=t.length)return;this._selectedPathIndex=e;for(let s of t)s.classList.remove("selected");t[e].classList.add("selected"),t[e].scrollIntoView({block:"nearest"}),this._pathTableContainer.focus(),this._renderDetailTable();let r=(this._currentTab==="setup"?this._setupPaths:this._holdPaths)[e]?._originalIndex??e;this._app.websocketManager.request({type:"timing_highlight",path_index:r,is_setup:this._currentTab==="setup"}).then(()=>this._refreshOverlay()).catch(s=>console.error("timing_highlight error:",s))}_renderPathTable(){this._hideHeaderTooltip();let e=this._currentTab==="setup"?this._setupPaths:this._holdPaths;this._pathCountLabel.textContent=e.length+" paths";let t=this._pathTable.querySelectorAll("thead th"),i=Array.from(t,c=>c.style.width);this._pathTable.innerHTML="";let r=document.createElement("thead"),s=document.createElement("tr");for(let c of n.PATH_COLS){let l=document.createElement("th");l.classList.add("sortable"),c.num&&l.classList.add("num"),l.textContent=c.label+(c.key===this._sortCol?this._sortAscending?" \u25B2":" \u25BC":""),c.tooltip&&(l.addEventListener("mousemove",u=>this._showHeaderTooltip(u,c.tooltip)),l.addEventListener("mouseleave",()=>this._hideHeaderTooltip())),l.addEventListener("click",()=>this._sortBy(c.key)),s.appendChild(l)}r.appendChild(s),this._pathTable.appendChild(r);let o=document.createElement("tbody"),a=e.reduce((c,l)=>Math.max(c,Math.abs(Number(l.slack)||0)),0);if(e.forEach((c,l)=>{let u=document.createElement("tr");l===this._selectedPathIndex&&u.classList.add("selected");for(let f of n.PATH_COLS){let d=document.createElement("td"),h=c[f.key];if(d.textContent=f.time?Ss(h):h,f.num&&d.classList.add("num"),f.key==="slack"){let p=Number(c.slack);p<0&&d.classList.add("slack-negative"),Number.isFinite(p)&&a>0&&(d.classList.add("slack-cell",p<0?"slack-under":"slack-over"),d.style.setProperty("--slack-frac",String(Math.abs(p)/a)))}u.appendChild(d)}u.style.cursor="pointer",u.addEventListener("click",()=>this._selectPathRow(l)),o.appendChild(u)}),e.length===0){let c=document.createElement("tr"),l=document.createElement("td");l.colSpan=n.PATH_COLS.length,l.style.textAlign="center",l.style.color="var(--fg-secondary)",l.textContent=fe(this._app)?"No timing data available":'Click "Update" to load timing paths',c.appendChild(l),o.appendChild(c)}this._pathTable.appendChild(o),ws(this._pathTable,i)}_selectDetailRow(e){let t=this._detailTable.querySelectorAll("tbody tr");if(e<0||e>=t.length)return;this._selectedDetailIndex=e;for(let a of t)a.classList.remove("timing-selected-row");t[e].classList.add("timing-selected-row"),t[e].scrollIntoView({block:"nearest"}),this._detailTableContainer.focus();let r=(this._currentTab==="setup"?this._setupPaths:this._holdPaths)[this._selectedPathIndex],s=this._detailTab==="data"?r.data_nodes:r.capture_nodes,o=r._originalIndex??this._selectedPathIndex;this._app.websocketManager.request({type:"timing_highlight",path_index:o,is_setup:this._currentTab==="setup",pin_name:s[e].pin}).then(()=>this._refreshOverlay())}_renderDetailTable(){let e=this._detailTable.querySelectorAll("thead th"),t=Array.from(e,l=>l.style.width);this._detailTable.innerHTML="",this._selectedDetailIndex=-1;let i=this._currentTab==="setup"?this._setupPaths:this._holdPaths;if(this._selectedPathIndex<0||this._selectedPathIndex>=i.length)return;let r=i[this._selectedPathIndex],s=this._detailTab==="data"?r.data_nodes:r.capture_nodes,o=document.createElement("thead"),a=document.createElement("tr");for(let l of n.DETAIL_COLS){let u=document.createElement("th");n.DETAIL_NUM_COLS.has(l)&&u.classList.add("num"),u.textContent=l,a.appendChild(u)}o.appendChild(a),this._detailTable.appendChild(o);let c=document.createElement("tbody");if(s.forEach((l,u)=>{let f=document.createElement("tr");l.clk&&f.classList.add("timing-clock-row"),[l.pin,l.fanout,l.rise?"\u2191":"\u2193",Ss(l.time),Ss(l.delay),Ss(l.slew),Ss(l.load)].forEach((h,p)=>{let m=document.createElement("td");n.DETAIL_NUM_COLS.has(n.DETAIL_COLS[p])&&m.classList.add("num"),m.textContent=h,f.appendChild(m)}),f.style.cursor="pointer",f.addEventListener("click",()=>this._selectDetailRow(u)),c.appendChild(f)}),this._detailTable.appendChild(c),ws(this._detailTable,t),!t[0]){let l=this._detailTable.querySelector("thead th");l&&(l.style.width="30ch")}}};function Ss(n){return n==null?"":typeof n=="number"?n.toFixed(4):String(n)}Ps.PATH_COLS=[{label:"Clock",key:"end_clk"},{label:"Required",key:"required",time:!0,num:!0},{label:"Arrival",key:"arrival",time:!0,num:!0},{label:"Slack",key:"slack",time:!0,num:!0},{label:"Skew",key:"skew",time:!0,num:!0,tooltip:`The difference in arrival times between source and destination clock pins of a macro/register, adjusted for CRPR and subtracting a clock period. -Setup and hold times account for internal clock delays.`},{label:"Logic Delay",key:"path_delay",time:!0,num:!0,tooltip:"Path delay from instances (excluding buffers and consecutive inverter pairs)"},{label:"Logic Depth",key:"logic_depth",num:!0,tooltip:"Path instances (excluding buffers and consecutive inverter pairs)"},{label:"Fanout",key:"fanout",num:!0},{label:"Start",key:"start_pin"},{label:"End",key:"end_pin"}];Ps.DETAIL_COLS=["Pin","Fanout","R/F","Time","Delay","Slew","Load"];Ps.DETAIL_NUM_COLS=new Set(["Fanout","Time","Delay","Slew","Load"]);function Be(n){let e=document.cookie.match("(?:^|; )"+n+"=([^;]*)");return e?e[1]:null}function Ue(n,e){document.cookie=n+"="+e+"; path=/; max-age=31536000; SameSite=Lax"}function Oh(n){document.cookie=n+"=; path=/; max-age=0; SameSite=Lax"}function Dh(n){Ue("or_theme",n);try{window.localStorage.setItem("or_theme",n)}catch{}}function K3(){Oh("or_theme");try{window.localStorage.removeItem("or_theme")}catch{}}function Jb(n){let e=document.getElementById("gl-theme-dark"),t=document.getElementById("gl-theme-light");!e||!t||(e.disabled=n!=="dark",t.disabled=n!=="light")}function Q3(n,e){Zo(n)&&(document.documentElement.style.setProperty("--bg-map",n),Ue("or_bg_color",n),eM(e),e.syncDisplayState())}function J3(n){document.documentElement.style.removeProperty("--bg-map"),Oh("or_bg_color"),eM(n),n.syncDisplayState()}function ev(){return U3(getComputedStyle(document.documentElement).getPropertyValue("--bg-map"))??"#000000"}function eM(n){n.threeDViewerWidget?.render?.()}if(typeof document<"u"){let n=Be("or_theme")||typeof localStorage<"u"&&localStorage.getItem("or_theme")||(matchMedia("(prefers-color-scheme: light)").matches?"light":"dark");document.documentElement.dataset.theme=n,Jb(n);let e=Be("or_bg_color");Zo(e)&&document.documentElement.style.setProperty("--bg-map",e)}function Cs(){let n=getComputedStyle(document.documentElement),e=t=>n.getPropertyValue(t).trim();return{canvasBg:e("--canvas-bg"),canvasText:e("--canvas-text"),canvasAxis:e("--canvas-axis"),canvasLabel:e("--canvas-label"),canvasGrid:e("--canvas-grid"),canvasTitle:e("--canvas-title"),fgPrimary:e("--fg-primary"),fgMuted:e("--fg-muted"),bgPanel:e("--bg-panel"),bgMap:e("--bg-map"),fontMono:e("--font-mono"),fontSans:e("--font-sans")}}function Ts(n,e){let t=document.createElement("a");t.href=n,t.download=e,document.body.appendChild(t),t.click(),t.remove()}function tM(n,e){let t=URL.createObjectURL(n);Ts(t,e),setTimeout(()=>URL.revokeObjectURL(t),1e3)}function tv(n){let e=n.cloneNode(!0);if(e.getAttribute("xmlns")||e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.getAttribute("xmlns:xlink")||e.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),!e.getAttribute("width")||!e.getAttribute("height")){let t=n.viewBox&&n.viewBox.baseVal;t&&t.width&&t.height&&(e.setAttribute("width",t.width),e.setAttribute("height",t.height))}return` -`+new XMLSerializer().serializeToString(e)}function qV(n){let e=n.viewBox&&n.viewBox.baseVal;if(e&&e.width&&e.height)return{width:e.width,height:e.height};let t=parseFloat(n.getAttribute("width")),i=parseFloat(n.getAttribute("height"));if(t&&i)return{width:t,height:i};let r=n.getBoundingClientRect();return{width:r.width||800,height:r.height||600}}function nv(n,e=2){let{width:t,height:i}=qV(n),r=tv(n),s=new Blob([r],{type:"image/svg+xml;charset=utf-8"}),o=URL.createObjectURL(s);return new Promise((a,c)=>{let l=new Image;l.onload=()=>{let u=document.createElement("canvas");u.width=Math.max(1,Math.round(t*e)),u.height=Math.max(1,Math.round(i*e));let f=u.getContext("2d");f.fillStyle="#ffffff",f.fillRect(0,0,u.width,u.height),f.drawImage(l,0,0,u.width,u.height),URL.revokeObjectURL(o),a(u.toDataURL("image/png"))},l.onerror=u=>{URL.revokeObjectURL(o),c(u)},l.src=o})}async function Nh(n){try{if(!navigator.clipboard||!window.ClipboardItem)return!1;let e=await(await fetch(n)).blob();return await navigator.clipboard.write([new ClipboardItem({"image/png":e})]),!0}catch{return!1}}function ZV(n){return(String(n||"").replace(/[^A-Za-z0-9._-]/g,"_").replace(/^_+|_+$/g,"")||"clock_tree")+".png"}var iv=24,rv=10,zh=40,XV=40,sv=70,KV=20,Fh={root:"#ff4444",buffer:"#4488ff",inverter:"#00b0b0",clock_gate:"#cc44cc",register:"#ff4444",macro:"#00b0b0",unknown:"#888888"};function QV(n){let e=parseInt(n.slice(1,3),16),t=parseInt(n.slice(3,5),16),i=parseInt(n.slice(5,7),16),r=o=>Math.round((o+255)/2),s=o=>o.toString(16).padStart(2,"0");return"#"+s(r(e))+s(r(t))+s(r(i))}function JV(n){let e=n.nodes;if(!e||e.length===0)return{layout:[],layoutWidth:0,layoutHeight:0,timeMin:0,timeMax:0,timeUnit:"",sceneHeight:0,layoutById:new Map};let t=new Map;for(let y of e)t.set(y.id,[]);for(let y of e)y.parent_id>=0&&t.has(y.parent_id)&&t.get(y.parent_id).push(y.id);let i=new Map;for(let y of e)i.set(y.id,y);let r=new Map,s=y=>{let b=t.get(y)||[];if(b.length===0)return r.set(y,1),1;let w=0;for(let E of b)w+=s(E);return r.set(y,w),w},o=e.filter(y=>y.parent_id===-1),a=0;for(let y of o)a+=s(y.id);let c=n.min_arrival,l=n.max_arrival,u=l-c||1,f=Math.max(200,a*iv*.6),d=[],h=(y,b)=>{let w=i.get(y),E=r.get(y),x=sv+(b+E/2)*iv,T=zh+(w.arrival-c)/u*f;d.push({id:w.id,x,y:T,type:w.type,name:w.name,pin_name:w.pin_name,arrival:w.arrival,delay:w.delay,fanout:w.fanout,level:w.level,parent_id:w.parent_id});let I=b,N=t.get(y)||[];for(let D of N)h(D,I),I+=r.get(D)},p=0;for(let y of o)h(y.id,p),p+=r.get(y.id);let m=sv+a*iv+KV,g=zh+f+XV,v=new Map;for(let y of d)v.set(y.id,y);return{layout:d,layoutWidth:m,layoutHeight:g,timeMin:c,timeMax:l,timeUnit:n.time_unit||"",sceneHeight:f,layoutById:v}}var Uh=class{constructor(e,t,i,r){this._app=t,this._redrawAllLayers=i,this._refreshOverlay=r||i,this._clockData=[],this._selectedClockIdx=0,this._selectedNodeId=-1,this._tx=0,this._ty=0,this._scale=1,this._layout=[],this._dragging=!1,this._dragStartX=0,this._dragStartY=0,this._dragStartTx=0,this._dragStartTy=0,this._build(e)}_build(e){let t=document.createElement("div");t.className="clock-tree-widget";let i=document.createElement("div");i.className="clock-tree-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",ue(this._app)&&(this._updateBtn.style.display="none"),this._fitBtn=document.createElement("button"),this._fitBtn.className="or-btn",this._fitBtn.textContent="Fit",this._pngBtn=document.createElement("button"),this._pngBtn.className="or-btn",this._pngBtn.textContent="PNG",this._pngBtn.title="Export the clock tree as a PNG image",this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",i.appendChild(this._updateBtn),i.appendChild(this._fitBtn),i.appendChild(this._pngBtn),i.appendChild(this._statusLabel),t.appendChild(i),this._tabBar=document.createElement("div"),this._tabBar.className="timing-tab-bar",t.appendChild(this._tabBar),this._canvas=document.createElement("canvas"),this._canvas.className="clock-tree-canvas",t.appendChild(this._canvas),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._tooltip.style.display="none",t.appendChild(this._tooltip),e.element.appendChild(t),this._el=t,this._ctx=this._canvas.getContext("2d"),this._bindEvents(),ue(this._app)&&setTimeout(()=>this.update(),0)}_fit(){this._sizeCanvas(),this._fitToView(),this._render()}_pngFileName(){let e=this._clockData[this._selectedClockIdx];return ZV(e&&e.name)}_exportPng(){try{Ts(this._canvas.toDataURL("image/png"),this._pngFileName())}catch(e){console.error("PNG export failed:",e)}}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update()),this._fitBtn.addEventListener("click",()=>this._fit()),this._pngBtn.addEventListener("click",()=>this._exportPng()),this._canvas.addEventListener("keydown",e=>{e.key==="f"&&this._fit()}),this._canvas.tabIndex=0,this._canvas.addEventListener("wheel",e=>{e.preventDefault();let t=this._canvas.getBoundingClientRect(),i=e.clientX-t.left,r=e.clientY-t.top,s=e.deltaY<0?1.15:1/1.15;this._tx=i-(i-this._tx)*s,this._ty=r-(r-this._ty)*s,this._scale*=s,this._render()}),this._canvas.addEventListener("mousedown",e=>{this._dragging=!0,this._dragStartX=e.clientX,this._dragStartY=e.clientY,this._dragStartTx=this._tx,this._dragStartTy=this._ty,this._canvas.style.cursor="grabbing"}),window.addEventListener("mousemove",e=>{this._dragging?(this._tx=this._dragStartTx+(e.clientX-this._dragStartX),this._ty=this._dragStartTy+(e.clientY-this._dragStartY),this._render()):this._handleHover(e)}),window.addEventListener("mouseup",()=>{this._dragging&&(this._dragging=!1,this._canvas.style.cursor="grab")}),this._canvas.addEventListener("click",e=>this._handleClick(e)),this._resizeObserver=new ResizeObserver(()=>{this._sizeCanvas(),this._render()}),this._resizeObserver.observe(this._canvas)}_sizeCanvas(){let e=this._canvas.getBoundingClientRect(),t=window.devicePixelRatio||1;this._canvas.width=e.width*t,this._canvas.height=e.height*t,this._ctx.setTransform(t,0,0,t,0,0)}async update(){this._statusLabel.textContent="Loading...";try{let e=await this._app.websocketManager.request({type:"clock_tree"});this._clockData=e.clocks||[],this._buildTabs(),this._selectClock(0),this._statusLabel.textContent=this._clockData.length+" clock"+(this._clockData.length!==1?"s":"")}catch(e){console.error("Clock tree error:",e),this._statusLabel.textContent="Error: "+e.message}}_buildTabs(){this._tabBar.innerHTML="",this._clockData.forEach((e,t)=>{let i=document.createElement("button");i.className="timing-tab"+(t===this._selectedClockIdx?" active":""),i.textContent=e.name,i.addEventListener("click",()=>this._selectClock(t)),this._tabBar.appendChild(i)})}_selectClock(e){if(e<0||e>=this._clockData.length)return;this._selectedClockIdx=e,this._selectedNodeId=-1,this._tabBar.querySelectorAll(".timing-tab").forEach((i,r)=>{i.classList.toggle("active",r===e)}),this._computeLayout(this._clockData[e]),requestAnimationFrame(()=>{this._sizeCanvas(),this._fitToView(),this._render()})}_computeLayout(e){let t=JV(e);this._layout=t.layout,this._layoutWidth=t.layoutWidth,this._layoutHeight=t.layoutHeight,this._timeMin=t.timeMin,this._timeMax=t.timeMax,this._timeUnit=t.timeUnit,this._sceneHeight=t.sceneHeight,this._layoutById=t.layoutById}_fitToView(){if(!this._layout.length)return;let e=this._canvas.getBoundingClientRect(),t=e.width,i=e.height,r=t/this._layoutWidth,s=i/this._layoutHeight;this._scale=Math.min(r,s)*.9,this._tx=(t-this._layoutWidth*this._scale)/2,this._ty=(i-this._layoutHeight*this._scale)/2}render(){this._render()}_render(){let e=this._ctx,t=this._canvas.getBoundingClientRect(),i=t.width,r=t.height,s=Cs();if(e.clearRect(0,0,i,r),e.fillStyle=s.canvasBg,e.fillRect(0,0,i,r),!this._layout.length){e.fillStyle=s.canvasText,e.font="14px "+s.fontSans,e.textAlign="center";let o=ue(this._app)?"No clock tree data available":'Click "Update" to load clock tree data';e.fillText(o,i/2,r/2);return}e.save(),e.translate(this._tx,this._ty),e.scale(this._scale,this._scale),this._drawConnections(e);for(let o of this._layout)this._drawNode(e,o,o.id===this._selectedNodeId);e.restore(),this._drawTimeScale(e,i,r,s)}_drawConnections(e){let t=1.5/this._scale,i=rv,r=this._timeMax-this._timeMin||1;for(let s of this._layout){if(s.parent_id<0)continue;let o=this._layoutById.get(s.parent_id);if(!o)continue;let a=o.x,c=s.x,l=(o.delay||0)/r*this._sceneHeight,u=o.y+l,f=s.y,d=o.type==="root"?o.y:o.y+i;if(u>d){let p=Fh[o.type]||Fh.unknown;e.strokeStyle=p,e.lineWidth=t,e.beginPath(),e.moveTo(a,d),e.lineTo(a,u);let m=i/20;e.moveTo(a-m,u),e.lineTo(a+m,u),e.stroke()}e.strokeStyle="#006400",e.lineWidth=t;let h=(u+f)/2;e.beginPath(),e.moveTo(a,u),e.bezierCurveTo(a,h,c,h,c,f),e.stroke()}}_drawNode(e,t,i){let r=t.x,s=t.y,o=rv,a=Fh[t.type]||Fh.unknown;switch(e.fillStyle=QV(a),e.strokeStyle=a,e.lineWidth=1/this._scale,t.type){case"root":{e.beginPath(),e.moveTo(r-o/2,s-o),e.lineTo(r+o/2,s-o),e.lineTo(r,s),e.closePath(),e.fill(),e.stroke();break}case"buffer":{e.beginPath(),e.moveTo(r-o/2,s),e.lineTo(r+o/2,s),e.lineTo(r,s+o),e.closePath(),e.fill(),e.stroke();break}case"inverter":{let c=o*.1,l=s+o-c;e.beginPath(),e.moveTo(r-o/2,s),e.lineTo(r+o/2,s),e.lineTo(r,l),e.closePath(),e.fill(),e.stroke(),e.beginPath(),e.arc(r,l+c/2,c/2,0,Math.PI*2),e.fill(),e.stroke();break}case"clock_gate":{e.beginPath(),e.arc(r,s+o/2,o/2,0,Math.PI*2),e.fill(),e.stroke();break}case"register":case"macro":{e.beginPath(),e.rect(r-o/2,s,o,o),e.fill(),e.stroke(),e.beginPath(),e.moveTo(r-o/8,s),e.lineTo(r+o/8,s),e.lineTo(r,s+o/4),e.closePath(),e.stroke();break}default:{e.beginPath(),e.arc(r,s+o/2,o/2,0,Math.PI*2),e.fill(),e.stroke();break}}if(i){e.strokeStyle="#ffff00",e.lineWidth=2/this._scale;let c=t.type==="root"?s-o/2:s+o/2;e.beginPath(),e.arc(r,c,o/2+3,0,Math.PI*2),e.stroke()}}_drawTimeScale(e,t,i,r){if(!this._sceneHeight)return;let s=m=>m*this._scale+this._ty,o=s(zh),a=s(zh+this._sceneHeight);if(a<0||o>i)return;e.save(),e.fillStyle=r.canvasLabel,e.strokeStyle=r.canvasAxis,e.font="11px "+r.fontMono,e.textAlign="right",e.textBaseline="middle";let c=this._timeMax-this._timeMin;if(c<=0){e.restore();return}let l=a-o,u=Math.max(2,Math.floor(l/40)),f=c/u,d=Math.pow(10,Math.floor(Math.log10(f))),h=d;f/d>5?h=10*d:f/d>2?h=5*d:f/d>1&&(h=2*d);let p=Math.ceil(this._timeMin/h)*h;e.beginPath();for(let m=p;m<=this._timeMax;m+=h){let g=(m-this._timeMin)/c,v=o+g*(a-o);e.moveTo(0,v),e.lineTo(t,v);let y=m.toFixed(h<.01?3:h<.1?2:1)+" "+this._timeUnit;e.fillText(y,sv-4,v)}e.stroke(),e.restore()}_screenToLayout(e,t){return{x:(e-this._tx)/this._scale,y:(t-this._ty)/this._scale}}_hitTest(e,t){let i=this._screenToLayout(e,t),r=rv;for(let s of this._layout){let o=s.type==="root"?s.y-r:s.y,a=s.type==="root"?s.y:s.y+r;if(i.x>=s.x-r/2&&i.x<=s.x+r/2&&i.y>=o&&i.y<=a)return s}return null}_handleClick(e){let t=this._canvas.getBoundingClientRect(),i=e.clientX-t.left,r=e.clientY-t.top,s=this._hitTest(i,r);s?(this._selectedNodeId=s.id,this._render(),this._app.websocketManager.request({type:"clock_tree_highlight",inst_name:s.name}).then(()=>this._refreshOverlay())):this._selectedNodeId>=0&&(this._selectedNodeId=-1,this._render(),this._app.websocketManager.request({type:"clock_tree_highlight",inst_name:""}).then(()=>this._refreshOverlay()))}_handleHover(e){let t=this._canvas.getBoundingClientRect(),i=e.clientX-t.left,r=e.clientY-t.top;if(i<0||r<0||i>t.width||r>t.height){this._tooltip.style.display="none";return}let s=this._hitTest(i,r);if(s){let o=[s.name,"Type: "+s.type,"Arrival: "+s.arrival.toFixed(3)+" "+(this._timeUnit||"")];s.delay&&o.push("Delay: "+s.delay.toFixed(3)+" "+(this._timeUnit||"")),s.fanout&&o.push("Fanout: "+s.fanout),this._tooltip.textContent=o.join(` -`),this._tooltip.style.display="block",this._tooltip.style.left=e.clientX+12+"px",this._tooltip.style.top=e.clientY+12+"px"}else this._tooltip.style.display="none"}};var iM=60,rM=20,sM=30,oM=50,nM=2,eW="#f08080",tW="#8b0000",nW="#90ee90",iW="#006400",lr=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7"],rW="rgba(240,128,128,0.12)",sW="rgba(144,238,144,0.12)",oW="#ff9999",aW="#b0ffb0",cW=[{value:"setup",label:"Setup Slack"},{value:"hold",label:"Hold Slack"},{value:"fanout",label:"Net Fanout"},{value:"netlength",label:"Net Length (HPWL)"}];function lW(n,e,t,i){if(!n||!e||ie.bottom)return null;for(let r of n)if(t>=r.x&&t<=r.x+r.width)return r;return null}function uW(n,e,t){return t?Math.log10(n+1)/Math.log10(e+1):n/e}function fW(n,e,t,i={}){let r=!!i.logY,s=n?.bins;if(!s||s.length===0)return{bars:[],yMax:0,yTicks:[],chartArea:null,logY:r};let o=iM,a=e-rM,c=sM,l=t-oM,u=a-o,f=l-c;if(u<=0||f<=0)return{bars:[],yMax:0,yTicks:[],chartArea:null,logY:r};let d={left:o,right:a,top:c,bottom:l},h=0;for(let y of s)y.count>h&&(h=y.count);h===0&&(h=1);let{yMax:p,yTicks:m}=r?hW(h):dW(h),g=(u-nM*(s.length-1))/s.length,v=[];for(let y=0;y[l.x,...l.ys||[]].join(","));return[a,...c].join(` +Setup and hold times account for internal clock delays.`},{label:"Logic Delay",key:"path_delay",time:!0,num:!0,tooltip:"Path delay from instances (excluding buffers and consecutive inverter pairs)"},{label:"Logic Depth",key:"logic_depth",num:!0,tooltip:"Path instances (excluding buffers and consecutive inverter pairs)"},{label:"Fanout",key:"fanout",num:!0},{label:"Start",key:"start_pin"},{label:"End",key:"end_pin"}];Ps.DETAIL_COLS=["Pin","Fanout","R/F","Time","Delay","Slew","Load"];Ps.DETAIL_NUM_COLS=new Set(["Fanout","Time","Delay","Slew","Load"]);function We(n){let e=document.cookie.match("(?:^|; )"+n+"=([^;]*)");return e?e[1]:null}function $e(n,e){document.cookie=n+"="+e+"; path=/; max-age=31536000; SameSite=Lax"}function Dh(n){document.cookie=n+"=; path=/; max-age=0; SameSite=Lax"}function Nh(n){$e("or_theme",n);try{window.localStorage.setItem("or_theme",n)}catch{}}function J3(){Dh("or_theme");try{window.localStorage.removeItem("or_theme")}catch{}}function ev(n){let e=document.getElementById("gl-theme-dark"),t=document.getElementById("gl-theme-light");!e||!t||(e.disabled=n!=="dark",t.disabled=n!=="light")}function eM(n,e){Zo(n)&&(document.documentElement.style.setProperty("--bg-map",n),$e("or_bg_color",n),nM(e),e.syncDisplayState())}function tM(n){document.documentElement.style.removeProperty("--bg-map"),Dh("or_bg_color"),nM(n),n.syncDisplayState()}function tv(){return G3(getComputedStyle(document.documentElement).getPropertyValue("--bg-map"))??"#000000"}function nM(n){n.threeDViewerWidget?.render?.()}if(typeof document<"u"){let n=We("or_theme")||typeof localStorage<"u"&&localStorage.getItem("or_theme")||(matchMedia("(prefers-color-scheme: light)").matches?"light":"dark");document.documentElement.dataset.theme=n,ev(n);let e=We("or_bg_color");Zo(e)&&document.documentElement.style.setProperty("--bg-map",e)}function Cs(){let n=getComputedStyle(document.documentElement),e=t=>n.getPropertyValue(t).trim();return{canvasBg:e("--canvas-bg"),canvasText:e("--canvas-text"),canvasAxis:e("--canvas-axis"),canvasLabel:e("--canvas-label"),canvasGrid:e("--canvas-grid"),canvasTitle:e("--canvas-title"),fgPrimary:e("--fg-primary"),fgMuted:e("--fg-muted"),bgPanel:e("--bg-panel"),bgMap:e("--bg-map"),fontMono:e("--font-mono"),fontSans:e("--font-sans")}}function Ts(n,e){let t=document.createElement("a");t.href=n,t.download=e,document.body.appendChild(t),t.click(),t.remove()}function iM(n,e){let t=URL.createObjectURL(n);Ts(t,e),setTimeout(()=>URL.revokeObjectURL(t),1e3)}function nv(n){let e=n.cloneNode(!0);if(e.getAttribute("xmlns")||e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.getAttribute("xmlns:xlink")||e.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),!e.getAttribute("width")||!e.getAttribute("height")){let t=n.viewBox&&n.viewBox.baseVal;t&&t.width&&t.height&&(e.setAttribute("width",t.width),e.setAttribute("height",t.height))}return` +`+new XMLSerializer().serializeToString(e)}function QV(n){let e=n.viewBox&&n.viewBox.baseVal;if(e&&e.width&&e.height)return{width:e.width,height:e.height};let t=parseFloat(n.getAttribute("width")),i=parseFloat(n.getAttribute("height"));if(t&&i)return{width:t,height:i};let r=n.getBoundingClientRect();return{width:r.width||800,height:r.height||600}}function iv(n,e=2){let{width:t,height:i}=QV(n),r=nv(n),s=new Blob([r],{type:"image/svg+xml;charset=utf-8"}),o=URL.createObjectURL(s);return new Promise((a,c)=>{let l=new Image;l.onload=()=>{let u=document.createElement("canvas");u.width=Math.max(1,Math.round(t*e)),u.height=Math.max(1,Math.round(i*e));let f=u.getContext("2d");f.fillStyle="#ffffff",f.fillRect(0,0,u.width,u.height),f.drawImage(l,0,0,u.width,u.height),URL.revokeObjectURL(o),a(u.toDataURL("image/png"))},l.onerror=u=>{URL.revokeObjectURL(o),c(u)},l.src=o})}async function Fh(n){try{if(!navigator.clipboard||!window.ClipboardItem)return!1;let e=await(await fetch(n)).blob();return await navigator.clipboard.write([new ClipboardItem({"image/png":e})]),!0}catch{return!1}}function JV(n){return(String(n||"").replace(/[^A-Za-z0-9._-]/g,"_").replace(/^_+|_+$/g,"")||"clock_tree")+".png"}var rv=24,sv=10,Uh=40,eW=40,ov=70,tW=20,zh={root:"#ff4444",buffer:"#4488ff",inverter:"#00b0b0",clock_gate:"#cc44cc",register:"#ff4444",macro:"#00b0b0",unknown:"#888888"};function nW(n){let e=parseInt(n.slice(1,3),16),t=parseInt(n.slice(3,5),16),i=parseInt(n.slice(5,7),16),r=o=>Math.round((o+255)/2),s=o=>o.toString(16).padStart(2,"0");return"#"+s(r(e))+s(r(t))+s(r(i))}function iW(n){let e=n.nodes;if(!e||e.length===0)return{layout:[],layoutWidth:0,layoutHeight:0,timeMin:0,timeMax:0,timeUnit:"",sceneHeight:0,layoutById:new Map};let t=new Map;for(let y of e)t.set(y.id,[]);for(let y of e)y.parent_id>=0&&t.has(y.parent_id)&&t.get(y.parent_id).push(y.id);let i=new Map;for(let y of e)i.set(y.id,y);let r=new Map,s=y=>{let b=t.get(y)||[];if(b.length===0)return r.set(y,1),1;let x=0;for(let E of b)x+=s(E);return r.set(y,x),x},o=e.filter(y=>y.parent_id===-1),a=0;for(let y of o)a+=s(y.id);let c=n.min_arrival,l=n.max_arrival,u=l-c||1,f=Math.max(200,a*rv*.6),d=[],h=(y,b)=>{let x=i.get(y),E=r.get(y),w=ov+(b+E/2)*rv,T=Uh+(x.arrival-c)/u*f;d.push({id:x.id,x:w,y:T,type:x.type,name:x.name,pin_name:x.pin_name,arrival:x.arrival,delay:x.delay,fanout:x.fanout,level:x.level,parent_id:x.parent_id});let R=b,F=t.get(y)||[];for(let O of F)h(O,R),R+=r.get(O)},p=0;for(let y of o)h(y.id,p),p+=r.get(y.id);let m=ov+a*rv+tW,g=Uh+f+eW,v=new Map;for(let y of d)v.set(y.id,y);return{layout:d,layoutWidth:m,layoutHeight:g,timeMin:c,timeMax:l,timeUnit:n.time_unit||"",sceneHeight:f,layoutById:v}}var $h=class{constructor(e,t,i,r){this._app=t,this._redrawAllLayers=i,this._refreshOverlay=r||i,this._clockData=[],this._selectedClockIdx=0,this._selectedNodeId=-1,this._tx=0,this._ty=0,this._scale=1,this._layout=[],this._dragging=!1,this._dragStartX=0,this._dragStartY=0,this._dragStartTx=0,this._dragStartTy=0,this._build(e)}_build(e){let t=document.createElement("div");t.className="clock-tree-widget";let i=document.createElement("div");i.className="clock-tree-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",fe(this._app)&&(this._updateBtn.style.display="none"),this._fitBtn=document.createElement("button"),this._fitBtn.className="or-btn",this._fitBtn.textContent="Fit",this._pngBtn=document.createElement("button"),this._pngBtn.className="or-btn",this._pngBtn.textContent="PNG",this._pngBtn.title="Export the clock tree as a PNG image",this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",i.appendChild(this._updateBtn),i.appendChild(this._fitBtn),i.appendChild(this._pngBtn),i.appendChild(this._statusLabel),t.appendChild(i),this._tabBar=document.createElement("div"),this._tabBar.className="timing-tab-bar",t.appendChild(this._tabBar),this._canvas=document.createElement("canvas"),this._canvas.className="clock-tree-canvas",t.appendChild(this._canvas),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._tooltip.style.display="none",t.appendChild(this._tooltip),e.element.appendChild(t),this._el=t,this._ctx=this._canvas.getContext("2d"),this._bindEvents(),fe(this._app)&&setTimeout(()=>this.update(),0)}_fit(){this._sizeCanvas(),this._fitToView(),this._render()}_pngFileName(){let e=this._clockData[this._selectedClockIdx];return JV(e&&e.name)}_exportPng(){try{Ts(this._canvas.toDataURL("image/png"),this._pngFileName())}catch(e){console.error("PNG export failed:",e)}}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update()),this._fitBtn.addEventListener("click",()=>this._fit()),this._pngBtn.addEventListener("click",()=>this._exportPng()),this._canvas.addEventListener("keydown",e=>{e.key==="f"&&this._fit()}),this._canvas.tabIndex=0,this._canvas.addEventListener("wheel",e=>{e.preventDefault();let t=this._canvas.getBoundingClientRect(),i=e.clientX-t.left,r=e.clientY-t.top,s=e.deltaY<0?1.15:1/1.15;this._tx=i-(i-this._tx)*s,this._ty=r-(r-this._ty)*s,this._scale*=s,this._render()}),this._canvas.addEventListener("mousedown",e=>{this._dragging=!0,this._dragStartX=e.clientX,this._dragStartY=e.clientY,this._dragStartTx=this._tx,this._dragStartTy=this._ty,this._canvas.style.cursor="grabbing"}),window.addEventListener("mousemove",e=>{this._dragging?(this._tx=this._dragStartTx+(e.clientX-this._dragStartX),this._ty=this._dragStartTy+(e.clientY-this._dragStartY),this._render()):this._handleHover(e)}),window.addEventListener("mouseup",()=>{this._dragging&&(this._dragging=!1,this._canvas.style.cursor="grab")}),this._canvas.addEventListener("click",e=>this._handleClick(e)),this._resizeObserver=new ResizeObserver(()=>{this._sizeCanvas(),this._render()}),this._resizeObserver.observe(this._canvas)}_sizeCanvas(){let e=this._canvas.getBoundingClientRect(),t=window.devicePixelRatio||1;this._canvas.width=e.width*t,this._canvas.height=e.height*t,this._ctx.setTransform(t,0,0,t,0,0)}async update(){this._statusLabel.textContent="Loading...";try{let e=await this._app.websocketManager.request({type:"clock_tree"});this._clockData=e.clocks||[],this._buildTabs(),this._selectClock(0),this._statusLabel.textContent=this._clockData.length+" clock"+(this._clockData.length!==1?"s":"")}catch(e){console.error("Clock tree error:",e),this._statusLabel.textContent="Error: "+e.message}}_buildTabs(){this._tabBar.innerHTML="",this._clockData.forEach((e,t)=>{let i=document.createElement("button");i.className="timing-tab"+(t===this._selectedClockIdx?" active":""),i.textContent=e.name,i.addEventListener("click",()=>this._selectClock(t)),this._tabBar.appendChild(i)})}_selectClock(e){if(e<0||e>=this._clockData.length)return;this._selectedClockIdx=e,this._selectedNodeId=-1,this._tabBar.querySelectorAll(".timing-tab").forEach((i,r)=>{i.classList.toggle("active",r===e)}),this._computeLayout(this._clockData[e]),requestAnimationFrame(()=>{this._sizeCanvas(),this._fitToView(),this._render()})}_computeLayout(e){let t=iW(e);this._layout=t.layout,this._layoutWidth=t.layoutWidth,this._layoutHeight=t.layoutHeight,this._timeMin=t.timeMin,this._timeMax=t.timeMax,this._timeUnit=t.timeUnit,this._sceneHeight=t.sceneHeight,this._layoutById=t.layoutById}_fitToView(){if(!this._layout.length)return;let e=this._canvas.getBoundingClientRect(),t=e.width,i=e.height,r=t/this._layoutWidth,s=i/this._layoutHeight;this._scale=Math.min(r,s)*.9,this._tx=(t-this._layoutWidth*this._scale)/2,this._ty=(i-this._layoutHeight*this._scale)/2}render(){this._render()}_render(){let e=this._ctx,t=this._canvas.getBoundingClientRect(),i=t.width,r=t.height,s=Cs();if(e.clearRect(0,0,i,r),e.fillStyle=s.canvasBg,e.fillRect(0,0,i,r),!this._layout.length){e.fillStyle=s.canvasText,e.font="14px "+s.fontSans,e.textAlign="center";let o=fe(this._app)?"No clock tree data available":'Click "Update" to load clock tree data';e.fillText(o,i/2,r/2);return}e.save(),e.translate(this._tx,this._ty),e.scale(this._scale,this._scale),this._drawConnections(e);for(let o of this._layout)this._drawNode(e,o,o.id===this._selectedNodeId);e.restore(),this._drawTimeScale(e,i,r,s)}_drawConnections(e){let t=1.5/this._scale,i=sv,r=this._timeMax-this._timeMin||1;for(let s of this._layout){if(s.parent_id<0)continue;let o=this._layoutById.get(s.parent_id);if(!o)continue;let a=o.x,c=s.x,l=(o.delay||0)/r*this._sceneHeight,u=o.y+l,f=s.y,d=o.type==="root"?o.y:o.y+i;if(u>d){let p=zh[o.type]||zh.unknown;e.strokeStyle=p,e.lineWidth=t,e.beginPath(),e.moveTo(a,d),e.lineTo(a,u);let m=i/20;e.moveTo(a-m,u),e.lineTo(a+m,u),e.stroke()}e.strokeStyle="#006400",e.lineWidth=t;let h=(u+f)/2;e.beginPath(),e.moveTo(a,u),e.bezierCurveTo(a,h,c,h,c,f),e.stroke()}}_drawNode(e,t,i){let r=t.x,s=t.y,o=sv,a=zh[t.type]||zh.unknown;switch(e.fillStyle=nW(a),e.strokeStyle=a,e.lineWidth=1/this._scale,t.type){case"root":{e.beginPath(),e.moveTo(r-o/2,s-o),e.lineTo(r+o/2,s-o),e.lineTo(r,s),e.closePath(),e.fill(),e.stroke();break}case"buffer":{e.beginPath(),e.moveTo(r-o/2,s),e.lineTo(r+o/2,s),e.lineTo(r,s+o),e.closePath(),e.fill(),e.stroke();break}case"inverter":{let c=o*.1,l=s+o-c;e.beginPath(),e.moveTo(r-o/2,s),e.lineTo(r+o/2,s),e.lineTo(r,l),e.closePath(),e.fill(),e.stroke(),e.beginPath(),e.arc(r,l+c/2,c/2,0,Math.PI*2),e.fill(),e.stroke();break}case"clock_gate":{e.beginPath(),e.arc(r,s+o/2,o/2,0,Math.PI*2),e.fill(),e.stroke();break}case"register":case"macro":{e.beginPath(),e.rect(r-o/2,s,o,o),e.fill(),e.stroke(),e.beginPath(),e.moveTo(r-o/8,s),e.lineTo(r+o/8,s),e.lineTo(r,s+o/4),e.closePath(),e.stroke();break}default:{e.beginPath(),e.arc(r,s+o/2,o/2,0,Math.PI*2),e.fill(),e.stroke();break}}if(i){e.strokeStyle="#ffff00",e.lineWidth=2/this._scale;let c=t.type==="root"?s-o/2:s+o/2;e.beginPath(),e.arc(r,c,o/2+3,0,Math.PI*2),e.stroke()}}_drawTimeScale(e,t,i,r){if(!this._sceneHeight)return;let s=m=>m*this._scale+this._ty,o=s(Uh),a=s(Uh+this._sceneHeight);if(a<0||o>i)return;e.save(),e.fillStyle=r.canvasLabel,e.strokeStyle=r.canvasAxis,e.font="11px "+r.fontMono,e.textAlign="right",e.textBaseline="middle";let c=this._timeMax-this._timeMin;if(c<=0){e.restore();return}let l=a-o,u=Math.max(2,Math.floor(l/40)),f=c/u,d=Math.pow(10,Math.floor(Math.log10(f))),h=d;f/d>5?h=10*d:f/d>2?h=5*d:f/d>1&&(h=2*d);let p=Math.ceil(this._timeMin/h)*h;e.beginPath();for(let m=p;m<=this._timeMax;m+=h){let g=(m-this._timeMin)/c,v=o+g*(a-o);e.moveTo(0,v),e.lineTo(t,v);let y=m.toFixed(h<.01?3:h<.1?2:1)+" "+this._timeUnit;e.fillText(y,ov-4,v)}e.stroke(),e.restore()}_screenToLayout(e,t){return{x:(e-this._tx)/this._scale,y:(t-this._ty)/this._scale}}_hitTest(e,t){let i=this._screenToLayout(e,t),r=sv;for(let s of this._layout){let o=s.type==="root"?s.y-r:s.y,a=s.type==="root"?s.y:s.y+r;if(i.x>=s.x-r/2&&i.x<=s.x+r/2&&i.y>=o&&i.y<=a)return s}return null}_handleClick(e){let t=this._canvas.getBoundingClientRect(),i=e.clientX-t.left,r=e.clientY-t.top,s=this._hitTest(i,r);s?(this._selectedNodeId=s.id,this._render(),this._app.websocketManager.request({type:"clock_tree_highlight",inst_name:s.name}).then(()=>this._refreshOverlay())):this._selectedNodeId>=0&&(this._selectedNodeId=-1,this._render(),this._app.websocketManager.request({type:"clock_tree_highlight",inst_name:""}).then(()=>this._refreshOverlay()))}_handleHover(e){let t=this._canvas.getBoundingClientRect(),i=e.clientX-t.left,r=e.clientY-t.top;if(i<0||r<0||i>t.width||r>t.height){this._tooltip.style.display="none";return}let s=this._hitTest(i,r);if(s){let o=[s.name,"Type: "+s.type,"Arrival: "+s.arrival.toFixed(3)+" "+(this._timeUnit||"")];s.delay&&o.push("Delay: "+s.delay.toFixed(3)+" "+(this._timeUnit||"")),s.fanout&&o.push("Fanout: "+s.fanout),this._tooltip.textContent=o.join(` +`),this._tooltip.style.display="block",this._tooltip.style.left=e.clientX+12+"px",this._tooltip.style.top=e.clientY+12+"px"}else this._tooltip.style.display="none"}};var sM=60,oM=20,aM=30,cM=50,rM=2,rW="#f08080",sW="#8b0000",oW="#90ee90",aW="#006400",fr=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7"],cW="rgba(240,128,128,0.12)",lW="rgba(144,238,144,0.12)",uW="#ff9999",fW="#b0ffb0",dW=[{value:"setup",label:"Setup Slack"},{value:"hold",label:"Hold Slack"},{value:"fanout",label:"Net Fanout"},{value:"netlength",label:"Net Length (HPWL)"}];function hW(n,e,t,i){if(!n||!e||ie.bottom)return null;for(let r of n)if(t>=r.x&&t<=r.x+r.width)return r;return null}function pW(n,e,t){return t?Math.log10(n+1)/Math.log10(e+1):n/e}function mW(n,e,t,i={}){let r=!!i.logY,s=n?.bins;if(!s||s.length===0)return{bars:[],yMax:0,yTicks:[],chartArea:null,logY:r};let o=sM,a=e-oM,c=aM,l=t-cM,u=a-o,f=l-c;if(u<=0||f<=0)return{bars:[],yMax:0,yTicks:[],chartArea:null,logY:r};let d={left:o,right:a,top:c,bottom:l},h=0;for(let y of s)y.count>h&&(h=y.count);h===0&&(h=1);let{yMax:p,yTicks:m}=r?_W(h):gW(h),g=(u-rM*(s.length-1))/s.length,v=[];for(let y=0;y[l.x,...l.ys||[]].join(","));return[a,...c].join(` `)}let t=e.bins||[],i=Array.isArray(e.series)?e.series:[],r=["lower","upper","count",...i.map(o=>o.name||"group")].join(","),s=t.map((o,a)=>{let c=[o.lower,o.upper,o.count];for(let l of i)c.push(l.counts&&l.counts[a]||0);return c.join(",")});return[r,...s].join(` -`)}var $h=class{constructor(e,t){this._app=e,this._redrawAllLayers=t,this._currentTab="setup",this._histogramData=null,this._bars=[],this._yMax=0,this._yTicks=[],this._chartArea=null,this._hoveredBar=null,this._debugCharts=[],this._activeDebugChart=-1,this._build()}_build(){let e=document.createElement("div");e.className="charts-widget";let t=document.createElement("div");t.className="charts-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",ue(this._app)&&(this._updateBtn.style.display="none"),this._chartSelect=document.createElement("select"),this._chartSelect.className="charts-select",this._csvBtn=document.createElement("button"),this._csvBtn.className="or-btn",this._csvBtn.textContent="CSV",this._csvBtn.title="Export the current chart data as CSV",this._pngBtn=document.createElement("button"),this._pngBtn.className="or-btn",this._pngBtn.textContent="PNG",this._pngBtn.title="Export the current chart as a PNG image",this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",t.appendChild(this._updateBtn),t.appendChild(this._chartSelect),t.appendChild(this._csvBtn),t.appendChild(this._pngBtn),t.appendChild(this._statusLabel),e.appendChild(t);let i=document.createElement("div");i.className="charts-toolbar";let r=document.createElement("span");r.textContent="Path Groups:",r.style.color="var(--fg-muted)",r.style.fontSize="var(--fs-12)",this._pathGroupSelect=document.createElement("select"),this._pathGroupSelect.className="charts-select",this._pathGroupSelect.multiple=!0,this._pathGroupSelect.size=1,this._pathGroupSelect.title="Select 0 = all, or \u22651 to stack by group";let s=document.createElement("span");s.textContent="Clock:",s.style.color="var(--fg-muted)",s.style.fontSize="var(--fs-12)",this._clockSelect=document.createElement("select"),this._clockSelect.className="charts-select",this._clockSelect.innerHTML='',i.appendChild(r),i.appendChild(this._pathGroupSelect),i.appendChild(s),i.appendChild(this._clockSelect),e.appendChild(i),this._canvas=document.createElement("canvas"),this._canvas.className="charts-canvas",e.appendChild(this._canvas),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._tooltip.style.display="none",e.appendChild(this._tooltip),this._filterRow=i,this.element=e,this._ctx=this._canvas.getContext("2d"),this._rebuildSelect(),this._bindEvents(),ue(this._app)&&setTimeout(()=>this.update(),0)}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update()),this._chartSelect.addEventListener("change",()=>this._onSelectChange()),this._csvBtn.addEventListener("click",()=>this._exportCsv()),this._pngBtn.addEventListener("click",()=>this._exportPng()),this._pathGroupSelect.addEventListener("change",()=>this._fetchHistogram()),this._clockSelect.addEventListener("change",()=>this._fetchHistogram()),this._canvas.addEventListener("mousemove",t=>this._handleHover(t)),this._canvas.addEventListener("mouseleave",()=>{this._hoveredBar=null,this._tooltip.style.display="none",this._syncView()}),this._canvas.addEventListener("click",t=>this._handleClick(t)),this._canvas.addEventListener("dblclick",t=>this._handleDblClick(t)),new ResizeObserver(()=>this._syncView()).observe(this._canvas)}_sizeCanvas(){let e=this._canvas.getBoundingClientRect(),t=window.devicePixelRatio||1;this._canvas.width=e.width*t,this._canvas.height=e.height*t,this._ctx.setTransform(t,0,0,t,0,0)}_rebuildSelect(){let e=this._chartSelect;e.innerHTML="";for(let t of cW){let i=document.createElement("option");i.value=t.value,i.textContent=t.label,e.appendChild(i)}this._debugCharts.forEach((t,i)=>{let r=document.createElement("option");r.value="gen:"+i,r.textContent=t.name||"Chart "+i,e.appendChild(r)}),e.value=this._activeDebugChart>=0?"gen:"+this._activeDebugChart:this._currentTab}_onSelectChange(){let e=this._chartSelect.value;e.startsWith("gen:")?(this._activeDebugChart=parseInt(e.slice(4),10)||0,this._hoveredBar=null,this._tooltip.style.display="none",this._syncView()):this._selectTab(e)}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...",this._statusLabel.textContent="";try{this._activeDebugChart<0?((this._currentTab==="setup"||this._currentTab==="hold")&&await this._fetchFilters(),await Promise.all([this._fetchHistogram(),this._fetchGenericCharts()])):await this._fetchGenericCharts()}catch(e){this._statusLabel.textContent="Error: "+e.message}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}async _fetchFilters(){let e=await this._app.websocketManager.request({type:"chart_filters"});this._populatePathGroups(e.path_groups||[]),this._populateClocks(e.clocks||[])}_populatePathGroups(e){let t=new Set(Array.from(this._pathGroupSelect.selectedOptions,i=>i.value));this._pathGroupSelect.innerHTML="";for(let i of e){let r=document.createElement("option");r.value=i,r.textContent=i,r.selected=t.has(i),this._pathGroupSelect.appendChild(r)}}_populateClocks(e){let t=this._clockSelect.value;this._clockSelect.innerHTML='';for(let i of e){let r=document.createElement("option");r.value=i,r.textContent=i,this._clockSelect.appendChild(r)}e.includes(t)&&(this._clockSelect.value=t)}async _fetchGenericCharts(){try{let e=await this._app.websocketManager.request({type:"debug_charts"});this.setDebugCharts(e.charts||[])}catch{}}async _fetchHistogram(){try{let e=this._currentTab,t;if(e==="fanout")t={type:"fanout_histogram"};else if(e==="netlength")t={type:"net_length_histogram",use_dbu:!!this._app.showDbu};else{t={type:"slack_histogram",is_setup:e==="setup"};let r=Array.from(this._pathGroupSelect.selectedOptions,s=>s.value).filter(Boolean);r.length>0&&(t.path_groups=r),this._clockSelect.value&&(t.clock_name=this._clockSelect.value)}let i=await this._app.websocketManager.request(t);if(this._currentTab!==e)return;if(this._histogramData=i,this._syncView(),e==="fanout"||e==="netlength"){let r=i.total_nets||0;this._statusLabel.textContent=`${r} nets`}else{let r=i.total_endpoints||0,s=i.unconstrained_count||0,o=r-s;this._statusLabel.textContent=`${o} endpoints`+(s>0?`, ${s} unconstrained`:"")}}catch(e){this._statusLabel.textContent="Error: "+e.message}}_selectTab(e){this._currentTab===e&&this._activeDebugChart<0||(this._currentTab=e,this._activeDebugChart=-1,this._chartSelect&&(this._chartSelect.value=e),this._filterRow.style.display=e==="setup"||e==="hold"?"":"none",this._hoveredBar=null,this._tooltip.style.display="none",this.update())}_computeLayout(){if(!this._histogramData)return;let e=this._canvas.getBoundingClientRect(),t=fW(this._histogramData,e.width,e.height,{logY:this._currentTab==="fanout"});this._bars=t.bars,this._yMax=t.yMax,this._yTicks=t.yTicks,this._chartArea=t.chartArea,this._logY=!!t.logY}render(){this._syncView()}_stackedSeries(){let e=this._histogramData?.series;return Array.isArray(e)&&e.length>1?e:null}_render(){let e=this._canvas.getBoundingClientRect(),t=e.width,i=e.height,r=this._ctx,s=Cs();if(r.clearRect(0,0,t,i),r.fillStyle=s.canvasBg,r.fillRect(0,0,t,i),!this._bars||this._bars.length===0){r.fillStyle=s.canvasText,r.font="14px "+s.fontSans,r.textAlign="center",r.textBaseline="middle";let o=ue(this._app)?"No histogram data available":'Click "Update" to load histogram';r.fillText(o,t/2,i/2);return}this._drawAxes(r,s),this._drawBars(r),this._drawTitle(r,t,s),this._stackedSeries()&&this._drawSeriesLegend(r,s)}_drawAxes(e,t){let i=this._chartArea;if(!i)return;e.strokeStyle=t.canvasAxis,e.lineWidth=1,e.beginPath(),e.moveTo(i.left,i.top),e.lineTo(i.left,i.bottom),e.stroke(),e.beginPath(),e.moveTo(i.left,i.bottom),e.lineTo(i.right,i.bottom),e.stroke(),e.fillStyle=t.canvasLabel,e.font="11px "+t.fontMono,e.textAlign="right",e.textBaseline="middle";let r=i.bottom-i.top;for(let d of this._yTicks){let h=this._logY?Math.log10(d+1)/Math.log10(this._yMax+1):d/this._yMax,p=i.bottom-h*r;e.fillText(this._formatCount(d),i.left-6,p),d>0&&(e.strokeStyle=t.canvasGrid,e.beginPath(),e.moveTo(i.left,p),e.lineTo(i.right,p),e.stroke(),e.strokeStyle=t.canvasAxis)}let s=this._currentTab,o=s==="fanout"||s==="netlength";e.save(),e.translate(14,(i.top+i.bottom)/2),e.rotate(-Math.PI/2),e.textAlign="center",e.textBaseline="middle",e.fillStyle=t.canvasTitle,e.font="11px "+t.fontMono,e.fillText(this._logY?"Nets (log)":o?"Nets":"Endpoints",0,0),e.restore(),e.textAlign="center",e.textBaseline="top",e.fillStyle=t.canvasLabel,e.font="10px "+t.fontMono;let a=this._histogramData.bins,c=this._histogramData.time_unit||this._histogramData.length_unit||"",l=a.length>0?a[0].upper-a[0].lower:1,u=s==="fanout"?0:Math.max(0,-Math.floor(Math.log10(l)));for(let d=0;d<=this._bars.length;d++){let h=d=0){this._hoveredBar=null,this._tooltip.style.display="none";return}let t=this._hitTestBar(e);if(t!==this._hoveredBar&&(this._hoveredBar=t,this._render()),t){let i=this._currentTab,r=t.upper-t.lower;if(i==="fanout"){let d=t.upper-1,h=t.lower===d?`${t.lower}`:`[${t.lower}, ${d}]`;this._tooltip.textContent=`Nets: ${t.count} +`)}var Gh=class{constructor(e,t){this._app=e,this._redrawAllLayers=t,this._currentTab="setup",this._histogramData=null,this._bars=[],this._yMax=0,this._yTicks=[],this._chartArea=null,this._hoveredBar=null,this._debugCharts=[],this._activeDebugChart=-1,this._build()}_build(){let e=document.createElement("div");e.className="charts-widget";let t=document.createElement("div");t.className="charts-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",fe(this._app)&&(this._updateBtn.style.display="none"),this._chartSelect=document.createElement("select"),this._chartSelect.className="charts-select",this._csvBtn=document.createElement("button"),this._csvBtn.className="or-btn",this._csvBtn.textContent="CSV",this._csvBtn.title="Export the current chart data as CSV",this._pngBtn=document.createElement("button"),this._pngBtn.className="or-btn",this._pngBtn.textContent="PNG",this._pngBtn.title="Export the current chart as a PNG image",this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",t.appendChild(this._updateBtn),t.appendChild(this._chartSelect),t.appendChild(this._csvBtn),t.appendChild(this._pngBtn),t.appendChild(this._statusLabel),e.appendChild(t);let i=document.createElement("div");i.className="charts-toolbar";let r=document.createElement("span");r.textContent="Path Groups:",r.style.color="var(--fg-muted)",r.style.fontSize="var(--fs-12)",this._pathGroupSelect=document.createElement("select"),this._pathGroupSelect.className="charts-select",this._pathGroupSelect.multiple=!0,this._pathGroupSelect.size=1,this._pathGroupSelect.title="Select 0 = all, or \u22651 to stack by group";let s=document.createElement("span");s.textContent="Clock:",s.style.color="var(--fg-muted)",s.style.fontSize="var(--fs-12)",this._clockSelect=document.createElement("select"),this._clockSelect.className="charts-select",this._clockSelect.innerHTML='',i.appendChild(r),i.appendChild(this._pathGroupSelect),i.appendChild(s),i.appendChild(this._clockSelect),e.appendChild(i),this._canvas=document.createElement("canvas"),this._canvas.className="charts-canvas",e.appendChild(this._canvas),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._tooltip.style.display="none",e.appendChild(this._tooltip),this._filterRow=i,this.element=e,this._ctx=this._canvas.getContext("2d"),this._rebuildSelect(),this._bindEvents(),fe(this._app)&&setTimeout(()=>this.update(),0)}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update()),this._chartSelect.addEventListener("change",()=>this._onSelectChange()),this._csvBtn.addEventListener("click",()=>this._exportCsv()),this._pngBtn.addEventListener("click",()=>this._exportPng()),this._pathGroupSelect.addEventListener("change",()=>this._fetchHistogram()),this._clockSelect.addEventListener("change",()=>this._fetchHistogram()),this._canvas.addEventListener("mousemove",t=>this._handleHover(t)),this._canvas.addEventListener("mouseleave",()=>{this._hoveredBar=null,this._tooltip.style.display="none",this._syncView()}),this._canvas.addEventListener("click",t=>this._handleClick(t)),this._canvas.addEventListener("dblclick",t=>this._handleDblClick(t)),new ResizeObserver(()=>this._syncView()).observe(this._canvas)}_sizeCanvas(){let e=this._canvas.getBoundingClientRect(),t=window.devicePixelRatio||1;this._canvas.width=e.width*t,this._canvas.height=e.height*t,this._ctx.setTransform(t,0,0,t,0,0)}_rebuildSelect(){let e=this._chartSelect;e.innerHTML="";for(let t of dW){let i=document.createElement("option");i.value=t.value,i.textContent=t.label,e.appendChild(i)}this._debugCharts.forEach((t,i)=>{let r=document.createElement("option");r.value="gen:"+i,r.textContent=t.name||"Chart "+i,e.appendChild(r)}),e.value=this._activeDebugChart>=0?"gen:"+this._activeDebugChart:this._currentTab}_onSelectChange(){let e=this._chartSelect.value;e.startsWith("gen:")?(this._activeDebugChart=parseInt(e.slice(4),10)||0,this._hoveredBar=null,this._tooltip.style.display="none",this._syncView()):this._selectTab(e)}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...",this._statusLabel.textContent="";try{this._activeDebugChart<0?((this._currentTab==="setup"||this._currentTab==="hold")&&await this._fetchFilters(),await Promise.all([this._fetchHistogram(),this._fetchGenericCharts()])):await this._fetchGenericCharts()}catch(e){this._statusLabel.textContent="Error: "+e.message}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}async _fetchFilters(){let e=await this._app.websocketManager.request({type:"chart_filters"});this._populatePathGroups(e.path_groups||[]),this._populateClocks(e.clocks||[])}_populatePathGroups(e){let t=new Set(Array.from(this._pathGroupSelect.selectedOptions,i=>i.value));this._pathGroupSelect.innerHTML="";for(let i of e){let r=document.createElement("option");r.value=i,r.textContent=i,r.selected=t.has(i),this._pathGroupSelect.appendChild(r)}}_populateClocks(e){let t=this._clockSelect.value;this._clockSelect.innerHTML='';for(let i of e){let r=document.createElement("option");r.value=i,r.textContent=i,this._clockSelect.appendChild(r)}e.includes(t)&&(this._clockSelect.value=t)}async _fetchGenericCharts(){try{let e=await this._app.websocketManager.request({type:"debug_charts"});this.setDebugCharts(e.charts||[])}catch{}}async _fetchHistogram(){try{let e=this._currentTab,t;if(e==="fanout")t={type:"fanout_histogram"};else if(e==="netlength")t={type:"net_length_histogram",use_dbu:!!this._app.showDbu};else{t={type:"slack_histogram",is_setup:e==="setup"};let r=Array.from(this._pathGroupSelect.selectedOptions,s=>s.value).filter(Boolean);r.length>0&&(t.path_groups=r),this._clockSelect.value&&(t.clock_name=this._clockSelect.value)}let i=await this._app.websocketManager.request(t);if(this._currentTab!==e)return;if(this._histogramData=i,this._syncView(),e==="fanout"||e==="netlength"){let r=i.total_nets||0;this._statusLabel.textContent=`${r} nets`}else{let r=i.total_endpoints||0,s=i.unconstrained_count||0,o=r-s;this._statusLabel.textContent=`${o} endpoints`+(s>0?`, ${s} unconstrained`:"")}}catch(e){this._statusLabel.textContent="Error: "+e.message}}_selectTab(e){this._currentTab===e&&this._activeDebugChart<0||(this._currentTab=e,this._activeDebugChart=-1,this._chartSelect&&(this._chartSelect.value=e),this._filterRow.style.display=e==="setup"||e==="hold"?"":"none",this._hoveredBar=null,this._tooltip.style.display="none",this.update())}_computeLayout(){if(!this._histogramData)return;let e=this._canvas.getBoundingClientRect(),t=mW(this._histogramData,e.width,e.height,{logY:this._currentTab==="fanout"});this._bars=t.bars,this._yMax=t.yMax,this._yTicks=t.yTicks,this._chartArea=t.chartArea,this._logY=!!t.logY}render(){this._syncView()}_stackedSeries(){let e=this._histogramData?.series;return Array.isArray(e)&&e.length>1?e:null}_render(){let e=this._canvas.getBoundingClientRect(),t=e.width,i=e.height,r=this._ctx,s=Cs();if(r.clearRect(0,0,t,i),r.fillStyle=s.canvasBg,r.fillRect(0,0,t,i),!this._bars||this._bars.length===0){r.fillStyle=s.canvasText,r.font="14px "+s.fontSans,r.textAlign="center",r.textBaseline="middle";let o=fe(this._app)?"No histogram data available":'Click "Update" to load histogram';r.fillText(o,t/2,i/2);return}this._drawAxes(r,s),this._drawBars(r),this._drawTitle(r,t,s),this._stackedSeries()&&this._drawSeriesLegend(r,s)}_drawAxes(e,t){let i=this._chartArea;if(!i)return;e.strokeStyle=t.canvasAxis,e.lineWidth=1,e.beginPath(),e.moveTo(i.left,i.top),e.lineTo(i.left,i.bottom),e.stroke(),e.beginPath(),e.moveTo(i.left,i.bottom),e.lineTo(i.right,i.bottom),e.stroke(),e.fillStyle=t.canvasLabel,e.font="11px "+t.fontMono,e.textAlign="right",e.textBaseline="middle";let r=i.bottom-i.top;for(let d of this._yTicks){let h=this._logY?Math.log10(d+1)/Math.log10(this._yMax+1):d/this._yMax,p=i.bottom-h*r;e.fillText(this._formatCount(d),i.left-6,p),d>0&&(e.strokeStyle=t.canvasGrid,e.beginPath(),e.moveTo(i.left,p),e.lineTo(i.right,p),e.stroke(),e.strokeStyle=t.canvasAxis)}let s=this._currentTab,o=s==="fanout"||s==="netlength";e.save(),e.translate(14,(i.top+i.bottom)/2),e.rotate(-Math.PI/2),e.textAlign="center",e.textBaseline="middle",e.fillStyle=t.canvasTitle,e.font="11px "+t.fontMono,e.fillText(this._logY?"Nets (log)":o?"Nets":"Endpoints",0,0),e.restore(),e.textAlign="center",e.textBaseline="top",e.fillStyle=t.canvasLabel,e.font="10px "+t.fontMono;let a=this._histogramData.bins,c=this._histogramData.time_unit||this._histogramData.length_unit||"",l=a.length>0?a[0].upper-a[0].lower:1,u=s==="fanout"?0:Math.max(0,-Math.floor(Math.log10(l)));for(let d=0;d<=this._bars.length;d++){let h=d=0){this._hoveredBar=null,this._tooltip.style.display="none";return}let t=this._hitTestBar(e);if(t!==this._hoveredBar&&(this._hoveredBar=t,this._render()),t){let i=this._currentTab,r=t.upper-t.lower;if(i==="fanout"){let d=t.upper-1,h=t.lower===d?`${t.lower}`:`[${t.lower}, ${d}]`;this._tooltip.textContent=`Nets: ${t.count} Fanout: ${h}`}else if(i==="netlength"){let d=this._histogramData?.length_unit||"",h=Math.max(0,-Math.floor(Math.log10(r)));this._tooltip.textContent=`Nets: ${t.count} Length: [${t.lower.toFixed(h)}, ${t.upper.toFixed(h)}) ${d}`}else{let d=this._histogramData?.time_unit||"",h=Math.max(0,-Math.floor(Math.log10(r)));this._tooltip.textContent=`Endpoints: ${t.count} -Slack: [${t.lower.toFixed(h)}, ${t.upper.toFixed(h)}) ${d}`}this._tooltip.style.display="block";let s=this.element.getBoundingClientRect(),o=this._tooltip.getBoundingClientRect(),a=4,c=e.clientX-s.left,l=e.clientY-s.top,u=c+12;u+o.width>s.width-a&&(u=c-12-o.width),u=Math.max(a,u);let f=l-10;f=Math.min(s.height-o.height-a,Math.max(a,f)),this._tooltip.style.left=u+"px",this._tooltip.style.top=f+"px"}else this._tooltip.style.display="none"}async _handleClick(e){if(this._activeDebugChart>=0||this._currentTab==="fanout"||this._currentTab==="netlength")return;let t=this._hitTestBar(e);if(!(!t||t.count===0))try{let i=await this._app.websocketManager.request({type:"timing_report",is_setup:this._currentTab==="setup",max_paths:50,slack_min:t.lower,slack_max:t.upper});this._app.timingWidget&&(this._app.timingWidget.showPaths(this._currentTab,i.paths||[]),this._app.focusComponent&&this._app.focusComponent("TimingWidget"))}catch(i){console.error("Charts bar click error:",i)}}async _handleDblClick(e){if(this._activeDebugChart>=0)return;let t;if(this._currentTab==="fanout")t="select_fanout_bin";else if(this._currentTab==="netlength")t="select_net_length_bin";else return;let i=this._hitTestBar(e);if(!i||i.count===0)return;let r=St(this._app);try{let s=await this._app.websocketManager.request({type:t,lower:i.lower,upper:i.upper,use_dbu:this._app.showDbu});if(!Dt(this._app,r))return;s&&s.truncated&&console.warn(`Bin has ${s.count} nets; selection capped at ${s.selection_limit} for performance.`),this._app.updateInspector&&this._app.updateInspector(s),this._app.focusComponent&&this._app.focusComponent("Inspector"),this._redrawAllLayers&&this._redrawAllLayers()}catch(s){console.error("Net bin select failed:",s)}}_activeChartData(){return this._activeDebugChart>=0?{kind:"generic",data:this._debugCharts[this._activeDebugChart]}:{kind:"histogram",data:this._histogramData}}_chartBaseName(){return this._activeDebugChart>=0?this._debugCharts[this._activeDebugChart].name||"chart":this._currentTab}_triggerDownload(e,t,{revoke:i=!1}={}){let r=document.createElement("a");r.href=t,r.download=e,document.body.appendChild(r),r.click(),r.remove(),i&&URL.revokeObjectURL(t)}_download(e,t,i){try{let r=URL.createObjectURL(new Blob([i],{type:t}));this._triggerDownload(e,r,{revoke:!0})}catch(r){console.error("Download failed:",r)}}_exportCsv(){let{kind:e,data:t}=this._activeChartData();if(!t)return;let i=pW(e,t);this._download(this._chartBaseName()+".csv","text/csv",i)}_exportPng(){try{let e=this._canvas.toDataURL("image/png");this._triggerDownload(this._chartBaseName()+".png",e)}catch(e){console.error("PNG export failed:",e)}}setDebugCharts(e){this._debugCharts=e,e.length===0?this._activeDebugChart=-1:this._activeDebugChart>=e.length&&(this._activeDebugChart=0),this._rebuildSelect(),this._syncView()}_syncView(){let e=this._activeDebugChart>=0;e&&(this._hoveredBar=null,this._tooltip.style.display="none");let t=!e&&(this._currentTab==="setup"||this._currentTab==="hold");this._filterRow&&(this._filterRow.style.display=t?"":"none"),this._sizeCanvas(),e?this._renderLineChart(this._debugCharts[this._activeDebugChart]):(this._computeLayout(),this._render())}_renderLineChart(e){let t=this._canvas.getBoundingClientRect(),i=t.width,r=t.height,s=this._ctx,o=Cs();s.clearRect(0,0,i,r),s.fillStyle=o.canvasBg,s.fillRect(0,0,i,r);let a=e.points;if(!a||a.length===0){s.fillStyle=o.canvasText,s.font="14px "+o.fontSans,s.textAlign="center",s.textBaseline="middle",s.fillText("No data points yet",i/2,r/2);return}let c=e.y_labels?e.y_labels.length:1,l=iM,u=i-rM,f=sM,d=r-oM,h=u-l,p=d-f;if(h<=0||p<=0)return;let m=a[0].x,g=a[0].x,v=1/0,y=-1/0;for(let T of a){T.xg&&(g=T.x);for(let I of T.ys)Iy&&(y=I)}m===g&&(g=m+1),(!isFinite(v)||!isFinite(y))&&(v=0,y=1);let b=(y-v)*.05||1;v-=b,y+=b;let w=T=>l+(T-m)/(g-m)*h,E=T=>d-(T-v)/(y-v)*p;s.strokeStyle=o.canvasAxis,s.lineWidth=1,s.beginPath(),s.moveTo(l,f),s.lineTo(l,d),s.lineTo(u,d),s.stroke(),s.fillStyle=o.canvasLabel,s.font="10px "+o.fontMono,s.textAlign="right",s.textBaseline="middle";let x=5;for(let T=0;T<=x;T++){let I=v+(y-v)*T/x,N=E(I);s.fillText(this._formatNum(I),l-4,N),T>0&&T1&&e.y_labels){s.font="10px "+o.fontMono,s.textAlign="left",s.textBaseline="top";let T=l+8,I=f+4;for(let N=0;N=1e6?(e/1e6).toFixed(1)+"M":t>=1e3?(e/1e3).toFixed(1)+"k":t>=1?e.toFixed(1):e.toPrecision(3)}_formatCount(e){return e===0?"0":e>=1e6?e/1e6+"M":e>=1e3?e/1e3+"k":String(e)}};var En=class{constructor(e){this.onChange=e,this.roots=[],this._nodeMap=new Map}addFromSpec(e,t=null){let i=this._makeNode(e.id,t,e);if(i.checked=e.checked!==!1,e.children){for(let r of e.children)i.children.push(this.addFromSpec(r,i));i.hasCheckbox&&this._computeParent(i)}return t||this.roots.push(i),i}buildFromNodes(e){this._nodeMap.clear(),this.roots=[];for(let t of e)this._makeNode(t.id,null,t);for(let t of e){let i=this._nodeMap.get(t.id);if(t.parentId!=null&&this._nodeMap.has(t.parentId)){let r=this._nodeMap.get(t.parentId);i.parent=r,r.children.push(i)}else this.roots.push(i)}for(let t=e.length-1;t>=0;t--){let i=this._nodeMap.get(e[t].id);i.hasCheckbox&&i.children.length>0&&this._computeParent(i)}return this.roots}get(e){return this._nodeMap.get(e)}isVisible(e){let t=this.get(e);return t?t.checked:!1}check(e,t){let i=this._nodeMap.get(e);if(i){i.checked=t,i.indeterminate=!1;for(let r of i.children)this._setSubtree(r,t);for(let r=i.parent;r;r=r.parent)r.hasCheckbox&&this._computeParent(r);this.onChange()}}cascadeQuiet(e,t){let i=this._nodeMap.get(e);if(i){i.checked=t,i.indeterminate=!1;for(let r of i.children)this._setSubtree(r,t);for(let r=i.parent;r;r=r.parent)r.hasCheckbox&&this._computeParent(r)}}checkSet(e){for(let[t,i]of Object.entries(e)){let r=this._nodeMap.get(t);r&&(r.checked=i,r.indeterminate=!1)}this._recomputeAllParents(),this.onChange()}mirrorStates(e){this._applyMirror(e),this.onChange()}mirrorStatesQuiet(e){this._applyMirror(e)}_applyMirror(e){for(let[t,i]of Object.entries(e)){let r=this._nodeMap.get(t);r&&(r.checked=!!i.checked,r.indeterminate=!!i.indeterminate)}}forEach(e){let t=i=>{e(i);for(let r of i.children)t(r)};for(let i of this.roots)t(i)}_makeNode(e,t,i){let r={id:e,parent:t,children:[],hasCheckbox:i.hasCheckbox!==!1,checked:i.checked!==!1,indeterminate:!1,data:i.data!=null?i.data:i};return this._nodeMap.set(e,r),r}_checkboxDescendants(e){let t=[];for(let i of e.children)i.hasCheckbox?t.push(i):t.push(...this._checkboxDescendants(i));return t}_computeParent(e){let t=this._checkboxDescendants(e);if(t.length===0)return;let i=t.every(s=>s.checked&&!s.indeterminate),r=t.every(s=>!s.checked&&!s.indeterminate);e.checked=i,e.indeterminate=!i&&!r}_setSubtree(e,t){e.hasCheckbox&&(e.checked=t,e.indeterminate=!1);for(let i of e.children)this._setSubtree(i,t)}_recomputeAllParents(){let e=t=>{for(let i of t.children)e(i);t.hasCheckbox&&t.children.length>0&&this._computeParent(t)};for(let t of this.roots)e(t)}};var aM=["Instance","Module","Instances","Macros","Modules","Area","Local Inst","Local Macros","Local Modules"],ur={MODULE:0,LEAF_GROUP:1,TYPE_GROUP:2,INSTANCE:3,NAME_GROUP:4};function Ls(n){return n===ur.MODULE||n===ur.NAME_GROUP}var Gh=class{constructor(e,t,i){this._app=t,this._redrawAllLayers=i,this._nodes=[],this._nameGrouped=!1,this._nameGroupsCapped=!1,this._rows=[],this._childrenMap=new Map,this._collapsed=new Set,this._moduleState=new Map,this._checkModel=null,this._build(e),t.hierarchyBrowser=this,ue(t)&&this.update()}_build(e){let t=document.createElement("div");t.className="hierarchy-widget";let i=document.createElement("div");i.className="timing-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",ue(this._app)&&(this._updateBtn.style.display="none"),this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",i.appendChild(this._updateBtn),i.appendChild(this._statusLabel),t.appendChild(i),this._tableContainer=document.createElement("div"),this._tableContainer.className="hierarchy-table-container",this._table=document.createElement("table"),this._table.className="timing-table",this._tableContainer.appendChild(this._table),t.appendChild(this._tableContainer),e.element.appendChild(t),this._bindEvents()}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update())}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...",this._statusLabel.textContent="";try{let e=await this._app.websocketManager.request({type:"module_hierarchy"});this._nodes=e.nodes||[],this._nameGrouped=!!e.name_grouped,this._nameGroupsCapped=!!e.name_groups_capped,this._buildTree(),this._readServerColors(),this._computeEffectiveColors(),this._render(),this._statusLabel.textContent=this._statusText(),await this._sendModuleColors()}catch(e){this._statusLabel.textContent="Error: "+e.message}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}_statusText(){let e=this._nodes.filter(r=>Ls(r.node_kind||0)).length;if(!this._nameGrouped)return e+" modules";let i=Math.max(0,e-1)+" groups from instance names \u2014 this design has no module hierarchy";return this._nameGroupsCapped&&(i+=" (truncated: too many groups)"),i}_buildTree(){this._childrenMap.clear(),this._collapsed.clear();for(let t of this._nodes)this._childrenMap.set(t.id,[]);for(let t of this._nodes)t.parent_id>=0&&this._childrenMap.has(t.parent_id)&&this._childrenMap.get(t.parent_id).push(t.id);this._nodeMap=new Map;for(let t of this._nodes)this._nodeMap.set(t.id,t);for(let t of this._nodes){let i=this._childrenMap.get(t.id);if(!i||i.length===0)continue;let r=t.node_kind||0;r===ur.LEAF_GROUP||r===ur.TYPE_GROUP?this._collapsed.add(t.id):Ls(r)&&t.parent_id>=0&&this._collapsed.add(t.id)}this._rows=[];let e=this._nodes.filter(t=>t.parent_id<0);for(let t of e)this._dfs(t.id,0);this._checkModel=new En(()=>{this._checkModel.forEach(t=>{if(!t.hasCheckbox)return;let i=this._moduleState.get(t.data.odb_id);i&&(i.visible=t.checked)}),this._sendModuleColors()}),this._checkModel.buildFromNodes(this._nodes.map(t=>({id:t.id,parentId:t.parent_id,hasCheckbox:Ls(t.node_kind||0)&&t.odb_id!=null,checked:!0,data:t})))}_readServerColors(){this._moduleState.clear();for(let e of this._rows){let t=this._nodeMap.get(e.id);if(!t||!Ls(t.node_kind||0)||t.odb_id==null)continue;let i=t.color||[128,128,128];this._moduleState.set(t.odb_id,{color:i,effectiveColor:i,visible:!0,nodeId:t.id})}}_computeEffectiveColors(){for(let e of this._rows){let t=this._nodeMap.get(e.id);if(!t||!Ls(t.node_kind||0))continue;let i=this._moduleState.get(t.odb_id);if(!i)continue;let r=t.parent_id,s=null;for(;r>=0;){let o=this._nodeMap.get(r);if(!o)break;if(Ls(o.node_kind||0)){let a=this._moduleState.get(o.odb_id);a&&this._collapsed.has(o.id)&&(s=a.effectiveColor)}r=o.parent_id}i.effectiveColor=s||i.color}}async _sendModuleColors(){let e=[];for(let[i,r]of this._moduleState){if(!r.visible)continue;let[s,o,a]=r.effectiveColor;e.push(`${i}:${s},${o},${a},100`)}let t=e.join(";");try{let i=await this._app.websocketManager.request({type:"set_module_colors",colors:t});console.log("set_module_colors:",i.count,"modules,",e.length,"sent")}catch(i){console.error("set_module_colors failed:",i)}this._redrawAllLayers()}_dfs(e,t){this._rows.push({id:e,depth:t});let i=this._childrenMap.get(e)||[];for(let r of i)this._dfs(r,t+1)}_render(){this._table.innerHTML="";let e=document.createElement("thead"),t=document.createElement("tr");for(let r of aM){let s=document.createElement("th");s.textContent=r,t.appendChild(s)}e.appendChild(t),this._table.appendChild(e);let i=document.createElement("tbody");for(let r of this._rows){let s=this._nodeMap.get(r.id);if(!s||this._isHidden(s))continue;let o=document.createElement("tr"),a=s.node_kind||0,l=(this._childrenMap.get(r.id)||[]).length>0,u=this._collapsed.has(r.id);a===ur.LEAF_GROUP||a===ur.TYPE_GROUP?(o.style.fontStyle="italic",o.style.color="var(--fg-disabled)"):a===ur.INSTANCE?o.style.color="var(--fg-secondary)":a===ur.NAME_GROUP&&(o.classList.add("hierarchy-name-group"),o.title="Recovered from instance names \u2014 this design has no module hierarchy");let f=document.createElement("td");if(f.style.paddingLeft=8+r.depth*16+"px",f.style.whiteSpace="nowrap",Ls(a)&&s.odb_id!=null){let p=this._moduleState.get(s.odb_id),m=this._checkModel?this._checkModel.get(s.id):null;if(p&&m){let g=document.createElement("input");g.type="checkbox",g.checked=m.checked,g.indeterminate=m.indeterminate,g.className="hierarchy-module-cb",m.cb=g,g.addEventListener("change",E=>{E.stopPropagation(),this._checkModel.check(s.id,g.checked),this._render()}),f.appendChild(g);let v=document.createElement("span");v.className="hierarchy-color-swatch";let[y,b,w]=p.effectiveColor;v.style.backgroundColor=`rgb(${y},${b},${w})`,f.appendChild(v)}}if(l){let p=document.createElement("span");p.className="hierarchy-arrow",p.textContent=u?"\u25B6":"\u25BC",p.addEventListener("click",m=>{m.stopPropagation(),this._toggleNode(r.id)}),f.appendChild(p)}else{let p=document.createElement("span");p.className="hierarchy-arrow",p.style.visibility="hidden",p.textContent="\u25B6",f.appendChild(p)}let d=document.createElement("span");d.textContent=s.inst_name,f.appendChild(d),o.appendChild(f);let h=[s.module_name,Ko(s.insts),Ko(s.macros),Ko(s.modules),this._fmtArea(s.area),Ko(s.local_insts),Ko(s.local_macros),Ko(s.local_modules)];for(let p of h){let m=document.createElement("td");m.textContent=p,m.style.textAlign="right",o.appendChild(m)}o.children[1].style.textAlign="left",i.appendChild(o)}if(this._rows.length===0){let r=document.createElement("tr"),s=document.createElement("td");s.colSpan=aM.length,s.style.textAlign="center",s.style.color="var(--fg-secondary)",s.textContent=ue(this._app)?"No hierarchy data available":'Click "Update" to load hierarchy',r.appendChild(s),i.appendChild(r)}this._table.appendChild(i),ws(this._table)}_isHidden(e){let t=e.parent_id;for(;t>=0;){if(this._collapsed.has(t))return!0;let i=this._nodeMap.get(t);if(!i)break;t=i.parent_id}return!1}_toggleNode(e){this._collapsed.has(e)?this._collapsed.delete(e):this._collapsed.add(e),this._computeEffectiveColors(),this._render(),this._sendModuleColors()}_fmtArea(e){if(e==null)return"";if(this._app.showDbu){let t=this._app.getDbuPerMicron();return String(Math.round(e*t*t))}return e>=1e6?(e/1e6).toFixed(3)+" mm\xB2":e.toFixed(3)+" \u03BCm\xB2"}};function Ko(n){return n!=null?String(n):""}var mW='',gW='',_W='',yW='',bW='',vW='',xW='',wW='',EW='',SW='',PW='',CW='';function cM(n,e,t){t=t||e;let i=null,r=null,s=null,o=!1,a=10;function c(M,S){return o?Promise.resolve():(o=!0,n.websocketManager.request({type:"set_property",name:M,use_dbu:n.showDbu,...S}).then(L=>{!L.ok&&L.error&&nn(L.error),Me(L),L.ok&&L.bbox&&$e(L.bbox)}).catch(L=>{console.error("set_property failed:",L),nn("Edit failed: "+L),i&&Me(i)}).finally(()=>{o=!1}))}function l(M,S){let L=document.createElement("select");L.className="inspector-editor-select";let F=M.editor.type==="bool"?["True","False"]:M.editor.options||[];for(let k of F){let U=document.createElement("option");U.value=k,U.textContent=k,k===M.value&&(U.selected=!0),L.appendChild(U)}if(!F.includes(M.value)){let k=document.createElement("option");k.value=M.value||"",k.textContent=M.value||"",k.selected=!0,k.disabled=!0,L.insertBefore(k,L.firstChild)}return L.addEventListener("change",()=>{if(S.onPropertyChange){S.onPropertyChange(M.name,L.value);return}if(M.editor.type==="bool")S.onPropertyEdit(M,{value:L.value==="True"});else{let k=(M.editor.options||[]).indexOf(L.value);S.onPropertyEdit(M,{option_index:k,option_name:L.value})}}),L}async function u(M,S){if(!o&&!(M==="Delete"&&!await k3({title:"Delete "+(S.type||"object"),message:"Delete "+(S.type||"object")+' "'+(S.name||"")+'"? This cannot be undone.',confirmLabel:"Delete",danger:!0}))){o=!0;try{let L=await n.websocketManager.request({type:"trigger_action",name:M,use_dbu:n.showDbu});!L.ok&&L.error&&nn(L.error),Me(L.properties?L:null),L.deleted&&_t(),ie(),t()}catch(L){console.error("trigger_action failed:",L),nn("Action failed: "+L)}finally{o=!1}}}function f(M){n.websocketManager.request({...M,use_dbu:n.showDbu}).then(S=>{!S.ok&&S.error&&nn(S.error),Me(S),t()}).catch(S=>{console.error(M.type+" failed:",S)})}function d(){let M=document.getElementById("highlight-picker");M&&M.remove()}function h(M,S){d();let L=n.techData?.highlight_colors||[];if(!L.length)return;let F=document.createElement("div");F.id="highlight-picker";let k=document.createElement("div");if(k.className="highlight-swatch-grid",L.forEach((B,$)=>{let Z=document.createElement("button");Z.className="highlight-swatch",Z.title="Group "+($+1),Z.style.backgroundColor=`rgb(${B[0]}, ${B[1]}, ${B[2]})`,$===S.highlight_group&&Z.classList.add("active"),Z.addEventListener("click",()=>{d(),f({type:"highlight",group:$})}),k.appendChild(Z)}),F.appendChild(k),S.highlight_group>=0){let B=document.createElement("button");B.className="highlight-remove",B.textContent="Remove highlight",B.addEventListener("click",()=>{d(),f({type:"unhighlight"})}),F.appendChild(B)}document.body.appendChild(F);let U=M.getBoundingClientRect();F.style.left=U.left+"px",F.style.top=U.bottom+4+"px";let R=B=>{B.type==="keydown"&&B.key!=="Escape"||B.type==="mousedown"&&F.contains(B.target)||(d(),document.removeEventListener("mousedown",R,!0),document.removeEventListener("keydown",R,!0))};setTimeout(()=>{document.addEventListener("mousedown",R,!0),document.addEventListener("keydown",R,!0)},0)}function p(){if(!n.inspectorEl)return;n.inspectorEl.innerHTML="";let M=document.createElement("div");M.className="stub-panel",M.innerHTML='
Loading\u2026
Fetching properties from server.
',n.inspectorEl.appendChild(M)}async function m(M){let S=n.focusNets.has(M)?"remove":"add";S==="add"?n.focusNets.add(M):n.focusNets.delete(M);try{await n.websocketManager.request({type:"set_focus_nets",action:S,net_name:M})}catch(L){console.error("set_focus_nets failed:",L)}e(),i&&Me(i)}async function g(){n.focusNets.clear();try{await n.websocketManager.request({type:"set_focus_nets",action:"clear",net_name:""})}catch(M){console.error("set_focus_nets clear failed:",M)}e(),i&&Me(i)}async function v(M){let S=n.routeGuideNets.has(M)?"remove":"add";S==="add"?n.routeGuideNets.add(M):n.routeGuideNets.delete(M);try{await n.websocketManager.request({type:"set_route_guides",action:S,net_name:M})}catch(L){console.error("set_route_guides failed:",L)}t(),i&&Me(i)}function y(M,S,L,F){return Ot(M,S,L,F,n.designScale,n.designOriginX,n.designOriginY)}function b(M,S,L){return M+(S-M)*L}function w(M,S,L){return M.map((F,k)=>Math.round(b(F,S[k],L)))}function E(M,S){let L=0;for(;LM[L+1].at;)L++;let F=M[L],k=M[L+1],U=Math.max(0,Math.min(1,(S-F.at)/(k.at-F.at))),R={};for(let B of Object.keys(F))B!=="at"&&(R[B]=Array.isArray(F[B])?w(F[B],k[B],U):b(F[B],k[B],U));return R}function x(M,S,L,F){if(Gl()||typeof requestAnimationFrame!="function")return F(),()=>{};let k=performance.now(),U=!1,R=()=>{if(U)return;let B=performance.now()-k;if(B>=M*S){F();return}L(B%M/M),requestAnimationFrame(R)};return R(),()=>{U=!0}}function T(M,S,L=at.highlight){n.view&&n.view.setOverlay(M,S,{order:L})}let I=null,N=()=>{},D=[255,242,122],H=[{at:0,stroke:[255,246,176],width:7,alpha:1,fill:.28},{at:.55,stroke:[255,255,255],width:5,alpha:1,fill:.06},{at:1,stroke:[255,232,92],width:3,alpha:.95,fill:.14}],W={stroke:[255,232,92],width:3,alpha:1,fill:.14};function V(M,S,L,F){let[k,U,R,B]=y(M,S,L,F),$=a/2**n.view.getZoom(),Z=Math.max(0,($-(R-k))/2),Q=Math.max(0,($-(B-U))/2);return[k-Z,U-Q,R+Z,B+Q]}function X(M){I&&T("hover",I.map(([S,L,F,k])=>({kind:"rect",rect:V(S,L,F,k),stroke:Nt(M.stroke,M.alpha),width:M.width,fill:Nt(D,M.fill)})))}function Y(){X(W)}function ie(){N(),I=null,T("hover",null),n.view?.off("zoom",Y)}function oe(){ie(),n.websocketManager.request({type:"hover",select_id:-1}).then(()=>{}).catch(()=>{})}function zt(M){ie(),!(!n.view||!n.designScale||!M||M.length===0)&&(I=M,n.view.on("zoom",Y),N=x(900,3,S=>X(E(H,1-Math.pow(1-S,2))),()=>X(W)))}function je(M,S){M.classList.add("inspector-link"),M.addEventListener("click",L=>{L.stopPropagation(),si(S)}),M.addEventListener("mouseenter",()=>{s!==null&&(n.websocketManager.cancel(s),s=null);let L=n.websocketManager.request({type:"hover",select_id:S});s=L.requestId,L.then(F=>{s=null,zt(F.rects||[]),t()}).catch(()=>{s=null})}),M.addEventListener("mouseleave",()=>{oe(),t()})}function sn(M){let S=M>0?"select_next":"select_prev";r!==null&&(n.websocketManager.cancel(r),r=null),p();let L=St(n),F=n.websocketManager.request({type:S,use_dbu:n.showDbu});r=F.requestId,F.then(k=>{if(r=null,!!Dt(n,L)){if(k.error){console.error("Selection cycle error:",k.error),Me(i);return}if(Me(k),k.type==="Inst"&&k.name&&(n.selectedInstanceName=k.name,n.schematicWidget&&n.schematicWidget.refresh()),ie(),_t(),k.bbox&&n.view&&n.designScale){let[U,R,B,$]=k.bbox;k.type!=="Inst"&&Sn(U,R,B,$,k.type),k.selection_count>1?Ut(k.bbox):$e(k.bbox,k.type)}e()}}).catch(k=>{r=null,console.error("Selection cycle failed:",k),Me(i)})}function si(M){r!==null&&(n.websocketManager.cancel(r),r=null),p();let S=St(n),L=n.websocketManager.request({type:"inspect",select_id:M,use_dbu:n.showDbu});r=L.requestId,L.then(F=>{if(r=null,!!Dt(n,S)){if(F.error){console.error("Inspect error:",F.error);return}if(Me(F),ie(),_t(),F.bbox&&n.view&&n.designScale){let[k,U,R,B]=F.bbox;F.type!=="Inst"&&Sn(k,U,R,B,F.type),$e(F.bbox,F.type)}t()}}).catch(F=>{r=null,console.error("Inspect failed:",F)})}function oi(){r!==null&&(n.websocketManager.cancel(r),r=null),p();let M=St(n),S=n.websocketManager.request({type:"inspect_back",use_dbu:n.showDbu});r=S.requestId,S.then(L=>{if(r=null,!!Dt(n,M)){if(L.error){console.error("Inspect back error:",L.error);return}if(Me(L),ie(),_t(),L.bbox&&n.view&&n.designScale){if(L.type!=="Inst"){let[F,k,U,R]=L.bbox;Sn(F,k,U,R,L.type)}$e(L.bbox,L.type)}t()}}).catch(L=>{r=null,console.error("Inspect back failed:",L)})}let on=null;function Ri(){let M=on&&n.designScale&&!(n.visibility&&n.visibility.highlight_selected===!1);T("selection",M?[{kind:"rect",rect:y(...on),stroke:Nt("#ff0"),width:2,dash:[6,4]}]:null,at.selection)}function _t(){on=null,Ri()}function Sn(M,S,L,F,k){on=k==="Net"?null:[M,S,L,F],Ri()}let Pn=null,Cn=[{at:0,alpha:0,fill:0},{at:.5,alpha:1,fill:.28},{at:1,alpha:0,fill:0}];function gr(){Pn&&(Pn(),Pn=null),T("pulse",null)}function $e(M,S){if(!M||!n.view||!n.designScale||(Ge!==null&&ai(),gr(),n.visibility&&n.visibility.highlight_selected===!1)||S==="Net")return;let L=y(...M);Pn=x(350,3,F=>{let k=E(Cn,.5-.5*Math.cos(Math.PI*F));T("pulse",[{kind:"rect",rect:L,stroke:Nt("#ff0",k.alpha),width:3,fill:Nt("#ff0",k.fill)}])},()=>{Pn=null,T("pulse",null)})}let Ge=null;function _r(M,S){T("anim",[{kind:"rect",rect:M,stroke:Nt("#ff0"),width:S,fill:Nt("#ff0",S===1?.39:0)}])}function ai(){Ge!==null&&(clearInterval(Ge),Ge=null),T("anim",null)}function Ut(M,{repeats:S=6,intervalMs:L=300}={}){if(!M||!n.view||!n.designScale)return;if(ai(),Gl()){$e(M);return}let F=y(...M);_r(F,1);let k=0,U=S>0?S*3:1/0;Ge=setInterval(()=>{if(k+=1,k>=U){ai();return}_r(F,k%3+1)},L)}n.clearSelectionPulse=gr,n.renderSelectionOutline=Ri,n.clearSelectionOutline=_t;function ci(M,S,L){let F=document.createElement("div");F.className="inspector-group";let k=document.createElement("div");k.className="inspector-group-header";let U=document.createElement("span");U.className="vis-arrow";let R=document.createElement("span");if(R.className="inspector-prop-name",R.textContent=M,R.title=M,k.appendChild(U),k.appendChild(R),S!==null){let $=document.createElement("span");$.className="inspector-count",$.textContent=`(${S})`,k.appendChild($)}F.appendChild(k);let B=document.createElement("div");return B.className="inspector-group-children"+(L?" collapsed":""),U.textContent=L?"\u25B6":"\u25BC",F.appendChild(B),k.addEventListener("click",()=>{B.classList.toggle("collapsed"),U.textContent=B.classList.contains("collapsed")?"\u25B6":"\u25BC"}),{group:F,header:k,arrow:U,body:B}}function Ve(M){let S=M.column_headers||[],L=M.row_headers||[],F=M.data||[],k=S.some($=>$!==""),U=L.some($=>$!==""),R=document.createElement("table");if(R.className="inspector-table",k){let $=document.createElement("thead"),Z=document.createElement("tr");U&&Z.appendChild(document.createElement("th"));for(let Q of S){let de=document.createElement("th");de.textContent=Q,Z.appendChild(de)}$.appendChild(Z),R.appendChild($)}let B=document.createElement("tbody");return F.forEach(($,Z)=>{let Q=document.createElement("tr");if(U){let de=document.createElement("th");de.textContent=L[Z]||"",Q.appendChild(de)}for(let de of $){let _e=document.createElement("td");_e.textContent=de,Q.appendChild(_e)}B.appendChild(Q)}),R.appendChild(B),R}function li(M,S){if(M.table){let R=(M.table.data||[]).length,{group:B,body:$}=ci(M.name,R,R>=10),Z=document.createElement("div");return Z.className="inspector-table-scroll",Z.appendChild(Ve(M.table)),$.appendChild(Z),B}if(M.children){let R=M.children.length<10,{group:B,body:$}=ci(M.name,M.children.length,!R);for(let Z of M.children)$.appendChild(li(Z,S));return B}let L=document.createElement("div");L.className="inspector-prop";let F=document.createElement("span");F.className="inspector-prop-name",F.textContent=M.name||"",F.title=M.name||"";let k=document.createElement("span");k.className="inspector-prop-value",k.textContent=M.value||"",L.appendChild(F),L.appendChild(k);let U=M.editable&&S&&(S.onPropertyEdit||S.onPropertyChange)&&M.editor&&(M.editor.type==="list"||M.editor.type==="bool");if(U&&M.value_select_id===void 0)L.replaceChild(l(M,S),k);else if(U){let R=document.createElement("button");R.className="inspector-edit-btn",R.title="Edit "+M.name,R.textContent="\u270E",R.addEventListener("click",B=>{B.stopPropagation();let $=l(M,S);L.replaceChild($,k),R.remove(),$.focus()}),L.appendChild(R)}else M.editable&&S&&(S.onPropertyChange||S.onPropertyEdit)&&(k.contentEditable=!0,k.classList.add("inspector-editable"),k.addEventListener("blur",()=>{let R=k.textContent;if(R!==M.value){if(S.onPropertyChange){S.onPropertyChange(M.name,R);return}if(M.editor&&M.editor.type==="number"){let B=Number(R);if(R.trim()===""||Number.isNaN(B)){nn("Not a number: "+R),k.textContent=M.value;return}S.onPropertyEdit(M,{value:B});return}S.onPropertyEdit(M,{value:R})}}),k.addEventListener("keydown",R=>{R.key==="Enter"&&(R.preventDefault(),k.blur()),R.key==="Escape"&&(k.textContent=M.value,k.blur())}));return M.name_select_id!==void 0&&M.value_select_id===void 0?(je(L,M.name_select_id),F.classList.add("inspector-link")):M.name_select_id!==void 0&&je(F,M.name_select_id),M.value_select_id!==void 0&&je(k,M.value_select_id),L}let an=140,Ii=60,Bi=500,Oi=an;function Rs(){n.inspectorEl&&n.inspectorEl.style.setProperty("--inspector-name-w",Oi+"px")}function Tn(){let M=document.createElement("div");return M.className="inspector-col-resizer",M.title="Drag to resize the name column",M.addEventListener("mousedown",S=>{S.preventDefault();let L=S.clientX,F=Oi;M.classList.add("dragging");let k=R=>{Oi=Math.max(Ii,Math.min(Bi,F+R.clientX-L)),Rs()},U=()=>{M.classList.remove("dragging"),document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",U)};document.addEventListener("mousemove",k),document.addEventListener("mouseup",U)}),M}function $t(M){!M||!n.view||!n.designScale||n.view.fitWorldRect(y(...M),{padding:[20,20]})}function Me(M){if(!n.inspectorEl)return;if(i=M,n.inspectorEl.innerHTML="",!M||!M.properties||M.properties.length===0){ai();let k=document.createElement("div");k.className="stub-panel",k.innerHTML='
Inspector
Select an object in the layout to inspect its properties.
',n.inspectorEl.appendChild(k);return}if(!M.onPropertyChange&&!M.onPropertyEdit&&!ue(n)&&(M.onPropertyEdit=(k,U)=>c(k.name,U)),M){let k=document.createElement("div");k.className="inspector-toolbar";let U=document.createElement("button");if(U.className="or-btn or-btn-icon",U.title="Back",U.innerHTML=yW,U.disabled=!M.can_navigate_back,U.addEventListener("click",()=>oi()),k.appendChild(U),M.bbox){let R=document.createElement("button");R.className="or-btn or-btn-icon",R.title="Zoom to",R.innerHTML=_W,R.addEventListener("click",()=>$t(M.bbox)),k.appendChild(R)}if(M.type==="Net"&&M.name){let R=n.focusNets.has(M.name),B=document.createElement("button");B.className="or-btn or-btn-icon",B.title=R?"De-focus net":"Focus net",B.innerHTML=R?vW:bW,B.addEventListener("click",()=>m(M.name)),k.appendChild(B)}if(M.type==="Net"&&M.name&&M.has_guides){let R=n.routeGuideNets.has(M.name),B=document.createElement("button");B.className="or-btn or-btn-icon",B.title=R?"Hide route guides":"Show route guides",B.innerHTML=R?wW:xW,B.addEventListener("click",()=>v(M.name)),k.appendChild(B)}if(M.type==="Net"&&M.name&&n.showInsertBufferDialog){let R=document.createElement("button");R.className="or-btn or-btn-icon",R.title="Insert buffer",R.innerHTML=CW,R.addEventListener("click",()=>n.showInsertBufferDialog(M.name)),k.appendChild(R)}if(n.focusNets.size>0){let R=document.createElement("button");R.className="or-btn or-btn-icon",R.title="Clear focus nets",R.innerHTML=EW,R.addEventListener("click",()=>g()),k.appendChild(R)}if(typeof M.highlight_group=="number"&&!ue(n)&&(n.techData?.highlight_colors||[]).length){let R=document.createElement("button");R.className="or-btn or-btn-icon inspector-highlight-btn";let B=M.highlight_group;if(R.title=B>=0?"Highlight group "+(B+1):"Add to highlight group",R.innerHTML=gW,B>=0){let $=n.techData.highlight_colors[B];R.style.backgroundColor=`rgba(${$[0]}, ${$[1]}, ${$[2]}, 0.45)`,R.style.borderColor=`rgb(${$[0]}, ${$[1]}, ${$[2]})`}R.addEventListener("click",()=>h(R,M)),k.appendChild(R)}if(Array.isArray(M.actions)&&!ue(n))for(let R of M.actions){let B=document.createElement("button");B.className="or-btn inspector-action-btn",B.title=R,R==="Delete"?(B.classList.add("or-btn-icon","or-btn-danger-hover"),B.innerHTML=mW):(B.classList.add("or-btn-sm"),B.textContent=R),B.addEventListener("click",()=>u(R,M)),k.appendChild(B)}n.inspectorEl.appendChild(k)}let S=M.selection_count||0,L=typeof M.selection_index=="number"?M.selection_index:-1;if(S>1&&L>=0){let k=document.createElement("div");k.className="inspector-selection-nav";let U=document.createElement("button");U.className="or-btn or-btn-icon",U.title="Previous (Shift+click to multi-select)",U.innerHTML=SW,U.addEventListener("click",()=>sn(-1));let R=document.createElement("span");R.className="inspector-selection-label",R.textContent=L+1+" / "+S;let B=document.createElement("button");B.className="or-btn or-btn-icon",B.title="Next",B.innerHTML=PW,B.addEventListener("click",()=>sn(1)),k.appendChild(U),k.appendChild(R),k.appendChild(B),n.inspectorEl.appendChild(k)}let F=document.createElement("div");F.className="inspector-rows";for(let k of M.properties)F.appendChild(li(k,M));F.appendChild(Tn()),n.inspectorEl.appendChild(F),Rs()}function yr(M){let S=document.createElement("div");S.className="inspector",n.inspectorEl=S,M.element.appendChild(S),Me(null)}function Ae(){if(i){if(i.type==="Ruler"){n.rulerManager&&n.rulerManager._selectedRulerId!==null&&n.rulerManager._selectRuler(n.rulerManager._selectedRulerId);return}n.websocketManager&&si(-1)}}return{createInspector:yr,updateInspector:Me,highlightBBox:Sn,pulseHighlight:$e,animateSelection:Ut,stopSelectionAnimation:ai,navigateInspector:si,refreshInspector:Ae}}var Vh=class{constructor(e,t,i){this._app=t,this._refreshOverlay=i||(()=>{}),this._data={selection:[],groups:[],truncated:!1},this._tab="selected",this._filter="",this._sortKey=null,this._sortAsc=!0,this._pendingRefresh=null,this._inFlight=!1,this._staleWhileInFlight=!1,this._visible=!0,this._el=document.createElement("div"),this._el.className="selection-browser",e.element.appendChild(this._el),e.on?.("show",()=>{this._visible=!0,this.refresh()}),e.on?.("hide",()=>{this._visible=!1}),e.on?.("destroy",()=>{this._visible=!1,this._staleWhileInFlight=!1,this._pendingRefresh!==null&&(clearTimeout(this._pendingRefresh),this._pendingRefresh=null)}),this._render(),this.refresh()}scheduleRefresh(){!this._visible||this._pendingRefresh!==null||(this._pendingRefresh=setTimeout(()=>{this._pendingRefresh=null,this.refresh()},150))}refresh(){if(!this._visible||ue(this._app))return;if(this._inFlight){this._staleWhileInFlight=!0;return}this._inFlight=!0;let e=()=>{this._inFlight=!1,this._staleWhileInFlight&&(this._staleWhileInFlight=!1,this.refresh())};this._app.websocketManager.request({type:"list_selection"}).then(t=>{t.ok&&(this._data=t,this._render()),e()}).catch(e)}_entries(){let e;this._tab==="selected"?e=(this._data.selection||[]).map((i,r)=>({row:i,index:r,group:-1})):e=(this._data.groups||[]).flatMap((i,r)=>i.map((s,o)=>({row:s,index:o,group:r})));let t=this._filter.trim().toLowerCase();if(t&&(e=e.filter(({row:i})=>(i.name||"").toLowerCase().includes(t)||(i.type||"").toLowerCase().includes(t))),this._sortKey){let i=this._sortKey,r=this._sortAsc?1:-1;e=e.slice().sort((s,o)=>r*String(s.row[i]||"").localeCompare(String(o.row[i]||"")))}return e}_fmtCoord(e){if(this._app.showDbu)return String(e);let t=this._app.getDbuPerMicron?this._app.getDbuPerMicron():1e3;return(e/t).toFixed(3)}_fmtBounds(e){if(!e)return"";let[t,i,r,s]=e;return`(${this._fmtCoord(t)}, ${this._fmtCoord(i)}), (${this._fmtCoord(r)}, ${this._fmtCoord(s)})`}_inspectRow(e,t){let i=e.group<0?{type:"inspect_selection",index:e.index,use_dbu:this._app.showDbu}:{type:"inspect_group",group:e.group,index:e.index,use_dbu:this._app.showDbu};this._app.websocketManager.request(i).then(r=>{if(!r.ok){this.refresh();return}this._app.updateInspector&&this._app.updateInspector(r),t&&this._app.focusComponent&&this._app.focusComponent("Inspector"),this._refreshOverlay()}).catch(()=>{})}_deselectRow(e){this._app.websocketManager.request({type:"deselect",index:e.index}).then(()=>{this.refresh(),this._refreshOverlay()}).catch(()=>{})}_clearHighlights(){this._app.websocketManager.request({type:"clear_highlights",group:-1}).then(()=>{this.refresh(),this._refreshOverlay(),this._app.refreshInspector&&this._app.refreshInspector()}).catch(()=>{})}_zoomToBBox(e){if(!e||!this._app.designScale||!this._app.view)return;let[t,i,r,s]=e,o=this._app.getDbuPerMicron?this._app.getDbuPerMicron():1e3,a=Math.min(10*o,2*Math.max(r-t,s-i));this._app.view.fitWorldRect(Ot(t-a,i-a,r+a,s+a,this._app.designScale,this._app.designOriginX,this._app.designOriginY))}_render(){this._app.stopSelectionAnimation&&this._app.stopSelectionAnimation(),this._el.innerHTML="";let e=(this._data.selection||[]).length,t=(this._data.groups||[]).reduce((o,a)=>o+a.length,0),i=document.createElement("div");i.className="sb-tabs";for(let[o,a,c]of[["selected","Selected",e],["highlighted","Highlighted",t]]){let l=document.createElement("button");l.className="sb-tab"+(this._tab===o?" active":""),l.textContent=`${a} (${c})`,l.addEventListener("click",()=>{this._tab=o,this._render()}),i.appendChild(l)}let r=document.createElement("button");if(r.className="or-btn or-btn-sm sb-tool",r.title="Refresh",r.textContent="\u27F3",r.addEventListener("click",()=>this.refresh()),i.appendChild(r),this._tab==="highlighted"&&t>0){let o=document.createElement("button");o.className="or-btn or-btn-sm sb-tool",o.title="Clear all highlights",o.textContent="Clear",o.addEventListener("click",()=>this._clearHighlights()),i.appendChild(o)}this._el.appendChild(i);let s=document.createElement("input");if(s.type="text",s.className="sb-filter",s.placeholder="Filter by name or type\u2026",s.value=this._filter,s.addEventListener("input",()=>{this._filter=s.value,this._renderTable()}),this._el.appendChild(s),this._data.truncated){let o=document.createElement("div");o.className="sb-truncated",o.textContent="List truncated \u2014 showing the first 1000 entries per set.",this._el.appendChild(o)}this._tableWrap=document.createElement("div"),this._tableWrap.className="sb-table-wrap",this._el.appendChild(this._tableWrap),this._renderTable()}_renderTable(){this._tableWrap.innerHTML="";let e=this._entries();if(!e.length){let c=document.createElement("div");c.className="sb-empty",c.textContent=this._tab==="selected"?"Nothing selected.":"Nothing highlighted.",this._tableWrap.appendChild(c);return}let t=document.createElement("table");t.className="sb-table";let i=document.createElement("thead"),r=document.createElement("tr"),s=[["name","Object"],["type","Type"],[null,"Bounds"]];this._tab==="highlighted"&&s.push([null,"Group"]),s.push([null,""]);for(let[c,l]of s){let u=document.createElement("th");u.textContent=l,c&&(u.classList.add("sb-sortable"),this._sortKey===c&&(u.textContent+=this._sortAsc?" \u25B2":" \u25BC"),u.addEventListener("click",()=>{this._sortKey===c?this._sortAsc=!this._sortAsc:(this._sortKey=c,this._sortAsc=!0),this._renderTable()})),r.appendChild(u)}i.appendChild(r),t.appendChild(i);let o=document.createElement("tbody"),a=this._app.techData?.highlight_colors||[];for(let c of e){let l=document.createElement("tr");l.className="sb-row";let u=document.createElement("td");u.textContent=c.row.name||"";let f=document.createElement("td");f.textContent=c.row.type||"";let d=document.createElement("td");if(d.textContent=this._fmtBounds(c.row.bbox),l.appendChild(u),l.appendChild(f),l.appendChild(d),this._tab==="highlighted"){let p=document.createElement("td"),m=document.createElement("span");m.className="sb-chip";let g=a[c.group];g&&(m.style.backgroundColor=`rgb(${g[0]}, ${g[1]}, ${g[2]})`),p.appendChild(m),p.appendChild(document.createTextNode(` Group ${c.group+1}`)),l.appendChild(p)}let h=document.createElement("td");if(h.className="sb-actions",c.row.bbox){let p=document.createElement("button");p.className="sb-row-btn",p.title="Zoom to",p.textContent="\u2316",p.addEventListener("click",m=>{m.stopPropagation(),this._zoomToBBox(c.row.bbox)}),h.appendChild(p)}if(this._tab==="selected"){let p=document.createElement("button");p.className="sb-row-btn",p.title="De-select",p.textContent="\u2715",p.addEventListener("click",m=>{m.stopPropagation(),this._deselectRow(c)}),h.appendChild(p)}l.appendChild(h),l.addEventListener("click",()=>this._inspectRow(c,!1)),l.addEventListener("dblclick",()=>this._inspectRow(c,!0)),c.row.bbox&&(l.addEventListener("mouseenter",()=>{this._app.animateSelection&&this._app.animateSelection(c.row.bbox,{repeats:0})}),l.addEventListener("mouseleave",()=>{this._app.stopSelectionAnimation&&this._app.stopSelectionAnimation()})),o.appendChild(l)}t.appendChild(o),this._tableWrap.appendChild(t),ws(t)}};var uM="options-dialog",lM=[{label:"System default",value:""},{label:"Sans-serif",value:"sans-serif"},{label:"Serif",value:"serif"},{label:"Monospace",value:"monospace"},{label:"Helvetica / Arial",value:"Helvetica, Arial, sans-serif"},{label:"Georgia",value:"Georgia, 'Times New Roman', serif"},{label:"Courier",value:"'Courier New', Courier, monospace"}],TW=100,Wh=70,jh=200;function Wl(n){let e=n===""||n===null?NaN:Math.round(Number(n));return Number.isFinite(e)?Math.min(jh,Math.max(Wh,e)):TW}function fM(n){let{overlay:e,close:t,okBtn:i,showError:r}=Xo("Arrow keys scroll step",` +Slack: [${t.lower.toFixed(h)}, ${t.upper.toFixed(h)}) ${d}`}this._tooltip.style.display="block";let s=this.element.getBoundingClientRect(),o=this._tooltip.getBoundingClientRect(),a=4,c=e.clientX-s.left,l=e.clientY-s.top,u=c+12;u+o.width>s.width-a&&(u=c-12-o.width),u=Math.max(a,u);let f=l-10;f=Math.min(s.height-o.height-a,Math.max(a,f)),this._tooltip.style.left=u+"px",this._tooltip.style.top=f+"px"}else this._tooltip.style.display="none"}async _handleClick(e){if(this._activeDebugChart>=0||this._currentTab==="fanout"||this._currentTab==="netlength")return;let t=this._hitTestBar(e);if(!(!t||t.count===0))try{let i=await this._app.websocketManager.request({type:"timing_report",is_setup:this._currentTab==="setup",max_paths:50,slack_min:t.lower,slack_max:t.upper});this._app.timingWidget&&(this._app.timingWidget.showPaths(this._currentTab,i.paths||[]),this._app.focusComponent&&this._app.focusComponent("TimingWidget"))}catch(i){console.error("Charts bar click error:",i)}}async _handleDblClick(e){if(this._activeDebugChart>=0)return;let t;if(this._currentTab==="fanout")t="select_fanout_bin";else if(this._currentTab==="netlength")t="select_net_length_bin";else return;let i=this._hitTestBar(e);if(!i||i.count===0)return;let r=Pt(this._app);try{let s=await this._app.websocketManager.request({type:t,lower:i.lower,upper:i.upper,use_dbu:this._app.showDbu});if(!zt(this._app,r))return;s&&s.truncated&&console.warn(`Bin has ${s.count} nets; selection capped at ${s.selection_limit} for performance.`),this._app.updateInspector&&this._app.updateInspector(s),this._app.focusComponent&&this._app.focusComponent("Inspector"),this._redrawAllLayers&&this._redrawAllLayers()}catch(s){console.error("Net bin select failed:",s)}}_activeChartData(){return this._activeDebugChart>=0?{kind:"generic",data:this._debugCharts[this._activeDebugChart]}:{kind:"histogram",data:this._histogramData}}_chartBaseName(){return this._activeDebugChart>=0?this._debugCharts[this._activeDebugChart].name||"chart":this._currentTab}_triggerDownload(e,t,{revoke:i=!1}={}){let r=document.createElement("a");r.href=t,r.download=e,document.body.appendChild(r),r.click(),r.remove(),i&&URL.revokeObjectURL(t)}_download(e,t,i){try{let r=URL.createObjectURL(new Blob([i],{type:t}));this._triggerDownload(e,r,{revoke:!0})}catch(r){console.error("Download failed:",r)}}_exportCsv(){let{kind:e,data:t}=this._activeChartData();if(!t)return;let i=yW(e,t);this._download(this._chartBaseName()+".csv","text/csv",i)}_exportPng(){try{let e=this._canvas.toDataURL("image/png");this._triggerDownload(this._chartBaseName()+".png",e)}catch(e){console.error("PNG export failed:",e)}}setDebugCharts(e){this._debugCharts=e,e.length===0?this._activeDebugChart=-1:this._activeDebugChart>=e.length&&(this._activeDebugChart=0),this._rebuildSelect(),this._syncView()}_syncView(){let e=this._activeDebugChart>=0;e&&(this._hoveredBar=null,this._tooltip.style.display="none");let t=!e&&(this._currentTab==="setup"||this._currentTab==="hold");this._filterRow&&(this._filterRow.style.display=t?"":"none"),this._sizeCanvas(),e?this._renderLineChart(this._debugCharts[this._activeDebugChart]):(this._computeLayout(),this._render())}_renderLineChart(e){let t=this._canvas.getBoundingClientRect(),i=t.width,r=t.height,s=this._ctx,o=Cs();s.clearRect(0,0,i,r),s.fillStyle=o.canvasBg,s.fillRect(0,0,i,r);let a=e.points;if(!a||a.length===0){s.fillStyle=o.canvasText,s.font="14px "+o.fontSans,s.textAlign="center",s.textBaseline="middle",s.fillText("No data points yet",i/2,r/2);return}let c=e.y_labels?e.y_labels.length:1,l=sM,u=i-oM,f=aM,d=r-cM,h=u-l,p=d-f;if(h<=0||p<=0)return;let m=a[0].x,g=a[0].x,v=1/0,y=-1/0;for(let T of a){T.xg&&(g=T.x);for(let R of T.ys)Ry&&(y=R)}m===g&&(g=m+1),(!isFinite(v)||!isFinite(y))&&(v=0,y=1);let b=(y-v)*.05||1;v-=b,y+=b;let x=T=>l+(T-m)/(g-m)*h,E=T=>d-(T-v)/(y-v)*p;s.strokeStyle=o.canvasAxis,s.lineWidth=1,s.beginPath(),s.moveTo(l,f),s.lineTo(l,d),s.lineTo(u,d),s.stroke(),s.fillStyle=o.canvasLabel,s.font="10px "+o.fontMono,s.textAlign="right",s.textBaseline="middle";let w=5;for(let T=0;T<=w;T++){let R=v+(y-v)*T/w,F=E(R);s.fillText(this._formatNum(R),l-4,F),T>0&&T1&&e.y_labels){s.font="10px "+o.fontMono,s.textAlign="left",s.textBaseline="top";let T=l+8,R=f+4;for(let F=0;F=1e6?(e/1e6).toFixed(1)+"M":t>=1e3?(e/1e3).toFixed(1)+"k":t>=1?e.toFixed(1):e.toPrecision(3)}_formatCount(e){return e===0?"0":e>=1e6?e/1e6+"M":e>=1e3?e/1e3+"k":String(e)}};var Cn=class{constructor(e){this.onChange=e,this.roots=[],this._nodeMap=new Map}addFromSpec(e,t=null){let i=this._makeNode(e.id,t,e);if(i.checked=e.checked!==!1,e.children){for(let r of e.children)i.children.push(this.addFromSpec(r,i));i.hasCheckbox&&this._computeParent(i)}return t||this.roots.push(i),i}buildFromNodes(e){this._nodeMap.clear(),this.roots=[];for(let t of e)this._makeNode(t.id,null,t);for(let t of e){let i=this._nodeMap.get(t.id);if(t.parentId!=null&&this._nodeMap.has(t.parentId)){let r=this._nodeMap.get(t.parentId);i.parent=r,r.children.push(i)}else this.roots.push(i)}for(let t=e.length-1;t>=0;t--){let i=this._nodeMap.get(e[t].id);i.hasCheckbox&&i.children.length>0&&this._computeParent(i)}return this.roots}get(e){return this._nodeMap.get(e)}isVisible(e){let t=this.get(e);return t?t.checked:!1}check(e,t){let i=this._nodeMap.get(e);if(i){i.checked=t,i.indeterminate=!1;for(let r of i.children)this._setSubtree(r,t);for(let r=i.parent;r;r=r.parent)r.hasCheckbox&&this._computeParent(r);this.onChange()}}cascadeQuiet(e,t){let i=this._nodeMap.get(e);if(i){i.checked=t,i.indeterminate=!1;for(let r of i.children)this._setSubtree(r,t);for(let r=i.parent;r;r=r.parent)r.hasCheckbox&&this._computeParent(r)}}checkSet(e){for(let[t,i]of Object.entries(e)){let r=this._nodeMap.get(t);r&&(r.checked=i,r.indeterminate=!1)}this._recomputeAllParents(),this.onChange()}mirrorStates(e){this._applyMirror(e),this.onChange()}mirrorStatesQuiet(e){this._applyMirror(e)}_applyMirror(e){for(let[t,i]of Object.entries(e)){let r=this._nodeMap.get(t);r&&(r.checked=!!i.checked,r.indeterminate=!!i.indeterminate)}}forEach(e){let t=i=>{e(i);for(let r of i.children)t(r)};for(let i of this.roots)t(i)}_makeNode(e,t,i){let r={id:e,parent:t,children:[],hasCheckbox:i.hasCheckbox!==!1,checked:i.checked!==!1,indeterminate:!1,data:i.data!=null?i.data:i};return this._nodeMap.set(e,r),r}_checkboxDescendants(e){let t=[];for(let i of e.children)i.hasCheckbox?t.push(i):t.push(...this._checkboxDescendants(i));return t}_computeParent(e){let t=this._checkboxDescendants(e);if(t.length===0)return;let i=t.every(s=>s.checked&&!s.indeterminate),r=t.every(s=>!s.checked&&!s.indeterminate);e.checked=i,e.indeterminate=!i&&!r}_setSubtree(e,t){e.hasCheckbox&&(e.checked=t,e.indeterminate=!1);for(let i of e.children)this._setSubtree(i,t)}_recomputeAllParents(){let e=t=>{for(let i of t.children)e(i);t.hasCheckbox&&t.children.length>0&&this._computeParent(t)};for(let t of this.roots)e(t)}};var lM=["Instance","Module","Instances","Macros","Modules","Area","Local Inst","Local Macros","Local Modules"],dr={MODULE:0,LEAF_GROUP:1,TYPE_GROUP:2,INSTANCE:3,NAME_GROUP:4};function Ls(n){return n===dr.MODULE||n===dr.NAME_GROUP}var Vh=class{constructor(e,t,i){this._app=t,this._redrawAllLayers=i,this._nodes=[],this._nameGrouped=!1,this._nameGroupsCapped=!1,this._rows=[],this._childrenMap=new Map,this._collapsed=new Set,this._moduleState=new Map,this._checkModel=null,this._build(e),t.hierarchyBrowser=this,fe(t)&&this.update()}_build(e){let t=document.createElement("div");t.className="hierarchy-widget";let i=document.createElement("div");i.className="timing-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",fe(this._app)&&(this._updateBtn.style.display="none"),this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",i.appendChild(this._updateBtn),i.appendChild(this._statusLabel),t.appendChild(i),this._tableContainer=document.createElement("div"),this._tableContainer.className="hierarchy-table-container",this._table=document.createElement("table"),this._table.className="timing-table",this._tableContainer.appendChild(this._table),t.appendChild(this._tableContainer),e.element.appendChild(t),this._bindEvents()}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update())}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...",this._statusLabel.textContent="";try{let e=await this._app.websocketManager.request({type:"module_hierarchy"});this._nodes=e.nodes||[],this._nameGrouped=!!e.name_grouped,this._nameGroupsCapped=!!e.name_groups_capped,this._buildTree(),this._readServerColors(),this._computeEffectiveColors(),this._render(),this._statusLabel.textContent=this._statusText(),await this._sendModuleColors()}catch(e){this._statusLabel.textContent="Error: "+e.message}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}_statusText(){let e=this._nodes.filter(r=>Ls(r.node_kind||0)).length;if(!this._nameGrouped)return e+" modules";let i=Math.max(0,e-1)+" groups from instance names \u2014 this design has no module hierarchy";return this._nameGroupsCapped&&(i+=" (truncated: too many groups)"),i}_buildTree(){this._childrenMap.clear(),this._collapsed.clear();for(let t of this._nodes)this._childrenMap.set(t.id,[]);for(let t of this._nodes)t.parent_id>=0&&this._childrenMap.has(t.parent_id)&&this._childrenMap.get(t.parent_id).push(t.id);this._nodeMap=new Map;for(let t of this._nodes)this._nodeMap.set(t.id,t);for(let t of this._nodes){let i=this._childrenMap.get(t.id);if(!i||i.length===0)continue;let r=t.node_kind||0;r===dr.LEAF_GROUP||r===dr.TYPE_GROUP?this._collapsed.add(t.id):Ls(r)&&t.parent_id>=0&&this._collapsed.add(t.id)}this._rows=[];let e=this._nodes.filter(t=>t.parent_id<0);for(let t of e)this._dfs(t.id,0);this._checkModel=new Cn(()=>{this._checkModel.forEach(t=>{if(!t.hasCheckbox)return;let i=this._moduleState.get(t.data.odb_id);i&&(i.visible=t.checked)}),this._sendModuleColors()}),this._checkModel.buildFromNodes(this._nodes.map(t=>({id:t.id,parentId:t.parent_id,hasCheckbox:Ls(t.node_kind||0)&&t.odb_id!=null,checked:!0,data:t})))}_readServerColors(){this._moduleState.clear();for(let e of this._rows){let t=this._nodeMap.get(e.id);if(!t||!Ls(t.node_kind||0)||t.odb_id==null)continue;let i=t.color||[128,128,128];this._moduleState.set(t.odb_id,{color:i,effectiveColor:i,visible:!0,nodeId:t.id})}}_computeEffectiveColors(){for(let e of this._rows){let t=this._nodeMap.get(e.id);if(!t||!Ls(t.node_kind||0))continue;let i=this._moduleState.get(t.odb_id);if(!i)continue;let r=t.parent_id,s=null;for(;r>=0;){let o=this._nodeMap.get(r);if(!o)break;if(Ls(o.node_kind||0)){let a=this._moduleState.get(o.odb_id);a&&this._collapsed.has(o.id)&&(s=a.effectiveColor)}r=o.parent_id}i.effectiveColor=s||i.color}}async _sendModuleColors(){let e=[];for(let[i,r]of this._moduleState){if(!r.visible)continue;let[s,o,a]=r.effectiveColor;e.push(`${i}:${s},${o},${a},100`)}let t=e.join(";");try{let i=await this._app.websocketManager.request({type:"set_module_colors",colors:t});console.log("set_module_colors:",i.count,"modules,",e.length,"sent")}catch(i){console.error("set_module_colors failed:",i)}this._redrawAllLayers()}_dfs(e,t){this._rows.push({id:e,depth:t});let i=this._childrenMap.get(e)||[];for(let r of i)this._dfs(r,t+1)}_render(){this._table.innerHTML="";let e=document.createElement("thead"),t=document.createElement("tr");for(let r of lM){let s=document.createElement("th");s.textContent=r,t.appendChild(s)}e.appendChild(t),this._table.appendChild(e);let i=document.createElement("tbody");for(let r of this._rows){let s=this._nodeMap.get(r.id);if(!s||this._isHidden(s))continue;let o=document.createElement("tr"),a=s.node_kind||0,l=(this._childrenMap.get(r.id)||[]).length>0,u=this._collapsed.has(r.id);a===dr.LEAF_GROUP||a===dr.TYPE_GROUP?(o.style.fontStyle="italic",o.style.color="var(--fg-disabled)"):a===dr.INSTANCE?o.style.color="var(--fg-secondary)":a===dr.NAME_GROUP&&(o.classList.add("hierarchy-name-group"),o.title="Recovered from instance names \u2014 this design has no module hierarchy");let f=document.createElement("td");if(f.style.paddingLeft=8+r.depth*16+"px",f.style.whiteSpace="nowrap",Ls(a)&&s.odb_id!=null){let p=this._moduleState.get(s.odb_id),m=this._checkModel?this._checkModel.get(s.id):null;if(p&&m){let g=document.createElement("input");g.type="checkbox",g.checked=m.checked,g.indeterminate=m.indeterminate,g.className="hierarchy-module-cb",m.cb=g,g.addEventListener("change",E=>{E.stopPropagation(),this._checkModel.check(s.id,g.checked),this._render()}),f.appendChild(g);let v=document.createElement("span");v.className="hierarchy-color-swatch";let[y,b,x]=p.effectiveColor;v.style.backgroundColor=`rgb(${y},${b},${x})`,f.appendChild(v)}}if(l){let p=document.createElement("span");p.className="hierarchy-arrow",p.textContent=u?"\u25B6":"\u25BC",p.addEventListener("click",m=>{m.stopPropagation(),this._toggleNode(r.id)}),f.appendChild(p)}else{let p=document.createElement("span");p.className="hierarchy-arrow",p.style.visibility="hidden",p.textContent="\u25B6",f.appendChild(p)}let d=document.createElement("span");d.textContent=s.inst_name,f.appendChild(d),o.appendChild(f);let h=[s.module_name,Ko(s.insts),Ko(s.macros),Ko(s.modules),this._fmtArea(s.area),Ko(s.local_insts),Ko(s.local_macros),Ko(s.local_modules)];for(let p of h){let m=document.createElement("td");m.textContent=p,m.style.textAlign="right",o.appendChild(m)}o.children[1].style.textAlign="left",i.appendChild(o)}if(this._rows.length===0){let r=document.createElement("tr"),s=document.createElement("td");s.colSpan=lM.length,s.style.textAlign="center",s.style.color="var(--fg-secondary)",s.textContent=fe(this._app)?"No hierarchy data available":'Click "Update" to load hierarchy',r.appendChild(s),i.appendChild(r)}this._table.appendChild(i),ws(this._table)}_isHidden(e){let t=e.parent_id;for(;t>=0;){if(this._collapsed.has(t))return!0;let i=this._nodeMap.get(t);if(!i)break;t=i.parent_id}return!1}_toggleNode(e){this._collapsed.has(e)?this._collapsed.delete(e):this._collapsed.add(e),this._computeEffectiveColors(),this._render(),this._sendModuleColors()}_fmtArea(e){if(e==null)return"";if(this._app.showDbu){let t=this._app.getDbuPerMicron();return String(Math.round(e*t*t))}return e>=1e6?(e/1e6).toFixed(3)+" mm\xB2":e.toFixed(3)+" \u03BCm\xB2"}};function Ko(n){return n!=null?String(n):""}var bW='',vW='',xW='',wW='',EW='',SW='',PW='',CW='',TW='',LW='',MW='',AW='';function uM(n,e,t){t=t||e;let i=null,r=null,s=null,o=!1,a=10;function c(M,S){return o?Promise.resolve():(o=!0,n.websocketManager.request({type:"set_property",name:M,use_dbu:n.showDbu,...S}).then(L=>{!L.ok&&L.error&&Ft(L.error),Re(L),L.ok&&L.bbox&&Ge(L.bbox)}).catch(L=>{console.error("set_property failed:",L),Ft("Edit failed: "+L),i&&Re(i)}).finally(()=>{o=!1}))}function l(M,S){let L=document.createElement("select");L.className="inspector-editor-select";let D=M.editor.type==="bool"?["True","False"]:M.editor.options||[];for(let A of D){let z=document.createElement("option");z.value=A,z.textContent=A,A===M.value&&(z.selected=!0),L.appendChild(z)}if(!D.includes(M.value)){let A=document.createElement("option");A.value=M.value||"",A.textContent=M.value||"",A.selected=!0,A.disabled=!0,L.insertBefore(A,L.firstChild)}return L.addEventListener("change",()=>{if(S.onPropertyChange){S.onPropertyChange(M.name,L.value);return}if(M.editor.type==="bool")S.onPropertyEdit(M,{value:L.value==="True"});else{let A=(M.editor.options||[]).indexOf(L.value);S.onPropertyEdit(M,{option_index:A,option_name:L.value})}}),L}async function u(M,S){if(!o&&!(M==="Delete"&&!await I3({title:"Delete "+(S.type||"object"),message:"Delete "+(S.type||"object")+' "'+(S.name||"")+'"? This cannot be undone.',confirmLabel:"Delete",danger:!0}))){o=!0;try{let L=await n.websocketManager.request({type:"trigger_action",name:M,use_dbu:n.showDbu});!L.ok&&L.error&&Ft(L.error),Re(L.properties?L:null),L.deleted&&cn(),se(),t()}catch(L){console.error("trigger_action failed:",L),Ft("Action failed: "+L)}finally{o=!1}}}function f(M){n.websocketManager.request({...M,use_dbu:n.showDbu}).then(S=>{!S.ok&&S.error&&Ft(S.error),Re(S),t()}).catch(S=>{console.error(M.type+" failed:",S)})}function d(){let M=document.getElementById("highlight-picker");M&&M.remove()}function h(M,S){d();let L=n.techData?.highlight_colors||[];if(!L.length)return;let D=document.createElement("div");D.id="highlight-picker";let A=document.createElement("div");if(A.className="highlight-swatch-grid",L.forEach((B,U)=>{let Z=document.createElement("button");Z.className="highlight-swatch",Z.title="Group "+(U+1),Z.style.backgroundColor=`rgb(${B[0]}, ${B[1]}, ${B[2]})`,U===S.highlight_group&&Z.classList.add("active"),Z.addEventListener("click",()=>{d(),f({type:"highlight",group:U})}),A.appendChild(Z)}),D.appendChild(A),S.highlight_group>=0){let B=document.createElement("button");B.className="highlight-remove",B.textContent="Remove highlight",B.addEventListener("click",()=>{d(),f({type:"unhighlight"})}),D.appendChild(B)}document.body.appendChild(D);let z=M.getBoundingClientRect();D.style.left=z.left+"px",D.style.top=z.bottom+4+"px";let I=B=>{B.type==="keydown"&&B.key!=="Escape"||B.type==="mousedown"&&D.contains(B.target)||(d(),document.removeEventListener("mousedown",I,!0),document.removeEventListener("keydown",I,!0))};setTimeout(()=>{document.addEventListener("mousedown",I,!0),document.addEventListener("keydown",I,!0)},0)}function p(){if(!n.inspectorEl)return;n.inspectorEl.innerHTML="";let M=document.createElement("div");M.className="stub-panel",M.innerHTML='
Loading\u2026
Fetching properties from server.
',n.inspectorEl.appendChild(M)}async function m(M){let S=n.focusNets.has(M)?"remove":"add";S==="add"?n.focusNets.add(M):n.focusNets.delete(M);try{await n.websocketManager.request({type:"set_focus_nets",action:S,net_name:M})}catch(L){console.error("set_focus_nets failed:",L)}e(),i&&Re(i)}async function g(){n.focusNets.clear();try{await n.websocketManager.request({type:"set_focus_nets",action:"clear",net_name:""})}catch(M){console.error("set_focus_nets clear failed:",M)}e(),i&&Re(i)}async function v(M){let S=n.routeGuideNets.has(M)?"remove":"add";S==="add"?n.routeGuideNets.add(M):n.routeGuideNets.delete(M);try{await n.websocketManager.request({type:"set_route_guides",action:S,net_name:M})}catch(L){console.error("set_route_guides failed:",L)}t(),i&&Re(i)}function y(M,S,L,D){return Nt(M,S,L,D,n.designScale,n.designOriginX,n.designOriginY)}function b(M,S,L){return M+(S-M)*L}function x(M,S,L){return M.map((D,A)=>Math.round(b(D,S[A],L)))}function E(M,S){let L=0;for(;LM[L+1].at;)L++;let D=M[L],A=M[L+1],z=Math.max(0,Math.min(1,(S-D.at)/(A.at-D.at))),I={};for(let B of Object.keys(D))B!=="at"&&(I[B]=Array.isArray(D[B])?x(D[B],A[B],z):b(D[B],A[B],z));return I}function w(M,S,L,D){if(Vl()||typeof requestAnimationFrame!="function")return D(),()=>{};let A=performance.now(),z=!1,I=()=>{if(z)return;let B=performance.now()-A;if(B>=M*S){D();return}L(B%M/M),requestAnimationFrame(I)};return I(),()=>{z=!0}}function T(M,S,L=ot.highlight){n.view&&n.view.setOverlay(M,S,{order:L})}let R=null,F=()=>{},O=[255,242,122],j=[{at:0,stroke:[255,246,176],width:7,alpha:1,fill:.28},{at:.55,stroke:[255,255,255],width:5,alpha:1,fill:.06},{at:1,stroke:[255,232,92],width:3,alpha:.95,fill:.14}],V={stroke:[255,232,92],width:3,alpha:1,fill:.14};function G(M,S,L,D){let[A,z,I,B]=y(M,S,L,D),U=a/2**n.view.getZoom(),Z=Math.max(0,(U-(I-A))/2),Q=Math.max(0,(U-(B-z))/2);return[A-Z,z-Q,I+Z,B+Q]}function q(M){R&&T("hover",R.map(([S,L,D,A])=>({kind:"rect",rect:G(S,L,D,A),stroke:Ut(M.stroke,M.alpha),width:M.width,fill:Ut(O,M.fill)})))}function X(){q(V)}function se(){F(),R=null,T("hover",null),n.view?.off("zoom",X)}function le(){se(),n.websocketManager.request({type:"hover",select_id:-1}).then(()=>{}).catch(()=>{})}function he(M){se(),!(!n.view||!n.designScale||!M||M.length===0)&&(R=M,n.view.on("zoom",X),F=w(900,3,S=>q(E(j,1-Math.pow(1-S,2))),()=>q(V)))}function at(M,S){M.classList.add("inspector-link"),M.addEventListener("click",L=>{L.stopPropagation(),Tn(S)}),M.addEventListener("mouseenter",()=>{s!==null&&(n.websocketManager.cancel(s),s=null);let L=n.websocketManager.request({type:"hover",select_id:S});s=L.requestId,L.then(D=>{s=null,he(D.rects||[]),t()}).catch(()=>{s=null})}),M.addEventListener("mouseleave",()=>{le(),t()})}function Ct(M){let S=M>0?"select_next":"select_prev";r!==null&&(n.websocketManager.cancel(r),r=null),p();let L=Pt(n),D=n.websocketManager.request({type:S,use_dbu:n.showDbu});r=D.requestId,D.then(A=>{if(r=null,!!zt(n,L)){if(A.error){console.error("Selection cycle error:",A.error),Re(i);return}if(Re(A),A.type==="Inst"&&A.name&&(n.selectedInstanceName=A.name,n.schematicWidget&&n.schematicWidget.refresh()),se(),cn(),A.bbox&&n.view&&n.designScale){let[z,I,B,U]=A.bbox;A.type!=="Inst"&&Gt(z,I,B,U,A.type),A.selection_count>1?Mn(A.bbox):Ge(A.bbox,A.type)}e()}}).catch(A=>{r=null,console.error("Selection cycle failed:",A),Re(i)})}function Tn(M){r!==null&&(n.websocketManager.cancel(r),r=null),p();let S=Pt(n),L=n.websocketManager.request({type:"inspect",select_id:M,use_dbu:n.showDbu});r=L.requestId,L.then(D=>{if(r=null,!!zt(n,S)){if(D.error){console.error("Inspect error:",D.error);return}if(Re(D),se(),cn(),D.bbox&&n.view&&n.designScale){let[A,z,I,B]=D.bbox;D.type!=="Inst"&&Gt(A,z,I,B,D.type),Ge(D.bbox,D.type)}t()}}).catch(D=>{r=null,console.error("Inspect failed:",D)})}function Ni(){r!==null&&(n.websocketManager.cancel(r),r=null),p();let M=Pt(n),S=n.websocketManager.request({type:"inspect_back",use_dbu:n.showDbu});r=S.requestId,S.then(L=>{if(r=null,!!zt(n,M)){if(L.error){console.error("Inspect back error:",L.error);return}if(Re(L),se(),cn(),L.bbox&&n.view&&n.designScale){if(L.type!=="Inst"){let[D,A,z,I]=L.bbox;Gt(D,A,z,I,L.type)}Ge(L.bbox,L.type)}t()}}).catch(L=>{r=null,console.error("Inspect back failed:",L)})}let Ln=null;function li(){let M=Ln&&n.designScale&&!(n.visibility&&n.visibility.highlight_selected===!1);T("selection",M?[{kind:"rect",rect:y(...Ln),stroke:Ut("#ff0"),width:2,dash:[6,4]}]:null,ot.selection)}function cn(){Ln=null,li()}function Gt(M,S,L,D,A){Ln=A==="Net"?null:[M,S,L,D],li()}let ln=null,ui=[{at:0,alpha:0,fill:0},{at:.5,alpha:1,fill:.28},{at:1,alpha:0,fill:0}];function fi(){ln&&(ln(),ln=null),T("pulse",null)}function Ge(M,S){if(!M||!n.view||!n.designScale||(_t!==null&&di(),fi(),n.visibility&&n.visibility.highlight_selected===!1)||S==="Net")return;let L=y(...M);ln=w(350,3,D=>{let A=E(ui,.5-.5*Math.cos(Math.PI*D));T("pulse",[{kind:"rect",rect:L,stroke:Ut("#ff0",A.alpha),width:3,fill:Ut("#ff0",A.fill)}])},()=>{ln=null,T("pulse",null)})}let _t=null;function Vt(M,S){T("anim",[{kind:"rect",rect:M,stroke:Ut("#ff0"),width:S,fill:Ut("#ff0",S===1?.39:0)}])}function di(){_t!==null&&(clearInterval(_t),_t=null),T("anim",null)}function Mn(M,{repeats:S=6,intervalMs:L=300}={}){if(!M||!n.view||!n.designScale)return;if(di(),Vl()){Ge(M);return}let D=y(...M);Vt(D,1);let A=0,z=S>0?S*3:1/0;_t=setInterval(()=>{if(A+=1,A>=z){di();return}Vt(D,A%3+1)},L)}n.clearSelectionPulse=fi,n.renderSelectionOutline=li,n.clearSelectionOutline=cn;function hi(M,S,L){let D=document.createElement("div");D.className="inspector-group";let A=document.createElement("div");A.className="inspector-group-header";let z=document.createElement("span");z.className="vis-arrow";let I=document.createElement("span");if(I.className="inspector-prop-name",I.textContent=M,I.title=M,A.appendChild(z),A.appendChild(I),S!==null){let U=document.createElement("span");U.className="inspector-count",U.textContent=`(${S})`,A.appendChild(U)}D.appendChild(A);let B=document.createElement("div");return B.className="inspector-group-children"+(L?" collapsed":""),z.textContent=L?"\u25B6":"\u25BC",D.appendChild(B),A.addEventListener("click",()=>{B.classList.toggle("collapsed"),z.textContent=B.classList.contains("collapsed")?"\u25B6":"\u25BC"}),{group:D,header:A,arrow:z,body:B}}function Ke(M){let S=M.column_headers||[],L=M.row_headers||[],D=M.data||[],A=S.some(U=>U!==""),z=L.some(U=>U!==""),I=document.createElement("table");if(I.className="inspector-table",A){let U=document.createElement("thead"),Z=document.createElement("tr");z&&Z.appendChild(document.createElement("th"));for(let Q of S){let ye=document.createElement("th");ye.textContent=Q,Z.appendChild(ye)}U.appendChild(Z),I.appendChild(U)}let B=document.createElement("tbody");return D.forEach((U,Z)=>{let Q=document.createElement("tr");if(z){let ye=document.createElement("th");ye.textContent=L[Z]||"",Q.appendChild(ye)}for(let ye of U){let be=document.createElement("td");be.textContent=ye,Q.appendChild(be)}B.appendChild(Q)}),I.appendChild(B),I}function Wt(M,S){if(M.table){let I=(M.table.data||[]).length,{group:B,body:U}=hi(M.name,I,I>=10),Z=document.createElement("div");return Z.className="inspector-table-scroll",Z.appendChild(Ke(M.table)),U.appendChild(Z),B}if(M.children){let I=M.children.length<10,{group:B,body:U}=hi(M.name,M.children.length,!I);for(let Z of M.children)U.appendChild(Wt(Z,S));return B}let L=document.createElement("div");L.className="inspector-prop";let D=document.createElement("span");D.className="inspector-prop-name",D.textContent=M.name||"",D.title=M.name||"";let A=document.createElement("span");A.className="inspector-prop-value",A.textContent=M.value||"",L.appendChild(D),L.appendChild(A);let z=M.editable&&S&&(S.onPropertyEdit||S.onPropertyChange)&&M.editor&&(M.editor.type==="list"||M.editor.type==="bool");if(z&&M.value_select_id===void 0)L.replaceChild(l(M,S),A);else if(z){let I=document.createElement("button");I.className="inspector-edit-btn",I.title="Edit "+M.name,I.textContent="\u270E",I.addEventListener("click",B=>{B.stopPropagation();let U=l(M,S);L.replaceChild(U,A),I.remove(),U.focus()}),L.appendChild(I)}else M.editable&&S&&(S.onPropertyChange||S.onPropertyEdit)&&(A.contentEditable=!0,A.classList.add("inspector-editable"),A.addEventListener("blur",()=>{let I=A.textContent;if(I!==M.value){if(S.onPropertyChange){S.onPropertyChange(M.name,I);return}if(M.editor&&M.editor.type==="number"){let B=Number(I);if(I.trim()===""||Number.isNaN(B)){Ft("Not a number: "+I),A.textContent=M.value;return}S.onPropertyEdit(M,{value:B});return}S.onPropertyEdit(M,{value:I})}}),A.addEventListener("keydown",I=>{I.key==="Enter"&&(I.preventDefault(),A.blur()),I.key==="Escape"&&(A.textContent=M.value,A.blur())}));return M.name_select_id!==void 0&&M.value_select_id===void 0?(at(L,M.name_select_id),D.classList.add("inspector-link")):M.name_select_id!==void 0&&at(D,M.name_select_id),M.value_select_id!==void 0&&at(A,M.value_select_id),L}let un=140,An=60,Rs=500,pi=un;function yr(){n.inspectorEl&&n.inspectorEl.style.setProperty("--inspector-name-w",pi+"px")}function kn(){let M=document.createElement("div");return M.className="inspector-col-resizer",M.title="Drag to resize the name column",M.addEventListener("mousedown",S=>{S.preventDefault();let L=S.clientX,D=pi;M.classList.add("dragging");let A=I=>{pi=Math.max(An,Math.min(Rs,D+I.clientX-L)),yr()},z=()=>{M.classList.remove("dragging"),document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",z)};document.addEventListener("mousemove",A),document.addEventListener("mouseup",z)}),M}function jt(M){!M||!n.view||!n.designScale||n.view.fitWorldRect(y(...M),{padding:[20,20]})}function Re(M){if(!n.inspectorEl)return;if(i=M,n.inspectorEl.innerHTML="",!M||!M.properties||M.properties.length===0){di();let A=document.createElement("div");A.className="stub-panel",A.innerHTML='
Inspector
Select an object in the layout to inspect its properties.
',n.inspectorEl.appendChild(A);return}if(!M.onPropertyChange&&!M.onPropertyEdit&&!fe(n)&&(M.onPropertyEdit=(A,z)=>c(A.name,z)),M){let A=document.createElement("div");A.className="inspector-toolbar";let z=document.createElement("button");if(z.className="or-btn or-btn-icon",z.title="Back",z.innerHTML=wW,z.disabled=!M.can_navigate_back,z.addEventListener("click",()=>Ni()),A.appendChild(z),M.bbox){let I=document.createElement("button");I.className="or-btn or-btn-icon",I.title="Zoom to",I.innerHTML=xW,I.addEventListener("click",()=>jt(M.bbox)),A.appendChild(I)}if(M.type==="Net"&&M.name){let I=n.focusNets.has(M.name),B=document.createElement("button");B.className="or-btn or-btn-icon",B.title=I?"De-focus net":"Focus net",B.innerHTML=I?SW:EW,B.addEventListener("click",()=>m(M.name)),A.appendChild(B)}if(M.type==="Net"&&M.name&&M.has_guides){let I=n.routeGuideNets.has(M.name),B=document.createElement("button");B.className="or-btn or-btn-icon",B.title=I?"Hide route guides":"Show route guides",B.innerHTML=I?CW:PW,B.addEventListener("click",()=>v(M.name)),A.appendChild(B)}if(M.type==="Net"&&M.name&&n.showInsertBufferDialog){let I=document.createElement("button");I.className="or-btn or-btn-icon",I.title="Insert buffer",I.innerHTML=AW,I.addEventListener("click",()=>n.showInsertBufferDialog(M.name)),A.appendChild(I)}if(n.focusNets.size>0){let I=document.createElement("button");I.className="or-btn or-btn-icon",I.title="Clear focus nets",I.innerHTML=TW,I.addEventListener("click",()=>g()),A.appendChild(I)}if(typeof M.highlight_group=="number"&&!fe(n)&&(n.techData?.highlight_colors||[]).length){let I=document.createElement("button");I.className="or-btn or-btn-icon inspector-highlight-btn";let B=M.highlight_group;if(I.title=B>=0?"Highlight group "+(B+1):"Add to highlight group",I.innerHTML=vW,B>=0){let U=n.techData.highlight_colors[B];I.style.backgroundColor=`rgba(${U[0]}, ${U[1]}, ${U[2]}, 0.45)`,I.style.borderColor=`rgb(${U[0]}, ${U[1]}, ${U[2]})`}I.addEventListener("click",()=>h(I,M)),A.appendChild(I)}if(Array.isArray(M.actions)&&!fe(n))for(let I of M.actions){let B=document.createElement("button");B.className="or-btn inspector-action-btn",B.title=I,I==="Delete"?(B.classList.add("or-btn-icon","or-btn-danger-hover"),B.innerHTML=bW):(B.classList.add("or-btn-sm"),B.textContent=I),B.addEventListener("click",()=>u(I,M)),A.appendChild(B)}n.inspectorEl.appendChild(A)}let S=M.selection_count||0,L=typeof M.selection_index=="number"?M.selection_index:-1;if(S>1&&L>=0){let A=document.createElement("div");A.className="inspector-selection-nav";let z=document.createElement("button");z.className="or-btn or-btn-icon",z.title="Previous (Shift+click to multi-select)",z.innerHTML=LW,z.addEventListener("click",()=>Ct(-1));let I=document.createElement("span");I.className="inspector-selection-label",I.textContent=L+1+" / "+S;let B=document.createElement("button");B.className="or-btn or-btn-icon",B.title="Next",B.innerHTML=MW,B.addEventListener("click",()=>Ct(1)),A.appendChild(z),A.appendChild(I),A.appendChild(B),n.inspectorEl.appendChild(A)}let D=document.createElement("div");D.className="inspector-rows";for(let A of M.properties)D.appendChild(Wt(A,M));D.appendChild(kn()),n.inspectorEl.appendChild(D),yr()}function na(M){let S=document.createElement("div");S.className="inspector",n.inspectorEl=S,M.element.appendChild(S),Re(null)}function Ce(){if(i){if(i.type==="Ruler"){n.rulerManager&&n.rulerManager._selectedRulerId!==null&&n.rulerManager._selectRuler(n.rulerManager._selectedRulerId);return}n.websocketManager&&Tn(-1)}}return{createInspector:na,updateInspector:Re,highlightBBox:Gt,pulseHighlight:Ge,animateSelection:Mn,stopSelectionAnimation:di,navigateInspector:Tn,refreshInspector:Ce}}var Wh=class{constructor(e,t,i){this._app=t,this._refreshOverlay=i||(()=>{}),this._data={selection:[],groups:[],truncated:!1},this._tab="selected",this._filter="",this._sortKey=null,this._sortAsc=!0,this._pendingRefresh=null,this._inFlight=!1,this._staleWhileInFlight=!1,this._visible=!0,this._el=document.createElement("div"),this._el.className="selection-browser",e.element.appendChild(this._el),e.on?.("show",()=>{this._visible=!0,this.refresh()}),e.on?.("hide",()=>{this._visible=!1}),e.on?.("destroy",()=>{this._visible=!1,this._staleWhileInFlight=!1,this._pendingRefresh!==null&&(clearTimeout(this._pendingRefresh),this._pendingRefresh=null)}),this._render(),this.refresh()}scheduleRefresh(){!this._visible||this._pendingRefresh!==null||(this._pendingRefresh=setTimeout(()=>{this._pendingRefresh=null,this.refresh()},150))}refresh(){if(!this._visible||fe(this._app))return;if(this._inFlight){this._staleWhileInFlight=!0;return}this._inFlight=!0;let e=()=>{this._inFlight=!1,this._staleWhileInFlight&&(this._staleWhileInFlight=!1,this.refresh())};this._app.websocketManager.request({type:"list_selection"}).then(t=>{t.ok&&(this._data=t,this._render()),e()}).catch(e)}_entries(){let e;this._tab==="selected"?e=(this._data.selection||[]).map((i,r)=>({row:i,index:r,group:-1})):e=(this._data.groups||[]).flatMap((i,r)=>i.map((s,o)=>({row:s,index:o,group:r})));let t=this._filter.trim().toLowerCase();if(t&&(e=e.filter(({row:i})=>(i.name||"").toLowerCase().includes(t)||(i.type||"").toLowerCase().includes(t))),this._sortKey){let i=this._sortKey,r=this._sortAsc?1:-1;e=e.slice().sort((s,o)=>r*String(s.row[i]||"").localeCompare(String(o.row[i]||"")))}return e}_fmtCoord(e){if(this._app.showDbu)return String(e);let t=this._app.getDbuPerMicron?this._app.getDbuPerMicron():1e3;return(e/t).toFixed(3)}_fmtBounds(e){if(!e)return"";let[t,i,r,s]=e;return`(${this._fmtCoord(t)}, ${this._fmtCoord(i)}), (${this._fmtCoord(r)}, ${this._fmtCoord(s)})`}_inspectRow(e,t){let i=e.group<0?{type:"inspect_selection",index:e.index,use_dbu:this._app.showDbu}:{type:"inspect_group",group:e.group,index:e.index,use_dbu:this._app.showDbu};this._app.websocketManager.request(i).then(r=>{if(!r.ok){this.refresh();return}this._app.updateInspector&&this._app.updateInspector(r),t&&this._app.focusComponent&&this._app.focusComponent("Inspector"),this._refreshOverlay()}).catch(()=>{})}_deselectRow(e){this._app.websocketManager.request({type:"deselect",index:e.index}).then(()=>{this.refresh(),this._refreshOverlay()}).catch(()=>{})}_clearHighlights(){this._app.websocketManager.request({type:"clear_highlights",group:-1}).then(()=>{this.refresh(),this._refreshOverlay(),this._app.refreshInspector&&this._app.refreshInspector()}).catch(()=>{})}_zoomToBBox(e){if(!e||!this._app.designScale||!this._app.view)return;let[t,i,r,s]=e,o=this._app.getDbuPerMicron?this._app.getDbuPerMicron():1e3,a=Math.min(10*o,2*Math.max(r-t,s-i));this._app.view.fitWorldRect(Nt(t-a,i-a,r+a,s+a,this._app.designScale,this._app.designOriginX,this._app.designOriginY))}_render(){this._app.stopSelectionAnimation&&this._app.stopSelectionAnimation(),this._el.innerHTML="";let e=(this._data.selection||[]).length,t=(this._data.groups||[]).reduce((o,a)=>o+a.length,0),i=document.createElement("div");i.className="sb-tabs";for(let[o,a,c]of[["selected","Selected",e],["highlighted","Highlighted",t]]){let l=document.createElement("button");l.className="sb-tab"+(this._tab===o?" active":""),l.textContent=`${a} (${c})`,l.addEventListener("click",()=>{this._tab=o,this._render()}),i.appendChild(l)}let r=document.createElement("button");if(r.className="or-btn or-btn-sm sb-tool",r.title="Refresh",r.textContent="\u27F3",r.addEventListener("click",()=>this.refresh()),i.appendChild(r),this._tab==="highlighted"&&t>0){let o=document.createElement("button");o.className="or-btn or-btn-sm sb-tool",o.title="Clear all highlights",o.textContent="Clear",o.addEventListener("click",()=>this._clearHighlights()),i.appendChild(o)}this._el.appendChild(i);let s=document.createElement("input");if(s.type="text",s.className="sb-filter",s.placeholder="Filter by name or type\u2026",s.value=this._filter,s.addEventListener("input",()=>{this._filter=s.value,this._renderTable()}),this._el.appendChild(s),this._data.truncated){let o=document.createElement("div");o.className="sb-truncated",o.textContent="List truncated \u2014 showing the first 1000 entries per set.",this._el.appendChild(o)}this._tableWrap=document.createElement("div"),this._tableWrap.className="sb-table-wrap",this._el.appendChild(this._tableWrap),this._renderTable()}_renderTable(){this._tableWrap.innerHTML="";let e=this._entries();if(!e.length){let c=document.createElement("div");c.className="sb-empty",c.textContent=this._tab==="selected"?"Nothing selected.":"Nothing highlighted.",this._tableWrap.appendChild(c);return}let t=document.createElement("table");t.className="sb-table";let i=document.createElement("thead"),r=document.createElement("tr"),s=[["name","Object"],["type","Type"],[null,"Bounds"]];this._tab==="highlighted"&&s.push([null,"Group"]),s.push([null,""]);for(let[c,l]of s){let u=document.createElement("th");u.textContent=l,c&&(u.classList.add("sb-sortable"),this._sortKey===c&&(u.textContent+=this._sortAsc?" \u25B2":" \u25BC"),u.addEventListener("click",()=>{this._sortKey===c?this._sortAsc=!this._sortAsc:(this._sortKey=c,this._sortAsc=!0),this._renderTable()})),r.appendChild(u)}i.appendChild(r),t.appendChild(i);let o=document.createElement("tbody"),a=this._app.techData?.highlight_colors||[];for(let c of e){let l=document.createElement("tr");l.className="sb-row";let u=document.createElement("td");u.textContent=c.row.name||"";let f=document.createElement("td");f.textContent=c.row.type||"";let d=document.createElement("td");if(d.textContent=this._fmtBounds(c.row.bbox),l.appendChild(u),l.appendChild(f),l.appendChild(d),this._tab==="highlighted"){let p=document.createElement("td"),m=document.createElement("span");m.className="sb-chip";let g=a[c.group];g&&(m.style.backgroundColor=`rgb(${g[0]}, ${g[1]}, ${g[2]})`),p.appendChild(m),p.appendChild(document.createTextNode(` Group ${c.group+1}`)),l.appendChild(p)}let h=document.createElement("td");if(h.className="sb-actions",c.row.bbox){let p=document.createElement("button");p.className="sb-row-btn",p.title="Zoom to",p.textContent="\u2316",p.addEventListener("click",m=>{m.stopPropagation(),this._zoomToBBox(c.row.bbox)}),h.appendChild(p)}if(this._tab==="selected"){let p=document.createElement("button");p.className="sb-row-btn",p.title="De-select",p.textContent="\u2715",p.addEventListener("click",m=>{m.stopPropagation(),this._deselectRow(c)}),h.appendChild(p)}l.appendChild(h),l.addEventListener("click",()=>this._inspectRow(c,!1)),l.addEventListener("dblclick",()=>this._inspectRow(c,!0)),c.row.bbox&&(l.addEventListener("mouseenter",()=>{this._app.animateSelection&&this._app.animateSelection(c.row.bbox,{repeats:0})}),l.addEventListener("mouseleave",()=>{this._app.stopSelectionAnimation&&this._app.stopSelectionAnimation()})),o.appendChild(l)}t.appendChild(o),this._tableWrap.appendChild(t),ws(t)}};var dM="options-dialog",fM=[{label:"System default",value:""},{label:"Sans-serif",value:"sans-serif"},{label:"Serif",value:"serif"},{label:"Monospace",value:"monospace"},{label:"Helvetica / Arial",value:"Helvetica, Arial, sans-serif"},{label:"Georgia",value:"Georgia, 'Times New Roman', serif"},{label:"Courier",value:"'Courier New', Courier, monospace"}],kW=100,jh=70,Hh=200;function jl(n){let e=n===""||n===null?NaN:Math.round(Number(n));return Number.isFinite(e)?Math.min(Hh,Math.max(jh,e)):kW}function hM(n){let{overlay:e,close:t,okBtn:i,showError:r}=Xo("Arrow keys scroll step",`
+ min="${Ul}" max="${$l}" step="1" + value="${Gl(n.arrowStep)}">
How far one arrow-key press pans the layout. - Default ${Kb}.
`,"Apply",uM),s=e.querySelector(".opt-step");s.focus(),s.select();function o(){let a=s.value.trim(),c=Number(a);if(a===""||!Number.isFinite(c)){r("Step must be a number.");return}if(cUl){r(`Step must be between ${zl} and ${Ul} px.`);return}n.setArrowStep(c),t()}return i.addEventListener("click",o),s.addEventListener("keydown",a=>{a.key==="Enter"&&(a.preventDefault(),o())}),{close:t}}function dM(n){let e=n.fontFamily||"",t=lM.some(p=>p.value===e),i=lM.map(p=>``).join("")+(t?"":``),{overlay:r,close:s,okBtn:o,showError:a}=Xo("Application font",` + Default ${Qb}.
`,"Apply",dM),s=e.querySelector(".opt-step");s.focus(),s.select();function o(){let a=s.value.trim(),c=Number(a);if(a===""||!Number.isFinite(c)){r("Step must be a number.");return}if(c$l){r(`Step must be between ${Ul} and ${$l} px.`);return}n.setArrowStep(c),t()}return i.addEventListener("click",o),s.addEventListener("keydown",a=>{a.key==="Enter"&&(a.preventDefault(),o())}),{close:t}}function pM(n){let e=n.fontFamily||"",t=fM.some(p=>p.value===e),i=fM.map(p=>``).join("")+(t?"":``),{overlay:r,close:s,okBtn:o,showError:a}=Xo("Application font",`
@@ -6442,19 +6442,19 @@ Slack: [${t.lower.toFixed(h)}, ${t.upper.toFixed(h)}) ${d}`}this._tooltip.style. + value="${t?"":av(e)}">
+ min="${jh}" max="${Hh}" step="5" + value="${jl(n.fontScale)}">
The quick brown fox jumps over the lazy dog 0123456789
Applies to the panels, menus and console. Text drawn into the layout is rendered on the server and is not - affected.
`,"Apply",uM),c=r.querySelector(".opt-family"),l=r.querySelector(".opt-custom"),u=r.querySelector(".opt-scale"),f=r.querySelector(".opt-preview");function d(){f.style.fontFamily=l.value.trim()||c.value,f.style.fontSize=`calc(13px * ${Wl(u.value)/100})`}for(let p of[c,l,u])p.addEventListener("input",d);d();function h(){let p=u.value.trim(),m=Number(p);if(p===""||!Number.isFinite(m)){a("Size must be a number.");return}if(mjh){a(`Size must be between ${Wh} and ${jh} %.`);return}n.setAppFont({family:l.value.trim()||c.value,scale:m}),s()}o.addEventListener("click",h);for(let p of[l,u])p.addEventListener("keydown",m=>{m.key==="Enter"&&(m.preventDefault(),h())});return{close:s}}function ov(n){return String(n).replace(/&/g,"&").replace(/"/g,""").replace(//g,">")}var LW='',MW='';function Qo(n){let e=document.createElement("span");return e.className="vis-name",n!=null&&(e.textContent=n),e}function fr(){let n=document.createElement("span");return n.className="vis-sel-cb vis-sel-spacer",n}function hM(){let n=document.createElement("div");n.className="display-controls-header",n.appendChild(Qo(""));for(let[e,t]of[[LW,"Visible"],[MW,"Selectable"]]){let i=document.createElement("span");i.className="vis-header-icon",i.title=t,i.innerHTML=e,n.appendChild(i)}return n}var Hh=class{constructor(e,t,i){this.visibility=e,this.selectability=t,this.onChange=i;let r=()=>{this._syncAll(),this.onChange()};this.model=new En(r),this.selModel=new En(r)}add(e){return this.model.addFromSpec(this._enrichSpec(e,"")),this.selModel.addFromSpec(this._enrichSelSpec(e,"",!1)),this}render(e){for(let t of this.model.roots)e.appendChild(this._dom(t));this._syncAll()}_nodeId(e,t){let i=e.key||e.label;return t?t+"/"+i:i}_enrichSpec(e,t){let i=this._nodeId(e,t),r={id:i,data:e};return e.children?r.children=e.children.map(s=>this._enrichSpec(s,i)):e.key&&(r.checked=!!this.visibility[e.key]),e.disabled!=null&&(r.disabled=e.disabled),r}_enrichSelSpec(e,t,i){let r=e.addSelectable===!0?!0:e.addSelectable===!1?!1:i,s=this._nodeId(e,t),o={id:s,data:e,hasCheckbox:!1};if(e.children){o.children=e.children.map(c=>this._enrichSelSpec(c,s,r));let a=c=>c.some(l=>l.hasCheckbox||l.children&&a(l.children));o.hasCheckbox=a(o.children),o.hasCheckbox&&(o.checked=!0)}else if(e.key){let a=e.selectable===!0||e.selectable!==!1&&i;o.hasCheckbox=a,a&&(o.checked=this.selectability[e.key]!==!1)}return o}_syncAll(){this.model.forEach(e=>{e.cb&&(e.cb.checked=e.checked,e.cb.indeterminate=e.indeterminate);let t=e.data;t.key&&(this.visibility[t.key]=e.checked),t.visKey&&(this.visibility[t.visKey]=e.checked||e.indeterminate)}),this.selModel.forEach(e=>{if(!e.hasCheckbox)return;let t=e.data;if(t.key&&(this.selectability[t.key]=e.checked),!e.selCb)return;e.selCb.checked=e.checked,e.selCb.indeterminate=e.indeterminate;let i=this.model.get(e.id),r=i&&!i.checked&&!i.indeterminate;e.selCb.disabled=r,e.selLabel&&e.selLabel.classList.toggle("vis-sel-disabled",r)}),this.model.forEach(e=>{let t=e.data;if(t.disabledBy&&e.el){let i=!this.visibility[t.disabledBy];e.el.classList.toggle("disabled",i)}})}_buildSelCheckbox(e){let t=this.selModel.get(e.id);if(!t||!t.hasCheckbox)return null;let i=document.createElement("input");return i.type="checkbox",i.className="vis-sel-cb",i.title="Selectable",i.addEventListener("change",()=>{this.selModel.check(t.id,i.checked)}),t.selCb=i,i}_dom(e){let t=e.data,i=document.createElement("input");i.type="checkbox",i.className="vis-cb",i.title="Visible",e.cb=i,i.addEventListener("change",()=>this.model.check(e.id,i.checked));let r=this._buildSelCheckbox(e),s=f=>{if(f.appendChild(i),r){f.appendChild(r);let d=this.selModel.get(e.id);d&&(d.selLabel=f)}else f.appendChild(fr())};if(!e.children.length){let f=document.createElement("div");f.className="vis-leaf";let d=document.createElement("span");return d.className="vis-arrow",d.style.visibility="hidden",d.textContent="\u25B6",f.appendChild(d),f.appendChild(Qo(t.label)),s(f),e.el=f,f}let o=document.createElement("div");o.className="vis-group";let{header:a,arrow:c,name:l}=vs();l.textContent=t.label,s(a),o.appendChild(a);let u=document.createElement("div");u.className="vis-group-children",t.disabled&&u.classList.add("disabled");for(let f of e.children)u.appendChild(this._dom(f));return o.appendChild(u),xs(a,c,u,!0),o}};function jl(n,e,t,i){let r=new Set,s=Math.max(0,n-e),o=Math.min(i-1,n+t);for(let a=s;a<=o;a++)r.add(a);return r}function AW(n){let e={};for(let[t,i]of Object.entries(n||{}))i!==1&&(e[t]=i);return e}function Yh(n,e){return(n||[]).some(t=>t.every(i=>!!e[i]))}function kW(n,e){return n.map(t=>{let i=!e.has(t.path);return{id:t.path,parentId:t.parent!=null?t.parent:null,hasCheckbox:t.parent!=null,checked:i,data:{path:t.path,name:t.name,master:t.master,depth:t.depth}}})}var RW=3,pM=[[70,130,210],[200,50,50],[50,180,80],[200,160,40],[160,60,200],[40,190,190],[220,120,50],[180,70,150]];function IW(n){return!n.forceComposite||ue(n)?0:n.groupLayers||E3}function mM(n,e,t,i,r,s){if(!n.displayControlsEl)return;n.displayControlsEl.innerHTML="",n.displayControlsEl.appendChild(hM());for(let S of n.allLayers||[])S.remove();n.allLayers=[],n.baseSlot=null,n.topSlot=null;let o=new Set;function a(){for(let S of o)S.refresh();o.clear()}function c(){n.baseSlot&&o.add(n.baseSlot)}function l(S){return{layer:S,opacity:1,visible:!1}}function u(S,L){m3(S,L)&&c()}function f(S,L,F){let k={layer:S,opacity:1,visible:!!F};return L&&(n[L]=k),k}let d=[f("_instances",null,!0),f("_pins","pinsLayer",e.pins),f("_modules","modulesLayer",e.module_view)],h=[];n.overlayLayers=(i&&i.overlays||[]).map(S=>({def:S,layer:f(S.name,null,Yh(S.shown_by,e)),under:S.z_indexF.def.z_index-k.def.z_index))(L?d:h).push(S);let p=[],m=[],g=null,v=new Set,y=new Set;try{let S=window.sessionStorage.getItem("or_hidden_layers");S&&(v=new Set(JSON.parse(S)))}catch{}try{let S=window.sessionStorage.getItem("or_nonselectable_layers");S&&(y=new Set(JSON.parse(S)))}catch{}try{let S=window.sessionStorage.getItem("or_layer_patterns");S&&Object.assign(n.layerPatterns,JSON.parse(S))}catch{}function b(){try{window.sessionStorage.setItem("or_layer_patterns",JSON.stringify(AW(n.layerPatterns)))}catch{}}function w(S,L){L===1?delete n.layerPatterns[S]:n.layerPatterns[S]=L,b(),c(),a()}let E=[{label:"Solid",value:1},{label:"Diagonal",value:2},{label:"Cross",value:3},{label:"Dots",value:4},{label:"None (no fill)",value:0}],x=0;function T(S,L="layers",F=void 0){let k=[],U=S.type==="category"?F:S.path,R=S.flipped===!0,B=S.instances||[],$=B.filter(ke=>ke.type!=="category"),Z=B.filter(ke=>ke.type==="category"),Q=S.layers||[],de=x;x+=Q.length;function _e(ke,Qe){let P=ke.map((A,O)=>O);Qe&&P.reverse(),P.forEach(A=>{let O=ke[A],G=L+"/"+(O.name||A);k.push(T(O,G,U))})}function Xe(){(R?Q.map((Qe,P)=>P).reverse():Q.map((Qe,P)=>P)).forEach(Qe=>{let P=Q[Qe],A=P.name||P,O=de+Qe,G=l(A),K=`${L}/${A}`,J=!v.has(K);J&&(u(G,!0),n.visibleLayers.add(K),n.visibleLayerNames.add(A)),p.push(G),m.push(K),k.push({id:K,data:{name:A,layer:G,color:P.color,colorIndex:O,nodeId:K,ownerChipletPath:U},checked:J})})}_e($,!1),R&&Xe(),_e(Z,R),R||Xe();let Oe={name:S.name,isInstance:!0};return S.type==="category"&&(S.name==="Implant"||S.name==="Other")&&(Oe.startCollapsed=!0),S.type!=="category"&&(Oe.chipletPath=S.path),{id:L,data:Oe,children:k}}let I;i.layer_hierarchy?I=T(i.layer_hierarchy,"layers_parent"):I={id:"layers_parent",children:i.layers.map((S,L)=>{let F=l(S),k=`layers_parent/${S}`,U=!v.has(k);return U&&(u(F,!0),n.visibleLayers.add(k),n.visibleLayerNames.add(S)),p.push(F),m.push(k),{id:k,data:{name:S,layer:F,colorIndex:L,nodeId:k},checked:U}})};function N(S,L,F){let k=n.view.addTileSlot(S,{order:L,source:S3({wm:n.websocketManager,ctx:n.tileCtx,getItems:()=>F,dpr:Yo,tileSize:tn,isDoubleBuffer:()=>n.doubleBuffer,groupLayers:()=>IW(n)})});return k.items=F,k}n.baseSlot=N("base",at.base,[...d,...p]),n.topSlot=N("top",at.top,h),n.allLayers=[n.baseSlot,n.topSlot];function D(S){if(!S.children||S.children.length===0){let L=S.data&&S.data.name,F=L?!y.has(L):!0;return F&&L&&n.selectableLayers.add(L),{id:S.id,data:{name:L},checked:F}}return{id:S.id,data:{name:S.data&&S.data.name},children:S.children.map(D)}}let H=D(I),W=new En(()=>{n.visibleLayerNames.clear();let S=[],L={},F=!1,k=!1,U=g&&n.visibleChiplets instanceof Set;if(W.forEach(B=>{if(B.cb&&(B.cb.checked=B.checked,B.cb.indeterminate=B.indeterminate),B.data&&B.data.layer){let $=B.data.nodeId||B.data.name;S.push($),u(B.data.layer,B.checked),B.checked?(n.visibleLayers.add($),n.visibleLayerNames.add(B.data.name)):n.visibleLayers.delete($)}if(U&&B.data&&B.data.chipletPath){let $=B.data.chipletPath,Z=g.get($);if(Z){let Q=B.checked||B.indeterminate,de={checked:B.checked,indeterminate:B.indeterminate};(Z.checked!==B.checked||Z.indeterminate!==B.indeterminate)&&(L[$]=de,F=!0),n.visibleChiplets.has($)!==Q&&(k=!0)}}}),n.baseSlot&&o.has(n.baseSlot))for(let{def:B,under:$}of n.overlayLayers)Yh(B.layers_by,e)&&o.add($?n.baseSlot:n.topSlot);a(),X();let R=S.filter(B=>!n.visibleLayers.has(B));try{window.sessionStorage.setItem("or_hidden_layers",JSON.stringify(R))}catch{}n.syncDisplayState(),k?g.mirrorStates(L):F&&(g.mirrorStatesQuiet(L),g.forEach(B=>{B.cb&&(B.cb.checked=B.checked,B.cb.indeterminate=B.indeterminate)}))});n.layerModel=W,W.addFromSpec(I);let V=new En(()=>{n.selectableLayers.clear(),V.forEach(L=>{L.checked&&L.data&&L.data.name&&n.selectableLayers.add(L.data.name)}),X();let S=i.layers.filter(L=>!n.selectableLayers.has(L));try{window.sessionStorage.setItem("or_nonselectable_layers",JSON.stringify(S))}catch{}n.syncDisplayState()});V.addFromSpec(H);function X(){V.forEach(S=>{if(!S.selCb)return;S.selCb.checked=S.checked,S.selCb.indeterminate=S.indeterminate;let L=W.get(S.id),F=L&&!L.checked&&!L.indeterminate;S.selCb.disabled=F})}let Y=document.createElement("div");Y.className="context-menu",Y.style.display="none",document.body.appendChild(Y);function ie(S){let L={};m.forEach((F,k)=>{F&&(L[F]=S.has(k))}),W.checkSet(L)}function oe(){Y.style.display="none"}function zt(S,L){let F=document.createElement("div");F.className="context-menu-item",F.textContent=S,F.addEventListener("click",()=>{L(),oe()}),Y.appendChild(F)}let je=p.length,sn=[{label:"Show only this layer",fn:S=>jl(S,0,0,je)},{label:"Show layer range \u2195",fn:S=>jl(S,1,1,je)},{label:"Show layer range \u2195\u2195",fn:S=>jl(S,2,2,je)},{label:"Show layer range \u2193",fn:S=>jl(S,1,0,je)},{label:"Show layer range \u2191",fn:S=>jl(S,0,1,je)}];document.addEventListener("click",S=>{Y.contains(S.target)||oe()}),document.addEventListener("keydown",S=>{S.key==="Escape"&&oe()});let si=!ue(n),oi=null;function on(){oi&&(oi.classList.remove("vis-row-selected"),oi=null)}si&&I3(n,on);function Ri(S,L,F){let k=St(n);oi=S,S.classList.add("vis-row-selected");let U={type:"select_layer",layer:L,use_dbu:n.showDbu};F&&(U.chiplet=F),n.websocketManager.request(U).then(R=>{Dt(n,k)&&(n.updateInspector&&n.updateInspector(R),n.focusComponent&&n.focusComponent("Inspector"),n.refreshOverlay&&n.refreshOverlay())}).catch(R=>{console.error("select_layer failed:",R),Dt(n,k)&&on()})}function _t(S,L=!1){let F=V.get(S.id);if(!S.children||S.children.length===0){let k=document.createElement("div");k.className=si?"vis-leaf vis-leaf-selectable":"vis-leaf";let U=document.createElement("span");U.className="vis-arrow",U.style.visibility="hidden",U.textContent="\u25B6",k.appendChild(U);let R=S.data.colorIndex,B=S.data.name,$=Qo(),Z=document.createElement("span");Z.className="layer-color";let Q=S.data.color||i.layer_colors&&i.layer_colors[R]||pM[R%pM.length];Z.style.backgroundColor=`rgb(${Q[0]},${Q[1]},${Q[2]})`,$.appendChild(Z),$.appendChild(document.createTextNode(B)),k.appendChild($),si&&$.addEventListener("click",()=>{Ri(k,B,S.data.ownerChipletPath)});let de=document.createElement("input");if(de.type="checkbox",de.className="vis-cb",de.title="Visible",de.checked=S.checked,S.cb=de,de.addEventListener("change",()=>{W.check(S.id,de.checked)}),k.appendChild(de),F){let _e=document.createElement("input");_e.type="checkbox",_e.className="vis-sel-cb",_e.title="Selectable",_e.checked=F.checked,F.selCb=_e,_e.addEventListener("change",()=>{V.check(S.id,_e.checked)}),k.appendChild(_e)}else k.appendChild(fr());return k.addEventListener("contextmenu",_e=>{_e.preventDefault(),_e.stopPropagation(),Y.innerHTML="";for(let ke of sn)zt(ke.label,()=>ie(ke.fn(R)));let Xe=document.createElement("div");Xe.className="context-menu-separator",Xe.style.borderTop="1px solid #555",Xe.style.margin="4px 0",Y.appendChild(Xe);let Oe=n.layerPatterns[B]??1;for(let ke of E){let Qe=Oe===ke.value?"\u25CF ":" ";zt(Qe+"Fill: "+ke.label,()=>w(B,ke.value))}Y.style.left=_e.clientX+"px",Y.style.top=_e.clientY+"px",Y.style.display="block"}),k}else{let k=document.createElement("div");k.className="vis-group";let{header:U,arrow:R,name:B}=vs();B.textContent=L?"Layers":S.data.name||"Group";let $=document.createElement("input");if($.type="checkbox",$.className="vis-cb",$.title="Visible",$.checked=S.checked,$.indeterminate=S.indeterminate,S.cb=$,$.addEventListener("change",()=>{W.check(S.id,$.checked)}),U.appendChild($),F){let Q=document.createElement("input");Q.type="checkbox",Q.className="vis-sel-cb",Q.title="Selectable",Q.checked=F.checked,Q.indeterminate=F.indeterminate,F.selCb=Q,Q.addEventListener("change",()=>{V.check(S.id,Q.checked)}),U.appendChild(Q)}else U.appendChild(fr());k.appendChild(U);let Z=document.createElement("div");Z.className="vis-group-children";for(let Q of S.children)Z.appendChild(_t(Q,!1));return k.appendChild(Z),xs(U,R,Z,!!(S.data&&S.data.startCollapsed)),k}}let Sn=W.roots[0]||W.get("layers_parent"),Pn=_t(Sn,!0);n.displayControlsEl.appendChild(Pn),X();let Cn=i&&Array.isArray(i.chiplets)?i.chiplets:[];if(Cn.length>1){let Z=function(P,A){let O=$.get(P);O&&(W.cascadeQuiet(O.id,A),W.onChange())},Qe=function(P){let A=P.data;if(P!==Oe){let O=document.createElement("div");O.className="vis-leaf",O.style.paddingLeft=8*(A.depth-1)+"px",O.title=A.path+(A.master?` (${A.master})`:""),O.appendChild(Qo(A.name));let G=document.createElement("input");G.type="checkbox",G.className="vis-cb",G.checked=P.checked,G.indeterminate=P.indeterminate,P.cb=G,G.addEventListener("change",()=>{g.check(P.id,G.checked),Z(A.path,G.checked)}),O.appendChild(G),O.appendChild(fr()),ke.appendChild(O)}P.children&&P.children.forEach(Qe)},S=i&&i.block_name||"",L=S!=="",F={};if(L)try{let P=Be("or_hidden_chiplets");if(P){let A=JSON.parse(decodeURIComponent(P));A&&typeof A=="object"&&!Array.isArray(A)&&(F=A)}}catch{}let k=new Set(Array.isArray(F[S])?F[S]:[]),U=kW(Cn,k),R=U.findIndex(P=>P.parentId===null),B=R>=0?U[R].id:null;if(R>=0&&(U[R].hasCheckbox=!0),n.visibleChiplets=new Set(Cn.filter(P=>!k.has(P.path)).map(P=>P.path)),g=new En(()=>{let P=new Set;if(g.forEach(A=>{A.cb&&(A.cb.checked=A.checked,A.cb.indeterminate=A.indeterminate),A.data&&A.data.path&&(A.checked||A.indeterminate)&&P.add(A.data.path)}),n.visibleChiplets=P,L){let A=Cn.filter(G=>!P.has(G.path)).map(G=>G.path),O={};try{let G=Be("or_hidden_chiplets");if(G){let K=JSON.parse(decodeURIComponent(G));K&&typeof K=="object"&&!Array.isArray(K)&&(O=K)}}catch{}A.length===0?delete O[S]:O[S]=A,Ue("or_hidden_chiplets",encodeURIComponent(JSON.stringify(O)))}r()}),g.buildFromNodes(U),typeof console<"u"&&console.warn){let P=new Set;W.forEach(O=>{O.data&&O.data.chipletPath&&P.add(O.data.chipletPath)});let A=new Set;g.forEach(O=>{O.data&&O.data.path&&A.add(O.data.path)});for(let O of A)P.has(O)||console.warn(`[display-controls] chiplet "${O}" missing from layer_hierarchy \u2014 Layers/Chiplets sync may drift`);for(let O of P)A.has(O)||console.warn(`[display-controls] layer hierarchy node "${O}" has no matching chiplet \u2014 Layers/Chiplets sync may drift`)}let $=new Map;W.forEach(P=>{P.data&&P.data.chipletPath&&$.set(P.data.chipletPath,P)});{let P={};if(W.forEach(A=>{if(!A.data||!A.data.chipletPath)return;let O=A.data.chipletPath;k.has(O)||g.get(O)&&(P[O]={checked:A.checked,indeterminate:A.indeterminate})}),Object.keys(P).length>0){g.mirrorStatesQuiet(P);let A=new Set;g.forEach(O=>{O.data&&O.data.path&&(O.checked||O.indeterminate)&&A.add(O.data.path)}),n.visibleChiplets=A}}let Q=document.createElement("div");Q.className="vis-group";let{header:de,arrow:_e,name:Xe}=vs();Xe.textContent="Chiplets";let Oe=B!=null?g.get(B):null;if(Oe){let P=document.createElement("input");P.type="checkbox",P.className="vis-cb",P.checked=Oe.checked,P.indeterminate=Oe.indeterminate,Oe.cb=P,P.addEventListener("change",A=>{A.stopPropagation(),g.check(B,P.checked),Oe.data&&Oe.data.path&&Z(Oe.data.path,P.checked)}),de.appendChild(P)}de.appendChild(fr()),Q.appendChild(de);let ke=document.createElement("div");ke.className="vis-group-children",g.roots.forEach(Qe),Q.appendChild(ke),xs(de,_e,ke,!1),n.displayControlsEl.appendChild(Q)}else n.visibleChiplets=null;let gr=!!e.debug_renderers,$e=new Hh(e,t,()=>{r(),!!e.debug_renderers!==gr&&(gr=!!e.debug_renderers,n.refreshRendererControls&&n.refreshRendererControls())});$e.add({label:"Nets",addSelectable:!0,children:[{key:"net_signal",label:"Signal"},{key:"net_power",label:"Power"},{key:"net_ground",label:"Ground"},{key:"net_clock",label:"Clock"},{key:"net_reset",label:"Reset"},{key:"net_tieoff",label:"Tie off"},{key:"net_scan",label:"Scan"},{key:"net_analog",label:"Analog"}]}),$e.add({label:"Instances",addSelectable:!0,children:[{label:"Std Cells",visKey:"stdcells",disabled:!n.hasLiberty,children:[{label:"Bufs/Invs",children:[{key:"std_bufinv_timing",label:"Timing opt."},{key:"std_bufinv",label:"Netlist"}]},{key:"std_combinational",label:"Combinational"},{key:"std_sequential",label:"Sequential"},{label:"Clock tree",children:[{key:"std_clock_bufinv",label:"Buffer/Inverter"},{key:"std_clock_gate",label:"Clock gate"}]},{key:"std_level_shift",label:"Level shifter"}]},{key:"macros",label:"Macros"},{label:"Pads",children:[{key:"pad_input",label:"Input"},{key:"pad_output",label:"Output"},{key:"pad_inout",label:"Inout"},{key:"pad_power",label:"Power"},{key:"pad_spacer",label:"Spacer"},{key:"pad_areaio",label:"Area IO"},{key:"pad_other",label:"Other"}]},{label:"Physical",children:[{key:"phys_fill",label:"Fill"},{key:"phys_endcap",label:"Endcap"},{key:"phys_welltap",label:"Welltap"},{key:"phys_tie",label:"Tie Hi/Lo"},{key:"phys_antenna",label:"Antenna"},{key:"phys_cover",label:"Cover"},{key:"phys_bump",label:"Bump"},{key:"phys_other",label:"Other"}]}]}),$e.add({label:"Blockages",addSelectable:!0,children:[{key:"placement_blockages",label:"Placement"},{key:"routing_obstructions",label:"Routing"}]}),i.sites&&i.sites.length>0&&$e.add({label:"Rows",visKey:"rows",addSelectable:!0,children:i.sites.map(S=>({key:"site_"+S,label:S}))}),$e.add({label:"Tracks",children:[{key:"tracks_pref",label:"Pref"},{key:"tracks_non_pref",label:"Non Pref"}]}),$e.add({label:"Shapes",children:[{label:"Routing",visKey:"routing",children:[{key:"routing_segments",label:"Segments"},{key:"routing_vias",label:"Vias"}]},{label:"Special Routing",visKey:"special_nets",children:[{key:"srouting_segments",label:"Segments"},{key:"srouting_vias",label:"Vias"}]},{key:"pins",label:"Pins",selectable:!0},{key:"pin_names",label:"Pin Names",disabledBy:"pins"},{key:"fills",label:"Fills"}]}),$e.add({label:"Misc",children:[{label:"Instances",children:[{key:"inst_names",label:"Names"},{key:"inst_pins",label:"Pins",selectable:!0},{key:"inst_pin_names",label:"Pin Names",disabledBy:"inst_pins"},{key:"blockages",label:"Blockages"}]},{key:"detailed",label:"Detailed view"},{key:"rulers",label:"Rulers"},{key:"labels",label:"Labels"},{key:"scale_bar",label:"Scale bar"},{key:"access_points",label:"Access Points"},{key:"regions",label:"Regions"},{key:"mfg_grid",label:"Manufacturing grid"},{key:"gcell_grid",label:"GCell grid"},{key:"flywires_only",label:"Flywires only"},{key:"focused_nets_guides",label:"Focused nets guides"},{key:"highlight_selected",label:"Highlight selected"}]}),$e.add({key:"module_view",label:"Module view"}),$e.add({label:"Debug Graphics",children:[{key:"debug_renderers",label:"Renderers"},{key:"debug_live",label:"Live (don't require pause)",disabledBy:"debug_renderers"},{key:"debug",label:"Tiles"}]}),$e.render(n.displayControlsEl);let Ge=document.createElement("div");Ge.className="renderer-controls",n.displayControlsEl.appendChild(Ge);function _r(S){return Promise.all(S.map(({path:L,value:F})=>n.websocketManager.request({type:"set_renderer_control",path:L,value:F}))).catch(()=>{})}function ai(S){Ge.innerHTML="";let L=new Map;for(let F of S||[]){let k=F.group||"";L.has(k)||L.set(k,[]),L.get(k).push(F)}for(let[F,k]of L){let U=Ge;if(F){let R=document.createElement("div");R.className="vis-group";let{header:B,arrow:$,name:Z}=vs();Z.textContent=F;let Q=document.createElement("input");Q.type="checkbox",Q.className="vis-cb",Q.title="Visible";let de=k.filter(Xe=>Xe.visible).length;Q.checked=de===k.length,Q.indeterminate=de>0&&de{let Xe=Q.checked;_r(k.filter(Oe=>!!Oe.visible!==Xe).map(Oe=>({path:Oe.path,value:Xe})))}),B.appendChild(Q),B.appendChild(fr()),R.appendChild(B);let _e=document.createElement("div");_e.className="vis-group-children",R.appendChild(_e),xs(B,$,_e,!1),Ge.appendChild(R),U=_e}for(let R of k){let B=document.createElement("div");B.className="vis-leaf";let $=document.createElement("span");$.className="vis-arrow",$.style.visibility="hidden",$.textContent="\u25B6",B.appendChild($),B.appendChild(Qo(R.name));let Z=document.createElement("input");Z.type="checkbox",Z.className="vis-cb",Z.title="Visible",Z.checked=!!R.visible,Z.addEventListener("change",()=>_r([{path:R.path,value:Z.checked}])),B.appendChild(Z),B.appendChild(fr()),U.appendChild(B)}}}n.refreshRendererControls=function(){return!n.websocketManager||ue(n)||!e.debug_renderers?(Ge.innerHTML="",Promise.resolve()):n.websocketManager.request({type:"renderer_controls"}).then(S=>ai(S.controls)).catch(()=>{})},n.refreshRendererControls();let Ut=document.createElement("div");Ut.className="bg-color-row";let ci=document.createElement("span");ci.textContent="Background";let Ve=document.createElement("input");Ve.type="color",Ve.className="bg-color-input",Ve.title="Layout background color";let li=Be("or_bg_color");Ve.value=Zo(li)?li:ev(),Ve.addEventListener("input",()=>{document.documentElement.style.setProperty("--bg-map",Ve.value)}),Ve.addEventListener("change",()=>{Q3(Ve.value,n)});let an=document.createElement("button");an.className="bg-color-reset",an.textContent="Reset",an.title="Reset background to the theme default",an.addEventListener("click",()=>{J3(n),Ve.value=ev()}),Ut.appendChild(ci),Ut.appendChild(Ve),Ut.appendChild(an),!n.heatMapLayer&&s&&(n.heatMapLayer=s());let Ii=document.createElement("div");Ii.className="vis-group heatmap-controls",n.displayControlsEl.appendChild(Ii);let{header:Bi,arrow:Oi,name:Rs}=vs("vis-group-header heatmap-header");Rs.textContent="Heat Maps",Ii.appendChild(Bi);let Tn=document.createElement("div");Tn.className="vis-group-children heatmap-group-children",Ii.appendChild(Tn),xs(Bi,Oi,Tn,!0),n.displayControlsEl.appendChild(Ut);function $t(S,L,F,k){let U=document.createElement("label");U.className="heatmap-setting";let R=document.createElement("input");R.type="checkbox",R.checked=F,R.addEventListener("change",()=>k(R.checked)),U.appendChild(R),U.appendChild(document.createTextNode(L)),S.appendChild(U)}function Me(S,L,F,k,U){let R=document.createElement("label");R.className="heatmap-setting";let B=document.createElement("span");B.textContent=L;let $=document.createElement("input");$.type="number",$.value=String(F),$.step=String(k||1),$.addEventListener("change",()=>U(parseFloat($.value))),R.appendChild(B),R.appendChild($),S.appendChild(R)}function yr(S,L,F,k,U){let R=document.createElement("label");R.className="heatmap-setting";let B=document.createElement("span");B.textContent=L;let $=document.createElement("select");for(let Z of k){let Q=document.createElement("option");Q.value=Z,Q.textContent=Z,Z===F&&(Q.selected=!0),$.appendChild(Q)}$.addEventListener("change",()=>U($.value)),R.appendChild(B),R.appendChild($),S.appendChild(R)}function Ae(S){n.websocketManager.request(S).then(L=>{n.updateHeatMaps&&n.updateHeatMaps(L)}).catch(L=>console.error("Heat map update failed",L))}function M(S){if(!n.heatMapLegendEl)return;let L=n.heatMapLegendEl;if(L.innerHTML="",!S||!S.show_legend||!S.legend||S.legend.length===0){L.classList.add("hidden");return}let F=document.createElement("div");F.className="heatmap-map-legend-title",F.textContent=S.title,L.appendChild(F);let k=document.createElement("div");k.className="heatmap-map-legend-units",k.textContent=S.units||"",L.appendChild(k);let U=document.createElement("div");U.className="heatmap-map-legend-list";for(let R of S.legend){let B=document.createElement("div");B.className="heatmap-legend-row";let $=document.createElement("span");$.className="heatmap-legend-swatch",$.style.backgroundColor=`rgba(${R.color[0]}, ${R.color[1]}, ${R.color[2]}, ${R.color[3]/255})`;let Z=document.createElement("span");Z.textContent=R.value,B.appendChild($),B.appendChild(Z),U.appendChild(B)}L.appendChild(U),L.classList.remove("hidden")}n.renderHeatMapControls=S=>{Tn.innerHTML="";let L=document.createElement("div");L.className="heatmap-list",Tn.appendChild(L);let F=document.createElement("label");F.className="heatmap-setting";let k=document.createElement("input");k.type="radio",k.name="active-heatmap",k.checked=!S.active,k.addEventListener("change",()=>{Ae({type:"set_active_heatmap",name:""})}),F.appendChild(k),F.appendChild(document.createTextNode("Off")),L.appendChild(F);for(let $ of S.heatmaps||[]){let Z=document.createElement("label");Z.className="heatmap-setting";let Q=document.createElement("input");Q.type="radio",Q.name="active-heatmap",Q.checked=$.name===S.active,Q.addEventListener("change",()=>{Ae({type:"set_active_heatmap",name:$.name})}),Z.appendChild(Q),Z.appendChild(document.createTextNode($.title)),L.appendChild(Z)}let U=(S.heatmaps||[]).find($=>$.name===S.active);if(M(U),!U)return;let R=document.createElement("div");R.className="heatmap-settings",Tn.appendChild(R),Me(R,"Display min",U.display_min,U.display_range_increment,$=>{Ae({type:"set_heatmap",name:U.name,option:"DisplayMin",value:$})}),Me(R,"Display max",U.display_max,U.display_range_increment,$=>{Ae({type:"set_heatmap",name:U.name,option:"DisplayMax",value:$})}),$t(R,"Show below min",U.draw_below_min,$=>{Ae({type:"set_heatmap",name:U.name,option:"ShowMin",value:$})}),$t(R,"Show above max",U.draw_above_max,$=>{Ae({type:"set_heatmap",name:U.name,option:"ShowMax",value:$})}),$t(R,"Log scale",U.log_scale,$=>{Ae({type:"set_heatmap",name:U.name,option:"LogScale",value:$})}),$t(R,"Reverse log",U.reverse_log,$=>{Ae({type:"set_heatmap",name:U.name,option:"ReverseLog",value:$})}),U.can_adjust_grid&&(Me(R,"Grid X",U.grid_x,.1,$=>{Ae({type:"set_heatmap",name:U.name,option:"GridX",value:$})}),Me(R,"Grid Y",U.grid_y,.1,$=>{Ae({type:"set_heatmap",name:U.name,option:"GridY",value:$})})),Me(R,"Alpha",U.alpha,1,$=>{Ae({type:"set_heatmap",name:U.name,option:"Alpha",value:$})}),$t(R,"Legend",U.show_legend,$=>{Ae({type:"set_heatmap",name:U.name,option:"ShowLegend",value:$})}),U.supports_numbers&&$t(R,"Show numbers",U.show_numbers,$=>{Ae({type:"set_heatmap",name:U.name,option:"ShowNumbers",value:$})});for(let $ of U.options||[])$.type==="bool"?$t(R,$.label,$.value,Z=>{Ae({type:"set_heatmap",name:U.name,option:$.name,value:Z})}):$.type==="choice"&&yr(R,$.label,$.value,$.choices||[],Z=>{Ae({type:"set_heatmap",name:U.name,option:$.name,value:Z})});U.selection_filter_label&&$t(R,U.selection_filter_label,U.use_selected_only,$=>{Ae({type:"set_heatmap",name:U.name,option:"use_selected_only",value:$})});let B=document.createElement("button");B.className="or-btn or-btn-sm heatmap-rebuild",B.textContent="Rebuild data",B.addEventListener("click",()=>{Ae({type:"set_heatmap",name:U.name,option:"rebuild",value:1})}),R.appendChild(B)}}var gM="search-nav-dialog",BW=[{label:"Instance",value:"inst"},{label:"Net",value:"net"},{label:"Port",value:"port"}];function qh(n){if(!n.designScale)return;let e=BW.map(u=>``).join(""),{overlay:t,close:i,okBtn:r,showError:s}=Xo("Find Object",` + affected.`,"Apply",dM),c=r.querySelector(".opt-family"),l=r.querySelector(".opt-custom"),u=r.querySelector(".opt-scale"),f=r.querySelector(".opt-preview");function d(){f.style.fontFamily=l.value.trim()||c.value,f.style.fontSize=`calc(13px * ${jl(u.value)/100})`}for(let p of[c,l,u])p.addEventListener("input",d);d();function h(){let p=u.value.trim(),m=Number(p);if(p===""||!Number.isFinite(m)){a("Size must be a number.");return}if(mHh){a(`Size must be between ${jh} and ${Hh} %.`);return}n.setAppFont({family:l.value.trim()||c.value,scale:m}),s()}o.addEventListener("click",h);for(let p of[l,u])p.addEventListener("keydown",m=>{m.key==="Enter"&&(m.preventDefault(),h())});return{close:s}}function av(n){return String(n).replace(/&/g,"&").replace(/"/g,""").replace(//g,">")}var RW='',IW='';function Qo(n){let e=document.createElement("span");return e.className="vis-name",n!=null&&(e.textContent=n),e}function hr(){let n=document.createElement("span");return n.className="vis-sel-cb vis-sel-spacer",n}function mM(){let n=document.createElement("div");n.className="display-controls-header",n.appendChild(Qo(""));for(let[e,t]of[[RW,"Visible"],[IW,"Selectable"]]){let i=document.createElement("span");i.className="vis-header-icon",i.title=t,i.innerHTML=e,n.appendChild(i)}return n}var Yh=class{constructor(e,t,i){this.visibility=e,this.selectability=t,this.onChange=i;let r=()=>{this._syncAll(),this.onChange()};this.model=new Cn(r),this.selModel=new Cn(r)}add(e){return this.model.addFromSpec(this._enrichSpec(e,"")),this.selModel.addFromSpec(this._enrichSelSpec(e,"",!1)),this}render(e){for(let t of this.model.roots)e.appendChild(this._dom(t));this._syncAll()}_nodeId(e,t){let i=e.key||e.label;return t?t+"/"+i:i}_enrichSpec(e,t){let i=this._nodeId(e,t),r={id:i,data:e};return e.children?r.children=e.children.map(s=>this._enrichSpec(s,i)):e.key&&(r.checked=!!this.visibility[e.key]),e.disabled!=null&&(r.disabled=e.disabled),r}_enrichSelSpec(e,t,i){let r=e.addSelectable===!0?!0:e.addSelectable===!1?!1:i,s=this._nodeId(e,t),o={id:s,data:e,hasCheckbox:!1};if(e.children){o.children=e.children.map(c=>this._enrichSelSpec(c,s,r));let a=c=>c.some(l=>l.hasCheckbox||l.children&&a(l.children));o.hasCheckbox=a(o.children),o.hasCheckbox&&(o.checked=!0)}else if(e.key){let a=e.selectable===!0||e.selectable!==!1&&i;o.hasCheckbox=a,a&&(o.checked=this.selectability[e.key]!==!1)}return o}_syncAll(){this.model.forEach(e=>{e.cb&&(e.cb.checked=e.checked,e.cb.indeterminate=e.indeterminate);let t=e.data;t.key&&(this.visibility[t.key]=e.checked),t.visKey&&(this.visibility[t.visKey]=e.checked||e.indeterminate)}),this.selModel.forEach(e=>{if(!e.hasCheckbox)return;let t=e.data;if(t.key&&(this.selectability[t.key]=e.checked),!e.selCb)return;e.selCb.checked=e.checked,e.selCb.indeterminate=e.indeterminate;let i=this.model.get(e.id),r=i&&!i.checked&&!i.indeterminate;e.selCb.disabled=r,e.selLabel&&e.selLabel.classList.toggle("vis-sel-disabled",r)}),this.model.forEach(e=>{let t=e.data;if(t.disabledBy&&e.el){let i=!this.visibility[t.disabledBy];e.el.classList.toggle("disabled",i)}})}_buildSelCheckbox(e){let t=this.selModel.get(e.id);if(!t||!t.hasCheckbox)return null;let i=document.createElement("input");return i.type="checkbox",i.className="vis-sel-cb",i.title="Selectable",i.addEventListener("change",()=>{this.selModel.check(t.id,i.checked)}),t.selCb=i,i}_dom(e){let t=e.data,i=document.createElement("input");i.type="checkbox",i.className="vis-cb",i.title="Visible",e.cb=i,i.addEventListener("change",()=>this.model.check(e.id,i.checked));let r=this._buildSelCheckbox(e),s=f=>{if(f.appendChild(i),r){f.appendChild(r);let d=this.selModel.get(e.id);d&&(d.selLabel=f)}else f.appendChild(hr())};if(!e.children.length){let f=document.createElement("div");f.className="vis-leaf";let d=document.createElement("span");return d.className="vis-arrow",d.style.visibility="hidden",d.textContent="\u25B6",f.appendChild(d),f.appendChild(Qo(t.label)),s(f),e.el=f,f}let o=document.createElement("div");o.className="vis-group";let{header:a,arrow:c,name:l}=vs();l.textContent=t.label,s(a),o.appendChild(a);let u=document.createElement("div");u.className="vis-group-children",t.disabled&&u.classList.add("disabled");for(let f of e.children)u.appendChild(this._dom(f));return o.appendChild(u),xs(a,c,u,!0),o}};function Hl(n,e,t,i){let r=new Set,s=Math.max(0,n-e),o=Math.min(i-1,n+t);for(let a=s;a<=o;a++)r.add(a);return r}function BW(n){let e={};for(let[t,i]of Object.entries(n||{}))i!==1&&(e[t]=i);return e}function qh(n,e){return(n||[]).some(t=>t.every(i=>!!e[i]))}function OW(n,e){return n.map(t=>{let i=!e.has(t.path);return{id:t.path,parentId:t.parent!=null?t.parent:null,hasCheckbox:t.parent!=null,checked:i,data:{path:t.path,name:t.name,master:t.master,depth:t.depth}}})}var DW=3,gM=[[70,130,210],[200,50,50],[50,180,80],[200,160,40],[160,60,200],[40,190,190],[220,120,50],[180,70,150]];function NW(n){return!n.forceComposite||fe(n)?0:n.groupLayers||S3}function _M(n,e,t,i,r,s){if(!n.displayControlsEl)return;n.displayControlsEl.innerHTML="",n.displayControlsEl.appendChild(mM());for(let S of n.allLayers||[])S.remove();n.allLayers=[],n.baseSlot=null,n.topSlot=null;let o=new Set;function a(){for(let S of o)S.refresh();o.clear()}function c(){n.baseSlot&&o.add(n.baseSlot)}function l(S){return{layer:S,opacity:1,visible:!1}}function u(S,L){g3(S,L)&&c()}function f(S,L,D){let A={layer:S,opacity:1,visible:!!D};return L&&(n[L]=A),A}let d=[f("_instances",null,!0),f("_pins","pinsLayer",e.pins),f("_modules","modulesLayer",e.module_view)],h=[];n.overlayLayers=(i&&i.overlays||[]).map(S=>({def:S,layer:f(S.name,null,qh(S.shown_by,e)),under:S.z_indexD.def.z_index-A.def.z_index))(L?d:h).push(S);let p=[],m=[],g=null,v=new Set,y=new Set;try{let S=window.sessionStorage.getItem("or_hidden_layers");S&&(v=new Set(JSON.parse(S)))}catch{}try{let S=window.sessionStorage.getItem("or_nonselectable_layers");S&&(y=new Set(JSON.parse(S)))}catch{}try{let S=window.sessionStorage.getItem("or_layer_patterns");S&&Object.assign(n.layerPatterns,JSON.parse(S))}catch{}function b(){try{window.sessionStorage.setItem("or_layer_patterns",JSON.stringify(BW(n.layerPatterns)))}catch{}}function x(S,L){L===1?delete n.layerPatterns[S]:n.layerPatterns[S]=L,b(),c(),a()}let E=[{label:"Solid",value:1},{label:"Diagonal",value:2},{label:"Cross",value:3},{label:"Dots",value:4},{label:"None (no fill)",value:0}],w=0;function T(S,L="layers",D=void 0){let A=[],z=S.type==="category"?D:S.path,I=S.flipped===!0,B=S.instances||[],U=B.filter(Oe=>Oe.type!=="category"),Z=B.filter(Oe=>Oe.type==="category"),Q=S.layers||[],ye=w;w+=Q.length;function be(Oe,yt){let K=Oe.map((P,k)=>k);yt&&K.reverse(),K.forEach(P=>{let k=Oe[P],$=L+"/"+(k.name||P);A.push(T(k,$,z))})}function je(){(I?Q.map((yt,K)=>K).reverse():Q.map((yt,K)=>K)).forEach(yt=>{let K=Q[yt],P=K.name||K,k=ye+yt,$=l(P),W=`${L}/${P}`,re=!v.has(W);re&&(u($,!0),n.visibleLayers.add(W),n.visibleLayerNames.add(P)),p.push($),m.push(W),A.push({id:W,data:{name:P,layer:$,color:K.color,colorIndex:k,nodeId:W,ownerChipletPath:z},checked:re})})}be(U,!1),I&&je(),be(Z,I),I||je();let Be={name:S.name,isInstance:!0};return S.type==="category"&&(S.name==="Implant"||S.name==="Other")&&(Be.startCollapsed=!0),S.type!=="category"&&(Be.chipletPath=S.path),{id:L,data:Be,children:A}}let R;i.layer_hierarchy?R=T(i.layer_hierarchy,"layers_parent"):R={id:"layers_parent",children:i.layers.map((S,L)=>{let D=l(S),A=`layers_parent/${S}`,z=!v.has(A);return z&&(u(D,!0),n.visibleLayers.add(A),n.visibleLayerNames.add(S)),p.push(D),m.push(A),{id:A,data:{name:S,layer:D,colorIndex:L,nodeId:A},checked:z}})};function F(S,L,D){let A=n.view.addTileSlot(S,{order:L,source:P3({wm:n.websocketManager,ctx:n.tileCtx,getItems:()=>D,dpr:Yo,tileSize:on,isDoubleBuffer:()=>n.doubleBuffer,groupLayers:()=>NW(n)})});return A.items=D,A}n.baseSlot=F("base",ot.base,[...d,...p]),n.topSlot=F("top",ot.top,h),n.allLayers=[n.baseSlot,n.topSlot];function O(S){if(!S.children||S.children.length===0){let L=S.data&&S.data.name,D=L?!y.has(L):!0;return D&&L&&n.selectableLayers.add(L),{id:S.id,data:{name:L},checked:D}}return{id:S.id,data:{name:S.data&&S.data.name},children:S.children.map(O)}}let j=O(R),V=new Cn(()=>{n.visibleLayerNames.clear();let S=[],L={},D=!1,A=!1,z=g&&n.visibleChiplets instanceof Set;if(V.forEach(B=>{if(B.cb&&(B.cb.checked=B.checked,B.cb.indeterminate=B.indeterminate),B.data&&B.data.layer){let U=B.data.nodeId||B.data.name;S.push(U),u(B.data.layer,B.checked),B.checked?(n.visibleLayers.add(U),n.visibleLayerNames.add(B.data.name)):n.visibleLayers.delete(U)}if(z&&B.data&&B.data.chipletPath){let U=B.data.chipletPath,Z=g.get(U);if(Z){let Q=B.checked||B.indeterminate,ye={checked:B.checked,indeterminate:B.indeterminate};(Z.checked!==B.checked||Z.indeterminate!==B.indeterminate)&&(L[U]=ye,D=!0),n.visibleChiplets.has(U)!==Q&&(A=!0)}}}),n.baseSlot&&o.has(n.baseSlot))for(let{def:B,under:U}of n.overlayLayers)qh(B.layers_by,e)&&o.add(U?n.baseSlot:n.topSlot);a(),q();let I=S.filter(B=>!n.visibleLayers.has(B));try{window.sessionStorage.setItem("or_hidden_layers",JSON.stringify(I))}catch{}n.syncDisplayState(),A?g.mirrorStates(L):D&&(g.mirrorStatesQuiet(L),g.forEach(B=>{B.cb&&(B.cb.checked=B.checked,B.cb.indeterminate=B.indeterminate)}))});n.layerModel=V,V.addFromSpec(R);let G=new Cn(()=>{n.selectableLayers.clear(),G.forEach(L=>{L.checked&&L.data&&L.data.name&&n.selectableLayers.add(L.data.name)}),q();let S=i.layers.filter(L=>!n.selectableLayers.has(L));try{window.sessionStorage.setItem("or_nonselectable_layers",JSON.stringify(S))}catch{}n.syncDisplayState()});G.addFromSpec(j);function q(){G.forEach(S=>{if(!S.selCb)return;S.selCb.checked=S.checked,S.selCb.indeterminate=S.indeterminate;let L=V.get(S.id),D=L&&!L.checked&&!L.indeterminate;S.selCb.disabled=D})}let X=document.createElement("div");X.className="context-menu",X.style.display="none",document.body.appendChild(X);function se(S){let L={};m.forEach((D,A)=>{D&&(L[D]=S.has(A))}),V.checkSet(L)}function le(){X.style.display="none"}function he(S,L){let D=document.createElement("div");D.className="context-menu-item",D.textContent=S,D.addEventListener("click",()=>{L(),le()}),X.appendChild(D)}let at=p.length,Ct=[{label:"Show only this layer",fn:S=>Hl(S,0,0,at)},{label:"Show layer range \u2195",fn:S=>Hl(S,1,1,at)},{label:"Show layer range \u2195\u2195",fn:S=>Hl(S,2,2,at)},{label:"Show layer range \u2193",fn:S=>Hl(S,1,0,at)},{label:"Show layer range \u2191",fn:S=>Hl(S,0,1,at)}];document.addEventListener("click",S=>{X.contains(S.target)||le()}),document.addEventListener("keydown",S=>{S.key==="Escape"&&le()});let Tn=!fe(n),Ni=null;function Ln(){Ni&&(Ni.classList.remove("vis-row-selected"),Ni=null)}Tn&&O3(n,Ln);function li(S,L,D){let A=Pt(n);Ni=S,S.classList.add("vis-row-selected");let z={type:"select_layer",layer:L,use_dbu:n.showDbu};D&&(z.chiplet=D),n.websocketManager.request(z).then(I=>{zt(n,A)&&(n.updateInspector&&n.updateInspector(I),n.focusComponent&&n.focusComponent("Inspector"),n.refreshOverlay&&n.refreshOverlay())}).catch(I=>{console.error("select_layer failed:",I),zt(n,A)&&Ln()})}function cn(S,L=!1){let D=G.get(S.id);if(!S.children||S.children.length===0){let A=document.createElement("div");A.className=Tn?"vis-leaf vis-leaf-selectable":"vis-leaf";let z=document.createElement("span");z.className="vis-arrow",z.style.visibility="hidden",z.textContent="\u25B6",A.appendChild(z);let I=S.data.colorIndex,B=S.data.name,U=Qo(),Z=document.createElement("span");Z.className="layer-color";let Q=S.data.color||i.layer_colors&&i.layer_colors[I]||gM[I%gM.length];Z.style.backgroundColor=`rgb(${Q[0]},${Q[1]},${Q[2]})`,U.appendChild(Z),U.appendChild(document.createTextNode(B)),A.appendChild(U),Tn&&U.addEventListener("click",()=>{li(A,B,S.data.ownerChipletPath)});let ye=document.createElement("input");if(ye.type="checkbox",ye.className="vis-cb",ye.title="Visible",ye.checked=S.checked,S.cb=ye,ye.addEventListener("change",()=>{V.check(S.id,ye.checked)}),A.appendChild(ye),D){let be=document.createElement("input");be.type="checkbox",be.className="vis-sel-cb",be.title="Selectable",be.checked=D.checked,D.selCb=be,be.addEventListener("change",()=>{G.check(S.id,be.checked)}),A.appendChild(be)}else A.appendChild(hr());return A.addEventListener("contextmenu",be=>{be.preventDefault(),be.stopPropagation(),X.innerHTML="";for(let Oe of Ct)he(Oe.label,()=>se(Oe.fn(I)));let je=document.createElement("div");je.className="context-menu-separator",je.style.borderTop="1px solid #555",je.style.margin="4px 0",X.appendChild(je);let Be=n.layerPatterns[B]??1;for(let Oe of E){let yt=Be===Oe.value?"\u25CF ":" ";he(yt+"Fill: "+Oe.label,()=>x(B,Oe.value))}X.style.left=be.clientX+"px",X.style.top=be.clientY+"px",X.style.display="block"}),A}else{let A=document.createElement("div");A.className="vis-group";let{header:z,arrow:I,name:B}=vs();B.textContent=L?"Layers":S.data.name||"Group";let U=document.createElement("input");if(U.type="checkbox",U.className="vis-cb",U.title="Visible",U.checked=S.checked,U.indeterminate=S.indeterminate,S.cb=U,U.addEventListener("change",()=>{V.check(S.id,U.checked)}),z.appendChild(U),D){let Q=document.createElement("input");Q.type="checkbox",Q.className="vis-sel-cb",Q.title="Selectable",Q.checked=D.checked,Q.indeterminate=D.indeterminate,D.selCb=Q,Q.addEventListener("change",()=>{G.check(S.id,Q.checked)}),z.appendChild(Q)}else z.appendChild(hr());A.appendChild(z);let Z=document.createElement("div");Z.className="vis-group-children";for(let Q of S.children)Z.appendChild(cn(Q,!1));return A.appendChild(Z),xs(z,I,Z,!!(S.data&&S.data.startCollapsed)),A}}let Gt=V.roots[0]||V.get("layers_parent"),ln=cn(Gt,!0);n.displayControlsEl.appendChild(ln),q();let ui=i&&Array.isArray(i.chiplets)?i.chiplets:[];if(ui.length>1){let Z=function(K,P){let k=U.get(K);k&&(V.cascadeQuiet(k.id,P),V.onChange())},yt=function(K){let P=K.data;if(K!==Be){let k=document.createElement("div");k.className="vis-leaf",k.style.paddingLeft=8*(P.depth-1)+"px",k.title=P.path+(P.master?` (${P.master})`:""),k.appendChild(Qo(P.name));let $=document.createElement("input");$.type="checkbox",$.className="vis-cb",$.checked=K.checked,$.indeterminate=K.indeterminate,K.cb=$,$.addEventListener("change",()=>{g.check(K.id,$.checked),Z(P.path,$.checked)}),k.appendChild($),k.appendChild(hr()),Oe.appendChild(k)}K.children&&K.children.forEach(yt)},S=i&&i.block_name||"",L=S!=="",D={};if(L)try{let K=We("or_hidden_chiplets");if(K){let P=JSON.parse(decodeURIComponent(K));P&&typeof P=="object"&&!Array.isArray(P)&&(D=P)}}catch{}let A=new Set(Array.isArray(D[S])?D[S]:[]),z=OW(ui,A),I=z.findIndex(K=>K.parentId===null),B=I>=0?z[I].id:null;if(I>=0&&(z[I].hasCheckbox=!0),n.visibleChiplets=new Set(ui.filter(K=>!A.has(K.path)).map(K=>K.path)),g=new Cn(()=>{let K=new Set;if(g.forEach(P=>{P.cb&&(P.cb.checked=P.checked,P.cb.indeterminate=P.indeterminate),P.data&&P.data.path&&(P.checked||P.indeterminate)&&K.add(P.data.path)}),n.visibleChiplets=K,L){let P=ui.filter($=>!K.has($.path)).map($=>$.path),k={};try{let $=We("or_hidden_chiplets");if($){let W=JSON.parse(decodeURIComponent($));W&&typeof W=="object"&&!Array.isArray(W)&&(k=W)}}catch{}P.length===0?delete k[S]:k[S]=P,$e("or_hidden_chiplets",encodeURIComponent(JSON.stringify(k)))}r()}),g.buildFromNodes(z),typeof console<"u"&&console.warn){let K=new Set;V.forEach(k=>{k.data&&k.data.chipletPath&&K.add(k.data.chipletPath)});let P=new Set;g.forEach(k=>{k.data&&k.data.path&&P.add(k.data.path)});for(let k of P)K.has(k)||console.warn(`[display-controls] chiplet "${k}" missing from layer_hierarchy \u2014 Layers/Chiplets sync may drift`);for(let k of K)P.has(k)||console.warn(`[display-controls] layer hierarchy node "${k}" has no matching chiplet \u2014 Layers/Chiplets sync may drift`)}let U=new Map;V.forEach(K=>{K.data&&K.data.chipletPath&&U.set(K.data.chipletPath,K)});{let K={};if(V.forEach(P=>{if(!P.data||!P.data.chipletPath)return;let k=P.data.chipletPath;A.has(k)||g.get(k)&&(K[k]={checked:P.checked,indeterminate:P.indeterminate})}),Object.keys(K).length>0){g.mirrorStatesQuiet(K);let P=new Set;g.forEach(k=>{k.data&&k.data.path&&(k.checked||k.indeterminate)&&P.add(k.data.path)}),n.visibleChiplets=P}}let Q=document.createElement("div");Q.className="vis-group";let{header:ye,arrow:be,name:je}=vs();je.textContent="Chiplets";let Be=B!=null?g.get(B):null;if(Be){let K=document.createElement("input");K.type="checkbox",K.className="vis-cb",K.checked=Be.checked,K.indeterminate=Be.indeterminate,Be.cb=K,K.addEventListener("change",P=>{P.stopPropagation(),g.check(B,K.checked),Be.data&&Be.data.path&&Z(Be.data.path,K.checked)}),ye.appendChild(K)}ye.appendChild(hr()),Q.appendChild(ye);let Oe=document.createElement("div");Oe.className="vis-group-children",g.roots.forEach(yt),Q.appendChild(Oe),xs(ye,be,Oe,!1),n.displayControlsEl.appendChild(Q)}else n.visibleChiplets=null;let fi=!!e.debug_renderers,Ge=new Yh(e,t,()=>{r(),!!e.debug_renderers!==fi&&(fi=!!e.debug_renderers,n.refreshRendererControls&&n.refreshRendererControls())});Ge.add({label:"Nets",addSelectable:!0,children:[{key:"net_signal",label:"Signal"},{key:"net_power",label:"Power"},{key:"net_ground",label:"Ground"},{key:"net_clock",label:"Clock"},{key:"net_reset",label:"Reset"},{key:"net_tieoff",label:"Tie off"},{key:"net_scan",label:"Scan"},{key:"net_analog",label:"Analog"}]}),Ge.add({label:"Instances",addSelectable:!0,children:[{label:"Std Cells",visKey:"stdcells",disabled:!n.hasLiberty,children:[{label:"Bufs/Invs",children:[{key:"std_bufinv_timing",label:"Timing opt."},{key:"std_bufinv",label:"Netlist"}]},{key:"std_combinational",label:"Combinational"},{key:"std_sequential",label:"Sequential"},{label:"Clock tree",children:[{key:"std_clock_bufinv",label:"Buffer/Inverter"},{key:"std_clock_gate",label:"Clock gate"}]},{key:"std_level_shift",label:"Level shifter"}]},{key:"macros",label:"Macros"},{label:"Pads",children:[{key:"pad_input",label:"Input"},{key:"pad_output",label:"Output"},{key:"pad_inout",label:"Inout"},{key:"pad_power",label:"Power"},{key:"pad_spacer",label:"Spacer"},{key:"pad_areaio",label:"Area IO"},{key:"pad_other",label:"Other"}]},{label:"Physical",children:[{key:"phys_fill",label:"Fill"},{key:"phys_endcap",label:"Endcap"},{key:"phys_welltap",label:"Welltap"},{key:"phys_tie",label:"Tie Hi/Lo"},{key:"phys_antenna",label:"Antenna"},{key:"phys_cover",label:"Cover"},{key:"phys_bump",label:"Bump"},{key:"phys_other",label:"Other"}]}]}),Ge.add({label:"Blockages",addSelectable:!0,children:[{key:"placement_blockages",label:"Placement"},{key:"routing_obstructions",label:"Routing"}]}),i.sites&&i.sites.length>0&&Ge.add({label:"Rows",visKey:"rows",addSelectable:!0,children:i.sites.map(S=>({key:"site_"+S,label:S}))}),Ge.add({label:"Tracks",children:[{key:"tracks_pref",label:"Pref"},{key:"tracks_non_pref",label:"Non Pref"}]}),Ge.add({label:"Shapes",children:[{label:"Routing",visKey:"routing",children:[{key:"routing_segments",label:"Segments"},{key:"routing_vias",label:"Vias"}]},{label:"Special Routing",visKey:"special_nets",children:[{key:"srouting_segments",label:"Segments"},{key:"srouting_vias",label:"Vias"}]},{key:"pins",label:"Pins",selectable:!0},{key:"pin_names",label:"Pin Names",disabledBy:"pins"},{key:"fills",label:"Fills"}]}),Ge.add({label:"Misc",children:[{label:"Instances",children:[{key:"inst_names",label:"Names"},{key:"inst_pins",label:"Pins",selectable:!0},{key:"inst_pin_names",label:"Pin Names",disabledBy:"inst_pins"},{key:"blockages",label:"Blockages"}]},{key:"detailed",label:"Detailed view"},{key:"rulers",label:"Rulers"},{key:"labels",label:"Labels"},{key:"scale_bar",label:"Scale bar"},{key:"access_points",label:"Access Points"},{key:"regions",label:"Regions"},{key:"mfg_grid",label:"Manufacturing grid"},{key:"gcell_grid",label:"GCell grid"},{key:"flywires_only",label:"Flywires only"},{key:"focused_nets_guides",label:"Focused nets guides"},{key:"highlight_selected",label:"Highlight selected"}]}),Ge.add({key:"module_view",label:"Module view"}),Ge.add({label:"Debug Graphics",children:[{key:"debug_renderers",label:"Renderers"},{key:"debug_live",label:"Live (don't require pause)",disabledBy:"debug_renderers"},{key:"debug",label:"Tiles"}]}),Ge.render(n.displayControlsEl);let _t=document.createElement("div");_t.className="renderer-controls",n.displayControlsEl.appendChild(_t);function Vt(S){return Promise.all(S.map(({path:L,value:D})=>n.websocketManager.request({type:"set_renderer_control",path:L,value:D}))).catch(()=>{})}function di(S){_t.innerHTML="";let L=new Map;for(let D of S||[]){let A=D.group||"";L.has(A)||L.set(A,[]),L.get(A).push(D)}for(let[D,A]of L){let z=_t;if(D){let I=document.createElement("div");I.className="vis-group";let{header:B,arrow:U,name:Z}=vs();Z.textContent=D;let Q=document.createElement("input");Q.type="checkbox",Q.className="vis-cb",Q.title="Visible";let ye=A.filter(je=>je.visible).length;Q.checked=ye===A.length,Q.indeterminate=ye>0&&ye{let je=Q.checked;Vt(A.filter(Be=>!!Be.visible!==je).map(Be=>({path:Be.path,value:je})))}),B.appendChild(Q),B.appendChild(hr()),I.appendChild(B);let be=document.createElement("div");be.className="vis-group-children",I.appendChild(be),xs(B,U,be,!1),_t.appendChild(I),z=be}for(let I of A){let B=document.createElement("div");B.className="vis-leaf";let U=document.createElement("span");U.className="vis-arrow",U.style.visibility="hidden",U.textContent="\u25B6",B.appendChild(U),B.appendChild(Qo(I.name));let Z=document.createElement("input");Z.type="checkbox",Z.className="vis-cb",Z.title="Visible",Z.checked=!!I.visible,Z.addEventListener("change",()=>Vt([{path:I.path,value:Z.checked}])),B.appendChild(Z),B.appendChild(hr()),z.appendChild(B)}}}n.refreshRendererControls=function(){return!n.websocketManager||fe(n)||!e.debug_renderers?(_t.innerHTML="",Promise.resolve()):n.websocketManager.request({type:"renderer_controls"}).then(S=>di(S.controls)).catch(()=>{})},n.refreshRendererControls();let Mn=document.createElement("div");Mn.className="bg-color-row";let hi=document.createElement("span");hi.textContent="Background";let Ke=document.createElement("input");Ke.type="color",Ke.className="bg-color-input",Ke.title="Layout background color";let Wt=We("or_bg_color");Ke.value=Zo(Wt)?Wt:tv(),Ke.addEventListener("input",()=>{document.documentElement.style.setProperty("--bg-map",Ke.value)}),Ke.addEventListener("change",()=>{eM(Ke.value,n)});let un=document.createElement("button");un.className="bg-color-reset",un.textContent="Reset",un.title="Reset background to the theme default",un.addEventListener("click",()=>{tM(n),Ke.value=tv()}),Mn.appendChild(hi),Mn.appendChild(Ke),Mn.appendChild(un),!n.heatMapLayer&&s&&(n.heatMapLayer=s());let An=document.createElement("div");An.className="vis-group heatmap-controls",n.displayControlsEl.appendChild(An);let{header:Rs,arrow:pi,name:yr}=vs("vis-group-header heatmap-header");yr.textContent="Heat Maps",An.appendChild(Rs);let kn=document.createElement("div");kn.className="vis-group-children heatmap-group-children",An.appendChild(kn),xs(Rs,pi,kn,!0),n.displayControlsEl.appendChild(Mn);function jt(S,L,D,A){let z=document.createElement("label");z.className="heatmap-setting";let I=document.createElement("input");I.type="checkbox",I.checked=D,I.addEventListener("change",()=>A(I.checked)),z.appendChild(I),z.appendChild(document.createTextNode(L)),S.appendChild(z)}function Re(S,L,D,A,z){let I=document.createElement("label");I.className="heatmap-setting";let B=document.createElement("span");B.textContent=L;let U=document.createElement("input");U.type="number",U.value=String(D),U.step=String(A||1),U.addEventListener("change",()=>z(parseFloat(U.value))),I.appendChild(B),I.appendChild(U),S.appendChild(I)}function na(S,L,D,A,z){let I=document.createElement("label");I.className="heatmap-setting";let B=document.createElement("span");B.textContent=L;let U=document.createElement("select");for(let Z of A){let Q=document.createElement("option");Q.value=Z,Q.textContent=Z,Z===D&&(Q.selected=!0),U.appendChild(Q)}U.addEventListener("change",()=>z(U.value)),I.appendChild(B),I.appendChild(U),S.appendChild(I)}function Ce(S){n.websocketManager.request(S).then(L=>{n.updateHeatMaps&&n.updateHeatMaps(L)}).catch(L=>console.error("Heat map update failed",L))}function M(S){if(!n.heatMapLegendEl)return;let L=n.heatMapLegendEl;if(L.innerHTML="",!S||!S.show_legend||!S.legend||S.legend.length===0){L.classList.add("hidden");return}let D=document.createElement("div");D.className="heatmap-map-legend-title",D.textContent=S.title,L.appendChild(D);let A=document.createElement("div");A.className="heatmap-map-legend-units",A.textContent=S.units||"",L.appendChild(A);let z=document.createElement("div");z.className="heatmap-map-legend-list";for(let I of S.legend){let B=document.createElement("div");B.className="heatmap-legend-row";let U=document.createElement("span");U.className="heatmap-legend-swatch",U.style.backgroundColor=`rgba(${I.color[0]}, ${I.color[1]}, ${I.color[2]}, ${I.color[3]/255})`;let Z=document.createElement("span");Z.textContent=I.value,B.appendChild(U),B.appendChild(Z),z.appendChild(B)}L.appendChild(z),L.classList.remove("hidden")}n.renderHeatMapControls=S=>{kn.innerHTML="";let L=document.createElement("div");L.className="heatmap-list",kn.appendChild(L);let D=document.createElement("label");D.className="heatmap-setting";let A=document.createElement("input");A.type="radio",A.name="active-heatmap",A.checked=!S.active,A.addEventListener("change",()=>{Ce({type:"set_active_heatmap",name:""})}),D.appendChild(A),D.appendChild(document.createTextNode("Off")),L.appendChild(D);for(let U of S.heatmaps||[]){let Z=document.createElement("label");Z.className="heatmap-setting";let Q=document.createElement("input");Q.type="radio",Q.name="active-heatmap",Q.checked=U.name===S.active,Q.addEventListener("change",()=>{Ce({type:"set_active_heatmap",name:U.name})}),Z.appendChild(Q),Z.appendChild(document.createTextNode(U.title)),L.appendChild(Z)}let z=(S.heatmaps||[]).find(U=>U.name===S.active);if(M(z),!z)return;let I=document.createElement("div");I.className="heatmap-settings",kn.appendChild(I),Re(I,"Display min",z.display_min,z.display_range_increment,U=>{Ce({type:"set_heatmap",name:z.name,option:"DisplayMin",value:U})}),Re(I,"Display max",z.display_max,z.display_range_increment,U=>{Ce({type:"set_heatmap",name:z.name,option:"DisplayMax",value:U})}),jt(I,"Show below min",z.draw_below_min,U=>{Ce({type:"set_heatmap",name:z.name,option:"ShowMin",value:U})}),jt(I,"Show above max",z.draw_above_max,U=>{Ce({type:"set_heatmap",name:z.name,option:"ShowMax",value:U})}),jt(I,"Log scale",z.log_scale,U=>{Ce({type:"set_heatmap",name:z.name,option:"LogScale",value:U})}),jt(I,"Reverse log",z.reverse_log,U=>{Ce({type:"set_heatmap",name:z.name,option:"ReverseLog",value:U})}),z.can_adjust_grid&&(Re(I,"Grid X",z.grid_x,.1,U=>{Ce({type:"set_heatmap",name:z.name,option:"GridX",value:U})}),Re(I,"Grid Y",z.grid_y,.1,U=>{Ce({type:"set_heatmap",name:z.name,option:"GridY",value:U})})),Re(I,"Alpha",z.alpha,1,U=>{Ce({type:"set_heatmap",name:z.name,option:"Alpha",value:U})}),jt(I,"Legend",z.show_legend,U=>{Ce({type:"set_heatmap",name:z.name,option:"ShowLegend",value:U})}),z.supports_numbers&&jt(I,"Show numbers",z.show_numbers,U=>{Ce({type:"set_heatmap",name:z.name,option:"ShowNumbers",value:U})});for(let U of z.options||[])U.type==="bool"?jt(I,U.label,U.value,Z=>{Ce({type:"set_heatmap",name:z.name,option:U.name,value:Z})}):U.type==="choice"&&na(I,U.label,U.value,U.choices||[],Z=>{Ce({type:"set_heatmap",name:z.name,option:U.name,value:Z})});z.selection_filter_label&&jt(I,z.selection_filter_label,z.use_selected_only,U=>{Ce({type:"set_heatmap",name:z.name,option:"use_selected_only",value:U})});let B=document.createElement("button");B.className="or-btn or-btn-sm heatmap-rebuild",B.textContent="Rebuild data",B.addEventListener("click",()=>{Ce({type:"set_heatmap",name:z.name,option:"rebuild",value:1})}),I.appendChild(B)}}var yM="search-nav-dialog",FW=[{label:"Instance",value:"inst"},{label:"Net",value:"net"},{label:"Port",value:"port"}];function Zh(n){if(!n.designScale)return;let e=FW.map(u=>``).join(""),{overlay:t,close:i,okBtn:r,showError:s}=Xo("Find Object",`
`,"Find",gM),o=t.querySelector(".sn-pattern"),a=t.querySelector(".sn-type"),c=t.querySelector(".sn-case");o.focus();function l(){let u=o.value.trim();if(!u){s("Enter a name or glob pattern.");return}n.websocketManager&&(s("Searching\u2026",!0),n.websocketManager.request({type:"find",obj_type:a.value,pattern:u,match_case:c.checked}).then(f=>{qo(n,f);let d=f&&f.count?f.count:0;if(!d){s("No objects found.");return}Array.isArray(f.bbox)&&(n.lastSelectionBounds=f.bbox.slice(0,4),n.view.fitWorldRect(Ot(...n.lastSelectionBounds,n.designScale,n.designOriginX,n.designOriginY))),typeof n.updateInspector=="function"&&n.updateInspector(f),typeof n.redrawAllLayers=="function"&&n.redrawAllLayers();let h=f.selection_count||d;s(f.truncated?`${d} found (showing first ${h}).`:`${d} found.`,!0)}).catch(f=>s("Find failed: "+f)))}return r.addEventListener("click",l),o.addEventListener("keydown",u=>{u.key==="Enter"&&(u.preventDefault(),l())}),{close:i}}function Zh(n){if(!n.designScale||!n.view)return;let e=p=>n.formatDbu(p),t=p=>n.parseDbu(p),i=n.unitLabel(),r=n.view.getCenter(),s=wn(r[0],r[1],n.designScale,n.designOriginX,n.designOriginY),{overlay:o,close:a,okBtn:c,showError:l}=Xo("Go to Position",` + `,"Find",yM),o=t.querySelector(".sn-pattern"),a=t.querySelector(".sn-type"),c=t.querySelector(".sn-case");o.focus();function l(){let u=o.value.trim();if(!u){s("Enter a name or glob pattern.");return}n.websocketManager&&(s("Searching\u2026",!0),n.websocketManager.request({type:"find",obj_type:a.value,pattern:u,match_case:c.checked}).then(f=>{qo(n,f);let d=f&&f.count?f.count:0;if(!d){s("No objects found.");return}Array.isArray(f.bbox)&&(n.lastSelectionBounds=f.bbox.slice(0,4),n.view.fitWorldRect(Nt(...n.lastSelectionBounds,n.designScale,n.designOriginX,n.designOriginY))),typeof n.updateInspector=="function"&&n.updateInspector(f),typeof n.redrawAllLayers=="function"&&n.redrawAllLayers();let h=f.selection_count||d;s(f.truncated?`${d} found (showing first ${h}).`:`${d} found.`,!0)}).catch(f=>s("Find failed: "+f)))}return r.addEventListener("click",l),o.addEventListener("keydown",u=>{u.key==="Enter"&&(u.preventDefault(),l())}),{close:i}}function Xh(n){if(!n.designScale||!n.view)return;let e=p=>n.formatDbu(p),t=p=>n.parseDbu(p),i=n.unitLabel(),r=n.view.getCenter(),s=Pn(r[0],r[1],n.designScale,n.designOriginX,n.designOriginY),{overlay:o,close:a,okBtn:c,showError:l}=Xo("Go to Position",`
-
`,"Go to",gM),u=o.querySelector(".sn-x"),f=o.querySelector(".sn-y"),d=o.querySelector(".sn-size");u.focus(),u.select();function h(){let p=t(u.value),m=t(f.value);if(p===null||m===null){l(`X and Y must be numbers (${i}).`);return}let g=d.value.trim(),v=g?t(g):null;if(v!==null&&v>0){let y=v/2;n.view.fitWorldRect(Ot(p-y,m-y,p+y,m+y,n.designScale,n.designOriginX,n.designOriginY))}else n.view.setView(xn(p,m,n.designScale,n.designOriginX,n.designOriginY),n.view.getZoom());a()}c.addEventListener("click",h);for(let p of[u,f,d])p.addEventListener("keydown",m=>{m.key==="Enter"&&(m.preventDefault(),h())});return{close:a}}var _M={ctrl:"ctrl",control:"ctrl",shift:"shift",alt:"alt",meta:"meta",cmd:"meta",command:"meta",super:"meta"};function OW(n){if(typeof n!="string")return null;let e=n.split("+").map(s=>s.trim().toLowerCase()).filter(Boolean);if(e.length===0)return null;let t=e.pop();if(_M[t]!==void 0)return null;let i=new Set;for(let s of e){let o=_M[s];if(o===void 0)return null;i.add(o)}return[...["ctrl","alt","shift","meta"].filter(s=>i.has(s)),t].join("+")}function DW(n){let e=[];return n.ctrlKey&&e.push("ctrl"),n.altKey&&e.push("alt"),n.shiftKey&&e.push("shift"),n.metaKey&&e.push("meta"),[...e,String(n.key).toLowerCase()].join("+")}function bM(n){let e=[{label:"File",items:[{label:"Open DB...",action:()=>yM(n,"Open DB","read_db"),enabledWhen:()=>!n.designScale},{label:"Save DB...",action:()=>yM(n,"Save DB","write_db"),enabledWhen:()=>!!n.designScale}]},{label:"View",items:[{label:"Fit",shortcut:"F",action:()=>{n.fitRect&&n.view.fitWorldRect(n.fitRect)}},{label:"Zoom In",shortcut:"Z",action:()=>n.view.zoomIn()},{label:"Zoom Out",shortcut:"Shift+Z",action:()=>n.view.zoomOut()},{type:"separator"},{label:"Toggle Theme",shortcut:"T",action:()=>n.toggleTheme()},{type:"separator"},{label:"Find...",shortcut:"Ctrl+F",action:()=>qh(n),enabledWhen:()=>!!n.designScale},{label:"Go to Position...",shortcut:"Shift+G",action:()=>Zh(n),enabledWhen:()=>!!n.designScale}]},{label:"Tools",items:[{label:"Ruler",shortcut:"K",action:()=>{n.rulerManager&&n.rulerManager.toggleRulerMode()}},{label:"Clear Rulers",shortcut:"Shift+K",action:()=>{n.rulerManager&&n.rulerManager.clearAllRulers()}},{type:"separator"},{label:"Add Label",shortcut:"L",action:()=>{n.labelManager&&n.labelManager.toggleLabelMode()}},{label:"Clear Labels",action:()=>{n.labelManager&&n.labelManager.clearAllLabels()}},{type:"separator"},{label:"Clear Highlights",action:()=>{n.websocketManager.request({type:"clear_highlights",group:-1}).then(()=>{n.refreshOverlay&&n.refreshOverlay(),n.refreshInspector&&n.refreshInspector()}).catch(()=>{})}},{type:"separator"},{label:"Global Connect...",action:()=>{n.showGlobalConnectDialog&&n.showGlobalConnectDialog()},enabledWhen:()=>!!n.designScale}]},{label:"Options",items:[{label:"Show DBU",action:()=>n.toggleShowDbu(),checked:()=>n.showDbu},{label:"Make euclidian rulers",action:()=>n.toggleRulerStyle(),checked:()=>n.rulerStyle!=="manhattan"},{type:"separator"},{label:"Mouse wheel mapped to zoom by default",action:()=>n.toggleWheelZoom(),checked:()=>n.wheelZoom},{label:"Arrow keys scroll step...",action:()=>n.showArrowStepDialog()},{label:"Application font...",action:()=>n.showAppFontDialog()},{type:"separator"},{label:"Smooth zoom and pan",action:()=>n.toggleControlSmoothing(),checked:()=>n.controlSmoothing},{label:"Double buffering",action:()=>n.toggleDoubleBuffer(),checked:()=>n.doubleBuffer},{label:"Defer tile updates while panning",action:()=>n.toggleDeferTileUpdates(),checked:()=>n.deferTileUpdates},{type:"separator"},{label:"Show polygon decomposition",action:()=>n.togglePolyDecomp(),checked:()=>n.polyDecomp,enabledWhen:()=>!!n.designScale}]},{label:"Windows",items:[{label:"Layout Viewer",action:()=>n.focusComponent("LayoutViewer")},{label:"3D Viewer",action:()=>n.focusComponent("3DViewer")},{label:"Display Controls",action:()=>n.focusComponent("DisplayControls")},{label:"Inspector",action:()=>n.focusComponent("Inspector")},{label:"Selection Browser",action:()=>n.focusComponent("SelectHighlight")},{label:"Tcl Console",action:()=>n.focusComponent("TclConsole")},{label:"Hierarchy Browser",action:()=>n.focusComponent("Browser")},{label:"Timing",action:()=>n.focusComponent("TimingWidget")},{label:"DRC Viewer",action:()=>n.focusComponent("DRCWidget")},{label:"Clock Tree",action:()=>n.focusComponent("ClockWidget")},{label:"Charts",action:()=>n.focusComponent("ChartsWidget")},{label:"Help",action:()=>n.focusComponent("HelpWidget")},{type:"separator"},{label:"Reset to Default Layout",action:()=>n.resetLayout()}]},{label:"Help",items:[{label:"Keyboard Shortcuts",action:()=>n.focusComponent("HelpWidget")}]}],t=document.getElementById("menu-bar"),i=null,r=new Map;function s(){i&&(i.classList.remove("open"),i=null)}function o(){let l=e.map(h=>({label:h.label,items:h.items.slice()})),u=new Map(l.map(h=>[h.label,h]));function f(h){let p=u.get(h);return p||(p={label:h,items:[]},u.set(h,p),l.push(p)),p}function d(h,p){let m=h.items.find(g=>g.submenu&&g.label===p);return m||(m={label:p,submenu:{label:p,items:[]}},h.items.push(m)),m.submenu}for(let h of n.customMenu||[]){let p=String(h.path||"Custom Scripts").split("/").map(y=>y.trim()).filter(Boolean);p.length===0&&p.push("Custom Scripts");let m=f(p[0]);for(let y=1;yVl(n,h.script,h.echo);m.items.push({label:h.text,shortcut:h.shortcut,action:g});let v=OW(h.shortcut);v&&r.set(v,g)}return l}function a(l,u){for(let f of u){if(f.type==="separator"){let p=document.createElement("div");p.className="menu-separator",l.appendChild(p);continue}let d=document.createElement("div");if(d.className="menu-item",f.submenu){d.classList.add("submenu-item");let p=document.createElement("span");p.textContent=f.label,d.appendChild(p);let m=document.createElement("span");m.className="submenu-arrow",m.textContent="\u25B8",d.appendChild(m);let g=document.createElement("div");g.className="menu-dropdown submenu",a(g,f.submenu.items),d.appendChild(g),l.appendChild(d);continue}if(f.disabled&&d.classList.add("disabled"),f.enabledWhen&&(d._enabledWhen=f.enabledWhen),f.checked){let p=document.createElement("span");p.className="menu-check",p.textContent=f.checked()?"\u2713":"",d.appendChild(p),d._checkedFn=f.checked}let h=document.createElement("span");if(h.textContent=f.label,d.appendChild(h),f.shortcut){let p=document.createElement("span");p.className="shortcut",p.textContent=f.shortcut,d.appendChild(p)}f.action&&d.addEventListener("click",p=>{d.classList.contains("disabled")||(p.stopPropagation(),s(),f.action())}),l.appendChild(d)}}function c(){for(let u of t.querySelectorAll(":scope > .menu-label"))u.remove();let l=t.firstChild;i=null,r.clear();for(let u of o()){let h=function(){for(let p of d.querySelectorAll(".menu-item"))if(p._enabledWhen&&p.classList.toggle("disabled",!p._enabledWhen()),p._checkedFn){let m=p.querySelector(".menu-check");m&&(m.textContent=p._checkedFn()?"\u2713":"")}},f=document.createElement("div");f.className="menu-label",f.textContent=u.label;let d=document.createElement("div");d.className="menu-dropdown",a(d,u.items),f.appendChild(d),f.addEventListener("click",p=>{p.stopPropagation(),i===f?s():(s(),h(),f.classList.add("open"),i=f)}),f.addEventListener("mouseenter",()=>{i&&i!==f&&(s(),h(),f.classList.add("open"),i=f)}),t.insertBefore(f,l)}}c(),n.rebuildMenuBar=c,document.addEventListener("click",s),NW(r)}function NW(n){document.addEventListener("keydown",e=>{if(n.size===0)return;let t=e.target.tagName;if(t==="INPUT"||t==="TEXTAREA"||e.target.isContentEditable)return;let i=n.get(DW(e));i&&(e.preventDefault(),e.stopImmediatePropagation(),i())},!0)}function yM(n,e,t){let i=t==="write_db",r=document.createElement("div");r.className="modal-overlay",r.innerHTML=` +
`,"Go to",yM),u=o.querySelector(".sn-x"),f=o.querySelector(".sn-y"),d=o.querySelector(".sn-size");u.focus(),u.select();function h(){let p=t(u.value),m=t(f.value);if(p===null||m===null){l(`X and Y must be numbers (${i}).`);return}let g=d.value.trim(),v=g?t(g):null;if(v!==null&&v>0){let y=v/2;n.view.fitWorldRect(Nt(p-y,m-y,p+y,m+y,n.designScale,n.designOriginX,n.designOriginY))}else n.view.setView(Sn(p,m,n.designScale,n.designOriginX,n.designOriginY),n.view.getZoom());a()}c.addEventListener("click",h);for(let p of[u,f,d])p.addEventListener("keydown",m=>{m.key==="Enter"&&(m.preventDefault(),h())});return{close:a}}var bM={ctrl:"ctrl",control:"ctrl",shift:"shift",alt:"alt",meta:"meta",cmd:"meta",command:"meta",super:"meta"};function zW(n){if(typeof n!="string")return null;let e=n.split("+").map(s=>s.trim().toLowerCase()).filter(Boolean);if(e.length===0)return null;let t=e.pop();if(bM[t]!==void 0)return null;let i=new Set;for(let s of e){let o=bM[s];if(o===void 0)return null;i.add(o)}return[...["ctrl","alt","shift","meta"].filter(s=>i.has(s)),t].join("+")}function UW(n){let e=[];return n.ctrlKey&&e.push("ctrl"),n.altKey&&e.push("alt"),n.shiftKey&&e.push("shift"),n.metaKey&&e.push("meta"),[...e,String(n.key).toLowerCase()].join("+")}function xM(n){let e=[{label:"File",items:[{label:"Open DB...",action:()=>vM(n,"Open DB","read_db"),enabledWhen:()=>!n.designScale},{label:"Save DB...",action:()=>vM(n,"Save DB","write_db"),enabledWhen:()=>!!n.designScale}]},{label:"View",items:[{label:"Fit",shortcut:"F",action:()=>{n.fitRect&&n.view.fitWorldRect(n.fitRect)}},{label:"Zoom In",shortcut:"Z",action:()=>n.view.zoomIn()},{label:"Zoom Out",shortcut:"Shift+Z",action:()=>n.view.zoomOut()},{type:"separator"},{label:"Toggle Theme",shortcut:"T",action:()=>n.toggleTheme()},{type:"separator"},{label:"Find...",shortcut:"Ctrl+F",action:()=>Zh(n),enabledWhen:()=>!!n.designScale},{label:"Go to Position...",shortcut:"Shift+G",action:()=>Xh(n),enabledWhen:()=>!!n.designScale}]},{label:"Tools",items:[{label:"Ruler",shortcut:"K",action:()=>{n.rulerManager&&n.rulerManager.toggleRulerMode()}},{label:"Clear Rulers",shortcut:"Shift+K",action:()=>{n.rulerManager&&n.rulerManager.clearAllRulers()}},{type:"separator"},{label:"Add Label",shortcut:"L",action:()=>{n.labelManager&&n.labelManager.toggleLabelMode()}},{label:"Clear Labels",action:()=>{n.labelManager&&n.labelManager.clearAllLabels()}},{type:"separator"},{label:"Clear Highlights",action:()=>{n.websocketManager.request({type:"clear_highlights",group:-1}).then(()=>{n.refreshOverlay&&n.refreshOverlay(),n.refreshInspector&&n.refreshInspector()}).catch(()=>{})}},{type:"separator"},{label:"Global Connect...",action:()=>{n.showGlobalConnectDialog&&n.showGlobalConnectDialog()},enabledWhen:()=>!!n.designScale}]},{label:"Options",items:[{label:"Show DBU",action:()=>n.toggleShowDbu(),checked:()=>n.showDbu},{label:"Make euclidian rulers",action:()=>n.toggleRulerStyle(),checked:()=>n.rulerStyle!=="manhattan"},{type:"separator"},{label:"Mouse wheel mapped to zoom by default",action:()=>n.toggleWheelZoom(),checked:()=>n.wheelZoom},{label:"Arrow keys scroll step...",action:()=>n.showArrowStepDialog()},{label:"Application font...",action:()=>n.showAppFontDialog()},{type:"separator"},{label:"Smooth zoom and pan",action:()=>n.toggleControlSmoothing(),checked:()=>n.controlSmoothing},{label:"Double buffering",action:()=>n.toggleDoubleBuffer(),checked:()=>n.doubleBuffer},{label:"Defer tile updates while panning",action:()=>n.toggleDeferTileUpdates(),checked:()=>n.deferTileUpdates},{type:"separator"},{label:"Show polygon decomposition",action:()=>n.togglePolyDecomp(),checked:()=>n.polyDecomp,enabledWhen:()=>!!n.designScale}]},{label:"Windows",items:[{label:"Layout Viewer",action:()=>n.focusComponent("LayoutViewer")},{label:"3D Viewer",action:()=>n.focusComponent("3DViewer")},{label:"Display Controls",action:()=>n.focusComponent("DisplayControls")},{label:"Inspector",action:()=>n.focusComponent("Inspector")},{label:"Selection Browser",action:()=>n.focusComponent("SelectHighlight")},{label:"Tcl Console",action:()=>n.focusComponent("TclConsole")},{label:"Hierarchy Browser",action:()=>n.focusComponent("Browser")},{label:"Timing",action:()=>n.focusComponent("TimingWidget")},{label:"DRC Viewer",action:()=>n.focusComponent("DRCWidget")},{label:"Clock Tree",action:()=>n.focusComponent("ClockWidget")},{label:"Charts",action:()=>n.focusComponent("ChartsWidget")},{label:"Help",action:()=>n.focusComponent("HelpWidget")},{type:"separator"},{label:"Reset to Default Layout",action:()=>n.resetLayout()}]},{label:"Help",items:[{label:"Keyboard Shortcuts",action:()=>n.focusComponent("HelpWidget")}]}],t=document.getElementById("menu-bar"),i=null,r=new Map;function s(){i&&(i.classList.remove("open"),i=null)}function o(){let l=e.map(h=>({label:h.label,items:h.items.slice()})),u=new Map(l.map(h=>[h.label,h]));function f(h){let p=u.get(h);return p||(p={label:h,items:[]},u.set(h,p),l.push(p)),p}function d(h,p){let m=h.items.find(g=>g.submenu&&g.label===p);return m||(m={label:p,submenu:{label:p,items:[]}},h.items.push(m)),m.submenu}for(let h of n.customMenu||[]){let p=String(h.path||"Custom Scripts").split("/").map(y=>y.trim()).filter(Boolean);p.length===0&&p.push("Custom Scripts");let m=f(p[0]);for(let y=1;yWl(n,h.script,h.echo);m.items.push({label:h.text,shortcut:h.shortcut,action:g});let v=zW(h.shortcut);v&&r.set(v,g)}return l}function a(l,u){for(let f of u){if(f.type==="separator"){let p=document.createElement("div");p.className="menu-separator",l.appendChild(p);continue}let d=document.createElement("div");if(d.className="menu-item",f.submenu){d.classList.add("submenu-item");let p=document.createElement("span");p.textContent=f.label,d.appendChild(p);let m=document.createElement("span");m.className="submenu-arrow",m.textContent="\u25B8",d.appendChild(m);let g=document.createElement("div");g.className="menu-dropdown submenu",a(g,f.submenu.items),d.appendChild(g),l.appendChild(d);continue}if(f.disabled&&d.classList.add("disabled"),f.enabledWhen&&(d._enabledWhen=f.enabledWhen),f.checked){let p=document.createElement("span");p.className="menu-check",p.textContent=f.checked()?"\u2713":"",d.appendChild(p),d._checkedFn=f.checked}let h=document.createElement("span");if(h.textContent=f.label,d.appendChild(h),f.shortcut){let p=document.createElement("span");p.className="shortcut",p.textContent=f.shortcut,d.appendChild(p)}f.action&&d.addEventListener("click",p=>{d.classList.contains("disabled")||(p.stopPropagation(),s(),f.action())}),l.appendChild(d)}}function c(){for(let u of t.querySelectorAll(":scope > .menu-label"))u.remove();let l=t.firstChild;i=null,r.clear();for(let u of o()){let h=function(){for(let p of d.querySelectorAll(".menu-item"))if(p._enabledWhen&&p.classList.toggle("disabled",!p._enabledWhen()),p._checkedFn){let m=p.querySelector(".menu-check");m&&(m.textContent=p._checkedFn()?"\u2713":"")}},f=document.createElement("div");f.className="menu-label",f.textContent=u.label;let d=document.createElement("div");d.className="menu-dropdown",a(d,u.items),f.appendChild(d),f.addEventListener("click",p=>{p.stopPropagation(),i===f?s():(s(),h(),f.classList.add("open"),i=f)}),f.addEventListener("mouseenter",()=>{i&&i!==f&&(s(),h(),f.classList.add("open"),i=f)}),t.insertBefore(f,l)}}c(),n.rebuildMenuBar=c,document.addEventListener("click",s),$W(r)}function $W(n){document.addEventListener("keydown",e=>{if(n.size===0)return;let t=e.target.tagName;if(t==="INPUT"||t==="TEXTAREA"||e.target.isContentEditable)return;let i=n.get(UW(e));i&&(e.preventDefault(),e.stopImmediatePropagation(),i())},!0)}function vM(n,e,t){let i=t==="write_db",r=document.createElement("div");r.className="modal-overlay",r.innerHTML=` - `,document.body.appendChild(r);let s=r.querySelector(".fb-breadcrumb"),o=r.querySelector(".fb-file-list"),a=r.querySelector(".fb-path-input"),c=r.querySelector(".modal-error"),l=r.querySelector(".ok"),u=r.querySelector(".cancel"),f="",d=null;function h(){r.remove()}function p(){let b=a.value.trim();l.disabled=!b}function m(b){s.innerHTML="";let w=b.split("/").filter(Boolean),E=document.createElement("span");E.className="fb-crumb",E.textContent="/",E.addEventListener("click",()=>v("/")),s.appendChild(E);let x="";for(let T of w){x+="/"+T;let I=document.createElement("span");I.className="fb-crumb-sep",I.textContent=" / ",s.appendChild(I);let N=document.createElement("span");N.className="fb-crumb",N.textContent=T;let D=x;N.addEventListener("click",()=>v(D)),s.appendChild(N)}}function g(b){if(o.innerHTML="",d=null,!b||b.length===0){let w=document.createElement("div");w.className="fb-empty",w.textContent="(empty directory)",o.appendChild(w);return}for(let w of b){let E=document.createElement("div");E.className="fb-entry",w.is_dir&&E.classList.add("fb-dir");let x=document.createElement("span");x.className="fb-icon",x.textContent=w.is_dir?"\u{1F4C1}":"\u{1F4C4}",E.appendChild(x);let T=document.createElement("span");if(T.className="fb-name",T.textContent=w.name,E.appendChild(T),!w.is_dir&&w.size!==void 0){let I=document.createElement("span");I.className="fb-size",I.textContent=FW(w.size),E.appendChild(I)}w.is_dir?E.addEventListener("click",()=>{v(f+"/"+w.name)}):(E.addEventListener("click",()=>{let I=o.querySelector(".fb-selected");I&&I.classList.remove("fb-selected"),E.classList.add("fb-selected"),d=w,a.value=f+"/"+w.name,p()}),E.addEventListener("dblclick",()=>{a.value=f+"/"+w.name,p(),y()})),o.appendChild(E)}}async function v(b){c.style.display="none",o.innerHTML='
Loading...
';try{let w=await n.websocketManager.request({type:"list_dir",path:b||""});if(f=w.path,m(w.path),g(w.entries),i){let x=a.value.trim().split("/").pop();x&&!x.includes("/")?a.value=f+"/"+x:a.value=f+"/"}else a.value="",d=null;p()}catch(w){o.innerHTML="",c.textContent=w.message||String(w),c.style.display=""}}async function y(){let b=a.value.trim();if(b){l.disabled=!0,l.textContent="Working...",c.style.display="none";try{let w=await n.websocketManager.request({type:"tcl_eval",cmd:`${t} ${b}`});if(w.is_error){c.textContent=w.output||w.result||"Command failed",c.style.display="",l.disabled=!1,l.textContent=i?"Save":"Open";return}if(h(),t==="read_db"){window.location.reload();return}}catch(w){c.textContent=w.message||"Request failed",c.style.display="",l.disabled=!1,l.textContent=i?"Save":"Open"}}}a.addEventListener("input",p),a.addEventListener("keydown",b=>{if(b.key==="Enter"){let w=a.value.trim();w.endsWith("/")?v(w.replace(/\/+$/,"")||"/"):y()}b.key==="Escape"&&h()}),l.addEventListener("click",y),u.addEventListener("click",h),r.addEventListener("click",b=>{b.target===r&&h()}),v("")}function FW(n){return n<1024?n+" B":n<1024*1024?(n/1024).toFixed(1)+" KB":n<1024*1024*1024?(n/(1024*1024)).toFixed(1)+" MB":(n/(1024*1024*1024)).toFixed(1)+" GB"}function vM(n){let e=document.getElementById("toolbar");if(!e)return;n._toolbarToggleState||(n._toolbarToggleState={});function t(){e.innerHTML="";let i=n.customToolbar||[],r=new Set(i.map(s=>s.key));for(let s of Object.keys(n._toolbarToggleState))r.has(s)||delete n._toolbarToggleState[s];for(let s of i){let o=document.createElement("button");if(o.className="or-btn or-btn-sm toolbar-button",o.dataset.key=s.key,s.tooltip&&(o.title=s.tooltip),s.icon){let a=document.createElement("span");if(a.className="toolbar-icon",/^(data:|https?:|\.?\/)/.test(s.icon)){let c=document.createElement("img");c.src=s.icon,c.alt="",a.appendChild(c)}else a.textContent=s.icon;o.appendChild(a)}if(s.text){let a=document.createElement("span");a.className="toolbar-label",a.textContent=s.text,o.appendChild(a)}s.toggle&&n._toolbarToggleState[s.key]&&o.classList.add("active"),o.addEventListener("click",()=>{if(s.toggle){let a=!n._toolbarToggleState[s.key];n._toolbarToggleState[s.key]=a,o.classList.toggle("active",a),Vl(n,a?s.script:s.script_off,s.echo)}else Vl(n,s.script,s.echo)}),e.appendChild(o)}}return t(),n.rebuildToolbar=t,{rebuild:t}}function wM(n,e=""){let t=document.createElement("div");t.className="modal-overlay",t.innerHTML=` + `,document.body.appendChild(r);let s=r.querySelector(".fb-breadcrumb"),o=r.querySelector(".fb-file-list"),a=r.querySelector(".fb-path-input"),c=r.querySelector(".modal-error"),l=r.querySelector(".ok"),u=r.querySelector(".cancel"),f="",d=null;function h(){r.remove()}function p(){let b=a.value.trim();l.disabled=!b}function m(b){s.innerHTML="";let x=b.split("/").filter(Boolean),E=document.createElement("span");E.className="fb-crumb",E.textContent="/",E.addEventListener("click",()=>v("/")),s.appendChild(E);let w="";for(let T of x){w+="/"+T;let R=document.createElement("span");R.className="fb-crumb-sep",R.textContent=" / ",s.appendChild(R);let F=document.createElement("span");F.className="fb-crumb",F.textContent=T;let O=w;F.addEventListener("click",()=>v(O)),s.appendChild(F)}}function g(b){if(o.innerHTML="",d=null,!b||b.length===0){let x=document.createElement("div");x.className="fb-empty",x.textContent="(empty directory)",o.appendChild(x);return}for(let x of b){let E=document.createElement("div");E.className="fb-entry",x.is_dir&&E.classList.add("fb-dir");let w=document.createElement("span");w.className="fb-icon",w.textContent=x.is_dir?"\u{1F4C1}":"\u{1F4C4}",E.appendChild(w);let T=document.createElement("span");if(T.className="fb-name",T.textContent=x.name,E.appendChild(T),!x.is_dir&&x.size!==void 0){let R=document.createElement("span");R.className="fb-size",R.textContent=GW(x.size),E.appendChild(R)}x.is_dir?E.addEventListener("click",()=>{v(f+"/"+x.name)}):(E.addEventListener("click",()=>{let R=o.querySelector(".fb-selected");R&&R.classList.remove("fb-selected"),E.classList.add("fb-selected"),d=x,a.value=f+"/"+x.name,p()}),E.addEventListener("dblclick",()=>{a.value=f+"/"+x.name,p(),y()})),o.appendChild(E)}}async function v(b){c.style.display="none",o.innerHTML='
Loading...
';try{let x=await n.websocketManager.request({type:"list_dir",path:b||""});if(f=x.path,m(x.path),g(x.entries),i){let w=a.value.trim().split("/").pop();w&&!w.includes("/")?a.value=f+"/"+w:a.value=f+"/"}else a.value="",d=null;p()}catch(x){o.innerHTML="",c.textContent=x.message||String(x),c.style.display=""}}async function y(){let b=a.value.trim();if(b){l.disabled=!0,l.textContent="Working...",c.style.display="none";try{let x=await n.websocketManager.request({type:"tcl_eval",cmd:`${t} ${b}`});if(x.is_error){c.textContent=x.output||x.result||"Command failed",c.style.display="",l.disabled=!1,l.textContent=i?"Save":"Open";return}if(h(),t==="read_db"){window.location.reload();return}}catch(x){c.textContent=x.message||"Request failed",c.style.display="",l.disabled=!1,l.textContent=i?"Save":"Open"}}}a.addEventListener("input",p),a.addEventListener("keydown",b=>{if(b.key==="Enter"){let x=a.value.trim();x.endsWith("/")?v(x.replace(/\/+$/,"")||"/"):y()}b.key==="Escape"&&h()}),l.addEventListener("click",y),u.addEventListener("click",h),r.addEventListener("click",b=>{b.target===r&&h()}),v("")}function GW(n){return n<1024?n+" B":n<1024*1024?(n/1024).toFixed(1)+" KB":n<1024*1024*1024?(n/(1024*1024)).toFixed(1)+" MB":(n/(1024*1024*1024)).toFixed(1)+" GB"}function wM(n){let e=document.getElementById("toolbar");if(!e)return;n._toolbarToggleState||(n._toolbarToggleState={});function t(){e.innerHTML="";let i=n.customToolbar||[],r=new Set(i.map(s=>s.key));for(let s of Object.keys(n._toolbarToggleState))r.has(s)||delete n._toolbarToggleState[s];for(let s of i){let o=document.createElement("button");if(o.className="or-btn or-btn-sm toolbar-button",o.dataset.key=s.key,s.tooltip&&(o.title=s.tooltip),s.icon){let a=document.createElement("span");if(a.className="toolbar-icon",/^(data:|https?:|\.?\/)/.test(s.icon)){let c=document.createElement("img");c.src=s.icon,c.alt="",a.appendChild(c)}else a.textContent=s.icon;o.appendChild(a)}if(s.text){let a=document.createElement("span");a.className="toolbar-label",a.textContent=s.text,o.appendChild(a)}s.toggle&&n._toolbarToggleState[s.key]&&o.classList.add("active"),o.addEventListener("click",()=>{if(s.toggle){let a=!n._toolbarToggleState[s.key];n._toolbarToggleState[s.key]=a,o.classList.toggle("active",a),Wl(n,a?s.script:s.script_off,s.echo)}else Wl(n,s.script,s.echo)}),e.appendChild(o)}}return t(),n.rebuildToolbar=t,{rebuild:t}}function SM(n,e=""){let t=document.createElement("div");t.className="modal-overlay",t.innerHTML=` `,document.body.appendChild(t);function i(s){s.key==="Escape"&&r()}let r=()=>{t.remove(),document.removeEventListener("keydown",i)};return t.addEventListener("click",s=>{s.target===t&&r()}),document.addEventListener("keydown",i),{overlay:t,body:t.querySelector(".modal-body"),errorDiv:t.querySelector(".modal-error"),buttons:t.querySelector(".modal-buttons"),close:r}}function ii(n,e){n.textContent=e,n.style.display=e?"":"none"}function Jo(n,e,{primary:t=!1}={}){let i=document.createElement("button");return i.textContent=e,i.className="or-btn"+(t?" or-btn-primary":""),n.appendChild(i),i}function Xh(n){return"{"+String(n)+"}"}function EM(n){let e=wM("Global Connect","gc-dialog"),t=document.createElement("div");t.className="gc-table",e.body.appendChild(t);let i=document.createElement("div");i.className="gc-form";let r=document.createElement("input");r.placeholder="Instance pattern (regex)",r.value=".*";let s=document.createElement("input");s.placeholder="Pin pattern (regex)";let o=document.createElement("select"),a=document.createElement("select"),c=document.createElement("span");c.innerHTML='',i.append(dr("Instance",r),dr("Pin",s),dr("Net",o),dr("Region",a),c);let l=Jo(i,"Add rule");e.body.appendChild(i);function u(){let p=s.value.trim()!==""&&o.value!=="";for(let m of[r,s])try{new RegExp(m.value),m.classList.remove("gc-invalid")}catch{m.classList.add("gc-invalid"),p=!1}l.disabled=!p}r.addEventListener("input",u),s.addEventListener("input",u),o.addEventListener("change",u);function f(){n.websocketManager.request({type:"global_connect_info"}).then(p=>{t.innerHTML='
InstancePinNetRegion
',(p.rules||[]).forEach(m=>{let g=document.createElement("div");g.className="gc-row",g.innerHTML=`${Hl(m.inst)}${Hl(m.pin)}${Hl(m.net)}${Hl(m.region||"All")}`;let v=document.createElement("button");v.className="or-btn or-btn-sm or-btn-icon",v.textContent="\u2715",v.title="Delete rule",v.addEventListener("click",()=>{n.websocketManager.request({type:"global_connect_delete",inst:m.inst,pin:m.pin,net:m.net,region:m.region||""}).then(f).catch(y=>ii(e.errorDiv,String(y)))}),g.appendChild(v),t.appendChild(g)}),av(o,p.nets||[]),av(a,["All",...p.regions||[]]),u()}).catch(p=>ii(e.errorDiv,String(p)))}l.addEventListener("click",()=>{let p=i.querySelector('input[name="gc-pg"]:checked').value,m=`add_global_connection -net ${Xh(o.value)} -inst_pattern ${Xh(r.value||".*")} -pin_pattern ${Xh(s.value)} -${p}`;a.value&&a.value!=="All"&&(m+=` -region ${Xh(a.value)}`),xM(n,m,e.errorDiv,"Rule added.",f)}),Jo(e.buttons,"Apply (force)").addEventListener("click",()=>{n.websocketManager.request({type:"global_connect_apply",force:!0}).then(p=>{if(!p.had_rules){ii(e.errorDiv,"No global-connect rules defined \u2014 add a rule first.");return}ii(e.errorDiv,`Connected ${p.connected} pin(s).`),n.scheduleRedrawAllLayers&&n.scheduleRedrawAllLayers(),f()}).catch(p=>ii(e.errorDiv,p.message||String(p)))}),Jo(e.buttons,"Clear all").addEventListener("click",()=>xM(n,"clear_global_connect",e.errorDiv,"Rules cleared.",f)),Jo(e.buttons,"Close").addEventListener("click",e.close),f()}function xM(n,e,t,i,r){n.websocketManager.request({type:"tcl_eval",cmd:e}).then(s=>{if(s.is_error){ii(t,s.output||s.result||"Command failed");return}ii(t,i||""),n.scheduleRedrawAllLayers&&n.scheduleRedrawAllLayers(),r&&r()}).catch(s=>ii(t,s.message||String(s)))}function SM(n,e){let t=wM(`Insert Buffer \u2014 ${Hl(e)}`,"buf-dialog"),i=Jo(t.buttons,"Insert",{primary:!0});i.disabled=!0,Jo(t.buttons,"Cancel").addEventListener("click",t.close),n.websocketManager.request({type:"buffer_info",net:e}).then(s=>{if(!s.can_buffer){t.body.textContent=s.error||"This net has multiple drivers and cannot be buffered.";return}zW(n,t,e,s,i)}).catch(s=>{t.body.textContent=String(s)})}function zW(n,e,t,i,r){let s=document.createElement("div");s.className="buf-pins";let o=i.drivers||[],a=i.loads||[],c=new Set;function l(){s.innerHTML="";let p=(m,g)=>{let v=document.createElement("label");v.className="buf-pin";let y=document.createElement("input");y.type="checkbox",y.checked=c.has(m.id),y.addEventListener("change",()=>{if(y.checked){if(g)c.clear();else for(let b of o)c.delete(b.id);c.add(m.id)}else c.delete(m.id);l(),h()}),v.append(y,document.createTextNode(" "+m.label)),s.appendChild(v)};o.forEach(m=>p(m,!0)),a.forEach(m=>p(m,!1))}o.length&&c.add(o[0].id),l();let u=document.createElement("select");av(u,i.masters||[]);let f=document.createElement("input");f.placeholder="Optional: new buffer name";let d=document.createElement("input");d.placeholder="Optional: new net name",e.body.append(dr("Pins to buffer",s),dr("Buffer master",u),dr("Buffer name",f),dr("Net name",d));function h(){r.disabled=c.size===0||!u.value}u.addEventListener("change",h),h(),r.addEventListener("click",()=>{let p=new Set(o.map(v=>v.id)),m=[...c],g=m.some(v=>p.has(v))?"driver":"loads";n.websocketManager.request({type:"insert_buffer",net:t,mode:g,pins:m,master:u.value,buf_name:f.value.trim(),net_name:d.value.trim()}).then(v=>{if(v.is_error||v.ok===!1){ii(e.errorDiv,v.error||v.result||"Insertion failed");return}e.close(),v.inst&&(n.selectedInstanceName=v.inst),n.scheduleRedrawAllLayers&&n.scheduleRedrawAllLayers()}).catch(v=>ii(e.errorDiv,v.message||String(v)))})}function dr(n,e){let t=document.createElement("label");t.className="edit-field";let i=document.createElement("span");return i.textContent=n,t.append(i,e),t}function av(n,e){let t=n.value;n.innerHTML="";for(let i of e){let r=document.createElement("option");r.value=i,r.textContent=i,n.appendChild(r)}e.includes(t)&&(n.value=t)}function Hl(n){return String(n??"").replace(/&/g,"&").replace(//g,">")}var PM="#00ffff",UW="#ffff00",CM="#ffffff",$W=4,Ms=0,cv=1,Yl=2,Kh=class{constructor(e,t,i,r){this._app=e,this._visibility=t,this._updateInspector=i,this._focusComponent=r,this._state=Ms,this._rulers=[],this._nextId=0,this._pt0=null,this._selectedRulerId=null,this._ctrlHeld=!1,this._shiftHeld=!1,this._snapTimer=null,this._lastSnapResult=null,this._snapShapes=null,this._preview=null,e.view?.on("zoom",()=>this._renderRulerShapes())}isActive(){return this._state!==Ms}updateVisibility(){this._renderAll(),this._drawTransient()}_shown(){return this._visibility.rulers!==!1}toggleRulerMode(){this._state===Ms?this._enterFirstPoint():this.cancelRulerBuild()}cancelRulerBuild(){this._state=Ms,this._pt0=null,this._lastSnapResult=null,this._clearTransient(),this._setCursor(!1)}clearAllRulers(){this._rulers=[],this._selectedRulerId=null,this._renderAll(),this._clearTransient(),this._state!==Ms&&this.cancelRulerBuild()}_enterFirstPoint(){this._state=cv,this._pt0=null,this._lastSnapResult=null,this._setCursor(!0)}_enterMeasuring(e){this._state=Yl,this._pt0=e}_toDbu(e){return wn(e[0],e[1],this._app.designScale,this._app.designOriginX,this._app.designOriginY)}_toWorld(e,t){return xn(e,t,this._app.designScale,this._app.designOriginX,this._app.designOriginY)}handleMouseMove(e,t){if(this._state===Ms)return;this._ctrlHeld=t.ctrlKey||t.metaKey,this._shiftHeld=t.shiftKey;let i=this._toDbu(e);this._snapTimer&&clearTimeout(this._snapTimer),this._snapTimer=setTimeout(()=>{this._requestSnap(i.dbuX,i.dbuY)},50)}handleMapClick(e,t){if(this._state===Ms)return;this._ctrlHeld=t.ctrlKey||t.metaKey,this._shiftHeld=t.shiftKey;let i=this._toDbu(e),r=this._getSnappedPoint(i.dbuX,i.dbuY);this._state===cv?this._enterMeasuring(r):this._state===Yl&&(this._createRuler(this._pt0,r),this._state=cv,this._pt0=null,this._clearTransient(),this._lastSnapResult=null)}async _requestSnap(e,t){let i=this._app;if(!i.websocketManager||!i.designScale)return;if(this._ctrlHeld){this._lastSnapResult=null,this._snapShapes=null,this._updatePreview(e,t);return}let s=i.techData?.dbu_per_micron||1e3,o=i.view.getZoom(),a=Math.pow(2,Math.max(0,o)),c=1/(i.designScale*a),l=Math.max(Math.round(10*c),10),u=!0,f=!0;if(this._shiftHeld)u=!0,f=!0;else if(this._state===Yl&&this._pt0){let h=Math.abs(e-this._pt0.x),p=Math.abs(t-this._pt0.y);h>p?(u=!1,f=!0):p>h&&(u=!0,f=!1)}let d={};for(let[h,p]of Object.entries(this._visibility))d[h]=!!p;try{let h=await i.websocketManager.request({type:"snap",dbu_x:e,dbu_y:t,radius:s,point_threshold:l,horizontal:!!u,vertical:!!f,visible_layers:[...i.visibleLayerNames],...d});this._lastSnapResult=h,this._updateSnapIndicator(h),this._updatePreview(e,t)}catch{this._lastSnapResult=null,this._clearSnap()}}_getSnappedPoint(e,t){if(this._ctrlHeld)return{x:e,y:t};let i=this._lastSnapResult,r;if(i?.found&&i.is_point)r={x:i.edge[0][0],y:i.edge[0][1]};else if(i?.found){let s=i.edge;s[0][1]===s[1][1]?r={x:e,y:s[0][1]}:r={x:s[0][0],y:t}}else r={x:e,y:t};if(!this._shiftHeld&&this._state===Yl&&this._pt0){let s=Math.abs(r.x-this._pt0.x),o=Math.abs(r.y-this._pt0.y);sthis._toWorld(r.x,r.y))}}_rulerShapes(e){let t=e.id===this._selectedRulerId,i=Nt(t?UW:PM),{joinPt:r,points:s}=this._rulerPath(e),o=[{kind:"path",points:s,stroke:i,width:2}],a=this._app.view.getZoom(),c=Math.pow(2,Math.max(0,a)),u=8*(1/(this._app.designScale*c)),f=(d,h,p)=>{let m=Math.sqrt(h*h+p*p);if(m===0)return;let g=-p/m,v=h/m;o.push({kind:"path",stroke:i,width:2,points:[this._toWorld(d.x+g*u,d.y+v*u),this._toWorld(d.x-g*u,d.y-v*u)]})};if(r)f(e.pt0,r.x-e.pt0.x,r.y-e.pt0.y),f(e.pt1,e.pt1.x-r.x,e.pt1.y-r.y);else{let d=e.pt1.x-e.pt0.x,h=e.pt1.y-e.pt0.y;f(e.pt0,d,h),f(e.pt1,d,h)}return o}_renderAll(){this._renderRulerShapes(),this._renderRulerLabels()}_renderRulerShapes(){let e=this._app.view;!e||!this._app.designScale||e.setOverlay("rulers",this._shown()?this._rulers.flatMap(t=>this._rulerShapes(t)):null,{order:at.ruler})}_renderRulerLabels(){let e=this._app.view;if(!(!e||!this._app.designScale)&&(e.clearMarkers("ruler-labels"),!!this._shown()))for(let t of this._rulers){let{joinPt:i,points:r}=this._rulerPath(t),s=i?r[1]:[(r[0][0]+r[1][0])/2,(r[0][1]+r[1][1])/2],o=this._computeDistance(t.pt0,t.pt1,t.euclidian);e.addMarker("ruler-labels",t.id,s,this._labelElement(this._formatDistance(o)))}}handleRulerClick(e){let t=this._app.view;if(!t||!this._shown()||this._rulers.length===0)return!1;let i=t.project(e);for(let r of this._rulers){let s=this._rulerPath(r).points.map(o=>t.project(o));for(let o=0;o+1l.id===e);if(!t)return;St(this._app);let i=Math.abs(t.pt1.x-t.pt0.x),r=Math.abs(t.pt1.y-t.pt0.y),s=t.euclidian?Math.sqrt(i*i+r*r):i+r,o=l=>this._app.formatDbu(l,!0),a=l=>this._app.parseDbu(l),c={type:"Ruler",name:t.name,bbox:[Math.min(t.pt0.x,t.pt1.x),Math.min(t.pt0.y,t.pt1.y),Math.max(t.pt0.x,t.pt1.x),Math.max(t.pt0.y,t.pt1.y)],properties:[{name:"Name",value:t.name,editable:!0},{name:"Label",value:t.label||"",editable:!0},{name:"Point 0 - x",value:o(t.pt0.x),editable:!0},{name:"Point 0 - y",value:o(t.pt0.y),editable:!0},{name:"Point 1 - x",value:o(t.pt1.x),editable:!0},{name:"Point 1 - y",value:o(t.pt1.y),editable:!0},{name:"Delta x",value:o(i)},{name:"Delta y",value:o(r)},{name:"Length",value:o(s)},{name:"Euclidian",value:t.euclidian?"True":"False",editable:!0,editor:{type:"bool"}}],onPropertyChange:(l,u)=>{switch(l){case"Name":t.name=u;break;case"Label":t.label=u;break;case"Point 0 - x":{let f=a(u);f!==null&&(t.pt0.x=f);break}case"Point 0 - y":{let f=a(u);f!==null&&(t.pt0.y=f);break}case"Point 1 - x":{let f=a(u);f!==null&&(t.pt1.x=f);break}case"Point 1 - y":{let f=a(u);f!==null&&(t.pt1.y=f);break}case"Euclidian":t.euclidian=u.trim().toLowerCase()==="true";break}this._renderAll(),this._selectRuler(t.id)}};this._updateInspector(c),this._focusComponent("Inspector"),requestAnimationFrame(()=>{let l=this._app.inspectorEl?.querySelector(".inspector-toolbar");if(!l)return;let u=document.createElement("button");u.className="or-btn or-btn-icon",u.title="Delete ruler",u.innerHTML='',u.addEventListener("click",()=>{this.deleteRuler(e)}),l.appendChild(u)})}deleteRuler(e){let t=this._rulers.findIndex(i=>i.id===e);t!==-1&&(this._rulers.splice(t,1),this._renderAll(),this._selectedRulerId===e&&(this._selectedRulerId=null,this._updateInspector(null)))}_getManhattanJoinPt(e,t){return{x:t.x,y:e.y}}_computeDistance(e,t,i=!0){let r=Math.abs(t.x-e.x),s=Math.abs(t.y-e.y);return i?Math.sqrt(r*r+s*s):r+s}_formatDistance(e){return this._app.formatDistance(e)}_setCursor(e){this._app.view?.setCursorMode("ruler",e)}_clearTransient(){this._preview=null,this._snapShapes=null,this._drawTransient()}_clearSnap(){this._snapShapes=null,this._drawTransient()}};function GW(n,e,t){let i=t[0]-e[0],r=t[1]-e[1],s=i*i+r*r,o=s>0?((n[0]-e[0])*i+(n[1]-e[1])*r)/s:0;return o=Math.max(0,Math.min(1,o)),Math.hypot(n[0]-(e[0]+o*i),n[1]-(e[1]+o*r))}var Qh="label-handles",TM=3,Jh=class{constructor(e,t,i,r){this._app=e,this._visibility=t,this._updateInspector=i,this._focusComponent=r,this._labels=[],this._anchors=[],this._mode=!1,this._selectedName=null}isActive(){return this._mode}updateVisibility(){this._app.view?.setMarkerGroupVisible(Qh,!!this._visibility.labels)}toggleLabelMode(){this._mode=!this._mode,this._setCursor(this._mode)}cancelLabelMode(){this._mode=!1,this._setCursor(!1)}_setCursor(e){this._app.view?.setCursorMode("label",e)}_wm(){return this._app.websocketManager}_applyLabels(e){this._labels=e||[],this._renderHandles()}_refresh(e){this._applyLabels(e&&e.labels),this._app.refreshOverlay()}applyRemoteLabels(e){this._applyLabels(e),this._selectedName&&!this._labels.some(t=>t.name===this._selectedName)&&(this._selectedName=null,this._updateInspector(null),this._renderHandles()),this._app.refreshOverlay()}_updateLabel(e,t){return this._wm().request({type:"update_label",name:e,...t})}async reload(){let e=this._wm();if(e)try{let t=await e.request({type:"list_labels"});this._anchors=t.anchors||[],this._applyLabels(t.labels)}catch{this._applyLabels([])}}async handleMapClick(e,t){let i=window.prompt("Label text:");if(this._mode=!1,this._setCursor(!1),!!i)try{let r=await this._wm().request({type:"add_label",x:Math.round(e),y:Math.round(t),text:i});this._refresh(r)}catch(r){console.error("add_label failed:",r)}}_renderHandles(){let e=this._app.view;if(!e)return;e.clearMarkers(Qh);let t=this._app;if(t.designScale)for(let i of this._labels){let r=document.createElement("div");r.className="label-handle"+(i.name===this._selectedName?" label-handle-selected":""),r.title=i.text,this._installDrag(r,i),e.addMarker(Qh,i.name,xn(i.x,i.y,t.designScale,t.designOriginX,t.designOriginY),r,{center:!0})}}_installDrag(e,t){let i=this._app.view,r=a=>{let c=i.getContainer().getBoundingClientRect();return i.unproject([a.clientX-c.left,a.clientY-c.top])},s=null;e.addEventListener("pointerdown",a=>{a.button===0&&(a.stopPropagation(),a.preventDefault(),e.setPointerCapture?.(a.pointerId),s={x:a.clientX,y:a.clientY,moved:!1})}),e.addEventListener("pointermove",a=>{s&&((Math.abs(a.clientX-s.x)>TM||Math.abs(a.clientY-s.y)>TM)&&(s.moved=!0),s.moved&&i.moveMarker(Qh,t.name,r(a)))});let o=(a,c)=>{if(!s)return;let l=s;if(s=null,e.releasePointerCapture?.(a.pointerId),!c)this._renderHandles();else if(!l.moved)this._select(t.name);else{let u=this._app,[f,d]=r(a),{dbuX:h,dbuY:p}=wn(f,d,u.designScale,u.designOriginX,u.designOriginY);this._commitMove(t,Math.round(h),Math.round(p))}};e.addEventListener("pointerup",a=>o(a,!0)),e.addEventListener("pointercancel",a=>o(a,!1)),e.addEventListener("click",a=>a.stopPropagation())}async _commitMove(e,t,i){try{let r=await this._updateLabel(e.name,{x:t,y:i,text:e.text,size:e.size||0,anchor:e.anchor||"center",color:e.color});this._refresh(r)}catch(r){console.error("move label failed:",r)}}_select(e){this._selectedName=e,this._renderHandles();let t=this._labels.find(s=>s.name===e);if(!t)return;let i=s=>this._app.formatDbu(s,!0),r={type:"Label",name:t.name,bbox:[t.x,t.y,t.x,t.y],properties:[{name:"Name",value:t.name},{name:"Text",value:t.text,editable:!0},{name:"x",value:i(t.x)},{name:"y",value:i(t.y)},{name:"Font size",value:String(t.size||0),editable:!0},{name:"Anchor",value:t.anchor||"center",editable:!0,editor:{type:"list",options:this._anchors}}],onPropertyChange:(s,o)=>{let a={text:t.text,size:t.size||0,anchor:t.anchor||"center"};s==="Text"?a.text=o:s==="Font size"?a.size=parseInt(o,10)||0:s==="Anchor"&&(a.anchor=o.trim()),this._edit(t,a)}};this._updateInspector(r),this._focusComponent("Inspector"),requestAnimationFrame(()=>{let s=this._app.inspectorEl?.querySelector(".inspector-toolbar");if(!s||s.querySelector(".delete-label-btn"))return;let o=document.createElement("button");o.className="or-btn or-btn-icon delete-label-btn",o.title="Delete label",o.innerHTML='',o.addEventListener("click",()=>this.deleteLabel(e)),s.appendChild(o)})}async _edit(e,t){try{let i=await this._updateLabel(e.name,{x:e.x,y:e.y,text:t.text,size:t.size,anchor:t.anchor,color:e.color});this._refresh(i),this._select(e.name)}catch(i){console.error("edit label failed:",i)}}async deleteLabel(e){try{let t=await this._wm().request({type:"delete_label",name:e});this._selectedName===e&&(this._selectedName=null,this._updateInspector(null)),this._refresh(t)}catch(t){console.error("delete_label failed:",t)}}async clearAllLabels(){try{let e=await this._wm().request({type:"clear_labels"});this._selectedName=null,this._refresh(e)}catch(e){console.error("clear_labels failed:",e)}}};var LM="Select an instance in the layout to view its schematic.",ep=class{constructor(e,t){this.container=e,this.appState=t,this.element=document.createElement("div"),this.element.className="schematic-widget",this.element.style.cssText="width:100%; height:100%; display:flex; flex-direction:column; background:var(--bg-panel); color:var(--fg-primary); overflow:hidden;",this.controls=document.createElement("div"),this.controls.style.cssText="padding:4px 8px; background:var(--bg-header); border-bottom:1px solid var(--border);flex-shrink:0; display:flex; align-items:center; gap:8px; flex-wrap:wrap;",this.controls.innerHTML='',this.element.appendChild(this.controls),this.svgContainer=document.createElement("div"),this.svgContainer.style.cssText="flex:1; overflow:hidden; position:relative; cursor:grab; background:var(--bg-main);",this.element.appendChild(this.svgContainer),this.container.element.appendChild(this.element),this.controls.querySelector("#schematic-refresh").addEventListener("click",()=>this.refresh()),this.controls.querySelector("#schematic-fit").addEventListener("click",()=>this.fitView()),this.controls.querySelector("#schematic-zoom-in").addEventListener("click",()=>this._zoomStep(1.5)),this.controls.querySelector("#schematic-zoom-out").addEventListener("click",()=>this._zoomStep(1/1.5)),this.controls.querySelector("#schematic-select").addEventListener("click",()=>this._toggleSelectMode()),this.controls.querySelector("#schematic-zoom-to").addEventListener("click",()=>this._zoomToSelected()),this.controls.querySelector("#schematic-save-svg").addEventListener("click",()=>this._exportSvg()),this.controls.querySelector("#schematic-save-png").addEventListener("click",()=>this._exportPng()),this.controls.querySelector("#schematic-copy").addEventListener("click",()=>this._copyImage()),this.appState.schematicWidget=this,this.netlistsvg=null,this.skin=null,this._svgEl=null,this._scale=1,this._panX=0,this._panY=0,this._selectMode=!1,this._selectedCell=null,this._svgIdToInstName=new Map,this._setupPanZoom(),this.initNetlistSVG()}_setupPanZoom(){let e=this.svgContainer,t=!1,i,r,s,o;e.addEventListener("wheel",a=>{if(!this._svgEl)return;a.preventDefault();let c=a.deltaY<0?1.2:1/1.2,l=e.getBoundingClientRect(),u=a.clientX-l.left,f=a.clientY-l.top;this._panX=u+(this._panX-u)*c,this._panY=f+(this._panY-f)*c,this._scale*=c,this._applyTransform()},{passive:!1}),e.addEventListener("mousedown",a=>{if(!(!this._svgEl||a.button!==0)){if(this._selectMode){this._handleSelectClick(a);return}t=!0,i=a.clientX,r=a.clientY,s=this._panX,o=this._panY,e.style.cursor="grabbing",a.preventDefault()}}),window.addEventListener("mousemove",a=>{t&&(this._panX=s+(a.clientX-i),this._panY=o+(a.clientY-r),this._applyTransform())}),window.addEventListener("mouseup",()=>{t&&(t=!1,e.style.cursor=this._selectMode?"default":"grab")})}_zoomStep(e){if(!this._svgEl)return;let t=this.svgContainer.getBoundingClientRect(),i=t.width/2,r=t.height/2;this._panX=i+(this._panX-i)*e,this._panY=r+(this._panY-r)*e,this._scale*=e,this._applyTransform()}_toggleSelectMode(){this._selectMode=!this._selectMode;let e=this.controls.querySelector("#schematic-select");this._selectMode?(e.style.background="var(--accent)",e.style.color="var(--fg-white)",this.svgContainer.style.cursor="default"):(e.style.background="",e.style.color="",this.svgContainer.style.cursor="grab",this._clearCellHighlight())}_handleSelectClick(e){if(!this._svgEl)return;let t=e.target,i=null;for(;t&&t!==this._svgEl;){if(t.tagName==="g"&&t.id&&this._svgIdToInstName.has(t.id)){i=t;break}t=t.parentElement}if(this._clearCellHighlight(),!i)return;let r=this._svgIdToInstName.get(i.id);try{let s=i.getBBox(),o=3,a=document.createElementNS("http://www.w3.org/2000/svg","rect");a.setAttribute("x",s.x-o),a.setAttribute("y",s.y-o),a.setAttribute("width",s.width+o*2),a.setAttribute("height",s.height+o*2),a.setAttribute("fill","none"),a.setAttribute("stroke","#e05a00"),a.setAttribute("stroke-width","1.5"),a.setAttribute("rx","3"),a.id="_schematic_highlight",i.appendChild(a),this._selectedCell=i}catch{}this.controls.querySelector("#schematic-zoom-to").disabled=!1,this.setStatus(`Selected: ${r}`),this._fetchInspect(r)}_fetchInspect(e){let t=this.appState.websocketManager;if(!t)return;console.log("[Schematic] inspect:",e);let i=St(this.appState);t.request({type:"schematic_inspect",inst_name:e,use_dbu:this.appState.showDbu}).then(r=>{Dt(this.appState,i)&&(this.appState.updateInspector&&this.appState.updateInspector(r),this.appState.focusComponent&&this.appState.focusComponent("Inspector"),this.appState.refreshOverlay&&this.appState.refreshOverlay())}).catch(r=>{console.error("schematic_inspect failed:",r),this.setStatus(`Inspect error: ${r}`)})}_clearCellHighlight(){if(this._svgEl){let e=this._svgEl.querySelector("#_schematic_highlight");e&&e.remove()}this._selectedCell=null,this.controls.querySelector("#schematic-zoom-to").disabled=!0}_zoomToSelected(){if(!this._selectedCell||!this._svgEl)return;let e=this.svgContainer.getBoundingClientRect(),t=this._selectedCell.getBoundingClientRect(),i=(t.left-e.left-this._panX)/this._scale,r=(t.top-e.top-this._panY)/this._scale,s=t.width/this._scale,o=t.height/this._scale,a=Math.min(e.width/s,e.height/o)*.9;this._scale=a,this._panX=e.width/2-(i+s/2)*a,this._panY=e.height/2-(r+o/2)*a,this._applyTransform()}_applyTransform(){this._svgEl&&(this._svgEl.style.transform=`translate(${this._panX}px, ${this._panY}px) scale(${this._scale})`,this._svgEl.style.transformOrigin="0 0")}fitView(){if(!this._svgEl)return;let e=this.svgContainer.getBoundingClientRect();if(e.width===0||e.height===0)return;let t=this._svgEl.viewBox&&this._svgEl.viewBox.baseVal,i=t&&t.width||this._svgEl.clientWidth||1,r=t&&t.height||this._svgEl.clientHeight||1;this._scale=Math.min(e.width/i,e.height/r)*.95,this._panX=(e.width-i*this._scale)/2,this._panY=(e.height-r*this._scale)/2,this._applyTransform()}initNetlistSVG(){this.netlistsvg=globalThis.netlistsvg,this.skin=globalThis.openroadSkin,this._netlistsvgReady=!!(this.netlistsvg&&this.skin),this._netlistsvgReady&&console.log("NetlistSVG ready."),this.setStatus(this._unreadyStatus()??LM)}_unreadyStatus(){return this._netlistsvgReady?null:ue(this.appState)?"The schematic is not available in saved reports.":"Init error: netlistsvg or its skin is missing from the page."}syncCone(e={}){let t=this.controls.querySelector("#schematic-fanin-depth"),i=this.controls.querySelector("#schematic-fanout-depth"),r=(s,o,a)=>{if(!s)return;let c=parseInt(s.max,10)||10;o===!1?s.value=0:a!==void 0&&(s.value=a>0?Math.min(a,c):c)};r(t,e.fanin,e.fanin_depth),r(i,e.fanout,e.fanout_depth),this.refresh(),this.appState.focusComponent&&this.appState.focusComponent("SchematicWidget")}refresh(){if(!this._netlistsvgReady){this.setStatus(this._unreadyStatus());return}let e=this.appState.selectedInstanceName;if(!e){this.setStatus(LM);return}let t=this.appState.websocketManager;if(!t){this.setStatus("Waiting for server connection\u2026");return}this.setStatus(`Loading schematic for ${e}\u2026`);let i=parseInt(this.controls.querySelector("#schematic-fanin-depth").value,10),r=parseInt(this.controls.querySelector("#schematic-fanout-depth").value,10),s=isNaN(i)?1:i,o=isNaN(r)?1:r;t.readyPromise.then(()=>{t.request({type:"schematic_cone",inst_name:e,fanin_depth:s,fanout_depth:o}).then(a=>{let c=a.modules&&a.modules.top&&a.modules.top.cells;if(!c||Object.keys(c).length===0){this.setStatus("No cells found for selected instance.");return}this.renderNetlist(a)}).catch(a=>{this.setStatus(`Error: ${a}`)})})}setStatus(e){this.controls.querySelector("#schematic-status").textContent=e}_exportSvg(){if(!this._svgEl){this.setStatus("No schematic to export.");return}let e=tv(this._svgEl);tM(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),"schematic.svg")}async _exportPng(){if(!this._svgEl){this.setStatus("No schematic to export.");return}try{let e=await nv(this._svgEl,2);Ts(e,"schematic.png")}catch{this.setStatus("PNG export failed.")}}async _copyImage(){if(!this._svgEl){this.setStatus("No schematic to export.");return}try{let e=await nv(this._svgEl,2),t=await Nh(e);this.setStatus(t?"Schematic copied to clipboard.":"Clipboard not available.")}catch{this.setStatus("Copy failed.")}}async renderNetlist(e){try{this.setStatus("Rendering\u2026"),typeof window<"u"&&(window.__lastSchematic=e);let t=YW(e),i,r=this.netlistsvg.render(this.skin,t);if(r&&typeof r.then=="function"?i=await r:i=await new Promise((a,c)=>{this.netlistsvg.render(this.skin,t,(l,u)=>{l?c(l):a(u)})}),typeof i!="string"||!i.includes("requestAnimationFrame(()=>this.fitView()));let o=Object.keys(e.modules.top.cells).length;this.setStatus(`${o} cell${o!==1?"s":""}`)}catch(t){console.error("NetlistSVG render failed:",t),this.setStatus(`Render error: ${t.message||t}`)}}_applyPinLabels(e){if(!this._svgEl)return;let t="http://www.w3.org/2000/svg",i="https://github.com/nturley/netlistsvg",r=e.modules&&e.modules.top&&e.modules.top.cells||{},s=(o,a)=>o.getAttribute("s:"+a)??o.getAttributeNS(i,a);for(let[o,a]of Object.entries(r)){let c=a.port_labels;if(!c)continue;let l=this._svgEl.querySelector("#"+CSS.escape("cell_"+o))||this._svgEl.querySelector("#"+CSS.escape(o));if(!l)continue;let u=a.port_directions||{};for(let f of Array.from(l.children)){if(f.tagName!=="g")continue;let d=s(f,"pid");if(!d||!(d in c))continue;let h=parseFloat(s(f,"x")),p=parseFloat(s(f,"y"));if(!isFinite(h)||!isFinite(p))continue;let m=document.createElementNS(t,"text");u[d]==="input"?(m.setAttribute("class","inputPortLabel"),m.setAttribute("x",h-3)):m.setAttribute("x",h+4),m.setAttribute("y",p-4),m.setAttribute("style","font-size:5px"),m.setAttribute("pointer-events","none"),m.textContent=c[d],l.appendChild(m)}}}_scopeSkinStyles(){if(!this._svgEl)return;let e=".schematic-widget",t=i=>{for(let r of i)r.selectorText?r.selectorText=VW(r.selectorText,e):r.cssRules&&t(r.cssRules)};for(let i of this._svgEl.querySelectorAll("style")){let r=i.sheet;if(r)try{t(r.cssRules)}catch{continue}}}};function VW(n,e){return n.split(",").map(t=>{let i=t.trim();if(!i)return"";let r=i.charAt(e.length);return i.startsWith(e)&&(r===""||!/[\w-]/.test(r))?i:`${e} ${i}`}).filter(Boolean).join(", ")}var MM={and:"$_AND_",nand:"$_NAND_",or:"$_OR_",nor:"$_NOR_",xor:"$_XOR_",xnor:"$_XNOR_",not:"$_NOT_",buf:"$_BUF_"},WW=new Set(["aoi21","aoi22","aoi211","aoi221","aoi222","aoi33","oai21","oai22","oai211","oai221","oai222","oai33"]),jW=new Set(["and3","and4","or3","or4","nand3","nand4","nor3","nor4"]),AM=["A","B","C","D","E","F"];function HW(n){let e=n&&n.gate_kind;if(!e)return n;let t=n.port_directions||{},i=null,r=[];for(let[f,d]of Object.entries(t))d==="output"&&i===null?i=f:d==="input"&&r.push(f);let s,o={};if(e==="aoi"||e==="oai"){let f=Array.isArray(n.gate_terms)?n.gate_terms:[];if(!f.length)return n;let d=f.map(m=>m.length);if(s=e+d.slice().sort((m,g)=>g-m).join(""),!WW.has(s))return n;let h=f.map(m=>m.slice()).sort((m,g)=>m.length-g.length),p=0;for(let m of h)for(let g of m)o[g]=AM[p]||"I"+p,p++}else{let f=r.length;if(e==="not"||e==="buf")s=MM[e];else if(f<=2)s=MM[e];else if(s=e+f,!jW.has(s))return n;if(!s)return n;r.forEach((d,h)=>{o[d]=AM[h]||"I"+h})}i!==null&&(o[i]="Y");let a=n.connections||{},c={},l={};for(let[f,d]of Object.entries(a))o[f]&&(c[o[f]]=d);for(let[f,d]of Object.entries(t))o[f]&&(l[o[f]]=d);let u={};for(let[f,d]of Object.entries(o))u[d]=f;return{...n,type:s,connections:c,port_directions:l,port_labels:u}}function YW(n){let e=n&&n.modules&&n.modules.top;if(!e||!e.cells)return n;let t={};for(let[i,r]of Object.entries(e.cells))t[i]=HW(r);return{...n,modules:{...n.modules,top:{...e,cells:t}}}}var tp=class{constructor(e,t,i){this._app=e,this._redrawAllLayers=t,this._refreshOverlay=i||t,this._categories=[],this._activeCategory="",this._markerTree=null,this._expandedNodes=new Set,this._build(),this._app.websocketManager.readyPromise.then(()=>this.refresh())}_build(){let e=document.createElement("div");e.className="drc-widget";let t=document.createElement("div");t.className="drc-toolbar",this._categorySelect=document.createElement("select"),this._categorySelect.className="drc-category-select",t.appendChild(this._categorySelect),this._loadBtn=document.createElement("button"),this._loadBtn.className="or-btn or-btn-sm",this._loadBtn.textContent="Load...",t.appendChild(this._loadBtn),e.appendChild(t),this._infoBar=document.createElement("div"),this._infoBar.className="drc-info-bar",e.appendChild(this._infoBar),this._treeContainer=document.createElement("div"),this._treeContainer.className="drc-tree-container",e.appendChild(this._treeContainer),this.element=e,this._bindEvents()}_bindEvents(){this._categorySelect.addEventListener("change",()=>{this._activeCategory=this._categorySelect.value,this._loadMarkers()}),this._loadBtn.addEventListener("click",()=>{this._showLoadDialog()})}_loadCategories(){return this._app.websocketManager.request({type:"drc_categories"}).then(e=>{this._categories=e.categories||[],this._renderCategorySelect()}).catch(e=>{console.error("Failed to load DRC categories:",e)})}refresh(){this._loadCategories().then(()=>{!this._activeCategory&&this._categories.length>0&&(this._activeCategory=this._categories[0].name,this._categorySelect.value=this._activeCategory),this._activeCategory&&this._loadMarkers()})}_renderCategorySelect(){let e=this._categorySelect,t=e.value;e.innerHTML="";let i=document.createElement("option");i.value="",i.textContent="(none)",e.appendChild(i);for(let r of this._categories){let s=document.createElement("option");s.value=r.name,s.textContent=`${r.name} (${r.count})`,e.appendChild(s)}this._activeCategory&&this._categories.some(r=>r.name===this._activeCategory)?e.value=this._activeCategory:t&&this._categories.some(r=>r.name===t)?(e.value=t,this._activeCategory=t):this._activeCategory=""}_loadMarkers(){if(!this._activeCategory){this._markerTree=null,this._treeContainer.innerHTML="",this._infoBar.textContent="",this._refreshOverlay();return}this._treeContainer.innerHTML='
Loading...
',this._app.websocketManager.request({type:"drc_markers",category:this._activeCategory}).then(e=>{this._markerTree=e,this._renderTree(),this._refreshOverlay()}).catch(e=>{this._treeContainer.innerHTML="";let t=document.createElement("div");t.className="drc-error",t.textContent=`Error: ${e}`,this._treeContainer.appendChild(t),console.error("Failed to load DRC markers:",e)})}_renderTree(){if(this._treeContainer.innerHTML="",!this._markerTree)return;if(this._markerTree.error){let o=document.createElement("div");o.className="drc-error",o.textContent=this._markerTree.error,this._treeContainer.appendChild(o);return}let e=this._markerTree.total_count||0;this._infoBar.textContent=`${e} total violation${e!==1?"s":""}`;let t=this._markerTree.name||this._activeCategory,i=this._markerTree.subcategories||[],r=this._markerTree.markers||[];if(i.length===0&&r.length===0){this._treeContainer.innerHTML='
No violations
';return}let s=document.createElement("div");s.className="drc-tree",r.length>0&&s.appendChild(this._buildCategoryNode({name:t||"Markers",count:r.length,markers:r},[]));for(let o of i)s.appendChild(this._buildCategoryNode(o,[t]));this._treeContainer.appendChild(s)}_buildCategoryNode(e,t=[]){let i=[...t,e.name],r=document.createElement("div");r.className="drc-tree-node";let s=document.createElement("div");s.className="drc-tree-header";let o=document.createElement("span");o.className="drc-toggle";let a=e.subcategories&&e.subcategories.length>0||e.markers&&e.markers.length>0,c=JSON.stringify(i),l=this._expandedNodes.has(c);o.textContent=a?l?"\u25BC":"\u25B6":" ",s.appendChild(o);let u=document.createElement("input");u.type="checkbox",u.checked=this._allMarkersVisible(e),u.className="drc-visibility-check",u.addEventListener("change",p=>{p.stopPropagation(),this._toggleCategoryVisibility(e,u.checked,i)}),s.appendChild(u);let f=document.createElement("span");f.className="drc-category-label",f.textContent=e.name,s.appendChild(f);let d=document.createElement("span");d.className="drc-count",d.textContent=`${e.count} markers`,s.appendChild(d),r.appendChild(s);let h=document.createElement("div");if(h.className="drc-tree-children",h.style.display=l?"":"none",e.subcategories)for(let p of e.subcategories)h.appendChild(this._buildCategoryNode(p,i));if(e.markers)for(let p of e.markers)h.appendChild(this._buildMarkerNode(p));return r.appendChild(h),a&&(s.addEventListener("click",p=>{if(p.target===u)return;let m=h.style.display!=="none";h.style.display=m?"none":"",o.textContent=m?"\u25B6":"\u25BC",m?this._expandedNodes.delete(c):this._expandedNodes.add(c)}),s.style.cursor="pointer"),r}_buildMarkerNode(e){let t=document.createElement("div");t.className="drc-marker-row",t.dataset.markerId=e.id,e.visited||t.classList.add("drc-unvisited");let i=document.createElement("input");i.type="checkbox",i.checked=e.visible,i.className="drc-visibility-check",i.addEventListener("change",o=>{o.stopPropagation(),e.visible=i.checked,this._updateMarker(e.id,"visible",i.checked)}),t.appendChild(i);let r=document.createElement("span");r.className="drc-marker-index",r.textContent=e.index,t.appendChild(r);let s=document.createElement("span");if(s.className="drc-marker-name",s.textContent=e.name,e.layer&&(s.title=`Layer: ${e.layer}`),t.appendChild(s),e.layer){let o=document.createElement("span");o.className="drc-layer-badge",o.textContent=e.layer,t.appendChild(o)}return t.addEventListener("click",o=>{o.target!==i&&this._highlightMarker(e)}),t.addEventListener("dblclick",o=>{o.target!==i&&this._highlightMarker(e,!0)}),t}highlightMarkerById(e,t=!1){let i=this._findMarkerById(e);i&&this._highlightMarker(i,t)}_findMarkerById(e){let t=i=>{if(!i)return null;if(i.markers){for(let r of i.markers)if(r.id===e)return r}if(i.subcategories)for(let r of i.subcategories){let s=t(r);if(s)return s}return null};return t(this._markerTree)}_highlightMarker(e,t=!1){this._app.websocketManager.request({type:"drc_highlight",marker_id:e.id,open_inspector:t}).then(i=>{if(i.ok&&i.bbox){e.visited=!0;let r=this._treeContainer.querySelector(`.drc-marker-row[data-marker-id="${e.id}"]`);r&&r.classList.remove("drc-unvisited"),this._zoomToBBox(i.bbox),this._refreshOverlay(),t&&(i.select_id!=null&&this._app.navigateInspector&&this._app.navigateInspector(i.select_id),this._app.focusComponent&&this._app.focusComponent("Inspector"))}}).catch(i=>{console.error("Failed to highlight DRC marker:",i)})}_zoomToBBox(e){if(!this._app.designScale||!this._app.view)return;let[t,i,r,s]=e,o=r-t,a=s-i,l=10*this._app.getDbuPerMicron(),u=2*Math.max(o,a),f=Math.min(l,u);this._app.view.fitWorldRect(Ot(t-f,i-f,r+f,s+f,this._app.designScale,this._app.designOriginX,this._app.designOriginY))}_updateMarker(e,t,i){this._app.websocketManager.request({type:"drc_update_marker",marker_id:e,field:t,value:!!i}).then(()=>{this._refreshOverlay(),t==="visible"&&(this._update3DHighlights(),i&&this._flashHighlight())}).catch(r=>{console.error("Failed to update DRC marker:",r)})}_flashHighlight(){this._app.view?.flashTiles()}_update3DHighlights(){let e=this._app.threeDViewerWidget;if(!e)return;let t=[];this._collectVisibleMarkers(this._markerTree,t),t.length>0?e.highlightDRC(t):e.clearHighlightDRC()}_collectVisibleMarkers(e,t){if(e){if(e.markers)for(let i of e.markers)i.visible&&t.push(i);if(e.subcategories)for(let i of e.subcategories)this._collectVisibleMarkers(i,t)}}_setMarkersVisible(e,t){if(e){if(e.markers)for(let i of e.markers)i.visible=t;if(e.subcategories)for(let i of e.subcategories)this._setMarkersVisible(i,t)}}_snapshotMarkerVisibility(e,t=new Map){if(!e)return t;if(e.markers)for(let i of e.markers)t.set(i.id,i.visible);if(e.subcategories)for(let i of e.subcategories)this._snapshotMarkerVisibility(i,t);return t}_restoreMarkerVisibility(e,t){if(e){if(e.markers)for(let i of e.markers)t.has(i.id)&&(i.visible=t.get(i.id));if(e.subcategories)for(let i of e.subcategories)this._restoreMarkerVisibility(i,t)}}_allMarkersVisible(e){if(e.markers){for(let t of e.markers)if(!t.visible)return!1}if(e.subcategories){for(let t of e.subcategories)if(!this._allMarkersVisible(t))return!1}return!0}_toggleCategoryVisibility(e,t,i){let r=this._snapshotMarkerVisibility(e);this._setMarkersVisible(e,t),this._renderTree(),this._app.websocketManager.request({type:"drc_update_category_visibility",category:e.name,path:i||[e.name],visible:!!t}).then(()=>{this._refreshOverlay(),this._update3DHighlights(),t&&this._flashHighlight()}).catch(s=>{console.error("Failed to update category visibility:",s),this._restoreMarkerVisibility(e,r),this._renderTree()})}_showLoadDialog(){new lv(this._app,t=>{this._activeCategory=t,this._loadCategories().then(()=>{this._categorySelect.value=this._activeCategory,this._loadMarkers()})}).open()}selectCategory(e){this._activeCategory=e,this._categorySelect.value=e,this._loadMarkers()}},lv=class{constructor(e,t){this._app=e,this._onLoaded=t,this._currentPath="",this._disposers=[],this._closed=!1}open(){this._overlay=document.createElement("div"),this._overlay.className="modal-overlay",this._overlay.innerHTML=` + `,document.body.appendChild(t);function i(s){s.key==="Escape"&&r()}let r=()=>{t.remove(),document.removeEventListener("keydown",i)};return t.addEventListener("click",s=>{s.target===t&&r()}),document.addEventListener("keydown",i),{overlay:t,body:t.querySelector(".modal-body"),errorDiv:t.querySelector(".modal-error"),buttons:t.querySelector(".modal-buttons"),close:r}}function ai(n,e){n.textContent=e,n.style.display=e?"":"none"}function Jo(n,e,{primary:t=!1}={}){let i=document.createElement("button");return i.textContent=e,i.className="or-btn"+(t?" or-btn-primary":""),n.appendChild(i),i}function Kh(n){return"{"+String(n)+"}"}function PM(n){let e=SM("Global Connect","gc-dialog"),t=document.createElement("div");t.className="gc-table",e.body.appendChild(t);let i=document.createElement("div");i.className="gc-form";let r=document.createElement("input");r.placeholder="Instance pattern (regex)",r.value=".*";let s=document.createElement("input");s.placeholder="Pin pattern (regex)";let o=document.createElement("select"),a=document.createElement("select"),c=document.createElement("span");c.innerHTML='',i.append(pr("Instance",r),pr("Pin",s),pr("Net",o),pr("Region",a),c);let l=Jo(i,"Add rule");e.body.appendChild(i);function u(){let p=s.value.trim()!==""&&o.value!=="";for(let m of[r,s])try{new RegExp(m.value),m.classList.remove("gc-invalid")}catch{m.classList.add("gc-invalid"),p=!1}l.disabled=!p}r.addEventListener("input",u),s.addEventListener("input",u),o.addEventListener("change",u);function f(){n.websocketManager.request({type:"global_connect_info"}).then(p=>{t.innerHTML='
InstancePinNetRegion
',(p.rules||[]).forEach(m=>{let g=document.createElement("div");g.className="gc-row",g.innerHTML=`${Yl(m.inst)}${Yl(m.pin)}${Yl(m.net)}${Yl(m.region||"All")}`;let v=document.createElement("button");v.className="or-btn or-btn-sm or-btn-icon",v.textContent="\u2715",v.title="Delete rule",v.addEventListener("click",()=>{n.websocketManager.request({type:"global_connect_delete",inst:m.inst,pin:m.pin,net:m.net,region:m.region||""}).then(f).catch(y=>ai(e.errorDiv,String(y)))}),g.appendChild(v),t.appendChild(g)}),cv(o,p.nets||[]),cv(a,["All",...p.regions||[]]),u()}).catch(p=>ai(e.errorDiv,String(p)))}l.addEventListener("click",()=>{let p=i.querySelector('input[name="gc-pg"]:checked').value,m=`add_global_connection -net ${Kh(o.value)} -inst_pattern ${Kh(r.value||".*")} -pin_pattern ${Kh(s.value)} -${p}`;a.value&&a.value!=="All"&&(m+=` -region ${Kh(a.value)}`),EM(n,m,e.errorDiv,"Rule added.",f)}),Jo(e.buttons,"Apply (force)").addEventListener("click",()=>{n.websocketManager.request({type:"global_connect_apply",force:!0}).then(p=>{if(!p.had_rules){ai(e.errorDiv,"No global-connect rules defined \u2014 add a rule first.");return}ai(e.errorDiv,`Connected ${p.connected} pin(s).`),n.scheduleRedrawAllLayers&&n.scheduleRedrawAllLayers(),f()}).catch(p=>ai(e.errorDiv,p.message||String(p)))}),Jo(e.buttons,"Clear all").addEventListener("click",()=>EM(n,"clear_global_connect",e.errorDiv,"Rules cleared.",f)),Jo(e.buttons,"Close").addEventListener("click",e.close),f()}function EM(n,e,t,i,r){n.websocketManager.request({type:"tcl_eval",cmd:e}).then(s=>{if(s.is_error){ai(t,s.output||s.result||"Command failed");return}ai(t,i||""),n.scheduleRedrawAllLayers&&n.scheduleRedrawAllLayers(),r&&r()}).catch(s=>ai(t,s.message||String(s)))}function CM(n,e){let t=SM(`Insert Buffer \u2014 ${Yl(e)}`,"buf-dialog"),i=Jo(t.buttons,"Insert",{primary:!0});i.disabled=!0,Jo(t.buttons,"Cancel").addEventListener("click",t.close),n.websocketManager.request({type:"buffer_info",net:e}).then(s=>{if(!s.can_buffer){t.body.textContent=s.error||"This net has multiple drivers and cannot be buffered.";return}VW(n,t,e,s,i)}).catch(s=>{t.body.textContent=String(s)})}function VW(n,e,t,i,r){let s=document.createElement("div");s.className="buf-pins";let o=i.drivers||[],a=i.loads||[],c=new Set;function l(){s.innerHTML="";let p=(m,g)=>{let v=document.createElement("label");v.className="buf-pin";let y=document.createElement("input");y.type="checkbox",y.checked=c.has(m.id),y.addEventListener("change",()=>{if(y.checked){if(g)c.clear();else for(let b of o)c.delete(b.id);c.add(m.id)}else c.delete(m.id);l(),h()}),v.append(y,document.createTextNode(" "+m.label)),s.appendChild(v)};o.forEach(m=>p(m,!0)),a.forEach(m=>p(m,!1))}o.length&&c.add(o[0].id),l();let u=document.createElement("select");cv(u,i.masters||[]);let f=document.createElement("input");f.placeholder="Optional: new buffer name";let d=document.createElement("input");d.placeholder="Optional: new net name",e.body.append(pr("Pins to buffer",s),pr("Buffer master",u),pr("Buffer name",f),pr("Net name",d));function h(){r.disabled=c.size===0||!u.value}u.addEventListener("change",h),h(),r.addEventListener("click",()=>{let p=new Set(o.map(v=>v.id)),m=[...c],g=m.some(v=>p.has(v))?"driver":"loads";n.websocketManager.request({type:"insert_buffer",net:t,mode:g,pins:m,master:u.value,buf_name:f.value.trim(),net_name:d.value.trim()}).then(v=>{if(v.is_error||v.ok===!1){ai(e.errorDiv,v.error||v.result||"Insertion failed");return}e.close(),v.inst&&(n.selectedInstanceName=v.inst),n.scheduleRedrawAllLayers&&n.scheduleRedrawAllLayers()}).catch(v=>ai(e.errorDiv,v.message||String(v)))})}function pr(n,e){let t=document.createElement("label");t.className="edit-field";let i=document.createElement("span");return i.textContent=n,t.append(i,e),t}function cv(n,e){let t=n.value;n.innerHTML="";for(let i of e){let r=document.createElement("option");r.value=i,r.textContent=i,n.appendChild(r)}e.includes(t)&&(n.value=t)}function Yl(n){return String(n??"").replace(/&/g,"&").replace(//g,">")}var TM="#00ffff",WW="#ffff00",LM="#ffffff",jW=4,Ms=0,lv=1,ql=2,Qh=class{constructor(e,t,i,r){this._app=e,this._visibility=t,this._updateInspector=i,this._focusComponent=r,this._state=Ms,this._rulers=[],this._nextId=0,this._pt0=null,this._selectedRulerId=null,this._ctrlHeld=!1,this._shiftHeld=!1,this._snapTimer=null,this._lastSnapResult=null,this._snapShapes=null,this._preview=null,e.view?.on("zoom",()=>this._renderRulerShapes())}isActive(){return this._state!==Ms}updateVisibility(){this._renderAll(),this._drawTransient()}_shown(){return this._visibility.rulers!==!1}toggleRulerMode(){this._state===Ms?this._enterFirstPoint():this.cancelRulerBuild()}cancelRulerBuild(){this._state=Ms,this._pt0=null,this._lastSnapResult=null,this._clearTransient(),this._setCursor(!1)}clearAllRulers(){this._rulers=[],this._selectedRulerId=null,this._renderAll(),this._clearTransient(),this._state!==Ms&&this.cancelRulerBuild()}_enterFirstPoint(){this._state=lv,this._pt0=null,this._lastSnapResult=null,this._setCursor(!0)}_enterMeasuring(e){this._state=ql,this._pt0=e}_toDbu(e){return Pn(e[0],e[1],this._app.designScale,this._app.designOriginX,this._app.designOriginY)}_toWorld(e,t){return Sn(e,t,this._app.designScale,this._app.designOriginX,this._app.designOriginY)}handleMouseMove(e,t){if(this._state===Ms)return;this._ctrlHeld=t.ctrlKey||t.metaKey,this._shiftHeld=t.shiftKey;let i=this._toDbu(e);this._snapTimer&&clearTimeout(this._snapTimer),this._snapTimer=setTimeout(()=>{this._requestSnap(i.dbuX,i.dbuY)},50)}handleMapClick(e,t){if(this._state===Ms)return;this._ctrlHeld=t.ctrlKey||t.metaKey,this._shiftHeld=t.shiftKey;let i=this._toDbu(e),r=this._getSnappedPoint(i.dbuX,i.dbuY);this._state===lv?this._enterMeasuring(r):this._state===ql&&(this._createRuler(this._pt0,r),this._state=lv,this._pt0=null,this._clearTransient(),this._lastSnapResult=null)}async _requestSnap(e,t){let i=this._app;if(!i.websocketManager||!i.designScale)return;if(this._ctrlHeld){this._lastSnapResult=null,this._snapShapes=null,this._updatePreview(e,t);return}let s=i.techData?.dbu_per_micron||1e3,o=i.view.getZoom(),a=Math.pow(2,Math.max(0,o)),c=1/(i.designScale*a),l=Math.max(Math.round(10*c),10),u=!0,f=!0;if(this._shiftHeld)u=!0,f=!0;else if(this._state===ql&&this._pt0){let h=Math.abs(e-this._pt0.x),p=Math.abs(t-this._pt0.y);h>p?(u=!1,f=!0):p>h&&(u=!0,f=!1)}let d={};for(let[h,p]of Object.entries(this._visibility))d[h]=!!p;try{let h=await i.websocketManager.request({type:"snap",dbu_x:e,dbu_y:t,radius:s,point_threshold:l,horizontal:!!u,vertical:!!f,visible_layers:[...i.visibleLayerNames],...d});this._lastSnapResult=h,this._updateSnapIndicator(h),this._updatePreview(e,t)}catch{this._lastSnapResult=null,this._clearSnap()}}_getSnappedPoint(e,t){if(this._ctrlHeld)return{x:e,y:t};let i=this._lastSnapResult,r;if(i?.found&&i.is_point)r={x:i.edge[0][0],y:i.edge[0][1]};else if(i?.found){let s=i.edge;s[0][1]===s[1][1]?r={x:e,y:s[0][1]}:r={x:s[0][0],y:t}}else r={x:e,y:t};if(!this._shiftHeld&&this._state===ql&&this._pt0){let s=Math.abs(r.x-this._pt0.x),o=Math.abs(r.y-this._pt0.y);sthis._toWorld(r.x,r.y))}}_rulerShapes(e){let t=e.id===this._selectedRulerId,i=Ut(t?WW:TM),{joinPt:r,points:s}=this._rulerPath(e),o=[{kind:"path",points:s,stroke:i,width:2}],a=this._app.view.getZoom(),c=Math.pow(2,Math.max(0,a)),u=8*(1/(this._app.designScale*c)),f=(d,h,p)=>{let m=Math.sqrt(h*h+p*p);if(m===0)return;let g=-p/m,v=h/m;o.push({kind:"path",stroke:i,width:2,points:[this._toWorld(d.x+g*u,d.y+v*u),this._toWorld(d.x-g*u,d.y-v*u)]})};if(r)f(e.pt0,r.x-e.pt0.x,r.y-e.pt0.y),f(e.pt1,e.pt1.x-r.x,e.pt1.y-r.y);else{let d=e.pt1.x-e.pt0.x,h=e.pt1.y-e.pt0.y;f(e.pt0,d,h),f(e.pt1,d,h)}return o}_renderAll(){this._renderRulerShapes(),this._renderRulerLabels()}_renderRulerShapes(){let e=this._app.view;!e||!this._app.designScale||e.setOverlay("rulers",this._shown()?this._rulers.flatMap(t=>this._rulerShapes(t)):null,{order:ot.ruler})}_renderRulerLabels(){let e=this._app.view;if(!(!e||!this._app.designScale)&&(e.clearMarkers("ruler-labels"),!!this._shown()))for(let t of this._rulers){let{joinPt:i,points:r}=this._rulerPath(t),s=i?r[1]:[(r[0][0]+r[1][0])/2,(r[0][1]+r[1][1])/2],o=this._computeDistance(t.pt0,t.pt1,t.euclidian);e.addMarker("ruler-labels",t.id,s,this._labelElement(this._formatDistance(o)))}}handleRulerClick(e){let t=this._app.view;if(!t||!this._shown()||this._rulers.length===0)return!1;let i=t.project(e);for(let r of this._rulers){let s=this._rulerPath(r).points.map(o=>t.project(o));for(let o=0;o+1l.id===e);if(!t)return;Pt(this._app);let i=Math.abs(t.pt1.x-t.pt0.x),r=Math.abs(t.pt1.y-t.pt0.y),s=t.euclidian?Math.sqrt(i*i+r*r):i+r,o=l=>this._app.formatDbu(l,!0),a=l=>this._app.parseDbu(l),c={type:"Ruler",name:t.name,bbox:[Math.min(t.pt0.x,t.pt1.x),Math.min(t.pt0.y,t.pt1.y),Math.max(t.pt0.x,t.pt1.x),Math.max(t.pt0.y,t.pt1.y)],properties:[{name:"Name",value:t.name,editable:!0},{name:"Label",value:t.label||"",editable:!0},{name:"Point 0 - x",value:o(t.pt0.x),editable:!0},{name:"Point 0 - y",value:o(t.pt0.y),editable:!0},{name:"Point 1 - x",value:o(t.pt1.x),editable:!0},{name:"Point 1 - y",value:o(t.pt1.y),editable:!0},{name:"Delta x",value:o(i)},{name:"Delta y",value:o(r)},{name:"Length",value:o(s)},{name:"Euclidian",value:t.euclidian?"True":"False",editable:!0,editor:{type:"bool"}}],onPropertyChange:(l,u)=>{switch(l){case"Name":t.name=u;break;case"Label":t.label=u;break;case"Point 0 - x":{let f=a(u);f!==null&&(t.pt0.x=f);break}case"Point 0 - y":{let f=a(u);f!==null&&(t.pt0.y=f);break}case"Point 1 - x":{let f=a(u);f!==null&&(t.pt1.x=f);break}case"Point 1 - y":{let f=a(u);f!==null&&(t.pt1.y=f);break}case"Euclidian":t.euclidian=u.trim().toLowerCase()==="true";break}this._renderAll(),this._selectRuler(t.id)}};this._updateInspector(c),this._focusComponent("Inspector"),requestAnimationFrame(()=>{let l=this._app.inspectorEl?.querySelector(".inspector-toolbar");if(!l)return;let u=document.createElement("button");u.className="or-btn or-btn-icon",u.title="Delete ruler",u.innerHTML='',u.addEventListener("click",()=>{this.deleteRuler(e)}),l.appendChild(u)})}deleteRuler(e){let t=this._rulers.findIndex(i=>i.id===e);t!==-1&&(this._rulers.splice(t,1),this._renderAll(),this._selectedRulerId===e&&(this._selectedRulerId=null,this._updateInspector(null)))}_getManhattanJoinPt(e,t){return{x:t.x,y:e.y}}_computeDistance(e,t,i=!0){let r=Math.abs(t.x-e.x),s=Math.abs(t.y-e.y);return i?Math.sqrt(r*r+s*s):r+s}_formatDistance(e){return this._app.formatDistance(e)}_setCursor(e){this._app.view?.setCursorMode("ruler",e)}_clearTransient(){this._preview=null,this._snapShapes=null,this._drawTransient()}_clearSnap(){this._snapShapes=null,this._drawTransient()}};function HW(n,e,t){let i=t[0]-e[0],r=t[1]-e[1],s=i*i+r*r,o=s>0?((n[0]-e[0])*i+(n[1]-e[1])*r)/s:0;return o=Math.max(0,Math.min(1,o)),Math.hypot(n[0]-(e[0]+o*i),n[1]-(e[1]+o*r))}var Jh="label-handles",MM=3,ep=class{constructor(e,t,i,r){this._app=e,this._visibility=t,this._updateInspector=i,this._focusComponent=r,this._labels=[],this._anchors=[],this._mode=!1,this._selectedName=null}isActive(){return this._mode}updateVisibility(){this._app.view?.setMarkerGroupVisible(Jh,!!this._visibility.labels)}toggleLabelMode(){this._mode=!this._mode,this._setCursor(this._mode)}cancelLabelMode(){this._mode=!1,this._setCursor(!1)}_setCursor(e){this._app.view?.setCursorMode("label",e)}_wm(){return this._app.websocketManager}_applyLabels(e){this._labels=e||[],this._renderHandles()}_refresh(e){this._applyLabels(e&&e.labels),this._app.refreshOverlay()}applyRemoteLabels(e){this._applyLabels(e),this._selectedName&&!this._labels.some(t=>t.name===this._selectedName)&&(this._selectedName=null,this._updateInspector(null),this._renderHandles()),this._app.refreshOverlay()}_updateLabel(e,t){return this._wm().request({type:"update_label",name:e,...t})}async reload(){let e=this._wm();if(e)try{let t=await e.request({type:"list_labels"});this._anchors=t.anchors||[],this._applyLabels(t.labels)}catch{this._applyLabels([])}}async handleMapClick(e,t){let i=window.prompt("Label text:");if(this._mode=!1,this._setCursor(!1),!!i)try{let r=await this._wm().request({type:"add_label",x:Math.round(e),y:Math.round(t),text:i});this._refresh(r)}catch(r){console.error("add_label failed:",r)}}_renderHandles(){let e=this._app.view;if(!e)return;e.clearMarkers(Jh);let t=this._app;if(t.designScale)for(let i of this._labels){let r=document.createElement("div");r.className="label-handle"+(i.name===this._selectedName?" label-handle-selected":""),r.title=i.text,this._installDrag(r,i),e.addMarker(Jh,i.name,Sn(i.x,i.y,t.designScale,t.designOriginX,t.designOriginY),r,{center:!0})}}_installDrag(e,t){let i=this._app.view,r=a=>{let c=i.getContainer().getBoundingClientRect();return i.unproject([a.clientX-c.left,a.clientY-c.top])},s=null;e.addEventListener("pointerdown",a=>{a.button===0&&(a.stopPropagation(),a.preventDefault(),e.setPointerCapture?.(a.pointerId),s={x:a.clientX,y:a.clientY,moved:!1})}),e.addEventListener("pointermove",a=>{s&&((Math.abs(a.clientX-s.x)>MM||Math.abs(a.clientY-s.y)>MM)&&(s.moved=!0),s.moved&&i.moveMarker(Jh,t.name,r(a)))});let o=(a,c)=>{if(!s)return;let l=s;if(s=null,e.releasePointerCapture?.(a.pointerId),!c)this._renderHandles();else if(!l.moved)this._select(t.name);else{let u=this._app,[f,d]=r(a),{dbuX:h,dbuY:p}=Pn(f,d,u.designScale,u.designOriginX,u.designOriginY);this._commitMove(t,Math.round(h),Math.round(p))}};e.addEventListener("pointerup",a=>o(a,!0)),e.addEventListener("pointercancel",a=>o(a,!1)),e.addEventListener("click",a=>a.stopPropagation())}async _commitMove(e,t,i){try{let r=await this._updateLabel(e.name,{x:t,y:i,text:e.text,size:e.size||0,anchor:e.anchor||"center",color:e.color});this._refresh(r)}catch(r){console.error("move label failed:",r)}}_select(e){this._selectedName=e,this._renderHandles();let t=this._labels.find(s=>s.name===e);if(!t)return;let i=s=>this._app.formatDbu(s,!0),r={type:"Label",name:t.name,bbox:[t.x,t.y,t.x,t.y],properties:[{name:"Name",value:t.name},{name:"Text",value:t.text,editable:!0},{name:"x",value:i(t.x)},{name:"y",value:i(t.y)},{name:"Font size",value:String(t.size||0),editable:!0},{name:"Anchor",value:t.anchor||"center",editable:!0,editor:{type:"list",options:this._anchors}}],onPropertyChange:(s,o)=>{let a={text:t.text,size:t.size||0,anchor:t.anchor||"center"};s==="Text"?a.text=o:s==="Font size"?a.size=parseInt(o,10)||0:s==="Anchor"&&(a.anchor=o.trim()),this._edit(t,a)}};this._updateInspector(r),this._focusComponent("Inspector"),requestAnimationFrame(()=>{let s=this._app.inspectorEl?.querySelector(".inspector-toolbar");if(!s||s.querySelector(".delete-label-btn"))return;let o=document.createElement("button");o.className="or-btn or-btn-icon delete-label-btn",o.title="Delete label",o.innerHTML='',o.addEventListener("click",()=>this.deleteLabel(e)),s.appendChild(o)})}async _edit(e,t){try{let i=await this._updateLabel(e.name,{x:e.x,y:e.y,text:t.text,size:t.size,anchor:t.anchor,color:e.color});this._refresh(i),this._select(e.name)}catch(i){console.error("edit label failed:",i)}}async deleteLabel(e){try{let t=await this._wm().request({type:"delete_label",name:e});this._selectedName===e&&(this._selectedName=null,this._updateInspector(null)),this._refresh(t)}catch(t){console.error("delete_label failed:",t)}}async clearAllLabels(){try{let e=await this._wm().request({type:"clear_labels"});this._selectedName=null,this._refresh(e)}catch(e){console.error("clear_labels failed:",e)}}};var AM="Select an instance in the layout to view its schematic.",tp=class{constructor(e,t){this.container=e,this.appState=t,this.element=document.createElement("div"),this.element.className="schematic-widget",this.element.style.cssText="width:100%; height:100%; display:flex; flex-direction:column; background:var(--bg-panel); color:var(--fg-primary); overflow:hidden;",this.controls=document.createElement("div"),this.controls.style.cssText="padding:4px 8px; background:var(--bg-header); border-bottom:1px solid var(--border);flex-shrink:0; display:flex; align-items:center; gap:8px; flex-wrap:wrap;",this.controls.innerHTML='',this.element.appendChild(this.controls),this.svgContainer=document.createElement("div"),this.svgContainer.style.cssText="flex:1; overflow:hidden; position:relative; cursor:grab; background:var(--bg-main);",this.element.appendChild(this.svgContainer),this.container.element.appendChild(this.element),this.controls.querySelector("#schematic-refresh").addEventListener("click",()=>this.refresh()),this.controls.querySelector("#schematic-fit").addEventListener("click",()=>this.fitView()),this.controls.querySelector("#schematic-zoom-in").addEventListener("click",()=>this._zoomStep(1.5)),this.controls.querySelector("#schematic-zoom-out").addEventListener("click",()=>this._zoomStep(1/1.5)),this.controls.querySelector("#schematic-select").addEventListener("click",()=>this._toggleSelectMode()),this.controls.querySelector("#schematic-zoom-to").addEventListener("click",()=>this._zoomToSelected()),this.controls.querySelector("#schematic-save-svg").addEventListener("click",()=>this._exportSvg()),this.controls.querySelector("#schematic-save-png").addEventListener("click",()=>this._exportPng()),this.controls.querySelector("#schematic-copy").addEventListener("click",()=>this._copyImage()),this.appState.schematicWidget=this,this.netlistsvg=null,this.skin=null,this._svgEl=null,this._scale=1,this._panX=0,this._panY=0,this._selectMode=!1,this._selectedCell=null,this._svgIdToInstName=new Map,this._setupPanZoom(),this.initNetlistSVG()}_setupPanZoom(){let e=this.svgContainer,t=!1,i,r,s,o;e.addEventListener("wheel",a=>{if(!this._svgEl)return;a.preventDefault();let c=a.deltaY<0?1.2:1/1.2,l=e.getBoundingClientRect(),u=a.clientX-l.left,f=a.clientY-l.top;this._panX=u+(this._panX-u)*c,this._panY=f+(this._panY-f)*c,this._scale*=c,this._applyTransform()},{passive:!1}),e.addEventListener("mousedown",a=>{if(!(!this._svgEl||a.button!==0)){if(this._selectMode){this._handleSelectClick(a);return}t=!0,i=a.clientX,r=a.clientY,s=this._panX,o=this._panY,e.style.cursor="grabbing",a.preventDefault()}}),window.addEventListener("mousemove",a=>{t&&(this._panX=s+(a.clientX-i),this._panY=o+(a.clientY-r),this._applyTransform())}),window.addEventListener("mouseup",()=>{t&&(t=!1,e.style.cursor=this._selectMode?"default":"grab")})}_zoomStep(e){if(!this._svgEl)return;let t=this.svgContainer.getBoundingClientRect(),i=t.width/2,r=t.height/2;this._panX=i+(this._panX-i)*e,this._panY=r+(this._panY-r)*e,this._scale*=e,this._applyTransform()}_toggleSelectMode(){this._selectMode=!this._selectMode;let e=this.controls.querySelector("#schematic-select");this._selectMode?(e.style.background="var(--accent)",e.style.color="var(--fg-white)",this.svgContainer.style.cursor="default"):(e.style.background="",e.style.color="",this.svgContainer.style.cursor="grab",this._clearCellHighlight())}_handleSelectClick(e){if(!this._svgEl)return;let t=e.target,i=null;for(;t&&t!==this._svgEl;){if(t.tagName==="g"&&t.id&&this._svgIdToInstName.has(t.id)){i=t;break}t=t.parentElement}if(this._clearCellHighlight(),!i)return;let r=this._svgIdToInstName.get(i.id);try{let s=i.getBBox(),o=3,a=document.createElementNS("http://www.w3.org/2000/svg","rect");a.setAttribute("x",s.x-o),a.setAttribute("y",s.y-o),a.setAttribute("width",s.width+o*2),a.setAttribute("height",s.height+o*2),a.setAttribute("fill","none"),a.setAttribute("stroke","#e05a00"),a.setAttribute("stroke-width","1.5"),a.setAttribute("rx","3"),a.id="_schematic_highlight",i.appendChild(a),this._selectedCell=i}catch{}this.controls.querySelector("#schematic-zoom-to").disabled=!1,this.setStatus(`Selected: ${r}`),this._fetchInspect(r)}_fetchInspect(e){let t=this.appState.websocketManager;if(!t)return;console.log("[Schematic] inspect:",e);let i=Pt(this.appState);t.request({type:"schematic_inspect",inst_name:e,use_dbu:this.appState.showDbu}).then(r=>{zt(this.appState,i)&&(this.appState.updateInspector&&this.appState.updateInspector(r),this.appState.focusComponent&&this.appState.focusComponent("Inspector"),this.appState.refreshOverlay&&this.appState.refreshOverlay())}).catch(r=>{console.error("schematic_inspect failed:",r),this.setStatus(`Inspect error: ${r}`)})}_clearCellHighlight(){if(this._svgEl){let e=this._svgEl.querySelector("#_schematic_highlight");e&&e.remove()}this._selectedCell=null,this.controls.querySelector("#schematic-zoom-to").disabled=!0}_zoomToSelected(){if(!this._selectedCell||!this._svgEl)return;let e=this.svgContainer.getBoundingClientRect(),t=this._selectedCell.getBoundingClientRect(),i=(t.left-e.left-this._panX)/this._scale,r=(t.top-e.top-this._panY)/this._scale,s=t.width/this._scale,o=t.height/this._scale,a=Math.min(e.width/s,e.height/o)*.9;this._scale=a,this._panX=e.width/2-(i+s/2)*a,this._panY=e.height/2-(r+o/2)*a,this._applyTransform()}_applyTransform(){this._svgEl&&(this._svgEl.style.transform=`translate(${this._panX}px, ${this._panY}px) scale(${this._scale})`,this._svgEl.style.transformOrigin="0 0")}fitView(){if(!this._svgEl)return;let e=this.svgContainer.getBoundingClientRect();if(e.width===0||e.height===0)return;let t=this._svgEl.viewBox&&this._svgEl.viewBox.baseVal,i=t&&t.width||this._svgEl.clientWidth||1,r=t&&t.height||this._svgEl.clientHeight||1;this._scale=Math.min(e.width/i,e.height/r)*.95,this._panX=(e.width-i*this._scale)/2,this._panY=(e.height-r*this._scale)/2,this._applyTransform()}initNetlistSVG(){this.netlistsvg=globalThis.netlistsvg,this.skin=globalThis.openroadSkin,this._netlistsvgReady=!!(this.netlistsvg&&this.skin),this._netlistsvgReady&&console.log("NetlistSVG ready."),this.setStatus(this._unreadyStatus()??AM)}_unreadyStatus(){return this._netlistsvgReady?null:fe(this.appState)?"The schematic is not available in saved reports.":"Init error: netlistsvg or its skin is missing from the page."}syncCone(e={}){let t=this.controls.querySelector("#schematic-fanin-depth"),i=this.controls.querySelector("#schematic-fanout-depth"),r=(s,o,a)=>{if(!s)return;let c=parseInt(s.max,10)||10;o===!1?s.value=0:a!==void 0&&(s.value=a>0?Math.min(a,c):c)};r(t,e.fanin,e.fanin_depth),r(i,e.fanout,e.fanout_depth),this.refresh(),this.appState.focusComponent&&this.appState.focusComponent("SchematicWidget")}refresh(){if(!this._netlistsvgReady){this.setStatus(this._unreadyStatus());return}let e=this.appState.selectedInstanceName;if(!e){this.setStatus(AM);return}let t=this.appState.websocketManager;if(!t){this.setStatus("Waiting for server connection\u2026");return}this.setStatus(`Loading schematic for ${e}\u2026`);let i=parseInt(this.controls.querySelector("#schematic-fanin-depth").value,10),r=parseInt(this.controls.querySelector("#schematic-fanout-depth").value,10),s=isNaN(i)?1:i,o=isNaN(r)?1:r;t.readyPromise.then(()=>{t.request({type:"schematic_cone",inst_name:e,fanin_depth:s,fanout_depth:o}).then(a=>{let c=a.modules&&a.modules.top&&a.modules.top.cells;if(!c||Object.keys(c).length===0){this.setStatus("No cells found for selected instance.");return}this.renderNetlist(a)}).catch(a=>{this.setStatus(`Error: ${a}`)})})}setStatus(e){this.controls.querySelector("#schematic-status").textContent=e}_exportSvg(){if(!this._svgEl){this.setStatus("No schematic to export.");return}let e=nv(this._svgEl);iM(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),"schematic.svg")}async _exportPng(){if(!this._svgEl){this.setStatus("No schematic to export.");return}try{let e=await iv(this._svgEl,2);Ts(e,"schematic.png")}catch{this.setStatus("PNG export failed.")}}async _copyImage(){if(!this._svgEl){this.setStatus("No schematic to export.");return}try{let e=await iv(this._svgEl,2),t=await Fh(e);this.setStatus(t?"Schematic copied to clipboard.":"Clipboard not available.")}catch{this.setStatus("Copy failed.")}}async renderNetlist(e){try{this.setStatus("Rendering\u2026"),typeof window<"u"&&(window.__lastSchematic=e);let t=KW(e),i,r=this.netlistsvg.render(this.skin,t);if(r&&typeof r.then=="function"?i=await r:i=await new Promise((a,c)=>{this.netlistsvg.render(this.skin,t,(l,u)=>{l?c(l):a(u)})}),typeof i!="string"||!i.includes("requestAnimationFrame(()=>this.fitView()));let o=Object.keys(e.modules.top.cells).length;this.setStatus(`${o} cell${o!==1?"s":""}`)}catch(t){console.error("NetlistSVG render failed:",t),this.setStatus(`Render error: ${t.message||t}`)}}_applyPinLabels(e){if(!this._svgEl)return;let t="http://www.w3.org/2000/svg",i="https://github.com/nturley/netlistsvg",r=e.modules&&e.modules.top&&e.modules.top.cells||{},s=(o,a)=>o.getAttribute("s:"+a)??o.getAttributeNS(i,a);for(let[o,a]of Object.entries(r)){let c=a.port_labels;if(!c)continue;let l=this._svgEl.querySelector("#"+CSS.escape("cell_"+o))||this._svgEl.querySelector("#"+CSS.escape(o));if(!l)continue;let u=a.port_directions||{};for(let f of Array.from(l.children)){if(f.tagName!=="g")continue;let d=s(f,"pid");if(!d||!(d in c))continue;let h=parseFloat(s(f,"x")),p=parseFloat(s(f,"y"));if(!isFinite(h)||!isFinite(p))continue;let m=document.createElementNS(t,"text");u[d]==="input"?(m.setAttribute("class","inputPortLabel"),m.setAttribute("x",h-3)):m.setAttribute("x",h+4),m.setAttribute("y",p-4),m.setAttribute("style","font-size:5px"),m.setAttribute("pointer-events","none"),m.textContent=c[d],l.appendChild(m)}}}_scopeSkinStyles(){if(!this._svgEl)return;let e=".schematic-widget",t=i=>{for(let r of i)r.selectorText?r.selectorText=YW(r.selectorText,e):r.cssRules&&t(r.cssRules)};for(let i of this._svgEl.querySelectorAll("style")){let r=i.sheet;if(r)try{t(r.cssRules)}catch{continue}}}};function YW(n,e){return n.split(",").map(t=>{let i=t.trim();if(!i)return"";let r=i.charAt(e.length);return i.startsWith(e)&&(r===""||!/[\w-]/.test(r))?i:`${e} ${i}`}).filter(Boolean).join(", ")}var kM={and:"$_AND_",nand:"$_NAND_",or:"$_OR_",nor:"$_NOR_",xor:"$_XOR_",xnor:"$_XNOR_",not:"$_NOT_",buf:"$_BUF_"},qW=new Set(["aoi21","aoi22","aoi211","aoi221","aoi222","aoi33","oai21","oai22","oai211","oai221","oai222","oai33"]),ZW=new Set(["and3","and4","or3","or4","nand3","nand4","nor3","nor4"]),RM=["A","B","C","D","E","F"];function XW(n){let e=n&&n.gate_kind;if(!e)return n;let t=n.port_directions||{},i=null,r=[];for(let[f,d]of Object.entries(t))d==="output"&&i===null?i=f:d==="input"&&r.push(f);let s,o={};if(e==="aoi"||e==="oai"){let f=Array.isArray(n.gate_terms)?n.gate_terms:[];if(!f.length)return n;let d=f.map(m=>m.length);if(s=e+d.slice().sort((m,g)=>g-m).join(""),!qW.has(s))return n;let h=f.map(m=>m.slice()).sort((m,g)=>m.length-g.length),p=0;for(let m of h)for(let g of m)o[g]=RM[p]||"I"+p,p++}else{let f=r.length;if(e==="not"||e==="buf")s=kM[e];else if(f<=2)s=kM[e];else if(s=e+f,!ZW.has(s))return n;if(!s)return n;r.forEach((d,h)=>{o[d]=RM[h]||"I"+h})}i!==null&&(o[i]="Y");let a=n.connections||{},c={},l={};for(let[f,d]of Object.entries(a))o[f]&&(c[o[f]]=d);for(let[f,d]of Object.entries(t))o[f]&&(l[o[f]]=d);let u={};for(let[f,d]of Object.entries(o))u[d]=f;return{...n,type:s,connections:c,port_directions:l,port_labels:u}}function KW(n){let e=n&&n.modules&&n.modules.top;if(!e||!e.cells)return n;let t={};for(let[i,r]of Object.entries(e.cells))t[i]=XW(r);return{...n,modules:{...n.modules,top:{...e,cells:t}}}}var np=class{constructor(e,t,i){this._app=e,this._redrawAllLayers=t,this._refreshOverlay=i||t,this._categories=[],this._activeCategory="",this._markerTree=null,this._expandedNodes=new Set,this._build(),this._app.websocketManager.readyPromise.then(()=>this.refresh())}_build(){let e=document.createElement("div");e.className="drc-widget";let t=document.createElement("div");t.className="drc-toolbar",this._categorySelect=document.createElement("select"),this._categorySelect.className="drc-category-select",t.appendChild(this._categorySelect),this._loadBtn=document.createElement("button"),this._loadBtn.className="or-btn or-btn-sm",this._loadBtn.textContent="Load...",t.appendChild(this._loadBtn),e.appendChild(t),this._infoBar=document.createElement("div"),this._infoBar.className="drc-info-bar",e.appendChild(this._infoBar),this._treeContainer=document.createElement("div"),this._treeContainer.className="drc-tree-container",e.appendChild(this._treeContainer),this.element=e,this._bindEvents()}_bindEvents(){this._categorySelect.addEventListener("change",()=>{this._activeCategory=this._categorySelect.value,this._loadMarkers()}),this._loadBtn.addEventListener("click",()=>{this._showLoadDialog()})}_loadCategories(){return this._app.websocketManager.request({type:"drc_categories"}).then(e=>{this._categories=e.categories||[],this._renderCategorySelect()}).catch(e=>{console.error("Failed to load DRC categories:",e)})}refresh(){this._loadCategories().then(()=>{!this._activeCategory&&this._categories.length>0&&(this._activeCategory=this._categories[0].name,this._categorySelect.value=this._activeCategory),this._activeCategory&&this._loadMarkers()})}_renderCategorySelect(){let e=this._categorySelect,t=e.value;e.innerHTML="";let i=document.createElement("option");i.value="",i.textContent="(none)",e.appendChild(i);for(let r of this._categories){let s=document.createElement("option");s.value=r.name,s.textContent=`${r.name} (${r.count})`,e.appendChild(s)}this._activeCategory&&this._categories.some(r=>r.name===this._activeCategory)?e.value=this._activeCategory:t&&this._categories.some(r=>r.name===t)?(e.value=t,this._activeCategory=t):this._activeCategory=""}_loadMarkers(){if(!this._activeCategory){this._markerTree=null,this._treeContainer.innerHTML="",this._infoBar.textContent="",this._refreshOverlay();return}this._treeContainer.innerHTML='
Loading...
',this._app.websocketManager.request({type:"drc_markers",category:this._activeCategory}).then(e=>{this._markerTree=e,this._renderTree(),this._refreshOverlay()}).catch(e=>{this._treeContainer.innerHTML="";let t=document.createElement("div");t.className="drc-error",t.textContent=`Error: ${e}`,this._treeContainer.appendChild(t),console.error("Failed to load DRC markers:",e)})}_renderTree(){if(this._treeContainer.innerHTML="",!this._markerTree)return;if(this._markerTree.error){let o=document.createElement("div");o.className="drc-error",o.textContent=this._markerTree.error,this._treeContainer.appendChild(o);return}let e=this._markerTree.total_count||0;this._infoBar.textContent=`${e} total violation${e!==1?"s":""}`;let t=this._markerTree.name||this._activeCategory,i=this._markerTree.subcategories||[],r=this._markerTree.markers||[];if(i.length===0&&r.length===0){this._treeContainer.innerHTML='
No violations
';return}let s=document.createElement("div");s.className="drc-tree",r.length>0&&s.appendChild(this._buildCategoryNode({name:t||"Markers",count:r.length,markers:r},[]));for(let o of i)s.appendChild(this._buildCategoryNode(o,[t]));this._treeContainer.appendChild(s)}_buildCategoryNode(e,t=[]){let i=[...t,e.name],r=document.createElement("div");r.className="drc-tree-node";let s=document.createElement("div");s.className="drc-tree-header";let o=document.createElement("span");o.className="drc-toggle";let a=e.subcategories&&e.subcategories.length>0||e.markers&&e.markers.length>0,c=JSON.stringify(i),l=this._expandedNodes.has(c);o.textContent=a?l?"\u25BC":"\u25B6":" ",s.appendChild(o);let u=document.createElement("input");u.type="checkbox",u.checked=this._allMarkersVisible(e),u.className="drc-visibility-check",u.addEventListener("change",p=>{p.stopPropagation(),this._toggleCategoryVisibility(e,u.checked,i)}),s.appendChild(u);let f=document.createElement("span");f.className="drc-category-label",f.textContent=e.name,s.appendChild(f);let d=document.createElement("span");d.className="drc-count",d.textContent=`${e.count} markers`,s.appendChild(d),r.appendChild(s);let h=document.createElement("div");if(h.className="drc-tree-children",h.style.display=l?"":"none",e.subcategories)for(let p of e.subcategories)h.appendChild(this._buildCategoryNode(p,i));if(e.markers)for(let p of e.markers)h.appendChild(this._buildMarkerNode(p));return r.appendChild(h),a&&(s.addEventListener("click",p=>{if(p.target===u)return;let m=h.style.display!=="none";h.style.display=m?"none":"",o.textContent=m?"\u25B6":"\u25BC",m?this._expandedNodes.delete(c):this._expandedNodes.add(c)}),s.style.cursor="pointer"),r}_buildMarkerNode(e){let t=document.createElement("div");t.className="drc-marker-row",t.dataset.markerId=e.id,e.visited||t.classList.add("drc-unvisited");let i=document.createElement("input");i.type="checkbox",i.checked=e.visible,i.className="drc-visibility-check",i.addEventListener("change",o=>{o.stopPropagation(),e.visible=i.checked,this._updateMarker(e.id,"visible",i.checked)}),t.appendChild(i);let r=document.createElement("span");r.className="drc-marker-index",r.textContent=e.index,t.appendChild(r);let s=document.createElement("span");if(s.className="drc-marker-name",s.textContent=e.name,e.layer&&(s.title=`Layer: ${e.layer}`),t.appendChild(s),e.layer){let o=document.createElement("span");o.className="drc-layer-badge",o.textContent=e.layer,t.appendChild(o)}return t.addEventListener("click",o=>{o.target!==i&&this._highlightMarker(e)}),t.addEventListener("dblclick",o=>{o.target!==i&&this._highlightMarker(e,!0)}),t}highlightMarkerById(e,t=!1){let i=this._findMarkerById(e);i&&this._highlightMarker(i,t)}_findMarkerById(e){let t=i=>{if(!i)return null;if(i.markers){for(let r of i.markers)if(r.id===e)return r}if(i.subcategories)for(let r of i.subcategories){let s=t(r);if(s)return s}return null};return t(this._markerTree)}_highlightMarker(e,t=!1){this._app.websocketManager.request({type:"drc_highlight",marker_id:e.id,open_inspector:t}).then(i=>{if(i.ok&&i.bbox){e.visited=!0;let r=this._treeContainer.querySelector(`.drc-marker-row[data-marker-id="${e.id}"]`);r&&r.classList.remove("drc-unvisited"),this._zoomToBBox(i.bbox),this._refreshOverlay(),t&&(i.select_id!=null&&this._app.navigateInspector&&this._app.navigateInspector(i.select_id),this._app.focusComponent&&this._app.focusComponent("Inspector"))}}).catch(i=>{console.error("Failed to highlight DRC marker:",i)})}_zoomToBBox(e){if(!this._app.designScale||!this._app.view)return;let[t,i,r,s]=e,o=r-t,a=s-i,l=10*this._app.getDbuPerMicron(),u=2*Math.max(o,a),f=Math.min(l,u);this._app.view.fitWorldRect(Nt(t-f,i-f,r+f,s+f,this._app.designScale,this._app.designOriginX,this._app.designOriginY))}_updateMarker(e,t,i){this._app.websocketManager.request({type:"drc_update_marker",marker_id:e,field:t,value:!!i}).then(()=>{this._refreshOverlay(),t==="visible"&&(this._update3DHighlights(),i&&this._flashHighlight())}).catch(r=>{console.error("Failed to update DRC marker:",r)})}_flashHighlight(){this._app.view?.flashTiles()}_update3DHighlights(){let e=this._app.threeDViewerWidget;if(!e)return;let t=[];this._collectVisibleMarkers(this._markerTree,t),t.length>0?e.highlightDRC(t):e.clearHighlightDRC()}_collectVisibleMarkers(e,t){if(e){if(e.markers)for(let i of e.markers)i.visible&&t.push(i);if(e.subcategories)for(let i of e.subcategories)this._collectVisibleMarkers(i,t)}}_setMarkersVisible(e,t){if(e){if(e.markers)for(let i of e.markers)i.visible=t;if(e.subcategories)for(let i of e.subcategories)this._setMarkersVisible(i,t)}}_snapshotMarkerVisibility(e,t=new Map){if(!e)return t;if(e.markers)for(let i of e.markers)t.set(i.id,i.visible);if(e.subcategories)for(let i of e.subcategories)this._snapshotMarkerVisibility(i,t);return t}_restoreMarkerVisibility(e,t){if(e){if(e.markers)for(let i of e.markers)t.has(i.id)&&(i.visible=t.get(i.id));if(e.subcategories)for(let i of e.subcategories)this._restoreMarkerVisibility(i,t)}}_allMarkersVisible(e){if(e.markers){for(let t of e.markers)if(!t.visible)return!1}if(e.subcategories){for(let t of e.subcategories)if(!this._allMarkersVisible(t))return!1}return!0}_toggleCategoryVisibility(e,t,i){let r=this._snapshotMarkerVisibility(e);this._setMarkersVisible(e,t),this._renderTree(),this._app.websocketManager.request({type:"drc_update_category_visibility",category:e.name,path:i||[e.name],visible:!!t}).then(()=>{this._refreshOverlay(),this._update3DHighlights(),t&&this._flashHighlight()}).catch(s=>{console.error("Failed to update category visibility:",s),this._restoreMarkerVisibility(e,r),this._renderTree()})}_showLoadDialog(){new uv(this._app,t=>{this._activeCategory=t,this._loadCategories().then(()=>{this._categorySelect.value=this._activeCategory,this._loadMarkers()})}).open()}selectCategory(e){this._activeCategory=e,this._categorySelect.value=e,this._loadMarkers()}},uv=class{constructor(e,t){this._app=e,this._onLoaded=t,this._currentPath="",this._disposers=[],this._closed=!1}open(){this._overlay=document.createElement("div"),this._overlay.className="modal-overlay",this._overlay.innerHTML=` - `,document.body.appendChild(this._overlay),this._breadcrumb=this._overlay.querySelector(".fb-breadcrumb"),this._fileList=this._overlay.querySelector(".fb-file-list"),this._pathInput=this._overlay.querySelector(".fb-path-input"),this._errorDiv=this._overlay.querySelector(".modal-error"),this._okBtn=this._overlay.querySelector(".ok"),this._cancelBtn=this._overlay.querySelector(".cancel"),this._listen(this._pathInput,"input",()=>this._updateOkState()),this._listen(this._pathInput,"keydown",e=>{if(e.key==="Enter"){let t=this._pathInput.value.trim();t.endsWith("/")?this._navigate(t.replace(/\/+$/,"")||"/"):this._submit()}else e.key==="Escape"&&this.close()}),this._listen(this._okBtn,"click",()=>this._submit()),this._listen(this._cancelBtn,"click",()=>this.close()),this._listen(this._overlay,"click",e=>{e.target===this._overlay&&this.close()}),this._navigate("")}close(){if(!this._closed){this._closed=!0;for(let e of this._disposers)e();this._disposers.length=0,this._overlay&&(this._overlay.remove(),this._overlay=null)}}_listen(e,t,i){e.addEventListener(t,i),this._disposers.push(()=>e.removeEventListener(t,i))}_updateOkState(){this._okBtn.disabled=!this._pathInput.value.trim()}_renderBreadcrumb(e){this._breadcrumb.innerHTML="";let t=e.split("/").filter(Boolean),i=document.createElement("span");i.className="fb-crumb",i.textContent="/",this._listen(i,"click",()=>this._navigate("/")),this._breadcrumb.appendChild(i);let r="";for(let s of t){r+="/"+s;let o=document.createElement("span");o.className="fb-crumb-sep",o.textContent=" / ",this._breadcrumb.appendChild(o);let a=document.createElement("span");a.className="fb-crumb",a.textContent=s;let c=r;this._listen(a,"click",()=>this._navigate(c)),this._breadcrumb.appendChild(a)}}_renderEntries(e){if(this._fileList.innerHTML="",!e||e.length===0){let t=document.createElement("div");t.className="fb-empty",t.textContent="(empty directory)",this._fileList.appendChild(t);return}for(let t of e){let i=document.createElement("div");i.className="fb-entry",t.is_dir&&i.classList.add("fb-dir");let r=document.createElement("span");r.className="fb-icon",r.textContent=t.is_dir?"\u{1F4C1}":"\u{1F4C4}",i.appendChild(r);let s=document.createElement("span");s.className="fb-name",s.textContent=t.name,i.appendChild(s),t.is_dir?this._listen(i,"click",()=>this._navigate(this._currentPath+"/"+t.name)):(this._listen(i,"click",()=>{let o=this._fileList.querySelector(".fb-selected");o&&o.classList.remove("fb-selected"),i.classList.add("fb-selected"),this._pathInput.value=this._currentPath+"/"+t.name,this._updateOkState()}),this._listen(i,"dblclick",()=>{this._pathInput.value=this._currentPath+"/"+t.name,this._updateOkState(),this._submit()})),this._fileList.appendChild(i)}}async _navigate(e){this._errorDiv.style.display="none",this._fileList.innerHTML='
Loading...
';try{let t=await this._app.websocketManager.request({type:"list_dir",path:e||""});if(this._closed)return;this._currentPath=t.path,this._renderBreadcrumb(t.path),this._renderEntries(t.entries),this._pathInput.value="",this._updateOkState()}catch(t){if(this._closed)return;this._fileList.innerHTML="",this._errorDiv.textContent=t.message||String(t),this._errorDiv.style.display=""}}async _submit(){let e=this._pathInput.value.trim();if(e){this._okBtn.disabled=!0,this._okBtn.textContent="Loading...",this._errorDiv.style.display="none";try{let t=await this._app.websocketManager.request({type:"drc_load_report",path:e});if(this._closed)return;if(t.ok){let i=t.category;this.close(),this._onLoaded(i)}else this._errorDiv.textContent=t.error||"Failed to load report",this._errorDiv.style.display="",this._okBtn.disabled=!1,this._okBtn.textContent="Load"}catch(t){if(this._closed)return;this._errorDiv.textContent=t.message||"Request failed",this._errorDiv.style.display="",this._okBtn.disabled=!1,this._okBtn.textContent="Load"}}}};var qW=` -\r[]{}`;var np=class{constructor(e,t){this._input=e,this._ws=t,this._popup=null,this._items=[],this._selectedIndex=-1,this._replaceStart=0,this._replaceEnd=0,this._debounceTimer=null,this._commandCache=null,this._history=[],this._historyIndex=-1,this._historyStash="",this._createPopup(),this._onInputBound=this._onInput.bind(this),this._onBlurBound=this._onBlur.bind(this),this._input.addEventListener("input",this._onInputBound),this._input.addEventListener("blur",this._onBlurBound)}_createPopup(){this._popup=document.createElement("div"),this._popup.className="tcl-complete-popup",this._popup.style.display="none",this._input.parentElement.appendChild(this._popup)}handleKeyDown(e){let t=this._popup.style.display!=="none";return e.key==="Tab"?(e.preventDefault(),t?this._tabAccept():this._tabComplete(this._input.value,this._input.selectionStart),!0):e.key==="Escape"?t?(this._hidePopup(),!0):!1:e.key==="ArrowDown"?t?(e.preventDefault(),this._selectItem(this._selectedIndex+1),!0):this._historyIndex>=0?(e.preventDefault(),this._historyIndex--,this._historyIndex<0?this._input.value=this._historyStash:this._input.value=this._history[this._historyIndex],!0):!1:e.key==="ArrowUp"?t?(e.preventDefault(),this._selectItem(this._selectedIndex-1),!0):this._historyIndex{let e=this._input.value,t=this._input.selectionStart,i=this._extractPrefix(e,t);i.length>=2||i.length>=1&&(i[0]==="$"||i[0]==="-")?this._requestCompletions(e,t):this._hidePopup()},100)}_onBlur(){setTimeout(()=>this._hidePopup(),150)}_extractPrefix(e,t){let i=t-1;for(;i>=0&&qW.indexOf(e[i])===-1;)i--;return e.substring(i+1,t)}_fetchCompletions(e,t,i){let r=this._extractPrefix(e,t),s=r.length>0&&r[0]==="$",o=r.length>0&&r[0]==="-",a=!s&&!o,c=t-r.length,l=e.substring(0,c),u=/^[\s\[]*$/.test(l);if(a&&u&&this._commandCache){let f=r.toLowerCase(),d=this._commandCache.filter(h=>h.toLowerCase().startsWith(f));i(d,c,t);return}this._ws.request({type:"tcl_complete",line:e,cursor_pos:t}).then(f=>{f.mode==="commands"&&!this._commandCache&&r===""&&(this._commandCache=f.completions),f.mode==="commands"&&!this._commandCache&&this._ws.request({type:"tcl_complete",line:"",cursor_pos:0}).then(d=>{d.mode==="commands"&&(this._commandCache=d.completions)}).catch(()=>{}),i(f.completions,f.replace_start,f.replace_end)}).catch(()=>i([],0,0))}_requestCompletions(e,t){this._fetchCompletions(e,t,(i,r,s)=>{this._showPopup(i,r,s)})}_tabAccept(){if(this._items.length===0){this._hidePopup();return}if(this._items.length===1){this._selectedIndex=0,this._acceptCompletion();return}this._advanceToCommonPrefix()}_tabComplete(e,t){this._fetchCompletions(e,t,(i,r,s)=>{if(!i||i.length===0){this._hidePopup();return}if(i.length===1){this._items=i,this._replaceStart=r,this._replaceEnd=s,this._selectedIndex=0,this._acceptCompletion();return}this._items=i,this._replaceStart=r,this._replaceEnd=s,this._advanceToCommonPrefix(),this._showPopup(i,this._replaceStart,this._replaceEnd)})}_advanceToCommonPrefix(){if(this._items.length<2)return!1;let e=this._items[0];for(let o=1;o0;o++){let a=this._items[o],c=0;for(;c{let c=document.createElement("div");c.className="tcl-complete-item",c.textContent=o,c.addEventListener("mousedown",l=>{l.preventDefault(),this._selectedIndex=a,this._acceptCompletion()}),this._popup.appendChild(c)}),e.length>15){let o=document.createElement("div");o.className="tcl-complete-more",o.textContent=`... ${e.length-15} more`,this._popup.appendChild(o)}this._selectedIndex=0,this._highlightSelected(),this._popup.style.display="block"}_hidePopup(){this._popup.style.display="none",this._items=[],this._selectedIndex=-1}_selectItem(e){if(this._items.length===0)return;let t=Math.min(this._items.length,15)-1;this._selectedIndex=Math.max(0,Math.min(e,t)),this._highlightSelected()}_highlightSelected(){let e=this._popup.querySelectorAll(".tcl-complete-item");e.forEach((t,i)=>{t.classList.toggle("selected",i===this._selectedIndex)}),e[this._selectedIndex]&&e[this._selectedIndex].scrollIntoView&&e[this._selectedIndex].scrollIntoView({block:"nearest"})}_acceptCompletion(){if(this._selectedIndex<0||this._selectedIndex>=this._items.length){this._hidePopup();return}let e=this._items[this._selectedIndex],t=this._input.value.substring(0,this._replaceStart),i=this._input.value.substring(this._replaceEnd),s=!e.endsWith("/")&&!e.endsWith("::")&&(i.length===0||i[0]!==" ")?" ":"";this._input.value=t+e+s+i;let o=this._replaceStart+e.length+s.length;this._input.setSelectionRange(o,o),this._input.focus(),this._hidePopup()}};var kM=[{key:"or_visibility",store:"cookie"},{key:"or_selectability",store:"cookie"},{key:"or_hidden_layers",store:"session"},{key:"or_nonselectable_layers",store:"session"},{key:"or_layer_patterns",store:"session"},{key:"or_hidden_chiplets",store:"cookie"},{key:"or_bg_color",store:"cookie"},{key:"or_show_dbu",store:"cookie"},{key:"or_theme",store:"theme"},{key:"or_use_true_z",store:"cookie"},{key:"or_ruler_style",store:"cookie"},{key:"or_wheel_zoom",store:"cookie"},{key:"or_arrow_step",store:"cookie"},{key:"or_font_family",store:"cookie"},{key:"or_font_scale",store:"cookie"},{key:"or_control_smoothing",store:"cookie"},{key:"or_double_buffer",store:"cookie"},{key:"or_defer_tile_updates",store:"cookie"}];function ZW(n,e){try{return window[n].getItem(e)}catch{return null}}function XW(n,e,t){try{t===null?window[n].removeItem(e):window[n].setItem(e,t)}catch{}}function KW({key:n,store:e}){return e==="session"?ZW("sessionStorage",n):Be(n)}function QW({key:n,store:e},t){e==="session"?XW("sessionStorage",n,t):e==="theme"?t===null?K3():Dh(t):t===null?Oh(n):Ue(n,t)}function RM(){let n={};for(let e of kM){let t=KW(e);t&&(n[e.key]=t)}return{version:1,entries:n}}function JW(n){return typeof n=="string"&&n!==""&&!/[;\r\n]/.test(n)}function IM(n){for(let e of kM){let t=n[e.key];QW(e,JW(t)?t:null)}}function BM(n,e=typeof document<"u"?document:null){let t="OpenROAD",i=n?`${t} - ${n}`:t;return e&&(e.title=i),i}var ce=globalThis.THREE,OM=2,e5=.002,t5=.9,n5=1.1,i5=.1,r5=20,s5=3,As=2,DM=2,o5=10,a5=1e4,c5=.15,l5=300,u5=6,ip=Math.PI/180,NM=[5025616,2201331,16750592,10233776,48340,16007990,2533018,7951688,15277667,4149685];function f5(n){let e=new Array(n.length).fill(0),t=new Map;n.forEach((i,r)=>{let s=i.z;t.has(s)||t.set(s,[]),t.get(s).push({idx:r,chiplet:i})});for(let i of t.values()){if(i.length<=1)continue;let r=[];for(let{idx:s,chiplet:o}of i){let a=o.x,c=o.y,l=o.x+o.width,u=o.y+o.height,f=!1;for(let d=0;dap.x1&&cp.y1)){r[d].push({x1:a,y1:c,x2:l,y2:u}),e[s]=d,f=!0;break}f||(r.push([{x1:a,y1:c,x2:l,y2:u}]),e[s]=r.length-1)}}return e}var rp=class{constructor(e,t){if(this._app=t,this._container=e,this._element=document.createElement("div"),this._element.className="three-d-viewer-widget",e.element.appendChild(this._element),!ce){ue(t)?this._showInfo("The 3D view is not available in saved reports."):this._showError("three.js is missing from the page."),this._destroyed=!0;return}this._canvasContainer=document.createElement("div"),this._canvasContainer.className="three-d-canvas-container",this._element.appendChild(this._canvasContainer),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._canvasContainer.appendChild(this._tooltip),this._optionsOverlay=this._createOptionsOverlay(),this._canvasContainer.appendChild(this._optionsOverlay),this._raycaster=new ce.Raycaster,this._scene=new ce.Scene,this._applyTheme(),this._themeObserver=new MutationObserver(()=>{this._applyTheme(),this.render()}),this._themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),this._camera=new ce.PerspectiveCamera(45,1,10,1e5),this._camera.position.set(0,0,1e3);try{this._renderer=new ce.WebGLRenderer({antialias:!0,preserveDrawingBuffer:!0})}catch(o){console.error("3D viewer: failed to create WebGL context:",o),this._showWebGLUnavailable(o),this._themeObserver&&(this._themeObserver.disconnect(),this._themeObserver=null),this._destroyed=!0;return}this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(e.width,e.height),this._canvasContainer.appendChild(this._renderer.domElement),this._rotation=new ce.Quaternion,this._distance=1e3,this._panX=0,this._panY=0,this._boundingRadius=1,this._sceneCenter=new ce.Vector3,this._mouseDown=!1,this._mouseButton=-1,this._lastMousePos={x:0,y:0},this._setupMouseHandlers();let i=new ce.AmbientLight(16777215,.5);this._scene.add(i);let r=new ce.DirectionalLight(16777215,.8);r.position.set(1,1,1).normalize(),this._scene.add(r);let s=new ce.DirectionalLight(16777215,.3);s.position.set(-1,-.5,.5).normalize(),this._scene.add(s),e.on("resize",this.onResize.bind(this)),e.on("open",this.onOpen.bind(this)),e.on("destroy",this.onDestroy.bind(this)),this._designGroup=new ce.Group,this._scene.add(this._designGroup),this._chipletMeshes=[],this._loading=!1,this._destroyed=!1,this._edgeMaterial=null}_setupMouseHandlers(){let e=this._renderer.domElement;e.addEventListener("mousedown",t=>{this._mouseDown=!0,this._mouseButton=t.button,this._lastMousePos.x=t.clientX,this._lastMousePos.y=t.clientY,e.focus(),t.preventDefault()}),e.addEventListener("contextmenu",t=>t.preventDefault()),this._onMouseMove=t=>{if(!this._mouseDown)return;let i=t.clientX-this._lastMousePos.x,r=t.clientY-this._lastMousePos.y;this._lastMousePos.x=t.clientX,this._lastMousePos.y=t.clientY,!(i===0&&r===0)&&(this._mouseButton===0?this._handleRotate(i,r):this._mouseButton===2&&this._handlePan(i,r),this._updateCamera())},this._onMouseUp=t=>{this._mouseDown&&t.button===this._mouseButton&&(this._mouseDown=!1,this._mouseButton=-1)},window.addEventListener("mousemove",this._onMouseMove),window.addEventListener("mouseup",this._onMouseUp),e.addEventListener("wheel",t=>{t.preventDefault(),t.deltaY<0?this._distance*=t5:this._distance*=n5;let i=Math.max(this._boundingRadius*i5,1),r=Math.max(this._boundingRadius*r5,i);this._distance=Math.max(i,Math.min(r,this._distance)),this._updateCamera()},{passive:!1}),e.tabIndex=0,e.style.outline="none",e.addEventListener("keydown",t=>{t.key.toLowerCase()==="f"&&this.resetCamera()}),e.addEventListener("dblclick",t=>{t.preventDefault();let i=this._pickDrcMarkerId(t);if(i!=null&&this._app.drcWidget){this._app.drcWidget.highlightMarkerById(i,!0);return}this.resetCamera()}),e.addEventListener("mousemove",t=>{if(this._mouseDown){this._hideTooltip();return}this._updateTooltip(t)}),e.addEventListener("mouseleave",()=>{this._hideTooltip()})}_createOptionsOverlay(){let e=document.createElement("div");e.className="three-d-options";let t=document.createElement("label");t.title="Render chiplets at their true Z (disable stacking offset for overlapping chiplets at same Z).";let i=document.createElement("input");i.type="checkbox",i.checked=!!this._app.useTrueZ,i.addEventListener("change",()=>{this._app.useTrueZ=i.checked,Ue("or_use_true_z",i.checked?"1":"0"),this._app.syncDisplayState(),this.refreshSceneForOptions()}),t.appendChild(i),t.appendChild(document.createTextNode("True Z (no stacking)")),e.appendChild(t);let r=document.createElement("div");r.style.cssText="margin-top:4px; display:flex; gap:4px;";let s=document.createElement("button");s.className="or-btn or-btn-sm",s.textContent="Save PNG",s.title="Save the 3D view as a PNG image (2x resolution)",s.addEventListener("click",()=>this._exportPng(2));let o=document.createElement("button");return o.className="or-btn or-btn-sm",o.textContent="Copy",o.title="Copy the 3D view image to the clipboard",o.addEventListener("click",()=>this._copyImage(2)),r.appendChild(s),r.appendChild(o),e.appendChild(r),e}_capturePng(e=2){if(!this._renderer)return null;let t=this._renderer,i=t.domElement.clientWidth||t.domElement.width,r=t.domElement.clientHeight||t.domElement.height,s=t.getPixelRatio();try{return t.setPixelRatio(s*e),t.setSize(i,r,!1),this.render(),t.domElement.toDataURL("image/png")}finally{t.setPixelRatio(s),t.setSize(i,r,!1),this.render()}}_exportPng(e=2){let t=this._capturePng(e);t&&Ts(t,"3d-view.png")}async _copyImage(e=2){let t=this._capturePng(e);t&&await Nh(t)}_setRaycasterFromEvent(e){let i=this._renderer.domElement.getBoundingClientRect(),r=new ce.Vector2((e.clientX-i.left)/i.width*2-1,-((e.clientY-i.top)/i.height*2-1));this._raycaster.setFromCamera(r,this._camera)}_updateTooltip(e){if(!this._chipletMeshes.length){this._hideTooltip();return}this._setRaycasterFromEvent(e);let t=this._chipletMeshes.map(a=>a.mesh),i=this._raycaster.intersectObjects(t,!1);if(i.length===0){this._hideTooltip();return}let r=i[0].object,s=this._chipletMeshes.find(a=>a.mesh===r);if(!s){this._hideTooltip();return}this._tooltip.textContent=s.data.name,this._tooltip.style.display="block";let o=this._canvasContainer.getBoundingClientRect();this._tooltip.style.left=e.clientX-o.left+12+"px",this._tooltip.style.top=e.clientY-o.top+12+"px"}_hideTooltip(){this._tooltip&&(this._tooltip.style.display="none")}_pickDrcMarkerId(e){if(!this._drcHitboxMesh||!this._drcHitboxMarkerIds)return null;this._setRaycasterFromEvent(e);let t=this._raycaster.intersectObject(this._drcHitboxMesh,!1);if(t.length===0)return null;let i=t[0].instanceId;return i==null?null:this._drcHitboxMarkerIds[i]??null}_handleRotate(e,t){let i=Math.sqrt(e*e+t*t);if(i<.001)return;let r=new ce.Vector3(t/i,e/i,0),s=i/OM,a=new ce.Quaternion().setFromAxisAngle(r,s*ip).clone().multiply(this._rotation);if(new ce.Vector3(0,0,1).applyQuaternion(a).z>=0)this._rotation.copy(a);else{let l=new ce.Vector3(0,1,0),u=e/OM*ip,d=new ce.Quaternion().setFromAxisAngle(l,u).clone().multiply(this._rotation);new ce.Vector3(0,0,1).applyQuaternion(d).z>=0&&this._rotation.copy(d)}}_handlePan(e,t){let i=this._distance*e5;this._panX+=e*i,this._panY-=t*i}_updateCamera(){let e=Math.max(this._boundingRadius,1e3),t=Math.max(this._distance-e*DM,o5),i=this._distance+e*DM;i0;){let e=this._designGroup.children[0];this._designGroup.remove(e),e.geometry&&e.geometry.dispose(),e.material&&!e.material._shared&&e.material.dispose()}this._edgeMaterial&&(this._edgeMaterial.dispose(),this._edgeMaterial=null),this._onMouseMove&&(window.removeEventListener("mousemove",this._onMouseMove),this._onMouseMove=null),this._onMouseUp&&(window.removeEventListener("mouseup",this._onMouseUp),this._onMouseUp=null),this._renderer&&(this._renderer.dispose(),this._renderer=null),this._app.threeDViewerWidget===this&&(this._app.threeDViewerWidget=null)}}_setInitialCameraState(){this._distance=this._boundingRadius*s5;let e=new ce.Quaternion().setFromAxisAngle(new ce.Vector3(1,0,0),-45*ip),t=new ce.Quaternion().setFromAxisAngle(new ce.Vector3(0,0,1),45*ip);this._rotation=e.multiply(t),this._panX=0,this._panY=0}resetCamera(){this._sceneBounds&&(this._setInitialCameraState(),this._updateCamera())}onResize(){if(this._destroyed)return;let e=this._canvasContainer.getBoundingClientRect(),t=e.width,i=e.height;t===0||i===0||(this._camera.aspect=t/i,this._camera.updateProjectionMatrix(),this._renderer.setSize(t,i),this.render())}render(){this._destroyed||this._renderer&&this._scene&&this._camera&&this._renderer.render(this._scene,this._camera)}_applyTheme(){let t=Cs().bgMap||"#000000";this._scene.background=new ce.Color(t)}async loadData(){if(!(this._loading||this._destroyed)){this._loading=!0;for(let e of[".three-d-error",".three-d-info"]){let t=this._element.querySelector(e);t&&t.remove()}try{await this._app.websocketManager.readyPromise;let e=await this._app.websocketManager.request({type:"get_3d_data"});if(this._destroyed)return;if(e&&e.error){this._showError(e.error);return}if(e&&e.info){this._showInfo(e.info);return}this.buildScene(e)}catch(e){if(this._destroyed)return;console.error("Failed to load 3D data:",e),this._showError(e.message||String(e))}finally{this._loading=!1}}}_showOverlay(e,t,i){let r=document.createElement("div");r.className=e,r.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-family:monospace;text-align:center;",r.style.color=i,r.textContent=t,this._element.appendChild(r)}_showError(e){this._showOverlay("three-d-error","Failed to load 3D data: "+e,"var(--error)")}_showInfo(e){this._showOverlay("three-d-info",e,"var(--fg-muted, #888)")}_showWebGLUnavailable(e){let t=document.createElement("div");t.className="three-d-error",t.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-family:monospace;text-align:center;max-width:80%;color:var(--error);";let i=e&&e.message?e.message:String(e||"");t.innerHTML='
3D viewer unavailable: WebGL context could not be created.
In Chrome, open chrome://flags/#ignore-gpu-blocklist and set Override software rendering list to Enabled, then relaunch the browser.
Otherwise enable hardware acceleration or try a different browser. See chrome://gpu for details.
'+(i?'
'+i+"
":""),this._element.appendChild(t)}buildScene(e){if(this._destroyed||(this._lastSceneData=e,this._clearScene(),!e||!e.chiplets||e.chiplets.length===0))return;let t=this._app.getDbuPerMicron(),i=this._buildChiplets(e.chiplets,t);i.minX!==1/0&&(this._buildGrid(i),this._setSceneBoundsAndCenter(i),this._setInitialCameraState(),this._updateCamera())}_clearScene(){for(this._chipletMeshes=[];this._designGroup.children.length>0;){let e=this._designGroup.children[0];this._designGroup.remove(e),e.geometry&&e.geometry.dispose(),e.material&&!e.material._shared&&e.material.dispose()}this._hideTooltip()}_buildChiplets(e,t){let i={minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0};this._edgeMaterial||(this._edgeMaterial=new ce.LineBasicMaterial({color:0,linewidth:1}),this._edgeMaterial._shared=!0);let r=this._app.useTrueZ?new Array(e.length).fill(0):f5(e);return e.forEach((s,o)=>{let a=s.width/t,c=s.height/t,l=s.thickness/t*As,u=NM[o%NM.length],f=new ce.MeshPhongMaterial({color:u,transparent:!1,opacity:1,side:ce.DoubleSide,shininess:40}),d=new ce.BoxGeometry(a,c,l),h=new ce.Mesh(d,f),p=s.x/t+a/2,m=s.y/t+c/2,g=l*c5,v=s.z/t*As+l/2+r[o]*(l+g);h.position.set(p,m,v),this._designGroup.add(h),this._chipletMeshes.push({mesh:h,data:s,color:u});let y=new ce.EdgesGeometry(d),b=new ce.LineSegments(y,this._edgeMaterial);b.position.set(p,m,v),this._designGroup.add(b),i.minX=Math.min(i.minX,s.x/t),i.minY=Math.min(i.minY,s.y/t),i.minZ=Math.min(i.minZ,v-l/2),i.maxX=Math.max(i.maxX,s.x/t+a),i.maxY=Math.max(i.maxY,s.y/t+c),i.maxZ=Math.max(i.maxZ,v+l/2)}),i}_buildGrid(e){let t=e.maxX-e.minX,i=e.maxY-e.minY,r=Math.max(t,i)*1.4,s=10,o=new ce.GridHelper(r,s,8947848,4473924);o.rotation.x=Math.PI/2,o.position.set((e.minX+e.maxX)/2,(e.minY+e.maxY)/2,e.minZ-1),this._designGroup.add(o)}_setSceneBoundsAndCenter(e){this._sceneBounds=e;let t=e.maxX-e.minX,i=e.maxY-e.minY,r=e.maxZ-e.minZ;this._boundingRadius=Math.sqrt(t*t+i*i+r*r)/2,this._sceneCenter.set((e.minX+e.maxX)/2,(e.minY+e.maxY)/2,(e.minZ+e.maxZ)/2)}_stackOffsetForPoint(e,t,i,r){for(let{mesh:s,data:o}of this._chipletMeshes){if(e!==o.z||to.x+o.width||io.y+o.height)continue;let a=o.thickness/r*As,c=o.z/r*As+a/2;return s.position.z-c}return 0}clearHighlightDRC(){this._drcBlinkInterval&&(clearInterval(this._drcBlinkInterval),this._drcBlinkInterval=null),this._drcMeshGroup&&(this._scene.remove(this._drcMeshGroup),this._drcMeshGroup.children.forEach(e=>{e.geometry&&e.geometry.dispose()}),this._drcMaterial&&(this._drcMaterial.dispose(),this._drcMaterial=null),this._drcHitboxMaterial&&(this._drcHitboxMaterial.dispose(),this._drcHitboxMaterial=null),this._drcHitboxMesh=null,this._drcHitboxMarkerIds=null,this._drcMeshGroup=null,this.render())}highlightDRC(e){if(this._destroyed||(this.clearHighlightDRC(),!e||e.length===0))return;let t=this._app.getDbuPerMicron(),i=0,r=1e4/t*As;this._sceneBounds&&this._sceneBounds.minZ!==1/0&&(i=this._sceneBounds.minZ,r=this._sceneBounds.maxZ),i-=1,r+=1;let s=Math.max(r-i,1);this._drcMeshGroup=new ce.Group,this._drcMaterial=new ce.LineBasicMaterial({color:16776960,transparent:!0,opacity:1,depthTest:!1,depthWrite:!1}),this._drcHitboxMaterial=new ce.MeshBasicMaterial({transparent:!0,opacity:0,depthWrite:!1});let o=[];for(let l of e){let u=l.rects&&l.rects.length>0?l.rects:[l.bbox];for(let f of u){let[d,h,p,m,g,v]=f,y=Math.max((p-d)/t,.001),b=Math.max((m-h)/t,.001),w=i,E=s,x=0;if(f.length>=6&&g!==void 0&&v!==void 0){w=g/t*As;let D=v/t*As;E=Math.max(D-w,.001),x=this._stackOffsetForPoint(g,(d+p)/2,(h+m)/2,t)}let T=d/t+y/2,I=h/t+b/2,N=w+E/2+x;o.push({cx:T,cy:I,cz:N,width:y,height:b,depth:E,markerId:l.id})}}if(o.length>0){let l=new ce.BoxGeometry(1,1,1);this._drcHitboxMesh=new ce.InstancedMesh(l,this._drcHitboxMaterial,o.length),this._drcHitboxMarkerIds=new Array(o.length);let u=new ce.Matrix4,f=new ce.Vector3,d=new ce.Vector3,h=new ce.Quaternion;o.forEach((p,m)=>{d.set(p.cx,p.cy,p.cz),f.set(p.width,p.height,p.depth),u.compose(d,h,f),this._drcHitboxMesh.setMatrixAt(m,u),this._drcHitboxMarkerIds[m]=p.markerId;let g=new ce.BoxGeometry(p.width,p.height,p.depth),v=new ce.EdgesGeometry(g);g.dispose();let y=new ce.LineSegments(v,this._drcMaterial);y.position.set(p.cx,p.cy,p.cz),y.renderOrder=999,this._drcMeshGroup.add(y)}),this._drcHitboxMesh.instanceMatrix.needsUpdate=!0,this._drcMeshGroup.add(this._drcHitboxMesh)}this._drcMeshGroup.renderOrder=999,this._scene.add(this._drcMeshGroup),this.render();let a=!0,c=0;this._drcBlinkInterval=setInterval(()=>{if(!(!this._drcMeshGroup||!this._drcMaterial)){if(c+=1,c>=u5){this._drcMaterial.opacity=1,this.render(),clearInterval(this._drcBlinkInterval),this._drcBlinkInterval=null;return}a=!a,this._drcMaterial.opacity=a?1:.2,this.render()}},l5)}refreshSceneForOptions(){this._destroyed||this._lastSceneData&&(this.clearHighlightDRC(),this.buildScene(this._lastSceneData))}};var d5=[{name:"green",hex:"#00ff00"},{name:"yellow",hex:"#ffff00"},{name:"cyan",hex:"#00ffff"},{name:"magenta",hex:"#ff00ff"},{name:"red",hex:"#ff0000"},{name:"dark_green",hex:"#008000"},{name:"dark_magenta",hex:"#800080"},{name:"blue",hex:"#0000ff"},{name:"orange",hex:"#ffa500"},{name:"purple",hex:"#800080"},{name:"lime",hex:"#bfff00"},{name:"teal",hex:"#008080"},{name:"pink",hex:"#ffc0cb"},{name:"brown",hex:"#8b4513"},{name:"indigo",hex:"#4b0082"},{name:"turquoise",hex:"#40e0d0"}],h5=[{label:"Connected Insts",suffix:"connected_insts",needsNet:!0},{label:"Output Nets",suffix:"connected_nets",args:{output:!0,input:!1}},{label:"Input Nets",suffix:"connected_nets",args:{output:!1,input:!0}},{label:"All Nets",suffix:"connected_nets",args:{output:!0,input:!0}},{label:"All buffer trees",suffix:"connected_buffer_trees"},{label:"All buffer trees (incl. inverters)",suffix:"connected_buffer_trees",args:{include_inverters:!0}}],sp=class{constructor(e){this._app=e,this._el=document.createElement("div"),this._el.className="context-menu",this._el.style.display="none",this._el.style.zIndex="10000",document.body.appendChild(this._el),this._bindEvents()}_bindEvents(){document.addEventListener("mousedown",e=>{this._el.contains(e.target)||this.hide()}),this._app.view&&this._app.view.on("movestart",()=>this.hide())}show(e){this._el.innerHTML="";let t=!!this._app.selHasInst,i=!!this._app.selHasNet,r=!(t||i),s=h=>h5.map(p=>({label:p.label,disabled:p.needsNet?!i:!t,...h(p.suffix,p.args||{})})),o=[{label:"Select",disabled:r,subMenu:s((h,p)=>({action:()=>this._sendContextAction("select_"+h,p)}))},{label:"Highlight",disabled:r,subMenu:s((h,p)=>({subMenu:this._buildColorSubmenu("highlight_"+h,p)}))},{label:"Save",subMenu:[{label:"Visible layout",action:()=>this._app.captureLayout?.({entire:!1})},{label:"Entire layout",action:()=>this._app.captureLayout?.({entire:!0})}]},{label:"Clear",subMenu:[{label:"Selections",action:()=>this._sendContextAction("clear_selections")},{label:"Highlights",action:()=>this._sendContextAction("clear_highlights")},{label:"Rulers",action:()=>{this._app.rulerManager?.clearAllRulers()}},{label:"Focus nets",action:()=>this._sendContextAction("clear_focus_nets")},{label:"Route Guides",action:()=>this._sendContextAction("clear_route_guides")},{label:"All",action:()=>{this._sendContextAction("clear_all"),this._app.rulerManager?.clearAllRulers()}}]}];this._buildMenu(o,this._el),this._el.style.display="block";let a=4,c=this._el.getBoundingClientRect(),l=window.innerWidth-c.width-a,u=window.innerHeight-c.height-a,f=Math.max(a,Math.min(e.clientX,l)),d=Math.max(a,Math.min(e.clientY,u));this._el.style.left=f+"px",this._el.style.top=d+"px"}hide(){this._el.style.display="none"}_buildColorSubmenu(e,t={}){return d5.map(({name:i,hex:r},s)=>({label:i,swatch:r,action:()=>this._sendContextAction(e,{...t,group:s})}))}_buildMenu(e,t){e.forEach(i=>{let r=document.createElement("div");if(r.className="cm-item",i.swatch){let s=document.createElement("span");s.className="cm-swatch",s.style.background=i.swatch,r.appendChild(s)}if(r.appendChild(document.createTextNode(i.label)),i.disabled){r.classList.add("disabled"),i.subMenu&&r.classList.add("has-submenu"),t.appendChild(r);return}if(i.subMenu){r.classList.add("has-submenu");let s=document.createElement("div");s.className="cm-submenu",this._buildMenu(i.subMenu,s),r.appendChild(s),r.addEventListener("mouseenter",()=>{s.classList.remove("flip-left"),s.getBoundingClientRect().right>window.innerWidth&&s.classList.add("flip-left")})}else i.action&&r.addEventListener("click",s=>{s.stopPropagation(),this.hide();try{i.action()}catch(o){console.error("Context menu item action threw:",i.label,o)}});t.appendChild(r)})}_sendContextAction(e,t={}){this._app.websocketManager&&this._app.websocketManager.request({type:"context_action",action:e,...t}).then(i=>{qo(this._app,i),i&&i.connected_count===0&&nn('Nothing connected \u2014 select an instance (or a net for "Connected Insts") first.'),this._syncAfterAction(e)}).catch(i=>{console.error("Context action failed:",e,i)})}_syncAfterAction(e){let t=this._app;(e==="clear_focus_nets"||e==="clear_route_guides"||e==="clear_all")&&typeof t.redrawAllLayers=="function"&&t.redrawAllLayers(),e==="clear_selections"||e==="clear_all"?(t.updateInspector?.(null),t.stopSelectionAnimation?.(),t.clearSelectionOutline?.(),t.lastSelectionBounds=null):t.refreshInspector?.(),t.refreshOverlay?.()}};function FM(n,e){if(!n)return;let t=URL.createObjectURL(n),i=document.createElement("a");i.href=t,i.download=e,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(t),0)}function p5(n,e,t){n.view.getContainer().querySelectorAll(".or-view-markers .ruler-label").forEach(r=>{let s=r.getBoundingClientRect();if(s.width<=0||s.height<=0)return;let o=r.textContent;if(!o)return;let a=getComputedStyle(r),c=s.left-t.left,l=s.top-t.top;e.save(),e.fillStyle=a.backgroundColor||"rgba(0, 0, 0, 0.75)";let u=Math.min(parseFloat(a.borderTopLeftRadius)||0,s.height/2);u>0&&typeof e.roundRect=="function"?(e.beginPath(),e.roundRect(c,l,s.width,s.height,u),e.fill()):e.fillRect(c,l,s.width,s.height),e.fillStyle=a.color||"#eee",e.font=a.font||`${a.fontSize||"12px"} ${a.fontFamily||"monospace"}`,e.textAlign="left",e.textBaseline="middle",e.fillText(o,c+(parseFloat(a.paddingLeft)||0),l+s.height/2),e.restore()})}async function zM(n){let e=n.view.getContainer(),t=e.getBoundingClientRect(),i=Math.max(1,Math.round(t.width)),r=Math.max(1,Math.round(t.height)),s=document.createElement("canvas");s.width=i,s.height=r;let o=s.getContext("2d"),a=getComputedStyle(e).backgroundColor;o.fillStyle=a&&a!=="transparent"&&a!=="rgba(0, 0, 0, 0)"?a:"#000",o.fillRect(0,0,i,r);let c=await n.view.captureCanvas();if(c){let l=c.rect;try{o.drawImage(c.image,l.left-t.left,l.top-t.top,l.width,l.height)}catch{}}return p5(n,o,t),new Promise(l=>s.toBlob(l,"image/png"))}async function UM(n,{entire:e=!1}={}){if(!n.view)return;if(!e||!n.fitRect){FM(await zM(n),"layout_visible.png");return}let t=n.view.getCenter(),i=n.view.getZoom();try{n.view.fitWorldRect(n.fitRect,{animate:!1}),await n.view.whenTilesSettled(),FM(await zM(n),"layout_entire.png")}finally{n.view.setView(t,i,{animate:!1})}}var hr=document.getElementById("websocket-status"),ql=null,m5=2e3,g5=20;function GM(){let n=_.websocketManager&&_.websocketManager.isConnected,e=_.websocketManager?_.websocketManager.pendingCount:0;if(n)if(ql&&(clearTimeout(ql),ql=null),e>g5){let t=`pending: ${e}`,i=hr.firstElementChild;(!i?.classList.contains("pending-indicator")||i.textContent!==t)&&(hr.innerHTML=`
${t}
`),hr.style.display="block"}else hr.style.display="none";else{if(_.websocketManager?._shutdown)return;ql||(ql=setTimeout(()=>{_.websocketManager?.isConnected||(hr.innerHTML='
\u26A0 OpenROAD disconnected \u2014 retrying\u2026
',hr.style.display="block")},m5))}_5(e)}function _5(n){let e=_.tileProgressEl;if(!e)return;e.classList.toggle("active",n>0);let t=n>0?`${n} tile requests pending`:"";e.title!==t&&(e.title=t)}var $M=cr(GM);function y5(n){if(!n)return"";try{return decodeURIComponent(n)}catch{return""}}var _={view:null,fitRect:null,lastSelectionBounds:null,selHasInst:!1,selHasNet:!1,displayControlsEl:null,allLayers:[],designScale:null,designOriginX:0,designOriginY:0,websocketManager:null,goldenLayout:null,hasLiberty:!1,techData:null,inspectorEl:null,tclOutputEl:null,modulesLayer:null,pinsLayer:null,overlayLayers:[],hierarchyBrowser:null,focusNets:new Set,routeGuideNets:new Set,visibleLayers:new Set,visibleLayerNames:new Set,visibleChiplets:null,layerPatterns:{},useTrueZ:Be("or_use_true_z")==="1",showDbu:Be("or_show_dbu")==="1",rulerStyle:Be("or_ruler_style")==="manhattan"?"manhattan":"euclidian",wheelZoom:Be("or_wheel_zoom")!=="0",arrowStep:$l(Be("or_arrow_step")),controlSmoothing:Be("or_control_smoothing")!=="0",doubleBuffer:Be("or_double_buffer")!=="0",deferTileUpdates:Be("or_defer_tile_updates")==="1",fontFamily:y5(Be("or_font_family")),fontScale:Wl(Be("or_font_scale")),polyDecomp:!1,labelManager:null,selectableLayers:new Set,heatMapData:null,activeHeatMap:"",heatMapLayer:null,heatMapLegendEl:null,renderHeatMapControls:null,rulerManager:null,selectionToken:0,selectionResetters:[],getDbuPerMicron(){return this.techData?.dbu_per_micron||1e3},unitOpts(){return{showDbu:this.showDbu,dbuPerMicron:this.getDbuPerMicron()}},formatDbu(n,e=!1){return D3(n,this.unitOpts(),e)},parseDbu(n){return N3(n,this.unitOpts())},formatDistance(n){return F3(n,this.unitOpts())},unitLabel(){return z3(this.unitOpts())}},gt={stdcells:!0,macros:!0,pad_input:!0,pad_output:!0,pad_inout:!0,pad_power:!0,pad_spacer:!0,pad_areaio:!0,pad_other:!0,phys_fill:!1,phys_endcap:!0,phys_welltap:!0,phys_tie:!0,phys_antenna:!0,phys_cover:!0,phys_bump:!0,phys_other:!0,std_bufinv:!0,std_bufinv_timing:!0,std_clock_bufinv:!0,std_clock_gate:!0,std_level_shift:!0,std_sequential:!0,std_combinational:!0,net_signal:!0,net_power:!0,net_ground:!0,net_clock:!0,net_reset:!0,net_tieoff:!0,net_scan:!0,net_analog:!0,inst_names:!0,inst_pins:!0,inst_pin_names:!1,routing:!0,routing_segments:!0,routing_vias:!0,special_nets:!0,srouting_segments:!0,srouting_vias:!0,pins:!0,pin_names:!0,access_points:!1,regions:!0,mfg_grid:!1,gcell_grid:!1,flywires_only:!1,blockages:!0,placement_blockages:!0,routing_obstructions:!0,fills:!1,rows:!1,tracks_pref:!1,tracks_non_pref:!1,module_view:!1,detailed:!1,rulers:!0,labels:!0,scale_bar:!0,focused_nets_guides:!1,highlight_selected:!0,debug:!1};try{let n=Be("or_visibility");if(n){let e=JSON.parse(decodeURIComponent(n));for(let[t,i]of Object.entries(e))gt[t]=!!i}}catch{}var ta={stdcells:!0,macros:!0,pad_input:!0,pad_output:!0,pad_inout:!0,pad_power:!0,pad_spacer:!0,pad_areaio:!0,pad_other:!0,phys_fill:!0,phys_endcap:!0,phys_welltap:!0,phys_tie:!0,phys_antenna:!0,phys_cover:!0,phys_bump:!0,phys_other:!0,std_bufinv:!0,std_bufinv_timing:!0,std_clock_bufinv:!0,std_clock_gate:!0,std_level_shift:!0,std_sequential:!0,std_combinational:!0,net_signal:!0,net_power:!0,net_ground:!0,net_clock:!0,net_reset:!0,net_tieoff:!0,net_scan:!0,net_analog:!0,pins:!0,inst_pins:!0,placement_blockages:!0,routing_obstructions:!0};_.visibility=gt;_.selectability=ta;try{let n=Be("or_selectability");if(n){let e=JSON.parse(decodeURIComponent(n));for(let[t,i]of Object.entries(e))ta[t]=!!i}}catch{}(function(){let e=null;try{e=new URLSearchParams(window.location.search)}catch{return}_.forceComposite=e.get("composite")==="1",_.preserveBuffer=e.get("preservebuffer")==="1";let t=Number(e.get("grouplayers"));Number.isFinite(t)&&t>0&&(_.groupLayers=Math.floor(t))})();_.tileCtx={visibility:gt,selectability:ta,visibleLayers:_.visibleLayerNames,selectableLayers:_.selectableLayers,app:_};function b5(){return _.view.addTileSlot("heatmap",{order:at.heatmap,visible:!!_.activeHeatMap,source:qb({wm:_.websocketManager,dpr:Yo,tileSize:tn,buildRequest:(n,e,t)=>C3(n,e,t,_)})})}function fv(n){if(_.heatMapData=n,_.activeHeatMap=n.active||"",_.heatMapLayer){let e=_.heatMapLayer.isVisible();_.heatMapLayer.setVisible(!!_.activeHeatMap),e&&_.heatMapLayer.refresh()}_.renderHeatMapControls&&_.renderHeatMapControls(n)}_.updateHeatMaps=fv;function dv(){_.overlayLayer&&_.overlayLayer.refresh()}var ks=cr(()=>{dv(),_.selectionBrowser&&_.selectionBrowser.scheduleRefresh()});_.refreshOverlay=ks;function Ft(){Ue("or_visibility",encodeURIComponent(JSON.stringify(gt))),Ue("or_selectability",encodeURIComponent(JSON.stringify(ta))),rn();let n=[[_.modulesLayer,gt.module_view],[_.pinsLayer,gt.pins],..._.overlayLayers.map(({def:e,layer:t})=>[t,Yh(e.shown_by,gt)])];for(let[e,t]of n)e&&(e.visible=!!t);for(let e of _.allLayers)e.refresh();_.heatMapLayer&&_.heatMapLayer.refresh(),_.renderSelectionOutline&&_.renderSelectionOutline(),!gt.highlight_selected&&_.clearSelectionPulse&&_.clearSelectionPulse(),dv(),_.rulerManager&&_.rulerManager.updateVisibility(),_.labelManager&&_.labelManager.updateVisibility(),_.updateScaleBar&&_.updateScaleBar()}var ea=cr(Ft),rn=cr(()=>{!_.websocketManager||ue(_)||_.websocketManager.request({type:"set_display_state",state:RM()}).catch(()=>{})});_.syncDisplayState=rn;function v5(n){if(!n||typeof n!="object")return;let e=n.entries;if(!(!e||typeof e!="object")){IM(e);try{if(_.view&&_.designScale&&typeof sessionStorage<"u"){let[t,i]=_.view.getCenter(),{dbuX:r,dbuY:s}=wn(t,i,_.designScale,_.designOriginX,_.designOriginY);sessionStorage.setItem("or_restore_view",JSON.stringify({dbuX:r,dbuY:s,zoom:_.view.getZoom()}))}}catch{}window.location.reload()}}_.redrawAllLayers=Ft;_.captureLayout=(n={})=>UM(_,n);function x5(n){let e=document.createElement("div");e.className="layout-viewer",e.style.width="100%",e.style.height="100%",e.style.backgroundColor="var(--bg-map)",n.element.appendChild(e);let t=document.createElement("div");t.className="or-hud or-hud-bottom-right heatmap-map-legend hidden",e.appendChild(t),_.heatMapLegendEl=t;let i=document.createElement("div");i.className="or-progress",e.appendChild(i),_.tileProgressEl=i,n.on("destroy",()=>{_.tileProgressEl=null,_.heatMapLegendEl=null}),_.view=q3(e,{preserveDrawingBuffer:_.preserveBuffer,prefs:{smooth:()=>_.controlSmoothing,doubleBuffer:()=>_.doubleBuffer,defer:()=>_.deferTileUpdates},tileSize:tn,dpr:Yo,isStatic:ue(_)}),_.view.on("contextlost",()=>{console.warn("Layout view: WebGL context lost; rebuilding the view.")}),_.view.on("contextfailed",()=>{nn("The layout view lost its graphics context and could not get it back; reload the page.",15e3)}),window.__orView=_.view,p3(()=>{_.view.invalidateSize(),Ft()});let r=document.createElement("div");r.className="or-zoom-control";let s=[];for(let[y,b,w]of[["+","Zoom in",()=>_.view.zoomIn()],["\u2212","Zoom out",()=>_.view.zoomOut()],["\u2922","Fit",()=>{_.fitRect&&_.view.fitWorldRect(_.fitRect)}]]){let E=document.createElement("button");E.type="button",E.title=b,E.setAttribute("aria-label",b),E.textContent=y,E.addEventListener("click",x=>{x.stopPropagation(),w()}),r.appendChild(E),s.push(E)}e.appendChild(r);let o=()=>{let{minZoom:y,maxZoom:b}=_.view.getLimits(),w=_.view.getTargetZoom();s[0].disabled=w>=b,s[1].disabled=w<=y};_.view.on("zoom zoomend limits",o),o();let a=document.createElement("div");a.className="or-hud or-hud-bottom-left hidden";let c=document.createElement("div");c.id="scale-bar";let l=document.createElement("span");l.className="or-hud-divider";let u=document.createElement("div");u.id="coord-bar",a.appendChild(c),a.appendChild(l),a.appendChild(u),e.appendChild(a);function f(){let y=c.style.display!=="none"&&c.childElementCount>0,b=u.textContent!=="";l.style.display=y&&b?"":"none",a.classList.toggle("hidden",!y&&!b)}f(),X3(_.view,{isStatic:()=>ue(_),wheelZoom:()=>_.wheelZoom,arrowStep:()=>_.arrowStep,contextEnabled:()=>!(_.rulerManager&&_.rulerManager.isActive()),onClick:(y,b)=>{_.rulerManager&&_.rulerManager.isActive()?_.rulerManager.handleMapClick(y,b):_.rulerManager?.handleRulerClick(y)||_.onMapClick&&_.onMapClick(y,b)},onContextClick:(y,b)=>{_.onMapContextClick&&_.onMapContextClick(y,b)},onMove:(y,b)=>{if(_.lastMouseWorld=y,_.rulerManager&&_.rulerManager.isActive()&&_.rulerManager.handleMouseMove(y,b),!_.designScale)return;let{dbuX:w,dbuY:E}=wn(y[0],y[1],_.designScale,_.designOriginX,_.designOriginY);u.textContent=`X: ${_.formatDbu(w)} Y: ${_.formatDbu(E)}`,f()},onLeave:()=>{_.lastMouseWorld=null,u.textContent="",f()}});let d=22,h=8,p=22;function m(y,b,w){let x=2+h,T=p,I=p+y,N=d-2,D=y>=40,H=[];if(H.push(``),D&&w>1)for(let W=1;W`)}D&&H.push(`0`),H.push(`${b}`),c.innerHTML=`${H.join("")}`}function g(){if(!_.designScale||!gt.scale_bar){c.style.display="none",f();return}let y=_.designScale*Math.pow(2,_.view.getZoom()),b=_.view.getSize().width||400,w=$3({targetPx:b*.15,pxPerDbu:y,dbuPerMicron:_.techData?.dbu_per_micron,showDbu:_.showDbu});if(!w){c.style.display="none",f();return}c.style.display="",m(w.barPx,w.label,w.segments),f()}let v=cr(g);_.view.on("zoom zoomend resize",v),_.updateScaleBar=g,_.rulerManager=new Kh(_,gt,Zl,op),_.labelManager=new Jh(_,gt,Zl,op)}function w5(n){let e=document.createElement("div");e.className="display-controls",e.innerHTML='
Loading layers...
',n.element.appendChild(e),_.displayControlsEl=e}var uv="or_restore_console",E5=1<<20;function S5(){try{if(_.tclOutputEl){let n=[..._.tclOutputEl.children].map(r=>[r.textContent,r.className]),e=n.length,t=0;for(;e>0&&t+n[e-1][0].length<=E5;)t+=n[--e][0].length;let i=n.slice(e);e>0&&i.unshift([`[earlier output not kept across reload] -`,""]),sessionStorage.setItem(uv,JSON.stringify(i))}}catch{}window.location.reload()}function P5(){try{let n=sessionStorage.getItem(uv);if(!n)return;sessionStorage.removeItem(uv);for(let[e,t]of JSON.parse(n))pr(e,t)}catch{}}function pr(n,e){if(!_.tclOutputEl)return;let t=document.createElement("span");e&&(t.className=e),t.textContent=n,_.tclOutputEl.appendChild(t),_.tclOutputEl.scrollTop=_.tclOutputEl.scrollHeight}function C5(){if(_._shutdownHandled)return;_._shutdownHandled=!0,_.websocketManager&&(_.websocketManager._shutdown=!0,_.websocketManager.onPush=()=>{});let n=document.createElement("div");n.style.cssText="position:fixed;inset:0;z-index:99999;background:#1e1e1e;color:#ddd;display:flex;flex-direction:column;align-items:center;justify-content:center;font-family:system-ui,sans-serif;font-size:16px;padding:24px;text-align:center;",n.innerHTML='
OpenROAD exited
You can close this tab.
',document.body.appendChild(n),setTimeout(()=>{try{window.close()}catch{}},1500)}function T5(n){let e=document.createElement("div");if(e.className="tcl-console",e.innerHTML='
%
',n.element.appendChild(e),_.tclOutputEl=e.querySelector(".tcl-output"),P5(),ue(_)){e.querySelector(".tcl-input-row").style.display="none";let r=document.createElement("span");r.className="tcl-static-notice",r.setAttribute("role","status"),r.setAttribute("aria-live","polite"),r.textContent="Tcl console is not available in saved reports.",_.tclOutputEl.appendChild(r);return}let t=e.querySelector(".tcl-input"),i=new np(t,_.websocketManager);t.addEventListener("keydown",r=>{if(!i.handleKeyDown(r)&&r.key==="Enter"){let s=t.value.trim();if(!s)return;pr(`>>> ${s} -`,"tcl-cmd"),i.addToHistory(s),t.value="",_.websocketManager.request({type:"tcl_eval",cmd:s}).then(o=>{o.result&&pr(o.result+` -`,o.is_error?"tcl-error":""),o.action==="shutdown"&&C5(),!o.is_error&&_.drcWidget&&_.drcWidget.refresh()}).catch(o=>pr(`Error: ${o} -`,"tcl-error"))}})}_.visibility=gt;var mr=cM(_,Ft,ks),L5=mr.createInspector,Zl=mr.updateInspector,M5=mr.highlightBBox,A5=mr.pulseHighlight;_.updateInspector=Zl;_.navigateInspector=mr.navigateInspector;_.refreshInspector=mr.refreshInspector;_.animateSelection=mr.animateSelection;_.stopSelectionAnimation=mr.stopSelectionAnimation;function k5(n){new Gh(n,_,Ft)}function R5(n){_.timingWidget=new Ps(_,Ft,ks),n.element.appendChild(_.timingWidget.element)}function I5(n){_.drcWidget=new tp(_,Ft,ks),n.element.appendChild(_.drcWidget.element)}function B5(n){_.clockTreeWidget=new Uh(n,_,Ft,ks)}function O5(n){_.chartsWidget=new $h(_,Ft),n.element.appendChild(_.chartsWidget.element)}function D5(n){let e=document.createElement("div");e.className="help-panel",e.innerHTML="

Keyboard Shortcuts

fFit design to viewport
scrollZoom in/out
dragPan the view
right-dragRubber-band zoom
Shift+clickAdd object to selection
Ctrl/Cmd+clickSelect object and its connected nets
kToggle ruler mode
Shift+KClear all rulers
EscapeCancel ruler (when building)
",n.element.appendChild(e)}function N5(n){_.selectionBrowser=new Vh(n,_,ks)}function F5(n){new ep(n,_)}function z5(n){_.threeDViewerWidget=new rp(n,_)}var U5=28,$5={dimensions:{headerHeight:U5},root:{type:"row",content:[{type:"component",componentType:"DisplayControls",title:"Display Controls",width:15},{type:"column",width:55,content:[{type:"stack",height:70,content:[{type:"component",componentType:"LayoutViewer",title:"Layout",isClosable:!1},{type:"component",componentType:"SchematicWidget",title:"Schematic"},{type:"component",componentType:"3DViewer",title:"3D Viewer"}]},{type:"component",componentType:"TclConsole",title:"Tcl Console",height:30}]},{type:"stack",width:30,content:[{type:"component",componentType:"Inspector",title:"Inspector"},{type:"component",componentType:"Browser",title:"Hierarchy"},{type:"component",componentType:"TimingWidget",title:"Timing"},{type:"component",componentType:"DRCWidget",title:"DRC"},{type:"component",componentType:"SelectHighlight",title:"Select Highlight"},{type:"component",componentType:"ClockWidget",title:"Clock Tree"},{type:"component",componentType:"ChartsWidget",title:"Charts"},{type:"component",componentType:"HelpWidget",title:"Help"}]}]}};_.goldenLayout=new Ch(document.getElementById("gl-container"));_.goldenLayout.registerComponentFactoryFunction("LayoutViewer",x5);_.goldenLayout.registerComponentFactoryFunction("DisplayControls",w5);_.goldenLayout.registerComponentFactoryFunction("TclConsole",T5);_.goldenLayout.registerComponentFactoryFunction("Inspector",L5);_.goldenLayout.registerComponentFactoryFunction("Browser",k5);_.goldenLayout.registerComponentFactoryFunction("TimingWidget",R5);_.goldenLayout.registerComponentFactoryFunction("DRCWidget",I5);_.goldenLayout.registerComponentFactoryFunction("ClockWidget",B5);_.goldenLayout.registerComponentFactoryFunction("ChartsWidget",O5);_.goldenLayout.registerComponentFactoryFunction("SchematicWidget",F5);_.goldenLayout.registerComponentFactoryFunction("3DViewer",z5);_.goldenLayout.registerComponentFactoryFunction("HelpWidget",D5);_.goldenLayout.registerComponentFactoryFunction("SelectHighlight",N5);var ri=window.__STATIC_CACHE__||null;if(ri)c3(),_.websocketManager=Dl.fromCache(ri,$M);else{let n=`ws://${window.location.host||"localhost:8080"}/ws`;_.websocketManager=new Dl(n,$M),_.layerExtents=new Rh,_.websocketManager.onReconnected=()=>{ap(),mv(null,null,{reloadOnChange:!0}).catch(()=>{})}}GM();_.goldenLayout.loadLayout($5);VM();function VM(){G3(document.getElementById("gl-container"))>0&&_.goldenLayout.updateSize()}_.goldenLayout.on("stateChanged",()=>{VM()});function hv(){_.goldenLayout.updateSize()}_.syncLayoutSize=hv;window.addEventListener("resize",hv);function op(n){_.goldenLayout.focusComponent(n)}_.focusComponent=op;_.resetLayout=function(){_.goldenLayout&&typeof _.goldenLayout.resetLayout=="function"&&_.goldenLayout.resetLayout()};_.toggleTheme=function(){let n=document.documentElement.dataset.theme==="dark"?"light":"dark";document.documentElement.dataset.theme=n,Jb(n),Dh(n),_.chartsWidget&&_.chartsWidget.render(),_.clockTreeWidget&&_.clockTreeWidget.render(),rn()};_.toggleShowDbu=function(){_.showDbu=!_.showDbu,Ue("or_show_dbu",_.showDbu?"1":"0"),_.rulerManager&&_.rulerManager._renderAll(),_.hierarchyBrowser&&_.hierarchyBrowser._render(),_.updateScaleBar&&_.updateScaleBar(),_.refreshInspector&&_.refreshInspector(),rn()};_.toggleRulerStyle=function(){_.rulerStyle=_.rulerStyle==="manhattan"?"euclidian":"manhattan",Ue("or_ruler_style",_.rulerStyle),rn()};_.toggleWheelZoom=function(){_.wheelZoom=!_.wheelZoom,Ue("or_wheel_zoom",_.wheelZoom?"1":"0"),rn()};_.toggleControlSmoothing=function(){_.controlSmoothing=!_.controlSmoothing,Ue("or_control_smoothing",_.controlSmoothing?"1":"0"),rn()};_.toggleDoubleBuffer=function(){_.doubleBuffer=!_.doubleBuffer,Ue("or_double_buffer",_.doubleBuffer?"1":"0"),_.view?.applyPrefs(),rn()};_.toggleDeferTileUpdates=function(){_.deferTileUpdates=!_.deferTileUpdates,Ue("or_defer_tile_updates",_.deferTileUpdates?"1":"0"),_.view?.applyPrefs(),rn()};_.setArrowStep=function(n){_.arrowStep=$l(n),Ue("or_arrow_step",String(_.arrowStep)),rn()};_.setAppFont=function({family:n,scale:e}){_.fontFamily=n??_.fontFamily,_.fontScale=Wl(e??_.fontScale),Ue("or_font_family",encodeURIComponent(_.fontFamily)),Ue("or_font_scale",String(_.fontScale)),_.applyAppFont(),rn()};_.applyAppFont=function(){let n=document.documentElement;_.fontFamily?n.style.setProperty("--or-font-family",_.fontFamily):n.style.removeProperty("--or-font-family"),n.style.setProperty("--or-font-scale",String(_.fontScale/100)),_.chartsWidget&&_.chartsWidget.render(),_.clockTreeWidget&&_.clockTreeWidget.render()};_.showArrowStepDialog=()=>fM(_);_.showAppFontDialog=()=>dM(_);_.togglePolyDecomp=function(){_.websocketManager&&_.websocketManager.request({type:"poly_decomp",value:!_.polyDecomp}).then(n=>pv(n.value)).catch(()=>{})};function pv(n){_.polyDecomp=!!n,_.rebuildMenuBar&&_.rebuildMenuBar(),_.refreshOverlay&&_.refreshOverlay()}_.applyAppFont();_.echoTcl=n=>pr(`>>> ${n} -`,"tcl-cmd");_.runTclScript=(n,e)=>n?(e&&_.echoTcl(n),_.websocketManager.request({type:"tcl_eval",cmd:n}).then(t=>(t&&t.result&&pr(t.result+` -`,t.is_error?"tcl-error":""),t)).catch(t=>{pr(`Error: ${t} -`,"tcl-error")})):Promise.resolve();function WM(n){n&&(_.customMenu=n.menu||[],_.customToolbar=n.toolbar||[],_.rebuildMenuBar&&_.rebuildMenuBar(),_.rebuildToolbar&&_.rebuildToolbar(),hv())}_.customMenu=[];_.customToolbar=[];_.scheduleRedrawAllLayers=ea;_.showGlobalConnectDialog=()=>EM(_);_.showInsertBufferDialog=n=>SM(_,n);bM(_);vM(_);_.contextMenu=new sp(_);function G5(){let n=document.getElementById("debug-continue-btn");return n||(n=document.createElement("button"),n.id="debug-continue-btn",n.className="debug-continue-btn",n.textContent="Continue",n.title="Advance the debugger (gpl, cts, ...)",n.addEventListener("click",()=>{_.websocketManager.request({type:"debug_continue"}).catch(()=>{})}),(document.getElementById("menu-bar")||document.body).appendChild(n),n)}function jM(n,e){let t=Xb(n,tn(),e);return t?(_.currentBounds=n,_.designScale=t.scale,_.designOriginX=t.originX,_.designOriginY=t.originY,_.fitRect=t.fitRect,_.view.setLimits({minZoom:0,maxZoom:B3(t.scale)}),!0):!1}async function mv(n,e,{reloadOnChange:t=!1}={}){if(ue(_)||!_.view)return!1;let i=n,r=e;if(!i)try{let l=await _.websocketManager.request({type:"bounds"});i=l.bounds,r=l.fit_bounds}catch{return!1}if(!i||R3(_.currentBounds,i))return!1;if(t)return window.location.reload(),!0;let s=!!_.designScale,[o,a]=_.view.getCenter(),c=s?wn(o,a,_.designScale,_.designOriginX,_.designOriginY):null;return jM(i,r)?(c&&_.view.setView(xn(c.dbuX,c.dbuY,_.designScale,_.designOriginX,_.designOriginY),_.view.getZoom(),{animate:!1}),_.clearSelectionOutline&&_.clearSelectionOutline(),Ft(),!0):!1}function V5(){let n=document.getElementById("loading-overlay");n.style.display="flex";let e=()=>{n.style.display!=="none"&&_.websocketManager.request({type:"bounds"}).then(t=>{t.shapes_ready&&(n.style.display="none")}).catch(()=>{}).finally(()=>{n.style.display!=="none"&&setTimeout(e,1e3)})};setTimeout(e,1e3)}function ap(){_.layerExtents&&_.layerExtents.refetch(n=>_.websocketManager.request(n))}function W5(n){document.getElementById("loading-overlay").style.display="none",ap(),mv(n.bounds,n.fit_bounds).then(e=>{e||Ft()}).catch(()=>Ft()),_.refreshInspector&&_.refreshInspector()}function j5(){let n=document.getElementById("script-running-badge");return n||(n=document.createElement("span"),n.id="script-running-badge",n.className="script-running-badge",n.textContent="Script running",n.title="The view updates when the script pauses or finishes",(document.getElementById("menu-bar")||document.body).appendChild(n),n)}function H5(n){if(_.scriptRunning=n,j5().style.display=n?"block":"none",!n){if(!_.booted||!_.designScale){S5();return}_.refreshPending&&(_.refreshPending=!1,ap(),_.refreshInspector&&_.refreshInspector()),mv().then(e=>{e||ea()}).catch(()=>ea())}}_.websocketManager.onPush=n=>{if(n.type==="refresh"){if(_.scriptRunning){_.refreshPending=!0;return}W5(n)}else if(n.type==="script_running")H5(!!n.running);else if(n.type==="renderer_controls_changed")_.refreshRendererControls&&_.refreshRendererControls(),ea();else if(n.type==="selection_invalidated")_.updateInspector&&_.updateInspector(null),_.stopSelectionAnimation&&_.stopSelectionAnimation(),_.clearSelectionOutline&&_.clearSelectionOutline(),ks();else if(n.type==="heatmaps_changed")_.websocketManager.request({type:"heatmaps"}).then(fv).catch(e=>console.error("Heat map refresh failed",e));else if(n.type==="labels_changed")_.labelManager&&_.labelManager.applyRemoteLabels(n.labels);else if(n.type==="drcUpdated")_._drcUpdateTimeout&&clearTimeout(_._drcUpdateTimeout),_._drcUpdateTimeout=setTimeout(()=>{_.drcWidget&&_.drcWidget.refresh()},500);else if(n.type==="debug_paused")_.refreshRendererControls&&_.refreshRendererControls(),G5().style.display="block",ea(),_.chartsWidget&&_.websocketManager.request({type:"debug_charts"}).then(e=>_.chartsWidget.setDebugCharts(e.charts||[])).catch(()=>{});else if(n.type==="debug_resumed"){let e=document.getElementById("debug-continue-btn");e&&(e.style.display="none")}else if(n.type==="debug_refresh"){if(_.scriptRunning)return;_.clearSelectionOutline&&_.clearSelectionOutline(),ea()}else if(n.type==="log"){let e=n.text;e.endsWith(` -`)&&(e=e.slice(0,-1)),e&&pr(e+` -`,"")}else n.type==="restore_display_state"?v5(n.state):n.type==="custom_ui"?WM(n):n.type==="poly_decomp"?pv(n.value):n.type==="shutdown"&&(_.websocketManager._shutdown=!0,hr.innerHTML='
Server stopped
',hr.style.display="block")};_.websocketManager.readyPromise.then(async()=>{try{let o=function(a,c={}){let{addToSelection:l=!1,focusInspector:u=!0,context:f=!1,showConnectivity:d=!1}=c;if(!_.designScale)return Promise.resolve(null);let{dbuX:h,dbuY:p}=wn(a[0],a[1],_.designScale,_.designOriginX,_.designOriginY);if(_.labelManager&&_.labelManager.isActive())return _.labelManager.handleMapClick(h,p),Promise.resolve(null);let m=A3(gt,ta),g={type:"select",dbu_x:h,dbu_y:p,zoom:Math.round(_.view.getZoom()),visible_layers:[..._.visibleLayerNames],selectable_layers:[..._.selectableLayers],use_dbu:_.showDbu,...m};l&&(g.add_to_selection=!0),f&&(g.context=!0),d&&(g.show_connectivity=!0),_.visibleChiplets instanceof Set&&(g.visible_chiplets=[..._.visibleChiplets]);let v=St(_);return _.websocketManager.request(g).then(y=>{if(Dt(_,v)){if(console.log("Select response:",y,"at dbu",h,p),qo(_,y),y.selected&&y.selected.length>0){let b=y.selected[0];b.type==="Inst"&&(_.selectedInstanceName=b.name,_.schematicWidget&&_.schematicWidget.refresh()),Zl(y),u&&op("Inspector"),y.bbox&&(M5(y.bbox[0],y.bbox[1],y.bbox[2],y.bbox[3],y.type),A5(y.bbox,y.type),_.lastSelectionBounds=y.bbox.slice(0,4)),g.show_connectivity&&y.connected_added>0&&nn(`Selected ${y.connected_added} connected net`+(y.connected_added>1?"s":""))}else!l&&!f&&(Zl(null),_.clearSelectionOutline&&_.clearSelectionOutline(),_.lastSelectionBounds=null);return dv(),y}}).catch(y=>(console.error("Select failed:",y),null))},[n,e,t]=await Promise.all([_.websocketManager.request({type:"tech"}),_.websocketManager.request({type:"bounds"}),_.websocketManager.request({type:"heatmaps"})]);ap(),_.hasLiberty=n.has_liberty,_.techData=n,BM(n.block_name),_.websocketManager.request({type:"custom_ui"}).then(WM).catch(()=>{}),_.websocketManager.request({type:"poly_decomp"}).then(a=>pv(a.value)).catch(()=>{});let i=e.bounds,r=e.fit_bounds;if(!ri){let a=_.view.getSize();l3(O3({designBounds:i,fitRect:r,viewW:a.width,viewH:a.height}))}let s=jM(i,r);if(s){if(_.labelManager&&_.labelManager.reload(),ri){let a=ri.zoom;_.view.setLimits({minZoom:a,maxZoom:a})}if(_.view.fitWorldRect(_.fitRect,{animate:!1}),ri){let a=Ot(i[0][1],i[0][0],i[1][1],i[1][0],_.designScale,_.designOriginX,_.designOriginY);ri.setPathOverlay=c=>{_.view.setImageOverlay("timing-path",c?{image:c,rect:a}:null)}}try{let a=sessionStorage.getItem("or_restore_view");if(a){sessionStorage.removeItem("or_restore_view");let c=JSON.parse(a);c&&isFinite(c.dbuX)&&isFinite(c.dbuY)&&isFinite(c.zoom)&&_.view.setView(xn(c.dbuX,c.dbuY,_.designScale,_.designOriginX,_.designOriginY),c.zoom,{animate:!1})}}catch{}}ri&&(document.getElementById("loading-overlay").style.display="none"),_.selectAtWorld=o,ri||(_.onMapClick=(a,c)=>o(a,{addToSelection:!!c.shiftKey,showConnectivity:!!(c.ctrlKey||c.metaKey)}),_.onMapContextClick=(a,c)=>{o(a,{context:!0,focusInspector:!1}).then(()=>_.contextMenu.show(c))}),mM(_,gt,ta,n,Ft,b5),!_.overlayLayer&&!ri&&(_.overlayLayer=_.view.addTileSlot("overlay",{order:at.overlay,source:qb({wm:_.websocketManager,dpr:Yo,tileSize:tn,buildRequest:(a,c,l)=>P3(a,c,l,gt,_)})})),fv(t),s&&!e.shapes_ready&&V5(),rn(),_.booted=!0}catch(n){_.scriptRunning||console.error("Failed to load initial data from server:",n)}});document.addEventListener("openroad-cone-sync",n=>{_.schematicWidget?.syncCone(n.detail||{})});document.addEventListener("keydown",n=>{let e=n.target.tagName;if(e==="INPUT"||e==="TEXTAREA"||n.target.isContentEditable)return;let t=n.key.toLowerCase();if(t==="escape"&&_.rulerManager&&_.rulerManager.isActive())_.rulerManager.cancelRulerBuild();else if(t==="escape"&&_.labelManager&&_.labelManager.isActive())_.labelManager.cancelLabelMode();else if(t==="k"&&!n.shiftKey&&!n.ctrlKey&&!n.metaKey)_.rulerManager&&_.rulerManager.toggleRulerMode();else if(t==="k"&&n.shiftKey&&!n.ctrlKey&&!n.metaKey)_.rulerManager&&_.rulerManager.clearAllRulers();else if(t==="l"&&!n.shiftKey&&!n.ctrlKey&&!n.metaKey)_.labelManager&&_.labelManager.toggleLabelMode();else if(t==="f"&&!n.ctrlKey&&!n.metaKey&&_.fitRect)_.view.fitWorldRect(_.fitRect);else if(t==="z"&&!n.ctrlKey&&_.view){let i=n.shiftKey?-1:1;_.view.zoomAround(_.lastMouseWorld?_.view.project(_.lastMouseWorld):null,i)}else t==="f"&&(n.ctrlKey||n.metaKey)?(n.preventDefault(),_.designScale&&qh(_)):t==="g"&&n.shiftKey&&!n.ctrlKey&&!n.metaKey?(n.preventDefault(),_.designScale&&Zh(_)):t==="t"&&!n.shiftKey&&!n.ctrlKey&&!n.metaKey&&_.toggleTheme()},!0);})(); + `,document.body.appendChild(this._overlay),this._breadcrumb=this._overlay.querySelector(".fb-breadcrumb"),this._fileList=this._overlay.querySelector(".fb-file-list"),this._pathInput=this._overlay.querySelector(".fb-path-input"),this._errorDiv=this._overlay.querySelector(".modal-error"),this._okBtn=this._overlay.querySelector(".ok"),this._cancelBtn=this._overlay.querySelector(".cancel"),this._listen(this._pathInput,"input",()=>this._updateOkState()),this._listen(this._pathInput,"keydown",e=>{if(e.key==="Enter"){let t=this._pathInput.value.trim();t.endsWith("/")?this._navigate(t.replace(/\/+$/,"")||"/"):this._submit()}else e.key==="Escape"&&this.close()}),this._listen(this._okBtn,"click",()=>this._submit()),this._listen(this._cancelBtn,"click",()=>this.close()),this._listen(this._overlay,"click",e=>{e.target===this._overlay&&this.close()}),this._navigate("")}close(){if(!this._closed){this._closed=!0;for(let e of this._disposers)e();this._disposers.length=0,this._overlay&&(this._overlay.remove(),this._overlay=null)}}_listen(e,t,i){e.addEventListener(t,i),this._disposers.push(()=>e.removeEventListener(t,i))}_updateOkState(){this._okBtn.disabled=!this._pathInput.value.trim()}_renderBreadcrumb(e){this._breadcrumb.innerHTML="";let t=e.split("/").filter(Boolean),i=document.createElement("span");i.className="fb-crumb",i.textContent="/",this._listen(i,"click",()=>this._navigate("/")),this._breadcrumb.appendChild(i);let r="";for(let s of t){r+="/"+s;let o=document.createElement("span");o.className="fb-crumb-sep",o.textContent=" / ",this._breadcrumb.appendChild(o);let a=document.createElement("span");a.className="fb-crumb",a.textContent=s;let c=r;this._listen(a,"click",()=>this._navigate(c)),this._breadcrumb.appendChild(a)}}_renderEntries(e){if(this._fileList.innerHTML="",!e||e.length===0){let t=document.createElement("div");t.className="fb-empty",t.textContent="(empty directory)",this._fileList.appendChild(t);return}for(let t of e){let i=document.createElement("div");i.className="fb-entry",t.is_dir&&i.classList.add("fb-dir");let r=document.createElement("span");r.className="fb-icon",r.textContent=t.is_dir?"\u{1F4C1}":"\u{1F4C4}",i.appendChild(r);let s=document.createElement("span");s.className="fb-name",s.textContent=t.name,i.appendChild(s),t.is_dir?this._listen(i,"click",()=>this._navigate(this._currentPath+"/"+t.name)):(this._listen(i,"click",()=>{let o=this._fileList.querySelector(".fb-selected");o&&o.classList.remove("fb-selected"),i.classList.add("fb-selected"),this._pathInput.value=this._currentPath+"/"+t.name,this._updateOkState()}),this._listen(i,"dblclick",()=>{this._pathInput.value=this._currentPath+"/"+t.name,this._updateOkState(),this._submit()})),this._fileList.appendChild(i)}}async _navigate(e){this._errorDiv.style.display="none",this._fileList.innerHTML='
Loading...
';try{let t=await this._app.websocketManager.request({type:"list_dir",path:e||""});if(this._closed)return;this._currentPath=t.path,this._renderBreadcrumb(t.path),this._renderEntries(t.entries),this._pathInput.value="",this._updateOkState()}catch(t){if(this._closed)return;this._fileList.innerHTML="",this._errorDiv.textContent=t.message||String(t),this._errorDiv.style.display=""}}async _submit(){let e=this._pathInput.value.trim();if(e){this._okBtn.disabled=!0,this._okBtn.textContent="Loading...",this._errorDiv.style.display="none";try{let t=await this._app.websocketManager.request({type:"drc_load_report",path:e});if(this._closed)return;if(t.ok){let i=t.category;this.close(),this._onLoaded(i)}else this._errorDiv.textContent=t.error||"Failed to load report",this._errorDiv.style.display="",this._okBtn.disabled=!1,this._okBtn.textContent="Load"}catch(t){if(this._closed)return;this._errorDiv.textContent=t.message||"Request failed",this._errorDiv.style.display="",this._okBtn.disabled=!1,this._okBtn.textContent="Load"}}}};var QW=` +\r[]{}`;var ip=class{constructor(e,t){this._input=e,this._ws=t,this._popup=null,this._items=[],this._selectedIndex=-1,this._replaceStart=0,this._replaceEnd=0,this._debounceTimer=null,this._commandCache=null,this._history=[],this._historyIndex=-1,this._historyStash="",this._createPopup(),this._onInputBound=this._onInput.bind(this),this._onBlurBound=this._onBlur.bind(this),this._input.addEventListener("input",this._onInputBound),this._input.addEventListener("blur",this._onBlurBound)}_createPopup(){this._popup=document.createElement("div"),this._popup.className="tcl-complete-popup",this._popup.style.display="none",this._input.parentElement.appendChild(this._popup)}handleKeyDown(e){let t=this._popup.style.display!=="none";return e.key==="Tab"?(e.preventDefault(),t?this._tabAccept():this._tabComplete(this._input.value,this._input.selectionStart),!0):e.key==="Escape"?t?(this._hidePopup(),!0):!1:e.key==="ArrowDown"?t?(e.preventDefault(),this._selectItem(this._selectedIndex+1),!0):this._historyIndex>=0?(e.preventDefault(),this._historyIndex--,this._historyIndex<0?this._input.value=this._historyStash:this._input.value=this._history[this._historyIndex],!0):!1:e.key==="ArrowUp"?t?(e.preventDefault(),this._selectItem(this._selectedIndex-1),!0):this._historyIndex{let e=this._input.value,t=this._input.selectionStart,i=this._extractPrefix(e,t);i.length>=2||i.length>=1&&(i[0]==="$"||i[0]==="-")?this._requestCompletions(e,t):this._hidePopup()},100)}_onBlur(){setTimeout(()=>this._hidePopup(),150)}_extractPrefix(e,t){let i=t-1;for(;i>=0&&QW.indexOf(e[i])===-1;)i--;return e.substring(i+1,t)}_fetchCompletions(e,t,i){let r=this._extractPrefix(e,t),s=r.length>0&&r[0]==="$",o=r.length>0&&r[0]==="-",a=!s&&!o,c=t-r.length,l=e.substring(0,c),u=/^[\s\[]*$/.test(l);if(a&&u&&this._commandCache){let f=r.toLowerCase(),d=this._commandCache.filter(h=>h.toLowerCase().startsWith(f));i(d,c,t);return}this._ws.request({type:"tcl_complete",line:e,cursor_pos:t}).then(f=>{f.mode==="commands"&&!this._commandCache&&r===""&&(this._commandCache=f.completions),f.mode==="commands"&&!this._commandCache&&this._ws.request({type:"tcl_complete",line:"",cursor_pos:0}).then(d=>{d.mode==="commands"&&(this._commandCache=d.completions)}).catch(()=>{}),i(f.completions,f.replace_start,f.replace_end)}).catch(()=>i([],0,0))}_requestCompletions(e,t){this._fetchCompletions(e,t,(i,r,s)=>{this._showPopup(i,r,s)})}_tabAccept(){if(this._items.length===0){this._hidePopup();return}if(this._items.length===1){this._selectedIndex=0,this._acceptCompletion();return}this._advanceToCommonPrefix()}_tabComplete(e,t){this._fetchCompletions(e,t,(i,r,s)=>{if(!i||i.length===0){this._hidePopup();return}if(i.length===1){this._items=i,this._replaceStart=r,this._replaceEnd=s,this._selectedIndex=0,this._acceptCompletion();return}this._items=i,this._replaceStart=r,this._replaceEnd=s,this._advanceToCommonPrefix(),this._showPopup(i,this._replaceStart,this._replaceEnd)})}_advanceToCommonPrefix(){if(this._items.length<2)return!1;let e=this._items[0];for(let o=1;o0;o++){let a=this._items[o],c=0;for(;c{let c=document.createElement("div");c.className="tcl-complete-item",c.textContent=o,c.addEventListener("mousedown",l=>{l.preventDefault(),this._selectedIndex=a,this._acceptCompletion()}),this._popup.appendChild(c)}),e.length>15){let o=document.createElement("div");o.className="tcl-complete-more",o.textContent=`... ${e.length-15} more`,this._popup.appendChild(o)}this._selectedIndex=0,this._highlightSelected(),this._popup.style.display="block"}_hidePopup(){this._popup.style.display="none",this._items=[],this._selectedIndex=-1}_selectItem(e){if(this._items.length===0)return;let t=Math.min(this._items.length,15)-1;this._selectedIndex=Math.max(0,Math.min(e,t)),this._highlightSelected()}_highlightSelected(){let e=this._popup.querySelectorAll(".tcl-complete-item");e.forEach((t,i)=>{t.classList.toggle("selected",i===this._selectedIndex)}),e[this._selectedIndex]&&e[this._selectedIndex].scrollIntoView&&e[this._selectedIndex].scrollIntoView({block:"nearest"})}_acceptCompletion(){if(this._selectedIndex<0||this._selectedIndex>=this._items.length){this._hidePopup();return}let e=this._items[this._selectedIndex],t=this._input.value.substring(0,this._replaceStart),i=this._input.value.substring(this._replaceEnd),s=!e.endsWith("/")&&!e.endsWith("::")&&(i.length===0||i[0]!==" ")?" ":"";this._input.value=t+e+s+i;let o=this._replaceStart+e.length+s.length;this._input.setSelectionRange(o,o),this._input.focus(),this._hidePopup()}};var IM=[{key:"or_visibility",store:"cookie"},{key:"or_selectability",store:"cookie"},{key:"or_hidden_layers",store:"session"},{key:"or_nonselectable_layers",store:"session"},{key:"or_layer_patterns",store:"session"},{key:"or_hidden_chiplets",store:"cookie"},{key:"or_bg_color",store:"cookie"},{key:"or_show_dbu",store:"cookie"},{key:"or_theme",store:"theme"},{key:"or_use_true_z",store:"cookie"},{key:"or_ruler_style",store:"cookie"},{key:"or_wheel_zoom",store:"cookie"},{key:"or_arrow_step",store:"cookie"},{key:"or_font_family",store:"cookie"},{key:"or_font_scale",store:"cookie"},{key:"or_control_smoothing",store:"cookie"},{key:"or_double_buffer",store:"cookie"},{key:"or_defer_tile_updates",store:"cookie"}];function BM(n){return{controlSmoothing:n("or_control_smoothing")==="1",doubleBuffer:n("or_double_buffer")!=="0",deferTileUpdates:n("or_defer_tile_updates")==="1"}}function JW(n,e){try{return window[n].getItem(e)}catch{return null}}function e5(n,e,t){try{t===null?window[n].removeItem(e):window[n].setItem(e,t)}catch{}}function t5({key:n,store:e}){return e==="session"?JW("sessionStorage",n):We(n)}function n5({key:n,store:e},t){e==="session"?e5("sessionStorage",n,t):e==="theme"?t===null?J3():Nh(t):t===null?Dh(n):$e(n,t)}function OM(){let n={};for(let e of IM){let t=t5(e);t&&(n[e.key]=t)}return{version:1,entries:n}}function i5(n){return typeof n=="string"&&n!==""&&!/[;\r\n]/.test(n)}function DM(n){for(let e of IM){let t=n[e.key];n5(e,i5(t)?t:null)}}function NM(n,e=typeof document<"u"?document:null){let t="OpenROAD",i=n?`${t} - ${n}`:t;return e&&(e.title=i),i}var ce=globalThis.THREE,FM=2,r5=.002,s5=.9,o5=1.1,a5=.1,c5=20,l5=3,As=2,zM=2,u5=10,f5=1e4,d5=.15,h5=300,p5=6,rp=Math.PI/180,UM=[5025616,2201331,16750592,10233776,48340,16007990,2533018,7951688,15277667,4149685];function m5(n){let e=new Array(n.length).fill(0),t=new Map;n.forEach((i,r)=>{let s=i.z;t.has(s)||t.set(s,[]),t.get(s).push({idx:r,chiplet:i})});for(let i of t.values()){if(i.length<=1)continue;let r=[];for(let{idx:s,chiplet:o}of i){let a=o.x,c=o.y,l=o.x+o.width,u=o.y+o.height,f=!1;for(let d=0;dap.x1&&cp.y1)){r[d].push({x1:a,y1:c,x2:l,y2:u}),e[s]=d,f=!0;break}f||(r.push([{x1:a,y1:c,x2:l,y2:u}]),e[s]=r.length-1)}}return e}var sp=class{constructor(e,t){if(this._app=t,this._container=e,this._element=document.createElement("div"),this._element.className="three-d-viewer-widget",e.element.appendChild(this._element),!ce){fe(t)?this._showInfo("The 3D view is not available in saved reports."):this._showError("three.js is missing from the page."),this._destroyed=!0;return}this._canvasContainer=document.createElement("div"),this._canvasContainer.className="three-d-canvas-container",this._element.appendChild(this._canvasContainer),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._canvasContainer.appendChild(this._tooltip),this._optionsOverlay=this._createOptionsOverlay(),this._canvasContainer.appendChild(this._optionsOverlay),this._raycaster=new ce.Raycaster,this._scene=new ce.Scene,this._applyTheme(),this._themeObserver=new MutationObserver(()=>{this._applyTheme(),this.render()}),this._themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),this._camera=new ce.PerspectiveCamera(45,1,10,1e5),this._camera.position.set(0,0,1e3);try{this._renderer=new ce.WebGLRenderer({antialias:!0,preserveDrawingBuffer:!0})}catch(o){console.error("3D viewer: failed to create WebGL context:",o),this._showWebGLUnavailable(o),this._themeObserver&&(this._themeObserver.disconnect(),this._themeObserver=null),this._destroyed=!0;return}this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(e.width,e.height),this._canvasContainer.appendChild(this._renderer.domElement),this._rotation=new ce.Quaternion,this._distance=1e3,this._panX=0,this._panY=0,this._boundingRadius=1,this._sceneCenter=new ce.Vector3,this._mouseDown=!1,this._mouseButton=-1,this._lastMousePos={x:0,y:0},this._setupMouseHandlers();let i=new ce.AmbientLight(16777215,.5);this._scene.add(i);let r=new ce.DirectionalLight(16777215,.8);r.position.set(1,1,1).normalize(),this._scene.add(r);let s=new ce.DirectionalLight(16777215,.3);s.position.set(-1,-.5,.5).normalize(),this._scene.add(s),e.on("resize",this.onResize.bind(this)),e.on("open",this.onOpen.bind(this)),e.on("destroy",this.onDestroy.bind(this)),this._designGroup=new ce.Group,this._scene.add(this._designGroup),this._chipletMeshes=[],this._loading=!1,this._destroyed=!1,this._edgeMaterial=null}_setupMouseHandlers(){let e=this._renderer.domElement;e.addEventListener("mousedown",t=>{this._mouseDown=!0,this._mouseButton=t.button,this._lastMousePos.x=t.clientX,this._lastMousePos.y=t.clientY,e.focus(),t.preventDefault()}),e.addEventListener("contextmenu",t=>t.preventDefault()),this._onMouseMove=t=>{if(!this._mouseDown)return;let i=t.clientX-this._lastMousePos.x,r=t.clientY-this._lastMousePos.y;this._lastMousePos.x=t.clientX,this._lastMousePos.y=t.clientY,!(i===0&&r===0)&&(this._mouseButton===0?this._handleRotate(i,r):this._mouseButton===2&&this._handlePan(i,r),this._updateCamera())},this._onMouseUp=t=>{this._mouseDown&&t.button===this._mouseButton&&(this._mouseDown=!1,this._mouseButton=-1)},window.addEventListener("mousemove",this._onMouseMove),window.addEventListener("mouseup",this._onMouseUp),e.addEventListener("wheel",t=>{t.preventDefault(),t.deltaY<0?this._distance*=s5:this._distance*=o5;let i=Math.max(this._boundingRadius*a5,1),r=Math.max(this._boundingRadius*c5,i);this._distance=Math.max(i,Math.min(r,this._distance)),this._updateCamera()},{passive:!1}),e.tabIndex=0,e.style.outline="none",e.addEventListener("keydown",t=>{t.key.toLowerCase()==="f"&&this.resetCamera()}),e.addEventListener("dblclick",t=>{t.preventDefault();let i=this._pickDrcMarkerId(t);if(i!=null&&this._app.drcWidget){this._app.drcWidget.highlightMarkerById(i,!0);return}this.resetCamera()}),e.addEventListener("mousemove",t=>{if(this._mouseDown){this._hideTooltip();return}this._updateTooltip(t)}),e.addEventListener("mouseleave",()=>{this._hideTooltip()})}_createOptionsOverlay(){let e=document.createElement("div");e.className="three-d-options";let t=document.createElement("label");t.title="Render chiplets at their true Z (disable stacking offset for overlapping chiplets at same Z).";let i=document.createElement("input");i.type="checkbox",i.checked=!!this._app.useTrueZ,i.addEventListener("change",()=>{this._app.useTrueZ=i.checked,$e("or_use_true_z",i.checked?"1":"0"),this._app.syncDisplayState(),this.refreshSceneForOptions()}),t.appendChild(i),t.appendChild(document.createTextNode("True Z (no stacking)")),e.appendChild(t);let r=document.createElement("div");r.style.cssText="margin-top:4px; display:flex; gap:4px;";let s=document.createElement("button");s.className="or-btn or-btn-sm",s.textContent="Save PNG",s.title="Save the 3D view as a PNG image (2x resolution)",s.addEventListener("click",()=>this._exportPng(2));let o=document.createElement("button");return o.className="or-btn or-btn-sm",o.textContent="Copy",o.title="Copy the 3D view image to the clipboard",o.addEventListener("click",()=>this._copyImage(2)),r.appendChild(s),r.appendChild(o),e.appendChild(r),e}_capturePng(e=2){if(!this._renderer)return null;let t=this._renderer,i=t.domElement.clientWidth||t.domElement.width,r=t.domElement.clientHeight||t.domElement.height,s=t.getPixelRatio();try{return t.setPixelRatio(s*e),t.setSize(i,r,!1),this.render(),t.domElement.toDataURL("image/png")}finally{t.setPixelRatio(s),t.setSize(i,r,!1),this.render()}}_exportPng(e=2){let t=this._capturePng(e);t&&Ts(t,"3d-view.png")}async _copyImage(e=2){let t=this._capturePng(e);t&&await Fh(t)}_setRaycasterFromEvent(e){let i=this._renderer.domElement.getBoundingClientRect(),r=new ce.Vector2((e.clientX-i.left)/i.width*2-1,-((e.clientY-i.top)/i.height*2-1));this._raycaster.setFromCamera(r,this._camera)}_updateTooltip(e){if(!this._chipletMeshes.length){this._hideTooltip();return}this._setRaycasterFromEvent(e);let t=this._chipletMeshes.map(a=>a.mesh),i=this._raycaster.intersectObjects(t,!1);if(i.length===0){this._hideTooltip();return}let r=i[0].object,s=this._chipletMeshes.find(a=>a.mesh===r);if(!s){this._hideTooltip();return}this._tooltip.textContent=s.data.name,this._tooltip.style.display="block";let o=this._canvasContainer.getBoundingClientRect();this._tooltip.style.left=e.clientX-o.left+12+"px",this._tooltip.style.top=e.clientY-o.top+12+"px"}_hideTooltip(){this._tooltip&&(this._tooltip.style.display="none")}_pickDrcMarkerId(e){if(!this._drcHitboxMesh||!this._drcHitboxMarkerIds)return null;this._setRaycasterFromEvent(e);let t=this._raycaster.intersectObject(this._drcHitboxMesh,!1);if(t.length===0)return null;let i=t[0].instanceId;return i==null?null:this._drcHitboxMarkerIds[i]??null}_handleRotate(e,t){let i=Math.sqrt(e*e+t*t);if(i<.001)return;let r=new ce.Vector3(t/i,e/i,0),s=i/FM,a=new ce.Quaternion().setFromAxisAngle(r,s*rp).clone().multiply(this._rotation);if(new ce.Vector3(0,0,1).applyQuaternion(a).z>=0)this._rotation.copy(a);else{let l=new ce.Vector3(0,1,0),u=e/FM*rp,d=new ce.Quaternion().setFromAxisAngle(l,u).clone().multiply(this._rotation);new ce.Vector3(0,0,1).applyQuaternion(d).z>=0&&this._rotation.copy(d)}}_handlePan(e,t){let i=this._distance*r5;this._panX+=e*i,this._panY-=t*i}_updateCamera(){let e=Math.max(this._boundingRadius,1e3),t=Math.max(this._distance-e*zM,u5),i=this._distance+e*zM;i0;){let e=this._designGroup.children[0];this._designGroup.remove(e),e.geometry&&e.geometry.dispose(),e.material&&!e.material._shared&&e.material.dispose()}this._edgeMaterial&&(this._edgeMaterial.dispose(),this._edgeMaterial=null),this._onMouseMove&&(window.removeEventListener("mousemove",this._onMouseMove),this._onMouseMove=null),this._onMouseUp&&(window.removeEventListener("mouseup",this._onMouseUp),this._onMouseUp=null),this._renderer&&(this._renderer.dispose(),this._renderer=null),this._app.threeDViewerWidget===this&&(this._app.threeDViewerWidget=null)}}_setInitialCameraState(){this._distance=this._boundingRadius*l5;let e=new ce.Quaternion().setFromAxisAngle(new ce.Vector3(1,0,0),-45*rp),t=new ce.Quaternion().setFromAxisAngle(new ce.Vector3(0,0,1),45*rp);this._rotation=e.multiply(t),this._panX=0,this._panY=0}resetCamera(){this._sceneBounds&&(this._setInitialCameraState(),this._updateCamera())}onResize(){if(this._destroyed)return;let e=this._canvasContainer.getBoundingClientRect(),t=e.width,i=e.height;t===0||i===0||(this._camera.aspect=t/i,this._camera.updateProjectionMatrix(),this._renderer.setSize(t,i),this.render())}render(){this._destroyed||this._renderer&&this._scene&&this._camera&&this._renderer.render(this._scene,this._camera)}_applyTheme(){let t=Cs().bgMap||"#000000";this._scene.background=new ce.Color(t)}async loadData(){if(!(this._loading||this._destroyed)){this._loading=!0;for(let e of[".three-d-error",".three-d-info"]){let t=this._element.querySelector(e);t&&t.remove()}try{await this._app.websocketManager.readyPromise;let e=await this._app.websocketManager.request({type:"get_3d_data"});if(this._destroyed)return;if(e&&e.error){this._showError(e.error);return}if(e&&e.info){this._showInfo(e.info);return}this.buildScene(e)}catch(e){if(this._destroyed)return;console.error("Failed to load 3D data:",e),this._showError(e.message||String(e))}finally{this._loading=!1}}}_showOverlay(e,t,i){let r=document.createElement("div");r.className=e,r.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-family:monospace;text-align:center;",r.style.color=i,r.textContent=t,this._element.appendChild(r)}_showError(e){this._showOverlay("three-d-error","Failed to load 3D data: "+e,"var(--error)")}_showInfo(e){this._showOverlay("three-d-info",e,"var(--fg-muted, #888)")}_showWebGLUnavailable(e){let t=document.createElement("div");t.className="three-d-error",t.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-family:monospace;text-align:center;max-width:80%;color:var(--error);";let i=e&&e.message?e.message:String(e||"");t.innerHTML='
3D viewer unavailable: WebGL context could not be created.
In Chrome, open chrome://flags/#ignore-gpu-blocklist and set Override software rendering list to Enabled, then relaunch the browser.
Otherwise enable hardware acceleration or try a different browser. See chrome://gpu for details.
'+(i?'
'+i+"
":""),this._element.appendChild(t)}buildScene(e){if(this._destroyed||(this._lastSceneData=e,this._clearScene(),!e||!e.chiplets||e.chiplets.length===0))return;let t=this._app.getDbuPerMicron(),i=this._buildChiplets(e.chiplets,t);i.minX!==1/0&&(this._buildGrid(i),this._setSceneBoundsAndCenter(i),this._setInitialCameraState(),this._updateCamera())}_clearScene(){for(this._chipletMeshes=[];this._designGroup.children.length>0;){let e=this._designGroup.children[0];this._designGroup.remove(e),e.geometry&&e.geometry.dispose(),e.material&&!e.material._shared&&e.material.dispose()}this._hideTooltip()}_buildChiplets(e,t){let i={minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0};this._edgeMaterial||(this._edgeMaterial=new ce.LineBasicMaterial({color:0,linewidth:1}),this._edgeMaterial._shared=!0);let r=this._app.useTrueZ?new Array(e.length).fill(0):m5(e);return e.forEach((s,o)=>{let a=s.width/t,c=s.height/t,l=s.thickness/t*As,u=UM[o%UM.length],f=new ce.MeshPhongMaterial({color:u,transparent:!1,opacity:1,side:ce.DoubleSide,shininess:40}),d=new ce.BoxGeometry(a,c,l),h=new ce.Mesh(d,f),p=s.x/t+a/2,m=s.y/t+c/2,g=l*d5,v=s.z/t*As+l/2+r[o]*(l+g);h.position.set(p,m,v),this._designGroup.add(h),this._chipletMeshes.push({mesh:h,data:s,color:u});let y=new ce.EdgesGeometry(d),b=new ce.LineSegments(y,this._edgeMaterial);b.position.set(p,m,v),this._designGroup.add(b),i.minX=Math.min(i.minX,s.x/t),i.minY=Math.min(i.minY,s.y/t),i.minZ=Math.min(i.minZ,v-l/2),i.maxX=Math.max(i.maxX,s.x/t+a),i.maxY=Math.max(i.maxY,s.y/t+c),i.maxZ=Math.max(i.maxZ,v+l/2)}),i}_buildGrid(e){let t=e.maxX-e.minX,i=e.maxY-e.minY,r=Math.max(t,i)*1.4,s=10,o=new ce.GridHelper(r,s,8947848,4473924);o.rotation.x=Math.PI/2,o.position.set((e.minX+e.maxX)/2,(e.minY+e.maxY)/2,e.minZ-1),this._designGroup.add(o)}_setSceneBoundsAndCenter(e){this._sceneBounds=e;let t=e.maxX-e.minX,i=e.maxY-e.minY,r=e.maxZ-e.minZ;this._boundingRadius=Math.sqrt(t*t+i*i+r*r)/2,this._sceneCenter.set((e.minX+e.maxX)/2,(e.minY+e.maxY)/2,(e.minZ+e.maxZ)/2)}_stackOffsetForPoint(e,t,i,r){for(let{mesh:s,data:o}of this._chipletMeshes){if(e!==o.z||to.x+o.width||io.y+o.height)continue;let a=o.thickness/r*As,c=o.z/r*As+a/2;return s.position.z-c}return 0}clearHighlightDRC(){this._drcBlinkInterval&&(clearInterval(this._drcBlinkInterval),this._drcBlinkInterval=null),this._drcMeshGroup&&(this._scene.remove(this._drcMeshGroup),this._drcMeshGroup.children.forEach(e=>{e.geometry&&e.geometry.dispose()}),this._drcMaterial&&(this._drcMaterial.dispose(),this._drcMaterial=null),this._drcHitboxMaterial&&(this._drcHitboxMaterial.dispose(),this._drcHitboxMaterial=null),this._drcHitboxMesh=null,this._drcHitboxMarkerIds=null,this._drcMeshGroup=null,this.render())}highlightDRC(e){if(this._destroyed||(this.clearHighlightDRC(),!e||e.length===0))return;let t=this._app.getDbuPerMicron(),i=0,r=1e4/t*As;this._sceneBounds&&this._sceneBounds.minZ!==1/0&&(i=this._sceneBounds.minZ,r=this._sceneBounds.maxZ),i-=1,r+=1;let s=Math.max(r-i,1);this._drcMeshGroup=new ce.Group,this._drcMaterial=new ce.LineBasicMaterial({color:16776960,transparent:!0,opacity:1,depthTest:!1,depthWrite:!1}),this._drcHitboxMaterial=new ce.MeshBasicMaterial({transparent:!0,opacity:0,depthWrite:!1});let o=[];for(let l of e){let u=l.rects&&l.rects.length>0?l.rects:[l.bbox];for(let f of u){let[d,h,p,m,g,v]=f,y=Math.max((p-d)/t,.001),b=Math.max((m-h)/t,.001),x=i,E=s,w=0;if(f.length>=6&&g!==void 0&&v!==void 0){x=g/t*As;let O=v/t*As;E=Math.max(O-x,.001),w=this._stackOffsetForPoint(g,(d+p)/2,(h+m)/2,t)}let T=d/t+y/2,R=h/t+b/2,F=x+E/2+w;o.push({cx:T,cy:R,cz:F,width:y,height:b,depth:E,markerId:l.id})}}if(o.length>0){let l=new ce.BoxGeometry(1,1,1);this._drcHitboxMesh=new ce.InstancedMesh(l,this._drcHitboxMaterial,o.length),this._drcHitboxMarkerIds=new Array(o.length);let u=new ce.Matrix4,f=new ce.Vector3,d=new ce.Vector3,h=new ce.Quaternion;o.forEach((p,m)=>{d.set(p.cx,p.cy,p.cz),f.set(p.width,p.height,p.depth),u.compose(d,h,f),this._drcHitboxMesh.setMatrixAt(m,u),this._drcHitboxMarkerIds[m]=p.markerId;let g=new ce.BoxGeometry(p.width,p.height,p.depth),v=new ce.EdgesGeometry(g);g.dispose();let y=new ce.LineSegments(v,this._drcMaterial);y.position.set(p.cx,p.cy,p.cz),y.renderOrder=999,this._drcMeshGroup.add(y)}),this._drcHitboxMesh.instanceMatrix.needsUpdate=!0,this._drcMeshGroup.add(this._drcHitboxMesh)}this._drcMeshGroup.renderOrder=999,this._scene.add(this._drcMeshGroup),this.render();let a=!0,c=0;this._drcBlinkInterval=setInterval(()=>{if(!(!this._drcMeshGroup||!this._drcMaterial)){if(c+=1,c>=p5){this._drcMaterial.opacity=1,this.render(),clearInterval(this._drcBlinkInterval),this._drcBlinkInterval=null;return}a=!a,this._drcMaterial.opacity=a?1:.2,this.render()}},h5)}refreshSceneForOptions(){this._destroyed||this._lastSceneData&&(this.clearHighlightDRC(),this.buildScene(this._lastSceneData))}};var g5=[{name:"green",hex:"#00ff00"},{name:"yellow",hex:"#ffff00"},{name:"cyan",hex:"#00ffff"},{name:"magenta",hex:"#ff00ff"},{name:"red",hex:"#ff0000"},{name:"dark_green",hex:"#008000"},{name:"dark_magenta",hex:"#800080"},{name:"blue",hex:"#0000ff"},{name:"orange",hex:"#ffa500"},{name:"purple",hex:"#800080"},{name:"lime",hex:"#bfff00"},{name:"teal",hex:"#008080"},{name:"pink",hex:"#ffc0cb"},{name:"brown",hex:"#8b4513"},{name:"indigo",hex:"#4b0082"},{name:"turquoise",hex:"#40e0d0"}],_5=[{label:"Connected Insts",suffix:"connected_insts",needsNet:!0},{label:"Output Nets",suffix:"connected_nets",args:{output:!0,input:!1}},{label:"Input Nets",suffix:"connected_nets",args:{output:!1,input:!0}},{label:"All Nets",suffix:"connected_nets",args:{output:!0,input:!0}},{label:"All buffer trees",suffix:"connected_buffer_trees"},{label:"All buffer trees (incl. inverters)",suffix:"connected_buffer_trees",args:{include_inverters:!0}}],op=class{constructor(e){this._app=e,this._el=document.createElement("div"),this._el.className="context-menu",this._el.style.display="none",this._el.style.zIndex="10000",document.body.appendChild(this._el),this._bindEvents()}_bindEvents(){document.addEventListener("mousedown",e=>{this._el.contains(e.target)||this.hide()}),this._app.view&&this._app.view.on("movestart",()=>this.hide())}show(e){this._el.innerHTML="";let t=!!this._app.selHasInst,i=!!this._app.selHasNet,r=!(t||i),s=h=>_5.map(p=>({label:p.label,disabled:p.needsNet?!i:!t,...h(p.suffix,p.args||{})})),o=[{label:"Select",disabled:r,subMenu:s((h,p)=>({action:()=>this._sendContextAction("select_"+h,p)}))},{label:"Highlight",disabled:r,subMenu:s((h,p)=>({subMenu:this._buildColorSubmenu("highlight_"+h,p)}))},{label:"Save",subMenu:[{label:"Visible layout",action:()=>this._app.captureLayout?.({entire:!1})},{label:"Entire layout",action:()=>this._app.captureLayout?.({entire:!0})}]},{label:"Clear",subMenu:[{label:"Selections",action:()=>this._sendContextAction("clear_selections")},{label:"Highlights",action:()=>this._sendContextAction("clear_highlights")},{label:"Rulers",action:()=>{this._app.rulerManager?.clearAllRulers()}},{label:"Focus nets",action:()=>this._sendContextAction("clear_focus_nets")},{label:"Route Guides",action:()=>this._sendContextAction("clear_route_guides")},{label:"All",action:()=>{this._sendContextAction("clear_all"),this._app.rulerManager?.clearAllRulers()}}]}];this._buildMenu(o,this._el),this._el.style.display="block";let a=4,c=this._el.getBoundingClientRect(),l=window.innerWidth-c.width-a,u=window.innerHeight-c.height-a,f=Math.max(a,Math.min(e.clientX,l)),d=Math.max(a,Math.min(e.clientY,u));this._el.style.left=f+"px",this._el.style.top=d+"px"}hide(){this._el.style.display="none"}_buildColorSubmenu(e,t={}){return g5.map(({name:i,hex:r},s)=>({label:i,swatch:r,action:()=>this._sendContextAction(e,{...t,group:s})}))}_buildMenu(e,t){e.forEach(i=>{let r=document.createElement("div");if(r.className="cm-item",i.swatch){let s=document.createElement("span");s.className="cm-swatch",s.style.background=i.swatch,r.appendChild(s)}if(r.appendChild(document.createTextNode(i.label)),i.disabled){r.classList.add("disabled"),i.subMenu&&r.classList.add("has-submenu"),t.appendChild(r);return}if(i.subMenu){r.classList.add("has-submenu");let s=document.createElement("div");s.className="cm-submenu",this._buildMenu(i.subMenu,s),r.appendChild(s),r.addEventListener("mouseenter",()=>{s.classList.remove("flip-left"),s.getBoundingClientRect().right>window.innerWidth&&s.classList.add("flip-left")})}else i.action&&r.addEventListener("click",s=>{s.stopPropagation(),this.hide();try{i.action()}catch(o){console.error("Context menu item action threw:",i.label,o)}});t.appendChild(r)})}_sendContextAction(e,t={}){this._app.websocketManager&&this._app.websocketManager.request({type:"context_action",action:e,...t}).then(i=>{qo(this._app,i),i&&i.connected_count===0&&Ft('Nothing connected \u2014 select an instance (or a net for "Connected Insts") first.'),this._syncAfterAction(e)}).catch(i=>{console.error("Context action failed:",e,i)})}_syncAfterAction(e){let t=this._app;(e==="clear_focus_nets"||e==="clear_route_guides"||e==="clear_all")&&typeof t.redrawAllLayers=="function"&&t.redrawAllLayers(),e==="clear_selections"||e==="clear_all"?(t.updateInspector?.(null),t.stopSelectionAnimation?.(),t.clearSelectionOutline?.(),t.lastSelectionBounds=null):t.refreshInspector?.(),t.refreshOverlay?.()}};function $M(n,e){if(!n)return;let t=URL.createObjectURL(n),i=document.createElement("a");i.href=t,i.download=e,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(t),0)}function y5(n,e,t){n.view.getContainer().querySelectorAll(".or-view-markers .ruler-label").forEach(r=>{let s=r.getBoundingClientRect();if(s.width<=0||s.height<=0)return;let o=r.textContent;if(!o)return;let a=getComputedStyle(r),c=s.left-t.left,l=s.top-t.top;e.save(),e.fillStyle=a.backgroundColor||"rgba(0, 0, 0, 0.75)";let u=Math.min(parseFloat(a.borderTopLeftRadius)||0,s.height/2);u>0&&typeof e.roundRect=="function"?(e.beginPath(),e.roundRect(c,l,s.width,s.height,u),e.fill()):e.fillRect(c,l,s.width,s.height),e.fillStyle=a.color||"#eee",e.font=a.font||`${a.fontSize||"12px"} ${a.fontFamily||"monospace"}`,e.textAlign="left",e.textBaseline="middle",e.fillText(o,c+(parseFloat(a.paddingLeft)||0),l+s.height/2),e.restore()})}async function GM(n){let e=n.view.getContainer(),t=e.getBoundingClientRect(),i=Math.max(1,Math.round(t.width)),r=Math.max(1,Math.round(t.height)),s=document.createElement("canvas");s.width=i,s.height=r;let o=s.getContext("2d"),a=getComputedStyle(e).backgroundColor;o.fillStyle=a&&a!=="transparent"&&a!=="rgba(0, 0, 0, 0)"?a:"#000",o.fillRect(0,0,i,r);let c=await n.view.captureCanvas();if(c){let l=c.rect;try{o.drawImage(c.image,l.left-t.left,l.top-t.top,l.width,l.height)}catch{}}return y5(n,o,t),new Promise(l=>s.toBlob(l,"image/png"))}async function VM(n,{entire:e=!1}={}){if(!n.view)return;if(!e||!n.fitRect){$M(await GM(n),"layout_visible.png");return}let t=n.view.getCenter(),i=n.view.getZoom();try{n.view.fitWorldRect(n.fitRect,{animate:!1}),await n.view.whenTilesSettled(),$M(await GM(n),"layout_entire.png")}finally{n.view.setView(t,i,{animate:!1})}}var mr=document.getElementById("websocket-status"),Zl=null,b5=2e3,v5=20;function jM(){let n=_.websocketManager&&_.websocketManager.isConnected,e=_.websocketManager?_.websocketManager.pendingCount:0;if(n)if(Zl&&(clearTimeout(Zl),Zl=null),e>v5){let t=`pending: ${e}`,i=mr.firstElementChild;(!i?.classList.contains("pending-indicator")||i.textContent!==t)&&(mr.innerHTML=`
${t}
`),mr.style.display="block"}else mr.style.display="none";else{if(_.websocketManager?._shutdown)return;Zl||(Zl=setTimeout(()=>{_.websocketManager?.isConnected||(mr.innerHTML='
\u26A0 OpenROAD disconnected \u2014 retrying\u2026
',mr.style.display="block")},b5))}x5(e)}function x5(n){let e=_.tileProgressEl;if(!e)return;e.classList.toggle("active",n>0);let t=n>0?`${n} tile requests pending`:"";e.title!==t&&(e.title=t)}var WM=ur(jM);function w5(n){if(!n)return"";try{return decodeURIComponent(n)}catch{return""}}var _={view:null,fitRect:null,lastSelectionBounds:null,selHasInst:!1,selHasNet:!1,displayControlsEl:null,allLayers:[],designScale:null,designOriginX:0,designOriginY:0,websocketManager:null,goldenLayout:null,hasLiberty:!1,techData:null,inspectorEl:null,tclOutputEl:null,modulesLayer:null,pinsLayer:null,overlayLayers:[],hierarchyBrowser:null,focusNets:new Set,routeGuideNets:new Set,visibleLayers:new Set,visibleLayerNames:new Set,visibleChiplets:null,layerPatterns:{},useTrueZ:We("or_use_true_z")==="1",showDbu:We("or_show_dbu")==="1",rulerStyle:We("or_ruler_style")==="manhattan"?"manhattan":"euclidian",wheelZoom:We("or_wheel_zoom")!=="0",arrowStep:Gl(We("or_arrow_step")),...BM(We),fontFamily:w5(We("or_font_family")),fontScale:jl(We("or_font_scale")),polyDecomp:!1,labelManager:null,selectableLayers:new Set,heatMapData:null,activeHeatMap:"",heatMapLayer:null,heatMapLegendEl:null,renderHeatMapControls:null,rulerManager:null,selectionToken:0,selectionResetters:[],getDbuPerMicron(){return this.techData?.dbu_per_micron||1e3},unitOpts(){return{showDbu:this.showDbu,dbuPerMicron:this.getDbuPerMicron()}},formatDbu(n,e=!1){return F3(n,this.unitOpts(),e)},parseDbu(n){return z3(n,this.unitOpts())},formatDistance(n){return U3(n,this.unitOpts())},unitLabel(){return $3(this.unitOpts())}},gt={stdcells:!0,macros:!0,pad_input:!0,pad_output:!0,pad_inout:!0,pad_power:!0,pad_spacer:!0,pad_areaio:!0,pad_other:!0,phys_fill:!1,phys_endcap:!0,phys_welltap:!0,phys_tie:!0,phys_antenna:!0,phys_cover:!0,phys_bump:!0,phys_other:!0,std_bufinv:!0,std_bufinv_timing:!0,std_clock_bufinv:!0,std_clock_gate:!0,std_level_shift:!0,std_sequential:!0,std_combinational:!0,net_signal:!0,net_power:!0,net_ground:!0,net_clock:!0,net_reset:!0,net_tieoff:!0,net_scan:!0,net_analog:!0,inst_names:!0,inst_pins:!0,inst_pin_names:!1,routing:!0,routing_segments:!0,routing_vias:!0,special_nets:!0,srouting_segments:!0,srouting_vias:!0,pins:!0,pin_names:!0,access_points:!1,regions:!0,mfg_grid:!1,gcell_grid:!1,flywires_only:!1,blockages:!0,placement_blockages:!0,routing_obstructions:!0,fills:!1,rows:!1,tracks_pref:!1,tracks_non_pref:!1,module_view:!1,detailed:!1,rulers:!0,labels:!0,scale_bar:!0,focused_nets_guides:!1,highlight_selected:!0,debug:!1};try{let n=We("or_visibility");if(n){let e=JSON.parse(decodeURIComponent(n));for(let[t,i]of Object.entries(e))gt[t]=!!i}}catch{}var ta={stdcells:!0,macros:!0,pad_input:!0,pad_output:!0,pad_inout:!0,pad_power:!0,pad_spacer:!0,pad_areaio:!0,pad_other:!0,phys_fill:!0,phys_endcap:!0,phys_welltap:!0,phys_tie:!0,phys_antenna:!0,phys_cover:!0,phys_bump:!0,phys_other:!0,std_bufinv:!0,std_bufinv_timing:!0,std_clock_bufinv:!0,std_clock_gate:!0,std_level_shift:!0,std_sequential:!0,std_combinational:!0,net_signal:!0,net_power:!0,net_ground:!0,net_clock:!0,net_reset:!0,net_tieoff:!0,net_scan:!0,net_analog:!0,pins:!0,inst_pins:!0,placement_blockages:!0,routing_obstructions:!0};_.visibility=gt;_.selectability=ta;try{let n=We("or_selectability");if(n){let e=JSON.parse(decodeURIComponent(n));for(let[t,i]of Object.entries(e))ta[t]=!!i}}catch{}(function(){let e=null;try{e=new URLSearchParams(window.location.search)}catch{return}_.forceComposite=e.get("composite")==="1",_.preserveBuffer=e.get("preservebuffer")==="1";let t=Number(e.get("grouplayers"));Number.isFinite(t)&&t>0&&(_.groupLayers=Math.floor(t))})();_.tileCtx={visibility:gt,selectability:ta,visibleLayers:_.visibleLayerNames,selectableLayers:_.selectableLayers,app:_};function E5(){return _.view.addTileSlot("heatmap",{order:ot.heatmap,visible:!!_.activeHeatMap,source:Zb({wm:_.websocketManager,dpr:Yo,tileSize:on,buildRequest:(n,e,t)=>T3(n,e,t,_)})})}function dv(n){if(_.heatMapData=n,_.activeHeatMap=n.active||"",_.heatMapLayer){let e=_.heatMapLayer.isVisible();_.heatMapLayer.setVisible(!!_.activeHeatMap),e&&_.heatMapLayer.refresh()}_.renderHeatMapControls&&_.renderHeatMapControls(n)}_.updateHeatMaps=dv;function hv(){_.overlayLayer&&_.overlayLayer.refresh()}var ks=ur(()=>{hv(),_.selectionBrowser&&_.selectionBrowser.scheduleRefresh()});_.refreshOverlay=ks;function $t(){$e("or_visibility",encodeURIComponent(JSON.stringify(gt))),$e("or_selectability",encodeURIComponent(JSON.stringify(ta))),an();let n=[[_.modulesLayer,gt.module_view],[_.pinsLayer,gt.pins],..._.overlayLayers.map(({def:e,layer:t})=>[t,qh(e.shown_by,gt)])];for(let[e,t]of n)e&&(e.visible=!!t);for(let e of _.allLayers)e.refresh();_.heatMapLayer&&_.heatMapLayer.refresh(),_.renderSelectionOutline&&_.renderSelectionOutline(),!gt.highlight_selected&&_.clearSelectionPulse&&_.clearSelectionPulse(),hv(),_.rulerManager&&_.rulerManager.updateVisibility(),_.labelManager&&_.labelManager.updateVisibility(),_.updateScaleBar&&_.updateScaleBar()}var ea=ur($t),an=ur(()=>{!_.websocketManager||fe(_)||_.websocketManager.request({type:"set_display_state",state:OM()}).catch(()=>{})});_.syncDisplayState=an;function S5(n){if(!n||typeof n!="object")return;let e=n.entries;if(!(!e||typeof e!="object")){DM(e);try{if(_.view&&_.designScale&&typeof sessionStorage<"u"){let[t,i]=_.view.getCenter(),{dbuX:r,dbuY:s}=Pn(t,i,_.designScale,_.designOriginX,_.designOriginY);sessionStorage.setItem("or_restore_view",JSON.stringify({dbuX:r,dbuY:s,zoom:_.view.getZoom()}))}}catch{}window.location.reload()}}_.redrawAllLayers=$t;_.captureLayout=(n={})=>VM(_,n);function P5(n){let e=R3(n);if(e){try{if(sessionStorage.getItem("or_sw_render_warned"))return;sessionStorage.setItem("or_sw_render_warned","1")}catch{}Ft(e,15e3)}}function C5(n){let e=document.createElement("div");e.className="layout-viewer",e.style.width="100%",e.style.height="100%",e.style.backgroundColor="var(--bg-map)",n.element.appendChild(e);let t=document.createElement("div");t.className="or-hud or-hud-bottom-right heatmap-map-legend hidden",e.appendChild(t),_.heatMapLegendEl=t;let i=document.createElement("div");i.className="or-progress",e.appendChild(i),_.tileProgressEl=i,n.on("destroy",()=>{_.tileProgressEl=null,_.heatMapLegendEl=null}),_.view=X3(e,{preserveDrawingBuffer:_.preserveBuffer,prefs:{smooth:()=>_.controlSmoothing,doubleBuffer:()=>_.doubleBuffer,defer:()=>_.deferTileUpdates},tileSize:on,dpr:Yo,isStatic:fe(_)}),_.view.on("contextlost",()=>{console.warn("Layout view: WebGL context lost; rebuilding the view.")}),_.view.on("contextfailed",()=>{Ft("The layout view lost its graphics context and could not get it back; reload the page.",15e3)}),_.view.on("renderer",P5),window.__orView=_.view,m3(()=>{_.view.invalidateSize(),$t()});let r=document.createElement("div");r.className="or-zoom-control";let s=[];for(let[y,b,x]of[["+","Zoom in",()=>_.view.zoomIn()],["\u2212","Zoom out",()=>_.view.zoomOut()],["\u2922","Fit",()=>{_.fitRect&&_.view.fitWorldRect(_.fitRect)}]]){let E=document.createElement("button");E.type="button",E.title=b,E.setAttribute("aria-label",b),E.textContent=y,E.addEventListener("click",w=>{w.stopPropagation(),x()}),r.appendChild(E),s.push(E)}e.appendChild(r);let o=()=>{let{minZoom:y,maxZoom:b}=_.view.getLimits(),x=_.view.getTargetZoom();s[0].disabled=x>=b,s[1].disabled=x<=y};_.view.on("zoom zoomend limits",o),o();let a=document.createElement("div");a.className="or-hud or-hud-bottom-left hidden";let c=document.createElement("div");c.id="scale-bar";let l=document.createElement("span");l.className="or-hud-divider";let u=document.createElement("div");u.id="coord-bar",a.appendChild(c),a.appendChild(l),a.appendChild(u),e.appendChild(a);function f(){let y=c.style.display!=="none"&&c.childElementCount>0,b=u.textContent!=="";l.style.display=y&&b?"":"none",a.classList.toggle("hidden",!y&&!b)}f(),Q3(_.view,{isStatic:()=>fe(_),wheelZoom:()=>_.wheelZoom,arrowStep:()=>_.arrowStep,contextEnabled:()=>!(_.rulerManager&&_.rulerManager.isActive()),onClick:(y,b)=>{_.rulerManager&&_.rulerManager.isActive()?_.rulerManager.handleMapClick(y,b):_.rulerManager?.handleRulerClick(y)||_.onMapClick&&_.onMapClick(y,b)},onContextClick:(y,b)=>{_.onMapContextClick&&_.onMapContextClick(y,b)},onMove:(y,b)=>{if(_.lastMouseWorld=y,_.rulerManager&&_.rulerManager.isActive()&&_.rulerManager.handleMouseMove(y,b),!_.designScale)return;let{dbuX:x,dbuY:E}=Pn(y[0],y[1],_.designScale,_.designOriginX,_.designOriginY);u.textContent=`X: ${_.formatDbu(x)} Y: ${_.formatDbu(E)}`,f()},onLeave:()=>{_.lastMouseWorld=null,u.textContent="",f()}});let d=22,h=8,p=22;function m(y,b,x){let w=2+h,T=p,R=p+y,F=d-2,O=y>=40,j=[];if(j.push(``),O&&x>1)for(let V=1;V`)}O&&j.push(`0`),j.push(`${b}`),c.innerHTML=`${j.join("")}`}function g(){if(!_.designScale||!gt.scale_bar){c.style.display="none",f();return}let y=_.designScale*Math.pow(2,_.view.getZoom()),b=_.view.getSize().width||400,x=V3({targetPx:b*.15,pxPerDbu:y,dbuPerMicron:_.techData?.dbu_per_micron,showDbu:_.showDbu});if(!x){c.style.display="none",f();return}c.style.display="",m(x.barPx,x.label,x.segments),f()}let v=ur(g);_.view.on("zoom zoomend resize",v),_.updateScaleBar=g,_.rulerManager=new Qh(_,gt,Xl,ap),_.labelManager=new ep(_,gt,Xl,ap)}function T5(n){let e=document.createElement("div");e.className="display-controls",e.innerHTML='
Loading layers...
',n.element.appendChild(e),_.displayControlsEl=e}var fv="or_restore_console",L5=1<<20;function M5(){try{if(_.tclOutputEl){let n=[..._.tclOutputEl.children].map(r=>[r.textContent,r.className]),e=n.length,t=0;for(;e>0&&t+n[e-1][0].length<=L5;)t+=n[--e][0].length;let i=n.slice(e);e>0&&i.unshift([`[earlier output not kept across reload] +`,""]),sessionStorage.setItem(fv,JSON.stringify(i))}}catch{}window.location.reload()}function A5(){try{let n=sessionStorage.getItem(fv);if(!n)return;sessionStorage.removeItem(fv);for(let[e,t]of JSON.parse(n))gr(e,t)}catch{}}function gr(n,e){if(!_.tclOutputEl)return;let t=document.createElement("span");e&&(t.className=e),t.textContent=n,_.tclOutputEl.appendChild(t),_.tclOutputEl.scrollTop=_.tclOutputEl.scrollHeight}function k5(){if(_._shutdownHandled)return;_._shutdownHandled=!0,_.websocketManager&&(_.websocketManager._shutdown=!0,_.websocketManager.onPush=()=>{});let n=document.createElement("div");n.style.cssText="position:fixed;inset:0;z-index:99999;background:#1e1e1e;color:#ddd;display:flex;flex-direction:column;align-items:center;justify-content:center;font-family:system-ui,sans-serif;font-size:16px;padding:24px;text-align:center;",n.innerHTML='
OpenROAD exited
You can close this tab.
',document.body.appendChild(n),setTimeout(()=>{try{window.close()}catch{}},1500)}function R5(n){let e=document.createElement("div");if(e.className="tcl-console",e.innerHTML='
%
',n.element.appendChild(e),_.tclOutputEl=e.querySelector(".tcl-output"),A5(),fe(_)){e.querySelector(".tcl-input-row").style.display="none";let r=document.createElement("span");r.className="tcl-static-notice",r.setAttribute("role","status"),r.setAttribute("aria-live","polite"),r.textContent="Tcl console is not available in saved reports.",_.tclOutputEl.appendChild(r);return}let t=e.querySelector(".tcl-input"),i=new ip(t,_.websocketManager);t.addEventListener("keydown",r=>{if(!i.handleKeyDown(r)&&r.key==="Enter"){let s=t.value.trim();if(!s)return;gr(`>>> ${s} +`,"tcl-cmd"),i.addToHistory(s),t.value="",_.websocketManager.request({type:"tcl_eval",cmd:s}).then(o=>{o.result&&gr(o.result+` +`,o.is_error?"tcl-error":""),o.action==="shutdown"&&k5(),!o.is_error&&_.drcWidget&&_.drcWidget.refresh()}).catch(o=>gr(`Error: ${o} +`,"tcl-error"))}})}_.visibility=gt;var _r=uM(_,$t,ks),I5=_r.createInspector,Xl=_r.updateInspector,B5=_r.highlightBBox,O5=_r.pulseHighlight;_.updateInspector=Xl;_.navigateInspector=_r.navigateInspector;_.refreshInspector=_r.refreshInspector;_.animateSelection=_r.animateSelection;_.stopSelectionAnimation=_r.stopSelectionAnimation;function D5(n){new Vh(n,_,$t)}function N5(n){_.timingWidget=new Ps(_,$t,ks),n.element.appendChild(_.timingWidget.element)}function F5(n){_.drcWidget=new np(_,$t,ks),n.element.appendChild(_.drcWidget.element)}function z5(n){_.clockTreeWidget=new $h(n,_,$t,ks)}function U5(n){_.chartsWidget=new Gh(_,$t),n.element.appendChild(_.chartsWidget.element)}function $5(n){let e=document.createElement("div");e.className="help-panel",e.innerHTML="

Keyboard Shortcuts

fFit design to viewport
scrollZoom in/out
dragPan the view
right-dragRubber-band zoom
Shift+clickAdd object to selection
Ctrl/Cmd+clickSelect object and its connected nets
kToggle ruler mode
Shift+KClear all rulers
EscapeCancel ruler (when building)
",n.element.appendChild(e)}function G5(n){_.selectionBrowser=new Wh(n,_,ks)}function V5(n){new tp(n,_)}function W5(n){_.threeDViewerWidget=new sp(n,_)}var j5=28,H5={dimensions:{headerHeight:j5},root:{type:"row",content:[{type:"component",componentType:"DisplayControls",title:"Display Controls",width:15},{type:"column",width:55,content:[{type:"stack",height:70,content:[{type:"component",componentType:"LayoutViewer",title:"Layout",isClosable:!1},{type:"component",componentType:"SchematicWidget",title:"Schematic"},{type:"component",componentType:"3DViewer",title:"3D Viewer"}]},{type:"component",componentType:"TclConsole",title:"Tcl Console",height:30}]},{type:"stack",width:30,content:[{type:"component",componentType:"Inspector",title:"Inspector"},{type:"component",componentType:"Browser",title:"Hierarchy"},{type:"component",componentType:"TimingWidget",title:"Timing"},{type:"component",componentType:"DRCWidget",title:"DRC"},{type:"component",componentType:"SelectHighlight",title:"Select Highlight"},{type:"component",componentType:"ClockWidget",title:"Clock Tree"},{type:"component",componentType:"ChartsWidget",title:"Charts"},{type:"component",componentType:"HelpWidget",title:"Help"}]}]}};_.goldenLayout=new Th(document.getElementById("gl-container"));_.goldenLayout.registerComponentFactoryFunction("LayoutViewer",C5);_.goldenLayout.registerComponentFactoryFunction("DisplayControls",T5);_.goldenLayout.registerComponentFactoryFunction("TclConsole",R5);_.goldenLayout.registerComponentFactoryFunction("Inspector",I5);_.goldenLayout.registerComponentFactoryFunction("Browser",D5);_.goldenLayout.registerComponentFactoryFunction("TimingWidget",N5);_.goldenLayout.registerComponentFactoryFunction("DRCWidget",F5);_.goldenLayout.registerComponentFactoryFunction("ClockWidget",z5);_.goldenLayout.registerComponentFactoryFunction("ChartsWidget",U5);_.goldenLayout.registerComponentFactoryFunction("SchematicWidget",V5);_.goldenLayout.registerComponentFactoryFunction("3DViewer",W5);_.goldenLayout.registerComponentFactoryFunction("HelpWidget",$5);_.goldenLayout.registerComponentFactoryFunction("SelectHighlight",G5);var ci=window.__STATIC_CACHE__||null;if(ci)l3(),_.websocketManager=Nl.fromCache(ci,WM);else{let n=`ws://${window.location.host||"localhost:8080"}/ws`;_.websocketManager=new Nl(n,WM),_.layerExtents=new Ih,_.websocketManager.onReconnected=()=>{cp(),gv(null,null,{reloadOnChange:!0}).catch(()=>{})}}jM();_.goldenLayout.loadLayout(H5);HM();function HM(){W3(document.getElementById("gl-container"))>0&&_.goldenLayout.updateSize()}_.goldenLayout.on("stateChanged",()=>{HM()});function pv(){_.goldenLayout.updateSize()}_.syncLayoutSize=pv;window.addEventListener("resize",pv);function ap(n){_.goldenLayout.focusComponent(n)}_.focusComponent=ap;_.resetLayout=function(){_.goldenLayout&&typeof _.goldenLayout.resetLayout=="function"&&_.goldenLayout.resetLayout()};_.toggleTheme=function(){let n=document.documentElement.dataset.theme==="dark"?"light":"dark";document.documentElement.dataset.theme=n,ev(n),Nh(n),_.chartsWidget&&_.chartsWidget.render(),_.clockTreeWidget&&_.clockTreeWidget.render(),an()};_.toggleShowDbu=function(){_.showDbu=!_.showDbu,$e("or_show_dbu",_.showDbu?"1":"0"),_.rulerManager&&_.rulerManager._renderAll(),_.hierarchyBrowser&&_.hierarchyBrowser._render(),_.updateScaleBar&&_.updateScaleBar(),_.refreshInspector&&_.refreshInspector(),an()};_.toggleRulerStyle=function(){_.rulerStyle=_.rulerStyle==="manhattan"?"euclidian":"manhattan",$e("or_ruler_style",_.rulerStyle),an()};_.toggleWheelZoom=function(){_.wheelZoom=!_.wheelZoom,$e("or_wheel_zoom",_.wheelZoom?"1":"0"),an()};_.toggleControlSmoothing=function(){_.controlSmoothing=!_.controlSmoothing,$e("or_control_smoothing",_.controlSmoothing?"1":"0"),an()};_.toggleDoubleBuffer=function(){_.doubleBuffer=!_.doubleBuffer,$e("or_double_buffer",_.doubleBuffer?"1":"0"),_.view?.applyPrefs(),an()};_.toggleDeferTileUpdates=function(){_.deferTileUpdates=!_.deferTileUpdates,$e("or_defer_tile_updates",_.deferTileUpdates?"1":"0"),_.view?.applyPrefs(),an()};_.setArrowStep=function(n){_.arrowStep=Gl(n),$e("or_arrow_step",String(_.arrowStep)),an()};_.setAppFont=function({family:n,scale:e}){_.fontFamily=n??_.fontFamily,_.fontScale=jl(e??_.fontScale),$e("or_font_family",encodeURIComponent(_.fontFamily)),$e("or_font_scale",String(_.fontScale)),_.applyAppFont(),an()};_.applyAppFont=function(){let n=document.documentElement;_.fontFamily?n.style.setProperty("--or-font-family",_.fontFamily):n.style.removeProperty("--or-font-family"),n.style.setProperty("--or-font-scale",String(_.fontScale/100)),_.chartsWidget&&_.chartsWidget.render(),_.clockTreeWidget&&_.clockTreeWidget.render()};_.showArrowStepDialog=()=>hM(_);_.showAppFontDialog=()=>pM(_);_.togglePolyDecomp=function(){_.websocketManager&&_.websocketManager.request({type:"poly_decomp",value:!_.polyDecomp}).then(n=>mv(n.value)).catch(()=>{})};function mv(n){_.polyDecomp=!!n,_.rebuildMenuBar&&_.rebuildMenuBar(),_.refreshOverlay&&_.refreshOverlay()}_.applyAppFont();_.echoTcl=n=>gr(`>>> ${n} +`,"tcl-cmd");_.runTclScript=(n,e)=>n?(e&&_.echoTcl(n),_.websocketManager.request({type:"tcl_eval",cmd:n}).then(t=>(t&&t.result&&gr(t.result+` +`,t.is_error?"tcl-error":""),t)).catch(t=>{gr(`Error: ${t} +`,"tcl-error")})):Promise.resolve();function YM(n){n&&(_.customMenu=n.menu||[],_.customToolbar=n.toolbar||[],_.rebuildMenuBar&&_.rebuildMenuBar(),_.rebuildToolbar&&_.rebuildToolbar(),pv())}_.customMenu=[];_.customToolbar=[];_.scheduleRedrawAllLayers=ea;_.showGlobalConnectDialog=()=>PM(_);_.showInsertBufferDialog=n=>CM(_,n);xM(_);wM(_);_.contextMenu=new op(_);function Y5(){let n=document.getElementById("debug-continue-btn");return n||(n=document.createElement("button"),n.id="debug-continue-btn",n.className="debug-continue-btn",n.textContent="Continue",n.title="Advance the debugger (gpl, cts, ...)",n.addEventListener("click",()=>{_.websocketManager.request({type:"debug_continue"}).catch(()=>{})}),(document.getElementById("menu-bar")||document.body).appendChild(n),n)}function qM(n,e){let t=Kb(n,on(),e);return t?(_.currentBounds=n,_.designScale=t.scale,_.designOriginX=t.originX,_.designOriginY=t.originY,_.fitRect=t.fitRect,_.view.setLimits({minZoom:0,maxZoom:D3(t.scale)}),!0):!1}async function gv(n,e,{reloadOnChange:t=!1}={}){if(fe(_)||!_.view)return!1;let i=n,r=e;if(!i)try{let l=await _.websocketManager.request({type:"bounds"});i=l.bounds,r=l.fit_bounds}catch{return!1}if(!i||B3(_.currentBounds,i))return!1;if(t)return window.location.reload(),!0;let s=!!_.designScale,[o,a]=_.view.getCenter(),c=s?Pn(o,a,_.designScale,_.designOriginX,_.designOriginY):null;return qM(i,r)?(c&&_.view.setView(Sn(c.dbuX,c.dbuY,_.designScale,_.designOriginX,_.designOriginY),_.view.getZoom(),{animate:!1}),_.clearSelectionOutline&&_.clearSelectionOutline(),$t(),!0):!1}function q5(){let n=document.getElementById("loading-overlay");n.style.display="flex";let e=()=>{n.style.display!=="none"&&_.websocketManager.request({type:"bounds"}).then(t=>{t.shapes_ready&&(n.style.display="none")}).catch(()=>{}).finally(()=>{n.style.display!=="none"&&setTimeout(e,1e3)})};setTimeout(e,1e3)}function cp(){_.layerExtents&&_.layerExtents.refetch(n=>_.websocketManager.request(n))}function Z5(n){document.getElementById("loading-overlay").style.display="none",cp(),gv(n.bounds,n.fit_bounds).then(e=>{e||$t()}).catch(()=>$t()),_.refreshInspector&&_.refreshInspector()}function X5(){let n=document.getElementById("script-running-badge");return n||(n=document.createElement("span"),n.id="script-running-badge",n.className="script-running-badge",n.textContent="Script running",n.title="The view updates when the script pauses or finishes",(document.getElementById("menu-bar")||document.body).appendChild(n),n)}function K5(n){if(_.scriptRunning=n,X5().style.display=n?"block":"none",!n){if(!_.booted||!_.designScale){M5();return}_.refreshPending&&(_.refreshPending=!1,cp(),_.refreshInspector&&_.refreshInspector()),gv().then(e=>{e||ea()}).catch(()=>ea())}}_.websocketManager.onPush=n=>{if(n.type==="refresh"){if(_.scriptRunning){_.refreshPending=!0;return}Z5(n)}else if(n.type==="script_running")K5(!!n.running);else if(n.type==="renderer_controls_changed")_.refreshRendererControls&&_.refreshRendererControls(),ea();else if(n.type==="selection_invalidated")_.updateInspector&&_.updateInspector(null),_.stopSelectionAnimation&&_.stopSelectionAnimation(),_.clearSelectionOutline&&_.clearSelectionOutline(),ks();else if(n.type==="heatmaps_changed")_.websocketManager.request({type:"heatmaps"}).then(dv).catch(e=>console.error("Heat map refresh failed",e));else if(n.type==="labels_changed")_.labelManager&&_.labelManager.applyRemoteLabels(n.labels);else if(n.type==="drcUpdated")_._drcUpdateTimeout&&clearTimeout(_._drcUpdateTimeout),_._drcUpdateTimeout=setTimeout(()=>{_.drcWidget&&_.drcWidget.refresh()},500);else if(n.type==="debug_paused")_.refreshRendererControls&&_.refreshRendererControls(),Y5().style.display="block",ea(),_.chartsWidget&&_.websocketManager.request({type:"debug_charts"}).then(e=>_.chartsWidget.setDebugCharts(e.charts||[])).catch(()=>{});else if(n.type==="debug_resumed"){let e=document.getElementById("debug-continue-btn");e&&(e.style.display="none")}else if(n.type==="debug_refresh"){if(_.scriptRunning)return;_.clearSelectionOutline&&_.clearSelectionOutline(),ea()}else if(n.type==="log"){let e=n.text;e.endsWith(` +`)&&(e=e.slice(0,-1)),e&&gr(e+` +`,"")}else n.type==="restore_display_state"?S5(n.state):n.type==="custom_ui"?YM(n):n.type==="poly_decomp"?mv(n.value):n.type==="shutdown"&&(_.websocketManager._shutdown=!0,mr.innerHTML='
Server stopped
',mr.style.display="block")};_.websocketManager.readyPromise.then(async()=>{try{let o=function(a,c={}){let{addToSelection:l=!1,focusInspector:u=!0,context:f=!1,showConnectivity:d=!1}=c;if(!_.designScale)return Promise.resolve(null);let{dbuX:h,dbuY:p}=Pn(a[0],a[1],_.designScale,_.designOriginX,_.designOriginY);if(_.labelManager&&_.labelManager.isActive())return _.labelManager.handleMapClick(h,p),Promise.resolve(null);let m=k3(gt,ta),g={type:"select",dbu_x:h,dbu_y:p,zoom:Math.round(_.view.getZoom()),visible_layers:[..._.visibleLayerNames],selectable_layers:[..._.selectableLayers],use_dbu:_.showDbu,...m};l&&(g.add_to_selection=!0),f&&(g.context=!0),d&&(g.show_connectivity=!0),_.visibleChiplets instanceof Set&&(g.visible_chiplets=[..._.visibleChiplets]);let v=Pt(_);return _.websocketManager.request(g).then(y=>{if(zt(_,v)){if(console.log("Select response:",y,"at dbu",h,p),qo(_,y),y.selected&&y.selected.length>0){let b=y.selected[0];b.type==="Inst"&&(_.selectedInstanceName=b.name,_.schematicWidget&&_.schematicWidget.refresh()),Xl(y),u&&ap("Inspector"),y.bbox&&(B5(y.bbox[0],y.bbox[1],y.bbox[2],y.bbox[3],y.type),O5(y.bbox,y.type),_.lastSelectionBounds=y.bbox.slice(0,4)),g.show_connectivity&&y.connected_added>0&&Ft(`Selected ${y.connected_added} connected net`+(y.connected_added>1?"s":""))}else!l&&!f&&(Xl(null),_.clearSelectionOutline&&_.clearSelectionOutline(),_.lastSelectionBounds=null);return hv(),y}}).catch(y=>(console.error("Select failed:",y),null))},[n,e,t]=await Promise.all([_.websocketManager.request({type:"tech"}),_.websocketManager.request({type:"bounds"}),_.websocketManager.request({type:"heatmaps"})]);cp(),_.hasLiberty=n.has_liberty,_.techData=n,NM(n.block_name),_.websocketManager.request({type:"custom_ui"}).then(YM).catch(()=>{}),_.websocketManager.request({type:"poly_decomp"}).then(a=>mv(a.value)).catch(()=>{});let i=e.bounds,r=e.fit_bounds;if(!ci){let a=_.view.getSize();u3(N3({designBounds:i,fitRect:r,viewW:a.width,viewH:a.height}))}let s=qM(i,r);if(s){if(_.labelManager&&_.labelManager.reload(),ci){let a=ci.zoom;_.view.setLimits({minZoom:a,maxZoom:a})}if(_.view.fitWorldRect(_.fitRect,{animate:!1}),ci){let a=Nt(i[0][1],i[0][0],i[1][1],i[1][0],_.designScale,_.designOriginX,_.designOriginY);ci.setPathOverlay=c=>{_.view.setImageOverlay("timing-path",c?{image:c,rect:a}:null)}}try{let a=sessionStorage.getItem("or_restore_view");if(a){sessionStorage.removeItem("or_restore_view");let c=JSON.parse(a);c&&isFinite(c.dbuX)&&isFinite(c.dbuY)&&isFinite(c.zoom)&&_.view.setView(Sn(c.dbuX,c.dbuY,_.designScale,_.designOriginX,_.designOriginY),c.zoom,{animate:!1})}}catch{}}ci&&(document.getElementById("loading-overlay").style.display="none"),_.selectAtWorld=o,ci||(_.onMapClick=(a,c)=>o(a,{addToSelection:!!c.shiftKey,showConnectivity:!!(c.ctrlKey||c.metaKey)}),_.onMapContextClick=(a,c)=>{o(a,{context:!0,focusInspector:!1}).then(()=>_.contextMenu.show(c))}),_M(_,gt,ta,n,$t,E5),!_.overlayLayer&&!ci&&(_.overlayLayer=_.view.addTileSlot("overlay",{order:ot.overlay,source:Zb({wm:_.websocketManager,dpr:Yo,tileSize:on,buildRequest:(a,c,l)=>C3(a,c,l,gt,_)})})),dv(t),s&&!e.shapes_ready&&q5(),an(),_.booted=!0}catch(n){_.scriptRunning||console.error("Failed to load initial data from server:",n)}});document.addEventListener("openroad-cone-sync",n=>{_.schematicWidget?.syncCone(n.detail||{})});document.addEventListener("keydown",n=>{let e=n.target.tagName;if(e==="INPUT"||e==="TEXTAREA"||n.target.isContentEditable)return;let t=n.key.toLowerCase();if(t==="escape"&&_.rulerManager&&_.rulerManager.isActive())_.rulerManager.cancelRulerBuild();else if(t==="escape"&&_.labelManager&&_.labelManager.isActive())_.labelManager.cancelLabelMode();else if(t==="k"&&!n.shiftKey&&!n.ctrlKey&&!n.metaKey)_.rulerManager&&_.rulerManager.toggleRulerMode();else if(t==="k"&&n.shiftKey&&!n.ctrlKey&&!n.metaKey)_.rulerManager&&_.rulerManager.clearAllRulers();else if(t==="l"&&!n.shiftKey&&!n.ctrlKey&&!n.metaKey)_.labelManager&&_.labelManager.toggleLabelMode();else if(t==="f"&&!n.ctrlKey&&!n.metaKey&&_.fitRect)_.view.fitWorldRect(_.fitRect);else if(t==="z"&&!n.ctrlKey&&_.view){let i=n.shiftKey?-1:1;_.view.zoomAround(_.lastMouseWorld?_.view.project(_.lastMouseWorld):null,i)}else t==="f"&&(n.ctrlKey||n.metaKey)?(n.preventDefault(),_.designScale&&Zh(_)):t==="g"&&n.shiftKey&&!n.ctrlKey&&!n.metaKey?(n.preventDefault(),_.designScale&&Xh(_)):t==="t"&&!n.shiftKey&&!n.ctrlKey&&!n.metaKey&&_.toggleTheme()},!0);})(); /*! Bundled license information: @lit/reactive-element/css-tag.js: diff --git a/src/web/src/display-state.js b/src/web/src/display-state.js index aac2f7a8f11..6fe66550f28 100644 --- a/src/web/src/display-state.js +++ b/src/web/src/display-state.js @@ -51,6 +51,23 @@ const DISPLAY_STATE_KEYS = [ { key: 'or_defer_tile_updates', store: 'cookie' }, ]; +// The rendering preferences (#11340) from their cookies. +export function renderPrefs(getCookie) { + return { + // Animated zoom and pan, and drag inertia. Off by default, so + // navigation jumps the way Qt's does. + controlSmoothing: getCookie('or_control_smoothing') === '1', + // Show new content only once it is complete — a tile's whole + // composite, and on a zoom the whole view (zoom-swap.js) — Qt's + // draw_pixmap_ model. + doubleBuffer: getCookie('or_double_buffer') !== '0', + // Hold tile requests until a drag ends rather than issuing a fresh + // batch every updateInterval while the pointer is down. Opt-in: it + // leaves the area a drag exposes empty until the button is released. + deferTileUpdates: getCookie('or_defer_tile_updates') === '1', + }; +} + // Storage accessors, tolerant of a browser with Web Storage disabled (the // cookie helpers in theme.js already are). The store is resolved by NAME // inside the try: with storage blocked, reading `window.sessionStorage` throws diff --git a/src/web/src/layout-view.js b/src/web/src/layout-view.js index ede01739684..fe7af5850c3 100644 --- a/src/web/src/layout-view.js +++ b/src/web/src/layout-view.js @@ -95,6 +95,13 @@ function makeEmitter() { }; } +// What draws the view: luma.gl reports a software renderer as gpuType 'cpu'. +function deviceInfo(d) { + const info = (d && d.device && d.device.info) || {}; + return { gpuType: info.gpuType || 'unknown', + renderer: info.renderer || '', vendor: info.vendor || '' }; +} + // `opts`: // deckApi the deck.gl namespace (window.deck); a missing one leaves a view // that keeps its state but draws nothing @@ -121,6 +128,7 @@ export function createLayoutView(container, opts = {}) { let anim = null; // { from, to, anchor, start, ms } let interacting = false; // a drag or pinch from the controller let afterFrame = []; // called once deck has drawn its next frame + let rendererInfo = null; // what draws, once deck's device is up let dragSamples = []; // { t, target, zoom } while interacting let prefetchZ = null; // level loaded in the background for a zoom out let flightTrail = null; // a landed flight's pulled-out level, kept under @@ -232,6 +240,8 @@ export function createLayoutView(container, opts = {}) { // The canvas only exists once the device is up. onLoad: () => { watchContext(); + rendererInfo = deviceInfo(deckgl); + events.emit('renderer', rendererInfo); scheduleRender(); }, onAfterRender: () => { @@ -990,6 +1000,7 @@ export function createLayoutView(container, opts = {}) { const view = { DRAW_ORDER, getContainer: () => container, + getRendererInfo: () => rendererInfo, getSize, getZoom: () => vs.zoom, // The zoom an animation in flight will end on. diff --git a/src/web/src/main.js b/src/web/src/main.js index ed5add178ca..b5d510ad1d4 100644 --- a/src/web/src/main.js +++ b/src/web/src/main.js @@ -23,7 +23,8 @@ import { applySelectionFlags, beginSelection, boundsEqual, buildVisibilityFlags, clampArrowStep, computeBoundsTransforms, computeScaleBar, decorateTabIcons, fittedTileSizeCss, formatDbu, formatDistance, isCurrentSelection, isStaticMode, maxUsefulZoom, - parseDbu, rafCoalesce, showToast, unitLabel } + parseDbu, rafCoalesce, showToast, softwareRenderingWarning, + unitLabel } from './ui-utils.js'; import { clampFontScale, showAppFontDialog, showArrowStepDialog } from './options-dialogs.js'; @@ -38,7 +39,8 @@ import { SchematicWidget } from './schematic-widget.js'; import { DrcWidget } from './drc-widget.js'; import { TclCompleter } from './tcl-completer.js'; import { getCookie, setCookie, applyGLTheme, persistTheme } from './theme.js'; -import { serializeDisplayState, applyDisplayStateEntries } from './display-state.js'; +import { serializeDisplayState, applyDisplayStateEntries, renderPrefs } + from './display-state.js'; import { updateDocumentTitle } from './title.js'; import { ThreeDViewerWidget } from './3d-viewer-widget.js'; import { ContextMenu } from './context-menu.js'; @@ -192,17 +194,8 @@ const app = { wheelZoom: getCookie('or_wheel_zoom') !== '0', // Qt's "Arrow keys scroll step", in CSS px. arrowStep: clampArrowStep(getCookie('or_arrow_step')), - // ── Rendering preferences (#11340) ── - // Animated zoom and pan, and drag inertia. On by default; off makes - // navigation jump the way Qt's does. - controlSmoothing: getCookie('or_control_smoothing') !== '0', - // Show new content only once it is complete — a tile's whole composite, - // and on a zoom the whole view (zoom-swap.js) — Qt's draw_pixmap_ model. - doubleBuffer: getCookie('or_double_buffer') !== '0', - // Hold tile requests until a drag ends rather than issuing a fresh batch - // every updateInterval while the pointer is down. Opt-in: it leaves the - // area a drag exposes empty until the button is released. - deferTileUpdates: getCookie('or_defer_tile_updates') === '1', + // Rendering preferences (#11340): smoothing, double buffering, defer. + ...renderPrefs(getCookie), // Qt's "Application font", split into the CSS family and a percentage // scale over the stylesheet's authored sizes. Empty family = the // stylesheet default. @@ -581,6 +574,23 @@ app.redrawAllLayers = redrawAllLayers; // Expose the WYSIWYG capture so the context menu "Save" can grab the scene. app.captureLayout = (opts = {}) => captureLayout(app, opts); +// Once per browser session: the layout view is slow without the GPU. +function warnIfSoftwareRendering(info) { + const message = softwareRenderingWarning(info); + if (!message) { + return; + } + try { + if (sessionStorage.getItem('or_sw_render_warned')) { + return; + } + sessionStorage.setItem('or_sw_render_warned', '1'); + } catch (_) { + // Storage blocked: warn on every load instead. + } + showToast(message, 15000); +} + function createLayoutViewer(container) { const mapDiv = document.createElement('div'); mapDiv.className = 'layout-viewer'; @@ -634,6 +644,7 @@ function createLayoutViewer(container) { showToast('The layout view lost its graphics context and could not ' + 'get it back; reload the page.', 15000); }); + app.view.on('renderer', warnIfSoftwareRendering); // For the browser probes and debugging from the console. window.__orView = app.view; // Tiles are rasterized for the ratio in force when they were requested and diff --git a/src/web/src/ui-utils.js b/src/web/src/ui-utils.js index 2afa34a4730..44adf4eb506 100644 --- a/src/web/src/ui-utils.js +++ b/src/web/src/ui-utils.js @@ -55,6 +55,18 @@ export function showToast(message, durationMs = 4000) { return toast; } +// The notice for a browser that draws the layout view without the GPU +// (luma.gl's gpuType 'cpu'), or null. +export function softwareRenderingWarning(info) { + if (!info || info.gpuType !== 'cpu') { + return null; + } + return 'Software rendering detected (reduced performance). Make sure ' + + "'Use graphics acceleration when available' (or 'Use hardware " + + "acceleration when available') is turned on in your browser " + + 'settings, then restart the browser.'; +} + // Themed confirmation dialog. Resolves true when confirmed, false when // cancelled (button, Escape, or clicking outside the box). Focus starts // on Cancel — the safe choice for destructive confirmations. diff --git a/src/web/test/js/fake-deck.js b/src/web/test/js/fake-deck.js index 851c60ae8dc..78b06182dae 100644 --- a/src/web/test/js/fake-deck.js +++ b/src/web/test/js/fake-deck.js @@ -14,6 +14,9 @@ export function makeFakeDeck() { } const api = { decks: [], + // What luma.gl's device.info would report. + deviceInfo: { gpuType: 'discrete', renderer: 'Fake GPU', + vendor: 'Fake' }, Deck: class { constructor(props) { this.props = { ...props }; @@ -24,6 +27,7 @@ export function makeFakeDeck() { api.decks.push(this); queueMicrotask(() => { this.loaded = true; + this.device = { info: { ...api.deviceInfo } }; this.props.onLoad?.(); }); } diff --git a/src/web/test/js/test-display-state.js b/src/web/test/js/test-display-state.js index db16d7e3168..0e05d6535b2 100644 --- a/src/web/test/js/test-display-state.js +++ b/src/web/test/js/test-display-state.js @@ -79,6 +79,36 @@ describe('serializeDisplayState', () => { }); }); +describe('renderPrefs', () => { + it('jumps without smoothing and double-buffers by default', async () => { + const { mod, getCookie } = await loadDisplayState(); + assert.deepEqual(mod.renderPrefs(getCookie), { + controlSmoothing: false, + doubleBuffer: true, + deferTileUpdates: false, + }); + }); + + it('keeps what the user chose', async () => { + const { mod, getCookie } = await loadDisplayState({ + cookie: { or_control_smoothing: '1', or_double_buffer: '0', + or_defer_tile_updates: '1' }, + }); + assert.deepEqual(mod.renderPrefs(getCookie), { + controlSmoothing: true, + doubleBuffer: false, + deferTileUpdates: true, + }); + }); + + it('reads smoothing turned off as off', async () => { + const { mod, getCookie } = await loadDisplayState({ + cookie: { or_control_smoothing: '0' }, + }); + assert.equal(mod.renderPrefs(getCookie).controlSmoothing, false); + }); +}); + describe('applyDisplayStateEntries', () => { it('round-trips every key through its own store', async () => { const all = { diff --git a/src/web/test/js/test-layout-view.js b/src/web/test/js/test-layout-view.js index 203ecf98fca..b17e95a855a 100644 --- a/src/web/test/js/test-layout-view.js +++ b/src/web/test/js/test-layout-view.js @@ -900,3 +900,33 @@ describe('LayoutView shapes, markers and capture', () => { assert.equal(await view.captureCanvas(), null); }); }); + +describe('LayoutView renderer', () => { + it('reports what draws once the deck is up', async () => { + const { view } = setup(); + const seen = []; + view.on('renderer', (info) => seen.push(info)); + assert.equal(view.getRendererInfo(), null); + await tick(); + const fake = { gpuType: 'discrete', renderer: 'Fake GPU', vendor: 'Fake' }; + assert.deepEqual(seen, [fake]); + assert.deepEqual(view.getRendererInfo(), fake); + }); + + it('reports a software renderer, and again after a lost context', async () => { + const deck = makeFakeDeck(); + deck.deviceInfo = { gpuType: 'cpu', renderer: 'SwiftShader' }; + const { view } = setup({ deck }); + const seen = []; + view.on('renderer', (info) => seen.push(info.gpuType)); + await tick(); + assert.deepEqual(view.getRendererInfo(), + { gpuType: 'cpu', renderer: 'SwiftShader', vendor: '' }); + deck.deviceInfo = { gpuType: 'integrated' }; + deck.decks[0].getCanvas().dispatchEvent( + new window.Event('webglcontextlost', { cancelable: true })); + await tick(); + assert.deepEqual(seen, ['cpu', 'integrated']); + assert.equal(view.getRendererInfo().gpuType, 'integrated'); + }); +}); diff --git a/src/web/test/js/test-ui-utils.js b/src/web/test/js/test-ui-utils.js index 98d1bc5ff03..a069618fb55 100644 --- a/src/web/test/js/test-ui-utils.js +++ b/src/web/test/js/test-ui-utils.js @@ -5,7 +5,8 @@ import { describe, it } from 'node:test'; import assert from 'node:assert/strict'; import { boundsEqual, computeBoundsTransforms, computeScaleBar, cssColorToHex, fittedTileSizeCss, isValidHexColor, kZoomMargin, maxUsefulZoom, - MAX_TILE_ZOOM, niceRoundParts, prefersReducedMotion, rafCoalesce } + MAX_TILE_ZOOM, niceRoundParts, prefersReducedMotion, rafCoalesce, + softwareRenderingWarning } from '../../src/ui-utils.js'; import { isDeviceExactTileSize, TILE_SIZE_CSS, TILE_SIZE_QUANTUM } from '../../src/tile-request.js'; @@ -400,3 +401,20 @@ describe('prefersReducedMotion', () => { } }); }); + +describe('softwareRenderingWarning', () => { + it('tells how to turn graphics acceleration on for a software renderer', () => { + const msg = softwareRenderingWarning({ gpuType: 'cpu' }); + assert.match(msg, /Software rendering detected/); + assert.match(msg, /Use graphics acceleration when available/); + assert.match(msg, /Use hardware acceleration when available/); + assert.match(msg, /restart the browser/); + }); + + it('says nothing when a GPU draws, or before the renderer is known', () => { + for (const gpuType of ['discrete', 'integrated', 'unknown']) { + assert.equal(softwareRenderingWarning({ gpuType }), null, gpuType); + } + assert.equal(softwareRenderingWarning(null), null); + }); +}); From 8fb0058c33d36118cf537cb0238615c12d458596 Mon Sep 17 00:00:00 2001 From: Jorge Ferreira Date: Wed, 21 Oct 2026 23:09:12 +0000 Subject: [PATCH 3/8] web: improve the warning for drawing without a GPU Also catches Mesa software renderers and missing WebGL. The warning stays in the bottom-right corner until closed, and can be silenced. Signed-off-by: Jorge Ferreira --- src/web/dist/app.min.js | 662 ++++++++++++++-------------- src/web/dist/index.html | 2 +- src/web/dist/report.min.js | 312 ++++++------- src/web/src/layout-view.js | 9 + src/web/src/main.js | 28 +- src/web/src/style.css | 43 ++ src/web/src/ui-utils.js | 68 ++- src/web/test/BUILD | 2 +- src/web/test/js/fake-deck.js | 6 + src/web/test/js/test-layout-view.js | 24 + src/web/test/js/test-ui-utils.js | 108 ++++- 11 files changed, 745 insertions(+), 519 deletions(-) diff --git a/src/web/dist/app.min.js b/src/web/dist/app.min.js index fb2b06a314d..cb9974d57df 100644 --- a/src/web/dist/app.min.js +++ b/src/web/dist/app.min.js @@ -1,6 +1,6 @@ -(()=>{var PVt=Object.create;var bPe=Object.defineProperty;var LVt=Object.getOwnPropertyDescriptor;var kVt=Object.getOwnPropertyNames;var RVt=Object.getPrototypeOf,IVt=Object.prototype.hasOwnProperty;var AD=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(n,r)=>(typeof require<"u"?require:n)[r]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var Ve=(s,n)=>()=>(s&&(n=s(s=0)),n);var Sd=(s,n)=>()=>(n||s((n={exports:{}}).exports,n),n.exports),Oy=(s,n)=>{for(var r in n)bPe(s,r,{get:n[r],enumerable:!0})},DVt=(s,n,r,c)=>{if(n&&typeof n=="object"||typeof n=="function")for(let u of kVt(n))!IVt.call(s,u)&&u!==r&&bPe(s,u,{get:()=>n[u],enumerable:!(c=LVt(n,u))||c.enumerable});return s};var Uut=(s,n,r)=>(r=s!=null?PVt(RVt(s)):{},DVt(n||!s||!s.__esModule?bPe(r,"default",{value:s,enumerable:!0}):r,s));var Wj,zVt,Vae,GVt,Gut,wPe=Ve(()=>{Wj=globalThis,zVt=globalThis.document||{},Vae=globalThis.process||{},GVt=globalThis.console,Gut=globalThis.navigator||{}});function Wae(s){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&process.versions?.electron)return!0;let n=typeof navigator<"u"&&navigator.userAgent,r=s||n;return!!(r&&r.indexOf("Electron")>=0)}var vPe=Ve(()=>{});function D1(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Wae()}var _Pe=Ve(()=>{vPe()});function yPe(s){return!s&&!D1()?"Node":Wae(s)?"Electron":(s||Gut.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var jut=Ve(()=>{_Pe();vPe();wPe()});var xPe,VL=Ve(()=>{wPe();_Pe();jut();xPe="4.1.2"});function PD(s,n){if(!s)throw new Error(n||"Assertion failed")}var EPe=Ve(()=>{});function SPe(s){if(!s)return 0;let n;switch(typeof s){case"number":n=s;break;case"object":n=s.logLevel||s.priority||0;break;default:return 0}return PD(Number.isFinite(n)&&n>=0),n}function $ut(s){let{logLevel:n,message:r}=s;s.logLevel=SPe(n);let c=s.args?Array.from(s.args):[];for(;c.length&&c.shift()!==r;);switch(typeof n){case"string":case"function":r!==void 0&&c.unshift(r),s.message=n;break;case"object":Object.assign(s,n);break;default:}typeof s.message=="function"&&(s.message=s.message());let u=typeof s.message;return PD(u==="string"||u==="object"),Object.assign(s,{args:c},s.opts)}var Vut=Ve(()=>{EPe()});var WL,Hae,Wut=Ve(()=>{Vut();WL=()=>{},Hae=class{constructor({level:n=0}={}){this.userData={},this._onceCache=new Set,this._level=n}set level(n){this.setLevel(n)}get level(){return this.getLevel()}setLevel(n){return this._level=n,this}getLevel(){return this._level}warn(n,...r){return this._log("warn",0,n,r,{once:!0})}error(n,...r){return this._log("error",0,n,r)}log(n,r,...c){return this._log("log",n,r,c)}info(n,r,...c){return this._log("info",n,r,c)}once(n,r,...c){return this._log("once",n,r,c,{once:!0})}_log(n,r,c,u,d={}){let b=$ut({logLevel:r,message:c,args:this._buildArgs(r,c,u),opts:d});return this._createLogFunction(n,b,d)}_buildArgs(n,r,c){return[n,r,...c]}_createLogFunction(n,r,c){if(!this._shouldLog(r.logLevel))return WL;let u=this._getOnceTag(c.tag??r.tag??r.message);if((c.once||r.once)&&u!==void 0){if(this._onceCache.has(u))return WL;this._onceCache.add(u)}return this._emit(n,r)}_shouldLog(n){return this.getLevel()>=SPe(n)}_getOnceTag(n){if(n!==void 0)try{return typeof n=="string"?n:String(n)}catch{return}}}});function $Vt(s){try{let n=window[s],r="__storage_test__";return n.setItem(r,r),n.removeItem(r),n}catch{return null}}var qae,Hut=Ve(()=>{qae=class{constructor(n,r,c="sessionStorage"){this.storage=$Vt(c),this.id=n,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(n){if(Object.assign(this.config,n),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let n={};if(this.storage){let r=this.storage.getItem(this.id);n=r?JSON.parse(r):{}}return Object.assign(this.config,n),this}}});function qut(s){let n;return s<10?n=`${s.toFixed(2)}ms`:s<100?n=`${s.toFixed(1)}ms`:s<1e3?n=`${s.toFixed(0)}ms`:n=`${(s/1e3).toFixed(2)}s`,n}function Xut(s,n=8){let r=Math.max(n-s.length,0);return`${" ".repeat(r)}${s}`}var Yut=Ve(()=>{});function Zut(s){return typeof s!="string"?s:(s=s.toUpperCase(),Xae[s]||Xae.WHITE)}function Kut(s,n,r){return!D1&&typeof s=="string"&&(n&&(s=`\x1B[${Zut(n)}m${s}\x1B[39m`),r&&(s=`\x1B[${Zut(r)+VVt}m${s}\x1B[49m`)),s}var Xae,VVt,Jut=Ve(()=>{VL();(function(s){s[s.BLACK=30]="BLACK",s[s.RED=31]="RED",s[s.GREEN=32]="GREEN",s[s.YELLOW=33]="YELLOW",s[s.BLUE=34]="BLUE",s[s.MAGENTA=35]="MAGENTA",s[s.CYAN=36]="CYAN",s[s.WHITE=37]="WHITE",s[s.BRIGHT_BLACK=90]="BRIGHT_BLACK",s[s.BRIGHT_RED=91]="BRIGHT_RED",s[s.BRIGHT_GREEN=92]="BRIGHT_GREEN",s[s.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",s[s.BRIGHT_BLUE=94]="BRIGHT_BLUE",s[s.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",s[s.BRIGHT_CYAN=96]="BRIGHT_CYAN",s[s.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Xae||(Xae={}));VVt=10});function Qut(s,n=["constructor"]){let r=Object.getPrototypeOf(s),c=Object.getOwnPropertyNames(r),u=s;for(let d of c){let b=u[d];typeof b=="function"&&(n.find(w=>d===w)||(u[d]=b.bind(s)))}}var eft=Ve(()=>{});var Yae,Fy,MPe=Ve(()=>{VL();Yae=class{getHighResolutionTimer(){let n;if(D1()&&Wj.performance)n=Wj?.performance?.now?.();else if("hrtime"in Vae){let r=Vae?.hrtime?.();n=r[0]*1e3+r[1]/1e6}else n=Date.now();return n}getMemoryUsageMB(){let r=Wj?.performance?.memory?.usedJSHeapSize;return r==null?null:Math.trunc(r/1024/1024)}},Fy=new Yae;globalThis.Probe=Yae;globalThis.probe=Fy});function WVt(s,n,r){if(typeof n=="string"){let c=r.time?Xut(qut(r.total)):"";n=r.time?`${s}: ${c} ${n}`:`${s}: ${n}`,n=Kut(n,r.color,r.background)}return n}function HVt(s){for(let n in s)for(let r in s[n])return r||"untitled";return"empty"}var LD,TPe,ig,CPe=Ve(()=>{VL();Wut();Hut();Yut();Jut();eft();EPe();MPe();LD={debug:D1()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},TPe={enabled:!0,level:0},ig=class extends Hae{constructor({id:n}={id:""}){super({level:0}),this.VERSION=xPe,this._startTs=Fy.getHighResolutionTimer(),this._deltaTs=Fy.getHighResolutionTimer(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=n,this.userData={},this._storage=new qae(`__probe-${this.id}__`,{[this.id]:TPe}),this.timeStamp(`${this.id} started`),Qut(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((Fy.getHighResolutionTimer()-this._startTs).toPrecision(10))}getDelta(){return Number((Fy.getHighResolutionTimer()-this._deltaTs).toPrecision(10))}set priority(n){this.level=n}get priority(){return this.level}getPriority(){return this.level}enable(n=!0){return this._updateConfiguration({enabled:n}),this}setLevel(n){return this._updateConfiguration({level:n}),this}get(n){return this._getConfiguration()[n]}set(n,r){this._updateConfiguration({[n]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(n,r){if(!n)throw new Error(r||"Assertion failed")}warn(n,...r){return this._log("warn",0,n,r,{method:LD.warn,once:!0})}error(n,...r){return this._log("error",0,n,r,{method:LD.error})}deprecated(n,r){return this.warn(`\`${n}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(n,r){return this.error(`\`${n}\` has been removed. Use \`${r}\` instead`)}probe(n,r,...c){let u=Fy.getMemoryUsageMB();if(u!==null){let d=`${u}MB `;typeof r=="function"?r=()=>`${d}${r()}`:typeof r=="string"&&(r=`${d}${r}`)}return this._log("log",n,r,c,{method:LD.log,time:!0,once:!0})}log(n,r,...c){return this._log("log",n,r,c,{method:LD.debug})}info(n,r,...c){return this._log("info",n,r,c,{method:console.info})}once(n,r,...c){return this._log("once",n,r,c,{method:LD.debug||LD.info,once:!0})}table(n,r,c){return r?this._log("table",n,r,c&&[c]||[],{method:console.table||WL,tag:HVt(r)}):WL}time(n,r){return this._log("time",n,r,[],{method:console.time?console.time:console.info})}timeEnd(n,r){return this._log("time",n,r,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(n,r){return this._log("time",n,r,[],{method:console.timeStamp||WL})}group(n,r,c={collapsed:!1}){let u=(c.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",n,r,[],{method:u})}groupCollapsed(n,r,c={}){return this.group(n,r,Object.assign({},c,{collapsed:!0}))}groupEnd(n){return this._log("groupEnd",n,"",[],{method:console.groupEnd||WL})}withGroup(n,r,c){this.group(n,r)();try{c()}finally{this.groupEnd(n)()}}trace(){console.trace&&console.trace()}_shouldLog(n){return this.isEnabled()&&super._shouldLog(n)}_emit(n,r){let c=r.method;PD(c),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=Fy.getHighResolutionTimer();let u=WVt(this.id,r.message,r);return c.bind(console,u,...r.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(TPe),this._storage.config[this.id]}_updateConfiguration(n){let r=this._storage.config[this.id]||{...TPe};this._storage.setConfiguration({[this.id]:{...r,...n}})}};ig.VERSION=xPe});var tft=Ve(()=>{MPe();globalThis.probe||(globalThis.probe=Fy)});var FDn,Hj=Ve(()=>{CPe();CPe();tft();FDn=new ig({id:"@probe.gl/log"})});function Zj(){let s;if(typeof window<"u"&&window.performance)s=window.performance.now();else if(typeof process<"u"&&process.hrtime){let n=process.hrtime();s=n[0]*1e3+n[1]/1e6}else s=Date.now();return s}var VPe=Ve(()=>{});var qL,WPe=Ve(()=>{VPe();qL=class{constructor(n,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=n,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(n){return this.sampleSize=n,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(n){return this._count+=n,this._samples++,this._checkSampling(),this}subtractCount(n){return this._count-=n,this._samples++,this._checkSampling(),this}addTime(n){return this._time+=n,this.lastTiming=n,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Zj(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Zj()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}});var Eb,pft=Ve(()=>{WPe();Eb=class{constructor(n){this.stats={},this.id=n.id,this.stats={},this._initializeStats(n.stats),Object.seal(this)}get(n,r="count"){return this._getOrCreate({name:n,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let n of Object.values(this.stats))n.reset();return this}forEach(n){for(let r of Object.values(this.stats))n(r)}getTable(){let n={};return this.forEach(r=>{n[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),n}_initializeStats(n=[]){n.forEach(r=>this._getOrCreate(r))}_getOrCreate(n){let{name:r,type:c}=n,u=this.stats[r];return u||(n instanceof qL?u=n:u=new qL(r,c),this.stats[r]=u),u}}});var Kj=Ve(()=>{pft();WPe();VPe()});function Vft(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Wft(s){return Array.isArray(s)?s.length===0||typeof s[0]=="number":!1}function r$(s){return Vft(s)||Wft(s)}var Hft=Ve(()=>{});var sLe=Ve(()=>{Hft()});function ND(s){let n=s.split(""),r=0,c=0,u=!1,d=!1,b=!1;for(;r{var RVt=Object.create;var bPe=Object.defineProperty;var IVt=Object.getOwnPropertyDescriptor;var DVt=Object.getOwnPropertyNames;var BVt=Object.getPrototypeOf,OVt=Object.prototype.hasOwnProperty;var AD=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(n,r)=>(typeof require<"u"?require:n)[r]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var Ve=(s,n)=>()=>(s&&(n=s(s=0)),n);var Sd=(s,n)=>()=>(n||s((n={exports:{}}).exports,n),n.exports),Oy=(s,n)=>{for(var r in n)bPe(s,r,{get:n[r],enumerable:!0})},NVt=(s,n,r,c)=>{if(n&&typeof n=="object"||typeof n=="function")for(let u of DVt(n))!OVt.call(s,u)&&u!==r&&bPe(s,u,{get:()=>n[u],enumerable:!(c=IVt(n,u))||c.enumerable});return s};var Uut=(s,n,r)=>(r=s!=null?RVt(BVt(s)):{},NVt(n||!s||!s.__esModule?bPe(r,"default",{value:s,enumerable:!0}):r,s));var Wj,$Vt,Vae,VVt,Gut,wPe=Ve(()=>{Wj=globalThis,$Vt=globalThis.document||{},Vae=globalThis.process||{},VVt=globalThis.console,Gut=globalThis.navigator||{}});function Wae(s){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&process.versions?.electron)return!0;let n=typeof navigator<"u"&&navigator.userAgent,r=s||n;return!!(r&&r.indexOf("Electron")>=0)}var vPe=Ve(()=>{});function D1(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Wae()}var _Pe=Ve(()=>{vPe()});function yPe(s){return!s&&!D1()?"Node":Wae(s)?"Electron":(s||Gut.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var jut=Ve(()=>{_Pe();vPe();wPe()});var xPe,VL=Ve(()=>{wPe();_Pe();jut();xPe="4.1.2"});function PD(s,n){if(!s)throw new Error(n||"Assertion failed")}var EPe=Ve(()=>{});function SPe(s){if(!s)return 0;let n;switch(typeof s){case"number":n=s;break;case"object":n=s.logLevel||s.priority||0;break;default:return 0}return PD(Number.isFinite(n)&&n>=0),n}function $ut(s){let{logLevel:n,message:r}=s;s.logLevel=SPe(n);let c=s.args?Array.from(s.args):[];for(;c.length&&c.shift()!==r;);switch(typeof n){case"string":case"function":r!==void 0&&c.unshift(r),s.message=n;break;case"object":Object.assign(s,n);break;default:}typeof s.message=="function"&&(s.message=s.message());let u=typeof s.message;return PD(u==="string"||u==="object"),Object.assign(s,{args:c},s.opts)}var Vut=Ve(()=>{EPe()});var WL,Hae,Wut=Ve(()=>{Vut();WL=()=>{},Hae=class{constructor({level:n=0}={}){this.userData={},this._onceCache=new Set,this._level=n}set level(n){this.setLevel(n)}get level(){return this.getLevel()}setLevel(n){return this._level=n,this}getLevel(){return this._level}warn(n,...r){return this._log("warn",0,n,r,{once:!0})}error(n,...r){return this._log("error",0,n,r)}log(n,r,...c){return this._log("log",n,r,c)}info(n,r,...c){return this._log("info",n,r,c)}once(n,r,...c){return this._log("once",n,r,c,{once:!0})}_log(n,r,c,u,d={}){let b=$ut({logLevel:r,message:c,args:this._buildArgs(r,c,u),opts:d});return this._createLogFunction(n,b,d)}_buildArgs(n,r,c){return[n,r,...c]}_createLogFunction(n,r,c){if(!this._shouldLog(r.logLevel))return WL;let u=this._getOnceTag(c.tag??r.tag??r.message);if((c.once||r.once)&&u!==void 0){if(this._onceCache.has(u))return WL;this._onceCache.add(u)}return this._emit(n,r)}_shouldLog(n){return this.getLevel()>=SPe(n)}_getOnceTag(n){if(n!==void 0)try{return typeof n=="string"?n:String(n)}catch{return}}}});function HVt(s){try{let n=window[s],r="__storage_test__";return n.setItem(r,r),n.removeItem(r),n}catch{return null}}var qae,Hut=Ve(()=>{qae=class{constructor(n,r,c="sessionStorage"){this.storage=HVt(c),this.id=n,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(n){if(Object.assign(this.config,n),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let n={};if(this.storage){let r=this.storage.getItem(this.id);n=r?JSON.parse(r):{}}return Object.assign(this.config,n),this}}});function qut(s){let n;return s<10?n=`${s.toFixed(2)}ms`:s<100?n=`${s.toFixed(1)}ms`:s<1e3?n=`${s.toFixed(0)}ms`:n=`${(s/1e3).toFixed(2)}s`,n}function Xut(s,n=8){let r=Math.max(n-s.length,0);return`${" ".repeat(r)}${s}`}var Yut=Ve(()=>{});function Zut(s){return typeof s!="string"?s:(s=s.toUpperCase(),Xae[s]||Xae.WHITE)}function Kut(s,n,r){return!D1&&typeof s=="string"&&(n&&(s=`\x1B[${Zut(n)}m${s}\x1B[39m`),r&&(s=`\x1B[${Zut(r)+qVt}m${s}\x1B[49m`)),s}var Xae,qVt,Jut=Ve(()=>{VL();(function(s){s[s.BLACK=30]="BLACK",s[s.RED=31]="RED",s[s.GREEN=32]="GREEN",s[s.YELLOW=33]="YELLOW",s[s.BLUE=34]="BLUE",s[s.MAGENTA=35]="MAGENTA",s[s.CYAN=36]="CYAN",s[s.WHITE=37]="WHITE",s[s.BRIGHT_BLACK=90]="BRIGHT_BLACK",s[s.BRIGHT_RED=91]="BRIGHT_RED",s[s.BRIGHT_GREEN=92]="BRIGHT_GREEN",s[s.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",s[s.BRIGHT_BLUE=94]="BRIGHT_BLUE",s[s.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",s[s.BRIGHT_CYAN=96]="BRIGHT_CYAN",s[s.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Xae||(Xae={}));qVt=10});function Qut(s,n=["constructor"]){let r=Object.getPrototypeOf(s),c=Object.getOwnPropertyNames(r),u=s;for(let d of c){let b=u[d];typeof b=="function"&&(n.find(w=>d===w)||(u[d]=b.bind(s)))}}var eft=Ve(()=>{});var Yae,Fy,MPe=Ve(()=>{VL();Yae=class{getHighResolutionTimer(){let n;if(D1()&&Wj.performance)n=Wj?.performance?.now?.();else if("hrtime"in Vae){let r=Vae?.hrtime?.();n=r[0]*1e3+r[1]/1e6}else n=Date.now();return n}getMemoryUsageMB(){let r=Wj?.performance?.memory?.usedJSHeapSize;return r==null?null:Math.trunc(r/1024/1024)}},Fy=new Yae;globalThis.Probe=Yae;globalThis.probe=Fy});function XVt(s,n,r){if(typeof n=="string"){let c=r.time?Xut(qut(r.total)):"";n=r.time?`${s}: ${c} ${n}`:`${s}: ${n}`,n=Kut(n,r.color,r.background)}return n}function YVt(s){for(let n in s)for(let r in s[n])return r||"untitled";return"empty"}var LD,TPe,ig,CPe=Ve(()=>{VL();Wut();Hut();Yut();Jut();eft();EPe();MPe();LD={debug:D1()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},TPe={enabled:!0,level:0},ig=class extends Hae{constructor({id:n}={id:""}){super({level:0}),this.VERSION=xPe,this._startTs=Fy.getHighResolutionTimer(),this._deltaTs=Fy.getHighResolutionTimer(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=n,this.userData={},this._storage=new qae(`__probe-${this.id}__`,{[this.id]:TPe}),this.timeStamp(`${this.id} started`),Qut(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((Fy.getHighResolutionTimer()-this._startTs).toPrecision(10))}getDelta(){return Number((Fy.getHighResolutionTimer()-this._deltaTs).toPrecision(10))}set priority(n){this.level=n}get priority(){return this.level}getPriority(){return this.level}enable(n=!0){return this._updateConfiguration({enabled:n}),this}setLevel(n){return this._updateConfiguration({level:n}),this}get(n){return this._getConfiguration()[n]}set(n,r){this._updateConfiguration({[n]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(n,r){if(!n)throw new Error(r||"Assertion failed")}warn(n,...r){return this._log("warn",0,n,r,{method:LD.warn,once:!0})}error(n,...r){return this._log("error",0,n,r,{method:LD.error})}deprecated(n,r){return this.warn(`\`${n}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(n,r){return this.error(`\`${n}\` has been removed. Use \`${r}\` instead`)}probe(n,r,...c){let u=Fy.getMemoryUsageMB();if(u!==null){let d=`${u}MB `;typeof r=="function"?r=()=>`${d}${r()}`:typeof r=="string"&&(r=`${d}${r}`)}return this._log("log",n,r,c,{method:LD.log,time:!0,once:!0})}log(n,r,...c){return this._log("log",n,r,c,{method:LD.debug})}info(n,r,...c){return this._log("info",n,r,c,{method:console.info})}once(n,r,...c){return this._log("once",n,r,c,{method:LD.debug||LD.info,once:!0})}table(n,r,c){return r?this._log("table",n,r,c&&[c]||[],{method:console.table||WL,tag:YVt(r)}):WL}time(n,r){return this._log("time",n,r,[],{method:console.time?console.time:console.info})}timeEnd(n,r){return this._log("time",n,r,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(n,r){return this._log("time",n,r,[],{method:console.timeStamp||WL})}group(n,r,c={collapsed:!1}){let u=(c.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",n,r,[],{method:u})}groupCollapsed(n,r,c={}){return this.group(n,r,Object.assign({},c,{collapsed:!0}))}groupEnd(n){return this._log("groupEnd",n,"",[],{method:console.groupEnd||WL})}withGroup(n,r,c){this.group(n,r)();try{c()}finally{this.groupEnd(n)()}}trace(){console.trace&&console.trace()}_shouldLog(n){return this.isEnabled()&&super._shouldLog(n)}_emit(n,r){let c=r.method;PD(c),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=Fy.getHighResolutionTimer();let u=XVt(this.id,r.message,r);return c.bind(console,u,...r.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(TPe),this._storage.config[this.id]}_updateConfiguration(n){let r=this._storage.config[this.id]||{...TPe};this._storage.setConfiguration({[this.id]:{...r,...n}})}};ig.VERSION=xPe});var tft=Ve(()=>{MPe();globalThis.probe||(globalThis.probe=Fy)});var jDn,Hj=Ve(()=>{CPe();CPe();tft();jDn=new ig({id:"@probe.gl/log"})});function Zj(){let s;if(typeof window<"u"&&window.performance)s=window.performance.now();else if(typeof process<"u"&&process.hrtime){let n=process.hrtime();s=n[0]*1e3+n[1]/1e6}else s=Date.now();return s}var VPe=Ve(()=>{});var qL,WPe=Ve(()=>{VPe();qL=class{constructor(n,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=n,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(n){return this.sampleSize=n,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(n){return this._count+=n,this._samples++,this._checkSampling(),this}subtractCount(n){return this._count-=n,this._samples++,this._checkSampling(),this}addTime(n){return this._time+=n,this.lastTiming=n,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Zj(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Zj()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}});var xb,pft=Ve(()=>{WPe();xb=class{constructor(n){this.stats={},this.id=n.id,this.stats={},this._initializeStats(n.stats),Object.seal(this)}get(n,r="count"){return this._getOrCreate({name:n,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let n of Object.values(this.stats))n.reset();return this}forEach(n){for(let r of Object.values(this.stats))n(r)}getTable(){let n={};return this.forEach(r=>{n[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),n}_initializeStats(n=[]){n.forEach(r=>this._getOrCreate(r))}_getOrCreate(n){let{name:r,type:c}=n,u=this.stats[r];return u||(n instanceof qL?u=n:u=new qL(r,c),this.stats[r]=u),u}}});var Kj=Ve(()=>{pft();WPe();VPe()});function Vft(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Wft(s){return Array.isArray(s)?s.length===0||typeof s[0]=="number":!1}function r$(s){return Vft(s)||Wft(s)}var Hft=Ve(()=>{});var sLe=Ve(()=>{Hft()});function ND(s){let n=s.split(""),r=0,c=0,u=!1,d=!1,b=!1;for(;r0){if(w==="/"&&_==="*"){n[r]=" ",n[r+1]=" ",c++,r+=2;continue}if(w==="*"&&_==="/"){n[r]=" ",n[r+1]=" ",c--,r+=2;continue}w!==` -`&&w!=="\r"&&(n[r]=" "),r++;continue}if(w==='"'){d=!0,r++;continue}if(w==="/"&&_==="/"){n[r]=" ",n[r+1]=" ",u=!0,r+=2;continue}if(w==="/"&&_==="*"){n[r]=" ",n[r+1]=" ",c=1,r+=2;continue}r++}return n.join("")}function YL(s,n){let r=ND(s),c=[];for(let u of n){u.lastIndex=0;let d;for(d=u.exec(r);d;){let b=u===n[0],w=d.index,_=d[0].length;c.push({match:s.slice(w,w+_),index:w,length:_,bindingToken:d[b?1:2],groupToken:d[b?2:1],accessDeclaration:d[3]?.trim(),name:d[4]}),d=u.exec(r)}}return c.sort((u,d)=>u.index-d.index)}function hLe(s,n,r){let c=YL(s,n);if(!c.length)return s;let u="",d=0;for(let b of c)u+=s.slice(d,b.index),u+=r(b),d=b.index+b.length;return u+=s.slice(d),u}function dLe(s){return/@binding\(\s*auto\s*\)/.test(ND(s))}function aht(s,n){return YL(s,n===OD||n===lce?lHt:n).find(c=>c.bindingToken==="auto")}var N1,Sb,OD,lce,oht,lHt,uce=Ve(()=>{N1="(?:var<\\s*(uniform|storage(?:\\s*,\\s*[A-Za-z_][A-Za-z0-9_]*)?)\\s*>|var)\\s+([A-Za-z_][A-Za-z0-9_]*)",Sb="\\s*",OD=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${Sb}@group\\(\\s*(\\d+)\\s*\\)${Sb}${N1}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${Sb}@binding\\(\\s*(auto|\\d+)\\s*\\)${Sb}${N1}`,"g")],lce=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${Sb}@group\\(\\s*(\\d+)\\s*\\)${Sb}${N1}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${Sb}@binding\\(\\s*(auto|\\d+)\\s*\\)${Sb}${N1}`,"g")],oht=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)${Sb}@group\\(\\s*(\\d+)\\s*\\)${Sb}${N1}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${Sb}@binding\\(\\s*(\\d+)\\s*\\)${Sb}${N1}`,"g")],lHt=[new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${N1}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)\\s*${N1}`,"g"),new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${N1}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${N1}`,"g")]});function hce(s,n={}){let r=cht(s),c=uHt(r);if(!c)return null;let u=fHt(r,c);if(!u)return null;let d=dHt(r,c,u);if(!d)return null;if(n.scanVertexAttributes===!1)return{attributes:[],bindings:d};let b=hHt(r,c);if(!b)return null;let w=wHt(r,c,u,b,n.vertexEntryPoint);return w?{attributes:w,bindings:d}:null}function cht(s){let n=ND(s),r=/[A-Za-z_][A-Za-z0-9_]*|(?:0[xX][0-9A-Fa-f]+|\d+)|[@(){}<>\[\]:,;=]/g,c=[],u=r.exec(n);for(;u;)c.push({value:u[0],index:u.index}),u=r.exec(n);return c}function uHt(s){let n=[],r=0;for(let c of s){if(c.value==="}"&&r===0)return null;n.push(r),c.value==="{"?r++:c.value==="}"&&r--}return r===0?n:null}function fHt(s,n){let r=new Map;for(let c=0;c");if(Z<0)return null;let H=dce(s.slice(M+1,Z),",");if(!H)return null;L=H.map(fce),M=Z+1}let I=s[M]?.value;if(!a$(I)||s[M+1]?.value!==":")return null;let D=fht(s,n,M+2,";");if(D<0||D===M+2)return null;let F=mLe(fce(s.slice(M+2,D)),r);if(!F)return null;let O=pHt({name:I,group:x,location:T,addressSpace:L,resourceType:F}),z=`${x}:${T}`;if(!O||u.has(z)||d.has(I))return null;c.push(O),u.add(z),d.add(I),b=D}return bHt(c),c.sort((b,w)=>b.group-w.group||b.location-w.location||b.name.localeCompare(w.name))}function pHt(s){let{name:n,group:r,location:c,addressSpace:u,resourceType:d}=s,b={name:n,group:r,location:c};if(u[0]==="uniform"&&u.length===1)return{...b,type:"uniform"};if(u[0]==="storage"&&u.length<=2){let w=u[1]||"read";return w==="read"?{...b,type:"read-only-storage"}:w==="read_write"?{...b,type:"storage"}:null}return u.length>0?null:d==="sampler"||d==="sampler_comparison"?{...b,type:"sampler",...d==="sampler_comparison"?{samplerType:"comparison"}:{}}:d==="texture_external"?{...b,type:"external-texture"}:gHt(b,d)||mHt(b,d)}function gHt(s,n){let r=/^texture_storage_(1d|2d|2d_array|3d)<([A-Za-z0-9_]+),(read|write|read_write)>$/.exec(n);if(!r)return null;let c={read:"read-only",write:"write-only",read_write:"read-write"}[r[3]];return{...s,type:"storage",format:r[2],access:c,viewDimension:gLe(r[1])}}function mHt(s,n){let r=/^texture_(multisampled_)?(1d|2d|2d_array|cube|cube_array|3d)<(f32|i32|u32)>$/.exec(n);if(r){if(r[1]&&r[2]!=="2d")return null;let u={f32:"float",i32:"sint",u32:"uint"}[r[3]];return{...s,type:"texture",viewDimension:gLe(r[2]),sampleType:u,multisampled:!!r[1]}}let c=/^texture_depth_(multisampled_)?(2d|2d_array|cube|cube_array)$/.exec(n);return!c||c[1]&&c[2]!=="2d"?null:{...s,type:"texture",viewDimension:gLe(c[2]),sampleType:"depth",multisampled:!!c[1]}}function bHt(s){for(let n of s){if(n.type!=="sampler"||n.samplerType||!n.name.endsWith("Sampler"))continue;let r=n.name.slice(0,-7);s.find(u=>u.type==="texture"&&u.name===r&&u.group===n.group)?.sampleType==="depth"&&(n.samplerType="non-filtering")}}function wHt(s,n,r,c,u){let d=vHt(s,n);if(!d)return null;let b=d.filter(I=>I.vertex),w=u?b.find(I=>I.name===u):b.length===1?b[0]:void 0;if(!w)return b.length===0&&!u?[]:null;let _=dce(w.parameters,",");if(!_)return null;let x=[],T=new Set,M=new Set,L=new Set;for(let I of _)if(I.length>0&&!lht({declaration:I,aliases:r,structures:c,attributes:x,attributeLocations:T,attributeNames:M,visitedStructures:L}))return null;return x.sort((I,D)=>I.location-D.location||I.name.localeCompare(D.name))}function vHt(s,n){let r=[],c=new Set;for(let u=0;u0&&!lht({...s,declaration:F}))return!1;return w.delete(L),!0}function mLe(s,n,r=new Set){let c=cht(s),u="";for(let d of c){let b=n.get(d.value);if(!b){u+=_Ht(d.value);continue}if(r.has(d.value))return null;let w=new Set(r);w.add(d.value);let _=mLe(b,n,w);if(!_)return null;u+=_}return u}function _Ht(s){let n=/^(vec[234]|mat[234]x[234])([fiuh])$/.exec(s);if(!n)return s;let r={f:"f32",i:"i32",u:"u32",h:"f16"}[n[2]];return`${n[1]}<${r}>`}function yHt(s){return/^(?:i32|u32|f32|f16|vec[234]<(?:i32|u32|f32|f16)>)$/.test(s)?s:null}function pLe(s,n){let r;for(let c=0;cr.value==="@"&&s[c+1]?.value===n)}function gLe(s){return s.replace("_","-")}function bLe(s,n,r,c){let u=0;for(let d=n;d":"<","]":"[","}":"{"};for(let w=0;wu[x]===0)){r.push(s.slice(c,w)),c=w+1;continue}if(_ in u)u[_]++;else if(_ in b){let x=b[_];if(u[x]--,u[x]<0)return null}}return d.every(w=>u[w]===0)?(r.push(s.slice(c)),r):null}function xHt(s,n){let r=dce(s,n);return r&&r.length===2?r[0].length:-1}function fht(s,n,r,c){for(let u=r;u=0;c--)if(s[c].value===";"&&n[c]===0||s[c].value==="}"&&n[c]===1)return c+1;return 0}function EHt(s){for(let n=s.length-1;n>=0;n--)if(a$(s[n].value))return s[n].value;return null}function fce(s){return s.map(n=>n.value).join("")}function a$(s){return!!(s&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(s))}var wLe=Ve(()=>{uce()});function C3(s,n){if(!s){let r=new Error(n||"shadertools: assertion failed.");throw Error.captureStackTrace?.(r,C3),r}}var pce=Ve(()=>{});function pht(s){let n={};for(let[r,c]of Object.entries(s))n[r]=SHt(c);return n}function SHt(s){let n=dht(s);if(n!=="object")return{value:s,...vLe[n],type:n};if(typeof s=="object")return s?s.type!==void 0?{...s,...vLe[s.type],type:s.type}:s.value===void 0?{type:"object",value:s}:(n=dht(s.value),{...s,...vLe[n],type:n}):{type:"object",value:null};throw new Error("props")}function dht(s){return Array.isArray(s)||ArrayBuffer.isView(s)?"array":typeof s}var vLe,ght=Ve(()=>{vLe={number:{type:"number",validate(s,n){return Number.isFinite(s)&&typeof n=="object"&&(n.max===void 0||s<=n.max)&&(n.min===void 0||s>=n.min)}},array:{type:"array",validate(s,n){return Array.isArray(s)||ArrayBuffer.isView(s)}}}});var mht,bht,wht=Ve(()=>{mht=`#ifdef MODULE_LOGDEPTH +`&&w!=="\r"&&(n[r]=" "),r++;continue}if(w==='"'){d=!0,r++;continue}if(w==="/"&&_==="/"){n[r]=" ",n[r+1]=" ",u=!0,r+=2;continue}if(w==="/"&&_==="*"){n[r]=" ",n[r+1]=" ",c=1,r+=2;continue}r++}return n.join("")}function YL(s,n){let r=ND(s),c=[];for(let u of n){u.lastIndex=0;let d;for(d=u.exec(r);d;){let b=u===n[0],w=d.index,_=d[0].length;c.push({match:s.slice(w,w+_),index:w,length:_,bindingToken:d[b?1:2],groupToken:d[b?2:1],accessDeclaration:d[3]?.trim(),name:d[4]}),d=u.exec(r)}}return c.sort((u,d)=>u.index-d.index)}function hLe(s,n,r){let c=YL(s,n);if(!c.length)return s;let u="",d=0;for(let b of c)u+=s.slice(d,b.index),u+=r(b),d=b.index+b.length;return u+=s.slice(d),u}function dLe(s){return/@binding\(\s*auto\s*\)/.test(ND(s))}function aht(s,n){return YL(s,n===OD||n===lce?hHt:n).find(c=>c.bindingToken==="auto")}var N1,Eb,OD,lce,oht,hHt,uce=Ve(()=>{N1="(?:var<\\s*(uniform|storage(?:\\s*,\\s*[A-Za-z_][A-Za-z0-9_]*)?)\\s*>|var)\\s+([A-Za-z_][A-Za-z0-9_]*)",Eb="\\s*",OD=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${Eb}@group\\(\\s*(\\d+)\\s*\\)${Eb}${N1}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${Eb}@binding\\(\\s*(auto|\\d+)\\s*\\)${Eb}${N1}`,"g")],lce=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${Eb}@group\\(\\s*(\\d+)\\s*\\)${Eb}${N1}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${Eb}@binding\\(\\s*(auto|\\d+)\\s*\\)${Eb}${N1}`,"g")],oht=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)${Eb}@group\\(\\s*(\\d+)\\s*\\)${Eb}${N1}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${Eb}@binding\\(\\s*(\\d+)\\s*\\)${Eb}${N1}`,"g")],hHt=[new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${N1}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)\\s*${N1}`,"g"),new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${N1}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${N1}`,"g")]});function hce(s,n={}){let r=cht(s),c=dHt(r);if(!c)return null;let u=pHt(r,c);if(!u)return null;let d=mHt(r,c,u);if(!d)return null;if(n.scanVertexAttributes===!1)return{attributes:[],bindings:d};let b=gHt(r,c);if(!b)return null;let w=yHt(r,c,u,b,n.vertexEntryPoint);return w?{attributes:w,bindings:d}:null}function cht(s){let n=ND(s),r=/[A-Za-z_][A-Za-z0-9_]*|(?:0[xX][0-9A-Fa-f]+|\d+)|[@(){}<>\[\]:,;=]/g,c=[],u=r.exec(n);for(;u;)c.push({value:u[0],index:u.index}),u=r.exec(n);return c}function dHt(s){let n=[],r=0;for(let c of s){if(c.value==="}"&&r===0)return null;n.push(r),c.value==="{"?r++:c.value==="}"&&r--}return r===0?n:null}function pHt(s,n){let r=new Map;for(let c=0;c");if(Z<0)return null;let H=dce(s.slice(M+1,Z),",");if(!H)return null;L=H.map(fce),M=Z+1}let I=s[M]?.value;if(!a$(I)||s[M+1]?.value!==":")return null;let D=fht(s,n,M+2,";");if(D<0||D===M+2)return null;let F=mLe(fce(s.slice(M+2,D)),r);if(!F)return null;let O=bHt({name:I,group:x,location:T,addressSpace:L,resourceType:F}),z=`${x}:${T}`;if(!O||u.has(z)||d.has(I))return null;c.push(O),u.add(z),d.add(I),b=D}return _Ht(c),c.sort((b,w)=>b.group-w.group||b.location-w.location||b.name.localeCompare(w.name))}function bHt(s){let{name:n,group:r,location:c,addressSpace:u,resourceType:d}=s,b={name:n,group:r,location:c};if(u[0]==="uniform"&&u.length===1)return{...b,type:"uniform"};if(u[0]==="storage"&&u.length<=2){let w=u[1]||"read";return w==="read"?{...b,type:"read-only-storage"}:w==="read_write"?{...b,type:"storage"}:null}return u.length>0?null:d==="sampler"||d==="sampler_comparison"?{...b,type:"sampler",...d==="sampler_comparison"?{samplerType:"comparison"}:{}}:d==="texture_external"?{...b,type:"external-texture"}:wHt(b,d)||vHt(b,d)}function wHt(s,n){let r=/^texture_storage_(1d|2d|2d_array|3d)<([A-Za-z0-9_]+),(read|write|read_write)>$/.exec(n);if(!r)return null;let c={read:"read-only",write:"write-only",read_write:"read-write"}[r[3]];return{...s,type:"storage",format:r[2],access:c,viewDimension:gLe(r[1])}}function vHt(s,n){let r=/^texture_(multisampled_)?(1d|2d|2d_array|cube|cube_array|3d)<(f32|i32|u32)>$/.exec(n);if(r){if(r[1]&&r[2]!=="2d")return null;let u={f32:"float",i32:"sint",u32:"uint"}[r[3]];return{...s,type:"texture",viewDimension:gLe(r[2]),sampleType:u,multisampled:!!r[1]}}let c=/^texture_depth_(multisampled_)?(2d|2d_array|cube|cube_array)$/.exec(n);return!c||c[1]&&c[2]!=="2d"?null:{...s,type:"texture",viewDimension:gLe(c[2]),sampleType:"depth",multisampled:!!c[1]}}function _Ht(s){for(let n of s){if(n.type!=="sampler"||n.samplerType||!n.name.endsWith("Sampler"))continue;let r=n.name.slice(0,-7);s.find(u=>u.type==="texture"&&u.name===r&&u.group===n.group)?.sampleType==="depth"&&(n.samplerType="non-filtering")}}function yHt(s,n,r,c,u){let d=xHt(s,n);if(!d)return null;let b=d.filter(I=>I.vertex),w=u?b.find(I=>I.name===u):b.length===1?b[0]:void 0;if(!w)return b.length===0&&!u?[]:null;let _=dce(w.parameters,",");if(!_)return null;let x=[],T=new Set,M=new Set,L=new Set;for(let I of _)if(I.length>0&&!lht({declaration:I,aliases:r,structures:c,attributes:x,attributeLocations:T,attributeNames:M,visitedStructures:L}))return null;return x.sort((I,D)=>I.location-D.location||I.name.localeCompare(D.name))}function xHt(s,n){let r=[],c=new Set;for(let u=0;u0&&!lht({...s,declaration:F}))return!1;return w.delete(L),!0}function mLe(s,n,r=new Set){let c=cht(s),u="";for(let d of c){let b=n.get(d.value);if(!b){u+=EHt(d.value);continue}if(r.has(d.value))return null;let w=new Set(r);w.add(d.value);let _=mLe(b,n,w);if(!_)return null;u+=_}return u}function EHt(s){let n=/^(vec[234]|mat[234]x[234])([fiuh])$/.exec(s);if(!n)return s;let r={f:"f32",i:"i32",u:"u32",h:"f16"}[n[2]];return`${n[1]}<${r}>`}function SHt(s){return/^(?:i32|u32|f32|f16|vec[234]<(?:i32|u32|f32|f16)>)$/.test(s)?s:null}function pLe(s,n){let r;for(let c=0;cr.value==="@"&&s[c+1]?.value===n)}function gLe(s){return s.replace("_","-")}function bLe(s,n,r,c){let u=0;for(let d=n;d":"<","]":"[","}":"{"};for(let w=0;wu[x]===0)){r.push(s.slice(c,w)),c=w+1;continue}if(_ in u)u[_]++;else if(_ in b){let x=b[_];if(u[x]--,u[x]<0)return null}}return d.every(w=>u[w]===0)?(r.push(s.slice(c)),r):null}function MHt(s,n){let r=dce(s,n);return r&&r.length===2?r[0].length:-1}function fht(s,n,r,c){for(let u=r;u=0;c--)if(s[c].value===";"&&n[c]===0||s[c].value==="}"&&n[c]===1)return c+1;return 0}function THt(s){for(let n=s.length-1;n>=0;n--)if(a$(s[n].value))return s[n].value;return null}function fce(s){return s.map(n=>n.value).join("")}function a$(s){return!!(s&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(s))}var wLe=Ve(()=>{uce()});function C3(s,n){if(!s){let r=new Error(n||"shadertools: assertion failed.");throw Error.captureStackTrace?.(r,C3),r}}var pce=Ve(()=>{});function pht(s){let n={};for(let[r,c]of Object.entries(s))n[r]=CHt(c);return n}function CHt(s){let n=dht(s);if(n!=="object")return{value:s,...vLe[n],type:n};if(typeof s=="object")return s?s.type!==void 0?{...s,...vLe[s.type],type:s.type}:s.value===void 0?{type:"object",value:s}:(n=dht(s.value),{...s,...vLe[n],type:n}):{type:"object",value:null};throw new Error("props")}function dht(s){return Array.isArray(s)||ArrayBuffer.isView(s)?"array":typeof s}var vLe,ght=Ve(()=>{vLe={number:{type:"number",validate(s,n){return Number.isFinite(s)&&typeof n=="object"&&(n.max===void 0||s<=n.max)&&(n.min===void 0||s>=n.min)}},array:{type:"array",validate(s,n){return Array.isArray(s)||ArrayBuffer.isView(s)}}}});var mht,bht,wht=Ve(()=>{mht=`#ifdef MODULE_LOGDEPTH logdepth_adjustPosition(gl_Position); #endif `,bht=`#ifdef MODULE_MATERIAL @@ -23,22 +23,22 @@ #ifdef MODULE_LOGDEPTH logdepth_setFragDepth(); #endif -`});function yht(s){let n={vertex:{},fragment:{}};for(let r in s){let c=s[r],u=THt(r);typeof c=="string"&&(c={order:0,injection:c}),n[u][r]=c}return n}function THt(s){let n=s.slice(0,2);switch(n){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(n)}}function l$(s,n,r,c=!1,u="glsl",d={}){let b=n==="vertex";for(let w in r){let _=r[w];_.sort((T,M)=>T.order-M.order),_Le.length=_.length;for(let T=0,M=_.length;TT.order-M.order),_Le.length=_.length;for(let T=0,M=_.length;TT+x));break;case"vs:#main-end":(u==="wgsl"||b)&&(s=u==="wgsl"?gce(s,"vertex",x,"end",d.vertex):s.replace(_ht,T=>x+T));break;case"fs:#decl":(u==="wgsl"||!b)&&(s=s.replace(c$,x));break;case"fs:#main-start":(u==="wgsl"||!b)&&(s=u==="wgsl"?gce(s,"fragment",x,"start",d.fragment):s.replace(vht,T=>T+x));break;case"fs:#main-end":(u==="wgsl"||!b)&&(s=u==="wgsl"?gce(s,"fragment",x,"end",d.fragment):s.replace(_ht,T=>x+T));break;default:s=s.replace(w,T=>T+x)}}return s=s.replace(c$,""),c&&(s=s.replace(/\}\s*$/,w=>w+MHt[n])),s}function gce(s,n,r,c,u){let d=CHt(s,n,u);if(!d)return s;if(c==="start"){let b=d.openBraceIndex+1;return`${s.slice(0,b)} -${r}${s.slice(b)}`}return`${s.slice(0,d.closeBraceIndex)}${r}${s.slice(d.closeBraceIndex)}`}function CHt(s,n,r){let c=n==="vertex"?"@vertex":"@fragment",u=s.indexOf(c);if(u<0)return null;let d=r?s.search(new RegExp(`\\bfn\\s+${AHt(r)}\\s*\\(`)):s.indexOf("fn",u);if(d<0)return null;let b=s.indexOf("{",d);if(b<0)return null;let w=0;for(let _=b;_{wht();MHt={vertex:mht,fragment:bht},vht=/void\s+main\s*\([^)]*\)\s*\{\n?/,_ht=/}\n?[^{}]*$/,_Le=[],c$="__LUMA_INJECT_DECLARATIONS__"});function FD(s){s.map(n=>PHt(n))}function PHt(s){if(s.instance)return;FD(s.dependencies||[]);let{propTypes:n={},deprecations:r=[],inject:c={}}=s,u={normalizedInjections:yht(c),parsedDeprecations:LHt(r)};n&&(u.propValidators=pht(n)),s.instance=u;let d={};n&&(d=Object.entries(n).reduce((b,[w,_])=>{let x=_?.value;return x&&(b[w]=x),b},{})),s.defaultUniforms={...s.defaultUniforms,...d}}function xLe(s,n,r){s.deprecations?.forEach(c=>{c.regex?.test(n)&&(c.deprecated?r.deprecated(c.old,c.new)():r.removed(c.old,c.new)())})}function LHt(s){return s.forEach(n=>{switch(n.type){case"function":n.regex=new RegExp(`\\b${n.old}\\(`);break;default:n.regex=new RegExp(`${n.type} ${n.old};`)}}),s}var mce=Ve(()=>{ght();yLe()});function ZL(s){FD(s);let n={},r={};xht({modules:s,level:0,moduleMap:n,moduleDepth:r});let c=Object.keys(r).sort((u,d)=>r[d]-r[u]).map(u=>n[u]);return FD(c),c}function xht(s){let{modules:n,level:r,moduleMap:c,moduleDepth:u}=s;if(r>=5)throw new Error("Possible loop in shader dependency graph");for(let d of n)c[d.name]=d,(u[d.name]===void 0||u[d.name]{mce()});var Qt,sg=Ve(()=>{Hj();Qt=new ig({id:"luma.gl"})});function kHt(s,n){return s!=null?!!s:n!==void 0?n!=="production":!1}function RHt(){return kHt(Qt.get("debug"),IHt())}function IHt(){let s=globalThis.process;if(s?.env)return s.env.NODE_ENV}var bce,SLe=Ve(()=>{sg();bce={id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,featureLevel:void 0,optionalFeatures:[],xrCompatible:!1,createCanvasContext:void 0,webgl:{},onError:(s,n)=>{},onResize:(s,n)=>{let[r,c]=s.getDevicePixelSize();Qt.log(1,`${s} resized => ${r}x${c}px`)()},onPositionChange:(s,n)=>{let[r,c]=s.getPosition();Qt.log(1,`${s} repositioned => ${r},${c}`)()},onVisibilityChange:s=>Qt.log(1,`${s} Visibility changed ${s.isVisible}`)(),onDevicePixelRatioChange:(s,n)=>Qt.log(1,`${s} DPR changed ${n.oldRatio} => ${s.devicePixelRatio}`)(),debug:RHt(),debugGPUTime:!1,debugShaders:Qt.get("debug-shaders")||void 0,debugFramebuffers:!!Qt.get("debug-framebuffers"),debugFactories:!!Qt.get("debug-factories"),debugWebGL:!!Qt.get("debug-webgl"),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0}});function OHt(s,n){let r=s.stats,c=!1;for(let _ of n)r[_]||(s.get(_),c=!0);let u=Object.keys(r).length,d=Eht.get(s);if(!c&&d?.orderedStatNames===n&&d.statCount===u)return;let b={},w=Sht.get(n);w||(w=new Set(n),Sht.set(n,w));for(let _ of n)r[_]&&(b[_]=r[_]);for(let[_,x]of Object.entries(r))w.has(_)||(b[_]=x);for(let _ of Object.keys(r))delete r[_];Object.assign(r,b),Eht.set(s,{orderedStatNames:n,statCount:u})}var DHt,BHt,Eht,Sht,MLe,wce,TLe=Ve(()=>{Kj();DHt="GPU Time and Memory",BHt=["Adapter","GPU","GPU Type","GPU Backend","Frame Rate","CPU Time","GPU Time","GPU Memory","Buffer Memory","Texture Memory","External Buffer Memory","External Texture Memory","Swap Chain Texture"],Eht=new WeakMap,Sht=new WeakMap,MLe=class{stats=new Map;getStats(n){return this.get(n)}get(n){this.stats.has(n)||this.stats.set(n,new Eb({id:n}));let r=this.stats.get(n);return n===DHt&&OHt(r,BHt),r}},wce=new MLe});var NHt,Mht,CLe,UD,Tht=Ve(()=>{SLe();TLe();sg();NHt="set luma.log.level=1 (or higher) to trace rendering",Mht="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",CLe=class s{static defaultProps={...bce,type:"best-available",adapters:void 0,waitForPageLoad:!0};stats=wce;log=Qt;VERSION="9.4.2";spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw Qt.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),Qt.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");Qt.error("This version of luma.gl has already been initialized")()}Qt.log(1,`${this.VERSION} - ${NHt}`)(),globalThis.luma=this}async createDevice(n={}){let r={...s.defaultProps,...n},c=this.selectAdapter(r.type,r.adapters);if(!c)throw new Error(Mht);return r.waitForPageLoad&&await c.pageLoaded,await c.create(r)}async attachDevice(n,r){let c=this._getTypeFromHandle(n,r.adapters),u=c&&this.selectAdapter(c,r.adapters);if(!u)throw new Error(Mht);return await u?.attach?.(n,r)}registerAdapters(n){for(let r of n)this.preregisteredAdapters.set(r.type,r)}getSupportedAdapters(n=[]){let r=this._getAdapterMap(n);return Array.from(r).map(([,c])=>c).filter(c=>c.isSupported?.()).map(c=>c.type)}getBestAvailableAdapterType(n=[]){let r=["webgpu","webgl","null"],c=this._getAdapterMap(n);for(let u of r)if(c.get(u)?.isSupported?.())return u;return null}selectAdapter(n,r=[]){let c=n;n==="best-available"&&(c=this.getBestAvailableAdapterType(r));let u=this._getAdapterMap(r);return c&&u.get(c)||null}enforceWebGL2(n=!0,r=[]){let u=this._getAdapterMap(r).get("webgl");u||Qt.warn("enforceWebGL2: webgl adapter not found")(),u?.enforceWebGL2?.(n)}setDefaultDeviceProps(n){Object.assign(s.defaultProps,n)}_getAdapterMap(n=[]){let r=new Map(this.preregisteredAdapters);for(let c of n)r.set(c.type,c);return r}_getTypeFromHandle(n,r=[]){return n instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&n instanceof GPUDevice||n?.queue?"webgpu":n===null?"null":(n instanceof WebGLRenderingContext?Qt.warn("WebGL1 is not supported",n)():Qt.warn("Unknown handle type",n)(),null)}},UD=new CLe});function zHt(){return vce||(UHt()||typeof window>"u"?vce=Promise.resolve():vce=new Promise(s=>window.addEventListener("load",()=>s()))),vce}var u$,FHt,UHt,vce,Cht=Ve(()=>{VL();u$=class{get pageLoaded(){return zHt()}},FHt=D1()&&typeof document<"u",UHt=()=>FHt&&document.readyState==="complete",vce=null});function $y(s="id"){ALe[s]=ALe[s]||1;let n=ALe[s]++;return`${s}-${n}`}var ALe,zD=Ve(()=>{ALe={}});function HHt(s,n){let r={...n};for(let c in s)s[c]!==void 0&&(r[c]=s[c]);return r}function Iht(s,n){let r=s.stats,c=!1;for(let _ of n)r[_]||(s.get(_),c=!0);let u=Object.keys(r).length,d=kht.get(s);if(!c&&d?.orderedStatNames===n&&d.statCount===u)return;let b={},w=Rht.get(n);w||(w=new Set(n),Rht.set(n,w));for(let _ of n)r[_]&&(b[_]=r[_]);for(let[_,x]of Object.entries(r))w.has(_)||(b[_]=x);for(let _ of Object.keys(r))delete r[_];Object.assign(r,b),kht.set(s,{orderedStatNames:n,statCount:u})}function Dht(s){return s.type==="webgl"?WHt:VHt}function f$(s){let n=s.userData[GHt];return n?.enabled?n:null}function OM(){return globalThis.performance?.now?.()??Date.now()}function qHt(s,n){let r=f$(s);if(!(!r||!r.activeDefaultFramebufferAcquireDepth))switch(r.transientCanvasResourceCreates=(r.transientCanvasResourceCreates||0)+1,n){case"Texture":r.transientCanvasTextureCreates=(r.transientCanvasTextureCreates||0)+1;break;case"TextureView":r.transientCanvasTextureViewCreates=(r.transientCanvasTextureViewCreates||0)+1;break;case"Sampler":r.transientCanvasSamplerCreates=(r.transientCanvasSamplerCreates||0)+1;break;case"Framebuffer":r.transientCanvasFramebufferCreates=(r.transientCanvasFramebufferCreates||0)+1;break;default:break}}function XHt(s){let n=Object.getPrototypeOf(s);for(;n;){let r=Object.getPrototypeOf(n);if(!r||r===is.prototype)return YHt(n)||s[Symbol.toStringTag]||s.constructor.name;n=r}return s[Symbol.toStringTag]||s.constructor.name}function YHt(s){let n=Object.getOwnPropertyDescriptor(s,Symbol.toStringTag);return typeof n?.get=="function"?n.get.call(s):typeof n?.value=="string"?n.value:null}var GHt,Aht,Pht,Lht,jHt,$Ht,VHt,WHt,kht,Rht,is,Gh=Ve(()=>{zD();GHt="cpu-hotspot-profiler",Aht="GPU Resource Counts",Pht="Resource Counts",Lht="GPU Time and Memory",jHt=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","RenderBundleEncoders","RenderBundles","ComputePasss","CommandEncoders","CommandBuffers"],$Ht=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","SharedRenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","RenderBundleEncoders","RenderBundles","ComputePasss","CommandEncoders","CommandBuffers"],VHt=jHt.flatMap(s=>[`${s} Created`,`${s} Active`]),WHt=$Ht.flatMap(s=>[`${s} Created`,`${s} Active`]),kht=new WeakMap,Rht=new WeakMap,is=class{static defaultProps={id:"undefined",handle:void 0,_isHandleBorrowed:!1,userData:void 0};toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}toJSON(){return this.toString()}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;allocatedBytesName=null;_attachedResources=new Set;get ownsHandle(){return(this.props.handle===void 0||this.props.handle===null)&&!this.isHandleBorrowed}get isHandleBorrowed(){return!!this.props._isHandleBorrowed}constructor(n,r,c){if(!n)throw new Error("no device");this._device=n,this.props=HHt(r,c);let u=this.props.id!=="undefined"?this.props.id:$y(this[Symbol.toStringTag]);this.props.id=u,this.id=u,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyed||this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(n){this._attachedResources.add(n)}detachResource(n){this._attachedResources.delete(n)}destroyAttachedResource(n){this._attachedResources.delete(n)&&n.destroy()}destroyAttachedResources(){for(let n of this._attachedResources)n.destroy();this._attachedResources=new Set}destroyResource(){this.destroyed||(this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0)}removeStats(){let n=f$(this._device),r=n?OM():0,c=[this._device.statsManager.getStats(Aht),this._device.statsManager.getStats(Pht)],u=Dht(this._device);for(let b of c)Iht(b,u);let d=this.getStatsName();for(let b of c)b.get("Resources Active").decrementCount(),b.get(`${d}s Active`).decrementCount();n&&(n.statsBookkeepingCalls=(n.statsBookkeepingCalls||0)+1,n.statsBookkeepingTimeMs=(n.statsBookkeepingTimeMs||0)+(OM()-r))}trackAllocatedMemory(n,r=this.getStatsName()){let c=f$(this._device),u=c?OM():0,d=this._device.statsManager.getStats(Lht);this.allocatedBytes>0&&this.allocatedBytesName&&(d.get("GPU Memory").subtractCount(this.allocatedBytes),d.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes)),d.get("GPU Memory").addCount(n),d.get(`${r} Memory`).addCount(n),c&&(c.statsBookkeepingCalls=(c.statsBookkeepingCalls||0)+1,c.statsBookkeepingTimeMs=(c.statsBookkeepingTimeMs||0)+(OM()-u)),this.allocatedBytes=n,this.allocatedBytesName=r}trackReferencedMemory(n,r=this.getStatsName()){this.trackAllocatedMemory(n,`External ${r}`)}trackDeallocatedMemory(n=this.getStatsName()){if(this.allocatedBytes===0){this.allocatedBytesName=null;return}let r=f$(this._device),c=r?OM():0,u=this._device.statsManager.getStats(Lht);u.get("GPU Memory").subtractCount(this.allocatedBytes),u.get(`${this.allocatedBytesName||n} Memory`).subtractCount(this.allocatedBytes),r&&(r.statsBookkeepingCalls=(r.statsBookkeepingCalls||0)+1,r.statsBookkeepingTimeMs=(r.statsBookkeepingTimeMs||0)+(OM()-c)),this.allocatedBytes=0,this.allocatedBytesName=null}trackDeallocatedReferencedMemory(n=this.getStatsName()){this.trackDeallocatedMemory(`Referenced ${n}`)}addStats(){let n=this.getStatsName(),r=f$(this._device),c=r?OM():0,u=[this._device.statsManager.getStats(Aht),this._device.statsManager.getStats(Pht)],d=Dht(this._device);for(let b of u)Iht(b,d);for(let b of u)b.get("Resources Created").incrementCount(),b.get("Resources Active").incrementCount(),b.get(`${n}s Created`).incrementCount(),b.get(`${n}s Active`).incrementCount();r&&(r.statsBookkeepingCalls=(r.statsBookkeepingCalls||0)+1,r.statsBookkeepingTimeMs=(r.statsBookkeepingTimeMs||0)+(OM()-c)),qHt(this._device,n)}getStatsName(){return XHt(this)}}});var cs,_ce=Ve(()=>{Gh();cs=class s extends is{static INDEX=16;static VERTEX=32;static UNIFORM=64;static STORAGE=128;static INDIRECT=256;static QUERY_RESOLVE=512;static MAP_READ=1;static MAP_WRITE=2;static COPY_SRC=4;static COPY_DST=8;get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(n,r){let c={...r};(r.usage||0)&s.INDEX&&!r.indexType&&(r.data instanceof Uint32Array?c.indexType="uint32":r.data instanceof Uint16Array?c.indexType="uint16":r.data instanceof Uint8Array&&(c.indexType="uint8")),delete c.data,super(n,c,s.defaultProps),this.usage=c.usage||0,this.indexType=c.indexType,this.updateTimestamp=n.incrementTimestamp()}clone(n){return this.device.createBuffer({...this.props,...n})}static DEBUG_DATA_MAX_LENGTH=32;debugData=new ArrayBuffer(0);_setDebugData(n,r,c){if(!this.device.props.debug)return;let u=null,d;ArrayBuffer.isView(n)?(u=n,d=n.buffer):d=n;let b=Math.min(n?n.byteLength:c,s.DEBUG_DATA_MAX_LENGTH);if(d===null)this.debugData=new ArrayBuffer(b);else{let w=Math.min(u?.byteOffset||0,d.byteLength),_=Math.max(0,d.byteLength-w),x=Math.min(b,_);this.debugData=new Uint8Array(d,w,x).slice().buffer}}static defaultProps={...is.defaultProps,handle:void 0,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0}}});function Bht(){return PLe??Uint16Array}function Oht(s){return!!(PLe&&s===PLe)}var PLe,Nht=Ve(()=>{PLe=globalThis.Float16Array});function Fht(s){let n=s.includes("norm"),r=!n&&!s.startsWith("float"),c=s.startsWith("s"),u=LLe[s],[d,b,w]=u||["uint8 ","i32",1];return{signedType:d,primitiveType:b,byteLength:w,normalized:n,integer:r,signed:c}}function Uht(s){let n=s;switch(n){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return n}}function Mb(s,n){switch(n){case 1:return s;case 2:return s+s%2;default:return s+(4-s%4)%4}}function yce(s){let n=ArrayBuffer.isView(s)?s.constructor:s;if(Oht(n))return"float16";if(n===Uint8ClampedArray)return"uint8";let r=Object.values(LLe).find(c=>n===c[4]);if(!r)throw new Error(n.name);return r[0]}function zht(s){return yce(s)}function KL(s){if(s==="float16")return Bht();let n=LLe[s];if(!n)throw new Error(s);let[,,,,r]=n;return r}function JL(s){return KL(s)}var LLe,xce=Ve(()=>{Nht();LLe={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]}});var kLe,Md,Ece=Ve(()=>{xce();kLe=class{getDataTypeInfo(n){return Fht(n)}getNormalizedDataType(n){return Uht(n)}alignTo(n,r){return Mb(n,r)}getDataType(n){return zht(n)}getTypedArrayConstructor(n){return JL(n)}},Md=new kLe});function ZHt(s,n){try{return Md.getDataTypeInfo(n)}catch{throw new Error(`Unsupported vertex format: ${s}`)}}function KHt(s,n){if(!n)return 1;let r=Number(n);if(r===2||r===3||r===4)return r;throw new Error(`Unsupported vertex format: ${s}`)}function JHt(s,n,r){if(r!==3)throw new Error(`Unsupported vertex format: ${s}`);switch(n){case"uint8":case"sint8":case"unorm8":case"snorm8":case"uint16":case"sint16":case"unorm16":case"snorm16":return`${n}x3-webgl`;default:throw new Error(`Unsupported vertex format: ${s}`)}}var RLe,hl,h$=Ve(()=>{Ece();RLe=class{getVertexFormatInfo(n){if(n==="unorm10-10-10-2")return{type:"unorm8",components:4,byteLength:4,integer:!1,signed:!1,normalized:!0};let r=n==="unorm8x4-bgra"?"unorm8x4":n,c;r.endsWith("-webgl")&&(r=r.slice(0,-6),c=!0);let u=r.split("x");if(u.length>2)throw new Error(`Unsupported vertex format: ${n}`);let[d,b]=u,w=d,_=KHt(n,b),x=ZHt(n,w),T;try{T=c?JHt(n,w,_):this.makeVertexFormat(x.signedType,_,x.normalized)}catch{throw new Error(`Unsupported vertex format: ${n}`)}if(T!==(c?n:r))throw new Error(`Unsupported vertex format: ${n}`);let M={type:w,components:_,byteLength:x.byteLength*_,integer:x.integer,signed:x.signed,normalized:x.normalized};return c&&(M.webglOnly=!0),M}makeVertexFormat(n,r,c){let u=c?Md.getNormalizedDataType(n):n;switch(u){case"unorm8":return r===1?"unorm8":r===3?"unorm8x3-webgl":`${u}x${r}`;case"snorm8":return r===1?"snorm8":r===3?"snorm8x3-webgl":`${u}x${r}`;case"uint8":case"sint8":if(r===3)throw new Error(`size: ${r}`);return r===1?u:`${u}x${r}`;case"uint16":return r===1?"uint16":r===3?"uint16x3-webgl":`${u}x${r}`;case"sint16":return r===1?"sint16":r===3?"sint16x3-webgl":`${u}x${r}`;case"unorm16":return r===1?"unorm16":r===3?"unorm16x3-webgl":`${u}x${r}`;case"snorm16":return r===1?"snorm16":r===3?"snorm16x3-webgl":`${u}x${r}`;case"float16":if(r===3)throw new Error(`size: ${r}`);return r===1?u:`${u}x${r}`;default:return r===1?u:`${u}x${r}`}}getVertexFormatFromAttribute(n,r,c){if(!r||r>4)throw new Error(`size ${r}`);let u=r,d=Md.getDataType(n);return this.makeVertexFormat(d,u,c)}getCompatibleVertexFormat(n){let r;switch(n.primitiveType){case"f32":r="float32";break;case"i32":r="sint32";break;case"u32":r="uint32";break;case"f16":return n.components<=2?"float16x2":"float16x4"}return n.components===1?r:`${r}x${n.components}`}},hl=new RLe});function Cce(s){let n=$ht[s];if(!n)throw new Error(`Unsupported texture format ${s}`);return n}function jht(){return $ht}var ap,Tc,Vy,QHt,Sce,ILe,Mce,DLe,eqt,BLe,NM,OLe,NLe,Tce,Ght,tqt,nqt,$ht,FLe=Ve(()=>{ap="texture-compression-bc",Tc="texture-compression-astc",Vy="texture-compression-etc2",QHt="texture-compression-etc1-webgl",Sce="texture-compression-pvrtc-webgl",ILe="texture-compression-atc-webgl",Mce="float32-renderable-webgl",DLe="float16-renderable-webgl",eqt="rgb9e5ufloat-renderable-webgl",BLe="snorm8-renderable-webgl",NM="norm16-webgl",OLe="norm16-renderable-webgl",NLe="snorm16-renderable-webgl",Tce="float32-filterable",Ght="float16-filterable-webgl";tqt={r8unorm:{webgpu:527},rg8unorm:{webgpu:527},"rgb8unorm-webgl":{},rgba8unorm:{webgpu:31},"rgba8unorm-srgb":{webgpu:15},r8snorm:{render:BLe,webgpu:837},rg8snorm:{render:BLe,webgpu:837},"rgb8snorm-webgl":{},rgba8snorm:{render:BLe,webgpu:341},r8uint:{webgpu:515},rg8uint:{webgpu:515},rgba8uint:{webgpu:19},r8sint:{webgpu:515},rg8sint:{webgpu:515},rgba8sint:{webgpu:19},bgra8unorm:{webgpu:15},"bgra8unorm-srgb":{webgpu:15360},r16unorm:{f:NM,render:OLe,webgpu:992},rg16unorm:{f:NM,render:OLe,webgpu:992},"rgb16unorm-webgl":{f:NM,render:!1},rgba16unorm:{f:NM,render:OLe,webgpu:992},r16snorm:{f:NM,render:NLe,webgpu:992},rg16snorm:{f:NM,render:NLe,webgpu:992},"rgb16snorm-webgl":{f:NM,render:!1},rgba16snorm:{f:NM,render:NLe,webgpu:992},r16uint:{webgpu:515},rg16uint:{webgpu:515},rgba16uint:{webgpu:19},r16sint:{webgpu:515},rg16sint:{webgpu:515},rgba16sint:{webgpu:19},r16float:{render:DLe,filter:"float16-filterable-webgl",webgpu:527},rg16float:{render:DLe,filter:Ght,webgpu:527},rgba16float:{render:DLe,filter:Ght,webgpu:31},r32uint:{webgpu:19},rg32uint:{webgpu:16387},rgba32uint:{webgpu:19},r32sint:{webgpu:19},rg32sint:{webgpu:16387},rgba32sint:{webgpu:19},r32float:{render:Mce,filter:Tce,webgpu:19},rg32float:{render:!1,filter:Tce,webgpu:16387},"rgb32float-webgl":{render:Mce,filter:Tce},rgba32float:{render:Mce,filter:Tce,webgpu:19},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:eqt,webgpu:5},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:Mce,webgpu:517},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:527},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:515},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8",webgpu:3},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16",webgpu:3},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32",webgpu:3},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32",webgpu:3},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0,webgpu:3},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0,f:"depth32float-stencil8",webgpu:3}},nqt={"bc1-rgb-unorm-webgl":{f:ap},"bc1-rgb-unorm-srgb-webgl":{f:ap},"bc1-rgba-unorm":{f:ap},"bc1-rgba-unorm-srgb":{f:ap},"bc2-rgba-unorm":{f:ap},"bc2-rgba-unorm-srgb":{f:ap},"bc3-rgba-unorm":{f:ap},"bc3-rgba-unorm-srgb":{f:ap},"bc4-r-unorm":{f:ap},"bc4-r-snorm":{f:ap},"bc5-rg-unorm":{f:ap},"bc5-rg-snorm":{f:ap},"bc6h-rgb-ufloat":{f:ap},"bc6h-rgb-float":{f:ap},"bc7-rgba-unorm":{f:ap},"bc7-rgba-unorm-srgb":{f:ap},"etc2-rgb8unorm":{f:Vy},"etc2-rgb8unorm-srgb":{f:Vy},"etc2-rgb8a1unorm":{f:Vy},"etc2-rgb8a1unorm-srgb":{f:Vy},"etc2-rgba8unorm":{f:Vy},"etc2-rgba8unorm-srgb":{f:Vy},"eac-r11unorm":{f:Vy},"eac-r11snorm":{f:Vy},"eac-rg11unorm":{f:Vy},"eac-rg11snorm":{f:Vy},"astc-4x4-unorm":{f:Tc},"astc-4x4-unorm-srgb":{f:Tc},"astc-5x4-unorm":{f:Tc},"astc-5x4-unorm-srgb":{f:Tc},"astc-5x5-unorm":{f:Tc},"astc-5x5-unorm-srgb":{f:Tc},"astc-6x5-unorm":{f:Tc},"astc-6x5-unorm-srgb":{f:Tc},"astc-6x6-unorm":{f:Tc},"astc-6x6-unorm-srgb":{f:Tc},"astc-8x5-unorm":{f:Tc},"astc-8x5-unorm-srgb":{f:Tc},"astc-8x6-unorm":{f:Tc},"astc-8x6-unorm-srgb":{f:Tc},"astc-8x8-unorm":{f:Tc},"astc-8x8-unorm-srgb":{f:Tc},"astc-10x5-unorm":{f:Tc},"astc-10x5-unorm-srgb":{f:Tc},"astc-10x6-unorm":{f:Tc},"astc-10x6-unorm-srgb":{f:Tc},"astc-10x8-unorm":{f:Tc},"astc-10x8-unorm-srgb":{f:Tc},"astc-10x10-unorm":{f:Tc},"astc-10x10-unorm-srgb":{f:Tc},"astc-12x10-unorm":{f:Tc},"astc-12x10-unorm-srgb":{f:Tc},"astc-12x12-unorm":{f:Tc},"astc-12x12-unorm-srgb":{f:Tc},"pvrtc-rgb4unorm-webgl":{f:Sce},"pvrtc-rgba4unorm-webgl":{f:Sce},"pvrtc-rgb2unorm-webgl":{f:Sce},"pvrtc-rgba2unorm-webgl":{f:Sce},"etc1-rbg-unorm-webgl":{f:QHt},"atc-rgb-unorm-webgl":{f:ILe},"atc-rgba-unorm-webgl":{f:ILe},"atc-rgbai-unorm-webgl":{f:ILe}},$ht={...tqt,...nqt}});function cqt({format:s,width:n,height:r,depth:c,byteAlignment:u}){let d=og.getInfo(s),{bytesPerPixel:b,bytesPerBlock:w=b,blockWidth:_=1,blockHeight:x=1,compressed:T=!1}=d,M=T?Math.ceil(n/_):n,L=T?Math.ceil(r/x):r,I=M*w,D=Math.ceil(I/u)*u,F=L,O=D*F*c;return{bytesPerPixel:b,bytesPerRow:D,rowsPerImage:F,depthOrArrayLayers:c,bytesPerImage:D*F,byteLength:O}}function lqt(s){let n=Cce(s),r={format:s,create:n.f??!0,render:n.render??!0,filter:n.filter??!0,blend:n.blend??!0,store:n.store??!0},c=Vht(s),u=s.startsWith("depth")||s.startsWith("stencil"),d=c?.signed,b=c?.integer,w=c?.webgl,_=!!c?.compressed;return r.render&&=!u&&!_,r.filter&&=!u&&!d&&!b&&!w,r}function Vht(s){let n=uqt(s);if(og.isCompressed(s)){n.channels="rgb",n.components=3,n.bytesPerPixel=1,n.srgb=!1,n.compressed=!0,n.bytesPerBlock=hqt(s);let c=fqt(s);c&&(n.blockWidth=c.blockWidth,n.blockHeight=c.blockHeight)}let r=n.packed?null:iqt.exec(s);if(r){let[,c,u,d,b,w]=r,_=`${d}${u}`,x=Md.getDataTypeInfo(_),T=x.byteLength*8,M=c?.length??1,L=[T,M>=2?T:0,M>=3?T:0,M>=4?T:0];n={format:s,attachment:n.attachment,dataType:x.signedType,components:M,channels:c,integer:x.integer,signed:x.signed,normalized:x.normalized,bitsPerChannel:L,bytesPerPixel:x.byteLength*M,packed:n.packed,srgb:n.srgb},w==="-webgl"&&(n.webgl=!0),b==="-srgb"&&(n.srgb=!0)}return s.endsWith("-webgl")&&(n.webgl=!0),s.endsWith("-srgb")&&(n.srgb=!0),n}function uqt(s){let n={...Cce(s)},r=n.bytesPerPixel||1,c=n.bitsPerChannel||[8,8,8,8];return delete n.bitsPerChannel,delete n.bytesPerPixel,delete n.f,delete n.render,delete n.filter,delete n.blend,delete n.store,delete n.webgpu,{...n,format:s,attachment:n.attachment||"color",channels:n.channels||"r",components:n.components||n.channels?.length||1,bytesPerPixel:r,bitsPerChannel:c,dataType:n.dataType||"uint8",srgb:n.srgb??!1,packed:n.packed??!1,webgl:n.webgl??!1,integer:n.integer??!1,signed:n.signed??!1,normalized:n.normalized??!1,compressed:n.compressed??!1}}function fqt(s){let r=/.*-(\d+)x(\d+)-.*/.exec(s);if(r){let[,c,u]=r;return{blockWidth:Number(c),blockHeight:Number(u)}}return s.startsWith("bc")||s.startsWith("etc1")||s.startsWith("etc2")||s.startsWith("eac")||s.startsWith("atc")?{blockWidth:4,blockHeight:4}:s.startsWith("pvrtc-rgb4")||s.startsWith("pvrtc-rgba4")?{blockWidth:4,blockHeight:4}:s.startsWith("pvrtc-rgb2")||s.startsWith("pvrtc-rgba2")?{blockWidth:8,blockHeight:4}:null}function hqt(s){return s.startsWith("bc1")||s.startsWith("bc4")||s.startsWith("etc1")||s.startsWith("etc2-rgb8")||s.startsWith("etc2-rgb8a1")||s.startsWith("eac-r11")||s==="atc-rgb-unorm-webgl"?8:s.startsWith("bc2")||s.startsWith("bc3")||s.startsWith("bc5")||s.startsWith("bc6h")||s.startsWith("bc7")||s.startsWith("etc2-rgba8")||s.startsWith("eac-rg11")||s.startsWith("astc")||s==="atc-rgba-unorm-webgl"||s==="atc-rgbai-unorm-webgl"?16:s.startsWith("pvrtc")?8:16}var iqt,rqt,sqt,oqt,aqt,ULe,og,Ace=Ve(()=>{Ece();FLe();iqt=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,rqt=["rgb","rgba","bgra"],sqt=["depth","stencil"],oqt=5,aqt=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],ULe=class{isColor(n){return rqt.some(r=>n.startsWith(r))}isDepthStencil(n){return sqt.some(r=>n.startsWith(r))}isCompressed(n){return aqt.some(r=>n.startsWith(r))}getInfo(n){return Vht(n)}getCapabilities(n){return lqt(n)}getWebGPUCapabilities(n){let r=Cce(n);return r.webgpu!==void 0?r.webgpu:this.isCompressed(n)&&!n.endsWith("-webgl")?oqt:0}computeMemoryLayout(n){return cqt(n)}},og=new ULe});function Wht(s){return typeof ImageData<"u"&&s instanceof ImageData||typeof ImageBitmap<"u"&&s instanceof ImageBitmap||typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&s instanceof HTMLVideoElement||typeof VideoFrame<"u"&&s instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas}function Hht(s){if(typeof ImageData<"u"&&s instanceof ImageData||typeof ImageBitmap<"u"&&s instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas)return{width:s.width,height:s.height};if(typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement)return{width:s.naturalWidth,height:s.naturalHeight};if(typeof HTMLVideoElement<"u"&&s instanceof HTMLVideoElement)return{width:s.videoWidth,height:s.videoHeight};if(typeof VideoFrame<"u"&&s instanceof VideoFrame)return{width:s.displayWidth,height:s.displayHeight};throw new Error("Unknown image type")}var qht=Ve(()=>{});function dqt(s,n){let r=zLe(s),c=n.map(zLe).filter(u=>u!==void 0);return[r,...c].filter(u=>u!==void 0)}function zLe(s){if(s!==void 0){if(s===null||typeof s=="string"||typeof s=="number"||typeof s=="boolean")return s;if(s instanceof Error)return s.message;if(Array.isArray(s))return s.map(zLe);if(typeof s=="object"){if(pqt(s)){let n=String(s);if(n!=="[object Object]")return n}return gqt(s)?mqt(s):s.constructor?.name||"Object"}return String(s)}}function pqt(s){return"toString"in s&&typeof s.toString=="function"&&s.toString!==Object.prototype.toString}function gqt(s){return"message"in s&&"type"in s}function mqt(s){let n=typeof s.type=="string"?s.type:"message",r=typeof s.message=="string"?s.message:"",c=typeof s.lineNum=="number"?s.lineNum:null,u=typeof s.linePos=="number"?s.linePos:null,d=c!==null&&u!==null?` @ ${c}:${u}`:c!==null?` @ ${c}`:"";return`${n}${d}: ${r}`.trim()}function GLe(){if(typeof HTMLCanvasElement>"u")return!1;let s=HTMLCanvasElement.prototype;return"layoutSubtree"in s&&typeof s.requestPaint=="function"}var d$,p$,A3,Xht=Ve(()=>{TLe();sg();zD();_ce();h$();Ace();qht();FLe();SLe();d$=class{};p$=class{features;disabledFeatures;constructor(n=[],r){this.features=new Set(n),this.disabledFeatures=r||{}}*[Symbol.iterator](){yield*this.features}has(n){return!this.disabledFeatures?.[n]&&this.features.has(n)}};A3=class s{static defaultProps={...bce};get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}toJSON(){return this.toString()}id;props;userData={};statsManager=wce;_factories={};timestamp=0;_reused=!1;_moduleData={};wgslLanguageFeatures=new Set;_textureCaps={};_debugGPUTimeQuery=null;constructor(n){this.props={...s.defaultProps,...n},this.id=this.props.id||$y(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(n){return hl.getVertexFormatInfo(n)}isVertexFormatSupported(n){return!0}getTextureFormatInfo(n){return og.getInfo(n)}getTextureFormatCapabilities(n){let r=this._textureCaps[n];if(!r){let c=this._getDeviceTextureFormatCapabilities(n);r=this._getDeviceSpecificTextureFormatCapabilities(c),this._textureCaps[n]=r}return r}getMipLevelCount(n,r,c=1){let u=Math.max(n,r,c);return 1+Math.floor(Math.log2(u))}isExternalImage(n){return Wht(n)}getExternalImageSize(n){return Hht(n)}isTextureFormatSupported(n){return this.getTextureFormatCapabilities(n).create}isTextureFormatFilterable(n){return this.getTextureFormatCapabilities(n).filter}isTextureFormatRenderable(n){return this.getTextureFormatCapabilities(n).render}isTextureFormatCompressed(n){return og.isCompressed(n)}getSupportedCompressedTextureFormats(){let n=[];for(let r of Object.keys(jht()))this.isTextureFormatCompressed(r)&&this.isTextureFormatSupported(r)&&n.push(r);return n}pushDebugGroup(n){this.commandEncoder.pushDebugGroup(n)}popDebugGroup(){this.commandEncoder?.popDebugGroup()}insertDebugMarker(n){this.commandEncoder?.insertDebugMarker(n)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(n,r,...c){if(!this.props.onError(n,r)){let d=dqt(r,c);return Qt.error(this.type==="webgl"?"%cWebGL":"%cWebGPU","color: white; background: red; padding: 2px 6px; border-radius: 3px;",n.message,...d)}return()=>{}}debug(){if(this.props.debug)debugger;else{let n=`'Type luma.log.set({debug: true}) in console to enable debug breakpoints', -or create a device with the 'debug: true' prop.`;Qt.once(0,n)()}}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}createFence(){throw new Error("createFence() not implemented")}beginRenderPass(n){return this.commandEncoder.beginRenderPass(n)}beginComputePass(n){return this.commandEncoder.beginComputePass(n)}writeBufferViaCommandEncoder(n,r,c,u=0){throw new Error("writeBufferViaCommandEncoder() not implemented")}generateMipmapsWebGPU(n){throw new Error("not implemented")}_createSharedRenderPipelineWebGL(n){throw new Error("_createSharedRenderPipelineWebGL() not implemented")}_createBindGroupLayoutWebGPU(n,r){throw new Error("_createBindGroupLayoutWebGPU() not implemented")}_createBindGroupWebGPU(n,r,c,u,d){throw new Error("_createBindGroupWebGPU() not implemented")}_supportsDebugGPUTime(){return this.features.has("timestamp-query")&&!!(this.props.debug||this.props.debugGPUTime)}_enableDebugGPUTime(n=256){if(!this._supportsDebugGPUTime())return null;if(this._debugGPUTimeQuery)return this._debugGPUTimeQuery;try{this._debugGPUTimeQuery=this.createQuerySet({type:"timestamp",count:n}),this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id,timeProfilingQuerySet:this._debugGPUTimeQuery})}catch{this._debugGPUTimeQuery=null}return this._debugGPUTimeQuery}_disableDebugGPUTime(){this._debugGPUTimeQuery&&(this.commandEncoder.getTimeProfilingQuerySet()===this._debugGPUTimeQuery&&(this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id})),this._debugGPUTimeQuery.destroy(),this._debugGPUTimeQuery=null)}_isDebugGPUTimeEnabled(){return this._debugGPUTimeQuery!==null}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(n,r){throw new Error("not implemented")}readPixelsToBufferWebGL(n,r){throw new Error("not implemented")}setParametersWebGL(n){throw new Error("not implemented")}getParametersWebGL(n){throw new Error("not implemented")}withParametersWebGL(n,r){throw new Error("not implemented")}clearWebGL(n){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}getModuleData(n){return this._moduleData[n]||={},this._moduleData[n]}static _getCanvasContextProps(n){return n.createCanvasContext===!0?{}:n.createCanvasContext}_getDeviceTextureFormatCapabilities(n){let r=og.getCapabilities(n),c=d=>(typeof d=="string"?this.features.has(d):d)??!0,u=c(r.create);return{format:n,create:u,render:u&&c(r.render),filter:u&&c(r.filter),blend:u&&c(r.blend),store:u&&c(r.store)}}_normalizeBufferProps(n){(n instanceof ArrayBuffer||ArrayBuffer.isView(n))&&(n={data:n});let r={...n};if((n.usage||0)&cs.INDEX&&(n.indexType||(n.data instanceof Uint32Array?r.indexType="uint32":n.data instanceof Uint16Array?r.indexType="uint16":n.data instanceof Uint8Array&&(r.data=new Uint16Array(n.data),r.indexType="uint16")),!r.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return r}}});var Pce,Yht=Ve(()=>{Pce=class{props;_resizeObserver;_intersectionObserver;_observeDevicePixelRatioTimeout=null;_observeDevicePixelRatioMediaQuery=null;_handleDevicePixelRatioChange=()=>this._refreshDevicePixelRatio();_trackPositionInterval=null;_started=!1;get started(){return this._started}constructor(n){this.props=n}start(){if(this._started||!this.props.canvas)return;this._started=!0,this._intersectionObserver||=new IntersectionObserver(r=>this.props.onIntersection(r)),this._resizeObserver||=new ResizeObserver(r=>this.props.onResize(r)),this._intersectionObserver.observe(this.props.canvas);let n=this.props.resizeObserverBox;try{this._resizeObserver.observe(this.props.canvas,{box:n})}catch{this._resizeObserver.observe(this.props.canvas,{box:"content-box"})}this._observeDevicePixelRatioTimeout=setTimeout(()=>this._refreshDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}stop(){this._started&&(this._started=!1,this._observeDevicePixelRatioTimeout&&(clearTimeout(this._observeDevicePixelRatioTimeout),this._observeDevicePixelRatioTimeout=null),this._observeDevicePixelRatioMediaQuery&&(this._observeDevicePixelRatioMediaQuery.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=null),this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null),this._resizeObserver?.disconnect(),this._intersectionObserver?.disconnect())}_refreshDevicePixelRatio(){this._started&&(this.props.onDevicePixelRatioChange(),this._observeDevicePixelRatioMediaQuery?.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._observeDevicePixelRatioMediaQuery.addEventListener("change",this._handleDevicePixelRatioChange,{once:!0}))}_trackPosition(n=100){this._trackPositionInterval||(this._trackPositionInterval=setInterval(()=>{this._started?this.props.onPositionChange():this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null)},n))}}});function Zht(){let s,n;return{promise:new Promise((c,u)=>{s=c,n=u}),resolve:s,reject:n}}var Kht=Ve(()=>{});function FM(s,n){if(!s){let r=new Error(n??"luma.gl assertion failed.");throw Error.captureStackTrace?.(r,FM),r}}function UM(s,n){return FM(s,n),s}var jLe=Ve(()=>{});function bqt(s){if(typeof s=="string"){let n=document.getElementById(s);if(!n)throw new Error(`${s} is not an HTML element`);return n}return s||document.body}function wqt(s){let n=document.getElementById(s);if(!zM.isHTMLCanvas(n))throw new Error("Object is not a canvas element");return n}function vqt(s){let{width:n,height:r}=s,c=document.createElement("canvas");c.id=$y("lumagl-auto-created-canvas"),c.width=n||1,c.height=r||1,c.style.width=Number.isFinite(n)?`${n}px`:"100%",c.style.height=Number.isFinite(r)?`${r}px`:"100%",s?.visible||(c.style.visibility="hidden");let u=bqt(s?.container||null);return u.insertBefore(c,u.firstChild),c}function _qt(s,n,r,c,u){let d=s,b=Jht(d[0],n,r),w=Qht(d[1],n,c,u),_=Jht(d[0]+1,n,r),x=_===r-1?_:_-1;_=Qht(d[1]+1,n,c,u);let T;return u?(_=_===0?_:_+1,T=w,w=_):T=_===c-1?_:_-1,{x:b,y:w,width:Math.max(x-b+1,1),height:Math.max(T-w+1,1)}}function Jht(s,n,r){return Math.min(Math.round(s*n),r-1)}function Qht(s,n,r,c){return c?Math.max(0,r-1-Math.round(s*n)):Math.min(Math.round(s*n),r-1)}var zM,$Le=Ve(()=>{VL();Yht();zD();Kht();jLe();zM=class s{static isHTMLCanvas(n){return typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement}static isOffscreenCanvas(n){return typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas}static defaultProps={id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,pixelSizeSource:"exact",autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",colorFormat:void 0,toneMapping:"standard",trackPosition:!1};id;props;canvas;htmlCanvas;offscreenCanvas;type;initialized;isInitialized=!1;isVisible=!0;cssWidth;cssHeight;devicePixelRatio;devicePixelWidth;devicePixelHeight;drawingBufferWidth;drawingBufferHeight;_initializedResolvers=Zht();_canvasObserver;_position=[0,0];destroyed=!1;_needsDrawingBufferResize=!0;_configuredDrawingBufferSize=[0,0];toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(n){this.props={...s.defaultProps,...n},n=this.props,this.initialized=this._initializedResolvers.promise,D1()?n.canvas?typeof n.canvas=="string"?this.canvas=wqt(n.canvas):this.canvas=n.canvas:this.canvas=vqt(n):this.canvas={width:n.width||1,height:n.height||1},s.isHTMLCanvas(this.canvas)?(this.id=n.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):s.isOffscreenCanvas(this.canvas)?(this.id=n.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=n.id||"node-canvas-context",this.type="node"),this.cssWidth=this.htmlCanvas?.clientWidth||this.canvas.width,this.cssHeight=this.htmlCanvas?.clientHeight||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this._configuredDrawingBufferSize=[this.canvas.width,this.canvas.height],this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],this._canvasObserver=new Pce({canvas:this.htmlCanvas,trackPosition:this.props.trackPosition,resizeObserverBox:this.props.pixelSizeSource==="css-dpr"?"content-box":"device-pixel-content-box",onResize:r=>this._handleResize(r),onIntersection:r=>this._handleIntersection(r),onDevicePixelRatioChange:()=>this._observeDevicePixelRatio(),onPositionChange:()=>this.updatePosition()})}destroy(){this.destroyed||(this.destroyed=!0,this._stopObservers(),this.device=null)}setProps(n){return"useDevicePixels"in n&&(this.props.useDevicePixels=n.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCurrentFramebuffer(n){return this._resizeDrawingBufferIfNeeded(),this._getCurrentFramebuffer(n)}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){let n=this.device.limits.maxTextureDimension2D;return[n,n]}setDrawingBufferSize(n,r){n=Math.floor(n),r=Math.floor(r),!(this.drawingBufferWidth===n&&this.drawingBufferHeight===r)&&(this.drawingBufferWidth=n,this.drawingBufferHeight=r,this._needsDrawingBufferResize=!0)}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(n,r=!0){let c=this.cssToDeviceRatio(),[u,d]=this.getDrawingBufferSize();return _qt(n,c,u,d,r)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){let[n,r]=this.getDrawingBufferSize();return n>0&&r>0?n/r:1}cssToDeviceRatio(){try{let[n]=this.getDrawingBufferSize(),[r]=this.getCSSSize();return r?n/r:1}catch{return 1}}resize(n){this.setDrawingBufferSize(n.width,n.height)}_setAutoCreatedCanvasId(n){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=n)}_startObservers(){this.destroyed||this._canvasObserver.start()}_stopObservers(){this._canvasObserver.stop()}_handleIntersection(n){if(this.destroyed)return;let r=n.find(u=>u.target===this.canvas);if(!r)return;let c=r.isIntersecting;this.isVisible!==c&&(this.isVisible=c,this.device.props.onVisibilityChange(this))}_handleResize(n){if(this.destroyed)return;let r=n.find(d=>d.target===this.canvas);if(!r)return;let c=UM(r.contentBoxSize?.[0]);this.cssWidth=c.inlineSize,this.cssHeight=c.blockSize;let u=this.getDevicePixelSize();this._setDevicePixelSize(this._getDevicePixelSizeFromResizeEntry(r)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:u})}_updateDrawingBufferSize(){if(this.props.autoResize)if(typeof this.props.useDevicePixels=="number"){let n=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*n,this.cssHeight*n)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_getDevicePixelSizeFromResizeEntry(n){let r=UM(n.contentBoxSize?.[0]);return this.props.pixelSizeSource==="css-dpr"?this._getDevicePixelSizeFromCSSSize(r.inlineSize,r.blockSize):{devicePixelWidth:n.devicePixelContentBoxSize?.[0]?.inlineSize||r.inlineSize*devicePixelRatio,devicePixelHeight:n.devicePixelContentBoxSize?.[0]?.blockSize||r.blockSize*devicePixelRatio}}_getDevicePixelSizeFromCSSSize(n,r){let c=this.getDevicePixelRatio();return{devicePixelWidth:Math.floor(n*c),devicePixelHeight:Math.floor(r*c)}}_setDevicePixelSize({devicePixelWidth:n,devicePixelHeight:r}){let[c,u]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(n,c)),this.devicePixelHeight=Math.max(1,Math.min(r,u))}_resizeDrawingBufferIfNeeded(){if(this._needsDrawingBufferResize){this._needsDrawingBufferResize=!1,(this.drawingBufferWidth!==this.canvas.width||this.drawingBufferHeight!==this.canvas.height)&&(this.canvas.width=this.drawingBufferWidth,this.canvas.height=this.drawingBufferHeight);let[r,c]=this._configuredDrawingBufferSize;(this.drawingBufferWidth!==r||this.drawingBufferHeight!==c)&&(this._configureDevice(),this._configuredDrawingBufferSize=[this.drawingBufferWidth,this.drawingBufferHeight])}}_observeDevicePixelRatio(){if(this.destroyed||!this._canvasObserver.started)return;let n=this.devicePixelRatio;if(this.devicePixelRatio=window.devicePixelRatio,this.props.pixelSizeSource==="css-dpr"){let r=this.getDevicePixelSize();this._setDevicePixelSize(this._getDevicePixelSizeFromCSSSize(this.cssWidth,this.cssHeight)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:r})}this.updatePosition(),this.device.props.onDevicePixelRatioChange?.(this,{oldRatio:n})}updatePosition(){if(this.destroyed)return;let n=this.htmlCanvas?.getBoundingClientRect();if(n){let r=[n.left,n.top];if(this._position??=r,r[0]!==this._position[0]||r[1]!==this._position[1]){let u=this._position;this._position=r,this.device.props.onPositionChange?.(this,{oldPosition:u})}}}}});var g$,edt=Ve(()=>{$Le();g$=class extends zM{static defaultProps=zM.defaultProps}});var m$,tdt=Ve(()=>{$Le();m$=class extends zM{}});var QL,VLe=Ve(()=>{Gh();QL=class s extends is{static defaultProps={...is.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1};get[Symbol.toStringTag](){return"Sampler"}constructor(n,r){r=s.normalizeProps(n,r),super(n,r,s.defaultProps)}static normalizeProps(n,r){return r}}});var yqt,Pa,WLe=Ve(()=>{Gh();VLe();sg();Ace();yqt={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},Pa=class s extends is{static SAMPLE=4;static STORAGE=8;static RENDER=16;static COPY_SRC=1;static COPY_DST=2;static TEXTURE=4;static RENDER_ATTACHMENT=16;dimension;baseDimension;format;width;height;depth;mipLevels;samples;byteAlignment;ready=Promise.resolve(this);isReady=!0;updateTimestamp;get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(n,r,c){if(r=s.normalizeProps(n,r),super(n,r,s.defaultProps),this.dimension=this.props.dimension,this.baseDimension=yqt[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.samples=this.props.samples||1,this.dimension==="cube"&&(this.depth=6),this.props.width===void 0||this.props.height===void 0)if(n.isExternalImage(r.data)){let u=n.getExternalImageSize(r.data);this.width=u?.width||1,this.height=u?.height||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&Qt.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=c?.byteAlignment||1,this.updateTimestamp=n.incrementTimestamp()}clone(n){return this.device.createTexture({...this.props,...n})}setSampler(n){this.sampler=n instanceof QL?n:this.device.createSampler(n)}copyImageData(n){let{data:r,depth:c,...u}=n;this.writeData(r,{...u,depthOrArrayLayers:u.depthOrArrayLayers??c})}computeMemoryLayout(n={}){let r=this._normalizeTextureReadOptions(n),{width:c=this.width,height:u=this.height,depthOrArrayLayers:d=this.depth}=r,{format:b,byteAlignment:w}=this;return og.computeMemoryLayout({format:b,width:c,height:u,depth:d,byteAlignment:w})}readBuffer(n,r){throw new Error("readBuffer not implemented")}readDataAsync(n){throw new Error("readBuffer not implemented")}writeBuffer(n,r){throw new Error("readBuffer not implemented")}writeData(n,r){throw new Error("readBuffer not implemented")}readDataSyncWebGL(n){throw new Error("readDataSyncWebGL not available")}generateMipmapsWebGL(){throw new Error("generateMipmapsWebGL not available")}static normalizeProps(n,r){let c={...r},{width:u,height:d}=c;return typeof u=="number"&&(c.width=Math.max(1,Math.ceil(u))),typeof d=="number"&&(c.height=Math.max(1,Math.ceil(d))),c}_initializeData(n){this.device.isExternalImage(n)?this.copyExternalImage({image:n,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):n&&this.copyImageData({data:n,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(n){let{data:r,depth:c,...u}=n,d=this._normalizeTextureWriteOptions({...u,depthOrArrayLayers:u.depthOrArrayLayers??c});return{data:r,depth:d.depthOrArrayLayers,...d}}_normalizeCopyExternalImageOptions(n){let r=s._omitUndefined(n),c=r.mipLevel??0,u=this._getMipLevelSize(c),d=this.device.getExternalImageSize(n.image),b={...s.defaultCopyExternalImageOptions,...u,...d,...r};return b.width=Math.min(b.width,u.width-b.x),b.height=Math.min(b.height,u.height-b.y),b.depth=Math.min(b.depth,u.depthOrArrayLayers-b.z),b}_normalizeCopyElementImageOptions(n){let r=s._omitUndefined(n),c=r.mipLevel??0,u=this._getMipLevelSize(c),d={...s.defaultCopyElementImageOptions,...u,...r};return d.width=Math.min(d.width,u.width-d.x),d.height=Math.min(d.height,u.height-d.y),d.depth=Math.min(d.depth,u.depthOrArrayLayers-d.z),d}_normalizeTextureReadOptions(n){let r=s._omitUndefined(n),c=r.mipLevel??0,u=this._getMipLevelSize(c),d={...s.defaultTextureReadOptions,...u,...r};return d.width=Math.min(d.width,u.width-d.x),d.height=Math.min(d.height,u.height-d.y),d.depthOrArrayLayers=Math.min(d.depthOrArrayLayers,u.depthOrArrayLayers-d.z),d}_getSupportedColorReadOptions(n){let r=this._normalizeTextureReadOptions(n),c=og.getInfo(this.format);switch(this._validateColorReadAspect(r),this._validateColorReadFormat(c),this.dimension){case"2d":case"cube":case"cube-array":case"2d-array":case"3d":return r;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}}_validateColorReadAspect(n){if(n.aspect!=="all")throw new Error(`${this} color readback only supports aspect 'all'`)}_validateColorReadFormat(n){if(n.compressed)throw new Error(`${this} color readback does not support compressed formats (${this.format})`);switch(n.attachment){case"color":return;case"depth":throw new Error(`${this} color readback does not support depth formats (${this.format})`);case"stencil":throw new Error(`${this} color readback does not support stencil formats (${this.format})`);case"depth-stencil":throw new Error(`${this} color readback does not support depth-stencil formats (${this.format})`);default:throw new Error(`${this} color readback does not support format ${this.format}`)}}_normalizeTextureWriteOptions(n){let r=s._omitUndefined(n),c=r.mipLevel??0,u=this._getMipLevelSize(c),d={...s.defaultTextureWriteOptions,...u,...r};d.width=Math.min(d.width,u.width-d.x),d.height=Math.min(d.height,u.height-d.y),d.depthOrArrayLayers=Math.min(d.depthOrArrayLayers,u.depthOrArrayLayers-d.z);let b=og.computeMemoryLayout({format:this.format,width:d.width,height:d.height,depth:d.depthOrArrayLayers,byteAlignment:this.byteAlignment}),w=b.bytesPerPixel*d.width;if(d.bytesPerRow=r.bytesPerRow??b.bytesPerRow,d.rowsPerImage=r.rowsPerImage??d.height,d.bytesPerRow>n),c=this.baseDimension==="1d"?1:Math.max(1,this.height>>n),u=this.dimension==="3d"?Math.max(1,this.depth>>n):this.depth;return{width:r,height:c,depthOrArrayLayers:u}}getAllocatedByteLength(){let n=0;for(let r=0;rr!==void 0))}static defaultProps={...is.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:s.SAMPLE|s.RENDER|s.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0};static defaultCopyDataOptions={data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,width:void 0,height:void 0,depthOrArrayLayers:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all"};static defaultCopyExternalImageOptions={image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultCopyElementImageOptions={element:void 0,width:void 0,height:void 0,sourceX:0,sourceY:0,sourceWidth:void 0,sourceHeight:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultTextureReadOptions={x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"};static defaultTextureWriteOptions={byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"}}});var e4,ndt=Ve(()=>{Gh();e4=class s extends is{get[Symbol.toStringTag](){return"TextureView"}constructor(n,r){super(n,r,s.defaultProps)}static defaultProps={...is.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0}}});var b$,idt=Ve(()=>{Gh();b$=class s extends is{width;height;updateTimestamp;get[Symbol.toStringTag](){return"ExternalTexture"}constructor(n,r){super(n,r,s.defaultProps);let c=this.props.source?n.getExternalImageSize(this.props.source):null;this.width=this.props.width||c?.width||0,this.height=this.props.height||c?.height||0,this.updateTimestamp=n.incrementTimestamp()}static defaultProps={...is.defaultProps,source:void 0,width:0,height:0,colorSpace:"srgb",sampler:{}}}});function rdt(s,n,r){let c="",u=n.split(/\r?\n/),d=s.slice().sort((b,w)=>b.lineNum-w.lineNum);switch(r?.showSourceCode||"no"){case"all":let b=0;for(let w=1;w<=u.length;w++){let _=u[w-1],x=d[b];for(_&&x&&(c+=sdt(_,w,r));d.length>b&&x.lineNum===w;){let T=d[b++];T&&(c+=HLe(T,u,T.lineNum,{...r,inlineSource:!1}))}}for(;d.length>b;){let w=d[b++];w&&(c+=HLe(w,[],0,{...r,inlineSource:!1}))}return c;case"issues":case"no":for(let w of s)c+=HLe(w,u,w.lineNum,{inlineSource:r?.showSourceCode!=="no"});return c}}function HLe(s,n,r,c){if(c?.inlineSource){let d=xqt(n,r),b=s.linePos>0?`${" ".repeat(s.linePos+5)}^^^ +`;switch(w){case"vs:#decl":(u==="wgsl"||b)&&(s=s.replace(c$,x));break;case"vs:#main-start":(u==="wgsl"||b)&&(s=u==="wgsl"?gce(s,"vertex",x,"start",d.vertex):s.replace(vht,T=>T+x));break;case"vs:#main-end":(u==="wgsl"||b)&&(s=u==="wgsl"?gce(s,"vertex",x,"end",d.vertex):s.replace(_ht,T=>x+T));break;case"fs:#decl":(u==="wgsl"||!b)&&(s=s.replace(c$,x));break;case"fs:#main-start":(u==="wgsl"||!b)&&(s=u==="wgsl"?gce(s,"fragment",x,"start",d.fragment):s.replace(vht,T=>T+x));break;case"fs:#main-end":(u==="wgsl"||!b)&&(s=u==="wgsl"?gce(s,"fragment",x,"end",d.fragment):s.replace(_ht,T=>x+T));break;default:s=s.replace(w,T=>T+x)}}return s=s.replace(c$,""),c&&(s=s.replace(/\}\s*$/,w=>w+AHt[n])),s}function gce(s,n,r,c,u){let d=LHt(s,n,u);if(!d)return s;if(c==="start"){let b=d.openBraceIndex+1;return`${s.slice(0,b)} +${r}${s.slice(b)}`}return`${s.slice(0,d.closeBraceIndex)}${r}${s.slice(d.closeBraceIndex)}`}function LHt(s,n,r){let c=n==="vertex"?"@vertex":"@fragment",u=s.indexOf(c);if(u<0)return null;let d=r?s.search(new RegExp(`\\bfn\\s+${kHt(r)}\\s*\\(`)):s.indexOf("fn",u);if(d<0)return null;let b=s.indexOf("{",d);if(b<0)return null;let w=0;for(let _=b;_{wht();AHt={vertex:mht,fragment:bht},vht=/void\s+main\s*\([^)]*\)\s*\{\n?/,_ht=/}\n?[^{}]*$/,_Le=[],c$="__LUMA_INJECT_DECLARATIONS__"});function FD(s){s.map(n=>RHt(n))}function RHt(s){if(s.instance)return;FD(s.dependencies||[]);let{propTypes:n={},deprecations:r=[],inject:c={}}=s,u={normalizedInjections:yht(c),parsedDeprecations:IHt(r)};n&&(u.propValidators=pht(n)),s.instance=u;let d={};n&&(d=Object.entries(n).reduce((b,[w,_])=>{let x=_?.value;return x&&(b[w]=x),b},{})),s.defaultUniforms={...s.defaultUniforms,...d}}function xLe(s,n,r){s.deprecations?.forEach(c=>{c.regex?.test(n)&&(c.deprecated?r.deprecated(c.old,c.new)():r.removed(c.old,c.new)())})}function IHt(s){return s.forEach(n=>{switch(n.type){case"function":n.regex=new RegExp(`\\b${n.old}\\(`);break;default:n.regex=new RegExp(`${n.type} ${n.old};`)}}),s}var mce=Ve(()=>{ght();yLe()});function ZL(s){FD(s);let n={},r={};xht({modules:s,level:0,moduleMap:n,moduleDepth:r});let c=Object.keys(r).sort((u,d)=>r[d]-r[u]).map(u=>n[u]);return FD(c),c}function xht(s){let{modules:n,level:r,moduleMap:c,moduleDepth:u}=s;if(r>=5)throw new Error("Possible loop in shader dependency graph");for(let d of n)c[d.name]=d,(u[d.name]===void 0||u[d.name]{mce()});var Qt,sg=Ve(()=>{Hj();Qt=new ig({id:"luma.gl"})});function DHt(s,n){return s!=null?!!s:n!==void 0?n!=="production":!1}function BHt(){return DHt(Qt.get("debug"),OHt())}function OHt(){let s=globalThis.process;if(s?.env)return s.env.NODE_ENV}var bce,SLe=Ve(()=>{sg();bce={id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,featureLevel:void 0,optionalFeatures:[],xrCompatible:!1,createCanvasContext:void 0,webgl:{},onError:(s,n)=>{},onResize:(s,n)=>{let[r,c]=s.getDevicePixelSize();Qt.log(1,`${s} resized => ${r}x${c}px`)()},onPositionChange:(s,n)=>{let[r,c]=s.getPosition();Qt.log(1,`${s} repositioned => ${r},${c}`)()},onVisibilityChange:s=>Qt.log(1,`${s} Visibility changed ${s.isVisible}`)(),onDevicePixelRatioChange:(s,n)=>Qt.log(1,`${s} DPR changed ${n.oldRatio} => ${s.devicePixelRatio}`)(),debug:BHt(),debugGPUTime:!1,debugShaders:Qt.get("debug-shaders")||void 0,debugFramebuffers:!!Qt.get("debug-framebuffers"),debugFactories:!!Qt.get("debug-factories"),debugWebGL:!!Qt.get("debug-webgl"),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0}});function UHt(s,n){let r=s.stats,c=!1;for(let _ of n)r[_]||(s.get(_),c=!0);let u=Object.keys(r).length,d=Eht.get(s);if(!c&&d?.orderedStatNames===n&&d.statCount===u)return;let b={},w=Sht.get(n);w||(w=new Set(n),Sht.set(n,w));for(let _ of n)r[_]&&(b[_]=r[_]);for(let[_,x]of Object.entries(r))w.has(_)||(b[_]=x);for(let _ of Object.keys(r))delete r[_];Object.assign(r,b),Eht.set(s,{orderedStatNames:n,statCount:u})}var NHt,FHt,Eht,Sht,MLe,wce,TLe=Ve(()=>{Kj();NHt="GPU Time and Memory",FHt=["Adapter","GPU","GPU Type","GPU Backend","Frame Rate","CPU Time","GPU Time","GPU Memory","Buffer Memory","Texture Memory","External Buffer Memory","External Texture Memory","Swap Chain Texture"],Eht=new WeakMap,Sht=new WeakMap,MLe=class{stats=new Map;getStats(n){return this.get(n)}get(n){this.stats.has(n)||this.stats.set(n,new xb({id:n}));let r=this.stats.get(n);return n===NHt&&UHt(r,FHt),r}},wce=new MLe});var zHt,Mht,CLe,UD,Tht=Ve(()=>{SLe();TLe();sg();zHt="set luma.log.level=1 (or higher) to trace rendering",Mht="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",CLe=class s{static defaultProps={...bce,type:"best-available",adapters:void 0,waitForPageLoad:!0};stats=wce;log=Qt;VERSION="9.4.2";spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw Qt.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),Qt.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");Qt.error("This version of luma.gl has already been initialized")()}Qt.log(1,`${this.VERSION} - ${zHt}`)(),globalThis.luma=this}async createDevice(n={}){let r={...s.defaultProps,...n},c=this.selectAdapter(r.type,r.adapters);if(!c)throw new Error(Mht);return r.waitForPageLoad&&await c.pageLoaded,await c.create(r)}async attachDevice(n,r){let c=this._getTypeFromHandle(n,r.adapters),u=c&&this.selectAdapter(c,r.adapters);if(!u)throw new Error(Mht);return await u?.attach?.(n,r)}registerAdapters(n){for(let r of n)this.preregisteredAdapters.set(r.type,r)}getSupportedAdapters(n=[]){let r=this._getAdapterMap(n);return Array.from(r).map(([,c])=>c).filter(c=>c.isSupported?.()).map(c=>c.type)}getBestAvailableAdapterType(n=[]){let r=["webgpu","webgl","null"],c=this._getAdapterMap(n);for(let u of r)if(c.get(u)?.isSupported?.())return u;return null}selectAdapter(n,r=[]){let c=n;n==="best-available"&&(c=this.getBestAvailableAdapterType(r));let u=this._getAdapterMap(r);return c&&u.get(c)||null}enforceWebGL2(n=!0,r=[]){let u=this._getAdapterMap(r).get("webgl");u||Qt.warn("enforceWebGL2: webgl adapter not found")(),u?.enforceWebGL2?.(n)}setDefaultDeviceProps(n){Object.assign(s.defaultProps,n)}_getAdapterMap(n=[]){let r=new Map(this.preregisteredAdapters);for(let c of n)r.set(c.type,c);return r}_getTypeFromHandle(n,r=[]){return n instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&n instanceof GPUDevice||n?.queue?"webgpu":n===null?"null":(n instanceof WebGLRenderingContext?Qt.warn("WebGL1 is not supported",n)():Qt.warn("Unknown handle type",n)(),null)}},UD=new CLe});function $Ht(){return vce||(jHt()||typeof window>"u"?vce=Promise.resolve():vce=new Promise(s=>window.addEventListener("load",()=>s()))),vce}var u$,GHt,jHt,vce,Cht=Ve(()=>{VL();u$=class{get pageLoaded(){return $Ht()}},GHt=D1()&&typeof document<"u",jHt=()=>GHt&&document.readyState==="complete",vce=null});function $y(s="id"){ALe[s]=ALe[s]||1;let n=ALe[s]++;return`${s}-${n}`}var ALe,zD=Ve(()=>{ALe={}});function YHt(s,n){let r={...n};for(let c in s)s[c]!==void 0&&(r[c]=s[c]);return r}function Iht(s,n){let r=s.stats,c=!1;for(let _ of n)r[_]||(s.get(_),c=!0);let u=Object.keys(r).length,d=kht.get(s);if(!c&&d?.orderedStatNames===n&&d.statCount===u)return;let b={},w=Rht.get(n);w||(w=new Set(n),Rht.set(n,w));for(let _ of n)r[_]&&(b[_]=r[_]);for(let[_,x]of Object.entries(r))w.has(_)||(b[_]=x);for(let _ of Object.keys(r))delete r[_];Object.assign(r,b),kht.set(s,{orderedStatNames:n,statCount:u})}function Dht(s){return s.type==="webgl"?XHt:qHt}function f$(s){let n=s.userData[VHt];return n?.enabled?n:null}function OM(){return globalThis.performance?.now?.()??Date.now()}function ZHt(s,n){let r=f$(s);if(!(!r||!r.activeDefaultFramebufferAcquireDepth))switch(r.transientCanvasResourceCreates=(r.transientCanvasResourceCreates||0)+1,n){case"Texture":r.transientCanvasTextureCreates=(r.transientCanvasTextureCreates||0)+1;break;case"TextureView":r.transientCanvasTextureViewCreates=(r.transientCanvasTextureViewCreates||0)+1;break;case"Sampler":r.transientCanvasSamplerCreates=(r.transientCanvasSamplerCreates||0)+1;break;case"Framebuffer":r.transientCanvasFramebufferCreates=(r.transientCanvasFramebufferCreates||0)+1;break;default:break}}function KHt(s){let n=Object.getPrototypeOf(s);for(;n;){let r=Object.getPrototypeOf(n);if(!r||r===is.prototype)return JHt(n)||s[Symbol.toStringTag]||s.constructor.name;n=r}return s[Symbol.toStringTag]||s.constructor.name}function JHt(s){let n=Object.getOwnPropertyDescriptor(s,Symbol.toStringTag);return typeof n?.get=="function"?n.get.call(s):typeof n?.value=="string"?n.value:null}var VHt,Aht,Pht,Lht,WHt,HHt,qHt,XHt,kht,Rht,is,Gh=Ve(()=>{zD();VHt="cpu-hotspot-profiler",Aht="GPU Resource Counts",Pht="Resource Counts",Lht="GPU Time and Memory",WHt=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","RenderBundleEncoders","RenderBundles","ComputePasss","CommandEncoders","CommandBuffers"],HHt=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","SharedRenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","RenderBundleEncoders","RenderBundles","ComputePasss","CommandEncoders","CommandBuffers"],qHt=WHt.flatMap(s=>[`${s} Created`,`${s} Active`]),XHt=HHt.flatMap(s=>[`${s} Created`,`${s} Active`]),kht=new WeakMap,Rht=new WeakMap,is=class{static defaultProps={id:"undefined",handle:void 0,_isHandleBorrowed:!1,userData:void 0};toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}toJSON(){return this.toString()}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;allocatedBytesName=null;_attachedResources=new Set;get ownsHandle(){return(this.props.handle===void 0||this.props.handle===null)&&!this.isHandleBorrowed}get isHandleBorrowed(){return!!this.props._isHandleBorrowed}constructor(n,r,c){if(!n)throw new Error("no device");this._device=n,this.props=YHt(r,c);let u=this.props.id!=="undefined"?this.props.id:$y(this[Symbol.toStringTag]);this.props.id=u,this.id=u,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyed||this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(n){this._attachedResources.add(n)}detachResource(n){this._attachedResources.delete(n)}destroyAttachedResource(n){this._attachedResources.delete(n)&&n.destroy()}destroyAttachedResources(){for(let n of this._attachedResources)n.destroy();this._attachedResources=new Set}destroyResource(){this.destroyed||(this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0)}removeStats(){let n=f$(this._device),r=n?OM():0,c=[this._device.statsManager.getStats(Aht),this._device.statsManager.getStats(Pht)],u=Dht(this._device);for(let b of c)Iht(b,u);let d=this.getStatsName();for(let b of c)b.get("Resources Active").decrementCount(),b.get(`${d}s Active`).decrementCount();n&&(n.statsBookkeepingCalls=(n.statsBookkeepingCalls||0)+1,n.statsBookkeepingTimeMs=(n.statsBookkeepingTimeMs||0)+(OM()-r))}trackAllocatedMemory(n,r=this.getStatsName()){let c=f$(this._device),u=c?OM():0,d=this._device.statsManager.getStats(Lht);this.allocatedBytes>0&&this.allocatedBytesName&&(d.get("GPU Memory").subtractCount(this.allocatedBytes),d.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes)),d.get("GPU Memory").addCount(n),d.get(`${r} Memory`).addCount(n),c&&(c.statsBookkeepingCalls=(c.statsBookkeepingCalls||0)+1,c.statsBookkeepingTimeMs=(c.statsBookkeepingTimeMs||0)+(OM()-u)),this.allocatedBytes=n,this.allocatedBytesName=r}trackReferencedMemory(n,r=this.getStatsName()){this.trackAllocatedMemory(n,`External ${r}`)}trackDeallocatedMemory(n=this.getStatsName()){if(this.allocatedBytes===0){this.allocatedBytesName=null;return}let r=f$(this._device),c=r?OM():0,u=this._device.statsManager.getStats(Lht);u.get("GPU Memory").subtractCount(this.allocatedBytes),u.get(`${this.allocatedBytesName||n} Memory`).subtractCount(this.allocatedBytes),r&&(r.statsBookkeepingCalls=(r.statsBookkeepingCalls||0)+1,r.statsBookkeepingTimeMs=(r.statsBookkeepingTimeMs||0)+(OM()-c)),this.allocatedBytes=0,this.allocatedBytesName=null}trackDeallocatedReferencedMemory(n=this.getStatsName()){this.trackDeallocatedMemory(`Referenced ${n}`)}addStats(){let n=this.getStatsName(),r=f$(this._device),c=r?OM():0,u=[this._device.statsManager.getStats(Aht),this._device.statsManager.getStats(Pht)],d=Dht(this._device);for(let b of u)Iht(b,d);for(let b of u)b.get("Resources Created").incrementCount(),b.get("Resources Active").incrementCount(),b.get(`${n}s Created`).incrementCount(),b.get(`${n}s Active`).incrementCount();r&&(r.statsBookkeepingCalls=(r.statsBookkeepingCalls||0)+1,r.statsBookkeepingTimeMs=(r.statsBookkeepingTimeMs||0)+(OM()-c)),ZHt(this._device,n)}getStatsName(){return KHt(this)}}});var cs,_ce=Ve(()=>{Gh();cs=class s extends is{static INDEX=16;static VERTEX=32;static UNIFORM=64;static STORAGE=128;static INDIRECT=256;static QUERY_RESOLVE=512;static MAP_READ=1;static MAP_WRITE=2;static COPY_SRC=4;static COPY_DST=8;get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(n,r){let c={...r};(r.usage||0)&s.INDEX&&!r.indexType&&(r.data instanceof Uint32Array?c.indexType="uint32":r.data instanceof Uint16Array?c.indexType="uint16":r.data instanceof Uint8Array&&(c.indexType="uint8")),delete c.data,super(n,c,s.defaultProps),this.usage=c.usage||0,this.indexType=c.indexType,this.updateTimestamp=n.incrementTimestamp()}clone(n){return this.device.createBuffer({...this.props,...n})}static DEBUG_DATA_MAX_LENGTH=32;debugData=new ArrayBuffer(0);_setDebugData(n,r,c){if(!this.device.props.debug)return;let u=null,d;ArrayBuffer.isView(n)?(u=n,d=n.buffer):d=n;let b=Math.min(n?n.byteLength:c,s.DEBUG_DATA_MAX_LENGTH);if(d===null)this.debugData=new ArrayBuffer(b);else{let w=Math.min(u?.byteOffset||0,d.byteLength),_=Math.max(0,d.byteLength-w),x=Math.min(b,_);this.debugData=new Uint8Array(d,w,x).slice().buffer}}static defaultProps={...is.defaultProps,handle:void 0,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0}}});function Bht(){return PLe??Uint16Array}function Oht(s){return!!(PLe&&s===PLe)}var PLe,Nht=Ve(()=>{PLe=globalThis.Float16Array});function Fht(s){let n=s.includes("norm"),r=!n&&!s.startsWith("float"),c=s.startsWith("s"),u=LLe[s],[d,b,w]=u||["uint8 ","i32",1];return{signedType:d,primitiveType:b,byteLength:w,normalized:n,integer:r,signed:c}}function Uht(s){let n=s;switch(n){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return n}}function Sb(s,n){switch(n){case 1:return s;case 2:return s+s%2;default:return s+(4-s%4)%4}}function yce(s){let n=ArrayBuffer.isView(s)?s.constructor:s;if(Oht(n))return"float16";if(n===Uint8ClampedArray)return"uint8";let r=Object.values(LLe).find(c=>n===c[4]);if(!r)throw new Error(n.name);return r[0]}function zht(s){return yce(s)}function KL(s){if(s==="float16")return Bht();let n=LLe[s];if(!n)throw new Error(s);let[,,,,r]=n;return r}function JL(s){return KL(s)}var LLe,xce=Ve(()=>{Nht();LLe={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]}});var kLe,Md,Ece=Ve(()=>{xce();kLe=class{getDataTypeInfo(n){return Fht(n)}getNormalizedDataType(n){return Uht(n)}alignTo(n,r){return Sb(n,r)}getDataType(n){return zht(n)}getTypedArrayConstructor(n){return JL(n)}},Md=new kLe});function QHt(s,n){try{return Md.getDataTypeInfo(n)}catch{throw new Error(`Unsupported vertex format: ${s}`)}}function eqt(s,n){if(!n)return 1;let r=Number(n);if(r===2||r===3||r===4)return r;throw new Error(`Unsupported vertex format: ${s}`)}function tqt(s,n,r){if(r!==3)throw new Error(`Unsupported vertex format: ${s}`);switch(n){case"uint8":case"sint8":case"unorm8":case"snorm8":case"uint16":case"sint16":case"unorm16":case"snorm16":return`${n}x3-webgl`;default:throw new Error(`Unsupported vertex format: ${s}`)}}var RLe,hl,h$=Ve(()=>{Ece();RLe=class{getVertexFormatInfo(n){if(n==="unorm10-10-10-2")return{type:"unorm8",components:4,byteLength:4,integer:!1,signed:!1,normalized:!0};let r=n==="unorm8x4-bgra"?"unorm8x4":n,c;r.endsWith("-webgl")&&(r=r.slice(0,-6),c=!0);let u=r.split("x");if(u.length>2)throw new Error(`Unsupported vertex format: ${n}`);let[d,b]=u,w=d,_=eqt(n,b),x=QHt(n,w),T;try{T=c?tqt(n,w,_):this.makeVertexFormat(x.signedType,_,x.normalized)}catch{throw new Error(`Unsupported vertex format: ${n}`)}if(T!==(c?n:r))throw new Error(`Unsupported vertex format: ${n}`);let M={type:w,components:_,byteLength:x.byteLength*_,integer:x.integer,signed:x.signed,normalized:x.normalized};return c&&(M.webglOnly=!0),M}makeVertexFormat(n,r,c){let u=c?Md.getNormalizedDataType(n):n;switch(u){case"unorm8":return r===1?"unorm8":r===3?"unorm8x3-webgl":`${u}x${r}`;case"snorm8":return r===1?"snorm8":r===3?"snorm8x3-webgl":`${u}x${r}`;case"uint8":case"sint8":if(r===3)throw new Error(`size: ${r}`);return r===1?u:`${u}x${r}`;case"uint16":return r===1?"uint16":r===3?"uint16x3-webgl":`${u}x${r}`;case"sint16":return r===1?"sint16":r===3?"sint16x3-webgl":`${u}x${r}`;case"unorm16":return r===1?"unorm16":r===3?"unorm16x3-webgl":`${u}x${r}`;case"snorm16":return r===1?"snorm16":r===3?"snorm16x3-webgl":`${u}x${r}`;case"float16":if(r===3)throw new Error(`size: ${r}`);return r===1?u:`${u}x${r}`;default:return r===1?u:`${u}x${r}`}}getVertexFormatFromAttribute(n,r,c){if(!r||r>4)throw new Error(`size ${r}`);let u=r,d=Md.getDataType(n);return this.makeVertexFormat(d,u,c)}getCompatibleVertexFormat(n){let r;switch(n.primitiveType){case"f32":r="float32";break;case"i32":r="sint32";break;case"u32":r="uint32";break;case"f16":return n.components<=2?"float16x2":"float16x4"}return n.components===1?r:`${r}x${n.components}`}},hl=new RLe});function Cce(s){let n=$ht[s];if(!n)throw new Error(`Unsupported texture format ${s}`);return n}function jht(){return $ht}var ap,Tc,Vy,nqt,Sce,ILe,Mce,DLe,iqt,BLe,NM,OLe,NLe,Tce,Ght,rqt,sqt,$ht,FLe=Ve(()=>{ap="texture-compression-bc",Tc="texture-compression-astc",Vy="texture-compression-etc2",nqt="texture-compression-etc1-webgl",Sce="texture-compression-pvrtc-webgl",ILe="texture-compression-atc-webgl",Mce="float32-renderable-webgl",DLe="float16-renderable-webgl",iqt="rgb9e5ufloat-renderable-webgl",BLe="snorm8-renderable-webgl",NM="norm16-webgl",OLe="norm16-renderable-webgl",NLe="snorm16-renderable-webgl",Tce="float32-filterable",Ght="float16-filterable-webgl";rqt={r8unorm:{webgpu:527},rg8unorm:{webgpu:527},"rgb8unorm-webgl":{},rgba8unorm:{webgpu:31},"rgba8unorm-srgb":{webgpu:15},r8snorm:{render:BLe,webgpu:837},rg8snorm:{render:BLe,webgpu:837},"rgb8snorm-webgl":{},rgba8snorm:{render:BLe,webgpu:341},r8uint:{webgpu:515},rg8uint:{webgpu:515},rgba8uint:{webgpu:19},r8sint:{webgpu:515},rg8sint:{webgpu:515},rgba8sint:{webgpu:19},bgra8unorm:{webgpu:15},"bgra8unorm-srgb":{webgpu:15360},r16unorm:{f:NM,render:OLe,webgpu:992},rg16unorm:{f:NM,render:OLe,webgpu:992},"rgb16unorm-webgl":{f:NM,render:!1},rgba16unorm:{f:NM,render:OLe,webgpu:992},r16snorm:{f:NM,render:NLe,webgpu:992},rg16snorm:{f:NM,render:NLe,webgpu:992},"rgb16snorm-webgl":{f:NM,render:!1},rgba16snorm:{f:NM,render:NLe,webgpu:992},r16uint:{webgpu:515},rg16uint:{webgpu:515},rgba16uint:{webgpu:19},r16sint:{webgpu:515},rg16sint:{webgpu:515},rgba16sint:{webgpu:19},r16float:{render:DLe,filter:"float16-filterable-webgl",webgpu:527},rg16float:{render:DLe,filter:Ght,webgpu:527},rgba16float:{render:DLe,filter:Ght,webgpu:31},r32uint:{webgpu:19},rg32uint:{webgpu:16387},rgba32uint:{webgpu:19},r32sint:{webgpu:19},rg32sint:{webgpu:16387},rgba32sint:{webgpu:19},r32float:{render:Mce,filter:Tce,webgpu:19},rg32float:{render:!1,filter:Tce,webgpu:16387},"rgb32float-webgl":{render:Mce,filter:Tce},rgba32float:{render:Mce,filter:Tce,webgpu:19},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:iqt,webgpu:5},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:Mce,webgpu:517},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:527},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:515},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8",webgpu:3},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16",webgpu:3},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32",webgpu:3},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32",webgpu:3},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0,webgpu:3},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0,f:"depth32float-stencil8",webgpu:3}},sqt={"bc1-rgb-unorm-webgl":{f:ap},"bc1-rgb-unorm-srgb-webgl":{f:ap},"bc1-rgba-unorm":{f:ap},"bc1-rgba-unorm-srgb":{f:ap},"bc2-rgba-unorm":{f:ap},"bc2-rgba-unorm-srgb":{f:ap},"bc3-rgba-unorm":{f:ap},"bc3-rgba-unorm-srgb":{f:ap},"bc4-r-unorm":{f:ap},"bc4-r-snorm":{f:ap},"bc5-rg-unorm":{f:ap},"bc5-rg-snorm":{f:ap},"bc6h-rgb-ufloat":{f:ap},"bc6h-rgb-float":{f:ap},"bc7-rgba-unorm":{f:ap},"bc7-rgba-unorm-srgb":{f:ap},"etc2-rgb8unorm":{f:Vy},"etc2-rgb8unorm-srgb":{f:Vy},"etc2-rgb8a1unorm":{f:Vy},"etc2-rgb8a1unorm-srgb":{f:Vy},"etc2-rgba8unorm":{f:Vy},"etc2-rgba8unorm-srgb":{f:Vy},"eac-r11unorm":{f:Vy},"eac-r11snorm":{f:Vy},"eac-rg11unorm":{f:Vy},"eac-rg11snorm":{f:Vy},"astc-4x4-unorm":{f:Tc},"astc-4x4-unorm-srgb":{f:Tc},"astc-5x4-unorm":{f:Tc},"astc-5x4-unorm-srgb":{f:Tc},"astc-5x5-unorm":{f:Tc},"astc-5x5-unorm-srgb":{f:Tc},"astc-6x5-unorm":{f:Tc},"astc-6x5-unorm-srgb":{f:Tc},"astc-6x6-unorm":{f:Tc},"astc-6x6-unorm-srgb":{f:Tc},"astc-8x5-unorm":{f:Tc},"astc-8x5-unorm-srgb":{f:Tc},"astc-8x6-unorm":{f:Tc},"astc-8x6-unorm-srgb":{f:Tc},"astc-8x8-unorm":{f:Tc},"astc-8x8-unorm-srgb":{f:Tc},"astc-10x5-unorm":{f:Tc},"astc-10x5-unorm-srgb":{f:Tc},"astc-10x6-unorm":{f:Tc},"astc-10x6-unorm-srgb":{f:Tc},"astc-10x8-unorm":{f:Tc},"astc-10x8-unorm-srgb":{f:Tc},"astc-10x10-unorm":{f:Tc},"astc-10x10-unorm-srgb":{f:Tc},"astc-12x10-unorm":{f:Tc},"astc-12x10-unorm-srgb":{f:Tc},"astc-12x12-unorm":{f:Tc},"astc-12x12-unorm-srgb":{f:Tc},"pvrtc-rgb4unorm-webgl":{f:Sce},"pvrtc-rgba4unorm-webgl":{f:Sce},"pvrtc-rgb2unorm-webgl":{f:Sce},"pvrtc-rgba2unorm-webgl":{f:Sce},"etc1-rbg-unorm-webgl":{f:nqt},"atc-rgb-unorm-webgl":{f:ILe},"atc-rgba-unorm-webgl":{f:ILe},"atc-rgbai-unorm-webgl":{f:ILe}},$ht={...rqt,...sqt}});function fqt({format:s,width:n,height:r,depth:c,byteAlignment:u}){let d=og.getInfo(s),{bytesPerPixel:b,bytesPerBlock:w=b,blockWidth:_=1,blockHeight:x=1,compressed:T=!1}=d,M=T?Math.ceil(n/_):n,L=T?Math.ceil(r/x):r,I=M*w,D=Math.ceil(I/u)*u,F=L,O=D*F*c;return{bytesPerPixel:b,bytesPerRow:D,rowsPerImage:F,depthOrArrayLayers:c,bytesPerImage:D*F,byteLength:O}}function hqt(s){let n=Cce(s),r={format:s,create:n.f??!0,render:n.render??!0,filter:n.filter??!0,blend:n.blend??!0,store:n.store??!0},c=Vht(s),u=s.startsWith("depth")||s.startsWith("stencil"),d=c?.signed,b=c?.integer,w=c?.webgl,_=!!c?.compressed;return r.render&&=!u&&!_,r.filter&&=!u&&!d&&!b&&!w,r}function Vht(s){let n=dqt(s);if(og.isCompressed(s)){n.channels="rgb",n.components=3,n.bytesPerPixel=1,n.srgb=!1,n.compressed=!0,n.bytesPerBlock=gqt(s);let c=pqt(s);c&&(n.blockWidth=c.blockWidth,n.blockHeight=c.blockHeight)}let r=n.packed?null:oqt.exec(s);if(r){let[,c,u,d,b,w]=r,_=`${d}${u}`,x=Md.getDataTypeInfo(_),T=x.byteLength*8,M=c?.length??1,L=[T,M>=2?T:0,M>=3?T:0,M>=4?T:0];n={format:s,attachment:n.attachment,dataType:x.signedType,components:M,channels:c,integer:x.integer,signed:x.signed,normalized:x.normalized,bitsPerChannel:L,bytesPerPixel:x.byteLength*M,packed:n.packed,srgb:n.srgb},w==="-webgl"&&(n.webgl=!0),b==="-srgb"&&(n.srgb=!0)}return s.endsWith("-webgl")&&(n.webgl=!0),s.endsWith("-srgb")&&(n.srgb=!0),n}function dqt(s){let n={...Cce(s)},r=n.bytesPerPixel||1,c=n.bitsPerChannel||[8,8,8,8];return delete n.bitsPerChannel,delete n.bytesPerPixel,delete n.f,delete n.render,delete n.filter,delete n.blend,delete n.store,delete n.webgpu,{...n,format:s,attachment:n.attachment||"color",channels:n.channels||"r",components:n.components||n.channels?.length||1,bytesPerPixel:r,bitsPerChannel:c,dataType:n.dataType||"uint8",srgb:n.srgb??!1,packed:n.packed??!1,webgl:n.webgl??!1,integer:n.integer??!1,signed:n.signed??!1,normalized:n.normalized??!1,compressed:n.compressed??!1}}function pqt(s){let r=/.*-(\d+)x(\d+)-.*/.exec(s);if(r){let[,c,u]=r;return{blockWidth:Number(c),blockHeight:Number(u)}}return s.startsWith("bc")||s.startsWith("etc1")||s.startsWith("etc2")||s.startsWith("eac")||s.startsWith("atc")?{blockWidth:4,blockHeight:4}:s.startsWith("pvrtc-rgb4")||s.startsWith("pvrtc-rgba4")?{blockWidth:4,blockHeight:4}:s.startsWith("pvrtc-rgb2")||s.startsWith("pvrtc-rgba2")?{blockWidth:8,blockHeight:4}:null}function gqt(s){return s.startsWith("bc1")||s.startsWith("bc4")||s.startsWith("etc1")||s.startsWith("etc2-rgb8")||s.startsWith("etc2-rgb8a1")||s.startsWith("eac-r11")||s==="atc-rgb-unorm-webgl"?8:s.startsWith("bc2")||s.startsWith("bc3")||s.startsWith("bc5")||s.startsWith("bc6h")||s.startsWith("bc7")||s.startsWith("etc2-rgba8")||s.startsWith("eac-rg11")||s.startsWith("astc")||s==="atc-rgba-unorm-webgl"||s==="atc-rgbai-unorm-webgl"?16:s.startsWith("pvrtc")?8:16}var oqt,aqt,cqt,lqt,uqt,ULe,og,Ace=Ve(()=>{Ece();FLe();oqt=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,aqt=["rgb","rgba","bgra"],cqt=["depth","stencil"],lqt=5,uqt=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],ULe=class{isColor(n){return aqt.some(r=>n.startsWith(r))}isDepthStencil(n){return cqt.some(r=>n.startsWith(r))}isCompressed(n){return uqt.some(r=>n.startsWith(r))}getInfo(n){return Vht(n)}getCapabilities(n){return hqt(n)}getWebGPUCapabilities(n){let r=Cce(n);return r.webgpu!==void 0?r.webgpu:this.isCompressed(n)&&!n.endsWith("-webgl")?lqt:0}computeMemoryLayout(n){return fqt(n)}},og=new ULe});function Wht(s){return typeof ImageData<"u"&&s instanceof ImageData||typeof ImageBitmap<"u"&&s instanceof ImageBitmap||typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&s instanceof HTMLVideoElement||typeof VideoFrame<"u"&&s instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas}function Hht(s){if(typeof ImageData<"u"&&s instanceof ImageData||typeof ImageBitmap<"u"&&s instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas)return{width:s.width,height:s.height};if(typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement)return{width:s.naturalWidth,height:s.naturalHeight};if(typeof HTMLVideoElement<"u"&&s instanceof HTMLVideoElement)return{width:s.videoWidth,height:s.videoHeight};if(typeof VideoFrame<"u"&&s instanceof VideoFrame)return{width:s.displayWidth,height:s.displayHeight};throw new Error("Unknown image type")}var qht=Ve(()=>{});function mqt(s,n){let r=zLe(s),c=n.map(zLe).filter(u=>u!==void 0);return[r,...c].filter(u=>u!==void 0)}function zLe(s){if(s!==void 0){if(s===null||typeof s=="string"||typeof s=="number"||typeof s=="boolean")return s;if(s instanceof Error)return s.message;if(Array.isArray(s))return s.map(zLe);if(typeof s=="object"){if(bqt(s)){let n=String(s);if(n!=="[object Object]")return n}return wqt(s)?vqt(s):s.constructor?.name||"Object"}return String(s)}}function bqt(s){return"toString"in s&&typeof s.toString=="function"&&s.toString!==Object.prototype.toString}function wqt(s){return"message"in s&&"type"in s}function vqt(s){let n=typeof s.type=="string"?s.type:"message",r=typeof s.message=="string"?s.message:"",c=typeof s.lineNum=="number"?s.lineNum:null,u=typeof s.linePos=="number"?s.linePos:null,d=c!==null&&u!==null?` @ ${c}:${u}`:c!==null?` @ ${c}`:"";return`${n}${d}: ${r}`.trim()}function GLe(){if(typeof HTMLCanvasElement>"u")return!1;let s=HTMLCanvasElement.prototype;return"layoutSubtree"in s&&typeof s.requestPaint=="function"}var d$,p$,A3,Xht=Ve(()=>{TLe();sg();zD();_ce();h$();Ace();qht();FLe();SLe();d$=class{};p$=class{features;disabledFeatures;constructor(n=[],r){this.features=new Set(n),this.disabledFeatures=r||{}}*[Symbol.iterator](){yield*this.features}has(n){return!this.disabledFeatures?.[n]&&this.features.has(n)}};A3=class s{static defaultProps={...bce};get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}toJSON(){return this.toString()}id;props;userData={};statsManager=wce;_factories={};timestamp=0;_reused=!1;_moduleData={};wgslLanguageFeatures=new Set;_textureCaps={};_debugGPUTimeQuery=null;constructor(n){this.props={...s.defaultProps,...n},this.id=this.props.id||$y(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(n){return hl.getVertexFormatInfo(n)}isVertexFormatSupported(n){return!0}getTextureFormatInfo(n){return og.getInfo(n)}getTextureFormatCapabilities(n){let r=this._textureCaps[n];if(!r){let c=this._getDeviceTextureFormatCapabilities(n);r=this._getDeviceSpecificTextureFormatCapabilities(c),this._textureCaps[n]=r}return r}getMipLevelCount(n,r,c=1){let u=Math.max(n,r,c);return 1+Math.floor(Math.log2(u))}isExternalImage(n){return Wht(n)}getExternalImageSize(n){return Hht(n)}isTextureFormatSupported(n){return this.getTextureFormatCapabilities(n).create}isTextureFormatFilterable(n){return this.getTextureFormatCapabilities(n).filter}isTextureFormatRenderable(n){return this.getTextureFormatCapabilities(n).render}isTextureFormatCompressed(n){return og.isCompressed(n)}getSupportedCompressedTextureFormats(){let n=[];for(let r of Object.keys(jht()))this.isTextureFormatCompressed(r)&&this.isTextureFormatSupported(r)&&n.push(r);return n}pushDebugGroup(n){this.commandEncoder.pushDebugGroup(n)}popDebugGroup(){this.commandEncoder?.popDebugGroup()}insertDebugMarker(n){this.commandEncoder?.insertDebugMarker(n)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(n,r,...c){if(!this.props.onError(n,r)){let d=mqt(r,c);return Qt.error(this.type==="webgl"?"%cWebGL":"%cWebGPU","color: white; background: red; padding: 2px 6px; border-radius: 3px;",n.message,...d)}return()=>{}}debug(){if(this.props.debug)debugger;else{let n=`'Type luma.log.set({debug: true}) in console to enable debug breakpoints', +or create a device with the 'debug: true' prop.`;Qt.once(0,n)()}}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}createFence(){throw new Error("createFence() not implemented")}beginRenderPass(n){return this.commandEncoder.beginRenderPass(n)}beginComputePass(n){return this.commandEncoder.beginComputePass(n)}writeBufferViaCommandEncoder(n,r,c,u=0){throw new Error("writeBufferViaCommandEncoder() not implemented")}generateMipmapsWebGPU(n){throw new Error("not implemented")}_createSharedRenderPipelineWebGL(n){throw new Error("_createSharedRenderPipelineWebGL() not implemented")}_createBindGroupLayoutWebGPU(n,r){throw new Error("_createBindGroupLayoutWebGPU() not implemented")}_createBindGroupWebGPU(n,r,c,u,d){throw new Error("_createBindGroupWebGPU() not implemented")}_supportsDebugGPUTime(){return this.features.has("timestamp-query")&&!!(this.props.debug||this.props.debugGPUTime)}_enableDebugGPUTime(n=256){if(!this._supportsDebugGPUTime())return null;if(this._debugGPUTimeQuery)return this._debugGPUTimeQuery;try{this._debugGPUTimeQuery=this.createQuerySet({type:"timestamp",count:n}),this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id,timeProfilingQuerySet:this._debugGPUTimeQuery})}catch{this._debugGPUTimeQuery=null}return this._debugGPUTimeQuery}_disableDebugGPUTime(){this._debugGPUTimeQuery&&(this.commandEncoder.getTimeProfilingQuerySet()===this._debugGPUTimeQuery&&(this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id})),this._debugGPUTimeQuery.destroy(),this._debugGPUTimeQuery=null)}_isDebugGPUTimeEnabled(){return this._debugGPUTimeQuery!==null}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(n,r){throw new Error("not implemented")}readPixelsToBufferWebGL(n,r){throw new Error("not implemented")}setParametersWebGL(n){throw new Error("not implemented")}getParametersWebGL(n){throw new Error("not implemented")}withParametersWebGL(n,r){throw new Error("not implemented")}clearWebGL(n){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}getModuleData(n){return this._moduleData[n]||={},this._moduleData[n]}static _getCanvasContextProps(n){return n.createCanvasContext===!0?{}:n.createCanvasContext}_getDeviceTextureFormatCapabilities(n){let r=og.getCapabilities(n),c=d=>(typeof d=="string"?this.features.has(d):d)??!0,u=c(r.create);return{format:n,create:u,render:u&&c(r.render),filter:u&&c(r.filter),blend:u&&c(r.blend),store:u&&c(r.store)}}_normalizeBufferProps(n){(n instanceof ArrayBuffer||ArrayBuffer.isView(n))&&(n={data:n});let r={...n};if((n.usage||0)&cs.INDEX&&(n.indexType||(n.data instanceof Uint32Array?r.indexType="uint32":n.data instanceof Uint16Array?r.indexType="uint16":n.data instanceof Uint8Array&&(r.data=new Uint16Array(n.data),r.indexType="uint16")),!r.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return r}}});var Pce,Yht=Ve(()=>{Pce=class{props;_resizeObserver;_intersectionObserver;_observeDevicePixelRatioTimeout=null;_observeDevicePixelRatioMediaQuery=null;_handleDevicePixelRatioChange=()=>this._refreshDevicePixelRatio();_trackPositionInterval=null;_started=!1;get started(){return this._started}constructor(n){this.props=n}start(){if(this._started||!this.props.canvas)return;this._started=!0,this._intersectionObserver||=new IntersectionObserver(r=>this.props.onIntersection(r)),this._resizeObserver||=new ResizeObserver(r=>this.props.onResize(r)),this._intersectionObserver.observe(this.props.canvas);let n=this.props.resizeObserverBox;try{this._resizeObserver.observe(this.props.canvas,{box:n})}catch{this._resizeObserver.observe(this.props.canvas,{box:"content-box"})}this._observeDevicePixelRatioTimeout=setTimeout(()=>this._refreshDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}stop(){this._started&&(this._started=!1,this._observeDevicePixelRatioTimeout&&(clearTimeout(this._observeDevicePixelRatioTimeout),this._observeDevicePixelRatioTimeout=null),this._observeDevicePixelRatioMediaQuery&&(this._observeDevicePixelRatioMediaQuery.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=null),this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null),this._resizeObserver?.disconnect(),this._intersectionObserver?.disconnect())}_refreshDevicePixelRatio(){this._started&&(this.props.onDevicePixelRatioChange(),this._observeDevicePixelRatioMediaQuery?.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._observeDevicePixelRatioMediaQuery.addEventListener("change",this._handleDevicePixelRatioChange,{once:!0}))}_trackPosition(n=100){this._trackPositionInterval||(this._trackPositionInterval=setInterval(()=>{this._started?this.props.onPositionChange():this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null)},n))}}});function Zht(){let s,n;return{promise:new Promise((c,u)=>{s=c,n=u}),resolve:s,reject:n}}var Kht=Ve(()=>{});function FM(s,n){if(!s){let r=new Error(n??"luma.gl assertion failed.");throw Error.captureStackTrace?.(r,FM),r}}function UM(s,n){return FM(s,n),s}var jLe=Ve(()=>{});function _qt(s){if(typeof s=="string"){let n=document.getElementById(s);if(!n)throw new Error(`${s} is not an HTML element`);return n}return s||document.body}function yqt(s){let n=document.getElementById(s);if(!zM.isHTMLCanvas(n))throw new Error("Object is not a canvas element");return n}function xqt(s){let{width:n,height:r}=s,c=document.createElement("canvas");c.id=$y("lumagl-auto-created-canvas"),c.width=n||1,c.height=r||1,c.style.width=Number.isFinite(n)?`${n}px`:"100%",c.style.height=Number.isFinite(r)?`${r}px`:"100%",s?.visible||(c.style.visibility="hidden");let u=_qt(s?.container||null);return u.insertBefore(c,u.firstChild),c}function Eqt(s,n,r,c,u){let d=s,b=Jht(d[0],n,r),w=Qht(d[1],n,c,u),_=Jht(d[0]+1,n,r),x=_===r-1?_:_-1;_=Qht(d[1]+1,n,c,u);let T;return u?(_=_===0?_:_+1,T=w,w=_):T=_===c-1?_:_-1,{x:b,y:w,width:Math.max(x-b+1,1),height:Math.max(T-w+1,1)}}function Jht(s,n,r){return Math.min(Math.round(s*n),r-1)}function Qht(s,n,r,c){return c?Math.max(0,r-1-Math.round(s*n)):Math.min(Math.round(s*n),r-1)}var zM,$Le=Ve(()=>{VL();Yht();zD();Kht();jLe();zM=class s{static isHTMLCanvas(n){return typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement}static isOffscreenCanvas(n){return typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas}static defaultProps={id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,pixelSizeSource:"exact",autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",colorFormat:void 0,toneMapping:"standard",trackPosition:!1};id;props;canvas;htmlCanvas;offscreenCanvas;type;initialized;isInitialized=!1;isVisible=!0;cssWidth;cssHeight;devicePixelRatio;devicePixelWidth;devicePixelHeight;drawingBufferWidth;drawingBufferHeight;_initializedResolvers=Zht();_canvasObserver;_position=[0,0];destroyed=!1;_needsDrawingBufferResize=!0;_configuredDrawingBufferSize=[0,0];toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(n){this.props={...s.defaultProps,...n},n=this.props,this.initialized=this._initializedResolvers.promise,D1()?n.canvas?typeof n.canvas=="string"?this.canvas=yqt(n.canvas):this.canvas=n.canvas:this.canvas=xqt(n):this.canvas={width:n.width||1,height:n.height||1},s.isHTMLCanvas(this.canvas)?(this.id=n.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):s.isOffscreenCanvas(this.canvas)?(this.id=n.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=n.id||"node-canvas-context",this.type="node"),this.cssWidth=this.htmlCanvas?.clientWidth||this.canvas.width,this.cssHeight=this.htmlCanvas?.clientHeight||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this._configuredDrawingBufferSize=[this.canvas.width,this.canvas.height],this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],this._canvasObserver=new Pce({canvas:this.htmlCanvas,trackPosition:this.props.trackPosition,resizeObserverBox:this.props.pixelSizeSource==="css-dpr"?"content-box":"device-pixel-content-box",onResize:r=>this._handleResize(r),onIntersection:r=>this._handleIntersection(r),onDevicePixelRatioChange:()=>this._observeDevicePixelRatio(),onPositionChange:()=>this.updatePosition()})}destroy(){this.destroyed||(this.destroyed=!0,this._stopObservers(),this.device=null)}setProps(n){return"useDevicePixels"in n&&(this.props.useDevicePixels=n.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCurrentFramebuffer(n){return this._resizeDrawingBufferIfNeeded(),this._getCurrentFramebuffer(n)}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){let n=this.device.limits.maxTextureDimension2D;return[n,n]}setDrawingBufferSize(n,r){n=Math.floor(n),r=Math.floor(r),!(this.drawingBufferWidth===n&&this.drawingBufferHeight===r)&&(this.drawingBufferWidth=n,this.drawingBufferHeight=r,this._needsDrawingBufferResize=!0)}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(n,r=!0){let c=this.cssToDeviceRatio(),[u,d]=this.getDrawingBufferSize();return Eqt(n,c,u,d,r)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){let[n,r]=this.getDrawingBufferSize();return n>0&&r>0?n/r:1}cssToDeviceRatio(){try{let[n]=this.getDrawingBufferSize(),[r]=this.getCSSSize();return r?n/r:1}catch{return 1}}resize(n){this.setDrawingBufferSize(n.width,n.height)}_setAutoCreatedCanvasId(n){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=n)}_startObservers(){this.destroyed||this._canvasObserver.start()}_stopObservers(){this._canvasObserver.stop()}_handleIntersection(n){if(this.destroyed)return;let r=n.find(u=>u.target===this.canvas);if(!r)return;let c=r.isIntersecting;this.isVisible!==c&&(this.isVisible=c,this.device.props.onVisibilityChange(this))}_handleResize(n){if(this.destroyed)return;let r=n.find(d=>d.target===this.canvas);if(!r)return;let c=UM(r.contentBoxSize?.[0]);this.cssWidth=c.inlineSize,this.cssHeight=c.blockSize;let u=this.getDevicePixelSize();this._setDevicePixelSize(this._getDevicePixelSizeFromResizeEntry(r)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:u})}_updateDrawingBufferSize(){if(this.props.autoResize)if(typeof this.props.useDevicePixels=="number"){let n=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*n,this.cssHeight*n)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_getDevicePixelSizeFromResizeEntry(n){let r=UM(n.contentBoxSize?.[0]);return this.props.pixelSizeSource==="css-dpr"?this._getDevicePixelSizeFromCSSSize(r.inlineSize,r.blockSize):{devicePixelWidth:n.devicePixelContentBoxSize?.[0]?.inlineSize||r.inlineSize*devicePixelRatio,devicePixelHeight:n.devicePixelContentBoxSize?.[0]?.blockSize||r.blockSize*devicePixelRatio}}_getDevicePixelSizeFromCSSSize(n,r){let c=this.getDevicePixelRatio();return{devicePixelWidth:Math.floor(n*c),devicePixelHeight:Math.floor(r*c)}}_setDevicePixelSize({devicePixelWidth:n,devicePixelHeight:r}){let[c,u]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(n,c)),this.devicePixelHeight=Math.max(1,Math.min(r,u))}_resizeDrawingBufferIfNeeded(){if(this._needsDrawingBufferResize){this._needsDrawingBufferResize=!1,(this.drawingBufferWidth!==this.canvas.width||this.drawingBufferHeight!==this.canvas.height)&&(this.canvas.width=this.drawingBufferWidth,this.canvas.height=this.drawingBufferHeight);let[r,c]=this._configuredDrawingBufferSize;(this.drawingBufferWidth!==r||this.drawingBufferHeight!==c)&&(this._configureDevice(),this._configuredDrawingBufferSize=[this.drawingBufferWidth,this.drawingBufferHeight])}}_observeDevicePixelRatio(){if(this.destroyed||!this._canvasObserver.started)return;let n=this.devicePixelRatio;if(this.devicePixelRatio=window.devicePixelRatio,this.props.pixelSizeSource==="css-dpr"){let r=this.getDevicePixelSize();this._setDevicePixelSize(this._getDevicePixelSizeFromCSSSize(this.cssWidth,this.cssHeight)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:r})}this.updatePosition(),this.device.props.onDevicePixelRatioChange?.(this,{oldRatio:n})}updatePosition(){if(this.destroyed)return;let n=this.htmlCanvas?.getBoundingClientRect();if(n){let r=[n.left,n.top];if(this._position??=r,r[0]!==this._position[0]||r[1]!==this._position[1]){let u=this._position;this._position=r,this.device.props.onPositionChange?.(this,{oldPosition:u})}}}}});var g$,edt=Ve(()=>{$Le();g$=class extends zM{static defaultProps=zM.defaultProps}});var m$,tdt=Ve(()=>{$Le();m$=class extends zM{}});var QL,VLe=Ve(()=>{Gh();QL=class s extends is{static defaultProps={...is.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1};get[Symbol.toStringTag](){return"Sampler"}constructor(n,r){r=s.normalizeProps(n,r),super(n,r,s.defaultProps)}static normalizeProps(n,r){return r}}});var Sqt,Pa,WLe=Ve(()=>{Gh();VLe();sg();Ace();Sqt={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},Pa=class s extends is{static SAMPLE=4;static STORAGE=8;static RENDER=16;static COPY_SRC=1;static COPY_DST=2;static TEXTURE=4;static RENDER_ATTACHMENT=16;dimension;baseDimension;format;width;height;depth;mipLevels;samples;byteAlignment;ready=Promise.resolve(this);isReady=!0;updateTimestamp;get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(n,r,c){if(r=s.normalizeProps(n,r),super(n,r,s.defaultProps),this.dimension=this.props.dimension,this.baseDimension=Sqt[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.samples=this.props.samples||1,this.dimension==="cube"&&(this.depth=6),this.props.width===void 0||this.props.height===void 0)if(n.isExternalImage(r.data)){let u=n.getExternalImageSize(r.data);this.width=u?.width||1,this.height=u?.height||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&Qt.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=c?.byteAlignment||1,this.updateTimestamp=n.incrementTimestamp()}clone(n){return this.device.createTexture({...this.props,...n})}setSampler(n){this.sampler=n instanceof QL?n:this.device.createSampler(n)}copyImageData(n){let{data:r,depth:c,...u}=n;this.writeData(r,{...u,depthOrArrayLayers:u.depthOrArrayLayers??c})}computeMemoryLayout(n={}){let r=this._normalizeTextureReadOptions(n),{width:c=this.width,height:u=this.height,depthOrArrayLayers:d=this.depth}=r,{format:b,byteAlignment:w}=this;return og.computeMemoryLayout({format:b,width:c,height:u,depth:d,byteAlignment:w})}readBuffer(n,r){throw new Error("readBuffer not implemented")}readDataAsync(n){throw new Error("readBuffer not implemented")}writeBuffer(n,r){throw new Error("readBuffer not implemented")}writeData(n,r){throw new Error("readBuffer not implemented")}readDataSyncWebGL(n){throw new Error("readDataSyncWebGL not available")}generateMipmapsWebGL(){throw new Error("generateMipmapsWebGL not available")}static normalizeProps(n,r){let c={...r},{width:u,height:d}=c;return typeof u=="number"&&(c.width=Math.max(1,Math.ceil(u))),typeof d=="number"&&(c.height=Math.max(1,Math.ceil(d))),c}_initializeData(n){this.device.isExternalImage(n)?this.copyExternalImage({image:n,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):n&&this.copyImageData({data:n,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(n){let{data:r,depth:c,...u}=n,d=this._normalizeTextureWriteOptions({...u,depthOrArrayLayers:u.depthOrArrayLayers??c});return{data:r,depth:d.depthOrArrayLayers,...d}}_normalizeCopyExternalImageOptions(n){let r=s._omitUndefined(n),c=r.mipLevel??0,u=this._getMipLevelSize(c),d=this.device.getExternalImageSize(n.image),b={...s.defaultCopyExternalImageOptions,...u,...d,...r};return b.width=Math.min(b.width,u.width-b.x),b.height=Math.min(b.height,u.height-b.y),b.depth=Math.min(b.depth,u.depthOrArrayLayers-b.z),b}_normalizeCopyElementImageOptions(n){let r=s._omitUndefined(n),c=r.mipLevel??0,u=this._getMipLevelSize(c),d={...s.defaultCopyElementImageOptions,...u,...r};return d.width=Math.min(d.width,u.width-d.x),d.height=Math.min(d.height,u.height-d.y),d.depth=Math.min(d.depth,u.depthOrArrayLayers-d.z),d}_normalizeTextureReadOptions(n){let r=s._omitUndefined(n),c=r.mipLevel??0,u=this._getMipLevelSize(c),d={...s.defaultTextureReadOptions,...u,...r};return d.width=Math.min(d.width,u.width-d.x),d.height=Math.min(d.height,u.height-d.y),d.depthOrArrayLayers=Math.min(d.depthOrArrayLayers,u.depthOrArrayLayers-d.z),d}_getSupportedColorReadOptions(n){let r=this._normalizeTextureReadOptions(n),c=og.getInfo(this.format);switch(this._validateColorReadAspect(r),this._validateColorReadFormat(c),this.dimension){case"2d":case"cube":case"cube-array":case"2d-array":case"3d":return r;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}}_validateColorReadAspect(n){if(n.aspect!=="all")throw new Error(`${this} color readback only supports aspect 'all'`)}_validateColorReadFormat(n){if(n.compressed)throw new Error(`${this} color readback does not support compressed formats (${this.format})`);switch(n.attachment){case"color":return;case"depth":throw new Error(`${this} color readback does not support depth formats (${this.format})`);case"stencil":throw new Error(`${this} color readback does not support stencil formats (${this.format})`);case"depth-stencil":throw new Error(`${this} color readback does not support depth-stencil formats (${this.format})`);default:throw new Error(`${this} color readback does not support format ${this.format}`)}}_normalizeTextureWriteOptions(n){let r=s._omitUndefined(n),c=r.mipLevel??0,u=this._getMipLevelSize(c),d={...s.defaultTextureWriteOptions,...u,...r};d.width=Math.min(d.width,u.width-d.x),d.height=Math.min(d.height,u.height-d.y),d.depthOrArrayLayers=Math.min(d.depthOrArrayLayers,u.depthOrArrayLayers-d.z);let b=og.computeMemoryLayout({format:this.format,width:d.width,height:d.height,depth:d.depthOrArrayLayers,byteAlignment:this.byteAlignment}),w=b.bytesPerPixel*d.width;if(d.bytesPerRow=r.bytesPerRow??b.bytesPerRow,d.rowsPerImage=r.rowsPerImage??d.height,d.bytesPerRow>n),c=this.baseDimension==="1d"?1:Math.max(1,this.height>>n),u=this.dimension==="3d"?Math.max(1,this.depth>>n):this.depth;return{width:r,height:c,depthOrArrayLayers:u}}getAllocatedByteLength(){let n=0;for(let r=0;rr!==void 0))}static defaultProps={...is.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:s.SAMPLE|s.RENDER|s.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0};static defaultCopyDataOptions={data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,width:void 0,height:void 0,depthOrArrayLayers:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all"};static defaultCopyExternalImageOptions={image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultCopyElementImageOptions={element:void 0,width:void 0,height:void 0,sourceX:0,sourceY:0,sourceWidth:void 0,sourceHeight:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultTextureReadOptions={x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"};static defaultTextureWriteOptions={byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"}}});var e4,ndt=Ve(()=>{Gh();e4=class s extends is{get[Symbol.toStringTag](){return"TextureView"}constructor(n,r){super(n,r,s.defaultProps)}static defaultProps={...is.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0}}});var b$,idt=Ve(()=>{Gh();b$=class s extends is{width;height;updateTimestamp;get[Symbol.toStringTag](){return"ExternalTexture"}constructor(n,r){super(n,r,s.defaultProps);let c=this.props.source?n.getExternalImageSize(this.props.source):null;this.width=this.props.width||c?.width||0,this.height=this.props.height||c?.height||0,this.updateTimestamp=n.incrementTimestamp()}static defaultProps={...is.defaultProps,source:void 0,width:0,height:0,colorSpace:"srgb",sampler:{}}}});function rdt(s,n,r){let c="",u=n.split(/\r?\n/),d=s.slice().sort((b,w)=>b.lineNum-w.lineNum);switch(r?.showSourceCode||"no"){case"all":let b=0;for(let w=1;w<=u.length;w++){let _=u[w-1],x=d[b];for(_&&x&&(c+=sdt(_,w,r));d.length>b&&x.lineNum===w;){let T=d[b++];T&&(c+=HLe(T,u,T.lineNum,{...r,inlineSource:!1}))}}for(;d.length>b;){let w=d[b++];w&&(c+=HLe(w,[],0,{...r,inlineSource:!1}))}return c;case"issues":case"no":for(let w of s)c+=HLe(w,u,w.lineNum,{inlineSource:r?.showSourceCode!=="no"});return c}}function HLe(s,n,r,c){if(c?.inlineSource){let d=Mqt(n,r),b=s.linePos>0?`${" ".repeat(s.linePos+5)}^^^ `:"";return` ${d}${b}${s.type.toUpperCase()}: ${s.message} -`}let u=s.type==="error"?"red":"orange";return c?.html?`
${s.type.toUpperCase()}: ${s.message}
`:`${s.type.toUpperCase()}: ${s.message}`}function xqt(s,n,r){let c="";for(let u=n-2;u<=n;u++){let d=s[u-1];d!==void 0&&(c+=sdt(d,n,r))}return c}function sdt(s,n,r){let c=r?.html?Sqt(s):s;return`${Eqt(String(n),4)}: ${c}${r?.html?"
":` -`}`}function Eqt(s,n){let r="";for(let c=s.length;c",">").replaceAll('"',""").replaceAll("'","'")}var odt=Ve(()=>{});function Mqt(s){return Tqt(s.source)||s.id||$y(`unnamed ${s.stage}-shader`)}function Tqt(s,n="unnamed"){return/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(s)?.[1]??n}var t4,qLe=Ve(()=>{Gh();sg();zD();odt();t4=class s extends is{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(n,r){r={...r,debugShaders:r.debugShaders||n.props.debugShaders||"errors"},super(n,{id:Mqt(r),...r},s.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(){let n=this.props.debugShaders;switch(n){case"never":return;case"errors":if(this.compilationStatus==="success")return;break;case"warnings":case"always":break}try{let r=await this.getCompilationInfo();if(n==="warnings"&&r?.length===0)return;this._displayShaderLog(r,this.id)}catch(r){Qt.warn(`Shader ${this.id}: failed to fetch compilation info during debug logging`,r)()}}_displayShaderLog(n,r){if(typeof document>"u"||!document?.createElement)return;let c=r,u=`${this.stage} shader "${c}"`,d=rdt(n,this.source,{showSourceCode:"all",html:!0}),b=this.getTranslatedSource(),w=document.createElement("div");w.innerHTML=`

Compilation error in ${u}

+`}let u=s.type==="error"?"red":"orange";return c?.html?`
${s.type.toUpperCase()}: ${s.message}
`:`${s.type.toUpperCase()}: ${s.message}`}function Mqt(s,n,r){let c="";for(let u=n-2;u<=n;u++){let d=s[u-1];d!==void 0&&(c+=sdt(d,n,r))}return c}function sdt(s,n,r){let c=r?.html?Cqt(s):s;return`${Tqt(String(n),4)}: ${c}${r?.html?"
":` +`}`}function Tqt(s,n){let r="";for(let c=s.length;c",">").replaceAll('"',""").replaceAll("'","'")}var odt=Ve(()=>{});function Aqt(s){return Pqt(s.source)||s.id||$y(`unnamed ${s.stage}-shader`)}function Pqt(s,n="unnamed"){return/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(s)?.[1]??n}var t4,qLe=Ve(()=>{Gh();sg();zD();odt();t4=class s extends is{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(n,r){r={...r,debugShaders:r.debugShaders||n.props.debugShaders||"errors"},super(n,{id:Aqt(r),...r},s.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(){let n=this.props.debugShaders;switch(n){case"never":return;case"errors":if(this.compilationStatus==="success")return;break;case"warnings":case"always":break}try{let r=await this.getCompilationInfo();if(n==="warnings"&&r?.length===0)return;this._displayShaderLog(r,this.id)}catch(r){Qt.warn(`Shader ${this.id}: failed to fetch compilation info during debug logging`,r)()}}_displayShaderLog(n,r){if(typeof document>"u"||!document?.createElement)return;let c=r,u=`${this.stage} shader "${c}"`,d=rdt(n,this.source,{showSourceCode:"all",html:!0}),b=this.getTranslatedSource(),w=document.createElement("div");w.innerHTML=`

Compilation error in ${u}


-
${d}
`,b&&(w.innerHTML+=`

Translated Source



${b}
`),w.style.top="0",w.style.left="0",w.style.background="white",w.style.position="fixed",w.style.zIndex="9999",w.style.maxWidth="100vw",w.style.maxHeight="100vh",w.style.overflowY="auto",document.body.appendChild(w),w.querySelector(".luma-compiler-log-error")?.scrollIntoView(),w.querySelector("button#close").onclick=()=>{w.remove()},w.querySelector("button#copy").onclick=()=>{navigator.clipboard.writeText(this.source)}}static defaultProps={...is.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0}}});var n4,adt=Ve(()=>{Gh();WLe();sg();n4=class s extends is{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(n,r={}){super(n,r,s.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(n){let r=this.colorAttachments.map(u=>u.texture.clone(n)),c=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(n);return this.device.createFramebuffer({...this.props,...n,colorAttachments:r,depthStencilAttachment:c})}resize(n){let r=!n;if(n){let[c,u]=Array.isArray(n)?n:[n.width,n.height];r=r||u!==this.height||c!==this.width,this.width=c,this.height=u}r&&(Qt.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map((r,c)=>{if(typeof r=="string"){let u=this.createColorTexture(r,c);return this.attachResource(u),u.view}return r instanceof Pa?r.view:r});let n=this.props.depthStencilAttachment;if(n)if(typeof n=="string"){let r=this.createDepthStencilTexture(n);this.attachResource(r),this.depthStencilAttachment=r.view}else n instanceof Pa?this.depthStencilAttachment=n.view:this.depthStencilAttachment=n}createColorTexture(n,r){return this.device.createTexture({id:`${this.id}-color-attachment-${r}`,usage:Pa.RENDER_ATTACHMENT,format:n,width:this.width,height:this.height,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(n){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:Pa.RENDER_ATTACHMENT|Pa.SAMPLE,format:n,width:this.width,height:this.height})}resizeAttachments(n,r){if(this.colorAttachments.forEach((c,u)=>{let d=c.texture.clone({width:n,height:r});this.destroyAttachedResource(c),this.colorAttachments[u]=d.view,this.attachResource(d.view)}),this.depthStencilAttachment){let c=this.depthStencilAttachment.texture.clone({width:n,height:r});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=c.view,this.attachResource(c)}this.updateAttachments()}static defaultProps={...is.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null}}});var Tb,XLe=Ve(()=>{Gh();Tb=class s extends is{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";sharedRenderPipeline=null;get isPending(){return this.linkStatus==="pending"||this.vs.compilationStatus==="pending"||this.fs?.compilationStatus==="pending"}get isErrored(){return this.linkStatus==="error"||this.vs.compilationStatus==="error"||this.fs?.compilationStatus==="error"}constructor(n,r){super(n,r,s.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[],this.sharedRenderPipeline=this.props._sharedRenderPipeline||null}static defaultProps={...is.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},varyings:void 0,bufferMode:void 0,disableWarnings:!1,_sharedRenderPipeline:void 0,_uniformBlockLayouts:[],bindings:void 0,bindGroups:void 0}}});var w$,cdt=Ve(()=>{Gh();w$=class extends is{get[Symbol.toStringTag](){return"SharedRenderPipeline"}constructor(n,r){super(n,r,{...is.defaultProps,handle:void 0,vs:void 0,fs:void 0,varyings:void 0,bufferMode:void 0})}}});var GM,YLe=Ve(()=>{Gh();GM=class s extends is{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(n,r){super(n,r,s.defaultProps),this.shaderLayout=r.shaderLayout}static defaultProps={...is.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0}}});var i4,ldt=Ve(()=>{YLe();XLe();sg();zD();i4=class s{static defaultProps={...Tb.defaultProps};static getDefaultPipelineFactory(n){let r=n.getModuleData("@luma.gl/core");return r.defaultPipelineFactory||=new s(n),r.defaultPipelineFactory}device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};_sharedRenderPipelineCache={};get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}constructor(n){this.device=n}createRenderPipeline(n){if(!this.device.props._cachePipelines)return this.device.createRenderPipeline(n);let r={...Tb.defaultProps,...n},c=this._renderPipelineCache,u=this._hashRenderPipeline(r),d=c[u]?.resource;if(d)c[u].useCount++,this.device.props.debugFactories&&Qt.log(3,`${this}: ${c[u].resource} reused, count=${c[u].useCount}, (id=${n.id})`)();else{let b=this.device.type==="webgl"&&this.device.props._sharePipelines?this.createSharedRenderPipeline(r):void 0;d=this.device.createRenderPipeline({...r,id:r.id?`${r.id}-cached`:$y("unnamed-cached"),_sharedRenderPipeline:b}),d.hash=u,c[u]={resource:d,useCount:1},this.device.props.debugFactories&&Qt.log(3,`${this}: ${d} created, count=${c[u].useCount}`)()}return d}createComputePipeline(n){if(!this.device.props._cachePipelines)return this.device.createComputePipeline(n);let r={...GM.defaultProps,...n},c=this._computePipelineCache,u=this._hashComputePipeline(r),d=c[u]?.resource;return d?(c[u].useCount++,this.device.props.debugFactories&&Qt.log(3,`${this}: ${c[u].resource} reused, count=${c[u].useCount}, (id=${n.id})`)()):(d=this.device.createComputePipeline({...r,id:r.id?`${r.id}-cached`:void 0}),d.hash=u,c[u]={resource:d,useCount:1},this.device.props.debugFactories&&Qt.log(3,`${this}: ${d} created, count=${c[u].useCount}`)()),d}release(n){if(!this.device.props._cachePipelines){n.destroy();return}let r=this._getCache(n),c=n.hash;r[c].useCount--,r[c].useCount===0?(this._destroyPipeline(n),this.device.props.debugFactories&&Qt.log(3,`${this}: ${n} released and destroyed`)()):r[c].useCount<0?(Qt.error(`${this}: ${n} released, useCount < 0, resetting`)(),r[c].useCount=0):this.device.props.debugFactories&&Qt.log(3,`${this}: ${n} released, count=${r[c].useCount}`)()}createSharedRenderPipeline(n){let r=this._hashSharedRenderPipeline(n),c=this._sharedRenderPipelineCache[r];return c||(c={resource:this.device._createSharedRenderPipelineWebGL(n),useCount:0},this._sharedRenderPipelineCache[r]=c),c.useCount++,c.resource}releaseSharedRenderPipeline(n){if(!n.sharedRenderPipeline)return;let r=this._hashSharedRenderPipeline(n.sharedRenderPipeline.props),c=this._sharedRenderPipelineCache[r];c&&(c.useCount--,c.useCount===0&&(c.resource.destroy(),delete this._sharedRenderPipelineCache[r]))}_destroyPipeline(n){let r=this._getCache(n);return this.device.props._destroyPipelines?(delete r[n.hash],n.destroy(),n instanceof Tb&&this.releaseSharedRenderPipeline(n),!0):!1}_getCache(n){let r;if(n instanceof GM&&(r=this._computePipelineCache),n instanceof Tb&&(r=this._renderPipelineCache),!r)throw new Error(`${this}`);if(!r[n.hash])throw new Error(`${this}: ${n} matched incorrect entry`);return r}_hashComputePipeline(n){let{type:r}=this.device,c=this._getHash(n.shader.source),u=this._getHash(JSON.stringify(n.shaderLayout));return`${r}/C/${c}SL${u}`}_hashRenderPipeline(n){let r=n.vs?this._getHash(n.vs.source):0,c=n.fs?this._getHash(n.fs.source):0,u=this._getWebGLVaryingHash(n),d=this._getHash(JSON.stringify(n.shaderLayout)),b=this._getHash(JSON.stringify(n._uniformBlockLayouts)),w=this._getHash(JSON.stringify(n.bufferLayout)),{type:_}=this.device;switch(_){case"webgl":let x=this._getHash(JSON.stringify(n.parameters));return`${_}/R/${r}/${c}V${u}T${n.topology}P${x}SL${d}UBL${b}BL${w}`;case"webgpu":default:let T=this._getHash(JSON.stringify({vertexEntryPoint:n.vertexEntryPoint,fragmentEntryPoint:n.fragmentEntryPoint})),M=this._getHash(JSON.stringify(n.parameters)),L=this._getWebGPUAttachmentHash(n);return`${_}/R/${r}/${c}V${u}T${n.topology}EP${T}P${M}SL${d}BL${w}A${L}`}}_hashSharedRenderPipeline(n){let r=n.vs?this._getHash(n.vs.source):0,c=n.fs?this._getHash(n.fs.source):0,u=this._getWebGLVaryingHash(n);return`webgl/S/${r}/${c}V${u}`}_getHash(n){return this._hashes[n]===void 0&&(this._hashes[n]=this._hashCounter++),this._hashes[n]}_getWebGLVaryingHash(n){let{varyings:r=[],bufferMode:c=null}=n;return this._getHash(JSON.stringify({varyings:r,bufferMode:c}))}_getWebGPUAttachmentHash(n){let r=n.colorAttachmentFormats??[this.device.preferredColorFormat],c=n.depthStencilAttachmentFormat??(n.parameters?.depthWriteEnabled?this.device.preferredDepthFormat:null);return this._getHash(JSON.stringify({colorAttachmentFormats:r,depthStencilAttachmentFormat:c}))}}});var r4,udt=Ve(()=>{qLe();sg();r4=class s{static defaultProps={...t4.defaultProps};static getDefaultShaderFactory(n){let r=n.getModuleData("@luma.gl/core");return r.defaultShaderFactory||=new s(n),r.defaultShaderFactory}device;_cache={};get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}constructor(n){this.device=n}createShader(n){if(!this.device.props._cacheShaders)return this.device.createShader(n);let r=this._hashShader(n),c=this._cache[r];if(c)c.useCount++,this.device.props.debugFactories&&Qt.log(3,`${this}: Reusing shader ${c.resource.id} count=${c.useCount}`)();else{let u=this.device.createShader({...n,id:n.id?`${n.id}-cached`:void 0});this._cache[r]=c={resource:u,useCount:1},this.device.props.debugFactories&&Qt.log(3,`${this}: Created new shader ${u.id}`)()}return c.resource}release(n){if(!this.device.props._cacheShaders){n.destroy();return}let r=this._hashShader(n),c=this._cache[r];if(c)if(c.useCount--,c.useCount===0)this.device.props._destroyShaders&&(delete this._cache[r],c.resource.destroy(),this.device.props.debugFactories&&Qt.log(3,`${this}: Releasing shader ${n.id}, destroyed`)());else{if(c.useCount<0)throw new Error(`ShaderFactory: Shader ${n.id} released too many times`);this.device.props.debugFactories&&Qt.log(3,`${this}: Releasing shader ${n.id} count=${c.useCount}`)()}}_hashShader(n){return`${n.stage}:${n.source}`}}});function Lce(s,n,r){let c=s.bindings.find(u=>u.name===n||`${u.name.toLocaleLowerCase()}uniforms`===n.toLocaleLowerCase());return!c&&!r?.ignoreWarnings&&Qt.warn(`Binding ${n} not set: Not found in shader layout.`)(),c||null}function s4(s,n){if(!n)return{};if(Cqt(n))return Object.fromEntries(Object.entries(n).map(([u,d])=>[Number(u),{...d}]));let r={};for(let[c,u]of Object.entries(n)){let b=Lce(s,c)?.group??0;r[b]||={},r[b][c]=u}return r}function GD(s){let n={};for(let r of Object.values(s))Object.assign(n,r);return n}function Cqt(s){let n=Object.keys(s);return n.length>0&&n.every(r=>/^\d+$/.test(r))}var fdt=Ve(()=>{sg()});var v$,hdt=Ve(()=>{Gh();v$=class s extends is{static defaultClearColor=[0,0,0,1];static defaultClearDepth=1;static defaultClearStencil=0;get[Symbol.toStringTag](){return"RenderPass"}constructor(n,r,c=s.defaultProps){r=s.normalizeProps(n,r),super(n,r,c)}static normalizeProps(n,r){return r}static defaultProps={...is.defaultProps,framebuffer:null,resolveTargets:void 0,parameters:void 0,clearColor:s.defaultClearColor,clearColors:void 0,clearDepth:s.defaultClearDepth,clearStencil:s.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0}}});var _$,ddt=Ve(()=>{Gh();_$=class s extends is{get[Symbol.toStringTag](){return"CommandEncoder"}_timeProfilingQuerySet=null;_timeProfilingSlotCount=0;_gpuTimeMs;constructor(n,r){super(n,r,s.defaultProps),this._timeProfilingQuerySet=r.timeProfilingQuerySet??null,this._timeProfilingSlotCount=0,this._gpuTimeMs=void 0}async resolveTimeProfilingQuerySet(){if(this._gpuTimeMs=void 0,!this._timeProfilingQuerySet)return;let n=Math.floor(this._timeProfilingSlotCount/2);if(n<=0)return;let r=n*2,c=await this._timeProfilingQuerySet.readResults({firstQuery:0,queryCount:r}),u=0n;for(let d=0;d=this._timeProfilingQuerySet.props.count?r:(this._timeProfilingSlotCount+=2,{...r,timestampQuerySet:this._timeProfilingQuerySet,beginTimestampIndex:c,endTimestampIndex:c+1})}_supportsTimestampQueries(){return this.device.features.has("timestamp-query")}static defaultProps={...is.defaultProps,measureExecutionTime:void 0,timeProfilingQuerySet:void 0}}});var y$,pdt=Ve(()=>{Gh();y$=class s extends is{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(n,r){super(n,r,s.defaultProps)}static defaultProps={...is.defaultProps}}});var x$,gdt=Ve(()=>{Gh();x$=class s extends is{static defaultProps={...is.defaultProps,shaderLayout:void 0,bufferLayout:[]};get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;indexBuffer=null;attributes;constructor(n,r){super(n,r,s.defaultProps),this.maxVertexAttributes=n.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null)}getBufferSlot(n){return null}getDrawValidationError(){return null}setConstantWebGL(n,r){this.device.reportError(new Error("constant attributes not supported"),this)()}}});var E$,mdt=Ve(()=>{Gh();E$=class s extends is{static defaultProps={...is.defaultProps,layout:void 0,buffers:{}};get[Symbol.toStringTag](){return"TransformFeedback"}constructor(n,r){super(n,r,s.defaultProps)}}});var S$,bdt=Ve(()=>{Gh();S$=class s extends is{get[Symbol.toStringTag](){return"QuerySet"}constructor(n,r){super(n,r,s.defaultProps)}static defaultProps={...is.defaultProps,type:void 0,count:void 0}}});var M$,wdt=Ve(()=>{Gh();M$=class s extends is{static defaultProps={...is.defaultProps};get[Symbol.toStringTag](){return"Fence"}constructor(n,r={}){super(n,r,s.defaultProps)}}});function jD(s){let n=kce(s),r=kqt[n];if(!r)throw new Error(`Unsupported variable shader type: ${s}`);return r}function vdt(s){let n=_dt(s),r=Lqt[n];if(!r)throw new Error(`Unsupported attribute shader type: ${s}`);let[c,u]=r,d=c==="i32"||c==="u32",b=c!=="u32",w=Pqt[c]*u;return{primitiveType:c,components:u,byteLength:w,integer:d,signed:b}}function Aqt(s,n){return n===1?s:`vec${n}<${s}>`}function _dt(s){return Rqt[s]||s}function kce(s){return Iqt[s]||s}var ZLe,F1,Pqt,Lqt,kqt,Rqt,Iqt,T$=Ve(()=>{ZLe=class{getVariableShaderTypeInfo(n){return jD(n)}getAttributeShaderTypeInfo(n){return vdt(n)}makeShaderAttributeType(n,r){return Aqt(n,r)}resolveAttributeShaderTypeAlias(n){return _dt(n)}resolveVariableShaderTypeAlias(n){return kce(n)}};F1=new ZLe,Pqt={f32:4,f16:2,i32:4,u32:4},Lqt={f32:["f32",1],"vec2":["f32",2],"vec3":["f32",3],"vec4":["f32",4],f16:["f16",1],"vec2":["f16",2],"vec3":["f16",3],"vec4":["f16",4],i32:["i32",1],"vec2":["i32",2],"vec3":["i32",3],"vec4":["i32",4],u32:["u32",1],"vec2":["u32",2],"vec3":["u32",3],"vec4":["u32",4]},kqt={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2":{type:"f32",components:2},"vec3":{type:"f32",components:3},"vec4":{type:"f32",components:4},"vec2":{type:"f16",components:2},"vec3":{type:"f16",components:3},"vec4":{type:"f16",components:4},"vec2":{type:"i32",components:2},"vec3":{type:"i32",components:3},"vec4":{type:"i32",components:4},"vec2":{type:"u32",components:2},"vec3":{type:"u32",components:3},"vec4":{type:"u32",components:4},"mat2x2":{type:"f32",components:4},"mat2x3":{type:"f32",components:6},"mat2x4":{type:"f32",components:8},"mat3x2":{type:"f32",components:6},"mat3x3":{type:"f32",components:9},"mat3x4":{type:"f32",components:12},"mat4x2":{type:"f32",components:8},"mat4x3":{type:"f32",components:12},"mat4x4":{type:"f32",components:16},"mat2x2":{type:"f16",components:4},"mat2x3":{type:"f16",components:6},"mat2x4":{type:"f16",components:8},"mat3x2":{type:"f16",components:6},"mat3x3":{type:"f16",components:9},"mat3x4":{type:"f16",components:12},"mat4x2":{type:"f16",components:8},"mat4x3":{type:"f16",components:12},"mat4x4":{type:"f16",components:16},"mat2x2":{type:"i32",components:4},"mat2x3":{type:"i32",components:6},"mat2x4":{type:"i32",components:8},"mat3x2":{type:"i32",components:6},"mat3x3":{type:"i32",components:9},"mat3x4":{type:"i32",components:12},"mat4x2":{type:"i32",components:8},"mat4x3":{type:"i32",components:12},"mat4x4":{type:"i32",components:16},"mat2x2":{type:"u32",components:4},"mat2x3":{type:"u32",components:6},"mat2x4":{type:"u32",components:8},"mat3x2":{type:"u32",components:6},"mat3x3":{type:"u32",components:9},"mat3x4":{type:"u32",components:12},"mat4x2":{type:"u32",components:8},"mat4x3":{type:"u32",components:12},"mat4x4":{type:"u32",components:16}},Rqt={vec2i:"vec2",vec3i:"vec3",vec4i:"vec4",vec2u:"vec2",vec3u:"vec3",vec4u:"vec4",vec2f:"vec2",vec3f:"vec3",vec4f:"vec4",vec2h:"vec2",vec3h:"vec3",vec4h:"vec4"},Iqt={vec2i:"vec2",vec3i:"vec3",vec4i:"vec4",vec2u:"vec2",vec3u:"vec3",vec4u:"vec4",vec2f:"vec2",vec3f:"vec3",vec4f:"vec4",vec2h:"vec2",vec3h:"vec3",vec4h:"vec4",mat2x2f:"mat2x2",mat2x3f:"mat2x3",mat2x4f:"mat2x4",mat3x2f:"mat3x2",mat3x3f:"mat3x3",mat3x4f:"mat3x4",mat4x2f:"mat4x2",mat4x3f:"mat4x3",mat4x4f:"mat4x4",mat2x2i:"mat2x2",mat2x3i:"mat2x3",mat2x4i:"mat2x4",mat3x2i:"mat3x2",mat3x3i:"mat3x3",mat3x4i:"mat3x4",mat4x2i:"mat4x2",mat4x3i:"mat4x3",mat4x4i:"mat4x4",mat2x2u:"mat2x2",mat2x3u:"mat2x3",mat2x4u:"mat2x4",mat3x2u:"mat3x2",mat3x3u:"mat3x3",mat3x4u:"mat3x4",mat4x2u:"mat4x2",mat4x3u:"mat4x3",mat4x4u:"mat4x4",mat2x2h:"mat2x2",mat2x3h:"mat2x3",mat2x4h:"mat2x4",mat3x2h:"mat3x2",mat3x3h:"mat3x3",mat3x4h:"mat3x4",mat4x2h:"mat4x2",mat4x3h:"mat4x3",mat4x4h:"mat4x4"}});function o4(s,n={}){let r={...s},c=n.layout??"std140",u={},d=0;for(let[b,w]of Object.entries(r))d=KLe(u,b,w,d,c);return d=Mb(d,jM(r,c)),{layout:c,byteLength:d*4,uniformTypes:r,fields:u}}function C$(s,n){let r=kce(s),c=jD(r),u=/^mat(\d)x(\d)<.+>$/.exec(r);if(u){let b=Number(u[1]),w=Number(u[2]),_=ydt(w,r,c.type,n),x=Bqt(_.size,_.alignment,n);return{alignment:_.alignment,size:b*x,components:b*w,columns:b,rows:w,columnStride:x,shaderType:r,type:c.type}}let d=/^vec(\d)<.+>$/.exec(r);return d?ydt(Number(d[1]),r,c.type,n):{alignment:1,size:1,components:1,columns:1,rows:1,columnStride:1,shaderType:r,type:c.type}}function JLe(s){return!!s&&typeof s=="object"&&!Array.isArray(s)}function KLe(s,n,r,c,u){if(typeof r=="string"){let d=C$(r,u),b=Mb(c,d.alignment);return s[n]={offset:b,...d},b+d.size}if(Array.isArray(r)){if(Array.isArray(r[0]))throw new Error(`Nested arrays are not supported for ${n}`);let d=r[0],b=r[1],w=Edt(d,u),_=Mb(c,jM(r,u));for(let x=0;x{xce();T$()});function QLe(s){return(!Ice||Ice.byteLength{});function Nqt(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function $D(s){return Array.isArray(s)?s.length===0||typeof s[0]=="number":Nqt(s)}var n4e=Ve(()=>{});function Fqt(s){return!!s&&typeof s=="object"&&!Array.isArray(s)&&!ArrayBuffer.isView(s)}function Uqt(s,n,r){return Array.prototype.slice.call(s,n,r)}var Dce,Mdt=Ve(()=>{t4e();n4e();sg();Rce();Dce=class{layout;constructor(n){this.layout=n}has(n){return!!this.layout.fields[n]}get(n){let r=this.layout.fields[n];return r?{offset:r.offset,size:r.size}:void 0}getFlatUniformValues(n){let r={};for(let[c,u]of Object.entries(n)){let d=this.layout.uniformTypes[c];d?this._flattenCompositeValue(r,c,d,u):this.layout.fields[c]&&(r[c]=u)}return r}getData(n){let r=QLe(this.layout.byteLength);new Uint8Array(r,0,this.layout.byteLength).fill(0);let c={i32:new Int32Array(r),u32:new Uint32Array(r),f32:new Float32Array(r),f16:new Uint16Array(r)},u=this.getFlatUniformValues(n);for(let[d,b]of Object.entries(u))this._writeLeafValue(c,d,b);return new Uint8Array(r,0,this.layout.byteLength)}_flattenCompositeValue(n,r,c,u){if(u!==void 0){if(typeof c=="string"||this.layout.fields[r]){n[r]=u;return}if(Array.isArray(c)){let d=c[0],b=c[1];if(Array.isArray(d))throw new Error(`Nested arrays are not supported for ${r}`);if(typeof d=="string"&&$D(u)){this._flattenPackedArray(n,r,d,b,u);return}if(!Array.isArray(u)){Qt.warn(`Unsupported uniform array value for ${r}:`,u)();return}for(let w=0;w=b.length)break;_===1?n[`${r}[${x}]`]=Number(b[T]):n[`${r}[${x}]`]=Uqt(d,T,T+_)}}_writeLeafValue(n,r,c){let u=this.layout.fields[r];if(!u){Qt.warn(`Uniform ${r} not found in layout`)();return}let{type:d,components:b,columns:w,rows:_,offset:x,columnStride:T}=u,M=n[d];if(b===1){M[x]=Number(c);return}let L=c;if(w===1){for(let D=0;Dd)return!1;for(let b=0;b{n4e();zqt=128});var Bce,Pdt=Ve(()=>{Adt();Bce=class{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(n){if(this.name=n?.name||"unnamed",n?.name&&n?.shaderLayout){let r=n?.shaderLayout.bindings?.find(u=>u.type==="uniform"&&u.name===n?.name);if(!r)throw new Error(n?.name);let c=r;for(let u of c.uniforms||[])this.bindingLayout[u.name]=u}}setUniforms(n){for(let[r,c]of Object.entries(n))this._setUniform(r,c)&&!this.needsRedraw&&this.setNeedsRedraw(`${this.name}.${r}=${c}`)}setNeedsRedraw(n){this.needsRedraw=this.needsRedraw||n}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(n,r){return Tdt(this.uniforms[n],r)?!1:(this.uniforms[n]=Cdt(r),this.modifiedUniforms[n]=!0,this.modified=!0,!0)}}});function jqt(s){return s.type==="webgpu"?"wgsl-uniform":"std140"}var Gqt,a4,Ldt=Ve(()=>{_ce();sg();Rce();Pdt();Mdt();Gqt=1024,a4=class{device;uniformBlocks=new Map;shaderBlockLayouts=new Map;shaderBlockWriters=new Map;uniformBuffers=new Map;constructor(n,r){this.device=n;for(let[c,u]of Object.entries(r)){let d=c,b=o4(u.uniformTypes??{},{layout:u.layout??jqt(n)}),w=new Dce(b);this.shaderBlockLayouts.set(d,b),this.shaderBlockWriters.set(d,w);let _=new Bce({name:c});_.setUniforms(w.getFlatUniformValues(u.defaultUniforms||{})),this.uniformBlocks.set(d,_)}}destroy(){for(let n of this.uniformBuffers.values())n.destroy()}setUniforms(n,r){for(let[c,u]of Object.entries(n)){let d=c,w=this.shaderBlockWriters.get(d)?.getFlatUniformValues(u||{});this.uniformBlocks.get(d)?.setUniforms(w||{})}this.updateUniformBuffers(r)}getUniformBufferByteLength(n){let r=this.shaderBlockLayouts.get(n)?.byteLength||0;return Math.max(r,Gqt)}getUniformBufferData(n){let r=this.uniformBlocks.get(n)?.getAllUniforms()||{};return this.shaderBlockWriters.get(n)?.getData(r)||new Uint8Array(0)}createUniformBuffer(n,r){r&&this.setUniforms(r);let c=this.getUniformBufferByteLength(n),u=this.device.createBuffer({usage:cs.UNIFORM|cs.COPY_DST,byteLength:c}),d=this.getUniformBufferData(n);return u.write(d),u}getManagedUniformBuffer(n){if(!this.uniformBuffers.get(n)){let r=this.getUniformBufferByteLength(n),c=this.device.createBuffer({usage:cs.UNIFORM|cs.COPY_DST,byteLength:r});this.uniformBuffers.set(n,c)}return this.uniformBuffers.get(n)}updateUniformBuffers(n){let r=!1;for(let c of this.uniformBlocks.keys()){let u=this.updateUniformBuffer(c,n);r||=u}return r&&Qt.log(3,`UniformStore.updateUniformBuffers(): ${r}`)(),r}updateUniformBuffer(n,r){let c=this.uniformBlocks.get(n),u=this.uniformBuffers.get(n),d=!1;if(u&&c?.needsRedraw){d||=c.needsRedraw;let b=this.getUniformBufferData(n);if(u=this.uniformBuffers.get(n),u&&(r?this.device.writeBufferViaCommandEncoder(r,u,b):u.write(b)),Qt.level>=4){let w=this.uniformBlocks.get(n)?.getAllUniforms();Qt.log(4,`Writing to uniform buffer ${String(n)}`,b,w)()}}return d}}});function VD(s){return s.attributes?s.attributes.map(n=>n.attribute):[s.name]}function i4e(s){return Object.fromEntries(s.attributes.map(n=>[n.name,n.location]))}function Oce(s){let n=1/0;for(let r of s)r!==void 0&&(n=Math.min(n,r));return n}function r4e(s,n,r){$qt(n);let c=new Map;for(let u of n){let d=Vqt(u);if(u.attributes)for(let b of u.attributes)c.has(b.attribute)||c.set(b.attribute,{bufferName:u.name,stepMode:u.stepMode,vertexFormat:b.format,byteOffset:b.byteOffset,byteStride:d});else u.format&&!c.has(u.name)&&c.set(u.name,{bufferName:u.name,stepMode:u.stepMode,vertexFormat:u.format,byteOffset:0,byteStride:d})}return s.attributes.map(u=>{let d=c.get(u.name);!d&&r?.warnOnMissingBufferLayout&&Qt.warn(`layout for attribute "${u.name}" not present in buffer layout`)();let b=F1.getAttributeShaderTypeInfo(u.type),w=d?.vertexFormat||hl.getCompatibleVertexFormat(b);return{attributeName:u.name,bufferName:d?.bufferName||u.name,location:u.location,vertexFormat:w,byteOffset:d?.byteOffset??0,byteStride:d?.byteStride??hl.getVertexFormatInfo(w).byteLength,stepMode:d?.stepMode||u.stepMode||(u.name.startsWith("instance")?"instance":"vertex")}}).sort((u,d)=>u.location-d.location)}function $qt(s){for(let n of s)(n.attributes&&n.format||!n.attributes&&!n.format)&&Qt.warn(`BufferLayout ${n.name} must have either 'attributes' or 'format' field`)()}function Vqt(s){if(typeof s.byteStride=="number")return s.byteStride;if(s.attributes){let n=0;for(let r of s.attributes)n+=hl.getVertexFormatInfo(r.format).byteLength;return n}return hl.getVertexFormatInfo(s.format).byteLength}var s4e=Ve(()=>{sg();T$();h$()});function A$(s,n){let r={},c=r4e(s,n,{warnOnMissingBufferLayout:!0});for(let u of c){let d=Wqt(s,u);r[u.attributeName]=d}return r}function Wqt(s,n){let r=Hqt(s,n.attributeName),c=F1.getAttributeShaderTypeInfo(r.type),u=n.vertexFormat,d=hl.getVertexFormatInfo(u);return{attributeName:n.attributeName,bufferName:n.bufferName,location:r.location,shaderType:r.type,primitiveType:c.primitiveType,shaderComponents:c.components,vertexFormat:u,bufferDataType:d.type,bufferComponents:d.components,normalized:d.normalized,integer:c.integer,stepMode:n.stepMode,byteOffset:n.byteOffset,byteStride:n.byteStride}}function Hqt(s,n){let r=s.attributes.find(c=>c.name===n);return r||Qt.warn(`shader layout attribute "${n}" not present in shader`)(),r||null}var kdt=Ve(()=>{sg();T$();h$();s4e()});var Vr=Ve(()=>{Tht();Cht();Xht();edt();tdt();_ce();WLe();ndt();idt();qLe();VLe();adt();XLe();cdt();ldt();udt();hdt();YLe();ddt();pdt();gdt();mdt();bdt();wdt();Rce();Ldt();Ece();xce();T$();h$();Ace();sg();fdt();jLe();t4e();kdt();s4e()});function P$(s=[],n){let r=[],c={},u={},d={},b={};for(let w of s)Rdt({modules:r,defines:c,injections:u,vertexInputs:d,varyings:b},w),Rdt({modules:r,defines:c,injections:u,vertexInputs:d,varyings:b},w[n]);for(let w of Object.keys(b))if(d[w])throw new Error(`ShaderPlugin name "${w}" cannot be both a vertex input and a varying`);return{modules:r,defines:c,injections:u,vertexInputs:d,varyings:b}}function L$(s=[],n=[]){let r=[...s],c=new Set(r.map(u=>u.name));for(let u of n)c.has(u.name)||(r.push(u),c.add(u.name));return r}function Rdt(s,n){if(n){n.modules?.length&&s.modules.push(...n.modules),n.defines&&Object.assign(s.defines,n.defines);for(let[r,c]of Object.entries(n.vertexInputs||{})){Idt(r,"vertex input");let u=s.vertexInputs[r];if(u&&u!==c)throw new Error(`ShaderPlugin vertex input "${r}" has conflicting types "${u}" and "${c}"`);s.vertexInputs[r]=c}for(let[r,c]of Object.entries(n.varyings||{})){Idt(r,"varying");let u=Xqt(r,c),d=s.varyings[r];if(d&&(d.type!==u.type||d.interpolation!==u.interpolation))throw new Error(`ShaderPlugin varying "${r}" has conflicting declarations "${d.type}/${d.interpolation}" and "${u.type}/${u.interpolation}"`);s.varyings[r]=u}for(let r of n.injections||[])Yqt(r.target),s.injections[r.target]||(s.injections[r.target]=[]),s.injections[r.target].push({injection:r.injection,order:r.order??0})}}function Idt(s,n){if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(s)||s.startsWith("_luma_"))throw new Error(`ShaderPlugin ${n} "${s}" must be a valid non-reserved identifier`)}function Xqt(s,n){let{primitiveType:r}=F1.getAttributeShaderTypeInfo(n.type),c=r==="i32"||r==="u32",u=n.interpolation||(c?"flat":"smooth");if(c&&u==="smooth")throw new Error(`ShaderPlugin integer varying "${s}" must use flat interpolation`);return{type:n.type,interpolation:u}}function Yqt(s){if(!qqt.test(s))throw new Error(`ShaderPlugin injection target "${s}" must be a named shader anchor or hook`)}var qqt,Ddt=Ve(()=>{Vr();qqt=/^(vs|fs):(?:#(?:decl|main-start|main-end)|[A-Za-z_][\w-]*)$/});function k$(s){return`${s.name}Uniforms`}function Odt(s,n){let r=n==="wgsl"?s.source:n==="vertex"?s.vs:s.fs;if(!r)return null;let c=k$(s);return Jqt(r,n==="wgsl"?"wgsl":"glsl",c)}function Ndt(s,n){let r=Object.keys(s.uniformTypes||{});if(!r.length)return null;let c=Odt(s,n);return c?{moduleName:s.name,uniformBlockName:k$(s),stage:n,expectedUniformNames:r,actualUniformNames:c,matches:tXt(r,c)}:null}function o4e(s,n,r={}){let c=Ndt(s,n);if(!c||c.matches)return c;let u=nXt(c);return r.log?.error?.(u,c)(),r.throwOnError!==!1&&C3(!1,u),c}function R$(s){let n=[],r=iXt(s);for(let c of r.matchAll(Kqt)){let u=c[1]?.trim()||null;n.push({blockName:c[2],body:c[3],instanceName:c[4]||null,layoutQualifier:u,hasLayoutQualifier:!!u,isStd140:!!(u&&/\blayout\s*\([^)]*\bstd140\b[^)]*\)/.exec(u))})}return n}function a4e(s,n,r,c){let u=R$(s).filter(b=>!b.isStd140),d=new Set;for(let b of u){if(d.has(b.blockName))continue;d.add(b.blockName);let w=c?.label?`${c.label} `:"",_=b.hasLayoutQualifier?`declares ${rXt(b.layoutQualifier)} instead of layout(std140)`:"does not declare layout(std140)",x=`${w}${n} shader uniform block ${b.blockName} ${_}. luma.gl host-side shader block packing assumes explicit layout(std140) for GLSL uniform blocks. Add \`layout(std140)\` to the block declaration.`;r?.warn?.(x,b)()}return u}function Jqt(s,n,r){let c=n==="wgsl"?Qqt(s,r):eXt(s,r);if(!c)return null;let u=[];for(let d of c.split(` -`)){let b=d.replace(/\/\/.*$/,"").trim();if(!b||b.startsWith("#"))continue;let w=n==="wgsl"?b.match(/^([A-Za-z0-9_]+)\s*:/):b.match(Zqt);w&&u.push(w[1])}return u}function Qqt(s,n){let r=new RegExp(`\\bstruct\\s+${n}\\b`,"m").exec(s);if(!r)return null;let c=s.indexOf("{",r.index);if(c<0)return null;let u=0;for(let d=c;dc.blockName===n)?.body||null}function tXt(s,n){if(s.length!==n.length)return!1;for(let r=0;r!r.includes(w)),u=r.filter(w=>!n.includes(w)),d=[`Expected ${n.length} fields, found ${r.length}.`],b=sXt(n,r);return b&&d.push(b),c.length&&d.push(`Missing from shader block (${c.length}): ${Bdt(c)}.`),u.length&&d.push(`Unexpected in shader block (${u.length}): ${Bdt(u)}.`),n.length<=12&&r.length<=12&&(c.length||u.length)&&(d.push(`Expected: ${n.join(", ")}.`),d.push(`Actual: ${r.join(", ")}.`)),`${s.moduleName}: ${s.stage} shader uniform block ${s.uniformBlockName} does not match module.uniformTypes. ${d.join(" ")}`}function iXt(s){return s.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"")}function rXt(s){return s.replace(/\s+/g," ").trim()}function sXt(s,n){let r=Math.min(s.length,n.length);for(let c=0;cn.length?`Shader block ends after field ${n.length}; expected next field ${s[n.length]}.`:n.length>s.length?`Shader block has extra field ${n.length}: ${n[s.length]}.`:null}function Bdt(s,n=8){if(s.length<=n)return s.join(", ");let r=s.length-n;return`${s.slice(0,n).join(", ")}, ... (${r} more)`}var Zqt,Kqt,c4e=Ve(()=>{pce();Zqt=/^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/,Kqt=/((?:layout\s*\([^)]*\)\s*)*)uniform\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([\s\S]*?)\}\s*([A-Za-z_][A-Za-z0-9_]*)?\s*;/g});function Fdt(s){switch(s?.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU +
${d}
`,b&&(w.innerHTML+=`

Translated Source



${b}
`),w.style.top="0",w.style.left="0",w.style.background="white",w.style.position="fixed",w.style.zIndex="9999",w.style.maxWidth="100vw",w.style.maxHeight="100vh",w.style.overflowY="auto",document.body.appendChild(w),w.querySelector(".luma-compiler-log-error")?.scrollIntoView(),w.querySelector("button#close").onclick=()=>{w.remove()},w.querySelector("button#copy").onclick=()=>{navigator.clipboard.writeText(this.source)}}static defaultProps={...is.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0}}});var n4,adt=Ve(()=>{Gh();WLe();sg();n4=class s extends is{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(n,r={}){super(n,r,s.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(n){let r=this.colorAttachments.map(u=>u.texture.clone(n)),c=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(n);return this.device.createFramebuffer({...this.props,...n,colorAttachments:r,depthStencilAttachment:c})}resize(n){let r=!n;if(n){let[c,u]=Array.isArray(n)?n:[n.width,n.height];r=r||u!==this.height||c!==this.width,this.width=c,this.height=u}r&&(Qt.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map((r,c)=>{if(typeof r=="string"){let u=this.createColorTexture(r,c);return this.attachResource(u),u.view}return r instanceof Pa?r.view:r});let n=this.props.depthStencilAttachment;if(n)if(typeof n=="string"){let r=this.createDepthStencilTexture(n);this.attachResource(r),this.depthStencilAttachment=r.view}else n instanceof Pa?this.depthStencilAttachment=n.view:this.depthStencilAttachment=n}createColorTexture(n,r){return this.device.createTexture({id:`${this.id}-color-attachment-${r}`,usage:Pa.RENDER_ATTACHMENT,format:n,width:this.width,height:this.height,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(n){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:Pa.RENDER_ATTACHMENT|Pa.SAMPLE,format:n,width:this.width,height:this.height})}resizeAttachments(n,r){if(this.colorAttachments.forEach((c,u)=>{let d=c.texture.clone({width:n,height:r});this.destroyAttachedResource(c),this.colorAttachments[u]=d.view,this.attachResource(d.view)}),this.depthStencilAttachment){let c=this.depthStencilAttachment.texture.clone({width:n,height:r});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=c.view,this.attachResource(c)}this.updateAttachments()}static defaultProps={...is.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null}}});var Mb,XLe=Ve(()=>{Gh();Mb=class s extends is{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";sharedRenderPipeline=null;get isPending(){return this.linkStatus==="pending"||this.vs.compilationStatus==="pending"||this.fs?.compilationStatus==="pending"}get isErrored(){return this.linkStatus==="error"||this.vs.compilationStatus==="error"||this.fs?.compilationStatus==="error"}constructor(n,r){super(n,r,s.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[],this.sharedRenderPipeline=this.props._sharedRenderPipeline||null}static defaultProps={...is.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},varyings:void 0,bufferMode:void 0,disableWarnings:!1,_sharedRenderPipeline:void 0,_uniformBlockLayouts:[],bindings:void 0,bindGroups:void 0}}});var w$,cdt=Ve(()=>{Gh();w$=class extends is{get[Symbol.toStringTag](){return"SharedRenderPipeline"}constructor(n,r){super(n,r,{...is.defaultProps,handle:void 0,vs:void 0,fs:void 0,varyings:void 0,bufferMode:void 0})}}});var GM,YLe=Ve(()=>{Gh();GM=class s extends is{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(n,r){super(n,r,s.defaultProps),this.shaderLayout=r.shaderLayout}static defaultProps={...is.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0}}});var i4,ldt=Ve(()=>{YLe();XLe();sg();zD();i4=class s{static defaultProps={...Mb.defaultProps};static getDefaultPipelineFactory(n){let r=n.getModuleData("@luma.gl/core");return r.defaultPipelineFactory||=new s(n),r.defaultPipelineFactory}device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};_sharedRenderPipelineCache={};get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}constructor(n){this.device=n}createRenderPipeline(n){if(!this.device.props._cachePipelines)return this.device.createRenderPipeline(n);let r={...Mb.defaultProps,...n},c=this._renderPipelineCache,u=this._hashRenderPipeline(r),d=c[u]?.resource;if(d)c[u].useCount++,this.device.props.debugFactories&&Qt.log(3,`${this}: ${c[u].resource} reused, count=${c[u].useCount}, (id=${n.id})`)();else{let b=this.device.type==="webgl"&&this.device.props._sharePipelines?this.createSharedRenderPipeline(r):void 0;d=this.device.createRenderPipeline({...r,id:r.id?`${r.id}-cached`:$y("unnamed-cached"),_sharedRenderPipeline:b}),d.hash=u,c[u]={resource:d,useCount:1},this.device.props.debugFactories&&Qt.log(3,`${this}: ${d} created, count=${c[u].useCount}`)()}return d}createComputePipeline(n){if(!this.device.props._cachePipelines)return this.device.createComputePipeline(n);let r={...GM.defaultProps,...n},c=this._computePipelineCache,u=this._hashComputePipeline(r),d=c[u]?.resource;return d?(c[u].useCount++,this.device.props.debugFactories&&Qt.log(3,`${this}: ${c[u].resource} reused, count=${c[u].useCount}, (id=${n.id})`)()):(d=this.device.createComputePipeline({...r,id:r.id?`${r.id}-cached`:void 0}),d.hash=u,c[u]={resource:d,useCount:1},this.device.props.debugFactories&&Qt.log(3,`${this}: ${d} created, count=${c[u].useCount}`)()),d}release(n){if(!this.device.props._cachePipelines){n.destroy();return}let r=this._getCache(n),c=n.hash;r[c].useCount--,r[c].useCount===0?(this._destroyPipeline(n),this.device.props.debugFactories&&Qt.log(3,`${this}: ${n} released and destroyed`)()):r[c].useCount<0?(Qt.error(`${this}: ${n} released, useCount < 0, resetting`)(),r[c].useCount=0):this.device.props.debugFactories&&Qt.log(3,`${this}: ${n} released, count=${r[c].useCount}`)()}createSharedRenderPipeline(n){let r=this._hashSharedRenderPipeline(n),c=this._sharedRenderPipelineCache[r];return c||(c={resource:this.device._createSharedRenderPipelineWebGL(n),useCount:0},this._sharedRenderPipelineCache[r]=c),c.useCount++,c.resource}releaseSharedRenderPipeline(n){if(!n.sharedRenderPipeline)return;let r=this._hashSharedRenderPipeline(n.sharedRenderPipeline.props),c=this._sharedRenderPipelineCache[r];c&&(c.useCount--,c.useCount===0&&(c.resource.destroy(),delete this._sharedRenderPipelineCache[r]))}_destroyPipeline(n){let r=this._getCache(n);return this.device.props._destroyPipelines?(delete r[n.hash],n.destroy(),n instanceof Mb&&this.releaseSharedRenderPipeline(n),!0):!1}_getCache(n){let r;if(n instanceof GM&&(r=this._computePipelineCache),n instanceof Mb&&(r=this._renderPipelineCache),!r)throw new Error(`${this}`);if(!r[n.hash])throw new Error(`${this}: ${n} matched incorrect entry`);return r}_hashComputePipeline(n){let{type:r}=this.device,c=this._getHash(n.shader.source),u=this._getHash(JSON.stringify(n.shaderLayout));return`${r}/C/${c}SL${u}`}_hashRenderPipeline(n){let r=n.vs?this._getHash(n.vs.source):0,c=n.fs?this._getHash(n.fs.source):0,u=this._getWebGLVaryingHash(n),d=this._getHash(JSON.stringify(n.shaderLayout)),b=this._getHash(JSON.stringify(n._uniformBlockLayouts)),w=this._getHash(JSON.stringify(n.bufferLayout)),{type:_}=this.device;switch(_){case"webgl":let x=this._getHash(JSON.stringify(n.parameters));return`${_}/R/${r}/${c}V${u}T${n.topology}P${x}SL${d}UBL${b}BL${w}`;case"webgpu":default:let T=this._getHash(JSON.stringify({vertexEntryPoint:n.vertexEntryPoint,fragmentEntryPoint:n.fragmentEntryPoint})),M=this._getHash(JSON.stringify(n.parameters)),L=this._getWebGPUAttachmentHash(n);return`${_}/R/${r}/${c}V${u}T${n.topology}EP${T}P${M}SL${d}BL${w}A${L}`}}_hashSharedRenderPipeline(n){let r=n.vs?this._getHash(n.vs.source):0,c=n.fs?this._getHash(n.fs.source):0,u=this._getWebGLVaryingHash(n);return`webgl/S/${r}/${c}V${u}`}_getHash(n){return this._hashes[n]===void 0&&(this._hashes[n]=this._hashCounter++),this._hashes[n]}_getWebGLVaryingHash(n){let{varyings:r=[],bufferMode:c=null}=n;return this._getHash(JSON.stringify({varyings:r,bufferMode:c}))}_getWebGPUAttachmentHash(n){let r=n.colorAttachmentFormats??[this.device.preferredColorFormat],c=n.depthStencilAttachmentFormat??(n.parameters?.depthWriteEnabled?this.device.preferredDepthFormat:null);return this._getHash(JSON.stringify({colorAttachmentFormats:r,depthStencilAttachmentFormat:c}))}}});var r4,udt=Ve(()=>{qLe();sg();r4=class s{static defaultProps={...t4.defaultProps};static getDefaultShaderFactory(n){let r=n.getModuleData("@luma.gl/core");return r.defaultShaderFactory||=new s(n),r.defaultShaderFactory}device;_cache={};get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}constructor(n){this.device=n}createShader(n){if(!this.device.props._cacheShaders)return this.device.createShader(n);let r=this._hashShader(n),c=this._cache[r];if(c)c.useCount++,this.device.props.debugFactories&&Qt.log(3,`${this}: Reusing shader ${c.resource.id} count=${c.useCount}`)();else{let u=this.device.createShader({...n,id:n.id?`${n.id}-cached`:void 0});this._cache[r]=c={resource:u,useCount:1},this.device.props.debugFactories&&Qt.log(3,`${this}: Created new shader ${u.id}`)()}return c.resource}release(n){if(!this.device.props._cacheShaders){n.destroy();return}let r=this._hashShader(n),c=this._cache[r];if(c)if(c.useCount--,c.useCount===0)this.device.props._destroyShaders&&(delete this._cache[r],c.resource.destroy(),this.device.props.debugFactories&&Qt.log(3,`${this}: Releasing shader ${n.id}, destroyed`)());else{if(c.useCount<0)throw new Error(`ShaderFactory: Shader ${n.id} released too many times`);this.device.props.debugFactories&&Qt.log(3,`${this}: Releasing shader ${n.id} count=${c.useCount}`)()}}_hashShader(n){return`${n.stage}:${n.source}`}}});function Lce(s,n,r){let c=s.bindings.find(u=>u.name===n||`${u.name.toLocaleLowerCase()}uniforms`===n.toLocaleLowerCase());return!c&&!r?.ignoreWarnings&&Qt.warn(`Binding ${n} not set: Not found in shader layout.`)(),c||null}function s4(s,n){if(!n)return{};if(Lqt(n))return Object.fromEntries(Object.entries(n).map(([u,d])=>[Number(u),{...d}]));let r={};for(let[c,u]of Object.entries(n)){let b=Lce(s,c)?.group??0;r[b]||={},r[b][c]=u}return r}function GD(s){let n={};for(let r of Object.values(s))Object.assign(n,r);return n}function Lqt(s){let n=Object.keys(s);return n.length>0&&n.every(r=>/^\d+$/.test(r))}var fdt=Ve(()=>{sg()});var v$,hdt=Ve(()=>{Gh();v$=class s extends is{static defaultClearColor=[0,0,0,1];static defaultClearDepth=1;static defaultClearStencil=0;get[Symbol.toStringTag](){return"RenderPass"}constructor(n,r,c=s.defaultProps){r=s.normalizeProps(n,r),super(n,r,c)}static normalizeProps(n,r){return r}static defaultProps={...is.defaultProps,framebuffer:null,resolveTargets:void 0,parameters:void 0,clearColor:s.defaultClearColor,clearColors:void 0,clearDepth:s.defaultClearDepth,clearStencil:s.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0}}});var _$,ddt=Ve(()=>{Gh();_$=class s extends is{get[Symbol.toStringTag](){return"CommandEncoder"}_timeProfilingQuerySet=null;_timeProfilingSlotCount=0;_gpuTimeMs;constructor(n,r){super(n,r,s.defaultProps),this._timeProfilingQuerySet=r.timeProfilingQuerySet??null,this._timeProfilingSlotCount=0,this._gpuTimeMs=void 0}async resolveTimeProfilingQuerySet(){if(this._gpuTimeMs=void 0,!this._timeProfilingQuerySet)return;let n=Math.floor(this._timeProfilingSlotCount/2);if(n<=0)return;let r=n*2,c=await this._timeProfilingQuerySet.readResults({firstQuery:0,queryCount:r}),u=0n;for(let d=0;d=this._timeProfilingQuerySet.props.count?r:(this._timeProfilingSlotCount+=2,{...r,timestampQuerySet:this._timeProfilingQuerySet,beginTimestampIndex:c,endTimestampIndex:c+1})}_supportsTimestampQueries(){return this.device.features.has("timestamp-query")}static defaultProps={...is.defaultProps,measureExecutionTime:void 0,timeProfilingQuerySet:void 0}}});var y$,pdt=Ve(()=>{Gh();y$=class s extends is{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(n,r){super(n,r,s.defaultProps)}static defaultProps={...is.defaultProps}}});var x$,gdt=Ve(()=>{Gh();x$=class s extends is{static defaultProps={...is.defaultProps,shaderLayout:void 0,bufferLayout:[]};get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;indexBuffer=null;attributes;constructor(n,r){super(n,r,s.defaultProps),this.maxVertexAttributes=n.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null)}getBufferSlot(n){return null}getDrawValidationError(){return null}setConstantWebGL(n,r){this.device.reportError(new Error("constant attributes not supported"),this)()}}});var E$,mdt=Ve(()=>{Gh();E$=class s extends is{static defaultProps={...is.defaultProps,layout:void 0,buffers:{}};get[Symbol.toStringTag](){return"TransformFeedback"}constructor(n,r){super(n,r,s.defaultProps)}}});var S$,bdt=Ve(()=>{Gh();S$=class s extends is{get[Symbol.toStringTag](){return"QuerySet"}constructor(n,r){super(n,r,s.defaultProps)}static defaultProps={...is.defaultProps,type:void 0,count:void 0}}});var M$,wdt=Ve(()=>{Gh();M$=class s extends is{static defaultProps={...is.defaultProps};get[Symbol.toStringTag](){return"Fence"}constructor(n,r={}){super(n,r,s.defaultProps)}}});function jD(s){let n=kce(s),r=Dqt[n];if(!r)throw new Error(`Unsupported variable shader type: ${s}`);return r}function vdt(s){let n=_dt(s),r=Iqt[n];if(!r)throw new Error(`Unsupported attribute shader type: ${s}`);let[c,u]=r,d=c==="i32"||c==="u32",b=c!=="u32",w=Rqt[c]*u;return{primitiveType:c,components:u,byteLength:w,integer:d,signed:b}}function kqt(s,n){return n===1?s:`vec${n}<${s}>`}function _dt(s){return Bqt[s]||s}function kce(s){return Oqt[s]||s}var ZLe,F1,Rqt,Iqt,Dqt,Bqt,Oqt,T$=Ve(()=>{ZLe=class{getVariableShaderTypeInfo(n){return jD(n)}getAttributeShaderTypeInfo(n){return vdt(n)}makeShaderAttributeType(n,r){return kqt(n,r)}resolveAttributeShaderTypeAlias(n){return _dt(n)}resolveVariableShaderTypeAlias(n){return kce(n)}};F1=new ZLe,Rqt={f32:4,f16:2,i32:4,u32:4},Iqt={f32:["f32",1],"vec2":["f32",2],"vec3":["f32",3],"vec4":["f32",4],f16:["f16",1],"vec2":["f16",2],"vec3":["f16",3],"vec4":["f16",4],i32:["i32",1],"vec2":["i32",2],"vec3":["i32",3],"vec4":["i32",4],u32:["u32",1],"vec2":["u32",2],"vec3":["u32",3],"vec4":["u32",4]},Dqt={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2":{type:"f32",components:2},"vec3":{type:"f32",components:3},"vec4":{type:"f32",components:4},"vec2":{type:"f16",components:2},"vec3":{type:"f16",components:3},"vec4":{type:"f16",components:4},"vec2":{type:"i32",components:2},"vec3":{type:"i32",components:3},"vec4":{type:"i32",components:4},"vec2":{type:"u32",components:2},"vec3":{type:"u32",components:3},"vec4":{type:"u32",components:4},"mat2x2":{type:"f32",components:4},"mat2x3":{type:"f32",components:6},"mat2x4":{type:"f32",components:8},"mat3x2":{type:"f32",components:6},"mat3x3":{type:"f32",components:9},"mat3x4":{type:"f32",components:12},"mat4x2":{type:"f32",components:8},"mat4x3":{type:"f32",components:12},"mat4x4":{type:"f32",components:16},"mat2x2":{type:"f16",components:4},"mat2x3":{type:"f16",components:6},"mat2x4":{type:"f16",components:8},"mat3x2":{type:"f16",components:6},"mat3x3":{type:"f16",components:9},"mat3x4":{type:"f16",components:12},"mat4x2":{type:"f16",components:8},"mat4x3":{type:"f16",components:12},"mat4x4":{type:"f16",components:16},"mat2x2":{type:"i32",components:4},"mat2x3":{type:"i32",components:6},"mat2x4":{type:"i32",components:8},"mat3x2":{type:"i32",components:6},"mat3x3":{type:"i32",components:9},"mat3x4":{type:"i32",components:12},"mat4x2":{type:"i32",components:8},"mat4x3":{type:"i32",components:12},"mat4x4":{type:"i32",components:16},"mat2x2":{type:"u32",components:4},"mat2x3":{type:"u32",components:6},"mat2x4":{type:"u32",components:8},"mat3x2":{type:"u32",components:6},"mat3x3":{type:"u32",components:9},"mat3x4":{type:"u32",components:12},"mat4x2":{type:"u32",components:8},"mat4x3":{type:"u32",components:12},"mat4x4":{type:"u32",components:16}},Bqt={vec2i:"vec2",vec3i:"vec3",vec4i:"vec4",vec2u:"vec2",vec3u:"vec3",vec4u:"vec4",vec2f:"vec2",vec3f:"vec3",vec4f:"vec4",vec2h:"vec2",vec3h:"vec3",vec4h:"vec4"},Oqt={vec2i:"vec2",vec3i:"vec3",vec4i:"vec4",vec2u:"vec2",vec3u:"vec3",vec4u:"vec4",vec2f:"vec2",vec3f:"vec3",vec4f:"vec4",vec2h:"vec2",vec3h:"vec3",vec4h:"vec4",mat2x2f:"mat2x2",mat2x3f:"mat2x3",mat2x4f:"mat2x4",mat3x2f:"mat3x2",mat3x3f:"mat3x3",mat3x4f:"mat3x4",mat4x2f:"mat4x2",mat4x3f:"mat4x3",mat4x4f:"mat4x4",mat2x2i:"mat2x2",mat2x3i:"mat2x3",mat2x4i:"mat2x4",mat3x2i:"mat3x2",mat3x3i:"mat3x3",mat3x4i:"mat3x4",mat4x2i:"mat4x2",mat4x3i:"mat4x3",mat4x4i:"mat4x4",mat2x2u:"mat2x2",mat2x3u:"mat2x3",mat2x4u:"mat2x4",mat3x2u:"mat3x2",mat3x3u:"mat3x3",mat3x4u:"mat3x4",mat4x2u:"mat4x2",mat4x3u:"mat4x3",mat4x4u:"mat4x4",mat2x2h:"mat2x2",mat2x3h:"mat2x3",mat2x4h:"mat2x4",mat3x2h:"mat3x2",mat3x3h:"mat3x3",mat3x4h:"mat3x4",mat4x2h:"mat4x2",mat4x3h:"mat4x3",mat4x4h:"mat4x4"}});function o4(s,n={}){let r={...s},c=n.layout??"std140",u={},d=0;for(let[b,w]of Object.entries(r))d=KLe(u,b,w,d,c);return d=Sb(d,jM(r,c)),{layout:c,byteLength:d*4,uniformTypes:r,fields:u}}function C$(s,n){let r=kce(s),c=jD(r),u=/^mat(\d)x(\d)<.+>$/.exec(r);if(u){let b=Number(u[1]),w=Number(u[2]),_=ydt(w,r,c.type,n),x=Fqt(_.size,_.alignment,n);return{alignment:_.alignment,size:b*x,components:b*w,columns:b,rows:w,columnStride:x,shaderType:r,type:c.type}}let d=/^vec(\d)<.+>$/.exec(r);return d?ydt(Number(d[1]),r,c.type,n):{alignment:1,size:1,components:1,columns:1,rows:1,columnStride:1,shaderType:r,type:c.type}}function JLe(s){return!!s&&typeof s=="object"&&!Array.isArray(s)}function KLe(s,n,r,c,u){if(typeof r=="string"){let d=C$(r,u),b=Sb(c,d.alignment);return s[n]={offset:b,...d},b+d.size}if(Array.isArray(r)){if(Array.isArray(r[0]))throw new Error(`Nested arrays are not supported for ${n}`);let d=r[0],b=r[1],w=Edt(d,u),_=Sb(c,jM(r,u));for(let x=0;x{xce();T$()});function QLe(s){return(!Ice||Ice.byteLength{});function zqt(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function $D(s){return Array.isArray(s)?s.length===0||typeof s[0]=="number":zqt(s)}var n4e=Ve(()=>{});function Gqt(s){return!!s&&typeof s=="object"&&!Array.isArray(s)&&!ArrayBuffer.isView(s)}function jqt(s,n,r){return Array.prototype.slice.call(s,n,r)}var Dce,Mdt=Ve(()=>{t4e();n4e();sg();Rce();Dce=class{layout;constructor(n){this.layout=n}has(n){return!!this.layout.fields[n]}get(n){let r=this.layout.fields[n];return r?{offset:r.offset,size:r.size}:void 0}getFlatUniformValues(n){let r={};for(let[c,u]of Object.entries(n)){let d=this.layout.uniformTypes[c];d?this._flattenCompositeValue(r,c,d,u):this.layout.fields[c]&&(r[c]=u)}return r}getData(n){let r=QLe(this.layout.byteLength);new Uint8Array(r,0,this.layout.byteLength).fill(0);let c={i32:new Int32Array(r),u32:new Uint32Array(r),f32:new Float32Array(r),f16:new Uint16Array(r)},u=this.getFlatUniformValues(n);for(let[d,b]of Object.entries(u))this._writeLeafValue(c,d,b);return new Uint8Array(r,0,this.layout.byteLength)}_flattenCompositeValue(n,r,c,u){if(u!==void 0){if(typeof c=="string"||this.layout.fields[r]){n[r]=u;return}if(Array.isArray(c)){let d=c[0],b=c[1];if(Array.isArray(d))throw new Error(`Nested arrays are not supported for ${r}`);if(typeof d=="string"&&$D(u)){this._flattenPackedArray(n,r,d,b,u);return}if(!Array.isArray(u)){Qt.warn(`Unsupported uniform array value for ${r}:`,u)();return}for(let w=0;w=b.length)break;_===1?n[`${r}[${x}]`]=Number(b[T]):n[`${r}[${x}]`]=jqt(d,T,T+_)}}_writeLeafValue(n,r,c){let u=this.layout.fields[r];if(!u){Qt.warn(`Uniform ${r} not found in layout`)();return}let{type:d,components:b,columns:w,rows:_,offset:x,columnStride:T}=u,M=n[d];if(b===1){M[x]=Number(c);return}let L=c;if(w===1){for(let D=0;Dd)return!1;for(let b=0;b{n4e();$qt=128});var Bce,Pdt=Ve(()=>{Adt();Bce=class{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(n){if(this.name=n?.name||"unnamed",n?.name&&n?.shaderLayout){let r=n?.shaderLayout.bindings?.find(u=>u.type==="uniform"&&u.name===n?.name);if(!r)throw new Error(n?.name);let c=r;for(let u of c.uniforms||[])this.bindingLayout[u.name]=u}}setUniforms(n){for(let[r,c]of Object.entries(n))this._setUniform(r,c)&&!this.needsRedraw&&this.setNeedsRedraw(`${this.name}.${r}=${c}`)}setNeedsRedraw(n){this.needsRedraw=this.needsRedraw||n}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(n,r){return Tdt(this.uniforms[n],r)?!1:(this.uniforms[n]=Cdt(r),this.modifiedUniforms[n]=!0,this.modified=!0,!0)}}});function Wqt(s){return s.type==="webgpu"?"wgsl-uniform":"std140"}var Vqt,a4,Ldt=Ve(()=>{_ce();sg();Rce();Pdt();Mdt();Vqt=1024,a4=class{device;uniformBlocks=new Map;shaderBlockLayouts=new Map;shaderBlockWriters=new Map;uniformBuffers=new Map;constructor(n,r){this.device=n;for(let[c,u]of Object.entries(r)){let d=c,b=o4(u.uniformTypes??{},{layout:u.layout??Wqt(n)}),w=new Dce(b);this.shaderBlockLayouts.set(d,b),this.shaderBlockWriters.set(d,w);let _=new Bce({name:c});_.setUniforms(w.getFlatUniformValues(u.defaultUniforms||{})),this.uniformBlocks.set(d,_)}}destroy(){for(let n of this.uniformBuffers.values())n.destroy()}setUniforms(n,r){for(let[c,u]of Object.entries(n)){let d=c,w=this.shaderBlockWriters.get(d)?.getFlatUniformValues(u||{});this.uniformBlocks.get(d)?.setUniforms(w||{})}this.updateUniformBuffers(r)}getUniformBufferByteLength(n){let r=this.shaderBlockLayouts.get(n)?.byteLength||0;return Math.max(r,Vqt)}getUniformBufferData(n){let r=this.uniformBlocks.get(n)?.getAllUniforms()||{};return this.shaderBlockWriters.get(n)?.getData(r)||new Uint8Array(0)}createUniformBuffer(n,r){r&&this.setUniforms(r);let c=this.getUniformBufferByteLength(n),u=this.device.createBuffer({usage:cs.UNIFORM|cs.COPY_DST,byteLength:c}),d=this.getUniformBufferData(n);return u.write(d),u}getManagedUniformBuffer(n){if(!this.uniformBuffers.get(n)){let r=this.getUniformBufferByteLength(n),c=this.device.createBuffer({usage:cs.UNIFORM|cs.COPY_DST,byteLength:r});this.uniformBuffers.set(n,c)}return this.uniformBuffers.get(n)}updateUniformBuffers(n){let r=!1;for(let c of this.uniformBlocks.keys()){let u=this.updateUniformBuffer(c,n);r||=u}return r&&Qt.log(3,`UniformStore.updateUniformBuffers(): ${r}`)(),r}updateUniformBuffer(n,r){let c=this.uniformBlocks.get(n),u=this.uniformBuffers.get(n),d=!1;if(u&&c?.needsRedraw){d||=c.needsRedraw;let b=this.getUniformBufferData(n);if(u=this.uniformBuffers.get(n),u&&(r?this.device.writeBufferViaCommandEncoder(r,u,b):u.write(b)),Qt.level>=4){let w=this.uniformBlocks.get(n)?.getAllUniforms();Qt.log(4,`Writing to uniform buffer ${String(n)}`,b,w)()}}return d}}});function VD(s){return s.attributes?s.attributes.map(n=>n.attribute):[s.name]}function i4e(s){return Object.fromEntries(s.attributes.map(n=>[n.name,n.location]))}function Oce(s){let n=1/0;for(let r of s)r!==void 0&&(n=Math.min(n,r));return n}function r4e(s,n,r){Hqt(n);let c=new Map;for(let u of n){let d=qqt(u);if(u.attributes)for(let b of u.attributes)c.has(b.attribute)||c.set(b.attribute,{bufferName:u.name,stepMode:u.stepMode,vertexFormat:b.format,byteOffset:b.byteOffset,byteStride:d});else u.format&&!c.has(u.name)&&c.set(u.name,{bufferName:u.name,stepMode:u.stepMode,vertexFormat:u.format,byteOffset:0,byteStride:d})}return s.attributes.map(u=>{let d=c.get(u.name);!d&&r?.warnOnMissingBufferLayout&&Qt.warn(`layout for attribute "${u.name}" not present in buffer layout`)();let b=F1.getAttributeShaderTypeInfo(u.type),w=d?.vertexFormat||hl.getCompatibleVertexFormat(b);return{attributeName:u.name,bufferName:d?.bufferName||u.name,location:u.location,vertexFormat:w,byteOffset:d?.byteOffset??0,byteStride:d?.byteStride??hl.getVertexFormatInfo(w).byteLength,stepMode:d?.stepMode||u.stepMode||(u.name.startsWith("instance")?"instance":"vertex")}}).sort((u,d)=>u.location-d.location)}function Hqt(s){for(let n of s)(n.attributes&&n.format||!n.attributes&&!n.format)&&Qt.warn(`BufferLayout ${n.name} must have either 'attributes' or 'format' field`)()}function qqt(s){if(typeof s.byteStride=="number")return s.byteStride;if(s.attributes){let n=0;for(let r of s.attributes)n+=hl.getVertexFormatInfo(r.format).byteLength;return n}return hl.getVertexFormatInfo(s.format).byteLength}var s4e=Ve(()=>{sg();T$();h$()});function A$(s,n){let r={},c=r4e(s,n,{warnOnMissingBufferLayout:!0});for(let u of c){let d=Xqt(s,u);r[u.attributeName]=d}return r}function Xqt(s,n){let r=Yqt(s,n.attributeName),c=F1.getAttributeShaderTypeInfo(r.type),u=n.vertexFormat,d=hl.getVertexFormatInfo(u);return{attributeName:n.attributeName,bufferName:n.bufferName,location:r.location,shaderType:r.type,primitiveType:c.primitiveType,shaderComponents:c.components,vertexFormat:u,bufferDataType:d.type,bufferComponents:d.components,normalized:d.normalized,integer:c.integer,stepMode:n.stepMode,byteOffset:n.byteOffset,byteStride:n.byteStride}}function Yqt(s,n){let r=s.attributes.find(c=>c.name===n);return r||Qt.warn(`shader layout attribute "${n}" not present in shader`)(),r||null}var kdt=Ve(()=>{sg();T$();h$();s4e()});var Vr=Ve(()=>{Tht();Cht();Xht();edt();tdt();_ce();WLe();ndt();idt();qLe();VLe();adt();XLe();cdt();ldt();udt();hdt();YLe();ddt();pdt();gdt();mdt();bdt();wdt();Rce();Ldt();Ece();xce();T$();h$();Ace();sg();fdt();jLe();t4e();kdt();s4e()});function P$(s=[],n){let r=[],c={},u={},d={},b={};for(let w of s)Rdt({modules:r,defines:c,injections:u,vertexInputs:d,varyings:b},w),Rdt({modules:r,defines:c,injections:u,vertexInputs:d,varyings:b},w[n]);for(let w of Object.keys(b))if(d[w])throw new Error(`ShaderPlugin name "${w}" cannot be both a vertex input and a varying`);return{modules:r,defines:c,injections:u,vertexInputs:d,varyings:b}}function L$(s=[],n=[]){let r=[...s],c=new Set(r.map(u=>u.name));for(let u of n)c.has(u.name)||(r.push(u),c.add(u.name));return r}function Rdt(s,n){if(n){n.modules?.length&&s.modules.push(...n.modules),n.defines&&Object.assign(s.defines,n.defines);for(let[r,c]of Object.entries(n.vertexInputs||{})){Idt(r,"vertex input");let u=s.vertexInputs[r];if(u&&u!==c)throw new Error(`ShaderPlugin vertex input "${r}" has conflicting types "${u}" and "${c}"`);s.vertexInputs[r]=c}for(let[r,c]of Object.entries(n.varyings||{})){Idt(r,"varying");let u=Kqt(r,c),d=s.varyings[r];if(d&&(d.type!==u.type||d.interpolation!==u.interpolation))throw new Error(`ShaderPlugin varying "${r}" has conflicting declarations "${d.type}/${d.interpolation}" and "${u.type}/${u.interpolation}"`);s.varyings[r]=u}for(let r of n.injections||[])Jqt(r.target),s.injections[r.target]||(s.injections[r.target]=[]),s.injections[r.target].push({injection:r.injection,order:r.order??0})}}function Idt(s,n){if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(s)||s.startsWith("_luma_"))throw new Error(`ShaderPlugin ${n} "${s}" must be a valid non-reserved identifier`)}function Kqt(s,n){let{primitiveType:r}=F1.getAttributeShaderTypeInfo(n.type),c=r==="i32"||r==="u32",u=n.interpolation||(c?"flat":"smooth");if(c&&u==="smooth")throw new Error(`ShaderPlugin integer varying "${s}" must use flat interpolation`);return{type:n.type,interpolation:u}}function Jqt(s){if(!Zqt.test(s))throw new Error(`ShaderPlugin injection target "${s}" must be a named shader anchor or hook`)}var Zqt,Ddt=Ve(()=>{Vr();Zqt=/^(vs|fs):(?:#(?:decl|main-start|main-end)|[A-Za-z_][\w-]*)$/});function k$(s){return`${s.name}Uniforms`}function Odt(s,n){let r=n==="wgsl"?s.source:n==="vertex"?s.vs:s.fs;if(!r)return null;let c=k$(s);return tXt(r,n==="wgsl"?"wgsl":"glsl",c)}function Ndt(s,n){let r=Object.keys(s.uniformTypes||{});if(!r.length)return null;let c=Odt(s,n);return c?{moduleName:s.name,uniformBlockName:k$(s),stage:n,expectedUniformNames:r,actualUniformNames:c,matches:rXt(r,c)}:null}function o4e(s,n,r={}){let c=Ndt(s,n);if(!c||c.matches)return c;let u=sXt(c);return r.log?.error?.(u,c)(),r.throwOnError!==!1&&C3(!1,u),c}function R$(s){let n=[],r=oXt(s);for(let c of r.matchAll(eXt)){let u=c[1]?.trim()||null;n.push({blockName:c[2],body:c[3],instanceName:c[4]||null,layoutQualifier:u,hasLayoutQualifier:!!u,isStd140:!!(u&&/\blayout\s*\([^)]*\bstd140\b[^)]*\)/.exec(u))})}return n}function a4e(s,n,r,c){let u=R$(s).filter(b=>!b.isStd140),d=new Set;for(let b of u){if(d.has(b.blockName))continue;d.add(b.blockName);let w=c?.label?`${c.label} `:"",_=b.hasLayoutQualifier?`declares ${aXt(b.layoutQualifier)} instead of layout(std140)`:"does not declare layout(std140)",x=`${w}${n} shader uniform block ${b.blockName} ${_}. luma.gl host-side shader block packing assumes explicit layout(std140) for GLSL uniform blocks. Add \`layout(std140)\` to the block declaration.`;r?.warn?.(x,b)()}return u}function tXt(s,n,r){let c=n==="wgsl"?nXt(s,r):iXt(s,r);if(!c)return null;let u=[];for(let d of c.split(` +`)){let b=d.replace(/\/\/.*$/,"").trim();if(!b||b.startsWith("#"))continue;let w=n==="wgsl"?b.match(/^([A-Za-z0-9_]+)\s*:/):b.match(Qqt);w&&u.push(w[1])}return u}function nXt(s,n){let r=new RegExp(`\\bstruct\\s+${n}\\b`,"m").exec(s);if(!r)return null;let c=s.indexOf("{",r.index);if(c<0)return null;let u=0;for(let d=c;dc.blockName===n)?.body||null}function rXt(s,n){if(s.length!==n.length)return!1;for(let r=0;r!r.includes(w)),u=r.filter(w=>!n.includes(w)),d=[`Expected ${n.length} fields, found ${r.length}.`],b=cXt(n,r);return b&&d.push(b),c.length&&d.push(`Missing from shader block (${c.length}): ${Bdt(c)}.`),u.length&&d.push(`Unexpected in shader block (${u.length}): ${Bdt(u)}.`),n.length<=12&&r.length<=12&&(c.length||u.length)&&(d.push(`Expected: ${n.join(", ")}.`),d.push(`Actual: ${r.join(", ")}.`)),`${s.moduleName}: ${s.stage} shader uniform block ${s.uniformBlockName} does not match module.uniformTypes. ${d.join(" ")}`}function oXt(s){return s.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"")}function aXt(s){return s.replace(/\s+/g," ").trim()}function cXt(s,n){let r=Math.min(s.length,n.length);for(let c=0;cn.length?`Shader block ends after field ${n.length}; expected next field ${s[n.length]}.`:n.length>s.length?`Shader block has extra field ${n.length}: ${n[s.length]}.`:null}function Bdt(s,n=8){if(s.length<=n)return s.join(", ");let r=s.length-n;return`${s.slice(0,n).join(", ")}, ... (${r} more)`}var Qqt,eXt,c4e=Ve(()=>{pce();Qqt=/^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/,eXt=/((?:layout\s*\([^)]*\)\s*)*)uniform\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([\s\S]*?)\}\s*([A-Za-z_][A-Za-z0-9_]*)?\s*;/g});function Fdt(s){switch(s?.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU // Apple optimizes away the calculation necessary for emulated fp64 #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 @@ -62,36 +62,36 @@ ${d}${b}${s.type.toUpperCase()}: ${s.message} #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 // If the GPU doesn't have full 32 bits precision, will causes overflow #define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 -`}}var Udt=Ve(()=>{});function Gdt(s,n){if(Number(s.match(/^#version[ \t]+(\d+)/m)?.[1]||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(n){case"vertex":return s=zdt(s,oXt),s;case"fragment":return s=zdt(s,aXt),s;default:throw new Error(n)}}function zdt(s,n){for(let[r,c]of n)s=s.replace(r,c);return s}function l4e(s){return new RegExp(`\\b${s}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}var jdt,oXt,aXt,$dt=Ve(()=>{jdt=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es -`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],oXt=[...jdt,[l4e("attribute"),"in $1"],[l4e("varying"),"out $1"]],aXt=[...jdt,[l4e("varying"),"in $1"]]});function Nce(s,n,r="glsl"){let c="";for(let u in s){let d=s[u];if(c+=`${r==="wgsl"?"fn":"void"} ${d.signature} { +`}}var Udt=Ve(()=>{});function Gdt(s,n){if(Number(s.match(/^#version[ \t]+(\d+)/m)?.[1]||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(n){case"vertex":return s=zdt(s,lXt),s;case"fragment":return s=zdt(s,uXt),s;default:throw new Error(n)}}function zdt(s,n){for(let[r,c]of n)s=s.replace(r,c);return s}function l4e(s){return new RegExp(`\\b${s}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}var jdt,lXt,uXt,$dt=Ve(()=>{jdt=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es +`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],lXt=[...jdt,[l4e("attribute"),"in $1"],[l4e("varying"),"out $1"]],uXt=[...jdt,[l4e("varying"),"in $1"]]});function Nce(s,n,r="glsl"){let c="";for(let u in s){let d=s[u];if(c+=`${r==="wgsl"?"fn":"void"} ${d.signature} { `,d.header&&(c+=` ${d.header}`),n[u]){let w=n[u];w.sort((_,x)=>_.order-x.order);for(let _ of w)c+=` ${_.injection} `}d.footer&&(c+=` ${d.footer}`),c+=`} -`}return c}function u4e(s){let n={vertex:{},fragment:{}};for(let r of s){let c,u;typeof r!="string"?(c=r,u=c.hook):(c={},u=r),u=u.trim();let d=u.indexOf(":"),b=u.slice(0,d),w=u.slice(d+1),_=u.replace(/\(.+/,""),x=Object.assign(c,{signature:w});switch(b){case"vs":n.vertex[_]=x;break;case"fs":n.fragment[_]=x;break;default:throw new Error(b)}}return n}var Vdt=Ve(()=>{});function Wdt(s,n){return{name:cXt(s,n),language:"glsl",version:lXt(s)}}function cXt(s,n="unnamed"){let c=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(s);return c?c[1]:n}function lXt(s){let n=100,r=s.match(/[^\s]+/g);if(r&&r.length>=2&&r[0]==="#version"){let c=parseInt(r[1],10);Number.isFinite(c)&&(n=c)}if(n!==100&&n!==300)throw new Error(`Invalid GLSL version ${n}`);return n}var Hdt=Ve(()=>{});function Fce(s,n=[]){let r=ND(s),c=new Map;for(let d of n)c.set(Xdt(d.name,d.group,d.location),d.moduleName);let u=[];for(let d of qdt){d.lastIndex=0;let b;for(b=d.exec(r);b;){let w=d===qdt[0],_=Number(b[w?1:2]),x=Number(b[w?2:1]),T=b[3]?.trim(),M=b[4],L=b[5].trim(),I=c.get(Xdt(M,x,_));u.push(uXt({name:M,group:x,binding:_,owner:I?"module":"application",moduleName:I,accessDeclaration:T,resourceType:L})),b=d.exec(r)}}return u.sort((d,b)=>d.group!==b.group?d.group-b.group:d.binding!==b.binding?d.binding-b.binding:d.name.localeCompare(b.name))}function uXt(s){let n={name:s.name,group:s.group,binding:s.binding,owner:s.owner,kind:"unknown",moduleName:s.moduleName,resourceType:s.resourceType};if(s.accessDeclaration){let r=s.accessDeclaration.split(",").map(c=>c.trim());if(r[0]==="uniform")return{...n,kind:"uniform",access:"uniform"};if(r[0]==="storage"){let c=r[1]||"read_write";return{...n,kind:c==="read"?"read-only-storage":"storage",access:c}}}return s.resourceType==="sampler"||s.resourceType==="sampler_comparison"?{...n,kind:"sampler",samplerKind:s.resourceType==="sampler_comparison"?"comparison":"filtering"}:s.resourceType.startsWith("texture_storage_")?{...n,kind:"storage-texture",access:hXt(s.resourceType),viewDimension:Ydt(s.resourceType)}:s.resourceType.startsWith("texture_")?{...n,kind:"texture",viewDimension:Ydt(s.resourceType),sampleType:fXt(s.resourceType),multisampled:s.resourceType.startsWith("texture_multisampled_")}:n}function Xdt(s,n,r){return`${n}:${r}:${s}`}function Ydt(s){if(s.includes("cube_array"))return"cube-array";if(s.includes("2d_array"))return"2d-array";if(s.includes("cube"))return"cube";if(s.includes("3d"))return"3d";if(s.includes("2d"))return"2d";if(s.includes("1d"))return"1d"}function fXt(s){if(s.startsWith("texture_depth_"))return"depth";if(s.includes(""))return"sint";if(s.includes(""))return"uint";if(s.includes(""))return"float"}function hXt(s){return/,\s*([A-Za-z_][A-Za-z0-9_]*)\s*>$/.exec(s)?.[1]}var qdt,f4e=Ve(()=>{uce();qdt=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${N1}\\s*:\\s*([^;]+);`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(\\d+)\\s*\\)\\s*${N1}\\s*:\\s*([^;]+);`,"g")]});function l4(s,n){let r=s.split(` -`),c=[],u=[],d=!0;for(let b of r){let w=b.match(dXt),_=b.match(wXt)||b.match(pXt),x=b.match(gXt),T=b.match(mXt),M=b.match(vXt)||b.match(bXt);if(w){let L=_Xt(w[1],n?.defines||{}),I=d&&L;u.push({parentActive:d,branchTaken:L,active:I}),d=I}else if(_||x){let L=(_||x)?.[1],I=!!n?.defines?.[L],D=_?I:!I,F=d&&D;u.push({parentActive:d,branchTaken:D,active:F}),d=F}else if(T){let L=u[u.length-1];if(!L)throw new Error("Encountered #else without matching #if, #ifdef or #ifndef");L.active=L.parentActive&&!L.branchTaken,L.branchTaken=!0,d=L.active}else M?(u.pop(),d=u.length?u[u.length-1].active:!0):d&&c.push(b)}if(u.length>0)throw new Error("Unterminated conditional block in shader source");return c.join(` -`)}function _Xt(s,n){let r=s.trim();if(/^[+-]?\d+(?:\.\d+)?$/.test(r))return Number(r)!==0;if(r==="true")return!0;if(r==="false")return!1;let c=r.match(new RegExp(`^!\\s*${c4}$`));if(c)return!n[c[1]];let u=r.match(new RegExp(`^${c4}$`));if(u)return!!n[u[1]];let d=r.match(new RegExp(`^defined\\s*\\(\\s*${c4}\\s*\\)$`));if(d)return n[d[1]]!==void 0;let b=r.match(new RegExp(`^!\\s*defined\\s*\\(\\s*${c4}\\s*\\)$`));if(b)return n[b[1]]===void 0;throw new Error(`Unsupported #if expression "${s}"`)}var c4,dXt,pXt,gXt,mXt,bXt,wXt,vXt,h4e=Ve(()=>{c4="([a-zA-Z_][a-zA-Z0-9_]*)",dXt=/^\s*\#\s*if\s+(.+?)\s*(?:\/\/.*)?$/,pXt=new RegExp(`^\\s*\\#\\s*ifdef\\s*${c4}\\s*$`),gXt=new RegExp(`^\\s*\\#\\s*ifndef\\s*${c4}\\s*(?:\\/\\/.*)?$`),mXt=/^\s*\#\s*else\s*(?:\/\/.*)?$/,bXt=/^\s*\#\s*endif\s*$/,wXt=new RegExp(`^\\s*\\#\\s*ifdef\\s*${c4}\\s*(?:\\/\\/.*)?$`),vXt=/^\s*\#\s*endif\s*(?:\/\/.*)?$/});function Jdt(s,n){let r=[];for(let[c,u]of Object.entries(n))yXt(s,c),r.push(`in ${Uce(u)} ${c};`);return r.join(` -`)}function Qdt(s,n,r){let c=Object.entries(r);if(c.length===0)return{source:s,declarations:"",initialization:""};let u=xXt(s,n),d=s.slice(u.openParenthesis+1,u.closeParenthesis),b=EXt(s,d),w=new Set(b.locations),_=[],x=[],T=[];for(let[F,O]of c){if(b.names.has(F)||TXt(s,F))throw new Error(`ShaderPlugin vertex input "${F}" conflicts with an existing WGSL shader input or variable`);let z=CXt(w);w.add(z);let Z=`_luma_${F}`;_.push(`@location(${z}) ${Z}: ${O}`),x.push(`var ${F}: ${O};`),T.push(`${F} = ${Z};`)}let M=d.trim()?`, +`}return c}function u4e(s){let n={vertex:{},fragment:{}};for(let r of s){let c,u;typeof r!="string"?(c=r,u=c.hook):(c={},u=r),u=u.trim();let d=u.indexOf(":"),b=u.slice(0,d),w=u.slice(d+1),_=u.replace(/\(.+/,""),x=Object.assign(c,{signature:w});switch(b){case"vs":n.vertex[_]=x;break;case"fs":n.fragment[_]=x;break;default:throw new Error(b)}}return n}var Vdt=Ve(()=>{});function Wdt(s,n){return{name:fXt(s,n),language:"glsl",version:hXt(s)}}function fXt(s,n="unnamed"){let c=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(s);return c?c[1]:n}function hXt(s){let n=100,r=s.match(/[^\s]+/g);if(r&&r.length>=2&&r[0]==="#version"){let c=parseInt(r[1],10);Number.isFinite(c)&&(n=c)}if(n!==100&&n!==300)throw new Error(`Invalid GLSL version ${n}`);return n}var Hdt=Ve(()=>{});function Fce(s,n=[]){let r=ND(s),c=new Map;for(let d of n)c.set(Xdt(d.name,d.group,d.location),d.moduleName);let u=[];for(let d of qdt){d.lastIndex=0;let b;for(b=d.exec(r);b;){let w=d===qdt[0],_=Number(b[w?1:2]),x=Number(b[w?2:1]),T=b[3]?.trim(),M=b[4],L=b[5].trim(),I=c.get(Xdt(M,x,_));u.push(dXt({name:M,group:x,binding:_,owner:I?"module":"application",moduleName:I,accessDeclaration:T,resourceType:L})),b=d.exec(r)}}return u.sort((d,b)=>d.group!==b.group?d.group-b.group:d.binding!==b.binding?d.binding-b.binding:d.name.localeCompare(b.name))}function dXt(s){let n={name:s.name,group:s.group,binding:s.binding,owner:s.owner,kind:"unknown",moduleName:s.moduleName,resourceType:s.resourceType};if(s.accessDeclaration){let r=s.accessDeclaration.split(",").map(c=>c.trim());if(r[0]==="uniform")return{...n,kind:"uniform",access:"uniform"};if(r[0]==="storage"){let c=r[1]||"read_write";return{...n,kind:c==="read"?"read-only-storage":"storage",access:c}}}return s.resourceType==="sampler"||s.resourceType==="sampler_comparison"?{...n,kind:"sampler",samplerKind:s.resourceType==="sampler_comparison"?"comparison":"filtering"}:s.resourceType.startsWith("texture_storage_")?{...n,kind:"storage-texture",access:gXt(s.resourceType),viewDimension:Ydt(s.resourceType)}:s.resourceType.startsWith("texture_")?{...n,kind:"texture",viewDimension:Ydt(s.resourceType),sampleType:pXt(s.resourceType),multisampled:s.resourceType.startsWith("texture_multisampled_")}:n}function Xdt(s,n,r){return`${n}:${r}:${s}`}function Ydt(s){if(s.includes("cube_array"))return"cube-array";if(s.includes("2d_array"))return"2d-array";if(s.includes("cube"))return"cube";if(s.includes("3d"))return"3d";if(s.includes("2d"))return"2d";if(s.includes("1d"))return"1d"}function pXt(s){if(s.startsWith("texture_depth_"))return"depth";if(s.includes(""))return"sint";if(s.includes(""))return"uint";if(s.includes(""))return"float"}function gXt(s){return/,\s*([A-Za-z_][A-Za-z0-9_]*)\s*>$/.exec(s)?.[1]}var qdt,f4e=Ve(()=>{uce();qdt=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${N1}\\s*:\\s*([^;]+);`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(\\d+)\\s*\\)\\s*${N1}\\s*:\\s*([^;]+);`,"g")]});function l4(s,n){let r=s.split(` +`),c=[],u=[],d=!0;for(let b of r){let w=b.match(mXt),_=b.match(yXt)||b.match(bXt),x=b.match(wXt),T=b.match(vXt),M=b.match(xXt)||b.match(_Xt);if(w){let L=EXt(w[1],n?.defines||{}),I=d&&L;u.push({parentActive:d,branchTaken:L,active:I}),d=I}else if(_||x){let L=(_||x)?.[1],I=!!n?.defines?.[L],D=_?I:!I,F=d&&D;u.push({parentActive:d,branchTaken:D,active:F}),d=F}else if(T){let L=u[u.length-1];if(!L)throw new Error("Encountered #else without matching #if, #ifdef or #ifndef");L.active=L.parentActive&&!L.branchTaken,L.branchTaken=!0,d=L.active}else M?(u.pop(),d=u.length?u[u.length-1].active:!0):d&&c.push(b)}if(u.length>0)throw new Error("Unterminated conditional block in shader source");return c.join(` +`)}function EXt(s,n){let r=s.trim();if(/^[+-]?\d+(?:\.\d+)?$/.test(r))return Number(r)!==0;if(r==="true")return!0;if(r==="false")return!1;let c=r.match(new RegExp(`^!\\s*${c4}$`));if(c)return!n[c[1]];let u=r.match(new RegExp(`^${c4}$`));if(u)return!!n[u[1]];let d=r.match(new RegExp(`^defined\\s*\\(\\s*${c4}\\s*\\)$`));if(d)return n[d[1]]!==void 0;let b=r.match(new RegExp(`^!\\s*defined\\s*\\(\\s*${c4}\\s*\\)$`));if(b)return n[b[1]]===void 0;throw new Error(`Unsupported #if expression "${s}"`)}var c4,mXt,bXt,wXt,vXt,_Xt,yXt,xXt,h4e=Ve(()=>{c4="([a-zA-Z_][a-zA-Z0-9_]*)",mXt=/^\s*\#\s*if\s+(.+?)\s*(?:\/\/.*)?$/,bXt=new RegExp(`^\\s*\\#\\s*ifdef\\s*${c4}\\s*$`),wXt=new RegExp(`^\\s*\\#\\s*ifndef\\s*${c4}\\s*(?:\\/\\/.*)?$`),vXt=/^\s*\#\s*else\s*(?:\/\/.*)?$/,_Xt=/^\s*\#\s*endif\s*$/,yXt=new RegExp(`^\\s*\\#\\s*ifdef\\s*${c4}\\s*(?:\\/\\/.*)?$`),xXt=/^\s*\#\s*endif\s*(?:\/\/.*)?$/});function Jdt(s,n){let r=[];for(let[c,u]of Object.entries(n))SXt(s,c),r.push(`in ${Uce(u)} ${c};`);return r.join(` +`)}function Qdt(s,n,r){let c=Object.entries(r);if(c.length===0)return{source:s,declarations:"",initialization:""};let u=MXt(s,n),d=s.slice(u.openParenthesis+1,u.closeParenthesis),b=TXt(s,d),w=new Set(b.locations),_=[],x=[],T=[];for(let[F,O]of c){if(b.names.has(F)||PXt(s,F))throw new Error(`ShaderPlugin vertex input "${F}" conflicts with an existing WGSL shader input or variable`);let z=LXt(w);w.add(z);let Z=`_luma_${F}`;_.push(`@location(${z}) ${Z}: ${O}`),x.push(`var ${F}: ${O};`),T.push(`${F} = ${Z};`)}let M=d.trim()?`, `:` `,L=d.trim()?"":` `,I=`${d}${M}${_.join(`, `)}${L}`;return{source:s.slice(0,u.openParenthesis+1)+I+s.slice(u.closeParenthesis),declarations:x.join(` `),initialization:T.join(` -`)}}function Uce(s){let{primitiveType:n,components:r}=F1.getAttributeShaderTypeInfo(s),c=n==="i32"?"int":n==="u32"?"uint":"float";return r===1?c:`${c==="int"?"i":c==="uint"?"u":""}vec${r}`}function yXt(s,n){let r=zce(n);if(new RegExp(`\\b(?:in|attribute)\\s+(?:(?:lowp|mediump|highp)\\s+)?[A-Za-z_][A-Za-z0-9_]*\\s+${r}\\s*(?:\\[|;)`).test(s))throw new Error(`ShaderPlugin vertex input "${n}" conflicts with an existing GLSL input`)}function xXt(s,n){let c=new RegExp(`\\bfn\\s+${zce(n)}\\s*\\(`,"g").exec(s);if(!c)throw new Error(`ShaderPlugin vertex inputs require WGSL vertex entry point "${n}"`);let u=s.indexOf("(",c.index),d=ept(s,u,"(",")");if(d<0)throw new Error(`Unable to parse WGSL vertex entry point "${n}" parameters`);return{openParenthesis:u,closeParenthesis:d}}function EXt(s,n){let r=Zdt(n),c=new Set(Kdt(n)),u=SXt(n);for(let d of u){let b=MXt(s,d);if(b!==null){r.push(...Zdt(b));for(let w of Kdt(b))c.add(w)}}return{locations:r,names:c}}function Zdt(s){let n=[],r=/@location\s*\(\s*(\d+)\s*\)/g,c=r.exec(s);for(;c;)n.push(Number(c[1])),c=r.exec(s);return n}function Kdt(s){let n=[],r=/(?:^|,)\s*(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:/gm,c=r.exec(s);for(;c;)n.push(c[1]),c=r.exec(s);return n}function SXt(s){let n=[],r=/:\s*([A-Za-z_][\w]*)\b/g,c=r.exec(s);for(;c;)n.push(c[1]),c=r.exec(s);return n}function MXt(s,n){let c=new RegExp(`\\bstruct\\s+${zce(n)}\\s*\\{`,"g").exec(s);if(!c)return null;let u=s.indexOf("{",c.index),d=ept(s,u,"{","}");return d<0?null:s.slice(u+1,d)}function TXt(s,n){let r=zce(n),c=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${r}\\b`,"g"),u=c.exec(s);for(;u;){if(AXt(s,u.index)===0)return!0;u=c.exec(s)}return!1}function CXt(s){let n=0;for(;s.has(n);)n++;return n}function ept(s,n,r,c){let u=0,d=0,b=!1;for(let w=n;w0){_==="/"&&x==="*"?(d++,w++):_==="*"&&x==="/"&&(d--,w++);continue}if(_==="/"&&x==="/"){b=!0,w++;continue}if(_==="/"&&x==="*"){d=1,w++;continue}if(_===r&&u++,_===c&&--u===0)return w}return-1}function AXt(s,n){let r=0,c=0,u=!1;for(let d=0;d0){b==="/"&&w==="*"?(c++,d++):b==="*"&&w==="/"&&(c--,d++);continue}b==="/"&&w==="/"?(u=!0,d++):b==="/"&&w==="*"?(c=1,d++):b==="{"?r++:b==="}"&&r--}return r}function zce(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var d4e=Ve(()=>{Vr()});function npt(s,n,r){let c=[],u=[];for(let[d,b]of Object.entries(r)){GXt(s,d);let w=b.interpolation==="flat"?"flat ":"",_=n==="vertex"?"out":"in";c.push(`${w}${_} ${Uce(b.type)} ${d};`),n==="vertex"&&u.push(`${d} = ${UXt(b.type)};`)}return{declarations:c.join(` +`)}}function Uce(s){let{primitiveType:n,components:r}=F1.getAttributeShaderTypeInfo(s),c=n==="i32"?"int":n==="u32"?"uint":"float";return r===1?c:`${c==="int"?"i":c==="uint"?"u":""}vec${r}`}function SXt(s,n){let r=zce(n);if(new RegExp(`\\b(?:in|attribute)\\s+(?:(?:lowp|mediump|highp)\\s+)?[A-Za-z_][A-Za-z0-9_]*\\s+${r}\\s*(?:\\[|;)`).test(s))throw new Error(`ShaderPlugin vertex input "${n}" conflicts with an existing GLSL input`)}function MXt(s,n){let c=new RegExp(`\\bfn\\s+${zce(n)}\\s*\\(`,"g").exec(s);if(!c)throw new Error(`ShaderPlugin vertex inputs require WGSL vertex entry point "${n}"`);let u=s.indexOf("(",c.index),d=ept(s,u,"(",")");if(d<0)throw new Error(`Unable to parse WGSL vertex entry point "${n}" parameters`);return{openParenthesis:u,closeParenthesis:d}}function TXt(s,n){let r=Zdt(n),c=new Set(Kdt(n)),u=CXt(n);for(let d of u){let b=AXt(s,d);if(b!==null){r.push(...Zdt(b));for(let w of Kdt(b))c.add(w)}}return{locations:r,names:c}}function Zdt(s){let n=[],r=/@location\s*\(\s*(\d+)\s*\)/g,c=r.exec(s);for(;c;)n.push(Number(c[1])),c=r.exec(s);return n}function Kdt(s){let n=[],r=/(?:^|,)\s*(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:/gm,c=r.exec(s);for(;c;)n.push(c[1]),c=r.exec(s);return n}function CXt(s){let n=[],r=/:\s*([A-Za-z_][\w]*)\b/g,c=r.exec(s);for(;c;)n.push(c[1]),c=r.exec(s);return n}function AXt(s,n){let c=new RegExp(`\\bstruct\\s+${zce(n)}\\s*\\{`,"g").exec(s);if(!c)return null;let u=s.indexOf("{",c.index),d=ept(s,u,"{","}");return d<0?null:s.slice(u+1,d)}function PXt(s,n){let r=zce(n),c=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${r}\\b`,"g"),u=c.exec(s);for(;u;){if(kXt(s,u.index)===0)return!0;u=c.exec(s)}return!1}function LXt(s){let n=0;for(;s.has(n);)n++;return n}function ept(s,n,r,c){let u=0,d=0,b=!1;for(let w=n;w0){_==="/"&&x==="*"?(d++,w++):_==="*"&&x==="/"&&(d--,w++);continue}if(_==="/"&&x==="/"){b=!0,w++;continue}if(_==="/"&&x==="*"){d=1,w++;continue}if(_===r&&u++,_===c&&--u===0)return w}return-1}function kXt(s,n){let r=0,c=0,u=!1;for(let d=0;d0){b==="/"&&w==="*"?(c++,d++):b==="*"&&w==="/"&&(c--,d++);continue}b==="/"&&w==="/"?(u=!0,d++):b==="/"&&w==="*"?(c=1,d++):b==="{"?r++:b==="}"&&r--}return r}function zce(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var d4e=Ve(()=>{Vr()});function npt(s,n,r){let c=[],u=[];for(let[d,b]of Object.entries(r)){VXt(s,d);let w=b.interpolation==="flat"?"flat ":"",_=n==="vertex"?"out":"in";c.push(`${w}${_} ${Uce(b.type)} ${d};`),n==="vertex"&&u.push(`${d} = ${jXt(b.type)};`)}return{declarations:c.join(` `),initialization:u.join(` -`)}}function ipt(s,n,r,c){let u=Object.entries(c);if(u.length===0)return{source:s,declarations:"",vertexInitialization:"",fragmentInitialization:""};let d=s,b=Gce(d,n,"vertex"),w=PXt(d,b),_=Gce(d,r,"fragment"),x=LXt(d,_),T=p4e(d,w),M=p4e(d,x.type),L=new Set([...jce(b.parameters),...jce(T.body),...jce(_.parameters),...jce(M.body)]),I=new Set([...tpt(T.body),...tpt(M.body)]),D=[],F=[],O=[],z=[];for(let[oe,ne]of u){if(L.has(oe)||NXt(d,oe))throw new Error(`ShaderPlugin varying "${oe}" conflicts with existing WGSL stage I/O or a module variable`);let ue=FXt(I);I.add(ue);let Te=ne.interpolation==="flat"?" @interpolate(flat)":"";D.push(` @location(${ue})${Te} ${oe}: ${ne.type},`),F.push(`var ${oe}: ${ne.type};`),O.push(`${oe} = ${zXt(ne.type)};`),z.push(`${oe} = ${x.name}.${oe};`)}kXt(d,w,b.openBrace,b.closeBrace),d=RXt(d,w,b,u.map(([oe])=>oe)),b=Gce(d,n,"vertex"),d=IXt(d,b,u.map(([oe])=>oe));let H=(w===x.type?[w]:[w,x.type]).map(oe=>p4e(d,oe).closeBrace).sort((oe,ne)=>ne-oe);for(let oe of H)d=d.slice(0,oe)+`${D.join(` +`)}}function ipt(s,n,r,c){let u=Object.entries(c);if(u.length===0)return{source:s,declarations:"",vertexInitialization:"",fragmentInitialization:""};let d=s,b=Gce(d,n,"vertex"),w=RXt(d,b),_=Gce(d,r,"fragment"),x=IXt(d,_),T=p4e(d,w),M=p4e(d,x.type),L=new Set([...jce(b.parameters),...jce(T.body),...jce(_.parameters),...jce(M.body)]),I=new Set([...tpt(T.body),...tpt(M.body)]),D=[],F=[],O=[],z=[];for(let[oe,ne]of u){if(L.has(oe)||zXt(d,oe))throw new Error(`ShaderPlugin varying "${oe}" conflicts with existing WGSL stage I/O or a module variable`);let ue=GXt(I);I.add(ue);let Te=ne.interpolation==="flat"?" @interpolate(flat)":"";D.push(` @location(${ue})${Te} ${oe}: ${ne.type},`),F.push(`var ${oe}: ${ne.type};`),O.push(`${oe} = ${$Xt(ne.type)};`),z.push(`${oe} = ${x.name}.${oe};`)}DXt(d,w,b.openBrace,b.closeBrace),d=BXt(d,w,b,u.map(([oe])=>oe)),b=Gce(d,n,"vertex"),d=OXt(d,b,u.map(([oe])=>oe));let H=(w===x.type?[w]:[w,x.type]).map(oe=>p4e(d,oe).closeBrace).sort((oe,ne)=>ne-oe);for(let oe of H)d=d.slice(0,oe)+`${D.join(` `)} `+d.slice(oe);if(_=Gce(d,r,"fragment"),!new RegExp(`\\b${u4(x.name)}\\s*:`).test(_.parameters))throw new Error(`Unable to preserve WGSL fragment input "${x.name}"`);return{source:d,declarations:F.join(` `),vertexInitialization:O.join(` `),fragmentInitialization:z.join(` -`)}}function Gce(s,n,r){let u=new RegExp(`\\bfn\\s+${u4(n)}\\s*\\(`,"g").exec(s);if(!u)throw new Error(`ShaderPlugin varyings require WGSL ${r} entry point "${n}"`);let d=s.indexOf("(",u.index),b=$ce(s,d,"(",")"),w=s.indexOf("{",b),_=$ce(s,w,"{","}");if(b<0||w<0||_<0)throw new Error(`Unable to parse WGSL ${r} entry point "${n}"`);return{openParenthesis:d,closeParenthesis:b,openBrace:w,closeBrace:_,parameters:s.slice(d+1,b)}}function PXt(s,n){let r=s.slice(n.closeParenthesis+1,n.openBrace),c=/->\s*([A-Za-z_][\w]*)\s*$/.exec(r.trim());if(!c||g4e(s,c[1])===null)throw new Error("ShaderPlugin varyings require the WGSL vertex entry point to return a named struct");return c[1]}function LXt(s,n){let r=[];for(let c of OXt(n.parameters,",")){let u=/(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:\s*([A-Za-z_][\w]*)\s*$/.exec(c.trim());u&&g4e(s,u[2])&&r.push({name:u[1],type:u[2]})}if(r.length!==1)throw new Error(`ShaderPlugin varyings require exactly one named WGSL fragment input struct; found ${r.length}`);return r[0]}function p4e(s,n){let r=g4e(s,n);if(!r)throw new Error(`Unable to find WGSL stage I/O struct "${n}"`);return r}function g4e(s,n){let c=new RegExp(`\\bstruct\\s+${u4(n)}\\s*\\{`,"g").exec(s);if(!c)return null;let u=s.indexOf("{",c.index),d=$ce(s,u,"{","}");return d<0?null:{openBrace:u,closeBrace:d,body:s.slice(u+1,d)}}function kXt(s,n,r,c){let u=new RegExp(`\\b${u4(n)}\\s*\\(`,"g"),d=u.exec(s);for(;d;){if(d.indexc)throw new Error(`ShaderPlugin varying output struct "${n}" is constructed outside the selected vertex entry point`);d=u.exec(s)}}function RXt(s,n,r,c){let u=new RegExp(`\\b${u4(n)}\\s*\\(`,"g"),d=[],b=u.exec(s);for(;b;){if(b.index>r.openBrace&&b.indexr.closeBrace)throw new Error(`Unable to parse WGSL output constructor "${n}"`);d.push({openParenthesis:w,closeParenthesis:_})}b=u.exec(s)}for(let w of d.sort((_,x)=>x.closeParenthesis-_.closeParenthesis)){let x=s.slice(w.openParenthesis+1,w.closeParenthesis).trim()?", ":"";s=s.slice(0,w.closeParenthesis)+x+c.join(", ")+s.slice(w.closeParenthesis)}return s}function IXt(s,n,r){let c=DXt(s,n.openBrace+1,n.closeBrace);for(let u=c.length-1;u>=0;u--){let d=c[u],b=s.slice(d.expressionStart,d.semicolon).trim();if(!b)throw new Error("ShaderPlugin varying vertex entry point cannot use an empty return");let w=`_luma_vertexOutput${u}`,_=r.map(T=>`${w}.${T} = ${T};`).join(` +`)}}function Gce(s,n,r){let u=new RegExp(`\\bfn\\s+${u4(n)}\\s*\\(`,"g").exec(s);if(!u)throw new Error(`ShaderPlugin varyings require WGSL ${r} entry point "${n}"`);let d=s.indexOf("(",u.index),b=$ce(s,d,"(",")"),w=s.indexOf("{",b),_=$ce(s,w,"{","}");if(b<0||w<0||_<0)throw new Error(`Unable to parse WGSL ${r} entry point "${n}"`);return{openParenthesis:d,closeParenthesis:b,openBrace:w,closeBrace:_,parameters:s.slice(d+1,b)}}function RXt(s,n){let r=s.slice(n.closeParenthesis+1,n.openBrace),c=/->\s*([A-Za-z_][\w]*)\s*$/.exec(r.trim());if(!c||g4e(s,c[1])===null)throw new Error("ShaderPlugin varyings require the WGSL vertex entry point to return a named struct");return c[1]}function IXt(s,n){let r=[];for(let c of UXt(n.parameters,",")){let u=/(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:\s*([A-Za-z_][\w]*)\s*$/.exec(c.trim());u&&g4e(s,u[2])&&r.push({name:u[1],type:u[2]})}if(r.length!==1)throw new Error(`ShaderPlugin varyings require exactly one named WGSL fragment input struct; found ${r.length}`);return r[0]}function p4e(s,n){let r=g4e(s,n);if(!r)throw new Error(`Unable to find WGSL stage I/O struct "${n}"`);return r}function g4e(s,n){let c=new RegExp(`\\bstruct\\s+${u4(n)}\\s*\\{`,"g").exec(s);if(!c)return null;let u=s.indexOf("{",c.index),d=$ce(s,u,"{","}");return d<0?null:{openBrace:u,closeBrace:d,body:s.slice(u+1,d)}}function DXt(s,n,r,c){let u=new RegExp(`\\b${u4(n)}\\s*\\(`,"g"),d=u.exec(s);for(;d;){if(d.indexc)throw new Error(`ShaderPlugin varying output struct "${n}" is constructed outside the selected vertex entry point`);d=u.exec(s)}}function BXt(s,n,r,c){let u=new RegExp(`\\b${u4(n)}\\s*\\(`,"g"),d=[],b=u.exec(s);for(;b;){if(b.index>r.openBrace&&b.indexr.closeBrace)throw new Error(`Unable to parse WGSL output constructor "${n}"`);d.push({openParenthesis:w,closeParenthesis:_})}b=u.exec(s)}for(let w of d.sort((_,x)=>x.closeParenthesis-_.closeParenthesis)){let x=s.slice(w.openParenthesis+1,w.closeParenthesis).trim()?", ":"";s=s.slice(0,w.closeParenthesis)+x+c.join(", ")+s.slice(w.closeParenthesis)}return s}function OXt(s,n,r){let c=NXt(s,n.openBrace+1,n.closeBrace);for(let u=c.length-1;u>=0;u--){let d=c[u],b=s.slice(d.expressionStart,d.semicolon).trim();if(!b)throw new Error("ShaderPlugin varying vertex entry point cannot use an empty return");let w=`_luma_vertexOutput${u}`,_=r.map(T=>`${w}.${T} = ${T};`).join(` `),x=`{ var ${w} = ${b}; ${_} return ${w}; -}`;s=s.slice(0,d.start)+x+s.slice(d.semicolon+1)}return s}function DXt(s,n,r){let c=[],u=n;for(;ur?r:u+1}if(s[c]==="/"&&s[c+1]==="*"){let u=1;for(c+=2;c0;)s[c]==="/"&&s[c+1]==="*"?(u++,c+=2):s[c]==="*"&&s[c+1]==="/"?(u--,c+=2):c++}return c}function OXt(s,n){let r=[],c=0,u=0,d=0;for(let b=0;b"&&d--,w===n&&u===0&&d===0&&(r.push(s.slice(c,b)),c=b+1)}return r.push(s.slice(c)),r}function tpt(s){let n=[],r=/@location\s*\(\s*(\d+)\s*\)/g,c=r.exec(s);for(;c;)n.push(Number(c[1])),c=r.exec(s);return n}function jce(s){let n=[],r=/(?:^|,)\s*(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:/gm,c=r.exec(s);for(;c;)n.push(c[1]),c=r.exec(s);return n}function NXt(s,n){let r=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${u4(n)}\\b`,"g"),c=r.exec(s);for(;c;){if(jXt(s,c.index)===0)return!0;c=r.exec(s)}return!1}function FXt(s){let n=0;for(;s.has(n);)n++;return n}function UXt(s){let{primitiveType:n,components:r}=F1.getAttributeShaderTypeInfo(s),c=n==="u32"?"0u":n==="i32"?"0":"0.0";return r===1?c:`${Uce(s)}(${c})`}function zXt(s){let{primitiveType:n,components:r}=F1.getAttributeShaderTypeInfo(s),c=`${n}(0)`;return r===1?c:`${s}(${c})`}function GXt(s,n){if(new RegExp(`\\b(?:flat\\s+|smooth\\s+)?(?:in|out|varying)\\s+(?:(?:lowp|mediump|highp)\\s+)?[A-Za-z_][A-Za-z0-9_]*\\s+${u4(n)}\\s*(?:\\[|;)`).test(s))throw new Error(`ShaderPlugin varying "${n}" conflicts with existing GLSL stage I/O`)}function $ce(s,n,r,c){let u=0,d=0,b=!1;for(let w=n;w0){_==="/"&&x==="*"?(d++,w++):_==="*"&&x==="/"&&(d--,w++);continue}if(_==="/"&&x==="/"){b=!0,w++;continue}if(_==="/"&&x==="*"){d=1,w++;continue}if(_===r&&u++,_===c&&--u===0)return w}return-1}function jXt(s,n){let r=0;for(let c=0;c{Vr();d4e()});function apt(s){let n=ZL(s.modules||[]),{source:r,bindingAssignments:c}=VXt(s.platformInfo,{...s,source:s.source,stage:"vertex",modules:n});return{source:r,getUniforms:lpt(n),bindingAssignments:c,bindingTable:Fce(r,c),shaderLayout:hce(r,{vertexEntryPoint:s.vertexEntryPoint,scanVertexAttributes:s.scanVertexAttributes})}}function cpt(s){let{vs:n,fs:r}=s,c=ZL(s.modules||[]);return{vs:spt(s.platformInfo,{...s,source:n,stage:"vertex",modules:c}),fs:spt(s.platformInfo,{...s,source:r,stage:"fragment",modules:c}),getUniforms:lpt(c)}}function VXt(s,n){let{source:r,stage:c,modules:u,defines:d={},hookFunctions:b=[],inject:w={},pluginInjections:_={},pluginVertexInputs:x={},pluginVaryings:T={},vertexEntryPoint:M="vertexMain",fragmentEntryPoint:L="fragmentMain",log:I}=n;C3(typeof r=="string","shader source must be a string");let D=l4(r,{defines:d}),F=Qdt(D,M,x),O=ipt(F.source,M,L,T),z=O.source,Z="",H=u4e(b),te={},oe={},ne={};upt(_,te,oe,ne);for(let st in w){let at=typeof w[st]=="string"?{injection:w[st],order:0}:w[st],Ne=/^(v|f)s:(#)?([\w-]+)$/.exec(st);if(Ne){let tt=Ne[2],ot=Ne[3];tt?ot==="decl"?oe[st]=[at]:ne[st]=[at]:te[st]=[at]}else ne[st]=[at]}WXt(F.declarations,F.initialization,oe,ne),HXt(O,oe,ne);let ue=u,Te=JXt(z),Q=KXt(Te.source),ge=nYt(ue,n._bindingRegistry,Q,d),Qe=[];for(let st of ue){I&&xLe(st,z,I);let at=l4(fpt(st,"wgsl",I),{defines:d}),Ne=QXt(at,st,{usedBindingsByGroup:Q,bindingRegistry:n._bindingRegistry,reservedBindingKeysByGroup:ge});Qe.push(...Ne.bindingAssignments);let tt=Ne.source;Z+=tt;let ot=qXt(st);for(let Tt in ot){let jt=/^(v|f)s:#([\w-]+)$/.exec(Tt);if(jt){let mn=jt[2]==="decl"?oe:ne;mn[Tt]=mn[Tt]||[],mn[Tt].push(ot[Tt])}else te[Tt]=te[Tt]||[],te[Tt].push(ot[Tt])}}return Z+=b4e,Z=l$(Z,c,XXt(oe),!1,"wgsl",{vertex:M,fragment:L}),Z+=YXt(H,te),Z+=cYt(Qe),Z+=Te.source,Z=l$(Z,c,ne,!1,"wgsl",{vertex:M,fragment:L}),aYt(Z),{source:Z,bindingAssignments:Qe}}function spt(s,n){let{source:r,stage:c,language:u="glsl",modules:d,defines:b={},hookFunctions:w=[],inject:_={},pluginInjections:x={},pluginVertexInputs:T={},pluginVaryings:M={},prologue:L=!0,log:I}=n;C3(typeof r=="string","shader source must be a string");let D=u==="glsl"?Wdt(r).version:-1,F=s.shaderLanguageVersion,O=D===100?"#version 100":"#version 300 es",Z=r.split(` +}`;s=s.slice(0,d.start)+x+s.slice(d.semicolon+1)}return s}function NXt(s,n,r){let c=[],u=n;for(;ur?r:u+1}if(s[c]==="/"&&s[c+1]==="*"){let u=1;for(c+=2;c0;)s[c]==="/"&&s[c+1]==="*"?(u++,c+=2):s[c]==="*"&&s[c+1]==="/"?(u--,c+=2):c++}return c}function UXt(s,n){let r=[],c=0,u=0,d=0;for(let b=0;b"&&d--,w===n&&u===0&&d===0&&(r.push(s.slice(c,b)),c=b+1)}return r.push(s.slice(c)),r}function tpt(s){let n=[],r=/@location\s*\(\s*(\d+)\s*\)/g,c=r.exec(s);for(;c;)n.push(Number(c[1])),c=r.exec(s);return n}function jce(s){let n=[],r=/(?:^|,)\s*(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:/gm,c=r.exec(s);for(;c;)n.push(c[1]),c=r.exec(s);return n}function zXt(s,n){let r=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${u4(n)}\\b`,"g"),c=r.exec(s);for(;c;){if(WXt(s,c.index)===0)return!0;c=r.exec(s)}return!1}function GXt(s){let n=0;for(;s.has(n);)n++;return n}function jXt(s){let{primitiveType:n,components:r}=F1.getAttributeShaderTypeInfo(s),c=n==="u32"?"0u":n==="i32"?"0":"0.0";return r===1?c:`${Uce(s)}(${c})`}function $Xt(s){let{primitiveType:n,components:r}=F1.getAttributeShaderTypeInfo(s),c=`${n}(0)`;return r===1?c:`${s}(${c})`}function VXt(s,n){if(new RegExp(`\\b(?:flat\\s+|smooth\\s+)?(?:in|out|varying)\\s+(?:(?:lowp|mediump|highp)\\s+)?[A-Za-z_][A-Za-z0-9_]*\\s+${u4(n)}\\s*(?:\\[|;)`).test(s))throw new Error(`ShaderPlugin varying "${n}" conflicts with existing GLSL stage I/O`)}function $ce(s,n,r,c){let u=0,d=0,b=!1;for(let w=n;w0){_==="/"&&x==="*"?(d++,w++):_==="*"&&x==="/"&&(d--,w++);continue}if(_==="/"&&x==="/"){b=!0,w++;continue}if(_==="/"&&x==="*"){d=1,w++;continue}if(_===r&&u++,_===c&&--u===0)return w}return-1}function WXt(s,n){let r=0;for(let c=0;c{Vr();d4e()});function apt(s){let n=ZL(s.modules||[]),{source:r,bindingAssignments:c}=qXt(s.platformInfo,{...s,source:s.source,stage:"vertex",modules:n});return{source:r,getUniforms:lpt(n),bindingAssignments:c,bindingTable:Fce(r,c),shaderLayout:hce(r,{vertexEntryPoint:s.vertexEntryPoint,scanVertexAttributes:s.scanVertexAttributes})}}function cpt(s){let{vs:n,fs:r}=s,c=ZL(s.modules||[]);return{vs:spt(s.platformInfo,{...s,source:n,stage:"vertex",modules:c}),fs:spt(s.platformInfo,{...s,source:r,stage:"fragment",modules:c}),getUniforms:lpt(c)}}function qXt(s,n){let{source:r,stage:c,modules:u,defines:d={},hookFunctions:b=[],inject:w={},pluginInjections:_={},pluginVertexInputs:x={},pluginVaryings:T={},vertexEntryPoint:M="vertexMain",fragmentEntryPoint:L="fragmentMain",log:I}=n;C3(typeof r=="string","shader source must be a string");let D=l4(r,{defines:d}),F=Qdt(D,M,x),O=ipt(F.source,M,L,T),z=O.source,Z="",H=u4e(b),te={},oe={},ne={};upt(_,te,oe,ne);for(let st in w){let at=typeof w[st]=="string"?{injection:w[st],order:0}:w[st],Ne=/^(v|f)s:(#)?([\w-]+)$/.exec(st);if(Ne){let tt=Ne[2],ot=Ne[3];tt?ot==="decl"?oe[st]=[at]:ne[st]=[at]:te[st]=[at]}else ne[st]=[at]}XXt(F.declarations,F.initialization,oe,ne),YXt(O,oe,ne);let ue=u,Te=tYt(z),Q=eYt(Te.source),ge=sYt(ue,n._bindingRegistry,Q,d),Qe=[];for(let st of ue){I&&xLe(st,z,I);let at=l4(fpt(st,"wgsl",I),{defines:d}),Ne=nYt(at,st,{usedBindingsByGroup:Q,bindingRegistry:n._bindingRegistry,reservedBindingKeysByGroup:ge});Qe.push(...Ne.bindingAssignments);let tt=Ne.source;Z+=tt;let ot=ZXt(st);for(let Tt in ot){let jt=/^(v|f)s:#([\w-]+)$/.exec(Tt);if(jt){let mn=jt[2]==="decl"?oe:ne;mn[Tt]=mn[Tt]||[],mn[Tt].push(ot[Tt])}else te[Tt]=te[Tt]||[],te[Tt].push(ot[Tt])}}return Z+=b4e,Z=l$(Z,c,KXt(oe),!1,"wgsl",{vertex:M,fragment:L}),Z+=JXt(H,te),Z+=fYt(Qe),Z+=Te.source,Z=l$(Z,c,ne,!1,"wgsl",{vertex:M,fragment:L}),uYt(Z),{source:Z,bindingAssignments:Qe}}function spt(s,n){let{source:r,stage:c,language:u="glsl",modules:d,defines:b={},hookFunctions:w=[],inject:_={},pluginInjections:x={},pluginVertexInputs:T={},pluginVaryings:M={},prologue:L=!0,log:I}=n;C3(typeof r=="string","shader source must be a string");let D=u==="glsl"?Wdt(r).version:-1,F=s.shaderLanguageVersion,O=D===100?"#version 100":"#version 300 es",Z=r.split(` `).slice(1).join(` `),H={};d.forEach(ge=>{Object.assign(H,ge.defines)}),Object.assign(H,b);let te="";switch(u){case"wgsl":break;case"glsl":te=L?`${O} @@ -99,35 +99,35 @@ return ${w}; ${`#define SHADER_TYPE_${c.toUpperCase()}`} ${Fdt(s)} -${c==="fragment"?$Xt:""} +${c==="fragment"?HXt:""} // ----- APPLICATION DEFINES ------------------------- -${ZXt(H)} +${QXt(H)} `:`${O} -`;break}let oe=u4e(w),ne={},ue={},Te={};upt(x,ne,ue,Te);for(let ge in _){let Qe=typeof _[ge]=="string"?{injection:_[ge],order:0}:_[ge],st=/^(v|f)s:(#)?([\w-]+)$/.exec(ge);if(st){let at=st[2],Ne=st[3];at?Ne==="decl"?ue[ge]=[Qe]:Te[ge]=[Qe]:ne[ge]=[Qe]}else Te[ge]=[Qe]}if(c==="vertex"){let ge=Jdt(Z,T);ge&&(ue["vs:#decl"]=ue["vs:#decl"]||[],ue["vs:#decl"].push({injection:ge,order:Number.MIN_SAFE_INTEGER}))}let Q=npt(Z,c,M);if(Q.declarations){let ge=c==="vertex"?"vs:#decl":"fs:#decl";ue[ge]=ue[ge]||[],ue[ge].push({injection:Q.declarations,order:Number.MIN_SAFE_INTEGER})}Q.initialization&&(Te["vs:#main-start"]=Te["vs:#main-start"]||[],Te["vs:#main-start"].push({injection:Q.initialization,order:Number.MIN_SAFE_INTEGER}));for(let ge of d){I&&xLe(ge,Z,I);let Qe=fpt(ge,c,I);te+=Qe;let st=ge.instance?.normalizedInjections[c]||{};for(let at in st){let Ne=/^(v|f)s:#([\w-]+)$/.exec(at);if(Ne){let ot=Ne[2]==="decl"?ue:Te;ot[at]=ot[at]||[],ot[at].push(st[at])}else ne[at]=ne[at]||[],ne[at].push(st[at])}}return te+="// ----- MAIN SHADER SOURCE -------------------------",te+=b4e,te=l$(te,c,ue),te+=Nce(oe[c],ne),te+=Z,te=l$(te,c,Te),u==="glsl"&&D!==F&&(te=Gdt(te,c)),u==="glsl"&&a4e(te,c,I),te.trim()}function lpt(s){return function(r){let c={};for(let u of s){let d=u.getUniforms?.(r,c);Object.assign(c,d)}return c}}function upt(s,n,r,c){for(let u in s){let d=/^(v|f)s:(#)?([\w-]+)$/.exec(u);if(d){let b=d[2],w=d[3],_=b?w==="decl"?r:c:n;_[u]=_[u]||[],_[u].push(...s[u])}else c[u]=c[u]||[],c[u].push(...s[u])}}function WXt(s,n,r,c){s&&(r["vs:#decl"]=r["vs:#decl"]||[],r["vs:#decl"].push({injection:s,order:Number.MIN_SAFE_INTEGER})),n&&(c["vs:#main-start"]=c["vs:#main-start"]||[],c["vs:#main-start"].push({injection:n,order:Number.MIN_SAFE_INTEGER}))}function HXt(s,n,r){s.declarations&&(n["vs:#decl"]=n["vs:#decl"]||[],n["vs:#decl"].push({injection:s.declarations,order:Number.MIN_SAFE_INTEGER})),s.vertexInitialization&&(r["vs:#main-start"]=r["vs:#main-start"]||[],r["vs:#main-start"].push({injection:s.vertexInitialization,order:Number.MIN_SAFE_INTEGER})),s.fragmentInitialization&&(r["fs:#main-start"]=r["fs:#main-start"]||[],r["fs:#main-start"].push({injection:s.fragmentInitialization,order:Number.MIN_SAFE_INTEGER}))}function qXt(s){return{...s.instance?.normalizedInjections.vertex||{},...s.instance?.normalizedInjections.fragment||{}}}function XXt(s){let n=[...s["vs:#decl"]||[],...s["fs:#decl"]||[]];return n.length?{"vs:#decl":n}:{}}function YXt(s,n){return Nce(s.vertex,n,"wgsl")+Nce(s.fragment,n,"wgsl")}function ZXt(s={}){let n="";for(let r in s){let c=s[r];(c||Number.isFinite(c))&&(n+=`#define ${r.toUpperCase()} ${s[r]} +`;break}let oe=u4e(w),ne={},ue={},Te={};upt(x,ne,ue,Te);for(let ge in _){let Qe=typeof _[ge]=="string"?{injection:_[ge],order:0}:_[ge],st=/^(v|f)s:(#)?([\w-]+)$/.exec(ge);if(st){let at=st[2],Ne=st[3];at?Ne==="decl"?ue[ge]=[Qe]:Te[ge]=[Qe]:ne[ge]=[Qe]}else Te[ge]=[Qe]}if(c==="vertex"){let ge=Jdt(Z,T);ge&&(ue["vs:#decl"]=ue["vs:#decl"]||[],ue["vs:#decl"].push({injection:ge,order:Number.MIN_SAFE_INTEGER}))}let Q=npt(Z,c,M);if(Q.declarations){let ge=c==="vertex"?"vs:#decl":"fs:#decl";ue[ge]=ue[ge]||[],ue[ge].push({injection:Q.declarations,order:Number.MIN_SAFE_INTEGER})}Q.initialization&&(Te["vs:#main-start"]=Te["vs:#main-start"]||[],Te["vs:#main-start"].push({injection:Q.initialization,order:Number.MIN_SAFE_INTEGER}));for(let ge of d){I&&xLe(ge,Z,I);let Qe=fpt(ge,c,I);te+=Qe;let st=ge.instance?.normalizedInjections[c]||{};for(let at in st){let Ne=/^(v|f)s:#([\w-]+)$/.exec(at);if(Ne){let ot=Ne[2]==="decl"?ue:Te;ot[at]=ot[at]||[],ot[at].push(st[at])}else ne[at]=ne[at]||[],ne[at].push(st[at])}}return te+="// ----- MAIN SHADER SOURCE -------------------------",te+=b4e,te=l$(te,c,ue),te+=Nce(oe[c],ne),te+=Z,te=l$(te,c,Te),u==="glsl"&&D!==F&&(te=Gdt(te,c)),u==="glsl"&&a4e(te,c,I),te.trim()}function lpt(s){return function(r){let c={};for(let u of s){let d=u.getUniforms?.(r,c);Object.assign(c,d)}return c}}function upt(s,n,r,c){for(let u in s){let d=/^(v|f)s:(#)?([\w-]+)$/.exec(u);if(d){let b=d[2],w=d[3],_=b?w==="decl"?r:c:n;_[u]=_[u]||[],_[u].push(...s[u])}else c[u]=c[u]||[],c[u].push(...s[u])}}function XXt(s,n,r,c){s&&(r["vs:#decl"]=r["vs:#decl"]||[],r["vs:#decl"].push({injection:s,order:Number.MIN_SAFE_INTEGER})),n&&(c["vs:#main-start"]=c["vs:#main-start"]||[],c["vs:#main-start"].push({injection:n,order:Number.MIN_SAFE_INTEGER}))}function YXt(s,n,r){s.declarations&&(n["vs:#decl"]=n["vs:#decl"]||[],n["vs:#decl"].push({injection:s.declarations,order:Number.MIN_SAFE_INTEGER})),s.vertexInitialization&&(r["vs:#main-start"]=r["vs:#main-start"]||[],r["vs:#main-start"].push({injection:s.vertexInitialization,order:Number.MIN_SAFE_INTEGER})),s.fragmentInitialization&&(r["fs:#main-start"]=r["fs:#main-start"]||[],r["fs:#main-start"].push({injection:s.fragmentInitialization,order:Number.MIN_SAFE_INTEGER}))}function ZXt(s){return{...s.instance?.normalizedInjections.vertex||{},...s.instance?.normalizedInjections.fragment||{}}}function KXt(s){let n=[...s["vs:#decl"]||[],...s["fs:#decl"]||[]];return n.length?{"vs:#decl":n}:{}}function JXt(s,n){return Nce(s.vertex,n,"wgsl")+Nce(s.fragment,n,"wgsl")}function QXt(s={}){let n="";for(let r in s){let c=s[r];(c||Number.isFinite(c))&&(n+=`#define ${r.toUpperCase()} ${s[r]} `)}return n}function fpt(s,n,r){let c;switch(n){case"vertex":c=s.vs||"";break;case"fragment":c=s.fs||"";break;case"wgsl":c=s.source||"";break;default:C3(!1)}if(!s.name)throw new Error("Shader module must have a name");o4e(s,n,{log:r});let u=s.name.toUpperCase().replace(/[^0-9a-z]/gi,"_"),d=`// ----- MODULE ${s.name} --------------- `;return n!=="wgsl"&&(d+=`#define MODULE_${u} `),d+=`${c} -`,d}function KXt(s){let n=new Map;for(let r of YL(s,oht)){let c=Number(r.bindingToken),u=Number(r.groupToken);w4e(u,c,r.name),WD(n,u,c,`application binding "${r.name}"`)}return n}function JXt(s){let n=YL(s,lce),r=new Map;for(let d of n){if(d.bindingToken==="auto")continue;let b=Number(d.bindingToken),w=Number(d.groupToken);w4e(w,b,d.name),WD(r,w,b,`application binding "${d.name}"`)}let c={sawSupportedBindingDeclaration:n.length>0},u=hLe(s,lce,d=>tYt(d,r,c));if(dLe(s)&&!c.sawSupportedBindingDeclaration)throw new Error('Unsupported @binding(auto) declaration form in application WGSL. Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.');return{source:u}}function QXt(s,n,r){let c=[],d={sawSupportedBindingDeclaration:YL(s,OD).length>0,nextHintedBindingLocation:typeof n.firstBindingSlot=="number"?n.firstBindingSlot:null},b=hLe(s,OD,w=>eYt(w,{module:n,context:r,bindingAssignments:c,relocationState:d}));if(dLe(s)&&!d.sawSupportedBindingDeclaration)throw new Error(`Unsupported @binding(auto) declaration form in module "${n.name}". Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.`);return{source:b,bindingAssignments:c}}function eYt(s,n){let{module:r,context:c,bindingAssignments:u,relocationState:d}=n,{match:b,bindingToken:w,groupToken:_,name:x}=s,T=Number(_);if(w==="auto"){let L=hpt(T,r.name,x),I=c.bindingRegistry?.get(L),D=I!==void 0?I:sYt(T,c.usedBindingsByGroup,r.name,d.nextHintedBindingLocation??void 0,c.bindingRegistry);return opt(r.name,T,D,x),I!==void 0&&iYt(c.reservedBindingKeysByGroup,T,D,L)?(u.push({moduleName:r.name,name:x,group:T,location:D}),b.replace(/@binding\(\s*auto\s*\)/,`@binding(${D})`)):(WD(c.usedBindingsByGroup,T,D,`module "${r.name}" binding "${x}"`),c.bindingRegistry?.set(L,D),u.push({moduleName:r.name,name:x,group:T,location:D}),d.nextHintedBindingLocation!==null&&I===void 0&&(d.nextHintedBindingLocation=D+1),b.replace(/@binding\(\s*auto\s*\)/,`@binding(${D})`))}let M=Number(w);return opt(r.name,T,M,x),WD(c.usedBindingsByGroup,T,M,`module "${r.name}" binding "${x}"`),u.push({moduleName:r.name,name:x,group:T,location:M}),b}function tYt(s,n,r){let{match:c,bindingToken:u,groupToken:d,name:b}=s,w=Number(d);if(u==="auto"){let _=oYt(w,n);return w4e(w,_,b),WD(n,w,_,`application binding "${b}"`),c.replace(/@binding\(\s*auto\s*\)/,`@binding(${_})`)}return r.sawSupportedBindingDeclaration=!0,c}function nYt(s,n,r,c){let u=new Map;if(!n)return u;for(let d of s)for(let b of rYt(d,c)){let w=hpt(b.group,d.name,b.name),_=n.get(w);if(_!==void 0){let x=u.get(b.group)||new Map,T=x.get(_);if(T&&T!==w)throw new Error(`Duplicate WGSL binding reservation for modules "${T}" and "${w}": group ${b.group}, binding ${_}.`);WD(r,b.group,_,`registered module binding "${w}"`),x.set(_,w),u.set(b.group,x)}}return u}function iYt(s,n,r,c){let u=s.get(n);if(!u)return!1;let d=u.get(r);if(!d)return!1;if(d!==c)throw new Error(`Registered module binding "${c}" collided with "${d}": group ${n}, binding ${r}.`);return!0}function rYt(s,n){let r=[],c=l4(s.source||"",{defines:n});for(let u of YL(c,OD))r.push({name:u.name,group:Number(u.groupToken)});return r}function w4e(s,n,r){if(s===0&&n>=I$)throw new Error(`Application binding "${r}" in group 0 uses reserved binding ${n}. Application-owned explicit group-0 bindings must stay below ${I$}.`)}function opt(s,n,r,c){if(n===0&&r0?Math.max(...d)+1:0);for(;d.has(x)||b.has(x);)x++;for(let[T,M]of u||[])M===x&&T.startsWith(w)&&u?.delete(T);return x}function oYt(s,n){let r=n.get(s)||new Set,c=0;for(;r.has(c);)c++;return c}function aYt(s){let n=aht(s,OD);if(!n)return;let r=lYt(s,n.index);throw r?new Error(`Unresolved @binding(auto) for module "${r}" binding "${n.name}" remained in assembled WGSL source.`):uYt(s,n.index)?new Error(`Unresolved @binding(auto) for application binding "${n.name}" remained in assembled WGSL source.`):new Error(`Unresolved @binding(auto) remained in assembled WGSL source near "${fYt(n.match)}".`)}function cYt(s){if(s.length===0)return"";let n=`// ----- MODULE WGSL BINDING ASSIGNMENTS --------------- +`,d}function eYt(s){let n=new Map;for(let r of YL(s,oht)){let c=Number(r.bindingToken),u=Number(r.groupToken);w4e(u,c,r.name),WD(n,u,c,`application binding "${r.name}"`)}return n}function tYt(s){let n=YL(s,lce),r=new Map;for(let d of n){if(d.bindingToken==="auto")continue;let b=Number(d.bindingToken),w=Number(d.groupToken);w4e(w,b,d.name),WD(r,w,b,`application binding "${d.name}"`)}let c={sawSupportedBindingDeclaration:n.length>0},u=hLe(s,lce,d=>rYt(d,r,c));if(dLe(s)&&!c.sawSupportedBindingDeclaration)throw new Error('Unsupported @binding(auto) declaration form in application WGSL. Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.');return{source:u}}function nYt(s,n,r){let c=[],d={sawSupportedBindingDeclaration:YL(s,OD).length>0,nextHintedBindingLocation:typeof n.firstBindingSlot=="number"?n.firstBindingSlot:null},b=hLe(s,OD,w=>iYt(w,{module:n,context:r,bindingAssignments:c,relocationState:d}));if(dLe(s)&&!d.sawSupportedBindingDeclaration)throw new Error(`Unsupported @binding(auto) declaration form in module "${n.name}". Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.`);return{source:b,bindingAssignments:c}}function iYt(s,n){let{module:r,context:c,bindingAssignments:u,relocationState:d}=n,{match:b,bindingToken:w,groupToken:_,name:x}=s,T=Number(_);if(w==="auto"){let L=hpt(T,r.name,x),I=c.bindingRegistry?.get(L),D=I!==void 0?I:cYt(T,c.usedBindingsByGroup,r.name,d.nextHintedBindingLocation??void 0,c.bindingRegistry);return opt(r.name,T,D,x),I!==void 0&&oYt(c.reservedBindingKeysByGroup,T,D,L)?(u.push({moduleName:r.name,name:x,group:T,location:D}),b.replace(/@binding\(\s*auto\s*\)/,`@binding(${D})`)):(WD(c.usedBindingsByGroup,T,D,`module "${r.name}" binding "${x}"`),c.bindingRegistry?.set(L,D),u.push({moduleName:r.name,name:x,group:T,location:D}),d.nextHintedBindingLocation!==null&&I===void 0&&(d.nextHintedBindingLocation=D+1),b.replace(/@binding\(\s*auto\s*\)/,`@binding(${D})`))}let M=Number(w);return opt(r.name,T,M,x),WD(c.usedBindingsByGroup,T,M,`module "${r.name}" binding "${x}"`),u.push({moduleName:r.name,name:x,group:T,location:M}),b}function rYt(s,n,r){let{match:c,bindingToken:u,groupToken:d,name:b}=s,w=Number(d);if(u==="auto"){let _=lYt(w,n);return w4e(w,_,b),WD(n,w,_,`application binding "${b}"`),c.replace(/@binding\(\s*auto\s*\)/,`@binding(${_})`)}return r.sawSupportedBindingDeclaration=!0,c}function sYt(s,n,r,c){let u=new Map;if(!n)return u;for(let d of s)for(let b of aYt(d,c)){let w=hpt(b.group,d.name,b.name),_=n.get(w);if(_!==void 0){let x=u.get(b.group)||new Map,T=x.get(_);if(T&&T!==w)throw new Error(`Duplicate WGSL binding reservation for modules "${T}" and "${w}": group ${b.group}, binding ${_}.`);WD(r,b.group,_,`registered module binding "${w}"`),x.set(_,w),u.set(b.group,x)}}return u}function oYt(s,n,r,c){let u=s.get(n);if(!u)return!1;let d=u.get(r);if(!d)return!1;if(d!==c)throw new Error(`Registered module binding "${c}" collided with "${d}": group ${n}, binding ${r}.`);return!0}function aYt(s,n){let r=[],c=l4(s.source||"",{defines:n});for(let u of YL(c,OD))r.push({name:u.name,group:Number(u.groupToken)});return r}function w4e(s,n,r){if(s===0&&n>=I$)throw new Error(`Application binding "${r}" in group 0 uses reserved binding ${n}. Application-owned explicit group-0 bindings must stay below ${I$}.`)}function opt(s,n,r,c){if(n===0&&r0?Math.max(...d)+1:0);for(;d.has(x)||b.has(x);)x++;for(let[T,M]of u||[])M===x&&T.startsWith(w)&&u?.delete(T);return x}function lYt(s,n){let r=n.get(s)||new Set,c=0;for(;r.has(c);)c++;return c}function uYt(s){let n=aht(s,OD);if(!n)return;let r=hYt(s,n.index);throw r?new Error(`Unresolved @binding(auto) for module "${r}" binding "${n.name}" remained in assembled WGSL source.`):dYt(s,n.index)?new Error(`Unresolved @binding(auto) for application binding "${n.name}" remained in assembled WGSL source.`):new Error(`Unresolved @binding(auto) remained in assembled WGSL source near "${pYt(n.match)}".`)}function fYt(s){if(s.length===0)return"";let n=`// ----- MODULE WGSL BINDING ASSIGNMENTS --------------- `;for(let r of s)n+=`// ${r.moduleName}.${r.name} -> @group(${r.group}) @binding(${r.location}) `;return n+=` -`,n}function hpt(s,n,r){return`${s}:${n}:${r}`}function lYt(s,n){let r=/^\/\/ ----- MODULE ([^\n]+) ---------------$/gm,c,u;for(u=r.exec(s);u&&u.index<=n;)c=u[1],u=r.exec(s);return c}function uYt(s,n){let r=s.indexOf(b4e);return r>=0?n>r:!0}function fYt(s){return s.replace(/\s+/g," ").trim()}var b4e,I$,$Xt,dpt=Ve(()=>{ELe();Udt();yLe();$dt();mce();c4e();Vdt();pce();Hdt();f4e();wLe();h4e();d4e();rpt();uce();b4e=` +`,n}function hpt(s,n,r){return`${s}:${n}:${r}`}function hYt(s,n){let r=/^\/\/ ----- MODULE ([^\n]+) ---------------$/gm,c,u;for(u=r.exec(s);u&&u.index<=n;)c=u[1],u=r.exec(s);return c}function dYt(s,n){let r=s.indexOf(b4e);return r>=0?n>r:!0}function pYt(s){return s.replace(/\s+/g," ").trim()}var b4e,I$,HXt,dpt=Ve(()=>{ELe();Udt();yLe();$dt();mce();c4e();Vdt();pce();Hdt();f4e();wLe();h4e();d4e();rpt();uce();b4e=` ${c$} -`,I$=100,$Xt=`precision highp float; -`});var Cb,HD,$M,ppt=Ve(()=>{mce();dpt();f4e();h4e();wLe();pce();Cb=class s{static defaultShaderAssemblers={};_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(n){return C3(n==="glsl"||n==="wgsl"),n==="wgsl"?(s.defaultShaderAssemblers.wgsl=s.defaultShaderAssemblers.wgsl||new $M,s.defaultShaderAssemblers.wgsl):(s.defaultShaderAssemblers.glsl=s.defaultShaderAssemblers.glsl||new HD,s.defaultShaderAssemblers.glsl)}addDefaultModule(n){this._defaultModules.find(r=>r.name===(typeof n=="string"?n:n.name))||this._defaultModules.push(n)}removeDefaultModule(n){let r=typeof n=="string"?n:n.name;this._defaultModules=this._defaultModules.filter(c=>c.name!==r)}addShaderHook(n,r){r&&(n=Object.assign(r,{hook:n})),this._hookFunctions.push(n)}_getModuleList(n=[]){let r=new Array(this._defaultModules.length+n.length),c={},u=0;for(let d=0,b=this._defaultModules.length;d(Object.assign(c,u.defines),c),{}),...n.defines}}static getPlatformPreprocessorDefines(n){let r=n.limits||{};return{LUMA_SUPPORTS_VERTEX_STORAGE_BUFFERS:n.type==="webgpu"&&(r.maxStorageBuffersInVertexStage||0)>0,LUMA_FP32_TAN_PRECISION_WORKAROUND:n.type==="webgpu"&&n.gpu.toLowerCase()!=="nvidia"&&n.gpu.toLowerCase()!=="amd",LUMA_FP64_INTEGER_ARITHMETIC:n.type==="webgpu"&&n.gpu.toLowerCase()==="apple"}}}});function v4e(s){let{input:n,inputChannels:r,output:c}=s||{};if(!n)return dYt;if(!r)throw new Error("inputChannels");let u=pYt(r),d=gpt(n,r);return`#version 300 es +`,I$=100,HXt=`precision highp float; +`});var Tb,HD,$M,ppt=Ve(()=>{mce();dpt();f4e();h4e();wLe();pce();Tb=class s{static defaultShaderAssemblers={};_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(n){return C3(n==="glsl"||n==="wgsl"),n==="wgsl"?(s.defaultShaderAssemblers.wgsl=s.defaultShaderAssemblers.wgsl||new $M,s.defaultShaderAssemblers.wgsl):(s.defaultShaderAssemblers.glsl=s.defaultShaderAssemblers.glsl||new HD,s.defaultShaderAssemblers.glsl)}addDefaultModule(n){this._defaultModules.find(r=>r.name===(typeof n=="string"?n:n.name))||this._defaultModules.push(n)}removeDefaultModule(n){let r=typeof n=="string"?n:n.name;this._defaultModules=this._defaultModules.filter(c=>c.name!==r)}addShaderHook(n,r){r&&(n=Object.assign(r,{hook:n})),this._hookFunctions.push(n)}_getModuleList(n=[]){let r=new Array(this._defaultModules.length+n.length),c={},u=0;for(let d=0,b=this._defaultModules.length;d(Object.assign(c,u.defines),c),{}),...n.defines}}static getPlatformPreprocessorDefines(n){let r=n.limits||{};return{LUMA_SUPPORTS_VERTEX_STORAGE_BUFFERS:n.type==="webgpu"&&(r.maxStorageBuffersInVertexStage||0)>0,LUMA_FP32_TAN_PRECISION_WORKAROUND:n.type==="webgpu"&&n.gpu.toLowerCase()!=="nvidia"&&n.gpu.toLowerCase()!=="amd",LUMA_FP64_INTEGER_ARITHMETIC:n.type==="webgpu"&&n.gpu.toLowerCase()==="apple"}}}});function v4e(s){let{input:n,inputChannels:r,output:c}=s||{};if(!n)return mYt;if(!r)throw new Error("inputChannels");let u=bYt(r),d=gpt(n,r);return`#version 300 es in ${u} ${n}; out vec4 ${c}; void main() { ${c} = ${d}; -}`}function pYt(s){switch(s){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${s}`)}}function gpt(s,n){switch(n){case 1:return`vec4(${s}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${s}, 0.0, 1.0)`;case 3:return`vec4(${s}, 1.0)`;case 4:return s;default:throw new Error(`invalid channels: ${n}`)}}var hYt,dYt,mpt=Ve(()=>{hYt=`out vec4 transform_output; +}`}function bYt(s){switch(s){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${s}`)}}function gpt(s,n){switch(n){case 1:return`vec4(${s}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${s}, 0.0, 1.0)`;case 3:return`vec4(${s}, 1.0)`;case 4:return s;default:throw new Error(`invalid channels: ${n}`)}}var gYt,mYt,mpt=Ve(()=>{gYt=`out vec4 transform_output; void main() { transform_output = vec4(0); -}`,dYt=`#version 300 es -${hYt}`});function _4e(s,{precision:n=jh.precision}={}){return s=mYt(s),`${parseFloat(s.toPrecision(n))}`}function P3(s){return Array.isArray(s)||ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Kl(s,n,r){return wYt(s,c=>Math.max(n,Math.min(r,c)))}function lv(s,n,r){return P3(s)?s.map((c,u)=>lv(c,n[u],r)):r*n+(1-r)*s}function Wy(s,n,r){let c=jh.EPSILON;r&&(jh.EPSILON=r);try{if(s===n)return!0;if(P3(s)&&P3(n)){if(s.length!==n.length)return!1;for(let u=0;u{J7n=1/Math.PI*180,Q7n=1/180*Math.PI,gYt={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...gYt}};jh=globalThis.mathgl.config});var XD,y4e=Ve(()=>{qD();XD=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(n,r=0){for(let c=0;c0?", ":"")+_4e(this[c],n);return`${n.printTypes?this.constructor.name:""}[${r}]`}equals(n){if(!n||this.length!==n.length)return!1;for(let r=0;r{qD()});function x4e(s,n){if(!s)throw new Error(`math.gl assertion ${n}`)}var bpt=Ve(()=>{});var Wce,wpt=Ve(()=>{y4e();D$();bpt();Wce=class extends XD{get x(){return this[0]}set x(n){this[0]=cp(n)}get y(){return this[1]}set y(n){this[1]=cp(n)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let n=0;for(let r=0;r=0&&n=0&&n=0?Math.round(s):s%.5===0?Math.floor(s):Math.round(s)}var Cc,Hy,uzn,f4=Ve(()=>{Cc=typeof Float32Array<"u"?Float32Array:Array,Hy=Math.random;uzn=Math.PI/180});var ag={};Oy(ag,{add:()=>SYt,angle:()=>$Yt,ceil:()=>MYt,clone:()=>_Yt,copy:()=>xYt,create:()=>vpt,cross:()=>OYt,dist:()=>JYt,distance:()=>Ept,div:()=>KYt,divide:()=>xpt,dot:()=>BYt,equals:()=>qYt,exactEquals:()=>HYt,floor:()=>TYt,forEach:()=>tZt,fromValues:()=>yYt,inverse:()=>IYt,len:()=>XYt,length:()=>Mpt,lerp:()=>NYt,max:()=>AYt,min:()=>CYt,mul:()=>ZYt,multiply:()=>ypt,negate:()=>RYt,normalize:()=>DYt,random:()=>FYt,rotate:()=>jYt,round:()=>PYt,scale:()=>LYt,scaleAndAdd:()=>kYt,set:()=>EYt,sqrDist:()=>QYt,sqrLen:()=>eZt,squaredDistance:()=>Spt,squaredLength:()=>Tpt,str:()=>WYt,sub:()=>YYt,subtract:()=>_pt,transformMat2:()=>UYt,transformMat2d:()=>zYt,transformMat3:()=>GYt,transformMat4:()=>E4e,zero:()=>VYt});function vpt(){let s=new Cc(2);return Cc!=Float32Array&&(s[0]=0,s[1]=0),s}function _Yt(s){let n=new Cc(2);return n[0]=s[0],n[1]=s[1],n}function yYt(s,n){let r=new Cc(2);return r[0]=s,r[1]=n,r}function xYt(s,n){return s[0]=n[0],s[1]=n[1],s}function EYt(s,n,r){return s[0]=n,s[1]=r,s}function SYt(s,n,r){return s[0]=n[0]+r[0],s[1]=n[1]+r[1],s}function _pt(s,n,r){return s[0]=n[0]-r[0],s[1]=n[1]-r[1],s}function ypt(s,n,r){return s[0]=n[0]*r[0],s[1]=n[1]*r[1],s}function xpt(s,n,r){return s[0]=n[0]/r[0],s[1]=n[1]/r[1],s}function MYt(s,n){return s[0]=Math.ceil(n[0]),s[1]=Math.ceil(n[1]),s}function TYt(s,n){return s[0]=Math.floor(n[0]),s[1]=Math.floor(n[1]),s}function CYt(s,n,r){return s[0]=Math.min(n[0],r[0]),s[1]=Math.min(n[1],r[1]),s}function AYt(s,n,r){return s[0]=Math.max(n[0],r[0]),s[1]=Math.max(n[1],r[1]),s}function PYt(s,n){return s[0]=Ab(n[0]),s[1]=Ab(n[1]),s}function LYt(s,n,r){return s[0]=n[0]*r,s[1]=n[1]*r,s}function kYt(s,n,r,c){return s[0]=n[0]+r[0]*c,s[1]=n[1]+r[1]*c,s}function Ept(s,n){let r=n[0]-s[0],c=n[1]-s[1];return Math.sqrt(r*r+c*c)}function Spt(s,n){let r=n[0]-s[0],c=n[1]-s[1];return r*r+c*c}function Mpt(s){let n=s[0],r=s[1];return Math.sqrt(n*n+r*r)}function Tpt(s){let n=s[0],r=s[1];return n*n+r*r}function RYt(s,n){return s[0]=-n[0],s[1]=-n[1],s}function IYt(s,n){return s[0]=1/n[0],s[1]=1/n[1],s}function DYt(s,n){let r=n[0],c=n[1],u=r*r+c*c;return u>0&&(u=1/Math.sqrt(u)),s[0]=n[0]*u,s[1]=n[1]*u,s}function BYt(s,n){return s[0]*n[0]+s[1]*n[1]}function OYt(s,n,r){let c=n[0]*r[1]-n[1]*r[0];return s[0]=s[1]=0,s[2]=c,s}function NYt(s,n,r,c){let u=n[0],d=n[1];return s[0]=u+c*(r[0]-u),s[1]=d+c*(r[1]-d),s}function FYt(s,n){n=n===void 0?1:n;let r=Hy()*2*Math.PI;return s[0]=Math.cos(r)*n,s[1]=Math.sin(r)*n,s}function UYt(s,n,r){let c=n[0],u=n[1];return s[0]=r[0]*c+r[2]*u,s[1]=r[1]*c+r[3]*u,s}function zYt(s,n,r){let c=n[0],u=n[1];return s[0]=r[0]*c+r[2]*u+r[4],s[1]=r[1]*c+r[3]*u+r[5],s}function GYt(s,n,r){let c=n[0],u=n[1];return s[0]=r[0]*c+r[3]*u+r[6],s[1]=r[1]*c+r[4]*u+r[7],s}function E4e(s,n,r){let c=n[0],u=n[1];return s[0]=r[0]*c+r[4]*u+r[12],s[1]=r[1]*c+r[5]*u+r[13],s}function jYt(s,n,r,c){let u=n[0]-r[0],d=n[1]-r[1],b=Math.sin(c),w=Math.cos(c);return s[0]=u*w-d*b+r[0],s[1]=u*b+d*w+r[1],s}function $Yt(s,n){let r=s[0],c=s[1],u=n[0],d=n[1],b=Math.sqrt((r*r+c*c)*(u*u+d*d)),w=b&&(r*u+c*d)/b;return Math.acos(Math.min(Math.max(w,-1),1))}function VYt(s){return s[0]=0,s[1]=0,s}function WYt(s){return`vec2(${s[0]}, ${s[1]})`}function HYt(s,n){return s[0]===n[0]&&s[1]===n[1]}function qYt(s,n){let r=s[0],c=s[1],u=n[0],d=n[1];return Math.abs(r-u)<=1e-6*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(c-d)<=1e-6*Math.max(1,Math.abs(c),Math.abs(d))}var XYt,YYt,ZYt,KYt,JYt,QYt,eZt,tZt,S4e=Ve(()=>{f4();XYt=Mpt,YYt=_pt,ZYt=ypt,KYt=xpt,JYt=Ept,QYt=Spt,eZt=Tpt,tZt=function(){let s=vpt();return function(n,r,c,u,d,b){let w,_;for(r||(r=2),c||(c=0),u?_=Math.min(u*r+c,n.length):_=n.length,w=c;w<_;w+=r)s[0]=n[w],s[1]=n[w+1],d(s,s,b),n[w]=s[0],n[w+1]=s[1];return n}}()});function Cpt(s,n,r){let c=n[0],u=n[1],d=r[3]*c+r[7]*u||1;return s[0]=(r[0]*c+r[4]*u)/d,s[1]=(r[1]*c+r[5]*u)/d,s}function Hce(s,n,r){let c=n[0],u=n[1],d=n[2],b=r[3]*c+r[7]*u+r[11]*d||1;return s[0]=(r[0]*c+r[4]*u+r[8]*d)/b,s[1]=(r[1]*c+r[5]*u+r[9]*d)/b,s[2]=(r[2]*c+r[6]*u+r[10]*d)/b,s}function Apt(s,n,r){let c=n[0],u=n[1];return s[0]=r[0]*c+r[2]*u,s[1]=r[1]*c+r[3]*u,s[2]=n[2],s}var M4e=Ve(()=>{});var wm={};Oy(wm,{add:()=>sZt,angle:()=>R4e,bezier:()=>wZt,ceil:()=>oZt,clone:()=>nZt,copy:()=>iZt,create:()=>qce,cross:()=>h4,dist:()=>CZt,distance:()=>Ipt,div:()=>TZt,divide:()=>Rpt,dot:()=>B$,equals:()=>EZt,exactEquals:()=>xZt,floor:()=>aZt,forEach:()=>LZt,fromValues:()=>Xce,hermite:()=>bZt,inverse:()=>pZt,len:()=>I4e,length:()=>Ppt,lerp:()=>gZt,max:()=>lZt,min:()=>cZt,mul:()=>MZt,multiply:()=>kpt,negate:()=>dZt,normalize:()=>T4e,random:()=>vZt,rotateX:()=>P4e,rotateY:()=>L4e,rotateZ:()=>k4e,round:()=>uZt,scale:()=>fZt,scaleAndAdd:()=>hZt,set:()=>rZt,slerp:()=>mZt,sqrDist:()=>AZt,sqrLen:()=>PZt,squaredDistance:()=>Dpt,squaredLength:()=>Bpt,str:()=>yZt,sub:()=>SZt,subtract:()=>Lpt,transformMat3:()=>C4e,transformMat4:()=>O$,transformQuat:()=>A4e,zero:()=>_Zt});function qce(){let s=new Cc(3);return Cc!=Float32Array&&(s[0]=0,s[1]=0,s[2]=0),s}function nZt(s){let n=new Cc(3);return n[0]=s[0],n[1]=s[1],n[2]=s[2],n}function Ppt(s){let n=s[0],r=s[1],c=s[2];return Math.sqrt(n*n+r*r+c*c)}function Xce(s,n,r){let c=new Cc(3);return c[0]=s,c[1]=n,c[2]=r,c}function iZt(s,n){return s[0]=n[0],s[1]=n[1],s[2]=n[2],s}function rZt(s,n,r,c){return s[0]=n,s[1]=r,s[2]=c,s}function sZt(s,n,r){return s[0]=n[0]+r[0],s[1]=n[1]+r[1],s[2]=n[2]+r[2],s}function Lpt(s,n,r){return s[0]=n[0]-r[0],s[1]=n[1]-r[1],s[2]=n[2]-r[2],s}function kpt(s,n,r){return s[0]=n[0]*r[0],s[1]=n[1]*r[1],s[2]=n[2]*r[2],s}function Rpt(s,n,r){return s[0]=n[0]/r[0],s[1]=n[1]/r[1],s[2]=n[2]/r[2],s}function oZt(s,n){return s[0]=Math.ceil(n[0]),s[1]=Math.ceil(n[1]),s[2]=Math.ceil(n[2]),s}function aZt(s,n){return s[0]=Math.floor(n[0]),s[1]=Math.floor(n[1]),s[2]=Math.floor(n[2]),s}function cZt(s,n,r){return s[0]=Math.min(n[0],r[0]),s[1]=Math.min(n[1],r[1]),s[2]=Math.min(n[2],r[2]),s}function lZt(s,n,r){return s[0]=Math.max(n[0],r[0]),s[1]=Math.max(n[1],r[1]),s[2]=Math.max(n[2],r[2]),s}function uZt(s,n){return s[0]=Ab(n[0]),s[1]=Ab(n[1]),s[2]=Ab(n[2]),s}function fZt(s,n,r){return s[0]=n[0]*r,s[1]=n[1]*r,s[2]=n[2]*r,s}function hZt(s,n,r,c){return s[0]=n[0]+r[0]*c,s[1]=n[1]+r[1]*c,s[2]=n[2]+r[2]*c,s}function Ipt(s,n){let r=n[0]-s[0],c=n[1]-s[1],u=n[2]-s[2];return Math.sqrt(r*r+c*c+u*u)}function Dpt(s,n){let r=n[0]-s[0],c=n[1]-s[1],u=n[2]-s[2];return r*r+c*c+u*u}function Bpt(s){let n=s[0],r=s[1],c=s[2];return n*n+r*r+c*c}function dZt(s,n){return s[0]=-n[0],s[1]=-n[1],s[2]=-n[2],s}function pZt(s,n){return s[0]=1/n[0],s[1]=1/n[1],s[2]=1/n[2],s}function T4e(s,n){let r=n[0],c=n[1],u=n[2],d=r*r+c*c+u*u;return d>0&&(d=1/Math.sqrt(d)),s[0]=n[0]*d,s[1]=n[1]*d,s[2]=n[2]*d,s}function B$(s,n){return s[0]*n[0]+s[1]*n[1]+s[2]*n[2]}function h4(s,n,r){let c=n[0],u=n[1],d=n[2],b=r[0],w=r[1],_=r[2];return s[0]=u*_-d*w,s[1]=d*b-c*_,s[2]=c*w-u*b,s}function gZt(s,n,r,c){let u=n[0],d=n[1],b=n[2];return s[0]=u+c*(r[0]-u),s[1]=d+c*(r[1]-d),s[2]=b+c*(r[2]-b),s}function mZt(s,n,r,c){let u=Math.acos(Math.min(Math.max(B$(n,r),-1),1)),d=Math.sin(u),b=Math.sin((1-c)*u)/d,w=Math.sin(c*u)/d;return s[0]=b*n[0]+w*r[0],s[1]=b*n[1]+w*r[1],s[2]=b*n[2]+w*r[2],s}function bZt(s,n,r,c,u,d){let b=d*d,w=b*(2*d-3)+1,_=b*(d-2)+d,x=b*(d-1),T=b*(3-2*d);return s[0]=n[0]*w+r[0]*_+c[0]*x+u[0]*T,s[1]=n[1]*w+r[1]*_+c[1]*x+u[1]*T,s[2]=n[2]*w+r[2]*_+c[2]*x+u[2]*T,s}function wZt(s,n,r,c,u,d){let b=1-d,w=b*b,_=d*d,x=w*b,T=3*d*w,M=3*_*b,L=_*d;return s[0]=n[0]*x+r[0]*T+c[0]*M+u[0]*L,s[1]=n[1]*x+r[1]*T+c[1]*M+u[1]*L,s[2]=n[2]*x+r[2]*T+c[2]*M+u[2]*L,s}function vZt(s,n){n=n===void 0?1:n;let r=Hy()*2*Math.PI,c=Hy()*2-1,u=Math.sqrt(1-c*c)*n;return s[0]=Math.cos(r)*u,s[1]=Math.sin(r)*u,s[2]=c*n,s}function O$(s,n,r){let c=n[0],u=n[1],d=n[2],b=r[3]*c+r[7]*u+r[11]*d+r[15];return b=b||1,s[0]=(r[0]*c+r[4]*u+r[8]*d+r[12])/b,s[1]=(r[1]*c+r[5]*u+r[9]*d+r[13])/b,s[2]=(r[2]*c+r[6]*u+r[10]*d+r[14])/b,s}function C4e(s,n,r){let c=n[0],u=n[1],d=n[2];return s[0]=c*r[0]+u*r[3]+d*r[6],s[1]=c*r[1]+u*r[4]+d*r[7],s[2]=c*r[2]+u*r[5]+d*r[8],s}function A4e(s,n,r){let c=r[0],u=r[1],d=r[2],b=r[3],w=n[0],_=n[1],x=n[2],T=u*x-d*_,M=d*w-c*x,L=c*_-u*w,I=u*L-d*M,D=d*T-c*L,F=c*M-u*T,O=b*2;return T*=O,M*=O,L*=O,I*=2,D*=2,F*=2,s[0]=w+T+I,s[1]=_+M+D,s[2]=x+L+F,s}function P4e(s,n,r,c){let u=[],d=[];return u[0]=n[0]-r[0],u[1]=n[1]-r[1],u[2]=n[2]-r[2],d[0]=u[0],d[1]=u[1]*Math.cos(c)-u[2]*Math.sin(c),d[2]=u[1]*Math.sin(c)+u[2]*Math.cos(c),s[0]=d[0]+r[0],s[1]=d[1]+r[1],s[2]=d[2]+r[2],s}function L4e(s,n,r,c){let u=[],d=[];return u[0]=n[0]-r[0],u[1]=n[1]-r[1],u[2]=n[2]-r[2],d[0]=u[2]*Math.sin(c)+u[0]*Math.cos(c),d[1]=u[1],d[2]=u[2]*Math.cos(c)-u[0]*Math.sin(c),s[0]=d[0]+r[0],s[1]=d[1]+r[1],s[2]=d[2]+r[2],s}function k4e(s,n,r,c){let u=[],d=[];return u[0]=n[0]-r[0],u[1]=n[1]-r[1],u[2]=n[2]-r[2],d[0]=u[0]*Math.cos(c)-u[1]*Math.sin(c),d[1]=u[0]*Math.sin(c)+u[1]*Math.cos(c),d[2]=u[2],s[0]=d[0]+r[0],s[1]=d[1]+r[1],s[2]=d[2]+r[2],s}function R4e(s,n){let r=s[0],c=s[1],u=s[2],d=n[0],b=n[1],w=n[2],_=Math.sqrt((r*r+c*c+u*u)*(d*d+b*b+w*w)),x=_&&B$(s,n)/_;return Math.acos(Math.min(Math.max(x,-1),1))}function _Zt(s){return s[0]=0,s[1]=0,s[2]=0,s}function yZt(s){return`vec3(${s[0]}, ${s[1]}, ${s[2]})`}function xZt(s,n){return s[0]===n[0]&&s[1]===n[1]&&s[2]===n[2]}function EZt(s,n){let r=s[0],c=s[1],u=s[2],d=n[0],b=n[1],w=n[2];return Math.abs(r-d)<=1e-6*Math.max(1,Math.abs(r),Math.abs(d))&&Math.abs(c-b)<=1e-6*Math.max(1,Math.abs(c),Math.abs(b))&&Math.abs(u-w)<=1e-6*Math.max(1,Math.abs(u),Math.abs(w))}var SZt,MZt,TZt,CZt,AZt,I4e,PZt,LZt,N$=Ve(()=>{f4();SZt=Lpt,MZt=kpt,TZt=Rpt,CZt=Ipt,AZt=Dpt,I4e=Ppt,PZt=Bpt,LZt=function(){let s=qce();return function(n,r,c,u,d,b){let w,_;for(r||(r=3),c||(c=0),u?_=Math.min(u*r+c,n.length):_=n.length,w=c;w<_;w+=r)s[0]=n[w],s[1]=n[w+1],s[2]=n[w+2],d(s,s,b),n[w]=s[0],n[w+1]=s[1],n[w+2]=s[2];return n}}()});var D4e,Yce,lp,Opt=Ve(()=>{wpt();qD();D$();N$();M4e();D4e=[0,0,0],lp=class s extends Wce{static get ZERO(){return Yce||(Yce=new s(0,0,0),Object.freeze(Yce)),Yce}constructor(n=0,r=0,c=0){super(-0,-0,-0),arguments.length===1&&P3(n)?this.copy(n):(jh.debug&&(cp(n),cp(r),cp(c)),this[0]=n,this[1]=r,this[2]=c)}set(n,r,c){return this[0]=n,this[1]=r,this[2]=c,this.check()}copy(n){return this[0]=n[0],this[1]=n[1],this[2]=n[2],this.check()}fromObject(n){return jh.debug&&(cp(n.x),cp(n.y),cp(n.z)),this[0]=n.x,this[1]=n.y,this[2]=n.z,this.check()}toObject(n){return n.x=this[0],n.y=this[1],n.z=this[2],n}get ELEMENTS(){return 3}get z(){return this[2]}set z(n){this[2]=cp(n)}angle(n){return R4e(this,n)}cross(n){return h4(this,this,n),this.check()}rotateX({radians:n,origin:r=D4e}){return P4e(this,this,r,n),this.check()}rotateY({radians:n,origin:r=D4e}){return L4e(this,this,r,n),this.check()}rotateZ({radians:n,origin:r=D4e}){return k4e(this,this,r,n),this.check()}transform(n){return this.transformAsPoint(n)}transformAsPoint(n){return O$(this,this,n),this.check()}transformAsVector(n){return Hce(this,this,n),this.check()}transformByMatrix3(n){return C4e(this,this,n),this.check()}transformByMatrix2(n){return Apt(this,this,n),this.check()}transformByQuaternion(n){return A4e(this,this,n),this.check()}}});var Zce,Npt=Ve(()=>{y4e();D$();qD();Zce=class extends XD{toString(){let n="[";if(jh.printRowMajor){n+="row-major:";for(let r=0;r{f4()});var fh={};Oy(fh,{add:()=>tKt,adjoint:()=>OZt,clone:()=>RZt,copy:()=>IZt,create:()=>kZt,decompose:()=>HZt,determinant:()=>F4e,equals:()=>sKt,exactEquals:()=>rKt,frob:()=>eKt,fromQuat:()=>W4e,fromQuat2:()=>$Zt,fromRotation:()=>UZt,fromRotationTranslation:()=>Gpt,fromRotationTranslationScale:()=>qZt,fromRotationTranslationScaleOrigin:()=>XZt,fromScaling:()=>FZt,fromTranslation:()=>NZt,fromValues:()=>DZt,fromXRotation:()=>zZt,fromYRotation:()=>GZt,fromZRotation:()=>jZt,frustum:()=>H4e,getRotation:()=>WZt,getScaling:()=>jpt,getTranslation:()=>VZt,identity:()=>zpt,invert:()=>N4e,lookAt:()=>Y4e,mul:()=>oKt,multiply:()=>F$,multiplyScalar:()=>nKt,multiplyScalarAndAdd:()=>iKt,ortho:()=>X4e,orthoNO:()=>Vpt,orthoZO:()=>KZt,perspective:()=>q4e,perspectiveFromFieldOfView:()=>ZZt,perspectiveNO:()=>$pt,perspectiveZO:()=>YZt,rotate:()=>G4e,rotateX:()=>j4e,rotateY:()=>$4e,rotateZ:()=>V4e,scale:()=>z4e,set:()=>BZt,str:()=>QZt,sub:()=>aKt,subtract:()=>Wpt,targetTo:()=>JZt,translate:()=>U4e,transpose:()=>O4e});function kZt(){let s=new Cc(16);return Cc!=Float32Array&&(s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[11]=0,s[12]=0,s[13]=0,s[14]=0),s[0]=1,s[5]=1,s[10]=1,s[15]=1,s}function RZt(s){let n=new Cc(16);return n[0]=s[0],n[1]=s[1],n[2]=s[2],n[3]=s[3],n[4]=s[4],n[5]=s[5],n[6]=s[6],n[7]=s[7],n[8]=s[8],n[9]=s[9],n[10]=s[10],n[11]=s[11],n[12]=s[12],n[13]=s[13],n[14]=s[14],n[15]=s[15],n}function IZt(s,n){return s[0]=n[0],s[1]=n[1],s[2]=n[2],s[3]=n[3],s[4]=n[4],s[5]=n[5],s[6]=n[6],s[7]=n[7],s[8]=n[8],s[9]=n[9],s[10]=n[10],s[11]=n[11],s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15],s}function DZt(s,n,r,c,u,d,b,w,_,x,T,M,L,I,D,F){let O=new Cc(16);return O[0]=s,O[1]=n,O[2]=r,O[3]=c,O[4]=u,O[5]=d,O[6]=b,O[7]=w,O[8]=_,O[9]=x,O[10]=T,O[11]=M,O[12]=L,O[13]=I,O[14]=D,O[15]=F,O}function BZt(s,n,r,c,u,d,b,w,_,x,T,M,L,I,D,F,O){return s[0]=n,s[1]=r,s[2]=c,s[3]=u,s[4]=d,s[5]=b,s[6]=w,s[7]=_,s[8]=x,s[9]=T,s[10]=M,s[11]=L,s[12]=I,s[13]=D,s[14]=F,s[15]=O,s}function zpt(s){return s[0]=1,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=1,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=1,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function O4e(s,n){if(s===n){let r=n[1],c=n[2],u=n[3],d=n[6],b=n[7],w=n[11];s[1]=n[4],s[2]=n[8],s[3]=n[12],s[4]=r,s[6]=n[9],s[7]=n[13],s[8]=c,s[9]=d,s[11]=n[14],s[12]=u,s[13]=b,s[14]=w}else s[0]=n[0],s[1]=n[4],s[2]=n[8],s[3]=n[12],s[4]=n[1],s[5]=n[5],s[6]=n[9],s[7]=n[13],s[8]=n[2],s[9]=n[6],s[10]=n[10],s[11]=n[14],s[12]=n[3],s[13]=n[7],s[14]=n[11],s[15]=n[15];return s}function N4e(s,n){let r=n[0],c=n[1],u=n[2],d=n[3],b=n[4],w=n[5],_=n[6],x=n[7],T=n[8],M=n[9],L=n[10],I=n[11],D=n[12],F=n[13],O=n[14],z=n[15],Z=r*w-c*b,H=r*_-u*b,te=r*x-d*b,oe=c*_-u*w,ne=c*x-d*w,ue=u*x-d*_,Te=T*F-M*D,Q=T*O-L*D,ge=T*z-I*D,Qe=M*O-L*F,st=M*z-I*F,at=L*z-I*O,Ne=Z*at-H*st+te*Qe+oe*ge-ne*Q+ue*Te;return Ne?(Ne=1/Ne,s[0]=(w*at-_*st+x*Qe)*Ne,s[1]=(u*st-c*at-d*Qe)*Ne,s[2]=(F*ue-O*ne+z*oe)*Ne,s[3]=(L*ne-M*ue-I*oe)*Ne,s[4]=(_*ge-b*at-x*Q)*Ne,s[5]=(r*at-u*ge+d*Q)*Ne,s[6]=(O*te-D*ue-z*H)*Ne,s[7]=(T*ue-L*te+I*H)*Ne,s[8]=(b*st-w*ge+x*Te)*Ne,s[9]=(c*ge-r*st-d*Te)*Ne,s[10]=(D*ne-F*te+z*Z)*Ne,s[11]=(M*te-T*ne-I*Z)*Ne,s[12]=(w*Q-b*Qe-_*Te)*Ne,s[13]=(r*Qe-c*Q+u*Te)*Ne,s[14]=(F*H-D*oe-O*Z)*Ne,s[15]=(T*oe-M*H+L*Z)*Ne,s):null}function OZt(s,n){let r=n[0],c=n[1],u=n[2],d=n[3],b=n[4],w=n[5],_=n[6],x=n[7],T=n[8],M=n[9],L=n[10],I=n[11],D=n[12],F=n[13],O=n[14],z=n[15],Z=r*w-c*b,H=r*_-u*b,te=r*x-d*b,oe=c*_-u*w,ne=c*x-d*w,ue=u*x-d*_,Te=T*F-M*D,Q=T*O-L*D,ge=T*z-I*D,Qe=M*O-L*F,st=M*z-I*F,at=L*z-I*O;return s[0]=w*at-_*st+x*Qe,s[1]=u*st-c*at-d*Qe,s[2]=F*ue-O*ne+z*oe,s[3]=L*ne-M*ue-I*oe,s[4]=_*ge-b*at-x*Q,s[5]=r*at-u*ge+d*Q,s[6]=O*te-D*ue-z*H,s[7]=T*ue-L*te+I*H,s[8]=b*st-w*ge+x*Te,s[9]=c*ge-r*st-d*Te,s[10]=D*ne-F*te+z*Z,s[11]=M*te-T*ne-I*Z,s[12]=w*Q-b*Qe-_*Te,s[13]=r*Qe-c*Q+u*Te,s[14]=F*H-D*oe-O*Z,s[15]=T*oe-M*H+L*Z,s}function F4e(s){let n=s[0],r=s[1],c=s[2],u=s[3],d=s[4],b=s[5],w=s[6],_=s[7],x=s[8],T=s[9],M=s[10],L=s[11],I=s[12],D=s[13],F=s[14],O=s[15],z=n*b-r*d,Z=n*w-c*d,H=r*w-c*b,te=x*D-T*I,oe=x*F-M*I,ne=T*F-M*D,ue=n*ne-r*oe+c*te,Te=d*ne-b*oe+w*te,Q=x*H-T*Z+M*z,ge=I*H-D*Z+F*z;return _*ue-u*Te+O*Q-L*ge}function F$(s,n,r){let c=n[0],u=n[1],d=n[2],b=n[3],w=n[4],_=n[5],x=n[6],T=n[7],M=n[8],L=n[9],I=n[10],D=n[11],F=n[12],O=n[13],z=n[14],Z=n[15],H=r[0],te=r[1],oe=r[2],ne=r[3];return s[0]=H*c+te*w+oe*M+ne*F,s[1]=H*u+te*_+oe*L+ne*O,s[2]=H*d+te*x+oe*I+ne*z,s[3]=H*b+te*T+oe*D+ne*Z,H=r[4],te=r[5],oe=r[6],ne=r[7],s[4]=H*c+te*w+oe*M+ne*F,s[5]=H*u+te*_+oe*L+ne*O,s[6]=H*d+te*x+oe*I+ne*z,s[7]=H*b+te*T+oe*D+ne*Z,H=r[8],te=r[9],oe=r[10],ne=r[11],s[8]=H*c+te*w+oe*M+ne*F,s[9]=H*u+te*_+oe*L+ne*O,s[10]=H*d+te*x+oe*I+ne*z,s[11]=H*b+te*T+oe*D+ne*Z,H=r[12],te=r[13],oe=r[14],ne=r[15],s[12]=H*c+te*w+oe*M+ne*F,s[13]=H*u+te*_+oe*L+ne*O,s[14]=H*d+te*x+oe*I+ne*z,s[15]=H*b+te*T+oe*D+ne*Z,s}function U4e(s,n,r){let c=r[0],u=r[1],d=r[2],b,w,_,x,T,M,L,I,D,F,O,z;return n===s?(s[12]=n[0]*c+n[4]*u+n[8]*d+n[12],s[13]=n[1]*c+n[5]*u+n[9]*d+n[13],s[14]=n[2]*c+n[6]*u+n[10]*d+n[14],s[15]=n[3]*c+n[7]*u+n[11]*d+n[15]):(b=n[0],w=n[1],_=n[2],x=n[3],T=n[4],M=n[5],L=n[6],I=n[7],D=n[8],F=n[9],O=n[10],z=n[11],s[0]=b,s[1]=w,s[2]=_,s[3]=x,s[4]=T,s[5]=M,s[6]=L,s[7]=I,s[8]=D,s[9]=F,s[10]=O,s[11]=z,s[12]=b*c+T*u+D*d+n[12],s[13]=w*c+M*u+F*d+n[13],s[14]=_*c+L*u+O*d+n[14],s[15]=x*c+I*u+z*d+n[15]),s}function z4e(s,n,r){let c=r[0],u=r[1],d=r[2];return s[0]=n[0]*c,s[1]=n[1]*c,s[2]=n[2]*c,s[3]=n[3]*c,s[4]=n[4]*u,s[5]=n[5]*u,s[6]=n[6]*u,s[7]=n[7]*u,s[8]=n[8]*d,s[9]=n[9]*d,s[10]=n[10]*d,s[11]=n[11]*d,s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15],s}function G4e(s,n,r,c){let u=c[0],d=c[1],b=c[2],w=Math.sqrt(u*u+d*d+b*b),_,x,T,M,L,I,D,F,O,z,Z,H,te,oe,ne,ue,Te,Q,ge,Qe,st,at,Ne,tt;return w<1e-6?null:(w=1/w,u*=w,d*=w,b*=w,x=Math.sin(r),_=Math.cos(r),T=1-_,M=n[0],L=n[1],I=n[2],D=n[3],F=n[4],O=n[5],z=n[6],Z=n[7],H=n[8],te=n[9],oe=n[10],ne=n[11],ue=u*u*T+_,Te=d*u*T+b*x,Q=b*u*T-d*x,ge=u*d*T-b*x,Qe=d*d*T+_,st=b*d*T+u*x,at=u*b*T+d*x,Ne=d*b*T-u*x,tt=b*b*T+_,s[0]=M*ue+F*Te+H*Q,s[1]=L*ue+O*Te+te*Q,s[2]=I*ue+z*Te+oe*Q,s[3]=D*ue+Z*Te+ne*Q,s[4]=M*ge+F*Qe+H*st,s[5]=L*ge+O*Qe+te*st,s[6]=I*ge+z*Qe+oe*st,s[7]=D*ge+Z*Qe+ne*st,s[8]=M*at+F*Ne+H*tt,s[9]=L*at+O*Ne+te*tt,s[10]=I*at+z*Ne+oe*tt,s[11]=D*at+Z*Ne+ne*tt,n!==s&&(s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15]),s)}function j4e(s,n,r){let c=Math.sin(r),u=Math.cos(r),d=n[4],b=n[5],w=n[6],_=n[7],x=n[8],T=n[9],M=n[10],L=n[11];return n!==s&&(s[0]=n[0],s[1]=n[1],s[2]=n[2],s[3]=n[3],s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15]),s[4]=d*u+x*c,s[5]=b*u+T*c,s[6]=w*u+M*c,s[7]=_*u+L*c,s[8]=x*u-d*c,s[9]=T*u-b*c,s[10]=M*u-w*c,s[11]=L*u-_*c,s}function $4e(s,n,r){let c=Math.sin(r),u=Math.cos(r),d=n[0],b=n[1],w=n[2],_=n[3],x=n[8],T=n[9],M=n[10],L=n[11];return n!==s&&(s[4]=n[4],s[5]=n[5],s[6]=n[6],s[7]=n[7],s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15]),s[0]=d*u-x*c,s[1]=b*u-T*c,s[2]=w*u-M*c,s[3]=_*u-L*c,s[8]=d*c+x*u,s[9]=b*c+T*u,s[10]=w*c+M*u,s[11]=_*c+L*u,s}function V4e(s,n,r){let c=Math.sin(r),u=Math.cos(r),d=n[0],b=n[1],w=n[2],_=n[3],x=n[4],T=n[5],M=n[6],L=n[7];return n!==s&&(s[8]=n[8],s[9]=n[9],s[10]=n[10],s[11]=n[11],s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15]),s[0]=d*u+x*c,s[1]=b*u+T*c,s[2]=w*u+M*c,s[3]=_*u+L*c,s[4]=x*u-d*c,s[5]=T*u-b*c,s[6]=M*u-w*c,s[7]=L*u-_*c,s}function NZt(s,n){return s[0]=1,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=1,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=1,s[11]=0,s[12]=n[0],s[13]=n[1],s[14]=n[2],s[15]=1,s}function FZt(s,n){return s[0]=n[0],s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=n[1],s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=n[2],s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function UZt(s,n,r){let c=r[0],u=r[1],d=r[2],b=Math.sqrt(c*c+u*u+d*d),w,_,x;return b<1e-6?null:(b=1/b,c*=b,u*=b,d*=b,_=Math.sin(n),w=Math.cos(n),x=1-w,s[0]=c*c*x+w,s[1]=u*c*x+d*_,s[2]=d*c*x-u*_,s[3]=0,s[4]=c*u*x-d*_,s[5]=u*u*x+w,s[6]=d*u*x+c*_,s[7]=0,s[8]=c*d*x+u*_,s[9]=u*d*x-c*_,s[10]=d*d*x+w,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s)}function zZt(s,n){let r=Math.sin(n),c=Math.cos(n);return s[0]=1,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=c,s[6]=r,s[7]=0,s[8]=0,s[9]=-r,s[10]=c,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function GZt(s,n){let r=Math.sin(n),c=Math.cos(n);return s[0]=c,s[1]=0,s[2]=-r,s[3]=0,s[4]=0,s[5]=1,s[6]=0,s[7]=0,s[8]=r,s[9]=0,s[10]=c,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function jZt(s,n){let r=Math.sin(n),c=Math.cos(n);return s[0]=c,s[1]=r,s[2]=0,s[3]=0,s[4]=-r,s[5]=c,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=1,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function Gpt(s,n,r){let c=n[0],u=n[1],d=n[2],b=n[3],w=c+c,_=u+u,x=d+d,T=c*w,M=c*_,L=c*x,I=u*_,D=u*x,F=d*x,O=b*w,z=b*_,Z=b*x;return s[0]=1-(I+F),s[1]=M+Z,s[2]=L-z,s[3]=0,s[4]=M-Z,s[5]=1-(T+F),s[6]=D+O,s[7]=0,s[8]=L+z,s[9]=D-O,s[10]=1-(T+I),s[11]=0,s[12]=r[0],s[13]=r[1],s[14]=r[2],s[15]=1,s}function $Zt(s,n){let r=new Cc(3),c=-n[0],u=-n[1],d=-n[2],b=n[3],w=n[4],_=n[5],x=n[6],T=n[7],M=c*c+u*u+d*d+b*b;return M>0?(r[0]=(w*b+T*c+_*d-x*u)*2/M,r[1]=(_*b+T*u+x*c-w*d)*2/M,r[2]=(x*b+T*d+w*u-_*c)*2/M):(r[0]=(w*b+T*c+_*d-x*u)*2,r[1]=(_*b+T*u+x*c-w*d)*2,r[2]=(x*b+T*d+w*u-_*c)*2),Gpt(s,n,r),s}function VZt(s,n){return s[0]=n[12],s[1]=n[13],s[2]=n[14],s}function jpt(s,n){let r=n[0],c=n[1],u=n[2],d=n[4],b=n[5],w=n[6],_=n[8],x=n[9],T=n[10];return s[0]=Math.sqrt(r*r+c*c+u*u),s[1]=Math.sqrt(d*d+b*b+w*w),s[2]=Math.sqrt(_*_+x*x+T*T),s}function WZt(s,n){let r=new Cc(3);jpt(r,n);let c=1/r[0],u=1/r[1],d=1/r[2],b=n[0]*c,w=n[1]*u,_=n[2]*d,x=n[4]*c,T=n[5]*u,M=n[6]*d,L=n[8]*c,I=n[9]*u,D=n[10]*d,F=b+T+D,O=0;return F>0?(O=Math.sqrt(F+1)*2,s[3]=.25*O,s[0]=(M-I)/O,s[1]=(L-_)/O,s[2]=(w-x)/O):b>T&&b>D?(O=Math.sqrt(1+b-T-D)*2,s[3]=(M-I)/O,s[0]=.25*O,s[1]=(w+x)/O,s[2]=(L+_)/O):T>D?(O=Math.sqrt(1+T-b-D)*2,s[3]=(L-_)/O,s[0]=(w+x)/O,s[1]=.25*O,s[2]=(M+I)/O):(O=Math.sqrt(1+D-b-T)*2,s[3]=(w-x)/O,s[0]=(L+_)/O,s[1]=(M+I)/O,s[2]=.25*O),s}function HZt(s,n,r,c){n[0]=c[12],n[1]=c[13],n[2]=c[14];let u=c[0],d=c[1],b=c[2],w=c[4],_=c[5],x=c[6],T=c[8],M=c[9],L=c[10];r[0]=Math.sqrt(u*u+d*d+b*b),r[1]=Math.sqrt(w*w+_*_+x*x),r[2]=Math.sqrt(T*T+M*M+L*L);let I=1/r[0],D=1/r[1],F=1/r[2],O=u*I,z=d*D,Z=b*F,H=w*I,te=_*D,oe=x*F,ne=T*I,ue=M*D,Te=L*F,Q=O+te+Te,ge=0;return Q>0?(ge=Math.sqrt(Q+1)*2,s[3]=.25*ge,s[0]=(oe-ue)/ge,s[1]=(ne-Z)/ge,s[2]=(z-H)/ge):O>te&&O>Te?(ge=Math.sqrt(1+O-te-Te)*2,s[3]=(oe-ue)/ge,s[0]=.25*ge,s[1]=(z+H)/ge,s[2]=(ne+Z)/ge):te>Te?(ge=Math.sqrt(1+te-O-Te)*2,s[3]=(ne-Z)/ge,s[0]=(z+H)/ge,s[1]=.25*ge,s[2]=(oe+ue)/ge):(ge=Math.sqrt(1+Te-O-te)*2,s[3]=(z-H)/ge,s[0]=(ne+Z)/ge,s[1]=(oe+ue)/ge,s[2]=.25*ge),s}function qZt(s,n,r,c){let u=n[0],d=n[1],b=n[2],w=n[3],_=u+u,x=d+d,T=b+b,M=u*_,L=u*x,I=u*T,D=d*x,F=d*T,O=b*T,z=w*_,Z=w*x,H=w*T,te=c[0],oe=c[1],ne=c[2];return s[0]=(1-(D+O))*te,s[1]=(L+H)*te,s[2]=(I-Z)*te,s[3]=0,s[4]=(L-H)*oe,s[5]=(1-(M+O))*oe,s[6]=(F+z)*oe,s[7]=0,s[8]=(I+Z)*ne,s[9]=(F-z)*ne,s[10]=(1-(M+D))*ne,s[11]=0,s[12]=r[0],s[13]=r[1],s[14]=r[2],s[15]=1,s}function XZt(s,n,r,c,u){let d=n[0],b=n[1],w=n[2],_=n[3],x=d+d,T=b+b,M=w+w,L=d*x,I=d*T,D=d*M,F=b*T,O=b*M,z=w*M,Z=_*x,H=_*T,te=_*M,oe=c[0],ne=c[1],ue=c[2],Te=u[0],Q=u[1],ge=u[2],Qe=(1-(F+z))*oe,st=(I+te)*oe,at=(D-H)*oe,Ne=(I-te)*ne,tt=(1-(L+z))*ne,ot=(O+Z)*ne,Tt=(D+H)*ue,jt=(O-Z)*ue,en=(1-(L+F))*ue;return s[0]=Qe,s[1]=st,s[2]=at,s[3]=0,s[4]=Ne,s[5]=tt,s[6]=ot,s[7]=0,s[8]=Tt,s[9]=jt,s[10]=en,s[11]=0,s[12]=r[0]+Te-(Qe*Te+Ne*Q+Tt*ge),s[13]=r[1]+Q-(st*Te+tt*Q+jt*ge),s[14]=r[2]+ge-(at*Te+ot*Q+en*ge),s[15]=1,s}function W4e(s,n){let r=n[0],c=n[1],u=n[2],d=n[3],b=r+r,w=c+c,_=u+u,x=r*b,T=c*b,M=c*w,L=u*b,I=u*w,D=u*_,F=d*b,O=d*w,z=d*_;return s[0]=1-M-D,s[1]=T+z,s[2]=L-O,s[3]=0,s[4]=T-z,s[5]=1-x-D,s[6]=I+F,s[7]=0,s[8]=L+O,s[9]=I-F,s[10]=1-x-M,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function H4e(s,n,r,c,u,d,b){let w=1/(r-n),_=1/(u-c),x=1/(d-b);return s[0]=d*2*w,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=d*2*_,s[6]=0,s[7]=0,s[8]=(r+n)*w,s[9]=(u+c)*_,s[10]=(b+d)*x,s[11]=-1,s[12]=0,s[13]=0,s[14]=b*d*2*x,s[15]=0,s}function $pt(s,n,r,c,u){let d=1/Math.tan(n/2);if(s[0]=d/r,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=d,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[11]=-1,s[12]=0,s[13]=0,s[15]=0,u!=null&&u!==1/0){let b=1/(c-u);s[10]=(u+c)*b,s[14]=2*u*c*b}else s[10]=-1,s[14]=-2*c;return s}function YZt(s,n,r,c,u){let d=1/Math.tan(n/2);if(s[0]=d/r,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=d,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[11]=-1,s[12]=0,s[13]=0,s[15]=0,u!=null&&u!==1/0){let b=1/(c-u);s[10]=u*b,s[14]=u*c*b}else s[10]=-1,s[14]=-c;return s}function ZZt(s,n,r,c){let u=Math.tan(n.upDegrees*Math.PI/180),d=Math.tan(n.downDegrees*Math.PI/180),b=Math.tan(n.leftDegrees*Math.PI/180),w=Math.tan(n.rightDegrees*Math.PI/180),_=2/(b+w),x=2/(u+d);return s[0]=_,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=x,s[6]=0,s[7]=0,s[8]=-((b-w)*_*.5),s[9]=(u-d)*x*.5,s[10]=c/(r-c),s[11]=-1,s[12]=0,s[13]=0,s[14]=c*r/(r-c),s[15]=0,s}function Vpt(s,n,r,c,u,d,b){let w=1/(n-r),_=1/(c-u),x=1/(d-b);return s[0]=-2*w,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=-2*_,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=2*x,s[11]=0,s[12]=(n+r)*w,s[13]=(u+c)*_,s[14]=(b+d)*x,s[15]=1,s}function KZt(s,n,r,c,u,d,b){let w=1/(n-r),_=1/(c-u),x=1/(d-b);return s[0]=-2*w,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=-2*_,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=x,s[11]=0,s[12]=(n+r)*w,s[13]=(u+c)*_,s[14]=d*x,s[15]=1,s}function Y4e(s,n,r,c){let u,d,b,w,_,x,T,M,L,I,D=n[0],F=n[1],O=n[2],z=c[0],Z=c[1],H=c[2],te=r[0],oe=r[1],ne=r[2];return Math.abs(D-te)<1e-6&&Math.abs(F-oe)<1e-6&&Math.abs(O-ne)<1e-6?zpt(s):(M=D-te,L=F-oe,I=O-ne,u=1/Math.sqrt(M*M+L*L+I*I),M*=u,L*=u,I*=u,d=Z*I-H*L,b=H*M-z*I,w=z*L-Z*M,u=Math.sqrt(d*d+b*b+w*w),u?(u=1/u,d*=u,b*=u,w*=u):(d=0,b=0,w=0),_=L*w-I*b,x=I*d-M*w,T=M*b-L*d,u=Math.sqrt(_*_+x*x+T*T),u?(u=1/u,_*=u,x*=u,T*=u):(_=0,x=0,T=0),s[0]=d,s[1]=_,s[2]=M,s[3]=0,s[4]=b,s[5]=x,s[6]=L,s[7]=0,s[8]=w,s[9]=T,s[10]=I,s[11]=0,s[12]=-(d*D+b*F+w*O),s[13]=-(_*D+x*F+T*O),s[14]=-(M*D+L*F+I*O),s[15]=1,s)}function JZt(s,n,r,c){let u=n[0],d=n[1],b=n[2],w=c[0],_=c[1],x=c[2],T=u-r[0],M=d-r[1],L=b-r[2],I=T*T+M*M+L*L;I>0&&(I=1/Math.sqrt(I),T*=I,M*=I,L*=I);let D=_*L-x*M,F=x*T-w*L,O=w*M-_*T;return I=D*D+F*F+O*O,I>0&&(I=1/Math.sqrt(I),D*=I,F*=I,O*=I),s[0]=D,s[1]=F,s[2]=O,s[3]=0,s[4]=M*O-L*F,s[5]=L*D-T*O,s[6]=T*F-M*D,s[7]=0,s[8]=T,s[9]=M,s[10]=L,s[11]=0,s[12]=u,s[13]=d,s[14]=b,s[15]=1,s}function QZt(s){return`mat4(${s[0]}, ${s[1]}, ${s[2]}, ${s[3]}, ${s[4]}, ${s[5]}, ${s[6]}, ${s[7]}, ${s[8]}, ${s[9]}, ${s[10]}, ${s[11]}, ${s[12]}, ${s[13]}, ${s[14]}, ${s[15]})`}function eKt(s){return Math.sqrt(s[0]*s[0]+s[1]*s[1]+s[2]*s[2]+s[3]*s[3]+s[4]*s[4]+s[5]*s[5]+s[6]*s[6]+s[7]*s[7]+s[8]*s[8]+s[9]*s[9]+s[10]*s[10]+s[11]*s[11]+s[12]*s[12]+s[13]*s[13]+s[14]*s[14]+s[15]*s[15])}function tKt(s,n,r){return s[0]=n[0]+r[0],s[1]=n[1]+r[1],s[2]=n[2]+r[2],s[3]=n[3]+r[3],s[4]=n[4]+r[4],s[5]=n[5]+r[5],s[6]=n[6]+r[6],s[7]=n[7]+r[7],s[8]=n[8]+r[8],s[9]=n[9]+r[9],s[10]=n[10]+r[10],s[11]=n[11]+r[11],s[12]=n[12]+r[12],s[13]=n[13]+r[13],s[14]=n[14]+r[14],s[15]=n[15]+r[15],s}function Wpt(s,n,r){return s[0]=n[0]-r[0],s[1]=n[1]-r[1],s[2]=n[2]-r[2],s[3]=n[3]-r[3],s[4]=n[4]-r[4],s[5]=n[5]-r[5],s[6]=n[6]-r[6],s[7]=n[7]-r[7],s[8]=n[8]-r[8],s[9]=n[9]-r[9],s[10]=n[10]-r[10],s[11]=n[11]-r[11],s[12]=n[12]-r[12],s[13]=n[13]-r[13],s[14]=n[14]-r[14],s[15]=n[15]-r[15],s}function nKt(s,n,r){return s[0]=n[0]*r,s[1]=n[1]*r,s[2]=n[2]*r,s[3]=n[3]*r,s[4]=n[4]*r,s[5]=n[5]*r,s[6]=n[6]*r,s[7]=n[7]*r,s[8]=n[8]*r,s[9]=n[9]*r,s[10]=n[10]*r,s[11]=n[11]*r,s[12]=n[12]*r,s[13]=n[13]*r,s[14]=n[14]*r,s[15]=n[15]*r,s}function iKt(s,n,r,c){return s[0]=n[0]+r[0]*c,s[1]=n[1]+r[1]*c,s[2]=n[2]+r[2]*c,s[3]=n[3]+r[3]*c,s[4]=n[4]+r[4]*c,s[5]=n[5]+r[5]*c,s[6]=n[6]+r[6]*c,s[7]=n[7]+r[7]*c,s[8]=n[8]+r[8]*c,s[9]=n[9]+r[9]*c,s[10]=n[10]+r[10]*c,s[11]=n[11]+r[11]*c,s[12]=n[12]+r[12]*c,s[13]=n[13]+r[13]*c,s[14]=n[14]+r[14]*c,s[15]=n[15]+r[15]*c,s}function rKt(s,n){return s[0]===n[0]&&s[1]===n[1]&&s[2]===n[2]&&s[3]===n[3]&&s[4]===n[4]&&s[5]===n[5]&&s[6]===n[6]&&s[7]===n[7]&&s[8]===n[8]&&s[9]===n[9]&&s[10]===n[10]&&s[11]===n[11]&&s[12]===n[12]&&s[13]===n[13]&&s[14]===n[14]&&s[15]===n[15]}function sKt(s,n){let r=s[0],c=s[1],u=s[2],d=s[3],b=s[4],w=s[5],_=s[6],x=s[7],T=s[8],M=s[9],L=s[10],I=s[11],D=s[12],F=s[13],O=s[14],z=s[15],Z=n[0],H=n[1],te=n[2],oe=n[3],ne=n[4],ue=n[5],Te=n[6],Q=n[7],ge=n[8],Qe=n[9],st=n[10],at=n[11],Ne=n[12],tt=n[13],ot=n[14],Tt=n[15];return Math.abs(r-Z)<=1e-6*Math.max(1,Math.abs(r),Math.abs(Z))&&Math.abs(c-H)<=1e-6*Math.max(1,Math.abs(c),Math.abs(H))&&Math.abs(u-te)<=1e-6*Math.max(1,Math.abs(u),Math.abs(te))&&Math.abs(d-oe)<=1e-6*Math.max(1,Math.abs(d),Math.abs(oe))&&Math.abs(b-ne)<=1e-6*Math.max(1,Math.abs(b),Math.abs(ne))&&Math.abs(w-ue)<=1e-6*Math.max(1,Math.abs(w),Math.abs(ue))&&Math.abs(_-Te)<=1e-6*Math.max(1,Math.abs(_),Math.abs(Te))&&Math.abs(x-Q)<=1e-6*Math.max(1,Math.abs(x),Math.abs(Q))&&Math.abs(T-ge)<=1e-6*Math.max(1,Math.abs(T),Math.abs(ge))&&Math.abs(M-Qe)<=1e-6*Math.max(1,Math.abs(M),Math.abs(Qe))&&Math.abs(L-st)<=1e-6*Math.max(1,Math.abs(L),Math.abs(st))&&Math.abs(I-at)<=1e-6*Math.max(1,Math.abs(I),Math.abs(at))&&Math.abs(D-Ne)<=1e-6*Math.max(1,Math.abs(D),Math.abs(Ne))&&Math.abs(F-tt)<=1e-6*Math.max(1,Math.abs(F),Math.abs(tt))&&Math.abs(O-ot)<=1e-6*Math.max(1,Math.abs(O),Math.abs(ot))&&Math.abs(z-Tt)<=1e-6*Math.max(1,Math.abs(z),Math.abs(Tt))}var q4e,X4e,oKt,aKt,Z4e=Ve(()=>{f4();q4e=$pt;X4e=Vpt;oKt=F$,aKt=Wpt});var U1={};Oy(U1,{add:()=>Kpt,ceil:()=>cKt,clone:()=>qpt,copy:()=>Ypt,create:()=>Hpt,cross:()=>mKt,dist:()=>MKt,distance:()=>ngt,div:()=>SKt,divide:()=>egt,dot:()=>rgt,equals:()=>yKt,exactEquals:()=>ogt,floor:()=>lKt,forEach:()=>PKt,fromValues:()=>Xpt,inverse:()=>gKt,len:()=>CKt,length:()=>K4e,lerp:()=>sgt,max:()=>fKt,min:()=>uKt,mul:()=>EKt,multiply:()=>Qpt,negate:()=>pKt,normalize:()=>Q4e,random:()=>bKt,round:()=>hKt,scale:()=>tgt,scaleAndAdd:()=>dKt,set:()=>Zpt,sqrDist:()=>TKt,sqrLen:()=>AKt,squaredDistance:()=>igt,squaredLength:()=>J4e,str:()=>_Kt,sub:()=>xKt,subtract:()=>Jpt,transformMat4:()=>eke,transformQuat:()=>wKt,zero:()=>vKt});function Hpt(){let s=new Cc(4);return Cc!=Float32Array&&(s[0]=0,s[1]=0,s[2]=0,s[3]=0),s}function qpt(s){let n=new Cc(4);return n[0]=s[0],n[1]=s[1],n[2]=s[2],n[3]=s[3],n}function Xpt(s,n,r,c){let u=new Cc(4);return u[0]=s,u[1]=n,u[2]=r,u[3]=c,u}function Ypt(s,n){return s[0]=n[0],s[1]=n[1],s[2]=n[2],s[3]=n[3],s}function Zpt(s,n,r,c,u){return s[0]=n,s[1]=r,s[2]=c,s[3]=u,s}function Kpt(s,n,r){return s[0]=n[0]+r[0],s[1]=n[1]+r[1],s[2]=n[2]+r[2],s[3]=n[3]+r[3],s}function Jpt(s,n,r){return s[0]=n[0]-r[0],s[1]=n[1]-r[1],s[2]=n[2]-r[2],s[3]=n[3]-r[3],s}function Qpt(s,n,r){return s[0]=n[0]*r[0],s[1]=n[1]*r[1],s[2]=n[2]*r[2],s[3]=n[3]*r[3],s}function egt(s,n,r){return s[0]=n[0]/r[0],s[1]=n[1]/r[1],s[2]=n[2]/r[2],s[3]=n[3]/r[3],s}function cKt(s,n){return s[0]=Math.ceil(n[0]),s[1]=Math.ceil(n[1]),s[2]=Math.ceil(n[2]),s[3]=Math.ceil(n[3]),s}function lKt(s,n){return s[0]=Math.floor(n[0]),s[1]=Math.floor(n[1]),s[2]=Math.floor(n[2]),s[3]=Math.floor(n[3]),s}function uKt(s,n,r){return s[0]=Math.min(n[0],r[0]),s[1]=Math.min(n[1],r[1]),s[2]=Math.min(n[2],r[2]),s[3]=Math.min(n[3],r[3]),s}function fKt(s,n,r){return s[0]=Math.max(n[0],r[0]),s[1]=Math.max(n[1],r[1]),s[2]=Math.max(n[2],r[2]),s[3]=Math.max(n[3],r[3]),s}function hKt(s,n){return s[0]=Ab(n[0]),s[1]=Ab(n[1]),s[2]=Ab(n[2]),s[3]=Ab(n[3]),s}function tgt(s,n,r){return s[0]=n[0]*r,s[1]=n[1]*r,s[2]=n[2]*r,s[3]=n[3]*r,s}function dKt(s,n,r,c){return s[0]=n[0]+r[0]*c,s[1]=n[1]+r[1]*c,s[2]=n[2]+r[2]*c,s[3]=n[3]+r[3]*c,s}function ngt(s,n){let r=n[0]-s[0],c=n[1]-s[1],u=n[2]-s[2],d=n[3]-s[3];return Math.sqrt(r*r+c*c+u*u+d*d)}function igt(s,n){let r=n[0]-s[0],c=n[1]-s[1],u=n[2]-s[2],d=n[3]-s[3];return r*r+c*c+u*u+d*d}function K4e(s){let n=s[0],r=s[1],c=s[2],u=s[3];return Math.sqrt(n*n+r*r+c*c+u*u)}function J4e(s){let n=s[0],r=s[1],c=s[2],u=s[3];return n*n+r*r+c*c+u*u}function pKt(s,n){return s[0]=-n[0],s[1]=-n[1],s[2]=-n[2],s[3]=-n[3],s}function gKt(s,n){return s[0]=1/n[0],s[1]=1/n[1],s[2]=1/n[2],s[3]=1/n[3],s}function Q4e(s,n){let r=n[0],c=n[1],u=n[2],d=n[3],b=r*r+c*c+u*u+d*d;return b>0&&(b=1/Math.sqrt(b)),s[0]=r*b,s[1]=c*b,s[2]=u*b,s[3]=d*b,s}function rgt(s,n){return s[0]*n[0]+s[1]*n[1]+s[2]*n[2]+s[3]*n[3]}function mKt(s,n,r,c){let u=r[0]*c[1]-r[1]*c[0],d=r[0]*c[2]-r[2]*c[0],b=r[0]*c[3]-r[3]*c[0],w=r[1]*c[2]-r[2]*c[1],_=r[1]*c[3]-r[3]*c[1],x=r[2]*c[3]-r[3]*c[2],T=n[0],M=n[1],L=n[2],I=n[3];return s[0]=M*x-L*_+I*w,s[1]=-(T*x)+L*b-I*d,s[2]=T*_-M*b+I*u,s[3]=-(T*w)+M*d-L*u,s}function sgt(s,n,r,c){let u=n[0],d=n[1],b=n[2],w=n[3];return s[0]=u+c*(r[0]-u),s[1]=d+c*(r[1]-d),s[2]=b+c*(r[2]-b),s[3]=w+c*(r[3]-w),s}function bKt(s,n){n=n===void 0?1:n;let r,c,u,d,b,w;do r=Hy()*2-1,c=Hy()*2-1,b=r*r+c*c;while(b>=1);do u=Hy()*2-1,d=Hy()*2-1,w=u*u+d*d;while(w>=1);let _=Math.sqrt((1-b)/w);return s[0]=n*r,s[1]=n*c,s[2]=n*u*_,s[3]=n*d*_,s}function eke(s,n,r){let c=n[0],u=n[1],d=n[2],b=n[3];return s[0]=r[0]*c+r[4]*u+r[8]*d+r[12]*b,s[1]=r[1]*c+r[5]*u+r[9]*d+r[13]*b,s[2]=r[2]*c+r[6]*u+r[10]*d+r[14]*b,s[3]=r[3]*c+r[7]*u+r[11]*d+r[15]*b,s}function wKt(s,n,r){let c=n[0],u=n[1],d=n[2],b=r[0],w=r[1],_=r[2],x=r[3],T=x*c+w*d-_*u,M=x*u+_*c-b*d,L=x*d+b*u-w*c,I=-b*c-w*u-_*d;return s[0]=T*x+I*-b+M*-_-L*-w,s[1]=M*x+I*-w+L*-b-T*-_,s[2]=L*x+I*-_+T*-w-M*-b,s[3]=n[3],s}function vKt(s){return s[0]=0,s[1]=0,s[2]=0,s[3]=0,s}function _Kt(s){return`vec4(${s[0]}, ${s[1]}, ${s[2]}, ${s[3]})`}function ogt(s,n){return s[0]===n[0]&&s[1]===n[1]&&s[2]===n[2]&&s[3]===n[3]}function yKt(s,n){let r=s[0],c=s[1],u=s[2],d=s[3],b=n[0],w=n[1],_=n[2],x=n[3];return Math.abs(r-b)<=1e-6*Math.max(1,Math.abs(r),Math.abs(b))&&Math.abs(c-w)<=1e-6*Math.max(1,Math.abs(c),Math.abs(w))&&Math.abs(u-_)<=1e-6*Math.max(1,Math.abs(u),Math.abs(_))&&Math.abs(d-x)<=1e-6*Math.max(1,Math.abs(d),Math.abs(x))}var xKt,EKt,SKt,MKt,TKt,CKt,AKt,PKt,Kce=Ve(()=>{f4();xKt=Jpt,EKt=Qpt,SKt=egt,MKt=ngt,TKt=igt,CKt=K4e,AKt=J4e,PKt=function(){let s=Hpt();return function(n,r,c,u,d,b){let w,_;for(r||(r=4),c||(c=0),u?_=Math.min(u*r+c,n.length):_=n.length,w=c;w<_;w+=r)s[0]=n[w],s[1]=n[w+1],s[2]=n[w+2],s[3]=n[w+3],d(s,s,b),n[w]=s[0],n[w+1]=s[1],n[w+2]=s[2],n[w+3]=s[3];return n}}()});function IKt(){return Jce||(Jce=new Bf([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Jce)),Jce}function DKt(){return Qce||(Qce=new Bf,Object.freeze(Qce)),Qce}function agt(s){if(s>Math.PI*2)throw Error("expected radians")}function BKt(s,n,r,c,u,d){let b=2*d/(r-n),w=2*d/(u-c),_=(r+n)/(r-n),x=(u+c)/(u-c),T=-1,M=-1,L=-2*d;return s[0]=b,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=w,s[6]=0,s[7]=0,s[8]=_,s[9]=x,s[10]=T,s[11]=M,s[12]=0,s[13]=0,s[14]=L,s[15]=0,s}var ike,LKt,kKt,tke,nke,RKt,Bf,Jce,Qce,cgt=Ve(()=>{Npt();D$();M4e();Z4e();S4e();N$();Kce();(function(s){s[s.COL0ROW0=0]="COL0ROW0",s[s.COL0ROW1=1]="COL0ROW1",s[s.COL0ROW2=2]="COL0ROW2",s[s.COL0ROW3=3]="COL0ROW3",s[s.COL1ROW0=4]="COL1ROW0",s[s.COL1ROW1=5]="COL1ROW1",s[s.COL1ROW2=6]="COL1ROW2",s[s.COL1ROW3=7]="COL1ROW3",s[s.COL2ROW0=8]="COL2ROW0",s[s.COL2ROW1=9]="COL2ROW1",s[s.COL2ROW2=10]="COL2ROW2",s[s.COL2ROW3=11]="COL2ROW3",s[s.COL3ROW0=12]="COL3ROW0",s[s.COL3ROW1=13]="COL3ROW1",s[s.COL3ROW2=14]="COL3ROW2",s[s.COL3ROW3=15]="COL3ROW3"})(ike||(ike={}));LKt=45*Math.PI/180,kKt=1,tke=.1,nke=500,RKt=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),Bf=class extends Zce{static get IDENTITY(){return DKt()}static get ZERO(){return IKt()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return ike}constructor(n){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(n)?this.copy(n):this.identity()}copy(n){return this[0]=n[0],this[1]=n[1],this[2]=n[2],this[3]=n[3],this[4]=n[4],this[5]=n[5],this[6]=n[6],this[7]=n[7],this[8]=n[8],this[9]=n[9],this[10]=n[10],this[11]=n[11],this[12]=n[12],this[13]=n[13],this[14]=n[14],this[15]=n[15],this.check()}set(n,r,c,u,d,b,w,_,x,T,M,L,I,D,F,O){return this[0]=n,this[1]=r,this[2]=c,this[3]=u,this[4]=d,this[5]=b,this[6]=w,this[7]=_,this[8]=x,this[9]=T,this[10]=M,this[11]=L,this[12]=I,this[13]=D,this[14]=F,this[15]=O,this.check()}setRowMajor(n,r,c,u,d,b,w,_,x,T,M,L,I,D,F,O){return this[0]=n,this[1]=d,this[2]=x,this[3]=I,this[4]=r,this[5]=b,this[6]=T,this[7]=D,this[8]=c,this[9]=w,this[10]=M,this[11]=F,this[12]=u,this[13]=_,this[14]=L,this[15]=O,this.check()}toRowMajor(n){return n[0]=this[0],n[1]=this[4],n[2]=this[8],n[3]=this[12],n[4]=this[1],n[5]=this[5],n[6]=this[9],n[7]=this[13],n[8]=this[2],n[9]=this[6],n[10]=this[10],n[11]=this[14],n[12]=this[3],n[13]=this[7],n[14]=this[11],n[15]=this[15],n}identity(){return this.copy(RKt)}fromObject(n){return this.check()}fromQuaternion(n){return W4e(this,n),this.check()}frustum(n){let{left:r,right:c,bottom:u,top:d,near:b=tke,far:w=nke}=n;return w===1/0?BKt(this,r,c,u,d,b):H4e(this,r,c,u,d,b,w),this.check()}lookAt(n){let{eye:r,center:c=[0,0,0],up:u=[0,1,0]}=n;return Y4e(this,r,c,u),this.check()}ortho(n){let{left:r,right:c,bottom:u,top:d,near:b=tke,far:w=nke}=n;return X4e(this,r,c,u,d,b,w),this.check()}orthographic(n){let{fovy:r=LKt,aspect:c=kKt,focalDistance:u=1,near:d=tke,far:b=nke}=n;agt(r);let w=r/2,_=u*Math.tan(w),x=_*c;return this.ortho({left:-x,right:x,bottom:-_,top:_,near:d,far:b})}perspective(n){let{fovy:r=45*Math.PI/180,aspect:c=1,near:u=.1,far:d=500}=n;return agt(r),q4e(this,r,c,u,d),this.check()}determinant(){return F4e(this)}getScale(n=[-0,-0,-0]){return n[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),n[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),n[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),n}getTranslation(n=[-0,-0,-0]){return n[0]=this[12],n[1]=this[13],n[2]=this[14],n}getRotation(n,r){n=n||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let c=this.getScale(r),u=1/c[0],d=1/c[1],b=1/c[2];return n[0]=this[0]*u,n[1]=this[1]*d,n[2]=this[2]*b,n[3]=0,n[4]=this[4]*u,n[5]=this[5]*d,n[6]=this[6]*b,n[7]=0,n[8]=this[8]*u,n[9]=this[9]*d,n[10]=this[10]*b,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}getRotationMatrix3(n,r){n=n||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let c=this.getScale(r),u=1/c[0],d=1/c[1],b=1/c[2];return n[0]=this[0]*u,n[1]=this[1]*d,n[2]=this[2]*b,n[3]=this[4]*u,n[4]=this[5]*d,n[5]=this[6]*b,n[6]=this[8]*u,n[7]=this[9]*d,n[8]=this[10]*b,n}transpose(){return O4e(this,this),this.check()}invert(){return N4e(this,this),this.check()}multiplyLeft(n){return F$(this,n,this),this.check()}multiplyRight(n){return F$(this,this,n),this.check()}rotateX(n){return j4e(this,this,n),this.check()}rotateY(n){return $4e(this,this,n),this.check()}rotateZ(n){return V4e(this,this,n),this.check()}rotateXYZ(n){return this.rotateX(n[0]).rotateY(n[1]).rotateZ(n[2])}rotateAxis(n,r){return G4e(this,this,n,r),this.check()}scale(n){return z4e(this,this,Array.isArray(n)?n:[n,n,n]),this.check()}translate(n){return U4e(this,this,n),this.check()}transform(n,r){return n.length===4?(r=eke(r||[-0,-0,-0,-0],n,this),Vce(r,4),r):this.transformAsPoint(n,r)}transformAsPoint(n,r){let{length:c}=n,u;switch(c){case 2:u=E4e(r||[-0,-0],n,this);break;case 3:u=O$(r||[-0,-0,-0],n,this);break;default:throw new Error("Illegal vector")}return Vce(u,n.length),u}transformAsVector(n,r){let c;switch(n.length){case 2:c=Cpt(r||[-0,-0],n,this);break;case 3:c=Hce(r||[-0,-0,-0],n,this);break;default:throw new Error("Illegal vector")}return Vce(c,n.length),c}transformPoint(n,r){return this.transformAsPoint(n,r)}transformVector(n,r){return this.transformAsPoint(n,r)}transformDirection(n,r){return this.transformAsVector(n,r)}makeRotationX(n){return this.identity().rotateX(n)}makeTranslation(n,r,c){return this.identity().translate([n,r,c])}}});function lgt(){let s=new Cc(4);return Cc!=Float32Array&&(s[0]=0,s[1]=0,s[2]=0),s[3]=1,s}function OKt(s,n,r){r=r*.5;let c=Math.sin(r);return s[0]=c*n[0],s[1]=c*n[1],s[2]=c*n[2],s[3]=Math.cos(r),s}function rke(s,n,r,c){let u=n[0],d=n[1],b=n[2],w=n[3],_=r[0],x=r[1],T=r[2],M=r[3],L,I,D,F,O;return L=u*_+d*x+b*T+w*M,L<0&&(L=-L,_=-_,x=-x,T=-T,M=-M),1-L>1e-6?(I=Math.acos(L),O=Math.sin(I),D=Math.sin((1-c)*I)/O,F=Math.sin(c*I)/O):(D=1-c,F=c),s[0]=D*u+F*_,s[1]=D*d+F*x,s[2]=D*b+F*T,s[3]=D*w+F*M,s}function NKt(s,n){let r=n[0]+n[4]+n[8],c;if(r>0)c=Math.sqrt(r+1),s[3]=.5*c,c=.5/c,s[0]=(n[5]-n[7])*c,s[1]=(n[6]-n[2])*c,s[2]=(n[1]-n[3])*c;else{let u=0;n[4]>n[0]&&(u=1),n[8]>n[u*3+u]&&(u=2);let d=(u+1)%3,b=(u+2)%3;c=Math.sqrt(n[u*3+u]-n[d*3+d]-n[b*3+b]+1),s[u]=.5*c,c=.5/c,s[3]=(n[d*3+b]-n[b*3+d])*c,s[d]=(n[d*3+u]+n[u*3+d])*c,s[b]=(n[b*3+u]+n[u*3+b])*c}return s}var ugt,Lzn,kzn,Rzn,fgt=Ve(()=>{f4();B4e();N$();Kce();ugt=Q4e,Lzn=function(){let s=qce(),n=Xce(1,0,0),r=Xce(0,1,0);return function(c,u,d){let b=B$(u,d);return b<-.999999?(h4(s,n,u),I4e(s)<1e-6&&h4(s,r,u),T4e(s,s),OKt(c,s,Math.PI),c):b>.999999?(c[0]=0,c[1]=0,c[2]=0,c[3]=1,c):(h4(s,u,d),c[0]=s[0],c[1]=s[1],c[2]=s[2],c[3]=1+b,ugt(c,c))}}(),kzn=function(){let s=lgt(),n=lgt();return function(r,c,u,d,b,w){return rke(s,c,b,w),rke(n,u,d,w),rke(r,s,n,2*w*(1-w)),r}}(),Rzn=function(){let s=Fpt();return function(n,r,c,u){return s[0]=c[0],s[3]=c[1],s[6]=c[2],s[1]=u[0],s[4]=u[1],s[7]=u[2],s[2]=-r[0],s[5]=-r[1],s[8]=-r[2],ugt(n,NKt(n,s))}}()});var Izn,Dzn,Bzn,Ozn,hgt=Ve(()=>{Izn=Math.PI/2,Dzn=Math.PI/4,Bzn=Math.PI/6,Ozn=Math.PI*2});var Of=Ve(()=>{Opt();cgt();hgt();qD();B4e();Z4e();fgt();S4e();N$();Kce()});function ske(s,n=[],r=0){let c=Math.fround(s),u=s-c;return n[r]=c,n[r+1]=u,n}function dgt(s){return s-Math.fround(s)}function pgt(s){let n=new Float32Array(32);for(let r=0;r<4;++r)for(let c=0;c<4;++c){let u=r*4+c;ske(s[c*4+r],n,u*2)}return n}var ggt=Ve(()=>{});function ele(s,n=!0){return s??n}function oke(s=[0,0,0],n=!0){return n?s.map(r=>r/255):[...s]}function mgt(s,n=!0){let r=oke(s.slice(0,3),n),c=Number.isFinite(s[3]),u=c?s[3]:1;return[r[0],r[1],r[2],n&&c?u/255:u]}var ake=Ve(()=>{});var zKt,GKt,d4,bgt=Ve(()=>{zKt=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND +}`,mYt=`#version 300 es +${gYt}`});function _4e(s,{precision:n=jh.precision}={}){return s=vYt(s),`${parseFloat(s.toPrecision(n))}`}function P3(s){return Array.isArray(s)||ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Kl(s,n,r){return yYt(s,c=>Math.max(n,Math.min(r,c)))}function lv(s,n,r){return P3(s)?s.map((c,u)=>lv(c,n[u],r)):r*n+(1-r)*s}function Wy(s,n,r){let c=jh.EPSILON;r&&(jh.EPSILON=r);try{if(s===n)return!0;if(P3(s)&&P3(n)){if(s.length!==n.length)return!1;for(let u=0;u{nzn=1/Math.PI*180,izn=1/180*Math.PI,wYt={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...wYt}};jh=globalThis.mathgl.config});var XD,y4e=Ve(()=>{qD();XD=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(n,r=0){for(let c=0;c0?", ":"")+_4e(this[c],n);return`${n.printTypes?this.constructor.name:""}[${r}]`}equals(n){if(!n||this.length!==n.length)return!1;for(let r=0;r{qD()});function x4e(s,n){if(!s)throw new Error(`math.gl assertion ${n}`)}var bpt=Ve(()=>{});var Wce,wpt=Ve(()=>{y4e();D$();bpt();Wce=class extends XD{get x(){return this[0]}set x(n){this[0]=cp(n)}get y(){return this[1]}set y(n){this[1]=cp(n)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let n=0;for(let r=0;r=0&&n=0&&n=0?Math.round(s):s%.5===0?Math.floor(s):Math.round(s)}var Cc,Hy,pzn,f4=Ve(()=>{Cc=typeof Float32Array<"u"?Float32Array:Array,Hy=Math.random;pzn=Math.PI/180});var ag={};Oy(ag,{add:()=>CYt,angle:()=>HYt,ceil:()=>AYt,clone:()=>EYt,copy:()=>MYt,create:()=>vpt,cross:()=>UYt,dist:()=>tZt,distance:()=>Ept,div:()=>eZt,divide:()=>xpt,dot:()=>FYt,equals:()=>ZYt,exactEquals:()=>YYt,floor:()=>PYt,forEach:()=>rZt,fromValues:()=>SYt,inverse:()=>OYt,len:()=>KYt,length:()=>Mpt,lerp:()=>zYt,max:()=>kYt,min:()=>LYt,mul:()=>QYt,multiply:()=>ypt,negate:()=>BYt,normalize:()=>NYt,random:()=>GYt,rotate:()=>WYt,round:()=>RYt,scale:()=>IYt,scaleAndAdd:()=>DYt,set:()=>TYt,sqrDist:()=>nZt,sqrLen:()=>iZt,squaredDistance:()=>Spt,squaredLength:()=>Tpt,str:()=>XYt,sub:()=>JYt,subtract:()=>_pt,transformMat2:()=>jYt,transformMat2d:()=>$Yt,transformMat3:()=>VYt,transformMat4:()=>E4e,zero:()=>qYt});function vpt(){let s=new Cc(2);return Cc!=Float32Array&&(s[0]=0,s[1]=0),s}function EYt(s){let n=new Cc(2);return n[0]=s[0],n[1]=s[1],n}function SYt(s,n){let r=new Cc(2);return r[0]=s,r[1]=n,r}function MYt(s,n){return s[0]=n[0],s[1]=n[1],s}function TYt(s,n,r){return s[0]=n,s[1]=r,s}function CYt(s,n,r){return s[0]=n[0]+r[0],s[1]=n[1]+r[1],s}function _pt(s,n,r){return s[0]=n[0]-r[0],s[1]=n[1]-r[1],s}function ypt(s,n,r){return s[0]=n[0]*r[0],s[1]=n[1]*r[1],s}function xpt(s,n,r){return s[0]=n[0]/r[0],s[1]=n[1]/r[1],s}function AYt(s,n){return s[0]=Math.ceil(n[0]),s[1]=Math.ceil(n[1]),s}function PYt(s,n){return s[0]=Math.floor(n[0]),s[1]=Math.floor(n[1]),s}function LYt(s,n,r){return s[0]=Math.min(n[0],r[0]),s[1]=Math.min(n[1],r[1]),s}function kYt(s,n,r){return s[0]=Math.max(n[0],r[0]),s[1]=Math.max(n[1],r[1]),s}function RYt(s,n){return s[0]=Cb(n[0]),s[1]=Cb(n[1]),s}function IYt(s,n,r){return s[0]=n[0]*r,s[1]=n[1]*r,s}function DYt(s,n,r,c){return s[0]=n[0]+r[0]*c,s[1]=n[1]+r[1]*c,s}function Ept(s,n){let r=n[0]-s[0],c=n[1]-s[1];return Math.sqrt(r*r+c*c)}function Spt(s,n){let r=n[0]-s[0],c=n[1]-s[1];return r*r+c*c}function Mpt(s){let n=s[0],r=s[1];return Math.sqrt(n*n+r*r)}function Tpt(s){let n=s[0],r=s[1];return n*n+r*r}function BYt(s,n){return s[0]=-n[0],s[1]=-n[1],s}function OYt(s,n){return s[0]=1/n[0],s[1]=1/n[1],s}function NYt(s,n){let r=n[0],c=n[1],u=r*r+c*c;return u>0&&(u=1/Math.sqrt(u)),s[0]=n[0]*u,s[1]=n[1]*u,s}function FYt(s,n){return s[0]*n[0]+s[1]*n[1]}function UYt(s,n,r){let c=n[0]*r[1]-n[1]*r[0];return s[0]=s[1]=0,s[2]=c,s}function zYt(s,n,r,c){let u=n[0],d=n[1];return s[0]=u+c*(r[0]-u),s[1]=d+c*(r[1]-d),s}function GYt(s,n){n=n===void 0?1:n;let r=Hy()*2*Math.PI;return s[0]=Math.cos(r)*n,s[1]=Math.sin(r)*n,s}function jYt(s,n,r){let c=n[0],u=n[1];return s[0]=r[0]*c+r[2]*u,s[1]=r[1]*c+r[3]*u,s}function $Yt(s,n,r){let c=n[0],u=n[1];return s[0]=r[0]*c+r[2]*u+r[4],s[1]=r[1]*c+r[3]*u+r[5],s}function VYt(s,n,r){let c=n[0],u=n[1];return s[0]=r[0]*c+r[3]*u+r[6],s[1]=r[1]*c+r[4]*u+r[7],s}function E4e(s,n,r){let c=n[0],u=n[1];return s[0]=r[0]*c+r[4]*u+r[12],s[1]=r[1]*c+r[5]*u+r[13],s}function WYt(s,n,r,c){let u=n[0]-r[0],d=n[1]-r[1],b=Math.sin(c),w=Math.cos(c);return s[0]=u*w-d*b+r[0],s[1]=u*b+d*w+r[1],s}function HYt(s,n){let r=s[0],c=s[1],u=n[0],d=n[1],b=Math.sqrt((r*r+c*c)*(u*u+d*d)),w=b&&(r*u+c*d)/b;return Math.acos(Math.min(Math.max(w,-1),1))}function qYt(s){return s[0]=0,s[1]=0,s}function XYt(s){return`vec2(${s[0]}, ${s[1]})`}function YYt(s,n){return s[0]===n[0]&&s[1]===n[1]}function ZYt(s,n){let r=s[0],c=s[1],u=n[0],d=n[1];return Math.abs(r-u)<=1e-6*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(c-d)<=1e-6*Math.max(1,Math.abs(c),Math.abs(d))}var KYt,JYt,QYt,eZt,tZt,nZt,iZt,rZt,S4e=Ve(()=>{f4();KYt=Mpt,JYt=_pt,QYt=ypt,eZt=xpt,tZt=Ept,nZt=Spt,iZt=Tpt,rZt=function(){let s=vpt();return function(n,r,c,u,d,b){let w,_;for(r||(r=2),c||(c=0),u?_=Math.min(u*r+c,n.length):_=n.length,w=c;w<_;w+=r)s[0]=n[w],s[1]=n[w+1],d(s,s,b),n[w]=s[0],n[w+1]=s[1];return n}}()});function Cpt(s,n,r){let c=n[0],u=n[1],d=r[3]*c+r[7]*u||1;return s[0]=(r[0]*c+r[4]*u)/d,s[1]=(r[1]*c+r[5]*u)/d,s}function Hce(s,n,r){let c=n[0],u=n[1],d=n[2],b=r[3]*c+r[7]*u+r[11]*d||1;return s[0]=(r[0]*c+r[4]*u+r[8]*d)/b,s[1]=(r[1]*c+r[5]*u+r[9]*d)/b,s[2]=(r[2]*c+r[6]*u+r[10]*d)/b,s}function Apt(s,n,r){let c=n[0],u=n[1];return s[0]=r[0]*c+r[2]*u,s[1]=r[1]*c+r[3]*u,s[2]=n[2],s}var M4e=Ve(()=>{});var wm={};Oy(wm,{add:()=>cZt,angle:()=>R4e,bezier:()=>yZt,ceil:()=>lZt,clone:()=>sZt,copy:()=>oZt,create:()=>qce,cross:()=>h4,dist:()=>LZt,distance:()=>Ipt,div:()=>PZt,divide:()=>Rpt,dot:()=>B$,equals:()=>TZt,exactEquals:()=>MZt,floor:()=>uZt,forEach:()=>IZt,fromValues:()=>Xce,hermite:()=>_Zt,inverse:()=>bZt,len:()=>I4e,length:()=>Ppt,lerp:()=>wZt,max:()=>hZt,min:()=>fZt,mul:()=>AZt,multiply:()=>kpt,negate:()=>mZt,normalize:()=>T4e,random:()=>xZt,rotateX:()=>P4e,rotateY:()=>L4e,rotateZ:()=>k4e,round:()=>dZt,scale:()=>pZt,scaleAndAdd:()=>gZt,set:()=>aZt,slerp:()=>vZt,sqrDist:()=>kZt,sqrLen:()=>RZt,squaredDistance:()=>Dpt,squaredLength:()=>Bpt,str:()=>SZt,sub:()=>CZt,subtract:()=>Lpt,transformMat3:()=>C4e,transformMat4:()=>O$,transformQuat:()=>A4e,zero:()=>EZt});function qce(){let s=new Cc(3);return Cc!=Float32Array&&(s[0]=0,s[1]=0,s[2]=0),s}function sZt(s){let n=new Cc(3);return n[0]=s[0],n[1]=s[1],n[2]=s[2],n}function Ppt(s){let n=s[0],r=s[1],c=s[2];return Math.sqrt(n*n+r*r+c*c)}function Xce(s,n,r){let c=new Cc(3);return c[0]=s,c[1]=n,c[2]=r,c}function oZt(s,n){return s[0]=n[0],s[1]=n[1],s[2]=n[2],s}function aZt(s,n,r,c){return s[0]=n,s[1]=r,s[2]=c,s}function cZt(s,n,r){return s[0]=n[0]+r[0],s[1]=n[1]+r[1],s[2]=n[2]+r[2],s}function Lpt(s,n,r){return s[0]=n[0]-r[0],s[1]=n[1]-r[1],s[2]=n[2]-r[2],s}function kpt(s,n,r){return s[0]=n[0]*r[0],s[1]=n[1]*r[1],s[2]=n[2]*r[2],s}function Rpt(s,n,r){return s[0]=n[0]/r[0],s[1]=n[1]/r[1],s[2]=n[2]/r[2],s}function lZt(s,n){return s[0]=Math.ceil(n[0]),s[1]=Math.ceil(n[1]),s[2]=Math.ceil(n[2]),s}function uZt(s,n){return s[0]=Math.floor(n[0]),s[1]=Math.floor(n[1]),s[2]=Math.floor(n[2]),s}function fZt(s,n,r){return s[0]=Math.min(n[0],r[0]),s[1]=Math.min(n[1],r[1]),s[2]=Math.min(n[2],r[2]),s}function hZt(s,n,r){return s[0]=Math.max(n[0],r[0]),s[1]=Math.max(n[1],r[1]),s[2]=Math.max(n[2],r[2]),s}function dZt(s,n){return s[0]=Cb(n[0]),s[1]=Cb(n[1]),s[2]=Cb(n[2]),s}function pZt(s,n,r){return s[0]=n[0]*r,s[1]=n[1]*r,s[2]=n[2]*r,s}function gZt(s,n,r,c){return s[0]=n[0]+r[0]*c,s[1]=n[1]+r[1]*c,s[2]=n[2]+r[2]*c,s}function Ipt(s,n){let r=n[0]-s[0],c=n[1]-s[1],u=n[2]-s[2];return Math.sqrt(r*r+c*c+u*u)}function Dpt(s,n){let r=n[0]-s[0],c=n[1]-s[1],u=n[2]-s[2];return r*r+c*c+u*u}function Bpt(s){let n=s[0],r=s[1],c=s[2];return n*n+r*r+c*c}function mZt(s,n){return s[0]=-n[0],s[1]=-n[1],s[2]=-n[2],s}function bZt(s,n){return s[0]=1/n[0],s[1]=1/n[1],s[2]=1/n[2],s}function T4e(s,n){let r=n[0],c=n[1],u=n[2],d=r*r+c*c+u*u;return d>0&&(d=1/Math.sqrt(d)),s[0]=n[0]*d,s[1]=n[1]*d,s[2]=n[2]*d,s}function B$(s,n){return s[0]*n[0]+s[1]*n[1]+s[2]*n[2]}function h4(s,n,r){let c=n[0],u=n[1],d=n[2],b=r[0],w=r[1],_=r[2];return s[0]=u*_-d*w,s[1]=d*b-c*_,s[2]=c*w-u*b,s}function wZt(s,n,r,c){let u=n[0],d=n[1],b=n[2];return s[0]=u+c*(r[0]-u),s[1]=d+c*(r[1]-d),s[2]=b+c*(r[2]-b),s}function vZt(s,n,r,c){let u=Math.acos(Math.min(Math.max(B$(n,r),-1),1)),d=Math.sin(u),b=Math.sin((1-c)*u)/d,w=Math.sin(c*u)/d;return s[0]=b*n[0]+w*r[0],s[1]=b*n[1]+w*r[1],s[2]=b*n[2]+w*r[2],s}function _Zt(s,n,r,c,u,d){let b=d*d,w=b*(2*d-3)+1,_=b*(d-2)+d,x=b*(d-1),T=b*(3-2*d);return s[0]=n[0]*w+r[0]*_+c[0]*x+u[0]*T,s[1]=n[1]*w+r[1]*_+c[1]*x+u[1]*T,s[2]=n[2]*w+r[2]*_+c[2]*x+u[2]*T,s}function yZt(s,n,r,c,u,d){let b=1-d,w=b*b,_=d*d,x=w*b,T=3*d*w,M=3*_*b,L=_*d;return s[0]=n[0]*x+r[0]*T+c[0]*M+u[0]*L,s[1]=n[1]*x+r[1]*T+c[1]*M+u[1]*L,s[2]=n[2]*x+r[2]*T+c[2]*M+u[2]*L,s}function xZt(s,n){n=n===void 0?1:n;let r=Hy()*2*Math.PI,c=Hy()*2-1,u=Math.sqrt(1-c*c)*n;return s[0]=Math.cos(r)*u,s[1]=Math.sin(r)*u,s[2]=c*n,s}function O$(s,n,r){let c=n[0],u=n[1],d=n[2],b=r[3]*c+r[7]*u+r[11]*d+r[15];return b=b||1,s[0]=(r[0]*c+r[4]*u+r[8]*d+r[12])/b,s[1]=(r[1]*c+r[5]*u+r[9]*d+r[13])/b,s[2]=(r[2]*c+r[6]*u+r[10]*d+r[14])/b,s}function C4e(s,n,r){let c=n[0],u=n[1],d=n[2];return s[0]=c*r[0]+u*r[3]+d*r[6],s[1]=c*r[1]+u*r[4]+d*r[7],s[2]=c*r[2]+u*r[5]+d*r[8],s}function A4e(s,n,r){let c=r[0],u=r[1],d=r[2],b=r[3],w=n[0],_=n[1],x=n[2],T=u*x-d*_,M=d*w-c*x,L=c*_-u*w,I=u*L-d*M,D=d*T-c*L,F=c*M-u*T,O=b*2;return T*=O,M*=O,L*=O,I*=2,D*=2,F*=2,s[0]=w+T+I,s[1]=_+M+D,s[2]=x+L+F,s}function P4e(s,n,r,c){let u=[],d=[];return u[0]=n[0]-r[0],u[1]=n[1]-r[1],u[2]=n[2]-r[2],d[0]=u[0],d[1]=u[1]*Math.cos(c)-u[2]*Math.sin(c),d[2]=u[1]*Math.sin(c)+u[2]*Math.cos(c),s[0]=d[0]+r[0],s[1]=d[1]+r[1],s[2]=d[2]+r[2],s}function L4e(s,n,r,c){let u=[],d=[];return u[0]=n[0]-r[0],u[1]=n[1]-r[1],u[2]=n[2]-r[2],d[0]=u[2]*Math.sin(c)+u[0]*Math.cos(c),d[1]=u[1],d[2]=u[2]*Math.cos(c)-u[0]*Math.sin(c),s[0]=d[0]+r[0],s[1]=d[1]+r[1],s[2]=d[2]+r[2],s}function k4e(s,n,r,c){let u=[],d=[];return u[0]=n[0]-r[0],u[1]=n[1]-r[1],u[2]=n[2]-r[2],d[0]=u[0]*Math.cos(c)-u[1]*Math.sin(c),d[1]=u[0]*Math.sin(c)+u[1]*Math.cos(c),d[2]=u[2],s[0]=d[0]+r[0],s[1]=d[1]+r[1],s[2]=d[2]+r[2],s}function R4e(s,n){let r=s[0],c=s[1],u=s[2],d=n[0],b=n[1],w=n[2],_=Math.sqrt((r*r+c*c+u*u)*(d*d+b*b+w*w)),x=_&&B$(s,n)/_;return Math.acos(Math.min(Math.max(x,-1),1))}function EZt(s){return s[0]=0,s[1]=0,s[2]=0,s}function SZt(s){return`vec3(${s[0]}, ${s[1]}, ${s[2]})`}function MZt(s,n){return s[0]===n[0]&&s[1]===n[1]&&s[2]===n[2]}function TZt(s,n){let r=s[0],c=s[1],u=s[2],d=n[0],b=n[1],w=n[2];return Math.abs(r-d)<=1e-6*Math.max(1,Math.abs(r),Math.abs(d))&&Math.abs(c-b)<=1e-6*Math.max(1,Math.abs(c),Math.abs(b))&&Math.abs(u-w)<=1e-6*Math.max(1,Math.abs(u),Math.abs(w))}var CZt,AZt,PZt,LZt,kZt,I4e,RZt,IZt,N$=Ve(()=>{f4();CZt=Lpt,AZt=kpt,PZt=Rpt,LZt=Ipt,kZt=Dpt,I4e=Ppt,RZt=Bpt,IZt=function(){let s=qce();return function(n,r,c,u,d,b){let w,_;for(r||(r=3),c||(c=0),u?_=Math.min(u*r+c,n.length):_=n.length,w=c;w<_;w+=r)s[0]=n[w],s[1]=n[w+1],s[2]=n[w+2],d(s,s,b),n[w]=s[0],n[w+1]=s[1],n[w+2]=s[2];return n}}()});var D4e,Yce,lp,Opt=Ve(()=>{wpt();qD();D$();N$();M4e();D4e=[0,0,0],lp=class s extends Wce{static get ZERO(){return Yce||(Yce=new s(0,0,0),Object.freeze(Yce)),Yce}constructor(n=0,r=0,c=0){super(-0,-0,-0),arguments.length===1&&P3(n)?this.copy(n):(jh.debug&&(cp(n),cp(r),cp(c)),this[0]=n,this[1]=r,this[2]=c)}set(n,r,c){return this[0]=n,this[1]=r,this[2]=c,this.check()}copy(n){return this[0]=n[0],this[1]=n[1],this[2]=n[2],this.check()}fromObject(n){return jh.debug&&(cp(n.x),cp(n.y),cp(n.z)),this[0]=n.x,this[1]=n.y,this[2]=n.z,this.check()}toObject(n){return n.x=this[0],n.y=this[1],n.z=this[2],n}get ELEMENTS(){return 3}get z(){return this[2]}set z(n){this[2]=cp(n)}angle(n){return R4e(this,n)}cross(n){return h4(this,this,n),this.check()}rotateX({radians:n,origin:r=D4e}){return P4e(this,this,r,n),this.check()}rotateY({radians:n,origin:r=D4e}){return L4e(this,this,r,n),this.check()}rotateZ({radians:n,origin:r=D4e}){return k4e(this,this,r,n),this.check()}transform(n){return this.transformAsPoint(n)}transformAsPoint(n){return O$(this,this,n),this.check()}transformAsVector(n){return Hce(this,this,n),this.check()}transformByMatrix3(n){return C4e(this,this,n),this.check()}transformByMatrix2(n){return Apt(this,this,n),this.check()}transformByQuaternion(n){return A4e(this,this,n),this.check()}}});var Zce,Npt=Ve(()=>{y4e();D$();qD();Zce=class extends XD{toString(){let n="[";if(jh.printRowMajor){n+="row-major:";for(let r=0;r{f4()});var hh={};Oy(hh,{add:()=>rKt,adjoint:()=>UZt,clone:()=>BZt,copy:()=>OZt,create:()=>DZt,decompose:()=>YZt,determinant:()=>F4e,equals:()=>cKt,exactEquals:()=>aKt,frob:()=>iKt,fromQuat:()=>W4e,fromQuat2:()=>HZt,fromRotation:()=>jZt,fromRotationTranslation:()=>Gpt,fromRotationTranslationScale:()=>ZZt,fromRotationTranslationScaleOrigin:()=>KZt,fromScaling:()=>GZt,fromTranslation:()=>zZt,fromValues:()=>NZt,fromXRotation:()=>$Zt,fromYRotation:()=>VZt,fromZRotation:()=>WZt,frustum:()=>H4e,getRotation:()=>XZt,getScaling:()=>jpt,getTranslation:()=>qZt,identity:()=>zpt,invert:()=>N4e,lookAt:()=>Y4e,mul:()=>lKt,multiply:()=>F$,multiplyScalar:()=>sKt,multiplyScalarAndAdd:()=>oKt,ortho:()=>X4e,orthoNO:()=>Vpt,orthoZO:()=>eKt,perspective:()=>q4e,perspectiveFromFieldOfView:()=>QZt,perspectiveNO:()=>$pt,perspectiveZO:()=>JZt,rotate:()=>G4e,rotateX:()=>j4e,rotateY:()=>$4e,rotateZ:()=>V4e,scale:()=>z4e,set:()=>FZt,str:()=>nKt,sub:()=>uKt,subtract:()=>Wpt,targetTo:()=>tKt,translate:()=>U4e,transpose:()=>O4e});function DZt(){let s=new Cc(16);return Cc!=Float32Array&&(s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[11]=0,s[12]=0,s[13]=0,s[14]=0),s[0]=1,s[5]=1,s[10]=1,s[15]=1,s}function BZt(s){let n=new Cc(16);return n[0]=s[0],n[1]=s[1],n[2]=s[2],n[3]=s[3],n[4]=s[4],n[5]=s[5],n[6]=s[6],n[7]=s[7],n[8]=s[8],n[9]=s[9],n[10]=s[10],n[11]=s[11],n[12]=s[12],n[13]=s[13],n[14]=s[14],n[15]=s[15],n}function OZt(s,n){return s[0]=n[0],s[1]=n[1],s[2]=n[2],s[3]=n[3],s[4]=n[4],s[5]=n[5],s[6]=n[6],s[7]=n[7],s[8]=n[8],s[9]=n[9],s[10]=n[10],s[11]=n[11],s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15],s}function NZt(s,n,r,c,u,d,b,w,_,x,T,M,L,I,D,F){let O=new Cc(16);return O[0]=s,O[1]=n,O[2]=r,O[3]=c,O[4]=u,O[5]=d,O[6]=b,O[7]=w,O[8]=_,O[9]=x,O[10]=T,O[11]=M,O[12]=L,O[13]=I,O[14]=D,O[15]=F,O}function FZt(s,n,r,c,u,d,b,w,_,x,T,M,L,I,D,F,O){return s[0]=n,s[1]=r,s[2]=c,s[3]=u,s[4]=d,s[5]=b,s[6]=w,s[7]=_,s[8]=x,s[9]=T,s[10]=M,s[11]=L,s[12]=I,s[13]=D,s[14]=F,s[15]=O,s}function zpt(s){return s[0]=1,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=1,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=1,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function O4e(s,n){if(s===n){let r=n[1],c=n[2],u=n[3],d=n[6],b=n[7],w=n[11];s[1]=n[4],s[2]=n[8],s[3]=n[12],s[4]=r,s[6]=n[9],s[7]=n[13],s[8]=c,s[9]=d,s[11]=n[14],s[12]=u,s[13]=b,s[14]=w}else s[0]=n[0],s[1]=n[4],s[2]=n[8],s[3]=n[12],s[4]=n[1],s[5]=n[5],s[6]=n[9],s[7]=n[13],s[8]=n[2],s[9]=n[6],s[10]=n[10],s[11]=n[14],s[12]=n[3],s[13]=n[7],s[14]=n[11],s[15]=n[15];return s}function N4e(s,n){let r=n[0],c=n[1],u=n[2],d=n[3],b=n[4],w=n[5],_=n[6],x=n[7],T=n[8],M=n[9],L=n[10],I=n[11],D=n[12],F=n[13],O=n[14],z=n[15],Z=r*w-c*b,H=r*_-u*b,te=r*x-d*b,oe=c*_-u*w,ne=c*x-d*w,ue=u*x-d*_,Te=T*F-M*D,Q=T*O-L*D,ge=T*z-I*D,Qe=M*O-L*F,st=M*z-I*F,at=L*z-I*O,Ne=Z*at-H*st+te*Qe+oe*ge-ne*Q+ue*Te;return Ne?(Ne=1/Ne,s[0]=(w*at-_*st+x*Qe)*Ne,s[1]=(u*st-c*at-d*Qe)*Ne,s[2]=(F*ue-O*ne+z*oe)*Ne,s[3]=(L*ne-M*ue-I*oe)*Ne,s[4]=(_*ge-b*at-x*Q)*Ne,s[5]=(r*at-u*ge+d*Q)*Ne,s[6]=(O*te-D*ue-z*H)*Ne,s[7]=(T*ue-L*te+I*H)*Ne,s[8]=(b*st-w*ge+x*Te)*Ne,s[9]=(c*ge-r*st-d*Te)*Ne,s[10]=(D*ne-F*te+z*Z)*Ne,s[11]=(M*te-T*ne-I*Z)*Ne,s[12]=(w*Q-b*Qe-_*Te)*Ne,s[13]=(r*Qe-c*Q+u*Te)*Ne,s[14]=(F*H-D*oe-O*Z)*Ne,s[15]=(T*oe-M*H+L*Z)*Ne,s):null}function UZt(s,n){let r=n[0],c=n[1],u=n[2],d=n[3],b=n[4],w=n[5],_=n[6],x=n[7],T=n[8],M=n[9],L=n[10],I=n[11],D=n[12],F=n[13],O=n[14],z=n[15],Z=r*w-c*b,H=r*_-u*b,te=r*x-d*b,oe=c*_-u*w,ne=c*x-d*w,ue=u*x-d*_,Te=T*F-M*D,Q=T*O-L*D,ge=T*z-I*D,Qe=M*O-L*F,st=M*z-I*F,at=L*z-I*O;return s[0]=w*at-_*st+x*Qe,s[1]=u*st-c*at-d*Qe,s[2]=F*ue-O*ne+z*oe,s[3]=L*ne-M*ue-I*oe,s[4]=_*ge-b*at-x*Q,s[5]=r*at-u*ge+d*Q,s[6]=O*te-D*ue-z*H,s[7]=T*ue-L*te+I*H,s[8]=b*st-w*ge+x*Te,s[9]=c*ge-r*st-d*Te,s[10]=D*ne-F*te+z*Z,s[11]=M*te-T*ne-I*Z,s[12]=w*Q-b*Qe-_*Te,s[13]=r*Qe-c*Q+u*Te,s[14]=F*H-D*oe-O*Z,s[15]=T*oe-M*H+L*Z,s}function F4e(s){let n=s[0],r=s[1],c=s[2],u=s[3],d=s[4],b=s[5],w=s[6],_=s[7],x=s[8],T=s[9],M=s[10],L=s[11],I=s[12],D=s[13],F=s[14],O=s[15],z=n*b-r*d,Z=n*w-c*d,H=r*w-c*b,te=x*D-T*I,oe=x*F-M*I,ne=T*F-M*D,ue=n*ne-r*oe+c*te,Te=d*ne-b*oe+w*te,Q=x*H-T*Z+M*z,ge=I*H-D*Z+F*z;return _*ue-u*Te+O*Q-L*ge}function F$(s,n,r){let c=n[0],u=n[1],d=n[2],b=n[3],w=n[4],_=n[5],x=n[6],T=n[7],M=n[8],L=n[9],I=n[10],D=n[11],F=n[12],O=n[13],z=n[14],Z=n[15],H=r[0],te=r[1],oe=r[2],ne=r[3];return s[0]=H*c+te*w+oe*M+ne*F,s[1]=H*u+te*_+oe*L+ne*O,s[2]=H*d+te*x+oe*I+ne*z,s[3]=H*b+te*T+oe*D+ne*Z,H=r[4],te=r[5],oe=r[6],ne=r[7],s[4]=H*c+te*w+oe*M+ne*F,s[5]=H*u+te*_+oe*L+ne*O,s[6]=H*d+te*x+oe*I+ne*z,s[7]=H*b+te*T+oe*D+ne*Z,H=r[8],te=r[9],oe=r[10],ne=r[11],s[8]=H*c+te*w+oe*M+ne*F,s[9]=H*u+te*_+oe*L+ne*O,s[10]=H*d+te*x+oe*I+ne*z,s[11]=H*b+te*T+oe*D+ne*Z,H=r[12],te=r[13],oe=r[14],ne=r[15],s[12]=H*c+te*w+oe*M+ne*F,s[13]=H*u+te*_+oe*L+ne*O,s[14]=H*d+te*x+oe*I+ne*z,s[15]=H*b+te*T+oe*D+ne*Z,s}function U4e(s,n,r){let c=r[0],u=r[1],d=r[2],b,w,_,x,T,M,L,I,D,F,O,z;return n===s?(s[12]=n[0]*c+n[4]*u+n[8]*d+n[12],s[13]=n[1]*c+n[5]*u+n[9]*d+n[13],s[14]=n[2]*c+n[6]*u+n[10]*d+n[14],s[15]=n[3]*c+n[7]*u+n[11]*d+n[15]):(b=n[0],w=n[1],_=n[2],x=n[3],T=n[4],M=n[5],L=n[6],I=n[7],D=n[8],F=n[9],O=n[10],z=n[11],s[0]=b,s[1]=w,s[2]=_,s[3]=x,s[4]=T,s[5]=M,s[6]=L,s[7]=I,s[8]=D,s[9]=F,s[10]=O,s[11]=z,s[12]=b*c+T*u+D*d+n[12],s[13]=w*c+M*u+F*d+n[13],s[14]=_*c+L*u+O*d+n[14],s[15]=x*c+I*u+z*d+n[15]),s}function z4e(s,n,r){let c=r[0],u=r[1],d=r[2];return s[0]=n[0]*c,s[1]=n[1]*c,s[2]=n[2]*c,s[3]=n[3]*c,s[4]=n[4]*u,s[5]=n[5]*u,s[6]=n[6]*u,s[7]=n[7]*u,s[8]=n[8]*d,s[9]=n[9]*d,s[10]=n[10]*d,s[11]=n[11]*d,s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15],s}function G4e(s,n,r,c){let u=c[0],d=c[1],b=c[2],w=Math.sqrt(u*u+d*d+b*b),_,x,T,M,L,I,D,F,O,z,Z,H,te,oe,ne,ue,Te,Q,ge,Qe,st,at,Ne,tt;return w<1e-6?null:(w=1/w,u*=w,d*=w,b*=w,x=Math.sin(r),_=Math.cos(r),T=1-_,M=n[0],L=n[1],I=n[2],D=n[3],F=n[4],O=n[5],z=n[6],Z=n[7],H=n[8],te=n[9],oe=n[10],ne=n[11],ue=u*u*T+_,Te=d*u*T+b*x,Q=b*u*T-d*x,ge=u*d*T-b*x,Qe=d*d*T+_,st=b*d*T+u*x,at=u*b*T+d*x,Ne=d*b*T-u*x,tt=b*b*T+_,s[0]=M*ue+F*Te+H*Q,s[1]=L*ue+O*Te+te*Q,s[2]=I*ue+z*Te+oe*Q,s[3]=D*ue+Z*Te+ne*Q,s[4]=M*ge+F*Qe+H*st,s[5]=L*ge+O*Qe+te*st,s[6]=I*ge+z*Qe+oe*st,s[7]=D*ge+Z*Qe+ne*st,s[8]=M*at+F*Ne+H*tt,s[9]=L*at+O*Ne+te*tt,s[10]=I*at+z*Ne+oe*tt,s[11]=D*at+Z*Ne+ne*tt,n!==s&&(s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15]),s)}function j4e(s,n,r){let c=Math.sin(r),u=Math.cos(r),d=n[4],b=n[5],w=n[6],_=n[7],x=n[8],T=n[9],M=n[10],L=n[11];return n!==s&&(s[0]=n[0],s[1]=n[1],s[2]=n[2],s[3]=n[3],s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15]),s[4]=d*u+x*c,s[5]=b*u+T*c,s[6]=w*u+M*c,s[7]=_*u+L*c,s[8]=x*u-d*c,s[9]=T*u-b*c,s[10]=M*u-w*c,s[11]=L*u-_*c,s}function $4e(s,n,r){let c=Math.sin(r),u=Math.cos(r),d=n[0],b=n[1],w=n[2],_=n[3],x=n[8],T=n[9],M=n[10],L=n[11];return n!==s&&(s[4]=n[4],s[5]=n[5],s[6]=n[6],s[7]=n[7],s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15]),s[0]=d*u-x*c,s[1]=b*u-T*c,s[2]=w*u-M*c,s[3]=_*u-L*c,s[8]=d*c+x*u,s[9]=b*c+T*u,s[10]=w*c+M*u,s[11]=_*c+L*u,s}function V4e(s,n,r){let c=Math.sin(r),u=Math.cos(r),d=n[0],b=n[1],w=n[2],_=n[3],x=n[4],T=n[5],M=n[6],L=n[7];return n!==s&&(s[8]=n[8],s[9]=n[9],s[10]=n[10],s[11]=n[11],s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15]),s[0]=d*u+x*c,s[1]=b*u+T*c,s[2]=w*u+M*c,s[3]=_*u+L*c,s[4]=x*u-d*c,s[5]=T*u-b*c,s[6]=M*u-w*c,s[7]=L*u-_*c,s}function zZt(s,n){return s[0]=1,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=1,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=1,s[11]=0,s[12]=n[0],s[13]=n[1],s[14]=n[2],s[15]=1,s}function GZt(s,n){return s[0]=n[0],s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=n[1],s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=n[2],s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function jZt(s,n,r){let c=r[0],u=r[1],d=r[2],b=Math.sqrt(c*c+u*u+d*d),w,_,x;return b<1e-6?null:(b=1/b,c*=b,u*=b,d*=b,_=Math.sin(n),w=Math.cos(n),x=1-w,s[0]=c*c*x+w,s[1]=u*c*x+d*_,s[2]=d*c*x-u*_,s[3]=0,s[4]=c*u*x-d*_,s[5]=u*u*x+w,s[6]=d*u*x+c*_,s[7]=0,s[8]=c*d*x+u*_,s[9]=u*d*x-c*_,s[10]=d*d*x+w,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s)}function $Zt(s,n){let r=Math.sin(n),c=Math.cos(n);return s[0]=1,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=c,s[6]=r,s[7]=0,s[8]=0,s[9]=-r,s[10]=c,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function VZt(s,n){let r=Math.sin(n),c=Math.cos(n);return s[0]=c,s[1]=0,s[2]=-r,s[3]=0,s[4]=0,s[5]=1,s[6]=0,s[7]=0,s[8]=r,s[9]=0,s[10]=c,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function WZt(s,n){let r=Math.sin(n),c=Math.cos(n);return s[0]=c,s[1]=r,s[2]=0,s[3]=0,s[4]=-r,s[5]=c,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=1,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function Gpt(s,n,r){let c=n[0],u=n[1],d=n[2],b=n[3],w=c+c,_=u+u,x=d+d,T=c*w,M=c*_,L=c*x,I=u*_,D=u*x,F=d*x,O=b*w,z=b*_,Z=b*x;return s[0]=1-(I+F),s[1]=M+Z,s[2]=L-z,s[3]=0,s[4]=M-Z,s[5]=1-(T+F),s[6]=D+O,s[7]=0,s[8]=L+z,s[9]=D-O,s[10]=1-(T+I),s[11]=0,s[12]=r[0],s[13]=r[1],s[14]=r[2],s[15]=1,s}function HZt(s,n){let r=new Cc(3),c=-n[0],u=-n[1],d=-n[2],b=n[3],w=n[4],_=n[5],x=n[6],T=n[7],M=c*c+u*u+d*d+b*b;return M>0?(r[0]=(w*b+T*c+_*d-x*u)*2/M,r[1]=(_*b+T*u+x*c-w*d)*2/M,r[2]=(x*b+T*d+w*u-_*c)*2/M):(r[0]=(w*b+T*c+_*d-x*u)*2,r[1]=(_*b+T*u+x*c-w*d)*2,r[2]=(x*b+T*d+w*u-_*c)*2),Gpt(s,n,r),s}function qZt(s,n){return s[0]=n[12],s[1]=n[13],s[2]=n[14],s}function jpt(s,n){let r=n[0],c=n[1],u=n[2],d=n[4],b=n[5],w=n[6],_=n[8],x=n[9],T=n[10];return s[0]=Math.sqrt(r*r+c*c+u*u),s[1]=Math.sqrt(d*d+b*b+w*w),s[2]=Math.sqrt(_*_+x*x+T*T),s}function XZt(s,n){let r=new Cc(3);jpt(r,n);let c=1/r[0],u=1/r[1],d=1/r[2],b=n[0]*c,w=n[1]*u,_=n[2]*d,x=n[4]*c,T=n[5]*u,M=n[6]*d,L=n[8]*c,I=n[9]*u,D=n[10]*d,F=b+T+D,O=0;return F>0?(O=Math.sqrt(F+1)*2,s[3]=.25*O,s[0]=(M-I)/O,s[1]=(L-_)/O,s[2]=(w-x)/O):b>T&&b>D?(O=Math.sqrt(1+b-T-D)*2,s[3]=(M-I)/O,s[0]=.25*O,s[1]=(w+x)/O,s[2]=(L+_)/O):T>D?(O=Math.sqrt(1+T-b-D)*2,s[3]=(L-_)/O,s[0]=(w+x)/O,s[1]=.25*O,s[2]=(M+I)/O):(O=Math.sqrt(1+D-b-T)*2,s[3]=(w-x)/O,s[0]=(L+_)/O,s[1]=(M+I)/O,s[2]=.25*O),s}function YZt(s,n,r,c){n[0]=c[12],n[1]=c[13],n[2]=c[14];let u=c[0],d=c[1],b=c[2],w=c[4],_=c[5],x=c[6],T=c[8],M=c[9],L=c[10];r[0]=Math.sqrt(u*u+d*d+b*b),r[1]=Math.sqrt(w*w+_*_+x*x),r[2]=Math.sqrt(T*T+M*M+L*L);let I=1/r[0],D=1/r[1],F=1/r[2],O=u*I,z=d*D,Z=b*F,H=w*I,te=_*D,oe=x*F,ne=T*I,ue=M*D,Te=L*F,Q=O+te+Te,ge=0;return Q>0?(ge=Math.sqrt(Q+1)*2,s[3]=.25*ge,s[0]=(oe-ue)/ge,s[1]=(ne-Z)/ge,s[2]=(z-H)/ge):O>te&&O>Te?(ge=Math.sqrt(1+O-te-Te)*2,s[3]=(oe-ue)/ge,s[0]=.25*ge,s[1]=(z+H)/ge,s[2]=(ne+Z)/ge):te>Te?(ge=Math.sqrt(1+te-O-Te)*2,s[3]=(ne-Z)/ge,s[0]=(z+H)/ge,s[1]=.25*ge,s[2]=(oe+ue)/ge):(ge=Math.sqrt(1+Te-O-te)*2,s[3]=(z-H)/ge,s[0]=(ne+Z)/ge,s[1]=(oe+ue)/ge,s[2]=.25*ge),s}function ZZt(s,n,r,c){let u=n[0],d=n[1],b=n[2],w=n[3],_=u+u,x=d+d,T=b+b,M=u*_,L=u*x,I=u*T,D=d*x,F=d*T,O=b*T,z=w*_,Z=w*x,H=w*T,te=c[0],oe=c[1],ne=c[2];return s[0]=(1-(D+O))*te,s[1]=(L+H)*te,s[2]=(I-Z)*te,s[3]=0,s[4]=(L-H)*oe,s[5]=(1-(M+O))*oe,s[6]=(F+z)*oe,s[7]=0,s[8]=(I+Z)*ne,s[9]=(F-z)*ne,s[10]=(1-(M+D))*ne,s[11]=0,s[12]=r[0],s[13]=r[1],s[14]=r[2],s[15]=1,s}function KZt(s,n,r,c,u){let d=n[0],b=n[1],w=n[2],_=n[3],x=d+d,T=b+b,M=w+w,L=d*x,I=d*T,D=d*M,F=b*T,O=b*M,z=w*M,Z=_*x,H=_*T,te=_*M,oe=c[0],ne=c[1],ue=c[2],Te=u[0],Q=u[1],ge=u[2],Qe=(1-(F+z))*oe,st=(I+te)*oe,at=(D-H)*oe,Ne=(I-te)*ne,tt=(1-(L+z))*ne,ot=(O+Z)*ne,Tt=(D+H)*ue,jt=(O-Z)*ue,en=(1-(L+F))*ue;return s[0]=Qe,s[1]=st,s[2]=at,s[3]=0,s[4]=Ne,s[5]=tt,s[6]=ot,s[7]=0,s[8]=Tt,s[9]=jt,s[10]=en,s[11]=0,s[12]=r[0]+Te-(Qe*Te+Ne*Q+Tt*ge),s[13]=r[1]+Q-(st*Te+tt*Q+jt*ge),s[14]=r[2]+ge-(at*Te+ot*Q+en*ge),s[15]=1,s}function W4e(s,n){let r=n[0],c=n[1],u=n[2],d=n[3],b=r+r,w=c+c,_=u+u,x=r*b,T=c*b,M=c*w,L=u*b,I=u*w,D=u*_,F=d*b,O=d*w,z=d*_;return s[0]=1-M-D,s[1]=T+z,s[2]=L-O,s[3]=0,s[4]=T-z,s[5]=1-x-D,s[6]=I+F,s[7]=0,s[8]=L+O,s[9]=I-F,s[10]=1-x-M,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function H4e(s,n,r,c,u,d,b){let w=1/(r-n),_=1/(u-c),x=1/(d-b);return s[0]=d*2*w,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=d*2*_,s[6]=0,s[7]=0,s[8]=(r+n)*w,s[9]=(u+c)*_,s[10]=(b+d)*x,s[11]=-1,s[12]=0,s[13]=0,s[14]=b*d*2*x,s[15]=0,s}function $pt(s,n,r,c,u){let d=1/Math.tan(n/2);if(s[0]=d/r,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=d,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[11]=-1,s[12]=0,s[13]=0,s[15]=0,u!=null&&u!==1/0){let b=1/(c-u);s[10]=(u+c)*b,s[14]=2*u*c*b}else s[10]=-1,s[14]=-2*c;return s}function JZt(s,n,r,c,u){let d=1/Math.tan(n/2);if(s[0]=d/r,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=d,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[11]=-1,s[12]=0,s[13]=0,s[15]=0,u!=null&&u!==1/0){let b=1/(c-u);s[10]=u*b,s[14]=u*c*b}else s[10]=-1,s[14]=-c;return s}function QZt(s,n,r,c){let u=Math.tan(n.upDegrees*Math.PI/180),d=Math.tan(n.downDegrees*Math.PI/180),b=Math.tan(n.leftDegrees*Math.PI/180),w=Math.tan(n.rightDegrees*Math.PI/180),_=2/(b+w),x=2/(u+d);return s[0]=_,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=x,s[6]=0,s[7]=0,s[8]=-((b-w)*_*.5),s[9]=(u-d)*x*.5,s[10]=c/(r-c),s[11]=-1,s[12]=0,s[13]=0,s[14]=c*r/(r-c),s[15]=0,s}function Vpt(s,n,r,c,u,d,b){let w=1/(n-r),_=1/(c-u),x=1/(d-b);return s[0]=-2*w,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=-2*_,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=2*x,s[11]=0,s[12]=(n+r)*w,s[13]=(u+c)*_,s[14]=(b+d)*x,s[15]=1,s}function eKt(s,n,r,c,u,d,b){let w=1/(n-r),_=1/(c-u),x=1/(d-b);return s[0]=-2*w,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=-2*_,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=x,s[11]=0,s[12]=(n+r)*w,s[13]=(u+c)*_,s[14]=d*x,s[15]=1,s}function Y4e(s,n,r,c){let u,d,b,w,_,x,T,M,L,I,D=n[0],F=n[1],O=n[2],z=c[0],Z=c[1],H=c[2],te=r[0],oe=r[1],ne=r[2];return Math.abs(D-te)<1e-6&&Math.abs(F-oe)<1e-6&&Math.abs(O-ne)<1e-6?zpt(s):(M=D-te,L=F-oe,I=O-ne,u=1/Math.sqrt(M*M+L*L+I*I),M*=u,L*=u,I*=u,d=Z*I-H*L,b=H*M-z*I,w=z*L-Z*M,u=Math.sqrt(d*d+b*b+w*w),u?(u=1/u,d*=u,b*=u,w*=u):(d=0,b=0,w=0),_=L*w-I*b,x=I*d-M*w,T=M*b-L*d,u=Math.sqrt(_*_+x*x+T*T),u?(u=1/u,_*=u,x*=u,T*=u):(_=0,x=0,T=0),s[0]=d,s[1]=_,s[2]=M,s[3]=0,s[4]=b,s[5]=x,s[6]=L,s[7]=0,s[8]=w,s[9]=T,s[10]=I,s[11]=0,s[12]=-(d*D+b*F+w*O),s[13]=-(_*D+x*F+T*O),s[14]=-(M*D+L*F+I*O),s[15]=1,s)}function tKt(s,n,r,c){let u=n[0],d=n[1],b=n[2],w=c[0],_=c[1],x=c[2],T=u-r[0],M=d-r[1],L=b-r[2],I=T*T+M*M+L*L;I>0&&(I=1/Math.sqrt(I),T*=I,M*=I,L*=I);let D=_*L-x*M,F=x*T-w*L,O=w*M-_*T;return I=D*D+F*F+O*O,I>0&&(I=1/Math.sqrt(I),D*=I,F*=I,O*=I),s[0]=D,s[1]=F,s[2]=O,s[3]=0,s[4]=M*O-L*F,s[5]=L*D-T*O,s[6]=T*F-M*D,s[7]=0,s[8]=T,s[9]=M,s[10]=L,s[11]=0,s[12]=u,s[13]=d,s[14]=b,s[15]=1,s}function nKt(s){return`mat4(${s[0]}, ${s[1]}, ${s[2]}, ${s[3]}, ${s[4]}, ${s[5]}, ${s[6]}, ${s[7]}, ${s[8]}, ${s[9]}, ${s[10]}, ${s[11]}, ${s[12]}, ${s[13]}, ${s[14]}, ${s[15]})`}function iKt(s){return Math.sqrt(s[0]*s[0]+s[1]*s[1]+s[2]*s[2]+s[3]*s[3]+s[4]*s[4]+s[5]*s[5]+s[6]*s[6]+s[7]*s[7]+s[8]*s[8]+s[9]*s[9]+s[10]*s[10]+s[11]*s[11]+s[12]*s[12]+s[13]*s[13]+s[14]*s[14]+s[15]*s[15])}function rKt(s,n,r){return s[0]=n[0]+r[0],s[1]=n[1]+r[1],s[2]=n[2]+r[2],s[3]=n[3]+r[3],s[4]=n[4]+r[4],s[5]=n[5]+r[5],s[6]=n[6]+r[6],s[7]=n[7]+r[7],s[8]=n[8]+r[8],s[9]=n[9]+r[9],s[10]=n[10]+r[10],s[11]=n[11]+r[11],s[12]=n[12]+r[12],s[13]=n[13]+r[13],s[14]=n[14]+r[14],s[15]=n[15]+r[15],s}function Wpt(s,n,r){return s[0]=n[0]-r[0],s[1]=n[1]-r[1],s[2]=n[2]-r[2],s[3]=n[3]-r[3],s[4]=n[4]-r[4],s[5]=n[5]-r[5],s[6]=n[6]-r[6],s[7]=n[7]-r[7],s[8]=n[8]-r[8],s[9]=n[9]-r[9],s[10]=n[10]-r[10],s[11]=n[11]-r[11],s[12]=n[12]-r[12],s[13]=n[13]-r[13],s[14]=n[14]-r[14],s[15]=n[15]-r[15],s}function sKt(s,n,r){return s[0]=n[0]*r,s[1]=n[1]*r,s[2]=n[2]*r,s[3]=n[3]*r,s[4]=n[4]*r,s[5]=n[5]*r,s[6]=n[6]*r,s[7]=n[7]*r,s[8]=n[8]*r,s[9]=n[9]*r,s[10]=n[10]*r,s[11]=n[11]*r,s[12]=n[12]*r,s[13]=n[13]*r,s[14]=n[14]*r,s[15]=n[15]*r,s}function oKt(s,n,r,c){return s[0]=n[0]+r[0]*c,s[1]=n[1]+r[1]*c,s[2]=n[2]+r[2]*c,s[3]=n[3]+r[3]*c,s[4]=n[4]+r[4]*c,s[5]=n[5]+r[5]*c,s[6]=n[6]+r[6]*c,s[7]=n[7]+r[7]*c,s[8]=n[8]+r[8]*c,s[9]=n[9]+r[9]*c,s[10]=n[10]+r[10]*c,s[11]=n[11]+r[11]*c,s[12]=n[12]+r[12]*c,s[13]=n[13]+r[13]*c,s[14]=n[14]+r[14]*c,s[15]=n[15]+r[15]*c,s}function aKt(s,n){return s[0]===n[0]&&s[1]===n[1]&&s[2]===n[2]&&s[3]===n[3]&&s[4]===n[4]&&s[5]===n[5]&&s[6]===n[6]&&s[7]===n[7]&&s[8]===n[8]&&s[9]===n[9]&&s[10]===n[10]&&s[11]===n[11]&&s[12]===n[12]&&s[13]===n[13]&&s[14]===n[14]&&s[15]===n[15]}function cKt(s,n){let r=s[0],c=s[1],u=s[2],d=s[3],b=s[4],w=s[5],_=s[6],x=s[7],T=s[8],M=s[9],L=s[10],I=s[11],D=s[12],F=s[13],O=s[14],z=s[15],Z=n[0],H=n[1],te=n[2],oe=n[3],ne=n[4],ue=n[5],Te=n[6],Q=n[7],ge=n[8],Qe=n[9],st=n[10],at=n[11],Ne=n[12],tt=n[13],ot=n[14],Tt=n[15];return Math.abs(r-Z)<=1e-6*Math.max(1,Math.abs(r),Math.abs(Z))&&Math.abs(c-H)<=1e-6*Math.max(1,Math.abs(c),Math.abs(H))&&Math.abs(u-te)<=1e-6*Math.max(1,Math.abs(u),Math.abs(te))&&Math.abs(d-oe)<=1e-6*Math.max(1,Math.abs(d),Math.abs(oe))&&Math.abs(b-ne)<=1e-6*Math.max(1,Math.abs(b),Math.abs(ne))&&Math.abs(w-ue)<=1e-6*Math.max(1,Math.abs(w),Math.abs(ue))&&Math.abs(_-Te)<=1e-6*Math.max(1,Math.abs(_),Math.abs(Te))&&Math.abs(x-Q)<=1e-6*Math.max(1,Math.abs(x),Math.abs(Q))&&Math.abs(T-ge)<=1e-6*Math.max(1,Math.abs(T),Math.abs(ge))&&Math.abs(M-Qe)<=1e-6*Math.max(1,Math.abs(M),Math.abs(Qe))&&Math.abs(L-st)<=1e-6*Math.max(1,Math.abs(L),Math.abs(st))&&Math.abs(I-at)<=1e-6*Math.max(1,Math.abs(I),Math.abs(at))&&Math.abs(D-Ne)<=1e-6*Math.max(1,Math.abs(D),Math.abs(Ne))&&Math.abs(F-tt)<=1e-6*Math.max(1,Math.abs(F),Math.abs(tt))&&Math.abs(O-ot)<=1e-6*Math.max(1,Math.abs(O),Math.abs(ot))&&Math.abs(z-Tt)<=1e-6*Math.max(1,Math.abs(z),Math.abs(Tt))}var q4e,X4e,lKt,uKt,Z4e=Ve(()=>{f4();q4e=$pt;X4e=Vpt;lKt=F$,uKt=Wpt});var U1={};Oy(U1,{add:()=>Kpt,ceil:()=>fKt,clone:()=>qpt,copy:()=>Ypt,create:()=>Hpt,cross:()=>vKt,dist:()=>AKt,distance:()=>ngt,div:()=>CKt,divide:()=>egt,dot:()=>rgt,equals:()=>SKt,exactEquals:()=>ogt,floor:()=>hKt,forEach:()=>RKt,fromValues:()=>Xpt,inverse:()=>wKt,len:()=>LKt,length:()=>K4e,lerp:()=>sgt,max:()=>pKt,min:()=>dKt,mul:()=>TKt,multiply:()=>Qpt,negate:()=>bKt,normalize:()=>Q4e,random:()=>_Kt,round:()=>gKt,scale:()=>tgt,scaleAndAdd:()=>mKt,set:()=>Zpt,sqrDist:()=>PKt,sqrLen:()=>kKt,squaredDistance:()=>igt,squaredLength:()=>J4e,str:()=>EKt,sub:()=>MKt,subtract:()=>Jpt,transformMat4:()=>eke,transformQuat:()=>yKt,zero:()=>xKt});function Hpt(){let s=new Cc(4);return Cc!=Float32Array&&(s[0]=0,s[1]=0,s[2]=0,s[3]=0),s}function qpt(s){let n=new Cc(4);return n[0]=s[0],n[1]=s[1],n[2]=s[2],n[3]=s[3],n}function Xpt(s,n,r,c){let u=new Cc(4);return u[0]=s,u[1]=n,u[2]=r,u[3]=c,u}function Ypt(s,n){return s[0]=n[0],s[1]=n[1],s[2]=n[2],s[3]=n[3],s}function Zpt(s,n,r,c,u){return s[0]=n,s[1]=r,s[2]=c,s[3]=u,s}function Kpt(s,n,r){return s[0]=n[0]+r[0],s[1]=n[1]+r[1],s[2]=n[2]+r[2],s[3]=n[3]+r[3],s}function Jpt(s,n,r){return s[0]=n[0]-r[0],s[1]=n[1]-r[1],s[2]=n[2]-r[2],s[3]=n[3]-r[3],s}function Qpt(s,n,r){return s[0]=n[0]*r[0],s[1]=n[1]*r[1],s[2]=n[2]*r[2],s[3]=n[3]*r[3],s}function egt(s,n,r){return s[0]=n[0]/r[0],s[1]=n[1]/r[1],s[2]=n[2]/r[2],s[3]=n[3]/r[3],s}function fKt(s,n){return s[0]=Math.ceil(n[0]),s[1]=Math.ceil(n[1]),s[2]=Math.ceil(n[2]),s[3]=Math.ceil(n[3]),s}function hKt(s,n){return s[0]=Math.floor(n[0]),s[1]=Math.floor(n[1]),s[2]=Math.floor(n[2]),s[3]=Math.floor(n[3]),s}function dKt(s,n,r){return s[0]=Math.min(n[0],r[0]),s[1]=Math.min(n[1],r[1]),s[2]=Math.min(n[2],r[2]),s[3]=Math.min(n[3],r[3]),s}function pKt(s,n,r){return s[0]=Math.max(n[0],r[0]),s[1]=Math.max(n[1],r[1]),s[2]=Math.max(n[2],r[2]),s[3]=Math.max(n[3],r[3]),s}function gKt(s,n){return s[0]=Cb(n[0]),s[1]=Cb(n[1]),s[2]=Cb(n[2]),s[3]=Cb(n[3]),s}function tgt(s,n,r){return s[0]=n[0]*r,s[1]=n[1]*r,s[2]=n[2]*r,s[3]=n[3]*r,s}function mKt(s,n,r,c){return s[0]=n[0]+r[0]*c,s[1]=n[1]+r[1]*c,s[2]=n[2]+r[2]*c,s[3]=n[3]+r[3]*c,s}function ngt(s,n){let r=n[0]-s[0],c=n[1]-s[1],u=n[2]-s[2],d=n[3]-s[3];return Math.sqrt(r*r+c*c+u*u+d*d)}function igt(s,n){let r=n[0]-s[0],c=n[1]-s[1],u=n[2]-s[2],d=n[3]-s[3];return r*r+c*c+u*u+d*d}function K4e(s){let n=s[0],r=s[1],c=s[2],u=s[3];return Math.sqrt(n*n+r*r+c*c+u*u)}function J4e(s){let n=s[0],r=s[1],c=s[2],u=s[3];return n*n+r*r+c*c+u*u}function bKt(s,n){return s[0]=-n[0],s[1]=-n[1],s[2]=-n[2],s[3]=-n[3],s}function wKt(s,n){return s[0]=1/n[0],s[1]=1/n[1],s[2]=1/n[2],s[3]=1/n[3],s}function Q4e(s,n){let r=n[0],c=n[1],u=n[2],d=n[3],b=r*r+c*c+u*u+d*d;return b>0&&(b=1/Math.sqrt(b)),s[0]=r*b,s[1]=c*b,s[2]=u*b,s[3]=d*b,s}function rgt(s,n){return s[0]*n[0]+s[1]*n[1]+s[2]*n[2]+s[3]*n[3]}function vKt(s,n,r,c){let u=r[0]*c[1]-r[1]*c[0],d=r[0]*c[2]-r[2]*c[0],b=r[0]*c[3]-r[3]*c[0],w=r[1]*c[2]-r[2]*c[1],_=r[1]*c[3]-r[3]*c[1],x=r[2]*c[3]-r[3]*c[2],T=n[0],M=n[1],L=n[2],I=n[3];return s[0]=M*x-L*_+I*w,s[1]=-(T*x)+L*b-I*d,s[2]=T*_-M*b+I*u,s[3]=-(T*w)+M*d-L*u,s}function sgt(s,n,r,c){let u=n[0],d=n[1],b=n[2],w=n[3];return s[0]=u+c*(r[0]-u),s[1]=d+c*(r[1]-d),s[2]=b+c*(r[2]-b),s[3]=w+c*(r[3]-w),s}function _Kt(s,n){n=n===void 0?1:n;let r,c,u,d,b,w;do r=Hy()*2-1,c=Hy()*2-1,b=r*r+c*c;while(b>=1);do u=Hy()*2-1,d=Hy()*2-1,w=u*u+d*d;while(w>=1);let _=Math.sqrt((1-b)/w);return s[0]=n*r,s[1]=n*c,s[2]=n*u*_,s[3]=n*d*_,s}function eke(s,n,r){let c=n[0],u=n[1],d=n[2],b=n[3];return s[0]=r[0]*c+r[4]*u+r[8]*d+r[12]*b,s[1]=r[1]*c+r[5]*u+r[9]*d+r[13]*b,s[2]=r[2]*c+r[6]*u+r[10]*d+r[14]*b,s[3]=r[3]*c+r[7]*u+r[11]*d+r[15]*b,s}function yKt(s,n,r){let c=n[0],u=n[1],d=n[2],b=r[0],w=r[1],_=r[2],x=r[3],T=x*c+w*d-_*u,M=x*u+_*c-b*d,L=x*d+b*u-w*c,I=-b*c-w*u-_*d;return s[0]=T*x+I*-b+M*-_-L*-w,s[1]=M*x+I*-w+L*-b-T*-_,s[2]=L*x+I*-_+T*-w-M*-b,s[3]=n[3],s}function xKt(s){return s[0]=0,s[1]=0,s[2]=0,s[3]=0,s}function EKt(s){return`vec4(${s[0]}, ${s[1]}, ${s[2]}, ${s[3]})`}function ogt(s,n){return s[0]===n[0]&&s[1]===n[1]&&s[2]===n[2]&&s[3]===n[3]}function SKt(s,n){let r=s[0],c=s[1],u=s[2],d=s[3],b=n[0],w=n[1],_=n[2],x=n[3];return Math.abs(r-b)<=1e-6*Math.max(1,Math.abs(r),Math.abs(b))&&Math.abs(c-w)<=1e-6*Math.max(1,Math.abs(c),Math.abs(w))&&Math.abs(u-_)<=1e-6*Math.max(1,Math.abs(u),Math.abs(_))&&Math.abs(d-x)<=1e-6*Math.max(1,Math.abs(d),Math.abs(x))}var MKt,TKt,CKt,AKt,PKt,LKt,kKt,RKt,Kce=Ve(()=>{f4();MKt=Jpt,TKt=Qpt,CKt=egt,AKt=ngt,PKt=igt,LKt=K4e,kKt=J4e,RKt=function(){let s=Hpt();return function(n,r,c,u,d,b){let w,_;for(r||(r=4),c||(c=0),u?_=Math.min(u*r+c,n.length):_=n.length,w=c;w<_;w+=r)s[0]=n[w],s[1]=n[w+1],s[2]=n[w+2],s[3]=n[w+3],d(s,s,b),n[w]=s[0],n[w+1]=s[1],n[w+2]=s[2],n[w+3]=s[3];return n}}()});function OKt(){return Jce||(Jce=new Of([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Jce)),Jce}function NKt(){return Qce||(Qce=new Of,Object.freeze(Qce)),Qce}function agt(s){if(s>Math.PI*2)throw Error("expected radians")}function FKt(s,n,r,c,u,d){let b=2*d/(r-n),w=2*d/(u-c),_=(r+n)/(r-n),x=(u+c)/(u-c),T=-1,M=-1,L=-2*d;return s[0]=b,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=w,s[6]=0,s[7]=0,s[8]=_,s[9]=x,s[10]=T,s[11]=M,s[12]=0,s[13]=0,s[14]=L,s[15]=0,s}var ike,IKt,DKt,tke,nke,BKt,Of,Jce,Qce,cgt=Ve(()=>{Npt();D$();M4e();Z4e();S4e();N$();Kce();(function(s){s[s.COL0ROW0=0]="COL0ROW0",s[s.COL0ROW1=1]="COL0ROW1",s[s.COL0ROW2=2]="COL0ROW2",s[s.COL0ROW3=3]="COL0ROW3",s[s.COL1ROW0=4]="COL1ROW0",s[s.COL1ROW1=5]="COL1ROW1",s[s.COL1ROW2=6]="COL1ROW2",s[s.COL1ROW3=7]="COL1ROW3",s[s.COL2ROW0=8]="COL2ROW0",s[s.COL2ROW1=9]="COL2ROW1",s[s.COL2ROW2=10]="COL2ROW2",s[s.COL2ROW3=11]="COL2ROW3",s[s.COL3ROW0=12]="COL3ROW0",s[s.COL3ROW1=13]="COL3ROW1",s[s.COL3ROW2=14]="COL3ROW2",s[s.COL3ROW3=15]="COL3ROW3"})(ike||(ike={}));IKt=45*Math.PI/180,DKt=1,tke=.1,nke=500,BKt=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),Of=class extends Zce{static get IDENTITY(){return NKt()}static get ZERO(){return OKt()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return ike}constructor(n){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(n)?this.copy(n):this.identity()}copy(n){return this[0]=n[0],this[1]=n[1],this[2]=n[2],this[3]=n[3],this[4]=n[4],this[5]=n[5],this[6]=n[6],this[7]=n[7],this[8]=n[8],this[9]=n[9],this[10]=n[10],this[11]=n[11],this[12]=n[12],this[13]=n[13],this[14]=n[14],this[15]=n[15],this.check()}set(n,r,c,u,d,b,w,_,x,T,M,L,I,D,F,O){return this[0]=n,this[1]=r,this[2]=c,this[3]=u,this[4]=d,this[5]=b,this[6]=w,this[7]=_,this[8]=x,this[9]=T,this[10]=M,this[11]=L,this[12]=I,this[13]=D,this[14]=F,this[15]=O,this.check()}setRowMajor(n,r,c,u,d,b,w,_,x,T,M,L,I,D,F,O){return this[0]=n,this[1]=d,this[2]=x,this[3]=I,this[4]=r,this[5]=b,this[6]=T,this[7]=D,this[8]=c,this[9]=w,this[10]=M,this[11]=F,this[12]=u,this[13]=_,this[14]=L,this[15]=O,this.check()}toRowMajor(n){return n[0]=this[0],n[1]=this[4],n[2]=this[8],n[3]=this[12],n[4]=this[1],n[5]=this[5],n[6]=this[9],n[7]=this[13],n[8]=this[2],n[9]=this[6],n[10]=this[10],n[11]=this[14],n[12]=this[3],n[13]=this[7],n[14]=this[11],n[15]=this[15],n}identity(){return this.copy(BKt)}fromObject(n){return this.check()}fromQuaternion(n){return W4e(this,n),this.check()}frustum(n){let{left:r,right:c,bottom:u,top:d,near:b=tke,far:w=nke}=n;return w===1/0?FKt(this,r,c,u,d,b):H4e(this,r,c,u,d,b,w),this.check()}lookAt(n){let{eye:r,center:c=[0,0,0],up:u=[0,1,0]}=n;return Y4e(this,r,c,u),this.check()}ortho(n){let{left:r,right:c,bottom:u,top:d,near:b=tke,far:w=nke}=n;return X4e(this,r,c,u,d,b,w),this.check()}orthographic(n){let{fovy:r=IKt,aspect:c=DKt,focalDistance:u=1,near:d=tke,far:b=nke}=n;agt(r);let w=r/2,_=u*Math.tan(w),x=_*c;return this.ortho({left:-x,right:x,bottom:-_,top:_,near:d,far:b})}perspective(n){let{fovy:r=45*Math.PI/180,aspect:c=1,near:u=.1,far:d=500}=n;return agt(r),q4e(this,r,c,u,d),this.check()}determinant(){return F4e(this)}getScale(n=[-0,-0,-0]){return n[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),n[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),n[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),n}getTranslation(n=[-0,-0,-0]){return n[0]=this[12],n[1]=this[13],n[2]=this[14],n}getRotation(n,r){n=n||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let c=this.getScale(r),u=1/c[0],d=1/c[1],b=1/c[2];return n[0]=this[0]*u,n[1]=this[1]*d,n[2]=this[2]*b,n[3]=0,n[4]=this[4]*u,n[5]=this[5]*d,n[6]=this[6]*b,n[7]=0,n[8]=this[8]*u,n[9]=this[9]*d,n[10]=this[10]*b,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}getRotationMatrix3(n,r){n=n||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let c=this.getScale(r),u=1/c[0],d=1/c[1],b=1/c[2];return n[0]=this[0]*u,n[1]=this[1]*d,n[2]=this[2]*b,n[3]=this[4]*u,n[4]=this[5]*d,n[5]=this[6]*b,n[6]=this[8]*u,n[7]=this[9]*d,n[8]=this[10]*b,n}transpose(){return O4e(this,this),this.check()}invert(){return N4e(this,this),this.check()}multiplyLeft(n){return F$(this,n,this),this.check()}multiplyRight(n){return F$(this,this,n),this.check()}rotateX(n){return j4e(this,this,n),this.check()}rotateY(n){return $4e(this,this,n),this.check()}rotateZ(n){return V4e(this,this,n),this.check()}rotateXYZ(n){return this.rotateX(n[0]).rotateY(n[1]).rotateZ(n[2])}rotateAxis(n,r){return G4e(this,this,n,r),this.check()}scale(n){return z4e(this,this,Array.isArray(n)?n:[n,n,n]),this.check()}translate(n){return U4e(this,this,n),this.check()}transform(n,r){return n.length===4?(r=eke(r||[-0,-0,-0,-0],n,this),Vce(r,4),r):this.transformAsPoint(n,r)}transformAsPoint(n,r){let{length:c}=n,u;switch(c){case 2:u=E4e(r||[-0,-0],n,this);break;case 3:u=O$(r||[-0,-0,-0],n,this);break;default:throw new Error("Illegal vector")}return Vce(u,n.length),u}transformAsVector(n,r){let c;switch(n.length){case 2:c=Cpt(r||[-0,-0],n,this);break;case 3:c=Hce(r||[-0,-0,-0],n,this);break;default:throw new Error("Illegal vector")}return Vce(c,n.length),c}transformPoint(n,r){return this.transformAsPoint(n,r)}transformVector(n,r){return this.transformAsPoint(n,r)}transformDirection(n,r){return this.transformAsVector(n,r)}makeRotationX(n){return this.identity().rotateX(n)}makeTranslation(n,r,c){return this.identity().translate([n,r,c])}}});function lgt(){let s=new Cc(4);return Cc!=Float32Array&&(s[0]=0,s[1]=0,s[2]=0),s[3]=1,s}function UKt(s,n,r){r=r*.5;let c=Math.sin(r);return s[0]=c*n[0],s[1]=c*n[1],s[2]=c*n[2],s[3]=Math.cos(r),s}function rke(s,n,r,c){let u=n[0],d=n[1],b=n[2],w=n[3],_=r[0],x=r[1],T=r[2],M=r[3],L,I,D,F,O;return L=u*_+d*x+b*T+w*M,L<0&&(L=-L,_=-_,x=-x,T=-T,M=-M),1-L>1e-6?(I=Math.acos(L),O=Math.sin(I),D=Math.sin((1-c)*I)/O,F=Math.sin(c*I)/O):(D=1-c,F=c),s[0]=D*u+F*_,s[1]=D*d+F*x,s[2]=D*b+F*T,s[3]=D*w+F*M,s}function zKt(s,n){let r=n[0]+n[4]+n[8],c;if(r>0)c=Math.sqrt(r+1),s[3]=.5*c,c=.5/c,s[0]=(n[5]-n[7])*c,s[1]=(n[6]-n[2])*c,s[2]=(n[1]-n[3])*c;else{let u=0;n[4]>n[0]&&(u=1),n[8]>n[u*3+u]&&(u=2);let d=(u+1)%3,b=(u+2)%3;c=Math.sqrt(n[u*3+u]-n[d*3+d]-n[b*3+b]+1),s[u]=.5*c,c=.5/c,s[3]=(n[d*3+b]-n[b*3+d])*c,s[d]=(n[d*3+u]+n[u*3+d])*c,s[b]=(n[b*3+u]+n[u*3+b])*c}return s}var ugt,Dzn,Bzn,Ozn,fgt=Ve(()=>{f4();B4e();N$();Kce();ugt=Q4e,Dzn=function(){let s=qce(),n=Xce(1,0,0),r=Xce(0,1,0);return function(c,u,d){let b=B$(u,d);return b<-.999999?(h4(s,n,u),I4e(s)<1e-6&&h4(s,r,u),T4e(s,s),UKt(c,s,Math.PI),c):b>.999999?(c[0]=0,c[1]=0,c[2]=0,c[3]=1,c):(h4(s,u,d),c[0]=s[0],c[1]=s[1],c[2]=s[2],c[3]=1+b,ugt(c,c))}}(),Bzn=function(){let s=lgt(),n=lgt();return function(r,c,u,d,b,w){return rke(s,c,b,w),rke(n,u,d,w),rke(r,s,n,2*w*(1-w)),r}}(),Ozn=function(){let s=Fpt();return function(n,r,c,u){return s[0]=c[0],s[3]=c[1],s[6]=c[2],s[1]=u[0],s[4]=u[1],s[7]=u[2],s[2]=-r[0],s[5]=-r[1],s[8]=-r[2],ugt(n,zKt(n,s))}}()});var Nzn,Fzn,Uzn,zzn,hgt=Ve(()=>{Nzn=Math.PI/2,Fzn=Math.PI/4,Uzn=Math.PI/6,zzn=Math.PI*2});var Nf=Ve(()=>{Opt();cgt();hgt();qD();B4e();Z4e();fgt();S4e();N$();Kce()});function ske(s,n=[],r=0){let c=Math.fround(s),u=s-c;return n[r]=c,n[r+1]=u,n}function dgt(s){return s-Math.fround(s)}function pgt(s){let n=new Float32Array(32);for(let r=0;r<4;++r)for(let c=0;c<4;++c){let u=r*4+c;ske(s[c*4+r],n,u*2)}return n}var ggt=Ve(()=>{});function ele(s,n=!0){return s??n}function oke(s=[0,0,0],n=!0){return n?s.map(r=>r/255):[...s]}function mgt(s,n=!0){let r=oke(s.slice(0,3),n),c=Number.isFinite(s[3]),u=c?s[3]:1;return[r[0],r[1],r[2],n&&c?u/255:u]}var ake=Ve(()=>{});var $Kt,VKt,d4,bgt=Ve(()=>{$Kt=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND // All these functions are for substituting tan() function from Intel GPU only const float TWO_PI = 6.2831854820251465; @@ -277,7 +277,7 @@ float tan_fp32(float a) { return tan(a); #endif } -`,GKt=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND +`,VKt=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND const FP32_TWO_PI: f32 = 6.2831854820251465; const FP32_PI_2: f32 = 1.5707963705062866; const FP32_PI_16: f32 = 0.1963495463132858; @@ -398,7 +398,7 @@ fn tan_fp32(a: f32) -> f32 { return tan(a); } #endif -`,d4={name:"fp32",source:GKt,vs:zKt}});var cke,wgt=Ve(()=>{cke=` +`,d4={name:"fp32",source:VKt,vs:$Kt}});var cke,wgt=Ve(()=>{cke=` layout(std140) uniform fp64arithmeticUniforms { uniform float ONE; uniform float SPLIT; @@ -1946,7 +1946,7 @@ fn compare_fp64(a: vec2f, b: vec2f) -> i32 { return fp64_compare_f32_bits(aLowBits, bLowBits); } #endif -`});var jKt,lke,Egt=Ve(()=>{ggt();wgt();xgt();jKt={ONE:1,SPLIT:4097},lke={name:"fp64arithmetic",source:ygt,fs:cke,vs:cke,defaultUniforms:jKt,uniformTypes:{ONE:"f32",SPLIT:"f32"},fp64ify:ske,fp64LowPart:dgt,fp64ifyMatrix4:pgt}});function Mgt(s){return`layout(std140) uniform ${s}Uniforms { +`});var WKt,lke,Egt=Ve(()=>{ggt();wgt();xgt();WKt={ONE:1,SPLIT:4097},lke={name:"fp64arithmetic",source:ygt,fs:cke,vs:cke,defaultUniforms:WKt,uniformTypes:{ONE:"f32",SPLIT:"f32"},fp64ify:ske,fp64LowPart:dgt,fp64ifyMatrix4:pgt}});function Mgt(s){return`layout(std140) uniform ${s}Uniforms { float useByteColors; } ${s}; @@ -2006,7 +2006,7 @@ fn ${s}_premultiply_alpha(inputColor: vec4) -> vec4 { fn ${s}_unpremultiply_alpha(inputColor: vec4) -> vec4 { return ${s}_unpremultiplyAlpha(inputColor); } -`}var L3,$Kt,VKt,hGn,dGn,WKt,HKt,pGn,gGn,Sgt,mGn,qKt,bGn,Cgt,Agt=Ve(()=>{L3={RGBA8UNORM:0,RGBA16FLOAT:1,RGBA32FLOAT:2},$Kt={rgba8unorm:4,rgba16float:8,rgba32float:16},VKt={...$Kt},hGn={rgba8unorm:L3.RGBA8UNORM,rgba16float:L3.RGBA16FLOAT,rgba32float:L3.RGBA32FLOAT},dGn={[L3.RGBA8UNORM]:"rgba8unorm",[L3.RGBA16FLOAT]:"rgba16float",[L3.RGBA32FLOAT]:"rgba32float"},WKt={useByteColors:"f32"},HKt={useByteColors:!0},pGn={format:L3.RGBA8UNORM,wordStride:VKt.rgba8unorm/Uint32Array.BYTES_PER_ELEMENT,wordOffset:0,_padding:0},gGn=Mgt("colors"),Sgt=Mgt("floatColors"),mGn=Tgt("colors"),qKt=Tgt("floatColors"),bGn=`struct storageColorsUniforms { +`}var L3,HKt,qKt,mGn,bGn,XKt,YKt,wGn,vGn,Sgt,_Gn,ZKt,yGn,Cgt,Agt=Ve(()=>{L3={RGBA8UNORM:0,RGBA16FLOAT:1,RGBA32FLOAT:2},HKt={rgba8unorm:4,rgba16float:8,rgba32float:16},qKt={...HKt},mGn={rgba8unorm:L3.RGBA8UNORM,rgba16float:L3.RGBA16FLOAT,rgba32float:L3.RGBA32FLOAT},bGn={[L3.RGBA8UNORM]:"rgba8unorm",[L3.RGBA16FLOAT]:"rgba16float",[L3.RGBA32FLOAT]:"rgba32float"},XKt={useByteColors:"f32"},YKt={useByteColors:!0},wGn={format:L3.RGBA8UNORM,wordStride:qKt.rgba8unorm/Uint32Array.BYTES_PER_ELEMENT,wordOffset:0,_padding:0},vGn=Mgt("colors"),Sgt=Mgt("floatColors"),_Gn=Tgt("colors"),ZKt=Tgt("floatColors"),yGn=`struct storageColorsUniforms { format: u32, wordStride: u32, wordOffset: u32, @@ -2052,7 +2052,7 @@ fn storageColors_readColor(rowIndex: u32) -> vec4 { } return storageColors_readRgba32FloatColor(wordIndex); } -`;Cgt={name:"floatColors",props:{},uniforms:{},vs:Sgt,fs:Sgt,source:qKt,uniformTypes:WKt,defaultUniforms:HKt}});function KKt(s={},n){let r={},c=ele(s.useByteColors,!0);if(s.highlightedObjectColor!==void 0)if(s.highlightedObjectColor===null)r.isHighlightActive=!1;else{r.isHighlightActive=!0;let u=s.highlightedObjectColor.slice(0,3);r.highlightedObjectColor=u}return s.highlightColor&&(r.highlightColor=mgt(s.highlightColor,c)),s.isActive!==void 0&&(r.isActive=!!s.isActive,r.isAttribute=!!s.isAttribute),s.useByteColors!==void 0&&(r.useByteColors=!!s.useByteColors),r}var XKt,YKt,ZKt,VM,Pgt=Ve(()=>{ake();XKt=[0,1,1,1],YKt=`layout(std140) uniform pickingUniforms { +`;Cgt={name:"floatColors",props:{},uniforms:{},vs:Sgt,fs:Sgt,source:ZKt,uniformTypes:XKt,defaultUniforms:YKt}});function eJt(s={},n){let r={},c=ele(s.useByteColors,!0);if(s.highlightedObjectColor!==void 0)if(s.highlightedObjectColor===null)r.isHighlightActive=!1;else{r.isHighlightActive=!0;let u=s.highlightedObjectColor.slice(0,3);r.highlightedObjectColor=u}return s.highlightColor&&(r.highlightColor=mgt(s.highlightColor,c)),s.isActive!==void 0&&(r.isActive=!!s.isActive,r.isAttribute=!!s.isAttribute),s.useByteColors!==void 0&&(r.useByteColors=!!s.useByteColors),r}var KKt,JKt,QKt,VM,Pgt=Ve(()=>{ake();KKt=[0,1,1,1],JKt=`layout(std140) uniform pickingUniforms { float isActive; float isAttribute; float isHighlightActive; @@ -2123,7 +2123,7 @@ void picking_setPickingAttribute(vec3 value) { picking_vRGBcolor_Avalid.rgb = value; } } -`,ZKt=`layout(std140) uniform pickingUniforms { +`,QKt=`layout(std140) uniform pickingUniforms { float isActive; float isAttribute; float isHighlightActive; @@ -2179,7 +2179,7 @@ vec4 picking_filterColor(vec4 color) { vec4 highlightColor = picking_filterHighlightColor(color); return picking_filterPickingColor(highlightColor); } -`,VM={props:{},uniforms:{},name:"picking",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useByteColors:"f32",highlightedObjectColor:"vec3",highlightColor:"vec4"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useByteColors:!0,highlightedObjectColor:[0,0,0],highlightColor:XKt},vs:YKt,fs:ZKt,getUniforms:KKt}});var uke,Lgt=Ve(()=>{uke=`precision highp int; +`,VM={props:{},uniforms:{},name:"picking",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useByteColors:"f32",highlightedObjectColor:"vec3",highlightColor:"vec4"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useByteColors:!0,highlightedObjectColor:[0,0,0],highlightColor:KKt},vs:JKt,fs:QKt,getUniforms:eJt}});var uke,Lgt=Ve(()=>{uke=`precision highp int; // #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) struct AmbientLight { @@ -2338,7 +2338,7 @@ fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3) ); return distanceAttenuation / max(coneFactor, 0.0001); } -`});function QKt(s,n={}){if(s=s&&{...s},!s)return nle();s.lights&&(s={...s,...tJt(s.lights),lights:void 0});let{useByteColors:r,ambientLight:c,pointLights:u,spotLights:d,directionalLights:b}=s||{};if(!(c||u&&u.length>0||d&&d.length>0||b&&b.length>0))return{...nle(),enabled:0};let _={...nle(),...eJt({useByteColors:r,ambientLight:c,pointLights:u,spotLights:d,directionalLights:b})};return s.enabled!==void 0&&(_.enabled=s.enabled?1:0),_}function eJt({useByteColors:s,ambientLight:n,pointLights:r=[],spotLights:c=[],directionalLights:u=[]}){let d=Dgt(),b=0,w=0,_=0,x=0;for(let T of r){if(b>=p4)break;d[b]={...d[b],color:tle(T,s),position:T.position,attenuation:T.attenuation||[1,0,0]},b++,w++}for(let T of c){if(b>=p4)break;d[b]={...d[b],color:tle(T,s),position:T.position,direction:T.direction,attenuation:T.attenuation||[1,0,0],coneCos:iJt(T)},b++,_++}for(let T of u){if(b>=p4)break;d[b]={...d[b],color:tle(T,s),direction:T.direction},b++,x++}return r.length+c.length+u.length>p4&&Qt.warn(`MAX_LIGHTS exceeded, truncating to ${p4}`)(),{ambientColor:tle(n,s),directionalLightCount:x,pointLightCount:w,spotLightCount:_,lights:d}}function tJt(s){let n={pointLights:[],spotLights:[],directionalLights:[]};for(let r of s||[])switch(r.type){case"ambient":n.ambientLight=r;break;case"directional":n.directionalLights?.push(r);break;case"point":n.pointLights?.push(r);break;case"spot":n.spotLights?.push(r);break;default:}return n}function tle(s={},n){let{color:r=[0,0,0],intensity:c=1}=s;return oke(r,ele(n,!0)).map(d=>d*c)}function nle(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:Dgt()}}function Dgt(){return Array.from({length:p4},()=>nJt())}function nJt(){return{color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}}function iJt(s){let n=s.innerConeAngle??0,r=s.outerConeAngle??Math.PI/4;return[Math.cos(n),Math.cos(r)]}var p4,JKt,Igt,Bgt=Ve(()=>{Vr();Lgt();Rgt();ake();p4=5,JKt={color:"vec3",position:"vec3",direction:"vec3",attenuation:"vec3",coneCos:"vec2"},Igt={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",directionalLightCount:"i32",pointLightCount:"i32",spotLightCount:"i32",ambientColor:"vec3",lights:[JKt,p4]},defaultUniforms:nle(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:kgt,vs:uke,fs:uke,getUniforms:QKt}});var Ogt,Ngt,Fgt=Ve(()=>{Ogt=`layout(std140) uniform phongMaterialUniforms { +`});function nJt(s,n={}){if(s=s&&{...s},!s)return nle();s.lights&&(s={...s,...rJt(s.lights),lights:void 0});let{useByteColors:r,ambientLight:c,pointLights:u,spotLights:d,directionalLights:b}=s||{};if(!(c||u&&u.length>0||d&&d.length>0||b&&b.length>0))return{...nle(),enabled:0};let _={...nle(),...iJt({useByteColors:r,ambientLight:c,pointLights:u,spotLights:d,directionalLights:b})};return s.enabled!==void 0&&(_.enabled=s.enabled?1:0),_}function iJt({useByteColors:s,ambientLight:n,pointLights:r=[],spotLights:c=[],directionalLights:u=[]}){let d=Dgt(),b=0,w=0,_=0,x=0;for(let T of r){if(b>=p4)break;d[b]={...d[b],color:tle(T,s),position:T.position,attenuation:T.attenuation||[1,0,0]},b++,w++}for(let T of c){if(b>=p4)break;d[b]={...d[b],color:tle(T,s),position:T.position,direction:T.direction,attenuation:T.attenuation||[1,0,0],coneCos:oJt(T)},b++,_++}for(let T of u){if(b>=p4)break;d[b]={...d[b],color:tle(T,s),direction:T.direction},b++,x++}return r.length+c.length+u.length>p4&&Qt.warn(`MAX_LIGHTS exceeded, truncating to ${p4}`)(),{ambientColor:tle(n,s),directionalLightCount:x,pointLightCount:w,spotLightCount:_,lights:d}}function rJt(s){let n={pointLights:[],spotLights:[],directionalLights:[]};for(let r of s||[])switch(r.type){case"ambient":n.ambientLight=r;break;case"directional":n.directionalLights?.push(r);break;case"point":n.pointLights?.push(r);break;case"spot":n.spotLights?.push(r);break;default:}return n}function tle(s={},n){let{color:r=[0,0,0],intensity:c=1}=s;return oke(r,ele(n,!0)).map(d=>d*c)}function nle(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:Dgt()}}function Dgt(){return Array.from({length:p4},()=>sJt())}function sJt(){return{color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}}function oJt(s){let n=s.innerConeAngle??0,r=s.outerConeAngle??Math.PI/4;return[Math.cos(n),Math.cos(r)]}var p4,tJt,Igt,Bgt=Ve(()=>{Vr();Lgt();Rgt();ake();p4=5,tJt={color:"vec3",position:"vec3",direction:"vec3",attenuation:"vec3",coneCos:"vec2"},Igt={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",directionalLightCount:"i32",pointLightCount:"i32",spotLightCount:"i32",ambientColor:"vec3",lights:[tJt,p4]},defaultUniforms:nle(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:kgt,vs:uke,fs:uke,getUniforms:nJt}});var Ogt,Ngt,Fgt=Ve(()=>{Ogt=`layout(std140) uniform phongMaterialUniforms { uniform bool unlit; uniform float ambient; uniform float diffuse; @@ -2525,9 +2525,9 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3, position_worldspace } return lightColor; } -`});var rJt,ZD,Ggt=Ve(()=>{Agt();Bgt();Fgt();zgt();rJt=[38.25,38.25,38.25],ZD={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:Ngt.replace("phongMaterial","gouraudMaterial"),fs:Ogt.replace("phongMaterial","gouraudMaterial"),source:Ugt.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[Igt,Cgt],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:rJt},getUniforms(s){return{...ZD.defaultUniforms,...s}}}});var vm=Ve(()=>{ELe();Ddt();c4e();ppt();mpt();bgt();Egt();Pgt();Ggt()});function Qy(s="id"){Ike[s]=Ike[s]||1;let n=Ike[s]++;return`${s}-${n}`}var Ike,hB=Ve(()=>{Ike={}});function y4(s){switch(s){case"POSITION":return"positions";case"NORMAL":return"normals";case"TEXCOORD_0":return"texCoords";case"TEXCOORD_1":return"texCoords1";case"COLOR_0":return"colors";default:return s}}function een(s){let n=[];for(let[r,c]of Object.entries(s)){if(!c)continue;let{value:u,size:d,normalized:b}=c;if(d===void 0)throw new Error(`Attribute ${r} is missing a size`);n.push({name:y4(r),format:hl.getVertexFormatFromAttribute(u,d,b)})}return n}var kb,Sle=Ve(()=>{Vr();hB();kb=class{id;topology;vertexCount;indices;attributes;bufferLayout;userData={};constructor(n){let{attributes:r={},indices:c=null,vertexCount:u=null}=n;this.id=n.id||Qy("geometry"),this.topology=n.topology,c&&(this.indices=ArrayBuffer.isView(c)?{value:c,size:1}:c),this.attributes={};for(let[d,b]of Object.entries(r)){let w=ArrayBuffer.isView(b)?{value:b}:b;if(!ArrayBuffer.isView(w.value))throw new Error(`${this._print(d)}: must be typed array or object with value as typed array`);if((d==="POSITION"||d==="positions")&&!w.size&&(w.size=3),d==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=w}else{let _=y4(d),x=Object.keys(this.attributes).find(T=>y4(T)===_);x&&delete this.attributes[x],this.attributes[d]=w}}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=u||this._calculateVertexCount(this.attributes,this.indices),this.bufferLayout=n.bufferLayout||een(this.attributes)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(n){return`Geometry ${this.id} attribute ${n}`}_setAttributes(n,r){return this}_calculateVertexCount(n,r){if(r)return r.value.length;let c=1/0;for(let u of Object.values(n)){if(!u)continue;let{value:d,size:b,constant:w}=u;!w&&d&&b!==void 0&&b>=1&&(c=Math.min(c,d.length/b))}return c}}});function Omt(s,n={}){let r=n.bufferName||"geometry";if(ten(s,r))return s;let c=n.minAttributeAlignment||4,u=nen(s,n.attributes),d=[],b=0,w=1/0;for(let[T,M]of u){if(!M)continue;if(M.constant)throw new Error(`Attribute ${T} is constant`);let{value:L,size:I,normalized:D}=M;if(!ArrayBuffer.isView(L))throw new Error(`Attribute ${T} is missing typed array data`);if(I===void 0)throw new Error(`Attribute ${T} is missing a size`);let F=hl.getVertexFormatFromAttribute(L,I,D),O=hl.getVertexFormatInfo(F);b=Bmt(b,c),d.push({sourceName:T,attributeName:y4(T),value:L,size:I,format:F,byteOffset:b,byteLength:O.byteLength}),b+=O.byteLength;let z=L.length/I;if(!Number.isInteger(z))throw new Error(`Attribute ${T} length is not divisible by size`);w=Math.min(w,z)}if(d.length===0||!Number.isFinite(w))throw new Error(`Geometry ${s.id} has no interleavable attributes`);let _=Bmt(b,c),x=new ArrayBuffer(w*_);for(let T of d)ien(x,w,_,T);return new kb({id:s.id,topology:s.topology||"triangle-list",vertexCount:s.vertexCount,indices:s.indices,attributes:{[r]:{value:new Uint8Array(x),size:_,byteStride:_}},bufferLayout:[{name:r,stepMode:"vertex",byteStride:_,attributes:d.map(T=>({attribute:T.attributeName,format:T.format,byteOffset:T.byteOffset}))}]})}function ten(s,n){if(s.bufferLayout.length!==1)return!1;let r=s.bufferLayout[0];return r.name===n&&!!r.attributes?.length&&!!s.attributes[n]}function nen(s,n){return n?n.map(r=>[r,s.attributes[r]]):Object.entries(s.attributes)}function ien(s,n,r,c){let u=c.value.constructor,d=u.BYTES_PER_ELEMENT;if(c.byteOffset%d!==0||r%d!==0)throw new Error(`Attribute ${c.sourceName} is not aligned to its component type`);let b=new u(s),w=c.value,_=c.byteOffset/d,x=r/d;for(let T=0;T{Vr();Sle()});var ren,sen,x4,Fmt=Ve(()=>{ren=1,sen=1,x4=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(n){let{delay:r=0,duration:c=Number.POSITIVE_INFINITY,rate:u=1,repeat:d=1}=n,b=ren++,w={time:0,delay:r,duration:c,rate:u,repeat:d};return this._setChannelTime(w,this.time),this.channels.set(b,w),b}removeChannel(n){this.channels.delete(n);for(let[r,c]of this.animations)c.channel===n&&this.detachAnimation(r)}isFinished(n){let r=this.channels.get(n);return r===void 0?!1:this.time>=r.delay+r.duration*r.repeat}getTime(n){if(n===void 0)return this.time;let r=this.channels.get(n);return r===void 0?-1:r.time}setTime(n){this.time=Math.max(0,n);let r=this.channels.values();for(let u of r)this._setChannelTime(u,this.time);let c=this.animations.values();for(let u of c){let{animation:d,channel:b}=u;d.setTime(this.getTime(b))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(n,r){let c=sen++;return this.animations.set(c,{animation:n,channel:r}),n.setTime(this.getTime(r)),c}detachAnimation(n){this.animations.delete(n)}update(n){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=n),this.setTime(this.time+(n-this.lastEngineTime)),this.lastEngineTime=n)}_setChannelTime(n,r){let c=r-n.delay,u=n.duration*n.repeat;c>=u?n.time=n.duration*n.rate:(n.time=Math.max(0,c)%n.duration,n.time*=n.rate)}}});function Umt(s){let n=typeof window<"u"?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame:null;return n?n.call(window,s):setTimeout(()=>s(typeof performance<"u"?performance.now():Date.now()),1e3/60)}function zmt(s){let n=typeof window<"u"?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame:null;if(n){n.call(window,s);return}clearTimeout(s)}var Gmt=Ve(()=>{});var oen,aen,jmt,iV,$mt=Ve(()=>{Vr();Gmt();Kj();oen=0,aen="Animation Loop",jmt={requestAnimationFrame:s=>Umt(s),cancelAnimationFrame:s=>zmt(s)},iV=class s{static defaultAnimationLoopProps={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:n=>{console.error(n)},stats:void 0,autoResizeViewport:!1,animationFrameProvider:jmt};device=null;canvas=null;props;animationProps=null;timeline=null;stats;sharedStats;cpuTime;gpuTime;frameRate;display;_needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;_lastFrameTime=0;constructor(n){if(this.props={...s.defaultAnimationLoopProps,...n},n=this.props,!n.device)throw new Error("No device provided");this.stats=n.stats||new Eb({id:`animation-loop-${oen++}`}),this.sharedStats=UD.stats.get(aen),this.frameRate=this.stats.get("Frame Rate"),this.frameRate.setSampleSize(1),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.setProps({autoResizeViewport:n.autoResizeViewport,animationFrameProvider:n.animationFrameProvider}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null),this.device?._disableDebugGPUTime()}delete(){this.destroy()}reportError(n){this._error=n,this.props.onError(n),this.props.onError===s.defaultAnimationLoopProps.onError&&typeof window<"u"&&typeof ErrorEvent<"u"&&window.dispatchEvent(new ErrorEvent("error",{error:n,message:n.message}))}setNeedsRedraw(n){return this._needsRedraw=this._needsRedraw||n,this}needsRedraw(){let n=this._needsRedraw;return this._needsRedraw=!1,n}setProps(n){if("autoResizeViewport"in n&&(this.props.autoResizeViewport=n.autoResizeViewport||!1),"animationFrameProvider"in n){let r=n.animationFrameProvider||jmt;if(r!==this.props.animationFrameProvider){let c=this._animationFrameId!==null;c&&this._cancelAnimationFrame(),this.props.animationFrameProvider=r,c&&this._requestAnimationFrame()}}return this}async start(){if(this._running)return this;this._running=!0;try{let n;if(!this._initialized){if(this._initialized=!0,await this._initDevice(),this._initialize(),!this._running)return null;await this.props.onInitialize(this._getAnimationProps())}return this._running?(n!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(n){let r=n instanceof Error?n:new Error("Unknown error");throw this.props.onError(r),r}}stop(){if(this._running){let n=this.animationProps;this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1,this._lastFrameTime=0,n&&this.props.onFinalize(n)}return this}redraw(n,r=null){return this.device?.isLost||this._error?this:(this._beginFrameTimers(n),this._setupFrame(),this.animationProps&&(this.animationProps.animationFrame=r),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(n){return this.timeline=n,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(n=>{this._resolveNextFrame=n})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeViewport(),this.device?._enableDebugGPUTime()}_setDisplay(n){this.display&&(this.display.destroy(),this.display.animationLoop=null),n&&(n.animationLoop=this),this.display=n}_requestAnimationFrame(){this._running&&(this._animationFrameId=this.props.animationFrameProvider.requestAnimationFrame(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(this.props.animationFrameProvider.cancelAnimationFrame(this._animationFrameId),this._animationFrameId=null)}_animationFrame(n,r){if(this._running)try{this.redraw(n,r??null),this._requestAnimationFrame()}catch(c){let u=c instanceof Error?c:new Error(String(c));this.reportError(u),this.stop()}}_renderFrame(n){if(this.display){this.display._renderFrame(n);return}let r=this.props.onRender(this._getAnimationProps());this.device&&r!==!1&&this.device.submit()}_clearNeedsRedraw(){this._needsRedraw=!1}_setupFrame(){this._resizeViewport()}_initializeAnimationProps(){let n=this.device?.getDefaultCanvasContext();if(!this.device||!n)throw new Error("loop");let r=n?.canvas,c=n.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:n,canvas:r,useDevicePixels:c,timeline:this.timeline,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,animationFrame:null,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:n,height:r,aspect:c}=this._getSizeAndAspect();(n!==this.animationProps.width||r!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),c!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=n,this.animationProps.height=r,this.animationProps.aspect=c,this.animationProps.needsRedraw=this._needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.getDefaultCanvasContext().canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let n=document.createElement("div");document.body.appendChild(n),n.style.position="relative";let r=document.createElement("div");r.style.position="absolute",r.style.left="10px",r.style.bottom="10px",r.style.width="300px",r.style.background="white",this.canvas instanceof HTMLCanvasElement&&n.appendChild(this.canvas),n.appendChild(r);let c=this.props.onAddHTML(r);c&&(r.innerHTML=c)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[n,r]=this.device.getDefaultCanvasContext().getDrawingBufferSize(),c=n>0&&r>0?n/r:1;return{width:n,height:r,aspect:c}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(n){let r=n??(typeof performance<"u"?performance.now():Date.now());if(this._lastFrameTime){let c=r-this._lastFrameTime;c>0&&this.frameRate.addTime(c)}this._lastFrameTime=r,this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeStart()}_endFrameTimers(){this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeEnd(),this._updateSharedStats()}_consumeEncodedGpuTime(){if(!this.device)return;let n=this.device.commandEncoder._gpuTimeMs;n!==void 0&&(this.gpuTime.addTime(n),this.device.commandEncoder._gpuTimeMs=void 0)}_updateSharedStats(){if(this.stats!==this.sharedStats){for(let n of Object.keys(this.sharedStats.stats))this.stats.stats[n]||delete this.sharedStats.stats[n];this.stats.forEach(n=>{let r=this.sharedStats.get(n.name,n.type);r.sampleSize=n.sampleSize,r.time=n.time,r.count=n.count,r.samples=n.samples,r.lastTiming=n.lastTiming,r.lastSampleTime=n.lastSampleTime,r.lastSampleCount=n.lastSampleCount,r._count=n._count,r._time=n._time,r._samples=n._samples,r._startTime=n._startTime,r._timerPending=n._timerPending})}}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(n){n instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[n.offsetX,n.offsetY])}_onMouseleave(n){this._getAnimationProps()._mousePosition=null}}});function Vmt(s,n){if(n instanceof Mle)return n;let r=Omt(n),c=cen(s,r),{attributes:u,bufferLayout:d}=len(s,r);return new Mle({topology:r.topology||"triangle-list",bufferLayout:d,vertexCount:r.vertexCount,indices:c,attributes:u})}function cen(s,n){if(!n.indices)return;let r=n.indices.value;return s.createBuffer({usage:cs.INDEX,data:r})}function len(s,n){let r={};for(let[c,u]of Object.entries(n.attributes)){let d=n.bufferLayout.find(b=>b.name===c)?.name||y4(c);u&&(r[d]=s.createBuffer({data:u.value,id:`${c}-buffer`}))}return{attributes:r,bufferLayout:n.bufferLayout,vertexCount:n.vertexCount}}var Mle,Wmt=Ve(()=>{Vr();Sle();Nmt();hB();Mle=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(n){if(this.id=n.id||Qy("geometry"),this.topology=n.topology,this.indices=n.indices||null,this.attributes=n.attributes,this.vertexCount=n.vertexCount,this.bufferLayout=n.bufferLayout||[],this.indices&&!(this.indices.usage&cs.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){this.indices?.destroy();for(let n of Object.values(this.attributes))n.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(n){return n.byteLength/12}}});function Hmt(s,n){let r={},c="Values";if(s.attributes.length===0&&!s.varyings?.length)return{"No attributes or varyings":{[c]:"N/A"}};for(let u of s.attributes)if(u){let d=`${u.location} ${u.name}: ${u.type}`;r[`in ${d}`]={[c]:u.stepMode||"vertex"}}for(let u of s.varyings||[]){let d=`${u.location} ${u.name}`;r[`out ${d}`]={[c]:JSON.stringify(u)}}return r}var qmt=Ve(()=>{});function Zmt(s,n,r){if(s.device.type!=="webgl")return;let c=hen(s.device);if(!c.flushing){if(pen(s)){uen(s,r,c);return}n&&den(n)&&n.handle!==null&&(c.queuedFramebuffers.includes(n)||c.queuedFramebuffers.push(n))}}function uen(s,n,r){if(r.queuedFramebuffers.length===0)return;let c=s.device,{gl:u}=c,d=u.getParameter(36010),b=u.getParameter(36006),[w,_]=s.device.getDefaultCanvasContext().getDrawingBufferSize(),x=Ymt(n.top,8),T=Ymt(n.left,8);r.flushing=!0;try{for(let M of r.queuedFramebuffers){let[L,I,D,F,O]=fen({framebuffer:M,targetWidth:w,targetHeight:_,topPx:x,leftPx:T,minimap:n.minimap});u.bindFramebuffer(36008,M.handle),u.bindFramebuffer(36009,null),u.blitFramebuffer(0,0,M.width,M.height,L,I,D,F,16384,9728),x+=O+8}}finally{u.bindFramebuffer(36008,d),u.bindFramebuffer(36009,b),r.flushing=!1}}function fen(s){let{framebuffer:n,targetWidth:r,targetHeight:c,topPx:u,leftPx:d,minimap:b}=s,w=b?Math.max(Math.floor(r/4),1):r,_=b?Math.max(Math.floor(c/4),1):c,x=Math.min(w/n.width,_/n.height),T=Math.max(Math.floor(n.width*x),1),M=Math.max(Math.floor(n.height*x),1),L=d,I=Math.max(c-u-M,0),D=L+T,F=I+M;return[L,I,D,F,M]}function hen(s){return s.userData[Xmt]||={flushing:!1,queuedFramebuffers:[]},s.userData[Xmt]}function den(s){return"colorAttachments"in s}function pen(s){let n=s.props.framebuffer;return!n||n.handle===null}function Ymt(s,n){if(!s)return n;let r=Number.parseInt(s,10);return Number.isFinite(r)?r:n}var Xmt,Kmt=Ve(()=>{Xmt="__debugFramebufferState"});function dB(s,n,r){if(s===n)return!0;if(!r||!s||!n)return!1;if(Array.isArray(s)){if(!Array.isArray(n)||s.length!==n.length)return!1;for(let c=0;c{});var pB,Qmt=Ve(()=>{Vr();pB=class{bufferLayouts;constructor(n){this.bufferLayouts=n}getBufferLayout(n){return this.bufferLayouts.find(r=>r.name===n)||null}getAttributeNamesForBuffer(n){return VD(n)}mergeBufferLayouts(n,r){let c=[...n];for(let u of r){let d=c.findIndex(b=>b.name===u.name);d<0?c.push(u):c[d]=u}return c}}});function e1t(s,n){let r=i4e(s),c=n.slice();return c.sort((u,d)=>{let b=Oce(VD(u).map(_=>r[_])),w=Oce(VD(d).map(_=>r[_]));return b-w}),c}var t1t=Ve(()=>{Vr()});function gB(s,n){if(!s||!n.some(c=>c.bindingLayout?.length))return s;let r={...s,bindings:s.bindings.map(c=>({...c}))};"attributes"in(s||{})&&(r.attributes=s?.attributes||[]);for(let c of n)for(let u of c.bindingLayout||[])for(let d of gen(u.name)){let b=r.bindings.find(w=>w.name===d);b?.group===0&&(b.group=u.group),b&&u.visibility!==void 0&&(b.visibility=u.visibility)}return r}function n1t(s,n,r=[]){return s?n?{...s,attributes:s.attributes.length?wen(s.attributes,n.attributes.filter(c=>r.includes(c.name))):n.attributes,bindings:ben(s.bindings,n.bindings)}:s:n}function rV(s){return!!(s.uniformTypes&&!men(s.uniformTypes))}function i1t(s){let n=[];for(let r of s){let c=k$(r),u=new Set([r.vs,r.fs].flatMap(b=>b?R$(b).filter(w=>w.isStd140).map(w=>w.blockName):[])),d=u.has(c)?c:u.size===1?u.values().next().value:void 0;rV(r)&&d&&n.push({name:d,uniformTypes:r.uniformTypes})}return n}function Tle(s,n){let r=[],c=new Set;for(let u of[...s||[],...n||[]])c.has(u.name)||(c.add(u.name),r.push(u));return r}function gen(s){let n=new Set([s,`${s}Uniforms`]);return s.endsWith("Uniforms")||n.add(`${s}Sampler`),[...n]}function men(s){for(let n in s)return!1;return!0}function ben(s,n){let r=s.map(d=>({...d})),c=new Set(s.map(d=>d.name)),u=new Set(s.map(d=>`${d.group}:${d.location}`));for(let d of n){let b=`${d.group}:${d.location}`;!c.has(d.name)&&!u.has(b)&&r.push({...d})}return r}function wen(s,n){let r=s.map(d=>({...d})),c=new Map(s.map(d=>[d.name,d])),u=new Map(s.map(d=>[d.location,d]));for(let d of n){let b=c.get(d.name);if(b){if(b.type!==d.type||b.location!==d.location)throw new Error(`Shader attribute "${d.name}" conflicts with its inferred type or location`);continue}let w=u.get(d.location);if(w)throw new Error(`Shader attributes "${w.name}" and "${d.name}" both use location ${d.location}`);r.push({...d})}return r}var Dke=Ve(()=>{vm()});function ven(s){return r$(s)||typeof s=="number"||typeof s=="boolean"}function r1t(s,n={}){let r={bindings:{},uniforms:{}};return Object.keys(s).forEach(c=>{let u=s[c];Object.prototype.hasOwnProperty.call(n,c)||ven(u)?r.uniforms[c]=u:r.bindings[c]=u}),r}var s1t=Ve(()=>{sLe()});function o1t(s={},n={},r={}){let c={...s};for(let[u,d]of Object.entries(n))d!==void 0&&(c[u]=Bke(s[u],d,r[u]));return c}function Bke(s,n,r){if(!r||typeof r=="string")return sV(n);if(Array.isArray(r)){if(Oke(n)||!Array.isArray(n))return sV(n);let b=Array.isArray(s)&&!Oke(s)?[...s]:[],w=b.slice();for(let _=0;_r===void 0?void 0:sV(r)):Nke(s)?Object.fromEntries(Object.entries(s).map(([n,r])=>[n,r===void 0?void 0:sV(r)])):s}function Oke(s){return ArrayBuffer.isView(s)||Array.isArray(s)&&(s.length===0||typeof s[0]=="number")}function Nke(s){return!!s&&typeof s=="object"&&!Array.isArray(s)&&!ArrayBuffer.isView(s)}function _en(s){return!!s?.dependencies}var mB,Fke=Ve(()=>{Vr();vm();s1t();mB=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;directBindings={};constructor(n,r){Object.assign(this.options,r);let c=ZL(Object.values(n).filter(_en));for(let u of c)n[u.name]=u;Qt.log(1,"Creating ShaderInputs with modules",Object.keys(n))(),this.modules=n,this.moduleUniforms={},this.moduleBindings={};for(let[u,d]of Object.entries(n))d&&(this._addModule(d),d.name&&u!==d.name&&!this.options.disableWarnings&&Qt.warn(`Module name: ${u} vs ${d.name}`)())}destroy(){}setProps(n){n.bindings&&Object.assign(this.directBindings,n.bindings);for(let r of Object.keys(n)){if(r==="bindings")continue;let c=r,u=n[c]||{},d=this.modules[c];if(!d)this.options.disableWarnings||Qt.warn(`Module ${r} not found`)();else{let b=this.moduleUniforms[c],w=this.moduleBindings[c],_=d.getUniforms?.(u,b)||u,{uniforms:x,bindings:T}=r1t(_,d.uniformTypes);this.moduleUniforms[c]=o1t(b,x,d.uniformTypes),this.moduleBindings[c]={...w,...T}}}}getModules(){return Object.values(this.modules)}addModules(n){let r=ZL(n);for(let c of r){let u=c.name;this.modules[u]||(this.modules[u]=c,this._addModule(c))}}getUniformValues(){return this.moduleUniforms}getBindingValues(){let n={};for(let r of Object.values(this.moduleBindings))Object.assign(n,r);return Object.assign(n,this.directBindings),n}getModuleBindingValues(n){let r=this.moduleBindings[n];return r?{...r}:{}}getDebugTable(){let n={};for(let[r,c]of Object.entries(this.moduleUniforms))for(let[u,d]of Object.entries(c))n[`${r}.${u}`]={type:this.modules[r].uniformTypes?.[u],value:String(d)};return n}_addModule(n){let r=n.name;this.moduleUniforms[r]=o1t({},n.defaultUniforms||{},n.uniformTypes),this.moduleBindings[r]={}}}});function Uke(s){return s!==null&&typeof s=="object"&&"buffer"in s}function xen(s){return s instanceof up?s.buffer:s}function a1t(s){return{buffer:xen(s.buffer),offset:s.offset,size:s.size}}var yen,up,zke=Ve(()=>{Vr();hB();yen=cs.DEBUG_DATA_MAX_LENGTH,up=class{device;id;ready;usage;props;isReady=!0;destroyed=!1;generation=0;updateTimestamp;debugData=new ArrayBuffer(0);_debugDataEnabled;_maxDebugDataByteLength;_ownsBuffer;_buffer;get buffer(){return this._buffer}get byteLength(){return this._buffer.byteLength}get[Symbol.toStringTag](){return"DynamicBuffer"}toString(){return`DynamicBuffer:"${this.id}":${this.byteLength}B`}toJSON(){return this.toString()}constructor(n,r){let{debugData:c=!1,buffer:u,ownsBuffer:d=!0,...b}=r;if(u&&u.device!==n)throw new Error("DynamicBuffer adopted buffers must belong to the supplied device");if(u&&(b.byteLength!==void 0||b.data!==void 0))throw new Error("DynamicBuffer cannot combine an adopted buffer with byteLength or data");let w=r.id||u?.id||Qy("dynamic-buffer"),_={...b,id:w,usage:b.usage??u?.usage,indexType:b.indexType??u?.indexType};(_.usage||0)&cs.INDEX&&!_.indexType&&(b.data instanceof Uint32Array?_.indexType="uint32":b.data instanceof Uint16Array?_.indexType="uint16":b.data instanceof Uint8Array&&(_.indexType="uint8")),delete _.data,delete _.byteOffset,this.device=n,this.id=w,this.props=_,this.usage=_.usage||0,this._debugDataEnabled=!!c,this._maxDebugDataByteLength=typeof c=="object"&&c.maxByteLength!==void 0?c.maxByteLength:yen,this._ownsBuffer=d,this._buffer=u??this.device.createBuffer({...b,id:w}),this.ready=Promise.resolve(this._buffer),this.updateTimestamp=this._buffer.updateTimestamp,this._resetDebugData(this._buffer.byteLength),b.data&&this._writeDebugData(b.data,b.byteOffset||0)}write(n,r=0){this._buffer.write(n,r),this._touch(),this._writeDebugData(n,r)}async mapAndWriteAsync(n,r=0,c=this.byteLength-r){let u=null;await this._buffer.mapAndWriteAsync(async(d,b)=>{await n(d,b),u=new Uint8Array(d.slice(0,c))},r,c),this._touch(),u&&this._writeDebugData(u,r)}async readAsync(n=0,r=this.byteLength-n){let c=await this._buffer.readAsync(n,r);return this._writeDebugData(c,n)&&this._touch(),c}async mapAndReadAsync(n,r=0,c=this.byteLength-r){let u=null,d=await this._buffer.mapAndReadAsync(async(b,w)=>(u=new Uint8Array(b.slice(0)),await n(b,w)),r,c);return u&&this._writeDebugData(u,r)&&this._touch(),d}resize(n){let{byteLength:r,preserveData:c=!1}=n;if(r===this.byteLength)return!1;let u=Math.min(n.copyByteLength??Math.min(this.byteLength,r),this.byteLength,r),d=this._buffer,b=this.debugData.slice(0),{data:w,byteOffset:_,...x}=this.props,T=this.device.createBuffer({...x,byteLength:r});return c&&u>0&&this._copyBufferContents(d,T,u),this._buffer=T,this._resetDebugData(r),c&&b.byteLength>0&&this._writeDebugData(b,0),this._ownsBuffer&&d.destroy(),this._ownsBuffer=!0,this.generation++,this._touch(),!0}ensureSize(n,r){return n<=this.byteLength?!1:this.resize({byteLength:n,preserveData:r?.preserveData})}getBinding(n){return n?.offset===void 0&&n?.size===void 0?this._buffer:{buffer:this._buffer,offset:n?.offset,size:n?.size}}destroy(){this.destroyed||(this._ownsBuffer&&this._buffer.destroy(),this.destroyed=!0,this.debugData=new ArrayBuffer(0))}_copyBufferContents(n,r,c){let u=this.device.type==="webgpu"?Math.ceil(c/4)*4:c,d=this.device.createCommandEncoder();d.copyBufferToBuffer({sourceBuffer:n,destinationBuffer:r,size:u}),this.device.submit(d.finish())}_touch(){this.updateTimestamp=this.device.incrementTimestamp()}_resetDebugData(n){if(!this._debugDataEnabled){this.debugData=new ArrayBuffer(0);return}this.debugData=new ArrayBuffer(Math.min(n,this._maxDebugDataByteLength))}_writeDebugData(n,r){if(!this._debugDataEnabled||this.debugData.byteLength===0||r>=this.debugData.byteLength)return!1;let c=ArrayBuffer.isView(n)?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n),u=new Uint8Array(this.debugData),d=Math.min(c.byteLength,u.byteLength-r);return u.set(c.subarray(0,d),r),d>0}}});function oV(s){return s!==null&&typeof s=="object"&&"resolveTextureBinding"in s&&typeof s.resolveTextureBinding=="function"}function Een(s){return s?.type==="texture"||s?.type==="external-texture"}function c1t(s,n,r){let c=Lce(s,n,{ignoreWarnings:!0});return Een(c)?c:s.bindings.length===0&&r?.fallbackGroup!==void 0?{type:"texture",name:n,group:r.fallbackGroup,location:0}:null}var l1t=Ve(()=>{Vr()});function jke(s,n){return s.shaderLanguage!==void 0&&s.shaderLanguage!==n?!1:n==="glsl"?"assembleGLSLShaderPair"in s&&typeof s.assembleGLSLShaderPair=="function":"assembleWGSLShader"in s&&typeof s.assembleWGSLShader=="function"}function Ten(s,n){return!s||Object.keys(n).length===0?s:{...s,attributes:s.attributes.map(r=>{let c=r.name.startsWith("_luma_")?r.name.slice(6):null;return c&&n[c]?{...r,name:c}:r})}}function Cen(s,n,r){if(oV(n)){let c=c1t(r,s,{fallbackGroup:0});return c?n.resolveTextureBinding(c):null}return n instanceof up?n.buffer:Uke(n)?a1t(n):n}function Aen(s){return s&&!u1t(s)?s:null}function Pen(s){return s&&u1t(s)?s:void 0}function u1t(s){return Men.includes(s)}function Len(s){return{type:s.type,shaderLanguage:s.info.shadingLanguage,shaderLanguageVersion:s.info.shadingLanguageVersion,gpu:s.info.gpu,limits:s.limits,features:s.features}}var e2,Sen,Gke,Men,Vh,$ke=Ve(()=>{Vr();vm();Wmt();qmt();Kmt();Jmt();Qmt();t1t();Dke();hB();Fke();zke();l1t();e2=2,Sen=1e4,Gke="render pipeline initialization failed",Men=["stencil8","depth16unorm","depth24plus","depth24plus-stencil8","depth32float","depth32float-stencil8"],Vh=class s{static defaultProps={...Tb.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],plugins:[],geometry:null,indexBuffer:null,indexCount:void 0,firstVertex:0,firstIndex:0,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,material:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:Cb.getDefaultShaderAssembler("glsl"),debugShaders:void 0,disableWarnings:void 0};device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexCount;firstVertex;firstIndex;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;material=null;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_dynamicIndexBufferSource=null;_dynamicAttributeBufferSources={};_colorAttachmentFormats;_depthStencilAttachmentFormat;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_drawBlockedReason=!1;_destroyed=!1;_vertexCountSet=!1;_lastDrawTimestamp=-1;_bindingTable=[];get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(n,r){let c=s.defaultProps.shaderAssembler,u=r.vertexCount!==void 0;this.props={...s.defaultProps,...r,shaderAssembler:r.shaderAssembler??(jke(c,n.info.shadingLanguage)?c:Cb.getDefaultShaderAssembler(n.info.shadingLanguage))},this._vertexCountSet=u,r=this.props,this.id=r.id||Qy("model"),this.device=n,Object.assign(this.userData,r.userData),this.material=r.material||null;let d=Len(n),b=P$(this.props.plugins,d.shaderLanguage),w=L$(this.props.modules,b.modules),_=Object.fromEntries(w.map(I=>[I.name,I])),x=r.shaderInputs||new mB(_,{disableWarnings:this.props.disableWarnings});r.shaderInputs&&b.modules.length>0&&x.addModules(b.modules),this.setShaderInputs(x);let T=Tle(this.props.modules,x.getModules()),M={...b.defines,...this.props.defines};if(this.device.type==="webgl"&&(this.props._uniformBlockLayouts=i1t(T)),this.props.shaderLayout=gB(this.props.shaderLayout,T)||null,this.device.type==="webgpu"&&this.props.source){let I=this.props.shaderAssembler;FM(jke(I,"wgsl"));let{source:D,getUniforms:F,bindingTable:O,shaderLayout:z}=I.assembleWGSLShader({platformInfo:d,...this.props,modules:T,defines:M,pluginInjections:b.injections,pluginVertexInputs:b.vertexInputs,pluginVaryings:b.varyings});this.source=D,this._getModuleUniforms=F,this._bindingTable=O;let Z=z??n.getShaderLayout?.(this.source),H=Ten(Z,b.vertexInputs),te=n1t(this.props.shaderLayout,H,Object.keys(b.vertexInputs));this.props.shaderLayout=gB(te||null,T)||null}else{let I=this.props.shaderAssembler;FM(jke(I,"glsl"));let{vs:D,fs:F,getUniforms:O}=I.assembleGLSLShaderPair({platformInfo:d,...this.props,modules:T,defines:M,pluginInjections:b.injections,pluginVertexInputs:b.vertexInputs,pluginVaryings:b.varyings});this.vs=D,this.fs=F,this._getModuleUniforms=O,this._bindingTable=[]}this.vertexCount=this.props.vertexCount,this.indexCount=this.props.indexCount,this.firstVertex=this.props.firstVertex,this.firstIndex=this.props.firstIndex,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,this._colorAttachmentFormats=this.props.colorAttachmentFormats,this._depthStencilAttachmentFormat=this.props.depthStencilAttachmentFormat,r.geometry&&this.setGeometry(r.geometry),this.pipelineFactory=r.pipelineFactory||i4.getDefaultPipelineFactory(this.device),this.shaderFactory=r.shaderFactory||r4.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=n.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in r&&(this.isInstanced=r.isInstanced),r.instanceCount&&this.setInstanceCount(r.instanceCount),r.vertexCount&&this.setVertexCount(r.vertexCount),r.indexBuffer&&this.setIndexBuffer(r.indexBuffer),r.attributes&&this.setAttributes(r.attributes),r.constantAttributes&&this.setConstantAttributes(r.constantAttributes),r.bindings&&this.setBindings(r.bindings),r.transformFeedback&&(this.transformFeedback=r.transformFeedback)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let n=this._needsRedraw;return this._needsRedraw=!1,n}setNeedsRedraw(n){this._needsRedraw||=n}getBindingDebugTable(){return this._bindingTable}predraw(n){this._syncDynamicBuffers(),this.updateShaderInputs(n),this.material?.updateShaderInputs(n),this.pipeline=this._updatePipeline()}draw(n){if(this._drawBlockedReason&&!this._pipelineNeedsUpdate)return Qt.info(e2,`>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)(),!1;let r=this._areBindingsLoading();if(r)return Qt.info(e2,`>>> DRAWING ABORTED ${this.id}: ${r} not loaded`)(),!1;this._syncAttachmentFormats(n);try{n.pushDebugGroup(`${this}.predraw(${n})`),this.device.type==="webgpu"?(this.updateShaderInputs(),this.material?.updateShaderInputs(),this._syncDynamicBuffers(),this.pipeline=this._updatePipeline()):this.predraw(this.device.commandEncoder)}finally{n.popDebugGroup()}let c,u=this.pipeline.isErrored;try{if(n.pushDebugGroup(`${this}.draw(${n})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline(),u=this.pipeline.isErrored,u)Qt.info(e2,`>>> DRAWING ABORTED ${this.id}: ${Gke}`)(),c=!1;else{let d=this.vertexArray.getDrawValidationError();if(d)Qt.info(e2,`>>> DRAWING ABORTED ${this.id}: ${d}`)(),this._drawBlockedReason=d,c=!1;else{let b=this._getCurrentShaderLayout(),w=this._getBindings(b),_=this._getBindGroups(b,w),{indexBuffer:x}=this.vertexArray,T=x?this.indexCount??(this._vertexCountSet?this.vertexCount:x.byteLength/(x.indexType==="uint32"?4:2)):void 0;n.setPipeline(this.pipeline),n.setBindings(_,{_bindGroupCacheKeys:this._getBindGroupCacheKeys()}),n.setVertexArray(this.vertexArray),c=this.isInstanced===!0&&this.instanceCount===0?!0:n.draw({isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.isInstanced?this.instanceCount:void 0,indexCount:T,firstVertex:this.firstVertex,firstIndex:this.firstIndex,transformFeedback:this.transformFeedback||void 0,uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}}}finally{n.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(n),c?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):u?(this._needsRedraw=Gke,this._drawBlockedReason=Gke):this._drawBlockedReason?this._needsRedraw=this._drawBlockedReason:this._needsRedraw="waiting for resource initialization",c}setGeometry(n){this._gpuGeometry?.destroy();let r=n&&Vmt(this.device,n);if(r){this.setTopology(r.topology||"triangle-list");let c=new pB(this.bufferLayout);this.bufferLayout=c.mergeBufferLayouts(r.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(r)}this._gpuGeometry=r}setTopology(n){n!==this.topology&&(this.topology=n,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(n){let r=new pB(this.bufferLayout),c=this._gpuGeometry?r.mergeBufferLayouts(n,this._gpuGeometry.bufferLayout):n;dB(c,this.bufferLayout,-1)||(this.bufferLayout=c,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry))}setParameters(n){dB(n,this.parameters,2)||(this.parameters=n,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(n){this.instanceCount=n,this.isInstanced===void 0&&n>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(n){this.vertexCount=n,this._vertexCountSet=!0,this.setNeedsRedraw("vertexCount")}setIndexCount(n){this.indexCount=n,this.setNeedsRedraw("indexCount")}setDrawOffsets({firstVertex:n,firstIndex:r}){this.firstVertex=n,this.firstIndex=r,this.setNeedsRedraw("drawOffsets")}setShaderInputs(n){this.shaderInputs=n,this._uniformStore=new a4(this.device,this.shaderInputs.modules);for(let[r,c]of Object.entries(this.shaderInputs.modules))if(rV(c)&&!this.material?.ownsModule(r)){let u=this._uniformStore.getManagedUniformBuffer(r);this.bindings[`${r}Uniforms`]=u}this.setNeedsRedraw("shaderInputs")}setMaterial(n){this.material=n,this.setNeedsRedraw("material")}updateShaderInputs(n){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),n),this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues())),this.setNeedsRedraw("shaderInputs")}setBindings(n){Object.assign(this.bindings,n),this.setNeedsRedraw("bindings")}setTransformFeedback(n){this.transformFeedback=n,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(n){let r=n instanceof up?n.buffer:n;this.indexBuffer=r,this._dynamicIndexBufferSource=n instanceof up?{source:n,generation:n.generation}:null,this.vertexArray.setIndexBuffer(r),this.setNeedsRedraw("indexBuffer")}setAttributes(n,r){this._drawBlockedReason=!1;let c=r?.disableWarnings??this.props.disableWarnings;n.indices&&Qt.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=e1t(this.pipeline.shaderLayout,this.bufferLayout);let u=new pB(this.bufferLayout);for(let[d,b]of Object.entries(n)){let w=b instanceof up?b.buffer:b,_=u.getBufferLayout(d);if(!_){c||Qt.warn(`Model(${this.id}): Missing layout for buffer "${d}".`)();continue}let x=u.getAttributeNamesForBuffer(_),T=!1;for(let M of x){let L=this._attributeInfos[M];if(L){let I=this.device.type==="webgpu"?this.vertexArray.getBufferSlot(L.bufferName):L.location;if(I===null){c||Qt.warn(`Model(${this.id}): Missing vertex array slot for buffer "${L.bufferName}".`)();continue}this.vertexArray.setBuffer(I,w),b instanceof up?this._dynamicAttributeBufferSources[I]={source:b,generation:b.generation}:delete this._dynamicAttributeBufferSources[I],T=!0}}!T&&!c&&Qt.warn(`Model(${this.id}): Ignoring buffer "${w.id}" for unknown attribute "${d}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(n,r){for(let[c,u]of Object.entries(n)){let d=this._attributeInfos[c];d?this.vertexArray.setConstantWebGL(d.location,u):(r?.disableWarnings??this.props.disableWarnings)||Qt.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${c}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(let n of Object.values(this.bindings))if(oV(n)&&!n.isReady)return n.id;for(let n of Object.values(this.material?.bindings||{}))if(oV(n)&&!n.isReady)return n.id;return!1}_getBindings(n=this._getCurrentShaderLayout()){let r={};for(let[c,u]of Object.entries(this.bindings)){let d=Cen(c,u,n);d&&(r[c]=d)}return r}_getBindGroups(n=this._getCurrentShaderLayout(),r=this._getBindings(n)){let c=n.bindings.length?s4(n,r):{0:r};if(!this.material)return c;for(let[u,d]of Object.entries(this.material.getBindingsByGroup(n))){let b=Number(u);c[b]={...c[b]||{},...d}}return c}_getBindGroupCacheKeys(){let n=this.material?.getBindGroupCacheKey(3);return n?{3:n}:{}}_getBindingsUpdateTimestamp(){let n=0;this._dynamicIndexBufferSource&&(n=Math.max(n,this._dynamicIndexBufferSource.source.updateTimestamp));for(let r of Object.values(this._dynamicAttributeBufferSources))n=Math.max(n,r.source.updateTimestamp);for(let r of Object.values(this.bindings))r instanceof e4?n=Math.max(n,r.texture.updateTimestamp):r instanceof cs||r instanceof Pa||r instanceof b$||r instanceof up?n=Math.max(n,r.updateTimestamp):oV(r)?n=r.isReady?Math.max(n,r.updateTimestamp):1/0:Uke(r)&&(n=Math.max(n,(r.buffer instanceof up,r.buffer.updateTimestamp)));return Math.max(n,this.material?.getBindingsUpdateTimestamp()||0)}_setGeometryAttributes(n){let r={...n.attributes};for(let[c]of Object.entries(r))!this.pipeline.shaderLayout.attributes.find(u=>u.name===c)&&c!=="positions"&&delete r[c];this.vertexCount=n.vertexCount,this._vertexCountSet=!0,this.setIndexBuffer(n.indices||null),this.setAttributes(n.attributes,{disableWarnings:!0}),this.setAttributes(r,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(n){this._pipelineNeedsUpdate||=n,this._drawBlockedReason=!1,this.setNeedsRedraw(n)}_updatePipeline(){if(this._pipelineNeedsUpdate){let n=null,r=null;this.pipeline&&(Qt.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),n=this.pipeline.vs,r=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let c=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders}),u=null;this.source?u=c:this.fs&&(u=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bindings:void 0,bufferLayout:this.bufferLayout,colorAttachmentFormats:this._colorAttachmentFormats,depthStencilAttachmentFormat:this._depthStencilAttachmentFormat,topology:this.topology,parameters:this.parameters,bindGroups:void 0,vs:c,fs:u}),this._attributeInfos=A$(this.pipeline.shaderLayout,this.bufferLayout),n&&this.shaderFactory.release(n),r&&r!==n&&this.shaderFactory.release(r)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let n=Qt.level>3?0:Sen;Qt.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:Qt.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let n=Hmt(this.pipeline.shaderLayout,this.id);Qt.table(e2,n)();let r=this.shaderInputs.getDebugTable();Qt.table(e2,r)();let c=this._getAttributeDebugTable();Qt.table(e2,this._attributeInfos)(),Qt.table(e2,c)(),Qt.groupEnd(e2)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(n){let r=this.device.props.debugFramebuffers;if(this._drawCount++,!r)return;let c=n.props.framebuffer;Zmt(n,c,{id:c?.id||`${this.id}-framebuffer`,minimap:!0})}_getAttributeDebugTable(){let n={};for(let[r,c]of Object.entries(this._attributeInfos)){let u=this.vertexArray.attributes[c.location];n[c.location]={name:r,type:c.shaderType,values:u?this._getBufferOrConstantValues(u,c.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:r}=this.vertexArray,c=r.indexType==="uint32"?new Uint32Array(r.debugData):new Uint16Array(r.debugData);n.indices={name:"indices",type:r.indexType,values:c.toString()}}return n}_getBufferOrConstantValues(n,r){let c=Md.getTypedArrayConstructor(r);return(n instanceof cs?new c(n.debugData):n).toString()}_getNonMaterialBindings(n){if(!this.material)return n;let r={};for(let[c,u]of Object.entries(n))this.material.ownsBinding(c)||(r[c]=u);return r}_getCurrentShaderLayout(){return this.pipeline?.shaderLayout||this.props.shaderLayout||{bindings:[]}}_syncDynamicBuffers(){if(this._dynamicIndexBufferSource&&this._dynamicIndexBufferSource.generation!==this._dynamicIndexBufferSource.source.generation){let n=this._dynamicIndexBufferSource.source.buffer;this.indexBuffer=n,this.vertexArray.setIndexBuffer(n),this._dynamicIndexBufferSource.generation=this._dynamicIndexBufferSource.source.generation,this.setNeedsRedraw("dynamic index buffer")}for(let[n,r]of Object.entries(this._dynamicAttributeBufferSources))r.generation!==r.source.generation&&(this.vertexArray.setBuffer(Number(n),r.source.buffer),r.generation=r.source.generation,this.setNeedsRedraw("dynamic attribute buffer"))}_syncAttachmentFormats(n){if(this.device.type!=="webgpu")return;let r=n.framebuffer||n.props.framebuffer,c=n.props,u=c.colorAttachmentFormats??r?.colorAttachments?.map(b=>Aen(b?.texture?.format)),d=c.depthStencilAttachmentFormat===!1?void 0:c.depthStencilAttachmentFormat??Pen(r?.depthStencilAttachment?.texture?.format);(!dB(this._colorAttachmentFormats,u,1)||this._depthStencilAttachmentFormat!==d)&&(this._colorAttachmentFormats=u,this._depthStencilAttachmentFormat=d,this._setPipelineNeedsUpdate("attachment formats"))}}});var ken,Ren,fp,f1t=Ve(()=>{Vr();vm();$ke();ken=35980,Ren=35981,fp=class s{device;model;transformFeedback;static defaultProps={...Vh.defaultProps,feedbackBufferMode:"separate",outputs:void 0,feedbackBuffers:void 0};static isSupported(n){return n?.info?.type==="webgl"}constructor(n,r=s.defaultProps){if(!s.isSupported(n))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=n,this.model=new Vh(this.device,{id:r.id||"buffer-transform-model",fs:r.fs||v4e(),topology:r.topology||"point-list",varyings:r.outputs||r.varyings,...r,bufferMode:r.bufferMode||(r.feedbackBufferMode==="interleaved"?ken:Ren)}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:r.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(n){n?.inputBuffers&&this.model.setAttributes(n.inputBuffers),n?.outputBuffers&&this.transformFeedback.setBuffers(n.outputBuffers);let r=this.device.beginRenderPass({discard:!0,...n});this.model.draw(r),r.end()}getBuffer(n){return this.transformFeedback.getBuffer(n)}readAsync(n){let r=this.getBuffer(n);if(!r)throw new Error("BufferTransform#getBuffer");if(r instanceof cs)return r.readAsync();let{buffer:c,byteOffset:u=0,byteLength:d=c.byteLength}=r;return c.readAsync(u,d)}}});function Den(s){return{type:s.type,shaderLanguage:s.info.shadingLanguage,shaderLanguageVersion:s.info.shadingLanguageVersion,gpu:s.info.gpu,limits:s.limits,features:s.features}}var Vke,Ien,G1,h1t=Ve(()=>{Vr();vm();sLe();Fke();Dke();hB();Vke=2,Ien=1e4,G1=class s{static defaultProps={...GM.defaultProps,id:"unnamed",handle:void 0,userData:{},source:"",modules:[],defines:{},plugins:[],bindings:void 0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,shaderAssembler:Cb.getDefaultShaderAssembler("wgsl"),debugShaders:void 0};device;id;pipelineFactory;shaderFactory;userData={};bindings={};pipeline;source;shader;shaderInputs;_uniformStore;_pipelineNeedsUpdate="newly created";_getModuleUniforms;props;_destroyed=!1;constructor(n,r){if(n.type!=="webgpu")throw new Error("Computation is only supported in WebGPU");this.props={...s.defaultProps,...r},r=this.props,this.id=r.id||Qy("model"),this.device=n,Object.assign(this.userData,r.userData);let c=Den(n),u=P$(this.props.plugins,c.shaderLanguage);if(Object.keys(u.vertexInputs).length>0||Object.keys(u.varyings).length>0)throw new Error("Computation does not support ShaderPlugin vertex inputs or varyings");let d=L$(this.props.modules,u.modules),b=Object.fromEntries(d.map(D=>[D.name,D]));this.shaderInputs=r.shaderInputs||new mB(b),r.shaderInputs&&u.modules.length>0&&this.shaderInputs.addModules(u.modules),this.setShaderInputs(this.shaderInputs);let w=Tle(this.props.modules,this.shaderInputs?.getModules()),_={...u.defines,...this.props.defines};this.props.shaderLayout=gB(this.props.shaderLayout,w)||null,this.pipelineFactory=r.pipelineFactory||i4.getDefaultPipelineFactory(this.device),this.shaderFactory=r.shaderFactory||r4.getDefaultShaderFactory(this.device);let x=this.props.shaderAssembler;FM(x instanceof $M);let{source:T,getUniforms:M,shaderLayout:L}=x.assembleWGSLShader({platformInfo:c,...this.props,modules:w,defines:_,scanVertexAttributes:!1,pluginInjections:u.injections});this.source=T,this._getModuleUniforms=M;let I=L??n.getShaderLayout?.(this.source,{scanVertexAttributes:!1});this.props.shaderLayout=gB(this.props.shaderLayout||I||null,w)||null,this.pipeline=this._updatePipeline(),r.bindings&&this.setBindings(r.bindings)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.shader),this._uniformStore.destroy(),this._destroyed=!0)}predraw(n){this.updateShaderInputs(n)}dispatch(n,r,c,u){try{this._logDrawCallStart(),this._setPipeline(n),n.dispatch(r,c,u)}finally{this._logDrawCallEnd()}}dispatchIndirect(n,r,c=0){try{this._logDrawCallStart(),this._setPipeline(n),n.dispatchIndirect(r,c)}finally{this._logDrawCallEnd()}}_setPipeline(n){this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings),n.setPipeline(this.pipeline),n.setBindings({})}setVertexCount(n){}setInstanceCount(n){}setShaderInputs(n){this.shaderInputs=n,this._uniformStore=new a4(this.device,this.shaderInputs.modules);for(let[r,c]of Object.entries(this.shaderInputs.modules))if(rV(c)){let u=this._uniformStore.getManagedUniformBuffer(r);this.bindings[`${r}Uniforms`]=u}}setShaderModuleProps(n){let r=this._getModuleUniforms(n),c=Object.keys(r).filter(d=>{let b=r[d];return!r$(b)&&typeof b!="number"&&typeof b!="boolean"}),u={};for(let d of c)u[d]=r[d],delete r[d]}updateShaderInputs(n){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),n)}setBindings(n){Object.assign(this.bindings,n)}_setPipelineNeedsUpdate(n){this._pipelineNeedsUpdate=this._pipelineNeedsUpdate||n}_updatePipeline(){if(this._pipelineNeedsUpdate){let n=null;this.pipeline&&(Qt.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),n=this.shader),this._pipelineNeedsUpdate=!1,this.shader=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"compute",source:this.source,debugShaders:this.props.debugShaders}),this.pipeline=this.pipelineFactory.createComputePipeline({...this.props,shader:this.shader}),n&&this.shaderFactory.release(n)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let n=Qt.level>3?0:Ien;Qt.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:Qt.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let n=this.shaderInputs.getDebugTable();Qt.table(Vke,n)(),Qt.groupEnd(Vke)(),this._logOpen=!1}}_drawCount=0;_getBufferOrConstantValues(n,r){let c=Md.getTypedArrayConstructor(r);return(n instanceof cs?new c(n.debugData):n).toString()}}});var Ql=Ve(()=>{Fmt();$mt();$ke();f1t();Sle();zke();h1t()});function C1t(s=!0){let n=HTMLCanvasElement.prototype;if(!s&&n.originalGetContext){n.getContext=n.originalGetContext,n.originalGetContext=void 0;return}n.originalGetContext=n.getContext,n.getContext=function(r,c){if(r==="webgl"||r==="experimental-webgl"){let u=this.originalGetContext("webgl2",c);return u instanceof HTMLElement&&ftn(u),u}return this.originalGetContext(r,c)}}function ftn(s){s.getExtension("EXT_color_buffer_float");let n={...atn,WEBGL_disjoint_timer_query:s.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:ctn(s),OES_vertex_array_object:ltn(s),ANGLE_instanced_arrays:utn(s)},r=s.getExtension.bind(s);s.getExtension=function(u){let d=r(u);return d||(u in n?n[u]:null)};let c=s.getSupportedExtensions;s.getSupportedExtensions=function(){return(c.apply(s)||[])?.concat(Object.keys(n))}}var atn,ctn,ltn,utn,A1t=Ve(()=>{atn={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},ctn=s=>({drawBuffersWEBGL(n){return s.drawBuffers(n)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),ltn=s=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return s.createVertexArray()},deleteVertexArrayOES(n){return s.deleteVertexArray(n)},isVertexArrayOES(n){return s.isVertexArray(n)},bindVertexArrayOES(n){return s.bindVertexArray(n)}}),utn=s=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...n){return s.drawArraysInstanced(...n)},drawElementsInstancedANGLE(...n){return s.drawElementsInstanced(...n)},vertexAttribDivisorANGLE(...n){return s.vertexAttribDivisor(...n)}})});async function L1t(){if(!Dle){tRe();return}await Dle.load()}function k1t(s,n){return Dle?Dle.makeDebugContext(s,n):(tRe(),s)}async function R1t(s){if(!eRe){tRe();return}await eRe.load(s)}function I1t(s){return eRe?.initialize(s)||null}function tRe(){P1t||(P1t=!0,Qt.warn("Import @luma.gl/webgl/debug before enabling WebGL debugging.")())}var Dle,eRe,P1t,nRe=Ve(()=>{Vr();Dle=null,eRe=null,P1t=!1});function iRe(s){return Array.isArray(s)||ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Iu(s,n,r){return n[s]!==void 0?n[s]:r[s]}var xV,Nf,D1t,j1,B1t,yV,O1t,N1t,rRe,r2,sRe,F1t,oRe=Ve(()=>{xV={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},Nf=(s,n,r)=>n?s.enable(r):s.disable(r),D1t=(s,n,r)=>s.hint(r,n),j1=(s,n,r)=>s.pixelStorei(r,n),B1t=(s,n,r)=>{let c=r===36006?36009:36008;return s.bindFramebuffer(c,n)},yV=(s,n,r)=>{let u={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[r];s.bindBuffer(u,n)};O1t={3042:Nf,32773:(s,n)=>s.blendColor(...n),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(s,n)=>s.clearColor(...n),3107:(s,n)=>s.colorMask(...n),2884:Nf,2885:(s,n)=>s.cullFace(n),2929:Nf,2931:(s,n)=>s.clearDepth(n),2932:(s,n)=>s.depthFunc(n),2928:(s,n)=>s.depthRange(...n),2930:(s,n)=>s.depthMask(n),3024:Nf,35723:D1t,35725:(s,n)=>s.useProgram(n),36007:(s,n)=>s.bindRenderbuffer(36161,n),36389:(s,n)=>s.bindTransformFeedback?.(36386,n),34229:(s,n)=>s.bindVertexArray(n),36006:B1t,36010:B1t,34964:yV,36662:yV,36663:yV,35053:yV,35055:yV,2886:(s,n)=>s.frontFace(n),33170:D1t,2849:(s,n)=>s.lineWidth(n),32823:Nf,32824:"polygonOffset",10752:"polygonOffset",35977:Nf,32926:Nf,32928:Nf,32938:"sampleCoverage",32939:"sampleCoverage",3089:Nf,3088:(s,n)=>s.scissor(...n),2960:Nf,2961:(s,n)=>s.clearStencil(n),2968:(s,n)=>s.stencilMaskSeparate(1028,n),36005:(s,n)=>s.stencilMaskSeparate(1029,n),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(s,n)=>s.viewport(...n),34383:Nf,10754:Nf,12288:Nf,12289:Nf,12290:Nf,12291:Nf,12292:Nf,12293:Nf,12294:Nf,12295:Nf,3333:j1,3317:j1,37440:j1,37441:j1,37443:j1,3330:j1,3332:j1,3331:j1,3314:j1,32878:j1,3316:j1,3315:j1,32877:j1,framebuffer:(s,n)=>{let r=n&&"handle"in n?n.handle:n;return s.bindFramebuffer(36160,r)},blend:(s,n)=>n?s.enable(3042):s.disable(3042),blendColor:(s,n)=>s.blendColor(...n),blendEquation:(s,n)=>{let r=typeof n=="number"?[n,n]:n;s.blendEquationSeparate(...r)},blendFunc:(s,n)=>{let r=n?.length===2?[...n,...n]:n;s.blendFuncSeparate(...r)},clearColor:(s,n)=>s.clearColor(...n),clearDepth:(s,n)=>s.clearDepth(n),clearStencil:(s,n)=>s.clearStencil(n),colorMask:(s,n)=>s.colorMask(...n),cull:(s,n)=>n?s.enable(2884):s.disable(2884),cullFace:(s,n)=>s.cullFace(n),depthTest:(s,n)=>n?s.enable(2929):s.disable(2929),depthFunc:(s,n)=>s.depthFunc(n),depthMask:(s,n)=>s.depthMask(n),depthRange:(s,n)=>s.depthRange(...n),dither:(s,n)=>n?s.enable(3024):s.disable(3024),derivativeHint:(s,n)=>{s.hint(35723,n)},frontFace:(s,n)=>s.frontFace(n),mipmapHint:(s,n)=>s.hint(33170,n),lineWidth:(s,n)=>s.lineWidth(n),polygonOffsetFill:(s,n)=>n?s.enable(32823):s.disable(32823),polygonOffset:(s,n)=>s.polygonOffset(...n),sampleCoverage:(s,n)=>s.sampleCoverage(n[0],n[1]||!1),scissorTest:(s,n)=>n?s.enable(3089):s.disable(3089),scissor:(s,n)=>s.scissor(...n),stencilTest:(s,n)=>n?s.enable(2960):s.disable(2960),stencilMask:(s,n)=>{n=iRe(n)?n:[n,n];let[r,c]=n;s.stencilMaskSeparate(1028,r),s.stencilMaskSeparate(1029,c)},stencilFunc:(s,n)=>{n=iRe(n)&&n.length===3?[...n,...n]:n;let[r,c,u,d,b,w]=n;s.stencilFuncSeparate(1028,r,c,u),s.stencilFuncSeparate(1029,d,b,w)},stencilOp:(s,n)=>{n=iRe(n)&&n.length===3?[...n,...n]:n;let[r,c,u,d,b,w]=n;s.stencilOpSeparate(1028,r,c,u),s.stencilOpSeparate(1029,d,b,w)},viewport:(s,n)=>s.viewport(...n)};N1t={blendEquation:(s,n,r)=>s.blendEquationSeparate(Iu(32777,n,r),Iu(34877,n,r)),blendFunc:(s,n,r)=>s.blendFuncSeparate(Iu(32969,n,r),Iu(32968,n,r),Iu(32971,n,r),Iu(32970,n,r)),polygonOffset:(s,n,r)=>s.polygonOffset(Iu(32824,n,r),Iu(10752,n,r)),sampleCoverage:(s,n,r)=>s.sampleCoverage(Iu(32938,n,r),Iu(32939,n,r)),stencilFuncFront:(s,n,r)=>s.stencilFuncSeparate(1028,Iu(2962,n,r),Iu(2967,n,r),Iu(2963,n,r)),stencilFuncBack:(s,n,r)=>s.stencilFuncSeparate(1029,Iu(34816,n,r),Iu(36003,n,r),Iu(36004,n,r)),stencilOpFront:(s,n,r)=>s.stencilOpSeparate(1028,Iu(2964,n,r),Iu(2965,n,r),Iu(2966,n,r)),stencilOpBack:(s,n,r)=>s.stencilOpSeparate(1029,Iu(34817,n,r),Iu(34818,n,r),Iu(34819,n,r))},rRe={enable:(s,n)=>s({[n]:!0}),disable:(s,n)=>s({[n]:!1}),pixelStorei:(s,n,r)=>s({[n]:r}),hint:(s,n,r)=>s({[n]:r}),useProgram:(s,n)=>s({35725:n}),bindRenderbuffer:(s,n,r)=>s({36007:r}),bindTransformFeedback:(s,n,r)=>s({36389:r}),bindVertexArray:(s,n)=>s({34229:n}),bindFramebuffer:(s,n,r)=>{switch(n){case 36160:return s({36006:r,36010:r});case 36009:return s({36006:r});case 36008:return s({36010:r});default:return null}},bindBuffer:(s,n,r)=>{let c={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[n];return c?s({[c]:r}):{valueChanged:!0}},blendColor:(s,n,r,c,u)=>s({32773:new Float32Array([n,r,c,u])}),blendEquation:(s,n)=>s({32777:n,34877:n}),blendEquationSeparate:(s,n,r)=>s({32777:n,34877:r}),blendFunc:(s,n,r)=>s({32969:n,32968:r,32971:n,32970:r}),blendFuncSeparate:(s,n,r,c,u)=>s({32969:n,32968:r,32971:c,32970:u}),clearColor:(s,n,r,c,u)=>s({3106:new Float32Array([n,r,c,u])}),clearDepth:(s,n)=>s({2931:n}),clearStencil:(s,n)=>s({2961:n}),colorMask:(s,n,r,c,u)=>s({3107:[n,r,c,u]}),cullFace:(s,n)=>s({2885:n}),depthFunc:(s,n)=>s({2932:n}),depthRange:(s,n,r)=>s({2928:new Float32Array([n,r])}),depthMask:(s,n)=>s({2930:n}),frontFace:(s,n)=>s({2886:n}),lineWidth:(s,n)=>s({2849:n}),polygonOffset:(s,n,r)=>s({32824:n,10752:r}),sampleCoverage:(s,n,r)=>s({32938:n,32939:r}),scissor:(s,n,r,c,u)=>s({3088:new Int32Array([n,r,c,u])}),stencilMask:(s,n)=>s({2968:n,36005:n}),stencilMaskSeparate:(s,n,r)=>s({[n===1028?2968:36005]:r}),stencilFunc:(s,n,r,c)=>s({2962:n,2967:r,2963:c,34816:n,36003:r,36004:c}),stencilFuncSeparate:(s,n,r,c,u)=>s({[n===1028?2962:34816]:r,[n===1028?2967:36003]:c,[n===1028?2963:36004]:u}),stencilOp:(s,n,r,c)=>s({2964:n,2965:r,2966:c,34817:n,34818:r,34819:c}),stencilOpSeparate:(s,n,r,c,u)=>s({[n===1028?2964:34817]:r,[n===1028?2965:34818]:c,[n===1028?2966:34819]:u}),viewport:(s,n,r,c,u)=>s({2978:[n,r,c,u]})},r2=(s,n)=>s.isEnabled(n),sRe={3042:r2,2884:r2,2929:r2,3024:r2,32823:r2,32926:r2,32928:r2,3089:r2,2960:r2,35977:r2},F1t=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068])});function bv(s,n){if(htn(n))return;let r={};for(let u in n){let d=Number(u),b=O1t[u];b&&(typeof b=="string"?r[b]=!0:b(s,n[u],d))}let c=s.lumaState?.cache;if(c)for(let u in r){let d=N1t[u];d(s,n,c)}}function Ble(s,n=xV){if(typeof n=="number"){let u=n,d=sRe[u];return d?d(s,u):s.getParameter(u)}let r=Array.isArray(n)?n:Object.keys(n),c={};for(let u of r){let d=sRe[u];c[u]=d?d(s,Number(u)):s.getParameter(Number(u))}return c}function U1t(s){bv(s,xV)}function htn(s){for(let n in s)return!1;return!0}var _B=Ve(()=>{oRe()});function G1t(s,n){if(s===n)return!0;if(z1t(s)&&z1t(n)&&s.length===n.length){for(let r=0;r{});function $1t(s,n){let r=s[n].bind(s);s[n]=function(u){if(u===void 0||F1t.has(u))return r(u);let d=wv.get(s);return u in d.cache||(d.cache[u]=r(u)),d.enable?d.cache[u]:r(u)},Object.defineProperty(s[n],"name",{value:`${n}-from-cache`,configurable:!1})}function dtn(s,n,r){if(!s[n])return;let c=s[n].bind(s);s[n]=function(...d){let b=wv.get(s),{valueChanged:w,oldValue:_}=r(b._updateCache,...d);return w&&c(...d),_},Object.defineProperty(s[n],"name",{value:`${n}-to-cache`,configurable:!1})}function ptn(s){let n=s.useProgram.bind(s);s.useProgram=function(c){let u=wv.get(s);u.program!==c&&(n(c),u.program=c)}}var wv,aRe=Ve(()=>{_B();j1t();oRe();wv=class{static get(n){return n.lumaState}gl;program=null;stateStack=[];enable=!0;cache=null;log;initialized=!1;constructor(n,r){this.gl=n,this.log=r?.log||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(n={}){this.stateStack.push({})}pop(){let n=this.stateStack[this.stateStack.length-1];bv(this.gl,n),this.stateStack.pop()}trackState(n,r){if(this.cache=r?.copyState?Ble(n):Object.assign({},xV),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.lumaState=this,ptn(n);for(let c in rRe){let u=rRe[c];dtn(n,c,u)}$1t(n,"getParameter"),$1t(n,"isEnabled")}_updateCache(n){let r=!1,c,u=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let d in n){let b=n[d],w=this.cache[d];G1t(b,w)||(r=!0,c=w,u&&!(d in u)&&(u[d]=w),this.cache[d]=b)}return{valueChanged:r,oldValue:c}}}});function EV(s){let n=s.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return n._polyfilled??=!1,n.extensions||={},s.luma=n,n}var cRe=Ve(()=>{});function V1t(s,n,r){let c="",u=_=>{let x=_.statusMessage;x&&(c||=x)};s.addEventListener("webglcontextcreationerror",u,!1);let d=r.failIfMajorPerformanceCaveat!==!0,b={preserveDrawingBuffer:!0,...r,failIfMajorPerformanceCaveat:!0},w=null;try{w||=s.getContext("webgl2",b),!w&&b.failIfMajorPerformanceCaveat&&(c||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.");let _=!1;if(!w&&d&&(b.failIfMajorPerformanceCaveat=!1,w=s.getContext("webgl2",b),_=!0),w||(w=s.getContext("webgl",{}),w&&(w=null,c||="Your browser only supports WebGL1")),!w)throw c||="Your browser does not support WebGL",new Error(`Failed to create WebGL context: ${c}`);let x=EV(w);x.softwareRenderer=_;let{onContextLost:T,onContextRestored:M}=n;return s.addEventListener("webglcontextlost",L=>T(L),!1),s.addEventListener("webglcontextrestored",L=>M(L),!1),w}finally{s.removeEventListener("webglcontextcreationerror",u,!1)}}var W1t=Ve(()=>{cRe()});function vv(s,n,r){return r[n]===void 0&&(r[n]=s.getExtension(n)||null),r[n]}var SV=Ve(()=>{});function H1t(s,n){let r=s.getParameter(7936),c=s.getParameter(7937);vv(s,"WEBGL_debug_renderer_info",n);let u=n.WEBGL_debug_renderer_info,d=s.getParameter(u?u.UNMASKED_VENDOR_WEBGL:7936),b=s.getParameter(u?u.UNMASKED_RENDERER_WEBGL:7937),w=d||r,_=b||c,x=s.getParameter(7938),T=q1t(w,_),M=gtn(w,_),L=mtn(w,_);return{type:"webgl",gpu:T,gpuType:L,gpuBackend:M,vendor:w,renderer:_,version:x,shadingLanguage:"glsl",shadingLanguageVersion:300}}function q1t(s,n){return/NVIDIA/i.exec(s)||/NVIDIA/i.exec(n)?"nvidia":/INTEL/i.exec(s)||/INTEL/i.exec(n)?"intel":/Apple/i.exec(s)||/Apple/i.exec(n)?"apple":/AMD/i.exec(s)||/AMD/i.exec(n)||/ATI/i.exec(s)||/ATI/i.exec(n)?"amd":/SwiftShader/i.exec(s)||/SwiftShader/i.exec(n)?"software":"unknown"}function gtn(s,n){return/Metal/i.exec(s)||/Metal/i.exec(n)?"metal":/ANGLE/i.exec(s)||/ANGLE/i.exec(n)?"opengl":"unknown"}function mtn(s,n){if(/SwiftShader/i.exec(s)||/SwiftShader/i.exec(n))return"cpu";switch(q1t(s,n)){case"apple":return btn(s,n)?"integrated":"unknown";case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function btn(s,n){return/Apple (M\d|A\d|GPU)/i.test(`${s} ${n}`)}var X1t=Ve(()=>{SV()});function Ole(s){switch(s){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(s))}var lRe=Ve(()=>{});function K1t(s){return s in Fle}function pRe(s,n,r){return J1t(s,n,r,new Set)}function J1t(s,n,r,c){let u=Fle[n];if(!u||c.has(n))return!1;c.add(n);let d=(u.features||[]).every(b=>J1t(s,b,r,c));return c.delete(n),d?(u.extensions||[]).every(b=>!!vv(s,b,r)):!1}function Q1t(s,n,r){let c=n.create,u=Ule[n.format];u?.gl===void 0&&(c=!1),u?.x&&(c=c&&!!vv(s,u.x,r)),n.format==="stencil8"&&(c=!1);let d=u?.r===!1?!1:u?.r===void 0||pRe(s,u.r,r),b=c&&n.render&&d&&Mtn(s,n.format,r);return{format:n.format,create:c&&n.create,render:b,filter:c&&n.filter,blend:c&&n.blend,store:c&&n.store}}function Mtn(s,n,r){let c=Ule[n],u=c?.gl;if(u===void 0||c?.x&&!vv(s,c.x,r))return!1;let d=s.getParameter(32873),b=s.getParameter(36006),w=s.createTexture(),_=s.createFramebuffer();if(!w||!_)return!1;let x=0,T=Number(s.getError());for(;T!==x;)T=s.getError();let M=!1;try{if(s.bindTexture(3553,w),s.texStorage2D(3553,1,u,1,1),Number(s.getError())!==x)return!1;s.bindFramebuffer(36160,_),s.framebufferTexture2D(36160,36064,3553,w,0),M=Number(s.checkFramebufferStatus(36160))===36053&&Number(s.getError())===x}finally{s.bindFramebuffer(36160,b),s.deleteFramebuffer(_),s.bindTexture(3553,d),s.deleteTexture(w)}return M}function zle(s){let n=Ule[s],r=Ctn(s),c=og.getInfo(s);return c.compressed&&(n.dataFormat=r),{internalFormat:r,format:n?.dataFormat||Ttn(c.channels,c.integer,c.normalized,r),type:c.dataType?Ole(c.dataType):n?.types?.[0]||5121,compressed:c.compressed||!1}}function e0t(s){switch(og.getInfo(s).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${s}`)}}function Ttn(s,n,r,c){if(c===6408||c===6407)return c;switch(s){case"r":return n&&!r?36244:6403;case"rg":return n&&!r?33320:33319;case"rgb":return n&&!r?36248:6407;case"rgba":return n&&!r?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function Ctn(s){let r=Ule[s]?.gl;if(r===void 0)throw new Error(`Unsupported texture format ${s}`);return r}var MV,TV,yB,xB,wtn,vtn,_tn,ytn,xtn,Etn,Y1t,Z1t,uRe,fRe,hRe,dRe,Nle,Stn,Fle,Ule,EB=Ve(()=>{Vr();SV();lRe();MV="WEBGL_compressed_texture_s3tc",TV="WEBGL_compressed_texture_s3tc_srgb",yB="EXT_texture_compression_rgtc",xB="EXT_texture_compression_bptc",wtn="WEBGL_compressed_texture_etc",vtn="WEBGL_compressed_texture_astc",_tn="WEBGL_compressed_texture_etc1",ytn="WEBGL_compressed_texture_pvrtc",xtn="WEBGL_compressed_texture_atc",Etn="EXT_texture_norm16",Y1t="EXT_render_snorm",Z1t="EXT_color_buffer_float",uRe="snorm8-renderable-webgl",fRe="norm16-renderable-webgl",hRe="snorm16-renderable-webgl",dRe="float16-renderable-webgl",Nle="float32-renderable-webgl",Stn="rgb9e5ufloat-renderable-webgl",Fle={"float32-renderable-webgl":{extensions:[Z1t]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[Y1t]},"norm16-webgl":{extensions:[Etn]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[Y1t]},"float32-filterable":{extensions:["OES_texture_float_linear"]},"float16-filterable-webgl":{extensions:["OES_texture_half_float_linear"]},"texture-filterable-anisotropic-webgl":{extensions:["EXT_texture_filter_anisotropic"]},"texture-blend-float-webgl":{extensions:["EXT_float_blend"]},"texture-compression-bc":{extensions:[MV,TV,yB,xB]},"texture-compression-bc5-webgl":{extensions:[yB]},"texture-compression-bc7-webgl":{extensions:[xB]},"texture-compression-etc2":{extensions:[wtn]},"texture-compression-astc":{extensions:[vtn]},"texture-compression-etc1-webgl":{extensions:[_tn]},"texture-compression-pvrtc-webgl":{extensions:[ytn]},"texture-compression-atc-webgl":{extensions:[xtn]}};Ule={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:uRe},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:uRe},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0,r:dRe},r16unorm:{gl:33322,rb:!0,r:fRe},r16snorm:{gl:36760,r:hRe},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759,r:uRe},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:dRe},rg16unorm:{gl:33324,r:fRe},rg16snorm:{gl:36761,r:hRe},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:Nle},rgb9e5ufloat:{gl:35901,r:Stn},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852,r:!1},"rgb16snorm-webgl":{gl:36762,r:!1},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0,r:Nle},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:dRe},rgba16unorm:{gl:32859,rb:!0,r:fRe},rgba16snorm:{gl:36763,r:hRe},"rgb32float-webgl":{gl:34837,x:Z1t,r:Nle,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:Nle},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:MV},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:TV},"bc1-rgba-unorm":{gl:33777,x:MV},"bc1-rgba-unorm-srgb":{gl:35916,x:TV},"bc2-rgba-unorm":{gl:33778,x:MV},"bc2-rgba-unorm-srgb":{gl:35918,x:TV},"bc3-rgba-unorm":{gl:33779,x:MV},"bc3-rgba-unorm-srgb":{gl:35919,x:TV},"bc4-r-unorm":{gl:36283,x:yB},"bc4-r-snorm":{gl:36284,x:yB},"bc5-rg-unorm":{gl:36285,x:yB},"bc5-rg-snorm":{gl:36286,x:yB},"bc6h-rgb-ufloat":{gl:36495,x:xB},"bc6h-rgb-float":{gl:36494,x:xB},"bc7-rgba-unorm":{gl:36492,x:xB},"bc7-rgba-unorm-srgb":{gl:36493,x:xB},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37816},"astc-10x5-unorm-srgb":{gl:37848},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rgb2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}}});var t0t,Gle,n0t=Ve(()=>{Vr();SV();EB();t0t={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","html-in-canvas":s=>GLe()&&typeof s.texElementImage2D=="function","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},Gle=class extends p${gl;extensions;testedFeatures=new Set;constructor(n,r,c){super([],c),this.gl=n,this.extensions=r,vv(n,"EXT_color_buffer_float",r)}*[Symbol.iterator](){let n=this.getFeatures();for(let r of n)this.has(r)&&(yield r);return[]}has(n){return this.disabledFeatures?.[n]?!1:(this.testedFeatures.has(n)||(this.testedFeatures.add(n),K1t(n)&&pRe(this.gl,n,this.extensions)&&this.features.add(n),this.getWebGLFeature(n)&&this.features.add(n)),this.features.has(n))}initializeFeatures(){let n=this.getFeatures().filter(r=>r!=="polygon-mode-webgl");for(let r of n)this.has(r)}getFeatures(){return[...Object.keys(t0t),...Object.keys(Fle)]}getWebGLFeature(n){let r=t0t[n];return typeof r=="string"?!!vv(this.gl,r,this.extensions):typeof r=="function"?r(this.gl):!!r}}});var jle,i0t=Ve(()=>{Vr();jle=class extends d${get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxBindGroupsPlusVertexBuffers(){return 0}get maxBindingsPerBindGroup(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageBuffersInVertexStage(){return 0}get maxStorageBuffersInFragmentStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxStorageTexturesInVertexStage(){return 0}get maxStorageTexturesInFragmentStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get maxBufferSize(){return Number.MAX_SAFE_INTEGER}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxColorAttachments(){return this.getParameter(36063)}get maxColorAttachmentBytesPerSample(){return 0}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(n){super(),this.gl=n}getParameter(n){return this.limits[n]===void 0&&(this.limits[n]=this.gl.getParameter(n)),this.limits[n]||0}}});function Atn(s){return s<34069?s+34069:s}function Ptn(s){switch(s){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${s}`}}var s2,$le=Ve(()=>{Vr();EB();s2=class extends n4{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(n,r){super(n,r);let c=r.handle,u=c===null;this.device=n,this.gl=n.gl,this.handle=c||u?c:this.gl.createFramebuffer(),u||(n._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),r.handle||(this.autoCreateAttachmentTextures(),this.updateAttachments()))}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&!this.props.handle&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){let n=this.gl.bindFramebuffer(36160,this.handle);for(let r=0;r{Vr();$le();Vle=class extends g${device;handle=null;_framebuffer=null;get[Symbol.toStringTag](){return"WebGLCanvasContext"}constructor(n,r){super(r),this.device=n,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._configureDevice()}_configureDevice(){(this.drawingBufferWidth!==this._framebuffer?.width||this.drawingBufferHeight!==this._framebuffer?.height)&&this._framebuffer?.resize([this.drawingBufferWidth,this.drawingBufferHeight])}_getCurrentFramebuffer(){return this._framebuffer||=new s2(this.device,{id:"canvas-context-framebuffer",handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}}});var Wle,s0t=Ve(()=>{Vr();Wle=class extends m${device;handle=null;context2d;get[Symbol.toStringTag](){return"WebGLPresentationContext"}constructor(n,r={}){super(r),this.device=n;let c=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw new Error(`${c}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);let d=this.canvas.getContext("2d");if(!d)throw new Error(`${c}: Failed to create 2d presentation context`);this.context2d=d,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();let n=this.device.getDefaultCanvasContext(),[r,c]=n.getDrawingBufferSize();if(!(this.drawingBufferWidth===0||this.drawingBufferHeight===0||r===0||c===0||n.canvas.width===0||n.canvas.height===0)){if(r!==this.drawingBufferWidth||c!==this.drawingBufferHeight||n.canvas.width!==this.drawingBufferWidth||n.canvas.height!==this.drawingBufferHeight)throw new Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${r}x${c} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(n.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(n){let r=this.device.getDefaultCanvasContext();return r.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),r.getCurrentFramebuffer(n)}}});function o0t(s="id"){gRe[s]=gRe[s]||1;let n=gRe[s]++;return`${s}-${n}`}var gRe,a0t=Ve(()=>{gRe={}});function Ltn(s){return s&cs.INDEX?34963:s&cs.VERTEX?34962:s&cs.UNIFORM?35345:34962}function ktn(s){return s&cs.INDEX||s&cs.VERTEX?35044:s&cs.UNIFORM?35048:35044}var _v,Hle=Ve(()=>{Vr();_v=class extends cs{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength=0;bytesUsed=0;constructor(n,r={}){super(n,r),this.device=n,this.gl=this.device.gl;let c=typeof r=="object"?r.handle:void 0;this.handle=c||this.gl.createBuffer(),n._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=Ltn(this.props.usage),this.glUsage=ktn(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,r.data?this._initWithData(r.data,r.byteOffset,r.byteLength):this._initWithByteLength(r.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Buffer"):(this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle)),this.destroyed=!0,this.handle=null)}_initWithData(n,r=0,c=n.byteLength+r){let u=this.glTarget;this.gl.bindBuffer(u,this.handle),this.gl.bufferData(u,c,this.glUsage),this.gl.bufferSubData(u,r,n),this.gl.bindBuffer(u,null),this.bytesUsed=c,this.byteLength=c,this._setDebugData(n,r,c),this.props.handle?this.trackReferencedMemory(c,"Buffer"):this.trackAllocatedMemory(c)}_initWithByteLength(n){let r=n;n===0&&(r=new Float32Array(0));let c=this.glTarget;return this.gl.bindBuffer(c,this.handle),this.gl.bufferData(c,r,this.glUsage),this.gl.bindBuffer(c,null),this.bytesUsed=n,this.byteLength=n,this._setDebugData(null,0,n),this.props.handle?this.trackReferencedMemory(n,"Buffer"):this.trackAllocatedMemory(n),this}write(n,r=0){let c=ArrayBuffer.isView(n)?n:new Uint8Array(n),u=0,d=void 0,b=36663;this.gl.bindBuffer(b,this.handle),u!==0||d!==void 0?this.gl.bufferSubData(b,r,c,u,d):this.gl.bufferSubData(b,r,c),this.gl.bindBuffer(b,null),this._setDebugData(n,r,n.byteLength)}async mapAndWriteAsync(n,r=0,c=this.byteLength-r){let u=new ArrayBuffer(c);await n(u,"copied"),this.write(u,r)}async readAsync(n=0,r){return this.readSyncWebGL(n,r)}async mapAndReadAsync(n,r=0,c){let u=await this.readAsync(r,c);return await n(u.buffer,"copied")}readSyncWebGL(n=0,r){r=r??this.byteLength-n;let c=new Uint8Array(r),u=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,n,c,u,r),this.gl.bindBuffer(36662,null),this._setDebugData(c,n,r),c}}});function c0t(s){let n=s.split(/\r?\n/),r=[];for(let c of n){if(c.length<=1)continue;let u=c.trim(),d=c.split(":"),b=d[0]?.trim();if(d.length===2){let[I,D]=d;if(!I||!D){r.push({message:u,type:qle(b||"info"),lineNum:0,linePos:0});continue}r.push({message:D.trim(),type:qle(I),lineNum:0,linePos:0});continue}let[w,_,x,...T]=d;if(!w||!_||!x){r.push({message:d.slice(1).join(":").trim()||u,type:qle(b||"info"),lineNum:0,linePos:0});continue}let M=parseInt(x,10);Number.isNaN(M)&&(M=0);let L=parseInt(_,10);Number.isNaN(L)&&(L=0),r.push({message:T.join(":").trim(),type:qle(w),lineNum:M,linePos:L})}return r}function qle(s){let n=["warning","error","info"],r=s.toLowerCase();return n.includes(r)?r:"info"}var l0t=Ve(()=>{});function Rtn(s){return s.split(/\r?\n/).find(n=>n.trim())?.trim()}var Xle,u0t=Ve(()=>{Vr();l0t();Xle=class extends t4{device;handle;_compilationInfoLog="";constructor(n,r){super(n,r),this.device=n;let c=this.props.handle;switch(this.props.stage){case"vertex":this.handle=c||this.device.gl.createShader(35633);break;case"fragment":this.handle=c||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}n._setWebGLDebugMetadata(this.handle,this,{spector:this.props});let u=this._compile(this.source);u&&typeof u.catch=="function"&&u.catch(()=>{this.compilationStatus="error"})}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let n=this._getCompilationInfoLog();return n?c0t(n):[]}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)||null}_compile(n){n=n.startsWith("#version ")?n:`#version 300 es -${n}`;let{gl:r}=this.device;if(r.shaderSource(this.handle,n),r.compileShader(this.handle),!this.device.props.debug){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus==="error")throw new Error(this._getCompilationErrorMessage(n));return}return Qt.once(1,"Shader compilation is asynchronous")(),this._waitForCompilationComplete().then(()=>{Qt.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()})}async _waitForCompilationComplete(){let n=async u=>await new Promise(d=>setTimeout(d,u));if(!this.device.features.has("compilation-status-async-webgl")){await n(10);return}let{gl:c}=this.device;for(;;){if(c.getShaderParameter(this.handle,37297))return;await n(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error",this.compilationStatus==="error"&&this._getCompilationInfoLog()}_getCompilationErrorMessage(n){let r=`${this.props.stage} shader ${this.props.id}`,c=Rtn(this._getCompilationInfoLog()),u=this.getCompilationInfoSync(),d=u.find(T=>T.type==="error"&&T.message.trim())||u.find(T=>T.message.trim())||u.find(T=>T.type==="error")||u[0];if(!d)return c?`GLSL compilation errors in ${r}: ${c}`:`GLSL compilation errors in ${r}: WebGL did not provide a shader compiler log`;let b=d.lineNum?n.split(/\r?\n/)[d.lineNum-1]?.trim():void 0,w=d.lineNum?` line ${d.lineNum}`:"",_=b?` -Source: ${b}`:"",x=d.message.trim()||c||"WebGL did not provide a shader compiler log";return`GLSL compilation errors in ${r}:${w}: ${x}${_}`}_getCompilationInfoLog(){let n=this.device.gl.getShaderInfoLog(this.handle)?.trim();return n&&(this._compilationInfoLog=n),this._compilationInfoLog}}});function h0t(s,n,r,c){if(Otn(n))return c(s);let u=s;u.pushState();try{return Itn(s,n),bv(u.gl,r),c(s)}finally{u.popState()}}function Itn(s,n){let r=s,{gl:c}=r;if(n.cullMode)switch(n.cullMode){case"none":c.disable(2884);break;case"front":c.enable(2884),c.cullFace(1028);break;case"back":c.enable(2884),c.cullFace(1029);break}if(n.frontFace&&c.frontFace(P4("frontFace",n.frontFace,{ccw:2305,cw:2304})),n.unclippedDepth&&s.features.has("depth-clip-control")&&c.enable(34383),n.depthBias!==void 0&&(c.enable(32823),c.polygonOffset(n.depthBias,n.depthBiasSlopeScale||0)),n.provokingVertex&&s.features.has("provoking-vertex-webgl")){let d=r.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,b=P4("provokingVertex",n.provokingVertex,{first:36429,last:36430});d?.provokingVertexWEBGL(b)}if((n.polygonMode||n.polygonOffsetLine)&&s.features.has("polygon-mode-webgl")){if(n.polygonMode){let d=r.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,b=P4("polygonMode",n.polygonMode,{fill:6914,line:6913});d?.polygonModeWEBGL(1028,b),d?.polygonModeWEBGL(1029,b)}n.polygonOffsetLine&&c.enable(10754)}if(s.features.has("shader-clip-cull-distance-webgl")&&(n.clipDistance0&&c.enable(12288),n.clipDistance1&&c.enable(12289),n.clipDistance2&&c.enable(12290),n.clipDistance3&&c.enable(12291),n.clipDistance4&&c.enable(12292),n.clipDistance5&&c.enable(12293),n.clipDistance6&&c.enable(12294),n.clipDistance7&&c.enable(12295)),n.depthWriteEnabled!==void 0&&c.depthMask(Btn("depthWriteEnabled",n.depthWriteEnabled)),n.depthCompare&&(n.depthCompare!=="always"?c.enable(2929):c.disable(2929),c.depthFunc(Zle("depthCompare",n.depthCompare))),n.clearDepth!==void 0&&c.clearDepth(n.clearDepth),n.stencilWriteMask){let u=n.stencilWriteMask;c.stencilMaskSeparate(1028,u),c.stencilMaskSeparate(1029,u)}if(n.stencilReadMask&&Qt.warn("stencilReadMask not supported under WebGL"),n.stencilCompare){let u=n.stencilReadMask||4294967295,d=Zle("depthCompare",n.stencilCompare);n.stencilCompare!=="always"?c.enable(2960):c.disable(2960),c.stencilFuncSeparate(1028,d,0,u),c.stencilFuncSeparate(1029,d,0,u)}if(n.stencilPassOperation&&n.stencilFailOperation&&n.stencilDepthFailOperation){let u=mRe("stencilPassOperation",n.stencilPassOperation),d=mRe("stencilFailOperation",n.stencilFailOperation),b=mRe("stencilDepthFailOperation",n.stencilDepthFailOperation);c.stencilOpSeparate(1028,d,b,u),c.stencilOpSeparate(1029,d,b,u)}switch(n.blend){case!0:c.enable(3042);break;case!1:c.disable(3042);break;default:}if(n.blendColorOperation||n.blendAlphaOperation){let u=f0t("blendColorOperation",n.blendColorOperation||"add"),d=f0t("blendAlphaOperation",n.blendAlphaOperation||"add");c.blendEquationSeparate(u,d);let b=Yle("blendColorSrcFactor",n.blendColorSrcFactor||"one"),w=Yle("blendColorDstFactor",n.blendColorDstFactor||"zero"),_=Yle("blendAlphaSrcFactor",n.blendAlphaSrcFactor||"one"),x=Yle("blendAlphaDstFactor",n.blendAlphaDstFactor||"zero");c.blendFuncSeparate(b,w,_,x)}}function Zle(s,n){return P4(s,n,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function mRe(s,n){return P4(s,n,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function f0t(s,n){return P4(s,n,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function Yle(s,n,r="color"){return P4(s,n,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:r==="color"?32769:32771,"one-minus-constant":r==="color"?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function Dtn(s,n){return`Illegal parameter ${n} for ${s}`}function P4(s,n,r){if(!(n in r))throw new Error(Dtn(s,n));return r[n]}function Btn(s,n){return n}function Otn(s){let n=!0;for(let r in s){n=!1;break}return n}var bRe=Ve(()=>{Vr();_B()});function Kle(s){let n={};return s.addressModeU&&(n[10242]=wRe(s.addressModeU)),s.addressModeV&&(n[10243]=wRe(s.addressModeV)),s.addressModeW&&(n[32882]=wRe(s.addressModeW)),s.magFilter&&(n[10240]=vRe(s.magFilter)),(s.minFilter||s.mipmapFilter)&&(n[10241]=Ntn(s.minFilter||"linear",s.mipmapFilter)),s.lodMinClamp!==void 0&&(n[33082]=s.lodMinClamp),s.lodMaxClamp!==void 0&&(n[33083]=s.lodMaxClamp),s.type==="comparison-sampler"&&(n[34892]=34894),s.compare&&(n[34893]=Zle("compare",s.compare)),s.maxAnisotropy&&(n[34046]=s.maxAnisotropy),n}function wRe(s){switch(s){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function vRe(s){switch(s){case"nearest":return 9728;case"linear":return 9729}}function Ntn(s,n="none"){if(!n)return vRe(s);switch(n){case"none":return vRe(s);case"nearest":switch(s){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(s){case"nearest":return 9986;case"linear":return 9987}}}var _Re=Ve(()=>{bRe()});var Jle,d0t=Ve(()=>{Vr();_Re();Jle=class extends QL{device;handle;parameters;constructor(n,r){super(n,r),this.device=n,this.parameters=Kle(r),this.handle=r.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(n){for(let[r,c]of Object.entries(n)){let u=Number(r);switch(u){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,u,c);break;default:this.device.gl.samplerParameteri(this.handle,u,c);break}}}}});function yv(s,n,r){if(Ftn(n))return r(s);let{nocatch:c=!0}=n,u=wv.get(s);u.push(),bv(s,n);let d;if(c)d=r(s),u.pop();else try{d=r(s)}finally{u.pop()}return d}function Ftn(s){for(let n in s)return!1;return!0}var Qle=Ve(()=>{_B();aRe()});var o2,yRe=Ve(()=>{Vr();o2=class extends e4{device;gl;handle;texture;constructor(n,r){super(n,{...Pa.defaultProps,...r}),this.device=n,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}}});function eue(s){return Utn[s]}var Utn,xRe=Ve(()=>{Utn={5124:"sint32",5125:"uint32",5122:"sint16",5123:"uint16",5120:"sint8",5121:"uint8",5126:"float32",5131:"float16",33635:"uint16",32819:"uint16",32820:"uint16",33640:"uint32",35899:"uint32",35902:"uint32",34042:"uint32",36269:"uint32"}});function ztn(s,n=0){return n?new s.constructor(s.buffer,s.byteOffset+n,(s.byteLength-n)/s.BYTES_PER_ELEMENT):s}function Gtn(s,n){if(n%s.BYTES_PER_ELEMENT!==0)throw new Error(`Texture byteOffset ${n} must align to typed array element size ${s.BYTES_PER_ELEMENT}`);return n/s.BYTES_PER_ELEMENT}function jtn(s){switch(s){case"1d":break;case"2d":return 3553;case"3d":return 32879;case"cube":return 34067;case"2d-array":return 35866;case"cube-array":break}throw new Error(s)}function CV(s,n,r){return n==="cube"?34069+r:s}var a2,tue=Ve(()=>{Vr();EB();_Re();Qle();yRe();xRe();a2=class extends Pa{device;gl;handle;sampler=void 0;view;glTarget;glFormat;glType;glInternalFormat;compressed;_textureUnit=0;_framebuffer=null;_framebufferAttachmentKey=null;constructor(n,r){super(n,r,{byteAlignment:1}),this.device=n,this.gl=this.device.gl;let c=zle(this.props.format);if(this.glTarget=jtn(this.props.dimension),this.glInternalFormat=c.internalFormat,this.glFormat=c.format,this.glType=c.type,this.compressed=c.compressed,this.isHandleBorrowed&&this.props.handle===void 0)throw new Error("Borrowed WebGL textures require a texture handle");if(this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),!this.isHandleBorrowed){this.gl.bindTexture(this.glTarget,this.handle);let{dimension:u,width:d,height:b,depth:w,mipLevels:_,glTarget:x,glInternalFormat:T}=this;if(!this.compressed)switch(u){case"2d":case"cube":this.gl.texStorage2D(x,_,T,d,b);break;case"2d-array":case"3d":this.gl.texStorage3D(x,_,T,d,b,w);break;default:throw new Error(u)}this.gl.bindTexture(this.glTarget,null),this._initializeData(r.data)}this.ownsHandle?this.trackAllocatedMemory(this.getAllocatedByteLength(),"Texture"):this.trackReferencedMemory(this.getAllocatedByteLength(),"Texture"),this.isHandleBorrowed||this.setSampler(this.props.sampler),this.view=new o2(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this._framebuffer?.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.ownsHandle?(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory("Texture")):this.trackDeallocatedReferencedMemory("Texture"),this.destroyed=!0)}createView(n){return new o2(this.device,{...n,texture:this})}clone(n){if(this.isHandleBorrowed&&n&&(n.width!==this.width||n.height!==this.height))throw new Error(`Cannot resize borrowed read-only ${this}`);return super.clone(n)}setSampler(n={}){this._assertWritable("set sampler parameters on"),super.setSampler(n);let r=Kle(this.sampler.props);this._setSamplerParameters(r)}copyExternalImage(n){this._assertWritable("copy external image data into");let r=this._normalizeCopyExternalImageOptions(n);if(r.sourceX||r.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");let{glFormat:c,glType:u}=this,{image:d,depth:b,mipLevel:w,x:_,y:x,z:T,width:M,height:L}=r,I=CV(this.glTarget,this.dimension,T),D=r.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),yv(this.gl,D,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(I,w,_,x,M,L,c,u,d);break;case"2d-array":case"3d":this.gl.texSubImage3D(I,w,_,x,T,M,L,b,c,u,d);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:r.width,height:r.height}}copyElementImage(n){this._assertWritable("copy element image data into");let r=this._normalizeCopyElementImageOptions(n),{glFormat:c}=this,{element:u,depth:d,mipLevel:b,sourceX:w,sourceY:_,sourceWidth:x,sourceHeight:T,x:M,y:L,z:I,width:D,height:F}=r,O=CV(this.glTarget,this.dimension,I),z=r.flipY?{37440:!0}:{},Z=this.gl;if(d!==1||this.dimension!=="2d"&&this.dimension!=="cube")throw new Error(`${this} copyElementImage only supports 2d and cube textures on WebGL`);if(b!==0||M!==0||L!==0)throw new Error(`${this} copyElementImage only supports full base-level uploads on WebGL`);if(typeof Z.texElementImage2D!="function")throw new Error(`${this} copyElementImage is not supported by this WebGL implementation`);return this.gl.bindTexture(this.glTarget,this.handle),yv(this.gl,z,()=>{Z.texElementImage2D?.(O,c,u,{sx:w,sy:_,swidth:x??D,sheight:T??F,width:D,height:F})}),this.gl.bindTexture(this.glTarget,null),{width:r.width,height:r.height}}copyImageData(n){super.copyImageData(n)}readBuffer(n={},r){if(!r)throw new Error(`${this} readBuffer requires a destination buffer`);let c=this._getSupportedColorReadOptions(n),u=n.byteOffset??0,d=this.computeMemoryLayout(c);if(r.byteLength{this.gl.readPixels(c.x,c.y,c.width,c.height,this.glFormat,this.glType,u+w)})}finally{this.gl.bindBuffer(35051,null)}return r}async readDataAsync(n={}){throw new Error(`${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`)}writeBuffer(n,r={}){this._assertWritable("write buffer data into");let c=this._normalizeTextureWriteOptions(r),{width:u,height:d,depthOrArrayLayers:b,mipLevel:w,byteOffset:_,x,y:T,z:M}=c,{glFormat:L,glType:I,compressed:D}=this,F=CV(this.glTarget,this.dimension,M);if(D)throw new Error("writeBuffer for compressed textures is not implemented in WebGL");let{bytesPerPixel:O}=this.device.getTextureFormatInfo(this.format),z=O?c.bytesPerRow/O:void 0,Z={3317:this.byteAlignment,...z!==void 0?{3314:z}:{},32878:c.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,n.handle),yv(this.gl,Z,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(F,w,x,T,u,d,L,I,_);break;case"2d-array":case"3d":this.gl.texSubImage3D(F,w,x,T,M,u,d,b,L,I,_);break;default:}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(n,r={}){this._assertWritable("write data into");let c=this._normalizeTextureWriteOptions(r),u=ArrayBuffer.isView(n)?n:new Uint8Array(n),{width:d,height:b,depthOrArrayLayers:w,mipLevel:_,x,y:T,z:M,byteOffset:L}=c,{glFormat:I,glType:D,compressed:F}=this,O=CV(this.glTarget,this.dimension,M),z;if(!F){let{bytesPerPixel:ue}=this.device.getTextureFormatInfo(this.format);ue&&(z=c.bytesPerRow/ue)}let Z=this.compressed?{}:{3317:this.byteAlignment,...z!==void 0?{3314:z}:{},32878:c.rowsPerImage},H=Gtn(u,L),te=F?ztn(u,L):u,oe=this._getMipLevelSize(_),ne=x===0&&T===0&&M===0&&d===oe.width&&b===oe.height&&w===oe.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),yv(this.gl,Z,()=>{switch(this.dimension){case"2d":case"cube":F?ne?this.gl.compressedTexImage2D(O,_,I,d,b,0,te):this.gl.compressedTexSubImage2D(O,_,x,T,d,b,I,te):this.gl.texSubImage2D(O,_,x,T,d,b,I,D,u,H);break;case"2d-array":case"3d":F?ne?this.gl.compressedTexImage3D(O,_,I,d,b,w,0,te):this.gl.compressedTexSubImage3D(O,_,x,T,M,d,b,w,I,te):this.gl.texSubImage3D(O,_,x,T,M,d,b,w,I,D,u,H);break;default:}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(n,r){return 1}_getFramebuffer(){return this._framebuffer||=this.device.createFramebuffer({id:`framebuffer-for-${this.id}`,width:this.width,height:this.height,colorAttachments:[this]}),this._framebuffer}readDataSyncWebGL(n={}){let r=this._getSupportedColorReadOptions(n),c=this.computeMemoryLayout(r),u=eue(this.glType),d=JL(u),b=new d(c.byteLength/d.BYTES_PER_ELEMENT);return this._readColorTextureLayers(r,c,w=>{let _=new d(b.buffer,b.byteOffset+w,c.bytesPerImage/d.BYTES_PER_ELEMENT);this.gl.readPixels(r.x,r.y,r.width,r.height,this.glFormat,this.glType,_)}),b.buffer}_readColorTextureLayers(n,r,c){let u=this._getFramebuffer(),d=r.bytesPerRow/r.bytesPerPixel,b={3333:this.byteAlignment,...d!==n.width?{3330:d}:{}},w=this.gl.getParameter(3074),_=this.gl.bindFramebuffer(36160,u.handle);try{this.gl.readBuffer(36064),yv(this.gl,b,()=>{for(let x=0;x=2&&Qt.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(n))(),this.gl.bindTexture(this.glTarget,this.handle);for(let[r,c]of Object.entries(n)){let u=Number(r),d=c;switch(u){case 33082:case 33083:this.gl.texParameterf(this.glTarget,u,d);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,u,d);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,u,d);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,u,d);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,u,d);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(n){let{gl:r}=this;return n!==void 0&&(this._textureUnit=n,r.activeTexture(33984+n)),r.bindTexture(this.glTarget,this.handle),n}_unbind(n){let{gl:r}=this;return n!==void 0&&(this._textureUnit=n,r.activeTexture(33984+n)),r.bindTexture(this.glTarget,null),n}_assertWritable(n){if(this.isHandleBorrowed)throw new Error(`Cannot ${n} borrowed read-only ${this}`)}}});function p0t(s,n,r,c){let u=s,d=c;d===!0&&(d=1),d===!1&&(d=0);let b=typeof d=="number"?[d]:d;switch(r){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof c!="number")throw new Error("samplers must be set to integers");return s.uniform1i(n,c);case 5126:return s.uniform1fv(n,b);case 35664:return s.uniform2fv(n,b);case 35665:return s.uniform3fv(n,b);case 35666:return s.uniform4fv(n,b);case 5124:return s.uniform1iv(n,b);case 35667:return s.uniform2iv(n,b);case 35668:return s.uniform3iv(n,b);case 35669:return s.uniform4iv(n,b);case 35670:return s.uniform1iv(n,b);case 35671:return s.uniform2iv(n,b);case 35672:return s.uniform3iv(n,b);case 35673:return s.uniform4iv(n,b);case 5125:return u.uniform1uiv(n,b,1);case 36294:return u.uniform2uiv(n,b,2);case 36295:return u.uniform3uiv(n,b,3);case 36296:return u.uniform4uiv(n,b,4);case 35674:return s.uniformMatrix2fv(n,!1,b);case 35675:return s.uniformMatrix3fv(n,!1,b);case 35676:return s.uniformMatrix4fv(n,!1,b);case 35685:return u.uniformMatrix2x3fv(n,!1,b);case 35686:return u.uniformMatrix2x4fv(n,!1,b);case 35687:return u.uniformMatrix3x2fv(n,!1,b);case 35688:return u.uniformMatrix3x4fv(n,!1,b);case 35689:return u.uniformMatrix4x2fv(n,!1,b);case 35690:return u.uniformMatrix4x3fv(n,!1,b)}throw new Error("Illegal uniform")}var g0t=Ve(()=>{});function m0t(s){return Vtn[s]}function nue(s){return $tn[s]}function iue(s){return!!w0t[s]}function b0t(s){return w0t[s]}var $tn,w0t,Vtn,rue=Ve(()=>{$tn={5126:"f32",35664:"vec2",35665:"vec3",35666:"vec4",5124:"i32",35667:"vec2",35668:"vec3",35669:"vec4",5125:"u32",36294:"vec2",36295:"vec3",36296:"vec4",35670:"f32",35671:"vec2",35672:"vec3",35673:"vec4",35674:"mat2x2",35685:"mat2x3",35686:"mat2x4",35687:"mat3x2",35675:"mat3x3",35688:"mat3x4",35689:"mat4x2",35690:"mat4x3",35676:"mat4x4"},w0t={35678:{viewDimension:"2d",sampleType:"float"},35680:{viewDimension:"cube",sampleType:"float"},35679:{viewDimension:"3d",sampleType:"float"},35682:{viewDimension:"3d",sampleType:"depth"},36289:{viewDimension:"2d-array",sampleType:"float"},36292:{viewDimension:"2d-array",sampleType:"depth"},36293:{viewDimension:"cube",sampleType:"float"},36298:{viewDimension:"2d",sampleType:"sint"},36299:{viewDimension:"3d",sampleType:"sint"},36300:{viewDimension:"cube",sampleType:"sint"},36303:{viewDimension:"2d-array",sampleType:"uint"},36306:{viewDimension:"2d",sampleType:"uint"},36307:{viewDimension:"3d",sampleType:"uint"},36308:{viewDimension:"cube",sampleType:"uint"},36311:{viewDimension:"2d-array",sampleType:"uint"}},Vtn={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126}});function _0t(s,n,r={}){let c={attributes:[],bindings:[]};c.attributes=Wtn(s,n);let u=Xtn(s,n,r);for(let _ of u){let x=_.uniforms.map(T=>({name:T.name,format:T.format,byteOffset:T.byteOffset,byteStride:T.byteStride,arrayLength:T.arrayLength}));c.bindings.push({type:"uniform",name:_.name,group:0,location:_.location,visibility:(_.vertex?1:0)|(_.fragment?2:0),minBindingSize:_.byteLength,uniforms:x})}let d=qtn(s,n),b=0;for(let _ of d)if(iue(_.type)){let{viewDimension:x,sampleType:T}=b0t(_.type);c.bindings.push({type:"texture",name:_.name,group:0,location:b,viewDimension:x,sampleType:T}),_.textureUnit=b,b+=1}d.length&&(c.uniforms=d);let w=Htn(s,n);return w?.length&&(c.varyings=w),c}function Wtn(s,n){let r=[],c=s.getProgramParameter(n,35721);for(let u=0;u=0){let x=nue(w),T=/instance/i.test(b)?"instance":"vertex";r.push({name:b,location:_,stepMode:T,type:x})}}return r.sort((u,d)=>u.location-d.location),r}function Htn(s,n){let r=[],c=s.getProgramParameter(n,35971);for(let u=0;uu.location-d.location),r}function qtn(s,n){let r=[],c=s.getProgramParameter(n,35718);for(let u=0;u1)for(let I=0;Ib.location-w.location),c}function Ytn(s,n){for(let r of s.uniforms){let c=n.uniforms.find(u=>r.name===u.name||r.name.endsWith(`.${u.name}`));if(!c)throw new Error(`Failed to validate WebGL uniform block "${n.name}": reflected unexpected member "${r.name}"`);if(r.format!==c.format||r.arrayLength!==c.arrayLength||r.byteOffset!==c.byteOffset||r.byteStride!==c.byteStride)throw new Error(`Failed to validate WebGL uniform block "${n.name}": reflected layout for "${r.name}" does not match supplied std140 metadata`)}}function Ztn(s,n,r){let c=new Map;for(let d of r.uniformBlockLayouts||[])c.set(d.name,Jtn(d));for(let d of r.shaderLayout?.bindings||[])enn(d)&&c.set(d.name,d);let u=new Map;for(let d of c.values()){let b=Ktn(s,n,d.name);if(!b)continue;let{blockIndex:w,blockName:_}=b;if(u.has(w))throw new Error(`Multiple supplied uniform block layouts resolve to active WebGL block "${_}"`);u.set(w,{name:_,location:w,byteLength:d.minBindingSize,vertex:!!(d.visibility&&d.visibility&1),fragment:!!(d.visibility&&d.visibility&2),uniformCount:d.uniforms.length,uniforms:d.uniforms.map(x=>({...x}))})}return u}function Ktn(s,n,r){let c=r.endsWith("Uniforms")?[r,r.slice(0,-8)]:[r,`${r}Uniforms`];for(let u of c){let d=s.getUniformBlockIndex(n,u);if(d!==4294967295){if(!Number.isInteger(d)||d<0)throw new Error(`Failed to resolve WebGL uniform block "${u}": getUniformBlockIndex returned ${String(d)}`);return{blockIndex:d,blockName:u}}}return null}function v0t(s,n,r,c){let u=c||s.getActiveUniformBlockName(n,r);if(!u)throw new Error(`Failed to reflect WebGL uniform block at index ${r}: missing block name`);let d=(H,te)=>{let oe=s.getActiveUniformBlockParameter(n,r,H);if(oe==null)throw new Error(`Failed to reflect WebGL uniform block "${u}": ${te} returned null`);return oe},b=L4(d(35391,"UNIFORM_BLOCK_BINDING"),u,"UNIFORM_BLOCK_BINDING",0),w=L4(d(35392,"UNIFORM_BLOCK_DATA_SIZE"),u,"UNIFORM_BLOCK_DATA_SIZE",0),_=L4(d(35394,"UNIFORM_BLOCK_ACTIVE_UNIFORMS"),u,"UNIFORM_BLOCK_ACTIVE_UNIFORMS",0),x=y0t(d(35395,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES"),u,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",_),T=AV(s,n,x,35383,"UNIFORM_TYPE",u,_),M=AV(s,n,x,35384,"UNIFORM_SIZE",u,_),L=AV(s,n,x,35386,"UNIFORM_BLOCK_INDEX",u,_),I=AV(s,n,x,35387,"UNIFORM_OFFSET",u,_),D=AV(s,n,x,35388,"UNIFORM_ARRAY_STRIDE",u,_),F=[];for(let H=0;H<_;H++){if(L[H]!==r)throw new Error(`Failed to reflect WebGL uniform block "${u}": active uniform index ${x[H]} belongs to block ${L[H]}, expected ${r}`);let te=x[H],oe=s.getActiveUniform(n,te);if(!oe)throw new Error(`Failed to reflect WebGL uniform block "${u}": getActiveUniform(${te}) returned null`);let ne=L4(T[H],u,`UNIFORM_TYPE[${H}]`,1),ue=L4(M[H],u,`UNIFORM_SIZE[${H}]`,1),Te=L4(I[H],u,`UNIFORM_OFFSET[${H}]`,0),Q=L4(D[H],u,`UNIFORM_ARRAY_STRIDE[${H}]`,0);if(oe.type!==ne||oe.size!==ue)throw new Error(`Failed to reflect WebGL uniform block "${u}": getActiveUniform(${te}) disagrees with getActiveUniforms`);F.push({name:oe.name,format:nue(ne),arrayLength:ue,byteOffset:Te,byteStride:Q})}let O={name:u,location:b,byteLength:w,vertex:!!d(35396,"UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER"),fragment:!!d(35398,"UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER"),uniformCount:_,uniforms:F},z=new Set(O.uniforms.map(H=>H.name.split(".")[0]).filter(H=>!!H)),Z=O.name.replace(/Uniforms$/,"");if(z.size===1&&!z.has(O.name)&&!z.has(Z)){let[H]=z;Qt.warn(`Uniform block "${O.name}" uses GLSL instance "${H}". luma.gl binds uniform buffers by block name ("${O.name}") and alias ("${Z}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}return O}function AV(s,n,r,c,u,d,b){let w=s.getActiveUniforms(n,r,c);if(w===null)throw new Error(`Failed to reflect WebGL uniform block "${d}": ${u} returned null`);return y0t(w,d,u,b)}function y0t(s,n,r,c){if(!Array.isArray(s)&&!ArrayBuffer.isView(s))throw new Error(`Failed to reflect WebGL uniform block "${n}": ${r} returned a non-array value`);let u=Array.from(s);if(u.length!==c||u.some(d=>!Number.isInteger(d)))throw new Error(`Failed to reflect WebGL uniform block "${n}": ${r} returned ${u.length} invalid values, expected ${c}`);return u}function L4(s,n,r,c){if(!Number.isInteger(s)||s{if(typeof b=="string"){let w=n[d];if(!w)throw new Error(`Missing std140 layout field ${d}`);r.push({name:d,format:w.shaderType,arrayLength:1,byteOffset:w.offset*4,byteStride:0});return}if(Array.isArray(b)){u(d,b[0],b[1]);return}for(let[w,_]of Object.entries(b))c(`${d}.${w}`,_)},u=(d,b,w)=>{if(typeof b=="string"){let _=n[`${d}[0]`],x=w>1?n[`${d}[1]`]:void 0;if(!_)throw new Error(`Missing std140 array layout field ${d}[0]`);r.push({name:`${d}[0]`,format:_.shaderType,arrayLength:w,byteOffset:_.offset*4,byteStride:x?(x.offset-_.offset)*4:0});return}if(Array.isArray(b))throw new Error(`Nested uniform arrays are not supported for ${d}`);for(let[_,x]of Object.entries(b)){if(typeof x!="string")throw new Error(`Composite uniform array members are not supported for ${d}`);let T=`${d}[0].${_}`,M=`${d}[1].${_}`,L=n[T],I=w>1?n[M]:void 0;if(!L)throw new Error(`Missing std140 array layout field ${T}`);r.push({name:T,format:L.shaderType,arrayLength:w,byteOffset:L.offset*4,byteStride:I?(I.offset-L.offset)*4:0})}};for(let[d,b]of Object.entries(s))c(d,b);return r}function enn(s){return s.type==="uniform"&&Number.isInteger(s.minBindingSize)&&s.minBindingSize>=0&&Array.isArray(s.uniforms)&&s.uniforms.every(n=>typeof n.name=="string"&&typeof n.format=="string"&&Number.isInteger(n.arrayLength)&&n.arrayLength>0&&Number.isInteger(n.byteOffset)&&n.byteOffset>=0&&Number.isInteger(n.byteStride)&&n.byteStride>=0)}function tnn(s){if(s[s.length-1]!=="]")return{name:s,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(s);return{name:UM(r?.[1],`Failed to parse GLSL uniform name ${s}`),length:r?.[2]?1:0,isArray:!!r?.[2]}}var x0t=Ve(()=>{Vr();rue()});function nnn(s,n){let r={...s,attributes:s.attributes.map(c=>({...c})),bindings:s.bindings.map(c=>({...c}))};for(let c of n?.attributes||[]){let u=r.attributes.find(d=>d.name===c.name);u?(u.type=c.type||u.type,u.stepMode=c.stepMode||u.stepMode):Qt.warn(`shader layout attribute ${c.name} not present in shader`)}for(let c of n?.bindings||[]){let u=S0t(r,c.name);if(!u){Qt.warn(`shader layout binding ${c.name} not present in shader`);continue}Object.assign(u,c)}return r}function S0t(s,n){return s.bindings.find(r=>r.name===n||r.name===`${n}Uniforms`||`${r.name}Uniforms`===n)}function E0t(s,n){return s[n]||s[`${n}Uniforms`]||s[n.replace(/Uniforms$/,"")]}var sue,M0t=Ve(()=>{Vr();g0t();Hle();$le();tue();yRe();x0t();sue=class extends Tb{device;handle;vs;fs;introspectedLayout;bindings={};uniforms={};varyings=null;_uniformCount=0;_uniformSetters={};get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}constructor(n,r){super(n,r),this.device=n;let c=this.sharedRenderPipeline||this.device._createSharedRenderPipelineWebGL(r);this.sharedRenderPipeline=c,this.handle=c.handle,this.vs=c.vs,this.fs=c.fs,this.linkStatus=c.linkStatus,this.introspectedLayout=_0t(this.device.gl,this.handle,{uniformBlockLayouts:r._uniformBlockLayouts,shaderLayout:r.shaderLayout}),this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.shaderLayout=r.shaderLayout?nnn(this.introspectedLayout,r.shaderLayout):this.introspectedLayout}destroy(){this.destroyed||(this.sharedRenderPipeline&&!this.props._sharedRenderPipeline&&this.sharedRenderPipeline.destroy(),this.destroyResource())}setBindings(n,r){let c=GD(s4(this.shaderLayout,n));for(let[u,d]of Object.entries(c)){let b=S0t(this.shaderLayout,u);if(b){switch(d||Qt.warn(`Unsetting binding "${u}" in render pipeline "${this.id}"`)(),b.type){case"uniform":if(!(d instanceof _v)&&!(d.buffer instanceof _v))throw new Error("buffer value");break;case"texture":if(!(d instanceof o2||d instanceof a2||d instanceof s2))throw new Error(`${this} Bad texture binding for ${u}`);break;case"sampler":Qt.warn(`Ignoring sampler ${u}`)();break;default:throw new Error(b.type)}this.bindings[u]=d}else{let w=this.shaderLayout.bindings.map(_=>`"${_.name}"`).join(", ");r?.disableWarnings||Qt.warn(`No binding "${u}" in render pipeline "${this.id}", expected one of ${w}`,d)()}}}draw(n){let r=n.renderPass,c=n.bindGroups?GD(n.bindGroups):n.bindings||this.bindings;return r.setPipeline(this),r.setBindings(c),r.setVertexArray(n.vertexArray),r.draw({parameters:n.parameters,topology:n.topology,isInstanced:n.isInstanced,vertexCount:n.vertexCount,indexCount:n.indexCount,instanceCount:n.instanceCount,firstVertex:n.firstVertex,firstIndex:n.firstIndex,firstInstance:n.firstInstance,baseVertex:n.baseVertex,transformFeedback:n.transformFeedback,uniforms:n.uniforms})}_areTexturesRenderable(n){let r=!0;for(let c of this.shaderLayout.bindings)E0t(n,c.name)||(Qt.warn(`Binding ${c.name} not found in ${this.id}`)(),r=!1);return r}_applyBindings(n,r){if(this._syncLinkStatus(),this.linkStatus!=="success")return;let{gl:c}=this.device;c.useProgram(this.handle);let u=0,d=0;for(let b of this.shaderLayout.bindings){let w=E0t(n,b.name);if(!w)throw new Error(`No value for binding ${b.name} in ${this.id}`);switch(b.type){case"uniform":let{name:_}=b,x=c.getUniformBlockIndex(this.handle,_);if(x===4294967295)throw new Error(`Invalid uniform block name ${_}`);if(c.uniformBlockBinding(this.handle,x,d),w instanceof _v)c.bindBufferBase(35345,d,w.handle);else{let M=w;c.bindBufferRange(35345,d,M.buffer.handle,M.offset||0,M.size||M.buffer.byteLength-(M.offset||0))}d+=1;break;case"texture":if(!(w instanceof o2||w instanceof a2||w instanceof s2))throw new Error("texture");let T;if(w instanceof o2)T=w.texture;else if(w instanceof a2)T=w;else if(w instanceof s2&&w.colorAttachments[0]instanceof o2)Qt.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),T=w.colorAttachments[0].texture;else throw new Error("No texture");c.activeTexture(33984+u),c.bindTexture(T.glTarget,T.handle),u+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${b.type}' not supported in WebGL`)}}}_applyUniforms(n){for(let r of this.shaderLayout.uniforms||[]){let{name:c,location:u,type:d,textureUnit:b}=r,w=n[c]??b;w!==void 0&&p0t(this.device.gl,u,d,w)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}}});var T0t,oue,C0t=Ve(()=>{Vr();rue();T0t=4,oue=class extends w${device;handle;vs;fs;linkStatus="pending";constructor(n,r){super(n,r),this.device=n,this.handle=r.handle||this.device.gl.createProgram(),this.vs=r.vs,this.fs=r.fs,r.varyings&&r.varyings.length>0&&this.device.gl.transformFeedbackVaryings(this.handle,r.varyings,r.bufferMode||35981),this._linkShaders()}destroy(){this.destroyed||(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.handle.destroyed=!0,this.destroyResource())}async _linkShaders(){let{gl:n}=this.device;if(n.attachShader(this.handle,this.vs.handle),n.attachShader(this.handle,this.fs.handle),Qt.time(T0t,`linkProgram for ${this.id}`)(),n.linkProgram(this.handle),Qt.timeEnd(T0t,`linkProgram for ${this.id}`)(),!this.device.features.has("compilation-status-async-webgl")){let c=this._getLinkStatus();this._reportLinkStatus(c);return}Qt.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),Qt.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let r=this._getLinkStatus();this._reportLinkStatus(r)}async _reportLinkStatus(n){switch(n){case"success":return;default:let r=n==="link-error"?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${r} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader();break;case"success":break}switch(this.fs?.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`${this} ${r} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader();break;case"success":break}let c=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${r} during ${n}: ${c}`),this)(),this.device.debug()}}_getLinkStatus(){let{gl:n}=this.device;return n.getProgramParameter(this.handle,35714)?(this._initializeSamplerUniforms(),n.validateProgram(this.handle),n.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}_initializeSamplerUniforms(){let{gl:n}=this.device;n.useProgram(this.handle);let r=0,c=n.getProgramParameter(this.handle,35718);for(let u=0;u1){let b=Int32Array.from({length:r.size},(w,_)=>u+_);return d.uniform1iv(n,b),u+r.size}return d.uniform1i(n,u),u+1}async _waitForLinkComplete(){let n=async u=>await new Promise(d=>setTimeout(d,u));if(!this.device.features.has("compilation-status-async-webgl")){await n(10);return}let{gl:c}=this.device;for(;;){if(c.getProgramParameter(this.handle,37297))return;await n(10)}}}});function inn(s,n){let r=n.sourceBuffer,c=n.destinationBuffer;s.gl.bindBuffer(36662,r.handle),s.gl.bindBuffer(36663,c.handle),s.gl.copyBufferSubData(36662,36663,n.sourceOffset??0,n.destinationOffset??0,n.size),s.gl.bindBuffer(36662,null),s.gl.bindBuffer(36663,null)}function rnn(s,n){let{sourceBuffer:r,byteOffset:c=0,destinationTexture:u,mipLevel:d=0,origin:b=[0,0,0],aspect:w="all",bytesPerRow:_,rowsPerImage:x,size:T}=n;if(w!=="all")throw new Error("copyBufferToTexture aspect is not supported in WebGL");u.writeBuffer(r,{byteOffset:c,bytesPerRow:_,rowsPerImage:x,mipLevel:d,x:b[0]??0,y:b[1]??0,z:b[2]??0,width:T[0],height:T[1],depthOrArrayLayers:T[2]})}function snn(s,n){let{sourceTexture:r,mipLevel:c=0,aspect:u="all",width:d=n.sourceTexture.width,height:b=n.sourceTexture.height,depthOrArrayLayers:w,origin:_=[0,0,0],destinationBuffer:x,byteOffset:T=0,bytesPerRow:M,rowsPerImage:L}=n;if(r instanceof Pa){r.readBuffer({x:_[0]??0,y:_[1]??0,z:_[2]??0,width:d,height:b,depthOrArrayLayers:w,mipLevel:c,aspect:u,byteOffset:T},x);return}if(u!=="all")throw new Error("aspect not supported in WebGL");if(c!==0||w!==void 0||M||L)throw new Error("not implemented");let{framebuffer:I,destroyFramebuffer:D}=A0t(r),F;try{let O=x,z=d||I.width,Z=b||I.height,H=UM(I.colorAttachments[0]),te=zle(H.texture.props.format),oe=te.format,ne=te.type;s.gl.bindBuffer(35051,O.handle),F=s.gl.bindFramebuffer(36160,I.handle),s.gl.readPixels(_[0],_[1],z,Z,oe,ne,T)}finally{s.gl.bindBuffer(35051,null),F!==void 0&&s.gl.bindFramebuffer(36160,F),D&&I.destroy()}}function onn(s,n){let{sourceTexture:r,destinationMipLevel:c=0,origin:u=[0,0],destinationOrigin:d=[0,0,0],destinationTexture:b}=n,{width:w=n.destinationTexture.width,height:_=n.destinationTexture.height}=n,{framebuffer:x,destroyFramebuffer:T}=A0t(r),[M=0,L=0]=u,[I,D,F]=d,O=s.gl.bindFramebuffer(36160,x.handle),z,Z;if(b instanceof a2)z=b,w=Number.isFinite(w)?w:z.width,_=Number.isFinite(_)?_:z.height,z._bind(0),Z=z.glTarget;else throw new Error("invalid destination");switch(Z){case 3553:case 34067:s.gl.copyTexSubImage2D(Z,c,I,D,M,L,w,_);break;case 35866:case 32879:s.gl.copyTexSubImage3D(Z,c,I,D,F,M,L,w,_);break;default:}z&&z._unbind(),s.gl.bindFramebuffer(36160,O),T&&x.destroy()}function A0t(s){if(s instanceof Pa){let{width:n,height:r,id:c}=s;return{framebuffer:s.device.createFramebuffer({id:`framebuffer-for-${c}`,width:n,height:r,colorAttachments:[s]}),destroyFramebuffer:!0}}return{framebuffer:s,destroyFramebuffer:!1}}var aue,P0t=Ve(()=>{Vr();EB();tue();aue=class extends y${device;handle=null;commands=[];constructor(n,r={}){super(n,r),this.device=n}_executeCommands(n=this.commands){for(let r of n)switch(r.name){case"copy-buffer-to-buffer":inn(this.device,r.options);break;case"copy-buffer-to-texture":rnn(this.device,r.options);break;case"copy-texture-to-buffer":snn(this.device,r.options);break;case"copy-texture-to-texture":onn(this.device,r.options);break;default:throw new Error(r.name)}}}});function L0t(s){switch(s){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"triangle-list":return 4;case"triangle-strip":return 5;default:throw new Error(s)}}function k0t(s){switch(s){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;default:throw new Error(s)}}var ERe=Ve(()=>{});var ann,cue,R0t=Ve(()=>{Vr();Qle();_B();ERe();bRe();ann=[1,2,4,8],cue=class extends v${device;handle=null;glParameters={};pipeline=null;bindings={};bindingsPipeline=null;vertexArray=null;constructor(n,r){super(n,r),this.device=n;let c=this.props.framebuffer,u=!c||c.handle===null;u&&n.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();let d;if(!r?.parameters?.viewport)if(!u&&c){let{width:b,height:w}=c;d=[0,0,b,w]}else{let[b,w]=n.getDefaultCanvasContext().getDrawingBufferSize();d=[0,0,b,w]}if(this.device.pushState(),this.setParameters({viewport:d,...this.props.parameters}),!u&&c?.colorAttachments.length){let b=c.colorAttachments.map((w,_)=>36064+_);this.device.gl.drawBuffers(b)}else u&&this.device.gl.drawBuffers([1029]);this.clear(),this.props.timestampQuerySet&&this.props.beginTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.beginTimestampIndex)}end(){this.destroyed||(this.props.timestampQuerySet&&this.props.endTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.endTimestampIndex),this.device.popState(),this.destroy())}pushDebugGroup(n){}popDebugGroup(){}insertDebugMarker(n){}executeBundles(n){throw new Error("Render bundles are only supported in WebGPU")}setParameters(n={}){let r={...this.glParameters};r.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(r.depthMask=!this.props.depthReadOnly),r.stencilMask=this.props.stencilReadOnly?0:1,r[35977]=this.props.discard,n.viewport&&(n.viewport.length>=6?(r.viewport=n.viewport.slice(0,4),r.depthRange=[n.viewport[4],n.viewport[5]]):r.viewport=n.viewport),n.scissorRect&&(r.scissorTest=!0,r.scissor=n.scissorRect),n.blendConstant&&(r.blendColor=n.blendConstant),n.stencilReference!==void 0&&(r[2967]=n.stencilReference,r[36003]=n.stencilReference),"colorMask"in n&&(r.colorMask=ann.map(c=>!!(c&n.colorMask))),this.glParameters=r,bv(this.device.gl,r)}setPipeline(n){this.pipeline=n}setBindings(n,r){if(!this.pipeline)throw new Error("RenderPass.setPipeline() must be called before setBindings()");this.bindings=GD(s4(this.pipeline.shaderLayout,n)),this.bindingsPipeline=this.pipeline}setVertexArray(n){this.vertexArray=n}draw(n){let r=this.pipeline,c=this.vertexArray;if(!r)throw new Error("RenderPass.setPipeline() must be called before draw()");if(!c)throw new Error("RenderPass.setVertexArray() must be called before draw()");if(r.shaderLayout.bindings.length>0&&this.bindingsPipeline!==r)throw new Error("RenderPass.setBindings() must be called after setPipeline() before draw()");r._syncLinkStatus();let{parameters:u=r.props.parameters,topology:d=r.props.topology,vertexCount:b,indexCount:w,instanceCount:_,isInstanced:x=!1,firstVertex:T=0,transformFeedback:M,uniforms:L=r.uniforms}=n,I=L0t(d),D=!!c.indexBuffer,F=c.indexBuffer?.glIndexType,O=w??b??0;if(r.linkStatus!=="success")return Qt.info(2,`RenderPipeline:${r.id}.draw() aborted - waiting for shader linking`)(),!1;if(!r._areTexturesRenderable(this.bindings))return Qt.info(2,`RenderPipeline:${r.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(r.handle),c.bindBeforeRender(this);let z=M;return z&&z.begin(r.props.topology),r._applyBindings(this.bindings,{disableWarnings:r.props.disableWarnings}),r._applyUniforms(L),h0t(this.device,u,this.glParameters,()=>{D&&x?this.device.gl.drawElementsInstanced(I,O,F,T,_||0):D?this.device.gl.drawElements(I,O,F,T):x?this.device.gl.drawArraysInstanced(I,T,b||0,_||0):this.device.gl.drawArrays(I,T,b||0),z&&z.end()}),c.unbindAfterRender(this),!0}drawIndirect(n,r=0){throw new Error("Indirect drawing is only supported in WebGPU")}drawIndexedIndirect(n,r=0){throw new Error("Indirect drawing is only supported in WebGPU")}beginOcclusionQuery(n){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let n={...this.glParameters},r=0;this.props.clearColors&&this.props.clearColors.forEach((c,u)=>{c&&this.clearColorBuffer(u,c)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(r|=16384,n.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=256,n.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=1024,n.clearStencil=this.props.clearStencil),r!==0&&yv(this.device.gl,n,()=>{this.device.gl.clear(r)})}clearColorBuffer(n=0,r=[0,0,0,0]){yv(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,n,r);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,n,r);break;case Float32Array:this.device.gl.clearBufferfv(6144,n,r);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}});var PV,I0t=Ve(()=>{Vr();P0t();R0t();PV=class extends _${device;handle=null;commandBuffer;constructor(n,r){super(n,r),this.device=n,this.commandBuffer=new aue(n,{id:this.id,userData:this.userData})}destroy(){this.destroyResource()}finish(){return this.destroy(),this.commandBuffer}beginRenderPass(n={}){return new cue(this.device,this._applyTimeProfilingToPassProps(n))}beginComputePass(n={}){throw new Error("ComputePass not supported in WebGL")}copyBufferToBuffer(n){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:n})}copyBufferToTexture(n){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:n})}copyTextureToBuffer(n){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:n})}copyTextureToTexture(n){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:n})}pushDebugGroup(n){}popDebugGroup(){}insertDebugMarker(n){}resolveQuerySet(n,r,c){throw new Error("resolveQuerySet is not supported in WebGL")}writeTimestamp(n,r){n.writeTimestamp(r)}}});function D0t(s){let{target:n,source:r,start:c=0,count:u=1}=s,d=r.length,b=u*d,w=0;for(let _=c;w{});function cnn(s){return Array.isArray(s)?new Float32Array(s):s}function lnn(s,n){if(!s||!n||s.length!==n.length||s.constructor!==n.constructor)return!1;for(let r=0;r{Vr();VL();lRe();B0t();lue=class s extends x${get[Symbol.toStringTag](){return"VertexArray"}device;handle;attributeInfosByLocation;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(n){return yPe()==="Chrome"}constructor(n,r){super(n,r),this.device=n,this.handle=this.device.gl.createVertexArray(),this.attributeInfosByLocation=new Array(this.maxVertexAttributes).fill(null);for(let c of Object.values(A$(r.shaderLayout,r.bufferLayout)))this.attributeInfosByLocation[c.location]=c}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(n){let r=n;if(r&&r.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,r?r.handle:null),this.indexBuffer=r,this.device.gl.bindVertexArray(null)}setBuffer(n,r){let c=r;if(c.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:u,type:d,stride:b,offset:w,normalized:_,integer:x,divisor:T}=this._getAccessor(n);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,c.handle),x?this.device.gl.vertexAttribIPointer(n,u,d,b,w):this.device.gl.vertexAttribPointer(n,u,d,_,b,w),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(n),this.device.gl.vertexAttribDivisor(n,T||0),this.attributes[n]=c,this.device.gl.bindVertexArray(null)}setConstantWebGL(n,r){this._enable(n,!1),this.attributes[n]=r}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let n=0;n{Vr();fue();ERe();uue=class extends E${device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(n,r){super(n,r),this.device=n,this.gl=n.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,r.buffers&&this.setBuffers(r.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(n="point-list"){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(k0t(n))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(n){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let[r,c]of Object.entries(n))this.setBuffer(r,c)})}setBuffer(n,r){let c=this._getVaryingIndex(n),{buffer:u,byteLength:d,byteOffset:b}=this._getBufferRange(r);if(c<0){this.unusedBuffers[n]=u,Qt.warn(`${this.id} unusedBuffers varying buffer ${n}`)();return}this.buffers[c]={buffer:u,byteLength:d,byteOffset:b},this.bindOnUse||this._bindBuffer(c,u,b,d)}getBuffer(n){if(N0t(n))return this.buffers[n]||null;let r=this._getVaryingIndex(n);return this.buffers[r]??null}bind(n=this.handle){if(typeof n!="function")return this.gl.bindTransformFeedback(36386,n),this;let r;return this._bound?r=n():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,r=n(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),r}unbind(){this.bind(null)}_getBufferRange(n){if(n instanceof _v)return{buffer:n,byteOffset:0,byteLength:n.byteLength};let{buffer:r,byteOffset:c=0,byteLength:u=n.buffer.byteLength}=n;return{buffer:r,byteOffset:c,byteLength:u}}_getVaryingIndex(n){if(N0t(n))return Number(n);for(let r of this.layout.varyings||[])if(n===r.name)return r.location;return-1}_bindBuffers(){for(let[n,r]of Object.entries(this.buffers)){let{buffer:c,byteLength:u,byteOffset:d}=this._getBufferRange(r);this._bindBuffer(Number(n),c,d,u)}}_unbindBuffers(){for(let n in this.buffers)this.gl.bindBufferBase(35982,Number(n),null)}_bindBuffer(n,r,c=0,u){let d=r&&r.handle;!d||u===void 0?this.gl.bindBufferBase(35982,n,d):this.gl.bindBufferRange(35982,n,d,c,u)}}});var hue,U0t=Ve(()=>{Vr();hue=class extends S${device;handle;_timestampPairs=[];_pendingReads=new Set;_occlusionQuery=null;_occlusionActive=!1;get[Symbol.toStringTag](){return"QuerySet"}constructor(n,r){if(super(n,r),this.device=n,r.type==="timestamp"){if(r.count<2)throw new Error("Timestamp QuerySet requires at least two query slots");this._timestampPairs=new Array(Math.ceil(r.count/2)).fill(null).map(()=>({activeQuery:null,completedQueries:[]})),this.handle=null}else{if(r.count>1)throw new Error("WebGL occlusion QuerySet can only have one value");let c=this.device.gl.createQuery();if(!c)throw new Error("WebGL query not supported");this.handle=c}Object.seal(this)}destroy(){if(!this.destroyed){this.handle&&this.device.gl.deleteQuery(this.handle);for(let n of this._timestampPairs){n.activeQuery&&(this._cancelPendingQuery(n.activeQuery),this.device.gl.deleteQuery(n.activeQuery.handle));for(let r of n.completedQueries)this._cancelPendingQuery(r),this.device.gl.deleteQuery(r.handle)}this._occlusionQuery&&(this._cancelPendingQuery(this._occlusionQuery),this.device.gl.deleteQuery(this._occlusionQuery.handle));for(let n of Array.from(this._pendingReads))this._cancelPendingQuery(n);this.destroyResource()}}isResultAvailable(n){return this.props.type==="timestamp"?n===void 0?this._timestampPairs.some((r,c)=>this._isTimestampPairAvailable(c)):this._isTimestampPairAvailable(this._getTimestampPairIndex(n)):this._occlusionQuery?this._pollQueryAvailability(this._occlusionQuery):!1}async readResults(n){let r=n?.firstQuery||0,c=n?.queryCount||this.props.count-r;if(this._validateRange(r,c),this.props.type==="timestamp"){let u=new Array(c).fill(0n),d=Math.floor(r/2),b=Math.floor((r+c-1)/2);for(let w=d;w<=b;w++){let _=await this._consumeTimestampPairResult(w),x=w*2,T=x+1;x>=r&&x=r&&T=this.props.count||r<=n)throw new Error("Timestamp duration range is out of bounds");if(n%2!==0||r!==n+1)throw new Error("WebGL timestamp durations require adjacent even/odd query indices");let c=await this._consumeTimestampPairResult(this._getTimestampPairIndex(n));return Number(c)/1e6}beginOcclusionQuery(){if(this.props.type!=="occlusion")throw new Error("Occlusion queries require an occlusion QuerySet");if(!this.handle)throw new Error("WebGL occlusion query is not available");if(this._occlusionActive)throw new Error("Occlusion query is already active");this.device.gl.beginQuery(35887,this.handle),this._occlusionQuery={handle:this.handle,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null},this._occlusionActive=!0}endOcclusionQuery(){if(!this._occlusionActive)throw new Error("Occlusion query is not active");this.device.gl.endQuery(35887),this._occlusionActive=!1}writeTimestamp(n){if(this.props.type!=="timestamp")throw new Error("Timestamp writes require a timestamp QuerySet");let r=this._getTimestampPairIndex(n),c=this._timestampPairs[r];if(n%2===0){if(c.activeQuery)throw new Error("Timestamp query pair is already active");let u=this.device.gl.createQuery();if(!u)throw new Error("WebGL query not supported");let d={handle:u,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null};this.device.gl.beginQuery(35007,u),c.activeQuery=d;return}if(!c.activeQuery)throw new Error("Timestamp query pair was ended before it was started");this.device.gl.endQuery(35007),c.completedQueries.push(c.activeQuery),c.activeQuery=null}_validateRange(n,r){if(n<0||r<0||n+r>this.props.count)throw new Error("Query read range is out of bounds")}_getTimestampPairIndex(n){if(n<0||n>=this.props.count)throw new Error("Query index is out of bounds");return Math.floor(n/2)}_isTimestampPairAvailable(n){let r=this._timestampPairs[n];return!r||r.completedQueries.length===0?!1:this._pollQueryAvailability(r.completedQueries[0])}_pollQueryAvailability(n){if(n.cancelled||this.destroyed)return n.result=0n,!0;if(n.result!==null||n.disjoint)return!0;if(!this.device.gl.getQueryParameter(n.handle,34919))return!1;let c=!!this.device.gl.getParameter(36795);return n.disjoint=c,n.result=c?0n:BigInt(this.device.gl.getQueryParameter(n.handle,34918)),!0}async _consumeTimestampPairResult(n){let r=this._timestampPairs[n];if(!r||r.completedQueries.length===0)throw new Error("Timestamp query pair has no completed result");let c=r.completedQueries.shift();try{return await this._consumeQueryResult(c)}finally{this.device.gl.deleteQuery(c.handle)}}_consumeQueryResult(n){return n.promise||(this._pendingReads.add(n),n.promise=new Promise((r,c)=>{n.resolve=r,n.reject=c;let u=()=>{if(n.pollRequestId=null,n.cancelled||this.destroyed){this._pendingReads.delete(n),n.promise=null,n.resolve=null,n.reject=null,r(0n);return}if(!this._pollQueryAvailability(n)){n.pollRequestId=this._requestAnimationFrame(u);return}this._pendingReads.delete(n),n.promise=null,n.resolve=null,n.reject=null,n.disjoint?c(new Error("GPU timestamp query was invalidated by a disjoint event")):r(n.result||0n)};u()})),n.promise}_cancelPendingQuery(n){if(this._pendingReads.delete(n),n.cancelled=!0,n.pollRequestId!==null&&(this._cancelAnimationFrame(n.pollRequestId),n.pollRequestId=null),n.resolve){let r=n.resolve;n.promise=null,n.resolve=null,n.reject=null,r(0n)}}_requestAnimationFrame(n){return requestAnimationFrame(n)}_cancelAnimationFrame(n){cancelAnimationFrame(n)}}});var due,z0t=Ve(()=>{Vr();due=class extends M${device;gl;handle;signaled;_signaled=!1;constructor(n,r={}){super(n,{}),this.device=n,this.gl=n.gl;let c=this.props.handle||this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE,0);if(!c)throw new Error("Failed to create WebGL fence");this.handle=c,this.signaled=new Promise(u=>{let d=()=>{let b=this.gl.clientWaitSync(this.handle,0,0);b===this.gl.ALREADY_SIGNALED||b===this.gl.CONDITION_SATISFIED?(this._signaled=!0,u()):setTimeout(d,1)};d()})}isSignaled(){if(this._signaled)return!0;let n=this.gl.getSyncParameter(this.handle,this.gl.SYNC_STATUS);return this._signaled=n===this.gl.SIGNALED,this._signaled}destroy(){this.destroyed||this.gl.deleteSync(this.handle)}}});function SRe(s){switch(s){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function G0t(s){switch(s){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}var j0t=Ve(()=>{});function $0t(s,n){let{sourceX:r=0,sourceY:c=0,sourceAttachment:u=0}=n||{},{target:d=null,sourceWidth:b,sourceHeight:w,sourceDepth:_,sourceFormat:x,sourceType:T}=n||{},{framebuffer:M,deleteFramebuffer:L}=W0t(s),{gl:I,handle:D}=M;b||=M.width,w||=M.height;let F=M.colorAttachments[u]?.texture;if(!F)throw new Error(`Invalid framebuffer attachment ${u}`);_=F?.depth||1,x||=F?.glFormat||6408,T||=F?.glType||5121,d=fnn(d,T,x,b,w,_);let O=Md.getDataType(d);T=T||m0t(O);let z=I.bindFramebuffer(36160,D);return I.readBuffer(36064+u),I.readPixels(r,c,b,w,x,T,d),I.readBuffer(36064),I.bindFramebuffer(36160,z||null),L&&M.destroy(),d}function V0t(s,n){let{target:r,sourceX:c=0,sourceY:u=0,sourceFormat:d=6408,targetByteOffset:b=0}=n||{},{sourceWidth:w,sourceHeight:_,sourceType:x}=n||{},{framebuffer:T,deleteFramebuffer:M}=W0t(s);w=w||T.width,_=_||T.height;let L=T;x=x||5121;let I=r;if(!I){let F=SRe(d),O=G0t(x),z=b+w*_*F*O;I=L.device.createBuffer({byteLength:z})}let D=s.device.createCommandEncoder();return D.copyTextureToBuffer({sourceTexture:s,width:w,height:_,origin:[c,u],destinationBuffer:I,byteOffset:b}),D.destroy(),M&&T.destroy(),I}function W0t(s){return s instanceof n4?{framebuffer:s,deleteFramebuffer:!1}:{framebuffer:unn(s),deleteFramebuffer:!0}}function unn(s,n){let{device:r,width:c,height:u,id:d}=s;return r.createFramebuffer({...n,id:`framebuffer-for-${d}`,width:c,height:u,colorAttachments:[s]})}function fnn(s,n,r,c,u,d){if(s)return s;n||=5121;let b=eue(n),w=Md.getTypedArrayConstructor(b),_=SRe(r);return new w(c*u*_)}var H0t=Ve(()=>{Vr();rue();j0t();xRe()});function q0t(s){let n=new Map;for(let r in s){let c=s[r];if(r<"a"){let u=n.get(c);n.set(c,u?`${u}, GL.${r}`:`GL.${r}`)}}return n}var X0t=Ve(()=>{});var MRe={};Oy(MRe,{WebGLDevice:()=>KM});function hnn(s,n,r){switch(r.length){case 1:s.gl.vertexAttrib1fv(n,r);break;case 2:s.gl.vertexAttrib2fv(n,r);break;case 3:s.gl.vertexAttrib3fv(n,r);break;case 4:s.gl.vertexAttrib4fv(n,r);break;default:}}function dnn(s,n,r){s.gl.vertexAttribI4iv(n,r)}function pnn(s,n,r){s.gl.vertexAttribI4uiv(n,r)}function gnn(s,n){if(!s||!n||s.length!==n.length||s.constructor!==n.constructor)return!1;for(let r=0;r{Vr();aRe();W1t();cRe();X1t();n0t();i0t();r0t();s0t();nRe();EB();a0t();Hle();u0t();d0t();tue();$le();M0t();C0t();I0t();O0t();F0t();U0t();z0t();H0t();_B();Qle();SV();X0t();KM=class s extends A3{static getDeviceFromContext(n){return n?n.luma?.device??null:null}type="webgl";handle;features;limits;info;canvasContext;preferredColorFormat="rgba8unorm";preferredDepthFormat="depth24plus";commandEncoder;lost;_resolveContextLost;_isLost=!1;gl;_glKeyByValue=null;_constants;extensions;_polyfilled=!1;spectorJS;get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(n){switch(n){case"unorm8x4-bgra":return!1;default:return!0}}constructor(n){super({...n,id:n.id||o0t("webgl-device")});let r=A3._getCanvasContextProps(n);if(!r)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let c=r.canvas?.gl??null,u=s.getDeviceFromContext(c);if(u)throw new Error(`WebGL context already attached to device ${u.id}`);this.canvasContext=new Vle(this,r),this.lost=new Promise(T=>{this._resolveContextLost=T});let d={...n.webgl};r.alphaMode==="premultiplied"&&(d.premultipliedAlpha=!0),n.powerPreference!==void 0&&(d.powerPreference=n.powerPreference),n.failIfMajorPerformanceCaveat!==void 0&&(d.failIfMajorPerformanceCaveat=n.failIfMajorPerformanceCaveat);let w=this.props._handle||V1t(this.canvasContext.canvas,{onContextLost:T=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."}),onContextRestored:T=>{console.log("WebGL context restored")}},d);if(!w)throw new Error("WebGL context creation failed");if(u=s.getDeviceFromContext(w),u){if(n._reuseDevices)return Qt.log(1,`Not creating a new Device, instead returning a reference to Device ${u.id} already attached to WebGL context`,u)(),this.canvasContext.destroy(),u._reused=!0,u;throw new Error(`WebGL context already attached to device ${u.id}`)}this.handle=w,this.gl=w,this.spectorJS=I1t({...this.props,gl:this.handle});let _=EV(this.handle);_.device=this,_.extensions||(_.extensions={}),this.extensions=_.extensions,this.info=H1t(this.gl,this.extensions),this.limits=new jle(this.gl),this.features=new Gle(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new wv(this.gl,{log:(...T)=>Qt.log(1,...T)()}).trackState(this.gl,{copyState:!1}),(n.debug||n.debugWebGL)&&(this.gl=k1t(this.gl,{debugWebGL:!0,traceWebGL:n.debugWebGL}),Qt.warn("WebGL debug mode activated. Performance reduced.")()),n.debugWebGL&&(Qt.level=Math.max(Qt.level,1)),this.commandEncoder=new PV(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}destroy(){if(!this.props._reuseDevices&&!this._reused){this._isLost=!0,this.commandEncoder?.destroy();let n=EV(this.handle);n.device=null}}get isLost(){return this._isLost||this.gl.isContextLost()}createCanvasContext(n){throw new Error("WebGL only supports a single canvas")}createPresentationContext(n){return new Wle(this,n||{})}createBuffer(n){let r=this._normalizeBufferProps(n);return new _v(this,r)}createTexture(n){return new a2(this,n)}createExternalTexture(n){throw new Error("ExternalTexture is not available on WebGL")}createSampler(n){return new Jle(this,n)}createShader(n){return new Xle(this,n)}createFramebuffer(n){return new s2(this,n)}createVertexArray(n){return new lue(this,n)}createTransformFeedback(n){return new uue(this,n)}createQuerySet(n){return new hue(this,n)}createFence(){return new due(this)}createRenderPipeline(n){return new sue(this,n)}_createSharedRenderPipelineWebGL(n){return new oue(this,n)}createComputePipeline(n){throw new Error("ComputePipeline not supported in WebGL")}createRenderBundleEncoder(n){throw new Error("Render bundles are only supported in WebGPU")}createCommandEncoder(n={}){return new PV(this,n)}submit(n){let r=null;n||({submittedCommandEncoder:r,commandBuffer:n}=this._finalizeDefaultCommandEncoderForSubmit());try{n._executeCommands(),r&&r.resolveTimeProfilingQuerySet().then(()=>{this.commandEncoder._gpuTimeMs=r._gpuTimeMs}).catch(()=>{})}finally{n.destroy()}}writeBufferViaCommandEncoder(n,r,c,u=0){r.write(c,u)}_finalizeDefaultCommandEncoderForSubmit(){let n=this.commandEncoder,r=n.finish();return this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:n.props.id,timeProfilingQuerySet:n.getTimeProfilingQuerySet()}),{submittedCommandEncoder:n,commandBuffer:r}}readPixelsToArrayWebGL(n,r){return $0t(n,r)}readPixelsToBufferWebGL(n,r){return V0t(n,r)}setParametersWebGL(n){bv(this.gl,n)}getParametersWebGL(n){return Ble(this.gl,n)}withParametersWebGL(n,r){return yv(this.gl,n,r)}resetWebGL(){Qt.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),U1t(this.gl)}_getDeviceSpecificTextureFormatCapabilities(n){return Q1t(this.gl,n,this.extensions)}loseDevice(){let n=!1,c=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return c&&(n=!0,c.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),n}pushState(){wv.get(this.gl).push()}popState(){wv.get(this.gl).pop()}getGLKey(n,r){let c=this._getGLKeyByValue().get(Number(n));return c||(r?.emptyIfUnknown?"":String(n))}getGLKeys(n){let r={emptyIfUnknown:!0};return Object.entries(n).reduce((c,[u,d])=>(c[`${u}:${this.getGLKey(u,r)}`]=`${d}:${this.getGLKey(d,r)}`,c),{})}_getGLKeyByValue(){return this._glKeyByValue??=q0t(this.gl),this._glKeyByValue}setConstantAttributeWebGL(n,r){let c=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(c).fill(null);let u=this._constants[n];switch(u&&gnn(u,r)&&Qt.info(1,`setConstantAttributeWebGL(${n}) could have been skipped, value unchanged`)(),this._constants[n]=r,r.constructor){case Float32Array:hnn(this,n,r);break;case Int32Array:dnn(this,n,r);break;case Uint32Array:pnn(this,n,r);break;default:throw new Error("constant")}}getExtension(n){return vv(this.gl,n,this.extensions),this.extensions}_setWebGLDebugMetadata(n,r,c){n.luma=r;let u={props:c.spector,id:c.spector.id};n.__SPECTOR_Metadata=u}}});function mnn(s){return typeof WebGL2RenderingContext<"u"&&s instanceof WebGL2RenderingContext?!0:!!(s&&typeof s.createVertexArray=="function")}function Y0t(s){return{...s,debug:s.debug??A3.defaultProps.debug,debugWebGL:s.debugWebGL??A3.defaultProps.debugWebGL,debugSpectorJS:s.debugSpectorJS??!!Qt.get("debug-spectorjs")}}async function Z0t(s){let n=[];(s.debugWebGL||s.debug)&&n.push(L1t()),s.debugSpectorJS&&n.push(R1t(s));let r=await Promise.allSettled(n);for(let c of r)c.status==="rejected"&&Qt.error(`Failed to initialize debug libraries ${c.reason}`)()}var LV,TRe,kV,K0t=Ve(()=>{Vr();A1t();nRe();LV=1,TRe=class extends u${type="webgl";enforceWebGL2(n){C1t(n)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(n){return typeof WebGL2RenderingContext<"u"&&n instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext&&Qt.warn("WebGL1 is not supported",n)(),!1)}async attach(n,r={}){let{WebGLDevice:c}=await Promise.resolve().then(()=>(pue(),MRe));if(n instanceof c)return n;let u=c.getDeviceFromContext(n);if(u)return u;if(!mnn(n))throw new Error("Invalid WebGL2RenderingContext");r=Y0t(r),await Z0t(r);let d=r.createCanvasContext===!0?{}:r.createCanvasContext;return new c({...r,_handle:n,createCanvasContext:{canvas:n.canvas,autoResize:!1,...d}})}async create(n={}){let{WebGLDevice:r}=await Promise.resolve().then(()=>(pue(),MRe));n=Y0t(n),await Z0t(n);try{let c=new r(n);Qt.groupCollapsed(LV,`WebGLDevice ${c.id} created`)();let u=`${c._reused?"Reusing":"Created"} device with WebGL2 ${c.props.debug?"debug ":""}context: ${c.info.vendor}, ${c.info.renderer} for canvas: ${c.canvasContext.id}`;return Qt.probe(LV,u)(),Qt.table(LV,c.info)(),c}finally{Qt.groupEnd(LV)(),Qt.info(LV,"%cWebGL call tracing: luma.log.set('debug-webgl') ","color: white; background: blue; padding: 2px 6px; border-radius: 3px;")()}}};kV=new TRe});var fue=Ve(()=>{K0t();pue();Hle()});function vue(s){return obt.test(s)}function _ue(s){return abt.test(s)}function cbt(s){let n=obt.exec(s),r=abt.exec(s),c=n?.[1]??r?.[1]??s;try{hl.getVertexFormatInfo(c)}catch{throw new Error(`Unsupported GPUVector format ${s}`)}return c}function O3(s){let n=cbt(s),r=vue(s),c=_ue(s),u=hl.getVertexFormatInfo(n),d=u.type,b=u.normalized,w=ynn(d,b);return{format:s,elementFormat:n,vertexList:r,valueList:c,type:d,signedDataType:xnn(n,d),primitiveType:w,components:u.components,byteLength:u.byteLength,integer:u.integer,signed:u.signed,normalized:b,...u.webglOnly?{webglOnly:!0}:{}}}function ynn(s,n){if(n)return"f32";switch(s){case"float32":return"f32";case"float16":return"f16";case"uint8":case"uint16":case"uint32":return"u32";case"sint8":case"sint16":case"sint32":return"i32";default:throw new Error(`Unsupported GPUVector component type ${s}`)}}function xnn(s,n){if(s==="unorm10-10-10-2")return"uint32";switch(n){case"unorm8":return"uint8";case"snorm8":return"sint8";case"unorm16":return"uint16";case"snorm16":return"sint16";default:return n}}var obt,abt,yue=Ve(()=>{Vr();obt=/^vertex-list<([^<>]+)>$/,abt=/^value-list<([^<>]+)>$/});function PRe(s,n){if(!Number.isSafeInteger(s)||s<0)throw new Error(`${n} must be a non-negative safe integer`)}var N3,LRe=Ve(()=>{Vr();N3=class{buffer;format;length;byteOffset;byteStride;constructor(n){let r=hl.getVertexFormatInfo(n.format).byteLength,c=n.byteOffset??0,u=n.byteStride??r;if(PRe(n.length,"GPUDataView length"),PRe(c,"GPUDataView byteOffset"),PRe(u,"GPUDataView byteStride"),un.buffer.byteLength)throw new Error("GPUDataView exceeds its backing buffer byte length");this.buffer=n.buffer,this.format=n.format,this.length=n.length,this.byteOffset=c,this.byteStride=u}get elementByteLength(){return hl.getVertexFormatInfo(this.format).byteLength}get byteLength(){return this.length===0?0:(this.length-1)*this.byteStride+this.elementByteLength}}});function Eue(s){return!!(s&&typeof s=="object"&&s.type==="struct")}function ubt(s,n){let r=Object.entries(s);if(r.length===0)throw new Error("GPUData struct format must declare at least one field");return n==="packed"?Enn(r):Snn(r)}function Enn(s){let n=[],r=0,c=0;for(let[u,d]of s){let b=hl.getVertexFormatInfo(d);if(b.webglOnly)throw new Error(`Packed GPUData struct field "${u}" uses WebGL-only format ${d}`);r=lbt(r,Math.min(4,b.byteLength)),n.push([u,Object.freeze({format:d,byteOffset:r,byteLength:b.byteLength})]),r+=b.byteLength,c+=b.components}return Object.freeze({type:"struct",layout:"packed",fields:Object.freeze(Object.fromEntries(n)),components:c,byteStride:lbt(r,4),rowByteLength:r})}function Snn(s){let n=Object.fromEntries(s.map(([b,w])=>[b,Mnn(w)])),r=o4(n,{layout:"wgsl-storage"}),c=[],u=0,d=0;for(let[b,w]of s){let _=hl.getVertexFormatInfo(w),x=r.fields[b].offset*4;c.push([b,Object.freeze({format:w,byteOffset:x,byteLength:_.byteLength})]),u=Math.max(u,x+_.byteLength),d+=_.components}return Object.freeze({type:"struct",layout:"wgsl-storage",fields:Object.freeze(Object.fromEntries(c)),components:d,byteStride:r.byteLength,rowByteLength:u})}function Mnn(s){let n=hl.getVertexFormatInfo(s);switch(n.type){case"float32":return xue("f32",n.components);case"sint32":return xue("i32",n.components);case"uint32":return xue("u32",n.components);default:{let r=Math.ceil(n.byteLength/4);return xue("u32",r)}}}function xue(s,n){return n===1?s:`vec${n}<${s}>`}function lbt(s,n){return Math.ceil(s/n)*n}var fbt=Ve(()=>{Vr()});var kRe,RRe,SB,IRe=Ve(()=>{LRe();fbt();yue();kRe=class{buffer;ownsDataBuffer;constructor(n,r){this.buffer=n,this.ownsDataBuffer=r}get ownsBuffer(){return this.ownsDataBuffer}transferBufferOwnership(n){if(n.buffer!==this.buffer)throw new Error("GPUData ownership can only be transferred to the same buffer");n.ownsDataBuffer=this.ownsDataBuffer,this.ownsDataBuffer=!1}destroy(){this.ownsDataBuffer&&(this.buffer.destroy(),this.ownsDataBuffer=!1)}},RRe=class extends kRe{dataType;format;length;valueLength;stride;byteOffset;byteStride;rowByteLength;readbackMetadata;valueOffsets;nullBitmap;valueByteLength;constructor(n){let{buffer:r,format:c,length:u,valueLength:d,stride:b,byteOffset:w=0,byteStride:_,rowByteLength:x,ownsBuffer:T=!1,readbackMetadata:M,valueOffsets:L,nullBitmap:I,valueByteLength:D,dataType:F}=n;super(r,T);let O;c?typeof c=="string"?O=c:O=ubt(c,n.layout??"wgsl-storage"):O=void 0;let z=Eue(O)?O:void 0,Z=typeof O=="string"?O3(O):void 0;if(this.dataType=F,this.format=O,this.length=u,this.valueLength=d??u,this.stride=b??Z?.components??z?.components??_??x??1,this.byteOffset=w,this.rowByteLength=x??z?.rowByteLength??Z?.byteLength??_??this.stride,this.byteStride=_??z?.byteStride??this.rowByteLength,z){if(this.rowByteLengthc.format!==n))throw new Error("GPUVector data chunks must share the declared format")}var c2,dbt=Ve(()=>{IRe();yue();c2=class{name;dataType;format;length;valueLength;stride;byteOffset;byteStride;rowByteLength;bufferLayout;data=[];device;bufferProps;isAppendable=!1;ownsDataChunks=!0;ownedVectors=[];appendableByteLength=0;constructor(n){switch(n.type){case"buffer":{let{name:r,buffer:c,format:u,length:d,valueLength:b=d,byteOffset:w=0,ownsBuffer:_=!1}=n,{stride:x,byteStride:T,rowByteLength:M}=hbt(n);this.name=r,this.dataType=n.dataType,this.format=u,this.length=d,this.valueLength=b,this.stride=x,this.byteOffset=w,this.byteStride=T,this.rowByteLength=M,this.data.push(new SB({buffer:c,format:u,length:d,valueLength:b,stride:x,byteOffset:w,byteStride:T,rowByteLength:M,ownsBuffer:_,dataType:n.dataType}));return}case"interleaved":{let{name:r,buffer:c,format:u,length:d,valueLength:b=d,byteOffset:w=0,byteStride:_,attributes:x,ownsBuffer:T=!1}=n;this.name=r,this.dataType=n.dataType,this.format=u,this.length=d,this.valueLength=b,this.stride=_,this.byteOffset=w,this.byteStride=_,this.rowByteLength=_,this.bufferLayout={name:r,byteStride:_,attributes:x},this.data.push(new SB({buffer:c,format:u,length:d,valueLength:b,stride:_,byteOffset:w,byteStride:_,rowByteLength:_,ownsBuffer:T,dataType:n.dataType}));return}case"data":{let r=n.format??Tnn(n.data),c=r?O3(r):void 0,{name:u,data:d,stride:b=d[0]?.stride??c?.components??1,valueLength:w=d.reduce((L,I)=>L+I.valueLength,0),byteStride:_=d[0]?.byteStride??c?.byteLength,rowByteLength:x=d[0]?.rowByteLength??c?.byteLength,bufferLayout:T,ownsData:M=!1}=n;if(_===void 0||x===void 0)throw new Error("GPUVector requires format or explicit byte layout metadata");r&&Cnn(d,r),this.name=u,this.dataType=n.dataType,this.format=r,this.length=d.reduce((L,I)=>L+I.length,0),this.valueLength=w,this.stride=b,this.byteOffset=d.length===1?d[0].byteOffset:0,this.byteStride=_,this.rowByteLength=x,this.bufferLayout=T,this.ownsDataChunks=M,this.data.push(...d);return}case"appendable":{let{name:r,device:c,format:u,valueLength:d=0,bufferProps:b}=n,{stride:w,byteStride:_,rowByteLength:x}=hbt(n);this.name=r,this.dataType=n.dataType,this.format=u,this.length=0,this.valueLength=d,this.stride=w,this.byteOffset=0,this.byteStride=_,this.rowByteLength=x,this.device=c,this.bufferProps=b,this.isAppendable=!0;return}}}get ownsBuffer(){return this.ownsDataChunks&&this.data.some(n=>n.ownsBuffer)||this.ownedVectors.some(n=>n.ownsBuffer)}get capacityRows(){return this.isAppendable?this.length:void 0}get appendedByteLength(){return this.appendableByteLength}addData(n){if(this.format&&n.format!==this.format)throw new Error("GPUVector.addData() requires matching formats");if(n.byteStride!==this.byteStride)throw new Error("GPUVector.addData() requires matching byteStride");if(n.rowByteLength!==this.rowByteLength)throw new Error("GPUVector.addData() requires matching rowByteLength");return this.data.push(n),this.length+=n.length,this.valueLength+=n.valueLength,this}appendDataChunk(n,r=this.appendableByteLength+n.buffer.byteLength){if(!this.isAppendable)throw new Error("GPUVector.appendDataChunk() requires appendable vector storage");if(this.format&&n.format!==this.format)throw new Error("GPUVector.appendDataChunk() requires matching formats");if(n.byteStride!==this.byteStride||n.rowByteLength!==this.rowByteLength)throw new Error("GPUVector.appendDataChunk() requires matching byte layout metadata");return this.data.push(n),this.length+=n.length,this.valueLength+=n.valueLength,this.appendableByteLength=r,this}resetLastBatch(){if(!this.isAppendable)throw new Error("GPUVector.resetLastBatch() requires appendable vector storage");for(let n of this.data.splice(0))n.destroy();return this.length=0,this.valueLength=0,this.appendableByteLength=0,this}retainOwnedVectors(n){return this.ownedVectors.push(...n),this}transferBufferOwnership(n){let r=this.data[0],c=n.data[0];if(!r||!c||r.buffer!==c.buffer)throw new Error("GPUVector ownership can only be transferred to the same buffer");r.transferBufferOwnership(c)}destroy(){if(this.ownsDataChunks)for(let n of this.data)n.destroy();for(let n of this.ownedVectors.splice(0))n.destroy()}}});var DRe=Ve(()=>{IRe();LRe();dbt();yue()});var BRe,lg,OV=Ve(()=>{Vr();BRe=class{poolSize=20;bufferPools;constructor(){this.bufferPools=new Map}createOrReuse(n,r){if(r>n.limits.maxBufferSize)throw new Error(`Buffer pool cannot allocate ${r} bytes: device.limits.maxBufferSize is ${n.limits.maxBufferSize}`);let c=this.bufferPools.get(n),u=c?c.findIndex(b=>b.byteLength>=r):-1;if(u<0)return n.createBuffer({usage:cs.VERTEX|cs.STORAGE|cs.COPY_DST|cs.COPY_SRC,byteLength:r});let[d]=c.splice(u,1);return d}recycle(n){let r=n.device;this.bufferPools.has(r)||this.bufferPools.set(r,[]);let c=this.bufferPools.get(r),u=c.findIndex(d=>d.byteLength>n.byteLength);u<0?c.push(n):c.splice(u,0,n),this.purge()}purge(){for(let[n,r]of this.bufferPools){let c=n.isLost?0:this.poolSize;for(;r.length>c;)r.shift().destroy();r.length===0&&this.bufferPools.delete(n)}}},lg=new BRe});function Ann(s,n,r,c){let{ValueType:u,size:d,offset:b,stride:w}=s,_=w/u.BYTES_PER_ELEMENT,x=b/u.BYTES_PER_ELEMENT,T=c-r;if(_===d){let L=x+r*_;return n.subarray(L,L+T*d)}let M=new u(T*d);for(let L=0;L0)throw new Error(`GPUDataEvaluator requires exactly one GPUData chunk for "${s.name}"`);return n}function knn(s){let n=[];return gbt(s,n,{byteOffset:0}),n}function gbt(s,n,r){let c=s.source;if(c&&!(c instanceof fc)&&c.name==="interleave"){for(let u of Object.values(c.inputs))u instanceof fc&&gbt(u,n,r);return}n.push({attribute:s.id??s.toString(),format:mbt(s.type,s.size,s.normalized),byteOffset:r.byteOffset}),r.byteOffset+=s.ValueType.BYTES_PER_ELEMENT*s.size}function mbt(s,n,r=!1){if(n<1||n>4)throw new Error(`Cannot synthesize a GPUVector vertex format with ${n} components`);let c=s;if(r)switch(s){case"uint8":c="unorm8";break;case"sint8":c="snorm8";break;case"uint16":c="unorm16";break;case"sint16":c="snorm16";break;case"float32":c="float32";break;default:throw new Error(`Unsupported normalized vertex format for ${s}`)}return(c==="uint8"||c==="sint8"||c==="uint16"||c==="sint16"||c==="unorm8"||c==="snorm8"||c==="unorm16"||c==="snorm16")&&n===3?`${c}x3-webgl`:`${c}${n===1?"":`x${n}`}`}function Rnn(s,n,r=!1){return n>=1&&n<=4?mbt(s,n,r):void 0}var fc,F3=Ve(()=>{Vr();Ql();DRe();OV();fc=class s{static get bufferPoolSize(){return lg.poolSize}static set bufferPoolSize(n){if(!Number.isSafeInteger(n)||n<0)throw new Error("GPUDataEvaluator.bufferPoolSize must be a non-negative safe integer");lg.poolSize=n,lg.purge()}type;size;get offset(){return this._offset}get stride(){return this._stride}normalized;isConstant;length;get byteLength(){return this._byteLength}ValueType;source=null;format;_id;_destroyed=!1;_value;_offset;_stride;_byteLength;_gpuVector;_bufferOwnership="owned";_targetBuffer;static fromArray(n,{type:r,size:c=1,offset:u=0,stride:d=0,normalized:b=!1}){let w=r,_;if(Array.isArray(n)){w=w||"float32";let T=KL(w);_=new T(n)}else n instanceof Float64Array?(w="uint32",c*=2,u*=2,d*=2,_=new Uint32Array(n.buffer,n.byteOffset,n.byteLength/4)):(w=w||yce(n),_=n);let x=`<${w} * ${c}>`;return new s({id:x,type:w,size:c,offset:u,stride:d,normalized:b,value:_})}static fromConstant(n,r="float32"){let c=KL(r),u;return Array.isArray(n)?u=`[${n.join(",")}]`:(u=String(n),n=[n]),new s({id:u,isConstant:!0,type:r,size:n.length,value:new c(n)})}static fromGPUData(n,r={}){Pnn(n);let c=new N3({buffer:n.buffer,format:n.format,length:n.length,byteOffset:n.byteOffset,byteStride:n.byteStride});return new s({...pbt(c),id:r.id,gpuData:n})}static fromGPUDataView(n,r={}){return new s({...pbt(n),id:r.id,buffer:n.buffer})}constructor(n){let{id:r,value:c,buffer:u,gpuData:d,format:b,source:w=null,isConstant:_=!1}=n;if(!w&&!c&&!u&&!d)throw new Error("GPUDataEvaluator must have a value source");let{type:x,size:T,offset:M,stride:L,normalized:I,length:D}=n;if(w instanceof s?(x=x??w.type,T=T??w.size,M=M??w.offset,L=L??w.stride,I=I??w.normalized,D=D??w.length):(T=T??1,M=M??0,I=I??!1,D=_?1:D),!x)throw new Error("GPUDataEvaluator: type not defined");if(this._id=r,this.type=x,this.size=T,this.ValueType=KL(this.type),this._offset=M,this._stride=L||this.ValueType.BYTES_PER_ELEMENT*T,this.normalized=I,this.source=w,this.format=b,D===void 0)if(_)D=1;else{if(!c)throw new Error("GPUDataEvaluator: length not defined");D=Math.ceil(c.byteLength/this.stride)}this.isConstant=_,this.length=D;let F=this.ValueType.BYTES_PER_ELEMENT*this.size;this._byteLength=D===0?0:(D-1)*this.stride+F,this._value=c,this._bufferOwnership=w instanceof s||u||d?"borrowed":"owned",d?this._gpuVector=new c2({type:"data",name:this._id??"data",format:d.format,data:[d],stride:d.stride,byteStride:d.byteStride,rowByteLength:d.rowByteLength}):u&&(this._gpuVector=this.createGPUVectorView({buffer:u,name:this._id,format:this.format}))}get value(){return this._value||(this.source instanceof s?this.source.value:void 0)}get evaluated(){return!!this._gpuVector}get id(){return this._id}get gpuVector(){if(!this._gpuVector)throw new Error(`${this} not evaluated`);return this._gpuVector}get buffer(){return Sue(this.gpuVector)}setTargetBuffer({buffer:n,byteOffset:r=0,byteStride:c=this.stride}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)throw new Error(`GPUDataEvaluator ${this} already evaluated`);if(!this.source||this.source instanceof s)throw new Error("GPUDataEvaluator target buffers require a deferred operation source");this._targetBuffer={buffer:n,byteOffset:r,byteStride:c}}async evaluate(n,r={}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let c;if(this.source instanceof s){let u=await this.source.evaluate(n);return this._gpuVector=this.createGPUVectorView({...r,buffer:Sue(u)}),this._gpuVector}if(c=this._getEvaluationBuffer(n),this._value)c.write(this._value);else{let u=await this.source.execute(n,c);if(!u.success)throw u.error||new Error(`${this.source} evaluation failed`);u.value&&(this._value=u.value)}return this._gpuVector=this.createGPUVectorView({...r,buffer:c}),this._gpuVector}evaluateSync(n,r={}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let c;if(this.source instanceof s){let u=this.source.evaluateSync(n);return this._gpuVector=this.createGPUVectorView({...r,buffer:Sue(u)}),this._gpuVector}if(c=this._getEvaluationBuffer(n),this._value)c.write(this._value);else{let u=this.source.executeSync(n,c);if(!u.success)throw u.error||new Error(`${this.source} evaluation failed`);u.value&&(this._value=u.value)}return this._gpuVector=this.createGPUVectorView({...r,buffer:c}),this._gpuVector}createGPUVectorView(n){let r=n.name??this._id??"vector",c=n.format??this.format??Rnn(this.type,this.size,this.normalized);if(n.interleaved){let u=typeof n.interleaved=="object"&&n.interleaved.attributes?n.interleaved.attributes:knn(this);return new c2({type:"interleaved",name:r,buffer:n.buffer,format:n.format??this.format,length:this.length,byteOffset:this.offset,byteStride:this.stride,attributes:u,ownsBuffer:!1})}return new c2({type:"buffer",name:r,buffer:n.buffer,format:c,length:this.length,stride:this.size,byteOffset:this.offset,byteStride:this.stride,rowByteLength:this.ValueType.BYTES_PER_ELEMENT*this.size,ownsBuffer:!1})}_getEvaluationBuffer(n){let r=this._targetBuffer;if(!r)return lg.createOrReuse(n,this.byteLength);if(r.buffer.device!==n)throw new Error("GPUDataEvaluator target buffer belongs to a different device");let c=this.ValueType.BYTES_PER_ELEMENT*this.size,u=this.length===0?0:(this.length-1)*r.byteStride+c;if(r.byteOffset+u>r.buffer.byteLength)throw new Error("GPUDataEvaluator target buffer is too small for the output layout");return this._offset=r.byteOffset,this._stride=r.byteStride,this._byteLength=u,this._bufferOwnership="borrowed",this._targetBuffer=void 0,r.buffer}async readValue(n=0,r){let{ValueType:c}=this,{size:u,offset:d,stride:b,length:w}=this,_=c.BYTES_PER_ELEMENT*u;if(r=r??w,n=Math.max(0,Math.min(w,n)),r=Math.max(n,Math.min(w,r)),this._value)return Ann(this,this._value,n,r);let x=r-n;if(x===0)return new c(0);let T=d+n*b,M=b===_?x*_:(x-1)*b+_,L=await this.buffer.readAsync(T,M),I=new c(L.buffer,L.byteOffset,L.byteLength/c.BYTES_PER_ELEMENT);if(b===_)return I;let D=new Uint8Array(_*x);for(let F=0;F{MB={add:{arity:2,symbol:"arithmetic_add"},subtract:{arity:2,symbol:"arithmetic_subtract"},multiply:{arity:2,symbol:"arithmetic_multiply"},divide:{arity:2,symbol:"arithmetic_divide"},pow:{arity:2,symbol:"pow"},sqrt:{arity:1,symbol:"sqrt"},abs:{arity:1,symbol:"abs"},sin:{arity:1,symbol:"sin"},cos:{arity:1,symbol:"cos"},tan:{arity:1,symbol:"arithmetic_tan"},exp:{arity:1,symbol:"exp"},log:{arity:1,symbol:"log"}}});function kbt(s,{operations:n,inputs:r}){switch(s.kind){case"input":if(!(s.name in r))throw new Error(`Unknown expression input '${s.name}'`);return;case"literal":if(Array.isArray(s.value)){for(let c of s.value)if(!Number.isFinite(c))throw new Error(`Expression literal array must contain only finite values, got ${c}`)}else if(!Number.isFinite(s.value))throw new Error(`Expression literal must be finite, got ${s.value}`);return;case"call":{let c=n[s.op];if(!c)throw new Error(`Unknown expression op '${s.op}'`);if(s.args.length!==c.arity)throw new Error(`Expression op '${s.op}' expects ${c.arity} args, got ${s.args.length}`);for(let u of s.args)kbt(u,{operations:n,inputs:r});return}default:{let c=s;throw new Error(`Unsupported expression node ${c.kind}`)}}}function Cue(s,n){return kbt(s,n),Rbt(s,n)}function Rbt(s,n){switch(s.kind){case"input":{let r=n.inputs[s.name];return n.laneIndexRbt(u,n));return n.formatCall(r.symbol,c)}default:{let r=s;throw new Error(`Unsupported expression node ${r.kind}`)}}}var URe=Ve(()=>{});function hp(s,n,r=!1){if(r)return n===1?"float":`vec${n}`;switch(s){case"uint8":case"uint16":case"uint32":return n===1?"uint":`uvec${n}`;case"sint8":case"sint16":case"sint32":return n===1?"int":`ivec${n}`;default:return n===1?"float":`vec${n}`}}function Aue(s,n,r=!1){let c;if(r)switch(s){case"uint8":c="unorm8";break;case"sint8":c="snorm8";break;case"uint16":c="unorm16";break;case"sint16":c="snorm16";break;case"float32":c="float32";break;default:throw new Error(`Unsupported normalized vertex format for ${s}`)}else c=s;return n===1?c:n===3&&!c.startsWith("float32")&&!c.endsWith("32")?`${c}x3-webgl`:`${c}x${n}`}function JM(s){switch(s[0]){case"u":return"0u";case"s":return"0";default:return"0."}}function Ibt(s,n){switch(s){case"uint8":case"uint16":case"uint32":return`${Math.trunc(n)}u`;case"sint8":case"sint16":case"sint32":return`${Math.trunc(n)}`;default:return Number.isInteger(n)?`${n}.0`:`${n}`}}function Dbt(s){switch(s){case"uint8":return"r8uint";case"sint8":return"r8sint";case"uint16":return"r16uint";case"sint16":return"r16sint";case"uint32":return"r32uint";case"sint32":return"r32sint";case"float32":return"r32float";default:throw new Error(`Unsupported WebGL gather texture format for ${s}`)}}function Bbt(s){switch(s){case"uint32":return"usampler2D";case"sint32":return"isampler2D";case"float32":return"sampler2D";default:throw new Error(`Unsupported WebGL gather sampler type for ${s}`)}}var CB=Ve(()=>{});function dp({module:s,elementWise:n=!1,expression:r,inputs:c,output:u,operationType:d=u.type,outputBuffer:b}){let w=b.device,_=R4("result",u.type,u.size,u.normalized),x=[s,_],T=[],M={},L=hp(u.type,1,u.normalized),I=hp(d,1,u.normalized),D="",F=null,O={TYPE:I,RESULT_LEN:u.size.toString()},z=Gnn(c);for(let[oe,ne]of z)x.push(zRe(oe,ne.type,ne.size,ne.normalized,d)),T.push(GRe(oe,ne)),ne instanceof fc?M[oe]=ne.buffer:(F=F||lg.createOrReuse(w,b.byteLength),M[oe]=F),D+=`TYPE ${oe}[${ne.size}]; get_${oe}(${oe}); +`});var aJt,ZD,Ggt=Ve(()=>{Agt();Bgt();Fgt();zgt();aJt=[38.25,38.25,38.25],ZD={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:Ngt.replace("phongMaterial","gouraudMaterial"),fs:Ogt.replace("phongMaterial","gouraudMaterial"),source:Ugt.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[Igt,Cgt],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:aJt},getUniforms(s){return{...ZD.defaultUniforms,...s}}}});var vm=Ve(()=>{ELe();Ddt();c4e();ppt();mpt();bgt();Egt();Pgt();Ggt()});function Qy(s="id"){Ike[s]=Ike[s]||1;let n=Ike[s]++;return`${s}-${n}`}var Ike,hB=Ve(()=>{Ike={}});function y4(s){switch(s){case"POSITION":return"positions";case"NORMAL":return"normals";case"TEXCOORD_0":return"texCoords";case"TEXCOORD_1":return"texCoords1";case"COLOR_0":return"colors";default:return s}}function ien(s){let n=[];for(let[r,c]of Object.entries(s)){if(!c)continue;let{value:u,size:d,normalized:b}=c;if(d===void 0)throw new Error(`Attribute ${r} is missing a size`);n.push({name:y4(r),format:hl.getVertexFormatFromAttribute(u,d,b)})}return n}var Lb,Sle=Ve(()=>{Vr();hB();Lb=class{id;topology;vertexCount;indices;attributes;bufferLayout;userData={};constructor(n){let{attributes:r={},indices:c=null,vertexCount:u=null}=n;this.id=n.id||Qy("geometry"),this.topology=n.topology,c&&(this.indices=ArrayBuffer.isView(c)?{value:c,size:1}:c),this.attributes={};for(let[d,b]of Object.entries(r)){let w=ArrayBuffer.isView(b)?{value:b}:b;if(!ArrayBuffer.isView(w.value))throw new Error(`${this._print(d)}: must be typed array or object with value as typed array`);if((d==="POSITION"||d==="positions")&&!w.size&&(w.size=3),d==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=w}else{let _=y4(d),x=Object.keys(this.attributes).find(T=>y4(T)===_);x&&delete this.attributes[x],this.attributes[d]=w}}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=u||this._calculateVertexCount(this.attributes,this.indices),this.bufferLayout=n.bufferLayout||ien(this.attributes)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(n){return`Geometry ${this.id} attribute ${n}`}_setAttributes(n,r){return this}_calculateVertexCount(n,r){if(r)return r.value.length;let c=1/0;for(let u of Object.values(n)){if(!u)continue;let{value:d,size:b,constant:w}=u;!w&&d&&b!==void 0&&b>=1&&(c=Math.min(c,d.length/b))}return c}}});function Omt(s,n={}){let r=n.bufferName||"geometry";if(ren(s,r))return s;let c=n.minAttributeAlignment||4,u=sen(s,n.attributes),d=[],b=0,w=1/0;for(let[T,M]of u){if(!M)continue;if(M.constant)throw new Error(`Attribute ${T} is constant`);let{value:L,size:I,normalized:D}=M;if(!ArrayBuffer.isView(L))throw new Error(`Attribute ${T} is missing typed array data`);if(I===void 0)throw new Error(`Attribute ${T} is missing a size`);let F=hl.getVertexFormatFromAttribute(L,I,D),O=hl.getVertexFormatInfo(F);b=Bmt(b,c),d.push({sourceName:T,attributeName:y4(T),value:L,size:I,format:F,byteOffset:b,byteLength:O.byteLength}),b+=O.byteLength;let z=L.length/I;if(!Number.isInteger(z))throw new Error(`Attribute ${T} length is not divisible by size`);w=Math.min(w,z)}if(d.length===0||!Number.isFinite(w))throw new Error(`Geometry ${s.id} has no interleavable attributes`);let _=Bmt(b,c),x=new ArrayBuffer(w*_);for(let T of d)oen(x,w,_,T);return new Lb({id:s.id,topology:s.topology||"triangle-list",vertexCount:s.vertexCount,indices:s.indices,attributes:{[r]:{value:new Uint8Array(x),size:_,byteStride:_}},bufferLayout:[{name:r,stepMode:"vertex",byteStride:_,attributes:d.map(T=>({attribute:T.attributeName,format:T.format,byteOffset:T.byteOffset}))}]})}function ren(s,n){if(s.bufferLayout.length!==1)return!1;let r=s.bufferLayout[0];return r.name===n&&!!r.attributes?.length&&!!s.attributes[n]}function sen(s,n){return n?n.map(r=>[r,s.attributes[r]]):Object.entries(s.attributes)}function oen(s,n,r,c){let u=c.value.constructor,d=u.BYTES_PER_ELEMENT;if(c.byteOffset%d!==0||r%d!==0)throw new Error(`Attribute ${c.sourceName} is not aligned to its component type`);let b=new u(s),w=c.value,_=c.byteOffset/d,x=r/d;for(let T=0;T{Vr();Sle()});var aen,cen,x4,Fmt=Ve(()=>{aen=1,cen=1,x4=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(n){let{delay:r=0,duration:c=Number.POSITIVE_INFINITY,rate:u=1,repeat:d=1}=n,b=aen++,w={time:0,delay:r,duration:c,rate:u,repeat:d};return this._setChannelTime(w,this.time),this.channels.set(b,w),b}removeChannel(n){this.channels.delete(n);for(let[r,c]of this.animations)c.channel===n&&this.detachAnimation(r)}isFinished(n){let r=this.channels.get(n);return r===void 0?!1:this.time>=r.delay+r.duration*r.repeat}getTime(n){if(n===void 0)return this.time;let r=this.channels.get(n);return r===void 0?-1:r.time}setTime(n){this.time=Math.max(0,n);let r=this.channels.values();for(let u of r)this._setChannelTime(u,this.time);let c=this.animations.values();for(let u of c){let{animation:d,channel:b}=u;d.setTime(this.getTime(b))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(n,r){let c=cen++;return this.animations.set(c,{animation:n,channel:r}),n.setTime(this.getTime(r)),c}detachAnimation(n){this.animations.delete(n)}update(n){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=n),this.setTime(this.time+(n-this.lastEngineTime)),this.lastEngineTime=n)}_setChannelTime(n,r){let c=r-n.delay,u=n.duration*n.repeat;c>=u?n.time=n.duration*n.rate:(n.time=Math.max(0,c)%n.duration,n.time*=n.rate)}}});function Umt(s){let n=typeof window<"u"?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame:null;return n?n.call(window,s):setTimeout(()=>s(typeof performance<"u"?performance.now():Date.now()),1e3/60)}function zmt(s){let n=typeof window<"u"?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame:null;if(n){n.call(window,s);return}clearTimeout(s)}var Gmt=Ve(()=>{});var len,uen,jmt,iV,$mt=Ve(()=>{Vr();Gmt();Kj();len=0,uen="Animation Loop",jmt={requestAnimationFrame:s=>Umt(s),cancelAnimationFrame:s=>zmt(s)},iV=class s{static defaultAnimationLoopProps={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:n=>{console.error(n)},stats:void 0,autoResizeViewport:!1,animationFrameProvider:jmt};device=null;canvas=null;props;animationProps=null;timeline=null;stats;sharedStats;cpuTime;gpuTime;frameRate;display;_needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;_lastFrameTime=0;constructor(n){if(this.props={...s.defaultAnimationLoopProps,...n},n=this.props,!n.device)throw new Error("No device provided");this.stats=n.stats||new xb({id:`animation-loop-${len++}`}),this.sharedStats=UD.stats.get(uen),this.frameRate=this.stats.get("Frame Rate"),this.frameRate.setSampleSize(1),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.setProps({autoResizeViewport:n.autoResizeViewport,animationFrameProvider:n.animationFrameProvider}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null),this.device?._disableDebugGPUTime()}delete(){this.destroy()}reportError(n){this._error=n,this.props.onError(n),this.props.onError===s.defaultAnimationLoopProps.onError&&typeof window<"u"&&typeof ErrorEvent<"u"&&window.dispatchEvent(new ErrorEvent("error",{error:n,message:n.message}))}setNeedsRedraw(n){return this._needsRedraw=this._needsRedraw||n,this}needsRedraw(){let n=this._needsRedraw;return this._needsRedraw=!1,n}setProps(n){if("autoResizeViewport"in n&&(this.props.autoResizeViewport=n.autoResizeViewport||!1),"animationFrameProvider"in n){let r=n.animationFrameProvider||jmt;if(r!==this.props.animationFrameProvider){let c=this._animationFrameId!==null;c&&this._cancelAnimationFrame(),this.props.animationFrameProvider=r,c&&this._requestAnimationFrame()}}return this}async start(){if(this._running)return this;this._running=!0;try{let n;if(!this._initialized){if(this._initialized=!0,await this._initDevice(),this._initialize(),!this._running)return null;await this.props.onInitialize(this._getAnimationProps())}return this._running?(n!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(n){let r=n instanceof Error?n:new Error("Unknown error");throw this.props.onError(r),r}}stop(){if(this._running){let n=this.animationProps;this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1,this._lastFrameTime=0,n&&this.props.onFinalize(n)}return this}redraw(n,r=null){return this.device?.isLost||this._error?this:(this._beginFrameTimers(n),this._setupFrame(),this.animationProps&&(this.animationProps.animationFrame=r),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(n){return this.timeline=n,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(n=>{this._resolveNextFrame=n})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeViewport(),this.device?._enableDebugGPUTime()}_setDisplay(n){this.display&&(this.display.destroy(),this.display.animationLoop=null),n&&(n.animationLoop=this),this.display=n}_requestAnimationFrame(){this._running&&(this._animationFrameId=this.props.animationFrameProvider.requestAnimationFrame(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(this.props.animationFrameProvider.cancelAnimationFrame(this._animationFrameId),this._animationFrameId=null)}_animationFrame(n,r){if(this._running)try{this.redraw(n,r??null),this._requestAnimationFrame()}catch(c){let u=c instanceof Error?c:new Error(String(c));this.reportError(u),this.stop()}}_renderFrame(n){if(this.display){this.display._renderFrame(n);return}let r=this.props.onRender(this._getAnimationProps());this.device&&r!==!1&&this.device.submit()}_clearNeedsRedraw(){this._needsRedraw=!1}_setupFrame(){this._resizeViewport()}_initializeAnimationProps(){let n=this.device?.getDefaultCanvasContext();if(!this.device||!n)throw new Error("loop");let r=n?.canvas,c=n.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:n,canvas:r,useDevicePixels:c,timeline:this.timeline,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,animationFrame:null,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:n,height:r,aspect:c}=this._getSizeAndAspect();(n!==this.animationProps.width||r!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),c!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=n,this.animationProps.height=r,this.animationProps.aspect=c,this.animationProps.needsRedraw=this._needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.getDefaultCanvasContext().canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let n=document.createElement("div");document.body.appendChild(n),n.style.position="relative";let r=document.createElement("div");r.style.position="absolute",r.style.left="10px",r.style.bottom="10px",r.style.width="300px",r.style.background="white",this.canvas instanceof HTMLCanvasElement&&n.appendChild(this.canvas),n.appendChild(r);let c=this.props.onAddHTML(r);c&&(r.innerHTML=c)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[n,r]=this.device.getDefaultCanvasContext().getDrawingBufferSize(),c=n>0&&r>0?n/r:1;return{width:n,height:r,aspect:c}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(n){let r=n??(typeof performance<"u"?performance.now():Date.now());if(this._lastFrameTime){let c=r-this._lastFrameTime;c>0&&this.frameRate.addTime(c)}this._lastFrameTime=r,this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeStart()}_endFrameTimers(){this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeEnd(),this._updateSharedStats()}_consumeEncodedGpuTime(){if(!this.device)return;let n=this.device.commandEncoder._gpuTimeMs;n!==void 0&&(this.gpuTime.addTime(n),this.device.commandEncoder._gpuTimeMs=void 0)}_updateSharedStats(){if(this.stats!==this.sharedStats){for(let n of Object.keys(this.sharedStats.stats))this.stats.stats[n]||delete this.sharedStats.stats[n];this.stats.forEach(n=>{let r=this.sharedStats.get(n.name,n.type);r.sampleSize=n.sampleSize,r.time=n.time,r.count=n.count,r.samples=n.samples,r.lastTiming=n.lastTiming,r.lastSampleTime=n.lastSampleTime,r.lastSampleCount=n.lastSampleCount,r._count=n._count,r._time=n._time,r._samples=n._samples,r._startTime=n._startTime,r._timerPending=n._timerPending})}}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(n){n instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[n.offsetX,n.offsetY])}_onMouseleave(n){this._getAnimationProps()._mousePosition=null}}});function Vmt(s,n){if(n instanceof Mle)return n;let r=Omt(n),c=fen(s,r),{attributes:u,bufferLayout:d}=hen(s,r);return new Mle({topology:r.topology||"triangle-list",bufferLayout:d,vertexCount:r.vertexCount,indices:c,attributes:u})}function fen(s,n){if(!n.indices)return;let r=n.indices.value;return s.createBuffer({usage:cs.INDEX,data:r})}function hen(s,n){let r={};for(let[c,u]of Object.entries(n.attributes)){let d=n.bufferLayout.find(b=>b.name===c)?.name||y4(c);u&&(r[d]=s.createBuffer({data:u.value,id:`${c}-buffer`}))}return{attributes:r,bufferLayout:n.bufferLayout,vertexCount:n.vertexCount}}var Mle,Wmt=Ve(()=>{Vr();Sle();Nmt();hB();Mle=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(n){if(this.id=n.id||Qy("geometry"),this.topology=n.topology,this.indices=n.indices||null,this.attributes=n.attributes,this.vertexCount=n.vertexCount,this.bufferLayout=n.bufferLayout||[],this.indices&&!(this.indices.usage&cs.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){this.indices?.destroy();for(let n of Object.values(this.attributes))n.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(n){return n.byteLength/12}}});function Hmt(s,n){let r={},c="Values";if(s.attributes.length===0&&!s.varyings?.length)return{"No attributes or varyings":{[c]:"N/A"}};for(let u of s.attributes)if(u){let d=`${u.location} ${u.name}: ${u.type}`;r[`in ${d}`]={[c]:u.stepMode||"vertex"}}for(let u of s.varyings||[]){let d=`${u.location} ${u.name}`;r[`out ${d}`]={[c]:JSON.stringify(u)}}return r}var qmt=Ve(()=>{});function Zmt(s,n,r){if(s.device.type!=="webgl")return;let c=gen(s.device);if(!c.flushing){if(ben(s)){den(s,r,c);return}n&&men(n)&&n.handle!==null&&(c.queuedFramebuffers.includes(n)||c.queuedFramebuffers.push(n))}}function den(s,n,r){if(r.queuedFramebuffers.length===0)return;let c=s.device,{gl:u}=c,d=u.getParameter(36010),b=u.getParameter(36006),[w,_]=s.device.getDefaultCanvasContext().getDrawingBufferSize(),x=Ymt(n.top,8),T=Ymt(n.left,8);r.flushing=!0;try{for(let M of r.queuedFramebuffers){let[L,I,D,F,O]=pen({framebuffer:M,targetWidth:w,targetHeight:_,topPx:x,leftPx:T,minimap:n.minimap});u.bindFramebuffer(36008,M.handle),u.bindFramebuffer(36009,null),u.blitFramebuffer(0,0,M.width,M.height,L,I,D,F,16384,9728),x+=O+8}}finally{u.bindFramebuffer(36008,d),u.bindFramebuffer(36009,b),r.flushing=!1}}function pen(s){let{framebuffer:n,targetWidth:r,targetHeight:c,topPx:u,leftPx:d,minimap:b}=s,w=b?Math.max(Math.floor(r/4),1):r,_=b?Math.max(Math.floor(c/4),1):c,x=Math.min(w/n.width,_/n.height),T=Math.max(Math.floor(n.width*x),1),M=Math.max(Math.floor(n.height*x),1),L=d,I=Math.max(c-u-M,0),D=L+T,F=I+M;return[L,I,D,F,M]}function gen(s){return s.userData[Xmt]||={flushing:!1,queuedFramebuffers:[]},s.userData[Xmt]}function men(s){return"colorAttachments"in s}function ben(s){let n=s.props.framebuffer;return!n||n.handle===null}function Ymt(s,n){if(!s)return n;let r=Number.parseInt(s,10);return Number.isFinite(r)?r:n}var Xmt,Kmt=Ve(()=>{Xmt="__debugFramebufferState"});function dB(s,n,r){if(s===n)return!0;if(!r||!s||!n)return!1;if(Array.isArray(s)){if(!Array.isArray(n)||s.length!==n.length)return!1;for(let c=0;c{});var pB,Qmt=Ve(()=>{Vr();pB=class{bufferLayouts;constructor(n){this.bufferLayouts=n}getBufferLayout(n){return this.bufferLayouts.find(r=>r.name===n)||null}getAttributeNamesForBuffer(n){return VD(n)}mergeBufferLayouts(n,r){let c=[...n];for(let u of r){let d=c.findIndex(b=>b.name===u.name);d<0?c.push(u):c[d]=u}return c}}});function e1t(s,n){let r=i4e(s),c=n.slice();return c.sort((u,d)=>{let b=Oce(VD(u).map(_=>r[_])),w=Oce(VD(d).map(_=>r[_]));return b-w}),c}var t1t=Ve(()=>{Vr()});function gB(s,n){if(!s||!n.some(c=>c.bindingLayout?.length))return s;let r={...s,bindings:s.bindings.map(c=>({...c}))};"attributes"in(s||{})&&(r.attributes=s?.attributes||[]);for(let c of n)for(let u of c.bindingLayout||[])for(let d of wen(u.name)){let b=r.bindings.find(w=>w.name===d);b?.group===0&&(b.group=u.group),b&&u.visibility!==void 0&&(b.visibility=u.visibility)}return r}function n1t(s,n,r=[]){return s?n?{...s,attributes:s.attributes.length?yen(s.attributes,n.attributes.filter(c=>r.includes(c.name))):n.attributes,bindings:_en(s.bindings,n.bindings)}:s:n}function rV(s){return!!(s.uniformTypes&&!ven(s.uniformTypes))}function i1t(s){let n=[];for(let r of s){let c=k$(r),u=new Set([r.vs,r.fs].flatMap(b=>b?R$(b).filter(w=>w.isStd140).map(w=>w.blockName):[])),d=u.has(c)?c:u.size===1?u.values().next().value:void 0;rV(r)&&d&&n.push({name:d,uniformTypes:r.uniformTypes})}return n}function Tle(s,n){let r=[],c=new Set;for(let u of[...s||[],...n||[]])c.has(u.name)||(c.add(u.name),r.push(u));return r}function wen(s){let n=new Set([s,`${s}Uniforms`]);return s.endsWith("Uniforms")||n.add(`${s}Sampler`),[...n]}function ven(s){for(let n in s)return!1;return!0}function _en(s,n){let r=s.map(d=>({...d})),c=new Set(s.map(d=>d.name)),u=new Set(s.map(d=>`${d.group}:${d.location}`));for(let d of n){let b=`${d.group}:${d.location}`;!c.has(d.name)&&!u.has(b)&&r.push({...d})}return r}function yen(s,n){let r=s.map(d=>({...d})),c=new Map(s.map(d=>[d.name,d])),u=new Map(s.map(d=>[d.location,d]));for(let d of n){let b=c.get(d.name);if(b){if(b.type!==d.type||b.location!==d.location)throw new Error(`Shader attribute "${d.name}" conflicts with its inferred type or location`);continue}let w=u.get(d.location);if(w)throw new Error(`Shader attributes "${w.name}" and "${d.name}" both use location ${d.location}`);r.push({...d})}return r}var Dke=Ve(()=>{vm()});function xen(s){return r$(s)||typeof s=="number"||typeof s=="boolean"}function r1t(s,n={}){let r={bindings:{},uniforms:{}};return Object.keys(s).forEach(c=>{let u=s[c];Object.prototype.hasOwnProperty.call(n,c)||xen(u)?r.uniforms[c]=u:r.bindings[c]=u}),r}var s1t=Ve(()=>{sLe()});function o1t(s={},n={},r={}){let c={...s};for(let[u,d]of Object.entries(n))d!==void 0&&(c[u]=Bke(s[u],d,r[u]));return c}function Bke(s,n,r){if(!r||typeof r=="string")return sV(n);if(Array.isArray(r)){if(Oke(n)||!Array.isArray(n))return sV(n);let b=Array.isArray(s)&&!Oke(s)?[...s]:[],w=b.slice();for(let _=0;_r===void 0?void 0:sV(r)):Nke(s)?Object.fromEntries(Object.entries(s).map(([n,r])=>[n,r===void 0?void 0:sV(r)])):s}function Oke(s){return ArrayBuffer.isView(s)||Array.isArray(s)&&(s.length===0||typeof s[0]=="number")}function Nke(s){return!!s&&typeof s=="object"&&!Array.isArray(s)&&!ArrayBuffer.isView(s)}function Een(s){return!!s?.dependencies}var mB,Fke=Ve(()=>{Vr();vm();s1t();mB=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;directBindings={};constructor(n,r){Object.assign(this.options,r);let c=ZL(Object.values(n).filter(Een));for(let u of c)n[u.name]=u;Qt.log(1,"Creating ShaderInputs with modules",Object.keys(n))(),this.modules=n,this.moduleUniforms={},this.moduleBindings={};for(let[u,d]of Object.entries(n))d&&(this._addModule(d),d.name&&u!==d.name&&!this.options.disableWarnings&&Qt.warn(`Module name: ${u} vs ${d.name}`)())}destroy(){}setProps(n){n.bindings&&Object.assign(this.directBindings,n.bindings);for(let r of Object.keys(n)){if(r==="bindings")continue;let c=r,u=n[c]||{},d=this.modules[c];if(!d)this.options.disableWarnings||Qt.warn(`Module ${r} not found`)();else{let b=this.moduleUniforms[c],w=this.moduleBindings[c],_=d.getUniforms?.(u,b)||u,{uniforms:x,bindings:T}=r1t(_,d.uniformTypes);this.moduleUniforms[c]=o1t(b,x,d.uniformTypes),this.moduleBindings[c]={...w,...T}}}}getModules(){return Object.values(this.modules)}addModules(n){let r=ZL(n);for(let c of r){let u=c.name;this.modules[u]||(this.modules[u]=c,this._addModule(c))}}getUniformValues(){return this.moduleUniforms}getBindingValues(){let n={};for(let r of Object.values(this.moduleBindings))Object.assign(n,r);return Object.assign(n,this.directBindings),n}getModuleBindingValues(n){let r=this.moduleBindings[n];return r?{...r}:{}}getDebugTable(){let n={};for(let[r,c]of Object.entries(this.moduleUniforms))for(let[u,d]of Object.entries(c))n[`${r}.${u}`]={type:this.modules[r].uniformTypes?.[u],value:String(d)};return n}_addModule(n){let r=n.name;this.moduleUniforms[r]=o1t({},n.defaultUniforms||{},n.uniformTypes),this.moduleBindings[r]={}}}});function Uke(s){return s!==null&&typeof s=="object"&&"buffer"in s}function Men(s){return s instanceof up?s.buffer:s}function a1t(s){return{buffer:Men(s.buffer),offset:s.offset,size:s.size}}var Sen,up,zke=Ve(()=>{Vr();hB();Sen=cs.DEBUG_DATA_MAX_LENGTH,up=class{device;id;ready;usage;props;isReady=!0;destroyed=!1;generation=0;updateTimestamp;debugData=new ArrayBuffer(0);_debugDataEnabled;_maxDebugDataByteLength;_ownsBuffer;_buffer;get buffer(){return this._buffer}get byteLength(){return this._buffer.byteLength}get[Symbol.toStringTag](){return"DynamicBuffer"}toString(){return`DynamicBuffer:"${this.id}":${this.byteLength}B`}toJSON(){return this.toString()}constructor(n,r){let{debugData:c=!1,buffer:u,ownsBuffer:d=!0,...b}=r;if(u&&u.device!==n)throw new Error("DynamicBuffer adopted buffers must belong to the supplied device");if(u&&(b.byteLength!==void 0||b.data!==void 0))throw new Error("DynamicBuffer cannot combine an adopted buffer with byteLength or data");let w=r.id||u?.id||Qy("dynamic-buffer"),_={...b,id:w,usage:b.usage??u?.usage,indexType:b.indexType??u?.indexType};(_.usage||0)&cs.INDEX&&!_.indexType&&(b.data instanceof Uint32Array?_.indexType="uint32":b.data instanceof Uint16Array?_.indexType="uint16":b.data instanceof Uint8Array&&(_.indexType="uint8")),delete _.data,delete _.byteOffset,this.device=n,this.id=w,this.props=_,this.usage=_.usage||0,this._debugDataEnabled=!!c,this._maxDebugDataByteLength=typeof c=="object"&&c.maxByteLength!==void 0?c.maxByteLength:Sen,this._ownsBuffer=d,this._buffer=u??this.device.createBuffer({...b,id:w}),this.ready=Promise.resolve(this._buffer),this.updateTimestamp=this._buffer.updateTimestamp,this._resetDebugData(this._buffer.byteLength),b.data&&this._writeDebugData(b.data,b.byteOffset||0)}write(n,r=0){this._buffer.write(n,r),this._touch(),this._writeDebugData(n,r)}async mapAndWriteAsync(n,r=0,c=this.byteLength-r){let u=null;await this._buffer.mapAndWriteAsync(async(d,b)=>{await n(d,b),u=new Uint8Array(d.slice(0,c))},r,c),this._touch(),u&&this._writeDebugData(u,r)}async readAsync(n=0,r=this.byteLength-n){let c=await this._buffer.readAsync(n,r);return this._writeDebugData(c,n)&&this._touch(),c}async mapAndReadAsync(n,r=0,c=this.byteLength-r){let u=null,d=await this._buffer.mapAndReadAsync(async(b,w)=>(u=new Uint8Array(b.slice(0)),await n(b,w)),r,c);return u&&this._writeDebugData(u,r)&&this._touch(),d}resize(n){let{byteLength:r,preserveData:c=!1}=n;if(r===this.byteLength)return!1;let u=Math.min(n.copyByteLength??Math.min(this.byteLength,r),this.byteLength,r),d=this._buffer,b=this.debugData.slice(0),{data:w,byteOffset:_,...x}=this.props,T=this.device.createBuffer({...x,byteLength:r});return c&&u>0&&this._copyBufferContents(d,T,u),this._buffer=T,this._resetDebugData(r),c&&b.byteLength>0&&this._writeDebugData(b,0),this._ownsBuffer&&d.destroy(),this._ownsBuffer=!0,this.generation++,this._touch(),!0}ensureSize(n,r){return n<=this.byteLength?!1:this.resize({byteLength:n,preserveData:r?.preserveData})}getBinding(n){return n?.offset===void 0&&n?.size===void 0?this._buffer:{buffer:this._buffer,offset:n?.offset,size:n?.size}}destroy(){this.destroyed||(this._ownsBuffer&&this._buffer.destroy(),this.destroyed=!0,this.debugData=new ArrayBuffer(0))}_copyBufferContents(n,r,c){let u=this.device.type==="webgpu"?Math.ceil(c/4)*4:c,d=this.device.createCommandEncoder();d.copyBufferToBuffer({sourceBuffer:n,destinationBuffer:r,size:u}),this.device.submit(d.finish())}_touch(){this.updateTimestamp=this.device.incrementTimestamp()}_resetDebugData(n){if(!this._debugDataEnabled){this.debugData=new ArrayBuffer(0);return}this.debugData=new ArrayBuffer(Math.min(n,this._maxDebugDataByteLength))}_writeDebugData(n,r){if(!this._debugDataEnabled||this.debugData.byteLength===0||r>=this.debugData.byteLength)return!1;let c=ArrayBuffer.isView(n)?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n),u=new Uint8Array(this.debugData),d=Math.min(c.byteLength,u.byteLength-r);return u.set(c.subarray(0,d),r),d>0}}});function oV(s){return s!==null&&typeof s=="object"&&"resolveTextureBinding"in s&&typeof s.resolveTextureBinding=="function"}function Ten(s){return s?.type==="texture"||s?.type==="external-texture"}function c1t(s,n,r){let c=Lce(s,n,{ignoreWarnings:!0});return Ten(c)?c:s.bindings.length===0&&r?.fallbackGroup!==void 0?{type:"texture",name:n,group:r.fallbackGroup,location:0}:null}var l1t=Ve(()=>{Vr()});function jke(s,n){return s.shaderLanguage!==void 0&&s.shaderLanguage!==n?!1:n==="glsl"?"assembleGLSLShaderPair"in s&&typeof s.assembleGLSLShaderPair=="function":"assembleWGSLShader"in s&&typeof s.assembleWGSLShader=="function"}function Pen(s,n){return!s||Object.keys(n).length===0?s:{...s,attributes:s.attributes.map(r=>{let c=r.name.startsWith("_luma_")?r.name.slice(6):null;return c&&n[c]?{...r,name:c}:r})}}function Len(s,n,r){if(oV(n)){let c=c1t(r,s,{fallbackGroup:0});return c?n.resolveTextureBinding(c):null}return n instanceof up?n.buffer:Uke(n)?a1t(n):n}function ken(s){return s&&!u1t(s)?s:null}function Ren(s){return s&&u1t(s)?s:void 0}function u1t(s){return Aen.includes(s)}function Ien(s){return{type:s.type,shaderLanguage:s.info.shadingLanguage,shaderLanguageVersion:s.info.shadingLanguageVersion,gpu:s.info.gpu,limits:s.limits,features:s.features}}var e2,Cen,Gke,Aen,Vh,$ke=Ve(()=>{Vr();vm();Wmt();qmt();Kmt();Jmt();Qmt();t1t();Dke();hB();Fke();zke();l1t();e2=2,Cen=1e4,Gke="render pipeline initialization failed",Aen=["stencil8","depth16unorm","depth24plus","depth24plus-stencil8","depth32float","depth32float-stencil8"],Vh=class s{static defaultProps={...Mb.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],plugins:[],geometry:null,indexBuffer:null,indexCount:void 0,firstVertex:0,firstIndex:0,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,material:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:Tb.getDefaultShaderAssembler("glsl"),debugShaders:void 0,disableWarnings:void 0};device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexCount;firstVertex;firstIndex;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;material=null;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_dynamicIndexBufferSource=null;_dynamicAttributeBufferSources={};_colorAttachmentFormats;_depthStencilAttachmentFormat;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_drawBlockedReason=!1;_destroyed=!1;_vertexCountSet=!1;_lastDrawTimestamp=-1;_bindingTable=[];get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(n,r){let c=s.defaultProps.shaderAssembler,u=r.vertexCount!==void 0;this.props={...s.defaultProps,...r,shaderAssembler:r.shaderAssembler??(jke(c,n.info.shadingLanguage)?c:Tb.getDefaultShaderAssembler(n.info.shadingLanguage))},this._vertexCountSet=u,r=this.props,this.id=r.id||Qy("model"),this.device=n,Object.assign(this.userData,r.userData),this.material=r.material||null;let d=Ien(n),b=P$(this.props.plugins,d.shaderLanguage),w=L$(this.props.modules,b.modules),_=Object.fromEntries(w.map(I=>[I.name,I])),x=r.shaderInputs||new mB(_,{disableWarnings:this.props.disableWarnings});r.shaderInputs&&b.modules.length>0&&x.addModules(b.modules),this.setShaderInputs(x);let T=Tle(this.props.modules,x.getModules()),M={...b.defines,...this.props.defines};if(this.device.type==="webgl"&&(this.props._uniformBlockLayouts=i1t(T)),this.props.shaderLayout=gB(this.props.shaderLayout,T)||null,this.device.type==="webgpu"&&this.props.source){let I=this.props.shaderAssembler;FM(jke(I,"wgsl"));let{source:D,getUniforms:F,bindingTable:O,shaderLayout:z}=I.assembleWGSLShader({platformInfo:d,...this.props,modules:T,defines:M,pluginInjections:b.injections,pluginVertexInputs:b.vertexInputs,pluginVaryings:b.varyings});this.source=D,this._getModuleUniforms=F,this._bindingTable=O;let Z=z??n.getShaderLayout?.(this.source),H=Pen(Z,b.vertexInputs),te=n1t(this.props.shaderLayout,H,Object.keys(b.vertexInputs));this.props.shaderLayout=gB(te||null,T)||null}else{let I=this.props.shaderAssembler;FM(jke(I,"glsl"));let{vs:D,fs:F,getUniforms:O}=I.assembleGLSLShaderPair({platformInfo:d,...this.props,modules:T,defines:M,pluginInjections:b.injections,pluginVertexInputs:b.vertexInputs,pluginVaryings:b.varyings});this.vs=D,this.fs=F,this._getModuleUniforms=O,this._bindingTable=[]}this.vertexCount=this.props.vertexCount,this.indexCount=this.props.indexCount,this.firstVertex=this.props.firstVertex,this.firstIndex=this.props.firstIndex,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,this._colorAttachmentFormats=this.props.colorAttachmentFormats,this._depthStencilAttachmentFormat=this.props.depthStencilAttachmentFormat,r.geometry&&this.setGeometry(r.geometry),this.pipelineFactory=r.pipelineFactory||i4.getDefaultPipelineFactory(this.device),this.shaderFactory=r.shaderFactory||r4.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=n.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in r&&(this.isInstanced=r.isInstanced),r.instanceCount&&this.setInstanceCount(r.instanceCount),r.vertexCount&&this.setVertexCount(r.vertexCount),r.indexBuffer&&this.setIndexBuffer(r.indexBuffer),r.attributes&&this.setAttributes(r.attributes),r.constantAttributes&&this.setConstantAttributes(r.constantAttributes),r.bindings&&this.setBindings(r.bindings),r.transformFeedback&&(this.transformFeedback=r.transformFeedback)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let n=this._needsRedraw;return this._needsRedraw=!1,n}setNeedsRedraw(n){this._needsRedraw||=n}getBindingDebugTable(){return this._bindingTable}predraw(n){this._syncDynamicBuffers(),this.updateShaderInputs(n),this.material?.updateShaderInputs(n),this.pipeline=this._updatePipeline()}draw(n){if(this._drawBlockedReason&&!this._pipelineNeedsUpdate)return Qt.info(e2,`>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)(),!1;let r=this._areBindingsLoading();if(r)return Qt.info(e2,`>>> DRAWING ABORTED ${this.id}: ${r} not loaded`)(),!1;this._syncAttachmentFormats(n);try{n.pushDebugGroup(`${this}.predraw(${n})`),this.device.type==="webgpu"?(this.updateShaderInputs(),this.material?.updateShaderInputs(),this._syncDynamicBuffers(),this.pipeline=this._updatePipeline()):this.predraw(this.device.commandEncoder)}finally{n.popDebugGroup()}let c,u=this.pipeline.isErrored;try{if(n.pushDebugGroup(`${this}.draw(${n})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline(),u=this.pipeline.isErrored,u)Qt.info(e2,`>>> DRAWING ABORTED ${this.id}: ${Gke}`)(),c=!1;else{let d=this.vertexArray.getDrawValidationError();if(d)Qt.info(e2,`>>> DRAWING ABORTED ${this.id}: ${d}`)(),this._drawBlockedReason=d,c=!1;else{let b=this._getCurrentShaderLayout(),w=this._getBindings(b),_=this._getBindGroups(b,w),{indexBuffer:x}=this.vertexArray,T=x?this.indexCount??(this._vertexCountSet?this.vertexCount:x.byteLength/(x.indexType==="uint32"?4:2)):void 0;n.setPipeline(this.pipeline),n.setBindings(_,{_bindGroupCacheKeys:this._getBindGroupCacheKeys()}),n.setVertexArray(this.vertexArray),c=this.isInstanced===!0&&this.instanceCount===0?!0:n.draw({isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.isInstanced?this.instanceCount:void 0,indexCount:T,firstVertex:this.firstVertex,firstIndex:this.firstIndex,transformFeedback:this.transformFeedback||void 0,uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}}}finally{n.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(n),c?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):u?(this._needsRedraw=Gke,this._drawBlockedReason=Gke):this._drawBlockedReason?this._needsRedraw=this._drawBlockedReason:this._needsRedraw="waiting for resource initialization",c}setGeometry(n){this._gpuGeometry?.destroy();let r=n&&Vmt(this.device,n);if(r){this.setTopology(r.topology||"triangle-list");let c=new pB(this.bufferLayout);this.bufferLayout=c.mergeBufferLayouts(r.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(r)}this._gpuGeometry=r}setTopology(n){n!==this.topology&&(this.topology=n,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(n){let r=new pB(this.bufferLayout),c=this._gpuGeometry?r.mergeBufferLayouts(n,this._gpuGeometry.bufferLayout):n;dB(c,this.bufferLayout,-1)||(this.bufferLayout=c,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry))}setParameters(n){dB(n,this.parameters,2)||(this.parameters=n,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(n){this.instanceCount=n,this.isInstanced===void 0&&n>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(n){this.vertexCount=n,this._vertexCountSet=!0,this.setNeedsRedraw("vertexCount")}setIndexCount(n){this.indexCount=n,this.setNeedsRedraw("indexCount")}setDrawOffsets({firstVertex:n,firstIndex:r}){this.firstVertex=n,this.firstIndex=r,this.setNeedsRedraw("drawOffsets")}setShaderInputs(n){this.shaderInputs=n,this._uniformStore=new a4(this.device,this.shaderInputs.modules);for(let[r,c]of Object.entries(this.shaderInputs.modules))if(rV(c)&&!this.material?.ownsModule(r)){let u=this._uniformStore.getManagedUniformBuffer(r);this.bindings[`${r}Uniforms`]=u}this.setNeedsRedraw("shaderInputs")}setMaterial(n){this.material=n,this.setNeedsRedraw("material")}updateShaderInputs(n){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),n),this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues())),this.setNeedsRedraw("shaderInputs")}setBindings(n){Object.assign(this.bindings,n),this.setNeedsRedraw("bindings")}setTransformFeedback(n){this.transformFeedback=n,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(n){let r=n instanceof up?n.buffer:n;this.indexBuffer=r,this._dynamicIndexBufferSource=n instanceof up?{source:n,generation:n.generation}:null,this.vertexArray.setIndexBuffer(r),this.setNeedsRedraw("indexBuffer")}setAttributes(n,r){this._drawBlockedReason=!1;let c=r?.disableWarnings??this.props.disableWarnings;n.indices&&Qt.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=e1t(this.pipeline.shaderLayout,this.bufferLayout);let u=new pB(this.bufferLayout);for(let[d,b]of Object.entries(n)){let w=b instanceof up?b.buffer:b,_=u.getBufferLayout(d);if(!_){c||Qt.warn(`Model(${this.id}): Missing layout for buffer "${d}".`)();continue}let x=u.getAttributeNamesForBuffer(_),T=!1;for(let M of x){let L=this._attributeInfos[M];if(L){let I=this.device.type==="webgpu"?this.vertexArray.getBufferSlot(L.bufferName):L.location;if(I===null){c||Qt.warn(`Model(${this.id}): Missing vertex array slot for buffer "${L.bufferName}".`)();continue}this.vertexArray.setBuffer(I,w),b instanceof up?this._dynamicAttributeBufferSources[I]={source:b,generation:b.generation}:delete this._dynamicAttributeBufferSources[I],T=!0}}!T&&!c&&Qt.warn(`Model(${this.id}): Ignoring buffer "${w.id}" for unknown attribute "${d}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(n,r){for(let[c,u]of Object.entries(n)){let d=this._attributeInfos[c];d?this.vertexArray.setConstantWebGL(d.location,u):(r?.disableWarnings??this.props.disableWarnings)||Qt.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${c}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(let n of Object.values(this.bindings))if(oV(n)&&!n.isReady)return n.id;for(let n of Object.values(this.material?.bindings||{}))if(oV(n)&&!n.isReady)return n.id;return!1}_getBindings(n=this._getCurrentShaderLayout()){let r={};for(let[c,u]of Object.entries(this.bindings)){let d=Len(c,u,n);d&&(r[c]=d)}return r}_getBindGroups(n=this._getCurrentShaderLayout(),r=this._getBindings(n)){let c=n.bindings.length?s4(n,r):{0:r};if(!this.material)return c;for(let[u,d]of Object.entries(this.material.getBindingsByGroup(n))){let b=Number(u);c[b]={...c[b]||{},...d}}return c}_getBindGroupCacheKeys(){let n=this.material?.getBindGroupCacheKey(3);return n?{3:n}:{}}_getBindingsUpdateTimestamp(){let n=0;this._dynamicIndexBufferSource&&(n=Math.max(n,this._dynamicIndexBufferSource.source.updateTimestamp));for(let r of Object.values(this._dynamicAttributeBufferSources))n=Math.max(n,r.source.updateTimestamp);for(let r of Object.values(this.bindings))r instanceof e4?n=Math.max(n,r.texture.updateTimestamp):r instanceof cs||r instanceof Pa||r instanceof b$||r instanceof up?n=Math.max(n,r.updateTimestamp):oV(r)?n=r.isReady?Math.max(n,r.updateTimestamp):1/0:Uke(r)&&(n=Math.max(n,(r.buffer instanceof up,r.buffer.updateTimestamp)));return Math.max(n,this.material?.getBindingsUpdateTimestamp()||0)}_setGeometryAttributes(n){let r={...n.attributes};for(let[c]of Object.entries(r))!this.pipeline.shaderLayout.attributes.find(u=>u.name===c)&&c!=="positions"&&delete r[c];this.vertexCount=n.vertexCount,this._vertexCountSet=!0,this.setIndexBuffer(n.indices||null),this.setAttributes(n.attributes,{disableWarnings:!0}),this.setAttributes(r,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(n){this._pipelineNeedsUpdate||=n,this._drawBlockedReason=!1,this.setNeedsRedraw(n)}_updatePipeline(){if(this._pipelineNeedsUpdate){let n=null,r=null;this.pipeline&&(Qt.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),n=this.pipeline.vs,r=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let c=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders}),u=null;this.source?u=c:this.fs&&(u=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bindings:void 0,bufferLayout:this.bufferLayout,colorAttachmentFormats:this._colorAttachmentFormats,depthStencilAttachmentFormat:this._depthStencilAttachmentFormat,topology:this.topology,parameters:this.parameters,bindGroups:void 0,vs:c,fs:u}),this._attributeInfos=A$(this.pipeline.shaderLayout,this.bufferLayout),n&&this.shaderFactory.release(n),r&&r!==n&&this.shaderFactory.release(r)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let n=Qt.level>3?0:Cen;Qt.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:Qt.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let n=Hmt(this.pipeline.shaderLayout,this.id);Qt.table(e2,n)();let r=this.shaderInputs.getDebugTable();Qt.table(e2,r)();let c=this._getAttributeDebugTable();Qt.table(e2,this._attributeInfos)(),Qt.table(e2,c)(),Qt.groupEnd(e2)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(n){let r=this.device.props.debugFramebuffers;if(this._drawCount++,!r)return;let c=n.props.framebuffer;Zmt(n,c,{id:c?.id||`${this.id}-framebuffer`,minimap:!0})}_getAttributeDebugTable(){let n={};for(let[r,c]of Object.entries(this._attributeInfos)){let u=this.vertexArray.attributes[c.location];n[c.location]={name:r,type:c.shaderType,values:u?this._getBufferOrConstantValues(u,c.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:r}=this.vertexArray,c=r.indexType==="uint32"?new Uint32Array(r.debugData):new Uint16Array(r.debugData);n.indices={name:"indices",type:r.indexType,values:c.toString()}}return n}_getBufferOrConstantValues(n,r){let c=Md.getTypedArrayConstructor(r);return(n instanceof cs?new c(n.debugData):n).toString()}_getNonMaterialBindings(n){if(!this.material)return n;let r={};for(let[c,u]of Object.entries(n))this.material.ownsBinding(c)||(r[c]=u);return r}_getCurrentShaderLayout(){return this.pipeline?.shaderLayout||this.props.shaderLayout||{bindings:[]}}_syncDynamicBuffers(){if(this._dynamicIndexBufferSource&&this._dynamicIndexBufferSource.generation!==this._dynamicIndexBufferSource.source.generation){let n=this._dynamicIndexBufferSource.source.buffer;this.indexBuffer=n,this.vertexArray.setIndexBuffer(n),this._dynamicIndexBufferSource.generation=this._dynamicIndexBufferSource.source.generation,this.setNeedsRedraw("dynamic index buffer")}for(let[n,r]of Object.entries(this._dynamicAttributeBufferSources))r.generation!==r.source.generation&&(this.vertexArray.setBuffer(Number(n),r.source.buffer),r.generation=r.source.generation,this.setNeedsRedraw("dynamic attribute buffer"))}_syncAttachmentFormats(n){if(this.device.type!=="webgpu")return;let r=n.framebuffer||n.props.framebuffer,c=n.props,u=c.colorAttachmentFormats??r?.colorAttachments?.map(b=>ken(b?.texture?.format)),d=c.depthStencilAttachmentFormat===!1?void 0:c.depthStencilAttachmentFormat??Ren(r?.depthStencilAttachment?.texture?.format);(!dB(this._colorAttachmentFormats,u,1)||this._depthStencilAttachmentFormat!==d)&&(this._colorAttachmentFormats=u,this._depthStencilAttachmentFormat=d,this._setPipelineNeedsUpdate("attachment formats"))}}});var Den,Ben,fp,f1t=Ve(()=>{Vr();vm();$ke();Den=35980,Ben=35981,fp=class s{device;model;transformFeedback;static defaultProps={...Vh.defaultProps,feedbackBufferMode:"separate",outputs:void 0,feedbackBuffers:void 0};static isSupported(n){return n?.info?.type==="webgl"}constructor(n,r=s.defaultProps){if(!s.isSupported(n))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=n,this.model=new Vh(this.device,{id:r.id||"buffer-transform-model",fs:r.fs||v4e(),topology:r.topology||"point-list",varyings:r.outputs||r.varyings,...r,bufferMode:r.bufferMode||(r.feedbackBufferMode==="interleaved"?Den:Ben)}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:r.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(n){n?.inputBuffers&&this.model.setAttributes(n.inputBuffers),n?.outputBuffers&&this.transformFeedback.setBuffers(n.outputBuffers);let r=this.device.beginRenderPass({discard:!0,...n});this.model.draw(r),r.end()}getBuffer(n){return this.transformFeedback.getBuffer(n)}readAsync(n){let r=this.getBuffer(n);if(!r)throw new Error("BufferTransform#getBuffer");if(r instanceof cs)return r.readAsync();let{buffer:c,byteOffset:u=0,byteLength:d=c.byteLength}=r;return c.readAsync(u,d)}}});function Nen(s){return{type:s.type,shaderLanguage:s.info.shadingLanguage,shaderLanguageVersion:s.info.shadingLanguageVersion,gpu:s.info.gpu,limits:s.limits,features:s.features}}var Vke,Oen,G1,h1t=Ve(()=>{Vr();vm();sLe();Fke();Dke();hB();Vke=2,Oen=1e4,G1=class s{static defaultProps={...GM.defaultProps,id:"unnamed",handle:void 0,userData:{},source:"",modules:[],defines:{},plugins:[],bindings:void 0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,shaderAssembler:Tb.getDefaultShaderAssembler("wgsl"),debugShaders:void 0};device;id;pipelineFactory;shaderFactory;userData={};bindings={};pipeline;source;shader;shaderInputs;_uniformStore;_pipelineNeedsUpdate="newly created";_getModuleUniforms;props;_destroyed=!1;constructor(n,r){if(n.type!=="webgpu")throw new Error("Computation is only supported in WebGPU");this.props={...s.defaultProps,...r},r=this.props,this.id=r.id||Qy("model"),this.device=n,Object.assign(this.userData,r.userData);let c=Nen(n),u=P$(this.props.plugins,c.shaderLanguage);if(Object.keys(u.vertexInputs).length>0||Object.keys(u.varyings).length>0)throw new Error("Computation does not support ShaderPlugin vertex inputs or varyings");let d=L$(this.props.modules,u.modules),b=Object.fromEntries(d.map(D=>[D.name,D]));this.shaderInputs=r.shaderInputs||new mB(b),r.shaderInputs&&u.modules.length>0&&this.shaderInputs.addModules(u.modules),this.setShaderInputs(this.shaderInputs);let w=Tle(this.props.modules,this.shaderInputs?.getModules()),_={...u.defines,...this.props.defines};this.props.shaderLayout=gB(this.props.shaderLayout,w)||null,this.pipelineFactory=r.pipelineFactory||i4.getDefaultPipelineFactory(this.device),this.shaderFactory=r.shaderFactory||r4.getDefaultShaderFactory(this.device);let x=this.props.shaderAssembler;FM(x instanceof $M);let{source:T,getUniforms:M,shaderLayout:L}=x.assembleWGSLShader({platformInfo:c,...this.props,modules:w,defines:_,scanVertexAttributes:!1,pluginInjections:u.injections});this.source=T,this._getModuleUniforms=M;let I=L??n.getShaderLayout?.(this.source,{scanVertexAttributes:!1});this.props.shaderLayout=gB(this.props.shaderLayout||I||null,w)||null,this.pipeline=this._updatePipeline(),r.bindings&&this.setBindings(r.bindings)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.shader),this._uniformStore.destroy(),this._destroyed=!0)}predraw(n){this.updateShaderInputs(n)}dispatch(n,r,c,u){try{this._logDrawCallStart(),this._setPipeline(n),n.dispatch(r,c,u)}finally{this._logDrawCallEnd()}}dispatchIndirect(n,r,c=0){try{this._logDrawCallStart(),this._setPipeline(n),n.dispatchIndirect(r,c)}finally{this._logDrawCallEnd()}}_setPipeline(n){this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings),n.setPipeline(this.pipeline),n.setBindings({})}setVertexCount(n){}setInstanceCount(n){}setShaderInputs(n){this.shaderInputs=n,this._uniformStore=new a4(this.device,this.shaderInputs.modules);for(let[r,c]of Object.entries(this.shaderInputs.modules))if(rV(c)){let u=this._uniformStore.getManagedUniformBuffer(r);this.bindings[`${r}Uniforms`]=u}}setShaderModuleProps(n){let r=this._getModuleUniforms(n),c=Object.keys(r).filter(d=>{let b=r[d];return!r$(b)&&typeof b!="number"&&typeof b!="boolean"}),u={};for(let d of c)u[d]=r[d],delete r[d]}updateShaderInputs(n){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),n)}setBindings(n){Object.assign(this.bindings,n)}_setPipelineNeedsUpdate(n){this._pipelineNeedsUpdate=this._pipelineNeedsUpdate||n}_updatePipeline(){if(this._pipelineNeedsUpdate){let n=null;this.pipeline&&(Qt.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),n=this.shader),this._pipelineNeedsUpdate=!1,this.shader=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"compute",source:this.source,debugShaders:this.props.debugShaders}),this.pipeline=this.pipelineFactory.createComputePipeline({...this.props,shader:this.shader}),n&&this.shaderFactory.release(n)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let n=Qt.level>3?0:Oen;Qt.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:Qt.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let n=this.shaderInputs.getDebugTable();Qt.table(Vke,n)(),Qt.groupEnd(Vke)(),this._logOpen=!1}}_drawCount=0;_getBufferOrConstantValues(n,r){let c=Md.getTypedArrayConstructor(r);return(n instanceof cs?new c(n.debugData):n).toString()}}});var Ql=Ve(()=>{Fmt();$mt();$ke();f1t();Sle();zke();h1t()});function C1t(s=!0){let n=HTMLCanvasElement.prototype;if(!s&&n.originalGetContext){n.getContext=n.originalGetContext,n.originalGetContext=void 0;return}n.originalGetContext=n.getContext,n.getContext=function(r,c){if(r==="webgl"||r==="experimental-webgl"){let u=this.originalGetContext("webgl2",c);return u instanceof HTMLElement&&ptn(u),u}return this.originalGetContext(r,c)}}function ptn(s){s.getExtension("EXT_color_buffer_float");let n={...utn,WEBGL_disjoint_timer_query:s.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:ftn(s),OES_vertex_array_object:htn(s),ANGLE_instanced_arrays:dtn(s)},r=s.getExtension.bind(s);s.getExtension=function(u){let d=r(u);return d||(u in n?n[u]:null)};let c=s.getSupportedExtensions;s.getSupportedExtensions=function(){return(c.apply(s)||[])?.concat(Object.keys(n))}}var utn,ftn,htn,dtn,A1t=Ve(()=>{utn={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},ftn=s=>({drawBuffersWEBGL(n){return s.drawBuffers(n)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),htn=s=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return s.createVertexArray()},deleteVertexArrayOES(n){return s.deleteVertexArray(n)},isVertexArrayOES(n){return s.isVertexArray(n)},bindVertexArrayOES(n){return s.bindVertexArray(n)}}),dtn=s=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...n){return s.drawArraysInstanced(...n)},drawElementsInstancedANGLE(...n){return s.drawElementsInstanced(...n)},vertexAttribDivisorANGLE(...n){return s.vertexAttribDivisor(...n)}})});async function L1t(){if(!Dle){tRe();return}await Dle.load()}function k1t(s,n){return Dle?Dle.makeDebugContext(s,n):(tRe(),s)}async function R1t(s){if(!eRe){tRe();return}await eRe.load(s)}function I1t(s){return eRe?.initialize(s)||null}function tRe(){P1t||(P1t=!0,Qt.warn("Import @luma.gl/webgl/debug before enabling WebGL debugging.")())}var Dle,eRe,P1t,nRe=Ve(()=>{Vr();Dle=null,eRe=null,P1t=!1});function iRe(s){return Array.isArray(s)||ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Iu(s,n,r){return n[s]!==void 0?n[s]:r[s]}var xV,Ff,D1t,j1,B1t,yV,O1t,N1t,rRe,r2,sRe,F1t,oRe=Ve(()=>{xV={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},Ff=(s,n,r)=>n?s.enable(r):s.disable(r),D1t=(s,n,r)=>s.hint(r,n),j1=(s,n,r)=>s.pixelStorei(r,n),B1t=(s,n,r)=>{let c=r===36006?36009:36008;return s.bindFramebuffer(c,n)},yV=(s,n,r)=>{let u={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[r];s.bindBuffer(u,n)};O1t={3042:Ff,32773:(s,n)=>s.blendColor(...n),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(s,n)=>s.clearColor(...n),3107:(s,n)=>s.colorMask(...n),2884:Ff,2885:(s,n)=>s.cullFace(n),2929:Ff,2931:(s,n)=>s.clearDepth(n),2932:(s,n)=>s.depthFunc(n),2928:(s,n)=>s.depthRange(...n),2930:(s,n)=>s.depthMask(n),3024:Ff,35723:D1t,35725:(s,n)=>s.useProgram(n),36007:(s,n)=>s.bindRenderbuffer(36161,n),36389:(s,n)=>s.bindTransformFeedback?.(36386,n),34229:(s,n)=>s.bindVertexArray(n),36006:B1t,36010:B1t,34964:yV,36662:yV,36663:yV,35053:yV,35055:yV,2886:(s,n)=>s.frontFace(n),33170:D1t,2849:(s,n)=>s.lineWidth(n),32823:Ff,32824:"polygonOffset",10752:"polygonOffset",35977:Ff,32926:Ff,32928:Ff,32938:"sampleCoverage",32939:"sampleCoverage",3089:Ff,3088:(s,n)=>s.scissor(...n),2960:Ff,2961:(s,n)=>s.clearStencil(n),2968:(s,n)=>s.stencilMaskSeparate(1028,n),36005:(s,n)=>s.stencilMaskSeparate(1029,n),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(s,n)=>s.viewport(...n),34383:Ff,10754:Ff,12288:Ff,12289:Ff,12290:Ff,12291:Ff,12292:Ff,12293:Ff,12294:Ff,12295:Ff,3333:j1,3317:j1,37440:j1,37441:j1,37443:j1,3330:j1,3332:j1,3331:j1,3314:j1,32878:j1,3316:j1,3315:j1,32877:j1,framebuffer:(s,n)=>{let r=n&&"handle"in n?n.handle:n;return s.bindFramebuffer(36160,r)},blend:(s,n)=>n?s.enable(3042):s.disable(3042),blendColor:(s,n)=>s.blendColor(...n),blendEquation:(s,n)=>{let r=typeof n=="number"?[n,n]:n;s.blendEquationSeparate(...r)},blendFunc:(s,n)=>{let r=n?.length===2?[...n,...n]:n;s.blendFuncSeparate(...r)},clearColor:(s,n)=>s.clearColor(...n),clearDepth:(s,n)=>s.clearDepth(n),clearStencil:(s,n)=>s.clearStencil(n),colorMask:(s,n)=>s.colorMask(...n),cull:(s,n)=>n?s.enable(2884):s.disable(2884),cullFace:(s,n)=>s.cullFace(n),depthTest:(s,n)=>n?s.enable(2929):s.disable(2929),depthFunc:(s,n)=>s.depthFunc(n),depthMask:(s,n)=>s.depthMask(n),depthRange:(s,n)=>s.depthRange(...n),dither:(s,n)=>n?s.enable(3024):s.disable(3024),derivativeHint:(s,n)=>{s.hint(35723,n)},frontFace:(s,n)=>s.frontFace(n),mipmapHint:(s,n)=>s.hint(33170,n),lineWidth:(s,n)=>s.lineWidth(n),polygonOffsetFill:(s,n)=>n?s.enable(32823):s.disable(32823),polygonOffset:(s,n)=>s.polygonOffset(...n),sampleCoverage:(s,n)=>s.sampleCoverage(n[0],n[1]||!1),scissorTest:(s,n)=>n?s.enable(3089):s.disable(3089),scissor:(s,n)=>s.scissor(...n),stencilTest:(s,n)=>n?s.enable(2960):s.disable(2960),stencilMask:(s,n)=>{n=iRe(n)?n:[n,n];let[r,c]=n;s.stencilMaskSeparate(1028,r),s.stencilMaskSeparate(1029,c)},stencilFunc:(s,n)=>{n=iRe(n)&&n.length===3?[...n,...n]:n;let[r,c,u,d,b,w]=n;s.stencilFuncSeparate(1028,r,c,u),s.stencilFuncSeparate(1029,d,b,w)},stencilOp:(s,n)=>{n=iRe(n)&&n.length===3?[...n,...n]:n;let[r,c,u,d,b,w]=n;s.stencilOpSeparate(1028,r,c,u),s.stencilOpSeparate(1029,d,b,w)},viewport:(s,n)=>s.viewport(...n)};N1t={blendEquation:(s,n,r)=>s.blendEquationSeparate(Iu(32777,n,r),Iu(34877,n,r)),blendFunc:(s,n,r)=>s.blendFuncSeparate(Iu(32969,n,r),Iu(32968,n,r),Iu(32971,n,r),Iu(32970,n,r)),polygonOffset:(s,n,r)=>s.polygonOffset(Iu(32824,n,r),Iu(10752,n,r)),sampleCoverage:(s,n,r)=>s.sampleCoverage(Iu(32938,n,r),Iu(32939,n,r)),stencilFuncFront:(s,n,r)=>s.stencilFuncSeparate(1028,Iu(2962,n,r),Iu(2967,n,r),Iu(2963,n,r)),stencilFuncBack:(s,n,r)=>s.stencilFuncSeparate(1029,Iu(34816,n,r),Iu(36003,n,r),Iu(36004,n,r)),stencilOpFront:(s,n,r)=>s.stencilOpSeparate(1028,Iu(2964,n,r),Iu(2965,n,r),Iu(2966,n,r)),stencilOpBack:(s,n,r)=>s.stencilOpSeparate(1029,Iu(34817,n,r),Iu(34818,n,r),Iu(34819,n,r))},rRe={enable:(s,n)=>s({[n]:!0}),disable:(s,n)=>s({[n]:!1}),pixelStorei:(s,n,r)=>s({[n]:r}),hint:(s,n,r)=>s({[n]:r}),useProgram:(s,n)=>s({35725:n}),bindRenderbuffer:(s,n,r)=>s({36007:r}),bindTransformFeedback:(s,n,r)=>s({36389:r}),bindVertexArray:(s,n)=>s({34229:n}),bindFramebuffer:(s,n,r)=>{switch(n){case 36160:return s({36006:r,36010:r});case 36009:return s({36006:r});case 36008:return s({36010:r});default:return null}},bindBuffer:(s,n,r)=>{let c={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[n];return c?s({[c]:r}):{valueChanged:!0}},blendColor:(s,n,r,c,u)=>s({32773:new Float32Array([n,r,c,u])}),blendEquation:(s,n)=>s({32777:n,34877:n}),blendEquationSeparate:(s,n,r)=>s({32777:n,34877:r}),blendFunc:(s,n,r)=>s({32969:n,32968:r,32971:n,32970:r}),blendFuncSeparate:(s,n,r,c,u)=>s({32969:n,32968:r,32971:c,32970:u}),clearColor:(s,n,r,c,u)=>s({3106:new Float32Array([n,r,c,u])}),clearDepth:(s,n)=>s({2931:n}),clearStencil:(s,n)=>s({2961:n}),colorMask:(s,n,r,c,u)=>s({3107:[n,r,c,u]}),cullFace:(s,n)=>s({2885:n}),depthFunc:(s,n)=>s({2932:n}),depthRange:(s,n,r)=>s({2928:new Float32Array([n,r])}),depthMask:(s,n)=>s({2930:n}),frontFace:(s,n)=>s({2886:n}),lineWidth:(s,n)=>s({2849:n}),polygonOffset:(s,n,r)=>s({32824:n,10752:r}),sampleCoverage:(s,n,r)=>s({32938:n,32939:r}),scissor:(s,n,r,c,u)=>s({3088:new Int32Array([n,r,c,u])}),stencilMask:(s,n)=>s({2968:n,36005:n}),stencilMaskSeparate:(s,n,r)=>s({[n===1028?2968:36005]:r}),stencilFunc:(s,n,r,c)=>s({2962:n,2967:r,2963:c,34816:n,36003:r,36004:c}),stencilFuncSeparate:(s,n,r,c,u)=>s({[n===1028?2962:34816]:r,[n===1028?2967:36003]:c,[n===1028?2963:36004]:u}),stencilOp:(s,n,r,c)=>s({2964:n,2965:r,2966:c,34817:n,34818:r,34819:c}),stencilOpSeparate:(s,n,r,c,u)=>s({[n===1028?2964:34817]:r,[n===1028?2965:34818]:c,[n===1028?2966:34819]:u}),viewport:(s,n,r,c,u)=>s({2978:[n,r,c,u]})},r2=(s,n)=>s.isEnabled(n),sRe={3042:r2,2884:r2,2929:r2,3024:r2,32823:r2,32926:r2,32928:r2,3089:r2,2960:r2,35977:r2},F1t=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068])});function bv(s,n){if(gtn(n))return;let r={};for(let u in n){let d=Number(u),b=O1t[u];b&&(typeof b=="string"?r[b]=!0:b(s,n[u],d))}let c=s.lumaState?.cache;if(c)for(let u in r){let d=N1t[u];d(s,n,c)}}function Ble(s,n=xV){if(typeof n=="number"){let u=n,d=sRe[u];return d?d(s,u):s.getParameter(u)}let r=Array.isArray(n)?n:Object.keys(n),c={};for(let u of r){let d=sRe[u];c[u]=d?d(s,Number(u)):s.getParameter(Number(u))}return c}function U1t(s){bv(s,xV)}function gtn(s){for(let n in s)return!1;return!0}var _B=Ve(()=>{oRe()});function G1t(s,n){if(s===n)return!0;if(z1t(s)&&z1t(n)&&s.length===n.length){for(let r=0;r{});function $1t(s,n){let r=s[n].bind(s);s[n]=function(u){if(u===void 0||F1t.has(u))return r(u);let d=wv.get(s);return u in d.cache||(d.cache[u]=r(u)),d.enable?d.cache[u]:r(u)},Object.defineProperty(s[n],"name",{value:`${n}-from-cache`,configurable:!1})}function mtn(s,n,r){if(!s[n])return;let c=s[n].bind(s);s[n]=function(...d){let b=wv.get(s),{valueChanged:w,oldValue:_}=r(b._updateCache,...d);return w&&c(...d),_},Object.defineProperty(s[n],"name",{value:`${n}-to-cache`,configurable:!1})}function btn(s){let n=s.useProgram.bind(s);s.useProgram=function(c){let u=wv.get(s);u.program!==c&&(n(c),u.program=c)}}var wv,aRe=Ve(()=>{_B();j1t();oRe();wv=class{static get(n){return n.lumaState}gl;program=null;stateStack=[];enable=!0;cache=null;log;initialized=!1;constructor(n,r){this.gl=n,this.log=r?.log||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(n={}){this.stateStack.push({})}pop(){let n=this.stateStack[this.stateStack.length-1];bv(this.gl,n),this.stateStack.pop()}trackState(n,r){if(this.cache=r?.copyState?Ble(n):Object.assign({},xV),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.lumaState=this,btn(n);for(let c in rRe){let u=rRe[c];mtn(n,c,u)}$1t(n,"getParameter"),$1t(n,"isEnabled")}_updateCache(n){let r=!1,c,u=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let d in n){let b=n[d],w=this.cache[d];G1t(b,w)||(r=!0,c=w,u&&!(d in u)&&(u[d]=w),this.cache[d]=b)}return{valueChanged:r,oldValue:c}}}});function EV(s){let n=s.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return n._polyfilled??=!1,n.extensions||={},s.luma=n,n}var cRe=Ve(()=>{});function V1t(s,n,r){let c="",u=_=>{let x=_.statusMessage;x&&(c||=x)};s.addEventListener("webglcontextcreationerror",u,!1);let d=r.failIfMajorPerformanceCaveat!==!0,b={preserveDrawingBuffer:!0,...r,failIfMajorPerformanceCaveat:!0},w=null;try{w||=s.getContext("webgl2",b),!w&&b.failIfMajorPerformanceCaveat&&(c||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.");let _=!1;if(!w&&d&&(b.failIfMajorPerformanceCaveat=!1,w=s.getContext("webgl2",b),_=!0),w||(w=s.getContext("webgl",{}),w&&(w=null,c||="Your browser only supports WebGL1")),!w)throw c||="Your browser does not support WebGL",new Error(`Failed to create WebGL context: ${c}`);let x=EV(w);x.softwareRenderer=_;let{onContextLost:T,onContextRestored:M}=n;return s.addEventListener("webglcontextlost",L=>T(L),!1),s.addEventListener("webglcontextrestored",L=>M(L),!1),w}finally{s.removeEventListener("webglcontextcreationerror",u,!1)}}var W1t=Ve(()=>{cRe()});function vv(s,n,r){return r[n]===void 0&&(r[n]=s.getExtension(n)||null),r[n]}var SV=Ve(()=>{});function H1t(s,n){let r=s.getParameter(7936),c=s.getParameter(7937);vv(s,"WEBGL_debug_renderer_info",n);let u=n.WEBGL_debug_renderer_info,d=s.getParameter(u?u.UNMASKED_VENDOR_WEBGL:7936),b=s.getParameter(u?u.UNMASKED_RENDERER_WEBGL:7937),w=d||r,_=b||c,x=s.getParameter(7938),T=q1t(w,_),M=wtn(w,_),L=vtn(w,_);return{type:"webgl",gpu:T,gpuType:L,gpuBackend:M,vendor:w,renderer:_,version:x,shadingLanguage:"glsl",shadingLanguageVersion:300}}function q1t(s,n){return/NVIDIA/i.exec(s)||/NVIDIA/i.exec(n)?"nvidia":/INTEL/i.exec(s)||/INTEL/i.exec(n)?"intel":/Apple/i.exec(s)||/Apple/i.exec(n)?"apple":/AMD/i.exec(s)||/AMD/i.exec(n)||/ATI/i.exec(s)||/ATI/i.exec(n)?"amd":/SwiftShader/i.exec(s)||/SwiftShader/i.exec(n)?"software":"unknown"}function wtn(s,n){return/Metal/i.exec(s)||/Metal/i.exec(n)?"metal":/ANGLE/i.exec(s)||/ANGLE/i.exec(n)?"opengl":"unknown"}function vtn(s,n){if(/SwiftShader/i.exec(s)||/SwiftShader/i.exec(n))return"cpu";switch(q1t(s,n)){case"apple":return _tn(s,n)?"integrated":"unknown";case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function _tn(s,n){return/Apple (M\d|A\d|GPU)/i.test(`${s} ${n}`)}var X1t=Ve(()=>{SV()});function Ole(s){switch(s){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(s))}var lRe=Ve(()=>{});function K1t(s){return s in Fle}function pRe(s,n,r){return J1t(s,n,r,new Set)}function J1t(s,n,r,c){let u=Fle[n];if(!u||c.has(n))return!1;c.add(n);let d=(u.features||[]).every(b=>J1t(s,b,r,c));return c.delete(n),d?(u.extensions||[]).every(b=>!!vv(s,b,r)):!1}function Q1t(s,n,r){let c=n.create,u=Ule[n.format];u?.gl===void 0&&(c=!1),u?.x&&(c=c&&!!vv(s,u.x,r)),n.format==="stencil8"&&(c=!1);let d=u?.r===!1?!1:u?.r===void 0||pRe(s,u.r,r),b=c&&n.render&&d&&Atn(s,n.format,r);return{format:n.format,create:c&&n.create,render:b,filter:c&&n.filter,blend:c&&n.blend,store:c&&n.store}}function Atn(s,n,r){let c=Ule[n],u=c?.gl;if(u===void 0||c?.x&&!vv(s,c.x,r))return!1;let d=s.getParameter(32873),b=s.getParameter(36006),w=s.createTexture(),_=s.createFramebuffer();if(!w||!_)return!1;let x=0,T=Number(s.getError());for(;T!==x;)T=s.getError();let M=!1;try{if(s.bindTexture(3553,w),s.texStorage2D(3553,1,u,1,1),Number(s.getError())!==x)return!1;s.bindFramebuffer(36160,_),s.framebufferTexture2D(36160,36064,3553,w,0),M=Number(s.checkFramebufferStatus(36160))===36053&&Number(s.getError())===x}finally{s.bindFramebuffer(36160,b),s.deleteFramebuffer(_),s.bindTexture(3553,d),s.deleteTexture(w)}return M}function zle(s){let n=Ule[s],r=Ltn(s),c=og.getInfo(s);return c.compressed&&(n.dataFormat=r),{internalFormat:r,format:n?.dataFormat||Ptn(c.channels,c.integer,c.normalized,r),type:c.dataType?Ole(c.dataType):n?.types?.[0]||5121,compressed:c.compressed||!1}}function e0t(s){switch(og.getInfo(s).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${s}`)}}function Ptn(s,n,r,c){if(c===6408||c===6407)return c;switch(s){case"r":return n&&!r?36244:6403;case"rg":return n&&!r?33320:33319;case"rgb":return n&&!r?36248:6407;case"rgba":return n&&!r?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function Ltn(s){let r=Ule[s]?.gl;if(r===void 0)throw new Error(`Unsupported texture format ${s}`);return r}var MV,TV,yB,xB,ytn,xtn,Etn,Stn,Mtn,Ttn,Y1t,Z1t,uRe,fRe,hRe,dRe,Nle,Ctn,Fle,Ule,EB=Ve(()=>{Vr();SV();lRe();MV="WEBGL_compressed_texture_s3tc",TV="WEBGL_compressed_texture_s3tc_srgb",yB="EXT_texture_compression_rgtc",xB="EXT_texture_compression_bptc",ytn="WEBGL_compressed_texture_etc",xtn="WEBGL_compressed_texture_astc",Etn="WEBGL_compressed_texture_etc1",Stn="WEBGL_compressed_texture_pvrtc",Mtn="WEBGL_compressed_texture_atc",Ttn="EXT_texture_norm16",Y1t="EXT_render_snorm",Z1t="EXT_color_buffer_float",uRe="snorm8-renderable-webgl",fRe="norm16-renderable-webgl",hRe="snorm16-renderable-webgl",dRe="float16-renderable-webgl",Nle="float32-renderable-webgl",Ctn="rgb9e5ufloat-renderable-webgl",Fle={"float32-renderable-webgl":{extensions:[Z1t]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[Y1t]},"norm16-webgl":{extensions:[Ttn]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[Y1t]},"float32-filterable":{extensions:["OES_texture_float_linear"]},"float16-filterable-webgl":{extensions:["OES_texture_half_float_linear"]},"texture-filterable-anisotropic-webgl":{extensions:["EXT_texture_filter_anisotropic"]},"texture-blend-float-webgl":{extensions:["EXT_float_blend"]},"texture-compression-bc":{extensions:[MV,TV,yB,xB]},"texture-compression-bc5-webgl":{extensions:[yB]},"texture-compression-bc7-webgl":{extensions:[xB]},"texture-compression-etc2":{extensions:[ytn]},"texture-compression-astc":{extensions:[xtn]},"texture-compression-etc1-webgl":{extensions:[Etn]},"texture-compression-pvrtc-webgl":{extensions:[Stn]},"texture-compression-atc-webgl":{extensions:[Mtn]}};Ule={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:uRe},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:uRe},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0,r:dRe},r16unorm:{gl:33322,rb:!0,r:fRe},r16snorm:{gl:36760,r:hRe},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759,r:uRe},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:dRe},rg16unorm:{gl:33324,r:fRe},rg16snorm:{gl:36761,r:hRe},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:Nle},rgb9e5ufloat:{gl:35901,r:Ctn},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852,r:!1},"rgb16snorm-webgl":{gl:36762,r:!1},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0,r:Nle},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:dRe},rgba16unorm:{gl:32859,rb:!0,r:fRe},rgba16snorm:{gl:36763,r:hRe},"rgb32float-webgl":{gl:34837,x:Z1t,r:Nle,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:Nle},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:MV},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:TV},"bc1-rgba-unorm":{gl:33777,x:MV},"bc1-rgba-unorm-srgb":{gl:35916,x:TV},"bc2-rgba-unorm":{gl:33778,x:MV},"bc2-rgba-unorm-srgb":{gl:35918,x:TV},"bc3-rgba-unorm":{gl:33779,x:MV},"bc3-rgba-unorm-srgb":{gl:35919,x:TV},"bc4-r-unorm":{gl:36283,x:yB},"bc4-r-snorm":{gl:36284,x:yB},"bc5-rg-unorm":{gl:36285,x:yB},"bc5-rg-snorm":{gl:36286,x:yB},"bc6h-rgb-ufloat":{gl:36495,x:xB},"bc6h-rgb-float":{gl:36494,x:xB},"bc7-rgba-unorm":{gl:36492,x:xB},"bc7-rgba-unorm-srgb":{gl:36493,x:xB},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37816},"astc-10x5-unorm-srgb":{gl:37848},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rgb2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}}});var t0t,Gle,n0t=Ve(()=>{Vr();SV();EB();t0t={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","html-in-canvas":s=>GLe()&&typeof s.texElementImage2D=="function","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},Gle=class extends p${gl;extensions;testedFeatures=new Set;constructor(n,r,c){super([],c),this.gl=n,this.extensions=r,vv(n,"EXT_color_buffer_float",r)}*[Symbol.iterator](){let n=this.getFeatures();for(let r of n)this.has(r)&&(yield r);return[]}has(n){return this.disabledFeatures?.[n]?!1:(this.testedFeatures.has(n)||(this.testedFeatures.add(n),K1t(n)&&pRe(this.gl,n,this.extensions)&&this.features.add(n),this.getWebGLFeature(n)&&this.features.add(n)),this.features.has(n))}initializeFeatures(){let n=this.getFeatures().filter(r=>r!=="polygon-mode-webgl");for(let r of n)this.has(r)}getFeatures(){return[...Object.keys(t0t),...Object.keys(Fle)]}getWebGLFeature(n){let r=t0t[n];return typeof r=="string"?!!vv(this.gl,r,this.extensions):typeof r=="function"?r(this.gl):!!r}}});var jle,i0t=Ve(()=>{Vr();jle=class extends d${get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxBindGroupsPlusVertexBuffers(){return 0}get maxBindingsPerBindGroup(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageBuffersInVertexStage(){return 0}get maxStorageBuffersInFragmentStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxStorageTexturesInVertexStage(){return 0}get maxStorageTexturesInFragmentStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get maxBufferSize(){return Number.MAX_SAFE_INTEGER}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxColorAttachments(){return this.getParameter(36063)}get maxColorAttachmentBytesPerSample(){return 0}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(n){super(),this.gl=n}getParameter(n){return this.limits[n]===void 0&&(this.limits[n]=this.gl.getParameter(n)),this.limits[n]||0}}});function ktn(s){return s<34069?s+34069:s}function Rtn(s){switch(s){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${s}`}}var s2,$le=Ve(()=>{Vr();EB();s2=class extends n4{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(n,r){super(n,r);let c=r.handle,u=c===null;this.device=n,this.gl=n.gl,this.handle=c||u?c:this.gl.createFramebuffer(),u||(n._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),r.handle||(this.autoCreateAttachmentTextures(),this.updateAttachments()))}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&!this.props.handle&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){let n=this.gl.bindFramebuffer(36160,this.handle);for(let r=0;r{Vr();$le();Vle=class extends g${device;handle=null;_framebuffer=null;get[Symbol.toStringTag](){return"WebGLCanvasContext"}constructor(n,r){super(r),this.device=n,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._configureDevice()}_configureDevice(){(this.drawingBufferWidth!==this._framebuffer?.width||this.drawingBufferHeight!==this._framebuffer?.height)&&this._framebuffer?.resize([this.drawingBufferWidth,this.drawingBufferHeight])}_getCurrentFramebuffer(){return this._framebuffer||=new s2(this.device,{id:"canvas-context-framebuffer",handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}}});var Wle,s0t=Ve(()=>{Vr();Wle=class extends m${device;handle=null;context2d;get[Symbol.toStringTag](){return"WebGLPresentationContext"}constructor(n,r={}){super(r),this.device=n;let c=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw new Error(`${c}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);let d=this.canvas.getContext("2d");if(!d)throw new Error(`${c}: Failed to create 2d presentation context`);this.context2d=d,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();let n=this.device.getDefaultCanvasContext(),[r,c]=n.getDrawingBufferSize();if(!(this.drawingBufferWidth===0||this.drawingBufferHeight===0||r===0||c===0||n.canvas.width===0||n.canvas.height===0)){if(r!==this.drawingBufferWidth||c!==this.drawingBufferHeight||n.canvas.width!==this.drawingBufferWidth||n.canvas.height!==this.drawingBufferHeight)throw new Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${r}x${c} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(n.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(n){let r=this.device.getDefaultCanvasContext();return r.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),r.getCurrentFramebuffer(n)}}});function o0t(s="id"){gRe[s]=gRe[s]||1;let n=gRe[s]++;return`${s}-${n}`}var gRe,a0t=Ve(()=>{gRe={}});function Itn(s){return s&cs.INDEX?34963:s&cs.VERTEX?34962:s&cs.UNIFORM?35345:34962}function Dtn(s){return s&cs.INDEX||s&cs.VERTEX?35044:s&cs.UNIFORM?35048:35044}var _v,Hle=Ve(()=>{Vr();_v=class extends cs{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength=0;bytesUsed=0;constructor(n,r={}){super(n,r),this.device=n,this.gl=this.device.gl;let c=typeof r=="object"?r.handle:void 0;this.handle=c||this.gl.createBuffer(),n._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=Itn(this.props.usage),this.glUsage=Dtn(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,r.data?this._initWithData(r.data,r.byteOffset,r.byteLength):this._initWithByteLength(r.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Buffer"):(this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle)),this.destroyed=!0,this.handle=null)}_initWithData(n,r=0,c=n.byteLength+r){let u=this.glTarget;this.gl.bindBuffer(u,this.handle),this.gl.bufferData(u,c,this.glUsage),this.gl.bufferSubData(u,r,n),this.gl.bindBuffer(u,null),this.bytesUsed=c,this.byteLength=c,this._setDebugData(n,r,c),this.props.handle?this.trackReferencedMemory(c,"Buffer"):this.trackAllocatedMemory(c)}_initWithByteLength(n){let r=n;n===0&&(r=new Float32Array(0));let c=this.glTarget;return this.gl.bindBuffer(c,this.handle),this.gl.bufferData(c,r,this.glUsage),this.gl.bindBuffer(c,null),this.bytesUsed=n,this.byteLength=n,this._setDebugData(null,0,n),this.props.handle?this.trackReferencedMemory(n,"Buffer"):this.trackAllocatedMemory(n),this}write(n,r=0){let c=ArrayBuffer.isView(n)?n:new Uint8Array(n),u=0,d=void 0,b=36663;this.gl.bindBuffer(b,this.handle),u!==0||d!==void 0?this.gl.bufferSubData(b,r,c,u,d):this.gl.bufferSubData(b,r,c),this.gl.bindBuffer(b,null),this._setDebugData(n,r,n.byteLength)}async mapAndWriteAsync(n,r=0,c=this.byteLength-r){let u=new ArrayBuffer(c);await n(u,"copied"),this.write(u,r)}async readAsync(n=0,r){return this.readSyncWebGL(n,r)}async mapAndReadAsync(n,r=0,c){let u=await this.readAsync(r,c);return await n(u.buffer,"copied")}readSyncWebGL(n=0,r){r=r??this.byteLength-n;let c=new Uint8Array(r),u=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,n,c,u,r),this.gl.bindBuffer(36662,null),this._setDebugData(c,n,r),c}}});function c0t(s){let n=s.split(/\r?\n/),r=[];for(let c of n){if(c.length<=1)continue;let u=c.trim(),d=c.split(":"),b=d[0]?.trim();if(d.length===2){let[I,D]=d;if(!I||!D){r.push({message:u,type:qle(b||"info"),lineNum:0,linePos:0});continue}r.push({message:D.trim(),type:qle(I),lineNum:0,linePos:0});continue}let[w,_,x,...T]=d;if(!w||!_||!x){r.push({message:d.slice(1).join(":").trim()||u,type:qle(b||"info"),lineNum:0,linePos:0});continue}let M=parseInt(x,10);Number.isNaN(M)&&(M=0);let L=parseInt(_,10);Number.isNaN(L)&&(L=0),r.push({message:T.join(":").trim(),type:qle(w),lineNum:M,linePos:L})}return r}function qle(s){let n=["warning","error","info"],r=s.toLowerCase();return n.includes(r)?r:"info"}var l0t=Ve(()=>{});function Btn(s){return s.split(/\r?\n/).find(n=>n.trim())?.trim()}var Xle,u0t=Ve(()=>{Vr();l0t();Xle=class extends t4{device;handle;_compilationInfoLog="";constructor(n,r){super(n,r),this.device=n;let c=this.props.handle;switch(this.props.stage){case"vertex":this.handle=c||this.device.gl.createShader(35633);break;case"fragment":this.handle=c||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}n._setWebGLDebugMetadata(this.handle,this,{spector:this.props});let u=this._compile(this.source);u&&typeof u.catch=="function"&&u.catch(()=>{this.compilationStatus="error"})}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let n=this._getCompilationInfoLog();return n?c0t(n):[]}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)||null}_compile(n){n=n.startsWith("#version ")?n:`#version 300 es +${n}`;let{gl:r}=this.device;if(r.shaderSource(this.handle,n),r.compileShader(this.handle),!this.device.props.debug){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus==="error")throw new Error(this._getCompilationErrorMessage(n));return}return Qt.once(1,"Shader compilation is asynchronous")(),this._waitForCompilationComplete().then(()=>{Qt.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()})}async _waitForCompilationComplete(){let n=async u=>await new Promise(d=>setTimeout(d,u));if(!this.device.features.has("compilation-status-async-webgl")){await n(10);return}let{gl:c}=this.device;for(;;){if(c.getShaderParameter(this.handle,37297))return;await n(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error",this.compilationStatus==="error"&&this._getCompilationInfoLog()}_getCompilationErrorMessage(n){let r=`${this.props.stage} shader ${this.props.id}`,c=Btn(this._getCompilationInfoLog()),u=this.getCompilationInfoSync(),d=u.find(T=>T.type==="error"&&T.message.trim())||u.find(T=>T.message.trim())||u.find(T=>T.type==="error")||u[0];if(!d)return c?`GLSL compilation errors in ${r}: ${c}`:`GLSL compilation errors in ${r}: WebGL did not provide a shader compiler log`;let b=d.lineNum?n.split(/\r?\n/)[d.lineNum-1]?.trim():void 0,w=d.lineNum?` line ${d.lineNum}`:"",_=b?` +Source: ${b}`:"",x=d.message.trim()||c||"WebGL did not provide a shader compiler log";return`GLSL compilation errors in ${r}:${w}: ${x}${_}`}_getCompilationInfoLog(){let n=this.device.gl.getShaderInfoLog(this.handle)?.trim();return n&&(this._compilationInfoLog=n),this._compilationInfoLog}}});function h0t(s,n,r,c){if(Utn(n))return c(s);let u=s;u.pushState();try{return Otn(s,n),bv(u.gl,r),c(s)}finally{u.popState()}}function Otn(s,n){let r=s,{gl:c}=r;if(n.cullMode)switch(n.cullMode){case"none":c.disable(2884);break;case"front":c.enable(2884),c.cullFace(1028);break;case"back":c.enable(2884),c.cullFace(1029);break}if(n.frontFace&&c.frontFace(P4("frontFace",n.frontFace,{ccw:2305,cw:2304})),n.unclippedDepth&&s.features.has("depth-clip-control")&&c.enable(34383),n.depthBias!==void 0&&(c.enable(32823),c.polygonOffset(n.depthBias,n.depthBiasSlopeScale||0)),n.provokingVertex&&s.features.has("provoking-vertex-webgl")){let d=r.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,b=P4("provokingVertex",n.provokingVertex,{first:36429,last:36430});d?.provokingVertexWEBGL(b)}if((n.polygonMode||n.polygonOffsetLine)&&s.features.has("polygon-mode-webgl")){if(n.polygonMode){let d=r.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,b=P4("polygonMode",n.polygonMode,{fill:6914,line:6913});d?.polygonModeWEBGL(1028,b),d?.polygonModeWEBGL(1029,b)}n.polygonOffsetLine&&c.enable(10754)}if(s.features.has("shader-clip-cull-distance-webgl")&&(n.clipDistance0&&c.enable(12288),n.clipDistance1&&c.enable(12289),n.clipDistance2&&c.enable(12290),n.clipDistance3&&c.enable(12291),n.clipDistance4&&c.enable(12292),n.clipDistance5&&c.enable(12293),n.clipDistance6&&c.enable(12294),n.clipDistance7&&c.enable(12295)),n.depthWriteEnabled!==void 0&&c.depthMask(Ftn("depthWriteEnabled",n.depthWriteEnabled)),n.depthCompare&&(n.depthCompare!=="always"?c.enable(2929):c.disable(2929),c.depthFunc(Zle("depthCompare",n.depthCompare))),n.clearDepth!==void 0&&c.clearDepth(n.clearDepth),n.stencilWriteMask){let u=n.stencilWriteMask;c.stencilMaskSeparate(1028,u),c.stencilMaskSeparate(1029,u)}if(n.stencilReadMask&&Qt.warn("stencilReadMask not supported under WebGL"),n.stencilCompare){let u=n.stencilReadMask||4294967295,d=Zle("depthCompare",n.stencilCompare);n.stencilCompare!=="always"?c.enable(2960):c.disable(2960),c.stencilFuncSeparate(1028,d,0,u),c.stencilFuncSeparate(1029,d,0,u)}if(n.stencilPassOperation&&n.stencilFailOperation&&n.stencilDepthFailOperation){let u=mRe("stencilPassOperation",n.stencilPassOperation),d=mRe("stencilFailOperation",n.stencilFailOperation),b=mRe("stencilDepthFailOperation",n.stencilDepthFailOperation);c.stencilOpSeparate(1028,d,b,u),c.stencilOpSeparate(1029,d,b,u)}switch(n.blend){case!0:c.enable(3042);break;case!1:c.disable(3042);break;default:}if(n.blendColorOperation||n.blendAlphaOperation){let u=f0t("blendColorOperation",n.blendColorOperation||"add"),d=f0t("blendAlphaOperation",n.blendAlphaOperation||"add");c.blendEquationSeparate(u,d);let b=Yle("blendColorSrcFactor",n.blendColorSrcFactor||"one"),w=Yle("blendColorDstFactor",n.blendColorDstFactor||"zero"),_=Yle("blendAlphaSrcFactor",n.blendAlphaSrcFactor||"one"),x=Yle("blendAlphaDstFactor",n.blendAlphaDstFactor||"zero");c.blendFuncSeparate(b,w,_,x)}}function Zle(s,n){return P4(s,n,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function mRe(s,n){return P4(s,n,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function f0t(s,n){return P4(s,n,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function Yle(s,n,r="color"){return P4(s,n,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:r==="color"?32769:32771,"one-minus-constant":r==="color"?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function Ntn(s,n){return`Illegal parameter ${n} for ${s}`}function P4(s,n,r){if(!(n in r))throw new Error(Ntn(s,n));return r[n]}function Ftn(s,n){return n}function Utn(s){let n=!0;for(let r in s){n=!1;break}return n}var bRe=Ve(()=>{Vr();_B()});function Kle(s){let n={};return s.addressModeU&&(n[10242]=wRe(s.addressModeU)),s.addressModeV&&(n[10243]=wRe(s.addressModeV)),s.addressModeW&&(n[32882]=wRe(s.addressModeW)),s.magFilter&&(n[10240]=vRe(s.magFilter)),(s.minFilter||s.mipmapFilter)&&(n[10241]=ztn(s.minFilter||"linear",s.mipmapFilter)),s.lodMinClamp!==void 0&&(n[33082]=s.lodMinClamp),s.lodMaxClamp!==void 0&&(n[33083]=s.lodMaxClamp),s.type==="comparison-sampler"&&(n[34892]=34894),s.compare&&(n[34893]=Zle("compare",s.compare)),s.maxAnisotropy&&(n[34046]=s.maxAnisotropy),n}function wRe(s){switch(s){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function vRe(s){switch(s){case"nearest":return 9728;case"linear":return 9729}}function ztn(s,n="none"){if(!n)return vRe(s);switch(n){case"none":return vRe(s);case"nearest":switch(s){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(s){case"nearest":return 9986;case"linear":return 9987}}}var _Re=Ve(()=>{bRe()});var Jle,d0t=Ve(()=>{Vr();_Re();Jle=class extends QL{device;handle;parameters;constructor(n,r){super(n,r),this.device=n,this.parameters=Kle(r),this.handle=r.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(n){for(let[r,c]of Object.entries(n)){let u=Number(r);switch(u){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,u,c);break;default:this.device.gl.samplerParameteri(this.handle,u,c);break}}}}});function yv(s,n,r){if(Gtn(n))return r(s);let{nocatch:c=!0}=n,u=wv.get(s);u.push(),bv(s,n);let d;if(c)d=r(s),u.pop();else try{d=r(s)}finally{u.pop()}return d}function Gtn(s){for(let n in s)return!1;return!0}var Qle=Ve(()=>{_B();aRe()});var o2,yRe=Ve(()=>{Vr();o2=class extends e4{device;gl;handle;texture;constructor(n,r){super(n,{...Pa.defaultProps,...r}),this.device=n,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}}});function eue(s){return jtn[s]}var jtn,xRe=Ve(()=>{jtn={5124:"sint32",5125:"uint32",5122:"sint16",5123:"uint16",5120:"sint8",5121:"uint8",5126:"float32",5131:"float16",33635:"uint16",32819:"uint16",32820:"uint16",33640:"uint32",35899:"uint32",35902:"uint32",34042:"uint32",36269:"uint32"}});function $tn(s,n=0){return n?new s.constructor(s.buffer,s.byteOffset+n,(s.byteLength-n)/s.BYTES_PER_ELEMENT):s}function Vtn(s,n){if(n%s.BYTES_PER_ELEMENT!==0)throw new Error(`Texture byteOffset ${n} must align to typed array element size ${s.BYTES_PER_ELEMENT}`);return n/s.BYTES_PER_ELEMENT}function Wtn(s){switch(s){case"1d":break;case"2d":return 3553;case"3d":return 32879;case"cube":return 34067;case"2d-array":return 35866;case"cube-array":break}throw new Error(s)}function CV(s,n,r){return n==="cube"?34069+r:s}var a2,tue=Ve(()=>{Vr();EB();_Re();Qle();yRe();xRe();a2=class extends Pa{device;gl;handle;sampler=void 0;view;glTarget;glFormat;glType;glInternalFormat;compressed;_textureUnit=0;_framebuffer=null;_framebufferAttachmentKey=null;constructor(n,r){super(n,r,{byteAlignment:1}),this.device=n,this.gl=this.device.gl;let c=zle(this.props.format);if(this.glTarget=Wtn(this.props.dimension),this.glInternalFormat=c.internalFormat,this.glFormat=c.format,this.glType=c.type,this.compressed=c.compressed,this.isHandleBorrowed&&this.props.handle===void 0)throw new Error("Borrowed WebGL textures require a texture handle");if(this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),!this.isHandleBorrowed){this.gl.bindTexture(this.glTarget,this.handle);let{dimension:u,width:d,height:b,depth:w,mipLevels:_,glTarget:x,glInternalFormat:T}=this;if(!this.compressed)switch(u){case"2d":case"cube":this.gl.texStorage2D(x,_,T,d,b);break;case"2d-array":case"3d":this.gl.texStorage3D(x,_,T,d,b,w);break;default:throw new Error(u)}this.gl.bindTexture(this.glTarget,null),this._initializeData(r.data)}this.ownsHandle?this.trackAllocatedMemory(this.getAllocatedByteLength(),"Texture"):this.trackReferencedMemory(this.getAllocatedByteLength(),"Texture"),this.isHandleBorrowed||this.setSampler(this.props.sampler),this.view=new o2(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this._framebuffer?.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.ownsHandle?(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory("Texture")):this.trackDeallocatedReferencedMemory("Texture"),this.destroyed=!0)}createView(n){return new o2(this.device,{...n,texture:this})}clone(n){if(this.isHandleBorrowed&&n&&(n.width!==this.width||n.height!==this.height))throw new Error(`Cannot resize borrowed read-only ${this}`);return super.clone(n)}setSampler(n={}){this._assertWritable("set sampler parameters on"),super.setSampler(n);let r=Kle(this.sampler.props);this._setSamplerParameters(r)}copyExternalImage(n){this._assertWritable("copy external image data into");let r=this._normalizeCopyExternalImageOptions(n);if(r.sourceX||r.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");let{glFormat:c,glType:u}=this,{image:d,depth:b,mipLevel:w,x:_,y:x,z:T,width:M,height:L}=r,I=CV(this.glTarget,this.dimension,T),D=r.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),yv(this.gl,D,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(I,w,_,x,M,L,c,u,d);break;case"2d-array":case"3d":this.gl.texSubImage3D(I,w,_,x,T,M,L,b,c,u,d);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:r.width,height:r.height}}copyElementImage(n){this._assertWritable("copy element image data into");let r=this._normalizeCopyElementImageOptions(n),{glFormat:c}=this,{element:u,depth:d,mipLevel:b,sourceX:w,sourceY:_,sourceWidth:x,sourceHeight:T,x:M,y:L,z:I,width:D,height:F}=r,O=CV(this.glTarget,this.dimension,I),z=r.flipY?{37440:!0}:{},Z=this.gl;if(d!==1||this.dimension!=="2d"&&this.dimension!=="cube")throw new Error(`${this} copyElementImage only supports 2d and cube textures on WebGL`);if(b!==0||M!==0||L!==0)throw new Error(`${this} copyElementImage only supports full base-level uploads on WebGL`);if(typeof Z.texElementImage2D!="function")throw new Error(`${this} copyElementImage is not supported by this WebGL implementation`);return this.gl.bindTexture(this.glTarget,this.handle),yv(this.gl,z,()=>{Z.texElementImage2D?.(O,c,u,{sx:w,sy:_,swidth:x??D,sheight:T??F,width:D,height:F})}),this.gl.bindTexture(this.glTarget,null),{width:r.width,height:r.height}}copyImageData(n){super.copyImageData(n)}readBuffer(n={},r){if(!r)throw new Error(`${this} readBuffer requires a destination buffer`);let c=this._getSupportedColorReadOptions(n),u=n.byteOffset??0,d=this.computeMemoryLayout(c);if(r.byteLength{this.gl.readPixels(c.x,c.y,c.width,c.height,this.glFormat,this.glType,u+w)})}finally{this.gl.bindBuffer(35051,null)}return r}async readDataAsync(n={}){throw new Error(`${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`)}writeBuffer(n,r={}){this._assertWritable("write buffer data into");let c=this._normalizeTextureWriteOptions(r),{width:u,height:d,depthOrArrayLayers:b,mipLevel:w,byteOffset:_,x,y:T,z:M}=c,{glFormat:L,glType:I,compressed:D}=this,F=CV(this.glTarget,this.dimension,M);if(D)throw new Error("writeBuffer for compressed textures is not implemented in WebGL");let{bytesPerPixel:O}=this.device.getTextureFormatInfo(this.format),z=O?c.bytesPerRow/O:void 0,Z={3317:this.byteAlignment,...z!==void 0?{3314:z}:{},32878:c.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,n.handle),yv(this.gl,Z,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(F,w,x,T,u,d,L,I,_);break;case"2d-array":case"3d":this.gl.texSubImage3D(F,w,x,T,M,u,d,b,L,I,_);break;default:}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(n,r={}){this._assertWritable("write data into");let c=this._normalizeTextureWriteOptions(r),u=ArrayBuffer.isView(n)?n:new Uint8Array(n),{width:d,height:b,depthOrArrayLayers:w,mipLevel:_,x,y:T,z:M,byteOffset:L}=c,{glFormat:I,glType:D,compressed:F}=this,O=CV(this.glTarget,this.dimension,M),z;if(!F){let{bytesPerPixel:ue}=this.device.getTextureFormatInfo(this.format);ue&&(z=c.bytesPerRow/ue)}let Z=this.compressed?{}:{3317:this.byteAlignment,...z!==void 0?{3314:z}:{},32878:c.rowsPerImage},H=Vtn(u,L),te=F?$tn(u,L):u,oe=this._getMipLevelSize(_),ne=x===0&&T===0&&M===0&&d===oe.width&&b===oe.height&&w===oe.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),yv(this.gl,Z,()=>{switch(this.dimension){case"2d":case"cube":F?ne?this.gl.compressedTexImage2D(O,_,I,d,b,0,te):this.gl.compressedTexSubImage2D(O,_,x,T,d,b,I,te):this.gl.texSubImage2D(O,_,x,T,d,b,I,D,u,H);break;case"2d-array":case"3d":F?ne?this.gl.compressedTexImage3D(O,_,I,d,b,w,0,te):this.gl.compressedTexSubImage3D(O,_,x,T,M,d,b,w,I,te):this.gl.texSubImage3D(O,_,x,T,M,d,b,w,I,D,u,H);break;default:}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(n,r){return 1}_getFramebuffer(){return this._framebuffer||=this.device.createFramebuffer({id:`framebuffer-for-${this.id}`,width:this.width,height:this.height,colorAttachments:[this]}),this._framebuffer}readDataSyncWebGL(n={}){let r=this._getSupportedColorReadOptions(n),c=this.computeMemoryLayout(r),u=eue(this.glType),d=JL(u),b=new d(c.byteLength/d.BYTES_PER_ELEMENT);return this._readColorTextureLayers(r,c,w=>{let _=new d(b.buffer,b.byteOffset+w,c.bytesPerImage/d.BYTES_PER_ELEMENT);this.gl.readPixels(r.x,r.y,r.width,r.height,this.glFormat,this.glType,_)}),b.buffer}_readColorTextureLayers(n,r,c){let u=this._getFramebuffer(),d=r.bytesPerRow/r.bytesPerPixel,b={3333:this.byteAlignment,...d!==n.width?{3330:d}:{}},w=this.gl.getParameter(3074),_=this.gl.bindFramebuffer(36160,u.handle);try{this.gl.readBuffer(36064),yv(this.gl,b,()=>{for(let x=0;x=2&&Qt.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(n))(),this.gl.bindTexture(this.glTarget,this.handle);for(let[r,c]of Object.entries(n)){let u=Number(r),d=c;switch(u){case 33082:case 33083:this.gl.texParameterf(this.glTarget,u,d);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,u,d);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,u,d);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,u,d);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,u,d);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(n){let{gl:r}=this;return n!==void 0&&(this._textureUnit=n,r.activeTexture(33984+n)),r.bindTexture(this.glTarget,this.handle),n}_unbind(n){let{gl:r}=this;return n!==void 0&&(this._textureUnit=n,r.activeTexture(33984+n)),r.bindTexture(this.glTarget,null),n}_assertWritable(n){if(this.isHandleBorrowed)throw new Error(`Cannot ${n} borrowed read-only ${this}`)}}});function p0t(s,n,r,c){let u=s,d=c;d===!0&&(d=1),d===!1&&(d=0);let b=typeof d=="number"?[d]:d;switch(r){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof c!="number")throw new Error("samplers must be set to integers");return s.uniform1i(n,c);case 5126:return s.uniform1fv(n,b);case 35664:return s.uniform2fv(n,b);case 35665:return s.uniform3fv(n,b);case 35666:return s.uniform4fv(n,b);case 5124:return s.uniform1iv(n,b);case 35667:return s.uniform2iv(n,b);case 35668:return s.uniform3iv(n,b);case 35669:return s.uniform4iv(n,b);case 35670:return s.uniform1iv(n,b);case 35671:return s.uniform2iv(n,b);case 35672:return s.uniform3iv(n,b);case 35673:return s.uniform4iv(n,b);case 5125:return u.uniform1uiv(n,b,1);case 36294:return u.uniform2uiv(n,b,2);case 36295:return u.uniform3uiv(n,b,3);case 36296:return u.uniform4uiv(n,b,4);case 35674:return s.uniformMatrix2fv(n,!1,b);case 35675:return s.uniformMatrix3fv(n,!1,b);case 35676:return s.uniformMatrix4fv(n,!1,b);case 35685:return u.uniformMatrix2x3fv(n,!1,b);case 35686:return u.uniformMatrix2x4fv(n,!1,b);case 35687:return u.uniformMatrix3x2fv(n,!1,b);case 35688:return u.uniformMatrix3x4fv(n,!1,b);case 35689:return u.uniformMatrix4x2fv(n,!1,b);case 35690:return u.uniformMatrix4x3fv(n,!1,b)}throw new Error("Illegal uniform")}var g0t=Ve(()=>{});function m0t(s){return qtn[s]}function nue(s){return Htn[s]}function iue(s){return!!w0t[s]}function b0t(s){return w0t[s]}var Htn,w0t,qtn,rue=Ve(()=>{Htn={5126:"f32",35664:"vec2",35665:"vec3",35666:"vec4",5124:"i32",35667:"vec2",35668:"vec3",35669:"vec4",5125:"u32",36294:"vec2",36295:"vec3",36296:"vec4",35670:"f32",35671:"vec2",35672:"vec3",35673:"vec4",35674:"mat2x2",35685:"mat2x3",35686:"mat2x4",35687:"mat3x2",35675:"mat3x3",35688:"mat3x4",35689:"mat4x2",35690:"mat4x3",35676:"mat4x4"},w0t={35678:{viewDimension:"2d",sampleType:"float"},35680:{viewDimension:"cube",sampleType:"float"},35679:{viewDimension:"3d",sampleType:"float"},35682:{viewDimension:"3d",sampleType:"depth"},36289:{viewDimension:"2d-array",sampleType:"float"},36292:{viewDimension:"2d-array",sampleType:"depth"},36293:{viewDimension:"cube",sampleType:"float"},36298:{viewDimension:"2d",sampleType:"sint"},36299:{viewDimension:"3d",sampleType:"sint"},36300:{viewDimension:"cube",sampleType:"sint"},36303:{viewDimension:"2d-array",sampleType:"uint"},36306:{viewDimension:"2d",sampleType:"uint"},36307:{viewDimension:"3d",sampleType:"uint"},36308:{viewDimension:"cube",sampleType:"uint"},36311:{viewDimension:"2d-array",sampleType:"uint"}},qtn={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126}});function _0t(s,n,r={}){let c={attributes:[],bindings:[]};c.attributes=Xtn(s,n);let u=Ktn(s,n,r);for(let _ of u){let x=_.uniforms.map(T=>({name:T.name,format:T.format,byteOffset:T.byteOffset,byteStride:T.byteStride,arrayLength:T.arrayLength}));c.bindings.push({type:"uniform",name:_.name,group:0,location:_.location,visibility:(_.vertex?1:0)|(_.fragment?2:0),minBindingSize:_.byteLength,uniforms:x})}let d=Ztn(s,n),b=0;for(let _ of d)if(iue(_.type)){let{viewDimension:x,sampleType:T}=b0t(_.type);c.bindings.push({type:"texture",name:_.name,group:0,location:b,viewDimension:x,sampleType:T}),_.textureUnit=b,b+=1}d.length&&(c.uniforms=d);let w=Ytn(s,n);return w?.length&&(c.varyings=w),c}function Xtn(s,n){let r=[],c=s.getProgramParameter(n,35721);for(let u=0;u=0){let x=nue(w),T=/instance/i.test(b)?"instance":"vertex";r.push({name:b,location:_,stepMode:T,type:x})}}return r.sort((u,d)=>u.location-d.location),r}function Ytn(s,n){let r=[],c=s.getProgramParameter(n,35971);for(let u=0;uu.location-d.location),r}function Ztn(s,n){let r=[],c=s.getProgramParameter(n,35718);for(let u=0;u1)for(let I=0;Ib.location-w.location),c}function Jtn(s,n){for(let r of s.uniforms){let c=n.uniforms.find(u=>r.name===u.name||r.name.endsWith(`.${u.name}`));if(!c)throw new Error(`Failed to validate WebGL uniform block "${n.name}": reflected unexpected member "${r.name}"`);if(r.format!==c.format||r.arrayLength!==c.arrayLength||r.byteOffset!==c.byteOffset||r.byteStride!==c.byteStride)throw new Error(`Failed to validate WebGL uniform block "${n.name}": reflected layout for "${r.name}" does not match supplied std140 metadata`)}}function Qtn(s,n,r){let c=new Map;for(let d of r.uniformBlockLayouts||[])c.set(d.name,tnn(d));for(let d of r.shaderLayout?.bindings||[])inn(d)&&c.set(d.name,d);let u=new Map;for(let d of c.values()){let b=enn(s,n,d.name);if(!b)continue;let{blockIndex:w,blockName:_}=b;if(u.has(w))throw new Error(`Multiple supplied uniform block layouts resolve to active WebGL block "${_}"`);u.set(w,{name:_,location:w,byteLength:d.minBindingSize,vertex:!!(d.visibility&&d.visibility&1),fragment:!!(d.visibility&&d.visibility&2),uniformCount:d.uniforms.length,uniforms:d.uniforms.map(x=>({...x}))})}return u}function enn(s,n,r){let c=r.endsWith("Uniforms")?[r,r.slice(0,-8)]:[r,`${r}Uniforms`];for(let u of c){let d=s.getUniformBlockIndex(n,u);if(d!==4294967295){if(!Number.isInteger(d)||d<0)throw new Error(`Failed to resolve WebGL uniform block "${u}": getUniformBlockIndex returned ${String(d)}`);return{blockIndex:d,blockName:u}}}return null}function v0t(s,n,r,c){let u=c||s.getActiveUniformBlockName(n,r);if(!u)throw new Error(`Failed to reflect WebGL uniform block at index ${r}: missing block name`);let d=(H,te)=>{let oe=s.getActiveUniformBlockParameter(n,r,H);if(oe==null)throw new Error(`Failed to reflect WebGL uniform block "${u}": ${te} returned null`);return oe},b=L4(d(35391,"UNIFORM_BLOCK_BINDING"),u,"UNIFORM_BLOCK_BINDING",0),w=L4(d(35392,"UNIFORM_BLOCK_DATA_SIZE"),u,"UNIFORM_BLOCK_DATA_SIZE",0),_=L4(d(35394,"UNIFORM_BLOCK_ACTIVE_UNIFORMS"),u,"UNIFORM_BLOCK_ACTIVE_UNIFORMS",0),x=y0t(d(35395,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES"),u,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",_),T=AV(s,n,x,35383,"UNIFORM_TYPE",u,_),M=AV(s,n,x,35384,"UNIFORM_SIZE",u,_),L=AV(s,n,x,35386,"UNIFORM_BLOCK_INDEX",u,_),I=AV(s,n,x,35387,"UNIFORM_OFFSET",u,_),D=AV(s,n,x,35388,"UNIFORM_ARRAY_STRIDE",u,_),F=[];for(let H=0;H<_;H++){if(L[H]!==r)throw new Error(`Failed to reflect WebGL uniform block "${u}": active uniform index ${x[H]} belongs to block ${L[H]}, expected ${r}`);let te=x[H],oe=s.getActiveUniform(n,te);if(!oe)throw new Error(`Failed to reflect WebGL uniform block "${u}": getActiveUniform(${te}) returned null`);let ne=L4(T[H],u,`UNIFORM_TYPE[${H}]`,1),ue=L4(M[H],u,`UNIFORM_SIZE[${H}]`,1),Te=L4(I[H],u,`UNIFORM_OFFSET[${H}]`,0),Q=L4(D[H],u,`UNIFORM_ARRAY_STRIDE[${H}]`,0);if(oe.type!==ne||oe.size!==ue)throw new Error(`Failed to reflect WebGL uniform block "${u}": getActiveUniform(${te}) disagrees with getActiveUniforms`);F.push({name:oe.name,format:nue(ne),arrayLength:ue,byteOffset:Te,byteStride:Q})}let O={name:u,location:b,byteLength:w,vertex:!!d(35396,"UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER"),fragment:!!d(35398,"UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER"),uniformCount:_,uniforms:F},z=new Set(O.uniforms.map(H=>H.name.split(".")[0]).filter(H=>!!H)),Z=O.name.replace(/Uniforms$/,"");if(z.size===1&&!z.has(O.name)&&!z.has(Z)){let[H]=z;Qt.warn(`Uniform block "${O.name}" uses GLSL instance "${H}". luma.gl binds uniform buffers by block name ("${O.name}") and alias ("${Z}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}return O}function AV(s,n,r,c,u,d,b){let w=s.getActiveUniforms(n,r,c);if(w===null)throw new Error(`Failed to reflect WebGL uniform block "${d}": ${u} returned null`);return y0t(w,d,u,b)}function y0t(s,n,r,c){if(!Array.isArray(s)&&!ArrayBuffer.isView(s))throw new Error(`Failed to reflect WebGL uniform block "${n}": ${r} returned a non-array value`);let u=Array.from(s);if(u.length!==c||u.some(d=>!Number.isInteger(d)))throw new Error(`Failed to reflect WebGL uniform block "${n}": ${r} returned ${u.length} invalid values, expected ${c}`);return u}function L4(s,n,r,c){if(!Number.isInteger(s)||s{if(typeof b=="string"){let w=n[d];if(!w)throw new Error(`Missing std140 layout field ${d}`);r.push({name:d,format:w.shaderType,arrayLength:1,byteOffset:w.offset*4,byteStride:0});return}if(Array.isArray(b)){u(d,b[0],b[1]);return}for(let[w,_]of Object.entries(b))c(`${d}.${w}`,_)},u=(d,b,w)=>{if(typeof b=="string"){let _=n[`${d}[0]`],x=w>1?n[`${d}[1]`]:void 0;if(!_)throw new Error(`Missing std140 array layout field ${d}[0]`);r.push({name:`${d}[0]`,format:_.shaderType,arrayLength:w,byteOffset:_.offset*4,byteStride:x?(x.offset-_.offset)*4:0});return}if(Array.isArray(b))throw new Error(`Nested uniform arrays are not supported for ${d}`);for(let[_,x]of Object.entries(b)){if(typeof x!="string")throw new Error(`Composite uniform array members are not supported for ${d}`);let T=`${d}[0].${_}`,M=`${d}[1].${_}`,L=n[T],I=w>1?n[M]:void 0;if(!L)throw new Error(`Missing std140 array layout field ${T}`);r.push({name:T,format:L.shaderType,arrayLength:w,byteOffset:L.offset*4,byteStride:I?(I.offset-L.offset)*4:0})}};for(let[d,b]of Object.entries(s))c(d,b);return r}function inn(s){return s.type==="uniform"&&Number.isInteger(s.minBindingSize)&&s.minBindingSize>=0&&Array.isArray(s.uniforms)&&s.uniforms.every(n=>typeof n.name=="string"&&typeof n.format=="string"&&Number.isInteger(n.arrayLength)&&n.arrayLength>0&&Number.isInteger(n.byteOffset)&&n.byteOffset>=0&&Number.isInteger(n.byteStride)&&n.byteStride>=0)}function rnn(s){if(s[s.length-1]!=="]")return{name:s,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(s);return{name:UM(r?.[1],`Failed to parse GLSL uniform name ${s}`),length:r?.[2]?1:0,isArray:!!r?.[2]}}var x0t=Ve(()=>{Vr();rue()});function snn(s,n){let r={...s,attributes:s.attributes.map(c=>({...c})),bindings:s.bindings.map(c=>({...c}))};for(let c of n?.attributes||[]){let u=r.attributes.find(d=>d.name===c.name);u?(u.type=c.type||u.type,u.stepMode=c.stepMode||u.stepMode):Qt.warn(`shader layout attribute ${c.name} not present in shader`)}for(let c of n?.bindings||[]){let u=S0t(r,c.name);if(!u){Qt.warn(`shader layout binding ${c.name} not present in shader`);continue}Object.assign(u,c)}return r}function S0t(s,n){return s.bindings.find(r=>r.name===n||r.name===`${n}Uniforms`||`${r.name}Uniforms`===n)}function E0t(s,n){return s[n]||s[`${n}Uniforms`]||s[n.replace(/Uniforms$/,"")]}var sue,M0t=Ve(()=>{Vr();g0t();Hle();$le();tue();yRe();x0t();sue=class extends Mb{device;handle;vs;fs;introspectedLayout;bindings={};uniforms={};varyings=null;_uniformCount=0;_uniformSetters={};get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}constructor(n,r){super(n,r),this.device=n;let c=this.sharedRenderPipeline||this.device._createSharedRenderPipelineWebGL(r);this.sharedRenderPipeline=c,this.handle=c.handle,this.vs=c.vs,this.fs=c.fs,this.linkStatus=c.linkStatus,this.introspectedLayout=_0t(this.device.gl,this.handle,{uniformBlockLayouts:r._uniformBlockLayouts,shaderLayout:r.shaderLayout}),this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.shaderLayout=r.shaderLayout?snn(this.introspectedLayout,r.shaderLayout):this.introspectedLayout}destroy(){this.destroyed||(this.sharedRenderPipeline&&!this.props._sharedRenderPipeline&&this.sharedRenderPipeline.destroy(),this.destroyResource())}setBindings(n,r){let c=GD(s4(this.shaderLayout,n));for(let[u,d]of Object.entries(c)){let b=S0t(this.shaderLayout,u);if(b){switch(d||Qt.warn(`Unsetting binding "${u}" in render pipeline "${this.id}"`)(),b.type){case"uniform":if(!(d instanceof _v)&&!(d.buffer instanceof _v))throw new Error("buffer value");break;case"texture":if(!(d instanceof o2||d instanceof a2||d instanceof s2))throw new Error(`${this} Bad texture binding for ${u}`);break;case"sampler":Qt.warn(`Ignoring sampler ${u}`)();break;default:throw new Error(b.type)}this.bindings[u]=d}else{let w=this.shaderLayout.bindings.map(_=>`"${_.name}"`).join(", ");r?.disableWarnings||Qt.warn(`No binding "${u}" in render pipeline "${this.id}", expected one of ${w}`,d)()}}}draw(n){let r=n.renderPass,c=n.bindGroups?GD(n.bindGroups):n.bindings||this.bindings;return r.setPipeline(this),r.setBindings(c),r.setVertexArray(n.vertexArray),r.draw({parameters:n.parameters,topology:n.topology,isInstanced:n.isInstanced,vertexCount:n.vertexCount,indexCount:n.indexCount,instanceCount:n.instanceCount,firstVertex:n.firstVertex,firstIndex:n.firstIndex,firstInstance:n.firstInstance,baseVertex:n.baseVertex,transformFeedback:n.transformFeedback,uniforms:n.uniforms})}_areTexturesRenderable(n){let r=!0;for(let c of this.shaderLayout.bindings)E0t(n,c.name)||(Qt.warn(`Binding ${c.name} not found in ${this.id}`)(),r=!1);return r}_applyBindings(n,r){if(this._syncLinkStatus(),this.linkStatus!=="success")return;let{gl:c}=this.device;c.useProgram(this.handle);let u=0,d=0;for(let b of this.shaderLayout.bindings){let w=E0t(n,b.name);if(!w)throw new Error(`No value for binding ${b.name} in ${this.id}`);switch(b.type){case"uniform":let{name:_}=b,x=c.getUniformBlockIndex(this.handle,_);if(x===4294967295)throw new Error(`Invalid uniform block name ${_}`);if(c.uniformBlockBinding(this.handle,x,d),w instanceof _v)c.bindBufferBase(35345,d,w.handle);else{let M=w;c.bindBufferRange(35345,d,M.buffer.handle,M.offset||0,M.size||M.buffer.byteLength-(M.offset||0))}d+=1;break;case"texture":if(!(w instanceof o2||w instanceof a2||w instanceof s2))throw new Error("texture");let T;if(w instanceof o2)T=w.texture;else if(w instanceof a2)T=w;else if(w instanceof s2&&w.colorAttachments[0]instanceof o2)Qt.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),T=w.colorAttachments[0].texture;else throw new Error("No texture");c.activeTexture(33984+u),c.bindTexture(T.glTarget,T.handle),u+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${b.type}' not supported in WebGL`)}}}_applyUniforms(n){for(let r of this.shaderLayout.uniforms||[]){let{name:c,location:u,type:d,textureUnit:b}=r,w=n[c]??b;w!==void 0&&p0t(this.device.gl,u,d,w)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}}});var T0t,oue,C0t=Ve(()=>{Vr();rue();T0t=4,oue=class extends w${device;handle;vs;fs;linkStatus="pending";constructor(n,r){super(n,r),this.device=n,this.handle=r.handle||this.device.gl.createProgram(),this.vs=r.vs,this.fs=r.fs,r.varyings&&r.varyings.length>0&&this.device.gl.transformFeedbackVaryings(this.handle,r.varyings,r.bufferMode||35981),this._linkShaders()}destroy(){this.destroyed||(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.handle.destroyed=!0,this.destroyResource())}async _linkShaders(){let{gl:n}=this.device;if(n.attachShader(this.handle,this.vs.handle),n.attachShader(this.handle,this.fs.handle),Qt.time(T0t,`linkProgram for ${this.id}`)(),n.linkProgram(this.handle),Qt.timeEnd(T0t,`linkProgram for ${this.id}`)(),!this.device.features.has("compilation-status-async-webgl")){let c=this._getLinkStatus();this._reportLinkStatus(c);return}Qt.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),Qt.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let r=this._getLinkStatus();this._reportLinkStatus(r)}async _reportLinkStatus(n){switch(n){case"success":return;default:let r=n==="link-error"?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${r} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader();break;case"success":break}switch(this.fs?.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`${this} ${r} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader();break;case"success":break}let c=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${r} during ${n}: ${c}`),this)(),this.device.debug()}}_getLinkStatus(){let{gl:n}=this.device;return n.getProgramParameter(this.handle,35714)?(this._initializeSamplerUniforms(),n.validateProgram(this.handle),n.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}_initializeSamplerUniforms(){let{gl:n}=this.device;n.useProgram(this.handle);let r=0,c=n.getProgramParameter(this.handle,35718);for(let u=0;u1){let b=Int32Array.from({length:r.size},(w,_)=>u+_);return d.uniform1iv(n,b),u+r.size}return d.uniform1i(n,u),u+1}async _waitForLinkComplete(){let n=async u=>await new Promise(d=>setTimeout(d,u));if(!this.device.features.has("compilation-status-async-webgl")){await n(10);return}let{gl:c}=this.device;for(;;){if(c.getProgramParameter(this.handle,37297))return;await n(10)}}}});function onn(s,n){let r=n.sourceBuffer,c=n.destinationBuffer;s.gl.bindBuffer(36662,r.handle),s.gl.bindBuffer(36663,c.handle),s.gl.copyBufferSubData(36662,36663,n.sourceOffset??0,n.destinationOffset??0,n.size),s.gl.bindBuffer(36662,null),s.gl.bindBuffer(36663,null)}function ann(s,n){let{sourceBuffer:r,byteOffset:c=0,destinationTexture:u,mipLevel:d=0,origin:b=[0,0,0],aspect:w="all",bytesPerRow:_,rowsPerImage:x,size:T}=n;if(w!=="all")throw new Error("copyBufferToTexture aspect is not supported in WebGL");u.writeBuffer(r,{byteOffset:c,bytesPerRow:_,rowsPerImage:x,mipLevel:d,x:b[0]??0,y:b[1]??0,z:b[2]??0,width:T[0],height:T[1],depthOrArrayLayers:T[2]})}function cnn(s,n){let{sourceTexture:r,mipLevel:c=0,aspect:u="all",width:d=n.sourceTexture.width,height:b=n.sourceTexture.height,depthOrArrayLayers:w,origin:_=[0,0,0],destinationBuffer:x,byteOffset:T=0,bytesPerRow:M,rowsPerImage:L}=n;if(r instanceof Pa){r.readBuffer({x:_[0]??0,y:_[1]??0,z:_[2]??0,width:d,height:b,depthOrArrayLayers:w,mipLevel:c,aspect:u,byteOffset:T},x);return}if(u!=="all")throw new Error("aspect not supported in WebGL");if(c!==0||w!==void 0||M||L)throw new Error("not implemented");let{framebuffer:I,destroyFramebuffer:D}=A0t(r),F;try{let O=x,z=d||I.width,Z=b||I.height,H=UM(I.colorAttachments[0]),te=zle(H.texture.props.format),oe=te.format,ne=te.type;s.gl.bindBuffer(35051,O.handle),F=s.gl.bindFramebuffer(36160,I.handle),s.gl.readPixels(_[0],_[1],z,Z,oe,ne,T)}finally{s.gl.bindBuffer(35051,null),F!==void 0&&s.gl.bindFramebuffer(36160,F),D&&I.destroy()}}function lnn(s,n){let{sourceTexture:r,destinationMipLevel:c=0,origin:u=[0,0],destinationOrigin:d=[0,0,0],destinationTexture:b}=n,{width:w=n.destinationTexture.width,height:_=n.destinationTexture.height}=n,{framebuffer:x,destroyFramebuffer:T}=A0t(r),[M=0,L=0]=u,[I,D,F]=d,O=s.gl.bindFramebuffer(36160,x.handle),z,Z;if(b instanceof a2)z=b,w=Number.isFinite(w)?w:z.width,_=Number.isFinite(_)?_:z.height,z._bind(0),Z=z.glTarget;else throw new Error("invalid destination");switch(Z){case 3553:case 34067:s.gl.copyTexSubImage2D(Z,c,I,D,M,L,w,_);break;case 35866:case 32879:s.gl.copyTexSubImage3D(Z,c,I,D,F,M,L,w,_);break;default:}z&&z._unbind(),s.gl.bindFramebuffer(36160,O),T&&x.destroy()}function A0t(s){if(s instanceof Pa){let{width:n,height:r,id:c}=s;return{framebuffer:s.device.createFramebuffer({id:`framebuffer-for-${c}`,width:n,height:r,colorAttachments:[s]}),destroyFramebuffer:!0}}return{framebuffer:s,destroyFramebuffer:!1}}var aue,P0t=Ve(()=>{Vr();EB();tue();aue=class extends y${device;handle=null;commands=[];constructor(n,r={}){super(n,r),this.device=n}_executeCommands(n=this.commands){for(let r of n)switch(r.name){case"copy-buffer-to-buffer":onn(this.device,r.options);break;case"copy-buffer-to-texture":ann(this.device,r.options);break;case"copy-texture-to-buffer":cnn(this.device,r.options);break;case"copy-texture-to-texture":lnn(this.device,r.options);break;default:throw new Error(r.name)}}}});function L0t(s){switch(s){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"triangle-list":return 4;case"triangle-strip":return 5;default:throw new Error(s)}}function k0t(s){switch(s){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;default:throw new Error(s)}}var ERe=Ve(()=>{});var unn,cue,R0t=Ve(()=>{Vr();Qle();_B();ERe();bRe();unn=[1,2,4,8],cue=class extends v${device;handle=null;glParameters={};pipeline=null;bindings={};bindingsPipeline=null;vertexArray=null;constructor(n,r){super(n,r),this.device=n;let c=this.props.framebuffer,u=!c||c.handle===null;u&&n.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();let d;if(!r?.parameters?.viewport)if(!u&&c){let{width:b,height:w}=c;d=[0,0,b,w]}else{let[b,w]=n.getDefaultCanvasContext().getDrawingBufferSize();d=[0,0,b,w]}if(this.device.pushState(),this.setParameters({viewport:d,...this.props.parameters}),!u&&c?.colorAttachments.length){let b=c.colorAttachments.map((w,_)=>36064+_);this.device.gl.drawBuffers(b)}else u&&this.device.gl.drawBuffers([1029]);this.clear(),this.props.timestampQuerySet&&this.props.beginTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.beginTimestampIndex)}end(){this.destroyed||(this.props.timestampQuerySet&&this.props.endTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.endTimestampIndex),this.device.popState(),this.destroy())}pushDebugGroup(n){}popDebugGroup(){}insertDebugMarker(n){}executeBundles(n){throw new Error("Render bundles are only supported in WebGPU")}setParameters(n={}){let r={...this.glParameters};r.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(r.depthMask=!this.props.depthReadOnly),r.stencilMask=this.props.stencilReadOnly?0:1,r[35977]=this.props.discard,n.viewport&&(n.viewport.length>=6?(r.viewport=n.viewport.slice(0,4),r.depthRange=[n.viewport[4],n.viewport[5]]):r.viewport=n.viewport),n.scissorRect&&(r.scissorTest=!0,r.scissor=n.scissorRect),n.blendConstant&&(r.blendColor=n.blendConstant),n.stencilReference!==void 0&&(r[2967]=n.stencilReference,r[36003]=n.stencilReference),"colorMask"in n&&(r.colorMask=unn.map(c=>!!(c&n.colorMask))),this.glParameters=r,bv(this.device.gl,r)}setPipeline(n){this.pipeline=n}setBindings(n,r){if(!this.pipeline)throw new Error("RenderPass.setPipeline() must be called before setBindings()");this.bindings=GD(s4(this.pipeline.shaderLayout,n)),this.bindingsPipeline=this.pipeline}setVertexArray(n){this.vertexArray=n}draw(n){let r=this.pipeline,c=this.vertexArray;if(!r)throw new Error("RenderPass.setPipeline() must be called before draw()");if(!c)throw new Error("RenderPass.setVertexArray() must be called before draw()");if(r.shaderLayout.bindings.length>0&&this.bindingsPipeline!==r)throw new Error("RenderPass.setBindings() must be called after setPipeline() before draw()");r._syncLinkStatus();let{parameters:u=r.props.parameters,topology:d=r.props.topology,vertexCount:b,indexCount:w,instanceCount:_,isInstanced:x=!1,firstVertex:T=0,transformFeedback:M,uniforms:L=r.uniforms}=n,I=L0t(d),D=!!c.indexBuffer,F=c.indexBuffer?.glIndexType,O=w??b??0;if(r.linkStatus!=="success")return Qt.info(2,`RenderPipeline:${r.id}.draw() aborted - waiting for shader linking`)(),!1;if(!r._areTexturesRenderable(this.bindings))return Qt.info(2,`RenderPipeline:${r.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(r.handle),c.bindBeforeRender(this);let z=M;return z&&z.begin(r.props.topology),r._applyBindings(this.bindings,{disableWarnings:r.props.disableWarnings}),r._applyUniforms(L),h0t(this.device,u,this.glParameters,()=>{D&&x?this.device.gl.drawElementsInstanced(I,O,F,T,_||0):D?this.device.gl.drawElements(I,O,F,T):x?this.device.gl.drawArraysInstanced(I,T,b||0,_||0):this.device.gl.drawArrays(I,T,b||0),z&&z.end()}),c.unbindAfterRender(this),!0}drawIndirect(n,r=0){throw new Error("Indirect drawing is only supported in WebGPU")}drawIndexedIndirect(n,r=0){throw new Error("Indirect drawing is only supported in WebGPU")}beginOcclusionQuery(n){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let n={...this.glParameters},r=0;this.props.clearColors&&this.props.clearColors.forEach((c,u)=>{c&&this.clearColorBuffer(u,c)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(r|=16384,n.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=256,n.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=1024,n.clearStencil=this.props.clearStencil),r!==0&&yv(this.device.gl,n,()=>{this.device.gl.clear(r)})}clearColorBuffer(n=0,r=[0,0,0,0]){yv(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,n,r);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,n,r);break;case Float32Array:this.device.gl.clearBufferfv(6144,n,r);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}});var PV,I0t=Ve(()=>{Vr();P0t();R0t();PV=class extends _${device;handle=null;commandBuffer;constructor(n,r){super(n,r),this.device=n,this.commandBuffer=new aue(n,{id:this.id,userData:this.userData})}destroy(){this.destroyResource()}finish(){return this.destroy(),this.commandBuffer}beginRenderPass(n={}){return new cue(this.device,this._applyTimeProfilingToPassProps(n))}beginComputePass(n={}){throw new Error("ComputePass not supported in WebGL")}copyBufferToBuffer(n){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:n})}copyBufferToTexture(n){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:n})}copyTextureToBuffer(n){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:n})}copyTextureToTexture(n){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:n})}pushDebugGroup(n){}popDebugGroup(){}insertDebugMarker(n){}resolveQuerySet(n,r,c){throw new Error("resolveQuerySet is not supported in WebGL")}writeTimestamp(n,r){n.writeTimestamp(r)}}});function D0t(s){let{target:n,source:r,start:c=0,count:u=1}=s,d=r.length,b=u*d,w=0;for(let _=c;w{});function fnn(s){return Array.isArray(s)?new Float32Array(s):s}function hnn(s,n){if(!s||!n||s.length!==n.length||s.constructor!==n.constructor)return!1;for(let r=0;r{Vr();VL();lRe();B0t();lue=class s extends x${get[Symbol.toStringTag](){return"VertexArray"}device;handle;attributeInfosByLocation;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(n){return yPe()==="Chrome"}constructor(n,r){super(n,r),this.device=n,this.handle=this.device.gl.createVertexArray(),this.attributeInfosByLocation=new Array(this.maxVertexAttributes).fill(null);for(let c of Object.values(A$(r.shaderLayout,r.bufferLayout)))this.attributeInfosByLocation[c.location]=c}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(n){let r=n;if(r&&r.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,r?r.handle:null),this.indexBuffer=r,this.device.gl.bindVertexArray(null)}setBuffer(n,r){let c=r;if(c.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:u,type:d,stride:b,offset:w,normalized:_,integer:x,divisor:T}=this._getAccessor(n);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,c.handle),x?this.device.gl.vertexAttribIPointer(n,u,d,b,w):this.device.gl.vertexAttribPointer(n,u,d,_,b,w),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(n),this.device.gl.vertexAttribDivisor(n,T||0),this.attributes[n]=c,this.device.gl.bindVertexArray(null)}setConstantWebGL(n,r){this._enable(n,!1),this.attributes[n]=r}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let n=0;n{Vr();fue();ERe();uue=class extends E${device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(n,r){super(n,r),this.device=n,this.gl=n.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,r.buffers&&this.setBuffers(r.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(n="point-list"){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(k0t(n))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(n){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let[r,c]of Object.entries(n))this.setBuffer(r,c)})}setBuffer(n,r){let c=this._getVaryingIndex(n),{buffer:u,byteLength:d,byteOffset:b}=this._getBufferRange(r);if(c<0){this.unusedBuffers[n]=u,Qt.warn(`${this.id} unusedBuffers varying buffer ${n}`)();return}this.buffers[c]={buffer:u,byteLength:d,byteOffset:b},this.bindOnUse||this._bindBuffer(c,u,b,d)}getBuffer(n){if(N0t(n))return this.buffers[n]||null;let r=this._getVaryingIndex(n);return this.buffers[r]??null}bind(n=this.handle){if(typeof n!="function")return this.gl.bindTransformFeedback(36386,n),this;let r;return this._bound?r=n():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,r=n(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),r}unbind(){this.bind(null)}_getBufferRange(n){if(n instanceof _v)return{buffer:n,byteOffset:0,byteLength:n.byteLength};let{buffer:r,byteOffset:c=0,byteLength:u=n.buffer.byteLength}=n;return{buffer:r,byteOffset:c,byteLength:u}}_getVaryingIndex(n){if(N0t(n))return Number(n);for(let r of this.layout.varyings||[])if(n===r.name)return r.location;return-1}_bindBuffers(){for(let[n,r]of Object.entries(this.buffers)){let{buffer:c,byteLength:u,byteOffset:d}=this._getBufferRange(r);this._bindBuffer(Number(n),c,d,u)}}_unbindBuffers(){for(let n in this.buffers)this.gl.bindBufferBase(35982,Number(n),null)}_bindBuffer(n,r,c=0,u){let d=r&&r.handle;!d||u===void 0?this.gl.bindBufferBase(35982,n,d):this.gl.bindBufferRange(35982,n,d,c,u)}}});var hue,U0t=Ve(()=>{Vr();hue=class extends S${device;handle;_timestampPairs=[];_pendingReads=new Set;_occlusionQuery=null;_occlusionActive=!1;get[Symbol.toStringTag](){return"QuerySet"}constructor(n,r){if(super(n,r),this.device=n,r.type==="timestamp"){if(r.count<2)throw new Error("Timestamp QuerySet requires at least two query slots");this._timestampPairs=new Array(Math.ceil(r.count/2)).fill(null).map(()=>({activeQuery:null,completedQueries:[]})),this.handle=null}else{if(r.count>1)throw new Error("WebGL occlusion QuerySet can only have one value");let c=this.device.gl.createQuery();if(!c)throw new Error("WebGL query not supported");this.handle=c}Object.seal(this)}destroy(){if(!this.destroyed){this.handle&&this.device.gl.deleteQuery(this.handle);for(let n of this._timestampPairs){n.activeQuery&&(this._cancelPendingQuery(n.activeQuery),this.device.gl.deleteQuery(n.activeQuery.handle));for(let r of n.completedQueries)this._cancelPendingQuery(r),this.device.gl.deleteQuery(r.handle)}this._occlusionQuery&&(this._cancelPendingQuery(this._occlusionQuery),this.device.gl.deleteQuery(this._occlusionQuery.handle));for(let n of Array.from(this._pendingReads))this._cancelPendingQuery(n);this.destroyResource()}}isResultAvailable(n){return this.props.type==="timestamp"?n===void 0?this._timestampPairs.some((r,c)=>this._isTimestampPairAvailable(c)):this._isTimestampPairAvailable(this._getTimestampPairIndex(n)):this._occlusionQuery?this._pollQueryAvailability(this._occlusionQuery):!1}async readResults(n){let r=n?.firstQuery||0,c=n?.queryCount||this.props.count-r;if(this._validateRange(r,c),this.props.type==="timestamp"){let u=new Array(c).fill(0n),d=Math.floor(r/2),b=Math.floor((r+c-1)/2);for(let w=d;w<=b;w++){let _=await this._consumeTimestampPairResult(w),x=w*2,T=x+1;x>=r&&x=r&&T=this.props.count||r<=n)throw new Error("Timestamp duration range is out of bounds");if(n%2!==0||r!==n+1)throw new Error("WebGL timestamp durations require adjacent even/odd query indices");let c=await this._consumeTimestampPairResult(this._getTimestampPairIndex(n));return Number(c)/1e6}beginOcclusionQuery(){if(this.props.type!=="occlusion")throw new Error("Occlusion queries require an occlusion QuerySet");if(!this.handle)throw new Error("WebGL occlusion query is not available");if(this._occlusionActive)throw new Error("Occlusion query is already active");this.device.gl.beginQuery(35887,this.handle),this._occlusionQuery={handle:this.handle,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null},this._occlusionActive=!0}endOcclusionQuery(){if(!this._occlusionActive)throw new Error("Occlusion query is not active");this.device.gl.endQuery(35887),this._occlusionActive=!1}writeTimestamp(n){if(this.props.type!=="timestamp")throw new Error("Timestamp writes require a timestamp QuerySet");let r=this._getTimestampPairIndex(n),c=this._timestampPairs[r];if(n%2===0){if(c.activeQuery)throw new Error("Timestamp query pair is already active");let u=this.device.gl.createQuery();if(!u)throw new Error("WebGL query not supported");let d={handle:u,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null};this.device.gl.beginQuery(35007,u),c.activeQuery=d;return}if(!c.activeQuery)throw new Error("Timestamp query pair was ended before it was started");this.device.gl.endQuery(35007),c.completedQueries.push(c.activeQuery),c.activeQuery=null}_validateRange(n,r){if(n<0||r<0||n+r>this.props.count)throw new Error("Query read range is out of bounds")}_getTimestampPairIndex(n){if(n<0||n>=this.props.count)throw new Error("Query index is out of bounds");return Math.floor(n/2)}_isTimestampPairAvailable(n){let r=this._timestampPairs[n];return!r||r.completedQueries.length===0?!1:this._pollQueryAvailability(r.completedQueries[0])}_pollQueryAvailability(n){if(n.cancelled||this.destroyed)return n.result=0n,!0;if(n.result!==null||n.disjoint)return!0;if(!this.device.gl.getQueryParameter(n.handle,34919))return!1;let c=!!this.device.gl.getParameter(36795);return n.disjoint=c,n.result=c?0n:BigInt(this.device.gl.getQueryParameter(n.handle,34918)),!0}async _consumeTimestampPairResult(n){let r=this._timestampPairs[n];if(!r||r.completedQueries.length===0)throw new Error("Timestamp query pair has no completed result");let c=r.completedQueries.shift();try{return await this._consumeQueryResult(c)}finally{this.device.gl.deleteQuery(c.handle)}}_consumeQueryResult(n){return n.promise||(this._pendingReads.add(n),n.promise=new Promise((r,c)=>{n.resolve=r,n.reject=c;let u=()=>{if(n.pollRequestId=null,n.cancelled||this.destroyed){this._pendingReads.delete(n),n.promise=null,n.resolve=null,n.reject=null,r(0n);return}if(!this._pollQueryAvailability(n)){n.pollRequestId=this._requestAnimationFrame(u);return}this._pendingReads.delete(n),n.promise=null,n.resolve=null,n.reject=null,n.disjoint?c(new Error("GPU timestamp query was invalidated by a disjoint event")):r(n.result||0n)};u()})),n.promise}_cancelPendingQuery(n){if(this._pendingReads.delete(n),n.cancelled=!0,n.pollRequestId!==null&&(this._cancelAnimationFrame(n.pollRequestId),n.pollRequestId=null),n.resolve){let r=n.resolve;n.promise=null,n.resolve=null,n.reject=null,r(0n)}}_requestAnimationFrame(n){return requestAnimationFrame(n)}_cancelAnimationFrame(n){cancelAnimationFrame(n)}}});var due,z0t=Ve(()=>{Vr();due=class extends M${device;gl;handle;signaled;_signaled=!1;constructor(n,r={}){super(n,{}),this.device=n,this.gl=n.gl;let c=this.props.handle||this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE,0);if(!c)throw new Error("Failed to create WebGL fence");this.handle=c,this.signaled=new Promise(u=>{let d=()=>{let b=this.gl.clientWaitSync(this.handle,0,0);b===this.gl.ALREADY_SIGNALED||b===this.gl.CONDITION_SATISFIED?(this._signaled=!0,u()):setTimeout(d,1)};d()})}isSignaled(){if(this._signaled)return!0;let n=this.gl.getSyncParameter(this.handle,this.gl.SYNC_STATUS);return this._signaled=n===this.gl.SIGNALED,this._signaled}destroy(){this.destroyed||this.gl.deleteSync(this.handle)}}});function SRe(s){switch(s){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function G0t(s){switch(s){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}var j0t=Ve(()=>{});function $0t(s,n){let{sourceX:r=0,sourceY:c=0,sourceAttachment:u=0}=n||{},{target:d=null,sourceWidth:b,sourceHeight:w,sourceDepth:_,sourceFormat:x,sourceType:T}=n||{},{framebuffer:M,deleteFramebuffer:L}=W0t(s),{gl:I,handle:D}=M;b||=M.width,w||=M.height;let F=M.colorAttachments[u]?.texture;if(!F)throw new Error(`Invalid framebuffer attachment ${u}`);_=F?.depth||1,x||=F?.glFormat||6408,T||=F?.glType||5121,d=pnn(d,T,x,b,w,_);let O=Md.getDataType(d);T=T||m0t(O);let z=I.bindFramebuffer(36160,D);return I.readBuffer(36064+u),I.readPixels(r,c,b,w,x,T,d),I.readBuffer(36064),I.bindFramebuffer(36160,z||null),L&&M.destroy(),d}function V0t(s,n){let{target:r,sourceX:c=0,sourceY:u=0,sourceFormat:d=6408,targetByteOffset:b=0}=n||{},{sourceWidth:w,sourceHeight:_,sourceType:x}=n||{},{framebuffer:T,deleteFramebuffer:M}=W0t(s);w=w||T.width,_=_||T.height;let L=T;x=x||5121;let I=r;if(!I){let F=SRe(d),O=G0t(x),z=b+w*_*F*O;I=L.device.createBuffer({byteLength:z})}let D=s.device.createCommandEncoder();return D.copyTextureToBuffer({sourceTexture:s,width:w,height:_,origin:[c,u],destinationBuffer:I,byteOffset:b}),D.destroy(),M&&T.destroy(),I}function W0t(s){return s instanceof n4?{framebuffer:s,deleteFramebuffer:!1}:{framebuffer:dnn(s),deleteFramebuffer:!0}}function dnn(s,n){let{device:r,width:c,height:u,id:d}=s;return r.createFramebuffer({...n,id:`framebuffer-for-${d}`,width:c,height:u,colorAttachments:[s]})}function pnn(s,n,r,c,u,d){if(s)return s;n||=5121;let b=eue(n),w=Md.getTypedArrayConstructor(b),_=SRe(r);return new w(c*u*_)}var H0t=Ve(()=>{Vr();rue();j0t();xRe()});function q0t(s){let n=new Map;for(let r in s){let c=s[r];if(r<"a"){let u=n.get(c);n.set(c,u?`${u}, GL.${r}`:`GL.${r}`)}}return n}var X0t=Ve(()=>{});var MRe={};Oy(MRe,{WebGLDevice:()=>KM});function gnn(s,n,r){switch(r.length){case 1:s.gl.vertexAttrib1fv(n,r);break;case 2:s.gl.vertexAttrib2fv(n,r);break;case 3:s.gl.vertexAttrib3fv(n,r);break;case 4:s.gl.vertexAttrib4fv(n,r);break;default:}}function mnn(s,n,r){s.gl.vertexAttribI4iv(n,r)}function bnn(s,n,r){s.gl.vertexAttribI4uiv(n,r)}function wnn(s,n){if(!s||!n||s.length!==n.length||s.constructor!==n.constructor)return!1;for(let r=0;r{Vr();aRe();W1t();cRe();X1t();n0t();i0t();r0t();s0t();nRe();EB();a0t();Hle();u0t();d0t();tue();$le();M0t();C0t();I0t();O0t();F0t();U0t();z0t();H0t();_B();Qle();SV();X0t();KM=class s extends A3{static getDeviceFromContext(n){return n?n.luma?.device??null:null}type="webgl";handle;features;limits;info;canvasContext;preferredColorFormat="rgba8unorm";preferredDepthFormat="depth24plus";commandEncoder;lost;_resolveContextLost;_isLost=!1;gl;_glKeyByValue=null;_constants;extensions;_polyfilled=!1;spectorJS;get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(n){switch(n){case"unorm8x4-bgra":return!1;default:return!0}}constructor(n){super({...n,id:n.id||o0t("webgl-device")});let r=A3._getCanvasContextProps(n);if(!r)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let c=r.canvas?.gl??null,u=s.getDeviceFromContext(c);if(u)throw new Error(`WebGL context already attached to device ${u.id}`);this.canvasContext=new Vle(this,r),this.lost=new Promise(T=>{this._resolveContextLost=T});let d={...n.webgl};r.alphaMode==="premultiplied"&&(d.premultipliedAlpha=!0),n.powerPreference!==void 0&&(d.powerPreference=n.powerPreference),n.failIfMajorPerformanceCaveat!==void 0&&(d.failIfMajorPerformanceCaveat=n.failIfMajorPerformanceCaveat);let w=this.props._handle||V1t(this.canvasContext.canvas,{onContextLost:T=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."}),onContextRestored:T=>{console.log("WebGL context restored")}},d);if(!w)throw new Error("WebGL context creation failed");if(u=s.getDeviceFromContext(w),u){if(n._reuseDevices)return Qt.log(1,`Not creating a new Device, instead returning a reference to Device ${u.id} already attached to WebGL context`,u)(),this.canvasContext.destroy(),u._reused=!0,u;throw new Error(`WebGL context already attached to device ${u.id}`)}this.handle=w,this.gl=w,this.spectorJS=I1t({...this.props,gl:this.handle});let _=EV(this.handle);_.device=this,_.extensions||(_.extensions={}),this.extensions=_.extensions,this.info=H1t(this.gl,this.extensions),this.limits=new jle(this.gl),this.features=new Gle(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new wv(this.gl,{log:(...T)=>Qt.log(1,...T)()}).trackState(this.gl,{copyState:!1}),(n.debug||n.debugWebGL)&&(this.gl=k1t(this.gl,{debugWebGL:!0,traceWebGL:n.debugWebGL}),Qt.warn("WebGL debug mode activated. Performance reduced.")()),n.debugWebGL&&(Qt.level=Math.max(Qt.level,1)),this.commandEncoder=new PV(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}destroy(){if(!this.props._reuseDevices&&!this._reused){this._isLost=!0,this.commandEncoder?.destroy();let n=EV(this.handle);n.device=null}}get isLost(){return this._isLost||this.gl.isContextLost()}createCanvasContext(n){throw new Error("WebGL only supports a single canvas")}createPresentationContext(n){return new Wle(this,n||{})}createBuffer(n){let r=this._normalizeBufferProps(n);return new _v(this,r)}createTexture(n){return new a2(this,n)}createExternalTexture(n){throw new Error("ExternalTexture is not available on WebGL")}createSampler(n){return new Jle(this,n)}createShader(n){return new Xle(this,n)}createFramebuffer(n){return new s2(this,n)}createVertexArray(n){return new lue(this,n)}createTransformFeedback(n){return new uue(this,n)}createQuerySet(n){return new hue(this,n)}createFence(){return new due(this)}createRenderPipeline(n){return new sue(this,n)}_createSharedRenderPipelineWebGL(n){return new oue(this,n)}createComputePipeline(n){throw new Error("ComputePipeline not supported in WebGL")}createRenderBundleEncoder(n){throw new Error("Render bundles are only supported in WebGPU")}createCommandEncoder(n={}){return new PV(this,n)}submit(n){let r=null;n||({submittedCommandEncoder:r,commandBuffer:n}=this._finalizeDefaultCommandEncoderForSubmit());try{n._executeCommands(),r&&r.resolveTimeProfilingQuerySet().then(()=>{this.commandEncoder._gpuTimeMs=r._gpuTimeMs}).catch(()=>{})}finally{n.destroy()}}writeBufferViaCommandEncoder(n,r,c,u=0){r.write(c,u)}_finalizeDefaultCommandEncoderForSubmit(){let n=this.commandEncoder,r=n.finish();return this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:n.props.id,timeProfilingQuerySet:n.getTimeProfilingQuerySet()}),{submittedCommandEncoder:n,commandBuffer:r}}readPixelsToArrayWebGL(n,r){return $0t(n,r)}readPixelsToBufferWebGL(n,r){return V0t(n,r)}setParametersWebGL(n){bv(this.gl,n)}getParametersWebGL(n){return Ble(this.gl,n)}withParametersWebGL(n,r){return yv(this.gl,n,r)}resetWebGL(){Qt.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),U1t(this.gl)}_getDeviceSpecificTextureFormatCapabilities(n){return Q1t(this.gl,n,this.extensions)}loseDevice(){let n=!1,c=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return c&&(n=!0,c.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),n}pushState(){wv.get(this.gl).push()}popState(){wv.get(this.gl).pop()}getGLKey(n,r){let c=this._getGLKeyByValue().get(Number(n));return c||(r?.emptyIfUnknown?"":String(n))}getGLKeys(n){let r={emptyIfUnknown:!0};return Object.entries(n).reduce((c,[u,d])=>(c[`${u}:${this.getGLKey(u,r)}`]=`${d}:${this.getGLKey(d,r)}`,c),{})}_getGLKeyByValue(){return this._glKeyByValue??=q0t(this.gl),this._glKeyByValue}setConstantAttributeWebGL(n,r){let c=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(c).fill(null);let u=this._constants[n];switch(u&&wnn(u,r)&&Qt.info(1,`setConstantAttributeWebGL(${n}) could have been skipped, value unchanged`)(),this._constants[n]=r,r.constructor){case Float32Array:gnn(this,n,r);break;case Int32Array:mnn(this,n,r);break;case Uint32Array:bnn(this,n,r);break;default:throw new Error("constant")}}getExtension(n){return vv(this.gl,n,this.extensions),this.extensions}_setWebGLDebugMetadata(n,r,c){n.luma=r;let u={props:c.spector,id:c.spector.id};n.__SPECTOR_Metadata=u}}});function vnn(s){return typeof WebGL2RenderingContext<"u"&&s instanceof WebGL2RenderingContext?!0:!!(s&&typeof s.createVertexArray=="function")}function Y0t(s){return{...s,debug:s.debug??A3.defaultProps.debug,debugWebGL:s.debugWebGL??A3.defaultProps.debugWebGL,debugSpectorJS:s.debugSpectorJS??!!Qt.get("debug-spectorjs")}}async function Z0t(s){let n=[];(s.debugWebGL||s.debug)&&n.push(L1t()),s.debugSpectorJS&&n.push(R1t(s));let r=await Promise.allSettled(n);for(let c of r)c.status==="rejected"&&Qt.error(`Failed to initialize debug libraries ${c.reason}`)()}var LV,TRe,kV,K0t=Ve(()=>{Vr();A1t();nRe();LV=1,TRe=class extends u${type="webgl";enforceWebGL2(n){C1t(n)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(n){return typeof WebGL2RenderingContext<"u"&&n instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext&&Qt.warn("WebGL1 is not supported",n)(),!1)}async attach(n,r={}){let{WebGLDevice:c}=await Promise.resolve().then(()=>(pue(),MRe));if(n instanceof c)return n;let u=c.getDeviceFromContext(n);if(u)return u;if(!vnn(n))throw new Error("Invalid WebGL2RenderingContext");r=Y0t(r),await Z0t(r);let d=r.createCanvasContext===!0?{}:r.createCanvasContext;return new c({...r,_handle:n,createCanvasContext:{canvas:n.canvas,autoResize:!1,...d}})}async create(n={}){let{WebGLDevice:r}=await Promise.resolve().then(()=>(pue(),MRe));n=Y0t(n),await Z0t(n);try{let c=new r(n);Qt.groupCollapsed(LV,`WebGLDevice ${c.id} created`)();let u=`${c._reused?"Reusing":"Created"} device with WebGL2 ${c.props.debug?"debug ":""}context: ${c.info.vendor}, ${c.info.renderer} for canvas: ${c.canvasContext.id}`;return Qt.probe(LV,u)(),Qt.table(LV,c.info)(),c}finally{Qt.groupEnd(LV)(),Qt.info(LV,"%cWebGL call tracing: luma.log.set('debug-webgl') ","color: white; background: blue; padding: 2px 6px; border-radius: 3px;")()}}};kV=new TRe});var fue=Ve(()=>{K0t();pue();Hle()});function vue(s){return obt.test(s)}function _ue(s){return abt.test(s)}function cbt(s){let n=obt.exec(s),r=abt.exec(s),c=n?.[1]??r?.[1]??s;try{hl.getVertexFormatInfo(c)}catch{throw new Error(`Unsupported GPUVector format ${s}`)}return c}function O3(s){let n=cbt(s),r=vue(s),c=_ue(s),u=hl.getVertexFormatInfo(n),d=u.type,b=u.normalized,w=Snn(d,b);return{format:s,elementFormat:n,vertexList:r,valueList:c,type:d,signedDataType:Mnn(n,d),primitiveType:w,components:u.components,byteLength:u.byteLength,integer:u.integer,signed:u.signed,normalized:b,...u.webglOnly?{webglOnly:!0}:{}}}function Snn(s,n){if(n)return"f32";switch(s){case"float32":return"f32";case"float16":return"f16";case"uint8":case"uint16":case"uint32":return"u32";case"sint8":case"sint16":case"sint32":return"i32";default:throw new Error(`Unsupported GPUVector component type ${s}`)}}function Mnn(s,n){if(s==="unorm10-10-10-2")return"uint32";switch(n){case"unorm8":return"uint8";case"snorm8":return"sint8";case"unorm16":return"uint16";case"snorm16":return"sint16";default:return n}}var obt,abt,yue=Ve(()=>{Vr();obt=/^vertex-list<([^<>]+)>$/,abt=/^value-list<([^<>]+)>$/});function PRe(s,n){if(!Number.isSafeInteger(s)||s<0)throw new Error(`${n} must be a non-negative safe integer`)}var N3,LRe=Ve(()=>{Vr();N3=class{buffer;format;length;byteOffset;byteStride;constructor(n){let r=hl.getVertexFormatInfo(n.format).byteLength,c=n.byteOffset??0,u=n.byteStride??r;if(PRe(n.length,"GPUDataView length"),PRe(c,"GPUDataView byteOffset"),PRe(u,"GPUDataView byteStride"),un.buffer.byteLength)throw new Error("GPUDataView exceeds its backing buffer byte length");this.buffer=n.buffer,this.format=n.format,this.length=n.length,this.byteOffset=c,this.byteStride=u}get elementByteLength(){return hl.getVertexFormatInfo(this.format).byteLength}get byteLength(){return this.length===0?0:(this.length-1)*this.byteStride+this.elementByteLength}}});function Eue(s){return!!(s&&typeof s=="object"&&s.type==="struct")}function ubt(s,n){let r=Object.entries(s);if(r.length===0)throw new Error("GPUData struct format must declare at least one field");return n==="packed"?Tnn(r):Cnn(r)}function Tnn(s){let n=[],r=0,c=0;for(let[u,d]of s){let b=hl.getVertexFormatInfo(d);if(b.webglOnly)throw new Error(`Packed GPUData struct field "${u}" uses WebGL-only format ${d}`);r=lbt(r,Math.min(4,b.byteLength)),n.push([u,Object.freeze({format:d,byteOffset:r,byteLength:b.byteLength})]),r+=b.byteLength,c+=b.components}return Object.freeze({type:"struct",layout:"packed",fields:Object.freeze(Object.fromEntries(n)),components:c,byteStride:lbt(r,4),rowByteLength:r})}function Cnn(s){let n=Object.fromEntries(s.map(([b,w])=>[b,Ann(w)])),r=o4(n,{layout:"wgsl-storage"}),c=[],u=0,d=0;for(let[b,w]of s){let _=hl.getVertexFormatInfo(w),x=r.fields[b].offset*4;c.push([b,Object.freeze({format:w,byteOffset:x,byteLength:_.byteLength})]),u=Math.max(u,x+_.byteLength),d+=_.components}return Object.freeze({type:"struct",layout:"wgsl-storage",fields:Object.freeze(Object.fromEntries(c)),components:d,byteStride:r.byteLength,rowByteLength:u})}function Ann(s){let n=hl.getVertexFormatInfo(s);switch(n.type){case"float32":return xue("f32",n.components);case"sint32":return xue("i32",n.components);case"uint32":return xue("u32",n.components);default:{let r=Math.ceil(n.byteLength/4);return xue("u32",r)}}}function xue(s,n){return n===1?s:`vec${n}<${s}>`}function lbt(s,n){return Math.ceil(s/n)*n}var fbt=Ve(()=>{Vr()});var kRe,RRe,SB,IRe=Ve(()=>{LRe();fbt();yue();kRe=class{buffer;ownsDataBuffer;constructor(n,r){this.buffer=n,this.ownsDataBuffer=r}get ownsBuffer(){return this.ownsDataBuffer}transferBufferOwnership(n){if(n.buffer!==this.buffer)throw new Error("GPUData ownership can only be transferred to the same buffer");n.ownsDataBuffer=this.ownsDataBuffer,this.ownsDataBuffer=!1}destroy(){this.ownsDataBuffer&&(this.buffer.destroy(),this.ownsDataBuffer=!1)}},RRe=class extends kRe{dataType;format;length;valueLength;stride;byteOffset;byteStride;rowByteLength;readbackMetadata;valueOffsets;nullBitmap;valueByteLength;constructor(n){let{buffer:r,format:c,length:u,valueLength:d,stride:b,byteOffset:w=0,byteStride:_,rowByteLength:x,ownsBuffer:T=!1,readbackMetadata:M,valueOffsets:L,nullBitmap:I,valueByteLength:D,dataType:F}=n;super(r,T);let O;c?typeof c=="string"?O=c:O=ubt(c,n.layout??"wgsl-storage"):O=void 0;let z=Eue(O)?O:void 0,Z=typeof O=="string"?O3(O):void 0;if(this.dataType=F,this.format=O,this.length=u,this.valueLength=d??u,this.stride=b??Z?.components??z?.components??_??x??1,this.byteOffset=w,this.rowByteLength=x??z?.rowByteLength??Z?.byteLength??_??this.stride,this.byteStride=_??z?.byteStride??this.rowByteLength,z){if(this.rowByteLengthc.format!==n))throw new Error("GPUVector data chunks must share the declared format")}var c2,dbt=Ve(()=>{IRe();yue();c2=class{name;dataType;format;length;valueLength;stride;byteOffset;byteStride;rowByteLength;bufferLayout;data=[];device;bufferProps;isAppendable=!1;ownsDataChunks=!0;ownedVectors=[];appendableByteLength=0;constructor(n){switch(n.type){case"buffer":{let{name:r,buffer:c,format:u,length:d,valueLength:b=d,byteOffset:w=0,ownsBuffer:_=!1}=n,{stride:x,byteStride:T,rowByteLength:M}=hbt(n);this.name=r,this.dataType=n.dataType,this.format=u,this.length=d,this.valueLength=b,this.stride=x,this.byteOffset=w,this.byteStride=T,this.rowByteLength=M,this.data.push(new SB({buffer:c,format:u,length:d,valueLength:b,stride:x,byteOffset:w,byteStride:T,rowByteLength:M,ownsBuffer:_,dataType:n.dataType}));return}case"interleaved":{let{name:r,buffer:c,format:u,length:d,valueLength:b=d,byteOffset:w=0,byteStride:_,attributes:x,ownsBuffer:T=!1}=n;this.name=r,this.dataType=n.dataType,this.format=u,this.length=d,this.valueLength=b,this.stride=_,this.byteOffset=w,this.byteStride=_,this.rowByteLength=_,this.bufferLayout={name:r,byteStride:_,attributes:x},this.data.push(new SB({buffer:c,format:u,length:d,valueLength:b,stride:_,byteOffset:w,byteStride:_,rowByteLength:_,ownsBuffer:T,dataType:n.dataType}));return}case"data":{let r=n.format??Pnn(n.data),c=r?O3(r):void 0,{name:u,data:d,stride:b=d[0]?.stride??c?.components??1,valueLength:w=d.reduce((L,I)=>L+I.valueLength,0),byteStride:_=d[0]?.byteStride??c?.byteLength,rowByteLength:x=d[0]?.rowByteLength??c?.byteLength,bufferLayout:T,ownsData:M=!1}=n;if(_===void 0||x===void 0)throw new Error("GPUVector requires format or explicit byte layout metadata");r&&Lnn(d,r),this.name=u,this.dataType=n.dataType,this.format=r,this.length=d.reduce((L,I)=>L+I.length,0),this.valueLength=w,this.stride=b,this.byteOffset=d.length===1?d[0].byteOffset:0,this.byteStride=_,this.rowByteLength=x,this.bufferLayout=T,this.ownsDataChunks=M,this.data.push(...d);return}case"appendable":{let{name:r,device:c,format:u,valueLength:d=0,bufferProps:b}=n,{stride:w,byteStride:_,rowByteLength:x}=hbt(n);this.name=r,this.dataType=n.dataType,this.format=u,this.length=0,this.valueLength=d,this.stride=w,this.byteOffset=0,this.byteStride=_,this.rowByteLength=x,this.device=c,this.bufferProps=b,this.isAppendable=!0;return}}}get ownsBuffer(){return this.ownsDataChunks&&this.data.some(n=>n.ownsBuffer)||this.ownedVectors.some(n=>n.ownsBuffer)}get capacityRows(){return this.isAppendable?this.length:void 0}get appendedByteLength(){return this.appendableByteLength}addData(n){if(this.format&&n.format!==this.format)throw new Error("GPUVector.addData() requires matching formats");if(n.byteStride!==this.byteStride)throw new Error("GPUVector.addData() requires matching byteStride");if(n.rowByteLength!==this.rowByteLength)throw new Error("GPUVector.addData() requires matching rowByteLength");return this.data.push(n),this.length+=n.length,this.valueLength+=n.valueLength,this}appendDataChunk(n,r=this.appendableByteLength+n.buffer.byteLength){if(!this.isAppendable)throw new Error("GPUVector.appendDataChunk() requires appendable vector storage");if(this.format&&n.format!==this.format)throw new Error("GPUVector.appendDataChunk() requires matching formats");if(n.byteStride!==this.byteStride||n.rowByteLength!==this.rowByteLength)throw new Error("GPUVector.appendDataChunk() requires matching byte layout metadata");return this.data.push(n),this.length+=n.length,this.valueLength+=n.valueLength,this.appendableByteLength=r,this}resetLastBatch(){if(!this.isAppendable)throw new Error("GPUVector.resetLastBatch() requires appendable vector storage");for(let n of this.data.splice(0))n.destroy();return this.length=0,this.valueLength=0,this.appendableByteLength=0,this}retainOwnedVectors(n){return this.ownedVectors.push(...n),this}transferBufferOwnership(n){let r=this.data[0],c=n.data[0];if(!r||!c||r.buffer!==c.buffer)throw new Error("GPUVector ownership can only be transferred to the same buffer");r.transferBufferOwnership(c)}destroy(){if(this.ownsDataChunks)for(let n of this.data)n.destroy();for(let n of this.ownedVectors.splice(0))n.destroy()}}});var DRe=Ve(()=>{IRe();LRe();dbt();yue()});var BRe,lg,OV=Ve(()=>{Vr();BRe=class{poolSize=20;bufferPools;constructor(){this.bufferPools=new Map}createOrReuse(n,r){if(r>n.limits.maxBufferSize)throw new Error(`Buffer pool cannot allocate ${r} bytes: device.limits.maxBufferSize is ${n.limits.maxBufferSize}`);let c=this.bufferPools.get(n),u=c?c.findIndex(b=>b.byteLength>=r):-1;if(u<0)return n.createBuffer({usage:cs.VERTEX|cs.STORAGE|cs.COPY_DST|cs.COPY_SRC,byteLength:r});let[d]=c.splice(u,1);return d}recycle(n){let r=n.device;this.bufferPools.has(r)||this.bufferPools.set(r,[]);let c=this.bufferPools.get(r),u=c.findIndex(d=>d.byteLength>n.byteLength);u<0?c.push(n):c.splice(u,0,n),this.purge()}purge(){for(let[n,r]of this.bufferPools){let c=n.isLost?0:this.poolSize;for(;r.length>c;)r.shift().destroy();r.length===0&&this.bufferPools.delete(n)}}},lg=new BRe});function knn(s,n,r,c){let{ValueType:u,size:d,offset:b,stride:w}=s,_=w/u.BYTES_PER_ELEMENT,x=b/u.BYTES_PER_ELEMENT,T=c-r;if(_===d){let L=x+r*_;return n.subarray(L,L+T*d)}let M=new u(T*d);for(let L=0;L0)throw new Error(`GPUDataEvaluator requires exactly one GPUData chunk for "${s.name}"`);return n}function Dnn(s){let n=[];return gbt(s,n,{byteOffset:0}),n}function gbt(s,n,r){let c=s.source;if(c&&!(c instanceof fc)&&c.name==="interleave"){for(let u of Object.values(c.inputs))u instanceof fc&&gbt(u,n,r);return}n.push({attribute:s.id??s.toString(),format:mbt(s.type,s.size,s.normalized),byteOffset:r.byteOffset}),r.byteOffset+=s.ValueType.BYTES_PER_ELEMENT*s.size}function mbt(s,n,r=!1){if(n<1||n>4)throw new Error(`Cannot synthesize a GPUVector vertex format with ${n} components`);let c=s;if(r)switch(s){case"uint8":c="unorm8";break;case"sint8":c="snorm8";break;case"uint16":c="unorm16";break;case"sint16":c="snorm16";break;case"float32":c="float32";break;default:throw new Error(`Unsupported normalized vertex format for ${s}`)}return(c==="uint8"||c==="sint8"||c==="uint16"||c==="sint16"||c==="unorm8"||c==="snorm8"||c==="unorm16"||c==="snorm16")&&n===3?`${c}x3-webgl`:`${c}${n===1?"":`x${n}`}`}function Bnn(s,n,r=!1){return n>=1&&n<=4?mbt(s,n,r):void 0}var fc,F3=Ve(()=>{Vr();Ql();DRe();OV();fc=class s{static get bufferPoolSize(){return lg.poolSize}static set bufferPoolSize(n){if(!Number.isSafeInteger(n)||n<0)throw new Error("GPUDataEvaluator.bufferPoolSize must be a non-negative safe integer");lg.poolSize=n,lg.purge()}type;size;get offset(){return this._offset}get stride(){return this._stride}normalized;isConstant;length;get byteLength(){return this._byteLength}ValueType;source=null;format;_id;_destroyed=!1;_value;_offset;_stride;_byteLength;_gpuVector;_bufferOwnership="owned";_targetBuffer;static fromArray(n,{type:r,size:c=1,offset:u=0,stride:d=0,normalized:b=!1}){let w=r,_;if(Array.isArray(n)){w=w||"float32";let T=KL(w);_=new T(n)}else n instanceof Float64Array?(w="uint32",c*=2,u*=2,d*=2,_=new Uint32Array(n.buffer,n.byteOffset,n.byteLength/4)):(w=w||yce(n),_=n);let x=`<${w} * ${c}>`;return new s({id:x,type:w,size:c,offset:u,stride:d,normalized:b,value:_})}static fromConstant(n,r="float32"){let c=KL(r),u;return Array.isArray(n)?u=`[${n.join(",")}]`:(u=String(n),n=[n]),new s({id:u,isConstant:!0,type:r,size:n.length,value:new c(n)})}static fromGPUData(n,r={}){Rnn(n);let c=new N3({buffer:n.buffer,format:n.format,length:n.length,byteOffset:n.byteOffset,byteStride:n.byteStride});return new s({...pbt(c),id:r.id,gpuData:n})}static fromGPUDataView(n,r={}){return new s({...pbt(n),id:r.id,buffer:n.buffer})}constructor(n){let{id:r,value:c,buffer:u,gpuData:d,format:b,source:w=null,isConstant:_=!1}=n;if(!w&&!c&&!u&&!d)throw new Error("GPUDataEvaluator must have a value source");let{type:x,size:T,offset:M,stride:L,normalized:I,length:D}=n;if(w instanceof s?(x=x??w.type,T=T??w.size,M=M??w.offset,L=L??w.stride,I=I??w.normalized,D=D??w.length):(T=T??1,M=M??0,I=I??!1,D=_?1:D),!x)throw new Error("GPUDataEvaluator: type not defined");if(this._id=r,this.type=x,this.size=T,this.ValueType=KL(this.type),this._offset=M,this._stride=L||this.ValueType.BYTES_PER_ELEMENT*T,this.normalized=I,this.source=w,this.format=b,D===void 0)if(_)D=1;else{if(!c)throw new Error("GPUDataEvaluator: length not defined");D=Math.ceil(c.byteLength/this.stride)}this.isConstant=_,this.length=D;let F=this.ValueType.BYTES_PER_ELEMENT*this.size;this._byteLength=D===0?0:(D-1)*this.stride+F,this._value=c,this._bufferOwnership=w instanceof s||u||d?"borrowed":"owned",d?this._gpuVector=new c2({type:"data",name:this._id??"data",format:d.format,data:[d],stride:d.stride,byteStride:d.byteStride,rowByteLength:d.rowByteLength}):u&&(this._gpuVector=this.createGPUVectorView({buffer:u,name:this._id,format:this.format}))}get value(){return this._value||(this.source instanceof s?this.source.value:void 0)}get evaluated(){return!!this._gpuVector}get id(){return this._id}get gpuVector(){if(!this._gpuVector)throw new Error(`${this} not evaluated`);return this._gpuVector}get buffer(){return Sue(this.gpuVector)}setTargetBuffer({buffer:n,byteOffset:r=0,byteStride:c=this.stride}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)throw new Error(`GPUDataEvaluator ${this} already evaluated`);if(!this.source||this.source instanceof s)throw new Error("GPUDataEvaluator target buffers require a deferred operation source");this._targetBuffer={buffer:n,byteOffset:r,byteStride:c}}async evaluate(n,r={}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let c;if(this.source instanceof s){let u=await this.source.evaluate(n);return this._gpuVector=this.createGPUVectorView({...r,buffer:Sue(u)}),this._gpuVector}if(c=this._getEvaluationBuffer(n),this._value)c.write(this._value);else{let u=await this.source.execute(n,c);if(!u.success)throw u.error||new Error(`${this.source} evaluation failed`);u.value&&(this._value=u.value)}return this._gpuVector=this.createGPUVectorView({...r,buffer:c}),this._gpuVector}evaluateSync(n,r={}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let c;if(this.source instanceof s){let u=this.source.evaluateSync(n);return this._gpuVector=this.createGPUVectorView({...r,buffer:Sue(u)}),this._gpuVector}if(c=this._getEvaluationBuffer(n),this._value)c.write(this._value);else{let u=this.source.executeSync(n,c);if(!u.success)throw u.error||new Error(`${this.source} evaluation failed`);u.value&&(this._value=u.value)}return this._gpuVector=this.createGPUVectorView({...r,buffer:c}),this._gpuVector}createGPUVectorView(n){let r=n.name??this._id??"vector",c=n.format??this.format??Bnn(this.type,this.size,this.normalized);if(n.interleaved){let u=typeof n.interleaved=="object"&&n.interleaved.attributes?n.interleaved.attributes:Dnn(this);return new c2({type:"interleaved",name:r,buffer:n.buffer,format:n.format??this.format,length:this.length,byteOffset:this.offset,byteStride:this.stride,attributes:u,ownsBuffer:!1})}return new c2({type:"buffer",name:r,buffer:n.buffer,format:c,length:this.length,stride:this.size,byteOffset:this.offset,byteStride:this.stride,rowByteLength:this.ValueType.BYTES_PER_ELEMENT*this.size,ownsBuffer:!1})}_getEvaluationBuffer(n){let r=this._targetBuffer;if(!r)return lg.createOrReuse(n,this.byteLength);if(r.buffer.device!==n)throw new Error("GPUDataEvaluator target buffer belongs to a different device");let c=this.ValueType.BYTES_PER_ELEMENT*this.size,u=this.length===0?0:(this.length-1)*r.byteStride+c;if(r.byteOffset+u>r.buffer.byteLength)throw new Error("GPUDataEvaluator target buffer is too small for the output layout");return this._offset=r.byteOffset,this._stride=r.byteStride,this._byteLength=u,this._bufferOwnership="borrowed",this._targetBuffer=void 0,r.buffer}async readValue(n=0,r){let{ValueType:c}=this,{size:u,offset:d,stride:b,length:w}=this,_=c.BYTES_PER_ELEMENT*u;if(r=r??w,n=Math.max(0,Math.min(w,n)),r=Math.max(n,Math.min(w,r)),this._value)return knn(this,this._value,n,r);let x=r-n;if(x===0)return new c(0);let T=d+n*b,M=b===_?x*_:(x-1)*b+_,L=await this.buffer.readAsync(T,M),I=new c(L.buffer,L.byteOffset,L.byteLength/c.BYTES_PER_ELEMENT);if(b===_)return I;let D=new Uint8Array(_*x);for(let F=0;F{MB={add:{arity:2,symbol:"arithmetic_add"},subtract:{arity:2,symbol:"arithmetic_subtract"},multiply:{arity:2,symbol:"arithmetic_multiply"},divide:{arity:2,symbol:"arithmetic_divide"},pow:{arity:2,symbol:"pow"},sqrt:{arity:1,symbol:"sqrt"},abs:{arity:1,symbol:"abs"},sin:{arity:1,symbol:"sin"},cos:{arity:1,symbol:"cos"},tan:{arity:1,symbol:"arithmetic_tan"},exp:{arity:1,symbol:"exp"},log:{arity:1,symbol:"log"}}});function kbt(s,{operations:n,inputs:r}){switch(s.kind){case"input":if(!(s.name in r))throw new Error(`Unknown expression input '${s.name}'`);return;case"literal":if(Array.isArray(s.value)){for(let c of s.value)if(!Number.isFinite(c))throw new Error(`Expression literal array must contain only finite values, got ${c}`)}else if(!Number.isFinite(s.value))throw new Error(`Expression literal must be finite, got ${s.value}`);return;case"call":{let c=n[s.op];if(!c)throw new Error(`Unknown expression op '${s.op}'`);if(s.args.length!==c.arity)throw new Error(`Expression op '${s.op}' expects ${c.arity} args, got ${s.args.length}`);for(let u of s.args)kbt(u,{operations:n,inputs:r});return}default:{let c=s;throw new Error(`Unsupported expression node ${c.kind}`)}}}function Cue(s,n){return kbt(s,n),Rbt(s,n)}function Rbt(s,n){switch(s.kind){case"input":{let r=n.inputs[s.name];return n.laneIndexRbt(u,n));return n.formatCall(r.symbol,c)}default:{let r=s;throw new Error(`Unsupported expression node ${r.kind}`)}}}var URe=Ve(()=>{});function hp(s,n,r=!1){if(r)return n===1?"float":`vec${n}`;switch(s){case"uint8":case"uint16":case"uint32":return n===1?"uint":`uvec${n}`;case"sint8":case"sint16":case"sint32":return n===1?"int":`ivec${n}`;default:return n===1?"float":`vec${n}`}}function Aue(s,n,r=!1){let c;if(r)switch(s){case"uint8":c="unorm8";break;case"sint8":c="snorm8";break;case"uint16":c="unorm16";break;case"sint16":c="snorm16";break;case"float32":c="float32";break;default:throw new Error(`Unsupported normalized vertex format for ${s}`)}else c=s;return n===1?c:n===3&&!c.startsWith("float32")&&!c.endsWith("32")?`${c}x3-webgl`:`${c}x${n}`}function JM(s){switch(s[0]){case"u":return"0u";case"s":return"0";default:return"0."}}function Ibt(s,n){switch(s){case"uint8":case"uint16":case"uint32":return`${Math.trunc(n)}u`;case"sint8":case"sint16":case"sint32":return`${Math.trunc(n)}`;default:return Number.isInteger(n)?`${n}.0`:`${n}`}}function Dbt(s){switch(s){case"uint8":return"r8uint";case"sint8":return"r8sint";case"uint16":return"r16uint";case"sint16":return"r16sint";case"uint32":return"r32uint";case"sint32":return"r32sint";case"float32":return"r32float";default:throw new Error(`Unsupported WebGL gather texture format for ${s}`)}}function Bbt(s){switch(s){case"uint32":return"usampler2D";case"sint32":return"isampler2D";case"float32":return"sampler2D";default:throw new Error(`Unsupported WebGL gather sampler type for ${s}`)}}var CB=Ve(()=>{});function dp({module:s,elementWise:n=!1,expression:r,inputs:c,output:u,operationType:d=u.type,outputBuffer:b}){let w=b.device,_=R4("result",u.type,u.size,u.normalized),x=[s,_],T=[],M={},L=hp(u.type,1,u.normalized),I=hp(d,1,u.normalized),D="",F=null,O={TYPE:I,RESULT_LEN:u.size.toString()},z=Vnn(c);for(let[oe,ne]of z)x.push(zRe(oe,ne.type,ne.size,ne.normalized,d)),T.push(GRe(oe,ne)),ne instanceof fc?M[oe]=ne.buffer:(F=F||lg.createOrReuse(w,b.byteLength),M[oe]=F),D+=`TYPE ${oe}[${ne.size}]; get_${oe}(${oe}); `,O[`${oe.toUpperCase()}_LEN`]=ne.size.toString();let Z="";if(r)for(let oe=0;oeoeoe).join(", ")}, result);`;let H=`#version 300 es @@ -2538,7 +2538,7 @@ ${L} result[${u.size}]; ${Z} set_result(result); } - `,te=new fp(w,{vs:H,shaderAssembler:znn,defines:O,modules:x,bufferLayout:T,vertexCount:1,instanceCount:u.length,attributes:M,feedbackBufferMode:"interleaved",outputs:_.varyings});w.statsManager.getStats(Fnn).get(Unn).incrementCount(),te.run({inputBuffers:M,outputBuffers:{[_.varyings[0]]:u.offset===0?b:{buffer:b,byteOffset:u.offset,byteLength:u.byteLength}}}),F&&lg.recycle(F)}function Gnn(s){return Array.isArray(s)?s.map((n,r)=>[`x${r}`,n]):Object.entries(s)}function zRe(s,n,r,c=!1,u=n){let d="",b="";for(let _=0;_[`x${r}`,n]):Object.entries(s)}function zRe(s,n,r,c=!1,u=n){let d="",b="";for(let _=0;_1&&(L=`${L}[${M}]`),(c||n!==u)&&(L=`TYPE(${L})`),b+=`v[${_+M}]=${L}; `}}let w=` ${d} @@ -2552,7 +2552,7 @@ ${b} void set_${s}(in ${d} v[${r}]) { ${w} } -`}}var Fnn,Unn,znn,$1=Ve(()=>{Ql();vm();F3();OV();CB();Fnn="GPGPU Operation Counts",Unn="Transform Runs",znn=new HD});var jnn,Pue,jRe=Ve(()=>{vm();URe();Tue();$1();CB();jnn=`TYPE arithmetic_add(TYPE x, TYPE y) { +`}}var Gnn,jnn,$nn,$1=Ve(()=>{Ql();vm();F3();OV();CB();Gnn="GPGPU Operation Counts",jnn="Transform Runs",$nn=new HD});var Wnn,Pue,jRe=Ve(()=>{vm();URe();Tue();$1();CB();Wnn=`TYPE arithmetic_add(TYPE x, TYPE y) { return x + y; } @@ -2571,7 +2571,7 @@ TYPE arithmetic_divide(TYPE x, TYPE y) { float arithmetic_tan(float x) { return tan_fp32(x); } -`,Pue=({inputs:s,output:n,target:r})=>{let c=n.type,u=hp(c,1,n.normalized),d=JM(u),b=s.namedInputs;return dp({module:{name:"arithmetic",dependencies:[d4],vs:jnn},inputs:b,output:n,operationType:c,outputBuffer:r,expression:w=>Cue(s.expression,{operations:MB,inputs:b,laneIndex:w,formatInput:_=>`${_}[${w}]`,formatOutOfBoundsInput:_=>b[_].size===1?`${_}[0]`:d,formatLiteral:_=>{let x=Array.isArray(_)?_[w]??0:_;return`${u}(${Ibt(c,x)})`},formatCall:(_,x)=>`${_}(${x.join(", ")})`})}),{success:!0}}});var $nn,Vnn,Nbt,Obt,Fbt=Ve(()=>{Vr();Ql();F3();OV();jRe();$1();$nn="GPGPU Operation Counts",Vnn="Transform Runs",Nbt=({inputs:s,output:n,target:r})=>{let{sourceValues:c}=s,u=r.device;if(c.length===0){let M=new n.ValueType(n.length*n.size);return r.write(M),{success:!0,value:M}}if(c.isConstant){let M=c.value,L=new n.ValueType(n.length*n.size);for(let I=0;I{let c=n.type,u=hp(c,1,n.normalized),d=JM(u),b=s.namedInputs;return dp({module:{name:"arithmetic",dependencies:[d4],vs:Wnn},inputs:b,output:n,operationType:c,outputBuffer:r,expression:w=>Cue(s.expression,{operations:MB,inputs:b,laneIndex:w,formatInput:_=>`${_}[${w}]`,formatOutOfBoundsInput:_=>b[_].size===1?`${_}[0]`:d,formatLiteral:_=>{let x=Array.isArray(_)?_[w]??0:_;return`${u}(${Ibt(c,x)})`},formatCall:(_,x)=>`${_}(${x.join(", ")})`})}),{success:!0}}});var Hnn,qnn,Nbt,Obt,Fbt=Ve(()=>{Vr();Ql();F3();OV();jRe();$1();Hnn="GPGPU Operation Counts",qnn="Transform Runs",Nbt=({inputs:s,output:n,target:r})=>{let{sourceValues:c}=s,u=r.device;if(c.length===0){let M=new n.ValueType(n.length*n.size);return r.write(M),{success:!0,value:M}}if(c.isConstant){let M=c.value,L=new n.ValueType(n.length*n.size);for(let I=0;Ic+Math.ceil(u.size/4),0);if(r>s)throw new Error(`interleave() requires ${r} vertex attributes, exceeding device limit ${s}`)}function Hnn(s,n){if(n.size>s)throw new Error(`interleave() output size ${n.size} exceeds device inter-stage component limit ${s}`)}var Ubt,zbt=Ve(()=>{$1();Ubt=({inputs:s,output:n,target:r})=>{let c=s.map((_,x)=>[`x${x}`,_]);Wnn(r.device.limits.maxVertexAttributes,c),Hnn(r.device.limits.maxInterStageShaderVariables,n);let u=c.map(([_,x])=>`in TYPE ${_}[${x.size}]`).join(", "),d=0,b=c.map(([_,x])=>{let T=Array.from({length:x.size},(M,L)=>` result[${d+L}] = ${_}[${L}];`).join(` + `,x=new Vh(u,{vs:w,fs:_,topology:"point-list",parameters:{depthCompare:"always",blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one",blendColorOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",blendAlphaOperation:"max"},modules:[zRe("sourceValues",c.type,c.size,c.normalized)],defines:{TYPE:"float",SOURCE_VALUES_LEN:c.size.toString(),CHANNEL_COUNT:n.length.toString()},attributes:{sourceValues:c.buffer},bufferLayout:[GRe("sourceValues",c)],instanceCount:c.length,vertexCount:n.length,disableWarnings:!0}),T=lg.createOrReuse(u,n.byteLength);try{let M=u.beginRenderPass({framebuffer:b,parameters:{viewport:[0,0,1,n.length]},clearColor:[-Obt,-Obt,0,0],clearDepth:!1,clearStencil:!1});u.statsManager.getStats(Hnn).get(qnn).incrementCount(),x.draw(M),M.end();let L=u.createCommandEncoder();return L.copyTextureToBuffer({sourceTexture:d,width:1,height:n.length,destinationBuffer:T,byteOffset:0,bytesPerRow:8}),u.submit(L.finish()),Pue({device:u,inputs:{expression:{kind:"call",op:"multiply",args:[{kind:"input",name:"x"},{kind:"literal",value:[-1,1]}]},namedInputs:{x:new fc({buffer:T,size:2,type:"float32",length:n.length})}},output:n,target:r})}finally{x.destroy(),lg.recycle(T),b.destroy(),d.destroy()}},Obt=3e38});function Xnn(s,n){let r=n.reduce((c,[,u])=>c+Math.ceil(u.size/4),0);if(r>s)throw new Error(`interleave() requires ${r} vertex attributes, exceeding device limit ${s}`)}function Ynn(s,n){if(n.size>s)throw new Error(`interleave() output size ${n.size} exceeds device inter-stage component limit ${s}`)}var Ubt,zbt=Ve(()=>{$1();Ubt=({inputs:s,output:n,target:r})=>{let c=s.map((_,x)=>[`x${x}`,_]);Xnn(r.device.limits.maxVertexAttributes,c),Ynn(r.device.limits.maxInterStageShaderVariables,n);let u=c.map(([_,x])=>`in TYPE ${_}[${x.size}]`).join(", "),d=0,b=c.map(([_,x])=>{let T=Array.from({length:x.size},(M,L)=>` result[${d+L}] = ${_}[${L}];`).join(` `);return d+=x.size,T}).join(` `),w=`void interleave(${u}, out TYPE result[RESULT_LEN]) { ${b} } -`;return dp({module:{name:"interleave",vs:w},inputs:s,output:n,outputBuffer:r}),{success:!0}}});function qnn(){let s=new Uint16Array([255]);return new Uint8Array(s.buffer)[0]>0}var Xnn,Gbt,jbt=Ve(()=>{$1();Xnn=`#define LE ${qnn()?1:0} +`;return dp({module:{name:"interleave",vs:w},inputs:s,output:n,outputBuffer:r}),{success:!0}}});function Znn(){let s=new Uint16Array([255]);return new Uint8Array(s.buffer)[0]>0}var Knn,Gbt,jbt=Ve(()=>{$1();Knn=`#define LE ${Znn()?1:0} const uint F32_NAN = 0xffffffffu; const uint F32_INF = 0x7f800000u; @@ -2773,18 +2773,18 @@ void fround(in uint x[X_LEN], out float result[X_LEN]) { result[i + n] = uintBitsToFloat(f.y); } } -`,Gbt=({inputs:s,output:n,target:r})=>(dp({module:{name:"fround",vs:Xnn},inputs:s,output:n,operationType:"uint32",outputBuffer:r}),{success:!0})});function Lue(s,n,r){let c=Bbt(r),u=hp(n,1),d=Array.from({length:s.size},(b,w)=>` v[${w}] = ${u}(texelFetch(source_values_texture, ivec2(${w}, rowIndex), 0).r);`).join(` +`,Gbt=({inputs:s,output:n,target:r})=>(dp({module:{name:"fround",vs:Knn},inputs:s,output:n,operationType:"uint32",outputBuffer:r}),{success:!0})});function Lue(s,n,r){let c=Bbt(r),u=hp(n,1),d=Array.from({length:s.size},(b,w)=>` v[${w}] = ${u}(texelFetch(source_values_texture, ivec2(${w}, rowIndex), 0).r);`).join(` `);return{name:"source_values_texture",vs:` uniform highp ${c} source_values_texture; void read_source_values(int rowIndex, out TYPE v[${s.size}]) { ${d} } -`}}function kue(s,n,r){let c=r.createTexture({width:Math.max(s.size,1),height:s.length,format:Dbt(n),usage:Pa.SAMPLE|Pa.COPY_DST});if(s.length===0)return c;let u=r.createCommandEncoder();return u.copyBufferToTexture({sourceBuffer:s.buffer,destinationTexture:c,byteOffset:s.offset,bytesPerRow:s.stride,rowsPerImage:s.length,size:[s.size,s.length,1]}),r.submit(u.finish()),c}var $Re=Ve(()=>{Vr();CB()});function Ynn(s,n){let r=hp(s.type,1),c="aids_0";return s.type!==Jnn(n)&&(c=`${n}(${c})`),{name:"ids",vs:` +`}}function kue(s,n,r){let c=r.createTexture({width:Math.max(s.size,1),height:s.length,format:Dbt(n),usage:Pa.SAMPLE|Pa.COPY_DST});if(s.length===0)return c;let u=r.createCommandEncoder();return u.copyBufferToTexture({sourceBuffer:s.buffer,destinationTexture:c,byteOffset:s.offset,bytesPerRow:s.stride,rowsPerImage:s.length,size:[s.size,s.length,1]}),r.submit(u.finish()),c}var $Re=Ve(()=>{Vr();CB()});function Jnn(s,n){let r=hp(s.type,1),c="aids_0";return s.type!==tin(n)&&(c=`${n}(${c})`),{name:"ids",vs:` in ${r} aids_0; void get_ids(out INDEX_TYPE v[1]) { v[0] = ${c}; } -`}}function Znn(s){return{name:"ids",stepMode:s.isConstant?"vertex":"instance",byteStride:s.stride,attributes:[{attribute:"aids_0",format:Aue(s.type,1,s.normalized),byteOffset:s.offset}]}}function Knn(s){return{name:"gather",vs:` +`}}function Qnn(s){return{name:"ids",stepMode:s.isConstant?"vertex":"instance",byteStride:s.stride,attributes:[{attribute:"aids_0",format:Aue(s.type,1,s.normalized),byteOffset:s.offset}]}}function ein(s){return{name:"gather",vs:` void zero_result(out TYPE result[RESULT_LEN]) { for (int i = 0; i < RESULT_LEN; i++) { result[i] = ${JM(s)}; @@ -2799,7 +2799,7 @@ void gather(in INDEX_TYPE ids[1], out TYPE result[RESULT_LEN]) { } read_source_values(sourceIndex, result); } -`}}function Jnn(s){switch(s){case"uint":return"uint32";case"int":return"sint32";default:return"float32"}}var $bt,Vbt=Ve(()=>{Ql();CB();$1();$Re();$bt=async({inputs:s,output:n,target:r})=>{let{ids:c,sourceValues:u}=s,d=r.device,b=R4("result",n.type,n.size),w=hp(c.type,1),_=hp(n.type,1),x=n.type,T=kue(u,x,d),M=`#version 300 es +`}}function tin(s){switch(s){case"uint":return"uint32";case"int":return"sint32";default:return"float32"}}var $bt,Vbt=Ve(()=>{Ql();CB();$1();$Re();$bt=async({inputs:s,output:n,target:r})=>{let{ids:c,sourceValues:u}=s,d=r.device,b=R4("result",n.type,n.size),w=hp(c.type,1),_=hp(n.type,1),x=n.type,T=kue(u,x,d),M=`#version 300 es void main() { INDEX_TYPE ids[1]; @@ -2808,14 +2808,14 @@ void main() { gather(ids, result); set_result(result); } - `,L=new fp(d,{vs:M,defines:{INDEX_TYPE:w,TYPE:_,RESULT_LEN:n.size.toString(),SOURCE_VALUES_ROWS:u.length.toString()},modules:[Ynn(c,w),Lue(u,n.type,x),Knn(n.type),b],bindings:{source_values_texture:T},bufferLayout:[Znn(c)],vertexCount:1,instanceCount:n.length,feedbackBufferMode:"interleaved",outputs:b.varyings});try{return L.run({inputBuffers:{ids:c.buffer},outputBuffers:{[b.varyings[0]]:r}}),{success:!0}}finally{L.destroy(),T.destroy()}}});var Qnn,Wbt,Hbt=Ve(()=>{$1();Qnn=`void row_dot(in TYPE x[X_LEN], in TYPE y[Y_LEN], out float result[1]) { + `,L=new fp(d,{vs:M,defines:{INDEX_TYPE:w,TYPE:_,RESULT_LEN:n.size.toString(),SOURCE_VALUES_ROWS:u.length.toString()},modules:[Jnn(c,w),Lue(u,n.type,x),ein(n.type),b],bindings:{source_values_texture:T},bufferLayout:[Qnn(c)],vertexCount:1,instanceCount:n.length,feedbackBufferMode:"interleaved",outputs:b.varyings});try{return L.run({inputBuffers:{ids:c.buffer},outputBuffers:{[b.varyings[0]]:r}}),{success:!0}}finally{L.destroy(),T.destroy()}}});var nin,Wbt,Hbt=Ve(()=>{$1();nin=`void row_dot(in TYPE x[X_LEN], in TYPE y[Y_LEN], out float result[1]) { float sum = 0.0; for (int i = 0; i < X_LEN; i++) { sum += float(x[i]) * float(y[i]); } result[0] = sum; } -`,Wbt=({inputs:s,output:n,target:r})=>(dp({module:{name:"row_dot",vs:Qnn},inputs:s,output:n,operationType:"float32",outputBuffer:r}),{success:!0})});var ein,qbt,Xbt=Ve(()=>{$1();ein=`void equalAll(in TYPE x[X_LEN], in TYPE y[Y_LEN], out uint result[1]) { +`,Wbt=({inputs:s,output:n,target:r})=>(dp({module:{name:"row_dot",vs:nin},inputs:s,output:n,operationType:"float32",outputBuffer:r}),{success:!0})});var iin,qbt,Xbt=Ve(()=>{$1();iin=`void equalAll(in TYPE x[X_LEN], in TYPE y[Y_LEN], out uint result[1]) { uint allEqual = uint(1); for (int i = 0; i < X_LEN; i++) { if (x[i] != y[i]) { @@ -2825,14 +2825,14 @@ void main() { } result[0] = allEqual; } -`,qbt=({inputs:s,output:n,target:r})=>(dp({module:{name:"equalAll",vs:ein},inputs:s,output:n,operationType:n.type==="uint32"?s.x.type:n.type,outputBuffer:r}),{success:!0})});var tin,Ybt,Zbt=Ve(()=>{$1();tin=`void row_length(in TYPE x[X_LEN], out float result[1]) { +`,qbt=({inputs:s,output:n,target:r})=>(dp({module:{name:"equalAll",vs:iin},inputs:s,output:n,operationType:n.type==="uint32"?s.x.type:n.type,outputBuffer:r}),{success:!0})});var rin,Ybt,Zbt=Ve(()=>{$1();rin=`void row_length(in TYPE x[X_LEN], out float result[1]) { float sum = 0.0; for (int i = 0; i < X_LEN; i++) { sum += float(x[i]) * float(x[i]); } result[0] = sqrt(sum); } -`,Ybt=({inputs:s,output:n,target:r})=>(dp({module:{name:"row_length",vs:tin},inputs:s,output:n,operationType:"float32",outputBuffer:r}),{success:!0})});function nin(){return{name:"segmentedMap",vs:` +`,Ybt=({inputs:s,output:n,target:r})=>(dp({module:{name:"row_length",vs:rin},inputs:s,output:n,operationType:"float32",outputBuffer:r}),{success:!0})});function sin(){return{name:"segmentedMap",vs:` uint read_segment_start(int segmentIndex) { TYPE value[1]; read_source_values(segmentIndex, value); @@ -2866,21 +2866,21 @@ void main() { segmentedMap(result); set_result(result); } -`,defines:{TYPE:"uint",RESULT_LEN:n.size.toString(),SEGMENTS_LENGTH:c.length.toString()},modules:[Lue(c,n.type,b),nin(),d],bindings:{source_values_texture:w},vertexCount:1,instanceCount:n.length,feedbackBufferMode:"interleaved",outputs:d.varyings});try{return _.run({outputBuffers:{[d.varyings[0]]:r}}),{success:!0}}finally{_.destroy(),w.destroy()}}});function VRe(s,n,r,c){return r{$1();CB();Qbt=async({inputs:s,output:n,target:r})=>{let c=hp(n.type,1,n.normalized),u=JM(c);return dp({module:{name:"select",vs:""},inputs:s,output:n,operationType:n.type,outputBuffer:r,expression:d=>{let b=VRe("condition",s.condition,d,u),w=VRe("whenTrue",s.whenTrue,d,u),_=VRe("whenFalse",s.whenFalse,d,u);return`(${b} != ${u} ? ${w} : ${_})`}}),{success:!0}}});var twt,nwt=Ve(()=>{Ql();$1();twt=({inputs:s,output:n,target:r})=>{let c=R4("result",n.type,n.size),u=new fp(r.device,{vs:`#version 300 es +`,defines:{TYPE:"uint",RESULT_LEN:n.size.toString(),SEGMENTS_LENGTH:c.length.toString()},modules:[Lue(c,n.type,b),sin(),d],bindings:{source_values_texture:w},vertexCount:1,instanceCount:n.length,feedbackBufferMode:"interleaved",outputs:d.varyings});try{return _.run({outputBuffers:{[d.varyings[0]]:r}}),{success:!0}}finally{_.destroy(),w.destroy()}}});function VRe(s,n,r,c){return r{$1();CB();Qbt=async({inputs:s,output:n,target:r})=>{let c=hp(n.type,1,n.normalized),u=JM(c);return dp({module:{name:"select",vs:""},inputs:s,output:n,operationType:n.type,outputBuffer:r,expression:d=>{let b=VRe("condition",s.condition,d,u),w=VRe("whenTrue",s.whenTrue,d,u),_=VRe("whenFalse",s.whenFalse,d,u);return`(${b} != ${u} ? ${w} : ${_})`}}),{success:!0}}});var twt,nwt=Ve(()=>{Ql();$1();twt=({inputs:s,output:n,target:r})=>{let c=R4("result",n.type,n.size),u=new fp(r.device,{vs:`#version 300 es void main() { int result[1]; result[0] = START + gl_InstanceID * STEP; set_result(result); } -`,defines:{START:s.start.toString(),STEP:s.step.toString()},modules:[c],vertexCount:1,instanceCount:n.length,feedbackBufferMode:"interleaved",outputs:c.varyings});try{return u.run({outputBuffers:{[c.varyings[0]]:r}}),{success:!0}}finally{u.destroy()}}});var iwt,rwt=Ve(()=>{$1();iwt=({inputs:s,output:n,target:r})=>{let{columns:c}=s;return dp({module:{name:"swizzle",vs:"// swizzle expression handled inline"},expression:u=>`x[${c[u]}]`,inputs:{x:s.x},output:n,outputBuffer:r}),{success:!0}}});var swt={};Oy(swt,{arithmetic:()=>Pue,dot:()=>Wbt,equalAll:()=>qbt,extent:()=>Nbt,fround:()=>Gbt,gather:()=>$bt,interleave:()=>Ubt,length:()=>Ybt,segmentedMap:()=>Kbt,select:()=>Qbt,sequence:()=>twt,swizzle:()=>iwt});var owt=Ve(()=>{jRe();Fbt();zbt();jbt();Vbt();Hbt();Xbt();Zbt();Jbt();ewt();nwt();rwt()});function l2(s,n){let r=iin(n),c=Math.max(1,Math.ceil(s)),u=Math.min(c,r),d=Math.min(Math.ceil(c/u),r),b=Math.ceil(c/u/d);if(b>r)throw new Error(`WebGPU dispatch requires ${c} workgroups, exceeding the 3D dispatch limit of ${r} per dimension`);return{x:u,y:d,z:b}}function WRe(s,n="workgroupId"){return`((${n}.z * ${s.y}u + ${n}.y) * ${s.x}u + ${n}.x)`}function QM(s,n,r="workgroupId",c="localId"){return`(${WRe(s,r)} * ${n}u + ${c}.x)`}function iin(s){return Number.isFinite(s)&&s>0?Math.floor(s):65535}var AB=Ve(()=>{});function eT(s,n){switch(s){case"u32":return`${n}u`;case"f32":return Number.isInteger(n)?`${n}.0`:`${n}`;default:return`${n}`}}function awt(s,n){switch(s){case"uint32":return eT("u32",Math.trunc(n));case"sint32":return`${Math.trunc(n)}`;case"float32":return eT("f32",n);default:throw new Error(`WebGPU operations only support 32-bit output types, got ${s}`)}}function tT(s){switch(s){case"uint32":return"0u";case"sint32":return"0";case"float32":return"0.0";default:throw new Error(`WebGPU operations only support 32-bit output types, got ${s}`)}}function Jc(s){switch(s){case"uint32":return"u32";case"sint32":return"i32";case"float32":return"f32";default:throw new Error(`WebGPU operations only support 32-bit storage types, got ${s}`)}}var I4=Ve(()=>{});function pp({module:s,elementWise:n=!1,expression:r,inputs:c,output:u,operationType:d=u.type,outputBuffer:b}){if(!s.source)throw new Error(`WebGPU computation ${s.name} requires WGSL source`);let w=hin(c),_=w.map(([Z,H])=>({name:Z,input:H})),x=_.filter(({input:Z})=>!Z.isConstant).map((Z,H)=>({...Z,index:H})),T=Jc(d),M=Jc(u.type),L={TYPE:T,RESULT_LEN:u.size.toString()},I=l2(Math.ceil(u.length/HRe),b.device.limits.maxComputeWorkgroupsPerDimension);for(let[Z,H]of w)L[`${Z.toUpperCase()}_LEN`]=H.size.toString();let D=` -${pin(s.source,L)} -${x.map(({name:Z,input:H,index:te})=>ain(Z,H,te)).join(` +`,defines:{START:s.start.toString(),STEP:s.step.toString()},modules:[c],vertexCount:1,instanceCount:n.length,feedbackBufferMode:"interleaved",outputs:c.varyings});try{return u.run({outputBuffers:{[c.varyings[0]]:r}}),{success:!0}}finally{u.destroy()}}});var iwt,rwt=Ve(()=>{$1();iwt=({inputs:s,output:n,target:r})=>{let{columns:c}=s;return dp({module:{name:"swizzle",vs:"// swizzle expression handled inline"},expression:u=>`x[${c[u]}]`,inputs:{x:s.x},output:n,outputBuffer:r}),{success:!0}}});var swt={};Oy(swt,{arithmetic:()=>Pue,dot:()=>Wbt,equalAll:()=>qbt,extent:()=>Nbt,fround:()=>Gbt,gather:()=>$bt,interleave:()=>Ubt,length:()=>Ybt,segmentedMap:()=>Kbt,select:()=>Qbt,sequence:()=>twt,swizzle:()=>iwt});var owt=Ve(()=>{jRe();Fbt();zbt();jbt();Vbt();Hbt();Xbt();Zbt();Jbt();ewt();nwt();rwt()});function l2(s,n){let r=oin(n),c=Math.max(1,Math.ceil(s)),u=Math.min(c,r),d=Math.min(Math.ceil(c/u),r),b=Math.ceil(c/u/d);if(b>r)throw new Error(`WebGPU dispatch requires ${c} workgroups, exceeding the 3D dispatch limit of ${r} per dimension`);return{x:u,y:d,z:b}}function WRe(s,n="workgroupId"){return`((${n}.z * ${s.y}u + ${n}.y) * ${s.x}u + ${n}.x)`}function QM(s,n,r="workgroupId",c="localId"){return`(${WRe(s,r)} * ${n}u + ${c}.x)`}function oin(s){return Number.isFinite(s)&&s>0?Math.floor(s):65535}var AB=Ve(()=>{});function eT(s,n){switch(s){case"u32":return`${n}u`;case"f32":return Number.isInteger(n)?`${n}.0`:`${n}`;default:return`${n}`}}function awt(s,n){switch(s){case"uint32":return eT("u32",Math.trunc(n));case"sint32":return`${Math.trunc(n)}`;case"float32":return eT("f32",n);default:throw new Error(`WebGPU operations only support 32-bit output types, got ${s}`)}}function tT(s){switch(s){case"uint32":return"0u";case"sint32":return"0";case"float32":return"0.0";default:throw new Error(`WebGPU operations only support 32-bit output types, got ${s}`)}}function Jc(s){switch(s){case"uint32":return"u32";case"sint32":return"i32";case"float32":return"f32";default:throw new Error(`WebGPU operations only support 32-bit storage types, got ${s}`)}}var I4=Ve(()=>{});function pp({module:s,elementWise:n=!1,expression:r,inputs:c,output:u,operationType:d=u.type,outputBuffer:b}){if(!s.source)throw new Error(`WebGPU computation ${s.name} requires WGSL source`);let w=gin(c),_=w.map(([Z,H])=>({name:Z,input:H})),x=_.filter(({input:Z})=>!Z.isConstant).map((Z,H)=>({...Z,index:H})),T=Jc(d),M=Jc(u.type),L={TYPE:T,RESULT_LEN:u.size.toString()},I=l2(Math.ceil(u.length/HRe),b.device.limits.maxComputeWorkgroupsPerDimension);for(let[Z,H]of w)L[`${Z.toUpperCase()}_LEN`]=H.size.toString();let D=` +${bin(s.source,L)} +${x.map(({name:Z,input:H,index:te})=>uin(Z,H,te)).join(` `)} -${_.map(({name:Z,input:H})=>cin(Z,H,d)).join(` +${_.map(({name:Z,input:H})=>fin(Z,H,d)).join(` `)} -${lin(u,x.length)} -${uin(u)} +${hin(u,x.length)} +${din(u)} @compute @workgroup_size(${HRe}) fn main( @builtin(workgroup_id) workgroupId: vec3, @@ -2894,24 +2894,24 @@ ${uin(u)} ${_.map(({name:Z})=>` let ${Z} = read_${Z}(rowIndex);`).join(` `)} var result: array<${M}, ${u.size}>; -${fin(s.name,w,u,n,r)} +${pin(s.name,w,u,n,r)} write_result(rowIndex, result); } -`,F=new G1(b.device,{source:D,modules:s.dependencies,shaderAssembler:oin,shaderLayout:{bindings:[...x.map(({name:Z},H)=>({name:Z,type:"storage",group:0,location:H})),{name:"result",type:"storage",group:0,location:x.length}]}}),O=Object.fromEntries(x.map(({name:Z,input:H})=>[Z,H.buffer]));O.result=b,F.setBindings(O);let z=b.device.beginComputePass({});b.device.statsManager.getStats(rin).get(sin).incrementCount(),F.dispatch(z,I.x,I.y,I.z),z.end(),b.device.submit(),F.destroy()}function ain(s,n,r){if(n.isConstant)return"";let c=Jc(n.type);return`@group(0) @binding(${r}) var ${s}: array<${c}>;`}function cin(s,n,r){let c=Jc(r),u=n.type===r?"":c,d=n.stride/n.ValueType.BYTES_PER_ELEMENT,b=n.offset/n.ValueType.BYTES_PER_ELEMENT;return n.isConstant?`fn read_${s}(_rowIndex: u32) -> array<${c}, ${n.size}> { - return array<${c}, ${n.size}>(${din(n,u)}); +`,F=new G1(b.device,{source:D,modules:s.dependencies,shaderAssembler:lin,shaderLayout:{bindings:[...x.map(({name:Z},H)=>({name:Z,type:"storage",group:0,location:H})),{name:"result",type:"storage",group:0,location:x.length}]}}),O=Object.fromEntries(x.map(({name:Z,input:H})=>[Z,H.buffer]));O.result=b,F.setBindings(O);let z=b.device.beginComputePass({});b.device.statsManager.getStats(ain).get(cin).incrementCount(),F.dispatch(z,I.x,I.y,I.z),z.end(),b.device.submit(),F.destroy()}function uin(s,n,r){if(n.isConstant)return"";let c=Jc(n.type);return`@group(0) @binding(${r}) var ${s}: array<${c}>;`}function fin(s,n,r){let c=Jc(r),u=n.type===r?"":c,d=n.stride/n.ValueType.BYTES_PER_ELEMENT,b=n.offset/n.ValueType.BYTES_PER_ELEMENT;return n.isConstant?`fn read_${s}(_rowIndex: u32) -> array<${c}, ${n.size}> { + return array<${c}, ${n.size}>(${min(n,u)}); }`:`fn read_${s}(rowIndex: u32) -> array<${c}, ${n.size}> { var value: array<${c}, ${n.size}>; let rowOffset = ${b}u + rowIndex * ${d}u; ${Array.from({length:n.size},(w,_)=>u?` value[${_}] = ${u}(${s}[rowOffset + ${_}u]);`:` value[${_}] = ${s}[rowOffset + ${_}u];`).join(` `)} return value; -}`}function lin(s,n){let r=Jc(s.type);return`@group(0) @binding(${n}) var result: array<${r}>;`}function uin(s){let n=s.stride/s.ValueType.BYTES_PER_ELEMENT,r=s.offset/s.ValueType.BYTES_PER_ELEMENT;return`fn write_result(rowIndex: u32, value: array<${Jc(s.type)}, ${s.size}>) { +}`}function hin(s,n){let r=Jc(s.type);return`@group(0) @binding(${n}) var result: array<${r}>;`}function din(s){let n=s.stride/s.ValueType.BYTES_PER_ELEMENT,r=s.offset/s.ValueType.BYTES_PER_ELEMENT;return`fn write_result(rowIndex: u32, value: array<${Jc(s.type)}, ${s.size}>) { let rowOffset = ${r}u + rowIndex * ${n}u; ${Array.from({length:s.size},(u,d)=>` result[rowOffset + ${d}u] = value[${d}];`).join(` `)} -}`}function fin(s,n,r,c,u){let d="";if(u)for(let b=0;b_b).join(", ")});`;return d.trimEnd()}function hin(s){return Array.isArray(s)?s.map((n,r)=>[`x${r}`,n]):Object.entries(s)}function din(s,n){let r=s.value;if(!r)throw new Error(`Constant input ${s} is missing CPU values`);return Array.from({length:s.size},(c,u)=>eT(n,r[u]??0)).join(", ")}function pin(s,n){for(let r in n)s=s.replaceAll(`{${r}}`,n[r]);return s}var HRe,rin,sin,oin,U3=Ve(()=>{Ql();vm();AB();I4();HRe=64,rin="GPGPU Operation Counts",sin="Computation Runs",oin=new $M});var gin,cwt,lwt=Ve(()=>{vm();URe();Tue();U3();I4();gin=`fn arithmetic_add(x: {TYPE}, y: {TYPE}) -> {TYPE} { +`}}else d+=`result = ${s}(${n.map(([b])=>b).join(", ")});`;return d.trimEnd()}function gin(s){return Array.isArray(s)?s.map((n,r)=>[`x${r}`,n]):Object.entries(s)}function min(s,n){let r=s.value;if(!r)throw new Error(`Constant input ${s} is missing CPU values`);return Array.from({length:s.size},(c,u)=>eT(n,r[u]??0)).join(", ")}function bin(s,n){for(let r in n)s=s.replaceAll(`{${r}}`,n[r]);return s}var HRe,ain,cin,lin,U3=Ve(()=>{Ql();vm();AB();I4();HRe=64,ain="GPGPU Operation Counts",cin="Computation Runs",lin=new $M});var win,cwt,lwt=Ve(()=>{vm();URe();Tue();U3();I4();win=`fn arithmetic_add(x: {TYPE}, y: {TYPE}) -> {TYPE} { return x + y; } @@ -2930,14 +2930,14 @@ fn arithmetic_divide(x: {TYPE}, y: {TYPE}) -> {TYPE} { fn arithmetic_tan(x: f32) -> f32 { return tan_fp32(x); } -`,cwt=({inputs:s,output:n,target:r})=>{let c=n.type,u=Jc(c),d=tT(c),b=s.namedInputs;return pp({module:{name:"arithmetic",source:gin,dependencies:[d4]},inputs:b,output:n,operationType:c,outputBuffer:r,expression:w=>Cue(s.expression,{operations:MB,inputs:b,laneIndex:w,formatInput:_=>`${_}[${w}]`,formatOutOfBoundsInput:_=>b[_].size===1?`${_}[0]`:d,formatLiteral:_=>{let x=Array.isArray(_)?_[w]??0:_;return`${u}(${awt(c,x)})`},formatCall:(_,x)=>`${_}(${x.join(", ")})`})}),{success:!0}}});var min,uwt,fwt=Ve(()=>{U3();min=`fn row_dot(x: array<{TYPE}, {X_LEN}>, y: array<{TYPE}, {Y_LEN}>) -> array { +`,cwt=({inputs:s,output:n,target:r})=>{let c=n.type,u=Jc(c),d=tT(c),b=s.namedInputs;return pp({module:{name:"arithmetic",source:win,dependencies:[d4]},inputs:b,output:n,operationType:c,outputBuffer:r,expression:w=>Cue(s.expression,{operations:MB,inputs:b,laneIndex:w,formatInput:_=>`${_}[${w}]`,formatOutOfBoundsInput:_=>b[_].size===1?`${_}[0]`:d,formatLiteral:_=>{let x=Array.isArray(_)?_[w]??0:_;return`${u}(${awt(c,x)})`},formatCall:(_,x)=>`${_}(${x.join(", ")})`})}),{success:!0}}});var vin,uwt,fwt=Ve(()=>{U3();vin=`fn row_dot(x: array<{TYPE}, {X_LEN}>, y: array<{TYPE}, {Y_LEN}>) -> array { var sum = 0.0; for (var i = 0u; i < {X_LEN}u; i = i + 1u) { sum += f32(x[i]) * f32(y[i]); } return array(sum); } -`,uwt=({inputs:s,output:n,target:r})=>(pp({module:{name:"row_dot",source:min},inputs:s,output:n,operationType:"float32",outputBuffer:r}),{success:!0})});var bin,hwt,dwt=Ve(()=>{U3();bin=`fn equalAll(x: array<{TYPE}, {X_LEN}>, y: array<{TYPE}, {Y_LEN}>) -> array { +`,uwt=({inputs:s,output:n,target:r})=>(pp({module:{name:"row_dot",source:vin},inputs:s,output:n,operationType:"float32",outputBuffer:r}),{success:!0})});var _in,hwt,dwt=Ve(()=>{U3();_in=`fn equalAll(x: array<{TYPE}, {X_LEN}>, y: array<{TYPE}, {Y_LEN}>) -> array { var allEqual = 1u; for (var i = 0u; i < {X_LEN}u; i = i + 1u) { if (x[i] != y[i]) { @@ -2947,7 +2947,7 @@ fn arithmetic_tan(x: f32) -> f32 { } return array(allEqual); } -`,hwt=({inputs:s,output:n,target:r})=>(pp({module:{name:"equalAll",source:bin},inputs:s,output:n,operationType:s.x.type,outputBuffer:r}),{success:!0})});function PB(s,n,r){let c=Jc(n.type);return`@group(0) @binding(${r}) var ${s}: array<${c}>;`}function qRe(s,n,r,c=s){let u=Jc(r);if(n.isConstant){let x=n.value;if(!x)throw new Error(`Constant input ${n} is missing CPU values`);return`fn read_${c}(_sourceIndex: u32) -> array<${u}, ${n.size}> { +`,hwt=({inputs:s,output:n,target:r})=>(pp({module:{name:"equalAll",source:_in},inputs:s,output:n,operationType:s.x.type,outputBuffer:r}),{success:!0})});function PB(s,n,r){let c=Jc(n.type);return`@group(0) @binding(${r}) var ${s}: array<${c}>;`}function qRe(s,n,r,c=s){let u=Jc(r);if(n.isConstant){let x=n.value;if(!x)throw new Error(`Constant input ${n} is missing CPU values`);return`fn read_${c}(_sourceIndex: u32) -> array<${u}, ${n.size}> { return array<${u}, ${n.size}>(${Array.from({length:n.size},(T,M)=>eT(u,x[M]??0)).join(", ")}); }`}let d=n.stride/n.ValueType.BYTES_PER_ELEMENT,b=n.offset/n.ValueType.BYTES_PER_ELEMENT,_=Jc(n.type)===u?"":`${u}`;return`fn read_${c}(sourceIndex: u32) -> array<${u}, ${n.size}> { var value: array<${u}, ${n.size}>; @@ -2964,12 +2964,12 @@ ${Array.from({length:s.size},(u,d)=>` result[rowOffset + ${d}u] = value[${d}];` ${Array.from({length:n},(c,u)=>` result[${u}] = ${r};`).join(` `)} return result; -}`}var ug,Iue=Ve(()=>{I4();ug=64});function win({input:s,inputMode:n,inputGroupCount:r,channelCount:c,outputType:u,outputBuffer:d,outputLength:b,outputStride:w,outputOffset:_}){let x=Jc(u),T=l2(b,d.device.limits.maxComputeWorkgroupsPerDimension),M=new fc({buffer:d,type:u,size:2,length:b,stride:w,offset:_}),L=` +}`}var ug,Iue=Ve(()=>{I4();ug=64});function yin({input:s,inputMode:n,inputGroupCount:r,channelCount:c,outputType:u,outputBuffer:d,outputLength:b,outputStride:w,outputOffset:_}){let x=Jc(u),T=l2(b,d.device.limits.maxComputeWorkgroupsPerDimension),M=new fc({buffer:d,type:u,size:2,length:b,stride:w,offset:_}),L=` ${s.isConstant?"":PB("sourceValues",s,0)} ${Rue(s,u)} ${LB(M,s.isConstant?0:1)} ${kB(M)} -${vin(n,u,c,r)} +${xin(n,u,c,r)} var sharedMin: array<${x}, ${ug}>; var sharedMax: array<${x}, ${ug}>; @@ -3014,7 +3014,7 @@ var sharedMax: array<${x}, ${ug}>; write_result(outputRowIndex, array<${x}, 2>(sharedMin[0], sharedMax[0])); } } -`,I=new G1(d.device,{source:L,shaderLayout:{bindings:[...s.isConstant?[]:[{name:"sourceValues",type:"storage",group:0,location:0}],{name:"result",type:"storage",group:0,location:s.isConstant?0:1}]}}),D={result:d};s.isConstant||(D.sourceValues=s.buffer),I.setBindings(D);let F=d.device.beginComputePass({});I.dispatch(F,T.x,T.y,T.z),F.end(),d.device.submit(),I.destroy()}function vin(s,n,r,c){let u=Jc(n),[d,b]=_in(n);return s==="raw"?`fn extent_pass(channelIndex: u32, inputGroupIndex: u32) -> array<${u}, 2> { +`,I=new G1(d.device,{source:L,shaderLayout:{bindings:[...s.isConstant?[]:[{name:"sourceValues",type:"storage",group:0,location:0}],{name:"result",type:"storage",group:0,location:s.isConstant?0:1}]}}),D={result:d};s.isConstant||(D.sourceValues=s.buffer),I.setBindings(D);let F=d.device.beginComputePass({});I.dispatch(F,T.x,T.y,T.z),F.end(),d.device.submit(),I.destroy()}function xin(s,n,r,c){let u=Jc(n),[d,b]=Ein(n);return s==="raw"?`fn extent_pass(channelIndex: u32, inputGroupIndex: u32) -> array<${u}, 2> { var result: array<${u}, 2>; result[0] = ${d}; result[1] = ${b}; @@ -3039,7 +3039,7 @@ var sharedMax: array<${x}, ${ug}>; } return result; -}`}function _in(s){switch(s){case"uint32":return["0xffffffffu","0u"];case"sint32":return["2147483647","-2147483648"];case"float32":return["3.402823e38","-3.402823e38"];default:throw new Error(`Unsupported WebGPU extent type for ${s}`)}}var gwt,mwt=Ve(()=>{Ql();F3();OV();AB();I4();Iue();gwt=({inputs:s,output:n,target:r})=>{let{sourceValues:c}=s;if(c.length===0){let _=new n.ValueType(n.length*n.size);return r.write(_),{success:!0,value:_}}if(c.isConstant){let _=c.value;if(!_)throw new Error(`Constant input ${c} is missing CPU values`);let x=new n.ValueType(n.length*n.size);for(let T=0;T1&&u.push(T),win({input:d,inputMode:b,inputGroupCount:w,channelCount:n.length,outputType:n.type,outputBuffer:T,outputLength:x,outputStride:n.stride,outputOffset:n.offset}),_===1)break;d=new fc({buffer:T,type:n.type,size:2,length:x}),b="partial",w=_}return{success:!0}}finally{for(let _ of u)lg.recycle(_)}}});function yin(){let s=new Uint16Array([255]);return new Uint8Array(s.buffer)[0]>0}var xin,bwt,wwt=Ve(()=>{U3();xin=`const LE: bool = ${yin()?"true":"false"}; +}`}function Ein(s){switch(s){case"uint32":return["0xffffffffu","0u"];case"sint32":return["2147483647","-2147483648"];case"float32":return["3.402823e38","-3.402823e38"];default:throw new Error(`Unsupported WebGPU extent type for ${s}`)}}var gwt,mwt=Ve(()=>{Ql();F3();OV();AB();I4();Iue();gwt=({inputs:s,output:n,target:r})=>{let{sourceValues:c}=s;if(c.length===0){let _=new n.ValueType(n.length*n.size);return r.write(_),{success:!0,value:_}}if(c.isConstant){let _=c.value;if(!_)throw new Error(`Constant input ${c} is missing CPU values`);let x=new n.ValueType(n.length*n.size);for(let T=0;T1&&u.push(T),yin({input:d,inputMode:b,inputGroupCount:w,channelCount:n.length,outputType:n.type,outputBuffer:T,outputLength:x,outputStride:n.stride,outputOffset:n.offset}),_===1)break;d=new fc({buffer:T,type:n.type,size:2,length:x}),b="partial",w=_}return{success:!0}}finally{for(let _ of u)lg.recycle(_)}}});function Sin(){let s=new Uint16Array([255]);return new Uint8Array(s.buffer)[0]>0}var Min,bwt,wwt=Ve(()=>{U3();Min=`const LE: bool = ${Sin()?"true":"false"}; const F32_NAN: u32 = 0xffffffffu; const F32_INF: u32 = 0x7f800000u; @@ -3178,12 +3178,12 @@ fn fround(x: array) -> array { } return result; } -`,bwt=({inputs:s,output:n,target:r})=>(pp({module:{name:"fround",source:xin},inputs:s,output:n,operationType:"uint32",outputBuffer:r}),{success:!0})});function Ein(s,n){if(s.isConstant){let u=s.value;if(!u)throw new Error(`Constant input ${s} is missing CPU values`);return`fn read_ids(_rowIndex: u32) -> ${n} { +`,bwt=({inputs:s,output:n,target:r})=>(pp({module:{name:"fround",source:Min},inputs:s,output:n,operationType:"uint32",outputBuffer:r}),{success:!0})});function Tin(s,n){if(s.isConstant){let u=s.value;if(!u)throw new Error(`Constant input ${s} is missing CPU values`);return`fn read_ids(_rowIndex: u32) -> ${n} { return ${eT(n,u[0]??0)}; }`}let r=s.stride/s.ValueType.BYTES_PER_ELEMENT,c=s.offset/s.ValueType.BYTES_PER_ELEMENT;return`fn read_ids(rowIndex: u32) -> ${n} { let rowOffset = ${c}u + rowIndex * ${r}u; return ids[rowOffset]; -}`}function Sin(s,n,r,c){let u=Jc(s),d=Jc(n);return`fn gather(idsValue: ${u}) -> array<${d}, ${r}> { +}`}function Cin(s,n,r,c){let u=Jc(s),d=Jc(n);return`fn gather(idsValue: ${u}) -> array<${d}, ${r}> { let sourceIndex = ${u==="u32"?"i32(idsValue)":u==="i32"?"idsValue":"i32(idsValue)"}; if (sourceIndex < 0 || sourceIndex >= ${c}) { return zero_result(); @@ -3192,12 +3192,12 @@ fn fround(x: array) -> array { }`}var vwt,_wt=Ve(()=>{Ql();AB();I4();Iue();vwt=async({inputs:s,output:n,target:r})=>{let{ids:c,sourceValues:u}=s,d=Jc(c.type),b=[];c.isConstant||b.push({name:"ids",input:c,index:b.length}),u.isConstant||b.push({name:"sourceValues",input:u,index:b.length});let w=l2(Math.ceil(n.length/ug),r.device.limits.maxComputeWorkgroupsPerDimension),_=` ${b.map(({name:L,input:I,index:D})=>PB(L,I,D)).join(` `)} -${Ein(c,d)} +${Tin(c,d)} ${Rue(u,n.type)} ${LB(n,b.length)} ${kB(n)} ${pwt(n.type,n.size)} -${Sin(c.type,n.type,n.size,u.length)} +${Cin(c.type,n.type,n.size,u.length)} @compute @workgroup_size(${ug}) fn main( @builtin(workgroup_id) workgroupId: vec3, @@ -3212,7 +3212,7 @@ ${Sin(c.type,n.type,n.size,u.length)} let result = gather(idsValue); write_result(rowIndex, result); } -`,x=new G1(r.device,{source:_,shaderLayout:{bindings:[...b.map(({name:L,index:I})=>({name:L,type:"storage",group:0,location:I})),{name:"result",type:"storage",group:0,location:b.length}]}}),T={};c.isConstant||(T.ids=c.buffer),u.isConstant||(T.sourceValues=u.buffer),T.result=r,x.setBindings(T);let M=r.device.beginComputePass({});return x.dispatch(M,w.x,w.y,w.z),M.end(),r.device.submit(),x.destroy(),{success:!0}}});function Min(s){return`fn segmented_map(vertexIndex: u32) -> array { +`,x=new G1(r.device,{source:_,shaderLayout:{bindings:[...b.map(({name:L,index:I})=>({name:L,type:"storage",group:0,location:I})),{name:"result",type:"storage",group:0,location:b.length}]}}),T={};c.isConstant||(T.ids=c.buffer),u.isConstant||(T.sourceValues=u.buffer),T.result=r,x.setBindings(T);let M=r.device.beginComputePass({});return x.dispatch(M,w.x,w.y,w.z),M.end(),r.device.submit(),x.destroy(),{success:!0}}});function Ain(s){return`fn segmented_map(vertexIndex: u32) -> array { var low = 0i; var high = ${s}i; while (low < high) { @@ -3234,7 +3234,7 @@ ${u.map(({name:T,input:M,index:L})=>PB(T,M,L)).join(` ${qRe("segments",c,"uint32")} ${LB(n,u.length)} ${kB(n)} -${Min(c.length)} +${Ain(c.length)} @compute @workgroup_size(${ug}) fn main( @builtin(workgroup_id) workgroupId: vec3, @@ -3248,21 +3248,21 @@ ${Min(c.length)} let result = segmented_map(rowIndex); write_result(rowIndex, result); } -`,w=new G1(r.device,{source:b,shaderLayout:{bindings:[...u.map(({name:T,index:M})=>({name:T,type:"storage",group:0,location:M})),{name:"result",type:"storage",group:0,location:u.length}]}}),_=Object.fromEntries(u.map(({name:T,input:M})=>[T,M.buffer]));_.result=r,w.setBindings(_);let x=r.device.beginComputePass({});return w.dispatch(x,d.x,d.y,d.z),x.end(),r.device.submit(),w.destroy(),{success:!0}}});function Tin(s,n){let c=n.filter(([,u])=>!u.isConstant).length+1;if(c>s.maxStorageBuffersPerShaderStage)throw new Error(`interleave() requires ${c} storage buffers, exceeding device limit ${s.maxStorageBuffersPerShaderStage}`);if(c>s.maxBindingsPerBindGroup)throw new Error(`interleave() requires ${c} bindings, exceeding bind group limit ${s.maxBindingsPerBindGroup}`)}var Due,Ewt=Ve(()=>{U3();Due=({inputs:s,output:n,target:r})=>{let c=s.map((_,x)=>[`x${x}`,_]);Tin(r.device.limits,c);let u=c.map(([_,x])=>`${_}: array<{TYPE}, ${x.size}>`).join(", "),d=0,b=c.map(([_,x])=>{let T=Array.from({length:x.size},(M,L)=>` out[${d+L}] = ${_}[${L}];`).join(` +`,w=new G1(r.device,{source:b,shaderLayout:{bindings:[...u.map(({name:T,index:M})=>({name:T,type:"storage",group:0,location:M})),{name:"result",type:"storage",group:0,location:u.length}]}}),_=Object.fromEntries(u.map(({name:T,input:M})=>[T,M.buffer]));_.result=r,w.setBindings(_);let x=r.device.beginComputePass({});return w.dispatch(x,d.x,d.y,d.z),x.end(),r.device.submit(),w.destroy(),{success:!0}}});function Pin(s,n){let c=n.filter(([,u])=>!u.isConstant).length+1;if(c>s.maxStorageBuffersPerShaderStage)throw new Error(`interleave() requires ${c} storage buffers, exceeding device limit ${s.maxStorageBuffersPerShaderStage}`);if(c>s.maxBindingsPerBindGroup)throw new Error(`interleave() requires ${c} bindings, exceeding bind group limit ${s.maxBindingsPerBindGroup}`)}var Due,Ewt=Ve(()=>{U3();Due=({inputs:s,output:n,target:r})=>{let c=s.map((_,x)=>[`x${x}`,_]);Pin(r.device.limits,c);let u=c.map(([_,x])=>`${_}: array<{TYPE}, ${x.size}>`).join(", "),d=0,b=c.map(([_,x])=>{let T=Array.from({length:x.size},(M,L)=>` out[${d+L}] = ${_}[${L}];`).join(` `);return d+=x.size,T}).join(` `),w=`fn interleave(${u}) -> array<{TYPE}, {RESULT_LEN}> { var out: array<{TYPE}, {RESULT_LEN}>; ${b} return out; } -`;return pp({module:{name:"interleave",source:w},inputs:s,output:n,outputBuffer:r}),{success:!0}}});var Cin,Swt,Mwt=Ve(()=>{U3();Cin=`fn row_length(x: array<{TYPE}, {X_LEN}>) -> array { +`;return pp({module:{name:"interleave",source:w},inputs:s,output:n,outputBuffer:r}),{success:!0}}});var Lin,Swt,Mwt=Ve(()=>{U3();Lin=`fn row_length(x: array<{TYPE}, {X_LEN}>) -> array { var sum = 0.0; for (var i = 0u; i < {X_LEN}u; i = i + 1u) { sum += f32(x[i]) * f32(x[i]); } return array(sqrt(sum)); } -`,Swt=({inputs:s,output:n,target:r})=>(pp({module:{name:"row_length",source:Cin},inputs:s,output:n,operationType:"float32",outputBuffer:r}),{success:!0})});function XRe(s,n,r,c){return r{U3();I4();Twt=async({inputs:s,output:n,target:r})=>{let c=tT(n.type);return pp({module:{name:"select",source:`// inline expression select +`,Swt=({inputs:s,output:n,target:r})=>(pp({module:{name:"row_length",source:Lin},inputs:s,output:n,operationType:"float32",outputBuffer:r}),{success:!0})});function XRe(s,n,r,c){return r{U3();I4();Twt=async({inputs:s,output:n,target:r})=>{let c=tT(n.type);return pp({module:{name:"select",source:`// inline expression select `},inputs:s,output:n,operationType:n.type,outputBuffer:r,expression:u=>{let d=XRe("condition",s.condition,u,c),b=XRe("whenTrue",s.whenTrue,u,c);return`select(${XRe("whenFalse",s.whenFalse,u,c)}, ${b}, ${d} != ${c})`}}),{success:!0}}});var YRe,Awt,Pwt=Ve(()=>{Ql();AB();YRe=64,Awt=({inputs:s,output:n,target:r})=>{let c=l2(Math.ceil(n.length/YRe),r.device.limits.maxComputeWorkgroupsPerDimension),u=`@group(0) @binding(0) var result: array; @compute @workgroup_size(${YRe}) fn main( @@ -3277,16 +3277,16 @@ ${b} let rowOffset = ${n.offset/n.ValueType.BYTES_PER_ELEMENT}u + rowIndex * ${n.stride/n.ValueType.BYTES_PER_ELEMENT}u; result[rowOffset] = ${s.start} + i32(rowIndex) * ${s.step}; } -`,d=new G1(r.device,{source:u,shaderLayout:{bindings:[{name:"result",type:"storage",group:0,location:0}]}});d.setBindings({result:r});let b=r.device.beginComputePass({});return d.dispatch(b,c.x,c.y,c.z),b.end(),r.device.submit(),d.destroy(),{success:!0}}});var Lwt,kwt=Ve(()=>{U3();Lwt=({inputs:s,output:n,target:r})=>{let{columns:c}=s;return pp({module:{name:"swizzle",source:"// swizzle expression handled inline"},expression:u=>`x[${c[u]}]`,inputs:{x:s.x},output:n,outputBuffer:r}),{success:!0}}});var Rwt={};Oy(Rwt,{arithmetic:()=>cwt,dot:()=>uwt,equalAll:()=>hwt,extent:()=>gwt,fround:()=>bwt,gather:()=>vwt,interleave:()=>Due,length:()=>Swt,segmentedMap:()=>ywt,select:()=>Twt,sequence:()=>Awt,swizzle:()=>Lwt});var ZRe=Ve(()=>{lwt();fwt();dwt();mwt();wwt();_wt();xwt();Ewt();Mwt();Cwt();Pwt();kwt()});var zvt=Sd((oai,TIe)=>{"use strict";TIe.exports=Jue;TIe.exports.default=Jue;function Jue(s,n,r){r=r||2;var c=n&&n.length,u=c?n[0]*r:s.length,d=Nvt(s,0,u,r,!0),b=[];if(!d||d.next===d.prev)return b;var w,_,x,T,M,L,I;if(c&&(d=gsn(s,n,d,r)),s.length>80*r){w=x=s[0],_=T=s[1];for(var D=r;Dx&&(x=M),L>T&&(T=L);I=Math.max(x-w,T-_),I=I!==0?32767/I:0}return fW(d,b,r,w,_,I,0),b}function Nvt(s,n,r,c,u){var d,b;if(u===MIe(s,n,r,c)>0)for(d=n;d=n;d-=c)b=Ovt(d,s[d],s[d+1],b);return b&&Que(b,b.next)&&(dW(b),b=b.next),b}function B4(s,n){if(!s)return s;n||(n=s);var r=s,c;do if(c=!1,!r.steiner&&(Que(r,r.next)||eu(r.prev,r,r.next)===0)){if(dW(r),r=n=r.prev,r===r.next)break;c=!0}else r=r.next;while(c||r!==n);return n}function fW(s,n,r,c,u,d,b){if(s){!b&&d&&_sn(s,c,u,d);for(var w=s,_,x;s.prev!==s.next;){if(_=s.prev,x=s.next,d?hsn(s,c,u,d):fsn(s)){n.push(_.i/r|0),n.push(s.i/r|0),n.push(x.i/r|0),dW(s),s=x.next,w=x.next;continue}if(s=x,s===w){b?b===1?(s=dsn(B4(s),n,r),fW(s,n,r,c,u,d,2)):b===2&&psn(s,n,r,c,u,d):fW(B4(s),n,r,c,u,d,1);break}}}}function fsn(s){var n=s.prev,r=s,c=s.next;if(eu(n,r,c)>=0)return!1;for(var u=n.x,d=r.x,b=c.x,w=n.y,_=r.y,x=c.y,T=ud?u>b?u:b:d>b?d:b,I=w>_?w>x?w:x:_>x?_:x,D=c.next;D!==n;){if(D.x>=T&&D.x<=L&&D.y>=M&&D.y<=I&&BB(u,w,d,_,b,x,D.x,D.y)&&eu(D.prev,D,D.next)>=0)return!1;D=D.next}return!0}function hsn(s,n,r,c){var u=s.prev,d=s,b=s.next;if(eu(u,d,b)>=0)return!1;for(var w=u.x,_=d.x,x=b.x,T=u.y,M=d.y,L=b.y,I=w<_?w_?w>x?w:x:_>x?_:x,O=T>M?T>L?T:L:M>L?M:L,z=EIe(I,D,n,r,c),Z=EIe(F,O,n,r,c),H=s.prevZ,te=s.nextZ;H&&H.z>=z&&te&&te.z<=Z;){if(H.x>=I&&H.x<=F&&H.y>=D&&H.y<=O&&H!==u&&H!==b&&BB(w,T,_,M,x,L,H.x,H.y)&&eu(H.prev,H,H.next)>=0||(H=H.prevZ,te.x>=I&&te.x<=F&&te.y>=D&&te.y<=O&&te!==u&&te!==b&&BB(w,T,_,M,x,L,te.x,te.y)&&eu(te.prev,te,te.next)>=0))return!1;te=te.nextZ}for(;H&&H.z>=z;){if(H.x>=I&&H.x<=F&&H.y>=D&&H.y<=O&&H!==u&&H!==b&&BB(w,T,_,M,x,L,H.x,H.y)&&eu(H.prev,H,H.next)>=0)return!1;H=H.prevZ}for(;te&&te.z<=Z;){if(te.x>=I&&te.x<=F&&te.y>=D&&te.y<=O&&te!==u&&te!==b&&BB(w,T,_,M,x,L,te.x,te.y)&&eu(te.prev,te,te.next)>=0)return!1;te=te.nextZ}return!0}function dsn(s,n,r){var c=s;do{var u=c.prev,d=c.next.next;!Que(u,d)&&Fvt(u,c,c.next,d)&&hW(u,d)&&hW(d,u)&&(n.push(u.i/r|0),n.push(c.i/r|0),n.push(d.i/r|0),dW(c),dW(c.next),c=s=d),c=c.next}while(c!==s);return B4(c)}function psn(s,n,r,c,u,d){var b=s;do{for(var w=b.next.next;w!==b.prev;){if(b.i!==w.i&&Esn(b,w)){var _=Uvt(b,w);b=B4(b,b.next),_=B4(_,_.next),fW(b,n,r,c,u,d,0),fW(_,n,r,c,u,d,0);return}w=w.next}b=b.next}while(b!==s)}function gsn(s,n,r,c){var u=[],d,b,w,_,x;for(d=0,b=n.length;d=r.next.y&&r.next.y!==r.y){var w=r.x+(u-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(w<=c&&w>d&&(d=w,b=r.x=r.x&&r.x>=x&&c!==r.x&&BB(ub.x||r.x===b.x&&vsn(b,r)))&&(b=r,M=L)),r=r.next;while(r!==_);return b}function vsn(s,n){return eu(s.prev,s,n.prev)<0&&eu(n.next,s,s.next)<0}function _sn(s,n,r,c){var u=s;do u.z===0&&(u.z=EIe(u.x,u.y,n,r,c)),u.prevZ=u.prev,u.nextZ=u.next,u=u.next;while(u!==s);u.prevZ.nextZ=null,u.prevZ=null,ysn(u)}function ysn(s){var n,r,c,u,d,b,w,_,x=1;do{for(r=s,s=null,d=null,b=0;r;){for(b++,c=r,w=0,n=0;n0||_>0&&c;)w!==0&&(_===0||!c||r.z<=c.z)?(u=r,r=r.nextZ,w--):(u=c,c=c.nextZ,_--),d?d.nextZ=u:s=u,u.prevZ=d,d=u;r=c}d.nextZ=null,x*=2}while(b>1);return s}function EIe(s,n,r,c,u){return s=(s-r)*u|0,n=(n-c)*u|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,s|n<<1}function xsn(s){var n=s,r=s;do(n.x=(s-b)*(d-w)&&(s-b)*(c-w)>=(r-b)*(n-w)&&(r-b)*(d-w)>=(u-b)*(c-w)}function Esn(s,n){return s.next.i!==n.i&&s.prev.i!==n.i&&!Ssn(s,n)&&(hW(s,n)&&hW(n,s)&&Msn(s,n)&&(eu(s.prev,s,n.prev)||eu(s,n.prev,n))||Que(s,n)&&eu(s.prev,s,s.next)>0&&eu(n.prev,n,n.next)>0)}function eu(s,n,r){return(n.y-s.y)*(r.x-n.x)-(n.x-s.x)*(r.y-n.y)}function Que(s,n){return s.x===n.x&&s.y===n.y}function Fvt(s,n,r,c){var u=Kue(eu(s,n,r)),d=Kue(eu(s,n,c)),b=Kue(eu(r,c,s)),w=Kue(eu(r,c,n));return!!(u!==d&&b!==w||u===0&&Zue(s,r,n)||d===0&&Zue(s,c,n)||b===0&&Zue(r,s,c)||w===0&&Zue(r,n,c))}function Zue(s,n,r){return n.x<=Math.max(s.x,r.x)&&n.x>=Math.min(s.x,r.x)&&n.y<=Math.max(s.y,r.y)&&n.y>=Math.min(s.y,r.y)}function Kue(s){return s>0?1:s<0?-1:0}function Ssn(s,n){var r=s;do{if(r.i!==s.i&&r.next.i!==s.i&&r.i!==n.i&&r.next.i!==n.i&&Fvt(r,r.next,s,n))return!0;r=r.next}while(r!==s);return!1}function hW(s,n){return eu(s.prev,s,s.next)<0?eu(s,n,s.next)>=0&&eu(s,s.prev,n)>=0:eu(s,n,s.prev)<0||eu(s,s.next,n)<0}function Msn(s,n){var r=s,c=!1,u=(s.x+n.x)/2,d=(s.y+n.y)/2;do r.y>d!=r.next.y>d&&r.next.y!==r.y&&u<(r.next.x-r.x)*(d-r.y)/(r.next.y-r.y)+r.x&&(c=!c),r=r.next;while(r!==s);return c}function Uvt(s,n){var r=new SIe(s.i,s.x,s.y),c=new SIe(n.i,n.x,n.y),u=s.next,d=n.prev;return s.next=n,n.prev=s,r.next=u,u.prev=r,c.next=r,r.prev=c,d.next=c,c.prev=d,c}function Ovt(s,n,r,c){var u=new SIe(s,n,r);return c?(u.next=c.next,u.prev=c,c.next.prev=u,c.next=u):(u.prev=u,u.next=u),u}function dW(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function SIe(s,n,r){this.i=s,this.x=n,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Jue.deviation=function(s,n,r,c){var u=n&&n.length,d=u?n[0]*r:s.length,b=Math.abs(MIe(s,0,d,r));if(u)for(var w=0,_=n.length;w<_;w++){var x=n[w]*r,T=w<_-1?n[w+1]*r:s.length;b-=Math.abs(MIe(s,x,T,r))}var M=0;for(w=0;w0&&(c+=s[u-1].length,r.holes.push(c))}return r}});var r_t=Sd((i_t,PIe)=>{(function(s){if(typeof i_t=="object"&&typeof PIe<"u")PIe.exports=s();else if(typeof define=="function"&&define.amd)define([],s);else{var n;typeof window<"u"?n=window:typeof global<"u"?n=global:typeof self<"u"?n=self:n=this,n.ELK=s()}})(function(){var s,n,r;return function c(u,d,b){function w(T,M){if(!d[T]){if(!u[T]){var L=typeof AD=="function"&&AD;if(!M&&L)return L(T,!0);if(_)return _(T,!0);var I=new Error("Cannot find module '"+T+"'");throw I.code="MODULE_NOT_FOUND",I}var D=d[T]={exports:{}};u[T][0].call(D.exports,function(F){var O=u[T][1][F];return w(O||F)},D,D.exports,c,u,d,b)}return d[T].exports}for(var _=typeof AD=="function"&&AD,x=0;x0&&arguments[0]!==void 0?arguments[0]:{},I=L.defaultLayoutOptions,D=I===void 0?{}:I,F=L.algorithms,O=F===void 0?["layered","stress","mrtree","radial","force","disco"]:F,z=L.workerFactory,Z=L.workerUrl;if(w(this,T),this.defaultLayoutOptions=D,this.initialized=!1,typeof Z>"u"&&typeof z>"u")throw new Error("Cannot construct an ELK without both 'workerUrl' and 'workerFactory'.");var H=z;typeof Z<"u"&&typeof z>"u"&&(H=function(ne){return new Worker(ne)});var te=H(Z);if(typeof te.postMessage!="function")throw new TypeError("Created worker does not provide the required 'postMessage' function.");this.worker=new x(te),this.worker.postMessage({cmd:"register",algorithms:O}).then(function(oe){return M.initialized=!0}).catch(console.err)}return b(T,[{key:"layout",value:function(L){var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},D=I.layoutOptions,F=D===void 0?this.defaultLayoutOptions:D;return L?this.worker.postMessage({cmd:"layout",graph:L,options:F}):Promise.reject(new Error("Missing mandatory parameter 'graph'."))}},{key:"knownLayoutAlgorithms",value:function(){return this.worker.postMessage({cmd:"algorithms"})}},{key:"knownLayoutOptions",value:function(){return this.worker.postMessage({cmd:"options"})}},{key:"knownLayoutCategories",value:function(){return this.worker.postMessage({cmd:"categories"})}},{key:"terminateWorker",value:function(){this.worker.terminate()}}]),T}();d.default=_;var x=function(){function T(M){var L=this;if(w(this,T),M===void 0)throw new Error("Missing mandatory parameter 'worker'.");this.resolvers={},this.worker=M,this.worker.onmessage=function(I){setTimeout(function(){L.receive(L,I)},0)}}return b(T,[{key:"postMessage",value:function(L){var I=this.id||0;this.id=I+1,L.id=I;var D=this;return new Promise(function(F,O){D.resolvers[I]=function(z,Z){z?O(z):F(Z)},D.worker.postMessage(L)})}},{key:"receive",value:function(L,I){var D=I.data,F=L.resolvers[D.id];F&&(delete L.resolvers[D.id],D.error?F(D.error):F(null,D.data))}},{key:"terminate",value:function(){this.worker.terminate&&this.worker.terminate()}}]),T}()},{}],2:[function(c,u,d){(function(b){var w;typeof window<"u"?w=window:typeof b<"u"?w=b:typeof self<"u"&&(w=self);var _,x;function T(){}function M(){}function L(){}function I(){}function D(){}function F(){}function O(){}function z(){}function Z(){}function H(){}function te(){}function oe(){}function ne(){}function ue(){}function Te(){}function Q(){}function ge(){}function Qe(){}function st(){}function at(){}function Ne(){}function tt(){}function ot(){}function Tt(){}function jt(){}function en(){}function mn(){}function cn(){}function bi(){}function Vt(){}function pn(){}function qn(){}function Yi(){}function $i(){}function Tr(){}function wr(){}function Si(){}function Fr(){}function se(){}function de(){}function it(){}function We(){}function En(){}function hr(){}function qi(){}function Me(){}function ve(){}function wt(){}function gn(){}function vn(){}function Mn(){}function xi(){}function mi(){}function ri(){}function Ge(){}function Ae(){}function Le(){}function ht(){}function Ye(){}function ct(){}function Ze(){}function Ke(){}function pt(){}function Xn(){}function _i(){}function Hi(){}function _n(){}function Je(){}function Qn(){}function ei(){}function ar(){}function yn(){}function Re(){}function nt(){}function kt(){}function xn(){}function Ei(){}function Xi(){}function cr(){}function So(){}function Ks(){}function Bi(){}function io(){}function gf(){}function Q1(){}function Lm(){}function b2(){}function zb(){}function bk(){}function Pe(){}function xt(){}function Kt(){}function tn(){}function Yt(){}function Zi(){}function Rr(){}function Xr(){}function bs(){}function Vs(){}function xs(){}function Cs(){}function Lc(){}function zf(){}function pl(){}function bg(){}function hc(){}function Js(){}function w2(){}function dc(){}function km(){}function v2(){}function Iv(){}function _2(){}function gl(){}function Rm(){}function rE(){}function gh(){}function y2(){}function sE(){}function PT(){}function kO(){}function wk(){}function vk(){}function x2(){}function RO(){}function IO(){}function uH(){}function DO(){}function BO(){}function OO(){}function NO(){}function fH(){}function hH(){}function dH(){}function FO(){}function pH(){}function gH(){}function mH(){}function bH(){}function _k(){}function wH(){}function vH(){}function _H(){}function yH(){}function xH(){}function pc(){}function ic(){}function EH(){}function SH(){}function MH(){}function TH(){}function CH(){}function AH(){}function UO(){}function PH(){}function Du(){}function yk(){}function Dv(){}function zO(){}function xk(){}function wp(){}function GO(){}function jO(){}function $O(){}function VO(){}function WO(){}function HO(){}function Cd(){}function LH(){}function Ad(){}function kH(){}function qO(){}function Gb(){}function LT(){}function Ek(){}function kc(){}function jb(){}function Sk(){}function RH(){}function Mk(){}function IH(){}function DH(){}function BH(){}function XO(){}function kT(){}function E2(){}function OH(){}function YO(){}function ZO(){}function Tk(){}function Ck(){}function KO(){}function NH(){}function Ak(){}function Pk(){}function FH(){}function JO(){}function Pd(){}function Lk(){}function oE(){}function QO(){}function eN(){}function UH(){}function zH(){}function GH(){}function jH(){}function $H(){}function S2(){}function VH(){}function WH(){}function kk(){}function tN(){}function $b(){}function RT(){}function HH(){}function qH(){}function XH(){}function M2(){}function wg(){}function nN(){}function YH(){}function ZH(){}function KH(){}function JH(){}function QH(){}function e0(){}function lt(){}function fn(){}function Jt(){}function rr(){}function Es(){}function ta(){}function Dl(){}function Ha(){}function IT(){}function eq(){}function vp(){}function DT(){}function tq(){}function T2(){}function BT(){}function OT(){}function ya(){}function nq(){}function iN(){}function NT(){}function iq(){}function rq(){}function sq(){}function FT(){}function Vb(){}function UT(){}function rN(){}function zT(){}function sN(){}function oN(){}function GT(){}function aN(){}function aE(){}function Bv(){}function jT(){}function oq(){}function aq(){}function cq(){}function $T(){}function VT(){}function Rk(){}function lq(){}function cN(){}function uq(){}function fq(){}function nu(){}function Gf(){}function hq(){}function dq(){}function lN(){}function pq(){}function Ik(){}function cE(){}function Dk(){}function C2(){}function lE(){}function uE(){}function WT(){}function A2(){}function gq(){}function mq(){}function bq(){}function wq(){}function vq(){}function HT(){}function fE(){}function uN(){}function _e(){}function P2(){}function qT(){}function _p(){}function Io(){}function _q(){}function yq(){}function xq(){}function Ov(){}function t0(){}function Wb(){}function fN(){}function Eq(){}function Sq(){}function n0(){}function Mq(){}function Tq(){}function Cq(){}function Aq(){}function Pq(){}function i0(){}function Lq(){}function kq(){}function Rq(){}function Iq(){}function Dq(){}function Nv(){}function Bq(){}function Oq(){}function vg(){}function Nq(){}function Fq(){}function Uq(){}function zq(){}function Pt(){}function hN(){}function dN(){}function Gq(){}function jq(){}function Bk(){}function hE(){}function dE(){}function $q(){}function pN(){}function Vq(){}function Im(){}function Ok(){}function Fv(){}function yp(){}function Wq(){}function gN(){}function mN(){}function pE(){}function Hb(){}function bN(){}function Hq(){}function XT(){}function qq(){}function gE(){}function mf(){}function YT(){}function mE(){}function Dm(){}function ZT(){}function KT(){}function r0(){}function wN(){}function Bu(){}function Nk(){}function Xq(){}function Yq(){}function Zq(){}function L2(){}function Kq(){}function bE(){}function vN(){}function Jq(){}function _N(){}function wE(){}function Fk(){}function yN(){}function Uk(){}function xN(){}function Qq(){}function eX(){}function tX(){}function EN(){}function zk(){}function nX(){}function Gk(){}function SN(){}function MN(){}function TN(){}function JT(){}function iX(){}function CN(){}function qb(){}function jk(){}function AN(){}function rX(){}function $k(){}function PN(){}function Vk(){}function sX(){}function Wk(){}function ro(){}function oX(){}function aX(){}function vE(){}function LN(){}function cX(){}function lX(){}function xp(){}function uX(){}function QT(){}function Hk(){}function kN(){}function RN(){}function Ld(){}function Xb(){}function qk(){}function IN(){}function eC(){}function DN(){}function Xk(){}function BN(){}function Yk(){}function Zk(){}function Yb(){}function fX(){}function Zb(){}function ON(){}function NN(){}function Kk(){}function hX(){}function dX(){}function pX(){}function FN(){}function UN(){}function gX(){}function zN(){}function GN(){}function Xh(){}function Bm(){}function mX(){}function bX(){}function tC(){}function k2(){}function jN(){}function $N(){}function wX(){}function VN(){}function R2(){}function _E(){}function vX(){}function WN(){}function HN(){}function nC(){}function qN(){}function iC(){}function Jk(){}function rC(){}function _X(){}function XN(){}function sC(){}function YN(){}function Qk(){}function yX(){}function ZN(){}function s0(){}function KN(){}function JN(){}function xX(){}function QN(){}function EX(){}function SX(){}function o0(){}function eR(){}function tR(){}function nR(){}function oC(){}function I2(){}function ns(){}function aC(){}function iR(){}function Uv(){}function MX(){}function rR(){}function eF(){}function jf(){}function TX(){}function CX(){}function tF(){}function AX(){}function nF(){}function PX(){}function LX(){}function kX(){}function a0(){}function $f(){}function sR(){}function RX(){}function IX(e){}function lDe(e){}function oR(){Ur()}function yE(){s7()}function iF(){Dee()}function rF(){qA()}function DX(){G_e()}function BX(){rve()}function OX(){UI()}function NX(){Tf()}function sF(){Twe()}function oF(){RR()}function FX(){lI()}function aR(){LGe()}function aF(){YHe()}function xE(){TBe()}function cR(){Ipe()}function cF(){$e()}function lF(){l7e()}function cC(){Xje()}function uF(){h7e()}function _g(){FHe()}function zv(){d7e()}function UX(){ube()}function fF(){vVe()}function zX(){Ew()}function GX(){p7e()}function jX(){OGe()}function $X(){bZe()}function VX(){CBe()}function WX(){Pve()}function HX(){ww()}function mh(){T8e()}function qX(){l7()}function XX(){ur()}function hF(){I7()}function dF(){CU()}function pF(){twe()}function lR(){bee()}function YX(){p_e()}function ZX(e){this.a=e}function KX(e){this.a=e}function EE(e){this.a=e}function JX(e){this.a=e}function QX(e){this.a=e}function eY(e){this.a=e}function gF(e){this.a=e}function tY(e){this.a=e}function mF(e){this.a=e}function kd(e){this.a=e}function nY(e){this.a=e}function uR(e){this.a=e}function iY(e){this.a=e}function bF(e){this.a=e}function rY(e){this.a=e}function sY(e){this.a=e}function oY(e){this.a=e}function aY(e){this.a=e}function fR(e){this.a=e}function hR(e){this.b=e}function cY(e){this.a=e}function lY(e){this.a=e}function uY(e){this.a=e}function fY(e){this.a=e}function hY(e){this.a=e}function wF(e){this.a=e}function vF(e){this.a=e}function dR(e){this.a=e}function lC(e){this.a=e}function SE(e){this.a=e}function dY(e){this.a=e}function _F(e){this.a=e}function Kb(e){this.a=e}function yF(e){this.a=e}function xF(e){this.a=e}function EF(e){this.a=e}function Ep(e){this.a=e}function Gv(e){this.a=e}function pR(e){this.a=e}function bh(e){this.a=e}function c0(e){this.a=e}function ME(e){this.d=e}function Om(){this.a=[]}function ui(){nl(this)}function bde(e,t){e.i=t}function wde(e,t){e.g=t}function vde(e,t){e.b=t}function _de(e,t){e.b=t}function yde(e,t){e.a=t}function SF(e,t){e.a=t}function xde(e,t){e.c=t}function gR(e,t){e.c=t}function Ede(e,t){e.b=t}function Sde(e,t){e.d=t}function Mde(e,t){e.d=t}function Ou(e,t){e.j=t}function Tde(e,t){e.a=t}function Cde(e,t){e.f=t}function Ade(e,t){e.f=t}function pY(e,t){e.e=t}function MF(e,t){e.k=t}function Pde(e,t){e.a=t}function Lde(e,t){e.b=t}function TF(e,t){e.g=t}function CF(e,t){e.j=t}function kde(e,t){e.n=t}function Rde(e,t){e.a=t}function Ide(e,t){e.a=t}function gY(e,t){e.c=t}function mY(e,t){e.c=t}function Dde(e,t){e.d=t}function Bde(e,t){e.e=t}function Ode(e,t){e.g=t}function Nde(e,t){e.a=t}function mR(e,t){e.c=t}function Fde(e,t){e.d=t}function Ude(e,t){e.e=t}function zde(e,t){e.f=t}function Gde(e,t){e.j=t}function jde(e,t){e.a=t}function $de(e,t){e.a=t}function Vde(e,t){e.b=t}function bY(e){e.b=e.a}function wY(e){e.c=e.d.d}function vY(e){ti(Hn(e))}function AF(e){this.b=e}function jv(e){this.a=e}function uC(e){this.a=e}function fC(e){this.a=e}function Jb(e){this.b=e}function Nm(e){this.b=e}function PF(e){this.a=e}function LF(e){this.a=e}function gr(e){this.a=e}function kF(e){this.a=e}function RF(e){this.a=e}function _Y(e){this.a=e}function IF(e){this.a=e}function D2(e){this.a=e}function hC(e){this.a=e}function yY(e){this.a=e}function xY(e){this.a=e}function bR(e){this.a=e}function DF(e){this.a=e}function EY(e){this.a=e}function SY(e){this.a=e}function MY(e){this.a=e}function TY(e){this.a=e}function CY(e){this.a=e}function AY(e){this.a=e}function PY(e){this.a=e}function LY(e){this.a=e}function kY(e){this.a=e}function RY(e){this.a=e}function IY(e){this.a=e}function $v(e){this.a=e}function yg(e){this.a=e}function DY(e){this.a=e}function BY(e){this.a=e}function Vv(e){this.a=e}function Rs(e){this.a=e}function BF(e){this.a=e}function bf(e){this.a=e}function j(e){this.c=e}function dC(e){this.e=e}function Rd(e){this.a=e}function OY(e){this.a=e}function Wv(e){this.a=e}function OF(e){this.a=e}function NY(e){this.a=e}function FY(e){this.a=e}function wR(e){this.a=e}function UY(e){this.a=e}function l0(e){this.a=e}function NF(e){this.a=e}function pC(e){this.a=e}function Uc(e){this.a=e}function Qc(e){this.a=e}function FF(e){this.a=e}function vR(e){this.a=e}function zY(e){this.a=e}function GY(e){this.a=e}function jY(e){this.a=e}function $Y(e){this.a=e}function VY(e){this.a=e}function UF(e){this.a=e}function TE(e){this.a=e}function Qb(e){this.a=e}function WY(e){this.a=e}function zF(e){this.a=e}function gC(e){this.a=e}function Id(e){this.a=e}function B2(e){this.a=e}function HY(e){this.a=e}function qY(e){this.a=e}function XY(e){this.a=e}function YY(e){this.a=e}function ZY(e){this.a=e}function GF(e){this.a=e}function u0(e){this.a=e}function Ws(e){this.a=e}function jF(e){this.a=e}function Sp(e){this.a=e}function $F(e){this.a=e}function KY(e){this.b=e}function xa(e){this.a=e}function JY(e){this.a=e}function VF(e){this.a=e}function WF(e){this.c=e}function _R(e){this.a=e}function QY(e){this.a=e}function eZ(e){this.a=e}function tZ(e){this.a=e}function nZ(e){this.a=e}function iZ(e){this.a=e}function rZ(e){this.a=e}function sZ(e){this.a=e}function oZ(e){this.a=e}function aZ(e){this.a=e}function cZ(e){this.a=e}function lZ(e){this.a=e}function uZ(e){this.a=e}function yR(e){this.a=e}function fZ(e){this.a=e}function xR(e){this.a=e}function hZ(e){this.a=e}function dZ(e){this.a=e}function pZ(e){this.a=e}function Nu(e){this.a=e}function Yh(e){this.a=e}function Dd(e){this.a=e}function ew(e){this.a=e}function gZ(e){this.a=e}function HF(e){this.a=e}function mZ(e){this.a=e}function bZ(e){this.a=e}function mC(e){this.a=e}function qF(e){this.f=e}function wZ(e){this.i=e}function ER(e){this.a=e}function vZ(e){this.a=e}function XF(e){this.a=e}function YF(e){this.a=e}function _Z(e){this.a=e}function yZ(e){this.a=e}function xZ(e){this.a=e}function EZ(e){this.a=e}function O2(e){this.a=e}function SZ(e){this.a=e}function MZ(e){this.a=e}function TZ(e){this.a=e}function CZ(e){this.a=e}function AZ(e){this.a=e}function ZF(e){this.a=e}function KF(e){this.a=e}function PZ(e){this.a=e}function LZ(e){this.a=e}function kZ(e){this.a=e}function RZ(e){this.a=e}function IZ(e){this.a=e}function DZ(e){this.a=e}function BZ(e){this.a=e}function OZ(e){this.a=e}function NZ(e){this.a=e}function FZ(e){this.a=e}function UZ(e){this.a=e}function zZ(e){this.a=e}function GZ(e){this.a=e}function jZ(e){this.a=e}function $Z(e){this.a=e}function JF(e){this.a=e}function Sr(e){this.b=e}function VZ(e){this.a=e}function WZ(e){this.a=e}function HZ(e){this.a=e}function qZ(e){this.a=e}function XZ(e){this.a=e}function YZ(e){this.a=e}function ZZ(e){this.a=e}function KZ(e){this.b=e}function SR(e){this.a=e}function N2(e){this.a=e}function QF(e){this.a=e}function bC(e){this.a=e}function wC(e){this.a=e}function MR(e){this.a=e}function TR(e){this.a=e}function JZ(e){this.d=e}function e8(e){this.c=e}function vC(e){this.e=e}function Rc(e){this.e=e}function _C(e){this.a=e}function t8(e){this.a=e}function CE(){this.a=0}function AE(){XNe(this)}function ke(){rJ(this)}function PE(){dUe(this)}function Wde(){_pe(),w$t()}function n8(){return null}function Hde(){return null}function qde(e){return e.a}function Xde(e){return e.a}function Yde(e){return e.a}function QZ(e){return e.a}function Zde(e){return e.a}function Y(e){return e.e}function xg(){this.c=zAe}function CR(){this.a=this}function yC(e){this.a=oIt(e)}function i8(){Mp.call(this)}function LE(){Mp.call(this)}function qa(){Mp.call(this)}function r8(){Mp.call(this)}function AR(){Mp.call(this)}function s8(){RFe.call(this)}function Mp(){RFe.call(this)}function F2(){Mp.call(this)}function Pi(){Mp.call(this)}function o8(){r8.call(this)}function Kde(e){e.b.Te(e.e)}function eK(e,t){t.jd(e.a)}function U2(e,t){e.a=t-e.a}function z2(e,t){e.b=t-e.b}function tK(e,t){e.b+=t}function Jde(e,t){e.d.b.$b(t)}function kE(e,t){e.e=t,t.b=e}function nK(e,t){e.length=t}function a8(e){e.a=new Ir}function c8(){c8=M,new ui}function iK(){this.b=new $pe}function S(){this.Bb|=256}function P(){Mp.call(this)}function U(){Mp.call(this)}function K(){Mp.call(this)}function pe(){Mp.call(this)}function xe(e){g7(e.c,e.b)}function je(e,t){cve(e.c,t)}function rt(e,t){n7(e.a,t)}function gt(e,t){Yee(e.a,t)}function wn(e,t){De(e.a,t)}function Sn(e,t){Cr(e.b,t)}function Dn(e,t){Li(e.e,t)}function Vi(e){oS(),Zre.Rd(e)}function vr(){vr=M,r3e=new F}function Ur(){Ur=M,Wre=new I}function Qs(){Qs=M,i3e=new L}function Wr(){Wr=M,Hre=new rBe}function so(){so=M,qre=new sBe}function jo(){jo=M,Pnt=new Q}function Vf(){Vf=M,jP=new ge}function wh(){wh=M,Bnt=new at}function zr(){this.a=new ui}function ml(){this.a=new D7e}function Zh(){this.a=new ke}function f0(){this.a=new ke}function l8(){this.a=new ke}function uDe(){this.a=new ke}function fDe(){this.a=new ke}function hDe(){this.a=new zr}function Qde(){this.a=new iOe}function epe(){this.a=new x7e}function tpe(){this.a=new u8e}function npe(){this.a=new Ks}function iu(){this.a=new vp}function rK(){this.a=new ke}function ipe(){this.a=new ke}function dDe(){this.b=new ke}function rpe(){this.f=new ke}function pDe(){this.d=new ke}function gDe(){this.a=new ke}function Fm(){this.a=new oGe}function spe(){this.a=new _e}function mDe(){this.j=new ke}function zc(){Ir.call(this)}function bDe(){ke.call(this)}function sK(){Zh.call(this)}function ope(){G2.call(this)}function G2(){bg.call(this)}function j2(){bg.call(this)}function ape(){j2.call(this)}function wDe(){ui.call(this)}function vDe(){ui.call(this)}function _De(){ui.call(this)}function yDe(){qUe.call(this)}function xDe(){qUe.call(this)}function EDe(){a9.call(this)}function SDe(){zDe.call(this)}function MDe(){zDe.call(this)}function cpe(){mf.call(this)}function lpe(){mf.call(this)}function oK(){Dge.call(this)}function aK(){Dge.call(this)}function cK(){Qje.call(this)}function upe(){Bu.call(this)}function TDe(){Bu.call(this)}function CDe(){upe.call(this)}function ADe(){S.call(this)}function PDe(){zr.call(this)}function fpe(){ui.call(this)}function lK(){ui.call(this)}function LDe(){ui.call(this)}function kDe(){$f.call(this)}function K3t(e){ZBe.call(this,e)}function hpe(e){ZBe.call(this,e)}function J3t(e){hpe.call(this,e)}function RDe(e){w$e.call(this,e)}function IDe(e){w$e.call(this,e)}function DDe(e){vme.call(this,e)}function dpe(e){EK.call(this,e)}function ppe(e){r7e.call(this,e)}function Hv(e){UE.call(this,e)}function na(e){$9e.call(this,e)}function BDe(e){na.call(this,e)}function u8(e){na.call(this,e)}function Ra(e){na.call(this,e)}function ODe(e){na.call(this,e)}function uK(e){$9e.call(this,e)}function gpe(e){Ra.call(this,e)}function xC(e){na.call(this,e)}function un(e){na.call(this,e)}function ba(e){na.call(this,e)}function NDe(e){na.call(this,e)}function EC(e){na.call(this,e)}function vh(e){un.call(this,e)}function SC(){lC.call(this,{})}function Tp(){SE.call(this,"")}function MC(){SE.call(this,"")}function h0(){SE.call(this,"")}function tw(){SE.call(this,"")}function FDe(e){Ra.call(this,e)}function Cp(e){na.call(this,e)}function mpe(e){KKe(),Kjt(this,e)}function fK(e){HE(),this.a=e}function PR(e){e.b=null,e.c=0}function Q3t(e,t){e.a=t,HNt(e)}function eEt(e,t){return e*e/t}function RE(e){return e<0?-e:e}function hK(e){A$e(),this.a=e}function dK(e){$J(),this.f=e}function pK(e){$J(),this.f=e}function gK(e,t,i){e.a[t.g]=i}function tEt(e,t,i){MBt(i,e,t)}function nEt(e,t,i){GGt(i,e,t)}function iEt(e,t,i){G5t(e,i,t)}function UDe(){this.d=new ke}function zDe(){this.a=new Kq}function GDe(){throw Y(new Pi)}function bpe(){throw Y(new Pi)}function rEt(){throw Y(new Pi)}function sEt(){throw Y(new Pi)}function oEt(){throw Y(new Pi)}function jDe(){throw Y(new Pi)}function LR(e){this.c=ti(Hn(e))}function aEt(e){return new dR(e)}function cEt(e){return new rx(e)}function q(e,t){return a7e(e,t)}function lEt(e,t){return e.a-t.a}function uEt(e,t){return e.a-t.a}function fEt(e,t){return e.a-t.a}function $De(e,t){return e.g-t.g}function wf(e,t){return e>t?e:t}function d0(e,t){return e0}function _K(e,t){return Ma(e,t)<0}function OE(e){return e.d.c+e.e.c}function fo(){this.a=0,this.b=0}function p8(e){h9.call(this,e)}function Eg(e){w_.call(this,e)}function _Be(e){pQ.call(this,e)}function yBe(e){pQ.call(this,e)}function g8(e){lVe.call(this,e,0)}function xBe(e){this.c=(dn(e),e)}function m8(e){this.a=new g8(e)}function iw(e){this.a=new WJ(e)}function kEt(){throw Y(new K)}function REt(){throw Y(new K)}function NE(){NE=M,k3e=new xNe}function Yv(){Yv=M,uy=new ot}function EBe(){EBe=M,Znt=new gn}function b8(){b8=M,ase=new zFe}function Lpe(){Lpe=M,zit=new Lm}function SBe(){SBe=M,Git=new Pe}function kpe(){kpe=M,jit=new R9e}function Rpe(){Rpe=M,CEe=new Zi}function MBe(){MBe=M,Zit=new zf}function PC(){PC=M,srt=new QH}function TBe(){TBe=M,rrt=new zO}function Ipe(){Ipe=M,bSe=new RH}function RR(){RR=M,Qit=new fo}function CBe(){CBe=M,Gat=new ss}function ABe(){this.b=new tne(ITe)}function PBe(){this.a=new tne(qTe)}function LBe(){this.a=(qs(),Oh)}function kBe(){this.a=(qs(),Oh)}function w8(e){this.a=0,this.b=e}function v8(e){return e.b!=e.d.c}function RBe(e,t){return e.d[t.o]}function IBe(e,t){for(;e.sd(t););}function Dpe(e,t,i){e.splice(t,i)}function IEt(e,t,i){Ko(e.d,t.f,i)}function DEt(e,t){qte(ye(e.a),t)}function BEt(e,t){qte(ye(e.a),t)}function DBe(e){e.c?rZe(e):sZe(e)}function BBe(){BBe=M,klt=new vN}function OBe(){OBe=M,Wlt=new vDe}function NBe(){NBe=M,Hlt=new _De}function Sg(){Sg=M,ku=new fpe}function Bpe(){Bpe=M,FAe=new LDe}function _8(){_8=M,Dj=new ui}function Ope(){Ope=M,YAe=new ke}function Mg(){Mg=M,mm=new RX}function LC(){LC=M,Dae=new oFe}function Pp(){Pp=M,_D=new aFe}function yK(){yK=M,rut=new Bm}function Yo(){Yo=M,out=new mX}function IR(e){this.a=new nOe(e)}function FBe(e){this.a=h(Hn(e),13)}function UBe(e,t){this.b=e,this.c=t}function zBe(e,t){this.b=e,this.a=t}function Npe(e,t){this.b=e,this.d=t}function FE(e,t){this.e=e,this.d=t}function Fpe(e,t){this.b=e,this.c=t}function GBe(e,t){this.a=e,this.b=t}function jBe(e,t){this.a=e,this.b=t}function $Be(e,t){this.a=e,this.b=t}function VBe(e,t){this.a=e,this.b=t}function WBe(e,t){this.b=e,this.a=t}function X2(e,t){XE.call(this,e,t)}function Zv(e,t){X2.call(this,e,t)}function HBe(e,t){this.b=e,this.a=t}function qBe(e,t){this.a=e,this.b=t}function DR(e,t){this.g=e,this.i=t}function XBe(e,t){this.b=e,this.a=t}function xK(e,t){this.a=e,this.b=t}function YBe(e,t){this.a=e,this.f=t}function ZBe(e){cJ(e.Wb()),this.c=e}function KBe(e,t){this.b=e,this.c=t}function Oi(e,t){this.f=e,this.g=t}function JBe(e,t){Oi.call(this,e,t)}function QBe(e,t){this.e=e,this.c=t}function EK(e){this.b=h(Hn(e),43)}function eOe(e){this.a=h(Hn(e),15)}function UE(e){this.a=h(Hn(e),15)}function Upe(e,t){this.a=e,this.b=t}function OEt(e,t){return e>t&&t0?e:t}function DNe(e){return Xa(e.l,e.m,e.h)}function eJ(e){return e<10?"0"+e:""+e}function bSt(e){return e==eb||e==Nw}function wSt(e){return e==eb||e==Ow}function ju(e){return Qo(e.b.b,e,0)}function BNe(e){this.a=VOe(),this.b=e}function ONe(e){this.a=VOe(),this.b=e}function ex(e){this.a=e,oR.call(this)}function NNe(e){this.a=e,oR.call(this)}function vge(e,t){DI(e,0,e.length,t)}function FNe(e,t){return De(e.a,t),t}function vSt(e,t){return De(e.c,t),e}function UNe(e,t){return oc(e.a,t),e}function _St(e,t){return Vu(),t.a+=e}function ySt(e,t){return Vu(),t.c+=e}function xSt(e,t){return Vu(),t.a+=e}function zNe(e){return e==_y||e==vy}function n_(e){return e==rf||e==sf}function YR(e){return e==hm||e==rp}function Bd(e){return e!=sp&&e!=hb}function $u(e){return e.eg()&&e.fg()}function V8(e){return oc(new ss,e)}function GNe(){GNe=M,Roe=new GA(mae)}function Gc(){IF.call(this,new A0)}function jNe(){F9.call(this,0,0,0,0)}function VE(){Yf.call(this,0,0,0,0)}function _ge(e){pNe.call(this,e,!0)}function Do(e){this.a=e.a,this.b=e.b}function Od(e,t,i){Yu(e,t),Zu(e,i)}function W8(e,t,i){x_(e,t),y_(e,i)}function yge(e,t,i){see(e,t),oee(e,i)}function tJ(e,t,i){CA(e,t),TA(e,i)}function nJ(e,t,i){AA(e,t),PA(e,i)}function iJ(e,t){Uee(e,t),aee(e,e.D)}function $Ne(e,t){return new wS(t,e)}function ESt(e,t){return new wS(t,e)}function kp(e,t){return et?1:0}function qC(e){return a1e(e.b.tc(),e.a)}function Kh(e){return rA(e.a.tc(),e.b)}function VNe(e){return hu(e,0,e.length)}function H8(e){return e!=null?Hr(e):0}function Nd(e){r7e.call(this,new ppe(e))}function WNe(){M8.call(this,"Head",1)}function HNe(){M8.call(this,"Tail",3)}function xge(e,t,i){xJ.call(this,e,t,i)}function SSt(e,t,i){SF(e,t.le(e.a,i))}function qNe(e,t){return parseInt(e,t)}function MSt(e,t){return SA(t,Sh(e))}function TSt(e,t){return SA(t,Sh(e))}function tx(e){F9.call(this,e,e,e,e)}function rJ(e){e.c=le(on,et,1,0,5,1)}function XNe(e){e.a=le(on,et,1,8,5,1)}function Ege(e){return e.b&&vne(e),e.a}function Sge(e){return e.b&&vne(e),e.c}function sJ(e){return e.d&&Gte(e),e.c}function oJ(e){return e.d&&Gte(e),e.b}function Mge(e){return e.d&&Gte(e),e.a}function Tge(e,t,i){return Gr(e,t,i),i}function YNe(e,t,i){Gr(e.c[t.g],t.g,i)}function CSt(e,t,i){return dr(e.g,i,t)}function ASt(e,t,i){return dr(e.k,i,t)}function PSt(e,t,i){Od(i,i.i+e,i.j+t)}function wa(e,t){Zr.call(this,e.b,t)}function XC(e){vi(),Rc.call(this,e)}function Ol(){Ol=M,gm=(BBe(),klt)}function zn(){zn=M,new ZNe,new ke}function ZNe(){new ui,new ui,new ui}function Mo(){Mo=M,Tnt=new te,n3e=new oe}function i_(){i_=M,d5=new fOe,p5=new LNe}function ru(){ru=M,Qxe=sMt(new LR(Ca))}function Yr(){Yr=M,new vY((ru(),"="))}function q8(e){e.j=le(b3e,be,287,0,0,1)}function KNe(e){this.a=e,Rme.call(this,e)}function LSt(e){return e==null?0:Hr(e)}function YC(e){return e==null?Xc:Ga(e)}function po(e,t){return e.charCodeAt(t)}function WE(e,t,i){return Pge(e,wc(t),i)}function Xa(e,t,i){return{l:e,m:t,h:i}}function Zo(e){return e.at-1?0:t-1}function ZSt(e,t,i){return i?t!=0:t!=e-1}function fJ(e,t,i){return e.a[t.g][i.g]}function KSt(e,t){return e.e[t.c.o][t.o]}function JSt(e,t){return e.a[t.c.o][t.o]}function Hf(e,t){return e.a[t.c.o][t.o]}function QSt(e,t){return e.j[t.o]=P8t(t)}function eMt(e,t){return to(e.c.d,t.c.d)}function tMt(e,t){return to(e.c.c,t.c.c)}function nMt(e,t,i){wjt(e.a,e.b,e.c,t,i)}function iMt(e,t,i,a){Gr(e.a[t.g],i.g,a)}function JC(e,t,i){return Gr(e.g,t,i),i}function au(e,t){return e.a*=t,e.b*=t,e}function rMt(e,t){e.q.setHours(t),fP(e,t)}function vs(e,t,i){uI.call(this,e,t,i)}function Z8(e,t,i){vs.call(this,e,t,i)}function Nl(e,t,i){vs.call(this,e,t,i)}function gFe(e,t,i){Z8.call(this,e,t,i)}function Rge(e,t,i){b9.call(this,e,t,i)}function mFe(e,t,i){b9.call(this,e,t,i)}function bFe(e,t,i){Rge.call(this,e,t,i)}function wFe(e,t,i){Ige.call(this,e,t,i)}function Ige(e,t,i){uI.call(this,e,t,i)}function qE(e,t,i){uI.call(this,e,t,i)}function XE(e,t){this.a=e,MK.call(this,t)}function Bn(e){this.i=e,this.f=this.i.j}function Cg(e){this.c=e,this.a=this.c.a}function Dge(){this.Bb|=256,this.Bb|=512}function vFe(e,t){this.a=e,EK.call(this,t)}function _Fe(e,t){this.a=t,EK.call(this,e)}function Bge(e){this.b=e,this.a=this.b.a.e}function yFe(e){e.b.jc(),--e.d.f.d,k9(e.d)}function xFe(e){e.a=h(sn(e.b.a,4),116)}function EFe(e){e.a=h(sn(e.b.a,4),116)}function SFe(e){uR.call(this,h(Hn(e),34))}function MFe(e){uR.call(this,h(Hn(e),34))}function sMt(e){return Hn(Xc),new e9e(e,e)}function TFe(e,t){return new iXe(e.a,e.b,t)}function qf(e,t,i){return e.substr(t,i-t)}function oMt(e){return e==null?null:e.name}function aMt(e){return e.l+e.m*Nx+e.h*l1}function aw(e){return typeof e=="number"}function $o(e){return typeof e=="number"}function Rp(e,t){return!!t&&e.b[t.g]==t}function Oge(e,t){var i;i=e[Z_],t[Z_]=i}function K8(e){Jb.call(this,e),this.a=e}function Nge(e){Nm.call(this,e),this.a=e}function KR(e){qv.call(this,e),this.a=e}function Fge(e){IF.call(this,new E0e(e))}function CFe(e){if(!e)throw Y(new P)}function Rn(e){if(!e)throw Y(new K)}function Fd(e){e.o==null&&o8t(e)}function hJ(e){return Rn(e.a!=null),e.a}function AFe(e,t){return De(t.a,e.a),e.a}function PFe(e,t){return De(t.b,e.a),e.a}function cMt(e,t){t&&(e.a=(f_(t),t.a))}function Uge(e,t){return fA(e.a,t)!=null}function rc(e,t){return h(er(e.a,t),15)}function dJ(e){return e.b=h(_Ue(e.a),38)}function m0(e){return e.$H||(e.$H=++lVt)}function pJ(e){return Zo(e.a)||Zo(e.b)}function cw(e,t){return!!e.p&&v0(e.p,t)}function lMt(e,t){return e.k.b=(dn(t),t)}function uMt(e,t){return e.k.b=(dn(t),t)}function J8(e,t){return++e.b,De(e.a,t)}function zge(e,t){return++e.b,Sa(e.a,t)}function fMt(e,t,i){return uze(e,t,i,e.b)}function Gge(e,t,i){return uze(e,t,i,e.c)}function jge(e,t){uwe.call(this,e,t,null)}function LFe(e,t){this.a=t,EK.call(this,e)}function JR(e){this.a=e,AF.call(this,e)}function kFe(){PC(),this.b=new B2(this)}function gJ(e,t){$J(),this.f=t,this.d=e}function RFe(){q8(this),z9(this),this.Pd()}function QC(e){this.d=e,Bn.call(this,e)}function nx(e){this.c=e,Bn.call(this,e)}function QR(e){this.c=e,QC.call(this,e)}function hMt(e,t,i){Yee(e.a,i),n7(e.a,t)}function $ge(e,t,i){h(II(e,t),19).nc(i)}function b0(e,t){return De(t.a,e.a),e.a}function Qh(e){var t;t=e.a,e.a=e.b,e.b=t}function eI(e,t){LC(),this.a=e,this.b=t}function Q8(e,t){Pp(),this.b=e,this.c=t}function IFe(e,t,i,a){t1e.call(this,e,t,i,a)}function e9(e,t,i){var a;a=e.fd(t),a.Bc(i)}function DFe(e,t,i){try{e[t]=i}catch{}}function t9(){t9=M,Tj=new Zr(PQe,0)}function eA(){eA=M,wL=new Sr("root")}function tA(){tA=M,vD=new MDe,new SDe}function dMt(e){return++Er,new pw(3,e)}function ed(e){return Ef(e,Dx),new Gl(e)}function Vge(e){return Mo(),Hn(e),new R8e(e)}function pMt(e){return i_(),Fi((A7e(),Ant),e)}function BFe(e){return oS(),parseInt(e)||-1}function gMt(e,t){return vt(),e==t?0:e?1:-1}function mMt(e){return e==null?null:Ga(e)}function bMt(e){return e==null?null:Ga(e)}function tI(e){return e.f!=null?e.f:""+e.g}function mJ(e){return g1e(e.c,e.c.length)}function OFe(e){e.b=new UFe(e),e.c=new ui}function Wge(e){this.q=new w.Date(cS(e))}function NFe(e){this.c=e,this.a=1,this.b=1}function Hge(e){NE(),this.b=e,this.a=!0}function FFe(){this.a=new Kv,this.b=new Kv}function UFe(e){Bme.call(this,e,null,null)}function zFe(){Oi.call(this,"POLYOMINO",0)}function nI(e){re(e,142)&&h(e,142).Xg()}function bJ(e){return Rn(e.b!=0),e.a.a.c}function n9(e){return Rn(e.b!=0),e.c.b.c}function Fl(e,t,i){return e.a+=t,e.b+=i,e}function wMt(e,t,i){return e.a*=t,e.b*=i,e}function iI(e,t,i){return e.a-=t,e.b-=i,e}function GFe(e,t,i){return e.a+=hu(t,0,i),e}function wJ(e){return e.a=-e.a,e.b=-e.b,e}function vJ(e){return RE(e.d.e-e.e.e)-e.a}function vMt(e,t){return e.c.nc(h(t,134))}function _Mt(e,t,i){return De(t,bWe(e,i))}function yMt(e,t){return e>0?t*t/e:t*t*100}function xMt(e,t){return e>0?t/(e*e):t*100}function EMt(e,t,i){JI(Ea(e.a),t,T7e(i))}function SMt(e,t,i){JI(Vc(e.a),t,C7e(i))}function wl(e,t,i){il.call(this,e,t,i,2)}function jFe(e,t){LC(),eI.call(this,e,t)}function qge(e,t){Pp(),Q8.call(this,e,t)}function $Fe(e,t){Pp(),Q8.call(this,e,t)}function VFe(e,t){Pp(),qge.call(this,e,t)}function _J(e,t){Ol(),M9.call(this,e,t)}function Xge(e,t){Ol(),M9.call(this,e,t)}function WFe(e,t){Ol(),_J.call(this,e,t)}function Yge(e,t){Ol(),_J.call(this,e,t)}function HFe(e,t){Ol(),Yge.call(this,e,t)}function qFe(e,t){Ol(),Xge.call(this,e,t)}function XFe(e,t){Ol(),M9.call(this,e,t)}function MMt(e,t,i){return t.ak(e.e,e.c,i)}function TMt(e,t,i){return t.bk(e.e,e.c,i)}function Zge(e,t,i){return B7(OI(e,t),i)}function yJ(e,t){return jg(e.e,h(t,42))}function CMt(e){return e==null?null:kjt(e)}function AMt(e){return e==null?null:aNt(e)}function YFe(e){this.c=e,Yu(e,0),Zu(e,0)}function YE(e,t){this.c=e,FE.call(this,e,t)}function nA(e,t){this.a=e,YE.call(this,e,t)}function Kge(e){this.a=e,this.b=eUe(this.a.d)}function PMt(e,t){this.d=e,wY(this),this.b=t}function Jge(){Qje.call(this),this.Bb|=oo}function i9(){IIt.call(this,new A0,new ui)}function xJ(e,t,i){TI.call(this,e,t,i,null)}function Qge(e,t,i){TI.call(this,e,t,i,null)}function td(e,t){e.a.bd(e.b,t),++e.b,e.c=-1}function eme(e,t){var i;return i=e.e,e.e=t,i}function mt(e){return KC(e==null||ow(e)),e}function Xe(e){return KC(e==null||aw(e)),e}function ti(e){return KC(e==null||ws(e)),e}function LMt(e,t){return Hn(e),Hn(t),LA(e,t)}function ZFe(e){return e>8?0:e+1}function KFe(e){nl(e.c),e.b.b=e.b,e.b.a=e.b}function JFe(e,t){BGe.call(this,e),this.a=t}function oi(e,t){BGe.call(this,e),this.a=t}function kMt(e){nwe.call(this,0,0),this.f=e}function EJ(e){var t;t=e[Z_]|0,e[Z_]=t+1}function RMt(e,t,i){return e.Ld(t,i)<=0?i:t}function IMt(e,t){return h(gx(e.b,t),180)}function DMt(e,t){return h(gx(e.c,t),199)}function SJ(e){return h(St(e.a,e.b),269)}function QFe(e){return new $t(e.c,e.d+e.a)}function tme(e){return zg(xAt($o(e)?fu(e):e))}function e8e(e){return vl(),zNe(h(e,179))}function Gm(){Gm=M,xAe=Ht((Hl(),C1))}function r9(){r9=M,w.Math.pow(2,-65)}function rI(e,t,i){++e.j,e.Yh(),GQ(e,t,i)}function t8e(e,t,i){++e.j,e.Vh(t,e.Ch(t,i))}function nme(e,t,i){return i=Ml(e,t,3,i),i}function ime(e,t,i){return i=Ml(e,t,6,i),i}function rme(e,t,i){return i=Ml(e,t,9,i),i}function Ud(e,t){return tQ(t,fxe),e.f=t,e}function sme(e,t){return(t&zi)%e.d.length}function BMt(e,t){return RR(),TS(t.d.g,e)}function n8e(e,t){return dr(e.a,t,"")==null}function i8e(e,t,i){return E_e(e.c,e.b,t,i)}function OMt(e,t,i){var a;a=e.fd(t),a.Bc(i)}function r8e(e,t){this.a=e,KZ.call(this,t)}function sI(e,t){this.a=e,KZ.call(this,t)}function s8e(e,t){this.c=e,w_.call(this,t)}function o8e(e){this.b=e,this.a=this.b.b.Tb()}function ome(e,t){e8.call(this,e),this.a=t}function MJ(e,t){e8.call(this,e),this.a=t}function Zr(e,t){Sr.call(this,e),this.a=t}function o_(e,t){Ra.call(this,RP+e+_z+t)}function s9(){K3t.call(this,new ui),this.a=3}function oI(e){return!e.a&&(e.a=new st),e.a}function o9(e){e.b?o9(e.b):e.f.c.Zb(e.e,e.d)}function a8e(e){this.a=(_t(),new fC(Hn(e)))}function Ag(e,t){if(!e)throw Y(new ba(t))}function ame(e,t){if(!e)throw Y(new un(t))}function cme(e,t,i){return e.lastIndexOf(t,i)}function NMt(e,t,i){return e.apply(t,i);var a}function TJ(e,t,i){return ix(e,h(t,23),i)}function FMt(e,t){return vK($We(e.a,t,!0))}function UMt(e,t){return vK(VWe(e.a,t,!0))}function c8e(e){return new xBe((f_(e),e.a))}function CJ(e){return String.fromCharCode(e)}function zMt(e){return e==null?null:e.message}function GMt(e,t){e.e=t,t!=null&&DFe(t,jne,e)}function jMt(e,t,i){return to(e[t.b],e[i.b])}function lme(e,t,i,a){F9.call(this,e,t,i,a)}function aI(e){YRt.call(this,e,(uU(),nse))}function $Mt(e,t){return e.k.a=(dn(t),t+10)}function VMt(e,t){return e.k.a=(dn(t),t+10)}function WMt(e,t){return RR(),!TS(t.d.g,e)}function l8e(){l8e=M,h3e=le(Po,be,21,256,0,1)}function vt(){vt=M,K0=(vt(),!1),oM=!0}function u8e(){this.b=new fo,this.c=new ke}function ume(){this.d=new fo,this.e=new fo}function fme(){this.k=new fo,this.n=new fo}function f8e(){this.b=new ABe,this.a=new hq}function h8e(){this.b=new ui,this.a=new ui}function d8e(){this.b=new zr,this.a=new zr}function p8e(){this.a=new ke,this.d=new ke}function g8e(){this.a=new ke,this.b=new ke}function m8e(){this.a=new Ks,this.b=new iK}function b8e(){this.a=new l8,this.c=new Cs}function a9(){this.n=new j2,this.i=new VE}function w8e(){a9.call(this),this.a=new fo}function hme(e,t,i){return i=Ml(e,t,11,i),i}function tr(e,t){return e.a+=t.a,e.b+=t.b,e}function Bc(e,t){return e.a-=t.a,e.b-=t.b,e}function HMt(e,t){var i;return i=t.Yg(e.a),i}function dme(e,t){return h(e.b.cd(t),190).a}function qMt(e,t){return t==e||QA(E7(t),e)}function XMt(e){return e<100?null:new Eg(e)}function YMt(e,t,i){i!=null&&Q0e(t,yte(e,i))}function ZMt(e,t,i){i!=null&&ebe(t,yte(e,i))}function ZE(e,t,i,a){ze.call(this,e,t,i,a)}function pme(e,t,i,a){ze.call(this,e,t,i,a)}function v8e(e,t,i,a){pme.call(this,e,t,i,a)}function _8e(e,t,i,a){D9.call(this,e,t,i,a)}function AJ(e,t,i,a){D9.call(this,e,t,i,a)}function gme(e,t,i,a){D9.call(this,e,t,i,a)}function y8e(e,t,i,a){AJ.call(this,e,t,i,a)}function mme(e,t,i,a){AJ.call(this,e,t,i,a)}function an(e,t,i,a){gme.call(this,e,t,i,a)}function x8e(e,t,i,a){mme.call(this,e,t,i,a)}function E8e(e,t,i,a){o1e.call(this,e,t,i,a)}function S8e(e,t,i){this.a=e,Npe.call(this,t,i)}function KMt(e,t,i){return e.d=h(t.Kb(i),206)}function M8e(e,t){return e.Pi().dh().Zg(e,t)}function bme(e,t){return e.Pi().dh()._g(e,t)}function PJ(e,t){return Mo(),vIt(e.tc(),t)!=-1}function JMt(e,t){return Yr(),new LFe(e.tc(),t)}function c9(e){return Mo(),e.hc()?e.ic():null}function wme(e){return aw(e)?(dn(e),e):e.$d()}function l9(e){return!isNaN(e)&&!isFinite(e)}function vme(e){lw(),this.b=(_t(),new qv(e))}function lw(){lw=M,new iY((_t(),_t(),uo))}function T8e(){T8e=M,Qlt=le(on,et,1,0,5,1)}function _me(){_me=M,eut=le(on,et,1,0,5,1)}function C8e(){C8e=M,Nlt=le(on,et,1,0,5,1)}function A8e(){A8e=M,u3e=le(qx,be,192,256,0,1)}function P8e(){P8e=M,d3e=le(J0,be,149,256,0,1)}function L8e(){L8e=M,m3e=le(Q0,be,168,256,0,1)}function k8e(){k8e=M,f3e=le($P,be,159,128,0,1)}function R8e(e){this.b=e,this.a=(Mo(),Mo(),n3e)}function I8e(e){this.b=e,j8.call(this,V7,0)}function D8e(e){this.c=e,j8.call(this,V7,0)}function B8e(e){return e.c?Qo(e.c.a,e,0):-1}function LJ(e,t){return vK(VWe(e.a,t,!1))}function kJ(e,t){return vK($We(e.a,t,!1))}function a_(e,t){return e.b.sd(new Hpe(e,t))}function O8e(e,t){return e.b.sd(new bOe(e,t))}function u9(e,t){if(!e)throw Y(new un(t))}function yme(e,t){if(!e)throw Y(new ODe(t))}function xme(e,t){a8(this),this.e=e,this.f=t}function Eme(){a8(this),this.e=0,this.f=!0}function Sme(e,t){this.c=e,KJ.call(this,e,t)}function N8e(e,t){return re(t,15)&&iZe(e.c,t)}function f9(e,t,i){return h(e.c,64).yj(t,i)}function QMt(e,t,i){return h(e.c,64).xj(t,i)}function eTt(e,t,i){return MMt(e,h(t,311),i)}function Mme(e,t,i){return TMt(e,h(t,311),i)}function tTt(e,t,i){return bqe(e,h(t,311),i)}function F8e(e,t,i){return zOt(e,h(t,311),i)}function nTt(e,t){return Jh(),$n(ye(e.a),t)}function iTt(e,t){return Jh(),$n(ye(e.a),t)}function rTt(e){return Mo(),v8(e.a)?gze(e):null}function U8e(e,t){return e.b.Qb(t)?lUe(e,t):null}function cI(e,t){return e.substr(t,e.length-t)}function z8e(e){return h(e,11).f.c.length!=0}function G8e(e){return h(e,11).d.c.length!=0}function iA(e){return e==p3||e==vd||e==Oa}function j8e(e){yf(e.a),IGe(e.c,e.b),e.b=null}function vf(e){rJ(this),Nme(this.c,0,e.yc())}function h9(e){eFe(this),rd(this),wo(this,e)}function $8e(e,t,i){this.d=e,this.b=i,this.a=t}function Oc(e,t,i){this.a=e,this.b=t,this.c=i}function V8e(e,t,i){this.a=e,this.b=t,this.c=i}function W8e(e,t,i){this.c=e,this.a=t,this.b=i}function sTt(e,t,i,a){e.d.b.$b(i),e.d.b.Zb(a,t)}function rA(e,t){return Mo(),Hn(t),new _Fe(e,t)}function oTt(e){return KU(),Fi((xze(),eit),e)}function aTt(e){return dU(),Fi((Eze(),tit),e)}function cTt(e){return uU(),Fi((WGe(),Xnt),e)}function lTt(e){return Wg(),Fi((eGe(),Ynt),e)}function uTt(e){return A7(),Fi((q$e(),nit),e)}function fTt(e){return Sx(),Fi((XGe(),rit),e)}function hTt(e){return YA(),Fi((YGe(),oit),e)}function dTt(e){return b8(),Fi((Z7e(),ait),e)}function pTt(e){return gU(),Fi((Sze(),Sit),e)}function gTt(e){return xA(),Fi((bGe(),Bit),e)}function mTt(e){return _o(),Fi((mje(),Uit),e)}function bTt(e){return yS(),Fi((qGe(),Vit),e)}function wTt(e){return Xt(),Fi((y$e(),Jit),e)}function RJ(e){F9.call(this,e.d,e.c,e.a,e.b)}function Tme(e){F9.call(this,e.d,e.c,e.a,e.b)}function vTt(e){return NA(),Fi((wGe(),nrt),e)}function _Tt(e){return Ao(),Fi((HOe(),irt),e)}function yTt(e){return JA(),Fi((pje(),urt),e)}function xTt(e){return sU(),Fi((Mze(),frt),e)}function ETt(e){return kS(),Fi((Vje(),hrt),e)}function STt(e){return fx(),Fi((Tze(),drt),e)}function MTt(e){return wU(),Fi((cGe(),prt),e)}function TTt(e){return EU(),Fi((aGe(),grt),e)}function CTt(e){return M_(),Fi((lGe(),brt),e)}function ATt(e){return d7(),Fi((Gje(),wrt),e)}function PTt(e){return g6(),Fi((jje(),vrt),e)}function LTt(e){return IS(),Fi(($je(),_rt),e)}function kTt(e){return xo(),Fi((wVe(),yrt),e)}function RTt(e){return bS(),Fi((gGe(),xrt),e)}function ITt(e){return Hd(),Fi((mGe(),Srt),e)}function DTt(e){return Q9(),Fi((Cze(),Mrt),e)}function BTt(e){return du(),Fi((gje(),Crt),e)}function OTt(e){return u7(),Fi((Wje(),not),e)}function NTt(e){return _w(),Fi((HGe(),iot),e)}function FTt(e){return XA(),Fi((dje(),rot),e)}function UTt(e){return G_(),Fi((B$e(),sot),e)}function zTt(e){return Oo(),Fi((uGe(),aot),e)}function GTt(e){return WU(),Fi((fGe(),cot),e)}function jTt(e){return yU(),Fi((hGe(),lot),e)}function $Tt(e){return wx(),Fi((pGe(),uot),e)}function VTt(e){return LU(),Fi((dGe(),fot),e)}function Cme(e,t){for(;e.b.sd(new Hpe(e,t)););}function d9(e,t,i){this.b=e,this.a=t,this.c=i}function Ame(e,t,i){this.a=e,this.b=t,this.c=i}function H8e(e,t,i){this.a=e,this.b=t,this.c=i}function p9(e,t,i){this.e=t,this.b=e,this.d=i}function IJ(e){var t;return t=new DT,t.e=e,t}function WTt(e){return!e.e&&(e.e=new ke),e.e}function Vu(){Vu=M,ort=new WH,art=new kk}function DJ(){DJ=M,P3e=new qi,qnt=new Me}function lI(){lI=M,nG=new ic,iG=new EH}function HTt(e){return wA(),Fi((Oze(),kot),e)}function qTt(e){return R0(),Fi((vGe(),Cot),e)}function XTt(e){return PS(),Fi((ZGe(),Mat),e)}function YTt(e){return nP(),Fi((Fje(),Cat),e)}function ZTt(e){return Eh(),Fi((Pze(),Fot),e)}function KTt(e){return Kf(),Fi((Aze(),zot),e)}function JTt(e){return RI(),Fi((Lze(),jot),e)}function QTt(e){return ll(),Fi((qOe(),mat),e)}function eCt(e){return KI(),Fi((yGe(),Hat),e)}function tCt(e){return lU(),Fi((Bze(),Wat),e)}function nCt(e){return M0(),Fi((kze(),Sat),e)}function iCt(e){return W9(),Fi((Ize(),Oat),e)}function rCt(e){return q9(),Fi((Dze(),Nat),e)}function sCt(e){return vU(),Fi((Rze(),jat),e)}function oCt(e){return VU(),Fi((_Ge(),Vat),e)}function aCt(e){return i7(),Fi((KGe(),nct),e)}function cCt(e){return SU(),Fi((xGe(),ict),e)}function lCt(e){return i1(),Fi((wje(),sct),e)}function uCt(e){return o1(),Fi((O$e(),act),e)}function fCt(e){return ud(),Fi((Uje(),cct),e)}function hCt(e){return Qf(),Fi((EGe(),Oct),e)}function dCt(e){return Fe(),Fi((sje(),Nct),e)}function pCt(e){return Ms(),Fi((Lje(),Bct),e)}function gCt(e){return e1(),Fi((MGe(),Rct),e)}function mCt(e){return a1(),Fi((Y$e(),Ict),e)}function bCt(e){return Xg(),Fi((bje(),Dct),e)}function wCt(e){return qs(),Fi((vje(),Cct),e)}function vCt(e){return Yd(),Fi((JGe(),Act),e)}function _Ct(e){return ld(),Fi((QGe(),Pct),e)}function yCt(e){return f7(),Fi((zje(),Lct),e)}function xCt(e){return Hl(),Fi((eje(),jct),e)}function ECt(e){return cc(),Fi((X$e(),$ct),e)}function SCt(e){return XU(),Fi((nje(),Vct),e)}function MCt(e){return xl(),Fi((ije(),qct),e)}function TCt(e){return xf(),Fi((SGe(),Yct),e)}function CCt(e){return rl(),Fi((TGe(),Kct),e)}function ACt(e){return Nc(),Fi((CGe(),Qct),e)}function PCt(e){return U7(),Fi((CNe(),xlt),e)}function LCt(e){return D0(),Fi((tje(),Slt),e)}function kCt(e){return BS(),Fi((N$e(),Olt),e)}function BJ(e,t,i){return e=t)throw Y(new o8)}function rAt(e,t){var i;for(i=0;i0?1:0}function Xme(e){return!Array.isArray(e)&&e.sl===T}function P9e(e){return e!=null&&XJ(e)&&e.sl!==T}function Yme(e,t){return re(t,23)&&Rp(e,h(t,23))}function L9e(e,t){return re(t,23)&&sRt(e,h(t,23))}function cAt(e,t){return e.a.get(t)!==void 0}function Zme(e){return al(e,26)*bP+al(e,27)*wP}function k9e(e,t){return gRt(new En,new yY(e),t)}function Kme(e,t){if(e==null)throw Y(new EC(t))}function ix(e,t,i){return yl(e.a,t),c1e(e,t.g,i)}function A9(e,t,i){RVe(0,t,e.length),DI(e,0,t,i)}function _0(e,t,i){g_(t,e.c.length),UR(e.c,t,i)}function lAt(e,t,i){sYe(i,e,1),De(t,new AOe(i,e))}function uAt(e,t,i){ZA(i,e,1),De(t,new MOe(i,e))}function Jme(){this.d=new mi,this.e=new WUe(this)}function R9e(){this.b=new tn,this.c=new VUe(this)}function I9e(){u7e(),this.e=new Ir,this.d=new Ir}function jJ(e,t){this.b=new Ir,this.a=e,this.c=t}function l_(e,t,i){Kg(),this.e=e,this.d=t,this.a=i}function P9(e,t,i){var a;e&&(a=e.i,a.d=t,a.a=i)}function L9(e,t,i){var a;e&&(a=e.i,a.c=t,a.b=i)}function D9e(e,t,i){var a;for(a=0;a0?w.Math.log(e/t):-100}function TAt(e,t){return to(e.c.c+e.c.b,t.c.c+t.c.b)}function KJ(e,t){this.d=e,Bn.call(this,e),this.e=t}function fw(e,t,i){return EIt(e,t.g,i),yl(e.c,t),e}function CAt(e){return W_(e,(qs(),rf)),e.d=!0,e}function Hn(e){if(e==null)throw Y(new F2);return e}function rx(e){if(e==null)throw Y(new F2);this.a=e}function JJ(e){e.a=null,e.e=null,nl(e.b),e.d=0,++e.c}function QJ(e){return!e.j&&Gde(e,YUt(e.g,e.b)),e.j}function AAt(e){return e.b.k.a+=e.a.f*(e.a.a-1),null}function cA(e){s_(e.b!=-1),L0(e.c,e.a=e.b),e.b=-1}function q9e(e){XNe(this),nK(this.a,gbe(8>e?8:e)<<1)}function h1e(e,t){Rc.call(this,1),this.a=e,this.b=t}function eQ(e,t,i){this.a=e,IQ(i,t),this.c=t,this.b=i}function X9e(e,t){this.a=e,this.b=t,this.c=this.b.lc()}function gI(e,t){uFe(e,re(t,184)?t:h(t,1630).rk())}function Y9e(e){return Hn(e),re(e,476)?h(e,476):Ga(e)}function d1e(e,t){return t?wo(e,t):!1}function JE(e,t){return e.a+=String.fromCharCode(t),e}function Lg(e,t){return e.a+=String.fromCharCode(t),e}function PAt(e,t,i,a){return e.a+=""+t.substr(i,a-i),e}function LAt(e,t,i){var a;return a=mx(e,t),Nze(e,t,i),a}function kAt(e,t,i){var a;for(a=0;a=e.g}function HAt(e,t){return lx(),e==s1(t)?z0(t):s1(t)}function dr(e,t,i){return ws(t)?Ko(e,t,i):El(e.d,t,i)}function rQ(e,t,i){var a;return a=hee(e,t,i),r_e(e,a)}function uA(e,t){var i;return i=e.a._b(),OLt(t,i),i-1-t}function w1e(e,t){var i;return i=new EI(e),qbe(i,t),i}function Gr(e,t,i){return $St(i==null||L7t(e,i)),e[t]=i}function ox(e,t){var i;i=e.a.length,mx(e,i),Nze(e,i,t)}function iUe(e,t){var i;++e.j,i=e.hi(),e.Wh(e.Ch(i,t))}function qAt(e,t){ox(e,new rx(t.f!=null?t.f:""+t.g))}function XAt(e,t){ox(e,new rx(t.f!=null?t.f:""+t.g))}function rUe(e){this.b=new ke,this.a=new ke,this.c=e}function lu(e){this.c=new fo,this.a=new ke,this.b=e}function sUe(e){ume.call(this),this.a=new fo,this.c=e}function v1e(e,t,i){vC.call(this,t),this.a=e,this.b=i}function _1e(e,t,i){Rc.call(this,e),this.a=t,this.b=i}function y1e(e,t,i){this.a=e,e8.call(this,t),this.b=i}function oUe(e,t,i){this.a=e,e0e.call(this,8,t,null,i)}function aUe(e){this.c=e,this.a=new Ir,this.b=new Ir}function cUe(e){this.c=e,this.b=this.c.a,this.a=this.c.e}function YAt(e){this.a=(dn(Kn),Kn),this.b=e,new fpe}function x0(e){return!e.d&&(e.d=new vs(ko,e,1)),e.d}function lUe(e,t){var i;return i=e.b.$b(t),e.d.b.$b(i),i}function x1e(e,t){for(;t-- >0;)e=e<<1|(e<0?1:0);return e}function Dp(e,t){return Be(e)===Be(t)||e!=null&&ki(e,t)}function E0(e,t){return oA(t,e.a.c.length),St(e.a,t)}function sQ(e){return w.Math.sqrt(e.a*e.a+e.b*e.b)}function ZAt(e){return String.fromCharCode.apply(null,e)}function Bp(e){return re(e,13)?h(e,13)._b():vA(e.tc())}function uUe(e){return re(e,543)?e:new uOe(e)}function va(e){return!e.a&&e.c?e.c.b:e.a}function oQ(e){e.c?oQ(e.c):(e.d=!0,v9t(e))}function f_(e){e.c?f_(e.c):(MS(e),e.d=!0)}function fUe(e){bI(e.a),e.b=le(on,et,1,e.b.length,5,1)}function aQ(e){this.c=e,this.b=e.a.b.a,Oge(e.a.c,this)}function KAt(e,t){e.c<0||e.b.b0?new xme(e-1,t):new xme(e,t)}function wUe(e,t){return m9(),new dwe(new MFe(e),new SFe(t))}function nS(e){if(ol(e.d),e.d.d!=e.c)throw Y(new P)}function oPt(e,t){var i;return i=e.a.get(t),i??[]}function aPt(e,t){var i;return i=Ii(e.f,t),lbe(t,i),null}function fi(e,t,i,a){return Q$e(e,t,i,!1),Fbe(e,a),e}function cPt(e,t){return e.a=qf(e.a,0,t)+""+cI(e.a,t+1),e}function lPt(e){return e.j.c=le(on,et,1,0,5,1),e.a=-1,e}function uPt(e){return!e.c&&(e.c=new an(pi,e,5,8)),e.c}function fPt(e){return!e.b&&(e.b=new an(pi,e,4,7)),e.b}function uQ(e){return!e.n&&(e.n=new ze(ea,e,1,7)),e.n}function C1e(e){return!e.c&&(e.c=new ze(Pu,e,9,9)),e.c}function iS(e){return e.e==iM&&Ude(e,T5t(e.g,e.b)),e.e}function mI(e){return e.f==iM&&zde(e,eBt(e.g,e.b)),e.f}function vUe(e){return KC(e==null||XJ(e)&&e.sl!==T),e}function A1e(e,t){if(e==null)throw Y(new EC(t));return e}function hw(e){var t;return t=e.b,!t&&(e.b=t=new uY(e)),t}function P1e(e){var t;return t=e.Gh(e.f),$n(e,t),t.hc()}function bI(e){var t;for(t=e.tc();t.hc();)t.ic(),t.jc()}function _Ue(e){return Rn(e.ba&&++a,a}function $d(e){var t,i;return i=(t=new xg,t),MA(i,e),i}function dQ(e){var t,i;return i=(t=new xg,t),kqe(i,e),i}function mPt(e){if(e.p!=5)throw Y(new qa);return nr(e.f)}function bPt(e){if(e.p!=5)throw Y(new qa);return nr(e.k)}function LUe(e){return e?e.Wb():!null.tc().hc()}function z9(e){return e.n&&(e.e!==kJe&&e.Pd(),e.j=null),e}function wPt(e){return e!=null&&RC(Bj,e.toLowerCase())}function pQ(e){this.f=e,this.c=this.f.e,e.f>0&&eqe(this)}function Vm(e,t,i,a){this.e=e,this.a=t,this.c=i,this.d=a}function kUe(e,t,i,a){Ol(),nGe.call(this,t,i,a),this.a=e}function RUe(e,t,i,a){Ol(),nGe.call(this,t,i,a),this.a=e}function IUe(e,t,i,a){this.b=e,this.c=a,j8.call(this,t,i)}function DUe(e,t){this.a=e,PMt.call(this,e,h(e.d,15).fd(t))}function rd(e){e.a.a=e.c,e.c.b=e.a,e.a.b=e.c.a=null,e.b=0}function k1e(e,t){return e.b=t.b,e.c=t.c,e.d=t.d,e.a=t.a,e}function vPt(e,t,i){e.i=0,e.e=0,t!=i&&EVe(e,t,i)}function _Pt(e,t,i){e.i=0,e.e=0,t!=i&&SVe(e,t,i)}function BUe(e,t){var i;return i=qQ(t),h(Ii(e.c,i),21).a}function yPt(e,t,i){return i>=0&&dt(e.substr(i,t.length),t)}function gQ(e,t){return t==null?!!gc(e.d,null):cAt(e.e,t)}function OUe(e,t){e.d&&!e.d.a&&(tK(e.d,t),OUe(e.d,t))}function NUe(e,t){e.e&&!e.e.a&&(tK(e.e,t),NUe(e.e,t))}function FUe(e,t){this.g=e,this.d=X(q(Eu,1),Cf,8,0,[t])}function R1e(e,t){new Ir,this.a=new zc,this.b=e,this.c=t}function UUe(){ove(this,new hF),this.wb=(kg(),Ct),IE()}function zUe(e,t){return re(t,166)&&dt(e.b,h(t,166).Lf())}function xPt(e,t){return sl(e),sl(t),$De(h(e,23),h(t,23))}function I1e(e,t,i,a,l,f){VGe.call(this,e,t,i,a,l,f?-2:-1)}function GUe(e,t,i,a){pge.call(this,t,i),this.b=e,this.a=a}function jUe(e,t){J3t.call(this,new WJ(e)),this.a=e,this.b=t}function D1e(e){this.b=e,this.c=e,e.e=null,e.c=null,this.a=1}function $Ue(e,t){var i;return i=Um(e.ql),t==null?i:i+": "+t}function Kr(e,t){return zg(pAt($o(e)?fu(e):e,$o(t)?fu(t):t))}function Zf(e,t){return zg(gAt($o(e)?fu(e):e,$o(t)?fu(t):t))}function EPt(e,t){return zg(mAt($o(e)?fu(e):e,$o(t)?fu(t):t))}function B1e(e){return e&&e.hashCode?e.hashCode():m0(e)}function rS(e){return _t(),re(e,49)?new bK(e):new K8(e)}function _t(){_t=M,uo=new tt,ep=new Tt,$z=new jt}function sS(){sS=M,C3e=new en,jnt=new en,A3e=new mn}function O1e(){O1e=M,Knt=new vn,Qnt=new Jme,Jnt=new Mn}function oS(){oS=M;var e,t;t=!l5t(),e=new H,Zre=t?new O:e}function VUe(e){this.c=e,this.b=new iw(h(Hn(new Kt),65))}function WUe(e){this.c=e,this.b=new iw(h(Hn(new xi),65))}function Op(){this.a=new zc,this.b=(Ef(3,Dx),new Gl(3))}function mQ(e,t,i){this.a=e,this.e=!1,this.d=t,this.c=i}function HUe(e,t,i){return e.f?e.f.re(t,i):!1}function ye(e){return!e.s&&(e.s=new ze(Sc,e,21,17)),e.s}function Ni(e){return!e.q&&(e.q=new ze(uf,e,11,10)),e.q}function N1e(e){return!e.a&&(e.a=new ze(Br,e,10,11)),e.a}function SPt(e,t){var i;return i=Lge(e.a,t),i&&(t.d=null),i}function h_(e,t,i,a){Gr(e.c[t.g],i.g,a),Gr(e.c[i.g],t.g,a)}function G9(e,t,i,a){Gr(e.c[t.g],t.g,i),Gr(e.b[t.g],t.g,a)}function ax(e,t,i){tU(),e&&dr(Lae,e,t),e&&dr(bD,e,i)}function MPt(e,t){dFe(e,nr(Kr(Pg(t,24),H7)),nr(Kr(t,H7)))}function sc(e){var t;return t=h(sn(e,16),24),t||e.Rg()}function TPt(e){if(e.p!=0)throw Y(new qa);return kC(e.f,0)}function CPt(e){if(e.p!=0)throw Y(new qa);return kC(e.k,0)}function Bo(e){return e.u||(uu(e),e.u=new r8e(e,e)),e.u}function APt(e){return e==ip||e==Zp}function PPt(e){h8(),w.setTimeout(function(){throw e},0)}function bQ(e){this.c=e.c,this.d=e.d,this.b=e.b,this.a=e.a}function Np(e,t){this.e=e,this.a=on,this.b=_Ze(t),this.c=t}function qUe(){this.b=new zr,this.c=new Ir,this.d=new sK}function Eh(){Eh=M,sb=new ige(YS,0),Yp=new ige(XS,1)}function M0(){M0=M,um=new cge(XS,0),xy=new cge(YS,1)}function XUe(){XUe=M,lw(),t3e=(jo(),Pnt),Mnt=new M1e(new iw(t3e))}function LPt(e){return XUe(),Hn(e),t3e==e?Mnt:new M1e(new iw(e))}function Wm(e,t,i,a,l,f,g){return new kQ(e.e,t,i,a,l,f,g)}function YUe(e,t,i,a,l,f){this.a=e,lee.call(this,t,i,a,l,f)}function ZUe(e,t,i,a,l,f){this.a=e,lee.call(this,t,i,a,l,f)}function F1e(e){this.e=e,this.b=this.e.a.entries(),this.a=[]}function U1e(e){e.d=e.d-15,e.b=e.b-15,e.c=e.c+15,e.a=e.a+15}function KUe(e,t){var i;i=h(L0e(e.e,t),249),i&&(e.d=!0)}function za(e,t){return t==null?Dc(gc(e.d,null)):NC(e.e,t)}function gc(e,t){return TVe(e,t,oPt(e,t==null?0:e.b.he(t)))}function JUe(e,t){return t===e?"(this Map)":t==null?Xc:Ga(t)}function kPt(e,t){return e.a?t.pg().tc():h(t.pg(),64).oh()}function vI(e,t,i){return e.a=qf(e.a,0,t)+(""+i)+cI(e.a,t),e}function Hm(e,t){if(t==null)throw Y(new F2);return w5t(e,t)}function RPt(){return KU(),X(q(G3e,1),Oe,391,0,[rse,z3e])}function IPt(){return dU(),X(q($3e,1),Oe,390,0,[j3e,sse])}function DPt(){return gU(),X(q(dEe,1),Oe,387,0,[hse,Kz])}function BPt(){return sU(),X(q(xSe,1),Oe,386,0,[ySe,Gse])}function OPt(){return fx(),X(q(MSe,1),Oe,317,0,[M5,S5])}function NPt(){return Q9(),X(q(VSe,1),Oe,383,0,[noe,$Se])}function FPt(){return q9(),X(q(HTe,1),Oe,388,0,[$oe,WTe])}function UPt(){return W9(),X(q(VTe,1),Oe,438,0,[joe,$Te])}function zPt(){return vU(),X(q(qTe,1),Oe,447,0,[sj,vM])}function GPt(){return RI(),X(q(kTe,1),Oe,437,0,[LTe,ZG])}function jPt(){return Eh(),X(q(Not,1),Oe,466,0,[sb,Yp])}function $Pt(){return Kf(),X(q(Uot,1),Oe,465,0,[M1,sh])}function VPt(){return M0(),X(q(Eat,1),Oe,417,0,[um,xy])}function WPt(){return wA(),X(q(Lot,1),Oe,472,0,[fL,uL])}function HPt(){return lU(),X(q(YTe,1),Oe,389,0,[XTe,qoe])}function j9(e,t,i,a){return i>=0?e.Dg(t,i,a):e.lg(null,i,a)}function qPt(e,t){var i;i=h(rn(t,(eA(),wL)),35),sKe(e,i)}function wQ(e){var t;return t=cu(e.b),wo(t,e.c),wo(t,e.i),t}function z1e(e){return Be(e.a)===Be((bee(),Iae))&&lGt(e),e.a}function QUe(e){return e.b.b==0?e.a.Be():FJ(e.b)}function G1e(e){var t;return t=e.g,h(t||(e.g=new gF(e)),15)}function Kf(){Kf=M,M1=new rge(ore,0),sh=new rge("UP",1)}function vQ(e,t){Pde(this,new $t(e.a,e.b)),Lde(this,cu(t))}function e7e(e,t){a9.call(this),j0e(this),this.a=e,this.c=t}function j1e(e,t,i){Ol(),vC.call(this,t),this.a=e,this.b=i}function _Q(e,t,i){vi(),Rc.call(this,e),this.b=t,this.a=i}function XPt(e,t){var i=Yre[e.charCodeAt(0)];return i??e}function YPt(e,t){var i;return i=Kkt(e.f,t),tr(wJ(i),e.f.d)}function t7e(e){var t;t=e.c.b.b,e.b=t,e.a=e.c.b,t.a=e.c.b.b=e}function ZPt(e){return e.b==0?null:(Rn(e.b!=0),Xu(e,e.a.a))}function KPt(e){return no(jd(Wc(al(e,32)),32),Wc(al(e,32)))}function n7e(e){return re(e,62)&&(h(h(e,17),62).Bb&Ja)!=0}function yr(e){return Math.max(Math.min(e,zi),-2147483648)|0}function $9(e,t){return n0e(t),Ekt(e,le(In,si,22,t,15,1),t)}function JPt(e,t){return lx(),e==eo(s1(t))||e==eo(z0(t))}function i7e(e){var t;return t=rU(e),"n_"+(t??""+e.o)}function r7e(e){this.b=(Mo(),Mo(),Mo(),Tnt),this.a=h(Hn(e),43)}function s7e(e){a9.call(this),j0e(this),this.a=e,this.c=!0}function o7e(e,t,i){this.d=e,this.b=new ke,this.c=t,this.a=i}function yQ(e,t,i,a){var l;l=new w8e,t.a[i.g]=l,ix(e.b,a,l)}function a7e(e,t){var i=e.a=e.a||[];return i[t]||(i[t]=e._d(t))}function _I(e,t){var i;i=e.q.getHours(),e.q.setDate(t),fP(e,i)}function c7e(e){var t;return t=new m8(Eee(e.length)),qI(t,e),t}function QPt(e){function t(){}return t.prototype=e||{},new t}function eLt(e,t){return nVe(e,t)?(e$e(e),!0):!1}function V9(e){return e.Db>>16!=3?null:h(e.Cb,35)}function Sh(e){return e.Db>>16!=9?null:h(e.Cb,35)}function tLt(e){if(e.p!=2)throw Y(new qa);return nr(e.f)&jr}function nLt(e){if(e.p!=2)throw Y(new qa);return nr(e.k)&jr}function W9(){W9=M,joe=new lge(HQe,0),$Te=new lge("FAN",1)}function xQ(e,t,i){var a;a=xVe(e,t,i),e.b=new dee(a.c.length)}function Ko(e,t,i){return t==null?El(e.d,null,i):B0(e.e,t,i)}function $1e(e,t){return n1(no(n1(h(e,149).a).a,h(t,149).a))}function l7e(){l7e=M,PTe=wUe(He(1),He(4)),ATe=wUe(He(1),He(2))}function u7e(){u7e=M,dot=jc(new ss,(_o(),qo),(Ao(),hG))}function f7e(){f7e=M,hot=jc(new ss,(_o(),qo),(Ao(),hG))}function h7e(){h7e=M,Rot=Ai(new ss,(_o(),qo),(Ao(),XP))}function vl(){vl=M,Bot=Ai(new ss,(_o(),qo),(Ao(),XP))}function d7e(){d7e=M,Oot=Ai(new ss,(_o(),qo),(Ao(),XP))}function EQ(){EQ=M,Got=Ai(new ss,(_o(),qo),(Ao(),XP))}function p7e(){p7e=M,Fat=jc(new ss,(PS(),pL),(nP(),Ioe))}function g7e(e){return e.Db>>16!=6?null:h(e.Cb,105)}function m7e(e){return e.Db>>16!=7?null:h(e.Cb,207)}function b7e(e){return e.Db>>16!=7?null:h(e.Cb,253)}function eo(e){return e.Db>>16!=11?null:h(e.Cb,35)}function dw(e){return e.Db>>16!=17?null:h(e.Cb,24)}function w7e(e){return e.Db>>16!=3?null:h(e.Cb,139)}function aS(e){return e.Db>>16!=6?null:h(e.Cb,207)}function dA(e,t,i,a,l,f){return new Wd(e.e,t,e.pi(),i,a,l,f)}function V1e(e,t){return L9e(e.a,t)?c1e(e,h(t,23).g,null):null}function iLt(e,t){return A9e(Wc(e.q.getTime()),Wc(t.q.getTime()))}function rLt(e,t){var i;i=e.q.getHours(),e.q.setMonth(t),fP(e,i)}function Os(e,t){e.c&&Sa(e.c.f,e),e.c=t,e.c&&De(e.c.f,e)}function Hs(e,t){e.c&&Sa(e.c.a,e),e.c=t,e.c&&De(e.c.a,e)}function _s(e,t){e.d&&Sa(e.d.d,e),e.d=t,e.d&&De(e.d.d,e)}function us(e,t){e.g&&Sa(e.g.i,e),e.g=t,e.g&&De(e.g.i,e)}function v7e(e,t){return e.b+=t.b,e.c+=t.c,e.d+=t.d,e.a+=t.a,e}function W1e(e){return Y8(e.c),e.e=e.a=e.c,e.c=e.c.c,++e.d,e.a.f}function _7e(e){return Y8(e.e),e.c=e.a=e.e,e.e=e.e.e,--e.d,e.a.f}function y7e(e,t){var i;return i=new lu(e),t.c[t.c.length]=i,i}function sLt(e,t){var i,a;i=t.c,a=i!=null,a&&ox(e,new rx(t.c))}function oLt(e){var t;t=q6t(h(rn(e,(ww(),Yoe)),349)),t.Ef(e)}function SQ(e,t){re(e.Cb,96)&&sP(uu(h(e.Cb,96)),4),Sf(e,t)}function H9(e,t){re(e.Cb,248)&&(h(e.Cb,248).tb=null),Sf(e,t)}function aLt(e,t){uWe(e,t),re(e.Cb,96)&&sP(uu(h(e.Cb,96)),2)}function cLt(e,t){q8(this),this.f=t,this.g=e,z9(this),this.Pd()}function cx(e){this.c=new Ir,this.b=e.b,this.d=e.c,this.a=e.a}function x7e(){this.a=new Gc,this.e=new zr,this.g=0,this.i=0}function Rg(e,t,i){HVe(t,i,e._b()),this.c=e,this.a=t,this.b=i-t}function Ns(e,t){this.a=e,ME.call(this,e),g_(t,e._b()),this.b=t}function E7e(e){this.a=e,this.b=le(Aot,be,1637,e.e.length,0,2)}function d_(e){this.a=w.Math.cos(e),this.b=w.Math.sin(e)}function di(e,t){this.b=(dn(e),e),this.a=t&H0?t:t|64|Ah}function S7e(e,t,i){var a;HVe(t,i,e.c.length),a=i-t,Dpe(e.c,t,a)}function M7e(e,t){var i;return i=h(AS(y0(e.a),t),13),i?i._b():0}function T7e(e){var t,i;return i=(IE(),t=new xg,t),MA(i,e),i}function C7e(e){var t,i;return i=(IE(),t=new xg,t),MA(i,e),i}function p_(e){return PC(),re(e.g,8)?h(e.g,8):null}function lLt(e,t){var i;i=h(Ii(e.g,t),57),cd(t.d,new kOe(e,i))}function $c(e,t){return Yo(),O0e(t)?new y9(t,e):new qR(t,e)}function Wu(e){return Fo(X(q(es,1),be,9,0,[e.g.k,e.k,e.a]))}function uLt(){return NA(),X(q(trt,1),Oe,412,0,[Tse,Cse,Mse])}function fLt(){return Wg(),X(q(nh,1),Oe,150,0,[N3e,th,Bw])}function hLt(){return Hd(),X(q(Ert,1),Oe,280,0,[A5,gy,Kx])}function dLt(){return bS(),X(q(jSe,1),Oe,318,0,[eoe,toe,EG])}function pLt(){return wU(),X(q(CSe,1),Oe,319,0,[TSe,bG,$se])}function gLt(){return EU(),X(q(PSe,1),Oe,384,0,[Vse,ASe,Wse])}function mLt(){return M_(),X(q(mrt,1),Oe,406,0,[Hse,T5,YP])}function bLt(){return Oo(),X(q(oot,1),Oe,410,0,[WG,Fc,lc])}function wLt(){return WU(),X(q(xTe,1),Oe,345,0,[_Te,Aoe,yTe])}function vLt(){return yU(),X(q(MTe,1),Oe,347,0,[STe,Poe,ETe])}function _Lt(){return LU(),X(q(CTe,1),Oe,346,0,[Loe,koe,H5])}function yLt(){return wx(),X(q(TTe,1),Oe,385,0,[W5,$5,V5])}function xLt(){return xA(),X(q(MEe,1),Oe,348,0,[mse,gse,bse])}function ELt(){return KI(),X(q(JTe,1),Oe,349,0,[oj,ZTe,KTe])}function SLt(){return VU(),X(q($at,1),Oe,401,0,[Hoe,Voe,Woe])}function MLt(){return R0(),X(q(Tot,1),Oe,413,0,[HG,lL,qG])}function TLt(){return rl(),X(q(Zct,1),Oe,419,0,[Uh,mb,cf])}function CLt(){return Nc(),X(q(Jct,1),Oe,420,0,[If,bb,lf])}function ALt(){return Qf(),X(q(pAe,1),Oe,275,0,[Ty,db,_j])}function PLt(){return SU(),X(q(fCe,1),Oe,277,0,[Koe,uCe,lCe])}function LLt(){return xf(),X(q(Jw,1),Oe,203,0,[aa,Wa,ca])}function kLt(){return e1(),X(q(uAe,1),Oe,316,0,[vj,d3,ML])}function A7e(){A7e=M,Ant=Ui((i_(),X(q(Xre,1),Oe,350,0,[d5,p5])))}function q9(){q9=M,$oe=new uge("DFS",0),WTe=new uge("BFS",1)}function lx(){lx=M,Zz=new ke,fse=(Yr(),new ui),use=new ke}function P7e(e,t,i){var a;a=new uq,a.b=t,a.a=i,++t.b,De(e.d,a)}function L7e(e,t,i){Rc.call(this,25),this.b=e,this.a=t,this.c=i}function _l(e){vi(),Rc.call(this,e),this.c=!1,this.a=!1}function RLt(e){return e.a==(fS(),Uj)&&Nde(e,w9t(e.g,e.b)),e.a}function pA(e){return e.d==(fS(),Uj)&&Fde(e,S7t(e.g,e.b)),e.d}function ILt(e,t){var i;return i=(dn(e),e).g,kge(!!i),dn(t),i(t)}function MQ(e,t){var i,a;return a=KE(e,t),i=e.a.fd(a),new KBe(e,i)}function cS(e){var t;return $o(e)?(t=e,t==-0?0:t):Wkt(e)}function DLt(e){return e.Db>>16!=6?null:h(Xte(e),207)}function $(e){return Rn(e.a=t)throw Y(new Ra(GNt(e,t)));return e}function k7e(e,t,i){if(e<0||ti)throw Y(new Ra(wNt(e,t,i)))}function NLt(e){return Mo(),Lg(zbe((ru(),Qxe),Lg(new h0,91),e),93).a}function X9(e){return Hn(e),Ete((Mo(),new Nd(Kh(Gd(e.a,new z)))))}function Y9(e){return new Gl((Ef(e,zne),NI(no(no(5,e),e/10|0))))}function H1e(e,t){return e&&e.equals?e.equals(t):Be(e)===Be(t)}function q1e(e,t){return t==0?!!e.o&&e.o.f!=0:fte(e,t)}function FLt(e,t){var i;i=ce(Xe(e.a.xe((ur(),bj)))),sJe(e,t,i)}function R7e(e,t,i){var a;a=br(e.d,t),a>=0?b7(e,a,i):Uve(e,t,i)}function CQ(e,t,i){var a;a=e.d[t.o],e.d[t.o]=e.d[i.o],e.d[i.o]=a}function I7e(e,t){var i;for(i=e+"";i.length0&&e.a[--e.d]==0;);e.a[e.d++]==0&&(e.e=0)}function ULt(e){return!!e.u&&Ea(e.u.a).i!=0&&!(e.n&&bte(e.n))}function K9(e){lA(),this.a=(_t(),re(e,49)?new bK(e):new K8(e))}function D7e(){this.c=new rFe,this.a=new b8e,this.b=new ENe,MBe()}function B7e(e,t,i){this.d=e,this.j=t,this.e=i,this.o=-1,this.p=3}function O7e(e,t,i){this.d=e,this.k=t,this.f=i,this.o=-1,this.p=5}function N7e(e,t,i,a,l,f){V0e.call(this,e,t,i,a,l),f&&(this.o=-2)}function F7e(e,t,i,a,l,f){W0e.call(this,e,t,i,a,l),f&&(this.o=-2)}function U7e(e,t,i,a,l,f){d0e.call(this,e,t,i,a,l),f&&(this.o=-2)}function z7e(e,t,i,a,l,f){X0e.call(this,e,t,i,a,l),f&&(this.o=-2)}function G7e(e,t,i,a,l,f){p0e.call(this,e,t,i,a,l),f&&(this.o=-2)}function j7e(e,t,i,a,l,f){H0e.call(this,e,t,i,a,l),f&&(this.o=-2)}function $7e(e,t,i,a,l,f){q0e.call(this,e,t,i,a,l),f&&(this.o=-2)}function V7e(e,t,i,a,l,f){g0e.call(this,e,t,i,a,l),f&&(this.o=-2)}function W7e(e,t,i,a){vC.call(this,i),this.b=e,this.c=t,this.d=a}function H7e(e,t){this.f=e,this.a=(fS(),Fj),this.c=Fj,this.b=t}function q7e(e,t){this.g=e,this.d=(fS(),Uj),this.a=Uj,this.b=t}function X7e(e,t){!e.c&&(e.c=new ps(e,0)),Sne(e.c,(lr(),ED),t)}function ia(e,t,i,a,l,f){return Q$e(e,t,i,f),eWe(e,a),tWe(e,l),e}function Y7e(e,t){return re(t,38)?xte(e.a,h(t,38)):!1}function zLt(e){if(!("stack"in e))try{throw e}catch{}return e}function GLt(e){if(e.p!=1)throw Y(new qa);return nr(e.f)<<24>>24}function jLt(e){if(e.p!=1)throw Y(new qa);return nr(e.k)<<24>>24}function $Lt(e){if(e.p!=7)throw Y(new qa);return nr(e.k)<<16>>16}function VLt(e){if(e.p!=7)throw Y(new qa);return nr(e.f)<<16>>16}function J9(e){Ywe(),dFe(this,nr(Kr(Pg(e,24),H7)),nr(Kr(e,H7)))}function Z7e(){Z7e=M,ait=Ui((b8(),X(q(oEe,1),Oe,439,0,[ase])))}function Q9(){Q9=M,noe=new tge(MP,0),$Se=new tge("TOP_LEFT",1)}function K7e(e,t){var i;e.e=new spe,i=Sw(t),fa(i,e.c),eZe(e,i,0)}function bt(e,t,i,a){var l;l=new fN,l.a=t,l.b=i,l.c=a,Gi(e.b,l)}function mc(e,t,i,a){var l;l=new fN,l.a=t,l.b=i,l.c=a,Gi(e.a,l)}function WLt(e,t,i){var a;return a=h(e.Hc().Vb(t),13),!!a&&a.pc(i)}function J7e(e,t,i){var a;return a=h(e.Hc().Vb(t),13),!!a&&a.vc(i)}function Q7e(e,t){var i;return i=1-t,e.a[i]=_U(e.a[i],i),_U(e,t)}function lS(e){return Rn(e.b.b!=e.d.a),e.c=e.b=e.b.b,--e.a,e.c.c}function eze(e){return _9(e),Y8(e.c),e.e=e.a=e.c,e.c=e.c.b,++e.d,e.a}function tze(e){return _9(e),Y8(e.e),e.c=e.a=e.e,e.e=e.e.d,--e.d,e.a}function Tn(e){if(!Gn(e))throw Y(new K);return e.c=e.b,e.b.ic()}function nze(e,t){return re(t,38)?xte(e.a,h(t,38)):!1}function ize(e,t){return re(t,38)?xte(e.a,h(t,38)):!1}function rze(e){var t;return f_(e),t=new cn,Cme(e.a,new MY(t)),t}function Y1e(){var e,t,i;return t=(i=(e=new xg,e),i),De(YAe,t),t}function HLt(e){var t;return t=(ll(),ll(),nat),e.d&&Gte(e),rEt(),t}function Z1e(e){return e.j.c=le(on,et,1,0,5,1),bI(e.c),lPt(e.a),e}function ss(){mDe.call(this),this.j.c=le(on,et,1,0,5,1),this.a=-1}function sze(e,t,i){this.b=new VF(this),this.c=e,this.f=t,this.d=i}function qLt(e,t,i){e.d&&Sa(e.d.d,e),e.d=t,e.d&&_0(e.d.d,i,e)}function XLt(e){return!!e.a&&Vc(e.a.a).i!=0&&!(e.b&&wte(e.b))}function YLt(e){return vl(),!Jo(e)&&!(!Jo(e)&&e.c.g.c==e.d.g.c)}function ZLt(e){return tU(),v0(Lae,e)?h(Ii(Lae,e),337).Mf():null}function mA(e){return re(e,13)?new hI((ru(),h(e,13))):RCt(e.tc())}function KLt(e,t,i){return i.f.c.length>0?u1e(e.a,t,i):u1e(e.b,t,i)}function oze(e,t,i){var a;return a=jA(i),dr(e.b,a,t),dr(e.c,t,i),t}function T0(e,t){var i,a;return i=Hm(e,t),a=null,i&&(a=i.Vd()),a}function yI(e,t){var i,a;return i=Hm(e,t),a=null,i&&(a=i.Yd()),a}function uS(e,t){var i,a;return i=mx(e,t),a=null,i&&(a=i.Yd()),a}function Vd(e,t){var i,a;return i=Hm(e,t),a=null,i&&(a=Kqe(i)),a}function K1e(e){var t;return t=e.Fh(e.i),e.i>0&&vc(e.g,0,t,0,e.i),t}function xI(e){var t;return t=(Hn(e),new vf((ru(),e))),iP(t),Lee(t)}function Ea(e){return e.n||(uu(e),e.n=new cFe(ko,e),Bo(e)),e.n}function aze(e,t){var i;return i=new tw,e.wd(i),i.a+="..",t.xd(i),i.a}function cze(e,t){_8();var i;return i=h(Ii(Dj,e),47),!i||i.Li(t)}function C0(e){return re(e,13)?h(e,13).Wb():!e.tc().hc()}function JLt(e){if(e.ee())return null;var t=e.n,i=Nz[t];return i}function Un(e){return Rn(e.b!=e.d.c),e.c=e.b,e.b=e.b.a,++e.a,e.c.c}function J1e(e,t){dn(t),Gr(e.a,e.c,t),e.c=e.c+1&e.a.length-1,dHe(e)}function bA(e,t){dn(t),e.b=e.b-1&e.a.length-1,Gr(e.a,e.b,t),dHe(e)}function lze(e){var t;t=e.pg(),this.a=re(t,64)?h(t,64).oh():t.tc()}function QLt(e,t,i){var a;a=c5t();try{return NMt(e,t,i)}finally{G4t(a)}}function Q1e(e,t,i,a){return re(i,49)?new IFe(e,t,i,a):new t1e(e,t,i,a)}function e4t(){return uU(),X(q(Vz,1),Oe,278,0,[nse,D3e,B3e,O3e])}function t4t(){return yS(),X(q($it,1),Oe,373,0,[eb,Nw,Ow,fy])}function n4t(){return Sx(),X(q(iit,1),Oe,304,0,[m5,g5,b5,w5])}function i4t(){return YA(),X(q(sit,1),Oe,362,0,[v5,qz,Xz,_5])}function r4t(e){return ce(mt(G(e,(Ie(),Fw))))&&G(e,Jn)!=null}function s4t(e){return ce(mt(G(e,(Ie(),Fw))))&&G(e,Jn)!=null}function ux(e){return PC(),re(e.g,153)?h(e.g,153):null}function o4t(e,t,i){var a;a=h(Ii(e.g,i),57),De(e.a.c,new Is(t,a))}function uze(e,t,i,a){var l;return l=a[t.g][i.g],ce(Xe(G(e.a,l)))}function fze(e,t,i,a){this.e=a,this.d=null,this.c=e,this.a=t,this.b=i}function e0e(e,t,i,a){this.d=e,this.n=t,this.g=i,this.o=a,this.p=-1}function hze(e,t,i,a,l){this.c=e,this.e=t,this.d=i,this.b=a,this.a=l}function t0e(e,t,i,a,l){this.i=e,this.a=t,this.e=i,this.j=a,this.f=l}function Ig(e,t,i,a,l){Oi.call(this,e,t),this.a=i,this.b=a,this.c=l}function wA(){wA=M,fL=new nge("UPPER",0),uL=new nge("LOWER",1)}function a4t(){return PS(),X(q(ITe,1),Oe,360,0,[JG,dL,q5,pL])}function c4t(){return i7(),X(q(cCe,1),Oe,320,0,[Zoe,oCe,aCe,sCe])}function l4t(){return Yd(),X(q(QCe,1),Oe,226,0,[wj,xL,h3,EL])}function u4t(){return ld(),X(q(mae,1),Oe,197,0,[gae,pae,EM,ub])}function f4t(){return Hl(),X(q(AL,1),Oe,344,0,[lD,C1,cD,gb])}function h4t(){return D0(),X(q(Elt,1),Oe,374,0,[dD,hD,Sae,Mae])}function d4t(){return XU(),X(q(yAe,1),Oe,288,0,[yae,wAe,_Ae,vAe])}function p4t(){return xl(),X(q(Hct,1),Oe,265,0,[fD,Ed,dm,uD])}function g4t(){return _w(),X(q(Moe,1),Oe,179,0,[jG,Soe,_y,vy])}function zl(e,t,i){return t<0?Vte(e,i):h(i,61).aj().fj(e,e.Qg(),t)}function dze(e,t){var i;for(i=e.j.c.length;i=0&&e.a[i]===t[i];i--);return i<0}function s0e(e,t){var i;i=e.q.getHours(),e.q.setFullYear(t+V0),fP(e,i)}function hx(e,t){return t==0||e.e==0?e:t>0?PWe(e,t):OYe(e,-t)}function o0e(e,t){return t==0||e.e==0?e:t>0?OYe(e,t):PWe(e,-t)}function a0e(e){e.b!=e.c&&(e.a=le(on,et,1,8,5,1),e.b=0,e.c=0)}function dx(e){return Rn(e.a0;)a+=e.a[i],i-=i&-i;return a}function zze(e,t){var i;for(i=t;i;)Fl(e,-i.i,-i.j),i=eo(i);return e}function Xm(e,t){return e.a?Mi(e.a,e.b):e.a=new ou(e.d),Z2(e.a,t),e}function Gze(e,t){for(dn(t);e.a||(e.a=a_(e.c,e)),e.a;)t.ie(eU(e))}function RQ(e){return e.c&&e.d?X1e(e.c)+"->"+X1e(e.d):"e_"+m0(e)}function x4t(e,t,i){return h(t==null?El(e.d,null,i):B0(e.e,t,i),261)}function E4t(e,t,i){var a,l;a=Hm(e,i),l=null,a&&(l=Kqe(a)),bFt(t,i,l)}function S4t(e,t){var i;i=new SC,$m(i,"x",t.a),$m(i,"y",t.b),ox(e,i)}function M4t(e,t){var i;i=new SC,$m(i,"x",t.a),$m(i,"y",t.b),ox(e,i)}function T4t(e,t){return E8t(e,t,re(t,62)&&(h(h(t,17),62).Bb&oo)!=0)}function od(e){return Hn(e),re(e,13)?new vf((ru(),h(e,13))):NJ(e.tc())}function C4t(){return Fe(),X(q(Ec,1),Oe,69,0,[Na,bn,Zt,ni,nn])}function A4t(e){return h8(),function(){return QLt(e,this,arguments);var t}}function P4t(){return Date.now?Date.now():new Date().getTime()}function l0e(e){if(!e.c.Cc())throw Y(new K);return e.a=!0,e.c.Ec()}function IQ(e,t){if(e<0||e>t)throw Y(new Ra(uve(e,t,"index")));return e}function u0e(e,t){return re(t,180)?dt(e.c,h(t,180).c):!1}function L4t(e){return e.d=3,e.c=pRt(e),e.d!=2?(e.d=0,!0):!1}function jze(e,t){var i,a;return i=(a=e.slice(0,t),yA(a,e)),i.length=t,i}function Hu(e,t,i){var a;return a=(ai(t,e.c.length),e.c[t]),e.c[t]=i,a}function DQ(e,t,i,a){var l;return l=le(In,si,22,t,15,1),GBt(l,e,t,i,a),l}function $ze(e,t,i,a){this.e=e,this.b=new ke,this.d=t,this.a=i,this.c=a}function P0(e,t){this.b=Ca,this.d=e,this.e=t,this.c=this.d+(""+this.e)}function Vze(){rJ(this),this.b=new $t(Jr,Jr),this.a=new $t(Ts,Ts)}function fS(){fS=M;var e,t;Fj=(IE(),t=new S,t),Uj=(e=new cK,e)}function Wze(){cU(),this.b=(Yr(),new ui),this.a=new ui,this.c=new ke}function nl(e){var t;e.d=new BNe(e),e.e=new ONe(e),t=e[Z_]|0,e[Z_]=t+1}function nU(e,t){return(MS(e),Ebe(new oi(e,new S0e(t,e.a)))).a!=null}function k4t(){return _o(),X(q(TEe,1),Oe,328,0,[Dh,Zx,Qa,ec,qo])}function R4t(){return JA(),X(q(_Se,1),Oe,276,0,[Use,zse,Nse,vSe,Fse])}function I4t(){return du(),X(q(tMe,1),Oe,178,0,[r3,I5,zw,QP,ib])}function D4t(){return XA(),X(q(pTe,1),Oe,292,0,[dTe,Toe,Coe,U5,z5])}function B4t(){return Xg(),X(q(CL,1),Oe,225,0,[fb,wae,fAe,TL,hAe])}function O4t(){return i1(),X(q(Qp,1),Oe,163,0,[Ln,ga,bd,lb,fm])}function N4t(){return qs(),X(q(yL,1),Oe,110,0,[Oh,sf,rf,rp,hm])}function F4t(e,t){var i;return i=t!=null?za(e,t):Dc(gc(e.d,null)),$E(i)}function U4t(e,t){var i;return i=t!=null?za(e,t):Dc(gc(e.d,null)),$E(i)}function f0e(e,t){var i;return i=h(gx(e.d,t),27),i||h(gx(e.e,t),27)}function h0e(e,t){var i;return i=0,e&&(i+=e.f.a/2),t&&(i+=t.f.a/2),i}function uu(e){return e.t||(e.t=new YZ(e),JI(new VDe(e),0,e.t)),e.t}function Hze(e){var t;return e.c||(t=e.r,re(t,96)&&(e.c=h(t,24))),e.c}function qze(e,t){return v0(e.a,t)?(hS(e.a,t),!0):!1}function Jo(e){return!e.c||!e.d?!1:!!e.c.g&&e.c.g==e.d.g}function z4t(e){return Ef(e,"size"),nr(_K(Jm(e,8),Rx)?Jm(e,8):Rx),new tw}function Fp(e,t){return kNe((lA(),new K9(cWe(X(q(on,1),et,1,5,[e,t])))))}function G4t(e){e&&Xkt((vr(),r3e)),--Fz,e&&Uz!=-1&&($Et(Uz),Uz=-1)}function j4t(e,t){var i,a;i=h(x5t(e.c,t),13),i&&(a=i._b(),i.Pb(),e.d-=a)}function vA(e){Mo();var t;for(t=0;e.hc();)e.ic(),t=no(t,1);return NI(t)}function BQ(e){var t,i,a;return t=e&Yc,i=e>>22&Yc,a=e<0?Kd:0,Xa(t,i,a)}function Xze(e,t){var i,a;return i=t.kc(),a=Sbe(e,i),!!a&&tl(a.e,t.lc())}function Yze(e){var t;return t=e.e+e.f,isNaN(t)&&l9(e.d)?e.d:t}function Zze(e){this.b=e,Bn.call(this,e),this.a=h(sn(this.b.a,4),116)}function Kze(e){this.b=e,nx.call(this,e),this.a=h(sn(this.b.a,4),116)}function qu(e,t,i,a,l){iGe.call(this,t,a,l),this.c=e,this.b=i}function d0e(e,t,i,a,l){B7e.call(this,t,a,l),this.c=e,this.a=i}function p0e(e,t,i,a,l){O7e.call(this,t,a,l),this.c=e,this.a=i}function g0e(e,t,i,a,l){iGe.call(this,t,a,l),this.c=e,this.a=i}function Jze(e,t){this.d=new G2,this.a=e,this.b=t,this.e=new Do(t.Qe())}function Up(e,t){Kg(),this.e=e,this.d=1,this.a=X(q(In,1),si,22,15,[t])}function hS(e,t){return ws(t)?t==null?Tve(e.d,null):iVe(e.e,t):Tve(e.d,t)}function m0e(e,t,i){var a;return a=e.rg(t),a>=0?e.ug(a,i,!0):Ax(e,t,i)}function $4t(e,t,i){var a;a=(Hn(e),new vf((ru(),e))),BBt(new _ze(a,t,i))}function SI(e,t,i){var a;a=(Hn(e),new vf((ru(),e))),HDt(new yze(a,t,i))}function V4t(e,t,i){var a;return a=jA(i),eP(e.d,a,t,!1),dr(e.e,t,i),t}function W4t(e,t,i){var a;return a=jA(i),eP(e.j,a,t,!1),dr(e.k,t,i),t}function Qze(e,t,i){var a;a=new Age(e.a),wee(a,e.a.a),El(a.d,t,i),e.a.a=a}function OQ(e){var t;return t=new Op,No(t,e),Ee(t,($e(),Lo),null),t}function Ym(e){var t,i;return Hn(e),t=VAt(e.length),i=new Gl(t),qI(i,e),i}function _A(e){var t,i;++e.j,t=e.g,i=e.i,e.g=null,e.i=0,e.uh(i,t),e.th()}function MI(e,t){e.Eh(e.i+1),JC(e,e.i,e.Ch(e.i,t)),e.sh(e.i++,t),e.th()}function L0(e,t){var i;return i=(ai(t,e.c.length),e.c[t]),Dpe(e.c,t,1),i}function NQ(e,t,i,a){var l;return l=le(In,si,22,t+1,15,1),y7t(l,e,t,i,a),l}function b0e(e,t,i,a){var l;for(l=0;lt.o?-1:0}function g_(e,t){if(e<0||e>t)throw Y(new Ra("Index: "+e+", Size: "+t))}function x0e(e,t,i){if(e<0||t>i||t=t)throw Y(new Ra("Index: "+e+", Size: "+t))}function Z4t(e,t){var i;i=e.q.getHours()+(t/60|0),e.q.setMinutes(t),fP(e,i)}function oU(e,t,i){this.a=e,this.b=t,this.c=i,De(e.q,this),De(t.g,this)}function TI(e,t,i,a){this.f=e,this.e=t,this.d=i,this.b=a,this.c=a?a.d:null}function E0e(e){lVe.call(this,e,0),OFe(this),this.b.b=this.b,this.b.a=this.b}function S0e(e,t){j8.call(this,t.rd(),t.qd()&-65),dn(e),this.a=e,this.c=t}function PGe(e,t,i){this.d=(dn(e),e),this.a=i&H0?i:i|64|Ah,this.c=t}function aU(){this.b=new Ir,this.a=new Ir,this.b=new Ir,this.a=new Ir}function LGe(){LGe=M,pot=jc(Ai(new ss,(_o(),Dh),(Ao(),kse)),qo,hG)}function kGe(){kGe=M,got=Ai(Ai(new ss,(_o(),Dh),(Ao(),qP)),Qa,fM)}function UQ(e,t){return!e.o&&(e.o=new il((Ta(),op),pm,e,0)),nte(e.o,t)}function K4t(e,t){ii(t,"Label management",1),$E(G(e,(FQ(),K5))),On(t)}function J4t(e,t){var i;return i=e.c,t>0?h(St(i.a,t-1),8):null}function zQ(e){var t;return t=e.b,t.b==0?null:h(qg(t,0),170).b}function M0e(e){var t,i,a,l;l=e.d,t=e.a,i=e.b,a=e.c,e.d=i,e.a=a,e.b=l,e.c=t}function Q4t(e,t){var i;e.A&&(i=h(Ds(e.b,t),114).n,i.d=e.A.d,i.a=e.A.a)}function GQ(e,t,i){var a,l;if(i!=null)for(a=0;a=0,"Initial capacity must not be negative")}function DGe(e){this.b=(Yr(),new ui),this.c=new ui,this.d=new ui,this.a=e}function BGe(e){e?(this.c=e,this.b=null):(this.c=null,this.b=new ke)}function jQ(e,t){S8.call(this,e,t),this.a=le(oVt,et,398,2,0,1),this.b=!0}function $Q(e,t,i){return bne(e,t,i,re(t,62)&&(h(h(t,17),62).Bb&oo)!=0)}function ukt(e,t,i){return hP(e,t,i,re(t,62)&&(h(h(t,17),62).Bb&oo)!=0)}function fkt(e,t,i){return S8t(e,t,i,re(t,62)&&(h(h(t,17),62).Bb&oo)!=0)}function hkt(e,t){return to(ce(Xe(G(e,(Ie(),nb)))),ce(Xe(G(t,nb))))}function dkt(){return kS(),X(q(jse,1),Oe,290,0,[SSe,mG,gG,ESe,dG,pG])}function pkt(){return d7(),X(q(LSe,1),Oe,241,0,[Xse,qse,Zse,Yse,Kse,wG])}function gkt(){return g6(),X(q(BSe,1),Oe,255,0,[vG,RSe,DSe,kSe,ISe,Jse])}function mkt(){return IS(),X(q(GSe,1),Oe,256,0,[ZP,NSe,zSe,USe,FSe,OSe])}function bkt(){return u7(),X(q(hTe,1),Oe,291,0,[Eoe,uTe,xoe,lTe,fTe,GG])}function wkt(){return Ms(),X(q(dAe,1),Oe,83,0,[hb,sp,g3,p3,vd,Oa])}function vkt(){return nP(),X(q(Tat,1),Oe,308,0,[QG,Doe,Ooe,Boe,Noe,Ioe])}function _kt(){return ud(),X(q(gCe,1),Oe,224,0,[Qoe,J5,Q5,fj,lj,uj])}function ykt(){return f7(),X(q(sAe,1),Oe,289,0,[bae,nAe,rAe,eAe,iAe,tAe])}function OGe(){OGe=M,Uat=$A($A(Gpe(new ss,(PS(),dL)),(nP(),QG)),Doe)}function cU(){cU=M,new Sr("org.eclipse.elk.addLayoutConfig"),rct=new P2}function NGe(){NGe=M,I7(),iPe=Jr,Eut=Ts,rPe=new Kb(Jr),Sut=new Kb(Ts)}function FGe(e,t,i){vi();var a;return a=em(e,t),i&&a&&$At(e)&&(a=null),a}function le(e,t,i,a,l,f){var g;return g=IHe(l,a),l!=10&&X(q(e,f),t,i,l,g),g}function xkt(e,t,i){return kNe((lA(),new K9(cWe(X(q(on,1),et,1,5,[e,t,i])))))}function UGe(e,t){var i;return i=t.kc(),Yr(),new DR(i,nqe(e.e,i,h(t.lc(),13)))}function zGe(e,t){var i,a;return i=e.a-t.a,a=e.b-t.b,w.Math.sqrt(i*i+a*a)}function T0e(e,t,i){var a;a=e.b[i.c.o][i.o],a.b+=t.b,a.c+=t.c,a.a+=t.a,++a.a}function Ekt(e,t,i){var a,l;return l=e.length,a=i=e.i)throw Y(new JK(t,e.i));return e.g[t]}function jGe(e,t,i){if(DA(e,i),i!=null&&!e.Li(i))throw Y(new AR);return i}function Mh(e,t){return tQ(t,"Horizontal alignment cannot be null"),e.b=t,e}function AI(e,t){var i;return i=e.rg(t),i>=0?e.ug(i,!0,!0):Ax(e,t,!0)}function PI(e,t,i){var a,l;return l=(a=OS(e.b,t),a),l?B7(OI(e,l),i):null}function Skt(e){return re(e,159)?""+h(e,159).a:e==null?null:Ga(e)}function Mkt(e){return re(e,159)?""+h(e,159).a:e==null?null:Ga(e)}function pS(e){var t;return $o(e)&&(t=0-e,!isNaN(t))?t:zg(_S(e))}function Tkt(e){var t;return e=e>2?e:2,t=gbe(e),e>t?(t<<=1,t>0?t:Rx):t}function LI(e){var t,i;return t=e+128,i=(A8e(),u3e)[t],!i&&(i=u3e[t]=new dY(e)),i}function yA(e,t){return FI(t)!=10&&X(sl(t),t.rl,t.__elementTypeId$,FI(t),e),e}function m_(e,t){return t.e==0||e.e==0?cM:(DS(),Qte(e,t))}function Ckt(e){for(;!e.a;)if(!U0e(e.b,new TY(e)))return!1;return!0}function Akt(e){for(;!e.a;)if(!O8e(e.c,new PY(e)))return!1;return!0}function $Ge(e,t){if(t.a)throw Y(new na(HJe));Cr(e.a,t),t.a=e,!e.j&&(e.j=t)}function VQ(e,t,i,a,l,f){e0e.call(this,t,a,l,f),this.c=e,this.b=i}function VGe(e,t,i,a,l,f){e0e.call(this,t,a,l,f),this.c=e,this.a=i}function il(e,t,i,a){this.Gi(),this.a=t,this.b=e,this.c=new o1e(this,t,i,a)}function kI(e,t){this.e=t,this.a=m$e(e),this.a<54?this.f=cS(e):this.c=s6(e)}function Pkt(e,t){e.a.Ld(t.d,e.b)>0&&(De(e.c,new Ome(t.c,t.d,e.d)),e.b=t.d)}function WQ(e){e.a=le(In,si,22,e.b+1,15,1),e.c=le(In,si,22,e.b,15,1),e.d=0}function WGe(){WGe=M,Xnt=Ui((uU(),X(q(Vz,1),Oe,278,0,[nse,D3e,B3e,O3e])))}function HGe(){HGe=M,iot=Ui((_w(),X(q(Moe,1),Oe,179,0,[jG,Soe,_y,vy])))}function qGe(){qGe=M,Vit=Ui((yS(),X(q($it,1),Oe,373,0,[eb,Nw,Ow,fy])))}function XGe(){XGe=M,rit=Ui((Sx(),X(q(iit,1),Oe,304,0,[m5,g5,b5,w5])))}function YGe(){YGe=M,oit=Ui((YA(),X(q(sit,1),Oe,362,0,[v5,qz,Xz,_5])))}function ZGe(){ZGe=M,Mat=Ui((PS(),X(q(ITe,1),Oe,360,0,[JG,dL,q5,pL])))}function KGe(){KGe=M,nct=Ui((i7(),X(q(cCe,1),Oe,320,0,[Zoe,oCe,aCe,sCe])))}function JGe(){JGe=M,Act=Ui((Yd(),X(q(QCe,1),Oe,226,0,[wj,xL,h3,EL])))}function QGe(){QGe=M,Pct=Ui((ld(),X(q(mae,1),Oe,197,0,[gae,pae,EM,ub])))}function eje(){eje=M,jct=Ui((Hl(),X(q(AL,1),Oe,344,0,[lD,C1,cD,gb])))}function tje(){tje=M,Slt=Ui((D0(),X(q(Elt,1),Oe,374,0,[dD,hD,Sae,Mae])))}function nje(){nje=M,Vct=Ui((XU(),X(q(yAe,1),Oe,288,0,[yae,wAe,_Ae,vAe])))}function ije(){ije=M,qct=Ui((xl(),X(q(Hct,1),Oe,265,0,[fD,Ed,dm,uD])))}function rl(){rl=M,Uh=new ZK(XS,0),mb=new ZK(MP,1),cf=new ZK(YS,2)}function RI(){RI=M,LTe=new sge(q0,0),ZG=new sge("IMPROVE_STRAIGHTNESS",1)}function lU(){lU=M,XTe=new age("LEAF_NUMBER",0),qoe=new age("NODE_SIZE",1)}function uU(){uU=M,nse=new M8("All",0),D3e=new WNe,B3e=new nFe,O3e=new HNe}function Vc(e){return e.b||(e.b=new lFe(ko,e),!e.a&&(e.a=new sI(e,e))),e.b}function II(e,t){if(t<0)throw Y(new Ra(eet+t));return dze(e,t+1),St(e.j,t)}function px(e){var t;if(!S_(e))throw Y(new K);return e.d=1,t=e.c,e.c=null,t}function fU(e){var t,i;return i=e.length,t=le(Zl,Ph,22,i,15,1),V9e(e,0,i,t,0),t}function HQ(e,t){var i;this.f=e,this.b=t,i=h(Ii(e.b,t),264),this.c=i?i.b:null}function Lkt(e,t,i){var a;return a=xVe(e,t,i),e.b=new dee(a.c.length),Yve(e,a)}function kkt(e,t){var i;return i=h(AS(e.d,t),13),i?nqe(e.e,t,i):null}function L0e(e,t){var i;return i=h(hS(e.c,t),353),i?(zme(i),i.e):null}function Rkt(e){var t,i;if(!e.b)return null;for(i=e.b;t=i.a[0];)i=t;return i}function Ikt(e,t,i){var a;return a=jA(i),eP(e.g,a,t,!1),eP(e.i,t,i,!1),t}function DI(e,t,i,a){var l;a=(sS(),a||C3e),l=e.slice(t,i),pve(l,e,t,i,-t,a)}function jl(e,t,i,a,l){return t<0?Ax(e,i,a):h(i,61).aj().cj(e,e.Qg(),t,a,l)}function Dkt(e,t){return t0?zi:Ma(e,zs)<0?zs:nr(e)}function Ukt(e,t){if(!e)throw Y(new un(K8t("Enum constant undefined: %s",t)))}function hU(e){q8(this),this.g=e?$Ue(e,e.Od()):null,this.f=e,z9(this),this.Pd()}function Wd(e,t,i,a,l,f,g){lee.call(this,t,a,l,f,g),this.c=e,this.b=i}function ad(e,t,i){var a,l;for(a=10,l=0;l=0?(e.gd(i),!0):!1}function QQ(e,t){var i;return i=br(e.d,t),i>=0?t7(e,i,!0,!0):Ax(e,t,!0)}function $kt(e,t){var i;for(i=0;e.e!=e.i._b();)nMt(t,Yn(e),He(i)),i!=zi&&++i}function oje(e,t){var i,a,l;for(l=0,a=e.tc();a.hc();)i=a.ic(),Gr(t,l++,i);return t}function Og(e,t,i){var a;if(t==null)throw Y(new F2);return a=Hm(e,t),m4t(e,t,i),a}function Ng(e){if(e<0)throw Y(new un("tolerance ("+e+") must be >= 0"));return e}function eee(e){var t;return t=e.b.c.length==0?null:St(e.b,0),t!=null&&ibe(e,0),t}function aje(e,t){var i,a,l;for(a=0,l=t.length;a=e.a.c.length;)De(e.a,new Ir);return h(St(e.a,t),15)}function Wkt(e){return Bwe(e,(gS(),c3e))<0?-aMt(_S(e)):e.l+e.m*Nx+e.h*l1}function cje(e){var t,i;return t=e/60|0,i=e%60,i==0?""+t:""+t+":"+(""+i)}function Hkt(e,t){var i;return i=O6t(e.e.c,t.e.c),i==0?to(e.e.d,t.e.d):i}function mx(e,t){var i=e.a[t],a=(Bee(),Kre)[typeof i];return a?a(i):Ibe(typeof i)}function lje(e,t){return t==(DJ(),DJ(),qnt)?e.toLocaleLowerCase():e.toLowerCase()}function FI(e){return e.__elementTypeCategory$==null?10:e.__elementTypeCategory$}function N0e(e){return(e.i&2?"interface ":e.i&1?"":"class ")+(Fd(e),e.o)}function qkt(e,t,i){var a;return a=e.a.e[h(t.a,8).o]-e.a.e[h(i.a,8).o],yr(s9e(a))}function uje(e,t){var i;for(++e.d,++e.c[t],i=t+1;i=0&&te||e>t)throw Y(new gpe("fromIndex: 0, toIndex: "+e+rye+t))}function bU(e,t){var i,a;for(a=e.tc();a.hc();)i=h(a.ic(),68),Ee(i,(Ie(),t3),t)}function Qkt(e,t,i){var a;a=w.Math.max(0,e.b/2-.5),ZA(i,a,1),De(t,new TOe(i,a))}function eRt(e){var t;return t=ce(Xe(G(e,($e(),tp)))),t<0&&(t=0,Ee(e,tp,t)),t}function v_(e){r9();var t,i;for(i=q2e,t=0;ti&&(i=e[t]);return i}function tRt(){iBe();for(var e=Vre,t=0;t=e.i)throw Y(new JK(t,e.i));return e.zh(t,e.g[t])}function Rje(e,t,i){if(DA(e,i),!e.Nj()&&i!=null&&!e.Li(i))throw Y(new AR);return i}function SA(e,t){var i;for(i=e;eo(i);)if(i=eo(i),i==t)return!0;return!1}function sRt(e,t){return t&&e.b[t.g]==t?(Gr(e.b,t.g,null),--e.c,!0):!1}function Xu(e,t){var i;return i=t.c,t.a.b=t.b,t.b.a=t.a,t.a=t.b=null,t.c=null,--e.b,i}function cd(e,t){var i,a,l,f;for(dn(t),a=e.c,l=0,f=a.length;l>5,l=t&31,a=Kr(c_(e.n[i][f],nr(jd(l,1))),3),a}function Ije(e,t){for(;t[0]=0;)++t[0]}function Dje(e,t){a9.call(this),j0e(this),this.a=e,this.c=!0,this.b=t.d,this.f=t.e}function Bje(e,t){return xh(),Ng(tm),w.Math.abs(e-t)<=tm||e==t||isNaN(e)&&isNaN(t)}function G0e(e){return e.a<54?e.f<0?-1:e.f>0?1:0:(!e.c&&(e.c=ZI(e.f)),e.c).e}function Oje(e){return e.c&&e.d?e.c.g+"("+e.c+")->"+e.d.g+"("+e.d+")":"e_"+m0(e)}function Nje(e,t,i){var a,l;a=t;do l=ce(e.p[a.o])+i,e.p[a.o]=l,a=e.a[a.o];while(a!=t)}function aRt(e,t,i){var a,l,f;for(l=t[i],a=0;a=14&&t<=16))),e}function iee(e,t){Mo();var i;for(Hn(e),Hn(t),i=!1;t.hc();)i=i|e.nc(t.ic());return i}function Ef(e,t){if(e<0)throw Y(new un(t+" cannot be negative but was: "+e));return e}function ree(e,t){var i,a;for(a=new j(e);a.ai)throw Y(new o_(t,i));return new Sme(e,t)}function E_(e,t){var i;i=e.s,e.s=t,e.Db&4&&!(e.Db&1)&&Li(e,new LQ(e,4,i,e.s))}function mS(e,t){var i;i=e.t,e.t=t,e.Db&4&&!(e.Db&1)&&Li(e,new LQ(e,5,i,e.t))}function $0e(e,t){var i;i=e.d,e.d=t,e.Db&4&&!(e.Db&1)&&Li(e,new LQ(e,2,i,e.d))}function aee(e,t){var i;i=e.F,e.F=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,5,i,t))}function lRt(e,t){var i,a,l;return i=(a=(p0(),l=new ZT,l),t&&kYe(a,t),a),i$e(i,e),i}function R0(){R0=M,HG=new jK("BARYCENTER",0),lL=new jK(EQe,1),qG=new jK(SQe,2)}function wU(){wU=M,TSe=new RK("ARD",0),bG=new RK("MSD",1),$se=new RK("MANUAL",2)}function Oo(){Oo=M,WG=new NK(zx,0),Fc=new NK("INPUT",1),lc=new NK("OUTPUT",2)}function Hje(){Vu(),this.b=(Yr(),new ui),this.f=new ui,this.g=new ui,this.e=new ui}function V0e(e,t,i,a,l){this.d=t,this.k=a,this.f=l,this.o=-1,this.p=1,this.c=e,this.a=i}function W0e(e,t,i,a,l){this.d=t,this.k=a,this.f=l,this.o=-1,this.p=2,this.c=e,this.a=i}function H0e(e,t,i,a,l){this.d=t,this.k=a,this.f=l,this.o=-1,this.p=6,this.c=e,this.a=i}function q0e(e,t,i,a,l){this.d=t,this.k=a,this.f=l,this.o=-1,this.p=7,this.c=e,this.a=i}function X0e(e,t,i,a,l){this.d=t,this.j=a,this.e=l,this.o=-1,this.p=4,this.c=e,this.a=i}function Y0e(e,t){return xh(),Ng(tm),w.Math.abs(e-t)<=tm||e==t||isNaN(e)&&isNaN(t)}function uRt(){return A7(),X(q(sEe,1),Oe,228,0,[rEe,eEe,tEe,Q3e,ose,iEe,nEe,J3e,K3e])}function fRt(){return a1(),X(q(Ys,1),Oe,86,0,[Mu,Nh,Cu,Rf,af,of,Ll,Au,Tu])}function hRt(){return cc(),X(q(bAe,1),Oe,239,0,[SM,PL,xj,LL,Ej,Sj,b3,_ae,yj])}function qje(){qje=M,Nnt=X(q(In,1),si,22,15,[0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15])}function Xje(){Xje=M,Sot=jc(Ai(Ai(new ss,(_o(),Qa),(Ao(),Dse)),ec,Rse),qo,Ise)}function cee(){return Joe||(Joe=new fZe,kA(Joe,X(q(WP,1),et,154,0,[new XX]))),Joe}function bo(e,t,i){return ES(e,t),Sf(e,i),E_(e,0),mS(e,1),A_(e,!0),C_(e,!0),e}function Yje(e,t){var i;return re(t,38)?e.c.vc(t):(i=nte(e,t),a6(e,t),i)}function pr(e){var t;return re(e,78)?e:(t=e&&e[jne],t||(t=new wWe(e),Vi(t)),t)}function Z0e(e){var t,i;if(e==0)return 32;for(i=0,t=1;!(t&e);t<<=1)++i;return i}function dRt(e,t){var i;return i=e.c,t=0),M5t(e.d,e.c)<0&&(e.a=e.a-1&e.d.a.length-1,e.b=e.d.c),e.c=-1}function uee(e,t){e.j>0&&e.c0&&e.e!=0&&uee(e.g,t/e.j*e.g.d))}function t$e(e,t){var i;i=e.c,e.c=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,1,i,e.c))}function n$e(e,t){var i;i=e.b,e.b=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,0,i,e.b))}function jI(e,t){var i;i=e.k,e.k=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,2,i,e.k))}function Q0e(e,t){var i;i=e.f,e.f=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,8,i,e.f))}function ebe(e,t){var i;i=e.i,e.i=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,7,i,e.i))}function i$e(e,t){var i;i=e.a,e.a=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,8,i,e.a))}function r$e(e,t){var i;i=e.d,e.d=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,1,i,e.d))}function s$e(e,t){var i;i=e.c,e.c=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,1,i,e.c))}function tbe(e,t){var i;i=e.c,e.c=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,4,i,e.c))}function fee(e,t){var i;i=e.D,e.D=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,2,i,e.D))}function o$e(e,t){var i;i=e.b,e.b=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,0,i,e.b))}function wRt(e,t,i){var a;e.b=t,e.a=i,a=(e.a&512)==512?new kDe:new $f,e.c=eUt(a,e.b,e.a)}function a$e(e,t){return j0(e.e,t)?(Yo(),O0e(t)?new y9(t,e):new qR(t,e)):new yNe(t,e)}function LA(e,t){return vt(),ws(e)?qme(e,ti(t)):aw(e)?v9e(e,Xe(t)):ow(e)?nAt(e,mt(t)):e.vd(t)}function vRt(e){var t=/function(?:\s+([\w$]+))?\s*\(/,i=t.exec(e);return i&&i[1]||$ne}function _Rt(e,t){var i,a;return i=e.o+e.p,a=t.o+t.p,i>>31;a!=0&&(e[i]=a)}function m$e(e){var t;return Ma(e,0)<0&&(e=tme(e)),t=nr(Pg(e,32)),64-(t!=0?x6(t):x6(nr(e))+32)}function TRt(e){var t,i;for(i=e.c.a.Xb().tc();i.hc();)t=h(i.ic(),204),Tde(t,new U9e(t.f))}function b$e(e){var t,i;for(i=e.c.a.Xb().tc();i.hc();)t=h(i.ic(),204),Cde(t,new pqe(t.e))}function w$e(e){this.d=e,this.c=e.c.Tb().tc(),this.b=null,this.a=null,this.e=(Mo(),Mo(),n3e)}function v$e(e){this.e=e,this.d=new m8(Eee(i1e(this.e)._b())),this.c=this.e.a,this.b=this.e.c}function dee(e){this.b=e,this.a=le(In,si,22,e+1,15,1),this.c=le(In,si,22,e,15,1),this.d=0}function CRt(e){e.a=null,e.e=null,e.b.c=le(on,et,1,0,5,1),e.f.c=le(on,et,1,0,5,1),e.c=null}function Ji(e,t){var i,a;a=(i=new Jge,i),a.n=t,$n((!e.s&&(e.s=new ze(Sc,e,21,17)),e.s),a)}function xr(e,t){var i,a;i=(a=new cK,a),i.n=t,$n((!e.s&&(e.s=new ze(Sc,e,21,17)),e.s),i)}function Sf(e,t){var i;i=e.zb,e.zb=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,1,i,e.zb))}function pee(e,t){var i;i=e.xb,e.xb=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,3,i,e.xb))}function gee(e,t){var i;i=e.yb,e.yb=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,2,i,e.yb))}function mee(e,t,i){var a,l,f;return l=T0(t,"labels"),a=new rNe(e,i),f=(sUt(a.a,a.b,l),l),f}function Ar(e,t,i,a,l,f,g,m,v,y,E,C,R){return oXe(e,t,i,a,l,f,g,m,v,y,E,C,R),$be(e,!1),e}function wo(e,t){var i,a,l;for(dn(t),i=!1,l=t.tc();l.hc();)a=l.ic(),i=i|e.nc(a);return i}function _$e(e){if(e){if(e.Wb())throw Y(new K);return e.cd(e._b()-1)}return gze(null.tc())}function ARt(e){if(dn(e),e.length==0)throw Y(new vh("Zero length BigInteger"));gUt(this,e)}function yU(){yU=M,STe=new UK("NO",0),Poe=new UK("GREEDY",1),ETe=new UK("LOOK_BACK",2)}function bee(){bee=M,BL=new PDe,Iae=X(q(Sc,1),oy,158,0,[]),tut=X(q(uf,1),Fxe,53,0,[])}function y$e(){y$e=M,Jit=Ui((Xt(),X(q(xse,1),Oe,232,0,[hs,Nr,Qr,oa,ul,$a,ih])))}function PRt(){return xo(),X(q(Qse,1),Oe,233,0,[_G,Su,KP,yG,dy,py,C5,hM,dM,xG])}function LRt(e,t){return yS(),e==eb&&t==Nw||e==Nw&&t==eb||e==fy&&t==Ow||e==Ow&&t==fy}function kRt(e,t){return yS(),e==eb&&t==Ow||e==eb&&t==fy||e==Nw&&t==fy||e==Nw&&t==Ow}function x$e(e,t){return ce(Xe(hJ(t6(Xf(new oi(null,new di(e.c.b,16)),new jF(e)),t))))}function obe(e,t){return ce(Xe(hJ(t6(Xf(new oi(null,new di(e.c.b,16)),new Ws(e)),t))))}function E$e(e,t){t?e.B==null&&(e.B=e.D,e.D=null):e.B!=null&&(e.D=e.B,e.B=null)}function RRt(e){var t;return re(e,182)?(t=h(e,182),new ppe(t.a)):(Mo(),new hR(e))}function S$e(e){var t;return t=rze(e),rw(t.a,0)?(NE(),NE(),k3e):(NE(),new Hge(t.b))}function M$e(e){var t;return t=rze(e),rw(t.a,0)?(NE(),NE(),k3e):(NE(),new Hge(t.c))}function T$e(e){Jme.call(this),this.b=ce(Xe(G(e,($e(),rh)))),this.a=h(G(e,cm),197)}function C$e(){this.c=new w8(0),this.b=new w8(VQe),this.d=new w8($Qe),this.a=new w8(Cie)}function xU(e){this.b=(Hn(e),new vf((ru(),e))),this.a=new ke,this.d=new ke,this.e=new fo}function qd(){qd=M,Sse=new hc,Ese=new Js,kEe=new w2,LEe=new dc,REe=new km,IEe=new v2}function EU(){EU=M,Vse=new IK("GREEDY",0),ASe=new IK("DEPTH_FIRST",1),Wse=new IK(Die,2)}function Qf(){Qf=M,Ty=new XK("OUTSIDE",0),db=new XK("INSIDE",1),_j=new XK("FIXED",2)}function A$e(){A$e=M,Mot=$A(fSt(Ai(Ai(new ss,(_o(),Qa),(Ao(),Dse)),ec,Rse),qo),Ise)}function IRt(e){return e.b.c.g.j==(Xt(),Qr)?h(G(e.b.c.g,(Ie(),Jn)),11):e.b.c}function P$e(e){return e.b.d.g.j==(Xt(),Qr)?h(G(e.b.d.g,(Ie(),Jn)),11):e.b.d}function L$e(e){var t;if(e.b==-2){if(e.e==0)t=-1;else for(t=0;e.a[t]==0;t++);e.b=t}return e.b}function k$e(e){var t,i,a;for(t=0,a=e.tc();a.hc();)i=a.ic(),t+=i!=null?Hr(i):0,t=~~t;return t}function abe(e,t,i){var a,l;for(l=Nn(e,0);l.b!=l.d.c;)a=h(Un(l),9),a.a+=t,a.b+=i;return e}function $I(e){var t,i,a;for(t=0,a=e.tc();a.hc();)i=Xe(a.ic()),t+=(dn(i),i);return t/e._b()}function R$e(e){var t;return e==0?"UTC":(e<0?(e=-e,t="UTC+"):t="UTC-",t+cje(e))}function DRt(e,t){_t();var i,a;for(a=new ke,i=0;i0&&(this.g=this.Fh(this.i+(this.i/8|0)+1),e.zc(this.g))}function D$e(e,t){return xh(),Ng(gd),w.Math.abs(0-t)<=gd||t==0||isNaN(0)&&isNaN(t)?0:e/t}function ps(e,t){b9.call(this,nut,e,t),this.b=this,this.a=cl(e.mg(),Wt(this.e.mg(),this.c))}function VI(e,t){var i,a;for(a=t.length,i=0;il&&t.af&&t.b1||e.hc())return++e.a,e.g=0,t=e.i,e.hc(),t;throw Y(new K)}function W$e(e){var t;e.d==null?(++e.e,e.f=0,$Ve(null)):(++e.e,t=e.d,e.d=null,e.f=0,$Ve(t))}function TU(e,t){var i;re(t,109)?(h(e.c,81).ij(),i=h(t,109),l$e(e,i)):h(e.c,81).Gc(t)}function I0(e){return re(e,193)?xI(h(e,193)):re(e,160)?h(e,160).a:re(e,49)?new Hv(e):new UE(e)}function VRt(e,t,i){return e==(R0(),qG)?new Vb:al(t,1)!=0?new Mpe(i.length):new dBe(i.length)}function Li(e,t){var i,a,l;if(i=e.cg(),i!=null&&e.fg())for(a=0,l=i.length;a=128?!1:e<64?kC(Kr(jd(1,e),i),0):kC(Kr(jd(1,e-64),t),0)}function KRt(e){var t;return t=h(G(e,(Ie(),pa)),69),e.j==(Xt(),Qr)&&(t==(Fe(),nn)||t==Zt)}function xee(e,t){var i;return re(t,13)?(i=(ru(),h(t,13)),e.oc(i)):iee(e,h(Hn(t),20).tc())}function JRt(e){GNe();var t;return gOe(Roe,e)||(t=new nu,t.a=e,TJ(Roe,e,t)),h(Ds(Roe,e),573)}function Eee(e){return Yr(),e<3?(Ef(e,"expectedSize"),e+1):e>22),l=e.h+t.h+(a>>22),Xa(i&Yc,a&Yc,l&Kd)}function tVe(e,t){var i,a,l;return i=e.l-t.l,a=e.m-t.m+(i>>22),l=e.h-t.h+(a>>22),Xa(i&Yc,a&Yc,l&Kd)}function Mee(e,t,i,a){return i==1?(!e.n&&(e.n=new ze(ea,e,1,7)),Us(e.n,t,a)):sve(e,t,i,a)}function nVe(e,t){if(t==null)return!1;for(;e.a!=e.b;)if(ki(t,DU(e)))return!0;return!1}function hbe(e){return e.a.hc()?!0:e.a!=e.d?!1:(e.a=new F1e(e.e.d),e.a.hc())}function Lr(e,t){var i,a;return i=t.yc(),a=i.length,a==0?!1:(Nme(e.c,e.c.length,i),!0)}function iIt(e,t,i){var a,l;for(l=t.Tb().tc();l.hc();)a=h(l.ic(),38),e.Yb(a.kc(),a.lc(),i);return e}function iVe(e,t){var i;return i=e.a.get(t),i===void 0?++e.d:(e.a[hie](t),--e.c,EJ(e.b)),i}function wS(e,t){this.b=e,this.e=t,this.d=t.j,this.f=(Yo(),h(e,61).bj()),this.k=cl(t.e.mg(),e)}function rVe(e){this.o=e,this.g=new ke,this.j=new Ir,this.n=new Ir,this.e=new ke,this.b=new ke}function sVe(e){this.a=le(xot,be,1704,e.length,0,2),this.b=le(Eot,be,1705,e.length,0,2),this.c=new LWe}function rIt(e,t){e.d==(qs(),rf)||e.d==hm?h(t.a,57).c.nc(h(t.b,57)):h(t.b,57).c.nc(h(t.a,57))}function oVe(e,t){var i,a;for(a=new j(e.b);a.at?1:e==t?0:isNaN(e)?isNaN(t)?0:1:-1}function cVe(e,t){return!e||!t||e==t?!1:WWe(e.d.c,t.d.c+t.d.b)&&WWe(t.d.c,e.d.c+e.d.b)}function lVe(e,t){u9(e>=0,"Negative initial capacity"),u9(t>=0,"Non-positive load factor"),nl(this)}function uVe(e){var t,i;return i=(t=new jk,t),Sf(i,"T"),$n((!e.d&&(e.d=new Nl(fl,e,11)),e.d),i),i}function fVe(e,t){var i;return i=ed(t.a._b()),Fa(Cje(new oi(null,new di(t,1)),e.i),new eNe(e,i)),i}function dbe(e){var t,i,a;for(t=new Ir,a=Nn(e.d,0);a.b!=a.d.c;)i=h(Un(a),170),Gi(t,i.c);return t}function pbe(e){var t,i,a,l;for(t=1,i=0,l=e._b();i>=1);return t}function oIt(e){var t;return t=xw(e),t>eye?Jr:t<-34028234663852886e22?Ts:t}function X(e,t,i,a,l){return l.ql=e,l.rl=t,l.sl=T,l.__elementTypeId$=i,l.__elementTypeCategory$=a,l}function vS(e,t,i,a,l){var f,g;for(g=i;g<=l;g++)for(f=t;f<=a;f++)L_(e,f,g)||P7(e,f,g,!0,!1)}function aIt(e){var t,i,a,l;for(i=e.a,a=0,l=i.length;ae.f,i=e.u+e.e[e.o.o]*e.d>e.f*e.s*e.d,t||i}function kU(e,t,i){var a,l;return a=new jQ(t,i),l=new se,e.b=WYe(e,e.b,a,l),l.b||++e.c,e.b.b=!1,l.d}function vbe(e){var t;return(!e.c||!(e.Bb&1)&&e.c.Db&64)&&(t=pu(e),re(t,96)&&(e.c=h(t,24))),e.c}function $g(e){var t,i;for(i=new j(e.a.b);i.a=0&&e[a]===t[a];a--);return a<0?0:_K(Kr(e[a],ao),Kr(t[a],ao))?-1:1}function wIt(e){var t;return e==null?!0:(t=e.length,t>0&&e.charCodeAt(t-1)==58&&!Ree(e,IL,DL))}function OA(e){switch(e.g){case 1:return $Qe;default:case 2:return 0;case 3:return Cie;case 4:return VQe}}function Lee(e){switch(e._b()){case 0:return e3e;case 1:return new a8e(e.tc().ic());default:return new K9(e)}}function vIt(e,t){Mo();var i,a;for(A1e(t,"predicate"),a=0;e.hc();a++)if(i=e.ic(),t.Mb(i))return a;return-1}function _It(e,t,i){if(Hn(t),i.hc())for(Vpe(t,e.Lb(i.ic()));i.hc();)Vpe(t,e.c),Vpe(t,e.Lb(i.ic()));return t}function kee(e,t){var i;return t===e?!0:re(t,238)?(i=h(t,238),ki(e.Hc(),i.Hc())):!1}function Ma(e,t){var i;return $o(e)&&$o(t)&&(i=e-t,!isNaN(i))?i:Bwe($o(e)?fu(e):e,$o(t)?fu(t):t)}function ZI(e){return Kg(),e<0?e!=-1?new hwe(-1,-e):ese:e<=10?T3e[yr(e)]:new hwe(1,e)}function yIt(){vi();var e;return Uae||(e=dMt(em("M",!0)),e=C9(em("M",!1),e),Uae=e,Uae)}function T_(e,t,i){var a,l;return l=(a=new oK,a),bo(l,t,i),$n((!e.q&&(e.q=new ze(uf,e,11,10)),e.q),l),l}function Ree(e,t,i){var a,l;for(a=0,l=e.length;a=e.b.c.length||(Cbe(e,2*t+1),i=2*t+2,it)throw Y(new un(q7+e+$Je+t));if(e<0||t>i)throw Y(new gpe(q7+e+sye+t+rye+i))}function EIt(e,t,i){if(t<0)throw Y(new Ra(eet+t));t0)return oA(t-1,e.a.c.length),L0(e.a,t-1);throw Y(new U)}function DVe(e,t){var i;if(t.c.length!=0){for(;ive(e,t);)v7(e,t,!1);i=PU(t),e.a&&(e.a.If(i),DVe(e,i))}}function CIt(e,t){var i,a;for(a=Nn(e,0);a.b!=a.d.c;)i=h(Un(a),204),i.e.length>0&&(t.td(i),i.i&&s6t(i))}function Fee(e,t,i){var a,l,f;for(a=new Ir,f=Nn(i,0);f.b!=f.d.c;)l=h(Un(f),9),Gi(a,new Do(l));QIt(e,t,a)}function BVe(e,t){var i;return i=new sne((e.f&256)!=0,e.i,e.a,e.d,(e.f&16)!=0,e.j,e.g,t),e.e!=null||(i.c=e),i}function AIt(e,t){var i,a;return i=h(e.d.$b(t),13),i?(a=e.e.Oc(),a.oc(i),e.e.d-=i._b(),i.Pb(),a):null}function RU(e){var t,i,a,l;for(l=0,i=0,a=e.length;i1||t>=0&&e.b<3)}function bw(e){var t;++e.j,e.i==0?e.g=null:e.i>>0).toString(16):e.toString()}function Uee(e,t){e.D==null&&e.B!=null&&(e.D=e.B,e.B=null),fee(e,t==null?null:(dn(t),t)),e.C&&e.Kj(null)}function kIt(e,t){var i,a;for(i=e.a.length-1,e.c=e.c-1&i;t!=e.c;)a=t+1&i,Gr(e.a,t,e.a[a]),t=a;Gr(e.a,e.c,null)}function RIt(e,t){var i,a;for(i=e.a.length-1;t!=e.b;)a=t-1&i,Gr(e.a,t,e.a[a]),t=a;Gr(e.a,e.b,null),e.b=e.b+1&i}function IIt(e,t){X8(!this.b),X8(!this.d),cJ(OE(e.c)==0),cJ(t.d.c+t.e.c==0),cJ(!0),this.b=e,this.d=this.ec(t)}function FVe(e,t,i,a,l){a?vBt(e,t):(DBt(e,t,l),HGt(e,t,i)),t.c.length>1&&(_t(),fa(t,e.b),VUt(e.c,t))}function DIt(e,t,i,a,l){t==0||a==0||(t==1?l[a]=lwe(l,i,a,e[0]):a==1?l[t]=lwe(l,e,t,i[0]):vFt(e,i,l,t,a))}function BIt(e){var t,i;if(e==null)return null;for(t=0,i=e.length;t=e.c.b:e.a<=e.c.b))throw Y(new K);return t=e.a,e.a+=e.c.c,++e.b,He(t)}function xS(e){var t,i;return e>-129&&e<128?(t=e+128,i=(L8e(),m3e)[t],!i&&(i=m3e[t]=new EF(e)),i):new EF(e)}function He(e){var t,i;return e>-129&&e<128?(t=e+128,i=(l8e(),h3e)[t],!i&&(i=h3e[t]=new yF(e)),i):new yF(e)}function Gee(e,t){return!e||t&&!e.j||re(e,114)&&h(e,114).a.b==0?0:e.Pf()}function IU(e,t){return!e||t&&!e.k||re(e,114)&&h(e,114).a.a==0?0:e.Qf()}function ki(e,t){return ws(e)?dt(e,t):aw(e)||ow(e)?(dn(e),e===t):Xme(e)?e.Fb(t):$me(e)?e===t:H1e(e,t)}function Hr(e){return ws(e)?Hg(e):aw(e)?yr((dn(e),e)):ow(e)?(dn(e),e?1231:1237):Xme(e)?e.Hb():$me(e)?m0(e):B1e(e)}function sl(e){return ws(e)?Se:aw(e)?Eo:ow(e)?lo:Xme(e)||$me(e)?e.ql:e.ql||Array.isArray(e)&&q(knt,1)||knt}function FIt(e){return e?e.i&1?e==Ru?lo:e==In?Po:e==av?aM:e==ks?Eo:e==R1?J0:e==By?Q0:e==Mc?qx:$P:e:null}function ww(){ww=M,ect=(ur(),f3),tct=My,Xoe=(Pve(),qat),Yoe=Xat,iCe=Yat,aj=Zat,cj=Kat,Y5=Jat,rCe=Qat}function jee(){jee=M,vse=c7e(X(q(yL,1),Oe,110,0,[(qs(),rf),sf])),_se=c7e(X(q(yL,1),Oe,110,0,[hm,rp]))}function NA(){NA=M,Tse=new kK("MIRROR_X",0),Cse=new kK("TRANSPOSE",1),Mse=new kK("MIRROR_AND_TRANSPOSE",2)}function UIt(e){var t;return t=new yje(e),SI(e.a,Yit,new Bl(X(q(x5,1),et,341,0,[t]))),t.d&&De(t.f,t.d),t.f}function zIt(e){var t,i;for(i=new j(e.r);i.a=48&&e<58?e-48:e>=97&&e<97?e-97+10:e>=65&&e<65?e-65+10:-1}function GIt(e){var t,i;if(e==null)return!1;for(t=0,i=e.length;tkw?e-i>kw:i-e>kw}function no(e,t){var i;return $o(e)&&$o(t)&&(i=e+t,j6a)throw Y(new o_(t,a));if(e.xh()&&e.pc(i))throw Y(new un(s5));e.mh(t,i)}function HVe(e,t,i){if(e<0||t>i)throw Y(new Ra(q7+e+sye+t+", size: "+i));if(e>t)throw Y(new un(q7+e+$Je+t))}function Ibe(e){throw Bee(),Y(new BDe("Unexpected typeof result '"+e+"'; please report this bug to the GWT team"))}function Gp(e){switch(lw(),e.c){case 0:return tS(),GP;case 1:return new $2(a8t(new zE(e)));default:return new DDe(e)}}function qVe(e){var t;return e.Db&64?Ku(e):(t=new su(Ku(e)),t.a+=" (source: ",ho(t,e.d),t.a+=")",t.a)}function Ee(e,t,i){return i==null?(!e.p&&(e.p=(Yr(),new ui)),hS(e.p,t)):(!e.p&&(e.p=(Yr(),new ui)),dr(e.p,t,i)),e}function QI(e,t,i){return i==null?(!e.p&&(e.p=(Yr(),new ui)),hS(e.p,t)):(!e.p&&(e.p=(Yr(),new ui)),dr(e.p,t,i)),e}function e6(e,t,i){var a;e.Eh(e.i+1),a=e.Ch(t,i),t!=e.i&&vc(e.g,t,e.g,t+1,e.i-t),Gr(e.g,t,a),++e.i,e.sh(t,i),e.th()}function Wee(e,t,i){var a,l,f;for(a=0,f=Nn(e,0);f.b!=f.d.c&&(l=ce(Xe(Un(f))),!(l>i));)l>=t&&++a;return a}function Hee(e,t){var i,a,l;for(i=0,l=sa(e,t).tc();l.hc();)a=h(l.ic(),11),i+=G(a,(Ie(),Pl))!=null?1:0;return i}function XIt(e){var t;return t=h(gx(e.c.c,""),199),t||(t=new cx(BE(DE(new Wb,""),"Other")),N0(e.c.c,"",t)),t}function XVe(e){this.a=new Gc,this.d=new Gc,this.b=new Gc,this.c=new Gc,this.g=new Gc,this.i=new Gc,this.f=e}function qs(){qs=M,Oh=new VR(zx,0),sf=new VR(YS,1),rf=new VR(XS,2),rp=new VR(ore,3),hm=new VR("UP",4)}function e1(){e1=M,vj=new qK("INHERIT",0),d3=new qK("INCLUDE_CHILDREN",1),ML=new qK("SEPARATE_CHILDREN",2)}function YIt(e,t,i){var a,l;return a=new Wd(e.e,3,13,null,(l=t.c,l||(yt(),zh)),$p(e,t),!1),i?i.Sh(a):i=a,i}function ZIt(e,t,i){var a,l;return a=new Wd(e.e,4,13,(l=t.c,l||(yt(),zh)),null,$p(e,t),!1),i?i.Sh(a):i=a,i}function Dbe(e,t,i){var a,l;return l=e.sb,e.sb=t,e.Db&4&&!(e.Db&1)&&(a=new ls(e,1,4,l,t),i?i.Sh(a):i=a),i}function Bbe(e,t,i){var a,l;return l=e.r,e.r=t,e.Db&4&&!(e.Db&1)&&(a=new ls(e,1,8,l,e.r),i?i.Sh(a):i=a),i}function jp(e,t){var i,a;return i=h(t,614),a=i.Hj(),!a&&i.Ij(a=re(t,96)?new bNe(e,h(t,24)):new H7e(e,h(t,140))),a}function Obe(e,t){var i;return e===t?!0:re(t,89)?(i=h(t,89),e.e==i.e&&e.d==i.d&&w4t(e,i.a)):!1}function KIt(e,t){var i;if(i=T6(e,t),re(i,335))return h(i,29);throw Y(new un(ry+t+"' is not a valid attribute"))}function t6(e,t){var i;return i=new wt,e.a.sd(i)?(HE(),new fK(dn(rje(e,i.a,t)))):(f_(e),HE(),HE(),L3e)}function YVe(e,t){var i;e.c.length!=0&&(i=h(vo(e,le(Eu,Cf,8,e.c.length,0,1)),123),vge(i,new _H),IXe(i,t))}function ZVe(e,t){var i;e.c.length!=0&&(i=h(vo(e,le(Eu,Cf,8,e.c.length,0,1)),123),vge(i,new yH),IXe(i,t))}function SS(e,t){switch(t.g){case 2:case 1:return sa(e,t);case 3:case 4:return I0(sa(e,t))}return _t(),_t(),uo}function Nbe(e,t,i,a){switch(t){case 1:return!e.n&&(e.n=new ze(ea,e,1,7)),e.n;case 2:return e.k}return Mwe(e,t,i,a)}function JIt(e,t,i,a,l,f,g,m){var v;for(v=i;f=a||t=65&&e<=70?e-65+10:e>=97&&e<=102?e-97+10:e>=48&&e<=57?e-48:0}function QVe(e){return e-=e>>1&1431655765,e=(e>>2&858993459)+(e&858993459),e=(e>>4)+e&252645135,e+=e>>8,e+=e>>16,e&63}function C_(e,t){var i;i=(e.Bb&256)!=0,t?e.Bb|=256:e.Bb&=-257,e.Db&4&&!(e.Db&1)&&Li(e,new qu(e,1,2,i,t))}function eWe(e,t){var i;i=(e.Bb&256)!=0,t?e.Bb|=256:e.Bb&=-257,e.Db&4&&!(e.Db&1)&&Li(e,new qu(e,1,8,i,t))}function Fbe(e,t){var i;i=(e.Bb&256)!=0,t?e.Bb|=256:e.Bb&=-257,e.Db&4&&!(e.Db&1)&&Li(e,new qu(e,1,8,i,t))}function tWe(e,t){var i;i=(e.Bb&512)!=0,t?e.Bb|=512:e.Bb&=-513,e.Db&4&&!(e.Db&1)&&Li(e,new qu(e,1,9,i,t))}function A_(e,t){var i;i=(e.Bb&512)!=0,t?e.Bb|=512:e.Bb&=-513,e.Db&4&&!(e.Db&1)&&Li(e,new qu(e,1,3,i,t))}function UA(e,t){var i;return e.b==-1&&e.a&&(i=e.a.Vi(),e.b=i?e.c.qg(e.a.pi(),i):br(e.c.mg(),e.a)),e.c.hg(e.b,t)}function t6t(e,t,i){var a,l;return l=e.a,e.a=t,e.Db&4&&!(e.Db&1)&&(a=new ls(e,1,5,l,e.a),i?Hwe(i,a):i=a),i}function n6t(e,t){var i;if(i=Lp(e.i,t),i==null)throw Y(new _h("Node did not exist in input."));return lbe(t,i),null}function i6t(e,t){var i;if(i=Ii(e.k,t),i==null)throw Y(new _h("Port did not exist in input."));return lbe(t,i),null}function MS(e){if(e.c)MS(e.c);else if(e.d)throw Y(new ba("Stream already terminated, can't be modified or used"))}function r6t(e){var t;if(!e.a)throw Y(new ba("Cannot offset an unassigned cut."));t=e.c-e.b,e.b+=t,OUe(e,t),NUe(e,t)}function s6t(e){var t;e.g&&(t=e.c.pf()?e.f:e.a,Xve(t.a,e.o,!0),Xve(t.a,e.o,!1),Ee(e.o,($e(),Ki),(Ms(),p3)))}function o6t(e){var t,i,a;for(t=h(G(e,(ha(),DTe)),15),a=t.tc();a.hc();)i=h(a.ic(),170),Gi(i.b.d,i),Gi(i.c.b,i)}function nWe(e){var t,i,a;for(a=0,i=(Mo(),new Nd(Kh(Gd(e.a,new z))));Gn(i);)t=h(Tn(i),14),t.c.g==t.d.g||++a;return a}function iWe(e,t){var i,a;for(a=new Bn(e);a.e!=a.i._b();)if(i=h(Yn(a),24),Be(t)===Be(i))return!0;return!1}function rWe(e,t){var i,a;for(a=new Bn(e);a.e!=a.i._b();)if(i=h(Yn(a),133),Be(t)===Be(i))return!0;return!1}function a6t(e,t,i){var a,l,f;return f=(l=OS(e.b,t),l),f&&(a=h(B7(OI(e,f),""),24),a)?Bve(e,a,t,i):null}function qee(e,t,i){var a,l,f;return f=(l=OS(e.b,t),l),f&&(a=h(B7(OI(e,f),""),24),a)?Ove(e,a,t,i):null}function Ube(e){var t,i;return t=e.j,t==(Xt(),Qr)?(i=h(G(e,(Ie(),pa)),69),i==(Fe(),bn)||i==ni):!1}function sWe(e){var t;return t=new h0,t.a+="VerticalSegment ",Ic(t,e.e),t.a+=" ",Mi(t,lJ(new LR(Ca),new j(e.k))),t.a}function c6t(e){var t,i,a;for(t=new ke,a=new j(e.b);a.a0&&(a+=l,++i);return i>1&&(a+=e.d*(i-1)),a}function v6t(e,t,i){var a,l;for(l=e.a.Xb().tc();l.hc();)if(a=h(l.ic(),8),Gg(i,h(St(t,a.o),13)))return a;return null}function Kee(e,t,i,a){var l;if(l=e.length,t>=l)return l;for(t=t>0?t:0;t=1?sf:rp):i}function y6t(e){var t,i,a;for(t=0,a=new j(e.c.a);a.a=64&&t<128&&(l=Zf(l,jd(1,t-64)));return l}function hWe(e,t,i){var a,l,f;for(l=Cn(t?As(e):fr(e));Gn(l);)a=h(Tn(l),14),f=t?a.c.g:a.d.g,f.j==(Xt(),ul)&&Hs(f,i)}function x6t(e,t,i){var a;a=new Jze(e,t),ir(e.r,t.ef(),a),i&&e.t!=(Qf(),_j)&&(a.c=new s7e(e.d),cd(t.We(),new vZ(a)))}function dWe(e,t,i){var a,l;return a=(p0(),l=new gE,l),see(a,t),oee(a,i),e&&$n((!e.a&&(e.a=new vs(oh,e,5)),e.a),a),a}function On(e){if(e.i==null)throw Y(new ba("The task has not begun yet."));e.b||(e.c0&&t.charCodeAt(0)==43?t.substr(1,t.length-1):t))}function T6t(e){var t;return e==null?null:new Tg((t=Ba(e,!0),t.length>0&&t.charCodeAt(0)==43?t.substr(1,t.length-1):t))}function Wbe(e){var t;return t=le(Zl,Ph,22,2,15,1),e-=oo,t[0]=(e>>10)+$6&jr,t[1]=(e&1023)+56320&jr,hu(t,0,t.length)}function C6t(e){var t,i;for(i=u8t($l(dw(e))).tc();i.hc();)if(t=ti(i.ic()),uP(e,t))return U4t((NBe(),Hlt),t);return null}function hu(e,t,i){var a,l,f,g;for(f=t+i,x0e(t,f,e.length),g="",l=t;lt&&a.Ld(e[f-1],e[f])>0;--f)g=e[f],Gr(e,f,e[f-1]),Gr(e,f-1,g)}function P6t(e,t){var i;e.c=t,e.a=N6t(t),e.a<54&&(e.f=(i=t.d>1?Zf(jd(t.a[1],32),Kr(t.a[0],ao)):Kr(t.a[0],ao),cS(Jm(t.e,i))))}function Jee(){Ywe();var e,t,i;i=sVt+++H4t(),e=yr(w.Math.floor(i*W6))&H7,t=yr(i-e*iye),this.a=e^1502,this.b=t^die}function L6t(e,t,i){e.n=uw(R1,[be,tye],[378,22],14,[i,yr(w.Math.ceil(t/32))],2),e.o=t,e.p=i,e.j=t-1>>1,e.k=i-1>>1}function k6t(e,t){var i,a,l;a=p_(t),l=ce(Xe(CS(a,($e(),rh)))),i=w.Math.max(0,l/2-.5),ZA(t,i,1),De(e,new COe(t,i))}function pWe(e,t){var i,a;for(i=Nn(e,0);i.b!=i.d.c;){if(a=ce(Xe(Un(i))),a==t)return;if(a>t){lS(i);break}}QE(i,t)}function zt(e,t){var i,a,l,f,g;if(i=t.f,N0(e.c.d,i,t),t.g!=null)for(l=t.g,f=0,g=l.length;ft?1:$8(isNaN(e),isNaN(t))}function wWe(e){Qs(),q8(this),z9(this),this.e=e,e!=null&&DFe(e,jne,this),this.g=e==null?Xc:Ga(e),this.a="",this.b=e,this.a=""}function GA(e){var t;this.a=(t=h(e.e&&e.e(),10),new Oc(t,h(el(t,t.length),10),0)),this.b=le(on,et,1,this.a.a.length,5,1)}function $U(e,t){var i,a;return i=e._b(),t.lengthi&&Gr(t,i,null),t}function Xbe(e){var t,i,a;for(a=new Tp,a.a+="[",t=0,i=e._b();t>5,t=e&31,a=le(In,si,22,i+1,15,1),a[i]=1<f?t:f;return He(t)}function G6t(e,t){var i,a;for(a=e.e.a.Xb().tc();a.hc();)if(i=h(a.ic(),247),YOt(t,i.d)||QNt(t,i.d))return!0;return!1}function vWe(e,t){var i,a,l,f;for(f=e.g.ed(),i=0;f.hc();){if(a=ce(Xe(f.ic())),l=a-t,l>ey)return i;l>hz&&++i}return i}function _We(e,t){var i,a,l;l=t.d.g,a=l.j,!(a==(Xt(),hs)||a==$a||a==ih)&&(i=Cn(fr(l)),Gn(i)&&dr(e.k,t,h(Tn(i),14)))}function yWe(e,t){var i,a;i=t==(JA(),Fse),a=Zbe(e),i&&!a||!i&&a?Ee(e,($e(),Bh),(ud(),Q5)):Ee(e,($e(),Bh),(ud(),J5))}function ld(){ld=M,gae=new D8(zx,0),pae=new D8("POLYLINE",1),EM=new D8("ORTHOGONAL",2),ub=new D8("SPLINES",3)}function VU(){VU=M,Hoe=new WK("OVERLAP_REMOVAL",0),Voe=new WK("COMPACTION",1),Woe=new WK("GRAPH_SIZE_CALCULATION",2)}function WU(){WU=M,_Te=new FK("EQUALLY_DISTRIBUTED",0),Aoe=new FK("NORTH_STACKED",1),yTe=new FK("NORTH_SEQUENCE",2)}function j6t(e){var t,i,a,l,f;return f=Zwe(e),i=x8(e.c),a=!i,a&&(l=new Om,Og(f,"knownLayouters",l),t=new jZ(l),mo(e.c,t)),f}function $6t(e,t,i){var a,l;for(l=re(t,62)&&h(h(t,17),62).Bb&oo?new QK(t,e):new wS(t,e),a=0;a3;)l*=10,--f;e=(e+(l>>1))/l|0}return a.i=e,!0}function _x(e,t,i){var a,l;for(l=e.tc();l.hc();)if(a=l.ic(),Be(t)===Be(a)||t!=null&&ki(t,a))return i&&l.jc(),!0;return!1}function AWe(e,t){var i,a;if(t){for(i=0;i0&&(t.lengthe.i&&Gr(t,e.i,null),t}function PWe(e,t){var i,a,l,f;return i=t>>5,t&=31,l=e.d+i+(t==0?0:1),a=le(In,si,22,l,15,1),gOt(a,e.a,i,t),f=new l_(e.e,l,a),gA(f),f}function qU(e,t){oge();var i,a;return i=oI((Vf(),Vf(),jP)),a=null,t==i&&(a=h(za(s3e,e),556)),a||(a=new tUe(e),t==i&&Ko(s3e,e,a)),a}function br(e,t){var i,a,l;if(i=(e.i==null&&Jg(e),e.i),a=t.pi(),a!=-1){for(l=i.length;a=0;--a)for(t=i[a],l=0;l0&&Ma(e,128)<0?(t=nr(e)+128,i=(P8e(),d3e)[t],!i&&(i=d3e[t]=new xF(e)),i):new xF(e)}function s6(e){return Kg(),Ma(e,0)<0?Ma(e,-1)!=0?new Owe(-1,pS(e)):ese:Ma(e,10)<=0?T3e[nr(e)]:new Owe(1,e)}function LWe(){hpe.call(this,new E0e(16)),Ef(2,"expectedValuesPerKey"),this.b=2,this.a=new S1e(null,null,0,null),kE(this.a,this.a)}function XU(){XU=M,yae=new O8("SIMPLE",0),wAe=new O8("GROUP_DEC",1),_Ae=new O8("GROUP_MIXED",2),vAe=new O8("GROUP_INC",3)}function twe(){twe=M,mAe=new tx(15),Uct=new wa((ur(),Sy),mAe),Gct=new wa(My,15),zct=new wa(fae,He(0)),Fct=new wa(yM,HS)}function tte(){tte=M,Bae=new zk,GAe=new nX,jAe=new Gk,$Ae=new SN,VAe=new MN,WAe=new TN,HAe=new JT,qAe=new iX,XAe=new CN}function kWe(e){this.e=le(In,si,22,e.length,15,1),this.c=le(Ru,f1,22,e.length,16,1),this.b=le(Ru,f1,22,e.length,16,1),this.f=0}function nwe(e,t){this.n=uw(R1,[be,tye],[378,22],14,[t,yr(w.Math.ceil(e/32))],2),this.o=e,this.p=t,this.j=e-1>>1,this.k=t-1>>1}function RWe(e,t,i){kje(),EDe.call(this),this.a=uw(Xct,[be,Pye],[537,171],0,[Mj,xae],2),this.c=new VE,this.g=e,this.f=t,this.d=i}function ja(e,t,i){var a,l,f;return e.ti()?(a=e.i,f=e.ui(),e6(e,a,t),l=e.mi(3,null,t,a,f),i?i.Sh(l):i=l):e6(e,e.i,t),i}function Mf(e,t){var i,a,l;return e.f>0&&(e.Fi(),a=t==null?0:Hr(t),l=(a&zi)%e.d.length,i=_ve(e,l,a,t),i)?i.lc():null}function nte(e,t){var i,a,l;return e.f>0?(e.Fi(),a=t==null?0:Hr(t),l=(a&zi)%e.d.length,i=lYe(e,l,a,t),i!=-1):!1}function o6(e,t){var i,a,l,f;for(f=cl(e.e.mg(),t),i=h(e.g,124),l=0;l2e3&&(Rnt=e,Uz=w.setTimeout(QEt,10))),Fz++==0?(Ykt((vr(),r3e)),!0):!1}function l5t(){return Error.stackTraceLimit>0?(w.Error.stackTraceLimit=Error.stackTraceLimit=64,!0):"stack"in new Error}function FWe(e,t){return e.e>t.e?1:e.et.d?e.e:e.d=0?f=f.a[1]:(l=f,f=f.a[0])}return l}function VWe(e,t,i){var a,l,f;for(l=null,f=e.b;f;){if(a=e.a.Ld(t,f.d),i&&a==0)return f;a<=0?f=f.a[0]:(l=f,f=f.a[1])}return l}function h5t(e,t,i,a){var l,f,g;return l=!1,kGt(e.f,i,a)&&(A5t(e.f,e.a[t][i],e.a[t][a]),f=e.a[t],g=f[a],f[a]=f[i],f[i]=g,l=!0),l}function swe(e,t){var i,a,l;for(l=e.g.ed();l.hc();)if(i=ce(Xe(l.ic())),a=w.Math.abs(i-t),at?1:$8(isNaN(e),isNaN(t)))>0}function awe(e,t){return xh(),xh(),Ng(tm),(w.Math.abs(e-t)<=tm||e==t||isNaN(e)&&isNaN(t)?0:et?1:$8(isNaN(e),isNaN(t)))<0}function WWe(e,t){return xh(),xh(),Ng(tm),(w.Math.abs(e-t)<=tm||e==t||isNaN(e)&&isNaN(t)?0:et?1:$8(isNaN(e),isNaN(t)))<=0}function g5t(e,t){if(t.c==e)return t.d;if(t.d==e)return t.c;throw Y(new un("Input edge is not connected to the input port."))}function YU(e,t){return dn(e),t==null?!1:dt(e,t)?!0:e.length==t.length&&dt(e.toLowerCase(),t.toLowerCase())}function HWe(e){var t,i,a,l,f;if(e==null)return null;for(f=new ke,i=Iee(e),a=0,l=i.length;at.e?1:e.ft.f?1:Hr(e)-Hr(t)}function AS(e,t){Yr(),Hn(e);try{return e.Vb(t)}catch(i){if(i=pr(i),re(i,177))return null;if(re(i,169))return null;throw Y(i)}}function x5t(e,t){Yr(),Hn(e);try{return e.$b(t)}catch(i){if(i=pr(i),re(i,177))return null;if(re(i,169))return null;throw Y(i)}}function QWe(e){Kg(),e.length==0?(this.e=0,this.d=1,this.a=X(q(In,1),si,22,15,[0])):(this.e=1,this.d=e.length,this.a=e,gA(this))}function lwe(e,t,i,a){DS();var l,f;for(l=0,f=0;f=f?(kIt(e,t),-1):(RIt(e,t),1)}function eHe(e,t){var i,a,l;++e.j,a=e.g==null?0:e.g.length,t>a&&(l=e.g,i=a+(a/2|0)+4,iuie)return i.zg();if(a=i.sg(),a||i==e)break}return a}function tHe(e,t){var i,a;return i=t.Yg(e.a),i&&(a=ti(Mf((!i.b&&(i.b=new wl((yt(),zo),Aa,i)),i.b),gi)),a!=null)?a:t.be()}function T5t(e,t){var i,a;return i=t.Yg(e.a),i&&(a=ti(Mf((!i.b&&(i.b=new wl((yt(),zo),Aa,i)),i.b),gi)),a!=null)?a:t.be()}function qt(e){var t;if(re(e.a,4)){if(t=zWe(e.a),t==null)throw Y(new ba(tet+e.b+"'. "+rxe+(Fd(wD),wD.k)+sxe));return t}else return e.a}function C5t(e){var t;if(e==null)return null;if(t=M8t(Ba(e,!0)),t==null)throw Y(new mK("Invalid hexBinary value: '"+e+"'"));return t}function nHe(e,t){var i,a,l;if(De(Zz,e),t.nc(e),i=h(Ii(fse,e),19),i)for(l=i.tc();l.hc();)a=h(l.ic(),35),Qo(Zz,a,0)!=-1||nHe(a,t)}function A5t(e,t,i){var a,l;Bte(e.e,t,i,(Fe(),nn)),Bte(e.i,t,i,Zt),e.a&&(l=h(G(t,(Ie(),Jn)),11),a=h(G(i,Jn),11),CQ(e.g,l,a))}function iHe(e){var t;Be(rn(e,(ur(),Ey)))===Be((e1(),vj))&&(eo(e)?(t=h(rn(eo(e),Ey),316),ac(e,Ey,t)):ac(e,Ey,ML))}function uwe(e,t,i){this.c=e,this.f=new ke,this.e=new fo,this.j=new Hme,this.n=new Hme,this.b=t,this.g=new Yf(t.c,t.d,t.b,t.a),this.a=i}function fwe(e,t,i,a,l,f){Cge(this),this.e=e,this.f=t,this.d=i,this.c=a,this.g=l,this.b=f,this.j=ce(Xe(l.tc().ic())),this.i=ce(Xe(_$e(l)))}function P5t(e){var t;for(t=h(Tn(Cn(As(e))),14).c.g;t.j==(Xt(),Nr);)Ee(t,(Ie(),k5),(vt(),vt(),!0)),t=h(Tn(Cn(As(t))),14).c.g}function L5t(e,t,i){var a,l,f,g;return f=t.i,g=i.i,f!=g?f.g-g.g:(a=e.f[t.o],l=e.f[i.o],a==0&&l==0?0:a==0?-1:l==0?1:to(a,l))}function Yn(e){var t;try{return t=e.i.cd(e.e),e.Bi(),e.g=e.e++,t}catch(i){throw i=pr(i),re(i,79)?(e.Bi(),Y(new K)):Y(i)}}function ate(e){var t;try{return t=e.c.yh(e.e),e.Bi(),e.g=e.e++,t}catch(i){throw i=pr(i),re(i,79)?(e.Bi(),Y(new K)):Y(i)}}function qg(e,t){var i;i=e.fd(t);try{return i.ic()}catch(a){throw a=pr(a),re(a,101)?Y(new Ra("Can't get element "+t)):Y(a)}}function rHe(e,t){ru(),Hn(e);try{return e.pc(t)}catch(i){if(i=pr(i),re(i,177))return!1;if(re(i,169))return!1;throw Y(i)}}function k5t(e,t){Yr(),Hn(e);try{return e.Qb(t)}catch(i){if(i=pr(i),re(i,177))return!1;if(re(i,169))return!1;throw Y(i)}}function sHe(e,t,i){return new Yf(w.Math.min(e.a,t.a)-i/2,w.Math.min(e.b,t.b)-i/2,w.Math.abs(e.a-t.a)+i,w.Math.abs(e.b-t.b)+i)}function oHe(e,t){var i,a,l,f;for(i=0,l=new j(t.a);l.a0),t.a.cd(t.c=--t.b))}function i1(){i1=M,Ln=new $R("PARENTS",0),ga=new $R("NODES",1),bd=new $R("EDGES",2),lb=new $R("PORTS",3),fm=new $R("LABELS",4)}function Xg(){Xg=M,fb=new WR("DISTRIBUTED",0),wae=new WR("JUSTIFIED",1),fAe=new WR("BEGIN",2),TL=new WR(MP,3),hAe=new WR("END",4)}function HA(e,t,i){EDe.call(this),this.a=le(Xct,Pye,171,(xf(),X(q(Jw,1),Oe,203,0,[aa,Wa,ca])).length,0,1),this.b=e,this.d=t,this.c=i}function l6(e,t){var i,a;if(++e.j,t!=null&&(i=(a=e.a.Cb,re(a,92)?h(a,92).cg():null),IFt(t,i))){VA(e.a,4,i);return}VA(e.a,4,h(t,116))}function R5t(e,t){var i,a;return t!=null&&yw(t).length!=0&&(i=o_e(e,t),i)?i:Pn.length!=0&&(a=o_e(e,Pn),a)?a:null}function I5t(e){var t,i;if(e.j==(Xt(),Nr)){for(i=Cn(t1(e));Gn(i);)if(t=h(Tn(i),14),!Jo(t)&&e.c==Ate(t,e).c)return!0}return!1}function KU(){KU=M,rse=new Xpe("NUM_OF_EXTERNAL_SIDES_THAN_NUM_OF_EXTENSIONS_LAST",0),z3e=new Xpe("CORNER_CASES_THAN_SINGLE_SIDE_LAST",1)}function cte(){return U7(),X(q(ylt,1),Oe,147,0,[vlt,wlt,_lt,ult,llt,flt,plt,dlt,hlt,blt,mlt,glt,alt,olt,clt,rlt,ilt,slt,tlt,elt,nlt,Eae])}function lte(e,t){var i;switch(i=!e.v.pc((Hl(),C1))||e.q==(Ms(),Oa),e.t.g){case 1:i?Jjt(e,t):YKe(e,t);break;case 0:i?gjt(e,t):WKe(e,t)}}function D5t(e,t,i){var a;switch(a=i.q.getFullYear()-V0+V0,a<0&&(a=-a),t){case 1:e.a+=a;break;case 2:ad(e,a%100,2);break;default:ad(e,a,t)}}function B5t(e){var t;switch(t=e.Mh(null),t){case 10:return 0;case 15:return 1;case 14:return 2;case 11:return 3;case 21:return 4}return-1}function ute(e){switch(e.g){case 1:return qs(),hm;case 4:return qs(),rf;case 2:return qs(),sf;case 3:return qs(),rp}return qs(),Oh}function O5t(e,t,i,a){var l,f,g;return l=new Wd(e.e,1,13,(g=t.c,g||(yt(),zh)),(f=i.c,f||(yt(),zh)),$p(e,t),!1),a?a.Sh(l):a=l,a}function Nn(e,t){var i,a;if(g_(t,e.b),t>=e.b>>1)for(a=e.c,i=e.b;i>t;--i)a=a.b;else for(a=e.a.a,i=0;i=0?e.Fg(l):Vte(e,a)):i<0?Vte(e,a):h(a,61).aj().fj(e,e.Qg(),i)}function cHe(e){var t,i,a;for(a=(!e.o&&(e.o=new il((Ta(),op),pm,e,0)),e.o),i=a.c.tc();i.e!=i.i._b();)t=h(i.Ci(),38),t.lc();return CI(a)}function j5t(e){var t,i,a,l;for(a=le(Q$t,et,144,e.c.length,0,1),l=0,i=new j(e);i.a0&&(De(e.b,new r9e(t.a,i)),a=t.a.length,0a&&(t.a+=VNe(le(Zl,Ph,22,-a,15,1))))}function QU(e){switch(Rpe(),this.c=new ke,this.d=e,e.g){case 0:case 2:this.a=T1e(CEe),this.b=Jr;break;case 3:case 1:this.a=CEe,this.b=Ts}}function hwe(e,t){this.e=e,t.5&&f<50;)l=EYe(a),i=Mx(a,l,!0),t=w.Math.abs(i.b),++f;return Mx(e,l,!1)}function fHe(e){var t,i,a,l,f;for(a=yne(e),t=Jr,f=0,l=0;t>.5&&f<50;)l=xYe(a),i=Mx(a,l,!0),t=w.Math.abs(i.a),++f;return Mx(e,l,!1)}function H5t(e,t){var i,a,l,f;for(f=0,a=Nn(e,0);a.b!=a.d.c;)i=h(Un(a),35),f+=w.Math.pow(i.g*i.f-t,2);return l=w.Math.sqrt(f/(e.b-1)),l}function hHe(e,t){var i,a,l;for(i=e.o,l=h(h(er(e.r,t),19),60).tc();l.hc();)a=h(l.ic(),111),a.e.a=GDt(a,i.a),a.e.b=i.b*ce(Xe(a.b.xe(Tj)))}function yx(e,t,i,a){var l;return i>=0?e.Bg(t,i,a):(e.yg()&&(a=(l=e.og(),l>=0?e.jg(a):e.yg().Cg(e,-1-l,null,a))),e.lg(t,i,a))}function xx(e,t,i){var a,l;if(l=e._b(),t>=l)throw Y(new o_(t,l));if(e.xh()&&(a=e.dd(i),a>=0&&a!=t))throw Y(new un(s5));return e.Ah(t,i)}function q5t(e,t,i){var a,l,f,g;return a=e.dd(t),a!=-1&&(e.ti()?(f=e.ui(),g=x9(e,a),l=e.mi(4,g,null,a,f),i?i.Sh(l):i=l):x9(e,a)),i}function Us(e,t,i){var a,l,f,g;return a=e.dd(t),a!=-1&&(e.ti()?(f=e.ui(),g=Ex(e,a),l=e.mi(4,g,null,a,f),i?i.Sh(l):i=l):Ex(e,a)),i}function dHe(e){var t,i,a;e.b==e.c&&(a=e.a.length,i=gbe(8>a?8:a)<<1,e.b!=0?(t=el(e.a,i),g$e(e,t,a),e.a=t,e.b=0):nK(e.a,i),e.c=a)}function X5t(e){var t,i;t=new ke,i=e;do i=h(Tn(Cn(fr(i))),14).d.g,i.j==(Xt(),Nr)&&(t.c[t.c.length]=i);while(i.j==(Xt(),Nr));return t}function pHe(e){var t,i;for(this.b=new ke,this.c=e,this.a=!1,i=new j(e.a);i.a0||e==(Wr(),Hre)||t==(so(),qre))throw Y(new un("Invalid range: "+aze(e,t)))}function Y5t(e){switch(e.g){case 1:return D0(),dD;case 3:return D0(),hD;case 2:return D0(),Mae;case 4:return D0(),Sae;default:return null}}function dte(e){switch(e.g){case 0:return null;case 1:return new C$e;case 2:return new spe;default:throw Y(new un(ure+(e.f!=null?e.f:""+e.g)))}}function Z5t(e,t,i){if(e.e)switch(e.b){case 1:vPt(e.c,t,i);break;case 0:_Pt(e.c,t,i)}else mze(e.c,t,i);e.a[t.o][i.o]=e.c.i,e.a[i.o][t.o]=e.c.e}function _w(){_w=M,jG=new L8(q0,0),Soe=new L8("PORT_POSITION",1),_y=new L8("NODE_SIZE_WHERE_SPACE_PERMITS",2),vy=new L8("NODE_SIZE",3)}function bHe(e){var t,i,a;for(i=new j(e.a);i.a=0?e.ug(g,i,!0):Ax(e,f,i)):h(f,61).aj().cj(e,e.Qg(),l,i,a)}function K5t(e,t){var i,a,l,f;return f=e.o,i=e.p,f=0)return l;if(e.Rj()){for(a=0;al&&Gr(t,l,null),t}function wHe(e,t){var i,a,l;for(l=e.a.length,t.lengthl&&Gr(t,l,null),t}function L_(e,t,i){try{return rw(tee(e,t,i),1)}catch(a){throw a=pr(a),re(a,305)?Y(new Ra(_ie+e.o+"*"+e.p+yie+t+Ca+i+xie)):Y(a)}}function vHe(e,t,i){try{return rw(tee(e,t,i),0)}catch(a){throw a=pr(a),re(a,305)?Y(new Ra(_ie+e.o+"*"+e.p+yie+t+Ca+i+xie)):Y(a)}}function _He(e,t,i){try{return rw(tee(e,t,i),2)}catch(a){throw a=pr(a),re(a,305)?Y(new Ra(_ie+e.o+"*"+e.p+yie+t+Ca+i+xie)):Y(a)}}function yHe(e,t,i){var a;try{return L_(e,t+e.j,i+e.k)}catch(l){throw l=pr(l),re(l,79)?(a=l,Y(new Ra(a.g+Y7+t+Ca+i+")."))):Y(l)}}function J5t(e,t,i){var a;try{return vHe(e,t+e.j,i+e.k)}catch(l){throw l=pr(l),re(l,79)?(a=l,Y(new Ra(a.g+Y7+t+Ca+i+")."))):Y(l)}}function Q5t(e,t,i){var a;try{return _He(e,t+e.j,i+e.k)}catch(l){throw l=pr(l),re(l,79)?(a=l,Y(new Ra(a.g+Y7+t+Ca+i+")."))):Y(l)}}function xHe(e,t){if(e.g==-1)throw Y(new qa);e.Bi();try{e.d.hd(e.g,t),e.f=e.d.j}catch(i){throw i=pr(i),re(i,79)?Y(new P):Y(i)}}function EHe(e,t,i){ii(i,"Compound graph preprocessor",1),e.a=new Kv,HKe(e,t,null),kzt(e,t),n9t(e),Ee(t,(Ie(),YSe),e.a),e.a=null,nl(e.b),On(i)}function pte(e,t){var i,a;if(kge(t>0),(t&-t)==t)return yr(t*al(e,31)*4656612873077393e-25);do i=al(e,31),a=i%t;while(i-a+(t-1)<0);return yr(a)}function eDt(e,t,i){switch(i.g){case 1:e.a=t.a/2,e.b=0;break;case 2:e.a=t.a,e.b=t.b/2;break;case 3:e.a=t.a/2,e.b=t.b;break;case 4:e.a=0,e.b=t.b/2}}function tDt(e){var t,i;for(i=h(G(e,(Ie(),LG)),15).tc();i.hc();)if(t=h(i.ic(),68),cw(t,($e(),DG)))return h(G(t,DG),276);return null}function nDt(e,t){var i,a,l;for(i=b0(new Fm,e),l=new j(t);l.a1&&(f=nDt(e,t)),f}function oDt(e,t){var i,a,l,f;for(f=new j(t.a);f.a102?-1:e<=57?e-48:e<65?-1:e<=70?e-65+10:e<97?-1:e-97+10}function AHe(e,t){var i,a,l;for(e.b[t.g]=1,a=Nn(t.d,0);a.b!=a.d.c;)i=h(Un(a),170),l=i.c,e.b[l.g]==1?Gi(e.a,i):e.b[l.g]==2?e.b[l.g]=1:AHe(e,l)}function PHe(e,t){var i;return i=X(q(ks,1),Wo,22,15,[Gee(e.a[0],t),Gee(e.a[1],t),Gee(e.a[2],t)]),e.d&&(i[0]=w.Math.max(i[0],i[2]),i[2]=i[0]),i}function LHe(e,t){var i;return i=X(q(ks,1),Wo,22,15,[IU(e.a[0],t),IU(e.a[1],t),IU(e.a[2],t)]),e.d&&(i[0]=w.Math.max(i[0],i[2]),i[2]=i[0]),i}function aDt(e){var t,i,a;for(PR(e.b.a),e.a=le(Hz,et,57,e.c.c.a.b.c.length,0,1),t=0,a=new j(e.c.c.a.b);a.aa&&e.charCodeAt(t-1)<=32;)--t;return a>0||tf&&Gr(t,f,null),t}function Ete(e){Mo();var t;if(t=LIt(e),!Gn(e))throw Y(new Ra("position (0) must be less than the number of elements that remained ("+t+")"));return Tn(e)}function CDt(e){var t;return t=(qje(),Nnt),t[e>>>28]|t[e>>24&15]<<4|t[e>>20&15]<<8|t[e>>16&15]<<12|t[e>>12&15]<<16|t[e>>8&15]<<20|t[e>>4&15]<<24|t[e&15]<<28}function DHe(e){var t,i,a;for(a=e.f,e.k=le(ks,Wo,22,a,15,1),e.d=le(ks,Wo,22,a,15,1),t=0;t0&&(l.b+=t),l}function r7(e,t){var i,a,l;for(l=new fo,a=e.tc();a.hc();)i=h(a.ic(),31),A6(i,0,l.b),l.b+=i.e.b+t,l.a=w.Math.max(l.a,i.e.a);return l.a>0&&(l.a+=t),l}function RDt(e,t){var i,a;if(t<0||t>=e._b())return null;for(i=t;i=e.i)throw Y(new JK(t,e.i));return++e.j,i=e.g[t],a=e.i-t-1,a>0&&vc(e.g,t+1,e.g,t,a),Gr(e.g,--e.i,null),e.vh(t,i),e.th(),i}function Mte(e,t){var i,a;return e.Db>>16==6?e.Cb.Cg(e,5,ah,t):(a=Uo(h(Wt((i=h(sn(e,16),24),i||e.Rg()),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function Ewe(e,t){var i,a;i=e.fd(t);try{return a=i.ic(),i.jc(),a}catch(l){throw l=pr(l),re(l,101)?Y(new Ra("Can't remove element "+t)):Y(l)}}function NDt(e,t){var i,a,l;return l=new di(new Bl(X(q(cVt,1),et,1700,0,[e,t])),16),a=new I8e(l),i=new oi(null,a),p1e(i,new CY(e)),p1e(i,new AY(t)),i}function Swe(e,t,i,a,l,f){var g,m,v;for(Be(e)===Be(i)&&(e=e.slice(t,t+l),t=0),m=t,v=t+l;m>22),l+=a>>22,l<0)?!1:(e.l=i&Yc,e.m=a&Yc,e.h=l&Kd,!0)}function VDt(e,t,i,a,l,f,g){var m,v;return!(t.je()&&(v=e.a.Ld(i,a),v<0||!l&&v==0)||t.ke()&&(m=e.a.Ld(i,f),m>0||!g&&m==0))}function Sx(){Sx=M,m5=new C8("NORTH",0),g5=new C8("EAST",1),b5=new C8("SOUTH",2),w5=new C8("WEST",3),m5.a=!1,g5.a=!0,b5.a=!1,w5.a=!0}function YA(){YA=M,v5=new A8("NORTH",0),qz=new A8("EAST",1),Xz=new A8("SOUTH",2),_5=new A8("WEST",3),v5.a=!1,qz.a=!0,Xz.a=!1,_5.a=!0}function xl(){xl=M,fD=new N8("UNKNOWN",0),Ed=new N8("ABOVE",1),dm=new N8("BELOW",2),uD=new N8("INLINE",3),new Zr("org.eclipse.elk.labelSide",fD)}function Yg(e,t,i){if(i&&(t<0||t>i.a.c.length))throw Y(new un("index must be >= 0 and <= layer node count"));e.c&&Sa(e.c.a,e),e.c=i,i&&_0(i.a,t,e)}function GHe(e){switch(e.g){case 0:return qse;case 1:return Xse;case 2:return Yse;case 3:return Zse;case 4:return wG;case 5:return Kse;default:return null}}function PS(){PS=M,JG=new k8("P1_TREEIFICATION",0),dL=new k8("P2_NODE_ORDERING",1),q5=new k8("P3_NODE_PLACEMENT",2),pL=new k8("P4_EDGE_ROUTING",3)}function Co(e,t,i){var a,l;return a=(l=new aK,ES(l,t),Sf(l,i),$n((!e.c&&(e.c=new ze(nv,e,12,10)),e.c),l),l),E_(a,0),mS(a,1),A_(a,!0),C_(a,!0),a}function jHe(e,t){var i,a;return e.Db>>16==17?e.Cb.Cg(e,21,Lu,t):(a=Uo(h(Wt((i=h(sn(e,16),24),i||e.Rg()),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function WDt(e,t){var i,a,l;if(a=new T8,l=new bbe(a.q.getFullYear()-V0,a.q.getMonth(),a.q.getDate()),i=czt(e,t,l),i==0||i>16==6?e.Cb.Cg(e,6,js,t):(a=Uo(h(Wt((i=h(sn(e,16),24),i||(Ta(),Cj)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function Pwe(e,t){var i,a;return e.Db>>16==7?e.Cb.Cg(e,1,pD,t):(a=Uo(h(Wt((i=h(sn(e,16),24),i||(Ta(),SAe)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function Lwe(e,t){var i,a;return e.Db>>16==9?e.Cb.Cg(e,9,Br,t):(a=Uo(h(Wt((i=h(sn(e,16),24),i||(Ta(),TAe)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function kwe(e,t){var i,a;return e.Db>>16==3?e.Cb.Cg(e,12,Br,t):(a=Uo(h(Wt((i=h(sn(e,16),24),i||(Ta(),EAe)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function Rwe(e,t){var i,a;return e.Db>>16==3?e.Cb.Cg(e,0,mD,t):(a=Uo(h(Wt((i=h(sn(e,16),24),i||(yt(),A1)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function VHe(e,t){var i,a;return e.Db>>16==7?e.Cb.Cg(e,6,ah,t):(a=Uo(h(Wt((i=h(sn(e,16),24),i||(yt(),k1)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function WHe(e,t){var i,a;return e.Db>>16==5?e.Cb.Cg(e,9,Oj,t):(a=Uo(h(Wt((i=h(sn(e,16),24),i||(yt(),P1)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function LS(e,t){var i,a;if(t){if(t==e)return!0;for(i=0,a=h(t,42).yg();a&&a!=t;a=a.yg()){if(++i>uie)return LS(e,a);if(a==e)return!0}}return!1}function rBt(e){var t,i;t=h(G(e,(Tf(),Cit)),21),t?(i=t.a,i==0?Ee(e,(Fg(),eG),new Jee):Ee(e,(Fg(),eG),new J9(i))):Ee(e,(Fg(),eG),new J9(1))}function sBt(e,t){var i;switch(i=e.g,t.g){case 1:return-(e.k.b+e.n.b);case 2:return e.k.a-i.n.a;case 3:return e.k.b-i.n.b;case 4:return-(e.k.a+e.n.a)}return 0}function Iwe(e,t,i,a){var l,f,g;if(e.a[t.o]==-1)for(e.a[t.o]=i,e.b[t.o]=a,f=Cn(fr(t));Gn(f);)l=h(Tn(f),14),!Jo(l)&&(g=l.d.g,Iwe(e,g,i+1,a))}function oBt(e){switch(t9(),e.q.g){case 5:CXe(e,(Fe(),bn)),CXe(e,ni);break;case 4:mYe(e,(Fe(),bn)),mYe(e,ni);break;default:QKe(e,(Fe(),bn)),QKe(e,ni)}}function aBt(e){switch(t9(),e.q.g){case 5:FXe(e,(Fe(),Zt)),FXe(e,nn);break;case 4:hHe(e,(Fe(),Zt)),hHe(e,nn);break;default:eJe(e,(Fe(),Zt)),eJe(e,nn)}}function pu(e){var t;return!(e.Bb&1)&&e.r&&e.r.Eg()&&(t=h(e.r,42),e.r=h(jg(e,t),133),e.r!=t&&e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,9,8,t,e.r))),e.r}function ZA(e,t,i){var a,l;a=t*i,re(e.g,153)?(l=ux(e),l.f.d?l.f.a||(e.d.a+=a+gd):(e.d.d-=a+gd,e.d.a+=a+gd)):re(e.g,8)&&(e.d.d-=a,e.d.a+=2*a)}function HHe(){M7(),this.c=new ke,this.i=new ke,this.e=new Gc,this.f=new Gc,this.g=new Gc,this.j=new ke,this.a=new ke,this.b=(Yr(),new ui),this.k=new ui}function cBt(e,t){var i,a,l,f;for(ii(t,"Dull edge routing",1),f=Nn(e.b,0);f.b!=f.d.c;)for(l=h(Un(f),76),a=Nn(l.d,0);a.b!=a.d.c;)i=h(Un(a),170),rd(i.a)}function Cte(e,t,i){var a;return a=X(q(ks,1),Wo,22,15,[tve(e,(xf(),aa),t,i),tve(e,Wa,t,i),tve(e,ca,t,i)]),e.f&&(a[0]=w.Math.max(a[0],a[2]),a[2]=a[0]),a}function lBt(){I7();var e,t;try{if(t=h(Wwe((Sg(),ku),tM),1698),t)return t}catch(i){if(i=pr(i),re(i,104))e=i,Ime((zn(),e));else throw Y(i)}return new Dm}function uBt(){I7();var e,t;try{if(t=h(Wwe((Sg(),ku),wu),1635),t)return t}catch(i){if(i=pr(i),re(i,104))e=i,Ime((zn(),e));else throw Y(i)}return new AN}function fBt(){NGe();var e,t;try{if(t=h(Wwe((Sg(),ku),v1),1710),t)return t}catch(i){if(i=pr(i),re(i,104))e=i,Ime((zn(),e));else throw Y(i)}return new tC}function Dwe(e,t){var i,a;return e.Db>>16==11?e.Cb.Cg(e,10,Br,t):(a=Uo(h(Wt((i=h(sn(e,16),24),i||(Ta(),MAe)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function qHe(e,t){var i,a;return e.Db>>16==10?e.Cb.Cg(e,11,Lu,t):(a=Uo(h(Wt((i=h(sn(e,16),24),i||(yt(),L1)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function XHe(e,t){var i,a;return e.Db>>16==10?e.Cb.Cg(e,12,uf,t):(a=Uo(h(Wt((i=h(sn(e,16),24),i||(yt(),rv)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function hBt(e,t){var i,a,l,f,g;if(t)for(l=t.a.length,i=new jm(l),g=(i.b-i.a)*i.c<0?(Mg(),mm):new Cg(i);g.hc();)f=h(g.ic(),21),a=uS(t,f.a),a&&rYe(e,a)}function dBt(){Ope();var e,t;for(U$t((kg(),Ct)),R$t(Ct),Tte(Ct),zAe=(yt(),zh),t=new j(YAe);t.a>19,y=t.h>>19,v!=y?y-v:(l=e.h,m=t.h,l!=m?l-m:(a=e.m,g=t.m,a!=g?a-g:(i=e.l,f=t.l,i-f)))}function pBt(e,t){var i,a,l;if(a=e.b.d.d,e.a||(a+=e.b.d.a),l=t.b.d.d,t.a||(l+=t.b.d.a),i=to(a,l),i==0){if(!e.a&&t.a)return-1;if(!t.a&&e.a)return 1}return i}function gBt(e,t){var i,a,l;if(a=e.b.g.d,e.a||(a+=e.b.g.a),l=t.b.g.d,t.a||(l+=t.b.g.a),i=to(a,l),i==0){if(!e.a&&t.a)return-1;if(!t.a&&e.a)return 1}return i}function mBt(e,t,i,a){var l,f,g,m;for(l=0;lg&&(m=g/a),l>f&&(v=f/l),au(e,w.Math.min(m,v)),e}function wBt(e,t,i){var a,l;return l=e.e,e.e=t,e.Db&4&&!(e.Db&1)&&(a=new ls(e,1,4,l,t),i?i.Sh(a):i=a),l!=t&&(t?i=GS(e,x7(e,t),i):i=GS(e,e.a,i)),i}function JHe(){T8.call(this),this.e=-1,this.a=!1,this.p=zs,this.k=-1,this.c=-1,this.b=-1,this.g=!1,this.f=-1,this.j=-1,this.n=-1,this.i=-1,this.d=-1,this.o=zs}function vBt(e,t){var i,a;for(a=new j(t);a.a=0?(i=h6(e,W7),a=i6(e,W7)):(t=c_(e,1),i=h6(t,5e8),a=i6(t,5e8),a=no(jd(a,1),Kr(e,1))),Zf(jd(a,32),Kr(i,ao))}function s7(){s7=M,Z3e=(A7(),ose),Y3e=new ln(oye,Z3e),X3e=(dU(),sse),q3e=new ln(aye,X3e),H3e=(KU(),rse),W3e=new ln(cye,H3e),V3e=new ln(lye,(vt(),vt(),!0))}function Ate(e,t){if(t==e.c.g)return e.d.g;if(t==e.d.g)return e.c.g;throw Y(new un("'node' must either be the source node or target node of the edge."))}function EBt(e,t,i){var a,l;for(ii(i,"Interactive node placement",1),e.a=h(G(t,(Ie(),Uw)),266),l=new j(t.b);l.a0&&(g=(f&zi)%e.d.length,l=_ve(e,g,f,t),l)?(m=l.mc(i),m):(a=e.Ii(f,t,i),e.c.nc(a),null)}function Uwe(e,t){var i,a,l,f;switch(jp(e,t).lk()){case 3:case 2:{for(i=V_(t),l=0,f=i.i;l=0;a--)if(dt(e[a].d,t)||dt(e[a].d,i)){e.length>=a+1&&e.splice(0,a+1);break}return e}function zwe(e,t,i){this.b=new s9,this.i=new ke,this.d=new Uc(this),this.g=e,this.a=t.c.length,this.c=t,this.e=h(St(this.c,this.c.c.length-1),8),this.f=i,fzt(this)}function iqe(){this.a=new Xq,this.g=new i9,this.j=new i9,this.b=(Yr(),new ui),this.d=new i9,this.i=new i9,this.k=new ui,this.c=new ui,this.e=new ui,this.f=new ui}function RBt(e){var t,i,a,l,f;for(a=new Zm(new Ep(e.b).a);a.b;)i=k0(a),t=h(i.kc(),8),f=h(h(i.lc(),48).a,8),l=h(h(i.lc(),48).b,9),tr(Wf(t.k),tr(Ua(f.k),l))}function JA(){JA=M,Use=new zR("MEDIAN_LAYER",0),zse=new zR("WIDEST_LAYER",1),Nse=new zR("CENTER_LAYER",2),vSe=new zR("TAIL_LAYER",3),Fse=new zR("HEAD_LAYER",4)}function IBt(e){var t,i,a;for(i=new j(e.p);i.ai);return l}function jwe(e,t,i){switch(t){case 1:!e.n&&(e.n=new ze(ea,e,1,7)),Pr(e.n),!e.n&&(e.n=new ze(ea,e,1,7)),Mr(e.n,h(i,13));return;case 2:jI(e,ti(i));return}xbe(e,t,i)}function $we(e,t,i){switch(t){case 3:y_(e,ce(Xe(i)));return;case 4:x_(e,ce(Xe(i)));return;case 5:Yu(e,ce(Xe(i)));return;case 6:Zu(e,ce(Xe(i)));return}jwe(e,t,i)}function a7(e,t,i){var a,l,f;f=(a=new aK,a),l=Zg(f,t,null),l&&l.Th(),Sf(f,i),$n((!e.c&&(e.c=new ze(nv,e,12,10)),e.c),f),E_(f,0),mS(f,1),A_(f,!0),C_(f,!0)}function Vwe(e){var t;return e.Db&64?HU(e):(t=new su(HU(e)),t.a+=" (abstract: ",Ap(t,(e.Bb&256)!=0),t.a+=", interface: ",Ap(t,(e.Bb&512)!=0),t.a+=")",t.a)}function Wwe(e,t){var i,a,l;return i=NC(e.e,t),re(i,207)?(l=h(i,207),l.gh()==null,l.dh()):re(i,456)?(a=h(i,1631),l=a.b,l):null}function aqe(e,t){var i;if(this.f=e,this.b=this.f.c,i=e.d,IQ(t,i),t>=(i/2|0))for(this.e=e.e,this.d=i;t++0;)eze(this);this.a=null}function cqe(e,t,i,a,l,f,g){var m,v,y,E,C;if(E=l[f],y=f==g-1,m=y?a:0,C=IHe(m,E),a!=10&&X(q(e,g-f),t[f],i[f],m,C),!y)for(++f,v=0;v0&&po(e,e.length-1)==33)try{return t=PXe(qf(e,0,e.length-1)),t.e==null}catch(i){if(i=pr(i),!re(i,30))throw Y(i)}return!1}function VBt(e,t,i){var a,l,f,g;for(i=yx(t,e.e,-1-e.c,i),g=E1e(e.a),f=(a=new Zm(new Ep(g.a).a),new wC(a));f.a.b;)l=h(k0(f.a).kc(),84),i=GS(l,x7(l,e.a),i);return i}function WBt(e,t,i){var a,l,f,g;for(i=j9(t,e.e,-1-e.c,i),g=E1e(e.a),f=(a=new Zm(new Ep(g.a).a),new wC(a));f.a.b;)l=h(k0(f.a).kc(),84),i=GS(l,x7(l,e.a),i);return i}function lqe(e){var t,i,a;if(e==null)return null;if(i=h(e,15),i.Wb())return"";for(a=new Tp,t=i.tc();t.hc();)ho(a,(lr(),ti(t.ic()))),a.a+=" ";return E8(a,a.a.length-1)}function uqe(e){var t,i,a;if(e==null)return null;if(i=h(e,15),i.Wb())return"";for(a=new Tp,t=i.tc();t.hc();)ho(a,(lr(),ti(t.ic()))),a.a+=" ";return E8(a,a.a.length-1)}function HBt(e,t){DS();var i,a;for(a=(Kg(),Gz),i=e;t>1;t>>=1)t&1&&(a=m_(a,i)),i.d==1?i=m_(i,i):i=new QWe(TZe(i.a,i.d,le(In,si,22,i.d<<1,15,1)));return a=m_(a,i),a}function tP(e,t){return e.b.a=w.Math.min(e.b.a,t.c),e.b.b=w.Math.min(e.b.b,t.d),e.a.a=w.Math.max(e.a.a,t.c),e.a.b=w.Math.max(e.a.b,t.d),e.c[e.c.length]=t,!0}function qBt(e){var t,i,a,l;for(l=-1,a=0,i=new j(e);i.a=0&&dt(e.substr(t,3),"GMT")||t>=0&&dt(e.substr(t,3),"UTC"))&&(i[0]=t+3),h_e(e,i,a)}function Ywe(){Ywe=M;var e,t,i,a;for(R3e=le(ks,Wo,22,25,15,1),I3e=le(ks,Wo,22,33,15,1),a=152587890625e-16,t=32;t>=0;t--)I3e[t]=a,a*=.5;for(i=1,e=24;e>=0;e--)R3e[e]=i,i*=.5}function mqe(e,t,i){var a,l;switch(a=(Rn(t.b!=0),h(Xu(t,t.a.a),9)),i.g){case 0:a.b=0;break;case 2:a.b=e.f;break;case 3:a.a=0;break;default:a.a=e.g}return l=Nn(t,0),QE(l,a),t}function u7(){u7=M,Eoe=new jC(FQe,0),uTe=new jC("LONGEST_PATH",1),xoe=new jC("COFFMAN_GRAHAM",2),lTe=new jC(Die,3),fTe=new jC("STRETCH_WIDTH",4),GG=new jC("MIN_WIDTH",5)}function hOt(e,t){var i,a,l,f;for(i=0,a=0,f=new j(t.b);f.ai;f--)e[f]|=t[f-i-1]>>>g,e[f-1]=t[f-i-1]<=e.f)break;f.c[f.c.length]=i}return f}function bOt(e,t,i){var a,l,f;return f=0,a=i[t],t>4&15,f=e[a]&15,g[l++]=CAe[i],g[l++]=CAe[f];return hu(g,0,g.length)}function vqe(e,t,i){var a,l,f,g,m;for(a=i._b(),eHe(e,e.i+a),m=e.i-t,m>0&&vc(e.g,t,e.g,t+a,m),g=i.tc(),e.i+=a,l=0;l=oo?(t=$6+(e-oo>>10&1023)&jr,i=56320+(e-oo&1023)&jr,String.fromCharCode(t)+(""+String.fromCharCode(i))):String.fromCharCode(e&jr)}function SOt(e){var t,i,a;for(a=e.e.c.length,e.a=uw(In,[be,si],[37,22],15,[a,a],2),i=new j(e.c);i.a0&&UHe(this,this.c-1,(Fe(),Zt)),this.c1&&(t.c[t.c.length]=f))}function TOt(e){var t,i,a;for(i=new Bn((!e.a&&(e.a=new ze(Br,e,10,11)),e.a));i.e!=i.i._b();)if(t=h(Yn(i),35),a=S6(t),!Gn((Mo(),new Nd(Kh(Gd(a.a,new z))))))return t;return null}function _qe(e,t,i){var a,l;for(l=new Bn((!e.a&&(e.a=new ze(Br,e,10,11)),e.a));l.e!=l.i._b();)a=h(Yn(l),35),Od(a,a.i+t,a.j+i);mo((!e.b&&(e.b=new ze(js,e,12,3)),e.b),new XOe(t,i))}function yqe(e,t,i,a,l){var f,g,m;for(f=ZYe(e,t,i,a,l),m=!1;!f;)v7(e,l,!0),m=!0,f=ZYe(e,t,i,a,l);m&&v7(e,l,!1),g=PU(l),g.c.length!=0&&(e.d&&e.d.If(g),yqe(e,l,i,a,g))}function eve(e,t){var i;i=za((Sg(),ku),e),re(i,456)?Ko(ku,e,new gNe(this,t)):Ko(ku,e,this),ove(this,t),t==(IE(),UAe)?(this.wb=h(this,1633),h(t,1635)):this.wb=(kg(),Ct)}function COt(e){var t,i,a;if(e==null)return null;for(t=null,i=0;i0;){if(i=a,a=(a-1)/2|0,e.a.Ld(St(e.b,a),t)<=0)return Hu(e.b,i,t),!0;Hu(e.b,i,St(e.b,a))}return Hu(e.b,a,t),!0}function ROt(e){for(var t,i,a,l;e.o.a.c.length!=0;)i=h(Abe(e.o),48),a=h(i.a,113),t=h(i.b,189),l=jU(t,a),t.e==a?(J8(l.g,t),a.e=l.e+t.a):(J8(l.b,t),a.e=l.e-t.a),De(e.e.a,a)}function tve(e,t,i,a){var l,f;if(l=0,i)l=IU(e.a[i.g][t.g],a);else for(f=0;fuie)return Mqe(i);if(a=i,i==e)throw Y(new ba("There is a cycle in the containment hierarchy of "+e))}return a}function Tqe(){Tqe=M,$nt=X(q(Se,1),be,2,6,["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]),Vnt=X(q(Se,1),be,2,6,["Jan","Feb","Mar","Apr",Bx,"Jun","Jul","Aug","Sep","Oct","Nov","Dec"])}function DOt(e,t,i,a){var l,f;for(f=t,l=f.d==null||e.a.Ld(i.d,f.d)>0?1:0;f.a[l]!=i;)f=f.a[l],l=e.a.Ld(i.d,f.d)>0?1:0;f.a[l]=a,a.b=i.b,a.a[0]=i.a[0],a.a[1]=i.a[1],i.a[0]=null,i.a[1]=null}function _o(){_o=M,Dh=new FR("P1_CYCLE_BREAKING",0),Zx=new FR("P2_LAYERING",1),Qa=new FR("P3_NODE_ORDERING",2),ec=new FR("P4_NODE_PLACEMENT",3),qo=new FR("P5_EDGE_ROUTING",4)}function Cqe(e){var t,i;return i=w.Math.sqrt(e.f*(e.i==null&&(e.i=obe(e,new ta)),ce(e.i))/(e.b*(e.g==null&&(e.g=x$e(e,new Dl)),ce(e.g)))),t=nr(Wc(w.Math.round(i))),t=d0(t,e.f),t}function Aqe(e){var t,i;i=e.k,t=tr(new $t(i.a,i.b),e.n),this.d=w.Math.min(i.b,t.b),this.a=w.Math.max(i.b,t.b),this.b=w.Math.min(i.a,t.a),this.c=w.Math.max(i.a,t.a)}function BOt(e){var t,i;if(e.a>=e.c.c.length)return tS(),GP;if(i=$(e),e.a>=e.c.c.length)return new $2(i);t=new Gc,Cr(t,Hn(i));do Cr(t,Hn($(e)));while(e.a0&&IZe((ai(0,i.c.length),h(i.c[0],26)),e),i.c.length>1&&IZe(h(St(i,i.c.length-1),26),e),On(t)}function FOt(e,t,i,a){var l,f,g,m,v;return g=zHe(e.a,t,i),m=h(g.a,21).a,f=h(g.b,21).a,a&&(v=h(G(t,(Ie(),Pl)),8),l=h(G(i,Pl),8),v&&l&&(mze(e.b,v,l),m+=e.b.i,f+=e.b.e)),m>f}function Lqe(e,t){var i,a,l;if(ive(e,t))return!0;for(a=new j(t);a.af&&aAt(y,lje(i[m],P3e))&&(l=m,f=v);return l>=0&&(a[0]=t+f),l}function h7(e,t){var i,a,l;if(l=0,a=t[0],a>=e.length)return-1;for(i=e.charCodeAt(a);i>=48&&i<=57&&(l=l*10+(i-48),++a,!(a>=e.length));)i=e.charCodeAt(a);return a>t[0]?t[0]=a:l=-1,l}function GOt(e,t){var i,a,l;return a=(YA(),v5),l=w.Math.abs(e.b),i=w.Math.abs(t.f-e.b),iSJ(e.d).c?(e.i+=e.g.c,rte(e.d)):SJ(e.d).c>SJ(e.g).c?(e.e+=e.d.c,rte(e.g)):(e.i+=x9e(e.g),e.e+=x9e(e.d),rte(e.g),rte(e.d))}function IS(){IS=M,ZP=new GC(q0,0),NSe=new GC(XS,1),zSe=new GC(YS,2),USe=new GC("LEFT_RIGHT_CONSTRAINT_LOCKING",3),FSe=new GC("LEFT_RIGHT_CONNECTION_LOCKING",4),OSe=new GC(CQe,5)}function VOt(e){var t,i,a,l,f,g;for(a=kZe(yne(e)),t=Jr,f=0,l=0;t>.5&&f<50;)l=EYe(a),i=Mx(a,l,!0),t=w.Math.abs(i.b),++f;return g=Xe(qg(cu(e.g),cu(e.g).b-1)),Mx(e,(dn(g),g-l),!1)}function WOt(e){var t,i,a,l,f,g;for(a=kZe(yne(e)),t=Jr,f=0,l=0;t>.5&&f<50;)l=xYe(a),i=Mx(a,l,!0),t=w.Math.abs(i.a),++f;return g=Xe(qg(cu(e.g),cu(e.g).b-1)),Mx(e,(dn(g),g-l),!1)}function Iqe(e,t,i,a){e.a.d=w.Math.min(t,i),e.a.a=w.Math.max(t,a)-e.a.d,tm&&(v=m/a),l>f&&(y=f/l),g=w.Math.min(v,y),e.a+=g*(t.a-e.a),e.b+=g*(t.b-e.b)}function YOt(e,t){r9();var i,a,l,f;if(t.b<2)return!1;for(f=Nn(t,0),i=h(Un(f),9),a=i;f.b!=f.d.c;){if(l=h(Un(f),9),vYe(e,a,l))return!0;a=l}return!!vYe(e,a,i)}function sve(e,t,i,a){var l,f;return i==0?(!e.o&&(e.o=new il((Ta(),op),pm,e,0)),f9(e.o,t,a)):(f=h(Wt((l=h(sn(e,16),24),l||e.Rg()),i),61),f.aj().ej(e,Ya(e),i-jn(e.Rg()),t,a))}function ZOt(e,t){var i;t!=e.a?(i=null,e.a&&(i=h(e.a,42).Cg(e,4,ah,null)),t&&(i=h(t,42).Ag(e,4,ah,i)),i=Rbe(e,t,i),i&&i.Th()):e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,1,t,t))}function Oqe(e){var t;return e.Db&64?Ote(e):(t=new ou(dxe),!e.a||Mi(Mi((t.a+=' "',t),e.a),'"'),Mi(g0(Mi(g0(Mi(g0(Mi(g0((t.a+=" (",t),e.i),","),e.j)," | "),e.g),","),e.f),")"),t.a)}function KOt(e){var t,i,a,l,f,g,m,v,y;return y=Zwe(e),i=e.e,f=i!=null,f&&sA(y,bz,e.e),m=e.k,g=!!m,g&&sA(y,"type",tI(e.k)),a=x8(e.j),l=!a,l&&(v=new Om,Og(y,Ere,v),t=new $Z(v),mo(e.j,t)),y}function JOt(e,t){var i;if(t!=null&&!e.c.jj().Li(t))throw i=re(t,51)?h(t,51).mg().zb:Um(sl(t)),Y(new xC(ry+e.c.be()+"'s type '"+e.c.jj().be()+"' does not permit a value of type '"+i+"'"))}function QOt(e,t){var i,a,l,f;if(dn(t),f=e.a._b(),f>22-t,l=e.h<>22-t):t<44?(i=0,a=e.l<>44-t):(i=0,a=0,l=e.l<>>l|i[g+a+1]<>>l,++g}return f}function Fqe(e){vwe();var t,i,a,l;return a=h(G(e,($e(),IG)),318),l=ce(mt(G(e,poe)))||Be(G(e,mM))===Be((fx(),S5)),t=h(G(e,MMe),21).a,i=e.a.c.length,!l&&a!=(bS(),EG)&&(t==0||t>i)}function iNt(e,t,i){var a,l;for(l=new Ns(e.b,0);l.b=g)return li.a._b()?h(St(a,l-i.a._b()-1),8):null;return null}function ove(e,t){var i;t!=e.sb?(i=null,e.sb&&(i=h(e.sb,42).Cg(e,1,kL,null)),t&&(i=h(t,42).Ag(e,1,kL,i)),i=Dbe(e,t,i),i&&i.Th()):e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,4,t,t))}function oNt(e,t,i){var a,l,f,g,m;if(i)for(l=i.a.length,a=new jm(l),m=(a.b-a.a)*a.c<0?(Mg(),mm):new Cg(a);m.hc();)g=h(m.ic(),21),f=uS(i,g.a),vxe in f.a||Ere in f.a?PUt(e,f,t):D$t(e,f,t)}function zqe(e){switch(e.g){case 0:return new hK((R0(),HG));case 1:return new cC;default:throw Y(new un("No implementation is available for the crossing minimizer "+(e.f!=null?e.f:""+e.g)))}}function aNt(e){Zve();var t,i,a,l,f;if(e==null)return null;for(a=e.length,l=a*2,t=le(Zl,Ph,22,l,15,1),i=0;i>4],t[i*2+1]=$j[f&15];return hu(t,0,t.length)}function yo(){qd(),fme.call(this),this.i=(Fe(),Na),this.a=new fo,new ope,this.e=(Ef(2,Dx),new Gl(2)),this.d=(Ef(4,Dx),new Gl(4)),this.f=(Ef(4,Dx),new Gl(4)),this.c=new _Oe(this.d,this.f)}function cNt(e,t){var i,a;return!(ce(mt(G(t,(Ie(),om))))||e==(du(),I5)&&(a=t.c.g,a.j==(Xt(),ul)||(i=h(G(a,($e(),tc)),178),i==zw)))}function lNt(e,t){var i,a;return!(ce(mt(G(t,(Ie(),om))))||e==(du(),QP)&&(a=t.d.g,a.j==(Xt(),ul)||(i=h(G(a,($e(),tc)),178),i==ib)))}function uNt(e,t){var i,a,l;i=OCt(t,e.e),a=h(Ii(e.g.f,i),21).a,l=e.a.c.length-1,e.a.c.length!=0&&h(St(e.a,l),269).c==a?(++h(St(e.a,l),269).a,++h(St(e.a,l),269).b):De(e.a,new NFe(a))}function Gqe(e,t,i,a,l){if(aa&&(e.a=a),e.bl&&(e.b=l),e}function fNt(e){if(re(e,180))return s9t(h(e,180));if(re(e,199))return j6t(h(e,199));if(re(e,27))return KOt(h(e,27));throw Y(new un(Txe+Vp(new Bl(X(q(on,1),et,1,5,[e])))))}function Hc(e,t){switch(t.g){case 1:return zd(e.i,(qd(),kEe));case 2:return zd(e.i,(qd(),LEe));case 3:return zd(e.i,(qd(),REe));case 4:return zd(e.i,(qd(),IEe));default:return _t(),_t(),uo}}function jqe(e){var t;this.a=e,t=(Xt(),X(q(xse,1),Oe,232,0,[hs,Nr,Qr,oa,ul,$a,ih])).length,this.b=uw(hCe,[be,UQe],[616,166],0,[t,t],2),this.c=uw(hCe,[be,UQe],[616,166],0,[t,t],2),wzt(this)}function hNt(e){var t,i;return i=h(G(e,(Ie(),Va)),19),t=new ss,(i.pc((xo(),dy))||ce(mt(G(e,($e(),D5)))))&&(oc(t,Jot),i.pc(py)&&oc(t,Qot)),i.pc(hM)&&oc(t,Zot),i.pc(dM)&&oc(t,Kot),t}function $qe(e,t,i){var a,l,f,g;if(t.b!=0){for(a=new Ir,g=Nn(t,0);g.b!=g.d.c;)f=h(Un(g),76),wo(a,dbe(f)),l=f.e,l.a=h(G(f,(ha(),Goe)),21).a,l.b=h(G(f,BTe),21).a;$qe(e,a,bc(i,a.b/e.a|0))}}function m6(e){var t,i,a;for(a=new zc,Gi(a,new $t(e.j,e.k)),i=new Bn((!e.a&&(e.a=new vs(oh,e,5)),e.a));i.e!=i.i._b();)t=h(Yn(i),531),Gi(a,new $t(t.a,t.b));return Gi(a,new $t(e.b,e.c)),a}function dNt(e,t,i,a,l){var f,g,m,v,y,E;if(l)for(v=l.a.length,f=new jm(v),E=(f.b-f.a)*f.c<0?(Mg(),mm):new Cg(f);E.hc();)y=h(E.ic(),21),m=uS(l,y.a),g=new CUe(e,t,i,a),d7t(g.a,g.b,g.c,g.d,m)}function F_(e){lw();var t,i,a;for(a=new Gc,qI(a,e),i=a.a.Xb().tc();i.hc();)t=i.ic(),Hn(t);switch(a.a._b()){case 0:return tS(),GP;case 1:return new $2(a.a.Xb().tc().ic());default:return new TK(a)}}function ave(e,t){var i,a,l;for(l=zi,a=new j(P_(t));a.a1&&(e.e.b+=e.a)):(e.e.a+=i.a,e.e.b=w.Math.max(e.e.b,i.b),e.d.c.length>1&&(e.e.a+=e.a))}function Vqe(e,t,i){var a,l,f,g;if(f=h(sn(e.a,8),1629),f!=null)for(a=0,l=f.length;a1)throw Y(new un("In straight spline segments there may be only one edge."));a=e.a.c,i=e.a.c+e.a.b,Gi(h(t.a.Xb().tc().ic(),14).a,new $t(a+(i-a)/2,e.b))}function Wqe(e,t,i,a){var l;this.b=a,this.e=e==(R0(),lL),l=t[i],this.d=uw(Ru,[be,f1],[221,22],16,[l.length,l.length],2),this.a=uw(In,[be,si],[37,22],15,[l.length,l.length],2),this.c=new Jwe(t,i)}function Fte(e){var t,i,a;if(e.a==null)for(e.a=le(Ru,f1,22,e.c.b.c.length,16,1),e.a[0]=!1,a=new j(e.c.b),a.a>>t,l=e.m>>t|i<<22-t,a=e.l>>t|e.m<<22-t):t<44?(f=0,l=i>>>t-22,a=e.m>>t-22|e.h<<44-t):(f=0,l=0,a=i>>>t-44),Xa(a&Yc,l&Yc,f&Kd)}function qqe(e,t,i){var a,l,f,g,m;for(m=cl(e.e.mg(),t),l=h(e.g,124),a=0,g=0;gi?uve(e,i,"start index"):t<0||t>i?uve(t,i,"end index"):E6("end index (%s) must not be less than start index (%s)",X(q(on,1),et,1,5,[He(t),He(e)]))}function Xqe(e,t){var i,a,l;if(t===e)return!0;if(!re(t,109)||(l=h(t,109),e._b()!=l._b()))return!1;for(a=l.Tb().tc();a.hc();)if(i=h(a.ic(),38),!e.Wc(i))return!1;return!0}function Yqe(e,t){var i,a,l,f;for(a=0,l=e.length;a0?m[g-1]:le(Eu,Cf,8,0,0,1),l=m[g],y=g0&&eXe(e,f,i));t.o=0}function ANt(e,t){var i,a,l;for(l=new j(t.f);l.at)throw Y(new un("Top must be smaller or equal to bottom."));if(0>e)throw Y(new un("Left must be smaller or equal to right."));this.d=0,this.c=e,this.a=t,this.b=0}function nXe(e,t){var i,a,l;if(t.c.length!=0){for(i=Lqe(e,t),l=!1;!i;)v7(e,t,!0),l=!0,i=Lqe(e,t);l&&v7(e,t,!1),a=PU(t),e.b&&e.b.If(a),e.a=jVe(e,(ai(0,t.c.length),h(t.c[0],35))),nXe(e,a)}}function Rt(e){var t;this.c=new Ir,this.f=e.e,this.e=e.d,this.i=e.g,this.d=e.c,this.b=e.b,this.k=e.j,this.a=e.a,e.i?this.j=e.i:this.j=(t=h(bl(Qp),10),new Oc(t,h(el(t,t.length),10),0)),this.g=e.f}function o1(){o1=M,dCe=new J2(zx,0),_a=new J2("BOOLEAN",1),xc=new J2("INT",2),Z5=new J2("STRING",3),nc=new J2("DOUBLE",4),ms=new J2("ENUM",5),_M=new J2("ENUMSET",6),wd=new J2("OBJECT",7)}function qc(){qc=M,JAe=X(q(Se,1),be,2,6,[Gxe,c5,Az,Ytt,Pz,Ire,bz]),KAe=X(q(Se,1),be,2,6,[Gxe,"empty",c5,a5,"elementOnly"]),QAe=X(q(Se,1),be,2,6,[Gxe,"preserve","replace",Lf]),Zs=new l9e}function er(e,t){var i;return i=h(e.c.Vb(t),13),!i&&(i=e.Pc(t)),re(i,196)?new xge(e,t,h(i,196)):re(i,60)?new xJ(e,t,h(i,60)):re(i,19)?new Qge(e,t,h(i,19)):re(i,15)?Q1e(e,t,h(i,15),null):new TI(e,t,i,null)}function G(e,t){var i,a;return a=(!e.p&&(e.p=(Yr(),new ui)),Ii(e.p,t)),a??(i=t.Of(),re(i,4)&&(i==null?(!e.p&&(e.p=(Yr(),new ui)),hS(e.p,t)):(!e.p&&(e.p=(Yr(),new ui)),dr(e.p,t,i))),i)}function PNt(e,t){var i,a,l,f;if(e.e.c.length==0)return null;for(f=new VE,a=new j(e.e);a.a=(l/2|0))for(this.e=a?a.c:null,this.d=l;i++0;)W1e(this);this.b=t,this.a=null}function INt(e){var t,i,a,l,f;return l=h(e.a,21).a,f=h(e.b,21).a,t=(l<0?-l:l)>(f<0?-f:f)?l<0?-l:l:f<0?-f:f,l<=0&&l==f?(i=0,a=f-1):l==-t&&f!=t?(i=f,a=l,f>=0&&++i):(i=-f,a=l),new Is(He(i),He(a))}function DNt(e,t){var i;return e.c.length==0?!1:(i=DWe((ai(0,e.c.length),h(e.c[0],14)).c.g),vl(),i==(_w(),_y)||i==vy?!0:nU(Xf(new oi(null,new di(e,16)),new iN),new aZ(t)))}function fve(e,t,i){var a,l,f;if(!e.b[t.g]){for(e.b[t.g]=!0,a=i,!i&&(a=new aU),Gi(a.b,t),f=e.a[t.g].tc();f.hc();)l=h(f.ic(),170),l.b!=t&&fve(e,l.b,a),l.c!=t&&fve(e,l.c,a),Gi(a.a,l);return a}return null}function BNt(e){switch(e.g){case 0:case 1:case 2:return Fe(),bn;case 3:case 4:case 5:return Fe(),ni;case 6:case 7:case 8:return Fe(),nn;case 9:case 10:case 11:return Fe(),Zt;default:return Fe(),Na}}function ONt(e){var t,i,a,l;for(t=0,a=e.length,l=a-4,i=0;i0)try{l=Sl(t,zs,zi)}catch(f){throw f=pr(f),re(f,118)?(a=f,Y(new hU(a))):Y(f)}return i=(!e.a&&(e.a=new MR(e)),e.a),l=0?h(ae(i,l),51):null}function VNt(e,t,i,a){var l;return l=N_(e,i,X(q(Se,1),be,2,6,[tie,nie,iie,rie,sie,oie,aie]),t),l<0&&(l=N_(e,i,X(q(Se,1),be,2,6,["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]),t)),l<0?!1:(a.d=l,!0)}function WNt(e,t,i,a){var l;return l=N_(e,i,X(q(Se,1),be,2,6,[tie,nie,iie,rie,sie,oie,aie]),t),l<0&&(l=N_(e,i,X(q(Se,1),be,2,6,["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]),t)),l<0?!1:(a.d=l,!0)}function HNt(e){var t,i,a;for(C8t(e),a=new ke,i=new j(e.a.a.b);i.a>1),pve(t,e,v,y,-l,f),pve(t,e,y,m,-l,f),f.Ld(e[y-1],e[y])<=0){for(;i=0?(t||(t=new MC,a>0&&ho(t,e.substr(0,a))),t.a+="\\",JE(t,i&jr)):t&&JE(t,i&jr);return t?t.a:e}function YNt(e,t,i){var a,l,f,g;f=e.c,g=e.d,l=(Fo(X(q(es,1),be,9,0,[f.g.k,f.k,f.a])).b+Fo(X(q(es,1),be,9,0,[g.g.k,g.k,g.a])).b)/2,f.i==(Fe(),Zt)?a=new $t(t+f.g.c.c.a+i,l):a=new $t(t-i,l),e9(e.a,0,a)}function lXe(e,t){var i,a;return Z1e(e.a),fw(e.a,(vU(),sj),sj),fw(e.a,vM,vM),a=new ss,Ai(a,vM,(VU(),Hoe)),Be(rn(t,(ww(),Yoe)))!==Be((KI(),oj))&&Ai(a,vM,Voe),Ai(a,vM,Woe),UNe(e.a,a),i=T_e(e.a,t),i}function uXe(e){if(!e)return wh(),Bnt;var t=e.valueOf?e.valueOf():e;if(t!==e){var i=Kre[typeof t];return i?i(t):Ibe(typeof t)}else return e instanceof Array||e instanceof w.Array?new wF(e):new lC(e)}function v6(e,t){var i;if(t<0)throw Y(new u8("Negative exponent"));if(t==0)return Gz;if(t==1||Obe(e,Gz)||Obe(e,cM))return e;if(!VXe(e,0)){for(i=1;!VXe(e,i);)++i;return m_(F6t(i*t),v6(o0e(e,i),t))}return HBt(e,t)}function ZNt(e,t){var i,a,l;return re(t.g,8)&&h(t.g,8).j==(Xt(),Qr)?Jr:(l=ux(t),l?w.Math.max(0,e.b/2-.5):(i=p_(t),i?(a=ce(Xe(CS(i,($e(),np)))),w.Math.max(0,a/2-.5)):Jr))}function KNt(e,t){var i,a,l;return re(t.g,8)&&h(t.g,8).j==(Xt(),Qr)?Jr:(l=ux(t),l?w.Math.max(0,e.b/2-.5):(i=p_(t),i?(a=ce(Xe(CS(i,($e(),np)))),w.Math.max(0,a/2-.5)):Jr))}function JNt(e,t){var i,a,l,f,g;if(!t.Wb()){if(l=h(t.cd(0),125),t._b()==1){PYe(e,l,l,1,0,t);return}for(i=1;if.a&&!t&&(l.b=f.a),l.c=-(l.b-f.a)/2,i.g){case 1:l.d=-l.a;break;case 3:l.d=f.b}gne(a),mne(a)}function pXe(e,t,i){var a,l,f;switch(f=e.o,a=h(Ds(e.p,i),219),l=a.i,l.b=y6(a),l.a=_6(a),l.a=w.Math.max(l.a,f.b),l.a>f.b&&!t&&(l.a=f.b),l.d=-(l.a-f.b)/2,i.g){case 4:l.c=-l.b;break;case 2:l.c=f.a}gne(a),mne(a)}function sP(e,t){mZe(e,t),e.b&1&&(e.a.a=null),e.b&2&&(e.a.f=null),e.b&4&&(e.a.g=null,e.a.i=null),e.b&16&&(e.a.d=null,e.a.e=null),e.b&8&&(e.a.b=null),e.b&32&&(e.a.j=null,e.a.c=null)}function gXe(e){var t,i,a,l;if(i=h(e,42).Kg(),i)try{if(a=null,t=OS((Sg(),ku),NZe(H6t(i))),t&&(l=t.Lg(),l&&(a=l.gk(ti(ce(i.e))))),a&&a!=e)return gXe(a)}catch(f){if(f=pr(f),!re(f,54))throw Y(f)}return e}function mXe(e,t){var i;t.d?t.d.b=t.b:e.a=t.b,t.b?t.b.d=t.d:e.e=t.d,!t.e&&!t.c?(i=h(hS(e.b,t.a),264),i.a=0,++e.c):(i=h(Ii(e.b,t.a),264),--i.a,t.e?t.e.c=t.c:i.b=t.c,t.c?t.c.e=t.e:i.c=t.e),--e.d}function mve(e){var t,i;return e>-0x800000000000&&e<0x800000000000?e==0?0:(t=e<0,t&&(e=-e),i=yr(w.Math.floor(w.Math.log(e)/.6931471805599453)),(!t||e!=w.Math.pow(2,i))&&++i,i):m$e(Wc(e))}function bXe(e,t){var i,a,l,f,g,m;for(i=e.b.c.length,l=St(e.b,t);t*2+10)for(g=e.c.d,m=e.d.d,l=au(Bc(new $t(m.a,m.b),g),1/(a+1)),f=new $t(g.a,g.b),i=new j(e.a);i.a0&&(g+=i,++t);t>1&&(g+=e.c*(t-1))}else g=oBe(S$e(wI(go(f1e(e.a),new Ok),new Fv)));return g>0?g+e.n.d+e.n.a:0}function y6(e){var t,i,a,l,f,g;if(g=0,e.b==0)g=oBe(S$e(wI(go(f1e(e.a),new Vq),new Im)));else{for(f=LHe(e,!0),t=0,a=0,l=f.length;a0&&(g+=i,++t);t>1&&(g+=e.c*(t-1))}return g>0?g+e.n.b+e.n.c:0}function tFt(e){var t,i;return i=-e.a,t=X(q(Zl,1),Ph,22,15,[43,48,48,48,48]),i<0&&(t[0]=45,i=-i),t[1]=t[1]+((i/60|0)/10|0)&jr,t[2]=t[2]+(i/60|0)%10&jr,t[3]=t[3]+(i%60/10|0)&jr,t[4]=t[4]+i%10&jr,hu(t,0,t.length)}function nFt(e){var t,i,a,l,f,g;for(g=SS(e.d,e.e),f=g.tc();f.hc();)for(l=h(f.ic(),11),a=e.e==(Fe(),nn)?l.d:l.f,i=new j(a);i.a=0;f+=i?1:-1)g=g|t.c.qf(v,f,i,a),g=g|t.q.xf(v,f,i),g=g|BZe(e,v[f],i,a);return Cr(e.c,t),g}function _Xe(e,t){var i,a,l,f,g,m;for(f=new j(e.b);f.a=0&&a0;){if(t=h(e.k.cd(e.n-1),75),i=t.nj(),re(i,62)&&h(h(i,17),62).Bb&Ja&&(!e.e||i.Vi()!=MM||i.pi()!=0)&&t.lc()!=null)return!0;--e.n}return!1}else return e.n>0}function bve(e,t){var i,a,l,f;if(wi(e),e.c!=0||e.a!=123)throw Y(new Wn(Zn((zn(),ntt))));if(f=t==112,a=e.d,i=WE(e.i,125,a),i<0)throw Y(new Wn(Zn((zn(),itt))));return l=qf(e.i,a,i),e.d=i+1,FGe(l,f,(e.e&512)==512)}function sFt(e){var t,i;return i=-e.a,t=X(q(Zl,1),Ph,22,15,[43,48,48,58,48,48]),i<0&&(t[0]=45,i=-i),t[1]=t[1]+((i/60|0)/10|0)&jr,t[2]=t[2]+(i/60|0)%10&jr,t[4]=t[4]+(i%60/10|0)&jr,t[5]=t[5]+i%10&jr,hu(t,0,t.length)}function oFt(e){var t;return t=X(q(Zl,1),Ph,22,15,[71,77,84,45,48,48,58,48,48]),e<=0&&(t[3]=43,e=-e),t[4]=t[4]+((e/60|0)/10|0)&jr,t[5]=t[5]+(e/60|0)%10&jr,t[7]=t[7]+(e%60/10|0)&jr,t[8]=t[8]+e%10&jr,hu(t,0,t.length)}function EXe(e,t){var i,a,l;return a=new eh(e),No(a,t),Ee(a,(Ie(),AG),t),Ee(a,($e(),Ki),(Ms(),Oa)),Ee(a,Bh,(ud(),uj)),Ou(a,(Xt(),Qr)),i=new yo,us(i,a),mr(i,(Fe(),nn)),l=new yo,us(l,a),mr(l,Zt),a}function SXe(e,t){var i,a,l,f,g;for(e.c[t.o]=!0,De(e.a,t),g=new j(t.i);g.a0&&(l=i),g=new j(e.f.e);g.a=f)g.Pb();else for(l=g.tc(),a=0;a0?bpe():g<0&&vve(e,t,-g),!0):!1}function fFt(e){var t,i,a,l,f,g,m,v,y,E;for(i=e.o,t=e.p,g=zi,l=zs,m=zi,f=zs,y=0;yy?l:y,m=mE?f:E);return v=l-g+1,a=f-m+1,new EUe(He(g),He(m),He(v),He(a))}function hFt(e,t){var i,a,l;return i=h(G(t,(Tf(),lM)),21).a-h(G(e,lM),21).a,i==0?(a=Bc(Ua(h(G(e,(Fg(),y5)),9)),h(G(e,HP),9)),l=Bc(Ua(h(G(t,y5),9)),h(G(t,HP),9)),to(a.a*a.b,l.a*l.b)):i}function dFt(e,t){var i,a,l;return i=h(G(t,(Ew(),rj)),21).a-h(G(e,rj),21).a,i==0?(a=Bc(Ua(h(G(e,(ha(),X5)),9)),h(G(e,gL),9)),l=Bc(Ua(h(G(t,X5),9)),h(G(t,gL),9)),to(a.a*a.b,l.a*l.b)):i}function pFt(e,t,i){var a,l,f,g,m,v;if(!e||e.c.length==0)return null;for(f=new e7e(t,!i),l=new j(e);l.a0)switch(t.g){case 2:f.n.c=e.s;break;case 4:f.n.b=e.s}}function Vte(e,t){var i,a,l;if(l=zS((qc(),Zs),e.mg(),t),l)return Yo(),h(l,61).bj()||(l=pA(Vo(Zs,l))),a=(i=e.rg(l),h(i>=0?e.ug(i,!0,!0):Ax(e,l,!0),184)),h(a,237).wk(t);throw Y(new un(ry+t.be()+mxe))}function bFt(e,t,i){var a,l,f,g;return f=CKe(cee(),t),a=null,f&&(g=yKe(f,i),l=null,g!=null&&(l=(g==null?(!e.o&&(e.o=new il((Ta(),op),pm,e,0)),a6(e.o,f)):(!e.o&&(e.o=new il((Ta(),op),pm,e,0)),p6(e.o,f,g)),e)),a=l),a}function _ve(e,t,i,a){var l,f,g,m,v;if(l=e.d[t],l){if(f=l.g,v=l.i,a!=null){for(m=0;m1||i==-1?(e.b=-1,!0):(t=pu(e),t&&(Yo(),t.Ri()==Dtt)?(e.b=-1,!0):(e.b=1,!1));default:case 1:return!1}}function wFt(e,t){var i,a,l,f,g;for(a=(!t.s&&(t.s=new ze(Sc,t,21,17)),t.s),f=null,l=0,g=a.i;ll)?(Rn(f.a!=null),h(f.a,8)):null}function xFt(e,t){Vu();var i,a,l,f,g,m;for(i=null,g=t.tc();g.hc();)f=h(g.ic(),125),!f.k&&(a=FSt(f.a),l=NCt(f.a),m=new dP(a,l,null,h(f.d.a.Xb().tc().ic(),14)),De(m.c,f.a),e.c[e.c.length]=m,i&&De(i.d,m),i=m)}function EFt(e,t,i){var a,l,f,g,m,v;for(a=h(er(e.c,t),15),l=h(er(e.c,i),15),f=a.fd(a._b()),g=l.fd(l._b());f.Cc()&&g.Cc();)if(m=h(f.Ec(),21),v=h(g.Ec(),21),m!=v)return kp(m.a,v.a);return!f.hc()&&!g.hc()?0:f.hc()?1:-1}function oP(e,t,i,a,l){var f,g,m,v;return v=yJ(e,h(l,51)),Be(v)!==Be(l)?(m=h(e.g[i],75),f=Dg(t,v),JC(e,i,Ite(e,i,f)),$u(e.e)&&(g=Wm(e,9,f.nj(),l,v,a,!1),Hwe(g,new Wd(e.e,9,e.c,m,f,a,!1)),XQ(g)),v):l}function SFt(e,t,i){var a,l,f,g;for(l=i,f=c8e(wI(h(h(er(e.r,t),19),60).xc(),new Hb)),g=0;f.a||(f.a=a_(f.c,f)),f.a;)if(l){eU(f),l=!1;continue}else a=eU(f),f.a||(f.a=a_(f.c,f)),f.a&&(g=w.Math.max(g,a));return g}function ir(e,t,i){var a;if(a=h(e.c.Vb(t),13),a)return a.nc(i)?(++e.d,!0):!1;if(a=e.Pc(t),a.nc(i))return++e.d,e.c.Zb(t,a),!0;throw Y(new AQ("New Collection violated the Collection spec"))}function MFt(e){var t,i,a,l,f,g;for(l=0,e.q=new ke,t=new zr,g=new j(e.p);g.a>16),t=a>>16&16,i=16-t,e=e>>t,a=e-256,t=a>>16&8,i+=t,e<<=t,a=e-H0,t=a>>16&4,i+=t,e<<=t,a=e-Ah,t=a>>16&2,i+=t,e<<=t,a=e>>14,t=a&~(a>>1),i+2-t)}function CFt(e,t,i,a){var l,f,g,m,v,y;for(l=0;l=0&&y>=0&&v=0?e.ug(a,!0,!0):Ax(e,f,!0),184)),h(l,237).sk(t,i);throw Y(new un(ry+t.be()+mxe))}function LXe(e){var t,i;if(Bd(h(G(e,($e(),Ki)),83)))for(i=new j(e.i);i.a>24;return g}function RFt(e,t){var i,a,l,f,g;if(i=h(sn(e.a,4),116),g=i==null?0:i.length,t>=g)throw Y(new o_(t,g));return l=i[t],g==1?a=null:(a=le(kae,kre,380,g-1,0,1),vc(i,0,a,0,t),f=g-t-1,f>0&&vc(i,t+1,a,t,f)),l6(e,a),Vqe(e,t,l),l}function IFt(e,t){var i,a,l;if(Be(e)===Be(t))return!0;if(e==null||t==null||e.length!=t.length)return!1;for(i=0;i=null.tl()?(_7(e),Sve(e)):t.hc()}function Wte(e){var t,i;if(C0(e))throw Y(new un(jQe));for(i=Nn(e,0);i.b!=i.d.c;)t=h(Un(i),9),this.d=w.Math.min(this.d,t.b),this.c=w.Math.max(this.c,t.a),this.a=w.Math.max(this.a,t.b),this.b=w.Math.min(this.b,t.a)}function OFt(e){var t,i;return t=new ss,oc(t,bat),i=h(G(e,(Ie(),Va)),19),i.pc((xo(),C5))&&oc(t,xat),i.pc(hM)&&oc(t,wat),(i.pc(dy)||ce(mt(G(e,($e(),D5)))))&&(oc(t,_at),i.pc(py)&&oc(t,yat)),i.pc(dM)&&oc(t,vat),t}function Hte(e){var t,i;if(t=ti(rn(e,(ur(),yCe))),i=R5t(cee(),t),!i)throw t==null||t.length==0?Y(new kR("No layout algorithm has been specified ("+e+").")):Y(new kR("Layout algorithm not found: "+t));return i}function Px(){Px=M,y3=h(ae(ye((ype(),ma).qb),6),29),_3=h(ae(ye(ma.qb),3),29),Nae=h(ae(ye(ma.qb),4),29),Fae=h(ae(ye(ma.qb),5),17),c7(y3),c7(_3),c7(Nae),c7(Fae),aut=new Bl(X(q(Sc,1),oy,158,0,[y3,_3]))}function OXe(e){var t=(!Yre&&(Yre=l$t()),Yre),i=e.replace(/[\x00-\x1f\xad\u0600-\u0603\u06dd\u070f\u17b4\u17b5\u200b-\u200f\u2028-\u202e\u2060-\u2064\u206a-\u206f\ufeff\ufff9-\ufffb"\\]/g,function(a){return XPt(a,t)});return'"'+i+'"'}function NFt(e){var t,i,a,l,f,g;for(l=e.e.c.length,a=le(yu,Lw,15,l,0,1),g=new j(e.e);g.a=0;)a=i[f],g.Bk(a.nj())&&$n(l,a);!h$t(e,l)&&$u(e.e)&&Dn(e,t.lj()?Wm(e,6,t,(_t(),uo),null,-1,!1):Wm(e,t.Zi()?2:1,t,null,null,-1,!1))}function jFt(e,t){var i,a,l,f,g;return e.a==(IS(),ZP)?!0:(f=t.a.c,i=t.a.c+t.a.b,!(t.i&&(a=t.u,g=a.c.c.a-a.n.a/2,l=f-(a.k.a+a.n.a),l>g)||t.n&&(a=t.v,g=a.c.c.a-a.n.a/2,l=a.k.a-i,l>g)))}function zXe(e,t,i){var a,l,f,g,m,v;for(a=0,v=i,t||(a=i*(e.c.length-1),v*=-1),f=new j(e);f.a1?e.e*=ce(e.a):e.f/=ce(e.a),jIt(e),_5t(e),AUt(e),Ee(e.b,(qA(),Yz),e.g)}function VFt(e){lx();var t,i,a,l;for(Zz=new ke,fse=(Yr(),new ui),use=new ke,t=(!e.a&&(e.a=new ze(Br,e,10,11)),e.a),Zjt(t),l=new Bn(t);l.e!=l.i._b();)a=h(Yn(l),35),Qo(Zz,a,0)==-1&&(i=new ke,De(use,i),nHe(a,i));return use}function WFt(e,t){var i,a,l,f,g,m,v;if(a=QVe(e.Db&254),a==1)e.Eb=null;else if(f=__(e.Eb),a==2)l=Ste(e,t),e.Eb=f[l==0?1:0];else{for(g=le(on,et,1,a-1,5,1),i=2,m=0,v=0;i<=128;i<<=1)i==t?++m:e.Db&i&&(g[v++]=f[m++]);e.Eb=g}e.Db&=~t}function $Xe(e,t,i){var a,l,f;e.ti()?(f=e.ui(),e6(e,t,i),a=e.mi(3,null,i,t,f),e.qi()?(l=e.ri(i,null),e.xi()&&(l=e.yi(i,l)),l?(l.Sh(a),l.Th()):e.ni(a)):e.ni(a)):(e6(e,t,i),e.qi()&&(l=e.ri(i,null),l&&l.Th()))}function qte(e,t){var i,a,l,f;e.ti()?(i=e.i,f=e.ui(),MI(e,t),a=e.mi(3,null,t,i,f),e.qi()?(l=e.ri(t,null),e.xi()&&(l=e.yi(t,l)),l?(l.Sh(a),l.Th()):e.ni(a)):e.ni(a)):(MI(e,t),e.qi()&&(l=e.ri(t,null),l&&l.Th()))}function Cve(e,t){var i,a,l,f,g;if(t===e)return!0;if(!re(t,15)||(g=h(t,15),e._b()!=g._b()))return!1;for(f=g.tc(),a=e.tc();a.hc();)if(i=a.ic(),l=f.ic(),!(Be(i)===Be(l)||i!=null&&ki(i,l)))return!1;return!0}function VXe(e,t){var i,a,l;if(t==0)return(e.a[0]&1)!=0;if(t<0)throw Y(new u8("Negative bit address"));if(l=t>>5,l>=e.d)return e.e<0;if(i=e.a[l],t=1<<(t&31),e.e<0){if(a=L$e(e),l=0?e.jg(null):e.yg().Cg(e,-1-t,null,null)),e.kg(h(l,42),i),a&&a.Th(),e.eg()&&e.fg()&&i>-1&&Li(e,new ls(e,9,i,f,l)),l):f}function BS(){BS=M,Pae=new Q2(AQe,0),kj=new Q2("INSIDE_SELF_LOOPS",1),Rj=new Q2("MULTI_EDGES",2),Lj=new Q2("EDGE_LABELS",3),Aae=new Q2("PORTS",4),Pj=new Q2("COMPOUND",5),Aj=new Q2("CLUSTERS",6),Cae=new Q2("DISCONNECTED",7)}function WXe(e){var t,i;if(e.f){for(;e.n>16)),15).dd(f),m0&&(!(n_(e.a.c)&&t.n.d)&&!(YR(e.a.c)&&t.n.b)&&(t.g.d+=w.Math.max(0,a/2-.5)),!(n_(e.a.c)&&t.n.a)&&!(YR(e.a.c)&&t.n.c)&&(t.g.a-=a-1))}function KXe(e,t,i){var a,l,f,g,m,v;f=h(St(t.d,0),14).c,a=f.g,l=a.j,v=h(St(i.f,0),14).d,g=v.g,m=g.j,l==(Xt(),Nr)?Ee(e,(Ie(),Cl),h(G(a,Cl),11)):Ee(e,(Ie(),Cl),f),m==Nr?Ee(e,(Ie(),Al),h(G(g,Al),11)):Ee(e,(Ie(),Al),v)}function Yte(e){var t,i,a;if(e.length==0)throw Y(new un(jQe));for(i=0,a=e.length;i>t,f=e.m>>t|i<<22-t,l=e.l>>t|e.m<<22-t):t<44?(g=a?Kd:0,f=i>>t-22,l=e.m>>t-22|i<<44-t):(g=a?Kd:0,f=a?Yc:0,l=i>>t-44),Xa(l&Yc,f&Yc,g&Kd)}function Zte(e){var t,i,a,l,f,g;for(this.c=new ke,this.d=e,a=Jr,l=Jr,t=Ts,i=Ts,g=Nn(e,0);g.b!=g.d.c;)f=h(Un(g),9),a=w.Math.min(a,f.a),l=w.Math.min(l,f.b),t=w.Math.max(t,f.a),i=w.Math.max(i,f.b);this.a=new Yf(a,l,t-a,i-l)}function Rve(e){var t,i,a;this.c=e,a=h(G(e,($e(),nf)),110),t=ce(Xe(G(e,kG))),i=ce(Xe(G(e,tTe))),a==(qs(),rf)||a==sf||a==Oh?this.b=t*i:this.b=1/(t*i),this.j=ce(Xe(G(e,Hw))),this.e=ce(Xe(G(e,np))),this.f=e.b.c.length}function JXe(e){switch(e.g){case 0:return new zv;case 1:return new uF;case 2:return new _g;case 3:return new jOe;case 4:return new TUe;default:throw Y(new un("No implementation is available for the node placer "+(e.f!=null?e.f:""+e.g)))}}function Ku(e){var t;return t=new ou(Um(e.ql)),t.a+="@",Mi(t,(Hr(e)>>>0).toString(16)),e.Eg()?(t.a+=" (eProxyURI: ",Ic(t,e.Kg()),e.tg()&&(t.a+=" eClass: ",Ic(t,e.tg())),t.a+=")"):e.tg()&&(t.a+=" (eClass: ",Ic(t,e.tg()),t.a+=")"),t.a}function QXe(e,t){var i,a,l,f,g,m,v,y,E;if(e.a.f>0&&re(t,38)&&(e.a.Fi(),y=h(t,38),v=y.kc(),f=v==null?0:Hr(v),g=sme(e.a,f),i=e.a.d[g],i)){for(a=h(i.g,339),E=i.i,m=0;m0&&l0):l<0&&-l0):!1}function m7(e,t,i,a,l){var f,g,m,v,y,E;for(f=a,y=h(h(er(e.r,t),19),60).tc();y.hc();){if(v=h(y.ic(),111),f){f=!1;continue}g=0,l>0?g=l:v.c&&(g=w9(v.c)),g>0&&(i?(E=v.b.Re().a,g>E&&(m=(g-E)/2,v.d.b=m,v.d.c=m)):v.d.c=e.s+g)}}function Ive(e,t,i){switch(t){case 7:!e.e&&(e.e=new an(js,e,7,4)),Pr(e.e),!e.e&&(e.e=new an(js,e,7,4)),Mr(e.e,h(i,13));return;case 8:!e.d&&(e.d=new an(js,e,8,5)),Pr(e.d),!e.d&&(e.d=new an(js,e,8,5)),Mr(e.d,h(i,13));return}$we(e,t,i)}function QFt(e){var t,i;if(e.c.length!=2)throw Y(new ba("Order only allowed for two paths."));t=(ai(0,e.c.length),h(e.c[0],14)),i=(ai(1,e.c.length),h(e.c[1],14)),t.d.g!=i.c.g&&(e.c=le(on,et,1,0,5,1),e.c[e.c.length]=i,e.c[e.c.length]=t)}function e8t(e){var t,i,a,l;if(e==null)return null;if(a=Ba(e,!0),l=u5.length,dt(a.substr(a.length-l,l),u5)){if(i=a.length,i==4){if(t=a.charCodeAt(0),t==43)return iPe;if(t==45)return Eut}else if(i==3)return iPe}return xw(a)}function t8t(e,t,i){var a;a=null,t&&(a=t.d),tP(e,new jE(t.k.a-a.b+i.a,t.k.b-a.d+i.b)),tP(e,new jE(t.k.a-a.b+i.a,t.k.b+t.n.b+a.a+i.b)),tP(e,new jE(t.k.a+t.n.a+a.c+i.a,t.k.b-a.d+i.b)),tP(e,new jE(t.k.a+t.n.a+a.c+i.a,t.k.b+t.n.b+a.a+i.b))}function n8t(e,t){var i,a,l,f,g;for(ii(t,"Port side processing",1),g=new j(e.a);g.av-i&&m=e.c.a.length)return t;for(a=Ic(Mi(new h0,"expected one element but was: <"),t),i=0;i<4&&e.a=0?e.Mg(f,i):Uve(e,l,i);else throw Y(new un(ry+l.be()+gre));else throw Y(new un("The feature ID"+t+" is not a valid feature ID"));else Wl(e,a,l,i)}function Kte(e,t,i,a,l){var f,g,m,v,y,E,C,R,B;return g=i-e,m=a-t,f=w.Math.atan2(g,m),v=f+Cie,y=f-Cie,E=l*w.Math.sin(v)+e,R=l*w.Math.cos(v)+t,C=l*w.Math.sin(y)+e,B=l*w.Math.cos(y)+t,Ym(X(q(es,1),be,9,0,[new $t(E,R),new $t(C,B)]))}function oYe(e){var t,i,a,l,f,g,m;for(f=0,l=e.f.e,i=0;i=0)return l;for(f=1,m=new j(t.i);m.av+1?f:v+1);return Y6t(e,t,f),f}function a1(){a1=M,Mu=new Qv("H_LEFT",0),Nh=new Qv("H_CENTER",1),Cu=new Qv("H_RIGHT",2),Rf=new Qv("V_TOP",3),af=new Qv("V_CENTER",4),of=new Qv("V_BOTTOM",5),Ll=new Qv("INSIDE",6),Au=new Qv("OUTSIDE",7),Tu=new Qv("H_PRIORITY",8)}function rn(e,t){var i,a;return a=(!e.o&&(e.o=new il((Ta(),op),pm,e,0)),Mf(e.o,t)),a??(i=t.Of(),re(i,4)&&(i==null?(!e.o&&(e.o=new il((Ta(),op),pm,e,0)),a6(e.o,t)):(!e.o&&(e.o=new il((Ta(),op),pm,e,0)),p6(e.o,t,i))),i)}function u8t(e){var t,i,a,l,f,g,m;if(t=e.Yg(wu),t&&(m=ti(Mf((!t.b&&(t.b=new wl((yt(),zo),Aa,t)),t.b),"settingDelegates")),m!=null)){for(i=new ke,l=Lx(m,"\\w+"),f=0,g=l.length;f0?(t-=1,i-=1):a>=0&&l<0?(t+=1,i+=1):a>0&&l>=0?(t-=1,i+=1):(t+=1,i-=1),new Is(He(t),He(i))}function Dve(e,t,i){var a,l,f;if(t!=i){a=t;do tr(e,a.c),l=h(G(a,(Ie(),sm)),8),l&&(f=a.d,Fl(e,f.b,f.d),tr(e,l.k),a=va(l));while(l);a=i;do Bc(e,a.c),l=h(G(a,(Ie(),sm)),8),l&&(f=a.d,iI(e,f.b,f.d),Bc(e,l.k),a=va(l));while(l)}}function d8t(e,t,i){var a,l,f,g,m,v;a=new ke,a.c[a.c.length]=t,v=t,m=0;do v=Ujt(e,v),v&&(a.c[a.c.length]=v),++m;while(v);for(g=(i-(a.c.length-1)*e.d.d)/a.c.length,f=new j(a);f.at.c?1:e.bt.b?1:e.a!=t.a?Hr(e.a)-Hr(t.a):e.d==(wA(),fL)&&t.d==uL?-1:e.d==uL&&t.d==fL?1:0}function Jte(e){var t,i,a,l,f,g,m,v;for(l=Jr,a=Ts,i=new j(e.e.b);i.a=0;t-=2)for(i=0;i<=t;i+=2)(e.b[i]>e.b[i+2]||e.b[i]===e.b[i+2]&&e.b[i+1]>e.b[i+3])&&(a=e.b[i+2],e.b[i+2]=e.b[i],e.b[i]=a,a=e.b[i+3],e.b[i+3]=e.b[i+1],e.b[i+1]=a);e.c=!0}}function fYe(e,t){var i,a,l,f,g,m,v,y;for(g=t==1?_se:vse,f=g.a.Xb().tc();f.hc();)for(l=h(f.ic(),110),v=h(er(e.f.c,l),19).tc();v.hc();)switch(m=h(v.ic(),48),a=h(m.b,80),y=h(m.a,172),i=y.c,l.g){case 2:case 1:a.g.d+=i;break;case 4:case 3:a.g.c+=i}}function M8t(e){Zve();var t,i,a,l,f,g,m;if(e==null||(l=e.length,l%2!=0))return null;for(t=fU(e),f=l/2|0,i=le(Mc,sy,22,f,15,1),a=0;a>24}return i}function OS(e,t){var i,a,l;return i=t==null?Dc(gc(e.d,null)):NC(e.e,t),re(i,207)?(l=h(i,207),l.gh()==null,l):re(i,456)?(a=h(i,1631),l=a.a,l&&(l.yb==null||(t==null?El(e.d,null,l):B0(e.e,t,l))),l):null}function T8t(e,t){var i,a,l,f,g;if(a=t.nj(),j0(e.e,a)){if(a.xh()&&$Q(e,a,t.lc()))return!1}else for(g=cl(e.e.mg(),a),i=h(e.g,124),l=0;l0&&(!(n_(e.a.c)&&t.n.d)&&!(YR(e.a.c)&&t.n.b)&&(t.g.d-=w.Math.max(0,a/2-.5)),!(n_(e.a.c)&&t.n.a)&&!(YR(e.a.c)&&t.n.c)&&(t.g.a+=w.Math.max(0,a-1)))}function hYe(e,t,i){var a,l;if((e.c-e.b&e.a.length-1)==2)t==(Fe(),bn)||t==Zt?(bU(h(IA(e),15),(xl(),Ed)),bU(h(IA(e),15),dm)):(bU(h(IA(e),15),(xl(),dm)),bU(h(IA(e),15),Ed));else for(l=new hA(e);l.a!=l.b;)a=h(DU(l),15),bU(a,i)}function dYe(e){var t,i,a,l,f,g,m;if(e&&(t=e.Yg(wu),t&&(g=ti(Mf((!t.b&&(t.b=new wl((yt(),zo),Aa,t)),t.b),"conversionDelegates")),g!=null))){for(m=new ke,a=Lx(g,"\\w+"),l=0,f=a.length;l=2147483648&&(a-=fie),a)}function pYe(e,t,i){var a,l,f,g;BUe(e,t)>BUe(e,i)?(a=sa(i,(Fe(),Zt)),e.d=a.Wb()?0:fI(h(a.cd(0),11)),g=sa(t,nn),e.b=g.Wb()?0:fI(h(g.cd(0),11))):(l=sa(i,(Fe(),nn)),e.d=l.Wb()?0:fI(h(l.cd(0),11)),f=sa(t,Zt),e.b=f.Wb()?0:fI(h(f.cd(0),11)))}function A8t(e){var t,i,a,l,f,g;if(l=h(St(e.i,0),11),l.d.c.length+l.f.c.length==0)e.k.a=0;else{for(g=0,a=Cn(Fp(new Rd(l),new Wv(l)));Gn(a);)i=h(Tn(a),11),g+=i.g.k.a+i.k.a+i.a.a;t=h(G(e,($e(),$w)),9),f=t?t.a:0,e.k.a=g/(l.d.c.length+l.f.c.length)-f}}function gYe(e){switch(e.g){case 0:return new iFe;case 1:return new aF;case 2:return new GOe;case 3:return new T2;case 4:return new d8e;case 5:return new lF;default:throw Y(new un("No implementation is available for the layerer "+(e.f!=null?e.f:""+e.g)))}}function mYe(e,t){var i,a,l,f;for(i=e.o.a,f=h(h(er(e.r,t),19),60).tc();f.hc();)l=h(f.ic(),111),l.e.a=i*ce(Xe(l.b.xe(Tj))),l.e.b=(a=l.b,a.ye((ur(),Zc))?a.ef()==(Fe(),bn)?-a.Re().b-ce(Xe(a.xe(Zc))):ce(Xe(a.xe(Zc))):a.ef()==(Fe(),bn)?-a.Re().b:0)}function Qte(e,t){DS();var i,a,l,f,g,m,v,y,E;return t.d>e.d&&(m=e,e=t,t=m),t.d<63?S9t(e,t):(g=(e.d&-2)<<4,y=o0e(e,g),E=o0e(t,g),a=pne(e,hx(y,g)),l=pne(t,hx(E,g)),v=Qte(y,E),i=Qte(a,l),f=Qte(pne(y,a),pne(l,E)),f=xne(xne(f,v),i),f=hx(f,g),v=hx(v,g<<1),xne(xne(v,f),i))}function bYe(e,t,i){var a,l,f;for(kMt.call(this,new ke),this.a=t,this.b=i,this.e=e,a=(e.b&&vne(e),e.a),this.d=PUe(a.a,this.a),this.c=PUe(a.b,this.b),L6t(this,this.d,this.c),cFt(this),f=this.e.e.a.Xb().tc();f.hc();)l=h(f.ic(),247),l.c.c.length>0&&oGt(this,l)}function P8t(e){var t,i,a,l;for(t=0,i=0,l=new j(e.i);l.a1||i>1)return 2;return t+i==1?2:0}function L8t(e,t,i){var a,l,f,g,m,v,y;a=i,l=t;do l=e.a[l.o],g=(y=e.g[l.o],ce(e.p[y.o])+ce(e.d[l.o])-l.d.d),m=J4t(l,l.c?Qo(l.c.a,l,0):-1),m&&(f=(v=e.g[m.o],ce(e.p[v.o])+ce(e.d[m.o])+m.n.b+m.d.a),a=w.Math.min(a,g-(f+r_(e.k,l,m))));while(t!=l);return a}function k8t(e,t,i){var a,l,f,g,m,v,y;a=i,l=t;do l=e.a[l.o],f=(y=e.g[l.o],ce(e.p[y.o])+ce(e.d[l.o])+l.n.b+l.d.a),m=dRt(l,l.c?Qo(l.c.a,l,0):-1),m&&(g=(v=e.g[m.o],ce(e.p[v.o])+ce(e.d[m.o])-m.d.d),a=w.Math.min(a,g-(f+r_(e.k,l,m))));while(t!=l);return a}function R8t(e,t,i){var a,l,f,g;for(l=i,f=c8e(wI(h(h(er(e.r,t),19),60).xc(),new yp)),g=0;f.a||(f.a=a_(f.c,f)),f.a;)if(l){Rn((f.a||(f.a=a_(f.c,f)),f.a)),f.a=!1,l=!1;continue}else a=eU(f),f.a||(f.a=a_(f.c,f)),f.a&&(g=w.Math.max(g,a));return g}function I8t(e,t,i){var a,l,f,g,m,v,y,E;if(i)for(f=i.a.length,a=new jm(f),m=(a.b-a.a)*a.c<0?(Mg(),mm):new Cg(a);m.hc();)g=h(m.ic(),21),l=uS(i,g.a),l&&(v=W4t(e,(y=(p0(),E=new lpe,E),t&&MYe(y,t),y),l),jI(v,Vd(l,Rh)),o7(l,v),lve(l,v),mee(e,l,v))}function D8t(e){var t,i,a;return i=h(e.a,21).a,a=h(e.b,21).a,t=(i<0?-i:i)>(a<0?-a:a)?i<0?-i:i:a<0?-a:a,i=-t&&a==t?new Is(He(i-1),He(a)):new Is(He(i),He(a-1))}function wYe(e){var t,i,a,l,f,g;for(g=h(vo(e.a,le(Eu,Cf,8,e.a.c.length,0,1)),123),vge(g,new wH),i=null,l=0,f=g.length;la.o?mr(l,ni):l.i==ni&&a.o>e.o&&mr(l,bn);break}return a}function Nve(e,t,i){var a,l,f;for(f=new j(e.e);f.a0&&(a.b.c-=a.c,a.b.c<=0&&a.b.f>0&&Gi(t,a.b));for(l=new j(e.b);l.a0&&(a.a.f-=a.c,a.a.f<=0&&a.a.c>0&&Gi(i,a.a))}function Fve(e,t,i){var a,l,f;for(f=new j(e.q);f.a0&&(a.b.j-=a.c,a.b.j<=0&&a.b.r>0&&Gi(t,a.b));for(l=new j(e.g);l.a0&&(a.a.r-=a.c,a.a.r<=0&&a.a.j>0&&Gi(i,a.a))}function _7(e){var t,i,a,l,f;if(e.g==null&&(e.d=e.Gh(e.f),$n(e,e.d),e.c))return f=e.f,f;if(t=h(e.g[e.i-1],43),l=t.ic(),e.e=t,i=e.Gh(l),i.hc())e.d=i,$n(e,i);else for(e.d=null;!t.hc()&&(Gr(e.g,--e.i,null),e.i!=0);)a=h(e.g[e.i-1],43),t=a;return l}function E6(e,t){var i,a,l,f;for(e=e,i=new tw,f=0,a=0;a=0?e.ug(a,!0,!0):Ax(e,f,!0),184)),h(l,237).xk(t,i)}else throw Y(new un(ry+t.be()+gre))}function zve(e,t,i){switch(i.g){case 1:return new $t(t.a,w.Math.min(e.d.b,t.b));case 2:return new $t(w.Math.max(e.c.a,t.a),t.b);case 3:return new $t(t.a,w.Math.max(e.c.b,t.b));case 4:return new $t(w.Math.min(t.a,e.d.a),t.b)}return new $t(t.a,t.b)}function S6(e){var t,i,a;for(t=ed(1+(!e.c&&(e.c=new ze(Pu,e,9,9)),e.c).i),De(t,(!e.d&&(e.d=new an(js,e,8,5)),e.d)),a=new Bn((!e.c&&(e.c=new ze(Pu,e,9,9)),e.c));a.e!=a.i._b();)i=h(Yn(a),121),De(t,(!i.d&&(i.d=new an(js,i,8,5)),i.d));return Hn(t),new ex(t)}function Th(e){var t,i,a;for(t=ed(1+(!e.c&&(e.c=new ze(Pu,e,9,9)),e.c).i),De(t,(!e.e&&(e.e=new an(js,e,7,4)),e.e)),a=new Bn((!e.c&&(e.c=new ze(Pu,e,9,9)),e.c));a.e!=a.i._b();)i=h(Yn(a),121),De(t,(!i.e&&(i.e=new an(js,i,7,4)),i.e));return Hn(t),new ex(t)}function U8t(e,t){var i,a,l,f,g;if(ii(t,"Breaking Point Processor",1),hjt(e),ce(mt(G(e,($e(),oTe))))){for(l=new j(e.b);l.a3&&ad(e,0,t-3))}function j8t(e){var t,i,a;return i=e.l,i&i-1||(a=e.m,a&a-1)||(t=e.h,t&t-1)||t==0&&a==0&&i==0?-1:t==0&&a==0&&i!=0?Z0e(i):t==0&&a!=0&&i==0?Z0e(a)+22:t!=0&&a==0&&i==0?Z0e(t)+44:-1}function $8t(e,t){var i,a,l,f,g;for(ii(t,"Edge joining",1),i=ce(mt(G(e,($e(),_oe)))),l=new j(e.b);l.a0),f.a.cd(f.c=--f.b),td(f,l),Rn(f.bey,v=Eey,v=Eey,v=Eey,v=E=0){if(t==i)return new Is(He(-t-1),He(-t-1));if(t==-i)return new Is(He(-t),He(i+1))}return(t<0?-t:t)>(i<0?-i:i)?t<0?new Is(He(-t),He(i)):new Is(He(-t),He(i+1)):new Is(He(t+1),He(i))}function Z8t(e,t,i){var a,l,f,g,m;return l=h(rn(t,(l7(),_Ce)),21),!l&&(l=He(0)),f=h(rn(i,_Ce),21),!f&&(f=He(0)),l.a>f.a?-1:l.a1)for(t=b0((i=new Fm,++e.b,i),e.d),m=Nn(f,0);m.b!=m.d.c;)g=h(Un(m),113),Ju(zu(Uu(Gu(Fu(new iu,1),0),t),g))}function e9t(e,t,i){var a,l,f,g,m;for(ii(i,"Breaking Point Removing",1),e.a=h(G(t,($e(),cm)),197),f=new j(t.b);f.a>16!=6&&t){if(LS(e,t))throw Y(new un(LP+kXe(e)));a=null,e.Cb&&(a=(i=e.Db>>16,i>=0?Awe(e,null):e.Cb.Cg(e,-1-i,null,null))),t&&(a=yx(t,e,6,a)),a=ime(e,t,a),a&&a.Th()}else e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,6,t,t))}function SYe(e,t){var i,a;if(t!=e.Cb||e.Db>>16!=3&&t){if(LS(e,t))throw Y(new un(LP+uKe(e)));a=null,e.Cb&&(a=(i=e.Db>>16,i>=0?kwe(e,null):e.Cb.Cg(e,-1-i,null,null))),t&&(a=yx(t,e,12,a)),a=nme(e,t,a),a&&a.Th()}else e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,3,t,t))}function MYe(e,t){var i,a;if(t!=e.Cb||e.Db>>16!=9&&t){if(LS(e,t))throw Y(new un(LP+vZe(e)));a=null,e.Cb&&(a=(i=e.Db>>16,i>=0?Lwe(e,null):e.Cb.Cg(e,-1-i,null,null))),t&&(a=yx(t,e,9,a)),a=rme(e,t,a),a&&a.Th()}else e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,9,t,t))}function TYe(e,t){var i,a;if(t!=e.Cb||e.Db>>16!=11&&t){if(LS(e,t))throw Y(new un(LP+s_e(e)));a=null,e.Cb&&(a=(i=e.Db>>16,i>=0?Dwe(e,null):e.Cb.Cg(e,-1-i,null,null))),t&&(a=yx(t,e,10,a)),a=hme(e,t,a),a&&a.Th()}else e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,11,t,t))}function r9t(e,t){if(re(t,246))return n6t(e,h(t,35));if(re(t,187))return i6t(e,h(t,121));if(re(t,263))return aPt(e,h(t,137));if(re(t,183))return wUt(e,h(t,105));if(t)return null;throw Y(new un(Txe+Vp(new Bl(X(q(on,1),et,1,5,[null])))))}function s9t(e){var t,i,a,l,f,g,m,v,y,E,C;return C=Zwe(e),t=e.a,v=t!=null,v&&sA(C,"category",e.a),l=x8(new Gv(e.d)),g=!l,g&&(y=new Om,Og(C,"knownOptions",y),i=new zZ(y),mo(new Gv(e.d),i)),f=x8(e.g),m=!f,m&&(E=new Om,Og(C,"supportedFeatures",E),a=new GZ(E),mo(e.g,a)),C}function o9t(e,t,i){var a,l,f;for(l=new j(e.a.b);l.av){for(E=e.d,e.d=le(PAe,Oxe,55,2*v+4,0,1),f=0;f=9223372036854776e3?(gS(),o3e):(l=!1,e<0&&(l=!0,e=-e),a=0,e>=l1&&(a=yr(e/l1),e-=a*l1),i=0,e>=Nx&&(i=yr(e/Nx),e-=i*Nx),t=yr(e),f=Xa(t,i,a),l&&Cee(f),f)}function CYe(e,t,i){var a,l,f,g,m,v;if(!C0(t)){for(v=bc(i,(re(t,13)?h(t,13)._b():vA(t.tc()))/e.a|0),ii(v,WQe,1),m=new Dk,g=0,f=t.tc();f.hc();)a=h(f.ic(),76),m=Fp(m,new Dd(a)),gkw,f=a-gkw,(l||f)&&(v=h(t.e,249).b,g=h(t.e,249).a,m=h(t.d,129),v==0&&g==0)))return m;return m}function AYe(e,t,i,a){var l,f,g,m;return g=new eh(e),Ou(g,(Xt(),Nr)),Ee(g,(Ie(),Jn),t),Ee(g,($e(),Ki),(Ms(),Oa)),Ee(g,Cl,i),Ee(g,Al,a),f=new yo,mr(f,(Fe(),nn)),us(f,g),m=new yo,mr(m,Zt),us(m,g),_s(t,f),l=new Op,No(l,t),Ee(l,Lo,null),Os(l,m),_s(l,a),g}function p9t(e,t,i,a,l){var f,g;(!Jo(t)&&t.c.g.c==t.d.g.c||!d$e(Fo(X(q(es,1),be,9,0,[l.g.k,l.k,l.a])),i))&&(t.c==l?e9(t.a,0,new Do(i)):Gi(t.a,new Do(i)),a&&!IC(e.a,i)&&(g=h(G(t,($e(),Lo)),74),g||(g=new zc,Ee(t,Lo,g)),f=new Do(i),Fs(g,f,g.c.b,g.c),Cr(e.a,f)))}function g9t(e,t){var i,a;if(a=R9(e.b,t.b),!a)throw Y(new ba("Invalid hitboxes for scanline constraint calculation."));(cVe(t.b,h(UMt(e.b,t.b),57))||cVe(t.b,h(FMt(e.b,t.b),57)))&&(Jh(),t.b+""),e.a[t.b.f]=h(LJ(e.b,t.b),57),i=h(kJ(e.b,t.b),57),i&&(e.a[i.f]=t.b)}function PYe(e,t,i,a,l,f){var g,m,v,y,E,C,R,B,N,W,V,ee;for(E=a,t.i&&t.k?(B=h(Ii(e.f,t.u),57),W=B.d.c+B.d.b,--E):W=t.a.c+t.a.b,C=l,i.n&&i.k?(B=h(Ii(e.f,i.v),57),y=B.d.c,++C):y=i.a.c,V=y-W,v=2>C-E?2:C-E,m=V/v,N=W+m,R=E;R>16!=7&&t){if(LS(e,t))throw Y(new un(LP+Oqe(e)));a=null,e.Cb&&(a=(i=e.Db>>16,i>=0?Pwe(e,null):e.Cb.Cg(e,-1-i,null,null))),t&&(a=h(t,42).Ag(e,1,pD,a)),a=Qme(e,t,a),a&&a.Th()}else e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,7,t,t))}function m9t(e,t){var i,a;if(t!=e.Cb||e.Db>>16!=3&&t){if(LS(e,t))throw Y(new un(LP+qVe(e)));a=null,e.Cb&&(a=(i=e.Db>>16,i>=0?Rwe(e,null):e.Cb.Cg(e,-1-i,null,null))),t&&(a=h(t,42).Ag(e,0,mD,a)),a=e1e(e,t,a),a&&a.Th()}else e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,3,t,t))}function RYe(e){var t,i,a,l,f,g,m;for(f=new j(e.a.a);f.a0&&f>0?g.o=t++:a>0?g.o=i++:f>0?g.o=l++:g.o=i++}_t(),fa(e.i,new jb)}function IYe(e,t){var i,a,l;for(l=(!t.a&&(t.a=new ze(Br,t,10,11)),t.a).i,a=new Bn((!t.a&&(t.a=new ze(Br,t,10,11)),t.a));a.e!=a.i._b();)i=h(Yn(a),35),Be(rn(i,(ur(),Ey)))!==Be((e1(),ML))&&u0e(Hte(t),Hte(i))&&((!i.a&&(i.a=new ze(Br,i,10,11)),i.a).i==0||(l+=IYe(e,i)));return l}function w9t(e,t){var i,a,l;return i=t.Yg(e.a),i&&(l=ti(Mf((!i.b&&(i.b=new wl((yt(),zo),Aa,i)),i.b),"affiliation")),l!=null)?(a=uJ(l,wc(35)),a==-1?qee(e,aA(e,$l(t.Wi())),l):a==0?qee(e,null,l.substr(1,l.length-1)):qee(e,l.substr(0,a),l.substr(a+1,l.length-(a+1)))):null}function v9t(e){var t,i,a,l,f;if(f=new ke,cd(e.b,new RY(f)),e.b.c=le(on,et,1,0,5,1),f.c.length!=0){for(t=(ai(0,f.c.length),h(f.c[0],78)),i=1,a=f.c.length;i=e.a||!Xwe(t,i))return-1;if(C0(h(a.Kb(t),20)))return 1;for(l=0,g=h(a.Kb(t),20).tc();g.hc();)if(f=h(g.ic(),14),v=f.c.g==t?f.d.g:f.c.g,m=Vve(e,v,i,a),m==-1||(l=l>m?l:m,l>e.c-1))return-1;return l+1}function _9t(e,t,i,a){var l,f,g,m,v,y,E,C,R;for(C=a?(Fe(),nn):(Fe(),Zt),l=!1,v=t[i],y=0,E=v.length;y>5,t&=31,a>=e.d)return e.e<0?(Kg(),ese):(Kg(),cM);if(f=e.d-a,l=le(In,si,22,f+1,15,1),nNt(l,f,e.a,a,t),e.e<0){for(i=0;i0&&e.a[i]<<32-t){for(i=0;i0&&(f=h(St(this.b,0),157),l+=f.o,a+=f.p),l*=2,a*=2,t>1?l=yr(w.Math.ceil(l*t)):a=yr(w.Math.ceil(a/t)),this.a=new nwe(l,a)}function qve(e,t,i,a,l,f){var g,m,v,y,E,C;for(y=i.c.length,f&&(e.c=le(In,si,22,t.length,15,1)),g=l?0:t.length-1;l?g=0;g+=l?1:-1){for(m=t[g],v=a==(Fe(),Zt)?l?sa(m,a):I0(sa(m,a)):l?I0(sa(m,a)):sa(m,a),f&&(e.c[m.o]=v._b()),C=v.tc();C.hc();)E=h(C.ic(),11),e.d[E.o]=y++;Lr(i,v)}}function GYe(e,t,i){var a,l,f,g,m,v,y,E;for(f=ce(Xe(e.b.tc().ic())),y=ce(Xe(_$e(t.b))),a=au(Ua(e.a),y-i),l=au(Ua(t.a),i-f),E=tr(a,l),au(E,1/(y-f)),this.a=E,this.b=new ke,m=!0,g=e.b.tc(),g.ic();g.hc();)v=ce(Xe(g.ic())),m&&v-i>ey&&(this.b.nc(i),m=!1),this.b.nc(v);m&&this.b.nc(i)}function R9t(e){var t,i,a,l;if(OUt(e,e.n),e.d.c.length>0){for(TC(e.c);Mve(e,h($(new j(e.e.a)),113))=l&&(e.c=!1,e.a=!1),e.b[a++]=l,e.b[a]=f,e.c||U_(e)}}function jYe(e){var t,i,a,l;return l=Sh(e),i=new yg(l),a=new DY(l),t=new ke,Lr(t,(!e.d&&(e.d=new an(js,e,8,5)),e.d)),Lr(t,(!e.e&&(e.e=new an(js,e,7,4)),e.e)),h(sd(Xf(go(new oi(null,new di(t,16)),i),a),b_(new qn,new bi,new Si,new it,X(q(nh,1),Oe,150,0,[(Wg(),Bw),th]))),19)}function $Ye(e){var t,i,a;if(i=h(G(e,(Ie(),Pl)),8),i?mr(e,h(G(i,pa),69)):e.d.c.length-e.f.c.length<0?mr(e,(Fe(),Zt)):mr(e,(Fe(),nn)),!e.b)switch(a=e.n,t=e.a,e.i.g){case 1:t.a=a.a/2,t.b=0;break;case 2:t.a=a.a,t.b=a.b/2;break;case 3:t.a=a.a/2,t.b=a.b;break;case 4:t.a=0,t.b=a.b/2}}function I9t(e,t,i){var a,l,f,g,m;for(ii(i,"Longest path layering",1),e.a=t,m=e.a.a,e.b=le(In,si,22,m.c.length,15,1),a=0,g=new j(m);g.a=0?!1:(i=zS((qc(),Zs),l,t),i?(a=i.kj(),(a>1||a==-1)&&S0(Vo(Zs,i))!=3):!0)):!1}function D9t(e,t){var i;switch(i=h(G(e,($e(),nL)),241),ii(t,"Label side selection ("+i+")",1),i.g){case 0:_Xe(e,(xl(),Ed));break;case 1:_Xe(e,(xl(),dm));break;case 2:DZe(e,(xl(),Ed));break;case 3:DZe(e,(xl(),dm));break;case 4:KYe(e,(xl(),Ed));break;case 5:KYe(e,(xl(),dm))}On(t)}function Xve(e,t,i){var a,l,f,g,m,v;if(a=xEt(i,e.length),g=e[a],g[0].j==(Xt(),Qr))for(f=lBe(i,g.length),v=t.i,l=0;l0&&(i[0]+=e.d,g-=i[0]),i[2]>0&&(i[2]+=e.d,g-=i[2]),f=w.Math.max(0,g),i[1]=w.Math.max(i[1],g),b0e(e,Wa,l.c+a.b+i[0]-(i[1]-g)/2,i),t==Wa&&(e.c.b=f,e.c.c=l.c+a.b+(f-g)/2)}function z9t(e,t){var i,a,l,f,g,m,v;for(i=Ts,m=(Xt(),hs),l=new j(t.a);l.a0?g=i:v.c&&(g=zJ(v.c)),g>0&&(a&&(Gm(),v.a.B&&(!ce(mt(v.a.e.xe((ur(),iD))))||v.b.ff()))?v.d.a=e.s+g:(E=v.b.Re().b,g>E&&(m=(g-E)/2,v.d.d=m,v.d.a=m)))}}function $9t(e,t){var i,a,l,f,g;return l=t.Yg(e.a),l&&(a=(!l.b&&(l.b=new wl((yt(),zo),Aa,l)),l.b),i=ti(Mf(a,Ls)),i!=null&&(f=i.lastIndexOf("#"),g=f==-1?Zge(e,t.Pi(),i):f==0?PI(e,null,i.substr(1,i.length-1)):PI(e,i.substr(0,f),i.substr(f+1,i.length-(f+1))),re(g,140)))?h(g,140):null}function V9t(e,t){var i,a,l,f,g;return a=t.Yg(e.a),a&&(i=(!a.b&&(a.b=new wl((yt(),zo),Aa,a)),a.b),f=ti(Mf(i,Dre)),f!=null&&(l=f.lastIndexOf("#"),g=l==-1?Zge(e,t.Pi(),f):l==0?PI(e,null,f.substr(1,f.length-1)):PI(e,f.substr(0,l),f.substr(l+1,f.length-(l+1))),re(g,140)))?h(g,140):null}function ZYe(e,t,i,a,l){var f,g,m,v,y,E;if(e.d&&e.d.If(l),f=h(l.cd(0),35),THe(e,i,f,!1)||(g=h(l.cd(l._b()-1),35),THe(e,a,g,!0))||ive(e,l))return!0;for(E=l.tc();E.hc();)for(y=h(E.ic(),35),v=t.tc();v.hc();)if(m=h(v.ic(),35),C7(e,y,m))return!0;return!1}function W9t(e,t,i){var a,l,f,g,m,v,y,E,C,R;R=t.c.length,C=(y=e.rg(i),h(y>=0?e.ug(y,!1,!0):Ax(e,i,!1),52));e:for(f=C.tc();f.hc();){for(l=h(f.ic(),51),E=0;Ee.d[g.o]&&(i+=Uze(e.b,f),bA(e.a,He(f)));for(;!wpe(e.a);)uje(e.b,h(ZJ(e.a),21).a)}return i}function j_(e,t,i){var a,l;if((!e.a&&(e.a=new ze(ts,e,6,6)),e.a).i==0)return pVe(e);if(a=h(ae((!e.a&&(e.a=new ze(ts,e,6,6)),e.a),0),270),t&&(Pr((!a.a&&(a.a=new vs(oh,a,5)),a.a)),AA(a,0),PA(a,0),CA(a,0),TA(a,0)),i)for(l=(!e.a&&(e.a=new ze(ts,e,6,6)),e.a);l.i>1;)Mw(l,l.i-1);return a}function Y9t(e,t){var i,a,l,f;if(f=LZe(t),l=h(G(f,(Ie(),Va)),19),qGt(t,l),l.pc((xo(),Su)))for(a=new Bn((!t.c&&(t.c=new ze(Pu,t,9,9)),t.c));a.e!=a.i._b();)i=h(Yn(a),121),njt(e,t,f,i);return T9t(t,f),ce(mt(G(f,($e(),XMe))))&&l.nc(xG),Be(rn(t,iL))===Be((e1(),d3))?c$t(e,t,f):tjt(e,t,f),f}function xo(){xo=M,_G=new sw("COMMENTS",0),Su=new sw("EXTERNAL_PORTS",1),KP=new sw("HYPEREDGES",2),yG=new sw("HYPERNODES",3),dy=new sw("NON_FREE_PORTS",4),py=new sw("NORTH_SOUTH_PORTS",5),C5=new sw(AQe,6),hM=new sw("CENTER_LABELS",7),dM=new sw("END_LABELS",8),xG=new sw("PARTITIONS",9)}function JYe(e,t,i){var a,l,f,g;for(f=(!t.a&&(t.a=new ze(Br,t,10,11)),t.a).i,l=new Bn((!t.a&&(t.a=new ze(Br,t,10,11)),t.a));l.e!=l.i._b();)a=h(Yn(l),35),(!a.a&&(a.a=new ze(Br,a,10,11)),a.a).i==0||(f+=JYe(e,a,!1));if(i)for(g=eo(t);g;)f+=(!g.a&&(g.a=new ze(Br,g,10,11)),g.a).i,g=eo(g);return f}function Mw(e,t){var i,a,l,f;return e.ti()?(a=null,l=e.ui(),e.xi()&&(a=e.zi(e.Dh(t),null)),i=e.mi(4,f=Ex(e,t),null,t,l),e.qi()&&f!=null&&(a=e.si(f,a)),a?(a.Sh(i),a.Th()):e.ni(i),f):(f=Ex(e,t),e.qi()&&f!=null&&(a=e.si(f,null),a&&a.Th()),f)}function Z9t(e){var t,i,a,l,f,g,m,v,y;for(g=Jr,v=Jr,m=null,i=new aQ(new D2(e.e));i.b!=i.c.a.b;)if(t=A0e(i),(Be(t.d)===Be((ll(),Zp))||Be(t.d)===Be(Xw))&&(a=h(t.e,249).a,y=h(t.e,249).b,l=g-a>kw,f=a-gkw,(l||f)&&(v=h(t.e,249).b,g=h(t.e,249).a,m=h(t.d,129),v==0&&g==0)))return m;return m}function K9t(e){var t,i,a,l,f,g,m,v,y,E;for(f=e.a,t=new zr,y=0,a=new j(e.d);a.av.d&&(E=v.d+v.a+f));i.c.d=E,t.a.Zb(i,t),y=w.Math.max(y,i.c.d+i.c.a)}return y}function J9t(e,t,i,a,l){return a<0?(a=N_(e,l,X(q(Se,1),be,2,6,[Vne,Wne,Hne,qne,Bx,Xne,Yne,Zne,Kne,Jne,Qne,eie]),t),a<0&&(a=N_(e,l,X(q(Se,1),be,2,6,["Jan","Feb","Mar","Apr",Bx,"Jun","Jul","Aug","Sep","Oct","Nov","Dec"]),t)),a<0?!1:(i.k=a,!0)):a>0?(i.k=a-1,!0):!1}function Q9t(e,t,i,a,l){return a<0?(a=N_(e,l,X(q(Se,1),be,2,6,[Vne,Wne,Hne,qne,Bx,Xne,Yne,Zne,Kne,Jne,Qne,eie]),t),a<0&&(a=N_(e,l,X(q(Se,1),be,2,6,["Jan","Feb","Mar","Apr",Bx,"Jun","Jul","Aug","Sep","Oct","Nov","Dec"]),t)),a<0?!1:(i.k=a,!0)):a>0?(i.k=a-1,!0):!1}function eUt(e,t,i){var a,l,f;if(e.e=i,e.d=0,e.b=0,e.f=1,e.i=t,(e.e&16)==16&&(e.i=MUt(e.i)),e.j=e.i.length,wi(e),f=O0(e),e.d!=e.j)throw Y(new Wn(Zn((zn(),qet))));if(e.g){for(a=0;aKQe?fa(v,e.b):a<=KQe&&a>JQe?fa(v,e.d):a<=JQe&&a>QQe?fa(v,e.c):a<=QQe&&fa(v,e.a),f=eZe(e,v,f);return l}function tZe(e){Y2(e,new O_(q2(V2(H2(W2(new t0,gz),"Randomizer"),'Distributes the nodes randomly on the plane, leading to very obfuscating layouts. Can be useful to demonstrate the power of "real" layout algorithms.'),new Gq))),bt(e,gz,Ux,mAe),bt(e,gz,qS,15),bt(e,gz,J7,He(0)),bt(e,gz,WS,HS)}function nUt(e,t){var i,a,l,f,g,m,v,y,E,C;for(v=t.a.length,m=yr(w.Math.ceil(v/e.a)),C=t.a,g=0,y=m,f=0;fg?0:g)g?0:g:v,(0>(yg?0:g)g?0:g:v)),g=y,y+=m,a=h(St(e.c,f),8),i=new aJ(E),i.n.b=t.n.b,ir(e.b,t,i),De(a.b,i);Sa(e.g.b,t),De(e.i,(l=new xOe(e,t),l))}function nZe(e,t,i){var a,l,f,g,m,v,y,E,C;for(t.o=1,f=t.c,C=vw(t,(Oo(),lc)).tc();C.hc();)for(E=h(C.ic(),11),l=new j(E.f);l.a=e.length||(m=e.charCodeAt(t[0]),m!=43&&m!=45)||(++t[0],a=h7(e,t),a<0))return!1;m==45&&(a=-a)}return m==32&&t[0]-i==2&&l.b==2&&(v=new T8,y=v.q.getFullYear()-V0+V0-80,g=y%100,f.a=a==g,a+=(y/100|0)*100+(a0){if(e.Fi(),t!=null){for(f=0;f=48;i--)OL[i]=i-48<<24>>24;for(a=70;a>=65;a--)OL[a]=a-65+10<<24>>24;for(l=102;l>=97;l--)OL[l]=l-97+10<<24>>24;for(f=0;f<10;f++)$j[f]=48+f&jr;for(e=10;e<=15;e++)$j[e]=65+e-10&jr}function aZe(e){var t,i,a,l;i=ce(Xe(G(e.a,(Tf(),Pit)))),a=e.a.c.d,l=e.a.d.d,t=e.d,a.a>=l.a?a.b>=l.b?(t.a=l.a+(a.a-l.a)/2+i,t.b=l.b+(a.b-l.b)/2-i):(t.a=l.a+(a.a-l.a)/2+i,t.b=a.b+(l.b-a.b)/2+i):a.b>=l.b?(t.a=a.a+(l.a-a.a)/2+i,t.b=l.b+(a.b-l.b)/2+i):(t.a=a.a+(l.a-a.a)/2+i,t.b=a.b+(l.b-a.b)/2-i)}function cUt(e,t,i,a){var l,f,g,m,v;return m=Ia(h(ae((!t.b&&(t.b=new an(pi,t,4,7)),t.b),0),97)),v=Ia(h(ae((!t.c&&(t.c=new an(pi,t,5,8)),t.c),0),97)),eo(m)==eo(v)||SA(v,m)?null:(g=V9(t),g==i?a:(f=h(Ii(e.a,g),8),f&&(l=h(G(f,(Ie(),md)),31),l)?l:null))}function lUt(e,t,i,a){var l,f,g,m,v;for(f=e.i.c.length,v=le(EVt,Pye,267,f,0,1),g=0;gR+v&&a.jc();for(g=new j(B);g.a>19)return"-"+lZe(_S(e));for(i=e,a="";!(i.l==0&&i.m==0&&i.h==0);){if(l=BQ(W7),i=A_e(i,l,!0),t=""+vBe(rm),!(i.l==0&&i.m==0&&i.h==0))for(f=9-t.length;f>0;f--)t="0"+t;a=t+a}return a}function Sl(e,t,i){var a,l,f,g,m;if(e==null)throw Y(new vh(Xc));for(f=e.length,g=f>0&&(e.charCodeAt(0)==45||e.charCodeAt(0)==43)?1:0,a=g;ai)throw Y(new vh(W0+e+'"'));return m}function fUt(){if(!Object.create||!Object.getOwnPropertyNames)return!1;var e="__proto__",t=Object.create(null);if(t[e]!==void 0)return!1;var i=Object.getOwnPropertyNames(t);return!(i.length!=0||(t[e]=42,t[e]!==42)||Object.getOwnPropertyNames(t).length==0)}function hUt(e,t){var i,a,l,f;for(ii(t,"Resize child graph to fit parent.",1),a=new j(e.b);a.a>24;case 97:case 98:case 99:case 100:case 101:case 102:return e-97+10<<24>>24;case 65:case 66:case 67:case 68:case 69:case 70:return e-65+10<<24>>24;default:throw Y(new vh("Invalid hexadecimal"))}}function wUt(e,t){var i,a,l,f,g,m,v,y,E;if(y=h(Ii(e.c,t),191),!y)throw Y(new _h("Edge did not exist in input."));return g=jA(y),E=new Om,i=new q8e(e,g,E),eSt((!t.a&&(t.a=new ze(ts,t,6,6)),t.a),i),Og(y,_xe,E),m=h(rn(t,(ur(),u3)),74),l=!m||LUe(m),f=!l,f&&(v=new Om,a=new TZ(v),mo(m,a),Og(y,"junctionPoints",v)),null}function vUt(e,t,i){var a,l,f,g;ii(i,"Orthogonally routing hierarchical port edges",1),e.a=0,a=Dzt(t),DGt(t,a),sGt(e,t,a),jjt(t),l=h(G(t,($e(),Ki)),83),f=t.b,qKe((ai(0,f.c.length),h(f.c[0],26)),l,t),qKe(h(St(f,f.c.length-1),26),l,t),g=t.b,eKe((ai(0,g.c.length),h(g.c[0],26))),eKe(h(St(g,g.c.length-1),26)),On(i)}function _Ut(e){var t,i,a;switch(t=h(G(e.d,($e(),cm)),197),t.g){case 2:i=b$t(e);break;case 3:i=(a=new ke,Fa(go(Xf(Jf(Jf(new oi(null,new di(e.d.b,16)),new nN),new YH),new ZH),new VH),new u0(a)),a);break;default:throw Y(new ba("Compaction not supported for "+t+" edges."))}Zzt(e,i),mo(new Gv(e.g),new XY(e))}function yUt(e,t,i,a){var l,f,g,m,v;for(l=!1,f=!1,m=new j(a.i);m.a1&&(i?g=ju(t.c)+1:g=ju(y.c)-1,m=h(St(e.a.b,g),26),Hs(y,m)),Qve(e,y,i));return t}function uZe(e,t,i,a,l,f){if(this.b=i,this.d=l,e>=t.length)throw Y(new Ra("Greedy SwitchDecider: Free layer not in graph."));this.c=t[e],this.e=new ZR(a),hee(this.e,this.c,(Fe(),nn)),this.i=new ZR(a),hee(this.i,this.c,Zt),this.f=new M9e(this.c),this.a=!f&&l.i&&!l.s&&this.c[0].j==(Xt(),Qr),this.a&&MNt(this,e,t.length)}function xUt(e,t,i){var a,l,f,g;for(ii(i,"Processor order nodes",2),e.a=ce(Xe(G(t,(Ew(),jTe)))),l=new Ir,g=Nn(t.b,0);g.b!=g.d.c;)f=h(Un(g),76),ce(mt(G(f,(ha(),Kw))))&&Fs(l,f,l.c.b,l.c);a=(Rn(l.b!=0),h(l.a.a.c,76)),hKe(e,a),!i.b&&uee(i,1),i_e(e,a,0-ce(Xe(G(a,(ha(),nj))))/2,0),!i.b&&uee(i,1),On(i)}function fZe(){this.b=(Yr(),new A0),this.d=new A0,this.e=new A0,this.c=new A0,this.a=new ui,this.f=new ui,ax(es,new Eq,new Sq),ax(pCe,new kq,new Rq),ax(AEe,new Iq,new Dq),ax(PEe,new Nv,new Bq),ax(tVt,new Oq,new zq),ax(rVt,new n0,new Mq),ax(nVt,new Tq,new Cq),ax(iVt,new Aq,new Pq),ax(aVt,new i0,new Lq)}function hZe(e,t,i,a){var l,f,g,m,v,y;for(v=kte(e,i),y=kte(t,i),l=!1;v&&y&&(a||IDt(v,y,i));)g=kte(v,i),m=kte(y,i),BI(t),BI(e),f=v.c,Lne(v,!1),Lne(y,!1),i?(Yg(t,y.o,f),t.o=y.o,Yg(e,v.o+1,f),e.o=v.o):(Yg(e,v.o,f),e.o=v.o,Yg(t,y.o+1,f),t.o=y.o),Hs(v,null),Hs(y,null),v=g,y=m,l=!0;return l}function sne(e,t,i,a,l,f,g,m){var v,y,E;for(v=0,t!=null&&(v^=Hg(t.toLowerCase())),i!=null&&(v^=Hg(i)),a!=null&&(v^=Hg(a)),g!=null&&(v^=Hg(g)),m!=null&&(v^=Hg(m)),y=0,E=f.length;yv?new mU(t,e,m-v):m>0&&v>0&&(new mU(e,t,0),new mU(t,e,0)))}function dZe(e){Y2(e,new O_(q2(V2(H2(W2(new t0,i5),Tet),"Keeps the current layout as it is, without any automatic modification. Optional coordinates can be given for nodes and edge bend points."),new dN))),bt(e,i5,Ux,lAe),bt(e,i5,fz,qt(SL)),bt(e,i5,cxe,qt(oAe)),bt(e,i5,lz,qt(aAe)),bt(e,i5,uz,qt(cAe))}function pZe(e){var t,i,a;a=h(G(e,($e(),kf)),19),!a.Wb()&&(i=(t=h(bl(Ys),10),new Oc(t,h(el(t,t.length),10),0)),a.pc((a1(),Ll))?yl(i,Ll):yl(i,Au),a.pc(Tu)||yl(i,Tu),a.pc(Mu)?yl(i,Rf):a.pc(Nh)?yl(i,af):a.pc(Cu)&&yl(i,of),a.pc(Rf)?yl(i,Mu):a.pc(af)?yl(i,Nh):a.pc(of)&&yl(i,Cu),Ee(e,kf,i))}function e_e(e,t){var i,a,l,f;if(0<(re(e,13)?h(e,13)._b():vA(e.tc()))){if(l=t,1=e.o)throw Y(new o8);m=t>>5,g=t&31,f=jd(1,nr(jd(g,1))),l?e.n[i][m]=Zf(e.n[i][m],f):e.n[i][m]=Kr(e.n[i][m],tme(f)),f=jd(f,1),a?e.n[i][m]=Zf(e.n[i][m],f):e.n[i][m]=Kr(e.n[i][m],tme(f))}catch(v){throw v=pr(v),re(v,305)?Y(new Ra(_ie+e.o+"*"+e.p+yie+t+Ca+i+xie)):Y(v)}}function one(e,t){var i,a,l,f,g,m,v;for(l=new ke,v=new ke,i=h(Ds(hy,e),15).tc();i.hc();)a=h(i.ic(),151),KWe(l,a.b),KWe(l,BWe(a)),i.hc()&&(a=h(i.ic(),151),Lr(v,BWe(a)),Lr(v,a.b));for(ree(l,e.b),ree(v,e.a),m=new j(l);m.ae.d[m.o]&&(i+=Uze(e.b,f),bA(e.a,He(f)))):++g;for(i+=e.b.d*g;!wpe(e.a);)uje(e.b,h(ZJ(e.a),21).a)}return i}function kUt(e){var t,i,a,l,f,g;if(l=e.g.ed(),a=e.b.ed(),e.e)for(i=0;iey;){for(f=t,g=0;w.Math.abs(t-f)0&&(a=(!e.n&&(e.n=new ze(ea,e,1,7)),h(h(ae(e.n,0),137),263)).a,!a||Mi(Mi((t.a+=' "',t),a),'"'))),Mi(g0(Mi(g0(Mi(g0(Mi(g0((t.a+=" (",t),e.i),","),e.j)," | "),e.g),","),e.f),")"),t.a)}function vZe(e){var t,i,a;return e.Db&64?Ote(e):(t=new ou(gxe),i=e.k,i?Mi(Mi((t.a+=' "',t),i),'"'):(!e.n&&(e.n=new ze(ea,e,1,7)),e.n.i>0&&(a=(!e.n&&(e.n=new ze(ea,e,1,7)),h(h(ae(e.n,0),137),263)).a,!a||Mi(Mi((t.a+=' "',t),a),'"'))),Mi(g0(Mi(g0(Mi(g0(Mi(g0((t.a+=" (",t),e.i),","),e.j)," | "),e.g),","),e.f),")"),t.a)}function _Ze(e){var t,i,a,l,f,g;return f=0,t=pu(e),t.Qi()&&(f|=4),e.Bb&yc&&(f|=2),re(e,62)?(i=h(e,17),l=Uo(i),i.Bb&Ja&&(f|=32),l&&(jn(dw(l)),f|=8,g=l.t,(g>1||g==-1)&&(f|=16),l.Bb&Ja&&(f|=64)),i.Bb&oo&&(f|=Dw),f|=tf):re(t,425)?f|=512:(a=t.Qi(),a&&a.i&1&&(f|=256)),e.Bb&512&&(f|=128),f}function o_e(e,t){var i,a,l,f,g,m,v;if(t==null||t.length==0)return null;if(l=h(za(e.a,t),180),!l){for(a=(m=new bh(e.b).a.Tb().tc(),new c0(m));a.a.hc();)if(i=(f=h(a.a.ic(),38),h(f.lc(),180)),g=i.c,v=t.length,dt(g.substr(g.length-v,v),t)&&(t.length==g.length||po(g,g.length-t.length-1)==46)){if(l)return null;l=i}l&&Ko(e.a,t,l)}return l}function IUt(e,t){var i;return e.f==Oae?(i=S0(Vo((qc(),Zs),t)),e.e?i==4&&t!=(Px(),y3)&&t!=(Px(),_3)&&t!=(Px(),Nae)&&t!=(Px(),Fae):i==2):e.d&&(e.d.pc(t)||e.d.pc(pA(Vo((qc(),Zs),t)))||e.d.pc(zS((qc(),Zs),e.b,t)))?!0:e.f&&jve((qc(),e.f),mI(Vo(Zs,t)))?(i=S0(Vo(Zs,t)),e.e?i==4:i==2):!1}function DUt(e,t,i,a){var l,f,g,m,v,y,E,C;return g=h(rn(i,(ur(),f3)),9),v=g.a,E=g.b+e,l=w.Math.atan2(E,v),l<0&&(l+=$x),l+=t,l>$x&&(l-=$x),m=h(rn(a,f3),9),y=m.a,C=m.b+e,f=w.Math.atan2(C,y),f<0&&(f+=$x),f+=t,f>$x&&(f-=$x),xh(),Ng(1e-10),w.Math.abs(l-f)<=1e-10||l==f||isNaN(l)&&isNaN(f)?0:lf?1:$8(isNaN(l),isNaN(f))}function BUt(e,t,i,a){var l,f;for(mBt(e,t,i,a),wde(t,e.j-t.j+i),bde(t,e.k-t.k+a),f=new j(t.f);f.ai.k&&my&&a>y)y=ce(i.p[m.o])+ce(i.d[m.o])+m.n.b+m.d.a;else{l=!1,e.a&&Jh();break}if(!l)break}return e.a&&Jh(),l}function qUt(e,t){var i,a,l,f,g;for(e.c==null||e.c.lengthf*2?(E=new xU(C),y=Ul(g)/_f(g),v=Rne(E,t,new j2,i,a,l,y),tr(Wf(E.e),v),C.c=le(on,et,1,0,5,1),C.c[C.c.length]=E,C.c[C.c.length]=g,f=Ul(E)*_f(E)+Ul(g)*_f(g)):(C.c[C.c.length]=g,f+=Ul(g)*_f(g));return C}function FS(e){switch(e){case 100:return q_(zP,!0);case 68:return q_(zP,!1);case 119:return q_(Ure,!0);case 87:return q_(Ure,!1);case 115:return q_(zre,!0);case 83:return q_(zre,!1);case 99:return q_(Gre,!0);case 67:return q_(Gre,!1);case 105:return q_(jre,!0);case 73:return q_(jre,!1);default:throw Y(new na(hnt+e.toString(16)))}}function PZe(e,t,i){var a,l,f,g,m,v,y,E;if(t.o==0){for(t.o=1,g=i,i||(l=new ke,f=(a=h(bl(Ec),10),new Oc(a,h(el(a,a.length),10),0)),g=new Is(l,f)),h(g.a,15).nc(t),t.j==(Xt(),Qr)&&h(g.b,19).nc(h(G(t,(Ie(),pa)),69)),v=new j(t.i);v.am&&(m=l,E.c=le(on,et,1,0,5,1)),l==m&&De(E,new Is(i.c.g,i)));_t(),fa(E,e.c),_0(e.b,v.o,E)}}function r7t(e,t){var i,a,l,f,g,m,v,y,E;for(g=new j(t.b);g.am&&(m=l,E.c=le(on,et,1,0,5,1)),l==m&&De(E,new Is(i.d.g,i)));_t(),fa(E,e.c),_0(e.f,v.o,E)}}function s7t(e,t,i,a){var l,f,g,m,v,y,E,C,R;for(v=new $t(i,a),Bc(v,h(G(t,(Fg(),HP)),9)),R=new j(t.e);R.a=40,g&&F7t(e),Azt(e),R9t(e),i=oWe(e),a=0;i&&a0&&Gi(e.e,f)):(e.c[g]-=y+1,e.c[g]<=0&&e.a[g]>0&&Gi(e.d,f))))}function kZe(e){var t,i,a,l,f,g,m,v,y,E,C;for(m=new ke,f=ce(Xe(e.g.cd(e.g._b()-1))),C=e.g.tc();C.hc();)E=Xe(C.ic()),_0(m,0,f-(dn(E),E));for(g=BA(_ee(e)),y=new ke,l=new j(m),v=new ke,t=0;t1)&&t==1&&h(e.a[e.b],8).j==(Xt(),ul)?kx(h(e.a[e.b],8),(xl(),Ed)):a&&(!i||(e.c-e.b&e.a.length-1)>1)&&t==1&&h(e.a[e.c-1&e.a.length-1],8).j==(Xt(),ul)?kx(h(e.a[e.c-1&e.a.length-1],8),(xl(),dm)):(e.c-e.b&e.a.length-1)==2?(kx(h(IA(e),8),(xl(),Ed)),kx(h(IA(e),8),dm)):B8t(e,l),a0e(e)}function c7t(e){var t,i;if(!e.Wb()){for(i=h(e.cd(0),151).f,new g_e(e),t=new Ns(i.i,0),B_((ll(),ip),t),R_(yy,t),c6((Fe(),bn),t),one(lm,t),R_(cb,t),z_(qw,t),B_(Zp,t),c6(Zt,t),one(ob,t),B_(Xw,t),z_(ab,t),B_(cb,t),c6(ni,t),one(Kp,t),B_(yy,t),z_(Zw,t),R_(Xw,t);t.b=0&&(m=$Dt(e,g),!(m&&(y<22?v.l|=1<>>1,g.m=E>>>1|(C&1)<<21,g.l=R>>>1|(E&1)<<21,--y;return i&&Cee(v),f&&(a?(rm=_S(e),l&&(rm=tVe(rm,(gS(),a3e)))):rm=Xa(e.l,e.m,e.h)),v}function FZe(e,t,i,a){var l,f,g,m,v,y,E,C;if(aRt(e,t,i),f=t[i],C=a?(Fe(),nn):(Fe(),Zt),ZSt(t.length,i,a)){for(l=t[a?i-1:i+1],y0e(e,l,a?(Oo(),lc):(Oo(),Fc)),v=0,E=f.length;v0){for(l=m.length;l>0&&m[l-1]=="";)--l;l=0&&m!=i&&(f=new ls(e,1,m,g,null),a?a.Sh(f):a=f),i>=0&&(f=new ls(e,1,i,m==i?g:null,t),a?a.Sh(f):a=f)),a}function _7t(e,t,i,a){var l,f,g,m,v,y,E;if(CFt(e,t,i,a))return!0;for(g=new j(t.f);g.a=l){for(g=1;g0){if(l=h(e.Ab.g,1627),t==null){for(f=0;f1)for(a=new j(l);a.at.f?1:0:(a=e.e-t.e,i=(e.d>0?e.d:w.Math.floor((e.a-1)*FJe)+1)-(t.d>0?t.d:w.Math.floor((t.a-1)*FJe)+1),i>a+1?l:i0&&(g=m_(g,JZe(a))),FWe(f,g))):lv+N&&(W=C.i+R.i,R.a=(R.i*R.a+C.i*C.a)/W,R.i=W,C.g=R,i=!0)),f=m,C=R;return i}function $Ze(e,t){var i,a,l,f,g,m,v,y,E;if(l=e.g,g=l.n.a,f=l.n.b,g<=0&&f<=0)return Fe(),Na;switch(y=e.k.a,E=e.k.b,m=e.n.a,i=e.n.b,t.g){case 2:case 1:if(y<0)return Fe(),nn;if(y+m>g)return Fe(),Zt;break;case 4:case 3:if(E<0)return Fe(),bn;if(E+i>f)return Fe(),ni}return v=(y+m/2)/g,a=(E+i/2)/f,v+a<=1&&v-a<=0?(Fe(),nn):v+a>=1&&v-a>=0?(Fe(),Zt):a<.5?(Fe(),bn):(Fe(),ni)}function h_e(e,t,i){var a,l,f,g;if(t[0]>=e.length)return i.o=0,!0;switch(e.charCodeAt(t[0])){case 43:l=1;break;case 45:l=-1;break;default:return i.o=0,!0}if(++t[0],f=t[0],g=h7(e,t),g==0&&t[0]==f)return!1;if(t[0]=14&&i<=16));case 11:return t!=null&&typeof t===Dne;case 12:return t!=null&&(typeof t===N6||typeof t==Dne);case 0:return hte(t,e.__elementTypeId$);case 2:return XJ(t)&&t.sl!==T;case 1:return XJ(t)&&t.sl!==T||hte(t,e.__elementTypeId$);default:return!0}}function kx(e,t){var i,a,l,f,g,m;if(e.j==(Xt(),ul)&&(i=Ebe(go(h(G(e,(Ie(),LG)),15).xc(),new RF(new WO))).a==null?(xl(),uD):t,Ee(e,t3,i),i!=(xl(),dm)))for(a=h(G(e,Jn),14),m=ce(Xe(G(a,($e(),tp)))),g=0,i==Ed?g=e.n.b-w.Math.ceil(m/2):i==uD&&(e.n.b-=ce(Xe(G(va(e),N5))),g=(e.n.b-w.Math.ceil(m))/2),f=new j(e.i);f.a0&&(YI(v,!1,(qs(),rf)),YI(v,!0,sf)),cd(t.g,new ROe(e,i)),dr(e.g,t,i)}function R7t(e,t){var i,a,l,f,g,m,v;for(f=0,m=0,v=0,l=new j(e.f.e);l.a0&&e.d!=(xA(),bse)&&(m+=g*(a.d.a+e.a[t.b][a.b]*(t.d.a-a.d.a)/i)),i>0&&e.d!=(xA(),gse)&&(v+=g*(a.d.b+e.a[t.b][a.b]*(t.d.b-a.d.b)/i)));switch(e.d.g){case 1:return new $t(m/f,t.d.b);case 2:return new $t(t.d.a,v/f);default:return new $t(m/f,v/f)}}function g_e(e){LVe();var t,i,a,l,f,g,m,v,y,E;for(this.b=new ZO,this.c=new ke,this.a=new ke,v=Tee(),y=0,E=v.length;y0){for(g=0;g>16==-15&&e.Cb.Hg()&&XQ(new VQ(e.Cb,9,13,i,e.c,$p(Vc(h(e.Cb,53)),e))):re(e.Cb,96)&&e.Db>>16==-23&&e.Cb.Hg()&&(t=e.c,re(t,96)||(t=(yt(),ff)),re(i,96)||(i=(yt(),ff)),XQ(new VQ(e.Cb,9,10,i,t,$p(Ea(h(e.Cb,24)),e)))))),e.c}function Tw(e){vi();var t,i,a,l,f;if(e.e!=4&&e.e!=5)throw Y(new un("Token#complementRanges(): must be RANGE: "+e.e));for(U_(e),gP(e),a=e.b.length+2,e.b[0]==0&&(a-=2),i=e.b[e.b.length-1],i==rM&&(a-=2),l=(++Er,new _l(4)),l.b=le(In,si,22,a,15,1),f=0,e.b[0]>0&&(l.b[f++]=0,l.b[f++]=e.b[0]-1),t=1;t=65;i--)lh[i]=i-65<<24>>24;for(a=122;a>=97;a--)lh[a]=a-97+26<<24>>24;for(l=57;l>=48;l--)lh[l]=l-48+52<<24>>24;for(lh[43]=62,lh[47]=63,f=0;f<=25;f++)tg[f]=65+f&jr;for(g=26,v=0;g<=51;++g,v++)tg[g]=97+v&jr;for(e=52,m=0;e<=61;++e,m++)tg[e]=48+m&jr;tg[62]=43,tg[63]=47}function N7t(e,t){var i,a,l,f,g,m,v,y,E,C;if(g=e.d,E=h(G(e,(Ie(),i3)),15),C=0,E){for(v=0,f=E.tc();f.hc();)l=h(f.ic(),8),v=w.Math.max(v,l.n.b),C+=l.n.a;C+=t/2*(E._b()-1),g.d+=v+t}if(i=h(G(e,Jx),15),a=0,i){for(v=0,f=i.tc();f.hc();)l=h(f.ic(),8),v=w.Math.max(v,l.n.b),a+=l.n.a;a+=t/2*(i._b()-1),g.a+=v+t}m=w.Math.max(C,a),m>e.n.a&&(y=(m-e.n.a)/2,g.b=w.Math.max(g.b,y),g.c=w.Math.max(g.c,y))}function F7t(e){var t,i,a,l,f,g,m;for(e.o=new sK,a=new Ir,g=new j(e.e.a);g.a0,m=jU(t,f),zge(i?m.b:m.g,t),P_(m).c.length==1&&Fs(a,m,a.c.b,a.c),l=new Is(f,t),FNe(e.o,l),Sa(e.e.a,f))}function XZe(e,t){var i,a,l,f,g;for(t.d?l=e.a.c==(Eh(),sb)?As(t.b):fr(t.b):l=e.a.c==(Eh(),Yp)?As(t.b):fr(t.b),f=!1,a=(Mo(),new Nd(Kh(Gd(l.a,new z))));Gn(a);)if(i=h(Tn(a),14),g=ce(e.a.f[e.a.g[t.b.o].o]),!(!g&&!Jo(i)&&i.c.g.c==i.d.g.c)&&!(ce(e.a.n[e.a.g[t.b.o].o])||ce(e.a.n[e.a.g[t.b.o].o]))&&(f=!0,IC(e.b,e.a.g[bDt(i,t.b).o])))return t.c=!0,t.a=i,t;return t.c=f,t.a=null,t}function v_e(e,t){var i,a,l,f,g,m,v;if(!Sh(e))throw Y(new ba(Cet));if(a=Sh(e),f=a.g,l=a.f,f<=0&&l<=0)return Fe(),Na;switch(m=e.i,v=e.j,t.g){case 2:case 1:if(m<0)return Fe(),nn;if(m+e.g>f)return Fe(),Zt;break;case 4:case 3:if(v<0)return Fe(),bn;if(v+e.f>l)return Fe(),ni}return g=(m+e.g/2)/f,i=(v+e.f/2)/l,g+i<=1&&g-i<=0?(Fe(),nn):g+i>=1&&g-i>=0?(Fe(),Zt):i<.5?(Fe(),bn):(Fe(),ni)}function U7t(e,t){var i,a,l,f,g,m,v,y,E,C,R,B;if(e.Wb())return new fo;for(y=0,C=0,l=e.tc();l.hc();)a=h(l.ic(),31),f=a.e,y=w.Math.max(y,f.a),C+=f.a*f.b;for(y=w.Math.max(y,w.Math.sqrt(C)*ce(Xe(G(h(e.tc().ic(),31),($e(),kG))))),R=0,B=0,v=0,i=t,m=e.tc();m.hc();)g=h(m.ic(),31),E=g.e,R+E.a>y&&(R=0,B+=v+t,v=0),A6(g,R,B),i=w.Math.max(i,R+E.a),v=w.Math.max(v,E.b),R+=E.a+t;return new $t(i+t,B+v+t)}function dne(e,t,i){var a,l,f,g,m,v,y,E;if(a=i._b(),a==0)return!1;if(e.ti())if(y=e.ui(),vqe(e,t,i),g=a==1?e.mi(3,null,i.tc().ic(),t,y):e.mi(5,null,i,t,y),e.qi()){for(m=a<100?null:new Eg(a),f=t+a,l=t;l1)for(a=Nn(l,0);a.b!=a.d.c;)for(i=h(Un(a),202),f=0,v=new j(i.e);v.am?1:-1:Mbe(e.a,t.a,f),l==-1)C=-v,E=g==v?DQ(t.a,m,e.a,f):NQ(t.a,m,e.a,f);else if(C=g,g==v){if(l==0)return Kg(),cM;E=DQ(e.a,f,t.a,m)}else E=NQ(e.a,f,t.a,m);return y=new l_(C,E.length,E),gA(y),y}function JZe(e){DS();var t,i,a,l;if(t=yr(e),e1e6)throw Y(new u8("power of ten too big"));if(e<=zi)return hx(v6(Xx[1],t),t);for(a=v6(Xx[1],zi),l=a,i=Wc(e-zi),t=yr(e%zi);Ma(i,zi)>0;)l=m_(l,a),i=Qm(i,zi);for(l=m_(l,v6(Xx[1],t)),l=hx(l,zi),i=Wc(e-zi);Ma(i,zi)>0;)l=hx(l,zi),i=Qm(i,zi);return l=hx(l,t),l}function $7t(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V;i=b0(new Fm,e.f),y=e.i[t.c.g.o],B=e.i[t.d.g.o],v=t.c,R=t.d,m=v.a.b,C=R.a.b,y.b||(m+=v.k.b),B.b||(C+=R.k.b),E=yr(w.Math.max(0,m-C)),g=yr(w.Math.max(0,C-m)),N=(W=wf(1,h(G(t,($e(),o3)),21).a),V=r0e(t.c.g.j,t.d.g.j),W*V),l=Ju(zu(Uu(Fu(Gu(new iu,N),g),i),h(Ii(e.k,t.c),113))),f=Ju(zu(Uu(Fu(Gu(new iu,N),E),i),h(Ii(e.k,t.d),113))),a=new DOe(l,f),e.c[t.o]=a}function gne(e){var t,i,a,l,f,g,m,v,y,E,C,R,B;if(i=e.i,t=e.n,e.b==0)for(B=i.c+t.b,R=i.b-t.b-t.c,g=e.a,v=0,E=g.length;v0&&(C-=a[0]+e.c,a[0]+=e.c),a[2]>0&&(C-=a[2]+e.c),a[1]=w.Math.max(a[1],C),L9(e.a[1],i.c+t.b+a[0]-(a[1]-C)/2,a[1]);for(f=e.a,m=0,y=f.length;m0&&(t[0]+=e.c,C-=t[0]),t[2]>0&&(C-=t[2]+e.c),t[1]=w.Math.max(t[1],C),P9(e.a[1],a.d+i.d+t[0]-(t[1]-C)/2,t[1]);else for(N=a.d+i.d,B=a.a-i.d-i.a,g=e.a,v=0,E=g.length;v>>0).toString(16),i="\\x"+qf(t,t.length-2,t.length)):e>=oo?(t="0"+(e>>>0).toString(16),i="\\v"+qf(t,t.length-6,t.length)):i=""+String.fromCharCode(e&jr)}return i}function __e(e){var t,i,a,l,f,g;for(Cge(this),i=e._b()-1;i<3;i++)e.bd(0,h(e.cd(0),9));if(e._b()<4)throw Y(new un("At (least dimension + 1) control points are necessary!"));for(this.c=3,this.e=!0,this.f=!0,this.d=!1,m8t(this,e._b()+this.c-1),g=new ke,f=this.g.tc(),t=0;t=0&&f!=i))throw Y(new un(s5));for(l=0,v=0;vce(Hf(g.g,g.d[0]).a)?(Rn(v.b>0),v.a.cd(v.c=--v.b),td(v,g),l=!0):m.e&&m.e._b()>0&&(f=(!m.e&&(m.e=new ke),m.e).vc(t),y=(!m.e&&(m.e=new ke),m.e).vc(i),(f||y)&&((!m.e&&(m.e=new ke),m.e).nc(g),++g.c));l||(a.c[a.c.length]=g)}function X7t(e,t,i){var a,l,f,g,m,v;for(a=0,f=new Bn((!e.a&&(e.a=new ze(Br,e,10,11)),e.a));f.e!=f.i._b();)l=h(Yn(f),35),g="",(!l.n&&(l.n=new ze(ea,l,1,7)),l.n).i==0||(g=h(h(ae((!l.n&&(l.n=new ze(ea,l,1,7)),l.n),0),137),263).a),m=new sUe(g),No(m,l),Ee(m,(Fg(),Yx),l),m.b=a++,m.d.a=l.i+l.g/2,m.d.b=l.j+l.f/2,m.e.a=w.Math.max(l.g,1),m.e.b=w.Math.max(l.f,1),De(t.e,m),El(i.d,l,m),v=h(rn(l,(Tf(),bEe)),83),v==(Ms(),hb)}function Y7t(e,t,i,a){var l,f,g,m,v,y,E;if(i.c.g!=t.g)for(l=new eh(e),Ou(l,(Xt(),Nr)),Ee(l,(Ie(),Jn),i),Ee(l,($e(),Ki),(Ms(),Oa)),a.c[a.c.length]=l,g=new yo,us(g,l),mr(g,(Fe(),nn)),m=new yo,us(m,l),mr(m,Zt),_s(i,g),f=new Op,No(f,i),Ee(f,Lo,null),Os(f,m),_s(f,t),KXe(l,g,m),y=new Ns(i.b,0);y.b0&&(v=m/60|0,y=m%60,l=e.q.getDate(),i=e.q.getHours(),i+v>=24&&++l,f=new w.Date(e.q.getFullYear(),e.q.getMonth(),l,t+v,e.q.getMinutes()+y,e.q.getSeconds(),e.q.getMilliseconds()),e.q.setTime(f.getTime()))),g=e.q.getTime(),e.q.setTime(g+36e5),e.q.getHours()!=t&&e.q.setTime(g)}function Z7t(e,t){var i,a,l,f,g,m,v,y,E;for(ii(t,"Layer constraint edge reversal",1),g=new j(e.b);g.ai){On(t);return}switch(h(G(e,($e(),yoe)),319).g){case 2:f=new Ha;break;case 0:f=new e0;break;default:f=new IT}if(a=f.sf(e,l),!f.tf())switch(h(G(e,aTe),347).g){case 2:a=Ezt(l,a);break;case 1:a=mOt(l,a)}Gzt(e,l,a),On(t)}function tKe(e,t,i){var a,l,f,g;return e.ti()?(l=null,f=e.ui(),a=e.mi(1,g=KQ(e,t,i),i,t,f),e.qi()&&!(e.Bh()&&g!=null?ki(g,i):Be(g)===Be(i))?(g!=null&&(l=e.si(g,null)),l=e.ri(i,l),e.xi()&&(l=e.Ai(g,i,l)),l?(l.Sh(a),l.Th()):e.ni(a)):(e.xi()&&(l=e.Ai(g,i,null)),l?(l.Sh(a),l.Th()):e.ni(a)),g):(g=KQ(e,t,i),e.qi()&&!(e.Bh()&&g!=null?ki(g,i):Be(g)===Be(i))&&(l=null,g!=null&&(l=e.si(g,null)),l=e.ri(i,l),l&&l.Th()),g)}function wne(e){var t,i,a,l,f,g,m;if(!e.d){if(m=new xN,t=BL,f=t.a.Zb(e,t),f==null){for(a=new Bn(Bo(e));a.e!=a.i._b();)i=h(Yn(a),24),Mr(m,wne(i));t.a.$b(e)!=null,t.a._b()==0}for(g=m.i,l=(!e.q&&(e.q=new ze(uf,e,11,10)),new Bn(e.q));l.e!=l.i._b();++g)h(Yn(l),371);Mr(m,(!e.q&&(e.q=new ze(uf,e,11,10)),e.q)),bw(m),e.d=new t_((h(ae(ye((kg(),Ct).o),9),17),m.i),m.g),e.e=h(m.g,611),e.e==null&&(e.e=tut),uu(e).b&=-17}return e.d}function hP(e,t,i,a){var l,f,g,m,v,y;if(y=cl(e.e.mg(),t),v=0,l=h(e.g,124),Yo(),h(t,61).bj()){for(g=0;g1&&(v>Ul(m)*_f(m)/2||g.b==0)&&(C=new xU(R),E=Ul(m)/_f(m),y=Rne(C,t,new j2,i,a,l,E),tr(Wf(C.e),y),m=C,B.c[B.c.length]=C,v=0,R.c=le(on,et,1,0,5,1)));return Lr(B,R),B}function ezt(e,t){var i,a,l,f,g,m,v,y,E;for(ii(t,"Hierarchical port dummy size processing",1),v=new ke,E=new ke,a=ce(Xe(G(e,($e(),a3)))),i=a*2,f=new j(e.b);f.a=V&&e.e[v.o]>N*e.b||fe>=i*V)&&(R.c[R.c.length]=m,m=new ke,wo(g,f),f.a.Pb(),y-=E,B=w.Math.max(B,y*e.b+W),y+=fe,ie=fe,fe=0,E=0,W=0);return new Is(B,R)}function izt(e){var t,i,a,l,f,g,m,v,y,E,C,R;for(t=YXe(e),E=(m=new Gv(t).a.Tb().tc(),new pR(m));E.a.hc();){for(y=(l=h(E.a.ic(),38),h(l.kc(),8)),C=y.d.d,R=y.n.b+y.d.a,e.d[y.o]=0,i=y;(f=e.a[i.o])!=y;)a=qIt(i,f),e.c==(Eh(),Yp)?v=a.d.k.b+a.d.a.b-a.c.k.b-a.c.a.b:v=a.c.k.b+a.c.a.b-a.d.k.b-a.d.a.b,g=ce(e.d[i.o])+v,e.d[f.o]=g,C=w.Math.max(C,f.d.d-g),R=w.Math.max(R,g+f.n.b+f.d.a),i=f;i=y;do e.d[i.o]=ce(e.d[i.o])+C,i=e.a[i.o];while(i!=y);e.b[y.o]=C+R}}function y_e(e,t,i){var a,l,f,g,m,v,y,E,C,R;for(MVe(this),i==(M0(),um)?Cr(this.o,e):Cr(this.t,e),E=Jr,y=Ts,g=t.a.Xb().tc();g.hc();)l=h(g.ic(),48),m=h(l.a,417),a=h(l.b,14),v=a.c,v==e&&(v=a.d),m==um?Cr(this.o,v):Cr(this.t,v),R=Fo(X(q(es,1),be,9,0,[v.g.k,v.k,v.a])).b,E=w.Math.min(E,R),y=w.Math.max(y,R);for(C=Fo(X(q(es,1),be,9,0,[e.g.k,e.k,e.a])).b,Iqe(this,C,E,y),f=t.a.Xb().tc();f.hc();)l=h(f.ic(),48),NXe(this,h(l.b,14));this.k=!1}function rzt(e){var t,i,a,l;if(a=Ine((!e.c&&(e.c=ZI(e.f)),e.c),0),e.e==0||e.a==0&&e.f!=-1&&e.e<0)return a;if(t=G0e(e)<0?1:0,i=e.e,l=(a.length+1+RE(yr(e.e)),new tw),t==1&&(l.a+="-"),e.e>0)if(i-=a.length-t,i>=0){for(l.a+="0.";i>_1.length;i-=_1.length)i9e(l,_1);GFe(l,_1,yr(i)),Mi(l,a.substr(t,a.length-t))}else i=t-i,Mi(l,qf(a,t,yr(i))),l.a+=".",Mi(l,cI(a,yr(i)));else{for(Mi(l,a.substr(t,a.length-t));i<-_1.length;i+=_1.length)i9e(l,_1);GFe(l,_1,yr(-i))}return l.a}function Ba(e,t){var i,a,l,f,g,m,v;if(e==null)return null;if(f=e.length,f==0)return"";for(v=le(Zl,Ph,22,f,15,1),x0e(0,f,e.length),x0e(0,f,v.length),V9e(e,0,f,v,0),i=null,m=t,l=0,g=0;l0?qf(i.a,0,f-1):""):e.substr(0,f-1):i?i.a:e}function szt(e){var t,i,a,l,f,g,m,v,y,E,C,R,B;for(i=(y=new bh(e.c.b).a.Tb().tc(),new c0(y));i.a.hc();)t=(m=h(i.a.ic(),38),h(m.lc(),180)),l=t.a,l==null&&(l=""),a=DMt(e.c,l),!a&&l.length==0&&(a=XIt(e)),a&&!_x(a.c,t,!1)&&Gi(a.c,t);for(g=Nn(e.a,0);g.b!=g.d.c;)f=h(Un(g),436),E=f0e(e.c,f.a),B=f0e(e.c,f.b),E&&B&&Gi(E.c,new Is(B,f.c));for(rd(e.a),R=Nn(e.b,0);R.b!=R.d.c;)C=h(Un(R),436),t=IMt(e.c,C.a),v=f0e(e.c,C.b),t&&v&&IEt(t,v,C.c);rd(e.b)}function ozt(e,t,i){var a,l,f,g,m,v,y,E,C;for(v=i+t.c.c.a,C=new j(t.i);C.a1,m=new zp(E.c);Zo(m.a)||Zo(m.b);)g=h(Zo(m.a)?$(m.a):$(m.b),14),y=g.c==E?g.d:g.c,w.Math.abs(Fo(X(q(es,1),be,9,0,[y.g.k,y.k,y.a])).b-f.b)>1&&p9t(e,g,f,l,E)}}function pP(e){var t,i,a,l,f,g,m,v;if(!e.f){if(v=new yN,m=new yN,t=BL,g=t.a.Zb(e,t),g==null){for(f=new Bn(Bo(e));f.e!=f.i._b();)l=h(Yn(f),24),Mr(v,pP(l));t.a.$b(e)!=null,t.a._b()==0}for(a=(!e.s&&(e.s=new ze(Sc,e,21,17)),new Bn(e.s));a.e!=a.i._b();)i=h(Yn(a),158),re(i,62)&&$n(m,h(i,17));bw(m),e.r=new c9e(e,(h(ae(ye((kg(),Ct).o),6),17),m.i),m.g),Mr(v,e.r),bw(v),e.f=new t_((h(ae(ye(Ct.o),5),17),v.i),v.g),uu(e).b&=-3}return e.f}function azt(e){var t,i,a,l,f,g,m,v,y,E,C,R,B,N;for(g=e.o,a=le(In,si,22,g,15,1),l=le(In,si,22,g,15,1),i=e.p,t=le(In,si,22,i,15,1),f=le(In,si,22,i,15,1),y=0;y=0&&!L_(e,E,C);)--C;l[E]=C}for(B=0;B=0&&!L_(e,m,N);)--m;f[N]=m}for(v=0;vt[R]&&Ra[v]&&P7(e,v,R,!1,!0)}function I7(){I7=M,CAe=X(q(Zl,1),Ph,22,15,[48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70]),Rlt=new RegExp(`[ -\r\f]+`);try{RL=X(q(TVt,1),et,1699,0,[new N2((oge(),qU("yyyy-MM-dd'T'HH:mm:ss'.'SSSZ",oI((Vf(),Vf(),jP))))),new N2(qU("yyyy-MM-dd'T'HH:mm:ss'.'SSS",oI(jP))),new N2(qU("yyyy-MM-dd'T'HH:mm:ss",oI(jP))),new N2(qU("yyyy-MM-dd'T'HH:mm",oI(jP))),new N2(qU("yyyy-MM-dd",oI(jP)))])}catch(e){if(e=pr(e),!re(e,78))throw Y(e)}}function nKe(e,t){var i,a,l,f,g;switch(f=new zc,e.a.g){case 1:case 3:wo(f,t.e.a),Gi(f,t.i.k),wo(f,I0(t.j.a)),Gi(f,t.a.k),wo(f,t.f.a);break;default:wo(f,t.e.a),wo(f,I0(t.j.a)),wo(f,t.f.a)}rd(t.f.a),wo(t.f.a,f),Os(t.f,t.e.c),i=h(G(t.e,($e(),Lo)),74),l=h(G(t.j,Lo),74),a=h(G(t.f,Lo),74),(i||l||a)&&(g=new zc,d1e(g,a),d1e(g,l),d1e(g,i),Ee(t.f,Lo,g)),Os(t.j,null),_s(t.j,null),Os(t.e,null),_s(t.e,null),Hs(t.a,null),Hs(t.i,null),t.g&&nKe(e,t.g)}function iKe(e){Y2(e,new O_(q2(V2(H2(W2(new t0,u1),"ELK DisCo"),"Layouter for arranging unconnected subgraphs. The subgraphs themselves are, by default, not laid out."),new nt))),bt(e,u1,Mie,qt(fEe)),bt(e,u1,Tie,qt(lse)),bt(e,u1,WS,qt(fit)),bt(e,u1,Ux,qt(uEe)),bt(e,u1,aye,qt(git)),bt(e,u1,cye,qt(pit)),bt(e,u1,oye,qt(mit)),bt(e,u1,lye,qt(dit)),bt(e,u1,fye,qt(hit)),bt(e,u1,hye,qt(cse)),bt(e,u1,dye,qt(lEe)),bt(e,u1,pye,qt(Yz))}function czt(e,t,i){var a,l,f,g,m,v,y,E,C;for(g=new JHe,y=X(q(In,1),si,22,15,[0]),l=-1,f=0,a=0,v=0;v0){if(l<0&&E.a&&(l=v,f=y[0],a=0),l>=0){if(m=E.b,v==l&&(m-=a++,m==0))return 0;if(!rJe(t,y,E,m,g)){v=l-1,y[0]=f;continue}}else if(l=-1,!rJe(t,y,E,0,g))return 0}else{if(l=-1,E.c.charCodeAt(0)==32){if(C=y[0],Ije(t,y),y[0]>C)continue}else if(yPt(t,E.c,y[0])){y[0]+=E.c.length;continue}return 0}return Djt(g,i)?y[0]:0}function lzt(e,t,i){var a,l,f,g,m;if(a=h(G(e,($e(),doe)),19),i.a>t.a&&(a.pc((kS(),dG))?e.c.a+=(i.a-t.a)/2:a.pc(pG)&&(e.c.a+=i.a-t.a)),i.b>t.b&&(a.pc((kS(),mG))?e.c.b+=(i.b-t.b)/2:a.pc(gG)&&(e.c.b+=i.b-t.b)),h(G(e,(Ie(),Va)),19).pc((xo(),Su))&&(i.a>t.a||i.b>t.b))for(m=new j(e.a);m.at.a&&(a.pc((kS(),dG))?e.c.a+=(i.a-t.a)/2:a.pc(pG)&&(e.c.a+=i.a-t.a)),i.b>t.b&&(a.pc((kS(),mG))?e.c.b+=(i.b-t.b)/2:a.pc(gG)&&(e.c.b+=i.b-t.b)),h(G(e,(Ie(),Va)),19).pc((xo(),Su))&&(i.a>t.a||i.b>t.b))for(g=new j(e.a);g.aB||a+l>y)throw Y(new r8);if(!(C.i&1)&&R!=v)if(E=__(e),f=__(i),Be(e)===Be(i)&&ta;)Gr(f,m,E[--t]);else for(m=a+l;a0&&Swe(e,t,i,a,l,!0)}function hzt(e,t,i){var a,l,f,g,m,v,y,E,C,R;for(E=new I9(new Vv(i)),m=le(Ru,f1,22,e.f.e.c.length,16,1),l1e(m,m.length),i[t.b]=0,y=new j(e.f.e);y.a=e.b.length?(f[l++]=g.b[a++],f[l++]=g.b[a++]):a>=g.b.length?(f[l++]=e.b[i++],f[l++]=e.b[i++]):g.b[a]=m?NQ(e.a,f,t.a,m):NQ(t.a,m,e.a,f);else{if(l=f!=m?f>m?1:-1:Mbe(e.a,t.a,f),l==0)return Kg(),cM;l==1?(R=g,C=DQ(e.a,f,t.a,m)):(R=v,C=DQ(t.a,m,e.a,f))}return y=new l_(R,C.length,C),gA(y),y}function oKe(e,t){var i,a,l,f,g,m;for(g=new Zm(new Ep(e.f.b).a);g.b;){if(f=k0(g),l=h(f.kc(),536),t==1){if(l.Je()!=(qs(),hm)&&l.Je()!=rp)continue}else if(l.Je()!=(qs(),rf)&&l.Je()!=sf)continue;switch(a=h(h(f.lc(),48).b,80),m=h(h(f.lc(),48).a,172),i=m.c,l.Je().g){case 2:a.g.c=e.e.a,a.g.b=w.Math.max(1,a.g.b+i);break;case 1:a.g.c=a.g.c+i,a.g.b=w.Math.max(1,a.g.b-i);break;case 4:a.g.d=e.e.b,a.g.a=w.Math.max(1,a.g.a+i);break;case 3:a.g.d=a.g.d+i,a.g.a=w.Math.max(1,a.g.a-i)}}}function aKe(e,t,i,a){var l,f,g,m,v,y,E;if(f=zU(a),m=ce(mt(G(a,($e(),jMe)))),(m||ce(mt(G(e,OG))))&&!Bd(h(G(e,Ki),83)))l=r6(f),v=d_e(e,i,i==(Oo(),lc)?l:n6(l));else switch(v=new yo,us(v,e),t?(E=v.k,E.a=t.a-e.k.a,E.b=t.b-e.k.b,Gqe(E,0,0,e.n.a,e.n.b),mr(v,$Ze(v,f))):(l=r6(f),mr(v,i==(Oo(),lc)?l:n6(l))),g=h(G(a,(Ie(),Va)),19),y=v.i,f.g){case 2:case 1:(y==(Fe(),bn)||y==ni)&&g.nc((xo(),py));break;case 4:case 3:(y==(Fe(),Zt)||y==nn)&&g.nc((xo(),py))}return v}function mzt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W;for(m=le(In,si,22,t.b.c.length,15,1),y=le(xse,Oe,232,t.b.c.length,0,1),v=le(Eu,Cf,8,t.b.c.length,0,1),C=e.a,R=0,B=C.length;R0&&v[a]&&(N=r_(e.b,v[a],l)),W=w.Math.max(W,l.c.c.b+N);for(f=new j(E.f);f.a"}v!=null&&(t.a+=""+v)}else e.e?(m=e.e.zb,m!=null&&(t.a+=""+m)):(t.a+="?",e.b?(t.a+=" super ",Ene(e.b,t)):e.f&&(t.a+=" extends ",Ene(e.f,t)))}function bzt(e,t){var i,a,l,f,g,m,v,y;for(e.f=t,e.d=h(G(e.f,(UI(),_Ee)),348),e.g=h(G(e.f,SEe),21).a,e.e=ce(Xe(G(e.f,yEe))),e.c=ce(Xe(G(e.f,tG))),JJ(e.b),a=new j(e.f.c);a.a=0)return!1;if(i.e&&l==(Xt(),$a)&&l!=i.e)return!1;if(t.o=i.b,De(i.f,t),i.e=l,l==(Xt(),Nr)||l==oa||l==$a){for(g=new j(t.i);g.a0&&a<=l?(y-=a,f=m,g=m):(e.a==null&&Fte(e),e.a[g]&&(y+=l,f=g)),f>0){De(C,He(f)),m=-1,E=!1;do if(i.hc())v=He(h(i.ic(),21).a+y);else break e;while(v.a<=g)}}else if(e.a==null&&Fte(e),e.a[g]&&(m=g),g==v.a)if(e.a==null&&Fte(e),e.a[g])if(C.c[C.c.length]=v,m=-1,i.hc())v=He(h(i.ic(),21).a+y);else break;else E=!0;++g}return C}function uKe(e){var t,i,a,l;return e.Db&64?Xee(e):(t=new ou(hxe),a=e.k,a?Mi(Mi((t.a+=' "',t),a),'"'):(!e.n&&(e.n=new ze(ea,e,1,7)),e.n.i>0&&(l=(!e.n&&(e.n=new ze(ea,e,1,7)),h(h(ae(e.n,0),137),263)).a,!l||Mi(Mi((t.a+=' "',t),l),'"'))),i=(!e.b&&(e.b=new an(pi,e,4,7)),!(e.b.i<=1&&(!e.c&&(e.c=new an(pi,e,5,8)),e.c.i<=1))),i?t.a+=" [":t.a+=" ",Mi(t,lJ(new LR(Ca),new Bn(e.b))),i&&(t.a+="]"),t.a+=" -> ",i&&(t.a+="["),Mi(t,lJ(new LR(Ca),new Bn(e.c))),i&&(t.a+="]"),t.a)}function Szt(e){var t,i,a,l,f,g;for(l=new ke,g=new j(e.c.i);g.ae.n.b||(i=sa(e,Zt),m=t.d+t.a+(i._b()-1)*g,m>e.n.b)))}function Cne(e,t,i){var a,l,f,g,m,v,y,E;return a=e.a.o==(Kf(),sh)?Jr:Ts,m=XZe(e,new UOe(t,i)),!m.a&&m.c?(Gi(e.c,m),a):m.a?(l=m.a.c,v=m.a.d,i?(y=e.a.c==(Eh(),sb)?v:l,f=e.a.c==sb?l:v,g=e.a.g[f.g.o],E=ce(e.a.p[g.o])+ce(e.a.d[f.g.o])+f.k.b+f.a.b-ce(e.a.d[y.g.o])-y.k.b-y.a.b):(y=e.a.c==(Eh(),Yp)?v:l,f=e.a.c==Yp?l:v,E=ce(e.a.p[e.a.g[f.g.o].o])+ce(e.a.d[f.g.o])+f.k.b+f.a.b-ce(e.a.d[y.g.o])-y.k.b-y.a.b),e.a.n[e.a.g[l.g.o].o]=(vt(),vt(),!0),e.a.n[e.a.g[v.g.o].o]=!0,E):a}function Ane(e,t,i,a,l,f,g){var m,v,y,E,C,R,B;return C=ce(mt(G(t,($e(),$Me)))),R=null,f==(Oo(),Fc)&&a.c.g==i?R=a.c:f==lc&&a.d.g==i&&(R=a.d),y=g,!g||!C||R?(E=(Fe(),Na),R?E=R.i:Bd(h(G(i,Ki),83))&&(E=f==Fc?nn:Zt),v=Fzt(e,t,i,f,E,a),m=OQ((va(i),a)),f==Fc?(Os(m,h(St(v.i,0),11)),_s(m,l)):(Os(m,l),_s(m,h(St(v.i,0),11))),y=new KVe(a,m,v,h(G(v,(Ie(),Jn)),11),f,!R)):(De(g.e,a),B=w.Math.max(ce(Xe(G(g.d,tp))),ce(Xe(G(a,tp)))),Ee(g.d,tp,B)),ir(e.a,a,new d9(y.d,t,f)),y}function hKe(e,t){var i,a,l,f,g,m,v,y,E,C;if(Ee(t,(ha(),wM),0),v=h(G(t,tj),76),t.d.b==0)v?(E=ce(Xe(G(v,Jp)))+e.a+h0e(v,t),Ee(t,Jp,E)):Ee(t,Jp,0);else{for(a=(f=Nn(new Dd(t).a.d,0),new ew(f));v8(a.a);)i=h(Un(a.a),170).c,hKe(e,i);m=h(c9((g=Nn(new Dd(t).a.d,0),new ew(g))),76),C=h(rTt((l=Nn(new Dd(t).a.d,0),new ew(l))),76),y=(ce(Xe(G(C,Jp)))+ce(Xe(G(m,Jp))))/2,v?(E=ce(Xe(G(v,Jp)))+e.a+h0e(v,t),Ee(t,Jp,E),Ee(t,wM,ce(Xe(G(t,Jp)))-y),LGt(e,t)):Ee(t,Jp,y)}}function Czt(e,t){var i,a,l,f,g,m,v,y,E;if(y=h(G(e,(Ie(),pa)),69),a=h(St(e.i,0),11),y==(Fe(),bn)?mr(a,ni):y==ni&&mr(a,bn),h(G(t,($e(),jw)),185).pc((Hl(),C1))){if(v=ce(Xe(G(e,aL))),g=ce(Xe(G(e,c3))),m=h(G(t,s3),275),m==(Qf(),db))for(i=v,E=e.n.a/2-a.k.a,f=new j(a.e);f.a0&&a>=-6?a>=0?vI(f,i-yr(e.e),"."):(f.a=qf(f.a,0,t-1)+"0."+cI(f.a,t-1),vI(f,t+1,hu(_1,0,-yr(a)-1))):(i-t>=1&&(vI(f,t,"."),++i),vI(f,i,"E"),a>0&&vI(f,++i,"+"),vI(f,++i,""+E9(Wc(a)))),e.g=f.a,e.g))}function pKe(e,t,i){var a,l,f,g;this.j=e,this.e=gve(e),this.o=h(G(this.j,(Ie(),sm)),8),this.i=!!this.o,this.p=this.i?h(St(i,va(this.o).o),204):null,l=h(G(e,Va),19),this.g=l.pc((xo(),Su)),this.b=new ke,this.d=new kWe(this.e),g=h(G(this.j,gM),214),this.q=VRt(t,g,this.e),this.k=new E7e(this),f=Ym(X(q(crt,1),et,208,0,[this,this.d,this.k,this.q])),t==(R0(),HG)?(a=new sVe(this.e),f.c[f.c.length]=a,this.c=new sze(a,g,h(this.q,422))):this.c=new IOe(t,this),De(f,this.c),fKe(f,this.e),this.s=u$t(this.k)}function Pzt(e,t){var i,a,l,f;return i=new Ae,a=h(sd(Xf(new oi(null,new di(e.f,16)),i),b_(new qn,new bi,new Si,new it,X(q(nh,1),Oe,150,0,[(Wg(),Bw),th]))),19),l=a._b(),l=l==2?1:0,l==1&&rw(i6(h(sd(go(a.uc(),new Le),F$e(n1(0),new $i)),149).a,2),0)&&(l=0),a=h(sd(Xf(new oi(null,new di(t.f,16)),i),b_(new qn,new bi,new Si,new it,X(q(nh,1),Oe,150,0,[Bw,th]))),19),f=a._b(),f=f==2?1:0,f==1&&rw(i6(h(sd(go(a.uc(),new ht),F$e(n1(0),new $i)),149).a,2),0)&&(f=0),l=e.b[l+1])l+=2;else if(i0)for(a=new vf(h(er(e.a,f),19)),_t(),fa(a,new BF(t)),l=new Ns(f.b,0);l.b=oo?ho(i,Wbe(a)):JE(i,a&jr),g=(++Er,new _Q(10,null,0)),SAt(e.a,g,m-1)):(i=(g.ll().length+f,new MC),ho(i,g.ll())),t.e==0?(a=t.jl(),a>=oo?ho(i,Wbe(a)):JE(i,a&jr)):ho(i,t.ll()),h(g,474).b=i.a}}function Bzt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B;if(ii(t,"Edge splitting",1),e.b.c.length<=2){On(t);return}for(f=new Ns(e.b,0),g=(Rn(f.bCe)?(v=2,g=zi):v==0?(v=1,g=qe):(v=0,g=qe)):(B=qe>=g||g-qe0?(l=a+(N-1)*i,C&&(l+=a),l0){JU(e,i,0),i.a+=String.fromCharCode(a),l=tIt(t,f),JU(e,i,l),f+=l-1;continue}a==39?f+10){if(t=new dge(e.i,e.g),i=e.i,f=i<100?null:new Eg(i),e.xi())for(a=0;a0){for(m=e.g,y=e.i,_A(e),f=y<100?null:new Eg(y),a=0;a0)if(t=new cbe(e.Uh()),l=v<100?null:new Eg(v),rI(e,v,t.g),a=v==1?e.mi(4,ae(t,0),null,0,m):e.mi(6,t,null,-1,m),e.qi()){for(i=new Bn(t);i.e!=i.i._b();)l=e.si(Yn(i),l);l?(l.Sh(a),l.Th()):e.ni(a)}else l?(l.Sh(a),l.Th()):e.ni(a);else rI(e,e.hi(),e.ii()),e.ni(e.mi(6,(_t(),uo),null,-1,m));else if(e.qi())if(v=e.hi(),v>0){for(g=e.ii(),rI(e,v,g),l=v<100?null:new Eg(v),i=0;i>13|(e.m&15)<<9,l=e.m>>4&8191,f=e.m>>17|(e.h&255)<<5,g=(e.h&1048320)>>8,m=t.l&8191,v=t.l>>13|(t.m&15)<<9,y=t.m>>4&8191,E=t.m>>17|(t.h&255)<<5,C=(t.h&1048320)>>8,ut=i*m,ft=a*m,Mt=l*m,Et=f*m,kn=g*m,v!=0&&(ft+=i*v,Mt+=a*v,Et+=l*v,kn+=f*v),y!=0&&(Mt+=i*y,Et+=a*y,kn+=l*y),E!=0&&(Et+=i*E,kn+=a*E),C!=0&&(kn+=i*C),B=ut&Yc,N=(ft&511)<<13,R=B+N,V=ut>>22,ee=ft>>9,ie=(Mt&262143)<<4,fe=(Et&31)<<17,W=V+ee+ie+fe,Ce=Mt>>18,Ue=Et>>5,qe=(kn&4095)<<8,we=Ce+Ue+qe,W+=R>>22,R&=Yc,we+=W>>22,W&=Yc,we&=Kd,Xa(R,W,we)}function bKe(e,t){var i,a,l,f,g;i=ce(Xe(G(t,($e(),rh)))),i<2&&Ee(t,rh,2),a=h(G(t,nf),110),a==(qs(),Oh)&&Ee(t,nf,zU(t)),l=h(G(t,eot),21),l.a==0?Ee(t,(Ie(),gM),new Jee):Ee(t,(Ie(),gM),new J9(l.a)),f=mt(G(t,rL)),f==null&&Ee(t,rL,(vt(),Be(G(t,cm))===Be((ld(),EM)))),g=new jqe(t),Ee(t,(Ie(),Uw),g),Z1e(e.a),fw(e.a,(_o(),Dh),h(G(t,CMe),285)),fw(e.a,Zx,h(G(t,GMe),285)),fw(e.a,Qa,h(G(t,mM),285)),fw(e.a,ec,h(G(t,FG),285)),fw(e.a,qo,JRt(h(G(t,cm),197))),UNe(e.a,g$t(t)),Ee(t,coe,T_e(e.a,t))}function wKe(e,t){var i,a,l,f,g,m,v,y,E,C;if(v=t.length-1,m=t.charCodeAt(v),m==93){if(g=yh(t,wc(91)),g>=0)return l=_6t(e,t.substr(1,g-1)),E=t.substr(g+1,v-(g+1)),t$t(e,E,l)}else{if(i=-1,/\d/.test(String.fromCharCode(m))&&(i=cme(t,wc(46),v-1),i>=0)){a=h(m0e(e,Eje(e,t.substr(1,i-1)),!1),52);try{y=Sl(t.substr(i+1,t.length-(i+1)),zs,zi)}catch(R){throw R=pr(R),re(R,118)?(f=R,Y(new hU(f))):Y(R)}if(y4)if(e.Li(t)){if(e.Dj()){if(l=h(t,42),a=l.ng(),v=a==e.e&&(e.Pj()?l.hg(l.og(),e.Lj())==e.Mj():-1-l.og()==e.pi()),e.Qj()&&!v&&!a&&l.sg()){for(f=0;f=V-1)return null;for(l=new ke,l.c[l.c.length]=t,we=t,g=i,N=-1,m=h(St(e.d.c.b,i),26),B=0;B1&&g0&&(y=e.k.a/f);break;case 2:case 4:l=e.g.n.b,l>0&&(y=e.k.b/l)}Ee(e,(Ie(),nb),y)}if(v=e.n,g=e.a,a)g.a=a.a,g.b=a.b,e.b=!0;else if(t!=sp&&t!=hb&&m!=Na)switch(m.g){case 1:g.a=v.a/2;break;case 2:g.a=v.a,g.b=v.b/2;break;case 3:g.a=v.a/2,g.b=v.b;break;case 4:g.b=v.b/2}else g.a=v.a/2,g.b=v.b/2}function Qzt(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N;for(ii(i,xQe,1),e.c=t,R=e.c.a,f=0,y=new j(R);y.aN){for(B=1,l=m.n.a;l>g;)++B,l=(m.n.a-(B-1)*e.d)/B;De(a,new $ze(e,m,B,l))}for(v=new j(a);v.a1&&Ul(g)*_f(g)/2>m[0]){for(f=0;fm[f];)++f;N=new Rg(W,0,f+1),C=new xU(N),E=Ul(g)/_f(g),v=Rne(C,t,new j2,i,a,l,E),tr(Wf(C.e),v),dS(RS(R,C)),B=new Rg(W,f+1,W.c.length),F0e(R,B),W.c=le(on,et,1,0,5,1),y=0,D9e(m,m.length,0)}else V=R.b.c.length==0?null:St(R.b,0),V!=null&&ibe(R,0),y>0&&(m[y]=m[y-1]),m[y]+=Ul(g)*_f(g),++y,W.c[W.c.length]=g;return W}function T_e(e,t){var i,a,l,f,g,m,v,y,E,C,R;if(e.e&&e.c.c.5?ee-=g*2*(N-.5):N<.5&&(ee+=f*2*(.5-N)),l=m.d.b,eeV.a-W-E&&(ee=V.a-W-E),m.k.a=t+ee}}function _Ke(e,t){var i,a,l,f,g;for(g=new j(e.i);g.a0&&eXe(e,m,C);for(l=new j(C);l.a0&&(e.a=v+(B-1)*f,t.c.b+=e.a,t.e.b+=e.a)),N.a._b()!=0&&(R=new Nte(1,f),B=x_e(R,t,N,W,t.e.b+v-t.c.b),B>0&&(t.e.b+=v+(B-1)*f))}function A_e(e,t,i){var a,l,f,g,m,v;if(t.l==0&&t.m==0&&t.h==0)throw Y(new u8("divide by zero"));if(e.l==0&&e.m==0&&e.h==0)return i&&(rm=Xa(0,0,0)),Xa(0,0,0);if(t.h==G6&&t.m==0&&t.l==0)return I6t(e,i);if(v=!1,t.h>>19&&(t=_S(t),v=!0),g=j8t(t),f=!1,l=!1,a=!1,e.h==G6&&e.m==0&&e.l==0)if(l=!0,f=!0,g==-1)e=DNe((gS(),o3e)),a=!0,v=!v;else return m=kve(e,g),v&&Cee(m),i&&(rm=Xa(0,0,0)),m;else e.h>>19&&(f=!0,e=_S(e),a=!0,v=!v);return g!=-1?gIt(e,g,v,f,i):Bwe(e,t)<0?(i&&(f?rm=_S(e):rm=Xa(e.l,e.m,e.h)),Xa(0,0,0)):h7t(a?e:Xa(e.l,e.m,e.h),t,v,f,l,i)}function oGt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie;for(y=t.c,l=Sge(e.e),C=au(iI(Ua(Ege(e.e)),e.d*e.a,e.c*e.b),-.5),i=l.a-C.a,a=l.b-C.b,g=t.a,i=g.c-i,a=g.d-a,v=new j(y);v.a=0)return i;switch(S0(Vo(e,i))){case 2:{if(dt("",jp(e,i.Wi()).be())){if(v=mI(Vo(e,i)),m=iS(Vo(e,i)),E=Bve(e,t,v,m),E)return E;for(l=c_e(e,t),g=0,C=l._b();gt.e||t.f>e.e)){for(i=0,a=0,g=e.t.a.Xb().tc();g.hc();)l=h(g.ic(),11),Vee(Fo(X(q(es,1),be,9,0,[l.g.k,l.k,l.a])).b,t.f,t.e)&&++i;for(m=e.o.a.Xb().tc();m.hc();)l=h(m.ic(),11),Vee(Fo(X(q(es,1),be,9,0,[l.g.k,l.k,l.a])).b,t.f,t.e)&&--i;for(v=t.t.a.Xb().tc();v.hc();)l=h(v.ic(),11),Vee(Fo(X(q(es,1),be,9,0,[l.g.k,l.k,l.a])).b,e.f,e.e)&&++a;for(f=t.o.a.Xb().tc();f.hc();)l=h(f.ic(),11),Vee(Fo(X(q(es,1),be,9,0,[l.g.k,l.k,l.a])).b,e.f,e.e)&&--a;i0&&i.charCodeAt(0)!=47))throw Y(new un("invalid opaquePart: "+i));if(e&&!(t!=null&&RC(Bj,t.toLowerCase()))&&!(i==null||!Ree(i,IL,DL)))throw Y(new un(xtt+i));if(e&&t!=null&&RC(Bj,t.toLowerCase())&&!$Bt(i))throw Y(new un(xtt+i));if(!wIt(a))throw Y(new un("invalid device: "+a));if(!GIt(l))throw g=l==null?"invalid segments: null":"invalid segment: "+BIt(l),Y(new un(g));if(!(f==null||yh(f,wc(35))==-1))throw Y(new un("invalid query: "+f))}function yKe(e,t){var i;if(t==null||dt(t,Xc)||t.length==0&&e.k!=(o1(),_M))return null;switch(e.k.g){case 1:return YU(t,KS)?(vt(),oM):YU(t,dre)?(vt(),K0):null;case 2:try{return He(Sl(t,zs,zi))}catch(a){if(a=pr(a),re(a,118))return null;throw Y(a)}case 4:try{return xw(t)}catch(a){if(a=pr(a),re(a,118))return null;throw Y(a)}case 3:return t;case 5:return kVe(e),yXe(e,t);case 6:return kVe(e),y8t(e,e.a,t);case 7:try{return i=zFt(e),i.gf(t),i}catch(a){if(a=pr(a),re(a,30))return null;throw Y(a)}default:throw Y(new ba("Invalid type set for this layout option."))}}function fGt(e){var t,i,a,l,f,g,m,v,y,E,C;for(g=new j(e.d.b);g.a0&&YI(y,!0,(qs(),sf)),m.j==(Xt(),Qr)&&dUe(y),dr(e.f,m,t)}}function hGt(e,t,i){var a,l,f,g,m,v,y,E;if(i._b()==0)return!1;if(m=(Yo(),h(t,61).bj()),f=m?i:new w_(i._b()),j0(e.e,t)){if(t.xh())for(y=i.tc();y.hc();)v=y.ic(),bne(e,t,v,re(t,62)&&(h(h(t,17),62).Bb&oo)!=0)||(l=Dg(t,v),f.pc(l)||f.nc(l));else if(!m)for(y=i.tc();y.hc();)v=y.ic(),l=Dg(t,v),f.nc(l)}else{if(i._b()>1)throw Y(new un(Ore));for(E=cl(e.e.mg(),t),a=h(e.g,124),g=0;g1&&g>1;)E=ZZe(e,we),m=h(St(e.d.c.b,g),26),C=h(St(e.d.c.b,g-1),26),Ue=h(W.cd(R++),21).a,ee=d0(Ue,C.a.c.length),Yg(we,ee,C),Yg(E,fe,m),fe=ee,we&&(l.c[l.c.length]=we),we=E,--Ce,++f,--g;for(ie=(a-(l.c.length-1)*e.d.d)/l.c.length,y=new j(l);y.a0&&m7(e,t,!1,!1,l),C=Pte(e,t,!0,!1)):(m7(e,t,!1,v,0),C=Pte(e,t,!0,!1)):E?(m=h(h(er(e.r,t),19),60)._b(),f=KBt(e,t),C=f*m+e.u*(m-1),f>0&&m7(e,t,!0,!1,f)):(m7(e,t,!0,!1,0),C=Pte(e,t,!0,!0)),nne(e,t)==(Xg(),fb)&&(C+=2*e.u),i.a.a=C}function SKe(e,t){var i,a,l,f,g,m,v,y,E,C;if(i=h(Ds(e.b,t),114),h(h(er(e.r,t),19),60).Wb()){i.n.d=0,i.n.a=0;return}i.n.d=e.A.d,i.n.a=e.A.a,l=e.v.pc((Hl(),C1)),E=h(h(er(e.r,t),19),60)._b()==2,m=e.t==(Qf(),Ty),y=e.w.pc((cc(),b3)),C=e.w.pc(Sj),a=0,!l||E&&m?a=Lte(e,t,!1,!1):m?C?(f=SFt(e,t,y),f>0&&T7(e,t,f,!1,!1),a=Lte(e,t,!0,!1)):(T7(e,t,0,!1,y),a=Lte(e,t,!0,!1)):C?(v=h(h(er(e.r,t),19),60)._b(),g=t9t(e,t),a=g*v+e.u*(v-1),g>0&&T7(e,t,g,!0,!1)):(T7(e,t,0,!0,!1),a=Lte(e,t,!0,!0)),nne(e,t)==(Xg(),fb)&&(a+=2*e.u),i.a.b=a}function lr(){lr=M,nPe=(ype(),ma).b,uut=h(ae(ye(ma.b),0),29),sv=h(ae(ye(ma.b),1),29),lut=h(ae(ye(ma.b),2),29),CM=ma.bb,h(ae(ye(ma.bb),0),29),h(ae(ye(ma.bb),1),29),AM=ma.fb,ED=h(ae(ye(ma.fb),0),29),h(ae(ye(ma.fb),1),29),h(ae(ye(ma.fb),2),17),Iy=ma.qb,xut=h(ae(ye(ma.qb),0),29),h(ae(ye(ma.qb),1),17),h(ae(ye(ma.qb),2),17),Gj=h(ae(ye(ma.qb),3),29),jj=h(ae(ye(ma.qb),4),29),MD=h(ae(ye(ma.qb),6),29),SD=h(ae(ye(ma.qb),5),17),fut=ma.j,hut=ma.k,dut=ma.q,put=ma.w,gut=ma.B,mut=ma.A,but=ma.C,wut=ma.D,vut=ma._,_ut=ma.cb,yut=ma.hb}function pGt(e,t,i){var a,l,f,g,m,v,y,E,C,R,B;e.c=0,e.b=0,a=2*t.c.a.c.length+1;e:for(C=i.tc();C.hc();){if(E=h(C.ic(),11),m=E.i==(Fe(),bn)||E.i==ni,B=0,m){if(R=h(G(E,(Ie(),Pl)),8),!R)continue;B+=yUt(e,a,E,R)}else{for(y=new j(E.f);y.a0?(e.f[E.o]=B/(E.d.c.length+E.f.c.length),e.c=w.Math.min(e.c,e.f[E.o]),e.b=w.Math.max(e.b,e.f[E.o])):m&&(e.f[E.o]=B)}}function gGt(e){e.b=null,e.bb=null,e.fb=null,e.qb=null,e.a=null,e.c=null,e.d=null,e.e=null,e.f=null,e.n=null,e.M=null,e.L=null,e.Q=null,e.R=null,e.K=null,e.db=null,e.eb=null,e.g=null,e.i=null,e.j=null,e.k=null,e.gb=null,e.o=null,e.p=null,e.q=null,e.r=null,e.$=null,e.ib=null,e.S=null,e.T=null,e.t=null,e.s=null,e.u=null,e.v=null,e.w=null,e.B=null,e.A=null,e.C=null,e.D=null,e.F=null,e.G=null,e.H=null,e.I=null,e.J=null,e.P=null,e.Z=null,e.U=null,e.V=null,e.W=null,e.X=null,e.Y=null,e._=null,e.ab=null,e.cb=null,e.hb=null,e.nb=null,e.lb=null,e.mb=null,e.ob=null,e.pb=null,e.jb=null,e.kb=null,e.N=!1,e.O=!1}function mGt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe;if(W=t.b.c.length,!(W<3)){for(B=le(In,si,22,W,15,1),C=0,E=new j(t.b);E.ag)&&Cr(e.c,h(V.b,14));++m}f=g}}}function P_e(e){var t;switch(e.d){case 1:{if(e.wi())return e.o!=-2;break}case 2:{if(e.wi())return e.o==-2;break}case 3:case 5:case 4:case 6:case 7:return e.o>-2;default:return!1}switch(t=e.vi(),e.p){case 0:return t!=null&&ce(mt(t))!=kC(e.k,0);case 1:return t!=null&&h(t,192).a!=nr(e.k)<<24>>24;case 2:return t!=null&&h(t,159).a!=(nr(e.k)&jr);case 6:return t!=null&&kC(h(t,149).a,e.k);case 5:return t!=null&&h(t,21).a!=nr(e.k);case 7:return t!=null&&h(t,168).a!=nr(e.k)<<16>>16;case 3:return t!=null&&ce(Xe(t))!=e.j;case 4:return t!=null&&h(t,126).a!=e.j;default:return t==null?e.n!=null:!ki(t,e.n)}}function Pne(e,t){var i,a,l,f;f=e.F,t==null?(e.F=null,Uee(e,null)):(e.F=(dn(t),t),a=yh(t,wc(60)),a!=-1?(l=t.substr(0,a),yh(t,wc(46))==-1&&!dt(l,jS)&&!dt(l,IP)&&!dt(l,yz)&&!dt(l,DP)&&!dt(l,BP)&&!dt(l,OP)&&!dt(l,NP)&&!dt(l,FP)&&(l=Btt),i=uJ(t,wc(62)),i!=-1&&(l+=""+t.substr(i+1,t.length-(i+1))),Uee(e,l)):(l=t,yh(t,wc(46))==-1&&(a=yh(t,wc(91)),a!=-1&&(l=t.substr(0,a)),!dt(l,jS)&&!dt(l,IP)&&!dt(l,yz)&&!dt(l,DP)&&!dt(l,BP)&&!dt(l,OP)&&!dt(l,NP)&&!dt(l,FP)?(l=Btt,a!=-1&&(l+=""+t.substr(a,t.length-a))):l=t),Uee(e,l),l==t&&(e.F=e.D))),e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,5,f,t))}function bGt(e){EA();var t,i,a,l,f,g,m;for(m=new f0,i=new j(e);i.a=m.b.c)&&(m.b=t),(!m.c||t.c<=m.c.c)&&(m.d=m.c,m.c=t),(!m.e||t.d>=m.e.d)&&(m.e=t),(!m.f||t.d<=m.f.d)&&(m.f=t);return a=new QU((yS(),eb)),SI(e,Xit,new Bl(X(q(x5,1),et,341,0,[a]))),g=new QU(Nw),SI(e,qit,new Bl(X(q(x5,1),et,341,0,[g]))),l=new QU(Ow),SI(e,Hit,new Bl(X(q(x5,1),et,341,0,[l]))),f=new QU(fy),SI(e,Wit,new Bl(X(q(x5,1),et,341,0,[f]))),ene(a.c,eb),ene(l.c,Ow),ene(f.c,fy),ene(g.c,Nw),m.a.c=le(on,et,1,0,5,1),Lr(m.a,a.c),Lr(m.a,I0(l.c)),Lr(m.a,f.c),Lr(m.a,I0(g.c)),m}function B6(e,t,i){var a,l,f,g;return e.Rj()&&e.Qj()&&(g=HJ(e,h(i,51)),Be(g)!==Be(i))?(e.ai(t),e.gi(t,jGe(e,t,g)),e.Dj()&&(f=(l=h(i,42),e.Pj()?e.Nj()?l.Cg(e.b,Uo(h(Wt(sc(e.b),e.pi()),17)).n,h(Wt(sc(e.b),e.pi()).jj(),24).Qi(),null):l.Cg(e.b,br(l.mg(),Uo(h(Wt(sc(e.b),e.pi()),17))),null,null):l.Cg(e.b,-1-e.pi(),null,null)),!h(g,42).yg()&&(f=(a=h(g,42),e.Pj()?e.Nj()?a.Ag(e.b,Uo(h(Wt(sc(e.b),e.pi()),17)).n,h(Wt(sc(e.b),e.pi()).jj(),24).Qi(),f):a.Ag(e.b,br(a.mg(),Uo(h(Wt(sc(e.b),e.pi()),17))),null,f):a.Ag(e.b,-1-e.pi(),null,f))),f&&f.Th()),$u(e.b)&&e.ni(e.mi(9,i,g,t,!1)),g):i}function MKe(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we;for(E=ce(Xe(G(e,($e(),S1)))),a=ce(Xe(G(e,eTe))),R=new Bk,Ee(R,S1,E+a),y=t,ee=t.d,W=t.c.g,ie=t.d.g,V=ju(W.c),fe=ju(ie.c),l=new ke,C=V;C<=fe;C++)m=new eh(e),Ou(m,(Xt(),Nr)),Ee(m,(Ie(),Jn),y),Ee(m,Ki,(Ms(),Oa)),Ee(m,zG,R),B=h(St(e.b,C),26),C==V?Yg(m,B.a.c.length-i,B):Hs(m,B),we=ce(Xe(G(y,tp))),we<0&&(we=0,Ee(y,tp,we)),m.n.b=we,N=w.Math.floor(we/2),g=new yo,mr(g,(Fe(),nn)),us(g,m),g.k.b=N,v=new yo,mr(v,Zt),us(v,m),v.k.b=N,_s(y,g),f=new Op,No(f,y),Ee(f,Lo,null),Os(f,v),_s(f,ee),bBt(m,y,f),l.c[l.c.length]=f,y=f;return l}function wGt(e,t){var i,a,l,f,g,m,v,y,E,C;for(e.a=new rUe($Rt(yL)),a=new j(t.a);a.a0;){for(W=(ai(0,v.c.length),h(v.c[0],14)),l=(ai(0,B.c.length),h(B.c[0],14)),ie=l.d.d,f=Qo(ie,l,0),qLt(W,l.d,f),Os(l,null),_s(l,null),N=W.a,t&&Gi(N,new Do(fe)),a=Nn(l.a,0);a.b!=a.d.c;)i=h(Un(a),9),Gi(N,new Do(i));for(ee=W.b,R=new j(l.b);R.a0?nee(this,this.f/this.a):Hf(t.g,t.d[0]).a!=null&&Hf(i.g,i.d[0]).a!=null?nee(this,(ce(Hf(t.g,t.d[0]).a)+ce(Hf(i.g,i.d[0]).a))/2):Hf(t.g,t.d[0]).a!=null?nee(this,Hf(t.g,t.d[0]).a):Hf(i.g,i.d[0]).a!=null&&nee(this,Hf(i.g,i.d[0]).a)}function L_e(e){var t;this.r=hPt(new pN,new $q),this.b=(Yr(),new GA(h(Hn(Ec),274))),this.p=new GA(h(Hn(Ec),274)),this.i=new GA(h(Hn(ylt),274)),this.e=e,this.o=new Do(e.Re()),this.B=e.bf()||ce(mt(e.xe((ur(),hj)))),this.v=h(e.xe((ur(),xM)),19),this.w=h(e.xe(gj),19),this.q=h(e.xe(nD),83),this.t=h(e.xe(uae),275),this.j=h(e.xe(pj),19),this.n=h(f6(e,_ct),119),this.k=ce(Xe(f6(e,bj))),this.d=ce(Xe(f6(e,XCe))),this.u=ce(Xe(f6(e,JCe))),this.s=ce(Xe(f6(e,YCe))),this.A=h(f6(e,ZCe),135),this.c=2*this.d,t=!this.w.pc((cc(),yj)),this.f=new HA(0,t,0),this.g=new HA(1,t,0),gK(this.f,(xf(),Wa),this.g)}function CKe(e,t){var i,a,l,f,g,m,v,y,E,C,R,B;if(t==null||t.length==0)return null;if(f=h(za(e.f,t),27),!f){for(l=(R=new bh(e.d).a.Tb().tc(),new c0(R));l.a.hc();)if(i=(g=h(l.a.ic(),38),h(g.lc(),27)),m=i.f,B=t.length,dt(m.substr(m.length-B,B),t)&&(t.length==m.length||po(m,m.length-t.length-1)==46)){if(f)return null;f=i}if(!f){for(a=(C=new bh(e.d).a.Tb().tc(),new c0(C));a.a.hc();)if(i=(g=h(a.a.ic(),38),h(g.lc(),27)),E=i.g,E!=null){for(v=0,y=E.length;v=1&&(V-g>0&&C>=0?(v.k.a+=W,v.k.b+=f*g):V-g<0&&E>=0&&(v.k.a+=W*V,v.k.b+=f));e.n.a=t.a,e.n.b=t.b,Ee(e,($e(),jw),(Hl(),a=h(bl(AL),10),new Oc(a,h(el(a,a.length),10),0)))}function LKe(e,t){var i,a,l,f,g,m,v,y,E,C;for(v=!0,l=0,y=e.f[t.o],E=t.n.b+e.n,i=e.c[t.o][2],Hu(e.a,y,He(h(St(e.a,y),21).a-1+i)),Hu(e.b,y,ce(Xe(St(e.b,y)))-E+i*e.e),++y,y>=e.i?(++e.i,De(e.a,He(1)),De(e.b,E)):(a=e.c[t.o][1],Hu(e.a,y,He(h(St(e.a,y),21).a+1-a)),Hu(e.b,y,ce(Xe(St(e.b,y)))+E-a*e.e)),(e.q==(G_(),G5)&&(h(St(e.a,y),21).a>e.j||h(St(e.a,y-1),21).a>e.j)||e.q==j5&&(ce(Xe(St(e.b,y)))>e.k||ce(Xe(St(e.b,y-1)))>e.k))&&(v=!1),g=Cn(As(t));Gn(g);)f=h(Tn(g),14),m=f.c.g,e.f[m.o]==y&&(C=LKe(e,m),l=l+h(C.a,21).a,v=v&&ce(mt(C.b)));return e.f[t.o]=y,l=l+e.c[t.o][0],new Is(He(l),(vt(),!!v))}function yGt(e){var t,i,a,l,f,g,m,v,y,E;for(y=new Ir,m=new Ir,f=new j(e);f.a-1){for(l=Nn(m,0);l.b!=l.d.c;)a=h(Un(l),125),a.s=g;for(;m.b!=0;)for(a=h(Ewe(m,0),125),i=new j(a.g);i.a-1){for(f=new j(m);f.a0)&&(v.i=d0(v.i,l.i-1),--v.f,v.f==0&&(m.c[m.c.length]=v))}}function RKe(e,t){var i,a,l,f,g,m,v,y;if(!(t.b==null||e.b==null)){for(U_(e),gP(e),U_(t),gP(t),i=le(In,si,22,e.b.length+t.b.length,15,1),y=0,a=0,g=0;a=m&&l<=v)m<=l&&f<=v?(i[y++]=l,i[y++]=f,a+=2):m<=l?(i[y++]=l,i[y++]=v,e.b[a]=v+1,g+=2):f<=v?(i[y++]=m,i[y++]=f,a+=2):(i[y++]=m,i[y++]=v,e.b[a]=v+1);else if(ve.j&&(e.q=G5,US(e,f));break;case 4:for(e.q=(G_(),VG),US(e,f),y=0,l=new j(e.b);l.ae.k&&(e.q=j5,US(e,f));break;case 6:R=yr(w.Math.ceil(e.f.length*E/100)),US(e,new UF(R));break;case 5:C=yr(w.Math.ceil(e.d*E/100)),US(e,new TE(C));break;default:US(e,f)}X9t(e,t),On(i)}function TGt(e){var t,i,a,l,f,g,m;for(t=new ke,e.g=new ke,e.d=new ke,g=new Zm(new Ep(e.f.b).a);g.b;)f=k0(g),De(t,h(h(f.lc(),48).b,80)),n_(h(f.kc(),536).Je())?De(e.d,h(f.lc(),48)):De(e.g,h(f.lc(),48));for(ete(e,e.d),ete(e,e.g),e.c=new DXe(e.b),bEt(e.c,(Lpe(),zit)),Zee(e,e.d),Zee(e,e.g),Lr(t,e.c.a.b),e.e=new $t(Jr,Jr),e.a=new $t(Ts,Ts),a=new j(t);a.atm)&&m<10);xpe(e.c,new bk),IKe(e),CAt(e.c),vGt(e.f)}function IKe(e){var t,i,a,l,f,g,m;for(t=0,f=new j(e.b.a);f.a=2){for(v=Nn(i,0),g=h(Un(v),9),m=h(Un(v),9);m.a0&&(m=w.Math.max(m,D$e(e.A.b+a.d.b,l))),C=a,R=l,B=f;e.A&&e.A.c>0&&(N=B+e.A.c,E&&(N+=C.d.c),m=w.Math.max(m,(xh(),Ng(gd),w.Math.abs(R-1)<=gd||R==1||isNaN(R)&&isNaN(1)?0:N/(1-R)))),i.n.b=0,i.a.a=m}function BKe(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W;if(i=h(Ds(e.b,t),114),y=h(h(er(e.r,t),19),60),y.Wb()){i.n.d=0,i.n.a=0;return}for(g=e.v.pc((Hl(),C1)),W=e.w.pc((cc(),b3)),E=e.t==(Qf(),db),m=0,v=y.tc(),C=null,B=0,R=0;v.hc();)a=h(v.ic(),111),f=ce(Xe(a.b.xe((t9(),Tj)))),l=a.b.Re().b,g&&T7(e,t,0,E,!E&&W),C?(N=R+C.d.a+e.u+a.d.d,m=w.Math.max(m,(xh(),Ng(gd),w.Math.abs(B-f)<=gd||B==f||isNaN(B)&&isNaN(f)?0:N/(f-B)))):e.A&&e.A.d>0&&(m=w.Math.max(m,D$e(e.A.d+a.d.d,f))),C=a,B=f,R=l;e.A&&e.A.a>0&&(N=R+e.A.a,E&&(N+=C.d.a),m=w.Math.max(m,(xh(),Ng(gd),w.Math.abs(B-1)<=gd||B==1||isNaN(B)&&isNaN(1)?0:N/(1-B)))),i.n.d=0,i.a.b=m}function kGt(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue;return R=e.c[t],B=e.c[i],N=h(G(R,(Ie(),e3)),15),!!N&&N._b()!=0&&N.pc(B)||(W=R.j!=(Xt(),Nr)&&B.j!=Nr,V=h(G(R,pM),8),ee=h(G(B,pM),8),ie=V!=ee,fe=!!V&&V!=R||!!ee&&ee!=B,we=_te(R,(Fe(),bn)),Ce=_te(B,ni),fe=fe|(_te(R,ni)||_te(B,bn)),Ue=fe&&ie||we||Ce,W&&Ue)||R.j==(Xt(),oa)&&B.j==hs||B.j==(Xt(),oa)&&R.j==hs?!1:(E=e.c[t],f=e.c[i],l=KHe(e.e,E,f,(Fe(),nn)),v=KHe(e.i,E,f,Zt),l9t(e.f,E,f),y=IVe(e.b,E,f)+h(l.a,21).a+h(v.a,21).a+e.f.d,m=IVe(e.b,f,E)+h(l.b,21).a+h(v.b,21).a+e.f.b,e.a&&(C=h(G(E,Jn),11),g=h(G(f,Jn),11),a=zHe(e.g,C,g),y+=h(a.a,21).a,m+=h(a.b,21).a),y>m)}function OKe(e,t,i){var a,l,f,g,m,v,y,E,C;if(e.a!=t.Pi())throw Y(new un(eM+t.be()+Y0));if(a=jp((qc(),Zs),t).kk(),a)return a.Pi().dh().Zg(a,i);if(g=jp(Zs,t).mk(),g){if(i==null)return null;if(m=h(i,15),m.Wb())return"";for(C=new Tp,f=m.tc();f.hc();)l=f.ic(),ho(C,g.Pi().dh().Zg(g,l)),C.a+=" ";return E8(C,C.a.length-1)}if(E=jp(Zs,t).nk(),!E.Wb()){for(y=E.tc();y.hc();)if(v=h(y.ic(),140),v.Li(i))try{if(C=v.Pi().dh().Zg(v,i),C!=null)return C}catch(R){if(R=pr(R),!re(R,104))throw Y(R)}throw Y(new un("Invalid value: '"+i+"' for datatype :"+t.be()))}return h(t,737).Ui(),i==null?null:re(i,159)?""+h(i,159).a:sl(i)==zz?sFe(RL[0],h(i,181)):Ga(i)}function RGt(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V;for(ii(i,xQe,1),ert=ce(mt(G(t,($e(),tL)))),e.c=t,N=new ke,m=new j(t.b);m.aV){for(W=1,l=y.n.a;l>v;)++W,l=(y.n.a-(W-1)*e.d)/W;De(a,new o7e(e,y,W))}for(E=new j(a);E.ay?0:y),1),g),e.c[a.a.d])),Ju(zu(Uu(Gu(Fu(new iu,0>-y?0:-y),1),g),e.c[m.a.d]))):(R=1,(re(a.g,153)&&re(m.g,8)||re(m.g,153)&&re(a.g,8))&&(R=2),Ju(zu(Uu(Gu(Fu(new iu,yr(f)),R),e.c[a.a.d]),e.c[m.a.d]))))}function DGt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W;for(i=h(G(e,($e(),Ki)),83),g=e.e,f=e.d,m=g.a+f.b+f.c,v=0-f.d-e.c.b,E=g.b+f.d+f.a-e.c.b,y=new ke,C=new ke,l=new j(t);l.a0),h(E.a.cd(E.c=--E.b),14));f!=a&&E.b>0;)e.a[f.o]=!0,e.a[a.o]=!0,f=(Rn(E.b>0),h(E.a.cd(E.c=--E.b),14));E.b>0&&yf(E)}}function OGt(e){e.q||(e.q=!0,e.p=ra(e,0),e.a=ra(e,1),Ji(e.a,0),e.f=ra(e,2),Ji(e.f,1),xr(e.f,2),e.n=ra(e,3),xr(e.n,3),xr(e.n,4),xr(e.n,5),xr(e.n,6),e.g=ra(e,4),Ji(e.g,7),xr(e.g,8),e.c=ra(e,5),Ji(e.c,7),Ji(e.c,8),e.i=ra(e,6),Ji(e.i,9),Ji(e.i,10),Ji(e.i,11),Ji(e.i,12),xr(e.i,13),e.j=ra(e,7),Ji(e.j,9),e.d=ra(e,8),Ji(e.d,3),Ji(e.d,4),Ji(e.d,5),Ji(e.d,6),xr(e.d,7),xr(e.d,8),xr(e.d,9),xr(e.d,10),e.b=ra(e,9),xr(e.b,0),xr(e.b,1),e.e=ra(e,10),xr(e.e,1),xr(e.e,2),xr(e.e,3),xr(e.e,4),Ji(e.e,5),Ji(e.e,6),Ji(e.e,7),Ji(e.e,8),Ji(e.e,9),Ji(e.e,10),xr(e.e,11),e.k=ra(e,11),xr(e.k,0),xr(e.k,1),e.o=hi(e,12),e.s=hi(e,13))}function NGt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee;for(ii(t,"Interactive crossing minimization",1),g=0,f=new j(e.b);f.a0&&(i+=v.k.a+v.n.a/2,++C),N=new j(v.i);N.a=m&&l<=v)m<=l&&f<=v?a+=2:m<=l?(e.b[a]=v+1,g+=2):f<=v?(i[y++]=l,i[y++]=m-1,a+=2):(i[y++]=l,i[y++]=m-1,e.b[a]=v+1,g+=2);else if(v0),g.a.cd(g.c=--g.b),td(g,a),QE(y,a),w7(a,v.i),lS(y),lS(y),l.a.$b(a)!=null}}function zGt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V;for(ii(t,"Spline SelfLoop pre-processing.",1),y=new Gc,C=new j(e.a);C.a0?l-=864e5:l+=864e5,v=new Wge(no(Wc(t.q.getTime()),l))),E=new tw,y=e.a.length,f=0;f=97&&a<=122||a>=65&&a<=90){for(g=f+1;g=y)throw Y(new un("Missing trailing '"));g+1=14&&y<=16))?t.a.Qb(a)?(i.a?Mi(i.a,i.b):i.a=new ou(i.d),Z2(i.a,"[...]")):(g=__(a),v=new hI(t),Xm(i,FKe(g,v))):re(a,221)?Xm(i,SNt(h(a,221))):re(a,173)?Xm(i,vNt(h(a,173))):re(a,176)?Xm(i,kOt(h(a,176))):re(a,1697)?Xm(i,ENt(h(a,1697))):re(a,37)?Xm(i,xNt(h(a,37))):re(a,378)?Xm(i,kNt(h(a,378))):re(a,736)?Xm(i,yNt(h(a,736))):re(a,106)&&Xm(i,_Nt(h(a,106))):Xm(i,a==null?Xc:Ga(a));return i.a?i.e.length==0?i.a.a:i.a.a+(""+i.e):i.c}function $Gt(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W;if(ce(mt(G(i,($e(),by)))))for(m=new j(i.i);m.a1))););(m>0||R==(Qf(),db)&&(!f.n&&(f.n=new ze(ea,f,1,7)),f.n).i>0)&&(v=!0),m>1&&(y=!0)}v&&t.nc((xo(),Su)),y&&t.nc((xo(),KP))}function UKe(e,t,i){var a,l,f;return l=new L_e(e),J8t(l,i),gZe(l,!1),cd(l.e.We(),new hge(l,!1)),yQ(l,l.f,(xf(),aa),(Fe(),bn)),yQ(l,l.f,ca,ni),yQ(l,l.g,aa,nn),yQ(l,l.g,ca,Zt),gWe(l,bn),gWe(l,ni),J9e(l,Zt),J9e(l,nn),Gm(),a=l.v.pc((Hl(),gb))&&l.w.pc((cc(),PL))?iwe(l):null,a&&PEt(l.a,a),iUt(l),BDt(l),ODt(l),WGt(l),RUt(l),oBt(l),lte(l,bn),lte(l,ni),LUt(l),gzt(l),t&&(V6t(l),aBt(l),lte(l,Zt),lte(l,nn),f=l.w.pc((cc(),LL)),dXe(l,f,bn),dXe(l,f,ni),pXe(l,f,Zt),pXe(l,f,nn),Fa(new oi(null,new di(new bh(l.i),0)),new Wq),Fa(go(new oi(null,b1e(l.r).wc()),new gN),new mN),cOt(l),l.e.Ue(l.o),Fa(new oi(null,b1e(l.r).wc()),new pE)),l.o}function XGt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N;for(ii(t,"Spline SelfLoop positioning",1),E=h(G(e,($e(),kMe)),345),y=new j(e.b);y.a2?(E=new ke,Lr(E,new Rg(ee,1,ee.b)),f=pJe(E,fe+e.a),ie=new Zte(f),No(ie,t),i.c[i.c.length]=ie):a?ie=h(Ii(e.b,s1(t)),247):ie=h(Ii(e.b,z0(t)),247),v=s1(t),a&&(v=z0(t)),g=GOt(V,v),y=fe+e.a,g.a?(y+=w.Math.abs(V.b-C.b),W=new $t(C.a,(C.b+V.b)/2)):(y+=w.Math.abs(V.a-C.a),W=new $t((C.a+V.a)/2,C.b)),a?dr(e.d,t,new _we(ie,g,W,y)):dr(e.c,t,new _we(ie,g,W,y)),dr(e.b,t,ie),N=(!t.n&&(t.n=new ze(ea,t,1,7)),t.n),B=new Bn(N);B.e!=B.i._b();)R=h(Yn(B),137),l=C6(e,R,!0,0,0),i.c[i.c.length]=l}function ZGt(){ci(Ly,new cX),ci(Ri,new IN),ci(Lu,new NN),ci(ch,new UN),ci(Rae,new gX),ci(Oj,new zN),ci(eg,new GN),ci(kL,new Xh),ci(mD,new $k),ci(Tae,new PN),ci(Qw,new Vk),ci(uf,new sX),ci(ah,new Wk),ci(nv,new ro),ci(iv,new oX),ci(Sc,new aX),ci(tv,new vE),ci(Aa,new LN),ci(ko,new lX),ci(fl,new xp),ci(lo,new uX),ci(q(Mc,1),new QT),ci(qx,new Hk),ci($P,new kN),ci(zz,new RN),ci(dPe,new Ld),ci(Eo,new Xb),ci(AAe,new qk),ci(kAe,new eC),ci(ePe,new DN),ci(Nj,new Xk),ci(aM,new BN),ci(Po,new Yk),ci(Kxe,new Zk),ci(J0,new Yb),ci(Jxe,new fX),ci(ZAe,new Zb),ci(pPe,new ON),ci(Q0,new Kk),ci(Se,new hX),ci(LAe,new dX),ci(gPe,new pX)}function KGt(e){var t,i,a,l,f,g,m,v;for(t=null,a=new j(e);a.a0&&i.c==0&&(!t&&(t=new ke),t.c[t.c.length]=i);if(t)for(;t.c.length!=0;){if(i=h(L0(t,0),205),i.b&&i.b.c.length>0){for(f=(!i.b&&(i.b=new ke),new j(i.b));f.aQo(e,i,0))return new Is(l,i)}else if(ce(Hf(l.g,l.d[0]).a)>ce(Hf(i.g,i.d[0]).a))return new Is(l,i)}for(m=(!i.e&&(i.e=new ke),i.e).tc();m.hc();)g=h(m.ic(),205),v=(!g.b&&(g.b=new ke),g.b),g_(0,v.c.length),UR(v.c,0,i),g.c==v.c.length&&(t.c[t.c.length]=g)}return null}function JGt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W;for(ii(t,"Label dummy insertions",1),C=new ke,g=ce(Xe(G(e,($e(),N5)))),y=ce(Xe(G(e,c3))),E=h(G(e,nf),110),B=new j(e.a);B.a>16==-10?i=h(e.Cb,268).zj(t,i):e.Db>>16==-15&&(!t&&(t=(yt(),zh)),!y&&(y=(yt(),zh)),e.Cb.Hg()&&(v=new Wd(e.Cb,1,13,y,t,$p(Vc(h(e.Cb,53)),e),!1),i?i.Sh(v):i=v));else if(re(e.Cb,96))e.Db>>16==-23&&(re(t,96)||(t=(yt(),ff)),re(y,96)||(y=(yt(),ff)),e.Cb.Hg()&&(v=new Wd(e.Cb,1,10,y,t,$p(Ea(h(e.Cb,24)),e),!1),i?i.Sh(v):i=v));else if(re(e.Cb,411))for(m=h(e.Cb,742),g=(!m.b&&(m.b=new bC(new lK)),m.b),f=(a=new Zm(new Ep(g.a).a),new wC(a));f.a.b;)l=h(k0(f.a).kc(),84),i=GS(l,x7(l,m),i)}return i}function ejt(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V;for(ii(i,"Depth-first cycle removal",1),E=t.a,W=E.c.length,e.a=le(In,si,22,W,15,1),WDe(e.a),e.b=le(In,si,22,W,15,1),WDe(e.b),g=0,y=new j(E);y.a=0){for(v=null,m=new Ns(E.a,y+1);m.b=y.c.c.length?E=r0e((Xt(),hs),Nr):E=r0e((Xt(),Nr),Nr),E*=2,f=i.a.g,i.a.g=w.Math.max(f,f+(E-f)),g=i.b.g,i.b.g=w.Math.max(g,g+(E-g)),l=t}}function WKe(e,t){var i,a,l,f,g,m,v,y,E;for(g=h(h(er(e.r,t),19),60),E=g._b()==2||g._b()>2&&e.w.pc((cc(),b3)),f=g.tc();f.hc();)if(l=h(f.ic(),111),!(!l.c||l.c.d.c.length<=0)){switch(y=l.b.Re(),m=l.c,v=m.i,v.b=(a=m.n,m.e.a+a.b+a.c),v.a=(i=m.n,m.e.b+i.d+i.a),t.g){case 1:E?(v.c=-v.b-e.s,Mh(m,(rl(),cf))):(v.c=y.a+e.s,Mh(m,(rl(),Uh))),v.d=-v.a-e.s,Ud(m,(Nc(),lf));break;case 3:E?(v.c=-v.b-e.s,Mh(m,(rl(),cf))):(v.c=y.a+e.s,Mh(m,(rl(),Uh))),v.d=y.b+e.s,Ud(m,(Nc(),If));break;case 2:v.c=y.a+e.s,E?(v.d=-v.a-e.s,Ud(m,(Nc(),lf))):(v.d=y.b+e.s,Ud(m,(Nc(),If))),Mh(m,(rl(),Uh));break;case 4:v.c=-v.b-e.s,E?(v.d=-v.a-e.s,Ud(m,(Nc(),lf))):(v.d=y.b+e.s,Ud(m,(Nc(),If))),Mh(m,(rl(),cf))}E=!1}}function N7(e,t){var i;if(e.e)throw Y(new ba((Fd(ise),mie+ise.k+bie)));if(!JEt(e.a,t))throw Y(new na(XJe+t+YJe));if(t==e.d)return e;switch(i=e.d,e.d=t,i.g){case 0:switch(t.g){case 2:U0(e);break;case 1:$g(e),U0(e);break;case 4:I_(e),U0(e);break;case 3:I_(e),$g(e),U0(e)}break;case 2:switch(t.g){case 1:$g(e),cne(e);break;case 4:I_(e),U0(e);break;case 3:I_(e),$g(e),U0(e)}break;case 1:switch(t.g){case 2:$g(e),cne(e);break;case 4:$g(e),I_(e),U0(e);break;case 3:$g(e),I_(e),$g(e),U0(e)}break;case 4:switch(t.g){case 2:I_(e),U0(e);break;case 1:I_(e),$g(e),U0(e);break;case 3:$g(e),cne(e)}break;case 3:switch(t.g){case 2:$g(e),I_(e),U0(e);break;case 1:$g(e),I_(e),$g(e),U0(e);break;case 4:$g(e),cne(e)}}return e}function W_(e,t){var i;if(e.d)throw Y(new ba((Fd(yse),mie+yse.k+bie)));if(!KEt(e.a,t))throw Y(new na(XJe+t+YJe));if(t==e.c)return e;switch(i=e.c,e.c=t,i.g){case 0:switch(t.g){case 2:Km(e);break;case 1:Vg(e),Km(e);break;case 4:D_(e),Km(e);break;case 3:D_(e),Vg(e),Km(e)}break;case 2:switch(t.g){case 1:Vg(e),lne(e);break;case 4:D_(e),Km(e);break;case 3:D_(e),Vg(e),Km(e)}break;case 1:switch(t.g){case 2:Vg(e),lne(e);break;case 4:Vg(e),D_(e),Km(e);break;case 3:Vg(e),D_(e),Vg(e),Km(e)}break;case 4:switch(t.g){case 2:D_(e),Km(e);break;case 1:D_(e),Vg(e),Km(e);break;case 3:Vg(e),lne(e)}break;case 3:switch(t.g){case 2:Vg(e),D_(e),Km(e);break;case 1:Vg(e),D_(e),Vg(e),Km(e);break;case 4:Vg(e),lne(e)}}return e}function HKe(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee;for(l=new ke,N=new j(t.a);N.aee?v:ee,fe=new j(E.i);fe.a=y&&Ce>=V&&(R+=N.k.b+W.k.b+W.a.b-we,++m));if(i)for(g=new j(ie.d);g.a=y&&Ce>=V&&(R+=N.k.b+W.k.b+W.a.b-we,++m))}m>0&&(Ue+=R/m,++B)}B>0?(t.a=l*Ue/B,t.i=B):(t.a=0,t.i=0)}function fjt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe;for(e.e=t,m=VFt(t),Ue=new ke,a=new j(m);a.a0&&(C.d+=y.n.d,C.d+=y.d),C.a>0&&(C.a+=y.n.a,C.a+=y.d),C.b>0&&(C.b+=y.n.b,C.b+=y.d),C.c>0&&(C.c+=y.n.c,C.c+=y.d),C}function bjt(e,t,i){var a;if(ii(i,"StretchWidth layering",1),t.a.c.length==0){On(i);return}for(e.c=t,e.t=0,e.u=0,e.i=Jr,e.g=Ts,e.d=ce(Xe(G(t,($e(),rh)))),lDt(e),MFt(e),UOt(e),IBt(e),s5t(e),e.i=w.Math.max(1,e.i),e.g=w.Math.max(1,e.g),e.d=e.d/e.i,e.f=e.g/e.i,e.s=y6t(e),a=new lu(e.c),De(e.c.b,a),e.r=od(e.p),e.n=$9(e.k,e.k.length);e.r.c.length!=0;)e.o=zIt(e),!e.o||yVe(e)&&e.b.a._b()!=0?(SDt(e,a),a=new lu(e.c),De(e.c.b,a),wo(e.a,e.b),e.b.a.Pb(),e.t=e.u,e.u=0):yVe(e)?(e.c.b.c=le(on,et,1,0,5,1),a=new lu(e.c),De(e.c.b,a),e.t=0,e.u=0,e.b.a.Pb(),e.a.a.Pb(),++e.f,e.r=od(e.p),e.n=$9(e.k,e.k.length)):(Hs(e.o,a),Sa(e.r,e.o),Cr(e.b,e.o),e.t=e.t-e.k[e.o.o]*e.d+e.j[e.o.o],e.u+=e.e[e.o.o]*e.d);t.a.c=le(on,et,1,0,5,1),iP(t.b),On(i)}function XKe(e){var t,i,a,l,f,g,m,v,y,E,C,R,B,N,W,V;for(N=new j(e);N.a0&&(e.a[t.c.o][t.o].d+=al(e.f,24)*W6*.07000000029802322-.03500000014901161,e.a[t.c.o][t.o].a=e.a[t.c.o][t.o].d/e.a[t.c.o][t.o].b)}}function wjt(e,t,i,a,l){var f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et,kn;Mt=Ii(e.e,a),Mt==null&&(Mt=new SC,B=h(Mt,191),ie=t+"_s",fe=ie+l,R=new rx(fe),Og(B,Rh,R)),ft=h(Mt,191),ox(i,ft),kn=new SC,$m(kn,"x",a.j),$m(kn,"y",a.k),Og(ft,jet,kn),qe=new SC,$m(qe,"x",a.b),$m(qe,"y",a.c),Og(ft,"endPoint",qe),C=x8((!a.a&&(a.a=new vs(oh,a,5)),a.a)),N=!C,N&&(Ue=new Om,f=new OZ(Ue),mo((!a.a&&(a.a=new vs(oh,a,5)),a.a),f),Og(ft,Sre,Ue)),v=gte(a),we=!!v,we&&Qwe(e.a,ft,xxe,zte(e,gte(a))),ee=mte(a),Ce=!!ee,Ce&&Qwe(e.a,ft,yxe,zte(e,mte(a))),y=(!a.e&&(a.e=new an(ts,a,10,9)),a.e).i==0,W=!y,W&&(ut=new Om,g=new oNe(e,ut),mo((!a.e&&(a.e=new an(ts,a,10,9)),a.e),g),Og(ft,Sxe,ut)),E=(!a.g&&(a.g=new an(ts,a,9,10)),a.g).i==0,V=!E,V&&(Et=new Om,m=new aNe(e,Et),mo((!a.g&&(a.g=new an(ts,a,9,10)),a.g),m),Og(ft,Exe,Et))}function F7(e){var t,i,a,l,f,g,m,v,y,E,C;if(e==null)throw Y(new vh(Xc));if(y=e,f=e.length,v=!1,f>0&&(t=e.charCodeAt(0),(t==45||t==43)&&(e=e.substr(1,e.length-1),--f,v=t==45)),f==0)throw Y(new vh(W0+y+'"'));for(;e.length>0&&e.charCodeAt(0)==48;)e=e.substr(1,e.length-1),--f;if(f>(GZe(),Fnt)[10])throw Y(new vh(W0+y+'"'));for(l=0;l0&&(C=-qNe(e.substr(0,a),10),e=e.substr(a,e.length-a),f-=a,i=!1);f>=g;){if(a=qNe(e.substr(0,g),10),e=e.substr(g,e.length-g),f-=g,i)i=!1;else{if(Ma(C,m)<0)throw Y(new vh(W0+y+'"'));C=Jm(C,E)}C=Qm(C,a)}if(Ma(C,0)>0)throw Y(new vh(W0+y+'"'));if(!v&&(C=pS(C),Ma(C,0)<0))throw Y(new vh(W0+y+'"'));return C}function vjt(e,t,i,a,l){var f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt;for(fe=0,N=0,B=0,R=1,ie=new Bn((!e.a&&(e.a=new ze(Br,e,10,11)),e.a));ie.e!=ie.i._b();)V=h(Yn(ie),35),R+=Bp(Th(V)),ut=V.g,N=w.Math.max(N,ut),C=V.f,B=w.Math.max(B,C),fe+=ut*C;for(W=(!e.a&&(e.a=new ze(Br,e,10,11)),e.a).i,g=fe+2*a*a*R*W,f=w.Math.sqrt(g),v=w.Math.max(f*i,N),m=w.Math.max(f/i,B),ee=new Bn((!e.a&&(e.a=new ze(Br,e,10,11)),e.a));ee.e!=ee.i._b();)V=h(Yn(ee),35),ft=l.b+(al(t,26)*bP+al(t,27)*wP)*(v-V.g),Mt=l.b+(al(t,26)*bP+al(t,27)*wP)*(m-V.f),Yu(V,ft),Zu(V,Mt);for(qe=v+(l.b+l.c),Ue=m+(l.d+l.a),Ce=new Bn((!e.a&&(e.a=new ze(Br,e,10,11)),e.a));Ce.e!=Ce.i._b();)for(we=h(Yn(Ce),35),E=Cn(Th(we));Gn(E);)y=h(Tn(E),105),rP(y)||B$t(y,t,qe,Ue);qe+=l.b+l.c,Ue+=l.d+l.a,H_(e,qe,Ue,!1,!0)}function _jt(e,t,i,a){var l,f,g,m,v,y,E,C,R,B,N,W,V,ee;if(W=e.k,V=e.n,R=e.d,t){for(C=a/2*(t._b()-1),B=0,y=t.tc();y.hc();)m=h(y.ic(),8),C+=m.n.a,B=w.Math.max(B,m.n.b);for(ee=W.a-(C-V.a)/2,g=W.b-R.d+B,l=V.a/(t._b()+1),f=l,v=t.tc();v.hc();)m=h(v.ic(),8),m.k.a=ee,m.k.b=g-m.n.b,ee+=m.n.a+a/2,E=_Ye(m),E.k.a=m.n.a/2-E.a.a,E.k.b=m.n.b,N=h(G(m,(Ie(),SG)),11),N.d.c.length+N.f.c.length==1&&(N.k.a=f-N.a.a,N.k.b=0,us(N,e)),f+=l}if(i){for(C=a/2*(i._b()-1),B=0,y=i.tc();y.hc();)m=h(y.ic(),8),C+=m.n.a,B=w.Math.max(B,m.n.b);for(ee=W.a-(C-V.a)/2,g=W.b+V.b+R.a-B,l=V.a/(i._b()+1),f=l,v=i.tc();v.hc();)m=h(v.ic(),8),m.k.a=ee,m.k.b=g,ee+=m.n.a+a/2,E=_Ye(m),E.k.a=m.n.a/2-E.a.a,E.k.b=0,N=h(G(m,(Ie(),SG)),11),N.d.c.length+N.f.c.length==1&&(N.k.a=f-N.a.a,N.k.b=V.b,us(N,e)),f+=l}}function yjt(e,t){var i,a,l,f,g,m,v,y,E,C,R;for(l=new j(e.a.b);l.aTs||t.o==M1&&E0&&Yu(ee,we*Ue),Ce>0&&Zu(ee,Ce*qe);for(vee(e.b,new So),t=new ke,m=new Zm(new Ep(e.c).a);m.b;)g=k0(m),a=h(g.kc(),105),i=h(g.lc(),363).a,l=j_(a,!1,!1),C=mqe(s1(a),m6(l),i),R6(C,l),fe=Eqe(a),fe&&Qo(t,fe,0)==-1&&(t.c[t.c.length]=fe,yUe(fe,(Rn(C.b!=0),h(C.a.a.c,9)),i));for(V=new Zm(new Ep(e.d).a);V.b;)W=k0(V),a=h(W.kc(),105),i=h(W.lc(),363).a,l=j_(a,!1,!1),C=mqe(z0(a),BA(m6(l)),i),C=BA(C),R6(C,l),fe=Sqe(a),fe&&Qo(t,fe,0)==-1&&(t.c[t.c.length]=fe,yUe(fe,(Rn(C.b!=0),h(C.c.b.c,9)),i))}function Tjt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie;for(ii(t,"Inverted port preprocessing",1),y=e.b,v=new Ns(y,0),i=null,ie=new ke;v.b0&&(h(Ds(e.b,t),114).a.b=i)}function Cjt(e,t,i,a,l){var f,g,m,v,y,E,C,R,B,N,W,V,ee;switch(R=OA(e.i),N=OA(t.i),B=tr(Ua(e.k),e.a),W=tr(Ua(t.k),t.a),v=tr(new $t(B.a,B.b),au(new d_(R),1.3*i)),V=tr(new $t(W.a,W.b),au(new d_(N),1.3*a)),m=w.Math.abs(v.a-V.a),ml+2&&yee(e.charCodeAt(l+1),IAe,DAe)&&yee(e.charCodeAt(l+2),IAe,DAe))if(i=zCt(e.charCodeAt(l+1),e.charCodeAt(l+2)),l+=2,a>0?(i&192)==128?t[m++]=i<<24>>24:a=0:i>=128&&((i&224)==192?(t[m++]=i<<24>>24,a=2):(i&240)==224?(t[m++]=i<<24>>24,a=3):(i&248)==240&&(t[m++]=i<<24>>24,a=4)),a>0){if(m==a){switch(m){case 2:{Lg(v,((t[0]&31)<<6|t[1]&63)&jr);break}case 3:{Lg(v,((t[0]&15)<<12|(t[1]&63)<<6|t[2]&63)&jr);break}}m=0,a=0}}else{for(f=0;f0&&De(e.p,E),De(e.o,E);t-=a,B=v+t,y+=t*e.e,Hu(e.a,m,He(B)),Hu(e.b,m,y),e.j=wf(e.j,B),e.k=w.Math.max(e.k,y),e.d+=t,t+=W}}function KKe(){KKe=M;var e,t,i;for(new kI(1,0),new kI(10,0),new kI(0,0),Unt=le(Qre,be,216,11,0,1),_1=le(Zl,Ph,22,100,15,1),_3e=X(q(ks,1),Wo,22,15,[1,5,25,125,625,3125,15625,78125,390625,1953125,9765625,48828125,244140625,1220703125,6103515625,30517578125,152587890625,762939453125,3814697265625,19073486328125,95367431640625,476837158203125,0x878678326eac9]),y3e=le(In,si,22,_3e.length,15,1),x3e=X(q(ks,1),Wo,22,15,[1,10,100,Pw,V6,uie,1e6,1e7,1e8,W7,1e10,1e11,1e12,1e13,1e14,1e15,1e16]),E3e=le(In,si,22,x3e.length,15,1),S3e=le(Qre,be,216,11,0,1),e=0;e1)for(B=new y_e(N,fe,a),mo(fe,new KOe(e,B)),g.c[g.c.length]=B,C=fe.a.Xb().tc();C.hc();)E=h(C.ic(),48),Sa(f,E.b);if(m.a._b()>1)for(B=new y_e(N,m,a),mo(m,new JOe(e,B)),g.c[g.c.length]=B,C=m.a.Xb().tc();C.hc();)E=h(C.ic(),48),Sa(f,E.b)}}function Ljt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N;for(ii(t,"Label dummy switching",1),C=h(G(e,($e(),DG)),276),a=h(sd(go(Jf(new oi(null,new di(e.b,16)),new GO),new jO),zA(new pn,new Vt,new wr,X(q(nh,1),Oe,150,0,[(Wg(),th)]))),15),g=C==(JA(),zse)||C==Nse?ADt(e):null,f=a.tc();f.hc();){switch(l=h(f.ic(),8),i=tDt(l),!i&&(i=C),m=EDt(l),E=X5t(l),R=null,i.g){case 2:R=sNt(l,g,m,E);break;case 0:R=(B=m.a._b()+E.c.length+1,N=(B-1)/2|0,Nm.a._b()?h(St(E,N-m.a._b()-1),8):null);break;case 1:R=yFt(l,g,m,E);break;case 4:yWe(l,i),R=(y=Zbe(l),y?m.a._b()==0?null:h(m.a.cd(uA(m,0)),8):E.c.length==0?null:h(St(E,E.c.length-1),8));break;case 3:yWe(l,i),R=(v=Zbe(l),v?E.c.length==0?null:h(St(E,E.c.length-1),8):m.a._b()==0?null:h(m.a.cd(uA(m,0)),8))}R&&tGt(l,R),P5t(l)}On(t)}function D_e(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe;if(R=t.length,R>0&&(v=t.charCodeAt(0),v!=64)){if(v==37&&(C=t.lastIndexOf("%"),y=!1,C!=0&&(C==R-1||(y=t.charCodeAt(C+1)==46)))){if(g=t.substr(1,C-1),fe=dt("%",g)?null:I_e(g),a=0,y)try{a=Sl(t.substr(C+2,t.length-(C+2)),zs,zi)}catch(we){throw we=pr(we),re(we,118)?(m=we,Y(new hU(m))):Y(we)}for(V=sbe(e.pg());V.hc();)if(N=MU(V),re(N,469)&&(l=h(N,609),ie=l.d,(fe==null?ie==null:dt(fe,ie))&&a--==0))return l;return null}if(E=t.lastIndexOf("."),B=E==-1?t:t.substr(0,E),i=0,E!=-1)try{i=Sl(t.substr(E+1,t.length-(E+1)),zs,zi)}catch(we){if(we=pr(we),re(we,118))B=t;else throw Y(we)}for(B=dt("%",B)?null:I_e(B),W=sbe(e.pg());W.hc();)if(N=MU(W),re(N,174)&&(f=h(N,174),ee=f.be(),(B==null?ee==null:dt(B,ee))&&i--==0))return f;return null}return wKe(e,t)}function kjt(e){w_e();var t,i,a,l,f,g,m,v,y,E,C,R,B,N,W,V;if(e==null)return null;if(C=e.length*8,C==0)return"";for(m=C%24,B=C/24|0,R=m!=0?B+1:B,f=le(Zl,Ph,22,R*4,15,1),g=0,l=0,v=0;v>24,y=(t&3)<<24>>24,N=t&-128?(t>>2^192)<<24>>24:t>>2<<24>>24,W=i&-128?(i>>4^240)<<24>>24:i>>4<<24>>24,V=a&-128?(a>>6^252)<<24>>24:a>>6<<24>>24,f[g++]=tg[N],f[g++]=tg[W|y<<4],f[g++]=tg[E<<2|V],f[g++]=tg[a&63];return m==8?(t=e[l],y=(t&3)<<24>>24,N=t&-128?(t>>2^192)<<24>>24:t>>2<<24>>24,f[g++]=tg[N],f[g++]=tg[y<<4],f[g++]=61,f[g++]=61):m==16&&(t=e[l],i=e[l+1],E=(i&15)<<24>>24,y=(t&3)<<24>>24,N=t&-128?(t>>2^192)<<24>>24:t>>2<<24>>24,W=i&-128?(i>>4^240)<<24>>24:i>>4<<24>>24,f[g++]=tg[N],f[g++]=tg[W|y<<4],f[g++]=tg[E<<2],f[g++]=61),hu(f,0,f.length)}function Rjt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt;for(Ue=t.a.c,y=t.a.c+t.a.b,fe=e.c&&jFt(e,t),a=fe?(Ue+y)/2:Ue+(t.s+1)*e.b,m=t.d.a.Xb().tc();m.hc();)if(g=h(m.ic(),14),v=h(Ii(t.c,g),589),ft=v.f,Mt=v.a,Ce=new $t(a,ft),ut=new $t(a,Mt),we=new $t(Ue-10,ft),qe=new $t(y,Mt),C=!1,R=!1,v.b&&(C=!0,we.a=y),v.c&&(R=!0,qe.a=Ue-10),B=v.d,N=v.e,!fe||!(B||N)||R||C)t.d.a._b()==1?pU(g.a,X(q(es,1),be,9,0,[we,Ce,ut,qe])):(i=new $t(a,t.b),pU(g.a,X(q(es,1),be,9,0,[we,Ce,i,ut,qe])));else if(B&&N){for(E=0,W=0,ie=new j(g.d.g.i);ie.a=0&&gB&&(f&&(zm(we,R),zm(Ue,He(y.a-1))),Et=i.b,kn+=R+t,R=0,E=w.Math.max(E,i.b+i.c+Mt)),Yu(m,Et),Zu(m,kn),E=w.Math.max(E,Et+Mt+i.c),R=w.Math.max(R,C),Et+=Mt+t;if(E=w.Math.max(E,a),ft=kn+R+i.a,ft0&&(e.p=-(e.p-1)),e.p>zs&&s0e(t,e.p-V0),g=t.q.getDate(),_I(t,1),e.k>=0&&rLt(t,e.k),e.c>=0?_I(t,e.c):e.k>=0?(v=new bbe(t.q.getFullYear()-V0,t.q.getMonth(),35),a=35-v.q.getDate(),_I(t,a0&&e.f<12&&(e.f+=12),rMt(t,e.f==24&&e.g?0:e.f),e.j>=0&&Z4t(t,e.j),e.n>=0&&ckt(t,e.n),e.i>=0&&hOe(t,no(Jm(h6(Wc(t.q.getTime()),Pw),Pw),e.i)),e.a&&(l=new T8,s0e(l,l.q.getFullYear()-V0-80),_K(Wc(t.q.getTime()),Wc(l.q.getTime()))&&s0e(t,l.q.getFullYear()-V0+100)),e.d>=0){if(e.c==-1)i=(7+e.d-t.q.getDay())%7,i>3&&(i-=7),m=t.q.getMonth(),_I(t,t.q.getDate()+i),t.q.getMonth()!=m&&_I(t,t.q.getDate()+(i>0?-7:7));else if(t.q.getDay()!=e.d)return!1}return e.o>zs&&(f=t.q.getTimezoneOffset(),hOe(t,no(Wc(t.q.getTime()),(e.o-f)*60*Pw))),!0}function JKe(){JKe=M,fs=new Kv,ir(fs,(Fe(),aD),xd),ir(fs,rD,_d),ir(fs,sD,yd),ir(fs,oD,Fh),ir(fs,T1,pb),ir(fs,T1,yd),ir(fs,T1,Fh),ir(fs,pb,T1),ir(fs,pb,xd),ir(fs,pb,_d),ir(fs,m3,m3),ir(fs,m3,yd),ir(fs,m3,xd),ir(fs,Ay,Ay),ir(fs,Ay,yd),ir(fs,Ay,_d),ir(fs,Py,Py),ir(fs,Py,Fh),ir(fs,Py,xd),ir(fs,Cy,Cy),ir(fs,Cy,Fh),ir(fs,Cy,_d),ir(fs,yd,sD),ir(fs,yd,T1),ir(fs,yd,m3),ir(fs,yd,Ay),ir(fs,yd,yd),ir(fs,yd,xd),ir(fs,yd,_d),ir(fs,Fh,oD),ir(fs,Fh,T1),ir(fs,Fh,Py),ir(fs,Fh,Cy),ir(fs,Fh,Fh),ir(fs,Fh,xd),ir(fs,Fh,_d),ir(fs,xd,aD),ir(fs,xd,pb),ir(fs,xd,m3),ir(fs,xd,Py),ir(fs,xd,yd),ir(fs,xd,Fh),ir(fs,xd,xd),ir(fs,_d,rD),ir(fs,_d,pb),ir(fs,_d,Ay),ir(fs,_d,Cy),ir(fs,_d,yd),ir(fs,_d,Fh),ir(fs,_d,_d)}function Bjt(){ci(yD,new qN),ci(zj,new s0),ci(xD,new oC),ci(tPe,new CX),ci(Se,new PX),ci(q(Mc,1),new LX),ci(lo,new kX),ci(qx,new a0),ci(Se,new jN),ci(Se,new $N),ci(Se,new wX),ci(Eo,new VN),ci(Se,new R2),ci(yu,new _E),ci(yu,new vX),ci(Se,new WN),ci(aM,new HN),ci(Se,new nC),ci(Se,new iC),ci(Se,new Jk),ci(Se,new rC),ci(Se,new _X),ci(q(Mc,1),new XN),ci(Se,new sC),ci(Se,new YN),ci(yu,new Qk),ci(yu,new yX),ci(Se,new ZN),ci(Po,new KN),ci(Se,new JN),ci(J0,new xX),ci(Se,new QN),ci(Se,new EX),ci(Se,new SX),ci(Se,new o0),ci(yu,new eR),ci(yu,new tR),ci(Se,new nR),ci(Se,new I2),ci(Se,new ns),ci(Se,new aC),ci(Se,new iR),ci(Se,new Uv),ci(Q0,new MX),ci(Se,new rR),ci(Se,new eF),ci(Se,new jf),ci(Q0,new TX),ci(J0,new tF),ci(Se,new AX),ci(Po,new nF)}function Ojt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B;for(a=h(G(e,(Ie(),Jn)),35),Yu(a,e.k.a+t.a),Zu(a,e.k.b+t.b),(h(rn(a,($e(),jw)),185)._b()!=0||G(e,md)!=null||Be(G(va(e),FG))===Be((XA(),z5))&&zNe((_w(),(e.p?e.p:(_t(),_t(),ep)).Qb(rb)?C=h(G(e,rb),179):C=h(G(va(e),sL),179),C)))&&(x_(a,e.n.a),y_(a,e.n.b)),E=new j(e.i);E.a1;)t=w.Math.min(f,e.c),y=(C=new eh(e.e.c),Ou(C,(Xt(),$a)),Ee(C,($e(),Ki),h(G(y,Ki),83)),Ee(C,kf,h(G(y,kf),185)),C.o=e.e.b++,De(e.b,C),C.n.b=y.n.b,C.n.a=t,R=new yo,mr(R,(Fe(),Zt)),us(R,y),R.k.a=C.n.a,R.k.b=C.n.b/2,B=new yo,mr(B,nn),us(B,C),B.k.b=C.n.b/2,B.k.a=-B.n.a,N=new Op,Os(N,R),_s(N,B),C),De(e.e.c.a,y),--E,f-=e.c+e.e.d;for(new zwe(e.d,e.b,e.c),m=new j(l);m.a=t.length)return{done:!0};var l=t[a++];return{value:[l,i.get(l)],done:!1}}}},fUt()||(e.prototype.createObject=function(){return{}},e.prototype.get=function(t){return this.obj[":"+t]},e.prototype.set=function(t,i){this.obj[":"+t]=i},e.prototype[hie]=function(t){delete this.obj[":"+t]},e.prototype.keys=function(){var t=[];for(var i in this.obj)i.charCodeAt(0)==58&&t.push(i.substring(1));return t}),e}function Ujt(e,t){var i,a,l,f,g,m,v,y,E;if(Bp(As(t))!=1||h(X9(As(t)),14).c.g.j!=(Xt(),Nr))return null;for(i=h(X9(As(t)),14),a=i.c.g,Ou(a,(Xt(),hs)),Ee(a,(Ie(),Cl),null),Ee(a,Al,null),Ee(a,P5,h(G(t,P5),126)),Ee(a,Fw,(vt(),vt(),!0)),Ee(a,Jn,G(t,Jn)),a.n.b=t.n.b,f=G(i.d,Jn),g=null,y=Hc(a,(Fe(),nn)).tc();y.hc();)if(m=h(y.ic(),11),m.d.c.length!=0){Ee(m,Jn,f),E=i.d,m.n.a=E.n.a,m.n.b=E.n.b,m.a.a=E.a.a,m.a.b=E.a.b,Lr(m.e,E.e),E.e.c=le(on,et,1,0,5,1),g=m;break}if(Ee(i.d,Jn,null),Bp(Hc(t,nn))>1)for(v=Nn(cu(Hc(t,nn)),0);v.b!=v.d.c;)m=h(Un(v),11),m.d.c.length==0?(l=new yo,mr(l,nn),l.n.a=m.n.a,l.n.b=m.n.b,us(l,a),Ee(l,Jn,G(m,Jn)),us(m,null)):us(g,a);return Ee(t,Jn,null),Ee(t,Fw,!1),Ou(t,$a),Ee(a,($e(),Ki),h(G(t,Ki),83)),Ee(a,kf,h(G(t,kf),185)),_0(e.b,0,a),a}function zjt(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe;for(ii(i,"Polyline edge routing",1),B=ce(Xe(G(t,($e(),Hw)))),l=ce(Xe(G(t,a3))),a=w.Math.min(1,l/B),ie=0,t.b.c.length!=0&&(fe=ZXe(h(St(t.b,0),26)),ie=.4*a*fe),m=new Ns(t.b,0);m.b0&&(ie-=B),C_e(g,ie),E=0,R=new j(g.a);R.a0),m.a.cd(m.c=--m.b)),v=.4*a*E,!f&&m.b0||E.i==nn&&E.d.c.length-E.f.c.length<0)){i=!1;break}if(E.i==nn){for(l=new j(E.f);l.a=m){Rn(V.b>0),V.a.cd(V.c=--V.b);break}else N.a>v&&(l?(Lr(l.b,N.b),l.a=w.Math.max(l.a,N.a),yf(V)):(De(N.b,E),N.c=w.Math.min(N.c,v),N.a=w.Math.max(N.a,m),l=N));l||(l=new dDe,l.c=v,l.a=m,td(V,l),De(l.b,E))}for(g=t.b,y=0,W=new j(a);W.a0&&Ma(a,-6)>=0){if(Ma(a,0)>=0){for(l=i+nr(a),g=17;g>=l;g--)y[g+1]=y[g];return y[++l]=46,m&&(y[--i]=45),hu(y,i,18-i+1)}for(f=2;_K(f,no(pS(a),1));f++)y[--i]=48;return y[--i]=46,y[--i]=48,m&&(y[--i]=45),hu(y,i,18-i)}return R=i+1,E=new tw,m&&(E.a+="-"),18-R>=1?(Lg(E,y[i]),E.a+=".",E.a+=hu(y,i+1,18-i-1)):E.a+=hu(y,i,18-i),E.a+="E",Ma(a,0)>0&&(E.a+="+"),E.a+=""+E9(a),E.a}function iJe(e){var t,i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et,kn,yi,as;for(C=h(G(e,(Fg(),Yx)),35),ee=zi,ie=zi,W=zs,V=zs,we=new j(e.e);we.at.d.c){if(B=e.c[t.a.d],V=e.c[C.a.d],B==V)continue;Ju(zu(Uu(Gu(Fu(new iu,1),100),B),V))}}}}}function Hjt(e,t,i,a,l,f){var g,m,v,y,E,C;for(y=new yo,No(y,t),mr(y,h(rn(t,($e(),oL)),69)),Ee(y,(Ie(),Jn),t),us(y,i),C=y.n,C.a=t.g,C.b=t.f,E=y.k,E.a=t.i,E.b=t.j,dr(e.a,t,y),g=nU(Xf(Jf(new oi(null,(!t.e&&(t.e=new an(js,t,7,4)),new di(t.e,16))),new gl),new _2),new NY(t)),g||(g=nU(Xf(Jf(new oi(null,(!t.d&&(t.d=new an(js,t,8,5)),new di(t.d,16))),new Rm),new Iv),new FY(t))),g||(g=nU(new oi(null,(!t.e&&(t.e=new an(js,t,7,4)),new di(t.e,16))),new rE)),Ee(y,L5,(vt(),!!g)),Jzt(y,f,l,h(rn(t,$w),9)),v=new Bn((!t.n&&(t.n=new ze(ea,t,1,7)),t.n));v.e!=v.i._b();)m=h(Yn(v),137),!ce(mt(rn(m,x1)))&&m.a&&De(y.e,$ee(m));switch((!t.d&&(t.d=new an(js,t,8,5)),t.d).i+(!t.e&&(t.e=new an(js,t,7,4)),t.e).i>1&&a.nc((xo(),KP)),l.g){case 2:case 1:(y.i==(Fe(),bn)||y.i==ni)&&a.nc((xo(),py));break;case 4:case 3:(y.i==(Fe(),Zt)||y.i==nn)&&a.nc((xo(),py))}return y}function em(e,t){vi();var i,a,l,f,g,m,v,y,E,C,R,B,N;if(OE(LM)==0){for(C=le(CVt,be,112,Tut.length,0,1),g=0;gy&&(a.a+=VNe(le(Zl,Ph,22,-y,15,1))),a.a+="Is",yh(v,wc(32))>=0)for(l=0;l0){if(g+a>e.length)return!1;m=h7(e.substr(0,g+a),t)}else m=h7(e,t);switch(f){case 71:return m=N_(e,g,X(q(Se,1),be,2,6,[RJe,IJe]),t),l.e=m,!0;case 77:return J9t(e,t,l,m,g);case 76:return Q9t(e,t,l,m,g);case 69:return VNt(e,t,g,l);case 99:return WNt(e,t,g,l);case 97:return m=N_(e,g,X(q(Se,1),be,2,6,["AM","PM"]),t),l.b=m,!0;case 121:return oUt(e,t,g,m,i,l);case 100:return m<=0?!1:(l.c=m,!0);case 83:return m<0?!1:e5t(m,g,t[0],l);case 104:m==12&&(m=0);case 75:case 72:return m<0?!1:(l.f=m,l.g=!1,!0);case 107:return m<0?!1:(l.f=m,l.g=!0,!0);case 109:return m<0?!1:(l.j=m,!0);case 115:return m<0?!1:(l.n=m,!0);case 90:if(gut[v]&&(V=v),C=new j(e.b.b);C.a0?R=r6(m):R=n6(r6(m)),e.ze(oL,R)),R.g){case 4:Ee(E,tc,(du(),zw)),Ee(E,roe,(M_(),YP)),E.n.b=g.b,mr(C,(Fe(),Zt)),C.k.b=y.b;break;case 2:Ee(E,tc,(du(),ib)),Ee(E,roe,(M_(),T5)),E.n.b=g.b,mr(C,(Fe(),nn)),C.k.b=y.b;break;case 1:Ee(E,y1,(Hd(),gy)),E.n.a=g.a,mr(C,(Fe(),ni)),C.k.a=y.a;break;case 3:Ee(E,y1,(Hd(),Kx)),E.n.a=g.a,mr(C,(Fe(),bn)),C.k.a=y.a}if(t==p3||t==vd||t==Oa){if(B=0,t==p3&&e.ye(E1))switch(R.g){case 1:case 2:B=h(e.xe(E1),21).a;break;case 3:case 4:B=-h(e.xe(E1),21).a}else switch(R.g){case 4:case 2:B=f.b,t==vd&&(B/=l.b);break;case 1:case 3:B=f.a,t==vd&&(B/=l.a)}Ee(E,nb,B)}return Ee(E,pa,R),E}function Jjt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue;if(R=h(h(er(e.r,t),19),60),t==(Fe(),Zt)||t==nn){YKe(e,t);return}for(f=t==bn?(D0(),hD):(D0(),dD),we=t==bn?(Nc(),If):(Nc(),lf),i=h(Ds(e.b,t),114),a=i.i,l=a.c+v_(X(q(ks,1),Wo,22,15,[i.n.b,e.A.b,e.k])),ee=a.c+a.b-v_(X(q(ks,1),Wo,22,15,[i.n.c,e.A.c,e.k])),g=Cpe(Dme(f),e.s),ie=t==bn?cre:Gx,C=R.tc();C.hc();)y=h(C.ic(),111),!(!y.c||y.c.d.c.length<=0)&&(V=y.b.Re(),W=y.e,B=y.c,N=B.i,N.b=(v=B.n,B.e.a+v.b+v.c),N.a=(m=B.n,B.e.b+m.d+m.a),tQ(we,fxe),B.f=we,Mh(B,(rl(),cf)),N.c=W.a-(N.b-V.a)/2,Ce=w.Math.min(l,W.a),Ue=w.Math.max(ee,W.a+V.a),N.cUe&&(N.c=Ue-N.b),De(g.d,new jJ(N,Gbe(g,N))),ie=t==bn?w.Math.max(ie,W.b+y.b.Re().b):w.Math.min(ie,W.b));for(ie+=t==bn?e.s:-e.s,fe=Qbe((g.e=ie,g)),fe>0&&(h(Ds(e.b,t),114).a.b=fe),E=R.tc();E.hc();)y=h(E.ic(),111),!(!y.c||y.c.d.c.length<=0)&&(N=y.c.i,N.c-=y.e.a,N.d-=y.e.b)}function sJe(e,t,i){var a,l,f,g,m,v,y,E,C,R;if(a=new Yf(t.Qe().a,t.Qe().b,t.Re().a,t.Re().b),l=new VE,e.c)for(g=new j(t.We());g.a=2){if((!e.a&&(e.a=new ze(ts,e,6,6)),e.a).i==0)i=(p0(),l=new mE,l),$n((!e.a&&(e.a=new ze(ts,e,6,6)),e.a),i);else if((!e.a&&(e.a=new ze(ts,e,6,6)),e.a).i>1)for(R=new QC((!e.a&&(e.a=new ze(ts,e,6,6)),e.a));R.e!=R.i._b();)KA(R);R6(t,h(ae((!e.a&&(e.a=new ze(ts,e,6,6)),e.a),0),270))}if(C)for(a=new Bn((!e.a&&(e.a=new ze(ts,e,6,6)),e.a));a.e!=a.i._b();)for(i=h(Yn(a),270),y=new Bn((!i.a&&(i.a=new vs(oh,i,5)),i.a));y.e!=y.i._b();)v=h(Yn(y),531),m.a=w.Math.max(m.a,v.a),m.b=w.Math.max(m.b,v.b);for(g=new Bn((!e.n&&(e.n=new ze(ea,e,1,7)),e.n));g.e!=g.i._b();)f=h(Yn(g),137),E=h(rn(f,SL),9),E&&Od(f,E.a,E.b),C&&(m.a=w.Math.max(m.a,f.i+f.g),m.b=w.Math.max(m.b,f.j+f.f));return m}function Qjt(e,t,i){var a,l,f,g,m,v,y,E,C,R,B;if(e.e.a.Pb(),e.f.a.Pb(),e.c.c=le(on,et,1,0,5,1),e.i.c=le(on,et,1,0,5,1),e.g.a.Pb(),t)for(g=new j(t.a);g.a>4)<<24>>24,C[R++]=((i&15)<<4|a>>2&15)<<24>>24,C[R++]=(a<<6|l)<<24>>24}return!BR(g=f[E++])||!BR(m=f[E++])?null:(t=lh[g],i=lh[m],v=f[E++],y=f[E++],lh[v]==-1||lh[y]==-1?v==61&&y==61?i&15?null:(V=le(Mc,sy,22,B*3+1,15,1),vc(C,0,V,0,B*3),V[R]=(t<<2|i>>4)<<24>>24,V):v!=61&&y==61?(a=lh[v],a&3?null:(V=le(Mc,sy,22,B*3+2,15,1),vc(C,0,V,0,B*3),V[R++]=(t<<2|i>>4)<<24>>24,V[R]=((i&15)<<4|a>>2&15)<<24>>24,V)):null:(a=lh[v],l=lh[y],C[R++]=(t<<2|i>>4)<<24>>24,C[R++]=((i&15)<<4|a>>2&15)<<24>>24,C[R++]=(a<<6|l)<<24>>24,C))}function t$t(e,t,i){var a,l,f,g,m,v,y,E,C,R;for(v=new ke,C=t.length,g=vbe(i),y=0;ym&&(fe=0,we+=g+ee,g=0),s7t(W,i,fe,we),t=w.Math.max(t,fe+V.a),g=w.Math.max(g,V.b),fe+=V.a+ee;return W}function n$t(e,t,i){var a,l,f,g,m;switch(a=t.i,f=e.g.n,l=e.g.d,m=e.k,g=Fo(X(q(es,1),be,9,0,[m,e.a])),e.i.g){case 1:Ud(t,(Nc(),lf)),a.d=-l.d-i-a.a,h(h(rS(t.d).a.cd(0),271).xe((Ie(),t3)),265)==(xl(),Ed)?(Mh(t,(rl(),cf)),a.c=g.a-ce(Xe(G(e,my)))-i-a.b):(Mh(t,(rl(),Uh)),a.c=g.a+ce(Xe(G(e,my)))+i);break;case 2:Mh(t,(rl(),Uh)),a.c=f.a+l.c+i,h(h(rS(t.d).a.cd(0),271).xe((Ie(),t3)),265)==(xl(),Ed)?(Ud(t,(Nc(),lf)),a.d=g.b-ce(Xe(G(e,my)))-i-a.a):(Ud(t,(Nc(),If)),a.d=g.b+ce(Xe(G(e,my)))+i);break;case 3:Ud(t,(Nc(),If)),a.d=f.b+l.a+i,h(h(rS(t.d).a.cd(0),271).xe((Ie(),t3)),265)==(xl(),Ed)?(Mh(t,(rl(),cf)),a.c=g.a-ce(Xe(G(e,my)))-i-a.b):(Mh(t,(rl(),Uh)),a.c=g.a+ce(Xe(G(e,my)))+i);break;case 4:Mh(t,(rl(),cf)),a.c=-l.b-i-a.b,h(h(rS(t.d).a.cd(0),271).xe((Ie(),t3)),265)==(xl(),Ed)?(Ud(t,(Nc(),lf)),a.d=g.b-ce(Xe(G(e,my)))-i-a.a):(Ud(t,(Nc(),If)),a.d=g.b+ce(Xe(G(e,my)))+i)}}function cJe(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N;switch(g=new b9e(e),m=od(zd(t,g)),_t(),fa(m,new KO),l=e.b,l.c){case 2:v=new Qb(l.a),i=qC(zd(m,v)),S_(i)?y=h(px(i),188).b:y=15,v=new Qb(ywe(l)),i=qC(zd(m,v)),S_(i)?f=h(px(i),188).b:f=15,v=new Qb(l.b),i=qC(zd(m,v)),S_(i)?E=h(px(i),188).b:E=15,a=H8t(e,y,f,E),Cr(t,new cP(a,e.c,e.e,e.a.c.g,l.a)),Cr(t,new cP(a,e.c,e.e,e.a.c.g,ywe(l))),Cr(t,new cP(a,e.c,e.e,e.a.c.g,l.b));break;case 1:v=new Qb(l.a),i=qC(zd(m,v)),S_(i)?y=h(px(i),188).b:y=15,v=new Qb(l.b),i=qC(zd(m,v)),S_(i)?E=h(px(i),188).b:E=15,a=O8t(e,y,E),Cr(t,new cP(a,e.c,e.e,e.a.c.g,l.a)),Cr(t,new cP(a,e.c,e.e,e.a.c.g,l.b));break;case 0:v=new Qb(l.a),i=qC(zd(m,v)),S_(i)?y=h(px(i),188).b:y=15,a=(C=e.b,R=b7t(e.a.c,e.a.d,y),wo(e.a.a,ote(R)),B=nve(e.a.b,R.a,C),N=new EI((!R.k&&(R.k=new Wte(_ee(R))),R.k)),U1e(N),B?w1e(N,B):N),Cr(t,new cP(a,e.c,e.e,e.a.c.g,l.a));break;default:throw Y(new un("The loopside must be defined."))}return a}function i$t(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft;for(ii(t,"Compound graph postprocessor",1),i=ce(mt(G(e,($e(),_oe)))),m=h(G(e,(Ie(),YSe)),238),E=new zr,ee=m.Xb().tc();ee.hc();){for(V=h(ee.ic(),14),g=new vf(m.Mc(V)),_t(),fa(g,new BF(e)),Ce=IRt((ai(0,g.c.length),h(g.c[0],234))),qe=P$e(h(St(g,g.c.length-1),234)),fe=Ce.g,TS(qe.g,fe)?ie=h(G(fe,md),31):ie=va(fe),C=V5t(V,g),rd(V.a),R=null,f=new j(g);f.aJd,ft=w.Math.abs(R.b-N.b)>Jd,(!i&&ut&&ft||i&&(ut||ft))&&Gi(V.a,we)),wo(V.a,a),a.b==0?R=we:R=(Rn(a.b!=0),h(a.c.b.c,9)),eIt(B,C,W),P$e(l)==qe&&(va(qe.g)!=l.a&&(W=new fo,Dve(W,va(qe.g),ie)),Ee(V,foe,W)),iNt(B,V,ie),E.a.Zb(B,E);Os(V,Ce),_s(V,qe)}for(y=E.a.Xb().tc();y.hc();)v=h(y.ic(),14),Os(v,null),_s(v,null);On(t)}function r$t(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et,kn,yi;for(ie=new Ns(e.b,0),E=t.tc(),N=0,y=h(E.ic(),21).a,Ce=0,i=new zr,qe=new Gc;ie.b=e.a&&(a=v7t(e,ie),E=wf(E,a.b),we=wf(we,a.d),De(m,new Is(ie,a)));for(ut=new ke,y=0;y0),V.a.cd(V.c=--V.b),ft=new lu(e.b),td(V,ft),Rn(V.b=a.n.b/2}else ie=!C;ie?(ee=h(G(a,(Ie(),i3)),15),ee?R?f=ee:(l=h(G(a,Jx),15),l?ee._b()<=l._b()?f=ee:f=l:(f=new ke,Ee(a,Jx,f))):(f=new ke,Ee(a,i3,f))):(l=h(G(a,(Ie(),Jx)),15),l?C?f=l:(ee=h(G(a,i3),15),ee?l._b()<=ee._b()?f=l:f=ee:(f=new ke,Ee(a,i3,f))):(f=new ke,Ee(a,Jx,f))),f.nc(e),Ee(e,(Ie(),SG),i),t.d==i?(_s(t,null),i.d.c.length+i.f.c.length==0&&us(i,null),xIt(i)):(Os(t,null),i.d.c.length+i.f.c.length==0&&us(i,null)),rd(t.a)}function a$t(e){var t,i,a,l,f,g,m,v,y,E,C,R,B,N;if(Be(G(e.c,($e(),Ki)))===Be((Ms(),vd))||Be(G(e.c,Ki))===Be(Oa)){for(E=new j(e.c.i);E.a0&&(l=h(St(V.c.a,Ue-1),8),g=e.i[l.o],ut=w.Math.ceil(r_(e.n,l,V)),f=Ce.a.e-V.d.d-(g.a.e+l.n.b+l.d.a)-ut),y=Jr,Ue0&&qe.a.e.e-qe.a.a-(qe.b.e.e-qe.b.a)<0,N=fe.a.e.e-fe.a.a-(fe.b.e.e-fe.b.a)<0&&qe.a.e.e-qe.a.a-(qe.b.e.e-qe.b.a)>0,B=fe.a.e.e+fe.b.aqe.b.e.e+qe.a.a,we=0,!W&&!N&&(R?f+C>0?we=C:y-a>0&&(we=a):B&&(f+m>0?we=m:y-ie>0&&(we=ie))),Ce.a.e+=we,Ce.b&&(Ce.d.e+=we),!1))}function l$t(){var e=["\\u0000","\\u0001","\\u0002","\\u0003","\\u0004","\\u0005","\\u0006","\\u0007","\\b","\\t","\\n","\\u000B","\\f","\\r","\\u000E","\\u000F","\\u0010","\\u0011","\\u0012","\\u0013","\\u0014","\\u0015","\\u0016","\\u0017","\\u0018","\\u0019","\\u001A","\\u001B","\\u001C","\\u001D","\\u001E","\\u001F"];return e[34]='\\"',e[92]="\\\\",e[173]="\\u00ad",e[1536]="\\u0600",e[1537]="\\u0601",e[1538]="\\u0602",e[1539]="\\u0603",e[1757]="\\u06dd",e[1807]="\\u070f",e[6068]="\\u17b4",e[6069]="\\u17b5",e[8203]="\\u200b",e[8204]="\\u200c",e[8205]="\\u200d",e[8206]="\\u200e",e[8207]="\\u200f",e[8232]="\\u2028",e[8233]="\\u2029",e[8234]="\\u202a",e[8235]="\\u202b",e[8236]="\\u202c",e[8237]="\\u202d",e[8238]="\\u202e",e[8288]="\\u2060",e[8289]="\\u2061",e[8290]="\\u2062",e[8291]="\\u2063",e[8292]="\\u2064",e[8298]="\\u206a",e[8299]="\\u206b",e[8300]="\\u206c",e[8301]="\\u206d",e[8302]="\\u206e",e[8303]="\\u206f",e[65279]="\\ufeff",e[65529]="\\ufff9",e[65530]="\\ufffa",e[65531]="\\ufffb",e}function ll(){ll=M,lm=new Ig("N",0,(Fe(),bn),bn,0),qw=new Ig("EN",1,Zt,bn,1),ob=new Ig("E",2,Zt,Zt,0),ab=new Ig("SE",3,ni,Zt,1),Kp=new Ig("S",4,ni,ni,0),Zw=new Ig("WS",5,nn,ni,1),Yw=new Ig("W",6,nn,nn,0),ip=new Ig("NW",7,bn,nn,1),Zp=new Ig("ENW",8,Zt,nn,2),Xw=new Ig("ESW",9,Zt,nn,2),cb=new Ig("SEN",10,ni,bn,2),yy=new Ig("SWN",11,ni,bn,2),l3=new Ig(zx,12,Na,Na,3),eat=E5t(lm,qw,ob,ab,Kp,Zw,X(q(hL,1),Oe,129,0,[Yw,ip,Zp,Xw,cb,yy])),nat=(lw(),F_(X(q(on,1),et,1,5,[lm,ob,Kp,Yw]))),tat=F_(X(q(on,1),et,1,5,[qw,ab,Zw,ip])),aat=new $2(bn),rat=F_(X(q(on,1),et,1,5,[Zt,bn])),iat=new $2(Zt),uat=F_(X(q(on,1),et,1,5,[ni,Zt])),lat=new $2(ni),gat=F_(X(q(on,1),et,1,5,[nn,ni])),pat=new $2(nn),cat=F_(X(q(on,1),et,1,5,[bn,nn])),sat=F_(X(q(on,1),et,1,5,[Zt,bn,nn])),oat=F_(X(q(on,1),et,1,5,[Zt,ni,nn])),hat=F_(X(q(on,1),et,1,5,[ni,nn,bn])),fat=F_(X(q(on,1),et,1,5,[ni,Zt,bn])),dat=(tS(),GP)}function u$t(e){var t,i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut;if(i=ce(Xe(G(e.a.j,($e(),TMe)))),i<-1||!e.a.i||iA(h(G(e.a.o,Ki),83))||sa(e.a.o,(Fe(),Zt))._b()<2&&sa(e.a.o,nn)._b()<2)return!0;if(e.a.c.pf())return!1;for(we=0,fe=0,ie=new ke,v=e.a.e,y=0,E=v.length;y=i}function f$t(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we;for(ii(t,TQe,1),B=h(G(e,($e(),cm)),197),l=new j(e.b);l.a=2){for(N=!0,C=new j(f.i),i=h($(C),11);C.a0){for(R=E<100?null:new Eg(E),y=new cbe(t),N=y.g,ee=le(In,si,22,E,15,1),a=0,we=new w_(E),l=0;l=0;)if(m!=null?ki(m,N[v]):N[v]==null){ee.length<=a&&(V=ee,ee=le(In,si,22,2*ee.length,15,1),vc(V,0,ee,0,a)),ee[a++]=l,$n(we,N[v]);break e}if(Be(m)===Be(m))break}}if(N=we.g,a>ee.length&&(V=ee,ee=le(In,si,22,a,15,1),vc(V,0,ee,0,a)),a>0){for(fe=!0,f=0;f=0;)Ex(e,ee[g]);if(a!=a){for(l=a;--l>=a;)Ex(we,l);V=ee,ee=le(In,si,22,a,15,1),vc(V,0,ee,0,a)}t=we}}}else for(t=zDt(e,t),l=e.i;--l>=0;)t.pc(e.g[l])&&(Ex(e,l),fe=!0);if(fe){if(ee!=null){for(i=t._b(),C=i==1?dA(e,4,t.tc().ic(),null,ee[0],W):dA(e,6,t,ee,ee[0],W),R=i<100?null:new Eg(i),l=t.tc();l.hc();)B=l.ic(),R=Mme(e,h(B,75),R);R?(R.Sh(C),R.Th()):Li(e.e,C)}else{for(R=XMt(t._b()),l=t.tc();l.hc();)B=l.ic(),R=Mme(e,h(B,75),R);R&&R.Th()}return!0}else return!1}function d$t(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et,kn,yi,as;for(ii(i,"MinWidth layering",1),B=t.b,qe=t.a,as=h(G(t,($e(),FMe)),21).a,m=h(G(t,UMe),21).a,e.b=ce(Xe(G(t,rh))),e.d=Jr,we=new j(qe);we.a0||i.o==sh&&l0?(C=h(St(R.c.a,g-1),8),ut=r_(e.b,R,C),V=R.k.b-R.d.d-(C.k.b+C.n.b+C.d.a+ut)):V=R.k.b-R.d.d,y=w.Math.min(V,y),g=1&&(ut-y>0&&N>=0?(Yu(C,C.i+qe),Zu(C,C.j+v*y)):ut-y<0&&B>=0&&(Yu(C,C.i+qe*ut),Zu(C,C.j+v)));return ac(e,xM,(f=h(bl(AL),10),new Oc(f,h(el(f,f.length),10),0))),new $t(ft,E)}function b$t(e){var t,i,a,l,f,g,m,v,y,E,C,R,B,N,W,V;for(W=new ke,R=new j(e.d.b);R.al.d.d+l.d.a?E.f.d=!0:(E.f.d=!0,E.f.a=!0))),a.b!=a.d.c&&(t=i);E&&(f=h(Ii(e.f,g.d.g),57),t.bf.d.d+f.d.a?E.f.d=!0:(E.f.d=!0,E.f.a=!0))}for(m=Cn(As(B));Gn(m);)g=h(Tn(m),14),g.a.b!=0&&(t=h(n9(g.a),9),g.d.i==(Fe(),bn)&&(V=new dP(t,new $t(t.a,l.d.d),l,g),V.f.a=!0,V.a=g.d,W.c[W.c.length]=V),g.d.i==ni&&(V=new dP(t,new $t(t.a,l.d.d+l.d.a),l,g),V.f.d=!0,V.a=g.d,W.c[W.c.length]=V))}return W}function w$t(){_pe();function e(a){var l=this;this.dispatch=function(f){var g=f.data;switch(g.cmd){case"algorithms":var m=Jbe((_t(),new Jb(new bh(ev.b))));a.postMessage({id:g.id,data:m});break;case"categories":var v=Jbe((_t(),new Jb(new bh(ev.c))));a.postMessage({id:g.id,data:v});break;case"options":var y=Jbe((_t(),new Jb(new bh(ev.d))));a.postMessage({id:g.id,data:y});break;case"register":Izt(g.algorithms),a.postMessage({id:g.id});break;case"layout":q8t(g.graph,g.options||{}),a.postMessage({id:g.id,data:g.graph});break}},this.saveDispatch=function(f){try{l.dispatch(f)}catch(g){delete g[jne],a.postMessage({id:f.data.id,error:g.message})}}}function t(a){var l=this;this.dispatcher=new e({postMessage:function(f){l.onmessage({data:f})}}),this.postMessage=function(f){setTimeout(function(){l.dispatcher.saveDispatch({data:f})},0)}}if(typeof document===Axe&&typeof self!==Axe){var i=new e(self);self.onmessage=i.saveDispatch}else typeof u!==Axe&&u.exports&&(Object.defineProperty(d,"__esModule",{value:!0}),u.exports={default:t,Worker:t})}function fJe(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we;if(ie=0,t.e.a==0)for(V=new j(e);V.a50?ee.c[ee.c.length]=l:l.k>0?ie.c[ie.c.length]=l:fe.c[fe.c.length]=l;if(ie.c.length==1&&ee.c.length==0&&(Lr(ee,ie),ie.c=le(on,et,1,0,5,1)),ee.c.length!=0&&Rp(oJ(e.a),(ll(),lm))&&Rp(oJ(e.a),(ll(),Kp))?D6t(e,ee):Lr(ie,ee),ie.c.length==0||B6t(e,ie),fe.c.length!=0){if(i=sJ(e.a),i.c!=0)for(E=new j(fe),v=(Hn(i),Vge(new NNe(i).a));E.a1&&(W=h(nbe(v),129),WA(l,W,!0),cA(E),KUe(e.a,W))}for(R=fe.c.length,a=FUt(e),B=new ke,g=R/Mge(e.a).c|0,m=0;m3&&(Lr(B,(ll(),ll(),tat)),N-=4),N){case 3:De(B,M6(a));case 2:V=y7(M6(a));do V=y7(V);while(!Rp(oJ(e.a),V));B.c[B.c.length]=V,V=Gve(M6(a));do V=Gve(V);while(!Rp(oJ(e.a),V));B.c[B.c.length]=V;break;case 1:De(B,M6(a))}for(C=new j(B),y=new j(fe);C.aW&&(f&&(zm(Ue,B),zm(ut,He(E.b-1)),De(e.d,N),m.c=le(on,et,1,0,5,1)),yi=i.b,as+=B+t,B=0,C=w.Math.max(C,i.b+i.c+kn)),m.c[m.c.length]=v,lHe(v,yi,as),C=w.Math.max(C,yi+kn+i.c),B=w.Math.max(B,R),yi+=kn+t,N=v;if(Lr(e.a,m),De(e.d,h(St(m,m.c.length-1),145)),C=w.Math.max(C,a),Et=as+B+i.a,Et1&&(g=w.Math.min(g,w.Math.abs(h(qg(m.a,1),9).b-E.b)))));else for(W=new j(t.i);W.al&&(f=R.a-l,g=zi,a.c=le(on,et,1,0,5,1),l=R.a),R.a>=l&&(a.c[a.c.length]=m,m.a.b>1&&(g=w.Math.min(g,w.Math.abs(h(qg(m.a,m.a.b-2),9).b-R.b)))));if(a.c.length!=0&&f>t.n.a/2&&g>t.n.b/2){for(B=new yo,us(B,t),mr(B,(Fe(),bn)),B.k.a=t.n.a/2,ee=new yo,us(ee,t),mr(ee,ni),ee.k.a=t.n.a/2,ee.k.b=t.n.b,v=new j(a);v.a=y.b?Os(m,ee):Os(m,B)):(y=h(DCt(m.a),9),V=m.a.b==0?Wu(m.c):h(n9(m.a),9),V.b>=y.b?_s(m,ee):_s(m,B)),C=h(G(m,($e(),Lo)),74),C&&_x(C,y,!0);t.k.a=l-t.n.a/2}}function S$t(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce;for(m=new j(e.a.b);m.a0)if(a=C._b(),y=yr(w.Math.floor((a+1)/2))-1,l=yr(w.Math.ceil((a+1)/2))-1,t.o==sh)for(E=l;E>=y;E--)t.a[we.o]==we&&(W=h(C.cd(E),48),N=h(W.a,8),!IC(i,W.b)&&B>e.b.e[N.o]&&(t.a[N.o]=we,t.g[we.o]=t.g[N.o],t.a[we.o]=t.g[we.o],t.f[t.g[we.o].o]=(vt(),!!(ce(t.f[t.g[we.o].o])&we.j==(Xt(),Nr))),B=e.b.e[N.o]));else for(E=y;E<=l;E++)t.a[we.o]==we&&(ee=h(C.cd(E),48),V=h(ee.a,8),!IC(i,ee.b)&&B=48&&t<=57){for(a=t-48;l=48&&t<=57;)if(a=a*10+t-48,a<0)throw Y(new Wn(Zn((zn(),Dxe))))}else throw Y(new Wn(Zn((zn(),dtt))));if(i=a,t==44){if(l>=e.j)throw Y(new Wn(Zn((zn(),gtt))));if((t=po(e.i,l++))>=48&&t<=57){for(i=t-48;l=48&&t<=57;)if(i=i*10+t-48,i<0)throw Y(new Wn(Zn((zn(),Dxe))));if(a>i)throw Y(new Wn(Zn((zn(),mtt))))}else i=-1}if(t!=125)throw Y(new Wn(Zn((zn(),ptt))));e.Ck(l)?(f=(vi(),vi(),++Er,new pw(9,f)),e.d=l+1):(f=(vi(),vi(),++Er,new pw(3,f)),e.d=l),f.nl(a),f.ml(i),wi(e)}}return f}function M$t(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt;return C=U7t(rc(e,(Fe(),gAe)),t),N=k_(rc(e,sD),t),we=k_(rc(e,oD),t),ut=r7(rc(e,aD),t),R=r7(rc(e,rD),t),ie=k_(rc(e,m3),t),W=k_(rc(e,Ay),t),Ue=k_(rc(e,Py),t),Ce=k_(rc(e,Cy),t),ft=r7(rc(e,pb),t),ee=k_(rc(e,T1),t),fe=k_(rc(e,yd),t),qe=k_(rc(e,Fh),t),Mt=r7(rc(e,xd),t),B=r7(rc(e,_d),t),V=k_(rc(e,vae),t),i=v_(X(q(ks,1),Wo,22,15,[ie.a,ut.a,Ue.a,Mt.a])),a=v_(X(q(ks,1),Wo,22,15,[N.a,C.a,we.a,V.a])),l=ee.a,f=v_(X(q(ks,1),Wo,22,15,[W.a,R.a,Ce.a,B.a])),y=v_(X(q(ks,1),Wo,22,15,[ie.b,N.b,W.b,fe.b])),v=v_(X(q(ks,1),Wo,22,15,[ut.b,C.b,R.b,V.b])),E=ft.b,m=v_(X(q(ks,1),Wo,22,15,[Ue.b,we.b,Ce.b,qe.b])),Bg(rc(e,gAe),i+l,y+E),Bg(rc(e,vae),i+l,y+E),Bg(rc(e,sD),i+l,0),Bg(rc(e,oD),i+l,y+E+v),Bg(rc(e,aD),0,y+E),Bg(rc(e,rD),i+l+a,y+E),Bg(rc(e,Ay),i+l+a,0),Bg(rc(e,Py),0,y+E+v),Bg(rc(e,Cy),i+l+a,y+E+v),Bg(rc(e,pb),0,y),Bg(rc(e,T1),i,0),Bg(rc(e,Fh),0,y+E+v),Bg(rc(e,_d),i+l+a,0),g=new fo,g.a=v_(X(q(ks,1),Wo,22,15,[i+a+l+f,ft.a,fe.a,qe.a])),g.b=v_(X(q(ks,1),Wo,22,15,[y+v+E+m,ee.b,Mt.b,B.b])),g}function Ta(){Ta=M,tBe(),Llt=ds.a,h(ae(ye(ds.a),0),17),Alt=ds.f,h(ae(ye(ds.f),0),17),h(ae(ye(ds.f),1),29),Plt=ds.n,h(ae(ye(ds.n),0),29),h(ae(ye(ds.n),1),29),h(ae(ye(ds.n),2),29),h(ae(ye(ds.n),3),29),SAe=ds.g,h(ae(ye(ds.g),0),17),h(ae(ye(ds.g),1),29),Clt=ds.c,h(ae(ye(ds.c),0),17),h(ae(ye(ds.c),1),17),MAe=ds.i,h(ae(ye(ds.i),0),17),h(ae(ye(ds.i),1),17),h(ae(ye(ds.i),2),17),h(ae(ye(ds.i),3),17),h(ae(ye(ds.i),4),29),TAe=ds.j,h(ae(ye(ds.j),0),17),EAe=ds.d,h(ae(ye(ds.d),0),17),h(ae(ye(ds.d),1),17),h(ae(ye(ds.d),2),17),h(ae(ye(ds.d),3),17),h(ae(ye(ds.d),4),29),h(ae(ye(ds.d),5),29),h(ae(ye(ds.d),6),29),h(ae(ye(ds.d),7),29),Tlt=ds.b,h(ae(ye(ds.b),0),29),h(ae(ye(ds.b),1),29),Cj=ds.e,h(ae(ye(ds.e),0),29),h(ae(ye(ds.e),1),29),h(ae(ye(ds.e),2),29),h(ae(ye(ds.e),3),29),h(ae(ye(ds.e),4),17),h(ae(ye(ds.e),5),17),h(ae(ye(ds.e),6),17),h(ae(ye(ds.e),7),17),h(ae(ye(ds.e),8),17),h(ae(ye(ds.e),9),17),h(ae(ye(ds.e),10),29),op=ds.k,h(ae(ye(ds.k),0),29),h(ae(ye(ds.k),1),29)}function T$t(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et;for(ft=new Ir,Ue=new Ir,V=-1,v=new j(e);v.a=N&&(ie>N&&(B.c=le(on,et,1,0,5,1),N=ie),B.c[B.c.length]=g);B.c.length!=0&&(R=h(St(B,pte(t,B.c.length)),125),Et.a.$b(R)!=null,R.p=W++,Fve(R,ft,Ue),B.c=le(on,et,1,0,5,1))}for(we=e.c.length+1,m=new j(e);m.aMt.p&&(yf(i),Sa(Mt.g,a),a.c>0&&(a.a=Mt,De(Mt.q,a),a.b=qe,De(qe.g,a)))}function C$t(e,t,i){var a,l,f,g,m,v,y,E,C;if(ii(i,"Network simplex node placement",1),e.e=t,e.n=h(G(t,(Ie(),Uw)),266),Lzt(e),eOt(e),Fa(Jf(new oi(null,new di(e.e.b,16)),new iq),new lZ(e)),Fa(go(Jf(go(Jf(new oi(null,new di(e.e.b,16)),new $T),new VT),new Rk),new lq),new cZ(e)),ce(mt(G(e.e,($e(),rL))))&&(g=bc(i,1),ii(g,"Straight Edges Pre-Processing",1),ljt(e),On(g)),sDt(e.f),f=h(G(t,F5),21).a*e.f.a.c.length,fne(Epe(Spe(IJ(e.f),f),!1),bc(i,1)),e.d.a._b()!=0){for(g=bc(i,1),ii(g,"Flexible Where Space Processing",1),m=h(hJ(t6(Xf(new oi(null,new di(e.f.a,16)),new rq),(dn(new OT),new Fr))),21).a,v=h(hJ(W9e(Xf(new oi(null,new di(e.f.a,16)),new sq),new ya)),21).a,y=v-m,E=b0(new Fm,e.f),C=b0(new Fm,e.f),Ju(zu(Uu(Fu(Gu(new iu,2e4),y),E),C)),Fa(go(go(f1e(e.i),new sN),new oN),new xUe(m,E,y,C)),l=e.d.a.Xb().tc();l.hc();)a=h(l.ic(),189),a.g=1;fne(Epe(Spe(IJ(e.f),f),!1),bc(g,1)),On(g)}ce(mt(G(t,rL)))&&(g=bc(i,1),ii(g,"Straight Edges Post-Processing",1),LNt(e),On(g)),VGt(e),e.e=null,e.f=null,e.i=null,e.c=null,nl(e.k),e.j=null,e.a=null,e.o=null,e.d.a.Pb(),On(i)}function hJe(e,t,i,a,l){var f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et;for(W=new Gl(t.b),we=new Gl(t.b),R=new Gl(t.b),ut=new Gl(t.b),V=new Gl(t.b),qe=Nn(t,0);qe.b!=qe.d.c;)for(Ce=h(Un(qe),11),m=new j(Ce.f);m.a0,ee=Ce.f.c.length>0,y&&ee?R.c[R.c.length]=Ce:y?W.c[W.c.length]=Ce:ee&&(we.c[we.c.length]=Ce);for(N=new j(W);N.a=0&&dt(e.substr(m,2),"//")?(m+=2,v=Kee(e,m,IL,DL),a=e.substr(m,v-m),m=v):C!=null&&(m==e.length||e.charCodeAt(m)!=47)&&(g=!1,v=Pge(e,wc(35),m),v==-1&&(v=e.length),a=e.substr(m,v-m),m=v);if(!i&&m0&&po(E,E.length-1)==58&&(l=E,m=v)),m=R&&(we>R&&(C.c=le(on,et,1,0,5,1),R=we),C.c[C.c.length]=V);C.c.length!=0&&(E=h(St(C,pte(t,C.c.length)),165),fA(yi.a,E)!=null,E.d=B++,Nve(E,Et,ut),C.c=le(on,et,1,0,5,1))}for(Ue=e.c.length+1,ee=new j(e);ee.akn.d&&(yf(i),Sa(kn.b,a),a.c>0&&(a.a=kn,De(kn.e,a),a.b=ft,De(ft.b,a)))}function k$t(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et;for(ie=new Kv,fe=new Kv,E=T0(t,_xe),a=new AUe(e,i,ie,fe),dNt(a.a,a.b,a.c,a.d,E),v=(Ue=ie.i,Ue||(ie.i=re(ie.c,122)?new Zv(ie,h(ie.c,122)):re(ie.c,115)?new X2(ie,h(ie.c,115)):new XE(ie,ie.c))),ut=v.tc();ut.hc();)for(qe=h(ut.ic(),270),l=h(er(ie,qe),19),W=l.tc();W.hc();)if(N=W.ic(),we=h(Lp(e.d,N),270),we)m=(!qe.e&&(qe.e=new an(ts,qe,10,9)),qe.e),$n(m,we);else throw g=Vd(t,Rh),R=Vet+N+Wet+g,B=R+nM,Y(new _h(B));for(y=(Ce=fe.i,Ce||(fe.i=re(fe.c,122)?new Zv(fe,h(fe.c,122)):re(fe.c,115)?new X2(fe,h(fe.c,115)):new XE(fe,fe.c))),Mt=y.tc();Mt.hc();)for(ft=h(Mt.ic(),270),f=h(er(fe,ft),19),ee=f.tc();ee.hc();)if(V=ee.ic(),we=h(Lp(e.d,V),270),we)C=(!ft.g&&(ft.g=new an(ts,ft,9,10)),ft.g),$n(C,we);else throw g=Vd(t,Rh),R=Vet+V+Wet+g,B=R+nM,Y(new _h(B));!i.b&&(i.b=new an(pi,i,4,7)),i.b.i!=0&&(!i.c&&(i.c=new an(pi,i,5,8)),i.c.i!=0)&&(!i.b&&(i.b=new an(pi,i,4,7)),i.b.i<=1&&(!i.c&&(i.c=new an(pi,i,5,8)),i.c.i<=1))&&(!i.a&&(i.a=new ze(ts,i,6,6)),i.a).i==1&&(Et=h(ae((!i.a&&(i.a=new ze(ts,i,6,6)),i.a),0),270),!gte(Et)&&!mte(Et)&&(Q0e(Et,h(ae((!i.b&&(i.b=new an(pi,i,4,7)),i.b),0),97)),ebe(Et,h(ae((!i.c&&(i.c=new an(pi,i,5,8)),i.c),0),97))))}function dJe(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut;for(e.d=new $t(Jr,Jr),e.c=new $t(Ts,Ts),R=t.tc();R.hc();)for(E=h(R.ic(),31),fe=new j(E.a);fe.a=Ce||!OIt(ee,a))&&(a=y7e(t,E)),Hs(ee,a),f=Cn(As(ee));Gn(f);)l=h(Tn(f),14),!e.a[l.o]&&(W=l.c.g,--e.e[W.o],e.e[W.o]==0&&dS(RS(B,W)));for(y=E.c.length-1;y>=0;--y)De(t.b,(ai(y,E.c.length),h(E.c[y],26)));t.a.c=le(on,et,1,0,5,1),On(i)}function D$t(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et,kn,yi,as,Kc,uc,ng,kl,bm,I1,uh,hf;if(Et=oze(e,pze(i),t),jI(Et,Vd(t,Rh)),kn=h(Lp(e.g,Tx(Hm(t,wre))),35),R=Hm(t,"sourcePort"),a=null,R&&(a=Tx(R)),yi=h(Lp(e.j,a),121),!kn)throw m=jA(t),N="An edge must have a source node (edge id: '"+m,W=N+nM,Y(new _h(W));if(yi&&!Dp(Sh(yi),kn))throw v=Vd(t,Rh),V="The source port of an edge must be a port of the edge's source node (edge id: '"+v,ee=V+nM,Y(new _h(ee));if(ut=(!Et.b&&(Et.b=new an(pi,Et,4,7)),Et.b),yi?f=yi:f=kn,$n(ut,f),as=h(Lp(e.g,Tx(Hm(t,Cxe))),35),B=Hm(t,"targetPort"),l=null,B&&(l=Tx(B)),Kc=h(Lp(e.j,l),121),!as)throw C=jA(t),ie="An edge must have a target node (edge id: '"+C,fe=ie+nM,Y(new _h(fe));if(Kc&&!Dp(Sh(Kc),as))throw y=Vd(t,Rh),we="The target port of an edge must be a port of the edge's target node (edge id: '"+y,Ce=we+nM,Y(new _h(Ce));if(ft=(!Et.c&&(Et.c=new an(pi,Et,5,8)),Et.c),Kc?g=Kc:g=as,$n(ft,g),(!Et.b&&(Et.b=new an(pi,Et,4,7)),Et.b).i==0||(!Et.c&&(Et.c=new an(pi,Et,5,8)),Et.c).i==0)throw E=Vd(t,Rh),Ue=$et+E,qe=Ue+nM,Y(new _h(qe));return o7(t,Et),uc=j_(Et,!0,!0),ng=yI(t,"sourcePoint"),kl=new RZ(uc),Z6t(kl.a,ng),bm=yI(t,"targetPoint"),I1=new NZ(uc),K6t(I1.a,bm),uh=T0(t,Sre),hf=new FZ(uc),QBt(hf.a,uh),Mt=mee(e,t,Et),Mt}function Ine(e,t){_ne();var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et,kn;if(qe=e.e,B=e.d,l=e.a,qe==0)switch(t){case 0:return"0";case 1:return VS;case 2:return"0.00";case 3:return"0.000";case 4:return"0.0000";case 5:return"0.00000";case 6:return"0.000000";default:return Ce=new h0,t<0?Ce.a+="0E+":Ce.a+="0E",Ce.a+=-t,Ce.a}if(ie=B*10+1+7,fe=le(Zl,Ph,22,ie+1,15,1),i=ie,B==1)if(g=l[0],g<0){kn=Kr(g,ao);do N=kn,kn=h6(kn,10),fe[--i]=48+nr(Qm(N,Jm(kn,10)))&jr;while(Ma(kn,0)!=0)}else{kn=g;do N=kn,kn=kn/10|0,fe[--i]=48+(N-kn*10)&jr;while(kn!=0)}else{ft=le(In,si,22,B,15,1),Et=B,vc(l,0,ft,0,B);e:for(;;){for(Ue=0,v=Et-1;v>=0;v--)Mt=no(jd(Ue,32),Kr(ft[v],ao)),V=xBt(Mt),ft[v]=nr(V),Ue=nr(Pg(V,32));ee=nr(Ue),W=i;do fe[--i]=48+ee%10&jr;while((ee=ee/10|0)!=0&&i!=0);for(a=9-W+i,m=0;m0;m++)fe[--i]=48;for(E=Et-1;ft[E]==0;E--)if(E==0)break e;Et=E+1}for(;fe[i]==48;)++i}if(R=qe<0,f=ie-i-t-1,t==0)return R&&(fe[--i]=45),hu(fe,i,ie-i);if(t>0&&f>=-6){if(f>=0){for(y=i+f,C=ie-1;C>=y;C--)fe[C+1]=fe[C];return fe[++y]=46,R&&(fe[--i]=45),hu(fe,i,ie-i+1)}for(E=2;E<-f+1;E++)fe[--i]=48;return fe[--i]=46,fe[--i]=48,R&&(fe[--i]=45),hu(fe,i,ie-i)}return ut=i+1,we=new tw,R&&(we.a+="-"),ie-ut>=1?(Lg(we,fe[i]),we.a+=".",we.a+=hu(fe,i+1,ie-i-1)):we.a+=hu(fe,i,ie-i),we.a+="E",f>0&&(we.a+="+"),we.a+=""+f,we.a}function B$t(e,t,i,a){var l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et,kn,yi,as,Kc,uc,ng,kl,bm,I1,uh;if(fe=h(ae((!e.b&&(e.b=new an(pi,e,4,7)),e.b),0),97),Ce=fe.Yf(),Ue=fe.Zf(),we=fe.Xf()/2,W=fe.Wf()/2,re(fe,187)&&(ie=h(fe,121),Ce+=Sh(ie).i,Ce+=Sh(ie).i),Ce+=we,Ue+=W,Et=h(ae((!e.b&&(e.b=new an(pi,e,4,7)),e.b),0),97),yi=Et.Yf(),as=Et.Zf(),kn=Et.Xf()/2,qe=Et.Wf()/2,re(Et,187)&&(Mt=h(Et,121),yi+=Sh(Mt).i,yi+=Sh(Mt).i),yi+=kn,as+=qe,(!e.a&&(e.a=new ze(ts,e,6,6)),e.a).i==0)m=(p0(),y=new mE,y),$n((!e.a&&(e.a=new ze(ts,e,6,6)),e.a),m);else if((!e.a&&(e.a=new ze(ts,e,6,6)),e.a).i>1)for(N=new QC((!e.a&&(e.a=new ze(ts,e,6,6)),e.a));N.e!=N.i._b();)KA(N);for(g=h(ae((!e.a&&(e.a=new ze(ts,e,6,6)),e.a),0),270),V=yi,yi>Ce+we?V=Ce+we:yiUe+W?ee=Ue+W:asCe-we&&VUe-W&&eeyi+kn?ut=yi+kn:Ceas+qe?ft=as+qe:Ueyi-kn&&utas-qe&&fti&&(R=i-1),B=bm+al(t,24)*W6*C-C/2,B<0?B=1:B>a&&(B=a-1),l=(p0(),v=new gE,v),see(l,R),oee(l,B),$n((!g.a&&(g.a=new vs(oh,g,5)),g.a),l)}function pJe(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee;for(a=new ke,m=new ke,V=t/2,B=e._b(),l=h(e.cd(0),9),ee=h(e.cd(1),9),N=Kte(l.a,l.b,ee.a,ee.b,V),De(a,(ai(0,N.c.length),h(N.c[0],9))),De(m,(ai(1,N.c.length),h(N.c[1],9))),y=2;y=0;v--)Gi(i,(ai(v,g.c.length),h(g.c[v],9)));return i}function O$t(e){var t,i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et,kn;if(qe=h(G(e,($e(),Ki)),83),qe!=(Ms(),sp)&&qe!=hb){for(N=e.b,B=N.c.length,E=new Gl((Ef(B+2,zne),NI(no(no(5,B+2),(B+2)/10|0)))),W=new Gl((Ef(B+2,zne),NI(no(no(5,B+2),(B+2)/10|0)))),De(E,new ui),De(E,new ui),De(W,new ke),De(W,new ke),Ue=new ke,t=0;tEt?C:Et;for(a=new j(ft.f);a.aEt?ut:Et}Ee(we,XG,He(C)),Ee(we,YG,He(ut))}for(ee=0,B=new j(t.b);B.a=e.j){e.a=-1,e.c=1;return}if(t=po(e.i,e.d++),e.a=t,e.b==1){switch(t){case 92:if(a=10,e.d>=e.j)throw Y(new Wn(Zn((zn(),wz))));e.a=po(e.i,e.d++);break;case 45:(e.e&512)==512&&e.d=e.j||po(e.i,e.d)!=63)break;if(++e.d>=e.j)throw Y(new Wn(Zn((zn(),Are))));switch(t=po(e.i,e.d++),t){case 58:a=13;break;case 61:a=14;break;case 33:a=15;break;case 91:a=19;break;case 62:a=18;break;case 60:if(e.d>=e.j)throw Y(new Wn(Zn((zn(),Are))));if(t=po(e.i,e.d++),t==61)a=16;else if(t==33)a=17;else throw Y(new Wn(Zn((zn(),Yet))));break;case 35:for(;e.d=e.j)throw Y(new Wn(Zn((zn(),wz))));e.a=po(e.i,e.d++);break;default:a=0}e.c=a}function gJe(e){var t,i,a,l,f,g,m,v,y;for(e.b=1,wi(e),t=null,e.c==0&&e.a==94?(wi(e),t=(vi(),vi(),++Er,new _l(4)),Da(t,0,rM),m=(++Er,new _l(4))):m=(vi(),vi(),++Er,new _l(4)),l=!0;(y=e.c)!=1;){if(y==0&&e.a==93&&!l){t&&(mP(t,m),m=t);break}if(i=e.a,a=!1,y==10)switch(i){case 100:case 68:case 119:case 87:case 115:case 83:Cw(m,FS(i)),a=!0;break;case 105:case 73:case 99:case 67:i=(Cw(m,FS(i)),-1),a=!0;break;case 112:case 80:if(v=bve(e,i),!v)throw Y(new Wn(Zn((zn(),Pre))));Cw(m,v),a=!0;break;default:i=Kve(e)}else if(y==24&&!l){if(t&&(mP(t,m),m=t),f=gJe(e),mP(m,f),e.c!=0||e.a!=93)throw Y(new Wn(Zn((zn(),stt))));break}if(wi(e),!a){if(y==0){if(i==91)throw Y(new Wn(Zn((zn(),Rxe))));if(i==93)throw Y(new Wn(Zn((zn(),Ixe))));if(i==45&&!l&&e.a!=93)throw Y(new Wn(Zn((zn(),Lre))))}if(e.c!=0||e.a!=45||i==45&&l)Da(m,i,i);else{if(wi(e),(y=e.c)==1)throw Y(new Wn(Zn((zn(),vz))));if(y==0&&e.a==93)Da(m,i,i),Da(m,45,45);else{if(y==0&&e.a==93||y==24)throw Y(new Wn(Zn((zn(),Lre))));if(g=e.a,y==0){if(g==91)throw Y(new Wn(Zn((zn(),Rxe))));if(g==93)throw Y(new Wn(Zn((zn(),Ixe))));if(g==45)throw Y(new Wn(Zn((zn(),Lre))))}else y==10&&(g=Kve(e));if(wi(e),i>g)throw Y(new Wn(Zn((zn(),ctt))));Da(m,i,g)}}}l=!1}if(e.c==1)throw Y(new Wn(Zn((zn(),vz))));return U_(m),gP(m),e.b=0,wi(e),m}function F$t(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et,kn,yi,as,Kc,uc;for(ii(i,"Greedy cycle removal",1),ie=t.a,uc=ie.c.length,e.a=le(In,si,22,uc,15,1),e.c=le(In,si,22,uc,15,1),e.b=le(In,si,22,uc,15,1),v=0,V=new j(ie);V.a0?Mt+1:1);for(f=new j(Ce.f);f.a0?Mt+1:1)}e.c[v]==0?Gi(e.d,N):e.a[v]==0&&Gi(e.e,N),++v}for(B=-1,R=1,E=new ke,Et=h(G(t,(Ie(),gM)),214);uc>0;){for(;e.d.b!=0;)yi=h(FJ(e.d),8),e.b[yi.o]=B--,f_e(e,yi),--uc;for(;e.e.b!=0;)as=h(FJ(e.e),8),e.b[as.o]=R++,f_e(e,as),--uc;if(uc>0){for(C=zs,ee=new j(ie);ee.a=C&&(fe>C&&(E.c=le(on,et,1,0,5,1),C=fe),E.c[E.c.length]=N));y=h(St(E,pte(Et,E.c.length)),8),e.b[y.o]=R++,f_e(e,y),--uc}}for(kn=ie.c.length+1,v=0;ve.b[Kc]&&(Qg(a,!0),Ee(t,TG,(vt(),vt(),!0)));e.a=null,e.c=null,e.b=null,rd(e.e),rd(e.d),On(i)}function U$t(e){Fn(e.c,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#decimal"])),Fn(e.d,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#integer"])),Fn(e.e,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#boolean"])),Fn(e.f,Kn,X(q(Se,1),be,2,6,[Ls,"EBoolean",gi,"EBoolean:Object"])),Fn(e.i,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#byte"])),Fn(e.g,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#hexBinary"])),Fn(e.j,Kn,X(q(Se,1),be,2,6,[Ls,"EByte",gi,"EByte:Object"])),Fn(e.n,Kn,X(q(Se,1),be,2,6,[Ls,"EChar",gi,"EChar:Object"])),Fn(e.t,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#double"])),Fn(e.u,Kn,X(q(Se,1),be,2,6,[Ls,"EDouble",gi,"EDouble:Object"])),Fn(e.F,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#float"])),Fn(e.G,Kn,X(q(Se,1),be,2,6,[Ls,"EFloat",gi,"EFloat:Object"])),Fn(e.I,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#int"])),Fn(e.J,Kn,X(q(Se,1),be,2,6,[Ls,"EInt",gi,"EInt:Object"])),Fn(e.N,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#long"])),Fn(e.O,Kn,X(q(Se,1),be,2,6,[Ls,"ELong",gi,"ELong:Object"])),Fn(e.Z,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#short"])),Fn(e.$,Kn,X(q(Se,1),be,2,6,[Ls,"EShort",gi,"EShort:Object"])),Fn(e._,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#string"]))}function F_e(e,t,i,a){var l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et,kn,yi;if(yZe(t),v=h(ae((!t.b&&(t.b=new an(pi,t,4,7)),t.b),0),97),E=h(ae((!t.c&&(t.c=new an(pi,t,5,8)),t.c),0),97),m=Ia(v),y=Ia(E),g=(!t.a&&(t.a=new ze(ts,t,6,6)),t.a).i==0?null:h(ae((!t.a&&(t.a=new ze(ts,t,6,6)),t.a),0),270),qe=h(Ii(e.a,m),8),Et=h(Ii(e.a,y),8),ut=null,kn=null,re(v,187)&&(Ue=h(Ii(e.a,v),279),re(Ue,11)?ut=h(Ue,11):re(Ue,8)&&(qe=h(Ue,8),ut=h(St(qe.i,0),11))),re(E,187)&&(Mt=h(Ii(e.a,E),279),re(Mt,11)?kn=h(Mt,11):re(Mt,8)&&(Et=h(Mt,8),kn=h(St(Et.i,0),11))),!qe||!Et)return null;for(W=new Op,No(W,t),Ee(W,(Ie(),Jn),t),Ee(W,($e(),Lo),null),B=h(G(a,Va),19),qe==Et&&B.nc((xo(),C5)),ut||(Ce=(Oo(),lc),ft=null,g&&Bd(h(G(qe,Ki),83))&&(ft=new $t(g.j,g.k),wze(ft,V9(t)),zze(ft,i),SA(y,m)&&(Ce=Fc,tr(ft,qe.k))),ut=aKe(qe,ft,Ce,a)),kn||(Ce=(Oo(),Fc),yi=null,g&&Bd(h(G(Et,Ki),83))&&(yi=new $t(g.b,g.c),wze(yi,V9(t)),zze(yi,i)),kn=aKe(Et,yi,Ce,va(Et))),Os(W,ut),_s(W,kn),R=new Bn((!t.n&&(t.n=new ze(ea,t,1,7)),t.n));R.e!=R.i._b();)if(C=h(Yn(R),137),!ce(mt(rn(C,x1)))&&C.a)switch(V=$ee(C),De(W.b,V),h(G(V,am),226).g){case 2:case 3:B.nc((xo(),dM));break;case 1:case 0:B.nc((xo(),hM)),Ee(V,am,(Yd(),xL))}if(f=h(G(a,mM),317),ee=h(G(a,FG),292),l=f==(fx(),S5)||ee==(XA(),Toe),g&&(!g.a&&(g.a=new vs(oh,g,5)),g.a).i!=0&&l){for(ie=m6(g),N=new zc,we=Nn(ie,0);we.b!=we.d.c;)fe=h(Un(we),9),Gi(N,new Do(fe));Ee(W,KSe,N)}return W}function U_e(e,t,i,a,l,f){var g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et,kn,yi;for(m=h(St(e.d.c.b,a),26),Et=new zr,B=new zr,R=0;Ri&&(ut=B.a.Zb(ee,B),ut==null);for(kn=new zr,N=new zr,fe=Et.a.Xb().tc();fe.hc();)for(ee=h(fe.ic(),8),g=t==1?fr(ee):As(ee),y=(Mo(),new Nd(Kh(Gd(g.a,new z))));Gn(y);)v=h(Tn(y),14),ju(ee.c)!=ju(v.d.g.c)&&Cr(kn,v.d.g);for(we=B.a.Xb().tc();we.hc();)for(ee=h(we.ic(),8),g=t==1?fr(ee):As(ee),y=(Mo(),new Nd(Kh(Gd(g.a,new z))));Gn(y);)v=h(Tn(y),14),ju(ee.c)!=ju(v.d.g.c)&&Cr(N,v.d.g);for(ert&&Jh(),qe=h(St(e.d.c.b,a+(t==1?1:-1)),26),W=zs,V=zi,C=0;CC?W:C:N.a.Qb(ee)&&(V=VC&&(Et=0,kn+=E+qe,E=0),a9t(Ce,g,Et,kn),t=w.Math.max(t,Et+Ue.a),E=w.Math.max(E,Ue.b),Et+=Ue.a+qe;for(we=new ui,i=new ui,ft=new j(e);ft.a=2){for(R=!0,ie=(ai(1,C.c.length),h(C.c[1],26)),W=new j(g.a);W.a=2){for(R=!0,fe=h(St(C,C.c.length-2),26),W=new j(v.a);W.aJte(f))&&(C=f);for(!C&&(C=(ai(0,V.c.length),h(V.c[0],164))),W=new j(t.b);W.a0?(N=(Ce+1)*e.d,N=0&&(df+=(Ce+2)*e.d)}fe=Mt,m=v}while(Mt);for(l=new j(e.j);l.a=-1900?1:0,i>=4?Mi(e,X(q(Se,1),be,2,6,[RJe,IJe])[m]):Mi(e,X(q(Se,1),be,2,6,["BC","AD"])[m]);break;case 121:D5t(e,i,a);break;case 77:JUt(e,i,a);break;case 107:v=l.q.getHours(),v==0?ad(e,24,i):ad(e,v,i);break;case 83:G8t(e,i,l);break;case 69:E=a.q.getDay(),i==5?Mi(e,X(q(Se,1),be,2,6,["S","M","T","W","T","F","S"])[E]):i==4?Mi(e,X(q(Se,1),be,2,6,[tie,nie,iie,rie,sie,oie,aie])[E]):Mi(e,X(q(Se,1),be,2,6,["Sun","Mon","Tue","Wed","Thu","Fri","Sat"])[E]);break;case 97:l.q.getHours()>=12&&l.q.getHours()<24?Mi(e,X(q(Se,1),be,2,6,["AM","PM"])[1]):Mi(e,X(q(Se,1),be,2,6,["AM","PM"])[0]);break;case 104:C=l.q.getHours()%12,C==0?ad(e,12,i):ad(e,C,i);break;case 75:R=l.q.getHours()%12,ad(e,R,i);break;case 72:B=l.q.getHours(),ad(e,B,i);break;case 99:N=a.q.getDay(),i==5?Mi(e,X(q(Se,1),be,2,6,["S","M","T","W","T","F","S"])[N]):i==4?Mi(e,X(q(Se,1),be,2,6,[tie,nie,iie,rie,sie,oie,aie])[N]):i==3?Mi(e,X(q(Se,1),be,2,6,["Sun","Mon","Tue","Wed","Thu","Fri","Sat"])[N]):ad(e,N,1);break;case 76:W=a.q.getMonth(),i==5?Mi(e,X(q(Se,1),be,2,6,["J","F","M","A","M","J","J","A","S","O","N","D"])[W]):i==4?Mi(e,X(q(Se,1),be,2,6,[Vne,Wne,Hne,qne,Bx,Xne,Yne,Zne,Kne,Jne,Qne,eie])[W]):i==3?Mi(e,X(q(Se,1),be,2,6,["Jan","Feb","Mar","Apr",Bx,"Jun","Jul","Aug","Sep","Oct","Nov","Dec"])[W]):ad(e,W+1,i);break;case 81:V=a.q.getMonth()/3|0,i<4?Mi(e,X(q(Se,1),be,2,6,["Q1","Q2","Q3","Q4"])[V]):Mi(e,X(q(Se,1),be,2,6,["1st quarter","2nd quarter","3rd quarter","4th quarter"])[V]);break;case 100:ee=a.q.getDate(),ad(e,ee,i);break;case 109:y=l.q.getMinutes(),ad(e,y,i);break;case 115:g=l.q.getSeconds(),ad(e,g,i);break;case 122:i<4?Mi(e,f.c[0]):Mi(e,f.c[1]);break;case 118:Mi(e,f.b);break;case 90:i<3?Mi(e,tFt(f)):i==3?Mi(e,sFt(f)):Mi(e,oFt(f.a));break;default:return!1}return!0}function G_e(){G_e=M;var e;rMe=(e=h(bl(jse),10),new Oc(e,h(el(e,e.length),10),0)),krt=new ln(Iye,rMe),Hrt=new ln(Dye,(vt(),vt(),!1)),fMe=(Q9(),noe),Zrt=new ln(nz,fMe),ust=new ln(Bye,!1),fst=new ln(Oye,!0),He(1),kst=new ln(Nye,He(7)),Rst=new ln(Fye,!1),Sst=new ln(Uye,!1),aMe=(EU(),Vse),Nrt=new ln(Bie,aMe),pMe=(u7(),Eoe),cst=new ln(t5,pMe),hMe=(du(),r3),tst=new ln(zye,hMe),gMe=(wx(),W5),lst=new ln(Gye,gMe),He(-1),nst=new ln(Oie,He(4)),He(-1),rst=new ln(Nie,He(2)),dMe=(G_(),$G),ast=new ln(Fie,dMe),He(0),ost=new ln(Uie,He(0)),Qrt=new ln(zie,He(zi)),oMe=(fx(),M5),Ort=new ln(Gie,oMe),Drt=new ln(jye,.1),Brt=new ln($ye,!1),He(0),Rrt=new ln(Vye,He(40)),sMe=(bS(),toe),Irt=new ln(Wye,sMe),vMe=(XA(),U5),Est=new ln(ZS,vMe),mst=new Sr(jie),mMe=(RI(),ZG),hst=new ln($ie,mMe),bMe=(g6(),vG),pst=new ln(Vie,bMe),new CE,wst=new ln(Wie,.3),_st=new Sr(Hie),wMe=(_w(),jG),yst=new ln(Hye,wMe),uMe=(WU(),Aoe),zrt=new ln(qie,uMe),Vrt=new ln(iz,!0),jrt=new ln(rz,.4),Pst=new ln(qye,10),Ast=new ln(Xye,10),Lst=new ln(Yye,20),He(0),Mst=new ln(Zye,He(0)),He(0),Tst=new ln(Kye,He(0)),He(0),Cst=new ln(Jye,He(0)),Art=new ln(Xie,!1),iMe=(IS(),ZP),Lrt=new ln(Qye,iMe),nMe=(sU(),Gse),Prt=new ln(e2e,nMe),Xrt=new ln(sz,!1),He(0),qrt=new ln(Yie,He(16)),He(0),Yrt=new ln(Zie,He(5)),EMe=(LU(),Loe),Xst=new ln(TP,EMe),Ist=new ln(t2e,10),Dst=new ln(n2e,1),yMe=(wU(),bG),Ust=new ln(oz,yMe),Bst=new Sr(Kie),_Me=He(1),He(0),Nst=new ln(Jie,_Me),xMe=(yU(),Poe),Hst=new ln(Qie,xMe),jst=new ln(az,!0),zst=new ln(cz,2),Vst=new ln(ere,!0),lMe=(d7(),wG),Urt=new ln(i2e,lMe),cMe=(JA(),Use),Frt=new ln(r2e,cMe),Jrt=Wse,Krt=S5,ist=GG,sst=GG,est=xoe,bst=z5,dst=U5,gst=U5,vst=Coe,xst=z5,Grt=(ld(),ub),Wrt=ub,$rt=ub,Ost=$se,Fst=bG,qst=koe,$st=H5,Gst=H5,Wst=H5}function ur(){ur=M;var e,t;yCe=new Sr(iet),xCe=(ud(),Qoe),dct=new ln(x2e,xCe),new CE,yM=new ln(WS,null),pct=new Sr(cxe),nae=new ln(nre,(vt(),vt(),!1)),SCe=(qs(),Oh),vL=new ln(rre,SCe),CCe=(ld(),gae),TCe=new ln(n5,CCe),wct=new ln(oxe,!1),LCe=(e1(),vj),Ey=new ln(E2e,LCe),FCe=new tx(12),Sy=new ln(Ux,FCe),rae=new ln(Q7,!1),$Ce=(Ms(),hb),nD=new ln(kie,$Ce),f3=new Sr(fz),mj=new Sr(Y6),fae=new Sr(J7),hae=new Sr(Z6),kCe=new zc,u3=new ln(D2e,kCe),mct=new ln(F2e,!1),vct=new ln(U2e,!1),new Sr(ret),RCe=new G2,dj=new ln($2e,RCe),sae=new ln(_2e,!1),new CE,Sct=new ln(set,1),new ln(oet,!0),He(0),new ln(aet,He(100)),new ln(cet,!1),He(0),new ln(uet,He(4e3)),He(0),new ln(fet,He(400)),new ln(het,!1),new ln(det,!0),new ln(pet,!1),ECe=(XU(),yae),gct=new ln(axe,ECe),HCe=new ln(Mie,12),Mct=new ln(h2e,10),qCe=new ln(Lie,2),Tct=new ln(d2e,10),XCe=new ln(p2e,0),bj=new ln(m2e,5),YCe=new ln(g2e,1),My=new ln(qS,20),JCe=new ln(b2e,10),dae=new Sr(w2e),KCe=new jNe,ZCe=new ln(V2e,KCe),xct=new Sr(j2e),UCe=!1,yct=new ln(G2e,UCe),ICe=new tx(5),_ct=new ln(get,ICe),DCe=(a1(),t=h(bl(Ys),10),new Oc(t,h(el(t,t.length),10),0)),pj=new ln(T2e,DCe),GCe=(Xg(),fb),zCe=new ln(P2e,GCe),aae=new Sr(L2e),cae=new Sr(k2e),lae=new Sr(R2e),oae=new Sr(I2e),BCe=(e=h(bl(AL),10),new Oc(e,h(el(e,e.length),10),0)),xM=new ln(lz,BCe),NCe=Ht((cc(),SM)),gj=new ln(ire,NCe),OCe=new $t(0,0),tD=new ln(uz,OCe),MCe=(Yd(),wj),eD=new ln(B2e,MCe),bct=new ln(O2e,!1),new Sr(met),He(1),new ln(bet,null),jCe=new Sr(z2e),Ect=new Sr(N2e),WCe=(Fe(),Na),_L=new ln(y2e,WCe),Zc=new Sr(v2e),VCe=(Qf(),Ty),uae=new ln(C2e,VCe),iD=new ln(A2e,!1),hj=new ln(S2e,!1),iae=new ln(M2e,!1),ACe=new ln(Tie,1),PCe=(f7(),bae),new ln(wet,PCe)}function W$t(e){e.gb||(e.gb=!0,e.b=ra(e,0),xr(e.b,18),Ji(e.b,19),e.a=ra(e,1),xr(e.a,1),Ji(e.a,2),Ji(e.a,3),Ji(e.a,4),Ji(e.a,5),e.o=ra(e,2),xr(e.o,8),xr(e.o,9),Ji(e.o,10),Ji(e.o,11),Ji(e.o,12),Ji(e.o,13),Ji(e.o,14),Ji(e.o,15),Ji(e.o,16),Ji(e.o,17),Ji(e.o,18),Ji(e.o,19),Ji(e.o,20),Ji(e.o,21),Ji(e.o,22),Ji(e.o,23),To(e.o),To(e.o),To(e.o),To(e.o),To(e.o),To(e.o),To(e.o),To(e.o),To(e.o),To(e.o),e.p=ra(e,3),xr(e.p,2),xr(e.p,3),xr(e.p,4),xr(e.p,5),Ji(e.p,6),Ji(e.p,7),To(e.p),To(e.p),e.q=ra(e,4),xr(e.q,8),e.v=ra(e,5),Ji(e.v,9),To(e.v),To(e.v),To(e.v),e.w=ra(e,6),xr(e.w,2),xr(e.w,3),xr(e.w,4),Ji(e.w,5),e.B=ra(e,7),Ji(e.B,1),To(e.B),To(e.B),To(e.B),e.Q=ra(e,8),Ji(e.Q,0),To(e.Q),e.R=ra(e,9),xr(e.R,1),e.S=ra(e,10),To(e.S),To(e.S),To(e.S),To(e.S),To(e.S),To(e.S),To(e.S),To(e.S),To(e.S),To(e.S),To(e.S),To(e.S),To(e.S),To(e.S),To(e.S),e.T=ra(e,11),Ji(e.T,10),Ji(e.T,11),Ji(e.T,12),Ji(e.T,13),Ji(e.T,14),To(e.T),To(e.T),e.U=ra(e,12),xr(e.U,2),xr(e.U,3),Ji(e.U,4),Ji(e.U,5),Ji(e.U,6),Ji(e.U,7),To(e.U),e.V=ra(e,13),Ji(e.V,10),e.W=ra(e,14),xr(e.W,18),xr(e.W,19),xr(e.W,20),Ji(e.W,21),Ji(e.W,22),Ji(e.W,23),e.bb=ra(e,15),xr(e.bb,10),xr(e.bb,11),xr(e.bb,12),xr(e.bb,13),xr(e.bb,14),xr(e.bb,15),xr(e.bb,16),Ji(e.bb,17),To(e.bb),To(e.bb),e.eb=ra(e,16),xr(e.eb,2),xr(e.eb,3),xr(e.eb,4),xr(e.eb,5),xr(e.eb,6),xr(e.eb,7),Ji(e.eb,8),Ji(e.eb,9),e.ab=ra(e,17),xr(e.ab,0),xr(e.ab,1),e.H=ra(e,18),Ji(e.H,0),Ji(e.H,1),Ji(e.H,2),Ji(e.H,3),Ji(e.H,4),Ji(e.H,5),To(e.H),e.db=ra(e,19),Ji(e.db,2),e.c=hi(e,20),e.d=hi(e,21),e.e=hi(e,22),e.f=hi(e,23),e.i=hi(e,24),e.g=hi(e,25),e.j=hi(e,26),e.k=hi(e,27),e.n=hi(e,28),e.r=hi(e,29),e.s=hi(e,30),e.t=hi(e,31),e.u=hi(e,32),e.fb=hi(e,33),e.A=hi(e,34),e.C=hi(e,35),e.D=hi(e,36),e.F=hi(e,37),e.G=hi(e,38),e.I=hi(e,39),e.J=hi(e,40),e.L=hi(e,41),e.M=hi(e,42),e.N=hi(e,43),e.O=hi(e,44),e.P=hi(e,45),e.X=hi(e,46),e.Y=hi(e,47),e.Z=hi(e,48),e.$=hi(e,49),e._=hi(e,50),e.cb=hi(e,51),e.K=hi(e,52))}function Ie(){Ie=M;var e,t;Jn=new Sr(yye),XSe=new Sr("coordinateOrigin"),coe=new Sr("processors"),qSe=new Zr("compoundNode",(vt(),vt(),!1)),L5=new Zr("insideConnections",!1),md=new Sr("nestedLGraph"),sm=new Sr("parentLNode"),KSe=new Sr("originalBendpoints"),JSe=new Sr("originalDummyNodePosition"),QSe=new Sr("originalLabelEdge"),LG=new Sr("representedLabels"),CG=new Sr("endLabels"),t3=new Zr("labelSide",(xl(),fD)),my=new Zr("maxEdgeThickness",0),om=new Zr("reversed",!1),gM=new Sr(xye),Cl=new Zr("longEdgeSource",null),Al=new Zr("longEdgeTarget",null),n3=new Zr("longEdgeHasLabelDummies",!1),k5=new Zr("longEdgeBeforeLabelDummy",!1),roe=new Zr("edgeConstraint",(M_(),Hse)),pM=new Sr("inLayerLayoutUnit"),y1=new Zr("inLayerConstraint",(Hd(),A5)),e3=new Zr("inLayerSuccessorConstraint",new ke),Pl=new Sr("portDummy"),MG=new Zr("crossingHint",He(0)),Va=new Zr("graphProperties",(t=h(bl(Qse),10),new Oc(t,h(el(t,t.length),10),0))),pa=new Zr("externalPortSide",(Fe(),Na)),ZSe=new Zr("externalPortSize",new fo),soe=new Sr("externalPortReplacedDummies"),AG=new Sr("externalPortReplacedDummy"),Qx=new Zr("externalPortConnections",(e=h(bl(Ec),10),new Oc(e,h(el(e,e.length),10),0))),nb=new Zr(PQe,0),WSe=new Sr("barycenterAssociates"),i3=new Sr("TopSideComments"),Jx=new Sr("BottomSideComments"),SG=new Sr("CommentConnectionPort"),ooe=new Zr("inputCollect",!1),aoe=new Zr("outputCollect",!1),TG=new Zr("cyclic",!1),P5=new Zr("bigNodeOriginalSize",new Kb(0)),Fw=new Zr("bigNodeInitial",!1),HSe=new Zr("org.eclipse.elk.alg.layered.bigNodeLabels",new ke),ioe=new Zr("org.eclipse.elk.alg.layered.postProcess",null),YSe=new Sr("crossHierarchyMap"),foe=new Sr("targetOffset"),Trt=new Zr("splineLabelSize",new fo),R5=new Zr("splineLoopSide",(ll(),l3)),uoe=new Zr("splineSelfLoopComponents",new ke),eMe=new Zr("splineSelfLoopMargins",new G2),Uw=new Sr("spacings"),PG=new Zr("partitionConstraint",!1),tb=new Sr("breakingPoint.info"),JP=new Sr("splines.route.start"),loe=new Sr("splines.edgeChain")}function Ao(){Ao=M,nSe=new Dr("LEFT_DIR_PREPROCESSOR",0),jEe=new Dr("DOWN_DIR_PREPROCESSOR",1),mSe=new Dr("UP_DIR_PREPROCESSOR",2),zEe=new Dr("COMMENT_PREPROCESSOR",3),qP=new Dr("EDGE_AND_LAYER_CONSTRAINT_EDGE_REVERSER",4),hSe=new Dr("SPLINE_SELF_LOOP_PREPROCESSOR",5),kse=new Dr("INTERACTIVE_EXTERNAL_PORT_POSITIONER",6),aSe=new Dr("PARTITION_PREPROCESSOR",7),Pse=new Dr("BIG_NODES_PREPROCESSOR",8),aG=new Dr("LABEL_DUMMY_INSERTER",9),YEe=new Dr("HIGH_DEGREE_NODE_LAYER_PROCESSOR",10),oSe=new Dr("PARTITION_POSTPROCESSOR",11),rSe=new Dr("NODE_PROMOTION",12),fM=new Dr("LAYER_CONSTRAINT_PROCESSOR",13),HEe=new Dr("HIERARCHICAL_PORT_CONSTRAINT_PROCESSOR",14),Ase=new Dr("BIG_NODES_INTERMEDIATEPROCESSOR",15),lSe=new Dr("SEMI_INTERACTIVE_CROSSMIN_PROCESSOR",16),BEe=new Dr("BREAKING_POINT_INSERTER",17),Dse=new Dr("LONG_EDGE_SPLITTER",18),Ose=new Dr("PORT_SIDE_PROCESSOR",19),oG=new Dr("INVERTED_PORT_PROCESSOR",20),cSe=new Dr("SELF_LOOP_PROCESSOR",21),Bse=new Dr("PORT_LIST_SORTER",22),fG=new Dr("NORTH_SOUTH_PORT_PREPROCESSOR",23),OEe=new Dr("BREAKING_POINT_PROCESSOR",24),sSe=new Dr(EQe,25),pSe=new Dr(SQe,26),fSe=new Dr("SPLINE_SELF_LOOP_POSITIONER",27),uSe=new Dr("SINGLE_EDGE_GRAPH_WRAPPER",28),Rse=new Dr("IN_LAYER_CONSTRAINT_PROCESSOR",29),Lse=new Dr("BIG_NODES_SPLITTER",30),$Ee=new Dr("END_NODE_PORT_LABEL_MANAGEMENT_PROCESSOR",31),QEe=new Dr("LABEL_AND_NODE_SIZE_PROCESSOR",32),dSe=new Dr("SPLINE_SELF_LOOP_ROUTER",33),iSe=new Dr("NODE_MARGIN_CALCULATOR",34),sG=new Dr("END_LABEL_PREPROCESSOR",35),lG=new Dr("LABEL_DUMMY_SWITCHER",36),FEe=new Dr("CENTER_LABEL_MANAGEMENT_PROCESSOR",37),uM=new Dr("LABEL_SIDE_SELECTOR",38),KEe=new Dr("HYPEREDGE_DUMMY_MERGER",39),qEe=new Dr("HIERARCHICAL_PORT_DUMMY_SIZE_PROCESSOR",40),eSe=new Dr("LAYER_SIZE_AND_GRAPH_HEIGHT_CALCULATOR",41),XP=new Dr("HIERARCHICAL_PORT_POSITION_PROCESSOR",42),E5=new Dr("BIG_NODES_POSTPROCESSOR",43),UEe=new Dr("COMMENT_POSTPROCESSOR",44),JEe=new Dr("HYPERNODE_PROCESSOR",45),XEe=new Dr("HIERARCHICAL_PORT_ORTHOGONAL_EDGE_ROUTER",46),Ise=new Dr("LONG_EDGE_JOINER",47),NEe=new Dr("BREAKING_POINT_REMOVER",48),uG=new Dr("NORTH_SOUTH_PORT_POSTPROCESSOR",49),ZEe=new Dr("HORIZONTAL_COMPACTOR",50),cG=new Dr("LABEL_DUMMY_REMOVER",51),VEe=new Dr("FINAL_SPLINE_BENDPOINTS_CALCULATOR",52),hG=new Dr("REVERSED_EDGE_RESTORER",53),rG=new Dr("END_LABEL_POSTPROCESSOR",54),WEe=new Dr("HIERARCHICAL_NODE_RESIZER",55),tSe=new Dr("LEFT_DIR_POSTPROCESSOR",56),GEe=new Dr("DOWN_DIR_POSTPROCESSOR",57),gSe=new Dr("UP_DIR_POSTPROCESSOR",58)}function H$t(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et,kn,yi,as,Kc,uc,ng,kl,bm,I1,uh,hf,df,RM,TD,CD,E3,Gae,UL,Nut,mPe,yb,zL,jae,S3,GL,cv,jL,$ae,Fut;for(mPe=0,kn=0,Kc=t.length;kn0&&(e.a[hf.o]=mPe++)}for(GL=0,yi=0,uc=i.length;yi0;){for(hf=(Rn(CD.b>0),h(CD.a.cd(CD.c=--CD.b),11)),TD=0,m=new j(hf.d);m.a0&&(hf.i==(Fe(),bn)?(e.a[hf.o]=GL,++GL):(e.a[hf.o]=GL+ng+bm,++bm))}GL+=bm}for(RM=(Yr(),new ui),B=new Gc,Et=0,as=t.length;Ety.b&&(y.b=E3)):hf.g.c==Nut&&(E3y.c&&(y.c=E3));for(DI(N,0,N.length,null),S3=le(In,si,22,N.length,15,1),a=le(In,si,22,GL+1,15,1),V=0;V0;)Ue%2>0&&(l+=$ae[Ue+1]),Ue=(Ue-1)/2|0,++$ae[Ue];for(ut=le(Pot,et,336,N.length*2,0,1),fe=0;fe'?":dt(Yet,e)?"'(?<' or '(? toIndex: ",sye=", toIndex: ",VJe="org.eclipse.elk.alg.common.compaction",WJe="Scanline/EventHandler",dd="org.eclipse.elk.alg.common.compaction.oned",HJe="CNode belongs to another CGroup.",qJe="ISpacingsHandler/1",mie="The ",bie=" instance has been finished already.",XJe="The direction ",YJe=" is not supported by the CGraph instance.",ZJe="OneDimensionalCompactor",KJe="OneDimensionalCompactor/lambda$0$Type",JJe="Quadruplet",QJe="ScanlineConstraintCalculator",eQe="ScanlineConstraintCalculator/ConstraintsScanlineHandler",tQe="ScanlineConstraintCalculator/ConstraintsScanlineHandler/lambda$0$Type",nQe="ScanlineConstraintCalculator/Timestamp",iQe="ScanlineConstraintCalculator/lambda$0$Type",ef={138:1,56:1},wie="org.eclipse.elk.alg.common.compaction.options",Za="org.eclipse.elk.core.data",oye="org.eclipse.elk.polyomino.traversalStrategy",aye="org.eclipse.elk.polyomino.lowLevelSort",cye="org.eclipse.elk.polyomino.highLevelSort",lye="org.eclipse.elk.polyomino.fill",pd={154:1},vie="polyomino",Lh="org.eclipse.elk.alg.common.compaction.polyomino",X7="org.eclipse.elk.alg.common.compaction.polyomino.structures",uye="Direction",_ie="Grid is only of size ",yie=". Requested point (",xie=") is out of bounds.",Y7=" Given center based coordinates were (",q6="org.eclipse.elk.graph.properties",rQe="IPropertyHolder",Eie={3:1,93:1,131:1},K_={244:1},vP="org.eclipse.elk.core",sQe="Connected Components Compaction",oQe="org.eclipse.elk.alg.disco",Z7="org.eclipse.elk.alg.disco.graph",Sie="org.eclipse.elk.alg.disco.options",aQe="CompactionStrategy",fye="org.eclipse.elk.disco.componentCompaction.strategy",hye="org.eclipse.elk.disco.componentCompaction.componentLayoutAlgorithm",dye="org.eclipse.elk.disco.debug.discoGraph",pye="org.eclipse.elk.disco.debug.discoPolys",cQe="componentCompaction",u1="org.eclipse.elk.disco",Mie="org.eclipse.elk.spacing.componentComponent",Tie="org.eclipse.elk.edge.thickness",WS="org.eclipse.elk.aspectRatio",Ux="org.eclipse.elk.padding",J_="org.eclipse.elk.alg.disco.transform",Cie=1.5707963267948966,Lw={3:1,4:1,5:1,175:1},f1={221:1,3:1,4:1},gye={3:1,6:1,4:1,5:1,63:1,73:1},mye="org.eclipse.elk.alg.force",bye="ComponentsProcessor",lQe="ComponentsProcessor/1",X6="org.eclipse.elk.alg.force.graph",uQe="Component Layout",wye="org.eclipse.elk.alg.force.model",gd=.01,K7="org.eclipse.elk.force.model",vye="org.eclipse.elk.force.iterations",_ye="org.eclipse.elk.force.repulsivePower",Aie="org.eclipse.elk.force.temperature",Jd=.001,Pie="org.eclipse.elk.force.repulsion",_P="org.eclipse.elk.alg.force.options",HS=1.600000023841858,kh="org.eclipse.elk.force",Y6="org.eclipse.elk.priority",qS="org.eclipse.elk.spacing.nodeNode",Lie="org.eclipse.elk.spacing.edgeLabel",J7="org.eclipse.elk.randomSeed",Z6="org.eclipse.elk.separateConnectedComponents",Q7="org.eclipse.elk.interactive",kie="org.eclipse.elk.portConstraints",yye="origin",xye="random",fQe="boundingBox.upLeft",hQe="boundingBox.lowRight",Eye="org.eclipse.elk.stress.fixed",Sye="org.eclipse.elk.stress.desiredEdgeLength",Mye="org.eclipse.elk.stress.dimension",Tye="org.eclipse.elk.stress.epsilon",Cye="org.eclipse.elk.stress.iterationLimit",yP="org.eclipse.elk.stress",dQe="ELK Stress",Rie="org.eclipse.elk.alg.force.stress",pQe="Layered layout",K6="org.eclipse.elk.alg.layered",J6="org.eclipse.elk.alg.layered.compaction.components",xP="org.eclipse.elk.alg.layered.compaction.oned",ez="org.eclipse.elk.alg.layered.compaction.oned.algs",h1="org.eclipse.elk.alg.layered.compaction.recthull",nm="org.eclipse.elk.alg.layered.components",gQe={3:1,6:1,4:1,5:1,85:1,63:1,73:1},tz="org.eclipse.elk.alg.layered.compound",mu={3:1,6:1,4:1,5:1,99:1,85:1,63:1,73:1},kr={50:1},Ka="org.eclipse.elk.alg.layered.graph",Cf={3:1,6:1,4:1,5:1,85:1,123:1,148:1,63:1,73:1},mQe="Not supported by LGraph",bQe=`([{"' \r +`,d=new G1(r.device,{source:u,shaderLayout:{bindings:[{name:"result",type:"storage",group:0,location:0}]}});d.setBindings({result:r});let b=r.device.beginComputePass({});return d.dispatch(b,c.x,c.y,c.z),b.end(),r.device.submit(),d.destroy(),{success:!0}}});var Lwt,kwt=Ve(()=>{U3();Lwt=({inputs:s,output:n,target:r})=>{let{columns:c}=s;return pp({module:{name:"swizzle",source:"// swizzle expression handled inline"},expression:u=>`x[${c[u]}]`,inputs:{x:s.x},output:n,outputBuffer:r}),{success:!0}}});var Rwt={};Oy(Rwt,{arithmetic:()=>cwt,dot:()=>uwt,equalAll:()=>hwt,extent:()=>gwt,fround:()=>bwt,gather:()=>vwt,interleave:()=>Due,length:()=>Swt,segmentedMap:()=>ywt,select:()=>Twt,sequence:()=>Awt,swizzle:()=>Lwt});var ZRe=Ve(()=>{lwt();fwt();dwt();mwt();wwt();_wt();xwt();Ewt();Mwt();Cwt();Pwt();kwt()});var zvt=Sd((uai,TIe)=>{"use strict";TIe.exports=Jue;TIe.exports.default=Jue;function Jue(s,n,r){r=r||2;var c=n&&n.length,u=c?n[0]*r:s.length,d=Nvt(s,0,u,r,!0),b=[];if(!d||d.next===d.prev)return b;var w,_,x,T,M,L,I;if(c&&(d=wsn(s,n,d,r)),s.length>80*r){w=x=s[0],_=T=s[1];for(var D=r;Dx&&(x=M),L>T&&(T=L);I=Math.max(x-w,T-_),I=I!==0?32767/I:0}return fW(d,b,r,w,_,I,0),b}function Nvt(s,n,r,c,u){var d,b;if(u===MIe(s,n,r,c)>0)for(d=n;d=n;d-=c)b=Ovt(d,s[d],s[d+1],b);return b&&Que(b,b.next)&&(dW(b),b=b.next),b}function B4(s,n){if(!s)return s;n||(n=s);var r=s,c;do if(c=!1,!r.steiner&&(Que(r,r.next)||eu(r.prev,r,r.next)===0)){if(dW(r),r=n=r.prev,r===r.next)break;c=!0}else r=r.next;while(c||r!==n);return n}function fW(s,n,r,c,u,d,b){if(s){!b&&d&&Esn(s,c,u,d);for(var w=s,_,x;s.prev!==s.next;){if(_=s.prev,x=s.next,d?gsn(s,c,u,d):psn(s)){n.push(_.i/r|0),n.push(s.i/r|0),n.push(x.i/r|0),dW(s),s=x.next,w=x.next;continue}if(s=x,s===w){b?b===1?(s=msn(B4(s),n,r),fW(s,n,r,c,u,d,2)):b===2&&bsn(s,n,r,c,u,d):fW(B4(s),n,r,c,u,d,1);break}}}}function psn(s){var n=s.prev,r=s,c=s.next;if(eu(n,r,c)>=0)return!1;for(var u=n.x,d=r.x,b=c.x,w=n.y,_=r.y,x=c.y,T=ud?u>b?u:b:d>b?d:b,I=w>_?w>x?w:x:_>x?_:x,D=c.next;D!==n;){if(D.x>=T&&D.x<=L&&D.y>=M&&D.y<=I&&BB(u,w,d,_,b,x,D.x,D.y)&&eu(D.prev,D,D.next)>=0)return!1;D=D.next}return!0}function gsn(s,n,r,c){var u=s.prev,d=s,b=s.next;if(eu(u,d,b)>=0)return!1;for(var w=u.x,_=d.x,x=b.x,T=u.y,M=d.y,L=b.y,I=w<_?w_?w>x?w:x:_>x?_:x,O=T>M?T>L?T:L:M>L?M:L,z=EIe(I,D,n,r,c),Z=EIe(F,O,n,r,c),H=s.prevZ,te=s.nextZ;H&&H.z>=z&&te&&te.z<=Z;){if(H.x>=I&&H.x<=F&&H.y>=D&&H.y<=O&&H!==u&&H!==b&&BB(w,T,_,M,x,L,H.x,H.y)&&eu(H.prev,H,H.next)>=0||(H=H.prevZ,te.x>=I&&te.x<=F&&te.y>=D&&te.y<=O&&te!==u&&te!==b&&BB(w,T,_,M,x,L,te.x,te.y)&&eu(te.prev,te,te.next)>=0))return!1;te=te.nextZ}for(;H&&H.z>=z;){if(H.x>=I&&H.x<=F&&H.y>=D&&H.y<=O&&H!==u&&H!==b&&BB(w,T,_,M,x,L,H.x,H.y)&&eu(H.prev,H,H.next)>=0)return!1;H=H.prevZ}for(;te&&te.z<=Z;){if(te.x>=I&&te.x<=F&&te.y>=D&&te.y<=O&&te!==u&&te!==b&&BB(w,T,_,M,x,L,te.x,te.y)&&eu(te.prev,te,te.next)>=0)return!1;te=te.nextZ}return!0}function msn(s,n,r){var c=s;do{var u=c.prev,d=c.next.next;!Que(u,d)&&Fvt(u,c,c.next,d)&&hW(u,d)&&hW(d,u)&&(n.push(u.i/r|0),n.push(c.i/r|0),n.push(d.i/r|0),dW(c),dW(c.next),c=s=d),c=c.next}while(c!==s);return B4(c)}function bsn(s,n,r,c,u,d){var b=s;do{for(var w=b.next.next;w!==b.prev;){if(b.i!==w.i&&Tsn(b,w)){var _=Uvt(b,w);b=B4(b,b.next),_=B4(_,_.next),fW(b,n,r,c,u,d,0),fW(_,n,r,c,u,d,0);return}w=w.next}b=b.next}while(b!==s)}function wsn(s,n,r,c){var u=[],d,b,w,_,x;for(d=0,b=n.length;d=r.next.y&&r.next.y!==r.y){var w=r.x+(u-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(w<=c&&w>d&&(d=w,b=r.x=r.x&&r.x>=x&&c!==r.x&&BB(ub.x||r.x===b.x&&xsn(b,r)))&&(b=r,M=L)),r=r.next;while(r!==_);return b}function xsn(s,n){return eu(s.prev,s,n.prev)<0&&eu(n.next,s,s.next)<0}function Esn(s,n,r,c){var u=s;do u.z===0&&(u.z=EIe(u.x,u.y,n,r,c)),u.prevZ=u.prev,u.nextZ=u.next,u=u.next;while(u!==s);u.prevZ.nextZ=null,u.prevZ=null,Ssn(u)}function Ssn(s){var n,r,c,u,d,b,w,_,x=1;do{for(r=s,s=null,d=null,b=0;r;){for(b++,c=r,w=0,n=0;n0||_>0&&c;)w!==0&&(_===0||!c||r.z<=c.z)?(u=r,r=r.nextZ,w--):(u=c,c=c.nextZ,_--),d?d.nextZ=u:s=u,u.prevZ=d,d=u;r=c}d.nextZ=null,x*=2}while(b>1);return s}function EIe(s,n,r,c,u){return s=(s-r)*u|0,n=(n-c)*u|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,s|n<<1}function Msn(s){var n=s,r=s;do(n.x=(s-b)*(d-w)&&(s-b)*(c-w)>=(r-b)*(n-w)&&(r-b)*(d-w)>=(u-b)*(c-w)}function Tsn(s,n){return s.next.i!==n.i&&s.prev.i!==n.i&&!Csn(s,n)&&(hW(s,n)&&hW(n,s)&&Asn(s,n)&&(eu(s.prev,s,n.prev)||eu(s,n.prev,n))||Que(s,n)&&eu(s.prev,s,s.next)>0&&eu(n.prev,n,n.next)>0)}function eu(s,n,r){return(n.y-s.y)*(r.x-n.x)-(n.x-s.x)*(r.y-n.y)}function Que(s,n){return s.x===n.x&&s.y===n.y}function Fvt(s,n,r,c){var u=Kue(eu(s,n,r)),d=Kue(eu(s,n,c)),b=Kue(eu(r,c,s)),w=Kue(eu(r,c,n));return!!(u!==d&&b!==w||u===0&&Zue(s,r,n)||d===0&&Zue(s,c,n)||b===0&&Zue(r,s,c)||w===0&&Zue(r,n,c))}function Zue(s,n,r){return n.x<=Math.max(s.x,r.x)&&n.x>=Math.min(s.x,r.x)&&n.y<=Math.max(s.y,r.y)&&n.y>=Math.min(s.y,r.y)}function Kue(s){return s>0?1:s<0?-1:0}function Csn(s,n){var r=s;do{if(r.i!==s.i&&r.next.i!==s.i&&r.i!==n.i&&r.next.i!==n.i&&Fvt(r,r.next,s,n))return!0;r=r.next}while(r!==s);return!1}function hW(s,n){return eu(s.prev,s,s.next)<0?eu(s,n,s.next)>=0&&eu(s,s.prev,n)>=0:eu(s,n,s.prev)<0||eu(s,s.next,n)<0}function Asn(s,n){var r=s,c=!1,u=(s.x+n.x)/2,d=(s.y+n.y)/2;do r.y>d!=r.next.y>d&&r.next.y!==r.y&&u<(r.next.x-r.x)*(d-r.y)/(r.next.y-r.y)+r.x&&(c=!c),r=r.next;while(r!==s);return c}function Uvt(s,n){var r=new SIe(s.i,s.x,s.y),c=new SIe(n.i,n.x,n.y),u=s.next,d=n.prev;return s.next=n,n.prev=s,r.next=u,u.prev=r,c.next=r,r.prev=c,d.next=c,c.prev=d,c}function Ovt(s,n,r,c){var u=new SIe(s,n,r);return c?(u.next=c.next,u.prev=c,c.next.prev=u,c.next=u):(u.prev=u,u.next=u),u}function dW(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function SIe(s,n,r){this.i=s,this.x=n,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Jue.deviation=function(s,n,r,c){var u=n&&n.length,d=u?n[0]*r:s.length,b=Math.abs(MIe(s,0,d,r));if(u)for(var w=0,_=n.length;w<_;w++){var x=n[w]*r,T=w<_-1?n[w+1]*r:s.length;b-=Math.abs(MIe(s,x,T,r))}var M=0;for(w=0;w0&&(c+=s[u-1].length,r.holes.push(c))}return r}});var r_t=Sd((i_t,PIe)=>{(function(s){if(typeof i_t=="object"&&typeof PIe<"u")PIe.exports=s();else if(typeof define=="function"&&define.amd)define([],s);else{var n;typeof window<"u"?n=window:typeof global<"u"?n=global:typeof self<"u"?n=self:n=this,n.ELK=s()}})(function(){var s,n,r;return function c(u,d,b){function w(T,M){if(!d[T]){if(!u[T]){var L=typeof AD=="function"&&AD;if(!M&&L)return L(T,!0);if(_)return _(T,!0);var I=new Error("Cannot find module '"+T+"'");throw I.code="MODULE_NOT_FOUND",I}var D=d[T]={exports:{}};u[T][0].call(D.exports,function(F){var O=u[T][1][F];return w(O||F)},D,D.exports,c,u,d,b)}return d[T].exports}for(var _=typeof AD=="function"&&AD,x=0;x0&&arguments[0]!==void 0?arguments[0]:{},I=L.defaultLayoutOptions,D=I===void 0?{}:I,F=L.algorithms,O=F===void 0?["layered","stress","mrtree","radial","force","disco"]:F,z=L.workerFactory,Z=L.workerUrl;if(w(this,T),this.defaultLayoutOptions=D,this.initialized=!1,typeof Z>"u"&&typeof z>"u")throw new Error("Cannot construct an ELK without both 'workerUrl' and 'workerFactory'.");var H=z;typeof Z<"u"&&typeof z>"u"&&(H=function(ne){return new Worker(ne)});var te=H(Z);if(typeof te.postMessage!="function")throw new TypeError("Created worker does not provide the required 'postMessage' function.");this.worker=new x(te),this.worker.postMessage({cmd:"register",algorithms:O}).then(function(oe){return M.initialized=!0}).catch(console.err)}return b(T,[{key:"layout",value:function(L){var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},D=I.layoutOptions,F=D===void 0?this.defaultLayoutOptions:D;return L?this.worker.postMessage({cmd:"layout",graph:L,options:F}):Promise.reject(new Error("Missing mandatory parameter 'graph'."))}},{key:"knownLayoutAlgorithms",value:function(){return this.worker.postMessage({cmd:"algorithms"})}},{key:"knownLayoutOptions",value:function(){return this.worker.postMessage({cmd:"options"})}},{key:"knownLayoutCategories",value:function(){return this.worker.postMessage({cmd:"categories"})}},{key:"terminateWorker",value:function(){this.worker.terminate()}}]),T}();d.default=_;var x=function(){function T(M){var L=this;if(w(this,T),M===void 0)throw new Error("Missing mandatory parameter 'worker'.");this.resolvers={},this.worker=M,this.worker.onmessage=function(I){setTimeout(function(){L.receive(L,I)},0)}}return b(T,[{key:"postMessage",value:function(L){var I=this.id||0;this.id=I+1,L.id=I;var D=this;return new Promise(function(F,O){D.resolvers[I]=function(z,Z){z?O(z):F(Z)},D.worker.postMessage(L)})}},{key:"receive",value:function(L,I){var D=I.data,F=L.resolvers[D.id];F&&(delete L.resolvers[D.id],D.error?F(D.error):F(null,D.data))}},{key:"terminate",value:function(){this.worker.terminate&&this.worker.terminate()}}]),T}()},{}],2:[function(c,u,d){(function(b){var w;typeof window<"u"?w=window:typeof b<"u"?w=b:typeof self<"u"&&(w=self);var _,x;function T(){}function M(){}function L(){}function I(){}function D(){}function F(){}function O(){}function z(){}function Z(){}function H(){}function te(){}function oe(){}function ne(){}function ue(){}function Te(){}function Q(){}function ge(){}function Qe(){}function st(){}function at(){}function Ne(){}function tt(){}function ot(){}function Tt(){}function jt(){}function en(){}function mn(){}function cn(){}function bi(){}function Vt(){}function pn(){}function qn(){}function Yi(){}function $i(){}function Tr(){}function wr(){}function Si(){}function Fr(){}function se(){}function de(){}function it(){}function We(){}function En(){}function hr(){}function qi(){}function Me(){}function ve(){}function wt(){}function gn(){}function vn(){}function Mn(){}function xi(){}function mi(){}function ri(){}function Ge(){}function Ae(){}function Le(){}function ht(){}function Ye(){}function ct(){}function Ze(){}function Ke(){}function pt(){}function Xn(){}function _i(){}function Hi(){}function _n(){}function Je(){}function Qn(){}function ei(){}function ar(){}function yn(){}function Re(){}function nt(){}function kt(){}function xn(){}function Ei(){}function Xi(){}function cr(){}function So(){}function Ks(){}function Bi(){}function io(){}function mf(){}function J1(){}function Lm(){}function b2(){}function zb(){}function bk(){}function Pe(){}function xt(){}function Kt(){}function tn(){}function Yt(){}function Zi(){}function Rr(){}function Xr(){}function bs(){}function Vs(){}function xs(){}function Cs(){}function Lc(){}function Gf(){}function pl(){}function bg(){}function hc(){}function Js(){}function w2(){}function dc(){}function km(){}function v2(){}function Iv(){}function _2(){}function gl(){}function Rm(){}function rE(){}function gh(){}function y2(){}function sE(){}function PT(){}function kO(){}function wk(){}function vk(){}function x2(){}function RO(){}function IO(){}function uH(){}function DO(){}function BO(){}function OO(){}function NO(){}function fH(){}function hH(){}function dH(){}function FO(){}function pH(){}function gH(){}function mH(){}function bH(){}function _k(){}function wH(){}function vH(){}function _H(){}function yH(){}function xH(){}function pc(){}function ic(){}function EH(){}function SH(){}function MH(){}function TH(){}function CH(){}function AH(){}function UO(){}function PH(){}function Du(){}function yk(){}function Dv(){}function zO(){}function xk(){}function wp(){}function GO(){}function jO(){}function $O(){}function VO(){}function WO(){}function HO(){}function Cd(){}function LH(){}function Ad(){}function kH(){}function qO(){}function Gb(){}function LT(){}function Ek(){}function kc(){}function jb(){}function Sk(){}function RH(){}function Mk(){}function IH(){}function DH(){}function BH(){}function XO(){}function kT(){}function E2(){}function OH(){}function YO(){}function ZO(){}function Tk(){}function Ck(){}function KO(){}function NH(){}function Ak(){}function Pk(){}function FH(){}function JO(){}function Pd(){}function Lk(){}function oE(){}function QO(){}function eN(){}function UH(){}function zH(){}function GH(){}function jH(){}function $H(){}function S2(){}function VH(){}function WH(){}function kk(){}function tN(){}function $b(){}function RT(){}function HH(){}function qH(){}function XH(){}function M2(){}function wg(){}function nN(){}function YH(){}function ZH(){}function KH(){}function JH(){}function QH(){}function Q1(){}function lt(){}function fn(){}function Jt(){}function rr(){}function Es(){}function ta(){}function Dl(){}function Ha(){}function IT(){}function eq(){}function vp(){}function DT(){}function tq(){}function T2(){}function BT(){}function OT(){}function ya(){}function nq(){}function iN(){}function NT(){}function iq(){}function rq(){}function sq(){}function FT(){}function Vb(){}function UT(){}function rN(){}function zT(){}function sN(){}function oN(){}function GT(){}function aN(){}function aE(){}function Bv(){}function jT(){}function oq(){}function aq(){}function cq(){}function $T(){}function VT(){}function Rk(){}function lq(){}function cN(){}function uq(){}function fq(){}function nu(){}function jf(){}function hq(){}function dq(){}function lN(){}function pq(){}function Ik(){}function cE(){}function Dk(){}function C2(){}function lE(){}function uE(){}function WT(){}function A2(){}function gq(){}function mq(){}function bq(){}function wq(){}function vq(){}function HT(){}function fE(){}function uN(){}function _e(){}function P2(){}function qT(){}function _p(){}function Io(){}function _q(){}function yq(){}function xq(){}function Ov(){}function e0(){}function Wb(){}function fN(){}function Eq(){}function Sq(){}function t0(){}function Mq(){}function Tq(){}function Cq(){}function Aq(){}function Pq(){}function n0(){}function Lq(){}function kq(){}function Rq(){}function Iq(){}function Dq(){}function Nv(){}function Bq(){}function Oq(){}function vg(){}function Nq(){}function Fq(){}function Uq(){}function zq(){}function Pt(){}function hN(){}function dN(){}function Gq(){}function jq(){}function Bk(){}function hE(){}function dE(){}function $q(){}function pN(){}function Vq(){}function Im(){}function Ok(){}function Fv(){}function yp(){}function Wq(){}function gN(){}function mN(){}function pE(){}function Hb(){}function bN(){}function Hq(){}function XT(){}function qq(){}function gE(){}function bf(){}function YT(){}function mE(){}function Dm(){}function ZT(){}function KT(){}function i0(){}function wN(){}function Bu(){}function Nk(){}function Xq(){}function Yq(){}function Zq(){}function L2(){}function Kq(){}function bE(){}function vN(){}function Jq(){}function _N(){}function wE(){}function Fk(){}function yN(){}function Uk(){}function xN(){}function Qq(){}function eX(){}function tX(){}function EN(){}function zk(){}function nX(){}function Gk(){}function SN(){}function MN(){}function TN(){}function JT(){}function iX(){}function CN(){}function qb(){}function jk(){}function AN(){}function rX(){}function $k(){}function PN(){}function Vk(){}function sX(){}function Wk(){}function ro(){}function oX(){}function aX(){}function vE(){}function LN(){}function cX(){}function lX(){}function xp(){}function uX(){}function QT(){}function Hk(){}function kN(){}function RN(){}function Ld(){}function Xb(){}function qk(){}function IN(){}function eC(){}function DN(){}function Xk(){}function BN(){}function Yk(){}function Zk(){}function Yb(){}function fX(){}function Zb(){}function ON(){}function NN(){}function Kk(){}function hX(){}function dX(){}function pX(){}function FN(){}function UN(){}function gX(){}function zN(){}function GN(){}function Xh(){}function Bm(){}function mX(){}function bX(){}function tC(){}function k2(){}function jN(){}function $N(){}function wX(){}function VN(){}function R2(){}function _E(){}function vX(){}function WN(){}function HN(){}function nC(){}function qN(){}function iC(){}function Jk(){}function rC(){}function _X(){}function XN(){}function sC(){}function YN(){}function Qk(){}function yX(){}function ZN(){}function r0(){}function KN(){}function JN(){}function xX(){}function QN(){}function EX(){}function SX(){}function s0(){}function eR(){}function tR(){}function nR(){}function oC(){}function I2(){}function ns(){}function aC(){}function iR(){}function Uv(){}function MX(){}function rR(){}function eF(){}function $f(){}function TX(){}function CX(){}function tF(){}function AX(){}function nF(){}function PX(){}function LX(){}function kX(){}function o0(){}function Vf(){}function sR(){}function RX(){}function IX(e){}function lDe(e){}function oR(){Ur()}function yE(){s7()}function iF(){Dee()}function rF(){qA()}function DX(){G_e()}function BX(){rve()}function OX(){UI()}function NX(){Cf()}function sF(){Twe()}function oF(){RR()}function FX(){lI()}function aR(){LGe()}function aF(){YHe()}function xE(){TBe()}function cR(){Ipe()}function cF(){$e()}function lF(){l7e()}function cC(){Xje()}function uF(){h7e()}function _g(){FHe()}function zv(){d7e()}function UX(){ube()}function fF(){vVe()}function zX(){Ew()}function GX(){p7e()}function jX(){OGe()}function $X(){bZe()}function VX(){CBe()}function WX(){Pve()}function HX(){ww()}function mh(){T8e()}function qX(){l7()}function XX(){ur()}function hF(){I7()}function dF(){CU()}function pF(){twe()}function lR(){bee()}function YX(){p_e()}function ZX(e){this.a=e}function KX(e){this.a=e}function EE(e){this.a=e}function JX(e){this.a=e}function QX(e){this.a=e}function eY(e){this.a=e}function gF(e){this.a=e}function tY(e){this.a=e}function mF(e){this.a=e}function kd(e){this.a=e}function nY(e){this.a=e}function uR(e){this.a=e}function iY(e){this.a=e}function bF(e){this.a=e}function rY(e){this.a=e}function sY(e){this.a=e}function oY(e){this.a=e}function aY(e){this.a=e}function fR(e){this.a=e}function hR(e){this.b=e}function cY(e){this.a=e}function lY(e){this.a=e}function uY(e){this.a=e}function fY(e){this.a=e}function hY(e){this.a=e}function wF(e){this.a=e}function vF(e){this.a=e}function dR(e){this.a=e}function lC(e){this.a=e}function SE(e){this.a=e}function dY(e){this.a=e}function _F(e){this.a=e}function Kb(e){this.a=e}function yF(e){this.a=e}function xF(e){this.a=e}function EF(e){this.a=e}function Ep(e){this.a=e}function Gv(e){this.a=e}function pR(e){this.a=e}function bh(e){this.a=e}function a0(e){this.a=e}function ME(e){this.d=e}function Om(){this.a=[]}function ui(){nl(this)}function bde(e,t){e.i=t}function wde(e,t){e.g=t}function vde(e,t){e.b=t}function _de(e,t){e.b=t}function yde(e,t){e.a=t}function SF(e,t){e.a=t}function xde(e,t){e.c=t}function gR(e,t){e.c=t}function Ede(e,t){e.b=t}function Sde(e,t){e.d=t}function Mde(e,t){e.d=t}function Ou(e,t){e.j=t}function Tde(e,t){e.a=t}function Cde(e,t){e.f=t}function Ade(e,t){e.f=t}function pY(e,t){e.e=t}function MF(e,t){e.k=t}function Pde(e,t){e.a=t}function Lde(e,t){e.b=t}function TF(e,t){e.g=t}function CF(e,t){e.j=t}function kde(e,t){e.n=t}function Rde(e,t){e.a=t}function Ide(e,t){e.a=t}function gY(e,t){e.c=t}function mY(e,t){e.c=t}function Dde(e,t){e.d=t}function Bde(e,t){e.e=t}function Ode(e,t){e.g=t}function Nde(e,t){e.a=t}function mR(e,t){e.c=t}function Fde(e,t){e.d=t}function Ude(e,t){e.e=t}function zde(e,t){e.f=t}function Gde(e,t){e.j=t}function jde(e,t){e.a=t}function $de(e,t){e.a=t}function Vde(e,t){e.b=t}function bY(e){e.b=e.a}function wY(e){e.c=e.d.d}function vY(e){ti(Hn(e))}function AF(e){this.b=e}function jv(e){this.a=e}function uC(e){this.a=e}function fC(e){this.a=e}function Jb(e){this.b=e}function Nm(e){this.b=e}function PF(e){this.a=e}function LF(e){this.a=e}function gr(e){this.a=e}function kF(e){this.a=e}function RF(e){this.a=e}function _Y(e){this.a=e}function IF(e){this.a=e}function D2(e){this.a=e}function hC(e){this.a=e}function yY(e){this.a=e}function xY(e){this.a=e}function bR(e){this.a=e}function DF(e){this.a=e}function EY(e){this.a=e}function SY(e){this.a=e}function MY(e){this.a=e}function TY(e){this.a=e}function CY(e){this.a=e}function AY(e){this.a=e}function PY(e){this.a=e}function LY(e){this.a=e}function kY(e){this.a=e}function RY(e){this.a=e}function IY(e){this.a=e}function $v(e){this.a=e}function yg(e){this.a=e}function DY(e){this.a=e}function BY(e){this.a=e}function Vv(e){this.a=e}function Rs(e){this.a=e}function BF(e){this.a=e}function wf(e){this.a=e}function j(e){this.c=e}function dC(e){this.e=e}function Rd(e){this.a=e}function OY(e){this.a=e}function Wv(e){this.a=e}function OF(e){this.a=e}function NY(e){this.a=e}function FY(e){this.a=e}function wR(e){this.a=e}function UY(e){this.a=e}function c0(e){this.a=e}function NF(e){this.a=e}function pC(e){this.a=e}function Uc(e){this.a=e}function Qc(e){this.a=e}function FF(e){this.a=e}function vR(e){this.a=e}function zY(e){this.a=e}function GY(e){this.a=e}function jY(e){this.a=e}function $Y(e){this.a=e}function VY(e){this.a=e}function UF(e){this.a=e}function TE(e){this.a=e}function Qb(e){this.a=e}function WY(e){this.a=e}function zF(e){this.a=e}function gC(e){this.a=e}function Id(e){this.a=e}function B2(e){this.a=e}function HY(e){this.a=e}function qY(e){this.a=e}function XY(e){this.a=e}function YY(e){this.a=e}function ZY(e){this.a=e}function GF(e){this.a=e}function l0(e){this.a=e}function Ws(e){this.a=e}function jF(e){this.a=e}function Sp(e){this.a=e}function $F(e){this.a=e}function KY(e){this.b=e}function xa(e){this.a=e}function JY(e){this.a=e}function VF(e){this.a=e}function WF(e){this.c=e}function _R(e){this.a=e}function QY(e){this.a=e}function eZ(e){this.a=e}function tZ(e){this.a=e}function nZ(e){this.a=e}function iZ(e){this.a=e}function rZ(e){this.a=e}function sZ(e){this.a=e}function oZ(e){this.a=e}function aZ(e){this.a=e}function cZ(e){this.a=e}function lZ(e){this.a=e}function uZ(e){this.a=e}function yR(e){this.a=e}function fZ(e){this.a=e}function xR(e){this.a=e}function hZ(e){this.a=e}function dZ(e){this.a=e}function pZ(e){this.a=e}function Nu(e){this.a=e}function Yh(e){this.a=e}function Dd(e){this.a=e}function ew(e){this.a=e}function gZ(e){this.a=e}function HF(e){this.a=e}function mZ(e){this.a=e}function bZ(e){this.a=e}function mC(e){this.a=e}function qF(e){this.f=e}function wZ(e){this.i=e}function ER(e){this.a=e}function vZ(e){this.a=e}function XF(e){this.a=e}function YF(e){this.a=e}function _Z(e){this.a=e}function yZ(e){this.a=e}function xZ(e){this.a=e}function EZ(e){this.a=e}function O2(e){this.a=e}function SZ(e){this.a=e}function MZ(e){this.a=e}function TZ(e){this.a=e}function CZ(e){this.a=e}function AZ(e){this.a=e}function ZF(e){this.a=e}function KF(e){this.a=e}function PZ(e){this.a=e}function LZ(e){this.a=e}function kZ(e){this.a=e}function RZ(e){this.a=e}function IZ(e){this.a=e}function DZ(e){this.a=e}function BZ(e){this.a=e}function OZ(e){this.a=e}function NZ(e){this.a=e}function FZ(e){this.a=e}function UZ(e){this.a=e}function zZ(e){this.a=e}function GZ(e){this.a=e}function jZ(e){this.a=e}function $Z(e){this.a=e}function JF(e){this.a=e}function Sr(e){this.b=e}function VZ(e){this.a=e}function WZ(e){this.a=e}function HZ(e){this.a=e}function qZ(e){this.a=e}function XZ(e){this.a=e}function YZ(e){this.a=e}function ZZ(e){this.a=e}function KZ(e){this.b=e}function SR(e){this.a=e}function N2(e){this.a=e}function QF(e){this.a=e}function bC(e){this.a=e}function wC(e){this.a=e}function MR(e){this.a=e}function TR(e){this.a=e}function JZ(e){this.d=e}function e8(e){this.c=e}function vC(e){this.e=e}function Rc(e){this.e=e}function _C(e){this.a=e}function t8(e){this.a=e}function CE(){this.a=0}function AE(){XNe(this)}function ke(){rJ(this)}function PE(){dUe(this)}function Wde(){_pe(),y$t()}function n8(){return null}function Hde(){return null}function qde(e){return e.a}function Xde(e){return e.a}function Yde(e){return e.a}function QZ(e){return e.a}function Zde(e){return e.a}function Y(e){return e.e}function xg(){this.c=zAe}function CR(){this.a=this}function yC(e){this.a=lIt(e)}function i8(){Mp.call(this)}function LE(){Mp.call(this)}function qa(){Mp.call(this)}function r8(){Mp.call(this)}function AR(){Mp.call(this)}function s8(){RFe.call(this)}function Mp(){RFe.call(this)}function F2(){Mp.call(this)}function Pi(){Mp.call(this)}function o8(){r8.call(this)}function Kde(e){e.b.Te(e.e)}function eK(e,t){t.jd(e.a)}function U2(e,t){e.a=t-e.a}function z2(e,t){e.b=t-e.b}function tK(e,t){e.b+=t}function Jde(e,t){e.d.b.$b(t)}function kE(e,t){e.e=t,t.b=e}function nK(e,t){e.length=t}function a8(e){e.a=new Ir}function c8(){c8=M,new ui}function iK(){this.b=new $pe}function S(){this.Bb|=256}function P(){Mp.call(this)}function U(){Mp.call(this)}function K(){Mp.call(this)}function pe(){Mp.call(this)}function xe(e){g7(e.c,e.b)}function je(e,t){cve(e.c,t)}function rt(e,t){n7(e.a,t)}function gt(e,t){Yee(e.a,t)}function wn(e,t){De(e.a,t)}function Sn(e,t){Cr(e.b,t)}function Dn(e,t){Li(e.e,t)}function Vi(e){oS(),Zre.Rd(e)}function vr(){vr=M,r3e=new F}function Ur(){Ur=M,Wre=new I}function Qs(){Qs=M,i3e=new L}function Wr(){Wr=M,Hre=new rBe}function so(){so=M,qre=new sBe}function jo(){jo=M,Pnt=new Q}function Wf(){Wf=M,jP=new ge}function wh(){wh=M,Bnt=new at}function zr(){this.a=new ui}function ml(){this.a=new D7e}function Zh(){this.a=new ke}function u0(){this.a=new ke}function l8(){this.a=new ke}function uDe(){this.a=new ke}function fDe(){this.a=new ke}function hDe(){this.a=new zr}function Qde(){this.a=new iOe}function epe(){this.a=new x7e}function tpe(){this.a=new u8e}function npe(){this.a=new Ks}function iu(){this.a=new vp}function rK(){this.a=new ke}function ipe(){this.a=new ke}function dDe(){this.b=new ke}function rpe(){this.f=new ke}function pDe(){this.d=new ke}function gDe(){this.a=new ke}function Fm(){this.a=new oGe}function spe(){this.a=new _e}function mDe(){this.j=new ke}function zc(){Ir.call(this)}function bDe(){ke.call(this)}function sK(){Zh.call(this)}function ope(){G2.call(this)}function G2(){bg.call(this)}function j2(){bg.call(this)}function ape(){j2.call(this)}function wDe(){ui.call(this)}function vDe(){ui.call(this)}function _De(){ui.call(this)}function yDe(){qUe.call(this)}function xDe(){qUe.call(this)}function EDe(){a9.call(this)}function SDe(){zDe.call(this)}function MDe(){zDe.call(this)}function cpe(){bf.call(this)}function lpe(){bf.call(this)}function oK(){Dge.call(this)}function aK(){Dge.call(this)}function cK(){Qje.call(this)}function upe(){Bu.call(this)}function TDe(){Bu.call(this)}function CDe(){upe.call(this)}function ADe(){S.call(this)}function PDe(){zr.call(this)}function fpe(){ui.call(this)}function lK(){ui.call(this)}function LDe(){ui.call(this)}function kDe(){Vf.call(this)}function eEt(e){ZBe.call(this,e)}function hpe(e){ZBe.call(this,e)}function tEt(e){hpe.call(this,e)}function RDe(e){w$e.call(this,e)}function IDe(e){w$e.call(this,e)}function DDe(e){vme.call(this,e)}function dpe(e){EK.call(this,e)}function ppe(e){r7e.call(this,e)}function Hv(e){UE.call(this,e)}function na(e){$9e.call(this,e)}function BDe(e){na.call(this,e)}function u8(e){na.call(this,e)}function Ra(e){na.call(this,e)}function ODe(e){na.call(this,e)}function uK(e){$9e.call(this,e)}function gpe(e){Ra.call(this,e)}function xC(e){na.call(this,e)}function un(e){na.call(this,e)}function ba(e){na.call(this,e)}function NDe(e){na.call(this,e)}function EC(e){na.call(this,e)}function vh(e){un.call(this,e)}function SC(){lC.call(this,{})}function Tp(){SE.call(this,"")}function MC(){SE.call(this,"")}function f0(){SE.call(this,"")}function tw(){SE.call(this,"")}function FDe(e){Ra.call(this,e)}function Cp(e){na.call(this,e)}function mpe(e){KKe(),e$t(this,e)}function fK(e){HE(),this.a=e}function PR(e){e.b=null,e.c=0}function nEt(e,t){e.a=t,YNt(e)}function iEt(e,t){return e*e/t}function RE(e){return e<0?-e:e}function hK(e){A$e(),this.a=e}function dK(e){$J(),this.f=e}function pK(e){$J(),this.f=e}function gK(e,t,i){e.a[t.g]=i}function rEt(e,t,i){ABt(i,e,t)}function sEt(e,t,i){VGt(i,e,t)}function oEt(e,t,i){V5t(e,i,t)}function UDe(){this.d=new ke}function zDe(){this.a=new Kq}function GDe(){throw Y(new Pi)}function bpe(){throw Y(new Pi)}function aEt(){throw Y(new Pi)}function cEt(){throw Y(new Pi)}function lEt(){throw Y(new Pi)}function jDe(){throw Y(new Pi)}function LR(e){this.c=ti(Hn(e))}function uEt(e){return new dR(e)}function fEt(e){return new rx(e)}function q(e,t){return a7e(e,t)}function hEt(e,t){return e.a-t.a}function dEt(e,t){return e.a-t.a}function pEt(e,t){return e.a-t.a}function $De(e,t){return e.g-t.g}function vf(e,t){return e>t?e:t}function h0(e,t){return e0}function _K(e,t){return Ma(e,t)<0}function OE(e){return e.d.c+e.e.c}function fo(){this.a=0,this.b=0}function p8(e){h9.call(this,e)}function Eg(e){w_.call(this,e)}function _Be(e){pQ.call(this,e)}function yBe(e){pQ.call(this,e)}function g8(e){lVe.call(this,e,0)}function xBe(e){this.c=(dn(e),e)}function m8(e){this.a=new g8(e)}function iw(e){this.a=new WJ(e)}function DEt(){throw Y(new K)}function BEt(){throw Y(new K)}function NE(){NE=M,k3e=new xNe}function Yv(){Yv=M,uy=new ot}function EBe(){EBe=M,Znt=new gn}function b8(){b8=M,ase=new zFe}function Lpe(){Lpe=M,zit=new Lm}function SBe(){SBe=M,Git=new Pe}function kpe(){kpe=M,jit=new R9e}function Rpe(){Rpe=M,CEe=new Zi}function MBe(){MBe=M,Zit=new Gf}function PC(){PC=M,srt=new QH}function TBe(){TBe=M,rrt=new zO}function Ipe(){Ipe=M,bSe=new RH}function RR(){RR=M,Qit=new fo}function CBe(){CBe=M,Gat=new ss}function ABe(){this.b=new tne(ITe)}function PBe(){this.a=new tne(qTe)}function LBe(){this.a=(qs(),Oh)}function kBe(){this.a=(qs(),Oh)}function w8(e){this.a=0,this.b=e}function v8(e){return e.b!=e.d.c}function RBe(e,t){return e.d[t.o]}function IBe(e,t){for(;e.sd(t););}function Dpe(e,t,i){e.splice(t,i)}function OEt(e,t,i){Ko(e.d,t.f,i)}function NEt(e,t){qte(ye(e.a),t)}function FEt(e,t){qte(ye(e.a),t)}function DBe(e){e.c?rZe(e):sZe(e)}function BBe(){BBe=M,klt=new vN}function OBe(){OBe=M,Wlt=new vDe}function NBe(){NBe=M,Hlt=new _De}function Sg(){Sg=M,ku=new fpe}function Bpe(){Bpe=M,FAe=new LDe}function _8(){_8=M,Dj=new ui}function Ope(){Ope=M,YAe=new ke}function Mg(){Mg=M,mm=new RX}function LC(){LC=M,Dae=new oFe}function Pp(){Pp=M,_D=new aFe}function yK(){yK=M,rut=new Bm}function Yo(){Yo=M,out=new mX}function IR(e){this.a=new nOe(e)}function FBe(e){this.a=h(Hn(e),13)}function UBe(e,t){this.b=e,this.c=t}function zBe(e,t){this.b=e,this.a=t}function Npe(e,t){this.b=e,this.d=t}function FE(e,t){this.e=e,this.d=t}function Fpe(e,t){this.b=e,this.c=t}function GBe(e,t){this.a=e,this.b=t}function jBe(e,t){this.a=e,this.b=t}function $Be(e,t){this.a=e,this.b=t}function VBe(e,t){this.a=e,this.b=t}function WBe(e,t){this.b=e,this.a=t}function X2(e,t){XE.call(this,e,t)}function Zv(e,t){X2.call(this,e,t)}function HBe(e,t){this.b=e,this.a=t}function qBe(e,t){this.a=e,this.b=t}function DR(e,t){this.g=e,this.i=t}function XBe(e,t){this.b=e,this.a=t}function xK(e,t){this.a=e,this.b=t}function YBe(e,t){this.a=e,this.f=t}function ZBe(e){cJ(e.Wb()),this.c=e}function KBe(e,t){this.b=e,this.c=t}function Oi(e,t){this.f=e,this.g=t}function JBe(e,t){Oi.call(this,e,t)}function QBe(e,t){this.e=e,this.c=t}function EK(e){this.b=h(Hn(e),43)}function eOe(e){this.a=h(Hn(e),15)}function UE(e){this.a=h(Hn(e),15)}function Upe(e,t){this.a=e,this.b=t}function UEt(e,t){return e>t&&t0?e:t}function DNe(e){return Xa(e.l,e.m,e.h)}function eJ(e){return e<10?"0"+e:""+e}function _St(e){return e==Q0||e==Nw}function ySt(e){return e==Q0||e==Ow}function ju(e){return Qo(e.b.b,e,0)}function BNe(e){this.a=VOe(),this.b=e}function ONe(e){this.a=VOe(),this.b=e}function ex(e){this.a=e,oR.call(this)}function NNe(e){this.a=e,oR.call(this)}function vge(e,t){DI(e,0,e.length,t)}function FNe(e,t){return De(e.a,t),t}function xSt(e,t){return De(e.c,t),e}function UNe(e,t){return oc(e.a,t),e}function ESt(e,t){return Vu(),t.a+=e}function SSt(e,t){return Vu(),t.c+=e}function MSt(e,t){return Vu(),t.a+=e}function zNe(e){return e==_y||e==vy}function n_(e){return e==rf||e==sf}function YR(e){return e==hm||e==rp}function Bd(e){return e!=sp&&e!=fb}function $u(e){return e.eg()&&e.fg()}function V8(e){return oc(new ss,e)}function GNe(){GNe=M,Roe=new GA(mae)}function Gc(){IF.call(this,new C0)}function jNe(){F9.call(this,0,0,0,0)}function VE(){Zf.call(this,0,0,0,0)}function _ge(e){pNe.call(this,e,!0)}function Do(e){this.a=e.a,this.b=e.b}function Od(e,t,i){Yu(e,t),Zu(e,i)}function W8(e,t,i){x_(e,t),y_(e,i)}function yge(e,t,i){see(e,t),oee(e,i)}function tJ(e,t,i){CA(e,t),TA(e,i)}function nJ(e,t,i){AA(e,t),PA(e,i)}function iJ(e,t){Uee(e,t),aee(e,e.D)}function $Ne(e,t){return new wS(t,e)}function TSt(e,t){return new wS(t,e)}function kp(e,t){return et?1:0}function qC(e){return a1e(e.b.tc(),e.a)}function Kh(e){return rA(e.a.tc(),e.b)}function VNe(e){return hu(e,0,e.length)}function H8(e){return e!=null?Hr(e):0}function Nd(e){r7e.call(this,new ppe(e))}function WNe(){M8.call(this,"Head",1)}function HNe(){M8.call(this,"Tail",3)}function xge(e,t,i){xJ.call(this,e,t,i)}function CSt(e,t,i){SF(e,t.le(e.a,i))}function qNe(e,t){return parseInt(e,t)}function ASt(e,t){return SA(t,Sh(e))}function PSt(e,t){return SA(t,Sh(e))}function tx(e){F9.call(this,e,e,e,e)}function rJ(e){e.c=le(on,et,1,0,5,1)}function XNe(e){e.a=le(on,et,1,8,5,1)}function Ege(e){return e.b&&vne(e),e.a}function Sge(e){return e.b&&vne(e),e.c}function sJ(e){return e.d&&Gte(e),e.c}function oJ(e){return e.d&&Gte(e),e.b}function Mge(e){return e.d&&Gte(e),e.a}function Tge(e,t,i){return Gr(e,t,i),i}function YNe(e,t,i){Gr(e.c[t.g],t.g,i)}function LSt(e,t,i){return dr(e.g,i,t)}function kSt(e,t,i){return dr(e.k,i,t)}function RSt(e,t,i){Od(i,i.i+e,i.j+t)}function wa(e,t){Zr.call(this,e.b,t)}function XC(e){vi(),Rc.call(this,e)}function Ol(){Ol=M,gm=(BBe(),klt)}function zn(){zn=M,new ZNe,new ke}function ZNe(){new ui,new ui,new ui}function Mo(){Mo=M,Tnt=new te,n3e=new oe}function i_(){i_=M,d5=new fOe,p5=new LNe}function ru(){ru=M,Qxe=cMt(new LR(Ca))}function Yr(){Yr=M,new vY((ru(),"="))}function q8(e){e.j=le(b3e,be,287,0,0,1)}function KNe(e){this.a=e,Rme.call(this,e)}function ISt(e){return e==null?0:Hr(e)}function YC(e){return e==null?Xc:Ga(e)}function po(e,t){return e.charCodeAt(t)}function WE(e,t,i){return Pge(e,wc(t),i)}function Xa(e,t,i){return{l:e,m:t,h:i}}function Zo(e){return e.at-1?0:t-1}function QSt(e,t,i){return i?t!=0:t!=e-1}function fJ(e,t,i){return e.a[t.g][i.g]}function eMt(e,t){return e.e[t.c.o][t.o]}function tMt(e,t){return e.a[t.c.o][t.o]}function qf(e,t){return e.a[t.c.o][t.o]}function nMt(e,t){return e.j[t.o]=R8t(t)}function iMt(e,t){return to(e.c.d,t.c.d)}function rMt(e,t){return to(e.c.c,t.c.c)}function sMt(e,t,i){yjt(e.a,e.b,e.c,t,i)}function oMt(e,t,i,a){Gr(e.a[t.g],i.g,a)}function JC(e,t,i){return Gr(e.g,t,i),i}function au(e,t){return e.a*=t,e.b*=t,e}function aMt(e,t){e.q.setHours(t),fP(e,t)}function vs(e,t,i){uI.call(this,e,t,i)}function Z8(e,t,i){vs.call(this,e,t,i)}function Nl(e,t,i){vs.call(this,e,t,i)}function gFe(e,t,i){Z8.call(this,e,t,i)}function Rge(e,t,i){b9.call(this,e,t,i)}function mFe(e,t,i){b9.call(this,e,t,i)}function bFe(e,t,i){Rge.call(this,e,t,i)}function wFe(e,t,i){Ige.call(this,e,t,i)}function Ige(e,t,i){uI.call(this,e,t,i)}function qE(e,t,i){uI.call(this,e,t,i)}function XE(e,t){this.a=e,MK.call(this,t)}function Bn(e){this.i=e,this.f=this.i.j}function Cg(e){this.c=e,this.a=this.c.a}function Dge(){this.Bb|=256,this.Bb|=512}function vFe(e,t){this.a=e,EK.call(this,t)}function _Fe(e,t){this.a=t,EK.call(this,e)}function Bge(e){this.b=e,this.a=this.b.a.e}function yFe(e){e.b.jc(),--e.d.f.d,k9(e.d)}function xFe(e){e.a=h(sn(e.b.a,4),116)}function EFe(e){e.a=h(sn(e.b.a,4),116)}function SFe(e){uR.call(this,h(Hn(e),34))}function MFe(e){uR.call(this,h(Hn(e),34))}function cMt(e){return Hn(Xc),new e9e(e,e)}function TFe(e,t){return new iXe(e.a,e.b,t)}function Xf(e,t,i){return e.substr(t,i-t)}function lMt(e){return e==null?null:e.name}function uMt(e){return e.l+e.m*Nx+e.h*l1}function aw(e){return typeof e=="number"}function $o(e){return typeof e=="number"}function Rp(e,t){return!!t&&e.b[t.g]==t}function Oge(e,t){var i;i=e[Z_],t[Z_]=i}function K8(e){Jb.call(this,e),this.a=e}function Nge(e){Nm.call(this,e),this.a=e}function KR(e){qv.call(this,e),this.a=e}function Fge(e){IF.call(this,new E0e(e))}function CFe(e){if(!e)throw Y(new P)}function Rn(e){if(!e)throw Y(new K)}function Fd(e){e.o==null&&l8t(e)}function hJ(e){return Rn(e.a!=null),e.a}function AFe(e,t){return De(t.a,e.a),e.a}function PFe(e,t){return De(t.b,e.a),e.a}function fMt(e,t){t&&(e.a=(f_(t),t.a))}function Uge(e,t){return fA(e.a,t)!=null}function rc(e,t){return h(er(e.a,t),15)}function dJ(e){return e.b=h(_Ue(e.a),38)}function g0(e){return e.$H||(e.$H=++hVt)}function pJ(e){return Zo(e.a)||Zo(e.b)}function cw(e,t){return!!e.p&&w0(e.p,t)}function hMt(e,t){return e.k.b=(dn(t),t)}function dMt(e,t){return e.k.b=(dn(t),t)}function J8(e,t){return++e.b,De(e.a,t)}function zge(e,t){return++e.b,Sa(e.a,t)}function pMt(e,t,i){return uze(e,t,i,e.b)}function Gge(e,t,i){return uze(e,t,i,e.c)}function jge(e,t){uwe.call(this,e,t,null)}function LFe(e,t){this.a=t,EK.call(this,e)}function JR(e){this.a=e,AF.call(this,e)}function kFe(){PC(),this.b=new B2(this)}function gJ(e,t){$J(),this.f=t,this.d=e}function RFe(){q8(this),z9(this),this.Pd()}function QC(e){this.d=e,Bn.call(this,e)}function nx(e){this.c=e,Bn.call(this,e)}function QR(e){this.c=e,QC.call(this,e)}function gMt(e,t,i){Yee(e.a,i),n7(e.a,t)}function $ge(e,t,i){h(II(e,t),19).nc(i)}function m0(e,t){return De(t.a,e.a),e.a}function Qh(e){var t;t=e.a,e.a=e.b,e.b=t}function eI(e,t){LC(),this.a=e,this.b=t}function Q8(e,t){Pp(),this.b=e,this.c=t}function IFe(e,t,i,a){t1e.call(this,e,t,i,a)}function e9(e,t,i){var a;a=e.fd(t),a.Bc(i)}function DFe(e,t,i){try{e[t]=i}catch{}}function t9(){t9=M,Tj=new Zr(PQe,0)}function eA(){eA=M,wL=new Sr("root")}function tA(){tA=M,vD=new MDe,new SDe}function mMt(e){return++Er,new pw(3,e)}function ed(e){return Sf(e,Dx),new Gl(e)}function Vge(e){return Mo(),Hn(e),new R8e(e)}function bMt(e){return i_(),Fi((A7e(),Ant),e)}function BFe(e){return oS(),parseInt(e)||-1}function wMt(e,t){return vt(),e==t?0:e?1:-1}function vMt(e){return e==null?null:Ga(e)}function _Mt(e){return e==null?null:Ga(e)}function tI(e){return e.f!=null?e.f:""+e.g}function mJ(e){return g1e(e.c,e.c.length)}function OFe(e){e.b=new UFe(e),e.c=new ui}function Wge(e){this.q=new w.Date(cS(e))}function NFe(e){this.c=e,this.a=1,this.b=1}function Hge(e){NE(),this.b=e,this.a=!0}function FFe(){this.a=new Kv,this.b=new Kv}function UFe(e){Bme.call(this,e,null,null)}function zFe(){Oi.call(this,"POLYOMINO",0)}function nI(e){re(e,142)&&h(e,142).Xg()}function bJ(e){return Rn(e.b!=0),e.a.a.c}function n9(e){return Rn(e.b!=0),e.c.b.c}function Fl(e,t,i){return e.a+=t,e.b+=i,e}function yMt(e,t,i){return e.a*=t,e.b*=i,e}function iI(e,t,i){return e.a-=t,e.b-=i,e}function GFe(e,t,i){return e.a+=hu(t,0,i),e}function wJ(e){return e.a=-e.a,e.b=-e.b,e}function vJ(e){return RE(e.d.e-e.e.e)-e.a}function xMt(e,t){return e.c.nc(h(t,134))}function EMt(e,t,i){return De(t,bWe(e,i))}function SMt(e,t){return e>0?t*t/e:t*t*100}function MMt(e,t){return e>0?t/(e*e):t*100}function TMt(e,t,i){JI(Ea(e.a),t,T7e(i))}function CMt(e,t,i){JI(Vc(e.a),t,C7e(i))}function wl(e,t,i){il.call(this,e,t,i,2)}function jFe(e,t){LC(),eI.call(this,e,t)}function qge(e,t){Pp(),Q8.call(this,e,t)}function $Fe(e,t){Pp(),Q8.call(this,e,t)}function VFe(e,t){Pp(),qge.call(this,e,t)}function _J(e,t){Ol(),M9.call(this,e,t)}function Xge(e,t){Ol(),M9.call(this,e,t)}function WFe(e,t){Ol(),_J.call(this,e,t)}function Yge(e,t){Ol(),_J.call(this,e,t)}function HFe(e,t){Ol(),Yge.call(this,e,t)}function qFe(e,t){Ol(),Xge.call(this,e,t)}function XFe(e,t){Ol(),M9.call(this,e,t)}function AMt(e,t,i){return t.ak(e.e,e.c,i)}function PMt(e,t,i){return t.bk(e.e,e.c,i)}function Zge(e,t,i){return B7(OI(e,t),i)}function yJ(e,t){return jg(e.e,h(t,42))}function LMt(e){return e==null?null:Djt(e)}function kMt(e){return e==null?null:uNt(e)}function YFe(e){this.c=e,Yu(e,0),Zu(e,0)}function YE(e,t){this.c=e,FE.call(this,e,t)}function nA(e,t){this.a=e,YE.call(this,e,t)}function Kge(e){this.a=e,this.b=eUe(this.a.d)}function RMt(e,t){this.d=e,wY(this),this.b=t}function Jge(){Qje.call(this),this.Bb|=oo}function i9(){OIt.call(this,new C0,new ui)}function xJ(e,t,i){TI.call(this,e,t,i,null)}function Qge(e,t,i){TI.call(this,e,t,i,null)}function td(e,t){e.a.bd(e.b,t),++e.b,e.c=-1}function eme(e,t){var i;return i=e.e,e.e=t,i}function mt(e){return KC(e==null||ow(e)),e}function Xe(e){return KC(e==null||aw(e)),e}function ti(e){return KC(e==null||ws(e)),e}function IMt(e,t){return Hn(e),Hn(t),LA(e,t)}function ZFe(e){return e>8?0:e+1}function KFe(e){nl(e.c),e.b.b=e.b,e.b.a=e.b}function JFe(e,t){BGe.call(this,e),this.a=t}function oi(e,t){BGe.call(this,e),this.a=t}function DMt(e){nwe.call(this,0,0),this.f=e}function EJ(e){var t;t=e[Z_]|0,e[Z_]=t+1}function BMt(e,t,i){return e.Ld(t,i)<=0?i:t}function OMt(e,t){return h(gx(e.b,t),180)}function NMt(e,t){return h(gx(e.c,t),199)}function SJ(e){return h(St(e.a,e.b),269)}function QFe(e){return new $t(e.c,e.d+e.a)}function tme(e){return zg(MAt($o(e)?fu(e):e))}function e8e(e){return vl(),zNe(h(e,179))}function Gm(){Gm=M,xAe=Ht((Hl(),C1))}function r9(){r9=M,w.Math.pow(2,-65)}function rI(e,t,i){++e.j,e.Yh(),GQ(e,t,i)}function t8e(e,t,i){++e.j,e.Vh(t,e.Ch(t,i))}function nme(e,t,i){return i=Ml(e,t,3,i),i}function ime(e,t,i){return i=Ml(e,t,6,i),i}function rme(e,t,i){return i=Ml(e,t,9,i),i}function Ud(e,t){return tQ(t,fxe),e.f=t,e}function sme(e,t){return(t&zi)%e.d.length}function FMt(e,t){return RR(),TS(t.d.g,e)}function n8e(e,t){return dr(e.a,t,"")==null}function i8e(e,t,i){return E_e(e.c,e.b,t,i)}function UMt(e,t,i){var a;a=e.fd(t),a.Bc(i)}function r8e(e,t){this.a=e,KZ.call(this,t)}function sI(e,t){this.a=e,KZ.call(this,t)}function s8e(e,t){this.c=e,w_.call(this,t)}function o8e(e){this.b=e,this.a=this.b.b.Tb()}function ome(e,t){e8.call(this,e),this.a=t}function MJ(e,t){e8.call(this,e),this.a=t}function Zr(e,t){Sr.call(this,e),this.a=t}function o_(e,t){Ra.call(this,RP+e+_z+t)}function s9(){eEt.call(this,new ui),this.a=3}function oI(e){return!e.a&&(e.a=new st),e.a}function o9(e){e.b?o9(e.b):e.f.c.Zb(e.e,e.d)}function a8e(e){this.a=(_t(),new fC(Hn(e)))}function Ag(e,t){if(!e)throw Y(new ba(t))}function ame(e,t){if(!e)throw Y(new un(t))}function cme(e,t,i){return e.lastIndexOf(t,i)}function zMt(e,t,i){return e.apply(t,i);var a}function TJ(e,t,i){return ix(e,h(t,23),i)}function GMt(e,t){return vK($We(e.a,t,!0))}function jMt(e,t){return vK(VWe(e.a,t,!0))}function c8e(e){return new xBe((f_(e),e.a))}function CJ(e){return String.fromCharCode(e)}function $Mt(e){return e==null?null:e.message}function VMt(e,t){e.e=t,t!=null&&DFe(t,jne,e)}function WMt(e,t,i){return to(e[t.b],e[i.b])}function lme(e,t,i,a){F9.call(this,e,t,i,a)}function aI(e){JRt.call(this,e,(uU(),nse))}function HMt(e,t){return e.k.a=(dn(t),t+10)}function qMt(e,t){return e.k.a=(dn(t),t+10)}function XMt(e,t){return RR(),!TS(t.d.g,e)}function l8e(){l8e=M,h3e=le(Po,be,21,256,0,1)}function vt(){vt=M,Z0=(vt(),!1),oM=!0}function u8e(){this.b=new fo,this.c=new ke}function ume(){this.d=new fo,this.e=new fo}function fme(){this.k=new fo,this.n=new fo}function f8e(){this.b=new ABe,this.a=new hq}function h8e(){this.b=new ui,this.a=new ui}function d8e(){this.b=new zr,this.a=new zr}function p8e(){this.a=new ke,this.d=new ke}function g8e(){this.a=new ke,this.b=new ke}function m8e(){this.a=new Ks,this.b=new iK}function b8e(){this.a=new l8,this.c=new Cs}function a9(){this.n=new j2,this.i=new VE}function w8e(){a9.call(this),this.a=new fo}function hme(e,t,i){return i=Ml(e,t,11,i),i}function tr(e,t){return e.a+=t.a,e.b+=t.b,e}function Bc(e,t){return e.a-=t.a,e.b-=t.b,e}function YMt(e,t){var i;return i=t.Yg(e.a),i}function dme(e,t){return h(e.b.cd(t),190).a}function ZMt(e,t){return t==e||QA(E7(t),e)}function KMt(e){return e<100?null:new Eg(e)}function JMt(e,t,i){i!=null&&Q0e(t,yte(e,i))}function QMt(e,t,i){i!=null&&ebe(t,yte(e,i))}function ZE(e,t,i,a){ze.call(this,e,t,i,a)}function pme(e,t,i,a){ze.call(this,e,t,i,a)}function v8e(e,t,i,a){pme.call(this,e,t,i,a)}function _8e(e,t,i,a){D9.call(this,e,t,i,a)}function AJ(e,t,i,a){D9.call(this,e,t,i,a)}function gme(e,t,i,a){D9.call(this,e,t,i,a)}function y8e(e,t,i,a){AJ.call(this,e,t,i,a)}function mme(e,t,i,a){AJ.call(this,e,t,i,a)}function an(e,t,i,a){gme.call(this,e,t,i,a)}function x8e(e,t,i,a){mme.call(this,e,t,i,a)}function E8e(e,t,i,a){o1e.call(this,e,t,i,a)}function S8e(e,t,i){this.a=e,Npe.call(this,t,i)}function eTt(e,t,i){return e.d=h(t.Kb(i),206)}function M8e(e,t){return e.Pi().dh().Zg(e,t)}function bme(e,t){return e.Pi().dh()._g(e,t)}function PJ(e,t){return Mo(),xIt(e.tc(),t)!=-1}function tTt(e,t){return Yr(),new LFe(e.tc(),t)}function c9(e){return Mo(),e.hc()?e.ic():null}function wme(e){return aw(e)?(dn(e),e):e.$d()}function l9(e){return!isNaN(e)&&!isFinite(e)}function vme(e){lw(),this.b=(_t(),new qv(e))}function lw(){lw=M,new iY((_t(),_t(),uo))}function T8e(){T8e=M,Qlt=le(on,et,1,0,5,1)}function _me(){_me=M,eut=le(on,et,1,0,5,1)}function C8e(){C8e=M,Nlt=le(on,et,1,0,5,1)}function A8e(){A8e=M,u3e=le(qx,be,192,256,0,1)}function P8e(){P8e=M,d3e=le(K0,be,149,256,0,1)}function L8e(){L8e=M,m3e=le(J0,be,168,256,0,1)}function k8e(){k8e=M,f3e=le($P,be,159,128,0,1)}function R8e(e){this.b=e,this.a=(Mo(),Mo(),n3e)}function I8e(e){this.b=e,j8.call(this,V7,0)}function D8e(e){this.c=e,j8.call(this,V7,0)}function B8e(e){return e.c?Qo(e.c.a,e,0):-1}function LJ(e,t){return vK(VWe(e.a,t,!1))}function kJ(e,t){return vK($We(e.a,t,!1))}function a_(e,t){return e.b.sd(new Hpe(e,t))}function O8e(e,t){return e.b.sd(new bOe(e,t))}function u9(e,t){if(!e)throw Y(new un(t))}function yme(e,t){if(!e)throw Y(new ODe(t))}function xme(e,t){a8(this),this.e=e,this.f=t}function Eme(){a8(this),this.e=0,this.f=!0}function Sme(e,t){this.c=e,KJ.call(this,e,t)}function N8e(e,t){return re(t,15)&&iZe(e.c,t)}function f9(e,t,i){return h(e.c,64).yj(t,i)}function nTt(e,t,i){return h(e.c,64).xj(t,i)}function iTt(e,t,i){return AMt(e,h(t,311),i)}function Mme(e,t,i){return PMt(e,h(t,311),i)}function rTt(e,t,i){return bqe(e,h(t,311),i)}function F8e(e,t,i){return $Ot(e,h(t,311),i)}function sTt(e,t){return Jh(),$n(ye(e.a),t)}function oTt(e,t){return Jh(),$n(ye(e.a),t)}function aTt(e){return Mo(),v8(e.a)?gze(e):null}function U8e(e,t){return e.b.Qb(t)?lUe(e,t):null}function cI(e,t){return e.substr(t,e.length-t)}function z8e(e){return h(e,11).f.c.length!=0}function G8e(e){return h(e,11).d.c.length!=0}function iA(e){return e==p3||e==vd||e==Oa}function j8e(e){xf(e.a),IGe(e.c,e.b),e.b=null}function _f(e){rJ(this),Nme(this.c,0,e.yc())}function h9(e){eFe(this),rd(this),wo(this,e)}function $8e(e,t,i){this.d=e,this.b=i,this.a=t}function Oc(e,t,i){this.a=e,this.b=t,this.c=i}function V8e(e,t,i){this.a=e,this.b=t,this.c=i}function W8e(e,t,i){this.c=e,this.a=t,this.b=i}function cTt(e,t,i,a){e.d.b.$b(i),e.d.b.Zb(a,t)}function rA(e,t){return Mo(),Hn(t),new _Fe(e,t)}function lTt(e){return KU(),Fi((xze(),eit),e)}function uTt(e){return dU(),Fi((Eze(),tit),e)}function fTt(e){return uU(),Fi((WGe(),Xnt),e)}function hTt(e){return Wg(),Fi((eGe(),Ynt),e)}function dTt(e){return A7(),Fi((q$e(),nit),e)}function pTt(e){return Sx(),Fi((XGe(),rit),e)}function gTt(e){return YA(),Fi((YGe(),oit),e)}function mTt(e){return b8(),Fi((Z7e(),ait),e)}function bTt(e){return gU(),Fi((Sze(),Sit),e)}function wTt(e){return xA(),Fi((bGe(),Bit),e)}function vTt(e){return _o(),Fi((mje(),Uit),e)}function _Tt(e){return yS(),Fi((qGe(),Vit),e)}function yTt(e){return Xt(),Fi((y$e(),Jit),e)}function RJ(e){F9.call(this,e.d,e.c,e.a,e.b)}function Tme(e){F9.call(this,e.d,e.c,e.a,e.b)}function xTt(e){return NA(),Fi((wGe(),nrt),e)}function ETt(e){return Ao(),Fi((HOe(),irt),e)}function STt(e){return JA(),Fi((pje(),urt),e)}function MTt(e){return sU(),Fi((Mze(),frt),e)}function TTt(e){return kS(),Fi((Vje(),hrt),e)}function CTt(e){return fx(),Fi((Tze(),drt),e)}function ATt(e){return wU(),Fi((cGe(),prt),e)}function PTt(e){return EU(),Fi((aGe(),grt),e)}function LTt(e){return M_(),Fi((lGe(),brt),e)}function kTt(e){return d7(),Fi((Gje(),wrt),e)}function RTt(e){return g6(),Fi((jje(),vrt),e)}function ITt(e){return IS(),Fi(($je(),_rt),e)}function DTt(e){return xo(),Fi((wVe(),yrt),e)}function BTt(e){return bS(),Fi((gGe(),xrt),e)}function OTt(e){return Hd(),Fi((mGe(),Srt),e)}function NTt(e){return Q9(),Fi((Cze(),Mrt),e)}function FTt(e){return du(),Fi((gje(),Crt),e)}function UTt(e){return u7(),Fi((Wje(),not),e)}function zTt(e){return _w(),Fi((HGe(),iot),e)}function GTt(e){return XA(),Fi((dje(),rot),e)}function jTt(e){return G_(),Fi((B$e(),sot),e)}function $Tt(e){return Oo(),Fi((uGe(),aot),e)}function VTt(e){return WU(),Fi((fGe(),cot),e)}function WTt(e){return yU(),Fi((hGe(),lot),e)}function HTt(e){return wx(),Fi((pGe(),uot),e)}function qTt(e){return LU(),Fi((dGe(),fot),e)}function Cme(e,t){for(;e.b.sd(new Hpe(e,t)););}function d9(e,t,i){this.b=e,this.a=t,this.c=i}function Ame(e,t,i){this.a=e,this.b=t,this.c=i}function H8e(e,t,i){this.a=e,this.b=t,this.c=i}function p9(e,t,i){this.e=t,this.b=e,this.d=i}function IJ(e){var t;return t=new DT,t.e=e,t}function XTt(e){return!e.e&&(e.e=new ke),e.e}function Vu(){Vu=M,ort=new WH,art=new kk}function DJ(){DJ=M,P3e=new qi,qnt=new Me}function lI(){lI=M,nG=new ic,iG=new EH}function YTt(e){return wA(),Fi((Oze(),kot),e)}function ZTt(e){return k0(),Fi((vGe(),Cot),e)}function KTt(e){return PS(),Fi((ZGe(),Mat),e)}function JTt(e){return nP(),Fi((Fje(),Cat),e)}function QTt(e){return Eh(),Fi((Pze(),Fot),e)}function eCt(e){return Jf(),Fi((Aze(),zot),e)}function tCt(e){return RI(),Fi((Lze(),jot),e)}function nCt(e){return ll(),Fi((qOe(),mat),e)}function iCt(e){return KI(),Fi((yGe(),Hat),e)}function rCt(e){return lU(),Fi((Bze(),Wat),e)}function sCt(e){return S0(),Fi((kze(),Sat),e)}function oCt(e){return W9(),Fi((Ize(),Oat),e)}function aCt(e){return q9(),Fi((Dze(),Nat),e)}function cCt(e){return vU(),Fi((Rze(),jat),e)}function lCt(e){return VU(),Fi((_Ge(),Vat),e)}function uCt(e){return i7(),Fi((KGe(),nct),e)}function fCt(e){return SU(),Fi((xGe(),ict),e)}function hCt(e){return i1(),Fi((wje(),sct),e)}function dCt(e){return o1(),Fi((O$e(),act),e)}function pCt(e){return ud(),Fi((Uje(),cct),e)}function gCt(e){return eh(),Fi((EGe(),Oct),e)}function mCt(e){return Fe(),Fi((sje(),Nct),e)}function bCt(e){return Ms(),Fi((Lje(),Bct),e)}function wCt(e){return e1(),Fi((MGe(),Rct),e)}function vCt(e){return a1(),Fi((Y$e(),Ict),e)}function _Ct(e){return Xg(),Fi((bje(),Dct),e)}function yCt(e){return qs(),Fi((vje(),Cct),e)}function xCt(e){return Yd(),Fi((JGe(),Act),e)}function ECt(e){return ld(),Fi((QGe(),Pct),e)}function SCt(e){return f7(),Fi((zje(),Lct),e)}function MCt(e){return Hl(),Fi((eje(),jct),e)}function TCt(e){return cc(),Fi((X$e(),$ct),e)}function CCt(e){return XU(),Fi((nje(),Vct),e)}function ACt(e){return xl(),Fi((ije(),qct),e)}function PCt(e){return Ef(),Fi((SGe(),Yct),e)}function LCt(e){return rl(),Fi((TGe(),Kct),e)}function kCt(e){return Nc(),Fi((CGe(),Qct),e)}function RCt(e){return U7(),Fi((CNe(),xlt),e)}function ICt(e){return I0(),Fi((tje(),Slt),e)}function DCt(e){return BS(),Fi((N$e(),Olt),e)}function BJ(e,t,i){return e=t)throw Y(new o8)}function aAt(e,t){var i;for(i=0;i0?1:0}function Xme(e){return!Array.isArray(e)&&e.sl===T}function P9e(e){return e!=null&&XJ(e)&&e.sl!==T}function Yme(e,t){return re(t,23)&&Rp(e,h(t,23))}function L9e(e,t){return re(t,23)&&cRt(e,h(t,23))}function fAt(e,t){return e.a.get(t)!==void 0}function Zme(e){return al(e,26)*bP+al(e,27)*wP}function k9e(e,t){return wRt(new En,new yY(e),t)}function Kme(e,t){if(e==null)throw Y(new EC(t))}function ix(e,t,i){return yl(e.a,t),c1e(e,t.g,i)}function A9(e,t,i){RVe(0,t,e.length),DI(e,0,t,i)}function v0(e,t,i){g_(t,e.c.length),UR(e.c,t,i)}function hAt(e,t,i){sYe(i,e,1),De(t,new AOe(i,e))}function dAt(e,t,i){ZA(i,e,1),De(t,new MOe(i,e))}function Jme(){this.d=new mi,this.e=new WUe(this)}function R9e(){this.b=new tn,this.c=new VUe(this)}function I9e(){u7e(),this.e=new Ir,this.d=new Ir}function jJ(e,t){this.b=new Ir,this.a=e,this.c=t}function l_(e,t,i){Kg(),this.e=e,this.d=t,this.a=i}function P9(e,t,i){var a;e&&(a=e.i,a.d=t,a.a=i)}function L9(e,t,i){var a;e&&(a=e.i,a.c=t,a.b=i)}function D9e(e,t,i){var a;for(a=0;a0?w.Math.log(e/t):-100}function PAt(e,t){return to(e.c.c+e.c.b,t.c.c+t.c.b)}function KJ(e,t){this.d=e,Bn.call(this,e),this.e=t}function fw(e,t,i){return TIt(e,t.g,i),yl(e.c,t),e}function LAt(e){return W_(e,(qs(),rf)),e.d=!0,e}function Hn(e){if(e==null)throw Y(new F2);return e}function rx(e){if(e==null)throw Y(new F2);this.a=e}function JJ(e){e.a=null,e.e=null,nl(e.b),e.d=0,++e.c}function QJ(e){return!e.j&&Gde(e,JUt(e.g,e.b)),e.j}function kAt(e){return e.b.k.a+=e.a.f*(e.a.a-1),null}function cA(e){s_(e.b!=-1),P0(e.c,e.a=e.b),e.b=-1}function q9e(e){XNe(this),nK(this.a,gbe(8>e?8:e)<<1)}function h1e(e,t){Rc.call(this,1),this.a=e,this.b=t}function eQ(e,t,i){this.a=e,IQ(i,t),this.c=t,this.b=i}function X9e(e,t){this.a=e,this.b=t,this.c=this.b.lc()}function gI(e,t){uFe(e,re(t,184)?t:h(t,1630).rk())}function Y9e(e){return Hn(e),re(e,476)?h(e,476):Ga(e)}function d1e(e,t){return t?wo(e,t):!1}function JE(e,t){return e.a+=String.fromCharCode(t),e}function Lg(e,t){return e.a+=String.fromCharCode(t),e}function RAt(e,t,i,a){return e.a+=""+t.substr(i,a-i),e}function IAt(e,t,i){var a;return a=mx(e,t),Nze(e,t,i),a}function DAt(e,t,i){var a;for(a=0;a=e.g}function YAt(e,t){return lx(),e==s1(t)?U0(t):s1(t)}function dr(e,t,i){return ws(t)?Ko(e,t,i):El(e.d,t,i)}function rQ(e,t,i){var a;return a=hee(e,t,i),r_e(e,a)}function uA(e,t){var i;return i=e.a._b(),ULt(t,i),i-1-t}function w1e(e,t){var i;return i=new EI(e),qbe(i,t),i}function Gr(e,t,i){return HSt(i==null||I7t(e,i)),e[t]=i}function ox(e,t){var i;i=e.a.length,mx(e,i),Nze(e,i,t)}function iUe(e,t){var i;++e.j,i=e.hi(),e.Wh(e.Ch(i,t))}function ZAt(e,t){ox(e,new rx(t.f!=null?t.f:""+t.g))}function KAt(e,t){ox(e,new rx(t.f!=null?t.f:""+t.g))}function rUe(e){this.b=new ke,this.a=new ke,this.c=e}function lu(e){this.c=new fo,this.a=new ke,this.b=e}function sUe(e){ume.call(this),this.a=new fo,this.c=e}function v1e(e,t,i){vC.call(this,t),this.a=e,this.b=i}function _1e(e,t,i){Rc.call(this,e),this.a=t,this.b=i}function y1e(e,t,i){this.a=e,e8.call(this,t),this.b=i}function oUe(e,t,i){this.a=e,e0e.call(this,8,t,null,i)}function aUe(e){this.c=e,this.a=new Ir,this.b=new Ir}function cUe(e){this.c=e,this.b=this.c.a,this.a=this.c.e}function JAt(e){this.a=(dn(Kn),Kn),this.b=e,new fpe}function y0(e){return!e.d&&(e.d=new vs(ko,e,1)),e.d}function lUe(e,t){var i;return i=e.b.$b(t),e.d.b.$b(i),i}function x1e(e,t){for(;t-- >0;)e=e<<1|(e<0?1:0);return e}function Dp(e,t){return Be(e)===Be(t)||e!=null&&ki(e,t)}function x0(e,t){return oA(t,e.a.c.length),St(e.a,t)}function sQ(e){return w.Math.sqrt(e.a*e.a+e.b*e.b)}function QAt(e){return String.fromCharCode.apply(null,e)}function Bp(e){return re(e,13)?h(e,13)._b():vA(e.tc())}function uUe(e){return re(e,543)?e:new uOe(e)}function va(e){return!e.a&&e.c?e.c.b:e.a}function oQ(e){e.c?oQ(e.c):(e.d=!0,x9t(e))}function f_(e){e.c?f_(e.c):(MS(e),e.d=!0)}function fUe(e){bI(e.a),e.b=le(on,et,1,e.b.length,5,1)}function aQ(e){this.c=e,this.b=e.a.b.a,Oge(e.a.c,this)}function ePt(e,t){e.c<0||e.b.b0?new xme(e-1,t):new xme(e,t)}function wUe(e,t){return m9(),new dwe(new MFe(e),new SFe(t))}function nS(e){if(ol(e.d),e.d.d!=e.c)throw Y(new P)}function lPt(e,t){var i;return i=e.a.get(t),i??[]}function uPt(e,t){var i;return i=Ii(e.f,t),lbe(t,i),null}function fi(e,t,i,a){return Q$e(e,t,i,!1),Fbe(e,a),e}function fPt(e,t){return e.a=Xf(e.a,0,t)+""+cI(e.a,t+1),e}function hPt(e){return e.j.c=le(on,et,1,0,5,1),e.a=-1,e}function dPt(e){return!e.c&&(e.c=new an(pi,e,5,8)),e.c}function pPt(e){return!e.b&&(e.b=new an(pi,e,4,7)),e.b}function uQ(e){return!e.n&&(e.n=new ze(ea,e,1,7)),e.n}function C1e(e){return!e.c&&(e.c=new ze(Pu,e,9,9)),e.c}function iS(e){return e.e==iM&&Ude(e,P5t(e.g,e.b)),e.e}function mI(e){return e.f==iM&&zde(e,iBt(e.g,e.b)),e.f}function vUe(e){return KC(e==null||XJ(e)&&e.sl!==T),e}function A1e(e,t){if(e==null)throw Y(new EC(t));return e}function hw(e){var t;return t=e.b,!t&&(e.b=t=new uY(e)),t}function P1e(e){var t;return t=e.Gh(e.f),$n(e,t),t.hc()}function bI(e){var t;for(t=e.tc();t.hc();)t.ic(),t.jc()}function _Ue(e){return Rn(e.ba&&++a,a}function $d(e){var t,i;return i=(t=new xg,t),MA(i,e),i}function dQ(e){var t,i;return i=(t=new xg,t),kqe(i,e),i}function vPt(e){if(e.p!=5)throw Y(new qa);return nr(e.f)}function _Pt(e){if(e.p!=5)throw Y(new qa);return nr(e.k)}function LUe(e){return e?e.Wb():!null.tc().hc()}function z9(e){return e.n&&(e.e!==kJe&&e.Pd(),e.j=null),e}function yPt(e){return e!=null&&RC(Bj,e.toLowerCase())}function pQ(e){this.f=e,this.c=this.f.e,e.f>0&&eqe(this)}function Vm(e,t,i,a){this.e=e,this.a=t,this.c=i,this.d=a}function kUe(e,t,i,a){Ol(),nGe.call(this,t,i,a),this.a=e}function RUe(e,t,i,a){Ol(),nGe.call(this,t,i,a),this.a=e}function IUe(e,t,i,a){this.b=e,this.c=a,j8.call(this,t,i)}function DUe(e,t){this.a=e,RMt.call(this,e,h(e.d,15).fd(t))}function rd(e){e.a.a=e.c,e.c.b=e.a,e.a.b=e.c.a=null,e.b=0}function k1e(e,t){return e.b=t.b,e.c=t.c,e.d=t.d,e.a=t.a,e}function xPt(e,t,i){e.i=0,e.e=0,t!=i&&EVe(e,t,i)}function EPt(e,t,i){e.i=0,e.e=0,t!=i&&SVe(e,t,i)}function BUe(e,t){var i;return i=qQ(t),h(Ii(e.c,i),21).a}function SPt(e,t,i){return i>=0&&dt(e.substr(i,t.length),t)}function gQ(e,t){return t==null?!!gc(e.d,null):fAt(e.e,t)}function OUe(e,t){e.d&&!e.d.a&&(tK(e.d,t),OUe(e.d,t))}function NUe(e,t){e.e&&!e.e.a&&(tK(e.e,t),NUe(e.e,t))}function FUe(e,t){this.g=e,this.d=X(q(Eu,1),Af,8,0,[t])}function R1e(e,t){new Ir,this.a=new zc,this.b=e,this.c=t}function UUe(){ove(this,new hF),this.wb=(kg(),Ct),IE()}function zUe(e,t){return re(t,166)&&dt(e.b,h(t,166).Lf())}function MPt(e,t){return sl(e),sl(t),$De(h(e,23),h(t,23))}function I1e(e,t,i,a,l,f){VGe.call(this,e,t,i,a,l,f?-2:-1)}function GUe(e,t,i,a){pge.call(this,t,i),this.b=e,this.a=a}function jUe(e,t){tEt.call(this,new WJ(e)),this.a=e,this.b=t}function D1e(e){this.b=e,this.c=e,e.e=null,e.c=null,this.a=1}function $Ue(e,t){var i;return i=Um(e.ql),t==null?i:i+": "+t}function Kr(e,t){return zg(bAt($o(e)?fu(e):e,$o(t)?fu(t):t))}function Kf(e,t){return zg(wAt($o(e)?fu(e):e,$o(t)?fu(t):t))}function TPt(e,t){return zg(vAt($o(e)?fu(e):e,$o(t)?fu(t):t))}function B1e(e){return e&&e.hashCode?e.hashCode():g0(e)}function rS(e){return _t(),re(e,49)?new bK(e):new K8(e)}function _t(){_t=M,uo=new tt,ep=new Tt,$z=new jt}function sS(){sS=M,C3e=new en,jnt=new en,A3e=new mn}function O1e(){O1e=M,Knt=new vn,Qnt=new Jme,Jnt=new Mn}function oS(){oS=M;var e,t;t=!h5t(),e=new H,Zre=t?new O:e}function VUe(e){this.c=e,this.b=new iw(h(Hn(new Kt),65))}function WUe(e){this.c=e,this.b=new iw(h(Hn(new xi),65))}function Op(){this.a=new zc,this.b=(Sf(3,Dx),new Gl(3))}function mQ(e,t,i){this.a=e,this.e=!1,this.d=t,this.c=i}function HUe(e,t,i){return e.f?e.f.re(t,i):!1}function ye(e){return!e.s&&(e.s=new ze(Sc,e,21,17)),e.s}function Ni(e){return!e.q&&(e.q=new ze(uf,e,11,10)),e.q}function N1e(e){return!e.a&&(e.a=new ze(Br,e,10,11)),e.a}function CPt(e,t){var i;return i=Lge(e.a,t),i&&(t.d=null),i}function h_(e,t,i,a){Gr(e.c[t.g],i.g,a),Gr(e.c[i.g],t.g,a)}function G9(e,t,i,a){Gr(e.c[t.g],t.g,i),Gr(e.b[t.g],t.g,a)}function ax(e,t,i){tU(),e&&dr(Lae,e,t),e&&dr(bD,e,i)}function APt(e,t){dFe(e,nr(Kr(Pg(t,24),H7)),nr(Kr(t,H7)))}function sc(e){var t;return t=h(sn(e,16),24),t||e.Rg()}function PPt(e){if(e.p!=0)throw Y(new qa);return kC(e.f,0)}function LPt(e){if(e.p!=0)throw Y(new qa);return kC(e.k,0)}function Bo(e){return e.u||(uu(e),e.u=new r8e(e,e)),e.u}function kPt(e){return e==ip||e==Zp}function RPt(e){h8(),w.setTimeout(function(){throw e},0)}function bQ(e){this.c=e.c,this.d=e.d,this.b=e.b,this.a=e.a}function Np(e,t){this.e=e,this.a=on,this.b=_Ze(t),this.c=t}function qUe(){this.b=new zr,this.c=new Ir,this.d=new sK}function Eh(){Eh=M,rb=new ige(YS,0),Yp=new ige(XS,1)}function S0(){S0=M,um=new cge(XS,0),xy=new cge(YS,1)}function XUe(){XUe=M,lw(),t3e=(jo(),Pnt),Mnt=new M1e(new iw(t3e))}function IPt(e){return XUe(),Hn(e),t3e==e?Mnt:new M1e(new iw(e))}function Wm(e,t,i,a,l,f,g){return new kQ(e.e,t,i,a,l,f,g)}function YUe(e,t,i,a,l,f){this.a=e,lee.call(this,t,i,a,l,f)}function ZUe(e,t,i,a,l,f){this.a=e,lee.call(this,t,i,a,l,f)}function F1e(e){this.e=e,this.b=this.e.a.entries(),this.a=[]}function U1e(e){e.d=e.d-15,e.b=e.b-15,e.c=e.c+15,e.a=e.a+15}function KUe(e,t){var i;i=h(L0e(e.e,t),249),i&&(e.d=!0)}function za(e,t){return t==null?Dc(gc(e.d,null)):NC(e.e,t)}function gc(e,t){return TVe(e,t,lPt(e,t==null?0:e.b.he(t)))}function JUe(e,t){return t===e?"(this Map)":t==null?Xc:Ga(t)}function DPt(e,t){return e.a?t.pg().tc():h(t.pg(),64).oh()}function vI(e,t,i){return e.a=Xf(e.a,0,t)+(""+i)+cI(e.a,t),e}function Hm(e,t){if(t==null)throw Y(new F2);return y5t(e,t)}function BPt(){return KU(),X(q(G3e,1),Oe,391,0,[rse,z3e])}function OPt(){return dU(),X(q($3e,1),Oe,390,0,[j3e,sse])}function NPt(){return gU(),X(q(dEe,1),Oe,387,0,[hse,Kz])}function FPt(){return sU(),X(q(xSe,1),Oe,386,0,[ySe,Gse])}function UPt(){return fx(),X(q(MSe,1),Oe,317,0,[M5,S5])}function zPt(){return Q9(),X(q(VSe,1),Oe,383,0,[noe,$Se])}function GPt(){return q9(),X(q(HTe,1),Oe,388,0,[$oe,WTe])}function jPt(){return W9(),X(q(VTe,1),Oe,438,0,[joe,$Te])}function $Pt(){return vU(),X(q(qTe,1),Oe,447,0,[sj,vM])}function VPt(){return RI(),X(q(kTe,1),Oe,437,0,[LTe,ZG])}function WPt(){return Eh(),X(q(Not,1),Oe,466,0,[rb,Yp])}function HPt(){return Jf(),X(q(Uot,1),Oe,465,0,[M1,oh])}function qPt(){return S0(),X(q(Eat,1),Oe,417,0,[um,xy])}function XPt(){return wA(),X(q(Lot,1),Oe,472,0,[fL,uL])}function YPt(){return lU(),X(q(YTe,1),Oe,389,0,[XTe,qoe])}function j9(e,t,i,a){return i>=0?e.Dg(t,i,a):e.lg(null,i,a)}function ZPt(e,t){var i;i=h(rn(t,(eA(),wL)),35),sKe(e,i)}function wQ(e){var t;return t=cu(e.b),wo(t,e.c),wo(t,e.i),t}function z1e(e){return Be(e.a)===Be((bee(),Iae))&&hGt(e),e.a}function QUe(e){return e.b.b==0?e.a.Be():FJ(e.b)}function G1e(e){var t;return t=e.g,h(t||(e.g=new gF(e)),15)}function Jf(){Jf=M,M1=new rge(ore,0),oh=new rge("UP",1)}function vQ(e,t){Pde(this,new $t(e.a,e.b)),Lde(this,cu(t))}function e7e(e,t){a9.call(this),j0e(this),this.a=e,this.c=t}function j1e(e,t,i){Ol(),vC.call(this,t),this.a=e,this.b=i}function _Q(e,t,i){vi(),Rc.call(this,e),this.b=t,this.a=i}function KPt(e,t){var i=Yre[e.charCodeAt(0)];return i??e}function JPt(e,t){var i;return i=eRt(e.f,t),tr(wJ(i),e.f.d)}function t7e(e){var t;t=e.c.b.b,e.b=t,e.a=e.c.b,t.a=e.c.b.b=e}function QPt(e){return e.b==0?null:(Rn(e.b!=0),Xu(e,e.a.a))}function eLt(e){return no(jd(Wc(al(e,32)),32),Wc(al(e,32)))}function n7e(e){return re(e,62)&&(h(h(e,17),62).Bb&Ja)!=0}function yr(e){return Math.max(Math.min(e,zi),-2147483648)|0}function $9(e,t){return n0e(t),Tkt(e,le(In,si,22,t,15,1),t)}function tLt(e,t){return lx(),e==eo(s1(t))||e==eo(U0(t))}function i7e(e){var t;return t=rU(e),"n_"+(t??""+e.o)}function r7e(e){this.b=(Mo(),Mo(),Mo(),Tnt),this.a=h(Hn(e),43)}function s7e(e){a9.call(this),j0e(this),this.a=e,this.c=!0}function o7e(e,t,i){this.d=e,this.b=new ke,this.c=t,this.a=i}function yQ(e,t,i,a){var l;l=new w8e,t.a[i.g]=l,ix(e.b,a,l)}function a7e(e,t){var i=e.a=e.a||[];return i[t]||(i[t]=e._d(t))}function _I(e,t){var i;i=e.q.getHours(),e.q.setDate(t),fP(e,i)}function c7e(e){var t;return t=new m8(Eee(e.length)),qI(t,e),t}function nLt(e){function t(){}return t.prototype=e||{},new t}function iLt(e,t){return nVe(e,t)?(e$e(e),!0):!1}function V9(e){return e.Db>>16!=3?null:h(e.Cb,35)}function Sh(e){return e.Db>>16!=9?null:h(e.Cb,35)}function rLt(e){if(e.p!=2)throw Y(new qa);return nr(e.f)&jr}function sLt(e){if(e.p!=2)throw Y(new qa);return nr(e.k)&jr}function W9(){W9=M,joe=new lge(HQe,0),$Te=new lge("FAN",1)}function xQ(e,t,i){var a;a=xVe(e,t,i),e.b=new dee(a.c.length)}function Ko(e,t,i){return t==null?El(e.d,null,i):D0(e.e,t,i)}function $1e(e,t){return n1(no(n1(h(e,149).a).a,h(t,149).a))}function l7e(){l7e=M,PTe=wUe(He(1),He(4)),ATe=wUe(He(1),He(2))}function u7e(){u7e=M,dot=jc(new ss,(_o(),qo),(Ao(),hG))}function f7e(){f7e=M,hot=jc(new ss,(_o(),qo),(Ao(),hG))}function h7e(){h7e=M,Rot=Ai(new ss,(_o(),qo),(Ao(),XP))}function vl(){vl=M,Bot=Ai(new ss,(_o(),qo),(Ao(),XP))}function d7e(){d7e=M,Oot=Ai(new ss,(_o(),qo),(Ao(),XP))}function EQ(){EQ=M,Got=Ai(new ss,(_o(),qo),(Ao(),XP))}function p7e(){p7e=M,Fat=jc(new ss,(PS(),pL),(nP(),Ioe))}function g7e(e){return e.Db>>16!=6?null:h(e.Cb,105)}function m7e(e){return e.Db>>16!=7?null:h(e.Cb,207)}function b7e(e){return e.Db>>16!=7?null:h(e.Cb,253)}function eo(e){return e.Db>>16!=11?null:h(e.Cb,35)}function dw(e){return e.Db>>16!=17?null:h(e.Cb,24)}function w7e(e){return e.Db>>16!=3?null:h(e.Cb,139)}function aS(e){return e.Db>>16!=6?null:h(e.Cb,207)}function dA(e,t,i,a,l,f){return new Wd(e.e,t,e.pi(),i,a,l,f)}function V1e(e,t){return L9e(e.a,t)?c1e(e,h(t,23).g,null):null}function oLt(e,t){return A9e(Wc(e.q.getTime()),Wc(t.q.getTime()))}function aLt(e,t){var i;i=e.q.getHours(),e.q.setMonth(t),fP(e,i)}function Os(e,t){e.c&&Sa(e.c.f,e),e.c=t,e.c&&De(e.c.f,e)}function Hs(e,t){e.c&&Sa(e.c.a,e),e.c=t,e.c&&De(e.c.a,e)}function _s(e,t){e.d&&Sa(e.d.d,e),e.d=t,e.d&&De(e.d.d,e)}function us(e,t){e.g&&Sa(e.g.i,e),e.g=t,e.g&&De(e.g.i,e)}function v7e(e,t){return e.b+=t.b,e.c+=t.c,e.d+=t.d,e.a+=t.a,e}function W1e(e){return Y8(e.c),e.e=e.a=e.c,e.c=e.c.c,++e.d,e.a.f}function _7e(e){return Y8(e.e),e.c=e.a=e.e,e.e=e.e.e,--e.d,e.a.f}function y7e(e,t){var i;return i=new lu(e),t.c[t.c.length]=i,i}function cLt(e,t){var i,a;i=t.c,a=i!=null,a&&ox(e,new rx(t.c))}function lLt(e){var t;t=Z6t(h(rn(e,(ww(),Yoe)),349)),t.Ef(e)}function SQ(e,t){re(e.Cb,96)&&sP(uu(h(e.Cb,96)),4),Mf(e,t)}function H9(e,t){re(e.Cb,248)&&(h(e.Cb,248).tb=null),Mf(e,t)}function uLt(e,t){uWe(e,t),re(e.Cb,96)&&sP(uu(h(e.Cb,96)),2)}function fLt(e,t){q8(this),this.f=t,this.g=e,z9(this),this.Pd()}function cx(e){this.c=new Ir,this.b=e.b,this.d=e.c,this.a=e.a}function x7e(){this.a=new Gc,this.e=new zr,this.g=0,this.i=0}function Rg(e,t,i){HVe(t,i,e._b()),this.c=e,this.a=t,this.b=i-t}function Ns(e,t){this.a=e,ME.call(this,e),g_(t,e._b()),this.b=t}function E7e(e){this.a=e,this.b=le(Aot,be,1637,e.e.length,0,2)}function d_(e){this.a=w.Math.cos(e),this.b=w.Math.sin(e)}function di(e,t){this.b=(dn(e),e),this.a=t&W0?t:t|64|Ah}function S7e(e,t,i){var a;HVe(t,i,e.c.length),a=i-t,Dpe(e.c,t,a)}function M7e(e,t){var i;return i=h(AS(_0(e.a),t),13),i?i._b():0}function T7e(e){var t,i;return i=(IE(),t=new xg,t),MA(i,e),i}function C7e(e){var t,i;return i=(IE(),t=new xg,t),MA(i,e),i}function p_(e){return PC(),re(e.g,8)?h(e.g,8):null}function hLt(e,t){var i;i=h(Ii(e.g,t),57),cd(t.d,new kOe(e,i))}function $c(e,t){return Yo(),O0e(t)?new y9(t,e):new qR(t,e)}function Wu(e){return Fo(X(q(es,1),be,9,0,[e.g.k,e.k,e.a]))}function dLt(){return NA(),X(q(trt,1),Oe,412,0,[Tse,Cse,Mse])}function pLt(){return Wg(),X(q(ih,1),Oe,150,0,[N3e,nh,Bw])}function gLt(){return Hd(),X(q(Ert,1),Oe,280,0,[A5,gy,Kx])}function mLt(){return bS(),X(q(jSe,1),Oe,318,0,[eoe,toe,EG])}function bLt(){return wU(),X(q(CSe,1),Oe,319,0,[TSe,bG,$se])}function wLt(){return EU(),X(q(PSe,1),Oe,384,0,[Vse,ASe,Wse])}function vLt(){return M_(),X(q(mrt,1),Oe,406,0,[Hse,T5,YP])}function _Lt(){return Oo(),X(q(oot,1),Oe,410,0,[WG,Fc,lc])}function yLt(){return WU(),X(q(xTe,1),Oe,345,0,[_Te,Aoe,yTe])}function xLt(){return yU(),X(q(MTe,1),Oe,347,0,[STe,Poe,ETe])}function ELt(){return LU(),X(q(CTe,1),Oe,346,0,[Loe,koe,H5])}function SLt(){return wx(),X(q(TTe,1),Oe,385,0,[W5,$5,V5])}function MLt(){return xA(),X(q(MEe,1),Oe,348,0,[mse,gse,bse])}function TLt(){return KI(),X(q(JTe,1),Oe,349,0,[oj,ZTe,KTe])}function CLt(){return VU(),X(q($at,1),Oe,401,0,[Hoe,Voe,Woe])}function ALt(){return k0(),X(q(Tot,1),Oe,413,0,[HG,lL,qG])}function PLt(){return rl(),X(q(Zct,1),Oe,419,0,[Uh,gb,cf])}function LLt(){return Nc(),X(q(Jct,1),Oe,420,0,[Df,mb,lf])}function kLt(){return eh(),X(q(pAe,1),Oe,275,0,[Ty,hb,_j])}function RLt(){return SU(),X(q(fCe,1),Oe,277,0,[Koe,uCe,lCe])}function ILt(){return Ef(),X(q(Jw,1),Oe,203,0,[aa,Wa,ca])}function DLt(){return e1(),X(q(uAe,1),Oe,316,0,[vj,d3,ML])}function A7e(){A7e=M,Ant=Ui((i_(),X(q(Xre,1),Oe,350,0,[d5,p5])))}function q9(){q9=M,$oe=new uge("DFS",0),WTe=new uge("BFS",1)}function lx(){lx=M,Zz=new ke,fse=(Yr(),new ui),use=new ke}function P7e(e,t,i){var a;a=new uq,a.b=t,a.a=i,++t.b,De(e.d,a)}function L7e(e,t,i){Rc.call(this,25),this.b=e,this.a=t,this.c=i}function _l(e){vi(),Rc.call(this,e),this.c=!1,this.a=!1}function BLt(e){return e.a==(fS(),Uj)&&Nde(e,y9t(e.g,e.b)),e.a}function pA(e){return e.d==(fS(),Uj)&&Fde(e,C7t(e.g,e.b)),e.d}function OLt(e,t){var i;return i=(dn(e),e).g,kge(!!i),dn(t),i(t)}function MQ(e,t){var i,a;return a=KE(e,t),i=e.a.fd(a),new KBe(e,i)}function cS(e){var t;return $o(e)?(t=e,t==-0?0:t):Xkt(e)}function NLt(e){return e.Db>>16!=6?null:h(Xte(e),207)}function $(e){return Rn(e.a=t)throw Y(new Ra(VNt(e,t)));return e}function k7e(e,t,i){if(e<0||ti)throw Y(new Ra(yNt(e,t,i)))}function zLt(e){return Mo(),Lg(zbe((ru(),Qxe),Lg(new f0,91),e),93).a}function X9(e){return Hn(e),Ete((Mo(),new Nd(Kh(Gd(e.a,new z)))))}function Y9(e){return new Gl((Sf(e,zne),NI(no(no(5,e),e/10|0))))}function H1e(e,t){return e&&e.equals?e.equals(t):Be(e)===Be(t)}function q1e(e,t){return t==0?!!e.o&&e.o.f!=0:fte(e,t)}function GLt(e,t){var i;i=ce(Xe(e.a.xe((ur(),bj)))),sJe(e,t,i)}function R7e(e,t,i){var a;a=br(e.d,t),a>=0?b7(e,a,i):Uve(e,t,i)}function CQ(e,t,i){var a;a=e.d[t.o],e.d[t.o]=e.d[i.o],e.d[i.o]=a}function I7e(e,t){var i;for(i=e+"";i.length0&&e.a[--e.d]==0;);e.a[e.d++]==0&&(e.e=0)}function jLt(e){return!!e.u&&Ea(e.u.a).i!=0&&!(e.n&&bte(e.n))}function K9(e){lA(),this.a=(_t(),re(e,49)?new bK(e):new K8(e))}function D7e(){this.c=new rFe,this.a=new b8e,this.b=new ENe,MBe()}function B7e(e,t,i){this.d=e,this.j=t,this.e=i,this.o=-1,this.p=3}function O7e(e,t,i){this.d=e,this.k=t,this.f=i,this.o=-1,this.p=5}function N7e(e,t,i,a,l,f){V0e.call(this,e,t,i,a,l),f&&(this.o=-2)}function F7e(e,t,i,a,l,f){W0e.call(this,e,t,i,a,l),f&&(this.o=-2)}function U7e(e,t,i,a,l,f){d0e.call(this,e,t,i,a,l),f&&(this.o=-2)}function z7e(e,t,i,a,l,f){X0e.call(this,e,t,i,a,l),f&&(this.o=-2)}function G7e(e,t,i,a,l,f){p0e.call(this,e,t,i,a,l),f&&(this.o=-2)}function j7e(e,t,i,a,l,f){H0e.call(this,e,t,i,a,l),f&&(this.o=-2)}function $7e(e,t,i,a,l,f){q0e.call(this,e,t,i,a,l),f&&(this.o=-2)}function V7e(e,t,i,a,l,f){g0e.call(this,e,t,i,a,l),f&&(this.o=-2)}function W7e(e,t,i,a){vC.call(this,i),this.b=e,this.c=t,this.d=a}function H7e(e,t){this.f=e,this.a=(fS(),Fj),this.c=Fj,this.b=t}function q7e(e,t){this.g=e,this.d=(fS(),Uj),this.a=Uj,this.b=t}function X7e(e,t){!e.c&&(e.c=new ps(e,0)),Sne(e.c,(lr(),ED),t)}function ia(e,t,i,a,l,f){return Q$e(e,t,i,f),eWe(e,a),tWe(e,l),e}function Y7e(e,t){return re(t,38)?xte(e.a,h(t,38)):!1}function $Lt(e){if(!("stack"in e))try{throw e}catch{}return e}function VLt(e){if(e.p!=1)throw Y(new qa);return nr(e.f)<<24>>24}function WLt(e){if(e.p!=1)throw Y(new qa);return nr(e.k)<<24>>24}function HLt(e){if(e.p!=7)throw Y(new qa);return nr(e.k)<<16>>16}function qLt(e){if(e.p!=7)throw Y(new qa);return nr(e.f)<<16>>16}function J9(e){Ywe(),dFe(this,nr(Kr(Pg(e,24),H7)),nr(Kr(e,H7)))}function Z7e(){Z7e=M,ait=Ui((b8(),X(q(oEe,1),Oe,439,0,[ase])))}function Q9(){Q9=M,noe=new tge(MP,0),$Se=new tge("TOP_LEFT",1)}function K7e(e,t){var i;e.e=new spe,i=Sw(t),fa(i,e.c),eZe(e,i,0)}function bt(e,t,i,a){var l;l=new fN,l.a=t,l.b=i,l.c=a,Gi(e.b,l)}function mc(e,t,i,a){var l;l=new fN,l.a=t,l.b=i,l.c=a,Gi(e.a,l)}function XLt(e,t,i){var a;return a=h(e.Hc().Vb(t),13),!!a&&a.pc(i)}function J7e(e,t,i){var a;return a=h(e.Hc().Vb(t),13),!!a&&a.vc(i)}function Q7e(e,t){var i;return i=1-t,e.a[i]=_U(e.a[i],i),_U(e,t)}function lS(e){return Rn(e.b.b!=e.d.a),e.c=e.b=e.b.b,--e.a,e.c.c}function eze(e){return _9(e),Y8(e.c),e.e=e.a=e.c,e.c=e.c.b,++e.d,e.a}function tze(e){return _9(e),Y8(e.e),e.c=e.a=e.e,e.e=e.e.d,--e.d,e.a}function Tn(e){if(!Gn(e))throw Y(new K);return e.c=e.b,e.b.ic()}function nze(e,t){return re(t,38)?xte(e.a,h(t,38)):!1}function ize(e,t){return re(t,38)?xte(e.a,h(t,38)):!1}function rze(e){var t;return f_(e),t=new cn,Cme(e.a,new MY(t)),t}function Y1e(){var e,t,i;return t=(i=(e=new xg,e),i),De(YAe,t),t}function YLt(e){var t;return t=(ll(),ll(),nat),e.d&&Gte(e),aEt(),t}function Z1e(e){return e.j.c=le(on,et,1,0,5,1),bI(e.c),hPt(e.a),e}function ss(){mDe.call(this),this.j.c=le(on,et,1,0,5,1),this.a=-1}function sze(e,t,i){this.b=new VF(this),this.c=e,this.f=t,this.d=i}function ZLt(e,t,i){e.d&&Sa(e.d.d,e),e.d=t,e.d&&v0(e.d.d,i,e)}function KLt(e){return!!e.a&&Vc(e.a.a).i!=0&&!(e.b&&wte(e.b))}function JLt(e){return vl(),!Jo(e)&&!(!Jo(e)&&e.c.g.c==e.d.g.c)}function QLt(e){return tU(),w0(Lae,e)?h(Ii(Lae,e),337).Mf():null}function mA(e){return re(e,13)?new hI((ru(),h(e,13))):BCt(e.tc())}function e4t(e,t,i){return i.f.c.length>0?u1e(e.a,t,i):u1e(e.b,t,i)}function oze(e,t,i){var a;return a=jA(i),dr(e.b,a,t),dr(e.c,t,i),t}function M0(e,t){var i,a;return i=Hm(e,t),a=null,i&&(a=i.Vd()),a}function yI(e,t){var i,a;return i=Hm(e,t),a=null,i&&(a=i.Yd()),a}function uS(e,t){var i,a;return i=mx(e,t),a=null,i&&(a=i.Yd()),a}function Vd(e,t){var i,a;return i=Hm(e,t),a=null,i&&(a=Kqe(i)),a}function K1e(e){var t;return t=e.Fh(e.i),e.i>0&&vc(e.g,0,t,0,e.i),t}function xI(e){var t;return t=(Hn(e),new _f((ru(),e))),iP(t),Lee(t)}function Ea(e){return e.n||(uu(e),e.n=new cFe(ko,e),Bo(e)),e.n}function aze(e,t){var i;return i=new tw,e.wd(i),i.a+="..",t.xd(i),i.a}function cze(e,t){_8();var i;return i=h(Ii(Dj,e),47),!i||i.Li(t)}function T0(e){return re(e,13)?h(e,13).Wb():!e.tc().hc()}function t4t(e){if(e.ee())return null;var t=e.n,i=Nz[t];return i}function Un(e){return Rn(e.b!=e.d.c),e.c=e.b,e.b=e.b.a,++e.a,e.c.c}function J1e(e,t){dn(t),Gr(e.a,e.c,t),e.c=e.c+1&e.a.length-1,dHe(e)}function bA(e,t){dn(t),e.b=e.b-1&e.a.length-1,Gr(e.a,e.b,t),dHe(e)}function lze(e){var t;t=e.pg(),this.a=re(t,64)?h(t,64).oh():t.tc()}function n4t(e,t,i){var a;a=f5t();try{return zMt(e,t,i)}finally{V4t(a)}}function Q1e(e,t,i,a){return re(i,49)?new IFe(e,t,i,a):new t1e(e,t,i,a)}function i4t(){return uU(),X(q(Vz,1),Oe,278,0,[nse,D3e,B3e,O3e])}function r4t(){return yS(),X(q($it,1),Oe,373,0,[Q0,Nw,Ow,fy])}function s4t(){return Sx(),X(q(iit,1),Oe,304,0,[m5,g5,b5,w5])}function o4t(){return YA(),X(q(sit,1),Oe,362,0,[v5,qz,Xz,_5])}function a4t(e){return ce(mt(G(e,(Ie(),Fw))))&&G(e,Jn)!=null}function c4t(e){return ce(mt(G(e,(Ie(),Fw))))&&G(e,Jn)!=null}function ux(e){return PC(),re(e.g,153)?h(e.g,153):null}function l4t(e,t,i){var a;a=h(Ii(e.g,i),57),De(e.a.c,new Is(t,a))}function uze(e,t,i,a){var l;return l=a[t.g][i.g],ce(Xe(G(e.a,l)))}function fze(e,t,i,a){this.e=a,this.d=null,this.c=e,this.a=t,this.b=i}function e0e(e,t,i,a){this.d=e,this.n=t,this.g=i,this.o=a,this.p=-1}function hze(e,t,i,a,l){this.c=e,this.e=t,this.d=i,this.b=a,this.a=l}function t0e(e,t,i,a,l){this.i=e,this.a=t,this.e=i,this.j=a,this.f=l}function Ig(e,t,i,a,l){Oi.call(this,e,t),this.a=i,this.b=a,this.c=l}function wA(){wA=M,fL=new nge("UPPER",0),uL=new nge("LOWER",1)}function u4t(){return PS(),X(q(ITe,1),Oe,360,0,[JG,dL,q5,pL])}function f4t(){return i7(),X(q(cCe,1),Oe,320,0,[Zoe,oCe,aCe,sCe])}function h4t(){return Yd(),X(q(QCe,1),Oe,226,0,[wj,xL,h3,EL])}function d4t(){return ld(),X(q(mae,1),Oe,197,0,[gae,pae,EM,lb])}function p4t(){return Hl(),X(q(AL,1),Oe,344,0,[lD,C1,cD,pb])}function g4t(){return I0(),X(q(Elt,1),Oe,374,0,[dD,hD,Sae,Mae])}function m4t(){return XU(),X(q(yAe,1),Oe,288,0,[yae,wAe,_Ae,vAe])}function b4t(){return xl(),X(q(Hct,1),Oe,265,0,[fD,Ed,dm,uD])}function w4t(){return _w(),X(q(Moe,1),Oe,179,0,[jG,Soe,_y,vy])}function zl(e,t,i){return t<0?Vte(e,i):h(i,61).aj().fj(e,e.Qg(),t)}function dze(e,t){var i;for(i=e.j.c.length;i=0&&e.a[i]===t[i];i--);return i<0}function s0e(e,t){var i;i=e.q.getHours(),e.q.setFullYear(t+$0),fP(e,i)}function hx(e,t){return t==0||e.e==0?e:t>0?PWe(e,t):OYe(e,-t)}function o0e(e,t){return t==0||e.e==0?e:t>0?OYe(e,t):PWe(e,-t)}function a0e(e){e.b!=e.c&&(e.a=le(on,et,1,8,5,1),e.b=0,e.c=0)}function dx(e){return Rn(e.a0;)a+=e.a[i],i-=i&-i;return a}function zze(e,t){var i;for(i=t;i;)Fl(e,-i.i,-i.j),i=eo(i);return e}function Xm(e,t){return e.a?Mi(e.a,e.b):e.a=new ou(e.d),Z2(e.a,t),e}function Gze(e,t){for(dn(t);e.a||(e.a=a_(e.c,e)),e.a;)t.ie(eU(e))}function RQ(e){return e.c&&e.d?X1e(e.c)+"->"+X1e(e.d):"e_"+g0(e)}function M4t(e,t,i){return h(t==null?El(e.d,null,i):D0(e.e,t,i),261)}function T4t(e,t,i){var a,l;a=Hm(e,i),l=null,a&&(l=Kqe(a)),_Ft(t,i,l)}function C4t(e,t){var i;i=new SC,$m(i,"x",t.a),$m(i,"y",t.b),ox(e,i)}function A4t(e,t){var i;i=new SC,$m(i,"x",t.a),$m(i,"y",t.b),ox(e,i)}function P4t(e,t){return T8t(e,t,re(t,62)&&(h(h(t,17),62).Bb&oo)!=0)}function od(e){return Hn(e),re(e,13)?new _f((ru(),h(e,13))):NJ(e.tc())}function L4t(){return Fe(),X(q(Ec,1),Oe,69,0,[Na,bn,Zt,ni,nn])}function k4t(e){return h8(),function(){return n4t(e,this,arguments);var t}}function R4t(){return Date.now?Date.now():new Date().getTime()}function l0e(e){if(!e.c.Cc())throw Y(new K);return e.a=!0,e.c.Ec()}function IQ(e,t){if(e<0||e>t)throw Y(new Ra(uve(e,t,"index")));return e}function u0e(e,t){return re(t,180)?dt(e.c,h(t,180).c):!1}function I4t(e){return e.d=3,e.c=bRt(e),e.d!=2?(e.d=0,!0):!1}function jze(e,t){var i,a;return i=(a=e.slice(0,t),yA(a,e)),i.length=t,i}function Hu(e,t,i){var a;return a=(ai(t,e.c.length),e.c[t]),e.c[t]=i,a}function DQ(e,t,i,a){var l;return l=le(In,si,22,t,15,1),VBt(l,e,t,i,a),l}function $ze(e,t,i,a){this.e=e,this.b=new ke,this.d=t,this.a=i,this.c=a}function A0(e,t){this.b=Ca,this.d=e,this.e=t,this.c=this.d+(""+this.e)}function Vze(){rJ(this),this.b=new $t(Jr,Jr),this.a=new $t(Ts,Ts)}function fS(){fS=M;var e,t;Fj=(IE(),t=new S,t),Uj=(e=new cK,e)}function Wze(){cU(),this.b=(Yr(),new ui),this.a=new ui,this.c=new ke}function nl(e){var t;e.d=new BNe(e),e.e=new ONe(e),t=e[Z_]|0,e[Z_]=t+1}function nU(e,t){return(MS(e),Ebe(new oi(e,new S0e(t,e.a)))).a!=null}function D4t(){return _o(),X(q(TEe,1),Oe,328,0,[Dh,Zx,Qa,ec,qo])}function B4t(){return JA(),X(q(_Se,1),Oe,276,0,[Use,zse,Nse,vSe,Fse])}function O4t(){return du(),X(q(tMe,1),Oe,178,0,[r3,I5,zw,QP,nb])}function N4t(){return XA(),X(q(pTe,1),Oe,292,0,[dTe,Toe,Coe,U5,z5])}function F4t(){return Xg(),X(q(CL,1),Oe,225,0,[ub,wae,fAe,TL,hAe])}function U4t(){return i1(),X(q(Qp,1),Oe,163,0,[Ln,ga,bd,cb,fm])}function z4t(){return qs(),X(q(yL,1),Oe,110,0,[Oh,sf,rf,rp,hm])}function G4t(e,t){var i;return i=t!=null?za(e,t):Dc(gc(e.d,null)),$E(i)}function j4t(e,t){var i;return i=t!=null?za(e,t):Dc(gc(e.d,null)),$E(i)}function f0e(e,t){var i;return i=h(gx(e.d,t),27),i||h(gx(e.e,t),27)}function h0e(e,t){var i;return i=0,e&&(i+=e.f.a/2),t&&(i+=t.f.a/2),i}function uu(e){return e.t||(e.t=new YZ(e),JI(new VDe(e),0,e.t)),e.t}function Hze(e){var t;return e.c||(t=e.r,re(t,96)&&(e.c=h(t,24))),e.c}function qze(e,t){return w0(e.a,t)?(hS(e.a,t),!0):!1}function Jo(e){return!e.c||!e.d?!1:!!e.c.g&&e.c.g==e.d.g}function $4t(e){return Sf(e,"size"),nr(_K(Jm(e,8),Rx)?Jm(e,8):Rx),new tw}function Fp(e,t){return kNe((lA(),new K9(cWe(X(q(on,1),et,1,5,[e,t])))))}function V4t(e){e&&Kkt((vr(),r3e)),--Fz,e&&Uz!=-1&&(HEt(Uz),Uz=-1)}function W4t(e,t){var i,a;i=h(M5t(e.c,t),13),i&&(a=i._b(),i.Pb(),e.d-=a)}function vA(e){Mo();var t;for(t=0;e.hc();)e.ic(),t=no(t,1);return NI(t)}function BQ(e){var t,i,a;return t=e&Yc,i=e>>22&Yc,a=e<0?Kd:0,Xa(t,i,a)}function Xze(e,t){var i,a;return i=t.kc(),a=Sbe(e,i),!!a&&tl(a.e,t.lc())}function Yze(e){var t;return t=e.e+e.f,isNaN(t)&&l9(e.d)?e.d:t}function Zze(e){this.b=e,Bn.call(this,e),this.a=h(sn(this.b.a,4),116)}function Kze(e){this.b=e,nx.call(this,e),this.a=h(sn(this.b.a,4),116)}function qu(e,t,i,a,l){iGe.call(this,t,a,l),this.c=e,this.b=i}function d0e(e,t,i,a,l){B7e.call(this,t,a,l),this.c=e,this.a=i}function p0e(e,t,i,a,l){O7e.call(this,t,a,l),this.c=e,this.a=i}function g0e(e,t,i,a,l){iGe.call(this,t,a,l),this.c=e,this.a=i}function Jze(e,t){this.d=new G2,this.a=e,this.b=t,this.e=new Do(t.Qe())}function Up(e,t){Kg(),this.e=e,this.d=1,this.a=X(q(In,1),si,22,15,[t])}function hS(e,t){return ws(t)?t==null?Tve(e.d,null):iVe(e.e,t):Tve(e.d,t)}function m0e(e,t,i){var a;return a=e.rg(t),a>=0?e.ug(a,i,!0):Ax(e,t,i)}function H4t(e,t,i){var a;a=(Hn(e),new _f((ru(),e))),FBt(new _ze(a,t,i))}function SI(e,t,i){var a;a=(Hn(e),new _f((ru(),e))),YDt(new yze(a,t,i))}function q4t(e,t,i){var a;return a=jA(i),eP(e.d,a,t,!1),dr(e.e,t,i),t}function X4t(e,t,i){var a;return a=jA(i),eP(e.j,a,t,!1),dr(e.k,t,i),t}function Qze(e,t,i){var a;a=new Age(e.a),wee(a,e.a.a),El(a.d,t,i),e.a.a=a}function OQ(e){var t;return t=new Op,No(t,e),Ee(t,($e(),Lo),null),t}function Ym(e){var t,i;return Hn(e),t=qAt(e.length),i=new Gl(t),qI(i,e),i}function _A(e){var t,i;++e.j,t=e.g,i=e.i,e.g=null,e.i=0,e.uh(i,t),e.th()}function MI(e,t){e.Eh(e.i+1),JC(e,e.i,e.Ch(e.i,t)),e.sh(e.i++,t),e.th()}function P0(e,t){var i;return i=(ai(t,e.c.length),e.c[t]),Dpe(e.c,t,1),i}function NQ(e,t,i,a){var l;return l=le(In,si,22,t+1,15,1),S7t(l,e,t,i,a),l}function b0e(e,t,i,a){var l;for(l=0;lt.o?-1:0}function g_(e,t){if(e<0||e>t)throw Y(new Ra("Index: "+e+", Size: "+t))}function x0e(e,t,i){if(e<0||t>i||t=t)throw Y(new Ra("Index: "+e+", Size: "+t))}function Q4t(e,t){var i;i=e.q.getHours()+(t/60|0),e.q.setMinutes(t),fP(e,i)}function oU(e,t,i){this.a=e,this.b=t,this.c=i,De(e.q,this),De(t.g,this)}function TI(e,t,i,a){this.f=e,this.e=t,this.d=i,this.b=a,this.c=a?a.d:null}function E0e(e){lVe.call(this,e,0),OFe(this),this.b.b=this.b,this.b.a=this.b}function S0e(e,t){j8.call(this,t.rd(),t.qd()&-65),dn(e),this.a=e,this.c=t}function PGe(e,t,i){this.d=(dn(e),e),this.a=i&W0?i:i|64|Ah,this.c=t}function aU(){this.b=new Ir,this.a=new Ir,this.b=new Ir,this.a=new Ir}function LGe(){LGe=M,pot=jc(Ai(new ss,(_o(),Dh),(Ao(),kse)),qo,hG)}function kGe(){kGe=M,got=Ai(Ai(new ss,(_o(),Dh),(Ao(),qP)),Qa,fM)}function UQ(e,t){return!e.o&&(e.o=new il((Ta(),op),pm,e,0)),nte(e.o,t)}function ekt(e,t){ii(t,"Label management",1),$E(G(e,(FQ(),K5))),On(t)}function tkt(e,t){var i;return i=e.c,t>0?h(St(i.a,t-1),8):null}function zQ(e){var t;return t=e.b,t.b==0?null:h(qg(t,0),170).b}function M0e(e){var t,i,a,l;l=e.d,t=e.a,i=e.b,a=e.c,e.d=i,e.a=a,e.b=l,e.c=t}function nkt(e,t){var i;e.A&&(i=h(Ds(e.b,t),114).n,i.d=e.A.d,i.a=e.A.a)}function GQ(e,t,i){var a,l;if(i!=null)for(a=0;a=0,"Initial capacity must not be negative")}function DGe(e){this.b=(Yr(),new ui),this.c=new ui,this.d=new ui,this.a=e}function BGe(e){e?(this.c=e,this.b=null):(this.c=null,this.b=new ke)}function jQ(e,t){S8.call(this,e,t),this.a=le(lVt,et,398,2,0,1),this.b=!0}function $Q(e,t,i){return bne(e,t,i,re(t,62)&&(h(h(t,17),62).Bb&oo)!=0)}function dkt(e,t,i){return hP(e,t,i,re(t,62)&&(h(h(t,17),62).Bb&oo)!=0)}function pkt(e,t,i){return C8t(e,t,i,re(t,62)&&(h(h(t,17),62).Bb&oo)!=0)}function gkt(e,t){return to(ce(Xe(G(e,(Ie(),tb)))),ce(Xe(G(t,tb))))}function mkt(){return kS(),X(q(jse,1),Oe,290,0,[SSe,mG,gG,ESe,dG,pG])}function bkt(){return d7(),X(q(LSe,1),Oe,241,0,[Xse,qse,Zse,Yse,Kse,wG])}function wkt(){return g6(),X(q(BSe,1),Oe,255,0,[vG,RSe,DSe,kSe,ISe,Jse])}function vkt(){return IS(),X(q(GSe,1),Oe,256,0,[ZP,NSe,zSe,USe,FSe,OSe])}function _kt(){return u7(),X(q(hTe,1),Oe,291,0,[Eoe,uTe,xoe,lTe,fTe,GG])}function ykt(){return Ms(),X(q(dAe,1),Oe,83,0,[fb,sp,g3,p3,vd,Oa])}function xkt(){return nP(),X(q(Tat,1),Oe,308,0,[QG,Doe,Ooe,Boe,Noe,Ioe])}function Ekt(){return ud(),X(q(gCe,1),Oe,224,0,[Qoe,J5,Q5,fj,lj,uj])}function Skt(){return f7(),X(q(sAe,1),Oe,289,0,[bae,nAe,rAe,eAe,iAe,tAe])}function OGe(){OGe=M,Uat=$A($A(Gpe(new ss,(PS(),dL)),(nP(),QG)),Doe)}function cU(){cU=M,new Sr("org.eclipse.elk.addLayoutConfig"),rct=new P2}function NGe(){NGe=M,I7(),iPe=Jr,Eut=Ts,rPe=new Kb(Jr),Sut=new Kb(Ts)}function FGe(e,t,i){vi();var a;return a=em(e,t),i&&a&&HAt(e)&&(a=null),a}function le(e,t,i,a,l,f){var g;return g=IHe(l,a),l!=10&&X(q(e,f),t,i,l,g),g}function Mkt(e,t,i){return kNe((lA(),new K9(cWe(X(q(on,1),et,1,5,[e,t,i])))))}function UGe(e,t){var i;return i=t.kc(),Yr(),new DR(i,nqe(e.e,i,h(t.lc(),13)))}function zGe(e,t){var i,a;return i=e.a-t.a,a=e.b-t.b,w.Math.sqrt(i*i+a*a)}function T0e(e,t,i){var a;a=e.b[i.c.o][i.o],a.b+=t.b,a.c+=t.c,a.a+=t.a,++a.a}function Tkt(e,t,i){var a,l;return l=e.length,a=i=e.i)throw Y(new JK(t,e.i));return e.g[t]}function jGe(e,t,i){if(DA(e,i),i!=null&&!e.Li(i))throw Y(new AR);return i}function Mh(e,t){return tQ(t,"Horizontal alignment cannot be null"),e.b=t,e}function AI(e,t){var i;return i=e.rg(t),i>=0?e.ug(i,!0,!0):Ax(e,t,!0)}function PI(e,t,i){var a,l;return l=(a=OS(e.b,t),a),l?B7(OI(e,l),i):null}function Ckt(e){return re(e,159)?""+h(e,159).a:e==null?null:Ga(e)}function Akt(e){return re(e,159)?""+h(e,159).a:e==null?null:Ga(e)}function pS(e){var t;return $o(e)&&(t=0-e,!isNaN(t))?t:zg(_S(e))}function Pkt(e){var t;return e=e>2?e:2,t=gbe(e),e>t?(t<<=1,t>0?t:Rx):t}function LI(e){var t,i;return t=e+128,i=(A8e(),u3e)[t],!i&&(i=u3e[t]=new dY(e)),i}function yA(e,t){return FI(t)!=10&&X(sl(t),t.rl,t.__elementTypeId$,FI(t),e),e}function m_(e,t){return t.e==0||e.e==0?cM:(DS(),Qte(e,t))}function Lkt(e){for(;!e.a;)if(!U0e(e.b,new TY(e)))return!1;return!0}function kkt(e){for(;!e.a;)if(!O8e(e.c,new PY(e)))return!1;return!0}function $Ge(e,t){if(t.a)throw Y(new na(HJe));Cr(e.a,t),t.a=e,!e.j&&(e.j=t)}function VQ(e,t,i,a,l,f){e0e.call(this,t,a,l,f),this.c=e,this.b=i}function VGe(e,t,i,a,l,f){e0e.call(this,t,a,l,f),this.c=e,this.a=i}function il(e,t,i,a){this.Gi(),this.a=t,this.b=e,this.c=new o1e(this,t,i,a)}function kI(e,t){this.e=t,this.a=m$e(e),this.a<54?this.f=cS(e):this.c=s6(e)}function Rkt(e,t){e.a.Ld(t.d,e.b)>0&&(De(e.c,new Ome(t.c,t.d,e.d)),e.b=t.d)}function WQ(e){e.a=le(In,si,22,e.b+1,15,1),e.c=le(In,si,22,e.b,15,1),e.d=0}function WGe(){WGe=M,Xnt=Ui((uU(),X(q(Vz,1),Oe,278,0,[nse,D3e,B3e,O3e])))}function HGe(){HGe=M,iot=Ui((_w(),X(q(Moe,1),Oe,179,0,[jG,Soe,_y,vy])))}function qGe(){qGe=M,Vit=Ui((yS(),X(q($it,1),Oe,373,0,[Q0,Nw,Ow,fy])))}function XGe(){XGe=M,rit=Ui((Sx(),X(q(iit,1),Oe,304,0,[m5,g5,b5,w5])))}function YGe(){YGe=M,oit=Ui((YA(),X(q(sit,1),Oe,362,0,[v5,qz,Xz,_5])))}function ZGe(){ZGe=M,Mat=Ui((PS(),X(q(ITe,1),Oe,360,0,[JG,dL,q5,pL])))}function KGe(){KGe=M,nct=Ui((i7(),X(q(cCe,1),Oe,320,0,[Zoe,oCe,aCe,sCe])))}function JGe(){JGe=M,Act=Ui((Yd(),X(q(QCe,1),Oe,226,0,[wj,xL,h3,EL])))}function QGe(){QGe=M,Pct=Ui((ld(),X(q(mae,1),Oe,197,0,[gae,pae,EM,lb])))}function eje(){eje=M,jct=Ui((Hl(),X(q(AL,1),Oe,344,0,[lD,C1,cD,pb])))}function tje(){tje=M,Slt=Ui((I0(),X(q(Elt,1),Oe,374,0,[dD,hD,Sae,Mae])))}function nje(){nje=M,Vct=Ui((XU(),X(q(yAe,1),Oe,288,0,[yae,wAe,_Ae,vAe])))}function ije(){ije=M,qct=Ui((xl(),X(q(Hct,1),Oe,265,0,[fD,Ed,dm,uD])))}function rl(){rl=M,Uh=new ZK(XS,0),gb=new ZK(MP,1),cf=new ZK(YS,2)}function RI(){RI=M,LTe=new sge(H0,0),ZG=new sge("IMPROVE_STRAIGHTNESS",1)}function lU(){lU=M,XTe=new age("LEAF_NUMBER",0),qoe=new age("NODE_SIZE",1)}function uU(){uU=M,nse=new M8("All",0),D3e=new WNe,B3e=new nFe,O3e=new HNe}function Vc(e){return e.b||(e.b=new lFe(ko,e),!e.a&&(e.a=new sI(e,e))),e.b}function II(e,t){if(t<0)throw Y(new Ra(eet+t));return dze(e,t+1),St(e.j,t)}function px(e){var t;if(!S_(e))throw Y(new K);return e.d=1,t=e.c,e.c=null,t}function fU(e){var t,i;return i=e.length,t=le(Zl,Ph,22,i,15,1),V9e(e,0,i,t,0),t}function HQ(e,t){var i;this.f=e,this.b=t,i=h(Ii(e.b,t),264),this.c=i?i.b:null}function Ikt(e,t,i){var a;return a=xVe(e,t,i),e.b=new dee(a.c.length),Yve(e,a)}function Dkt(e,t){var i;return i=h(AS(e.d,t),13),i?nqe(e.e,t,i):null}function L0e(e,t){var i;return i=h(hS(e.c,t),353),i?(zme(i),i.e):null}function Bkt(e){var t,i;if(!e.b)return null;for(i=e.b;t=i.a[0];)i=t;return i}function Okt(e,t,i){var a;return a=jA(i),eP(e.g,a,t,!1),eP(e.i,t,i,!1),t}function DI(e,t,i,a){var l;a=(sS(),a||C3e),l=e.slice(t,i),pve(l,e,t,i,-t,a)}function jl(e,t,i,a,l){return t<0?Ax(e,i,a):h(i,61).aj().cj(e,e.Qg(),t,a,l)}function Nkt(e,t){return t0?zi:Ma(e,zs)<0?zs:nr(e)}function jkt(e,t){if(!e)throw Y(new un(e9t("Enum constant undefined: %s",t)))}function hU(e){q8(this),this.g=e?$Ue(e,e.Od()):null,this.f=e,z9(this),this.Pd()}function Wd(e,t,i,a,l,f,g){lee.call(this,t,a,l,f,g),this.c=e,this.b=i}function ad(e,t,i){var a,l;for(a=10,l=0;l=0?(e.gd(i),!0):!1}function QQ(e,t){var i;return i=br(e.d,t),i>=0?t7(e,i,!0,!0):Ax(e,t,!0)}function Hkt(e,t){var i;for(i=0;e.e!=e.i._b();)sMt(t,Yn(e),He(i)),i!=zi&&++i}function oje(e,t){var i,a,l;for(l=0,a=e.tc();a.hc();)i=a.ic(),Gr(t,l++,i);return t}function Og(e,t,i){var a;if(t==null)throw Y(new F2);return a=Hm(e,t),v4t(e,t,i),a}function Ng(e){if(e<0)throw Y(new un("tolerance ("+e+") must be >= 0"));return e}function eee(e){var t;return t=e.b.c.length==0?null:St(e.b,0),t!=null&&ibe(e,0),t}function aje(e,t){var i,a,l;for(a=0,l=t.length;a=e.a.c.length;)De(e.a,new Ir);return h(St(e.a,t),15)}function Xkt(e){return Bwe(e,(gS(),c3e))<0?-uMt(_S(e)):e.l+e.m*Nx+e.h*l1}function cje(e){var t,i;return t=e/60|0,i=e%60,i==0?""+t:""+t+":"+(""+i)}function Ykt(e,t){var i;return i=U6t(e.e.c,t.e.c),i==0?to(e.e.d,t.e.d):i}function mx(e,t){var i=e.a[t],a=(Bee(),Kre)[typeof i];return a?a(i):Ibe(typeof i)}function lje(e,t){return t==(DJ(),DJ(),qnt)?e.toLocaleLowerCase():e.toLowerCase()}function FI(e){return e.__elementTypeCategory$==null?10:e.__elementTypeCategory$}function N0e(e){return(e.i&2?"interface ":e.i&1?"":"class ")+(Fd(e),e.o)}function Zkt(e,t,i){var a;return a=e.a.e[h(t.a,8).o]-e.a.e[h(i.a,8).o],yr(s9e(a))}function uje(e,t){var i;for(++e.d,++e.c[t],i=t+1;i=0&&te||e>t)throw Y(new gpe("fromIndex: 0, toIndex: "+e+rye+t))}function bU(e,t){var i,a;for(a=e.tc();a.hc();)i=h(a.ic(),68),Ee(i,(Ie(),t3),t)}function nRt(e,t,i){var a;a=w.Math.max(0,e.b/2-.5),ZA(i,a,1),De(t,new TOe(i,a))}function iRt(e){var t;return t=ce(Xe(G(e,($e(),tp)))),t<0&&(t=0,Ee(e,tp,t)),t}function v_(e){r9();var t,i;for(i=q2e,t=0;ti&&(i=e[t]);return i}function rRt(){iBe();for(var e=Vre,t=0;t=e.i)throw Y(new JK(t,e.i));return e.zh(t,e.g[t])}function Rje(e,t,i){if(DA(e,i),!e.Nj()&&i!=null&&!e.Li(i))throw Y(new AR);return i}function SA(e,t){var i;for(i=e;eo(i);)if(i=eo(i),i==t)return!0;return!1}function cRt(e,t){return t&&e.b[t.g]==t?(Gr(e.b,t.g,null),--e.c,!0):!1}function Xu(e,t){var i;return i=t.c,t.a.b=t.b,t.b.a=t.a,t.a=t.b=null,t.c=null,--e.b,i}function cd(e,t){var i,a,l,f;for(dn(t),a=e.c,l=0,f=a.length;l>5,l=t&31,a=Kr(c_(e.n[i][f],nr(jd(l,1))),3),a}function Ije(e,t){for(;t[0]=0;)++t[0]}function Dje(e,t){a9.call(this),j0e(this),this.a=e,this.c=!0,this.b=t.d,this.f=t.e}function Bje(e,t){return xh(),Ng(tm),w.Math.abs(e-t)<=tm||e==t||isNaN(e)&&isNaN(t)}function G0e(e){return e.a<54?e.f<0?-1:e.f>0?1:0:(!e.c&&(e.c=ZI(e.f)),e.c).e}function Oje(e){return e.c&&e.d?e.c.g+"("+e.c+")->"+e.d.g+"("+e.d+")":"e_"+g0(e)}function Nje(e,t,i){var a,l;a=t;do l=ce(e.p[a.o])+i,e.p[a.o]=l,a=e.a[a.o];while(a!=t)}function uRt(e,t,i){var a,l,f;for(l=t[i],a=0;a=14&&t<=16))),e}function iee(e,t){Mo();var i;for(Hn(e),Hn(t),i=!1;t.hc();)i=i|e.nc(t.ic());return i}function Sf(e,t){if(e<0)throw Y(new un(t+" cannot be negative but was: "+e));return e}function ree(e,t){var i,a;for(a=new j(e);a.ai)throw Y(new o_(t,i));return new Sme(e,t)}function E_(e,t){var i;i=e.s,e.s=t,e.Db&4&&!(e.Db&1)&&Li(e,new LQ(e,4,i,e.s))}function mS(e,t){var i;i=e.t,e.t=t,e.Db&4&&!(e.Db&1)&&Li(e,new LQ(e,5,i,e.t))}function $0e(e,t){var i;i=e.d,e.d=t,e.Db&4&&!(e.Db&1)&&Li(e,new LQ(e,2,i,e.d))}function aee(e,t){var i;i=e.F,e.F=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,5,i,t))}function hRt(e,t){var i,a,l;return i=(a=(d0(),l=new ZT,l),t&&kYe(a,t),a),i$e(i,e),i}function k0(){k0=M,HG=new jK("BARYCENTER",0),lL=new jK(EQe,1),qG=new jK(SQe,2)}function wU(){wU=M,TSe=new RK("ARD",0),bG=new RK("MSD",1),$se=new RK("MANUAL",2)}function Oo(){Oo=M,WG=new NK(zx,0),Fc=new NK("INPUT",1),lc=new NK("OUTPUT",2)}function Hje(){Vu(),this.b=(Yr(),new ui),this.f=new ui,this.g=new ui,this.e=new ui}function V0e(e,t,i,a,l){this.d=t,this.k=a,this.f=l,this.o=-1,this.p=1,this.c=e,this.a=i}function W0e(e,t,i,a,l){this.d=t,this.k=a,this.f=l,this.o=-1,this.p=2,this.c=e,this.a=i}function H0e(e,t,i,a,l){this.d=t,this.k=a,this.f=l,this.o=-1,this.p=6,this.c=e,this.a=i}function q0e(e,t,i,a,l){this.d=t,this.k=a,this.f=l,this.o=-1,this.p=7,this.c=e,this.a=i}function X0e(e,t,i,a,l){this.d=t,this.j=a,this.e=l,this.o=-1,this.p=4,this.c=e,this.a=i}function Y0e(e,t){return xh(),Ng(tm),w.Math.abs(e-t)<=tm||e==t||isNaN(e)&&isNaN(t)}function dRt(){return A7(),X(q(sEe,1),Oe,228,0,[rEe,eEe,tEe,Q3e,ose,iEe,nEe,J3e,K3e])}function pRt(){return a1(),X(q(Ys,1),Oe,86,0,[Mu,Nh,Cu,If,af,of,Ll,Au,Tu])}function gRt(){return cc(),X(q(bAe,1),Oe,239,0,[SM,PL,xj,LL,Ej,Sj,b3,_ae,yj])}function qje(){qje=M,Nnt=X(q(In,1),si,22,15,[0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15])}function Xje(){Xje=M,Sot=jc(Ai(Ai(new ss,(_o(),Qa),(Ao(),Dse)),ec,Rse),qo,Ise)}function cee(){return Joe||(Joe=new fZe,kA(Joe,X(q(WP,1),et,154,0,[new XX]))),Joe}function bo(e,t,i){return ES(e,t),Mf(e,i),E_(e,0),mS(e,1),A_(e,!0),C_(e,!0),e}function Yje(e,t){var i;return re(t,38)?e.c.vc(t):(i=nte(e,t),a6(e,t),i)}function pr(e){var t;return re(e,78)?e:(t=e&&e[jne],t||(t=new wWe(e),Vi(t)),t)}function Z0e(e){var t,i;if(e==0)return 32;for(i=0,t=1;!(t&e);t<<=1)++i;return i}function mRt(e,t){var i;return i=e.c,t=0),A5t(e.d,e.c)<0&&(e.a=e.a-1&e.d.a.length-1,e.b=e.d.c),e.c=-1}function uee(e,t){e.j>0&&e.c0&&e.e!=0&&uee(e.g,t/e.j*e.g.d))}function t$e(e,t){var i;i=e.c,e.c=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,1,i,e.c))}function n$e(e,t){var i;i=e.b,e.b=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,0,i,e.b))}function jI(e,t){var i;i=e.k,e.k=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,2,i,e.k))}function Q0e(e,t){var i;i=e.f,e.f=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,8,i,e.f))}function ebe(e,t){var i;i=e.i,e.i=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,7,i,e.i))}function i$e(e,t){var i;i=e.a,e.a=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,8,i,e.a))}function r$e(e,t){var i;i=e.d,e.d=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,1,i,e.d))}function s$e(e,t){var i;i=e.c,e.c=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,1,i,e.c))}function tbe(e,t){var i;i=e.c,e.c=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,4,i,e.c))}function fee(e,t){var i;i=e.D,e.D=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,2,i,e.D))}function o$e(e,t){var i;i=e.b,e.b=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,0,i,e.b))}function yRt(e,t,i){var a;e.b=t,e.a=i,a=(e.a&512)==512?new kDe:new Vf,e.c=iUt(a,e.b,e.a)}function a$e(e,t){return G0(e.e,t)?(Yo(),O0e(t)?new y9(t,e):new qR(t,e)):new yNe(t,e)}function LA(e,t){return vt(),ws(e)?qme(e,ti(t)):aw(e)?v9e(e,Xe(t)):ow(e)?sAt(e,mt(t)):e.vd(t)}function xRt(e){var t=/function(?:\s+([\w$]+))?\s*\(/,i=t.exec(e);return i&&i[1]||$ne}function ERt(e,t){var i,a;return i=e.o+e.p,a=t.o+t.p,i>>31;a!=0&&(e[i]=a)}function m$e(e){var t;return Ma(e,0)<0&&(e=tme(e)),t=nr(Pg(e,32)),64-(t!=0?x6(t):x6(nr(e))+32)}function PRt(e){var t,i;for(i=e.c.a.Xb().tc();i.hc();)t=h(i.ic(),204),Tde(t,new U9e(t.f))}function b$e(e){var t,i;for(i=e.c.a.Xb().tc();i.hc();)t=h(i.ic(),204),Cde(t,new pqe(t.e))}function w$e(e){this.d=e,this.c=e.c.Tb().tc(),this.b=null,this.a=null,this.e=(Mo(),Mo(),n3e)}function v$e(e){this.e=e,this.d=new m8(Eee(i1e(this.e)._b())),this.c=this.e.a,this.b=this.e.c}function dee(e){this.b=e,this.a=le(In,si,22,e+1,15,1),this.c=le(In,si,22,e,15,1),this.d=0}function LRt(e){e.a=null,e.e=null,e.b.c=le(on,et,1,0,5,1),e.f.c=le(on,et,1,0,5,1),e.c=null}function Ji(e,t){var i,a;a=(i=new Jge,i),a.n=t,$n((!e.s&&(e.s=new ze(Sc,e,21,17)),e.s),a)}function xr(e,t){var i,a;i=(a=new cK,a),i.n=t,$n((!e.s&&(e.s=new ze(Sc,e,21,17)),e.s),i)}function Mf(e,t){var i;i=e.zb,e.zb=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,1,i,e.zb))}function pee(e,t){var i;i=e.xb,e.xb=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,3,i,e.xb))}function gee(e,t){var i;i=e.yb,e.yb=t,e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,2,i,e.yb))}function mee(e,t,i){var a,l,f;return l=M0(t,"labels"),a=new rNe(e,i),f=(cUt(a.a,a.b,l),l),f}function Ar(e,t,i,a,l,f,g,m,v,y,E,C,R){return oXe(e,t,i,a,l,f,g,m,v,y,E,C,R),$be(e,!1),e}function wo(e,t){var i,a,l;for(dn(t),i=!1,l=t.tc();l.hc();)a=l.ic(),i=i|e.nc(a);return i}function _$e(e){if(e){if(e.Wb())throw Y(new K);return e.cd(e._b()-1)}return gze(null.tc())}function kRt(e){if(dn(e),e.length==0)throw Y(new vh("Zero length BigInteger"));wUt(this,e)}function yU(){yU=M,STe=new UK("NO",0),Poe=new UK("GREEDY",1),ETe=new UK("LOOK_BACK",2)}function bee(){bee=M,BL=new PDe,Iae=X(q(Sc,1),oy,158,0,[]),tut=X(q(uf,1),Fxe,53,0,[])}function y$e(){y$e=M,Jit=Ui((Xt(),X(q(xse,1),Oe,232,0,[hs,Nr,Qr,oa,ul,$a,rh])))}function RRt(){return xo(),X(q(Qse,1),Oe,233,0,[_G,Su,KP,yG,dy,py,C5,hM,dM,xG])}function IRt(e,t){return yS(),e==Q0&&t==Nw||e==Nw&&t==Q0||e==fy&&t==Ow||e==Ow&&t==fy}function DRt(e,t){return yS(),e==Q0&&t==Ow||e==Q0&&t==fy||e==Nw&&t==fy||e==Nw&&t==Ow}function x$e(e,t){return ce(Xe(hJ(t6(Yf(new oi(null,new di(e.c.b,16)),new jF(e)),t))))}function obe(e,t){return ce(Xe(hJ(t6(Yf(new oi(null,new di(e.c.b,16)),new Ws(e)),t))))}function E$e(e,t){t?e.B==null&&(e.B=e.D,e.D=null):e.B!=null&&(e.D=e.B,e.B=null)}function BRt(e){var t;return re(e,182)?(t=h(e,182),new ppe(t.a)):(Mo(),new hR(e))}function S$e(e){var t;return t=rze(e),rw(t.a,0)?(NE(),NE(),k3e):(NE(),new Hge(t.b))}function M$e(e){var t;return t=rze(e),rw(t.a,0)?(NE(),NE(),k3e):(NE(),new Hge(t.c))}function T$e(e){Jme.call(this),this.b=ce(Xe(G(e,($e(),sh)))),this.a=h(G(e,cm),197)}function C$e(){this.c=new w8(0),this.b=new w8(VQe),this.d=new w8($Qe),this.a=new w8(Cie)}function xU(e){this.b=(Hn(e),new _f((ru(),e))),this.a=new ke,this.d=new ke,this.e=new fo}function qd(){qd=M,Sse=new hc,Ese=new Js,kEe=new w2,LEe=new dc,REe=new km,IEe=new v2}function EU(){EU=M,Vse=new IK("GREEDY",0),ASe=new IK("DEPTH_FIRST",1),Wse=new IK(Die,2)}function eh(){eh=M,Ty=new XK("OUTSIDE",0),hb=new XK("INSIDE",1),_j=new XK("FIXED",2)}function A$e(){A$e=M,Mot=$A(pSt(Ai(Ai(new ss,(_o(),Qa),(Ao(),Dse)),ec,Rse),qo),Ise)}function ORt(e){return e.b.c.g.j==(Xt(),Qr)?h(G(e.b.c.g,(Ie(),Jn)),11):e.b.c}function P$e(e){return e.b.d.g.j==(Xt(),Qr)?h(G(e.b.d.g,(Ie(),Jn)),11):e.b.d}function L$e(e){var t;if(e.b==-2){if(e.e==0)t=-1;else for(t=0;e.a[t]==0;t++);e.b=t}return e.b}function k$e(e){var t,i,a;for(t=0,a=e.tc();a.hc();)i=a.ic(),t+=i!=null?Hr(i):0,t=~~t;return t}function abe(e,t,i){var a,l;for(l=Nn(e,0);l.b!=l.d.c;)a=h(Un(l),9),a.a+=t,a.b+=i;return e}function $I(e){var t,i,a;for(t=0,a=e.tc();a.hc();)i=Xe(a.ic()),t+=(dn(i),i);return t/e._b()}function R$e(e){var t;return e==0?"UTC":(e<0?(e=-e,t="UTC+"):t="UTC-",t+cje(e))}function NRt(e,t){_t();var i,a;for(a=new ke,i=0;i0&&(this.g=this.Fh(this.i+(this.i/8|0)+1),e.zc(this.g))}function D$e(e,t){return xh(),Ng(gd),w.Math.abs(0-t)<=gd||t==0||isNaN(0)&&isNaN(t)?0:e/t}function ps(e,t){b9.call(this,nut,e,t),this.b=this,this.a=cl(e.mg(),Wt(this.e.mg(),this.c))}function VI(e,t){var i,a;for(a=t.length,i=0;il&&t.af&&t.b1||e.hc())return++e.a,e.g=0,t=e.i,e.hc(),t;throw Y(new K)}function W$e(e){var t;e.d==null?(++e.e,e.f=0,$Ve(null)):(++e.e,t=e.d,e.d=null,e.f=0,$Ve(t))}function TU(e,t){var i;re(t,109)?(h(e.c,81).ij(),i=h(t,109),l$e(e,i)):h(e.c,81).Gc(t)}function R0(e){return re(e,193)?xI(h(e,193)):re(e,160)?h(e,160).a:re(e,49)?new Hv(e):new UE(e)}function qRt(e,t,i){return e==(k0(),qG)?new Vb:al(t,1)!=0?new Mpe(i.length):new dBe(i.length)}function Li(e,t){var i,a,l;if(i=e.cg(),i!=null&&e.fg())for(a=0,l=i.length;a=128?!1:e<64?kC(Kr(jd(1,e),i),0):kC(Kr(jd(1,e-64),t),0)}function eIt(e){var t;return t=h(G(e,(Ie(),pa)),69),e.j==(Xt(),Qr)&&(t==(Fe(),nn)||t==Zt)}function xee(e,t){var i;return re(t,13)?(i=(ru(),h(t,13)),e.oc(i)):iee(e,h(Hn(t),20).tc())}function tIt(e){GNe();var t;return gOe(Roe,e)||(t=new nu,t.a=e,TJ(Roe,e,t)),h(Ds(Roe,e),573)}function Eee(e){return Yr(),e<3?(Sf(e,"expectedSize"),e+1):e>22),l=e.h+t.h+(a>>22),Xa(i&Yc,a&Yc,l&Kd)}function tVe(e,t){var i,a,l;return i=e.l-t.l,a=e.m-t.m+(i>>22),l=e.h-t.h+(a>>22),Xa(i&Yc,a&Yc,l&Kd)}function Mee(e,t,i,a){return i==1?(!e.n&&(e.n=new ze(ea,e,1,7)),Us(e.n,t,a)):sve(e,t,i,a)}function nVe(e,t){if(t==null)return!1;for(;e.a!=e.b;)if(ki(t,DU(e)))return!0;return!1}function hbe(e){return e.a.hc()?!0:e.a!=e.d?!1:(e.a=new F1e(e.e.d),e.a.hc())}function Lr(e,t){var i,a;return i=t.yc(),a=i.length,a==0?!1:(Nme(e.c,e.c.length,i),!0)}function oIt(e,t,i){var a,l;for(l=t.Tb().tc();l.hc();)a=h(l.ic(),38),e.Yb(a.kc(),a.lc(),i);return e}function iVe(e,t){var i;return i=e.a.get(t),i===void 0?++e.d:(e.a[hie](t),--e.c,EJ(e.b)),i}function wS(e,t){this.b=e,this.e=t,this.d=t.j,this.f=(Yo(),h(e,61).bj()),this.k=cl(t.e.mg(),e)}function rVe(e){this.o=e,this.g=new ke,this.j=new Ir,this.n=new Ir,this.e=new ke,this.b=new ke}function sVe(e){this.a=le(xot,be,1704,e.length,0,2),this.b=le(Eot,be,1705,e.length,0,2),this.c=new LWe}function aIt(e,t){e.d==(qs(),rf)||e.d==hm?h(t.a,57).c.nc(h(t.b,57)):h(t.b,57).c.nc(h(t.a,57))}function oVe(e,t){var i,a;for(a=new j(e.b);a.at?1:e==t?0:isNaN(e)?isNaN(t)?0:1:-1}function cVe(e,t){return!e||!t||e==t?!1:WWe(e.d.c,t.d.c+t.d.b)&&WWe(t.d.c,e.d.c+e.d.b)}function lVe(e,t){u9(e>=0,"Negative initial capacity"),u9(t>=0,"Non-positive load factor"),nl(this)}function uVe(e){var t,i;return i=(t=new jk,t),Mf(i,"T"),$n((!e.d&&(e.d=new Nl(fl,e,11)),e.d),i),i}function fVe(e,t){var i;return i=ed(t.a._b()),Fa(Cje(new oi(null,new di(t,1)),e.i),new eNe(e,i)),i}function dbe(e){var t,i,a;for(t=new Ir,a=Nn(e.d,0);a.b!=a.d.c;)i=h(Un(a),170),Gi(t,i.c);return t}function pbe(e){var t,i,a,l;for(t=1,i=0,l=e._b();i>=1);return t}function lIt(e){var t;return t=xw(e),t>eye?Jr:t<-34028234663852886e22?Ts:t}function X(e,t,i,a,l){return l.ql=e,l.rl=t,l.sl=T,l.__elementTypeId$=i,l.__elementTypeCategory$=a,l}function vS(e,t,i,a,l){var f,g;for(g=i;g<=l;g++)for(f=t;f<=a;f++)L_(e,f,g)||P7(e,f,g,!0,!1)}function uIt(e){var t,i,a,l;for(i=e.a,a=0,l=i.length;ae.f,i=e.u+e.e[e.o.o]*e.d>e.f*e.s*e.d,t||i}function kU(e,t,i){var a,l;return a=new jQ(t,i),l=new se,e.b=WYe(e,e.b,a,l),l.b||++e.c,e.b.b=!1,l.d}function vbe(e){var t;return(!e.c||!(e.Bb&1)&&e.c.Db&64)&&(t=pu(e),re(t,96)&&(e.c=h(t,24))),e.c}function $g(e){var t,i;for(i=new j(e.a.b);i.a=0&&e[a]===t[a];a--);return a<0?0:_K(Kr(e[a],ao),Kr(t[a],ao))?-1:1}function yIt(e){var t;return e==null?!0:(t=e.length,t>0&&e.charCodeAt(t-1)==58&&!Ree(e,IL,DL))}function OA(e){switch(e.g){case 1:return $Qe;default:case 2:return 0;case 3:return Cie;case 4:return VQe}}function Lee(e){switch(e._b()){case 0:return e3e;case 1:return new a8e(e.tc().ic());default:return new K9(e)}}function xIt(e,t){Mo();var i,a;for(A1e(t,"predicate"),a=0;e.hc();a++)if(i=e.ic(),t.Mb(i))return a;return-1}function EIt(e,t,i){if(Hn(t),i.hc())for(Vpe(t,e.Lb(i.ic()));i.hc();)Vpe(t,e.c),Vpe(t,e.Lb(i.ic()));return t}function kee(e,t){var i;return t===e?!0:re(t,238)?(i=h(t,238),ki(e.Hc(),i.Hc())):!1}function Ma(e,t){var i;return $o(e)&&$o(t)&&(i=e-t,!isNaN(i))?i:Bwe($o(e)?fu(e):e,$o(t)?fu(t):t)}function ZI(e){return Kg(),e<0?e!=-1?new hwe(-1,-e):ese:e<=10?T3e[yr(e)]:new hwe(1,e)}function SIt(){vi();var e;return Uae||(e=mMt(em("M",!0)),e=C9(em("M",!1),e),Uae=e,Uae)}function T_(e,t,i){var a,l;return l=(a=new oK,a),bo(l,t,i),$n((!e.q&&(e.q=new ze(uf,e,11,10)),e.q),l),l}function Ree(e,t,i){var a,l;for(a=0,l=e.length;a=e.b.c.length||(Cbe(e,2*t+1),i=2*t+2,it)throw Y(new un(q7+e+$Je+t));if(e<0||t>i)throw Y(new gpe(q7+e+sye+t+rye+i))}function TIt(e,t,i){if(t<0)throw Y(new Ra(eet+t));t0)return oA(t-1,e.a.c.length),P0(e.a,t-1);throw Y(new U)}function DVe(e,t){var i;if(t.c.length!=0){for(;ive(e,t);)v7(e,t,!1);i=PU(t),e.a&&(e.a.If(i),DVe(e,i))}}function LIt(e,t){var i,a;for(a=Nn(e,0);a.b!=a.d.c;)i=h(Un(a),204),i.e.length>0&&(t.td(i),i.i&&c6t(i))}function Fee(e,t,i){var a,l,f;for(a=new Ir,f=Nn(i,0);f.b!=f.d.c;)l=h(Un(f),9),Gi(a,new Do(l));n6t(e,t,a)}function BVe(e,t){var i;return i=new sne((e.f&256)!=0,e.i,e.a,e.d,(e.f&16)!=0,e.j,e.g,t),e.e!=null||(i.c=e),i}function kIt(e,t){var i,a;return i=h(e.d.$b(t),13),i?(a=e.e.Oc(),a.oc(i),e.e.d-=i._b(),i.Pb(),a):null}function RU(e){var t,i,a,l;for(l=0,i=0,a=e.length;i1||t>=0&&e.b<3)}function bw(e){var t;++e.j,e.i==0?e.g=null:e.i>>0).toString(16):e.toString()}function Uee(e,t){e.D==null&&e.B!=null&&(e.D=e.B,e.B=null),fee(e,t==null?null:(dn(t),t)),e.C&&e.Kj(null)}function DIt(e,t){var i,a;for(i=e.a.length-1,e.c=e.c-1&i;t!=e.c;)a=t+1&i,Gr(e.a,t,e.a[a]),t=a;Gr(e.a,e.c,null)}function BIt(e,t){var i,a;for(i=e.a.length-1;t!=e.b;)a=t-1&i,Gr(e.a,t,e.a[a]),t=a;Gr(e.a,e.b,null),e.b=e.b+1&i}function OIt(e,t){X8(!this.b),X8(!this.d),cJ(OE(e.c)==0),cJ(t.d.c+t.e.c==0),cJ(!0),this.b=e,this.d=this.ec(t)}function FVe(e,t,i,a,l){a?xBt(e,t):(NBt(e,t,l),YGt(e,t,i)),t.c.length>1&&(_t(),fa(t,e.b),qUt(e.c,t))}function NIt(e,t,i,a,l){t==0||a==0||(t==1?l[a]=lwe(l,i,a,e[0]):a==1?l[t]=lwe(l,e,t,i[0]):xFt(e,i,l,t,a))}function FIt(e){var t,i;if(e==null)return null;for(t=0,i=e.length;t=e.c.b:e.a<=e.c.b))throw Y(new K);return t=e.a,e.a+=e.c.c,++e.b,He(t)}function xS(e){var t,i;return e>-129&&e<128?(t=e+128,i=(L8e(),m3e)[t],!i&&(i=m3e[t]=new EF(e)),i):new EF(e)}function He(e){var t,i;return e>-129&&e<128?(t=e+128,i=(l8e(),h3e)[t],!i&&(i=h3e[t]=new yF(e)),i):new yF(e)}function Gee(e,t){return!e||t&&!e.j||re(e,114)&&h(e,114).a.b==0?0:e.Pf()}function IU(e,t){return!e||t&&!e.k||re(e,114)&&h(e,114).a.a==0?0:e.Qf()}function ki(e,t){return ws(e)?dt(e,t):aw(e)||ow(e)?(dn(e),e===t):Xme(e)?e.Fb(t):$me(e)?e===t:H1e(e,t)}function Hr(e){return ws(e)?Hg(e):aw(e)?yr((dn(e),e)):ow(e)?(dn(e),e?1231:1237):Xme(e)?e.Hb():$me(e)?g0(e):B1e(e)}function sl(e){return ws(e)?Se:aw(e)?Eo:ow(e)?lo:Xme(e)||$me(e)?e.ql:e.ql||Array.isArray(e)&&q(knt,1)||knt}function GIt(e){return e?e.i&1?e==Ru?lo:e==In?Po:e==av?aM:e==ks?Eo:e==R1?K0:e==By?J0:e==Mc?qx:$P:e:null}function ww(){ww=M,ect=(ur(),f3),tct=My,Xoe=(Pve(),qat),Yoe=Xat,iCe=Yat,aj=Zat,cj=Kat,Y5=Jat,rCe=Qat}function jee(){jee=M,vse=c7e(X(q(yL,1),Oe,110,0,[(qs(),rf),sf])),_se=c7e(X(q(yL,1),Oe,110,0,[hm,rp]))}function NA(){NA=M,Tse=new kK("MIRROR_X",0),Cse=new kK("TRANSPOSE",1),Mse=new kK("MIRROR_AND_TRANSPOSE",2)}function jIt(e){var t;return t=new yje(e),SI(e.a,Yit,new Bl(X(q(x5,1),et,341,0,[t]))),t.d&&De(t.f,t.d),t.f}function $It(e){var t,i;for(i=new j(e.r);i.a=48&&e<58?e-48:e>=97&&e<97?e-97+10:e>=65&&e<65?e-65+10:-1}function VIt(e){var t,i;if(e==null)return!1;for(t=0,i=e.length;tkw?e-i>kw:i-e>kw}function no(e,t){var i;return $o(e)&&$o(t)&&(i=e+t,j6a)throw Y(new o_(t,a));if(e.xh()&&e.pc(i))throw Y(new un(s5));e.mh(t,i)}function HVe(e,t,i){if(e<0||t>i)throw Y(new Ra(q7+e+sye+t+", size: "+i));if(e>t)throw Y(new un(q7+e+$Je+t))}function Ibe(e){throw Bee(),Y(new BDe("Unexpected typeof result '"+e+"'; please report this bug to the GWT team"))}function Gp(e){switch(lw(),e.c){case 0:return tS(),GP;case 1:return new $2(u8t(new zE(e)));default:return new DDe(e)}}function qVe(e){var t;return e.Db&64?Ku(e):(t=new su(Ku(e)),t.a+=" (source: ",ho(t,e.d),t.a+=")",t.a)}function Ee(e,t,i){return i==null?(!e.p&&(e.p=(Yr(),new ui)),hS(e.p,t)):(!e.p&&(e.p=(Yr(),new ui)),dr(e.p,t,i)),e}function QI(e,t,i){return i==null?(!e.p&&(e.p=(Yr(),new ui)),hS(e.p,t)):(!e.p&&(e.p=(Yr(),new ui)),dr(e.p,t,i)),e}function e6(e,t,i){var a;e.Eh(e.i+1),a=e.Ch(t,i),t!=e.i&&vc(e.g,t,e.g,t+1,e.i-t),Gr(e.g,t,a),++e.i,e.sh(t,i),e.th()}function Wee(e,t,i){var a,l,f;for(a=0,f=Nn(e,0);f.b!=f.d.c&&(l=ce(Xe(Un(f))),!(l>i));)l>=t&&++a;return a}function Hee(e,t){var i,a,l;for(i=0,l=sa(e,t).tc();l.hc();)a=h(l.ic(),11),i+=G(a,(Ie(),Pl))!=null?1:0;return i}function KIt(e){var t;return t=h(gx(e.c.c,""),199),t||(t=new cx(BE(DE(new Wb,""),"Other")),O0(e.c.c,"",t)),t}function XVe(e){this.a=new Gc,this.d=new Gc,this.b=new Gc,this.c=new Gc,this.g=new Gc,this.i=new Gc,this.f=e}function qs(){qs=M,Oh=new VR(zx,0),sf=new VR(YS,1),rf=new VR(XS,2),rp=new VR(ore,3),hm=new VR("UP",4)}function e1(){e1=M,vj=new qK("INHERIT",0),d3=new qK("INCLUDE_CHILDREN",1),ML=new qK("SEPARATE_CHILDREN",2)}function JIt(e,t,i){var a,l;return a=new Wd(e.e,3,13,null,(l=t.c,l||(yt(),zh)),$p(e,t),!1),i?i.Sh(a):i=a,i}function QIt(e,t,i){var a,l;return a=new Wd(e.e,4,13,(l=t.c,l||(yt(),zh)),null,$p(e,t),!1),i?i.Sh(a):i=a,i}function Dbe(e,t,i){var a,l;return l=e.sb,e.sb=t,e.Db&4&&!(e.Db&1)&&(a=new ls(e,1,4,l,t),i?i.Sh(a):i=a),i}function Bbe(e,t,i){var a,l;return l=e.r,e.r=t,e.Db&4&&!(e.Db&1)&&(a=new ls(e,1,8,l,e.r),i?i.Sh(a):i=a),i}function jp(e,t){var i,a;return i=h(t,614),a=i.Hj(),!a&&i.Ij(a=re(t,96)?new bNe(e,h(t,24)):new H7e(e,h(t,140))),a}function Obe(e,t){var i;return e===t?!0:re(t,89)?(i=h(t,89),e.e==i.e&&e.d==i.d&&y4t(e,i.a)):!1}function e6t(e,t){var i;if(i=T6(e,t),re(i,335))return h(i,29);throw Y(new un(ry+t+"' is not a valid attribute"))}function t6(e,t){var i;return i=new wt,e.a.sd(i)?(HE(),new fK(dn(rje(e,i.a,t)))):(f_(e),HE(),HE(),L3e)}function YVe(e,t){var i;e.c.length!=0&&(i=h(vo(e,le(Eu,Af,8,e.c.length,0,1)),123),vge(i,new _H),IXe(i,t))}function ZVe(e,t){var i;e.c.length!=0&&(i=h(vo(e,le(Eu,Af,8,e.c.length,0,1)),123),vge(i,new yH),IXe(i,t))}function SS(e,t){switch(t.g){case 2:case 1:return sa(e,t);case 3:case 4:return R0(sa(e,t))}return _t(),_t(),uo}function Nbe(e,t,i,a){switch(t){case 1:return!e.n&&(e.n=new ze(ea,e,1,7)),e.n;case 2:return e.k}return Mwe(e,t,i,a)}function t6t(e,t,i,a,l,f,g,m){var v;for(v=i;f=a||t=65&&e<=70?e-65+10:e>=97&&e<=102?e-97+10:e>=48&&e<=57?e-48:0}function QVe(e){return e-=e>>1&1431655765,e=(e>>2&858993459)+(e&858993459),e=(e>>4)+e&252645135,e+=e>>8,e+=e>>16,e&63}function C_(e,t){var i;i=(e.Bb&256)!=0,t?e.Bb|=256:e.Bb&=-257,e.Db&4&&!(e.Db&1)&&Li(e,new qu(e,1,2,i,t))}function eWe(e,t){var i;i=(e.Bb&256)!=0,t?e.Bb|=256:e.Bb&=-257,e.Db&4&&!(e.Db&1)&&Li(e,new qu(e,1,8,i,t))}function Fbe(e,t){var i;i=(e.Bb&256)!=0,t?e.Bb|=256:e.Bb&=-257,e.Db&4&&!(e.Db&1)&&Li(e,new qu(e,1,8,i,t))}function tWe(e,t){var i;i=(e.Bb&512)!=0,t?e.Bb|=512:e.Bb&=-513,e.Db&4&&!(e.Db&1)&&Li(e,new qu(e,1,9,i,t))}function A_(e,t){var i;i=(e.Bb&512)!=0,t?e.Bb|=512:e.Bb&=-513,e.Db&4&&!(e.Db&1)&&Li(e,new qu(e,1,3,i,t))}function UA(e,t){var i;return e.b==-1&&e.a&&(i=e.a.Vi(),e.b=i?e.c.qg(e.a.pi(),i):br(e.c.mg(),e.a)),e.c.hg(e.b,t)}function r6t(e,t,i){var a,l;return l=e.a,e.a=t,e.Db&4&&!(e.Db&1)&&(a=new ls(e,1,5,l,e.a),i?Hwe(i,a):i=a),i}function s6t(e,t){var i;if(i=Lp(e.i,t),i==null)throw Y(new _h("Node did not exist in input."));return lbe(t,i),null}function o6t(e,t){var i;if(i=Ii(e.k,t),i==null)throw Y(new _h("Port did not exist in input."));return lbe(t,i),null}function MS(e){if(e.c)MS(e.c);else if(e.d)throw Y(new ba("Stream already terminated, can't be modified or used"))}function a6t(e){var t;if(!e.a)throw Y(new ba("Cannot offset an unassigned cut."));t=e.c-e.b,e.b+=t,OUe(e,t),NUe(e,t)}function c6t(e){var t;e.g&&(t=e.c.pf()?e.f:e.a,Xve(t.a,e.o,!0),Xve(t.a,e.o,!1),Ee(e.o,($e(),Ki),(Ms(),p3)))}function l6t(e){var t,i,a;for(t=h(G(e,(ha(),DTe)),15),a=t.tc();a.hc();)i=h(a.ic(),170),Gi(i.b.d,i),Gi(i.c.b,i)}function nWe(e){var t,i,a;for(a=0,i=(Mo(),new Nd(Kh(Gd(e.a,new z))));Gn(i);)t=h(Tn(i),14),t.c.g==t.d.g||++a;return a}function iWe(e,t){var i,a;for(a=new Bn(e);a.e!=a.i._b();)if(i=h(Yn(a),24),Be(t)===Be(i))return!0;return!1}function rWe(e,t){var i,a;for(a=new Bn(e);a.e!=a.i._b();)if(i=h(Yn(a),133),Be(t)===Be(i))return!0;return!1}function u6t(e,t,i){var a,l,f;return f=(l=OS(e.b,t),l),f&&(a=h(B7(OI(e,f),""),24),a)?Bve(e,a,t,i):null}function qee(e,t,i){var a,l,f;return f=(l=OS(e.b,t),l),f&&(a=h(B7(OI(e,f),""),24),a)?Ove(e,a,t,i):null}function Ube(e){var t,i;return t=e.j,t==(Xt(),Qr)?(i=h(G(e,(Ie(),pa)),69),i==(Fe(),bn)||i==ni):!1}function sWe(e){var t;return t=new f0,t.a+="VerticalSegment ",Ic(t,e.e),t.a+=" ",Mi(t,lJ(new LR(Ca),new j(e.k))),t.a}function f6t(e){var t,i,a;for(t=new ke,a=new j(e.b);a.a0&&(a+=l,++i);return i>1&&(a+=e.d*(i-1)),a}function x6t(e,t,i){var a,l;for(l=e.a.Xb().tc();l.hc();)if(a=h(l.ic(),8),Gg(i,h(St(t,a.o),13)))return a;return null}function Kee(e,t,i,a){var l;if(l=e.length,t>=l)return l;for(t=t>0?t:0;t=1?sf:rp):i}function S6t(e){var t,i,a;for(t=0,a=new j(e.c.a);a.a=64&&t<128&&(l=Kf(l,jd(1,t-64)));return l}function hWe(e,t,i){var a,l,f;for(l=Cn(t?As(e):fr(e));Gn(l);)a=h(Tn(l),14),f=t?a.c.g:a.d.g,f.j==(Xt(),ul)&&Hs(f,i)}function M6t(e,t,i){var a;a=new Jze(e,t),ir(e.r,t.ef(),a),i&&e.t!=(eh(),_j)&&(a.c=new s7e(e.d),cd(t.We(),new vZ(a)))}function dWe(e,t,i){var a,l;return a=(d0(),l=new gE,l),see(a,t),oee(a,i),e&&$n((!e.a&&(e.a=new vs(ah,e,5)),e.a),a),a}function On(e){if(e.i==null)throw Y(new ba("The task has not begun yet."));e.b||(e.c0&&t.charCodeAt(0)==43?t.substr(1,t.length-1):t))}function P6t(e){var t;return e==null?null:new Tg((t=Ba(e,!0),t.length>0&&t.charCodeAt(0)==43?t.substr(1,t.length-1):t))}function Wbe(e){var t;return t=le(Zl,Ph,22,2,15,1),e-=oo,t[0]=(e>>10)+$6&jr,t[1]=(e&1023)+56320&jr,hu(t,0,t.length)}function L6t(e){var t,i;for(i=d8t($l(dw(e))).tc();i.hc();)if(t=ti(i.ic()),uP(e,t))return j4t((NBe(),Hlt),t);return null}function hu(e,t,i){var a,l,f,g;for(f=t+i,x0e(t,f,e.length),g="",l=t;lt&&a.Ld(e[f-1],e[f])>0;--f)g=e[f],Gr(e,f,e[f-1]),Gr(e,f-1,g)}function R6t(e,t){var i;e.c=t,e.a=z6t(t),e.a<54&&(e.f=(i=t.d>1?Kf(jd(t.a[1],32),Kr(t.a[0],ao)):Kr(t.a[0],ao),cS(Jm(t.e,i))))}function Jee(){Ywe();var e,t,i;i=cVt+++Y4t(),e=yr(w.Math.floor(i*W6))&H7,t=yr(i-e*iye),this.a=e^1502,this.b=t^die}function I6t(e,t,i){e.n=uw(R1,[be,tye],[378,22],14,[i,yr(w.Math.ceil(t/32))],2),e.o=t,e.p=i,e.j=t-1>>1,e.k=i-1>>1}function D6t(e,t){var i,a,l;a=p_(t),l=ce(Xe(CS(a,($e(),sh)))),i=w.Math.max(0,l/2-.5),ZA(t,i,1),De(e,new COe(t,i))}function pWe(e,t){var i,a;for(i=Nn(e,0);i.b!=i.d.c;){if(a=ce(Xe(Un(i))),a==t)return;if(a>t){lS(i);break}}QE(i,t)}function zt(e,t){var i,a,l,f,g;if(i=t.f,O0(e.c.d,i,t),t.g!=null)for(l=t.g,f=0,g=l.length;ft?1:$8(isNaN(e),isNaN(t))}function wWe(e){Qs(),q8(this),z9(this),this.e=e,e!=null&&DFe(e,jne,this),this.g=e==null?Xc:Ga(e),this.a="",this.b=e,this.a=""}function GA(e){var t;this.a=(t=h(e.e&&e.e(),10),new Oc(t,h(el(t,t.length),10),0)),this.b=le(on,et,1,this.a.a.length,5,1)}function $U(e,t){var i,a;return i=e._b(),t.lengthi&&Gr(t,i,null),t}function Xbe(e){var t,i,a;for(a=new Tp,a.a+="[",t=0,i=e._b();t>5,t=e&31,a=le(In,si,22,i+1,15,1),a[i]=1<f?t:f;return He(t)}function V6t(e,t){var i,a;for(a=e.e.a.Xb().tc();a.hc();)if(i=h(a.ic(),247),JOt(t,i.d)||nFt(t,i.d))return!0;return!1}function vWe(e,t){var i,a,l,f;for(f=e.g.ed(),i=0;f.hc();){if(a=ce(Xe(f.ic())),l=a-t,l>ey)return i;l>hz&&++i}return i}function _We(e,t){var i,a,l;l=t.d.g,a=l.j,!(a==(Xt(),hs)||a==$a||a==rh)&&(i=Cn(fr(l)),Gn(i)&&dr(e.k,t,h(Tn(i),14)))}function yWe(e,t){var i,a;i=t==(JA(),Fse),a=Zbe(e),i&&!a||!i&&a?Ee(e,($e(),Bh),(ud(),Q5)):Ee(e,($e(),Bh),(ud(),J5))}function ld(){ld=M,gae=new D8(zx,0),pae=new D8("POLYLINE",1),EM=new D8("ORTHOGONAL",2),lb=new D8("SPLINES",3)}function VU(){VU=M,Hoe=new WK("OVERLAP_REMOVAL",0),Voe=new WK("COMPACTION",1),Woe=new WK("GRAPH_SIZE_CALCULATION",2)}function WU(){WU=M,_Te=new FK("EQUALLY_DISTRIBUTED",0),Aoe=new FK("NORTH_STACKED",1),yTe=new FK("NORTH_SEQUENCE",2)}function W6t(e){var t,i,a,l,f;return f=Zwe(e),i=x8(e.c),a=!i,a&&(l=new Om,Og(f,"knownLayouters",l),t=new jZ(l),mo(e.c,t)),f}function H6t(e,t,i){var a,l;for(l=re(t,62)&&h(h(t,17),62).Bb&oo?new QK(t,e):new wS(t,e),a=0;a3;)l*=10,--f;e=(e+(l>>1))/l|0}return a.i=e,!0}function _x(e,t,i){var a,l;for(l=e.tc();l.hc();)if(a=l.ic(),Be(t)===Be(a)||t!=null&&ki(t,a))return i&&l.jc(),!0;return!1}function AWe(e,t){var i,a;if(t){for(i=0;i0&&(t.lengthe.i&&Gr(t,e.i,null),t}function PWe(e,t){var i,a,l,f;return i=t>>5,t&=31,l=e.d+i+(t==0?0:1),a=le(In,si,22,l,15,1),wOt(a,e.a,i,t),f=new l_(e.e,l,a),gA(f),f}function qU(e,t){oge();var i,a;return i=oI((Wf(),Wf(),jP)),a=null,t==i&&(a=h(za(s3e,e),556)),a||(a=new tUe(e),t==i&&Ko(s3e,e,a)),a}function br(e,t){var i,a,l;if(i=(e.i==null&&Jg(e),e.i),a=t.pi(),a!=-1){for(l=i.length;a=0;--a)for(t=i[a],l=0;l0&&Ma(e,128)<0?(t=nr(e)+128,i=(P8e(),d3e)[t],!i&&(i=d3e[t]=new xF(e)),i):new xF(e)}function s6(e){return Kg(),Ma(e,0)<0?Ma(e,-1)!=0?new Owe(-1,pS(e)):ese:Ma(e,10)<=0?T3e[nr(e)]:new Owe(1,e)}function LWe(){hpe.call(this,new E0e(16)),Sf(2,"expectedValuesPerKey"),this.b=2,this.a=new S1e(null,null,0,null),kE(this.a,this.a)}function XU(){XU=M,yae=new O8("SIMPLE",0),wAe=new O8("GROUP_DEC",1),_Ae=new O8("GROUP_MIXED",2),vAe=new O8("GROUP_INC",3)}function twe(){twe=M,mAe=new tx(15),Uct=new wa((ur(),Sy),mAe),Gct=new wa(My,15),zct=new wa(fae,He(0)),Fct=new wa(yM,HS)}function tte(){tte=M,Bae=new zk,GAe=new nX,jAe=new Gk,$Ae=new SN,VAe=new MN,WAe=new TN,HAe=new JT,qAe=new iX,XAe=new CN}function kWe(e){this.e=le(In,si,22,e.length,15,1),this.c=le(Ru,f1,22,e.length,16,1),this.b=le(Ru,f1,22,e.length,16,1),this.f=0}function nwe(e,t){this.n=uw(R1,[be,tye],[378,22],14,[t,yr(w.Math.ceil(e/32))],2),this.o=e,this.p=t,this.j=e-1>>1,this.k=t-1>>1}function RWe(e,t,i){kje(),EDe.call(this),this.a=uw(Xct,[be,Pye],[537,171],0,[Mj,xae],2),this.c=new VE,this.g=e,this.f=t,this.d=i}function ja(e,t,i){var a,l,f;return e.ti()?(a=e.i,f=e.ui(),e6(e,a,t),l=e.mi(3,null,t,a,f),i?i.Sh(l):i=l):e6(e,e.i,t),i}function Tf(e,t){var i,a,l;return e.f>0&&(e.Fi(),a=t==null?0:Hr(t),l=(a&zi)%e.d.length,i=_ve(e,l,a,t),i)?i.lc():null}function nte(e,t){var i,a,l;return e.f>0?(e.Fi(),a=t==null?0:Hr(t),l=(a&zi)%e.d.length,i=lYe(e,l,a,t),i!=-1):!1}function o6(e,t){var i,a,l,f;for(f=cl(e.e.mg(),t),i=h(e.g,124),l=0;l2e3&&(Rnt=e,Uz=w.setTimeout(nSt,10))),Fz++==0?(Jkt((vr(),r3e)),!0):!1}function h5t(){return Error.stackTraceLimit>0?(w.Error.stackTraceLimit=Error.stackTraceLimit=64,!0):"stack"in new Error}function FWe(e,t){return e.e>t.e?1:e.et.d?e.e:e.d=0?f=f.a[1]:(l=f,f=f.a[0])}return l}function VWe(e,t,i){var a,l,f;for(l=null,f=e.b;f;){if(a=e.a.Ld(t,f.d),i&&a==0)return f;a<=0?f=f.a[0]:(l=f,f=f.a[1])}return l}function g5t(e,t,i,a){var l,f,g;return l=!1,DGt(e.f,i,a)&&(k5t(e.f,e.a[t][i],e.a[t][a]),f=e.a[t],g=f[a],f[a]=f[i],f[i]=g,l=!0),l}function swe(e,t){var i,a,l;for(l=e.g.ed();l.hc();)if(i=ce(Xe(l.ic())),a=w.Math.abs(i-t),at?1:$8(isNaN(e),isNaN(t)))>0}function awe(e,t){return xh(),xh(),Ng(tm),(w.Math.abs(e-t)<=tm||e==t||isNaN(e)&&isNaN(t)?0:et?1:$8(isNaN(e),isNaN(t)))<0}function WWe(e,t){return xh(),xh(),Ng(tm),(w.Math.abs(e-t)<=tm||e==t||isNaN(e)&&isNaN(t)?0:et?1:$8(isNaN(e),isNaN(t)))<=0}function w5t(e,t){if(t.c==e)return t.d;if(t.d==e)return t.c;throw Y(new un("Input edge is not connected to the input port."))}function YU(e,t){return dn(e),t==null?!1:dt(e,t)?!0:e.length==t.length&&dt(e.toLowerCase(),t.toLowerCase())}function HWe(e){var t,i,a,l,f;if(e==null)return null;for(f=new ke,i=Iee(e),a=0,l=i.length;at.e?1:e.ft.f?1:Hr(e)-Hr(t)}function AS(e,t){Yr(),Hn(e);try{return e.Vb(t)}catch(i){if(i=pr(i),re(i,177))return null;if(re(i,169))return null;throw Y(i)}}function M5t(e,t){Yr(),Hn(e);try{return e.$b(t)}catch(i){if(i=pr(i),re(i,177))return null;if(re(i,169))return null;throw Y(i)}}function QWe(e){Kg(),e.length==0?(this.e=0,this.d=1,this.a=X(q(In,1),si,22,15,[0])):(this.e=1,this.d=e.length,this.a=e,gA(this))}function lwe(e,t,i,a){DS();var l,f;for(l=0,f=0;f=f?(DIt(e,t),-1):(BIt(e,t),1)}function eHe(e,t){var i,a,l;++e.j,a=e.g==null?0:e.g.length,t>a&&(l=e.g,i=a+(a/2|0)+4,iuie)return i.zg();if(a=i.sg(),a||i==e)break}return a}function tHe(e,t){var i,a;return i=t.Yg(e.a),i&&(a=ti(Tf((!i.b&&(i.b=new wl((yt(),zo),Aa,i)),i.b),gi)),a!=null)?a:t.be()}function P5t(e,t){var i,a;return i=t.Yg(e.a),i&&(a=ti(Tf((!i.b&&(i.b=new wl((yt(),zo),Aa,i)),i.b),gi)),a!=null)?a:t.be()}function qt(e){var t;if(re(e.a,4)){if(t=zWe(e.a),t==null)throw Y(new ba(tet+e.b+"'. "+rxe+(Fd(wD),wD.k)+sxe));return t}else return e.a}function L5t(e){var t;if(e==null)return null;if(t=A8t(Ba(e,!0)),t==null)throw Y(new mK("Invalid hexBinary value: '"+e+"'"));return t}function nHe(e,t){var i,a,l;if(De(Zz,e),t.nc(e),i=h(Ii(fse,e),19),i)for(l=i.tc();l.hc();)a=h(l.ic(),35),Qo(Zz,a,0)!=-1||nHe(a,t)}function k5t(e,t,i){var a,l;Bte(e.e,t,i,(Fe(),nn)),Bte(e.i,t,i,Zt),e.a&&(l=h(G(t,(Ie(),Jn)),11),a=h(G(i,Jn),11),CQ(e.g,l,a))}function iHe(e){var t;Be(rn(e,(ur(),Ey)))===Be((e1(),vj))&&(eo(e)?(t=h(rn(eo(e),Ey),316),ac(e,Ey,t)):ac(e,Ey,ML))}function uwe(e,t,i){this.c=e,this.f=new ke,this.e=new fo,this.j=new Hme,this.n=new Hme,this.b=t,this.g=new Zf(t.c,t.d,t.b,t.a),this.a=i}function fwe(e,t,i,a,l,f){Cge(this),this.e=e,this.f=t,this.d=i,this.c=a,this.g=l,this.b=f,this.j=ce(Xe(l.tc().ic())),this.i=ce(Xe(_$e(l)))}function R5t(e){var t;for(t=h(Tn(Cn(As(e))),14).c.g;t.j==(Xt(),Nr);)Ee(t,(Ie(),k5),(vt(),vt(),!0)),t=h(Tn(Cn(As(t))),14).c.g}function I5t(e,t,i){var a,l,f,g;return f=t.i,g=i.i,f!=g?f.g-g.g:(a=e.f[t.o],l=e.f[i.o],a==0&&l==0?0:a==0?-1:l==0?1:to(a,l))}function Yn(e){var t;try{return t=e.i.cd(e.e),e.Bi(),e.g=e.e++,t}catch(i){throw i=pr(i),re(i,79)?(e.Bi(),Y(new K)):Y(i)}}function ate(e){var t;try{return t=e.c.yh(e.e),e.Bi(),e.g=e.e++,t}catch(i){throw i=pr(i),re(i,79)?(e.Bi(),Y(new K)):Y(i)}}function qg(e,t){var i;i=e.fd(t);try{return i.ic()}catch(a){throw a=pr(a),re(a,101)?Y(new Ra("Can't get element "+t)):Y(a)}}function rHe(e,t){ru(),Hn(e);try{return e.pc(t)}catch(i){if(i=pr(i),re(i,177))return!1;if(re(i,169))return!1;throw Y(i)}}function D5t(e,t){Yr(),Hn(e);try{return e.Qb(t)}catch(i){if(i=pr(i),re(i,177))return!1;if(re(i,169))return!1;throw Y(i)}}function sHe(e,t,i){return new Zf(w.Math.min(e.a,t.a)-i/2,w.Math.min(e.b,t.b)-i/2,w.Math.abs(e.a-t.a)+i,w.Math.abs(e.b-t.b)+i)}function oHe(e,t){var i,a,l,f;for(i=0,l=new j(t.a);l.a0),t.a.cd(t.c=--t.b))}function i1(){i1=M,Ln=new $R("PARENTS",0),ga=new $R("NODES",1),bd=new $R("EDGES",2),cb=new $R("PORTS",3),fm=new $R("LABELS",4)}function Xg(){Xg=M,ub=new WR("DISTRIBUTED",0),wae=new WR("JUSTIFIED",1),fAe=new WR("BEGIN",2),TL=new WR(MP,3),hAe=new WR("END",4)}function HA(e,t,i){EDe.call(this),this.a=le(Xct,Pye,171,(Ef(),X(q(Jw,1),Oe,203,0,[aa,Wa,ca])).length,0,1),this.b=e,this.d=t,this.c=i}function l6(e,t){var i,a;if(++e.j,t!=null&&(i=(a=e.a.Cb,re(a,92)?h(a,92).cg():null),OFt(t,i))){VA(e.a,4,i);return}VA(e.a,4,h(t,116))}function B5t(e,t){var i,a;return t!=null&&yw(t).length!=0&&(i=o_e(e,t),i)?i:Pn.length!=0&&(a=o_e(e,Pn),a)?a:null}function O5t(e){var t,i;if(e.j==(Xt(),Nr)){for(i=Cn(t1(e));Gn(i);)if(t=h(Tn(i),14),!Jo(t)&&e.c==Ate(t,e).c)return!0}return!1}function KU(){KU=M,rse=new Xpe("NUM_OF_EXTERNAL_SIDES_THAN_NUM_OF_EXTENSIONS_LAST",0),z3e=new Xpe("CORNER_CASES_THAN_SINGLE_SIDE_LAST",1)}function cte(){return U7(),X(q(ylt,1),Oe,147,0,[vlt,wlt,_lt,ult,llt,flt,plt,dlt,hlt,blt,mlt,glt,alt,olt,clt,rlt,ilt,slt,tlt,elt,nlt,Eae])}function lte(e,t){var i;switch(i=!e.v.pc((Hl(),C1))||e.q==(Ms(),Oa),e.t.g){case 1:i?t$t(e,t):YKe(e,t);break;case 0:i?wjt(e,t):WKe(e,t)}}function N5t(e,t,i){var a;switch(a=i.q.getFullYear()-$0+$0,a<0&&(a=-a),t){case 1:e.a+=a;break;case 2:ad(e,a%100,2);break;default:ad(e,a,t)}}function F5t(e){var t;switch(t=e.Mh(null),t){case 10:return 0;case 15:return 1;case 14:return 2;case 11:return 3;case 21:return 4}return-1}function ute(e){switch(e.g){case 1:return qs(),hm;case 4:return qs(),rf;case 2:return qs(),sf;case 3:return qs(),rp}return qs(),Oh}function U5t(e,t,i,a){var l,f,g;return l=new Wd(e.e,1,13,(g=t.c,g||(yt(),zh)),(f=i.c,f||(yt(),zh)),$p(e,t),!1),a?a.Sh(l):a=l,a}function Nn(e,t){var i,a;if(g_(t,e.b),t>=e.b>>1)for(a=e.c,i=e.b;i>t;--i)a=a.b;else for(a=e.a.a,i=0;i=0?e.Fg(l):Vte(e,a)):i<0?Vte(e,a):h(a,61).aj().fj(e,e.Qg(),i)}function cHe(e){var t,i,a;for(a=(!e.o&&(e.o=new il((Ta(),op),pm,e,0)),e.o),i=a.c.tc();i.e!=i.i._b();)t=h(i.Ci(),38),t.lc();return CI(a)}function W5t(e){var t,i,a,l;for(a=le(nVt,et,144,e.c.length,0,1),l=0,i=new j(e);i.a0&&(De(e.b,new r9e(t.a,i)),a=t.a.length,0a&&(t.a+=VNe(le(Zl,Ph,22,-a,15,1))))}function QU(e){switch(Rpe(),this.c=new ke,this.d=e,e.g){case 0:case 2:this.a=T1e(CEe),this.b=Jr;break;case 3:case 1:this.a=CEe,this.b=Ts}}function hwe(e,t){this.e=e,t.5&&f<50;)l=EYe(a),i=Mx(a,l,!0),t=w.Math.abs(i.b),++f;return Mx(e,l,!1)}function fHe(e){var t,i,a,l,f;for(a=yne(e),t=Jr,f=0,l=0;t>.5&&f<50;)l=xYe(a),i=Mx(a,l,!0),t=w.Math.abs(i.a),++f;return Mx(e,l,!1)}function Y5t(e,t){var i,a,l,f;for(f=0,a=Nn(e,0);a.b!=a.d.c;)i=h(Un(a),35),f+=w.Math.pow(i.g*i.f-t,2);return l=w.Math.sqrt(f/(e.b-1)),l}function hHe(e,t){var i,a,l;for(i=e.o,l=h(h(er(e.r,t),19),60).tc();l.hc();)a=h(l.ic(),111),a.e.a=VDt(a,i.a),a.e.b=i.b*ce(Xe(a.b.xe(Tj)))}function yx(e,t,i,a){var l;return i>=0?e.Bg(t,i,a):(e.yg()&&(a=(l=e.og(),l>=0?e.jg(a):e.yg().Cg(e,-1-l,null,a))),e.lg(t,i,a))}function xx(e,t,i){var a,l;if(l=e._b(),t>=l)throw Y(new o_(t,l));if(e.xh()&&(a=e.dd(i),a>=0&&a!=t))throw Y(new un(s5));return e.Ah(t,i)}function Z5t(e,t,i){var a,l,f,g;return a=e.dd(t),a!=-1&&(e.ti()?(f=e.ui(),g=x9(e,a),l=e.mi(4,g,null,a,f),i?i.Sh(l):i=l):x9(e,a)),i}function Us(e,t,i){var a,l,f,g;return a=e.dd(t),a!=-1&&(e.ti()?(f=e.ui(),g=Ex(e,a),l=e.mi(4,g,null,a,f),i?i.Sh(l):i=l):Ex(e,a)),i}function dHe(e){var t,i,a;e.b==e.c&&(a=e.a.length,i=gbe(8>a?8:a)<<1,e.b!=0?(t=el(e.a,i),g$e(e,t,a),e.a=t,e.b=0):nK(e.a,i),e.c=a)}function K5t(e){var t,i;t=new ke,i=e;do i=h(Tn(Cn(fr(i))),14).d.g,i.j==(Xt(),Nr)&&(t.c[t.c.length]=i);while(i.j==(Xt(),Nr));return t}function pHe(e){var t,i;for(this.b=new ke,this.c=e,this.a=!1,i=new j(e.a);i.a0||e==(Wr(),Hre)||t==(so(),qre))throw Y(new un("Invalid range: "+aze(e,t)))}function J5t(e){switch(e.g){case 1:return I0(),dD;case 3:return I0(),hD;case 2:return I0(),Mae;case 4:return I0(),Sae;default:return null}}function dte(e){switch(e.g){case 0:return null;case 1:return new C$e;case 2:return new spe;default:throw Y(new un(ure+(e.f!=null?e.f:""+e.g)))}}function Q5t(e,t,i){if(e.e)switch(e.b){case 1:xPt(e.c,t,i);break;case 0:EPt(e.c,t,i)}else mze(e.c,t,i);e.a[t.o][i.o]=e.c.i,e.a[i.o][t.o]=e.c.e}function _w(){_w=M,jG=new L8(H0,0),Soe=new L8("PORT_POSITION",1),_y=new L8("NODE_SIZE_WHERE_SPACE_PERMITS",2),vy=new L8("NODE_SIZE",3)}function bHe(e){var t,i,a;for(i=new j(e.a);i.a=0?e.ug(g,i,!0):Ax(e,f,i)):h(f,61).aj().cj(e,e.Qg(),l,i,a)}function eDt(e,t){var i,a,l,f;return f=e.o,i=e.p,f=0)return l;if(e.Rj()){for(a=0;al&&Gr(t,l,null),t}function wHe(e,t){var i,a,l;for(l=e.a.length,t.lengthl&&Gr(t,l,null),t}function L_(e,t,i){try{return rw(tee(e,t,i),1)}catch(a){throw a=pr(a),re(a,305)?Y(new Ra(_ie+e.o+"*"+e.p+yie+t+Ca+i+xie)):Y(a)}}function vHe(e,t,i){try{return rw(tee(e,t,i),0)}catch(a){throw a=pr(a),re(a,305)?Y(new Ra(_ie+e.o+"*"+e.p+yie+t+Ca+i+xie)):Y(a)}}function _He(e,t,i){try{return rw(tee(e,t,i),2)}catch(a){throw a=pr(a),re(a,305)?Y(new Ra(_ie+e.o+"*"+e.p+yie+t+Ca+i+xie)):Y(a)}}function yHe(e,t,i){var a;try{return L_(e,t+e.j,i+e.k)}catch(l){throw l=pr(l),re(l,79)?(a=l,Y(new Ra(a.g+Y7+t+Ca+i+")."))):Y(l)}}function tDt(e,t,i){var a;try{return vHe(e,t+e.j,i+e.k)}catch(l){throw l=pr(l),re(l,79)?(a=l,Y(new Ra(a.g+Y7+t+Ca+i+")."))):Y(l)}}function nDt(e,t,i){var a;try{return _He(e,t+e.j,i+e.k)}catch(l){throw l=pr(l),re(l,79)?(a=l,Y(new Ra(a.g+Y7+t+Ca+i+")."))):Y(l)}}function xHe(e,t){if(e.g==-1)throw Y(new qa);e.Bi();try{e.d.hd(e.g,t),e.f=e.d.j}catch(i){throw i=pr(i),re(i,79)?Y(new P):Y(i)}}function EHe(e,t,i){ii(i,"Compound graph preprocessor",1),e.a=new Kv,HKe(e,t,null),Dzt(e,t),s9t(e),Ee(t,(Ie(),YSe),e.a),e.a=null,nl(e.b),On(i)}function pte(e,t){var i,a;if(kge(t>0),(t&-t)==t)return yr(t*al(e,31)*4656612873077393e-25);do i=al(e,31),a=i%t;while(i-a+(t-1)<0);return yr(a)}function iDt(e,t,i){switch(i.g){case 1:e.a=t.a/2,e.b=0;break;case 2:e.a=t.a,e.b=t.b/2;break;case 3:e.a=t.a/2,e.b=t.b;break;case 4:e.a=0,e.b=t.b/2}}function rDt(e){var t,i;for(i=h(G(e,(Ie(),LG)),15).tc();i.hc();)if(t=h(i.ic(),68),cw(t,($e(),DG)))return h(G(t,DG),276);return null}function sDt(e,t){var i,a,l;for(i=m0(new Fm,e),l=new j(t);l.a1&&(f=sDt(e,t)),f}function lDt(e,t){var i,a,l,f;for(f=new j(t.a);f.a102?-1:e<=57?e-48:e<65?-1:e<=70?e-65+10:e<97?-1:e-97+10}function AHe(e,t){var i,a,l;for(e.b[t.g]=1,a=Nn(t.d,0);a.b!=a.d.c;)i=h(Un(a),170),l=i.c,e.b[l.g]==1?Gi(e.a,i):e.b[l.g]==2?e.b[l.g]=1:AHe(e,l)}function PHe(e,t){var i;return i=X(q(ks,1),Wo,22,15,[Gee(e.a[0],t),Gee(e.a[1],t),Gee(e.a[2],t)]),e.d&&(i[0]=w.Math.max(i[0],i[2]),i[2]=i[0]),i}function LHe(e,t){var i;return i=X(q(ks,1),Wo,22,15,[IU(e.a[0],t),IU(e.a[1],t),IU(e.a[2],t)]),e.d&&(i[0]=w.Math.max(i[0],i[2]),i[2]=i[0]),i}function uDt(e){var t,i,a;for(PR(e.b.a),e.a=le(Hz,et,57,e.c.c.a.b.c.length,0,1),t=0,a=new j(e.c.c.a.b);a.aa&&e.charCodeAt(t-1)<=32;)--t;return a>0||tf&&Gr(t,f,null),t}function Ete(e){Mo();var t;if(t=IIt(e),!Gn(e))throw Y(new Ra("position (0) must be less than the number of elements that remained ("+t+")"));return Tn(e)}function LDt(e){var t;return t=(qje(),Nnt),t[e>>>28]|t[e>>24&15]<<4|t[e>>20&15]<<8|t[e>>16&15]<<12|t[e>>12&15]<<16|t[e>>8&15]<<20|t[e>>4&15]<<24|t[e&15]<<28}function DHe(e){var t,i,a;for(a=e.f,e.k=le(ks,Wo,22,a,15,1),e.d=le(ks,Wo,22,a,15,1),t=0;t0&&(l.b+=t),l}function r7(e,t){var i,a,l;for(l=new fo,a=e.tc();a.hc();)i=h(a.ic(),31),A6(i,0,l.b),l.b+=i.e.b+t,l.a=w.Math.max(l.a,i.e.a);return l.a>0&&(l.a+=t),l}function BDt(e,t){var i,a;if(t<0||t>=e._b())return null;for(i=t;i=e.i)throw Y(new JK(t,e.i));return++e.j,i=e.g[t],a=e.i-t-1,a>0&&vc(e.g,t+1,e.g,t,a),Gr(e.g,--e.i,null),e.vh(t,i),e.th(),i}function Mte(e,t){var i,a;return e.Db>>16==6?e.Cb.Cg(e,5,ch,t):(a=Uo(h(Wt((i=h(sn(e,16),24),i||e.Rg()),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function Ewe(e,t){var i,a;i=e.fd(t);try{return a=i.ic(),i.jc(),a}catch(l){throw l=pr(l),re(l,101)?Y(new Ra("Can't remove element "+t)):Y(l)}}function zDt(e,t){var i,a,l;return l=new di(new Bl(X(q(fVt,1),et,1700,0,[e,t])),16),a=new I8e(l),i=new oi(null,a),p1e(i,new CY(e)),p1e(i,new AY(t)),i}function Swe(e,t,i,a,l,f){var g,m,v;for(Be(e)===Be(i)&&(e=e.slice(t,t+l),t=0),m=t,v=t+l;m>22),l+=a>>22,l<0)?!1:(e.l=i&Yc,e.m=a&Yc,e.h=l&Kd,!0)}function qDt(e,t,i,a,l,f,g){var m,v;return!(t.je()&&(v=e.a.Ld(i,a),v<0||!l&&v==0)||t.ke()&&(m=e.a.Ld(i,f),m>0||!g&&m==0))}function Sx(){Sx=M,m5=new C8("NORTH",0),g5=new C8("EAST",1),b5=new C8("SOUTH",2),w5=new C8("WEST",3),m5.a=!1,g5.a=!0,b5.a=!1,w5.a=!0}function YA(){YA=M,v5=new A8("NORTH",0),qz=new A8("EAST",1),Xz=new A8("SOUTH",2),_5=new A8("WEST",3),v5.a=!1,qz.a=!0,Xz.a=!1,_5.a=!0}function xl(){xl=M,fD=new N8("UNKNOWN",0),Ed=new N8("ABOVE",1),dm=new N8("BELOW",2),uD=new N8("INLINE",3),new Zr("org.eclipse.elk.labelSide",fD)}function Yg(e,t,i){if(i&&(t<0||t>i.a.c.length))throw Y(new un("index must be >= 0 and <= layer node count"));e.c&&Sa(e.c.a,e),e.c=i,i&&v0(i.a,t,e)}function GHe(e){switch(e.g){case 0:return qse;case 1:return Xse;case 2:return Yse;case 3:return Zse;case 4:return wG;case 5:return Kse;default:return null}}function PS(){PS=M,JG=new k8("P1_TREEIFICATION",0),dL=new k8("P2_NODE_ORDERING",1),q5=new k8("P3_NODE_PLACEMENT",2),pL=new k8("P4_EDGE_ROUTING",3)}function Co(e,t,i){var a,l;return a=(l=new aK,ES(l,t),Mf(l,i),$n((!e.c&&(e.c=new ze(nv,e,12,10)),e.c),l),l),E_(a,0),mS(a,1),A_(a,!0),C_(a,!0),a}function jHe(e,t){var i,a;return e.Db>>16==17?e.Cb.Cg(e,21,Lu,t):(a=Uo(h(Wt((i=h(sn(e,16),24),i||e.Rg()),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function XDt(e,t){var i,a,l;if(a=new T8,l=new bbe(a.q.getFullYear()-$0,a.q.getMonth(),a.q.getDate()),i=fzt(e,t,l),i==0||i>16==6?e.Cb.Cg(e,6,js,t):(a=Uo(h(Wt((i=h(sn(e,16),24),i||(Ta(),Cj)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function Pwe(e,t){var i,a;return e.Db>>16==7?e.Cb.Cg(e,1,pD,t):(a=Uo(h(Wt((i=h(sn(e,16),24),i||(Ta(),SAe)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function Lwe(e,t){var i,a;return e.Db>>16==9?e.Cb.Cg(e,9,Br,t):(a=Uo(h(Wt((i=h(sn(e,16),24),i||(Ta(),TAe)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function kwe(e,t){var i,a;return e.Db>>16==3?e.Cb.Cg(e,12,Br,t):(a=Uo(h(Wt((i=h(sn(e,16),24),i||(Ta(),EAe)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function Rwe(e,t){var i,a;return e.Db>>16==3?e.Cb.Cg(e,0,mD,t):(a=Uo(h(Wt((i=h(sn(e,16),24),i||(yt(),A1)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function VHe(e,t){var i,a;return e.Db>>16==7?e.Cb.Cg(e,6,ch,t):(a=Uo(h(Wt((i=h(sn(e,16),24),i||(yt(),k1)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function WHe(e,t){var i,a;return e.Db>>16==5?e.Cb.Cg(e,9,Oj,t):(a=Uo(h(Wt((i=h(sn(e,16),24),i||(yt(),P1)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function LS(e,t){var i,a;if(t){if(t==e)return!0;for(i=0,a=h(t,42).yg();a&&a!=t;a=a.yg()){if(++i>uie)return LS(e,a);if(a==e)return!0}}return!1}function aBt(e){var t,i;t=h(G(e,(Cf(),Cit)),21),t?(i=t.a,i==0?Ee(e,(Fg(),eG),new Jee):Ee(e,(Fg(),eG),new J9(i))):Ee(e,(Fg(),eG),new J9(1))}function cBt(e,t){var i;switch(i=e.g,t.g){case 1:return-(e.k.b+e.n.b);case 2:return e.k.a-i.n.a;case 3:return e.k.b-i.n.b;case 4:return-(e.k.a+e.n.a)}return 0}function Iwe(e,t,i,a){var l,f,g;if(e.a[t.o]==-1)for(e.a[t.o]=i,e.b[t.o]=a,f=Cn(fr(t));Gn(f);)l=h(Tn(f),14),!Jo(l)&&(g=l.d.g,Iwe(e,g,i+1,a))}function lBt(e){switch(t9(),e.q.g){case 5:CXe(e,(Fe(),bn)),CXe(e,ni);break;case 4:mYe(e,(Fe(),bn)),mYe(e,ni);break;default:QKe(e,(Fe(),bn)),QKe(e,ni)}}function uBt(e){switch(t9(),e.q.g){case 5:FXe(e,(Fe(),Zt)),FXe(e,nn);break;case 4:hHe(e,(Fe(),Zt)),hHe(e,nn);break;default:eJe(e,(Fe(),Zt)),eJe(e,nn)}}function pu(e){var t;return!(e.Bb&1)&&e.r&&e.r.Eg()&&(t=h(e.r,42),e.r=h(jg(e,t),133),e.r!=t&&e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,9,8,t,e.r))),e.r}function ZA(e,t,i){var a,l;a=t*i,re(e.g,153)?(l=ux(e),l.f.d?l.f.a||(e.d.a+=a+gd):(e.d.d-=a+gd,e.d.a+=a+gd)):re(e.g,8)&&(e.d.d-=a,e.d.a+=2*a)}function HHe(){M7(),this.c=new ke,this.i=new ke,this.e=new Gc,this.f=new Gc,this.g=new Gc,this.j=new ke,this.a=new ke,this.b=(Yr(),new ui),this.k=new ui}function fBt(e,t){var i,a,l,f;for(ii(t,"Dull edge routing",1),f=Nn(e.b,0);f.b!=f.d.c;)for(l=h(Un(f),76),a=Nn(l.d,0);a.b!=a.d.c;)i=h(Un(a),170),rd(i.a)}function Cte(e,t,i){var a;return a=X(q(ks,1),Wo,22,15,[tve(e,(Ef(),aa),t,i),tve(e,Wa,t,i),tve(e,ca,t,i)]),e.f&&(a[0]=w.Math.max(a[0],a[2]),a[2]=a[0]),a}function hBt(){I7();var e,t;try{if(t=h(Wwe((Sg(),ku),tM),1698),t)return t}catch(i){if(i=pr(i),re(i,104))e=i,Ime((zn(),e));else throw Y(i)}return new Dm}function dBt(){I7();var e,t;try{if(t=h(Wwe((Sg(),ku),wu),1635),t)return t}catch(i){if(i=pr(i),re(i,104))e=i,Ime((zn(),e));else throw Y(i)}return new AN}function pBt(){NGe();var e,t;try{if(t=h(Wwe((Sg(),ku),v1),1710),t)return t}catch(i){if(i=pr(i),re(i,104))e=i,Ime((zn(),e));else throw Y(i)}return new tC}function Dwe(e,t){var i,a;return e.Db>>16==11?e.Cb.Cg(e,10,Br,t):(a=Uo(h(Wt((i=h(sn(e,16),24),i||(Ta(),MAe)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function qHe(e,t){var i,a;return e.Db>>16==10?e.Cb.Cg(e,11,Lu,t):(a=Uo(h(Wt((i=h(sn(e,16),24),i||(yt(),L1)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function XHe(e,t){var i,a;return e.Db>>16==10?e.Cb.Cg(e,12,uf,t):(a=Uo(h(Wt((i=h(sn(e,16),24),i||(yt(),rv)),e.Db>>16),17)),e.Cb.Cg(e,a.n,a.f,t))}function gBt(e,t){var i,a,l,f,g;if(t)for(l=t.a.length,i=new jm(l),g=(i.b-i.a)*i.c<0?(Mg(),mm):new Cg(i);g.hc();)f=h(g.ic(),21),a=uS(t,f.a),a&&rYe(e,a)}function mBt(){Ope();var e,t;for(j$t((kg(),Ct)),B$t(Ct),Tte(Ct),zAe=(yt(),zh),t=new j(YAe);t.a>19,y=t.h>>19,v!=y?y-v:(l=e.h,m=t.h,l!=m?l-m:(a=e.m,g=t.m,a!=g?a-g:(i=e.l,f=t.l,i-f)))}function bBt(e,t){var i,a,l;if(a=e.b.d.d,e.a||(a+=e.b.d.a),l=t.b.d.d,t.a||(l+=t.b.d.a),i=to(a,l),i==0){if(!e.a&&t.a)return-1;if(!t.a&&e.a)return 1}return i}function wBt(e,t){var i,a,l;if(a=e.b.g.d,e.a||(a+=e.b.g.a),l=t.b.g.d,t.a||(l+=t.b.g.a),i=to(a,l),i==0){if(!e.a&&t.a)return-1;if(!t.a&&e.a)return 1}return i}function vBt(e,t,i,a){var l,f,g,m;for(l=0;lg&&(m=g/a),l>f&&(v=f/l),au(e,w.Math.min(m,v)),e}function yBt(e,t,i){var a,l;return l=e.e,e.e=t,e.Db&4&&!(e.Db&1)&&(a=new ls(e,1,4,l,t),i?i.Sh(a):i=a),l!=t&&(t?i=GS(e,x7(e,t),i):i=GS(e,e.a,i)),i}function JHe(){T8.call(this),this.e=-1,this.a=!1,this.p=zs,this.k=-1,this.c=-1,this.b=-1,this.g=!1,this.f=-1,this.j=-1,this.n=-1,this.i=-1,this.d=-1,this.o=zs}function xBt(e,t){var i,a;for(a=new j(t);a.a=0?(i=h6(e,W7),a=i6(e,W7)):(t=c_(e,1),i=h6(t,5e8),a=i6(t,5e8),a=no(jd(a,1),Kr(e,1))),Kf(jd(a,32),Kr(i,ao))}function s7(){s7=M,Z3e=(A7(),ose),Y3e=new ln(oye,Z3e),X3e=(dU(),sse),q3e=new ln(aye,X3e),H3e=(KU(),rse),W3e=new ln(cye,H3e),V3e=new ln(lye,(vt(),vt(),!0))}function Ate(e,t){if(t==e.c.g)return e.d.g;if(t==e.d.g)return e.c.g;throw Y(new un("'node' must either be the source node or target node of the edge."))}function TBt(e,t,i){var a,l;for(ii(i,"Interactive node placement",1),e.a=h(G(t,(Ie(),Uw)),266),l=new j(t.b);l.a0&&(g=(f&zi)%e.d.length,l=_ve(e,g,f,t),l)?(m=l.mc(i),m):(a=e.Ii(f,t,i),e.c.nc(a),null)}function Uwe(e,t){var i,a,l,f;switch(jp(e,t).lk()){case 3:case 2:{for(i=V_(t),l=0,f=i.i;l=0;a--)if(dt(e[a].d,t)||dt(e[a].d,i)){e.length>=a+1&&e.splice(0,a+1);break}return e}function zwe(e,t,i){this.b=new s9,this.i=new ke,this.d=new Uc(this),this.g=e,this.a=t.c.length,this.c=t,this.e=h(St(this.c,this.c.c.length-1),8),this.f=i,pzt(this)}function iqe(){this.a=new Xq,this.g=new i9,this.j=new i9,this.b=(Yr(),new ui),this.d=new i9,this.i=new i9,this.k=new ui,this.c=new ui,this.e=new ui,this.f=new ui}function BBt(e){var t,i,a,l,f;for(a=new Zm(new Ep(e.b).a);a.b;)i=L0(a),t=h(i.kc(),8),f=h(h(i.lc(),48).a,8),l=h(h(i.lc(),48).b,9),tr(Hf(t.k),tr(Ua(f.k),l))}function JA(){JA=M,Use=new zR("MEDIAN_LAYER",0),zse=new zR("WIDEST_LAYER",1),Nse=new zR("CENTER_LAYER",2),vSe=new zR("TAIL_LAYER",3),Fse=new zR("HEAD_LAYER",4)}function OBt(e){var t,i,a;for(i=new j(e.p);i.ai);return l}function jwe(e,t,i){switch(t){case 1:!e.n&&(e.n=new ze(ea,e,1,7)),Pr(e.n),!e.n&&(e.n=new ze(ea,e,1,7)),Mr(e.n,h(i,13));return;case 2:jI(e,ti(i));return}xbe(e,t,i)}function $we(e,t,i){switch(t){case 3:y_(e,ce(Xe(i)));return;case 4:x_(e,ce(Xe(i)));return;case 5:Yu(e,ce(Xe(i)));return;case 6:Zu(e,ce(Xe(i)));return}jwe(e,t,i)}function a7(e,t,i){var a,l,f;f=(a=new aK,a),l=Zg(f,t,null),l&&l.Th(),Mf(f,i),$n((!e.c&&(e.c=new ze(nv,e,12,10)),e.c),f),E_(f,0),mS(f,1),A_(f,!0),C_(f,!0)}function Vwe(e){var t;return e.Db&64?HU(e):(t=new su(HU(e)),t.a+=" (abstract: ",Ap(t,(e.Bb&256)!=0),t.a+=", interface: ",Ap(t,(e.Bb&512)!=0),t.a+=")",t.a)}function Wwe(e,t){var i,a,l;return i=NC(e.e,t),re(i,207)?(l=h(i,207),l.gh()==null,l.dh()):re(i,456)?(a=h(i,1631),l=a.b,l):null}function aqe(e,t){var i;if(this.f=e,this.b=this.f.c,i=e.d,IQ(t,i),t>=(i/2|0))for(this.e=e.e,this.d=i;t++0;)eze(this);this.a=null}function cqe(e,t,i,a,l,f,g){var m,v,y,E,C;if(E=l[f],y=f==g-1,m=y?a:0,C=IHe(m,E),a!=10&&X(q(e,g-f),t[f],i[f],m,C),!y)for(++f,v=0;v0&&po(e,e.length-1)==33)try{return t=PXe(Xf(e,0,e.length-1)),t.e==null}catch(i){if(i=pr(i),!re(i,30))throw Y(i)}return!1}function qBt(e,t,i){var a,l,f,g;for(i=yx(t,e.e,-1-e.c,i),g=E1e(e.a),f=(a=new Zm(new Ep(g.a).a),new wC(a));f.a.b;)l=h(L0(f.a).kc(),84),i=GS(l,x7(l,e.a),i);return i}function XBt(e,t,i){var a,l,f,g;for(i=j9(t,e.e,-1-e.c,i),g=E1e(e.a),f=(a=new Zm(new Ep(g.a).a),new wC(a));f.a.b;)l=h(L0(f.a).kc(),84),i=GS(l,x7(l,e.a),i);return i}function lqe(e){var t,i,a;if(e==null)return null;if(i=h(e,15),i.Wb())return"";for(a=new Tp,t=i.tc();t.hc();)ho(a,(lr(),ti(t.ic()))),a.a+=" ";return E8(a,a.a.length-1)}function uqe(e){var t,i,a;if(e==null)return null;if(i=h(e,15),i.Wb())return"";for(a=new Tp,t=i.tc();t.hc();)ho(a,(lr(),ti(t.ic()))),a.a+=" ";return E8(a,a.a.length-1)}function YBt(e,t){DS();var i,a;for(a=(Kg(),Gz),i=e;t>1;t>>=1)t&1&&(a=m_(a,i)),i.d==1?i=m_(i,i):i=new QWe(TZe(i.a,i.d,le(In,si,22,i.d<<1,15,1)));return a=m_(a,i),a}function tP(e,t){return e.b.a=w.Math.min(e.b.a,t.c),e.b.b=w.Math.min(e.b.b,t.d),e.a.a=w.Math.max(e.a.a,t.c),e.a.b=w.Math.max(e.a.b,t.d),e.c[e.c.length]=t,!0}function ZBt(e){var t,i,a,l;for(l=-1,a=0,i=new j(e);i.a=0&&dt(e.substr(t,3),"GMT")||t>=0&&dt(e.substr(t,3),"UTC"))&&(i[0]=t+3),h_e(e,i,a)}function Ywe(){Ywe=M;var e,t,i,a;for(R3e=le(ks,Wo,22,25,15,1),I3e=le(ks,Wo,22,33,15,1),a=152587890625e-16,t=32;t>=0;t--)I3e[t]=a,a*=.5;for(i=1,e=24;e>=0;e--)R3e[e]=i,i*=.5}function mqe(e,t,i){var a,l;switch(a=(Rn(t.b!=0),h(Xu(t,t.a.a),9)),i.g){case 0:a.b=0;break;case 2:a.b=e.f;break;case 3:a.a=0;break;default:a.a=e.g}return l=Nn(t,0),QE(l,a),t}function u7(){u7=M,Eoe=new jC(FQe,0),uTe=new jC("LONGEST_PATH",1),xoe=new jC("COFFMAN_GRAHAM",2),lTe=new jC(Die,3),fTe=new jC("STRETCH_WIDTH",4),GG=new jC("MIN_WIDTH",5)}function gOt(e,t){var i,a,l,f;for(i=0,a=0,f=new j(t.b);f.ai;f--)e[f]|=t[f-i-1]>>>g,e[f-1]=t[f-i-1]<=e.f)break;f.c[f.c.length]=i}return f}function _Ot(e,t,i){var a,l,f;return f=0,a=i[t],t>4&15,f=e[a]&15,g[l++]=CAe[i],g[l++]=CAe[f];return hu(g,0,g.length)}function vqe(e,t,i){var a,l,f,g,m;for(a=i._b(),eHe(e,e.i+a),m=e.i-t,m>0&&vc(e.g,t,e.g,t+a,m),g=i.tc(),e.i+=a,l=0;l=oo?(t=$6+(e-oo>>10&1023)&jr,i=56320+(e-oo&1023)&jr,String.fromCharCode(t)+(""+String.fromCharCode(i))):String.fromCharCode(e&jr)}function COt(e){var t,i,a;for(a=e.e.c.length,e.a=uw(In,[be,si],[37,22],15,[a,a],2),i=new j(e.c);i.a0&&UHe(this,this.c-1,(Fe(),Zt)),this.c1&&(t.c[t.c.length]=f))}function POt(e){var t,i,a;for(i=new Bn((!e.a&&(e.a=new ze(Br,e,10,11)),e.a));i.e!=i.i._b();)if(t=h(Yn(i),35),a=S6(t),!Gn((Mo(),new Nd(Kh(Gd(a.a,new z))))))return t;return null}function _qe(e,t,i){var a,l;for(l=new Bn((!e.a&&(e.a=new ze(Br,e,10,11)),e.a));l.e!=l.i._b();)a=h(Yn(l),35),Od(a,a.i+t,a.j+i);mo((!e.b&&(e.b=new ze(js,e,12,3)),e.b),new XOe(t,i))}function yqe(e,t,i,a,l){var f,g,m;for(f=ZYe(e,t,i,a,l),m=!1;!f;)v7(e,l,!0),m=!0,f=ZYe(e,t,i,a,l);m&&v7(e,l,!1),g=PU(l),g.c.length!=0&&(e.d&&e.d.If(g),yqe(e,l,i,a,g))}function eve(e,t){var i;i=za((Sg(),ku),e),re(i,456)?Ko(ku,e,new gNe(this,t)):Ko(ku,e,this),ove(this,t),t==(IE(),UAe)?(this.wb=h(this,1633),h(t,1635)):this.wb=(kg(),Ct)}function LOt(e){var t,i,a;if(e==null)return null;for(t=null,i=0;i0;){if(i=a,a=(a-1)/2|0,e.a.Ld(St(e.b,a),t)<=0)return Hu(e.b,i,t),!0;Hu(e.b,i,St(e.b,a))}return Hu(e.b,a,t),!0}function BOt(e){for(var t,i,a,l;e.o.a.c.length!=0;)i=h(Abe(e.o),48),a=h(i.a,113),t=h(i.b,189),l=jU(t,a),t.e==a?(J8(l.g,t),a.e=l.e+t.a):(J8(l.b,t),a.e=l.e-t.a),De(e.e.a,a)}function tve(e,t,i,a){var l,f;if(l=0,i)l=IU(e.a[i.g][t.g],a);else for(f=0;fuie)return Mqe(i);if(a=i,i==e)throw Y(new ba("There is a cycle in the containment hierarchy of "+e))}return a}function Tqe(){Tqe=M,$nt=X(q(Se,1),be,2,6,["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]),Vnt=X(q(Se,1),be,2,6,["Jan","Feb","Mar","Apr",Bx,"Jun","Jul","Aug","Sep","Oct","Nov","Dec"])}function NOt(e,t,i,a){var l,f;for(f=t,l=f.d==null||e.a.Ld(i.d,f.d)>0?1:0;f.a[l]!=i;)f=f.a[l],l=e.a.Ld(i.d,f.d)>0?1:0;f.a[l]=a,a.b=i.b,a.a[0]=i.a[0],a.a[1]=i.a[1],i.a[0]=null,i.a[1]=null}function _o(){_o=M,Dh=new FR("P1_CYCLE_BREAKING",0),Zx=new FR("P2_LAYERING",1),Qa=new FR("P3_NODE_ORDERING",2),ec=new FR("P4_NODE_PLACEMENT",3),qo=new FR("P5_EDGE_ROUTING",4)}function Cqe(e){var t,i;return i=w.Math.sqrt(e.f*(e.i==null&&(e.i=obe(e,new ta)),ce(e.i))/(e.b*(e.g==null&&(e.g=x$e(e,new Dl)),ce(e.g)))),t=nr(Wc(w.Math.round(i))),t=h0(t,e.f),t}function Aqe(e){var t,i;i=e.k,t=tr(new $t(i.a,i.b),e.n),this.d=w.Math.min(i.b,t.b),this.a=w.Math.max(i.b,t.b),this.b=w.Math.min(i.a,t.a),this.c=w.Math.max(i.a,t.a)}function FOt(e){var t,i;if(e.a>=e.c.c.length)return tS(),GP;if(i=$(e),e.a>=e.c.c.length)return new $2(i);t=new Gc,Cr(t,Hn(i));do Cr(t,Hn($(e)));while(e.a0&&IZe((ai(0,i.c.length),h(i.c[0],26)),e),i.c.length>1&&IZe(h(St(i,i.c.length-1),26),e),On(t)}function GOt(e,t,i,a){var l,f,g,m,v;return g=zHe(e.a,t,i),m=h(g.a,21).a,f=h(g.b,21).a,a&&(v=h(G(t,(Ie(),Pl)),8),l=h(G(i,Pl),8),v&&l&&(mze(e.b,v,l),m+=e.b.i,f+=e.b.e)),m>f}function Lqe(e,t){var i,a,l;if(ive(e,t))return!0;for(a=new j(t);a.af&&uAt(y,lje(i[m],P3e))&&(l=m,f=v);return l>=0&&(a[0]=t+f),l}function h7(e,t){var i,a,l;if(l=0,a=t[0],a>=e.length)return-1;for(i=e.charCodeAt(a);i>=48&&i<=57&&(l=l*10+(i-48),++a,!(a>=e.length));)i=e.charCodeAt(a);return a>t[0]?t[0]=a:l=-1,l}function VOt(e,t){var i,a,l;return a=(YA(),v5),l=w.Math.abs(e.b),i=w.Math.abs(t.f-e.b),iSJ(e.d).c?(e.i+=e.g.c,rte(e.d)):SJ(e.d).c>SJ(e.g).c?(e.e+=e.d.c,rte(e.g)):(e.i+=x9e(e.g),e.e+=x9e(e.d),rte(e.g),rte(e.d))}function IS(){IS=M,ZP=new GC(H0,0),NSe=new GC(XS,1),zSe=new GC(YS,2),USe=new GC("LEFT_RIGHT_CONSTRAINT_LOCKING",3),FSe=new GC("LEFT_RIGHT_CONNECTION_LOCKING",4),OSe=new GC(CQe,5)}function qOt(e){var t,i,a,l,f,g;for(a=kZe(yne(e)),t=Jr,f=0,l=0;t>.5&&f<50;)l=EYe(a),i=Mx(a,l,!0),t=w.Math.abs(i.b),++f;return g=Xe(qg(cu(e.g),cu(e.g).b-1)),Mx(e,(dn(g),g-l),!1)}function XOt(e){var t,i,a,l,f,g;for(a=kZe(yne(e)),t=Jr,f=0,l=0;t>.5&&f<50;)l=xYe(a),i=Mx(a,l,!0),t=w.Math.abs(i.a),++f;return g=Xe(qg(cu(e.g),cu(e.g).b-1)),Mx(e,(dn(g),g-l),!1)}function Iqe(e,t,i,a){e.a.d=w.Math.min(t,i),e.a.a=w.Math.max(t,a)-e.a.d,tm&&(v=m/a),l>f&&(y=f/l),g=w.Math.min(v,y),e.a+=g*(t.a-e.a),e.b+=g*(t.b-e.b)}function JOt(e,t){r9();var i,a,l,f;if(t.b<2)return!1;for(f=Nn(t,0),i=h(Un(f),9),a=i;f.b!=f.d.c;){if(l=h(Un(f),9),vYe(e,a,l))return!0;a=l}return!!vYe(e,a,i)}function sve(e,t,i,a){var l,f;return i==0?(!e.o&&(e.o=new il((Ta(),op),pm,e,0)),f9(e.o,t,a)):(f=h(Wt((l=h(sn(e,16),24),l||e.Rg()),i),61),f.aj().ej(e,Ya(e),i-jn(e.Rg()),t,a))}function QOt(e,t){var i;t!=e.a?(i=null,e.a&&(i=h(e.a,42).Cg(e,4,ch,null)),t&&(i=h(t,42).Ag(e,4,ch,i)),i=Rbe(e,t,i),i&&i.Th()):e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,1,t,t))}function Oqe(e){var t;return e.Db&64?Ote(e):(t=new ou(dxe),!e.a||Mi(Mi((t.a+=' "',t),e.a),'"'),Mi(p0(Mi(p0(Mi(p0(Mi(p0((t.a+=" (",t),e.i),","),e.j)," | "),e.g),","),e.f),")"),t.a)}function eNt(e){var t,i,a,l,f,g,m,v,y;return y=Zwe(e),i=e.e,f=i!=null,f&&sA(y,bz,e.e),m=e.k,g=!!m,g&&sA(y,"type",tI(e.k)),a=x8(e.j),l=!a,l&&(v=new Om,Og(y,Ere,v),t=new $Z(v),mo(e.j,t)),y}function tNt(e,t){var i;if(t!=null&&!e.c.jj().Li(t))throw i=re(t,51)?h(t,51).mg().zb:Um(sl(t)),Y(new xC(ry+e.c.be()+"'s type '"+e.c.jj().be()+"' does not permit a value of type '"+i+"'"))}function nNt(e,t){var i,a,l,f;if(dn(t),f=e.a._b(),f>22-t,l=e.h<>22-t):t<44?(i=0,a=e.l<>44-t):(i=0,a=0,l=e.l<>>l|i[g+a+1]<>>l,++g}return f}function Fqe(e){vwe();var t,i,a,l;return a=h(G(e,($e(),IG)),318),l=ce(mt(G(e,poe)))||Be(G(e,mM))===Be((fx(),S5)),t=h(G(e,MMe),21).a,i=e.a.c.length,!l&&a!=(bS(),EG)&&(t==0||t>i)}function oNt(e,t,i){var a,l;for(l=new Ns(e.b,0);l.b=g)return li.a._b()?h(St(a,l-i.a._b()-1),8):null;return null}function ove(e,t){var i;t!=e.sb?(i=null,e.sb&&(i=h(e.sb,42).Cg(e,1,kL,null)),t&&(i=h(t,42).Ag(e,1,kL,i)),i=Dbe(e,t,i),i&&i.Th()):e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,4,t,t))}function lNt(e,t,i){var a,l,f,g,m;if(i)for(l=i.a.length,a=new jm(l),m=(a.b-a.a)*a.c<0?(Mg(),mm):new Cg(a);m.hc();)g=h(m.ic(),21),f=uS(i,g.a),vxe in f.a||Ere in f.a?RUt(e,f,t):N$t(e,f,t)}function zqe(e){switch(e.g){case 0:return new hK((k0(),HG));case 1:return new cC;default:throw Y(new un("No implementation is available for the crossing minimizer "+(e.f!=null?e.f:""+e.g)))}}function uNt(e){Zve();var t,i,a,l,f;if(e==null)return null;for(a=e.length,l=a*2,t=le(Zl,Ph,22,l,15,1),i=0;i>4],t[i*2+1]=$j[f&15];return hu(t,0,t.length)}function yo(){qd(),fme.call(this),this.i=(Fe(),Na),this.a=new fo,new ope,this.e=(Sf(2,Dx),new Gl(2)),this.d=(Sf(4,Dx),new Gl(4)),this.f=(Sf(4,Dx),new Gl(4)),this.c=new _Oe(this.d,this.f)}function fNt(e,t){var i,a;return!(ce(mt(G(t,(Ie(),om))))||e==(du(),I5)&&(a=t.c.g,a.j==(Xt(),ul)||(i=h(G(a,($e(),tc)),178),i==zw)))}function hNt(e,t){var i,a;return!(ce(mt(G(t,(Ie(),om))))||e==(du(),QP)&&(a=t.d.g,a.j==(Xt(),ul)||(i=h(G(a,($e(),tc)),178),i==nb)))}function dNt(e,t){var i,a,l;i=UCt(t,e.e),a=h(Ii(e.g.f,i),21).a,l=e.a.c.length-1,e.a.c.length!=0&&h(St(e.a,l),269).c==a?(++h(St(e.a,l),269).a,++h(St(e.a,l),269).b):De(e.a,new NFe(a))}function Gqe(e,t,i,a,l){if(aa&&(e.a=a),e.bl&&(e.b=l),e}function pNt(e){if(re(e,180))return c9t(h(e,180));if(re(e,199))return W6t(h(e,199));if(re(e,27))return eNt(h(e,27));throw Y(new un(Txe+Vp(new Bl(X(q(on,1),et,1,5,[e])))))}function Hc(e,t){switch(t.g){case 1:return zd(e.i,(qd(),kEe));case 2:return zd(e.i,(qd(),LEe));case 3:return zd(e.i,(qd(),REe));case 4:return zd(e.i,(qd(),IEe));default:return _t(),_t(),uo}}function jqe(e){var t;this.a=e,t=(Xt(),X(q(xse,1),Oe,232,0,[hs,Nr,Qr,oa,ul,$a,rh])).length,this.b=uw(hCe,[be,UQe],[616,166],0,[t,t],2),this.c=uw(hCe,[be,UQe],[616,166],0,[t,t],2),yzt(this)}function gNt(e){var t,i;return i=h(G(e,(Ie(),Va)),19),t=new ss,(i.pc((xo(),dy))||ce(mt(G(e,($e(),D5)))))&&(oc(t,Jot),i.pc(py)&&oc(t,Qot)),i.pc(hM)&&oc(t,Zot),i.pc(dM)&&oc(t,Kot),t}function $qe(e,t,i){var a,l,f,g;if(t.b!=0){for(a=new Ir,g=Nn(t,0);g.b!=g.d.c;)f=h(Un(g),76),wo(a,dbe(f)),l=f.e,l.a=h(G(f,(ha(),Goe)),21).a,l.b=h(G(f,BTe),21).a;$qe(e,a,bc(i,a.b/e.a|0))}}function m6(e){var t,i,a;for(a=new zc,Gi(a,new $t(e.j,e.k)),i=new Bn((!e.a&&(e.a=new vs(ah,e,5)),e.a));i.e!=i.i._b();)t=h(Yn(i),531),Gi(a,new $t(t.a,t.b));return Gi(a,new $t(e.b,e.c)),a}function mNt(e,t,i,a,l){var f,g,m,v,y,E;if(l)for(v=l.a.length,f=new jm(v),E=(f.b-f.a)*f.c<0?(Mg(),mm):new Cg(f);E.hc();)y=h(E.ic(),21),m=uS(l,y.a),g=new CUe(e,t,i,a),m7t(g.a,g.b,g.c,g.d,m)}function F_(e){lw();var t,i,a;for(a=new Gc,qI(a,e),i=a.a.Xb().tc();i.hc();)t=i.ic(),Hn(t);switch(a.a._b()){case 0:return tS(),GP;case 1:return new $2(a.a.Xb().tc().ic());default:return new TK(a)}}function ave(e,t){var i,a,l;for(l=zi,a=new j(P_(t));a.a1&&(e.e.b+=e.a)):(e.e.a+=i.a,e.e.b=w.Math.max(e.e.b,i.b),e.d.c.length>1&&(e.e.a+=e.a))}function Vqe(e,t,i){var a,l,f,g;if(f=h(sn(e.a,8),1629),f!=null)for(a=0,l=f.length;a1)throw Y(new un("In straight spline segments there may be only one edge."));a=e.a.c,i=e.a.c+e.a.b,Gi(h(t.a.Xb().tc().ic(),14).a,new $t(a+(i-a)/2,e.b))}function Wqe(e,t,i,a){var l;this.b=a,this.e=e==(k0(),lL),l=t[i],this.d=uw(Ru,[be,f1],[221,22],16,[l.length,l.length],2),this.a=uw(In,[be,si],[37,22],15,[l.length,l.length],2),this.c=new Jwe(t,i)}function Fte(e){var t,i,a;if(e.a==null)for(e.a=le(Ru,f1,22,e.c.b.c.length,16,1),e.a[0]=!1,a=new j(e.c.b),a.a>>t,l=e.m>>t|i<<22-t,a=e.l>>t|e.m<<22-t):t<44?(f=0,l=i>>>t-22,a=e.m>>t-22|e.h<<44-t):(f=0,l=0,a=i>>>t-44),Xa(a&Yc,l&Yc,f&Kd)}function qqe(e,t,i){var a,l,f,g,m;for(m=cl(e.e.mg(),t),l=h(e.g,124),a=0,g=0;gi?uve(e,i,"start index"):t<0||t>i?uve(t,i,"end index"):E6("end index (%s) must not be less than start index (%s)",X(q(on,1),et,1,5,[He(t),He(e)]))}function Xqe(e,t){var i,a,l;if(t===e)return!0;if(!re(t,109)||(l=h(t,109),e._b()!=l._b()))return!1;for(a=l.Tb().tc();a.hc();)if(i=h(a.ic(),38),!e.Wc(i))return!1;return!0}function Yqe(e,t){var i,a,l,f;for(a=0,l=e.length;a0?m[g-1]:le(Eu,Af,8,0,0,1),l=m[g],y=g0&&eXe(e,f,i));t.o=0}function kNt(e,t){var i,a,l;for(l=new j(t.f);l.at)throw Y(new un("Top must be smaller or equal to bottom."));if(0>e)throw Y(new un("Left must be smaller or equal to right."));this.d=0,this.c=e,this.a=t,this.b=0}function nXe(e,t){var i,a,l;if(t.c.length!=0){for(i=Lqe(e,t),l=!1;!i;)v7(e,t,!0),l=!0,i=Lqe(e,t);l&&v7(e,t,!1),a=PU(t),e.b&&e.b.If(a),e.a=jVe(e,(ai(0,t.c.length),h(t.c[0],35))),nXe(e,a)}}function Rt(e){var t;this.c=new Ir,this.f=e.e,this.e=e.d,this.i=e.g,this.d=e.c,this.b=e.b,this.k=e.j,this.a=e.a,e.i?this.j=e.i:this.j=(t=h(bl(Qp),10),new Oc(t,h(el(t,t.length),10),0)),this.g=e.f}function o1(){o1=M,dCe=new J2(zx,0),_a=new J2("BOOLEAN",1),xc=new J2("INT",2),Z5=new J2("STRING",3),nc=new J2("DOUBLE",4),ms=new J2("ENUM",5),_M=new J2("ENUMSET",6),wd=new J2("OBJECT",7)}function qc(){qc=M,JAe=X(q(Se,1),be,2,6,[Gxe,c5,Az,Ytt,Pz,Ire,bz]),KAe=X(q(Se,1),be,2,6,[Gxe,"empty",c5,a5,"elementOnly"]),QAe=X(q(Se,1),be,2,6,[Gxe,"preserve","replace",kf]),Zs=new l9e}function er(e,t){var i;return i=h(e.c.Vb(t),13),!i&&(i=e.Pc(t)),re(i,196)?new xge(e,t,h(i,196)):re(i,60)?new xJ(e,t,h(i,60)):re(i,19)?new Qge(e,t,h(i,19)):re(i,15)?Q1e(e,t,h(i,15),null):new TI(e,t,i,null)}function G(e,t){var i,a;return a=(!e.p&&(e.p=(Yr(),new ui)),Ii(e.p,t)),a??(i=t.Of(),re(i,4)&&(i==null?(!e.p&&(e.p=(Yr(),new ui)),hS(e.p,t)):(!e.p&&(e.p=(Yr(),new ui)),dr(e.p,t,i))),i)}function RNt(e,t){var i,a,l,f;if(e.e.c.length==0)return null;for(f=new VE,a=new j(e.e);a.a=(l/2|0))for(this.e=a?a.c:null,this.d=l;i++0;)W1e(this);this.b=t,this.a=null}function ONt(e){var t,i,a,l,f;return l=h(e.a,21).a,f=h(e.b,21).a,t=(l<0?-l:l)>(f<0?-f:f)?l<0?-l:l:f<0?-f:f,l<=0&&l==f?(i=0,a=f-1):l==-t&&f!=t?(i=f,a=l,f>=0&&++i):(i=-f,a=l),new Is(He(i),He(a))}function NNt(e,t){var i;return e.c.length==0?!1:(i=DWe((ai(0,e.c.length),h(e.c[0],14)).c.g),vl(),i==(_w(),_y)||i==vy?!0:nU(Yf(new oi(null,new di(e,16)),new iN),new aZ(t)))}function fve(e,t,i){var a,l,f;if(!e.b[t.g]){for(e.b[t.g]=!0,a=i,!i&&(a=new aU),Gi(a.b,t),f=e.a[t.g].tc();f.hc();)l=h(f.ic(),170),l.b!=t&&fve(e,l.b,a),l.c!=t&&fve(e,l.c,a),Gi(a.a,l);return a}return null}function FNt(e){switch(e.g){case 0:case 1:case 2:return Fe(),bn;case 3:case 4:case 5:return Fe(),ni;case 6:case 7:case 8:return Fe(),nn;case 9:case 10:case 11:return Fe(),Zt;default:return Fe(),Na}}function UNt(e){var t,i,a,l;for(t=0,a=e.length,l=a-4,i=0;i0)try{l=Sl(t,zs,zi)}catch(f){throw f=pr(f),re(f,118)?(a=f,Y(new hU(a))):Y(f)}return i=(!e.a&&(e.a=new MR(e)),e.a),l=0?h(ae(i,l),51):null}function qNt(e,t,i,a){var l;return l=N_(e,i,X(q(Se,1),be,2,6,[tie,nie,iie,rie,sie,oie,aie]),t),l<0&&(l=N_(e,i,X(q(Se,1),be,2,6,["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]),t)),l<0?!1:(a.d=l,!0)}function XNt(e,t,i,a){var l;return l=N_(e,i,X(q(Se,1),be,2,6,[tie,nie,iie,rie,sie,oie,aie]),t),l<0&&(l=N_(e,i,X(q(Se,1),be,2,6,["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]),t)),l<0?!1:(a.d=l,!0)}function YNt(e){var t,i,a;for(L8t(e),a=new ke,i=new j(e.a.a.b);i.a>1),pve(t,e,v,y,-l,f),pve(t,e,y,m,-l,f),f.Ld(e[y-1],e[y])<=0){for(;i=0?(t||(t=new MC,a>0&&ho(t,e.substr(0,a))),t.a+="\\",JE(t,i&jr)):t&&JE(t,i&jr);return t?t.a:e}function JNt(e,t,i){var a,l,f,g;f=e.c,g=e.d,l=(Fo(X(q(es,1),be,9,0,[f.g.k,f.k,f.a])).b+Fo(X(q(es,1),be,9,0,[g.g.k,g.k,g.a])).b)/2,f.i==(Fe(),Zt)?a=new $t(t+f.g.c.c.a+i,l):a=new $t(t-i,l),e9(e.a,0,a)}function lXe(e,t){var i,a;return Z1e(e.a),fw(e.a,(vU(),sj),sj),fw(e.a,vM,vM),a=new ss,Ai(a,vM,(VU(),Hoe)),Be(rn(t,(ww(),Yoe)))!==Be((KI(),oj))&&Ai(a,vM,Voe),Ai(a,vM,Woe),UNe(e.a,a),i=T_e(e.a,t),i}function uXe(e){if(!e)return wh(),Bnt;var t=e.valueOf?e.valueOf():e;if(t!==e){var i=Kre[typeof t];return i?i(t):Ibe(typeof t)}else return e instanceof Array||e instanceof w.Array?new wF(e):new lC(e)}function v6(e,t){var i;if(t<0)throw Y(new u8("Negative exponent"));if(t==0)return Gz;if(t==1||Obe(e,Gz)||Obe(e,cM))return e;if(!VXe(e,0)){for(i=1;!VXe(e,i);)++i;return m_(G6t(i*t),v6(o0e(e,i),t))}return YBt(e,t)}function QNt(e,t){var i,a,l;return re(t.g,8)&&h(t.g,8).j==(Xt(),Qr)?Jr:(l=ux(t),l?w.Math.max(0,e.b/2-.5):(i=p_(t),i?(a=ce(Xe(CS(i,($e(),np)))),w.Math.max(0,a/2-.5)):Jr))}function eFt(e,t){var i,a,l;return re(t.g,8)&&h(t.g,8).j==(Xt(),Qr)?Jr:(l=ux(t),l?w.Math.max(0,e.b/2-.5):(i=p_(t),i?(a=ce(Xe(CS(i,($e(),np)))),w.Math.max(0,a/2-.5)):Jr))}function tFt(e,t){var i,a,l,f,g;if(!t.Wb()){if(l=h(t.cd(0),125),t._b()==1){PYe(e,l,l,1,0,t);return}for(i=1;if.a&&!t&&(l.b=f.a),l.c=-(l.b-f.a)/2,i.g){case 1:l.d=-l.a;break;case 3:l.d=f.b}gne(a),mne(a)}function pXe(e,t,i){var a,l,f;switch(f=e.o,a=h(Ds(e.p,i),219),l=a.i,l.b=y6(a),l.a=_6(a),l.a=w.Math.max(l.a,f.b),l.a>f.b&&!t&&(l.a=f.b),l.d=-(l.a-f.b)/2,i.g){case 4:l.c=-l.b;break;case 2:l.c=f.a}gne(a),mne(a)}function sP(e,t){mZe(e,t),e.b&1&&(e.a.a=null),e.b&2&&(e.a.f=null),e.b&4&&(e.a.g=null,e.a.i=null),e.b&16&&(e.a.d=null,e.a.e=null),e.b&8&&(e.a.b=null),e.b&32&&(e.a.j=null,e.a.c=null)}function gXe(e){var t,i,a,l;if(i=h(e,42).Kg(),i)try{if(a=null,t=OS((Sg(),ku),NZe(Y6t(i))),t&&(l=t.Lg(),l&&(a=l.gk(ti(ce(i.e))))),a&&a!=e)return gXe(a)}catch(f){if(f=pr(f),!re(f,54))throw Y(f)}return e}function mXe(e,t){var i;t.d?t.d.b=t.b:e.a=t.b,t.b?t.b.d=t.d:e.e=t.d,!t.e&&!t.c?(i=h(hS(e.b,t.a),264),i.a=0,++e.c):(i=h(Ii(e.b,t.a),264),--i.a,t.e?t.e.c=t.c:i.b=t.c,t.c?t.c.e=t.e:i.c=t.e),--e.d}function mve(e){var t,i;return e>-0x800000000000&&e<0x800000000000?e==0?0:(t=e<0,t&&(e=-e),i=yr(w.Math.floor(w.Math.log(e)/.6931471805599453)),(!t||e!=w.Math.pow(2,i))&&++i,i):m$e(Wc(e))}function bXe(e,t){var i,a,l,f,g,m;for(i=e.b.c.length,l=St(e.b,t);t*2+10)for(g=e.c.d,m=e.d.d,l=au(Bc(new $t(m.a,m.b),g),1/(a+1)),f=new $t(g.a,g.b),i=new j(e.a);i.a0&&(g+=i,++t);t>1&&(g+=e.c*(t-1))}else g=oBe(S$e(wI(go(f1e(e.a),new Ok),new Fv)));return g>0?g+e.n.d+e.n.a:0}function y6(e){var t,i,a,l,f,g;if(g=0,e.b==0)g=oBe(S$e(wI(go(f1e(e.a),new Vq),new Im)));else{for(f=LHe(e,!0),t=0,a=0,l=f.length;a0&&(g+=i,++t);t>1&&(g+=e.c*(t-1))}return g>0?g+e.n.b+e.n.c:0}function rFt(e){var t,i;return i=-e.a,t=X(q(Zl,1),Ph,22,15,[43,48,48,48,48]),i<0&&(t[0]=45,i=-i),t[1]=t[1]+((i/60|0)/10|0)&jr,t[2]=t[2]+(i/60|0)%10&jr,t[3]=t[3]+(i%60/10|0)&jr,t[4]=t[4]+i%10&jr,hu(t,0,t.length)}function sFt(e){var t,i,a,l,f,g;for(g=SS(e.d,e.e),f=g.tc();f.hc();)for(l=h(f.ic(),11),a=e.e==(Fe(),nn)?l.d:l.f,i=new j(a);i.a=0;f+=i?1:-1)g=g|t.c.qf(v,f,i,a),g=g|t.q.xf(v,f,i),g=g|BZe(e,v[f],i,a);return Cr(e.c,t),g}function _Xe(e,t){var i,a,l,f,g,m;for(f=new j(e.b);f.a=0&&a0;){if(t=h(e.k.cd(e.n-1),75),i=t.nj(),re(i,62)&&h(h(i,17),62).Bb&Ja&&(!e.e||i.Vi()!=MM||i.pi()!=0)&&t.lc()!=null)return!0;--e.n}return!1}else return e.n>0}function bve(e,t){var i,a,l,f;if(wi(e),e.c!=0||e.a!=123)throw Y(new Wn(Zn((zn(),ntt))));if(f=t==112,a=e.d,i=WE(e.i,125,a),i<0)throw Y(new Wn(Zn((zn(),itt))));return l=Xf(e.i,a,i),e.d=i+1,FGe(l,f,(e.e&512)==512)}function cFt(e){var t,i;return i=-e.a,t=X(q(Zl,1),Ph,22,15,[43,48,48,58,48,48]),i<0&&(t[0]=45,i=-i),t[1]=t[1]+((i/60|0)/10|0)&jr,t[2]=t[2]+(i/60|0)%10&jr,t[4]=t[4]+(i%60/10|0)&jr,t[5]=t[5]+i%10&jr,hu(t,0,t.length)}function lFt(e){var t;return t=X(q(Zl,1),Ph,22,15,[71,77,84,45,48,48,58,48,48]),e<=0&&(t[3]=43,e=-e),t[4]=t[4]+((e/60|0)/10|0)&jr,t[5]=t[5]+(e/60|0)%10&jr,t[7]=t[7]+(e%60/10|0)&jr,t[8]=t[8]+e%10&jr,hu(t,0,t.length)}function EXe(e,t){var i,a,l;return a=new th(e),No(a,t),Ee(a,(Ie(),AG),t),Ee(a,($e(),Ki),(Ms(),Oa)),Ee(a,Bh,(ud(),uj)),Ou(a,(Xt(),Qr)),i=new yo,us(i,a),mr(i,(Fe(),nn)),l=new yo,us(l,a),mr(l,Zt),a}function SXe(e,t){var i,a,l,f,g;for(e.c[t.o]=!0,De(e.a,t),g=new j(t.i);g.a0&&(l=i),g=new j(e.f.e);g.a=f)g.Pb();else for(l=g.tc(),a=0;a0?bpe():g<0&&vve(e,t,-g),!0):!1}function pFt(e){var t,i,a,l,f,g,m,v,y,E;for(i=e.o,t=e.p,g=zi,l=zs,m=zi,f=zs,y=0;yy?l:y,m=mE?f:E);return v=l-g+1,a=f-m+1,new EUe(He(g),He(m),He(v),He(a))}function gFt(e,t){var i,a,l;return i=h(G(t,(Cf(),lM)),21).a-h(G(e,lM),21).a,i==0?(a=Bc(Ua(h(G(e,(Fg(),y5)),9)),h(G(e,HP),9)),l=Bc(Ua(h(G(t,y5),9)),h(G(t,HP),9)),to(a.a*a.b,l.a*l.b)):i}function mFt(e,t){var i,a,l;return i=h(G(t,(Ew(),rj)),21).a-h(G(e,rj),21).a,i==0?(a=Bc(Ua(h(G(e,(ha(),X5)),9)),h(G(e,gL),9)),l=Bc(Ua(h(G(t,X5),9)),h(G(t,gL),9)),to(a.a*a.b,l.a*l.b)):i}function bFt(e,t,i){var a,l,f,g,m,v;if(!e||e.c.length==0)return null;for(f=new e7e(t,!i),l=new j(e);l.a0)switch(t.g){case 2:f.n.c=e.s;break;case 4:f.n.b=e.s}}function Vte(e,t){var i,a,l;if(l=zS((qc(),Zs),e.mg(),t),l)return Yo(),h(l,61).bj()||(l=pA(Vo(Zs,l))),a=(i=e.rg(l),h(i>=0?e.ug(i,!0,!0):Ax(e,l,!0),184)),h(a,237).wk(t);throw Y(new un(ry+t.be()+mxe))}function _Ft(e,t,i){var a,l,f,g;return f=CKe(cee(),t),a=null,f&&(g=yKe(f,i),l=null,g!=null&&(l=(g==null?(!e.o&&(e.o=new il((Ta(),op),pm,e,0)),a6(e.o,f)):(!e.o&&(e.o=new il((Ta(),op),pm,e,0)),p6(e.o,f,g)),e)),a=l),a}function _ve(e,t,i,a){var l,f,g,m,v;if(l=e.d[t],l){if(f=l.g,v=l.i,a!=null){for(m=0;m1||i==-1?(e.b=-1,!0):(t=pu(e),t&&(Yo(),t.Ri()==Dtt)?(e.b=-1,!0):(e.b=1,!1));default:case 1:return!1}}function yFt(e,t){var i,a,l,f,g;for(a=(!t.s&&(t.s=new ze(Sc,t,21,17)),t.s),f=null,l=0,g=a.i;ll)?(Rn(f.a!=null),h(f.a,8)):null}function MFt(e,t){Vu();var i,a,l,f,g,m;for(i=null,g=t.tc();g.hc();)f=h(g.ic(),125),!f.k&&(a=GSt(f.a),l=zCt(f.a),m=new dP(a,l,null,h(f.d.a.Xb().tc().ic(),14)),De(m.c,f.a),e.c[e.c.length]=m,i&&De(i.d,m),i=m)}function TFt(e,t,i){var a,l,f,g,m,v;for(a=h(er(e.c,t),15),l=h(er(e.c,i),15),f=a.fd(a._b()),g=l.fd(l._b());f.Cc()&&g.Cc();)if(m=h(f.Ec(),21),v=h(g.Ec(),21),m!=v)return kp(m.a,v.a);return!f.hc()&&!g.hc()?0:f.hc()?1:-1}function oP(e,t,i,a,l){var f,g,m,v;return v=yJ(e,h(l,51)),Be(v)!==Be(l)?(m=h(e.g[i],75),f=Dg(t,v),JC(e,i,Ite(e,i,f)),$u(e.e)&&(g=Wm(e,9,f.nj(),l,v,a,!1),Hwe(g,new Wd(e.e,9,e.c,m,f,a,!1)),XQ(g)),v):l}function CFt(e,t,i){var a,l,f,g;for(l=i,f=c8e(wI(h(h(er(e.r,t),19),60).xc(),new Hb)),g=0;f.a||(f.a=a_(f.c,f)),f.a;)if(l){eU(f),l=!1;continue}else a=eU(f),f.a||(f.a=a_(f.c,f)),f.a&&(g=w.Math.max(g,a));return g}function ir(e,t,i){var a;if(a=h(e.c.Vb(t),13),a)return a.nc(i)?(++e.d,!0):!1;if(a=e.Pc(t),a.nc(i))return++e.d,e.c.Zb(t,a),!0;throw Y(new AQ("New Collection violated the Collection spec"))}function AFt(e){var t,i,a,l,f,g;for(l=0,e.q=new ke,t=new zr,g=new j(e.p);g.a>16),t=a>>16&16,i=16-t,e=e>>t,a=e-256,t=a>>16&8,i+=t,e<<=t,a=e-W0,t=a>>16&4,i+=t,e<<=t,a=e-Ah,t=a>>16&2,i+=t,e<<=t,a=e>>14,t=a&~(a>>1),i+2-t)}function LFt(e,t,i,a){var l,f,g,m,v,y;for(l=0;l=0&&y>=0&&v=0?e.ug(a,!0,!0):Ax(e,f,!0),184)),h(l,237).sk(t,i);throw Y(new un(ry+t.be()+mxe))}function LXe(e){var t,i;if(Bd(h(G(e,($e(),Ki)),83)))for(i=new j(e.i);i.a>24;return g}function BFt(e,t){var i,a,l,f,g;if(i=h(sn(e.a,4),116),g=i==null?0:i.length,t>=g)throw Y(new o_(t,g));return l=i[t],g==1?a=null:(a=le(kae,kre,380,g-1,0,1),vc(i,0,a,0,t),f=g-t-1,f>0&&vc(i,t+1,a,t,f)),l6(e,a),Vqe(e,t,l),l}function OFt(e,t){var i,a,l;if(Be(e)===Be(t))return!0;if(e==null||t==null||e.length!=t.length)return!1;for(i=0;i=null.tl()?(_7(e),Sve(e)):t.hc()}function Wte(e){var t,i;if(T0(e))throw Y(new un(jQe));for(i=Nn(e,0);i.b!=i.d.c;)t=h(Un(i),9),this.d=w.Math.min(this.d,t.b),this.c=w.Math.max(this.c,t.a),this.a=w.Math.max(this.a,t.b),this.b=w.Math.min(this.b,t.a)}function UFt(e){var t,i;return t=new ss,oc(t,bat),i=h(G(e,(Ie(),Va)),19),i.pc((xo(),C5))&&oc(t,xat),i.pc(hM)&&oc(t,wat),(i.pc(dy)||ce(mt(G(e,($e(),D5)))))&&(oc(t,_at),i.pc(py)&&oc(t,yat)),i.pc(dM)&&oc(t,vat),t}function Hte(e){var t,i;if(t=ti(rn(e,(ur(),yCe))),i=B5t(cee(),t),!i)throw t==null||t.length==0?Y(new kR("No layout algorithm has been specified ("+e+").")):Y(new kR("Layout algorithm not found: "+t));return i}function Px(){Px=M,y3=h(ae(ye((ype(),ma).qb),6),29),_3=h(ae(ye(ma.qb),3),29),Nae=h(ae(ye(ma.qb),4),29),Fae=h(ae(ye(ma.qb),5),17),c7(y3),c7(_3),c7(Nae),c7(Fae),aut=new Bl(X(q(Sc,1),oy,158,0,[y3,_3]))}function OXe(e){var t=(!Yre&&(Yre=h$t()),Yre),i=e.replace(/[\x00-\x1f\xad\u0600-\u0603\u06dd\u070f\u17b4\u17b5\u200b-\u200f\u2028-\u202e\u2060-\u2064\u206a-\u206f\ufeff\ufff9-\ufffb"\\]/g,function(a){return KPt(a,t)});return'"'+i+'"'}function zFt(e){var t,i,a,l,f,g;for(l=e.e.c.length,a=le(yu,Lw,15,l,0,1),g=new j(e.e);g.a=0;)a=i[f],g.Bk(a.nj())&&$n(l,a);!g$t(e,l)&&$u(e.e)&&Dn(e,t.lj()?Wm(e,6,t,(_t(),uo),null,-1,!1):Wm(e,t.Zi()?2:1,t,null,null,-1,!1))}function WFt(e,t){var i,a,l,f,g;return e.a==(IS(),ZP)?!0:(f=t.a.c,i=t.a.c+t.a.b,!(t.i&&(a=t.u,g=a.c.c.a-a.n.a/2,l=f-(a.k.a+a.n.a),l>g)||t.n&&(a=t.v,g=a.c.c.a-a.n.a/2,l=a.k.a-i,l>g)))}function zXe(e,t,i){var a,l,f,g,m,v;for(a=0,v=i,t||(a=i*(e.c.length-1),v*=-1),f=new j(e);f.a1?e.e*=ce(e.a):e.f/=ce(e.a),WIt(e),E5t(e),kUt(e),Ee(e.b,(qA(),Yz),e.g)}function qFt(e){lx();var t,i,a,l;for(Zz=new ke,fse=(Yr(),new ui),use=new ke,t=(!e.a&&(e.a=new ze(Br,e,10,11)),e.a),Qjt(t),l=new Bn(t);l.e!=l.i._b();)a=h(Yn(l),35),Qo(Zz,a,0)==-1&&(i=new ke,De(use,i),nHe(a,i));return use}function XFt(e,t){var i,a,l,f,g,m,v;if(a=QVe(e.Db&254),a==1)e.Eb=null;else if(f=__(e.Eb),a==2)l=Ste(e,t),e.Eb=f[l==0?1:0];else{for(g=le(on,et,1,a-1,5,1),i=2,m=0,v=0;i<=128;i<<=1)i==t?++m:e.Db&i&&(g[v++]=f[m++]);e.Eb=g}e.Db&=~t}function $Xe(e,t,i){var a,l,f;e.ti()?(f=e.ui(),e6(e,t,i),a=e.mi(3,null,i,t,f),e.qi()?(l=e.ri(i,null),e.xi()&&(l=e.yi(i,l)),l?(l.Sh(a),l.Th()):e.ni(a)):e.ni(a)):(e6(e,t,i),e.qi()&&(l=e.ri(i,null),l&&l.Th()))}function qte(e,t){var i,a,l,f;e.ti()?(i=e.i,f=e.ui(),MI(e,t),a=e.mi(3,null,t,i,f),e.qi()?(l=e.ri(t,null),e.xi()&&(l=e.yi(t,l)),l?(l.Sh(a),l.Th()):e.ni(a)):e.ni(a)):(MI(e,t),e.qi()&&(l=e.ri(t,null),l&&l.Th()))}function Cve(e,t){var i,a,l,f,g;if(t===e)return!0;if(!re(t,15)||(g=h(t,15),e._b()!=g._b()))return!1;for(f=g.tc(),a=e.tc();a.hc();)if(i=a.ic(),l=f.ic(),!(Be(i)===Be(l)||i!=null&&ki(i,l)))return!1;return!0}function VXe(e,t){var i,a,l;if(t==0)return(e.a[0]&1)!=0;if(t<0)throw Y(new u8("Negative bit address"));if(l=t>>5,l>=e.d)return e.e<0;if(i=e.a[l],t=1<<(t&31),e.e<0){if(a=L$e(e),l=0?e.jg(null):e.yg().Cg(e,-1-t,null,null)),e.kg(h(l,42),i),a&&a.Th(),e.eg()&&e.fg()&&i>-1&&Li(e,new ls(e,9,i,f,l)),l):f}function BS(){BS=M,Pae=new Q2(AQe,0),kj=new Q2("INSIDE_SELF_LOOPS",1),Rj=new Q2("MULTI_EDGES",2),Lj=new Q2("EDGE_LABELS",3),Aae=new Q2("PORTS",4),Pj=new Q2("COMPOUND",5),Aj=new Q2("CLUSTERS",6),Cae=new Q2("DISCONNECTED",7)}function WXe(e){var t,i;if(e.f){for(;e.n>16)),15).dd(f),m0&&(!(n_(e.a.c)&&t.n.d)&&!(YR(e.a.c)&&t.n.b)&&(t.g.d+=w.Math.max(0,a/2-.5)),!(n_(e.a.c)&&t.n.a)&&!(YR(e.a.c)&&t.n.c)&&(t.g.a-=a-1))}function KXe(e,t,i){var a,l,f,g,m,v;f=h(St(t.d,0),14).c,a=f.g,l=a.j,v=h(St(i.f,0),14).d,g=v.g,m=g.j,l==(Xt(),Nr)?Ee(e,(Ie(),Cl),h(G(a,Cl),11)):Ee(e,(Ie(),Cl),f),m==Nr?Ee(e,(Ie(),Al),h(G(g,Al),11)):Ee(e,(Ie(),Al),v)}function Yte(e){var t,i,a;if(e.length==0)throw Y(new un(jQe));for(i=0,a=e.length;i>t,f=e.m>>t|i<<22-t,l=e.l>>t|e.m<<22-t):t<44?(g=a?Kd:0,f=i>>t-22,l=e.m>>t-22|i<<44-t):(g=a?Kd:0,f=a?Yc:0,l=i>>t-44),Xa(l&Yc,f&Yc,g&Kd)}function Zte(e){var t,i,a,l,f,g;for(this.c=new ke,this.d=e,a=Jr,l=Jr,t=Ts,i=Ts,g=Nn(e,0);g.b!=g.d.c;)f=h(Un(g),9),a=w.Math.min(a,f.a),l=w.Math.min(l,f.b),t=w.Math.max(t,f.a),i=w.Math.max(i,f.b);this.a=new Zf(a,l,t-a,i-l)}function Rve(e){var t,i,a;this.c=e,a=h(G(e,($e(),nf)),110),t=ce(Xe(G(e,kG))),i=ce(Xe(G(e,tTe))),a==(qs(),rf)||a==sf||a==Oh?this.b=t*i:this.b=1/(t*i),this.j=ce(Xe(G(e,Hw))),this.e=ce(Xe(G(e,np))),this.f=e.b.c.length}function JXe(e){switch(e.g){case 0:return new zv;case 1:return new uF;case 2:return new _g;case 3:return new jOe;case 4:return new TUe;default:throw Y(new un("No implementation is available for the node placer "+(e.f!=null?e.f:""+e.g)))}}function Ku(e){var t;return t=new ou(Um(e.ql)),t.a+="@",Mi(t,(Hr(e)>>>0).toString(16)),e.Eg()?(t.a+=" (eProxyURI: ",Ic(t,e.Kg()),e.tg()&&(t.a+=" eClass: ",Ic(t,e.tg())),t.a+=")"):e.tg()&&(t.a+=" (eClass: ",Ic(t,e.tg()),t.a+=")"),t.a}function QXe(e,t){var i,a,l,f,g,m,v,y,E;if(e.a.f>0&&re(t,38)&&(e.a.Fi(),y=h(t,38),v=y.kc(),f=v==null?0:Hr(v),g=sme(e.a,f),i=e.a.d[g],i)){for(a=h(i.g,339),E=i.i,m=0;m0&&l0):l<0&&-l0):!1}function m7(e,t,i,a,l){var f,g,m,v,y,E;for(f=a,y=h(h(er(e.r,t),19),60).tc();y.hc();){if(v=h(y.ic(),111),f){f=!1;continue}g=0,l>0?g=l:v.c&&(g=w9(v.c)),g>0&&(i?(E=v.b.Re().a,g>E&&(m=(g-E)/2,v.d.b=m,v.d.c=m)):v.d.c=e.s+g)}}function Ive(e,t,i){switch(t){case 7:!e.e&&(e.e=new an(js,e,7,4)),Pr(e.e),!e.e&&(e.e=new an(js,e,7,4)),Mr(e.e,h(i,13));return;case 8:!e.d&&(e.d=new an(js,e,8,5)),Pr(e.d),!e.d&&(e.d=new an(js,e,8,5)),Mr(e.d,h(i,13));return}$we(e,t,i)}function n8t(e){var t,i;if(e.c.length!=2)throw Y(new ba("Order only allowed for two paths."));t=(ai(0,e.c.length),h(e.c[0],14)),i=(ai(1,e.c.length),h(e.c[1],14)),t.d.g!=i.c.g&&(e.c=le(on,et,1,0,5,1),e.c[e.c.length]=i,e.c[e.c.length]=t)}function i8t(e){var t,i,a,l;if(e==null)return null;if(a=Ba(e,!0),l=u5.length,dt(a.substr(a.length-l,l),u5)){if(i=a.length,i==4){if(t=a.charCodeAt(0),t==43)return iPe;if(t==45)return Eut}else if(i==3)return iPe}return xw(a)}function r8t(e,t,i){var a;a=null,t&&(a=t.d),tP(e,new jE(t.k.a-a.b+i.a,t.k.b-a.d+i.b)),tP(e,new jE(t.k.a-a.b+i.a,t.k.b+t.n.b+a.a+i.b)),tP(e,new jE(t.k.a+t.n.a+a.c+i.a,t.k.b-a.d+i.b)),tP(e,new jE(t.k.a+t.n.a+a.c+i.a,t.k.b+t.n.b+a.a+i.b))}function s8t(e,t){var i,a,l,f,g;for(ii(t,"Port side processing",1),g=new j(e.a);g.av-i&&m=e.c.a.length)return t;for(a=Ic(Mi(new f0,"expected one element but was: <"),t),i=0;i<4&&e.a=0?e.Mg(f,i):Uve(e,l,i);else throw Y(new un(ry+l.be()+gre));else throw Y(new un("The feature ID"+t+" is not a valid feature ID"));else Wl(e,a,l,i)}function Kte(e,t,i,a,l){var f,g,m,v,y,E,C,R,B;return g=i-e,m=a-t,f=w.Math.atan2(g,m),v=f+Cie,y=f-Cie,E=l*w.Math.sin(v)+e,R=l*w.Math.cos(v)+t,C=l*w.Math.sin(y)+e,B=l*w.Math.cos(y)+t,Ym(X(q(es,1),be,9,0,[new $t(E,R),new $t(C,B)]))}function oYe(e){var t,i,a,l,f,g,m;for(f=0,l=e.f.e,i=0;i=0)return l;for(f=1,m=new j(t.i);m.av+1?f:v+1);return J6t(e,t,f),f}function a1(){a1=M,Mu=new Qv("H_LEFT",0),Nh=new Qv("H_CENTER",1),Cu=new Qv("H_RIGHT",2),If=new Qv("V_TOP",3),af=new Qv("V_CENTER",4),of=new Qv("V_BOTTOM",5),Ll=new Qv("INSIDE",6),Au=new Qv("OUTSIDE",7),Tu=new Qv("H_PRIORITY",8)}function rn(e,t){var i,a;return a=(!e.o&&(e.o=new il((Ta(),op),pm,e,0)),Tf(e.o,t)),a??(i=t.Of(),re(i,4)&&(i==null?(!e.o&&(e.o=new il((Ta(),op),pm,e,0)),a6(e.o,t)):(!e.o&&(e.o=new il((Ta(),op),pm,e,0)),p6(e.o,t,i))),i)}function d8t(e){var t,i,a,l,f,g,m;if(t=e.Yg(wu),t&&(m=ti(Tf((!t.b&&(t.b=new wl((yt(),zo),Aa,t)),t.b),"settingDelegates")),m!=null)){for(i=new ke,l=Lx(m,"\\w+"),f=0,g=l.length;f0?(t-=1,i-=1):a>=0&&l<0?(t+=1,i+=1):a>0&&l>=0?(t-=1,i+=1):(t+=1,i-=1),new Is(He(t),He(i))}function Dve(e,t,i){var a,l,f;if(t!=i){a=t;do tr(e,a.c),l=h(G(a,(Ie(),sm)),8),l&&(f=a.d,Fl(e,f.b,f.d),tr(e,l.k),a=va(l));while(l);a=i;do Bc(e,a.c),l=h(G(a,(Ie(),sm)),8),l&&(f=a.d,iI(e,f.b,f.d),Bc(e,l.k),a=va(l));while(l)}}function m8t(e,t,i){var a,l,f,g,m,v;a=new ke,a.c[a.c.length]=t,v=t,m=0;do v=jjt(e,v),v&&(a.c[a.c.length]=v),++m;while(v);for(g=(i-(a.c.length-1)*e.d.d)/a.c.length,f=new j(a);f.at.c?1:e.bt.b?1:e.a!=t.a?Hr(e.a)-Hr(t.a):e.d==(wA(),fL)&&t.d==uL?-1:e.d==uL&&t.d==fL?1:0}function Jte(e){var t,i,a,l,f,g,m,v;for(l=Jr,a=Ts,i=new j(e.e.b);i.a=0;t-=2)for(i=0;i<=t;i+=2)(e.b[i]>e.b[i+2]||e.b[i]===e.b[i+2]&&e.b[i+1]>e.b[i+3])&&(a=e.b[i+2],e.b[i+2]=e.b[i],e.b[i]=a,a=e.b[i+3],e.b[i+3]=e.b[i+1],e.b[i+1]=a);e.c=!0}}function fYe(e,t){var i,a,l,f,g,m,v,y;for(g=t==1?_se:vse,f=g.a.Xb().tc();f.hc();)for(l=h(f.ic(),110),v=h(er(e.f.c,l),19).tc();v.hc();)switch(m=h(v.ic(),48),a=h(m.b,80),y=h(m.a,172),i=y.c,l.g){case 2:case 1:a.g.d+=i;break;case 4:case 3:a.g.c+=i}}function A8t(e){Zve();var t,i,a,l,f,g,m;if(e==null||(l=e.length,l%2!=0))return null;for(t=fU(e),f=l/2|0,i=le(Mc,sy,22,f,15,1),a=0;a>24}return i}function OS(e,t){var i,a,l;return i=t==null?Dc(gc(e.d,null)):NC(e.e,t),re(i,207)?(l=h(i,207),l.gh()==null,l):re(i,456)?(a=h(i,1631),l=a.a,l&&(l.yb==null||(t==null?El(e.d,null,l):D0(e.e,t,l))),l):null}function P8t(e,t){var i,a,l,f,g;if(a=t.nj(),G0(e.e,a)){if(a.xh()&&$Q(e,a,t.lc()))return!1}else for(g=cl(e.e.mg(),a),i=h(e.g,124),l=0;l0&&(!(n_(e.a.c)&&t.n.d)&&!(YR(e.a.c)&&t.n.b)&&(t.g.d-=w.Math.max(0,a/2-.5)),!(n_(e.a.c)&&t.n.a)&&!(YR(e.a.c)&&t.n.c)&&(t.g.a+=w.Math.max(0,a-1)))}function hYe(e,t,i){var a,l;if((e.c-e.b&e.a.length-1)==2)t==(Fe(),bn)||t==Zt?(bU(h(IA(e),15),(xl(),Ed)),bU(h(IA(e),15),dm)):(bU(h(IA(e),15),(xl(),dm)),bU(h(IA(e),15),Ed));else for(l=new hA(e);l.a!=l.b;)a=h(DU(l),15),bU(a,i)}function dYe(e){var t,i,a,l,f,g,m;if(e&&(t=e.Yg(wu),t&&(g=ti(Tf((!t.b&&(t.b=new wl((yt(),zo),Aa,t)),t.b),"conversionDelegates")),g!=null))){for(m=new ke,a=Lx(g,"\\w+"),l=0,f=a.length;l=2147483648&&(a-=fie),a)}function pYe(e,t,i){var a,l,f,g;BUe(e,t)>BUe(e,i)?(a=sa(i,(Fe(),Zt)),e.d=a.Wb()?0:fI(h(a.cd(0),11)),g=sa(t,nn),e.b=g.Wb()?0:fI(h(g.cd(0),11))):(l=sa(i,(Fe(),nn)),e.d=l.Wb()?0:fI(h(l.cd(0),11)),f=sa(t,Zt),e.b=f.Wb()?0:fI(h(f.cd(0),11)))}function k8t(e){var t,i,a,l,f,g;if(l=h(St(e.i,0),11),l.d.c.length+l.f.c.length==0)e.k.a=0;else{for(g=0,a=Cn(Fp(new Rd(l),new Wv(l)));Gn(a);)i=h(Tn(a),11),g+=i.g.k.a+i.k.a+i.a.a;t=h(G(e,($e(),$w)),9),f=t?t.a:0,e.k.a=g/(l.d.c.length+l.f.c.length)-f}}function gYe(e){switch(e.g){case 0:return new iFe;case 1:return new aF;case 2:return new GOe;case 3:return new T2;case 4:return new d8e;case 5:return new lF;default:throw Y(new un("No implementation is available for the layerer "+(e.f!=null?e.f:""+e.g)))}}function mYe(e,t){var i,a,l,f;for(i=e.o.a,f=h(h(er(e.r,t),19),60).tc();f.hc();)l=h(f.ic(),111),l.e.a=i*ce(Xe(l.b.xe(Tj))),l.e.b=(a=l.b,a.ye((ur(),Zc))?a.ef()==(Fe(),bn)?-a.Re().b-ce(Xe(a.xe(Zc))):ce(Xe(a.xe(Zc))):a.ef()==(Fe(),bn)?-a.Re().b:0)}function Qte(e,t){DS();var i,a,l,f,g,m,v,y,E;return t.d>e.d&&(m=e,e=t,t=m),t.d<63?C9t(e,t):(g=(e.d&-2)<<4,y=o0e(e,g),E=o0e(t,g),a=pne(e,hx(y,g)),l=pne(t,hx(E,g)),v=Qte(y,E),i=Qte(a,l),f=Qte(pne(y,a),pne(l,E)),f=xne(xne(f,v),i),f=hx(f,g),v=hx(v,g<<1),xne(xne(v,f),i))}function bYe(e,t,i){var a,l,f;for(DMt.call(this,new ke),this.a=t,this.b=i,this.e=e,a=(e.b&&vne(e),e.a),this.d=PUe(a.a,this.a),this.c=PUe(a.b,this.b),I6t(this,this.d,this.c),fFt(this),f=this.e.e.a.Xb().tc();f.hc();)l=h(f.ic(),247),l.c.c.length>0&&lGt(this,l)}function R8t(e){var t,i,a,l;for(t=0,i=0,l=new j(e.i);l.a1||i>1)return 2;return t+i==1?2:0}function I8t(e,t,i){var a,l,f,g,m,v,y;a=i,l=t;do l=e.a[l.o],g=(y=e.g[l.o],ce(e.p[y.o])+ce(e.d[l.o])-l.d.d),m=tkt(l,l.c?Qo(l.c.a,l,0):-1),m&&(f=(v=e.g[m.o],ce(e.p[v.o])+ce(e.d[m.o])+m.n.b+m.d.a),a=w.Math.min(a,g-(f+r_(e.k,l,m))));while(t!=l);return a}function D8t(e,t,i){var a,l,f,g,m,v,y;a=i,l=t;do l=e.a[l.o],f=(y=e.g[l.o],ce(e.p[y.o])+ce(e.d[l.o])+l.n.b+l.d.a),m=mRt(l,l.c?Qo(l.c.a,l,0):-1),m&&(g=(v=e.g[m.o],ce(e.p[v.o])+ce(e.d[m.o])-m.d.d),a=w.Math.min(a,g-(f+r_(e.k,l,m))));while(t!=l);return a}function B8t(e,t,i){var a,l,f,g;for(l=i,f=c8e(wI(h(h(er(e.r,t),19),60).xc(),new yp)),g=0;f.a||(f.a=a_(f.c,f)),f.a;)if(l){Rn((f.a||(f.a=a_(f.c,f)),f.a)),f.a=!1,l=!1;continue}else a=eU(f),f.a||(f.a=a_(f.c,f)),f.a&&(g=w.Math.max(g,a));return g}function O8t(e,t,i){var a,l,f,g,m,v,y,E;if(i)for(f=i.a.length,a=new jm(f),m=(a.b-a.a)*a.c<0?(Mg(),mm):new Cg(a);m.hc();)g=h(m.ic(),21),l=uS(i,g.a),l&&(v=X4t(e,(y=(d0(),E=new lpe,E),t&&MYe(y,t),y),l),jI(v,Vd(l,Rh)),o7(l,v),lve(l,v),mee(e,l,v))}function N8t(e){var t,i,a;return i=h(e.a,21).a,a=h(e.b,21).a,t=(i<0?-i:i)>(a<0?-a:a)?i<0?-i:i:a<0?-a:a,i=-t&&a==t?new Is(He(i-1),He(a)):new Is(He(i),He(a-1))}function wYe(e){var t,i,a,l,f,g;for(g=h(vo(e.a,le(Eu,Af,8,e.a.c.length,0,1)),123),vge(g,new wH),i=null,l=0,f=g.length;la.o?mr(l,ni):l.i==ni&&a.o>e.o&&mr(l,bn);break}return a}function Nve(e,t,i){var a,l,f;for(f=new j(e.e);f.a0&&(a.b.c-=a.c,a.b.c<=0&&a.b.f>0&&Gi(t,a.b));for(l=new j(e.b);l.a0&&(a.a.f-=a.c,a.a.f<=0&&a.a.c>0&&Gi(i,a.a))}function Fve(e,t,i){var a,l,f;for(f=new j(e.q);f.a0&&(a.b.j-=a.c,a.b.j<=0&&a.b.r>0&&Gi(t,a.b));for(l=new j(e.g);l.a0&&(a.a.r-=a.c,a.a.r<=0&&a.a.j>0&&Gi(i,a.a))}function _7(e){var t,i,a,l,f;if(e.g==null&&(e.d=e.Gh(e.f),$n(e,e.d),e.c))return f=e.f,f;if(t=h(e.g[e.i-1],43),l=t.ic(),e.e=t,i=e.Gh(l),i.hc())e.d=i,$n(e,i);else for(e.d=null;!t.hc()&&(Gr(e.g,--e.i,null),e.i!=0);)a=h(e.g[e.i-1],43),t=a;return l}function E6(e,t){var i,a,l,f;for(e=e,i=new tw,f=0,a=0;a=0?e.ug(a,!0,!0):Ax(e,f,!0),184)),h(l,237).xk(t,i)}else throw Y(new un(ry+t.be()+gre))}function zve(e,t,i){switch(i.g){case 1:return new $t(t.a,w.Math.min(e.d.b,t.b));case 2:return new $t(w.Math.max(e.c.a,t.a),t.b);case 3:return new $t(t.a,w.Math.max(e.c.b,t.b));case 4:return new $t(w.Math.min(t.a,e.d.a),t.b)}return new $t(t.a,t.b)}function S6(e){var t,i,a;for(t=ed(1+(!e.c&&(e.c=new ze(Pu,e,9,9)),e.c).i),De(t,(!e.d&&(e.d=new an(js,e,8,5)),e.d)),a=new Bn((!e.c&&(e.c=new ze(Pu,e,9,9)),e.c));a.e!=a.i._b();)i=h(Yn(a),121),De(t,(!i.d&&(i.d=new an(js,i,8,5)),i.d));return Hn(t),new ex(t)}function Th(e){var t,i,a;for(t=ed(1+(!e.c&&(e.c=new ze(Pu,e,9,9)),e.c).i),De(t,(!e.e&&(e.e=new an(js,e,7,4)),e.e)),a=new Bn((!e.c&&(e.c=new ze(Pu,e,9,9)),e.c));a.e!=a.i._b();)i=h(Yn(a),121),De(t,(!i.e&&(i.e=new an(js,i,7,4)),i.e));return Hn(t),new ex(t)}function j8t(e,t){var i,a,l,f,g;if(ii(t,"Breaking Point Processor",1),gjt(e),ce(mt(G(e,($e(),oTe))))){for(l=new j(e.b);l.a3&&ad(e,0,t-3))}function W8t(e){var t,i,a;return i=e.l,i&i-1||(a=e.m,a&a-1)||(t=e.h,t&t-1)||t==0&&a==0&&i==0?-1:t==0&&a==0&&i!=0?Z0e(i):t==0&&a!=0&&i==0?Z0e(a)+22:t!=0&&a==0&&i==0?Z0e(t)+44:-1}function H8t(e,t){var i,a,l,f,g;for(ii(t,"Edge joining",1),i=ce(mt(G(e,($e(),_oe)))),l=new j(e.b);l.a0),f.a.cd(f.c=--f.b),td(f,l),Rn(f.bey,v=Eey,v=Eey,v=Eey,v=E=0){if(t==i)return new Is(He(-t-1),He(-t-1));if(t==-i)return new Is(He(-t),He(i+1))}return(t<0?-t:t)>(i<0?-i:i)?t<0?new Is(He(-t),He(i)):new Is(He(-t),He(i+1)):new Is(He(t+1),He(i))}function Q8t(e,t,i){var a,l,f,g,m;return l=h(rn(t,(l7(),_Ce)),21),!l&&(l=He(0)),f=h(rn(i,_Ce),21),!f&&(f=He(0)),l.a>f.a?-1:l.a1)for(t=m0((i=new Fm,++e.b,i),e.d),m=Nn(f,0);m.b!=m.d.c;)g=h(Un(m),113),Ju(zu(Uu(Gu(Fu(new iu,1),0),t),g))}function i9t(e,t,i){var a,l,f,g,m;for(ii(i,"Breaking Point Removing",1),e.a=h(G(t,($e(),cm)),197),f=new j(t.b);f.a>16!=6&&t){if(LS(e,t))throw Y(new un(LP+kXe(e)));a=null,e.Cb&&(a=(i=e.Db>>16,i>=0?Awe(e,null):e.Cb.Cg(e,-1-i,null,null))),t&&(a=yx(t,e,6,a)),a=ime(e,t,a),a&&a.Th()}else e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,6,t,t))}function SYe(e,t){var i,a;if(t!=e.Cb||e.Db>>16!=3&&t){if(LS(e,t))throw Y(new un(LP+uKe(e)));a=null,e.Cb&&(a=(i=e.Db>>16,i>=0?kwe(e,null):e.Cb.Cg(e,-1-i,null,null))),t&&(a=yx(t,e,12,a)),a=nme(e,t,a),a&&a.Th()}else e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,3,t,t))}function MYe(e,t){var i,a;if(t!=e.Cb||e.Db>>16!=9&&t){if(LS(e,t))throw Y(new un(LP+vZe(e)));a=null,e.Cb&&(a=(i=e.Db>>16,i>=0?Lwe(e,null):e.Cb.Cg(e,-1-i,null,null))),t&&(a=yx(t,e,9,a)),a=rme(e,t,a),a&&a.Th()}else e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,9,t,t))}function TYe(e,t){var i,a;if(t!=e.Cb||e.Db>>16!=11&&t){if(LS(e,t))throw Y(new un(LP+s_e(e)));a=null,e.Cb&&(a=(i=e.Db>>16,i>=0?Dwe(e,null):e.Cb.Cg(e,-1-i,null,null))),t&&(a=yx(t,e,10,a)),a=hme(e,t,a),a&&a.Th()}else e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,11,t,t))}function a9t(e,t){if(re(t,246))return s6t(e,h(t,35));if(re(t,187))return o6t(e,h(t,121));if(re(t,263))return uPt(e,h(t,137));if(re(t,183))return yUt(e,h(t,105));if(t)return null;throw Y(new un(Txe+Vp(new Bl(X(q(on,1),et,1,5,[null])))))}function c9t(e){var t,i,a,l,f,g,m,v,y,E,C;return C=Zwe(e),t=e.a,v=t!=null,v&&sA(C,"category",e.a),l=x8(new Gv(e.d)),g=!l,g&&(y=new Om,Og(C,"knownOptions",y),i=new zZ(y),mo(new Gv(e.d),i)),f=x8(e.g),m=!f,m&&(E=new Om,Og(C,"supportedFeatures",E),a=new GZ(E),mo(e.g,a)),C}function l9t(e,t,i){var a,l,f;for(l=new j(e.a.b);l.av){for(E=e.d,e.d=le(PAe,Oxe,55,2*v+4,0,1),f=0;f=9223372036854776e3?(gS(),o3e):(l=!1,e<0&&(l=!0,e=-e),a=0,e>=l1&&(a=yr(e/l1),e-=a*l1),i=0,e>=Nx&&(i=yr(e/Nx),e-=i*Nx),t=yr(e),f=Xa(t,i,a),l&&Cee(f),f)}function CYe(e,t,i){var a,l,f,g,m,v;if(!T0(t)){for(v=bc(i,(re(t,13)?h(t,13)._b():vA(t.tc()))/e.a|0),ii(v,WQe,1),m=new Dk,g=0,f=t.tc();f.hc();)a=h(f.ic(),76),m=Fp(m,new Dd(a)),gkw,f=a-gkw,(l||f)&&(v=h(t.e,249).b,g=h(t.e,249).a,m=h(t.d,129),v==0&&g==0)))return m;return m}function AYe(e,t,i,a){var l,f,g,m;return g=new th(e),Ou(g,(Xt(),Nr)),Ee(g,(Ie(),Jn),t),Ee(g,($e(),Ki),(Ms(),Oa)),Ee(g,Cl,i),Ee(g,Al,a),f=new yo,mr(f,(Fe(),nn)),us(f,g),m=new yo,mr(m,Zt),us(m,g),_s(t,f),l=new Op,No(l,t),Ee(l,Lo,null),Os(l,m),_s(l,a),g}function b9t(e,t,i,a,l){var f,g;(!Jo(t)&&t.c.g.c==t.d.g.c||!d$e(Fo(X(q(es,1),be,9,0,[l.g.k,l.k,l.a])),i))&&(t.c==l?e9(t.a,0,new Do(i)):Gi(t.a,new Do(i)),a&&!IC(e.a,i)&&(g=h(G(t,($e(),Lo)),74),g||(g=new zc,Ee(t,Lo,g)),f=new Do(i),Fs(g,f,g.c.b,g.c),Cr(e.a,f)))}function w9t(e,t){var i,a;if(a=R9(e.b,t.b),!a)throw Y(new ba("Invalid hitboxes for scanline constraint calculation."));(cVe(t.b,h(jMt(e.b,t.b),57))||cVe(t.b,h(GMt(e.b,t.b),57)))&&(Jh(),t.b+""),e.a[t.b.f]=h(LJ(e.b,t.b),57),i=h(kJ(e.b,t.b),57),i&&(e.a[i.f]=t.b)}function PYe(e,t,i,a,l,f){var g,m,v,y,E,C,R,B,N,W,V,ee;for(E=a,t.i&&t.k?(B=h(Ii(e.f,t.u),57),W=B.d.c+B.d.b,--E):W=t.a.c+t.a.b,C=l,i.n&&i.k?(B=h(Ii(e.f,i.v),57),y=B.d.c,++C):y=i.a.c,V=y-W,v=2>C-E?2:C-E,m=V/v,N=W+m,R=E;R>16!=7&&t){if(LS(e,t))throw Y(new un(LP+Oqe(e)));a=null,e.Cb&&(a=(i=e.Db>>16,i>=0?Pwe(e,null):e.Cb.Cg(e,-1-i,null,null))),t&&(a=h(t,42).Ag(e,1,pD,a)),a=Qme(e,t,a),a&&a.Th()}else e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,7,t,t))}function v9t(e,t){var i,a;if(t!=e.Cb||e.Db>>16!=3&&t){if(LS(e,t))throw Y(new un(LP+qVe(e)));a=null,e.Cb&&(a=(i=e.Db>>16,i>=0?Rwe(e,null):e.Cb.Cg(e,-1-i,null,null))),t&&(a=h(t,42).Ag(e,0,mD,a)),a=e1e(e,t,a),a&&a.Th()}else e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,3,t,t))}function RYe(e){var t,i,a,l,f,g,m;for(f=new j(e.a.a);f.a0&&f>0?g.o=t++:a>0?g.o=i++:f>0?g.o=l++:g.o=i++}_t(),fa(e.i,new jb)}function IYe(e,t){var i,a,l;for(l=(!t.a&&(t.a=new ze(Br,t,10,11)),t.a).i,a=new Bn((!t.a&&(t.a=new ze(Br,t,10,11)),t.a));a.e!=a.i._b();)i=h(Yn(a),35),Be(rn(i,(ur(),Ey)))!==Be((e1(),ML))&&u0e(Hte(t),Hte(i))&&((!i.a&&(i.a=new ze(Br,i,10,11)),i.a).i==0||(l+=IYe(e,i)));return l}function y9t(e,t){var i,a,l;return i=t.Yg(e.a),i&&(l=ti(Tf((!i.b&&(i.b=new wl((yt(),zo),Aa,i)),i.b),"affiliation")),l!=null)?(a=uJ(l,wc(35)),a==-1?qee(e,aA(e,$l(t.Wi())),l):a==0?qee(e,null,l.substr(1,l.length-1)):qee(e,l.substr(0,a),l.substr(a+1,l.length-(a+1)))):null}function x9t(e){var t,i,a,l,f;if(f=new ke,cd(e.b,new RY(f)),e.b.c=le(on,et,1,0,5,1),f.c.length!=0){for(t=(ai(0,f.c.length),h(f.c[0],78)),i=1,a=f.c.length;i=e.a||!Xwe(t,i))return-1;if(T0(h(a.Kb(t),20)))return 1;for(l=0,g=h(a.Kb(t),20).tc();g.hc();)if(f=h(g.ic(),14),v=f.c.g==t?f.d.g:f.c.g,m=Vve(e,v,i,a),m==-1||(l=l>m?l:m,l>e.c-1))return-1;return l+1}function E9t(e,t,i,a){var l,f,g,m,v,y,E,C,R;for(C=a?(Fe(),nn):(Fe(),Zt),l=!1,v=t[i],y=0,E=v.length;y>5,t&=31,a>=e.d)return e.e<0?(Kg(),ese):(Kg(),cM);if(f=e.d-a,l=le(In,si,22,f+1,15,1),sNt(l,f,e.a,a,t),e.e<0){for(i=0;i0&&e.a[i]<<32-t){for(i=0;i0&&(f=h(St(this.b,0),157),l+=f.o,a+=f.p),l*=2,a*=2,t>1?l=yr(w.Math.ceil(l*t)):a=yr(w.Math.ceil(a/t)),this.a=new nwe(l,a)}function qve(e,t,i,a,l,f){var g,m,v,y,E,C;for(y=i.c.length,f&&(e.c=le(In,si,22,t.length,15,1)),g=l?0:t.length-1;l?g=0;g+=l?1:-1){for(m=t[g],v=a==(Fe(),Zt)?l?sa(m,a):R0(sa(m,a)):l?R0(sa(m,a)):sa(m,a),f&&(e.c[m.o]=v._b()),C=v.tc();C.hc();)E=h(C.ic(),11),e.d[E.o]=y++;Lr(i,v)}}function GYe(e,t,i){var a,l,f,g,m,v,y,E;for(f=ce(Xe(e.b.tc().ic())),y=ce(Xe(_$e(t.b))),a=au(Ua(e.a),y-i),l=au(Ua(t.a),i-f),E=tr(a,l),au(E,1/(y-f)),this.a=E,this.b=new ke,m=!0,g=e.b.tc(),g.ic();g.hc();)v=ce(Xe(g.ic())),m&&v-i>ey&&(this.b.nc(i),m=!1),this.b.nc(v);m&&this.b.nc(i)}function B9t(e){var t,i,a,l;if(UUt(e,e.n),e.d.c.length>0){for(TC(e.c);Mve(e,h($(new j(e.e.a)),113))=l&&(e.c=!1,e.a=!1),e.b[a++]=l,e.b[a]=f,e.c||U_(e)}}function jYe(e){var t,i,a,l;return l=Sh(e),i=new yg(l),a=new DY(l),t=new ke,Lr(t,(!e.d&&(e.d=new an(js,e,8,5)),e.d)),Lr(t,(!e.e&&(e.e=new an(js,e,7,4)),e.e)),h(sd(Yf(go(new oi(null,new di(t,16)),i),a),b_(new qn,new bi,new Si,new it,X(q(ih,1),Oe,150,0,[(Wg(),Bw),nh]))),19)}function $Ye(e){var t,i,a;if(i=h(G(e,(Ie(),Pl)),8),i?mr(e,h(G(i,pa),69)):e.d.c.length-e.f.c.length<0?mr(e,(Fe(),Zt)):mr(e,(Fe(),nn)),!e.b)switch(a=e.n,t=e.a,e.i.g){case 1:t.a=a.a/2,t.b=0;break;case 2:t.a=a.a,t.b=a.b/2;break;case 3:t.a=a.a/2,t.b=a.b;break;case 4:t.a=0,t.b=a.b/2}}function O9t(e,t,i){var a,l,f,g,m;for(ii(i,"Longest path layering",1),e.a=t,m=e.a.a,e.b=le(In,si,22,m.c.length,15,1),a=0,g=new j(m);g.a=0?!1:(i=zS((qc(),Zs),l,t),i?(a=i.kj(),(a>1||a==-1)&&E0(Vo(Zs,i))!=3):!0)):!1}function N9t(e,t){var i;switch(i=h(G(e,($e(),nL)),241),ii(t,"Label side selection ("+i+")",1),i.g){case 0:_Xe(e,(xl(),Ed));break;case 1:_Xe(e,(xl(),dm));break;case 2:DZe(e,(xl(),Ed));break;case 3:DZe(e,(xl(),dm));break;case 4:KYe(e,(xl(),Ed));break;case 5:KYe(e,(xl(),dm))}On(t)}function Xve(e,t,i){var a,l,f,g,m,v;if(a=MEt(i,e.length),g=e[a],g[0].j==(Xt(),Qr))for(f=lBe(i,g.length),v=t.i,l=0;l0&&(i[0]+=e.d,g-=i[0]),i[2]>0&&(i[2]+=e.d,g-=i[2]),f=w.Math.max(0,g),i[1]=w.Math.max(i[1],g),b0e(e,Wa,l.c+a.b+i[0]-(i[1]-g)/2,i),t==Wa&&(e.c.b=f,e.c.c=l.c+a.b+(f-g)/2)}function $9t(e,t){var i,a,l,f,g,m,v;for(i=Ts,m=(Xt(),hs),l=new j(t.a);l.a0?g=i:v.c&&(g=zJ(v.c)),g>0&&(a&&(Gm(),v.a.B&&(!ce(mt(v.a.e.xe((ur(),iD))))||v.b.ff()))?v.d.a=e.s+g:(E=v.b.Re().b,g>E&&(m=(g-E)/2,v.d.d=m,v.d.a=m)))}}function H9t(e,t){var i,a,l,f,g;return l=t.Yg(e.a),l&&(a=(!l.b&&(l.b=new wl((yt(),zo),Aa,l)),l.b),i=ti(Tf(a,Ls)),i!=null&&(f=i.lastIndexOf("#"),g=f==-1?Zge(e,t.Pi(),i):f==0?PI(e,null,i.substr(1,i.length-1)):PI(e,i.substr(0,f),i.substr(f+1,i.length-(f+1))),re(g,140)))?h(g,140):null}function q9t(e,t){var i,a,l,f,g;return a=t.Yg(e.a),a&&(i=(!a.b&&(a.b=new wl((yt(),zo),Aa,a)),a.b),f=ti(Tf(i,Dre)),f!=null&&(l=f.lastIndexOf("#"),g=l==-1?Zge(e,t.Pi(),f):l==0?PI(e,null,f.substr(1,f.length-1)):PI(e,f.substr(0,l),f.substr(l+1,f.length-(l+1))),re(g,140)))?h(g,140):null}function ZYe(e,t,i,a,l){var f,g,m,v,y,E;if(e.d&&e.d.If(l),f=h(l.cd(0),35),THe(e,i,f,!1)||(g=h(l.cd(l._b()-1),35),THe(e,a,g,!0))||ive(e,l))return!0;for(E=l.tc();E.hc();)for(y=h(E.ic(),35),v=t.tc();v.hc();)if(m=h(v.ic(),35),C7(e,y,m))return!0;return!1}function X9t(e,t,i){var a,l,f,g,m,v,y,E,C,R;R=t.c.length,C=(y=e.rg(i),h(y>=0?e.ug(y,!1,!0):Ax(e,i,!1),52));e:for(f=C.tc();f.hc();){for(l=h(f.ic(),51),E=0;Ee.d[g.o]&&(i+=Uze(e.b,f),bA(e.a,He(f)));for(;!wpe(e.a);)uje(e.b,h(ZJ(e.a),21).a)}return i}function j_(e,t,i){var a,l;if((!e.a&&(e.a=new ze(ts,e,6,6)),e.a).i==0)return pVe(e);if(a=h(ae((!e.a&&(e.a=new ze(ts,e,6,6)),e.a),0),270),t&&(Pr((!a.a&&(a.a=new vs(ah,a,5)),a.a)),AA(a,0),PA(a,0),CA(a,0),TA(a,0)),i)for(l=(!e.a&&(e.a=new ze(ts,e,6,6)),e.a);l.i>1;)Mw(l,l.i-1);return a}function J9t(e,t){var i,a,l,f;if(f=LZe(t),l=h(G(f,(Ie(),Va)),19),ZGt(t,l),l.pc((xo(),Su)))for(a=new Bn((!t.c&&(t.c=new ze(Pu,t,9,9)),t.c));a.e!=a.i._b();)i=h(Yn(a),121),sjt(e,t,f,i);return P9t(t,f),ce(mt(G(f,($e(),XMe))))&&l.nc(xG),Be(rn(t,iL))===Be((e1(),d3))?f$t(e,t,f):rjt(e,t,f),f}function xo(){xo=M,_G=new sw("COMMENTS",0),Su=new sw("EXTERNAL_PORTS",1),KP=new sw("HYPEREDGES",2),yG=new sw("HYPERNODES",3),dy=new sw("NON_FREE_PORTS",4),py=new sw("NORTH_SOUTH_PORTS",5),C5=new sw(AQe,6),hM=new sw("CENTER_LABELS",7),dM=new sw("END_LABELS",8),xG=new sw("PARTITIONS",9)}function JYe(e,t,i){var a,l,f,g;for(f=(!t.a&&(t.a=new ze(Br,t,10,11)),t.a).i,l=new Bn((!t.a&&(t.a=new ze(Br,t,10,11)),t.a));l.e!=l.i._b();)a=h(Yn(l),35),(!a.a&&(a.a=new ze(Br,a,10,11)),a.a).i==0||(f+=JYe(e,a,!1));if(i)for(g=eo(t);g;)f+=(!g.a&&(g.a=new ze(Br,g,10,11)),g.a).i,g=eo(g);return f}function Mw(e,t){var i,a,l,f;return e.ti()?(a=null,l=e.ui(),e.xi()&&(a=e.zi(e.Dh(t),null)),i=e.mi(4,f=Ex(e,t),null,t,l),e.qi()&&f!=null&&(a=e.si(f,a)),a?(a.Sh(i),a.Th()):e.ni(i),f):(f=Ex(e,t),e.qi()&&f!=null&&(a=e.si(f,null),a&&a.Th()),f)}function Q9t(e){var t,i,a,l,f,g,m,v,y;for(g=Jr,v=Jr,m=null,i=new aQ(new D2(e.e));i.b!=i.c.a.b;)if(t=A0e(i),(Be(t.d)===Be((ll(),Zp))||Be(t.d)===Be(Xw))&&(a=h(t.e,249).a,y=h(t.e,249).b,l=g-a>kw,f=a-gkw,(l||f)&&(v=h(t.e,249).b,g=h(t.e,249).a,m=h(t.d,129),v==0&&g==0)))return m;return m}function eUt(e){var t,i,a,l,f,g,m,v,y,E;for(f=e.a,t=new zr,y=0,a=new j(e.d);a.av.d&&(E=v.d+v.a+f));i.c.d=E,t.a.Zb(i,t),y=w.Math.max(y,i.c.d+i.c.a)}return y}function tUt(e,t,i,a,l){return a<0?(a=N_(e,l,X(q(Se,1),be,2,6,[Vne,Wne,Hne,qne,Bx,Xne,Yne,Zne,Kne,Jne,Qne,eie]),t),a<0&&(a=N_(e,l,X(q(Se,1),be,2,6,["Jan","Feb","Mar","Apr",Bx,"Jun","Jul","Aug","Sep","Oct","Nov","Dec"]),t)),a<0?!1:(i.k=a,!0)):a>0?(i.k=a-1,!0):!1}function nUt(e,t,i,a,l){return a<0?(a=N_(e,l,X(q(Se,1),be,2,6,[Vne,Wne,Hne,qne,Bx,Xne,Yne,Zne,Kne,Jne,Qne,eie]),t),a<0&&(a=N_(e,l,X(q(Se,1),be,2,6,["Jan","Feb","Mar","Apr",Bx,"Jun","Jul","Aug","Sep","Oct","Nov","Dec"]),t)),a<0?!1:(i.k=a,!0)):a>0?(i.k=a-1,!0):!1}function iUt(e,t,i){var a,l,f;if(e.e=i,e.d=0,e.b=0,e.f=1,e.i=t,(e.e&16)==16&&(e.i=AUt(e.i)),e.j=e.i.length,wi(e),f=B0(e),e.d!=e.j)throw Y(new Wn(Zn((zn(),qet))));if(e.g){for(a=0;aKQe?fa(v,e.b):a<=KQe&&a>JQe?fa(v,e.d):a<=JQe&&a>QQe?fa(v,e.c):a<=QQe&&fa(v,e.a),f=eZe(e,v,f);return l}function tZe(e){Y2(e,new O_(q2(V2(H2(W2(new e0,gz),"Randomizer"),'Distributes the nodes randomly on the plane, leading to very obfuscating layouts. Can be useful to demonstrate the power of "real" layout algorithms.'),new Gq))),bt(e,gz,Ux,mAe),bt(e,gz,qS,15),bt(e,gz,J7,He(0)),bt(e,gz,WS,HS)}function sUt(e,t){var i,a,l,f,g,m,v,y,E,C;for(v=t.a.length,m=yr(w.Math.ceil(v/e.a)),C=t.a,g=0,y=m,f=0;fg?0:g)g?0:g:v,(0>(yg?0:g)g?0:g:v)),g=y,y+=m,a=h(St(e.c,f),8),i=new aJ(E),i.n.b=t.n.b,ir(e.b,t,i),De(a.b,i);Sa(e.g.b,t),De(e.i,(l=new xOe(e,t),l))}function nZe(e,t,i){var a,l,f,g,m,v,y,E,C;for(t.o=1,f=t.c,C=vw(t,(Oo(),lc)).tc();C.hc();)for(E=h(C.ic(),11),l=new j(E.f);l.a=e.length||(m=e.charCodeAt(t[0]),m!=43&&m!=45)||(++t[0],a=h7(e,t),a<0))return!1;m==45&&(a=-a)}return m==32&&t[0]-i==2&&l.b==2&&(v=new T8,y=v.q.getFullYear()-$0+$0-80,g=y%100,f.a=a==g,a+=(y/100|0)*100+(a0){if(e.Fi(),t!=null){for(f=0;f=48;i--)OL[i]=i-48<<24>>24;for(a=70;a>=65;a--)OL[a]=a-65+10<<24>>24;for(l=102;l>=97;l--)OL[l]=l-97+10<<24>>24;for(f=0;f<10;f++)$j[f]=48+f&jr;for(e=10;e<=15;e++)$j[e]=65+e-10&jr}function aZe(e){var t,i,a,l;i=ce(Xe(G(e.a,(Cf(),Pit)))),a=e.a.c.d,l=e.a.d.d,t=e.d,a.a>=l.a?a.b>=l.b?(t.a=l.a+(a.a-l.a)/2+i,t.b=l.b+(a.b-l.b)/2-i):(t.a=l.a+(a.a-l.a)/2+i,t.b=a.b+(l.b-a.b)/2+i):a.b>=l.b?(t.a=a.a+(l.a-a.a)/2+i,t.b=l.b+(a.b-l.b)/2+i):(t.a=a.a+(l.a-a.a)/2+i,t.b=a.b+(l.b-a.b)/2-i)}function fUt(e,t,i,a){var l,f,g,m,v;return m=Ia(h(ae((!t.b&&(t.b=new an(pi,t,4,7)),t.b),0),97)),v=Ia(h(ae((!t.c&&(t.c=new an(pi,t,5,8)),t.c),0),97)),eo(m)==eo(v)||SA(v,m)?null:(g=V9(t),g==i?a:(f=h(Ii(e.a,g),8),f&&(l=h(G(f,(Ie(),md)),31),l)?l:null))}function hUt(e,t,i,a){var l,f,g,m,v;for(f=e.i.c.length,v=le(TVt,Pye,267,f,0,1),g=0;gR+v&&a.jc();for(g=new j(B);g.a>19)return"-"+lZe(_S(e));for(i=e,a="";!(i.l==0&&i.m==0&&i.h==0);){if(l=BQ(W7),i=A_e(i,l,!0),t=""+vBe(rm),!(i.l==0&&i.m==0&&i.h==0))for(f=9-t.length;f>0;f--)t="0"+t;a=t+a}return a}function Sl(e,t,i){var a,l,f,g,m;if(e==null)throw Y(new vh(Xc));for(f=e.length,g=f>0&&(e.charCodeAt(0)==45||e.charCodeAt(0)==43)?1:0,a=g;ai)throw Y(new vh(V0+e+'"'));return m}function pUt(){if(!Object.create||!Object.getOwnPropertyNames)return!1;var e="__proto__",t=Object.create(null);if(t[e]!==void 0)return!1;var i=Object.getOwnPropertyNames(t);return!(i.length!=0||(t[e]=42,t[e]!==42)||Object.getOwnPropertyNames(t).length==0)}function gUt(e,t){var i,a,l,f;for(ii(t,"Resize child graph to fit parent.",1),a=new j(e.b);a.a>24;case 97:case 98:case 99:case 100:case 101:case 102:return e-97+10<<24>>24;case 65:case 66:case 67:case 68:case 69:case 70:return e-65+10<<24>>24;default:throw Y(new vh("Invalid hexadecimal"))}}function yUt(e,t){var i,a,l,f,g,m,v,y,E;if(y=h(Ii(e.c,t),191),!y)throw Y(new _h("Edge did not exist in input."));return g=jA(y),E=new Om,i=new q8e(e,g,E),iSt((!t.a&&(t.a=new ze(ts,t,6,6)),t.a),i),Og(y,_xe,E),m=h(rn(t,(ur(),u3)),74),l=!m||LUe(m),f=!l,f&&(v=new Om,a=new TZ(v),mo(m,a),Og(y,"junctionPoints",v)),null}function xUt(e,t,i){var a,l,f,g;ii(i,"Orthogonally routing hierarchical port edges",1),e.a=0,a=Nzt(t),NGt(t,a),cGt(e,t,a),Wjt(t),l=h(G(t,($e(),Ki)),83),f=t.b,qKe((ai(0,f.c.length),h(f.c[0],26)),l,t),qKe(h(St(f,f.c.length-1),26),l,t),g=t.b,eKe((ai(0,g.c.length),h(g.c[0],26))),eKe(h(St(g,g.c.length-1),26)),On(i)}function EUt(e){var t,i,a;switch(t=h(G(e.d,($e(),cm)),197),t.g){case 2:i=_$t(e);break;case 3:i=(a=new ke,Fa(go(Yf(Qf(Qf(new oi(null,new di(e.d.b,16)),new nN),new YH),new ZH),new VH),new l0(a)),a);break;default:throw Y(new ba("Compaction not supported for "+t+" edges."))}Qzt(e,i),mo(new Gv(e.g),new XY(e))}function SUt(e,t,i,a){var l,f,g,m,v;for(l=!1,f=!1,m=new j(a.i);m.a1&&(i?g=ju(t.c)+1:g=ju(y.c)-1,m=h(St(e.a.b,g),26),Hs(y,m)),Qve(e,y,i));return t}function uZe(e,t,i,a,l,f){if(this.b=i,this.d=l,e>=t.length)throw Y(new Ra("Greedy SwitchDecider: Free layer not in graph."));this.c=t[e],this.e=new ZR(a),hee(this.e,this.c,(Fe(),nn)),this.i=new ZR(a),hee(this.i,this.c,Zt),this.f=new M9e(this.c),this.a=!f&&l.i&&!l.s&&this.c[0].j==(Xt(),Qr),this.a&&ANt(this,e,t.length)}function MUt(e,t,i){var a,l,f,g;for(ii(i,"Processor order nodes",2),e.a=ce(Xe(G(t,(Ew(),jTe)))),l=new Ir,g=Nn(t.b,0);g.b!=g.d.c;)f=h(Un(g),76),ce(mt(G(f,(ha(),Kw))))&&Fs(l,f,l.c.b,l.c);a=(Rn(l.b!=0),h(l.a.a.c,76)),hKe(e,a),!i.b&&uee(i,1),i_e(e,a,0-ce(Xe(G(a,(ha(),nj))))/2,0),!i.b&&uee(i,1),On(i)}function fZe(){this.b=(Yr(),new C0),this.d=new C0,this.e=new C0,this.c=new C0,this.a=new ui,this.f=new ui,ax(es,new Eq,new Sq),ax(pCe,new kq,new Rq),ax(AEe,new Iq,new Dq),ax(PEe,new Nv,new Bq),ax(rVt,new Oq,new zq),ax(aVt,new t0,new Mq),ax(sVt,new Tq,new Cq),ax(oVt,new Aq,new Pq),ax(uVt,new n0,new Lq)}function hZe(e,t,i,a){var l,f,g,m,v,y;for(v=kte(e,i),y=kte(t,i),l=!1;v&&y&&(a||ODt(v,y,i));)g=kte(v,i),m=kte(y,i),BI(t),BI(e),f=v.c,Lne(v,!1),Lne(y,!1),i?(Yg(t,y.o,f),t.o=y.o,Yg(e,v.o+1,f),e.o=v.o):(Yg(e,v.o,f),e.o=v.o,Yg(t,y.o+1,f),t.o=y.o),Hs(v,null),Hs(y,null),v=g,y=m,l=!0;return l}function sne(e,t,i,a,l,f,g,m){var v,y,E;for(v=0,t!=null&&(v^=Hg(t.toLowerCase())),i!=null&&(v^=Hg(i)),a!=null&&(v^=Hg(a)),g!=null&&(v^=Hg(g)),m!=null&&(v^=Hg(m)),y=0,E=f.length;yv?new mU(t,e,m-v):m>0&&v>0&&(new mU(e,t,0),new mU(t,e,0)))}function dZe(e){Y2(e,new O_(q2(V2(H2(W2(new e0,i5),Tet),"Keeps the current layout as it is, without any automatic modification. Optional coordinates can be given for nodes and edge bend points."),new dN))),bt(e,i5,Ux,lAe),bt(e,i5,fz,qt(SL)),bt(e,i5,cxe,qt(oAe)),bt(e,i5,lz,qt(aAe)),bt(e,i5,uz,qt(cAe))}function pZe(e){var t,i,a;a=h(G(e,($e(),Rf)),19),!a.Wb()&&(i=(t=h(bl(Ys),10),new Oc(t,h(el(t,t.length),10),0)),a.pc((a1(),Ll))?yl(i,Ll):yl(i,Au),a.pc(Tu)||yl(i,Tu),a.pc(Mu)?yl(i,If):a.pc(Nh)?yl(i,af):a.pc(Cu)&&yl(i,of),a.pc(If)?yl(i,Mu):a.pc(af)?yl(i,Nh):a.pc(of)&&yl(i,Cu),Ee(e,Rf,i))}function e_e(e,t){var i,a,l,f;if(0<(re(e,13)?h(e,13)._b():vA(e.tc()))){if(l=t,1=e.o)throw Y(new o8);m=t>>5,g=t&31,f=jd(1,nr(jd(g,1))),l?e.n[i][m]=Kf(e.n[i][m],f):e.n[i][m]=Kr(e.n[i][m],tme(f)),f=jd(f,1),a?e.n[i][m]=Kf(e.n[i][m],f):e.n[i][m]=Kr(e.n[i][m],tme(f))}catch(v){throw v=pr(v),re(v,305)?Y(new Ra(_ie+e.o+"*"+e.p+yie+t+Ca+i+xie)):Y(v)}}function one(e,t){var i,a,l,f,g,m,v;for(l=new ke,v=new ke,i=h(Ds(hy,e),15).tc();i.hc();)a=h(i.ic(),151),KWe(l,a.b),KWe(l,BWe(a)),i.hc()&&(a=h(i.ic(),151),Lr(v,BWe(a)),Lr(v,a.b));for(ree(l,e.b),ree(v,e.a),m=new j(l);m.ae.d[m.o]&&(i+=Uze(e.b,f),bA(e.a,He(f)))):++g;for(i+=e.b.d*g;!wpe(e.a);)uje(e.b,h(ZJ(e.a),21).a)}return i}function DUt(e){var t,i,a,l,f,g;if(l=e.g.ed(),a=e.b.ed(),e.e)for(i=0;iey;){for(f=t,g=0;w.Math.abs(t-f)0&&(a=(!e.n&&(e.n=new ze(ea,e,1,7)),h(h(ae(e.n,0),137),263)).a,!a||Mi(Mi((t.a+=' "',t),a),'"'))),Mi(p0(Mi(p0(Mi(p0(Mi(p0((t.a+=" (",t),e.i),","),e.j)," | "),e.g),","),e.f),")"),t.a)}function vZe(e){var t,i,a;return e.Db&64?Ote(e):(t=new ou(gxe),i=e.k,i?Mi(Mi((t.a+=' "',t),i),'"'):(!e.n&&(e.n=new ze(ea,e,1,7)),e.n.i>0&&(a=(!e.n&&(e.n=new ze(ea,e,1,7)),h(h(ae(e.n,0),137),263)).a,!a||Mi(Mi((t.a+=' "',t),a),'"'))),Mi(p0(Mi(p0(Mi(p0(Mi(p0((t.a+=" (",t),e.i),","),e.j)," | "),e.g),","),e.f),")"),t.a)}function _Ze(e){var t,i,a,l,f,g;return f=0,t=pu(e),t.Qi()&&(f|=4),e.Bb&yc&&(f|=2),re(e,62)?(i=h(e,17),l=Uo(i),i.Bb&Ja&&(f|=32),l&&(jn(dw(l)),f|=8,g=l.t,(g>1||g==-1)&&(f|=16),l.Bb&Ja&&(f|=64)),i.Bb&oo&&(f|=Dw),f|=tf):re(t,425)?f|=512:(a=t.Qi(),a&&a.i&1&&(f|=256)),e.Bb&512&&(f|=128),f}function o_e(e,t){var i,a,l,f,g,m,v;if(t==null||t.length==0)return null;if(l=h(za(e.a,t),180),!l){for(a=(m=new bh(e.b).a.Tb().tc(),new a0(m));a.a.hc();)if(i=(f=h(a.a.ic(),38),h(f.lc(),180)),g=i.c,v=t.length,dt(g.substr(g.length-v,v),t)&&(t.length==g.length||po(g,g.length-t.length-1)==46)){if(l)return null;l=i}l&&Ko(e.a,t,l)}return l}function OUt(e,t){var i;return e.f==Oae?(i=E0(Vo((qc(),Zs),t)),e.e?i==4&&t!=(Px(),y3)&&t!=(Px(),_3)&&t!=(Px(),Nae)&&t!=(Px(),Fae):i==2):e.d&&(e.d.pc(t)||e.d.pc(pA(Vo((qc(),Zs),t)))||e.d.pc(zS((qc(),Zs),e.b,t)))?!0:e.f&&jve((qc(),e.f),mI(Vo(Zs,t)))?(i=E0(Vo(Zs,t)),e.e?i==4:i==2):!1}function NUt(e,t,i,a){var l,f,g,m,v,y,E,C;return g=h(rn(i,(ur(),f3)),9),v=g.a,E=g.b+e,l=w.Math.atan2(E,v),l<0&&(l+=$x),l+=t,l>$x&&(l-=$x),m=h(rn(a,f3),9),y=m.a,C=m.b+e,f=w.Math.atan2(C,y),f<0&&(f+=$x),f+=t,f>$x&&(f-=$x),xh(),Ng(1e-10),w.Math.abs(l-f)<=1e-10||l==f||isNaN(l)&&isNaN(f)?0:lf?1:$8(isNaN(l),isNaN(f))}function FUt(e,t,i,a){var l,f;for(vBt(e,t,i,a),wde(t,e.j-t.j+i),bde(t,e.k-t.k+a),f=new j(t.f);f.ai.k&&my&&a>y)y=ce(i.p[m.o])+ce(i.d[m.o])+m.n.b+m.d.a;else{l=!1,e.a&&Jh();break}if(!l)break}return e.a&&Jh(),l}function ZUt(e,t){var i,a,l,f,g;for(e.c==null||e.c.lengthf*2?(E=new xU(C),y=Ul(g)/yf(g),v=Rne(E,t,new j2,i,a,l,y),tr(Hf(E.e),v),C.c=le(on,et,1,0,5,1),C.c[C.c.length]=E,C.c[C.c.length]=g,f=Ul(E)*yf(E)+Ul(g)*yf(g)):(C.c[C.c.length]=g,f+=Ul(g)*yf(g));return C}function FS(e){switch(e){case 100:return q_(zP,!0);case 68:return q_(zP,!1);case 119:return q_(Ure,!0);case 87:return q_(Ure,!1);case 115:return q_(zre,!0);case 83:return q_(zre,!1);case 99:return q_(Gre,!0);case 67:return q_(Gre,!1);case 105:return q_(jre,!0);case 73:return q_(jre,!1);default:throw Y(new na(hnt+e.toString(16)))}}function PZe(e,t,i){var a,l,f,g,m,v,y,E;if(t.o==0){for(t.o=1,g=i,i||(l=new ke,f=(a=h(bl(Ec),10),new Oc(a,h(el(a,a.length),10),0)),g=new Is(l,f)),h(g.a,15).nc(t),t.j==(Xt(),Qr)&&h(g.b,19).nc(h(G(t,(Ie(),pa)),69)),v=new j(t.i);v.am&&(m=l,E.c=le(on,et,1,0,5,1)),l==m&&De(E,new Is(i.c.g,i)));_t(),fa(E,e.c),v0(e.b,v.o,E)}}function a7t(e,t){var i,a,l,f,g,m,v,y,E;for(g=new j(t.b);g.am&&(m=l,E.c=le(on,et,1,0,5,1)),l==m&&De(E,new Is(i.d.g,i)));_t(),fa(E,e.c),v0(e.f,v.o,E)}}function c7t(e,t,i,a){var l,f,g,m,v,y,E,C,R;for(v=new $t(i,a),Bc(v,h(G(t,(Fg(),HP)),9)),R=new j(t.e);R.a=40,g&&G7t(e),kzt(e),B9t(e),i=oWe(e),a=0;i&&a0&&Gi(e.e,f)):(e.c[g]-=y+1,e.c[g]<=0&&e.a[g]>0&&Gi(e.d,f))))}function kZe(e){var t,i,a,l,f,g,m,v,y,E,C;for(m=new ke,f=ce(Xe(e.g.cd(e.g._b()-1))),C=e.g.tc();C.hc();)E=Xe(C.ic()),v0(m,0,f-(dn(E),E));for(g=BA(_ee(e)),y=new ke,l=new j(m),v=new ke,t=0;t1)&&t==1&&h(e.a[e.b],8).j==(Xt(),ul)?kx(h(e.a[e.b],8),(xl(),Ed)):a&&(!i||(e.c-e.b&e.a.length-1)>1)&&t==1&&h(e.a[e.c-1&e.a.length-1],8).j==(Xt(),ul)?kx(h(e.a[e.c-1&e.a.length-1],8),(xl(),dm)):(e.c-e.b&e.a.length-1)==2?(kx(h(IA(e),8),(xl(),Ed)),kx(h(IA(e),8),dm)):F8t(e,l),a0e(e)}function f7t(e){var t,i;if(!e.Wb()){for(i=h(e.cd(0),151).f,new g_e(e),t=new Ns(i.i,0),B_((ll(),ip),t),R_(yy,t),c6((Fe(),bn),t),one(lm,t),R_(ab,t),z_(qw,t),B_(Zp,t),c6(Zt,t),one(sb,t),B_(Xw,t),z_(ob,t),B_(ab,t),c6(ni,t),one(Kp,t),B_(yy,t),z_(Zw,t),R_(Xw,t);t.b=0&&(m=HDt(e,g),!(m&&(y<22?v.l|=1<>>1,g.m=E>>>1|(C&1)<<21,g.l=R>>>1|(E&1)<<21,--y;return i&&Cee(v),f&&(a?(rm=_S(e),l&&(rm=tVe(rm,(gS(),a3e)))):rm=Xa(e.l,e.m,e.h)),v}function FZe(e,t,i,a){var l,f,g,m,v,y,E,C;if(uRt(e,t,i),f=t[i],C=a?(Fe(),nn):(Fe(),Zt),QSt(t.length,i,a)){for(l=t[a?i-1:i+1],y0e(e,l,a?(Oo(),lc):(Oo(),Fc)),v=0,E=f.length;v0){for(l=m.length;l>0&&m[l-1]=="";)--l;l=0&&m!=i&&(f=new ls(e,1,m,g,null),a?a.Sh(f):a=f),i>=0&&(f=new ls(e,1,i,m==i?g:null,t),a?a.Sh(f):a=f)),a}function E7t(e,t,i,a){var l,f,g,m,v,y,E;if(LFt(e,t,i,a))return!0;for(g=new j(t.f);g.a=l){for(g=1;g0){if(l=h(e.Ab.g,1627),t==null){for(f=0;f1)for(a=new j(l);a.at.f?1:0:(a=e.e-t.e,i=(e.d>0?e.d:w.Math.floor((e.a-1)*FJe)+1)-(t.d>0?t.d:w.Math.floor((t.a-1)*FJe)+1),i>a+1?l:i0&&(g=m_(g,JZe(a))),FWe(f,g))):lv+N&&(W=C.i+R.i,R.a=(R.i*R.a+C.i*C.a)/W,R.i=W,C.g=R,i=!0)),f=m,C=R;return i}function $Ze(e,t){var i,a,l,f,g,m,v,y,E;if(l=e.g,g=l.n.a,f=l.n.b,g<=0&&f<=0)return Fe(),Na;switch(y=e.k.a,E=e.k.b,m=e.n.a,i=e.n.b,t.g){case 2:case 1:if(y<0)return Fe(),nn;if(y+m>g)return Fe(),Zt;break;case 4:case 3:if(E<0)return Fe(),bn;if(E+i>f)return Fe(),ni}return v=(y+m/2)/g,a=(E+i/2)/f,v+a<=1&&v-a<=0?(Fe(),nn):v+a>=1&&v-a>=0?(Fe(),Zt):a<.5?(Fe(),bn):(Fe(),ni)}function h_e(e,t,i){var a,l,f,g;if(t[0]>=e.length)return i.o=0,!0;switch(e.charCodeAt(t[0])){case 43:l=1;break;case 45:l=-1;break;default:return i.o=0,!0}if(++t[0],f=t[0],g=h7(e,t),g==0&&t[0]==f)return!1;if(t[0]=14&&i<=16));case 11:return t!=null&&typeof t===Dne;case 12:return t!=null&&(typeof t===N6||typeof t==Dne);case 0:return hte(t,e.__elementTypeId$);case 2:return XJ(t)&&t.sl!==T;case 1:return XJ(t)&&t.sl!==T||hte(t,e.__elementTypeId$);default:return!0}}function kx(e,t){var i,a,l,f,g,m;if(e.j==(Xt(),ul)&&(i=Ebe(go(h(G(e,(Ie(),LG)),15).xc(),new RF(new WO))).a==null?(xl(),uD):t,Ee(e,t3,i),i!=(xl(),dm)))for(a=h(G(e,Jn),14),m=ce(Xe(G(a,($e(),tp)))),g=0,i==Ed?g=e.n.b-w.Math.ceil(m/2):i==uD&&(e.n.b-=ce(Xe(G(va(e),N5))),g=(e.n.b-w.Math.ceil(m))/2),f=new j(e.i);f.a0&&(YI(v,!1,(qs(),rf)),YI(v,!0,sf)),cd(t.g,new ROe(e,i)),dr(e.g,t,i)}function B7t(e,t){var i,a,l,f,g,m,v;for(f=0,m=0,v=0,l=new j(e.f.e);l.a0&&e.d!=(xA(),bse)&&(m+=g*(a.d.a+e.a[t.b][a.b]*(t.d.a-a.d.a)/i)),i>0&&e.d!=(xA(),gse)&&(v+=g*(a.d.b+e.a[t.b][a.b]*(t.d.b-a.d.b)/i)));switch(e.d.g){case 1:return new $t(m/f,t.d.b);case 2:return new $t(t.d.a,v/f);default:return new $t(m/f,v/f)}}function g_e(e){LVe();var t,i,a,l,f,g,m,v,y,E;for(this.b=new ZO,this.c=new ke,this.a=new ke,v=Tee(),y=0,E=v.length;y0){for(g=0;g>16==-15&&e.Cb.Hg()&&XQ(new VQ(e.Cb,9,13,i,e.c,$p(Vc(h(e.Cb,53)),e))):re(e.Cb,96)&&e.Db>>16==-23&&e.Cb.Hg()&&(t=e.c,re(t,96)||(t=(yt(),ff)),re(i,96)||(i=(yt(),ff)),XQ(new VQ(e.Cb,9,10,i,t,$p(Ea(h(e.Cb,24)),e)))))),e.c}function Tw(e){vi();var t,i,a,l,f;if(e.e!=4&&e.e!=5)throw Y(new un("Token#complementRanges(): must be RANGE: "+e.e));for(U_(e),gP(e),a=e.b.length+2,e.b[0]==0&&(a-=2),i=e.b[e.b.length-1],i==rM&&(a-=2),l=(++Er,new _l(4)),l.b=le(In,si,22,a,15,1),f=0,e.b[0]>0&&(l.b[f++]=0,l.b[f++]=e.b[0]-1),t=1;t=65;i--)uh[i]=i-65<<24>>24;for(a=122;a>=97;a--)uh[a]=a-97+26<<24>>24;for(l=57;l>=48;l--)uh[l]=l-48+52<<24>>24;for(uh[43]=62,uh[47]=63,f=0;f<=25;f++)tg[f]=65+f&jr;for(g=26,v=0;g<=51;++g,v++)tg[g]=97+v&jr;for(e=52,m=0;e<=61;++e,m++)tg[e]=48+m&jr;tg[62]=43,tg[63]=47}function z7t(e,t){var i,a,l,f,g,m,v,y,E,C;if(g=e.d,E=h(G(e,(Ie(),i3)),15),C=0,E){for(v=0,f=E.tc();f.hc();)l=h(f.ic(),8),v=w.Math.max(v,l.n.b),C+=l.n.a;C+=t/2*(E._b()-1),g.d+=v+t}if(i=h(G(e,Jx),15),a=0,i){for(v=0,f=i.tc();f.hc();)l=h(f.ic(),8),v=w.Math.max(v,l.n.b),a+=l.n.a;a+=t/2*(i._b()-1),g.a+=v+t}m=w.Math.max(C,a),m>e.n.a&&(y=(m-e.n.a)/2,g.b=w.Math.max(g.b,y),g.c=w.Math.max(g.c,y))}function G7t(e){var t,i,a,l,f,g,m;for(e.o=new sK,a=new Ir,g=new j(e.e.a);g.a0,m=jU(t,f),zge(i?m.b:m.g,t),P_(m).c.length==1&&Fs(a,m,a.c.b,a.c),l=new Is(f,t),FNe(e.o,l),Sa(e.e.a,f))}function XZe(e,t){var i,a,l,f,g;for(t.d?l=e.a.c==(Eh(),rb)?As(t.b):fr(t.b):l=e.a.c==(Eh(),Yp)?As(t.b):fr(t.b),f=!1,a=(Mo(),new Nd(Kh(Gd(l.a,new z))));Gn(a);)if(i=h(Tn(a),14),g=ce(e.a.f[e.a.g[t.b.o].o]),!(!g&&!Jo(i)&&i.c.g.c==i.d.g.c)&&!(ce(e.a.n[e.a.g[t.b.o].o])||ce(e.a.n[e.a.g[t.b.o].o]))&&(f=!0,IC(e.b,e.a.g[_Dt(i,t.b).o])))return t.c=!0,t.a=i,t;return t.c=f,t.a=null,t}function v_e(e,t){var i,a,l,f,g,m,v;if(!Sh(e))throw Y(new ba(Cet));if(a=Sh(e),f=a.g,l=a.f,f<=0&&l<=0)return Fe(),Na;switch(m=e.i,v=e.j,t.g){case 2:case 1:if(m<0)return Fe(),nn;if(m+e.g>f)return Fe(),Zt;break;case 4:case 3:if(v<0)return Fe(),bn;if(v+e.f>l)return Fe(),ni}return g=(m+e.g/2)/f,i=(v+e.f/2)/l,g+i<=1&&g-i<=0?(Fe(),nn):g+i>=1&&g-i>=0?(Fe(),Zt):i<.5?(Fe(),bn):(Fe(),ni)}function j7t(e,t){var i,a,l,f,g,m,v,y,E,C,R,B;if(e.Wb())return new fo;for(y=0,C=0,l=e.tc();l.hc();)a=h(l.ic(),31),f=a.e,y=w.Math.max(y,f.a),C+=f.a*f.b;for(y=w.Math.max(y,w.Math.sqrt(C)*ce(Xe(G(h(e.tc().ic(),31),($e(),kG))))),R=0,B=0,v=0,i=t,m=e.tc();m.hc();)g=h(m.ic(),31),E=g.e,R+E.a>y&&(R=0,B+=v+t,v=0),A6(g,R,B),i=w.Math.max(i,R+E.a),v=w.Math.max(v,E.b),R+=E.a+t;return new $t(i+t,B+v+t)}function dne(e,t,i){var a,l,f,g,m,v,y,E;if(a=i._b(),a==0)return!1;if(e.ti())if(y=e.ui(),vqe(e,t,i),g=a==1?e.mi(3,null,i.tc().ic(),t,y):e.mi(5,null,i,t,y),e.qi()){for(m=a<100?null:new Eg(a),f=t+a,l=t;l1)for(a=Nn(l,0);a.b!=a.d.c;)for(i=h(Un(a),202),f=0,v=new j(i.e);v.am?1:-1:Mbe(e.a,t.a,f),l==-1)C=-v,E=g==v?DQ(t.a,m,e.a,f):NQ(t.a,m,e.a,f);else if(C=g,g==v){if(l==0)return Kg(),cM;E=DQ(e.a,f,t.a,m)}else E=NQ(e.a,f,t.a,m);return y=new l_(C,E.length,E),gA(y),y}function JZe(e){DS();var t,i,a,l;if(t=yr(e),e1e6)throw Y(new u8("power of ten too big"));if(e<=zi)return hx(v6(Xx[1],t),t);for(a=v6(Xx[1],zi),l=a,i=Wc(e-zi),t=yr(e%zi);Ma(i,zi)>0;)l=m_(l,a),i=Qm(i,zi);for(l=m_(l,v6(Xx[1],t)),l=hx(l,zi),i=Wc(e-zi);Ma(i,zi)>0;)l=hx(l,zi),i=Qm(i,zi);return l=hx(l,t),l}function H7t(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V;i=m0(new Fm,e.f),y=e.i[t.c.g.o],B=e.i[t.d.g.o],v=t.c,R=t.d,m=v.a.b,C=R.a.b,y.b||(m+=v.k.b),B.b||(C+=R.k.b),E=yr(w.Math.max(0,m-C)),g=yr(w.Math.max(0,C-m)),N=(W=vf(1,h(G(t,($e(),o3)),21).a),V=r0e(t.c.g.j,t.d.g.j),W*V),l=Ju(zu(Uu(Fu(Gu(new iu,N),g),i),h(Ii(e.k,t.c),113))),f=Ju(zu(Uu(Fu(Gu(new iu,N),E),i),h(Ii(e.k,t.d),113))),a=new DOe(l,f),e.c[t.o]=a}function gne(e){var t,i,a,l,f,g,m,v,y,E,C,R,B;if(i=e.i,t=e.n,e.b==0)for(B=i.c+t.b,R=i.b-t.b-t.c,g=e.a,v=0,E=g.length;v0&&(C-=a[0]+e.c,a[0]+=e.c),a[2]>0&&(C-=a[2]+e.c),a[1]=w.Math.max(a[1],C),L9(e.a[1],i.c+t.b+a[0]-(a[1]-C)/2,a[1]);for(f=e.a,m=0,y=f.length;m0&&(t[0]+=e.c,C-=t[0]),t[2]>0&&(C-=t[2]+e.c),t[1]=w.Math.max(t[1],C),P9(e.a[1],a.d+i.d+t[0]-(t[1]-C)/2,t[1]);else for(N=a.d+i.d,B=a.a-i.d-i.a,g=e.a,v=0,E=g.length;v>>0).toString(16),i="\\x"+Xf(t,t.length-2,t.length)):e>=oo?(t="0"+(e>>>0).toString(16),i="\\v"+Xf(t,t.length-6,t.length)):i=""+String.fromCharCode(e&jr)}return i}function __e(e){var t,i,a,l,f,g;for(Cge(this),i=e._b()-1;i<3;i++)e.bd(0,h(e.cd(0),9));if(e._b()<4)throw Y(new un("At (least dimension + 1) control points are necessary!"));for(this.c=3,this.e=!0,this.f=!0,this.d=!1,v8t(this,e._b()+this.c-1),g=new ke,f=this.g.tc(),t=0;t=0&&f!=i))throw Y(new un(s5));for(l=0,v=0;vce(qf(g.g,g.d[0]).a)?(Rn(v.b>0),v.a.cd(v.c=--v.b),td(v,g),l=!0):m.e&&m.e._b()>0&&(f=(!m.e&&(m.e=new ke),m.e).vc(t),y=(!m.e&&(m.e=new ke),m.e).vc(i),(f||y)&&((!m.e&&(m.e=new ke),m.e).nc(g),++g.c));l||(a.c[a.c.length]=g)}function K7t(e,t,i){var a,l,f,g,m,v;for(a=0,f=new Bn((!e.a&&(e.a=new ze(Br,e,10,11)),e.a));f.e!=f.i._b();)l=h(Yn(f),35),g="",(!l.n&&(l.n=new ze(ea,l,1,7)),l.n).i==0||(g=h(h(ae((!l.n&&(l.n=new ze(ea,l,1,7)),l.n),0),137),263).a),m=new sUe(g),No(m,l),Ee(m,(Fg(),Yx),l),m.b=a++,m.d.a=l.i+l.g/2,m.d.b=l.j+l.f/2,m.e.a=w.Math.max(l.g,1),m.e.b=w.Math.max(l.f,1),De(t.e,m),El(i.d,l,m),v=h(rn(l,(Cf(),bEe)),83),v==(Ms(),fb)}function J7t(e,t,i,a){var l,f,g,m,v,y,E;if(i.c.g!=t.g)for(l=new th(e),Ou(l,(Xt(),Nr)),Ee(l,(Ie(),Jn),i),Ee(l,($e(),Ki),(Ms(),Oa)),a.c[a.c.length]=l,g=new yo,us(g,l),mr(g,(Fe(),nn)),m=new yo,us(m,l),mr(m,Zt),_s(i,g),f=new Op,No(f,i),Ee(f,Lo,null),Os(f,m),_s(f,t),KXe(l,g,m),y=new Ns(i.b,0);y.b0&&(v=m/60|0,y=m%60,l=e.q.getDate(),i=e.q.getHours(),i+v>=24&&++l,f=new w.Date(e.q.getFullYear(),e.q.getMonth(),l,t+v,e.q.getMinutes()+y,e.q.getSeconds(),e.q.getMilliseconds()),e.q.setTime(f.getTime()))),g=e.q.getTime(),e.q.setTime(g+36e5),e.q.getHours()!=t&&e.q.setTime(g)}function Q7t(e,t){var i,a,l,f,g,m,v,y,E;for(ii(t,"Layer constraint edge reversal",1),g=new j(e.b);g.ai){On(t);return}switch(h(G(e,($e(),yoe)),319).g){case 2:f=new Ha;break;case 0:f=new Q1;break;default:f=new IT}if(a=f.sf(e,l),!f.tf())switch(h(G(e,aTe),347).g){case 2:a=Tzt(l,a);break;case 1:a=vOt(l,a)}Vzt(e,l,a),On(t)}function tKe(e,t,i){var a,l,f,g;return e.ti()?(l=null,f=e.ui(),a=e.mi(1,g=KQ(e,t,i),i,t,f),e.qi()&&!(e.Bh()&&g!=null?ki(g,i):Be(g)===Be(i))?(g!=null&&(l=e.si(g,null)),l=e.ri(i,l),e.xi()&&(l=e.Ai(g,i,l)),l?(l.Sh(a),l.Th()):e.ni(a)):(e.xi()&&(l=e.Ai(g,i,null)),l?(l.Sh(a),l.Th()):e.ni(a)),g):(g=KQ(e,t,i),e.qi()&&!(e.Bh()&&g!=null?ki(g,i):Be(g)===Be(i))&&(l=null,g!=null&&(l=e.si(g,null)),l=e.ri(i,l),l&&l.Th()),g)}function wne(e){var t,i,a,l,f,g,m;if(!e.d){if(m=new xN,t=BL,f=t.a.Zb(e,t),f==null){for(a=new Bn(Bo(e));a.e!=a.i._b();)i=h(Yn(a),24),Mr(m,wne(i));t.a.$b(e)!=null,t.a._b()==0}for(g=m.i,l=(!e.q&&(e.q=new ze(uf,e,11,10)),new Bn(e.q));l.e!=l.i._b();++g)h(Yn(l),371);Mr(m,(!e.q&&(e.q=new ze(uf,e,11,10)),e.q)),bw(m),e.d=new t_((h(ae(ye((kg(),Ct).o),9),17),m.i),m.g),e.e=h(m.g,611),e.e==null&&(e.e=tut),uu(e).b&=-17}return e.d}function hP(e,t,i,a){var l,f,g,m,v,y;if(y=cl(e.e.mg(),t),v=0,l=h(e.g,124),Yo(),h(t,61).bj()){for(g=0;g1&&(v>Ul(m)*yf(m)/2||g.b==0)&&(C=new xU(R),E=Ul(m)/yf(m),y=Rne(C,t,new j2,i,a,l,E),tr(Hf(C.e),y),m=C,B.c[B.c.length]=C,v=0,R.c=le(on,et,1,0,5,1)));return Lr(B,R),B}function izt(e,t){var i,a,l,f,g,m,v,y,E;for(ii(t,"Hierarchical port dummy size processing",1),v=new ke,E=new ke,a=ce(Xe(G(e,($e(),a3)))),i=a*2,f=new j(e.b);f.a=V&&e.e[v.o]>N*e.b||fe>=i*V)&&(R.c[R.c.length]=m,m=new ke,wo(g,f),f.a.Pb(),y-=E,B=w.Math.max(B,y*e.b+W),y+=fe,ie=fe,fe=0,E=0,W=0);return new Is(B,R)}function ozt(e){var t,i,a,l,f,g,m,v,y,E,C,R;for(t=YXe(e),E=(m=new Gv(t).a.Tb().tc(),new pR(m));E.a.hc();){for(y=(l=h(E.a.ic(),38),h(l.kc(),8)),C=y.d.d,R=y.n.b+y.d.a,e.d[y.o]=0,i=y;(f=e.a[i.o])!=y;)a=ZIt(i,f),e.c==(Eh(),Yp)?v=a.d.k.b+a.d.a.b-a.c.k.b-a.c.a.b:v=a.c.k.b+a.c.a.b-a.d.k.b-a.d.a.b,g=ce(e.d[i.o])+v,e.d[f.o]=g,C=w.Math.max(C,f.d.d-g),R=w.Math.max(R,g+f.n.b+f.d.a),i=f;i=y;do e.d[i.o]=ce(e.d[i.o])+C,i=e.a[i.o];while(i!=y);e.b[y.o]=C+R}}function y_e(e,t,i){var a,l,f,g,m,v,y,E,C,R;for(MVe(this),i==(S0(),um)?Cr(this.o,e):Cr(this.t,e),E=Jr,y=Ts,g=t.a.Xb().tc();g.hc();)l=h(g.ic(),48),m=h(l.a,417),a=h(l.b,14),v=a.c,v==e&&(v=a.d),m==um?Cr(this.o,v):Cr(this.t,v),R=Fo(X(q(es,1),be,9,0,[v.g.k,v.k,v.a])).b,E=w.Math.min(E,R),y=w.Math.max(y,R);for(C=Fo(X(q(es,1),be,9,0,[e.g.k,e.k,e.a])).b,Iqe(this,C,E,y),f=t.a.Xb().tc();f.hc();)l=h(f.ic(),48),NXe(this,h(l.b,14));this.k=!1}function azt(e){var t,i,a,l;if(a=Ine((!e.c&&(e.c=ZI(e.f)),e.c),0),e.e==0||e.a==0&&e.f!=-1&&e.e<0)return a;if(t=G0e(e)<0?1:0,i=e.e,l=(a.length+1+RE(yr(e.e)),new tw),t==1&&(l.a+="-"),e.e>0)if(i-=a.length-t,i>=0){for(l.a+="0.";i>_1.length;i-=_1.length)i9e(l,_1);GFe(l,_1,yr(i)),Mi(l,a.substr(t,a.length-t))}else i=t-i,Mi(l,Xf(a,t,yr(i))),l.a+=".",Mi(l,cI(a,yr(i)));else{for(Mi(l,a.substr(t,a.length-t));i<-_1.length;i+=_1.length)i9e(l,_1);GFe(l,_1,yr(-i))}return l.a}function Ba(e,t){var i,a,l,f,g,m,v;if(e==null)return null;if(f=e.length,f==0)return"";for(v=le(Zl,Ph,22,f,15,1),x0e(0,f,e.length),x0e(0,f,v.length),V9e(e,0,f,v,0),i=null,m=t,l=0,g=0;l0?Xf(i.a,0,f-1):""):e.substr(0,f-1):i?i.a:e}function czt(e){var t,i,a,l,f,g,m,v,y,E,C,R,B;for(i=(y=new bh(e.c.b).a.Tb().tc(),new a0(y));i.a.hc();)t=(m=h(i.a.ic(),38),h(m.lc(),180)),l=t.a,l==null&&(l=""),a=NMt(e.c,l),!a&&l.length==0&&(a=KIt(e)),a&&!_x(a.c,t,!1)&&Gi(a.c,t);for(g=Nn(e.a,0);g.b!=g.d.c;)f=h(Un(g),436),E=f0e(e.c,f.a),B=f0e(e.c,f.b),E&&B&&Gi(E.c,new Is(B,f.c));for(rd(e.a),R=Nn(e.b,0);R.b!=R.d.c;)C=h(Un(R),436),t=OMt(e.c,C.a),v=f0e(e.c,C.b),t&&v&&OEt(t,v,C.c);rd(e.b)}function lzt(e,t,i){var a,l,f,g,m,v,y,E,C;for(v=i+t.c.c.a,C=new j(t.i);C.a1,m=new zp(E.c);Zo(m.a)||Zo(m.b);)g=h(Zo(m.a)?$(m.a):$(m.b),14),y=g.c==E?g.d:g.c,w.Math.abs(Fo(X(q(es,1),be,9,0,[y.g.k,y.k,y.a])).b-f.b)>1&&b9t(e,g,f,l,E)}}function pP(e){var t,i,a,l,f,g,m,v;if(!e.f){if(v=new yN,m=new yN,t=BL,g=t.a.Zb(e,t),g==null){for(f=new Bn(Bo(e));f.e!=f.i._b();)l=h(Yn(f),24),Mr(v,pP(l));t.a.$b(e)!=null,t.a._b()==0}for(a=(!e.s&&(e.s=new ze(Sc,e,21,17)),new Bn(e.s));a.e!=a.i._b();)i=h(Yn(a),158),re(i,62)&&$n(m,h(i,17));bw(m),e.r=new c9e(e,(h(ae(ye((kg(),Ct).o),6),17),m.i),m.g),Mr(v,e.r),bw(v),e.f=new t_((h(ae(ye(Ct.o),5),17),v.i),v.g),uu(e).b&=-3}return e.f}function uzt(e){var t,i,a,l,f,g,m,v,y,E,C,R,B,N;for(g=e.o,a=le(In,si,22,g,15,1),l=le(In,si,22,g,15,1),i=e.p,t=le(In,si,22,i,15,1),f=le(In,si,22,i,15,1),y=0;y=0&&!L_(e,E,C);)--C;l[E]=C}for(B=0;B=0&&!L_(e,m,N);)--m;f[N]=m}for(v=0;vt[R]&&Ra[v]&&P7(e,v,R,!1,!0)}function I7(){I7=M,CAe=X(q(Zl,1),Ph,22,15,[48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70]),Rlt=new RegExp(`[ +\r\f]+`);try{RL=X(q(PVt,1),et,1699,0,[new N2((oge(),qU("yyyy-MM-dd'T'HH:mm:ss'.'SSSZ",oI((Wf(),Wf(),jP))))),new N2(qU("yyyy-MM-dd'T'HH:mm:ss'.'SSS",oI(jP))),new N2(qU("yyyy-MM-dd'T'HH:mm:ss",oI(jP))),new N2(qU("yyyy-MM-dd'T'HH:mm",oI(jP))),new N2(qU("yyyy-MM-dd",oI(jP)))])}catch(e){if(e=pr(e),!re(e,78))throw Y(e)}}function nKe(e,t){var i,a,l,f,g;switch(f=new zc,e.a.g){case 1:case 3:wo(f,t.e.a),Gi(f,t.i.k),wo(f,R0(t.j.a)),Gi(f,t.a.k),wo(f,t.f.a);break;default:wo(f,t.e.a),wo(f,R0(t.j.a)),wo(f,t.f.a)}rd(t.f.a),wo(t.f.a,f),Os(t.f,t.e.c),i=h(G(t.e,($e(),Lo)),74),l=h(G(t.j,Lo),74),a=h(G(t.f,Lo),74),(i||l||a)&&(g=new zc,d1e(g,a),d1e(g,l),d1e(g,i),Ee(t.f,Lo,g)),Os(t.j,null),_s(t.j,null),Os(t.e,null),_s(t.e,null),Hs(t.a,null),Hs(t.i,null),t.g&&nKe(e,t.g)}function iKe(e){Y2(e,new O_(q2(V2(H2(W2(new e0,u1),"ELK DisCo"),"Layouter for arranging unconnected subgraphs. The subgraphs themselves are, by default, not laid out."),new nt))),bt(e,u1,Mie,qt(fEe)),bt(e,u1,Tie,qt(lse)),bt(e,u1,WS,qt(fit)),bt(e,u1,Ux,qt(uEe)),bt(e,u1,aye,qt(git)),bt(e,u1,cye,qt(pit)),bt(e,u1,oye,qt(mit)),bt(e,u1,lye,qt(dit)),bt(e,u1,fye,qt(hit)),bt(e,u1,hye,qt(cse)),bt(e,u1,dye,qt(lEe)),bt(e,u1,pye,qt(Yz))}function fzt(e,t,i){var a,l,f,g,m,v,y,E,C;for(g=new JHe,y=X(q(In,1),si,22,15,[0]),l=-1,f=0,a=0,v=0;v0){if(l<0&&E.a&&(l=v,f=y[0],a=0),l>=0){if(m=E.b,v==l&&(m-=a++,m==0))return 0;if(!rJe(t,y,E,m,g)){v=l-1,y[0]=f;continue}}else if(l=-1,!rJe(t,y,E,0,g))return 0}else{if(l=-1,E.c.charCodeAt(0)==32){if(C=y[0],Ije(t,y),y[0]>C)continue}else if(SPt(t,E.c,y[0])){y[0]+=E.c.length;continue}return 0}return Njt(g,i)?y[0]:0}function hzt(e,t,i){var a,l,f,g,m;if(a=h(G(e,($e(),doe)),19),i.a>t.a&&(a.pc((kS(),dG))?e.c.a+=(i.a-t.a)/2:a.pc(pG)&&(e.c.a+=i.a-t.a)),i.b>t.b&&(a.pc((kS(),mG))?e.c.b+=(i.b-t.b)/2:a.pc(gG)&&(e.c.b+=i.b-t.b)),h(G(e,(Ie(),Va)),19).pc((xo(),Su))&&(i.a>t.a||i.b>t.b))for(m=new j(e.a);m.at.a&&(a.pc((kS(),dG))?e.c.a+=(i.a-t.a)/2:a.pc(pG)&&(e.c.a+=i.a-t.a)),i.b>t.b&&(a.pc((kS(),mG))?e.c.b+=(i.b-t.b)/2:a.pc(gG)&&(e.c.b+=i.b-t.b)),h(G(e,(Ie(),Va)),19).pc((xo(),Su))&&(i.a>t.a||i.b>t.b))for(g=new j(e.a);g.aB||a+l>y)throw Y(new r8);if(!(C.i&1)&&R!=v)if(E=__(e),f=__(i),Be(e)===Be(i)&&ta;)Gr(f,m,E[--t]);else for(m=a+l;a0&&Swe(e,t,i,a,l,!0)}function gzt(e,t,i){var a,l,f,g,m,v,y,E,C,R;for(E=new I9(new Vv(i)),m=le(Ru,f1,22,e.f.e.c.length,16,1),l1e(m,m.length),i[t.b]=0,y=new j(e.f.e);y.a=e.b.length?(f[l++]=g.b[a++],f[l++]=g.b[a++]):a>=g.b.length?(f[l++]=e.b[i++],f[l++]=e.b[i++]):g.b[a]=m?NQ(e.a,f,t.a,m):NQ(t.a,m,e.a,f);else{if(l=f!=m?f>m?1:-1:Mbe(e.a,t.a,f),l==0)return Kg(),cM;l==1?(R=g,C=DQ(e.a,f,t.a,m)):(R=v,C=DQ(t.a,m,e.a,f))}return y=new l_(R,C.length,C),gA(y),y}function oKe(e,t){var i,a,l,f,g,m;for(g=new Zm(new Ep(e.f.b).a);g.b;){if(f=L0(g),l=h(f.kc(),536),t==1){if(l.Je()!=(qs(),hm)&&l.Je()!=rp)continue}else if(l.Je()!=(qs(),rf)&&l.Je()!=sf)continue;switch(a=h(h(f.lc(),48).b,80),m=h(h(f.lc(),48).a,172),i=m.c,l.Je().g){case 2:a.g.c=e.e.a,a.g.b=w.Math.max(1,a.g.b+i);break;case 1:a.g.c=a.g.c+i,a.g.b=w.Math.max(1,a.g.b-i);break;case 4:a.g.d=e.e.b,a.g.a=w.Math.max(1,a.g.a+i);break;case 3:a.g.d=a.g.d+i,a.g.a=w.Math.max(1,a.g.a-i)}}}function aKe(e,t,i,a){var l,f,g,m,v,y,E;if(f=zU(a),m=ce(mt(G(a,($e(),jMe)))),(m||ce(mt(G(e,OG))))&&!Bd(h(G(e,Ki),83)))l=r6(f),v=d_e(e,i,i==(Oo(),lc)?l:n6(l));else switch(v=new yo,us(v,e),t?(E=v.k,E.a=t.a-e.k.a,E.b=t.b-e.k.b,Gqe(E,0,0,e.n.a,e.n.b),mr(v,$Ze(v,f))):(l=r6(f),mr(v,i==(Oo(),lc)?l:n6(l))),g=h(G(a,(Ie(),Va)),19),y=v.i,f.g){case 2:case 1:(y==(Fe(),bn)||y==ni)&&g.nc((xo(),py));break;case 4:case 3:(y==(Fe(),Zt)||y==nn)&&g.nc((xo(),py))}return v}function vzt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W;for(m=le(In,si,22,t.b.c.length,15,1),y=le(xse,Oe,232,t.b.c.length,0,1),v=le(Eu,Af,8,t.b.c.length,0,1),C=e.a,R=0,B=C.length;R0&&v[a]&&(N=r_(e.b,v[a],l)),W=w.Math.max(W,l.c.c.b+N);for(f=new j(E.f);f.a"}v!=null&&(t.a+=""+v)}else e.e?(m=e.e.zb,m!=null&&(t.a+=""+m)):(t.a+="?",e.b?(t.a+=" super ",Ene(e.b,t)):e.f&&(t.a+=" extends ",Ene(e.f,t)))}function _zt(e,t){var i,a,l,f,g,m,v,y;for(e.f=t,e.d=h(G(e.f,(UI(),_Ee)),348),e.g=h(G(e.f,SEe),21).a,e.e=ce(Xe(G(e.f,yEe))),e.c=ce(Xe(G(e.f,tG))),JJ(e.b),a=new j(e.f.c);a.a=0)return!1;if(i.e&&l==(Xt(),$a)&&l!=i.e)return!1;if(t.o=i.b,De(i.f,t),i.e=l,l==(Xt(),Nr)||l==oa||l==$a){for(g=new j(t.i);g.a0&&a<=l?(y-=a,f=m,g=m):(e.a==null&&Fte(e),e.a[g]&&(y+=l,f=g)),f>0){De(C,He(f)),m=-1,E=!1;do if(i.hc())v=He(h(i.ic(),21).a+y);else break e;while(v.a<=g)}}else if(e.a==null&&Fte(e),e.a[g]&&(m=g),g==v.a)if(e.a==null&&Fte(e),e.a[g])if(C.c[C.c.length]=v,m=-1,i.hc())v=He(h(i.ic(),21).a+y);else break;else E=!0;++g}return C}function uKe(e){var t,i,a,l;return e.Db&64?Xee(e):(t=new ou(hxe),a=e.k,a?Mi(Mi((t.a+=' "',t),a),'"'):(!e.n&&(e.n=new ze(ea,e,1,7)),e.n.i>0&&(l=(!e.n&&(e.n=new ze(ea,e,1,7)),h(h(ae(e.n,0),137),263)).a,!l||Mi(Mi((t.a+=' "',t),l),'"'))),i=(!e.b&&(e.b=new an(pi,e,4,7)),!(e.b.i<=1&&(!e.c&&(e.c=new an(pi,e,5,8)),e.c.i<=1))),i?t.a+=" [":t.a+=" ",Mi(t,lJ(new LR(Ca),new Bn(e.b))),i&&(t.a+="]"),t.a+=" -> ",i&&(t.a+="["),Mi(t,lJ(new LR(Ca),new Bn(e.c))),i&&(t.a+="]"),t.a)}function Czt(e){var t,i,a,l,f,g;for(l=new ke,g=new j(e.c.i);g.ae.n.b||(i=sa(e,Zt),m=t.d+t.a+(i._b()-1)*g,m>e.n.b)))}function Cne(e,t,i){var a,l,f,g,m,v,y,E;return a=e.a.o==(Jf(),oh)?Jr:Ts,m=XZe(e,new UOe(t,i)),!m.a&&m.c?(Gi(e.c,m),a):m.a?(l=m.a.c,v=m.a.d,i?(y=e.a.c==(Eh(),rb)?v:l,f=e.a.c==rb?l:v,g=e.a.g[f.g.o],E=ce(e.a.p[g.o])+ce(e.a.d[f.g.o])+f.k.b+f.a.b-ce(e.a.d[y.g.o])-y.k.b-y.a.b):(y=e.a.c==(Eh(),Yp)?v:l,f=e.a.c==Yp?l:v,E=ce(e.a.p[e.a.g[f.g.o].o])+ce(e.a.d[f.g.o])+f.k.b+f.a.b-ce(e.a.d[y.g.o])-y.k.b-y.a.b),e.a.n[e.a.g[l.g.o].o]=(vt(),vt(),!0),e.a.n[e.a.g[v.g.o].o]=!0,E):a}function Ane(e,t,i,a,l,f,g){var m,v,y,E,C,R,B;return C=ce(mt(G(t,($e(),$Me)))),R=null,f==(Oo(),Fc)&&a.c.g==i?R=a.c:f==lc&&a.d.g==i&&(R=a.d),y=g,!g||!C||R?(E=(Fe(),Na),R?E=R.i:Bd(h(G(i,Ki),83))&&(E=f==Fc?nn:Zt),v=Gzt(e,t,i,f,E,a),m=OQ((va(i),a)),f==Fc?(Os(m,h(St(v.i,0),11)),_s(m,l)):(Os(m,l),_s(m,h(St(v.i,0),11))),y=new KVe(a,m,v,h(G(v,(Ie(),Jn)),11),f,!R)):(De(g.e,a),B=w.Math.max(ce(Xe(G(g.d,tp))),ce(Xe(G(a,tp)))),Ee(g.d,tp,B)),ir(e.a,a,new d9(y.d,t,f)),y}function hKe(e,t){var i,a,l,f,g,m,v,y,E,C;if(Ee(t,(ha(),wM),0),v=h(G(t,tj),76),t.d.b==0)v?(E=ce(Xe(G(v,Jp)))+e.a+h0e(v,t),Ee(t,Jp,E)):Ee(t,Jp,0);else{for(a=(f=Nn(new Dd(t).a.d,0),new ew(f));v8(a.a);)i=h(Un(a.a),170).c,hKe(e,i);m=h(c9((g=Nn(new Dd(t).a.d,0),new ew(g))),76),C=h(aTt((l=Nn(new Dd(t).a.d,0),new ew(l))),76),y=(ce(Xe(G(C,Jp)))+ce(Xe(G(m,Jp))))/2,v?(E=ce(Xe(G(v,Jp)))+e.a+h0e(v,t),Ee(t,Jp,E),Ee(t,wM,ce(Xe(G(t,Jp)))-y),IGt(e,t)):Ee(t,Jp,y)}}function Lzt(e,t){var i,a,l,f,g,m,v,y,E;if(y=h(G(e,(Ie(),pa)),69),a=h(St(e.i,0),11),y==(Fe(),bn)?mr(a,ni):y==ni&&mr(a,bn),h(G(t,($e(),jw)),185).pc((Hl(),C1))){if(v=ce(Xe(G(e,aL))),g=ce(Xe(G(e,c3))),m=h(G(t,s3),275),m==(eh(),hb))for(i=v,E=e.n.a/2-a.k.a,f=new j(a.e);f.a0&&a>=-6?a>=0?vI(f,i-yr(e.e),"."):(f.a=Xf(f.a,0,t-1)+"0."+cI(f.a,t-1),vI(f,t+1,hu(_1,0,-yr(a)-1))):(i-t>=1&&(vI(f,t,"."),++i),vI(f,i,"E"),a>0&&vI(f,++i,"+"),vI(f,++i,""+E9(Wc(a)))),e.g=f.a,e.g))}function pKe(e,t,i){var a,l,f,g;this.j=e,this.e=gve(e),this.o=h(G(this.j,(Ie(),sm)),8),this.i=!!this.o,this.p=this.i?h(St(i,va(this.o).o),204):null,l=h(G(e,Va),19),this.g=l.pc((xo(),Su)),this.b=new ke,this.d=new kWe(this.e),g=h(G(this.j,gM),214),this.q=qRt(t,g,this.e),this.k=new E7e(this),f=Ym(X(q(crt,1),et,208,0,[this,this.d,this.k,this.q])),t==(k0(),HG)?(a=new sVe(this.e),f.c[f.c.length]=a,this.c=new sze(a,g,h(this.q,422))):this.c=new IOe(t,this),De(f,this.c),fKe(f,this.e),this.s=d$t(this.k)}function Rzt(e,t){var i,a,l,f;return i=new Ae,a=h(sd(Yf(new oi(null,new di(e.f,16)),i),b_(new qn,new bi,new Si,new it,X(q(ih,1),Oe,150,0,[(Wg(),Bw),nh]))),19),l=a._b(),l=l==2?1:0,l==1&&rw(i6(h(sd(go(a.uc(),new Le),F$e(n1(0),new $i)),149).a,2),0)&&(l=0),a=h(sd(Yf(new oi(null,new di(t.f,16)),i),b_(new qn,new bi,new Si,new it,X(q(ih,1),Oe,150,0,[Bw,nh]))),19),f=a._b(),f=f==2?1:0,f==1&&rw(i6(h(sd(go(a.uc(),new ht),F$e(n1(0),new $i)),149).a,2),0)&&(f=0),l=e.b[l+1])l+=2;else if(i0)for(a=new _f(h(er(e.a,f),19)),_t(),fa(a,new BF(t)),l=new Ns(f.b,0);l.b=oo?ho(i,Wbe(a)):JE(i,a&jr),g=(++Er,new _Q(10,null,0)),CAt(e.a,g,m-1)):(i=(g.ll().length+f,new MC),ho(i,g.ll())),t.e==0?(a=t.jl(),a>=oo?ho(i,Wbe(a)):JE(i,a&jr)):ho(i,t.ll()),h(g,474).b=i.a}}function Fzt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B;if(ii(t,"Edge splitting",1),e.b.c.length<=2){On(t);return}for(f=new Ns(e.b,0),g=(Rn(f.bCe)?(v=2,g=zi):v==0?(v=1,g=qe):(v=0,g=qe)):(B=qe>=g||g-qe0?(l=a+(N-1)*i,C&&(l+=a),l0){JU(e,i,0),i.a+=String.fromCharCode(a),l=rIt(t,f),JU(e,i,l),f+=l-1;continue}a==39?f+10){if(t=new dge(e.i,e.g),i=e.i,f=i<100?null:new Eg(i),e.xi())for(a=0;a0){for(m=e.g,y=e.i,_A(e),f=y<100?null:new Eg(y),a=0;a0)if(t=new cbe(e.Uh()),l=v<100?null:new Eg(v),rI(e,v,t.g),a=v==1?e.mi(4,ae(t,0),null,0,m):e.mi(6,t,null,-1,m),e.qi()){for(i=new Bn(t);i.e!=i.i._b();)l=e.si(Yn(i),l);l?(l.Sh(a),l.Th()):e.ni(a)}else l?(l.Sh(a),l.Th()):e.ni(a);else rI(e,e.hi(),e.ii()),e.ni(e.mi(6,(_t(),uo),null,-1,m));else if(e.qi())if(v=e.hi(),v>0){for(g=e.ii(),rI(e,v,g),l=v<100?null:new Eg(v),i=0;i>13|(e.m&15)<<9,l=e.m>>4&8191,f=e.m>>17|(e.h&255)<<5,g=(e.h&1048320)>>8,m=t.l&8191,v=t.l>>13|(t.m&15)<<9,y=t.m>>4&8191,E=t.m>>17|(t.h&255)<<5,C=(t.h&1048320)>>8,ut=i*m,ft=a*m,Mt=l*m,Et=f*m,kn=g*m,v!=0&&(ft+=i*v,Mt+=a*v,Et+=l*v,kn+=f*v),y!=0&&(Mt+=i*y,Et+=a*y,kn+=l*y),E!=0&&(Et+=i*E,kn+=a*E),C!=0&&(kn+=i*C),B=ut&Yc,N=(ft&511)<<13,R=B+N,V=ut>>22,ee=ft>>9,ie=(Mt&262143)<<4,fe=(Et&31)<<17,W=V+ee+ie+fe,Ce=Mt>>18,Ue=Et>>5,qe=(kn&4095)<<8,we=Ce+Ue+qe,W+=R>>22,R&=Yc,we+=W>>22,W&=Yc,we&=Kd,Xa(R,W,we)}function bKe(e,t){var i,a,l,f,g;i=ce(Xe(G(t,($e(),sh)))),i<2&&Ee(t,sh,2),a=h(G(t,nf),110),a==(qs(),Oh)&&Ee(t,nf,zU(t)),l=h(G(t,eot),21),l.a==0?Ee(t,(Ie(),gM),new Jee):Ee(t,(Ie(),gM),new J9(l.a)),f=mt(G(t,rL)),f==null&&Ee(t,rL,(vt(),Be(G(t,cm))===Be((ld(),EM)))),g=new jqe(t),Ee(t,(Ie(),Uw),g),Z1e(e.a),fw(e.a,(_o(),Dh),h(G(t,CMe),285)),fw(e.a,Zx,h(G(t,GMe),285)),fw(e.a,Qa,h(G(t,mM),285)),fw(e.a,ec,h(G(t,FG),285)),fw(e.a,qo,tIt(h(G(t,cm),197))),UNe(e.a,w$t(t)),Ee(t,coe,T_e(e.a,t))}function wKe(e,t){var i,a,l,f,g,m,v,y,E,C;if(v=t.length-1,m=t.charCodeAt(v),m==93){if(g=yh(t,wc(91)),g>=0)return l=E6t(e,t.substr(1,g-1)),E=t.substr(g+1,v-(g+1)),r$t(e,E,l)}else{if(i=-1,/\d/.test(String.fromCharCode(m))&&(i=cme(t,wc(46),v-1),i>=0)){a=h(m0e(e,Eje(e,t.substr(1,i-1)),!1),52);try{y=Sl(t.substr(i+1,t.length-(i+1)),zs,zi)}catch(R){throw R=pr(R),re(R,118)?(f=R,Y(new hU(f))):Y(R)}if(y4)if(e.Li(t)){if(e.Dj()){if(l=h(t,42),a=l.ng(),v=a==e.e&&(e.Pj()?l.hg(l.og(),e.Lj())==e.Mj():-1-l.og()==e.pi()),e.Qj()&&!v&&!a&&l.sg()){for(f=0;f=V-1)return null;for(l=new ke,l.c[l.c.length]=t,we=t,g=i,N=-1,m=h(St(e.d.c.b,i),26),B=0;B1&&g0&&(y=e.k.a/f);break;case 2:case 4:l=e.g.n.b,l>0&&(y=e.k.b/l)}Ee(e,(Ie(),tb),y)}if(v=e.n,g=e.a,a)g.a=a.a,g.b=a.b,e.b=!0;else if(t!=sp&&t!=fb&&m!=Na)switch(m.g){case 1:g.a=v.a/2;break;case 2:g.a=v.a,g.b=v.b/2;break;case 3:g.a=v.a/2,g.b=v.b;break;case 4:g.b=v.b/2}else g.a=v.a/2,g.b=v.b/2}function nGt(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N;for(ii(i,xQe,1),e.c=t,R=e.c.a,f=0,y=new j(R);y.aN){for(B=1,l=m.n.a;l>g;)++B,l=(m.n.a-(B-1)*e.d)/B;De(a,new $ze(e,m,B,l))}for(v=new j(a);v.a1&&Ul(g)*yf(g)/2>m[0]){for(f=0;fm[f];)++f;N=new Rg(W,0,f+1),C=new xU(N),E=Ul(g)/yf(g),v=Rne(C,t,new j2,i,a,l,E),tr(Hf(C.e),v),dS(RS(R,C)),B=new Rg(W,f+1,W.c.length),F0e(R,B),W.c=le(on,et,1,0,5,1),y=0,D9e(m,m.length,0)}else V=R.b.c.length==0?null:St(R.b,0),V!=null&&ibe(R,0),y>0&&(m[y]=m[y-1]),m[y]+=Ul(g)*yf(g),++y,W.c[W.c.length]=g;return W}function T_e(e,t){var i,a,l,f,g,m,v,y,E,C,R;if(e.e&&e.c.c.5?ee-=g*2*(N-.5):N<.5&&(ee+=f*2*(.5-N)),l=m.d.b,eeV.a-W-E&&(ee=V.a-W-E),m.k.a=t+ee}}function _Ke(e,t){var i,a,l,f,g;for(g=new j(e.i);g.a0&&eXe(e,m,C);for(l=new j(C);l.a0&&(e.a=v+(B-1)*f,t.c.b+=e.a,t.e.b+=e.a)),N.a._b()!=0&&(R=new Nte(1,f),B=x_e(R,t,N,W,t.e.b+v-t.c.b),B>0&&(t.e.b+=v+(B-1)*f))}function A_e(e,t,i){var a,l,f,g,m,v;if(t.l==0&&t.m==0&&t.h==0)throw Y(new u8("divide by zero"));if(e.l==0&&e.m==0&&e.h==0)return i&&(rm=Xa(0,0,0)),Xa(0,0,0);if(t.h==G6&&t.m==0&&t.l==0)return O6t(e,i);if(v=!1,t.h>>19&&(t=_S(t),v=!0),g=W8t(t),f=!1,l=!1,a=!1,e.h==G6&&e.m==0&&e.l==0)if(l=!0,f=!0,g==-1)e=DNe((gS(),o3e)),a=!0,v=!v;else return m=kve(e,g),v&&Cee(m),i&&(rm=Xa(0,0,0)),m;else e.h>>19&&(f=!0,e=_S(e),a=!0,v=!v);return g!=-1?wIt(e,g,v,f,i):Bwe(e,t)<0?(i&&(f?rm=_S(e):rm=Xa(e.l,e.m,e.h)),Xa(0,0,0)):g7t(a?e:Xa(e.l,e.m,e.h),t,v,f,l,i)}function lGt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie;for(y=t.c,l=Sge(e.e),C=au(iI(Ua(Ege(e.e)),e.d*e.a,e.c*e.b),-.5),i=l.a-C.a,a=l.b-C.b,g=t.a,i=g.c-i,a=g.d-a,v=new j(y);v.a=0)return i;switch(E0(Vo(e,i))){case 2:{if(dt("",jp(e,i.Wi()).be())){if(v=mI(Vo(e,i)),m=iS(Vo(e,i)),E=Bve(e,t,v,m),E)return E;for(l=c_e(e,t),g=0,C=l._b();gt.e||t.f>e.e)){for(i=0,a=0,g=e.t.a.Xb().tc();g.hc();)l=h(g.ic(),11),Vee(Fo(X(q(es,1),be,9,0,[l.g.k,l.k,l.a])).b,t.f,t.e)&&++i;for(m=e.o.a.Xb().tc();m.hc();)l=h(m.ic(),11),Vee(Fo(X(q(es,1),be,9,0,[l.g.k,l.k,l.a])).b,t.f,t.e)&&--i;for(v=t.t.a.Xb().tc();v.hc();)l=h(v.ic(),11),Vee(Fo(X(q(es,1),be,9,0,[l.g.k,l.k,l.a])).b,e.f,e.e)&&++a;for(f=t.o.a.Xb().tc();f.hc();)l=h(f.ic(),11),Vee(Fo(X(q(es,1),be,9,0,[l.g.k,l.k,l.a])).b,e.f,e.e)&&--a;i0&&i.charCodeAt(0)!=47))throw Y(new un("invalid opaquePart: "+i));if(e&&!(t!=null&&RC(Bj,t.toLowerCase()))&&!(i==null||!Ree(i,IL,DL)))throw Y(new un(xtt+i));if(e&&t!=null&&RC(Bj,t.toLowerCase())&&!HBt(i))throw Y(new un(xtt+i));if(!yIt(a))throw Y(new un("invalid device: "+a));if(!VIt(l))throw g=l==null?"invalid segments: null":"invalid segment: "+FIt(l),Y(new un(g));if(!(f==null||yh(f,wc(35))==-1))throw Y(new un("invalid query: "+f))}function yKe(e,t){var i;if(t==null||dt(t,Xc)||t.length==0&&e.k!=(o1(),_M))return null;switch(e.k.g){case 1:return YU(t,KS)?(vt(),oM):YU(t,dre)?(vt(),Z0):null;case 2:try{return He(Sl(t,zs,zi))}catch(a){if(a=pr(a),re(a,118))return null;throw Y(a)}case 4:try{return xw(t)}catch(a){if(a=pr(a),re(a,118))return null;throw Y(a)}case 3:return t;case 5:return kVe(e),yXe(e,t);case 6:return kVe(e),S8t(e,e.a,t);case 7:try{return i=$Ft(e),i.gf(t),i}catch(a){if(a=pr(a),re(a,30))return null;throw Y(a)}default:throw Y(new ba("Invalid type set for this layout option."))}}function pGt(e){var t,i,a,l,f,g,m,v,y,E,C;for(g=new j(e.d.b);g.a0&&YI(y,!0,(qs(),sf)),m.j==(Xt(),Qr)&&dUe(y),dr(e.f,m,t)}}function gGt(e,t,i){var a,l,f,g,m,v,y,E;if(i._b()==0)return!1;if(m=(Yo(),h(t,61).bj()),f=m?i:new w_(i._b()),G0(e.e,t)){if(t.xh())for(y=i.tc();y.hc();)v=y.ic(),bne(e,t,v,re(t,62)&&(h(h(t,17),62).Bb&oo)!=0)||(l=Dg(t,v),f.pc(l)||f.nc(l));else if(!m)for(y=i.tc();y.hc();)v=y.ic(),l=Dg(t,v),f.nc(l)}else{if(i._b()>1)throw Y(new un(Ore));for(E=cl(e.e.mg(),t),a=h(e.g,124),g=0;g1&&g>1;)E=ZZe(e,we),m=h(St(e.d.c.b,g),26),C=h(St(e.d.c.b,g-1),26),Ue=h(W.cd(R++),21).a,ee=h0(Ue,C.a.c.length),Yg(we,ee,C),Yg(E,fe,m),fe=ee,we&&(l.c[l.c.length]=we),we=E,--Ce,++f,--g;for(ie=(a-(l.c.length-1)*e.d.d)/l.c.length,y=new j(l);y.a0&&m7(e,t,!1,!1,l),C=Pte(e,t,!0,!1)):(m7(e,t,!1,v,0),C=Pte(e,t,!0,!1)):E?(m=h(h(er(e.r,t),19),60)._b(),f=eOt(e,t),C=f*m+e.u*(m-1),f>0&&m7(e,t,!0,!1,f)):(m7(e,t,!0,!1,0),C=Pte(e,t,!0,!0)),nne(e,t)==(Xg(),ub)&&(C+=2*e.u),i.a.a=C}function SKe(e,t){var i,a,l,f,g,m,v,y,E,C;if(i=h(Ds(e.b,t),114),h(h(er(e.r,t),19),60).Wb()){i.n.d=0,i.n.a=0;return}i.n.d=e.A.d,i.n.a=e.A.a,l=e.v.pc((Hl(),C1)),E=h(h(er(e.r,t),19),60)._b()==2,m=e.t==(eh(),Ty),y=e.w.pc((cc(),b3)),C=e.w.pc(Sj),a=0,!l||E&&m?a=Lte(e,t,!1,!1):m?C?(f=CFt(e,t,y),f>0&&T7(e,t,f,!1,!1),a=Lte(e,t,!0,!1)):(T7(e,t,0,!1,y),a=Lte(e,t,!0,!1)):C?(v=h(h(er(e.r,t),19),60)._b(),g=r9t(e,t),a=g*v+e.u*(v-1),g>0&&T7(e,t,g,!0,!1)):(T7(e,t,0,!0,!1),a=Lte(e,t,!0,!0)),nne(e,t)==(Xg(),ub)&&(a+=2*e.u),i.a.b=a}function lr(){lr=M,nPe=(ype(),ma).b,uut=h(ae(ye(ma.b),0),29),sv=h(ae(ye(ma.b),1),29),lut=h(ae(ye(ma.b),2),29),CM=ma.bb,h(ae(ye(ma.bb),0),29),h(ae(ye(ma.bb),1),29),AM=ma.fb,ED=h(ae(ye(ma.fb),0),29),h(ae(ye(ma.fb),1),29),h(ae(ye(ma.fb),2),17),Iy=ma.qb,xut=h(ae(ye(ma.qb),0),29),h(ae(ye(ma.qb),1),17),h(ae(ye(ma.qb),2),17),Gj=h(ae(ye(ma.qb),3),29),jj=h(ae(ye(ma.qb),4),29),MD=h(ae(ye(ma.qb),6),29),SD=h(ae(ye(ma.qb),5),17),fut=ma.j,hut=ma.k,dut=ma.q,put=ma.w,gut=ma.B,mut=ma.A,but=ma.C,wut=ma.D,vut=ma._,_ut=ma.cb,yut=ma.hb}function bGt(e,t,i){var a,l,f,g,m,v,y,E,C,R,B;e.c=0,e.b=0,a=2*t.c.a.c.length+1;e:for(C=i.tc();C.hc();){if(E=h(C.ic(),11),m=E.i==(Fe(),bn)||E.i==ni,B=0,m){if(R=h(G(E,(Ie(),Pl)),8),!R)continue;B+=SUt(e,a,E,R)}else{for(y=new j(E.f);y.a0?(e.f[E.o]=B/(E.d.c.length+E.f.c.length),e.c=w.Math.min(e.c,e.f[E.o]),e.b=w.Math.max(e.b,e.f[E.o])):m&&(e.f[E.o]=B)}}function wGt(e){e.b=null,e.bb=null,e.fb=null,e.qb=null,e.a=null,e.c=null,e.d=null,e.e=null,e.f=null,e.n=null,e.M=null,e.L=null,e.Q=null,e.R=null,e.K=null,e.db=null,e.eb=null,e.g=null,e.i=null,e.j=null,e.k=null,e.gb=null,e.o=null,e.p=null,e.q=null,e.r=null,e.$=null,e.ib=null,e.S=null,e.T=null,e.t=null,e.s=null,e.u=null,e.v=null,e.w=null,e.B=null,e.A=null,e.C=null,e.D=null,e.F=null,e.G=null,e.H=null,e.I=null,e.J=null,e.P=null,e.Z=null,e.U=null,e.V=null,e.W=null,e.X=null,e.Y=null,e._=null,e.ab=null,e.cb=null,e.hb=null,e.nb=null,e.lb=null,e.mb=null,e.ob=null,e.pb=null,e.jb=null,e.kb=null,e.N=!1,e.O=!1}function vGt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe;if(W=t.b.c.length,!(W<3)){for(B=le(In,si,22,W,15,1),C=0,E=new j(t.b);E.ag)&&Cr(e.c,h(V.b,14));++m}f=g}}}function P_e(e){var t;switch(e.d){case 1:{if(e.wi())return e.o!=-2;break}case 2:{if(e.wi())return e.o==-2;break}case 3:case 5:case 4:case 6:case 7:return e.o>-2;default:return!1}switch(t=e.vi(),e.p){case 0:return t!=null&&ce(mt(t))!=kC(e.k,0);case 1:return t!=null&&h(t,192).a!=nr(e.k)<<24>>24;case 2:return t!=null&&h(t,159).a!=(nr(e.k)&jr);case 6:return t!=null&&kC(h(t,149).a,e.k);case 5:return t!=null&&h(t,21).a!=nr(e.k);case 7:return t!=null&&h(t,168).a!=nr(e.k)<<16>>16;case 3:return t!=null&&ce(Xe(t))!=e.j;case 4:return t!=null&&h(t,126).a!=e.j;default:return t==null?e.n!=null:!ki(t,e.n)}}function Pne(e,t){var i,a,l,f;f=e.F,t==null?(e.F=null,Uee(e,null)):(e.F=(dn(t),t),a=yh(t,wc(60)),a!=-1?(l=t.substr(0,a),yh(t,wc(46))==-1&&!dt(l,jS)&&!dt(l,IP)&&!dt(l,yz)&&!dt(l,DP)&&!dt(l,BP)&&!dt(l,OP)&&!dt(l,NP)&&!dt(l,FP)&&(l=Btt),i=uJ(t,wc(62)),i!=-1&&(l+=""+t.substr(i+1,t.length-(i+1))),Uee(e,l)):(l=t,yh(t,wc(46))==-1&&(a=yh(t,wc(91)),a!=-1&&(l=t.substr(0,a)),!dt(l,jS)&&!dt(l,IP)&&!dt(l,yz)&&!dt(l,DP)&&!dt(l,BP)&&!dt(l,OP)&&!dt(l,NP)&&!dt(l,FP)?(l=Btt,a!=-1&&(l+=""+t.substr(a,t.length-a))):l=t),Uee(e,l),l==t&&(e.F=e.D))),e.Db&4&&!(e.Db&1)&&Li(e,new ls(e,1,5,f,t))}function _Gt(e){EA();var t,i,a,l,f,g,m;for(m=new u0,i=new j(e);i.a=m.b.c)&&(m.b=t),(!m.c||t.c<=m.c.c)&&(m.d=m.c,m.c=t),(!m.e||t.d>=m.e.d)&&(m.e=t),(!m.f||t.d<=m.f.d)&&(m.f=t);return a=new QU((yS(),Q0)),SI(e,Xit,new Bl(X(q(x5,1),et,341,0,[a]))),g=new QU(Nw),SI(e,qit,new Bl(X(q(x5,1),et,341,0,[g]))),l=new QU(Ow),SI(e,Hit,new Bl(X(q(x5,1),et,341,0,[l]))),f=new QU(fy),SI(e,Wit,new Bl(X(q(x5,1),et,341,0,[f]))),ene(a.c,Q0),ene(l.c,Ow),ene(f.c,fy),ene(g.c,Nw),m.a.c=le(on,et,1,0,5,1),Lr(m.a,a.c),Lr(m.a,R0(l.c)),Lr(m.a,f.c),Lr(m.a,R0(g.c)),m}function B6(e,t,i){var a,l,f,g;return e.Rj()&&e.Qj()&&(g=HJ(e,h(i,51)),Be(g)!==Be(i))?(e.ai(t),e.gi(t,jGe(e,t,g)),e.Dj()&&(f=(l=h(i,42),e.Pj()?e.Nj()?l.Cg(e.b,Uo(h(Wt(sc(e.b),e.pi()),17)).n,h(Wt(sc(e.b),e.pi()).jj(),24).Qi(),null):l.Cg(e.b,br(l.mg(),Uo(h(Wt(sc(e.b),e.pi()),17))),null,null):l.Cg(e.b,-1-e.pi(),null,null)),!h(g,42).yg()&&(f=(a=h(g,42),e.Pj()?e.Nj()?a.Ag(e.b,Uo(h(Wt(sc(e.b),e.pi()),17)).n,h(Wt(sc(e.b),e.pi()).jj(),24).Qi(),f):a.Ag(e.b,br(a.mg(),Uo(h(Wt(sc(e.b),e.pi()),17))),null,f):a.Ag(e.b,-1-e.pi(),null,f))),f&&f.Th()),$u(e.b)&&e.ni(e.mi(9,i,g,t,!1)),g):i}function MKe(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we;for(E=ce(Xe(G(e,($e(),S1)))),a=ce(Xe(G(e,eTe))),R=new Bk,Ee(R,S1,E+a),y=t,ee=t.d,W=t.c.g,ie=t.d.g,V=ju(W.c),fe=ju(ie.c),l=new ke,C=V;C<=fe;C++)m=new th(e),Ou(m,(Xt(),Nr)),Ee(m,(Ie(),Jn),y),Ee(m,Ki,(Ms(),Oa)),Ee(m,zG,R),B=h(St(e.b,C),26),C==V?Yg(m,B.a.c.length-i,B):Hs(m,B),we=ce(Xe(G(y,tp))),we<0&&(we=0,Ee(y,tp,we)),m.n.b=we,N=w.Math.floor(we/2),g=new yo,mr(g,(Fe(),nn)),us(g,m),g.k.b=N,v=new yo,mr(v,Zt),us(v,m),v.k.b=N,_s(y,g),f=new Op,No(f,y),Ee(f,Lo,null),Os(f,v),_s(f,ee),_Bt(m,y,f),l.c[l.c.length]=f,y=f;return l}function yGt(e,t){var i,a,l,f,g,m,v,y,E,C;for(e.a=new rUe(HRt(yL)),a=new j(t.a);a.a0;){for(W=(ai(0,v.c.length),h(v.c[0],14)),l=(ai(0,B.c.length),h(B.c[0],14)),ie=l.d.d,f=Qo(ie,l,0),ZLt(W,l.d,f),Os(l,null),_s(l,null),N=W.a,t&&Gi(N,new Do(fe)),a=Nn(l.a,0);a.b!=a.d.c;)i=h(Un(a),9),Gi(N,new Do(i));for(ee=W.b,R=new j(l.b);R.a0?nee(this,this.f/this.a):qf(t.g,t.d[0]).a!=null&&qf(i.g,i.d[0]).a!=null?nee(this,(ce(qf(t.g,t.d[0]).a)+ce(qf(i.g,i.d[0]).a))/2):qf(t.g,t.d[0]).a!=null?nee(this,qf(t.g,t.d[0]).a):qf(i.g,i.d[0]).a!=null&&nee(this,qf(i.g,i.d[0]).a)}function L_e(e){var t;this.r=gPt(new pN,new $q),this.b=(Yr(),new GA(h(Hn(Ec),274))),this.p=new GA(h(Hn(Ec),274)),this.i=new GA(h(Hn(ylt),274)),this.e=e,this.o=new Do(e.Re()),this.B=e.bf()||ce(mt(e.xe((ur(),hj)))),this.v=h(e.xe((ur(),xM)),19),this.w=h(e.xe(gj),19),this.q=h(e.xe(nD),83),this.t=h(e.xe(uae),275),this.j=h(e.xe(pj),19),this.n=h(f6(e,_ct),119),this.k=ce(Xe(f6(e,bj))),this.d=ce(Xe(f6(e,XCe))),this.u=ce(Xe(f6(e,JCe))),this.s=ce(Xe(f6(e,YCe))),this.A=h(f6(e,ZCe),135),this.c=2*this.d,t=!this.w.pc((cc(),yj)),this.f=new HA(0,t,0),this.g=new HA(1,t,0),gK(this.f,(Ef(),Wa),this.g)}function CKe(e,t){var i,a,l,f,g,m,v,y,E,C,R,B;if(t==null||t.length==0)return null;if(f=h(za(e.f,t),27),!f){for(l=(R=new bh(e.d).a.Tb().tc(),new a0(R));l.a.hc();)if(i=(g=h(l.a.ic(),38),h(g.lc(),27)),m=i.f,B=t.length,dt(m.substr(m.length-B,B),t)&&(t.length==m.length||po(m,m.length-t.length-1)==46)){if(f)return null;f=i}if(!f){for(a=(C=new bh(e.d).a.Tb().tc(),new a0(C));a.a.hc();)if(i=(g=h(a.a.ic(),38),h(g.lc(),27)),E=i.g,E!=null){for(v=0,y=E.length;v=1&&(V-g>0&&C>=0?(v.k.a+=W,v.k.b+=f*g):V-g<0&&E>=0&&(v.k.a+=W*V,v.k.b+=f));e.n.a=t.a,e.n.b=t.b,Ee(e,($e(),jw),(Hl(),a=h(bl(AL),10),new Oc(a,h(el(a,a.length),10),0)))}function LKe(e,t){var i,a,l,f,g,m,v,y,E,C;for(v=!0,l=0,y=e.f[t.o],E=t.n.b+e.n,i=e.c[t.o][2],Hu(e.a,y,He(h(St(e.a,y),21).a-1+i)),Hu(e.b,y,ce(Xe(St(e.b,y)))-E+i*e.e),++y,y>=e.i?(++e.i,De(e.a,He(1)),De(e.b,E)):(a=e.c[t.o][1],Hu(e.a,y,He(h(St(e.a,y),21).a+1-a)),Hu(e.b,y,ce(Xe(St(e.b,y)))+E-a*e.e)),(e.q==(G_(),G5)&&(h(St(e.a,y),21).a>e.j||h(St(e.a,y-1),21).a>e.j)||e.q==j5&&(ce(Xe(St(e.b,y)))>e.k||ce(Xe(St(e.b,y-1)))>e.k))&&(v=!1),g=Cn(As(t));Gn(g);)f=h(Tn(g),14),m=f.c.g,e.f[m.o]==y&&(C=LKe(e,m),l=l+h(C.a,21).a,v=v&&ce(mt(C.b)));return e.f[t.o]=y,l=l+e.c[t.o][0],new Is(He(l),(vt(),!!v))}function SGt(e){var t,i,a,l,f,g,m,v,y,E;for(y=new Ir,m=new Ir,f=new j(e);f.a-1){for(l=Nn(m,0);l.b!=l.d.c;)a=h(Un(l),125),a.s=g;for(;m.b!=0;)for(a=h(Ewe(m,0),125),i=new j(a.g);i.a-1){for(f=new j(m);f.a0)&&(v.i=h0(v.i,l.i-1),--v.f,v.f==0&&(m.c[m.c.length]=v))}}function RKe(e,t){var i,a,l,f,g,m,v,y;if(!(t.b==null||e.b==null)){for(U_(e),gP(e),U_(t),gP(t),i=le(In,si,22,e.b.length+t.b.length,15,1),y=0,a=0,g=0;a=m&&l<=v)m<=l&&f<=v?(i[y++]=l,i[y++]=f,a+=2):m<=l?(i[y++]=l,i[y++]=v,e.b[a]=v+1,g+=2):f<=v?(i[y++]=m,i[y++]=f,a+=2):(i[y++]=m,i[y++]=v,e.b[a]=v+1);else if(ve.j&&(e.q=G5,US(e,f));break;case 4:for(e.q=(G_(),VG),US(e,f),y=0,l=new j(e.b);l.ae.k&&(e.q=j5,US(e,f));break;case 6:R=yr(w.Math.ceil(e.f.length*E/100)),US(e,new UF(R));break;case 5:C=yr(w.Math.ceil(e.d*E/100)),US(e,new TE(C));break;default:US(e,f)}K9t(e,t),On(i)}function PGt(e){var t,i,a,l,f,g,m;for(t=new ke,e.g=new ke,e.d=new ke,g=new Zm(new Ep(e.f.b).a);g.b;)f=L0(g),De(t,h(h(f.lc(),48).b,80)),n_(h(f.kc(),536).Je())?De(e.d,h(f.lc(),48)):De(e.g,h(f.lc(),48));for(ete(e,e.d),ete(e,e.g),e.c=new DXe(e.b),_Et(e.c,(Lpe(),zit)),Zee(e,e.d),Zee(e,e.g),Lr(t,e.c.a.b),e.e=new $t(Jr,Jr),e.a=new $t(Ts,Ts),a=new j(t);a.atm)&&m<10);xpe(e.c,new bk),IKe(e),LAt(e.c),xGt(e.f)}function IKe(e){var t,i,a,l,f,g,m;for(t=0,f=new j(e.b.a);f.a=2){for(v=Nn(i,0),g=h(Un(v),9),m=h(Un(v),9);m.a0&&(m=w.Math.max(m,D$e(e.A.b+a.d.b,l))),C=a,R=l,B=f;e.A&&e.A.c>0&&(N=B+e.A.c,E&&(N+=C.d.c),m=w.Math.max(m,(xh(),Ng(gd),w.Math.abs(R-1)<=gd||R==1||isNaN(R)&&isNaN(1)?0:N/(1-R)))),i.n.b=0,i.a.a=m}function BKe(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W;if(i=h(Ds(e.b,t),114),y=h(h(er(e.r,t),19),60),y.Wb()){i.n.d=0,i.n.a=0;return}for(g=e.v.pc((Hl(),C1)),W=e.w.pc((cc(),b3)),E=e.t==(eh(),hb),m=0,v=y.tc(),C=null,B=0,R=0;v.hc();)a=h(v.ic(),111),f=ce(Xe(a.b.xe((t9(),Tj)))),l=a.b.Re().b,g&&T7(e,t,0,E,!E&&W),C?(N=R+C.d.a+e.u+a.d.d,m=w.Math.max(m,(xh(),Ng(gd),w.Math.abs(B-f)<=gd||B==f||isNaN(B)&&isNaN(f)?0:N/(f-B)))):e.A&&e.A.d>0&&(m=w.Math.max(m,D$e(e.A.d+a.d.d,f))),C=a,B=f,R=l;e.A&&e.A.a>0&&(N=R+e.A.a,E&&(N+=C.d.a),m=w.Math.max(m,(xh(),Ng(gd),w.Math.abs(B-1)<=gd||B==1||isNaN(B)&&isNaN(1)?0:N/(1-B)))),i.n.d=0,i.a.b=m}function DGt(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue;return R=e.c[t],B=e.c[i],N=h(G(R,(Ie(),e3)),15),!!N&&N._b()!=0&&N.pc(B)||(W=R.j!=(Xt(),Nr)&&B.j!=Nr,V=h(G(R,pM),8),ee=h(G(B,pM),8),ie=V!=ee,fe=!!V&&V!=R||!!ee&&ee!=B,we=_te(R,(Fe(),bn)),Ce=_te(B,ni),fe=fe|(_te(R,ni)||_te(B,bn)),Ue=fe&&ie||we||Ce,W&&Ue)||R.j==(Xt(),oa)&&B.j==hs||B.j==(Xt(),oa)&&R.j==hs?!1:(E=e.c[t],f=e.c[i],l=KHe(e.e,E,f,(Fe(),nn)),v=KHe(e.i,E,f,Zt),h9t(e.f,E,f),y=IVe(e.b,E,f)+h(l.a,21).a+h(v.a,21).a+e.f.d,m=IVe(e.b,f,E)+h(l.b,21).a+h(v.b,21).a+e.f.b,e.a&&(C=h(G(E,Jn),11),g=h(G(f,Jn),11),a=zHe(e.g,C,g),y+=h(a.a,21).a,m+=h(a.b,21).a),y>m)}function OKe(e,t,i){var a,l,f,g,m,v,y,E,C;if(e.a!=t.Pi())throw Y(new un(eM+t.be()+X0));if(a=jp((qc(),Zs),t).kk(),a)return a.Pi().dh().Zg(a,i);if(g=jp(Zs,t).mk(),g){if(i==null)return null;if(m=h(i,15),m.Wb())return"";for(C=new Tp,f=m.tc();f.hc();)l=f.ic(),ho(C,g.Pi().dh().Zg(g,l)),C.a+=" ";return E8(C,C.a.length-1)}if(E=jp(Zs,t).nk(),!E.Wb()){for(y=E.tc();y.hc();)if(v=h(y.ic(),140),v.Li(i))try{if(C=v.Pi().dh().Zg(v,i),C!=null)return C}catch(R){if(R=pr(R),!re(R,104))throw Y(R)}throw Y(new un("Invalid value: '"+i+"' for datatype :"+t.be()))}return h(t,737).Ui(),i==null?null:re(i,159)?""+h(i,159).a:sl(i)==zz?sFe(RL[0],h(i,181)):Ga(i)}function BGt(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V;for(ii(i,xQe,1),ert=ce(mt(G(t,($e(),tL)))),e.c=t,N=new ke,m=new j(t.b);m.aV){for(W=1,l=y.n.a;l>v;)++W,l=(y.n.a-(W-1)*e.d)/W;De(a,new o7e(e,y,W))}for(E=new j(a);E.ay?0:y),1),g),e.c[a.a.d])),Ju(zu(Uu(Gu(Fu(new iu,0>-y?0:-y),1),g),e.c[m.a.d]))):(R=1,(re(a.g,153)&&re(m.g,8)||re(m.g,153)&&re(a.g,8))&&(R=2),Ju(zu(Uu(Gu(Fu(new iu,yr(f)),R),e.c[a.a.d]),e.c[m.a.d]))))}function NGt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W;for(i=h(G(e,($e(),Ki)),83),g=e.e,f=e.d,m=g.a+f.b+f.c,v=0-f.d-e.c.b,E=g.b+f.d+f.a-e.c.b,y=new ke,C=new ke,l=new j(t);l.a0),h(E.a.cd(E.c=--E.b),14));f!=a&&E.b>0;)e.a[f.o]=!0,e.a[a.o]=!0,f=(Rn(E.b>0),h(E.a.cd(E.c=--E.b),14));E.b>0&&xf(E)}}function UGt(e){e.q||(e.q=!0,e.p=ra(e,0),e.a=ra(e,1),Ji(e.a,0),e.f=ra(e,2),Ji(e.f,1),xr(e.f,2),e.n=ra(e,3),xr(e.n,3),xr(e.n,4),xr(e.n,5),xr(e.n,6),e.g=ra(e,4),Ji(e.g,7),xr(e.g,8),e.c=ra(e,5),Ji(e.c,7),Ji(e.c,8),e.i=ra(e,6),Ji(e.i,9),Ji(e.i,10),Ji(e.i,11),Ji(e.i,12),xr(e.i,13),e.j=ra(e,7),Ji(e.j,9),e.d=ra(e,8),Ji(e.d,3),Ji(e.d,4),Ji(e.d,5),Ji(e.d,6),xr(e.d,7),xr(e.d,8),xr(e.d,9),xr(e.d,10),e.b=ra(e,9),xr(e.b,0),xr(e.b,1),e.e=ra(e,10),xr(e.e,1),xr(e.e,2),xr(e.e,3),xr(e.e,4),Ji(e.e,5),Ji(e.e,6),Ji(e.e,7),Ji(e.e,8),Ji(e.e,9),Ji(e.e,10),xr(e.e,11),e.k=ra(e,11),xr(e.k,0),xr(e.k,1),e.o=hi(e,12),e.s=hi(e,13))}function zGt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee;for(ii(t,"Interactive crossing minimization",1),g=0,f=new j(e.b);f.a0&&(i+=v.k.a+v.n.a/2,++C),N=new j(v.i);N.a=m&&l<=v)m<=l&&f<=v?a+=2:m<=l?(e.b[a]=v+1,g+=2):f<=v?(i[y++]=l,i[y++]=m-1,a+=2):(i[y++]=l,i[y++]=m-1,e.b[a]=v+1,g+=2);else if(v0),g.a.cd(g.c=--g.b),td(g,a),QE(y,a),w7(a,v.i),lS(y),lS(y),l.a.$b(a)!=null}}function $Gt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V;for(ii(t,"Spline SelfLoop pre-processing.",1),y=new Gc,C=new j(e.a);C.a0?l-=864e5:l+=864e5,v=new Wge(no(Wc(t.q.getTime()),l))),E=new tw,y=e.a.length,f=0;f=97&&a<=122||a>=65&&a<=90){for(g=f+1;g=y)throw Y(new un("Missing trailing '"));g+1=14&&y<=16))?t.a.Qb(a)?(i.a?Mi(i.a,i.b):i.a=new ou(i.d),Z2(i.a,"[...]")):(g=__(a),v=new hI(t),Xm(i,FKe(g,v))):re(a,221)?Xm(i,CNt(h(a,221))):re(a,173)?Xm(i,xNt(h(a,173))):re(a,176)?Xm(i,DOt(h(a,176))):re(a,1697)?Xm(i,TNt(h(a,1697))):re(a,37)?Xm(i,MNt(h(a,37))):re(a,378)?Xm(i,DNt(h(a,378))):re(a,736)?Xm(i,SNt(h(a,736))):re(a,106)&&Xm(i,ENt(h(a,106))):Xm(i,a==null?Xc:Ga(a));return i.a?i.e.length==0?i.a.a:i.a.a+(""+i.e):i.c}function HGt(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W;if(ce(mt(G(i,($e(),by)))))for(m=new j(i.i);m.a1))););(m>0||R==(eh(),hb)&&(!f.n&&(f.n=new ze(ea,f,1,7)),f.n).i>0)&&(v=!0),m>1&&(y=!0)}v&&t.nc((xo(),Su)),y&&t.nc((xo(),KP))}function UKe(e,t,i){var a,l,f;return l=new L_e(e),t9t(l,i),gZe(l,!1),cd(l.e.We(),new hge(l,!1)),yQ(l,l.f,(Ef(),aa),(Fe(),bn)),yQ(l,l.f,ca,ni),yQ(l,l.g,aa,nn),yQ(l,l.g,ca,Zt),gWe(l,bn),gWe(l,ni),J9e(l,Zt),J9e(l,nn),Gm(),a=l.v.pc((Hl(),pb))&&l.w.pc((cc(),PL))?iwe(l):null,a&&REt(l.a,a),oUt(l),FDt(l),UDt(l),XGt(l),BUt(l),lBt(l),lte(l,bn),lte(l,ni),IUt(l),wzt(l),t&&(q6t(l),uBt(l),lte(l,Zt),lte(l,nn),f=l.w.pc((cc(),LL)),dXe(l,f,bn),dXe(l,f,ni),pXe(l,f,Zt),pXe(l,f,nn),Fa(new oi(null,new di(new bh(l.i),0)),new Wq),Fa(go(new oi(null,b1e(l.r).wc()),new gN),new mN),fOt(l),l.e.Ue(l.o),Fa(new oi(null,b1e(l.r).wc()),new pE)),l.o}function KGt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N;for(ii(t,"Spline SelfLoop positioning",1),E=h(G(e,($e(),kMe)),345),y=new j(e.b);y.a2?(E=new ke,Lr(E,new Rg(ee,1,ee.b)),f=pJe(E,fe+e.a),ie=new Zte(f),No(ie,t),i.c[i.c.length]=ie):a?ie=h(Ii(e.b,s1(t)),247):ie=h(Ii(e.b,U0(t)),247),v=s1(t),a&&(v=U0(t)),g=VOt(V,v),y=fe+e.a,g.a?(y+=w.Math.abs(V.b-C.b),W=new $t(C.a,(C.b+V.b)/2)):(y+=w.Math.abs(V.a-C.a),W=new $t((C.a+V.a)/2,C.b)),a?dr(e.d,t,new _we(ie,g,W,y)):dr(e.c,t,new _we(ie,g,W,y)),dr(e.b,t,ie),N=(!t.n&&(t.n=new ze(ea,t,1,7)),t.n),B=new Bn(N);B.e!=B.i._b();)R=h(Yn(B),137),l=C6(e,R,!0,0,0),i.c[i.c.length]=l}function QGt(){ci(Ly,new cX),ci(Ri,new IN),ci(Lu,new NN),ci(lh,new UN),ci(Rae,new gX),ci(Oj,new zN),ci(eg,new GN),ci(kL,new Xh),ci(mD,new $k),ci(Tae,new PN),ci(Qw,new Vk),ci(uf,new sX),ci(ch,new Wk),ci(nv,new ro),ci(iv,new oX),ci(Sc,new aX),ci(tv,new vE),ci(Aa,new LN),ci(ko,new lX),ci(fl,new xp),ci(lo,new uX),ci(q(Mc,1),new QT),ci(qx,new Hk),ci($P,new kN),ci(zz,new RN),ci(dPe,new Ld),ci(Eo,new Xb),ci(AAe,new qk),ci(kAe,new eC),ci(ePe,new DN),ci(Nj,new Xk),ci(aM,new BN),ci(Po,new Yk),ci(Kxe,new Zk),ci(K0,new Yb),ci(Jxe,new fX),ci(ZAe,new Zb),ci(pPe,new ON),ci(J0,new Kk),ci(Se,new hX),ci(LAe,new dX),ci(gPe,new pX)}function ejt(e){var t,i,a,l,f,g,m,v;for(t=null,a=new j(e);a.a0&&i.c==0&&(!t&&(t=new ke),t.c[t.c.length]=i);if(t)for(;t.c.length!=0;){if(i=h(P0(t,0),205),i.b&&i.b.c.length>0){for(f=(!i.b&&(i.b=new ke),new j(i.b));f.aQo(e,i,0))return new Is(l,i)}else if(ce(qf(l.g,l.d[0]).a)>ce(qf(i.g,i.d[0]).a))return new Is(l,i)}for(m=(!i.e&&(i.e=new ke),i.e).tc();m.hc();)g=h(m.ic(),205),v=(!g.b&&(g.b=new ke),g.b),g_(0,v.c.length),UR(v.c,0,i),g.c==v.c.length&&(t.c[t.c.length]=g)}return null}function tjt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W;for(ii(t,"Label dummy insertions",1),C=new ke,g=ce(Xe(G(e,($e(),N5)))),y=ce(Xe(G(e,c3))),E=h(G(e,nf),110),B=new j(e.a);B.a>16==-10?i=h(e.Cb,268).zj(t,i):e.Db>>16==-15&&(!t&&(t=(yt(),zh)),!y&&(y=(yt(),zh)),e.Cb.Hg()&&(v=new Wd(e.Cb,1,13,y,t,$p(Vc(h(e.Cb,53)),e),!1),i?i.Sh(v):i=v));else if(re(e.Cb,96))e.Db>>16==-23&&(re(t,96)||(t=(yt(),ff)),re(y,96)||(y=(yt(),ff)),e.Cb.Hg()&&(v=new Wd(e.Cb,1,10,y,t,$p(Ea(h(e.Cb,24)),e),!1),i?i.Sh(v):i=v));else if(re(e.Cb,411))for(m=h(e.Cb,742),g=(!m.b&&(m.b=new bC(new lK)),m.b),f=(a=new Zm(new Ep(g.a).a),new wC(a));f.a.b;)l=h(L0(f.a).kc(),84),i=GS(l,x7(l,m),i)}return i}function ijt(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V;for(ii(i,"Depth-first cycle removal",1),E=t.a,W=E.c.length,e.a=le(In,si,22,W,15,1),WDe(e.a),e.b=le(In,si,22,W,15,1),WDe(e.b),g=0,y=new j(E);y.a=0){for(v=null,m=new Ns(E.a,y+1);m.b=y.c.c.length?E=r0e((Xt(),hs),Nr):E=r0e((Xt(),Nr),Nr),E*=2,f=i.a.g,i.a.g=w.Math.max(f,f+(E-f)),g=i.b.g,i.b.g=w.Math.max(g,g+(E-g)),l=t}}function WKe(e,t){var i,a,l,f,g,m,v,y,E;for(g=h(h(er(e.r,t),19),60),E=g._b()==2||g._b()>2&&e.w.pc((cc(),b3)),f=g.tc();f.hc();)if(l=h(f.ic(),111),!(!l.c||l.c.d.c.length<=0)){switch(y=l.b.Re(),m=l.c,v=m.i,v.b=(a=m.n,m.e.a+a.b+a.c),v.a=(i=m.n,m.e.b+i.d+i.a),t.g){case 1:E?(v.c=-v.b-e.s,Mh(m,(rl(),cf))):(v.c=y.a+e.s,Mh(m,(rl(),Uh))),v.d=-v.a-e.s,Ud(m,(Nc(),lf));break;case 3:E?(v.c=-v.b-e.s,Mh(m,(rl(),cf))):(v.c=y.a+e.s,Mh(m,(rl(),Uh))),v.d=y.b+e.s,Ud(m,(Nc(),Df));break;case 2:v.c=y.a+e.s,E?(v.d=-v.a-e.s,Ud(m,(Nc(),lf))):(v.d=y.b+e.s,Ud(m,(Nc(),Df))),Mh(m,(rl(),Uh));break;case 4:v.c=-v.b-e.s,E?(v.d=-v.a-e.s,Ud(m,(Nc(),lf))):(v.d=y.b+e.s,Ud(m,(Nc(),Df))),Mh(m,(rl(),cf))}E=!1}}function N7(e,t){var i;if(e.e)throw Y(new ba((Fd(ise),mie+ise.k+bie)));if(!tSt(e.a,t))throw Y(new na(XJe+t+YJe));if(t==e.d)return e;switch(i=e.d,e.d=t,i.g){case 0:switch(t.g){case 2:F0(e);break;case 1:$g(e),F0(e);break;case 4:I_(e),F0(e);break;case 3:I_(e),$g(e),F0(e)}break;case 2:switch(t.g){case 1:$g(e),cne(e);break;case 4:I_(e),F0(e);break;case 3:I_(e),$g(e),F0(e)}break;case 1:switch(t.g){case 2:$g(e),cne(e);break;case 4:$g(e),I_(e),F0(e);break;case 3:$g(e),I_(e),$g(e),F0(e)}break;case 4:switch(t.g){case 2:I_(e),F0(e);break;case 1:I_(e),$g(e),F0(e);break;case 3:$g(e),cne(e)}break;case 3:switch(t.g){case 2:$g(e),I_(e),F0(e);break;case 1:$g(e),I_(e),$g(e),F0(e);break;case 4:$g(e),cne(e)}}return e}function W_(e,t){var i;if(e.d)throw Y(new ba((Fd(yse),mie+yse.k+bie)));if(!eSt(e.a,t))throw Y(new na(XJe+t+YJe));if(t==e.c)return e;switch(i=e.c,e.c=t,i.g){case 0:switch(t.g){case 2:Km(e);break;case 1:Vg(e),Km(e);break;case 4:D_(e),Km(e);break;case 3:D_(e),Vg(e),Km(e)}break;case 2:switch(t.g){case 1:Vg(e),lne(e);break;case 4:D_(e),Km(e);break;case 3:D_(e),Vg(e),Km(e)}break;case 1:switch(t.g){case 2:Vg(e),lne(e);break;case 4:Vg(e),D_(e),Km(e);break;case 3:Vg(e),D_(e),Vg(e),Km(e)}break;case 4:switch(t.g){case 2:D_(e),Km(e);break;case 1:D_(e),Vg(e),Km(e);break;case 3:Vg(e),lne(e)}break;case 3:switch(t.g){case 2:Vg(e),D_(e),Km(e);break;case 1:Vg(e),D_(e),Vg(e),Km(e);break;case 4:Vg(e),lne(e)}}return e}function HKe(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee;for(l=new ke,N=new j(t.a);N.aee?v:ee,fe=new j(E.i);fe.a=y&&Ce>=V&&(R+=N.k.b+W.k.b+W.a.b-we,++m));if(i)for(g=new j(ie.d);g.a=y&&Ce>=V&&(R+=N.k.b+W.k.b+W.a.b-we,++m))}m>0&&(Ue+=R/m,++B)}B>0?(t.a=l*Ue/B,t.i=B):(t.a=0,t.i=0)}function pjt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe;for(e.e=t,m=qFt(t),Ue=new ke,a=new j(m);a.a0&&(C.d+=y.n.d,C.d+=y.d),C.a>0&&(C.a+=y.n.a,C.a+=y.d),C.b>0&&(C.b+=y.n.b,C.b+=y.d),C.c>0&&(C.c+=y.n.c,C.c+=y.d),C}function _jt(e,t,i){var a;if(ii(i,"StretchWidth layering",1),t.a.c.length==0){On(i);return}for(e.c=t,e.t=0,e.u=0,e.i=Jr,e.g=Ts,e.d=ce(Xe(G(t,($e(),sh)))),hDt(e),AFt(e),jOt(e),OBt(e),c5t(e),e.i=w.Math.max(1,e.i),e.g=w.Math.max(1,e.g),e.d=e.d/e.i,e.f=e.g/e.i,e.s=S6t(e),a=new lu(e.c),De(e.c.b,a),e.r=od(e.p),e.n=$9(e.k,e.k.length);e.r.c.length!=0;)e.o=$It(e),!e.o||yVe(e)&&e.b.a._b()!=0?(CDt(e,a),a=new lu(e.c),De(e.c.b,a),wo(e.a,e.b),e.b.a.Pb(),e.t=e.u,e.u=0):yVe(e)?(e.c.b.c=le(on,et,1,0,5,1),a=new lu(e.c),De(e.c.b,a),e.t=0,e.u=0,e.b.a.Pb(),e.a.a.Pb(),++e.f,e.r=od(e.p),e.n=$9(e.k,e.k.length)):(Hs(e.o,a),Sa(e.r,e.o),Cr(e.b,e.o),e.t=e.t-e.k[e.o.o]*e.d+e.j[e.o.o],e.u+=e.e[e.o.o]*e.d);t.a.c=le(on,et,1,0,5,1),iP(t.b),On(i)}function XKe(e){var t,i,a,l,f,g,m,v,y,E,C,R,B,N,W,V;for(N=new j(e);N.a0&&(e.a[t.c.o][t.o].d+=al(e.f,24)*W6*.07000000029802322-.03500000014901161,e.a[t.c.o][t.o].a=e.a[t.c.o][t.o].d/e.a[t.c.o][t.o].b)}}function yjt(e,t,i,a,l){var f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et,kn;Mt=Ii(e.e,a),Mt==null&&(Mt=new SC,B=h(Mt,191),ie=t+"_s",fe=ie+l,R=new rx(fe),Og(B,Rh,R)),ft=h(Mt,191),ox(i,ft),kn=new SC,$m(kn,"x",a.j),$m(kn,"y",a.k),Og(ft,jet,kn),qe=new SC,$m(qe,"x",a.b),$m(qe,"y",a.c),Og(ft,"endPoint",qe),C=x8((!a.a&&(a.a=new vs(ah,a,5)),a.a)),N=!C,N&&(Ue=new Om,f=new OZ(Ue),mo((!a.a&&(a.a=new vs(ah,a,5)),a.a),f),Og(ft,Sre,Ue)),v=gte(a),we=!!v,we&&Qwe(e.a,ft,xxe,zte(e,gte(a))),ee=mte(a),Ce=!!ee,Ce&&Qwe(e.a,ft,yxe,zte(e,mte(a))),y=(!a.e&&(a.e=new an(ts,a,10,9)),a.e).i==0,W=!y,W&&(ut=new Om,g=new oNe(e,ut),mo((!a.e&&(a.e=new an(ts,a,10,9)),a.e),g),Og(ft,Sxe,ut)),E=(!a.g&&(a.g=new an(ts,a,9,10)),a.g).i==0,V=!E,V&&(Et=new Om,m=new aNe(e,Et),mo((!a.g&&(a.g=new an(ts,a,9,10)),a.g),m),Og(ft,Exe,Et))}function F7(e){var t,i,a,l,f,g,m,v,y,E,C;if(e==null)throw Y(new vh(Xc));if(y=e,f=e.length,v=!1,f>0&&(t=e.charCodeAt(0),(t==45||t==43)&&(e=e.substr(1,e.length-1),--f,v=t==45)),f==0)throw Y(new vh(V0+y+'"'));for(;e.length>0&&e.charCodeAt(0)==48;)e=e.substr(1,e.length-1),--f;if(f>(GZe(),Fnt)[10])throw Y(new vh(V0+y+'"'));for(l=0;l0&&(C=-qNe(e.substr(0,a),10),e=e.substr(a,e.length-a),f-=a,i=!1);f>=g;){if(a=qNe(e.substr(0,g),10),e=e.substr(g,e.length-g),f-=g,i)i=!1;else{if(Ma(C,m)<0)throw Y(new vh(V0+y+'"'));C=Jm(C,E)}C=Qm(C,a)}if(Ma(C,0)>0)throw Y(new vh(V0+y+'"'));if(!v&&(C=pS(C),Ma(C,0)<0))throw Y(new vh(V0+y+'"'));return C}function xjt(e,t,i,a,l){var f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt;for(fe=0,N=0,B=0,R=1,ie=new Bn((!e.a&&(e.a=new ze(Br,e,10,11)),e.a));ie.e!=ie.i._b();)V=h(Yn(ie),35),R+=Bp(Th(V)),ut=V.g,N=w.Math.max(N,ut),C=V.f,B=w.Math.max(B,C),fe+=ut*C;for(W=(!e.a&&(e.a=new ze(Br,e,10,11)),e.a).i,g=fe+2*a*a*R*W,f=w.Math.sqrt(g),v=w.Math.max(f*i,N),m=w.Math.max(f/i,B),ee=new Bn((!e.a&&(e.a=new ze(Br,e,10,11)),e.a));ee.e!=ee.i._b();)V=h(Yn(ee),35),ft=l.b+(al(t,26)*bP+al(t,27)*wP)*(v-V.g),Mt=l.b+(al(t,26)*bP+al(t,27)*wP)*(m-V.f),Yu(V,ft),Zu(V,Mt);for(qe=v+(l.b+l.c),Ue=m+(l.d+l.a),Ce=new Bn((!e.a&&(e.a=new ze(Br,e,10,11)),e.a));Ce.e!=Ce.i._b();)for(we=h(Yn(Ce),35),E=Cn(Th(we));Gn(E);)y=h(Tn(E),105),rP(y)||F$t(y,t,qe,Ue);qe+=l.b+l.c,Ue+=l.d+l.a,H_(e,qe,Ue,!1,!0)}function Ejt(e,t,i,a){var l,f,g,m,v,y,E,C,R,B,N,W,V,ee;if(W=e.k,V=e.n,R=e.d,t){for(C=a/2*(t._b()-1),B=0,y=t.tc();y.hc();)m=h(y.ic(),8),C+=m.n.a,B=w.Math.max(B,m.n.b);for(ee=W.a-(C-V.a)/2,g=W.b-R.d+B,l=V.a/(t._b()+1),f=l,v=t.tc();v.hc();)m=h(v.ic(),8),m.k.a=ee,m.k.b=g-m.n.b,ee+=m.n.a+a/2,E=_Ye(m),E.k.a=m.n.a/2-E.a.a,E.k.b=m.n.b,N=h(G(m,(Ie(),SG)),11),N.d.c.length+N.f.c.length==1&&(N.k.a=f-N.a.a,N.k.b=0,us(N,e)),f+=l}if(i){for(C=a/2*(i._b()-1),B=0,y=i.tc();y.hc();)m=h(y.ic(),8),C+=m.n.a,B=w.Math.max(B,m.n.b);for(ee=W.a-(C-V.a)/2,g=W.b+V.b+R.a-B,l=V.a/(i._b()+1),f=l,v=i.tc();v.hc();)m=h(v.ic(),8),m.k.a=ee,m.k.b=g,ee+=m.n.a+a/2,E=_Ye(m),E.k.a=m.n.a/2-E.a.a,E.k.b=0,N=h(G(m,(Ie(),SG)),11),N.d.c.length+N.f.c.length==1&&(N.k.a=f-N.a.a,N.k.b=V.b,us(N,e)),f+=l}}function Sjt(e,t){var i,a,l,f,g,m,v,y,E,C,R;for(l=new j(e.a.b);l.aTs||t.o==M1&&E0&&Yu(ee,we*Ue),Ce>0&&Zu(ee,Ce*qe);for(vee(e.b,new So),t=new ke,m=new Zm(new Ep(e.c).a);m.b;)g=L0(m),a=h(g.kc(),105),i=h(g.lc(),363).a,l=j_(a,!1,!1),C=mqe(s1(a),m6(l),i),R6(C,l),fe=Eqe(a),fe&&Qo(t,fe,0)==-1&&(t.c[t.c.length]=fe,yUe(fe,(Rn(C.b!=0),h(C.a.a.c,9)),i));for(V=new Zm(new Ep(e.d).a);V.b;)W=L0(V),a=h(W.kc(),105),i=h(W.lc(),363).a,l=j_(a,!1,!1),C=mqe(U0(a),BA(m6(l)),i),C=BA(C),R6(C,l),fe=Sqe(a),fe&&Qo(t,fe,0)==-1&&(t.c[t.c.length]=fe,yUe(fe,(Rn(C.b!=0),h(C.c.b.c,9)),i))}function Pjt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie;for(ii(t,"Inverted port preprocessing",1),y=e.b,v=new Ns(y,0),i=null,ie=new ke;v.b0&&(h(Ds(e.b,t),114).a.b=i)}function Ljt(e,t,i,a,l){var f,g,m,v,y,E,C,R,B,N,W,V,ee;switch(R=OA(e.i),N=OA(t.i),B=tr(Ua(e.k),e.a),W=tr(Ua(t.k),t.a),v=tr(new $t(B.a,B.b),au(new d_(R),1.3*i)),V=tr(new $t(W.a,W.b),au(new d_(N),1.3*a)),m=w.Math.abs(v.a-V.a),ml+2&&yee(e.charCodeAt(l+1),IAe,DAe)&&yee(e.charCodeAt(l+2),IAe,DAe))if(i=$Ct(e.charCodeAt(l+1),e.charCodeAt(l+2)),l+=2,a>0?(i&192)==128?t[m++]=i<<24>>24:a=0:i>=128&&((i&224)==192?(t[m++]=i<<24>>24,a=2):(i&240)==224?(t[m++]=i<<24>>24,a=3):(i&248)==240&&(t[m++]=i<<24>>24,a=4)),a>0){if(m==a){switch(m){case 2:{Lg(v,((t[0]&31)<<6|t[1]&63)&jr);break}case 3:{Lg(v,((t[0]&15)<<12|(t[1]&63)<<6|t[2]&63)&jr);break}}m=0,a=0}}else{for(f=0;f0&&De(e.p,E),De(e.o,E);t-=a,B=v+t,y+=t*e.e,Hu(e.a,m,He(B)),Hu(e.b,m,y),e.j=vf(e.j,B),e.k=w.Math.max(e.k,y),e.d+=t,t+=W}}function KKe(){KKe=M;var e,t,i;for(new kI(1,0),new kI(10,0),new kI(0,0),Unt=le(Qre,be,216,11,0,1),_1=le(Zl,Ph,22,100,15,1),_3e=X(q(ks,1),Wo,22,15,[1,5,25,125,625,3125,15625,78125,390625,1953125,9765625,48828125,244140625,1220703125,6103515625,30517578125,152587890625,762939453125,3814697265625,19073486328125,95367431640625,476837158203125,0x878678326eac9]),y3e=le(In,si,22,_3e.length,15,1),x3e=X(q(ks,1),Wo,22,15,[1,10,100,Pw,V6,uie,1e6,1e7,1e8,W7,1e10,1e11,1e12,1e13,1e14,1e15,1e16]),E3e=le(In,si,22,x3e.length,15,1),S3e=le(Qre,be,216,11,0,1),e=0;e1)for(B=new y_e(N,fe,a),mo(fe,new KOe(e,B)),g.c[g.c.length]=B,C=fe.a.Xb().tc();C.hc();)E=h(C.ic(),48),Sa(f,E.b);if(m.a._b()>1)for(B=new y_e(N,m,a),mo(m,new JOe(e,B)),g.c[g.c.length]=B,C=m.a.Xb().tc();C.hc();)E=h(C.ic(),48),Sa(f,E.b)}}function Ijt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N;for(ii(t,"Label dummy switching",1),C=h(G(e,($e(),DG)),276),a=h(sd(go(Qf(new oi(null,new di(e.b,16)),new GO),new jO),zA(new pn,new Vt,new wr,X(q(ih,1),Oe,150,0,[(Wg(),nh)]))),15),g=C==(JA(),zse)||C==Nse?kDt(e):null,f=a.tc();f.hc();){switch(l=h(f.ic(),8),i=rDt(l),!i&&(i=C),m=TDt(l),E=K5t(l),R=null,i.g){case 2:R=cNt(l,g,m,E);break;case 0:R=(B=m.a._b()+E.c.length+1,N=(B-1)/2|0,Nm.a._b()?h(St(E,N-m.a._b()-1),8):null);break;case 1:R=SFt(l,g,m,E);break;case 4:yWe(l,i),R=(y=Zbe(l),y?m.a._b()==0?null:h(m.a.cd(uA(m,0)),8):E.c.length==0?null:h(St(E,E.c.length-1),8));break;case 3:yWe(l,i),R=(v=Zbe(l),v?E.c.length==0?null:h(St(E,E.c.length-1),8):m.a._b()==0?null:h(m.a.cd(uA(m,0)),8))}R&&rGt(l,R),R5t(l)}On(t)}function D_e(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe;if(R=t.length,R>0&&(v=t.charCodeAt(0),v!=64)){if(v==37&&(C=t.lastIndexOf("%"),y=!1,C!=0&&(C==R-1||(y=t.charCodeAt(C+1)==46)))){if(g=t.substr(1,C-1),fe=dt("%",g)?null:I_e(g),a=0,y)try{a=Sl(t.substr(C+2,t.length-(C+2)),zs,zi)}catch(we){throw we=pr(we),re(we,118)?(m=we,Y(new hU(m))):Y(we)}for(V=sbe(e.pg());V.hc();)if(N=MU(V),re(N,469)&&(l=h(N,609),ie=l.d,(fe==null?ie==null:dt(fe,ie))&&a--==0))return l;return null}if(E=t.lastIndexOf("."),B=E==-1?t:t.substr(0,E),i=0,E!=-1)try{i=Sl(t.substr(E+1,t.length-(E+1)),zs,zi)}catch(we){if(we=pr(we),re(we,118))B=t;else throw Y(we)}for(B=dt("%",B)?null:I_e(B),W=sbe(e.pg());W.hc();)if(N=MU(W),re(N,174)&&(f=h(N,174),ee=f.be(),(B==null?ee==null:dt(B,ee))&&i--==0))return f;return null}return wKe(e,t)}function Djt(e){w_e();var t,i,a,l,f,g,m,v,y,E,C,R,B,N,W,V;if(e==null)return null;if(C=e.length*8,C==0)return"";for(m=C%24,B=C/24|0,R=m!=0?B+1:B,f=le(Zl,Ph,22,R*4,15,1),g=0,l=0,v=0;v>24,y=(t&3)<<24>>24,N=t&-128?(t>>2^192)<<24>>24:t>>2<<24>>24,W=i&-128?(i>>4^240)<<24>>24:i>>4<<24>>24,V=a&-128?(a>>6^252)<<24>>24:a>>6<<24>>24,f[g++]=tg[N],f[g++]=tg[W|y<<4],f[g++]=tg[E<<2|V],f[g++]=tg[a&63];return m==8?(t=e[l],y=(t&3)<<24>>24,N=t&-128?(t>>2^192)<<24>>24:t>>2<<24>>24,f[g++]=tg[N],f[g++]=tg[y<<4],f[g++]=61,f[g++]=61):m==16&&(t=e[l],i=e[l+1],E=(i&15)<<24>>24,y=(t&3)<<24>>24,N=t&-128?(t>>2^192)<<24>>24:t>>2<<24>>24,W=i&-128?(i>>4^240)<<24>>24:i>>4<<24>>24,f[g++]=tg[N],f[g++]=tg[W|y<<4],f[g++]=tg[E<<2],f[g++]=61),hu(f,0,f.length)}function Bjt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt;for(Ue=t.a.c,y=t.a.c+t.a.b,fe=e.c&&WFt(e,t),a=fe?(Ue+y)/2:Ue+(t.s+1)*e.b,m=t.d.a.Xb().tc();m.hc();)if(g=h(m.ic(),14),v=h(Ii(t.c,g),589),ft=v.f,Mt=v.a,Ce=new $t(a,ft),ut=new $t(a,Mt),we=new $t(Ue-10,ft),qe=new $t(y,Mt),C=!1,R=!1,v.b&&(C=!0,we.a=y),v.c&&(R=!0,qe.a=Ue-10),B=v.d,N=v.e,!fe||!(B||N)||R||C)t.d.a._b()==1?pU(g.a,X(q(es,1),be,9,0,[we,Ce,ut,qe])):(i=new $t(a,t.b),pU(g.a,X(q(es,1),be,9,0,[we,Ce,i,ut,qe])));else if(B&&N){for(E=0,W=0,ie=new j(g.d.g.i);ie.a=0&&gB&&(f&&(zm(we,R),zm(Ue,He(y.a-1))),Et=i.b,kn+=R+t,R=0,E=w.Math.max(E,i.b+i.c+Mt)),Yu(m,Et),Zu(m,kn),E=w.Math.max(E,Et+Mt+i.c),R=w.Math.max(R,C),Et+=Mt+t;if(E=w.Math.max(E,a),ft=kn+R+i.a,ft0&&(e.p=-(e.p-1)),e.p>zs&&s0e(t,e.p-$0),g=t.q.getDate(),_I(t,1),e.k>=0&&aLt(t,e.k),e.c>=0?_I(t,e.c):e.k>=0?(v=new bbe(t.q.getFullYear()-$0,t.q.getMonth(),35),a=35-v.q.getDate(),_I(t,a0&&e.f<12&&(e.f+=12),aMt(t,e.f==24&&e.g?0:e.f),e.j>=0&&Q4t(t,e.j),e.n>=0&&fkt(t,e.n),e.i>=0&&hOe(t,no(Jm(h6(Wc(t.q.getTime()),Pw),Pw),e.i)),e.a&&(l=new T8,s0e(l,l.q.getFullYear()-$0-80),_K(Wc(t.q.getTime()),Wc(l.q.getTime()))&&s0e(t,l.q.getFullYear()-$0+100)),e.d>=0){if(e.c==-1)i=(7+e.d-t.q.getDay())%7,i>3&&(i-=7),m=t.q.getMonth(),_I(t,t.q.getDate()+i),t.q.getMonth()!=m&&_I(t,t.q.getDate()+(i>0?-7:7));else if(t.q.getDay()!=e.d)return!1}return e.o>zs&&(f=t.q.getTimezoneOffset(),hOe(t,no(Wc(t.q.getTime()),(e.o-f)*60*Pw))),!0}function JKe(){JKe=M,fs=new Kv,ir(fs,(Fe(),aD),xd),ir(fs,rD,_d),ir(fs,sD,yd),ir(fs,oD,Fh),ir(fs,T1,db),ir(fs,T1,yd),ir(fs,T1,Fh),ir(fs,db,T1),ir(fs,db,xd),ir(fs,db,_d),ir(fs,m3,m3),ir(fs,m3,yd),ir(fs,m3,xd),ir(fs,Ay,Ay),ir(fs,Ay,yd),ir(fs,Ay,_d),ir(fs,Py,Py),ir(fs,Py,Fh),ir(fs,Py,xd),ir(fs,Cy,Cy),ir(fs,Cy,Fh),ir(fs,Cy,_d),ir(fs,yd,sD),ir(fs,yd,T1),ir(fs,yd,m3),ir(fs,yd,Ay),ir(fs,yd,yd),ir(fs,yd,xd),ir(fs,yd,_d),ir(fs,Fh,oD),ir(fs,Fh,T1),ir(fs,Fh,Py),ir(fs,Fh,Cy),ir(fs,Fh,Fh),ir(fs,Fh,xd),ir(fs,Fh,_d),ir(fs,xd,aD),ir(fs,xd,db),ir(fs,xd,m3),ir(fs,xd,Py),ir(fs,xd,yd),ir(fs,xd,Fh),ir(fs,xd,xd),ir(fs,_d,rD),ir(fs,_d,db),ir(fs,_d,Ay),ir(fs,_d,Cy),ir(fs,_d,yd),ir(fs,_d,Fh),ir(fs,_d,_d)}function Fjt(){ci(yD,new qN),ci(zj,new r0),ci(xD,new oC),ci(tPe,new CX),ci(Se,new PX),ci(q(Mc,1),new LX),ci(lo,new kX),ci(qx,new o0),ci(Se,new jN),ci(Se,new $N),ci(Se,new wX),ci(Eo,new VN),ci(Se,new R2),ci(yu,new _E),ci(yu,new vX),ci(Se,new WN),ci(aM,new HN),ci(Se,new nC),ci(Se,new iC),ci(Se,new Jk),ci(Se,new rC),ci(Se,new _X),ci(q(Mc,1),new XN),ci(Se,new sC),ci(Se,new YN),ci(yu,new Qk),ci(yu,new yX),ci(Se,new ZN),ci(Po,new KN),ci(Se,new JN),ci(K0,new xX),ci(Se,new QN),ci(Se,new EX),ci(Se,new SX),ci(Se,new s0),ci(yu,new eR),ci(yu,new tR),ci(Se,new nR),ci(Se,new I2),ci(Se,new ns),ci(Se,new aC),ci(Se,new iR),ci(Se,new Uv),ci(J0,new MX),ci(Se,new rR),ci(Se,new eF),ci(Se,new $f),ci(J0,new TX),ci(K0,new tF),ci(Se,new AX),ci(Po,new nF)}function Ujt(e,t){var i,a,l,f,g,m,v,y,E,C,R,B;for(a=h(G(e,(Ie(),Jn)),35),Yu(a,e.k.a+t.a),Zu(a,e.k.b+t.b),(h(rn(a,($e(),jw)),185)._b()!=0||G(e,md)!=null||Be(G(va(e),FG))===Be((XA(),z5))&&zNe((_w(),(e.p?e.p:(_t(),_t(),ep)).Qb(ib)?C=h(G(e,ib),179):C=h(G(va(e),sL),179),C)))&&(x_(a,e.n.a),y_(a,e.n.b)),E=new j(e.i);E.a1;)t=w.Math.min(f,e.c),y=(C=new th(e.e.c),Ou(C,(Xt(),$a)),Ee(C,($e(),Ki),h(G(y,Ki),83)),Ee(C,Rf,h(G(y,Rf),185)),C.o=e.e.b++,De(e.b,C),C.n.b=y.n.b,C.n.a=t,R=new yo,mr(R,(Fe(),Zt)),us(R,y),R.k.a=C.n.a,R.k.b=C.n.b/2,B=new yo,mr(B,nn),us(B,C),B.k.b=C.n.b/2,B.k.a=-B.n.a,N=new Op,Os(N,R),_s(N,B),C),De(e.e.c.a,y),--E,f-=e.c+e.e.d;for(new zwe(e.d,e.b,e.c),m=new j(l);m.a=t.length)return{done:!0};var l=t[a++];return{value:[l,i.get(l)],done:!1}}}},pUt()||(e.prototype.createObject=function(){return{}},e.prototype.get=function(t){return this.obj[":"+t]},e.prototype.set=function(t,i){this.obj[":"+t]=i},e.prototype[hie]=function(t){delete this.obj[":"+t]},e.prototype.keys=function(){var t=[];for(var i in this.obj)i.charCodeAt(0)==58&&t.push(i.substring(1));return t}),e}function jjt(e,t){var i,a,l,f,g,m,v,y,E;if(Bp(As(t))!=1||h(X9(As(t)),14).c.g.j!=(Xt(),Nr))return null;for(i=h(X9(As(t)),14),a=i.c.g,Ou(a,(Xt(),hs)),Ee(a,(Ie(),Cl),null),Ee(a,Al,null),Ee(a,P5,h(G(t,P5),126)),Ee(a,Fw,(vt(),vt(),!0)),Ee(a,Jn,G(t,Jn)),a.n.b=t.n.b,f=G(i.d,Jn),g=null,y=Hc(a,(Fe(),nn)).tc();y.hc();)if(m=h(y.ic(),11),m.d.c.length!=0){Ee(m,Jn,f),E=i.d,m.n.a=E.n.a,m.n.b=E.n.b,m.a.a=E.a.a,m.a.b=E.a.b,Lr(m.e,E.e),E.e.c=le(on,et,1,0,5,1),g=m;break}if(Ee(i.d,Jn,null),Bp(Hc(t,nn))>1)for(v=Nn(cu(Hc(t,nn)),0);v.b!=v.d.c;)m=h(Un(v),11),m.d.c.length==0?(l=new yo,mr(l,nn),l.n.a=m.n.a,l.n.b=m.n.b,us(l,a),Ee(l,Jn,G(m,Jn)),us(m,null)):us(g,a);return Ee(t,Jn,null),Ee(t,Fw,!1),Ou(t,$a),Ee(a,($e(),Ki),h(G(t,Ki),83)),Ee(a,Rf,h(G(t,Rf),185)),v0(e.b,0,a),a}function $jt(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe;for(ii(i,"Polyline edge routing",1),B=ce(Xe(G(t,($e(),Hw)))),l=ce(Xe(G(t,a3))),a=w.Math.min(1,l/B),ie=0,t.b.c.length!=0&&(fe=ZXe(h(St(t.b,0),26)),ie=.4*a*fe),m=new Ns(t.b,0);m.b0&&(ie-=B),C_e(g,ie),E=0,R=new j(g.a);R.a0),m.a.cd(m.c=--m.b)),v=.4*a*E,!f&&m.b0||E.i==nn&&E.d.c.length-E.f.c.length<0)){i=!1;break}if(E.i==nn){for(l=new j(E.f);l.a=m){Rn(V.b>0),V.a.cd(V.c=--V.b);break}else N.a>v&&(l?(Lr(l.b,N.b),l.a=w.Math.max(l.a,N.a),xf(V)):(De(N.b,E),N.c=w.Math.min(N.c,v),N.a=w.Math.max(N.a,m),l=N));l||(l=new dDe,l.c=v,l.a=m,td(V,l),De(l.b,E))}for(g=t.b,y=0,W=new j(a);W.a0&&Ma(a,-6)>=0){if(Ma(a,0)>=0){for(l=i+nr(a),g=17;g>=l;g--)y[g+1]=y[g];return y[++l]=46,m&&(y[--i]=45),hu(y,i,18-i+1)}for(f=2;_K(f,no(pS(a),1));f++)y[--i]=48;return y[--i]=46,y[--i]=48,m&&(y[--i]=45),hu(y,i,18-i)}return R=i+1,E=new tw,m&&(E.a+="-"),18-R>=1?(Lg(E,y[i]),E.a+=".",E.a+=hu(y,i+1,18-i-1)):E.a+=hu(y,i,18-i),E.a+="E",Ma(a,0)>0&&(E.a+="+"),E.a+=""+E9(a),E.a}function iJe(e){var t,i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et,kn,yi,as;for(C=h(G(e,(Fg(),Yx)),35),ee=zi,ie=zi,W=zs,V=zs,we=new j(e.e);we.at.d.c){if(B=e.c[t.a.d],V=e.c[C.a.d],B==V)continue;Ju(zu(Uu(Gu(Fu(new iu,1),100),B),V))}}}}}function Yjt(e,t,i,a,l,f){var g,m,v,y,E,C;for(y=new yo,No(y,t),mr(y,h(rn(t,($e(),oL)),69)),Ee(y,(Ie(),Jn),t),us(y,i),C=y.n,C.a=t.g,C.b=t.f,E=y.k,E.a=t.i,E.b=t.j,dr(e.a,t,y),g=nU(Yf(Qf(new oi(null,(!t.e&&(t.e=new an(js,t,7,4)),new di(t.e,16))),new gl),new _2),new NY(t)),g||(g=nU(Yf(Qf(new oi(null,(!t.d&&(t.d=new an(js,t,8,5)),new di(t.d,16))),new Rm),new Iv),new FY(t))),g||(g=nU(new oi(null,(!t.e&&(t.e=new an(js,t,7,4)),new di(t.e,16))),new rE)),Ee(y,L5,(vt(),!!g)),tGt(y,f,l,h(rn(t,$w),9)),v=new Bn((!t.n&&(t.n=new ze(ea,t,1,7)),t.n));v.e!=v.i._b();)m=h(Yn(v),137),!ce(mt(rn(m,x1)))&&m.a&&De(y.e,$ee(m));switch((!t.d&&(t.d=new an(js,t,8,5)),t.d).i+(!t.e&&(t.e=new an(js,t,7,4)),t.e).i>1&&a.nc((xo(),KP)),l.g){case 2:case 1:(y.i==(Fe(),bn)||y.i==ni)&&a.nc((xo(),py));break;case 4:case 3:(y.i==(Fe(),Zt)||y.i==nn)&&a.nc((xo(),py))}return y}function em(e,t){vi();var i,a,l,f,g,m,v,y,E,C,R,B,N;if(OE(LM)==0){for(C=le(LVt,be,112,Tut.length,0,1),g=0;gy&&(a.a+=VNe(le(Zl,Ph,22,-y,15,1))),a.a+="Is",yh(v,wc(32))>=0)for(l=0;l0){if(g+a>e.length)return!1;m=h7(e.substr(0,g+a),t)}else m=h7(e,t);switch(f){case 71:return m=N_(e,g,X(q(Se,1),be,2,6,[RJe,IJe]),t),l.e=m,!0;case 77:return tUt(e,t,l,m,g);case 76:return nUt(e,t,l,m,g);case 69:return qNt(e,t,g,l);case 99:return XNt(e,t,g,l);case 97:return m=N_(e,g,X(q(Se,1),be,2,6,["AM","PM"]),t),l.b=m,!0;case 121:return lUt(e,t,g,m,i,l);case 100:return m<=0?!1:(l.c=m,!0);case 83:return m<0?!1:i5t(m,g,t[0],l);case 104:m==12&&(m=0);case 75:case 72:return m<0?!1:(l.f=m,l.g=!1,!0);case 107:return m<0?!1:(l.f=m,l.g=!0,!0);case 109:return m<0?!1:(l.j=m,!0);case 115:return m<0?!1:(l.n=m,!0);case 90:if(gut[v]&&(V=v),C=new j(e.b.b);C.a0?R=r6(m):R=n6(r6(m)),e.ze(oL,R)),R.g){case 4:Ee(E,tc,(du(),zw)),Ee(E,roe,(M_(),YP)),E.n.b=g.b,mr(C,(Fe(),Zt)),C.k.b=y.b;break;case 2:Ee(E,tc,(du(),nb)),Ee(E,roe,(M_(),T5)),E.n.b=g.b,mr(C,(Fe(),nn)),C.k.b=y.b;break;case 1:Ee(E,y1,(Hd(),gy)),E.n.a=g.a,mr(C,(Fe(),ni)),C.k.a=y.a;break;case 3:Ee(E,y1,(Hd(),Kx)),E.n.a=g.a,mr(C,(Fe(),bn)),C.k.a=y.a}if(t==p3||t==vd||t==Oa){if(B=0,t==p3&&e.ye(E1))switch(R.g){case 1:case 2:B=h(e.xe(E1),21).a;break;case 3:case 4:B=-h(e.xe(E1),21).a}else switch(R.g){case 4:case 2:B=f.b,t==vd&&(B/=l.b);break;case 1:case 3:B=f.a,t==vd&&(B/=l.a)}Ee(E,tb,B)}return Ee(E,pa,R),E}function t$t(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue;if(R=h(h(er(e.r,t),19),60),t==(Fe(),Zt)||t==nn){YKe(e,t);return}for(f=t==bn?(I0(),hD):(I0(),dD),we=t==bn?(Nc(),Df):(Nc(),lf),i=h(Ds(e.b,t),114),a=i.i,l=a.c+v_(X(q(ks,1),Wo,22,15,[i.n.b,e.A.b,e.k])),ee=a.c+a.b-v_(X(q(ks,1),Wo,22,15,[i.n.c,e.A.c,e.k])),g=Cpe(Dme(f),e.s),ie=t==bn?cre:Gx,C=R.tc();C.hc();)y=h(C.ic(),111),!(!y.c||y.c.d.c.length<=0)&&(V=y.b.Re(),W=y.e,B=y.c,N=B.i,N.b=(v=B.n,B.e.a+v.b+v.c),N.a=(m=B.n,B.e.b+m.d+m.a),tQ(we,fxe),B.f=we,Mh(B,(rl(),cf)),N.c=W.a-(N.b-V.a)/2,Ce=w.Math.min(l,W.a),Ue=w.Math.max(ee,W.a+V.a),N.cUe&&(N.c=Ue-N.b),De(g.d,new jJ(N,Gbe(g,N))),ie=t==bn?w.Math.max(ie,W.b+y.b.Re().b):w.Math.min(ie,W.b));for(ie+=t==bn?e.s:-e.s,fe=Qbe((g.e=ie,g)),fe>0&&(h(Ds(e.b,t),114).a.b=fe),E=R.tc();E.hc();)y=h(E.ic(),111),!(!y.c||y.c.d.c.length<=0)&&(N=y.c.i,N.c-=y.e.a,N.d-=y.e.b)}function sJe(e,t,i){var a,l,f,g,m,v,y,E,C,R;if(a=new Zf(t.Qe().a,t.Qe().b,t.Re().a,t.Re().b),l=new VE,e.c)for(g=new j(t.We());g.a=2){if((!e.a&&(e.a=new ze(ts,e,6,6)),e.a).i==0)i=(d0(),l=new mE,l),$n((!e.a&&(e.a=new ze(ts,e,6,6)),e.a),i);else if((!e.a&&(e.a=new ze(ts,e,6,6)),e.a).i>1)for(R=new QC((!e.a&&(e.a=new ze(ts,e,6,6)),e.a));R.e!=R.i._b();)KA(R);R6(t,h(ae((!e.a&&(e.a=new ze(ts,e,6,6)),e.a),0),270))}if(C)for(a=new Bn((!e.a&&(e.a=new ze(ts,e,6,6)),e.a));a.e!=a.i._b();)for(i=h(Yn(a),270),y=new Bn((!i.a&&(i.a=new vs(ah,i,5)),i.a));y.e!=y.i._b();)v=h(Yn(y),531),m.a=w.Math.max(m.a,v.a),m.b=w.Math.max(m.b,v.b);for(g=new Bn((!e.n&&(e.n=new ze(ea,e,1,7)),e.n));g.e!=g.i._b();)f=h(Yn(g),137),E=h(rn(f,SL),9),E&&Od(f,E.a,E.b),C&&(m.a=w.Math.max(m.a,f.i+f.g),m.b=w.Math.max(m.b,f.j+f.f));return m}function n$t(e,t,i){var a,l,f,g,m,v,y,E,C,R,B;if(e.e.a.Pb(),e.f.a.Pb(),e.c.c=le(on,et,1,0,5,1),e.i.c=le(on,et,1,0,5,1),e.g.a.Pb(),t)for(g=new j(t.a);g.a>4)<<24>>24,C[R++]=((i&15)<<4|a>>2&15)<<24>>24,C[R++]=(a<<6|l)<<24>>24}return!BR(g=f[E++])||!BR(m=f[E++])?null:(t=uh[g],i=uh[m],v=f[E++],y=f[E++],uh[v]==-1||uh[y]==-1?v==61&&y==61?i&15?null:(V=le(Mc,sy,22,B*3+1,15,1),vc(C,0,V,0,B*3),V[R]=(t<<2|i>>4)<<24>>24,V):v!=61&&y==61?(a=uh[v],a&3?null:(V=le(Mc,sy,22,B*3+2,15,1),vc(C,0,V,0,B*3),V[R++]=(t<<2|i>>4)<<24>>24,V[R]=((i&15)<<4|a>>2&15)<<24>>24,V)):null:(a=uh[v],l=uh[y],C[R++]=(t<<2|i>>4)<<24>>24,C[R++]=((i&15)<<4|a>>2&15)<<24>>24,C[R++]=(a<<6|l)<<24>>24,C))}function r$t(e,t,i){var a,l,f,g,m,v,y,E,C,R;for(v=new ke,C=t.length,g=vbe(i),y=0;ym&&(fe=0,we+=g+ee,g=0),c7t(W,i,fe,we),t=w.Math.max(t,fe+V.a),g=w.Math.max(g,V.b),fe+=V.a+ee;return W}function s$t(e,t,i){var a,l,f,g,m;switch(a=t.i,f=e.g.n,l=e.g.d,m=e.k,g=Fo(X(q(es,1),be,9,0,[m,e.a])),e.i.g){case 1:Ud(t,(Nc(),lf)),a.d=-l.d-i-a.a,h(h(rS(t.d).a.cd(0),271).xe((Ie(),t3)),265)==(xl(),Ed)?(Mh(t,(rl(),cf)),a.c=g.a-ce(Xe(G(e,my)))-i-a.b):(Mh(t,(rl(),Uh)),a.c=g.a+ce(Xe(G(e,my)))+i);break;case 2:Mh(t,(rl(),Uh)),a.c=f.a+l.c+i,h(h(rS(t.d).a.cd(0),271).xe((Ie(),t3)),265)==(xl(),Ed)?(Ud(t,(Nc(),lf)),a.d=g.b-ce(Xe(G(e,my)))-i-a.a):(Ud(t,(Nc(),Df)),a.d=g.b+ce(Xe(G(e,my)))+i);break;case 3:Ud(t,(Nc(),Df)),a.d=f.b+l.a+i,h(h(rS(t.d).a.cd(0),271).xe((Ie(),t3)),265)==(xl(),Ed)?(Mh(t,(rl(),cf)),a.c=g.a-ce(Xe(G(e,my)))-i-a.b):(Mh(t,(rl(),Uh)),a.c=g.a+ce(Xe(G(e,my)))+i);break;case 4:Mh(t,(rl(),cf)),a.c=-l.b-i-a.b,h(h(rS(t.d).a.cd(0),271).xe((Ie(),t3)),265)==(xl(),Ed)?(Ud(t,(Nc(),lf)),a.d=g.b-ce(Xe(G(e,my)))-i-a.a):(Ud(t,(Nc(),Df)),a.d=g.b+ce(Xe(G(e,my)))+i)}}function cJe(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N;switch(g=new b9e(e),m=od(zd(t,g)),_t(),fa(m,new KO),l=e.b,l.c){case 2:v=new Qb(l.a),i=qC(zd(m,v)),S_(i)?y=h(px(i),188).b:y=15,v=new Qb(ywe(l)),i=qC(zd(m,v)),S_(i)?f=h(px(i),188).b:f=15,v=new Qb(l.b),i=qC(zd(m,v)),S_(i)?E=h(px(i),188).b:E=15,a=Y8t(e,y,f,E),Cr(t,new cP(a,e.c,e.e,e.a.c.g,l.a)),Cr(t,new cP(a,e.c,e.e,e.a.c.g,ywe(l))),Cr(t,new cP(a,e.c,e.e,e.a.c.g,l.b));break;case 1:v=new Qb(l.a),i=qC(zd(m,v)),S_(i)?y=h(px(i),188).b:y=15,v=new Qb(l.b),i=qC(zd(m,v)),S_(i)?E=h(px(i),188).b:E=15,a=U8t(e,y,E),Cr(t,new cP(a,e.c,e.e,e.a.c.g,l.a)),Cr(t,new cP(a,e.c,e.e,e.a.c.g,l.b));break;case 0:v=new Qb(l.a),i=qC(zd(m,v)),S_(i)?y=h(px(i),188).b:y=15,a=(C=e.b,R=_7t(e.a.c,e.a.d,y),wo(e.a.a,ote(R)),B=nve(e.a.b,R.a,C),N=new EI((!R.k&&(R.k=new Wte(_ee(R))),R.k)),U1e(N),B?w1e(N,B):N),Cr(t,new cP(a,e.c,e.e,e.a.c.g,l.a));break;default:throw Y(new un("The loopside must be defined."))}return a}function o$t(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft;for(ii(t,"Compound graph postprocessor",1),i=ce(mt(G(e,($e(),_oe)))),m=h(G(e,(Ie(),YSe)),238),E=new zr,ee=m.Xb().tc();ee.hc();){for(V=h(ee.ic(),14),g=new _f(m.Mc(V)),_t(),fa(g,new BF(e)),Ce=ORt((ai(0,g.c.length),h(g.c[0],234))),qe=P$e(h(St(g,g.c.length-1),234)),fe=Ce.g,TS(qe.g,fe)?ie=h(G(fe,md),31):ie=va(fe),C=q5t(V,g),rd(V.a),R=null,f=new j(g);f.aJd,ft=w.Math.abs(R.b-N.b)>Jd,(!i&&ut&&ft||i&&(ut||ft))&&Gi(V.a,we)),wo(V.a,a),a.b==0?R=we:R=(Rn(a.b!=0),h(a.c.b.c,9)),iIt(B,C,W),P$e(l)==qe&&(va(qe.g)!=l.a&&(W=new fo,Dve(W,va(qe.g),ie)),Ee(V,foe,W)),oNt(B,V,ie),E.a.Zb(B,E);Os(V,Ce),_s(V,qe)}for(y=E.a.Xb().tc();y.hc();)v=h(y.ic(),14),Os(v,null),_s(v,null);On(t)}function a$t(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et,kn,yi;for(ie=new Ns(e.b,0),E=t.tc(),N=0,y=h(E.ic(),21).a,Ce=0,i=new zr,qe=new Gc;ie.b=e.a&&(a=x7t(e,ie),E=vf(E,a.b),we=vf(we,a.d),De(m,new Is(ie,a)));for(ut=new ke,y=0;y0),V.a.cd(V.c=--V.b),ft=new lu(e.b),td(V,ft),Rn(V.b=a.n.b/2}else ie=!C;ie?(ee=h(G(a,(Ie(),i3)),15),ee?R?f=ee:(l=h(G(a,Jx),15),l?ee._b()<=l._b()?f=ee:f=l:(f=new ke,Ee(a,Jx,f))):(f=new ke,Ee(a,i3,f))):(l=h(G(a,(Ie(),Jx)),15),l?C?f=l:(ee=h(G(a,i3),15),ee?l._b()<=ee._b()?f=l:f=ee:(f=new ke,Ee(a,i3,f))):(f=new ke,Ee(a,Jx,f))),f.nc(e),Ee(e,(Ie(),SG),i),t.d==i?(_s(t,null),i.d.c.length+i.f.c.length==0&&us(i,null),MIt(i)):(Os(t,null),i.d.c.length+i.f.c.length==0&&us(i,null)),rd(t.a)}function u$t(e){var t,i,a,l,f,g,m,v,y,E,C,R,B,N;if(Be(G(e.c,($e(),Ki)))===Be((Ms(),vd))||Be(G(e.c,Ki))===Be(Oa)){for(E=new j(e.c.i);E.a0&&(l=h(St(V.c.a,Ue-1),8),g=e.i[l.o],ut=w.Math.ceil(r_(e.n,l,V)),f=Ce.a.e-V.d.d-(g.a.e+l.n.b+l.d.a)-ut),y=Jr,Ue0&&qe.a.e.e-qe.a.a-(qe.b.e.e-qe.b.a)<0,N=fe.a.e.e-fe.a.a-(fe.b.e.e-fe.b.a)<0&&qe.a.e.e-qe.a.a-(qe.b.e.e-qe.b.a)>0,B=fe.a.e.e+fe.b.aqe.b.e.e+qe.a.a,we=0,!W&&!N&&(R?f+C>0?we=C:y-a>0&&(we=a):B&&(f+m>0?we=m:y-ie>0&&(we=ie))),Ce.a.e+=we,Ce.b&&(Ce.d.e+=we),!1))}function h$t(){var e=["\\u0000","\\u0001","\\u0002","\\u0003","\\u0004","\\u0005","\\u0006","\\u0007","\\b","\\t","\\n","\\u000B","\\f","\\r","\\u000E","\\u000F","\\u0010","\\u0011","\\u0012","\\u0013","\\u0014","\\u0015","\\u0016","\\u0017","\\u0018","\\u0019","\\u001A","\\u001B","\\u001C","\\u001D","\\u001E","\\u001F"];return e[34]='\\"',e[92]="\\\\",e[173]="\\u00ad",e[1536]="\\u0600",e[1537]="\\u0601",e[1538]="\\u0602",e[1539]="\\u0603",e[1757]="\\u06dd",e[1807]="\\u070f",e[6068]="\\u17b4",e[6069]="\\u17b5",e[8203]="\\u200b",e[8204]="\\u200c",e[8205]="\\u200d",e[8206]="\\u200e",e[8207]="\\u200f",e[8232]="\\u2028",e[8233]="\\u2029",e[8234]="\\u202a",e[8235]="\\u202b",e[8236]="\\u202c",e[8237]="\\u202d",e[8238]="\\u202e",e[8288]="\\u2060",e[8289]="\\u2061",e[8290]="\\u2062",e[8291]="\\u2063",e[8292]="\\u2064",e[8298]="\\u206a",e[8299]="\\u206b",e[8300]="\\u206c",e[8301]="\\u206d",e[8302]="\\u206e",e[8303]="\\u206f",e[65279]="\\ufeff",e[65529]="\\ufff9",e[65530]="\\ufffa",e[65531]="\\ufffb",e}function ll(){ll=M,lm=new Ig("N",0,(Fe(),bn),bn,0),qw=new Ig("EN",1,Zt,bn,1),sb=new Ig("E",2,Zt,Zt,0),ob=new Ig("SE",3,ni,Zt,1),Kp=new Ig("S",4,ni,ni,0),Zw=new Ig("WS",5,nn,ni,1),Yw=new Ig("W",6,nn,nn,0),ip=new Ig("NW",7,bn,nn,1),Zp=new Ig("ENW",8,Zt,nn,2),Xw=new Ig("ESW",9,Zt,nn,2),ab=new Ig("SEN",10,ni,bn,2),yy=new Ig("SWN",11,ni,bn,2),l3=new Ig(zx,12,Na,Na,3),eat=T5t(lm,qw,sb,ob,Kp,Zw,X(q(hL,1),Oe,129,0,[Yw,ip,Zp,Xw,ab,yy])),nat=(lw(),F_(X(q(on,1),et,1,5,[lm,sb,Kp,Yw]))),tat=F_(X(q(on,1),et,1,5,[qw,ob,Zw,ip])),aat=new $2(bn),rat=F_(X(q(on,1),et,1,5,[Zt,bn])),iat=new $2(Zt),uat=F_(X(q(on,1),et,1,5,[ni,Zt])),lat=new $2(ni),gat=F_(X(q(on,1),et,1,5,[nn,ni])),pat=new $2(nn),cat=F_(X(q(on,1),et,1,5,[bn,nn])),sat=F_(X(q(on,1),et,1,5,[Zt,bn,nn])),oat=F_(X(q(on,1),et,1,5,[Zt,ni,nn])),hat=F_(X(q(on,1),et,1,5,[ni,nn,bn])),fat=F_(X(q(on,1),et,1,5,[ni,Zt,bn])),dat=(tS(),GP)}function d$t(e){var t,i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut;if(i=ce(Xe(G(e.a.j,($e(),TMe)))),i<-1||!e.a.i||iA(h(G(e.a.o,Ki),83))||sa(e.a.o,(Fe(),Zt))._b()<2&&sa(e.a.o,nn)._b()<2)return!0;if(e.a.c.pf())return!1;for(we=0,fe=0,ie=new ke,v=e.a.e,y=0,E=v.length;y=i}function p$t(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we;for(ii(t,TQe,1),B=h(G(e,($e(),cm)),197),l=new j(e.b);l.a=2){for(N=!0,C=new j(f.i),i=h($(C),11);C.a0){for(R=E<100?null:new Eg(E),y=new cbe(t),N=y.g,ee=le(In,si,22,E,15,1),a=0,we=new w_(E),l=0;l=0;)if(m!=null?ki(m,N[v]):N[v]==null){ee.length<=a&&(V=ee,ee=le(In,si,22,2*ee.length,15,1),vc(V,0,ee,0,a)),ee[a++]=l,$n(we,N[v]);break e}if(Be(m)===Be(m))break}}if(N=we.g,a>ee.length&&(V=ee,ee=le(In,si,22,a,15,1),vc(V,0,ee,0,a)),a>0){for(fe=!0,f=0;f=0;)Ex(e,ee[g]);if(a!=a){for(l=a;--l>=a;)Ex(we,l);V=ee,ee=le(In,si,22,a,15,1),vc(V,0,ee,0,a)}t=we}}}else for(t=$Dt(e,t),l=e.i;--l>=0;)t.pc(e.g[l])&&(Ex(e,l),fe=!0);if(fe){if(ee!=null){for(i=t._b(),C=i==1?dA(e,4,t.tc().ic(),null,ee[0],W):dA(e,6,t,ee,ee[0],W),R=i<100?null:new Eg(i),l=t.tc();l.hc();)B=l.ic(),R=Mme(e,h(B,75),R);R?(R.Sh(C),R.Th()):Li(e.e,C)}else{for(R=KMt(t._b()),l=t.tc();l.hc();)B=l.ic(),R=Mme(e,h(B,75),R);R&&R.Th()}return!0}else return!1}function m$t(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et,kn,yi,as;for(ii(i,"MinWidth layering",1),B=t.b,qe=t.a,as=h(G(t,($e(),FMe)),21).a,m=h(G(t,UMe),21).a,e.b=ce(Xe(G(t,sh))),e.d=Jr,we=new j(qe);we.a0||i.o==oh&&l0?(C=h(St(R.c.a,g-1),8),ut=r_(e.b,R,C),V=R.k.b-R.d.d-(C.k.b+C.n.b+C.d.a+ut)):V=R.k.b-R.d.d,y=w.Math.min(V,y),g=1&&(ut-y>0&&N>=0?(Yu(C,C.i+qe),Zu(C,C.j+v*y)):ut-y<0&&B>=0&&(Yu(C,C.i+qe*ut),Zu(C,C.j+v)));return ac(e,xM,(f=h(bl(AL),10),new Oc(f,h(el(f,f.length),10),0))),new $t(ft,E)}function _$t(e){var t,i,a,l,f,g,m,v,y,E,C,R,B,N,W,V;for(W=new ke,R=new j(e.d.b);R.al.d.d+l.d.a?E.f.d=!0:(E.f.d=!0,E.f.a=!0))),a.b!=a.d.c&&(t=i);E&&(f=h(Ii(e.f,g.d.g),57),t.bf.d.d+f.d.a?E.f.d=!0:(E.f.d=!0,E.f.a=!0))}for(m=Cn(As(B));Gn(m);)g=h(Tn(m),14),g.a.b!=0&&(t=h(n9(g.a),9),g.d.i==(Fe(),bn)&&(V=new dP(t,new $t(t.a,l.d.d),l,g),V.f.a=!0,V.a=g.d,W.c[W.c.length]=V),g.d.i==ni&&(V=new dP(t,new $t(t.a,l.d.d+l.d.a),l,g),V.f.d=!0,V.a=g.d,W.c[W.c.length]=V))}return W}function y$t(){_pe();function e(a){var l=this;this.dispatch=function(f){var g=f.data;switch(g.cmd){case"algorithms":var m=Jbe((_t(),new Jb(new bh(ev.b))));a.postMessage({id:g.id,data:m});break;case"categories":var v=Jbe((_t(),new Jb(new bh(ev.c))));a.postMessage({id:g.id,data:v});break;case"options":var y=Jbe((_t(),new Jb(new bh(ev.d))));a.postMessage({id:g.id,data:y});break;case"register":Ozt(g.algorithms),a.postMessage({id:g.id});break;case"layout":Z8t(g.graph,g.options||{}),a.postMessage({id:g.id,data:g.graph});break}},this.saveDispatch=function(f){try{l.dispatch(f)}catch(g){delete g[jne],a.postMessage({id:f.data.id,error:g.message})}}}function t(a){var l=this;this.dispatcher=new e({postMessage:function(f){l.onmessage({data:f})}}),this.postMessage=function(f){setTimeout(function(){l.dispatcher.saveDispatch({data:f})},0)}}if(typeof document===Axe&&typeof self!==Axe){var i=new e(self);self.onmessage=i.saveDispatch}else typeof u!==Axe&&u.exports&&(Object.defineProperty(d,"__esModule",{value:!0}),u.exports={default:t,Worker:t})}function fJe(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we;if(ie=0,t.e.a==0)for(V=new j(e);V.a50?ee.c[ee.c.length]=l:l.k>0?ie.c[ie.c.length]=l:fe.c[fe.c.length]=l;if(ie.c.length==1&&ee.c.length==0&&(Lr(ee,ie),ie.c=le(on,et,1,0,5,1)),ee.c.length!=0&&Rp(oJ(e.a),(ll(),lm))&&Rp(oJ(e.a),(ll(),Kp))?N6t(e,ee):Lr(ie,ee),ie.c.length==0||F6t(e,ie),fe.c.length!=0){if(i=sJ(e.a),i.c!=0)for(E=new j(fe),v=(Hn(i),Vge(new NNe(i).a));E.a1&&(W=h(nbe(v),129),WA(l,W,!0),cA(E),KUe(e.a,W))}for(R=fe.c.length,a=GUt(e),B=new ke,g=R/Mge(e.a).c|0,m=0;m3&&(Lr(B,(ll(),ll(),tat)),N-=4),N){case 3:De(B,M6(a));case 2:V=y7(M6(a));do V=y7(V);while(!Rp(oJ(e.a),V));B.c[B.c.length]=V,V=Gve(M6(a));do V=Gve(V);while(!Rp(oJ(e.a),V));B.c[B.c.length]=V;break;case 1:De(B,M6(a))}for(C=new j(B),y=new j(fe);C.aW&&(f&&(zm(Ue,B),zm(ut,He(E.b-1)),De(e.d,N),m.c=le(on,et,1,0,5,1)),yi=i.b,as+=B+t,B=0,C=w.Math.max(C,i.b+i.c+kn)),m.c[m.c.length]=v,lHe(v,yi,as),C=w.Math.max(C,yi+kn+i.c),B=w.Math.max(B,R),yi+=kn+t,N=v;if(Lr(e.a,m),De(e.d,h(St(m,m.c.length-1),145)),C=w.Math.max(C,a),Et=as+B+i.a,Et1&&(g=w.Math.min(g,w.Math.abs(h(qg(m.a,1),9).b-E.b)))));else for(W=new j(t.i);W.al&&(f=R.a-l,g=zi,a.c=le(on,et,1,0,5,1),l=R.a),R.a>=l&&(a.c[a.c.length]=m,m.a.b>1&&(g=w.Math.min(g,w.Math.abs(h(qg(m.a,m.a.b-2),9).b-R.b)))));if(a.c.length!=0&&f>t.n.a/2&&g>t.n.b/2){for(B=new yo,us(B,t),mr(B,(Fe(),bn)),B.k.a=t.n.a/2,ee=new yo,us(ee,t),mr(ee,ni),ee.k.a=t.n.a/2,ee.k.b=t.n.b,v=new j(a);v.a=y.b?Os(m,ee):Os(m,B)):(y=h(NCt(m.a),9),V=m.a.b==0?Wu(m.c):h(n9(m.a),9),V.b>=y.b?_s(m,ee):_s(m,B)),C=h(G(m,($e(),Lo)),74),C&&_x(C,y,!0);t.k.a=l-t.n.a/2}}function C$t(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce;for(m=new j(e.a.b);m.a0)if(a=C._b(),y=yr(w.Math.floor((a+1)/2))-1,l=yr(w.Math.ceil((a+1)/2))-1,t.o==oh)for(E=l;E>=y;E--)t.a[we.o]==we&&(W=h(C.cd(E),48),N=h(W.a,8),!IC(i,W.b)&&B>e.b.e[N.o]&&(t.a[N.o]=we,t.g[we.o]=t.g[N.o],t.a[we.o]=t.g[we.o],t.f[t.g[we.o].o]=(vt(),!!(ce(t.f[t.g[we.o].o])&we.j==(Xt(),Nr))),B=e.b.e[N.o]));else for(E=y;E<=l;E++)t.a[we.o]==we&&(ee=h(C.cd(E),48),V=h(ee.a,8),!IC(i,ee.b)&&B=48&&t<=57){for(a=t-48;l=48&&t<=57;)if(a=a*10+t-48,a<0)throw Y(new Wn(Zn((zn(),Dxe))))}else throw Y(new Wn(Zn((zn(),dtt))));if(i=a,t==44){if(l>=e.j)throw Y(new Wn(Zn((zn(),gtt))));if((t=po(e.i,l++))>=48&&t<=57){for(i=t-48;l=48&&t<=57;)if(i=i*10+t-48,i<0)throw Y(new Wn(Zn((zn(),Dxe))));if(a>i)throw Y(new Wn(Zn((zn(),mtt))))}else i=-1}if(t!=125)throw Y(new Wn(Zn((zn(),ptt))));e.Ck(l)?(f=(vi(),vi(),++Er,new pw(9,f)),e.d=l+1):(f=(vi(),vi(),++Er,new pw(3,f)),e.d=l),f.nl(a),f.ml(i),wi(e)}}return f}function A$t(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt;return C=j7t(rc(e,(Fe(),gAe)),t),N=k_(rc(e,sD),t),we=k_(rc(e,oD),t),ut=r7(rc(e,aD),t),R=r7(rc(e,rD),t),ie=k_(rc(e,m3),t),W=k_(rc(e,Ay),t),Ue=k_(rc(e,Py),t),Ce=k_(rc(e,Cy),t),ft=r7(rc(e,db),t),ee=k_(rc(e,T1),t),fe=k_(rc(e,yd),t),qe=k_(rc(e,Fh),t),Mt=r7(rc(e,xd),t),B=r7(rc(e,_d),t),V=k_(rc(e,vae),t),i=v_(X(q(ks,1),Wo,22,15,[ie.a,ut.a,Ue.a,Mt.a])),a=v_(X(q(ks,1),Wo,22,15,[N.a,C.a,we.a,V.a])),l=ee.a,f=v_(X(q(ks,1),Wo,22,15,[W.a,R.a,Ce.a,B.a])),y=v_(X(q(ks,1),Wo,22,15,[ie.b,N.b,W.b,fe.b])),v=v_(X(q(ks,1),Wo,22,15,[ut.b,C.b,R.b,V.b])),E=ft.b,m=v_(X(q(ks,1),Wo,22,15,[Ue.b,we.b,Ce.b,qe.b])),Bg(rc(e,gAe),i+l,y+E),Bg(rc(e,vae),i+l,y+E),Bg(rc(e,sD),i+l,0),Bg(rc(e,oD),i+l,y+E+v),Bg(rc(e,aD),0,y+E),Bg(rc(e,rD),i+l+a,y+E),Bg(rc(e,Ay),i+l+a,0),Bg(rc(e,Py),0,y+E+v),Bg(rc(e,Cy),i+l+a,y+E+v),Bg(rc(e,db),0,y),Bg(rc(e,T1),i,0),Bg(rc(e,Fh),0,y+E+v),Bg(rc(e,_d),i+l+a,0),g=new fo,g.a=v_(X(q(ks,1),Wo,22,15,[i+a+l+f,ft.a,fe.a,qe.a])),g.b=v_(X(q(ks,1),Wo,22,15,[y+v+E+m,ee.b,Mt.b,B.b])),g}function Ta(){Ta=M,tBe(),Llt=ds.a,h(ae(ye(ds.a),0),17),Alt=ds.f,h(ae(ye(ds.f),0),17),h(ae(ye(ds.f),1),29),Plt=ds.n,h(ae(ye(ds.n),0),29),h(ae(ye(ds.n),1),29),h(ae(ye(ds.n),2),29),h(ae(ye(ds.n),3),29),SAe=ds.g,h(ae(ye(ds.g),0),17),h(ae(ye(ds.g),1),29),Clt=ds.c,h(ae(ye(ds.c),0),17),h(ae(ye(ds.c),1),17),MAe=ds.i,h(ae(ye(ds.i),0),17),h(ae(ye(ds.i),1),17),h(ae(ye(ds.i),2),17),h(ae(ye(ds.i),3),17),h(ae(ye(ds.i),4),29),TAe=ds.j,h(ae(ye(ds.j),0),17),EAe=ds.d,h(ae(ye(ds.d),0),17),h(ae(ye(ds.d),1),17),h(ae(ye(ds.d),2),17),h(ae(ye(ds.d),3),17),h(ae(ye(ds.d),4),29),h(ae(ye(ds.d),5),29),h(ae(ye(ds.d),6),29),h(ae(ye(ds.d),7),29),Tlt=ds.b,h(ae(ye(ds.b),0),29),h(ae(ye(ds.b),1),29),Cj=ds.e,h(ae(ye(ds.e),0),29),h(ae(ye(ds.e),1),29),h(ae(ye(ds.e),2),29),h(ae(ye(ds.e),3),29),h(ae(ye(ds.e),4),17),h(ae(ye(ds.e),5),17),h(ae(ye(ds.e),6),17),h(ae(ye(ds.e),7),17),h(ae(ye(ds.e),8),17),h(ae(ye(ds.e),9),17),h(ae(ye(ds.e),10),29),op=ds.k,h(ae(ye(ds.k),0),29),h(ae(ye(ds.k),1),29)}function P$t(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et;for(ft=new Ir,Ue=new Ir,V=-1,v=new j(e);v.a=N&&(ie>N&&(B.c=le(on,et,1,0,5,1),N=ie),B.c[B.c.length]=g);B.c.length!=0&&(R=h(St(B,pte(t,B.c.length)),125),Et.a.$b(R)!=null,R.p=W++,Fve(R,ft,Ue),B.c=le(on,et,1,0,5,1))}for(we=e.c.length+1,m=new j(e);m.aMt.p&&(xf(i),Sa(Mt.g,a),a.c>0&&(a.a=Mt,De(Mt.q,a),a.b=qe,De(qe.g,a)))}function L$t(e,t,i){var a,l,f,g,m,v,y,E,C;if(ii(i,"Network simplex node placement",1),e.e=t,e.n=h(G(t,(Ie(),Uw)),266),Izt(e),iOt(e),Fa(Qf(new oi(null,new di(e.e.b,16)),new iq),new lZ(e)),Fa(go(Qf(go(Qf(new oi(null,new di(e.e.b,16)),new $T),new VT),new Rk),new lq),new cZ(e)),ce(mt(G(e.e,($e(),rL))))&&(g=bc(i,1),ii(g,"Straight Edges Pre-Processing",1),hjt(e),On(g)),cDt(e.f),f=h(G(t,F5),21).a*e.f.a.c.length,fne(Epe(Spe(IJ(e.f),f),!1),bc(i,1)),e.d.a._b()!=0){for(g=bc(i,1),ii(g,"Flexible Where Space Processing",1),m=h(hJ(t6(Yf(new oi(null,new di(e.f.a,16)),new rq),(dn(new OT),new Fr))),21).a,v=h(hJ(W9e(Yf(new oi(null,new di(e.f.a,16)),new sq),new ya)),21).a,y=v-m,E=m0(new Fm,e.f),C=m0(new Fm,e.f),Ju(zu(Uu(Fu(Gu(new iu,2e4),y),E),C)),Fa(go(go(f1e(e.i),new sN),new oN),new xUe(m,E,y,C)),l=e.d.a.Xb().tc();l.hc();)a=h(l.ic(),189),a.g=1;fne(Epe(Spe(IJ(e.f),f),!1),bc(g,1)),On(g)}ce(mt(G(t,rL)))&&(g=bc(i,1),ii(g,"Straight Edges Post-Processing",1),INt(e),On(g)),qGt(e),e.e=null,e.f=null,e.i=null,e.c=null,nl(e.k),e.j=null,e.a=null,e.o=null,e.d.a.Pb(),On(i)}function hJe(e,t,i,a,l){var f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et;for(W=new Gl(t.b),we=new Gl(t.b),R=new Gl(t.b),ut=new Gl(t.b),V=new Gl(t.b),qe=Nn(t,0);qe.b!=qe.d.c;)for(Ce=h(Un(qe),11),m=new j(Ce.f);m.a0,ee=Ce.f.c.length>0,y&&ee?R.c[R.c.length]=Ce:y?W.c[W.c.length]=Ce:ee&&(we.c[we.c.length]=Ce);for(N=new j(W);N.a=0&&dt(e.substr(m,2),"//")?(m+=2,v=Kee(e,m,IL,DL),a=e.substr(m,v-m),m=v):C!=null&&(m==e.length||e.charCodeAt(m)!=47)&&(g=!1,v=Pge(e,wc(35),m),v==-1&&(v=e.length),a=e.substr(m,v-m),m=v);if(!i&&m0&&po(E,E.length-1)==58&&(l=E,m=v)),m=R&&(we>R&&(C.c=le(on,et,1,0,5,1),R=we),C.c[C.c.length]=V);C.c.length!=0&&(E=h(St(C,pte(t,C.c.length)),165),fA(yi.a,E)!=null,E.d=B++,Nve(E,Et,ut),C.c=le(on,et,1,0,5,1))}for(Ue=e.c.length+1,ee=new j(e);ee.akn.d&&(xf(i),Sa(kn.b,a),a.c>0&&(a.a=kn,De(kn.e,a),a.b=ft,De(ft.b,a)))}function D$t(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et;for(ie=new Kv,fe=new Kv,E=M0(t,_xe),a=new AUe(e,i,ie,fe),mNt(a.a,a.b,a.c,a.d,E),v=(Ue=ie.i,Ue||(ie.i=re(ie.c,122)?new Zv(ie,h(ie.c,122)):re(ie.c,115)?new X2(ie,h(ie.c,115)):new XE(ie,ie.c))),ut=v.tc();ut.hc();)for(qe=h(ut.ic(),270),l=h(er(ie,qe),19),W=l.tc();W.hc();)if(N=W.ic(),we=h(Lp(e.d,N),270),we)m=(!qe.e&&(qe.e=new an(ts,qe,10,9)),qe.e),$n(m,we);else throw g=Vd(t,Rh),R=Vet+N+Wet+g,B=R+nM,Y(new _h(B));for(y=(Ce=fe.i,Ce||(fe.i=re(fe.c,122)?new Zv(fe,h(fe.c,122)):re(fe.c,115)?new X2(fe,h(fe.c,115)):new XE(fe,fe.c))),Mt=y.tc();Mt.hc();)for(ft=h(Mt.ic(),270),f=h(er(fe,ft),19),ee=f.tc();ee.hc();)if(V=ee.ic(),we=h(Lp(e.d,V),270),we)C=(!ft.g&&(ft.g=new an(ts,ft,9,10)),ft.g),$n(C,we);else throw g=Vd(t,Rh),R=Vet+V+Wet+g,B=R+nM,Y(new _h(B));!i.b&&(i.b=new an(pi,i,4,7)),i.b.i!=0&&(!i.c&&(i.c=new an(pi,i,5,8)),i.c.i!=0)&&(!i.b&&(i.b=new an(pi,i,4,7)),i.b.i<=1&&(!i.c&&(i.c=new an(pi,i,5,8)),i.c.i<=1))&&(!i.a&&(i.a=new ze(ts,i,6,6)),i.a).i==1&&(Et=h(ae((!i.a&&(i.a=new ze(ts,i,6,6)),i.a),0),270),!gte(Et)&&!mte(Et)&&(Q0e(Et,h(ae((!i.b&&(i.b=new an(pi,i,4,7)),i.b),0),97)),ebe(Et,h(ae((!i.c&&(i.c=new an(pi,i,5,8)),i.c),0),97))))}function dJe(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut;for(e.d=new $t(Jr,Jr),e.c=new $t(Ts,Ts),R=t.tc();R.hc();)for(E=h(R.ic(),31),fe=new j(E.a);fe.a=Ce||!UIt(ee,a))&&(a=y7e(t,E)),Hs(ee,a),f=Cn(As(ee));Gn(f);)l=h(Tn(f),14),!e.a[l.o]&&(W=l.c.g,--e.e[W.o],e.e[W.o]==0&&dS(RS(B,W)));for(y=E.c.length-1;y>=0;--y)De(t.b,(ai(y,E.c.length),h(E.c[y],26)));t.a.c=le(on,et,1,0,5,1),On(i)}function N$t(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et,kn,yi,as,Kc,uc,ng,kl,bm,I1,fh,hf;if(Et=oze(e,pze(i),t),jI(Et,Vd(t,Rh)),kn=h(Lp(e.g,Tx(Hm(t,wre))),35),R=Hm(t,"sourcePort"),a=null,R&&(a=Tx(R)),yi=h(Lp(e.j,a),121),!kn)throw m=jA(t),N="An edge must have a source node (edge id: '"+m,W=N+nM,Y(new _h(W));if(yi&&!Dp(Sh(yi),kn))throw v=Vd(t,Rh),V="The source port of an edge must be a port of the edge's source node (edge id: '"+v,ee=V+nM,Y(new _h(ee));if(ut=(!Et.b&&(Et.b=new an(pi,Et,4,7)),Et.b),yi?f=yi:f=kn,$n(ut,f),as=h(Lp(e.g,Tx(Hm(t,Cxe))),35),B=Hm(t,"targetPort"),l=null,B&&(l=Tx(B)),Kc=h(Lp(e.j,l),121),!as)throw C=jA(t),ie="An edge must have a target node (edge id: '"+C,fe=ie+nM,Y(new _h(fe));if(Kc&&!Dp(Sh(Kc),as))throw y=Vd(t,Rh),we="The target port of an edge must be a port of the edge's target node (edge id: '"+y,Ce=we+nM,Y(new _h(Ce));if(ft=(!Et.c&&(Et.c=new an(pi,Et,5,8)),Et.c),Kc?g=Kc:g=as,$n(ft,g),(!Et.b&&(Et.b=new an(pi,Et,4,7)),Et.b).i==0||(!Et.c&&(Et.c=new an(pi,Et,5,8)),Et.c).i==0)throw E=Vd(t,Rh),Ue=$et+E,qe=Ue+nM,Y(new _h(qe));return o7(t,Et),uc=j_(Et,!0,!0),ng=yI(t,"sourcePoint"),kl=new RZ(uc),Q6t(kl.a,ng),bm=yI(t,"targetPoint"),I1=new NZ(uc),e5t(I1.a,bm),fh=M0(t,Sre),hf=new FZ(uc),nOt(hf.a,fh),Mt=mee(e,t,Et),Mt}function Ine(e,t){_ne();var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et,kn;if(qe=e.e,B=e.d,l=e.a,qe==0)switch(t){case 0:return"0";case 1:return VS;case 2:return"0.00";case 3:return"0.000";case 4:return"0.0000";case 5:return"0.00000";case 6:return"0.000000";default:return Ce=new f0,t<0?Ce.a+="0E+":Ce.a+="0E",Ce.a+=-t,Ce.a}if(ie=B*10+1+7,fe=le(Zl,Ph,22,ie+1,15,1),i=ie,B==1)if(g=l[0],g<0){kn=Kr(g,ao);do N=kn,kn=h6(kn,10),fe[--i]=48+nr(Qm(N,Jm(kn,10)))&jr;while(Ma(kn,0)!=0)}else{kn=g;do N=kn,kn=kn/10|0,fe[--i]=48+(N-kn*10)&jr;while(kn!=0)}else{ft=le(In,si,22,B,15,1),Et=B,vc(l,0,ft,0,B);e:for(;;){for(Ue=0,v=Et-1;v>=0;v--)Mt=no(jd(Ue,32),Kr(ft[v],ao)),V=MBt(Mt),ft[v]=nr(V),Ue=nr(Pg(V,32));ee=nr(Ue),W=i;do fe[--i]=48+ee%10&jr;while((ee=ee/10|0)!=0&&i!=0);for(a=9-W+i,m=0;m0;m++)fe[--i]=48;for(E=Et-1;ft[E]==0;E--)if(E==0)break e;Et=E+1}for(;fe[i]==48;)++i}if(R=qe<0,f=ie-i-t-1,t==0)return R&&(fe[--i]=45),hu(fe,i,ie-i);if(t>0&&f>=-6){if(f>=0){for(y=i+f,C=ie-1;C>=y;C--)fe[C+1]=fe[C];return fe[++y]=46,R&&(fe[--i]=45),hu(fe,i,ie-i+1)}for(E=2;E<-f+1;E++)fe[--i]=48;return fe[--i]=46,fe[--i]=48,R&&(fe[--i]=45),hu(fe,i,ie-i)}return ut=i+1,we=new tw,R&&(we.a+="-"),ie-ut>=1?(Lg(we,fe[i]),we.a+=".",we.a+=hu(fe,i+1,ie-i-1)):we.a+=hu(fe,i,ie-i),we.a+="E",f>0&&(we.a+="+"),we.a+=""+f,we.a}function F$t(e,t,i,a){var l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et,kn,yi,as,Kc,uc,ng,kl,bm,I1,fh;if(fe=h(ae((!e.b&&(e.b=new an(pi,e,4,7)),e.b),0),97),Ce=fe.Yf(),Ue=fe.Zf(),we=fe.Xf()/2,W=fe.Wf()/2,re(fe,187)&&(ie=h(fe,121),Ce+=Sh(ie).i,Ce+=Sh(ie).i),Ce+=we,Ue+=W,Et=h(ae((!e.b&&(e.b=new an(pi,e,4,7)),e.b),0),97),yi=Et.Yf(),as=Et.Zf(),kn=Et.Xf()/2,qe=Et.Wf()/2,re(Et,187)&&(Mt=h(Et,121),yi+=Sh(Mt).i,yi+=Sh(Mt).i),yi+=kn,as+=qe,(!e.a&&(e.a=new ze(ts,e,6,6)),e.a).i==0)m=(d0(),y=new mE,y),$n((!e.a&&(e.a=new ze(ts,e,6,6)),e.a),m);else if((!e.a&&(e.a=new ze(ts,e,6,6)),e.a).i>1)for(N=new QC((!e.a&&(e.a=new ze(ts,e,6,6)),e.a));N.e!=N.i._b();)KA(N);for(g=h(ae((!e.a&&(e.a=new ze(ts,e,6,6)),e.a),0),270),V=yi,yi>Ce+we?V=Ce+we:yiUe+W?ee=Ue+W:asCe-we&&VUe-W&&eeyi+kn?ut=yi+kn:Ceas+qe?ft=as+qe:Ueyi-kn&&utas-qe&&fti&&(R=i-1),B=bm+al(t,24)*W6*C-C/2,B<0?B=1:B>a&&(B=a-1),l=(d0(),v=new gE,v),see(l,R),oee(l,B),$n((!g.a&&(g.a=new vs(ah,g,5)),g.a),l)}function pJe(e,t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee;for(a=new ke,m=new ke,V=t/2,B=e._b(),l=h(e.cd(0),9),ee=h(e.cd(1),9),N=Kte(l.a,l.b,ee.a,ee.b,V),De(a,(ai(0,N.c.length),h(N.c[0],9))),De(m,(ai(1,N.c.length),h(N.c[1],9))),y=2;y=0;v--)Gi(i,(ai(v,g.c.length),h(g.c[v],9)));return i}function U$t(e){var t,i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et,kn;if(qe=h(G(e,($e(),Ki)),83),qe!=(Ms(),sp)&&qe!=fb){for(N=e.b,B=N.c.length,E=new Gl((Sf(B+2,zne),NI(no(no(5,B+2),(B+2)/10|0)))),W=new Gl((Sf(B+2,zne),NI(no(no(5,B+2),(B+2)/10|0)))),De(E,new ui),De(E,new ui),De(W,new ke),De(W,new ke),Ue=new ke,t=0;tEt?C:Et;for(a=new j(ft.f);a.aEt?ut:Et}Ee(we,XG,He(C)),Ee(we,YG,He(ut))}for(ee=0,B=new j(t.b);B.a=e.j){e.a=-1,e.c=1;return}if(t=po(e.i,e.d++),e.a=t,e.b==1){switch(t){case 92:if(a=10,e.d>=e.j)throw Y(new Wn(Zn((zn(),wz))));e.a=po(e.i,e.d++);break;case 45:(e.e&512)==512&&e.d=e.j||po(e.i,e.d)!=63)break;if(++e.d>=e.j)throw Y(new Wn(Zn((zn(),Are))));switch(t=po(e.i,e.d++),t){case 58:a=13;break;case 61:a=14;break;case 33:a=15;break;case 91:a=19;break;case 62:a=18;break;case 60:if(e.d>=e.j)throw Y(new Wn(Zn((zn(),Are))));if(t=po(e.i,e.d++),t==61)a=16;else if(t==33)a=17;else throw Y(new Wn(Zn((zn(),Yet))));break;case 35:for(;e.d=e.j)throw Y(new Wn(Zn((zn(),wz))));e.a=po(e.i,e.d++);break;default:a=0}e.c=a}function gJe(e){var t,i,a,l,f,g,m,v,y;for(e.b=1,wi(e),t=null,e.c==0&&e.a==94?(wi(e),t=(vi(),vi(),++Er,new _l(4)),Da(t,0,rM),m=(++Er,new _l(4))):m=(vi(),vi(),++Er,new _l(4)),l=!0;(y=e.c)!=1;){if(y==0&&e.a==93&&!l){t&&(mP(t,m),m=t);break}if(i=e.a,a=!1,y==10)switch(i){case 100:case 68:case 119:case 87:case 115:case 83:Cw(m,FS(i)),a=!0;break;case 105:case 73:case 99:case 67:i=(Cw(m,FS(i)),-1),a=!0;break;case 112:case 80:if(v=bve(e,i),!v)throw Y(new Wn(Zn((zn(),Pre))));Cw(m,v),a=!0;break;default:i=Kve(e)}else if(y==24&&!l){if(t&&(mP(t,m),m=t),f=gJe(e),mP(m,f),e.c!=0||e.a!=93)throw Y(new Wn(Zn((zn(),stt))));break}if(wi(e),!a){if(y==0){if(i==91)throw Y(new Wn(Zn((zn(),Rxe))));if(i==93)throw Y(new Wn(Zn((zn(),Ixe))));if(i==45&&!l&&e.a!=93)throw Y(new Wn(Zn((zn(),Lre))))}if(e.c!=0||e.a!=45||i==45&&l)Da(m,i,i);else{if(wi(e),(y=e.c)==1)throw Y(new Wn(Zn((zn(),vz))));if(y==0&&e.a==93)Da(m,i,i),Da(m,45,45);else{if(y==0&&e.a==93||y==24)throw Y(new Wn(Zn((zn(),Lre))));if(g=e.a,y==0){if(g==91)throw Y(new Wn(Zn((zn(),Rxe))));if(g==93)throw Y(new Wn(Zn((zn(),Ixe))));if(g==45)throw Y(new Wn(Zn((zn(),Lre))))}else y==10&&(g=Kve(e));if(wi(e),i>g)throw Y(new Wn(Zn((zn(),ctt))));Da(m,i,g)}}}l=!1}if(e.c==1)throw Y(new Wn(Zn((zn(),vz))));return U_(m),gP(m),e.b=0,wi(e),m}function G$t(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et,kn,yi,as,Kc,uc;for(ii(i,"Greedy cycle removal",1),ie=t.a,uc=ie.c.length,e.a=le(In,si,22,uc,15,1),e.c=le(In,si,22,uc,15,1),e.b=le(In,si,22,uc,15,1),v=0,V=new j(ie);V.a0?Mt+1:1);for(f=new j(Ce.f);f.a0?Mt+1:1)}e.c[v]==0?Gi(e.d,N):e.a[v]==0&&Gi(e.e,N),++v}for(B=-1,R=1,E=new ke,Et=h(G(t,(Ie(),gM)),214);uc>0;){for(;e.d.b!=0;)yi=h(FJ(e.d),8),e.b[yi.o]=B--,f_e(e,yi),--uc;for(;e.e.b!=0;)as=h(FJ(e.e),8),e.b[as.o]=R++,f_e(e,as),--uc;if(uc>0){for(C=zs,ee=new j(ie);ee.a=C&&(fe>C&&(E.c=le(on,et,1,0,5,1),C=fe),E.c[E.c.length]=N));y=h(St(E,pte(Et,E.c.length)),8),e.b[y.o]=R++,f_e(e,y),--uc}}for(kn=ie.c.length+1,v=0;ve.b[Kc]&&(Qg(a,!0),Ee(t,TG,(vt(),vt(),!0)));e.a=null,e.c=null,e.b=null,rd(e.e),rd(e.d),On(i)}function j$t(e){Fn(e.c,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#decimal"])),Fn(e.d,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#integer"])),Fn(e.e,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#boolean"])),Fn(e.f,Kn,X(q(Se,1),be,2,6,[Ls,"EBoolean",gi,"EBoolean:Object"])),Fn(e.i,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#byte"])),Fn(e.g,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#hexBinary"])),Fn(e.j,Kn,X(q(Se,1),be,2,6,[Ls,"EByte",gi,"EByte:Object"])),Fn(e.n,Kn,X(q(Se,1),be,2,6,[Ls,"EChar",gi,"EChar:Object"])),Fn(e.t,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#double"])),Fn(e.u,Kn,X(q(Se,1),be,2,6,[Ls,"EDouble",gi,"EDouble:Object"])),Fn(e.F,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#float"])),Fn(e.G,Kn,X(q(Se,1),be,2,6,[Ls,"EFloat",gi,"EFloat:Object"])),Fn(e.I,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#int"])),Fn(e.J,Kn,X(q(Se,1),be,2,6,[Ls,"EInt",gi,"EInt:Object"])),Fn(e.N,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#long"])),Fn(e.O,Kn,X(q(Se,1),be,2,6,[Ls,"ELong",gi,"ELong:Object"])),Fn(e.Z,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#short"])),Fn(e.$,Kn,X(q(Se,1),be,2,6,[Ls,"EShort",gi,"EShort:Object"])),Fn(e._,Kn,X(q(Se,1),be,2,6,[Ls,"http://www.w3.org/2001/XMLSchema#string"]))}function F_e(e,t,i,a){var l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et,kn,yi;if(yZe(t),v=h(ae((!t.b&&(t.b=new an(pi,t,4,7)),t.b),0),97),E=h(ae((!t.c&&(t.c=new an(pi,t,5,8)),t.c),0),97),m=Ia(v),y=Ia(E),g=(!t.a&&(t.a=new ze(ts,t,6,6)),t.a).i==0?null:h(ae((!t.a&&(t.a=new ze(ts,t,6,6)),t.a),0),270),qe=h(Ii(e.a,m),8),Et=h(Ii(e.a,y),8),ut=null,kn=null,re(v,187)&&(Ue=h(Ii(e.a,v),279),re(Ue,11)?ut=h(Ue,11):re(Ue,8)&&(qe=h(Ue,8),ut=h(St(qe.i,0),11))),re(E,187)&&(Mt=h(Ii(e.a,E),279),re(Mt,11)?kn=h(Mt,11):re(Mt,8)&&(Et=h(Mt,8),kn=h(St(Et.i,0),11))),!qe||!Et)return null;for(W=new Op,No(W,t),Ee(W,(Ie(),Jn),t),Ee(W,($e(),Lo),null),B=h(G(a,Va),19),qe==Et&&B.nc((xo(),C5)),ut||(Ce=(Oo(),lc),ft=null,g&&Bd(h(G(qe,Ki),83))&&(ft=new $t(g.j,g.k),wze(ft,V9(t)),zze(ft,i),SA(y,m)&&(Ce=Fc,tr(ft,qe.k))),ut=aKe(qe,ft,Ce,a)),kn||(Ce=(Oo(),Fc),yi=null,g&&Bd(h(G(Et,Ki),83))&&(yi=new $t(g.b,g.c),wze(yi,V9(t)),zze(yi,i)),kn=aKe(Et,yi,Ce,va(Et))),Os(W,ut),_s(W,kn),R=new Bn((!t.n&&(t.n=new ze(ea,t,1,7)),t.n));R.e!=R.i._b();)if(C=h(Yn(R),137),!ce(mt(rn(C,x1)))&&C.a)switch(V=$ee(C),De(W.b,V),h(G(V,am),226).g){case 2:case 3:B.nc((xo(),dM));break;case 1:case 0:B.nc((xo(),hM)),Ee(V,am,(Yd(),xL))}if(f=h(G(a,mM),317),ee=h(G(a,FG),292),l=f==(fx(),S5)||ee==(XA(),Toe),g&&(!g.a&&(g.a=new vs(ah,g,5)),g.a).i!=0&&l){for(ie=m6(g),N=new zc,we=Nn(ie,0);we.b!=we.d.c;)fe=h(Un(we),9),Gi(N,new Do(fe));Ee(W,KSe,N)}return W}function U_e(e,t,i,a,l,f){var g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et,kn,yi;for(m=h(St(e.d.c.b,a),26),Et=new zr,B=new zr,R=0;Ri&&(ut=B.a.Zb(ee,B),ut==null);for(kn=new zr,N=new zr,fe=Et.a.Xb().tc();fe.hc();)for(ee=h(fe.ic(),8),g=t==1?fr(ee):As(ee),y=(Mo(),new Nd(Kh(Gd(g.a,new z))));Gn(y);)v=h(Tn(y),14),ju(ee.c)!=ju(v.d.g.c)&&Cr(kn,v.d.g);for(we=B.a.Xb().tc();we.hc();)for(ee=h(we.ic(),8),g=t==1?fr(ee):As(ee),y=(Mo(),new Nd(Kh(Gd(g.a,new z))));Gn(y);)v=h(Tn(y),14),ju(ee.c)!=ju(v.d.g.c)&&Cr(N,v.d.g);for(ert&&Jh(),qe=h(St(e.d.c.b,a+(t==1?1:-1)),26),W=zs,V=zi,C=0;CC?W:C:N.a.Qb(ee)&&(V=VC&&(Et=0,kn+=E+qe,E=0),u9t(Ce,g,Et,kn),t=w.Math.max(t,Et+Ue.a),E=w.Math.max(E,Ue.b),Et+=Ue.a+qe;for(we=new ui,i=new ui,ft=new j(e);ft.a=2){for(R=!0,ie=(ai(1,C.c.length),h(C.c[1],26)),W=new j(g.a);W.a=2){for(R=!0,fe=h(St(C,C.c.length-2),26),W=new j(v.a);W.aJte(f))&&(C=f);for(!C&&(C=(ai(0,V.c.length),h(V.c[0],164))),W=new j(t.b);W.a0?(N=(Ce+1)*e.d,N=0&&(df+=(Ce+2)*e.d)}fe=Mt,m=v}while(Mt);for(l=new j(e.j);l.a=-1900?1:0,i>=4?Mi(e,X(q(Se,1),be,2,6,[RJe,IJe])[m]):Mi(e,X(q(Se,1),be,2,6,["BC","AD"])[m]);break;case 121:N5t(e,i,a);break;case 77:t7t(e,i,a);break;case 107:v=l.q.getHours(),v==0?ad(e,24,i):ad(e,v,i);break;case 83:V8t(e,i,l);break;case 69:E=a.q.getDay(),i==5?Mi(e,X(q(Se,1),be,2,6,["S","M","T","W","T","F","S"])[E]):i==4?Mi(e,X(q(Se,1),be,2,6,[tie,nie,iie,rie,sie,oie,aie])[E]):Mi(e,X(q(Se,1),be,2,6,["Sun","Mon","Tue","Wed","Thu","Fri","Sat"])[E]);break;case 97:l.q.getHours()>=12&&l.q.getHours()<24?Mi(e,X(q(Se,1),be,2,6,["AM","PM"])[1]):Mi(e,X(q(Se,1),be,2,6,["AM","PM"])[0]);break;case 104:C=l.q.getHours()%12,C==0?ad(e,12,i):ad(e,C,i);break;case 75:R=l.q.getHours()%12,ad(e,R,i);break;case 72:B=l.q.getHours(),ad(e,B,i);break;case 99:N=a.q.getDay(),i==5?Mi(e,X(q(Se,1),be,2,6,["S","M","T","W","T","F","S"])[N]):i==4?Mi(e,X(q(Se,1),be,2,6,[tie,nie,iie,rie,sie,oie,aie])[N]):i==3?Mi(e,X(q(Se,1),be,2,6,["Sun","Mon","Tue","Wed","Thu","Fri","Sat"])[N]):ad(e,N,1);break;case 76:W=a.q.getMonth(),i==5?Mi(e,X(q(Se,1),be,2,6,["J","F","M","A","M","J","J","A","S","O","N","D"])[W]):i==4?Mi(e,X(q(Se,1),be,2,6,[Vne,Wne,Hne,qne,Bx,Xne,Yne,Zne,Kne,Jne,Qne,eie])[W]):i==3?Mi(e,X(q(Se,1),be,2,6,["Jan","Feb","Mar","Apr",Bx,"Jun","Jul","Aug","Sep","Oct","Nov","Dec"])[W]):ad(e,W+1,i);break;case 81:V=a.q.getMonth()/3|0,i<4?Mi(e,X(q(Se,1),be,2,6,["Q1","Q2","Q3","Q4"])[V]):Mi(e,X(q(Se,1),be,2,6,["1st quarter","2nd quarter","3rd quarter","4th quarter"])[V]);break;case 100:ee=a.q.getDate(),ad(e,ee,i);break;case 109:y=l.q.getMinutes(),ad(e,y,i);break;case 115:g=l.q.getSeconds(),ad(e,g,i);break;case 122:i<4?Mi(e,f.c[0]):Mi(e,f.c[1]);break;case 118:Mi(e,f.b);break;case 90:i<3?Mi(e,rFt(f)):i==3?Mi(e,cFt(f)):Mi(e,lFt(f.a));break;default:return!1}return!0}function G_e(){G_e=M;var e;rMe=(e=h(bl(jse),10),new Oc(e,h(el(e,e.length),10),0)),krt=new ln(Iye,rMe),Hrt=new ln(Dye,(vt(),vt(),!1)),fMe=(Q9(),noe),Zrt=new ln(nz,fMe),ust=new ln(Bye,!1),fst=new ln(Oye,!0),He(1),kst=new ln(Nye,He(7)),Rst=new ln(Fye,!1),Sst=new ln(Uye,!1),aMe=(EU(),Vse),Nrt=new ln(Bie,aMe),pMe=(u7(),Eoe),cst=new ln(t5,pMe),hMe=(du(),r3),tst=new ln(zye,hMe),gMe=(wx(),W5),lst=new ln(Gye,gMe),He(-1),nst=new ln(Oie,He(4)),He(-1),rst=new ln(Nie,He(2)),dMe=(G_(),$G),ast=new ln(Fie,dMe),He(0),ost=new ln(Uie,He(0)),Qrt=new ln(zie,He(zi)),oMe=(fx(),M5),Ort=new ln(Gie,oMe),Drt=new ln(jye,.1),Brt=new ln($ye,!1),He(0),Rrt=new ln(Vye,He(40)),sMe=(bS(),toe),Irt=new ln(Wye,sMe),vMe=(XA(),U5),Est=new ln(ZS,vMe),mst=new Sr(jie),mMe=(RI(),ZG),hst=new ln($ie,mMe),bMe=(g6(),vG),pst=new ln(Vie,bMe),new CE,wst=new ln(Wie,.3),_st=new Sr(Hie),wMe=(_w(),jG),yst=new ln(Hye,wMe),uMe=(WU(),Aoe),zrt=new ln(qie,uMe),Vrt=new ln(iz,!0),jrt=new ln(rz,.4),Pst=new ln(qye,10),Ast=new ln(Xye,10),Lst=new ln(Yye,20),He(0),Mst=new ln(Zye,He(0)),He(0),Tst=new ln(Kye,He(0)),He(0),Cst=new ln(Jye,He(0)),Art=new ln(Xie,!1),iMe=(IS(),ZP),Lrt=new ln(Qye,iMe),nMe=(sU(),Gse),Prt=new ln(e2e,nMe),Xrt=new ln(sz,!1),He(0),qrt=new ln(Yie,He(16)),He(0),Yrt=new ln(Zie,He(5)),EMe=(LU(),Loe),Xst=new ln(TP,EMe),Ist=new ln(t2e,10),Dst=new ln(n2e,1),yMe=(wU(),bG),Ust=new ln(oz,yMe),Bst=new Sr(Kie),_Me=He(1),He(0),Nst=new ln(Jie,_Me),xMe=(yU(),Poe),Hst=new ln(Qie,xMe),jst=new ln(az,!0),zst=new ln(cz,2),Vst=new ln(ere,!0),lMe=(d7(),wG),Urt=new ln(i2e,lMe),cMe=(JA(),Use),Frt=new ln(r2e,cMe),Jrt=Wse,Krt=S5,ist=GG,sst=GG,est=xoe,bst=z5,dst=U5,gst=U5,vst=Coe,xst=z5,Grt=(ld(),lb),Wrt=lb,$rt=lb,Ost=$se,Fst=bG,qst=koe,$st=H5,Gst=H5,Wst=H5}function ur(){ur=M;var e,t;yCe=new Sr(iet),xCe=(ud(),Qoe),dct=new ln(x2e,xCe),new CE,yM=new ln(WS,null),pct=new Sr(cxe),nae=new ln(nre,(vt(),vt(),!1)),SCe=(qs(),Oh),vL=new ln(rre,SCe),CCe=(ld(),gae),TCe=new ln(n5,CCe),wct=new ln(oxe,!1),LCe=(e1(),vj),Ey=new ln(E2e,LCe),FCe=new tx(12),Sy=new ln(Ux,FCe),rae=new ln(Q7,!1),$Ce=(Ms(),fb),nD=new ln(kie,$Ce),f3=new Sr(fz),mj=new Sr(Y6),fae=new Sr(J7),hae=new Sr(Z6),kCe=new zc,u3=new ln(D2e,kCe),mct=new ln(F2e,!1),vct=new ln(U2e,!1),new Sr(ret),RCe=new G2,dj=new ln($2e,RCe),sae=new ln(_2e,!1),new CE,Sct=new ln(set,1),new ln(oet,!0),He(0),new ln(aet,He(100)),new ln(cet,!1),He(0),new ln(uet,He(4e3)),He(0),new ln(fet,He(400)),new ln(het,!1),new ln(det,!0),new ln(pet,!1),ECe=(XU(),yae),gct=new ln(axe,ECe),HCe=new ln(Mie,12),Mct=new ln(h2e,10),qCe=new ln(Lie,2),Tct=new ln(d2e,10),XCe=new ln(p2e,0),bj=new ln(m2e,5),YCe=new ln(g2e,1),My=new ln(qS,20),JCe=new ln(b2e,10),dae=new Sr(w2e),KCe=new jNe,ZCe=new ln(V2e,KCe),xct=new Sr(j2e),UCe=!1,yct=new ln(G2e,UCe),ICe=new tx(5),_ct=new ln(get,ICe),DCe=(a1(),t=h(bl(Ys),10),new Oc(t,h(el(t,t.length),10),0)),pj=new ln(T2e,DCe),GCe=(Xg(),ub),zCe=new ln(P2e,GCe),aae=new Sr(L2e),cae=new Sr(k2e),lae=new Sr(R2e),oae=new Sr(I2e),BCe=(e=h(bl(AL),10),new Oc(e,h(el(e,e.length),10),0)),xM=new ln(lz,BCe),NCe=Ht((cc(),SM)),gj=new ln(ire,NCe),OCe=new $t(0,0),tD=new ln(uz,OCe),MCe=(Yd(),wj),eD=new ln(B2e,MCe),bct=new ln(O2e,!1),new Sr(met),He(1),new ln(bet,null),jCe=new Sr(z2e),Ect=new Sr(N2e),WCe=(Fe(),Na),_L=new ln(y2e,WCe),Zc=new Sr(v2e),VCe=(eh(),Ty),uae=new ln(C2e,VCe),iD=new ln(A2e,!1),hj=new ln(S2e,!1),iae=new ln(M2e,!1),ACe=new ln(Tie,1),PCe=(f7(),bae),new ln(wet,PCe)}function X$t(e){e.gb||(e.gb=!0,e.b=ra(e,0),xr(e.b,18),Ji(e.b,19),e.a=ra(e,1),xr(e.a,1),Ji(e.a,2),Ji(e.a,3),Ji(e.a,4),Ji(e.a,5),e.o=ra(e,2),xr(e.o,8),xr(e.o,9),Ji(e.o,10),Ji(e.o,11),Ji(e.o,12),Ji(e.o,13),Ji(e.o,14),Ji(e.o,15),Ji(e.o,16),Ji(e.o,17),Ji(e.o,18),Ji(e.o,19),Ji(e.o,20),Ji(e.o,21),Ji(e.o,22),Ji(e.o,23),To(e.o),To(e.o),To(e.o),To(e.o),To(e.o),To(e.o),To(e.o),To(e.o),To(e.o),To(e.o),e.p=ra(e,3),xr(e.p,2),xr(e.p,3),xr(e.p,4),xr(e.p,5),Ji(e.p,6),Ji(e.p,7),To(e.p),To(e.p),e.q=ra(e,4),xr(e.q,8),e.v=ra(e,5),Ji(e.v,9),To(e.v),To(e.v),To(e.v),e.w=ra(e,6),xr(e.w,2),xr(e.w,3),xr(e.w,4),Ji(e.w,5),e.B=ra(e,7),Ji(e.B,1),To(e.B),To(e.B),To(e.B),e.Q=ra(e,8),Ji(e.Q,0),To(e.Q),e.R=ra(e,9),xr(e.R,1),e.S=ra(e,10),To(e.S),To(e.S),To(e.S),To(e.S),To(e.S),To(e.S),To(e.S),To(e.S),To(e.S),To(e.S),To(e.S),To(e.S),To(e.S),To(e.S),To(e.S),e.T=ra(e,11),Ji(e.T,10),Ji(e.T,11),Ji(e.T,12),Ji(e.T,13),Ji(e.T,14),To(e.T),To(e.T),e.U=ra(e,12),xr(e.U,2),xr(e.U,3),Ji(e.U,4),Ji(e.U,5),Ji(e.U,6),Ji(e.U,7),To(e.U),e.V=ra(e,13),Ji(e.V,10),e.W=ra(e,14),xr(e.W,18),xr(e.W,19),xr(e.W,20),Ji(e.W,21),Ji(e.W,22),Ji(e.W,23),e.bb=ra(e,15),xr(e.bb,10),xr(e.bb,11),xr(e.bb,12),xr(e.bb,13),xr(e.bb,14),xr(e.bb,15),xr(e.bb,16),Ji(e.bb,17),To(e.bb),To(e.bb),e.eb=ra(e,16),xr(e.eb,2),xr(e.eb,3),xr(e.eb,4),xr(e.eb,5),xr(e.eb,6),xr(e.eb,7),Ji(e.eb,8),Ji(e.eb,9),e.ab=ra(e,17),xr(e.ab,0),xr(e.ab,1),e.H=ra(e,18),Ji(e.H,0),Ji(e.H,1),Ji(e.H,2),Ji(e.H,3),Ji(e.H,4),Ji(e.H,5),To(e.H),e.db=ra(e,19),Ji(e.db,2),e.c=hi(e,20),e.d=hi(e,21),e.e=hi(e,22),e.f=hi(e,23),e.i=hi(e,24),e.g=hi(e,25),e.j=hi(e,26),e.k=hi(e,27),e.n=hi(e,28),e.r=hi(e,29),e.s=hi(e,30),e.t=hi(e,31),e.u=hi(e,32),e.fb=hi(e,33),e.A=hi(e,34),e.C=hi(e,35),e.D=hi(e,36),e.F=hi(e,37),e.G=hi(e,38),e.I=hi(e,39),e.J=hi(e,40),e.L=hi(e,41),e.M=hi(e,42),e.N=hi(e,43),e.O=hi(e,44),e.P=hi(e,45),e.X=hi(e,46),e.Y=hi(e,47),e.Z=hi(e,48),e.$=hi(e,49),e._=hi(e,50),e.cb=hi(e,51),e.K=hi(e,52))}function Ie(){Ie=M;var e,t;Jn=new Sr(yye),XSe=new Sr("coordinateOrigin"),coe=new Sr("processors"),qSe=new Zr("compoundNode",(vt(),vt(),!1)),L5=new Zr("insideConnections",!1),md=new Sr("nestedLGraph"),sm=new Sr("parentLNode"),KSe=new Sr("originalBendpoints"),JSe=new Sr("originalDummyNodePosition"),QSe=new Sr("originalLabelEdge"),LG=new Sr("representedLabels"),CG=new Sr("endLabels"),t3=new Zr("labelSide",(xl(),fD)),my=new Zr("maxEdgeThickness",0),om=new Zr("reversed",!1),gM=new Sr(xye),Cl=new Zr("longEdgeSource",null),Al=new Zr("longEdgeTarget",null),n3=new Zr("longEdgeHasLabelDummies",!1),k5=new Zr("longEdgeBeforeLabelDummy",!1),roe=new Zr("edgeConstraint",(M_(),Hse)),pM=new Sr("inLayerLayoutUnit"),y1=new Zr("inLayerConstraint",(Hd(),A5)),e3=new Zr("inLayerSuccessorConstraint",new ke),Pl=new Sr("portDummy"),MG=new Zr("crossingHint",He(0)),Va=new Zr("graphProperties",(t=h(bl(Qse),10),new Oc(t,h(el(t,t.length),10),0))),pa=new Zr("externalPortSide",(Fe(),Na)),ZSe=new Zr("externalPortSize",new fo),soe=new Sr("externalPortReplacedDummies"),AG=new Sr("externalPortReplacedDummy"),Qx=new Zr("externalPortConnections",(e=h(bl(Ec),10),new Oc(e,h(el(e,e.length),10),0))),tb=new Zr(PQe,0),WSe=new Sr("barycenterAssociates"),i3=new Sr("TopSideComments"),Jx=new Sr("BottomSideComments"),SG=new Sr("CommentConnectionPort"),ooe=new Zr("inputCollect",!1),aoe=new Zr("outputCollect",!1),TG=new Zr("cyclic",!1),P5=new Zr("bigNodeOriginalSize",new Kb(0)),Fw=new Zr("bigNodeInitial",!1),HSe=new Zr("org.eclipse.elk.alg.layered.bigNodeLabels",new ke),ioe=new Zr("org.eclipse.elk.alg.layered.postProcess",null),YSe=new Sr("crossHierarchyMap"),foe=new Sr("targetOffset"),Trt=new Zr("splineLabelSize",new fo),R5=new Zr("splineLoopSide",(ll(),l3)),uoe=new Zr("splineSelfLoopComponents",new ke),eMe=new Zr("splineSelfLoopMargins",new G2),Uw=new Sr("spacings"),PG=new Zr("partitionConstraint",!1),eb=new Sr("breakingPoint.info"),JP=new Sr("splines.route.start"),loe=new Sr("splines.edgeChain")}function Ao(){Ao=M,nSe=new Dr("LEFT_DIR_PREPROCESSOR",0),jEe=new Dr("DOWN_DIR_PREPROCESSOR",1),mSe=new Dr("UP_DIR_PREPROCESSOR",2),zEe=new Dr("COMMENT_PREPROCESSOR",3),qP=new Dr("EDGE_AND_LAYER_CONSTRAINT_EDGE_REVERSER",4),hSe=new Dr("SPLINE_SELF_LOOP_PREPROCESSOR",5),kse=new Dr("INTERACTIVE_EXTERNAL_PORT_POSITIONER",6),aSe=new Dr("PARTITION_PREPROCESSOR",7),Pse=new Dr("BIG_NODES_PREPROCESSOR",8),aG=new Dr("LABEL_DUMMY_INSERTER",9),YEe=new Dr("HIGH_DEGREE_NODE_LAYER_PROCESSOR",10),oSe=new Dr("PARTITION_POSTPROCESSOR",11),rSe=new Dr("NODE_PROMOTION",12),fM=new Dr("LAYER_CONSTRAINT_PROCESSOR",13),HEe=new Dr("HIERARCHICAL_PORT_CONSTRAINT_PROCESSOR",14),Ase=new Dr("BIG_NODES_INTERMEDIATEPROCESSOR",15),lSe=new Dr("SEMI_INTERACTIVE_CROSSMIN_PROCESSOR",16),BEe=new Dr("BREAKING_POINT_INSERTER",17),Dse=new Dr("LONG_EDGE_SPLITTER",18),Ose=new Dr("PORT_SIDE_PROCESSOR",19),oG=new Dr("INVERTED_PORT_PROCESSOR",20),cSe=new Dr("SELF_LOOP_PROCESSOR",21),Bse=new Dr("PORT_LIST_SORTER",22),fG=new Dr("NORTH_SOUTH_PORT_PREPROCESSOR",23),OEe=new Dr("BREAKING_POINT_PROCESSOR",24),sSe=new Dr(EQe,25),pSe=new Dr(SQe,26),fSe=new Dr("SPLINE_SELF_LOOP_POSITIONER",27),uSe=new Dr("SINGLE_EDGE_GRAPH_WRAPPER",28),Rse=new Dr("IN_LAYER_CONSTRAINT_PROCESSOR",29),Lse=new Dr("BIG_NODES_SPLITTER",30),$Ee=new Dr("END_NODE_PORT_LABEL_MANAGEMENT_PROCESSOR",31),QEe=new Dr("LABEL_AND_NODE_SIZE_PROCESSOR",32),dSe=new Dr("SPLINE_SELF_LOOP_ROUTER",33),iSe=new Dr("NODE_MARGIN_CALCULATOR",34),sG=new Dr("END_LABEL_PREPROCESSOR",35),lG=new Dr("LABEL_DUMMY_SWITCHER",36),FEe=new Dr("CENTER_LABEL_MANAGEMENT_PROCESSOR",37),uM=new Dr("LABEL_SIDE_SELECTOR",38),KEe=new Dr("HYPEREDGE_DUMMY_MERGER",39),qEe=new Dr("HIERARCHICAL_PORT_DUMMY_SIZE_PROCESSOR",40),eSe=new Dr("LAYER_SIZE_AND_GRAPH_HEIGHT_CALCULATOR",41),XP=new Dr("HIERARCHICAL_PORT_POSITION_PROCESSOR",42),E5=new Dr("BIG_NODES_POSTPROCESSOR",43),UEe=new Dr("COMMENT_POSTPROCESSOR",44),JEe=new Dr("HYPERNODE_PROCESSOR",45),XEe=new Dr("HIERARCHICAL_PORT_ORTHOGONAL_EDGE_ROUTER",46),Ise=new Dr("LONG_EDGE_JOINER",47),NEe=new Dr("BREAKING_POINT_REMOVER",48),uG=new Dr("NORTH_SOUTH_PORT_POSTPROCESSOR",49),ZEe=new Dr("HORIZONTAL_COMPACTOR",50),cG=new Dr("LABEL_DUMMY_REMOVER",51),VEe=new Dr("FINAL_SPLINE_BENDPOINTS_CALCULATOR",52),hG=new Dr("REVERSED_EDGE_RESTORER",53),rG=new Dr("END_LABEL_POSTPROCESSOR",54),WEe=new Dr("HIERARCHICAL_NODE_RESIZER",55),tSe=new Dr("LEFT_DIR_POSTPROCESSOR",56),GEe=new Dr("DOWN_DIR_POSTPROCESSOR",57),gSe=new Dr("UP_DIR_POSTPROCESSOR",58)}function Y$t(e,t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt,Et,kn,yi,as,Kc,uc,ng,kl,bm,I1,fh,hf,df,RM,TD,CD,E3,Gae,UL,Nut,mPe,_b,zL,jae,S3,GL,cv,jL,$ae,Fut;for(mPe=0,kn=0,Kc=t.length;kn0&&(e.a[hf.o]=mPe++)}for(GL=0,yi=0,uc=i.length;yi0;){for(hf=(Rn(CD.b>0),h(CD.a.cd(CD.c=--CD.b),11)),TD=0,m=new j(hf.d);m.a0&&(hf.i==(Fe(),bn)?(e.a[hf.o]=GL,++GL):(e.a[hf.o]=GL+ng+bm,++bm))}GL+=bm}for(RM=(Yr(),new ui),B=new Gc,Et=0,as=t.length;Ety.b&&(y.b=E3)):hf.g.c==Nut&&(E3y.c&&(y.c=E3));for(DI(N,0,N.length,null),S3=le(In,si,22,N.length,15,1),a=le(In,si,22,GL+1,15,1),V=0;V0;)Ue%2>0&&(l+=$ae[Ue+1]),Ue=(Ue-1)/2|0,++$ae[Ue];for(ut=le(Pot,et,336,N.length*2,0,1),fe=0;fe'?":dt(Yet,e)?"'(?<' or '(? toIndex: ",sye=", toIndex: ",VJe="org.eclipse.elk.alg.common.compaction",WJe="Scanline/EventHandler",dd="org.eclipse.elk.alg.common.compaction.oned",HJe="CNode belongs to another CGroup.",qJe="ISpacingsHandler/1",mie="The ",bie=" instance has been finished already.",XJe="The direction ",YJe=" is not supported by the CGraph instance.",ZJe="OneDimensionalCompactor",KJe="OneDimensionalCompactor/lambda$0$Type",JJe="Quadruplet",QJe="ScanlineConstraintCalculator",eQe="ScanlineConstraintCalculator/ConstraintsScanlineHandler",tQe="ScanlineConstraintCalculator/ConstraintsScanlineHandler/lambda$0$Type",nQe="ScanlineConstraintCalculator/Timestamp",iQe="ScanlineConstraintCalculator/lambda$0$Type",ef={138:1,56:1},wie="org.eclipse.elk.alg.common.compaction.options",Za="org.eclipse.elk.core.data",oye="org.eclipse.elk.polyomino.traversalStrategy",aye="org.eclipse.elk.polyomino.lowLevelSort",cye="org.eclipse.elk.polyomino.highLevelSort",lye="org.eclipse.elk.polyomino.fill",pd={154:1},vie="polyomino",Lh="org.eclipse.elk.alg.common.compaction.polyomino",X7="org.eclipse.elk.alg.common.compaction.polyomino.structures",uye="Direction",_ie="Grid is only of size ",yie=". Requested point (",xie=") is out of bounds.",Y7=" Given center based coordinates were (",q6="org.eclipse.elk.graph.properties",rQe="IPropertyHolder",Eie={3:1,93:1,131:1},K_={244:1},vP="org.eclipse.elk.core",sQe="Connected Components Compaction",oQe="org.eclipse.elk.alg.disco",Z7="org.eclipse.elk.alg.disco.graph",Sie="org.eclipse.elk.alg.disco.options",aQe="CompactionStrategy",fye="org.eclipse.elk.disco.componentCompaction.strategy",hye="org.eclipse.elk.disco.componentCompaction.componentLayoutAlgorithm",dye="org.eclipse.elk.disco.debug.discoGraph",pye="org.eclipse.elk.disco.debug.discoPolys",cQe="componentCompaction",u1="org.eclipse.elk.disco",Mie="org.eclipse.elk.spacing.componentComponent",Tie="org.eclipse.elk.edge.thickness",WS="org.eclipse.elk.aspectRatio",Ux="org.eclipse.elk.padding",J_="org.eclipse.elk.alg.disco.transform",Cie=1.5707963267948966,Lw={3:1,4:1,5:1,175:1},f1={221:1,3:1,4:1},gye={3:1,6:1,4:1,5:1,63:1,73:1},mye="org.eclipse.elk.alg.force",bye="ComponentsProcessor",lQe="ComponentsProcessor/1",X6="org.eclipse.elk.alg.force.graph",uQe="Component Layout",wye="org.eclipse.elk.alg.force.model",gd=.01,K7="org.eclipse.elk.force.model",vye="org.eclipse.elk.force.iterations",_ye="org.eclipse.elk.force.repulsivePower",Aie="org.eclipse.elk.force.temperature",Jd=.001,Pie="org.eclipse.elk.force.repulsion",_P="org.eclipse.elk.alg.force.options",HS=1.600000023841858,kh="org.eclipse.elk.force",Y6="org.eclipse.elk.priority",qS="org.eclipse.elk.spacing.nodeNode",Lie="org.eclipse.elk.spacing.edgeLabel",J7="org.eclipse.elk.randomSeed",Z6="org.eclipse.elk.separateConnectedComponents",Q7="org.eclipse.elk.interactive",kie="org.eclipse.elk.portConstraints",yye="origin",xye="random",fQe="boundingBox.upLeft",hQe="boundingBox.lowRight",Eye="org.eclipse.elk.stress.fixed",Sye="org.eclipse.elk.stress.desiredEdgeLength",Mye="org.eclipse.elk.stress.dimension",Tye="org.eclipse.elk.stress.epsilon",Cye="org.eclipse.elk.stress.iterationLimit",yP="org.eclipse.elk.stress",dQe="ELK Stress",Rie="org.eclipse.elk.alg.force.stress",pQe="Layered layout",K6="org.eclipse.elk.alg.layered",J6="org.eclipse.elk.alg.layered.compaction.components",xP="org.eclipse.elk.alg.layered.compaction.oned",ez="org.eclipse.elk.alg.layered.compaction.oned.algs",h1="org.eclipse.elk.alg.layered.compaction.recthull",nm="org.eclipse.elk.alg.layered.components",gQe={3:1,6:1,4:1,5:1,85:1,63:1,73:1},tz="org.eclipse.elk.alg.layered.compound",mu={3:1,6:1,4:1,5:1,99:1,85:1,63:1,73:1},kr={50:1},Ka="org.eclipse.elk.alg.layered.graph",Af={3:1,6:1,4:1,5:1,85:1,123:1,148:1,63:1,73:1},mQe="Not supported by LGraph",bQe=`([{"' \r `,wQe=`)]}"' \r -`,vQe="The given string contains parts that cannot be parsed as numbers.",Q6="org.eclipse.elk.core.math",_Qe={3:1,4:1,135:1,211:1,428:1},yQe={3:1,4:1,119:1,211:1,428:1},d1="org.eclipse.elk.alg.layered.graph.transform",An="org.eclipse.elk.alg.layered.intermediate",xQe="Big nodes pre-processing",Aye={3:1,6:1,4:1,5:1,85:1,619:1,148:1,63:1,73:1},Pye={3:1,4:1,5:1,537:1},EQe="ONE_SIDED_GREEDY_SWITCH",SQe="TWO_SIDED_GREEDY_SWITCH",Iie="No implementation is available for the layout processor ",Lye="IntermediateProcessorStrategy",kye="Node '",MQe="NodeMarginCalculator",TQe="Odd port side processing",kw=1e-8,qr="org.eclipse.elk.alg.layered.intermediate.compaction",EP="org.eclipse.elk.alg.layered.intermediate.greedyswitch",p1="org.eclipse.elk.alg.layered.p3order.counting",e5={208:1},Qd="org.eclipse.elk.alg.layered.intermediate.wrapping",SP="org.eclipse.elk.alg.layered.networksimplex",_c="org.eclipse.elk.alg.layered.options",Die="INTERACTIVE",q0="NONE",XS="LEFT",YS="RIGHT",CQe="EDGE_LENGTH",AQe="SELF_LOOPS",Rye="BOTTOM",MP="CENTER",PQe="portRatioOrPosition",Iye="org.eclipse.elk.layered.contentAlignment",Dye="org.eclipse.elk.layered.feedbackEdges",nz="org.eclipse.elk.layered.interactiveReferencePoint",Bye="org.eclipse.elk.layered.mergeEdges",Oye="org.eclipse.elk.layered.mergeHierarchyEdges",Nye="org.eclipse.elk.layered.thoroughness",Fye="org.eclipse.elk.layered.unnecessaryBendpoints",Uye="org.eclipse.elk.layered.northOrSouthPort",Bie="org.eclipse.elk.layered.cycleBreaking.strategy",t5="org.eclipse.elk.layered.layering.strategy",zye="org.eclipse.elk.layered.layering.layerConstraint",Gye="org.eclipse.elk.layered.layering.wideNodesOnMultipleLayers",Oie="org.eclipse.elk.layered.layering.minWidth.upperBoundOnWidth",Nie="org.eclipse.elk.layered.layering.minWidth.upperLayerEstimationScalingFactor",Fie="org.eclipse.elk.layered.layering.nodePromotion.strategy",Uie="org.eclipse.elk.layered.layering.nodePromotion.maxIterations",zie="org.eclipse.elk.layered.layering.coffmanGraham.layerBound",Gie="org.eclipse.elk.layered.crossingMinimization.strategy",jye="org.eclipse.elk.layered.crossingMinimization.hierarchicalSweepiness",$ye="org.eclipse.elk.layered.crossingMinimization.semiInteractive",Vye="org.eclipse.elk.layered.crossingMinimization.greedySwitch.activationThreshold",Wye="org.eclipse.elk.layered.crossingMinimization.greedySwitch.type",ZS="org.eclipse.elk.layered.nodePlacement.strategy",jie="org.eclipse.elk.layered.nodePlacement.favorStraightEdges",$ie="org.eclipse.elk.layered.nodePlacement.bk.edgeStraightening",Vie="org.eclipse.elk.layered.nodePlacement.bk.fixedAlignment",Wie="org.eclipse.elk.layered.nodePlacement.linearSegments.deflectionDampening",Hie="org.eclipse.elk.layered.nodePlacement.networkSimplex.nodeFlexibility",Hye="org.eclipse.elk.layered.nodePlacement.networkSimplex.nodeFlexibility.default",qie="org.eclipse.elk.layered.edgeRouting.selfLoopPlacement",iz="org.eclipse.elk.layered.edgeRouting.sloppySplineRouting",rz="org.eclipse.elk.layered.edgeRouting.sloppySplineLayerSpacing",qye="org.eclipse.elk.layered.spacing.edgeNodeBetweenLayers",Xye="org.eclipse.elk.layered.spacing.edgeEdgeBetweenLayers",Yye="org.eclipse.elk.layered.spacing.nodeNodeBetweenLayers",Zye="org.eclipse.elk.layered.priority.direction",Kye="org.eclipse.elk.layered.priority.shortness",Jye="org.eclipse.elk.layered.priority.straightness",Xie="org.eclipse.elk.layered.compaction.connectedComponents",Qye="org.eclipse.elk.layered.compaction.postCompaction.strategy",e2e="org.eclipse.elk.layered.compaction.postCompaction.constraints",sz="org.eclipse.elk.layered.highDegreeNodes.treatment",Yie="org.eclipse.elk.layered.highDegreeNodes.threshold",Zie="org.eclipse.elk.layered.highDegreeNodes.treeHeight",TP="org.eclipse.elk.layered.wrapping.strategy",t2e="org.eclipse.elk.layered.wrapping.additionalEdgeSpacing",n2e="org.eclipse.elk.layered.wrapping.correctionFactor",oz="org.eclipse.elk.layered.wrapping.cutting.strategy",Kie="org.eclipse.elk.layered.wrapping.cutting.cuts",Jie="org.eclipse.elk.layered.wrapping.cutting.msd.freedom",Qie="org.eclipse.elk.layered.wrapping.singleEdge.validify.strategy",az="org.eclipse.elk.layered.wrapping.multiEdge.improveCuts",cz="org.eclipse.elk.layered.wrapping.multiEdge.distancePenalty",ere="org.eclipse.elk.layered.wrapping.multiEdge.improveWrappedEdges",i2e="org.eclipse.elk.layered.edgeLabels.sideSelection",r2e="org.eclipse.elk.layered.edgeLabels.centerLabelPlacementStrategy",s2e="layering",LQe="layering.minWidth",kQe="layering.nodePromotion",o2e="crossingMinimization",RQe="crossingMinimization.greedySwitch",IQe="nodePlacement",DQe="nodePlacement.bk",a2e="edgeRouting",n5="org.eclipse.elk.edgeRouting",im="spacing",c2e="priority",BQe="compaction.postCompaction",OQe="Specifies whether and how post-process compaction is applied.",l2e="highDegreeNodes",u2e="wrapping",NQe="wrapping.cutting",f2e="wrapping.multiEdge",tre="edgeLabels",Pn="org.eclipse.elk.layered",h2e="org.eclipse.elk.spacing.edgeEdge",d2e="org.eclipse.elk.spacing.edgeNode",p2e="org.eclipse.elk.spacing.labelLabel",g2e="org.eclipse.elk.spacing.labelPort",m2e="org.eclipse.elk.spacing.labelNode",b2e="org.eclipse.elk.spacing.portPort",w2e="org.eclipse.elk.spacing.individualOverride",v2e="org.eclipse.elk.port.borderOffset",_2e="org.eclipse.elk.noLayout",y2e="org.eclipse.elk.port.side",nre="org.eclipse.elk.debugMode",x2e="org.eclipse.elk.alignment",E2e="org.eclipse.elk.hierarchyHandling",S2e="org.eclipse.elk.insideSelfLoops.activate",M2e="org.eclipse.elk.insideSelfLoops.yo",lz="org.eclipse.elk.nodeSize.constraints",ire="org.eclipse.elk.nodeSize.options",rre="org.eclipse.elk.direction",T2e="org.eclipse.elk.nodeLabels.placement",C2e="org.eclipse.elk.portLabels.placement",A2e="org.eclipse.elk.portLabels.nextToPortIfPossible",P2e="org.eclipse.elk.portAlignment.default",L2e="org.eclipse.elk.portAlignment.north",k2e="org.eclipse.elk.portAlignment.south",R2e="org.eclipse.elk.portAlignment.west",I2e="org.eclipse.elk.portAlignment.east",uz="org.eclipse.elk.nodeSize.minimum",D2e="org.eclipse.elk.junctionPoints",B2e="org.eclipse.elk.edgeLabels.placement",O2e="org.eclipse.elk.edgeLabels.inline",N2e="org.eclipse.elk.port.index",F2e="org.eclipse.elk.commentBox",U2e="org.eclipse.elk.hypernode",z2e="org.eclipse.elk.port.anchor",G2e="org.eclipse.elk.partitioning.activate",j2e="org.eclipse.elk.partitioning.partition",fz="org.eclipse.elk.position",$2e="org.eclipse.elk.margins",V2e="org.eclipse.elk.spacing.portsSurrounding",FQe="NETWORK_SIMPLEX",zx="UNDEFINED",UQe={3:1,4:1,5:1,616:1},Tl={141:1,50:1},W2e="org.eclipse.elk.alg.layered.p1cycles",Rw="org.eclipse.elk.alg.layered.p2layers",H2e={422:1,208:1},zQe={736:1,3:1,4:1},ql="org.eclipse.elk.alg.layered.p3order",co="org.eclipse.elk.alg.layered.p4nodes",GQe={3:1,4:1,5:1,745:1},sre=1e-5,ore="DOWN",Hp="org.eclipse.elk.alg.layered.p4nodes.bk",Gx=17976931348623157e292,Q_="org.eclipse.elk.alg.layered.p5edges",g1="org.eclipse.elk.alg.layered.p5edges.splines",ey=1e-6,hz=-1e-6,jQe="The list of vectors may not be empty.",q2e=-17976931348623157e292,are=.09999999999999998,$Qe=4.71238898038469,VQe=3.141592653589793,CP="org.eclipse.elk.alg.mrtree",AP="org.eclipse.elk.alg.mrtree.graph",jx="org.eclipse.elk.alg.mrtree.intermediate",WQe="Set neighbors in level",HQe="DESCENDANTS",X2e="org.eclipse.elk.mrtree.weighting",Y2e="org.eclipse.elk.mrtree.searchOrder",dz="org.eclipse.elk.alg.mrtree.options",ty="org.eclipse.elk.mrtree",qQe="org.eclipse.elk.tree",Z2e="org.eclipse.elk.alg.radial",$x=6.283185307179586,cre=5e-324,XQe="org.eclipse.elk.alg.radial.intermediate",lre="org.eclipse.elk.alg.radial.intermediate.compaction",YQe={3:1,4:1,5:1,63:1},K2e="org.eclipse.elk.alg.radial.intermediate.optimization",ure="No implementation is available for the layout option ",PP="org.eclipse.elk.alg.radial.options",J2e="org.eclipse.elk.radial.orderId",Q2e="org.eclipse.elk.radial.radius",fre="org.eclipse.elk.radial.compactor",hre="org.eclipse.elk.radial.compactionStepSize",exe="org.eclipse.elk.radial.sorter",txe="org.eclipse.elk.radial.wedgeCriteria",nxe="org.eclipse.elk.radial.optimizationCriteria",X0="org.eclipse.elk.radial",ZQe="org.eclipse.elk.alg.radial.p1position.wedge",ixe="org.eclipse.elk.alg.radial.sorting",KQe=5.497787143782138,JQe=3.9269908169872414,QQe=2.356194490192345,Af="org.eclipse.elk.core.util",eet="Invalid index: ",Vx="org.eclipse.elk.core.alg",Wx={337:1},ny={284:1},rxe="Make sure it's type is registered with the ",sxe=" utility class.",KS="true",dre="false",tet="Couldn't clone property '",Pf="org.eclipse.elk.core.options",net=1.2999999523162842,Iw="org.eclipse.elk.box",oxe="org.eclipse.elk.expandNodes",axe="org.eclipse.elk.box.packingMode",iet="org.eclipse.elk.algorithm",cxe="org.eclipse.elk.bendPoints",ret="org.eclipse.elk.labelManager",set="org.eclipse.elk.scaleFactor",oet="org.eclipse.elk.animate",aet="org.eclipse.elk.animTimeFactor",cet="org.eclipse.elk.layoutAncestors",uet="org.eclipse.elk.maxAnimTime",fet="org.eclipse.elk.minAnimTime",het="org.eclipse.elk.progressBar",det="org.eclipse.elk.validateOptions",pet="org.eclipse.elk.zoomToFit",get="org.eclipse.elk.nodeLabels.padding",met="org.eclipse.elk.font.name",bet="org.eclipse.elk.font.size",wet="org.eclipse.elk.edge.type",vet="de.cau.cs.kieler.labelSpacing",_et="partitioning",yet="nodeLabels",pz="portAlignment",lxe="nodeSize",pre="port",xet="portLabels",Eet="insideSelfLoops",Met="de.cau.cs.kieler.selfLoopInside",i5="org.eclipse.elk.fixed",Tet="Fixed Layout",gz="org.eclipse.elk.random",Cet="port must have a parent node to calculate the port side",r5="org.eclipse.elk.core.util.adapters",uxe="org.eclipse.elk.core.util.nodespacing",m1="org.eclipse.elk.core.util.nodespacing.cellsystem",Aet={171:1,307:1},fxe="Vertical alignment cannot be null",mz="org.eclipse.elk.core.util.nodespacing.internal",JS="org.eclipse.elk.core.util.nodespacing.internal.algorithm",QS="org.eclipse.elk.core.util.overlaps",Xl="org.eclipse.emf.ecore",iy="org.eclipse.elk.graph",Pet="EMapPropertyHolder",Let="ElkBendPoint",ket="ElkGraphElement",Ret="ElkConnectableShape",hxe="ElkEdge",Iet="ElkEdgeSection",Det="EModelElement",Bet="ENamedElement",dxe="ElkLabel",pxe="ElkNode",gxe="ElkPort",Oet={91:1,87:1},Hx="org.eclipse.emf.common.notify.impl",ry="The feature '",gre="' is not a valid changeable feature",Net="Expecting null",mxe="' is not a valid feature",Ja=32768,Fet={95:1,91:1,87:1,51:1,42:1,92:1},Lt="org.eclipse.emf.ecore.impl",b1="org.eclipse.elk.graph.impl",LP="Recursive containment not allowed for ",eM="The datatype '",Y0="' is not a valid classifier",mre="The value '",sy={173:1,3:1,4:1},bre="The class '",tM="http://www.eclipse.org/elk/ElkGraph",bxe="property",kP="value",wre="source",Uet="properties",zet="identifier",vre="height",_re="width",yre="parent",xre="text",wxe="children",Get="hierarchical",vxe="sources",Ere="targets",_xe="sections",Sre="bendPoints",yxe="outgoingShape",xxe="incomingShape",Exe="outgoingSections",Sxe="incomingSections",Gs="org.eclipse.emf.common.util",Mxe="Severe implementation error in the Json to ElkGraph importer.",Rh="id",Ps="org.eclipse.elk.graph.json",Txe="Unhandled parameter types: ",jet="startPoint",$et="An edge must have at least one source and one target (edge id: '",nM="').",Vet="Referenced edge section does not exist: ",Wet=" (edge id: '",Cxe="target",bz="group",gi="name",Het="connectableShape cannot be null",Mre="Passed edge is not 'simple'.",s5="The 'no duplicates' constraint is violated",Ih={3:1,4:1,20:1,25:1,41:1,13:1,15:1,49:1,59:1,55:1,52:1},Tre={3:1,4:1,20:1,25:1,41:1,13:1,43:1,15:1,49:1,59:1,55:1,52:1,532:1},Cre="org.eclipse.elk.graph.util",Axe="undefined",qet="parser.parse.1",Xet="parser.parse.2",wz="parser.next.1",Are="parser.next.2",Yet="parser.next.3",Zet="parser.next.4",w1="parser.factor.1",Pxe="parser.factor.2",Ket="parser.factor.3",Jet="parser.factor.4",Qet="parser.factor.5",ett="parser.factor.6",ttt="parser.atom.1",ntt="parser.atom.2",itt="parser.atom.3",Lxe="parser.atom.4",Pre="parser.atom.5",kxe="parser.cc.1",vz="parser.cc.2",rtt="parser.cc.3",stt="parser.cc.5",Rxe="parser.cc.6",Ixe="parser.cc.7",Lre="parser.cc.8",ott="parser.ope.1",att="parser.ope.2",ctt="parser.ope.3",qp="parser.descape.1",ltt="parser.descape.2",utt="parser.descape.3",ftt="parser.descape.4",htt="parser.descape.5",Yl="parser.process.1",dtt="parser.quantifier.1",ptt="parser.quantifier.2",gtt="parser.quantifier.3",mtt="parser.quantifier.4",Dxe="parser.quantifier.5",btt="org.eclipse.emf.common.notify",Bxe={380:1,610:1},wtt={3:1,4:1,20:1,25:1,41:1,13:1,15:1,59:1,52:1},o5={338:1,136:1},RP="index=",_z=", size=",kre={3:1,4:1,5:1,116:1},vtt={3:1,4:1,20:1,25:1,41:1,13:1,15:1,49:1,59:1,52:1},Oxe={3:1,6:1,4:1,5:1,175:1},_tt={3:1,4:1,5:1,339:1},ytt=";/?:@&=+$,",xtt="invalid authority: ",Ett="EAnnotation",Stt="ETypedElement",Mtt="EStructuralFeature",Ttt="EAttribute",Ctt="EClassifier",Att="EEnumLiteral",Ptt="EGenericType",Ltt="EOperation",ktt="EParameter",Rtt="EReference",Itt="ETypeParameter",or="org.eclipse.emf.ecore.util",Nxe={3:1,20:1,13:1,15:1,52:1,533:1,81:1,64:1},Dtt="org.eclipse.emf.ecore.util.FeatureMap$Entry",tf=1024,yc=8192,Dw=2048,IP="byte",yz="char",DP="double",BP="float",OP="int",NP="long",FP="short",Btt="java.lang.Object",oy={3:1,4:1,5:1,222:1},Fxe={3:1,4:1,5:1,611:1},Ott={3:1,4:1,20:1,25:1,41:1,13:1,15:1,49:1,59:1,55:1,52:1,64:1},Ho={3:1,4:1,20:1,25:1,41:1,13:1,15:1,49:1,59:1,55:1,52:1,81:1,64:1},a5="mixed",Kn="http:///org/eclipse/emf/ecore/util/ExtendedMetaData",bu="kind",Ntt={3:1,4:1,5:1,612:1},Uxe={3:1,4:1,20:1,25:1,41:1,13:1,15:1,59:1,52:1,81:1,64:1},xz={20:1,25:1,41:1,13:1,15:1,52:1,64:1},Ez={43:1,120:1,260:1},Sz={75:1,311:1},Mz="The value of type '",Tz="' must be of type '",ay=1365,wu="http://www.eclipse.org/emf/2002/Ecore",Cz=-32768,Z0="constraints",Ls="baseType",Ftt="getEStructuralFeature",Utt="getFeatureID",UP="feature",ztt="getOperationID",zxe="operation",Gtt="defaultValue",jtt="eTypeParameters",$tt="isInstance",Vtt="getEEnumLiteral",Wtt="eContainingClass",li={47:1},Htt={3:1,4:1,5:1,124:1},qtt="org.eclipse.emf.ecore.resource",Xtt={91:1,87:1,534:1,1628:1},Rre="org.eclipse.emf.ecore.resource.impl",Gxe="unspecified",c5="simple",Az="attribute",Ytt="attributeWildcard",Pz="element",Ire="elementWildcard",Lf="collapse",Dre="itemType",Lz="namespace",l5="##targetNamespace",vu="whiteSpace",jxe="wildcards",v1="http://www.eclipse.org/emf/2003/XMLType",Bre="##any",iM="uninitialized",Ore="The multiplicity constraint is violated",kz="org.eclipse.emf.ecore.xml.type",Ztt="ProcessingInstruction",Ktt="SimpleAnyType",Jtt="XMLTypeDocumentRoot",$r="org.eclipse.emf.ecore.xml.type.impl",u5="INF",Qtt="processing",ent="ENTITIES_._base",$xe="minLength",Vxe="ENTITY",Rz="NCName",tnt="IDREFS_._base",Wxe="integer",Nre="token",Fre="pattern",nnt="[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*",Hxe="\\i\\c*",int="[\\i-[:]][\\c-[:]]*",rnt="nonPositiveInteger",f5="maxInclusive",qxe="NMTOKEN",snt="NMTOKENS_._base",Xxe="nonNegativeInteger",h5="minInclusive",ont="normalizedString",ant="unsignedByte",cnt="unsignedInt",lnt="18446744073709551615",unt="unsignedShort",fnt="processingInstruction",Xp="org.eclipse.emf.ecore.xml.type.internal",rM=1114111,hnt="Internal Error: shorthands: \\u",zP="xml:isDigit",Ure="xml:isWord",zre="xml:isSpace",Gre="xml:isNameChar",jre="xml:isInitialNameChar",dnt="09\u0660\u0669\u06F0\u06F9\u0966\u096F\u09E6\u09EF\u0A66\u0A6F\u0AE6\u0AEF\u0B66\u0B6F\u0BE7\u0BEF\u0C66\u0C6F\u0CE6\u0CEF\u0D66\u0D6F\u0E50\u0E59\u0ED0\u0ED9\u0F20\u0F29",pnt="AZaz\xC0\xD6\xD8\xF6\xF8\u0131\u0134\u013E\u0141\u0148\u014A\u017E\u0180\u01C3\u01CD\u01F0\u01F4\u01F5\u01FA\u0217\u0250\u02A8\u02BB\u02C1\u0386\u0386\u0388\u038A\u038C\u038C\u038E\u03A1\u03A3\u03CE\u03D0\u03D6\u03DA\u03DA\u03DC\u03DC\u03DE\u03DE\u03E0\u03E0\u03E2\u03F3\u0401\u040C\u040E\u044F\u0451\u045C\u045E\u0481\u0490\u04C4\u04C7\u04C8\u04CB\u04CC\u04D0\u04EB\u04EE\u04F5\u04F8\u04F9\u0531\u0556\u0559\u0559\u0561\u0586\u05D0\u05EA\u05F0\u05F2\u0621\u063A\u0641\u064A\u0671\u06B7\u06BA\u06BE\u06C0\u06CE\u06D0\u06D3\u06D5\u06D5\u06E5\u06E6\u0905\u0939\u093D\u093D\u0958\u0961\u0985\u098C\u098F\u0990\u0993\u09A8\u09AA\u09B0\u09B2\u09B2\u09B6\u09B9\u09DC\u09DD\u09DF\u09E1\u09F0\u09F1\u0A05\u0A0A\u0A0F\u0A10\u0A13\u0A28\u0A2A\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59\u0A5C\u0A5E\u0A5E\u0A72\u0A74\u0A85\u0A8B\u0A8D\u0A8D\u0A8F\u0A91\u0A93\u0AA8\u0AAA\u0AB0\u0AB2\u0AB3\u0AB5\u0AB9\u0ABD\u0ABD\u0AE0\u0AE0\u0B05\u0B0C\u0B0F\u0B10\u0B13\u0B28\u0B2A\u0B30\u0B32\u0B33\u0B36\u0B39\u0B3D\u0B3D\u0B5C\u0B5D\u0B5F\u0B61\u0B85\u0B8A\u0B8E\u0B90\u0B92\u0B95\u0B99\u0B9A\u0B9C\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8\u0BAA\u0BAE\u0BB5\u0BB7\u0BB9\u0C05\u0C0C\u0C0E\u0C10\u0C12\u0C28\u0C2A\u0C33\u0C35\u0C39\u0C60\u0C61\u0C85\u0C8C\u0C8E\u0C90\u0C92\u0CA8\u0CAA\u0CB3\u0CB5\u0CB9\u0CDE\u0CDE\u0CE0\u0CE1\u0D05\u0D0C\u0D0E\u0D10\u0D12\u0D28\u0D2A\u0D39\u0D60\u0D61\u0E01\u0E2E\u0E30\u0E30\u0E32\u0E33\u0E40\u0E45\u0E81\u0E82\u0E84\u0E84\u0E87\u0E88\u0E8A\u0E8A\u0E8D\u0E8D\u0E94\u0E97\u0E99\u0E9F\u0EA1\u0EA3\u0EA5\u0EA5\u0EA7\u0EA7\u0EAA\u0EAB\u0EAD\u0EAE\u0EB0\u0EB0\u0EB2\u0EB3\u0EBD\u0EBD\u0EC0\u0EC4\u0F40\u0F47\u0F49\u0F69\u10A0\u10C5\u10D0\u10F6\u1100\u1100\u1102\u1103\u1105\u1107\u1109\u1109\u110B\u110C\u110E\u1112\u113C\u113C\u113E\u113E\u1140\u1140\u114C\u114C\u114E\u114E\u1150\u1150\u1154\u1155\u1159\u1159\u115F\u1161\u1163\u1163\u1165\u1165\u1167\u1167\u1169\u1169\u116D\u116E\u1172\u1173\u1175\u1175\u119E\u119E\u11A8\u11A8\u11AB\u11AB\u11AE\u11AF\u11B7\u11B8\u11BA\u11BA\u11BC\u11C2\u11EB\u11EB\u11F0\u11F0\u11F9\u11F9\u1E00\u1E9B\u1EA0\u1EF9\u1F00\u1F15\u1F18\u1F1D\u1F20\u1F45\u1F48\u1F4D\u1F50\u1F57\u1F59\u1F59\u1F5B\u1F5B\u1F5D\u1F5D\u1F5F\u1F7D\u1F80\u1FB4\u1FB6\u1FBC\u1FBE\u1FBE\u1FC2\u1FC4\u1FC6\u1FCC\u1FD0\u1FD3\u1FD6\u1FDB\u1FE0\u1FEC\u1FF2\u1FF4\u1FF6\u1FFC\u2126\u2126\u212A\u212B\u212E\u212E\u2180\u2182\u3007\u3007\u3021\u3029\u3041\u3094\u30A1\u30FA\u3105\u312C\u4E00\u9FA5\uAC00\uD7A3",gnt="Private Use",$re="ASSIGNED",mnt="\0\x7F\x80\xFF\u0100\u017F\u0180\u024F\u0250\u02AF\u02B0\u02FF\u0300\u036F\u0370\u03FF\u0400\u04FF\u0530\u058F\u0590\u05FF\u0600\u06FF\u0700\u074F\u0780\u07BF\u0900\u097F\u0980\u09FF\u0A00\u0A7F\u0A80\u0AFF\u0B00\u0B7F\u0B80\u0BFF\u0C00\u0C7F\u0C80\u0CFF\u0D00\u0D7F\u0D80\u0DFF\u0E00\u0E7F\u0E80\u0EFF\u0F00\u0FFF\u1000\u109F\u10A0\u10FF\u1100\u11FF\u1200\u137F\u13A0\u13FF\u1400\u167F\u1680\u169F\u16A0\u16FF\u1780\u17FF\u1800\u18AF\u1E00\u1EFF\u1F00\u1FFF\u2000\u206F\u2070\u209F\u20A0\u20CF\u20D0\u20FF\u2100\u214F\u2150\u218F\u2190\u21FF\u2200\u22FF\u2300\u23FF\u2400\u243F\u2440\u245F\u2460\u24FF\u2500\u257F\u2580\u259F\u25A0\u25FF\u2600\u26FF\u2700\u27BF\u2800\u28FF\u2E80\u2EFF\u2F00\u2FDF\u2FF0\u2FFF\u3000\u303F\u3040\u309F\u30A0\u30FF\u3100\u312F\u3130\u318F\u3190\u319F\u31A0\u31BF\u3200\u32FF\u3300\u33FF\u3400\u4DB5\u4E00\u9FFF\uA000\uA48F\uA490\uA4CF\uAC00\uD7A3\uE000\uF8FF\uF900\uFAFF\uFB00\uFB4F\uFB50\uFDFF\uFE20\uFE2F\uFE30\uFE4F\uFE50\uFE6F\uFE70\uFEFE\uFEFF\uFEFF\uFF00\uFFEF",Yxe="UNASSIGNED",sM={3:1,112:1},bnt="org.eclipse.emf.ecore.xml.type.util",Iz={3:1,4:1,5:1,342:1},Zxe="org.eclipse.xtext.xbase.lib",wnt="Cannot add elements to a Range",vnt="Cannot set elements in a Range",_nt="Cannot remove elements from a Range",Dz="locale",Bz="default",Oz="user.agent",p,Nz,Vre,K$t=-1;W6t(),A(1,null,{},L),p.Fb=function(t){return this===t},p.Gb=function(){return this.ql},p.Hb=function(){return m0(this)},p.Ib=function(){return Um(sl(this))+"@"+(Hr(this)>>>0).toString(16)},p.equals=function(e){return this.Fb(e)},p.hashCode=function(){return this.Hb()},p.toString=function(){return this.Ib()};var ynt,xnt,Ent;A(274,1,{274:1,1712:1},wbe),p._d=function(t){var i;return i=new wbe,i.i=4,t>1?i.c=a7e(this,t-1):i.c=this,i},p.ae=function(){return Fd(this),this.b},p.be=function(){return Um(this)},p.ce=function(){return Fd(this),this.k},p.de=function(){return(this.i&4)!=0},p.ee=function(){return(this.i&1)!=0},p.Ib=function(){return N0e(this)},p.i=0;var J$t=1,on=k(da,"Object",1),Kxe=k(da,"Class",274);A(1692,1,{3:1});var sgn=k(X_,"Optional",1692);A(1060,1692,{3:1},I),p.Fb=function(t){return t===this},p.Hb=function(){return 2040732332},p.Ib=function(){return"Optional.absent()"},p.Jb=function(t){return Hn(t),Ur(),Wre};var Wre,ogn=k(X_,"Absent",1060),Q$t=_r(X_,"Function");A(393,1,{},LR),p.Lb=function(t){return Y9e(t)};var agn=k(X_,"Joiner",393);A(875,393,{},e9e),p.Lb=function(t){return t==null?this.b:Y9e(t)};var cgn=k(X_,"Joiner/1",875);A(874,1,{},vY);var lgn=k(X_,"Joiner/MapJoiner",874),eVt=_r(X_,"Predicate"),Snt;A(494,1,{138:1,494:1,3:1,56:1},KX),p.Nb=function(t){return this.Mb(t)},p.Mb=function(t){var i;for(i=0;i0},p.ic=function(){if(this.b>=this.c)throw Y(new K);return wBe(this,this.b++)},p.Dc=function(){return this.b},p.Ec=function(){if(this.b<=0)throw Y(new K);return wBe(this,--this.b)},p.Fc=function(){return this.b-1},p.b=0,p.c=0;var Cgn=k(At,"AbstractIndexedListIterator",847);A(949,257,$7),p.hc=function(){return S_(this)},p.ic=function(){return px(this)},p.d=1;var Agn=k(At,"AbstractIterator",949);A(1677,1,{238:1}),p.Hc=function(){var t;return t=this.f,t||(this.f=this.Ic())},p.Jc=function(){return new MK(this.Hc())},p.Lc=function(){return new PGe(this.Kc(),this._b(),re(this,475)?1:0)},p.Fb=function(t){return kee(this,t)},p.Hb=function(){return Hr(this.Hc())},p.Wb=function(){return this._b()==0},p.Xb=function(){return i1e(this)},p.Ib=function(){return Ga(this.Hc())};var Pgn=k(At,"AbstractMultimap",1677);A(654,1677,One),p.Pb=function(){K0e(this)},p.Qb=function(t){return this.c.Qb(t)},p.Ic=function(){return re(this.c,122)?new nA(this,h(this.c,122)):re(this.c,115)?new YE(this,h(this.c,115)):new FE(this,this.c)},p.Pc=function(t){return this.Oc()},p.Jc=function(){return re(this.c,122)?new Zv(this,h(this.c,122)):re(this.c,115)?new X2(this,h(this.c,115)):new XE(this,this.c)},p.Qc=function(){return jDt(this.Oc())},p.Kc=function(){return new IDe(this)},p.Lc=function(){return Kwe(this.c.Tb().wc(),new Z,64,this.d)},p.Mc=function(t){return er(this,t)},p.Nc=function(t){return aP(this,t)},p._b=function(){return this.d},p.Rc=function(){return new RDe(this)},p.Sc=function(){return Kwe(this.c.ac().wc(),new D,64,this.d)},p.d=0;var Lgn=k(At,"AbstractMapBasedMultimap",654);A(1483,654,One),p.Oc=function(){return new Gl(this.a)},p.Qc=function(){return lA(),lA(),e3e},p.Mc=function(t){return h(er(this,t),15)},p.Nc=function(t){return h(aP(this,t),15)},p.Hc=function(){var t;return t=this.f,t||(this.f=re(this.c,122)?new nA(this,h(this.c,122)):re(this.c,115)?new YE(this,h(this.c,115)):new FE(this,this.c))},p.Fb=function(t){return kee(this,t)},p.Tc=function(t){return h(er(this,t),15)},p.Uc=function(t){return h(aP(this,t),15)};var kgn=k(At,"AbstractListMultimap",1483);A(661,1,ys),p.gc=function(t){Ss(this,t)},p.hc=function(){return this.c.hc()||this.e.hc()},p.ic=function(){var t;return this.e.hc()||(t=h(this.c.ic(),38),this.b=t.kc(),this.a=h(t.lc(),13),this.e=this.a.tc()),this.Vc(this.b,this.e.ic())},p.jc=function(){this.e.jc(),this.a.Wb()&&this.c.jc(),--this.d.d};var Rgn=k(At,"AbstractMapBasedMultimap/Itr",661);A(970,661,ys,RDe),p.Vc=function(t,i){return i};var Ign=k(At,"AbstractMapBasedMultimap/1",970);A(971,1,gs,D),p.Kb=function(t){return h(t,13).wc()};var Dgn=k(At,"AbstractMapBasedMultimap/1methodref$spliterator$Type",971);A(972,661,ys,IDe),p.Vc=function(t,i){return Yr(),new DR(t,i)};var Bgn=k(At,"AbstractMapBasedMultimap/2",972);A(1666,1,$S),p.Ub=function(t){vee(this,t)},p.Yb=function(t,i,a){return Vbe(this,t,i,a)},p.Pb=function(){this.Tb().Pb()},p.Wc=function(t){return xte(this,t)},p.Qb=function(t){return!!qwe(this,t,!1)},p.Rb=function(t){var i,a,l;for(a=this.Tb().tc();a.hc();)if(i=h(a.ic(),38),l=i.lc(),Be(t)===Be(l)||t!=null&&ki(t,l))return!0;return!1},p.Fb=function(t){return Xqe(this,t)},p.Vb=function(t){return Dc(qwe(this,t,!1))},p.Hb=function(){return mbe(this.Tb())},p.Wb=function(){return this._b()==0},p.Xb=function(){return new Gv(this)},p.Zb=function(t,i){throw Y(new Cp("Put not supported on this map"))},p.$b=function(t){return Dc(qwe(this,t,!0))},p._b=function(){return this.Tb()._b()},p.Ib=function(){var t,i,a;for(a=new P0("{","}"),i=this.Tb().tc();i.hc();)t=h(i.ic(),38),Xm(a,JUe(this,t.kc())+"="+JUe(this,t.lc()));return a.a?a.e.length==0?a.a.a:a.a.a+(""+a.e):a.c},p.ac=function(){return new bh(this)};var Ogn=k(Vn,"AbstractMap",1666);A(1678,1666,$S),p.Jc=function(){return new MK(this)},p.Tb=function(){return n1e(this)},p.Xb=function(){var t;return t=this.g,t||(this.g=this.Jc())},p.ac=function(){var t;return t=this.i,t||(this.i=new lOe(this))};var Ngn=k(At,"Maps/ViewCachingAbstractMap",1678);A(357,1678,$S,FE),p.Vb=function(t){return kkt(this,t)},p.$b=function(t){return AIt(this,t)},p.Pb=function(){this.d==this.e.c?this.e.Pb():N9(new Vme(this))},p.Qb=function(t){return k5t(this.d,t)},p.Yc=function(){return new JX(this)},p.Xc=function(){return this.Yc()},p.Fb=function(t){return this===t||ki(this.d,t)},p.Hb=function(){return Hr(this.d)},p.Xb=function(){return this.e.Xb()},p._b=function(){return this.d._b()},p.Ib=function(){return Ga(this.d)};var Fgn=k(At,"AbstractMapBasedMultimap/AsMap",357);A(25,1,Y_),p.sc=function(t){mo(this,t)},p.uc=function(){return new oi(null,this.wc())},p.wc=function(){return new di(this,0)},p.xc=function(){return new oi(null,this.wc())},p.nc=function(t){throw Y(new Cp("Add not supported on this collection"))},p.oc=function(t){return wo(this,t)},p.Pb=function(){bI(this)},p.pc=function(t){return _x(this,t,!1)},p.qc=function(t){return Gg(this,t)},p.Wb=function(){return this._b()==0},p.vc=function(t){return _x(this,t,!0)},p.yc=function(){return VJ(this)},p.zc=function(t){return u6(this,t)},p.Ib=function(){return Vp(this)};var Ugn=k(Vn,"AbstractCollection",25);A(fd,25,gu),p.wc=function(){return new di(this,1)},p.Fb=function(t){return TWe(this,t)},p.Hb=function(){return mbe(this)};var zgn=k(Vn,"AbstractSet",fd);A(1660,fd,gu);var Ggn=k(At,"Sets/ImprovedAbstractSet",1660);A(1679,1660,gu),p.Pb=function(){this.Zc().Pb()},p.pc=function(t){return IWe(this,t)},p.Wb=function(){return this.Zc().Wb()},p.vc=function(t){var i;return this.pc(t)?(i=h(t,38),this.Zc().Xb().vc(i.kc())):!1},p._b=function(){return this.Zc()._b()};var jgn=k(At,"Maps/EntrySet",1679);A(968,1679,gu,JX),p.pc=function(t){return rHe(this.a.d.Tb(),t)},p.tc=function(){return new Vme(this.a)},p.Zc=function(){return this.a},p.vc=function(t){var i;return rHe(this.a.d.Tb(),t)?(i=h(t,38),j4t(this.a.e,i.kc()),!0):!1},p.wc=function(){return UJ(this.a.d.Tb().wc(),new QX(this.a))};var $gn=k(At,"AbstractMapBasedMultimap/AsMap/AsMapEntries",968);A(969,1,gs,QX),p.Kb=function(t){return UGe(this.a,h(t,38))};var Vgn=k(At,"AbstractMapBasedMultimap/AsMap/AsMapEntries/0methodref$wrapEntry$Type",969);A(659,1,ys,Vme),p.gc=function(t){Ss(this,t)},p.ic=function(){var t;return t=h(this.b.ic(),38),this.a=h(t.lc(),13),UGe(this.c,t)},p.hc=function(){return this.b.hc()},p.jc=function(){this.b.jc(),this.c.e.d-=this.a._b(),this.a.Pb()};var Wgn=k(At,"AbstractMapBasedMultimap/AsMap/AsMapIterator",659);A(541,1660,gu,MK),p.Pb=function(){this.b.Pb()},p.pc=function(t){return this.b.Qb(t)},p.sc=function(t){Hn(t),this.b.Ub(new rY(t))},p.Wb=function(){return this.b.Wb()},p.tc=function(){return Yr(),rA(this.b.Tb().tc(),(i_(),d5))},p.vc=function(t){return this.b.Qb(t)?(this.b.$b(t),!0):!1},p._b=function(){return this.b._b()};var Hgn=k(At,"Maps/KeySet",541);A(356,541,gu,XE),p.Pb=function(){var t;N9((t=this.b.Tb().tc(),new Fpe(this,t)))},p.qc=function(t){return this.b.Xb().qc(t)},p.Fb=function(t){return this===t||ki(this.b.Xb(),t)},p.Hb=function(){return Hr(this.b.Xb())},p.tc=function(){var t;return t=this.b.Tb().tc(),new Fpe(this,t)},p.vc=function(t){var i,a;return a=0,i=h(this.b.$b(t),13),i&&(a=i._b(),i.Pb(),this.a.d-=a),a>0},p.wc=function(){return this.b.Xb().wc()};var qgn=k(At,"AbstractMapBasedMultimap/KeySet",356);A(660,1,ys,Fpe),p.gc=function(t){Ss(this,t)},p.hc=function(){return this.c.hc()},p.ic=function(){return this.a=h(this.c.ic(),38),this.a.kc()},p.jc=function(){var t;Ag(!!this.a,Aw),t=h(this.a.lc(),13),this.c.jc(),this.b.a.d-=t._b(),t.Pb()};var Xgn=k(At,"AbstractMapBasedMultimap/KeySet/1",660);A(358,357,{109:1,115:1},YE),p.Jc=function(){return this.$c()},p.Xb=function(){return this._c()},p.$c=function(){return new X2(this.c,this.ad())},p._c=function(){var t;return t=this.b,t||(this.b=this.$c())},p.ad=function(){return h(this.d,115)};var Ygn=k(At,"AbstractMapBasedMultimap/SortedAsMap",358);A(396,358,EJe,nA),p.$c=function(){return new Zv(this.a,h(h(this.d,115),122))},p.Xb=function(){var t;return t=this.b,h(t||(this.b=new Zv(this.a,h(h(this.d,115),122))),196)},p._c=function(){var t;return t=this.b,h(t||(this.b=new Zv(this.a,h(h(this.d,115),122))),196)},p.ad=function(){return h(h(this.d,115),122)};var Zgn=k(At,"AbstractMapBasedMultimap/NavigableAsMap",396);A(327,356,SJe,X2),p.wc=function(){return this.b.Xb().wc()};var Kgn=k(At,"AbstractMapBasedMultimap/SortedKeySet",327);A(299,327,V_e,Zv);var Jgn=k(At,"AbstractMapBasedMultimap/NavigableKeySet",299);A(448,25,Y_,TI),p.nc=function(t){var i,a;return ol(this),a=this.d.Wb(),i=this.d.nc(t),i&&(++this.f.d,a&&o9(this)),i},p.oc=function(t){var i,a,l;return t.Wb()?!1:(l=(ol(this),this.d._b()),i=this.d.oc(t),i&&(a=this.d._b(),this.f.d+=a-l,l==0&&o9(this)),i)},p.Pb=function(){var t;t=(ol(this),this.d._b()),t!=0&&(this.d.Pb(),this.f.d-=t,k9(this))},p.pc=function(t){return ol(this),this.d.pc(t)},p.qc=function(t){return ol(this),this.d.qc(t)},p.Fb=function(t){return t===this?!0:(ol(this),ki(this.d,t))},p.Hb=function(){return ol(this),Hr(this.d)},p.tc=function(){return ol(this),new Rme(this)},p.vc=function(t){var i;return ol(this),i=this.d.vc(t),i&&(--this.f.d,k9(this)),i},p._b=function(){return ANe(this)},p.wc=function(){return ol(this),this.d.wc()},p.Ib=function(){return ol(this),Ga(this.d)};var Qgn=k(At,"AbstractMapBasedMultimap/WrappedCollection",448),yu=_r(Vn,"List");A(657,448,{20:1,25:1,13:1,15:1},t1e),p.jd=function(t){Ug(this,t)},p.wc=function(){return ol(this),this.d.wc()},p.bd=function(t,i){var a;ol(this),a=this.d.Wb(),h(this.d,15).bd(t,i),++this.a.d,a&&o9(this)},p.cd=function(t){return ol(this),h(this.d,15).cd(t)},p.dd=function(t){return ol(this),h(this.d,15).dd(t)},p.ed=function(){return ol(this),new KNe(this)},p.fd=function(t){return ol(this),new DUe(this,t)},p.gd=function(t){var i;return ol(this),i=h(this.d,15).gd(t),--this.a.d,k9(this),i},p.hd=function(t,i){return ol(this),h(this.d,15).hd(t,i)},p.kd=function(t,i){return ol(this),Q1e(this.a,this.e,h(this.d,15).kd(t,i),this.b?this.b:this)};var emn=k(At,"AbstractMapBasedMultimap/WrappedList",657);A(967,657,{20:1,25:1,13:1,15:1,49:1},IFe);var tmn=k(At,"AbstractMapBasedMultimap/RandomAccessWrappedList",967);A(558,1,ys,Rme),p.gc=function(t){Ss(this,t)},p.hc=function(){return nS(this),this.b.hc()},p.ic=function(){return nS(this),this.b.ic()},p.jc=function(){yFe(this)};var nmn=k(At,"AbstractMapBasedMultimap/WrappedCollection/WrappedIterator",558);A(658,558,Ch,KNe,DUe),p.jc=function(){yFe(this)},p.Bc=function(t){var i;i=ANe(this.a)==0,(nS(this),h(this.b,120)).Bc(t),++this.a.a.d,i&&o9(this.a)},p.Cc=function(){return(nS(this),h(this.b,120)).Cc()},p.Dc=function(){return(nS(this),h(this.b,120)).Dc()},p.Ec=function(){return(nS(this),h(this.b,120)).Ec()},p.Fc=function(){return(nS(this),h(this.b,120)).Fc()},p.Gc=function(t){(nS(this),h(this.b,120)).Gc(t)};var imn=k(At,"AbstractMapBasedMultimap/WrappedList/WrappedListIterator",658);A(559,448,SJe,xJ),p.wc=function(){return ol(this),this.d.wc()};var rmn=k(At,"AbstractMapBasedMultimap/WrappedSortedSet",559);A(656,559,V_e,xge);var smn=k(At,"AbstractMapBasedMultimap/WrappedNavigableSet",656);A(655,448,gu,Qge),p.wc=function(){return ol(this),this.d.wc()};var omn=k(At,"AbstractMapBasedMultimap/WrappedSet",655);A(974,1,gs,Z),p.Kb=function(t){var i,a;return i=t.kc(),a=h(t.lc(),13),UJ(a.wc(),new eY(i))};var amn=k(At,"AbstractMapBasedMultimap/lambda$0$Type",974);A(973,1,gs,eY),p.Kb=function(t){return jSt(this.a,t)};var cmn=k(At,"AbstractMapBasedMultimap/lambda$2$Type",973);A(392,1,Nne),p.Fb=function(t){var i;return re(t,38)?(i=h(t,38),Dp(this.kc(),i.kc())&&Dp(this.lc(),i.lc())):!1},p.Hb=function(){var t,i;return t=this.kc(),i=this.lc(),(t==null?0:Hr(t))^(i==null?0:Hr(i))},p.mc=function(t){throw Y(new Pi)},p.Ib=function(){return this.kc()+"="+this.lc()};var lmn=k(At,MJe,392);A(1680,25,Y_),p.Pb=function(){this.ld().Pb()},p.pc=function(t){var i;return re(t,38)?(i=h(t,38),WLt(this.ld(),i.kc(),i.lc())):!1},p.vc=function(t){var i;return re(t,38)?(i=h(t,38),J7e(this.ld(),i.kc(),i.lc())):!1},p._b=function(){return this.ld()._b()};var umn=k(At,"Multimaps/Entries",1680);A(975,1680,Y_),p.tc=function(){return this.a.Kc()},p.ld=function(){return this.a},p.wc=function(){return this.a.Lc()};var fmn=k(At,"AbstractMultimap/Entries",975);A(662,975,gu,mF),p.wc=function(){return this.a.Lc()},p.Fb=function(t){return sXe(this,t)},p.Hb=function(){return k$e(this)};var hmn=k(At,"AbstractMultimap/EntrySet",662);A(663,25,Y_,kd),p.Pb=function(){this.a.Pb()},p.pc=function(t){return SIt(this.a,t)},p.tc=function(){return this.a.Rc()},p._b=function(){return this.a.d},p.wc=function(){return this.a.Sc()};var dmn=k(At,"AbstractMultimap/Values",663);A(1681,25,{738:1,20:1,25:1,13:1}),p.sc=function(t){Hn(t),hw(this).sc(new hY(t))},p.wc=function(){var t;return t=hw(this).wc(),Kwe(t,new Te,64|t.qd()&1296,zee(this))},p.nc=function(t){return bpe(),!0},p.oc=function(t){return LOt(this,t)},p.Pb=function(){N9(new dpe(n1e(y0(this.a)).tc()))},p.pc=function(t){var i;return i=h(AS(y0(this.a),t),13),(i?i._b():0)>0},p.Fb=function(t){return v8t(this,t)},p.Hb=function(){return Hr(hw(this))},p.Wb=function(){return hw(this).Wb()},p.tc=function(){return new QBe(this,hw(this).tc())},p.vc=function(t){return vve(this,t,1)>0},p._b=function(){return zee(this)},p.Ib=function(){return Ga(hw(this))};var pmn=k(At,"AbstractMultiset",1681);A(557,654,F6),p.Oc=function(){return this.md()},p.Qc=function(){return this.nd()},p.Mc=function(t){return this.od(t)},p.Nc=function(t){return this.pd(t)},p.Hc=function(){var t;return t=this.f,t||(this.f=re(this.c,122)?new nA(this,h(this.c,122)):re(this.c,115)?new YE(this,h(this.c,115)):new FE(this,this.c))},p.nd=function(){return lw(),tS(),GP},p.Fb=function(t){return kee(this,t)},p.od=function(t){return h(er(this,t),19)},p.pd=function(t){return h(aP(this,t),19)};var gmn=k(At,"AbstractSetMultimap",557);A(1413,557,F6),p.md=function(){return new iw(this.b)},p.nd=function(){var t;return t=this.b,t?LPt(this.b):(_t(),new KR(new iw(this.b)))},p.Mc=function(t){return h(h(er(this,t),19),60)},p.od=function(t){return h(h(er(this,t),19),60)},p.Nc=function(t){return h(h(aP(this,t),19),60)},p.pd=function(t){return h(h(aP(this,t),19),60)},p.Hc=function(){var t;return t=this.f,t||(this.f=re(this.c,122)?new nA(this,h(this.c,122)):re(this.c,115)?new YE(this,h(this.c,115)):new FE(this,this.c))};var mmn=k(At,"AbstractSortedSetMultimap",1413);A(1414,1413,F6),p.Hc=function(){var t;return t=this.f,h(h(t||(this.f=re(this.c,122)?new nA(this,h(this.c,122)):re(this.c,115)?new YE(this,h(this.c,115)):new FE(this,this.c)),115),122)},p.Xb=function(){var t;return t=this.i,h(h(t||(this.i=re(this.c,122)?new Zv(this,h(this.c,122)):re(this.c,115)?new X2(this,h(this.c,115)):new XE(this,this.c)),60),196)};var bmn=k(At,"AbstractSortedKeySortedSetMultimap",1414);A(521,1483,One,s9),p.a=0;var wmn=k(At,"ArrayListMultimap",521);A(1156,1,Wp,GBe),p.qd=function(){return this.a.qd()&-262},p.rd=function(){return this.a.rd()},p.gc=function(t){this.a.gc(new $Be(t,this.b))},p.sd=function(t){return this.a.sd(new jBe(t,this.b))};var vmn=k(At,"CollectSpliterators/1",1156);A(1157,1,{},jBe),p.td=function(t){this.a.td(this.b.Kb(t))};var _mn=k(At,"CollectSpliterators/1/lambda$0$Type",1157);A(1158,1,{},$Be),p.td=function(t){this.a.td(this.b.Kb(t))};var ymn=k(At,"CollectSpliterators/1/lambda$1$Type",1158);A(1159,1,Wp,fze),p.qd=function(){return this.a},p.rd=function(){return this.d&&(this.b=INe(this.b,this.d.rd())),INe(this.b,0)},p.gc=function(t){this.d&&(this.d.gc(t),this.d=null),this.c.gc(new WBe(this.e,t)),this.b=0},p.sd=function(t){for(;;){if(this.d&&this.d.sd(t))return kC(this.b,V7)&&(this.b=Qm(this.b,1)),!0;if(this.d=null,!this.c.sd(new VBe(this,this.e)))return!1}},p.a=0,p.b=0;var xmn=k(At,"CollectSpliterators/1FlatMapSpliterator",1159);A(1160,1,{},VBe),p.td=function(t){KMt(this.a,this.b,t)};var Emn=k(At,"CollectSpliterators/1FlatMapSpliterator/lambda$0$Type",1160);A(1161,1,{},WBe),p.td=function(t){HSt(this.b,this.a,t)};var Smn=k(At,"CollectSpliterators/1FlatMapSpliterator/lambda$1$Type",1161),Qxe;A(844,1,Qu,nY),p.Fb=function(t){return this===t},p.Kb=function(t){return Be(t)===Be(this.a)?xJe:t};var Mmn=k(At,"Collections2/1",844);A(220,1,Fne),p.vd=function(t){return this.ud(h(t,220))},p.ud=function(t){var i;return t==(so(),qre)?1:t==(Wr(),Hre)?-1:(i=(m9(),LA(this.a,t.a)),i!=0?i:re(this,467)==re(t,467)?0:re(this,467)?1:-1)},p.yd=function(){return this.a},p.Fb=function(t){return rwe(this,t)};var Tmn=k(At,"Cut",220);A(1508,220,Fne,rBe),p.ud=function(t){return t==this?0:1},p.wd=function(t){throw Y(new s8)},p.xd=function(t){t.a+="+\u221E)"},p.yd=function(){throw Y(new ba(TJe))},p.zd=function(t){return!1},p.Ib=function(){return"+\u221E"};var Hre,Cmn=k(At,"Cut/AboveAll",1508);A(467,220,{220:1,467:1,3:1,34:1},SFe),p.wd=function(t){Ic((t.a+="(",t),this.a)},p.xd=function(t){Lg(Ic(t,this.a),93)},p.Hb=function(){return~Hr(this.a)},p.zd=function(t){return m9(),LA(this.a,t)<0},p.Ib=function(){return"/"+this.a+"\\"};var Amn=k(At,"Cut/AboveValue",467);A(1507,220,Fne,sBe),p.ud=function(t){return t==this?0:-1},p.wd=function(t){t.a+="(-\u221E"},p.xd=function(t){throw Y(new s8)},p.yd=function(){throw Y(new ba(TJe))},p.zd=function(t){return!0},p.Ib=function(){return"-\u221E"};var qre,Pmn=k(At,"Cut/BelowAll",1507);A(1509,220,Fne,MFe),p.wd=function(t){Ic((t.a+="[",t),this.a)},p.xd=function(t){Lg(Ic(t,this.a),41)},p.Hb=function(){return Hr(this.a)},p.zd=function(t){return m9(),LA(this.a,t)<=0},p.Ib=function(){return"\\"+this.a+"/"};var Lmn=k(At,"Cut/BelowValue",1509);A(482,1,hd),p.sc=function(t){mo(this,t)},p.Ib=function(){return NLt(h(A1e(this,"use Optional.orNull() instead of Optional.or(null)"),20).tc())};var kmn=k(At,"FluentIterable",482);A(325,482,hd,ex),p.tc=function(){return Cn(this)};var Rmn=k(At,"FluentIterable/2",325);A(1670,25,CJe),p.tc=function(){return this.Ad()},p.nc=function(t){throw Y(new Pi)},p.oc=function(t){throw Y(new Pi)},p.Pb=function(){throw Y(new Pi)},p.pc=function(t){return t!=null&&_x(this,t,!1)},p.vc=function(t){throw Y(new Pi)};var Imn=k(At,"ImmutableCollection",1670);A(912,1670,CJe,iY),p.tc=function(){return bx((_t(),Yv(),uy))},p.pc=function(t){return!1},p.qc=function(t){return Gg(this.a,t)},p.Wb=function(){return!0},p.Ad=function(){return bx((_t(),Yv(),uy))},p._b=function(){return 0},p.yc=function(){return VJ(this.a)},p.zc=function(t){return u6(this.a,t)},p.Ib=function(){return Vp(this.a)};var Dmn=k(At,"ForwardingImmutableCollection",912);A(193,1670,Une),p.tc=function(){return this.Ad()},p.ed=function(){return new eQ(this,this._b(),0)},p.fd=function(t){return new eQ(this,this._b(),t)},p.jd=function(t){Ug(this,t)},p.wc=function(){return new di(this,16)},p.kd=function(t,i){return this.Bd(t,i)},p.bd=function(t,i){throw Y(new Pi)},p.Fb=function(t){return s8t(this,t)},p.Hb=function(){return ZRt(this)},p.dd=function(t){return t==null?-1:yDt(this,t)},p.Ad=function(){return new eQ(this,this._b(),0)},p.gd=function(t){throw Y(new Pi)},p.hd=function(t,i){throw Y(new Pi)},p.Bd=function(t,i){var a;return Lee((a=new eOe(this),new Rg(a,t,i)))};var e3e,Bmn=k(At,"ImmutableList",193);A(1675,193,Une),p.tc=function(){return bx(this.Cd().tc())},p.kd=function(t,i){return Lee(this.Cd().kd(t,i))},p.pc=function(t){return t!=null&&this.Cd().pc(t)},p.qc=function(t){return this.Cd().qc(t)},p.Fb=function(t){return ki(this.Cd(),t)},p.cd=function(t){return this.Cd().cd(t)},p.Hb=function(){return Hr(this.Cd())},p.dd=function(t){return this.Cd().dd(t)},p.Wb=function(){return this.Cd().Wb()},p.Ad=function(){return bx(this.Cd().tc())},p._b=function(){return this.Cd()._b()},p.Bd=function(t,i){return Lee(this.Cd().kd(t,i))},p.yc=function(){return this.Cd().zc(le(on,et,1,this.Cd()._b(),5,1))},p.zc=function(t){return this.Cd().zc(t)},p.Ib=function(){return Ga(this.Cd())};var Omn=k(At,"ForwardingImmutableList",1675);A(1671,1670,U6),p.tc=function(){return this.Ad()},p.wc=function(){return new di(this,1)},p.Fb=function(t){return sXe(this,t)},p.Hb=function(){return k$e(this)};var Nmn=k(At,"ImmutableSet",1671);A(550,1671,U6),p.tc=function(){return this.Ad()},p.pc=function(t){return t!=null&&RC(this.b,t)},p.qc=function(t){return zpe(this.b,t)},p.Hb=function(){return Hr(this.b.b)},p.Wb=function(){return this.b.b.Wb()},p.Ad=function(){return bx(new Nm(this.b.b.tc()))},p._b=function(){return this.b.b._b()},p.yc=function(){return this.b.b.yc()},p.zc=function(t){return tOe(this.b,t)},p.Ib=function(){return Ga(this.b.b)};var Fmn=k(At,"ForwardingImmutableSet",550);A(1664,1663,AJe),p.Ac=function(){return _t(),new KR(this.a)},p.wc=function(){return new NR(this)};var Umn=k(At,"ForwardingSortedSet",1664);A(481,632,z7,i9),p.ec=function(t){return new S8e(this,t,this)},p.Zb=function(t,i){return eP(this,t,i,!1)};var zmn=k(At,"HashBiMap",481);A(892,633,z7,S8e),p.dc=function(){return new vFe(this,this.a.b.Tb().tc())};var Gmn=k(At,"HashBiMap/1",892);A(479,1,ys),p.gc=function(t){Ss(this,t)},p.hc=function(){return this.b.hc()},p.ic=function(){return _Ne(this)},p.jc=function(){this.b.jc()};var jmn=k(At,"TransformedIterator",479);A(893,479,ys,vFe),p.Ed=function(t){return new X9e(this,h(t,38))},p.Dd=function(e){return this.Ed(e)};var $mn=k(At,"HashBiMap/1/1",893);A(894,392,Nne,X9e),p.kc=function(){return this.c},p.lc=function(){return this.a.a.b.Vb(this.c)},p.mc=function(t){var i;return Ag(Ape(O9(this.a.a),this),$_e),i=this.a.a.b.Vb(this.c),Be(t)===Be(i)||t!=null&&ki(t,i)?t:(eP(this.a.a,this.c,t,!0),i)};var Vmn=k(At,"HashBiMap/1/1/1",894);A(298,557,F6,Kv),p.md=function(){return new m8(Eee(this.a))},p.a=2;var Wmn=k(At,"HashMultimap",298);A(372,392,{392:1,372:1,3:1,38:1},DR),p.kc=function(){return this.g},p.lc=function(){return this.i},p.mc=function(t){throw Y(new Pi)};var Hmn=k(At,"ImmutableEntry",372);A(903,550,U6,DDe);var qmn=k(At,"ImmutableEnumSet",903);A(544,847,Bne,eQ);var Xmn=k(At,"ImmutableList/1",544);A(1561,550,PJe),p.tc=function(){return bx(new Nm(this.b.b.tc()))},p.wc=function(){return new NR(this)},p.pc=function(t){try{return t!=null&&RC(this.a,t)}catch(i){if(i=pr(i),re(i,177))return!1;throw Y(i)}},p.qc=function(t){var i,a;for(a=t.tc();a.hc();)if(i=a.ic(),i==null)return!1;try{return zpe(this.a,t)}catch(l){if(l=pr(l),re(l,177))return!1;throw Y(l)}},p.Ad=function(){return bx(new Nm(this.b.b.tc()))},p.yc=function(){return oje(this,le(on,et,1,this.b.b._b(),5,1))},p.zc=function(t){return $U(this,t)};var Mnt,t3e,Ymn=k(At,"ImmutableSortedSet",1561);A(904,482,hd,NNe),p.tc=function(){return Vge(this.a)},p.Ib=function(){return Vp(this.a)+" (cycled)"};var Zmn=k(At,"Iterables/1",904);A(200,1,Qu,z),p.Kb=function(t){return h(t,20).tc()},p.Fb=function(t){return this===t};var Kmn=k(At,"Iterables/12",200);A(905,482,hd,h9e),p.sc=function(t){Hn(t),this.b.sc(new HBe(this.a,t))},p.tc=function(){return qC(this)};var Jmn=k(At,"Iterables/4",905);A(906,1,{},HBe),p.td=function(t){VEt(this.b,this.a,t)};var Qmn=k(At,"Iterables/4/lambda$0$Type",906);A(907,482,hd,d9e),p.sc=function(t){Hn(t),this.a.sc(new qBe(t,this.b))},p.tc=function(){return Kh(this)};var e1n=k(At,"Iterables/5",907);A(908,1,{},qBe),p.td=function(t){this.a.td(this.b.Kb(t))};var t1n=k(At,"Iterables/5/lambda$0$Type",908),Tnt,n3e;A(945,1665,Bne,te),p.hc=function(){return!1},p.Cc=function(){return!1},p.ic=function(){throw Y(new K)},p.Dc=function(){return 0},p.Ec=function(){throw Y(new K)},p.Fc=function(){return-1};var n1n=k(At,"Iterators/1",945);A(555,257,$7,hR),p.hc=function(){return!this.a},p.ic=function(){if(this.a)throw Y(new K);return this.a=!0,this.b},p.a=!1;var i1n=k(At,"Iterators/11",555);A(946,1,ys,oe),p.gc=function(t){Ss(this,t)},p.hc=function(){return!1},p.ic=function(){throw Y(new K)},p.jc=function(){Ag(!1,Aw)};var r1n=k(At,"Iterators/2",946);A(947,257,$7,fR),p.hc=function(){return this.a.hc()},p.ic=function(){return this.a.ic()};var s1n=k(At,"Iterators/3",947);A(948,1,ys,R8e),p.gc=function(t){Ss(this,t)},p.hc=function(){return this.a.hc()||this.b.tc().hc()},p.ic=function(){return nbe(this)},p.jc=function(){this.a.jc()};var o1n=k(At,"Iterators/4",948);A(950,949,$7,XBe);var a1n=k(At,"Iterators/6",950);A(951,479,ys,_Fe),p.Dd=function(t){return this.a.Kb(t)};var c1n=k(At,"Iterators/7",951);A(647,1,ys),p.gc=function(t){Ss(this,t)},p.hc=function(){return Gn(this)},p.ic=function(){return Tn(this)},p.jc=function(){Ag(!!this.c,Aw),this.c.jc(),this.c=null};var l1n=k(At,"MultitransformedIterator",647);A(182,647,{182:1,43:1},Nd),p.Fd=function(t){return h(t,43)};var u1n=k(At,"Iterators/ConcatenatedIterator",182);A(648,647,ys,ppe),p.Fd=function(t){return RRt(h(t,43))};var f1n=k(At,"Iterators/ConcatenatedIterator/1",648);A(1540,557,F6,LWe),p.Pb=function(){K0e(this),kE(this.a,this.a)},p.md=function(){return new Fge(this.b)},p.Pc=function(t){return new PVe(this,t,this.b)},p.Kc=function(){return new Bge(this)},p.Lc=function(){var t;return new di((t=this.g,h(t||(this.g=new mF(this)),19)),17)},p.Xb=function(){var t;return t=this.i,t||(this.i=re(this.c,122)?new Zv(this,h(this.c,122)):re(this.c,115)?new X2(this,h(this.c,115)):new XE(this,this.c))},p.Rc=function(){return Yr(),rA(new Bge(this),(i_(),p5))},p.Sc=function(){var t;return UJ(new di((t=this.g,h(t||(this.g=new mF(this)),19)),17),new ne)},p.b=2;var h1n=k(At,"LinkedHashMultimap",1540);A(1543,1,gs,ne),p.Kb=function(t){return h(t,38).lc()};var d1n=k(At,"LinkedHashMultimap/0methodref$getValue$Type",1543);A(728,1,ys,Bge),p.gc=function(t){Ss(this,t)},p.ic=function(){return Zkt(this)},p.hc=function(){return this.a!=this.b.a},p.jc=function(){Ag(!!this.c,Aw),J7e(this.b,this.c.g,this.c.i),this.c=null};var p1n=k(At,"LinkedHashMultimap/1",728);A(310,372,{392:1,372:1,310:1,1706:1,3:1,38:1},S1e),p.Gd=function(){return this.f},p.Hd=function(t){this.c=t},p.Id=function(t){this.f=t},p.d=0;var Cnt=k(At,"LinkedHashMultimap/ValueEntry",310);A(1541,1660,{1706:1,20:1,25:1,13:1,19:1},PVe),p.nc=function(t){var i,a,l,f,g;for(g=W_e*x1e((t==null?0:Hr(t))*H_e,15),i=g&this.b.length-1,f=this.b[i],a=f;a;a=a.a)if(a.d==g&&Dp(a.i,t))return!1;return l=new S1e(this.c,t,g,f),uBe(this.d,l),l.f=this,this.d=l,kE(this.g.a.b,l),kE(l,this.g.a),this.b[i]=l,++this.f,++this.e,LBt(this),!0},p.Pb=function(){var t,i;for(CK(this.b,null),this.f=0,t=this.a;t!=this;t=t.Gd())i=h(t,310),kE(i.b,i.e);this.a=this,this.d=this,++this.e},p.pc=function(t){var i,a;for(a=W_e*x1e((t==null?0:Hr(t))*H_e,15),i=this.b[a&this.b.length-1];i;i=i.a)if(i.d==a&&Dp(i.i,t))return!0;return!1},p.sc=function(t){var i;for(Hn(t),i=this.a;i!=this;i=i.Gd())t.td(h(i,310).i)},p.Gd=function(){return this.a},p.tc=function(){return new cUe(this)},p.vc=function(t){return AXe(this,t)},p.Hd=function(t){this.d=t},p.Id=function(t){this.a=t},p._b=function(){return this.f},p.e=0,p.f=0;var g1n=k(At,"LinkedHashMultimap/ValueSet",1541);A(1542,1,ys,cUe),p.gc=function(t){Ss(this,t)},p.hc=function(){return Gme(this),this.b!=this.c},p.ic=function(){var t,i;if(Gme(this),this.b==this.c)throw Y(new K);return t=h(this.b,310),i=t.i,this.d=t,this.b=t.f,i},p.jc=function(){Gme(this),Ag(!!this.d,Aw),AXe(this.c,this.d.i),this.a=this.c.e,this.d=null},p.a=0;var m1n=k(At,"LinkedHashMultimap/ValueSet/1",1542);A(689,1677,One,$pe),p.Hc=function(){return y0(this)},p.Fb=function(t){return kee(this,t)},p.Mc=function(t){return new xK(this,t)},p.Nc=function(t){return PQ(this,t)},p.Pb=function(){JJ(this)},p.Qb=function(t){return Ppe(this,t)},p.Ic=function(){return new jpe(this)},p.Jc=function(){return new tY(this)},p.Kc=function(){throw Y(new AQ("should never be called"))},p.Tc=function(t){return new xK(this,t)},p.Wb=function(){return!this.a},p.Uc=function(t){return PQ(this,t)},p._b=function(){return this.d},p.c=0,p.d=0;var b1n=k(At,"LinkedListMultimap",689);A(41,25,Ix),p.jd=function(t){Ug(this,t)},p.wc=function(){return new di(this,16)},p.bd=function(t,i){throw Y(new Cp("Add not supported on this list"))},p.nc=function(t){return this.bd(this._b(),t),!0},p.Pb=function(){this.Jd(0,this._b())},p.Fb=function(t){return Cve(this,t)},p.Hb=function(){return ybe(this)},p.dd=function(t){return Zje(this,t)},p.tc=function(){return new ME(this)},p.ed=function(){return this.fd(0)},p.fd=function(t){return new Ns(this,t)},p.gd=function(t){throw Y(new Cp("Remove not supported on this list"))},p.Jd=function(t,i){var a,l;for(l=this.fd(t),a=t;a0||this.c.hc()},p.ic=function(){if(!(this.d>0||this.c.hc()))throw Y(new K);return this.d==0&&(this.b=h(this.c.ic(),312),this.f=this.d=h(this.b.a.lc(),13)._b()),--this.d,this.a=!0,this.b.a.kc()},p.jc=function(){Ag(this.a,Aw),this.f==1?this.c.jc():vve(this.e,this.b.a.kc(),1)>0,--this.f,this.a=!1},p.a=!1,p.d=0,p.f=0;var Q1n=k(At,"Multisets/MultisetIteratorImpl",981);A(667,1,gs,Te),p.Kb=function(t){return new di(DRt(h(h(t,300).a.lc(),13)._b(),h(t,300).a.kc()),16)};var e0n=k(At,"Multisets/lambda$0$Type",667);A(1684,1,Or),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)};var t0n=k(At,"Ordering",1684);A(1565,1684,Gne,Q),p.Ld=function(t,i){return LMt(h(t,34),h(i,34))},p.Ib=function(){return"Ordering.natural()"};var Pnt,n0n=k(At,"NaturalOrdering",1565);A(464,1,{138:1,464:1,3:1,56:1},dwe),p.Mb=function(t){return hAt(this,h(t,34))},p.Nb=function(t){return this.Mb(t)},p.Fb=function(t){var i;return re(t,464)?(i=h(t,464),rwe(this.a,i.a)&&rwe(this.b,i.b)):!1},p.Hb=function(){return Hr(this.a)*31+Hr(this.b)},p.Ib=function(){return aze(this.a,this.b)};var i0n=k(At,"Range",464);A(485,1675,Une,K9),p.Cd=function(){return this.a};var r0n=k(At,"RegularImmutableList",485);A(554,550,U6,TK);var GP,s0n=k(At,"RegularImmutableSet",554);A(729,1561,PJe,M1e);var o0n=k(At,"RegularImmutableSortedSet",729);A(543,1664,{543:1,3:1,20:1,13:1,196:1,19:1,60:1},uOe);var a0n=k(At,"Sets/UnmodifiableNavigableSet",543);A(1165,1675,Une,a8e),p.Cd=function(){return this.a};var c0n=k(At,"SingletonImmutableList",1165);A(326,1671,U6,$2),p.tc=function(){return Mo(),new hR(this.a)},p.pc=function(t){return ki(this.a,t)},p.Ad=function(){return Mo(),new hR(this.a)},p._b=function(){return 1};var l0n=k(At,"SingletonImmutableSet",326);A(1415,1414,F6,jUe),p.Hc=function(){var t;return t=this.f,h(h(t||(this.f=re(this.c,122)?new nA(this,h(this.c,122)):re(this.c,115)?new YE(this,h(this.c,115)):new FE(this,this.c)),115),122)},p.Xb=function(){var t;return t=this.i,h(h(t||(this.i=re(this.c,122)?new Zv(this,h(this.c,122)):re(this.c,115)?new X2(this,h(this.c,115)):new XE(this,this.c)),60),196)},p.Pc=function(t){return t==null&&this.a.Ld(null,null),new iw(this.b)};var u0n=k(At,"TreeMultimap",1415);A(78,1,{3:1,78:1}),p.Nd=function(t){return new w.Error(t)},p.Od=function(){return this.g},p.Pd=function(){var t,i,a;a=this.g==null?null:this.g.replace(new w.RegExp(` -`,"g")," "),i=(t=Um(this.ql),a==null?t:t+": "+a),GMt(this,zLt(this.Nd(i))),Vi(this)},p.Ib=function(){return $Ue(this,this.Od())},p.e=kJe,p.i=!1,p.n=!0;var Lnt=k(da,"Throwable",78);A(104,78,{3:1,104:1,78:1});var f0n=k(da,"Exception",104);A(54,104,Zd,Mp,na);var h0n=k(da,"RuntimeException",54);A(539,54,Zd);var d0n=k(da,"JsException",539);A(760,539,Zd);var p0n=k(z6,"JavaScriptExceptionBase",760);A(435,760,{435:1,3:1,104:1,54:1,78:1},wWe),p.Od=function(){return XBt(this),this.c},p.Qd=function(){return Be(this.b)===Be(i3e)?null:this.b};var i3e,g0n=k(Y_e,"JavaScriptException",435),knt=k(Y_e,"JavaScriptObject$",0),Yre;A(1640,1,{});var m0n=k(Y_e,"Scheduler",1640),Fz=0,Rnt=0,Uz=-1;A(787,1640,{},F);var r3e,b0n=k(z6,"SchedulerImpl",787),Zre;A(1653,1,{});var w0n=k(z6,"StackTraceCreator/Collector",1653);A(761,1653,{},O),p.Rd=function(t){var i={},a,l=[];t[Z_e]=l;for(var f=arguments.callee.caller;f;){var g=(oS(),f.name||(f.name=vRt(f.toString())));l.push(g);var m=":"+g,v=i[m];if(v){var y,E;for(y=0,E=v.length;y=0?"+":"")+(a/60|0),i=(a<0?-a:a)%60<10?"0"+(a<0?-a:a)%60:""+(a<0?-a:a)%60,(Tqe(),$nt)[this.q.getDay()]+" "+Vnt[this.q.getMonth()]+" "+eJ(this.q.getDate())+" "+eJ(this.q.getHours())+":"+eJ(this.q.getMinutes())+":"+eJ(this.q.getSeconds())+" GMT"+t+i+" "+this.q.getFullYear()};var zz=k(Vn,"Date",181);A(1622,181,OJe,JHe),p.a=!1,p.b=0,p.c=0,p.d=0,p.e=0,p.f=0,p.g=!1,p.i=0,p.j=0,p.k=0,p.n=0,p.o=0,p.p=0;var L0n=k("com.google.gwt.i18n.shared.impl","DateRecord",1622);A(1659,1,{}),p.Vd=function(){return null},p.Wd=function(){return null},p.Xd=function(){return null},p.Yd=function(){return null},p.Zd=function(){return null};var k0n=k(Ox,"JSONValue",1659);A(209,1659,{209:1},Om,wF),p.Fb=function(t){return re(t,209)?H1e(this.a,h(t,209).a):!1},p.Ud=function(){return Xde},p.Hb=function(){return B1e(this.a)},p.Vd=function(){return this},p.Ib=function(){var t,i,a;for(a=new ou("["),i=0,t=this.a.length;i0&&(a.a+=","),Ic(a,mx(this,i));return a.a+="]",a.a};var R0n=k(Ox,"JSONArray",209);A(443,1659,{443:1},vF),p.Ud=function(){return Yde},p.Wd=function(){return this},p.Ib=function(){return vt(),""+this.a},p.a=!1;var Int,Dnt,I0n=k(Ox,"JSONBoolean",443);A(877,54,Zd,BDe);var D0n=k(Ox,"JSONException",877);A(913,1659,{},at),p.Ud=function(){return n8},p.Ib=function(){return Xc};var Bnt,B0n=k(Ox,"JSONNull",913);A(259,1659,{259:1},dR),p.Fb=function(t){return re(t,259)?this.a==h(t,259).a:!1},p.Ud=function(){return QZ},p.Hb=function(){return yr(ce(this.a))},p.Xd=function(){return this},p.Ib=function(){return this.a+""},p.a=0;var O0n=k(Ox,"JSONNumber",259);A(191,1659,{191:1},SC,lC),p.Fb=function(t){return re(t,191)?H1e(this.a,h(t,191).a):!1},p.Ud=function(){return Zde},p.Hb=function(){return B1e(this.a)},p.Yd=function(){return this},p.Ib=function(){var t,i,a,l,f,g;for(g=new ou("{"),t=!0,f=rbe(this,le(Se,be,2,0,6,1)),a=0,l=f.length;a=0?":"+this.c:"")+")"},p.c=0;var b3e=k(da,"StackTraceElement",287);Ent={3:1,476:1,34:1,2:1};var Se=k(da,X_e,2);A(100,381,{476:1},Tp,MC,su);var ibn=k(da,"StringBuffer",100);A(98,381,{476:1},h0,tw,ou);var rbn=k(da,"StringBuilder",98);A(763,79,lie,FDe);var sbn=k(da,"StringIndexOutOfBoundsException",763);A(1722,1,{});var w3e,v3e;A(46,54,{3:1,104:1,54:1,78:1,46:1},Pi,Cp);var obn=k(da,"UnsupportedOperationException",46);A(216,210,{3:1,34:1,210:1,216:1},kI,mpe),p.vd=function(t){return jZe(this,h(t,216))},p.$d=function(){return xw(dKe(this))},p.Fb=function(t){var i;return this===t?!0:re(t,216)?(i=h(t,216),this.e==i.e&&jZe(this,i)==0):!1},p.Hb=function(){var t;return this.b!=0?this.b:this.a<54?(t=Wc(this.f),this.b=nr(Kr(t,-1)),this.b=33*this.b+nr(Kr(Pg(t,32),-1)),this.b=17*this.b+yr(this.e),this.b):(this.b=17*UVe(this.c)+yr(this.e),this.b)},p.Ib=function(){return dKe(this)},p.a=0,p.b=0,p.d=0,p.e=0,p.f=0;var Unt,_1,_3e,y3e,x3e,E3e,S3e,M3e,Qre=k("java.math","BigDecimal",216);A(89,210,{3:1,34:1,210:1,89:1},hwe,Up,l_,Owe,QWe,Tg),p.vd=function(t){return FWe(this,h(t,89))},p.$d=function(){return xw(Ine(this,0))},p.Fb=function(t){return Obe(this,t)},p.Hb=function(){return UVe(this)},p.Ib=function(){return Ine(this,0)},p.b=-2,p.c=0,p.d=0,p.e=0;var ese,Gz,T3e,tse,jz,cM,ly=k("java.math","BigInteger",89),znt,Gnt,Xx,VP;A(441,1666,$S),p.Pb=function(){nl(this)},p.Qb=function(t){return v0(this,t)},p.Rb=function(t){return CVe(this,t,this.e)||CVe(this,t,this.d)},p.Tb=function(){return new Ep(this)},p.Vb=function(t){return Ii(this,t)},p.Zb=function(t,i){return dr(this,t,i)},p.$b=function(t){return hS(this,t)},p._b=function(){return OE(this)};var abn=k(Vn,"AbstractHashMap",441);A(242,fd,gu,Ep),p.Pb=function(){this.a.Pb()},p.pc=function(t){return Y7e(this,t)},p.tc=function(){return new Zm(this.a)},p.vc=function(t){var i;return Y7e(this,t)?(i=h(t,38).kc(),this.a.$b(i),!0):!1},p._b=function(){return this.a._b()};var cbn=k(Vn,"AbstractHashMap/EntrySet",242);A(243,1,ys,Zm),p.gc=function(t){Ss(this,t)},p.ic=function(){return k0(this)},p.hc=function(){return this.b},p.jc=function(){RGe(this)},p.b=!1;var lbn=k(Vn,"AbstractHashMap/EntrySetIterator",243);A(433,1,ys,ME),p.gc=function(t){Ss(this,t)},p.hc=function(){return y8(this)},p.ic=function(){return _Ue(this)},p.jc=function(){yf(this)},p.b=0,p.c=-1;var ubn=k(Vn,"AbstractList/IteratorImpl",433);A(94,433,Ch,Ns),p.jc=function(){yf(this)},p.Bc=function(t){td(this,t)},p.Cc=function(){return this.b>0},p.Dc=function(){return this.b},p.Ec=function(){return Rn(this.b>0),this.a.cd(this.c=--this.b)},p.Fc=function(){return this.b-1},p.Gc=function(t){s_(this.c!=-1),this.a.hd(this.c,t)};var fbn=k(Vn,"AbstractList/ListIteratorImpl",94);A(227,41,Ix,Rg),p.bd=function(t,i){g_(t,this.b),this.c.bd(this.a+t,i),++this.b},p.cd=function(t){return ai(t,this.b),this.c.cd(this.a+t)},p.gd=function(t){var i;return ai(t,this.b),i=this.c.gd(this.a+t),--this.b,i},p.hd=function(t,i){return ai(t,this.b),this.c.hd(this.a+t,i)},p._b=function(){return this.b},p.a=0,p.b=0;var hbn=k(Vn,"AbstractList/SubList",227);A(352,fd,gu,Gv),p.Pb=function(){this.a.Pb()},p.pc=function(t){return this.a.Qb(t)},p.tc=function(){var t;return t=this.a.Tb().tc(),new pR(t)},p.vc=function(t){return this.a.Qb(t)?(this.a.$b(t),!0):!1},p._b=function(){return this.a._b()};var dbn=k(Vn,"AbstractMap/1",352);A(542,1,ys,pR),p.gc=function(t){Ss(this,t)},p.hc=function(){return this.a.hc()},p.ic=function(){var t;return t=h(this.a.ic(),38),t.kc()},p.jc=function(){this.a.jc()};var pbn=k(Vn,"AbstractMap/1/1",542);A(223,25,Y_,bh),p.Pb=function(){this.a.Pb()},p.pc=function(t){return this.a.Rb(t)},p.tc=function(){var t;return t=this.a.Tb().tc(),new c0(t)},p._b=function(){return this.a._b()};var gbn=k(Vn,"AbstractMap/2",223);A(321,1,ys,c0),p.gc=function(t){Ss(this,t)},p.hc=function(){return this.a.hc()},p.ic=function(){var t;return t=h(this.a.ic(),38),t.lc()},p.jc=function(){this.a.jc()};var mbn=k(Vn,"AbstractMap/2/1",321);A(440,1,{440:1,38:1}),p.Fb=function(t){var i;return re(t,38)?(i=h(t,38),tl(this.d,i.kc())&&tl(this.e,i.lc())):!1},p.kc=function(){return this.d},p.lc=function(){return this.e},p.Hb=function(){return H8(this.d)^H8(this.e)},p.mc=function(t){return eme(this,t)},p.Ib=function(){return this.d+"="+this.e};var bbn=k(Vn,"AbstractMap/AbstractEntry",440);A(351,440,{440:1,351:1,38:1},S8);var wbn=k(Vn,"AbstractMap/SimpleEntry",351);A(1672,1,G7),p.Fb=function(t){var i;return re(t,38)?(i=h(t,38),tl(this.kc(),i.kc())&&tl(this.lc(),i.lc())):!1},p.Hb=function(){return H8(this.kc())^H8(this.lc())},p.Ib=function(){return this.kc()+"="+this.lc()};var vbn=k(Vn,MJe,1672);A(1685,1666,EJe),p.Wc=function(t){return Xze(this,t)},p.Qb=function(t){return AK(this,t)},p.Tb=function(){return new AF(this)},p.Vb=function(t){return Dc(Sbe(this,t))},p.Xb=function(){return new jv(this)};var _bn=k(Vn,"AbstractNavigableMap",1685);A(668,fd,gu,AF),p.pc=function(t){return re(t,38)&&Xze(this.b,h(t,38))},p.tc=function(){return new aI(this.b)},p.vc=function(t){var i;return re(t,38)?(i=h(t,38),IGe(this.b,i)):!1},p._b=function(){return this.b.c};var ybn=k(Vn,"AbstractNavigableMap/EntrySet",668);A(488,fd,V_e,jv),p.wc=function(){return new NR(this)},p.Pb=function(){PR(this.a)},p.pc=function(t){return AK(this.a,t)},p.tc=function(){var t;return t=new aI(new JR(this.a).b),new uC(t)},p.vc=function(t){return AK(this.a,t)?(fA(this.a,t),!0):!1},p._b=function(){return this.a.c};var xbn=k(Vn,"AbstractNavigableMap/NavigableKeySet",488);A(489,1,ys,uC),p.gc=function(t){Ss(this,t)},p.hc=function(){return y8(this.a.a)},p.ic=function(){var t;return t=dJ(this.a),t.kc()},p.jc=function(){j8e(this.a)};var Ebn=k(Vn,"AbstractNavigableMap/NavigableKeySet/1",489);A(1693,25,Y_),p.nc=function(t){return dS(RS(this,t)),!0},p.oc=function(t){return dn(t),u9(t!=this,"Can't add a queue to itself"),wo(this,t)},p.Pb=function(){for(;eee(this)!=null;);};var Sbn=k(Vn,"AbstractQueue",1693);A(407,25,{4:1,20:1,25:1,13:1},AE,q9e),p.nc=function(t){return J1e(this,t),!0},p.Pb=function(){a0e(this)},p.pc=function(t){return nVe(new hA(this),t)},p.Wb=function(){return wpe(this)},p.tc=function(){return new hA(this)},p.vc=function(t){return eLt(new hA(this),t)},p._b=function(){return this.c-this.b&this.a.length-1},p.wc=function(){return new di(this,272)},p.zc=function(t){var i,a;return a=this.c-this.b&this.a.length-1,t.lengtha&&Gr(t,a,null),t},p.b=0,p.c=0;var Mbn=k(Vn,"ArrayDeque",407);A(408,1,ys,hA),p.gc=function(t){Ss(this,t)},p.hc=function(){return this.a!=this.b},p.ic=function(){return DU(this)},p.jc=function(){e$e(this)},p.a=0,p.b=0,p.c=-1;var Tbn=k(Vn,"ArrayDeque/IteratorImpl",408);A(12,41,UJe,ke,Gl,vf),p.bd=function(t,i){_0(this,t,i)},p.nc=function(t){return De(this,t)},p.oc=function(t){return Lr(this,t)},p.Pb=function(){this.c=le(on,et,1,0,5,1)},p.pc=function(t){return Qo(this,t,0)!=-1},p.sc=function(t){cd(this,t)},p.cd=function(t){return St(this,t)},p.dd=function(t){return Qo(this,t,0)},p.Wb=function(){return this.c.length==0},p.tc=function(){return new j(this)},p.gd=function(t){return L0(this,t)},p.vc=function(t){return Sa(this,t)},p.Jd=function(t,i){S7e(this,t,i)},p.hd=function(t,i){return Hu(this,t,i)},p._b=function(){return this.c.length},p.jd=function(t){fa(this,t)},p.yc=function(){return mJ(this)},p.zc=function(t){return vo(this,t)};var tVt=k(Vn,"ArrayList",12);A(7,1,ys,j),p.gc=function(t){Ss(this,t)},p.hc=function(){return Zo(this)},p.ic=function(){return $(this)},p.jc=function(){cA(this)},p.a=0,p.b=-1;var Cbn=k(Vn,"ArrayList/1",7);A(155,41,zJe,Bl),p.pc=function(t){return Zje(this,t)!=-1},p.sc=function(t){var i,a,l,f;for(dn(t),a=this.a,l=0,f=a.length;l=0},p.qc=function(t){return Gg(this.b,t)},p.tc=function(){return new Nm(rS(this.b).b.tc())},p.vc=function(t){return p$e(this,t)},p._b=function(){return this.b.c.length},p.wc=function(){return new di(this,256)},p.yc=function(){return mJ(this.b)},p.zc=function(t){return vo(this.b,t)};var wwn=k(Vn,"PriorityQueue",453);A(214,1,{214:1},Jee,J9),p.a=0,p.b=0;var R3e,I3e,sVt=0,vwn=k(Vn,"Random",214);A(39,1,Wp,di,sx,PGe),p.qd=function(){return this.a},p.rd=function(){return r1e(this),this.c},p.gc=function(t){r1e(this),this.d.gc(t)},p.sd=function(t){return U0e(this,t)},p.a=0,p.c=0;var _wn=k(Vn,"Spliterators/IteratorSpliterator",39);A(382,39,Wp,NR);var ywn=k(Vn,"SortedSet/1",382);A(625,1,{},PF),p.ie=function(t){this.a.td(t)};var xwn=k(Vn,"Spliterator/OfDouble/0methodref$accept$Type",625);A(626,1,{},LF),p.ie=function(t){this.a.td(t)};var Ewn=k(Vn,"Spliterator/OfDouble/1methodref$accept$Type",626);A(642,1,Wp),p.gc=function(t){IBe(this,t)},p.qd=function(){return this.d},p.rd=function(){return this.e},p.d=0,p.e=0;var Swn=k(Vn,"Spliterators/BaseSpliterator",642);A(929,642,Wp),p.gc=function(t){re(t,273)?Cme(this,h(t,273)):Cme(this,new LF(t))},p.sd=function(t){return re(t,273)?a_(this,h(t,273)):a_(this,new PF(t))};var Mwn=k(Vn,"Spliterators/AbstractDoubleSpliterator",929);A(446,642,Wp);var Twn=k(Vn,"Spliterators/AbstractSpliterator",446);A(790,1,Wp),p.gc=function(t){IBe(this,t)},p.qd=function(){return this.b},p.rd=function(){return this.d-this.c},p.b=0,p.c=0,p.d=0;var Cwn=k(Vn,"Spliterators/BaseArraySpliterator",790);A(791,790,Wp,SUe),p.gc=function(t){QAt(this,t)},p.sd=function(t){return lkt(this,t)};var Awn=k(Vn,"Spliterators/ArraySpliterator",791);A(789,1,ys,xBe),p.gc=function(t){re(t,273)?Gze(this,h(t,273)):Gze(this,new hC(t))},p.ic=function(){return eU(this)},p.jc=function(){jDe()},p.ie=function(t){this.b=t},p.hc=function(){return this.a||(this.a=a_(this.c,this)),this.a},p.a=!1,p.b=0;var Pwn=k(Vn,"Spliterators/DoubleConsumerIterator",789);A(523,41,jJe,Zh),p.bd=function(t,i){oA(t,this.a.c.length+1),_0(this.a,t,i)},p.nc=function(t){return De(this.a,t)},p.oc=function(t){return Lr(this.a,t)},p.Pb=function(){this.a.c=le(on,et,1,0,5,1)},p.pc=function(t){return Qo(this.a,t,0)!=-1},p.qc=function(t){return Gg(this.a,t)},p.sc=function(t){cd(this.a,t)},p.cd=function(t){return oA(t,this.a.c.length),St(this.a,t)},p.dd=function(t){return Qo(this.a,t,0)},p.Wb=function(){return this.a.c.length==0},p.tc=function(){return new j(this.a)},p.gd=function(t){return oA(t,this.a.c.length),L0(this.a,t)},p.Jd=function(t,i){S7e(this.a,t,i)},p.hd=function(t,i){return oA(t,this.a.c.length),Hu(this.a,t,i)},p._b=function(){return this.a.c.length},p.jd=function(t){fa(this.a,t)},p.kd=function(t,i){return new Rg(this.a,t,i)},p.yc=function(){return mJ(this.a)},p.zc=function(t){return vo(this.a,t)},p.Ib=function(){return Vp(this.a)};var Lwn=k(Vn,"Vector",523);A(596,523,jJe,sK);var kwn=k(Vn,"Stack",596);A(254,1,{},P0),p.Ib=function(){return this.a?this.e.length==0?this.a.a:this.a.a+(""+this.e):this.c};var Rwn=k(Vn,"StringJoiner",254);A(487,1685,{3:1,109:1,122:1,115:1},iOe,WJ),p.Pb=function(){PR(this)},p.Tb=function(){return new JR(this)},p.Zb=function(t,i){return kU(this,t,i)},p.$b=function(t){return fA(this,t)},p._b=function(){return this.c},p.c=0;var Iwn=k(Vn,"TreeMap",487);A(397,1,ys,aI),p.gc=function(t){Ss(this,t)},p.ic=function(){return dJ(this)},p.hc=function(){return y8(this.a)},p.jc=function(){j8e(this)};var Dwn=k(Vn,"TreeMap/EntryIterator",397);A(449,668,gu,JR),p.Pb=function(){PR(this.a)};var Bwn=k(Vn,"TreeMap/EntrySet",449);A(398,351,{440:1,351:1,38:1,398:1},jQ),p.b=!1;var oVt=k(Vn,"TreeMap/Node",398);A(560,1,{},se),p.Ib=function(){return"State: mv="+this.c+" value="+this.d+" done="+this.a+" found="+this.b},p.a=!1,p.b=!1,p.c=!1;var Own=k(Vn,"TreeMap/State",560);A(278,23,pie,M8),p.je=function(){return!1},p.ke=function(){return!1};var nse,D3e,B3e,O3e,Vz=Ti(Vn,"TreeMap/SubMapType",278,Di,e4t,cTt);A(982,278,pie,WNe),p.ke=function(){return!0};var Nwn=Ti(Vn,"TreeMap/SubMapType/1",982,Vz,null,null);A(983,278,pie,nFe),p.je=function(){return!0},p.ke=function(){return!0};var Fwn=Ti(Vn,"TreeMap/SubMapType/2",983,Vz,null,null);A(984,278,pie,HNe),p.je=function(){return!0};var Uwn=Ti(Vn,"TreeMap/SubMapType/3",984,Vz,null,null),Xnt;A(212,fd,{3:1,20:1,25:1,13:1,196:1,19:1,60:1,212:1},Qde,iw),p.wc=function(){return new NR(this)},p.nc=function(t){return R9(this,t)},p.Pb=function(){PR(this.a)},p.pc=function(t){return AK(this.a,t)},p.tc=function(){var t;return t=new aI(new JR(new jv(this.a).a).b),new uC(t)},p.vc=function(t){return Uge(this,t)},p._b=function(){return this.a.c};var aVt=k(Vn,"TreeSet",212);A(845,1,{},_Y),p.le=function(t,i){return RMt(this.a,t,i)};var zwn=k(gie,"BinaryOperator/lambda$0$Type",845);A(846,1,{},Fr),p.le=function(t,i){return kp(h(t,21).a,h(i,21).a)<=0?t:i};var Gwn=k(gie,"BinaryOperator/lambda$1$Type",846);A(843,1,gs,de),p.Kb=function(t){return t};var jwn=k(gie,"Function/lambda$0$Type",843);A(627,1,os,RF),p.Nb=function(t){return!this.a.Nb(t)};var $wn=k(gie,"Predicate/lambda$0$Type",627);A(150,23,{3:1,34:1,23:1,150:1},PK);var N3e,th,Bw,nh=Ti(Xs,"Collector/Characteristics",150,Di,fLt,lTt),Ynt;A(684,1,{},W8e,fqe);var Vwn=k(Xs,"Collector/CollectorImpl",684);A(1053,1,gs,yY),p.Kb=function(t){return vt(),!!i0e(t)};var Wwn=k(Xs,"Collectors/12methodref$test$Type",1053);A(365,1,{},Vt),p.Kd=function(t,i){h(t,13).nc(i)};var Hwn=k(Xs,"Collectors/20methodref$add$Type",365);A(367,1,{},pn),p.ne=function(){return new ke};var qwn=k(Xs,"Collectors/21methodref$ctor$Type",367);A(331,1,{},qn),p.ne=function(){return new zr};var Xwn=k(Xs,"Collectors/23methodref$ctor$Type",331);A(332,1,{},bi),p.Kd=function(t,i){Cr(h(t,67),i)};var Ywn=k(Xs,"Collectors/24methodref$add$Type",332);A(1050,1,{},Yi),p.le=function(t,i){return rOe(h(t,15),h(i,13))};var Zwn=k(Xs,"Collectors/4methodref$addAll$Type",1050);A(683,1,{},$i),p.le=function(t,i){return $1e(t,i)};var Kwn=k(Xs,"Collectors/lambda$1$Type",683);A(1055,1,{},xY),p.ne=function(){return X(q(on,1),et,1,5,[this.a])};var Jwn=k(Xs,"Collectors/lambda$10$Type",1055);A(1056,1,{},bR),p.Kd=function(t,i){WCt(this.a,t)};var Qwn=k(Xs,"Collectors/lambda$11$Type",1056);A(1057,1,{},DF),p.le=function(t,i){return bAt(this.a,t,i)};var evn=k(Xs,"Collectors/lambda$12$Type",1057);A(1058,1,gs,Tr),p.Kb=function(t){return __(t)[0]};var tvn=k(Xs,"Collectors/lambda$13$Type",1058);A(366,1,{},wr),p.le=function(t,i){return h(t,13).oc(h(i,13)),h(t,13)};var nvn=k(Xs,"Collectors/lambda$21$Type",366);A(333,1,{},Si),p.le=function(t,i){return wo(h(t,67),h(i,67)),h(t,67)};var ivn=k(Xs,"Collectors/lambda$25$Type",333);A(334,1,gs,it),p.Kb=function(t){return h(t,67)};var rvn=k(Xs,"Collectors/lambda$26$Type",334);A(1049,1,{},EY),p.Kd=function(t,i){bIt(this.a,t,i)};var svn=k(Xs,"Collectors/lambda$3$Type",1049);A(1051,1,{},We),p.le=function(t,i){return iIt(h(t,109),h(i,109),new Yi)};var ovn=k(Xs,"Collectors/lambda$4$Type",1051);A(1052,1,gs,SY),p.Kb=function(t){return S6t(this.a,t)};var avn=k(Xs,"Collectors/lambda$5$Type",1052);A(1054,1,{},En),p.ne=function(){var t;return t=new A0,N0(t,(vt(),vt(),!1),new ke),N0(t,!0,new ke),t};var cvn=k(Xs,"Collectors/lambda$8$Type",1054);A(645,1,{}),p.d=!1;var lvn=k(Xs,"TerminatableStream",645);A(1416,645,{607:1,1701:1},JFe);var uvn=k(Xs,"DoubleStream/DoubleStreamSource",1416);A(1417,1,{},MY),p.ie=function(t){NWe(this.a,t)};var fvn=k(Xs,"DoubleStream/DoubleStreamSource/lambda$2$Type",1417),cVt=_r(Xs,"Stream");A(940,446,Wp,I8e),p.sd=function(t){for(;Ckt(this);){if(this.a.sd(t))return!0;this.a=null}return!1};var hvn=k(Xs,"Stream/2",940);A(941,1,{},TY),p.td=function(t){cMt(this.a,t)};var dvn=k(Xs,"Stream/2/lambda$0$Type",941);A(942,1,H6,CY),p.fe=function(){oQ(this.a)};var pvn=k(Xs,"Stream/3methodref$close$Type",942);A(943,1,H6,AY),p.fe=function(){oQ(this.a)};var gvn=k(Xs,"Stream/4methodref$close$Type",943);A(644,446,Wp,S0e),p.sd=function(t){for(this.b=!1;!this.b&&this.c.sd(new mOe(this,t)););return this.b},p.b=!1;var mvn=k(Xs,"Stream/FilterSpliterator",644);A(932,1,{},mOe),p.td=function(t){wAt(this.a,this.b,t)};var bvn=k(Xs,"Stream/FilterSpliterator/lambda$0$Type",932);A(930,929,Wp,tGe);var wvn=k(Xs,"Stream/MapToDoubleSpliterator",930);A(646,1,{},Hpe),p.td=function(t){YEt(this.a,this.b,t)};var vvn=k(Xs,"Stream/MapToDoubleSpliterator/lambda$0$Type",646);A(643,446,Wp,v0e),p.sd=function(t){return O8e(this,t)};var _vn=k(Xs,"Stream/MapToObjSpliterator",643);A(931,1,{},bOe),p.td=function(t){ZEt(this.a,this.b,t)};var yvn=k(Xs,"Stream/MapToObjSpliterator/lambda$0$Type",931);A(45,645,{607:1,1701:1,1700:1},oi);var xvn=k(Xs,"Stream/StreamSource",45);A(936,446,Wp,D8e),p.sd=function(t){for(;Akt(this);){if(this.a.sd(t))return!0;oQ(this.b),this.b=null,this.a=null}return!1};var Evn=k(Xs,"Stream/StreamSource/1",936);A(937,1,{},PY),p.td=function(t){BCt(this.a,t)};var Svn=k(Xs,"Stream/StreamSource/1/lambda$0$Type",937);A(938,446,Wp,IUe),p.sd=function(t){var i;return this.a||(i=new ke,this.b.a.gc(new LY(i)),_t(),fa(i,this.c),this.a=new di(i,16)),U0e(this.a,t)},p.a=null;var Mvn=k(Xs,"Stream/StreamSource/5",938);A(939,1,{},LY),p.td=function(t){De(this.a,t)};var Tvn=k(Xs,"Stream/StreamSource/5/2methodref$add$Type",939);A(933,1,{},ve),p.td=function(t){};var Cvn=k(Xs,"Stream/StreamSource/lambda$0$Type",933);A(934,1,{},kY),p.le=function(t,i){return WSt(this.a,t,i)};var Avn=k(Xs,"Stream/StreamSource/lambda$3$Type",934);A(935,1,{},wOe),p.td=function(t){SSt(this.b,this.a,t)};var Pvn=k(Xs,"Stream/StreamSource/lambda$4$Type",935);A(553,1,{},wt),p.td=function(t){SF(this,t)};var Lvn=k(Xs,"Stream/ValueConsumer",553);A(944,1,{},RY),p.td=function(t){lIt(this.a,t)};var kvn=k(Xs,"TerminatableStream/lambda$0$Type",944),lVt=0,F3e,U3e=0,Wz;A(1480,1,{},_ze);var Rvn=k(VJe,"Scanline",1480),uVt=_r(VJe,WJe);A(1450,1,{},_je);var Ivn=k(dd,"CGraph",1450);A(309,1,{309:1},x7e),p.b=0,p.c=0,p.d=0,p.g=0,p.i=0,p.k=Ts;var Dvn=k(dd,"CGroup",309);A(723,1,{},epe);var Bvn=k(dd,"CGroup/CGroupBuilder",723);A(57,1,{57:1},u8e),p.Ib=function(){return this.j?ti(this.j.Kb(this)):(Fd(Hz),Hz.o+"@"+(m0(this)>>>0).toString(16))},p.f=0,p.i=Ts;var Hz=k(dd,"CNode",57);A(722,1,{},tpe);var Ovn=k(dd,"CNode/CNodeBuilder",722),Znt;A(1236,1,{},gn),p.se=function(t,i){return 0},p.te=function(t,i){return 0};var Nvn=k(dd,qJe,1236);A(1505,1,{},vn),p.pe=function(t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V;for(E=Jr,l=new j(t.a.b);l.al.d.c||l.d.c==g.d.c&&l.d.b>>0).toString(16)},p.equals=function(e){return this.Fb(e)},p.hashCode=function(){return this.Hb()},p.toString=function(){return this.Ib()};var ynt,xnt,Ent;A(274,1,{274:1,1712:1},wbe),p._d=function(t){var i;return i=new wbe,i.i=4,t>1?i.c=a7e(this,t-1):i.c=this,i},p.ae=function(){return Fd(this),this.b},p.be=function(){return Um(this)},p.ce=function(){return Fd(this),this.k},p.de=function(){return(this.i&4)!=0},p.ee=function(){return(this.i&1)!=0},p.Ib=function(){return N0e(this)},p.i=0;var tVt=1,on=k(da,"Object",1),Kxe=k(da,"Class",274);A(1692,1,{3:1});var lgn=k(X_,"Optional",1692);A(1060,1692,{3:1},I),p.Fb=function(t){return t===this},p.Hb=function(){return 2040732332},p.Ib=function(){return"Optional.absent()"},p.Jb=function(t){return Hn(t),Ur(),Wre};var Wre,ugn=k(X_,"Absent",1060),nVt=_r(X_,"Function");A(393,1,{},LR),p.Lb=function(t){return Y9e(t)};var fgn=k(X_,"Joiner",393);A(875,393,{},e9e),p.Lb=function(t){return t==null?this.b:Y9e(t)};var hgn=k(X_,"Joiner/1",875);A(874,1,{},vY);var dgn=k(X_,"Joiner/MapJoiner",874),iVt=_r(X_,"Predicate"),Snt;A(494,1,{138:1,494:1,3:1,56:1},KX),p.Nb=function(t){return this.Mb(t)},p.Mb=function(t){var i;for(i=0;i0},p.ic=function(){if(this.b>=this.c)throw Y(new K);return wBe(this,this.b++)},p.Dc=function(){return this.b},p.Ec=function(){if(this.b<=0)throw Y(new K);return wBe(this,--this.b)},p.Fc=function(){return this.b-1},p.b=0,p.c=0;var kgn=k(At,"AbstractIndexedListIterator",847);A(949,257,$7),p.hc=function(){return S_(this)},p.ic=function(){return px(this)},p.d=1;var Rgn=k(At,"AbstractIterator",949);A(1677,1,{238:1}),p.Hc=function(){var t;return t=this.f,t||(this.f=this.Ic())},p.Jc=function(){return new MK(this.Hc())},p.Lc=function(){return new PGe(this.Kc(),this._b(),re(this,475)?1:0)},p.Fb=function(t){return kee(this,t)},p.Hb=function(){return Hr(this.Hc())},p.Wb=function(){return this._b()==0},p.Xb=function(){return i1e(this)},p.Ib=function(){return Ga(this.Hc())};var Ign=k(At,"AbstractMultimap",1677);A(654,1677,One),p.Pb=function(){K0e(this)},p.Qb=function(t){return this.c.Qb(t)},p.Ic=function(){return re(this.c,122)?new nA(this,h(this.c,122)):re(this.c,115)?new YE(this,h(this.c,115)):new FE(this,this.c)},p.Pc=function(t){return this.Oc()},p.Jc=function(){return re(this.c,122)?new Zv(this,h(this.c,122)):re(this.c,115)?new X2(this,h(this.c,115)):new XE(this,this.c)},p.Qc=function(){return WDt(this.Oc())},p.Kc=function(){return new IDe(this)},p.Lc=function(){return Kwe(this.c.Tb().wc(),new Z,64,this.d)},p.Mc=function(t){return er(this,t)},p.Nc=function(t){return aP(this,t)},p._b=function(){return this.d},p.Rc=function(){return new RDe(this)},p.Sc=function(){return Kwe(this.c.ac().wc(),new D,64,this.d)},p.d=0;var Dgn=k(At,"AbstractMapBasedMultimap",654);A(1483,654,One),p.Oc=function(){return new Gl(this.a)},p.Qc=function(){return lA(),lA(),e3e},p.Mc=function(t){return h(er(this,t),15)},p.Nc=function(t){return h(aP(this,t),15)},p.Hc=function(){var t;return t=this.f,t||(this.f=re(this.c,122)?new nA(this,h(this.c,122)):re(this.c,115)?new YE(this,h(this.c,115)):new FE(this,this.c))},p.Fb=function(t){return kee(this,t)},p.Tc=function(t){return h(er(this,t),15)},p.Uc=function(t){return h(aP(this,t),15)};var Bgn=k(At,"AbstractListMultimap",1483);A(661,1,ys),p.gc=function(t){Ss(this,t)},p.hc=function(){return this.c.hc()||this.e.hc()},p.ic=function(){var t;return this.e.hc()||(t=h(this.c.ic(),38),this.b=t.kc(),this.a=h(t.lc(),13),this.e=this.a.tc()),this.Vc(this.b,this.e.ic())},p.jc=function(){this.e.jc(),this.a.Wb()&&this.c.jc(),--this.d.d};var Ogn=k(At,"AbstractMapBasedMultimap/Itr",661);A(970,661,ys,RDe),p.Vc=function(t,i){return i};var Ngn=k(At,"AbstractMapBasedMultimap/1",970);A(971,1,gs,D),p.Kb=function(t){return h(t,13).wc()};var Fgn=k(At,"AbstractMapBasedMultimap/1methodref$spliterator$Type",971);A(972,661,ys,IDe),p.Vc=function(t,i){return Yr(),new DR(t,i)};var Ugn=k(At,"AbstractMapBasedMultimap/2",972);A(1666,1,$S),p.Ub=function(t){vee(this,t)},p.Yb=function(t,i,a){return Vbe(this,t,i,a)},p.Pb=function(){this.Tb().Pb()},p.Wc=function(t){return xte(this,t)},p.Qb=function(t){return!!qwe(this,t,!1)},p.Rb=function(t){var i,a,l;for(a=this.Tb().tc();a.hc();)if(i=h(a.ic(),38),l=i.lc(),Be(t)===Be(l)||t!=null&&ki(t,l))return!0;return!1},p.Fb=function(t){return Xqe(this,t)},p.Vb=function(t){return Dc(qwe(this,t,!1))},p.Hb=function(){return mbe(this.Tb())},p.Wb=function(){return this._b()==0},p.Xb=function(){return new Gv(this)},p.Zb=function(t,i){throw Y(new Cp("Put not supported on this map"))},p.$b=function(t){return Dc(qwe(this,t,!0))},p._b=function(){return this.Tb()._b()},p.Ib=function(){var t,i,a;for(a=new A0("{","}"),i=this.Tb().tc();i.hc();)t=h(i.ic(),38),Xm(a,JUe(this,t.kc())+"="+JUe(this,t.lc()));return a.a?a.e.length==0?a.a.a:a.a.a+(""+a.e):a.c},p.ac=function(){return new bh(this)};var zgn=k(Vn,"AbstractMap",1666);A(1678,1666,$S),p.Jc=function(){return new MK(this)},p.Tb=function(){return n1e(this)},p.Xb=function(){var t;return t=this.g,t||(this.g=this.Jc())},p.ac=function(){var t;return t=this.i,t||(this.i=new lOe(this))};var Ggn=k(At,"Maps/ViewCachingAbstractMap",1678);A(357,1678,$S,FE),p.Vb=function(t){return Dkt(this,t)},p.$b=function(t){return kIt(this,t)},p.Pb=function(){this.d==this.e.c?this.e.Pb():N9(new Vme(this))},p.Qb=function(t){return D5t(this.d,t)},p.Yc=function(){return new JX(this)},p.Xc=function(){return this.Yc()},p.Fb=function(t){return this===t||ki(this.d,t)},p.Hb=function(){return Hr(this.d)},p.Xb=function(){return this.e.Xb()},p._b=function(){return this.d._b()},p.Ib=function(){return Ga(this.d)};var jgn=k(At,"AbstractMapBasedMultimap/AsMap",357);A(25,1,Y_),p.sc=function(t){mo(this,t)},p.uc=function(){return new oi(null,this.wc())},p.wc=function(){return new di(this,0)},p.xc=function(){return new oi(null,this.wc())},p.nc=function(t){throw Y(new Cp("Add not supported on this collection"))},p.oc=function(t){return wo(this,t)},p.Pb=function(){bI(this)},p.pc=function(t){return _x(this,t,!1)},p.qc=function(t){return Gg(this,t)},p.Wb=function(){return this._b()==0},p.vc=function(t){return _x(this,t,!0)},p.yc=function(){return VJ(this)},p.zc=function(t){return u6(this,t)},p.Ib=function(){return Vp(this)};var $gn=k(Vn,"AbstractCollection",25);A(fd,25,gu),p.wc=function(){return new di(this,1)},p.Fb=function(t){return TWe(this,t)},p.Hb=function(){return mbe(this)};var Vgn=k(Vn,"AbstractSet",fd);A(1660,fd,gu);var Wgn=k(At,"Sets/ImprovedAbstractSet",1660);A(1679,1660,gu),p.Pb=function(){this.Zc().Pb()},p.pc=function(t){return IWe(this,t)},p.Wb=function(){return this.Zc().Wb()},p.vc=function(t){var i;return this.pc(t)?(i=h(t,38),this.Zc().Xb().vc(i.kc())):!1},p._b=function(){return this.Zc()._b()};var Hgn=k(At,"Maps/EntrySet",1679);A(968,1679,gu,JX),p.pc=function(t){return rHe(this.a.d.Tb(),t)},p.tc=function(){return new Vme(this.a)},p.Zc=function(){return this.a},p.vc=function(t){var i;return rHe(this.a.d.Tb(),t)?(i=h(t,38),W4t(this.a.e,i.kc()),!0):!1},p.wc=function(){return UJ(this.a.d.Tb().wc(),new QX(this.a))};var qgn=k(At,"AbstractMapBasedMultimap/AsMap/AsMapEntries",968);A(969,1,gs,QX),p.Kb=function(t){return UGe(this.a,h(t,38))};var Xgn=k(At,"AbstractMapBasedMultimap/AsMap/AsMapEntries/0methodref$wrapEntry$Type",969);A(659,1,ys,Vme),p.gc=function(t){Ss(this,t)},p.ic=function(){var t;return t=h(this.b.ic(),38),this.a=h(t.lc(),13),UGe(this.c,t)},p.hc=function(){return this.b.hc()},p.jc=function(){this.b.jc(),this.c.e.d-=this.a._b(),this.a.Pb()};var Ygn=k(At,"AbstractMapBasedMultimap/AsMap/AsMapIterator",659);A(541,1660,gu,MK),p.Pb=function(){this.b.Pb()},p.pc=function(t){return this.b.Qb(t)},p.sc=function(t){Hn(t),this.b.Ub(new rY(t))},p.Wb=function(){return this.b.Wb()},p.tc=function(){return Yr(),rA(this.b.Tb().tc(),(i_(),d5))},p.vc=function(t){return this.b.Qb(t)?(this.b.$b(t),!0):!1},p._b=function(){return this.b._b()};var Zgn=k(At,"Maps/KeySet",541);A(356,541,gu,XE),p.Pb=function(){var t;N9((t=this.b.Tb().tc(),new Fpe(this,t)))},p.qc=function(t){return this.b.Xb().qc(t)},p.Fb=function(t){return this===t||ki(this.b.Xb(),t)},p.Hb=function(){return Hr(this.b.Xb())},p.tc=function(){var t;return t=this.b.Tb().tc(),new Fpe(this,t)},p.vc=function(t){var i,a;return a=0,i=h(this.b.$b(t),13),i&&(a=i._b(),i.Pb(),this.a.d-=a),a>0},p.wc=function(){return this.b.Xb().wc()};var Kgn=k(At,"AbstractMapBasedMultimap/KeySet",356);A(660,1,ys,Fpe),p.gc=function(t){Ss(this,t)},p.hc=function(){return this.c.hc()},p.ic=function(){return this.a=h(this.c.ic(),38),this.a.kc()},p.jc=function(){var t;Ag(!!this.a,Aw),t=h(this.a.lc(),13),this.c.jc(),this.b.a.d-=t._b(),t.Pb()};var Jgn=k(At,"AbstractMapBasedMultimap/KeySet/1",660);A(358,357,{109:1,115:1},YE),p.Jc=function(){return this.$c()},p.Xb=function(){return this._c()},p.$c=function(){return new X2(this.c,this.ad())},p._c=function(){var t;return t=this.b,t||(this.b=this.$c())},p.ad=function(){return h(this.d,115)};var Qgn=k(At,"AbstractMapBasedMultimap/SortedAsMap",358);A(396,358,EJe,nA),p.$c=function(){return new Zv(this.a,h(h(this.d,115),122))},p.Xb=function(){var t;return t=this.b,h(t||(this.b=new Zv(this.a,h(h(this.d,115),122))),196)},p._c=function(){var t;return t=this.b,h(t||(this.b=new Zv(this.a,h(h(this.d,115),122))),196)},p.ad=function(){return h(h(this.d,115),122)};var emn=k(At,"AbstractMapBasedMultimap/NavigableAsMap",396);A(327,356,SJe,X2),p.wc=function(){return this.b.Xb().wc()};var tmn=k(At,"AbstractMapBasedMultimap/SortedKeySet",327);A(299,327,V_e,Zv);var nmn=k(At,"AbstractMapBasedMultimap/NavigableKeySet",299);A(448,25,Y_,TI),p.nc=function(t){var i,a;return ol(this),a=this.d.Wb(),i=this.d.nc(t),i&&(++this.f.d,a&&o9(this)),i},p.oc=function(t){var i,a,l;return t.Wb()?!1:(l=(ol(this),this.d._b()),i=this.d.oc(t),i&&(a=this.d._b(),this.f.d+=a-l,l==0&&o9(this)),i)},p.Pb=function(){var t;t=(ol(this),this.d._b()),t!=0&&(this.d.Pb(),this.f.d-=t,k9(this))},p.pc=function(t){return ol(this),this.d.pc(t)},p.qc=function(t){return ol(this),this.d.qc(t)},p.Fb=function(t){return t===this?!0:(ol(this),ki(this.d,t))},p.Hb=function(){return ol(this),Hr(this.d)},p.tc=function(){return ol(this),new Rme(this)},p.vc=function(t){var i;return ol(this),i=this.d.vc(t),i&&(--this.f.d,k9(this)),i},p._b=function(){return ANe(this)},p.wc=function(){return ol(this),this.d.wc()},p.Ib=function(){return ol(this),Ga(this.d)};var imn=k(At,"AbstractMapBasedMultimap/WrappedCollection",448),yu=_r(Vn,"List");A(657,448,{20:1,25:1,13:1,15:1},t1e),p.jd=function(t){Ug(this,t)},p.wc=function(){return ol(this),this.d.wc()},p.bd=function(t,i){var a;ol(this),a=this.d.Wb(),h(this.d,15).bd(t,i),++this.a.d,a&&o9(this)},p.cd=function(t){return ol(this),h(this.d,15).cd(t)},p.dd=function(t){return ol(this),h(this.d,15).dd(t)},p.ed=function(){return ol(this),new KNe(this)},p.fd=function(t){return ol(this),new DUe(this,t)},p.gd=function(t){var i;return ol(this),i=h(this.d,15).gd(t),--this.a.d,k9(this),i},p.hd=function(t,i){return ol(this),h(this.d,15).hd(t,i)},p.kd=function(t,i){return ol(this),Q1e(this.a,this.e,h(this.d,15).kd(t,i),this.b?this.b:this)};var rmn=k(At,"AbstractMapBasedMultimap/WrappedList",657);A(967,657,{20:1,25:1,13:1,15:1,49:1},IFe);var smn=k(At,"AbstractMapBasedMultimap/RandomAccessWrappedList",967);A(558,1,ys,Rme),p.gc=function(t){Ss(this,t)},p.hc=function(){return nS(this),this.b.hc()},p.ic=function(){return nS(this),this.b.ic()},p.jc=function(){yFe(this)};var omn=k(At,"AbstractMapBasedMultimap/WrappedCollection/WrappedIterator",558);A(658,558,Ch,KNe,DUe),p.jc=function(){yFe(this)},p.Bc=function(t){var i;i=ANe(this.a)==0,(nS(this),h(this.b,120)).Bc(t),++this.a.a.d,i&&o9(this.a)},p.Cc=function(){return(nS(this),h(this.b,120)).Cc()},p.Dc=function(){return(nS(this),h(this.b,120)).Dc()},p.Ec=function(){return(nS(this),h(this.b,120)).Ec()},p.Fc=function(){return(nS(this),h(this.b,120)).Fc()},p.Gc=function(t){(nS(this),h(this.b,120)).Gc(t)};var amn=k(At,"AbstractMapBasedMultimap/WrappedList/WrappedListIterator",658);A(559,448,SJe,xJ),p.wc=function(){return ol(this),this.d.wc()};var cmn=k(At,"AbstractMapBasedMultimap/WrappedSortedSet",559);A(656,559,V_e,xge);var lmn=k(At,"AbstractMapBasedMultimap/WrappedNavigableSet",656);A(655,448,gu,Qge),p.wc=function(){return ol(this),this.d.wc()};var umn=k(At,"AbstractMapBasedMultimap/WrappedSet",655);A(974,1,gs,Z),p.Kb=function(t){var i,a;return i=t.kc(),a=h(t.lc(),13),UJ(a.wc(),new eY(i))};var fmn=k(At,"AbstractMapBasedMultimap/lambda$0$Type",974);A(973,1,gs,eY),p.Kb=function(t){return WSt(this.a,t)};var hmn=k(At,"AbstractMapBasedMultimap/lambda$2$Type",973);A(392,1,Nne),p.Fb=function(t){var i;return re(t,38)?(i=h(t,38),Dp(this.kc(),i.kc())&&Dp(this.lc(),i.lc())):!1},p.Hb=function(){var t,i;return t=this.kc(),i=this.lc(),(t==null?0:Hr(t))^(i==null?0:Hr(i))},p.mc=function(t){throw Y(new Pi)},p.Ib=function(){return this.kc()+"="+this.lc()};var dmn=k(At,MJe,392);A(1680,25,Y_),p.Pb=function(){this.ld().Pb()},p.pc=function(t){var i;return re(t,38)?(i=h(t,38),XLt(this.ld(),i.kc(),i.lc())):!1},p.vc=function(t){var i;return re(t,38)?(i=h(t,38),J7e(this.ld(),i.kc(),i.lc())):!1},p._b=function(){return this.ld()._b()};var pmn=k(At,"Multimaps/Entries",1680);A(975,1680,Y_),p.tc=function(){return this.a.Kc()},p.ld=function(){return this.a},p.wc=function(){return this.a.Lc()};var gmn=k(At,"AbstractMultimap/Entries",975);A(662,975,gu,mF),p.wc=function(){return this.a.Lc()},p.Fb=function(t){return sXe(this,t)},p.Hb=function(){return k$e(this)};var mmn=k(At,"AbstractMultimap/EntrySet",662);A(663,25,Y_,kd),p.Pb=function(){this.a.Pb()},p.pc=function(t){return CIt(this.a,t)},p.tc=function(){return this.a.Rc()},p._b=function(){return this.a.d},p.wc=function(){return this.a.Sc()};var bmn=k(At,"AbstractMultimap/Values",663);A(1681,25,{738:1,20:1,25:1,13:1}),p.sc=function(t){Hn(t),hw(this).sc(new hY(t))},p.wc=function(){var t;return t=hw(this).wc(),Kwe(t,new Te,64|t.qd()&1296,zee(this))},p.nc=function(t){return bpe(),!0},p.oc=function(t){return IOt(this,t)},p.Pb=function(){N9(new dpe(n1e(_0(this.a)).tc()))},p.pc=function(t){var i;return i=h(AS(_0(this.a),t),13),(i?i._b():0)>0},p.Fb=function(t){return x8t(this,t)},p.Hb=function(){return Hr(hw(this))},p.Wb=function(){return hw(this).Wb()},p.tc=function(){return new QBe(this,hw(this).tc())},p.vc=function(t){return vve(this,t,1)>0},p._b=function(){return zee(this)},p.Ib=function(){return Ga(hw(this))};var wmn=k(At,"AbstractMultiset",1681);A(557,654,F6),p.Oc=function(){return this.md()},p.Qc=function(){return this.nd()},p.Mc=function(t){return this.od(t)},p.Nc=function(t){return this.pd(t)},p.Hc=function(){var t;return t=this.f,t||(this.f=re(this.c,122)?new nA(this,h(this.c,122)):re(this.c,115)?new YE(this,h(this.c,115)):new FE(this,this.c))},p.nd=function(){return lw(),tS(),GP},p.Fb=function(t){return kee(this,t)},p.od=function(t){return h(er(this,t),19)},p.pd=function(t){return h(aP(this,t),19)};var vmn=k(At,"AbstractSetMultimap",557);A(1413,557,F6),p.md=function(){return new iw(this.b)},p.nd=function(){var t;return t=this.b,t?IPt(this.b):(_t(),new KR(new iw(this.b)))},p.Mc=function(t){return h(h(er(this,t),19),60)},p.od=function(t){return h(h(er(this,t),19),60)},p.Nc=function(t){return h(h(aP(this,t),19),60)},p.pd=function(t){return h(h(aP(this,t),19),60)},p.Hc=function(){var t;return t=this.f,t||(this.f=re(this.c,122)?new nA(this,h(this.c,122)):re(this.c,115)?new YE(this,h(this.c,115)):new FE(this,this.c))};var _mn=k(At,"AbstractSortedSetMultimap",1413);A(1414,1413,F6),p.Hc=function(){var t;return t=this.f,h(h(t||(this.f=re(this.c,122)?new nA(this,h(this.c,122)):re(this.c,115)?new YE(this,h(this.c,115)):new FE(this,this.c)),115),122)},p.Xb=function(){var t;return t=this.i,h(h(t||(this.i=re(this.c,122)?new Zv(this,h(this.c,122)):re(this.c,115)?new X2(this,h(this.c,115)):new XE(this,this.c)),60),196)};var ymn=k(At,"AbstractSortedKeySortedSetMultimap",1414);A(521,1483,One,s9),p.a=0;var xmn=k(At,"ArrayListMultimap",521);A(1156,1,Wp,GBe),p.qd=function(){return this.a.qd()&-262},p.rd=function(){return this.a.rd()},p.gc=function(t){this.a.gc(new $Be(t,this.b))},p.sd=function(t){return this.a.sd(new jBe(t,this.b))};var Emn=k(At,"CollectSpliterators/1",1156);A(1157,1,{},jBe),p.td=function(t){this.a.td(this.b.Kb(t))};var Smn=k(At,"CollectSpliterators/1/lambda$0$Type",1157);A(1158,1,{},$Be),p.td=function(t){this.a.td(this.b.Kb(t))};var Mmn=k(At,"CollectSpliterators/1/lambda$1$Type",1158);A(1159,1,Wp,fze),p.qd=function(){return this.a},p.rd=function(){return this.d&&(this.b=INe(this.b,this.d.rd())),INe(this.b,0)},p.gc=function(t){this.d&&(this.d.gc(t),this.d=null),this.c.gc(new WBe(this.e,t)),this.b=0},p.sd=function(t){for(;;){if(this.d&&this.d.sd(t))return kC(this.b,V7)&&(this.b=Qm(this.b,1)),!0;if(this.d=null,!this.c.sd(new VBe(this,this.e)))return!1}},p.a=0,p.b=0;var Tmn=k(At,"CollectSpliterators/1FlatMapSpliterator",1159);A(1160,1,{},VBe),p.td=function(t){eTt(this.a,this.b,t)};var Cmn=k(At,"CollectSpliterators/1FlatMapSpliterator/lambda$0$Type",1160);A(1161,1,{},WBe),p.td=function(t){YSt(this.b,this.a,t)};var Amn=k(At,"CollectSpliterators/1FlatMapSpliterator/lambda$1$Type",1161),Qxe;A(844,1,Qu,nY),p.Fb=function(t){return this===t},p.Kb=function(t){return Be(t)===Be(this.a)?xJe:t};var Pmn=k(At,"Collections2/1",844);A(220,1,Fne),p.vd=function(t){return this.ud(h(t,220))},p.ud=function(t){var i;return t==(so(),qre)?1:t==(Wr(),Hre)?-1:(i=(m9(),LA(this.a,t.a)),i!=0?i:re(this,467)==re(t,467)?0:re(this,467)?1:-1)},p.yd=function(){return this.a},p.Fb=function(t){return rwe(this,t)};var Lmn=k(At,"Cut",220);A(1508,220,Fne,rBe),p.ud=function(t){return t==this?0:1},p.wd=function(t){throw Y(new s8)},p.xd=function(t){t.a+="+\u221E)"},p.yd=function(){throw Y(new ba(TJe))},p.zd=function(t){return!1},p.Ib=function(){return"+\u221E"};var Hre,kmn=k(At,"Cut/AboveAll",1508);A(467,220,{220:1,467:1,3:1,34:1},SFe),p.wd=function(t){Ic((t.a+="(",t),this.a)},p.xd=function(t){Lg(Ic(t,this.a),93)},p.Hb=function(){return~Hr(this.a)},p.zd=function(t){return m9(),LA(this.a,t)<0},p.Ib=function(){return"/"+this.a+"\\"};var Rmn=k(At,"Cut/AboveValue",467);A(1507,220,Fne,sBe),p.ud=function(t){return t==this?0:-1},p.wd=function(t){t.a+="(-\u221E"},p.xd=function(t){throw Y(new s8)},p.yd=function(){throw Y(new ba(TJe))},p.zd=function(t){return!0},p.Ib=function(){return"-\u221E"};var qre,Imn=k(At,"Cut/BelowAll",1507);A(1509,220,Fne,MFe),p.wd=function(t){Ic((t.a+="[",t),this.a)},p.xd=function(t){Lg(Ic(t,this.a),41)},p.Hb=function(){return Hr(this.a)},p.zd=function(t){return m9(),LA(this.a,t)<=0},p.Ib=function(){return"\\"+this.a+"/"};var Dmn=k(At,"Cut/BelowValue",1509);A(482,1,hd),p.sc=function(t){mo(this,t)},p.Ib=function(){return zLt(h(A1e(this,"use Optional.orNull() instead of Optional.or(null)"),20).tc())};var Bmn=k(At,"FluentIterable",482);A(325,482,hd,ex),p.tc=function(){return Cn(this)};var Omn=k(At,"FluentIterable/2",325);A(1670,25,CJe),p.tc=function(){return this.Ad()},p.nc=function(t){throw Y(new Pi)},p.oc=function(t){throw Y(new Pi)},p.Pb=function(){throw Y(new Pi)},p.pc=function(t){return t!=null&&_x(this,t,!1)},p.vc=function(t){throw Y(new Pi)};var Nmn=k(At,"ImmutableCollection",1670);A(912,1670,CJe,iY),p.tc=function(){return bx((_t(),Yv(),uy))},p.pc=function(t){return!1},p.qc=function(t){return Gg(this.a,t)},p.Wb=function(){return!0},p.Ad=function(){return bx((_t(),Yv(),uy))},p._b=function(){return 0},p.yc=function(){return VJ(this.a)},p.zc=function(t){return u6(this.a,t)},p.Ib=function(){return Vp(this.a)};var Fmn=k(At,"ForwardingImmutableCollection",912);A(193,1670,Une),p.tc=function(){return this.Ad()},p.ed=function(){return new eQ(this,this._b(),0)},p.fd=function(t){return new eQ(this,this._b(),t)},p.jd=function(t){Ug(this,t)},p.wc=function(){return new di(this,16)},p.kd=function(t,i){return this.Bd(t,i)},p.bd=function(t,i){throw Y(new Pi)},p.Fb=function(t){return c8t(this,t)},p.Hb=function(){return QRt(this)},p.dd=function(t){return t==null?-1:SDt(this,t)},p.Ad=function(){return new eQ(this,this._b(),0)},p.gd=function(t){throw Y(new Pi)},p.hd=function(t,i){throw Y(new Pi)},p.Bd=function(t,i){var a;return Lee((a=new eOe(this),new Rg(a,t,i)))};var e3e,Umn=k(At,"ImmutableList",193);A(1675,193,Une),p.tc=function(){return bx(this.Cd().tc())},p.kd=function(t,i){return Lee(this.Cd().kd(t,i))},p.pc=function(t){return t!=null&&this.Cd().pc(t)},p.qc=function(t){return this.Cd().qc(t)},p.Fb=function(t){return ki(this.Cd(),t)},p.cd=function(t){return this.Cd().cd(t)},p.Hb=function(){return Hr(this.Cd())},p.dd=function(t){return this.Cd().dd(t)},p.Wb=function(){return this.Cd().Wb()},p.Ad=function(){return bx(this.Cd().tc())},p._b=function(){return this.Cd()._b()},p.Bd=function(t,i){return Lee(this.Cd().kd(t,i))},p.yc=function(){return this.Cd().zc(le(on,et,1,this.Cd()._b(),5,1))},p.zc=function(t){return this.Cd().zc(t)},p.Ib=function(){return Ga(this.Cd())};var zmn=k(At,"ForwardingImmutableList",1675);A(1671,1670,U6),p.tc=function(){return this.Ad()},p.wc=function(){return new di(this,1)},p.Fb=function(t){return sXe(this,t)},p.Hb=function(){return k$e(this)};var Gmn=k(At,"ImmutableSet",1671);A(550,1671,U6),p.tc=function(){return this.Ad()},p.pc=function(t){return t!=null&&RC(this.b,t)},p.qc=function(t){return zpe(this.b,t)},p.Hb=function(){return Hr(this.b.b)},p.Wb=function(){return this.b.b.Wb()},p.Ad=function(){return bx(new Nm(this.b.b.tc()))},p._b=function(){return this.b.b._b()},p.yc=function(){return this.b.b.yc()},p.zc=function(t){return tOe(this.b,t)},p.Ib=function(){return Ga(this.b.b)};var jmn=k(At,"ForwardingImmutableSet",550);A(1664,1663,AJe),p.Ac=function(){return _t(),new KR(this.a)},p.wc=function(){return new NR(this)};var $mn=k(At,"ForwardingSortedSet",1664);A(481,632,z7,i9),p.ec=function(t){return new S8e(this,t,this)},p.Zb=function(t,i){return eP(this,t,i,!1)};var Vmn=k(At,"HashBiMap",481);A(892,633,z7,S8e),p.dc=function(){return new vFe(this,this.a.b.Tb().tc())};var Wmn=k(At,"HashBiMap/1",892);A(479,1,ys),p.gc=function(t){Ss(this,t)},p.hc=function(){return this.b.hc()},p.ic=function(){return _Ne(this)},p.jc=function(){this.b.jc()};var Hmn=k(At,"TransformedIterator",479);A(893,479,ys,vFe),p.Ed=function(t){return new X9e(this,h(t,38))},p.Dd=function(e){return this.Ed(e)};var qmn=k(At,"HashBiMap/1/1",893);A(894,392,Nne,X9e),p.kc=function(){return this.c},p.lc=function(){return this.a.a.b.Vb(this.c)},p.mc=function(t){var i;return Ag(Ape(O9(this.a.a),this),$_e),i=this.a.a.b.Vb(this.c),Be(t)===Be(i)||t!=null&&ki(t,i)?t:(eP(this.a.a,this.c,t,!0),i)};var Xmn=k(At,"HashBiMap/1/1/1",894);A(298,557,F6,Kv),p.md=function(){return new m8(Eee(this.a))},p.a=2;var Ymn=k(At,"HashMultimap",298);A(372,392,{392:1,372:1,3:1,38:1},DR),p.kc=function(){return this.g},p.lc=function(){return this.i},p.mc=function(t){throw Y(new Pi)};var Zmn=k(At,"ImmutableEntry",372);A(903,550,U6,DDe);var Kmn=k(At,"ImmutableEnumSet",903);A(544,847,Bne,eQ);var Jmn=k(At,"ImmutableList/1",544);A(1561,550,PJe),p.tc=function(){return bx(new Nm(this.b.b.tc()))},p.wc=function(){return new NR(this)},p.pc=function(t){try{return t!=null&&RC(this.a,t)}catch(i){if(i=pr(i),re(i,177))return!1;throw Y(i)}},p.qc=function(t){var i,a;for(a=t.tc();a.hc();)if(i=a.ic(),i==null)return!1;try{return zpe(this.a,t)}catch(l){if(l=pr(l),re(l,177))return!1;throw Y(l)}},p.Ad=function(){return bx(new Nm(this.b.b.tc()))},p.yc=function(){return oje(this,le(on,et,1,this.b.b._b(),5,1))},p.zc=function(t){return $U(this,t)};var Mnt,t3e,Qmn=k(At,"ImmutableSortedSet",1561);A(904,482,hd,NNe),p.tc=function(){return Vge(this.a)},p.Ib=function(){return Vp(this.a)+" (cycled)"};var e1n=k(At,"Iterables/1",904);A(200,1,Qu,z),p.Kb=function(t){return h(t,20).tc()},p.Fb=function(t){return this===t};var t1n=k(At,"Iterables/12",200);A(905,482,hd,h9e),p.sc=function(t){Hn(t),this.b.sc(new HBe(this.a,t))},p.tc=function(){return qC(this)};var n1n=k(At,"Iterables/4",905);A(906,1,{},HBe),p.td=function(t){qEt(this.b,this.a,t)};var i1n=k(At,"Iterables/4/lambda$0$Type",906);A(907,482,hd,d9e),p.sc=function(t){Hn(t),this.a.sc(new qBe(t,this.b))},p.tc=function(){return Kh(this)};var r1n=k(At,"Iterables/5",907);A(908,1,{},qBe),p.td=function(t){this.a.td(this.b.Kb(t))};var s1n=k(At,"Iterables/5/lambda$0$Type",908),Tnt,n3e;A(945,1665,Bne,te),p.hc=function(){return!1},p.Cc=function(){return!1},p.ic=function(){throw Y(new K)},p.Dc=function(){return 0},p.Ec=function(){throw Y(new K)},p.Fc=function(){return-1};var o1n=k(At,"Iterators/1",945);A(555,257,$7,hR),p.hc=function(){return!this.a},p.ic=function(){if(this.a)throw Y(new K);return this.a=!0,this.b},p.a=!1;var a1n=k(At,"Iterators/11",555);A(946,1,ys,oe),p.gc=function(t){Ss(this,t)},p.hc=function(){return!1},p.ic=function(){throw Y(new K)},p.jc=function(){Ag(!1,Aw)};var c1n=k(At,"Iterators/2",946);A(947,257,$7,fR),p.hc=function(){return this.a.hc()},p.ic=function(){return this.a.ic()};var l1n=k(At,"Iterators/3",947);A(948,1,ys,R8e),p.gc=function(t){Ss(this,t)},p.hc=function(){return this.a.hc()||this.b.tc().hc()},p.ic=function(){return nbe(this)},p.jc=function(){this.a.jc()};var u1n=k(At,"Iterators/4",948);A(950,949,$7,XBe);var f1n=k(At,"Iterators/6",950);A(951,479,ys,_Fe),p.Dd=function(t){return this.a.Kb(t)};var h1n=k(At,"Iterators/7",951);A(647,1,ys),p.gc=function(t){Ss(this,t)},p.hc=function(){return Gn(this)},p.ic=function(){return Tn(this)},p.jc=function(){Ag(!!this.c,Aw),this.c.jc(),this.c=null};var d1n=k(At,"MultitransformedIterator",647);A(182,647,{182:1,43:1},Nd),p.Fd=function(t){return h(t,43)};var p1n=k(At,"Iterators/ConcatenatedIterator",182);A(648,647,ys,ppe),p.Fd=function(t){return BRt(h(t,43))};var g1n=k(At,"Iterators/ConcatenatedIterator/1",648);A(1540,557,F6,LWe),p.Pb=function(){K0e(this),kE(this.a,this.a)},p.md=function(){return new Fge(this.b)},p.Pc=function(t){return new PVe(this,t,this.b)},p.Kc=function(){return new Bge(this)},p.Lc=function(){var t;return new di((t=this.g,h(t||(this.g=new mF(this)),19)),17)},p.Xb=function(){var t;return t=this.i,t||(this.i=re(this.c,122)?new Zv(this,h(this.c,122)):re(this.c,115)?new X2(this,h(this.c,115)):new XE(this,this.c))},p.Rc=function(){return Yr(),rA(new Bge(this),(i_(),p5))},p.Sc=function(){var t;return UJ(new di((t=this.g,h(t||(this.g=new mF(this)),19)),17),new ne)},p.b=2;var m1n=k(At,"LinkedHashMultimap",1540);A(1543,1,gs,ne),p.Kb=function(t){return h(t,38).lc()};var b1n=k(At,"LinkedHashMultimap/0methodref$getValue$Type",1543);A(728,1,ys,Bge),p.gc=function(t){Ss(this,t)},p.ic=function(){return Qkt(this)},p.hc=function(){return this.a!=this.b.a},p.jc=function(){Ag(!!this.c,Aw),J7e(this.b,this.c.g,this.c.i),this.c=null};var w1n=k(At,"LinkedHashMultimap/1",728);A(310,372,{392:1,372:1,310:1,1706:1,3:1,38:1},S1e),p.Gd=function(){return this.f},p.Hd=function(t){this.c=t},p.Id=function(t){this.f=t},p.d=0;var Cnt=k(At,"LinkedHashMultimap/ValueEntry",310);A(1541,1660,{1706:1,20:1,25:1,13:1,19:1},PVe),p.nc=function(t){var i,a,l,f,g;for(g=W_e*x1e((t==null?0:Hr(t))*H_e,15),i=g&this.b.length-1,f=this.b[i],a=f;a;a=a.a)if(a.d==g&&Dp(a.i,t))return!1;return l=new S1e(this.c,t,g,f),uBe(this.d,l),l.f=this,this.d=l,kE(this.g.a.b,l),kE(l,this.g.a),this.b[i]=l,++this.f,++this.e,IBt(this),!0},p.Pb=function(){var t,i;for(CK(this.b,null),this.f=0,t=this.a;t!=this;t=t.Gd())i=h(t,310),kE(i.b,i.e);this.a=this,this.d=this,++this.e},p.pc=function(t){var i,a;for(a=W_e*x1e((t==null?0:Hr(t))*H_e,15),i=this.b[a&this.b.length-1];i;i=i.a)if(i.d==a&&Dp(i.i,t))return!0;return!1},p.sc=function(t){var i;for(Hn(t),i=this.a;i!=this;i=i.Gd())t.td(h(i,310).i)},p.Gd=function(){return this.a},p.tc=function(){return new cUe(this)},p.vc=function(t){return AXe(this,t)},p.Hd=function(t){this.d=t},p.Id=function(t){this.a=t},p._b=function(){return this.f},p.e=0,p.f=0;var v1n=k(At,"LinkedHashMultimap/ValueSet",1541);A(1542,1,ys,cUe),p.gc=function(t){Ss(this,t)},p.hc=function(){return Gme(this),this.b!=this.c},p.ic=function(){var t,i;if(Gme(this),this.b==this.c)throw Y(new K);return t=h(this.b,310),i=t.i,this.d=t,this.b=t.f,i},p.jc=function(){Gme(this),Ag(!!this.d,Aw),AXe(this.c,this.d.i),this.a=this.c.e,this.d=null},p.a=0;var _1n=k(At,"LinkedHashMultimap/ValueSet/1",1542);A(689,1677,One,$pe),p.Hc=function(){return _0(this)},p.Fb=function(t){return kee(this,t)},p.Mc=function(t){return new xK(this,t)},p.Nc=function(t){return PQ(this,t)},p.Pb=function(){JJ(this)},p.Qb=function(t){return Ppe(this,t)},p.Ic=function(){return new jpe(this)},p.Jc=function(){return new tY(this)},p.Kc=function(){throw Y(new AQ("should never be called"))},p.Tc=function(t){return new xK(this,t)},p.Wb=function(){return!this.a},p.Uc=function(t){return PQ(this,t)},p._b=function(){return this.d},p.c=0,p.d=0;var y1n=k(At,"LinkedListMultimap",689);A(41,25,Ix),p.jd=function(t){Ug(this,t)},p.wc=function(){return new di(this,16)},p.bd=function(t,i){throw Y(new Cp("Add not supported on this list"))},p.nc=function(t){return this.bd(this._b(),t),!0},p.Pb=function(){this.Jd(0,this._b())},p.Fb=function(t){return Cve(this,t)},p.Hb=function(){return ybe(this)},p.dd=function(t){return Zje(this,t)},p.tc=function(){return new ME(this)},p.ed=function(){return this.fd(0)},p.fd=function(t){return new Ns(this,t)},p.gd=function(t){throw Y(new Cp("Remove not supported on this list"))},p.Jd=function(t,i){var a,l;for(l=this.fd(t),a=t;a0||this.c.hc()},p.ic=function(){if(!(this.d>0||this.c.hc()))throw Y(new K);return this.d==0&&(this.b=h(this.c.ic(),312),this.f=this.d=h(this.b.a.lc(),13)._b()),--this.d,this.a=!0,this.b.a.kc()},p.jc=function(){Ag(this.a,Aw),this.f==1?this.c.jc():vve(this.e,this.b.a.kc(),1)>0,--this.f,this.a=!1},p.a=!1,p.d=0,p.f=0;var i0n=k(At,"Multisets/MultisetIteratorImpl",981);A(667,1,gs,Te),p.Kb=function(t){return new di(NRt(h(h(t,300).a.lc(),13)._b(),h(t,300).a.kc()),16)};var r0n=k(At,"Multisets/lambda$0$Type",667);A(1684,1,Or),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)};var s0n=k(At,"Ordering",1684);A(1565,1684,Gne,Q),p.Ld=function(t,i){return IMt(h(t,34),h(i,34))},p.Ib=function(){return"Ordering.natural()"};var Pnt,o0n=k(At,"NaturalOrdering",1565);A(464,1,{138:1,464:1,3:1,56:1},dwe),p.Mb=function(t){return gAt(this,h(t,34))},p.Nb=function(t){return this.Mb(t)},p.Fb=function(t){var i;return re(t,464)?(i=h(t,464),rwe(this.a,i.a)&&rwe(this.b,i.b)):!1},p.Hb=function(){return Hr(this.a)*31+Hr(this.b)},p.Ib=function(){return aze(this.a,this.b)};var a0n=k(At,"Range",464);A(485,1675,Une,K9),p.Cd=function(){return this.a};var c0n=k(At,"RegularImmutableList",485);A(554,550,U6,TK);var GP,l0n=k(At,"RegularImmutableSet",554);A(729,1561,PJe,M1e);var u0n=k(At,"RegularImmutableSortedSet",729);A(543,1664,{543:1,3:1,20:1,13:1,196:1,19:1,60:1},uOe);var f0n=k(At,"Sets/UnmodifiableNavigableSet",543);A(1165,1675,Une,a8e),p.Cd=function(){return this.a};var h0n=k(At,"SingletonImmutableList",1165);A(326,1671,U6,$2),p.tc=function(){return Mo(),new hR(this.a)},p.pc=function(t){return ki(this.a,t)},p.Ad=function(){return Mo(),new hR(this.a)},p._b=function(){return 1};var d0n=k(At,"SingletonImmutableSet",326);A(1415,1414,F6,jUe),p.Hc=function(){var t;return t=this.f,h(h(t||(this.f=re(this.c,122)?new nA(this,h(this.c,122)):re(this.c,115)?new YE(this,h(this.c,115)):new FE(this,this.c)),115),122)},p.Xb=function(){var t;return t=this.i,h(h(t||(this.i=re(this.c,122)?new Zv(this,h(this.c,122)):re(this.c,115)?new X2(this,h(this.c,115)):new XE(this,this.c)),60),196)},p.Pc=function(t){return t==null&&this.a.Ld(null,null),new iw(this.b)};var p0n=k(At,"TreeMultimap",1415);A(78,1,{3:1,78:1}),p.Nd=function(t){return new w.Error(t)},p.Od=function(){return this.g},p.Pd=function(){var t,i,a;a=this.g==null?null:this.g.replace(new w.RegExp(` +`,"g")," "),i=(t=Um(this.ql),a==null?t:t+": "+a),VMt(this,$Lt(this.Nd(i))),Vi(this)},p.Ib=function(){return $Ue(this,this.Od())},p.e=kJe,p.i=!1,p.n=!0;var Lnt=k(da,"Throwable",78);A(104,78,{3:1,104:1,78:1});var g0n=k(da,"Exception",104);A(54,104,Zd,Mp,na);var m0n=k(da,"RuntimeException",54);A(539,54,Zd);var b0n=k(da,"JsException",539);A(760,539,Zd);var w0n=k(z6,"JavaScriptExceptionBase",760);A(435,760,{435:1,3:1,104:1,54:1,78:1},wWe),p.Od=function(){return KBt(this),this.c},p.Qd=function(){return Be(this.b)===Be(i3e)?null:this.b};var i3e,v0n=k(Y_e,"JavaScriptException",435),knt=k(Y_e,"JavaScriptObject$",0),Yre;A(1640,1,{});var _0n=k(Y_e,"Scheduler",1640),Fz=0,Rnt=0,Uz=-1;A(787,1640,{},F);var r3e,y0n=k(z6,"SchedulerImpl",787),Zre;A(1653,1,{});var x0n=k(z6,"StackTraceCreator/Collector",1653);A(761,1653,{},O),p.Rd=function(t){var i={},a,l=[];t[Z_e]=l;for(var f=arguments.callee.caller;f;){var g=(oS(),f.name||(f.name=xRt(f.toString())));l.push(g);var m=":"+g,v=i[m];if(v){var y,E;for(y=0,E=v.length;y=0?"+":"")+(a/60|0),i=(a<0?-a:a)%60<10?"0"+(a<0?-a:a)%60:""+(a<0?-a:a)%60,(Tqe(),$nt)[this.q.getDay()]+" "+Vnt[this.q.getMonth()]+" "+eJ(this.q.getDate())+" "+eJ(this.q.getHours())+":"+eJ(this.q.getMinutes())+":"+eJ(this.q.getSeconds())+" GMT"+t+i+" "+this.q.getFullYear()};var zz=k(Vn,"Date",181);A(1622,181,OJe,JHe),p.a=!1,p.b=0,p.c=0,p.d=0,p.e=0,p.f=0,p.g=!1,p.i=0,p.j=0,p.k=0,p.n=0,p.o=0,p.p=0;var D0n=k("com.google.gwt.i18n.shared.impl","DateRecord",1622);A(1659,1,{}),p.Vd=function(){return null},p.Wd=function(){return null},p.Xd=function(){return null},p.Yd=function(){return null},p.Zd=function(){return null};var B0n=k(Ox,"JSONValue",1659);A(209,1659,{209:1},Om,wF),p.Fb=function(t){return re(t,209)?H1e(this.a,h(t,209).a):!1},p.Ud=function(){return Xde},p.Hb=function(){return B1e(this.a)},p.Vd=function(){return this},p.Ib=function(){var t,i,a;for(a=new ou("["),i=0,t=this.a.length;i0&&(a.a+=","),Ic(a,mx(this,i));return a.a+="]",a.a};var O0n=k(Ox,"JSONArray",209);A(443,1659,{443:1},vF),p.Ud=function(){return Yde},p.Wd=function(){return this},p.Ib=function(){return vt(),""+this.a},p.a=!1;var Int,Dnt,N0n=k(Ox,"JSONBoolean",443);A(877,54,Zd,BDe);var F0n=k(Ox,"JSONException",877);A(913,1659,{},at),p.Ud=function(){return n8},p.Ib=function(){return Xc};var Bnt,U0n=k(Ox,"JSONNull",913);A(259,1659,{259:1},dR),p.Fb=function(t){return re(t,259)?this.a==h(t,259).a:!1},p.Ud=function(){return QZ},p.Hb=function(){return yr(ce(this.a))},p.Xd=function(){return this},p.Ib=function(){return this.a+""},p.a=0;var z0n=k(Ox,"JSONNumber",259);A(191,1659,{191:1},SC,lC),p.Fb=function(t){return re(t,191)?H1e(this.a,h(t,191).a):!1},p.Ud=function(){return Zde},p.Hb=function(){return B1e(this.a)},p.Yd=function(){return this},p.Ib=function(){var t,i,a,l,f,g;for(g=new ou("{"),t=!0,f=rbe(this,le(Se,be,2,0,6,1)),a=0,l=f.length;a=0?":"+this.c:"")+")"},p.c=0;var b3e=k(da,"StackTraceElement",287);Ent={3:1,476:1,34:1,2:1};var Se=k(da,X_e,2);A(100,381,{476:1},Tp,MC,su);var abn=k(da,"StringBuffer",100);A(98,381,{476:1},f0,tw,ou);var cbn=k(da,"StringBuilder",98);A(763,79,lie,FDe);var lbn=k(da,"StringIndexOutOfBoundsException",763);A(1722,1,{});var w3e,v3e;A(46,54,{3:1,104:1,54:1,78:1,46:1},Pi,Cp);var ubn=k(da,"UnsupportedOperationException",46);A(216,210,{3:1,34:1,210:1,216:1},kI,mpe),p.vd=function(t){return jZe(this,h(t,216))},p.$d=function(){return xw(dKe(this))},p.Fb=function(t){var i;return this===t?!0:re(t,216)?(i=h(t,216),this.e==i.e&&jZe(this,i)==0):!1},p.Hb=function(){var t;return this.b!=0?this.b:this.a<54?(t=Wc(this.f),this.b=nr(Kr(t,-1)),this.b=33*this.b+nr(Kr(Pg(t,32),-1)),this.b=17*this.b+yr(this.e),this.b):(this.b=17*UVe(this.c)+yr(this.e),this.b)},p.Ib=function(){return dKe(this)},p.a=0,p.b=0,p.d=0,p.e=0,p.f=0;var Unt,_1,_3e,y3e,x3e,E3e,S3e,M3e,Qre=k("java.math","BigDecimal",216);A(89,210,{3:1,34:1,210:1,89:1},hwe,Up,l_,Owe,QWe,Tg),p.vd=function(t){return FWe(this,h(t,89))},p.$d=function(){return xw(Ine(this,0))},p.Fb=function(t){return Obe(this,t)},p.Hb=function(){return UVe(this)},p.Ib=function(){return Ine(this,0)},p.b=-2,p.c=0,p.d=0,p.e=0;var ese,Gz,T3e,tse,jz,cM,ly=k("java.math","BigInteger",89),znt,Gnt,Xx,VP;A(441,1666,$S),p.Pb=function(){nl(this)},p.Qb=function(t){return w0(this,t)},p.Rb=function(t){return CVe(this,t,this.e)||CVe(this,t,this.d)},p.Tb=function(){return new Ep(this)},p.Vb=function(t){return Ii(this,t)},p.Zb=function(t,i){return dr(this,t,i)},p.$b=function(t){return hS(this,t)},p._b=function(){return OE(this)};var fbn=k(Vn,"AbstractHashMap",441);A(242,fd,gu,Ep),p.Pb=function(){this.a.Pb()},p.pc=function(t){return Y7e(this,t)},p.tc=function(){return new Zm(this.a)},p.vc=function(t){var i;return Y7e(this,t)?(i=h(t,38).kc(),this.a.$b(i),!0):!1},p._b=function(){return this.a._b()};var hbn=k(Vn,"AbstractHashMap/EntrySet",242);A(243,1,ys,Zm),p.gc=function(t){Ss(this,t)},p.ic=function(){return L0(this)},p.hc=function(){return this.b},p.jc=function(){RGe(this)},p.b=!1;var dbn=k(Vn,"AbstractHashMap/EntrySetIterator",243);A(433,1,ys,ME),p.gc=function(t){Ss(this,t)},p.hc=function(){return y8(this)},p.ic=function(){return _Ue(this)},p.jc=function(){xf(this)},p.b=0,p.c=-1;var pbn=k(Vn,"AbstractList/IteratorImpl",433);A(94,433,Ch,Ns),p.jc=function(){xf(this)},p.Bc=function(t){td(this,t)},p.Cc=function(){return this.b>0},p.Dc=function(){return this.b},p.Ec=function(){return Rn(this.b>0),this.a.cd(this.c=--this.b)},p.Fc=function(){return this.b-1},p.Gc=function(t){s_(this.c!=-1),this.a.hd(this.c,t)};var gbn=k(Vn,"AbstractList/ListIteratorImpl",94);A(227,41,Ix,Rg),p.bd=function(t,i){g_(t,this.b),this.c.bd(this.a+t,i),++this.b},p.cd=function(t){return ai(t,this.b),this.c.cd(this.a+t)},p.gd=function(t){var i;return ai(t,this.b),i=this.c.gd(this.a+t),--this.b,i},p.hd=function(t,i){return ai(t,this.b),this.c.hd(this.a+t,i)},p._b=function(){return this.b},p.a=0,p.b=0;var mbn=k(Vn,"AbstractList/SubList",227);A(352,fd,gu,Gv),p.Pb=function(){this.a.Pb()},p.pc=function(t){return this.a.Qb(t)},p.tc=function(){var t;return t=this.a.Tb().tc(),new pR(t)},p.vc=function(t){return this.a.Qb(t)?(this.a.$b(t),!0):!1},p._b=function(){return this.a._b()};var bbn=k(Vn,"AbstractMap/1",352);A(542,1,ys,pR),p.gc=function(t){Ss(this,t)},p.hc=function(){return this.a.hc()},p.ic=function(){var t;return t=h(this.a.ic(),38),t.kc()},p.jc=function(){this.a.jc()};var wbn=k(Vn,"AbstractMap/1/1",542);A(223,25,Y_,bh),p.Pb=function(){this.a.Pb()},p.pc=function(t){return this.a.Rb(t)},p.tc=function(){var t;return t=this.a.Tb().tc(),new a0(t)},p._b=function(){return this.a._b()};var vbn=k(Vn,"AbstractMap/2",223);A(321,1,ys,a0),p.gc=function(t){Ss(this,t)},p.hc=function(){return this.a.hc()},p.ic=function(){var t;return t=h(this.a.ic(),38),t.lc()},p.jc=function(){this.a.jc()};var _bn=k(Vn,"AbstractMap/2/1",321);A(440,1,{440:1,38:1}),p.Fb=function(t){var i;return re(t,38)?(i=h(t,38),tl(this.d,i.kc())&&tl(this.e,i.lc())):!1},p.kc=function(){return this.d},p.lc=function(){return this.e},p.Hb=function(){return H8(this.d)^H8(this.e)},p.mc=function(t){return eme(this,t)},p.Ib=function(){return this.d+"="+this.e};var ybn=k(Vn,"AbstractMap/AbstractEntry",440);A(351,440,{440:1,351:1,38:1},S8);var xbn=k(Vn,"AbstractMap/SimpleEntry",351);A(1672,1,G7),p.Fb=function(t){var i;return re(t,38)?(i=h(t,38),tl(this.kc(),i.kc())&&tl(this.lc(),i.lc())):!1},p.Hb=function(){return H8(this.kc())^H8(this.lc())},p.Ib=function(){return this.kc()+"="+this.lc()};var Ebn=k(Vn,MJe,1672);A(1685,1666,EJe),p.Wc=function(t){return Xze(this,t)},p.Qb=function(t){return AK(this,t)},p.Tb=function(){return new AF(this)},p.Vb=function(t){return Dc(Sbe(this,t))},p.Xb=function(){return new jv(this)};var Sbn=k(Vn,"AbstractNavigableMap",1685);A(668,fd,gu,AF),p.pc=function(t){return re(t,38)&&Xze(this.b,h(t,38))},p.tc=function(){return new aI(this.b)},p.vc=function(t){var i;return re(t,38)?(i=h(t,38),IGe(this.b,i)):!1},p._b=function(){return this.b.c};var Mbn=k(Vn,"AbstractNavigableMap/EntrySet",668);A(488,fd,V_e,jv),p.wc=function(){return new NR(this)},p.Pb=function(){PR(this.a)},p.pc=function(t){return AK(this.a,t)},p.tc=function(){var t;return t=new aI(new JR(this.a).b),new uC(t)},p.vc=function(t){return AK(this.a,t)?(fA(this.a,t),!0):!1},p._b=function(){return this.a.c};var Tbn=k(Vn,"AbstractNavigableMap/NavigableKeySet",488);A(489,1,ys,uC),p.gc=function(t){Ss(this,t)},p.hc=function(){return y8(this.a.a)},p.ic=function(){var t;return t=dJ(this.a),t.kc()},p.jc=function(){j8e(this.a)};var Cbn=k(Vn,"AbstractNavigableMap/NavigableKeySet/1",489);A(1693,25,Y_),p.nc=function(t){return dS(RS(this,t)),!0},p.oc=function(t){return dn(t),u9(t!=this,"Can't add a queue to itself"),wo(this,t)},p.Pb=function(){for(;eee(this)!=null;);};var Abn=k(Vn,"AbstractQueue",1693);A(407,25,{4:1,20:1,25:1,13:1},AE,q9e),p.nc=function(t){return J1e(this,t),!0},p.Pb=function(){a0e(this)},p.pc=function(t){return nVe(new hA(this),t)},p.Wb=function(){return wpe(this)},p.tc=function(){return new hA(this)},p.vc=function(t){return iLt(new hA(this),t)},p._b=function(){return this.c-this.b&this.a.length-1},p.wc=function(){return new di(this,272)},p.zc=function(t){var i,a;return a=this.c-this.b&this.a.length-1,t.lengtha&&Gr(t,a,null),t},p.b=0,p.c=0;var Pbn=k(Vn,"ArrayDeque",407);A(408,1,ys,hA),p.gc=function(t){Ss(this,t)},p.hc=function(){return this.a!=this.b},p.ic=function(){return DU(this)},p.jc=function(){e$e(this)},p.a=0,p.b=0,p.c=-1;var Lbn=k(Vn,"ArrayDeque/IteratorImpl",408);A(12,41,UJe,ke,Gl,_f),p.bd=function(t,i){v0(this,t,i)},p.nc=function(t){return De(this,t)},p.oc=function(t){return Lr(this,t)},p.Pb=function(){this.c=le(on,et,1,0,5,1)},p.pc=function(t){return Qo(this,t,0)!=-1},p.sc=function(t){cd(this,t)},p.cd=function(t){return St(this,t)},p.dd=function(t){return Qo(this,t,0)},p.Wb=function(){return this.c.length==0},p.tc=function(){return new j(this)},p.gd=function(t){return P0(this,t)},p.vc=function(t){return Sa(this,t)},p.Jd=function(t,i){S7e(this,t,i)},p.hd=function(t,i){return Hu(this,t,i)},p._b=function(){return this.c.length},p.jd=function(t){fa(this,t)},p.yc=function(){return mJ(this)},p.zc=function(t){return vo(this,t)};var rVt=k(Vn,"ArrayList",12);A(7,1,ys,j),p.gc=function(t){Ss(this,t)},p.hc=function(){return Zo(this)},p.ic=function(){return $(this)},p.jc=function(){cA(this)},p.a=0,p.b=-1;var kbn=k(Vn,"ArrayList/1",7);A(155,41,zJe,Bl),p.pc=function(t){return Zje(this,t)!=-1},p.sc=function(t){var i,a,l,f;for(dn(t),a=this.a,l=0,f=a.length;l=0},p.qc=function(t){return Gg(this.b,t)},p.tc=function(){return new Nm(rS(this.b).b.tc())},p.vc=function(t){return p$e(this,t)},p._b=function(){return this.b.c.length},p.wc=function(){return new di(this,256)},p.yc=function(){return mJ(this.b)},p.zc=function(t){return vo(this.b,t)};var xwn=k(Vn,"PriorityQueue",453);A(214,1,{214:1},Jee,J9),p.a=0,p.b=0;var R3e,I3e,cVt=0,Ewn=k(Vn,"Random",214);A(39,1,Wp,di,sx,PGe),p.qd=function(){return this.a},p.rd=function(){return r1e(this),this.c},p.gc=function(t){r1e(this),this.d.gc(t)},p.sd=function(t){return U0e(this,t)},p.a=0,p.c=0;var Swn=k(Vn,"Spliterators/IteratorSpliterator",39);A(382,39,Wp,NR);var Mwn=k(Vn,"SortedSet/1",382);A(625,1,{},PF),p.ie=function(t){this.a.td(t)};var Twn=k(Vn,"Spliterator/OfDouble/0methodref$accept$Type",625);A(626,1,{},LF),p.ie=function(t){this.a.td(t)};var Cwn=k(Vn,"Spliterator/OfDouble/1methodref$accept$Type",626);A(642,1,Wp),p.gc=function(t){IBe(this,t)},p.qd=function(){return this.d},p.rd=function(){return this.e},p.d=0,p.e=0;var Awn=k(Vn,"Spliterators/BaseSpliterator",642);A(929,642,Wp),p.gc=function(t){re(t,273)?Cme(this,h(t,273)):Cme(this,new LF(t))},p.sd=function(t){return re(t,273)?a_(this,h(t,273)):a_(this,new PF(t))};var Pwn=k(Vn,"Spliterators/AbstractDoubleSpliterator",929);A(446,642,Wp);var Lwn=k(Vn,"Spliterators/AbstractSpliterator",446);A(790,1,Wp),p.gc=function(t){IBe(this,t)},p.qd=function(){return this.b},p.rd=function(){return this.d-this.c},p.b=0,p.c=0,p.d=0;var kwn=k(Vn,"Spliterators/BaseArraySpliterator",790);A(791,790,Wp,SUe),p.gc=function(t){nPt(this,t)},p.sd=function(t){return hkt(this,t)};var Rwn=k(Vn,"Spliterators/ArraySpliterator",791);A(789,1,ys,xBe),p.gc=function(t){re(t,273)?Gze(this,h(t,273)):Gze(this,new hC(t))},p.ic=function(){return eU(this)},p.jc=function(){jDe()},p.ie=function(t){this.b=t},p.hc=function(){return this.a||(this.a=a_(this.c,this)),this.a},p.a=!1,p.b=0;var Iwn=k(Vn,"Spliterators/DoubleConsumerIterator",789);A(523,41,jJe,Zh),p.bd=function(t,i){oA(t,this.a.c.length+1),v0(this.a,t,i)},p.nc=function(t){return De(this.a,t)},p.oc=function(t){return Lr(this.a,t)},p.Pb=function(){this.a.c=le(on,et,1,0,5,1)},p.pc=function(t){return Qo(this.a,t,0)!=-1},p.qc=function(t){return Gg(this.a,t)},p.sc=function(t){cd(this.a,t)},p.cd=function(t){return oA(t,this.a.c.length),St(this.a,t)},p.dd=function(t){return Qo(this.a,t,0)},p.Wb=function(){return this.a.c.length==0},p.tc=function(){return new j(this.a)},p.gd=function(t){return oA(t,this.a.c.length),P0(this.a,t)},p.Jd=function(t,i){S7e(this.a,t,i)},p.hd=function(t,i){return oA(t,this.a.c.length),Hu(this.a,t,i)},p._b=function(){return this.a.c.length},p.jd=function(t){fa(this.a,t)},p.kd=function(t,i){return new Rg(this.a,t,i)},p.yc=function(){return mJ(this.a)},p.zc=function(t){return vo(this.a,t)},p.Ib=function(){return Vp(this.a)};var Dwn=k(Vn,"Vector",523);A(596,523,jJe,sK);var Bwn=k(Vn,"Stack",596);A(254,1,{},A0),p.Ib=function(){return this.a?this.e.length==0?this.a.a:this.a.a+(""+this.e):this.c};var Own=k(Vn,"StringJoiner",254);A(487,1685,{3:1,109:1,122:1,115:1},iOe,WJ),p.Pb=function(){PR(this)},p.Tb=function(){return new JR(this)},p.Zb=function(t,i){return kU(this,t,i)},p.$b=function(t){return fA(this,t)},p._b=function(){return this.c},p.c=0;var Nwn=k(Vn,"TreeMap",487);A(397,1,ys,aI),p.gc=function(t){Ss(this,t)},p.ic=function(){return dJ(this)},p.hc=function(){return y8(this.a)},p.jc=function(){j8e(this)};var Fwn=k(Vn,"TreeMap/EntryIterator",397);A(449,668,gu,JR),p.Pb=function(){PR(this.a)};var Uwn=k(Vn,"TreeMap/EntrySet",449);A(398,351,{440:1,351:1,38:1,398:1},jQ),p.b=!1;var lVt=k(Vn,"TreeMap/Node",398);A(560,1,{},se),p.Ib=function(){return"State: mv="+this.c+" value="+this.d+" done="+this.a+" found="+this.b},p.a=!1,p.b=!1,p.c=!1;var zwn=k(Vn,"TreeMap/State",560);A(278,23,pie,M8),p.je=function(){return!1},p.ke=function(){return!1};var nse,D3e,B3e,O3e,Vz=Ti(Vn,"TreeMap/SubMapType",278,Di,i4t,fTt);A(982,278,pie,WNe),p.ke=function(){return!0};var Gwn=Ti(Vn,"TreeMap/SubMapType/1",982,Vz,null,null);A(983,278,pie,nFe),p.je=function(){return!0},p.ke=function(){return!0};var jwn=Ti(Vn,"TreeMap/SubMapType/2",983,Vz,null,null);A(984,278,pie,HNe),p.je=function(){return!0};var $wn=Ti(Vn,"TreeMap/SubMapType/3",984,Vz,null,null),Xnt;A(212,fd,{3:1,20:1,25:1,13:1,196:1,19:1,60:1,212:1},Qde,iw),p.wc=function(){return new NR(this)},p.nc=function(t){return R9(this,t)},p.Pb=function(){PR(this.a)},p.pc=function(t){return AK(this.a,t)},p.tc=function(){var t;return t=new aI(new JR(new jv(this.a).a).b),new uC(t)},p.vc=function(t){return Uge(this,t)},p._b=function(){return this.a.c};var uVt=k(Vn,"TreeSet",212);A(845,1,{},_Y),p.le=function(t,i){return BMt(this.a,t,i)};var Vwn=k(gie,"BinaryOperator/lambda$0$Type",845);A(846,1,{},Fr),p.le=function(t,i){return kp(h(t,21).a,h(i,21).a)<=0?t:i};var Wwn=k(gie,"BinaryOperator/lambda$1$Type",846);A(843,1,gs,de),p.Kb=function(t){return t};var Hwn=k(gie,"Function/lambda$0$Type",843);A(627,1,os,RF),p.Nb=function(t){return!this.a.Nb(t)};var qwn=k(gie,"Predicate/lambda$0$Type",627);A(150,23,{3:1,34:1,23:1,150:1},PK);var N3e,nh,Bw,ih=Ti(Xs,"Collector/Characteristics",150,Di,pLt,hTt),Ynt;A(684,1,{},W8e,fqe);var Xwn=k(Xs,"Collector/CollectorImpl",684);A(1053,1,gs,yY),p.Kb=function(t){return vt(),!!i0e(t)};var Ywn=k(Xs,"Collectors/12methodref$test$Type",1053);A(365,1,{},Vt),p.Kd=function(t,i){h(t,13).nc(i)};var Zwn=k(Xs,"Collectors/20methodref$add$Type",365);A(367,1,{},pn),p.ne=function(){return new ke};var Kwn=k(Xs,"Collectors/21methodref$ctor$Type",367);A(331,1,{},qn),p.ne=function(){return new zr};var Jwn=k(Xs,"Collectors/23methodref$ctor$Type",331);A(332,1,{},bi),p.Kd=function(t,i){Cr(h(t,67),i)};var Qwn=k(Xs,"Collectors/24methodref$add$Type",332);A(1050,1,{},Yi),p.le=function(t,i){return rOe(h(t,15),h(i,13))};var evn=k(Xs,"Collectors/4methodref$addAll$Type",1050);A(683,1,{},$i),p.le=function(t,i){return $1e(t,i)};var tvn=k(Xs,"Collectors/lambda$1$Type",683);A(1055,1,{},xY),p.ne=function(){return X(q(on,1),et,1,5,[this.a])};var nvn=k(Xs,"Collectors/lambda$10$Type",1055);A(1056,1,{},bR),p.Kd=function(t,i){XCt(this.a,t)};var ivn=k(Xs,"Collectors/lambda$11$Type",1056);A(1057,1,{},DF),p.le=function(t,i){return _At(this.a,t,i)};var rvn=k(Xs,"Collectors/lambda$12$Type",1057);A(1058,1,gs,Tr),p.Kb=function(t){return __(t)[0]};var svn=k(Xs,"Collectors/lambda$13$Type",1058);A(366,1,{},wr),p.le=function(t,i){return h(t,13).oc(h(i,13)),h(t,13)};var ovn=k(Xs,"Collectors/lambda$21$Type",366);A(333,1,{},Si),p.le=function(t,i){return wo(h(t,67),h(i,67)),h(t,67)};var avn=k(Xs,"Collectors/lambda$25$Type",333);A(334,1,gs,it),p.Kb=function(t){return h(t,67)};var cvn=k(Xs,"Collectors/lambda$26$Type",334);A(1049,1,{},EY),p.Kd=function(t,i){_It(this.a,t,i)};var lvn=k(Xs,"Collectors/lambda$3$Type",1049);A(1051,1,{},We),p.le=function(t,i){return oIt(h(t,109),h(i,109),new Yi)};var uvn=k(Xs,"Collectors/lambda$4$Type",1051);A(1052,1,gs,SY),p.Kb=function(t){return C6t(this.a,t)};var fvn=k(Xs,"Collectors/lambda$5$Type",1052);A(1054,1,{},En),p.ne=function(){var t;return t=new C0,O0(t,(vt(),vt(),!1),new ke),O0(t,!0,new ke),t};var hvn=k(Xs,"Collectors/lambda$8$Type",1054);A(645,1,{}),p.d=!1;var dvn=k(Xs,"TerminatableStream",645);A(1416,645,{607:1,1701:1},JFe);var pvn=k(Xs,"DoubleStream/DoubleStreamSource",1416);A(1417,1,{},MY),p.ie=function(t){NWe(this.a,t)};var gvn=k(Xs,"DoubleStream/DoubleStreamSource/lambda$2$Type",1417),fVt=_r(Xs,"Stream");A(940,446,Wp,I8e),p.sd=function(t){for(;Lkt(this);){if(this.a.sd(t))return!0;this.a=null}return!1};var mvn=k(Xs,"Stream/2",940);A(941,1,{},TY),p.td=function(t){fMt(this.a,t)};var bvn=k(Xs,"Stream/2/lambda$0$Type",941);A(942,1,H6,CY),p.fe=function(){oQ(this.a)};var wvn=k(Xs,"Stream/3methodref$close$Type",942);A(943,1,H6,AY),p.fe=function(){oQ(this.a)};var vvn=k(Xs,"Stream/4methodref$close$Type",943);A(644,446,Wp,S0e),p.sd=function(t){for(this.b=!1;!this.b&&this.c.sd(new mOe(this,t)););return this.b},p.b=!1;var _vn=k(Xs,"Stream/FilterSpliterator",644);A(932,1,{},mOe),p.td=function(t){yAt(this.a,this.b,t)};var yvn=k(Xs,"Stream/FilterSpliterator/lambda$0$Type",932);A(930,929,Wp,tGe);var xvn=k(Xs,"Stream/MapToDoubleSpliterator",930);A(646,1,{},Hpe),p.td=function(t){JEt(this.a,this.b,t)};var Evn=k(Xs,"Stream/MapToDoubleSpliterator/lambda$0$Type",646);A(643,446,Wp,v0e),p.sd=function(t){return O8e(this,t)};var Svn=k(Xs,"Stream/MapToObjSpliterator",643);A(931,1,{},bOe),p.td=function(t){QEt(this.a,this.b,t)};var Mvn=k(Xs,"Stream/MapToObjSpliterator/lambda$0$Type",931);A(45,645,{607:1,1701:1,1700:1},oi);var Tvn=k(Xs,"Stream/StreamSource",45);A(936,446,Wp,D8e),p.sd=function(t){for(;kkt(this);){if(this.a.sd(t))return!0;oQ(this.b),this.b=null,this.a=null}return!1};var Cvn=k(Xs,"Stream/StreamSource/1",936);A(937,1,{},PY),p.td=function(t){FCt(this.a,t)};var Avn=k(Xs,"Stream/StreamSource/1/lambda$0$Type",937);A(938,446,Wp,IUe),p.sd=function(t){var i;return this.a||(i=new ke,this.b.a.gc(new LY(i)),_t(),fa(i,this.c),this.a=new di(i,16)),U0e(this.a,t)},p.a=null;var Pvn=k(Xs,"Stream/StreamSource/5",938);A(939,1,{},LY),p.td=function(t){De(this.a,t)};var Lvn=k(Xs,"Stream/StreamSource/5/2methodref$add$Type",939);A(933,1,{},ve),p.td=function(t){};var kvn=k(Xs,"Stream/StreamSource/lambda$0$Type",933);A(934,1,{},kY),p.le=function(t,i){return XSt(this.a,t,i)};var Rvn=k(Xs,"Stream/StreamSource/lambda$3$Type",934);A(935,1,{},wOe),p.td=function(t){CSt(this.b,this.a,t)};var Ivn=k(Xs,"Stream/StreamSource/lambda$4$Type",935);A(553,1,{},wt),p.td=function(t){SF(this,t)};var Dvn=k(Xs,"Stream/ValueConsumer",553);A(944,1,{},RY),p.td=function(t){hIt(this.a,t)};var Bvn=k(Xs,"TerminatableStream/lambda$0$Type",944),hVt=0,F3e,U3e=0,Wz;A(1480,1,{},_ze);var Ovn=k(VJe,"Scanline",1480),dVt=_r(VJe,WJe);A(1450,1,{},_je);var Nvn=k(dd,"CGraph",1450);A(309,1,{309:1},x7e),p.b=0,p.c=0,p.d=0,p.g=0,p.i=0,p.k=Ts;var Fvn=k(dd,"CGroup",309);A(723,1,{},epe);var Uvn=k(dd,"CGroup/CGroupBuilder",723);A(57,1,{57:1},u8e),p.Ib=function(){return this.j?ti(this.j.Kb(this)):(Fd(Hz),Hz.o+"@"+(g0(this)>>>0).toString(16))},p.f=0,p.i=Ts;var Hz=k(dd,"CNode",57);A(722,1,{},tpe);var zvn=k(dd,"CNode/CNodeBuilder",722),Znt;A(1236,1,{},gn),p.se=function(t,i){return 0},p.te=function(t,i){return 0};var Gvn=k(dd,qJe,1236);A(1505,1,{},vn),p.pe=function(t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V;for(E=Jr,l=new j(t.a.b);l.al.d.c||l.d.c==g.d.c&&l.d.b=0?"b"+t+"["+RQ(this.a)+"]":"b["+RQ(this.a)+"]"):"b_"+m0(this)};var V_n=k(X6,"FBendpoint",497);A(262,131,{3:1,262:1,93:1,131:1},g8e),p.Ib=function(){return RQ(this)};var W_n=k(X6,"FEdge",262);A(202,131,{3:1,202:1,93:1,131:1},iU);var hVt=k(X6,"FGraph",202);A(454,329,{3:1,454:1,329:1,93:1,131:1},vze),p.Ib=function(){return this.b==null||this.b.length==0?"l["+RQ(this.a)+"]":"l_"+this.b};var H_n=k(X6,"FLabel",454);A(146,329,{3:1,146:1,329:1,93:1,131:1},sUe),p.Ib=function(){return X1e(this)},p.b=0;var q_n=k(X6,"FNode",146);A(1691,1,{}),p.Ee=function(t){b_e(this,t)},p.Fe=function(){BHe(this)},p.d=0;var X_n=k(wye,"AbstractForceModel",1691);A(568,1691,{568:1},H$e),p.De=function(t,i){var a,l,f,g,m;return vXe(this.f,t,i),f=Bc(Ua(i.d),t.d),m=w.Math.sqrt(f.a*f.a+f.b*f.b),l=w.Math.max(0,m-sQ(t.e)/2-sQ(i.e)/2),a=eVe(this.e,t,i),a>0?g=-MAt(l,this.c)*a:g=xMt(l,this.b)*h(G(t,(Tf(),lM)),21).a,au(f,g/m),f},p.Ee=function(t){b_e(this,t),this.a=h(G(t,(Tf(),Jz)),21).a,this.c=ce(Xe(G(t,Qz))),this.b=ce(Xe(G(t,dse)))},p.Ge=function(t){return t0&&(g-=eEt(l,this.a)*a),au(f,g*this.b/m),f},p.Ee=function(t){var i,a,l,f,g,m,v;for(b_e(this,t),this.b=ce(Xe(G(t,(Tf(),pse)))),this.c=this.b/h(G(t,Jz),21).a,l=t.e.c.length,g=0,f=0,v=new j(t.e);v.a0},p.a=0,p.b=0,p.c=0;var Z_n=k(wye,"FruchtermanReingoldModel",569);A(748,1,pd,BX),p.ue=function(t){zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,K7),""),"Force Model"),"Determines the model for force calculation."),hEe),(o1(),ms)),dEe),Ht((i1(),Ln))))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,vye),""),"Iterations"),"The number of iterations on the force model."),He(300)),xc),Po),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,_ye),""),"Repulsive Power"),"Determines how many bend points are added to the edge; such bend points are regarded as repelling particles in the force model"),He(0)),xc),Po),Ht(bd)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Aie),""),"FR Temperature"),"The temperature is used as a scaling factor for particle displacements."),Jd),nc),Eo),Ht(Ln)))),mc(t,Aie,K7,Eit),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Pie),""),"Eades Repulsion"),"Factor for repulsive forces in Eades' model."),5),nc),Eo),Ht(Ln)))),mc(t,Pie,K7,_it),$Ke((new NX,t))};var bit,wit,hEe,vit,_it,yit,xit,Eit,K_n=k(_P,"ForceMetaDataProvider",748);A(387,23,{3:1,34:1,23:1,387:1},Kpe);var hse,Kz,dEe=Ti(_P,"ForceModelStrategy",387,Di,DPt,pTt),Sit;A(880,1,pd,NX),p.ue=function(t){$Ke(t)};var Mit,pEe,Jz,gEe,Tit,mEe,bEe,lM,Cit,dse,wEe,Ait,Pit,Qz,pse,J_n=k(_P,"ForceOptions",880);A(881,1,{},io),p.Be=function(){var t;return t=new npe,t},p.Ce=function(t){};var Q_n=k(_P,"ForceOptions/ForceFactory",881),y5,HP,Yx,eG;A(749,1,pd,sF),p.ue=function(t){zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Eye),""),"Fixed Position"),"Prevent that the node is moved by the layout algorithm."),(vt(),vt(),!1)),(o1(),_a)),lo),Ht((i1(),ga))))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Sye),""),"Desired Edge Length"),"Either specified for parent nodes or for individual edges, where the latter takes higher precedence."),100),nc),Eo),sr(Ln,X(q(Qp,1),Oe,163,0,[bd]))))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Mye),""),"Layout Dimension"),"Dimensions that are permitted to be altered during layout."),vEe),ms),MEe),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Tye),""),"Stress Epsilon"),"Termination criterion for the iterative process."),Jd),nc),Eo),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Cye),""),"Iteration Limit"),"Maximum number of performed iterations. Takes higher precedence than 'epsilon'."),He(zi)),xc),Po),Ht(Ln)))),cKe((new OX,t))};var Lit,kit,vEe,Rit,Iit,Dit,eyn=k(_P,"StressMetaDataProvider",749);A(884,1,pd,OX),p.ue=function(t){cKe(t)};var tG,_Ee,yEe,xEe,EEe,SEe,tyn=k(_P,"StressOptions",884);A(885,1,{},gf),p.Be=function(){var t;return t=new m8e,t},p.Ce=function(t){};var nyn=k(_P,"StressOptions/StressFactory",885);A(959,244,K_,m8e),p.Ae=function(t,i){var a,l,f,g;for(ii(i,dQe,1),ce(mt(rn(t,(UI(),EEe))))||Qqe(new npe,t,bc(i,1)),l=bVe(t),a=YZe(this.a,l),g=a.tc();g.hc();)f=h(g.ic(),202),bzt(this.b,f),lFt(this.b);l=aJe(a),iJe(l),On(i)};var iyn=k(Rie,"StressLayoutProvider",959);A(882,1,{},iK),p.c=0,p.e=0,p.g=0;var ryn=k(Rie,"StressMajorization",882);A(348,23,{3:1,34:1,23:1,348:1},LK);var gse,mse,bse,MEe=Ti(Rie,"StressMajorization/Dimension",348,Di,xLt,gTt),Bit;A(883,1,Or,Vv),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return jMt(this.a,t,i)};var syn=k(Rie,"StressMajorization/lambda$0$Type",883);A(985,1,{},D7e);var oyn=k(K6,"ElkLayered",985);A(986,1,{},Rs),p.td=function(t){zkt(this.a,t)};var ayn=k(K6,"ElkLayered/lambda$0$Type",986);A(987,1,{},Q1),p.td=function(t){Ee(h(t,31),($e(),IG),(bS(),EG))};var cyn=k(K6,"ElkLayered/lambda$1$Type",987);A(1033,1,{},rFe);var Oit,Nit,Fit,lyn=k(K6,"GraphConfigurator",1033);A(958,244,K_,ml),p.Ae=function(t,i){var a;a=Y9t(new SNe,t),Be(rn(t,($e(),iL)))===Be((e1(),d3))?h6t(this.a,a,i):_Ft(this.a,a,i),nJe(new oF,a)};var uyn=k(K6,"LayeredLayoutProvider",958);A(328,23,{3:1,34:1,23:1,328:1},FR);var Dh,Zx,Qa,ec,qo,TEe=Ti(K6,"LayeredPhases",328,Di,k4t,mTt),Uit;A(1407,1,{},U$e),p.i=0;var zit,fyn=k(J6,"ComponentsToCGraphTransformer",1407),Git;A(1408,1,{},Lm),p.He=function(t,i){return w.Math.min(t.a!=null?ce(t.a):t.c.i,i.a!=null?ce(i.a):i.c.i)},p.Ie=function(t,i){return w.Math.min(t.a!=null?ce(t.a):t.c.i,i.a!=null?ce(i.a):i.c.i)};var hyn=k(J6,"ComponentsToCGraphTransformer/1",1408);A(80,1,{80:1}),p.i=0,p.k=!0,p.o=Ts;var wse=k(xP,"CNode",80);A(282,80,{282:1,80:1},jge,uwe),p.Ib=function(){return""};var dyn=k(J6,"ComponentsToCGraphTransformer/CRectNode",282);A(1391,1,{},b2);var vse,_se,pyn=k(J6,"OneDimensionalComponentsCompaction",1391);A(1392,1,Qu,zb),p.Fb=function(t){return this===t},p.Kb=function(t){return jee(),vt(),h(h(t,48).a,80).d.e!=0};var gyn=k(J6,"OneDimensionalComponentsCompaction/lambda$0$Type",1392);A(1393,1,Qu,bk),p.Fb=function(t){return this===t},p.Kb=function(t){return jee(),vt(),!!(mWe(h(h(t,48).a,80).j,h(h(t,48).b,110))||h(h(t,48).a,80).d.e!=0&&mWe(h(h(t,48).a,80).j,h(h(t,48).b,110)))};var myn=k(J6,"OneDimensionalComponentsCompaction/lambda$1$Type",1393);A(1410,1,{},rUe);var byn=k(xP,"CGraph",1410);A(172,1,{172:1},ite),p.b=0,p.c=0,p.e=0,p.g=!0,p.i=Ts;var wyn=k(xP,"CGroup",172);A(1409,1,{},Pe),p.He=function(t,i){return w.Math.max(t.a!=null?ce(t.a):t.c.i,i.a!=null?ce(i.a):i.c.i)},p.Ie=function(t,i){return w.Math.max(t.a!=null?ce(t.a):t.c.i,i.a!=null?ce(i.a):i.c.i)};var vyn=k(xP,qJe,1409);A(1411,1,{},DXe),p.d=!1;var jit,yse=k(xP,ZJe,1411);A(1412,1,Qu,xt),p.Fb=function(t){return this===t},p.Kb=function(t){return kpe(),vt(),h(h(t,48).a,80).d.e!=0};var _yn=k(xP,KJe,1412);A(726,1,{},Hme),p.a=!1,p.b=!1,p.c=!1,p.d=!1;var yyn=k(xP,JJe,726);A(1521,1,{},R9e);var xyn=k(ez,QJe,1521),x5=_r(h1,WJe);A(1522,1,{341:1},VUe),p.Ne=function(t){N9t(this,h(t,524))};var Eyn=k(ez,eQe,1522);A(1523,1,Or,Kt),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return to(h(t,282).g.c+h(t,282).g.b/2,h(i,282).g.c+h(i,282).g.b/2)};var Syn=k(ez,tQe,1523);A(524,1,{524:1},Jpe),p.a=!1;var Myn=k(ez,nQe,524);A(1524,1,Or,tn),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return gBt(t,i)};var Tyn=k(ez,iQe,1524);A(102,1,{102:1},jE,Ome),p.Fb=function(t){var i;return t==null||dVt!=sl(t)?!1:(i=h(t,102),tl(this.c,i.c)&&tl(this.d,i.d))},p.Hb=function(){return Aee(X(q(on,1),et,1,5,[this.c,this.d]))},p.Ib=function(){return"("+this.c+Ca+this.d+(this.a?"cx":"")+this.b+")"},p.a=!0,p.c=0,p.d=0;var dVt=k(h1,"Point",102);A(373,23,{3:1,34:1,23:1,373:1},P8);var eb,Ow,fy,Nw,$it=Ti(h1,"Point/Quadrant",373,Di,t4t,bTt),Vit;A(1398,1,{},f0),p.b=null,p.c=null,p.d=null,p.e=null,p.f=null;var Wit,Hit,qit,Xit,Yit,Cyn=k(h1,"RectilinearConvexHull",1398);A(516,1,{341:1},QU),p.Ne=function(t){Pkt(this,h(t,102))},p.b=0;var CEe,Ayn=k(h1,"RectilinearConvexHull/MaximalElementsEventHandler",516);A(1400,1,Or,Zi),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return Rpe(),to(ce(Xe(t)),ce(Xe(i)))};var Pyn=k(h1,"RectilinearConvexHull/MaximalElementsEventHandler/lambda$0$Type",1400);A(1399,1,{341:1},yje),p.Ne=function(t){f9t(this,h(t,102))},p.a=0,p.b=null,p.c=null,p.d=null,p.e=null;var Lyn=k(h1,"RectilinearConvexHull/RectangleEventHandler",1399);A(1401,1,Or,Rr),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return EA(),h(t,102).c==h(i,102).c?to(h(i,102).d,h(t,102).d):to(h(t,102).c,h(i,102).c)};var kyn=k(h1,"RectilinearConvexHull/lambda$0$Type",1401);A(1402,1,Or,Xr),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return EA(),h(t,102).c==h(i,102).c?to(h(t,102).d,h(i,102).d):to(h(t,102).c,h(i,102).c)};var Ryn=k(h1,"RectilinearConvexHull/lambda$1$Type",1402);A(1403,1,Or,Yt),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return EA(),h(t,102).c==h(i,102).c?to(h(i,102).d,h(t,102).d):to(h(i,102).c,h(t,102).c)};var Iyn=k(h1,"RectilinearConvexHull/lambda$2$Type",1403);A(1404,1,Or,bs),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return EA(),h(t,102).c==h(i,102).c?to(h(t,102).d,h(i,102).d):to(h(i,102).c,h(t,102).c)};var Dyn=k(h1,"RectilinearConvexHull/lambda$3$Type",1404);A(1405,1,Or,Vs),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return IOt(t,i)};var Byn=k(h1,"RectilinearConvexHull/lambda$4$Type",1405);A(1406,1,{},yze);var Oyn=k(h1,"Scanline",1406);A(1694,1,{});var Nyn=k(nm,"AbstractGraphPlacer",1694);A(458,1,{458:1},f9e);var fs,Fyn=k(nm,"ComponentGroup",458);A(1076,1694,{},l8),p.Oe=function(t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W;if(this.a.c=le(on,et,1,0,5,1),i.a.c=le(on,et,1,0,5,1),t.Wb()){i.e.a=0,i.e.b=0;return}for(m=h(t.cd(0),31),No(i,m),f=t.tc();f.hc();)l=h(f.ic(),31),m6t(this,l);for(W=new fo,g=ce(Xe(G(m,($e(),woe)))),E=new j(this.a);E.aN&&(Ue=0,qe+=B+f,B=0),ee=m.c,A6(m,Ue+ee.a,qe+ee.b),Wf(ee),a=w.Math.max(a,Ue+fe.a),B=w.Math.max(B,fe.b),Ue+=fe.a+f;if(i.e.a=a,i.e.b=qe+B,ce(mt(G(g,hoe)))){for(l=new xs,dJe(l,t,f),R=t.tc();R.hc();)C=h(R.ic(),31),tr(Wf(C.c),l.e);tr(Wf(i.e),l.a)}GGe(i,t)};var Yyn=k(nm,"SimpleRowGraphPlacer",1074);A(1075,1,Or,Lc),p.Ld=function(t,i){return HRt(h(t,31),h(i,31))},p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)};var Zyn=k(nm,"SimpleRowGraphPlacer/1",1075),Zit;A(1032,1,ef,zf),p.Mb=function(t){var i;return i=h(G(h(t,234).b,($e(),Lo)),74),!!i&&i.b!=0},p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)};var Kyn=k(tz,"CompoundGraphPostprocessor/1",1032);A(1031,1,kr,ENe),p.Pe=function(t,i){EHe(this,h(t,31),i)};var Jyn=k(tz,"CompoundGraphPreprocessor",1031);A(400,1,{400:1},KVe),p.c=!1;var Qyn=k(tz,"CompoundGraphPreprocessor/ExternalPort",400);A(234,1,{234:1},d9),p.Ib=function(){return tI(this.c)+":"+Oje(this.b)};var e2n=k(tz,"CrossHierarchyEdge",234);A(687,1,Or,BF),p.Ld=function(t,i){return JDt(this,h(t,234),h(i,234))},p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)};var t2n=k(tz,"CrossHierarchyEdgeComparator",687);A(279,131,{3:1,279:1,93:1,131:1}),p.o=0;var n2n=k(Ka,"LGraphElement",279);A(14,279,{3:1,14:1,279:1,93:1,131:1},Op),p.Ib=function(){return Oje(this)};var xu=k(Ka,"LEdge",14);A(31,279,{3:1,20:1,31:1,279:1,93:1,131:1},J0e),p.sc=function(t){mo(this,t)},p.tc=function(){return new j(this.b)},p.Ib=function(){return this.b.c.length==0?"G-unlayered"+Vp(this.a):this.a.c.length==0?"G-layered"+Vp(this.b):"G[layerless"+Vp(this.a)+", layers"+Vp(this.b)+"]"};var Kit=k(Ka,"LGraph",31);A(591,1,{}),p.Qe=function(){return this.e.k},p.xe=function(t){return G(this.e,t)},p.Re=function(){return this.e.n},p.Se=function(){return this.e.o},p.ye=function(t){return cw(this.e,t)},p.Te=function(t){this.e.k.a=t.a,this.e.k.b=t.b},p.Ue=function(t){this.e.n.a=t.a,this.e.n.b=t.b},p.Ve=function(t){this.e.o=t};var i2n=k(Ka,"LGraphAdapters/AbstractLShapeAdapter",591);A(520,1,{741:1},bf),p.We=function(){var t,i;if(!this.b)for(this.b=ed(this.a.b.c.length),i=new j(this.a.b);i.a0&&$$e(t.charCodeAt(i-1),wQe);)--i;if(g "+this.a+" "+tI(this.c)},p.a=0,p.b=0,p.d=0;var B3n=k(An,"SplineSelfLoopRouter/LoopPadding",188);A(1294,1,ef,b9e),p.Mb=function(t){return F5t(this,h(t,188))},p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)},p.a=0,p.c=0;var O3n=k(An,"SplineSelfLoopRouter/LoopPadding/EnclosingPredicate",1294);A(1293,1,Or,KO),p.Ld=function(t,i){return oSt(h(t,188),h(i,188))},p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)};var N3n=k(An,"SplineSelfLoopRouter/LoopPadding/MarginComparator",1293);A(415,1,ef,Qb),p.Mb=function(t){return h(t,188).c==this.a},p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)};var F3n=k(An,"SplineSelfLoopRouter/LoopPadding/PortSidePredicate",415);A(414,1,{414:1},hze),p.c=0,p.d=0,p.e=0;var U3n=k(An,"SplineSelfLoopRouter/SelfLoopEdge",414);A(1292,1,Or,NH),p.Ld=function(t,i){return _Et(h(t,414),h(i,414))},p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)};var z3n=k(An,"SplineSelfLoopRouter/SelfLoopEdge/StepSizeComparator",1292);A(1451,715,{},T$e),p.qe=function(t){var i,a,l,f;switch(this.c=t,this.a.g){case 2:i=new ke,Fa(go(new oi(null,new di(this.c.a.b,16)),new jH),new LOe(this,i)),w6(this,new $H),cd(i,new FH),i.c=le(on,et,1,0,5,1),Fa(go(new oi(null,new di(this.c.a.b,16)),new JO),new zF(i)),w6(this,new Pd),cd(i,new Lk),i.c=le(on,et,1,0,5,1),a=QNe(M$e(wI(new oi(null,new di(this.c.a.b,16)),new gC(this))),new oE),Fa(new oi(null,new di(this.c.a.a,16)),new SOe(a,i)),w6(this,new QO),cd(i,new eN),i.c=le(on,et,1,0,5,1);break;case 3:l=new ke,w6(this,new Pk),f=QNe(M$e(wI(new oi(null,new di(this.c.a.b,16)),new WY(this))),new UH),Fa(go(new oi(null,new di(this.c.a.b,16)),new Ak),new POe(f,l)),w6(this,new zH),cd(l,new GH),l.c=le(on,et,1,0,5,1);break;default:throw Y(new pe)}},p.b=0;var G3n=k(qr,"EdgeAwareScanlineConstraintCalculation",1451);A(1452,1,ef,Pk),p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)},p.Mb=function(t){return re(h(t,57).g,153)};var j3n=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$0$Type",1452);A(1453,1,{},WY),p.oe=function(t){return ZNt(this.a,t)};var $3n=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$1$Type",1453);A(1464,1,{},FH),p.td=function(t){h(t,340).fe()};var V3n=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$10$Type",1464);A(1465,1,os,JO),p.Nb=function(t){return re(h(t,57).g,8)};var W3n=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$11$Type",1465);A(1467,1,{},zF),p.td=function(t){k6t(this.a,t)};var H3n=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$12$Type",1467);A(1468,1,ef,Pd),p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)},p.Mb=function(t){return re(h(t,57).g,8)};var q3n=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$13$Type",1468);A(1469,1,{},Lk),p.td=function(t){h(t,340).fe()};var X3n=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$14$Type",1469);A(1470,1,{},gC),p.oe=function(t){return KNt(this.a,t)};var Y3n=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$15$Type",1470);A(1471,1,{},oE),p.me=function(){return 0};var Z3n=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$16$Type",1471);A(1473,1,{},SOe),p.td=function(t){lAt(this.a,this.b,t)},p.a=0;var K3n=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$17$Type",1473);A(1474,1,ef,QO),p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)},p.Mb=function(t){return!0};var J3n=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$18$Type",1474);A(1475,1,{},eN),p.td=function(t){h(t,340).fe()};var Q3n=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$19$Type",1475);A(1454,1,{},UH),p.me=function(){return 0};var eEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$2$Type",1454);A(1456,1,H6,MOe),p.fe=function(){ZA(this.b,this.a,-1)},p.a=0;var tEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$20$Type",1456);A(1461,1,H6,TOe),p.fe=function(){ZA(this.a,this.b,-1)},p.b=0;var nEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$21$Type",1461);A(1466,1,H6,COe),p.fe=function(){ZA(this.b,this.a,-1)},p.a=0;var iEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$22$Type",1466);A(1472,1,H6,AOe),p.fe=function(){sYe(this.a,this.b,-1)},p.b=0;var rEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$23$Type",1472);A(1455,1,os,Ak),p.Nb=function(t){return re(h(t,57).g,8)};var sEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$3$Type",1455);A(1457,1,{},POe),p.td=function(t){uAt(this.a,this.b,t)},p.a=0;var oEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$4$Type",1457);A(1458,1,ef,zH),p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)},p.Mb=function(t){return!0};var aEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$5$Type",1458);A(1459,1,{},GH),p.td=function(t){h(t,340).fe()};var cEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$6$Type",1459);A(1460,1,os,jH),p.Nb=function(t){return re(h(t,57).g,153)};var lEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$7$Type",1460);A(1462,1,{},LOe),p.td=function(t){Qkt(this.a,this.b,t)};var uEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$8$Type",1462);A(1463,1,ef,$H),p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)},p.Mb=function(t){return re(h(t,57).g,153)};var fEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$9$Type",1463);A(1232,1,kr,kFe),p.Pe=function(t,i){jzt(this,h(t,31),i)};var srt,hEn=k(qr,"HorizontalGraphCompactor",1232);A(1233,1,{},B2),p.se=function(t,i){var a,l,f;return Be(G(this.a.a,($e(),cm)))===Be((ld(),ub))&&(re(t.g,153)&&re(i.g,8)||re(i.g,153)&&re(t.g,8))?ce(mt(G(this.a.a,BG)))?0:10:R0e(t,i)||(a=p_(t),l=p_(i),a&&a.j==(Xt(),Qr)||l&&l.j==(Xt(),Qr))?0:(f=h(G(this.a.a,(Ie(),Uw)),266),fMt(f,a?a.j:(Xt(),Nr),l?l.j:(Xt(),Nr)))},p.te=function(t,i){var a,l,f;return R0e(t,i)?1:(a=p_(t),l=p_(i),f=h(G(this.a.a,(Ie(),Uw)),266),Gge(f,a?a.j:(Xt(),Nr),l?l.j:(Xt(),Nr)))};var dEn=k(qr,"HorizontalGraphCompactor/1",1233);A(1234,1,{},S2),p.re=function(t,i){return PC(),t.a.i==0};var pEn=k(qr,"HorizontalGraphCompactor/lambda$0$Type",1234);A(1235,1,{},Id),p.re=function(t,i){return gPt(this.a,t,i)};var gEn=k(qr,"HorizontalGraphCompactor/lambda$1$Type",1235);A(1422,1,{},Hje);var ort,art,mEn=k(qr,"LGraphToCGraphTransformer",1422);A(1430,1,os,VH),p.Nb=function(t){return t!=null};var bEn=k(qr,"LGraphToCGraphTransformer/0methodref$nonNull$Type",1430);A(1423,1,gs,WH),p.Kb=function(t){return Vu(),Ga(G(h(h(t,57).g,8),(Ie(),Jn)))};var wEn=k(qr,"LGraphToCGraphTransformer/lambda$0$Type",1423);A(1424,1,gs,kk),p.Kb=function(t){return Vu(),sWe(h(h(t,57).g,153))};var vEn=k(qr,"LGraphToCGraphTransformer/lambda$1$Type",1424);A(1435,1,os,tN),p.Nb=function(t){return Vu(),re(h(t,57).g,153)};var _En=k(qr,"LGraphToCGraphTransformer/lambda$10$Type",1435);A(1439,1,{},$b),p.td=function(t){var i,a;Vu(),i=t.d.c-t.e.c,a=h(t.g,153),cd(a.b,new YY(i)),cd(a.c,new ZY(i)),mo(a.i,new GF(i))};var yEn=k(qr,"LGraphToCGraphTransformer/lambda$11$Type",1439);A(1440,1,gs,RT),p.Kb=function(t){return Vu(),new oi(null,new sx(Cn(fr(h(t,8)))))};var xEn=k(qr,"LGraphToCGraphTransformer/lambda$12$Type",1440);A(1441,1,os,HH),p.Nb=function(t){return Vu(),Jo(h(t,14))};var EEn=k(qr,"LGraphToCGraphTransformer/lambda$13$Type",1441);A(1442,1,{},HY),p.td=function(t){Gkt(this.a,t)};var SEn=k(qr,"LGraphToCGraphTransformer/lambda$14$Type",1442);A(1443,1,gs,qH),p.Kb=function(t){return Vu(),new oi(null,new di(h(t,26).a,16))};var MEn=k(qr,"LGraphToCGraphTransformer/lambda$15$Type",1443);A(1444,1,gs,XH),p.Kb=function(t){return Vu(),new oi(null,new sx(Cn(fr(h(t,8)))))};var TEn=k(qr,"LGraphToCGraphTransformer/lambda$16$Type",1444);A(1445,1,gs,M2),p.Kb=function(t){return Vu(),h(G(h(t,14),(Ie(),JP)),15)};var CEn=k(qr,"LGraphToCGraphTransformer/lambda$17$Type",1445);A(1446,1,os,wg),p.Nb=function(t){return Vu(),!!h(t,15)&&!h(t,15).Wb()};var AEn=k(qr,"LGraphToCGraphTransformer/lambda$18$Type",1446);A(1447,1,{},qY),p.td=function(t){JNt(this.a,h(t,15))};var PEn=k(qr,"LGraphToCGraphTransformer/lambda$19$Type",1447);A(1426,1,{},XY),p.td=function(t){lLt(this.a,t)};var LEn=k(qr,"LGraphToCGraphTransformer/lambda$2$Type",1426);A(1425,1,{},kOe),p.td=function(t){o4t(this.a,this.b,t)};var kEn=k(qr,"LGraphToCGraphTransformer/lambda$20$Type",1425);A(1436,1,{},YY),p.td=function(t){_St(this.a,t)},p.a=0;var REn=k(qr,"LGraphToCGraphTransformer/lambda$21$Type",1436);A(1437,1,{},ZY),p.td=function(t){ySt(this.a,t)},p.a=0;var IEn=k(qr,"LGraphToCGraphTransformer/lambda$22$Type",1437);A(1438,1,{},GF),p.td=function(t){xSt(this.a,t)},p.a=0;var DEn=k(qr,"LGraphToCGraphTransformer/lambda$23$Type",1438);A(1427,1,gs,nN),p.Kb=function(t){return Vu(),new oi(null,new di(h(t,26).a,16))};var BEn=k(qr,"LGraphToCGraphTransformer/lambda$3$Type",1427);A(1428,1,gs,YH),p.Kb=function(t){return Vu(),new oi(null,new sx(Cn(fr(h(t,8)))))};var OEn=k(qr,"LGraphToCGraphTransformer/lambda$4$Type",1428);A(1429,1,gs,ZH),p.Kb=function(t){return Vu(),h(G(h(t,14),(Ie(),JP)),15)};var NEn=k(qr,"LGraphToCGraphTransformer/lambda$5$Type",1429);A(1431,1,{},u0),p.td=function(t){xFt(this.a,t)};var FEn=k(qr,"LGraphToCGraphTransformer/lambda$6$Type",1431);A(1432,1,{},ROe),p.td=function(t){CSt(this.a,this.b,t)};var UEn=k(qr,"LGraphToCGraphTransformer/lambda$7$Type",1432);A(1433,1,os,KH),p.Nb=function(t){return Vu(),re(h(t,57).g,8)};var zEn=k(qr,"LGraphToCGraphTransformer/lambda$8$Type",1433);A(1434,1,{},JH),p.td=function(t){var i;Vu(),i=h(t.g,8),i.k.a=t.d.c+i.d.b};var GEn=k(qr,"LGraphToCGraphTransformer/lambda$9$Type",1434);A(1421,1,{},QH),p.pe=function(t){var i,a,l,f,g;for(this.a=t,this.d=new rK,this.c=le(wSe,et,113,this.a.a.a.c.length,0,1),this.b=0,a=new j(this.a.a.a);a.a=0?"b"+t+"["+RQ(this.a)+"]":"b["+RQ(this.a)+"]"):"b_"+g0(this)};var X_n=k(X6,"FBendpoint",497);A(262,131,{3:1,262:1,93:1,131:1},g8e),p.Ib=function(){return RQ(this)};var Y_n=k(X6,"FEdge",262);A(202,131,{3:1,202:1,93:1,131:1},iU);var gVt=k(X6,"FGraph",202);A(454,329,{3:1,454:1,329:1,93:1,131:1},vze),p.Ib=function(){return this.b==null||this.b.length==0?"l["+RQ(this.a)+"]":"l_"+this.b};var Z_n=k(X6,"FLabel",454);A(146,329,{3:1,146:1,329:1,93:1,131:1},sUe),p.Ib=function(){return X1e(this)},p.b=0;var K_n=k(X6,"FNode",146);A(1691,1,{}),p.Ee=function(t){b_e(this,t)},p.Fe=function(){BHe(this)},p.d=0;var J_n=k(wye,"AbstractForceModel",1691);A(568,1691,{568:1},H$e),p.De=function(t,i){var a,l,f,g,m;return vXe(this.f,t,i),f=Bc(Ua(i.d),t.d),m=w.Math.sqrt(f.a*f.a+f.b*f.b),l=w.Math.max(0,m-sQ(t.e)/2-sQ(i.e)/2),a=eVe(this.e,t,i),a>0?g=-AAt(l,this.c)*a:g=MMt(l,this.b)*h(G(t,(Cf(),lM)),21).a,au(f,g/m),f},p.Ee=function(t){b_e(this,t),this.a=h(G(t,(Cf(),Jz)),21).a,this.c=ce(Xe(G(t,Qz))),this.b=ce(Xe(G(t,dse)))},p.Ge=function(t){return t0&&(g-=iEt(l,this.a)*a),au(f,g*this.b/m),f},p.Ee=function(t){var i,a,l,f,g,m,v;for(b_e(this,t),this.b=ce(Xe(G(t,(Cf(),pse)))),this.c=this.b/h(G(t,Jz),21).a,l=t.e.c.length,g=0,f=0,v=new j(t.e);v.a0},p.a=0,p.b=0,p.c=0;var eyn=k(wye,"FruchtermanReingoldModel",569);A(748,1,pd,BX),p.ue=function(t){zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,K7),""),"Force Model"),"Determines the model for force calculation."),hEe),(o1(),ms)),dEe),Ht((i1(),Ln))))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,vye),""),"Iterations"),"The number of iterations on the force model."),He(300)),xc),Po),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,_ye),""),"Repulsive Power"),"Determines how many bend points are added to the edge; such bend points are regarded as repelling particles in the force model"),He(0)),xc),Po),Ht(bd)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Aie),""),"FR Temperature"),"The temperature is used as a scaling factor for particle displacements."),Jd),nc),Eo),Ht(Ln)))),mc(t,Aie,K7,Eit),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Pie),""),"Eades Repulsion"),"Factor for repulsive forces in Eades' model."),5),nc),Eo),Ht(Ln)))),mc(t,Pie,K7,_it),$Ke((new NX,t))};var bit,wit,hEe,vit,_it,yit,xit,Eit,tyn=k(_P,"ForceMetaDataProvider",748);A(387,23,{3:1,34:1,23:1,387:1},Kpe);var hse,Kz,dEe=Ti(_P,"ForceModelStrategy",387,Di,NPt,bTt),Sit;A(880,1,pd,NX),p.ue=function(t){$Ke(t)};var Mit,pEe,Jz,gEe,Tit,mEe,bEe,lM,Cit,dse,wEe,Ait,Pit,Qz,pse,nyn=k(_P,"ForceOptions",880);A(881,1,{},io),p.Be=function(){var t;return t=new npe,t},p.Ce=function(t){};var iyn=k(_P,"ForceOptions/ForceFactory",881),y5,HP,Yx,eG;A(749,1,pd,sF),p.ue=function(t){zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Eye),""),"Fixed Position"),"Prevent that the node is moved by the layout algorithm."),(vt(),vt(),!1)),(o1(),_a)),lo),Ht((i1(),ga))))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Sye),""),"Desired Edge Length"),"Either specified for parent nodes or for individual edges, where the latter takes higher precedence."),100),nc),Eo),sr(Ln,X(q(Qp,1),Oe,163,0,[bd]))))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Mye),""),"Layout Dimension"),"Dimensions that are permitted to be altered during layout."),vEe),ms),MEe),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Tye),""),"Stress Epsilon"),"Termination criterion for the iterative process."),Jd),nc),Eo),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Cye),""),"Iteration Limit"),"Maximum number of performed iterations. Takes higher precedence than 'epsilon'."),He(zi)),xc),Po),Ht(Ln)))),cKe((new OX,t))};var Lit,kit,vEe,Rit,Iit,Dit,ryn=k(_P,"StressMetaDataProvider",749);A(884,1,pd,OX),p.ue=function(t){cKe(t)};var tG,_Ee,yEe,xEe,EEe,SEe,syn=k(_P,"StressOptions",884);A(885,1,{},mf),p.Be=function(){var t;return t=new m8e,t},p.Ce=function(t){};var oyn=k(_P,"StressOptions/StressFactory",885);A(959,244,K_,m8e),p.Ae=function(t,i){var a,l,f,g;for(ii(i,dQe,1),ce(mt(rn(t,(UI(),EEe))))||Qqe(new npe,t,bc(i,1)),l=bVe(t),a=YZe(this.a,l),g=a.tc();g.hc();)f=h(g.ic(),202),_zt(this.b,f),hFt(this.b);l=aJe(a),iJe(l),On(i)};var ayn=k(Rie,"StressLayoutProvider",959);A(882,1,{},iK),p.c=0,p.e=0,p.g=0;var cyn=k(Rie,"StressMajorization",882);A(348,23,{3:1,34:1,23:1,348:1},LK);var gse,mse,bse,MEe=Ti(Rie,"StressMajorization/Dimension",348,Di,MLt,wTt),Bit;A(883,1,Or,Vv),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return WMt(this.a,t,i)};var lyn=k(Rie,"StressMajorization/lambda$0$Type",883);A(985,1,{},D7e);var uyn=k(K6,"ElkLayered",985);A(986,1,{},Rs),p.td=function(t){$kt(this.a,t)};var fyn=k(K6,"ElkLayered/lambda$0$Type",986);A(987,1,{},J1),p.td=function(t){Ee(h(t,31),($e(),IG),(bS(),EG))};var hyn=k(K6,"ElkLayered/lambda$1$Type",987);A(1033,1,{},rFe);var Oit,Nit,Fit,dyn=k(K6,"GraphConfigurator",1033);A(958,244,K_,ml),p.Ae=function(t,i){var a;a=J9t(new SNe,t),Be(rn(t,($e(),iL)))===Be((e1(),d3))?g6t(this.a,a,i):EFt(this.a,a,i),nJe(new oF,a)};var pyn=k(K6,"LayeredLayoutProvider",958);A(328,23,{3:1,34:1,23:1,328:1},FR);var Dh,Zx,Qa,ec,qo,TEe=Ti(K6,"LayeredPhases",328,Di,D4t,vTt),Uit;A(1407,1,{},U$e),p.i=0;var zit,gyn=k(J6,"ComponentsToCGraphTransformer",1407),Git;A(1408,1,{},Lm),p.He=function(t,i){return w.Math.min(t.a!=null?ce(t.a):t.c.i,i.a!=null?ce(i.a):i.c.i)},p.Ie=function(t,i){return w.Math.min(t.a!=null?ce(t.a):t.c.i,i.a!=null?ce(i.a):i.c.i)};var myn=k(J6,"ComponentsToCGraphTransformer/1",1408);A(80,1,{80:1}),p.i=0,p.k=!0,p.o=Ts;var wse=k(xP,"CNode",80);A(282,80,{282:1,80:1},jge,uwe),p.Ib=function(){return""};var byn=k(J6,"ComponentsToCGraphTransformer/CRectNode",282);A(1391,1,{},b2);var vse,_se,wyn=k(J6,"OneDimensionalComponentsCompaction",1391);A(1392,1,Qu,zb),p.Fb=function(t){return this===t},p.Kb=function(t){return jee(),vt(),h(h(t,48).a,80).d.e!=0};var vyn=k(J6,"OneDimensionalComponentsCompaction/lambda$0$Type",1392);A(1393,1,Qu,bk),p.Fb=function(t){return this===t},p.Kb=function(t){return jee(),vt(),!!(mWe(h(h(t,48).a,80).j,h(h(t,48).b,110))||h(h(t,48).a,80).d.e!=0&&mWe(h(h(t,48).a,80).j,h(h(t,48).b,110)))};var _yn=k(J6,"OneDimensionalComponentsCompaction/lambda$1$Type",1393);A(1410,1,{},rUe);var yyn=k(xP,"CGraph",1410);A(172,1,{172:1},ite),p.b=0,p.c=0,p.e=0,p.g=!0,p.i=Ts;var xyn=k(xP,"CGroup",172);A(1409,1,{},Pe),p.He=function(t,i){return w.Math.max(t.a!=null?ce(t.a):t.c.i,i.a!=null?ce(i.a):i.c.i)},p.Ie=function(t,i){return w.Math.max(t.a!=null?ce(t.a):t.c.i,i.a!=null?ce(i.a):i.c.i)};var Eyn=k(xP,qJe,1409);A(1411,1,{},DXe),p.d=!1;var jit,yse=k(xP,ZJe,1411);A(1412,1,Qu,xt),p.Fb=function(t){return this===t},p.Kb=function(t){return kpe(),vt(),h(h(t,48).a,80).d.e!=0};var Syn=k(xP,KJe,1412);A(726,1,{},Hme),p.a=!1,p.b=!1,p.c=!1,p.d=!1;var Myn=k(xP,JJe,726);A(1521,1,{},R9e);var Tyn=k(ez,QJe,1521),x5=_r(h1,WJe);A(1522,1,{341:1},VUe),p.Ne=function(t){z9t(this,h(t,524))};var Cyn=k(ez,eQe,1522);A(1523,1,Or,Kt),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return to(h(t,282).g.c+h(t,282).g.b/2,h(i,282).g.c+h(i,282).g.b/2)};var Ayn=k(ez,tQe,1523);A(524,1,{524:1},Jpe),p.a=!1;var Pyn=k(ez,nQe,524);A(1524,1,Or,tn),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return wBt(t,i)};var Lyn=k(ez,iQe,1524);A(102,1,{102:1},jE,Ome),p.Fb=function(t){var i;return t==null||mVt!=sl(t)?!1:(i=h(t,102),tl(this.c,i.c)&&tl(this.d,i.d))},p.Hb=function(){return Aee(X(q(on,1),et,1,5,[this.c,this.d]))},p.Ib=function(){return"("+this.c+Ca+this.d+(this.a?"cx":"")+this.b+")"},p.a=!0,p.c=0,p.d=0;var mVt=k(h1,"Point",102);A(373,23,{3:1,34:1,23:1,373:1},P8);var Q0,Ow,fy,Nw,$it=Ti(h1,"Point/Quadrant",373,Di,r4t,_Tt),Vit;A(1398,1,{},u0),p.b=null,p.c=null,p.d=null,p.e=null,p.f=null;var Wit,Hit,qit,Xit,Yit,kyn=k(h1,"RectilinearConvexHull",1398);A(516,1,{341:1},QU),p.Ne=function(t){Rkt(this,h(t,102))},p.b=0;var CEe,Ryn=k(h1,"RectilinearConvexHull/MaximalElementsEventHandler",516);A(1400,1,Or,Zi),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return Rpe(),to(ce(Xe(t)),ce(Xe(i)))};var Iyn=k(h1,"RectilinearConvexHull/MaximalElementsEventHandler/lambda$0$Type",1400);A(1399,1,{341:1},yje),p.Ne=function(t){p9t(this,h(t,102))},p.a=0,p.b=null,p.c=null,p.d=null,p.e=null;var Dyn=k(h1,"RectilinearConvexHull/RectangleEventHandler",1399);A(1401,1,Or,Rr),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return EA(),h(t,102).c==h(i,102).c?to(h(i,102).d,h(t,102).d):to(h(t,102).c,h(i,102).c)};var Byn=k(h1,"RectilinearConvexHull/lambda$0$Type",1401);A(1402,1,Or,Xr),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return EA(),h(t,102).c==h(i,102).c?to(h(t,102).d,h(i,102).d):to(h(t,102).c,h(i,102).c)};var Oyn=k(h1,"RectilinearConvexHull/lambda$1$Type",1402);A(1403,1,Or,Yt),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return EA(),h(t,102).c==h(i,102).c?to(h(i,102).d,h(t,102).d):to(h(i,102).c,h(t,102).c)};var Nyn=k(h1,"RectilinearConvexHull/lambda$2$Type",1403);A(1404,1,Or,bs),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return EA(),h(t,102).c==h(i,102).c?to(h(t,102).d,h(i,102).d):to(h(i,102).c,h(t,102).c)};var Fyn=k(h1,"RectilinearConvexHull/lambda$3$Type",1404);A(1405,1,Or,Vs),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return OOt(t,i)};var Uyn=k(h1,"RectilinearConvexHull/lambda$4$Type",1405);A(1406,1,{},yze);var zyn=k(h1,"Scanline",1406);A(1694,1,{});var Gyn=k(nm,"AbstractGraphPlacer",1694);A(458,1,{458:1},f9e);var fs,jyn=k(nm,"ComponentGroup",458);A(1076,1694,{},l8),p.Oe=function(t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W;if(this.a.c=le(on,et,1,0,5,1),i.a.c=le(on,et,1,0,5,1),t.Wb()){i.e.a=0,i.e.b=0;return}for(m=h(t.cd(0),31),No(i,m),f=t.tc();f.hc();)l=h(f.ic(),31),v6t(this,l);for(W=new fo,g=ce(Xe(G(m,($e(),woe)))),E=new j(this.a);E.aN&&(Ue=0,qe+=B+f,B=0),ee=m.c,A6(m,Ue+ee.a,qe+ee.b),Hf(ee),a=w.Math.max(a,Ue+fe.a),B=w.Math.max(B,fe.b),Ue+=fe.a+f;if(i.e.a=a,i.e.b=qe+B,ce(mt(G(g,hoe)))){for(l=new xs,dJe(l,t,f),R=t.tc();R.hc();)C=h(R.ic(),31),tr(Hf(C.c),l.e);tr(Hf(i.e),l.a)}GGe(i,t)};var Qyn=k(nm,"SimpleRowGraphPlacer",1074);A(1075,1,Or,Lc),p.Ld=function(t,i){return YRt(h(t,31),h(i,31))},p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)};var e2n=k(nm,"SimpleRowGraphPlacer/1",1075),Zit;A(1032,1,ef,Gf),p.Mb=function(t){var i;return i=h(G(h(t,234).b,($e(),Lo)),74),!!i&&i.b!=0},p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)};var t2n=k(tz,"CompoundGraphPostprocessor/1",1032);A(1031,1,kr,ENe),p.Pe=function(t,i){EHe(this,h(t,31),i)};var n2n=k(tz,"CompoundGraphPreprocessor",1031);A(400,1,{400:1},KVe),p.c=!1;var i2n=k(tz,"CompoundGraphPreprocessor/ExternalPort",400);A(234,1,{234:1},d9),p.Ib=function(){return tI(this.c)+":"+Oje(this.b)};var r2n=k(tz,"CrossHierarchyEdge",234);A(687,1,Or,BF),p.Ld=function(t,i){return tBt(this,h(t,234),h(i,234))},p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)};var s2n=k(tz,"CrossHierarchyEdgeComparator",687);A(279,131,{3:1,279:1,93:1,131:1}),p.o=0;var o2n=k(Ka,"LGraphElement",279);A(14,279,{3:1,14:1,279:1,93:1,131:1},Op),p.Ib=function(){return Oje(this)};var xu=k(Ka,"LEdge",14);A(31,279,{3:1,20:1,31:1,279:1,93:1,131:1},J0e),p.sc=function(t){mo(this,t)},p.tc=function(){return new j(this.b)},p.Ib=function(){return this.b.c.length==0?"G-unlayered"+Vp(this.a):this.a.c.length==0?"G-layered"+Vp(this.b):"G[layerless"+Vp(this.a)+", layers"+Vp(this.b)+"]"};var Kit=k(Ka,"LGraph",31);A(591,1,{}),p.Qe=function(){return this.e.k},p.xe=function(t){return G(this.e,t)},p.Re=function(){return this.e.n},p.Se=function(){return this.e.o},p.ye=function(t){return cw(this.e,t)},p.Te=function(t){this.e.k.a=t.a,this.e.k.b=t.b},p.Ue=function(t){this.e.n.a=t.a,this.e.n.b=t.b},p.Ve=function(t){this.e.o=t};var a2n=k(Ka,"LGraphAdapters/AbstractLShapeAdapter",591);A(520,1,{741:1},wf),p.We=function(){var t,i;if(!this.b)for(this.b=ed(this.a.b.c.length),i=new j(this.a.b);i.a0&&$$e(t.charCodeAt(i-1),wQe);)--i;if(g "+this.a+" "+tI(this.c)},p.a=0,p.b=0,p.d=0;var U3n=k(An,"SplineSelfLoopRouter/LoopPadding",188);A(1294,1,ef,b9e),p.Mb=function(t){return G5t(this,h(t,188))},p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)},p.a=0,p.c=0;var z3n=k(An,"SplineSelfLoopRouter/LoopPadding/EnclosingPredicate",1294);A(1293,1,Or,KO),p.Ld=function(t,i){return lSt(h(t,188),h(i,188))},p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)};var G3n=k(An,"SplineSelfLoopRouter/LoopPadding/MarginComparator",1293);A(415,1,ef,Qb),p.Mb=function(t){return h(t,188).c==this.a},p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)};var j3n=k(An,"SplineSelfLoopRouter/LoopPadding/PortSidePredicate",415);A(414,1,{414:1},hze),p.c=0,p.d=0,p.e=0;var $3n=k(An,"SplineSelfLoopRouter/SelfLoopEdge",414);A(1292,1,Or,NH),p.Ld=function(t,i){return EEt(h(t,414),h(i,414))},p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)};var V3n=k(An,"SplineSelfLoopRouter/SelfLoopEdge/StepSizeComparator",1292);A(1451,715,{},T$e),p.qe=function(t){var i,a,l,f;switch(this.c=t,this.a.g){case 2:i=new ke,Fa(go(new oi(null,new di(this.c.a.b,16)),new jH),new LOe(this,i)),w6(this,new $H),cd(i,new FH),i.c=le(on,et,1,0,5,1),Fa(go(new oi(null,new di(this.c.a.b,16)),new JO),new zF(i)),w6(this,new Pd),cd(i,new Lk),i.c=le(on,et,1,0,5,1),a=QNe(M$e(wI(new oi(null,new di(this.c.a.b,16)),new gC(this))),new oE),Fa(new oi(null,new di(this.c.a.a,16)),new SOe(a,i)),w6(this,new QO),cd(i,new eN),i.c=le(on,et,1,0,5,1);break;case 3:l=new ke,w6(this,new Pk),f=QNe(M$e(wI(new oi(null,new di(this.c.a.b,16)),new WY(this))),new UH),Fa(go(new oi(null,new di(this.c.a.b,16)),new Ak),new POe(f,l)),w6(this,new zH),cd(l,new GH),l.c=le(on,et,1,0,5,1);break;default:throw Y(new pe)}},p.b=0;var W3n=k(qr,"EdgeAwareScanlineConstraintCalculation",1451);A(1452,1,ef,Pk),p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)},p.Mb=function(t){return re(h(t,57).g,153)};var H3n=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$0$Type",1452);A(1453,1,{},WY),p.oe=function(t){return QNt(this.a,t)};var q3n=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$1$Type",1453);A(1464,1,{},FH),p.td=function(t){h(t,340).fe()};var X3n=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$10$Type",1464);A(1465,1,os,JO),p.Nb=function(t){return re(h(t,57).g,8)};var Y3n=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$11$Type",1465);A(1467,1,{},zF),p.td=function(t){D6t(this.a,t)};var Z3n=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$12$Type",1467);A(1468,1,ef,Pd),p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)},p.Mb=function(t){return re(h(t,57).g,8)};var K3n=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$13$Type",1468);A(1469,1,{},Lk),p.td=function(t){h(t,340).fe()};var J3n=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$14$Type",1469);A(1470,1,{},gC),p.oe=function(t){return eFt(this.a,t)};var Q3n=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$15$Type",1470);A(1471,1,{},oE),p.me=function(){return 0};var eEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$16$Type",1471);A(1473,1,{},SOe),p.td=function(t){hAt(this.a,this.b,t)},p.a=0;var tEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$17$Type",1473);A(1474,1,ef,QO),p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)},p.Mb=function(t){return!0};var nEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$18$Type",1474);A(1475,1,{},eN),p.td=function(t){h(t,340).fe()};var iEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$19$Type",1475);A(1454,1,{},UH),p.me=function(){return 0};var rEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$2$Type",1454);A(1456,1,H6,MOe),p.fe=function(){ZA(this.b,this.a,-1)},p.a=0;var sEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$20$Type",1456);A(1461,1,H6,TOe),p.fe=function(){ZA(this.a,this.b,-1)},p.b=0;var oEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$21$Type",1461);A(1466,1,H6,COe),p.fe=function(){ZA(this.b,this.a,-1)},p.a=0;var aEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$22$Type",1466);A(1472,1,H6,AOe),p.fe=function(){sYe(this.a,this.b,-1)},p.b=0;var cEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$23$Type",1472);A(1455,1,os,Ak),p.Nb=function(t){return re(h(t,57).g,8)};var lEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$3$Type",1455);A(1457,1,{},POe),p.td=function(t){dAt(this.a,this.b,t)},p.a=0;var uEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$4$Type",1457);A(1458,1,ef,zH),p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)},p.Mb=function(t){return!0};var fEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$5$Type",1458);A(1459,1,{},GH),p.td=function(t){h(t,340).fe()};var hEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$6$Type",1459);A(1460,1,os,jH),p.Nb=function(t){return re(h(t,57).g,153)};var dEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$7$Type",1460);A(1462,1,{},LOe),p.td=function(t){nRt(this.a,this.b,t)};var pEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$8$Type",1462);A(1463,1,ef,$H),p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)},p.Mb=function(t){return re(h(t,57).g,153)};var gEn=k(qr,"EdgeAwareScanlineConstraintCalculation/lambda$9$Type",1463);A(1232,1,kr,kFe),p.Pe=function(t,i){Wzt(this,h(t,31),i)};var srt,mEn=k(qr,"HorizontalGraphCompactor",1232);A(1233,1,{},B2),p.se=function(t,i){var a,l,f;return Be(G(this.a.a,($e(),cm)))===Be((ld(),lb))&&(re(t.g,153)&&re(i.g,8)||re(i.g,153)&&re(t.g,8))?ce(mt(G(this.a.a,BG)))?0:10:R0e(t,i)||(a=p_(t),l=p_(i),a&&a.j==(Xt(),Qr)||l&&l.j==(Xt(),Qr))?0:(f=h(G(this.a.a,(Ie(),Uw)),266),pMt(f,a?a.j:(Xt(),Nr),l?l.j:(Xt(),Nr)))},p.te=function(t,i){var a,l,f;return R0e(t,i)?1:(a=p_(t),l=p_(i),f=h(G(this.a.a,(Ie(),Uw)),266),Gge(f,a?a.j:(Xt(),Nr),l?l.j:(Xt(),Nr)))};var bEn=k(qr,"HorizontalGraphCompactor/1",1233);A(1234,1,{},S2),p.re=function(t,i){return PC(),t.a.i==0};var wEn=k(qr,"HorizontalGraphCompactor/lambda$0$Type",1234);A(1235,1,{},Id),p.re=function(t,i){return wPt(this.a,t,i)};var vEn=k(qr,"HorizontalGraphCompactor/lambda$1$Type",1235);A(1422,1,{},Hje);var ort,art,_En=k(qr,"LGraphToCGraphTransformer",1422);A(1430,1,os,VH),p.Nb=function(t){return t!=null};var yEn=k(qr,"LGraphToCGraphTransformer/0methodref$nonNull$Type",1430);A(1423,1,gs,WH),p.Kb=function(t){return Vu(),Ga(G(h(h(t,57).g,8),(Ie(),Jn)))};var xEn=k(qr,"LGraphToCGraphTransformer/lambda$0$Type",1423);A(1424,1,gs,kk),p.Kb=function(t){return Vu(),sWe(h(h(t,57).g,153))};var EEn=k(qr,"LGraphToCGraphTransformer/lambda$1$Type",1424);A(1435,1,os,tN),p.Nb=function(t){return Vu(),re(h(t,57).g,153)};var SEn=k(qr,"LGraphToCGraphTransformer/lambda$10$Type",1435);A(1439,1,{},$b),p.td=function(t){var i,a;Vu(),i=t.d.c-t.e.c,a=h(t.g,153),cd(a.b,new YY(i)),cd(a.c,new ZY(i)),mo(a.i,new GF(i))};var MEn=k(qr,"LGraphToCGraphTransformer/lambda$11$Type",1439);A(1440,1,gs,RT),p.Kb=function(t){return Vu(),new oi(null,new sx(Cn(fr(h(t,8)))))};var TEn=k(qr,"LGraphToCGraphTransformer/lambda$12$Type",1440);A(1441,1,os,HH),p.Nb=function(t){return Vu(),Jo(h(t,14))};var CEn=k(qr,"LGraphToCGraphTransformer/lambda$13$Type",1441);A(1442,1,{},HY),p.td=function(t){Vkt(this.a,t)};var AEn=k(qr,"LGraphToCGraphTransformer/lambda$14$Type",1442);A(1443,1,gs,qH),p.Kb=function(t){return Vu(),new oi(null,new di(h(t,26).a,16))};var PEn=k(qr,"LGraphToCGraphTransformer/lambda$15$Type",1443);A(1444,1,gs,XH),p.Kb=function(t){return Vu(),new oi(null,new sx(Cn(fr(h(t,8)))))};var LEn=k(qr,"LGraphToCGraphTransformer/lambda$16$Type",1444);A(1445,1,gs,M2),p.Kb=function(t){return Vu(),h(G(h(t,14),(Ie(),JP)),15)};var kEn=k(qr,"LGraphToCGraphTransformer/lambda$17$Type",1445);A(1446,1,os,wg),p.Nb=function(t){return Vu(),!!h(t,15)&&!h(t,15).Wb()};var REn=k(qr,"LGraphToCGraphTransformer/lambda$18$Type",1446);A(1447,1,{},qY),p.td=function(t){tFt(this.a,h(t,15))};var IEn=k(qr,"LGraphToCGraphTransformer/lambda$19$Type",1447);A(1426,1,{},XY),p.td=function(t){hLt(this.a,t)};var DEn=k(qr,"LGraphToCGraphTransformer/lambda$2$Type",1426);A(1425,1,{},kOe),p.td=function(t){l4t(this.a,this.b,t)};var BEn=k(qr,"LGraphToCGraphTransformer/lambda$20$Type",1425);A(1436,1,{},YY),p.td=function(t){ESt(this.a,t)},p.a=0;var OEn=k(qr,"LGraphToCGraphTransformer/lambda$21$Type",1436);A(1437,1,{},ZY),p.td=function(t){SSt(this.a,t)},p.a=0;var NEn=k(qr,"LGraphToCGraphTransformer/lambda$22$Type",1437);A(1438,1,{},GF),p.td=function(t){MSt(this.a,t)},p.a=0;var FEn=k(qr,"LGraphToCGraphTransformer/lambda$23$Type",1438);A(1427,1,gs,nN),p.Kb=function(t){return Vu(),new oi(null,new di(h(t,26).a,16))};var UEn=k(qr,"LGraphToCGraphTransformer/lambda$3$Type",1427);A(1428,1,gs,YH),p.Kb=function(t){return Vu(),new oi(null,new sx(Cn(fr(h(t,8)))))};var zEn=k(qr,"LGraphToCGraphTransformer/lambda$4$Type",1428);A(1429,1,gs,ZH),p.Kb=function(t){return Vu(),h(G(h(t,14),(Ie(),JP)),15)};var GEn=k(qr,"LGraphToCGraphTransformer/lambda$5$Type",1429);A(1431,1,{},l0),p.td=function(t){MFt(this.a,t)};var jEn=k(qr,"LGraphToCGraphTransformer/lambda$6$Type",1431);A(1432,1,{},ROe),p.td=function(t){LSt(this.a,this.b,t)};var $En=k(qr,"LGraphToCGraphTransformer/lambda$7$Type",1432);A(1433,1,os,KH),p.Nb=function(t){return Vu(),re(h(t,57).g,8)};var VEn=k(qr,"LGraphToCGraphTransformer/lambda$8$Type",1433);A(1434,1,{},JH),p.td=function(t){var i;Vu(),i=h(t.g,8),i.k.a=t.d.c+i.d.b};var WEn=k(qr,"LGraphToCGraphTransformer/lambda$9$Type",1434);A(1421,1,{},QH),p.pe=function(t){var i,a,l,f,g;for(this.a=t,this.d=new rK,this.c=le(wSe,et,113,this.a.a.a.c.length,0,1),this.b=0,a=new j(this.a.a.a);a.af-m?0:f-m;B<=d0(i.f-1,f+m);B++){if(V=ie/(B+1),ee=0,C=1,g=new ke,fe=Ts,R=0,v=0,W=y[0],B==0)fe=ie,v=(i.g==null&&(i.g=x$e(i,new Dl)),ce(i.g));else{for(;C=V&&(De(g,He(C)),fe=w.Math.max(fe,we[C-1]-R),v+=W,ee+=we[C-1]-ee,R=we[C-1],W=y[C]),W=w.Math.max(W,y[C]),++C;v+=W}N=w.Math.min(1/fe,1/i.b/v),N>l&&(l=N,a=g)}return a},p.tf=function(){return!1};var fSn=k(Qd,"MSDCutIndexHeuristic",714);A(1279,1,kr,eq),p.Pe=function(t,i){K7t(h(t,31),i)};var hSn=k(Qd,"SingleEdgeGraphWrapper",1279);A(189,1,{189:1},vp),p.Ib=function(){return"NEdge[id="+this.b+" w="+this.g+" d="+this.a+"]"},p.a=1,p.b=0,p.c=0,p.f=!1,p.g=0;var lrt=k(SP,"NEdge",189);A(162,1,{},iu);var dSn=k(SP,"NEdge/NEdgeBuilder",162);A(592,1,{},rK);var pSn=k(SP,"NGraph",592);A(113,1,{113:1},oGe),p.c=-1,p.d=0,p.e=0,p.i=-1,p.j=!1;var wSe=k(SP,"NNode",113);A(717,1,GJe,ipe),p.sc=function(t){mo(this,t)},p.uc=function(){return this.xc()},p.jd=function(t){Ug(this,t)},p.wc=function(){return new di(this,16)},p.xc=function(){return new oi(null,this.wc())},p.bd=function(t,i){++this.b,_0(this.a,t,i)},p.nc=function(t){return J8(this,t)},p.oc=function(t){return++this.b,Lr(this.a,t)},p.Pb=function(){++this.b,this.a.c=le(on,et,1,0,5,1)},p.pc=function(t){return Qo(this.a,t,0)!=-1},p.qc=function(t){return Gg(this.a,t)},p.cd=function(t){return St(this.a,t)},p.dd=function(t){return Qo(this.a,t,0)},p.Wb=function(){return this.a.c.length==0},p.tc=function(){return bx(new j(this.a))},p.ed=function(){throw Y(new Pi)},p.fd=function(t){throw Y(new Pi)},p.gd=function(t){return++this.b,L0(this.a,t)},p.vc=function(t){return zge(this,t)},p.hd=function(t,i){return++this.b,Hu(this.a,t,i)},p._b=function(){return this.a.c.length},p.kd=function(t,i){return new Rg(this.a,t,i)},p.yc=function(){return mJ(this.a)},p.zc=function(t){return vo(this.a,t)},p.b=0;var gSn=k(SP,"NNode/ChangeAwareArrayList",717);A(251,1,{},Fm);var mSn=k(SP,"NNode/NNodeBuilder",251);A(1482,1,{},DT),p.a=!1,p.f=zi,p.j=0;var bSn=k(SP,"NetworkSimplex",1482);A(276,23,{3:1,34:1,23:1,276:1},zR);var Nse,Fse,Use,vSe,zse,_Se=Ti(_c,"CenterEdgeLabelPlacementStrategy",276,Di,R4t,yTt),urt;A(386,23,{3:1,34:1,23:1,386:1},Qpe);var ySe,Gse,xSe=Ti(_c,"ConstraintCalculationStrategy",386,Di,BPt,xTt),frt;A(290,23,{3:1,34:1,23:1,290:1},FC);var dG,ESe,pG,gG,mG,SSe,jse=Ti(_c,"ContentAlignment",290,Di,dkt,ETt),hrt;A(317,23,{3:1,34:1,23:1,317:1,285:1,286:1},ege),p.hf=function(){return zqe(this)},p.uf=function(){return zqe(this)};var S5,M5,MSe=Ti(_c,"CrossingMinimizationStrategy",317,Di,OPt,STt),drt;A(319,23,{3:1,34:1,23:1,319:1},RK);var TSe,$se,bG,CSe=Ti(_c,"CuttingStrategy",319,Di,pLt,MTt),prt;A(384,23,{3:1,34:1,23:1,384:1,285:1,286:1},IK),p.hf=function(){return Hqe(this)},p.uf=function(){return Hqe(this)};var ASe,Vse,Wse,PSe=Ti(_c,"CycleBreakingStrategy",384,Di,gLt,TTt),grt;A(406,23,{3:1,34:1,23:1,406:1},DK);var T5,Hse,YP,mrt=Ti(_c,"EdgeConstraint",406,Di,mLt,CTt),brt;A(241,23,{3:1,34:1,23:1,241:1},UC);var qse,Xse,Yse,Zse,wG,Kse,LSe=Ti(_c,"EdgeLabelSideSelection",241,Di,pkt,ATt),wrt;A(255,23,{3:1,34:1,23:1,255:1},zC);var Jse,kSe,RSe,vG,ISe,DSe,BSe=Ti(_c,"FixedAlignment",255,Di,gkt,PTt),vrt;A(256,23,{3:1,34:1,23:1,256:1},GC);var OSe,NSe,FSe,USe,ZP,zSe,GSe=Ti(_c,"GraphCompactionStrategy",256,Di,mkt,LTt),_rt;A(233,23,{3:1,34:1,23:1,233:1},sw);var hM,_G,dM,Su,KP,yG,dy,py,xG,C5,Qse=Ti(_c,"GraphProperties",233,Di,PRt,kTt),yrt;A(318,23,{3:1,34:1,23:1,318:1},BK);var EG,eoe,toe,jSe=Ti(_c,"GreedySwitchType",318,Di,dLt,RTt),xrt;A(280,23,{3:1,34:1,23:1,280:1},OK);var Kx,A5,gy,Ert=Ti(_c,"InLayerConstraint",280,Di,hLt,ITt),Srt;A(383,23,{3:1,34:1,23:1,383:1},tge);var noe,$Se,VSe=Ti(_c,"InteractiveReferencePoint",383,Di,NPt,DTt),Mrt,WSe,HSe,ioe,Fw,P5,Jx,tb,SG,qSe,XSe,MG,YSe,TG,roe,CG,Qx,soe,AG,pa,ZSe,Va,ooe,L5,y1,pM,e3,t3,k5,n3,Cl,Al,my,md,Jn,KSe,JSe,QSe,aoe,sm,PG,Pl,nb,coe,gM,LG,om,Uw,loe,Trt,R5,JP,uoe,eMe,foe,i3;A(178,23,{3:1,34:1,23:1,178:1},GR);var I5,zw,QP,ib,r3,tMe=Ti(_c,"LayerConstraint",178,Di,I4t,BTt),Crt;A(747,1,pd,DX),p.ue=function(t){zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Iye),""),"Content Alignment"),"Specifies how the content of compound nodes is to be aligned, e.g. top-left."),rMe),(o1(),_M)),jse),Ht((i1(),Ln))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.contentAlignment"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Dye),""),"Feedback Edges"),"Whether feedback edges should be highlighted by routing around the nodes."),(vt(),vt(),!1)),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.feedBackEdges"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,nz),""),"Interactive Reference Point"),"Determines which point of a node is considered by interactive layout phases."),fMe),ms),VSe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.interactiveReferencePoint"])))),mc(t,nz,Bie,Jrt),mc(t,nz,Gie,Krt),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Bye),""),"Merge Edges"),"Edges that have no ports are merged so they touch the connected nodes at the same points. When this option is disabled, one port is created for each edge directly connected to a node. When it is enabled, all such incoming edges share an input port, and all outgoing edges share an output port."),!1),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.mergeEdges"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Oye),""),"Merge Hierarchy-Crossing Edges"),"If hierarchical layout is active, hierarchy-crossing edges use as few hierarchical ports as possible. They are broken by the algorithm, with hierarchical ports inserted as required. Usually, one such port is created for each edge at each hierarchy crossing point. With this option set to true, we try to create as few hierarchical ports as possible in the process. In particular, all edges that form a hyperedge can share a port."),!0),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.mergeHierarchyEdges"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Nye),""),"Thoroughness"),"How much effort should be spent to produce a nice layout."),He(7)),xc),Po),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.thoroughness"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Fye),""),"Add Unnecessary Bendpoints"),"Adds bend points even if an edge does not change direction. If true, each long edge dummy will contribute a bend point to its edges and hierarchy-crossing edges will always get a bend point where they cross hierarchy boundaries. By default, bend points are only added where an edge changes direction."),!1),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.unnecessaryBendpoints"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Uye),""),"North or South Port"),"Specifies that this port can either be placed on the north side of a node or on the south side (if port constraints permit)"),!1),_a),lo),Ht(lb)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.northOrSouthPort"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Bie),"cycleBreaking"),"Cycle Breaking Strategy"),"Strategy for cycle breaking. Cycle breaking looks for cycles in the graph and determines which edges to reverse to break the cycles. Reversed edges will end up pointing to the opposite direction of regular edges (that is, reversed edges will point left if edges usually point right)."),aMe),ms),PSe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.cycleBreaking"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,t5),s2e),"Node Layering Strategy"),"Strategy for node layering."),pMe),ms),hTe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.nodeLayering"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,zye),s2e),"Layer Constraint"),"Determines a constraint on the placement of the node regarding the layering."),hMe),ms),tMe),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.layerConstraint"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Gye),s2e),"Wide Nodes on Multiple Layers"),"Strategy to distribute wide nodes over multiple layers."),gMe),ms),TTe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.wideNodesOnMultipleLayers"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Oie),LQe),"Upper Bound On Width [MinWidth Layerer]"),"Defines a loose upper bound on the width of the MinWidth layerer. If set to '-1' multiple values are tested and the best result is selected."),He(4)),xc),Po),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.minWidthUpperBoundOnWidth"])))),mc(t,Oie,t5,ist),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Nie),LQe),"Upper Layer Estimation Scaling Factor [MinWidth Layerer]"),"Multiplied with Upper Bound On Width for defining an upper bound on the width of layers which haven't been determined yet, but whose maximum width had been (roughly) estimated by the MinWidth algorithm. Compensates for too high estimations. If set to '-1' multiple values are tested and the best result is selected."),He(2)),xc),Po),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.minWidthUpperLayerEstimationScalingFactor"])))),mc(t,Nie,t5,sst),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Fie),kQe),"Node Promotion Strategy"),"Reduces number of dummy nodes after layering phase (if possible)."),dMe),ms),vTe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.nodePromotion"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Uie),kQe),"Max Node Promotion Iterations"),"Limits the number of iterations for node promotion."),He(0)),xc),Po),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.nodePromotionBoundary"])))),mc(t,Uie,Fie,null),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,zie),"layering.coffmanGraham"),"Layer Bound"),"The maximum number of nodes allowed per layer."),He(zi)),xc),Po),Ht(Ln)))),mc(t,zie,t5,est),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Gie),o2e),"Crossing Minimization Strategy"),"Strategy for crossing minimization."),oMe),ms),MSe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.crossMin"])))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,jye),o2e),"Hierarchical Sweepiness"),"How likely it is to use cross-hierarchy (1) vs bottom-up (-1)."),.1),nc),Eo),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,$ye),o2e),"Semi-Interactive Crossing Minimization"),"Preserves the order of nodes within a layer but still minimizes crossings between edges connecting long edge dummies. Derives the desired order from positions specified by the 'org.eclipse.elk.position' layout option. Requires a crossing minimization strategy that is able to process 'in-layer' constraints."),!1),_a),lo),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Vye),RQe),"Greedy Switch Activation Threshold"),"By default it is decided automatically if the greedy switch is activated or not. The decision is based on whether the size of the input graph (without dummy nodes) is smaller than the value of this option. A '0' enforces the activation."),He(40)),xc),Po),Ht(Ln)))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Wye),RQe),"Greedy Switch Crossing Minimization"),"Greedy Switch strategy for crossing minimization. The greedy switch heuristic is executed after the regular layer sweep as a post-processor."),sMe),ms),jSe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.greedySwitch"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,ZS),IQe),"Node Placement Strategy"),"Strategy for node placement."),vMe),ms),pTe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.nodePlace"])))),zt(t,new Rt(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,jie),IQe),"Favor Straight Edges Over Balancing"),"Favor straight edges over a balanced node placement. The default behavior is determined automatically based on the used 'edgeRouting'. For an orthogonal style it is set to true, for all other styles to false."),_a),lo),Ht(Ln)))),mc(t,jie,ZS,bst),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,$ie),DQe),"BK Edge Straightening"),"Specifies whether the Brandes Koepf node placer tries to increase the number of straight edges at the expense of diagram size. There is a subtle difference to the 'favorStraightEdges' option, which decides whether a balanced placement of the nodes is desired, or not. In bk terms this means combining the four alignments into a single balanced one, or not. This option on the other hand tries to straighten additional edges during the creation of each of the four alignments."),mMe),ms),kTe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.nodeplace.compactionStrategy"])))),mc(t,$ie,ZS,dst),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Vie),DQe),"BK Fixed Alignment"),"Tells the BK node placer to use a certain alignment (out of its four) instead of the one producing the smallest height, or the combination of all four."),bMe),ms),BSe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.fixedAlignment"])))),mc(t,Vie,ZS,gst),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Wie),"nodePlacement.linearSegments"),"Linear Segments Deflection Dampening"),"Dampens the movement of nodes to keep the diagram from getting too large."),.3),nc),Eo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.linearSegmentsDeflectionDampening"])))),mc(t,Wie,ZS,vst),zt(t,new Rt(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,Hie),"nodePlacement.networkSimplex"),"Node Flexibility"),"Aims at shorter and straighter edges. Two configurations are possible: (a) allow ports to move freely on the side they are assigned to (the order is always defined beforehand), (b) additionally allow to enlarge a node wherever it helps. If this option is not configured for a node, the 'nodeFlexibility.default' value is used, which is specified for the node's parent."),ms),Moe),Ht(ga)))),mc(t,Hie,ZS,xst),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Hye),"nodePlacement.networkSimplex.nodeFlexibility"),"Node Flexibility Default"),"Default value of the 'nodeFlexibility' option for the children of a hierarchical node."),wMe),ms),Moe),Ht(Ln)))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,qie),a2e),"Spline Self-Loop Placement"),null),uMe),ms),xTe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.splines.selfLoopPlacement"])))),mc(t,qie,n5,Grt),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,iz),a2e),"Sloppy Spline Routing"),"Use less spline control points at the start and end of an edge. Might lead to crossings edge/node overlap."),!0),_a),lo),Ht(Ln)))),mc(t,iz,n5,Wrt),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,rz),a2e),"Sloppy Spline Layer Spacing Factor"),"Spacing factor for routing area between layers when using sloppy spline routing."),.4),nc),Eo),Ht(Ln)))),mc(t,rz,n5,$rt),mc(t,rz,iz,!0),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,qye),im),"Edge Node Between Layers Spacing"),"The spacing to be preserved between nodes and edges that are routed next to the node's layer. For the spacing between nodes and edges that cross the node's layer 'spacing.edgeNode' is used."),10),nc),Eo),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Xye),im),"Edge Edge Between Layer Spacing"),"Spacing to be preserved between pairs of edges that are routed between the same pair of layers. Note that 'spacing.edgeEdge' is used for the spacing between pairs of edges crossing the same layer."),10),nc),Eo),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Yye),im),"Node Node Between Layers Spacing"),"The spacing to be preserved between any pair of nodes of two adjacent layers. Note that 'spacing.nodeNode' is used for the spacing between nodes within the layer itself."),20),nc),Eo),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Zye),c2e),"Direction Priority"),"Defines how important it is to have a certain edge point into the direction of the overall layout. This option is evaluated during the cycle breaking phase."),He(0)),xc),Po),Ht(bd)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Kye),c2e),"Shortness Priority"),"Defines how important it is to keep an edge as short as possible. This option is evaluated during the layering phase."),He(0)),xc),Po),Ht(bd)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Jye),c2e),"Straightness Priority"),"Defines how important it is to keep an edge straight, i.e. aligned with one of the two axes. This option is evaluated during node placement."),He(0)),xc),Po),Ht(bd)))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Xie),"compaction"),sQe),"Tries to further compact components (disconnected sub-graphs)."),!1),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.components.compact"])))),mc(t,Xie,Z6,!0),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Qye),BQe),"Post Compaction Strategy"),OQe),iMe),ms),GSe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.postCompaction"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,e2e),BQe),"Post Compaction Constraint Calculation"),OQe),nMe),ms),xSe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.postCompaction.constraints"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,sz),l2e),"High Degree Node Treatment"),"Makes room around high degree nodes to place leafs and trees."),!1),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.highDegreeNode.treatment"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Yie),l2e),"High Degree Node Threshold"),"Whether a node is considered to have a high degree."),He(16)),xc),Po),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.highDegreeNode.threshold"])))),mc(t,Yie,sz,!0),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Zie),l2e),"High Degree Node Maximum Tree Height"),"Maximum height of a subtree connected to a high degree node to be moved to separate layers."),He(5)),xc),Po),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.highDegreeNode.treeHeight"])))),mc(t,Zie,sz,!0),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,TP),u2e),"Graph Wrapping Strategy"),"For certain graphs and certain prescribed drawing areas it may be desirable to split the laid out graph into chunks that are placed side by side. The edges that connect different chunks are 'wrapped' around from the end of one chunk to the start of the other chunk. The points between the chunks are referred to as 'cuts'."),EMe),ms),CTe),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,t2e),u2e),"Additional Wrapped Edges Spacing"),"To visually separate edges that are wrapped from regularly routed edges an additional spacing value can be specified in form of this layout option. The spacing is added to the regular edgeNode spacing."),10),nc),Eo),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,n2e),u2e),"Correction factor for the wrapping"),"At times and for certain types of graphs the executed wrapping may produce results that are consistently biased in the same fashion: either wrapping to often or to rarely. This factor can be used to correct the bias. Internally, it is simplay multiplied with the 'aspect ratio' layout option."),1),nc),Eo),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,oz),NQe),"Cutting Strategy"),"The strategy by which the layer indexes are determined at which the layering crumbles into chunks."),yMe),ms),CSe),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,Kie),NQe),"Manually Specified Cuts"),"Allows the user to specify her own cuts for a certain graph."),wd),yu),Ht(Ln)))),mc(t,Kie,oz,Ost),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Jie),"wrapping.cutting.msd"),"MSD Freedom"),"The MSD cutting strategy starts with an initial guess on the number of chunks the graph should be split into. The freedom specifies how much the strategy may deviate from this guess. E.g. if an initial number of 3 is computed, a freedom of 1 allows 2, 3, and 4 cuts."),_Me),xc),Po),Ht(Ln)))),mc(t,Jie,oz,Fst),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Qie),"wrapping.singleEdge.validify"),"Path-Like Validify Strategy"),"When wrapping path-like graphs, the graph must not be split between any pair of layers. The validify strategy makes sure every computed split point is allowed."),xMe),ms),MTe),Ht(Ln)))),mc(t,Qie,TP,qst),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,az),f2e),"Improve Cuts"),"For general graphs it is important that not too many edges wrap backwards. Thus a compromise between evenly-distributed cuts and the total number of cut edges is sought."),!0),_a),lo),Ht(Ln)))),mc(t,az,TP,$st),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,cz),f2e),"Distance Penalty When Improving Cuts"),null),2),nc),Eo),Ht(Ln)))),mc(t,cz,TP,Gst),mc(t,cz,az,!0),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,ere),f2e),"Improve Wrapped Edges"),"The initial wrapping is performed in a very simple way. As a consequence, edges that wrap from one chunk to another may be unnecessarily long. Activating this option tries to shorten such edges."),!0),_a),lo),Ht(Ln)))),mc(t,ere,TP,Wst),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,i2e),tre),"Edge Label Side Selection"),"Method to decide on edge label sides."),lMe),ms),LSe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.edgeLabelSideSelection"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,r2e),tre),"Edge Center Label Placement Strategy"),"Determines in which layer center labels of long edges should be placed."),cMe),ms),_Se),sr(Ln,X(q(Qp,1),Oe,163,0,[fm]))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.edgeLabelPlacementStrategy"])))),mJe((new cF,t))};var Art,Prt,nMe,Lrt,iMe,krt,rMe,Rrt,Irt,sMe,Drt,Brt,Ort,oMe,Nrt,aMe,Frt,cMe,Urt,lMe,zrt,uMe,Grt,jrt,$rt,Vrt,Wrt,Hrt,qrt,Xrt,Yrt,Zrt,fMe,Krt,Jrt,Qrt,est,tst,hMe,nst,ist,rst,sst,ost,ast,dMe,cst,pMe,lst,gMe,ust,fst,hst,mMe,dst,pst,bMe,gst,mst,bst,wst,vst,_st,yst,wMe,xst,Est,vMe,Sst,Mst,Tst,Cst,Ast,Pst,Lst,kst,Rst,Ist,Dst,Bst,Ost,Nst,_Me,Fst,Ust,yMe,zst,Gst,jst,$st,Vst,Wst,Hst,xMe,qst,Xst,EMe,wSn=k(_c,"LayeredMetaDataProvider",747);A(878,1,pd,cF),p.ue=function(t){mJe(t)};var Bh,kG,eL,hoe,SMe,RG,doe,MMe,IG,TMe,poe,mM,CMe,tL,nf,AMe,DG,PMe,am,nL,cm,LMe,kMe,RMe,BG,tp,D5,iL,IMe,DMe,BMe,OG,by,Gw,OMe,Lo,NMe,tc,FMe,UMe,zMe,goe,GMe,B5,NG,jMe,$Me,kf,VMe,moe,rL,WMe,rb,sL,FG,jw,bM,UG,boe,x1,HMe,qMe,XMe,YMe,ZMe,Yst,Zst,Kst,Jst,$w,Vw,Ki,E1,KMe,s3,oL,Ww,Qst,O5,JMe,o3,eot,tot,woe,rh,a3,N5,S1,wy,zG,c3,QMe,aL,np,Hw,voe,cL,F5,_oe,eTe,tTe,nTe,iTe,yoe,rTe,sTe,oTe,aTe,cTe,vSn=k(_c,"LayeredOptions",878);A(879,1,{},tq),p.Be=function(){var t;return t=new ml,t},p.Ce=function(t){};var _Sn=k(_c,"LayeredOptions/LayeredFactory",879);A(291,23,{3:1,34:1,23:1,291:1,285:1,286:1},jC),p.hf=function(){return gYe(this)},p.uf=function(){return gYe(this)};var xoe,lTe,uTe,GG,Eoe,fTe,hTe=Ti(_c,"LayeringStrategy",291,Di,bkt,OTt),not;A(179,23,{3:1,34:1,23:1,179:1},L8);var vy,_y,jG,Soe,Moe=Ti(_c,"NodeFlexibility",179,Di,g4t,NTt),iot;A(292,23,{3:1,34:1,23:1,292:1,285:1,286:1},jR),p.hf=function(){return JXe(this)},p.uf=function(){return JXe(this)};var U5,Toe,Coe,z5,dTe,pTe=Ti(_c,"NodePlacementStrategy",292,Di,D4t,FTt),rot;A(240,23,{3:1,34:1,23:1,240:1},K2);var gTe,G5,mTe,bTe,j5,wTe,$G,VG,vTe=Ti(_c,"NodePromotionStrategy",240,Di,nRt,UTt),sot;A(410,23,{3:1,34:1,23:1,410:1},NK);var Fc,lc,WG,oot=Ti(_c,"PortType",410,Di,bLt,zTt),aot;A(345,23,{3:1,34:1,23:1,345:1},FK);var _Te,yTe,Aoe,xTe=Ti(_c,"SelfLoopPlacement",345,Di,wLt,GTt),cot;A(266,1,{266:1},jqe);var ySn=k(_c,"Spacings",266);A(347,23,{3:1,34:1,23:1,347:1},UK);var Poe,ETe,STe,MTe=Ti(_c,"ValidifyStrategy",347,Di,vLt,jTt),lot;A(385,23,{3:1,34:1,23:1,385:1},zK);var $5,V5,W5,TTe=Ti(_c,"WideNodesStrategy",385,Di,yLt,$Tt),uot;A(346,23,{3:1,34:1,23:1,346:1},GK);var H5,Loe,koe,CTe=Ti(_c,"WrappingStrategy",346,Di,_Lt,VTt),fot;A(1296,1,Tl,zOe),p.vf=function(t){return h(t,31),hot},p.Pe=function(t,i){ejt(this,h(t,31),i)};var hot,xSn=k(W2e,"DepthFirstCycleBreaker",1296);A(1295,1,Tl,I9e),p.vf=function(t){return h(t,31),dot},p.Pe=function(t,i){F$t(this,h(t,31),i)};var dot,ESn=k(W2e,"GreedyCycleBreaker",1295);A(1297,1,Tl,aR),p.vf=function(t){return h(t,31),pot},p.Pe=function(t,i){rGt(this,h(t,31),i)};var pot,SSn=k(W2e,"InteractiveCycleBreaker",1297);A(1300,1,Tl,GOe),p.vf=function(t){return h(t,31),got},p.Pe=function(t,i){I$t(this,h(t,31),i)};var got,MSn=k(Rw,"CoffmanGrahamLayerer",1300);A(1301,1,Or,Sp),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return EFt(this.a,h(t,8),h(i,8))};var TSn=k(Rw,"CoffmanGrahamLayerer/lambda$0$Type",1301);A(1302,1,Or,$F),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return sAt(this.a,t,i)};var CSn=k(Rw,"CoffmanGrahamLayerer/lambda$1$Type",1302);A(1303,1,Tl,T2),p.vf=function(t){return h(t,31),Ai(Ai(new ss,(_o(),Dh),(Ao(),kse)),Qa,fM)},p.Pe=function(t,i){$jt(this,h(t,31),i)};var ASn=k(Rw,"InteractiveLayerer",1303);A(511,1,{511:1},dDe),p.a=0,p.c=0;var PSn=k(Rw,"InteractiveLayerer/LayerSpan",511);A(1299,1,Tl,aF),p.vf=function(t){return r5t(h(t,31))},p.Pe=function(t,i){I9t(this,h(t,31),i)};var mot,bot,wot,LSn=k(Rw,"LongestPathLayerer",1299);A(1306,1,Tl,lF),p.vf=function(t){return h(t,31),Ai(Ai(new ss,(_o(),Dh),(Ao(),qP)),Qa,fM)},p.Pe=function(t,i){d$t(this,h(t,31),i)},p.a=0,p.b=0,p.d=0;var ATe,PTe,kSn=k(Rw,"MinWidthLayerer",1306);A(1307,1,Or,xa),p.Ld=function(t,i){return qRt(this,h(t,8),h(i,8))},p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)};var RSn=k(Rw,"MinWidthLayerer/MinOutgoingEdgesComparator",1307);A(1298,1,Tl,iFe),p.vf=function(t){return iBt(this,h(t,31))},p.Pe=function(t,i){Mzt(this,h(t,31),i)};var vot,_ot,yot,ISn=k(Rw,"NetworkSimplexLayerer",1298);A(1304,1,Tl,d8e),p.vf=function(t){return h(t,31),Ai(Ai(new ss,(_o(),Dh),(Ao(),qP)),Qa,fM)},p.Pe=function(t,i){bjt(this,h(t,31),i)},p.d=0,p.f=0,p.g=0,p.i=0,p.s=0,p.t=0,p.u=0;var DSn=k(Rw,"StretchWidthLayerer",1304);A(1305,1,Or,FT),p.Ld=function(t,i){return Y4t(h(t,8),h(i,8))},p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)};var BSn=k(Rw,"StretchWidthLayerer/1",1305);A(422,1,H2e),p.lf=function(t,i,a,l,f,g){},p.xf=function(t,i,a){return FZe(this,t,i,a)},p.kf=function(){this.g=le(av,zQe,22,this.d,15,1),this.f=le(av,zQe,22,this.d,15,1)},p.mf=function(t,i){this.e[t]=le(In,si,22,i[t].length,15,1)},p.nf=function(t,i,a){var l;l=a[t][i],l.o=i,this.e[t][i]=i},p.of=function(t,i,a,l){h(St(l[t][i].i,a),11).o=this.d++},p.b=0,p.c=0,p.d=0;var OSn=k(ql,"AbstractBarycenterPortDistributor",422);A(1484,1,Or,JY),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return L5t(this.a,t,i)};var NSn=k(ql,"AbstractBarycenterPortDistributor/lambda$0$Type",1484);A(1532,1,e5,sze),p.lf=function(t,i,a,l,f,g){},p.nf=function(t,i,a){},p.of=function(t,i,a,l){},p.jf=function(){return!1},p.kf=function(){this.a=this.c.a,this.e=this.d.g},p.mf=function(t,i){i[t][0].c.o=t},p.pf=function(){return!1},p.qf=function(t,i,a,l){var f,g,m,v,y,E,C;for(i!=pFe(a,t.length)&&(g=t[i-(a?1:-1)],y0e(this.d,g,a?(Oo(),lc):(Oo(),Fc))),f=t[i][0],C=!l||f.j==(Xt(),Qr),E=Ym(t[i]),FVe(this,E,C,!1,a),m=0,y=new j(E);y.a"),t0?xQ(this.a,t[i-1],t[i]):!a&&i1&&(f.i==(Fe(),Zt)?this.b[t]=!0:f.i==nn&&t>0&&(this.b[t-1]=!0))},p.f=0;var tMn=k(p1,"AllCrossingsCounter",1528);A(602,1,{},dee),p.b=0,p.d=0;var nMn=k(p1,"BinaryIndexedTree",602);A(473,1,{},ZR);var iMn=k(p1,"CrossingsCounter",473);A(1557,1,Or,nZ),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return qCt(this.a,t,i)};var rMn=k(p1,"CrossingsCounter/lambda$0$Type",1557);A(1558,1,Or,iZ),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return XCt(this.a,t,i)};var sMn=k(p1,"CrossingsCounter/lambda$1$Type",1558);A(1559,1,Or,rZ),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return YCt(this.a,t,i)};var oMn=k(p1,"CrossingsCounter/lambda$2$Type",1559);A(1560,1,Or,sZ),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return ZCt(this.a,t,i)};var aMn=k(p1,"CrossingsCounter/lambda$3$Type",1560);A(1555,1,{},oZ);var cMn=k(p1,"HyperedgeCrossingsCounter",1555);A(426,1,{34:1,426:1},p8e),p.vd=function(t){return y5t(this,h(t,426))},p.b=0,p.c=0,p.e=0,p.f=0;var mVt=k(p1,"HyperedgeCrossingsCounter/Hyperedge",426);A(336,1,{34:1,336:1},U9),p.vd=function(t){return _8t(this,h(t,336))},p.b=0,p.c=0;var Pot=k(p1,"HyperedgeCrossingsCounter/HyperedgeCorner",336);A(472,23,{3:1,34:1,23:1,472:1},nge);var uL,fL,Lot=Ti(p1,"HyperedgeCrossingsCounter/HyperedgeCorner/Type",472,Di,WPt,HTt),kot;A(1556,1,{},wZ),p.e=!0,p.f=0,p.g=0;var lMn=k(p1,"NorthSouthEdgeAllCrossingsCounter",1556);A(1311,1,Tl,uF),p.vf=function(t){return h(G(h(t,31),(Ie(),Va)),19).pc((xo(),Su))?Rot:null},p.Pe=function(t,i){EBt(this,h(t,31),i)};var Rot,uMn=k(co,"InteractiveNodePlacer",1311);A(1312,1,Tl,_g),p.vf=function(t){return h(G(h(t,31),(Ie(),Va)),19).pc((xo(),Su))?Iot:null},p.Pe=function(t,i){_Dt(this,h(t,31),i)};var Iot,XG,YG,fMn=k(co,"LinearSegmentsNodePlacer",1312);A(235,1,{34:1,235:1},rpe),p.vd=function(t){return EEt(this,h(t,235))},p.Fb=function(t){var i;return re(t,235)?(i=h(t,235),this.b==i.b):!1},p.Hb=function(){return this.b},p.Ib=function(){return"ls"+Vp(this.f)},p.a=0,p.b=0,p.c=-1,p.d=-1,p.i=0;var Dot=k(co,"LinearSegmentsNodePlacer/LinearSegment",235);A(1314,1,Tl,TUe),p.vf=function(t){return h(G(h(t,31),(Ie(),Va)),19).pc((xo(),Su))?Bot:null},p.Pe=function(t,i){C$t(this,h(t,31),i)},p.b=0,p.g=0;var Bot,hMn=k(co,"NetworkSimplexPlacer",1314);A(1333,1,Or,OT),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return kp(h(t,21).a,h(i,21).a)};var dMn=k(co,"NetworkSimplexPlacer/0methodref$compare$Type",1333);A(1335,1,Or,ya),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return kp(h(t,21).a,h(i,21).a)};var pMn=k(co,"NetworkSimplexPlacer/1methodref$compare$Type",1335);A(584,1,{584:1},DOe);var bVt=k(co,"NetworkSimplexPlacer/EdgeRep",584);A(416,1,{416:1},L1e),p.b=!1;var wVt=k(co,"NetworkSimplexPlacer/NodeRep",416);A(460,12,{3:1,4:1,20:1,25:1,41:1,12:1,13:1,15:1,49:1,460:1},bDe);var gMn=k(co,"NetworkSimplexPlacer/Path",460);A(1315,1,gs,nq),p.Kb=function(t){return h(t,14).d.g.j};var mMn=k(co,"NetworkSimplexPlacer/Path/lambda$0$Type",1315);A(1316,1,os,BT),p.Nb=function(t){return h(t,232)==(Xt(),Nr)};var bMn=k(co,"NetworkSimplexPlacer/Path/lambda$1$Type",1316);A(1317,1,gs,iN),p.Kb=function(t){return h(t,14).d.g};var wMn=k(co,"NetworkSimplexPlacer/Path/lambda$2$Type",1317);A(1318,1,os,aZ),p.Nb=function(t){return e8e(DWe(h(t,8)))};var vMn=k(co,"NetworkSimplexPlacer/Path/lambda$3$Type",1318);A(1319,1,os,NT),p.Nb=function(t){return vl(),(Fe(),pb).pc(h(t,11).i)};var _Mn=k(co,"NetworkSimplexPlacer/lambda$0$Type",1319);A(1320,1,{},BOe),p.td=function(t){ASt(this.a,this.b,t)};var yMn=k(co,"NetworkSimplexPlacer/lambda$1$Type",1320);A(1329,1,{},cZ),p.td=function(t){eFt(this.a,t)};var xMn=k(co,"NetworkSimplexPlacer/lambda$10$Type",1329);A(1330,1,gs,iq),p.Kb=function(t){return vl(),new oi(null,new di(h(t,26).a,16))};var EMn=k(co,"NetworkSimplexPlacer/lambda$11$Type",1330);A(1331,1,{},lZ),p.td=function(t){uUt(this.a,t)};var SMn=k(co,"NetworkSimplexPlacer/lambda$12$Type",1331);A(1332,1,gs,rq),p.Kb=function(t){return vl(),He(h(t,113).e)};var MMn=k(co,"NetworkSimplexPlacer/lambda$13$Type",1332);A(1334,1,gs,sq),p.Kb=function(t){return vl(),He(h(t,113).e)};var TMn=k(co,"NetworkSimplexPlacer/lambda$14$Type",1334);A(1336,1,os,sN),p.Nb=function(t){return vl(),h(t,416).c.j==(Xt(),hs)};var CMn=k(co,"NetworkSimplexPlacer/lambda$15$Type",1336);A(1337,1,os,oN),p.Nb=function(t){return vl(),h(t,416).c.i.c.length>1};var AMn=k(co,"NetworkSimplexPlacer/lambda$16$Type",1337);A(1338,1,{},xUe),p.td=function(t){J6t(this.c,this.b,this.d,this.a,t)},p.c=0,p.d=0;var PMn=k(co,"NetworkSimplexPlacer/lambda$17$Type",1338);A(1339,1,{},uZ),p.td=function(t){GSt(this.a,t)},p.a=0;var LMn=k(co,"NetworkSimplexPlacer/lambda$18$Type",1339);A(1340,1,gs,GT),p.Kb=function(t){return vl(),new oi(null,new di(h(t,26).a,16))};var kMn=k(co,"NetworkSimplexPlacer/lambda$19$Type",1340);A(1321,1,gs,aN),p.Kb=function(t){return vl(),new oi(null,new di(h(t,26).a,16))};var RMn=k(co,"NetworkSimplexPlacer/lambda$2$Type",1321);A(1341,1,{},yR),p.td=function(t){QSt(this.a,t)};var IMn=k(co,"NetworkSimplexPlacer/lambda$20$Type",1341);A(1342,1,os,aE),p.Nb=function(t){return e8e(t)};var DMn=k(co,"NetworkSimplexPlacer/lambda$21$Type",1342);A(1343,1,gs,Bv),p.Kb=function(t){return vl(),new oi(null,new di(h(t,26).a,16))};var BMn=k(co,"NetworkSimplexPlacer/lambda$22$Type",1343);A(1344,1,os,fZ),p.Nb=function(t){return uSt(this.a,t)};var OMn=k(co,"NetworkSimplexPlacer/lambda$23$Type",1344);A(1345,1,{},OOe),p.td=function(t){MOt(this.a,this.b,t)};var NMn=k(co,"NetworkSimplexPlacer/lambda$24$Type",1345);A(1346,1,os,jT),p.Nb=function(t){return vl(),!Jo(h(t,14))};var FMn=k(co,"NetworkSimplexPlacer/lambda$25$Type",1346);A(1347,1,os,oq),p.Nb=function(t){return vl(),!Jo(h(t,14))};var UMn=k(co,"NetworkSimplexPlacer/lambda$26$Type",1347);A(1348,1,{},xR),p.le=function(t,i){return zSt(this.a,t,i)};var zMn=k(co,"NetworkSimplexPlacer/lambda$27$Type",1348);A(1322,1,gs,aq),p.Kb=function(t){return vl(),new oi(null,new sx(Cn(fr(h(t,8)))))};var GMn=k(co,"NetworkSimplexPlacer/lambda$3$Type",1322);A(1323,1,os,cq),p.Nb=function(t){return vl(),YLt(h(t,14))};var jMn=k(co,"NetworkSimplexPlacer/lambda$4$Type",1323);A(1324,1,{},hZ),p.td=function(t){$7t(this.a,h(t,14))};var $Mn=k(co,"NetworkSimplexPlacer/lambda$5$Type",1324);A(1325,1,gs,$T),p.Kb=function(t){return vl(),new oi(null,new di(h(t,26).a,16))};var VMn=k(co,"NetworkSimplexPlacer/lambda$6$Type",1325);A(1326,1,os,VT),p.Nb=function(t){return vl(),h(t,8).j==(Xt(),hs)};var WMn=k(co,"NetworkSimplexPlacer/lambda$7$Type",1326);A(1327,1,gs,Rk),p.Kb=function(t){return vl(),new oi(null,new sx(Cn(t1(h(t,8)))))};var HMn=k(co,"NetworkSimplexPlacer/lambda$8$Type",1327);A(1328,1,os,lq),p.Nb=function(t){return vl(),VCt(h(t,14))};var qMn=k(co,"NetworkSimplexPlacer/lambda$9$Type",1328);A(1310,1,Tl,zv),p.vf=function(t){return h(G(h(t,31),(Ie(),Va)),19).pc((xo(),Su))?Oot:null},p.Pe=function(t,i){_zt(h(t,31),i)};var Oot,XMn=k(co,"SimpleNodePlacer",1310);A(164,1,{164:1},$_),p.Ib=function(){var t;return t="",this.c==(Eh(),sb)?t+=YS:this.c==Yp&&(t+=XS),this.o==(Kf(),M1)?t+=ore:this.o==sh?t+="UP":t+="BALANCED",t};var YMn=k(Hp,"BKAlignedLayout",164);A(466,23,{3:1,34:1,23:1,466:1},ige);var Yp,sb,Not=Ti(Hp,"BKAlignedLayout/HDirection",466,Di,jPt,ZTt),Fot;A(465,23,{3:1,34:1,23:1,465:1},rge);var M1,sh,Uot=Ti(Hp,"BKAlignedLayout/VDirection",465,Di,$Pt,KTt),zot;A(1485,1,{},NOe);var ZMn=k(Hp,"BKAligner",1485);A(1488,1,{},tqe);var KMn=k(Hp,"BKCompactor",1488);A(593,1,{593:1},uq),p.a=0;var JMn=k(Hp,"BKCompactor/ClassEdge",593);A(423,1,{423:1},pDe),p.a=null,p.b=0;var QMn=k(Hp,"BKCompactor/ClassNode",423);A(1313,1,Tl,jOe),p.vf=function(t){return h(G(h(t,31),(Ie(),Va)),19).pc((xo(),Su))?Got:null},p.Pe=function(t,i){j$t(this,h(t,31),i)},p.a=!1,p.e=!1;var Got,eTn=k(Hp,"BKNodePlacer",1313);A(437,23,{3:1,34:1,23:1,437:1},sge);var ZG,LTe,kTe=Ti(Hp,"EdgeStraighteningStrategy",437,Di,GPt,JTt),jot;A(1486,1,{},fq),p.d=0;var tTn=k(Hp,"NeighborhoodInformation",1486);A(1487,1,Or,dZ),p.Ld=function(t,i){return qkt(this,h(t,48),h(i,48))},p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)};var nTn=k(Hp,"NeighborhoodInformation/NeighborComparator",1487);A(724,1,{});var iTn=k(Hp,"ThresholdStrategy",724);A(1510,724,{},yDe),p.yf=function(t,i,a){return this.a.o==(Kf(),sh)?Jr:Ts},p.zf=function(){};var rTn=k(Hp,"ThresholdStrategy/NullThresholdStrategy",1510);A(522,1,{522:1},UOe),p.c=!1,p.d=!1;var sTn=k(Hp,"ThresholdStrategy/Postprocessable",522);A(1511,724,{},xDe),p.yf=function(t,i,a){var l,f,g;return f=i==a,l=this.a.a[a.o]==i,f||l?(g=t,this.a.c==(Eh(),sb)?(f&&(g=Cne(this,i,!0)),!isNaN(g)&&!isFinite(g)&&l&&(g=Cne(this,a,!1))):(f&&(g=Cne(this,i,!0)),!isNaN(g)&&!isFinite(g)&&l&&(g=Cne(this,a,!1))),g):t},p.zf=function(){for(var t,i,a,l,f;this.c.b!=0;)f=h(ZPt(this.c),522),l=XZe(this,f),l.a&&(t=l.a,a=ce(this.a.f[this.a.g[f.b.o].o]),!(!a&&!Jo(t)&&t.c.g.c==t.d.g.c)&&(i=tYe(this,f),i||FNe(this.d,f)));for(;this.d.a.c.length!=0;)tYe(this,h(Abe(this.d),522))};var oTn=k(Hp,"ThresholdStrategy/SimpleThresholdStrategy",1511);A(573,1,{573:1,285:1,286:1},nu),p.hf=function(){return K$e(this)},p.uf=function(){return K$e(this)};var Roe,aTn=k(Q_,"EdgeRouterFactory",573);A(1356,1,Tl,$X),p.vf=function(t){return U9t(h(t,31))},p.Pe=function(t,i){Uzt(h(t,31),i)};var $ot,Vot,Wot,Hot,qot,RTe,Xot,Yot,cTn=k(Q_,"OrthogonalEdgeRouter",1356);A(594,1,{},Nte),p.a=0,p.c=0;var lTn=k(Q_,"OrthogonalRoutingGenerator",594);A(252,1,{252:1},mU),p.Ib=function(){return this.a+"->"+this.b},p.c=0;var uTn=k(Q_,"OrthogonalRoutingGenerator/Dependency",252);A(165,1,{34:1,165:1},rVe),p.vd=function(t){return SEt(this,h(t,165))},p.Fb=function(t){var i;return re(t,165)?(i=h(t,165),this.d==i.d):!1},p.Hb=function(){return this.d},p.Ib=function(){var t,i,a,l;for(t=new ou("{"),l=new j(this.g);l.aJd&&(f=new $t(y,R),Gi(a.a,f),P6(this.a,a,t,f,!1),g=new $t(C,R),Gi(a.a,g),P6(this.a,a,t,g,!1))},p.Bf=function(t){return t.g.k.a+t.k.a+t.a.a},p.Cf=function(){return Fe(),ni},p.Df=function(){return Fe(),bn};var hTn=k(Q_,"OrthogonalRoutingGenerator/NorthToSouthRoutingStrategy",1490);A(1491,1,{},Nu),p.Af=function(t,i){var a,l,f,g,m,v,y,E,C,R;for(R=i-t.i*this.a.c,v=new j(t.g);v.aJd&&(f=new $t(y,R),Gi(a.a,f),P6(this.a,a,t,f,!1),g=new $t(C,R),Gi(a.a,g),P6(this.a,a,t,g,!1))},p.Bf=function(t){return t.g.k.a+t.k.a+t.a.a},p.Cf=function(){return Fe(),bn},p.Df=function(){return Fe(),ni};var dTn=k(Q_,"OrthogonalRoutingGenerator/SouthToNorthRoutingStrategy",1491);A(1489,1,{},Yh),p.Af=function(t,i){var a,l,f,g,m,v,y,E,C,R;for(R=i+t.i*this.a.c,v=new j(t.g);v.aJd&&(f=new $t(R,y),Gi(a.a,f),P6(this.a,a,t,f,!0),g=new $t(R,C),Gi(a.a,g),P6(this.a,a,t,g,!0))},p.Bf=function(t){return t.g.k.b+t.k.b+t.a.b},p.Cf=function(){return Fe(),Zt},p.Df=function(){return Fe(),nn};var pTn=k(Q_,"OrthogonalRoutingGenerator/WestToEastRoutingStrategy",1489);A(1351,1,Tl,$Oe),p.vf=function(t){return hNt(h(t,31))},p.Pe=function(t,i){zjt(this,h(t,31),i)};var Zot,Kot,Jot,Qot,KG,gTn=k(Q_,"PolylineEdgeRouter",1351);A(1352,1,ef,cN),p.Mb=function(t){return KRt(h(t,8))},p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)};var mTn=k(Q_,"PolylineEdgeRouter/1",1352);A(151,1,{151:1},XVe),p.Ib=function(){var t,i,a,l;for(a=new h0,this.e&&Mi(Mi(a,tI(this.e)),": "),i=Nn(wQ(this),0);i.b!=i.d.c;)t=h(Un(i),11),Mi(Mi(Lg(Mi(a,(l=rGe(t),l==null?"p_"+t.o:"p_"+l)),32),tI(t.i))," / ");return E8(a,a.a.length-2-1)},p.j=0,p.k=0;var bTn=k(g1,"ConnectedSelfLoopComponent",151);A(129,23,{3:1,34:1,23:1,129:1},Ig),p.c=0;var eat,tat,nat,ob,qw,Zp,Xw,lm,ip,Kp,ab,cb,iat,rat,sat,oat,aat,cat,lat,uat,fat,hat,dat,pat,gat,yy,l3,Yw,Zw,hL=Ti(g1,"LoopSide",129,Di,Tee,QTt),mat;A(424,1,{},OWe,__e,fwe),p.Ib=function(){return this.b.Ib()},p.c=0,p.d=!1,p.e=!1,p.f=!1,p.i=0,p.j=0;var wTn=k(g1,"NubSpline",424);A(190,1,{190:1},GYe,vQ);var vTn=k(g1,"NubSpline/PolarCP",190);A(599,424,{},fQ);var _Tn=k(g1,"NubsSelfLoop",599);A(236,1,{},tXe,Wte,Aqe,EI,Yte),p.a=q2e,p.b=Gx,p.c=q2e,p.d=Gx;var yTn=k(g1,"Rectangle",236);A(1353,1,Tl,HHe),p.vf=function(t){return OFt(h(t,31))},p.Pe=function(t,i){$$t(this,h(t,31),i)},p.d=3;var bat,wat,vat,_at,yat,xat,xTn=k(g1,"SplineEdgeRouter",1353);A(250,1,{250:1},oU),p.Ib=function(){return this.a+" ->("+this.c+") "+this.b},p.c=0;var ETn=k(g1,"SplineEdgeRouter/Dependency",250);A(417,23,{3:1,34:1,23:1,417:1},cge);var um,xy,Eat=Ti(g1,"SplineEdgeRouter/SideToProcess",417,Di,VPt,nCt),Sat;A(1354,1,{},KOe),p.td=function(t){FCt(this.a,this.b,t)};var STn=k(g1,"SplineEdgeRouter/lambda$0$Type",1354);A(1355,1,{},JOe),p.td=function(t){UCt(this.a,this.b,t)};var MTn=k(g1,"SplineEdgeRouter/lambda$1$Type",1355);A(125,1,{34:1,125:1},hXe,y_e),p.vd=function(t){return MEt(this,h(t,125))},p.b=0,p.e=0,p.f=0,p.i=!1,p.j=0,p.k=!1,p.n=!1,p.p=0,p.r=0,p.s=0;var TTn=k(g1,"SplineSegment",125);A(589,1,{589:1},Gf),p.a=0,p.b=!1,p.c=!1,p.d=!1,p.e=!1,p.f=0;var CTn=k(g1,"SplineSegment/EdgeInformation",589);A(990,1,{},hq);var ATn=k(CP,bye,990);A(991,1,Or,dq),p.Ld=function(t,i){return dFt(h(t,128),h(i,128))},p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)};var PTn=k(CP,lQe,991);A(989,1,{},ABe);var LTn=k(CP,"MrTree",989);A(360,23,{3:1,34:1,23:1,360:1,285:1,286:1},k8),p.hf=function(){return TXe(this)},p.uf=function(){return TXe(this)};var JG,dL,q5,pL,ITe=Ti(CP,"TreeLayoutPhases",360,Di,a4t,XTt),Mat;A(960,244,K_,f8e),p.Ae=function(t,i){var a,l,f,g,m,v;for(g=(m=new aU,No(m,t),Ee(m,(ha(),bL),t),v=new ui,E7t(t,m,v),f7t(t,m,v),m),f=T7t(this.a,g),l=new j(f);l.a"+Z9(this.c):"e_"+Hr(this)};var BTn=k(AP,"TEdge",170);A(128,131,{3:1,128:1,93:1,131:1},aU),p.Ib=function(){var t,i,a,l,f;for(f=null,l=Nn(this.b,0);l.b!=l.d.c;)a=h(Un(l),76),f+=(a.c==null||a.c.length==0?"n_"+a.g:"n_"+a.c)+` + endInLayerEdge=`,Ic(t,this.c),t.a};var iSn=k(Qd,"BreakingPointInserter/BPInfo",281);A(582,1,{582:1},KY),p.a=!1,p.b=0,p.c=0;var rSn=k(Qd,"BreakingPointInserter/Cut",582);A(1194,1,kr,fn),p.Pe=function(t,i){j8t(h(t,31),i)};var sSn=k(Qd,"BreakingPointProcessor",1194);A(1195,1,os,Jt),p.Nb=function(t){return Sje(h(t,8))};var oSn=k(Qd,"BreakingPointProcessor/0methodref$isEnd$Type",1195);A(1196,1,os,rr),p.Nb=function(t){return Mje(h(t,8))};var aSn=k(Qd,"BreakingPointProcessor/1methodref$isStart$Type",1196);A(1197,1,kr,Es),p.Pe=function(t,i){i9t(this,h(t,31),i)};var cSn=k(Qd,"BreakingPointRemover",1197);A(711,1,{},Rve),p.b=0,p.e=0,p.f=0,p.j=0;var lSn=k(Qd,"GraphStats",711);A(588,1,{},ta),p.le=function(t,i){return w.Math.max(ce(Xe(t)),ce(Xe(i)))};var uSn=k(Qd,"GraphStats/0methodref$max$Type",588);A(712,1,{},Dl),p.le=function(t,i){return w.Math.max(ce(Xe(t)),ce(Xe(i)))};var fSn=k(Qd,"GraphStats/1methodref$max$Type",712);A(1418,1,gs,Ws),p.Kb=function(t){return oHe(this.a,h(t,26))};var hSn=k(Qd,"GraphStats/lambda$0$Type",1418);A(1419,1,gs,jF),p.Kb=function(t){return cYe(this.a,h(t,26))};var dSn=k(Qd,"GraphStats/lambda$1$Type",1419);A(1420,1,{},Ha),p.sf=function(t,i){var a;return a=h(G(t,($e(),nTe)),15),a||(_t(),_t(),uo)},p.tf=function(){return!1};var pSn=k(Qd,"ICutIndexCalculator/ManualCutIndexCalculator",1420);A(714,1,{},IT),p.sf=function(t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce;for(Ce=(i.k==null&&DHe(i),i.k),y=(i.d==null&&DHe(i),i.d),we=le(ks,Wo,22,Ce.length,15,1),we[0]=Ce[0],ie=Ce[0],E=1;Ef-m?0:f-m;B<=h0(i.f-1,f+m);B++){if(V=ie/(B+1),ee=0,C=1,g=new ke,fe=Ts,R=0,v=0,W=y[0],B==0)fe=ie,v=(i.g==null&&(i.g=x$e(i,new Dl)),ce(i.g));else{for(;C=V&&(De(g,He(C)),fe=w.Math.max(fe,we[C-1]-R),v+=W,ee+=we[C-1]-ee,R=we[C-1],W=y[C]),W=w.Math.max(W,y[C]),++C;v+=W}N=w.Math.min(1/fe,1/i.b/v),N>l&&(l=N,a=g)}return a},p.tf=function(){return!1};var gSn=k(Qd,"MSDCutIndexHeuristic",714);A(1279,1,kr,eq),p.Pe=function(t,i){ezt(h(t,31),i)};var mSn=k(Qd,"SingleEdgeGraphWrapper",1279);A(189,1,{189:1},vp),p.Ib=function(){return"NEdge[id="+this.b+" w="+this.g+" d="+this.a+"]"},p.a=1,p.b=0,p.c=0,p.f=!1,p.g=0;var lrt=k(SP,"NEdge",189);A(162,1,{},iu);var bSn=k(SP,"NEdge/NEdgeBuilder",162);A(592,1,{},rK);var wSn=k(SP,"NGraph",592);A(113,1,{113:1},oGe),p.c=-1,p.d=0,p.e=0,p.i=-1,p.j=!1;var wSe=k(SP,"NNode",113);A(717,1,GJe,ipe),p.sc=function(t){mo(this,t)},p.uc=function(){return this.xc()},p.jd=function(t){Ug(this,t)},p.wc=function(){return new di(this,16)},p.xc=function(){return new oi(null,this.wc())},p.bd=function(t,i){++this.b,v0(this.a,t,i)},p.nc=function(t){return J8(this,t)},p.oc=function(t){return++this.b,Lr(this.a,t)},p.Pb=function(){++this.b,this.a.c=le(on,et,1,0,5,1)},p.pc=function(t){return Qo(this.a,t,0)!=-1},p.qc=function(t){return Gg(this.a,t)},p.cd=function(t){return St(this.a,t)},p.dd=function(t){return Qo(this.a,t,0)},p.Wb=function(){return this.a.c.length==0},p.tc=function(){return bx(new j(this.a))},p.ed=function(){throw Y(new Pi)},p.fd=function(t){throw Y(new Pi)},p.gd=function(t){return++this.b,P0(this.a,t)},p.vc=function(t){return zge(this,t)},p.hd=function(t,i){return++this.b,Hu(this.a,t,i)},p._b=function(){return this.a.c.length},p.kd=function(t,i){return new Rg(this.a,t,i)},p.yc=function(){return mJ(this.a)},p.zc=function(t){return vo(this.a,t)},p.b=0;var vSn=k(SP,"NNode/ChangeAwareArrayList",717);A(251,1,{},Fm);var _Sn=k(SP,"NNode/NNodeBuilder",251);A(1482,1,{},DT),p.a=!1,p.f=zi,p.j=0;var ySn=k(SP,"NetworkSimplex",1482);A(276,23,{3:1,34:1,23:1,276:1},zR);var Nse,Fse,Use,vSe,zse,_Se=Ti(_c,"CenterEdgeLabelPlacementStrategy",276,Di,B4t,STt),urt;A(386,23,{3:1,34:1,23:1,386:1},Qpe);var ySe,Gse,xSe=Ti(_c,"ConstraintCalculationStrategy",386,Di,FPt,MTt),frt;A(290,23,{3:1,34:1,23:1,290:1},FC);var dG,ESe,pG,gG,mG,SSe,jse=Ti(_c,"ContentAlignment",290,Di,mkt,TTt),hrt;A(317,23,{3:1,34:1,23:1,317:1,285:1,286:1},ege),p.hf=function(){return zqe(this)},p.uf=function(){return zqe(this)};var S5,M5,MSe=Ti(_c,"CrossingMinimizationStrategy",317,Di,UPt,CTt),drt;A(319,23,{3:1,34:1,23:1,319:1},RK);var TSe,$se,bG,CSe=Ti(_c,"CuttingStrategy",319,Di,bLt,ATt),prt;A(384,23,{3:1,34:1,23:1,384:1,285:1,286:1},IK),p.hf=function(){return Hqe(this)},p.uf=function(){return Hqe(this)};var ASe,Vse,Wse,PSe=Ti(_c,"CycleBreakingStrategy",384,Di,wLt,PTt),grt;A(406,23,{3:1,34:1,23:1,406:1},DK);var T5,Hse,YP,mrt=Ti(_c,"EdgeConstraint",406,Di,vLt,LTt),brt;A(241,23,{3:1,34:1,23:1,241:1},UC);var qse,Xse,Yse,Zse,wG,Kse,LSe=Ti(_c,"EdgeLabelSideSelection",241,Di,bkt,kTt),wrt;A(255,23,{3:1,34:1,23:1,255:1},zC);var Jse,kSe,RSe,vG,ISe,DSe,BSe=Ti(_c,"FixedAlignment",255,Di,wkt,RTt),vrt;A(256,23,{3:1,34:1,23:1,256:1},GC);var OSe,NSe,FSe,USe,ZP,zSe,GSe=Ti(_c,"GraphCompactionStrategy",256,Di,vkt,ITt),_rt;A(233,23,{3:1,34:1,23:1,233:1},sw);var hM,_G,dM,Su,KP,yG,dy,py,xG,C5,Qse=Ti(_c,"GraphProperties",233,Di,RRt,DTt),yrt;A(318,23,{3:1,34:1,23:1,318:1},BK);var EG,eoe,toe,jSe=Ti(_c,"GreedySwitchType",318,Di,mLt,BTt),xrt;A(280,23,{3:1,34:1,23:1,280:1},OK);var Kx,A5,gy,Ert=Ti(_c,"InLayerConstraint",280,Di,gLt,OTt),Srt;A(383,23,{3:1,34:1,23:1,383:1},tge);var noe,$Se,VSe=Ti(_c,"InteractiveReferencePoint",383,Di,zPt,NTt),Mrt,WSe,HSe,ioe,Fw,P5,Jx,eb,SG,qSe,XSe,MG,YSe,TG,roe,CG,Qx,soe,AG,pa,ZSe,Va,ooe,L5,y1,pM,e3,t3,k5,n3,Cl,Al,my,md,Jn,KSe,JSe,QSe,aoe,sm,PG,Pl,tb,coe,gM,LG,om,Uw,loe,Trt,R5,JP,uoe,eMe,foe,i3;A(178,23,{3:1,34:1,23:1,178:1},GR);var I5,zw,QP,nb,r3,tMe=Ti(_c,"LayerConstraint",178,Di,O4t,FTt),Crt;A(747,1,pd,DX),p.ue=function(t){zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Iye),""),"Content Alignment"),"Specifies how the content of compound nodes is to be aligned, e.g. top-left."),rMe),(o1(),_M)),jse),Ht((i1(),Ln))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.contentAlignment"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Dye),""),"Feedback Edges"),"Whether feedback edges should be highlighted by routing around the nodes."),(vt(),vt(),!1)),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.feedBackEdges"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,nz),""),"Interactive Reference Point"),"Determines which point of a node is considered by interactive layout phases."),fMe),ms),VSe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.interactiveReferencePoint"])))),mc(t,nz,Bie,Jrt),mc(t,nz,Gie,Krt),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Bye),""),"Merge Edges"),"Edges that have no ports are merged so they touch the connected nodes at the same points. When this option is disabled, one port is created for each edge directly connected to a node. When it is enabled, all such incoming edges share an input port, and all outgoing edges share an output port."),!1),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.mergeEdges"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Oye),""),"Merge Hierarchy-Crossing Edges"),"If hierarchical layout is active, hierarchy-crossing edges use as few hierarchical ports as possible. They are broken by the algorithm, with hierarchical ports inserted as required. Usually, one such port is created for each edge at each hierarchy crossing point. With this option set to true, we try to create as few hierarchical ports as possible in the process. In particular, all edges that form a hyperedge can share a port."),!0),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.mergeHierarchyEdges"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Nye),""),"Thoroughness"),"How much effort should be spent to produce a nice layout."),He(7)),xc),Po),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.thoroughness"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Fye),""),"Add Unnecessary Bendpoints"),"Adds bend points even if an edge does not change direction. If true, each long edge dummy will contribute a bend point to its edges and hierarchy-crossing edges will always get a bend point where they cross hierarchy boundaries. By default, bend points are only added where an edge changes direction."),!1),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.unnecessaryBendpoints"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Uye),""),"North or South Port"),"Specifies that this port can either be placed on the north side of a node or on the south side (if port constraints permit)"),!1),_a),lo),Ht(cb)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.northOrSouthPort"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Bie),"cycleBreaking"),"Cycle Breaking Strategy"),"Strategy for cycle breaking. Cycle breaking looks for cycles in the graph and determines which edges to reverse to break the cycles. Reversed edges will end up pointing to the opposite direction of regular edges (that is, reversed edges will point left if edges usually point right)."),aMe),ms),PSe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.cycleBreaking"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,t5),s2e),"Node Layering Strategy"),"Strategy for node layering."),pMe),ms),hTe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.nodeLayering"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,zye),s2e),"Layer Constraint"),"Determines a constraint on the placement of the node regarding the layering."),hMe),ms),tMe),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.layerConstraint"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Gye),s2e),"Wide Nodes on Multiple Layers"),"Strategy to distribute wide nodes over multiple layers."),gMe),ms),TTe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.wideNodesOnMultipleLayers"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Oie),LQe),"Upper Bound On Width [MinWidth Layerer]"),"Defines a loose upper bound on the width of the MinWidth layerer. If set to '-1' multiple values are tested and the best result is selected."),He(4)),xc),Po),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.minWidthUpperBoundOnWidth"])))),mc(t,Oie,t5,ist),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Nie),LQe),"Upper Layer Estimation Scaling Factor [MinWidth Layerer]"),"Multiplied with Upper Bound On Width for defining an upper bound on the width of layers which haven't been determined yet, but whose maximum width had been (roughly) estimated by the MinWidth algorithm. Compensates for too high estimations. If set to '-1' multiple values are tested and the best result is selected."),He(2)),xc),Po),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.minWidthUpperLayerEstimationScalingFactor"])))),mc(t,Nie,t5,sst),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Fie),kQe),"Node Promotion Strategy"),"Reduces number of dummy nodes after layering phase (if possible)."),dMe),ms),vTe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.nodePromotion"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Uie),kQe),"Max Node Promotion Iterations"),"Limits the number of iterations for node promotion."),He(0)),xc),Po),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.nodePromotionBoundary"])))),mc(t,Uie,Fie,null),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,zie),"layering.coffmanGraham"),"Layer Bound"),"The maximum number of nodes allowed per layer."),He(zi)),xc),Po),Ht(Ln)))),mc(t,zie,t5,est),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Gie),o2e),"Crossing Minimization Strategy"),"Strategy for crossing minimization."),oMe),ms),MSe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.crossMin"])))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,jye),o2e),"Hierarchical Sweepiness"),"How likely it is to use cross-hierarchy (1) vs bottom-up (-1)."),.1),nc),Eo),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,$ye),o2e),"Semi-Interactive Crossing Minimization"),"Preserves the order of nodes within a layer but still minimizes crossings between edges connecting long edge dummies. Derives the desired order from positions specified by the 'org.eclipse.elk.position' layout option. Requires a crossing minimization strategy that is able to process 'in-layer' constraints."),!1),_a),lo),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Vye),RQe),"Greedy Switch Activation Threshold"),"By default it is decided automatically if the greedy switch is activated or not. The decision is based on whether the size of the input graph (without dummy nodes) is smaller than the value of this option. A '0' enforces the activation."),He(40)),xc),Po),Ht(Ln)))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Wye),RQe),"Greedy Switch Crossing Minimization"),"Greedy Switch strategy for crossing minimization. The greedy switch heuristic is executed after the regular layer sweep as a post-processor."),sMe),ms),jSe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.greedySwitch"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,ZS),IQe),"Node Placement Strategy"),"Strategy for node placement."),vMe),ms),pTe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.nodePlace"])))),zt(t,new Rt(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,jie),IQe),"Favor Straight Edges Over Balancing"),"Favor straight edges over a balanced node placement. The default behavior is determined automatically based on the used 'edgeRouting'. For an orthogonal style it is set to true, for all other styles to false."),_a),lo),Ht(Ln)))),mc(t,jie,ZS,bst),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,$ie),DQe),"BK Edge Straightening"),"Specifies whether the Brandes Koepf node placer tries to increase the number of straight edges at the expense of diagram size. There is a subtle difference to the 'favorStraightEdges' option, which decides whether a balanced placement of the nodes is desired, or not. In bk terms this means combining the four alignments into a single balanced one, or not. This option on the other hand tries to straighten additional edges during the creation of each of the four alignments."),mMe),ms),kTe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.nodeplace.compactionStrategy"])))),mc(t,$ie,ZS,dst),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Vie),DQe),"BK Fixed Alignment"),"Tells the BK node placer to use a certain alignment (out of its four) instead of the one producing the smallest height, or the combination of all four."),bMe),ms),BSe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.fixedAlignment"])))),mc(t,Vie,ZS,gst),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Wie),"nodePlacement.linearSegments"),"Linear Segments Deflection Dampening"),"Dampens the movement of nodes to keep the diagram from getting too large."),.3),nc),Eo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.linearSegmentsDeflectionDampening"])))),mc(t,Wie,ZS,vst),zt(t,new Rt(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,Hie),"nodePlacement.networkSimplex"),"Node Flexibility"),"Aims at shorter and straighter edges. Two configurations are possible: (a) allow ports to move freely on the side they are assigned to (the order is always defined beforehand), (b) additionally allow to enlarge a node wherever it helps. If this option is not configured for a node, the 'nodeFlexibility.default' value is used, which is specified for the node's parent."),ms),Moe),Ht(ga)))),mc(t,Hie,ZS,xst),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Hye),"nodePlacement.networkSimplex.nodeFlexibility"),"Node Flexibility Default"),"Default value of the 'nodeFlexibility' option for the children of a hierarchical node."),wMe),ms),Moe),Ht(Ln)))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,qie),a2e),"Spline Self-Loop Placement"),null),uMe),ms),xTe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.splines.selfLoopPlacement"])))),mc(t,qie,n5,Grt),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,iz),a2e),"Sloppy Spline Routing"),"Use less spline control points at the start and end of an edge. Might lead to crossings edge/node overlap."),!0),_a),lo),Ht(Ln)))),mc(t,iz,n5,Wrt),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,rz),a2e),"Sloppy Spline Layer Spacing Factor"),"Spacing factor for routing area between layers when using sloppy spline routing."),.4),nc),Eo),Ht(Ln)))),mc(t,rz,n5,$rt),mc(t,rz,iz,!0),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,qye),im),"Edge Node Between Layers Spacing"),"The spacing to be preserved between nodes and edges that are routed next to the node's layer. For the spacing between nodes and edges that cross the node's layer 'spacing.edgeNode' is used."),10),nc),Eo),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Xye),im),"Edge Edge Between Layer Spacing"),"Spacing to be preserved between pairs of edges that are routed between the same pair of layers. Note that 'spacing.edgeEdge' is used for the spacing between pairs of edges crossing the same layer."),10),nc),Eo),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Yye),im),"Node Node Between Layers Spacing"),"The spacing to be preserved between any pair of nodes of two adjacent layers. Note that 'spacing.nodeNode' is used for the spacing between nodes within the layer itself."),20),nc),Eo),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Zye),c2e),"Direction Priority"),"Defines how important it is to have a certain edge point into the direction of the overall layout. This option is evaluated during the cycle breaking phase."),He(0)),xc),Po),Ht(bd)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Kye),c2e),"Shortness Priority"),"Defines how important it is to keep an edge as short as possible. This option is evaluated during the layering phase."),He(0)),xc),Po),Ht(bd)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Jye),c2e),"Straightness Priority"),"Defines how important it is to keep an edge straight, i.e. aligned with one of the two axes. This option is evaluated during node placement."),He(0)),xc),Po),Ht(bd)))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Xie),"compaction"),sQe),"Tries to further compact components (disconnected sub-graphs)."),!1),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.components.compact"])))),mc(t,Xie,Z6,!0),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Qye),BQe),"Post Compaction Strategy"),OQe),iMe),ms),GSe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.postCompaction"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,e2e),BQe),"Post Compaction Constraint Calculation"),OQe),nMe),ms),xSe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.postCompaction.constraints"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,sz),l2e),"High Degree Node Treatment"),"Makes room around high degree nodes to place leafs and trees."),!1),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.highDegreeNode.treatment"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Yie),l2e),"High Degree Node Threshold"),"Whether a node is considered to have a high degree."),He(16)),xc),Po),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.highDegreeNode.threshold"])))),mc(t,Yie,sz,!0),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Zie),l2e),"High Degree Node Maximum Tree Height"),"Maximum height of a subtree connected to a high degree node to be moved to separate layers."),He(5)),xc),Po),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.highDegreeNode.treeHeight"])))),mc(t,Zie,sz,!0),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,TP),u2e),"Graph Wrapping Strategy"),"For certain graphs and certain prescribed drawing areas it may be desirable to split the laid out graph into chunks that are placed side by side. The edges that connect different chunks are 'wrapped' around from the end of one chunk to the start of the other chunk. The points between the chunks are referred to as 'cuts'."),EMe),ms),CTe),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,t2e),u2e),"Additional Wrapped Edges Spacing"),"To visually separate edges that are wrapped from regularly routed edges an additional spacing value can be specified in form of this layout option. The spacing is added to the regular edgeNode spacing."),10),nc),Eo),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,n2e),u2e),"Correction factor for the wrapping"),"At times and for certain types of graphs the executed wrapping may produce results that are consistently biased in the same fashion: either wrapping to often or to rarely. This factor can be used to correct the bias. Internally, it is simplay multiplied with the 'aspect ratio' layout option."),1),nc),Eo),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,oz),NQe),"Cutting Strategy"),"The strategy by which the layer indexes are determined at which the layering crumbles into chunks."),yMe),ms),CSe),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,Kie),NQe),"Manually Specified Cuts"),"Allows the user to specify her own cuts for a certain graph."),wd),yu),Ht(Ln)))),mc(t,Kie,oz,Ost),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Jie),"wrapping.cutting.msd"),"MSD Freedom"),"The MSD cutting strategy starts with an initial guess on the number of chunks the graph should be split into. The freedom specifies how much the strategy may deviate from this guess. E.g. if an initial number of 3 is computed, a freedom of 1 allows 2, 3, and 4 cuts."),_Me),xc),Po),Ht(Ln)))),mc(t,Jie,oz,Fst),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Qie),"wrapping.singleEdge.validify"),"Path-Like Validify Strategy"),"When wrapping path-like graphs, the graph must not be split between any pair of layers. The validify strategy makes sure every computed split point is allowed."),xMe),ms),MTe),Ht(Ln)))),mc(t,Qie,TP,qst),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,az),f2e),"Improve Cuts"),"For general graphs it is important that not too many edges wrap backwards. Thus a compromise between evenly-distributed cuts and the total number of cut edges is sought."),!0),_a),lo),Ht(Ln)))),mc(t,az,TP,$st),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,cz),f2e),"Distance Penalty When Improving Cuts"),null),2),nc),Eo),Ht(Ln)))),mc(t,cz,TP,Gst),mc(t,cz,az,!0),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,ere),f2e),"Improve Wrapped Edges"),"The initial wrapping is performed in a very simple way. As a consequence, edges that wrap from one chunk to another may be unnecessarily long. Activating this option tries to shorten such edges."),!0),_a),lo),Ht(Ln)))),mc(t,ere,TP,Wst),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,i2e),tre),"Edge Label Side Selection"),"Method to decide on edge label sides."),lMe),ms),LSe),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.klay.layered.edgeLabelSideSelection"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,r2e),tre),"Edge Center Label Placement Strategy"),"Determines in which layer center labels of long edges should be placed."),cMe),ms),_Se),sr(Ln,X(q(Qp,1),Oe,163,0,[fm]))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.edgeLabelPlacementStrategy"])))),mJe((new cF,t))};var Art,Prt,nMe,Lrt,iMe,krt,rMe,Rrt,Irt,sMe,Drt,Brt,Ort,oMe,Nrt,aMe,Frt,cMe,Urt,lMe,zrt,uMe,Grt,jrt,$rt,Vrt,Wrt,Hrt,qrt,Xrt,Yrt,Zrt,fMe,Krt,Jrt,Qrt,est,tst,hMe,nst,ist,rst,sst,ost,ast,dMe,cst,pMe,lst,gMe,ust,fst,hst,mMe,dst,pst,bMe,gst,mst,bst,wst,vst,_st,yst,wMe,xst,Est,vMe,Sst,Mst,Tst,Cst,Ast,Pst,Lst,kst,Rst,Ist,Dst,Bst,Ost,Nst,_Me,Fst,Ust,yMe,zst,Gst,jst,$st,Vst,Wst,Hst,xMe,qst,Xst,EMe,xSn=k(_c,"LayeredMetaDataProvider",747);A(878,1,pd,cF),p.ue=function(t){mJe(t)};var Bh,kG,eL,hoe,SMe,RG,doe,MMe,IG,TMe,poe,mM,CMe,tL,nf,AMe,DG,PMe,am,nL,cm,LMe,kMe,RMe,BG,tp,D5,iL,IMe,DMe,BMe,OG,by,Gw,OMe,Lo,NMe,tc,FMe,UMe,zMe,goe,GMe,B5,NG,jMe,$Me,Rf,VMe,moe,rL,WMe,ib,sL,FG,jw,bM,UG,boe,x1,HMe,qMe,XMe,YMe,ZMe,Yst,Zst,Kst,Jst,$w,Vw,Ki,E1,KMe,s3,oL,Ww,Qst,O5,JMe,o3,eot,tot,woe,sh,a3,N5,S1,wy,zG,c3,QMe,aL,np,Hw,voe,cL,F5,_oe,eTe,tTe,nTe,iTe,yoe,rTe,sTe,oTe,aTe,cTe,ESn=k(_c,"LayeredOptions",878);A(879,1,{},tq),p.Be=function(){var t;return t=new ml,t},p.Ce=function(t){};var SSn=k(_c,"LayeredOptions/LayeredFactory",879);A(291,23,{3:1,34:1,23:1,291:1,285:1,286:1},jC),p.hf=function(){return gYe(this)},p.uf=function(){return gYe(this)};var xoe,lTe,uTe,GG,Eoe,fTe,hTe=Ti(_c,"LayeringStrategy",291,Di,_kt,UTt),not;A(179,23,{3:1,34:1,23:1,179:1},L8);var vy,_y,jG,Soe,Moe=Ti(_c,"NodeFlexibility",179,Di,w4t,zTt),iot;A(292,23,{3:1,34:1,23:1,292:1,285:1,286:1},jR),p.hf=function(){return JXe(this)},p.uf=function(){return JXe(this)};var U5,Toe,Coe,z5,dTe,pTe=Ti(_c,"NodePlacementStrategy",292,Di,N4t,GTt),rot;A(240,23,{3:1,34:1,23:1,240:1},K2);var gTe,G5,mTe,bTe,j5,wTe,$G,VG,vTe=Ti(_c,"NodePromotionStrategy",240,Di,sRt,jTt),sot;A(410,23,{3:1,34:1,23:1,410:1},NK);var Fc,lc,WG,oot=Ti(_c,"PortType",410,Di,_Lt,$Tt),aot;A(345,23,{3:1,34:1,23:1,345:1},FK);var _Te,yTe,Aoe,xTe=Ti(_c,"SelfLoopPlacement",345,Di,yLt,VTt),cot;A(266,1,{266:1},jqe);var MSn=k(_c,"Spacings",266);A(347,23,{3:1,34:1,23:1,347:1},UK);var Poe,ETe,STe,MTe=Ti(_c,"ValidifyStrategy",347,Di,xLt,WTt),lot;A(385,23,{3:1,34:1,23:1,385:1},zK);var $5,V5,W5,TTe=Ti(_c,"WideNodesStrategy",385,Di,SLt,HTt),uot;A(346,23,{3:1,34:1,23:1,346:1},GK);var H5,Loe,koe,CTe=Ti(_c,"WrappingStrategy",346,Di,ELt,qTt),fot;A(1296,1,Tl,zOe),p.vf=function(t){return h(t,31),hot},p.Pe=function(t,i){ijt(this,h(t,31),i)};var hot,TSn=k(W2e,"DepthFirstCycleBreaker",1296);A(1295,1,Tl,I9e),p.vf=function(t){return h(t,31),dot},p.Pe=function(t,i){G$t(this,h(t,31),i)};var dot,CSn=k(W2e,"GreedyCycleBreaker",1295);A(1297,1,Tl,aR),p.vf=function(t){return h(t,31),pot},p.Pe=function(t,i){aGt(this,h(t,31),i)};var pot,ASn=k(W2e,"InteractiveCycleBreaker",1297);A(1300,1,Tl,GOe),p.vf=function(t){return h(t,31),got},p.Pe=function(t,i){O$t(this,h(t,31),i)};var got,PSn=k(Rw,"CoffmanGrahamLayerer",1300);A(1301,1,Or,Sp),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return TFt(this.a,h(t,8),h(i,8))};var LSn=k(Rw,"CoffmanGrahamLayerer/lambda$0$Type",1301);A(1302,1,Or,$F),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return cAt(this.a,t,i)};var kSn=k(Rw,"CoffmanGrahamLayerer/lambda$1$Type",1302);A(1303,1,Tl,T2),p.vf=function(t){return h(t,31),Ai(Ai(new ss,(_o(),Dh),(Ao(),kse)),Qa,fM)},p.Pe=function(t,i){Hjt(this,h(t,31),i)};var RSn=k(Rw,"InteractiveLayerer",1303);A(511,1,{511:1},dDe),p.a=0,p.c=0;var ISn=k(Rw,"InteractiveLayerer/LayerSpan",511);A(1299,1,Tl,aF),p.vf=function(t){return a5t(h(t,31))},p.Pe=function(t,i){O9t(this,h(t,31),i)};var mot,bot,wot,DSn=k(Rw,"LongestPathLayerer",1299);A(1306,1,Tl,lF),p.vf=function(t){return h(t,31),Ai(Ai(new ss,(_o(),Dh),(Ao(),qP)),Qa,fM)},p.Pe=function(t,i){m$t(this,h(t,31),i)},p.a=0,p.b=0,p.d=0;var ATe,PTe,BSn=k(Rw,"MinWidthLayerer",1306);A(1307,1,Or,xa),p.Ld=function(t,i){return ZRt(this,h(t,8),h(i,8))},p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)};var OSn=k(Rw,"MinWidthLayerer/MinOutgoingEdgesComparator",1307);A(1298,1,Tl,iFe),p.vf=function(t){return oBt(this,h(t,31))},p.Pe=function(t,i){Azt(this,h(t,31),i)};var vot,_ot,yot,NSn=k(Rw,"NetworkSimplexLayerer",1298);A(1304,1,Tl,d8e),p.vf=function(t){return h(t,31),Ai(Ai(new ss,(_o(),Dh),(Ao(),qP)),Qa,fM)},p.Pe=function(t,i){_jt(this,h(t,31),i)},p.d=0,p.f=0,p.g=0,p.i=0,p.s=0,p.t=0,p.u=0;var FSn=k(Rw,"StretchWidthLayerer",1304);A(1305,1,Or,FT),p.Ld=function(t,i){return J4t(h(t,8),h(i,8))},p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)};var USn=k(Rw,"StretchWidthLayerer/1",1305);A(422,1,H2e),p.lf=function(t,i,a,l,f,g){},p.xf=function(t,i,a){return FZe(this,t,i,a)},p.kf=function(){this.g=le(av,zQe,22,this.d,15,1),this.f=le(av,zQe,22,this.d,15,1)},p.mf=function(t,i){this.e[t]=le(In,si,22,i[t].length,15,1)},p.nf=function(t,i,a){var l;l=a[t][i],l.o=i,this.e[t][i]=i},p.of=function(t,i,a,l){h(St(l[t][i].i,a),11).o=this.d++},p.b=0,p.c=0,p.d=0;var zSn=k(ql,"AbstractBarycenterPortDistributor",422);A(1484,1,Or,JY),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return I5t(this.a,t,i)};var GSn=k(ql,"AbstractBarycenterPortDistributor/lambda$0$Type",1484);A(1532,1,e5,sze),p.lf=function(t,i,a,l,f,g){},p.nf=function(t,i,a){},p.of=function(t,i,a,l){},p.jf=function(){return!1},p.kf=function(){this.a=this.c.a,this.e=this.d.g},p.mf=function(t,i){i[t][0].c.o=t},p.pf=function(){return!1},p.qf=function(t,i,a,l){var f,g,m,v,y,E,C;for(i!=pFe(a,t.length)&&(g=t[i-(a?1:-1)],y0e(this.d,g,a?(Oo(),lc):(Oo(),Fc))),f=t[i][0],C=!l||f.j==(Xt(),Qr),E=Ym(t[i]),FVe(this,E,C,!1,a),m=0,y=new j(E);y.a"),t0?xQ(this.a,t[i-1],t[i]):!a&&i1&&(f.i==(Fe(),Zt)?this.b[t]=!0:f.i==nn&&t>0&&(this.b[t-1]=!0))},p.f=0;var sMn=k(p1,"AllCrossingsCounter",1528);A(602,1,{},dee),p.b=0,p.d=0;var oMn=k(p1,"BinaryIndexedTree",602);A(473,1,{},ZR);var aMn=k(p1,"CrossingsCounter",473);A(1557,1,Or,nZ),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return ZCt(this.a,t,i)};var cMn=k(p1,"CrossingsCounter/lambda$0$Type",1557);A(1558,1,Or,iZ),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return KCt(this.a,t,i)};var lMn=k(p1,"CrossingsCounter/lambda$1$Type",1558);A(1559,1,Or,rZ),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return JCt(this.a,t,i)};var uMn=k(p1,"CrossingsCounter/lambda$2$Type",1559);A(1560,1,Or,sZ),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return QCt(this.a,t,i)};var fMn=k(p1,"CrossingsCounter/lambda$3$Type",1560);A(1555,1,{},oZ);var hMn=k(p1,"HyperedgeCrossingsCounter",1555);A(426,1,{34:1,426:1},p8e),p.vd=function(t){return S5t(this,h(t,426))},p.b=0,p.c=0,p.e=0,p.f=0;var vVt=k(p1,"HyperedgeCrossingsCounter/Hyperedge",426);A(336,1,{34:1,336:1},U9),p.vd=function(t){return E8t(this,h(t,336))},p.b=0,p.c=0;var Pot=k(p1,"HyperedgeCrossingsCounter/HyperedgeCorner",336);A(472,23,{3:1,34:1,23:1,472:1},nge);var uL,fL,Lot=Ti(p1,"HyperedgeCrossingsCounter/HyperedgeCorner/Type",472,Di,XPt,YTt),kot;A(1556,1,{},wZ),p.e=!0,p.f=0,p.g=0;var dMn=k(p1,"NorthSouthEdgeAllCrossingsCounter",1556);A(1311,1,Tl,uF),p.vf=function(t){return h(G(h(t,31),(Ie(),Va)),19).pc((xo(),Su))?Rot:null},p.Pe=function(t,i){TBt(this,h(t,31),i)};var Rot,pMn=k(co,"InteractiveNodePlacer",1311);A(1312,1,Tl,_g),p.vf=function(t){return h(G(h(t,31),(Ie(),Va)),19).pc((xo(),Su))?Iot:null},p.Pe=function(t,i){EDt(this,h(t,31),i)};var Iot,XG,YG,gMn=k(co,"LinearSegmentsNodePlacer",1312);A(235,1,{34:1,235:1},rpe),p.vd=function(t){return TEt(this,h(t,235))},p.Fb=function(t){var i;return re(t,235)?(i=h(t,235),this.b==i.b):!1},p.Hb=function(){return this.b},p.Ib=function(){return"ls"+Vp(this.f)},p.a=0,p.b=0,p.c=-1,p.d=-1,p.i=0;var Dot=k(co,"LinearSegmentsNodePlacer/LinearSegment",235);A(1314,1,Tl,TUe),p.vf=function(t){return h(G(h(t,31),(Ie(),Va)),19).pc((xo(),Su))?Bot:null},p.Pe=function(t,i){L$t(this,h(t,31),i)},p.b=0,p.g=0;var Bot,mMn=k(co,"NetworkSimplexPlacer",1314);A(1333,1,Or,OT),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return kp(h(t,21).a,h(i,21).a)};var bMn=k(co,"NetworkSimplexPlacer/0methodref$compare$Type",1333);A(1335,1,Or,ya),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return kp(h(t,21).a,h(i,21).a)};var wMn=k(co,"NetworkSimplexPlacer/1methodref$compare$Type",1335);A(584,1,{584:1},DOe);var _Vt=k(co,"NetworkSimplexPlacer/EdgeRep",584);A(416,1,{416:1},L1e),p.b=!1;var yVt=k(co,"NetworkSimplexPlacer/NodeRep",416);A(460,12,{3:1,4:1,20:1,25:1,41:1,12:1,13:1,15:1,49:1,460:1},bDe);var vMn=k(co,"NetworkSimplexPlacer/Path",460);A(1315,1,gs,nq),p.Kb=function(t){return h(t,14).d.g.j};var _Mn=k(co,"NetworkSimplexPlacer/Path/lambda$0$Type",1315);A(1316,1,os,BT),p.Nb=function(t){return h(t,232)==(Xt(),Nr)};var yMn=k(co,"NetworkSimplexPlacer/Path/lambda$1$Type",1316);A(1317,1,gs,iN),p.Kb=function(t){return h(t,14).d.g};var xMn=k(co,"NetworkSimplexPlacer/Path/lambda$2$Type",1317);A(1318,1,os,aZ),p.Nb=function(t){return e8e(DWe(h(t,8)))};var EMn=k(co,"NetworkSimplexPlacer/Path/lambda$3$Type",1318);A(1319,1,os,NT),p.Nb=function(t){return vl(),(Fe(),db).pc(h(t,11).i)};var SMn=k(co,"NetworkSimplexPlacer/lambda$0$Type",1319);A(1320,1,{},BOe),p.td=function(t){kSt(this.a,this.b,t)};var MMn=k(co,"NetworkSimplexPlacer/lambda$1$Type",1320);A(1329,1,{},cZ),p.td=function(t){iFt(this.a,t)};var TMn=k(co,"NetworkSimplexPlacer/lambda$10$Type",1329);A(1330,1,gs,iq),p.Kb=function(t){return vl(),new oi(null,new di(h(t,26).a,16))};var CMn=k(co,"NetworkSimplexPlacer/lambda$11$Type",1330);A(1331,1,{},lZ),p.td=function(t){dUt(this.a,t)};var AMn=k(co,"NetworkSimplexPlacer/lambda$12$Type",1331);A(1332,1,gs,rq),p.Kb=function(t){return vl(),He(h(t,113).e)};var PMn=k(co,"NetworkSimplexPlacer/lambda$13$Type",1332);A(1334,1,gs,sq),p.Kb=function(t){return vl(),He(h(t,113).e)};var LMn=k(co,"NetworkSimplexPlacer/lambda$14$Type",1334);A(1336,1,os,sN),p.Nb=function(t){return vl(),h(t,416).c.j==(Xt(),hs)};var kMn=k(co,"NetworkSimplexPlacer/lambda$15$Type",1336);A(1337,1,os,oN),p.Nb=function(t){return vl(),h(t,416).c.i.c.length>1};var RMn=k(co,"NetworkSimplexPlacer/lambda$16$Type",1337);A(1338,1,{},xUe),p.td=function(t){t5t(this.c,this.b,this.d,this.a,t)},p.c=0,p.d=0;var IMn=k(co,"NetworkSimplexPlacer/lambda$17$Type",1338);A(1339,1,{},uZ),p.td=function(t){VSt(this.a,t)},p.a=0;var DMn=k(co,"NetworkSimplexPlacer/lambda$18$Type",1339);A(1340,1,gs,GT),p.Kb=function(t){return vl(),new oi(null,new di(h(t,26).a,16))};var BMn=k(co,"NetworkSimplexPlacer/lambda$19$Type",1340);A(1321,1,gs,aN),p.Kb=function(t){return vl(),new oi(null,new di(h(t,26).a,16))};var OMn=k(co,"NetworkSimplexPlacer/lambda$2$Type",1321);A(1341,1,{},yR),p.td=function(t){nMt(this.a,t)};var NMn=k(co,"NetworkSimplexPlacer/lambda$20$Type",1341);A(1342,1,os,aE),p.Nb=function(t){return e8e(t)};var FMn=k(co,"NetworkSimplexPlacer/lambda$21$Type",1342);A(1343,1,gs,Bv),p.Kb=function(t){return vl(),new oi(null,new di(h(t,26).a,16))};var UMn=k(co,"NetworkSimplexPlacer/lambda$22$Type",1343);A(1344,1,os,fZ),p.Nb=function(t){return dSt(this.a,t)};var zMn=k(co,"NetworkSimplexPlacer/lambda$23$Type",1344);A(1345,1,{},OOe),p.td=function(t){AOt(this.a,this.b,t)};var GMn=k(co,"NetworkSimplexPlacer/lambda$24$Type",1345);A(1346,1,os,jT),p.Nb=function(t){return vl(),!Jo(h(t,14))};var jMn=k(co,"NetworkSimplexPlacer/lambda$25$Type",1346);A(1347,1,os,oq),p.Nb=function(t){return vl(),!Jo(h(t,14))};var $Mn=k(co,"NetworkSimplexPlacer/lambda$26$Type",1347);A(1348,1,{},xR),p.le=function(t,i){return $St(this.a,t,i)};var VMn=k(co,"NetworkSimplexPlacer/lambda$27$Type",1348);A(1322,1,gs,aq),p.Kb=function(t){return vl(),new oi(null,new sx(Cn(fr(h(t,8)))))};var WMn=k(co,"NetworkSimplexPlacer/lambda$3$Type",1322);A(1323,1,os,cq),p.Nb=function(t){return vl(),JLt(h(t,14))};var HMn=k(co,"NetworkSimplexPlacer/lambda$4$Type",1323);A(1324,1,{},hZ),p.td=function(t){H7t(this.a,h(t,14))};var qMn=k(co,"NetworkSimplexPlacer/lambda$5$Type",1324);A(1325,1,gs,$T),p.Kb=function(t){return vl(),new oi(null,new di(h(t,26).a,16))};var XMn=k(co,"NetworkSimplexPlacer/lambda$6$Type",1325);A(1326,1,os,VT),p.Nb=function(t){return vl(),h(t,8).j==(Xt(),hs)};var YMn=k(co,"NetworkSimplexPlacer/lambda$7$Type",1326);A(1327,1,gs,Rk),p.Kb=function(t){return vl(),new oi(null,new sx(Cn(t1(h(t,8)))))};var ZMn=k(co,"NetworkSimplexPlacer/lambda$8$Type",1327);A(1328,1,os,lq),p.Nb=function(t){return vl(),qCt(h(t,14))};var KMn=k(co,"NetworkSimplexPlacer/lambda$9$Type",1328);A(1310,1,Tl,zv),p.vf=function(t){return h(G(h(t,31),(Ie(),Va)),19).pc((xo(),Su))?Oot:null},p.Pe=function(t,i){Ezt(h(t,31),i)};var Oot,JMn=k(co,"SimpleNodePlacer",1310);A(164,1,{164:1},$_),p.Ib=function(){var t;return t="",this.c==(Eh(),rb)?t+=YS:this.c==Yp&&(t+=XS),this.o==(Jf(),M1)?t+=ore:this.o==oh?t+="UP":t+="BALANCED",t};var QMn=k(Hp,"BKAlignedLayout",164);A(466,23,{3:1,34:1,23:1,466:1},ige);var Yp,rb,Not=Ti(Hp,"BKAlignedLayout/HDirection",466,Di,WPt,QTt),Fot;A(465,23,{3:1,34:1,23:1,465:1},rge);var M1,oh,Uot=Ti(Hp,"BKAlignedLayout/VDirection",465,Di,HPt,eCt),zot;A(1485,1,{},NOe);var eTn=k(Hp,"BKAligner",1485);A(1488,1,{},tqe);var tTn=k(Hp,"BKCompactor",1488);A(593,1,{593:1},uq),p.a=0;var nTn=k(Hp,"BKCompactor/ClassEdge",593);A(423,1,{423:1},pDe),p.a=null,p.b=0;var iTn=k(Hp,"BKCompactor/ClassNode",423);A(1313,1,Tl,jOe),p.vf=function(t){return h(G(h(t,31),(Ie(),Va)),19).pc((xo(),Su))?Got:null},p.Pe=function(t,i){W$t(this,h(t,31),i)},p.a=!1,p.e=!1;var Got,rTn=k(Hp,"BKNodePlacer",1313);A(437,23,{3:1,34:1,23:1,437:1},sge);var ZG,LTe,kTe=Ti(Hp,"EdgeStraighteningStrategy",437,Di,VPt,tCt),jot;A(1486,1,{},fq),p.d=0;var sTn=k(Hp,"NeighborhoodInformation",1486);A(1487,1,Or,dZ),p.Ld=function(t,i){return Zkt(this,h(t,48),h(i,48))},p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)};var oTn=k(Hp,"NeighborhoodInformation/NeighborComparator",1487);A(724,1,{});var aTn=k(Hp,"ThresholdStrategy",724);A(1510,724,{},yDe),p.yf=function(t,i,a){return this.a.o==(Jf(),oh)?Jr:Ts},p.zf=function(){};var cTn=k(Hp,"ThresholdStrategy/NullThresholdStrategy",1510);A(522,1,{522:1},UOe),p.c=!1,p.d=!1;var lTn=k(Hp,"ThresholdStrategy/Postprocessable",522);A(1511,724,{},xDe),p.yf=function(t,i,a){var l,f,g;return f=i==a,l=this.a.a[a.o]==i,f||l?(g=t,this.a.c==(Eh(),rb)?(f&&(g=Cne(this,i,!0)),!isNaN(g)&&!isFinite(g)&&l&&(g=Cne(this,a,!1))):(f&&(g=Cne(this,i,!0)),!isNaN(g)&&!isFinite(g)&&l&&(g=Cne(this,a,!1))),g):t},p.zf=function(){for(var t,i,a,l,f;this.c.b!=0;)f=h(QPt(this.c),522),l=XZe(this,f),l.a&&(t=l.a,a=ce(this.a.f[this.a.g[f.b.o].o]),!(!a&&!Jo(t)&&t.c.g.c==t.d.g.c)&&(i=tYe(this,f),i||FNe(this.d,f)));for(;this.d.a.c.length!=0;)tYe(this,h(Abe(this.d),522))};var uTn=k(Hp,"ThresholdStrategy/SimpleThresholdStrategy",1511);A(573,1,{573:1,285:1,286:1},nu),p.hf=function(){return K$e(this)},p.uf=function(){return K$e(this)};var Roe,fTn=k(Q_,"EdgeRouterFactory",573);A(1356,1,Tl,$X),p.vf=function(t){return j9t(h(t,31))},p.Pe=function(t,i){jzt(h(t,31),i)};var $ot,Vot,Wot,Hot,qot,RTe,Xot,Yot,hTn=k(Q_,"OrthogonalEdgeRouter",1356);A(594,1,{},Nte),p.a=0,p.c=0;var dTn=k(Q_,"OrthogonalRoutingGenerator",594);A(252,1,{252:1},mU),p.Ib=function(){return this.a+"->"+this.b},p.c=0;var pTn=k(Q_,"OrthogonalRoutingGenerator/Dependency",252);A(165,1,{34:1,165:1},rVe),p.vd=function(t){return CEt(this,h(t,165))},p.Fb=function(t){var i;return re(t,165)?(i=h(t,165),this.d==i.d):!1},p.Hb=function(){return this.d},p.Ib=function(){var t,i,a,l;for(t=new ou("{"),l=new j(this.g);l.aJd&&(f=new $t(y,R),Gi(a.a,f),P6(this.a,a,t,f,!1),g=new $t(C,R),Gi(a.a,g),P6(this.a,a,t,g,!1))},p.Bf=function(t){return t.g.k.a+t.k.a+t.a.a},p.Cf=function(){return Fe(),ni},p.Df=function(){return Fe(),bn};var mTn=k(Q_,"OrthogonalRoutingGenerator/NorthToSouthRoutingStrategy",1490);A(1491,1,{},Nu),p.Af=function(t,i){var a,l,f,g,m,v,y,E,C,R;for(R=i-t.i*this.a.c,v=new j(t.g);v.aJd&&(f=new $t(y,R),Gi(a.a,f),P6(this.a,a,t,f,!1),g=new $t(C,R),Gi(a.a,g),P6(this.a,a,t,g,!1))},p.Bf=function(t){return t.g.k.a+t.k.a+t.a.a},p.Cf=function(){return Fe(),bn},p.Df=function(){return Fe(),ni};var bTn=k(Q_,"OrthogonalRoutingGenerator/SouthToNorthRoutingStrategy",1491);A(1489,1,{},Yh),p.Af=function(t,i){var a,l,f,g,m,v,y,E,C,R;for(R=i+t.i*this.a.c,v=new j(t.g);v.aJd&&(f=new $t(R,y),Gi(a.a,f),P6(this.a,a,t,f,!0),g=new $t(R,C),Gi(a.a,g),P6(this.a,a,t,g,!0))},p.Bf=function(t){return t.g.k.b+t.k.b+t.a.b},p.Cf=function(){return Fe(),Zt},p.Df=function(){return Fe(),nn};var wTn=k(Q_,"OrthogonalRoutingGenerator/WestToEastRoutingStrategy",1489);A(1351,1,Tl,$Oe),p.vf=function(t){return gNt(h(t,31))},p.Pe=function(t,i){$jt(this,h(t,31),i)};var Zot,Kot,Jot,Qot,KG,vTn=k(Q_,"PolylineEdgeRouter",1351);A(1352,1,ef,cN),p.Mb=function(t){return eIt(h(t,8))},p.Fb=function(t){return this===t},p.Nb=function(t){return this.Mb(t)};var _Tn=k(Q_,"PolylineEdgeRouter/1",1352);A(151,1,{151:1},XVe),p.Ib=function(){var t,i,a,l;for(a=new f0,this.e&&Mi(Mi(a,tI(this.e)),": "),i=Nn(wQ(this),0);i.b!=i.d.c;)t=h(Un(i),11),Mi(Mi(Lg(Mi(a,(l=rGe(t),l==null?"p_"+t.o:"p_"+l)),32),tI(t.i))," / ");return E8(a,a.a.length-2-1)},p.j=0,p.k=0;var yTn=k(g1,"ConnectedSelfLoopComponent",151);A(129,23,{3:1,34:1,23:1,129:1},Ig),p.c=0;var eat,tat,nat,sb,qw,Zp,Xw,lm,ip,Kp,ob,ab,iat,rat,sat,oat,aat,cat,lat,uat,fat,hat,dat,pat,gat,yy,l3,Yw,Zw,hL=Ti(g1,"LoopSide",129,Di,Tee,nCt),mat;A(424,1,{},OWe,__e,fwe),p.Ib=function(){return this.b.Ib()},p.c=0,p.d=!1,p.e=!1,p.f=!1,p.i=0,p.j=0;var xTn=k(g1,"NubSpline",424);A(190,1,{190:1},GYe,vQ);var ETn=k(g1,"NubSpline/PolarCP",190);A(599,424,{},fQ);var STn=k(g1,"NubsSelfLoop",599);A(236,1,{},tXe,Wte,Aqe,EI,Yte),p.a=q2e,p.b=Gx,p.c=q2e,p.d=Gx;var MTn=k(g1,"Rectangle",236);A(1353,1,Tl,HHe),p.vf=function(t){return UFt(h(t,31))},p.Pe=function(t,i){H$t(this,h(t,31),i)},p.d=3;var bat,wat,vat,_at,yat,xat,TTn=k(g1,"SplineEdgeRouter",1353);A(250,1,{250:1},oU),p.Ib=function(){return this.a+" ->("+this.c+") "+this.b},p.c=0;var CTn=k(g1,"SplineEdgeRouter/Dependency",250);A(417,23,{3:1,34:1,23:1,417:1},cge);var um,xy,Eat=Ti(g1,"SplineEdgeRouter/SideToProcess",417,Di,qPt,sCt),Sat;A(1354,1,{},KOe),p.td=function(t){GCt(this.a,this.b,t)};var ATn=k(g1,"SplineEdgeRouter/lambda$0$Type",1354);A(1355,1,{},JOe),p.td=function(t){jCt(this.a,this.b,t)};var PTn=k(g1,"SplineEdgeRouter/lambda$1$Type",1355);A(125,1,{34:1,125:1},hXe,y_e),p.vd=function(t){return AEt(this,h(t,125))},p.b=0,p.e=0,p.f=0,p.i=!1,p.j=0,p.k=!1,p.n=!1,p.p=0,p.r=0,p.s=0;var LTn=k(g1,"SplineSegment",125);A(589,1,{589:1},jf),p.a=0,p.b=!1,p.c=!1,p.d=!1,p.e=!1,p.f=0;var kTn=k(g1,"SplineSegment/EdgeInformation",589);A(990,1,{},hq);var RTn=k(CP,bye,990);A(991,1,Or,dq),p.Ld=function(t,i){return mFt(h(t,128),h(i,128))},p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)};var ITn=k(CP,lQe,991);A(989,1,{},ABe);var DTn=k(CP,"MrTree",989);A(360,23,{3:1,34:1,23:1,360:1,285:1,286:1},k8),p.hf=function(){return TXe(this)},p.uf=function(){return TXe(this)};var JG,dL,q5,pL,ITe=Ti(CP,"TreeLayoutPhases",360,Di,u4t,KTt),Mat;A(960,244,K_,f8e),p.Ae=function(t,i){var a,l,f,g,m,v;for(g=(m=new aU,No(m,t),Ee(m,(ha(),bL),t),v=new ui,T7t(t,m,v),p7t(t,m,v),m),f=P7t(this.a,g),l=new j(f);l.a"+Z9(this.c):"e_"+Hr(this)};var UTn=k(AP,"TEdge",170);A(128,131,{3:1,128:1,93:1,131:1},aU),p.Ib=function(){var t,i,a,l,f;for(f=null,l=Nn(this.b,0);l.b!=l.d.c;)a=h(Un(l),76),f+=(a.c==null||a.c.length==0?"n_"+a.g:"n_"+a.c)+` `;for(i=Nn(this.a,0);i.b!=i.d.c;)t=h(Un(i),170),f+=(t.b&&t.c?Z9(t.b)+"->"+Z9(t.c):"e_"+Hr(t))+` -`;return f};var vVt=k(AP,"TGraph",128);A(570,452,{3:1,452:1,570:1,93:1,131:1});var OTn=k(AP,"TShape",570);A(76,570,{3:1,452:1,76:1,570:1,93:1,131:1},Pee),p.Ib=function(){return Z9(this)};var _Vt=k(AP,"TNode",76);A(231,1,hd,Dd),p.sc=function(t){mo(this,t)},p.tc=function(){var t;return t=Nn(this.a.d,0),new ew(t)};var NTn=k(AP,"TNode/2",231);A(330,1,ys,ew),p.gc=function(t){Ss(this,t)},p.ic=function(){return h(Un(this.a),170).c},p.hc=function(){return v8(this.a)},p.jc=function(){z0e(this.a)};var FTn=k(AP,"TNode/2/1",330);A(1545,1,kr,h8e),p.Pe=function(t,i){O7t(this,h(t,128),i)};var UTn=k(jx,"FanProcessor",1545);A(308,23,{3:1,34:1,23:1,308:1,286:1},$C),p.hf=function(){switch(this.g){case 0:return new gDe;case 1:return new h8e;case 2:return new C2;case 3:return new cE;case 4:return new Ik;case 5:return new uE;default:throw Y(new un(Iie+(this.f!=null?this.f:""+this.g)))}};var Ioe,Doe,Boe,Ooe,Noe,QG,Tat=Ti(jx,Lye,308,Di,vkt,YTt),Cat;A(1548,1,kr,cE),p.Pe=function(t,i){w8t(this,h(t,128),i)},p.a=0;var zTn=k(jx,"LevelHeightProcessor",1548);A(1549,1,hd,Dk),p.sc=function(t){mo(this,t)},p.tc=function(){return _t(),Yv(),uy};var GTn=k(jx,"LevelHeightProcessor/1",1549);A(1546,1,kr,C2),p.Pe=function(t,i){UNt(this,h(t,128),i)},p.a=0;var jTn=k(jx,"NeighborsProcessor",1546);A(1547,1,hd,lE),p.sc=function(t){mo(this,t)},p.tc=function(){return _t(),Yv(),uy};var $Tn=k(jx,"NeighborsProcessor/1",1547);A(1550,1,kr,Ik),p.Pe=function(t,i){b8t(this,h(t,128),i)},p.a=0;var VTn=k(jx,"NodePositionProcessor",1550);A(1544,1,kr,gDe),p.Pe=function(t,i){nGt(this,h(t,128))};var WTn=k(jx,"RootProcessor",1544);A(1551,1,kr,uE),p.Pe=function(t,i){o6t(h(t,128))};var HTn=k(jx,"Untreeifyer",1551),X5,gL,Aat,Foe,ej,mL,Uoe,tj,nj,wM,bL,ij,Jp,DTe,Pat,zoe,Kw,Goe,BTe;A(750,1,pd,UX),p.ue=function(t){zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,X2e),""),"Weighting of Nodes"),"Which weighting to use when computing a node order."),NTe),(o1(),ms)),VTe),Ht((i1(),Ln))))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Y2e),""),"Search Order"),"Which search order to use when computing a spanning tree."),OTe),ms),HTe),Ht(Ln)))),gKe((new zX,t))};var Lat,OTe,kat,NTe,qTn=k(dz,"MrTreeMetaDataProvider",750);A(886,1,pd,zX),p.ue=function(t){gKe(t)};var Rat,FTe,UTe,Iat,zTe,rj,GTe,Dat,jTe,Bat,XTn=k(dz,"MrTreeOptions",886);A(887,1,{},vq),p.Be=function(){var t;return t=new f8e,t},p.Ce=function(t){};var YTn=k(dz,"MrTreeOptions/MrtreeFactory",887);A(438,23,{3:1,34:1,23:1,438:1},lge);var joe,$Te,VTe=Ti(dz,"OrderWeighting",438,Di,UPt,iCt),Oat;A(388,23,{3:1,34:1,23:1,388:1},uge);var WTe,$oe,HTe=Ti(dz,"TreeifyingOrder",388,Di,FPt,rCt),Nat;A(1357,1,Tl,GX),p.vf=function(t){return h(t,128),Fat},p.Pe=function(t,i){ORt(this,h(t,128),i)};var Fat,ZTn=k("org.eclipse.elk.alg.mrtree.p1treeify","DFSTreeifyer",1357);A(1358,1,Tl,jX),p.vf=function(t){return h(t,128),Uat},p.Pe=function(t,i){zNt(this,h(t,128),i)};var Uat,KTn=k("org.eclipse.elk.alg.mrtree.p2order","NodeOrderer",1358);A(1359,1,Tl,fF),p.vf=function(t){return h(t,128),zat},p.Pe=function(t,i){xUt(this,h(t,128),i)},p.a=0;var zat,JTn=k("org.eclipse.elk.alg.mrtree.p3place","NodePlacer",1359);A(1360,1,Tl,VX),p.vf=function(t){return h(t,128),Gat},p.Pe=function(t,i){cBt(h(t,128),i)};var Gat,QTn=k("org.eclipse.elk.alg.mrtree.p4route","EdgeRouter",1360),wL;A(447,23,{3:1,34:1,23:1,447:1,285:1,286:1},fge),p.hf=function(){return xWe(this)},p.uf=function(){return xWe(this)};var sj,vM,qTe=Ti(Z2e,"RadialLayoutPhases",447,Di,zPt,sCt),jat;A(961,244,K_,PBe),p.Ae=function(t,i){var a,l,f,g,m,v,y;if(l=lXe(this,t),ii(i,"Radial layout",l.c.length),y=TOt(t),ac(t,(eA(),wL),y),!y)throw Y(new un("The given graph is not a tree!"));for(g=ce(Xe(rn(t,(ww(),cj)))),g==0&&(g=MXe(t)),ac(t,cj,g),a=new dK(t),cd(OHe(a),new dE),f=new ER(a),SWe(f),v=new j(lXe(this,t));v.a0&&V$e(t.charCodeAt(i-1),wQe);)--i;if(l>=i)throw Y(new un("The given string does not contain any numbers."));if(f=Lx(t.substr(l,i-l),`,|;|\r| +`;return f};var xVt=k(AP,"TGraph",128);A(570,452,{3:1,452:1,570:1,93:1,131:1});var zTn=k(AP,"TShape",570);A(76,570,{3:1,452:1,76:1,570:1,93:1,131:1},Pee),p.Ib=function(){return Z9(this)};var EVt=k(AP,"TNode",76);A(231,1,hd,Dd),p.sc=function(t){mo(this,t)},p.tc=function(){var t;return t=Nn(this.a.d,0),new ew(t)};var GTn=k(AP,"TNode/2",231);A(330,1,ys,ew),p.gc=function(t){Ss(this,t)},p.ic=function(){return h(Un(this.a),170).c},p.hc=function(){return v8(this.a)},p.jc=function(){z0e(this.a)};var jTn=k(AP,"TNode/2/1",330);A(1545,1,kr,h8e),p.Pe=function(t,i){U7t(this,h(t,128),i)};var $Tn=k(jx,"FanProcessor",1545);A(308,23,{3:1,34:1,23:1,308:1,286:1},$C),p.hf=function(){switch(this.g){case 0:return new gDe;case 1:return new h8e;case 2:return new C2;case 3:return new cE;case 4:return new Ik;case 5:return new uE;default:throw Y(new un(Iie+(this.f!=null?this.f:""+this.g)))}};var Ioe,Doe,Boe,Ooe,Noe,QG,Tat=Ti(jx,Lye,308,Di,xkt,JTt),Cat;A(1548,1,kr,cE),p.Pe=function(t,i){y8t(this,h(t,128),i)},p.a=0;var VTn=k(jx,"LevelHeightProcessor",1548);A(1549,1,hd,Dk),p.sc=function(t){mo(this,t)},p.tc=function(){return _t(),Yv(),uy};var WTn=k(jx,"LevelHeightProcessor/1",1549);A(1546,1,kr,C2),p.Pe=function(t,i){jNt(this,h(t,128),i)},p.a=0;var HTn=k(jx,"NeighborsProcessor",1546);A(1547,1,hd,lE),p.sc=function(t){mo(this,t)},p.tc=function(){return _t(),Yv(),uy};var qTn=k(jx,"NeighborsProcessor/1",1547);A(1550,1,kr,Ik),p.Pe=function(t,i){_8t(this,h(t,128),i)},p.a=0;var XTn=k(jx,"NodePositionProcessor",1550);A(1544,1,kr,gDe),p.Pe=function(t,i){sGt(this,h(t,128))};var YTn=k(jx,"RootProcessor",1544);A(1551,1,kr,uE),p.Pe=function(t,i){l6t(h(t,128))};var ZTn=k(jx,"Untreeifyer",1551),X5,gL,Aat,Foe,ej,mL,Uoe,tj,nj,wM,bL,ij,Jp,DTe,Pat,zoe,Kw,Goe,BTe;A(750,1,pd,UX),p.ue=function(t){zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,X2e),""),"Weighting of Nodes"),"Which weighting to use when computing a node order."),NTe),(o1(),ms)),VTe),Ht((i1(),Ln))))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Y2e),""),"Search Order"),"Which search order to use when computing a spanning tree."),OTe),ms),HTe),Ht(Ln)))),gKe((new zX,t))};var Lat,OTe,kat,NTe,KTn=k(dz,"MrTreeMetaDataProvider",750);A(886,1,pd,zX),p.ue=function(t){gKe(t)};var Rat,FTe,UTe,Iat,zTe,rj,GTe,Dat,jTe,Bat,JTn=k(dz,"MrTreeOptions",886);A(887,1,{},vq),p.Be=function(){var t;return t=new f8e,t},p.Ce=function(t){};var QTn=k(dz,"MrTreeOptions/MrtreeFactory",887);A(438,23,{3:1,34:1,23:1,438:1},lge);var joe,$Te,VTe=Ti(dz,"OrderWeighting",438,Di,jPt,oCt),Oat;A(388,23,{3:1,34:1,23:1,388:1},uge);var WTe,$oe,HTe=Ti(dz,"TreeifyingOrder",388,Di,GPt,aCt),Nat;A(1357,1,Tl,GX),p.vf=function(t){return h(t,128),Fat},p.Pe=function(t,i){URt(this,h(t,128),i)};var Fat,eCn=k("org.eclipse.elk.alg.mrtree.p1treeify","DFSTreeifyer",1357);A(1358,1,Tl,jX),p.vf=function(t){return h(t,128),Uat},p.Pe=function(t,i){$Nt(this,h(t,128),i)};var Uat,tCn=k("org.eclipse.elk.alg.mrtree.p2order","NodeOrderer",1358);A(1359,1,Tl,fF),p.vf=function(t){return h(t,128),zat},p.Pe=function(t,i){MUt(this,h(t,128),i)},p.a=0;var zat,nCn=k("org.eclipse.elk.alg.mrtree.p3place","NodePlacer",1359);A(1360,1,Tl,VX),p.vf=function(t){return h(t,128),Gat},p.Pe=function(t,i){fBt(h(t,128),i)};var Gat,iCn=k("org.eclipse.elk.alg.mrtree.p4route","EdgeRouter",1360),wL;A(447,23,{3:1,34:1,23:1,447:1,285:1,286:1},fge),p.hf=function(){return xWe(this)},p.uf=function(){return xWe(this)};var sj,vM,qTe=Ti(Z2e,"RadialLayoutPhases",447,Di,$Pt,cCt),jat;A(961,244,K_,PBe),p.Ae=function(t,i){var a,l,f,g,m,v,y;if(l=lXe(this,t),ii(i,"Radial layout",l.c.length),y=POt(t),ac(t,(eA(),wL),y),!y)throw Y(new un("The given graph is not a tree!"));for(g=ce(Xe(rn(t,(ww(),cj)))),g==0&&(g=MXe(t)),ac(t,cj,g),a=new dK(t),cd(OHe(a),new dE),f=new ER(a),SWe(f),v=new j(lXe(this,t));v.a0&&V$e(t.charCodeAt(i-1),wQe);)--i;if(l>=i)throw Y(new un("The given string does not contain any numbers."));if(f=Lx(t.substr(l,i-l),`,|;|\r| `),f.length!=2)throw Y(new un("Exactly two numbers are expected, "+f.length+" were found."));try{this.a=xw(yw(f[0])),this.b=xw(yw(f[1]))}catch(g){throw g=pr(g),re(g,118)?(a=g,Y(new un(vQe+a))):Y(g)}},p.Ib=function(){return"("+this.a+","+this.b+")"},p.a=0,p.b=0;var es=k(Q6,"KVector",9);A(74,66,{3:1,4:1,20:1,25:1,41:1,13:1,66:1,15:1,74:1,428:1},zc,p8),p.gf=function(t){var i,a,l,f,g,m;l=Lx(t,`,|;|\\(|\\)|\\[|\\]|\\{|\\}| | | -`),rd(this);try{for(a=0,g=0,f=0,m=0;a0&&(g%2==0?f=xw(l[a]):m=xw(l[a]),g>0&&g%2!=0&&Gi(this,new $t(f,m)),++g),++a}catch(v){throw v=pr(v),re(v,118)?(i=v,Y(new un("The given string does not match the expected format for vectors."+i))):Y(v)}},p.Ib=function(){var t,i,a;for(t=new ou("("),i=Nn(this,0);i.b!=i.d.c;)a=h(Un(i),9),Mi(t,a.a+","+a.b),i.b!=i.d.c&&(t.a+="; ");return(t.a+=")",t).a};var pCe=k(Q6,"KVectorChain",74);A(224,23,{3:1,34:1,23:1,224:1},VC);var Qoe,lj,uj,J5,Q5,fj,gCe=Ti(Pf,"Alignment",224,Di,_kt,fCt),cct;A(855,1,pd,qX),p.ue=function(t){RZe(t)};var mCe,eae,bCe,wCe,lct,tae,uct,fct,vCe,_Ce,hct,uAn=k(Pf,"BoxLayouterOptions",855);A(856,1,{},hN),p.Be=function(){var t;return t=new jq,t},p.Ce=function(t){};var fAn=k(Pf,"BoxLayouterOptions/BoxFactory",856);A(785,1,pd,XX),p.ue=function(t){zt(t,new Rt(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,iet),""),"Layout Algorithm"),"Select a specific layout algorithm."),(o1(),Z5)),Se),Ht((i1(),Ln))))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,x2e),""),"Alignment"),"Alignment of the selected node relative to other nodes, the exact meaning depends on the used algorithm."),xCe),ms),gCe),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.alignment"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,WS),""),"Aspect Ratio"),"The desired aspect ratio of the drawing, that is the quotient of width by height."),nc),Eo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.aspectRatio"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,cxe),""),"Bend Points"),"A fixed list of bend points for the edge. This is used by the 'Fixed Layout' algorithm to specify a pre-defined routing for an edge. The vector chain must include the source point, any bend points, and the target point, so it must have at least two points."),wd),pCe),Ht(bd)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.bendPoints"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,nre),""),"Debug Mode"),"Whether additional debug information shall be generated."),(vt(),vt(),!1)),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.debugMode"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,rre),""),uye),"Overall direction of edges: horizontal (right / left) or vertical (down / up)."),SCe),ms),yL),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.direction"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,n5),""),"Edge Routing"),"What kind of edge routing style should be applied for the content of a parent node. Algorithms may also set this option to single edges in order to mark them as splines. The bend point list of edges with this option set to SPLINES must be interpreted as control points for a piecewise cubic spline."),CCe),ms),mae),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.edgeRouting"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,oxe),""),"Expand Nodes"),"If active, nodes are expanded to fill the area of their parent."),!1),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.expandNodes"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,E2e),""),"Hierarchy Handling"),"If this option is set to SEPARATE_CHILDREN, each hierarchy level of the graph is processed independently, possibly by different layout algorithms, beginning with the lowest level. If it is set to INCLUDE_CHILDREN, the algorithm is responsible to process all hierarchy levels that are contained in the associated parent node. If the root node is set to inherit (or not set at all), the default behavior is SEPARATE_CHILDREN."),LCe),ms),uAe),sr(Ln,X(q(Qp,1),Oe,163,0,[ga]))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.hierarchyHandling"])))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Ux),""),"Padding"),"The padding to be left to a parent element's border when placing child elements. This can also serve as an output option of a layout algorithm if node size calculation is setup appropriately."),FCe),wd),PEe),sr(Ln,X(q(Qp,1),Oe,163,0,[ga]))))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Q7),""),"Interactive"),"Whether the algorithm should be run in interactive mode for the content of a parent node. What this means exactly depends on how the specific algorithm interprets this option. Usually in the interactive mode algorithms try to modify the current layout as little as possible."),!1),_a),lo),Ht(Ln)))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,kie),""),"Port Constraints"),"Defines constraints of the position of the ports of a node."),$Ce),ms),dAe),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portConstraints"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,fz),""),"Position"),"The position of a node, port, or label. This is used by the 'Fixed Layout' algorithm to specify a pre-defined position."),wd),es),sr(ga,X(q(Qp,1),Oe,163,0,[lb,fm]))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.position"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,Y6),""),"Priority"),"Defines the priority of an object; its meaning depends on the specific layout algorithm and the context where it is used."),xc),Po),sr(ga,X(q(Qp,1),Oe,163,0,[bd]))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.priority"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,J7),""),"Randomization Seed"),"Seed used for pseudo-random number generators to control the layout algorithm. If the value is 0, the seed shall be determined pseudo-randomly (e.g. from the system time)."),xc),Po),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.randomSeed"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,Z6),""),"Separate Connected Components"),"Whether each connected component should be processed separately."),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.separateConnComp"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,D2e),""),"Junction Points"),"This option is not used as option, but as output of the layout algorithms. It is attached to edges and determines the points where junction symbols should be drawn in order to represent hyperedges with orthogonal routing. Whether such points are computed depends on the chosen layout algorithm and edge routing style. The points are put into the vector chain with no specific order."),kCe),wd),pCe),Ht(bd)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.junctionPoints"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,F2e),""),"Comment Box"),"Whether the node should be regarded as a comment box instead of a regular node. In that case its placement should be similar to how labels are handled. Any edges incident to a comment box specify to which graph elements the comment is related."),!1),_a),lo),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.commentBox"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,U2e),""),"Hypernode"),"Whether the node should be handled as a hypernode."),!1),_a),lo),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.hypernode"])))),zt(t,new Rt(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,ret),""),"Label Manager"),"Label managers can shorten labels upon a layout algorithm's request."),wd),AVt),sr(Ln,X(q(Qp,1),Oe,163,0,[fm]))))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,$2e),""),"Margins"),"Margins define additional space around the actual bounds of a graph element. For instance, ports or labels being placed on the outside of a node's border might introduce such a margin. The margin is used to guarantee non-overlap of other graph elements with those ports or labels."),RCe),wd),AEe),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.margins"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,_2e),""),"No Layout"),"No layout is done for the associated element. This is used to mark parts of a diagram to avoid their inclusion in the layout graph, or to mark parts of the layout graph to prevent layout engines from processing them. If you wish to exclude the contents of a compound node from automatic layout, while the node itself is still considered on its own layer, use the 'Fixed Layout' algorithm for that node."),!1),_a),lo),sr(ga,X(q(Qp,1),Oe,163,0,[bd,lb,fm]))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.noLayout"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,set),""),"Scale Factor"),"The scaling factor to be applied to the corresponding node in recursive layout. It causes the corresponding node's size to be adjusted, and its ports and labels to be sized and placed accordingly after the layout of that node has been determined (and before the node itself and its siblings are arranged). The scaling is not reverted afterwards, so the resulting layout graph contains the adjusted size and position data. This option is currently not supported if 'Layout Hierarchy' is set."),1),nc),Eo),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.scaleFactor"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,oet),""),"Animate"),"Whether the shift from the old layout to the new computed layout shall be animated."),!0),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.animate"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,aet),""),"Animation Time Factor"),"Factor for computation of animation time. The higher the value, the longer the animation time. If the value is 0, the resulting time is always equal to the minimum defined by 'Minimal Animation Time'."),He(100)),xc),Po),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.animTimeFactor"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,cet),""),"Layout Ancestors"),"Whether the hierarchy levels on the path from the selected element to the root of the diagram shall be included in the layout process."),!1),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.layoutAncestors"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,uet),""),"Maximal Animation Time"),"The maximal time for animations, in milliseconds."),He(4e3)),xc),Po),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.maxAnimTime"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,fet),""),"Minimal Animation Time"),"The minimal time for animations, in milliseconds."),He(400)),xc),Po),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.minAnimTime"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,het),""),"Progress Bar"),"Whether a progress bar shall be displayed during layout computations."),!1),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.progressBar"])))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,det),""),"Validate Options"),"Whether layout options shall be validated before any layout algorithm is applied. If this option is enabled and at least one error is found, the layout process is aborted and a message is shown to the user."),!0),_a),lo),Ht(Ln)))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,pet),""),"Zoom to Fit"),"Whether the zoom level shall be set to view the whole diagram after layout."),!1),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.zoomToFit"])))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,axe),"box"),"Box Layout Mode"),"Configures the packing mode used by the {@link BoxLayoutProvider}. If SIMPLE is not required (neither priorities are used nor the interactive mode), GROUP_DEC can improve the packing and decrease the area. GROUP_MIXED and GROUP_INC may, in very specific scenarios, work better."),ECe),ms),yAe),Ht(Ln)))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Mie),im),"Components Spacing"),"Spacing to be preserved between pairs of connected components. This option is only relevant if 'separateConnectedComponents' is activated."),12),nc),Eo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.borderSpacing"])))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,h2e),im),"Edge Spacing"),"Spacing to be preserved between any two edges. Note that while this can somewhat easily be satisfied for the segments of orthogonally drawn edges, it is harder for general polylines or splines."),10),nc),Eo),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Lie),im),"Edge Label Spacing"),"The minimal distance to be preserved between a label and the edge it is associated with. Note that the placement of a label is influenced by the 'edgelabels.placement' option."),2),nc),Eo),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,d2e),im),"Edge Node Spacing"),"Spacing to be preserved between nodes and edges."),10),nc),Eo),Ht(Ln)))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,p2e),im),"Label Spacing"),"Determines the amount of space to be left between two labels of the same graph element."),0),nc),Eo),Ht(Ln)),X(q(Se,1),be,2,6,[vet])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,m2e),im),"Label Node Spacing"),"Spacing to be preserved between labels and the border of node they are associated with. Note that the placement of a label is influenced by the 'nodelabels.placement' option."),5),nc),Eo),Ht(Ln)),X(q(Se,1),be,2,6,[vet])))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,g2e),im),"Label Port Spacing"),"Spacing to be preserved between labels and the ports they are associated with. Note that the placement of a label is influenced by the 'portlabels.placement' option."),1),nc),Eo),Ht(Ln)))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,qS),im),"Node Spacing"),"The minimal distance to be preserved between each two nodes."),20),nc),Eo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.spacing"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,b2e),im),"Port Spacing"),"Spacing between pairs of ports of the same node."),10),nc),Eo),sr(Ln,X(q(Qp,1),Oe,163,0,[ga]))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portSpacing"])))),zt(t,new Rt(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,w2e),im),"Individual Spacing Override"),"In general spacing values apply to the children of the hierarchical node (possibly the root node) for which the values are actually specified. Hereby, the children include ports, edges, and labels."),wd),xVt),sr(ga,X(q(Qp,1),Oe,163,0,[bd,lb,fm]))))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,V2e),im),"Additional Port Space"),"Additional space around the sets of ports on each node side. For each side of a node, this option can reserve additional space before and after the ports on each side. For example, a top spacing of 20 makes sure that the first port on the western and eastern side is 20 units away from the northern border."),KCe),wd),AEe),Ht(Ln)))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,j2e),_et),"Layout Partition"),"Partition to which the node belongs to. If 'layoutPartitions' is true, all nodes are expected to have a partition."),xc),Po),sr(Ln,X(q(Qp,1),Oe,163,0,[ga]))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.partition"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,G2e),_et),"Layout Partitioning"),"Whether to activate partitioned layout."),UCe),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.layoutPartitions"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,get),yet),"Node Label Padding"),"Define padding for node labels that are placed inside of a node."),ICe),wd),PEe),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.nodeLabelInset"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,T2e),yet),"Node Label Placement"),"Hints for where node labels are to be placed; if empty, the node label's position is not modified."),DCe),_M),Ys),sr(ga,X(q(Qp,1),Oe,163,0,[fm]))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.nodeLabelPlacement"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,P2e),pz),"Port Alignment"),"Defines the default port distribution for a node. May be overridden for each side individually."),GCe),ms),CL),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portAlignment"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,L2e),pz),"Port Alignment (North)"),"Defines how ports on the northern side are placed, overriding the node's general port alignment."),ms),CL),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portAlignment.north"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,k2e),pz),"Port Alignment (South)"),"Defines how ports on the southern side are placed, overriding the node's general port alignment."),ms),CL),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portAlignment.south"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,R2e),pz),"Port Alignment (West)"),"Defines how ports on the western side are placed, overriding the node's general port alignment."),ms),CL),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portAlignment.west"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,I2e),pz),"Port Alignment (East)"),"Defines how ports on the eastern side are placed, overriding the node's general port alignment."),ms),CL),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portAlignment.east"])))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,lz),lxe),"Node Size Constraints"),"Constraints for determining node sizes. Each member of the set specifies something that should be taken into account when calculating node sizes. The empty set corresponds to node sizes being fixed."),BCe),_M),AL),Ht(ga)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,ire),lxe),"Node Size Options"),"Options modifying the behavior of the size constraints set on a node. Each member of the set specifies something that should be taken into account when calculating node sizes. The empty set corresponds to no further modifications."),NCe),_M),bAe),Ht(ga)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,uz),lxe),"Node Size Minimum"),"The minimal size to which a node can be reduced."),OCe),wd),es),Ht(ga)))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,B2e),tre),"Edge Label Placement"),"Gives a hint on where to put edge labels."),MCe),ms),QCe),Ht(fm)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.edgeLabelPlacement"])))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,O2e),tre),"Inline Edge Labels"),"If true, an edge label is placed directly on its edge. May only apply to center edge labels. This kind of label placement is only advisable if the label's rendering is such that it is not crossed by its edge and thus stays legible."),!1),_a),lo),Ht(fm)))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,met),"font"),"Font Name"),"Font name used for a label."),Z5),Se),Ht(fm)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.fontName"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,bet),"font"),"Font Size"),"Font size used for a label."),xc),Po),Ht(fm)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.fontSize"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,z2e),pre),"Port Anchor Offset"),"The offset to the port position where connections shall be attached."),wd),es),Ht(lb)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portAnchor"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,N2e),pre),"Port Index"),"The index of a port in the fixed order around a node. The order is assumed as clockwise, starting with the leftmost port on the top side. This option must be set if 'Port Constraints' is set to FIXED_ORDER and no specific positions are given for the ports. Additionally, the option 'Port Side' must be defined in this case."),xc),Po),Ht(lb)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portIndex"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,y2e),pre),"Port Side"),"The side of a node on which a port is situated. This option must be set if 'Port Constraints' is set to FIXED_SIDE or FIXED_ORDER and no specific positions are given for the ports."),WCe),ms),Ec),Ht(lb)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portSide"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,v2e),pre),"Port Border Offset"),"The offset of ports on the node border. With a positive offset the port is moved outside of the node, while with a negative offset the port is moved towards the inside. An offset of 0 means that the port is placed directly on the node border, i.e. if the port side is north, the port's south border touches the nodes's north border; if the port side is east, the port's west border touches the nodes's east border; if the port side is south, the port's north border touches the node's south border; if the port side is west, the port's east border touches the node's west border."),nc),Eo),Ht(lb)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.offset"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,C2e),xet),"Port Label Placement"),"Decides on a placement method for port labels."),VCe),ms),pAe),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portLabelPlacement"])))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,A2e),xet),"Port Labels Next to Port"),"Usually, inside port labels of hierarchical nodes are placed not next to their port, but with an offset to avoid edge-label crossings. The offset is not necessary if the port has no connections that would cross the label, but is usually applied anyway to keep things uniform. Setting this option to true places labels next to their ports if they won't be crossed by edges."),!1),_a),lo),Ht(ga)))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,S2e),Eet),"Activate Inside Self Loops"),"Whether this node allows to route self loops inside of it instead of around it. If set to true, this will make the node a compound node if it isn't already, and will require the layout algorithm to support compound nodes with hierarchical ports."),!1),_a),lo),Ht(ga)),X(q(Se,1),be,2,6,[Met])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,M2e),Eet),"Inside Self Loop"),"Whether a self loop should be routed inside a node instead of around that node."),!1),_a),lo),Ht(bd)),X(q(Se,1),be,2,6,[Met])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Tie),"edge"),"Edge Thickness"),"The thickness of an edge. This is a hint on the line width used to draw an edge, possibly requiring more space to be reserved for it."),1),nc),Eo),Ht(bd)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.thickness"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,wet),"edge"),"Edge Type"),"The type of an edge. This is usually used for UML class diagrams, where associations must be handled differently from generalizations."),PCe),ms),sAe),Ht(bd)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.edgeType"])))),BC(t,new cx(AC(BE(DE(new Wb,Pn),"Layered"),'The layer-based method was introduced by Sugiyama, Tagawa and Toda in 1981. It emphasizes the direction of edges by pointing as many edges as possible into the same direction. The nodes are arranged in layers, which are sometimes called "hierarchies", and then reordered such that the number of edge crossings is minimized. Afterwards, concrete coordinates are computed for the nodes and edge bend points.'))),BC(t,new cx(AC(BE(DE(new Wb,"org.eclipse.elk.orthogonal"),"Orthogonal"),`Orthogonal methods that follow the "topology-shape-metrics" approach by Batini, Nardelli and Tamassia '86. The first phase determines the topology of the drawing by applying a planarization technique, which results in a planar representation of the graph. The orthogonal shape is computed in the second phase, which aims at minimizing the number of edge bends, and is called orthogonalization. The third phase leads to concrete coordinates for nodes and edge bend points by applying a compaction method, thus defining the metrics.`))),BC(t,new cx(AC(BE(DE(new Wb,kh),"Force"),"Layout algorithms that follow physical analogies by simulating a system of attractive and repulsive forces. The first successful method of this kind was proposed by Eades in 1984."))),BC(t,new cx(AC(BE(DE(new Wb,"org.eclipse.elk.circle"),"Circle"),"Circular layout algorithms emphasize cycles or biconnected components of a graph by arranging them in circles. This is useful if a drawing is desired where such components are clearly grouped, or where cycles are shown as prominent OPTIONS of the graph."))),BC(t,new cx(AC(BE(DE(new Wb,qQe),"Tree"),"Specialized layout methods for trees, i.e. acyclic graphs. The regular structure of graphs that have no undirected cycles can be emphasized using an algorithm of this type."))),BC(t,new cx(AC(BE(DE(new Wb,"org.eclipse.elk.planar"),"Planar"),"Algorithms that require a planar or upward planar graph. Most of these algorithms are theoretically interesting, but not practically usable."))),BC(t,new cx(AC(BE(DE(new Wb,X0),"Radial"),"Radial layout algorithms usually position the nodes of the graph on concentric circles."))),dZe((new dF,t)),RZe((new qX,t)),tZe((new pF,t))};var yCe,dct,xCe,yM,pct,gct,ECe,mct,nae,vL,SCe,bct,eD,MCe,TCe,CCe,ACe,PCe,wct,Ey,LCe,vct,hj,iae,rae,u3,kCe,dj,RCe,_ct,ICe,pj,DCe,xM,BCe,tD,OCe,gj,NCe,sae,Sy,FCe,yct,UCe,xct,zCe,GCe,oae,aae,cae,lae,jCe,Zc,nD,$Ce,Ect,iD,uae,VCe,_L,WCe,f3,mj,fae,Sct,hae,HCe,Mct,qCe,Tct,dae,XCe,bj,YCe,My,ZCe,KCe,JCe,hAn=k(Pf,"CoreOptions",785);A(110,23,{3:1,34:1,23:1,110:1},VR);var rp,rf,sf,Oh,hm,yL=Ti(Pf,uye,110,Di,N4t,wCt),Cct;A(226,23,{3:1,34:1,23:1,226:1},I8);var xL,h3,EL,wj,QCe=Ti(Pf,"EdgeLabelPlacement",226,Di,l4t,vCt),Act;A(197,23,{3:1,34:1,23:1,197:1},D8);var EM,pae,ub,gae,mae=Ti(Pf,"EdgeRouting",197,Di,u4t,_Ct),Pct;A(289,23,{3:1,34:1,23:1,289:1},WC);var eAe,tAe,nAe,iAe,bae,rAe,sAe=Ti(Pf,"EdgeType",289,Di,ykt,yCt),Lct;A(853,1,pd,dF),p.ue=function(t){dZe(t)};var oAe,aAe,cAe,kct,lAe,SL,dAn=k(Pf,"FixedLayouterOptions",853);A(854,1,{},dN),p.Be=function(){var t;return t=new vg,t},p.Ce=function(t){};var pAn=k(Pf,"FixedLayouterOptions/FixedFactory",854);A(316,23,{3:1,34:1,23:1,316:1},qK);var d3,vj,ML,uAe=Ti(Pf,"HierarchyHandling",316,Di,kLt,gCt),Rct;A(86,23,{3:1,34:1,23:1,86:1},Qv);var Nh,Mu,Tu,Cu,Ll,Au,of,af,Rf,Ys=Ti(Pf,"NodeLabelPlacement",86,Di,fRt,mCt),Ict;A(225,23,{3:1,34:1,23:1,225:1},WR);var fAe,TL,fb,hAe,wae,CL=Ti(Pf,"PortAlignment",225,Di,B4t,bCt),Dct;A(83,23,{3:1,34:1,23:1,83:1},HC);var p3,Oa,vd,g3,sp,hb,dAe=Ti(Pf,"PortConstraints",83,Di,wkt,pCt),Bct;A(275,23,{3:1,34:1,23:1,275:1},XK);var _j,db,Ty,pAe=Ti(Pf,"PortLabelPlacement",275,Di,ALt,hCt),Oct;A(69,23,{3:1,34:1,23:1,69:1},HR);var Zt,bn,rD,Cy,Fh,pb,gAe,sD,Ay,_d,vae,yd,T1,xd,m3,oD,Py,aD,ni,Na,nn,Ec=Ti(Pf,"PortSide",69,Di,C4t,dCt),Nct;A(857,1,pd,pF),p.ue=function(t){tZe(t)};var Fct,Uct,mAe,zct,Gct,gAn=k(Pf,"RandomLayouterOptions",857);A(858,1,{},Gq),p.Be=function(){var t;return t=new hE,t},p.Ce=function(t){};var mAn=k(Pf,"RandomLayouterOptions/RandomFactory",858);A(344,23,{3:1,34:1,23:1,344:1},B8);var gb,cD,lD,C1,AL=Ti(Pf,"SizeConstraint",344,Di,f4t,xCt),jct;A(239,23,{3:1,34:1,23:1,239:1},e_);var yj,xj,SM,_ae,PL,LL,Ej,b3,Sj,bAe=Ti(Pf,"SizeOptions",239,Di,hRt,ECt),$ct;A(313,1,{},g9,Eme,xme),p.b=!1,p.c=0,p.d=-1,p.e=0,p.f=!1,p.j=0;var bAn=k(Af,"BasicProgressMonitor",313);A(848,244,K_,jq),p.Ae=function(t,i){var a,l,f,g,m,v,y,E,C,R;switch(ii(i,"Box layout",2),g=ce(Xe(rn(t,(l7(),hct)))),m=h(rn(t,fct),119),a=ce(mt(rn(t,bCe))),l=ce(mt(rn(t,wCe))),f=h(rn(t,eae),288),f.g){case 0:v=(y=new h9((!t.a&&(t.a=new ze(Br,t,10,11)),t.a)),_t(),Ug(y,new mZ(l)),y),E=h(rn(t,tae),9),E.a=w.Math.max(E.a-m.b-m.c,0),E.b=w.Math.max(E.b-m.d-m.a,0),C=Xe(rn(t,mCe)),(C==null||(dn(C),C<=0))&&(C=1.3),R=Ijt(v,g,m,E.a,E.b,a,(dn(C),C)),H_(t,R.a,R.b,!1,!0);break;default:Vzt(t,g,m,a)}On(i)};var wAn=k(Af,"BoxLayoutProvider",848);A(849,1,Or,mZ),p.Ld=function(t,i){return Z8t(this,h(t,35),h(i,35))},p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.a=!1;var vAn=k(Af,"BoxLayoutProvider/1",849);A(145,1,{145:1},xU,YFe),p.Ib=function(){return this.c?s_e(this.c):Vp(this.b)};var _An=k(Af,"BoxLayoutProvider/Group",145);A(288,23,{3:1,34:1,23:1,288:1},O8);var wAe,vAe,_Ae,yae,yAe=Ti(Af,"BoxLayoutProvider/PackingMode",288,Di,d4t,SCt),Vct;A(850,1,Or,Nq),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return-to(XR(h(t,145)),XR(h(i,145)))};var yAn=k(Af,"BoxLayoutProvider/lambda$0$Type",850);A(851,1,Or,Fq),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return to(XR(h(t,145)),XR(h(i,145)))};var xAn=k(Af,"BoxLayoutProvider/lambda$1$Type",851);A(852,1,Or,Uq),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return to(XR(h(t,145)),XR(h(i,145)))};var EAn=k(Af,"BoxLayoutProvider/lambda$2$Type",852);A(833,1,{},XOe),p.td=function(t){LFt(this.a,this.b,t)},p.a=0,p.b=0;var SAn=k(Af,"ElkUtil/lambda$0$Type",833);A(834,1,{},YOe),p.td=function(t){tEt(this.a,this.b,t)},p.a=0,p.b=0;var MAn=k(Af,"ElkUtil/lambda$1$Type",834);A(835,1,{},ZOe),p.td=function(t){PSt(this.a,this.b,t)},p.a=0,p.b=0;var TAn=k(Af,"ElkUtil/lambda$2$Type",835);A(322,1,{34:1,322:1},CE),p.vd=function(t){return OSt(this,h(t,210))},p.Fb=function(t){var i;return re(t,322)?(i=h(t,322),this.a==i.a):!1},p.Hb=function(){return yr(this.a)},p.Ib=function(){return this.a+" (exclusive)"},p.a=0;var CAn=k(Af,"ExclusiveBounds/ExclusiveLowerBound",322);A(963,244,K_,vg),p.Ae=function(t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt;for(ii(i,Tet,1),g=h(rn(t,(ur(),TCe)),197),B=0,N=0,we=new Bn((!t.a&&(t.a=new ze(Br,t,10,11)),t.a));we.e!=we.i._b();){for(ie=h(Yn(we),35),Mt=h(rn(ie,(CU(),SL)),9),Mt&&(Od(ie,Mt.a,Mt.b),h(rn(ie,aAe),185).pc((Hl(),gb))&&(W=h(rn(ie,cAe),9),W.a>0&&W.b>0&&H_(ie,W.a,W.b,!0,!0))),B=w.Math.max(B,ie.i+ie.g),N=w.Math.max(N,ie.j+ie.f),C=new Bn((!ie.n&&(ie.n=new ze(ea,ie,1,7)),ie.n));C.e!=C.i._b();)y=h(Yn(C),137),Mt=h(rn(y,SL),9),Mt&&Od(y,Mt.a,Mt.b),B=w.Math.max(B,ie.i+y.i+y.g),N=w.Math.max(N,ie.j+y.j+y.f);for(qe=new Bn((!ie.c&&(ie.c=new ze(Pu,ie,9,9)),ie.c));qe.e!=qe.i._b();)for(Ue=h(Yn(qe),121),Mt=h(rn(Ue,SL),9),Mt&&Od(Ue,Mt.a,Mt.b),ut=ie.i+Ue.i,ft=ie.j+Ue.j,B=w.Math.max(B,ut+Ue.g),N=w.Math.max(N,ft+Ue.f),E=new Bn((!Ue.n&&(Ue.n=new ze(ea,Ue,1,7)),Ue.n));E.e!=E.i._b();)y=h(Yn(E),137),Mt=h(rn(y,SL),9),Mt&&Od(y,Mt.a,Mt.b),B=w.Math.max(B,ut+y.i+y.g),N=w.Math.max(N,ft+y.j+y.f);for(f=Cn(Th(ie));Gn(f);)a=h(Tn(f),105),R=oJe(a),B=w.Math.max(B,R.a),N=w.Math.max(N,R.b);for(l=Cn(S6(ie));Gn(l);)a=h(Tn(l),105),Ia(h(ae((!a.b&&(a.b=new an(pi,a,4,7)),a.b),0),97))!=t&&(R=oJe(a),B=w.Math.max(B,R.a),N=w.Math.max(N,R.b))}if(g==(ld(),EM))for(fe=new Bn((!t.a&&(t.a=new ze(Br,t,10,11)),t.a));fe.e!=fe.i._b();)for(ie=h(Yn(fe),35),l=Cn(Th(ie));Gn(l);)a=h(Tn(l),105),v=(m=new zc,m),v.b==0?ac(a,u3,null):ac(a,u3,v);Ce=h(rn(t,(CU(),kct)),119),ee=B+Ce.b+Ce.c,V=N+Ce.d+Ce.a,H_(t,ee,V,!0,!0),On(i)};var AAn=k(Af,"FixedLayoutProvider",963);A(786,131,Eie,Bk);var xVt=k(Af,"IndividualSpacings",786);A(635,1,{},T9e),p.c=0;var PAn=k(Af,"InstancePool",635);A(48,1,{20:1,48:1},Is),p.sc=function(t){mo(this,t)},p.Fb=function(t){var i,a,l;return re(t,48)?(a=h(t,48),i=this.a==null?a.a==null:ki(this.a,a.a),l=this.b==null?a.b==null:ki(this.b,a.b),i&&l):!1},p.Hb=function(){var t,i,a,l,f,g;return a=this.a==null?0:Hr(this.a),t=a&jr,i=a&-65536,g=this.b==null?0:Hr(this.b),l=g&jr,f=g&-65536,t^f>>16&jr|i^l<<16},p.tc=function(){return new bZ(this)},p.Ib=function(){return this.a==null&&this.b==null?"pair(null,null)":this.a==null?"pair(null,"+Ga(this.b)+")":this.b==null?"pair("+Ga(this.a)+",null)":"pair("+Ga(this.a)+","+Ga(this.b)+")"};var LAn=k(Af,"Pair",48);A(859,1,ys,bZ),p.gc=function(t){Ss(this,t)},p.hc=function(){return!this.c&&(!this.b&&this.a.a!=null||this.a.b!=null)},p.ic=function(){if(!this.c&&!this.b&&this.a.a!=null)return this.b=!0,this.a.a;if(!this.c&&this.a.b!=null)return this.c=!0,this.a.b;throw Y(new K)},p.jc=function(){throw this.c&&this.a.b!=null?this.a.b=null:this.b&&this.a.a!=null&&(this.a.a=null),Y(new qa)},p.b=!1,p.c=!1;var kAn=k(Af,"Pair/1",859);A(404,1,{404:1},EUe),p.Fb=function(t){return tl(this.a,h(t,404).a)&&tl(this.c,h(t,404).c)&&tl(this.d,h(t,404).d)&&tl(this.b,h(t,404).b)},p.Hb=function(){return Aee(X(q(on,1),et,1,5,[this.a,this.c,this.d,this.b]))},p.Ib=function(){return"("+this.a+Ca+this.c+Ca+this.d+Ca+this.b+")"};var RAn=k(Af,"Quadruple",404);A(957,244,K_,hE),p.Ae=function(t,i){var a,l,f,g,m;if(ii(i,"Random Layout",1),(!t.a&&(t.a=new ze(Br,t,10,11)),t.a).i==0){On(i);return}g=h(rn(t,(twe(),zct)),21),g&&g.a!=0?f=new J9(g.a):f=new Jee,a=ce(Xe(rn(t,Fct))),m=ce(Xe(rn(t,Gct))),l=h(rn(t,Uct),119),vjt(t,f,a,m,l),On(i)};var IAn=k(Af,"RandomLayoutProvider",957);A(490,1,{}),p.Qe=function(){return new $t(this.f.i,this.f.j)},p.xe=function(t){return zUe(t,(ur(),Zc))?rn(this.f,Wct):rn(this.f,t)},p.Re=function(){return new $t(this.f.g,this.f.f)},p.Se=function(){return this.g},p.ye=function(t){return UQ(this.f,t)},p.Te=function(t){Yu(this.f,t.a),Zu(this.f,t.b)},p.Ue=function(t){x_(this.f,t.a),y_(this.f,t.b)},p.Ve=function(t){this.g=t},p.g=0;var Wct,DAn=k(r5,"ElkGraphAdapters/AbstractElkGraphElementAdapter",490);A(491,1,{741:1},mC),p.We=function(){var t,i;if(!this.b)for(this.b=Y9(uQ(this.a).i),i=new Bn(uQ(this.a));i.e!=i.i._b();)t=h(Yn(i),137),De(this.b,new pK(t));return this.b},p.b=null;var BAn=k(r5,"ElkGraphAdapters/ElkEdgeAdapter",491);A(562,490,{},dK),p.Xe=function(){return OHe(this)},p.a=null;var OAn=k(r5,"ElkGraphAdapters/ElkGraphAdapter",562);A(564,490,{271:1},pK);var NAn=k(r5,"ElkGraphAdapters/ElkLabelAdapter",564);A(563,490,{739:1},gJ),p.We=function(){return LDt(this)},p.$e=function(){var t;return t=h(rn(this.f,(ur(),dj)),135),!t&&(t=new G2),t},p.af=function(){return kDt(this)},p.cf=function(t){var i;i=new RJ(t),ac(this.f,(ur(),dj),i)},p.df=function(t){ac(this.f,(ur(),Sy),new Tme(t))},p.Ye=function(){return this.d},p.Ze=function(){var t,i;if(!this.a)for(this.a=new ke,i=Cn(S6(h(this.f,35)));Gn(i);)t=h(Tn(i),105),De(this.a,new mC(t));return this.a},p._e=function(){var t,i;if(!this.c)for(this.c=new ke,i=Cn(Th(h(this.f,35)));Gn(i);)t=h(Tn(i),105),De(this.c,new mC(t));return this.c},p.bf=function(){return N1e(h(this.f,35)).i!=0||ce(mt(h(this.f,35).xe((ur(),hj))))},p.a=null,p.b=null,p.c=null,p.d=null,p.e=null;var FAn=k(r5,"ElkGraphAdapters/ElkNodeAdapter",563);A(997,490,{740:1},qF),p.We=function(){return UDt(this)},p.Ze=function(){var t,i;if(!this.a)for(this.a=ed(h(this.f,121).Tf().i),i=new Bn(h(this.f,121).Tf());i.e!=i.i._b();)t=h(Yn(i),105),De(this.a,new mC(t));return this.a},p._e=function(){var t,i;if(!this.c)for(this.c=ed(h(this.f,121).Uf().i),i=new Bn(h(this.f,121).Uf());i.e!=i.i._b();)t=h(Yn(i),105),De(this.c,new mC(t));return this.c},p.ef=function(){return h(h(this.f,121).xe((ur(),_L)),69)},p.ff=function(){var t,i,a,l,f,g,m,v;for(l=Sh(h(this.f,121)),a=new Bn(h(this.f,121).Uf());a.e!=a.i._b();)for(t=h(Yn(a),105),v=new Bn((!t.c&&(t.c=new an(pi,t,5,8)),t.c));v.e!=v.i._b();){if(m=h(Yn(v),97),SA(Ia(m),l))return!0;if(Ia(m)==l&&ce(mt(rn(t,(ur(),iae)))))return!0}for(i=new Bn(h(this.f,121).Tf());i.e!=i.i._b();)for(t=h(Yn(i),105),g=new Bn((!t.b&&(t.b=new an(pi,t,4,7)),t.b));g.e!=g.i._b();)if(f=h(Yn(g),97),SA(Ia(f),l))return!0;return!1},p.a=null,p.b=null,p.c=null;var UAn=k(r5,"ElkGraphAdapters/ElkPortAdapter",997);A(265,23,{3:1,34:1,23:1,265:1},N8);var Ed,dm,uD,fD,Hct=Ti(uxe,"LabelSide",265,Di,p4t,MCt),qct;A(676,1,{},dE),p.td=function(t){UKe(h(t,739),!0,!1)};var zAn=k(uxe,"NodeLabelAndSizeCalculator/lambda$0$Type",676);A(571,1,{},ER),p.b=!0,p.c=!0,p.d=!0,p.e=!0;var GAn=k(uxe,MQe,571);A(171,1,{171:1}),p.j=!1,p.k=!1;var Xct=k(m1,"Cell",171);A(114,171,{114:1,171:1},w8e),p.Pf=function(){return v9(this)},p.Qf=function(){var t;return t=this.n,this.a.a+t.b+t.c};var jAn=k(m1,"AtomicCell",114);A(203,23,{3:1,34:1,23:1,203:1},YK);var aa,Wa,ca,Jw=Ti(m1,"ContainerArea",203,Di,LLt,TCt),Yct;A(307,171,Aet);var $An=k(m1,"ContainerCell",307);A(1179,307,Aet,RWe),p.Pf=function(){var t;return t=0,this.e?this.b?t=this.b.b:this.a[1][1]&&(t=this.a[1][1].Pf()):t=jbe(this,NHe(this,!0)),t>0?t+this.n.d+this.n.a:0},p.Qf=function(){var t,i,a,l,f;if(f=0,this.e)this.b?f=this.b.a:this.a[1][1]&&(f=this.a[1][1].Qf());else if(this.g)f=jbe(this,Cte(this,null,!0));else for(i=(xf(),X(q(Jw,1),Oe,203,0,[aa,Wa,ca])),a=0,l=i.length;a0?f+this.n.b+this.n.c:0},p.Rf=function(){var t,i,a,l,f;if(this.g)for(t=Cte(this,null,!1),a=(xf(),X(q(Jw,1),Oe,203,0,[aa,Wa,ca])),l=0,f=a.length;l0&&(l[0]+=this.d,a-=l[0]),l[2]>0&&(l[2]+=this.d,a-=l[2]),this.c.a=w.Math.max(0,a),this.c.d=i.d+t.d+(this.c.a-a)/2,l[1]=w.Math.max(l[1],a),w0e(this,Wa,i.d+t.d+l[0]-(l[1]-a)/2,l)},p.b=null,p.d=0,p.e=!1,p.f=!1,p.g=!1;var xae=0,Mj=0,VAn=k(m1,"GridContainerCell",1179);A(419,23,{3:1,34:1,23:1,419:1},ZK);var mb,Uh,cf,Zct=Ti(m1,"HorizontalLabelAlignment",419,Di,TLt,CCt),Kct;A(267,171,{171:1,267:1},s7e,Dje,e7e),p.Pf=function(){return zJ(this)},p.Qf=function(){return w9(this)},p.a=0,p.c=!1;var EVt=k(m1,"LabelCell",267);A(219,307,{171:1,307:1,219:1},HA),p.Pf=function(){return _6(this)},p.Qf=function(){return y6(this)},p.Rf=function(){gne(this)},p.Sf=function(){mne(this)},p.b=0,p.c=0,p.d=!1;var WAn=k(m1,"StripContainerCell",219);A(1394,1,os,Vq),p.Nb=function(t){return!!h(t,171)&&h(t,171).k};var HAn=k(m1,"StripContainerCell/lambda$0$Type",1394);A(1395,1,{},Im),p.oe=function(t){return h(t,171).Qf()};var qAn=k(m1,"StripContainerCell/lambda$1$Type",1395);A(1396,1,os,Ok),p.Nb=function(t){return!!h(t,171)&&h(t,171).j};var XAn=k(m1,"StripContainerCell/lambda$2$Type",1396);A(1397,1,{},Fv),p.oe=function(t){return h(t,171).Pf()};var YAn=k(m1,"StripContainerCell/lambda$3$Type",1397);A(420,23,{3:1,34:1,23:1,420:1},KK);var lf,bb,If,Jct=Ti(m1,"VerticalLabelAlignment",420,Di,CLt,ACt),Qct;A(697,1,{},L_e),p.c=0,p.d=0,p.k=0,p.s=0,p.u=0,p.B=!1;var ZAn=k(mz,"NodeContext",697);A(1177,1,Or,pN),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return TNe(h(t,69),h(i,69))};var KAn=k(mz,"NodeContext/0methodref$comparePortSides$Type",1177);A(1178,1,Or,$q),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return vOt(h(t,111),h(i,111))};var JAn=k(mz,"NodeContext/1methodref$comparePortContexts$Type",1178);A(147,23,{3:1,34:1,23:1,147:1},Vl);var elt,tlt,nlt,ilt,rlt,slt,olt,alt,clt,llt,ult,flt,hlt,dlt,plt,glt,mlt,blt,wlt,vlt,_lt,Eae,ylt=Ti(mz,"NodeLabelLocation",147,Di,cte,PCt),xlt;A(111,1,{111:1},Jze);var QAn=k(mz,"PortContext",111);A(1182,1,{},yp),p.oe=function(t){return h(t,111).c?w9(h(t,111).c):0};var ePn=k(JS,"HorizontalPortPlacementSizeCalculator/lambda$0$Type",1182);A(1184,1,{},Wq),p.td=function(t){DBe(h(t,267))};var tPn=k(JS,"LabelPlacer/lambda$0$Type",1184);A(1185,1,os,gN),p.Nb=function(t){return!!h(t,111).c};var nPn=k(JS,"LabelPlacer/lambda$1$Type",1185);A(1186,1,{},mN),p.td=function(t){DBe(h(t,111).c)};var iPn=k(JS,"LabelPlacer/lambda$2$Type",1186),xAe;A(1181,1,{},pE),p.td=function(t){Gm(),Kde(h(t,111))};var rPn=k(JS,"NodeLabelAndSizeUtilities/lambda$0$Type",1181);A(698,1,{},hge),p.td=function(t){iEt(this.a,this.b,t)},p.b=!1;var sPn=k(JS,"NodeLabelCellCreator/lambda$0$Type",698);A(1180,1,{},vZ),p.td=function(t){je(this.a,t)};var oPn=k(JS,"PortContextCreator/lambda$0$Type",1180),Tj;A(1183,1,{},Hb),p.oe=function(t){return h(t,111).c?zJ(h(t,111).c):0};var aPn=k(JS,"VerticalPortPlacementSizeCalculator/lambda$0$Type",1183);A(1525,1,{},bN);var cPn=k(QS,"GreedyRectangleStripOverlapRemover",1525);A(1526,1,Or,Hq),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return eMt(h(t,194),h(i,194))};var lPn=k(QS,"GreedyRectangleStripOverlapRemover/0methodref$compareByYCoordinate$Type",1526);A(1497,1,{},UDe),p.a=5,p.e=0;var uPn=k(QS,"RectangleStripOverlapRemover",1497);A(1498,1,Or,XT),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return tMt(h(t,194),h(i,194))};var fPn=k(QS,"RectangleStripOverlapRemover/0methodref$compareLeftRectangleBorders$Type",1498);A(1500,1,Or,qq),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return TAt(h(t,194),h(i,194))};var hPn=k(QS,"RectangleStripOverlapRemover/1methodref$compareRightRectangleBorders$Type",1500);A(374,23,{3:1,34:1,23:1,374:1},F8);var hD,Sae,Mae,dD,Elt=Ti(QS,"RectangleStripOverlapRemover/OverlapRemovalDirection",374,Di,h4t,LCt),Slt;A(194,1,{194:1},jJ);var dPn=k(QS,"RectangleStripOverlapRemover/RectangleNode",194);A(1499,1,{},XF),p.td=function(t){TDt(this.a,h(t,194))};var pPn=k(QS,"RectangleStripOverlapRemover/lambda$0$Type",1499),Qw=_r(Xl,"EObject"),MM=_r(iy,Pet),oh=_r(iy,Let),pD=_r(iy,ket),gD=_r(iy,"ElkShape"),pi=_r(iy,Ret),js=_r(iy,hxe),ts=_r(iy,Iet),mD=_r(Xl,Det),kL=_r(Xl,"EFactory"),Mlt,Tae=_r(Xl,Bet),ah=_r(Xl,"EPackage"),ds,Tlt,Clt,EAe,Cj,Alt,SAe,MAe,TAe,op,Plt,Llt,ea=_r(iy,dxe),Br=_r(iy,pxe),Pu=_r(iy,gxe);A(87,1,Oet),p.cg=function(){return this.dg(),null},p.dg=function(){return null},p.eg=function(){return this.dg(),!1},p.fg=function(){return!1},p.gg=function(t){Li(this,t)};var gPn=k(Hx,"BasicNotifierImpl",87);A(92,87,Fet),p.Hg=function(){return $u(this)},p.hg=function(t,i){return t},p.ig=function(){throw Y(new Pi)},p.jg=function(t){var i;return i=Uo(h(Wt(this.mg(),this.og()),17)),this.yg().Cg(this,i.n,i.f,t)},p.kg=function(t,i){throw Y(new Pi)},p.lg=function(t,i,a){return Ml(this,t,i,a)},p.mg=function(){var t;return this.ig()&&(t=this.ig().pj(),t)?t:this.Rg()},p.ng=function(){return Xte(this)},p.og=function(){throw Y(new Pi)},p.pg=function(){var t,i;return i=this.Jg().qj(),!i&&this.ig().vj(i=(LC(),t=z1e(Jg(this.mg())),t==null?Dae:new eI(this,t))),i},p.qg=function(t,i){return t},p.rg=function(t){var i;return i=t.Vi(),i?t.pi():br(this.mg(),t)},p.sg=function(){var t;return t=this.ig(),t?t.sj():null},p.tg=function(){return this.ig()?this.ig().pj():null},p.ug=function(t,i,a){return t7(this,t,i,a)},p.vg=function(t){return AI(this,t)},p.wg=function(t,i){return m0e(this,t,i)},p.xg=function(){var t;return t=this.ig(),!!t&&t.tj()},p.yg=function(){throw Y(new Pi)},p.zg=function(){return ZU(this)},p.Ag=function(t,i,a,l){return yx(this,t,i,l)},p.Bg=function(t,i,a){var l;return l=h(Wt(this.mg(),i),61),l.aj().dj(this,this.Qg(),i-this.Sg(),t,a)},p.Cg=function(t,i,a,l){return j9(this,t,i,l)},p.Dg=function(t,i,a){var l;return l=h(Wt(this.mg(),i),61),l.aj().ej(this,this.Qg(),i-this.Sg(),t,a)},p.Eg=function(){return!!this.ig()&&(this.ig().rj(),!1)},p.Fg=function(t){return fte(this,t)},p.Gg=function(t){var i;return i=this.rg(t),i>=0?this.Fg(i):Vte(this,t)},p.Ig=function(t){return wKe(this,t)},p.Jg=function(){throw Y(new Pi)},p.Kg=function(){return this.ig()?this.ig().rj():null},p.Lg=function(){return ZU(this)},p.Mg=function(t,i){b7(this,t,i)},p.Ng=function(t){this.Jg().uj(t)},p.Og=function(t){this.Jg().wj(t)},p.Pg=function(t,i){var a,l,f,g;return g=this.sg(),g&&t&&(i=Us(g.fk(),this,i),g.jk(this)),l=this.yg(),l&&(ane(this,this.yg(),this.og()).Bb&oo?(f=l.zg(),f&&(t?!g&&f.jk(this):f.ik(this))):(i=(a=this.og(),a>=0?this.jg(i):this.yg().Cg(this,-1-a,null,i)),i=this.lg(null,-1,i))),this.Og(t),i},p.Qg=function(){return B0e(this)},p.Rg=function(){return(kg(),Ct).S},p.Sg=function(){return jn(this.Rg())},p.Ib=function(){return Ku(this)};var mPn=k(Lt,"BasicEObjectImpl",92),klt;A(107,92,{95:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1}),p.Tg=function(t){var i;return i=D0e(this),i[t]},p.Ug=function(t,i){var a;a=D0e(this),Gr(a,t,i)},p.Vg=function(t){var i;i=D0e(this),Gr(i,t,null)},p.cg=function(){return h(sn(this,4),116)},p.dg=function(){throw Y(new Pi)},p.eg=function(){return(this.Db&4)!=0},p.ig=function(){throw Y(new Pi)},p.Wg=function(t){VA(this,2,t)},p.kg=function(t,i){this.Db=i<<16|this.Db&255,this.Wg(t)},p.mg=function(){return sc(this)},p.og=function(){return this.Db>>16},p.pg=function(){var t,i;return LC(),i=z1e(Jg((t=h(sn(this,16),24),t||this.Rg()))),i==null?Dae:new eI(this,i)},p.fg=function(){return(this.Db&1)==0},p.sg=function(){return h(sn(this,128),1628)},p.tg=function(){return h(sn(this,16),24)},p.xg=function(){return(this.Db&32)!=0},p.yg=function(){return h(sn(this,2),42)},p.Eg=function(){return(this.Db&64)!=0},p.Jg=function(){throw Y(new Pi)},p.Kg=function(){return h(sn(this,64),261)},p.Ng=function(t){VA(this,16,t)},p.Og=function(t){VA(this,128,t)},p.Qg=function(){return Ya(this)},p.Db=0;var bPn=k(Lt,"MinimalEObjectImpl",107);A(108,107,{95:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1}),p.Wg=function(t){this.Cb=t},p.yg=function(){return this.Cb};var wPn=k(Lt,"MinimalEObjectImpl/Container",108);A(1676,108,{95:1,379:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1}),p.ve=function(t){return!this.o&&(this.o=new il((Ta(),op),pm,this,0)),l$e(this.o,t.p?t.p:(_t(),_t(),ep)),this},p.ug=function(t,i,a){return Mwe(this,t,i,a)},p.Dg=function(t,i,a){return sve(this,t,i,a)},p.Fg=function(t){return q1e(this,t)},p.Mg=function(t,i){xbe(this,t,i)},p.Rg=function(){return Ta(),Llt},p.we=function(){return cHe(this)},p.xe=function(t){return rn(this,t)},p.ye=function(t){return UQ(this,t)},p.ze=function(t,i){return ac(this,t,i)};var vPn=k(b1,"EMapPropertyHolderImpl",1676);A(502,108,{95:1,531:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1},gE),p.ug=function(t,i,a){switch(t){case 0:return this.a;case 1:return this.b}return t7(this,t,i,a)},p.Fg=function(t){switch(t){case 0:return this.a!=0;case 1:return this.b!=0}return fte(this,t)},p.Mg=function(t,i){switch(t){case 0:see(this,ce(Xe(i)));return;case 1:oee(this,ce(Xe(i)));return}b7(this,t,i)},p.Rg=function(){return Ta(),Tlt},p.Ib=function(){var t;return this.Db&64?Ku(this):(t=new su(Ku(this)),t.a+=" (x: ",Xv(t,this.a),t.a+=", y: ",Xv(t,this.b),t.a+=")",t.a)},p.a=0,p.b=0;var _Pn=k(b1,"ElkBendPointImpl",502);A(651,1676,{95:1,379:1,253:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1}),p.ug=function(t,i,a){return Nbe(this,t,i,a)},p.Bg=function(t,i,a){return Dte(this,t,i,a)},p.Dg=function(t,i,a){return Mee(this,t,i,a)},p.Fg=function(t){return fbe(this,t)},p.Mg=function(t,i){jwe(this,t,i)},p.Rg=function(){return Ta(),Alt},p.Vf=function(){return uQ(this)},p.Ib=function(){return Xee(this)},p.k=null;var yPn=k(b1,"ElkGraphElementImpl",651);A(652,651,{95:1,379:1,253:1,429:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1}),p.ug=function(t,i,a){return Hbe(this,t,i,a)},p.Fg=function(t){return Kbe(this,t)},p.Mg=function(t,i){$we(this,t,i)},p.Rg=function(){return Ta(),Plt},p.Wf=function(){return this.f},p.Xf=function(){return this.g},p.Yf=function(){return this.i},p.Zf=function(){return this.j},p.$f=function(t,i){W8(this,t,i)},p._f=function(t,i){Od(this,t,i)},p.ag=function(t){Yu(this,t)},p.bg=function(t){Zu(this,t)},p.Ib=function(){return Ote(this)},p.f=0,p.g=0,p.i=0,p.j=0;var xPn=k(b1,"ElkShapeImpl",652);A(653,652,{95:1,379:1,97:1,253:1,429:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1}),p.ug=function(t,i,a){return bwe(this,t,i,a)},p.Bg=function(t,i,a){return Nwe(this,t,i,a)},p.Dg=function(t,i,a){return Fwe(this,t,i,a)},p.Fg=function(t){return _be(this,t)},p.Mg=function(t,i){Ive(this,t,i)},p.Rg=function(){return Ta(),Clt},p.Tf=function(){return!this.d&&(this.d=new an(js,this,8,5)),this.d},p.Uf=function(){return!this.e&&(this.e=new an(js,this,7,4)),this.e};var EPn=k(b1,"ElkConnectableShapeImpl",653);A(183,651,{95:1,379:1,105:1,253:1,183:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1},YT),p.jg=function(t){return kwe(this,t)},p.ug=function(t,i,a){switch(t){case 3:return V9(this);case 4:return!this.b&&(this.b=new an(pi,this,4,7)),this.b;case 5:return!this.c&&(this.c=new an(pi,this,5,8)),this.c;case 6:return!this.a&&(this.a=new ze(ts,this,6,6)),this.a;case 7:return vt(),!this.b&&(this.b=new an(pi,this,4,7)),!(this.b.i<=1&&(!this.c&&(this.c=new an(pi,this,5,8)),this.c.i<=1));case 8:return vt(),!!rP(this);case 9:return vt(),!!G0(this);case 10:return vt(),!this.b&&(this.b=new an(pi,this,4,7)),this.b.i!=0&&(!this.c&&(this.c=new an(pi,this,5,8)),this.c.i!=0)}return Nbe(this,t,i,a)},p.Bg=function(t,i,a){var l;switch(i){case 3:return this.Cb&&(a=(l=this.Db>>16,l>=0?kwe(this,a):this.Cb.Cg(this,-1-l,null,a))),nme(this,h(t,35),a);case 4:return!this.b&&(this.b=new an(pi,this,4,7)),ja(this.b,t,a);case 5:return!this.c&&(this.c=new an(pi,this,5,8)),ja(this.c,t,a);case 6:return!this.a&&(this.a=new ze(ts,this,6,6)),ja(this.a,t,a)}return Dte(this,t,i,a)},p.Dg=function(t,i,a){switch(i){case 3:return nme(this,null,a);case 4:return!this.b&&(this.b=new an(pi,this,4,7)),Us(this.b,t,a);case 5:return!this.c&&(this.c=new an(pi,this,5,8)),Us(this.c,t,a);case 6:return!this.a&&(this.a=new ze(ts,this,6,6)),Us(this.a,t,a)}return Mee(this,t,i,a)},p.Fg=function(t){switch(t){case 3:return!!V9(this);case 4:return!!this.b&&this.b.i!=0;case 5:return!!this.c&&this.c.i!=0;case 6:return!!this.a&&this.a.i!=0;case 7:return!this.b&&(this.b=new an(pi,this,4,7)),!(this.b.i<=1&&(!this.c&&(this.c=new an(pi,this,5,8)),this.c.i<=1));case 8:return rP(this);case 9:return G0(this);case 10:return!this.b&&(this.b=new an(pi,this,4,7)),this.b.i!=0&&(!this.c&&(this.c=new an(pi,this,5,8)),this.c.i!=0)}return fbe(this,t)},p.Mg=function(t,i){switch(t){case 3:SYe(this,h(i,35));return;case 4:!this.b&&(this.b=new an(pi,this,4,7)),Pr(this.b),!this.b&&(this.b=new an(pi,this,4,7)),Mr(this.b,h(i,13));return;case 5:!this.c&&(this.c=new an(pi,this,5,8)),Pr(this.c),!this.c&&(this.c=new an(pi,this,5,8)),Mr(this.c,h(i,13));return;case 6:!this.a&&(this.a=new ze(ts,this,6,6)),Pr(this.a),!this.a&&(this.a=new ze(ts,this,6,6)),Mr(this.a,h(i,13));return}jwe(this,t,i)},p.Rg=function(){return Ta(),EAe},p.Ib=function(){return uKe(this)};var SPn=k(b1,"ElkEdgeImpl",183);A(405,1676,{95:1,379:1,270:1,405:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1},mE),p.jg=function(t){return Awe(this,t)},p.ug=function(t,i,a){switch(t){case 1:return this.j;case 2:return this.k;case 3:return this.b;case 4:return this.c;case 5:return!this.a&&(this.a=new vs(oh,this,5)),this.a;case 6:return g7e(this);case 7:return i?mte(this):this.i;case 8:return i?gte(this):this.f;case 9:return!this.g&&(this.g=new an(ts,this,9,10)),this.g;case 10:return!this.e&&(this.e=new an(ts,this,10,9)),this.e;case 11:return this.d}return Mwe(this,t,i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 6:return this.Cb&&(a=(f=this.Db>>16,f>=0?Awe(this,a):this.Cb.Cg(this,-1-f,null,a))),ime(this,h(t,105),a);case 9:return!this.g&&(this.g=new an(ts,this,9,10)),ja(this.g,t,a);case 10:return!this.e&&(this.e=new an(ts,this,10,9)),ja(this.e,t,a)}return g=h(Wt((l=h(sn(this,16),24),l||(Ta(),Cj)),i),61),g.aj().dj(this,Ya(this),i-jn((Ta(),Cj)),t,a)},p.Dg=function(t,i,a){switch(i){case 5:return!this.a&&(this.a=new vs(oh,this,5)),Us(this.a,t,a);case 6:return ime(this,null,a);case 9:return!this.g&&(this.g=new an(ts,this,9,10)),Us(this.g,t,a);case 10:return!this.e&&(this.e=new an(ts,this,10,9)),Us(this.e,t,a)}return sve(this,t,i,a)},p.Fg=function(t){switch(t){case 1:return this.j!=0;case 2:return this.k!=0;case 3:return this.b!=0;case 4:return this.c!=0;case 5:return!!this.a&&this.a.i!=0;case 6:return!!g7e(this);case 7:return!!this.i;case 8:return!!this.f;case 9:return!!this.g&&this.g.i!=0;case 10:return!!this.e&&this.e.i!=0;case 11:return this.d!=null}return q1e(this,t)},p.Mg=function(t,i){switch(t){case 1:AA(this,ce(Xe(i)));return;case 2:PA(this,ce(Xe(i)));return;case 3:CA(this,ce(Xe(i)));return;case 4:TA(this,ce(Xe(i)));return;case 5:!this.a&&(this.a=new vs(oh,this,5)),Pr(this.a),!this.a&&(this.a=new vs(oh,this,5)),Mr(this.a,h(i,13));return;case 6:i9t(this,h(i,105));return;case 7:ebe(this,h(i,97));return;case 8:Q0e(this,h(i,97));return;case 9:!this.g&&(this.g=new an(ts,this,9,10)),Pr(this.g),!this.g&&(this.g=new an(ts,this,9,10)),Mr(this.g,h(i,13));return;case 10:!this.e&&(this.e=new an(ts,this,10,9)),Pr(this.e),!this.e&&(this.e=new an(ts,this,10,9)),Mr(this.e,h(i,13));return;case 11:u$e(this,ti(i));return}xbe(this,t,i)},p.Rg=function(){return Ta(),Cj},p.Ib=function(){return kXe(this)},p.b=0,p.c=0,p.d=null,p.j=0,p.k=0;var MPn=k(b1,"ElkEdgeSectionImpl",405);A(142,108,{95:1,91:1,87:1,139:1,51:1,103:1,42:1,92:1,142:1,107:1,108:1}),p.ug=function(t,i,a){var l;return t==0?(!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab):jl(this,t-jn(this.Rg()),Wt((l=h(sn(this,16),24),l||this.Rg()),t),i,a)},p.Bg=function(t,i,a){var l,f;return i==0?(!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),ja(this.Ab,t,a)):(f=h(Wt((l=h(sn(this,16),24),l||this.Rg()),i),61),f.aj().dj(this,Ya(this),i-jn(this.Rg()),t,a))},p.Dg=function(t,i,a){var l,f;return i==0?(!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a)):(f=h(Wt((l=h(sn(this,16),24),l||this.Rg()),i),61),f.aj().ej(this,Ya(this),i-jn(this.Rg()),t,a))},p.Fg=function(t){var i;return t==0?!!this.Ab&&this.Ab.i!=0:zl(this,t-jn(this.Rg()),Wt((i=h(sn(this,16),24),i||this.Rg()),t))},p.Ig=function(t){return D_e(this,t)},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return}Wl(this,t-jn(this.Rg()),Wt((a=h(sn(this,16),24),a||this.Rg()),t),i)},p.Og=function(t){VA(this,128,t)},p.Rg=function(){return yt(),Ylt},p.Xg=function(){this.Bb|=1},p.Yg=function(t){return uP(this,t)},p.Bb=0;var TPn=k(Lt,"EModelElementImpl",142);A(638,142,{95:1,91:1,87:1,430:1,139:1,51:1,103:1,42:1,92:1,142:1,107:1,108:1},hF),p.Zg=function(t,i){return OKe(this,t,i)},p.$g=function(t){var i,a,l,f,g;if(this.a!=$l(t)||t.Bb&256)throw Y(new un(bre+t.zb+Y0));for(l=Bo(t);Ea(l.a).i!=0;){if(a=h(B6(l,0,(i=h(ae(Ea(l.a),0),84),g=i.c,re(g,96)?h(g,24):(yt(),ff))),24),F0(a))return f=$l(a).dh().$g(a),h(f,42).Ng(t),f;l=Bo(a)}return(t.D!=null?t.D:t.B)=="java.util.Map$Entry"?new w9e(t):new Fme(t)},p._g=function(t,i){return $0(this,t,i)},p.ug=function(t,i,a){var l;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.a}return jl(this,t-jn((yt(),_b)),Wt((l=h(sn(this,16),24),l||_b),t),i,a)},p.Bg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),ja(this.Ab,t,a);case 1:return this.a&&(a=h(this.a,42).Cg(this,4,ah,a)),Rbe(this,h(t,207),a)}return f=h(Wt((l=h(sn(this,16),24),l||(yt(),_b)),i),61),f.aj().dj(this,Ya(this),i-jn((yt(),_b)),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a);case 1:return Rbe(this,null,a)}return f=h(Wt((l=h(sn(this,16),24),l||(yt(),_b)),i),61),f.aj().ej(this,Ya(this),i-jn((yt(),_b)),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return!!this.a}return zl(this,t-jn((yt(),_b)),Wt((i=h(sn(this,16),24),i||_b),t))},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:ZOt(this,h(i,207));return}Wl(this,t-jn((yt(),_b)),Wt((a=h(sn(this,16),24),a||_b),t),i)},p.Rg=function(){return yt(),_b};var RL,CAe,Rlt,CPn=k(Lt,"EFactoryImpl",638);A(914,638,{95:1,1698:1,91:1,87:1,430:1,139:1,51:1,103:1,42:1,92:1,142:1,107:1,108:1},Dm),p.Zg=function(t,i){switch(t.Ni()){case 12:return h(i,166).Lf();case 13:return Ga(i);default:throw Y(new un(eM+t.be()+Y0))}},p.$g=function(t){var i,a,l,f,g,m,v,y;switch(t.G==-1&&(t.G=(i=$l(t),i?$p(i.bh(),t):-1)),t.G){case 4:return g=new ZT,g;case 6:return m=new cpe,m;case 7:return v=new lpe,v;case 8:return l=new YT,l;case 9:return a=new gE,a;case 10:return f=new mE,f;case 11:return y=new Nk,y;default:throw Y(new un(bre+t.zb+Y0))}},p._g=function(t,i){switch(t.Ni()){case 13:case 12:return null;default:throw Y(new un(eM+t.be()+Y0))}};var APn=k(b1,"ElkGraphFactoryImpl",914);A(399,142,{95:1,91:1,87:1,139:1,174:1,51:1,103:1,42:1,92:1,142:1,107:1,108:1}),p.pg=function(){var t,i;return i=(t=h(sn(this,16),24),z1e(Jg(t||this.Rg()))),i==null?(LC(),LC(),Dae):new jFe(this,i)},p.ug=function(t,i,a){var l;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.be()}return jl(this,t-jn(this.Rg()),Wt((l=h(sn(this,16),24),l||this.Rg()),t),i,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null}return zl(this,t-jn(this.Rg()),Wt((i=h(sn(this,16),24),i||this.Rg()),t))},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:this.ah(ti(i));return}Wl(this,t-jn(this.Rg()),Wt((a=h(sn(this,16),24),a||this.Rg()),t),i)},p.Rg=function(){return yt(),Zlt},p.be=function(){return this.zb},p.ah=function(t){Sf(this,t)},p.Ib=function(){return FA(this)},p.zb=null;var PPn=k(Lt,"ENamedElementImpl",399);A(248,399,{95:1,91:1,87:1,139:1,174:1,51:1,207:1,103:1,42:1,92:1,142:1,248:1,107:1,108:1,613:1},UUe),p.jg=function(t){return VHe(this,t)},p.ug=function(t,i,a){var l;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.zb;case 2:return this.yb;case 3:return this.xb;case 4:return this.sb;case 5:return!this.rb&&(this.rb=new u_(this,ch,this)),this.rb;case 6:return!this.vb&&(this.vb=new ZE(ah,this,6,7)),this.vb;case 7:return i?this.Db>>16==7?h(this.Cb,207):null:m7e(this)}return jl(this,t-jn((yt(),k1)),Wt((l=h(sn(this,16),24),l||k1),t),i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),ja(this.Ab,t,a);case 4:return this.sb&&(a=h(this.sb,42).Cg(this,1,kL,a)),Dbe(this,h(t,430),a);case 5:return!this.rb&&(this.rb=new u_(this,ch,this)),ja(this.rb,t,a);case 6:return!this.vb&&(this.vb=new ZE(ah,this,6,7)),ja(this.vb,t,a);case 7:return this.Cb&&(a=(f=this.Db>>16,f>=0?VHe(this,a):this.Cb.Cg(this,-1-f,null,a))),Ml(this,t,7,a)}return g=h(Wt((l=h(sn(this,16),24),l||(yt(),k1)),i),61),g.aj().dj(this,Ya(this),i-jn((yt(),k1)),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a);case 4:return Dbe(this,null,a);case 5:return!this.rb&&(this.rb=new u_(this,ch,this)),Us(this.rb,t,a);case 6:return!this.vb&&(this.vb=new ZE(ah,this,6,7)),Us(this.vb,t,a);case 7:return Ml(this,null,7,a)}return f=h(Wt((l=h(sn(this,16),24),l||(yt(),k1)),i),61),f.aj().ej(this,Ya(this),i-jn((yt(),k1)),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.yb!=null;case 3:return this.xb!=null;case 4:return!!this.sb;case 5:return!!this.rb&&this.rb.i!=0;case 6:return!!this.vb&&this.vb.i!=0;case 7:return!!m7e(this)}return zl(this,t-jn((yt(),k1)),Wt((i=h(sn(this,16),24),i||k1),t))},p.Ig=function(t){var i;return i=h9t(this,t),i||D_e(this,t)},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:Sf(this,ti(i));return;case 2:gee(this,ti(i));return;case 3:pee(this,ti(i));return;case 4:ove(this,h(i,430));return;case 5:!this.rb&&(this.rb=new u_(this,ch,this)),Pr(this.rb),!this.rb&&(this.rb=new u_(this,ch,this)),Mr(this.rb,h(i,13));return;case 6:!this.vb&&(this.vb=new ZE(ah,this,6,7)),Pr(this.vb),!this.vb&&(this.vb=new ZE(ah,this,6,7)),Mr(this.vb,h(i,13));return}Wl(this,t-jn((yt(),k1)),Wt((a=h(sn(this,16),24),a||k1),t),i)},p.Rg=function(){return yt(),k1},p.Xg=function(){Tte(this)},p.bh=function(){return!this.rb&&(this.rb=new u_(this,ch,this)),this.rb},p.dh=function(){return this.sb},p.eh=function(){return this.ub},p.fh=function(){return this.xb},p.gh=function(){return this.yb},p.hh=function(t){this.ub=t},p.Ib=function(){var t;return this.Db&64?FA(this):(t=new su(FA(this)),t.a+=" (nsURI: ",ho(t,this.yb),t.a+=", nsPrefix: ",ho(t,this.xb),t.a+=")",t.a)},p.xb=null,p.yb=null;var Ilt,LPn=k(Lt,"EPackageImpl",248);A(506,248,{95:1,1702:1,506:1,91:1,87:1,139:1,174:1,51:1,207:1,103:1,42:1,92:1,142:1,248:1,107:1,108:1,613:1},HXe),p.q=!1,p.r=!1;var Dlt=!1,kPn=k(b1,"ElkGraphPackageImpl",506);A(263,652,{95:1,379:1,253:1,137:1,429:1,263:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1},ZT),p.jg=function(t){return Pwe(this,t)},p.ug=function(t,i,a){switch(t){case 7:return b7e(this);case 8:return this.a}return Hbe(this,t,i,a)},p.Bg=function(t,i,a){var l;switch(i){case 7:return this.Cb&&(a=(l=this.Db>>16,l>=0?Pwe(this,a):this.Cb.Cg(this,-1-l,null,a))),Qme(this,h(t,253),a)}return Dte(this,t,i,a)},p.Dg=function(t,i,a){return i==7?Qme(this,null,a):Mee(this,t,i,a)},p.Fg=function(t){switch(t){case 7:return!!b7e(this);case 8:return!dt("",this.a)}return Kbe(this,t)},p.Mg=function(t,i){switch(t){case 7:kYe(this,h(i,253));return;case 8:i$e(this,ti(i));return}$we(this,t,i)},p.Rg=function(){return Ta(),SAe},p.Ib=function(){return Oqe(this)},p.a="";var RPn=k(b1,"ElkLabelImpl",263);A(246,653,{95:1,379:1,97:1,253:1,35:1,429:1,246:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1},cpe),p.jg=function(t){return Dwe(this,t)},p.ug=function(t,i,a){switch(t){case 9:return!this.c&&(this.c=new ze(Pu,this,9,9)),this.c;case 10:return!this.a&&(this.a=new ze(Br,this,10,11)),this.a;case 11:return eo(this);case 12:return!this.b&&(this.b=new ze(js,this,12,3)),this.b;case 13:return vt(),!this.a&&(this.a=new ze(Br,this,10,11)),this.a.i>0}return bwe(this,t,i,a)},p.Bg=function(t,i,a){var l;switch(i){case 9:return!this.c&&(this.c=new ze(Pu,this,9,9)),ja(this.c,t,a);case 10:return!this.a&&(this.a=new ze(Br,this,10,11)),ja(this.a,t,a);case 11:return this.Cb&&(a=(l=this.Db>>16,l>=0?Dwe(this,a):this.Cb.Cg(this,-1-l,null,a))),hme(this,h(t,35),a);case 12:return!this.b&&(this.b=new ze(js,this,12,3)),ja(this.b,t,a)}return Nwe(this,t,i,a)},p.Dg=function(t,i,a){switch(i){case 9:return!this.c&&(this.c=new ze(Pu,this,9,9)),Us(this.c,t,a);case 10:return!this.a&&(this.a=new ze(Br,this,10,11)),Us(this.a,t,a);case 11:return hme(this,null,a);case 12:return!this.b&&(this.b=new ze(js,this,12,3)),Us(this.b,t,a)}return Fwe(this,t,i,a)},p.Fg=function(t){switch(t){case 9:return!!this.c&&this.c.i!=0;case 10:return!!this.a&&this.a.i!=0;case 11:return!!eo(this);case 12:return!!this.b&&this.b.i!=0;case 13:return!this.a&&(this.a=new ze(Br,this,10,11)),this.a.i>0}return _be(this,t)},p.Mg=function(t,i){switch(t){case 9:!this.c&&(this.c=new ze(Pu,this,9,9)),Pr(this.c),!this.c&&(this.c=new ze(Pu,this,9,9)),Mr(this.c,h(i,13));return;case 10:!this.a&&(this.a=new ze(Br,this,10,11)),Pr(this.a),!this.a&&(this.a=new ze(Br,this,10,11)),Mr(this.a,h(i,13));return;case 11:TYe(this,h(i,35));return;case 12:!this.b&&(this.b=new ze(js,this,12,3)),Pr(this.b),!this.b&&(this.b=new ze(js,this,12,3)),Mr(this.b,h(i,13));return}Ive(this,t,i)},p.Rg=function(){return Ta(),MAe},p.Ib=function(){return s_e(this)};var IPn=k(b1,"ElkNodeImpl",246);A(187,653,{95:1,379:1,97:1,253:1,121:1,429:1,187:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1},lpe),p.jg=function(t){return Lwe(this,t)},p.ug=function(t,i,a){return t==9?Sh(this):bwe(this,t,i,a)},p.Bg=function(t,i,a){var l;switch(i){case 9:return this.Cb&&(a=(l=this.Db>>16,l>=0?Lwe(this,a):this.Cb.Cg(this,-1-l,null,a))),rme(this,h(t,35),a)}return Nwe(this,t,i,a)},p.Dg=function(t,i,a){return i==9?rme(this,null,a):Fwe(this,t,i,a)},p.Fg=function(t){return t==9?!!Sh(this):_be(this,t)},p.Mg=function(t,i){switch(t){case 9:MYe(this,h(i,35));return}Ive(this,t,i)},p.Rg=function(){return Ta(),TAe},p.Ib=function(){return vZe(this)};var DPn=k(b1,"ElkPortImpl",187),Blt=_r(Gs,"BasicEMap/Entry");A(966,108,{95:1,38:1,91:1,87:1,134:1,51:1,103:1,42:1,92:1,107:1,108:1},Nk),p.Fb=function(t){return this===t},p.kc=function(){return this.b},p.Hb=function(){return m0(this)},p.kh=function(t){n$e(this,h(t,166))},p.ug=function(t,i,a){switch(t){case 0:return this.b;case 1:return this.c}return t7(this,t,i,a)},p.Fg=function(t){switch(t){case 0:return!!this.b;case 1:return this.c!=null}return fte(this,t)},p.Mg=function(t,i){switch(t){case 0:n$e(this,h(i,166));return;case 1:t$e(this,i);return}b7(this,t,i)},p.Rg=function(){return Ta(),op},p.ih=function(){var t;return this.a==-1&&(t=this.b,this.a=t?Hr(t):0),this.a},p.lc=function(){return this.c},p.jh=function(t){this.a=t},p.mc=function(t){var i;return i=this.c,t$e(this,t),i},p.Ib=function(){var t;return this.Db&64?Ku(this):(t=new h0,Mi(Mi(Mi(t,this.b?this.b.Lf():Xc)," -> "),YC(this.c)),t.a)},p.a=-1,p.c=null;var pm=k(b1,"ElkPropertyToValueMapEntryImpl",966);A(876,1,{},Xq);var BPn=k(Ps,"JsonAdapter",876);A(186,54,Zd,_h);var OPn=k(Ps,"JsonImportException",186);A(754,1,{},iqe);var NPn=k(Ps,"JsonImporter",754);A(792,1,{},tNe);var FPn=k(Ps,"JsonImporter/lambda$0$Type",792);A(793,1,{},nNe);var UPn=k(Ps,"JsonImporter/lambda$1$Type",793);A(816,1,{},YF);var zPn=k(Ps,"JsonImporter/lambda$10$Type",816);A(818,1,{},_Z);var GPn=k(Ps,"JsonImporter/lambda$11$Type",818);A(819,1,{},iNe),p.td=function(t){E4t(this.b,this.a,t)};var jPn=k(Ps,"JsonImporter/lambda$12$Type",819);A(820,1,{},rNe);var $Pn=k(Ps,"JsonImporter/lambda$13$Type",820);A(821,1,{},sNe);var VPn=k(Ps,"JsonImporter/lambda$14$Type",821);A(822,1,{},yZ);var WPn=k(Ps,"JsonImporter/lambda$15$Type",822);A(823,1,{},xZ);var HPn=k(Ps,"JsonImporter/lambda$16$Type",823);A(824,1,{},EZ);var qPn=k(Ps,"JsonImporter/lambda$17$Type",824);A(825,1,{},O2);var XPn=k(Ps,"JsonImporter/lambda$18$Type",825);A(756,1,{},SZ);var YPn=k(Ps,"JsonImporter/lambda$19$Type",756);A(794,1,{},MZ);var ZPn=k(Ps,"JsonImporter/lambda$2$Type",794);A(829,1,{},q8e);var KPn=k(Ps,"JsonImporter/lambda$20$Type",829);A(830,1,{},TZ),p.td=function(t){S4t(this.a,t)};var JPn=k(Ps,"JsonImporter/lambda$21$Type",830);A(795,1,{},CZ);var QPn=k(Ps,"JsonImporter/lambda$22$Type",795);A(796,1,{},AZ);var eLn=k(Ps,"JsonImporter/lambda$23$Type",796);A(798,1,{},ZF);var tLn=k(Ps,"JsonImporter/lambda$24$Type",798);A(799,1,{},KF);var nLn=k(Ps,"JsonImporter/lambda$25$Type",799);A(801,1,{},PZ);var iLn=k(Ps,"JsonImporter/lambda$26$Type",801);A(809,1,{},CUe);var rLn=k(Ps,"JsonImporter/lambda$27$Type",809);A(811,1,{},LZ);var sLn=k(Ps,"JsonImporter/lambda$28$Type",811);A(812,1,{},kZ);var oLn=k(Ps,"JsonImporter/lambda$29$Type",812);A(797,1,{},RZ);var aLn=k(Ps,"JsonImporter/lambda$3$Type",797);A(814,1,{},IZ);var cLn=k(Ps,"JsonImporter/lambda$30$Type",814);A(815,1,{},DZ);var lLn=k(Ps,"JsonImporter/lambda$31$Type",815);A(817,1,{},BZ);var uLn=k(Ps,"JsonImporter/lambda$32$Type",817);A(826,1,{},OZ),p.td=function(t){M4t(this.a,t)};var fLn=k(Ps,"JsonImporter/lambda$33$Type",826);A(827,1,{},oNe),p.td=function(t){tSt(this.a,this.b,t)};var hLn=k(Ps,"JsonImporter/lambda$34$Type",827);A(828,1,{},aNe),p.td=function(t){nSt(this.a,this.b,t)};var dLn=k(Ps,"JsonImporter/lambda$35$Type",828);A(805,1,{},cNe);var pLn=k(Ps,"JsonImporter/lambda$36$Type",805);A(806,1,{},lNe);var gLn=k(Ps,"JsonImporter/lambda$37$Type",806);A(807,1,{},hNe);var mLn=k(Ps,"JsonImporter/lambda$38$Type",807);A(808,1,{},dNe);var bLn=k(Ps,"JsonImporter/lambda$39$Type",808);A(800,1,{},NZ);var wLn=k(Ps,"JsonImporter/lambda$4$Type",800);A(802,1,{},FZ);var vLn=k(Ps,"JsonImporter/lambda$5$Type",802);A(803,1,{},uNe);var _Ln=k(Ps,"JsonImporter/lambda$6$Type",803);A(804,1,{},fNe);var yLn=k(Ps,"JsonImporter/lambda$7$Type",804);A(810,1,{},AUe);var xLn=k(Ps,"JsonImporter/lambda$8$Type",810);A(813,1,{},UZ);var ELn=k(Ps,"JsonImporter/lambda$9$Type",813);A(864,1,{},zZ),p.td=function(t){ox(this.a,new rx(ti(t)))};var SLn=k(Ps,"JsonMetaDataConverter/lambda$0$Type",864);A(865,1,{},GZ),p.td=function(t){XAt(this.a,t)};var MLn=k(Ps,"JsonMetaDataConverter/lambda$1$Type",865);A(866,1,{},jZ),p.td=function(t){sLt(this.a,t)};var TLn=k(Ps,"JsonMetaDataConverter/lambda$2$Type",866);A(867,1,{},$Z),p.td=function(t){qAt(this.a,t)};var CLn=k(Ps,"JsonMetaDataConverter/lambda$3$Type",867);A(229,23,{3:1,34:1,23:1,229:1},Q2);var Aj,Pj,Cae,Lj,kj,Rj,Aae,Pae,Ij=Ti(q6,"GraphFeature",229,Di,rRt,kCt),Olt;A(16,1,{34:1,166:1},Sr,Zr,ln,wa),p.vd=function(t){return BSt(this,h(t,166))},p.Fb=function(t){return zUe(this,t)},p.Of=function(){return qt(this)},p.Lf=function(){return this.b},p.Hb=function(){return Hg(this.b)},p.Ib=function(){return this.b};var ALn=k(q6,"Property",16);A(727,1,Or,JF),p.Ld=function(t,i){return f6t(this,h(t,93),h(i,93))},p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)};var PLn=k(q6,"PropertyHolderComparator",727),AAe=_r(Gs,"EList");A(59,41,{20:1,25:1,41:1,13:1,15:1,59:1,52:1}),p.bd=function(t,i){JI(this,t,i)},p.nc=function(t){return $n(this,t)},p.oc=function(t){return Mr(this,t)},p.oh=function(){return new nx(this)},p.ph=function(){return new QR(this)},p.qh=function(t){return GI(this,t)},p.rh=function(){return!0},p.sh=function(t,i){},p.th=function(){},p.uh=function(t,i){GQ(this,t,i)},p.vh=function(t,i){},p.wh=function(t,i,a){},p.Fb=function(t){return iZe(this,t)},p.Hb=function(){return pbe(this)},p.xh=function(){return!1},p.tc=function(){return new Bn(this)},p.ed=function(){return new QC(this)},p.fd=function(t){var i;if(i=this._b(),t<0||t>i)throw Y(new o_(t,i));return new KJ(this,t)},p.vc=function(t){return JQ(this,t)},p.zh=function(t,i){return i},p.hd=function(t,i){return xx(this,t,i)},p.Ib=function(){return Xbe(this)},p.Bh=function(){return!0},p.Ch=function(t,i){return DA(this,i)};var LLn=k(Gs,"AbstractEList",59);A(55,59,Ih,r0,w_,cbe),p.lh=function(t){return kHe(this,t)},p.mh=function(t,i){e6(this,t,i)},p.nh=function(t){MI(this,t)},p.Dh=function(t){return P0e(this,t)},p.Pb=function(){_A(this)},p.pc=function(t){return QA(this,t)},p.cd=function(t){return ae(this,t)},p.Eh=function(t){eHe(this,t)},p.dd=function(t){return $He(this,t)},p.Wb=function(){return this.i==0},p.Fh=function(t){return le(on,et,1,t,5,1)},p.yh=function(t){return this.g[t]},p.gd=function(t){return Ex(this,t)},p.Ah=function(t,i){return KQ(this,t,i)},p._b=function(){return this.i},p.yc=function(){return K1e(this)},p.zc=function(t){return ewe(this,t)},p.i=0;var PAe=k(Gs,"BasicEList",55),LAe=_r(Gs,"TreeIterator");A(629,55,Tre),p.gc=function(t){Ss(this,t)},p.hc=function(){return this.g==null&&!this.c?P1e(this):this.g==null||this.i!=0&&h(this.g[this.i-1],43).hc()},p.ic=function(){return _7(this)},p.jc=function(){if(!this.e)throw Y(new ba("There is no valid object to remove."));this.e.jc()},p.c=!1;var kLn=k(Gs,"AbstractTreeIterator",629);A(621,629,Tre,_ge),p.Gh=function(t){var i;return i=h(t,51).pg().tc(),re(i,260)&&h(i,260).Zj(new wN),i};var RLn=k(Cre,"ElkGraphUtil/PropertiesSkippingTreeIterator",621);A(868,1,{},wN);var ILn=k(Cre,"ElkGraphUtil/PropertiesSkippingTreeIterator/1",868),bD,Lae,wD=k(Cre,"ElkReflect",null);A(784,1,ny,KT),p.Nf=function(t){return tU(),akt(h(t,185))};var DLn=k(Cre,"ElkReflect/lambda$0$Type",784),ev,BLn=_r(Gs,"ResourceLocator");A(953,1,{});var OLn=k(Gs,"DelegatingResourceLocator",953);A(954,953,{});var NLn=k("org.eclipse.emf.common","EMFPlugin",954),kae=_r(btt,"Adapter"),SVt=_r(btt,"Notification");A(1016,1,Bxe),p.Hh=function(){return this.d},p.Ih=function(t){},p.Jh=function(t){this.d=t},p.Kh=function(t){this.d==t&&(this.d=null)},p.d=null;var FLn=k(Hx,"AdapterImpl",1016);A(1688,59,wtt),p.lh=function(t){var i,a,l;if(++this.j,t.Wb())return!1;for(i=this.hi(),l=t.tc();l.hc();)a=l.ic(),this.Wh(this.Ch(i,a)),++i;return!0},p.mh=function(t,i){t8e(this,t,i)},p.nh=function(t){iUe(this,t)},p.Uh=function(){return this.Xh()},p.Pb=function(){rI(this,this.hi(),this.ii())},p.pc=function(t){return this.Zh(t)},p.qc=function(t){return this.$h(t)},p.Vh=function(t,i){this.ei().tl()},p.Wh=function(t){this.ei().tl()},p.Xh=function(){return this.ei()},p.Yh=function(){this.ei().tl()},p.Zh=function(t){return this.ei().tl()},p.$h=function(t){return this.ei().tl()},p._h=function(t){return this.ei().tl()},p.ai=function(t){return this.ei().tl()},p.bi=function(){return this.ei().tl()},p.ci=function(t){return this.ei().tl()},p.di=function(){return this.ei().tl()},p.fi=function(t){return this.ei().tl()},p.gi=function(t,i){return this.ei().tl()},p.hi=function(){return this.ei().tl()},p.ii=function(){return this.ei().tl()},p.ji=function(t){return this.ei().tl()},p.ki=function(){return this.ei().tl()},p.Fb=function(t){return this._h(t)},p.cd=function(t){return this.zh(t,this.ai(t))},p.Hb=function(){return this.bi()},p.dd=function(t){return this.ci(t)},p.Wb=function(){return this.di()},p.yh=function(t){return this.ai(t)},p.gd=function(t){return x9(this,t)},p.vc=function(t){var i;return i=this.dd(t),i>=0?(this.gd(i),!0):!1},p.Ah=function(t,i){return this.gi(t,this.Ch(t,i))},p._b=function(){return this.hi()},p.yc=function(){return this.ii()},p.zc=function(t){return this.ji(t)},p.Ib=function(){return this.ki()};var ULn=k(Gs,"DelegatingEList",1688);A(1689,1688,wtt),p.li=function(t,i){return m_e(this,t,i)},p.lh=function(t){return this.li(this.hi(),t)},p.mh=function(t,i){qXe(this,t,i)},p.nh=function(t){UXe(this,t)},p.rh=function(){return!this.qi()},p.Pb=function(){O7(this)},p.mi=function(t,i,a,l,f){return new YUe(this,t,i,a,l,f)},p.ni=function(t){Li(this.Oh(),t)},p.oi=function(){return null},p.pi=function(){return-1},p.Oh=function(){return null},p.qi=function(){return!1},p.ri=function(t,i){return i},p.si=function(t,i){return i},p.ti=function(){return!1},p.ui=function(){return!this.di()},p.gd=function(t){var i,a,l,f;return this.ti()?(l=this.ui(),i=this.mi(4,f=x9(this,t),null,t,l),this.qi()&&f?(a=this.si(f,null),a?(a.Sh(i),a.Th()):this.ni(i)):this.ni(i),f):(f=x9(this,t),this.qi()&&f&&(a=this.si(f,null),a&&a.Th()),f)},p.Ah=function(t,i){return UZe(this,t,i)};var zLn=k(Hx,"DelegatingNotifyingListImpl",1689);A(136,1,o5),p.Sh=function(t){return Hwe(this,t)},p.Th=function(){XQ(this)},p.Lh=function(){return this.d},p.oi=function(){return null},p.vi=function(){return null},p.Mh=function(t){return-1},p.Nh=function(){return BYe(this)},p.Oh=function(){return null},p.Ph=function(){return Wve(this)},p.Qh=function(){return this.o<0?this.o<-2?-2-this.o-1:-1:this.o},p.wi=function(){return!1},p.Rh=function(t){var i,a,l,f,g,m,v,y,E,C,R;switch(this.d){case 1:case 2:switch(f=t.Lh(),f){case 1:case 2:if(g=t.Oh(),Be(g)===Be(this.Oh())&&this.Mh(null)==t.Mh(null))return this.g=t.Nh(),t.Lh()==1&&(this.d=1),!0}case 4:{switch(f=t.Lh(),f){case 4:{if(g=t.Oh(),Be(g)===Be(this.Oh())&&this.Mh(null)==t.Mh(null))return E=P_e(this),y=this.o<0?this.o<-2?-2-this.o-1:-1:this.o,m=t.Qh(),this.d=6,R=new w_(2),y<=m?($n(R,this.n),$n(R,t.Ph()),this.g=X(q(In,1),si,22,15,[this.o=y,m+1])):($n(R,t.Ph()),$n(R,this.n),this.g=X(q(In,1),si,22,15,[this.o=m,y])),this.n=R,E||(this.o=-2-this.o-1),!0;break}}break}case 6:{switch(f=t.Lh(),f){case 4:{if(g=t.Oh(),Be(g)===Be(this.Oh())&&this.Mh(null)==t.Mh(null)){for(E=P_e(this),m=t.Qh(),C=h(this.g,37),l=le(In,si,22,C.length+1,15,1),i=0;i>>0).toString(16)),a.a+=" (eventType: ",this.d){case 1:{a.a+="SET";break}case 2:{a.a+="UNSET";break}case 3:{a.a+="ADD";break}case 5:{a.a+="ADD_MANY";break}case 4:{a.a+="REMOVE";break}case 6:{a.a+="REMOVE_MANY";break}case 7:{a.a+="MOVE";break}case 8:{a.a+="REMOVING_ADAPTER";break}case 9:{a.a+="RESOLVE";break}default:{wK(a,this.d);break}}if(MZe(this)&&(a.a+=", touch: true"),a.a+=", position: ",wK(a,this.o<0?this.o<-2?-2-this.o-1:-1:this.o),a.a+=", notifier: ",OC(a,this.Oh()),a.a+=", feature: ",OC(a,this.oi()),a.a+=", oldValue: ",OC(a,Wve(this)),a.a+=", newValue: ",this.d==6&&re(this.g,37)){for(i=h(this.g,37),a.a+="[",t=0;t10?((!this.b||this.c.j!=this.a)&&(this.b=new hI(this),this.a=this.j),IC(this.b,t)):QA(this,t)},p.Bh=function(){return!0},p.a=0;var qLn=k(Gs,"AbstractEList/1",869);A(295,79,lie,o_);var XLn=k(Gs,"AbstractEList/BasicIndexOutOfBoundsException",295);A(36,1,ys,Bn),p.gc=function(t){Ss(this,t)},p.Bi=function(){if(this.i.j!=this.f)throw Y(new P)},p.Ci=function(){return Yn(this)},p.hc=function(){return this.e!=this.i._b()},p.ic=function(){return this.Ci()},p.jc=function(){KA(this)},p.e=0,p.f=0,p.g=-1;var YLn=k(Gs,"AbstractEList/EIterator",36);A(296,36,Ch,QC,KJ),p.jc=function(){KA(this)},p.Bc=function(t){MWe(this,t)},p.Di=function(){var t;try{return t=this.d.cd(--this.e),this.Bi(),this.g=this.e,t}catch(i){throw i=pr(i),re(i,79)?(this.Bi(),Y(new K)):Y(i)}},p.Ei=function(t){xHe(this,t)},p.Cc=function(){return this.e!=0},p.Dc=function(){return this.e},p.Ec=function(){return this.Di()},p.Fc=function(){return this.e-1},p.Gc=function(t){this.Ei(t)};var ZLn=k(Gs,"AbstractEList/EListIterator",296);A(324,36,ys,nx),p.Ci=function(){return ate(this)},p.jc=function(){throw Y(new Pi)};var KLn=k(Gs,"AbstractEList/NonResolvingEIterator",324);A(355,296,Ch,QR,Sme),p.Bc=function(t){throw Y(new Pi)},p.Ci=function(){var t;try{return t=this.c.yh(this.e),this.Bi(),this.g=this.e++,t}catch(i){throw i=pr(i),re(i,79)?(this.Bi(),Y(new K)):Y(i)}},p.Di=function(){var t;try{return t=this.c.yh(--this.e),this.Bi(),this.g=this.e,t}catch(i){throw i=pr(i),re(i,79)?(this.Bi(),Y(new K)):Y(i)}},p.jc=function(){throw Y(new Pi)},p.Gc=function(t){throw Y(new Pi)};var JLn=k(Gs,"AbstractEList/NonResolvingEListIterator",355);A(1673,59,vtt),p.lh=function(t){var i,a,l,f,g,m,v,y,E;if(l=t._b(),l!=0){for(y=(a=h(sn(this.a,4),116),a==null?0:a.length),E=y+l,i=Tbe(this,E),v=t.tc(),g=y;ga)throw Y(new o_(t,a));return new gUe(this,t)},p.Pb=function(){var t,i;++this.j,t=h(sn(this.a,4),116),i=t==null?0:t.length,l6(this,null),GQ(this,i,t)},p.pc=function(t){var i,a,l,f;if(i=h(sn(this.a,4),116),i!=null){if(t!=null){for(l=0,f=i.length;l=a)throw Y(new o_(t,a));return i[t]},p.dd=function(t){var i,a,l;if(i=h(sn(this.a,4),116),i!=null){if(t!=null){for(a=0,l=i.length;aa)throw Y(new o_(t,a));return new pUe(this,t)},p.yh=function(t){return h(sn(this.a,4),116)[t]},p.gd=function(t){return RFt(this,t)},p.Ah=function(t,i){var a,l;return a=b5t(this),l=a[t],Tge(a,t,DA(this,i)),l6(this,a),l},p._b=function(){var t;return t=h(sn(this.a,4),116),t==null?0:t.length},p.yc=function(){var t,i,a;return t=h(sn(this.a,4),116),a=t==null?0:t.length,i=le(kae,kre,380,a,0,1),a>0&&vc(t,0,i,0,a),i},p.zc=function(t){var i,a,l;return i=h(sn(this.a,4),116),l=i==null?0:i.length,l>0&&(t.lengthl&&Gr(t,l,null),t};var Nlt,QLn=k(Gs,"ArrayDelegatingEList",1673);A(927,36,ys,Zze),p.Bi=function(){if(this.b.j!=this.f||Be(h(sn(this.b.a,4),116))!==Be(this.a))throw Y(new P)},p.jc=function(){KA(this),this.a=h(sn(this.b.a,4),116)};var e4n=k(Gs,"ArrayDelegatingEList/EIterator",927);A(640,296,Ch,z9e,pUe),p.Bi=function(){if(this.b.j!=this.f||Be(h(sn(this.b.a,4),116))!==Be(this.a))throw Y(new P)},p.Ei=function(t){xHe(this,t),this.a=h(sn(this.b.a,4),116)},p.jc=function(){KA(this),this.a=h(sn(this.b.a,4),116)};var t4n=k(Gs,"ArrayDelegatingEList/EListIterator",640);A(928,324,ys,Kze),p.Bi=function(){if(this.b.j!=this.f||Be(h(sn(this.b.a,4),116))!==Be(this.a))throw Y(new P)};var n4n=k(Gs,"ArrayDelegatingEList/NonResolvingEIterator",928);A(641,355,Ch,G9e,gUe),p.Bi=function(){if(this.b.j!=this.f||Be(h(sn(this.b.a,4),116))!==Be(this.a))throw Y(new P)};var i4n=k(Gs,"ArrayDelegatingEList/NonResolvingEListIterator",641);A(549,295,lie,JK);var r4n=k(Gs,"BasicEList/BasicIndexOutOfBoundsException",549);A(630,55,Ih,dge),p.bd=function(t,i){throw Y(new Pi)},p.nc=function(t){throw Y(new Pi)},p.oc=function(t){throw Y(new Pi)},p.Pb=function(){throw Y(new Pi)},p.Eh=function(t){throw Y(new Pi)},p.tc=function(){return this.oh()},p.ed=function(){return this.ph()},p.fd=function(t){return this.qh(t)},p.gd=function(t){throw Y(new Pi)},p.vc=function(t){throw Y(new Pi)},p.hd=function(t,i){throw Y(new Pi)};var s4n=k(Gs,"BasicEList/UnmodifiableEList",630);A(639,1,{3:1,20:1,13:1,15:1,52:1,533:1}),p.bd=function(t,i){USt(this,t,h(i,38))},p.nc=function(t){return vMt(this,h(t,38))},p.sc=function(t){mo(this,t)},p.cd=function(t){return h(ae(this.c,t),134)},p.uc=function(){return this.xc()},p.gd=function(t){return h(this.c.gd(t),38)},p.hd=function(t,i){return GAt(this,t,h(i,38))},p.jd=function(t){Ug(this,t)},p.wc=function(){return new di(this,16)},p.xc=function(){return new oi(null,this.wc())},p.oc=function(t){return this.c.oc(t)},p.Pb=function(){this.c.Pb()},p.pc=function(t){return this.c.pc(t)},p.qc=function(t){return Gg(this.c,t)},p.Fi=function(){var t,i,a;if(this.d==null){for(this.d=le(PAe,Oxe,55,2*this.f+1,0,1),a=this.e,this.f=0,i=this.c.tc();i.e!=i.i._b();)t=h(i.Ci(),134),n7(this,t);this.e=a}},p.Fb=function(t){return N8e(this,t)},p.Hb=function(){return pbe(this.c)},p.dd=function(t){return this.c.dd(t)},p.Gi=function(){this.c=new VZ(this)},p.Wb=function(){return this.f==0},p.tc=function(){return this.c.tc()},p.ed=function(){return this.c.ed()},p.fd=function(t){return this.c.fd(t)},p.Hi=function(){return CI(this)},p.Ii=function(t,i,a){return new X8e(t,i,a)},p.Ji=function(){return new Zq},p.vc=function(t){return Yje(this,t)},p._b=function(){return this.f},p.kd=function(t,i){return new Rg(this.c,t,i)},p.yc=function(){return this.c.yc()},p.zc=function(t){return this.c.zc(t)},p.Ib=function(){return Xbe(this.c)},p.e=0,p.f=0;var o4n=k(Gs,"BasicEMap",639);A(922,55,Ih,VZ),p.sh=function(t,i){rt(this,h(i,134))},p.vh=function(t,i){gt(this,h(i,134))},p.wh=function(t,i,a){hMt(this,h(i,134),h(a,134))},p.uh=function(t,i){W$e(this.a)};var a4n=k(Gs,"BasicEMap/1",922);A(923,55,Ih,Zq),p.Fh=function(t){return le(MVt,_tt,551,t,0,1)};var c4n=k(Gs,"BasicEMap/2",923);A(924,fd,gu,WZ),p.Pb=function(){this.a.c.Pb()},p.pc=function(t){return nte(this.a,t)},p.tc=function(){return this.a.f==0?(tA(),vD.a):new _Be(this.a)},p.vc=function(t){var i;return i=this.a.f,a6(this.a,t),this.a.f!=i},p._b=function(){return this.a.f};var l4n=k(Gs,"BasicEMap/3",924);A(925,25,Y_,HZ),p.Pb=function(){this.a.c.Pb()},p.pc=function(t){return oZe(this.a,t)},p.tc=function(){return this.a.f==0?(tA(),vD.a):new yBe(this.a)},p._b=function(){return this.a.f};var u4n=k(Gs,"BasicEMap/4",925);A(926,fd,gu,qZ),p.Pb=function(){this.a.c.Pb()},p.pc=function(t){var i,a,l,f,g,m,v,y,E;if(this.a.f>0&&re(t,38)&&(this.a.Fi(),y=h(t,38),v=y.kc(),f=v==null?0:Hr(v),g=sme(this.a,f),i=this.a.d[g],i)){for(a=h(i.g,339),E=i.i,m=0;m"+this.c},p.a=0;var MVt=k(Gs,"BasicEMap/EntryImpl",551);A(484,1,{},L2);var m4n=k(Gs,"BasicEMap/View",484),vD;A(695,1,{}),p.Fb=function(t){return Cve((_t(),uo),t)},p.Hb=function(){return ybe((_t(),uo))},p.Ib=function(){return Vp((_t(),uo))};var b4n=k(Gs,"ECollections/BasicEmptyUnmodifiableEList",695);A(1164,1,Ch,Kq),p.gc=function(t){Ss(this,t)},p.Bc=function(t){throw Y(new Pi)},p.hc=function(){return!1},p.Cc=function(){return!1},p.ic=function(){throw Y(new K)},p.Dc=function(){return 0},p.Ec=function(){throw Y(new K)},p.Fc=function(){return-1},p.jc=function(){throw Y(new Pi)},p.Gc=function(t){throw Y(new Pi)};var w4n=k(Gs,"ECollections/BasicEmptyUnmodifiableEList/1",1164);A(1162,695,{20:1,13:1,15:1,52:1},MDe),p.bd=function(t,i){qDe()},p.nc=function(t){return XDe()},p.oc=function(t){return YDe()},p.Pb=function(){ZDe()},p.pc=function(t){return!1},p.qc=function(t){return!1},p.sc=function(t){mo(this,t)},p.cd=function(t){return wge((_t(),t)),null},p.dd=function(t){return-1},p.Wb=function(){return!0},p.tc=function(){return this.a},p.ed=function(){return this.a},p.fd=function(t){return this.a},p.uc=function(){return this.xc()},p.gd=function(t){return KDe()},p.vc=function(t){return JDe()},p.hd=function(t,i){return QDe()},p._b=function(){return 0},p.jd=function(t){Ug(this,t)},p.wc=function(){return new di(this,16)},p.xc=function(){return new oi(null,this.wc())},p.kd=function(t,i){return _t(),new Rg(uo,t,i)},p.yc=function(){return VJ((_t(),uo))},p.zc=function(t){return _t(),u6(uo,t)};var v4n=k(Gs,"ECollections/EmptyUnmodifiableEList",1162);A(1163,695,{20:1,13:1,15:1,52:1,533:1},SDe),p.bd=function(t,i){qDe()},p.nc=function(t){return XDe()},p.oc=function(t){return YDe()},p.Pb=function(){ZDe()},p.pc=function(t){return!1},p.qc=function(t){return!1},p.sc=function(t){mo(this,t)},p.cd=function(t){return wge((_t(),t)),null},p.dd=function(t){return-1},p.Wb=function(){return!0},p.tc=function(){return this.a},p.ed=function(){return this.a},p.fd=function(t){return this.a},p.uc=function(){return this.xc()},p.gd=function(t){return KDe()},p.vc=function(t){return JDe()},p.hd=function(t,i){return QDe()},p._b=function(){return 0},p.jd=function(t){Ug(this,t)},p.wc=function(){return new di(this,16)},p.xc=function(){return new oi(null,this.wc())},p.kd=function(t,i){return _t(),new Rg(uo,t,i)},p.yc=function(){return VJ((_t(),uo))},p.zc=function(t){return _t(),u6(uo,t)},p.Hi=function(){return _t(),_t(),ep};var _4n=k(Gs,"ECollections/EmptyUnmodifiableEMap",1163),kAe=_r(Gs,"Enumerator"),Dj;A(261,1,{261:1},sne),p.Fb=function(t){var i;return this===t?!0:re(t,261)?(i=h(t,261),this.f==i.f&&JCt(this.i,i.i)&&GJ(this.a,this.f&256?i.f&256?i.a:null:i.f&256?null:i.a)&&GJ(this.d,i.d)&&GJ(this.g,i.g)&&GJ(this.e,i.e)&&z5t(this,i)):!1},p.Hb=function(){return this.f},p.Ib=function(){return NZe(this)},p.f=0;var Flt=0,Ult=0,zlt=0,Glt=0,RAe=0,IAe=0,DAe=0,BAe=0,OAe=0,jlt,IL=0,DL=0,$lt=0,Vlt=0,Bj,NAe,y4n=k(Gs,"URI",261);A(965,44,Fx,wDe),p.Zb=function(t,i){return h(Ko(this,ti(t),h(i,261)),261)};var x4n=k(Gs,"URI/URICache",965);A(451,55,Ih,bE,S9),p.xh=function(){return!0};var E4n=k(Gs,"UniqueEList",451);A(526,54,Zd,hU);var S4n=k(Gs,"WrappedException",526),Ri=_r(Xl,Ett),tv=_r(Xl,Stt),Sc=_r(Xl,Mtt),Ly=_r(Xl,Ttt),ch=_r(Xl,Ctt),Lu=_r(Xl,"EClass"),Rae=_r(Xl,"EDataType"),Wlt;A(1096,44,Fx,vDe),p.Vb=function(t){return ws(t)?za(this,t):Dc(gc(this.d,t))};var M4n=k(Xl,"EDataType/Internal/ConversionDelegate/Factory/Registry/Impl",1096),Oj=_r(Xl,"EEnum"),eg=_r(Xl,Att),ko=_r(Xl,Ptt),uf=_r(Xl,Ltt),ku,nv=_r(Xl,ktt),iv=_r(Xl,Rtt);A(918,1,{},vN),p.Ib=function(){return"NIL"};var T4n=k(Xl,"EStructuralFeature/Internal/DynamicValueHolder/1",918),Hlt;A(917,44,Fx,_De),p.Vb=function(t){return ws(t)?za(this,t):Dc(gc(this.d,t))};var C4n=k(Xl,"EStructuralFeature/Internal/SettingDelegate/Factory/Registry/Impl",917),fl=_r(Xl,Itt),w3=_r(Xl,"EValidator/PatternMatcher"),FAe,UAe,Ct,A1,v3,wb,qlt,Xlt,vb,P1,_b,ky,zh,Ylt,Zlt,ff,L1,k1,rv,TM,zo,Klt,Jlt,Ry,Nj=_r(or,"FeatureMap/Entry");A(483,1,{75:1},U8),p.nj=function(){return this.a},p.lc=function(){return this.b};var A4n=k(Lt,"BasicEObjectImpl/1",483);A(1674,1,{103:1}),p.oj=function(t){this.e=t==0?Qlt:le(on,et,1,t,5,1)},p.Tg=function(t){return this.e[t]},p.Ug=function(t,i){this.e[t]=i},p.Vg=function(t){this.e[t]=null},p.pj=function(){return this.c},p.qj=function(){throw Y(new Pi)},p.rj=function(){throw Y(new Pi)},p.sj=function(){return this.d},p.tj=function(){return this.e!=null},p.uj=function(t){this.c=t},p.vj=function(t){throw Y(new Pi)},p.wj=function(t){this.d=t};var Qlt,P4n=k(Lt,"BasicEObjectImpl/EPropertiesHolderBaseImpl",1674);A(201,1674,{103:1},mh),p.qj=function(){return this.a},p.rj=function(){return this.b},p.vj=function(t){this.a=t};var L4n=k(Lt,"BasicEObjectImpl/EPropertiesHolderImpl",201);A(463,92,Fet,Bu),p.dg=function(){return this.f},p.ig=function(){return this.k},p.kg=function(t,i){this.g=t,this.i=i},p.mg=function(){return this.j&2?this.Jg().pj():this.Rg()},p.og=function(){return this.i},p.fg=function(){return(this.j&1)!=0},p.yg=function(){return this.g},p.Eg=function(){return(this.j&4)!=0},p.Jg=function(){return!this.k&&(this.k=new mh),this.k},p.Ng=function(t){this.Jg().uj(t),t?this.j|=2:this.j&=-3},p.Rg=function(){return(kg(),Ct).S},p.i=0,p.j=1;var k4n=k(Lt,"EObjectImpl",463);A(710,463,{95:1,91:1,87:1,51:1,103:1,42:1,92:1},Fme),p.Tg=function(t){return this.e[t]},p.Ug=function(t,i){this.e[t]=i},p.Vg=function(t){this.e[t]=null},p.mg=function(){return this.d},p.rg=function(t){return br(this.d,t)},p.tg=function(){return this.d},p.xg=function(){return this.e!=null},p.Jg=function(){return!this.k&&(this.k=new Jq),this.k},p.Ng=function(t){this.d=t},p.Qg=function(){var t;return this.e==null&&(t=jn(this.d),this.e=t==0?eut:le(on,et,1,t,5,1)),this},p.Sg=function(){return 0};var eut,R4n=k(Lt,"DynamicEObjectImpl",710);A(1389,710,{95:1,38:1,91:1,87:1,134:1,51:1,103:1,42:1,92:1},w9e),p.Fb=function(t){return this===t},p.Hb=function(){return m0(this)},p.Ng=function(t){this.d=t,this.b=T6(t,"key"),this.c=T6(t,kP)},p.ih=function(){var t;return this.a==-1&&(t=QQ(this,this.b),this.a=t==null?0:Hr(t)),this.a},p.kc=function(){return QQ(this,this.b)},p.lc=function(){return QQ(this,this.c)},p.jh=function(t){this.a=t},p.kh=function(t){R7e(this,this.b,t)},p.mc=function(t){var i;return i=QQ(this,this.c),R7e(this,this.c,t),i},p.a=0;var I4n=k(Lt,"DynamicEObjectImpl/BasicEMapEntry",1389);A(1390,1,{103:1},Jq),p.oj=function(t){throw Y(new Pi)},p.Tg=function(t){throw Y(new Pi)},p.Ug=function(t,i){throw Y(new Pi)},p.Vg=function(t){throw Y(new Pi)},p.pj=function(){throw Y(new Pi)},p.qj=function(){return this.a},p.rj=function(){return this.b},p.sj=function(){return this.c},p.tj=function(){throw Y(new Pi)},p.uj=function(t){throw Y(new Pi)},p.vj=function(t){this.a=t},p.wj=function(t){this.c=t};var D4n=k(Lt,"DynamicEObjectImpl/DynamicEPropertiesHolderImpl",1390);A(469,142,{95:1,91:1,87:1,609:1,139:1,51:1,103:1,42:1,92:1,469:1,142:1,107:1,108:1},_N),p.jg=function(t){return Rwe(this,t)},p.ug=function(t,i,a){var l;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.d;case 2:return a?(!this.b&&(this.b=new wl((yt(),zo),Aa,this)),this.b):(!this.b&&(this.b=new wl((yt(),zo),Aa,this)),CI(this.b));case 3:return w7e(this);case 4:return!this.a&&(this.a=new vs(Qw,this,4)),this.a;case 5:return!this.c&&(this.c=new qE(Qw,this,5)),this.c}return jl(this,t-jn((yt(),A1)),Wt((l=h(sn(this,16),24),l||A1),t),i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),ja(this.Ab,t,a);case 3:return this.Cb&&(a=(f=this.Db>>16,f>=0?Rwe(this,a):this.Cb.Cg(this,-1-f,null,a))),e1e(this,h(t,139),a)}return g=h(Wt((l=h(sn(this,16),24),l||(yt(),A1)),i),61),g.aj().dj(this,Ya(this),i-jn((yt(),A1)),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a);case 2:return!this.b&&(this.b=new wl((yt(),zo),Aa,this)),f9(this.b,t,a);case 3:return e1e(this,null,a);case 4:return!this.a&&(this.a=new vs(Qw,this,4)),Us(this.a,t,a)}return f=h(Wt((l=h(sn(this,16),24),l||(yt(),A1)),i),61),f.aj().ej(this,Ya(this),i-jn((yt(),A1)),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.d!=null;case 2:return!!this.b&&this.b.f!=0;case 3:return!!w7e(this);case 4:return!!this.a&&this.a.i!=0;case 5:return!!this.c&&this.c.i!=0}return zl(this,t-jn((yt(),A1)),Wt((i=h(sn(this,16),24),i||A1),t))},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:QCt(this,ti(i));return;case 2:!this.b&&(this.b=new wl((yt(),zo),Aa,this)),TU(this.b,i);return;case 3:m9t(this,h(i,139));return;case 4:!this.a&&(this.a=new vs(Qw,this,4)),Pr(this.a),!this.a&&(this.a=new vs(Qw,this,4)),Mr(this.a,h(i,13));return;case 5:!this.c&&(this.c=new qE(Qw,this,5)),Pr(this.c),!this.c&&(this.c=new qE(Qw,this,5)),Mr(this.c,h(i,13));return}Wl(this,t-jn((yt(),A1)),Wt((a=h(sn(this,16),24),a||A1),t),i)},p.Rg=function(){return yt(),A1},p.Ib=function(){return qVe(this)},p.d=null;var B4n=k(Lt,"EAnnotationImpl",469);A(143,639,Nxe,il),p.xj=function(t,i){return QMt(this,h(t,38),i)},p.Dh=function(t){return h(h(this.c,64).Dh(t),134)},p.oh=function(){return h(this.c,64).oh()},p.ph=function(){return h(this.c,64).ph()},p.qh=function(t){return h(this.c,64).qh(t)},p.yj=function(t,i){return f9(this,t,i)},p.hj=function(t){return h(this.c,81).hj(t)},p.Gi=function(){},p.ui=function(){return h(this.c,81).ui()},p.Ii=function(t,i,a){var l;return l=h($l(this.b).dh().$g(this.b),134),l.jh(t),l.kh(i),l.mc(a),l},p.Ji=function(){return new _C(this)},p.Gc=function(t){TU(this,t)},p.ij=function(){h(this.c,81).ij()};var O4n=k(or,"EcoreEMap",143);A(152,143,Nxe,wl),p.Fi=function(){var t,i,a,l,f,g;if(this.d==null){for(g=le(PAe,Oxe,55,2*this.f+1,0,1),a=this.c.tc();a.e!=a.i._b();)i=h(a.Ci(),134),l=i.ih(),f=(l&zi)%g.length,t=g[f],!t&&(t=g[f]=new _C(this)),t.nc(i);this.d=g}};var N4n=k(Lt,"EAnnotationImpl/1",152);A(268,399,{95:1,91:1,87:1,139:1,174:1,51:1,103:1,431:1,42:1,92:1,142:1,268:1,107:1,108:1}),p.ug=function(t,i,a){var l,f;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.zb;case 2:return vt(),!!(this.Bb&256);case 3:return vt(),!!(this.Bb&512);case 4:return He(this.s);case 5:return He(this.t);case 6:return vt(),!!this.lj();case 7:return vt(),f=this.s,f>=1;case 8:return i?pu(this):this.r;case 9:return this.q}return jl(this,t-jn(this.Rg()),Wt((l=h(sn(this,16),24),l||this.Rg()),t),i,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a);case 9:return nQ(this,a)}return f=h(Wt((l=h(sn(this,16),24),l||this.Rg()),i),61),f.aj().ej(this,Ya(this),i-jn(this.Rg()),t,a)},p.Fg=function(t){var i,a;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return(this.Bb&256)==0;case 3:return(this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return this.lj();case 7:return a=this.s,a>=1;case 8:return!!this.r&&!this.q.e&&x0(this.q).i==0;case 9:return!!this.q&&!(this.r&&!this.q.e&&x0(this.q).i==0)}return zl(this,t-jn(this.Rg()),Wt((i=h(sn(this,16),24),i||this.Rg()),t))},p.Mg=function(t,i){var a,l;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:this.ah(ti(i));return;case 2:C_(this,ce(mt(i)));return;case 3:A_(this,ce(mt(i)));return;case 4:E_(this,h(i,21).a);return;case 5:this.Aj(h(i,21).a);return;case 8:ES(this,h(i,133));return;case 9:l=Zg(this,h(i,84),null),l&&l.Th();return}Wl(this,t-jn(this.Rg()),Wt((a=h(sn(this,16),24),a||this.Rg()),t),i)},p.Rg=function(){return yt(),Jlt},p.Xg=function(){pu(this),this.Bb|=1},p.jj=function(){return pu(this)},p.kj=function(){return this.t},p.lj=function(){var t;return t=this.t,t>1||t==-1},p.xh=function(){return(this.Bb&512)!=0},p.zj=function(t,i){return Bbe(this,t,i)},p.Aj=function(t){mS(this,t)},p.Ib=function(){return Eve(this)},p.s=0,p.t=1;var F4n=k(Lt,"ETypedElementImpl",268);A(418,268,{95:1,91:1,87:1,139:1,174:1,51:1,158:1,61:1,103:1,431:1,42:1,92:1,142:1,418:1,268:1,107:1,108:1,615:1}),p.jg=function(t){return jHe(this,t)},p.ug=function(t,i,a){var l,f;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.zb;case 2:return vt(),!!(this.Bb&256);case 3:return vt(),!!(this.Bb&512);case 4:return He(this.s);case 5:return He(this.t);case 6:return vt(),!!this.lj();case 7:return vt(),f=this.s,f>=1;case 8:return i?pu(this):this.r;case 9:return this.q;case 10:return vt(),!!(this.Bb&tf);case 11:return vt(),!!(this.Bb&Dw);case 12:return vt(),!!(this.Bb&H0);case 13:return this.j;case 14:return NS(this);case 15:return vt(),!!(this.Bb&yc);case 16:return vt(),!!(this.Bb&Ah);case 17:return dw(this)}return jl(this,t-jn(this.Rg()),Wt((l=h(sn(this,16),24),l||this.Rg()),t),i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),ja(this.Ab,t,a);case 17:return this.Cb&&(a=(f=this.Db>>16,f>=0?jHe(this,a):this.Cb.Cg(this,-1-f,null,a))),Ml(this,t,17,a)}return g=h(Wt((l=h(sn(this,16),24),l||this.Rg()),i),61),g.aj().dj(this,Ya(this),i-jn(this.Rg()),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a);case 9:return nQ(this,a);case 17:return Ml(this,null,17,a)}return f=h(Wt((l=h(sn(this,16),24),l||this.Rg()),i),61),f.aj().ej(this,Ya(this),i-jn(this.Rg()),t,a)},p.Fg=function(t){var i,a;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return(this.Bb&256)==0;case 3:return(this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return this.lj();case 7:return a=this.s,a>=1;case 8:return!!this.r&&!this.q.e&&x0(this.q).i==0;case 9:return!!this.q&&!(this.r&&!this.q.e&&x0(this.q).i==0);case 10:return(this.Bb&tf)==0;case 11:return(this.Bb&Dw)!=0;case 12:return(this.Bb&H0)!=0;case 13:return this.j!=null;case 14:return NS(this)!=null;case 15:return(this.Bb&yc)!=0;case 16:return(this.Bb&Ah)!=0;case 17:return!!dw(this)}return zl(this,t-jn(this.Rg()),Wt((i=h(sn(this,16),24),i||this.Rg()),t))},p.Mg=function(t,i){var a,l;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:SQ(this,ti(i));return;case 2:C_(this,ce(mt(i)));return;case 3:A_(this,ce(mt(i)));return;case 4:E_(this,h(i,21).a);return;case 5:this.Aj(h(i,21).a);return;case 8:ES(this,h(i,133));return;case 9:l=Zg(this,h(i,84),null),l&&l.Th();return;case 10:OU(this,ce(mt(i)));return;case 11:BU(this,ce(mt(i)));return;case 12:FU(this,ce(mt(i)));return;case 13:mge(this,ti(i));return;case 15:NU(this,ce(mt(i)));return;case 16:UU(this,ce(mt(i)));return}Wl(this,t-jn(this.Rg()),Wt((a=h(sn(this,16),24),a||this.Rg()),t),i)},p.Rg=function(){return yt(),Klt},p.Xg=function(){iS(Vo((qc(),Zs),this)),pu(this),this.Bb|=1},p.Vi=function(){return this.f},p.Oi=function(){return NS(this)},p.Wi=function(){return dw(this)},p.$i=function(){return null},p.Bj=function(){return this.k},p.pi=function(){return this.n},p._i=function(){return c7(this)},p.aj=function(){var t,i,a,l,f,g,m,v,y;return this.p||(a=dw(this),(a.i==null&&Jg(a),a.i).length,l=this.$i(),l&&jn(dw(l)),f=pu(this),m=f.Qi(),t=m?m.i&1?m==Ru?lo:m==In?Po:m==av?aM:m==ks?Eo:m==R1?J0:m==By?Q0:m==Mc?qx:$P:m:null,i=NS(this),v=f.Oi(),C6t(this),this.Bb&Ah&&((g=Uwe((qc(),Zs),a))&&g!=this||(g=pA(Vo(Zs,this))))?this.p=new mNe(this,g):this.lj()?this.Dj()?l?this.Bb&yc?t?this.Ej()?this.p=new Vm(47,t,this,l):this.p=new Vm(5,t,this,l):this.Ej()?this.p=new qm(46,this,l):this.p=new qm(4,this,l):t?this.Ej()?this.p=new Vm(49,t,this,l):this.p=new Vm(7,t,this,l):this.Ej()?this.p=new qm(48,this,l):this.p=new qm(6,this,l):this.Bb&yc?t?t==cy?this.p=new Ip(50,Blt,this):this.Ej()?this.p=new Ip(43,t,this):this.p=new Ip(1,t,this):this.Ej()?this.p=new Np(42,this):this.p=new Np(0,this):t?t==cy?this.p=new Ip(41,Blt,this):this.Ej()?this.p=new Ip(45,t,this):this.p=new Ip(3,t,this):this.Ej()?this.p=new Np(44,this):this.p=new Np(2,this):re(f,140)?t==Nj?this.p=new Np(40,this):this.Bb&512?this.Bb&yc?t?this.p=new Ip(9,t,this):this.p=new Np(8,this):t?this.p=new Ip(11,t,this):this.p=new Np(10,this):this.Bb&yc?t?this.p=new Ip(13,t,this):this.p=new Np(12,this):t?this.p=new Ip(15,t,this):this.p=new Np(14,this):l?(y=l.t,y>1||y==-1?this.Ej()?this.Bb&yc?t?this.p=new Vm(25,t,this,l):this.p=new qm(24,this,l):t?this.p=new Vm(27,t,this,l):this.p=new qm(26,this,l):this.Bb&yc?t?this.p=new Vm(29,t,this,l):this.p=new qm(28,this,l):t?this.p=new Vm(31,t,this,l):this.p=new qm(30,this,l):this.Ej()?this.Bb&yc?t?this.p=new Vm(33,t,this,l):this.p=new qm(32,this,l):t?this.p=new Vm(35,t,this,l):this.p=new qm(34,this,l):this.Bb&yc?t?this.p=new Vm(37,t,this,l):this.p=new qm(36,this,l):t?this.p=new Vm(39,t,this,l):this.p=new qm(38,this,l)):this.Ej()?this.Bb&yc?t?this.p=new Ip(17,t,this):this.p=new Np(16,this):t?this.p=new Ip(19,t,this):this.p=new Np(18,this):this.Bb&yc?t?this.p=new Ip(21,t,this):this.p=new Np(20,this):t?this.p=new Ip(23,t,this):this.p=new Np(22,this):this.Cj()?this.Ej()?this.p=new Y8e(h(f,24),this,l):this.p=new j1e(h(f,24),this,l):re(f,140)?t==Nj?this.p=new Np(40,this):this.Bb&yc?t?this.p=new O9e(i,v,this,(tte(),m==In?HAe:m==Ru?GAe:m==R1?qAe:m==av?WAe:m==ks?VAe:m==By?XAe:m==Mc?jAe:m==Zl?$Ae:Bae)):this.p=new RUe(h(f,140),i,v,this):t?this.p=new B9e(i,v,this,(tte(),m==In?HAe:m==Ru?GAe:m==R1?qAe:m==av?WAe:m==ks?VAe:m==By?XAe:m==Mc?jAe:m==Zl?$Ae:Bae)):this.p=new kUe(h(f,140),i,v,this):this.Dj()?l?this.Bb&yc?this.Ej()?this.p=new K8e(h(f,24),this,l):this.p=new Lme(h(f,24),this,l):this.Ej()?this.p=new Z8e(h(f,24),this,l):this.p=new OJ(h(f,24),this,l):this.Bb&yc?this.Ej()?this.p=new HFe(h(f,24),this):this.p=new Yge(h(f,24),this):this.Ej()?this.p=new WFe(h(f,24),this):this.p=new _J(h(f,24),this):this.Ej()?l?this.Bb&yc?this.p=new J8e(h(f,24),this,l):this.p=new Pme(h(f,24),this,l):this.Bb&yc?this.p=new qFe(h(f,24),this):this.p=new Xge(h(f,24),this):l?this.Bb&yc?this.p=new Q8e(h(f,24),this,l):this.p=new kme(h(f,24),this,l):this.Bb&yc?this.p=new XFe(h(f,24),this):this.p=new M9(h(f,24),this)),this.p},p.Xi=function(){return(this.Bb&tf)!=0},p.Cj=function(){return!1},p.Dj=function(){return!1},p.Yi=function(){return(this.Bb&Ah)!=0},p.bj=function(){return O0e(this)},p.Ej=function(){return!1},p.Zi=function(){return(this.Bb&yc)!=0},p.Fj=function(t){this.k=t},p.ah=function(t){SQ(this,t)},p.Ib=function(){return L7(this)},p.e=!1,p.n=0;var U4n=k(Lt,"EStructuralFeatureImpl",418);A(335,418,{95:1,91:1,87:1,29:1,139:1,174:1,51:1,158:1,61:1,103:1,431:1,42:1,92:1,335:1,142:1,418:1,268:1,107:1,108:1,615:1},cK),p.ug=function(t,i,a){var l,f;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.zb;case 2:return vt(),!!(this.Bb&256);case 3:return vt(),!!(this.Bb&512);case 4:return He(this.s);case 5:return He(this.t);case 6:return vt(),!!yve(this);case 7:return vt(),f=this.s,f>=1;case 8:return i?pu(this):this.r;case 9:return this.q;case 10:return vt(),!!(this.Bb&tf);case 11:return vt(),!!(this.Bb&Dw);case 12:return vt(),!!(this.Bb&H0);case 13:return this.j;case 14:return NS(this);case 15:return vt(),!!(this.Bb&yc);case 16:return vt(),!!(this.Bb&Ah);case 17:return dw(this);case 18:return vt(),!!(this.Bb&Ja);case 19:return i?See(this):AGe(this)}return jl(this,t-jn((yt(),v3)),Wt((l=h(sn(this,16),24),l||v3),t),i,a)},p.Fg=function(t){var i,a;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return(this.Bb&256)==0;case 3:return(this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return yve(this);case 7:return a=this.s,a>=1;case 8:return!!this.r&&!this.q.e&&x0(this.q).i==0;case 9:return!!this.q&&!(this.r&&!this.q.e&&x0(this.q).i==0);case 10:return(this.Bb&tf)==0;case 11:return(this.Bb&Dw)!=0;case 12:return(this.Bb&H0)!=0;case 13:return this.j!=null;case 14:return NS(this)!=null;case 15:return(this.Bb&yc)!=0;case 16:return(this.Bb&Ah)!=0;case 17:return!!dw(this);case 18:return(this.Bb&Ja)!=0;case 19:return!!AGe(this)}return zl(this,t-jn((yt(),v3)),Wt((i=h(sn(this,16),24),i||v3),t))},p.Mg=function(t,i){var a,l;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:SQ(this,ti(i));return;case 2:C_(this,ce(mt(i)));return;case 3:A_(this,ce(mt(i)));return;case 4:E_(this,h(i,21).a);return;case 5:mBe(this,h(i,21).a);return;case 8:ES(this,h(i,133));return;case 9:l=Zg(this,h(i,84),null),l&&l.Th();return;case 10:OU(this,ce(mt(i)));return;case 11:BU(this,ce(mt(i)));return;case 12:FU(this,ce(mt(i)));return;case 13:mge(this,ti(i));return;case 15:NU(this,ce(mt(i)));return;case 16:UU(this,ce(mt(i)));return;case 18:$be(this,ce(mt(i)));return}Wl(this,t-jn((yt(),v3)),Wt((a=h(sn(this,16),24),a||v3),t),i)},p.Rg=function(){return yt(),v3},p.Xg=function(){See(this),iS(Vo((qc(),Zs),this)),pu(this),this.Bb|=1},p.lj=function(){return yve(this)},p.zj=function(t,i){return this.b=0,this.a=null,Bbe(this,t,i)},p.Aj=function(t){mBe(this,t)},p.Ib=function(){var t;return this.Db&64?L7(this):(t=new su(L7(this)),t.a+=" (iD: ",Ap(t,(this.Bb&Ja)!=0),t.a+=")",t.a)},p.b=0;var z4n=k(Lt,"EAttributeImpl",335);A(672,399,{95:1,91:1,87:1,133:1,139:1,174:1,51:1,103:1,42:1,92:1,142:1,107:1,108:1,614:1}),p.Gj=function(t){return t.mg()==this},p.jg=function(t){return Mte(this,t)},p.kg=function(t,i){this.w=null,this.Db=i<<16|this.Db&255,this.Cb=t},p.ug=function(t,i,a){var l;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.zb;case 2:return this.D!=null?this.D:this.B;case 3:return F0(this);case 4:return this.Oi();case 5:return this.F;case 6:return i?$l(this):aS(this);case 7:return!this.A&&(this.A=new Nl(fl,this,7)),this.A}return jl(this,t-jn(this.Rg()),Wt((l=h(sn(this,16),24),l||this.Rg()),t),i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),ja(this.Ab,t,a);case 6:return this.Cb&&(a=(f=this.Db>>16,f>=0?Mte(this,a):this.Cb.Cg(this,-1-f,null,a))),Ml(this,t,6,a)}return g=h(Wt((l=h(sn(this,16),24),l||this.Rg()),i),61),g.aj().dj(this,Ya(this),i-jn(this.Rg()),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a);case 6:return Ml(this,null,6,a);case 7:return!this.A&&(this.A=new Nl(fl,this,7)),Us(this.A,t,a)}return f=h(Wt((l=h(sn(this,16),24),l||this.Rg()),i),61),f.aj().ej(this,Ya(this),i-jn(this.Rg()),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.D!=null&&this.D==this.F;case 3:return!!F0(this);case 4:return this.Oi()!=null;case 5:return this.F!=null&&this.F!=this.D&&this.F!=this.B;case 6:return!!aS(this);case 7:return!!this.A&&this.A.i!=0}return zl(this,t-jn(this.Rg()),Wt((i=h(sn(this,16),24),i||this.Rg()),t))},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:H9(this,ti(i));return;case 2:iJ(this,ti(i));return;case 5:Pne(this,ti(i));return;case 7:!this.A&&(this.A=new Nl(fl,this,7)),Pr(this.A),!this.A&&(this.A=new Nl(fl,this,7)),Mr(this.A,h(i,13));return}Wl(this,t-jn(this.Rg()),Wt((a=h(sn(this,16),24),a||this.Rg()),t),i)},p.Rg=function(){return yt(),qlt},p.Ni=function(){var t;return this.G==-1&&(this.G=(t=$l(this),t?$p(t.bh(),this):-1)),this.G},p.Oi=function(){return null},p.Pi=function(){return $l(this)},p.Hj=function(){return this.v},p.Qi=function(){return F0(this)},p.Ri=function(){return this.D!=null?this.D:this.B},p.Si=function(){return this.F},p.Li=function(t){return hne(this,t)},p.Ij=function(t){this.v=t},p.Jj=function(t){E$e(this,t)},p.Kj=function(t){this.C=t},p.ah=function(t){H9(this,t)},p.Ib=function(){return HU(this)},p.C=null,p.D=null,p.G=-1;var G4n=k(Lt,"EClassifierImpl",672);A(96,672,{95:1,91:1,87:1,24:1,133:1,139:1,174:1,51:1,103:1,42:1,92:1,96:1,142:1,432:1,107:1,108:1,614:1},lR),p.Gj=function(t){return qMt(this,t.mg())},p.ug=function(t,i,a){var l;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.zb;case 2:return this.D!=null?this.D:this.B;case 3:return F0(this);case 4:return null;case 5:return this.F;case 6:return i?$l(this):aS(this);case 7:return!this.A&&(this.A=new Nl(fl,this,7)),this.A;case 8:return vt(),!!(this.Bb&256);case 9:return vt(),!!(this.Bb&512);case 10:return Bo(this);case 11:return!this.q&&(this.q=new ze(uf,this,11,10)),this.q;case 12:return V_(this);case 13:return pP(this);case 14:return pP(this),this.r;case 15:return V_(this),this.k;case 16:return hve(this);case 17:return wne(this);case 18:return Jg(this);case 19:return E7(this);case 20:return V_(this),this.o;case 21:return!this.s&&(this.s=new ze(Sc,this,21,17)),this.s;case 22:return Ea(this);case 23:return rne(this)}return jl(this,t-jn((yt(),wb)),Wt((l=h(sn(this,16),24),l||wb),t),i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),ja(this.Ab,t,a);case 6:return this.Cb&&(a=(f=this.Db>>16,f>=0?Mte(this,a):this.Cb.Cg(this,-1-f,null,a))),Ml(this,t,6,a);case 11:return!this.q&&(this.q=new ze(uf,this,11,10)),ja(this.q,t,a);case 21:return!this.s&&(this.s=new ze(Sc,this,21,17)),ja(this.s,t,a)}return g=h(Wt((l=h(sn(this,16),24),l||(yt(),wb)),i),61),g.aj().dj(this,Ya(this),i-jn((yt(),wb)),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a);case 6:return Ml(this,null,6,a);case 7:return!this.A&&(this.A=new Nl(fl,this,7)),Us(this.A,t,a);case 11:return!this.q&&(this.q=new ze(uf,this,11,10)),Us(this.q,t,a);case 21:return!this.s&&(this.s=new ze(Sc,this,21,17)),Us(this.s,t,a);case 22:return Us(Ea(this),t,a)}return f=h(Wt((l=h(sn(this,16),24),l||(yt(),wb)),i),61),f.aj().ej(this,Ya(this),i-jn((yt(),wb)),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.D!=null&&this.D==this.F;case 3:return!!F0(this);case 4:return!1;case 5:return this.F!=null&&this.F!=this.D&&this.F!=this.B;case 6:return!!aS(this);case 7:return!!this.A&&this.A.i!=0;case 8:return(this.Bb&256)!=0;case 9:return(this.Bb&512)!=0;case 10:return!!this.u&&Ea(this.u.a).i!=0&&!(this.n&&bte(this.n));case 11:return!!this.q&&this.q.i!=0;case 12:return V_(this).i!=0;case 13:return pP(this).i!=0;case 14:return pP(this),this.r.i!=0;case 15:return V_(this),this.k.i!=0;case 16:return hve(this).i!=0;case 17:return wne(this).i!=0;case 18:return Jg(this).i!=0;case 19:return E7(this).i!=0;case 20:return V_(this),!!this.o;case 21:return!!this.s&&this.s.i!=0;case 22:return!!this.n&&bte(this.n);case 23:return rne(this).i!=0}return zl(this,t-jn((yt(),wb)),Wt((i=h(sn(this,16),24),i||wb),t))},p.Ig=function(t){var i;return i=this.i==null||this.q&&this.q.i!=0?null:T6(this,t),i||D_e(this,t)},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:H9(this,ti(i));return;case 2:iJ(this,ti(i));return;case 5:Pne(this,ti(i));return;case 7:!this.A&&(this.A=new Nl(fl,this,7)),Pr(this.A),!this.A&&(this.A=new Nl(fl,this,7)),Mr(this.A,h(i,13));return;case 8:eWe(this,ce(mt(i)));return;case 9:tWe(this,ce(mt(i)));return;case 10:O7(Bo(this)),Mr(Bo(this),h(i,13));return;case 11:!this.q&&(this.q=new ze(uf,this,11,10)),Pr(this.q),!this.q&&(this.q=new ze(uf,this,11,10)),Mr(this.q,h(i,13));return;case 21:!this.s&&(this.s=new ze(Sc,this,21,17)),Pr(this.s),!this.s&&(this.s=new ze(Sc,this,21,17)),Mr(this.s,h(i,13));return;case 22:Pr(Ea(this)),Mr(Ea(this),h(i,13));return}Wl(this,t-jn((yt(),wb)),Wt((a=h(sn(this,16),24),a||wb),t),i)},p.Rg=function(){return yt(),wb},p.Xg=function(){var t,i;if(V_(this),pP(this),hve(this),wne(this),Jg(this),E7(this),rne(this),_A(ICt(uu(this))),this.s)for(t=0,i=this.s.i;t=0;--t)ae(this,t);return K1e(this)},p.zc=function(t){var i;if(this.Qj())for(i=this.i-1;i>=0;--i)ae(this,i);return ewe(this,t)},p.ij=function(){Pr(this)},p.Ch=function(t,i){return Rje(this,t,i)};var V4n=k(or,"EcoreEList",565);A(450,565,Ho,uI),p.rh=function(){return!1},p.pi=function(){return this.c},p.qi=function(){return!1},p.Rj=function(){return!0},p.xh=function(){return!0},p.zh=function(t,i){return i},p.Bh=function(){return!1},p.c=0;var W4n=k(or,"EObjectEList",450);A(88,450,Ho,vs),p.qi=function(){return!0},p.Pj=function(){return!1},p.Dj=function(){return!0};var H4n=k(or,"EObjectContainmentEList",88);A(493,88,Ho,Z8),p.th=function(){this.a=!0},p.ui=function(){return this.a},p.ij=function(){var t;Pr(this),$u(this.e)?(t=this.a,this.a=!1,Li(this.e,new qu(this.e,2,this.c,t,!1))):this.a=!1},p.a=!1;var q4n=k(or,"EObjectContainmentEList/Unsettable",493);A(1003,493,Ho,cFe),p.yi=function(t,i){return i5t(this,h(t,84),i)},p.zi=function(t,i){return n5t(this,h(t,84),i)},p.Ai=function(t,i,a){return zBt(this,h(t,84),h(i,84),a)},p.mi=function(t,i,a,l,f){switch(t){case 3:return dA(this,3,i,a,l,this.i>1);case 5:return dA(this,5,i,a,l,this.i-h(a,15)._b()>0);default:return new Wd(this.e,t,this.c,i,a,l,!0)}},p.xi=function(){return!0},p.ui=function(){return bte(this)},p.ij=function(){Pr(this)};var X4n=k(Lt,"EClassImpl/1",1003);A(1017,1016,Bxe),p.Ih=function(t){var i,a,l,f,g,m,v;if(a=t.Lh(),a!=8){if(l=B5t(t),l==0)switch(a){case 1:case 9:{v=t.Ph(),v!=null&&(i=uu(h(v,432)),!i.c&&(i.c=new qb),JQ(i.c,t.Oh())),m=t.Nh(),m!=null&&(f=h(m,432),f.Bb&1||(i=uu(f),!i.c&&(i.c=new qb),$n(i.c,h(t.Oh(),24))));break}case 3:{m=t.Nh(),m!=null&&(f=h(m,432),f.Bb&1||(i=uu(f),!i.c&&(i.c=new qb),$n(i.c,h(t.Oh(),24))));break}case 5:{if(m=t.Nh(),m!=null)for(g=h(m,13).tc();g.hc();)f=h(g.ic(),432),f.Bb&1||(i=uu(f),!i.c&&(i.c=new qb),$n(i.c,h(t.Oh(),24)));break}case 4:{v=t.Ph(),v!=null&&(f=h(v,432),f.Bb&1||(i=uu(f),!i.c&&(i.c=new qb),JQ(i.c,t.Oh())));break}case 6:{if(v=t.Ph(),v!=null)for(g=h(v,13).tc();g.hc();)f=h(g.ic(),432),f.Bb&1||(i=uu(f),!i.c&&(i.c=new qb),JQ(i.c,t.Oh()));break}}this.Tj(l)}},p.Tj=function(t){mZe(this,t)},p.b=63;var Y4n=k(Lt,"ESuperAdapter",1017);A(1018,1017,Bxe,YZ),p.Tj=function(t){sP(this,t)};var Z4n=k(Lt,"EClassImpl/10",1018);A(1007,630,Ho),p.lh=function(t){return kHe(this,t)},p.mh=function(t,i){e6(this,t,i)},p.nh=function(t){MI(this,t)},p.Dh=function(t){return P0e(this,t)},p.Ah=function(t,i){return KQ(this,t,i)},p.xj=function(t,i){throw Y(new Pi)},p.oh=function(){return new nx(this)},p.ph=function(){return new QR(this)},p.qh=function(t){return GI(this,t)},p.yj=function(t,i){throw Y(new Pi)},p.hj=function(t){return this},p.ui=function(){return this.i!=0},p.Gc=function(t){throw Y(new Pi)},p.ij=function(){throw Y(new Pi)};var K4n=k(or,"EcoreEList/UnmodifiableEList",1007);A(301,1007,Ho,t_),p.Bh=function(){return!1};var J4n=k(or,"EcoreEList/UnmodifiableEList/FastCompare",301);A(1010,301,Ho,_Ve),p.dd=function(t){var i,a,l;if(re(t,158)&&(i=h(t,158),a=i.pi(),a!=-1)){for(l=this.i;a4)if(this.Li(t)){if(this.Dj()){if(l=h(t,42),a=l.ng(),v=a==this.b&&(this.Pj()?l.hg(l.og(),h(Wt(sc(this.b),this.pi()).jj(),24).Qi())==Uo(h(Wt(sc(this.b),this.pi()),17)).n:-1-l.og()==this.pi()),this.Qj()&&!v&&!a&&l.sg()){for(f=0;f1||l==-1)):!1},p.Pj=function(){var t,i,a;return i=Wt(sc(this.b),this.pi()),re(i,62)?(t=h(i,17),a=Uo(t),!!a):!1},p.Qj=function(){var t,i;return i=Wt(sc(this.b),this.pi()),re(i,62)?(t=h(i,17),(t.Bb&oo)!=0):!1},p.dd=function(t){var i,a,l,f;if(l=this.ci(t),l>=0)return l;if(this.Rj()){for(a=0,f=this.hi();a=0;--t)B6(this,t,this.ai(t));return this.ii()},p.zc=function(t){var i;if(this.Qj())for(i=this.hi()-1;i>=0;--i)B6(this,i,this.ai(i));return this.ji(t)},p.ij=function(){O7(this)},p.Ch=function(t,i){return jGe(this,t,i)};var ukn=k(or,"DelegatingEcoreEList",674);A(1013,674,Uxe,r8e),p.Vh=function(t,i){EMt(this,t,h(i,24))},p.Wh=function(t){kSt(this,h(t,24))},p.ai=function(t){var i,a;return i=h(ae(Ea(this.a),t),84),a=i.c,re(a,96)?h(a,24):(yt(),ff)},p.fi=function(t){var i,a;return i=h(Mw(Ea(this.a),t),84),a=i.c,re(a,96)?h(a,24):(yt(),ff)},p.gi=function(t,i){return gDt(this,t,h(i,24))},p.rh=function(){return!1},p.mi=function(t,i,a,l,f){return null},p.Xh=function(){return new SR(this)},p.Yh=function(){Pr(Ea(this.a))},p.Zh=function(t){return iWe(this,t)},p.$h=function(t){var i,a;for(a=t.tc();a.hc();)if(i=a.ic(),!iWe(this,i))return!1;return!0},p._h=function(t){var i,a,l;if(re(t,15)&&(l=h(t,15),l._b()==Ea(this.a).i)){for(i=l.tc(),a=new Bn(this);i.hc();)if(Be(i.ic())!==Be(Yn(a)))return!1;return!0}return!1},p.bi=function(){var t,i,a,l,f;for(a=1,i=new Bn(Ea(this.a));i.e!=i.i._b();)t=h(Yn(i),84),l=(f=t.c,re(f,96)?h(f,24):(yt(),ff)),a=31*a+(l?m0(l):0);return a},p.ci=function(t){var i,a,l,f;for(l=0,a=new Bn(Ea(this.a));a.e!=a.i._b();){if(i=h(Yn(a),84),Be(t)===Be((f=i.c,re(f,96)?h(f,24):(yt(),ff))))return l;++l}return-1},p.di=function(){return Ea(this.a).i==0},p.ei=function(){return null},p.hi=function(){return Ea(this.a).i},p.ii=function(){var t,i,a,l,f,g;for(g=Ea(this.a).i,f=le(on,et,1,g,5,1),a=0,i=new Bn(Ea(this.a));i.e!=i.i._b();)t=h(Yn(i),84),f[a++]=(l=t.c,re(l,96)?h(l,24):(yt(),ff));return f},p.ji=function(t){var i,a,l,f,g,m,v;for(v=Ea(this.a).i,t.lengthv&&Gr(t,v,null),l=0,a=new Bn(Ea(this.a));a.e!=a.i._b();)i=h(Yn(a),84),g=(m=i.c,re(m,96)?h(m,24):(yt(),ff)),Gr(t,l++,g);return t},p.ki=function(){var t,i,a,l,f;for(f=new Tp,f.a+="[",t=Ea(this.a),i=0,l=Ea(this.a).i;i>16,f>=0?Mte(this,a):this.Cb.Cg(this,-1-f,null,a))),Ml(this,t,6,a);case 9:return!this.a&&(this.a=new ze(eg,this,9,5)),ja(this.a,t,a)}return g=h(Wt((l=h(sn(this,16),24),l||(yt(),vb)),i),61),g.aj().dj(this,Ya(this),i-jn((yt(),vb)),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a);case 6:return Ml(this,null,6,a);case 7:return!this.A&&(this.A=new Nl(fl,this,7)),Us(this.A,t,a);case 9:return!this.a&&(this.a=new ze(eg,this,9,5)),Us(this.a,t,a)}return f=h(Wt((l=h(sn(this,16),24),l||(yt(),vb)),i),61),f.aj().ej(this,Ya(this),i-jn((yt(),vb)),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.D!=null&&this.D==this.F;case 3:return!!F0(this);case 4:return!!Lbe(this);case 5:return this.F!=null&&this.F!=this.D&&this.F!=this.B;case 6:return!!aS(this);case 7:return!!this.A&&this.A.i!=0;case 8:return(this.Bb&256)==0;case 9:return!!this.a&&this.a.i!=0}return zl(this,t-jn((yt(),vb)),Wt((i=h(sn(this,16),24),i||vb),t))},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:H9(this,ti(i));return;case 2:iJ(this,ti(i));return;case 5:Pne(this,ti(i));return;case 7:!this.A&&(this.A=new Nl(fl,this,7)),Pr(this.A),!this.A&&(this.A=new Nl(fl,this,7)),Mr(this.A,h(i,13));return;case 8:Fbe(this,ce(mt(i)));return;case 9:!this.a&&(this.a=new ze(eg,this,9,5)),Pr(this.a),!this.a&&(this.a=new ze(eg,this,9,5)),Mr(this.a,h(i,13));return}Wl(this,t-jn((yt(),vb)),Wt((a=h(sn(this,16),24),a||vb),t),i)},p.Rg=function(){return yt(),vb},p.Xg=function(){var t,i;if(this.a)for(t=0,i=this.a.i;t>16==5?h(this.Cb,608):null}return jl(this,t-jn((yt(),P1)),Wt((l=h(sn(this,16),24),l||P1),t),i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),ja(this.Ab,t,a);case 5:return this.Cb&&(a=(f=this.Db>>16,f>=0?WHe(this,a):this.Cb.Cg(this,-1-f,null,a))),Ml(this,t,5,a)}return g=h(Wt((l=h(sn(this,16),24),l||(yt(),P1)),i),61),g.aj().dj(this,Ya(this),i-jn((yt(),P1)),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a);case 5:return Ml(this,null,5,a)}return f=h(Wt((l=h(sn(this,16),24),l||(yt(),P1)),i),61),f.aj().ej(this,Ya(this),i-jn((yt(),P1)),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.d!=0;case 3:return!!this.b;case 4:return this.c!=null;case 5:return!!(this.Db>>16==5&&h(this.Cb,608))}return zl(this,t-jn((yt(),P1)),Wt((i=h(sn(this,16),24),i||P1),t))},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:Sf(this,ti(i));return;case 2:$0e(this,h(i,21).a);return;case 3:BFt(this,h(i,1634));return;case 4:tbe(this,ti(i));return}Wl(this,t-jn((yt(),P1)),Wt((a=h(sn(this,16),24),a||P1),t),i)},p.Rg=function(){return yt(),P1},p.Ib=function(){var t;return t=this.c,t??this.zb},p.b=null,p.c=null,p.d=0;var bkn=k(Lt,"EEnumLiteralImpl",525),TVt=_r(Lt,"EFactoryImpl/InternalEDateTimeFormat");A(445,1,{1699:1},N2);var wkn=k(Lt,"EFactoryImpl/1ClientInternalEDateTimeFormat",445);A(217,108,{95:1,91:1,87:1,84:1,51:1,103:1,42:1,92:1,217:1,107:1,108:1},xg),p.lg=function(t,i,a){var l;return a=Ml(this,t,i,a),this.e&&re(t,158)&&(l=x7(this,this.e),l!=this.c&&(a=GS(this,l,a))),a},p.ug=function(t,i,a){var l;switch(t){case 0:return this.f;case 1:return!this.d&&(this.d=new vs(ko,this,1)),this.d;case 2:return i?R7(this):this.c;case 3:return this.b;case 4:return this.e;case 5:return i?vte(this):this.a}return jl(this,t-jn((yt(),ky)),Wt((l=h(sn(this,16),24),l||ky),t),i,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return WVe(this,null,a);case 1:return!this.d&&(this.d=new vs(ko,this,1)),Us(this.d,t,a);case 3:return VVe(this,null,a)}return f=h(Wt((l=h(sn(this,16),24),l||(yt(),ky)),i),61),f.aj().ej(this,Ya(this),i-jn((yt(),ky)),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.f;case 1:return!!this.d&&this.d.i!=0;case 2:return!!this.c;case 3:return!!this.b;case 4:return!!this.e;case 5:return!!this.a}return zl(this,t-jn((yt(),ky)),Wt((i=h(sn(this,16),24),i||ky),t))},p.Mg=function(t,i){var a;switch(t){case 0:lOt(this,h(i,84));return;case 1:!this.d&&(this.d=new vs(ko,this,1)),Pr(this.d),!this.d&&(this.d=new vs(ko,this,1)),Mr(this.d,h(i,13));return;case 3:dqe(this,h(i,84));return;case 4:kqe(this,h(i,742));return;case 5:MA(this,h(i,133));return}Wl(this,t-jn((yt(),ky)),Wt((a=h(sn(this,16),24),a||ky),t),i)},p.Rg=function(){return yt(),ky},p.Ib=function(){var t;return t=new ou(Ku(this)),t.a+=" (expression: ",Ene(this,t),t.a+=")",t.a};var zAe,vkn=k(Lt,"EGenericTypeImpl",217);A(1667,1657,xz),p.xj=function(t,i){return OMt(this,this._b(),t),i},p.Dh=function(t){return qg(this.Uh(),t)},p.oh=function(){return this.ph()},p.Uh=function(){return new TR(this)},p.ph=function(){return this.qh(0)},p.qh=function(t){return this.Uh().fd(t)},p.yj=function(t,i){return _x(this,t,!0),i};var _kn=k(or,"AbstractSequentialInternalEList",1667);A(444,1667,xz,eI),p.Dh=function(t){return qg(this.Uh(),t)},p.oh=function(){return this.b==null?(Pp(),Pp(),_D):this.Vj()},p.Uh=function(){return new PNe(this.a,this.b)},p.ph=function(){return this.b==null?(Pp(),Pp(),_D):this.Vj()},p.qh=function(t){var i,a;if(this.b==null){if(t<0||t>1)throw Y(new Ra(RP+t+", size=0"));return Pp(),Pp(),_D}for(a=this.Vj(),i=0;i0;)if(i=this.c[--this.d],(!this.e||i.Vi()!=MM||i.pi()!=0)&&(!this.Yj()||this.b.Gg(i))){if(g=this.b.wg(i,this.Xj()),this.f=(Yo(),h(i,61).bj()),this.f||i.lj()){if(this.Xj()?(l=h(g,15),this.k=l):(l=h(g,64),this.k=this.j=l),re(this.k,49)?(this.o=this.k._b(),this.n=this.o):this.p=this.j?this.j.qh(this.k._b()):this.k.fd(this.k._b()),this.p?cXe(this,this.p):xXe(this))return f=this.p?this.p.Ec():this.j?this.j.Dh(--this.n):this.k.cd(--this.n),this.f?(t=h(f,75),t.nj(),a=t.lc(),this.i=a):this.i=f,this.g=-3,!0}else if(g!=null)return this.k=null,this.p=null,this.i=g,this.g=-2,!0}return this.k=null,this.p=null,this.g=-1,!1}else return f=this.p?this.p.Ec():this.j?this.j.Dh(--this.n):this.k.cd(--this.n),this.f?(t=h(f,75),t.nj(),a=t.lc(),this.i=a):this.i=f,this.g=-3,!0}},p.ic=function(){return MU(this)},p.Dc=function(){return this.a},p.Ec=function(){var t;if(this.g<-1||this.Cc())return--this.a,this.g=0,t=this.i,this.Cc(),t;throw Y(new K)},p.Fc=function(){return this.a-1},p.jc=function(){throw Y(new Pi)},p.Xj=function(){return!1},p.Gc=function(t){throw Y(new Pi)},p.Yj=function(){return!0},p.a=0,p.d=0,p.f=!1,p.g=0,p.n=0,p.o=0;var _D,Ekn=k(or,"EContentsEList/FeatureIteratorImpl",260);A(631,260,Ez,qge),p.Xj=function(){return!0};var Skn=k(or,"EContentsEList/ResolvingFeatureIteratorImpl",631);A(1020,631,Ez,VFe),p.Yj=function(){return!1};var Mkn=k(Lt,"ENamedElementImpl/1/1",1020);A(1021,260,Ez,$Fe),p.Yj=function(){return!1};var Tkn=k(Lt,"ENamedElementImpl/1/2",1021);A(32,136,o5,gw,LQ,ls,VQ,Wd,qu,V0e,N7e,W0e,F7e,d0e,U7e,X0e,z7e,p0e,G7e,H0e,j7e,pI,I1e,q0e,$7e,g0e,V7e),p.oi=function(){return C0e(this)},p.vi=function(){var t;return t=C0e(this),t?t.Oi():null},p.Mh=function(t){return this.b==-1&&this.a&&(this.b=this.c.qg(this.a.pi(),this.a.Vi())),this.c.hg(this.b,t)},p.Oh=function(){return this.c},p.wi=function(){var t;return t=C0e(this),t?t.Zi():!1},p.b=-1;var Ckn=k(Lt,"ENotificationImpl",32);A(371,268,{95:1,91:1,87:1,139:1,174:1,51:1,53:1,103:1,431:1,42:1,92:1,142:1,371:1,268:1,107:1,108:1},oK),p.jg=function(t){return qHe(this,t)},p.ug=function(t,i,a){var l,f,g;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.zb;case 2:return vt(),!!(this.Bb&256);case 3:return vt(),!!(this.Bb&512);case 4:return He(this.s);case 5:return He(this.t);case 6:return vt(),g=this.t,g>1||g==-1;case 7:return vt(),f=this.s,f>=1;case 8:return i?pu(this):this.r;case 9:return this.q;case 10:return this.Db>>16==10?h(this.Cb,24):null;case 11:return!this.d&&(this.d=new Nl(fl,this,11)),this.d;case 12:return!this.c&&(this.c=new ze(nv,this,12,10)),this.c;case 13:return!this.a&&(this.a=new sI(this,this)),this.a;case 14:return Vc(this)}return jl(this,t-jn((yt(),L1)),Wt((l=h(sn(this,16),24),l||L1),t),i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),ja(this.Ab,t,a);case 10:return this.Cb&&(a=(f=this.Db>>16,f>=0?qHe(this,a):this.Cb.Cg(this,-1-f,null,a))),Ml(this,t,10,a);case 12:return!this.c&&(this.c=new ze(nv,this,12,10)),ja(this.c,t,a)}return g=h(Wt((l=h(sn(this,16),24),l||(yt(),L1)),i),61),g.aj().dj(this,Ya(this),i-jn((yt(),L1)),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a);case 9:return nQ(this,a);case 10:return Ml(this,null,10,a);case 11:return!this.d&&(this.d=new Nl(fl,this,11)),Us(this.d,t,a);case 12:return!this.c&&(this.c=new ze(nv,this,12,10)),Us(this.c,t,a);case 14:return Us(Vc(this),t,a)}return f=h(Wt((l=h(sn(this,16),24),l||(yt(),L1)),i),61),f.aj().ej(this,Ya(this),i-jn((yt(),L1)),t,a)},p.Fg=function(t){var i,a,l;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return(this.Bb&256)==0;case 3:return(this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return l=this.t,l>1||l==-1;case 7:return a=this.s,a>=1;case 8:return!!this.r&&!this.q.e&&x0(this.q).i==0;case 9:return!!this.q&&!(this.r&&!this.q.e&&x0(this.q).i==0);case 10:return!!(this.Db>>16==10&&h(this.Cb,24));case 11:return!!this.d&&this.d.i!=0;case 12:return!!this.c&&this.c.i!=0;case 13:return!!this.a&&Vc(this.a.a).i!=0&&!(this.b&&wte(this.b));case 14:return!!this.b&&wte(this.b)}return zl(this,t-jn((yt(),L1)),Wt((i=h(sn(this,16),24),i||L1),t))},p.Mg=function(t,i){var a,l;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:Sf(this,ti(i));return;case 2:C_(this,ce(mt(i)));return;case 3:A_(this,ce(mt(i)));return;case 4:E_(this,h(i,21).a);return;case 5:mS(this,h(i,21).a);return;case 8:ES(this,h(i,133));return;case 9:l=Zg(this,h(i,84),null),l&&l.Th();return;case 11:!this.d&&(this.d=new Nl(fl,this,11)),Pr(this.d),!this.d&&(this.d=new Nl(fl,this,11)),Mr(this.d,h(i,13));return;case 12:!this.c&&(this.c=new ze(nv,this,12,10)),Pr(this.c),!this.c&&(this.c=new ze(nv,this,12,10)),Mr(this.c,h(i,13));return;case 13:!this.a&&(this.a=new sI(this,this)),O7(this.a),!this.a&&(this.a=new sI(this,this)),Mr(this.a,h(i,13));return;case 14:Pr(Vc(this)),Mr(Vc(this),h(i,13));return}Wl(this,t-jn((yt(),L1)),Wt((a=h(sn(this,16),24),a||L1),t),i)},p.Rg=function(){return yt(),L1},p.Xg=function(){var t,i;if(this.c)for(t=0,i=this.c.i;tv&&Gr(t,v,null),l=0,a=new Bn(Vc(this.a));a.e!=a.i._b();)i=h(Yn(a),84),g=(m=i.c,m||(yt(),zh)),Gr(t,l++,g);return t},p.ki=function(){var t,i,a,l,f;for(f=new Tp,f.a+="[",t=Vc(this.a),i=0,l=Vc(this.a).i;i1);case 5:return dA(this,5,i,a,l,this.i-h(a,15)._b()>0);default:return new Wd(this.e,t,this.c,i,a,l,!0)}},p.xi=function(){return!0},p.ui=function(){return wte(this)},p.ij=function(){Pr(this)};var kkn=k(Lt,"EOperationImpl/2",1388);A(456,1,{1631:1,456:1},gNe);var Rkn=k(Lt,"EPackageImpl/1",456);A(18,88,Ho,ze),p.Lj=function(){return this.d},p.Mj=function(){return this.b},p.Pj=function(){return!0},p.b=0;var Ikn=k(or,"EObjectContainmentWithInverseEList",18);A(364,18,Ho,ZE),p.Qj=function(){return!0},p.zh=function(t,i){return Cx(this,t,h(i,51))};var Dkn=k(or,"EObjectContainmentWithInverseEList/Resolving",364);A(303,364,Ho,u_),p.th=function(){this.a.tb=null};var Bkn=k(Lt,"EPackageImpl/2",303);A(1155,1,{},tX);var Okn=k(Lt,"EPackageImpl/3",1155);A(650,44,Fx,fpe),p.Qb=function(t){return ws(t)?gQ(this,t):!!gc(this.d,t)};var Nkn=k(Lt,"EPackageRegistryImpl",650);A(468,268,{95:1,91:1,87:1,139:1,174:1,51:1,1703:1,103:1,431:1,42:1,92:1,142:1,468:1,268:1,107:1,108:1},aK),p.jg=function(t){return XHe(this,t)},p.ug=function(t,i,a){var l,f,g;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.zb;case 2:return vt(),!!(this.Bb&256);case 3:return vt(),!!(this.Bb&512);case 4:return He(this.s);case 5:return He(this.t);case 6:return vt(),g=this.t,g>1||g==-1;case 7:return vt(),f=this.s,f>=1;case 8:return i?pu(this):this.r;case 9:return this.q;case 10:return this.Db>>16==10?h(this.Cb,53):null}return jl(this,t-jn((yt(),rv)),Wt((l=h(sn(this,16),24),l||rv),t),i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),ja(this.Ab,t,a);case 10:return this.Cb&&(a=(f=this.Db>>16,f>=0?XHe(this,a):this.Cb.Cg(this,-1-f,null,a))),Ml(this,t,10,a)}return g=h(Wt((l=h(sn(this,16),24),l||(yt(),rv)),i),61),g.aj().dj(this,Ya(this),i-jn((yt(),rv)),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a);case 9:return nQ(this,a);case 10:return Ml(this,null,10,a)}return f=h(Wt((l=h(sn(this,16),24),l||(yt(),rv)),i),61),f.aj().ej(this,Ya(this),i-jn((yt(),rv)),t,a)},p.Fg=function(t){var i,a,l;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return(this.Bb&256)==0;case 3:return(this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return l=this.t,l>1||l==-1;case 7:return a=this.s,a>=1;case 8:return!!this.r&&!this.q.e&&x0(this.q).i==0;case 9:return!!this.q&&!(this.r&&!this.q.e&&x0(this.q).i==0);case 10:return!!(this.Db>>16==10&&h(this.Cb,53))}return zl(this,t-jn((yt(),rv)),Wt((i=h(sn(this,16),24),i||rv),t))},p.Rg=function(){return yt(),rv};var Fkn=k(Lt,"EParameterImpl",468);A(62,418,{95:1,91:1,87:1,139:1,174:1,51:1,17:1,158:1,61:1,103:1,431:1,42:1,92:1,142:1,62:1,418:1,268:1,107:1,108:1,615:1},Jge),p.ug=function(t,i,a){var l,f,g,m;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.zb;case 2:return vt(),!!(this.Bb&256);case 3:return vt(),!!(this.Bb&512);case 4:return He(this.s);case 5:return He(this.t);case 6:return vt(),m=this.t,m>1||m==-1;case 7:return vt(),f=this.s,f>=1;case 8:return i?pu(this):this.r;case 9:return this.q;case 10:return vt(),!!(this.Bb&tf);case 11:return vt(),!!(this.Bb&Dw);case 12:return vt(),!!(this.Bb&H0);case 13:return this.j;case 14:return NS(this);case 15:return vt(),!!(this.Bb&yc);case 16:return vt(),!!(this.Bb&Ah);case 17:return dw(this);case 18:return vt(),!!(this.Bb&Ja);case 19:return vt(),g=Uo(this),!!(g&&g.Bb&Ja);case 20:return vt(),!!(this.Bb&oo);case 21:return i?Uo(this):this.b;case 22:return i?vbe(this):Hze(this);case 23:return!this.a&&(this.a=new qE(Ly,this,23)),this.a}return jl(this,t-jn((yt(),TM)),Wt((l=h(sn(this,16),24),l||TM),t),i,a)},p.Fg=function(t){var i,a,l,f;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return(this.Bb&256)==0;case 3:return(this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return f=this.t,f>1||f==-1;case 7:return a=this.s,a>=1;case 8:return!!this.r&&!this.q.e&&x0(this.q).i==0;case 9:return!!this.q&&!(this.r&&!this.q.e&&x0(this.q).i==0);case 10:return(this.Bb&tf)==0;case 11:return(this.Bb&Dw)!=0;case 12:return(this.Bb&H0)!=0;case 13:return this.j!=null;case 14:return NS(this)!=null;case 15:return(this.Bb&yc)!=0;case 16:return(this.Bb&Ah)!=0;case 17:return!!dw(this);case 18:return(this.Bb&Ja)!=0;case 19:return l=Uo(this),!!l&&(l.Bb&Ja)!=0;case 20:return(this.Bb&oo)==0;case 21:return!!this.b;case 22:return!!Hze(this);case 23:return!!this.a&&this.a.i!=0}return zl(this,t-jn((yt(),TM)),Wt((i=h(sn(this,16),24),i||TM),t))},p.Mg=function(t,i){var a,l;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:SQ(this,ti(i));return;case 2:C_(this,ce(mt(i)));return;case 3:A_(this,ce(mt(i)));return;case 4:E_(this,h(i,21).a);return;case 5:mS(this,h(i,21).a);return;case 8:ES(this,h(i,133));return;case 9:l=Zg(this,h(i,84),null),l&&l.Th();return;case 10:OU(this,ce(mt(i)));return;case 11:BU(this,ce(mt(i)));return;case 12:FU(this,ce(mt(i)));return;case 13:mge(this,ti(i));return;case 15:NU(this,ce(mt(i)));return;case 16:UU(this,ce(mt(i)));return;case 18:aLt(this,ce(mt(i)));return;case 20:fWe(this,ce(mt(i)));return;case 21:h$e(this,h(i,17));return;case 23:!this.a&&(this.a=new qE(Ly,this,23)),Pr(this.a),!this.a&&(this.a=new qE(Ly,this,23)),Mr(this.a,h(i,13));return}Wl(this,t-jn((yt(),TM)),Wt((a=h(sn(this,16),24),a||TM),t),i)},p.Rg=function(){return yt(),TM},p.Xg=function(){vbe(this),iS(Vo((qc(),Zs),this)),pu(this),this.Bb|=1},p.$i=function(){return Uo(this)},p.Cj=function(){var t;return t=Uo(this),!!t&&(t.Bb&Ja)!=0},p.Dj=function(){return(this.Bb&Ja)!=0},p.Ej=function(){return(this.Bb&oo)!=0},p.zj=function(t,i){return this.c=null,Bbe(this,t,i)},p.Ib=function(){var t;return this.Db&64?L7(this):(t=new su(L7(this)),t.a+=" (containment: ",Ap(t,(this.Bb&Ja)!=0),t.a+=", resolveProxies: ",Ap(t,(this.Bb&oo)!=0),t.a+=")",t.a)};var Ukn=k(Lt,"EReferenceImpl",62);A(505,108,{95:1,38:1,91:1,87:1,134:1,51:1,103:1,42:1,92:1,505:1,107:1,108:1},EN),p.Fb=function(t){return this===t},p.kc=function(){return this.b},p.lc=function(){return this.c},p.Hb=function(){return m0(this)},p.kh=function(t){eAt(this,ti(t))},p.mc=function(t){return $Ct(this,ti(t))},p.ug=function(t,i,a){var l;switch(t){case 0:return this.b;case 1:return this.c}return jl(this,t-jn((yt(),zo)),Wt((l=h(sn(this,16),24),l||zo),t),i,a)},p.Fg=function(t){var i;switch(t){case 0:return this.b!=null;case 1:return this.c!=null}return zl(this,t-jn((yt(),zo)),Wt((i=h(sn(this,16),24),i||zo),t))},p.Mg=function(t,i){var a;switch(t){case 0:tAt(this,ti(i));return;case 1:s$e(this,ti(i));return}Wl(this,t-jn((yt(),zo)),Wt((a=h(sn(this,16),24),a||zo),t),i)},p.Rg=function(){return yt(),zo},p.ih=function(){var t;return this.a==-1&&(t=this.b,this.a=t==null?0:Hg(t)),this.a},p.jh=function(t){this.a=t},p.Ib=function(){var t;return this.Db&64?Ku(this):(t=new su(Ku(this)),t.a+=" (key: ",ho(t,this.b),t.a+=", value: ",ho(t,this.c),t.a+=")",t.a)},p.a=-1,p.b=null,p.c=null;var Aa=k(Lt,"EStringToStringMapEntryImpl",505),nut=_r(or,"FeatureMap/Entry/Internal");A(514,1,Sz),p.$j=function(t){return this._j(h(t,42))},p._j=function(t){return this.$j(t)},p.Fb=function(t){var i,a;return this===t?!0:re(t,75)?(i=h(t,75),i.nj()==this.c?(a=this.lc(),a==null?i.lc()==null:ki(a,i.lc())):!1):!1},p.nj=function(){return this.c},p.Hb=function(){var t;return t=this.lc(),Hr(this.c)^(t==null?0:Hr(t))},p.Ib=function(){var t,i;return t=this.c,i=$l(t.Wi()).fh(),t.be(),(i!=null&&i.length!=0?i+":"+t.be():t.be())+"="+this.lc()};var zkn=k(Lt,"EStructuralFeatureImpl/BasicFeatureMapEntry",514);A(709,514,Sz,ome),p._j=function(t){return new ome(this.c,t)},p.lc=function(){return this.a},p.ak=function(t,i,a){return URt(this,t,this.a,i,a)},p.bk=function(t,i,a){return zRt(this,t,this.a,i,a)};var Gkn=k(Lt,"EStructuralFeatureImpl/ContainmentUpdatingFeatureMapEntry",709);A(1363,1,{},mNe),p.cj=function(t,i,a,l,f){var g;return g=h(AI(t,this.b),237),g.yk(this.a).hj(l)},p.dj=function(t,i,a,l,f){var g;return g=h(AI(t,this.b),237),g.pk(this.a,l,f)},p.ej=function(t,i,a,l,f){var g;return g=h(AI(t,this.b),237),g.qk(this.a,l,f)},p.fj=function(t,i,a){var l;return l=h(AI(t,this.b),237),l.yk(this.a).ui()},p.gj=function(t,i,a,l){var f;f=h(AI(t,this.b),237),f.yk(this.a).Gc(l)};var jkn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateFeatureMapDelegator",1363);A(82,1,{},Ip,Vm,Np,qm),p.cj=function(t,i,a,l,f){var g;if(g=i.Tg(a),g==null&&i.Ug(a,g=z_e(this,t)),!f)switch(this.e){case 50:case 41:return h(g,533).Hi();case 40:return h(g,237).vk()}return g},p.dj=function(t,i,a,l,f){var g,m;return m=i.Tg(a),m==null&&i.Ug(a,m=z_e(this,t)),g=h(m,64).xj(l,f),g},p.ej=function(t,i,a,l,f){var g;return g=i.Tg(a),g!=null&&(f=h(g,64).yj(l,f)),f},p.fj=function(t,i,a){var l;return l=i.Tg(a),l!=null&&h(l,81).ui()},p.gj=function(t,i,a,l){var f;f=h(i.Tg(a),81),!f&&i.Ug(a,f=z_e(this,t)),f.Gc(l)},p.b=0,p.e=0;var $kn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateMany",82);A(461,1,{}),p.dj=function(t,i,a,l,f){throw Y(new Pi)},p.ej=function(t,i,a,l,f){throw Y(new Pi)};var gm,Vkn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingle",461);A(702,461,{},j1e),p.cj=function(t,i,a,l,f){return ane(t,t.yg(),t.og())==this.b?this.Ej()&&l?Xte(t):t.yg():null},p.dj=function(t,i,a,l,f){var g,m;return t.yg()&&(f=(g=t.og(),g>=0?t.jg(f):t.yg().Cg(t,-1-g,null,f))),m=br(t.mg(),this.e),t.lg(l,m,f)},p.ej=function(t,i,a,l,f){var g;return g=br(t.mg(),this.e),t.lg(null,g,f)},p.fj=function(t,i,a){var l;return l=br(t.mg(),this.e),!!t.yg()&&t.og()==l},p.gj=function(t,i,a,l){var f,g,m,v,y;if(l!=null&&!hne(this.a,l))throw Y(new xC(Mz+(re(l,51)?Vwe(h(l,51).mg()):N0e(sl(l)))+Tz+this.a+"'"));if(f=t.yg(),m=br(t.mg(),this.e),Be(l)!==Be(f)||t.og()!=m&&l!=null){if(LS(t,h(l,51)))throw Y(new un(LP+t.Ib()));y=null,f&&(y=(g=t.og(),g>=0?t.jg(null):t.yg().Cg(t,-1-g,null,null))),v=h(l,42),v&&(y=v.Ag(t,br(v.mg(),this.b),null,y)),y=t.lg(v,m,y),y&&y.Th()}else t.eg()&&t.fg()&&Li(t,new ls(t,1,m,l,l))},p.Ej=function(){return!1};var Wkn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleContainer",702);A(1364,702,{},Y8e),p.Ej=function(){return!0};var Hkn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleContainerResolving",1364);A(512,461,{}),p.cj=function(t,i,a,l,f){var g;return g=i.Tg(a),g==null?this.b:Be(g)===Be(gm)?null:g},p.fj=function(t,i,a){var l;return l=i.Tg(a),l!=null&&(Be(l)===Be(gm)||!ki(l,this.b))},p.gj=function(t,i,a,l){var f,g;t.eg()&&t.fg()?(f=(g=i.Tg(a),g==null?this.b:Be(g)===Be(gm)?null:g),l==null?this.c!=null?(i.Ug(a,null),l=this.b):this.b!=null?i.Ug(a,gm):i.Ug(a,null):(this.ck(l),i.Ug(a,l)),Li(t,this.d.dk(t,1,this.e,f,l))):l==null?this.c!=null?i.Ug(a,null):this.b!=null?i.Ug(a,gm):i.Ug(a,null):(this.ck(l),i.Ug(a,l))},p.ck=function(t){throw Y(new i8)};var qkn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData",512);A(ay,1,{},zk),p.dk=function(t,i,a,l,f){return new pI(t,i,a,l,f)},p.ek=function(t,i,a,l,f,g){return new I1e(t,i,a,l,f,g)};var GAe,jAe,$Ae,VAe,WAe,HAe,qAe,Bae,XAe,Xkn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator",ay);A(1379,ay,{},nX),p.dk=function(t,i,a,l,f){return new g0e(t,i,a,ce(mt(l)),ce(mt(f)))},p.ek=function(t,i,a,l,f,g){return new V7e(t,i,a,ce(mt(l)),ce(mt(f)),g)};var Ykn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/1",1379);A(1380,ay,{},Gk),p.dk=function(t,i,a,l,f){return new V0e(t,i,a,h(l,192).a,h(f,192).a)},p.ek=function(t,i,a,l,f,g){return new N7e(t,i,a,h(l,192).a,h(f,192).a,g)};var Zkn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/2",1380);A(1381,ay,{},SN),p.dk=function(t,i,a,l,f){return new W0e(t,i,a,h(l,159).a,h(f,159).a)},p.ek=function(t,i,a,l,f,g){return new F7e(t,i,a,h(l,159).a,h(f,159).a,g)};var Kkn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/3",1381);A(1382,ay,{},MN),p.dk=function(t,i,a,l,f){return new d0e(t,i,a,ce(Xe(l)),ce(Xe(f)))},p.ek=function(t,i,a,l,f,g){return new U7e(t,i,a,ce(Xe(l)),ce(Xe(f)),g)};var Jkn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/4",1382);A(1383,ay,{},TN),p.dk=function(t,i,a,l,f){return new X0e(t,i,a,h(l,126).a,h(f,126).a)},p.ek=function(t,i,a,l,f,g){return new z7e(t,i,a,h(l,126).a,h(f,126).a,g)};var Qkn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/5",1383);A(1384,ay,{},JT),p.dk=function(t,i,a,l,f){return new p0e(t,i,a,h(l,21).a,h(f,21).a)},p.ek=function(t,i,a,l,f,g){return new G7e(t,i,a,h(l,21).a,h(f,21).a,g)};var eRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/6",1384);A(1385,ay,{},iX),p.dk=function(t,i,a,l,f){return new H0e(t,i,a,h(l,149).a,h(f,149).a)},p.ek=function(t,i,a,l,f,g){return new j7e(t,i,a,h(l,149).a,h(f,149).a,g)};var tRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/7",1385);A(1386,ay,{},CN),p.dk=function(t,i,a,l,f){return new q0e(t,i,a,h(l,168).a,h(f,168).a)},p.ek=function(t,i,a,l,f,g){return new $7e(t,i,a,h(l,168).a,h(f,168).a,g)};var nRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/8",1386);A(1366,512,{},kUe),p.ck=function(t){if(!this.a.Li(t))throw Y(new xC(Mz+sl(t)+Tz+this.a+"'"))};var iRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleDataDynamic",1366);A(1367,512,{},B9e),p.ck=function(t){};var rRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleDataStatic",1367);A(703,512,{}),p.fj=function(t,i,a){var l;return l=i.Tg(a),l!=null},p.gj=function(t,i,a,l){var f,g;t.eg()&&t.fg()?(f=!0,g=i.Tg(a),g==null?(f=!1,g=this.b):Be(g)===Be(gm)&&(g=null),l==null?this.c!=null?(i.Ug(a,null),l=this.b):i.Ug(a,gm):(this.ck(l),i.Ug(a,l)),Li(t,this.d.ek(t,1,this.e,g,l,!f))):l==null?this.c!=null?i.Ug(a,null):i.Ug(a,gm):(this.ck(l),i.Ug(a,l))};var sRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleDataUnsettable",703);A(1368,703,{},RUe),p.ck=function(t){if(!this.a.Li(t))throw Y(new xC(Mz+sl(t)+Tz+this.a+"'"))};var oRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleDataUnsettableDynamic",1368);A(1369,703,{},O9e),p.ck=function(t){};var aRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleDataUnsettableStatic",1369);A(370,461,{},M9),p.cj=function(t,i,a,l,f){var g,m,v,y,E;if(E=i.Tg(a),this.Zi()&&Be(E)===Be(gm))return null;if(this.Ej()&&l&&E!=null){if(v=h(E,42),v.Eg()&&(y=jg(t,v),v!=y)){if(!hne(this.a,y))throw Y(new xC(Mz+sl(y)+Tz+this.a+"'"));i.Ug(a,E=y),this.Dj()&&(g=h(y,42),m=v.Cg(t,this.b?br(v.mg(),this.b):-1-br(t.mg(),this.e),null,null),!g.yg()&&(m=g.Ag(t,this.b?br(g.mg(),this.b):-1-br(t.mg(),this.e),null,m)),m&&m.Th()),t.eg()&&t.fg()&&Li(t,new pI(t,9,this.e,v,y))}return E}else return E},p.dj=function(t,i,a,l,f){var g,m;return m=i.Tg(a),Be(m)===Be(gm)&&(m=null),i.Ug(a,l),this.qi()?Be(m)!==Be(l)&&m!=null&&(g=h(m,42),f=g.Cg(t,br(g.mg(),this.b),null,f)):this.Dj()&&m!=null&&(f=h(m,42).Cg(t,-1-br(t.mg(),this.e),null,f)),t.eg()&&t.fg()&&(!f&&(f=new Eg(4)),f.Sh(new pI(t,1,this.e,m,l))),f},p.ej=function(t,i,a,l,f){var g;return g=i.Tg(a),Be(g)===Be(gm)&&(g=null),i.Vg(a),t.eg()&&t.fg()&&(!f&&(f=new Eg(4)),this.Zi()?f.Sh(new pI(t,2,this.e,g,null)):f.Sh(new pI(t,1,this.e,g,null))),f},p.fj=function(t,i,a){var l;return l=i.Tg(a),l!=null},p.gj=function(t,i,a,l){var f,g,m,v,y;if(l!=null&&!hne(this.a,l))throw Y(new xC(Mz+(re(l,51)?Vwe(h(l,51).mg()):N0e(sl(l)))+Tz+this.a+"'"));y=i.Tg(a),v=y!=null,this.Zi()&&Be(y)===Be(gm)&&(y=null),m=null,this.qi()?Be(y)!==Be(l)&&(y!=null&&(f=h(y,42),m=f.Cg(t,br(f.mg(),this.b),null,null)),l!=null&&(f=h(l,42),m=f.Ag(t,br(f.mg(),this.b),null,m))):this.Dj()&&Be(y)!==Be(l)&&(y!=null&&(m=h(y,42).Cg(t,-1-br(t.mg(),this.e),null,null)),l!=null&&(m=h(l,42).Ag(t,-1-br(t.mg(),this.e),null,m))),l==null&&this.Zi()?i.Ug(a,gm):i.Ug(a,l),t.eg()&&t.fg()?(g=new I1e(t,1,this.e,y,l,this.Zi()&&!v),m?(m.Sh(g),m.Th()):Li(t,g)):m&&m.Th()},p.qi=function(){return!1},p.Dj=function(){return!1},p.Ej=function(){return!1},p.Zi=function(){return!1};var cRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObject",370);A(513,370,{},_J),p.Dj=function(){return!0};var lRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainment",513);A(1372,513,{},WFe),p.Ej=function(){return!0};var uRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentResolving",1372);A(705,513,{},Yge),p.Zi=function(){return!0};var fRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentUnsettable",705);A(1374,705,{},HFe),p.Ej=function(){return!0};var hRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentUnsettableResolving",1374);A(585,513,{},OJ),p.qi=function(){return!0};var dRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverse",585);A(1373,585,{},Z8e),p.Ej=function(){return!0};var pRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverseResolving",1373);A(706,585,{},Lme),p.Zi=function(){return!0};var gRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverseUnsettable",706);A(1375,706,{},K8e),p.Ej=function(){return!0};var mRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverseUnsettableResolving",1375);A(586,370,{},Xge),p.Ej=function(){return!0};var bRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolving",586);A(1376,586,{},qFe),p.Zi=function(){return!0};var wRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolvingUnsettable",1376);A(707,586,{},Pme),p.qi=function(){return!0};var vRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolvingWithInverse",707);A(1377,707,{},J8e),p.Zi=function(){return!0};var _Rn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolvingWithInverseUnsettable",1377);A(1370,370,{},XFe),p.Zi=function(){return!0};var yRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectUnsettable",1370);A(704,370,{},kme),p.qi=function(){return!0};var xRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectWithInverse",704);A(1371,704,{},Q8e),p.Zi=function(){return!0};var ERn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectWithInverseUnsettable",1371);A(708,514,Sz,y1e),p._j=function(t){return new y1e(this.a,this.c,t)},p.lc=function(){return this.b},p.ak=function(t,i,a){return tkt(this,t,this.b,a)},p.bk=function(t,i,a){return nkt(this,t,this.b,a)};var SRn=k(Lt,"EStructuralFeatureImpl/InverseUpdatingFeatureMapEntry",708);A(1378,514,Sz,Fze),p.$j=function(t){return new MJ((lr(),MD),this.b.Zg(this.a,t))},p.lc=function(){return null},p.ak=function(t,i,a){return a},p.bk=function(t,i,a){return a};var MRn=k(Lt,"EStructuralFeatureImpl/SimpleContentFeatureMapEntry",1378);A(587,514,Sz,MJ),p.$j=function(t){return new MJ(this.c,t)},p.lc=function(){return this.a},p.ak=function(t,i,a){return a},p.bk=function(t,i,a){return a};var TRn=k(Lt,"EStructuralFeatureImpl/SimpleFeatureMapEntry",587);A(361,451,Ih,qb),p.Fh=function(t){return le(Lu,et,24,t,0,1)},p.Bh=function(){return!1};var CRn=k(Lt,"ESuperAdapter/1",361);A(411,399,{95:1,91:1,87:1,139:1,174:1,51:1,103:1,742:1,42:1,92:1,142:1,411:1,107:1,108:1},jk),p.ug=function(t,i,a){var l;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.zb;case 2:return!this.a&&(this.a=new dI(this,ko,this)),this.a}return jl(this,t-jn((yt(),Ry)),Wt((l=h(sn(this,16),24),l||Ry),t),i,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a);case 2:return!this.a&&(this.a=new dI(this,ko,this)),Us(this.a,t,a)}return f=h(Wt((l=h(sn(this,16),24),l||(yt(),Ry)),i),61),f.aj().ej(this,Ya(this),i-jn((yt(),Ry)),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return!!this.a&&this.a.i!=0}return zl(this,t-jn((yt(),Ry)),Wt((i=h(sn(this,16),24),i||Ry),t))},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:Sf(this,ti(i));return;case 2:!this.a&&(this.a=new dI(this,ko,this)),Pr(this.a),!this.a&&(this.a=new dI(this,ko,this)),Mr(this.a,h(i,13));return}Wl(this,t-jn((yt(),Ry)),Wt((a=h(sn(this,16),24),a||Ry),t),i)},p.Rg=function(){return yt(),Ry};var ARn=k(Lt,"ETypeParameterImpl",411);A(457,88,Ho,dI),p.ri=function(t,i){return VBt(this,h(t,84),i)},p.si=function(t,i){return WBt(this,h(t,84),i)};var PRn=k(Lt,"ETypeParameterImpl/1",457);A(579,44,Fx,lK),p.Xb=function(){return new bC(this)};var LRn=k(Lt,"ETypeParameterImpl/2",579);A(508,fd,gu,bC),p.nc=function(t){return n8e(this,h(t,84))},p.oc=function(t){var i,a,l;for(l=!1,a=t.tc();a.hc();)i=h(a.ic(),84),dr(this.a,i,"")==null&&(l=!0);return l},p.Pb=function(){nl(this.a)},p.pc=function(t){return v0(this.a,t)},p.tc=function(){var t;return t=new Zm(new Ep(this.a).a),new wC(t)},p.vc=function(t){return qze(this,t)},p._b=function(){return OE(this.a)};var kRn=k(Lt,"ETypeParameterImpl/2/1",508);A(509,1,ys,wC),p.gc=function(t){Ss(this,t)},p.ic=function(){return h(k0(this.a).kc(),84)},p.hc=function(){return this.a.b},p.jc=function(){RGe(this.a)};var RRn=k(Lt,"ETypeParameterImpl/2/1/1",509);A(1169,44,Fx,LDe),p.Qb=function(t){return ws(t)?gQ(this,t):!!gc(this.d,t)},p.Vb=function(t){var i,a;return i=ws(t)?za(this,t):Dc(gc(this.d,t)),re(i,743)?(a=h(i,743),i=a.mj(),dr(this,h(t,207),i),i):i??(t==null?(yK(),rut):null)};var IRn=k(Lt,"EValidatorRegistryImpl",1169);A(1362,638,{95:1,91:1,87:1,430:1,139:1,51:1,103:1,1635:1,42:1,92:1,142:1,107:1,108:1},AN),p.Zg=function(t,i){switch(t.Ni()){case 21:case 22:case 23:case 24:case 26:case 31:case 32:case 37:case 38:case 39:case 40:case 43:case 44:case 48:case 49:case 20:return i==null?null:Ga(i);case 25:return cRt(i);case 27:return Skt(i);case 28:return Mkt(i);case 29:return i==null?null:sFe(RL[0],h(i,181));case 41:return i==null?"":Um(h(i,274));case 42:return Ga(i);case 50:return ti(i);default:throw Y(new un(eM+t.be()+Y0))}},p.$g=function(t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee;switch(t.G==-1&&(t.G=(B=$l(t),B?$p(B.bh(),t):-1)),t.G){case 0:return a=new cK,a;case 1:return i=new _N,i;case 2:return l=new lR,l;case 4:return f=new S,f;case 5:return g=new ADe,g;case 6:return m=new CR,m;case 7:return v=new hF,v;case 10:return E=new Bu,E;case 11:return C=new oK,C;case 12:return R=new UUe,R;case 13:return N=new aK,N;case 14:return W=new Jge,W;case 17:return V=new EN,V;case 18:return y=new xg,y;case 19:return ee=new jk,ee;default:throw Y(new un(bre+t.zb+Y0))}},p._g=function(t,i){switch(t.Ni()){case 20:return i==null?null:new mpe(i);case 21:return i==null?null:new Tg(i);case 23:case 22:return i==null?null:Q6t(i);case 26:case 24:return i==null?null:LI(Sl(i,-128,127)<<24>>24);case 25:return kFt(i);case 27:return iDt(i);case 28:return rDt(i);case 29:return COt(i);case 32:case 31:return i==null?null:xw(i);case 38:case 37:return i==null?null:new yC(i);case 40:case 39:return i==null?null:He(Sl(i,zs,zi));case 41:return null;case 42:return i==null,null;case 44:case 43:return i==null?null:n1(F7(i));case 49:case 48:return i==null?null:xS(Sl(i,Cz,32767)<<16>>16);case 50:return i;default:throw Y(new un(eM+t.be()+Y0))}};var DRn=k(Lt,"EcoreFactoryImpl",1362);A(504,248,{95:1,91:1,87:1,139:1,174:1,51:1,207:1,103:1,1633:1,42:1,92:1,142:1,248:1,504:1,107:1,108:1,613:1},bUe),p.gb=!1,p.hb=!1;var YAe,iut=!1,BRn=k(Lt,"EcorePackageImpl",504);A(1111,1,{743:1},rX),p.mj=function(){return hFe(),sut};var ORn=k(Lt,"EcorePackageImpl/1",1111);A(1120,1,li,$k),p.Li=function(t){return re(t,139)},p.Mi=function(t){return le(mD,et,139,t,0,1)};var NRn=k(Lt,"EcorePackageImpl/10",1120);A(1121,1,li,PN),p.Li=function(t){return re(t,174)},p.Mi=function(t){return le(Tae,et,174,t,0,1)};var FRn=k(Lt,"EcorePackageImpl/11",1121);A(1122,1,li,Vk),p.Li=function(t){return re(t,51)},p.Mi=function(t){return le(Qw,et,51,t,0,1)};var URn=k(Lt,"EcorePackageImpl/12",1122);A(1123,1,li,sX),p.Li=function(t){return re(t,371)},p.Mi=function(t){return le(uf,Fxe,53,t,0,1)};var zRn=k(Lt,"EcorePackageImpl/13",1123);A(1124,1,li,Wk),p.Li=function(t){return re(t,207)},p.Mi=function(t){return le(ah,et,207,t,0,1)};var GRn=k(Lt,"EcorePackageImpl/14",1124);A(1125,1,li,ro),p.Li=function(t){return re(t,468)},p.Mi=function(t){return le(nv,et,1703,t,0,1)};var jRn=k(Lt,"EcorePackageImpl/15",1125);A(1126,1,li,oX),p.Li=function(t){return re(t,62)},p.Mi=function(t){return le(iv,oy,17,t,0,1)};var $Rn=k(Lt,"EcorePackageImpl/16",1126);A(1127,1,li,aX),p.Li=function(t){return re(t,158)},p.Mi=function(t){return le(Sc,oy,158,t,0,1)};var VRn=k(Lt,"EcorePackageImpl/17",1127);A(1128,1,li,vE),p.Li=function(t){return re(t,431)},p.Mi=function(t){return le(tv,et,431,t,0,1)};var WRn=k(Lt,"EcorePackageImpl/18",1128);A(1129,1,li,LN),p.Li=function(t){return re(t,505)},p.Mi=function(t){return le(Aa,_tt,505,t,0,1)};var HRn=k(Lt,"EcorePackageImpl/19",1129);A(1112,1,li,cX),p.Li=function(t){return re(t,335)},p.Mi=function(t){return le(Ly,oy,29,t,0,1)};var qRn=k(Lt,"EcorePackageImpl/2",1112);A(1130,1,li,lX),p.Li=function(t){return re(t,217)},p.Mi=function(t){return le(ko,Ntt,84,t,0,1)};var XRn=k(Lt,"EcorePackageImpl/20",1130);A(1131,1,li,xp),p.Li=function(t){return re(t,411)},p.Mi=function(t){return le(fl,et,742,t,0,1)};var YRn=k(Lt,"EcorePackageImpl/21",1131);A(1132,1,li,uX),p.Li=function(t){return ow(t)},p.Mi=function(t){return le(lo,be,434,t,8,1)};var ZRn=k(Lt,"EcorePackageImpl/22",1132);A(1133,1,li,QT),p.Li=function(t){return re(t,173)},p.Mi=function(t){return le(Mc,be,173,t,0,2)};var KRn=k(Lt,"EcorePackageImpl/23",1133);A(1134,1,li,Hk),p.Li=function(t){return re(t,192)},p.Mi=function(t){return le(qx,be,192,t,0,1)};var JRn=k(Lt,"EcorePackageImpl/24",1134);A(1135,1,li,kN),p.Li=function(t){return re(t,159)},p.Mi=function(t){return le($P,be,159,t,0,1)};var QRn=k(Lt,"EcorePackageImpl/25",1135);A(1136,1,li,RN),p.Li=function(t){return re(t,181)},p.Mi=function(t){return le(zz,be,181,t,0,1)};var eIn=k(Lt,"EcorePackageImpl/26",1136);A(1137,1,li,Ld),p.Li=function(t){return!1},p.Mi=function(t){return le(dPe,et,1787,t,0,1)};var tIn=k(Lt,"EcorePackageImpl/27",1137);A(1138,1,li,Xb),p.Li=function(t){return aw(t)},p.Mi=function(t){return le(Eo,be,315,t,7,1)};var nIn=k(Lt,"EcorePackageImpl/28",1138);A(1139,1,li,qk),p.Li=function(t){return re(t,52)},p.Mi=function(t){return le(AAe,Lw,52,t,0,1)};var iIn=k(Lt,"EcorePackageImpl/29",1139);A(1113,1,li,IN),p.Li=function(t){return re(t,469)},p.Mi=function(t){return le(Ri,{3:1,4:1,5:1,1627:1},609,t,0,1)};var rIn=k(Lt,"EcorePackageImpl/3",1113);A(1140,1,li,eC),p.Li=function(t){return re(t,525)},p.Mi=function(t){return le(kAe,et,1634,t,0,1)};var sIn=k(Lt,"EcorePackageImpl/30",1140);A(1141,1,li,DN),p.Li=function(t){return re(t,184)},p.Mi=function(t){return le(ePe,Lw,184,t,0,1)};var oIn=k(Lt,"EcorePackageImpl/31",1141);A(1142,1,li,Xk),p.Li=function(t){return re(t,75)},p.Mi=function(t){return le(Nj,Htt,75,t,0,1)};var aIn=k(Lt,"EcorePackageImpl/32",1142);A(1143,1,li,BN),p.Li=function(t){return re(t,126)},p.Mi=function(t){return le(aM,be,126,t,0,1)};var cIn=k(Lt,"EcorePackageImpl/33",1143);A(1144,1,li,Yk),p.Li=function(t){return re(t,21)},p.Mi=function(t){return le(Po,be,21,t,0,1)};var lIn=k(Lt,"EcorePackageImpl/34",1144);A(1145,1,li,Zk),p.Li=function(t){return re(t,274)},p.Mi=function(t){return le(Kxe,et,274,t,0,1)};var uIn=k(Lt,"EcorePackageImpl/35",1145);A(1146,1,li,Yb),p.Li=function(t){return re(t,149)},p.Mi=function(t){return le(J0,be,149,t,0,1)};var fIn=k(Lt,"EcorePackageImpl/36",1146);A(1147,1,li,fX),p.Li=function(t){return re(t,109)},p.Mi=function(t){return le(Jxe,et,109,t,0,1)};var hIn=k(Lt,"EcorePackageImpl/37",1147);A(1148,1,li,Zb),p.Li=function(t){return re(t,534)},p.Mi=function(t){return le(ZAe,et,534,t,0,1)};var dIn=k(Lt,"EcorePackageImpl/38",1148);A(1149,1,li,ON),p.Li=function(t){return!1},p.Mi=function(t){return le(pPe,et,1788,t,0,1)};var pIn=k(Lt,"EcorePackageImpl/39",1149);A(1114,1,li,NN),p.Li=function(t){return re(t,96)},p.Mi=function(t){return le(Lu,et,24,t,0,1)};var gIn=k(Lt,"EcorePackageImpl/4",1114);A(1150,1,li,Kk),p.Li=function(t){return re(t,168)},p.Mi=function(t){return le(Q0,be,168,t,0,1)};var mIn=k(Lt,"EcorePackageImpl/40",1150);A(1151,1,li,hX),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var bIn=k(Lt,"EcorePackageImpl/41",1151);A(1152,1,li,dX),p.Li=function(t){return re(t,532)},p.Mi=function(t){return le(LAe,et,532,t,0,1)};var wIn=k(Lt,"EcorePackageImpl/42",1152);A(1153,1,li,pX),p.Li=function(t){return!1},p.Mi=function(t){return le(gPe,be,1789,t,0,1)};var vIn=k(Lt,"EcorePackageImpl/43",1153);A(1154,1,li,FN),p.Li=function(t){return re(t,38)},p.Mi=function(t){return le(cy,et,38,t,0,1)};var _In=k(Lt,"EcorePackageImpl/44",1154);A(1115,1,li,UN),p.Li=function(t){return re(t,133)},p.Mi=function(t){return le(ch,et,133,t,0,1)};var yIn=k(Lt,"EcorePackageImpl/5",1115);A(1116,1,li,gX),p.Li=function(t){return re(t,140)},p.Mi=function(t){return le(Rae,et,140,t,0,1)};var xIn=k(Lt,"EcorePackageImpl/6",1116);A(1117,1,li,zN),p.Li=function(t){return re(t,425)},p.Mi=function(t){return le(Oj,et,608,t,0,1)};var EIn=k(Lt,"EcorePackageImpl/7",1117);A(1118,1,li,GN),p.Li=function(t){return re(t,525)},p.Mi=function(t){return le(eg,et,617,t,0,1)};var SIn=k(Lt,"EcorePackageImpl/8",1118);A(1119,1,li,Xh),p.Li=function(t){return re(t,430)},p.Mi=function(t){return le(kL,et,430,t,0,1)};var MIn=k(Lt,"EcorePackageImpl/9",1119);A(915,1673,vtt,VDe),p.sh=function(t,i){PIt(this,h(i,380))},p.vh=function(t,i){Vqe(this,t,h(i,380))};var TIn=k(Lt,"MinimalEObjectImpl/1ArrayDelegatingAdapterList",915);A(916,136,o5,oUe),p.Oh=function(){return this.a.a};var CIn=k(Lt,"MinimalEObjectImpl/1ArrayDelegatingAdapterList/1",916);A(955,954,{},ZNe);var AIn=k("org.eclipse.emf.ecore.plugin","EcorePlugin",955),ZAe=_r(qtt,"Resource");A(719,1492,Xtt),p.ik=function(t){},p.jk=function(t){},p.fk=function(){return!this.a&&(this.a=new MR(this)),this.a},p.gk=function(t){var i,a,l,f,g;if(l=t.length,l>0)if(t.charCodeAt(0)==47){for(g=new Gl(4),f=1,i=1;i0&&(t=t.substr(0,a)));return aFt(this,t)},p.hk=function(){return this.c},p.Ib=function(){return Um(this.ql)+"@"+(Hr(this)>>>0).toString(16)+" uri='"+this.d+"'"},p.b=!1;var PIn=k(Rre,"ResourceImpl",719);A(1493,719,Xtt,JZ);var LIn=k(Rre,"BinaryResourceImpl",1493);A(1048,629,Tre),p.Gh=function(t){return re(t,51)?kPt(this,h(t,51)):re(t,534)?new Bn(h(t,534).fk()):Be(t)===Be(this.f)?h(t,13).tc():(tA(),vD.a)},p.hc=function(){return Sve(this)},p.a=!1;var kIn=k(or,"EcoreUtil/ContentTreeIterator",1048);A(1494,1048,Tre,j9e),p.Gh=function(t){return Be(t)===Be(this.f)?h(t,15).tc():new lze(h(t,51))};var RIn=k(Rre,"ResourceImpl/5",1494);A(595,1687,Ott,MR),p.pc=function(t){return this.i<=4?QA(this,t):re(t,42)&&h(t,42).sg()==this.a},p.sh=function(t,i){t==this.i-1&&(this.a.b||(this.a.b=!0))},p.uh=function(t,i){t==0?this.a.b||(this.a.b=!0):GQ(this,t,i)},p.vh=function(t,i){},p.wh=function(t,i,a){},p.pi=function(){return 2},p.Oh=function(){return this.a},p.qi=function(){return!0},p.ri=function(t,i){var a;return a=h(t,42),i=a.Pg(this.a,i),i},p.si=function(t,i){var a;return a=h(t,42),a.Pg(null,i)},p.ti=function(){return!1},p.xh=function(){return!0},p.Fh=function(t){return le(Qw,et,51,t,0,1)},p.Bh=function(){return!1};var IIn=k(Rre,"ResourceImpl/ContentsEList",595);A(873,1657,Ix,TR),p.fd=function(t){return this.a.qh(t)},p._b=function(){return this.a._b()};var DIn=k(or,"AbstractSequentialInternalEList/1",873),KAe,JAe,Zs,QAe;A(567,1,{},l9e);var Fj,Uj,BIn=k(or,"BasicExtendedMetaData",567);A(1023,1,{},bNe),p.kk=function(){return null},p.lk=function(){return this.a==-2&&Rde(this,AOt(this.d,this.b)),this.a},p.mk=function(){return null},p.nk=function(){return _t(),_t(),uo},p.be=function(){return this.c==iM&&gY(this,tHe(this.d,this.b)),this.c},p.ok=function(){return 0},p.a=-2,p.c=iM;var OIn=k(or,"BasicExtendedMetaData/EClassExtendedMetaDataImpl",1023);A(tf,1,{},H7e),p.kk=function(){return this.a==(fS(),Fj)&&Ide(this,$9t(this.f,this.b)),this.a},p.lk=function(){return 0},p.mk=function(){return this.c==(fS(),Fj)&&mY(this,V9t(this.f,this.b)),this.c},p.nk=function(){return!this.d&&Dde(this,x7t(this.f,this.b)),this.d},p.be=function(){return this.e==iM&&Bde(this,tHe(this.f,this.b)),this.e},p.ok=function(){return this.g==-2&&Ode(this,iOt(this.f,this.b)),this.g},p.e=iM,p.g=-2;var NIn=k(or,"BasicExtendedMetaData/EDataTypeExtendedMetaDataImpl",tf);A(1022,1,{},wNe),p.b=!1,p.c=!1;var FIn=k(or,"BasicExtendedMetaData/EPackageExtendedMetaDataImpl",1022);A(1025,1,{},q7e),p.c=-2,p.e=iM,p.f=iM;var UIn=k(or,"BasicExtendedMetaData/EStructuralFeatureExtendedMetaDataImpl",1025);A(529,565,Ho,b9),p.pi=function(){return this.c},p.Rj=function(){return!1},p.zh=function(t,i){return i},p.c=0;var zIn=k(or,"EDataTypeEList",529),ePe=_r(or,"FeatureMap");A(90,529,{3:1,4:1,20:1,25:1,41:1,13:1,15:1,49:1,59:1,55:1,52:1,81:1,184:1,237:1,1630:1,64:1},ps),p.bd=function(t,i){W8t(this,t,h(i,75))},p.nc=function(t){return T8t(this,h(t,75))},p.nh=function(t){jAt(this,h(t,75))},p.ri=function(t,i){return eTt(this,h(t,75),i)},p.si=function(t,i){return Mme(this,h(t,75),i)},p.zh=function(t,i){return _Gt(this,t,h(i,75))},p.hd=function(t,i){return y9t(this,t,h(i,75))},p.yi=function(t,i){return tTt(this,h(t,75),i)},p.zi=function(t,i){return F8e(this,h(t,75),i)},p.Ai=function(t,i,a){return dOt(this,h(t,75),h(i,75),a)},p.Ch=function(t,i){return Ite(this,t,h(i,75))},p.oc=function(t){var i,a,l,f,g,m,v,y,E;for(y=new w_(t._b()),l=t.tc();l.hc();)if(a=h(l.ic(),75),f=a.nj(),j0(this.e,f))(!f.xh()||!$Q(this,f,a.lc())&&!QA(y,a))&&$n(y,a);else{for(E=cl(this.e.mg(),f),i=h(this.g,124),g=!0,m=0;m=0;)if(i=t[this.c],this.k.Bk(i.nj()))return this.j=this.f?i:i.lc(),this.i=-2,!0;return this.i=-1,this.g=-1,!1};var $In=k(or,"BasicFeatureMap/FeatureEIterator",377);A(601,377,Ch,QK),p.Xj=function(){return!0};var VIn=k(or,"BasicFeatureMap/ResolvingFeatureEIterator",601);A(871,444,xz,oFe),p.Uh=function(){return this};var WIn=k(or,"EContentsEList/1",871);A(872,444,xz,PNe),p.Xj=function(){return!1};var HIn=k(or,"EContentsEList/2",872);A(870,260,Ez,aFe),p.Zj=function(t){},p.hc=function(){return!1},p.Cc=function(){return!1};var qIn=k(or,"EContentsEList/FeatureIteratorImpl/1",870);A(734,529,Ho,Rge),p.th=function(){this.a=!0},p.ui=function(){return this.a},p.ij=function(){var t;Pr(this),$u(this.e)?(t=this.a,this.a=!1,Li(this.e,new qu(this.e,2,this.c,t,!1))):this.a=!1},p.a=!1;var XIn=k(or,"EDataTypeEList/Unsettable",734);A(1566,529,Ho,mFe),p.xh=function(){return!0};var YIn=k(or,"EDataTypeUniqueEList",1566);A(1567,734,Ho,bFe),p.xh=function(){return!0};var ZIn=k(or,"EDataTypeUniqueEList/Unsettable",1567);A(156,88,Ho,Nl),p.Qj=function(){return!0},p.zh=function(t,i){return Cx(this,t,h(i,51))};var KIn=k(or,"EObjectContainmentEList/Resolving",156);A(1026,493,Ho,gFe),p.Qj=function(){return!0},p.zh=function(t,i){return Cx(this,t,h(i,51))};var JIn=k(or,"EObjectContainmentEList/Unsettable/Resolving",1026);A(679,18,Ho,pme),p.th=function(){this.a=!0},p.ui=function(){return this.a},p.ij=function(){var t;Pr(this),$u(this.e)?(t=this.a,this.a=!1,Li(this.e,new qu(this.e,2,this.c,t,!1))):this.a=!1},p.a=!1;var QIn=k(or,"EObjectContainmentWithInverseEList/Unsettable",679);A(1044,679,Ho,v8e),p.Qj=function(){return!0},p.zh=function(t,i){return Cx(this,t,h(i,51))};var e6n=k(or,"EObjectContainmentWithInverseEList/Unsettable/Resolving",1044);A(675,450,Ho,Ige),p.th=function(){this.a=!0},p.ui=function(){return this.a},p.ij=function(){var t;Pr(this),$u(this.e)?(t=this.a,this.a=!1,Li(this.e,new qu(this.e,2,this.c,t,!1))):this.a=!1},p.a=!1;var t6n=k(or,"EObjectEList/Unsettable",675);A(376,450,Ho,qE),p.Qj=function(){return!0},p.zh=function(t,i){return Cx(this,t,h(i,51))};var n6n=k(or,"EObjectResolvingEList",376);A(1554,675,Ho,wFe),p.Qj=function(){return!0},p.zh=function(t,i){return Cx(this,t,h(i,51))};var i6n=k(or,"EObjectResolvingEList/Unsettable",1554);A(1495,1,{},Bm);var rut,r6n=k(or,"EObjectValidator",1495);A(496,450,Ho,D9),p.Lj=function(){return this.d},p.Mj=function(){return this.b},p.qi=function(){return!0},p.Pj=function(){return!0},p.b=0;var s6n=k(or,"EObjectWithInverseEList",496);A(1047,496,Ho,_8e),p.Oj=function(){return!0};var o6n=k(or,"EObjectWithInverseEList/ManyInverse",1047);A(572,496,Ho,AJ),p.th=function(){this.a=!0},p.ui=function(){return this.a},p.ij=function(){var t;Pr(this),$u(this.e)?(t=this.a,this.a=!1,Li(this.e,new qu(this.e,2,this.c,t,!1))):this.a=!1},p.a=!1;var a6n=k(or,"EObjectWithInverseEList/Unsettable",572);A(1046,572,Ho,y8e),p.Oj=function(){return!0};var c6n=k(or,"EObjectWithInverseEList/Unsettable/ManyInverse",1046);A(680,496,Ho,gme),p.Qj=function(){return!0},p.zh=function(t,i){return Cx(this,t,h(i,51))};var l6n=k(or,"EObjectWithInverseResolvingEList",680);A(33,680,Ho,an),p.Oj=function(){return!0};var u6n=k(or,"EObjectWithInverseResolvingEList/ManyInverse",33);A(681,572,Ho,mme),p.Qj=function(){return!0},p.zh=function(t,i){return Cx(this,t,h(i,51))};var f6n=k(or,"EObjectWithInverseResolvingEList/Unsettable",681);A(1045,681,Ho,x8e),p.Oj=function(){return!0};var h6n=k(or,"EObjectWithInverseResolvingEList/Unsettable/ManyInverse",1045);A(1027,565,Ho),p.rh=function(){return(this.b&1792)==0},p.th=function(){this.b|=1},p.Nj=function(){return(this.b&4)!=0},p.qi=function(){return(this.b&40)!=0},p.Oj=function(){return(this.b&16)!=0},p.Pj=function(){return(this.b&8)!=0},p.Qj=function(){return(this.b&Dw)!=0},p.Dj=function(){return(this.b&32)!=0},p.Rj=function(){return(this.b&tf)!=0},p.Li=function(t){return this.d?cze(this.d,t):this.nj().jj().Li(t)},p.ui=function(){return this.b&2?(this.b&1)!=0:this.i!=0},p.xh=function(){return(this.b&128)!=0},p.ij=function(){var t;Pr(this),this.b&2&&($u(this.e)?(t=(this.b&1)!=0,this.b&=-2,Dn(this,new qu(this.e,2,br(this.e.mg(),this.nj()),t,!1))):this.b&=-2)},p.Bh=function(){return(this.b&1536)==0},p.b=0;var d6n=k(or,"EcoreEList/Generic",1027);A(1028,1027,Ho,GUe),p.nj=function(){return this.a};var p6n=k(or,"EcoreEList/Dynamic",1028);A(678,55,Ih,_C),p.Fh=function(t){return zI(this.a.a,t)};var g6n=k(or,"EcoreEMap/1",678);A(677,88,Ho,o1e),p.sh=function(t,i){n7(this.b,h(i,134))},p.uh=function(t,i){W$e(this.b)},p.vh=function(t,i){Yee(this.b,h(i,134))},p.wh=function(t,i,a){Yee(this.b,h(a,134)),Be(a)===Be(i)&&h(a,134).jh(LSt(h(i,134).kc())),n7(this.b,h(i,134))};var m6n=k(or,"EcoreEMap/DelegateEObjectContainmentEList",677);A(1042,143,Nxe,Jje);var b6n=k(or,"EcoreEMap/Unsettable",1042);A(1043,677,Ho,E8e),p.th=function(){this.a=!0},p.ui=function(){return this.a},p.ij=function(){var t;Pr(this),$u(this.e)?(t=this.a,this.a=!1,Li(this.e,new qu(this.e,2,this.c,t,!1))):this.a=!1},p.a=!1;var w6n=k(or,"EcoreEMap/Unsettable/UnsettableDelegateEObjectContainmentEList",1043);A(682,1,ys,lze),p.gc=function(t){Ss(this,t)},p.hc=function(){return UWe(this)},p.ic=function(){var t;return UWe(this),t=this.b,this.b=null,t},p.jc=function(){this.a.jc()};var v6n=k(or,"EcoreUtil/ProperContentIterator",682);A(1496,1495,{},YX);var sut,_6n=k(or,"EcoreValidator",1496),out,y6n=_r(or,"FeatureMapUtil/Validator");A(1095,1,{1632:1},mX),p.Bk=function(t){return!0};var x6n=k(or,"FeatureMapUtil/1",1095);A(692,1,{1632:1},B_e),p.Bk=function(t){var i;return this.c==t?!0:(i=mt(Ii(this.a,t)),i==null?IUt(this,t)?(Qze(this.a,t,(vt(),oM)),!0):(Qze(this.a,t,(vt(),K0)),!1):i==(vt(),oM))},p.e=!1;var Oae,E6n=k(or,"FeatureMapUtil/BasicValidator",692);A(693,44,Fx,Age);var S6n=k(or,"FeatureMapUtil/BasicValidator/Cache",693);A(455,41,{20:1,25:1,41:1,13:1,15:1,52:1,81:1,64:1},qR),p.bd=function(t,i){qYe(this.c,this.b,t,i)},p.nc=function(t){return o7t(this.c,this.b,t)},p.oc=function(t){return ZC(this,t)},p.xj=function(t,i){return a_e(this.c,this.b,t,i)},p.Dh=function(t){return D7(this.c,this.b,t,!1)},p.oh=function(){return $Ne(this.c,this.b)},p.ph=function(){return ESt(this.c,this.b)},p.qh=function(t){return ekt(this.c,this.b,t)},p.yj=function(t,i){return i8e(this,t,i)},p.Pb=function(){xe(this)},p.pc=function(t){return $Q(this.c,this.b,t)},p.qc=function(t){return NRt(this.c,this.b,t)},p.cd=function(t){return D7(this.c,this.b,t,!0)},p.hj=function(t){return this},p.dd=function(t){return ukt(this.c,this.b,t)},p.Wb=function(){return z8(this)},p.ui=function(){return!o6(this.c,this.b)},p.tc=function(){return mRt(this.c,this.b)},p.ed=function(){return bRt(this.c,this.b)},p.fd=function(t){return $6t(this.c,this.b,t)},p.gd=function(t){return qqe(this.c,this.b,t)},p.vc=function(t){return ZUt(this.c,this.b,t)},p.hd=function(t,i){return QZe(this.c,this.b,t,i)},p.Gc=function(t){g7(this.c,this.b),ZC(this,h(t,15))},p._b=function(){return d6t(this.c,this.b)},p.yc=function(){return T4t(this.c,this.b)},p.zc=function(t){return fkt(this.c,this.b,t)},p.Ib=function(){var t,i;for(i=new Tp,i.a+="[",t=$Ne(this.c,this.b);Oee(t);)ho(i,YC(e7(t))),Oee(t)&&(i.a+=Ca);return i.a+="]",i.a},p.ij=function(){g7(this.c,this.b)};var M6n=k(or,"FeatureMapUtil/FeatureEList",455);A(575,32,o5,kQ),p.Mh=function(t){return UA(this,t)},p.Rh=function(t){var i,a,l,f,g,m,v;switch(this.d){case 1:case 2:{if(g=t.Oh(),Be(g)===Be(this.c)&&UA(this,null)==t.Mh(null))return this.g=t.Nh(),t.Lh()==1&&(this.d=1),!0;break}case 3:{switch(f=t.Lh(),f){case 3:{if(g=t.Oh(),Be(g)===Be(this.c)&&UA(this,null)==t.Mh(null))return this.d=5,i=new w_(2),$n(i,this.g),$n(i,t.Nh()),this.g=i,!0;break}}break}case 5:{switch(f=t.Lh(),f){case 3:{if(g=t.Oh(),Be(g)===Be(this.c)&&UA(this,null)==t.Mh(null))return a=h(this.g,13),a.nc(t.Nh()),!0;break}}break}case 4:{switch(f=t.Lh(),f){case 3:{if(g=t.Oh(),Be(g)===Be(this.c)&&UA(this,null)==t.Mh(null))return this.d=1,this.g=t.Nh(),!0;break}case 4:{if(g=t.Oh(),Be(g)===Be(this.c)&&UA(this,null)==t.Mh(null))return this.d=6,v=new w_(2),$n(v,this.n),$n(v,t.Ph()),this.n=v,m=X(q(In,1),si,22,15,[this.o,t.Qh()]),this.g=m,!0;break}}break}case 6:{switch(f=t.Lh(),f){case 4:{if(g=t.Oh(),Be(g)===Be(this.c)&&UA(this,null)==t.Mh(null))return a=h(this.n,13),a.nc(t.Ph()),m=h(this.g,37),l=le(In,si,22,m.length+1,15,1),vc(m,0,l,0,m.length),l[m.length]=t.Qh(),this.g=l,!0;break}}break}}return!1};var T6n=k(or,"FeatureMapUtil/FeatureENotificationImpl",575);A(501,455,{20:1,25:1,41:1,13:1,15:1,52:1,81:1,184:1,237:1,1630:1,64:1},y9),p.pk=function(t,i,a){return a_e(this.c,t,i,a)},p.qk=function(t,i,a){return E_e(this.c,t,i,a)},p.rk=function(){return this},p.sk=function(t,i){return D6(this.c,t,i)},p.tk=function(t){return h(D7(this.c,this.b,t,!1),75).nj()},p.uk=function(t){return h(D7(this.c,this.b,t,!1),75).lc()},p.vk=function(){return this.a},p.wk=function(t){return!o6(this.c,t)},p.xk=function(t,i){Sne(this.c,t,i)},p.yk=function(t){return a$e(this.c,t)};var C6n=k(or,"FeatureMapUtil/FeatureFeatureMap",501);A(1094,1,{81:1},yNe),p.hj=function(t){return D7(this.b,this.a,-1,t)},p.ui=function(){return!o6(this.b,this.a)},p.Gc=function(t){Sne(this.b,this.a,t)},p.ij=function(){g7(this.b,this.a)};var A6n=k(or,"FeatureMapUtil/FeatureValue",1094),_3,Nae,Fae,y3,aut,yD=_r(kz,"AnyType");A(603,54,Zd,mK);var P6n=k(kz,"InvalidDatatypeValueException",603),zj=_r(kz,Ztt),xD=_r(kz,Ktt),tPe=_r(kz,Jtt),cut,ma,nPe,sv,lut,uut,fut,hut,dut,put,gut,mut,but,wut,vut,CM,_ut,AM,ED,yut,Iy,Gj,jj,xut,SD,MD;A(735,463,{95:1,91:1,87:1,51:1,42:1,92:1,746:1},upe),p.ug=function(t,i,a){switch(t){case 0:return a?(!this.c&&(this.c=new ps(this,0)),this.c):(!this.c&&(this.c=new ps(this,0)),this.c.b);case 1:return a?(!this.c&&(this.c=new ps(this,0)),h($c(this.c,(lr(),sv)),184)):(!this.c&&(this.c=new ps(this,0)),h(h($c(this.c,(lr(),sv)),184),237)).vk();case 2:return a?(!this.b&&(this.b=new ps(this,2)),this.b):(!this.b&&(this.b=new ps(this,2)),this.b.b)}return jl(this,t-jn(this.Rg()),Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():this.Rg(),t),i,a)},p.Dg=function(t,i,a){var l;switch(i){case 0:return!this.c&&(this.c=new ps(this,0)),k6(this.c,t,a);case 1:return(!this.c&&(this.c=new ps(this,0)),h(h($c(this.c,(lr(),sv)),184),64)).yj(t,a);case 2:return!this.b&&(this.b=new ps(this,2)),k6(this.b,t,a)}return l=h(Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():this.Rg(),i),61),l.aj().ej(this,B0e(this),i-jn(this.Rg()),t,a)},p.Fg=function(t){switch(t){case 0:return!!this.c&&this.c.i!=0;case 1:return!(!this.c&&(this.c=new ps(this,0)),h($c(this.c,(lr(),sv)),184)).Wb();case 2:return!!this.b&&this.b.i!=0}return zl(this,t-jn(this.Rg()),Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():this.Rg(),t))},p.Mg=function(t,i){switch(t){case 0:!this.c&&(this.c=new ps(this,0)),gI(this.c,i);return;case 1:(!this.c&&(this.c=new ps(this,0)),h(h($c(this.c,(lr(),sv)),184),237)).Gc(i);return;case 2:!this.b&&(this.b=new ps(this,2)),gI(this.b,i);return}Wl(this,t-jn(this.Rg()),Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():this.Rg(),t),i)},p.Rg=function(){return lr(),nPe},p.Ib=function(){var t;return this.j&4?Ku(this):(t=new su(Ku(this)),t.a+=" (mixed: ",OC(t,this.c),t.a+=", anyAttribute: ",OC(t,this.b),t.a+=")",t.a)};var L6n=k($r,"AnyTypeImpl",735);A(604,463,{95:1,91:1,87:1,51:1,42:1,92:1,1707:1,604:1},bX),p.ug=function(t,i,a){switch(t){case 0:return this.a;case 1:return this.b}return jl(this,t-jn((lr(),CM)),Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():CM,t),i,a)},p.Fg=function(t){switch(t){case 0:return this.a!=null;case 1:return this.b!=null}return zl(this,t-jn((lr(),CM)),Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():CM,t))},p.Mg=function(t,i){switch(t){case 0:jde(this,ti(i));return;case 1:Vde(this,ti(i));return}Wl(this,t-jn((lr(),CM)),Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():CM,t),i)},p.Rg=function(){return lr(),CM},p.Ib=function(){var t;return this.j&4?Ku(this):(t=new su(Ku(this)),t.a+=" (data: ",ho(t,this.a),t.a+=", target: ",ho(t,this.b),t.a+=")",t.a)},p.a=null,p.b=null;var k6n=k($r,"ProcessingInstructionImpl",604);A(605,735,{95:1,91:1,87:1,51:1,42:1,92:1,746:1,1708:1,605:1},CDe),p.ug=function(t,i,a){switch(t){case 0:return a?(!this.c&&(this.c=new ps(this,0)),this.c):(!this.c&&(this.c=new ps(this,0)),this.c.b);case 1:return a?(!this.c&&(this.c=new ps(this,0)),h($c(this.c,(lr(),sv)),184)):(!this.c&&(this.c=new ps(this,0)),h(h($c(this.c,(lr(),sv)),184),237)).vk();case 2:return a?(!this.b&&(this.b=new ps(this,2)),this.b):(!this.b&&(this.b=new ps(this,2)),this.b.b);case 3:return!this.c&&(this.c=new ps(this,0)),ti(D6(this.c,(lr(),ED),!0));case 4:return bme(this.a,(!this.c&&(this.c=new ps(this,0)),ti(D6(this.c,(lr(),ED),!0))));case 5:return this.a}return jl(this,t-jn((lr(),AM)),Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():AM,t),i,a)},p.Fg=function(t){switch(t){case 0:return!!this.c&&this.c.i!=0;case 1:return!(!this.c&&(this.c=new ps(this,0)),h($c(this.c,(lr(),sv)),184)).Wb();case 2:return!!this.b&&this.b.i!=0;case 3:return!this.c&&(this.c=new ps(this,0)),ti(D6(this.c,(lr(),ED),!0))!=null;case 4:return bme(this.a,(!this.c&&(this.c=new ps(this,0)),ti(D6(this.c,(lr(),ED),!0))))!=null;case 5:return!!this.a}return zl(this,t-jn((lr(),AM)),Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():AM,t))},p.Mg=function(t,i){switch(t){case 0:!this.c&&(this.c=new ps(this,0)),gI(this.c,i);return;case 1:(!this.c&&(this.c=new ps(this,0)),h(h($c(this.c,(lr(),sv)),184),237)).Gc(i);return;case 2:!this.b&&(this.b=new ps(this,2)),gI(this.b,i);return;case 3:X7e(this,ti(i));return;case 4:X7e(this,M8e(this.a,i));return;case 5:$de(this,h(i,140));return}Wl(this,t-jn((lr(),AM)),Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():AM,t),i)},p.Rg=function(){return lr(),AM};var R6n=k($r,"SimpleAnyTypeImpl",605);A(606,463,{95:1,91:1,87:1,51:1,42:1,92:1,1709:1,606:1},TDe),p.ug=function(t,i,a){switch(t){case 0:return a?(!this.a&&(this.a=new ps(this,0)),this.a):(!this.a&&(this.a=new ps(this,0)),this.a.b);case 1:return a?(!this.b&&(this.b=new il((yt(),zo),Aa,this,1)),this.b):(!this.b&&(this.b=new il((yt(),zo),Aa,this,1)),CI(this.b));case 2:return a?(!this.c&&(this.c=new il((yt(),zo),Aa,this,2)),this.c):(!this.c&&(this.c=new il((yt(),zo),Aa,this,2)),CI(this.c));case 3:return!this.a&&(this.a=new ps(this,0)),$c(this.a,(lr(),Gj));case 4:return!this.a&&(this.a=new ps(this,0)),$c(this.a,(lr(),jj));case 5:return!this.a&&(this.a=new ps(this,0)),$c(this.a,(lr(),SD));case 6:return!this.a&&(this.a=new ps(this,0)),$c(this.a,(lr(),MD))}return jl(this,t-jn((lr(),Iy)),Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():Iy,t),i,a)},p.Dg=function(t,i,a){var l;switch(i){case 0:return!this.a&&(this.a=new ps(this,0)),k6(this.a,t,a);case 1:return!this.b&&(this.b=new il((yt(),zo),Aa,this,1)),f9(this.b,t,a);case 2:return!this.c&&(this.c=new il((yt(),zo),Aa,this,2)),f9(this.c,t,a);case 5:return!this.a&&(this.a=new ps(this,0)),i8e($c(this.a,(lr(),SD)),t,a)}return l=h(Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():(lr(),Iy),i),61),l.aj().ej(this,B0e(this),i-jn((lr(),Iy)),t,a)},p.Fg=function(t){switch(t){case 0:return!!this.a&&this.a.i!=0;case 1:return!!this.b&&this.b.f!=0;case 2:return!!this.c&&this.c.f!=0;case 3:return!this.a&&(this.a=new ps(this,0)),!z8($c(this.a,(lr(),Gj)));case 4:return!this.a&&(this.a=new ps(this,0)),!z8($c(this.a,(lr(),jj)));case 5:return!this.a&&(this.a=new ps(this,0)),!z8($c(this.a,(lr(),SD)));case 6:return!this.a&&(this.a=new ps(this,0)),!z8($c(this.a,(lr(),MD)))}return zl(this,t-jn((lr(),Iy)),Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():Iy,t))},p.Mg=function(t,i){switch(t){case 0:!this.a&&(this.a=new ps(this,0)),gI(this.a,i);return;case 1:!this.b&&(this.b=new il((yt(),zo),Aa,this,1)),TU(this.b,i);return;case 2:!this.c&&(this.c=new il((yt(),zo),Aa,this,2)),TU(this.c,i);return;case 3:!this.a&&(this.a=new ps(this,0)),xe($c(this.a,(lr(),Gj))),!this.a&&(this.a=new ps(this,0)),ZC($c(this.a,Gj),h(i,13));return;case 4:!this.a&&(this.a=new ps(this,0)),xe($c(this.a,(lr(),jj))),!this.a&&(this.a=new ps(this,0)),ZC($c(this.a,jj),h(i,13));return;case 5:!this.a&&(this.a=new ps(this,0)),xe($c(this.a,(lr(),SD))),!this.a&&(this.a=new ps(this,0)),ZC($c(this.a,SD),h(i,13));return;case 6:!this.a&&(this.a=new ps(this,0)),xe($c(this.a,(lr(),MD))),!this.a&&(this.a=new ps(this,0)),ZC($c(this.a,MD),h(i,13));return}Wl(this,t-jn((lr(),Iy)),Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():Iy,t),i)},p.Rg=function(){return lr(),Iy},p.Ib=function(){var t;return this.j&4?Ku(this):(t=new su(Ku(this)),t.a+=" (mixed: ",OC(t,this.a),t.a+=")",t.a)};var I6n=k($r,"XMLTypeDocumentRootImpl",606);A(1626,638,{95:1,91:1,87:1,430:1,139:1,51:1,103:1,42:1,92:1,142:1,107:1,108:1,1710:1},tC),p.Zg=function(t,i){switch(t.Ni()){case 7:case 8:case 9:case 10:case 16:case 22:case 23:case 24:case 25:case 26:case 32:case 33:case 34:case 36:case 37:case 44:case 45:case 50:case 51:case 53:case 55:case 56:case 57:case 58:case 60:case 61:case 4:return i==null?null:Ga(i);case 19:case 28:case 29:case 35:case 38:case 39:case 41:case 46:case 52:case 54:case 5:return ti(i);case 6:return CMt(h(i,173));case 12:case 47:case 49:case 11:return OKe(this,t,i);case 13:return i==null?null:rzt(h(i,216));case 15:case 14:return i==null?null:IAt(ce(Xe(i)));case 17:return lqe((lr(),i));case 18:return lqe(i);case 21:case 20:return i==null?null:DAt(h(i,126).a);case 27:return AMt(h(i,173));case 30:return RHe((lr(),h(i,15)));case 31:return RHe(h(i,15));case 40:return bMt((lr(),i));case 42:return uqe((lr(),i));case 43:return uqe(i);case 59:case 48:return mMt((lr(),i));default:throw Y(new un(eM+t.be()+Y0))}},p.$g=function(t){var i,a,l,f,g;switch(t.G==-1&&(t.G=(a=$l(t),a?$p(a.bh(),t):-1)),t.G){case 0:return i=new upe,i;case 1:return l=new bX,l;case 2:return f=new CDe,f;case 3:return g=new TDe,g;default:throw Y(new un(bre+t.zb+Y0))}},p._g=function(t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie;switch(t.Ni()){case 5:case 52:case 4:return i;case 6:return $5t(i);case 8:case 7:return i==null?null:ABt(i);case 9:return i==null?null:LI(Sl((l=Ba(i,!0),l.length>0&&l.charCodeAt(0)==43?l.substr(1,l.length-1):l),-128,127)<<24>>24);case 10:return i==null?null:LI(Sl((f=Ba(i,!0),f.length>0&&f.charCodeAt(0)==43?f.substr(1,f.length-1):f),-128,127)<<24>>24);case 11:return ti($0(this,(lr(),fut),i));case 12:return ti($0(this,(lr(),hut),i));case 13:return i==null?null:new mpe(Ba(i,!0));case 15:case 14:return e8t(i);case 16:return ti($0(this,(lr(),dut),i));case 17:return HWe((lr(),i));case 18:return HWe(i);case 28:case 29:case 35:case 38:case 39:case 41:case 54:case 19:return Ba(i,!0);case 21:case 20:return f8t(i);case 22:return ti($0(this,(lr(),put),i));case 23:return ti($0(this,(lr(),gut),i));case 24:return ti($0(this,(lr(),mut),i));case 25:return ti($0(this,(lr(),but),i));case 26:return ti($0(this,(lr(),wut),i));case 27:return C5t(i);case 30:return qWe((lr(),i));case 31:return qWe(i);case 32:return i==null?null:He(Sl((C=Ba(i,!0),C.length>0&&C.charCodeAt(0)==43?C.substr(1,C.length-1):C),zs,zi));case 33:return i==null?null:new Tg((R=Ba(i,!0),R.length>0&&R.charCodeAt(0)==43?R.substr(1,R.length-1):R));case 34:return i==null?null:He(Sl((B=Ba(i,!0),B.length>0&&B.charCodeAt(0)==43?B.substr(1,B.length-1):B),zs,zi));case 36:return i==null?null:n1(F7((N=Ba(i,!0),N.length>0&&N.charCodeAt(0)==43?N.substr(1,N.length-1):N)));case 37:return i==null?null:n1(F7((W=Ba(i,!0),W.length>0&&W.charCodeAt(0)==43?W.substr(1,W.length-1):W)));case 40:return T6t((lr(),i));case 42:return XWe((lr(),i));case 43:return XWe(i);case 44:return i==null?null:new Tg((V=Ba(i,!0),V.length>0&&V.charCodeAt(0)==43?V.substr(1,V.length-1):V));case 45:return i==null?null:new Tg((ee=Ba(i,!0),ee.length>0&&ee.charCodeAt(0)==43?ee.substr(1,ee.length-1):ee));case 46:return Ba(i,!1);case 47:return ti($0(this,(lr(),vut),i));case 59:case 48:return M6t((lr(),i));case 49:return ti($0(this,(lr(),_ut),i));case 50:return i==null?null:xS(Sl((ie=Ba(i,!0),ie.length>0&&ie.charCodeAt(0)==43?ie.substr(1,ie.length-1):ie),Cz,32767)<<16>>16);case 51:return i==null?null:xS(Sl((g=Ba(i,!0),g.length>0&&g.charCodeAt(0)==43?g.substr(1,g.length-1):g),Cz,32767)<<16>>16);case 53:return ti($0(this,(lr(),yut),i));case 55:return i==null?null:xS(Sl((m=Ba(i,!0),m.length>0&&m.charCodeAt(0)==43?m.substr(1,m.length-1):m),Cz,32767)<<16>>16);case 56:return i==null?null:xS(Sl((v=Ba(i,!0),v.length>0&&v.charCodeAt(0)==43?v.substr(1,v.length-1):v),Cz,32767)<<16>>16);case 57:return i==null?null:n1(F7((y=Ba(i,!0),y.length>0&&y.charCodeAt(0)==43?y.substr(1,y.length-1):y)));case 58:return i==null?null:n1(F7((E=Ba(i,!0),E.length>0&&E.charCodeAt(0)==43?E.substr(1,E.length-1):E)));case 60:return i==null?null:He(Sl((a=Ba(i,!0),a.length>0&&a.charCodeAt(0)==43?a.substr(1,a.length-1):a),zs,zi));case 61:return i==null?null:He(Sl(Ba(i,!0),zs,zi));default:throw Y(new un(eM+t.be()+Y0))}};var Eut,iPe,Sut,rPe,D6n=k($r,"XMLTypeFactoryImpl",1626);A(530,248,{95:1,91:1,87:1,139:1,174:1,51:1,207:1,103:1,42:1,92:1,142:1,248:1,107:1,108:1,613:1,1639:1,530:1},mUe),p.N=!1,p.O=!1;var Mut=!1,B6n=k($r,"XMLTypePackageImpl",530);A(1569,1,{743:1},k2),p.mj=function(){return p_e(),Dut};var O6n=k($r,"XMLTypePackageImpl/1",1569);A(1578,1,li,jN),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var N6n=k($r,"XMLTypePackageImpl/10",1578);A(1579,1,li,$N),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var F6n=k($r,"XMLTypePackageImpl/11",1579);A(1580,1,li,wX),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var U6n=k($r,"XMLTypePackageImpl/12",1580);A(1581,1,li,VN),p.Li=function(t){return aw(t)},p.Mi=function(t){return le(Eo,be,315,t,7,1)};var z6n=k($r,"XMLTypePackageImpl/13",1581);A(1582,1,li,R2),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var G6n=k($r,"XMLTypePackageImpl/14",1582);A(1583,1,li,_E),p.Li=function(t){return re(t,15)},p.Mi=function(t){return le(yu,Lw,15,t,0,1)};var j6n=k($r,"XMLTypePackageImpl/15",1583);A(1584,1,li,vX),p.Li=function(t){return re(t,15)},p.Mi=function(t){return le(yu,Lw,15,t,0,1)};var $6n=k($r,"XMLTypePackageImpl/16",1584);A(1585,1,li,WN),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var V6n=k($r,"XMLTypePackageImpl/17",1585);A(1586,1,li,HN),p.Li=function(t){return re(t,126)},p.Mi=function(t){return le(aM,be,126,t,0,1)};var W6n=k($r,"XMLTypePackageImpl/18",1586);A(1587,1,li,nC),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var H6n=k($r,"XMLTypePackageImpl/19",1587);A(1570,1,li,qN),p.Li=function(t){return re(t,746)},p.Mi=function(t){return le(yD,et,746,t,0,1)};var q6n=k($r,"XMLTypePackageImpl/2",1570);A(1588,1,li,iC),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var X6n=k($r,"XMLTypePackageImpl/20",1588);A(1589,1,li,Jk),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var Y6n=k($r,"XMLTypePackageImpl/21",1589);A(1590,1,li,rC),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var Z6n=k($r,"XMLTypePackageImpl/22",1590);A(1591,1,li,_X),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var K6n=k($r,"XMLTypePackageImpl/23",1591);A(1592,1,li,XN),p.Li=function(t){return re(t,173)},p.Mi=function(t){return le(Mc,be,173,t,0,2)};var J6n=k($r,"XMLTypePackageImpl/24",1592);A(1593,1,li,sC),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var Q6n=k($r,"XMLTypePackageImpl/25",1593);A(1594,1,li,YN),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var e5n=k($r,"XMLTypePackageImpl/26",1594);A(1595,1,li,Qk),p.Li=function(t){return re(t,15)},p.Mi=function(t){return le(yu,Lw,15,t,0,1)};var t5n=k($r,"XMLTypePackageImpl/27",1595);A(1596,1,li,yX),p.Li=function(t){return re(t,15)},p.Mi=function(t){return le(yu,Lw,15,t,0,1)};var n5n=k($r,"XMLTypePackageImpl/28",1596);A(1597,1,li,ZN),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var i5n=k($r,"XMLTypePackageImpl/29",1597);A(1571,1,li,s0),p.Li=function(t){return re(t,604)},p.Mi=function(t){return le(zj,et,1707,t,0,1)};var r5n=k($r,"XMLTypePackageImpl/3",1571);A(1598,1,li,KN),p.Li=function(t){return re(t,21)},p.Mi=function(t){return le(Po,be,21,t,0,1)};var s5n=k($r,"XMLTypePackageImpl/30",1598);A(1599,1,li,JN),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var o5n=k($r,"XMLTypePackageImpl/31",1599);A(1600,1,li,xX),p.Li=function(t){return re(t,149)},p.Mi=function(t){return le(J0,be,149,t,0,1)};var a5n=k($r,"XMLTypePackageImpl/32",1600);A(1601,1,li,QN),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var c5n=k($r,"XMLTypePackageImpl/33",1601);A(1602,1,li,EX),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var l5n=k($r,"XMLTypePackageImpl/34",1602);A(1603,1,li,SX),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var u5n=k($r,"XMLTypePackageImpl/35",1603);A(1604,1,li,o0),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var f5n=k($r,"XMLTypePackageImpl/36",1604);A(1605,1,li,eR),p.Li=function(t){return re(t,15)},p.Mi=function(t){return le(yu,Lw,15,t,0,1)};var h5n=k($r,"XMLTypePackageImpl/37",1605);A(1606,1,li,tR),p.Li=function(t){return re(t,15)},p.Mi=function(t){return le(yu,Lw,15,t,0,1)};var d5n=k($r,"XMLTypePackageImpl/38",1606);A(1607,1,li,nR),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var p5n=k($r,"XMLTypePackageImpl/39",1607);A(1572,1,li,oC),p.Li=function(t){return re(t,605)},p.Mi=function(t){return le(xD,et,1708,t,0,1)};var g5n=k($r,"XMLTypePackageImpl/4",1572);A(1608,1,li,I2),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var m5n=k($r,"XMLTypePackageImpl/40",1608);A(1609,1,li,ns),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var b5n=k($r,"XMLTypePackageImpl/41",1609);A(1610,1,li,aC),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var w5n=k($r,"XMLTypePackageImpl/42",1610);A(1611,1,li,iR),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var v5n=k($r,"XMLTypePackageImpl/43",1611);A(1612,1,li,Uv),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var _5n=k($r,"XMLTypePackageImpl/44",1612);A(1613,1,li,MX),p.Li=function(t){return re(t,168)},p.Mi=function(t){return le(Q0,be,168,t,0,1)};var y5n=k($r,"XMLTypePackageImpl/45",1613);A(1614,1,li,rR),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var x5n=k($r,"XMLTypePackageImpl/46",1614);A(1615,1,li,eF),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var E5n=k($r,"XMLTypePackageImpl/47",1615);A(1616,1,li,jf),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var S5n=k($r,"XMLTypePackageImpl/48",1616);A(1617,1,li,TX),p.Li=function(t){return re(t,168)},p.Mi=function(t){return le(Q0,be,168,t,0,1)};var M5n=k($r,"XMLTypePackageImpl/49",1617);A(1573,1,li,CX),p.Li=function(t){return re(t,606)},p.Mi=function(t){return le(tPe,et,1709,t,0,1)};var T5n=k($r,"XMLTypePackageImpl/5",1573);A(1618,1,li,tF),p.Li=function(t){return re(t,149)},p.Mi=function(t){return le(J0,be,149,t,0,1)};var C5n=k($r,"XMLTypePackageImpl/50",1618);A(1619,1,li,AX),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var A5n=k($r,"XMLTypePackageImpl/51",1619);A(1620,1,li,nF),p.Li=function(t){return re(t,21)},p.Mi=function(t){return le(Po,be,21,t,0,1)};var P5n=k($r,"XMLTypePackageImpl/52",1620);A(1574,1,li,PX),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var L5n=k($r,"XMLTypePackageImpl/6",1574);A(1575,1,li,LX),p.Li=function(t){return re(t,173)},p.Mi=function(t){return le(Mc,be,173,t,0,2)};var k5n=k($r,"XMLTypePackageImpl/7",1575);A(1576,1,li,kX),p.Li=function(t){return ow(t)},p.Mi=function(t){return le(lo,be,434,t,8,1)};var R5n=k($r,"XMLTypePackageImpl/8",1576);A(1577,1,li,a0),p.Li=function(t){return re(t,192)},p.Mi=function(t){return le(qx,be,192,t,0,1)};var I5n=k($r,"XMLTypePackageImpl/9",1577),lh,tg,OL,$j,J;A(40,54,Zd,Wn);var D5n=k(Xp,"RegEx/ParseException",40);A(730,1,{},$f),p.Ck=function(t){return ta*16)throw Y(new Wn(Zn((zn(),ltt))));a=a*16+f}while(!0);if(this.a!=125)throw Y(new Wn(Zn((zn(),utt))));if(a>rM)throw Y(new Wn(Zn((zn(),ftt))));t=a}else{if(f=0,this.c!=0||(f=r1(this.a))<0)throw Y(new Wn(Zn((zn(),qp))));if(a=f,wi(this),this.c!=0||(f=r1(this.a))<0)throw Y(new Wn(Zn((zn(),qp))));a=a*16+f,t=a}break;case 117:if(l=0,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Zn((zn(),qp))));if(i=l,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Zn((zn(),qp))));if(i=i*16+l,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Zn((zn(),qp))));if(i=i*16+l,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Zn((zn(),qp))));i=i*16+l,t=i;break;case 118:if(wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Zn((zn(),qp))));if(i=l,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Zn((zn(),qp))));if(i=i*16+l,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Zn((zn(),qp))));if(i=i*16+l,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Zn((zn(),qp))));if(i=i*16+l,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Zn((zn(),qp))));if(i=i*16+l,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Zn((zn(),qp))));if(i=i*16+l,i>rM)throw Y(new Wn(Zn((zn(),"parser.descappe.4"))));t=i;break;case 65:case 90:case 122:throw Y(new Wn(Zn((zn(),htt))))}return t},p.Ek=function(t){var i;switch(t){case 100:i=(this.e&32)==32?em("Nd",!0):(vi(),Vj);break;case 68:i=(this.e&32)==32?em("Nd",!1):(vi(),uPe);break;case 119:i=(this.e&32)==32?em("IsWord",!0):(vi(),kM);break;case 87:i=(this.e&32)==32?em("IsWord",!1):(vi(),hPe);break;case 115:i=(this.e&32)==32?em("IsSpace",!0):(vi(),x3);break;case 83:i=(this.e&32)==32?em("IsSpace",!1):(vi(),fPe);break;default:throw Y(new na(hnt+t.toString(16)))}return i},p.Fk=function(t){var i,a,l,f,g,m,v,y,E,C,R,B;for(this.b=1,wi(this),i=null,this.c==0&&this.a==94?(wi(this),t?C=(vi(),vi(),++Er,new _l(5)):(i=(vi(),vi(),++Er,new _l(4)),Da(i,0,rM),C=(++Er,new _l(4)))):C=(vi(),vi(),++Er,new _l(4)),f=!0;(B=this.c)!=1&&!(B==0&&this.a==93&&!f);){if(f=!1,a=this.a,l=!1,B==10)switch(a){case 100:case 68:case 119:case 87:case 115:case 83:Cw(C,this.Ek(a)),l=!0;break;case 105:case 73:case 99:case 67:a=this.Vk(C,a),a<0&&(l=!0);break;case 112:case 80:if(R=bve(this,a),!R)throw Y(new Wn(Zn((zn(),Pre))));Cw(C,R),l=!0;break;default:a=this.Dk()}else if(B==20){if(m=WE(this.i,58,this.d),m<0)throw Y(new Wn(Zn((zn(),kxe))));if(v=!0,po(this.i,this.d)==94&&(++this.d,v=!1),g=qf(this.i,this.d,m),y=FGe(g,v,(this.e&512)==512),!y)throw Y(new Wn(Zn((zn(),rtt))));if(Cw(C,y),l=!0,m+1>=this.j||po(this.i,m+1)!=93)throw Y(new Wn(Zn((zn(),kxe))));this.d=m+2}if(wi(this),!l)if(this.c!=0||this.a!=45)Da(C,a,a);else{if(wi(this),(B=this.c)==1)throw Y(new Wn(Zn((zn(),vz))));B==0&&this.a==93?(Da(C,a,a),Da(C,45,45)):(E=this.a,B==10&&(E=this.Dk()),wi(this),Da(C,a,E))}(this.e&tf)==tf&&this.c==0&&this.a==44&&wi(this)}if(this.c==1)throw Y(new Wn(Zn((zn(),vz))));return i&&(mP(i,C),C=i),U_(C),gP(C),this.b=0,wi(this),C},p.Gk=function(){var t,i,a,l;for(a=this.Fk(!1);(l=this.c)!=7;)if(t=this.a,l==0&&(t==45||t==38)||l==4){if(wi(this),this.c!=9)throw Y(new Wn(Zn((zn(),ott))));if(i=this.Fk(!1),l==4)Cw(a,i);else if(t==45)mP(a,i);else if(t==38)RKe(a,i);else throw Y(new na("ASSERT"))}else throw Y(new Wn(Zn((zn(),att))));return wi(this),a},p.Hk=function(){var t,i;return t=this.a-48,i=(vi(),vi(),++Er,new _Q(12,null,t)),!this.g&&(this.g=new Zh),wn(this.g,new t8(t)),wi(this),i},p.Ik=function(){return wi(this),vi(),Aut},p.Jk=function(){return wi(this),vi(),Cut},p.Kk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Lk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Mk=function(){return wi(this),yIt()},p.Nk=function(){return wi(this),vi(),Lut},p.Ok=function(){return wi(this),vi(),Rut},p.Pk=function(){var t;if(this.d>=this.j||((t=po(this.i,this.d++))&65504)!=64)throw Y(new Wn(Zn((zn(),ttt))));return wi(this),vi(),vi(),++Er,new id(0,t-64)},p.Qk=function(){return wi(this),j7t()},p.Rk=function(){return wi(this),vi(),Iut},p.Sk=function(){var t;return t=(vi(),vi(),++Er,new id(0,105)),wi(this),t},p.Tk=function(){return wi(this),vi(),kut},p.Uk=function(){return wi(this),vi(),Put},p.Vk=function(t,i){return this.Dk()},p.Wk=function(){return wi(this),vi(),cPe},p.Xk=function(){var t,i,a,l,f;if(this.d+1>=this.j)throw Y(new Wn(Zn((zn(),Jet))));if(l=-1,i=null,t=po(this.i,this.d),49<=t&&t<=57){if(l=t-48,!this.g&&(this.g=new Zh),wn(this.g,new t8(l)),++this.d,po(this.i,this.d)!=41)throw Y(new Wn(Zn((zn(),w1))));++this.d}else switch(t==63&&--this.d,wi(this),i=N_e(this),i.e){case 20:case 21:case 22:case 23:break;case 8:if(this.c!=7)throw Y(new Wn(Zn((zn(),w1))));break;default:throw Y(new Wn(Zn((zn(),Qet))))}if(wi(this),f=O0(this),a=null,f.e==2){if(f.ol()!=2)throw Y(new Wn(Zn((zn(),ett))));a=f.kl(1),f=f.kl(0)}if(this.c!=7)throw Y(new Wn(Zn((zn(),w1))));return wi(this),vi(),vi(),++Er,new fje(l,i,f,a)},p.Yk=function(){return wi(this),vi(),lPe},p.Zk=function(){var t;if(wi(this),t=B9(24,O0(this)),this.c!=7)throw Y(new Wn(Zn((zn(),w1))));return wi(this),t},p.$k=function(){var t;if(wi(this),t=B9(20,O0(this)),this.c!=7)throw Y(new Wn(Zn((zn(),w1))));return wi(this),t},p._k=function(){var t;if(wi(this),t=B9(22,O0(this)),this.c!=7)throw Y(new Wn(Zn((zn(),w1))));return wi(this),t},p.al=function(){var t,i,a,l,f;for(t=0,a=0,i=-1;this.d=this.j)throw Y(new Wn(Zn((zn(),Pxe))));if(i==45){for(++this.d;this.d=this.j)throw Y(new Wn(Zn((zn(),Pxe))))}if(i==58){if(++this.d,wi(this),l=Q9e(O0(this),t,a),this.c!=7)throw Y(new Wn(Zn((zn(),w1))));wi(this)}else if(i==41)++this.d,wi(this),l=Q9e(O0(this),t,a);else throw Y(new Wn(Zn((zn(),Ket))));return l},p.bl=function(){var t;if(wi(this),t=B9(21,O0(this)),this.c!=7)throw Y(new Wn(Zn((zn(),w1))));return wi(this),t},p.cl=function(){var t;if(wi(this),t=B9(23,O0(this)),this.c!=7)throw Y(new Wn(Zn((zn(),w1))));return wi(this),t},p.dl=function(){var t,i;if(wi(this),t=this.f++,i=qJ(O0(this),t),this.c!=7)throw Y(new Wn(Zn((zn(),w1))));return wi(this),i},p.el=function(){var t;if(wi(this),t=qJ(O0(this),0),this.c!=7)throw Y(new Wn(Zn((zn(),w1))));return wi(this),t},p.fl=function(t){return wi(this),this.c==5?(wi(this),C9(t,(vi(),vi(),++Er,new pw(9,t)))):C9(t,(vi(),vi(),++Er,new pw(3,t)))},p.gl=function(t){var i;return wi(this),i=(vi(),vi(),++Er,new XC(2)),this.c==5?(wi(this),c1(i,FL),c1(i,t)):(c1(i,t),c1(i,FL)),i},p.hl=function(t){return wi(this),this.c==5?(wi(this),vi(),vi(),++Er,new pw(9,t)):(vi(),vi(),++Er,new pw(3,t))},p.a=0,p.b=0,p.c=0,p.d=0,p.e=0,p.f=1,p.g=null,p.j=0;var B5n=k(Xp,"RegEx/RegexParser",730);A(1564,730,{},kDe),p.Ck=function(t){return!1},p.Dk=function(){return Kve(this)},p.Ek=function(t){return FS(t)},p.Fk=function(t){return gJe(this)},p.Gk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Hk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Ik=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Jk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Kk=function(){return wi(this),FS(67)},p.Lk=function(){return wi(this),FS(73)},p.Mk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Nk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Ok=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Pk=function(){return wi(this),FS(99)},p.Qk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Rk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Sk=function(){return wi(this),FS(105)},p.Tk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Uk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Vk=function(t,i){return Cw(t,FS(i)),-1},p.Wk=function(){return wi(this),vi(),vi(),++Er,new id(0,94)},p.Xk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Yk=function(){return wi(this),vi(),vi(),++Er,new id(0,36)},p.Zk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.$k=function(){throw Y(new Wn(Zn((zn(),Yl))))},p._k=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.al=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.bl=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.cl=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.dl=function(){var t;if(wi(this),t=qJ(O0(this),0),this.c!=7)throw Y(new Wn(Zn((zn(),w1))));return wi(this),t},p.el=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.fl=function(t){return wi(this),C9(t,(vi(),vi(),++Er,new pw(3,t)))},p.gl=function(t){var i;return wi(this),i=(vi(),vi(),++Er,new XC(2)),c1(i,t),c1(i,FL),i},p.hl=function(t){return wi(this),vi(),vi(),++Er,new pw(3,t)};var Dy=null,PM=null,O5n=k(Xp,"RegEx/ParserForXMLSchema",1564);A(112,1,sM,Rc),p.il=function(t){throw Y(new na("Not supported."))},p.jl=function(){return-1},p.kl=function(t){return null},p.ll=function(){return null},p.ml=function(t){},p.nl=function(t){},p.ol=function(){return 0},p.Ib=function(){return this.pl(0)},p.pl=function(t){return this.e==11?".":""},p.e=0;var sPe,LM,NL,Tut,oPe,ov=null,Vj,Uae=null,aPe,FL,zae=null,cPe,lPe,uPe,fPe,hPe,Cut,x3,Aut,Put,Lut,kut,kM,Rut,Iut,Er=0,CVt=k(Xp,"RegEx/Token",112);A(130,112,{3:1,130:1,112:1},_l),p.pl=function(t){var i,a,l;if(this.e==4)if(this==aPe)a=".";else if(this==Vj)a="\\d";else if(this==kM)a="\\w";else if(this==x3)a="\\s";else{for(l=new Tp,l.a+="[",i=0;i0&&(l.a+=","),this.b[i]===this.b[i+1]?ho(l,I6(this.b[i])):(ho(l,I6(this.b[i])),l.a+="-",ho(l,I6(this.b[i+1])));l.a+="]",a=l.a}else if(this==uPe)a="\\D";else if(this==hPe)a="\\W";else if(this==fPe)a="\\S";else{for(l=new Tp,l.a+="[^",i=0;i0&&(l.a+=","),this.b[i]===this.b[i+1]?ho(l,I6(this.b[i])):(ho(l,I6(this.b[i])),l.a+="-",ho(l,I6(this.b[i+1])));l.a+="]",a=l.a}return a},p.a=!1,p.c=!1;var N5n=k(Xp,"RegEx/RangeToken",130);A(528,1,{528:1},t8),p.a=0;var F5n=k(Xp,"RegEx/RegexParser/ReferencePosition",528);A(527,1,{3:1,527:1},nOe),p.Fb=function(t){var i;return t==null||!re(t,527)?!1:(i=h(t,527),dt(this.b,i.b)&&this.a==i.a)},p.Hb=function(){return Hg(this.b+"/"+Hve(this.a))},p.Ib=function(){return this.c.pl(this.a)},p.a=0;var U5n=k(Xp,"RegEx/RegularExpression",527);A(195,112,sM,id),p.jl=function(){return this.a},p.pl=function(t){var i,a;switch(this.e){case 0:switch(this.a){case 124:case 42:case 43:case 63:case 40:case 41:case 46:case 91:case 123:case 92:a="\\"+CJ(this.a&jr);break;case 12:a="\\f";break;case 10:a="\\n";break;case 13:a="\\r";break;case 9:a="\\t";break;case 27:a="\\e";break;default:this.a>=oo?(i="0"+(this.a>>>0).toString(16),a="\\v"+qf(i,i.length-6,i.length)):a=""+CJ(this.a&jr)}break;case 8:this==cPe||this==lPe?a=""+CJ(this.a&jr):a="\\"+CJ(this.a&jr);break;default:a=null}return a},p.a=0;var z5n=k(Xp,"RegEx/Token/CharToken",195);A(283,112,sM,pw),p.kl=function(t){return this.a},p.ml=function(t){this.b=t},p.nl=function(t){this.c=t},p.ol=function(){return 1},p.pl=function(t){var i;if(this.e==3)if(this.c<0&&this.b<0)i=this.a.pl(t)+"*";else if(this.c==this.b)i=this.a.pl(t)+"{"+this.c+"}";else if(this.c>=0&&this.b>=0)i=this.a.pl(t)+"{"+this.c+","+this.b+"}";else if(this.c>=0&&this.b<0)i=this.a.pl(t)+"{"+this.c+",}";else throw Y(new na("Token#toString(): CLOSURE "+this.c+Ca+this.b));else if(this.c<0&&this.b<0)i=this.a.pl(t)+"*?";else if(this.c==this.b)i=this.a.pl(t)+"{"+this.c+"}?";else if(this.c>=0&&this.b>=0)i=this.a.pl(t)+"{"+this.c+","+this.b+"}?";else if(this.c>=0&&this.b<0)i=this.a.pl(t)+"{"+this.c+",}?";else throw Y(new na("Token#toString(): NONGREEDYCLOSURE "+this.c+Ca+this.b));return i},p.b=0,p.c=0;var G5n=k(Xp,"RegEx/Token/ClosureToken",283);A(731,112,sM,h1e),p.kl=function(t){return t==0?this.a:this.b},p.ol=function(){return 2},p.pl=function(t){var i;return this.b.e==3&&this.b.kl(0)==this.a?i=this.a.pl(t)+"+":this.b.e==9&&this.b.kl(0)==this.a?i=this.a.pl(t)+"+?":i=this.a.pl(t)+(""+this.b.pl(t)),i};var j5n=k(Xp,"RegEx/Token/ConcatToken",731);A(1562,112,sM,fje),p.kl=function(t){if(t==0)return this.d;if(t==1)return this.b;throw Y(new na("Internal Error: "+t))},p.ol=function(){return this.b?2:1},p.pl=function(t){var i;return this.c>0?i="(?("+this.c+")":this.a.e==8?i="(?("+this.a+")":i="(?"+this.a,this.b?i+=this.d+"|"+this.b+")":i+=this.d+")",i},p.c=0;var $5n=k(Xp,"RegEx/Token/ConditionToken",1562);A(1563,112,sM,L7e),p.kl=function(t){return this.b},p.ol=function(){return 1},p.pl=function(t){return"(?"+(this.a==0?"":Hve(this.a))+(this.c==0?"":Hve(this.c))+":"+this.b.pl(t)+")"},p.a=0,p.c=0;var V5n=k(Xp,"RegEx/Token/ModifierToken",1563);A(732,112,sM,_1e),p.kl=function(t){return this.a},p.ol=function(){return 1},p.pl=function(t){var i;switch(i=null,this.e){case 6:this.b==0?i="(?:"+this.a.pl(t)+")":i="("+this.a.pl(t)+")";break;case 20:i="(?="+this.a.pl(t)+")";break;case 21:i="(?!"+this.a.pl(t)+")";break;case 22:i="(?<="+this.a.pl(t)+")";break;case 23:i="(?"+this.a.pl(t)+")"}return i},p.b=0;var W5n=k(Xp,"RegEx/Token/ParenToken",732);A(474,112,{3:1,112:1,474:1},_Q),p.ll=function(){return this.b},p.pl=function(t){return this.e==12?"\\"+this.a:XNt(this.b)},p.a=0;var H5n=k(Xp,"RegEx/Token/StringToken",474);A(427,112,sM,XC),p.il=function(t){c1(this,t)},p.kl=function(t){return h(E0(this.a,t),112)},p.ol=function(){return this.a?this.a.a.c.length:0},p.pl=function(t){var i,a,l,f,g;if(this.e==1){if(this.a.a.c.length==2)i=h(E0(this.a,0),112),a=h(E0(this.a,1),112),a.e==3&&a.kl(0)==i?f=i.pl(t)+"+":a.e==9&&a.kl(0)==i?f=i.pl(t)+"+?":f=i.pl(t)+(""+a.pl(t));else{for(g=new Tp,l=0;l=this.c.b:this.a<=this.c.b},p.Cc=function(){return this.b>0},p.Dc=function(){return this.b},p.Fc=function(){return this.b-1},p.jc=function(){throw Y(new Cp(_nt))},p.a=0,p.b=0;var J5n=k(Zxe,"ExclusiveRange/RangeIterator",230),Zl=eS(yz,"C"),In=eS(OP,"I"),Ru=eS(jS,"Z"),R1=eS(NP,"J"),Mc=eS(IP,"B"),ks=eS(DP,"D"),av=eS(BP,"F"),By=eS(FP,"S"),AVt=_r("org.eclipse.elk.core.labels","ILabelManager"),dPe=_r(Gs,"DiagnosticChain"),pPe=_r(qtt,"ResourceSet"),gPe=k(Gs,"InvocationTargetException",null),But=(h8(),A4t),Out=Out=NBt;tRt(Wde),SRt("permProps",[[[Dz,Bz],[Oz,"gecko1_8"]],[[Dz,Bz],[Oz,"ie10"]],[[Dz,Bz],[Oz,"ie8"]],[[Dz,Bz],[Oz,"ie9"]],[[Dz,Bz],[Oz,"safari"]]]),Out(null,"elk",null)}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],3:[function(c,u,d){"use strict";function b(M,L){if(!(M instanceof L))throw new TypeError("Cannot call a class as a function")}function w(M,L){if(!M)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return L&&(typeof L=="object"||typeof L=="function")?L:M}function _(M,L){if(typeof L!="function"&&L!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof L);M.prototype=Object.create(L&&L.prototype,{constructor:{value:M,enumerable:!1,writable:!0,configurable:!0}}),L&&(Object.setPrototypeOf?Object.setPrototypeOf(M,L):M.__proto__=L)}var x=c("./elk-api.js").default,T=function(M){_(L,M);function L(){var I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};b(this,L);var D=Object.assign({},I),F=!1;try{c.resolve("webworker-threads"),F=!0}catch{}if(I.workerUrl)if(F){var O=c("webworker-threads"),z=O.Worker;D.workerFactory=function(te){return new z(te)}}else console.warn(`Web worker requested but 'webworker-threads' package not installed. +`),rd(this);try{for(a=0,g=0,f=0,m=0;a0&&(g%2==0?f=xw(l[a]):m=xw(l[a]),g>0&&g%2!=0&&Gi(this,new $t(f,m)),++g),++a}catch(v){throw v=pr(v),re(v,118)?(i=v,Y(new un("The given string does not match the expected format for vectors."+i))):Y(v)}},p.Ib=function(){var t,i,a;for(t=new ou("("),i=Nn(this,0);i.b!=i.d.c;)a=h(Un(i),9),Mi(t,a.a+","+a.b),i.b!=i.d.c&&(t.a+="; ");return(t.a+=")",t).a};var pCe=k(Q6,"KVectorChain",74);A(224,23,{3:1,34:1,23:1,224:1},VC);var Qoe,lj,uj,J5,Q5,fj,gCe=Ti(Lf,"Alignment",224,Di,Ekt,pCt),cct;A(855,1,pd,qX),p.ue=function(t){RZe(t)};var mCe,eae,bCe,wCe,lct,tae,uct,fct,vCe,_Ce,hct,pAn=k(Lf,"BoxLayouterOptions",855);A(856,1,{},hN),p.Be=function(){var t;return t=new jq,t},p.Ce=function(t){};var gAn=k(Lf,"BoxLayouterOptions/BoxFactory",856);A(785,1,pd,XX),p.ue=function(t){zt(t,new Rt(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,iet),""),"Layout Algorithm"),"Select a specific layout algorithm."),(o1(),Z5)),Se),Ht((i1(),Ln))))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,x2e),""),"Alignment"),"Alignment of the selected node relative to other nodes, the exact meaning depends on the used algorithm."),xCe),ms),gCe),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.alignment"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,WS),""),"Aspect Ratio"),"The desired aspect ratio of the drawing, that is the quotient of width by height."),nc),Eo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.aspectRatio"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,cxe),""),"Bend Points"),"A fixed list of bend points for the edge. This is used by the 'Fixed Layout' algorithm to specify a pre-defined routing for an edge. The vector chain must include the source point, any bend points, and the target point, so it must have at least two points."),wd),pCe),Ht(bd)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.bendPoints"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,nre),""),"Debug Mode"),"Whether additional debug information shall be generated."),(vt(),vt(),!1)),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.debugMode"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,rre),""),uye),"Overall direction of edges: horizontal (right / left) or vertical (down / up)."),SCe),ms),yL),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.direction"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,n5),""),"Edge Routing"),"What kind of edge routing style should be applied for the content of a parent node. Algorithms may also set this option to single edges in order to mark them as splines. The bend point list of edges with this option set to SPLINES must be interpreted as control points for a piecewise cubic spline."),CCe),ms),mae),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.edgeRouting"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,oxe),""),"Expand Nodes"),"If active, nodes are expanded to fill the area of their parent."),!1),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.expandNodes"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,E2e),""),"Hierarchy Handling"),"If this option is set to SEPARATE_CHILDREN, each hierarchy level of the graph is processed independently, possibly by different layout algorithms, beginning with the lowest level. If it is set to INCLUDE_CHILDREN, the algorithm is responsible to process all hierarchy levels that are contained in the associated parent node. If the root node is set to inherit (or not set at all), the default behavior is SEPARATE_CHILDREN."),LCe),ms),uAe),sr(Ln,X(q(Qp,1),Oe,163,0,[ga]))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.hierarchyHandling"])))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Ux),""),"Padding"),"The padding to be left to a parent element's border when placing child elements. This can also serve as an output option of a layout algorithm if node size calculation is setup appropriately."),FCe),wd),PEe),sr(Ln,X(q(Qp,1),Oe,163,0,[ga]))))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Q7),""),"Interactive"),"Whether the algorithm should be run in interactive mode for the content of a parent node. What this means exactly depends on how the specific algorithm interprets this option. Usually in the interactive mode algorithms try to modify the current layout as little as possible."),!1),_a),lo),Ht(Ln)))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,kie),""),"Port Constraints"),"Defines constraints of the position of the ports of a node."),$Ce),ms),dAe),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portConstraints"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,fz),""),"Position"),"The position of a node, port, or label. This is used by the 'Fixed Layout' algorithm to specify a pre-defined position."),wd),es),sr(ga,X(q(Qp,1),Oe,163,0,[cb,fm]))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.position"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,Y6),""),"Priority"),"Defines the priority of an object; its meaning depends on the specific layout algorithm and the context where it is used."),xc),Po),sr(ga,X(q(Qp,1),Oe,163,0,[bd]))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.priority"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,J7),""),"Randomization Seed"),"Seed used for pseudo-random number generators to control the layout algorithm. If the value is 0, the seed shall be determined pseudo-randomly (e.g. from the system time)."),xc),Po),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.randomSeed"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,Z6),""),"Separate Connected Components"),"Whether each connected component should be processed separately."),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.separateConnComp"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,D2e),""),"Junction Points"),"This option is not used as option, but as output of the layout algorithms. It is attached to edges and determines the points where junction symbols should be drawn in order to represent hyperedges with orthogonal routing. Whether such points are computed depends on the chosen layout algorithm and edge routing style. The points are put into the vector chain with no specific order."),kCe),wd),pCe),Ht(bd)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.junctionPoints"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,F2e),""),"Comment Box"),"Whether the node should be regarded as a comment box instead of a regular node. In that case its placement should be similar to how labels are handled. Any edges incident to a comment box specify to which graph elements the comment is related."),!1),_a),lo),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.commentBox"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,U2e),""),"Hypernode"),"Whether the node should be handled as a hypernode."),!1),_a),lo),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.hypernode"])))),zt(t,new Rt(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,ret),""),"Label Manager"),"Label managers can shorten labels upon a layout algorithm's request."),wd),kVt),sr(Ln,X(q(Qp,1),Oe,163,0,[fm]))))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,$2e),""),"Margins"),"Margins define additional space around the actual bounds of a graph element. For instance, ports or labels being placed on the outside of a node's border might introduce such a margin. The margin is used to guarantee non-overlap of other graph elements with those ports or labels."),RCe),wd),AEe),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.margins"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,_2e),""),"No Layout"),"No layout is done for the associated element. This is used to mark parts of a diagram to avoid their inclusion in the layout graph, or to mark parts of the layout graph to prevent layout engines from processing them. If you wish to exclude the contents of a compound node from automatic layout, while the node itself is still considered on its own layer, use the 'Fixed Layout' algorithm for that node."),!1),_a),lo),sr(ga,X(q(Qp,1),Oe,163,0,[bd,cb,fm]))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.noLayout"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,set),""),"Scale Factor"),"The scaling factor to be applied to the corresponding node in recursive layout. It causes the corresponding node's size to be adjusted, and its ports and labels to be sized and placed accordingly after the layout of that node has been determined (and before the node itself and its siblings are arranged). The scaling is not reverted afterwards, so the resulting layout graph contains the adjusted size and position data. This option is currently not supported if 'Layout Hierarchy' is set."),1),nc),Eo),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.scaleFactor"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,oet),""),"Animate"),"Whether the shift from the old layout to the new computed layout shall be animated."),!0),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.animate"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,aet),""),"Animation Time Factor"),"Factor for computation of animation time. The higher the value, the longer the animation time. If the value is 0, the resulting time is always equal to the minimum defined by 'Minimal Animation Time'."),He(100)),xc),Po),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.animTimeFactor"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,cet),""),"Layout Ancestors"),"Whether the hierarchy levels on the path from the selected element to the root of the diagram shall be included in the layout process."),!1),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.layoutAncestors"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,uet),""),"Maximal Animation Time"),"The maximal time for animations, in milliseconds."),He(4e3)),xc),Po),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.maxAnimTime"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,fet),""),"Minimal Animation Time"),"The minimal time for animations, in milliseconds."),He(400)),xc),Po),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.minAnimTime"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,het),""),"Progress Bar"),"Whether a progress bar shall be displayed during layout computations."),!1),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.progressBar"])))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,det),""),"Validate Options"),"Whether layout options shall be validated before any layout algorithm is applied. If this option is enabled and at least one error is found, the layout process is aborted and a message is shown to the user."),!0),_a),lo),Ht(Ln)))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,pet),""),"Zoom to Fit"),"Whether the zoom level shall be set to view the whole diagram after layout."),!1),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.zoomToFit"])))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,axe),"box"),"Box Layout Mode"),"Configures the packing mode used by the {@link BoxLayoutProvider}. If SIMPLE is not required (neither priorities are used nor the interactive mode), GROUP_DEC can improve the packing and decrease the area. GROUP_MIXED and GROUP_INC may, in very specific scenarios, work better."),ECe),ms),yAe),Ht(Ln)))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Mie),im),"Components Spacing"),"Spacing to be preserved between pairs of connected components. This option is only relevant if 'separateConnectedComponents' is activated."),12),nc),Eo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.borderSpacing"])))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,h2e),im),"Edge Spacing"),"Spacing to be preserved between any two edges. Note that while this can somewhat easily be satisfied for the segments of orthogonally drawn edges, it is harder for general polylines or splines."),10),nc),Eo),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Lie),im),"Edge Label Spacing"),"The minimal distance to be preserved between a label and the edge it is associated with. Note that the placement of a label is influenced by the 'edgelabels.placement' option."),2),nc),Eo),Ht(Ln)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,d2e),im),"Edge Node Spacing"),"Spacing to be preserved between nodes and edges."),10),nc),Eo),Ht(Ln)))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,p2e),im),"Label Spacing"),"Determines the amount of space to be left between two labels of the same graph element."),0),nc),Eo),Ht(Ln)),X(q(Se,1),be,2,6,[vet])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,m2e),im),"Label Node Spacing"),"Spacing to be preserved between labels and the border of node they are associated with. Note that the placement of a label is influenced by the 'nodelabels.placement' option."),5),nc),Eo),Ht(Ln)),X(q(Se,1),be,2,6,[vet])))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,g2e),im),"Label Port Spacing"),"Spacing to be preserved between labels and the ports they are associated with. Note that the placement of a label is influenced by the 'portlabels.placement' option."),1),nc),Eo),Ht(Ln)))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,qS),im),"Node Spacing"),"The minimal distance to be preserved between each two nodes."),20),nc),Eo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.spacing"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,b2e),im),"Port Spacing"),"Spacing between pairs of ports of the same node."),10),nc),Eo),sr(Ln,X(q(Qp,1),Oe,163,0,[ga]))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portSpacing"])))),zt(t,new Rt(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,w2e),im),"Individual Spacing Override"),"In general spacing values apply to the children of the hierarchical node (possibly the root node) for which the values are actually specified. Hereby, the children include ports, edges, and labels."),wd),MVt),sr(ga,X(q(Qp,1),Oe,163,0,[bd,cb,fm]))))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,V2e),im),"Additional Port Space"),"Additional space around the sets of ports on each node side. For each side of a node, this option can reserve additional space before and after the ports on each side. For example, a top spacing of 20 makes sure that the first port on the western and eastern side is 20 units away from the northern border."),KCe),wd),AEe),Ht(Ln)))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,j2e),_et),"Layout Partition"),"Partition to which the node belongs to. If 'layoutPartitions' is true, all nodes are expected to have a partition."),xc),Po),sr(Ln,X(q(Qp,1),Oe,163,0,[ga]))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.partition"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,G2e),_et),"Layout Partitioning"),"Whether to activate partitioned layout."),UCe),_a),lo),Ht(Ln)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.layoutPartitions"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,get),yet),"Node Label Padding"),"Define padding for node labels that are placed inside of a node."),ICe),wd),PEe),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.nodeLabelInset"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,T2e),yet),"Node Label Placement"),"Hints for where node labels are to be placed; if empty, the node label's position is not modified."),DCe),_M),Ys),sr(ga,X(q(Qp,1),Oe,163,0,[fm]))),X(q(Se,1),be,2,6,["de.cau.cs.kieler.nodeLabelPlacement"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,P2e),pz),"Port Alignment"),"Defines the default port distribution for a node. May be overridden for each side individually."),GCe),ms),CL),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portAlignment"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,L2e),pz),"Port Alignment (North)"),"Defines how ports on the northern side are placed, overriding the node's general port alignment."),ms),CL),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portAlignment.north"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,k2e),pz),"Port Alignment (South)"),"Defines how ports on the southern side are placed, overriding the node's general port alignment."),ms),CL),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portAlignment.south"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,R2e),pz),"Port Alignment (West)"),"Defines how ports on the western side are placed, overriding the node's general port alignment."),ms),CL),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portAlignment.west"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,I2e),pz),"Port Alignment (East)"),"Defines how ports on the eastern side are placed, overriding the node's general port alignment."),ms),CL),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portAlignment.east"])))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,lz),lxe),"Node Size Constraints"),"Constraints for determining node sizes. Each member of the set specifies something that should be taken into account when calculating node sizes. The empty set corresponds to node sizes being fixed."),BCe),_M),AL),Ht(ga)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,ire),lxe),"Node Size Options"),"Options modifying the behavior of the size constraints set on a node. Each member of the set specifies something that should be taken into account when calculating node sizes. The empty set corresponds to no further modifications."),NCe),_M),bAe),Ht(ga)))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,uz),lxe),"Node Size Minimum"),"The minimal size to which a node can be reduced."),OCe),wd),es),Ht(ga)))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,B2e),tre),"Edge Label Placement"),"Gives a hint on where to put edge labels."),MCe),ms),QCe),Ht(fm)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.edgeLabelPlacement"])))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,O2e),tre),"Inline Edge Labels"),"If true, an edge label is placed directly on its edge. May only apply to center edge labels. This kind of label placement is only advisable if the label's rendering is such that it is not crossed by its edge and thus stays legible."),!1),_a),lo),Ht(fm)))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,met),"font"),"Font Name"),"Font name used for a label."),Z5),Se),Ht(fm)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.fontName"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,bet),"font"),"Font Size"),"Font size used for a label."),xc),Po),Ht(fm)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.fontSize"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,z2e),pre),"Port Anchor Offset"),"The offset to the port position where connections shall be attached."),wd),es),Ht(cb)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portAnchor"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,N2e),pre),"Port Index"),"The index of a port in the fixed order around a node. The order is assumed as clockwise, starting with the leftmost port on the top side. This option must be set if 'Port Constraints' is set to FIXED_ORDER and no specific positions are given for the ports. Additionally, the option 'Port Side' must be defined in this case."),xc),Po),Ht(cb)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portIndex"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,y2e),pre),"Port Side"),"The side of a node on which a port is situated. This option must be set if 'Port Constraints' is set to FIXED_SIDE or FIXED_ORDER and no specific positions are given for the ports."),WCe),ms),Ec),Ht(cb)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portSide"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(It(Ot(Dt(Bt(new Pt,v2e),pre),"Port Border Offset"),"The offset of ports on the node border. With a positive offset the port is moved outside of the node, while with a negative offset the port is moved towards the inside. An offset of 0 means that the port is placed directly on the node border, i.e. if the port side is north, the port's south border touches the nodes's north border; if the port side is east, the port's west border touches the nodes's east border; if the port side is south, the port's north border touches the node's south border; if the port side is west, the port's east border touches the node's west border."),nc),Eo),Ht(cb)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.offset"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,C2e),xet),"Port Label Placement"),"Decides on a placement method for port labels."),VCe),ms),pAe),Ht(ga)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.portLabelPlacement"])))),zt(t,new Rt(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,A2e),xet),"Port Labels Next to Port"),"Usually, inside port labels of hierarchical nodes are placed not next to their port, but with an offset to avoid edge-label crossings. The offset is not necessary if the port has no connections that would cross the label, but is usually applied anyway to keep things uniform. Setting this option to true places labels next to their ports if they won't be crossed by edges."),!1),_a),lo),Ht(ga)))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,S2e),Eet),"Activate Inside Self Loops"),"Whether this node allows to route self loops inside of it instead of around it. If set to true, this will make the node a compound node if it isn't already, and will require the layout algorithm to support compound nodes with hierarchical ports."),!1),_a),lo),Ht(ga)),X(q(Se,1),be,2,6,[Met])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,M2e),Eet),"Inside Self Loop"),"Whether a self loop should be routed inside a node instead of around that node."),!1),_a),lo),Ht(bd)),X(q(Se,1),be,2,6,[Met])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,Tie),"edge"),"Edge Thickness"),"The thickness of an edge. This is a hint on the line width used to draw an edge, possibly requiring more space to be reserved for it."),1),nc),Eo),Ht(bd)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.thickness"])))),zt(t,new Rt(Ci(Ft(Nt(Ut(hn(It(Ot(Dt(Bt(new Pt,wet),"edge"),"Edge Type"),"The type of an edge. This is usually used for UML class diagrams, where associations must be handled differently from generalizations."),PCe),ms),sAe),Ht(bd)),X(q(Se,1),be,2,6,["de.cau.cs.kieler.edgeType"])))),BC(t,new cx(AC(BE(DE(new Wb,Pn),"Layered"),'The layer-based method was introduced by Sugiyama, Tagawa and Toda in 1981. It emphasizes the direction of edges by pointing as many edges as possible into the same direction. The nodes are arranged in layers, which are sometimes called "hierarchies", and then reordered such that the number of edge crossings is minimized. Afterwards, concrete coordinates are computed for the nodes and edge bend points.'))),BC(t,new cx(AC(BE(DE(new Wb,"org.eclipse.elk.orthogonal"),"Orthogonal"),`Orthogonal methods that follow the "topology-shape-metrics" approach by Batini, Nardelli and Tamassia '86. The first phase determines the topology of the drawing by applying a planarization technique, which results in a planar representation of the graph. The orthogonal shape is computed in the second phase, which aims at minimizing the number of edge bends, and is called orthogonalization. The third phase leads to concrete coordinates for nodes and edge bend points by applying a compaction method, thus defining the metrics.`))),BC(t,new cx(AC(BE(DE(new Wb,kh),"Force"),"Layout algorithms that follow physical analogies by simulating a system of attractive and repulsive forces. The first successful method of this kind was proposed by Eades in 1984."))),BC(t,new cx(AC(BE(DE(new Wb,"org.eclipse.elk.circle"),"Circle"),"Circular layout algorithms emphasize cycles or biconnected components of a graph by arranging them in circles. This is useful if a drawing is desired where such components are clearly grouped, or where cycles are shown as prominent OPTIONS of the graph."))),BC(t,new cx(AC(BE(DE(new Wb,qQe),"Tree"),"Specialized layout methods for trees, i.e. acyclic graphs. The regular structure of graphs that have no undirected cycles can be emphasized using an algorithm of this type."))),BC(t,new cx(AC(BE(DE(new Wb,"org.eclipse.elk.planar"),"Planar"),"Algorithms that require a planar or upward planar graph. Most of these algorithms are theoretically interesting, but not practically usable."))),BC(t,new cx(AC(BE(DE(new Wb,q0),"Radial"),"Radial layout algorithms usually position the nodes of the graph on concentric circles."))),dZe((new dF,t)),RZe((new qX,t)),tZe((new pF,t))};var yCe,dct,xCe,yM,pct,gct,ECe,mct,nae,vL,SCe,bct,eD,MCe,TCe,CCe,ACe,PCe,wct,Ey,LCe,vct,hj,iae,rae,u3,kCe,dj,RCe,_ct,ICe,pj,DCe,xM,BCe,tD,OCe,gj,NCe,sae,Sy,FCe,yct,UCe,xct,zCe,GCe,oae,aae,cae,lae,jCe,Zc,nD,$Ce,Ect,iD,uae,VCe,_L,WCe,f3,mj,fae,Sct,hae,HCe,Mct,qCe,Tct,dae,XCe,bj,YCe,My,ZCe,KCe,JCe,mAn=k(Lf,"CoreOptions",785);A(110,23,{3:1,34:1,23:1,110:1},VR);var rp,rf,sf,Oh,hm,yL=Ti(Lf,uye,110,Di,z4t,yCt),Cct;A(226,23,{3:1,34:1,23:1,226:1},I8);var xL,h3,EL,wj,QCe=Ti(Lf,"EdgeLabelPlacement",226,Di,h4t,xCt),Act;A(197,23,{3:1,34:1,23:1,197:1},D8);var EM,pae,lb,gae,mae=Ti(Lf,"EdgeRouting",197,Di,d4t,ECt),Pct;A(289,23,{3:1,34:1,23:1,289:1},WC);var eAe,tAe,nAe,iAe,bae,rAe,sAe=Ti(Lf,"EdgeType",289,Di,Skt,SCt),Lct;A(853,1,pd,dF),p.ue=function(t){dZe(t)};var oAe,aAe,cAe,kct,lAe,SL,bAn=k(Lf,"FixedLayouterOptions",853);A(854,1,{},dN),p.Be=function(){var t;return t=new vg,t},p.Ce=function(t){};var wAn=k(Lf,"FixedLayouterOptions/FixedFactory",854);A(316,23,{3:1,34:1,23:1,316:1},qK);var d3,vj,ML,uAe=Ti(Lf,"HierarchyHandling",316,Di,DLt,wCt),Rct;A(86,23,{3:1,34:1,23:1,86:1},Qv);var Nh,Mu,Tu,Cu,Ll,Au,of,af,If,Ys=Ti(Lf,"NodeLabelPlacement",86,Di,pRt,vCt),Ict;A(225,23,{3:1,34:1,23:1,225:1},WR);var fAe,TL,ub,hAe,wae,CL=Ti(Lf,"PortAlignment",225,Di,F4t,_Ct),Dct;A(83,23,{3:1,34:1,23:1,83:1},HC);var p3,Oa,vd,g3,sp,fb,dAe=Ti(Lf,"PortConstraints",83,Di,ykt,bCt),Bct;A(275,23,{3:1,34:1,23:1,275:1},XK);var _j,hb,Ty,pAe=Ti(Lf,"PortLabelPlacement",275,Di,kLt,gCt),Oct;A(69,23,{3:1,34:1,23:1,69:1},HR);var Zt,bn,rD,Cy,Fh,db,gAe,sD,Ay,_d,vae,yd,T1,xd,m3,oD,Py,aD,ni,Na,nn,Ec=Ti(Lf,"PortSide",69,Di,L4t,mCt),Nct;A(857,1,pd,pF),p.ue=function(t){tZe(t)};var Fct,Uct,mAe,zct,Gct,vAn=k(Lf,"RandomLayouterOptions",857);A(858,1,{},Gq),p.Be=function(){var t;return t=new hE,t},p.Ce=function(t){};var _An=k(Lf,"RandomLayouterOptions/RandomFactory",858);A(344,23,{3:1,34:1,23:1,344:1},B8);var pb,cD,lD,C1,AL=Ti(Lf,"SizeConstraint",344,Di,p4t,MCt),jct;A(239,23,{3:1,34:1,23:1,239:1},e_);var yj,xj,SM,_ae,PL,LL,Ej,b3,Sj,bAe=Ti(Lf,"SizeOptions",239,Di,gRt,TCt),$ct;A(313,1,{},g9,Eme,xme),p.b=!1,p.c=0,p.d=-1,p.e=0,p.f=!1,p.j=0;var yAn=k(Pf,"BasicProgressMonitor",313);A(848,244,K_,jq),p.Ae=function(t,i){var a,l,f,g,m,v,y,E,C,R;switch(ii(i,"Box layout",2),g=ce(Xe(rn(t,(l7(),hct)))),m=h(rn(t,fct),119),a=ce(mt(rn(t,bCe))),l=ce(mt(rn(t,wCe))),f=h(rn(t,eae),288),f.g){case 0:v=(y=new h9((!t.a&&(t.a=new ze(Br,t,10,11)),t.a)),_t(),Ug(y,new mZ(l)),y),E=h(rn(t,tae),9),E.a=w.Math.max(E.a-m.b-m.c,0),E.b=w.Math.max(E.b-m.d-m.a,0),C=Xe(rn(t,mCe)),(C==null||(dn(C),C<=0))&&(C=1.3),R=Ojt(v,g,m,E.a,E.b,a,(dn(C),C)),H_(t,R.a,R.b,!1,!0);break;default:qzt(t,g,m,a)}On(i)};var xAn=k(Pf,"BoxLayoutProvider",848);A(849,1,Or,mZ),p.Ld=function(t,i){return Q8t(this,h(t,35),h(i,35))},p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.a=!1;var EAn=k(Pf,"BoxLayoutProvider/1",849);A(145,1,{145:1},xU,YFe),p.Ib=function(){return this.c?s_e(this.c):Vp(this.b)};var SAn=k(Pf,"BoxLayoutProvider/Group",145);A(288,23,{3:1,34:1,23:1,288:1},O8);var wAe,vAe,_Ae,yae,yAe=Ti(Pf,"BoxLayoutProvider/PackingMode",288,Di,m4t,CCt),Vct;A(850,1,Or,Nq),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return-to(XR(h(t,145)),XR(h(i,145)))};var MAn=k(Pf,"BoxLayoutProvider/lambda$0$Type",850);A(851,1,Or,Fq),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return to(XR(h(t,145)),XR(h(i,145)))};var TAn=k(Pf,"BoxLayoutProvider/lambda$1$Type",851);A(852,1,Or,Uq),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return to(XR(h(t,145)),XR(h(i,145)))};var CAn=k(Pf,"BoxLayoutProvider/lambda$2$Type",852);A(833,1,{},XOe),p.td=function(t){IFt(this.a,this.b,t)},p.a=0,p.b=0;var AAn=k(Pf,"ElkUtil/lambda$0$Type",833);A(834,1,{},YOe),p.td=function(t){rEt(this.a,this.b,t)},p.a=0,p.b=0;var PAn=k(Pf,"ElkUtil/lambda$1$Type",834);A(835,1,{},ZOe),p.td=function(t){RSt(this.a,this.b,t)},p.a=0,p.b=0;var LAn=k(Pf,"ElkUtil/lambda$2$Type",835);A(322,1,{34:1,322:1},CE),p.vd=function(t){return USt(this,h(t,210))},p.Fb=function(t){var i;return re(t,322)?(i=h(t,322),this.a==i.a):!1},p.Hb=function(){return yr(this.a)},p.Ib=function(){return this.a+" (exclusive)"},p.a=0;var kAn=k(Pf,"ExclusiveBounds/ExclusiveLowerBound",322);A(963,244,K_,vg),p.Ae=function(t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie,fe,we,Ce,Ue,qe,ut,ft,Mt;for(ii(i,Tet,1),g=h(rn(t,(ur(),TCe)),197),B=0,N=0,we=new Bn((!t.a&&(t.a=new ze(Br,t,10,11)),t.a));we.e!=we.i._b();){for(ie=h(Yn(we),35),Mt=h(rn(ie,(CU(),SL)),9),Mt&&(Od(ie,Mt.a,Mt.b),h(rn(ie,aAe),185).pc((Hl(),pb))&&(W=h(rn(ie,cAe),9),W.a>0&&W.b>0&&H_(ie,W.a,W.b,!0,!0))),B=w.Math.max(B,ie.i+ie.g),N=w.Math.max(N,ie.j+ie.f),C=new Bn((!ie.n&&(ie.n=new ze(ea,ie,1,7)),ie.n));C.e!=C.i._b();)y=h(Yn(C),137),Mt=h(rn(y,SL),9),Mt&&Od(y,Mt.a,Mt.b),B=w.Math.max(B,ie.i+y.i+y.g),N=w.Math.max(N,ie.j+y.j+y.f);for(qe=new Bn((!ie.c&&(ie.c=new ze(Pu,ie,9,9)),ie.c));qe.e!=qe.i._b();)for(Ue=h(Yn(qe),121),Mt=h(rn(Ue,SL),9),Mt&&Od(Ue,Mt.a,Mt.b),ut=ie.i+Ue.i,ft=ie.j+Ue.j,B=w.Math.max(B,ut+Ue.g),N=w.Math.max(N,ft+Ue.f),E=new Bn((!Ue.n&&(Ue.n=new ze(ea,Ue,1,7)),Ue.n));E.e!=E.i._b();)y=h(Yn(E),137),Mt=h(rn(y,SL),9),Mt&&Od(y,Mt.a,Mt.b),B=w.Math.max(B,ut+y.i+y.g),N=w.Math.max(N,ft+y.j+y.f);for(f=Cn(Th(ie));Gn(f);)a=h(Tn(f),105),R=oJe(a),B=w.Math.max(B,R.a),N=w.Math.max(N,R.b);for(l=Cn(S6(ie));Gn(l);)a=h(Tn(l),105),Ia(h(ae((!a.b&&(a.b=new an(pi,a,4,7)),a.b),0),97))!=t&&(R=oJe(a),B=w.Math.max(B,R.a),N=w.Math.max(N,R.b))}if(g==(ld(),EM))for(fe=new Bn((!t.a&&(t.a=new ze(Br,t,10,11)),t.a));fe.e!=fe.i._b();)for(ie=h(Yn(fe),35),l=Cn(Th(ie));Gn(l);)a=h(Tn(l),105),v=(m=new zc,m),v.b==0?ac(a,u3,null):ac(a,u3,v);Ce=h(rn(t,(CU(),kct)),119),ee=B+Ce.b+Ce.c,V=N+Ce.d+Ce.a,H_(t,ee,V,!0,!0),On(i)};var RAn=k(Pf,"FixedLayoutProvider",963);A(786,131,Eie,Bk);var MVt=k(Pf,"IndividualSpacings",786);A(635,1,{},T9e),p.c=0;var IAn=k(Pf,"InstancePool",635);A(48,1,{20:1,48:1},Is),p.sc=function(t){mo(this,t)},p.Fb=function(t){var i,a,l;return re(t,48)?(a=h(t,48),i=this.a==null?a.a==null:ki(this.a,a.a),l=this.b==null?a.b==null:ki(this.b,a.b),i&&l):!1},p.Hb=function(){var t,i,a,l,f,g;return a=this.a==null?0:Hr(this.a),t=a&jr,i=a&-65536,g=this.b==null?0:Hr(this.b),l=g&jr,f=g&-65536,t^f>>16&jr|i^l<<16},p.tc=function(){return new bZ(this)},p.Ib=function(){return this.a==null&&this.b==null?"pair(null,null)":this.a==null?"pair(null,"+Ga(this.b)+")":this.b==null?"pair("+Ga(this.a)+",null)":"pair("+Ga(this.a)+","+Ga(this.b)+")"};var DAn=k(Pf,"Pair",48);A(859,1,ys,bZ),p.gc=function(t){Ss(this,t)},p.hc=function(){return!this.c&&(!this.b&&this.a.a!=null||this.a.b!=null)},p.ic=function(){if(!this.c&&!this.b&&this.a.a!=null)return this.b=!0,this.a.a;if(!this.c&&this.a.b!=null)return this.c=!0,this.a.b;throw Y(new K)},p.jc=function(){throw this.c&&this.a.b!=null?this.a.b=null:this.b&&this.a.a!=null&&(this.a.a=null),Y(new qa)},p.b=!1,p.c=!1;var BAn=k(Pf,"Pair/1",859);A(404,1,{404:1},EUe),p.Fb=function(t){return tl(this.a,h(t,404).a)&&tl(this.c,h(t,404).c)&&tl(this.d,h(t,404).d)&&tl(this.b,h(t,404).b)},p.Hb=function(){return Aee(X(q(on,1),et,1,5,[this.a,this.c,this.d,this.b]))},p.Ib=function(){return"("+this.a+Ca+this.c+Ca+this.d+Ca+this.b+")"};var OAn=k(Pf,"Quadruple",404);A(957,244,K_,hE),p.Ae=function(t,i){var a,l,f,g,m;if(ii(i,"Random Layout",1),(!t.a&&(t.a=new ze(Br,t,10,11)),t.a).i==0){On(i);return}g=h(rn(t,(twe(),zct)),21),g&&g.a!=0?f=new J9(g.a):f=new Jee,a=ce(Xe(rn(t,Fct))),m=ce(Xe(rn(t,Gct))),l=h(rn(t,Uct),119),xjt(t,f,a,m,l),On(i)};var NAn=k(Pf,"RandomLayoutProvider",957);A(490,1,{}),p.Qe=function(){return new $t(this.f.i,this.f.j)},p.xe=function(t){return zUe(t,(ur(),Zc))?rn(this.f,Wct):rn(this.f,t)},p.Re=function(){return new $t(this.f.g,this.f.f)},p.Se=function(){return this.g},p.ye=function(t){return UQ(this.f,t)},p.Te=function(t){Yu(this.f,t.a),Zu(this.f,t.b)},p.Ue=function(t){x_(this.f,t.a),y_(this.f,t.b)},p.Ve=function(t){this.g=t},p.g=0;var Wct,FAn=k(r5,"ElkGraphAdapters/AbstractElkGraphElementAdapter",490);A(491,1,{741:1},mC),p.We=function(){var t,i;if(!this.b)for(this.b=Y9(uQ(this.a).i),i=new Bn(uQ(this.a));i.e!=i.i._b();)t=h(Yn(i),137),De(this.b,new pK(t));return this.b},p.b=null;var UAn=k(r5,"ElkGraphAdapters/ElkEdgeAdapter",491);A(562,490,{},dK),p.Xe=function(){return OHe(this)},p.a=null;var zAn=k(r5,"ElkGraphAdapters/ElkGraphAdapter",562);A(564,490,{271:1},pK);var GAn=k(r5,"ElkGraphAdapters/ElkLabelAdapter",564);A(563,490,{739:1},gJ),p.We=function(){return IDt(this)},p.$e=function(){var t;return t=h(rn(this.f,(ur(),dj)),135),!t&&(t=new G2),t},p.af=function(){return DDt(this)},p.cf=function(t){var i;i=new RJ(t),ac(this.f,(ur(),dj),i)},p.df=function(t){ac(this.f,(ur(),Sy),new Tme(t))},p.Ye=function(){return this.d},p.Ze=function(){var t,i;if(!this.a)for(this.a=new ke,i=Cn(S6(h(this.f,35)));Gn(i);)t=h(Tn(i),105),De(this.a,new mC(t));return this.a},p._e=function(){var t,i;if(!this.c)for(this.c=new ke,i=Cn(Th(h(this.f,35)));Gn(i);)t=h(Tn(i),105),De(this.c,new mC(t));return this.c},p.bf=function(){return N1e(h(this.f,35)).i!=0||ce(mt(h(this.f,35).xe((ur(),hj))))},p.a=null,p.b=null,p.c=null,p.d=null,p.e=null;var jAn=k(r5,"ElkGraphAdapters/ElkNodeAdapter",563);A(997,490,{740:1},qF),p.We=function(){return jDt(this)},p.Ze=function(){var t,i;if(!this.a)for(this.a=ed(h(this.f,121).Tf().i),i=new Bn(h(this.f,121).Tf());i.e!=i.i._b();)t=h(Yn(i),105),De(this.a,new mC(t));return this.a},p._e=function(){var t,i;if(!this.c)for(this.c=ed(h(this.f,121).Uf().i),i=new Bn(h(this.f,121).Uf());i.e!=i.i._b();)t=h(Yn(i),105),De(this.c,new mC(t));return this.c},p.ef=function(){return h(h(this.f,121).xe((ur(),_L)),69)},p.ff=function(){var t,i,a,l,f,g,m,v;for(l=Sh(h(this.f,121)),a=new Bn(h(this.f,121).Uf());a.e!=a.i._b();)for(t=h(Yn(a),105),v=new Bn((!t.c&&(t.c=new an(pi,t,5,8)),t.c));v.e!=v.i._b();){if(m=h(Yn(v),97),SA(Ia(m),l))return!0;if(Ia(m)==l&&ce(mt(rn(t,(ur(),iae)))))return!0}for(i=new Bn(h(this.f,121).Tf());i.e!=i.i._b();)for(t=h(Yn(i),105),g=new Bn((!t.b&&(t.b=new an(pi,t,4,7)),t.b));g.e!=g.i._b();)if(f=h(Yn(g),97),SA(Ia(f),l))return!0;return!1},p.a=null,p.b=null,p.c=null;var $An=k(r5,"ElkGraphAdapters/ElkPortAdapter",997);A(265,23,{3:1,34:1,23:1,265:1},N8);var Ed,dm,uD,fD,Hct=Ti(uxe,"LabelSide",265,Di,b4t,ACt),qct;A(676,1,{},dE),p.td=function(t){UKe(h(t,739),!0,!1)};var VAn=k(uxe,"NodeLabelAndSizeCalculator/lambda$0$Type",676);A(571,1,{},ER),p.b=!0,p.c=!0,p.d=!0,p.e=!0;var WAn=k(uxe,MQe,571);A(171,1,{171:1}),p.j=!1,p.k=!1;var Xct=k(m1,"Cell",171);A(114,171,{114:1,171:1},w8e),p.Pf=function(){return v9(this)},p.Qf=function(){var t;return t=this.n,this.a.a+t.b+t.c};var HAn=k(m1,"AtomicCell",114);A(203,23,{3:1,34:1,23:1,203:1},YK);var aa,Wa,ca,Jw=Ti(m1,"ContainerArea",203,Di,ILt,PCt),Yct;A(307,171,Aet);var qAn=k(m1,"ContainerCell",307);A(1179,307,Aet,RWe),p.Pf=function(){var t;return t=0,this.e?this.b?t=this.b.b:this.a[1][1]&&(t=this.a[1][1].Pf()):t=jbe(this,NHe(this,!0)),t>0?t+this.n.d+this.n.a:0},p.Qf=function(){var t,i,a,l,f;if(f=0,this.e)this.b?f=this.b.a:this.a[1][1]&&(f=this.a[1][1].Qf());else if(this.g)f=jbe(this,Cte(this,null,!0));else for(i=(Ef(),X(q(Jw,1),Oe,203,0,[aa,Wa,ca])),a=0,l=i.length;a0?f+this.n.b+this.n.c:0},p.Rf=function(){var t,i,a,l,f;if(this.g)for(t=Cte(this,null,!1),a=(Ef(),X(q(Jw,1),Oe,203,0,[aa,Wa,ca])),l=0,f=a.length;l0&&(l[0]+=this.d,a-=l[0]),l[2]>0&&(l[2]+=this.d,a-=l[2]),this.c.a=w.Math.max(0,a),this.c.d=i.d+t.d+(this.c.a-a)/2,l[1]=w.Math.max(l[1],a),w0e(this,Wa,i.d+t.d+l[0]-(l[1]-a)/2,l)},p.b=null,p.d=0,p.e=!1,p.f=!1,p.g=!1;var xae=0,Mj=0,XAn=k(m1,"GridContainerCell",1179);A(419,23,{3:1,34:1,23:1,419:1},ZK);var gb,Uh,cf,Zct=Ti(m1,"HorizontalLabelAlignment",419,Di,PLt,LCt),Kct;A(267,171,{171:1,267:1},s7e,Dje,e7e),p.Pf=function(){return zJ(this)},p.Qf=function(){return w9(this)},p.a=0,p.c=!1;var TVt=k(m1,"LabelCell",267);A(219,307,{171:1,307:1,219:1},HA),p.Pf=function(){return _6(this)},p.Qf=function(){return y6(this)},p.Rf=function(){gne(this)},p.Sf=function(){mne(this)},p.b=0,p.c=0,p.d=!1;var YAn=k(m1,"StripContainerCell",219);A(1394,1,os,Vq),p.Nb=function(t){return!!h(t,171)&&h(t,171).k};var ZAn=k(m1,"StripContainerCell/lambda$0$Type",1394);A(1395,1,{},Im),p.oe=function(t){return h(t,171).Qf()};var KAn=k(m1,"StripContainerCell/lambda$1$Type",1395);A(1396,1,os,Ok),p.Nb=function(t){return!!h(t,171)&&h(t,171).j};var JAn=k(m1,"StripContainerCell/lambda$2$Type",1396);A(1397,1,{},Fv),p.oe=function(t){return h(t,171).Pf()};var QAn=k(m1,"StripContainerCell/lambda$3$Type",1397);A(420,23,{3:1,34:1,23:1,420:1},KK);var lf,mb,Df,Jct=Ti(m1,"VerticalLabelAlignment",420,Di,LLt,kCt),Qct;A(697,1,{},L_e),p.c=0,p.d=0,p.k=0,p.s=0,p.u=0,p.B=!1;var ePn=k(mz,"NodeContext",697);A(1177,1,Or,pN),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return TNe(h(t,69),h(i,69))};var tPn=k(mz,"NodeContext/0methodref$comparePortSides$Type",1177);A(1178,1,Or,$q),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return xOt(h(t,111),h(i,111))};var nPn=k(mz,"NodeContext/1methodref$comparePortContexts$Type",1178);A(147,23,{3:1,34:1,23:1,147:1},Vl);var elt,tlt,nlt,ilt,rlt,slt,olt,alt,clt,llt,ult,flt,hlt,dlt,plt,glt,mlt,blt,wlt,vlt,_lt,Eae,ylt=Ti(mz,"NodeLabelLocation",147,Di,cte,RCt),xlt;A(111,1,{111:1},Jze);var iPn=k(mz,"PortContext",111);A(1182,1,{},yp),p.oe=function(t){return h(t,111).c?w9(h(t,111).c):0};var rPn=k(JS,"HorizontalPortPlacementSizeCalculator/lambda$0$Type",1182);A(1184,1,{},Wq),p.td=function(t){DBe(h(t,267))};var sPn=k(JS,"LabelPlacer/lambda$0$Type",1184);A(1185,1,os,gN),p.Nb=function(t){return!!h(t,111).c};var oPn=k(JS,"LabelPlacer/lambda$1$Type",1185);A(1186,1,{},mN),p.td=function(t){DBe(h(t,111).c)};var aPn=k(JS,"LabelPlacer/lambda$2$Type",1186),xAe;A(1181,1,{},pE),p.td=function(t){Gm(),Kde(h(t,111))};var cPn=k(JS,"NodeLabelAndSizeUtilities/lambda$0$Type",1181);A(698,1,{},hge),p.td=function(t){oEt(this.a,this.b,t)},p.b=!1;var lPn=k(JS,"NodeLabelCellCreator/lambda$0$Type",698);A(1180,1,{},vZ),p.td=function(t){je(this.a,t)};var uPn=k(JS,"PortContextCreator/lambda$0$Type",1180),Tj;A(1183,1,{},Hb),p.oe=function(t){return h(t,111).c?zJ(h(t,111).c):0};var fPn=k(JS,"VerticalPortPlacementSizeCalculator/lambda$0$Type",1183);A(1525,1,{},bN);var hPn=k(QS,"GreedyRectangleStripOverlapRemover",1525);A(1526,1,Or,Hq),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return iMt(h(t,194),h(i,194))};var dPn=k(QS,"GreedyRectangleStripOverlapRemover/0methodref$compareByYCoordinate$Type",1526);A(1497,1,{},UDe),p.a=5,p.e=0;var pPn=k(QS,"RectangleStripOverlapRemover",1497);A(1498,1,Or,XT),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return rMt(h(t,194),h(i,194))};var gPn=k(QS,"RectangleStripOverlapRemover/0methodref$compareLeftRectangleBorders$Type",1498);A(1500,1,Or,qq),p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)},p.Ld=function(t,i){return PAt(h(t,194),h(i,194))};var mPn=k(QS,"RectangleStripOverlapRemover/1methodref$compareRightRectangleBorders$Type",1500);A(374,23,{3:1,34:1,23:1,374:1},F8);var hD,Sae,Mae,dD,Elt=Ti(QS,"RectangleStripOverlapRemover/OverlapRemovalDirection",374,Di,g4t,ICt),Slt;A(194,1,{194:1},jJ);var bPn=k(QS,"RectangleStripOverlapRemover/RectangleNode",194);A(1499,1,{},XF),p.td=function(t){PDt(this.a,h(t,194))};var wPn=k(QS,"RectangleStripOverlapRemover/lambda$0$Type",1499),Qw=_r(Xl,"EObject"),MM=_r(iy,Pet),ah=_r(iy,Let),pD=_r(iy,ket),gD=_r(iy,"ElkShape"),pi=_r(iy,Ret),js=_r(iy,hxe),ts=_r(iy,Iet),mD=_r(Xl,Det),kL=_r(Xl,"EFactory"),Mlt,Tae=_r(Xl,Bet),ch=_r(Xl,"EPackage"),ds,Tlt,Clt,EAe,Cj,Alt,SAe,MAe,TAe,op,Plt,Llt,ea=_r(iy,dxe),Br=_r(iy,pxe),Pu=_r(iy,gxe);A(87,1,Oet),p.cg=function(){return this.dg(),null},p.dg=function(){return null},p.eg=function(){return this.dg(),!1},p.fg=function(){return!1},p.gg=function(t){Li(this,t)};var vPn=k(Hx,"BasicNotifierImpl",87);A(92,87,Fet),p.Hg=function(){return $u(this)},p.hg=function(t,i){return t},p.ig=function(){throw Y(new Pi)},p.jg=function(t){var i;return i=Uo(h(Wt(this.mg(),this.og()),17)),this.yg().Cg(this,i.n,i.f,t)},p.kg=function(t,i){throw Y(new Pi)},p.lg=function(t,i,a){return Ml(this,t,i,a)},p.mg=function(){var t;return this.ig()&&(t=this.ig().pj(),t)?t:this.Rg()},p.ng=function(){return Xte(this)},p.og=function(){throw Y(new Pi)},p.pg=function(){var t,i;return i=this.Jg().qj(),!i&&this.ig().vj(i=(LC(),t=z1e(Jg(this.mg())),t==null?Dae:new eI(this,t))),i},p.qg=function(t,i){return t},p.rg=function(t){var i;return i=t.Vi(),i?t.pi():br(this.mg(),t)},p.sg=function(){var t;return t=this.ig(),t?t.sj():null},p.tg=function(){return this.ig()?this.ig().pj():null},p.ug=function(t,i,a){return t7(this,t,i,a)},p.vg=function(t){return AI(this,t)},p.wg=function(t,i){return m0e(this,t,i)},p.xg=function(){var t;return t=this.ig(),!!t&&t.tj()},p.yg=function(){throw Y(new Pi)},p.zg=function(){return ZU(this)},p.Ag=function(t,i,a,l){return yx(this,t,i,l)},p.Bg=function(t,i,a){var l;return l=h(Wt(this.mg(),i),61),l.aj().dj(this,this.Qg(),i-this.Sg(),t,a)},p.Cg=function(t,i,a,l){return j9(this,t,i,l)},p.Dg=function(t,i,a){var l;return l=h(Wt(this.mg(),i),61),l.aj().ej(this,this.Qg(),i-this.Sg(),t,a)},p.Eg=function(){return!!this.ig()&&(this.ig().rj(),!1)},p.Fg=function(t){return fte(this,t)},p.Gg=function(t){var i;return i=this.rg(t),i>=0?this.Fg(i):Vte(this,t)},p.Ig=function(t){return wKe(this,t)},p.Jg=function(){throw Y(new Pi)},p.Kg=function(){return this.ig()?this.ig().rj():null},p.Lg=function(){return ZU(this)},p.Mg=function(t,i){b7(this,t,i)},p.Ng=function(t){this.Jg().uj(t)},p.Og=function(t){this.Jg().wj(t)},p.Pg=function(t,i){var a,l,f,g;return g=this.sg(),g&&t&&(i=Us(g.fk(),this,i),g.jk(this)),l=this.yg(),l&&(ane(this,this.yg(),this.og()).Bb&oo?(f=l.zg(),f&&(t?!g&&f.jk(this):f.ik(this))):(i=(a=this.og(),a>=0?this.jg(i):this.yg().Cg(this,-1-a,null,i)),i=this.lg(null,-1,i))),this.Og(t),i},p.Qg=function(){return B0e(this)},p.Rg=function(){return(kg(),Ct).S},p.Sg=function(){return jn(this.Rg())},p.Ib=function(){return Ku(this)};var _Pn=k(Lt,"BasicEObjectImpl",92),klt;A(107,92,{95:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1}),p.Tg=function(t){var i;return i=D0e(this),i[t]},p.Ug=function(t,i){var a;a=D0e(this),Gr(a,t,i)},p.Vg=function(t){var i;i=D0e(this),Gr(i,t,null)},p.cg=function(){return h(sn(this,4),116)},p.dg=function(){throw Y(new Pi)},p.eg=function(){return(this.Db&4)!=0},p.ig=function(){throw Y(new Pi)},p.Wg=function(t){VA(this,2,t)},p.kg=function(t,i){this.Db=i<<16|this.Db&255,this.Wg(t)},p.mg=function(){return sc(this)},p.og=function(){return this.Db>>16},p.pg=function(){var t,i;return LC(),i=z1e(Jg((t=h(sn(this,16),24),t||this.Rg()))),i==null?Dae:new eI(this,i)},p.fg=function(){return(this.Db&1)==0},p.sg=function(){return h(sn(this,128),1628)},p.tg=function(){return h(sn(this,16),24)},p.xg=function(){return(this.Db&32)!=0},p.yg=function(){return h(sn(this,2),42)},p.Eg=function(){return(this.Db&64)!=0},p.Jg=function(){throw Y(new Pi)},p.Kg=function(){return h(sn(this,64),261)},p.Ng=function(t){VA(this,16,t)},p.Og=function(t){VA(this,128,t)},p.Qg=function(){return Ya(this)},p.Db=0;var yPn=k(Lt,"MinimalEObjectImpl",107);A(108,107,{95:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1}),p.Wg=function(t){this.Cb=t},p.yg=function(){return this.Cb};var xPn=k(Lt,"MinimalEObjectImpl/Container",108);A(1676,108,{95:1,379:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1}),p.ve=function(t){return!this.o&&(this.o=new il((Ta(),op),pm,this,0)),l$e(this.o,t.p?t.p:(_t(),_t(),ep)),this},p.ug=function(t,i,a){return Mwe(this,t,i,a)},p.Dg=function(t,i,a){return sve(this,t,i,a)},p.Fg=function(t){return q1e(this,t)},p.Mg=function(t,i){xbe(this,t,i)},p.Rg=function(){return Ta(),Llt},p.we=function(){return cHe(this)},p.xe=function(t){return rn(this,t)},p.ye=function(t){return UQ(this,t)},p.ze=function(t,i){return ac(this,t,i)};var EPn=k(b1,"EMapPropertyHolderImpl",1676);A(502,108,{95:1,531:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1},gE),p.ug=function(t,i,a){switch(t){case 0:return this.a;case 1:return this.b}return t7(this,t,i,a)},p.Fg=function(t){switch(t){case 0:return this.a!=0;case 1:return this.b!=0}return fte(this,t)},p.Mg=function(t,i){switch(t){case 0:see(this,ce(Xe(i)));return;case 1:oee(this,ce(Xe(i)));return}b7(this,t,i)},p.Rg=function(){return Ta(),Tlt},p.Ib=function(){var t;return this.Db&64?Ku(this):(t=new su(Ku(this)),t.a+=" (x: ",Xv(t,this.a),t.a+=", y: ",Xv(t,this.b),t.a+=")",t.a)},p.a=0,p.b=0;var SPn=k(b1,"ElkBendPointImpl",502);A(651,1676,{95:1,379:1,253:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1}),p.ug=function(t,i,a){return Nbe(this,t,i,a)},p.Bg=function(t,i,a){return Dte(this,t,i,a)},p.Dg=function(t,i,a){return Mee(this,t,i,a)},p.Fg=function(t){return fbe(this,t)},p.Mg=function(t,i){jwe(this,t,i)},p.Rg=function(){return Ta(),Alt},p.Vf=function(){return uQ(this)},p.Ib=function(){return Xee(this)},p.k=null;var MPn=k(b1,"ElkGraphElementImpl",651);A(652,651,{95:1,379:1,253:1,429:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1}),p.ug=function(t,i,a){return Hbe(this,t,i,a)},p.Fg=function(t){return Kbe(this,t)},p.Mg=function(t,i){$we(this,t,i)},p.Rg=function(){return Ta(),Plt},p.Wf=function(){return this.f},p.Xf=function(){return this.g},p.Yf=function(){return this.i},p.Zf=function(){return this.j},p.$f=function(t,i){W8(this,t,i)},p._f=function(t,i){Od(this,t,i)},p.ag=function(t){Yu(this,t)},p.bg=function(t){Zu(this,t)},p.Ib=function(){return Ote(this)},p.f=0,p.g=0,p.i=0,p.j=0;var TPn=k(b1,"ElkShapeImpl",652);A(653,652,{95:1,379:1,97:1,253:1,429:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1}),p.ug=function(t,i,a){return bwe(this,t,i,a)},p.Bg=function(t,i,a){return Nwe(this,t,i,a)},p.Dg=function(t,i,a){return Fwe(this,t,i,a)},p.Fg=function(t){return _be(this,t)},p.Mg=function(t,i){Ive(this,t,i)},p.Rg=function(){return Ta(),Clt},p.Tf=function(){return!this.d&&(this.d=new an(js,this,8,5)),this.d},p.Uf=function(){return!this.e&&(this.e=new an(js,this,7,4)),this.e};var CPn=k(b1,"ElkConnectableShapeImpl",653);A(183,651,{95:1,379:1,105:1,253:1,183:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1},YT),p.jg=function(t){return kwe(this,t)},p.ug=function(t,i,a){switch(t){case 3:return V9(this);case 4:return!this.b&&(this.b=new an(pi,this,4,7)),this.b;case 5:return!this.c&&(this.c=new an(pi,this,5,8)),this.c;case 6:return!this.a&&(this.a=new ze(ts,this,6,6)),this.a;case 7:return vt(),!this.b&&(this.b=new an(pi,this,4,7)),!(this.b.i<=1&&(!this.c&&(this.c=new an(pi,this,5,8)),this.c.i<=1));case 8:return vt(),!!rP(this);case 9:return vt(),!!z0(this);case 10:return vt(),!this.b&&(this.b=new an(pi,this,4,7)),this.b.i!=0&&(!this.c&&(this.c=new an(pi,this,5,8)),this.c.i!=0)}return Nbe(this,t,i,a)},p.Bg=function(t,i,a){var l;switch(i){case 3:return this.Cb&&(a=(l=this.Db>>16,l>=0?kwe(this,a):this.Cb.Cg(this,-1-l,null,a))),nme(this,h(t,35),a);case 4:return!this.b&&(this.b=new an(pi,this,4,7)),ja(this.b,t,a);case 5:return!this.c&&(this.c=new an(pi,this,5,8)),ja(this.c,t,a);case 6:return!this.a&&(this.a=new ze(ts,this,6,6)),ja(this.a,t,a)}return Dte(this,t,i,a)},p.Dg=function(t,i,a){switch(i){case 3:return nme(this,null,a);case 4:return!this.b&&(this.b=new an(pi,this,4,7)),Us(this.b,t,a);case 5:return!this.c&&(this.c=new an(pi,this,5,8)),Us(this.c,t,a);case 6:return!this.a&&(this.a=new ze(ts,this,6,6)),Us(this.a,t,a)}return Mee(this,t,i,a)},p.Fg=function(t){switch(t){case 3:return!!V9(this);case 4:return!!this.b&&this.b.i!=0;case 5:return!!this.c&&this.c.i!=0;case 6:return!!this.a&&this.a.i!=0;case 7:return!this.b&&(this.b=new an(pi,this,4,7)),!(this.b.i<=1&&(!this.c&&(this.c=new an(pi,this,5,8)),this.c.i<=1));case 8:return rP(this);case 9:return z0(this);case 10:return!this.b&&(this.b=new an(pi,this,4,7)),this.b.i!=0&&(!this.c&&(this.c=new an(pi,this,5,8)),this.c.i!=0)}return fbe(this,t)},p.Mg=function(t,i){switch(t){case 3:SYe(this,h(i,35));return;case 4:!this.b&&(this.b=new an(pi,this,4,7)),Pr(this.b),!this.b&&(this.b=new an(pi,this,4,7)),Mr(this.b,h(i,13));return;case 5:!this.c&&(this.c=new an(pi,this,5,8)),Pr(this.c),!this.c&&(this.c=new an(pi,this,5,8)),Mr(this.c,h(i,13));return;case 6:!this.a&&(this.a=new ze(ts,this,6,6)),Pr(this.a),!this.a&&(this.a=new ze(ts,this,6,6)),Mr(this.a,h(i,13));return}jwe(this,t,i)},p.Rg=function(){return Ta(),EAe},p.Ib=function(){return uKe(this)};var APn=k(b1,"ElkEdgeImpl",183);A(405,1676,{95:1,379:1,270:1,405:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1},mE),p.jg=function(t){return Awe(this,t)},p.ug=function(t,i,a){switch(t){case 1:return this.j;case 2:return this.k;case 3:return this.b;case 4:return this.c;case 5:return!this.a&&(this.a=new vs(ah,this,5)),this.a;case 6:return g7e(this);case 7:return i?mte(this):this.i;case 8:return i?gte(this):this.f;case 9:return!this.g&&(this.g=new an(ts,this,9,10)),this.g;case 10:return!this.e&&(this.e=new an(ts,this,10,9)),this.e;case 11:return this.d}return Mwe(this,t,i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 6:return this.Cb&&(a=(f=this.Db>>16,f>=0?Awe(this,a):this.Cb.Cg(this,-1-f,null,a))),ime(this,h(t,105),a);case 9:return!this.g&&(this.g=new an(ts,this,9,10)),ja(this.g,t,a);case 10:return!this.e&&(this.e=new an(ts,this,10,9)),ja(this.e,t,a)}return g=h(Wt((l=h(sn(this,16),24),l||(Ta(),Cj)),i),61),g.aj().dj(this,Ya(this),i-jn((Ta(),Cj)),t,a)},p.Dg=function(t,i,a){switch(i){case 5:return!this.a&&(this.a=new vs(ah,this,5)),Us(this.a,t,a);case 6:return ime(this,null,a);case 9:return!this.g&&(this.g=new an(ts,this,9,10)),Us(this.g,t,a);case 10:return!this.e&&(this.e=new an(ts,this,10,9)),Us(this.e,t,a)}return sve(this,t,i,a)},p.Fg=function(t){switch(t){case 1:return this.j!=0;case 2:return this.k!=0;case 3:return this.b!=0;case 4:return this.c!=0;case 5:return!!this.a&&this.a.i!=0;case 6:return!!g7e(this);case 7:return!!this.i;case 8:return!!this.f;case 9:return!!this.g&&this.g.i!=0;case 10:return!!this.e&&this.e.i!=0;case 11:return this.d!=null}return q1e(this,t)},p.Mg=function(t,i){switch(t){case 1:AA(this,ce(Xe(i)));return;case 2:PA(this,ce(Xe(i)));return;case 3:CA(this,ce(Xe(i)));return;case 4:TA(this,ce(Xe(i)));return;case 5:!this.a&&(this.a=new vs(ah,this,5)),Pr(this.a),!this.a&&(this.a=new vs(ah,this,5)),Mr(this.a,h(i,13));return;case 6:o9t(this,h(i,105));return;case 7:ebe(this,h(i,97));return;case 8:Q0e(this,h(i,97));return;case 9:!this.g&&(this.g=new an(ts,this,9,10)),Pr(this.g),!this.g&&(this.g=new an(ts,this,9,10)),Mr(this.g,h(i,13));return;case 10:!this.e&&(this.e=new an(ts,this,10,9)),Pr(this.e),!this.e&&(this.e=new an(ts,this,10,9)),Mr(this.e,h(i,13));return;case 11:u$e(this,ti(i));return}xbe(this,t,i)},p.Rg=function(){return Ta(),Cj},p.Ib=function(){return kXe(this)},p.b=0,p.c=0,p.d=null,p.j=0,p.k=0;var PPn=k(b1,"ElkEdgeSectionImpl",405);A(142,108,{95:1,91:1,87:1,139:1,51:1,103:1,42:1,92:1,142:1,107:1,108:1}),p.ug=function(t,i,a){var l;return t==0?(!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab):jl(this,t-jn(this.Rg()),Wt((l=h(sn(this,16),24),l||this.Rg()),t),i,a)},p.Bg=function(t,i,a){var l,f;return i==0?(!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),ja(this.Ab,t,a)):(f=h(Wt((l=h(sn(this,16),24),l||this.Rg()),i),61),f.aj().dj(this,Ya(this),i-jn(this.Rg()),t,a))},p.Dg=function(t,i,a){var l,f;return i==0?(!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a)):(f=h(Wt((l=h(sn(this,16),24),l||this.Rg()),i),61),f.aj().ej(this,Ya(this),i-jn(this.Rg()),t,a))},p.Fg=function(t){var i;return t==0?!!this.Ab&&this.Ab.i!=0:zl(this,t-jn(this.Rg()),Wt((i=h(sn(this,16),24),i||this.Rg()),t))},p.Ig=function(t){return D_e(this,t)},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return}Wl(this,t-jn(this.Rg()),Wt((a=h(sn(this,16),24),a||this.Rg()),t),i)},p.Og=function(t){VA(this,128,t)},p.Rg=function(){return yt(),Ylt},p.Xg=function(){this.Bb|=1},p.Yg=function(t){return uP(this,t)},p.Bb=0;var LPn=k(Lt,"EModelElementImpl",142);A(638,142,{95:1,91:1,87:1,430:1,139:1,51:1,103:1,42:1,92:1,142:1,107:1,108:1},hF),p.Zg=function(t,i){return OKe(this,t,i)},p.$g=function(t){var i,a,l,f,g;if(this.a!=$l(t)||t.Bb&256)throw Y(new un(bre+t.zb+X0));for(l=Bo(t);Ea(l.a).i!=0;){if(a=h(B6(l,0,(i=h(ae(Ea(l.a),0),84),g=i.c,re(g,96)?h(g,24):(yt(),ff))),24),N0(a))return f=$l(a).dh().$g(a),h(f,42).Ng(t),f;l=Bo(a)}return(t.D!=null?t.D:t.B)=="java.util.Map$Entry"?new w9e(t):new Fme(t)},p._g=function(t,i){return j0(this,t,i)},p.ug=function(t,i,a){var l;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.a}return jl(this,t-jn((yt(),vb)),Wt((l=h(sn(this,16),24),l||vb),t),i,a)},p.Bg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),ja(this.Ab,t,a);case 1:return this.a&&(a=h(this.a,42).Cg(this,4,ch,a)),Rbe(this,h(t,207),a)}return f=h(Wt((l=h(sn(this,16),24),l||(yt(),vb)),i),61),f.aj().dj(this,Ya(this),i-jn((yt(),vb)),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a);case 1:return Rbe(this,null,a)}return f=h(Wt((l=h(sn(this,16),24),l||(yt(),vb)),i),61),f.aj().ej(this,Ya(this),i-jn((yt(),vb)),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return!!this.a}return zl(this,t-jn((yt(),vb)),Wt((i=h(sn(this,16),24),i||vb),t))},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:QOt(this,h(i,207));return}Wl(this,t-jn((yt(),vb)),Wt((a=h(sn(this,16),24),a||vb),t),i)},p.Rg=function(){return yt(),vb};var RL,CAe,Rlt,kPn=k(Lt,"EFactoryImpl",638);A(914,638,{95:1,1698:1,91:1,87:1,430:1,139:1,51:1,103:1,42:1,92:1,142:1,107:1,108:1},Dm),p.Zg=function(t,i){switch(t.Ni()){case 12:return h(i,166).Lf();case 13:return Ga(i);default:throw Y(new un(eM+t.be()+X0))}},p.$g=function(t){var i,a,l,f,g,m,v,y;switch(t.G==-1&&(t.G=(i=$l(t),i?$p(i.bh(),t):-1)),t.G){case 4:return g=new ZT,g;case 6:return m=new cpe,m;case 7:return v=new lpe,v;case 8:return l=new YT,l;case 9:return a=new gE,a;case 10:return f=new mE,f;case 11:return y=new Nk,y;default:throw Y(new un(bre+t.zb+X0))}},p._g=function(t,i){switch(t.Ni()){case 13:case 12:return null;default:throw Y(new un(eM+t.be()+X0))}};var RPn=k(b1,"ElkGraphFactoryImpl",914);A(399,142,{95:1,91:1,87:1,139:1,174:1,51:1,103:1,42:1,92:1,142:1,107:1,108:1}),p.pg=function(){var t,i;return i=(t=h(sn(this,16),24),z1e(Jg(t||this.Rg()))),i==null?(LC(),LC(),Dae):new jFe(this,i)},p.ug=function(t,i,a){var l;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.be()}return jl(this,t-jn(this.Rg()),Wt((l=h(sn(this,16),24),l||this.Rg()),t),i,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null}return zl(this,t-jn(this.Rg()),Wt((i=h(sn(this,16),24),i||this.Rg()),t))},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:this.ah(ti(i));return}Wl(this,t-jn(this.Rg()),Wt((a=h(sn(this,16),24),a||this.Rg()),t),i)},p.Rg=function(){return yt(),Zlt},p.be=function(){return this.zb},p.ah=function(t){Mf(this,t)},p.Ib=function(){return FA(this)},p.zb=null;var IPn=k(Lt,"ENamedElementImpl",399);A(248,399,{95:1,91:1,87:1,139:1,174:1,51:1,207:1,103:1,42:1,92:1,142:1,248:1,107:1,108:1,613:1},UUe),p.jg=function(t){return VHe(this,t)},p.ug=function(t,i,a){var l;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.zb;case 2:return this.yb;case 3:return this.xb;case 4:return this.sb;case 5:return!this.rb&&(this.rb=new u_(this,lh,this)),this.rb;case 6:return!this.vb&&(this.vb=new ZE(ch,this,6,7)),this.vb;case 7:return i?this.Db>>16==7?h(this.Cb,207):null:m7e(this)}return jl(this,t-jn((yt(),k1)),Wt((l=h(sn(this,16),24),l||k1),t),i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),ja(this.Ab,t,a);case 4:return this.sb&&(a=h(this.sb,42).Cg(this,1,kL,a)),Dbe(this,h(t,430),a);case 5:return!this.rb&&(this.rb=new u_(this,lh,this)),ja(this.rb,t,a);case 6:return!this.vb&&(this.vb=new ZE(ch,this,6,7)),ja(this.vb,t,a);case 7:return this.Cb&&(a=(f=this.Db>>16,f>=0?VHe(this,a):this.Cb.Cg(this,-1-f,null,a))),Ml(this,t,7,a)}return g=h(Wt((l=h(sn(this,16),24),l||(yt(),k1)),i),61),g.aj().dj(this,Ya(this),i-jn((yt(),k1)),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a);case 4:return Dbe(this,null,a);case 5:return!this.rb&&(this.rb=new u_(this,lh,this)),Us(this.rb,t,a);case 6:return!this.vb&&(this.vb=new ZE(ch,this,6,7)),Us(this.vb,t,a);case 7:return Ml(this,null,7,a)}return f=h(Wt((l=h(sn(this,16),24),l||(yt(),k1)),i),61),f.aj().ej(this,Ya(this),i-jn((yt(),k1)),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.yb!=null;case 3:return this.xb!=null;case 4:return!!this.sb;case 5:return!!this.rb&&this.rb.i!=0;case 6:return!!this.vb&&this.vb.i!=0;case 7:return!!m7e(this)}return zl(this,t-jn((yt(),k1)),Wt((i=h(sn(this,16),24),i||k1),t))},p.Ig=function(t){var i;return i=g9t(this,t),i||D_e(this,t)},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:Mf(this,ti(i));return;case 2:gee(this,ti(i));return;case 3:pee(this,ti(i));return;case 4:ove(this,h(i,430));return;case 5:!this.rb&&(this.rb=new u_(this,lh,this)),Pr(this.rb),!this.rb&&(this.rb=new u_(this,lh,this)),Mr(this.rb,h(i,13));return;case 6:!this.vb&&(this.vb=new ZE(ch,this,6,7)),Pr(this.vb),!this.vb&&(this.vb=new ZE(ch,this,6,7)),Mr(this.vb,h(i,13));return}Wl(this,t-jn((yt(),k1)),Wt((a=h(sn(this,16),24),a||k1),t),i)},p.Rg=function(){return yt(),k1},p.Xg=function(){Tte(this)},p.bh=function(){return!this.rb&&(this.rb=new u_(this,lh,this)),this.rb},p.dh=function(){return this.sb},p.eh=function(){return this.ub},p.fh=function(){return this.xb},p.gh=function(){return this.yb},p.hh=function(t){this.ub=t},p.Ib=function(){var t;return this.Db&64?FA(this):(t=new su(FA(this)),t.a+=" (nsURI: ",ho(t,this.yb),t.a+=", nsPrefix: ",ho(t,this.xb),t.a+=")",t.a)},p.xb=null,p.yb=null;var Ilt,DPn=k(Lt,"EPackageImpl",248);A(506,248,{95:1,1702:1,506:1,91:1,87:1,139:1,174:1,51:1,207:1,103:1,42:1,92:1,142:1,248:1,107:1,108:1,613:1},HXe),p.q=!1,p.r=!1;var Dlt=!1,BPn=k(b1,"ElkGraphPackageImpl",506);A(263,652,{95:1,379:1,253:1,137:1,429:1,263:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1},ZT),p.jg=function(t){return Pwe(this,t)},p.ug=function(t,i,a){switch(t){case 7:return b7e(this);case 8:return this.a}return Hbe(this,t,i,a)},p.Bg=function(t,i,a){var l;switch(i){case 7:return this.Cb&&(a=(l=this.Db>>16,l>=0?Pwe(this,a):this.Cb.Cg(this,-1-l,null,a))),Qme(this,h(t,253),a)}return Dte(this,t,i,a)},p.Dg=function(t,i,a){return i==7?Qme(this,null,a):Mee(this,t,i,a)},p.Fg=function(t){switch(t){case 7:return!!b7e(this);case 8:return!dt("",this.a)}return Kbe(this,t)},p.Mg=function(t,i){switch(t){case 7:kYe(this,h(i,253));return;case 8:i$e(this,ti(i));return}$we(this,t,i)},p.Rg=function(){return Ta(),SAe},p.Ib=function(){return Oqe(this)},p.a="";var OPn=k(b1,"ElkLabelImpl",263);A(246,653,{95:1,379:1,97:1,253:1,35:1,429:1,246:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1},cpe),p.jg=function(t){return Dwe(this,t)},p.ug=function(t,i,a){switch(t){case 9:return!this.c&&(this.c=new ze(Pu,this,9,9)),this.c;case 10:return!this.a&&(this.a=new ze(Br,this,10,11)),this.a;case 11:return eo(this);case 12:return!this.b&&(this.b=new ze(js,this,12,3)),this.b;case 13:return vt(),!this.a&&(this.a=new ze(Br,this,10,11)),this.a.i>0}return bwe(this,t,i,a)},p.Bg=function(t,i,a){var l;switch(i){case 9:return!this.c&&(this.c=new ze(Pu,this,9,9)),ja(this.c,t,a);case 10:return!this.a&&(this.a=new ze(Br,this,10,11)),ja(this.a,t,a);case 11:return this.Cb&&(a=(l=this.Db>>16,l>=0?Dwe(this,a):this.Cb.Cg(this,-1-l,null,a))),hme(this,h(t,35),a);case 12:return!this.b&&(this.b=new ze(js,this,12,3)),ja(this.b,t,a)}return Nwe(this,t,i,a)},p.Dg=function(t,i,a){switch(i){case 9:return!this.c&&(this.c=new ze(Pu,this,9,9)),Us(this.c,t,a);case 10:return!this.a&&(this.a=new ze(Br,this,10,11)),Us(this.a,t,a);case 11:return hme(this,null,a);case 12:return!this.b&&(this.b=new ze(js,this,12,3)),Us(this.b,t,a)}return Fwe(this,t,i,a)},p.Fg=function(t){switch(t){case 9:return!!this.c&&this.c.i!=0;case 10:return!!this.a&&this.a.i!=0;case 11:return!!eo(this);case 12:return!!this.b&&this.b.i!=0;case 13:return!this.a&&(this.a=new ze(Br,this,10,11)),this.a.i>0}return _be(this,t)},p.Mg=function(t,i){switch(t){case 9:!this.c&&(this.c=new ze(Pu,this,9,9)),Pr(this.c),!this.c&&(this.c=new ze(Pu,this,9,9)),Mr(this.c,h(i,13));return;case 10:!this.a&&(this.a=new ze(Br,this,10,11)),Pr(this.a),!this.a&&(this.a=new ze(Br,this,10,11)),Mr(this.a,h(i,13));return;case 11:TYe(this,h(i,35));return;case 12:!this.b&&(this.b=new ze(js,this,12,3)),Pr(this.b),!this.b&&(this.b=new ze(js,this,12,3)),Mr(this.b,h(i,13));return}Ive(this,t,i)},p.Rg=function(){return Ta(),MAe},p.Ib=function(){return s_e(this)};var NPn=k(b1,"ElkNodeImpl",246);A(187,653,{95:1,379:1,97:1,253:1,121:1,429:1,187:1,93:1,91:1,87:1,51:1,103:1,42:1,92:1,107:1,108:1},lpe),p.jg=function(t){return Lwe(this,t)},p.ug=function(t,i,a){return t==9?Sh(this):bwe(this,t,i,a)},p.Bg=function(t,i,a){var l;switch(i){case 9:return this.Cb&&(a=(l=this.Db>>16,l>=0?Lwe(this,a):this.Cb.Cg(this,-1-l,null,a))),rme(this,h(t,35),a)}return Nwe(this,t,i,a)},p.Dg=function(t,i,a){return i==9?rme(this,null,a):Fwe(this,t,i,a)},p.Fg=function(t){return t==9?!!Sh(this):_be(this,t)},p.Mg=function(t,i){switch(t){case 9:MYe(this,h(i,35));return}Ive(this,t,i)},p.Rg=function(){return Ta(),TAe},p.Ib=function(){return vZe(this)};var FPn=k(b1,"ElkPortImpl",187),Blt=_r(Gs,"BasicEMap/Entry");A(966,108,{95:1,38:1,91:1,87:1,134:1,51:1,103:1,42:1,92:1,107:1,108:1},Nk),p.Fb=function(t){return this===t},p.kc=function(){return this.b},p.Hb=function(){return g0(this)},p.kh=function(t){n$e(this,h(t,166))},p.ug=function(t,i,a){switch(t){case 0:return this.b;case 1:return this.c}return t7(this,t,i,a)},p.Fg=function(t){switch(t){case 0:return!!this.b;case 1:return this.c!=null}return fte(this,t)},p.Mg=function(t,i){switch(t){case 0:n$e(this,h(i,166));return;case 1:t$e(this,i);return}b7(this,t,i)},p.Rg=function(){return Ta(),op},p.ih=function(){var t;return this.a==-1&&(t=this.b,this.a=t?Hr(t):0),this.a},p.lc=function(){return this.c},p.jh=function(t){this.a=t},p.mc=function(t){var i;return i=this.c,t$e(this,t),i},p.Ib=function(){var t;return this.Db&64?Ku(this):(t=new f0,Mi(Mi(Mi(t,this.b?this.b.Lf():Xc)," -> "),YC(this.c)),t.a)},p.a=-1,p.c=null;var pm=k(b1,"ElkPropertyToValueMapEntryImpl",966);A(876,1,{},Xq);var UPn=k(Ps,"JsonAdapter",876);A(186,54,Zd,_h);var zPn=k(Ps,"JsonImportException",186);A(754,1,{},iqe);var GPn=k(Ps,"JsonImporter",754);A(792,1,{},tNe);var jPn=k(Ps,"JsonImporter/lambda$0$Type",792);A(793,1,{},nNe);var $Pn=k(Ps,"JsonImporter/lambda$1$Type",793);A(816,1,{},YF);var VPn=k(Ps,"JsonImporter/lambda$10$Type",816);A(818,1,{},_Z);var WPn=k(Ps,"JsonImporter/lambda$11$Type",818);A(819,1,{},iNe),p.td=function(t){T4t(this.b,this.a,t)};var HPn=k(Ps,"JsonImporter/lambda$12$Type",819);A(820,1,{},rNe);var qPn=k(Ps,"JsonImporter/lambda$13$Type",820);A(821,1,{},sNe);var XPn=k(Ps,"JsonImporter/lambda$14$Type",821);A(822,1,{},yZ);var YPn=k(Ps,"JsonImporter/lambda$15$Type",822);A(823,1,{},xZ);var ZPn=k(Ps,"JsonImporter/lambda$16$Type",823);A(824,1,{},EZ);var KPn=k(Ps,"JsonImporter/lambda$17$Type",824);A(825,1,{},O2);var JPn=k(Ps,"JsonImporter/lambda$18$Type",825);A(756,1,{},SZ);var QPn=k(Ps,"JsonImporter/lambda$19$Type",756);A(794,1,{},MZ);var eLn=k(Ps,"JsonImporter/lambda$2$Type",794);A(829,1,{},q8e);var tLn=k(Ps,"JsonImporter/lambda$20$Type",829);A(830,1,{},TZ),p.td=function(t){C4t(this.a,t)};var nLn=k(Ps,"JsonImporter/lambda$21$Type",830);A(795,1,{},CZ);var iLn=k(Ps,"JsonImporter/lambda$22$Type",795);A(796,1,{},AZ);var rLn=k(Ps,"JsonImporter/lambda$23$Type",796);A(798,1,{},ZF);var sLn=k(Ps,"JsonImporter/lambda$24$Type",798);A(799,1,{},KF);var oLn=k(Ps,"JsonImporter/lambda$25$Type",799);A(801,1,{},PZ);var aLn=k(Ps,"JsonImporter/lambda$26$Type",801);A(809,1,{},CUe);var cLn=k(Ps,"JsonImporter/lambda$27$Type",809);A(811,1,{},LZ);var lLn=k(Ps,"JsonImporter/lambda$28$Type",811);A(812,1,{},kZ);var uLn=k(Ps,"JsonImporter/lambda$29$Type",812);A(797,1,{},RZ);var fLn=k(Ps,"JsonImporter/lambda$3$Type",797);A(814,1,{},IZ);var hLn=k(Ps,"JsonImporter/lambda$30$Type",814);A(815,1,{},DZ);var dLn=k(Ps,"JsonImporter/lambda$31$Type",815);A(817,1,{},BZ);var pLn=k(Ps,"JsonImporter/lambda$32$Type",817);A(826,1,{},OZ),p.td=function(t){A4t(this.a,t)};var gLn=k(Ps,"JsonImporter/lambda$33$Type",826);A(827,1,{},oNe),p.td=function(t){rSt(this.a,this.b,t)};var mLn=k(Ps,"JsonImporter/lambda$34$Type",827);A(828,1,{},aNe),p.td=function(t){sSt(this.a,this.b,t)};var bLn=k(Ps,"JsonImporter/lambda$35$Type",828);A(805,1,{},cNe);var wLn=k(Ps,"JsonImporter/lambda$36$Type",805);A(806,1,{},lNe);var vLn=k(Ps,"JsonImporter/lambda$37$Type",806);A(807,1,{},hNe);var _Ln=k(Ps,"JsonImporter/lambda$38$Type",807);A(808,1,{},dNe);var yLn=k(Ps,"JsonImporter/lambda$39$Type",808);A(800,1,{},NZ);var xLn=k(Ps,"JsonImporter/lambda$4$Type",800);A(802,1,{},FZ);var ELn=k(Ps,"JsonImporter/lambda$5$Type",802);A(803,1,{},uNe);var SLn=k(Ps,"JsonImporter/lambda$6$Type",803);A(804,1,{},fNe);var MLn=k(Ps,"JsonImporter/lambda$7$Type",804);A(810,1,{},AUe);var TLn=k(Ps,"JsonImporter/lambda$8$Type",810);A(813,1,{},UZ);var CLn=k(Ps,"JsonImporter/lambda$9$Type",813);A(864,1,{},zZ),p.td=function(t){ox(this.a,new rx(ti(t)))};var ALn=k(Ps,"JsonMetaDataConverter/lambda$0$Type",864);A(865,1,{},GZ),p.td=function(t){KAt(this.a,t)};var PLn=k(Ps,"JsonMetaDataConverter/lambda$1$Type",865);A(866,1,{},jZ),p.td=function(t){cLt(this.a,t)};var LLn=k(Ps,"JsonMetaDataConverter/lambda$2$Type",866);A(867,1,{},$Z),p.td=function(t){ZAt(this.a,t)};var kLn=k(Ps,"JsonMetaDataConverter/lambda$3$Type",867);A(229,23,{3:1,34:1,23:1,229:1},Q2);var Aj,Pj,Cae,Lj,kj,Rj,Aae,Pae,Ij=Ti(q6,"GraphFeature",229,Di,aRt,DCt),Olt;A(16,1,{34:1,166:1},Sr,Zr,ln,wa),p.vd=function(t){return FSt(this,h(t,166))},p.Fb=function(t){return zUe(this,t)},p.Of=function(){return qt(this)},p.Lf=function(){return this.b},p.Hb=function(){return Hg(this.b)},p.Ib=function(){return this.b};var RLn=k(q6,"Property",16);A(727,1,Or,JF),p.Ld=function(t,i){return p6t(this,h(t,93),h(i,93))},p.Fb=function(t){return this===t},p.Md=function(){return new gr(this)};var ILn=k(q6,"PropertyHolderComparator",727),AAe=_r(Gs,"EList");A(59,41,{20:1,25:1,41:1,13:1,15:1,59:1,52:1}),p.bd=function(t,i){JI(this,t,i)},p.nc=function(t){return $n(this,t)},p.oc=function(t){return Mr(this,t)},p.oh=function(){return new nx(this)},p.ph=function(){return new QR(this)},p.qh=function(t){return GI(this,t)},p.rh=function(){return!0},p.sh=function(t,i){},p.th=function(){},p.uh=function(t,i){GQ(this,t,i)},p.vh=function(t,i){},p.wh=function(t,i,a){},p.Fb=function(t){return iZe(this,t)},p.Hb=function(){return pbe(this)},p.xh=function(){return!1},p.tc=function(){return new Bn(this)},p.ed=function(){return new QC(this)},p.fd=function(t){var i;if(i=this._b(),t<0||t>i)throw Y(new o_(t,i));return new KJ(this,t)},p.vc=function(t){return JQ(this,t)},p.zh=function(t,i){return i},p.hd=function(t,i){return xx(this,t,i)},p.Ib=function(){return Xbe(this)},p.Bh=function(){return!0},p.Ch=function(t,i){return DA(this,i)};var DLn=k(Gs,"AbstractEList",59);A(55,59,Ih,i0,w_,cbe),p.lh=function(t){return kHe(this,t)},p.mh=function(t,i){e6(this,t,i)},p.nh=function(t){MI(this,t)},p.Dh=function(t){return P0e(this,t)},p.Pb=function(){_A(this)},p.pc=function(t){return QA(this,t)},p.cd=function(t){return ae(this,t)},p.Eh=function(t){eHe(this,t)},p.dd=function(t){return $He(this,t)},p.Wb=function(){return this.i==0},p.Fh=function(t){return le(on,et,1,t,5,1)},p.yh=function(t){return this.g[t]},p.gd=function(t){return Ex(this,t)},p.Ah=function(t,i){return KQ(this,t,i)},p._b=function(){return this.i},p.yc=function(){return K1e(this)},p.zc=function(t){return ewe(this,t)},p.i=0;var PAe=k(Gs,"BasicEList",55),LAe=_r(Gs,"TreeIterator");A(629,55,Tre),p.gc=function(t){Ss(this,t)},p.hc=function(){return this.g==null&&!this.c?P1e(this):this.g==null||this.i!=0&&h(this.g[this.i-1],43).hc()},p.ic=function(){return _7(this)},p.jc=function(){if(!this.e)throw Y(new ba("There is no valid object to remove."));this.e.jc()},p.c=!1;var BLn=k(Gs,"AbstractTreeIterator",629);A(621,629,Tre,_ge),p.Gh=function(t){var i;return i=h(t,51).pg().tc(),re(i,260)&&h(i,260).Zj(new wN),i};var OLn=k(Cre,"ElkGraphUtil/PropertiesSkippingTreeIterator",621);A(868,1,{},wN);var NLn=k(Cre,"ElkGraphUtil/PropertiesSkippingTreeIterator/1",868),bD,Lae,wD=k(Cre,"ElkReflect",null);A(784,1,ny,KT),p.Nf=function(t){return tU(),ukt(h(t,185))};var FLn=k(Cre,"ElkReflect/lambda$0$Type",784),ev,ULn=_r(Gs,"ResourceLocator");A(953,1,{});var zLn=k(Gs,"DelegatingResourceLocator",953);A(954,953,{});var GLn=k("org.eclipse.emf.common","EMFPlugin",954),kae=_r(btt,"Adapter"),CVt=_r(btt,"Notification");A(1016,1,Bxe),p.Hh=function(){return this.d},p.Ih=function(t){},p.Jh=function(t){this.d=t},p.Kh=function(t){this.d==t&&(this.d=null)},p.d=null;var jLn=k(Hx,"AdapterImpl",1016);A(1688,59,wtt),p.lh=function(t){var i,a,l;if(++this.j,t.Wb())return!1;for(i=this.hi(),l=t.tc();l.hc();)a=l.ic(),this.Wh(this.Ch(i,a)),++i;return!0},p.mh=function(t,i){t8e(this,t,i)},p.nh=function(t){iUe(this,t)},p.Uh=function(){return this.Xh()},p.Pb=function(){rI(this,this.hi(),this.ii())},p.pc=function(t){return this.Zh(t)},p.qc=function(t){return this.$h(t)},p.Vh=function(t,i){this.ei().tl()},p.Wh=function(t){this.ei().tl()},p.Xh=function(){return this.ei()},p.Yh=function(){this.ei().tl()},p.Zh=function(t){return this.ei().tl()},p.$h=function(t){return this.ei().tl()},p._h=function(t){return this.ei().tl()},p.ai=function(t){return this.ei().tl()},p.bi=function(){return this.ei().tl()},p.ci=function(t){return this.ei().tl()},p.di=function(){return this.ei().tl()},p.fi=function(t){return this.ei().tl()},p.gi=function(t,i){return this.ei().tl()},p.hi=function(){return this.ei().tl()},p.ii=function(){return this.ei().tl()},p.ji=function(t){return this.ei().tl()},p.ki=function(){return this.ei().tl()},p.Fb=function(t){return this._h(t)},p.cd=function(t){return this.zh(t,this.ai(t))},p.Hb=function(){return this.bi()},p.dd=function(t){return this.ci(t)},p.Wb=function(){return this.di()},p.yh=function(t){return this.ai(t)},p.gd=function(t){return x9(this,t)},p.vc=function(t){var i;return i=this.dd(t),i>=0?(this.gd(i),!0):!1},p.Ah=function(t,i){return this.gi(t,this.Ch(t,i))},p._b=function(){return this.hi()},p.yc=function(){return this.ii()},p.zc=function(t){return this.ji(t)},p.Ib=function(){return this.ki()};var $Ln=k(Gs,"DelegatingEList",1688);A(1689,1688,wtt),p.li=function(t,i){return m_e(this,t,i)},p.lh=function(t){return this.li(this.hi(),t)},p.mh=function(t,i){qXe(this,t,i)},p.nh=function(t){UXe(this,t)},p.rh=function(){return!this.qi()},p.Pb=function(){O7(this)},p.mi=function(t,i,a,l,f){return new YUe(this,t,i,a,l,f)},p.ni=function(t){Li(this.Oh(),t)},p.oi=function(){return null},p.pi=function(){return-1},p.Oh=function(){return null},p.qi=function(){return!1},p.ri=function(t,i){return i},p.si=function(t,i){return i},p.ti=function(){return!1},p.ui=function(){return!this.di()},p.gd=function(t){var i,a,l,f;return this.ti()?(l=this.ui(),i=this.mi(4,f=x9(this,t),null,t,l),this.qi()&&f?(a=this.si(f,null),a?(a.Sh(i),a.Th()):this.ni(i)):this.ni(i),f):(f=x9(this,t),this.qi()&&f&&(a=this.si(f,null),a&&a.Th()),f)},p.Ah=function(t,i){return UZe(this,t,i)};var VLn=k(Hx,"DelegatingNotifyingListImpl",1689);A(136,1,o5),p.Sh=function(t){return Hwe(this,t)},p.Th=function(){XQ(this)},p.Lh=function(){return this.d},p.oi=function(){return null},p.vi=function(){return null},p.Mh=function(t){return-1},p.Nh=function(){return BYe(this)},p.Oh=function(){return null},p.Ph=function(){return Wve(this)},p.Qh=function(){return this.o<0?this.o<-2?-2-this.o-1:-1:this.o},p.wi=function(){return!1},p.Rh=function(t){var i,a,l,f,g,m,v,y,E,C,R;switch(this.d){case 1:case 2:switch(f=t.Lh(),f){case 1:case 2:if(g=t.Oh(),Be(g)===Be(this.Oh())&&this.Mh(null)==t.Mh(null))return this.g=t.Nh(),t.Lh()==1&&(this.d=1),!0}case 4:{switch(f=t.Lh(),f){case 4:{if(g=t.Oh(),Be(g)===Be(this.Oh())&&this.Mh(null)==t.Mh(null))return E=P_e(this),y=this.o<0?this.o<-2?-2-this.o-1:-1:this.o,m=t.Qh(),this.d=6,R=new w_(2),y<=m?($n(R,this.n),$n(R,t.Ph()),this.g=X(q(In,1),si,22,15,[this.o=y,m+1])):($n(R,t.Ph()),$n(R,this.n),this.g=X(q(In,1),si,22,15,[this.o=m,y])),this.n=R,E||(this.o=-2-this.o-1),!0;break}}break}case 6:{switch(f=t.Lh(),f){case 4:{if(g=t.Oh(),Be(g)===Be(this.Oh())&&this.Mh(null)==t.Mh(null)){for(E=P_e(this),m=t.Qh(),C=h(this.g,37),l=le(In,si,22,C.length+1,15,1),i=0;i>>0).toString(16)),a.a+=" (eventType: ",this.d){case 1:{a.a+="SET";break}case 2:{a.a+="UNSET";break}case 3:{a.a+="ADD";break}case 5:{a.a+="ADD_MANY";break}case 4:{a.a+="REMOVE";break}case 6:{a.a+="REMOVE_MANY";break}case 7:{a.a+="MOVE";break}case 8:{a.a+="REMOVING_ADAPTER";break}case 9:{a.a+="RESOLVE";break}default:{wK(a,this.d);break}}if(MZe(this)&&(a.a+=", touch: true"),a.a+=", position: ",wK(a,this.o<0?this.o<-2?-2-this.o-1:-1:this.o),a.a+=", notifier: ",OC(a,this.Oh()),a.a+=", feature: ",OC(a,this.oi()),a.a+=", oldValue: ",OC(a,Wve(this)),a.a+=", newValue: ",this.d==6&&re(this.g,37)){for(i=h(this.g,37),a.a+="[",t=0;t10?((!this.b||this.c.j!=this.a)&&(this.b=new hI(this),this.a=this.j),IC(this.b,t)):QA(this,t)},p.Bh=function(){return!0},p.a=0;var KLn=k(Gs,"AbstractEList/1",869);A(295,79,lie,o_);var JLn=k(Gs,"AbstractEList/BasicIndexOutOfBoundsException",295);A(36,1,ys,Bn),p.gc=function(t){Ss(this,t)},p.Bi=function(){if(this.i.j!=this.f)throw Y(new P)},p.Ci=function(){return Yn(this)},p.hc=function(){return this.e!=this.i._b()},p.ic=function(){return this.Ci()},p.jc=function(){KA(this)},p.e=0,p.f=0,p.g=-1;var QLn=k(Gs,"AbstractEList/EIterator",36);A(296,36,Ch,QC,KJ),p.jc=function(){KA(this)},p.Bc=function(t){MWe(this,t)},p.Di=function(){var t;try{return t=this.d.cd(--this.e),this.Bi(),this.g=this.e,t}catch(i){throw i=pr(i),re(i,79)?(this.Bi(),Y(new K)):Y(i)}},p.Ei=function(t){xHe(this,t)},p.Cc=function(){return this.e!=0},p.Dc=function(){return this.e},p.Ec=function(){return this.Di()},p.Fc=function(){return this.e-1},p.Gc=function(t){this.Ei(t)};var e4n=k(Gs,"AbstractEList/EListIterator",296);A(324,36,ys,nx),p.Ci=function(){return ate(this)},p.jc=function(){throw Y(new Pi)};var t4n=k(Gs,"AbstractEList/NonResolvingEIterator",324);A(355,296,Ch,QR,Sme),p.Bc=function(t){throw Y(new Pi)},p.Ci=function(){var t;try{return t=this.c.yh(this.e),this.Bi(),this.g=this.e++,t}catch(i){throw i=pr(i),re(i,79)?(this.Bi(),Y(new K)):Y(i)}},p.Di=function(){var t;try{return t=this.c.yh(--this.e),this.Bi(),this.g=this.e,t}catch(i){throw i=pr(i),re(i,79)?(this.Bi(),Y(new K)):Y(i)}},p.jc=function(){throw Y(new Pi)},p.Gc=function(t){throw Y(new Pi)};var n4n=k(Gs,"AbstractEList/NonResolvingEListIterator",355);A(1673,59,vtt),p.lh=function(t){var i,a,l,f,g,m,v,y,E;if(l=t._b(),l!=0){for(y=(a=h(sn(this.a,4),116),a==null?0:a.length),E=y+l,i=Tbe(this,E),v=t.tc(),g=y;ga)throw Y(new o_(t,a));return new gUe(this,t)},p.Pb=function(){var t,i;++this.j,t=h(sn(this.a,4),116),i=t==null?0:t.length,l6(this,null),GQ(this,i,t)},p.pc=function(t){var i,a,l,f;if(i=h(sn(this.a,4),116),i!=null){if(t!=null){for(l=0,f=i.length;l=a)throw Y(new o_(t,a));return i[t]},p.dd=function(t){var i,a,l;if(i=h(sn(this.a,4),116),i!=null){if(t!=null){for(a=0,l=i.length;aa)throw Y(new o_(t,a));return new pUe(this,t)},p.yh=function(t){return h(sn(this.a,4),116)[t]},p.gd=function(t){return BFt(this,t)},p.Ah=function(t,i){var a,l;return a=_5t(this),l=a[t],Tge(a,t,DA(this,i)),l6(this,a),l},p._b=function(){var t;return t=h(sn(this.a,4),116),t==null?0:t.length},p.yc=function(){var t,i,a;return t=h(sn(this.a,4),116),a=t==null?0:t.length,i=le(kae,kre,380,a,0,1),a>0&&vc(t,0,i,0,a),i},p.zc=function(t){var i,a,l;return i=h(sn(this.a,4),116),l=i==null?0:i.length,l>0&&(t.lengthl&&Gr(t,l,null),t};var Nlt,i4n=k(Gs,"ArrayDelegatingEList",1673);A(927,36,ys,Zze),p.Bi=function(){if(this.b.j!=this.f||Be(h(sn(this.b.a,4),116))!==Be(this.a))throw Y(new P)},p.jc=function(){KA(this),this.a=h(sn(this.b.a,4),116)};var r4n=k(Gs,"ArrayDelegatingEList/EIterator",927);A(640,296,Ch,z9e,pUe),p.Bi=function(){if(this.b.j!=this.f||Be(h(sn(this.b.a,4),116))!==Be(this.a))throw Y(new P)},p.Ei=function(t){xHe(this,t),this.a=h(sn(this.b.a,4),116)},p.jc=function(){KA(this),this.a=h(sn(this.b.a,4),116)};var s4n=k(Gs,"ArrayDelegatingEList/EListIterator",640);A(928,324,ys,Kze),p.Bi=function(){if(this.b.j!=this.f||Be(h(sn(this.b.a,4),116))!==Be(this.a))throw Y(new P)};var o4n=k(Gs,"ArrayDelegatingEList/NonResolvingEIterator",928);A(641,355,Ch,G9e,gUe),p.Bi=function(){if(this.b.j!=this.f||Be(h(sn(this.b.a,4),116))!==Be(this.a))throw Y(new P)};var a4n=k(Gs,"ArrayDelegatingEList/NonResolvingEListIterator",641);A(549,295,lie,JK);var c4n=k(Gs,"BasicEList/BasicIndexOutOfBoundsException",549);A(630,55,Ih,dge),p.bd=function(t,i){throw Y(new Pi)},p.nc=function(t){throw Y(new Pi)},p.oc=function(t){throw Y(new Pi)},p.Pb=function(){throw Y(new Pi)},p.Eh=function(t){throw Y(new Pi)},p.tc=function(){return this.oh()},p.ed=function(){return this.ph()},p.fd=function(t){return this.qh(t)},p.gd=function(t){throw Y(new Pi)},p.vc=function(t){throw Y(new Pi)},p.hd=function(t,i){throw Y(new Pi)};var l4n=k(Gs,"BasicEList/UnmodifiableEList",630);A(639,1,{3:1,20:1,13:1,15:1,52:1,533:1}),p.bd=function(t,i){jSt(this,t,h(i,38))},p.nc=function(t){return xMt(this,h(t,38))},p.sc=function(t){mo(this,t)},p.cd=function(t){return h(ae(this.c,t),134)},p.uc=function(){return this.xc()},p.gd=function(t){return h(this.c.gd(t),38)},p.hd=function(t,i){return VAt(this,t,h(i,38))},p.jd=function(t){Ug(this,t)},p.wc=function(){return new di(this,16)},p.xc=function(){return new oi(null,this.wc())},p.oc=function(t){return this.c.oc(t)},p.Pb=function(){this.c.Pb()},p.pc=function(t){return this.c.pc(t)},p.qc=function(t){return Gg(this.c,t)},p.Fi=function(){var t,i,a;if(this.d==null){for(this.d=le(PAe,Oxe,55,2*this.f+1,0,1),a=this.e,this.f=0,i=this.c.tc();i.e!=i.i._b();)t=h(i.Ci(),134),n7(this,t);this.e=a}},p.Fb=function(t){return N8e(this,t)},p.Hb=function(){return pbe(this.c)},p.dd=function(t){return this.c.dd(t)},p.Gi=function(){this.c=new VZ(this)},p.Wb=function(){return this.f==0},p.tc=function(){return this.c.tc()},p.ed=function(){return this.c.ed()},p.fd=function(t){return this.c.fd(t)},p.Hi=function(){return CI(this)},p.Ii=function(t,i,a){return new X8e(t,i,a)},p.Ji=function(){return new Zq},p.vc=function(t){return Yje(this,t)},p._b=function(){return this.f},p.kd=function(t,i){return new Rg(this.c,t,i)},p.yc=function(){return this.c.yc()},p.zc=function(t){return this.c.zc(t)},p.Ib=function(){return Xbe(this.c)},p.e=0,p.f=0;var u4n=k(Gs,"BasicEMap",639);A(922,55,Ih,VZ),p.sh=function(t,i){rt(this,h(i,134))},p.vh=function(t,i){gt(this,h(i,134))},p.wh=function(t,i,a){gMt(this,h(i,134),h(a,134))},p.uh=function(t,i){W$e(this.a)};var f4n=k(Gs,"BasicEMap/1",922);A(923,55,Ih,Zq),p.Fh=function(t){return le(AVt,_tt,551,t,0,1)};var h4n=k(Gs,"BasicEMap/2",923);A(924,fd,gu,WZ),p.Pb=function(){this.a.c.Pb()},p.pc=function(t){return nte(this.a,t)},p.tc=function(){return this.a.f==0?(tA(),vD.a):new _Be(this.a)},p.vc=function(t){var i;return i=this.a.f,a6(this.a,t),this.a.f!=i},p._b=function(){return this.a.f};var d4n=k(Gs,"BasicEMap/3",924);A(925,25,Y_,HZ),p.Pb=function(){this.a.c.Pb()},p.pc=function(t){return oZe(this.a,t)},p.tc=function(){return this.a.f==0?(tA(),vD.a):new yBe(this.a)},p._b=function(){return this.a.f};var p4n=k(Gs,"BasicEMap/4",925);A(926,fd,gu,qZ),p.Pb=function(){this.a.c.Pb()},p.pc=function(t){var i,a,l,f,g,m,v,y,E;if(this.a.f>0&&re(t,38)&&(this.a.Fi(),y=h(t,38),v=y.kc(),f=v==null?0:Hr(v),g=sme(this.a,f),i=this.a.d[g],i)){for(a=h(i.g,339),E=i.i,m=0;m"+this.c},p.a=0;var AVt=k(Gs,"BasicEMap/EntryImpl",551);A(484,1,{},L2);var _4n=k(Gs,"BasicEMap/View",484),vD;A(695,1,{}),p.Fb=function(t){return Cve((_t(),uo),t)},p.Hb=function(){return ybe((_t(),uo))},p.Ib=function(){return Vp((_t(),uo))};var y4n=k(Gs,"ECollections/BasicEmptyUnmodifiableEList",695);A(1164,1,Ch,Kq),p.gc=function(t){Ss(this,t)},p.Bc=function(t){throw Y(new Pi)},p.hc=function(){return!1},p.Cc=function(){return!1},p.ic=function(){throw Y(new K)},p.Dc=function(){return 0},p.Ec=function(){throw Y(new K)},p.Fc=function(){return-1},p.jc=function(){throw Y(new Pi)},p.Gc=function(t){throw Y(new Pi)};var x4n=k(Gs,"ECollections/BasicEmptyUnmodifiableEList/1",1164);A(1162,695,{20:1,13:1,15:1,52:1},MDe),p.bd=function(t,i){qDe()},p.nc=function(t){return XDe()},p.oc=function(t){return YDe()},p.Pb=function(){ZDe()},p.pc=function(t){return!1},p.qc=function(t){return!1},p.sc=function(t){mo(this,t)},p.cd=function(t){return wge((_t(),t)),null},p.dd=function(t){return-1},p.Wb=function(){return!0},p.tc=function(){return this.a},p.ed=function(){return this.a},p.fd=function(t){return this.a},p.uc=function(){return this.xc()},p.gd=function(t){return KDe()},p.vc=function(t){return JDe()},p.hd=function(t,i){return QDe()},p._b=function(){return 0},p.jd=function(t){Ug(this,t)},p.wc=function(){return new di(this,16)},p.xc=function(){return new oi(null,this.wc())},p.kd=function(t,i){return _t(),new Rg(uo,t,i)},p.yc=function(){return VJ((_t(),uo))},p.zc=function(t){return _t(),u6(uo,t)};var E4n=k(Gs,"ECollections/EmptyUnmodifiableEList",1162);A(1163,695,{20:1,13:1,15:1,52:1,533:1},SDe),p.bd=function(t,i){qDe()},p.nc=function(t){return XDe()},p.oc=function(t){return YDe()},p.Pb=function(){ZDe()},p.pc=function(t){return!1},p.qc=function(t){return!1},p.sc=function(t){mo(this,t)},p.cd=function(t){return wge((_t(),t)),null},p.dd=function(t){return-1},p.Wb=function(){return!0},p.tc=function(){return this.a},p.ed=function(){return this.a},p.fd=function(t){return this.a},p.uc=function(){return this.xc()},p.gd=function(t){return KDe()},p.vc=function(t){return JDe()},p.hd=function(t,i){return QDe()},p._b=function(){return 0},p.jd=function(t){Ug(this,t)},p.wc=function(){return new di(this,16)},p.xc=function(){return new oi(null,this.wc())},p.kd=function(t,i){return _t(),new Rg(uo,t,i)},p.yc=function(){return VJ((_t(),uo))},p.zc=function(t){return _t(),u6(uo,t)},p.Hi=function(){return _t(),_t(),ep};var S4n=k(Gs,"ECollections/EmptyUnmodifiableEMap",1163),kAe=_r(Gs,"Enumerator"),Dj;A(261,1,{261:1},sne),p.Fb=function(t){var i;return this===t?!0:re(t,261)?(i=h(t,261),this.f==i.f&&tAt(this.i,i.i)&&GJ(this.a,this.f&256?i.f&256?i.a:null:i.f&256?null:i.a)&&GJ(this.d,i.d)&&GJ(this.g,i.g)&&GJ(this.e,i.e)&&$5t(this,i)):!1},p.Hb=function(){return this.f},p.Ib=function(){return NZe(this)},p.f=0;var Flt=0,Ult=0,zlt=0,Glt=0,RAe=0,IAe=0,DAe=0,BAe=0,OAe=0,jlt,IL=0,DL=0,$lt=0,Vlt=0,Bj,NAe,M4n=k(Gs,"URI",261);A(965,44,Fx,wDe),p.Zb=function(t,i){return h(Ko(this,ti(t),h(i,261)),261)};var T4n=k(Gs,"URI/URICache",965);A(451,55,Ih,bE,S9),p.xh=function(){return!0};var C4n=k(Gs,"UniqueEList",451);A(526,54,Zd,hU);var A4n=k(Gs,"WrappedException",526),Ri=_r(Xl,Ett),tv=_r(Xl,Stt),Sc=_r(Xl,Mtt),Ly=_r(Xl,Ttt),lh=_r(Xl,Ctt),Lu=_r(Xl,"EClass"),Rae=_r(Xl,"EDataType"),Wlt;A(1096,44,Fx,vDe),p.Vb=function(t){return ws(t)?za(this,t):Dc(gc(this.d,t))};var P4n=k(Xl,"EDataType/Internal/ConversionDelegate/Factory/Registry/Impl",1096),Oj=_r(Xl,"EEnum"),eg=_r(Xl,Att),ko=_r(Xl,Ptt),uf=_r(Xl,Ltt),ku,nv=_r(Xl,ktt),iv=_r(Xl,Rtt);A(918,1,{},vN),p.Ib=function(){return"NIL"};var L4n=k(Xl,"EStructuralFeature/Internal/DynamicValueHolder/1",918),Hlt;A(917,44,Fx,_De),p.Vb=function(t){return ws(t)?za(this,t):Dc(gc(this.d,t))};var k4n=k(Xl,"EStructuralFeature/Internal/SettingDelegate/Factory/Registry/Impl",917),fl=_r(Xl,Itt),w3=_r(Xl,"EValidator/PatternMatcher"),FAe,UAe,Ct,A1,v3,bb,qlt,Xlt,wb,P1,vb,ky,zh,Ylt,Zlt,ff,L1,k1,rv,TM,zo,Klt,Jlt,Ry,Nj=_r(or,"FeatureMap/Entry");A(483,1,{75:1},U8),p.nj=function(){return this.a},p.lc=function(){return this.b};var R4n=k(Lt,"BasicEObjectImpl/1",483);A(1674,1,{103:1}),p.oj=function(t){this.e=t==0?Qlt:le(on,et,1,t,5,1)},p.Tg=function(t){return this.e[t]},p.Ug=function(t,i){this.e[t]=i},p.Vg=function(t){this.e[t]=null},p.pj=function(){return this.c},p.qj=function(){throw Y(new Pi)},p.rj=function(){throw Y(new Pi)},p.sj=function(){return this.d},p.tj=function(){return this.e!=null},p.uj=function(t){this.c=t},p.vj=function(t){throw Y(new Pi)},p.wj=function(t){this.d=t};var Qlt,I4n=k(Lt,"BasicEObjectImpl/EPropertiesHolderBaseImpl",1674);A(201,1674,{103:1},mh),p.qj=function(){return this.a},p.rj=function(){return this.b},p.vj=function(t){this.a=t};var D4n=k(Lt,"BasicEObjectImpl/EPropertiesHolderImpl",201);A(463,92,Fet,Bu),p.dg=function(){return this.f},p.ig=function(){return this.k},p.kg=function(t,i){this.g=t,this.i=i},p.mg=function(){return this.j&2?this.Jg().pj():this.Rg()},p.og=function(){return this.i},p.fg=function(){return(this.j&1)!=0},p.yg=function(){return this.g},p.Eg=function(){return(this.j&4)!=0},p.Jg=function(){return!this.k&&(this.k=new mh),this.k},p.Ng=function(t){this.Jg().uj(t),t?this.j|=2:this.j&=-3},p.Rg=function(){return(kg(),Ct).S},p.i=0,p.j=1;var B4n=k(Lt,"EObjectImpl",463);A(710,463,{95:1,91:1,87:1,51:1,103:1,42:1,92:1},Fme),p.Tg=function(t){return this.e[t]},p.Ug=function(t,i){this.e[t]=i},p.Vg=function(t){this.e[t]=null},p.mg=function(){return this.d},p.rg=function(t){return br(this.d,t)},p.tg=function(){return this.d},p.xg=function(){return this.e!=null},p.Jg=function(){return!this.k&&(this.k=new Jq),this.k},p.Ng=function(t){this.d=t},p.Qg=function(){var t;return this.e==null&&(t=jn(this.d),this.e=t==0?eut:le(on,et,1,t,5,1)),this},p.Sg=function(){return 0};var eut,O4n=k(Lt,"DynamicEObjectImpl",710);A(1389,710,{95:1,38:1,91:1,87:1,134:1,51:1,103:1,42:1,92:1},w9e),p.Fb=function(t){return this===t},p.Hb=function(){return g0(this)},p.Ng=function(t){this.d=t,this.b=T6(t,"key"),this.c=T6(t,kP)},p.ih=function(){var t;return this.a==-1&&(t=QQ(this,this.b),this.a=t==null?0:Hr(t)),this.a},p.kc=function(){return QQ(this,this.b)},p.lc=function(){return QQ(this,this.c)},p.jh=function(t){this.a=t},p.kh=function(t){R7e(this,this.b,t)},p.mc=function(t){var i;return i=QQ(this,this.c),R7e(this,this.c,t),i},p.a=0;var N4n=k(Lt,"DynamicEObjectImpl/BasicEMapEntry",1389);A(1390,1,{103:1},Jq),p.oj=function(t){throw Y(new Pi)},p.Tg=function(t){throw Y(new Pi)},p.Ug=function(t,i){throw Y(new Pi)},p.Vg=function(t){throw Y(new Pi)},p.pj=function(){throw Y(new Pi)},p.qj=function(){return this.a},p.rj=function(){return this.b},p.sj=function(){return this.c},p.tj=function(){throw Y(new Pi)},p.uj=function(t){throw Y(new Pi)},p.vj=function(t){this.a=t},p.wj=function(t){this.c=t};var F4n=k(Lt,"DynamicEObjectImpl/DynamicEPropertiesHolderImpl",1390);A(469,142,{95:1,91:1,87:1,609:1,139:1,51:1,103:1,42:1,92:1,469:1,142:1,107:1,108:1},_N),p.jg=function(t){return Rwe(this,t)},p.ug=function(t,i,a){var l;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.d;case 2:return a?(!this.b&&(this.b=new wl((yt(),zo),Aa,this)),this.b):(!this.b&&(this.b=new wl((yt(),zo),Aa,this)),CI(this.b));case 3:return w7e(this);case 4:return!this.a&&(this.a=new vs(Qw,this,4)),this.a;case 5:return!this.c&&(this.c=new qE(Qw,this,5)),this.c}return jl(this,t-jn((yt(),A1)),Wt((l=h(sn(this,16),24),l||A1),t),i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),ja(this.Ab,t,a);case 3:return this.Cb&&(a=(f=this.Db>>16,f>=0?Rwe(this,a):this.Cb.Cg(this,-1-f,null,a))),e1e(this,h(t,139),a)}return g=h(Wt((l=h(sn(this,16),24),l||(yt(),A1)),i),61),g.aj().dj(this,Ya(this),i-jn((yt(),A1)),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a);case 2:return!this.b&&(this.b=new wl((yt(),zo),Aa,this)),f9(this.b,t,a);case 3:return e1e(this,null,a);case 4:return!this.a&&(this.a=new vs(Qw,this,4)),Us(this.a,t,a)}return f=h(Wt((l=h(sn(this,16),24),l||(yt(),A1)),i),61),f.aj().ej(this,Ya(this),i-jn((yt(),A1)),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.d!=null;case 2:return!!this.b&&this.b.f!=0;case 3:return!!w7e(this);case 4:return!!this.a&&this.a.i!=0;case 5:return!!this.c&&this.c.i!=0}return zl(this,t-jn((yt(),A1)),Wt((i=h(sn(this,16),24),i||A1),t))},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:nAt(this,ti(i));return;case 2:!this.b&&(this.b=new wl((yt(),zo),Aa,this)),TU(this.b,i);return;case 3:v9t(this,h(i,139));return;case 4:!this.a&&(this.a=new vs(Qw,this,4)),Pr(this.a),!this.a&&(this.a=new vs(Qw,this,4)),Mr(this.a,h(i,13));return;case 5:!this.c&&(this.c=new qE(Qw,this,5)),Pr(this.c),!this.c&&(this.c=new qE(Qw,this,5)),Mr(this.c,h(i,13));return}Wl(this,t-jn((yt(),A1)),Wt((a=h(sn(this,16),24),a||A1),t),i)},p.Rg=function(){return yt(),A1},p.Ib=function(){return qVe(this)},p.d=null;var U4n=k(Lt,"EAnnotationImpl",469);A(143,639,Nxe,il),p.xj=function(t,i){return nTt(this,h(t,38),i)},p.Dh=function(t){return h(h(this.c,64).Dh(t),134)},p.oh=function(){return h(this.c,64).oh()},p.ph=function(){return h(this.c,64).ph()},p.qh=function(t){return h(this.c,64).qh(t)},p.yj=function(t,i){return f9(this,t,i)},p.hj=function(t){return h(this.c,81).hj(t)},p.Gi=function(){},p.ui=function(){return h(this.c,81).ui()},p.Ii=function(t,i,a){var l;return l=h($l(this.b).dh().$g(this.b),134),l.jh(t),l.kh(i),l.mc(a),l},p.Ji=function(){return new _C(this)},p.Gc=function(t){TU(this,t)},p.ij=function(){h(this.c,81).ij()};var z4n=k(or,"EcoreEMap",143);A(152,143,Nxe,wl),p.Fi=function(){var t,i,a,l,f,g;if(this.d==null){for(g=le(PAe,Oxe,55,2*this.f+1,0,1),a=this.c.tc();a.e!=a.i._b();)i=h(a.Ci(),134),l=i.ih(),f=(l&zi)%g.length,t=g[f],!t&&(t=g[f]=new _C(this)),t.nc(i);this.d=g}};var G4n=k(Lt,"EAnnotationImpl/1",152);A(268,399,{95:1,91:1,87:1,139:1,174:1,51:1,103:1,431:1,42:1,92:1,142:1,268:1,107:1,108:1}),p.ug=function(t,i,a){var l,f;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.zb;case 2:return vt(),!!(this.Bb&256);case 3:return vt(),!!(this.Bb&512);case 4:return He(this.s);case 5:return He(this.t);case 6:return vt(),!!this.lj();case 7:return vt(),f=this.s,f>=1;case 8:return i?pu(this):this.r;case 9:return this.q}return jl(this,t-jn(this.Rg()),Wt((l=h(sn(this,16),24),l||this.Rg()),t),i,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a);case 9:return nQ(this,a)}return f=h(Wt((l=h(sn(this,16),24),l||this.Rg()),i),61),f.aj().ej(this,Ya(this),i-jn(this.Rg()),t,a)},p.Fg=function(t){var i,a;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return(this.Bb&256)==0;case 3:return(this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return this.lj();case 7:return a=this.s,a>=1;case 8:return!!this.r&&!this.q.e&&y0(this.q).i==0;case 9:return!!this.q&&!(this.r&&!this.q.e&&y0(this.q).i==0)}return zl(this,t-jn(this.Rg()),Wt((i=h(sn(this,16),24),i||this.Rg()),t))},p.Mg=function(t,i){var a,l;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:this.ah(ti(i));return;case 2:C_(this,ce(mt(i)));return;case 3:A_(this,ce(mt(i)));return;case 4:E_(this,h(i,21).a);return;case 5:this.Aj(h(i,21).a);return;case 8:ES(this,h(i,133));return;case 9:l=Zg(this,h(i,84),null),l&&l.Th();return}Wl(this,t-jn(this.Rg()),Wt((a=h(sn(this,16),24),a||this.Rg()),t),i)},p.Rg=function(){return yt(),Jlt},p.Xg=function(){pu(this),this.Bb|=1},p.jj=function(){return pu(this)},p.kj=function(){return this.t},p.lj=function(){var t;return t=this.t,t>1||t==-1},p.xh=function(){return(this.Bb&512)!=0},p.zj=function(t,i){return Bbe(this,t,i)},p.Aj=function(t){mS(this,t)},p.Ib=function(){return Eve(this)},p.s=0,p.t=1;var j4n=k(Lt,"ETypedElementImpl",268);A(418,268,{95:1,91:1,87:1,139:1,174:1,51:1,158:1,61:1,103:1,431:1,42:1,92:1,142:1,418:1,268:1,107:1,108:1,615:1}),p.jg=function(t){return jHe(this,t)},p.ug=function(t,i,a){var l,f;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.zb;case 2:return vt(),!!(this.Bb&256);case 3:return vt(),!!(this.Bb&512);case 4:return He(this.s);case 5:return He(this.t);case 6:return vt(),!!this.lj();case 7:return vt(),f=this.s,f>=1;case 8:return i?pu(this):this.r;case 9:return this.q;case 10:return vt(),!!(this.Bb&tf);case 11:return vt(),!!(this.Bb&Dw);case 12:return vt(),!!(this.Bb&W0);case 13:return this.j;case 14:return NS(this);case 15:return vt(),!!(this.Bb&yc);case 16:return vt(),!!(this.Bb&Ah);case 17:return dw(this)}return jl(this,t-jn(this.Rg()),Wt((l=h(sn(this,16),24),l||this.Rg()),t),i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),ja(this.Ab,t,a);case 17:return this.Cb&&(a=(f=this.Db>>16,f>=0?jHe(this,a):this.Cb.Cg(this,-1-f,null,a))),Ml(this,t,17,a)}return g=h(Wt((l=h(sn(this,16),24),l||this.Rg()),i),61),g.aj().dj(this,Ya(this),i-jn(this.Rg()),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a);case 9:return nQ(this,a);case 17:return Ml(this,null,17,a)}return f=h(Wt((l=h(sn(this,16),24),l||this.Rg()),i),61),f.aj().ej(this,Ya(this),i-jn(this.Rg()),t,a)},p.Fg=function(t){var i,a;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return(this.Bb&256)==0;case 3:return(this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return this.lj();case 7:return a=this.s,a>=1;case 8:return!!this.r&&!this.q.e&&y0(this.q).i==0;case 9:return!!this.q&&!(this.r&&!this.q.e&&y0(this.q).i==0);case 10:return(this.Bb&tf)==0;case 11:return(this.Bb&Dw)!=0;case 12:return(this.Bb&W0)!=0;case 13:return this.j!=null;case 14:return NS(this)!=null;case 15:return(this.Bb&yc)!=0;case 16:return(this.Bb&Ah)!=0;case 17:return!!dw(this)}return zl(this,t-jn(this.Rg()),Wt((i=h(sn(this,16),24),i||this.Rg()),t))},p.Mg=function(t,i){var a,l;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:SQ(this,ti(i));return;case 2:C_(this,ce(mt(i)));return;case 3:A_(this,ce(mt(i)));return;case 4:E_(this,h(i,21).a);return;case 5:this.Aj(h(i,21).a);return;case 8:ES(this,h(i,133));return;case 9:l=Zg(this,h(i,84),null),l&&l.Th();return;case 10:OU(this,ce(mt(i)));return;case 11:BU(this,ce(mt(i)));return;case 12:FU(this,ce(mt(i)));return;case 13:mge(this,ti(i));return;case 15:NU(this,ce(mt(i)));return;case 16:UU(this,ce(mt(i)));return}Wl(this,t-jn(this.Rg()),Wt((a=h(sn(this,16),24),a||this.Rg()),t),i)},p.Rg=function(){return yt(),Klt},p.Xg=function(){iS(Vo((qc(),Zs),this)),pu(this),this.Bb|=1},p.Vi=function(){return this.f},p.Oi=function(){return NS(this)},p.Wi=function(){return dw(this)},p.$i=function(){return null},p.Bj=function(){return this.k},p.pi=function(){return this.n},p._i=function(){return c7(this)},p.aj=function(){var t,i,a,l,f,g,m,v,y;return this.p||(a=dw(this),(a.i==null&&Jg(a),a.i).length,l=this.$i(),l&&jn(dw(l)),f=pu(this),m=f.Qi(),t=m?m.i&1?m==Ru?lo:m==In?Po:m==av?aM:m==ks?Eo:m==R1?K0:m==By?J0:m==Mc?qx:$P:m:null,i=NS(this),v=f.Oi(),L6t(this),this.Bb&Ah&&((g=Uwe((qc(),Zs),a))&&g!=this||(g=pA(Vo(Zs,this))))?this.p=new mNe(this,g):this.lj()?this.Dj()?l?this.Bb&yc?t?this.Ej()?this.p=new Vm(47,t,this,l):this.p=new Vm(5,t,this,l):this.Ej()?this.p=new qm(46,this,l):this.p=new qm(4,this,l):t?this.Ej()?this.p=new Vm(49,t,this,l):this.p=new Vm(7,t,this,l):this.Ej()?this.p=new qm(48,this,l):this.p=new qm(6,this,l):this.Bb&yc?t?t==cy?this.p=new Ip(50,Blt,this):this.Ej()?this.p=new Ip(43,t,this):this.p=new Ip(1,t,this):this.Ej()?this.p=new Np(42,this):this.p=new Np(0,this):t?t==cy?this.p=new Ip(41,Blt,this):this.Ej()?this.p=new Ip(45,t,this):this.p=new Ip(3,t,this):this.Ej()?this.p=new Np(44,this):this.p=new Np(2,this):re(f,140)?t==Nj?this.p=new Np(40,this):this.Bb&512?this.Bb&yc?t?this.p=new Ip(9,t,this):this.p=new Np(8,this):t?this.p=new Ip(11,t,this):this.p=new Np(10,this):this.Bb&yc?t?this.p=new Ip(13,t,this):this.p=new Np(12,this):t?this.p=new Ip(15,t,this):this.p=new Np(14,this):l?(y=l.t,y>1||y==-1?this.Ej()?this.Bb&yc?t?this.p=new Vm(25,t,this,l):this.p=new qm(24,this,l):t?this.p=new Vm(27,t,this,l):this.p=new qm(26,this,l):this.Bb&yc?t?this.p=new Vm(29,t,this,l):this.p=new qm(28,this,l):t?this.p=new Vm(31,t,this,l):this.p=new qm(30,this,l):this.Ej()?this.Bb&yc?t?this.p=new Vm(33,t,this,l):this.p=new qm(32,this,l):t?this.p=new Vm(35,t,this,l):this.p=new qm(34,this,l):this.Bb&yc?t?this.p=new Vm(37,t,this,l):this.p=new qm(36,this,l):t?this.p=new Vm(39,t,this,l):this.p=new qm(38,this,l)):this.Ej()?this.Bb&yc?t?this.p=new Ip(17,t,this):this.p=new Np(16,this):t?this.p=new Ip(19,t,this):this.p=new Np(18,this):this.Bb&yc?t?this.p=new Ip(21,t,this):this.p=new Np(20,this):t?this.p=new Ip(23,t,this):this.p=new Np(22,this):this.Cj()?this.Ej()?this.p=new Y8e(h(f,24),this,l):this.p=new j1e(h(f,24),this,l):re(f,140)?t==Nj?this.p=new Np(40,this):this.Bb&yc?t?this.p=new O9e(i,v,this,(tte(),m==In?HAe:m==Ru?GAe:m==R1?qAe:m==av?WAe:m==ks?VAe:m==By?XAe:m==Mc?jAe:m==Zl?$Ae:Bae)):this.p=new RUe(h(f,140),i,v,this):t?this.p=new B9e(i,v,this,(tte(),m==In?HAe:m==Ru?GAe:m==R1?qAe:m==av?WAe:m==ks?VAe:m==By?XAe:m==Mc?jAe:m==Zl?$Ae:Bae)):this.p=new kUe(h(f,140),i,v,this):this.Dj()?l?this.Bb&yc?this.Ej()?this.p=new K8e(h(f,24),this,l):this.p=new Lme(h(f,24),this,l):this.Ej()?this.p=new Z8e(h(f,24),this,l):this.p=new OJ(h(f,24),this,l):this.Bb&yc?this.Ej()?this.p=new HFe(h(f,24),this):this.p=new Yge(h(f,24),this):this.Ej()?this.p=new WFe(h(f,24),this):this.p=new _J(h(f,24),this):this.Ej()?l?this.Bb&yc?this.p=new J8e(h(f,24),this,l):this.p=new Pme(h(f,24),this,l):this.Bb&yc?this.p=new qFe(h(f,24),this):this.p=new Xge(h(f,24),this):l?this.Bb&yc?this.p=new Q8e(h(f,24),this,l):this.p=new kme(h(f,24),this,l):this.Bb&yc?this.p=new XFe(h(f,24),this):this.p=new M9(h(f,24),this)),this.p},p.Xi=function(){return(this.Bb&tf)!=0},p.Cj=function(){return!1},p.Dj=function(){return!1},p.Yi=function(){return(this.Bb&Ah)!=0},p.bj=function(){return O0e(this)},p.Ej=function(){return!1},p.Zi=function(){return(this.Bb&yc)!=0},p.Fj=function(t){this.k=t},p.ah=function(t){SQ(this,t)},p.Ib=function(){return L7(this)},p.e=!1,p.n=0;var $4n=k(Lt,"EStructuralFeatureImpl",418);A(335,418,{95:1,91:1,87:1,29:1,139:1,174:1,51:1,158:1,61:1,103:1,431:1,42:1,92:1,335:1,142:1,418:1,268:1,107:1,108:1,615:1},cK),p.ug=function(t,i,a){var l,f;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.zb;case 2:return vt(),!!(this.Bb&256);case 3:return vt(),!!(this.Bb&512);case 4:return He(this.s);case 5:return He(this.t);case 6:return vt(),!!yve(this);case 7:return vt(),f=this.s,f>=1;case 8:return i?pu(this):this.r;case 9:return this.q;case 10:return vt(),!!(this.Bb&tf);case 11:return vt(),!!(this.Bb&Dw);case 12:return vt(),!!(this.Bb&W0);case 13:return this.j;case 14:return NS(this);case 15:return vt(),!!(this.Bb&yc);case 16:return vt(),!!(this.Bb&Ah);case 17:return dw(this);case 18:return vt(),!!(this.Bb&Ja);case 19:return i?See(this):AGe(this)}return jl(this,t-jn((yt(),v3)),Wt((l=h(sn(this,16),24),l||v3),t),i,a)},p.Fg=function(t){var i,a;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return(this.Bb&256)==0;case 3:return(this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return yve(this);case 7:return a=this.s,a>=1;case 8:return!!this.r&&!this.q.e&&y0(this.q).i==0;case 9:return!!this.q&&!(this.r&&!this.q.e&&y0(this.q).i==0);case 10:return(this.Bb&tf)==0;case 11:return(this.Bb&Dw)!=0;case 12:return(this.Bb&W0)!=0;case 13:return this.j!=null;case 14:return NS(this)!=null;case 15:return(this.Bb&yc)!=0;case 16:return(this.Bb&Ah)!=0;case 17:return!!dw(this);case 18:return(this.Bb&Ja)!=0;case 19:return!!AGe(this)}return zl(this,t-jn((yt(),v3)),Wt((i=h(sn(this,16),24),i||v3),t))},p.Mg=function(t,i){var a,l;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:SQ(this,ti(i));return;case 2:C_(this,ce(mt(i)));return;case 3:A_(this,ce(mt(i)));return;case 4:E_(this,h(i,21).a);return;case 5:mBe(this,h(i,21).a);return;case 8:ES(this,h(i,133));return;case 9:l=Zg(this,h(i,84),null),l&&l.Th();return;case 10:OU(this,ce(mt(i)));return;case 11:BU(this,ce(mt(i)));return;case 12:FU(this,ce(mt(i)));return;case 13:mge(this,ti(i));return;case 15:NU(this,ce(mt(i)));return;case 16:UU(this,ce(mt(i)));return;case 18:$be(this,ce(mt(i)));return}Wl(this,t-jn((yt(),v3)),Wt((a=h(sn(this,16),24),a||v3),t),i)},p.Rg=function(){return yt(),v3},p.Xg=function(){See(this),iS(Vo((qc(),Zs),this)),pu(this),this.Bb|=1},p.lj=function(){return yve(this)},p.zj=function(t,i){return this.b=0,this.a=null,Bbe(this,t,i)},p.Aj=function(t){mBe(this,t)},p.Ib=function(){var t;return this.Db&64?L7(this):(t=new su(L7(this)),t.a+=" (iD: ",Ap(t,(this.Bb&Ja)!=0),t.a+=")",t.a)},p.b=0;var V4n=k(Lt,"EAttributeImpl",335);A(672,399,{95:1,91:1,87:1,133:1,139:1,174:1,51:1,103:1,42:1,92:1,142:1,107:1,108:1,614:1}),p.Gj=function(t){return t.mg()==this},p.jg=function(t){return Mte(this,t)},p.kg=function(t,i){this.w=null,this.Db=i<<16|this.Db&255,this.Cb=t},p.ug=function(t,i,a){var l;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.zb;case 2:return this.D!=null?this.D:this.B;case 3:return N0(this);case 4:return this.Oi();case 5:return this.F;case 6:return i?$l(this):aS(this);case 7:return!this.A&&(this.A=new Nl(fl,this,7)),this.A}return jl(this,t-jn(this.Rg()),Wt((l=h(sn(this,16),24),l||this.Rg()),t),i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),ja(this.Ab,t,a);case 6:return this.Cb&&(a=(f=this.Db>>16,f>=0?Mte(this,a):this.Cb.Cg(this,-1-f,null,a))),Ml(this,t,6,a)}return g=h(Wt((l=h(sn(this,16),24),l||this.Rg()),i),61),g.aj().dj(this,Ya(this),i-jn(this.Rg()),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a);case 6:return Ml(this,null,6,a);case 7:return!this.A&&(this.A=new Nl(fl,this,7)),Us(this.A,t,a)}return f=h(Wt((l=h(sn(this,16),24),l||this.Rg()),i),61),f.aj().ej(this,Ya(this),i-jn(this.Rg()),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.D!=null&&this.D==this.F;case 3:return!!N0(this);case 4:return this.Oi()!=null;case 5:return this.F!=null&&this.F!=this.D&&this.F!=this.B;case 6:return!!aS(this);case 7:return!!this.A&&this.A.i!=0}return zl(this,t-jn(this.Rg()),Wt((i=h(sn(this,16),24),i||this.Rg()),t))},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:H9(this,ti(i));return;case 2:iJ(this,ti(i));return;case 5:Pne(this,ti(i));return;case 7:!this.A&&(this.A=new Nl(fl,this,7)),Pr(this.A),!this.A&&(this.A=new Nl(fl,this,7)),Mr(this.A,h(i,13));return}Wl(this,t-jn(this.Rg()),Wt((a=h(sn(this,16),24),a||this.Rg()),t),i)},p.Rg=function(){return yt(),qlt},p.Ni=function(){var t;return this.G==-1&&(this.G=(t=$l(this),t?$p(t.bh(),this):-1)),this.G},p.Oi=function(){return null},p.Pi=function(){return $l(this)},p.Hj=function(){return this.v},p.Qi=function(){return N0(this)},p.Ri=function(){return this.D!=null?this.D:this.B},p.Si=function(){return this.F},p.Li=function(t){return hne(this,t)},p.Ij=function(t){this.v=t},p.Jj=function(t){E$e(this,t)},p.Kj=function(t){this.C=t},p.ah=function(t){H9(this,t)},p.Ib=function(){return HU(this)},p.C=null,p.D=null,p.G=-1;var W4n=k(Lt,"EClassifierImpl",672);A(96,672,{95:1,91:1,87:1,24:1,133:1,139:1,174:1,51:1,103:1,42:1,92:1,96:1,142:1,432:1,107:1,108:1,614:1},lR),p.Gj=function(t){return ZMt(this,t.mg())},p.ug=function(t,i,a){var l;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.zb;case 2:return this.D!=null?this.D:this.B;case 3:return N0(this);case 4:return null;case 5:return this.F;case 6:return i?$l(this):aS(this);case 7:return!this.A&&(this.A=new Nl(fl,this,7)),this.A;case 8:return vt(),!!(this.Bb&256);case 9:return vt(),!!(this.Bb&512);case 10:return Bo(this);case 11:return!this.q&&(this.q=new ze(uf,this,11,10)),this.q;case 12:return V_(this);case 13:return pP(this);case 14:return pP(this),this.r;case 15:return V_(this),this.k;case 16:return hve(this);case 17:return wne(this);case 18:return Jg(this);case 19:return E7(this);case 20:return V_(this),this.o;case 21:return!this.s&&(this.s=new ze(Sc,this,21,17)),this.s;case 22:return Ea(this);case 23:return rne(this)}return jl(this,t-jn((yt(),bb)),Wt((l=h(sn(this,16),24),l||bb),t),i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),ja(this.Ab,t,a);case 6:return this.Cb&&(a=(f=this.Db>>16,f>=0?Mte(this,a):this.Cb.Cg(this,-1-f,null,a))),Ml(this,t,6,a);case 11:return!this.q&&(this.q=new ze(uf,this,11,10)),ja(this.q,t,a);case 21:return!this.s&&(this.s=new ze(Sc,this,21,17)),ja(this.s,t,a)}return g=h(Wt((l=h(sn(this,16),24),l||(yt(),bb)),i),61),g.aj().dj(this,Ya(this),i-jn((yt(),bb)),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a);case 6:return Ml(this,null,6,a);case 7:return!this.A&&(this.A=new Nl(fl,this,7)),Us(this.A,t,a);case 11:return!this.q&&(this.q=new ze(uf,this,11,10)),Us(this.q,t,a);case 21:return!this.s&&(this.s=new ze(Sc,this,21,17)),Us(this.s,t,a);case 22:return Us(Ea(this),t,a)}return f=h(Wt((l=h(sn(this,16),24),l||(yt(),bb)),i),61),f.aj().ej(this,Ya(this),i-jn((yt(),bb)),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.D!=null&&this.D==this.F;case 3:return!!N0(this);case 4:return!1;case 5:return this.F!=null&&this.F!=this.D&&this.F!=this.B;case 6:return!!aS(this);case 7:return!!this.A&&this.A.i!=0;case 8:return(this.Bb&256)!=0;case 9:return(this.Bb&512)!=0;case 10:return!!this.u&&Ea(this.u.a).i!=0&&!(this.n&&bte(this.n));case 11:return!!this.q&&this.q.i!=0;case 12:return V_(this).i!=0;case 13:return pP(this).i!=0;case 14:return pP(this),this.r.i!=0;case 15:return V_(this),this.k.i!=0;case 16:return hve(this).i!=0;case 17:return wne(this).i!=0;case 18:return Jg(this).i!=0;case 19:return E7(this).i!=0;case 20:return V_(this),!!this.o;case 21:return!!this.s&&this.s.i!=0;case 22:return!!this.n&&bte(this.n);case 23:return rne(this).i!=0}return zl(this,t-jn((yt(),bb)),Wt((i=h(sn(this,16),24),i||bb),t))},p.Ig=function(t){var i;return i=this.i==null||this.q&&this.q.i!=0?null:T6(this,t),i||D_e(this,t)},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:H9(this,ti(i));return;case 2:iJ(this,ti(i));return;case 5:Pne(this,ti(i));return;case 7:!this.A&&(this.A=new Nl(fl,this,7)),Pr(this.A),!this.A&&(this.A=new Nl(fl,this,7)),Mr(this.A,h(i,13));return;case 8:eWe(this,ce(mt(i)));return;case 9:tWe(this,ce(mt(i)));return;case 10:O7(Bo(this)),Mr(Bo(this),h(i,13));return;case 11:!this.q&&(this.q=new ze(uf,this,11,10)),Pr(this.q),!this.q&&(this.q=new ze(uf,this,11,10)),Mr(this.q,h(i,13));return;case 21:!this.s&&(this.s=new ze(Sc,this,21,17)),Pr(this.s),!this.s&&(this.s=new ze(Sc,this,21,17)),Mr(this.s,h(i,13));return;case 22:Pr(Ea(this)),Mr(Ea(this),h(i,13));return}Wl(this,t-jn((yt(),bb)),Wt((a=h(sn(this,16),24),a||bb),t),i)},p.Rg=function(){return yt(),bb},p.Xg=function(){var t,i;if(V_(this),pP(this),hve(this),wne(this),Jg(this),E7(this),rne(this),_A(OCt(uu(this))),this.s)for(t=0,i=this.s.i;t=0;--t)ae(this,t);return K1e(this)},p.zc=function(t){var i;if(this.Qj())for(i=this.i-1;i>=0;--i)ae(this,i);return ewe(this,t)},p.ij=function(){Pr(this)},p.Ch=function(t,i){return Rje(this,t,i)};var X4n=k(or,"EcoreEList",565);A(450,565,Ho,uI),p.rh=function(){return!1},p.pi=function(){return this.c},p.qi=function(){return!1},p.Rj=function(){return!0},p.xh=function(){return!0},p.zh=function(t,i){return i},p.Bh=function(){return!1},p.c=0;var Y4n=k(or,"EObjectEList",450);A(88,450,Ho,vs),p.qi=function(){return!0},p.Pj=function(){return!1},p.Dj=function(){return!0};var Z4n=k(or,"EObjectContainmentEList",88);A(493,88,Ho,Z8),p.th=function(){this.a=!0},p.ui=function(){return this.a},p.ij=function(){var t;Pr(this),$u(this.e)?(t=this.a,this.a=!1,Li(this.e,new qu(this.e,2,this.c,t,!1))):this.a=!1},p.a=!1;var K4n=k(or,"EObjectContainmentEList/Unsettable",493);A(1003,493,Ho,cFe),p.yi=function(t,i){return o5t(this,h(t,84),i)},p.zi=function(t,i){return s5t(this,h(t,84),i)},p.Ai=function(t,i,a){return $Bt(this,h(t,84),h(i,84),a)},p.mi=function(t,i,a,l,f){switch(t){case 3:return dA(this,3,i,a,l,this.i>1);case 5:return dA(this,5,i,a,l,this.i-h(a,15)._b()>0);default:return new Wd(this.e,t,this.c,i,a,l,!0)}},p.xi=function(){return!0},p.ui=function(){return bte(this)},p.ij=function(){Pr(this)};var J4n=k(Lt,"EClassImpl/1",1003);A(1017,1016,Bxe),p.Ih=function(t){var i,a,l,f,g,m,v;if(a=t.Lh(),a!=8){if(l=F5t(t),l==0)switch(a){case 1:case 9:{v=t.Ph(),v!=null&&(i=uu(h(v,432)),!i.c&&(i.c=new qb),JQ(i.c,t.Oh())),m=t.Nh(),m!=null&&(f=h(m,432),f.Bb&1||(i=uu(f),!i.c&&(i.c=new qb),$n(i.c,h(t.Oh(),24))));break}case 3:{m=t.Nh(),m!=null&&(f=h(m,432),f.Bb&1||(i=uu(f),!i.c&&(i.c=new qb),$n(i.c,h(t.Oh(),24))));break}case 5:{if(m=t.Nh(),m!=null)for(g=h(m,13).tc();g.hc();)f=h(g.ic(),432),f.Bb&1||(i=uu(f),!i.c&&(i.c=new qb),$n(i.c,h(t.Oh(),24)));break}case 4:{v=t.Ph(),v!=null&&(f=h(v,432),f.Bb&1||(i=uu(f),!i.c&&(i.c=new qb),JQ(i.c,t.Oh())));break}case 6:{if(v=t.Ph(),v!=null)for(g=h(v,13).tc();g.hc();)f=h(g.ic(),432),f.Bb&1||(i=uu(f),!i.c&&(i.c=new qb),JQ(i.c,t.Oh()));break}}this.Tj(l)}},p.Tj=function(t){mZe(this,t)},p.b=63;var Q4n=k(Lt,"ESuperAdapter",1017);A(1018,1017,Bxe,YZ),p.Tj=function(t){sP(this,t)};var ekn=k(Lt,"EClassImpl/10",1018);A(1007,630,Ho),p.lh=function(t){return kHe(this,t)},p.mh=function(t,i){e6(this,t,i)},p.nh=function(t){MI(this,t)},p.Dh=function(t){return P0e(this,t)},p.Ah=function(t,i){return KQ(this,t,i)},p.xj=function(t,i){throw Y(new Pi)},p.oh=function(){return new nx(this)},p.ph=function(){return new QR(this)},p.qh=function(t){return GI(this,t)},p.yj=function(t,i){throw Y(new Pi)},p.hj=function(t){return this},p.ui=function(){return this.i!=0},p.Gc=function(t){throw Y(new Pi)},p.ij=function(){throw Y(new Pi)};var tkn=k(or,"EcoreEList/UnmodifiableEList",1007);A(301,1007,Ho,t_),p.Bh=function(){return!1};var nkn=k(or,"EcoreEList/UnmodifiableEList/FastCompare",301);A(1010,301,Ho,_Ve),p.dd=function(t){var i,a,l;if(re(t,158)&&(i=h(t,158),a=i.pi(),a!=-1)){for(l=this.i;a4)if(this.Li(t)){if(this.Dj()){if(l=h(t,42),a=l.ng(),v=a==this.b&&(this.Pj()?l.hg(l.og(),h(Wt(sc(this.b),this.pi()).jj(),24).Qi())==Uo(h(Wt(sc(this.b),this.pi()),17)).n:-1-l.og()==this.pi()),this.Qj()&&!v&&!a&&l.sg()){for(f=0;f1||l==-1)):!1},p.Pj=function(){var t,i,a;return i=Wt(sc(this.b),this.pi()),re(i,62)?(t=h(i,17),a=Uo(t),!!a):!1},p.Qj=function(){var t,i;return i=Wt(sc(this.b),this.pi()),re(i,62)?(t=h(i,17),(t.Bb&oo)!=0):!1},p.dd=function(t){var i,a,l,f;if(l=this.ci(t),l>=0)return l;if(this.Rj()){for(a=0,f=this.hi();a=0;--t)B6(this,t,this.ai(t));return this.ii()},p.zc=function(t){var i;if(this.Qj())for(i=this.hi()-1;i>=0;--i)B6(this,i,this.ai(i));return this.ji(t)},p.ij=function(){O7(this)},p.Ch=function(t,i){return jGe(this,t,i)};var pkn=k(or,"DelegatingEcoreEList",674);A(1013,674,Uxe,r8e),p.Vh=function(t,i){TMt(this,t,h(i,24))},p.Wh=function(t){DSt(this,h(t,24))},p.ai=function(t){var i,a;return i=h(ae(Ea(this.a),t),84),a=i.c,re(a,96)?h(a,24):(yt(),ff)},p.fi=function(t){var i,a;return i=h(Mw(Ea(this.a),t),84),a=i.c,re(a,96)?h(a,24):(yt(),ff)},p.gi=function(t,i){return wDt(this,t,h(i,24))},p.rh=function(){return!1},p.mi=function(t,i,a,l,f){return null},p.Xh=function(){return new SR(this)},p.Yh=function(){Pr(Ea(this.a))},p.Zh=function(t){return iWe(this,t)},p.$h=function(t){var i,a;for(a=t.tc();a.hc();)if(i=a.ic(),!iWe(this,i))return!1;return!0},p._h=function(t){var i,a,l;if(re(t,15)&&(l=h(t,15),l._b()==Ea(this.a).i)){for(i=l.tc(),a=new Bn(this);i.hc();)if(Be(i.ic())!==Be(Yn(a)))return!1;return!0}return!1},p.bi=function(){var t,i,a,l,f;for(a=1,i=new Bn(Ea(this.a));i.e!=i.i._b();)t=h(Yn(i),84),l=(f=t.c,re(f,96)?h(f,24):(yt(),ff)),a=31*a+(l?g0(l):0);return a},p.ci=function(t){var i,a,l,f;for(l=0,a=new Bn(Ea(this.a));a.e!=a.i._b();){if(i=h(Yn(a),84),Be(t)===Be((f=i.c,re(f,96)?h(f,24):(yt(),ff))))return l;++l}return-1},p.di=function(){return Ea(this.a).i==0},p.ei=function(){return null},p.hi=function(){return Ea(this.a).i},p.ii=function(){var t,i,a,l,f,g;for(g=Ea(this.a).i,f=le(on,et,1,g,5,1),a=0,i=new Bn(Ea(this.a));i.e!=i.i._b();)t=h(Yn(i),84),f[a++]=(l=t.c,re(l,96)?h(l,24):(yt(),ff));return f},p.ji=function(t){var i,a,l,f,g,m,v;for(v=Ea(this.a).i,t.lengthv&&Gr(t,v,null),l=0,a=new Bn(Ea(this.a));a.e!=a.i._b();)i=h(Yn(a),84),g=(m=i.c,re(m,96)?h(m,24):(yt(),ff)),Gr(t,l++,g);return t},p.ki=function(){var t,i,a,l,f;for(f=new Tp,f.a+="[",t=Ea(this.a),i=0,l=Ea(this.a).i;i>16,f>=0?Mte(this,a):this.Cb.Cg(this,-1-f,null,a))),Ml(this,t,6,a);case 9:return!this.a&&(this.a=new ze(eg,this,9,5)),ja(this.a,t,a)}return g=h(Wt((l=h(sn(this,16),24),l||(yt(),wb)),i),61),g.aj().dj(this,Ya(this),i-jn((yt(),wb)),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a);case 6:return Ml(this,null,6,a);case 7:return!this.A&&(this.A=new Nl(fl,this,7)),Us(this.A,t,a);case 9:return!this.a&&(this.a=new ze(eg,this,9,5)),Us(this.a,t,a)}return f=h(Wt((l=h(sn(this,16),24),l||(yt(),wb)),i),61),f.aj().ej(this,Ya(this),i-jn((yt(),wb)),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.D!=null&&this.D==this.F;case 3:return!!N0(this);case 4:return!!Lbe(this);case 5:return this.F!=null&&this.F!=this.D&&this.F!=this.B;case 6:return!!aS(this);case 7:return!!this.A&&this.A.i!=0;case 8:return(this.Bb&256)==0;case 9:return!!this.a&&this.a.i!=0}return zl(this,t-jn((yt(),wb)),Wt((i=h(sn(this,16),24),i||wb),t))},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:H9(this,ti(i));return;case 2:iJ(this,ti(i));return;case 5:Pne(this,ti(i));return;case 7:!this.A&&(this.A=new Nl(fl,this,7)),Pr(this.A),!this.A&&(this.A=new Nl(fl,this,7)),Mr(this.A,h(i,13));return;case 8:Fbe(this,ce(mt(i)));return;case 9:!this.a&&(this.a=new ze(eg,this,9,5)),Pr(this.a),!this.a&&(this.a=new ze(eg,this,9,5)),Mr(this.a,h(i,13));return}Wl(this,t-jn((yt(),wb)),Wt((a=h(sn(this,16),24),a||wb),t),i)},p.Rg=function(){return yt(),wb},p.Xg=function(){var t,i;if(this.a)for(t=0,i=this.a.i;t>16==5?h(this.Cb,608):null}return jl(this,t-jn((yt(),P1)),Wt((l=h(sn(this,16),24),l||P1),t),i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),ja(this.Ab,t,a);case 5:return this.Cb&&(a=(f=this.Db>>16,f>=0?WHe(this,a):this.Cb.Cg(this,-1-f,null,a))),Ml(this,t,5,a)}return g=h(Wt((l=h(sn(this,16),24),l||(yt(),P1)),i),61),g.aj().dj(this,Ya(this),i-jn((yt(),P1)),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a);case 5:return Ml(this,null,5,a)}return f=h(Wt((l=h(sn(this,16),24),l||(yt(),P1)),i),61),f.aj().ej(this,Ya(this),i-jn((yt(),P1)),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.d!=0;case 3:return!!this.b;case 4:return this.c!=null;case 5:return!!(this.Db>>16==5&&h(this.Cb,608))}return zl(this,t-jn((yt(),P1)),Wt((i=h(sn(this,16),24),i||P1),t))},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:Mf(this,ti(i));return;case 2:$0e(this,h(i,21).a);return;case 3:FFt(this,h(i,1634));return;case 4:tbe(this,ti(i));return}Wl(this,t-jn((yt(),P1)),Wt((a=h(sn(this,16),24),a||P1),t),i)},p.Rg=function(){return yt(),P1},p.Ib=function(){var t;return t=this.c,t??this.zb},p.b=null,p.c=null,p.d=0;var ykn=k(Lt,"EEnumLiteralImpl",525),PVt=_r(Lt,"EFactoryImpl/InternalEDateTimeFormat");A(445,1,{1699:1},N2);var xkn=k(Lt,"EFactoryImpl/1ClientInternalEDateTimeFormat",445);A(217,108,{95:1,91:1,87:1,84:1,51:1,103:1,42:1,92:1,217:1,107:1,108:1},xg),p.lg=function(t,i,a){var l;return a=Ml(this,t,i,a),this.e&&re(t,158)&&(l=x7(this,this.e),l!=this.c&&(a=GS(this,l,a))),a},p.ug=function(t,i,a){var l;switch(t){case 0:return this.f;case 1:return!this.d&&(this.d=new vs(ko,this,1)),this.d;case 2:return i?R7(this):this.c;case 3:return this.b;case 4:return this.e;case 5:return i?vte(this):this.a}return jl(this,t-jn((yt(),ky)),Wt((l=h(sn(this,16),24),l||ky),t),i,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return WVe(this,null,a);case 1:return!this.d&&(this.d=new vs(ko,this,1)),Us(this.d,t,a);case 3:return VVe(this,null,a)}return f=h(Wt((l=h(sn(this,16),24),l||(yt(),ky)),i),61),f.aj().ej(this,Ya(this),i-jn((yt(),ky)),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.f;case 1:return!!this.d&&this.d.i!=0;case 2:return!!this.c;case 3:return!!this.b;case 4:return!!this.e;case 5:return!!this.a}return zl(this,t-jn((yt(),ky)),Wt((i=h(sn(this,16),24),i||ky),t))},p.Mg=function(t,i){var a;switch(t){case 0:hOt(this,h(i,84));return;case 1:!this.d&&(this.d=new vs(ko,this,1)),Pr(this.d),!this.d&&(this.d=new vs(ko,this,1)),Mr(this.d,h(i,13));return;case 3:dqe(this,h(i,84));return;case 4:kqe(this,h(i,742));return;case 5:MA(this,h(i,133));return}Wl(this,t-jn((yt(),ky)),Wt((a=h(sn(this,16),24),a||ky),t),i)},p.Rg=function(){return yt(),ky},p.Ib=function(){var t;return t=new ou(Ku(this)),t.a+=" (expression: ",Ene(this,t),t.a+=")",t.a};var zAe,Ekn=k(Lt,"EGenericTypeImpl",217);A(1667,1657,xz),p.xj=function(t,i){return UMt(this,this._b(),t),i},p.Dh=function(t){return qg(this.Uh(),t)},p.oh=function(){return this.ph()},p.Uh=function(){return new TR(this)},p.ph=function(){return this.qh(0)},p.qh=function(t){return this.Uh().fd(t)},p.yj=function(t,i){return _x(this,t,!0),i};var Skn=k(or,"AbstractSequentialInternalEList",1667);A(444,1667,xz,eI),p.Dh=function(t){return qg(this.Uh(),t)},p.oh=function(){return this.b==null?(Pp(),Pp(),_D):this.Vj()},p.Uh=function(){return new PNe(this.a,this.b)},p.ph=function(){return this.b==null?(Pp(),Pp(),_D):this.Vj()},p.qh=function(t){var i,a;if(this.b==null){if(t<0||t>1)throw Y(new Ra(RP+t+", size=0"));return Pp(),Pp(),_D}for(a=this.Vj(),i=0;i0;)if(i=this.c[--this.d],(!this.e||i.Vi()!=MM||i.pi()!=0)&&(!this.Yj()||this.b.Gg(i))){if(g=this.b.wg(i,this.Xj()),this.f=(Yo(),h(i,61).bj()),this.f||i.lj()){if(this.Xj()?(l=h(g,15),this.k=l):(l=h(g,64),this.k=this.j=l),re(this.k,49)?(this.o=this.k._b(),this.n=this.o):this.p=this.j?this.j.qh(this.k._b()):this.k.fd(this.k._b()),this.p?cXe(this,this.p):xXe(this))return f=this.p?this.p.Ec():this.j?this.j.Dh(--this.n):this.k.cd(--this.n),this.f?(t=h(f,75),t.nj(),a=t.lc(),this.i=a):this.i=f,this.g=-3,!0}else if(g!=null)return this.k=null,this.p=null,this.i=g,this.g=-2,!0}return this.k=null,this.p=null,this.g=-1,!1}else return f=this.p?this.p.Ec():this.j?this.j.Dh(--this.n):this.k.cd(--this.n),this.f?(t=h(f,75),t.nj(),a=t.lc(),this.i=a):this.i=f,this.g=-3,!0}},p.ic=function(){return MU(this)},p.Dc=function(){return this.a},p.Ec=function(){var t;if(this.g<-1||this.Cc())return--this.a,this.g=0,t=this.i,this.Cc(),t;throw Y(new K)},p.Fc=function(){return this.a-1},p.jc=function(){throw Y(new Pi)},p.Xj=function(){return!1},p.Gc=function(t){throw Y(new Pi)},p.Yj=function(){return!0},p.a=0,p.d=0,p.f=!1,p.g=0,p.n=0,p.o=0;var _D,Ckn=k(or,"EContentsEList/FeatureIteratorImpl",260);A(631,260,Ez,qge),p.Xj=function(){return!0};var Akn=k(or,"EContentsEList/ResolvingFeatureIteratorImpl",631);A(1020,631,Ez,VFe),p.Yj=function(){return!1};var Pkn=k(Lt,"ENamedElementImpl/1/1",1020);A(1021,260,Ez,$Fe),p.Yj=function(){return!1};var Lkn=k(Lt,"ENamedElementImpl/1/2",1021);A(32,136,o5,gw,LQ,ls,VQ,Wd,qu,V0e,N7e,W0e,F7e,d0e,U7e,X0e,z7e,p0e,G7e,H0e,j7e,pI,I1e,q0e,$7e,g0e,V7e),p.oi=function(){return C0e(this)},p.vi=function(){var t;return t=C0e(this),t?t.Oi():null},p.Mh=function(t){return this.b==-1&&this.a&&(this.b=this.c.qg(this.a.pi(),this.a.Vi())),this.c.hg(this.b,t)},p.Oh=function(){return this.c},p.wi=function(){var t;return t=C0e(this),t?t.Zi():!1},p.b=-1;var kkn=k(Lt,"ENotificationImpl",32);A(371,268,{95:1,91:1,87:1,139:1,174:1,51:1,53:1,103:1,431:1,42:1,92:1,142:1,371:1,268:1,107:1,108:1},oK),p.jg=function(t){return qHe(this,t)},p.ug=function(t,i,a){var l,f,g;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.zb;case 2:return vt(),!!(this.Bb&256);case 3:return vt(),!!(this.Bb&512);case 4:return He(this.s);case 5:return He(this.t);case 6:return vt(),g=this.t,g>1||g==-1;case 7:return vt(),f=this.s,f>=1;case 8:return i?pu(this):this.r;case 9:return this.q;case 10:return this.Db>>16==10?h(this.Cb,24):null;case 11:return!this.d&&(this.d=new Nl(fl,this,11)),this.d;case 12:return!this.c&&(this.c=new ze(nv,this,12,10)),this.c;case 13:return!this.a&&(this.a=new sI(this,this)),this.a;case 14:return Vc(this)}return jl(this,t-jn((yt(),L1)),Wt((l=h(sn(this,16),24),l||L1),t),i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),ja(this.Ab,t,a);case 10:return this.Cb&&(a=(f=this.Db>>16,f>=0?qHe(this,a):this.Cb.Cg(this,-1-f,null,a))),Ml(this,t,10,a);case 12:return!this.c&&(this.c=new ze(nv,this,12,10)),ja(this.c,t,a)}return g=h(Wt((l=h(sn(this,16),24),l||(yt(),L1)),i),61),g.aj().dj(this,Ya(this),i-jn((yt(),L1)),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a);case 9:return nQ(this,a);case 10:return Ml(this,null,10,a);case 11:return!this.d&&(this.d=new Nl(fl,this,11)),Us(this.d,t,a);case 12:return!this.c&&(this.c=new ze(nv,this,12,10)),Us(this.c,t,a);case 14:return Us(Vc(this),t,a)}return f=h(Wt((l=h(sn(this,16),24),l||(yt(),L1)),i),61),f.aj().ej(this,Ya(this),i-jn((yt(),L1)),t,a)},p.Fg=function(t){var i,a,l;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return(this.Bb&256)==0;case 3:return(this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return l=this.t,l>1||l==-1;case 7:return a=this.s,a>=1;case 8:return!!this.r&&!this.q.e&&y0(this.q).i==0;case 9:return!!this.q&&!(this.r&&!this.q.e&&y0(this.q).i==0);case 10:return!!(this.Db>>16==10&&h(this.Cb,24));case 11:return!!this.d&&this.d.i!=0;case 12:return!!this.c&&this.c.i!=0;case 13:return!!this.a&&Vc(this.a.a).i!=0&&!(this.b&&wte(this.b));case 14:return!!this.b&&wte(this.b)}return zl(this,t-jn((yt(),L1)),Wt((i=h(sn(this,16),24),i||L1),t))},p.Mg=function(t,i){var a,l;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:Mf(this,ti(i));return;case 2:C_(this,ce(mt(i)));return;case 3:A_(this,ce(mt(i)));return;case 4:E_(this,h(i,21).a);return;case 5:mS(this,h(i,21).a);return;case 8:ES(this,h(i,133));return;case 9:l=Zg(this,h(i,84),null),l&&l.Th();return;case 11:!this.d&&(this.d=new Nl(fl,this,11)),Pr(this.d),!this.d&&(this.d=new Nl(fl,this,11)),Mr(this.d,h(i,13));return;case 12:!this.c&&(this.c=new ze(nv,this,12,10)),Pr(this.c),!this.c&&(this.c=new ze(nv,this,12,10)),Mr(this.c,h(i,13));return;case 13:!this.a&&(this.a=new sI(this,this)),O7(this.a),!this.a&&(this.a=new sI(this,this)),Mr(this.a,h(i,13));return;case 14:Pr(Vc(this)),Mr(Vc(this),h(i,13));return}Wl(this,t-jn((yt(),L1)),Wt((a=h(sn(this,16),24),a||L1),t),i)},p.Rg=function(){return yt(),L1},p.Xg=function(){var t,i;if(this.c)for(t=0,i=this.c.i;tv&&Gr(t,v,null),l=0,a=new Bn(Vc(this.a));a.e!=a.i._b();)i=h(Yn(a),84),g=(m=i.c,m||(yt(),zh)),Gr(t,l++,g);return t},p.ki=function(){var t,i,a,l,f;for(f=new Tp,f.a+="[",t=Vc(this.a),i=0,l=Vc(this.a).i;i1);case 5:return dA(this,5,i,a,l,this.i-h(a,15)._b()>0);default:return new Wd(this.e,t,this.c,i,a,l,!0)}},p.xi=function(){return!0},p.ui=function(){return wte(this)},p.ij=function(){Pr(this)};var Bkn=k(Lt,"EOperationImpl/2",1388);A(456,1,{1631:1,456:1},gNe);var Okn=k(Lt,"EPackageImpl/1",456);A(18,88,Ho,ze),p.Lj=function(){return this.d},p.Mj=function(){return this.b},p.Pj=function(){return!0},p.b=0;var Nkn=k(or,"EObjectContainmentWithInverseEList",18);A(364,18,Ho,ZE),p.Qj=function(){return!0},p.zh=function(t,i){return Cx(this,t,h(i,51))};var Fkn=k(or,"EObjectContainmentWithInverseEList/Resolving",364);A(303,364,Ho,u_),p.th=function(){this.a.tb=null};var Ukn=k(Lt,"EPackageImpl/2",303);A(1155,1,{},tX);var zkn=k(Lt,"EPackageImpl/3",1155);A(650,44,Fx,fpe),p.Qb=function(t){return ws(t)?gQ(this,t):!!gc(this.d,t)};var Gkn=k(Lt,"EPackageRegistryImpl",650);A(468,268,{95:1,91:1,87:1,139:1,174:1,51:1,1703:1,103:1,431:1,42:1,92:1,142:1,468:1,268:1,107:1,108:1},aK),p.jg=function(t){return XHe(this,t)},p.ug=function(t,i,a){var l,f,g;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.zb;case 2:return vt(),!!(this.Bb&256);case 3:return vt(),!!(this.Bb&512);case 4:return He(this.s);case 5:return He(this.t);case 6:return vt(),g=this.t,g>1||g==-1;case 7:return vt(),f=this.s,f>=1;case 8:return i?pu(this):this.r;case 9:return this.q;case 10:return this.Db>>16==10?h(this.Cb,53):null}return jl(this,t-jn((yt(),rv)),Wt((l=h(sn(this,16),24),l||rv),t),i,a)},p.Bg=function(t,i,a){var l,f,g;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),ja(this.Ab,t,a);case 10:return this.Cb&&(a=(f=this.Db>>16,f>=0?XHe(this,a):this.Cb.Cg(this,-1-f,null,a))),Ml(this,t,10,a)}return g=h(Wt((l=h(sn(this,16),24),l||(yt(),rv)),i),61),g.aj().dj(this,Ya(this),i-jn((yt(),rv)),t,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a);case 9:return nQ(this,a);case 10:return Ml(this,null,10,a)}return f=h(Wt((l=h(sn(this,16),24),l||(yt(),rv)),i),61),f.aj().ej(this,Ya(this),i-jn((yt(),rv)),t,a)},p.Fg=function(t){var i,a,l;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return(this.Bb&256)==0;case 3:return(this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return l=this.t,l>1||l==-1;case 7:return a=this.s,a>=1;case 8:return!!this.r&&!this.q.e&&y0(this.q).i==0;case 9:return!!this.q&&!(this.r&&!this.q.e&&y0(this.q).i==0);case 10:return!!(this.Db>>16==10&&h(this.Cb,53))}return zl(this,t-jn((yt(),rv)),Wt((i=h(sn(this,16),24),i||rv),t))},p.Rg=function(){return yt(),rv};var jkn=k(Lt,"EParameterImpl",468);A(62,418,{95:1,91:1,87:1,139:1,174:1,51:1,17:1,158:1,61:1,103:1,431:1,42:1,92:1,142:1,62:1,418:1,268:1,107:1,108:1,615:1},Jge),p.ug=function(t,i,a){var l,f,g,m;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.zb;case 2:return vt(),!!(this.Bb&256);case 3:return vt(),!!(this.Bb&512);case 4:return He(this.s);case 5:return He(this.t);case 6:return vt(),m=this.t,m>1||m==-1;case 7:return vt(),f=this.s,f>=1;case 8:return i?pu(this):this.r;case 9:return this.q;case 10:return vt(),!!(this.Bb&tf);case 11:return vt(),!!(this.Bb&Dw);case 12:return vt(),!!(this.Bb&W0);case 13:return this.j;case 14:return NS(this);case 15:return vt(),!!(this.Bb&yc);case 16:return vt(),!!(this.Bb&Ah);case 17:return dw(this);case 18:return vt(),!!(this.Bb&Ja);case 19:return vt(),g=Uo(this),!!(g&&g.Bb&Ja);case 20:return vt(),!!(this.Bb&oo);case 21:return i?Uo(this):this.b;case 22:return i?vbe(this):Hze(this);case 23:return!this.a&&(this.a=new qE(Ly,this,23)),this.a}return jl(this,t-jn((yt(),TM)),Wt((l=h(sn(this,16),24),l||TM),t),i,a)},p.Fg=function(t){var i,a,l,f;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return(this.Bb&256)==0;case 3:return(this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return f=this.t,f>1||f==-1;case 7:return a=this.s,a>=1;case 8:return!!this.r&&!this.q.e&&y0(this.q).i==0;case 9:return!!this.q&&!(this.r&&!this.q.e&&y0(this.q).i==0);case 10:return(this.Bb&tf)==0;case 11:return(this.Bb&Dw)!=0;case 12:return(this.Bb&W0)!=0;case 13:return this.j!=null;case 14:return NS(this)!=null;case 15:return(this.Bb&yc)!=0;case 16:return(this.Bb&Ah)!=0;case 17:return!!dw(this);case 18:return(this.Bb&Ja)!=0;case 19:return l=Uo(this),!!l&&(l.Bb&Ja)!=0;case 20:return(this.Bb&oo)==0;case 21:return!!this.b;case 22:return!!Hze(this);case 23:return!!this.a&&this.a.i!=0}return zl(this,t-jn((yt(),TM)),Wt((i=h(sn(this,16),24),i||TM),t))},p.Mg=function(t,i){var a,l;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:SQ(this,ti(i));return;case 2:C_(this,ce(mt(i)));return;case 3:A_(this,ce(mt(i)));return;case 4:E_(this,h(i,21).a);return;case 5:mS(this,h(i,21).a);return;case 8:ES(this,h(i,133));return;case 9:l=Zg(this,h(i,84),null),l&&l.Th();return;case 10:OU(this,ce(mt(i)));return;case 11:BU(this,ce(mt(i)));return;case 12:FU(this,ce(mt(i)));return;case 13:mge(this,ti(i));return;case 15:NU(this,ce(mt(i)));return;case 16:UU(this,ce(mt(i)));return;case 18:uLt(this,ce(mt(i)));return;case 20:fWe(this,ce(mt(i)));return;case 21:h$e(this,h(i,17));return;case 23:!this.a&&(this.a=new qE(Ly,this,23)),Pr(this.a),!this.a&&(this.a=new qE(Ly,this,23)),Mr(this.a,h(i,13));return}Wl(this,t-jn((yt(),TM)),Wt((a=h(sn(this,16),24),a||TM),t),i)},p.Rg=function(){return yt(),TM},p.Xg=function(){vbe(this),iS(Vo((qc(),Zs),this)),pu(this),this.Bb|=1},p.$i=function(){return Uo(this)},p.Cj=function(){var t;return t=Uo(this),!!t&&(t.Bb&Ja)!=0},p.Dj=function(){return(this.Bb&Ja)!=0},p.Ej=function(){return(this.Bb&oo)!=0},p.zj=function(t,i){return this.c=null,Bbe(this,t,i)},p.Ib=function(){var t;return this.Db&64?L7(this):(t=new su(L7(this)),t.a+=" (containment: ",Ap(t,(this.Bb&Ja)!=0),t.a+=", resolveProxies: ",Ap(t,(this.Bb&oo)!=0),t.a+=")",t.a)};var $kn=k(Lt,"EReferenceImpl",62);A(505,108,{95:1,38:1,91:1,87:1,134:1,51:1,103:1,42:1,92:1,505:1,107:1,108:1},EN),p.Fb=function(t){return this===t},p.kc=function(){return this.b},p.lc=function(){return this.c},p.Hb=function(){return g0(this)},p.kh=function(t){iAt(this,ti(t))},p.mc=function(t){return HCt(this,ti(t))},p.ug=function(t,i,a){var l;switch(t){case 0:return this.b;case 1:return this.c}return jl(this,t-jn((yt(),zo)),Wt((l=h(sn(this,16),24),l||zo),t),i,a)},p.Fg=function(t){var i;switch(t){case 0:return this.b!=null;case 1:return this.c!=null}return zl(this,t-jn((yt(),zo)),Wt((i=h(sn(this,16),24),i||zo),t))},p.Mg=function(t,i){var a;switch(t){case 0:rAt(this,ti(i));return;case 1:s$e(this,ti(i));return}Wl(this,t-jn((yt(),zo)),Wt((a=h(sn(this,16),24),a||zo),t),i)},p.Rg=function(){return yt(),zo},p.ih=function(){var t;return this.a==-1&&(t=this.b,this.a=t==null?0:Hg(t)),this.a},p.jh=function(t){this.a=t},p.Ib=function(){var t;return this.Db&64?Ku(this):(t=new su(Ku(this)),t.a+=" (key: ",ho(t,this.b),t.a+=", value: ",ho(t,this.c),t.a+=")",t.a)},p.a=-1,p.b=null,p.c=null;var Aa=k(Lt,"EStringToStringMapEntryImpl",505),nut=_r(or,"FeatureMap/Entry/Internal");A(514,1,Sz),p.$j=function(t){return this._j(h(t,42))},p._j=function(t){return this.$j(t)},p.Fb=function(t){var i,a;return this===t?!0:re(t,75)?(i=h(t,75),i.nj()==this.c?(a=this.lc(),a==null?i.lc()==null:ki(a,i.lc())):!1):!1},p.nj=function(){return this.c},p.Hb=function(){var t;return t=this.lc(),Hr(this.c)^(t==null?0:Hr(t))},p.Ib=function(){var t,i;return t=this.c,i=$l(t.Wi()).fh(),t.be(),(i!=null&&i.length!=0?i+":"+t.be():t.be())+"="+this.lc()};var Vkn=k(Lt,"EStructuralFeatureImpl/BasicFeatureMapEntry",514);A(709,514,Sz,ome),p._j=function(t){return new ome(this.c,t)},p.lc=function(){return this.a},p.ak=function(t,i,a){return jRt(this,t,this.a,i,a)},p.bk=function(t,i,a){return $Rt(this,t,this.a,i,a)};var Wkn=k(Lt,"EStructuralFeatureImpl/ContainmentUpdatingFeatureMapEntry",709);A(1363,1,{},mNe),p.cj=function(t,i,a,l,f){var g;return g=h(AI(t,this.b),237),g.yk(this.a).hj(l)},p.dj=function(t,i,a,l,f){var g;return g=h(AI(t,this.b),237),g.pk(this.a,l,f)},p.ej=function(t,i,a,l,f){var g;return g=h(AI(t,this.b),237),g.qk(this.a,l,f)},p.fj=function(t,i,a){var l;return l=h(AI(t,this.b),237),l.yk(this.a).ui()},p.gj=function(t,i,a,l){var f;f=h(AI(t,this.b),237),f.yk(this.a).Gc(l)};var Hkn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateFeatureMapDelegator",1363);A(82,1,{},Ip,Vm,Np,qm),p.cj=function(t,i,a,l,f){var g;if(g=i.Tg(a),g==null&&i.Ug(a,g=z_e(this,t)),!f)switch(this.e){case 50:case 41:return h(g,533).Hi();case 40:return h(g,237).vk()}return g},p.dj=function(t,i,a,l,f){var g,m;return m=i.Tg(a),m==null&&i.Ug(a,m=z_e(this,t)),g=h(m,64).xj(l,f),g},p.ej=function(t,i,a,l,f){var g;return g=i.Tg(a),g!=null&&(f=h(g,64).yj(l,f)),f},p.fj=function(t,i,a){var l;return l=i.Tg(a),l!=null&&h(l,81).ui()},p.gj=function(t,i,a,l){var f;f=h(i.Tg(a),81),!f&&i.Ug(a,f=z_e(this,t)),f.Gc(l)},p.b=0,p.e=0;var qkn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateMany",82);A(461,1,{}),p.dj=function(t,i,a,l,f){throw Y(new Pi)},p.ej=function(t,i,a,l,f){throw Y(new Pi)};var gm,Xkn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingle",461);A(702,461,{},j1e),p.cj=function(t,i,a,l,f){return ane(t,t.yg(),t.og())==this.b?this.Ej()&&l?Xte(t):t.yg():null},p.dj=function(t,i,a,l,f){var g,m;return t.yg()&&(f=(g=t.og(),g>=0?t.jg(f):t.yg().Cg(t,-1-g,null,f))),m=br(t.mg(),this.e),t.lg(l,m,f)},p.ej=function(t,i,a,l,f){var g;return g=br(t.mg(),this.e),t.lg(null,g,f)},p.fj=function(t,i,a){var l;return l=br(t.mg(),this.e),!!t.yg()&&t.og()==l},p.gj=function(t,i,a,l){var f,g,m,v,y;if(l!=null&&!hne(this.a,l))throw Y(new xC(Mz+(re(l,51)?Vwe(h(l,51).mg()):N0e(sl(l)))+Tz+this.a+"'"));if(f=t.yg(),m=br(t.mg(),this.e),Be(l)!==Be(f)||t.og()!=m&&l!=null){if(LS(t,h(l,51)))throw Y(new un(LP+t.Ib()));y=null,f&&(y=(g=t.og(),g>=0?t.jg(null):t.yg().Cg(t,-1-g,null,null))),v=h(l,42),v&&(y=v.Ag(t,br(v.mg(),this.b),null,y)),y=t.lg(v,m,y),y&&y.Th()}else t.eg()&&t.fg()&&Li(t,new ls(t,1,m,l,l))},p.Ej=function(){return!1};var Ykn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleContainer",702);A(1364,702,{},Y8e),p.Ej=function(){return!0};var Zkn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleContainerResolving",1364);A(512,461,{}),p.cj=function(t,i,a,l,f){var g;return g=i.Tg(a),g==null?this.b:Be(g)===Be(gm)?null:g},p.fj=function(t,i,a){var l;return l=i.Tg(a),l!=null&&(Be(l)===Be(gm)||!ki(l,this.b))},p.gj=function(t,i,a,l){var f,g;t.eg()&&t.fg()?(f=(g=i.Tg(a),g==null?this.b:Be(g)===Be(gm)?null:g),l==null?this.c!=null?(i.Ug(a,null),l=this.b):this.b!=null?i.Ug(a,gm):i.Ug(a,null):(this.ck(l),i.Ug(a,l)),Li(t,this.d.dk(t,1,this.e,f,l))):l==null?this.c!=null?i.Ug(a,null):this.b!=null?i.Ug(a,gm):i.Ug(a,null):(this.ck(l),i.Ug(a,l))},p.ck=function(t){throw Y(new i8)};var Kkn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData",512);A(ay,1,{},zk),p.dk=function(t,i,a,l,f){return new pI(t,i,a,l,f)},p.ek=function(t,i,a,l,f,g){return new I1e(t,i,a,l,f,g)};var GAe,jAe,$Ae,VAe,WAe,HAe,qAe,Bae,XAe,Jkn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator",ay);A(1379,ay,{},nX),p.dk=function(t,i,a,l,f){return new g0e(t,i,a,ce(mt(l)),ce(mt(f)))},p.ek=function(t,i,a,l,f,g){return new V7e(t,i,a,ce(mt(l)),ce(mt(f)),g)};var Qkn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/1",1379);A(1380,ay,{},Gk),p.dk=function(t,i,a,l,f){return new V0e(t,i,a,h(l,192).a,h(f,192).a)},p.ek=function(t,i,a,l,f,g){return new N7e(t,i,a,h(l,192).a,h(f,192).a,g)};var eRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/2",1380);A(1381,ay,{},SN),p.dk=function(t,i,a,l,f){return new W0e(t,i,a,h(l,159).a,h(f,159).a)},p.ek=function(t,i,a,l,f,g){return new F7e(t,i,a,h(l,159).a,h(f,159).a,g)};var tRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/3",1381);A(1382,ay,{},MN),p.dk=function(t,i,a,l,f){return new d0e(t,i,a,ce(Xe(l)),ce(Xe(f)))},p.ek=function(t,i,a,l,f,g){return new U7e(t,i,a,ce(Xe(l)),ce(Xe(f)),g)};var nRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/4",1382);A(1383,ay,{},TN),p.dk=function(t,i,a,l,f){return new X0e(t,i,a,h(l,126).a,h(f,126).a)},p.ek=function(t,i,a,l,f,g){return new z7e(t,i,a,h(l,126).a,h(f,126).a,g)};var iRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/5",1383);A(1384,ay,{},JT),p.dk=function(t,i,a,l,f){return new p0e(t,i,a,h(l,21).a,h(f,21).a)},p.ek=function(t,i,a,l,f,g){return new G7e(t,i,a,h(l,21).a,h(f,21).a,g)};var rRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/6",1384);A(1385,ay,{},iX),p.dk=function(t,i,a,l,f){return new H0e(t,i,a,h(l,149).a,h(f,149).a)},p.ek=function(t,i,a,l,f,g){return new j7e(t,i,a,h(l,149).a,h(f,149).a,g)};var sRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/7",1385);A(1386,ay,{},CN),p.dk=function(t,i,a,l,f){return new q0e(t,i,a,h(l,168).a,h(f,168).a)},p.ek=function(t,i,a,l,f,g){return new $7e(t,i,a,h(l,168).a,h(f,168).a,g)};var oRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/8",1386);A(1366,512,{},kUe),p.ck=function(t){if(!this.a.Li(t))throw Y(new xC(Mz+sl(t)+Tz+this.a+"'"))};var aRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleDataDynamic",1366);A(1367,512,{},B9e),p.ck=function(t){};var cRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleDataStatic",1367);A(703,512,{}),p.fj=function(t,i,a){var l;return l=i.Tg(a),l!=null},p.gj=function(t,i,a,l){var f,g;t.eg()&&t.fg()?(f=!0,g=i.Tg(a),g==null?(f=!1,g=this.b):Be(g)===Be(gm)&&(g=null),l==null?this.c!=null?(i.Ug(a,null),l=this.b):i.Ug(a,gm):(this.ck(l),i.Ug(a,l)),Li(t,this.d.ek(t,1,this.e,g,l,!f))):l==null?this.c!=null?i.Ug(a,null):i.Ug(a,gm):(this.ck(l),i.Ug(a,l))};var lRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleDataUnsettable",703);A(1368,703,{},RUe),p.ck=function(t){if(!this.a.Li(t))throw Y(new xC(Mz+sl(t)+Tz+this.a+"'"))};var uRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleDataUnsettableDynamic",1368);A(1369,703,{},O9e),p.ck=function(t){};var fRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleDataUnsettableStatic",1369);A(370,461,{},M9),p.cj=function(t,i,a,l,f){var g,m,v,y,E;if(E=i.Tg(a),this.Zi()&&Be(E)===Be(gm))return null;if(this.Ej()&&l&&E!=null){if(v=h(E,42),v.Eg()&&(y=jg(t,v),v!=y)){if(!hne(this.a,y))throw Y(new xC(Mz+sl(y)+Tz+this.a+"'"));i.Ug(a,E=y),this.Dj()&&(g=h(y,42),m=v.Cg(t,this.b?br(v.mg(),this.b):-1-br(t.mg(),this.e),null,null),!g.yg()&&(m=g.Ag(t,this.b?br(g.mg(),this.b):-1-br(t.mg(),this.e),null,m)),m&&m.Th()),t.eg()&&t.fg()&&Li(t,new pI(t,9,this.e,v,y))}return E}else return E},p.dj=function(t,i,a,l,f){var g,m;return m=i.Tg(a),Be(m)===Be(gm)&&(m=null),i.Ug(a,l),this.qi()?Be(m)!==Be(l)&&m!=null&&(g=h(m,42),f=g.Cg(t,br(g.mg(),this.b),null,f)):this.Dj()&&m!=null&&(f=h(m,42).Cg(t,-1-br(t.mg(),this.e),null,f)),t.eg()&&t.fg()&&(!f&&(f=new Eg(4)),f.Sh(new pI(t,1,this.e,m,l))),f},p.ej=function(t,i,a,l,f){var g;return g=i.Tg(a),Be(g)===Be(gm)&&(g=null),i.Vg(a),t.eg()&&t.fg()&&(!f&&(f=new Eg(4)),this.Zi()?f.Sh(new pI(t,2,this.e,g,null)):f.Sh(new pI(t,1,this.e,g,null))),f},p.fj=function(t,i,a){var l;return l=i.Tg(a),l!=null},p.gj=function(t,i,a,l){var f,g,m,v,y;if(l!=null&&!hne(this.a,l))throw Y(new xC(Mz+(re(l,51)?Vwe(h(l,51).mg()):N0e(sl(l)))+Tz+this.a+"'"));y=i.Tg(a),v=y!=null,this.Zi()&&Be(y)===Be(gm)&&(y=null),m=null,this.qi()?Be(y)!==Be(l)&&(y!=null&&(f=h(y,42),m=f.Cg(t,br(f.mg(),this.b),null,null)),l!=null&&(f=h(l,42),m=f.Ag(t,br(f.mg(),this.b),null,m))):this.Dj()&&Be(y)!==Be(l)&&(y!=null&&(m=h(y,42).Cg(t,-1-br(t.mg(),this.e),null,null)),l!=null&&(m=h(l,42).Ag(t,-1-br(t.mg(),this.e),null,m))),l==null&&this.Zi()?i.Ug(a,gm):i.Ug(a,l),t.eg()&&t.fg()?(g=new I1e(t,1,this.e,y,l,this.Zi()&&!v),m?(m.Sh(g),m.Th()):Li(t,g)):m&&m.Th()},p.qi=function(){return!1},p.Dj=function(){return!1},p.Ej=function(){return!1},p.Zi=function(){return!1};var hRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObject",370);A(513,370,{},_J),p.Dj=function(){return!0};var dRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainment",513);A(1372,513,{},WFe),p.Ej=function(){return!0};var pRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentResolving",1372);A(705,513,{},Yge),p.Zi=function(){return!0};var gRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentUnsettable",705);A(1374,705,{},HFe),p.Ej=function(){return!0};var mRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentUnsettableResolving",1374);A(585,513,{},OJ),p.qi=function(){return!0};var bRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverse",585);A(1373,585,{},Z8e),p.Ej=function(){return!0};var wRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverseResolving",1373);A(706,585,{},Lme),p.Zi=function(){return!0};var vRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverseUnsettable",706);A(1375,706,{},K8e),p.Ej=function(){return!0};var _Rn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverseUnsettableResolving",1375);A(586,370,{},Xge),p.Ej=function(){return!0};var yRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolving",586);A(1376,586,{},qFe),p.Zi=function(){return!0};var xRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolvingUnsettable",1376);A(707,586,{},Pme),p.qi=function(){return!0};var ERn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolvingWithInverse",707);A(1377,707,{},J8e),p.Zi=function(){return!0};var SRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolvingWithInverseUnsettable",1377);A(1370,370,{},XFe),p.Zi=function(){return!0};var MRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectUnsettable",1370);A(704,370,{},kme),p.qi=function(){return!0};var TRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectWithInverse",704);A(1371,704,{},Q8e),p.Zi=function(){return!0};var CRn=k(Lt,"EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectWithInverseUnsettable",1371);A(708,514,Sz,y1e),p._j=function(t){return new y1e(this.a,this.c,t)},p.lc=function(){return this.b},p.ak=function(t,i,a){return rkt(this,t,this.b,a)},p.bk=function(t,i,a){return skt(this,t,this.b,a)};var ARn=k(Lt,"EStructuralFeatureImpl/InverseUpdatingFeatureMapEntry",708);A(1378,514,Sz,Fze),p.$j=function(t){return new MJ((lr(),MD),this.b.Zg(this.a,t))},p.lc=function(){return null},p.ak=function(t,i,a){return a},p.bk=function(t,i,a){return a};var PRn=k(Lt,"EStructuralFeatureImpl/SimpleContentFeatureMapEntry",1378);A(587,514,Sz,MJ),p.$j=function(t){return new MJ(this.c,t)},p.lc=function(){return this.a},p.ak=function(t,i,a){return a},p.bk=function(t,i,a){return a};var LRn=k(Lt,"EStructuralFeatureImpl/SimpleFeatureMapEntry",587);A(361,451,Ih,qb),p.Fh=function(t){return le(Lu,et,24,t,0,1)},p.Bh=function(){return!1};var kRn=k(Lt,"ESuperAdapter/1",361);A(411,399,{95:1,91:1,87:1,139:1,174:1,51:1,103:1,742:1,42:1,92:1,142:1,411:1,107:1,108:1},jk),p.ug=function(t,i,a){var l;switch(t){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),this.Ab;case 1:return this.zb;case 2:return!this.a&&(this.a=new dI(this,ko,this)),this.a}return jl(this,t-jn((yt(),Ry)),Wt((l=h(sn(this,16),24),l||Ry),t),i,a)},p.Dg=function(t,i,a){var l,f;switch(i){case 0:return!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Us(this.Ab,t,a);case 2:return!this.a&&(this.a=new dI(this,ko,this)),Us(this.a,t,a)}return f=h(Wt((l=h(sn(this,16),24),l||(yt(),Ry)),i),61),f.aj().ej(this,Ya(this),i-jn((yt(),Ry)),t,a)},p.Fg=function(t){var i;switch(t){case 0:return!!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return!!this.a&&this.a.i!=0}return zl(this,t-jn((yt(),Ry)),Wt((i=h(sn(this,16),24),i||Ry),t))},p.Mg=function(t,i){var a;switch(t){case 0:!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Pr(this.Ab),!this.Ab&&(this.Ab=new ze(Ri,this,0,3)),Mr(this.Ab,h(i,13));return;case 1:Mf(this,ti(i));return;case 2:!this.a&&(this.a=new dI(this,ko,this)),Pr(this.a),!this.a&&(this.a=new dI(this,ko,this)),Mr(this.a,h(i,13));return}Wl(this,t-jn((yt(),Ry)),Wt((a=h(sn(this,16),24),a||Ry),t),i)},p.Rg=function(){return yt(),Ry};var RRn=k(Lt,"ETypeParameterImpl",411);A(457,88,Ho,dI),p.ri=function(t,i){return qBt(this,h(t,84),i)},p.si=function(t,i){return XBt(this,h(t,84),i)};var IRn=k(Lt,"ETypeParameterImpl/1",457);A(579,44,Fx,lK),p.Xb=function(){return new bC(this)};var DRn=k(Lt,"ETypeParameterImpl/2",579);A(508,fd,gu,bC),p.nc=function(t){return n8e(this,h(t,84))},p.oc=function(t){var i,a,l;for(l=!1,a=t.tc();a.hc();)i=h(a.ic(),84),dr(this.a,i,"")==null&&(l=!0);return l},p.Pb=function(){nl(this.a)},p.pc=function(t){return w0(this.a,t)},p.tc=function(){var t;return t=new Zm(new Ep(this.a).a),new wC(t)},p.vc=function(t){return qze(this,t)},p._b=function(){return OE(this.a)};var BRn=k(Lt,"ETypeParameterImpl/2/1",508);A(509,1,ys,wC),p.gc=function(t){Ss(this,t)},p.ic=function(){return h(L0(this.a).kc(),84)},p.hc=function(){return this.a.b},p.jc=function(){RGe(this.a)};var ORn=k(Lt,"ETypeParameterImpl/2/1/1",509);A(1169,44,Fx,LDe),p.Qb=function(t){return ws(t)?gQ(this,t):!!gc(this.d,t)},p.Vb=function(t){var i,a;return i=ws(t)?za(this,t):Dc(gc(this.d,t)),re(i,743)?(a=h(i,743),i=a.mj(),dr(this,h(t,207),i),i):i??(t==null?(yK(),rut):null)};var NRn=k(Lt,"EValidatorRegistryImpl",1169);A(1362,638,{95:1,91:1,87:1,430:1,139:1,51:1,103:1,1635:1,42:1,92:1,142:1,107:1,108:1},AN),p.Zg=function(t,i){switch(t.Ni()){case 21:case 22:case 23:case 24:case 26:case 31:case 32:case 37:case 38:case 39:case 40:case 43:case 44:case 48:case 49:case 20:return i==null?null:Ga(i);case 25:return fRt(i);case 27:return Ckt(i);case 28:return Akt(i);case 29:return i==null?null:sFe(RL[0],h(i,181));case 41:return i==null?"":Um(h(i,274));case 42:return Ga(i);case 50:return ti(i);default:throw Y(new un(eM+t.be()+X0))}},p.$g=function(t){var i,a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee;switch(t.G==-1&&(t.G=(B=$l(t),B?$p(B.bh(),t):-1)),t.G){case 0:return a=new cK,a;case 1:return i=new _N,i;case 2:return l=new lR,l;case 4:return f=new S,f;case 5:return g=new ADe,g;case 6:return m=new CR,m;case 7:return v=new hF,v;case 10:return E=new Bu,E;case 11:return C=new oK,C;case 12:return R=new UUe,R;case 13:return N=new aK,N;case 14:return W=new Jge,W;case 17:return V=new EN,V;case 18:return y=new xg,y;case 19:return ee=new jk,ee;default:throw Y(new un(bre+t.zb+X0))}},p._g=function(t,i){switch(t.Ni()){case 20:return i==null?null:new mpe(i);case 21:return i==null?null:new Tg(i);case 23:case 22:return i==null?null:n5t(i);case 26:case 24:return i==null?null:LI(Sl(i,-128,127)<<24>>24);case 25:return DFt(i);case 27:return oDt(i);case 28:return aDt(i);case 29:return LOt(i);case 32:case 31:return i==null?null:xw(i);case 38:case 37:return i==null?null:new yC(i);case 40:case 39:return i==null?null:He(Sl(i,zs,zi));case 41:return null;case 42:return i==null,null;case 44:case 43:return i==null?null:n1(F7(i));case 49:case 48:return i==null?null:xS(Sl(i,Cz,32767)<<16>>16);case 50:return i;default:throw Y(new un(eM+t.be()+X0))}};var FRn=k(Lt,"EcoreFactoryImpl",1362);A(504,248,{95:1,91:1,87:1,139:1,174:1,51:1,207:1,103:1,1633:1,42:1,92:1,142:1,248:1,504:1,107:1,108:1,613:1},bUe),p.gb=!1,p.hb=!1;var YAe,iut=!1,URn=k(Lt,"EcorePackageImpl",504);A(1111,1,{743:1},rX),p.mj=function(){return hFe(),sut};var zRn=k(Lt,"EcorePackageImpl/1",1111);A(1120,1,li,$k),p.Li=function(t){return re(t,139)},p.Mi=function(t){return le(mD,et,139,t,0,1)};var GRn=k(Lt,"EcorePackageImpl/10",1120);A(1121,1,li,PN),p.Li=function(t){return re(t,174)},p.Mi=function(t){return le(Tae,et,174,t,0,1)};var jRn=k(Lt,"EcorePackageImpl/11",1121);A(1122,1,li,Vk),p.Li=function(t){return re(t,51)},p.Mi=function(t){return le(Qw,et,51,t,0,1)};var $Rn=k(Lt,"EcorePackageImpl/12",1122);A(1123,1,li,sX),p.Li=function(t){return re(t,371)},p.Mi=function(t){return le(uf,Fxe,53,t,0,1)};var VRn=k(Lt,"EcorePackageImpl/13",1123);A(1124,1,li,Wk),p.Li=function(t){return re(t,207)},p.Mi=function(t){return le(ch,et,207,t,0,1)};var WRn=k(Lt,"EcorePackageImpl/14",1124);A(1125,1,li,ro),p.Li=function(t){return re(t,468)},p.Mi=function(t){return le(nv,et,1703,t,0,1)};var HRn=k(Lt,"EcorePackageImpl/15",1125);A(1126,1,li,oX),p.Li=function(t){return re(t,62)},p.Mi=function(t){return le(iv,oy,17,t,0,1)};var qRn=k(Lt,"EcorePackageImpl/16",1126);A(1127,1,li,aX),p.Li=function(t){return re(t,158)},p.Mi=function(t){return le(Sc,oy,158,t,0,1)};var XRn=k(Lt,"EcorePackageImpl/17",1127);A(1128,1,li,vE),p.Li=function(t){return re(t,431)},p.Mi=function(t){return le(tv,et,431,t,0,1)};var YRn=k(Lt,"EcorePackageImpl/18",1128);A(1129,1,li,LN),p.Li=function(t){return re(t,505)},p.Mi=function(t){return le(Aa,_tt,505,t,0,1)};var ZRn=k(Lt,"EcorePackageImpl/19",1129);A(1112,1,li,cX),p.Li=function(t){return re(t,335)},p.Mi=function(t){return le(Ly,oy,29,t,0,1)};var KRn=k(Lt,"EcorePackageImpl/2",1112);A(1130,1,li,lX),p.Li=function(t){return re(t,217)},p.Mi=function(t){return le(ko,Ntt,84,t,0,1)};var JRn=k(Lt,"EcorePackageImpl/20",1130);A(1131,1,li,xp),p.Li=function(t){return re(t,411)},p.Mi=function(t){return le(fl,et,742,t,0,1)};var QRn=k(Lt,"EcorePackageImpl/21",1131);A(1132,1,li,uX),p.Li=function(t){return ow(t)},p.Mi=function(t){return le(lo,be,434,t,8,1)};var eIn=k(Lt,"EcorePackageImpl/22",1132);A(1133,1,li,QT),p.Li=function(t){return re(t,173)},p.Mi=function(t){return le(Mc,be,173,t,0,2)};var tIn=k(Lt,"EcorePackageImpl/23",1133);A(1134,1,li,Hk),p.Li=function(t){return re(t,192)},p.Mi=function(t){return le(qx,be,192,t,0,1)};var nIn=k(Lt,"EcorePackageImpl/24",1134);A(1135,1,li,kN),p.Li=function(t){return re(t,159)},p.Mi=function(t){return le($P,be,159,t,0,1)};var iIn=k(Lt,"EcorePackageImpl/25",1135);A(1136,1,li,RN),p.Li=function(t){return re(t,181)},p.Mi=function(t){return le(zz,be,181,t,0,1)};var rIn=k(Lt,"EcorePackageImpl/26",1136);A(1137,1,li,Ld),p.Li=function(t){return!1},p.Mi=function(t){return le(dPe,et,1787,t,0,1)};var sIn=k(Lt,"EcorePackageImpl/27",1137);A(1138,1,li,Xb),p.Li=function(t){return aw(t)},p.Mi=function(t){return le(Eo,be,315,t,7,1)};var oIn=k(Lt,"EcorePackageImpl/28",1138);A(1139,1,li,qk),p.Li=function(t){return re(t,52)},p.Mi=function(t){return le(AAe,Lw,52,t,0,1)};var aIn=k(Lt,"EcorePackageImpl/29",1139);A(1113,1,li,IN),p.Li=function(t){return re(t,469)},p.Mi=function(t){return le(Ri,{3:1,4:1,5:1,1627:1},609,t,0,1)};var cIn=k(Lt,"EcorePackageImpl/3",1113);A(1140,1,li,eC),p.Li=function(t){return re(t,525)},p.Mi=function(t){return le(kAe,et,1634,t,0,1)};var lIn=k(Lt,"EcorePackageImpl/30",1140);A(1141,1,li,DN),p.Li=function(t){return re(t,184)},p.Mi=function(t){return le(ePe,Lw,184,t,0,1)};var uIn=k(Lt,"EcorePackageImpl/31",1141);A(1142,1,li,Xk),p.Li=function(t){return re(t,75)},p.Mi=function(t){return le(Nj,Htt,75,t,0,1)};var fIn=k(Lt,"EcorePackageImpl/32",1142);A(1143,1,li,BN),p.Li=function(t){return re(t,126)},p.Mi=function(t){return le(aM,be,126,t,0,1)};var hIn=k(Lt,"EcorePackageImpl/33",1143);A(1144,1,li,Yk),p.Li=function(t){return re(t,21)},p.Mi=function(t){return le(Po,be,21,t,0,1)};var dIn=k(Lt,"EcorePackageImpl/34",1144);A(1145,1,li,Zk),p.Li=function(t){return re(t,274)},p.Mi=function(t){return le(Kxe,et,274,t,0,1)};var pIn=k(Lt,"EcorePackageImpl/35",1145);A(1146,1,li,Yb),p.Li=function(t){return re(t,149)},p.Mi=function(t){return le(K0,be,149,t,0,1)};var gIn=k(Lt,"EcorePackageImpl/36",1146);A(1147,1,li,fX),p.Li=function(t){return re(t,109)},p.Mi=function(t){return le(Jxe,et,109,t,0,1)};var mIn=k(Lt,"EcorePackageImpl/37",1147);A(1148,1,li,Zb),p.Li=function(t){return re(t,534)},p.Mi=function(t){return le(ZAe,et,534,t,0,1)};var bIn=k(Lt,"EcorePackageImpl/38",1148);A(1149,1,li,ON),p.Li=function(t){return!1},p.Mi=function(t){return le(pPe,et,1788,t,0,1)};var wIn=k(Lt,"EcorePackageImpl/39",1149);A(1114,1,li,NN),p.Li=function(t){return re(t,96)},p.Mi=function(t){return le(Lu,et,24,t,0,1)};var vIn=k(Lt,"EcorePackageImpl/4",1114);A(1150,1,li,Kk),p.Li=function(t){return re(t,168)},p.Mi=function(t){return le(J0,be,168,t,0,1)};var _In=k(Lt,"EcorePackageImpl/40",1150);A(1151,1,li,hX),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var yIn=k(Lt,"EcorePackageImpl/41",1151);A(1152,1,li,dX),p.Li=function(t){return re(t,532)},p.Mi=function(t){return le(LAe,et,532,t,0,1)};var xIn=k(Lt,"EcorePackageImpl/42",1152);A(1153,1,li,pX),p.Li=function(t){return!1},p.Mi=function(t){return le(gPe,be,1789,t,0,1)};var EIn=k(Lt,"EcorePackageImpl/43",1153);A(1154,1,li,FN),p.Li=function(t){return re(t,38)},p.Mi=function(t){return le(cy,et,38,t,0,1)};var SIn=k(Lt,"EcorePackageImpl/44",1154);A(1115,1,li,UN),p.Li=function(t){return re(t,133)},p.Mi=function(t){return le(lh,et,133,t,0,1)};var MIn=k(Lt,"EcorePackageImpl/5",1115);A(1116,1,li,gX),p.Li=function(t){return re(t,140)},p.Mi=function(t){return le(Rae,et,140,t,0,1)};var TIn=k(Lt,"EcorePackageImpl/6",1116);A(1117,1,li,zN),p.Li=function(t){return re(t,425)},p.Mi=function(t){return le(Oj,et,608,t,0,1)};var CIn=k(Lt,"EcorePackageImpl/7",1117);A(1118,1,li,GN),p.Li=function(t){return re(t,525)},p.Mi=function(t){return le(eg,et,617,t,0,1)};var AIn=k(Lt,"EcorePackageImpl/8",1118);A(1119,1,li,Xh),p.Li=function(t){return re(t,430)},p.Mi=function(t){return le(kL,et,430,t,0,1)};var PIn=k(Lt,"EcorePackageImpl/9",1119);A(915,1673,vtt,VDe),p.sh=function(t,i){RIt(this,h(i,380))},p.vh=function(t,i){Vqe(this,t,h(i,380))};var LIn=k(Lt,"MinimalEObjectImpl/1ArrayDelegatingAdapterList",915);A(916,136,o5,oUe),p.Oh=function(){return this.a.a};var kIn=k(Lt,"MinimalEObjectImpl/1ArrayDelegatingAdapterList/1",916);A(955,954,{},ZNe);var RIn=k("org.eclipse.emf.ecore.plugin","EcorePlugin",955),ZAe=_r(qtt,"Resource");A(719,1492,Xtt),p.ik=function(t){},p.jk=function(t){},p.fk=function(){return!this.a&&(this.a=new MR(this)),this.a},p.gk=function(t){var i,a,l,f,g;if(l=t.length,l>0)if(t.charCodeAt(0)==47){for(g=new Gl(4),f=1,i=1;i0&&(t=t.substr(0,a)));return uFt(this,t)},p.hk=function(){return this.c},p.Ib=function(){return Um(this.ql)+"@"+(Hr(this)>>>0).toString(16)+" uri='"+this.d+"'"},p.b=!1;var IIn=k(Rre,"ResourceImpl",719);A(1493,719,Xtt,JZ);var DIn=k(Rre,"BinaryResourceImpl",1493);A(1048,629,Tre),p.Gh=function(t){return re(t,51)?DPt(this,h(t,51)):re(t,534)?new Bn(h(t,534).fk()):Be(t)===Be(this.f)?h(t,13).tc():(tA(),vD.a)},p.hc=function(){return Sve(this)},p.a=!1;var BIn=k(or,"EcoreUtil/ContentTreeIterator",1048);A(1494,1048,Tre,j9e),p.Gh=function(t){return Be(t)===Be(this.f)?h(t,15).tc():new lze(h(t,51))};var OIn=k(Rre,"ResourceImpl/5",1494);A(595,1687,Ott,MR),p.pc=function(t){return this.i<=4?QA(this,t):re(t,42)&&h(t,42).sg()==this.a},p.sh=function(t,i){t==this.i-1&&(this.a.b||(this.a.b=!0))},p.uh=function(t,i){t==0?this.a.b||(this.a.b=!0):GQ(this,t,i)},p.vh=function(t,i){},p.wh=function(t,i,a){},p.pi=function(){return 2},p.Oh=function(){return this.a},p.qi=function(){return!0},p.ri=function(t,i){var a;return a=h(t,42),i=a.Pg(this.a,i),i},p.si=function(t,i){var a;return a=h(t,42),a.Pg(null,i)},p.ti=function(){return!1},p.xh=function(){return!0},p.Fh=function(t){return le(Qw,et,51,t,0,1)},p.Bh=function(){return!1};var NIn=k(Rre,"ResourceImpl/ContentsEList",595);A(873,1657,Ix,TR),p.fd=function(t){return this.a.qh(t)},p._b=function(){return this.a._b()};var FIn=k(or,"AbstractSequentialInternalEList/1",873),KAe,JAe,Zs,QAe;A(567,1,{},l9e);var Fj,Uj,UIn=k(or,"BasicExtendedMetaData",567);A(1023,1,{},bNe),p.kk=function(){return null},p.lk=function(){return this.a==-2&&Rde(this,kOt(this.d,this.b)),this.a},p.mk=function(){return null},p.nk=function(){return _t(),_t(),uo},p.be=function(){return this.c==iM&&gY(this,tHe(this.d,this.b)),this.c},p.ok=function(){return 0},p.a=-2,p.c=iM;var zIn=k(or,"BasicExtendedMetaData/EClassExtendedMetaDataImpl",1023);A(tf,1,{},H7e),p.kk=function(){return this.a==(fS(),Fj)&&Ide(this,H9t(this.f,this.b)),this.a},p.lk=function(){return 0},p.mk=function(){return this.c==(fS(),Fj)&&mY(this,q9t(this.f,this.b)),this.c},p.nk=function(){return!this.d&&Dde(this,M7t(this.f,this.b)),this.d},p.be=function(){return this.e==iM&&Bde(this,tHe(this.f,this.b)),this.e},p.ok=function(){return this.g==-2&&Ode(this,oOt(this.f,this.b)),this.g},p.e=iM,p.g=-2;var GIn=k(or,"BasicExtendedMetaData/EDataTypeExtendedMetaDataImpl",tf);A(1022,1,{},wNe),p.b=!1,p.c=!1;var jIn=k(or,"BasicExtendedMetaData/EPackageExtendedMetaDataImpl",1022);A(1025,1,{},q7e),p.c=-2,p.e=iM,p.f=iM;var $In=k(or,"BasicExtendedMetaData/EStructuralFeatureExtendedMetaDataImpl",1025);A(529,565,Ho,b9),p.pi=function(){return this.c},p.Rj=function(){return!1},p.zh=function(t,i){return i},p.c=0;var VIn=k(or,"EDataTypeEList",529),ePe=_r(or,"FeatureMap");A(90,529,{3:1,4:1,20:1,25:1,41:1,13:1,15:1,49:1,59:1,55:1,52:1,81:1,184:1,237:1,1630:1,64:1},ps),p.bd=function(t,i){X8t(this,t,h(i,75))},p.nc=function(t){return P8t(this,h(t,75))},p.nh=function(t){WAt(this,h(t,75))},p.ri=function(t,i){return iTt(this,h(t,75),i)},p.si=function(t,i){return Mme(this,h(t,75),i)},p.zh=function(t,i){return EGt(this,t,h(i,75))},p.hd=function(t,i){return S9t(this,t,h(i,75))},p.yi=function(t,i){return rTt(this,h(t,75),i)},p.zi=function(t,i){return F8e(this,h(t,75),i)},p.Ai=function(t,i,a){return mOt(this,h(t,75),h(i,75),a)},p.Ch=function(t,i){return Ite(this,t,h(i,75))},p.oc=function(t){var i,a,l,f,g,m,v,y,E;for(y=new w_(t._b()),l=t.tc();l.hc();)if(a=h(l.ic(),75),f=a.nj(),G0(this.e,f))(!f.xh()||!$Q(this,f,a.lc())&&!QA(y,a))&&$n(y,a);else{for(E=cl(this.e.mg(),f),i=h(this.g,124),g=!0,m=0;m=0;)if(i=t[this.c],this.k.Bk(i.nj()))return this.j=this.f?i:i.lc(),this.i=-2,!0;return this.i=-1,this.g=-1,!1};var qIn=k(or,"BasicFeatureMap/FeatureEIterator",377);A(601,377,Ch,QK),p.Xj=function(){return!0};var XIn=k(or,"BasicFeatureMap/ResolvingFeatureEIterator",601);A(871,444,xz,oFe),p.Uh=function(){return this};var YIn=k(or,"EContentsEList/1",871);A(872,444,xz,PNe),p.Xj=function(){return!1};var ZIn=k(or,"EContentsEList/2",872);A(870,260,Ez,aFe),p.Zj=function(t){},p.hc=function(){return!1},p.Cc=function(){return!1};var KIn=k(or,"EContentsEList/FeatureIteratorImpl/1",870);A(734,529,Ho,Rge),p.th=function(){this.a=!0},p.ui=function(){return this.a},p.ij=function(){var t;Pr(this),$u(this.e)?(t=this.a,this.a=!1,Li(this.e,new qu(this.e,2,this.c,t,!1))):this.a=!1},p.a=!1;var JIn=k(or,"EDataTypeEList/Unsettable",734);A(1566,529,Ho,mFe),p.xh=function(){return!0};var QIn=k(or,"EDataTypeUniqueEList",1566);A(1567,734,Ho,bFe),p.xh=function(){return!0};var e6n=k(or,"EDataTypeUniqueEList/Unsettable",1567);A(156,88,Ho,Nl),p.Qj=function(){return!0},p.zh=function(t,i){return Cx(this,t,h(i,51))};var t6n=k(or,"EObjectContainmentEList/Resolving",156);A(1026,493,Ho,gFe),p.Qj=function(){return!0},p.zh=function(t,i){return Cx(this,t,h(i,51))};var n6n=k(or,"EObjectContainmentEList/Unsettable/Resolving",1026);A(679,18,Ho,pme),p.th=function(){this.a=!0},p.ui=function(){return this.a},p.ij=function(){var t;Pr(this),$u(this.e)?(t=this.a,this.a=!1,Li(this.e,new qu(this.e,2,this.c,t,!1))):this.a=!1},p.a=!1;var i6n=k(or,"EObjectContainmentWithInverseEList/Unsettable",679);A(1044,679,Ho,v8e),p.Qj=function(){return!0},p.zh=function(t,i){return Cx(this,t,h(i,51))};var r6n=k(or,"EObjectContainmentWithInverseEList/Unsettable/Resolving",1044);A(675,450,Ho,Ige),p.th=function(){this.a=!0},p.ui=function(){return this.a},p.ij=function(){var t;Pr(this),$u(this.e)?(t=this.a,this.a=!1,Li(this.e,new qu(this.e,2,this.c,t,!1))):this.a=!1},p.a=!1;var s6n=k(or,"EObjectEList/Unsettable",675);A(376,450,Ho,qE),p.Qj=function(){return!0},p.zh=function(t,i){return Cx(this,t,h(i,51))};var o6n=k(or,"EObjectResolvingEList",376);A(1554,675,Ho,wFe),p.Qj=function(){return!0},p.zh=function(t,i){return Cx(this,t,h(i,51))};var a6n=k(or,"EObjectResolvingEList/Unsettable",1554);A(1495,1,{},Bm);var rut,c6n=k(or,"EObjectValidator",1495);A(496,450,Ho,D9),p.Lj=function(){return this.d},p.Mj=function(){return this.b},p.qi=function(){return!0},p.Pj=function(){return!0},p.b=0;var l6n=k(or,"EObjectWithInverseEList",496);A(1047,496,Ho,_8e),p.Oj=function(){return!0};var u6n=k(or,"EObjectWithInverseEList/ManyInverse",1047);A(572,496,Ho,AJ),p.th=function(){this.a=!0},p.ui=function(){return this.a},p.ij=function(){var t;Pr(this),$u(this.e)?(t=this.a,this.a=!1,Li(this.e,new qu(this.e,2,this.c,t,!1))):this.a=!1},p.a=!1;var f6n=k(or,"EObjectWithInverseEList/Unsettable",572);A(1046,572,Ho,y8e),p.Oj=function(){return!0};var h6n=k(or,"EObjectWithInverseEList/Unsettable/ManyInverse",1046);A(680,496,Ho,gme),p.Qj=function(){return!0},p.zh=function(t,i){return Cx(this,t,h(i,51))};var d6n=k(or,"EObjectWithInverseResolvingEList",680);A(33,680,Ho,an),p.Oj=function(){return!0};var p6n=k(or,"EObjectWithInverseResolvingEList/ManyInverse",33);A(681,572,Ho,mme),p.Qj=function(){return!0},p.zh=function(t,i){return Cx(this,t,h(i,51))};var g6n=k(or,"EObjectWithInverseResolvingEList/Unsettable",681);A(1045,681,Ho,x8e),p.Oj=function(){return!0};var m6n=k(or,"EObjectWithInverseResolvingEList/Unsettable/ManyInverse",1045);A(1027,565,Ho),p.rh=function(){return(this.b&1792)==0},p.th=function(){this.b|=1},p.Nj=function(){return(this.b&4)!=0},p.qi=function(){return(this.b&40)!=0},p.Oj=function(){return(this.b&16)!=0},p.Pj=function(){return(this.b&8)!=0},p.Qj=function(){return(this.b&Dw)!=0},p.Dj=function(){return(this.b&32)!=0},p.Rj=function(){return(this.b&tf)!=0},p.Li=function(t){return this.d?cze(this.d,t):this.nj().jj().Li(t)},p.ui=function(){return this.b&2?(this.b&1)!=0:this.i!=0},p.xh=function(){return(this.b&128)!=0},p.ij=function(){var t;Pr(this),this.b&2&&($u(this.e)?(t=(this.b&1)!=0,this.b&=-2,Dn(this,new qu(this.e,2,br(this.e.mg(),this.nj()),t,!1))):this.b&=-2)},p.Bh=function(){return(this.b&1536)==0},p.b=0;var b6n=k(or,"EcoreEList/Generic",1027);A(1028,1027,Ho,GUe),p.nj=function(){return this.a};var w6n=k(or,"EcoreEList/Dynamic",1028);A(678,55,Ih,_C),p.Fh=function(t){return zI(this.a.a,t)};var v6n=k(or,"EcoreEMap/1",678);A(677,88,Ho,o1e),p.sh=function(t,i){n7(this.b,h(i,134))},p.uh=function(t,i){W$e(this.b)},p.vh=function(t,i){Yee(this.b,h(i,134))},p.wh=function(t,i,a){Yee(this.b,h(a,134)),Be(a)===Be(i)&&h(a,134).jh(ISt(h(i,134).kc())),n7(this.b,h(i,134))};var _6n=k(or,"EcoreEMap/DelegateEObjectContainmentEList",677);A(1042,143,Nxe,Jje);var y6n=k(or,"EcoreEMap/Unsettable",1042);A(1043,677,Ho,E8e),p.th=function(){this.a=!0},p.ui=function(){return this.a},p.ij=function(){var t;Pr(this),$u(this.e)?(t=this.a,this.a=!1,Li(this.e,new qu(this.e,2,this.c,t,!1))):this.a=!1},p.a=!1;var x6n=k(or,"EcoreEMap/Unsettable/UnsettableDelegateEObjectContainmentEList",1043);A(682,1,ys,lze),p.gc=function(t){Ss(this,t)},p.hc=function(){return UWe(this)},p.ic=function(){var t;return UWe(this),t=this.b,this.b=null,t},p.jc=function(){this.a.jc()};var E6n=k(or,"EcoreUtil/ProperContentIterator",682);A(1496,1495,{},YX);var sut,S6n=k(or,"EcoreValidator",1496),out,M6n=_r(or,"FeatureMapUtil/Validator");A(1095,1,{1632:1},mX),p.Bk=function(t){return!0};var T6n=k(or,"FeatureMapUtil/1",1095);A(692,1,{1632:1},B_e),p.Bk=function(t){var i;return this.c==t?!0:(i=mt(Ii(this.a,t)),i==null?OUt(this,t)?(Qze(this.a,t,(vt(),oM)),!0):(Qze(this.a,t,(vt(),Z0)),!1):i==(vt(),oM))},p.e=!1;var Oae,C6n=k(or,"FeatureMapUtil/BasicValidator",692);A(693,44,Fx,Age);var A6n=k(or,"FeatureMapUtil/BasicValidator/Cache",693);A(455,41,{20:1,25:1,41:1,13:1,15:1,52:1,81:1,64:1},qR),p.bd=function(t,i){qYe(this.c,this.b,t,i)},p.nc=function(t){return l7t(this.c,this.b,t)},p.oc=function(t){return ZC(this,t)},p.xj=function(t,i){return a_e(this.c,this.b,t,i)},p.Dh=function(t){return D7(this.c,this.b,t,!1)},p.oh=function(){return $Ne(this.c,this.b)},p.ph=function(){return TSt(this.c,this.b)},p.qh=function(t){return ikt(this.c,this.b,t)},p.yj=function(t,i){return i8e(this,t,i)},p.Pb=function(){xe(this)},p.pc=function(t){return $Q(this.c,this.b,t)},p.qc=function(t){return zRt(this.c,this.b,t)},p.cd=function(t){return D7(this.c,this.b,t,!0)},p.hj=function(t){return this},p.dd=function(t){return dkt(this.c,this.b,t)},p.Wb=function(){return z8(this)},p.ui=function(){return!o6(this.c,this.b)},p.tc=function(){return vRt(this.c,this.b)},p.ed=function(){return _Rt(this.c,this.b)},p.fd=function(t){return H6t(this.c,this.b,t)},p.gd=function(t){return qqe(this.c,this.b,t)},p.vc=function(t){return QUt(this.c,this.b,t)},p.hd=function(t,i){return QZe(this.c,this.b,t,i)},p.Gc=function(t){g7(this.c,this.b),ZC(this,h(t,15))},p._b=function(){return m6t(this.c,this.b)},p.yc=function(){return P4t(this.c,this.b)},p.zc=function(t){return pkt(this.c,this.b,t)},p.Ib=function(){var t,i;for(i=new Tp,i.a+="[",t=$Ne(this.c,this.b);Oee(t);)ho(i,YC(e7(t))),Oee(t)&&(i.a+=Ca);return i.a+="]",i.a},p.ij=function(){g7(this.c,this.b)};var P6n=k(or,"FeatureMapUtil/FeatureEList",455);A(575,32,o5,kQ),p.Mh=function(t){return UA(this,t)},p.Rh=function(t){var i,a,l,f,g,m,v;switch(this.d){case 1:case 2:{if(g=t.Oh(),Be(g)===Be(this.c)&&UA(this,null)==t.Mh(null))return this.g=t.Nh(),t.Lh()==1&&(this.d=1),!0;break}case 3:{switch(f=t.Lh(),f){case 3:{if(g=t.Oh(),Be(g)===Be(this.c)&&UA(this,null)==t.Mh(null))return this.d=5,i=new w_(2),$n(i,this.g),$n(i,t.Nh()),this.g=i,!0;break}}break}case 5:{switch(f=t.Lh(),f){case 3:{if(g=t.Oh(),Be(g)===Be(this.c)&&UA(this,null)==t.Mh(null))return a=h(this.g,13),a.nc(t.Nh()),!0;break}}break}case 4:{switch(f=t.Lh(),f){case 3:{if(g=t.Oh(),Be(g)===Be(this.c)&&UA(this,null)==t.Mh(null))return this.d=1,this.g=t.Nh(),!0;break}case 4:{if(g=t.Oh(),Be(g)===Be(this.c)&&UA(this,null)==t.Mh(null))return this.d=6,v=new w_(2),$n(v,this.n),$n(v,t.Ph()),this.n=v,m=X(q(In,1),si,22,15,[this.o,t.Qh()]),this.g=m,!0;break}}break}case 6:{switch(f=t.Lh(),f){case 4:{if(g=t.Oh(),Be(g)===Be(this.c)&&UA(this,null)==t.Mh(null))return a=h(this.n,13),a.nc(t.Ph()),m=h(this.g,37),l=le(In,si,22,m.length+1,15,1),vc(m,0,l,0,m.length),l[m.length]=t.Qh(),this.g=l,!0;break}}break}}return!1};var L6n=k(or,"FeatureMapUtil/FeatureENotificationImpl",575);A(501,455,{20:1,25:1,41:1,13:1,15:1,52:1,81:1,184:1,237:1,1630:1,64:1},y9),p.pk=function(t,i,a){return a_e(this.c,t,i,a)},p.qk=function(t,i,a){return E_e(this.c,t,i,a)},p.rk=function(){return this},p.sk=function(t,i){return D6(this.c,t,i)},p.tk=function(t){return h(D7(this.c,this.b,t,!1),75).nj()},p.uk=function(t){return h(D7(this.c,this.b,t,!1),75).lc()},p.vk=function(){return this.a},p.wk=function(t){return!o6(this.c,t)},p.xk=function(t,i){Sne(this.c,t,i)},p.yk=function(t){return a$e(this.c,t)};var k6n=k(or,"FeatureMapUtil/FeatureFeatureMap",501);A(1094,1,{81:1},yNe),p.hj=function(t){return D7(this.b,this.a,-1,t)},p.ui=function(){return!o6(this.b,this.a)},p.Gc=function(t){Sne(this.b,this.a,t)},p.ij=function(){g7(this.b,this.a)};var R6n=k(or,"FeatureMapUtil/FeatureValue",1094),_3,Nae,Fae,y3,aut,yD=_r(kz,"AnyType");A(603,54,Zd,mK);var I6n=k(kz,"InvalidDatatypeValueException",603),zj=_r(kz,Ztt),xD=_r(kz,Ktt),tPe=_r(kz,Jtt),cut,ma,nPe,sv,lut,uut,fut,hut,dut,put,gut,mut,but,wut,vut,CM,_ut,AM,ED,yut,Iy,Gj,jj,xut,SD,MD;A(735,463,{95:1,91:1,87:1,51:1,42:1,92:1,746:1},upe),p.ug=function(t,i,a){switch(t){case 0:return a?(!this.c&&(this.c=new ps(this,0)),this.c):(!this.c&&(this.c=new ps(this,0)),this.c.b);case 1:return a?(!this.c&&(this.c=new ps(this,0)),h($c(this.c,(lr(),sv)),184)):(!this.c&&(this.c=new ps(this,0)),h(h($c(this.c,(lr(),sv)),184),237)).vk();case 2:return a?(!this.b&&(this.b=new ps(this,2)),this.b):(!this.b&&(this.b=new ps(this,2)),this.b.b)}return jl(this,t-jn(this.Rg()),Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():this.Rg(),t),i,a)},p.Dg=function(t,i,a){var l;switch(i){case 0:return!this.c&&(this.c=new ps(this,0)),k6(this.c,t,a);case 1:return(!this.c&&(this.c=new ps(this,0)),h(h($c(this.c,(lr(),sv)),184),64)).yj(t,a);case 2:return!this.b&&(this.b=new ps(this,2)),k6(this.b,t,a)}return l=h(Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():this.Rg(),i),61),l.aj().ej(this,B0e(this),i-jn(this.Rg()),t,a)},p.Fg=function(t){switch(t){case 0:return!!this.c&&this.c.i!=0;case 1:return!(!this.c&&(this.c=new ps(this,0)),h($c(this.c,(lr(),sv)),184)).Wb();case 2:return!!this.b&&this.b.i!=0}return zl(this,t-jn(this.Rg()),Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():this.Rg(),t))},p.Mg=function(t,i){switch(t){case 0:!this.c&&(this.c=new ps(this,0)),gI(this.c,i);return;case 1:(!this.c&&(this.c=new ps(this,0)),h(h($c(this.c,(lr(),sv)),184),237)).Gc(i);return;case 2:!this.b&&(this.b=new ps(this,2)),gI(this.b,i);return}Wl(this,t-jn(this.Rg()),Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():this.Rg(),t),i)},p.Rg=function(){return lr(),nPe},p.Ib=function(){var t;return this.j&4?Ku(this):(t=new su(Ku(this)),t.a+=" (mixed: ",OC(t,this.c),t.a+=", anyAttribute: ",OC(t,this.b),t.a+=")",t.a)};var D6n=k($r,"AnyTypeImpl",735);A(604,463,{95:1,91:1,87:1,51:1,42:1,92:1,1707:1,604:1},bX),p.ug=function(t,i,a){switch(t){case 0:return this.a;case 1:return this.b}return jl(this,t-jn((lr(),CM)),Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():CM,t),i,a)},p.Fg=function(t){switch(t){case 0:return this.a!=null;case 1:return this.b!=null}return zl(this,t-jn((lr(),CM)),Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():CM,t))},p.Mg=function(t,i){switch(t){case 0:jde(this,ti(i));return;case 1:Vde(this,ti(i));return}Wl(this,t-jn((lr(),CM)),Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():CM,t),i)},p.Rg=function(){return lr(),CM},p.Ib=function(){var t;return this.j&4?Ku(this):(t=new su(Ku(this)),t.a+=" (data: ",ho(t,this.a),t.a+=", target: ",ho(t,this.b),t.a+=")",t.a)},p.a=null,p.b=null;var B6n=k($r,"ProcessingInstructionImpl",604);A(605,735,{95:1,91:1,87:1,51:1,42:1,92:1,746:1,1708:1,605:1},CDe),p.ug=function(t,i,a){switch(t){case 0:return a?(!this.c&&(this.c=new ps(this,0)),this.c):(!this.c&&(this.c=new ps(this,0)),this.c.b);case 1:return a?(!this.c&&(this.c=new ps(this,0)),h($c(this.c,(lr(),sv)),184)):(!this.c&&(this.c=new ps(this,0)),h(h($c(this.c,(lr(),sv)),184),237)).vk();case 2:return a?(!this.b&&(this.b=new ps(this,2)),this.b):(!this.b&&(this.b=new ps(this,2)),this.b.b);case 3:return!this.c&&(this.c=new ps(this,0)),ti(D6(this.c,(lr(),ED),!0));case 4:return bme(this.a,(!this.c&&(this.c=new ps(this,0)),ti(D6(this.c,(lr(),ED),!0))));case 5:return this.a}return jl(this,t-jn((lr(),AM)),Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():AM,t),i,a)},p.Fg=function(t){switch(t){case 0:return!!this.c&&this.c.i!=0;case 1:return!(!this.c&&(this.c=new ps(this,0)),h($c(this.c,(lr(),sv)),184)).Wb();case 2:return!!this.b&&this.b.i!=0;case 3:return!this.c&&(this.c=new ps(this,0)),ti(D6(this.c,(lr(),ED),!0))!=null;case 4:return bme(this.a,(!this.c&&(this.c=new ps(this,0)),ti(D6(this.c,(lr(),ED),!0))))!=null;case 5:return!!this.a}return zl(this,t-jn((lr(),AM)),Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():AM,t))},p.Mg=function(t,i){switch(t){case 0:!this.c&&(this.c=new ps(this,0)),gI(this.c,i);return;case 1:(!this.c&&(this.c=new ps(this,0)),h(h($c(this.c,(lr(),sv)),184),237)).Gc(i);return;case 2:!this.b&&(this.b=new ps(this,2)),gI(this.b,i);return;case 3:X7e(this,ti(i));return;case 4:X7e(this,M8e(this.a,i));return;case 5:$de(this,h(i,140));return}Wl(this,t-jn((lr(),AM)),Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():AM,t),i)},p.Rg=function(){return lr(),AM};var O6n=k($r,"SimpleAnyTypeImpl",605);A(606,463,{95:1,91:1,87:1,51:1,42:1,92:1,1709:1,606:1},TDe),p.ug=function(t,i,a){switch(t){case 0:return a?(!this.a&&(this.a=new ps(this,0)),this.a):(!this.a&&(this.a=new ps(this,0)),this.a.b);case 1:return a?(!this.b&&(this.b=new il((yt(),zo),Aa,this,1)),this.b):(!this.b&&(this.b=new il((yt(),zo),Aa,this,1)),CI(this.b));case 2:return a?(!this.c&&(this.c=new il((yt(),zo),Aa,this,2)),this.c):(!this.c&&(this.c=new il((yt(),zo),Aa,this,2)),CI(this.c));case 3:return!this.a&&(this.a=new ps(this,0)),$c(this.a,(lr(),Gj));case 4:return!this.a&&(this.a=new ps(this,0)),$c(this.a,(lr(),jj));case 5:return!this.a&&(this.a=new ps(this,0)),$c(this.a,(lr(),SD));case 6:return!this.a&&(this.a=new ps(this,0)),$c(this.a,(lr(),MD))}return jl(this,t-jn((lr(),Iy)),Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():Iy,t),i,a)},p.Dg=function(t,i,a){var l;switch(i){case 0:return!this.a&&(this.a=new ps(this,0)),k6(this.a,t,a);case 1:return!this.b&&(this.b=new il((yt(),zo),Aa,this,1)),f9(this.b,t,a);case 2:return!this.c&&(this.c=new il((yt(),zo),Aa,this,2)),f9(this.c,t,a);case 5:return!this.a&&(this.a=new ps(this,0)),i8e($c(this.a,(lr(),SD)),t,a)}return l=h(Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():(lr(),Iy),i),61),l.aj().ej(this,B0e(this),i-jn((lr(),Iy)),t,a)},p.Fg=function(t){switch(t){case 0:return!!this.a&&this.a.i!=0;case 1:return!!this.b&&this.b.f!=0;case 2:return!!this.c&&this.c.f!=0;case 3:return!this.a&&(this.a=new ps(this,0)),!z8($c(this.a,(lr(),Gj)));case 4:return!this.a&&(this.a=new ps(this,0)),!z8($c(this.a,(lr(),jj)));case 5:return!this.a&&(this.a=new ps(this,0)),!z8($c(this.a,(lr(),SD)));case 6:return!this.a&&(this.a=new ps(this,0)),!z8($c(this.a,(lr(),MD)))}return zl(this,t-jn((lr(),Iy)),Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():Iy,t))},p.Mg=function(t,i){switch(t){case 0:!this.a&&(this.a=new ps(this,0)),gI(this.a,i);return;case 1:!this.b&&(this.b=new il((yt(),zo),Aa,this,1)),TU(this.b,i);return;case 2:!this.c&&(this.c=new il((yt(),zo),Aa,this,2)),TU(this.c,i);return;case 3:!this.a&&(this.a=new ps(this,0)),xe($c(this.a,(lr(),Gj))),!this.a&&(this.a=new ps(this,0)),ZC($c(this.a,Gj),h(i,13));return;case 4:!this.a&&(this.a=new ps(this,0)),xe($c(this.a,(lr(),jj))),!this.a&&(this.a=new ps(this,0)),ZC($c(this.a,jj),h(i,13));return;case 5:!this.a&&(this.a=new ps(this,0)),xe($c(this.a,(lr(),SD))),!this.a&&(this.a=new ps(this,0)),ZC($c(this.a,SD),h(i,13));return;case 6:!this.a&&(this.a=new ps(this,0)),xe($c(this.a,(lr(),MD))),!this.a&&(this.a=new ps(this,0)),ZC($c(this.a,MD),h(i,13));return}Wl(this,t-jn((lr(),Iy)),Wt(this.j&2?(!this.k&&(this.k=new mh),this.k).pj():Iy,t),i)},p.Rg=function(){return lr(),Iy},p.Ib=function(){var t;return this.j&4?Ku(this):(t=new su(Ku(this)),t.a+=" (mixed: ",OC(t,this.a),t.a+=")",t.a)};var N6n=k($r,"XMLTypeDocumentRootImpl",606);A(1626,638,{95:1,91:1,87:1,430:1,139:1,51:1,103:1,42:1,92:1,142:1,107:1,108:1,1710:1},tC),p.Zg=function(t,i){switch(t.Ni()){case 7:case 8:case 9:case 10:case 16:case 22:case 23:case 24:case 25:case 26:case 32:case 33:case 34:case 36:case 37:case 44:case 45:case 50:case 51:case 53:case 55:case 56:case 57:case 58:case 60:case 61:case 4:return i==null?null:Ga(i);case 19:case 28:case 29:case 35:case 38:case 39:case 41:case 46:case 52:case 54:case 5:return ti(i);case 6:return LMt(h(i,173));case 12:case 47:case 49:case 11:return OKe(this,t,i);case 13:return i==null?null:azt(h(i,216));case 15:case 14:return i==null?null:OAt(ce(Xe(i)));case 17:return lqe((lr(),i));case 18:return lqe(i);case 21:case 20:return i==null?null:NAt(h(i,126).a);case 27:return kMt(h(i,173));case 30:return RHe((lr(),h(i,15)));case 31:return RHe(h(i,15));case 40:return _Mt((lr(),i));case 42:return uqe((lr(),i));case 43:return uqe(i);case 59:case 48:return vMt((lr(),i));default:throw Y(new un(eM+t.be()+X0))}},p.$g=function(t){var i,a,l,f,g;switch(t.G==-1&&(t.G=(a=$l(t),a?$p(a.bh(),t):-1)),t.G){case 0:return i=new upe,i;case 1:return l=new bX,l;case 2:return f=new CDe,f;case 3:return g=new TDe,g;default:throw Y(new un(bre+t.zb+X0))}},p._g=function(t,i){var a,l,f,g,m,v,y,E,C,R,B,N,W,V,ee,ie;switch(t.Ni()){case 5:case 52:case 4:return i;case 6:return H5t(i);case 8:case 7:return i==null?null:kBt(i);case 9:return i==null?null:LI(Sl((l=Ba(i,!0),l.length>0&&l.charCodeAt(0)==43?l.substr(1,l.length-1):l),-128,127)<<24>>24);case 10:return i==null?null:LI(Sl((f=Ba(i,!0),f.length>0&&f.charCodeAt(0)==43?f.substr(1,f.length-1):f),-128,127)<<24>>24);case 11:return ti(j0(this,(lr(),fut),i));case 12:return ti(j0(this,(lr(),hut),i));case 13:return i==null?null:new mpe(Ba(i,!0));case 15:case 14:return i8t(i);case 16:return ti(j0(this,(lr(),dut),i));case 17:return HWe((lr(),i));case 18:return HWe(i);case 28:case 29:case 35:case 38:case 39:case 41:case 54:case 19:return Ba(i,!0);case 21:case 20:return p8t(i);case 22:return ti(j0(this,(lr(),put),i));case 23:return ti(j0(this,(lr(),gut),i));case 24:return ti(j0(this,(lr(),mut),i));case 25:return ti(j0(this,(lr(),but),i));case 26:return ti(j0(this,(lr(),wut),i));case 27:return L5t(i);case 30:return qWe((lr(),i));case 31:return qWe(i);case 32:return i==null?null:He(Sl((C=Ba(i,!0),C.length>0&&C.charCodeAt(0)==43?C.substr(1,C.length-1):C),zs,zi));case 33:return i==null?null:new Tg((R=Ba(i,!0),R.length>0&&R.charCodeAt(0)==43?R.substr(1,R.length-1):R));case 34:return i==null?null:He(Sl((B=Ba(i,!0),B.length>0&&B.charCodeAt(0)==43?B.substr(1,B.length-1):B),zs,zi));case 36:return i==null?null:n1(F7((N=Ba(i,!0),N.length>0&&N.charCodeAt(0)==43?N.substr(1,N.length-1):N)));case 37:return i==null?null:n1(F7((W=Ba(i,!0),W.length>0&&W.charCodeAt(0)==43?W.substr(1,W.length-1):W)));case 40:return P6t((lr(),i));case 42:return XWe((lr(),i));case 43:return XWe(i);case 44:return i==null?null:new Tg((V=Ba(i,!0),V.length>0&&V.charCodeAt(0)==43?V.substr(1,V.length-1):V));case 45:return i==null?null:new Tg((ee=Ba(i,!0),ee.length>0&&ee.charCodeAt(0)==43?ee.substr(1,ee.length-1):ee));case 46:return Ba(i,!1);case 47:return ti(j0(this,(lr(),vut),i));case 59:case 48:return A6t((lr(),i));case 49:return ti(j0(this,(lr(),_ut),i));case 50:return i==null?null:xS(Sl((ie=Ba(i,!0),ie.length>0&&ie.charCodeAt(0)==43?ie.substr(1,ie.length-1):ie),Cz,32767)<<16>>16);case 51:return i==null?null:xS(Sl((g=Ba(i,!0),g.length>0&&g.charCodeAt(0)==43?g.substr(1,g.length-1):g),Cz,32767)<<16>>16);case 53:return ti(j0(this,(lr(),yut),i));case 55:return i==null?null:xS(Sl((m=Ba(i,!0),m.length>0&&m.charCodeAt(0)==43?m.substr(1,m.length-1):m),Cz,32767)<<16>>16);case 56:return i==null?null:xS(Sl((v=Ba(i,!0),v.length>0&&v.charCodeAt(0)==43?v.substr(1,v.length-1):v),Cz,32767)<<16>>16);case 57:return i==null?null:n1(F7((y=Ba(i,!0),y.length>0&&y.charCodeAt(0)==43?y.substr(1,y.length-1):y)));case 58:return i==null?null:n1(F7((E=Ba(i,!0),E.length>0&&E.charCodeAt(0)==43?E.substr(1,E.length-1):E)));case 60:return i==null?null:He(Sl((a=Ba(i,!0),a.length>0&&a.charCodeAt(0)==43?a.substr(1,a.length-1):a),zs,zi));case 61:return i==null?null:He(Sl(Ba(i,!0),zs,zi));default:throw Y(new un(eM+t.be()+X0))}};var Eut,iPe,Sut,rPe,F6n=k($r,"XMLTypeFactoryImpl",1626);A(530,248,{95:1,91:1,87:1,139:1,174:1,51:1,207:1,103:1,42:1,92:1,142:1,248:1,107:1,108:1,613:1,1639:1,530:1},mUe),p.N=!1,p.O=!1;var Mut=!1,U6n=k($r,"XMLTypePackageImpl",530);A(1569,1,{743:1},k2),p.mj=function(){return p_e(),Dut};var z6n=k($r,"XMLTypePackageImpl/1",1569);A(1578,1,li,jN),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var G6n=k($r,"XMLTypePackageImpl/10",1578);A(1579,1,li,$N),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var j6n=k($r,"XMLTypePackageImpl/11",1579);A(1580,1,li,wX),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var $6n=k($r,"XMLTypePackageImpl/12",1580);A(1581,1,li,VN),p.Li=function(t){return aw(t)},p.Mi=function(t){return le(Eo,be,315,t,7,1)};var V6n=k($r,"XMLTypePackageImpl/13",1581);A(1582,1,li,R2),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var W6n=k($r,"XMLTypePackageImpl/14",1582);A(1583,1,li,_E),p.Li=function(t){return re(t,15)},p.Mi=function(t){return le(yu,Lw,15,t,0,1)};var H6n=k($r,"XMLTypePackageImpl/15",1583);A(1584,1,li,vX),p.Li=function(t){return re(t,15)},p.Mi=function(t){return le(yu,Lw,15,t,0,1)};var q6n=k($r,"XMLTypePackageImpl/16",1584);A(1585,1,li,WN),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var X6n=k($r,"XMLTypePackageImpl/17",1585);A(1586,1,li,HN),p.Li=function(t){return re(t,126)},p.Mi=function(t){return le(aM,be,126,t,0,1)};var Y6n=k($r,"XMLTypePackageImpl/18",1586);A(1587,1,li,nC),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var Z6n=k($r,"XMLTypePackageImpl/19",1587);A(1570,1,li,qN),p.Li=function(t){return re(t,746)},p.Mi=function(t){return le(yD,et,746,t,0,1)};var K6n=k($r,"XMLTypePackageImpl/2",1570);A(1588,1,li,iC),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var J6n=k($r,"XMLTypePackageImpl/20",1588);A(1589,1,li,Jk),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var Q6n=k($r,"XMLTypePackageImpl/21",1589);A(1590,1,li,rC),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var e5n=k($r,"XMLTypePackageImpl/22",1590);A(1591,1,li,_X),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var t5n=k($r,"XMLTypePackageImpl/23",1591);A(1592,1,li,XN),p.Li=function(t){return re(t,173)},p.Mi=function(t){return le(Mc,be,173,t,0,2)};var n5n=k($r,"XMLTypePackageImpl/24",1592);A(1593,1,li,sC),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var i5n=k($r,"XMLTypePackageImpl/25",1593);A(1594,1,li,YN),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var r5n=k($r,"XMLTypePackageImpl/26",1594);A(1595,1,li,Qk),p.Li=function(t){return re(t,15)},p.Mi=function(t){return le(yu,Lw,15,t,0,1)};var s5n=k($r,"XMLTypePackageImpl/27",1595);A(1596,1,li,yX),p.Li=function(t){return re(t,15)},p.Mi=function(t){return le(yu,Lw,15,t,0,1)};var o5n=k($r,"XMLTypePackageImpl/28",1596);A(1597,1,li,ZN),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var a5n=k($r,"XMLTypePackageImpl/29",1597);A(1571,1,li,r0),p.Li=function(t){return re(t,604)},p.Mi=function(t){return le(zj,et,1707,t,0,1)};var c5n=k($r,"XMLTypePackageImpl/3",1571);A(1598,1,li,KN),p.Li=function(t){return re(t,21)},p.Mi=function(t){return le(Po,be,21,t,0,1)};var l5n=k($r,"XMLTypePackageImpl/30",1598);A(1599,1,li,JN),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var u5n=k($r,"XMLTypePackageImpl/31",1599);A(1600,1,li,xX),p.Li=function(t){return re(t,149)},p.Mi=function(t){return le(K0,be,149,t,0,1)};var f5n=k($r,"XMLTypePackageImpl/32",1600);A(1601,1,li,QN),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var h5n=k($r,"XMLTypePackageImpl/33",1601);A(1602,1,li,EX),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var d5n=k($r,"XMLTypePackageImpl/34",1602);A(1603,1,li,SX),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var p5n=k($r,"XMLTypePackageImpl/35",1603);A(1604,1,li,s0),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var g5n=k($r,"XMLTypePackageImpl/36",1604);A(1605,1,li,eR),p.Li=function(t){return re(t,15)},p.Mi=function(t){return le(yu,Lw,15,t,0,1)};var m5n=k($r,"XMLTypePackageImpl/37",1605);A(1606,1,li,tR),p.Li=function(t){return re(t,15)},p.Mi=function(t){return le(yu,Lw,15,t,0,1)};var b5n=k($r,"XMLTypePackageImpl/38",1606);A(1607,1,li,nR),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var w5n=k($r,"XMLTypePackageImpl/39",1607);A(1572,1,li,oC),p.Li=function(t){return re(t,605)},p.Mi=function(t){return le(xD,et,1708,t,0,1)};var v5n=k($r,"XMLTypePackageImpl/4",1572);A(1608,1,li,I2),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var _5n=k($r,"XMLTypePackageImpl/40",1608);A(1609,1,li,ns),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var y5n=k($r,"XMLTypePackageImpl/41",1609);A(1610,1,li,aC),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var x5n=k($r,"XMLTypePackageImpl/42",1610);A(1611,1,li,iR),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var E5n=k($r,"XMLTypePackageImpl/43",1611);A(1612,1,li,Uv),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var S5n=k($r,"XMLTypePackageImpl/44",1612);A(1613,1,li,MX),p.Li=function(t){return re(t,168)},p.Mi=function(t){return le(J0,be,168,t,0,1)};var M5n=k($r,"XMLTypePackageImpl/45",1613);A(1614,1,li,rR),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var T5n=k($r,"XMLTypePackageImpl/46",1614);A(1615,1,li,eF),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var C5n=k($r,"XMLTypePackageImpl/47",1615);A(1616,1,li,$f),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var A5n=k($r,"XMLTypePackageImpl/48",1616);A(1617,1,li,TX),p.Li=function(t){return re(t,168)},p.Mi=function(t){return le(J0,be,168,t,0,1)};var P5n=k($r,"XMLTypePackageImpl/49",1617);A(1573,1,li,CX),p.Li=function(t){return re(t,606)},p.Mi=function(t){return le(tPe,et,1709,t,0,1)};var L5n=k($r,"XMLTypePackageImpl/5",1573);A(1618,1,li,tF),p.Li=function(t){return re(t,149)},p.Mi=function(t){return le(K0,be,149,t,0,1)};var k5n=k($r,"XMLTypePackageImpl/50",1618);A(1619,1,li,AX),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var R5n=k($r,"XMLTypePackageImpl/51",1619);A(1620,1,li,nF),p.Li=function(t){return re(t,21)},p.Mi=function(t){return le(Po,be,21,t,0,1)};var I5n=k($r,"XMLTypePackageImpl/52",1620);A(1574,1,li,PX),p.Li=function(t){return ws(t)},p.Mi=function(t){return le(Se,be,2,t,6,1)};var D5n=k($r,"XMLTypePackageImpl/6",1574);A(1575,1,li,LX),p.Li=function(t){return re(t,173)},p.Mi=function(t){return le(Mc,be,173,t,0,2)};var B5n=k($r,"XMLTypePackageImpl/7",1575);A(1576,1,li,kX),p.Li=function(t){return ow(t)},p.Mi=function(t){return le(lo,be,434,t,8,1)};var O5n=k($r,"XMLTypePackageImpl/8",1576);A(1577,1,li,o0),p.Li=function(t){return re(t,192)},p.Mi=function(t){return le(qx,be,192,t,0,1)};var N5n=k($r,"XMLTypePackageImpl/9",1577),uh,tg,OL,$j,J;A(40,54,Zd,Wn);var F5n=k(Xp,"RegEx/ParseException",40);A(730,1,{},Vf),p.Ck=function(t){return ta*16)throw Y(new Wn(Zn((zn(),ltt))));a=a*16+f}while(!0);if(this.a!=125)throw Y(new Wn(Zn((zn(),utt))));if(a>rM)throw Y(new Wn(Zn((zn(),ftt))));t=a}else{if(f=0,this.c!=0||(f=r1(this.a))<0)throw Y(new Wn(Zn((zn(),qp))));if(a=f,wi(this),this.c!=0||(f=r1(this.a))<0)throw Y(new Wn(Zn((zn(),qp))));a=a*16+f,t=a}break;case 117:if(l=0,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Zn((zn(),qp))));if(i=l,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Zn((zn(),qp))));if(i=i*16+l,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Zn((zn(),qp))));if(i=i*16+l,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Zn((zn(),qp))));i=i*16+l,t=i;break;case 118:if(wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Zn((zn(),qp))));if(i=l,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Zn((zn(),qp))));if(i=i*16+l,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Zn((zn(),qp))));if(i=i*16+l,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Zn((zn(),qp))));if(i=i*16+l,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Zn((zn(),qp))));if(i=i*16+l,wi(this),this.c!=0||(l=r1(this.a))<0)throw Y(new Wn(Zn((zn(),qp))));if(i=i*16+l,i>rM)throw Y(new Wn(Zn((zn(),"parser.descappe.4"))));t=i;break;case 65:case 90:case 122:throw Y(new Wn(Zn((zn(),htt))))}return t},p.Ek=function(t){var i;switch(t){case 100:i=(this.e&32)==32?em("Nd",!0):(vi(),Vj);break;case 68:i=(this.e&32)==32?em("Nd",!1):(vi(),uPe);break;case 119:i=(this.e&32)==32?em("IsWord",!0):(vi(),kM);break;case 87:i=(this.e&32)==32?em("IsWord",!1):(vi(),hPe);break;case 115:i=(this.e&32)==32?em("IsSpace",!0):(vi(),x3);break;case 83:i=(this.e&32)==32?em("IsSpace",!1):(vi(),fPe);break;default:throw Y(new na(hnt+t.toString(16)))}return i},p.Fk=function(t){var i,a,l,f,g,m,v,y,E,C,R,B;for(this.b=1,wi(this),i=null,this.c==0&&this.a==94?(wi(this),t?C=(vi(),vi(),++Er,new _l(5)):(i=(vi(),vi(),++Er,new _l(4)),Da(i,0,rM),C=(++Er,new _l(4)))):C=(vi(),vi(),++Er,new _l(4)),f=!0;(B=this.c)!=1&&!(B==0&&this.a==93&&!f);){if(f=!1,a=this.a,l=!1,B==10)switch(a){case 100:case 68:case 119:case 87:case 115:case 83:Cw(C,this.Ek(a)),l=!0;break;case 105:case 73:case 99:case 67:a=this.Vk(C,a),a<0&&(l=!0);break;case 112:case 80:if(R=bve(this,a),!R)throw Y(new Wn(Zn((zn(),Pre))));Cw(C,R),l=!0;break;default:a=this.Dk()}else if(B==20){if(m=WE(this.i,58,this.d),m<0)throw Y(new Wn(Zn((zn(),kxe))));if(v=!0,po(this.i,this.d)==94&&(++this.d,v=!1),g=Xf(this.i,this.d,m),y=FGe(g,v,(this.e&512)==512),!y)throw Y(new Wn(Zn((zn(),rtt))));if(Cw(C,y),l=!0,m+1>=this.j||po(this.i,m+1)!=93)throw Y(new Wn(Zn((zn(),kxe))));this.d=m+2}if(wi(this),!l)if(this.c!=0||this.a!=45)Da(C,a,a);else{if(wi(this),(B=this.c)==1)throw Y(new Wn(Zn((zn(),vz))));B==0&&this.a==93?(Da(C,a,a),Da(C,45,45)):(E=this.a,B==10&&(E=this.Dk()),wi(this),Da(C,a,E))}(this.e&tf)==tf&&this.c==0&&this.a==44&&wi(this)}if(this.c==1)throw Y(new Wn(Zn((zn(),vz))));return i&&(mP(i,C),C=i),U_(C),gP(C),this.b=0,wi(this),C},p.Gk=function(){var t,i,a,l;for(a=this.Fk(!1);(l=this.c)!=7;)if(t=this.a,l==0&&(t==45||t==38)||l==4){if(wi(this),this.c!=9)throw Y(new Wn(Zn((zn(),ott))));if(i=this.Fk(!1),l==4)Cw(a,i);else if(t==45)mP(a,i);else if(t==38)RKe(a,i);else throw Y(new na("ASSERT"))}else throw Y(new Wn(Zn((zn(),att))));return wi(this),a},p.Hk=function(){var t,i;return t=this.a-48,i=(vi(),vi(),++Er,new _Q(12,null,t)),!this.g&&(this.g=new Zh),wn(this.g,new t8(t)),wi(this),i},p.Ik=function(){return wi(this),vi(),Aut},p.Jk=function(){return wi(this),vi(),Cut},p.Kk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Lk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Mk=function(){return wi(this),SIt()},p.Nk=function(){return wi(this),vi(),Lut},p.Ok=function(){return wi(this),vi(),Rut},p.Pk=function(){var t;if(this.d>=this.j||((t=po(this.i,this.d++))&65504)!=64)throw Y(new Wn(Zn((zn(),ttt))));return wi(this),vi(),vi(),++Er,new id(0,t-64)},p.Qk=function(){return wi(this),W7t()},p.Rk=function(){return wi(this),vi(),Iut},p.Sk=function(){var t;return t=(vi(),vi(),++Er,new id(0,105)),wi(this),t},p.Tk=function(){return wi(this),vi(),kut},p.Uk=function(){return wi(this),vi(),Put},p.Vk=function(t,i){return this.Dk()},p.Wk=function(){return wi(this),vi(),cPe},p.Xk=function(){var t,i,a,l,f;if(this.d+1>=this.j)throw Y(new Wn(Zn((zn(),Jet))));if(l=-1,i=null,t=po(this.i,this.d),49<=t&&t<=57){if(l=t-48,!this.g&&(this.g=new Zh),wn(this.g,new t8(l)),++this.d,po(this.i,this.d)!=41)throw Y(new Wn(Zn((zn(),w1))));++this.d}else switch(t==63&&--this.d,wi(this),i=N_e(this),i.e){case 20:case 21:case 22:case 23:break;case 8:if(this.c!=7)throw Y(new Wn(Zn((zn(),w1))));break;default:throw Y(new Wn(Zn((zn(),Qet))))}if(wi(this),f=B0(this),a=null,f.e==2){if(f.ol()!=2)throw Y(new Wn(Zn((zn(),ett))));a=f.kl(1),f=f.kl(0)}if(this.c!=7)throw Y(new Wn(Zn((zn(),w1))));return wi(this),vi(),vi(),++Er,new fje(l,i,f,a)},p.Yk=function(){return wi(this),vi(),lPe},p.Zk=function(){var t;if(wi(this),t=B9(24,B0(this)),this.c!=7)throw Y(new Wn(Zn((zn(),w1))));return wi(this),t},p.$k=function(){var t;if(wi(this),t=B9(20,B0(this)),this.c!=7)throw Y(new Wn(Zn((zn(),w1))));return wi(this),t},p._k=function(){var t;if(wi(this),t=B9(22,B0(this)),this.c!=7)throw Y(new Wn(Zn((zn(),w1))));return wi(this),t},p.al=function(){var t,i,a,l,f;for(t=0,a=0,i=-1;this.d=this.j)throw Y(new Wn(Zn((zn(),Pxe))));if(i==45){for(++this.d;this.d=this.j)throw Y(new Wn(Zn((zn(),Pxe))))}if(i==58){if(++this.d,wi(this),l=Q9e(B0(this),t,a),this.c!=7)throw Y(new Wn(Zn((zn(),w1))));wi(this)}else if(i==41)++this.d,wi(this),l=Q9e(B0(this),t,a);else throw Y(new Wn(Zn((zn(),Ket))));return l},p.bl=function(){var t;if(wi(this),t=B9(21,B0(this)),this.c!=7)throw Y(new Wn(Zn((zn(),w1))));return wi(this),t},p.cl=function(){var t;if(wi(this),t=B9(23,B0(this)),this.c!=7)throw Y(new Wn(Zn((zn(),w1))));return wi(this),t},p.dl=function(){var t,i;if(wi(this),t=this.f++,i=qJ(B0(this),t),this.c!=7)throw Y(new Wn(Zn((zn(),w1))));return wi(this),i},p.el=function(){var t;if(wi(this),t=qJ(B0(this),0),this.c!=7)throw Y(new Wn(Zn((zn(),w1))));return wi(this),t},p.fl=function(t){return wi(this),this.c==5?(wi(this),C9(t,(vi(),vi(),++Er,new pw(9,t)))):C9(t,(vi(),vi(),++Er,new pw(3,t)))},p.gl=function(t){var i;return wi(this),i=(vi(),vi(),++Er,new XC(2)),this.c==5?(wi(this),c1(i,FL),c1(i,t)):(c1(i,t),c1(i,FL)),i},p.hl=function(t){return wi(this),this.c==5?(wi(this),vi(),vi(),++Er,new pw(9,t)):(vi(),vi(),++Er,new pw(3,t))},p.a=0,p.b=0,p.c=0,p.d=0,p.e=0,p.f=1,p.g=null,p.j=0;var U5n=k(Xp,"RegEx/RegexParser",730);A(1564,730,{},kDe),p.Ck=function(t){return!1},p.Dk=function(){return Kve(this)},p.Ek=function(t){return FS(t)},p.Fk=function(t){return gJe(this)},p.Gk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Hk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Ik=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Jk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Kk=function(){return wi(this),FS(67)},p.Lk=function(){return wi(this),FS(73)},p.Mk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Nk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Ok=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Pk=function(){return wi(this),FS(99)},p.Qk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Rk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Sk=function(){return wi(this),FS(105)},p.Tk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Uk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Vk=function(t,i){return Cw(t,FS(i)),-1},p.Wk=function(){return wi(this),vi(),vi(),++Er,new id(0,94)},p.Xk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.Yk=function(){return wi(this),vi(),vi(),++Er,new id(0,36)},p.Zk=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.$k=function(){throw Y(new Wn(Zn((zn(),Yl))))},p._k=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.al=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.bl=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.cl=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.dl=function(){var t;if(wi(this),t=qJ(B0(this),0),this.c!=7)throw Y(new Wn(Zn((zn(),w1))));return wi(this),t},p.el=function(){throw Y(new Wn(Zn((zn(),Yl))))},p.fl=function(t){return wi(this),C9(t,(vi(),vi(),++Er,new pw(3,t)))},p.gl=function(t){var i;return wi(this),i=(vi(),vi(),++Er,new XC(2)),c1(i,t),c1(i,FL),i},p.hl=function(t){return wi(this),vi(),vi(),++Er,new pw(3,t)};var Dy=null,PM=null,z5n=k(Xp,"RegEx/ParserForXMLSchema",1564);A(112,1,sM,Rc),p.il=function(t){throw Y(new na("Not supported."))},p.jl=function(){return-1},p.kl=function(t){return null},p.ll=function(){return null},p.ml=function(t){},p.nl=function(t){},p.ol=function(){return 0},p.Ib=function(){return this.pl(0)},p.pl=function(t){return this.e==11?".":""},p.e=0;var sPe,LM,NL,Tut,oPe,ov=null,Vj,Uae=null,aPe,FL,zae=null,cPe,lPe,uPe,fPe,hPe,Cut,x3,Aut,Put,Lut,kut,kM,Rut,Iut,Er=0,LVt=k(Xp,"RegEx/Token",112);A(130,112,{3:1,130:1,112:1},_l),p.pl=function(t){var i,a,l;if(this.e==4)if(this==aPe)a=".";else if(this==Vj)a="\\d";else if(this==kM)a="\\w";else if(this==x3)a="\\s";else{for(l=new Tp,l.a+="[",i=0;i0&&(l.a+=","),this.b[i]===this.b[i+1]?ho(l,I6(this.b[i])):(ho(l,I6(this.b[i])),l.a+="-",ho(l,I6(this.b[i+1])));l.a+="]",a=l.a}else if(this==uPe)a="\\D";else if(this==hPe)a="\\W";else if(this==fPe)a="\\S";else{for(l=new Tp,l.a+="[^",i=0;i0&&(l.a+=","),this.b[i]===this.b[i+1]?ho(l,I6(this.b[i])):(ho(l,I6(this.b[i])),l.a+="-",ho(l,I6(this.b[i+1])));l.a+="]",a=l.a}return a},p.a=!1,p.c=!1;var G5n=k(Xp,"RegEx/RangeToken",130);A(528,1,{528:1},t8),p.a=0;var j5n=k(Xp,"RegEx/RegexParser/ReferencePosition",528);A(527,1,{3:1,527:1},nOe),p.Fb=function(t){var i;return t==null||!re(t,527)?!1:(i=h(t,527),dt(this.b,i.b)&&this.a==i.a)},p.Hb=function(){return Hg(this.b+"/"+Hve(this.a))},p.Ib=function(){return this.c.pl(this.a)},p.a=0;var $5n=k(Xp,"RegEx/RegularExpression",527);A(195,112,sM,id),p.jl=function(){return this.a},p.pl=function(t){var i,a;switch(this.e){case 0:switch(this.a){case 124:case 42:case 43:case 63:case 40:case 41:case 46:case 91:case 123:case 92:a="\\"+CJ(this.a&jr);break;case 12:a="\\f";break;case 10:a="\\n";break;case 13:a="\\r";break;case 9:a="\\t";break;case 27:a="\\e";break;default:this.a>=oo?(i="0"+(this.a>>>0).toString(16),a="\\v"+Xf(i,i.length-6,i.length)):a=""+CJ(this.a&jr)}break;case 8:this==cPe||this==lPe?a=""+CJ(this.a&jr):a="\\"+CJ(this.a&jr);break;default:a=null}return a},p.a=0;var V5n=k(Xp,"RegEx/Token/CharToken",195);A(283,112,sM,pw),p.kl=function(t){return this.a},p.ml=function(t){this.b=t},p.nl=function(t){this.c=t},p.ol=function(){return 1},p.pl=function(t){var i;if(this.e==3)if(this.c<0&&this.b<0)i=this.a.pl(t)+"*";else if(this.c==this.b)i=this.a.pl(t)+"{"+this.c+"}";else if(this.c>=0&&this.b>=0)i=this.a.pl(t)+"{"+this.c+","+this.b+"}";else if(this.c>=0&&this.b<0)i=this.a.pl(t)+"{"+this.c+",}";else throw Y(new na("Token#toString(): CLOSURE "+this.c+Ca+this.b));else if(this.c<0&&this.b<0)i=this.a.pl(t)+"*?";else if(this.c==this.b)i=this.a.pl(t)+"{"+this.c+"}?";else if(this.c>=0&&this.b>=0)i=this.a.pl(t)+"{"+this.c+","+this.b+"}?";else if(this.c>=0&&this.b<0)i=this.a.pl(t)+"{"+this.c+",}?";else throw Y(new na("Token#toString(): NONGREEDYCLOSURE "+this.c+Ca+this.b));return i},p.b=0,p.c=0;var W5n=k(Xp,"RegEx/Token/ClosureToken",283);A(731,112,sM,h1e),p.kl=function(t){return t==0?this.a:this.b},p.ol=function(){return 2},p.pl=function(t){var i;return this.b.e==3&&this.b.kl(0)==this.a?i=this.a.pl(t)+"+":this.b.e==9&&this.b.kl(0)==this.a?i=this.a.pl(t)+"+?":i=this.a.pl(t)+(""+this.b.pl(t)),i};var H5n=k(Xp,"RegEx/Token/ConcatToken",731);A(1562,112,sM,fje),p.kl=function(t){if(t==0)return this.d;if(t==1)return this.b;throw Y(new na("Internal Error: "+t))},p.ol=function(){return this.b?2:1},p.pl=function(t){var i;return this.c>0?i="(?("+this.c+")":this.a.e==8?i="(?("+this.a+")":i="(?"+this.a,this.b?i+=this.d+"|"+this.b+")":i+=this.d+")",i},p.c=0;var q5n=k(Xp,"RegEx/Token/ConditionToken",1562);A(1563,112,sM,L7e),p.kl=function(t){return this.b},p.ol=function(){return 1},p.pl=function(t){return"(?"+(this.a==0?"":Hve(this.a))+(this.c==0?"":Hve(this.c))+":"+this.b.pl(t)+")"},p.a=0,p.c=0;var X5n=k(Xp,"RegEx/Token/ModifierToken",1563);A(732,112,sM,_1e),p.kl=function(t){return this.a},p.ol=function(){return 1},p.pl=function(t){var i;switch(i=null,this.e){case 6:this.b==0?i="(?:"+this.a.pl(t)+")":i="("+this.a.pl(t)+")";break;case 20:i="(?="+this.a.pl(t)+")";break;case 21:i="(?!"+this.a.pl(t)+")";break;case 22:i="(?<="+this.a.pl(t)+")";break;case 23:i="(?"+this.a.pl(t)+")"}return i},p.b=0;var Y5n=k(Xp,"RegEx/Token/ParenToken",732);A(474,112,{3:1,112:1,474:1},_Q),p.ll=function(){return this.b},p.pl=function(t){return this.e==12?"\\"+this.a:KNt(this.b)},p.a=0;var Z5n=k(Xp,"RegEx/Token/StringToken",474);A(427,112,sM,XC),p.il=function(t){c1(this,t)},p.kl=function(t){return h(x0(this.a,t),112)},p.ol=function(){return this.a?this.a.a.c.length:0},p.pl=function(t){var i,a,l,f,g;if(this.e==1){if(this.a.a.c.length==2)i=h(x0(this.a,0),112),a=h(x0(this.a,1),112),a.e==3&&a.kl(0)==i?f=i.pl(t)+"+":a.e==9&&a.kl(0)==i?f=i.pl(t)+"+?":f=i.pl(t)+(""+a.pl(t));else{for(g=new Tp,l=0;l=this.c.b:this.a<=this.c.b},p.Cc=function(){return this.b>0},p.Dc=function(){return this.b},p.Fc=function(){return this.b-1},p.jc=function(){throw Y(new Cp(_nt))},p.a=0,p.b=0;var nDn=k(Zxe,"ExclusiveRange/RangeIterator",230),Zl=eS(yz,"C"),In=eS(OP,"I"),Ru=eS(jS,"Z"),R1=eS(NP,"J"),Mc=eS(IP,"B"),ks=eS(DP,"D"),av=eS(BP,"F"),By=eS(FP,"S"),kVt=_r("org.eclipse.elk.core.labels","ILabelManager"),dPe=_r(Gs,"DiagnosticChain"),pPe=_r(qtt,"ResourceSet"),gPe=k(Gs,"InvocationTargetException",null),But=(h8(),k4t),Out=Out=zBt;rRt(Wde),CRt("permProps",[[[Dz,Bz],[Oz,"gecko1_8"]],[[Dz,Bz],[Oz,"ie10"]],[[Dz,Bz],[Oz,"ie8"]],[[Dz,Bz],[Oz,"ie9"]],[[Dz,Bz],[Oz,"safari"]]]),Out(null,"elk",null)}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],3:[function(c,u,d){"use strict";function b(M,L){if(!(M instanceof L))throw new TypeError("Cannot call a class as a function")}function w(M,L){if(!M)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return L&&(typeof L=="object"||typeof L=="function")?L:M}function _(M,L){if(typeof L!="function"&&L!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof L);M.prototype=Object.create(L&&L.prototype,{constructor:{value:M,enumerable:!1,writable:!0,configurable:!0}}),L&&(Object.setPrototypeOf?Object.setPrototypeOf(M,L):M.__proto__=L)}var x=c("./elk-api.js").default,T=function(M){_(L,M);function L(){var I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};b(this,L);var D=Object.assign({},I),F=!1;try{c.resolve("webworker-threads"),F=!0}catch{}if(I.workerUrl)if(F){var O=c("webworker-threads"),z=O.Worker;D.workerFactory=function(te){return new z(te)}}else console.warn(`Web worker requested but 'webworker-threads' package not installed. Consider installing the package or pass your own 'workerFactory' to ELK's constructor. ... Falling back to non-web worker version. `);if(!D.workerFactory){var Z=c("./elk-worker.min.js"),H=Z.Worker;D.workerFactory=function(te){return new H(te)}}return w(this,(L.__proto__||Object.getPrototypeOf(L)).call(this,D))}return L}(x);Object.defineProperty(u.exports,"__esModule",{value:!0}),u.exports=T,T.default=T},{"./elk-api.js":1,"./elk-worker.min.js":2,"webworker-threads":8}],4:[function(c,u,d){(function(b,w){var _=c("fs"),x=c("path"),T=x.join,M=x.dirname,L=_.accessSync&&function(F){try{_.accessSync(F)}catch{return!1}return!0}||_.existsSync||x.existsSync,I={arrow:b.env.NODE_BINDINGS_ARROW||" \u2192 ",compiled:b.env.NODE_BINDINGS_COMPILED_DIR||"compiled",platform:b.platform,arch:b.arch,version:b.versions.node,bindings:"bindings.node",try:[["module_root","build","bindings"],["module_root","build","Debug","bindings"],["module_root","build","Release","bindings"],["module_root","out","Debug","bindings"],["module_root","Debug","bindings"],["module_root","out","Release","bindings"],["module_root","Release","bindings"],["module_root","build","default","bindings"],["module_root","compiled","version","platform","arch","bindings"]]};function D(F){typeof F=="string"?F={bindings:F}:F||(F={}),Object.keys(I).map(function(ne){ne in F||(F[ne]=I[ne])}),F.module_root||(F.module_root=d.getRoot(d.getFileName())),x.extname(F.bindings)!=".node"&&(F.bindings+=".node");for(var O=[],z=0,Z=F.try.length,H,te,oe;z",se.tagName="",se.state=Q.SCRIPT;return}ot(se,"onscript",se.script),se.script=""}var de=se.tags.length,it=se.tagName;se.strict||(it=it[se.looseCase]());for(var We=it;de--;){var En=se.tags[de];if(En.name!==We)cn(se,"Unexpected close tag");else break}if(de<0){cn(se,"Unmatched closing tag: "+se.tagName),se.textNode+="",se.state=Q.TEXT;return}se.tagName=it;for(var hr=se.tags.length;hr-- >de;){var qi=se.tag=se.tags.pop();se.tagName=se.tag.name,ot(se,"onclosetag",se.tagName);var Me={};for(var ve in qi.ns)Me[ve]=qi.ns[ve];var wt=se.tags[se.tags.length-1]||se;se.opt.xmlns&&qi.ns!==wt.ns&&Object.keys(qi.ns).forEach(function(gn){var vn=qi.ns[gn];ot(se,"onclosenamespace",{prefix:gn,uri:vn})})}de===0&&(se.closedRoot=!0),se.tagName=se.attribValue=se.attribName="",se.attribList.length=0,se.state=Q.TEXT}function $i(se){var de=se.entity,it=de.toLowerCase(),We,En="";return se.ENTITIES[de]?se.ENTITIES[de]:se.ENTITIES[it]?se.ENTITIES[it]:(de=it,de.charAt(0)==="#"&&(de.charAt(1)==="x"?(de=de.slice(2),We=parseInt(de,16),En=We.toString(16)):(de=de.slice(1),We=parseInt(de,10),En=We.toString(10))),de=de.replace(/^0+/,""),isNaN(We)||En.toLowerCase()!==de||We<0||We>1114111||!Tr(We)?(cn(se,"Invalid character entity"),"&"+se.entity+";"):String.fromCodePoint(We))}function Tr(se){return se===9||se===10||se===13||se>=32&&se<=55295||se>=57344&&se<=65533||se>=65536&&se<=1114111}function wr(se,de){de==="<"?(se.state=Q.OPEN_WAKA,se.startTagPosition=se.position):te(de)||(cn(se,"Non-whitespace before first tag."),se.textNode=de,se.state=Q.TEXT)}function Si(se,de){var it="";return de"?(ot(de,"onsgmldeclaration",de.sgmlDecl),de.sgmlDecl="",de.state=Q.TEXT):(oe(We)&&(de.state=Q.SGML_DECL_QUOTED),de.sgmlDecl+=We);continue;case Q.SGML_DECL_QUOTED:We===de.q&&(de.state=Q.SGML_DECL,de.q=""),de.sgmlDecl+=We;continue;case Q.DOCTYPE:We===">"?(de.state=Q.TEXT,ot(de,"ondoctype",de.doctype),de.doctype=!0):(de.doctype+=We,We==="["?de.state=Q.DOCTYPE_DTD:oe(We)&&(de.state=Q.DOCTYPE_QUOTED,de.q=We));continue;case Q.DOCTYPE_QUOTED:de.doctype+=We,We===de.q&&(de.q="",de.state=Q.DOCTYPE);continue;case Q.DOCTYPE_DTD:We==="]"?(de.doctype+=We,de.state=Q.DOCTYPE):We==="<"?(de.state=Q.OPEN_WAKA,de.startTagPosition=de.position):oe(We)?(de.doctype+=We,de.state=Q.DOCTYPE_DTD_QUOTED,de.q=We):de.doctype+=We;continue;case Q.DOCTYPE_DTD_QUOTED:de.doctype+=We,We===de.q&&(de.state=Q.DOCTYPE_DTD,de.q="");continue;case Q.COMMENT:We==="-"?de.state=Q.COMMENT_ENDING:de.comment+=We;continue;case Q.COMMENT_ENDING:We==="-"?(de.state=Q.COMMENT_ENDED,de.comment=jt(de.opt,de.comment),de.comment&&ot(de,"oncomment",de.comment),de.comment=""):(de.comment+="-"+We,de.state=Q.COMMENT);continue;case Q.COMMENT_ENDED:We!==">"?(cn(de,"Malformed comment"),de.comment+="--"+We,de.state=Q.COMMENT):de.doctype&&de.doctype!==!0?de.state=Q.DOCTYPE_DTD:de.state=Q.TEXT;continue;case Q.CDATA:for(var hr=it-1;We&&We!=="]";)We=Si(se,it++),We&&de.trackPosition&&(de.position++,We===` -`?(de.line++,de.column=0):de.column++);de.cdata+=se.substring(hr,it-1),We==="]"&&(de.state=Q.CDATA_ENDING);continue;case Q.CDATA_ENDING:We==="]"?de.state=Q.CDATA_ENDING_2:(de.cdata+="]"+We,de.state=Q.CDATA);continue;case Q.CDATA_ENDING_2:We===">"?(de.cdata&&ot(de,"oncdata",de.cdata),ot(de,"onclosecdata"),de.cdata="",de.state=Q.TEXT):We==="]"?de.cdata+="]":(de.cdata+="]]"+We,de.state=Q.CDATA);continue;case Q.PROC_INST:We==="?"?de.state=Q.PROC_INST_ENDING:te(We)?de.state=Q.PROC_INST_BODY:de.procInstName+=We;continue;case Q.PROC_INST_BODY:if(!de.procInstBody&&te(We))continue;We==="?"?de.state=Q.PROC_INST_ENDING:de.procInstBody+=We;continue;case Q.PROC_INST_ENDING:if(We===">"){let wt={name:de.procInstName,body:de.procInstBody};tt(de,wt),ot(de,"onprocessinginstruction",wt),de.procInstName=de.procInstBody="",de.state=Q.TEXT}else de.procInstBody+="?"+We,de.state=Q.PROC_INST_BODY;continue;case Q.OPEN_TAG:ue(z,We)?de.tagName+=We:(bi(de),We===">"?qn(de):We==="/"?de.state=Q.OPEN_TAG_SLASH:(te(We)||cn(de,"Invalid character in tag name"),de.state=Q.ATTRIB));continue;case Q.OPEN_TAG_SLASH:We===">"?(qn(de,!0),Yi(de)):(cn(de,"Forward-slash in opening tag not followed by >"),de.state=Q.ATTRIB);continue;case Q.ATTRIB:if(te(We))continue;We===">"?qn(de):We==="/"?de.state=Q.OPEN_TAG_SLASH:ue(O,We)?(de.attribName=We,de.attribValue="",de.state=Q.ATTRIB_NAME):cn(de,"Invalid attribute name");continue;case Q.ATTRIB_NAME:We==="="?de.state=Q.ATTRIB_VALUE:We===">"?(cn(de,"Attribute without value"),de.attribValue=de.attribName,pn(de),qn(de)):te(We)?de.state=Q.ATTRIB_NAME_SAW_WHITE:ue(z,We)?de.attribName+=We:cn(de,"Invalid attribute name");continue;case Q.ATTRIB_NAME_SAW_WHITE:if(We==="=")de.state=Q.ATTRIB_VALUE;else{if(te(We))continue;cn(de,"Attribute without value"),de.tag.attributes[de.attribName]="",de.attribValue="",ot(de,"onattribute",{name:de.attribName,value:""}),de.attribName="",We===">"?qn(de):ue(O,We)?(de.attribName=We,de.state=Q.ATTRIB_NAME):(cn(de,"Invalid attribute name"),de.state=Q.ATTRIB)}continue;case Q.ATTRIB_VALUE:if(te(We))continue;oe(We)?(de.q=We,de.state=Q.ATTRIB_VALUE_QUOTED):(de.opt.unquotedAttributeValues||en(de,"Unquoted attribute value"),de.state=Q.ATTRIB_VALUE_UNQUOTED,de.attribValue=We);continue;case Q.ATTRIB_VALUE_QUOTED:if(We!==de.q){We==="&"?de.state=Q.ATTRIB_VALUE_ENTITY_Q:de.attribValue+=We;continue}pn(de),de.q="",de.state=Q.ATTRIB_VALUE_CLOSED;continue;case Q.ATTRIB_VALUE_CLOSED:te(We)?de.state=Q.ATTRIB:We===">"?qn(de):We==="/"?de.state=Q.OPEN_TAG_SLASH:ue(O,We)?(cn(de,"No whitespace between attributes"),de.attribName=We,de.attribValue="",de.state=Q.ATTRIB_NAME):cn(de,"Invalid attribute name");continue;case Q.ATTRIB_VALUE_UNQUOTED:if(!ne(We)){We==="&"?de.state=Q.ATTRIB_VALUE_ENTITY_U:de.attribValue+=We;continue}pn(de),We===">"?qn(de):de.state=Q.ATTRIB;continue;case Q.CLOSE_TAG:if(de.tagName)We===">"?Yi(de):ue(z,We)?de.tagName+=We:de.script?(de.script+=""?Yi(de):cn(de,"Invalid characters in closing tag");continue;case Q.TEXT_ENTITY:case Q.ATTRIB_VALUE_ENTITY_Q:case Q.ATTRIB_VALUE_ENTITY_U:var qi,Me;switch(de.state){case Q.TEXT_ENTITY:qi=Q.TEXT,Me="textNode";break;case Q.ATTRIB_VALUE_ENTITY_Q:qi=Q.ATTRIB_VALUE_QUOTED,Me="attribValue";break;case Q.ATTRIB_VALUE_ENTITY_U:qi=Q.ATTRIB_VALUE_UNQUOTED,Me="attribValue";break}if(We===";"){var ve=$i(de);de.opt.unparsedEntities&&!Object.values(s.XML_ENTITIES).includes(ve)?((de.entityCount+=1)>de.opt.maxEntityCount&&en(de,"Parsed entity count exceeds max entity count"),(de.entityDepth+=1)>de.opt.maxEntityDepth&&en(de,"Parsed entity depth exceeds max entity depth"),de.entity="",de.state=qi,de.write(ve),de.entityDepth-=1):(de[Me]+=ve,de.entity="",de.state=qi)}else ue(de.entity.length?H:Z,We)?de.entity+=We:(cn(de,"Invalid character in entity name"),de[Me]+="&"+de.entity+We,de.entity="",de.state=qi);continue;default:throw new Error(de,"Unknown state: "+de.state)}return de.position>=de.bufferCheckPosition&&c(de),de}String.fromCodePoint||function(){var se=String.fromCharCode,de=Math.floor,it=function(){var We=16384,En=[],hr,qi,Me=-1,ve=arguments.length;if(!ve)return"";for(var wt="";++Me1114111||de(gn)!==gn)throw RangeError("Invalid code point: "+gn);gn<=65535?En.push(gn):(gn-=65536,hr=(gn>>10)+55296,qi=gn%1024+56320,En.push(hr,qi)),(Me+1===ve||En.length>We)&&(wt+=se.apply(null,En),En.length=0)}return wt};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:it,configurable:!0,writable:!0}):String.fromCodePoint=it}()})(typeof rfe>"u"?rfe.sax={}:rfe)});var a_t=Sd((Uai,o_t)=>{"use strict";var Osn=s_t().parser;function Nsn(s){var n=[],r=[],c=n,u;return u=Osn(!0),u.ontext=function(d){d.trim()!==""&&c.push(d)},u.onopentag=function(d){var b;b=[d.name,d.attributes],r.push(c),c.push(b),c=b},u.onclosetag=function(){c=r.pop()},u.write(s).close(),n[0]}o_t.exports=Nsn});var u_t=Sd((zai,l_t)=>{"use strict";function Fsn(s){return s&&Object.prototype.toString.call(s)==="[object Object]"}function Usn(s){var n,r=[];return typeof s!="string"?s:(n=s.split(` +`?(de.line++,de.column=0):de.column++);de.cdata+=se.substring(hr,it-1),We==="]"&&(de.state=Q.CDATA_ENDING);continue;case Q.CDATA_ENDING:We==="]"?de.state=Q.CDATA_ENDING_2:(de.cdata+="]"+We,de.state=Q.CDATA);continue;case Q.CDATA_ENDING_2:We===">"?(de.cdata&&ot(de,"oncdata",de.cdata),ot(de,"onclosecdata"),de.cdata="",de.state=Q.TEXT):We==="]"?de.cdata+="]":(de.cdata+="]]"+We,de.state=Q.CDATA);continue;case Q.PROC_INST:We==="?"?de.state=Q.PROC_INST_ENDING:te(We)?de.state=Q.PROC_INST_BODY:de.procInstName+=We;continue;case Q.PROC_INST_BODY:if(!de.procInstBody&&te(We))continue;We==="?"?de.state=Q.PROC_INST_ENDING:de.procInstBody+=We;continue;case Q.PROC_INST_ENDING:if(We===">"){let wt={name:de.procInstName,body:de.procInstBody};tt(de,wt),ot(de,"onprocessinginstruction",wt),de.procInstName=de.procInstBody="",de.state=Q.TEXT}else de.procInstBody+="?"+We,de.state=Q.PROC_INST_BODY;continue;case Q.OPEN_TAG:ue(z,We)?de.tagName+=We:(bi(de),We===">"?qn(de):We==="/"?de.state=Q.OPEN_TAG_SLASH:(te(We)||cn(de,"Invalid character in tag name"),de.state=Q.ATTRIB));continue;case Q.OPEN_TAG_SLASH:We===">"?(qn(de,!0),Yi(de)):(cn(de,"Forward-slash in opening tag not followed by >"),de.state=Q.ATTRIB);continue;case Q.ATTRIB:if(te(We))continue;We===">"?qn(de):We==="/"?de.state=Q.OPEN_TAG_SLASH:ue(O,We)?(de.attribName=We,de.attribValue="",de.state=Q.ATTRIB_NAME):cn(de,"Invalid attribute name");continue;case Q.ATTRIB_NAME:We==="="?de.state=Q.ATTRIB_VALUE:We===">"?(cn(de,"Attribute without value"),de.attribValue=de.attribName,pn(de),qn(de)):te(We)?de.state=Q.ATTRIB_NAME_SAW_WHITE:ue(z,We)?de.attribName+=We:cn(de,"Invalid attribute name");continue;case Q.ATTRIB_NAME_SAW_WHITE:if(We==="=")de.state=Q.ATTRIB_VALUE;else{if(te(We))continue;cn(de,"Attribute without value"),de.tag.attributes[de.attribName]="",de.attribValue="",ot(de,"onattribute",{name:de.attribName,value:""}),de.attribName="",We===">"?qn(de):ue(O,We)?(de.attribName=We,de.state=Q.ATTRIB_NAME):(cn(de,"Invalid attribute name"),de.state=Q.ATTRIB)}continue;case Q.ATTRIB_VALUE:if(te(We))continue;oe(We)?(de.q=We,de.state=Q.ATTRIB_VALUE_QUOTED):(de.opt.unquotedAttributeValues||en(de,"Unquoted attribute value"),de.state=Q.ATTRIB_VALUE_UNQUOTED,de.attribValue=We);continue;case Q.ATTRIB_VALUE_QUOTED:if(We!==de.q){We==="&"?de.state=Q.ATTRIB_VALUE_ENTITY_Q:de.attribValue+=We;continue}pn(de),de.q="",de.state=Q.ATTRIB_VALUE_CLOSED;continue;case Q.ATTRIB_VALUE_CLOSED:te(We)?de.state=Q.ATTRIB:We===">"?qn(de):We==="/"?de.state=Q.OPEN_TAG_SLASH:ue(O,We)?(cn(de,"No whitespace between attributes"),de.attribName=We,de.attribValue="",de.state=Q.ATTRIB_NAME):cn(de,"Invalid attribute name");continue;case Q.ATTRIB_VALUE_UNQUOTED:if(!ne(We)){We==="&"?de.state=Q.ATTRIB_VALUE_ENTITY_U:de.attribValue+=We;continue}pn(de),We===">"?qn(de):de.state=Q.ATTRIB;continue;case Q.CLOSE_TAG:if(de.tagName)We===">"?Yi(de):ue(z,We)?de.tagName+=We:de.script?(de.script+=""?Yi(de):cn(de,"Invalid characters in closing tag");continue;case Q.TEXT_ENTITY:case Q.ATTRIB_VALUE_ENTITY_Q:case Q.ATTRIB_VALUE_ENTITY_U:var qi,Me;switch(de.state){case Q.TEXT_ENTITY:qi=Q.TEXT,Me="textNode";break;case Q.ATTRIB_VALUE_ENTITY_Q:qi=Q.ATTRIB_VALUE_QUOTED,Me="attribValue";break;case Q.ATTRIB_VALUE_ENTITY_U:qi=Q.ATTRIB_VALUE_UNQUOTED,Me="attribValue";break}if(We===";"){var ve=$i(de);de.opt.unparsedEntities&&!Object.values(s.XML_ENTITIES).includes(ve)?((de.entityCount+=1)>de.opt.maxEntityCount&&en(de,"Parsed entity count exceeds max entity count"),(de.entityDepth+=1)>de.opt.maxEntityDepth&&en(de,"Parsed entity depth exceeds max entity depth"),de.entity="",de.state=qi,de.write(ve),de.entityDepth-=1):(de[Me]+=ve,de.entity="",de.state=qi)}else ue(de.entity.length?H:Z,We)?de.entity+=We:(cn(de,"Invalid character in entity name"),de[Me]+="&"+de.entity+We,de.entity="",de.state=qi);continue;default:throw new Error(de,"Unknown state: "+de.state)}return de.position>=de.bufferCheckPosition&&c(de),de}String.fromCodePoint||function(){var se=String.fromCharCode,de=Math.floor,it=function(){var We=16384,En=[],hr,qi,Me=-1,ve=arguments.length;if(!ve)return"";for(var wt="";++Me1114111||de(gn)!==gn)throw RangeError("Invalid code point: "+gn);gn<=65535?En.push(gn):(gn-=65536,hr=(gn>>10)+55296,qi=gn%1024+56320,En.push(hr,qi)),(Me+1===ve||En.length>We)&&(wt+=se.apply(null,En),En.length=0)}return wt};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:it,configurable:!0,writable:!0}):String.fromCodePoint=it}()})(typeof rfe>"u"?rfe.sax={}:rfe)});var a_t=Sd(($ai,o_t)=>{"use strict";var Usn=s_t().parser;function zsn(s){var n=[],r=[],c=n,u;return u=Usn(!0),u.ontext=function(d){d.trim()!==""&&c.push(d)},u.onopentag=function(d){var b;b=[d.name,d.attributes],r.push(c),c.push(b),c=b},u.onclosetag=function(){c=r.pop()},u.write(s).close(),n[0]}o_t.exports=zsn});var u_t=Sd((Vai,l_t)=>{"use strict";function Gsn(s){return s&&Object.prototype.toString.call(s)==="[object Object]"}function jsn(s){var n,r=[];return typeof s!="string"?s:(n=s.split(` `),n.length===1?" "+s:(n.forEach(function(c){if(c.trim()===""){r.push(c);return}r.push(" "+c)}),r.join(` -`)))}function zsn(s){var n=s.split(` +`)))}function $sn(s){var n=s.split(` `),r=[];return n.forEach(function(c){c.trim()!==""&&r.push(c)}),r.join(` -`)}function c_t(s){var n,r,c,u;return r="",u=!0,c=s.some(function(d,b,w){if(b===0)return n="<"+d,w.length===1?!0:void 0;if(b===1)if(Fsn(d)){if(Object.keys(d).forEach(function(_){n+=" "+_+'="'+d[_]+'"'}),w.length===2)return!0;n+=">";return}else n+=">";switch(typeof d){case"string":case"number":case"boolean":r+=d+` +`)}function c_t(s){var n,r,c,u;return r="",u=!0,c=s.some(function(d,b,w){if(b===0)return n="<"+d,w.length===1?!0:void 0;if(b===1)if(Gsn(d)){if(Object.keys(d).forEach(function(_){n+=" "+_+'="'+d[_]+'"'}),w.length===2)return!0;n+=">";return}else n+=">";switch(typeof d){case"string":case"number":case"boolean":r+=d+` `;return}u=!1,r+=c_t(d)}),c?n+`/> -`:u?n+zsn(r)+" +`:u?n+$sn(r)+" `:n+` -`+Usn(r)+" -`}l_t.exports=c_t});var h_t=Sd((Gai,f_t)=>{"use strict";function Gsn(s,n){var r=function(){},c=r,u=r;function d(){this._skip=!0}function b(){this._remove=!0}function w(T){this._name=T}function _(T){this._replace=T}function x(T,M){var L,I={attr:{},full:T},D={name:w,skip:d,remove:b,replace:_,_name:void 0,_skip:!1,_remove:!1,_replace:void 0},F=!0,O,z,Z;if(T!==void 0&&T!==null&&T!==!0&&T!==!1)switch(L=Object.prototype.toString.call(T),L){case"[object String]":case"[object Number]":return;case"[object Array]":if(T.some(function(H,te){if(te===0)return I.name=H,!1;if(te===1)return Object.prototype.toString.call(H)==="[object Object]"&&(F=!1,I.attr=H),!0}),c.call(D,I,M),D._name&&(T[0]=D._name),D._replace)return D._replace;if(D._remove)return null;if(!D._skip){for(O=0,z=T.length;O1||O===1&&F){if(Z=x(T[O],I),Z===null){T.splice(O,1),z-=1;continue}Z&&(T[O]=Z)}O+=1}if(u.call(D,I,M),D._name&&(T[0]=D._name),D._replace)return D._replace;if(D._remove)return null}}}n&&(n.enter&&(c=n.enter),n.leave&&(u=n.leave)),x(s,void 0)}f_t.exports=Gsn});var bW=Sd((jai,m_t)=>{"use strict";var d_t=a_t(),p_t=u_t(),g_t=h_t();m_t.exports={parse:d_t,stringify:p_t,traverse:g_t,p:d_t,s:p_t,t:g_t}});var O4=Sd((NB,wW)=>{(function(){var s,n="4.18.1",r=200,c="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",u="Expected a function",d="Invalid `variable` option passed into `_.template`",b="Invalid `imports` option passed into `_.template`",w="__lodash_hash_undefined__",_=500,x="__lodash_placeholder__",T=1,M=2,L=4,I=1,D=2,F=1,O=2,z=4,Z=8,H=16,te=32,oe=64,ne=128,ue=256,Te=512,Q=30,ge="...",Qe=800,st=16,at=1,Ne=2,tt=3,ot=1/0,Tt=9007199254740991,jt=17976931348623157e292,en=NaN,mn=4294967295,cn=mn-1,bi=mn>>>1,Vt=[["ary",ne],["bind",F],["bindKey",O],["curry",Z],["curryRight",H],["flip",Te],["partial",te],["partialRight",oe],["rearg",ue]],pn="[object Arguments]",qn="[object Array]",Yi="[object AsyncFunction]",$i="[object Boolean]",Tr="[object Date]",wr="[object DOMException]",Si="[object Error]",Fr="[object Function]",se="[object GeneratorFunction]",de="[object Map]",it="[object Number]",We="[object Null]",En="[object Object]",hr="[object Promise]",qi="[object Proxy]",Me="[object RegExp]",ve="[object Set]",wt="[object String]",gn="[object Symbol]",vn="[object Undefined]",Mn="[object WeakMap]",xi="[object WeakSet]",mi="[object ArrayBuffer]",ri="[object DataView]",Ge="[object Float32Array]",Ae="[object Float64Array]",Le="[object Int8Array]",ht="[object Int16Array]",Ye="[object Int32Array]",ct="[object Uint8Array]",Ze="[object Uint8ClampedArray]",Ke="[object Uint16Array]",pt="[object Uint32Array]",Xn=/\b__p \+= '';/g,_i=/\b(__p \+=) '' \+/g,Hi=/(__e\(.*?\)|\b__t\)) \+\n'';/g,_n=/&(?:amp|lt|gt|quot|#39);/g,Je=/[&<>"']/g,Qn=RegExp(_n.source),ei=RegExp(Je.source),ar=/<%-([\s\S]+?)%>/g,yn=/<%([\s\S]+?)%>/g,Re=/<%=([\s\S]+?)%>/g,nt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,kt=/^\w*$/,xn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ei=/[\\^$.*+?()[\]{}|]/g,Xi=RegExp(Ei.source),cr=/^\s+/,So=/\s/,Ks=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Bi=/\{\n\/\* \[wrapped with (.+)\] \*/,io=/,? & /,gf=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Q1=/[()=,{}\[\]\/\s]/,Lm=/\\(\\)?/g,b2=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,zb=/\w*$/,bk=/^[-+]0x[0-9a-f]+$/i,Pe=/^0b[01]+$/i,xt=/^\[object .+?Constructor\]$/,Kt=/^0o[0-7]+$/i,tn=/^(?:0|[1-9]\d*)$/,Yt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Zi=/($^)/,Rr=/['\n\r\u2028\u2029\\]/g,Xr="\\ud800-\\udfff",bs="\\u0300-\\u036f",Vs="\\ufe20-\\ufe2f",xs="\\u20d0-\\u20ff",Cs=bs+Vs+xs,Lc="\\u2700-\\u27bf",zf="a-z\\xdf-\\xf6\\xf8-\\xff",pl="\\xac\\xb1\\xd7\\xf7",bg="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",hc="\\u2000-\\u206f",Js=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",w2="A-Z\\xc0-\\xd6\\xd8-\\xde",dc="\\ufe0e\\ufe0f",km=pl+bg+hc+Js,v2="['\u2019]",Iv="["+Xr+"]",_2="["+km+"]",gl="["+Cs+"]",Rm="\\d+",rE="["+Lc+"]",gh="["+zf+"]",y2="[^"+Xr+km+Rm+Lc+zf+w2+"]",sE="\\ud83c[\\udffb-\\udfff]",PT="(?:"+gl+"|"+sE+")",kO="[^"+Xr+"]",wk="(?:\\ud83c[\\udde6-\\uddff]){2}",vk="[\\ud800-\\udbff][\\udc00-\\udfff]",x2="["+w2+"]",RO="\\u200d",IO="(?:"+gh+"|"+y2+")",uH="(?:"+x2+"|"+y2+")",DO="(?:"+v2+"(?:d|ll|m|re|s|t|ve))?",BO="(?:"+v2+"(?:D|LL|M|RE|S|T|VE))?",OO=PT+"?",NO="["+dc+"]?",fH="(?:"+RO+"(?:"+[kO,wk,vk].join("|")+")"+NO+OO+")*",hH="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",dH="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",FO=NO+OO+fH,pH="(?:"+[rE,wk,vk].join("|")+")"+FO,gH="(?:"+[kO+gl+"?",gl,wk,vk,Iv].join("|")+")",mH=RegExp(v2,"g"),bH=RegExp(gl,"g"),_k=RegExp(sE+"(?="+sE+")|"+gH+FO,"g"),wH=RegExp([x2+"?"+gh+"+"+DO+"(?="+[_2,x2,"$"].join("|")+")",uH+"+"+BO+"(?="+[_2,x2+IO,"$"].join("|")+")",x2+"?"+IO+"+"+DO,x2+"+"+BO,dH,hH,Rm,pH].join("|"),"g"),vH=RegExp("["+RO+Xr+Cs+dc+"]"),_H=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,yH=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],xH=-1,pc={};pc[Ge]=pc[Ae]=pc[Le]=pc[ht]=pc[Ye]=pc[ct]=pc[Ze]=pc[Ke]=pc[pt]=!0,pc[pn]=pc[qn]=pc[mi]=pc[$i]=pc[ri]=pc[Tr]=pc[Si]=pc[Fr]=pc[de]=pc[it]=pc[En]=pc[Me]=pc[ve]=pc[wt]=pc[Mn]=!1;var ic={};ic[pn]=ic[qn]=ic[mi]=ic[ri]=ic[$i]=ic[Tr]=ic[Ge]=ic[Ae]=ic[Le]=ic[ht]=ic[Ye]=ic[de]=ic[it]=ic[En]=ic[Me]=ic[ve]=ic[wt]=ic[gn]=ic[ct]=ic[Ze]=ic[Ke]=ic[pt]=!0,ic[Si]=ic[Fr]=ic[Mn]=!1;var EH={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},SH={"&":"&","<":"<",">":">",'"':""","'":"'"},MH={"&":"&","<":"<",">":">",""":'"',"'":"'"},TH={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},CH=parseFloat,AH=parseInt,UO=typeof global=="object"&&global&&global.Object===Object&&global,PH=typeof self=="object"&&self&&self.Object===Object&&self,Du=UO||PH||Function("return this")(),yk=typeof NB=="object"&&NB&&!NB.nodeType&&NB,Dv=yk&&typeof wW=="object"&&wW&&!wW.nodeType&&wW,zO=Dv&&Dv.exports===yk,xk=zO&&UO.process,wp=function(){try{var lt=Dv&&Dv.require&&Dv.require("util").types;return lt||xk&&xk.binding&&xk.binding("util")}catch{}}(),GO=wp&&wp.isArrayBuffer,jO=wp&&wp.isDate,$O=wp&&wp.isMap,VO=wp&&wp.isRegExp,WO=wp&&wp.isSet,HO=wp&&wp.isTypedArray;function Cd(lt,fn,Jt){switch(Jt.length){case 0:return lt.call(fn);case 1:return lt.call(fn,Jt[0]);case 2:return lt.call(fn,Jt[0],Jt[1]);case 3:return lt.call(fn,Jt[0],Jt[1],Jt[2])}return lt.apply(fn,Jt)}function LH(lt,fn,Jt,rr){for(var Es=-1,ta=lt==null?0:lt.length;++Es-1}function Ek(lt,fn,Jt){for(var rr=-1,Es=lt==null?0:lt.length;++rr-1;);return Jt}function eN(lt,fn){for(var Jt=lt.length;Jt--&&E2(fn,lt[Jt],0)>-1;);return Jt}function UH(lt,fn){for(var Jt=lt.length,rr=0;Jt--;)lt[Jt]===fn&&++rr;return rr}var zH=Ck(EH),GH=Ck(SH);function jH(lt){return"\\"+TH[lt]}function $H(lt,fn){return lt==null?s:lt[fn]}function S2(lt){return vH.test(lt)}function VH(lt){return _H.test(lt)}function WH(lt){for(var fn,Jt=[];!(fn=lt.next()).done;)Jt.push(fn.value);return Jt}function kk(lt){var fn=-1,Jt=Array(lt.size);return lt.forEach(function(rr,Es){Jt[++fn]=[Es,rr]}),Jt}function tN(lt,fn){return function(Jt){return lt(fn(Jt))}}function $b(lt,fn){for(var Jt=-1,rr=lt.length,Es=0,ta=[];++Jt-1}function Pq(S,P){var U=this.__data__,K=dE(U,S);return K<0?(++this.size,U.push([S,P])):U[K][1]=P,this}n0.prototype.clear=Mq,n0.prototype.delete=Tq,n0.prototype.get=Cq,n0.prototype.has=Aq,n0.prototype.set=Pq;function i0(S){var P=-1,U=S==null?0:S.length;for(this.clear();++P=P?S:P)),S}function yp(S,P,U,K,pe,xe){var je,rt=P&T,gt=P&M,wn=P&L;if(U&&(je=pe?U(S,K,pe,xe):U(S)),je!==s)return je;if(!Uc(S))return S;var Sn=Rs(S);if(Sn){if(je=AX(S),!rt)return Xh(S,je)}else{var Dn=jf(S),Vi=Dn==Fr||Dn==se;if(Rd(S))return NN(S,rt);if(Dn==En||Dn==pn||Vi&&!pe){if(je=gt||Vi?{}:nF(S),!rt)return gt?bX(S,Vq(je,S)):mX(S,pN(je,S))}else{if(!ic[Dn])return pe?S:{};je=PX(S,Dn,rt)}}xe||(xe=new vg);var vr=xe.get(S);if(vr)return vr;xe.set(S,je),zF(S)?S.forEach(function(Wr){je.add(yp(Wr,P,U,Wr,S,xe))}):FF(S)&&S.forEach(function(Wr,so){je.set(so,yp(Wr,P,U,so,S,xe))});var Ur=wn?gt?tR:eR:gt?Yh:Nu,Qs=Sn?s:Ur(S);return Ad(Qs||S,function(Wr,so){Qs&&(so=Wr,Wr=S[so]),hE(je,so,yp(Wr,P,U,so,S,xe))}),je}function Wq(S){var P=Nu(S);return function(U){return gN(U,S,P)}}function gN(S,P,U){var K=U.length;if(S==null)return!K;for(S=Ha(S);K--;){var pe=U[K],xe=P[pe],je=S[pe];if(je===s&&!(pe in S)||!xe(je))return!1}return!0}function mN(S,P,U){if(typeof S!="function")throw new vp(u);return xE(function(){S.apply(s,U)},P)}function pE(S,P,U,K){var pe=-1,xe=LT,je=!0,rt=S.length,gt=[],wn=P.length;if(!rt)return gt;U&&(P=kc(P,Pd(U))),K?(xe=Ek,je=!1):P.length>=r&&(xe=oE,je=!1,P=new Nv(P));e:for(;++pepe?0:pe+U),K=K===s||K>pe?pe:Ws(K),K<0&&(K+=pe),K=U>K?0:jF(K);U0&&U(rt)?P>1?mf(rt,P-1,U,K,pe):jb(pe,rt):K||(pe[pe.length]=rt)}return pe}var YT=$N(),mE=$N(!0);function Dm(S,P){return S&&YT(S,P,Nu)}function ZT(S,P){return S&&mE(S,P,Nu)}function KT(S,P){return Gb(P,function(U){return l0(S[U])})}function r0(S,P){P=Yb(P,S);for(var U=0,K=P.length;S!=null&&UP}function Xq(S,P){return S!=null&&ya.call(S,P)}function Yq(S,P){return S!=null&&P in Ha(S)}function Zq(S,P,U){return S>=Gf(P,U)&&S=120&&Sn.length>=120)?new Nv(je&&Sn):s}Sn=S[0];var Dn=-1,Vi=rt[0];e:for(;++Dn-1;)rt!==S&>.call(rt,gt,1),GT.call(S,gt,1);return S}function PN(S,P){for(var U=S?P.length:0,K=U-1;U--;){var pe=P[U];if(U==K||pe!==xe){var xe=pe;a0(pe)?GT.call(S,pe,1):qk(S,pe)}}return S}function Vk(S,P){return S+VT(lN()*(P-S+1))}function sX(S,P,U,K){for(var pe=-1,xe=nu($T((P-S)/(U||1)),0),je=Jt(xe);xe--;)je[K?xe:++pe]=S,S+=U;return je}function Wk(S,P){var U="";if(!S||P<1||P>Tt)return U;do P%2&&(U+=S),P=VT(P/2),P&&(S+=S);while(P);return U}function ro(S,P){return cR(sF(S,P,Rc),S+"")}function oX(S){return dN(O2(S))}function aX(S,P){var U=O2(S);return cC(U,Fv(P,0,U.length))}function vE(S,P,U,K){if(!Uc(S))return S;P=Yb(P,S);for(var pe=-1,xe=P.length,je=xe-1,rt=S;rt!=null&&++pepe?0:pe+P),U=U>pe?pe:U,U<0&&(U+=pe),pe=P>U?0:U-P>>>0,P>>>=0;for(var xe=Jt(pe);++K>>1,je=S[xe];je!==null&&!Id(je)&&(U?je<=P:je=r){var wn=P?null:yX(S);if(wn)return RT(wn);je=!1,pe=oE,gt=new Nv}else gt=P?[]:rt;e:for(;++K=K?S:xp(S,P,U)}var ON=oq||function(S){return Du.clearTimeout(S)};function NN(S,P){if(P)return S.slice();var U=S.length,K=rN?rN(U):new S.constructor(U);return S.copy(K),K}function Kk(S){var P=new S.constructor(S.byteLength);return new UT(P).set(new UT(S)),P}function hX(S,P){var U=P?Kk(S.buffer):S.buffer;return new S.constructor(U,S.byteOffset,S.byteLength)}function dX(S){var P=new S.constructor(S.source,zb.exec(S));return P.lastIndex=S.lastIndex,P}function pX(S){return fE?Ha(fE.call(S)):{}}function FN(S,P){var U=P?Kk(S.buffer):S.buffer;return new S.constructor(U,S.byteOffset,S.length)}function UN(S,P){if(S!==P){var U=S!==s,K=S===null,pe=S===S,xe=Id(S),je=P!==s,rt=P===null,gt=P===P,wn=Id(P);if(!rt&&!wn&&!xe&&S>P||xe&&je&>&&!rt&&!wn||K&&je&>||!U&>||!pe)return 1;if(!K&&!xe&&!wn&&S=rt)return gt;var wn=U[K];return gt*(wn=="desc"?-1:1)}}return S.index-P.index}function zN(S,P,U,K){for(var pe=-1,xe=S.length,je=U.length,rt=-1,gt=P.length,wn=nu(xe-je,0),Sn=Jt(gt+wn),Dn=!K;++rt1?U[pe-1]:s,je=pe>2?U[2]:s;for(xe=S.length>3&&typeof xe=="function"?(pe--,xe):s,je&&$f(U[0],U[1],je)&&(xe=pe<3?s:xe,pe=1),P=Ha(P);++K-1?pe[xe?P[je]:je]:s}}function HN(S){return o0(function(P){var U=P.length,K=U,pe=_p.prototype.thru;for(S&&P.reverse();K--;){var xe=P[K];if(typeof xe!="function")throw new vp(u);if(pe&&!je&&oC(xe)=="wrapper")var je=new _p([],!0)}for(K=je?K:U;++K1&&jo.reverse(),Sn&>rt))return!1;var wn=xe.get(S),Sn=xe.get(P);if(wn&&Sn)return wn==P&&Sn==S;var Dn=-1,Vi=!0,vr=U&D?new Nv:s;for(xe.set(S,P),xe.set(P,S);++Dn1?"& ":"")+P[K],P=P.join(U>2?", ":" "),S.replace(Ks,`{ +`+jsn(r)+" +`}l_t.exports=c_t});var h_t=Sd((Wai,f_t)=>{"use strict";function Vsn(s,n){var r=function(){},c=r,u=r;function d(){this._skip=!0}function b(){this._remove=!0}function w(T){this._name=T}function _(T){this._replace=T}function x(T,M){var L,I={attr:{},full:T},D={name:w,skip:d,remove:b,replace:_,_name:void 0,_skip:!1,_remove:!1,_replace:void 0},F=!0,O,z,Z;if(T!==void 0&&T!==null&&T!==!0&&T!==!1)switch(L=Object.prototype.toString.call(T),L){case"[object String]":case"[object Number]":return;case"[object Array]":if(T.some(function(H,te){if(te===0)return I.name=H,!1;if(te===1)return Object.prototype.toString.call(H)==="[object Object]"&&(F=!1,I.attr=H),!0}),c.call(D,I,M),D._name&&(T[0]=D._name),D._replace)return D._replace;if(D._remove)return null;if(!D._skip){for(O=0,z=T.length;O1||O===1&&F){if(Z=x(T[O],I),Z===null){T.splice(O,1),z-=1;continue}Z&&(T[O]=Z)}O+=1}if(u.call(D,I,M),D._name&&(T[0]=D._name),D._replace)return D._replace;if(D._remove)return null}}}n&&(n.enter&&(c=n.enter),n.leave&&(u=n.leave)),x(s,void 0)}f_t.exports=Vsn});var bW=Sd((Hai,m_t)=>{"use strict";var d_t=a_t(),p_t=u_t(),g_t=h_t();m_t.exports={parse:d_t,stringify:p_t,traverse:g_t,p:d_t,s:p_t,t:g_t}});var O4=Sd((NB,wW)=>{(function(){var s,n="4.18.1",r=200,c="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",u="Expected a function",d="Invalid `variable` option passed into `_.template`",b="Invalid `imports` option passed into `_.template`",w="__lodash_hash_undefined__",_=500,x="__lodash_placeholder__",T=1,M=2,L=4,I=1,D=2,F=1,O=2,z=4,Z=8,H=16,te=32,oe=64,ne=128,ue=256,Te=512,Q=30,ge="...",Qe=800,st=16,at=1,Ne=2,tt=3,ot=1/0,Tt=9007199254740991,jt=17976931348623157e292,en=NaN,mn=4294967295,cn=mn-1,bi=mn>>>1,Vt=[["ary",ne],["bind",F],["bindKey",O],["curry",Z],["curryRight",H],["flip",Te],["partial",te],["partialRight",oe],["rearg",ue]],pn="[object Arguments]",qn="[object Array]",Yi="[object AsyncFunction]",$i="[object Boolean]",Tr="[object Date]",wr="[object DOMException]",Si="[object Error]",Fr="[object Function]",se="[object GeneratorFunction]",de="[object Map]",it="[object Number]",We="[object Null]",En="[object Object]",hr="[object Promise]",qi="[object Proxy]",Me="[object RegExp]",ve="[object Set]",wt="[object String]",gn="[object Symbol]",vn="[object Undefined]",Mn="[object WeakMap]",xi="[object WeakSet]",mi="[object ArrayBuffer]",ri="[object DataView]",Ge="[object Float32Array]",Ae="[object Float64Array]",Le="[object Int8Array]",ht="[object Int16Array]",Ye="[object Int32Array]",ct="[object Uint8Array]",Ze="[object Uint8ClampedArray]",Ke="[object Uint16Array]",pt="[object Uint32Array]",Xn=/\b__p \+= '';/g,_i=/\b(__p \+=) '' \+/g,Hi=/(__e\(.*?\)|\b__t\)) \+\n'';/g,_n=/&(?:amp|lt|gt|quot|#39);/g,Je=/[&<>"']/g,Qn=RegExp(_n.source),ei=RegExp(Je.source),ar=/<%-([\s\S]+?)%>/g,yn=/<%([\s\S]+?)%>/g,Re=/<%=([\s\S]+?)%>/g,nt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,kt=/^\w*$/,xn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ei=/[\\^$.*+?()[\]{}|]/g,Xi=RegExp(Ei.source),cr=/^\s+/,So=/\s/,Ks=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Bi=/\{\n\/\* \[wrapped with (.+)\] \*/,io=/,? & /,mf=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,J1=/[()=,{}\[\]\/\s]/,Lm=/\\(\\)?/g,b2=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,zb=/\w*$/,bk=/^[-+]0x[0-9a-f]+$/i,Pe=/^0b[01]+$/i,xt=/^\[object .+?Constructor\]$/,Kt=/^0o[0-7]+$/i,tn=/^(?:0|[1-9]\d*)$/,Yt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Zi=/($^)/,Rr=/['\n\r\u2028\u2029\\]/g,Xr="\\ud800-\\udfff",bs="\\u0300-\\u036f",Vs="\\ufe20-\\ufe2f",xs="\\u20d0-\\u20ff",Cs=bs+Vs+xs,Lc="\\u2700-\\u27bf",Gf="a-z\\xdf-\\xf6\\xf8-\\xff",pl="\\xac\\xb1\\xd7\\xf7",bg="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",hc="\\u2000-\\u206f",Js=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",w2="A-Z\\xc0-\\xd6\\xd8-\\xde",dc="\\ufe0e\\ufe0f",km=pl+bg+hc+Js,v2="['\u2019]",Iv="["+Xr+"]",_2="["+km+"]",gl="["+Cs+"]",Rm="\\d+",rE="["+Lc+"]",gh="["+Gf+"]",y2="[^"+Xr+km+Rm+Lc+Gf+w2+"]",sE="\\ud83c[\\udffb-\\udfff]",PT="(?:"+gl+"|"+sE+")",kO="[^"+Xr+"]",wk="(?:\\ud83c[\\udde6-\\uddff]){2}",vk="[\\ud800-\\udbff][\\udc00-\\udfff]",x2="["+w2+"]",RO="\\u200d",IO="(?:"+gh+"|"+y2+")",uH="(?:"+x2+"|"+y2+")",DO="(?:"+v2+"(?:d|ll|m|re|s|t|ve))?",BO="(?:"+v2+"(?:D|LL|M|RE|S|T|VE))?",OO=PT+"?",NO="["+dc+"]?",fH="(?:"+RO+"(?:"+[kO,wk,vk].join("|")+")"+NO+OO+")*",hH="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",dH="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",FO=NO+OO+fH,pH="(?:"+[rE,wk,vk].join("|")+")"+FO,gH="(?:"+[kO+gl+"?",gl,wk,vk,Iv].join("|")+")",mH=RegExp(v2,"g"),bH=RegExp(gl,"g"),_k=RegExp(sE+"(?="+sE+")|"+gH+FO,"g"),wH=RegExp([x2+"?"+gh+"+"+DO+"(?="+[_2,x2,"$"].join("|")+")",uH+"+"+BO+"(?="+[_2,x2+IO,"$"].join("|")+")",x2+"?"+IO+"+"+DO,x2+"+"+BO,dH,hH,Rm,pH].join("|"),"g"),vH=RegExp("["+RO+Xr+Cs+dc+"]"),_H=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,yH=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],xH=-1,pc={};pc[Ge]=pc[Ae]=pc[Le]=pc[ht]=pc[Ye]=pc[ct]=pc[Ze]=pc[Ke]=pc[pt]=!0,pc[pn]=pc[qn]=pc[mi]=pc[$i]=pc[ri]=pc[Tr]=pc[Si]=pc[Fr]=pc[de]=pc[it]=pc[En]=pc[Me]=pc[ve]=pc[wt]=pc[Mn]=!1;var ic={};ic[pn]=ic[qn]=ic[mi]=ic[ri]=ic[$i]=ic[Tr]=ic[Ge]=ic[Ae]=ic[Le]=ic[ht]=ic[Ye]=ic[de]=ic[it]=ic[En]=ic[Me]=ic[ve]=ic[wt]=ic[gn]=ic[ct]=ic[Ze]=ic[Ke]=ic[pt]=!0,ic[Si]=ic[Fr]=ic[Mn]=!1;var EH={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},SH={"&":"&","<":"<",">":">",'"':""","'":"'"},MH={"&":"&","<":"<",">":">",""":'"',"'":"'"},TH={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},CH=parseFloat,AH=parseInt,UO=typeof global=="object"&&global&&global.Object===Object&&global,PH=typeof self=="object"&&self&&self.Object===Object&&self,Du=UO||PH||Function("return this")(),yk=typeof NB=="object"&&NB&&!NB.nodeType&&NB,Dv=yk&&typeof wW=="object"&&wW&&!wW.nodeType&&wW,zO=Dv&&Dv.exports===yk,xk=zO&&UO.process,wp=function(){try{var lt=Dv&&Dv.require&&Dv.require("util").types;return lt||xk&&xk.binding&&xk.binding("util")}catch{}}(),GO=wp&&wp.isArrayBuffer,jO=wp&&wp.isDate,$O=wp&&wp.isMap,VO=wp&&wp.isRegExp,WO=wp&&wp.isSet,HO=wp&&wp.isTypedArray;function Cd(lt,fn,Jt){switch(Jt.length){case 0:return lt.call(fn);case 1:return lt.call(fn,Jt[0]);case 2:return lt.call(fn,Jt[0],Jt[1]);case 3:return lt.call(fn,Jt[0],Jt[1],Jt[2])}return lt.apply(fn,Jt)}function LH(lt,fn,Jt,rr){for(var Es=-1,ta=lt==null?0:lt.length;++Es-1}function Ek(lt,fn,Jt){for(var rr=-1,Es=lt==null?0:lt.length;++rr-1;);return Jt}function eN(lt,fn){for(var Jt=lt.length;Jt--&&E2(fn,lt[Jt],0)>-1;);return Jt}function UH(lt,fn){for(var Jt=lt.length,rr=0;Jt--;)lt[Jt]===fn&&++rr;return rr}var zH=Ck(EH),GH=Ck(SH);function jH(lt){return"\\"+TH[lt]}function $H(lt,fn){return lt==null?s:lt[fn]}function S2(lt){return vH.test(lt)}function VH(lt){return _H.test(lt)}function WH(lt){for(var fn,Jt=[];!(fn=lt.next()).done;)Jt.push(fn.value);return Jt}function kk(lt){var fn=-1,Jt=Array(lt.size);return lt.forEach(function(rr,Es){Jt[++fn]=[Es,rr]}),Jt}function tN(lt,fn){return function(Jt){return lt(fn(Jt))}}function $b(lt,fn){for(var Jt=-1,rr=lt.length,Es=0,ta=[];++Jt-1}function Pq(S,P){var U=this.__data__,K=dE(U,S);return K<0?(++this.size,U.push([S,P])):U[K][1]=P,this}t0.prototype.clear=Mq,t0.prototype.delete=Tq,t0.prototype.get=Cq,t0.prototype.has=Aq,t0.prototype.set=Pq;function n0(S){var P=-1,U=S==null?0:S.length;for(this.clear();++P=P?S:P)),S}function yp(S,P,U,K,pe,xe){var je,rt=P&T,gt=P&M,wn=P&L;if(U&&(je=pe?U(S,K,pe,xe):U(S)),je!==s)return je;if(!Uc(S))return S;var Sn=Rs(S);if(Sn){if(je=AX(S),!rt)return Xh(S,je)}else{var Dn=$f(S),Vi=Dn==Fr||Dn==se;if(Rd(S))return NN(S,rt);if(Dn==En||Dn==pn||Vi&&!pe){if(je=gt||Vi?{}:nF(S),!rt)return gt?bX(S,Vq(je,S)):mX(S,pN(je,S))}else{if(!ic[Dn])return pe?S:{};je=PX(S,Dn,rt)}}xe||(xe=new vg);var vr=xe.get(S);if(vr)return vr;xe.set(S,je),zF(S)?S.forEach(function(Wr){je.add(yp(Wr,P,U,Wr,S,xe))}):FF(S)&&S.forEach(function(Wr,so){je.set(so,yp(Wr,P,U,so,S,xe))});var Ur=wn?gt?tR:eR:gt?Yh:Nu,Qs=Sn?s:Ur(S);return Ad(Qs||S,function(Wr,so){Qs&&(so=Wr,Wr=S[so]),hE(je,so,yp(Wr,P,U,so,S,xe))}),je}function Wq(S){var P=Nu(S);return function(U){return gN(U,S,P)}}function gN(S,P,U){var K=U.length;if(S==null)return!K;for(S=Ha(S);K--;){var pe=U[K],xe=P[pe],je=S[pe];if(je===s&&!(pe in S)||!xe(je))return!1}return!0}function mN(S,P,U){if(typeof S!="function")throw new vp(u);return xE(function(){S.apply(s,U)},P)}function pE(S,P,U,K){var pe=-1,xe=LT,je=!0,rt=S.length,gt=[],wn=P.length;if(!rt)return gt;U&&(P=kc(P,Pd(U))),K?(xe=Ek,je=!1):P.length>=r&&(xe=oE,je=!1,P=new Nv(P));e:for(;++pepe?0:pe+U),K=K===s||K>pe?pe:Ws(K),K<0&&(K+=pe),K=U>K?0:jF(K);U0&&U(rt)?P>1?bf(rt,P-1,U,K,pe):jb(pe,rt):K||(pe[pe.length]=rt)}return pe}var YT=$N(),mE=$N(!0);function Dm(S,P){return S&&YT(S,P,Nu)}function ZT(S,P){return S&&mE(S,P,Nu)}function KT(S,P){return Gb(P,function(U){return c0(S[U])})}function i0(S,P){P=Yb(P,S);for(var U=0,K=P.length;S!=null&&UP}function Xq(S,P){return S!=null&&ya.call(S,P)}function Yq(S,P){return S!=null&&P in Ha(S)}function Zq(S,P,U){return S>=jf(P,U)&&S=120&&Sn.length>=120)?new Nv(je&&Sn):s}Sn=S[0];var Dn=-1,Vi=rt[0];e:for(;++Dn-1;)rt!==S&>.call(rt,gt,1),GT.call(S,gt,1);return S}function PN(S,P){for(var U=S?P.length:0,K=U-1;U--;){var pe=P[U];if(U==K||pe!==xe){var xe=pe;o0(pe)?GT.call(S,pe,1):qk(S,pe)}}return S}function Vk(S,P){return S+VT(lN()*(P-S+1))}function sX(S,P,U,K){for(var pe=-1,xe=nu($T((P-S)/(U||1)),0),je=Jt(xe);xe--;)je[K?xe:++pe]=S,S+=U;return je}function Wk(S,P){var U="";if(!S||P<1||P>Tt)return U;do P%2&&(U+=S),P=VT(P/2),P&&(S+=S);while(P);return U}function ro(S,P){return cR(sF(S,P,Rc),S+"")}function oX(S){return dN(O2(S))}function aX(S,P){var U=O2(S);return cC(U,Fv(P,0,U.length))}function vE(S,P,U,K){if(!Uc(S))return S;P=Yb(P,S);for(var pe=-1,xe=P.length,je=xe-1,rt=S;rt!=null&&++pepe?0:pe+P),U=U>pe?pe:U,U<0&&(U+=pe),pe=P>U?0:U-P>>>0,P>>>=0;for(var xe=Jt(pe);++K>>1,je=S[xe];je!==null&&!Id(je)&&(U?je<=P:je=r){var wn=P?null:yX(S);if(wn)return RT(wn);je=!1,pe=oE,gt=new Nv}else gt=P?[]:rt;e:for(;++K=K?S:xp(S,P,U)}var ON=oq||function(S){return Du.clearTimeout(S)};function NN(S,P){if(P)return S.slice();var U=S.length,K=rN?rN(U):new S.constructor(U);return S.copy(K),K}function Kk(S){var P=new S.constructor(S.byteLength);return new UT(P).set(new UT(S)),P}function hX(S,P){var U=P?Kk(S.buffer):S.buffer;return new S.constructor(U,S.byteOffset,S.byteLength)}function dX(S){var P=new S.constructor(S.source,zb.exec(S));return P.lastIndex=S.lastIndex,P}function pX(S){return fE?Ha(fE.call(S)):{}}function FN(S,P){var U=P?Kk(S.buffer):S.buffer;return new S.constructor(U,S.byteOffset,S.length)}function UN(S,P){if(S!==P){var U=S!==s,K=S===null,pe=S===S,xe=Id(S),je=P!==s,rt=P===null,gt=P===P,wn=Id(P);if(!rt&&!wn&&!xe&&S>P||xe&&je&>&&!rt&&!wn||K&&je&>||!U&>||!pe)return 1;if(!K&&!xe&&!wn&&S=rt)return gt;var wn=U[K];return gt*(wn=="desc"?-1:1)}}return S.index-P.index}function zN(S,P,U,K){for(var pe=-1,xe=S.length,je=U.length,rt=-1,gt=P.length,wn=nu(xe-je,0),Sn=Jt(gt+wn),Dn=!K;++rt1?U[pe-1]:s,je=pe>2?U[2]:s;for(xe=S.length>3&&typeof xe=="function"?(pe--,xe):s,je&&Vf(U[0],U[1],je)&&(xe=pe<3?s:xe,pe=1),P=Ha(P);++K-1?pe[xe?P[je]:je]:s}}function HN(S){return s0(function(P){var U=P.length,K=U,pe=_p.prototype.thru;for(S&&P.reverse();K--;){var xe=P[K];if(typeof xe!="function")throw new vp(u);if(pe&&!je&&oC(xe)=="wrapper")var je=new _p([],!0)}for(K=je?K:U;++K1&&jo.reverse(),Sn&>rt))return!1;var wn=xe.get(S),Sn=xe.get(P);if(wn&&Sn)return wn==P&&Sn==S;var Dn=-1,Vi=!0,vr=U&D?new Nv:s;for(xe.set(S,P),xe.set(P,S);++Dn1?"& ":"")+P[K],P=P.join(U>2?", ":" "),S.replace(Ks,`{ /* [wrapped with `+P+`] */ -`)}function kX(S){return Rs(S)||Vv(S)||!!(aN&&S&&S[aN])}function a0(S,P){var U=typeof S;return P=P??Tt,!!P&&(U=="number"||U!="symbol"&&tn.test(S))&&S>-1&&S%1==0&&S0){if(++P>=Qe)return arguments[0]}else P=0;return S.apply(s,arguments)}}function cC(S,P){var U=-1,K=S.length,pe=K-1;for(P=P===s?K:P;++U1?S[P-1]:s;return U=typeof U=="function"?(S.pop(),U):s,c0(S,U)});function SF(S){var P=_e(S);return P.__chain__=!0,P}function xde(S,P){return P(S),S}function gR(S,P){return P(S)}var Ede=o0(function(S){var P=S.length,U=P?S[0]:0,K=this.__wrapped__,pe=function(xe){return Ok(xe,S)};return P>1||this.__actions__.length||!(K instanceof Io)||!a0(U)?this.thru(pe):(K=K.slice(U,+U+(P?1:0)),K.__actions__.push({func:gR,args:[pe],thisArg:s}),new _p(K,this.__chain__).thru(function(xe){return P&&!xe.length&&xe.push(s),xe}))});function Sde(){return SF(this)}function Mde(){return new _p(this.value(),this.__chain__)}function Ou(){this.__values__===s&&(this.__values__=GF(this.value()));var S=this.__index__>=this.__values__.length,P=S?s:this.__values__[this.__index__++];return{done:S,value:P}}function Tde(){return this}function Cde(S){for(var P,U=this;U instanceof qT;){var K=fF(U);K.__index__=0,K.__values__=s,P?pe.__wrapped__=K:P=K;var pe=K;U=U.__wrapped__}return pe.__wrapped__=S,P}function Ade(){var S=this.__wrapped__;if(S instanceof Io){var P=S;return this.__actions__.length&&(P=new Io(this)),P=P.reverse(),P.__actions__.push({func:gR,args:[fR],thisArg:s}),new _p(P,this.__chain__)}return this.thru(fR)}function pY(){return DN(this.__wrapped__,this.__actions__)}var MF=tC(function(S,P,U){ya.call(S,U)?++S[U]:Im(S,U,1)});function Pde(S,P,U){var K=Rs(S)?qO:Hq;return U&&$f(S,P,U)&&(P=s),K(S,ns(P,3))}function Lde(S,P){var U=Rs(S)?Gb:gE;return U(S,ns(P,3))}var TF=WN(dF),CF=WN(pF);function kde(S,P){return mf(mR(S,P),1)}function Rde(S,P){return mf(mR(S,P),ot)}function Ide(S,P,U){return U=U===s?1:Ws(U),mf(mR(S,P),U)}function gY(S,P){var U=Rs(S)?Ad:Hb;return U(S,ns(P,3))}function mY(S,P){var U=Rs(S)?kH:bN;return U(S,ns(P,3))}var Dde=tC(function(S,P,U){ya.call(S,U)?S[U].push(P):Im(S,U,[P])});function Bde(S,P,U,K){S=bf(S)?S:O2(S),U=U&&!K?Ws(U):0;var pe=S.length;return U<0&&(U=nu(pe+U,0)),gC(S)?U<=pe&&S.indexOf(P,U)>-1:!!pe&&E2(S,P,U)>-1}var Ode=ro(function(S,P,U){var K=-1,pe=typeof P=="function",xe=bf(S)?Jt(S.length):[];return Hb(S,function(je){xe[++K]=pe?Cd(P,je,U):bE(je,P,U)}),xe}),Nde=tC(function(S,P,U){Im(S,U,P)});function mR(S,P){var U=Rs(S)?kc:SN;return U(S,ns(P,3))}function Fde(S,P,U,K){return S==null?[]:(Rs(P)||(P=P==null?[]:[P]),U=K?s:U,Rs(U)||(U=U==null?[]:[U]),qb(S,P,U))}var Ude=tC(function(S,P,U){S[U?0:1].push(P)},function(){return[[],[]]});function zde(S,P,U){var K=Rs(S)?Sk:KO,pe=arguments.length<3;return K(S,ns(P,4),U,pe,Hb)}function Gde(S,P,U){var K=Rs(S)?RH:KO,pe=arguments.length<3;return K(S,ns(P,4),U,pe,bN)}function jde(S,P){var U=Rs(S)?Gb:gE;return U(S,hC(ns(P,3)))}function $de(S){var P=Rs(S)?dN:oX;return P(S)}function Vde(S,P,U){(U?$f(S,P,U):P===s)?P=1:P=Ws(P);var K=Rs(S)?Gq:aX;return K(S,P)}function bY(S){var P=Rs(S)?jq:lX;return P(S)}function wY(S){if(S==null)return 0;if(bf(S))return gC(S)?M2(S):S.length;var P=jf(S);return P==de||P==ve?S.size:zk(S).length}function vY(S,P,U){var K=Rs(S)?Mk:uX;return U&&$f(S,P,U)&&(P=s),K(S,ns(P,3))}var AF=ro(function(S,P){if(S==null)return[];var U=P.length;return U>1&&$f(S,P[0],P[1])?P=[]:U>2&&$f(P[0],P[1],P[2])&&(P=[P[0]]),qb(S,mf(P,1),[])}),jv=aq||function(){return Du.Date.now()};function uC(S,P){if(typeof P!="function")throw new vp(u);return S=Ws(S),function(){if(--S<1)return P.apply(this,arguments)}}function fC(S,P,U){return P=U?s:P,P=S&&P==null?S.length:P,s0(S,ne,s,s,s,s,P)}function Jb(S,P){var U;if(typeof P!="function")throw new vp(u);return S=Ws(S),function(){return--S>0&&(U=P.apply(this,arguments)),S<=1&&(P=s),U}}var Nm=ro(function(S,P,U){var K=F;if(U.length){var pe=$b(U,I2(Nm));K|=te}return s0(S,K,P,U,pe)}),PF=ro(function(S,P,U){var K=F|O;if(U.length){var pe=$b(U,I2(PF));K|=te}return s0(P,K,S,U,pe)});function LF(S,P,U){P=U?s:P;var K=s0(S,Z,s,s,s,s,s,P);return K.placeholder=LF.placeholder,K}function gr(S,P,U){P=U?s:P;var K=s0(S,H,s,s,s,s,s,P);return K.placeholder=gr.placeholder,K}function kF(S,P,U){var K,pe,xe,je,rt,gt,wn=0,Sn=!1,Dn=!1,Vi=!0;if(typeof S!="function")throw new vp(u);P=Sp(P)||0,Uc(U)&&(Sn=!!U.leading,Dn="maxWait"in U,xe=Dn?nu(Sp(U.maxWait)||0,P):xe,Vi="trailing"in U?!!U.trailing:Vi);function vr(ml){var Zh=K,f0=pe;return K=pe=s,wn=ml,je=S.apply(f0,Zh),je}function Ur(ml){return wn=ml,rt=xE(so,P),Sn?vr(ml):je}function Qs(ml){var Zh=ml-gt,f0=ml-wn,l8=P-Zh;return Dn?Gf(l8,xe-f0):l8}function Wr(ml){var Zh=ml-gt,f0=ml-wn;return gt===s||Zh>=P||Zh<0||Dn&&f0>=xe}function so(){var ml=jv();if(Wr(ml))return jo(ml);rt=xE(so,Qs(ml))}function jo(ml){return rt=s,Vi&&K?vr(ml):(K=pe=s,je)}function Vf(){rt!==s&&ON(rt),wn=0,K=gt=pe=rt=s}function wh(){return rt===s?je:jo(jv())}function zr(){var ml=jv(),Zh=Wr(ml);if(K=arguments,pe=this,gt=ml,Zh){if(rt===s)return Ur(gt);if(Dn)return ON(rt),rt=xE(so,P),vr(gt)}return rt===s&&(rt=xE(so,P)),je}return zr.cancel=Vf,zr.flush=wh,zr}var RF=ro(function(S,P){return mN(S,1,P)}),_Y=ro(function(S,P,U){return mN(S,Sp(P)||0,U)});function IF(S){return s0(S,Te)}function D2(S,P){if(typeof S!="function"||P!=null&&typeof P!="function")throw new vp(u);var U=function(){var K=arguments,pe=P?P.apply(this,K):K[0],xe=U.cache;if(xe.has(pe))return xe.get(pe);var je=S.apply(this,K);return U.cache=xe.set(pe,je)||xe,je};return U.cache=new(D2.Cache||i0),U}D2.Cache=i0;function hC(S){if(typeof S!="function")throw new vp(u);return function(){var P=arguments;switch(P.length){case 0:return!S.call(this);case 1:return!S.call(this,P[0]);case 2:return!S.call(this,P[0],P[1]);case 3:return!S.call(this,P[0],P[1],P[2])}return!S.apply(this,P)}}function yY(S){return Jb(2,S)}var xY=fX(function(S,P){P=P.length==1&&Rs(P[0])?kc(P[0],Pd(ns())):kc(mf(P,1),Pd(ns()));var U=P.length;return ro(function(K){for(var pe=-1,xe=Gf(K.length,U);++pe=P}),Vv=vN(function(){return arguments}())?vN:function(S){return Qc(S)&&ya.call(S,"callee")&&!oN.call(S,"callee")},Rs=Jt.isArray,BF=GO?Pd(GO):Jq;function bf(S){return S!=null&&pC(S.length)&&!l0(S)}function j(S){return Qc(S)&&bf(S)}function dC(S){return S===!0||S===!1||Qc(S)&&Bu(S)==$i}var Rd=lq||yC,OY=jO?Pd(jO):_N;function Wv(S){return Qc(S)&&S.nodeType===1&&!TE(S)}function OF(S){if(S==null)return!0;if(bf(S)&&(Rs(S)||typeof S=="string"||typeof S.splice=="function"||Rd(S)||B2(S)||Vv(S)))return!S.length;var P=jf(S);if(P==de||P==ve)return!S.size;if(yE(S))return!zk(S).length;for(var U in S)if(ya.call(S,U))return!1;return!0}function NY(S,P){return wE(S,P)}function FY(S,P,U){U=typeof U=="function"?U:s;var K=U?U(S,P):s;return K===s?wE(S,P,s,U):!!K}function wR(S){if(!Qc(S))return!1;var P=Bu(S);return P==Si||P==wr||typeof S.message=="string"&&typeof S.name=="string"&&!TE(S)}function UY(S){return typeof S=="number"&&cN(S)}function l0(S){if(!Uc(S))return!1;var P=Bu(S);return P==Fr||P==se||P==Yi||P==qi}function NF(S){return typeof S=="number"&&S==Ws(S)}function pC(S){return typeof S=="number"&&S>-1&&S%1==0&&S<=Tt}function Uc(S){var P=typeof S;return S!=null&&(P=="object"||P=="function")}function Qc(S){return S!=null&&typeof S=="object"}var FF=$O?Pd($O):yN;function vR(S,P){return S===P||Uk(S,P,iR(P))}function zY(S,P,U){return U=typeof U=="function"?U:s,Uk(S,P,iR(P),U)}function GY(S){return UF(S)&&S!=+S}function jY(S){if(oR(S))throw new Es(c);return xN(S)}function $Y(S){return S===null}function VY(S){return S==null}function UF(S){return typeof S=="number"||Qc(S)&&Bu(S)==it}function TE(S){if(!Qc(S)||Bu(S)!=En)return!1;var P=zT(S);if(P===null)return!0;var U=ya.call(P,"constructor")&&P.constructor;return typeof U=="function"&&U instanceof U&&OT.call(U)==iq}var Qb=VO?Pd(VO):Qq;function WY(S){return NF(S)&&S>=-Tt&&S<=Tt}var zF=WO?Pd(WO):eX;function gC(S){return typeof S=="string"||!Rs(S)&&Qc(S)&&Bu(S)==wt}function Id(S){return typeof S=="symbol"||Qc(S)&&Bu(S)==gn}var B2=HO?Pd(HO):tX;function HY(S){return S===s}function qY(S){return Qc(S)&&jf(S)==Mn}function XY(S){return Qc(S)&&Bu(S)==xi}var YY=sC(Gk),ZY=sC(function(S,P){return S<=P});function GF(S){if(!S)return[];if(bf(S))return gC(S)?wg(S):Xh(S);if(aE&&S[aE])return WH(S[aE]());var P=jf(S),U=P==de?kk:P==ve?RT:O2;return U(S)}function u0(S){if(!S)return S===0?S:0;if(S=Sp(S),S===ot||S===-ot){var P=S<0?-1:1;return P*jt}return S===S?S:0}function Ws(S){var P=u0(S),U=P%1;return P===P?U?P-U:P:0}function jF(S){return S?Fv(Ws(S),0,mn):0}function Sp(S){if(typeof S=="number")return S;if(Id(S))return en;if(Uc(S)){var P=typeof S.valueOf=="function"?S.valueOf():S;S=Uc(P)?P+"":P}if(typeof S!="string")return S===0?S:+S;S=JO(S);var U=Pe.test(S);return U||Kt.test(S)?AH(S.slice(2),U?2:8):bk.test(S)?en:+S}function $F(S){return Bm(S,Yh(S))}function KY(S){return S?Fv(Ws(S),-Tt,Tt):S===0?S:0}function xa(S){return S==null?"":Ld(S)}var JY=k2(function(S,P){if(yE(P)||bf(P)){Bm(P,Nu(P),S);return}for(var U in P)ya.call(P,U)&&hE(S,U,P[U])}),VF=k2(function(S,P){Bm(P,Yh(P),S)}),WF=k2(function(S,P,U,K){Bm(P,Yh(P),S,K)}),_R=k2(function(S,P,U,K){Bm(P,Nu(P),S,K)}),QY=o0(Ok);function eZ(S,P){var U=P2(S);return P==null?U:pN(U,P)}var tZ=ro(function(S,P){S=Ha(S);var U=-1,K=P.length,pe=K>2?P[2]:s;for(pe&&$f(P[0],P[1],pe)&&(K=1);++U1),xe}),Bm(S,tR(S),U),K&&(U=yp(U,T|M|L,xX));for(var pe=P.length;pe--;)qk(U,P[pe]);return U});function bZ(S,P){return qF(S,hC(ns(P)))}var mC=o0(function(S,P){return S==null?{}:jk(S,P)});function qF(S,P){if(S==null)return{};var U=kc(tR(S),function(K){return[K]});return P=ns(P),AN(S,U,function(K,pe){return P(K,pe[0])})}function wZ(S,P,U){P=Yb(P,S);var K=-1,pe=P.length;for(pe||(pe=1,S=s);++KP){var K=S;S=P,P=K}if(U||S%1||P%1){var pe=lN();return Gf(S+pe*(P-S+CH("1e-"+((pe+"").length-1))),P)}return Vk(S,P)}var AZ=R2(function(S,P,U){return P=P.toLowerCase(),S+(U?ZF(P):P)});function ZF(S){return SR(xa(S).toLowerCase())}function KF(S){return S=xa(S),S&&S.replace(Yt,zH).replace(bH,"")}function PZ(S,P,U){S=xa(S),P=Ld(P);var K=S.length;U=U===s?K:Fv(Ws(U),0,K);var pe=U;return U-=P.length,U>=0&&S.slice(U,pe)==P}function LZ(S){return S=xa(S),S&&ei.test(S)?S.replace(Je,GH):S}function kZ(S){return S=xa(S),S&&Xi.test(S)?S.replace(Ei,"\\$&"):S}var RZ=R2(function(S,P,U){return S+(U?"-":"")+P.toLowerCase()}),IZ=R2(function(S,P,U){return S+(U?" ":"")+P.toLowerCase()}),DZ=VN("toLowerCase");function BZ(S,P,U){S=xa(S),P=Ws(P);var K=P?M2(S):0;if(!P||K>=P)return S;var pe=(P-K)/2;return rC(VT(pe),U)+S+rC($T(pe),U)}function OZ(S,P,U){S=xa(S),P=Ws(P);var K=P?M2(S):0;return P&&K>>0,U?(S=xa(S),S&&(typeof P=="string"||P!=null&&!Qb(P))&&(P=Ld(P),!P&&S2(S))?Zb(wg(S),0,U):S.split(P,U)):[]}var $Z=R2(function(S,P,U){return S+(U?" ":"")+SR(P)});function JF(S,P,U){return S=xa(S),U=U==null?0:Fv(Ws(U),0,S.length),P=Ld(P),S.slice(U,U+P.length)==P}function Sr(S,P,U){var K=_e.templateSettings;U&&$f(S,P,U)&&(P=s),S=xa(S),P=_R({},P,K,KN);var pe=_R({},P.imports,K.imports,KN),xe=Nu(pe),je=Lk(pe,xe);Ad(xe,function(Wr){if(Q1.test(Wr))throw new Es(b)});var rt,gt,wn=0,Sn=P.interpolate||Zi,Dn="__p += '",Vi=IT((P.escape||Zi).source+"|"+Sn.source+"|"+(Sn===Re?b2:Zi).source+"|"+(P.evaluate||Zi).source+"|$","g"),vr="//# sourceURL="+(ya.call(P,"sourceURL")?(P.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++xH+"]")+` -`;S.replace(Vi,function(Wr,so,jo,Vf,wh,zr){return jo||(jo=Vf),Dn+=S.slice(wn,zr).replace(Rr,jH),so&&(rt=!0,Dn+=`' + +`)}function kX(S){return Rs(S)||Vv(S)||!!(aN&&S&&S[aN])}function o0(S,P){var U=typeof S;return P=P??Tt,!!P&&(U=="number"||U!="symbol"&&tn.test(S))&&S>-1&&S%1==0&&S0){if(++P>=Qe)return arguments[0]}else P=0;return S.apply(s,arguments)}}function cC(S,P){var U=-1,K=S.length,pe=K-1;for(P=P===s?K:P;++U1?S[P-1]:s;return U=typeof U=="function"?(S.pop(),U):s,a0(S,U)});function SF(S){var P=_e(S);return P.__chain__=!0,P}function xde(S,P){return P(S),S}function gR(S,P){return P(S)}var Ede=s0(function(S){var P=S.length,U=P?S[0]:0,K=this.__wrapped__,pe=function(xe){return Ok(xe,S)};return P>1||this.__actions__.length||!(K instanceof Io)||!o0(U)?this.thru(pe):(K=K.slice(U,+U+(P?1:0)),K.__actions__.push({func:gR,args:[pe],thisArg:s}),new _p(K,this.__chain__).thru(function(xe){return P&&!xe.length&&xe.push(s),xe}))});function Sde(){return SF(this)}function Mde(){return new _p(this.value(),this.__chain__)}function Ou(){this.__values__===s&&(this.__values__=GF(this.value()));var S=this.__index__>=this.__values__.length,P=S?s:this.__values__[this.__index__++];return{done:S,value:P}}function Tde(){return this}function Cde(S){for(var P,U=this;U instanceof qT;){var K=fF(U);K.__index__=0,K.__values__=s,P?pe.__wrapped__=K:P=K;var pe=K;U=U.__wrapped__}return pe.__wrapped__=S,P}function Ade(){var S=this.__wrapped__;if(S instanceof Io){var P=S;return this.__actions__.length&&(P=new Io(this)),P=P.reverse(),P.__actions__.push({func:gR,args:[fR],thisArg:s}),new _p(P,this.__chain__)}return this.thru(fR)}function pY(){return DN(this.__wrapped__,this.__actions__)}var MF=tC(function(S,P,U){ya.call(S,U)?++S[U]:Im(S,U,1)});function Pde(S,P,U){var K=Rs(S)?qO:Hq;return U&&Vf(S,P,U)&&(P=s),K(S,ns(P,3))}function Lde(S,P){var U=Rs(S)?Gb:gE;return U(S,ns(P,3))}var TF=WN(dF),CF=WN(pF);function kde(S,P){return bf(mR(S,P),1)}function Rde(S,P){return bf(mR(S,P),ot)}function Ide(S,P,U){return U=U===s?1:Ws(U),bf(mR(S,P),U)}function gY(S,P){var U=Rs(S)?Ad:Hb;return U(S,ns(P,3))}function mY(S,P){var U=Rs(S)?kH:bN;return U(S,ns(P,3))}var Dde=tC(function(S,P,U){ya.call(S,U)?S[U].push(P):Im(S,U,[P])});function Bde(S,P,U,K){S=wf(S)?S:O2(S),U=U&&!K?Ws(U):0;var pe=S.length;return U<0&&(U=nu(pe+U,0)),gC(S)?U<=pe&&S.indexOf(P,U)>-1:!!pe&&E2(S,P,U)>-1}var Ode=ro(function(S,P,U){var K=-1,pe=typeof P=="function",xe=wf(S)?Jt(S.length):[];return Hb(S,function(je){xe[++K]=pe?Cd(P,je,U):bE(je,P,U)}),xe}),Nde=tC(function(S,P,U){Im(S,U,P)});function mR(S,P){var U=Rs(S)?kc:SN;return U(S,ns(P,3))}function Fde(S,P,U,K){return S==null?[]:(Rs(P)||(P=P==null?[]:[P]),U=K?s:U,Rs(U)||(U=U==null?[]:[U]),qb(S,P,U))}var Ude=tC(function(S,P,U){S[U?0:1].push(P)},function(){return[[],[]]});function zde(S,P,U){var K=Rs(S)?Sk:KO,pe=arguments.length<3;return K(S,ns(P,4),U,pe,Hb)}function Gde(S,P,U){var K=Rs(S)?RH:KO,pe=arguments.length<3;return K(S,ns(P,4),U,pe,bN)}function jde(S,P){var U=Rs(S)?Gb:gE;return U(S,hC(ns(P,3)))}function $de(S){var P=Rs(S)?dN:oX;return P(S)}function Vde(S,P,U){(U?Vf(S,P,U):P===s)?P=1:P=Ws(P);var K=Rs(S)?Gq:aX;return K(S,P)}function bY(S){var P=Rs(S)?jq:lX;return P(S)}function wY(S){if(S==null)return 0;if(wf(S))return gC(S)?M2(S):S.length;var P=$f(S);return P==de||P==ve?S.size:zk(S).length}function vY(S,P,U){var K=Rs(S)?Mk:uX;return U&&Vf(S,P,U)&&(P=s),K(S,ns(P,3))}var AF=ro(function(S,P){if(S==null)return[];var U=P.length;return U>1&&Vf(S,P[0],P[1])?P=[]:U>2&&Vf(P[0],P[1],P[2])&&(P=[P[0]]),qb(S,bf(P,1),[])}),jv=aq||function(){return Du.Date.now()};function uC(S,P){if(typeof P!="function")throw new vp(u);return S=Ws(S),function(){if(--S<1)return P.apply(this,arguments)}}function fC(S,P,U){return P=U?s:P,P=S&&P==null?S.length:P,r0(S,ne,s,s,s,s,P)}function Jb(S,P){var U;if(typeof P!="function")throw new vp(u);return S=Ws(S),function(){return--S>0&&(U=P.apply(this,arguments)),S<=1&&(P=s),U}}var Nm=ro(function(S,P,U){var K=F;if(U.length){var pe=$b(U,I2(Nm));K|=te}return r0(S,K,P,U,pe)}),PF=ro(function(S,P,U){var K=F|O;if(U.length){var pe=$b(U,I2(PF));K|=te}return r0(P,K,S,U,pe)});function LF(S,P,U){P=U?s:P;var K=r0(S,Z,s,s,s,s,s,P);return K.placeholder=LF.placeholder,K}function gr(S,P,U){P=U?s:P;var K=r0(S,H,s,s,s,s,s,P);return K.placeholder=gr.placeholder,K}function kF(S,P,U){var K,pe,xe,je,rt,gt,wn=0,Sn=!1,Dn=!1,Vi=!0;if(typeof S!="function")throw new vp(u);P=Sp(P)||0,Uc(U)&&(Sn=!!U.leading,Dn="maxWait"in U,xe=Dn?nu(Sp(U.maxWait)||0,P):xe,Vi="trailing"in U?!!U.trailing:Vi);function vr(ml){var Zh=K,u0=pe;return K=pe=s,wn=ml,je=S.apply(u0,Zh),je}function Ur(ml){return wn=ml,rt=xE(so,P),Sn?vr(ml):je}function Qs(ml){var Zh=ml-gt,u0=ml-wn,l8=P-Zh;return Dn?jf(l8,xe-u0):l8}function Wr(ml){var Zh=ml-gt,u0=ml-wn;return gt===s||Zh>=P||Zh<0||Dn&&u0>=xe}function so(){var ml=jv();if(Wr(ml))return jo(ml);rt=xE(so,Qs(ml))}function jo(ml){return rt=s,Vi&&K?vr(ml):(K=pe=s,je)}function Wf(){rt!==s&&ON(rt),wn=0,K=gt=pe=rt=s}function wh(){return rt===s?je:jo(jv())}function zr(){var ml=jv(),Zh=Wr(ml);if(K=arguments,pe=this,gt=ml,Zh){if(rt===s)return Ur(gt);if(Dn)return ON(rt),rt=xE(so,P),vr(gt)}return rt===s&&(rt=xE(so,P)),je}return zr.cancel=Wf,zr.flush=wh,zr}var RF=ro(function(S,P){return mN(S,1,P)}),_Y=ro(function(S,P,U){return mN(S,Sp(P)||0,U)});function IF(S){return r0(S,Te)}function D2(S,P){if(typeof S!="function"||P!=null&&typeof P!="function")throw new vp(u);var U=function(){var K=arguments,pe=P?P.apply(this,K):K[0],xe=U.cache;if(xe.has(pe))return xe.get(pe);var je=S.apply(this,K);return U.cache=xe.set(pe,je)||xe,je};return U.cache=new(D2.Cache||n0),U}D2.Cache=n0;function hC(S){if(typeof S!="function")throw new vp(u);return function(){var P=arguments;switch(P.length){case 0:return!S.call(this);case 1:return!S.call(this,P[0]);case 2:return!S.call(this,P[0],P[1]);case 3:return!S.call(this,P[0],P[1],P[2])}return!S.apply(this,P)}}function yY(S){return Jb(2,S)}var xY=fX(function(S,P){P=P.length==1&&Rs(P[0])?kc(P[0],Pd(ns())):kc(bf(P,1),Pd(ns()));var U=P.length;return ro(function(K){for(var pe=-1,xe=jf(K.length,U);++pe=P}),Vv=vN(function(){return arguments}())?vN:function(S){return Qc(S)&&ya.call(S,"callee")&&!oN.call(S,"callee")},Rs=Jt.isArray,BF=GO?Pd(GO):Jq;function wf(S){return S!=null&&pC(S.length)&&!c0(S)}function j(S){return Qc(S)&&wf(S)}function dC(S){return S===!0||S===!1||Qc(S)&&Bu(S)==$i}var Rd=lq||yC,OY=jO?Pd(jO):_N;function Wv(S){return Qc(S)&&S.nodeType===1&&!TE(S)}function OF(S){if(S==null)return!0;if(wf(S)&&(Rs(S)||typeof S=="string"||typeof S.splice=="function"||Rd(S)||B2(S)||Vv(S)))return!S.length;var P=$f(S);if(P==de||P==ve)return!S.size;if(yE(S))return!zk(S).length;for(var U in S)if(ya.call(S,U))return!1;return!0}function NY(S,P){return wE(S,P)}function FY(S,P,U){U=typeof U=="function"?U:s;var K=U?U(S,P):s;return K===s?wE(S,P,s,U):!!K}function wR(S){if(!Qc(S))return!1;var P=Bu(S);return P==Si||P==wr||typeof S.message=="string"&&typeof S.name=="string"&&!TE(S)}function UY(S){return typeof S=="number"&&cN(S)}function c0(S){if(!Uc(S))return!1;var P=Bu(S);return P==Fr||P==se||P==Yi||P==qi}function NF(S){return typeof S=="number"&&S==Ws(S)}function pC(S){return typeof S=="number"&&S>-1&&S%1==0&&S<=Tt}function Uc(S){var P=typeof S;return S!=null&&(P=="object"||P=="function")}function Qc(S){return S!=null&&typeof S=="object"}var FF=$O?Pd($O):yN;function vR(S,P){return S===P||Uk(S,P,iR(P))}function zY(S,P,U){return U=typeof U=="function"?U:s,Uk(S,P,iR(P),U)}function GY(S){return UF(S)&&S!=+S}function jY(S){if(oR(S))throw new Es(c);return xN(S)}function $Y(S){return S===null}function VY(S){return S==null}function UF(S){return typeof S=="number"||Qc(S)&&Bu(S)==it}function TE(S){if(!Qc(S)||Bu(S)!=En)return!1;var P=zT(S);if(P===null)return!0;var U=ya.call(P,"constructor")&&P.constructor;return typeof U=="function"&&U instanceof U&&OT.call(U)==iq}var Qb=VO?Pd(VO):Qq;function WY(S){return NF(S)&&S>=-Tt&&S<=Tt}var zF=WO?Pd(WO):eX;function gC(S){return typeof S=="string"||!Rs(S)&&Qc(S)&&Bu(S)==wt}function Id(S){return typeof S=="symbol"||Qc(S)&&Bu(S)==gn}var B2=HO?Pd(HO):tX;function HY(S){return S===s}function qY(S){return Qc(S)&&$f(S)==Mn}function XY(S){return Qc(S)&&Bu(S)==xi}var YY=sC(Gk),ZY=sC(function(S,P){return S<=P});function GF(S){if(!S)return[];if(wf(S))return gC(S)?wg(S):Xh(S);if(aE&&S[aE])return WH(S[aE]());var P=$f(S),U=P==de?kk:P==ve?RT:O2;return U(S)}function l0(S){if(!S)return S===0?S:0;if(S=Sp(S),S===ot||S===-ot){var P=S<0?-1:1;return P*jt}return S===S?S:0}function Ws(S){var P=l0(S),U=P%1;return P===P?U?P-U:P:0}function jF(S){return S?Fv(Ws(S),0,mn):0}function Sp(S){if(typeof S=="number")return S;if(Id(S))return en;if(Uc(S)){var P=typeof S.valueOf=="function"?S.valueOf():S;S=Uc(P)?P+"":P}if(typeof S!="string")return S===0?S:+S;S=JO(S);var U=Pe.test(S);return U||Kt.test(S)?AH(S.slice(2),U?2:8):bk.test(S)?en:+S}function $F(S){return Bm(S,Yh(S))}function KY(S){return S?Fv(Ws(S),-Tt,Tt):S===0?S:0}function xa(S){return S==null?"":Ld(S)}var JY=k2(function(S,P){if(yE(P)||wf(P)){Bm(P,Nu(P),S);return}for(var U in P)ya.call(P,U)&&hE(S,U,P[U])}),VF=k2(function(S,P){Bm(P,Yh(P),S)}),WF=k2(function(S,P,U,K){Bm(P,Yh(P),S,K)}),_R=k2(function(S,P,U,K){Bm(P,Nu(P),S,K)}),QY=s0(Ok);function eZ(S,P){var U=P2(S);return P==null?U:pN(U,P)}var tZ=ro(function(S,P){S=Ha(S);var U=-1,K=P.length,pe=K>2?P[2]:s;for(pe&&Vf(P[0],P[1],pe)&&(K=1);++U1),xe}),Bm(S,tR(S),U),K&&(U=yp(U,T|M|L,xX));for(var pe=P.length;pe--;)qk(U,P[pe]);return U});function bZ(S,P){return qF(S,hC(ns(P)))}var mC=s0(function(S,P){return S==null?{}:jk(S,P)});function qF(S,P){if(S==null)return{};var U=kc(tR(S),function(K){return[K]});return P=ns(P),AN(S,U,function(K,pe){return P(K,pe[0])})}function wZ(S,P,U){P=Yb(P,S);var K=-1,pe=P.length;for(pe||(pe=1,S=s);++KP){var K=S;S=P,P=K}if(U||S%1||P%1){var pe=lN();return jf(S+pe*(P-S+CH("1e-"+((pe+"").length-1))),P)}return Vk(S,P)}var AZ=R2(function(S,P,U){return P=P.toLowerCase(),S+(U?ZF(P):P)});function ZF(S){return SR(xa(S).toLowerCase())}function KF(S){return S=xa(S),S&&S.replace(Yt,zH).replace(bH,"")}function PZ(S,P,U){S=xa(S),P=Ld(P);var K=S.length;U=U===s?K:Fv(Ws(U),0,K);var pe=U;return U-=P.length,U>=0&&S.slice(U,pe)==P}function LZ(S){return S=xa(S),S&&ei.test(S)?S.replace(Je,GH):S}function kZ(S){return S=xa(S),S&&Xi.test(S)?S.replace(Ei,"\\$&"):S}var RZ=R2(function(S,P,U){return S+(U?"-":"")+P.toLowerCase()}),IZ=R2(function(S,P,U){return S+(U?" ":"")+P.toLowerCase()}),DZ=VN("toLowerCase");function BZ(S,P,U){S=xa(S),P=Ws(P);var K=P?M2(S):0;if(!P||K>=P)return S;var pe=(P-K)/2;return rC(VT(pe),U)+S+rC($T(pe),U)}function OZ(S,P,U){S=xa(S),P=Ws(P);var K=P?M2(S):0;return P&&K>>0,U?(S=xa(S),S&&(typeof P=="string"||P!=null&&!Qb(P))&&(P=Ld(P),!P&&S2(S))?Zb(wg(S),0,U):S.split(P,U)):[]}var $Z=R2(function(S,P,U){return S+(U?" ":"")+SR(P)});function JF(S,P,U){return S=xa(S),U=U==null?0:Fv(Ws(U),0,S.length),P=Ld(P),S.slice(U,U+P.length)==P}function Sr(S,P,U){var K=_e.templateSettings;U&&Vf(S,P,U)&&(P=s),S=xa(S),P=_R({},P,K,KN);var pe=_R({},P.imports,K.imports,KN),xe=Nu(pe),je=Lk(pe,xe);Ad(xe,function(Wr){if(J1.test(Wr))throw new Es(b)});var rt,gt,wn=0,Sn=P.interpolate||Zi,Dn="__p += '",Vi=IT((P.escape||Zi).source+"|"+Sn.source+"|"+(Sn===Re?b2:Zi).source+"|"+(P.evaluate||Zi).source+"|$","g"),vr="//# sourceURL="+(ya.call(P,"sourceURL")?(P.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++xH+"]")+` +`;S.replace(Vi,function(Wr,so,jo,Wf,wh,zr){return jo||(jo=Wf),Dn+=S.slice(wn,zr).replace(Rr,jH),so&&(rt=!0,Dn+=`' + __e(`+so+`) + '`),wh&&(gt=!0,Dn+=`'; `+wh+`; @@ -3334,18 +3334,18 @@ __p += '`),jo&&(Dn+=`' + `;var Ur=ya.call(P,"variable")&&P.variable;if(!Ur)Dn=`with (obj) { `+Dn+` } -`;else if(Q1.test(Ur))throw new Es(d);Dn=(gt?Dn.replace(Xn,""):Dn).replace(_i,"$1").replace(Hi,"$1;"),Dn="function("+(Ur||"obj")+`) { +`;else if(J1.test(Ur))throw new Es(d);Dn=(gt?Dn.replace(Xn,""):Dn).replace(_i,"$1").replace(Hi,"$1;"),Dn="function("+(Ur||"obj")+`) { `+(Ur?"":`obj || (obj = {}); `)+"var __t, __p = ''"+(rt?", __e = _.escape":"")+(gt?`, __j = Array.prototype.join; function print() { __p += __j.call(arguments, '') } `:`; `)+Dn+`return __p -}`;var Qs=QF(function(){return ta(xe,vr+"return "+Dn).apply(s,je)});if(Qs.source=Dn,wR(Qs))throw Qs;return Qs}function VZ(S){return xa(S).toLowerCase()}function WZ(S){return xa(S).toUpperCase()}function HZ(S,P,U){if(S=xa(S),S&&(U||P===s))return JO(S);if(!S||!(P=Ld(P)))return S;var K=wg(S),pe=wg(P),xe=QO(K,pe),je=eN(K,pe)+1;return Zb(K,xe,je).join("")}function qZ(S,P,U){if(S=xa(S),S&&(U||P===s))return S.slice(0,nN(S)+1);if(!S||!(P=Ld(P)))return S;var K=wg(S),pe=eN(K,wg(P))+1;return Zb(K,0,pe).join("")}function XZ(S,P,U){if(S=xa(S),S&&(U||P===s))return S.replace(cr,"");if(!S||!(P=Ld(P)))return S;var K=wg(S),pe=QO(K,wg(P));return Zb(K,pe).join("")}function YZ(S,P){var U=Q,K=ge;if(Uc(P)){var pe="separator"in P?P.separator:pe;U="length"in P?Ws(P.length):U,K="omission"in P?Ld(P.omission):K}S=xa(S);var xe=S.length;if(S2(S)){var je=wg(S);xe=je.length}if(U>=xe)return S;var rt=U-M2(K);if(rt<1)return K;var gt=je?Zb(je,0,rt).join(""):S.slice(0,rt);if(pe===s)return gt+K;if(je&&(rt+=gt.length-rt),Qb(pe)){if(S.slice(rt).search(pe)){var wn,Sn=gt;for(pe.global||(pe=IT(pe.source,xa(zb.exec(pe))+"g")),pe.lastIndex=0;wn=pe.exec(Sn);)var Dn=wn.index;gt=gt.slice(0,Dn===s?rt:Dn)}}else if(S.indexOf(Ld(pe),rt)!=rt){var Vi=gt.lastIndexOf(pe);Vi>-1&&(gt=gt.slice(0,Vi))}return gt+K}function ZZ(S){return S=xa(S),S&&Qn.test(S)?S.replace(_n,YH):S}var KZ=R2(function(S,P,U){return S+(U?" ":"")+P.toUpperCase()}),SR=VN("toUpperCase");function N2(S,P,U){return S=xa(S),P=U?s:P,P===s?VH(S)?JH(S):BH(S):S.match(P)||[]}var QF=ro(function(S,P){try{return Cd(S,s,P)}catch(U){return wR(U)?U:new Es(U)}}),bC=o0(function(S,P){return Ad(P,function(U){U=_g(U),Im(S,U,Nm(S[U],S))}),S});function wC(S){var P=S==null?0:S.length,U=ns();return S=P?kc(S,function(K){if(typeof K[1]!="function")throw new vp(u);return[U(K[0]),K[1]]}):[],ro(function(K){for(var pe=-1;++peTt)return[];var U=mn,K=Gf(S,mn);P=ns(P),S-=mn;for(var pe=Pk(K,P);++U0||P<0)?new Io(U):(S<0?U=U.takeRight(-S):S&&(U=U.drop(S)),P!==s&&(P=Ws(P),U=P<0?U.dropRight(-P):U.take(P-S)),U)},Io.prototype.takeRightWhile=function(S){return this.reverse().takeWhile(S).reverse()},Io.prototype.toArray=function(){return this.take(mn)},Dm(Io.prototype,function(S,P){var U=/^(?:filter|find|map|reject)|While$/.test(P),K=/^(?:head|last)$/.test(P),pe=_e[K?"take"+(P=="last"?"Right":""):P],xe=K||/^find/.test(P);pe&&(_e.prototype[P]=function(){var je=this.__wrapped__,rt=K?[1]:arguments,gt=je instanceof Io,wn=rt[0],Sn=gt||Rs(je),Dn=function(so){var jo=pe.apply(_e,jb([so],rt));return K&&Vi?jo[0]:jo};Sn&&U&&typeof wn=="function"&&wn.length!=1&&(gt=Sn=!1);var Vi=this.__chain__,vr=!!this.__actions__.length,Ur=xe&&!Vi,Qs=gt&&!vr;if(!xe&&Sn){je=Qs?je:new Io(this);var Wr=S.apply(je,rt);return Wr.__actions__.push({func:gR,args:[Dn],thisArg:s}),new _p(Wr,Vi)}return Ur&&Qs?S.apply(this,rt):(Wr=this.thru(Dn),Ur?K?Wr.value()[0]:Wr.value():Wr)})}),Ad(["pop","push","shift","sort","splice","unshift"],function(S){var P=DT[S],U=/^(?:push|sort|unshift)$/.test(S)?"tap":"thru",K=/^(?:pop|shift)$/.test(S);_e.prototype[S]=function(){var pe=arguments;if(K&&!this.__chain__){var xe=this.value();return P.apply(Rs(xe)?xe:[],pe)}return this[U](function(je){return P.apply(Rs(je)?je:[],pe)})}}),Dm(Io.prototype,function(S,P){var U=_e[P];if(U){var K=U.name+"";ya.call(A2,K)||(A2[K]=[]),A2[K].push({name:P,func:U})}}),A2[nC(s,O).name]=[{name:"wrapper",func:s}],Io.prototype.clone=_q,Io.prototype.reverse=yq,Io.prototype.value=xq,_e.prototype.at=Ede,_e.prototype.chain=Sde,_e.prototype.commit=Mde,_e.prototype.next=Ou,_e.prototype.plant=Cde,_e.prototype.reverse=Ade,_e.prototype.toJSON=_e.prototype.valueOf=_e.prototype.value=pY,_e.prototype.first=_e.prototype.head,aE&&(_e.prototype[aE]=Tde),_e},e0=QH();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Du._=e0,define(function(){return e0})):Dv?((Dv.exports=e0)._=e0,yk._=e0):Du._=e0}).call(NB)});var _W=Sd(vW=>{"use strict";Object.defineProperty(vW,"__esModule",{value:!0});var sfe=bW(),LIe=O4(),b_t;(function(s){s.skin=null;function n(x,T){var M=LIe.filter(x,function(L){if(L instanceof Array&&L[0]==="g")return L[1]["s:pid"].startsWith(T)});return M}s.getPortsWithPrefix=n;function r(x,T){var M=LIe.filter(x,function(L){var I=L[0];if(L instanceof Array&&I==="g"){var D=L[1];return T(D)}return!1});return M.map(function(L){return L[1]["s:pid"]})}function c(x){return r(x,function(T){return T["s:position"]?T["s:position"]==="top":!1})}s.getInputPids=c;function u(x){return r(x,function(T){return T["s:position"]?T["s:position"]==="bottom":!1})}s.getOutputPids=u;function d(x){return r(x,function(T){return T["s:dir"]?T["s:dir"]==="lateral":T["s:position"]?T["s:position"]==="left"||T["s:position"]==="right":!1})}s.getLateralPortPids=d;function b(x){var T=null;return sfe.traverse(s.skin,{enter:function(M,L){M.name==="s:alias"&&M.attr.val===x&&(T=L)}}),T==null&&sfe.traverse(s.skin,{enter:function(M){M.attr["s:type"]==="generic"&&(T=M)}}),T.full}s.findSkinType=b;function w(){var x=[];return sfe.t(s.skin,{enter:function(T){T.name==="s:low_priority_alias"&&x.push(T.attr.value)}}),x}s.getLowPriorityAliases=w;function _(){var x;return sfe.t(s.skin,{enter:function(T){T.name==="s:properties"?x=LIe.mapValues(T.attr,function(M){return isNaN(Number(M))?M==="true"?!0:M==="false"?!1:M:Number(M)}):T.name==="s:layoutEngine"&&(x.layoutEngine=T.attr)}}),x.layoutEngine||(x.layoutEngine={}),x}s.getProperties=_})(b_t=vW.Skin||(vW.Skin={}));vW.default=b_t});var w_t=Sd(RIe=>{"use strict";Object.defineProperty(RIe,"__esModule",{value:!0});var kIe;(function(s){var n;(function(b){b.Zero="0",b.One="1",b.X="x"})(n||(n={}));var r;(function(b){b.Input="input",b.Output="output"})(r=s.Direction||(s.Direction={}));function c(b){return b.port_directions?Object.keys(b.port_directions).filter(function(w){return b.port_directions[w]===r.Input}):[]}s.getInputPortPids=c;function u(b){return b.port_directions?Object.keys(b.port_directions).filter(function(w){return b.port_directions[w]===r.Output}):[]}s.getOutputPortPids=u;var d;(function(b){b[b.Hide=0]="Hide",b[b.NoHide=1]="NoHide"})(d||(d={}))})(kIe||(kIe={}));RIe.default=kIe});var v_t=Sd(DIe=>{"use strict";Object.defineProperty(DIe,"__esModule",{value:!0});var jsn=BIe(),IIe=O4(),$sn=function(){function s(n,r){this.key=n,this.value=r}return Object.defineProperty(s.prototype,"Key",{get:function(){return this.key},enumerable:!0,configurable:!0}),s.prototype.keyIn=function(n){return IIe.includes(n,this.key)},s.prototype.maxVal=function(){return IIe.max(IIe.map(this.value,function(n){return Number(n)}))},s.prototype.valString=function(){return","+this.value.join()+","},s.prototype.findConstants=function(n,r,c){var u=this,d="",b=[],w=this.value;return w.forEach(function(_,x){_==="0"||_==="1"?(r+=1,d+=_,w[x]=r,b.push(r)):b.length>0&&(u.assignConstant(d,b,x,n,c),d="",b=[])}),b.length>0&&this.assignConstant(d,b,w.length,n,c),r},s.prototype.getGenericElkPort=function(n,r,c){var u=this.parentNode.Key,d=this.parentNode.getTemplate()[1]["s:type"];if(n===0){var b={id:u+"."+this.key,width:1,height:1,x:Number(r[0][1]["s:x"]),y:Number(r[0][1]["s:y"])};return(d==="generic"||d==="join")&&c==="in"&&(b.labels=[{id:u+"."+this.key+".label",text:this.key,x:Number(r[0][2][1].x)-10,y:Number(r[0][2][1].y)-6,width:6*this.key.length,height:11}]),(d==="generic"||d==="split")&&c==="out"&&(b.labels=[{id:u+"."+this.key+".label",text:this.key,x:Number(r[0][2][1].x)-10,y:Number(r[0][2][1].y)-6,width:6*this.key.length,height:11}]),b}else{var w=Number(r[1][1]["s:y"])-Number(r[0][1]["s:y"]),b={id:u+"."+this.key,width:1,height:1,x:Number(r[0][1]["s:x"]),y:n*w+Number(r[0][1]["s:y"])};return d==="generic"&&(b.labels=[{id:u+"."+this.key+".label",text:this.key,x:Number(r[0][2][1].x)-10,y:Number(r[0][2][1].y)-6,width:6*this.key.length,height:11}]),b}},s.prototype.assignConstant=function(n,r,c,u,d){var b=this,w=n.split("").reverse().join("");if(u.hasOwnProperty(w)){var _=u[w],x=_.length;_.forEach(function(T,M){var L=c-x+M;b.value[L]=T})}else d.push(jsn.default.fromConstantInfo(w,r)),u[w]=r},s}();DIe.Port=$sn});var __t=Sd((Hai,ofe)=>{var Vsn=function(){"use strict";function s(T,M){return M!=null&&T instanceof M}var n;try{n=Map}catch{n=function(){}}var r;try{r=Set}catch{r=function(){}}var c;try{c=Promise}catch{c=function(){}}function u(T,M,L,I,D){typeof M=="object"&&(L=M.depth,I=M.prototype,D=M.includeNonEnumerable,M=M.circular);var F=[],O=[],z=typeof Buffer<"u";typeof M>"u"&&(M=!0),typeof L>"u"&&(L=1/0);function Z(H,te){if(H===null)return null;if(te===0)return H;var oe,ne;if(typeof H!="object")return H;if(s(H,n))oe=new n;else if(s(H,r))oe=new r;else if(s(H,c))oe=new c(function(tt,ot){H.then(function(Tt){tt(Z(Tt,te-1))},function(Tt){ot(Z(Tt,te-1))})});else if(u.__isArray(H))oe=[];else if(u.__isRegExp(H))oe=new RegExp(H.source,x(H)),H.lastIndex&&(oe.lastIndex=H.lastIndex);else if(u.__isDate(H))oe=new Date(H.getTime());else{if(z&&Buffer.isBuffer(H))return Buffer.allocUnsafe?oe=Buffer.allocUnsafe(H.length):oe=new Buffer(H.length),H.copy(oe),oe;s(H,Error)?oe=Object.create(H):typeof I>"u"?(ne=Object.getPrototypeOf(H),oe=Object.create(ne)):(oe=Object.create(I),ne=I)}if(M){var ue=F.indexOf(H);if(ue!=-1)return O[ue];F.push(H),O.push(oe)}s(H,n)&&H.forEach(function(tt,ot){var Tt=Z(ot,te-1),jt=Z(tt,te-1);oe.set(Tt,jt)}),s(H,r)&&H.forEach(function(tt){var ot=Z(tt,te-1);oe.add(ot)});for(var Te in H){var Q;ne&&(Q=Object.getOwnPropertyDescriptor(ne,Te)),!(Q&&Q.set==null)&&(oe[Te]=Z(H[Te],te-1))}if(Object.getOwnPropertySymbols)for(var ge=Object.getOwnPropertySymbols(H),Te=0;Te{"use strict";Object.defineProperty(UIe,"__esModule",{value:!0});var afe=zIe(),OIe=w_t(),fg=_W(),sT=v_t(),NIe=O4(),yW=__t(),cfe=bW(),Wsn=function(){function s(n,r,c,u,d){var b=this;this.key=n,this.type=r,this.inputPorts=c,this.outputPorts=u,this.attributes=d||{},c.forEach(function(w){w.parentNode=b}),u.forEach(function(w){w.parentNode=b})}return s.fromPort=function(n,r){var c=n.direction===OIe.default.Direction.Input;return c?new s(r,"$_inputExt_",[],[new sT.Port("Y",n.bits)],{}):new s(r,"$_outputExt_",[new sT.Port("A",n.bits)],[],{})},s.fromYosysCell=function(n,r){var c=fg.default.findSkinType(n.type),u=fg.default.getInputPids(c),d=fg.default.getOutputPids(c),b=NIe.map(n.connections,function(M,L){return new sT.Port(L,M)}),w=b.filter(function(M){return M.keyIn(u)}),_=b.filter(function(M){return M.keyIn(d)});if(w.length+_.length!==b.length){var x=OIe.default.getInputPortPids(n),T=OIe.default.getOutputPortPids(n);w=b.filter(function(M){return M.keyIn(x)}),_=b.filter(function(M){return M.keyIn(T)})}return new s(r,n.type,w,_,n.attributes)},s.fromConstantInfo=function(n,r){return new s(n,"$_constant_",[],[new sT.Port("Y",r)],{})},s.fromJoinInfo=function(n,r){var c=n.slice(1,-1).split(","),u=c.map(function(w){return Number(w)}),d=[new sT.Port("Y",u)],b=r.map(function(w){return new sT.Port(w,y_t(u,w))});return new s("$join$"+n,"$_join_",b,d,{})},s.fromSplitInfo=function(n,r){var c=n.slice(1,-1).split(","),u=c.map(function(w){return Number(w)}),d=[new sT.Port("A",u)],b=r.map(function(w){var _=y_t(u,w);return new sT.Port(w,_)});return new s("$split$"+n,"$_split_",d,b,{})},Object.defineProperty(s.prototype,"Type",{get:function(){return this.type},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"Key",{get:function(){return this.key},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"InputPorts",{get:function(){return this.inputPorts},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"OutputPorts",{get:function(){return this.outputPorts},enumerable:!0,configurable:!0}),s.prototype.maxOutVal=function(n){var r=NIe.max(this.outputPorts.map(function(c){return c.maxVal()}));return NIe.max([r,n])},s.prototype.findConstants=function(n,r,c){return this.inputPorts.forEach(function(u){r=u.findConstants(n,r,c)}),r},s.prototype.inputPortVals=function(){return this.inputPorts.map(function(n){return n.valString()})},s.prototype.outputPortVals=function(){return this.outputPorts.map(function(n){return n.valString()})},s.prototype.collectPortsByDirection=function(n,r,c,u){var d=fg.default.findSkinType(this.type),b=fg.default.getLateralPortPids(d);this.inputPorts.forEach(function(w){var _=w.keyIn(b);_||d[1]["s:type"]==="generic"&&u?afe.addToDefaultDict(c,w.valString(),w):afe.addToDefaultDict(n,w.valString(),w)}),this.outputPorts.forEach(function(w){var _=w.keyIn(b);_||d[1]["s:type"]==="generic"&&u?afe.addToDefaultDict(c,w.valString(),w):afe.addToDefaultDict(r,w.valString(),w)})},s.prototype.getValueAttribute=function(){return this.attributes&&this.attributes.value?this.attributes.value:null},s.prototype.getTemplate=function(){return fg.default.findSkinType(this.type)},s.prototype.buildElkChild=function(){var n=this,r=this.getTemplate(),c=r[1]["s:type"],u={"org.eclipse.elk.portConstraints":"FIXED_POS"},d=null,b=null;for(var w in this.attributes)if(w.startsWith("org.eclipse.elk")){if(w==="org.eclipse.elk.x"){d=this.attributes[w];continue}if(w==="org.eclipse.elk.y"){b=this.attributes[w];continue}u[w]=this.attributes[w]}if(c==="join"||c==="split"||c==="generic"){var _=fg.default.getPortsWithPrefix(r,"in"),x=fg.default.getPortsWithPrefix(r,"out"),T=this.inputPorts.map(function(O,z){return O.getGenericElkPort(z,_,"in")}),M=this.outputPorts.map(function(O,z){return O.getGenericElkPort(z,x,"out")}),L={id:this.key,width:Number(r[1]["s:width"]),height:Number(this.getGenericHeight()),ports:T.concat(M),layoutOptions:u,labels:[]};return d&&(L.x=d),b&&(L.y=b),this.addLabels(r,L),L}var I=fg.default.getPortsWithPrefix(r,"").map(function(O){return{id:n.key+"."+O[1]["s:pid"],width:0,height:0,x:Number(O[1]["s:x"]),y:Number(O[1]["s:y"])}}),D=Number(r[1]["s:width"]),F={id:this.key,width:D,height:Number(r[1]["s:height"]),ports:I,layoutOptions:u,labels:[]};return d&&(F.x=d),b&&(F.y=b),this.addLabels(r,F),F},s.prototype.render=function(n){for(var r=this.getTemplate(),c=yW(r),u=0,d=n.labels;u3){var w=parseInt(c.key,2);b="0x"+w.toString(16)}else b=c.key;c.attributes[d]=c.key}else if(d in c.attributes)b=c.attributes[d];else return;r.labels.push({id:c.key+".label."+d,text:b,x:u.attr.x,y:u.attr.y-6,height:11,width:6*b.length})}}})},s.prototype.getGenericHeight=function(){var n=this.getTemplate(),r=fg.default.getPortsWithPrefix(n,"in"),c=fg.default.getPortsWithPrefix(n,"out");if(this.inputPorts.length>this.outputPorts.length){var u=Number(r[1][1]["s:y"])-Number(r[0][1]["s:y"]);return Number(n[1]["s:height"])+u*(this.inputPorts.length-2)}if(c.length>1){var u=Number(c[1][1]["s:y"])-Number(c[0][1]["s:y"]);return Number(n[1]["s:height"])+u*(this.outputPorts.length-2)}return Number(n[1]["s:height"])},s}();UIe.default=Wsn;function FIe(s,n){cfe.traverse(s,{enter:function(r){r.name==="rect"&&r.attr["s:generic"]==="body"&&(r.attr.height=n)}})}function Hsn(s,n,r){cfe.traverse(s,{enter:function(c){c.name==="text"&&c.attr["s:attribute"]===n&&(c.full[2]=r)}})}function qsn(s,n,r){cfe.traverse(s,{enter:function(c){var u=c.attr.class;u&&u.includes(n)&&(c.attr.class=u.replace(n,r))}})}function y_t(s,n){var r=n.indexOf(":");if(r===-1)return[s[Number(n)]];var c=n.slice(0,r),u=n.slice(r+1),d=s.slice(Number(c),Number(u)+1);return d}});var zIe=Sd(FB=>{"use strict";Object.defineProperty(FB,"__esModule",{value:!0});var Xsn=_W(),lfe=BIe(),V1=O4(),Ysn=function(){function s(n){var r=this;this.moduleName=null,V1.forEach(n.modules,function(b,w){b.attributes&&Number(b.attributes.top)===1&&(r.moduleName=w)}),this.moduleName==null&&(this.moduleName=Object.keys(n.modules)[0]);var c=n.modules[this.moduleName],u=V1.map(c.ports,lfe.default.fromPort),d=V1.map(c.cells,function(b,w){return lfe.default.fromYosysCell(b,w)});this.nodes=d.concat(u),this.wires=[]}return s.prototype.addConstants=function(){var n=this.nodes.reduce(function(u,d){return d.maxOutVal(u)},-1),r={},c=[];this.nodes.forEach(function(u){n=u.findConstants(r,n,c)}),this.nodes=this.nodes.concat(c)},s.prototype.addSplitsJoins=function(){var n=V1.flatMap(this.nodes,function(b){return b.inputPortVals()}),r=V1.flatMap(this.nodes,function(b){return b.outputPortVals()}),c=n.slice(),u={},d={};n.forEach(function(b){EW(r,c,b,0,b.length,u,d)}),this.nodes=this.nodes.concat(V1.map(d,function(b,w){return lfe.default.fromJoinInfo(w,b)})).concat(V1.map(u,function(b,w){return lfe.default.fromSplitInfo(w,b)}))},s.prototype.createWires=function(){var n=Xsn.default.getProperties(),r={},c={},u={};this.nodes.forEach(function(w){w.collectPortsByDirection(r,c,u,n.genericsLaterals)});var d=S_t(V1.keys(r).concat(V1.keys(c)).concat(V1.keys(u))),b=d.map(function(w){var _=c[w]||[],x=r[w]||[],T=u[w]||[],M={netName:w,drivers:_,riders:x,laterals:T};return _.concat(x).concat(T).forEach(function(L){L.wire=M}),M});this.wires=b},s}();FB.FlatModule=Ysn;function Zsn(s){var n="";return s.forEach(function(r){var c=String(r);n===""?n=c:n+=","+c}),","+n+","}FB.arrayToBitstring=Zsn;function E_t(s,n){return n.indexOf(s)>-1}function x_t(s,n){return V1.findIndex(n,function(r){return E_t(s,r)})}function xW(s,n,r){s[n]===void 0?s[n]=[r]:s[n].push(r)}FB.addToDefaultDict=xW;function ufe(s,n,r){var c=V1.max([s.indexOf(n),r]),u=s.substring(0,c).split(",").length-1,d=u+n.split(",").length-3;return u===d?String(u):String(u)+":"+String(d)}function EW(s,n,r,c,u,d,b){var w=n.indexOf(r);if(w!==-1&&n.splice(w,1),!(c>=r.length||u-c<2)){var _=r.slice(c,u);if(E_t(_,s)){_!==r&&xW(b,r,ufe(r,_,c)),EW(s,n,r,u-1,r.length,d,b);return}var x=x_t(_,s);if(x!==-1){_!==r&&xW(b,r,ufe(r,_,c)),xW(d,s[x],ufe(s[x],_,0)),s.push(_),EW(s,n,r,u-1,r.length,d,b);return}if(x_t(_,n)!==-1){_!==r&&xW(b,r,ufe(r,_,c)),EW(s,[],_,0,_.length,d,b),s.push(_);return}EW(s,n,r,c,c+_.slice(0,-1).lastIndexOf(",")+1,d,b)}}function S_t(s){var n={};return s.forEach(function(r){n[r]=!0}),V1.keys(n)}FB.removeDups=S_t});var jIe=Sd(SW=>{"use strict";Object.defineProperty(SW,"__esModule",{value:!0});var T_t=O4(),Wh;(function(s){s.wireNameLookup={},s.dummyNum=0,s.edgeIndex=0})(Wh=SW.ElkModel||(SW.ElkModel={}));function Ksn(s){var n=s.nodes.map(function(c){return c.buildElkChild()});Wh.edgeIndex=0,Wh.dummyNum=0;var r=T_t.flatMap(s.wires,function(c){if(c.drivers.length>0&&c.riders.length>0&&c.laterals.length===0){var u=[];return GIe(c.drivers,c.riders,u),u}else if(c.drivers.concat(c.riders).length>0&&c.laterals.length>0){var u=[];return GIe(c.drivers,c.laterals,u),GIe(c.laterals,c.riders,u),u}else if(c.riders.length===0&&c.drivers.length>1){var d=M_t(n);Wh.dummyNum+=1;var b=c.drivers.map(function(M){var L=M.parentNode.Key,I="e"+String(Wh.edgeIndex);Wh.edgeIndex+=1;var D={id:I,source:L,sourcePort:L+"."+M.key,target:d,targetPort:d+".p"};return Wh.wireNameLookup[I]=M.wire.netName,D});return b}else if(c.riders.length>1&&c.drivers.length===0){var w=M_t(n);Wh.dummyNum+=1;var b=c.riders.map(function(L){var I=L.parentNode.Key,D="e"+String(Wh.edgeIndex);Wh.edgeIndex+=1;var F={id:D,source:w,sourcePort:w+".p",target:I,targetPort:I+"."+L.key};return Wh.wireNameLookup[D]=L.wire.netName,F});return b}else if(c.laterals.length>1){var _=c.laterals[0],x=_.parentNode.Key,T=c.laterals.slice(1).map(function(M){var L=M.parentNode.Key,I="e"+String(Wh.edgeIndex);Wh.edgeIndex+=1;var D={id:I,source:x,sourcePort:x+"."+_.key,target:L,targetPort:L+"."+M.key};return Wh.wireNameLookup[I]=M.wire.netName,D});return T}return[]});return{id:s.moduleName,children:n,edges:r}}SW.buildElkGraph=Ksn;function M_t(s){var n="$d_"+String(Wh.dummyNum),r={id:n,width:0,height:0,ports:[{id:n+".p",width:0,height:0}],layoutOptions:{"org.eclipse.elk.portConstraints":"FIXED_SIDE"}};return s.push(r),n}function GIe(s,n,r){var c=T_t.flatMap(s,function(u){var d=u.parentNode.key,b=d+"."+u.key;return n.map(function(w){var _=w.parentNode.key,x=_+"."+w.key,T="e"+Wh.edgeIndex,M={id:T,sources:[b],targets:[x]};return Wh.wireNameLookup[T]=w.wire.netName,u.parentNode.type!=="$dff"&&(M.layoutOptions={"org.eclipse.elk.layered.priority.direction":10}),Wh.edgeIndex+=1,M})});r.push.apply(r,c)}});var k_t=Sd(zB=>{"use strict";var C_t=zB&&zB.__spreadArrays||function(){for(var s=0,n=0,r=arguments.length;n0?[z.bendPoints[0]]:z.endPoint:z.bendPoints&&z.bendPoints.length>0?[u2.last(z.bendPoints)]:z.startPoint}).map(function(O){return O.x>x.x?UB.Right:O.xx.y?UB.Down:UB.Up}));F.size<3&&d.forEach(function(O){O.junctionPoints&&(O.junctionPoints=O.junctionPoints.filter(function(z){return!u2.isEqual(z,x)}))}),n+=1};n<1e4;){var c=r();if(c==="break")break}}zB.removeDummyEdges=L_t});var O_t=Sd(hfe=>{"use strict";Object.defineProperty(hfe,"__esModule",{value:!0});var ton=r_t(),non=bW(),ion=zIe(),ffe=_W(),I_t=jIe(),R_t=k_t(),D_t=new ton;function B_t(s,n){ffe.default.skin=non.p(s);var r=ffe.default.getProperties(),c=new ion.FlatModule(n);return r.constants!==!1&&c.addConstants(),r.splitsAndJoins!==!1&&c.addSplitsJoins(),c.createWires(),c}function ron(s,n,r,c){var u=B_t(s,n),d=I_t.buildElkGraph(u);if(r){c(null,JSON.stringify(d,null,2));return}var b=ffe.default.getProperties(),w=D_t.layout(d,{layoutOptions:b.layoutEngine});w.then(function(_){c(null,JSON.stringify(_,null,2))}).catch(function(_){throw Error(_)})}hfe.dumpLayout=ron;function son(s,n,r,c){var u=B_t(s,n),d=I_t.buildElkGraph(u),b=ffe.default.getProperties(),w;return c?w=new Promise(function(_){R_t.default(c,u),_()}):w=D_t.layout(d,{layoutOptions:b.layoutEngine}).then(function(_){return R_t.default(_,u)}).catch(function(_){console.error(_)}),typeof r=="function"&&w.then(function(_){return r(null,_),_}).catch(function(_){throw Error(_)}),w}hfe.render=son});function IM(s,n){if(!s)throw new Error(n||"loader assertion failed.")}var Ny={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},BVt=Ny.self||Ny.window||Ny.global||{},OVt=Ny.window||Ny.self||Ny.global||{},NVt=Ny.global||Ny.self||Ny.window||{},FVt=Ny.document||{};var $L=!!(typeof process!="object"||String(process)!=="[object process]"||process.browser);var zut=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),UVt=zut&&parseFloat(zut[1])||0;Hj();var APe="4.5.4",qVt=APe[0]>="0"&&APe[0]<="9"?`v${APe}`:"";function XVt(){let s=new ig({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=s,globalThis.loaders.version=qVt,globalThis.probe||={},globalThis.probe.loaders=s,s}var PPe=XVt();var YVt=s=>typeof s=="boolean",Uy=s=>typeof s=="function",zy=s=>s!==null&&typeof s=="object",Zae=s=>zy(s)&&s.constructor==={}.constructor;var LPe=s=>typeof SharedArrayBuffer<"u"&&s instanceof SharedArrayBuffer,kD=s=>zy(s)&&typeof s.byteLength=="number"&&typeof s.slice=="function";var kPe=s=>!!s&&Uy(s[Symbol.iterator]),RPe=s=>!!s&&Uy(s[Symbol.asyncIterator]);var B1=s=>typeof Response<"u"&&s instanceof Response||zy(s)&&Uy(s.arrayBuffer)&&Uy(s.text)&&Uy(s.json);var O1=s=>typeof Blob<"u"&&s instanceof Blob;var nft=s=>typeof ReadableStream<"u"&&s instanceof ReadableStream||zy(s)&&Uy(s.tee)&&Uy(s.cancel)&&Uy(s.getReader);var ift=s=>zy(s)&&Uy(s.read)&&Uy(s.pipe)&&YVt(s.readable),qj=s=>nft(s)||ift(s);function IPe(s,n){return rft(s||{},n)}function rft(s,n,r=0){if(r>3)return n;let c={...s};for(let[u,d]of Object.entries(n))d&&typeof d=="object"&&!Array.isArray(d)?c[u]=rft(c[u]||{},n[u],r+1):c[u]=n[u];return c}var sft="latest";function ZVt(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.5.4"),globalThis._loadersgl_.version}var oft=ZVt();function rg(s,n){if(!s)throw new Error(n||"loaders.gl assertion failed.")}var Gy={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},YDn=Gy.self||Gy.window||Gy.global||{},ZDn=Gy.window||Gy.self||Gy.global||{},KDn=Gy.global||Gy.self||Gy.window||{},JDn=Gy.document||{};var xb=typeof process!="object"||String(process)!=="[object process]"||process.browser;var cft=typeof window<"u"&&typeof window.orientation<"u",aft=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),QDn=aft&&parseFloat(aft[1])||0;var Xj=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(n,r){this.name=n,this.workerThread=r,this.result=new Promise((c,u)=>{this._resolve=c,this._reject=u})}postMessage(n,r){this.workerThread.postMessage({source:"loaders.gl",type:n,payload:r})}done(n){rg(this.isRunning),this.isRunning=!1,this._resolve(n)}error(n){rg(this.isRunning),this.isRunning=!1,this._reject(n)}};var RD=class{terminate(){}};var DPe=new Map;function lft(s){rg(s.source&&!s.url||!s.source&&s.url);let n=DPe.get(s.source||s.url);return n||(s.url&&(n=KVt(s.url),DPe.set(s.url,n)),s.source&&(n=uft(s.source),DPe.set(s.source,n))),rg(n),n}function KVt(s){if(!s.startsWith("http"))return s;let n=JVt(s);return uft(n)}function uft(s){let n=new Blob([s],{type:"application/javascript"});return URL.createObjectURL(n)}function JVt(s){return`try { +}`;var Qs=QF(function(){return ta(xe,vr+"return "+Dn).apply(s,je)});if(Qs.source=Dn,wR(Qs))throw Qs;return Qs}function VZ(S){return xa(S).toLowerCase()}function WZ(S){return xa(S).toUpperCase()}function HZ(S,P,U){if(S=xa(S),S&&(U||P===s))return JO(S);if(!S||!(P=Ld(P)))return S;var K=wg(S),pe=wg(P),xe=QO(K,pe),je=eN(K,pe)+1;return Zb(K,xe,je).join("")}function qZ(S,P,U){if(S=xa(S),S&&(U||P===s))return S.slice(0,nN(S)+1);if(!S||!(P=Ld(P)))return S;var K=wg(S),pe=eN(K,wg(P))+1;return Zb(K,0,pe).join("")}function XZ(S,P,U){if(S=xa(S),S&&(U||P===s))return S.replace(cr,"");if(!S||!(P=Ld(P)))return S;var K=wg(S),pe=QO(K,wg(P));return Zb(K,pe).join("")}function YZ(S,P){var U=Q,K=ge;if(Uc(P)){var pe="separator"in P?P.separator:pe;U="length"in P?Ws(P.length):U,K="omission"in P?Ld(P.omission):K}S=xa(S);var xe=S.length;if(S2(S)){var je=wg(S);xe=je.length}if(U>=xe)return S;var rt=U-M2(K);if(rt<1)return K;var gt=je?Zb(je,0,rt).join(""):S.slice(0,rt);if(pe===s)return gt+K;if(je&&(rt+=gt.length-rt),Qb(pe)){if(S.slice(rt).search(pe)){var wn,Sn=gt;for(pe.global||(pe=IT(pe.source,xa(zb.exec(pe))+"g")),pe.lastIndex=0;wn=pe.exec(Sn);)var Dn=wn.index;gt=gt.slice(0,Dn===s?rt:Dn)}}else if(S.indexOf(Ld(pe),rt)!=rt){var Vi=gt.lastIndexOf(pe);Vi>-1&&(gt=gt.slice(0,Vi))}return gt+K}function ZZ(S){return S=xa(S),S&&Qn.test(S)?S.replace(_n,YH):S}var KZ=R2(function(S,P,U){return S+(U?" ":"")+P.toUpperCase()}),SR=VN("toUpperCase");function N2(S,P,U){return S=xa(S),P=U?s:P,P===s?VH(S)?JH(S):BH(S):S.match(P)||[]}var QF=ro(function(S,P){try{return Cd(S,s,P)}catch(U){return wR(U)?U:new Es(U)}}),bC=s0(function(S,P){return Ad(P,function(U){U=_g(U),Im(S,U,Nm(S[U],S))}),S});function wC(S){var P=S==null?0:S.length,U=ns();return S=P?kc(S,function(K){if(typeof K[1]!="function")throw new vp(u);return[U(K[0]),K[1]]}):[],ro(function(K){for(var pe=-1;++peTt)return[];var U=mn,K=jf(S,mn);P=ns(P),S-=mn;for(var pe=Pk(K,P);++U0||P<0)?new Io(U):(S<0?U=U.takeRight(-S):S&&(U=U.drop(S)),P!==s&&(P=Ws(P),U=P<0?U.dropRight(-P):U.take(P-S)),U)},Io.prototype.takeRightWhile=function(S){return this.reverse().takeWhile(S).reverse()},Io.prototype.toArray=function(){return this.take(mn)},Dm(Io.prototype,function(S,P){var U=/^(?:filter|find|map|reject)|While$/.test(P),K=/^(?:head|last)$/.test(P),pe=_e[K?"take"+(P=="last"?"Right":""):P],xe=K||/^find/.test(P);pe&&(_e.prototype[P]=function(){var je=this.__wrapped__,rt=K?[1]:arguments,gt=je instanceof Io,wn=rt[0],Sn=gt||Rs(je),Dn=function(so){var jo=pe.apply(_e,jb([so],rt));return K&&Vi?jo[0]:jo};Sn&&U&&typeof wn=="function"&&wn.length!=1&&(gt=Sn=!1);var Vi=this.__chain__,vr=!!this.__actions__.length,Ur=xe&&!Vi,Qs=gt&&!vr;if(!xe&&Sn){je=Qs?je:new Io(this);var Wr=S.apply(je,rt);return Wr.__actions__.push({func:gR,args:[Dn],thisArg:s}),new _p(Wr,Vi)}return Ur&&Qs?S.apply(this,rt):(Wr=this.thru(Dn),Ur?K?Wr.value()[0]:Wr.value():Wr)})}),Ad(["pop","push","shift","sort","splice","unshift"],function(S){var P=DT[S],U=/^(?:push|sort|unshift)$/.test(S)?"tap":"thru",K=/^(?:pop|shift)$/.test(S);_e.prototype[S]=function(){var pe=arguments;if(K&&!this.__chain__){var xe=this.value();return P.apply(Rs(xe)?xe:[],pe)}return this[U](function(je){return P.apply(Rs(je)?je:[],pe)})}}),Dm(Io.prototype,function(S,P){var U=_e[P];if(U){var K=U.name+"";ya.call(A2,K)||(A2[K]=[]),A2[K].push({name:P,func:U})}}),A2[nC(s,O).name]=[{name:"wrapper",func:s}],Io.prototype.clone=_q,Io.prototype.reverse=yq,Io.prototype.value=xq,_e.prototype.at=Ede,_e.prototype.chain=Sde,_e.prototype.commit=Mde,_e.prototype.next=Ou,_e.prototype.plant=Cde,_e.prototype.reverse=Ade,_e.prototype.toJSON=_e.prototype.valueOf=_e.prototype.value=pY,_e.prototype.first=_e.prototype.head,aE&&(_e.prototype[aE]=Tde),_e},Q1=QH();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Du._=Q1,define(function(){return Q1})):Dv?((Dv.exports=Q1)._=Q1,yk._=Q1):Du._=Q1}).call(NB)});var _W=Sd(vW=>{"use strict";Object.defineProperty(vW,"__esModule",{value:!0});var sfe=bW(),LIe=O4(),b_t;(function(s){s.skin=null;function n(x,T){var M=LIe.filter(x,function(L){if(L instanceof Array&&L[0]==="g")return L[1]["s:pid"].startsWith(T)});return M}s.getPortsWithPrefix=n;function r(x,T){var M=LIe.filter(x,function(L){var I=L[0];if(L instanceof Array&&I==="g"){var D=L[1];return T(D)}return!1});return M.map(function(L){return L[1]["s:pid"]})}function c(x){return r(x,function(T){return T["s:position"]?T["s:position"]==="top":!1})}s.getInputPids=c;function u(x){return r(x,function(T){return T["s:position"]?T["s:position"]==="bottom":!1})}s.getOutputPids=u;function d(x){return r(x,function(T){return T["s:dir"]?T["s:dir"]==="lateral":T["s:position"]?T["s:position"]==="left"||T["s:position"]==="right":!1})}s.getLateralPortPids=d;function b(x){var T=null;return sfe.traverse(s.skin,{enter:function(M,L){M.name==="s:alias"&&M.attr.val===x&&(T=L)}}),T==null&&sfe.traverse(s.skin,{enter:function(M){M.attr["s:type"]==="generic"&&(T=M)}}),T.full}s.findSkinType=b;function w(){var x=[];return sfe.t(s.skin,{enter:function(T){T.name==="s:low_priority_alias"&&x.push(T.attr.value)}}),x}s.getLowPriorityAliases=w;function _(){var x;return sfe.t(s.skin,{enter:function(T){T.name==="s:properties"?x=LIe.mapValues(T.attr,function(M){return isNaN(Number(M))?M==="true"?!0:M==="false"?!1:M:Number(M)}):T.name==="s:layoutEngine"&&(x.layoutEngine=T.attr)}}),x.layoutEngine||(x.layoutEngine={}),x}s.getProperties=_})(b_t=vW.Skin||(vW.Skin={}));vW.default=b_t});var w_t=Sd(RIe=>{"use strict";Object.defineProperty(RIe,"__esModule",{value:!0});var kIe;(function(s){var n;(function(b){b.Zero="0",b.One="1",b.X="x"})(n||(n={}));var r;(function(b){b.Input="input",b.Output="output"})(r=s.Direction||(s.Direction={}));function c(b){return b.port_directions?Object.keys(b.port_directions).filter(function(w){return b.port_directions[w]===r.Input}):[]}s.getInputPortPids=c;function u(b){return b.port_directions?Object.keys(b.port_directions).filter(function(w){return b.port_directions[w]===r.Output}):[]}s.getOutputPortPids=u;var d;(function(b){b[b.Hide=0]="Hide",b[b.NoHide=1]="NoHide"})(d||(d={}))})(kIe||(kIe={}));RIe.default=kIe});var v_t=Sd(DIe=>{"use strict";Object.defineProperty(DIe,"__esModule",{value:!0});var Wsn=BIe(),IIe=O4(),Hsn=function(){function s(n,r){this.key=n,this.value=r}return Object.defineProperty(s.prototype,"Key",{get:function(){return this.key},enumerable:!0,configurable:!0}),s.prototype.keyIn=function(n){return IIe.includes(n,this.key)},s.prototype.maxVal=function(){return IIe.max(IIe.map(this.value,function(n){return Number(n)}))},s.prototype.valString=function(){return","+this.value.join()+","},s.prototype.findConstants=function(n,r,c){var u=this,d="",b=[],w=this.value;return w.forEach(function(_,x){_==="0"||_==="1"?(r+=1,d+=_,w[x]=r,b.push(r)):b.length>0&&(u.assignConstant(d,b,x,n,c),d="",b=[])}),b.length>0&&this.assignConstant(d,b,w.length,n,c),r},s.prototype.getGenericElkPort=function(n,r,c){var u=this.parentNode.Key,d=this.parentNode.getTemplate()[1]["s:type"];if(n===0){var b={id:u+"."+this.key,width:1,height:1,x:Number(r[0][1]["s:x"]),y:Number(r[0][1]["s:y"])};return(d==="generic"||d==="join")&&c==="in"&&(b.labels=[{id:u+"."+this.key+".label",text:this.key,x:Number(r[0][2][1].x)-10,y:Number(r[0][2][1].y)-6,width:6*this.key.length,height:11}]),(d==="generic"||d==="split")&&c==="out"&&(b.labels=[{id:u+"."+this.key+".label",text:this.key,x:Number(r[0][2][1].x)-10,y:Number(r[0][2][1].y)-6,width:6*this.key.length,height:11}]),b}else{var w=Number(r[1][1]["s:y"])-Number(r[0][1]["s:y"]),b={id:u+"."+this.key,width:1,height:1,x:Number(r[0][1]["s:x"]),y:n*w+Number(r[0][1]["s:y"])};return d==="generic"&&(b.labels=[{id:u+"."+this.key+".label",text:this.key,x:Number(r[0][2][1].x)-10,y:Number(r[0][2][1].y)-6,width:6*this.key.length,height:11}]),b}},s.prototype.assignConstant=function(n,r,c,u,d){var b=this,w=n.split("").reverse().join("");if(u.hasOwnProperty(w)){var _=u[w],x=_.length;_.forEach(function(T,M){var L=c-x+M;b.value[L]=T})}else d.push(Wsn.default.fromConstantInfo(w,r)),u[w]=r},s}();DIe.Port=Hsn});var __t=Sd((Zai,ofe)=>{var qsn=function(){"use strict";function s(T,M){return M!=null&&T instanceof M}var n;try{n=Map}catch{n=function(){}}var r;try{r=Set}catch{r=function(){}}var c;try{c=Promise}catch{c=function(){}}function u(T,M,L,I,D){typeof M=="object"&&(L=M.depth,I=M.prototype,D=M.includeNonEnumerable,M=M.circular);var F=[],O=[],z=typeof Buffer<"u";typeof M>"u"&&(M=!0),typeof L>"u"&&(L=1/0);function Z(H,te){if(H===null)return null;if(te===0)return H;var oe,ne;if(typeof H!="object")return H;if(s(H,n))oe=new n;else if(s(H,r))oe=new r;else if(s(H,c))oe=new c(function(tt,ot){H.then(function(Tt){tt(Z(Tt,te-1))},function(Tt){ot(Z(Tt,te-1))})});else if(u.__isArray(H))oe=[];else if(u.__isRegExp(H))oe=new RegExp(H.source,x(H)),H.lastIndex&&(oe.lastIndex=H.lastIndex);else if(u.__isDate(H))oe=new Date(H.getTime());else{if(z&&Buffer.isBuffer(H))return Buffer.allocUnsafe?oe=Buffer.allocUnsafe(H.length):oe=new Buffer(H.length),H.copy(oe),oe;s(H,Error)?oe=Object.create(H):typeof I>"u"?(ne=Object.getPrototypeOf(H),oe=Object.create(ne)):(oe=Object.create(I),ne=I)}if(M){var ue=F.indexOf(H);if(ue!=-1)return O[ue];F.push(H),O.push(oe)}s(H,n)&&H.forEach(function(tt,ot){var Tt=Z(ot,te-1),jt=Z(tt,te-1);oe.set(Tt,jt)}),s(H,r)&&H.forEach(function(tt){var ot=Z(tt,te-1);oe.add(ot)});for(var Te in H){var Q;ne&&(Q=Object.getOwnPropertyDescriptor(ne,Te)),!(Q&&Q.set==null)&&(oe[Te]=Z(H[Te],te-1))}if(Object.getOwnPropertySymbols)for(var ge=Object.getOwnPropertySymbols(H),Te=0;Te{"use strict";Object.defineProperty(UIe,"__esModule",{value:!0});var afe=zIe(),OIe=w_t(),fg=_W(),sT=v_t(),NIe=O4(),yW=__t(),cfe=bW(),Xsn=function(){function s(n,r,c,u,d){var b=this;this.key=n,this.type=r,this.inputPorts=c,this.outputPorts=u,this.attributes=d||{},c.forEach(function(w){w.parentNode=b}),u.forEach(function(w){w.parentNode=b})}return s.fromPort=function(n,r){var c=n.direction===OIe.default.Direction.Input;return c?new s(r,"$_inputExt_",[],[new sT.Port("Y",n.bits)],{}):new s(r,"$_outputExt_",[new sT.Port("A",n.bits)],[],{})},s.fromYosysCell=function(n,r){var c=fg.default.findSkinType(n.type),u=fg.default.getInputPids(c),d=fg.default.getOutputPids(c),b=NIe.map(n.connections,function(M,L){return new sT.Port(L,M)}),w=b.filter(function(M){return M.keyIn(u)}),_=b.filter(function(M){return M.keyIn(d)});if(w.length+_.length!==b.length){var x=OIe.default.getInputPortPids(n),T=OIe.default.getOutputPortPids(n);w=b.filter(function(M){return M.keyIn(x)}),_=b.filter(function(M){return M.keyIn(T)})}return new s(r,n.type,w,_,n.attributes)},s.fromConstantInfo=function(n,r){return new s(n,"$_constant_",[],[new sT.Port("Y",r)],{})},s.fromJoinInfo=function(n,r){var c=n.slice(1,-1).split(","),u=c.map(function(w){return Number(w)}),d=[new sT.Port("Y",u)],b=r.map(function(w){return new sT.Port(w,y_t(u,w))});return new s("$join$"+n,"$_join_",b,d,{})},s.fromSplitInfo=function(n,r){var c=n.slice(1,-1).split(","),u=c.map(function(w){return Number(w)}),d=[new sT.Port("A",u)],b=r.map(function(w){var _=y_t(u,w);return new sT.Port(w,_)});return new s("$split$"+n,"$_split_",d,b,{})},Object.defineProperty(s.prototype,"Type",{get:function(){return this.type},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"Key",{get:function(){return this.key},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"InputPorts",{get:function(){return this.inputPorts},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"OutputPorts",{get:function(){return this.outputPorts},enumerable:!0,configurable:!0}),s.prototype.maxOutVal=function(n){var r=NIe.max(this.outputPorts.map(function(c){return c.maxVal()}));return NIe.max([r,n])},s.prototype.findConstants=function(n,r,c){return this.inputPorts.forEach(function(u){r=u.findConstants(n,r,c)}),r},s.prototype.inputPortVals=function(){return this.inputPorts.map(function(n){return n.valString()})},s.prototype.outputPortVals=function(){return this.outputPorts.map(function(n){return n.valString()})},s.prototype.collectPortsByDirection=function(n,r,c,u){var d=fg.default.findSkinType(this.type),b=fg.default.getLateralPortPids(d);this.inputPorts.forEach(function(w){var _=w.keyIn(b);_||d[1]["s:type"]==="generic"&&u?afe.addToDefaultDict(c,w.valString(),w):afe.addToDefaultDict(n,w.valString(),w)}),this.outputPorts.forEach(function(w){var _=w.keyIn(b);_||d[1]["s:type"]==="generic"&&u?afe.addToDefaultDict(c,w.valString(),w):afe.addToDefaultDict(r,w.valString(),w)})},s.prototype.getValueAttribute=function(){return this.attributes&&this.attributes.value?this.attributes.value:null},s.prototype.getTemplate=function(){return fg.default.findSkinType(this.type)},s.prototype.buildElkChild=function(){var n=this,r=this.getTemplate(),c=r[1]["s:type"],u={"org.eclipse.elk.portConstraints":"FIXED_POS"},d=null,b=null;for(var w in this.attributes)if(w.startsWith("org.eclipse.elk")){if(w==="org.eclipse.elk.x"){d=this.attributes[w];continue}if(w==="org.eclipse.elk.y"){b=this.attributes[w];continue}u[w]=this.attributes[w]}if(c==="join"||c==="split"||c==="generic"){var _=fg.default.getPortsWithPrefix(r,"in"),x=fg.default.getPortsWithPrefix(r,"out"),T=this.inputPorts.map(function(O,z){return O.getGenericElkPort(z,_,"in")}),M=this.outputPorts.map(function(O,z){return O.getGenericElkPort(z,x,"out")}),L={id:this.key,width:Number(r[1]["s:width"]),height:Number(this.getGenericHeight()),ports:T.concat(M),layoutOptions:u,labels:[]};return d&&(L.x=d),b&&(L.y=b),this.addLabels(r,L),L}var I=fg.default.getPortsWithPrefix(r,"").map(function(O){return{id:n.key+"."+O[1]["s:pid"],width:0,height:0,x:Number(O[1]["s:x"]),y:Number(O[1]["s:y"])}}),D=Number(r[1]["s:width"]),F={id:this.key,width:D,height:Number(r[1]["s:height"]),ports:I,layoutOptions:u,labels:[]};return d&&(F.x=d),b&&(F.y=b),this.addLabels(r,F),F},s.prototype.render=function(n){for(var r=this.getTemplate(),c=yW(r),u=0,d=n.labels;u3){var w=parseInt(c.key,2);b="0x"+w.toString(16)}else b=c.key;c.attributes[d]=c.key}else if(d in c.attributes)b=c.attributes[d];else return;r.labels.push({id:c.key+".label."+d,text:b,x:u.attr.x,y:u.attr.y-6,height:11,width:6*b.length})}}})},s.prototype.getGenericHeight=function(){var n=this.getTemplate(),r=fg.default.getPortsWithPrefix(n,"in"),c=fg.default.getPortsWithPrefix(n,"out");if(this.inputPorts.length>this.outputPorts.length){var u=Number(r[1][1]["s:y"])-Number(r[0][1]["s:y"]);return Number(n[1]["s:height"])+u*(this.inputPorts.length-2)}if(c.length>1){var u=Number(c[1][1]["s:y"])-Number(c[0][1]["s:y"]);return Number(n[1]["s:height"])+u*(this.outputPorts.length-2)}return Number(n[1]["s:height"])},s}();UIe.default=Xsn;function FIe(s,n){cfe.traverse(s,{enter:function(r){r.name==="rect"&&r.attr["s:generic"]==="body"&&(r.attr.height=n)}})}function Ysn(s,n,r){cfe.traverse(s,{enter:function(c){c.name==="text"&&c.attr["s:attribute"]===n&&(c.full[2]=r)}})}function Zsn(s,n,r){cfe.traverse(s,{enter:function(c){var u=c.attr.class;u&&u.includes(n)&&(c.attr.class=u.replace(n,r))}})}function y_t(s,n){var r=n.indexOf(":");if(r===-1)return[s[Number(n)]];var c=n.slice(0,r),u=n.slice(r+1),d=s.slice(Number(c),Number(u)+1);return d}});var zIe=Sd(FB=>{"use strict";Object.defineProperty(FB,"__esModule",{value:!0});var Ksn=_W(),lfe=BIe(),V1=O4(),Jsn=function(){function s(n){var r=this;this.moduleName=null,V1.forEach(n.modules,function(b,w){b.attributes&&Number(b.attributes.top)===1&&(r.moduleName=w)}),this.moduleName==null&&(this.moduleName=Object.keys(n.modules)[0]);var c=n.modules[this.moduleName],u=V1.map(c.ports,lfe.default.fromPort),d=V1.map(c.cells,function(b,w){return lfe.default.fromYosysCell(b,w)});this.nodes=d.concat(u),this.wires=[]}return s.prototype.addConstants=function(){var n=this.nodes.reduce(function(u,d){return d.maxOutVal(u)},-1),r={},c=[];this.nodes.forEach(function(u){n=u.findConstants(r,n,c)}),this.nodes=this.nodes.concat(c)},s.prototype.addSplitsJoins=function(){var n=V1.flatMap(this.nodes,function(b){return b.inputPortVals()}),r=V1.flatMap(this.nodes,function(b){return b.outputPortVals()}),c=n.slice(),u={},d={};n.forEach(function(b){EW(r,c,b,0,b.length,u,d)}),this.nodes=this.nodes.concat(V1.map(d,function(b,w){return lfe.default.fromJoinInfo(w,b)})).concat(V1.map(u,function(b,w){return lfe.default.fromSplitInfo(w,b)}))},s.prototype.createWires=function(){var n=Ksn.default.getProperties(),r={},c={},u={};this.nodes.forEach(function(w){w.collectPortsByDirection(r,c,u,n.genericsLaterals)});var d=S_t(V1.keys(r).concat(V1.keys(c)).concat(V1.keys(u))),b=d.map(function(w){var _=c[w]||[],x=r[w]||[],T=u[w]||[],M={netName:w,drivers:_,riders:x,laterals:T};return _.concat(x).concat(T).forEach(function(L){L.wire=M}),M});this.wires=b},s}();FB.FlatModule=Jsn;function Qsn(s){var n="";return s.forEach(function(r){var c=String(r);n===""?n=c:n+=","+c}),","+n+","}FB.arrayToBitstring=Qsn;function E_t(s,n){return n.indexOf(s)>-1}function x_t(s,n){return V1.findIndex(n,function(r){return E_t(s,r)})}function xW(s,n,r){s[n]===void 0?s[n]=[r]:s[n].push(r)}FB.addToDefaultDict=xW;function ufe(s,n,r){var c=V1.max([s.indexOf(n),r]),u=s.substring(0,c).split(",").length-1,d=u+n.split(",").length-3;return u===d?String(u):String(u)+":"+String(d)}function EW(s,n,r,c,u,d,b){var w=n.indexOf(r);if(w!==-1&&n.splice(w,1),!(c>=r.length||u-c<2)){var _=r.slice(c,u);if(E_t(_,s)){_!==r&&xW(b,r,ufe(r,_,c)),EW(s,n,r,u-1,r.length,d,b);return}var x=x_t(_,s);if(x!==-1){_!==r&&xW(b,r,ufe(r,_,c)),xW(d,s[x],ufe(s[x],_,0)),s.push(_),EW(s,n,r,u-1,r.length,d,b);return}if(x_t(_,n)!==-1){_!==r&&xW(b,r,ufe(r,_,c)),EW(s,[],_,0,_.length,d,b),s.push(_);return}EW(s,n,r,c,c+_.slice(0,-1).lastIndexOf(",")+1,d,b)}}function S_t(s){var n={};return s.forEach(function(r){n[r]=!0}),V1.keys(n)}FB.removeDups=S_t});var jIe=Sd(SW=>{"use strict";Object.defineProperty(SW,"__esModule",{value:!0});var T_t=O4(),Wh;(function(s){s.wireNameLookup={},s.dummyNum=0,s.edgeIndex=0})(Wh=SW.ElkModel||(SW.ElkModel={}));function eon(s){var n=s.nodes.map(function(c){return c.buildElkChild()});Wh.edgeIndex=0,Wh.dummyNum=0;var r=T_t.flatMap(s.wires,function(c){if(c.drivers.length>0&&c.riders.length>0&&c.laterals.length===0){var u=[];return GIe(c.drivers,c.riders,u),u}else if(c.drivers.concat(c.riders).length>0&&c.laterals.length>0){var u=[];return GIe(c.drivers,c.laterals,u),GIe(c.laterals,c.riders,u),u}else if(c.riders.length===0&&c.drivers.length>1){var d=M_t(n);Wh.dummyNum+=1;var b=c.drivers.map(function(M){var L=M.parentNode.Key,I="e"+String(Wh.edgeIndex);Wh.edgeIndex+=1;var D={id:I,source:L,sourcePort:L+"."+M.key,target:d,targetPort:d+".p"};return Wh.wireNameLookup[I]=M.wire.netName,D});return b}else if(c.riders.length>1&&c.drivers.length===0){var w=M_t(n);Wh.dummyNum+=1;var b=c.riders.map(function(L){var I=L.parentNode.Key,D="e"+String(Wh.edgeIndex);Wh.edgeIndex+=1;var F={id:D,source:w,sourcePort:w+".p",target:I,targetPort:I+"."+L.key};return Wh.wireNameLookup[D]=L.wire.netName,F});return b}else if(c.laterals.length>1){var _=c.laterals[0],x=_.parentNode.Key,T=c.laterals.slice(1).map(function(M){var L=M.parentNode.Key,I="e"+String(Wh.edgeIndex);Wh.edgeIndex+=1;var D={id:I,source:x,sourcePort:x+"."+_.key,target:L,targetPort:L+"."+M.key};return Wh.wireNameLookup[I]=M.wire.netName,D});return T}return[]});return{id:s.moduleName,children:n,edges:r}}SW.buildElkGraph=eon;function M_t(s){var n="$d_"+String(Wh.dummyNum),r={id:n,width:0,height:0,ports:[{id:n+".p",width:0,height:0}],layoutOptions:{"org.eclipse.elk.portConstraints":"FIXED_SIDE"}};return s.push(r),n}function GIe(s,n,r){var c=T_t.flatMap(s,function(u){var d=u.parentNode.key,b=d+"."+u.key;return n.map(function(w){var _=w.parentNode.key,x=_+"."+w.key,T="e"+Wh.edgeIndex,M={id:T,sources:[b],targets:[x]};return Wh.wireNameLookup[T]=w.wire.netName,u.parentNode.type!=="$dff"&&(M.layoutOptions={"org.eclipse.elk.layered.priority.direction":10}),Wh.edgeIndex+=1,M})});r.push.apply(r,c)}});var k_t=Sd(zB=>{"use strict";var C_t=zB&&zB.__spreadArrays||function(){for(var s=0,n=0,r=arguments.length;n0?[z.bendPoints[0]]:z.endPoint:z.bendPoints&&z.bendPoints.length>0?[u2.last(z.bendPoints)]:z.startPoint}).map(function(O){return O.x>x.x?UB.Right:O.xx.y?UB.Down:UB.Up}));F.size<3&&d.forEach(function(O){O.junctionPoints&&(O.junctionPoints=O.junctionPoints.filter(function(z){return!u2.isEqual(z,x)}))}),n+=1};n<1e4;){var c=r();if(c==="break")break}}zB.removeDummyEdges=L_t});var O_t=Sd(hfe=>{"use strict";Object.defineProperty(hfe,"__esModule",{value:!0});var ron=r_t(),son=bW(),oon=zIe(),ffe=_W(),I_t=jIe(),R_t=k_t(),D_t=new ron;function B_t(s,n){ffe.default.skin=son.p(s);var r=ffe.default.getProperties(),c=new oon.FlatModule(n);return r.constants!==!1&&c.addConstants(),r.splitsAndJoins!==!1&&c.addSplitsJoins(),c.createWires(),c}function aon(s,n,r,c){var u=B_t(s,n),d=I_t.buildElkGraph(u);if(r){c(null,JSON.stringify(d,null,2));return}var b=ffe.default.getProperties(),w=D_t.layout(d,{layoutOptions:b.layoutEngine});w.then(function(_){c(null,JSON.stringify(_,null,2))}).catch(function(_){throw Error(_)})}hfe.dumpLayout=aon;function con(s,n,r,c){var u=B_t(s,n),d=I_t.buildElkGraph(u),b=ffe.default.getProperties(),w;return c?w=new Promise(function(_){R_t.default(c,u),_()}):w=D_t.layout(d,{layoutOptions:b.layoutEngine}).then(function(_){return R_t.default(_,u)}).catch(function(_){console.error(_)}),typeof r=="function"&&w.then(function(_){return r(null,_),_}).catch(function(_){throw Error(_)}),w}hfe.render=con});function IM(s,n){if(!s)throw new Error(n||"loader assertion failed.")}var Ny={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},FVt=Ny.self||Ny.window||Ny.global||{},UVt=Ny.window||Ny.self||Ny.global||{},zVt=Ny.global||Ny.self||Ny.window||{},GVt=Ny.document||{};var $L=!!(typeof process!="object"||String(process)!=="[object process]"||process.browser);var zut=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),jVt=zut&&parseFloat(zut[1])||0;Hj();var APe="4.5.4",ZVt=APe[0]>="0"&&APe[0]<="9"?`v${APe}`:"";function KVt(){let s=new ig({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=s,globalThis.loaders.version=ZVt,globalThis.probe||={},globalThis.probe.loaders=s,s}var PPe=KVt();var JVt=s=>typeof s=="boolean",Uy=s=>typeof s=="function",zy=s=>s!==null&&typeof s=="object",Zae=s=>zy(s)&&s.constructor==={}.constructor;var LPe=s=>typeof SharedArrayBuffer<"u"&&s instanceof SharedArrayBuffer,kD=s=>zy(s)&&typeof s.byteLength=="number"&&typeof s.slice=="function";var kPe=s=>!!s&&Uy(s[Symbol.iterator]),RPe=s=>!!s&&Uy(s[Symbol.asyncIterator]);var B1=s=>typeof Response<"u"&&s instanceof Response||zy(s)&&Uy(s.arrayBuffer)&&Uy(s.text)&&Uy(s.json);var O1=s=>typeof Blob<"u"&&s instanceof Blob;var nft=s=>typeof ReadableStream<"u"&&s instanceof ReadableStream||zy(s)&&Uy(s.tee)&&Uy(s.cancel)&&Uy(s.getReader);var ift=s=>zy(s)&&Uy(s.read)&&Uy(s.pipe)&&JVt(s.readable),qj=s=>nft(s)||ift(s);function IPe(s,n){return rft(s||{},n)}function rft(s,n,r=0){if(r>3)return n;let c={...s};for(let[u,d]of Object.entries(n))d&&typeof d=="object"&&!Array.isArray(d)?c[u]=rft(c[u]||{},n[u],r+1):c[u]=n[u];return c}var sft="latest";function QVt(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.5.4"),globalThis._loadersgl_.version}var oft=QVt();function rg(s,n){if(!s)throw new Error(n||"loaders.gl assertion failed.")}var Gy={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},QDn=Gy.self||Gy.window||Gy.global||{},eBn=Gy.window||Gy.self||Gy.global||{},tBn=Gy.global||Gy.self||Gy.window||{},nBn=Gy.document||{};var yb=typeof process!="object"||String(process)!=="[object process]"||process.browser;var cft=typeof window<"u"&&typeof window.orientation<"u",aft=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),iBn=aft&&parseFloat(aft[1])||0;var Xj=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(n,r){this.name=n,this.workerThread=r,this.result=new Promise((c,u)=>{this._resolve=c,this._reject=u})}postMessage(n,r){this.workerThread.postMessage({source:"loaders.gl",type:n,payload:r})}done(n){rg(this.isRunning),this.isRunning=!1,this._resolve(n)}error(n){rg(this.isRunning),this.isRunning=!1,this._reject(n)}};var RD=class{terminate(){}};var DPe=new Map;function lft(s){rg(s.source&&!s.url||!s.source&&s.url);let n=DPe.get(s.source||s.url);return n||(s.url&&(n=eWt(s.url),DPe.set(s.url,n)),s.source&&(n=uft(s.source),DPe.set(s.source,n))),rg(n),n}function eWt(s){if(!s.startsWith("http"))return s;let n=tWt(s);return uft(n)}function uft(s){let n=new Blob([s],{type:"application/javascript"});return URL.createObjectURL(n)}function tWt(s){return`try { importScripts('${s}'); } catch (error) { console.error(error); throw error; -}`}function BPe(s,n=!0,r){let c=r||new Set;if(s){if(fft(s))c.add(s);else if(fft(s.buffer))c.add(s.buffer);else if(!ArrayBuffer.isView(s)){if(n&&typeof s=="object")for(let u in s)BPe(s[u],n,c)}}return r===void 0?Array.from(c):[]}function fft(s){return s?s instanceof ArrayBuffer||typeof MessagePort<"u"&&s instanceof MessagePort||typeof ImageBitmap<"u"&&s instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas:!1}var OPe=()=>{},DM=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&xb||typeof RD<"u"&&!xb}constructor(n){let{name:r,source:c,url:u}=n;rg(c||u),this.name=r,this.source=c,this.url=u,this.onMessage=OPe,this.onError=d=>console.log(d),this.worker=xb?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=OPe,this.onError=OPe,this.worker.terminate(),this.terminated=!0}get isRunning(){return!!this.onMessage}postMessage(n,r){r=r||BPe(n),this.worker.postMessage(n,r)}_getErrorFromErrorEvent(n){let r="Failed to load ";return r+=`worker ${this.name} from ${this.url}. `,n.message&&(r+=`${n.message} in `),n.lineno&&(r+=`:${n.lineno}:${n.colno}`),new Error(r)}_createBrowserWorker(){this._loadableURL=lft({source:this.source,url:this.url});let n=new Worker(this._loadableURL,{name:this.name});return n.onmessage=r=>{r.data?this.onMessage(r.data):this.onError(new Error("No data received"))},n.onerror=r=>{this.onError(this._getErrorFromErrorEvent(r)),this.terminated=!0},n.onmessageerror=r=>console.error(r),n}_createNodeWorker(){let n;if(this.url){let c=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`,u=this.url.endsWith(".ts")||this.url.endsWith(".mjs")?"module":"commonjs";n=new RD(c,{eval:!1,type:u})}else if(this.source)n=new RD(this.source,{eval:!0});else throw new Error("no worker");return n.on("message",r=>{this.onMessage(r)}),n.on("error",r=>{this.onError(r)}),n.on("exit",r=>{}),n}};var Yj=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return DM.isSupported()}constructor(n){this.source=n.source,this.url=n.url,this.setProps(n)}destroy(){this.idleQueue.forEach(n=>n.destroy()),this.isDestroyed=!0}setProps(n){this.props={...this.props,...n},n.name!==void 0&&(this.name=n.name),n.maxConcurrency!==void 0&&(this.maxConcurrency=n.maxConcurrency),n.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=n.maxMobileConcurrency),n.reuseWorkers!==void 0&&(this.reuseWorkers=n.reuseWorkers),n.onDebug!==void 0&&(this.onDebug=n.onDebug)}async startJob(n,r=(u,d,b)=>u.done(b),c=(u,d)=>u.error(d)){let u=new Promise(d=>(this.jobQueue.push({name:n,onMessage:r,onError:c,onStart:d}),this));return this._startQueuedJob(),await u}async _startQueuedJob(){if(!this.jobQueue.length)return;let n=this._getAvailableWorker();if(!n)return;let r=this.jobQueue.shift();if(r){this.onDebug({message:"Starting job",name:r.name,workerThread:n,backlog:this.jobQueue.length});let c=new Xj(r.name,n);n.onMessage=u=>r.onMessage(c,u.type,u.payload),n.onError=u=>r.onError(c,u),r.onStart(c);try{await c.result}catch(u){console.error(`Worker exception: ${u}`)}finally{this.returnWorkerToQueue(n)}}}returnWorkerToQueue(n){!xb||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(n.destroy(),this.count--):this.idleQueue.push(n),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count{}},HL=class s{props;workerPools=new Map;static _workerFarm;static isSupported(){return DM.isSupported()}static getWorkerFarm(n={}){return s._workerFarm=s._workerFarm||new s({}),s._workerFarm.setProps(n),s._workerFarm}constructor(n){this.props={...QVt},this.setProps(n),this.workerPools=new Map}destroy(){for(let n of this.workerPools.values())n.destroy();this.workerPools=new Map}setProps(n){this.props={...this.props,...n};for(let r of this.workerPools.values())r.setProps(this._getWorkerPoolProps())}getWorkerPool(n){let{name:r,source:c,url:u}=n,d=this.workerPools.get(r);return d||(d=new Yj({name:r,source:c,url:u}),d.setProps(this._getWorkerPoolProps()),this.workerPools.set(r,d)),d}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}};function NPe(s,n={}){let r=n[s.id]||{},c=xb?s.workerFile||`${s.id}-worker.js`:`${s.id}-worker-node.js`,u=r.workerUrl;if(!u&&s.id==="compression"&&(u=n.workerUrl),(n._workerType||n?.core?._workerType)==="test"&&(xb?u=`modules/${s.module}/dist/${c}`:u=`modules/${s.module}/src/workers/${s.id}-worker-node.ts`),!u){let b=s.version;b==="latest"&&(b=sft);let w=b?`@${b}`:"";u=`loaders.gl-cdn-disabled/${s.module}${w}/dist/${c}`}return rg(u),u}function FPe(s,n=oft){rg(s,"no worker provided");let r=s.version;return!(!n||!r)}function UPe(s,n){if(!HL.isSupported())return!1;let r=n?._nodeWorkers??n?.core?._nodeWorkers;if(!xb&&!r)return!1;let c=n?.worker??n?.core?.worker;return!!(s.worker&&c)}async function zPe(s,n,r,c,u){let d=s.id,b=NPe(s,r),_=HL.getWorkerFarm(r?.core).getWorkerPool({name:d,url:b});r=JSON.parse(JSON.stringify(r||{})),r._workerLoaderId=s.id,c=JSON.parse(JSON.stringify(c||{}));let x=await _.startJob("process-on-worker",eWt.bind(null,u));return x.postMessage("process",{input:n,options:r,context:c}),await(await x.result).result}async function eWt(s,n,r,c){switch(r){case"done":n.done(c);break;case"error":n.error(new Error(c.error));break;case"process":let{id:u,input:d,options:b}=c;try{let w=await s(d,b);n.postMessage("done",{id:u,result:w})}catch(w){let _=w instanceof Error?w.message:"unknown error";n.postMessage("error",{id:u,error:_})}break;default:console.warn(`parse-with-worker unknown message ${r}`)}}function GPe(s,n,r){if(r=r||s.byteLength,s.byteLengthd instanceof ArrayBuffer?new Uint8Array(d):d),r=n.reduce((d,b)=>d+b.byteLength,0),c=new Uint8Array(r),u=0;for(let d of n)c.set(d,u),u+=d.byteLength;return c.buffer}async function $Pe(s){let n=[];for await(let r of s)n.push(tWt(r));return jPe(...n)}function tWt(s){if(s instanceof ArrayBuffer)return s;if(ArrayBuffer.isView(s)){let{buffer:n,byteOffset:r,byteLength:c}=s;return dft(n,r,c)}return dft(s)}function dft(s,n=0,r=s.byteLength-n){let c=new Uint8Array(s,n,r),u=new Uint8Array(c.length);return u.set(c),u.buffer}var nWt="",gft={};function HPe(s){for(let n in gft)if(s.startsWith(n)){let r=gft[n];s=s.replace(n,r)}return!s.startsWith("http://")&&!s.startsWith("https://")&&(s=`${nWt}${s}`),s}function Jae(s){return s&&typeof s=="object"&&s.isBuffer}function ID(s){if(Jae(s))return s;if(s instanceof ArrayBuffer)return s;if(LPe(s))return Kae(s);if(ArrayBuffer.isView(s)){let n=s.buffer;return s.byteOffset===0&&s.byteLength===s.buffer.byteLength?n:n.slice(s.byteOffset,s.byteOffset+s.byteLength)}if(typeof s=="string"){let n=s;return new TextEncoder().encode(n).buffer}if(s&&typeof s=="object"&&s._toArrayBuffer)return s._toArrayBuffer();throw new Error("toArrayBuffer")}function Jj(s){if(s instanceof ArrayBuffer)return s;if(LPe(s))return Kae(s);let{buffer:n,byteOffset:r,byteLength:c}=s;return n instanceof ArrayBuffer&&r===0&&c===n.byteLength?n:Kae(n,r,c)}function Kae(s,n=0,r=s.byteLength-n){let c=new Uint8Array(s,n,r),u=new Uint8Array(c.length);return u.set(c),u.buffer}function qPe(s){return ArrayBuffer.isView(s)?s:new Uint8Array(s)}var M3={};Oy(M3,{dirname:()=>rWt,filename:()=>iWt,join:()=>sWt,resolve:()=>oWt});function mft(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let s=window.location?.pathname;return s?.slice(0,s.lastIndexOf("/")+1)||""}function iWt(s){let n=s?s.lastIndexOf("/"):-1;return n>=0?s.substr(n+1):s}function rWt(s){let n=s?s.lastIndexOf("/"):-1;return n>=0?s.substr(0,n):""}function sWt(...s){let n="/";return s=s.map((r,c)=>(c&&(r=r.replace(new RegExp(`^${n}`),"")),c!==s.length-1&&(r=r.replace(new RegExp(`${n}$`),"")),r)),s.join(n)}function oWt(...s){let n=[];for(let d=0;d=-1&&!c;d--){let b;d>=0?b=n[d]:(u===void 0&&(u=mft()),b=u),b.length!==0&&(r=`${b}/${r}`,c=b.charCodeAt(0)===Qj)}return r=aWt(r,!c),c?`/${r}`:r.length>0?r:"."}var Qj=47,XPe=46;function aWt(s,n){let r="",c=-1,u=0,d,b=!1;for(let w=0;w<=s.length;++w){if(w2){let _=r.length-1,x=_;for(;x>=0&&r.charCodeAt(x)!==Qj;--x);if(x!==_){r=x===-1?"":r.slice(0,x),c=w,u=0,b=!1;continue}}else if(r.length===2||r.length===1){r="",c=w,u=0,b=!1;continue}}n&&(r.length>0?r+="/..":r="..",b=!0)}else{let _=s.slice(c+1,w);r.length>0?r+=`/${_}`:r=_,b=!1}c=w,u=0}else d===XPe&&u!==-1?++u:u=-1}return r}var Qae=class extends Error{constructor(n,r){super(n),this.reason=r.reason,this.url=r.url,this.response=r.response}reason;url;response};var uWt=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,fWt=/^([-\w.]+\/[-\w.+]+)/;function YPe(s,n){return s.toLowerCase()===n.toLowerCase()}function bft(s){let n=fWt.exec(s);return n?n[1]:s}function ZPe(s){let n=uWt.exec(s);return n?n[1]:""}var wft=/\?.*/;function vft(s){let n=s.match(wft);return n&&n[0]}function BM(s){return s.replace(wft,"")}function _ft(s){if(s.length<50)return s;let n=s.slice(s.length-15);return`${s.substr(0,32)}...${n}`}function XL(s){return B1(s)?s.url:O1(s)?("name"in s?s.name:"")||"":typeof s=="string"?s:""}function DD(s){if(B1(s)){let n=s.headers.get("content-type")||"",r=BM(s.url);return bft(n)||ZPe(r)}return O1(s)?s.type||"":typeof s=="string"?ZPe(s):""}function yft(s){return B1(s)?s.headers["content-length"]||-1:O1(s)?s.size:typeof s=="string"?s.length:s instanceof ArrayBuffer||ArrayBuffer.isView(s)?s.byteLength:-1}async function ece(s){if(B1(s))return s;let n={},r=yft(s);r>=0&&(n["content-length"]=String(r));let c=XL(s),u=DD(s);u&&(n["content-type"]=u);let d=await dWt(s);d&&(n["x-first-bytes"]=d),typeof s=="string"&&(s=new TextEncoder().encode(s));let b=new Response(s,{headers:n});return Object.defineProperty(b,"url",{value:c}),b}async function xft(s){if(!s.ok)throw await hWt(s)}async function hWt(s){let n=_ft(s.url),r=`Failed to fetch resource (${s.status}) ${s.statusText}: ${n}`;r=r.length>100?`${r.slice(0,100)}...`:r;let c={reason:s.statusText,url:s.url,response:s};try{let u=s.headers.get("Content-Type");c.reason=!s.bodyUsed&&u?.includes("application/json")?await s.json():await s.text()}catch{}return new Qae(r,c)}async function dWt(s){if(typeof s=="string")return`data:,${s.slice(0,5)}`;if(s instanceof Blob){let r=s.slice(0,5);return await new Promise(c=>{let u=new FileReader;u.onload=d=>c(d?.target?.result),u.readAsDataURL(r)})}if(s instanceof ArrayBuffer){let r=s.slice(0,5);return`data:base64,${pWt(r)}`}return null}function pWt(s){let n="",r=new Uint8Array(s);for(let c=0;c{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},nce=class{console;constructor(){this.console=console}log(...n){return this.console.log.bind(this.console,...n)}info(...n){return this.console.info.bind(this.console,...n)}warn(...n){return this.console.warn.bind(this.console,...n)}error(...n){return this.console.error.bind(this.console,...n)}};var ice={core:{baseUrl:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new nce,useLocalLibraries:!1,CDN:"loaders.gl-cdn-disabled",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:$L,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]}},Eft={baseUri:"core.baseUrl",fetch:"core.fetch",mimeType:"core.mimeType",fallbackMimeType:"core.fallbackMimeType",ignoreRegisteredLoaders:"core.ignoreRegisteredLoaders",nothrow:"core.nothrow",log:"core.log",useLocalLibraries:"core.useLocalLibraries",CDN:"core.CDN",worker:"core.worker",maxConcurrency:"core.maxConcurrency",maxMobileConcurrency:"core.maxMobileConcurrency",reuseWorkers:"core.reuseWorkers",_nodeWorkers:"core.nodeWorkers",_workerType:"core._workerType",_worker:"core._workerType",limit:"core.limit",_limitMB:"core._limitMB",batchSize:"core.batchSize",batchDebounceMs:"core.batchDebounceMs",metadata:"core.metadata",transforms:"core.transforms",throws:"nothrow",dataType:"(no longer used)",uri:"core.baseUrl",method:"core.fetch.method",headers:"core.fetch.headers",body:"core.fetch.body",mode:"core.fetch.mode",credentials:"core.fetch.credentials",cache:"core.fetch.cache",redirect:"core.fetch.redirect",referrer:"core.fetch.referrer",referrerPolicy:"core.fetch.referrerPolicy",integrity:"core.fetch.integrity",keepalive:"core.fetch.keepalive",signal:"core.fetch.signal"};var JPe=["baseUrl","fetch","mimeType","fallbackMimeType","ignoreRegisteredLoaders","nothrow","log","useLocalLibraries","CDN","worker","maxConcurrency","maxMobileConcurrency","reuseWorkers","_nodeWorkers","_workerType","limit","_limitMB","batchSize","batchDebounceMs","metadata","transforms"];function QPe(){globalThis.loaders=globalThis.loaders||{};let{loaders:s}=globalThis;return s._state||(s._state={}),s._state}function eLe(){let s=QPe();return s.globalOptions=s.globalOptions||{...ice,core:{...ice.core}},T3(s.globalOptions)}function Tft(s,n,r,c){return r=r||[],r=Array.isArray(r)?r:[r],wWt(s,r),T3(_Wt(n,s,c))}function T3(s){let n=xWt(s);Cft(n);for(let r of JPe)n.core&&n.core[r]!==void 0&&delete n[r];return n.core&&n.core._workerType!==void 0&&delete n._worker,n}function wWt(s,n){Sft(s,null,ice,Eft,n);for(let r of n){let c=s&&s[r.id]||{},u=r.options&&r.options[r.id]||{},d=r.deprecatedOptions&&r.deprecatedOptions[r.id]||{};Sft(c,r.id,u,d,n)}}function Sft(s,n,r,c,u){let d=n||"Top level",b=n?`${n}.`:"";for(let w in s){let _=!n&&zy(s[w]),x=w==="baseUri"&&!n,T=w==="workerUrl"&&n;if(!(w in r)&&!x&&!T){if(w in c)e$.level>0&&e$.warn(`${d} loader option '${b}${w}' no longer supported, use '${c[w]}'`)();else if(!_&&e$.level>0){let M=vWt(w,u);e$.warn(`${d} loader option '${b}${w}' not recognized. ${M}`)()}}}}function vWt(s,n){let r=s.toLowerCase(),c="";for(let u of n)for(let d in u.options){if(s===d)return`Did you mean '${u.id}.${d}'?`;let b=d.toLowerCase();(r.startsWith(b)||b.startsWith(r))&&(c=c||`Did you mean '${u.id}.${d}'?`)}return c}function _Wt(s,n,r){let c=s.options||{},u={...c};c.core&&(u.core={...c.core}),Cft(u),u.core?.log===null&&(u.core={...u.core,log:new tce}),Mft(u,T3(eLe()));let d=T3(n);return Mft(u,d),yWt(u,r),EWt(u),u}function Mft(s,n){for(let r in n)if(r in n){let c=n[r];Zae(c)&&Zae(s[r])?s[r]={...s[r],...n[r]}:s[r]=n[r]}}function yWt(s,n){if(!n)return;s.core?.baseUrl!==void 0||(s.core||={},s.core.baseUrl=M3.dirname(BM(n)))}function xWt(s){let n={...s};return s.core&&(n.core={...s.core}),n}function Cft(s){s.baseUri!==void 0&&(s.core||={},s.core.baseUrl===void 0&&(s.core.baseUrl=s.baseUri));for(let r of JPe)if(s[r]!==void 0){let u=s.core=s.core||{};u[r]===void 0&&(u[r]=s[r])}let n=s._worker;n!==void 0&&(s.core||={},s.core._workerType===void 0&&(s.core._workerType=n))}function EWt(s){let n=s.core;if(n)for(let r of JPe)n[r]!==void 0&&(s[r]=n[r])}function t$(s){return s?(Array.isArray(s)&&(s=s[0]),Array.isArray(s?.extensions)):!1}function n$(s){IM(s,"null loader"),IM(t$(s),"invalid loader");let n;return Array.isArray(s)&&(n=s[1],s=s[0],s={...s,options:{...s.options,...n}}),(s?.parseTextSync||s?.parseText)&&(s.text=!0),s.text||(s.binary=!0),s}var Aft=()=>{let s=QPe();return s.loaderRegistry=s.loaderRegistry||[],s.loaderRegistry};function tLe(s){let n=Aft();s=Array.isArray(s)?s:[s];for(let r of s){let c=n$(r);n.find(u=>c===u)||n.unshift(c)}}function Pft(){return Aft()}var SWt=/\.([^.]+)$/;async function Rft(s,n=[],r,c){if(!Ift(s))return null;let u=T3(r||{});if(u.core||={},s instanceof Response&&Lft(s)){let b=await s.clone().text(),w=rce(b,n,{...u,core:{...u.core,nothrow:!0}},c);if(w)return w}let d=rce(s,n,{...u,core:{...u.core,nothrow:!0}},c);if(d)return d;if(O1(s)&&(s=await s.slice(0,10).arrayBuffer(),d=rce(s,n,u,c)),!d&&s instanceof Response&&Lft(s)){let b=await s.clone().text();d=rce(b,n,u,c)}if(!d&&!u.core.nothrow)throw new Error(Dft(s));return d}function Lft(s){let n=DD(s);return!!(n&&(n.startsWith("text/")||n==="application/json"||n.endsWith("+json")))}function rce(s,n=[],r,c){if(!Ift(s))return null;let u=T3(r||{});if(u.core||={},n&&!Array.isArray(n))return n$(n);let d=[];n&&(d=d.concat(n)),u.core.ignoreRegisteredLoaders||d.push(...Pft()),TWt(d);let b=MWt(s,d,u,c);if(!b&&!u.core.nothrow)throw new Error(Dft(s));return b}function MWt(s,n,r,c){let u=XL(s),d=DD(s),b=BM(u)||c?.url,w=null,_="";return r?.core?.mimeType&&(w=nLe(n,r?.core?.mimeType),_=`match forced by supplied MIME type ${r?.core?.mimeType}`),w=w||CWt(n,b),_=_||(w?`matched url ${b}`:""),w=w||nLe(n,d),_=_||(w?`matched MIME type ${d}`:""),w=w||PWt(n,s),_=_||(w?`matched initial data ${Bft(s)}`:""),r?.core?.fallbackMimeType&&(w=w||nLe(n,r?.core?.fallbackMimeType),_=_||(w?`matched fallback MIME type ${d}`:"")),_&&PPe.log(1,`selectLoader selected ${w?.name}: ${_}.`),w}function Ift(s){return!(s instanceof Response&&s.status===204)}function Dft(s){let n=XL(s),r=DD(s),c="No valid loader found (";c+=n?`${M3.filename(n)}, `:"no url provided, ",c+=`MIME type: ${r?`"${r}"`:"not provided"}, `;let u=s?Bft(s):"";return c+=u?` first bytes: "${u}"`:"first bytes: not available",c+=")",c}function TWt(s){for(let n of s)n$(n)}function CWt(s,n){let r=n&&SWt.exec(n),c=r&&r[1];return c?AWt(s,c):null}function AWt(s,n){n=n.toLowerCase();for(let r of s)for(let c of r.extensions)if(c.toLowerCase()===n)return r;return null}function nLe(s,n){for(let r of s)if(r.mimeTypes?.some(c=>YPe(n,c))||YPe(n,`application/x.${r.id}`))return r;return null}function PWt(s,n){if(!n)return null;for(let r of s)if(typeof n=="string"){if(LWt(n,r))return r}else if(ArrayBuffer.isView(n)){if(kft(n.buffer,n.byteOffset,r))return r}else if(n instanceof ArrayBuffer&&kft(n,0,r))return r;return null}function LWt(s,n){return n.testText?n.testText(s):(Array.isArray(n.tests)?n.tests:[n.tests]).some(c=>s.startsWith(c))}function kft(s,n,r){return(Array.isArray(r.tests)?r.tests:[r.tests]).some(u=>kWt(s,n,r,u))}function kWt(s,n,r,c){if(kD(c))return GPe(c,s,c.byteLength);switch(typeof c){case"function":return c(Jj(s));case"string":let u=iLe(s,n,c.length);return c===u;default:return!1}}function Bft(s,n=5){return typeof s=="string"?s.slice(0,n):ArrayBuffer.isView(s)?iLe(s.buffer,s.byteOffset,n):s instanceof ArrayBuffer?iLe(s,0,n):""}function iLe(s,n,r){if(s.byteLengthKPe(d,u):n?.fetch?n?.fetch:KPe}function jft(s,n,r){if(r)return r;let c={fetch:sce(n,s),...s};if(c.url){let u=BM(c.url);c.baseUrl=u,c.queryString=vft(c.url),c.filename=M3.filename(u),c.baseUrl=M3.dirname(u)}return Array.isArray(c.loaders)||(c.loaders=null),c}function $ft(s,n){if(s&&!Array.isArray(s))return s;let r;if(s&&(r=Array.isArray(s)?s:[s]),n&&n.loaders){let c=Array.isArray(n.loaders)?n.loaders:[n.loaders];r=r?[...r,...c]:c}return r&&r.length?r:void 0}async function i$(s,n,r,c){n&&!Array.isArray(n)&&!t$(n)&&(c=void 0,r=n,n=void 0),s=await s,r=r||{};let u=XL(s),b=$ft(n,c),w=await Rft(s,b,r);if(!w)return null;let _=Tft(r,w,b,u);return c=jft({url:u,_parse:i$,loaders:b},_,c||null),await OWt(w,s,_,c)}async function OWt(s,n,r,c){if(FPe(s),r=IPe(s.options,r),B1(n)){let{ok:d,redirected:b,status:w,statusText:_,type:x,url:T}=n,M=Object.fromEntries(n.headers.entries());c.response={headers:M,ok:d,redirected:b,status:w,statusText:_,type:x,url:T}}n=await Gft(n,s,r);let u=s;if(u.parseTextSync&&typeof n=="string")return u.parseTextSync(n,r,c);if(UPe(s,r))return await zPe(s,n,r,c,i$);if(u.parseText&&typeof n=="string")return await u.parseText(n,r,c);if(u.parse)return await u.parse(n,r,c);throw rg(!u.parseSync),new Error(`${s.id} loader - no parser found and worker is disabled`)}async function BD(s,n,r,c){let u,d;!Array.isArray(n)&&!t$(n)?(u=[],d=n,c=void 0):(u=n,d=r);let b=sce(d),w=s;return typeof s=="string"&&(w=await b(s)),O1(s)&&(w=await b(s)),typeof s=="string"&&(T3(d||{}).core?.baseUrl||(d={...d,core:{...d?.core,baseUrl:s}})),Array.isArray(u)?await i$(w,u,d):await i$(w,u,d)}var qft="4.5.4";var NWt=globalThis.loaders?.parseImageNode,oLe=typeof Image<"u",aLe=typeof ImageBitmap<"u",FWt=!!NWt,cLe=$L?!0:FWt;function Xft(s){switch(s){case"auto":return aLe||oLe||cLe;case"imagebitmap":return aLe;case"image":return oLe;case"data":return cLe;default:throw new Error(`@loaders.gl/images: image ${s} not supported in this environment`)}}function Yft(){if(aLe)return"imagebitmap";if(oLe)return"image";if(cLe)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function UWt(s){let n=zWt(s);if(!n)throw new Error("Not an image");return n}function Zft(s){switch(UWt(s)){case"data":return s;case"image":case"imagebitmap":let n=document.createElement("canvas"),r=n.getContext("2d");if(!r)throw new Error("getImageData");return n.width=s.width,n.height=s.height,r.drawImage(s,0,0),r.getImageData(0,0,s.width,s.height);default:throw new Error("getImageData")}}function zWt(s){return typeof ImageBitmap<"u"&&s instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&s instanceof Image?"image":s&&typeof s=="object"&&s.data&&s.width&&s.height?"data":null}var GWt=/^data:image\/svg\+xml/,jWt=/\.svg((\?|#).*)?$/;function oce(s){return s&&(GWt.test(s)||jWt.test(s))}function Kft(s,n){if(oce(n)){let c=new TextDecoder().decode(s);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(c=unescape(encodeURIComponent(c)))}catch(d){throw new Error(d.message)}return`data:image/svg+xml;base64,${btoa(c)}`}return lLe(s,n)}function lLe(s,n){if(oce(n))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(s)])}async function ace(s,n,r){let c=Kft(s,r),u=self.URL||self.webkitURL,d=typeof c!="string"&&u.createObjectURL(c);try{return await $Wt(d||c,n)}finally{d&&u.revokeObjectURL(d)}}async function $Wt(s,n){let r=new Image;return r.src=s,n.image&&n.image.decode&&r.decode?(await r.decode(),r):await new Promise((c,u)=>{try{r.onload=()=>c(r),r.onerror=d=>{let b=d instanceof Error?d.message:"error";u(new Error(b))}}catch(d){u(d)}})}var Jft=!0;async function Qft(s,n,r){let c;oce(r)?c=await ace(s,n,r):c=lLe(s,r);let u=n&&n.imagebitmap;return await VWt(c,u)}async function VWt(s,n=null){if((WWt(n)||!Jft)&&(n=null),n)try{return await createImageBitmap(s,n)}catch(r){console.warn(r),Jft=!1}return await createImageBitmap(s)}function WWt(s){if(!s)return!0;for(let n in s)if(Object.prototype.hasOwnProperty.call(s,n))return!1;return!0}function eht(s){return!YWt(s,"ftyp",4)||!(s[8]&96)?null:HWt(s)}function HWt(s){switch(qWt(s,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function qWt(s,n,r){return String.fromCharCode(...s.slice(n,r))}function XWt(s){return[...s].map(n=>n.charCodeAt(0))}function YWt(s,n,r=0){let c=XWt(n);for(let u=0;u=24&&n.getUint32(0,jy)===2303741511?{mimeType:"image/png",width:n.getUint32(16,jy),height:n.getUint32(20,jy)}:null}function JWt(s){let n=o$(s);return n.byteLength>=10&&n.getUint32(0,jy)===1195984440?{mimeType:"image/gif",width:n.getUint16(6,s$),height:n.getUint16(8,s$)}:null}function QWt(s){let n=o$(s);return n.byteLength>=14&&n.getUint16(0,jy)===16973&&n.getUint32(2,s$)===n.byteLength?{mimeType:"image/bmp",width:n.getUint32(18,s$),height:n.getUint32(22,s$)}:null}function eHt(s){let n=o$(s);if(!(n.byteLength>=3&&n.getUint16(0,jy)===65496&&n.getUint8(2)===255))return null;let{tableMarkers:c,sofMarkers:u}=tHt(),d=2;for(;d+9!!cce(new DataView(s))],options:sHt};Hj();var oHt=new ig({id:"deck"}),Bs=oHt;var fLe={};function iht(s){fLe=s}function Df(s,n,r,c){Bs.level>0&&fLe[s]&&fLe[s].call(null,n,r,c)}function aHt(s){let n=s[0],r=s[s.length-1];return n==="{"&&r==="}"||n==="["&&r==="]"}var rht={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:aHt,parseTextSync:JSON.parse};function cHt(){let s="9.4.0",n=globalThis.deck&&globalThis.deck.VERSION;if(n&&n!==s)throw new Error(`deck.gl - multiple versions detected: ${n} vs ${s}`);return n||(Bs.log(1,`deck.gl ${s}`)(),globalThis.deck={...globalThis.deck,VERSION:s,version:s,log:Bs,_registerLoggers:iht},tLe([rht,[uLe,{imagebitmap:{premultiplyAlpha:"none"}}]])),s}var sht=cHt();vm();var sJt=`struct LayerUniforms { +}`}function BPe(s,n=!0,r){let c=r||new Set;if(s){if(fft(s))c.add(s);else if(fft(s.buffer))c.add(s.buffer);else if(!ArrayBuffer.isView(s)){if(n&&typeof s=="object")for(let u in s)BPe(s[u],n,c)}}return r===void 0?Array.from(c):[]}function fft(s){return s?s instanceof ArrayBuffer||typeof MessagePort<"u"&&s instanceof MessagePort||typeof ImageBitmap<"u"&&s instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas:!1}var OPe=()=>{},DM=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&yb||typeof RD<"u"&&!yb}constructor(n){let{name:r,source:c,url:u}=n;rg(c||u),this.name=r,this.source=c,this.url=u,this.onMessage=OPe,this.onError=d=>console.log(d),this.worker=yb?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=OPe,this.onError=OPe,this.worker.terminate(),this.terminated=!0}get isRunning(){return!!this.onMessage}postMessage(n,r){r=r||BPe(n),this.worker.postMessage(n,r)}_getErrorFromErrorEvent(n){let r="Failed to load ";return r+=`worker ${this.name} from ${this.url}. `,n.message&&(r+=`${n.message} in `),n.lineno&&(r+=`:${n.lineno}:${n.colno}`),new Error(r)}_createBrowserWorker(){this._loadableURL=lft({source:this.source,url:this.url});let n=new Worker(this._loadableURL,{name:this.name});return n.onmessage=r=>{r.data?this.onMessage(r.data):this.onError(new Error("No data received"))},n.onerror=r=>{this.onError(this._getErrorFromErrorEvent(r)),this.terminated=!0},n.onmessageerror=r=>console.error(r),n}_createNodeWorker(){let n;if(this.url){let c=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`,u=this.url.endsWith(".ts")||this.url.endsWith(".mjs")?"module":"commonjs";n=new RD(c,{eval:!1,type:u})}else if(this.source)n=new RD(this.source,{eval:!0});else throw new Error("no worker");return n.on("message",r=>{this.onMessage(r)}),n.on("error",r=>{this.onError(r)}),n.on("exit",r=>{}),n}};var Yj=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return DM.isSupported()}constructor(n){this.source=n.source,this.url=n.url,this.setProps(n)}destroy(){this.idleQueue.forEach(n=>n.destroy()),this.isDestroyed=!0}setProps(n){this.props={...this.props,...n},n.name!==void 0&&(this.name=n.name),n.maxConcurrency!==void 0&&(this.maxConcurrency=n.maxConcurrency),n.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=n.maxMobileConcurrency),n.reuseWorkers!==void 0&&(this.reuseWorkers=n.reuseWorkers),n.onDebug!==void 0&&(this.onDebug=n.onDebug)}async startJob(n,r=(u,d,b)=>u.done(b),c=(u,d)=>u.error(d)){let u=new Promise(d=>(this.jobQueue.push({name:n,onMessage:r,onError:c,onStart:d}),this));return this._startQueuedJob(),await u}async _startQueuedJob(){if(!this.jobQueue.length)return;let n=this._getAvailableWorker();if(!n)return;let r=this.jobQueue.shift();if(r){this.onDebug({message:"Starting job",name:r.name,workerThread:n,backlog:this.jobQueue.length});let c=new Xj(r.name,n);n.onMessage=u=>r.onMessage(c,u.type,u.payload),n.onError=u=>r.onError(c,u),r.onStart(c);try{await c.result}catch(u){console.error(`Worker exception: ${u}`)}finally{this.returnWorkerToQueue(n)}}}returnWorkerToQueue(n){!yb||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(n.destroy(),this.count--):this.idleQueue.push(n),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count{}},HL=class s{props;workerPools=new Map;static _workerFarm;static isSupported(){return DM.isSupported()}static getWorkerFarm(n={}){return s._workerFarm=s._workerFarm||new s({}),s._workerFarm.setProps(n),s._workerFarm}constructor(n){this.props={...nWt},this.setProps(n),this.workerPools=new Map}destroy(){for(let n of this.workerPools.values())n.destroy();this.workerPools=new Map}setProps(n){this.props={...this.props,...n};for(let r of this.workerPools.values())r.setProps(this._getWorkerPoolProps())}getWorkerPool(n){let{name:r,source:c,url:u}=n,d=this.workerPools.get(r);return d||(d=new Yj({name:r,source:c,url:u}),d.setProps(this._getWorkerPoolProps()),this.workerPools.set(r,d)),d}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}};function NPe(s,n={}){let r=n[s.id]||{},c=yb?s.workerFile||`${s.id}-worker.js`:`${s.id}-worker-node.js`,u=r.workerUrl;if(!u&&s.id==="compression"&&(u=n.workerUrl),(n._workerType||n?.core?._workerType)==="test"&&(yb?u=`modules/${s.module}/dist/${c}`:u=`modules/${s.module}/src/workers/${s.id}-worker-node.ts`),!u){let b=s.version;b==="latest"&&(b=sft);let w=b?`@${b}`:"";u=`loaders.gl-cdn-disabled/${s.module}${w}/dist/${c}`}return rg(u),u}function FPe(s,n=oft){rg(s,"no worker provided");let r=s.version;return!(!n||!r)}function UPe(s,n){if(!HL.isSupported())return!1;let r=n?._nodeWorkers??n?.core?._nodeWorkers;if(!yb&&!r)return!1;let c=n?.worker??n?.core?.worker;return!!(s.worker&&c)}async function zPe(s,n,r,c,u){let d=s.id,b=NPe(s,r),_=HL.getWorkerFarm(r?.core).getWorkerPool({name:d,url:b});r=JSON.parse(JSON.stringify(r||{})),r._workerLoaderId=s.id,c=JSON.parse(JSON.stringify(c||{}));let x=await _.startJob("process-on-worker",iWt.bind(null,u));return x.postMessage("process",{input:n,options:r,context:c}),await(await x.result).result}async function iWt(s,n,r,c){switch(r){case"done":n.done(c);break;case"error":n.error(new Error(c.error));break;case"process":let{id:u,input:d,options:b}=c;try{let w=await s(d,b);n.postMessage("done",{id:u,result:w})}catch(w){let _=w instanceof Error?w.message:"unknown error";n.postMessage("error",{id:u,error:_})}break;default:console.warn(`parse-with-worker unknown message ${r}`)}}function GPe(s,n,r){if(r=r||s.byteLength,s.byteLengthd instanceof ArrayBuffer?new Uint8Array(d):d),r=n.reduce((d,b)=>d+b.byteLength,0),c=new Uint8Array(r),u=0;for(let d of n)c.set(d,u),u+=d.byteLength;return c.buffer}async function $Pe(s){let n=[];for await(let r of s)n.push(rWt(r));return jPe(...n)}function rWt(s){if(s instanceof ArrayBuffer)return s;if(ArrayBuffer.isView(s)){let{buffer:n,byteOffset:r,byteLength:c}=s;return dft(n,r,c)}return dft(s)}function dft(s,n=0,r=s.byteLength-n){let c=new Uint8Array(s,n,r),u=new Uint8Array(c.length);return u.set(c),u.buffer}var sWt="",gft={};function HPe(s){for(let n in gft)if(s.startsWith(n)){let r=gft[n];s=s.replace(n,r)}return!s.startsWith("http://")&&!s.startsWith("https://")&&(s=`${sWt}${s}`),s}function Jae(s){return s&&typeof s=="object"&&s.isBuffer}function ID(s){if(Jae(s))return s;if(s instanceof ArrayBuffer)return s;if(LPe(s))return Kae(s);if(ArrayBuffer.isView(s)){let n=s.buffer;return s.byteOffset===0&&s.byteLength===s.buffer.byteLength?n:n.slice(s.byteOffset,s.byteOffset+s.byteLength)}if(typeof s=="string"){let n=s;return new TextEncoder().encode(n).buffer}if(s&&typeof s=="object"&&s._toArrayBuffer)return s._toArrayBuffer();throw new Error("toArrayBuffer")}function Jj(s){if(s instanceof ArrayBuffer)return s;if(LPe(s))return Kae(s);let{buffer:n,byteOffset:r,byteLength:c}=s;return n instanceof ArrayBuffer&&r===0&&c===n.byteLength?n:Kae(n,r,c)}function Kae(s,n=0,r=s.byteLength-n){let c=new Uint8Array(s,n,r),u=new Uint8Array(c.length);return u.set(c),u.buffer}function qPe(s){return ArrayBuffer.isView(s)?s:new Uint8Array(s)}var M3={};Oy(M3,{dirname:()=>aWt,filename:()=>oWt,join:()=>cWt,resolve:()=>lWt});function mft(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let s=window.location?.pathname;return s?.slice(0,s.lastIndexOf("/")+1)||""}function oWt(s){let n=s?s.lastIndexOf("/"):-1;return n>=0?s.substr(n+1):s}function aWt(s){let n=s?s.lastIndexOf("/"):-1;return n>=0?s.substr(0,n):""}function cWt(...s){let n="/";return s=s.map((r,c)=>(c&&(r=r.replace(new RegExp(`^${n}`),"")),c!==s.length-1&&(r=r.replace(new RegExp(`${n}$`),"")),r)),s.join(n)}function lWt(...s){let n=[];for(let d=0;d=-1&&!c;d--){let b;d>=0?b=n[d]:(u===void 0&&(u=mft()),b=u),b.length!==0&&(r=`${b}/${r}`,c=b.charCodeAt(0)===Qj)}return r=uWt(r,!c),c?`/${r}`:r.length>0?r:"."}var Qj=47,XPe=46;function uWt(s,n){let r="",c=-1,u=0,d,b=!1;for(let w=0;w<=s.length;++w){if(w2){let _=r.length-1,x=_;for(;x>=0&&r.charCodeAt(x)!==Qj;--x);if(x!==_){r=x===-1?"":r.slice(0,x),c=w,u=0,b=!1;continue}}else if(r.length===2||r.length===1){r="",c=w,u=0,b=!1;continue}}n&&(r.length>0?r+="/..":r="..",b=!0)}else{let _=s.slice(c+1,w);r.length>0?r+=`/${_}`:r=_,b=!1}c=w,u=0}else d===XPe&&u!==-1?++u:u=-1}return r}var Qae=class extends Error{constructor(n,r){super(n),this.reason=r.reason,this.url=r.url,this.response=r.response}reason;url;response};var dWt=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,pWt=/^([-\w.]+\/[-\w.+]+)/;function YPe(s,n){return s.toLowerCase()===n.toLowerCase()}function bft(s){let n=pWt.exec(s);return n?n[1]:s}function ZPe(s){let n=dWt.exec(s);return n?n[1]:""}var wft=/\?.*/;function vft(s){let n=s.match(wft);return n&&n[0]}function BM(s){return s.replace(wft,"")}function _ft(s){if(s.length<50)return s;let n=s.slice(s.length-15);return`${s.substr(0,32)}...${n}`}function XL(s){return B1(s)?s.url:O1(s)?("name"in s?s.name:"")||"":typeof s=="string"?s:""}function DD(s){if(B1(s)){let n=s.headers.get("content-type")||"",r=BM(s.url);return bft(n)||ZPe(r)}return O1(s)?s.type||"":typeof s=="string"?ZPe(s):""}function yft(s){return B1(s)?s.headers["content-length"]||-1:O1(s)?s.size:typeof s=="string"?s.length:s instanceof ArrayBuffer||ArrayBuffer.isView(s)?s.byteLength:-1}async function ece(s){if(B1(s))return s;let n={},r=yft(s);r>=0&&(n["content-length"]=String(r));let c=XL(s),u=DD(s);u&&(n["content-type"]=u);let d=await mWt(s);d&&(n["x-first-bytes"]=d),typeof s=="string"&&(s=new TextEncoder().encode(s));let b=new Response(s,{headers:n});return Object.defineProperty(b,"url",{value:c}),b}async function xft(s){if(!s.ok)throw await gWt(s)}async function gWt(s){let n=_ft(s.url),r=`Failed to fetch resource (${s.status}) ${s.statusText}: ${n}`;r=r.length>100?`${r.slice(0,100)}...`:r;let c={reason:s.statusText,url:s.url,response:s};try{let u=s.headers.get("Content-Type");c.reason=!s.bodyUsed&&u?.includes("application/json")?await s.json():await s.text()}catch{}return new Qae(r,c)}async function mWt(s){if(typeof s=="string")return`data:,${s.slice(0,5)}`;if(s instanceof Blob){let r=s.slice(0,5);return await new Promise(c=>{let u=new FileReader;u.onload=d=>c(d?.target?.result),u.readAsDataURL(r)})}if(s instanceof ArrayBuffer){let r=s.slice(0,5);return`data:base64,${bWt(r)}`}return null}function bWt(s){let n="",r=new Uint8Array(s);for(let c=0;c{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},nce=class{console;constructor(){this.console=console}log(...n){return this.console.log.bind(this.console,...n)}info(...n){return this.console.info.bind(this.console,...n)}warn(...n){return this.console.warn.bind(this.console,...n)}error(...n){return this.console.error.bind(this.console,...n)}};var ice={core:{baseUrl:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new nce,useLocalLibraries:!1,CDN:"loaders.gl-cdn-disabled",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:$L,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]}},Eft={baseUri:"core.baseUrl",fetch:"core.fetch",mimeType:"core.mimeType",fallbackMimeType:"core.fallbackMimeType",ignoreRegisteredLoaders:"core.ignoreRegisteredLoaders",nothrow:"core.nothrow",log:"core.log",useLocalLibraries:"core.useLocalLibraries",CDN:"core.CDN",worker:"core.worker",maxConcurrency:"core.maxConcurrency",maxMobileConcurrency:"core.maxMobileConcurrency",reuseWorkers:"core.reuseWorkers",_nodeWorkers:"core.nodeWorkers",_workerType:"core._workerType",_worker:"core._workerType",limit:"core.limit",_limitMB:"core._limitMB",batchSize:"core.batchSize",batchDebounceMs:"core.batchDebounceMs",metadata:"core.metadata",transforms:"core.transforms",throws:"nothrow",dataType:"(no longer used)",uri:"core.baseUrl",method:"core.fetch.method",headers:"core.fetch.headers",body:"core.fetch.body",mode:"core.fetch.mode",credentials:"core.fetch.credentials",cache:"core.fetch.cache",redirect:"core.fetch.redirect",referrer:"core.fetch.referrer",referrerPolicy:"core.fetch.referrerPolicy",integrity:"core.fetch.integrity",keepalive:"core.fetch.keepalive",signal:"core.fetch.signal"};var JPe=["baseUrl","fetch","mimeType","fallbackMimeType","ignoreRegisteredLoaders","nothrow","log","useLocalLibraries","CDN","worker","maxConcurrency","maxMobileConcurrency","reuseWorkers","_nodeWorkers","_workerType","limit","_limitMB","batchSize","batchDebounceMs","metadata","transforms"];function QPe(){globalThis.loaders=globalThis.loaders||{};let{loaders:s}=globalThis;return s._state||(s._state={}),s._state}function eLe(){let s=QPe();return s.globalOptions=s.globalOptions||{...ice,core:{...ice.core}},T3(s.globalOptions)}function Tft(s,n,r,c){return r=r||[],r=Array.isArray(r)?r:[r],yWt(s,r),T3(EWt(n,s,c))}function T3(s){let n=MWt(s);Cft(n);for(let r of JPe)n.core&&n.core[r]!==void 0&&delete n[r];return n.core&&n.core._workerType!==void 0&&delete n._worker,n}function yWt(s,n){Sft(s,null,ice,Eft,n);for(let r of n){let c=s&&s[r.id]||{},u=r.options&&r.options[r.id]||{},d=r.deprecatedOptions&&r.deprecatedOptions[r.id]||{};Sft(c,r.id,u,d,n)}}function Sft(s,n,r,c,u){let d=n||"Top level",b=n?`${n}.`:"";for(let w in s){let _=!n&&zy(s[w]),x=w==="baseUri"&&!n,T=w==="workerUrl"&&n;if(!(w in r)&&!x&&!T){if(w in c)e$.level>0&&e$.warn(`${d} loader option '${b}${w}' no longer supported, use '${c[w]}'`)();else if(!_&&e$.level>0){let M=xWt(w,u);e$.warn(`${d} loader option '${b}${w}' not recognized. ${M}`)()}}}}function xWt(s,n){let r=s.toLowerCase(),c="";for(let u of n)for(let d in u.options){if(s===d)return`Did you mean '${u.id}.${d}'?`;let b=d.toLowerCase();(r.startsWith(b)||b.startsWith(r))&&(c=c||`Did you mean '${u.id}.${d}'?`)}return c}function EWt(s,n,r){let c=s.options||{},u={...c};c.core&&(u.core={...c.core}),Cft(u),u.core?.log===null&&(u.core={...u.core,log:new tce}),Mft(u,T3(eLe()));let d=T3(n);return Mft(u,d),SWt(u,r),TWt(u),u}function Mft(s,n){for(let r in n)if(r in n){let c=n[r];Zae(c)&&Zae(s[r])?s[r]={...s[r],...n[r]}:s[r]=n[r]}}function SWt(s,n){if(!n)return;s.core?.baseUrl!==void 0||(s.core||={},s.core.baseUrl=M3.dirname(BM(n)))}function MWt(s){let n={...s};return s.core&&(n.core={...s.core}),n}function Cft(s){s.baseUri!==void 0&&(s.core||={},s.core.baseUrl===void 0&&(s.core.baseUrl=s.baseUri));for(let r of JPe)if(s[r]!==void 0){let u=s.core=s.core||{};u[r]===void 0&&(u[r]=s[r])}let n=s._worker;n!==void 0&&(s.core||={},s.core._workerType===void 0&&(s.core._workerType=n))}function TWt(s){let n=s.core;if(n)for(let r of JPe)n[r]!==void 0&&(s[r]=n[r])}function t$(s){return s?(Array.isArray(s)&&(s=s[0]),Array.isArray(s?.extensions)):!1}function n$(s){IM(s,"null loader"),IM(t$(s),"invalid loader");let n;return Array.isArray(s)&&(n=s[1],s=s[0],s={...s,options:{...s.options,...n}}),(s?.parseTextSync||s?.parseText)&&(s.text=!0),s.text||(s.binary=!0),s}var Aft=()=>{let s=QPe();return s.loaderRegistry=s.loaderRegistry||[],s.loaderRegistry};function tLe(s){let n=Aft();s=Array.isArray(s)?s:[s];for(let r of s){let c=n$(r);n.find(u=>c===u)||n.unshift(c)}}function Pft(){return Aft()}var CWt=/\.([^.]+)$/;async function Rft(s,n=[],r,c){if(!Ift(s))return null;let u=T3(r||{});if(u.core||={},s instanceof Response&&Lft(s)){let b=await s.clone().text(),w=rce(b,n,{...u,core:{...u.core,nothrow:!0}},c);if(w)return w}let d=rce(s,n,{...u,core:{...u.core,nothrow:!0}},c);if(d)return d;if(O1(s)&&(s=await s.slice(0,10).arrayBuffer(),d=rce(s,n,u,c)),!d&&s instanceof Response&&Lft(s)){let b=await s.clone().text();d=rce(b,n,u,c)}if(!d&&!u.core.nothrow)throw new Error(Dft(s));return d}function Lft(s){let n=DD(s);return!!(n&&(n.startsWith("text/")||n==="application/json"||n.endsWith("+json")))}function rce(s,n=[],r,c){if(!Ift(s))return null;let u=T3(r||{});if(u.core||={},n&&!Array.isArray(n))return n$(n);let d=[];n&&(d=d.concat(n)),u.core.ignoreRegisteredLoaders||d.push(...Pft()),PWt(d);let b=AWt(s,d,u,c);if(!b&&!u.core.nothrow)throw new Error(Dft(s));return b}function AWt(s,n,r,c){let u=XL(s),d=DD(s),b=BM(u)||c?.url,w=null,_="";return r?.core?.mimeType&&(w=nLe(n,r?.core?.mimeType),_=`match forced by supplied MIME type ${r?.core?.mimeType}`),w=w||LWt(n,b),_=_||(w?`matched url ${b}`:""),w=w||nLe(n,d),_=_||(w?`matched MIME type ${d}`:""),w=w||RWt(n,s),_=_||(w?`matched initial data ${Bft(s)}`:""),r?.core?.fallbackMimeType&&(w=w||nLe(n,r?.core?.fallbackMimeType),_=_||(w?`matched fallback MIME type ${d}`:"")),_&&PPe.log(1,`selectLoader selected ${w?.name}: ${_}.`),w}function Ift(s){return!(s instanceof Response&&s.status===204)}function Dft(s){let n=XL(s),r=DD(s),c="No valid loader found (";c+=n?`${M3.filename(n)}, `:"no url provided, ",c+=`MIME type: ${r?`"${r}"`:"not provided"}, `;let u=s?Bft(s):"";return c+=u?` first bytes: "${u}"`:"first bytes: not available",c+=")",c}function PWt(s){for(let n of s)n$(n)}function LWt(s,n){let r=n&&CWt.exec(n),c=r&&r[1];return c?kWt(s,c):null}function kWt(s,n){n=n.toLowerCase();for(let r of s)for(let c of r.extensions)if(c.toLowerCase()===n)return r;return null}function nLe(s,n){for(let r of s)if(r.mimeTypes?.some(c=>YPe(n,c))||YPe(n,`application/x.${r.id}`))return r;return null}function RWt(s,n){if(!n)return null;for(let r of s)if(typeof n=="string"){if(IWt(n,r))return r}else if(ArrayBuffer.isView(n)){if(kft(n.buffer,n.byteOffset,r))return r}else if(n instanceof ArrayBuffer&&kft(n,0,r))return r;return null}function IWt(s,n){return n.testText?n.testText(s):(Array.isArray(n.tests)?n.tests:[n.tests]).some(c=>s.startsWith(c))}function kft(s,n,r){return(Array.isArray(r.tests)?r.tests:[r.tests]).some(u=>DWt(s,n,r,u))}function DWt(s,n,r,c){if(kD(c))return GPe(c,s,c.byteLength);switch(typeof c){case"function":return c(Jj(s));case"string":let u=iLe(s,n,c.length);return c===u;default:return!1}}function Bft(s,n=5){return typeof s=="string"?s.slice(0,n):ArrayBuffer.isView(s)?iLe(s.buffer,s.byteOffset,n):s instanceof ArrayBuffer?iLe(s,0,n):""}function iLe(s,n,r){if(s.byteLengthKPe(d,u):n?.fetch?n?.fetch:KPe}function jft(s,n,r){if(r)return r;let c={fetch:sce(n,s),...s};if(c.url){let u=BM(c.url);c.baseUrl=u,c.queryString=vft(c.url),c.filename=M3.filename(u),c.baseUrl=M3.dirname(u)}return Array.isArray(c.loaders)||(c.loaders=null),c}function $ft(s,n){if(s&&!Array.isArray(s))return s;let r;if(s&&(r=Array.isArray(s)?s:[s]),n&&n.loaders){let c=Array.isArray(n.loaders)?n.loaders:[n.loaders];r=r?[...r,...c]:c}return r&&r.length?r:void 0}async function i$(s,n,r,c){n&&!Array.isArray(n)&&!t$(n)&&(c=void 0,r=n,n=void 0),s=await s,r=r||{};let u=XL(s),b=$ft(n,c),w=await Rft(s,b,r);if(!w)return null;let _=Tft(r,w,b,u);return c=jft({url:u,_parse:i$,loaders:b},_,c||null),await UWt(w,s,_,c)}async function UWt(s,n,r,c){if(FPe(s),r=IPe(s.options,r),B1(n)){let{ok:d,redirected:b,status:w,statusText:_,type:x,url:T}=n,M=Object.fromEntries(n.headers.entries());c.response={headers:M,ok:d,redirected:b,status:w,statusText:_,type:x,url:T}}n=await Gft(n,s,r);let u=s;if(u.parseTextSync&&typeof n=="string")return u.parseTextSync(n,r,c);if(UPe(s,r))return await zPe(s,n,r,c,i$);if(u.parseText&&typeof n=="string")return await u.parseText(n,r,c);if(u.parse)return await u.parse(n,r,c);throw rg(!u.parseSync),new Error(`${s.id} loader - no parser found and worker is disabled`)}async function BD(s,n,r,c){let u,d;!Array.isArray(n)&&!t$(n)?(u=[],d=n,c=void 0):(u=n,d=r);let b=sce(d),w=s;return typeof s=="string"&&(w=await b(s)),O1(s)&&(w=await b(s)),typeof s=="string"&&(T3(d||{}).core?.baseUrl||(d={...d,core:{...d?.core,baseUrl:s}})),Array.isArray(u)?await i$(w,u,d):await i$(w,u,d)}var qft="4.5.4";var zWt=globalThis.loaders?.parseImageNode,oLe=typeof Image<"u",aLe=typeof ImageBitmap<"u",GWt=!!zWt,cLe=$L?!0:GWt;function Xft(s){switch(s){case"auto":return aLe||oLe||cLe;case"imagebitmap":return aLe;case"image":return oLe;case"data":return cLe;default:throw new Error(`@loaders.gl/images: image ${s} not supported in this environment`)}}function Yft(){if(aLe)return"imagebitmap";if(oLe)return"image";if(cLe)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function jWt(s){let n=$Wt(s);if(!n)throw new Error("Not an image");return n}function Zft(s){switch(jWt(s)){case"data":return s;case"image":case"imagebitmap":let n=document.createElement("canvas"),r=n.getContext("2d");if(!r)throw new Error("getImageData");return n.width=s.width,n.height=s.height,r.drawImage(s,0,0),r.getImageData(0,0,s.width,s.height);default:throw new Error("getImageData")}}function $Wt(s){return typeof ImageBitmap<"u"&&s instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&s instanceof Image?"image":s&&typeof s=="object"&&s.data&&s.width&&s.height?"data":null}var VWt=/^data:image\/svg\+xml/,WWt=/\.svg((\?|#).*)?$/;function oce(s){return s&&(VWt.test(s)||WWt.test(s))}function Kft(s,n){if(oce(n)){let c=new TextDecoder().decode(s);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(c=unescape(encodeURIComponent(c)))}catch(d){throw new Error(d.message)}return`data:image/svg+xml;base64,${btoa(c)}`}return lLe(s,n)}function lLe(s,n){if(oce(n))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(s)])}async function ace(s,n,r){let c=Kft(s,r),u=self.URL||self.webkitURL,d=typeof c!="string"&&u.createObjectURL(c);try{return await HWt(d||c,n)}finally{d&&u.revokeObjectURL(d)}}async function HWt(s,n){let r=new Image;return r.src=s,n.image&&n.image.decode&&r.decode?(await r.decode(),r):await new Promise((c,u)=>{try{r.onload=()=>c(r),r.onerror=d=>{let b=d instanceof Error?d.message:"error";u(new Error(b))}}catch(d){u(d)}})}var Jft=!0;async function Qft(s,n,r){let c;oce(r)?c=await ace(s,n,r):c=lLe(s,r);let u=n&&n.imagebitmap;return await qWt(c,u)}async function qWt(s,n=null){if((XWt(n)||!Jft)&&(n=null),n)try{return await createImageBitmap(s,n)}catch(r){console.warn(r),Jft=!1}return await createImageBitmap(s)}function XWt(s){if(!s)return!0;for(let n in s)if(Object.prototype.hasOwnProperty.call(s,n))return!1;return!0}function eht(s){return!JWt(s,"ftyp",4)||!(s[8]&96)?null:YWt(s)}function YWt(s){switch(ZWt(s,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function ZWt(s,n,r){return String.fromCharCode(...s.slice(n,r))}function KWt(s){return[...s].map(n=>n.charCodeAt(0))}function JWt(s,n,r=0){let c=KWt(n);for(let u=0;u=24&&n.getUint32(0,jy)===2303741511?{mimeType:"image/png",width:n.getUint32(16,jy),height:n.getUint32(20,jy)}:null}function tHt(s){let n=o$(s);return n.byteLength>=10&&n.getUint32(0,jy)===1195984440?{mimeType:"image/gif",width:n.getUint16(6,s$),height:n.getUint16(8,s$)}:null}function nHt(s){let n=o$(s);return n.byteLength>=14&&n.getUint16(0,jy)===16973&&n.getUint32(2,s$)===n.byteLength?{mimeType:"image/bmp",width:n.getUint32(18,s$),height:n.getUint32(22,s$)}:null}function iHt(s){let n=o$(s);if(!(n.byteLength>=3&&n.getUint16(0,jy)===65496&&n.getUint8(2)===255))return null;let{tableMarkers:c,sofMarkers:u}=rHt(),d=2;for(;d+9!!cce(new DataView(s))],options:cHt};Hj();var lHt=new ig({id:"deck"}),Bs=lHt;var fLe={};function iht(s){fLe=s}function Bf(s,n,r,c){Bs.level>0&&fLe[s]&&fLe[s].call(null,n,r,c)}function uHt(s){let n=s[0],r=s[s.length-1];return n==="{"&&r==="}"||n==="["&&r==="]"}var rht={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:uHt,parseTextSync:JSON.parse};function fHt(){let s="9.4.0",n=globalThis.deck&&globalThis.deck.VERSION;if(n&&n!==s)throw new Error(`deck.gl - multiple versions detected: ${n} vs ${s}`);return n||(Bs.log(1,`deck.gl ${s}`)(),globalThis.deck={...globalThis.deck,VERSION:s,version:s,log:Bs,_registerLoggers:iht},tLe([rht,[uLe,{imagebitmap:{premultiplyAlpha:"none"}}]])),s}var sht=fHt();vm();var cJt=`struct LayerUniforms { opacity: f32, }; @@ -3354,13 +3354,13 @@ var layer: LayerUniforms; `,jgt=`layout(std140) uniform layerUniforms { uniform float opacity; } layer; -`,fke={name:"layer",source:sJt,vs:jgt,fs:jgt,getUniforms:s=>({opacity:Math.pow(s.opacity,.45454545454545453)}),uniformTypes:{opacity:"f32"}};var oJt=` +`,fke={name:"layer",source:cJt,vs:jgt,fs:jgt,getUniforms:s=>({opacity:Math.pow(s.opacity,.45454545454545453)}),uniformTypes:{opacity:"f32"}};var lJt=` @must_use fn deckgl_premultiplied_alpha(fragColor: vec4) -> vec4 { return vec4(fragColor.rgb * fragColor.a, fragColor.a); }; -`,qy={name:"color",dependencies:[],source:oJt,getUniforms:s=>({})};var aJt=`const SMOOTH_EDGE_RADIUS: f32 = 0.5; +`,qy={name:"color",dependencies:[],source:lJt,getUniforms:s=>({})};var uJt=`const SMOOTH_EDGE_RADIUS: f32 = 0.5; struct VertexGeometry { position: vec4, @@ -3389,7 +3389,7 @@ var fragmentGeometry: FragmentGeometry; fn smoothedge(edge: f32, x: f32) -> f32 { return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x); } -`,$gt="#define SMOOTH_EDGE_RADIUS 0.5",cJt=`${$gt} +`,$gt="#define SMOOTH_EDGE_RADIUS 0.5",fJt=`${$gt} struct VertexGeometry { vec4 position; @@ -3406,7 +3406,7 @@ struct VertexGeometry { vec2(0.0), vec3(0.0) ); -`,lJt=`${$gt} +`,hJt=`${$gt} struct FragmentGeometry { vec2 uv; @@ -3416,9 +3416,9 @@ FragmentGeometry geometry; float smoothedge(float edge, float x) { return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x); } -`,ile={name:"geometry",source:aJt,vs:cJt,fs:lJt};vm();Of();var rs;(function(s){s[s.Start=1]="Start",s[s.Move=2]="Move",s[s.End=4]="End",s[s.Cancel=8]="Cancel"})(rs||(rs={}));var Jl;(function(s){s[s.None=0]="None",s[s.Left=1]="Left",s[s.Right=2]="Right",s[s.Up=4]="Up",s[s.Down=8]="Down",s[s.Horizontal=3]="Horizontal",s[s.Vertical=12]="Vertical",s[s.All=15]="All"})(Jl||(Jl={}));var Wi;(function(s){s[s.Possible=1]="Possible",s[s.Began=2]="Began",s[s.Changed=4]="Changed",s[s.Ended=8]="Ended",s[s.Recognized=8]="Recognized",s[s.Cancelled=16]="Cancelled",s[s.Failed=32]="Failed"})(Wi||(Wi={}));var Vgt="compute",hke="auto",g4="manipulation",m4="none",U$="pan-x",z$="pan-y";function dke(s){if(s.includes(m4))return m4;let n=s.includes(U$),r=s.includes(z$);return n&&r?m4:n||r?n?U$:z$:s.includes(g4)?g4:hke}var G$=class{constructor(n,r){this.actions="",this.manager=n,this.set(r)}set(n){n===Vgt&&(n=this.compute()),this.manager.element&&(this.manager.element.style.touchAction=n,this.actions=n)}update(){this.set(this.manager.options.touchAction)}compute(){let n=[];for(let r of this.manager.recognizers)r.options.enable&&(n=n.concat(r.getTouchAction()));return dke(n.join(" "))}};function KD(s){return s.trim().split(/\s+/g)}function rle(s,n,r){if(s)for(let c of KD(n))s.addEventListener(c,r,!1)}function sle(s,n,r){if(s)for(let c of KD(n))s.removeEventListener(c,r,!1)}function pke(s){return(s.ownerDocument||s).defaultView}function gke(s,n){let r=s;for(;r;){if(r===n)return!0;r=r.parentNode}return!1}function ole(s){let n=s.length;if(n===1)return{x:Math.round(s[0].clientX),y:Math.round(s[0].clientY)};let r=0,c=0,u=0;for(;u=Math.abs(n)?s<0?Jl.Left:Jl.Right:n<0?Jl.Up:Jl.Down}function Hgt(s,n){let r=n.center,c=s.offsetDelta,u=s.prevDelta,d=s.prevInput;return(n.eventType===rs.Start||d?.eventType===rs.End)&&(u=s.prevDelta={x:d?.deltaX||0,y:d?.deltaY||0},c=s.offsetDelta={x:r.x,y:r.y}),{deltaX:u.x+(r.x-c.x),deltaY:u.y+(r.y-c.y)}}function ale(s,n,r){return{x:n/s||0,y:r/s||0}}function qgt(s,n){return j$(n[0],n[1])/j$(s[0],s[1])}function Xgt(s,n){return bke(n[1],n[0])-bke(s[1],s[0])}function Ygt(s,n){let r=s.lastInterval||n,c=n.timeStamp-r.timeStamp,u,d,b,w;if(n.eventType!==rs.Cancel&&(c>25||r.velocity===void 0)){let _=n.deltaX-r.deltaX,x=n.deltaY-r.deltaY,T=ale(c,_,x);d=T.x,b=T.y,u=Math.abs(T.x)>Math.abs(T.y)?T.x:T.y,w=QD(_,x),s.lastInterval=n}else u=r.velocity,d=r.velocityX,b=r.velocityY,w=r.direction;n.velocity=u,n.velocityX=d,n.velocityY=b,n.direction=w}function wke(s,n){return"pointerId"in s?s.pointerId:n}function Zgt(s,n){s.movementOrigin=new Map(n.map((r,c)=>[wke(r,c),{clientX:r.clientX,clientY:r.clientY}])),s.firstMovementTime=void 0}function fJt(s,n){let r=n.pointers.map(wke);if(s.movementOrigin?.size===r.length&&r.every(u=>s.movementOrigin.has(u))||Zgt(s,n.pointers),n.distancePerPointer=n.pointers.map((u,d)=>j$(s.movementOrigin.get(r[d]),u)),n.eventType&rs.Move&&n.distancePerPointer.some(u=>u>0)&&(s.firstMovementTime??(s.firstMovementTime=n.timeStamp)),n.movementDeltaTime=s.firstMovementTime===void 0?0:n.timeStamp-s.firstMovementTime,n.eventType&(rs.End|rs.Cancel)){let u=n.changedPointers.map(d=>wke(d,n.pointers.indexOf(d)));Zgt(s,n.pointers.filter((d,b)=>!u.includes(r[b])))}}function Kgt(s,n){let{session:r}=s,{pointers:c}=n,{length:u}=c;r.firstInput||(r.firstInput=mke(n)),u>1&&!r.firstMultiple?r.firstMultiple=mke(n):u===1&&(r.firstMultiple=!1);let{firstInput:d,firstMultiple:b}=r,w=b?b.center:d.center,_=n.center=ole(c);n.timeStamp=Date.now(),n.deltaTime=n.timeStamp-d.timeStamp,fJt(r,n),n.angle=Wgt(w,_),n.distance=JD(w,_);let{deltaX:x,deltaY:T}=Hgt(r,n);n.deltaX=x,n.deltaY=T,n.offsetDirection=QD(n.deltaX,n.deltaY);let M=ale(n.deltaTime,n.deltaX,n.deltaY);n.overallVelocityX=M.x,n.overallVelocityY=M.y,n.overallVelocity=Math.abs(M.x)>Math.abs(M.y)?M.x:M.y,n.scale=b?qgt(b.pointers,c):1,n.rotation=b?Xgt(b.pointers,c):0,n.maxPointers=r.prevInput?n.pointers.length>r.prevInput.maxPointers?n.pointers.length:r.prevInput.maxPointers:n.pointers.length;let L=s.element;return gke(n.srcEvent.target,L)&&(L=n.srcEvent.target),n.target=L,Ygt(r,n),n}function Jgt(s,n,r){let c=r.pointers.length,u=r.changedPointers.length,d=n&rs.Start&&c-u===0,b=n&(rs.End|rs.Cancel)&&c-u===0;r.isFirst=!!d,r.isFinal=!!b,d&&(s.session={}),r.eventType=n;let w=Kgt(s,r);s.emit("hammer.input",w),s.recognize(w),s.session.prevInput=w}var $$=class{constructor(n){this.evEl="",this.evWin="",this.evTarget="",this.domHandler=r=>{this.manager.options.enable&&this.handler(r)},this.manager=n,this.element=n.element,this.target=n.options.inputTarget||n.element}callback(n,r){Jgt(this.manager,n,r)}init(){rle(this.element,this.evEl,this.domHandler),rle(this.target,this.evTarget,this.domHandler),rle(pke(this.element),this.evWin,this.domHandler)}destroy(){sle(this.element,this.evEl,this.domHandler),sle(this.target,this.evTarget,this.domHandler),sle(pke(this.element),this.evWin,this.domHandler)}};var hJt={pointerdown:rs.Start,pointermove:rs.Move,pointerup:rs.End,pointercancel:rs.Cancel,pointerout:rs.Cancel},dJt="pointerdown",pJt="pointermove pointerup pointercancel",V$=class extends $${constructor(n){super(n),this.evEl=dJt,this.evWin=pJt,this.store=this.manager.session.pointerEvents=[],this.init()}handler(n){let{store:r}=this,c=!1,u=hJt[n.type],d=n.pointerType,b=d==="touch",w=r.findIndex(_=>_.pointerId===n.pointerId);u&rs.Start&&(n.buttons||b)?w<0&&(r.push(n),w=r.length-1):u&(rs.End|rs.Cancel)&&(c=!0),!(w<0)&&(r[w]=n,this.callback(u,{pointers:r,changedPointers:[n],eventType:u,pointerType:d,srcEvent:n}),c&&r.splice(w,1))}};var gJt=["","webkit","Moz","MS","ms","o"];function Qgt(s,n){let r=n[0].toUpperCase()+n.slice(1);for(let c of gJt){let u=c?c+r:n;if(u in s)return u}}var mJt=1,emt=2,tmt={touchAction:"compute",enable:!0,inputTarget:null,cssProps:{userSelect:"none",userDrag:"none",touchCallout:"none",tapHighlightColor:"rgba(0,0,0,0)"}},W$=class{constructor(n,r){this.options={...tmt,...r,cssProps:{...tmt.cssProps,...r.cssProps},inputTarget:r.inputTarget||n},this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=n,this.input=new V$(this),this.touchAction=new G$(this,this.options.touchAction),this.toggleCssProps(!0)}set(n){return Object.assign(this.options,n),n.touchAction&&this.touchAction.update(),n.inputTarget&&(this.input.destroy(),this.input.target=n.inputTarget,this.input.init()),this}stop(n){this.session.stopped=n?emt:mJt}recognize(n){let{session:r}=this;if(r.stopped)return;this.session.prevented&&n.srcEvent.preventDefault();let c,{recognizers:u}=this,{curRecognizer:d}=r;(!d||d&&d.state&Wi.Recognized)&&(d=r.curRecognizer=null);let b=0;for(;b-1&&this.requireFail.splice(c,1)}return this}hasRequireFailures(){return!!this.requireFail.find(n=>n.options.enable)}canRecognizeWith(n){return!!this.simultaneous[n.id]}emit(n){if(!n)return;let{state:r}=this;r=Wi.Ended&&this.manager.emit(this.options.event+vke(r),n)}tryEmit(n){this.canEmit()?this.emit(n):this.state=Wi.Failed}canEmit(){let n=0;for(;n=n.distance)&&(n.distancePerPointer===void 0||s.distancePerPointer.length>0&&s.distancePerPointer.every(r=>r>=n.distancePerPointer))&&(n.movementDeltaTime===void 0||s.movementDeltaTime>=n.movementDeltaTime)&&(n.rotation===void 0||wJt(s.rotation)>=n.rotation)&&(n.scale===void 0||Math.abs(s.scale-1)>=n.scale)}var b4=class extends uv{attrTest(n){let r=this.options.pointers;return r===0||n.pointers.length===r}coherentTest(n){let r=this.options.coherent;return!r?.length||r.some(c=>vJt(n,c))}process(n){let{state:r}=this,{eventType:c}=n,u=r&(Wi.Began|Wi.Changed),d=this.attrTest(n);return u&&(c&rs.Cancel||!d)?r|Wi.Cancelled:u||d?c&rs.End?r|Wi.Ended:r&Wi.Began?r|Wi.Changed:Wi.Began:Wi.Failed}};var _Jt=["","start","move","end","cancel"],eB=class extends uv{constructor(n={}){super({enable:!0,event:"doubleclickdrag",pointers:1,interval:500,time:350,threshold:28,dragThreshold:1,pixelsPerScale:120,...n}),this._tapStart=null,this._lastTap=null,this._drag=null,this._emittedStart=!1}getTouchAction(){return[g4]}getEventNames(){return _Jt.map(n=>this.options.event+n)}process(n){let{options:r}=this;return n.pointers.length===r.pointers?n.eventType&rs.Start?this._handleStart(n):n.eventType&rs.Move?this._handleMove(n):n.eventType&rs.Cancel?this._handleEnd(n,!0):n.eventType&rs.End?this._handleEnd(n,!1):Wi.Failed:(this.reset(),Wi.Failed)}reset(){this._tapStart=null,this._lastTap=null,this._drag=null,this._emittedStart=!1}emit(n){if(n){if(this.state===Wi.Began){if(!this._drag?.active||this._emittedStart)return;this._emittedStart=!0,this.manager.emit(`${this.options.event}start`,n),this.manager.emit(this.options.event,n);return}if(this.state===Wi.Changed){if(!this._emittedStart)return;this.manager.emit(`${this.options.event}move`,n),this.manager.emit(this.options.event,n);return}if(this.state===Wi.Ended){if(!this._emittedStart)return;this.manager.emit(this.options.event,n),this.manager.emit(`${this.options.event}end`,n),this._emittedStart=!1;return}if(this.state===Wi.Cancelled){if(!this._emittedStart)return;this.manager.emit(this.options.event,n),this.manager.emit(`${this.options.event}cancel`,n),this._emittedStart=!1}}}_handleStart(n){let r=this._getPointerId(n);return this._lastTap&&this._isTapMatch(n,this._lastTap)?(this._tapStart=null,this._lastTap=null,this._drag={startCenter:n.center,pointerId:r,active:!1},this._emittedStart=!1,Wi.Began):(this._tapStart={center:n.center,timeStamp:n.timeStamp,pointerId:r},this._lastTap=null,this._drag=null,this._emittedStart=!1,Wi.Failed)}_handleMove(n){if(!this._drag||!this._isSamePointer(n,this._drag.pointerId))return Wi.Failed;let r=this._drag.startCenter.y-n.center.y;return!this._drag.active&&Math.abs(r){this.state=Wi.Recognized,this.tryEmit(this._input)},r.interval),Wi.Began):Wi.Recognized}return Wi.Failed}failTimeout(){return this._timer=setTimeout(()=>{this.state=Wi.Failed},this.options.interval),Wi.Failed}reset(){clearTimeout(this._timer)}emit(n){this.state===Wi.Recognized&&(n.tapCount=this.count,this.manager.emit(this.options.event,n))}};var tB=class extends b4{constructor(){super(...arguments),this.wheelSession=null,this.wheelSessionUnsubscribe=null,this.handleWheelSessionEvent=n=>{n.device==="trackpad"&&this.handleTrackpadEvent(n)}}set(n){let{wheelSession:r,...c}=n;return r&&r!==this.wheelSession&&(this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=null,this.wheelSession=r),super.set(c),this.updateWheelSessionSubscription(),this}getTrackpadInput(n,r={}){let{srcEvent:c}=n,u=r.deltaX??n.deltaX,d=r.deltaY??n.deltaY,b=QD(u,d),w=Math.sqrt(n.deltaX*n.deltaX+n.deltaY*n.deltaY),_=c;return{pointers:[_,_],changedPointers:[_,_],pointerType:"trackpad",srcEvent:_,eventType:n.eventType,timeStamp:n.timeStamp,deltaTime:n.deltaTime,center:n.center,deltaX:u,deltaY:d,angle:Math.atan2(d,u)*180/Math.PI,distance:Math.sqrt(u*u+d*d),distancePerPointer:[w,w],movementDeltaTime:n.deltaTime,scale:1,rotation:0,direction:b,offsetDirection:b,velocity:n.velocity,velocityX:n.velocityX,velocityY:n.velocityY,overallVelocity:n.overallVelocity,overallVelocityX:n.overallVelocityX,overallVelocityY:n.overallVelocityY,maxPointers:2,target:c.target||this.manager.element,additionalEvent:"",...r}}updateWheelSessionSubscription(){let n=!!(this.wheelSession&&this.options.enable&&this.options.trackpad&&this.options.pointers===2);n&&!this.wheelSessionUnsubscribe?this.wheelSessionUnsubscribe=this.wheelSession.on(this.handleWheelSessionEvent):!n&&this.wheelSessionUnsubscribe&&(this.wheelSessionUnsubscribe(),this.wheelSessionUnsubscribe=null)}};var yJt=["","start","move","end","cancel","up","down","left","right"],WM=class extends tB{constructor(n={}){super({enable:!0,pointers:1,event:"pan",threshold:10,direction:Jl.All,trackpad:!1,coherent:[],...n}),this.trackpadGesture=!1,this.pX=null,this.pY=null}getTouchAction(){let{options:{direction:n}}=this,r=[];return n&Jl.Horizontal&&r.push(z$),n&Jl.Vertical&&r.push(U$),r}getEventNames(){return yJt.map(n=>this.options.event+n)}directionTest(n){let{options:r}=this,c=!0,{distance:u}=n,{direction:d}=n,b=n.deltaX,w=n.deltaY;return d&r.direction||(r.direction&Jl.Horizontal?(d=b===0?Jl.None:b<0?Jl.Left:Jl.Right,c=b!==this.pX,u=Math.abs(n.deltaX)):(d=w===0?Jl.None:w<0?Jl.Up:Jl.Down,c=w!==this.pY,u=Math.abs(n.deltaY))),n.direction=d,c&&u>r.threshold&&!!(d&r.direction)}attrTest(n){let r=!!(this.state&Wi.Began),c=!(this.options.coherent?.length&&n.eventType&(rs.End|rs.Cancel));return super.attrTest(n)&&(r||c&&this.coherentTest(n)&&this.directionTest(n))}emit(n){this.pX=n.deltaX,this.pY=n.deltaY;let r=Jl[n.direction].toLowerCase();r&&(n.additionalEvent=this.options.event+r),super.emit(n)}handleTrackpadEvent(n){n.isFirst&&(this.trackpadGesture=!n.srcEvent.ctrlKey,!this.trackpadGesture&&this.state&(Wi.Recognized|Wi.Cancelled|Wi.Failed)&&(this.state=Wi.Possible)),this.trackpadGesture&&(this.recognize(this.getTrackpadInput(n,{deltaX:-n.deltaX,deltaY:-n.deltaY,velocity:-n.velocity,velocityX:-n.velocityX,velocityY:-n.velocityY,overallVelocity:-n.overallVelocity,overallVelocityX:-n.overallVelocityX,overallVelocityY:-n.overallVelocityY})),n.isFinal&&(this.trackpadGesture=!1))}};var xJt=["","start","move","end","cancel","in","out"],nB=class extends tB{constructor(n={}){super({enable:!0,event:"pinch",threshold:0,pointers:2,trackpad:!1,coherent:[],...n}),this.trackpadGesture=!1}getTouchAction(){return[m4]}getEventNames(){return xJt.map(n=>this.options.event+n)}attrTest(n){let r=!!this.options.coherent?.length,c=!!(this.state&Wi.Began),u=!(r&&n.eventType&(rs.End|rs.Cancel));return super.attrTest(n)&&(c||u&&(r?this.coherentTest(n):Math.abs(n.scale-1)>this.options.threshold))}emit(n){if(n.scale!==1){let r=n.scale<1?"in":"out";n.additionalEvent=this.options.event+r}super.emit(n)}handleTrackpadEvent(n){n.isFirst&&(this.trackpadGesture=n.srcEvent.ctrlKey,!this.trackpadGesture&&this.state&(Wi.Recognized|Wi.Cancelled|Wi.Failed)&&(this.state=Wi.Possible)),this.trackpadGesture&&(this.recognize(this.getTrackpadInput(n,{deltaX:0,deltaY:0,velocity:0,velocityX:0,velocityY:0,overallVelocity:0,overallVelocityX:0,overallVelocityY:0,scale:Math.exp(-n.deltaY/100)})),n.isFinal&&(this.trackpadGesture=!1))}};var Xy=class{constructor(n,r,c){this.element=n,this.callback=r,this.options=c}listen(n,r){r?this.element.addEventListener(n,this.handleEvent,{passive:!1}):this.element.removeEventListener(n,this.handleEvent)}};var imt=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"";var TJt=imt.indexOf("firefox")!==-1,CJt=40,AJt=.25,cle=class extends Xy{constructor(n,r,c){c.enable=c.enable??!1,super(n,r,c),this.handleEvent=u=>{if(!this.options.enable)return;let d=u.deltaY;globalThis.WheelEvent&&(TJt&&u.deltaMode===globalThis.WheelEvent.DOM_DELTA_PIXEL&&(d/=globalThis.devicePixelRatio),u.deltaMode===globalThis.WheelEvent.DOM_DELTA_LINE&&(d*=CJt)),u.shiftKey&&d&&(d=d*AJt),this.callback({type:"wheel",center:{x:u.clientX,y:u.clientY},delta:-d,device:this.options.wheelSession?.device??"unknown",srcEvent:u,pointerType:"mouse",target:u.target})},c.enable&&(this.wheelSessionUnsubscribe=this.options.wheelSession?.on(()=>{}),this.listen("wheel",!0))}destroy(){this.listen("wheel",!1),this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=void 0}enableEventType(n,r){n==="wheel"&&this.options.enable!==r&&(this.options.enable=r,r&&!this.wheelSessionUnsubscribe&&(this.wheelSessionUnsubscribe=this.options.wheelSession?.on(()=>{})),this.listen("wheel",r),r||(this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=void 0))}};var PJt=4.000244140625,rmt=40,LJt=0,kJt=1,RJt=40,smt=40,IJt=120,DJt={classificationDelay:32,endDelay:80},lle=class{constructor(n,r={}){this.subscriptions=new Map,this.session=null,this.classificationTimer=null,this.endTimer=null,this.pressedControlKeys=new Set,this.listeningForControlKeys=!1,this.handleEvent=c=>{if(!this.hasSubscribers)return"unknown";let u=OJt(c,this.pressedControlKeys.size>0),d=this.session;if(d&&u.timeStamp-d.lastTimeStamp>=this.options.endDelay){if(this.end(),!this.hasSubscribers)return"unknown";d=null}d?(this.scheduleEnd(),this.addSample(d,u)):(d=this.startPendingSession(u),this.scheduleEnd());let{device:b}=d;return b==="unknown"&&(b=_ke(d.samples,!1),b!=="unknown"&&this.begin(d,b)),b},this.finishClassification=()=>{if(this.classificationTimer=null,!this.session||this.session.device!=="unknown")return;let c=this.session,u=_ke(c.samples,!0);this.begin(c,u==="unknown"?"mouse":u)},this.end=()=>{if(!this.session)return;if(this.session.device==="unknown"){let u=this.session,d=_ke(u.samples,!0);this.begin(u,d==="unknown"?"mouse":d)}if(!this.session)return;let c=this.session;this.emit(rs.End,c.lastEvent),this.reset()},this.handleKeyDown=c=>{c.key==="Control"&&this.pressedControlKeys.add(c.code||c.key)},this.handleKeyUp=c=>{c.key==="Control"&&(c.code?this.pressedControlKeys.delete(c.code):this.pressedControlKeys.clear())},this.handleWindowBlur=()=>{this.pressedControlKeys.clear()},this.element=n,this.options={...DJt,...r},this.element?.addEventListener("wheel",this.handleEvent,{passive:!0})}get hasSubscribers(){return this.subscriptions.size>0}get device(){return this.session?.device??"unknown"}on(n){let r={listener:n};return this.subscriptions.set(n,r),this.updateControlKeyEventListeners(),()=>{this.subscriptions.get(n)===r&&this.off(n)}}off(n){this.subscriptions.delete(n),this.updateControlKeyEventListeners(),this.hasSubscribers||this.reset()}cancel(){let n=this.session;n&&n.device!=="unknown"&&this.emit(rs.Cancel,n.lastEvent),this.reset()}destroy(){this.cancel(),this.subscriptions.clear(),this.updateControlKeyEventListeners(),this.element?.removeEventListener("wheel",this.handleEvent)}startPendingSession(n){let r={samples:[n],device:"unknown",firstTimeStamp:n.timeStamp,lastTimeStamp:n.timeStamp,totalDeltaX:n.deltaX,totalDeltaY:n.deltaY,velocityX:0,velocityY:0,lastEvent:n.event};return this.session=r,this.classificationTimer=globalThis.setTimeout(this.finishClassification,this.options.classificationDelay),r}addSample(n,r){if(n.samples.push(r),n.lastTimeStamp=r.timeStamp,n.lastEvent=r.event,n.totalDeltaX+=r.deltaX,n.totalDeltaY+=r.deltaY,n.device!=="unknown"){let c=n.samples[n.samples.length-2],u=r.timeStamp-c.timeStamp;n.velocityX=u>0?r.deltaX/u:0,n.velocityY=u>0?r.deltaY/u:0,this.emit(rs.Move,r.event,{velocityX:n.velocityX,velocityY:n.velocityY})}}begin(n,r){n.device=r,this.clearClassificationTimer(),this.emit(rs.Start,n.samples[0].event);let c=n.lastTimeStamp-n.firstTimeStamp;n.velocityX=c>0?n.totalDeltaX/c:0,n.velocityY=c>0?n.totalDeltaY/c:0,this.emit(rs.Move,n.lastEvent,{velocityX:n.velocityX,velocityY:n.velocityY})}scheduleEnd(){this.clearEndTimer(),this.endTimer=globalThis.setTimeout(this.end,this.options.endDelay)}emit(n,r,c){let u=this.session;if(!u||u.device==="unknown")return;let d=n===rs.Start,b=n===rs.End||n===rs.Cancel,w=d?u.firstTimeStamp:u.lastTimeStamp,_=d?0:Math.max(0,w-u.firstTimeStamp),x=d?0:u.totalDeltaX,T=d?0:u.totalDeltaY,M=_>0?x/_:0,L=_>0?T/_:0,I=d?0:c?.velocityX??u.velocityX,D=d?0:c?.velocityY??u.velocityY,F={eventType:n,device:u.device,srcEvent:r,timeStamp:w,center:{x:r.clientX,y:r.clientY},deltaX:x,deltaY:T,deltaTime:_,velocity:Math.abs(I)>Math.abs(D)?I:D,velocityX:I,velocityY:D,overallVelocity:Math.abs(M)>Math.abs(L)?M:L,overallVelocityX:M,overallVelocityY:L,isFirst:d,isFinal:b};for(let{listener:O}of[...this.subscriptions.values()])O(F)}reset(){this.clearClassificationTimer(),this.clearEndTimer(),this.session=null}clearClassificationTimer(){this.classificationTimer!==null&&(globalThis.clearTimeout(this.classificationTimer),this.classificationTimer=null)}clearEndTimer(){this.endTimer!==null&&(globalThis.clearTimeout(this.endTimer),this.endTimer=null)}updateControlKeyEventListeners(){let n=this.hasSubscribers,r=BJt();!r||n===this.listeningForControlKeys||(this.listeningForControlKeys=n,n?(r.addEventListener("keydown",this.handleKeyDown,!0),r.addEventListener("keyup",this.handleKeyUp,!0),r.addEventListener("blur",this.handleWindowBlur)):(r.removeEventListener("keydown",this.handleKeyDown,!0),r.removeEventListener("keyup",this.handleKeyUp,!0),r.removeEventListener("blur",this.handleWindowBlur),this.pressedControlKeys.clear()))}};function BJt(){return typeof window<"u"?window:globalThis.document?.defaultView}function OJt(s,n){let r=s.deltaX,c=s.deltaY;return s.deltaMode===kJt&&(r*=rmt,c*=rmt),{event:s,timeStamp:s.timeStamp,deltaX:r,deltaY:c,isControlKeyDown:n}}function _ke(s,n){return s.some(({event:r,isControlKeyDown:c})=>r.ctrlKey&&!c)?"trackpad":s.some(({event:r})=>r.deltaMode!==LJt)||s.some(NJt)||s.every(({event:r})=>{let c=r.wheelDelta;return c!==void 0&&Math.abs(c)%40===0})?"mouse":s.some(({deltaX:r})=>r!==0)||s.length>1&&FJt(s)?"trackpad":n?"mouse":"unknown"}function NJt({event:s,deltaX:n,deltaY:r}){if(n!==0||r===0)return!1;let c=Math.abs(r/PJt);if(Number.isInteger(c))return!0;let u=s.wheelDelta;return typeof u=="number"&&u!==0&&u%IJt===0}function FJt(s){for(let n=0;nsmt||Math.abs(r.deltaY)>smt||n>0&&r.timeStamp-s[n-1].timeStamp>RJt)return!1}return!0}var omt=["mousedown","mousemove","mouseup","mouseover","mouseout","mouseenter","mouseleave"],ule=class extends Xy{constructor(n,r,c){super(n,r,{enable:!0,...c}),this.handleEvent=d=>{this.handleOverEvent(d),this.handleOutEvent(d),this.handleEnterEvent(d),this.handleLeaveEvent(d),this.handleMoveEvent(d)},this.pressed=!1;let{enable:u=!1}=this.options;this.enableMoveEvent=u,this.enableLeaveEvent=u,this.enableEnterEvent=u,this.enableOutEvent=u,this.enableOverEvent=u,u&&omt.forEach(d=>this.listen(d,!0))}destroy(){omt.forEach(n=>this.listen(n,!1))}enableEventType(n,r){switch(n){case"pointermove":this.enableMoveEvent!==r&&(this.enableMoveEvent=r,this.listen("mousedown",r),this.listen("mousemove",r),this.listen("mouseup",r));break;case"pointerover":this.enableOverEvent!==r&&(this.enableOverEvent=r,this.listen("mouseover",r));break;case"pointerout":this.enableOutEvent!==r&&(this.enableOutEvent=r,this.listen("mouseout",r));break;case"pointerenter":this.enableEnterEvent!==r&&(this.enableEnterEvent=r,this.listen("mouseenter",r));break;case"pointerleave":this.enableLeaveEvent!==r&&(this.enableLeaveEvent=r,this.listen("mouseleave",r));break;default:}}handleOverEvent(n){this.enableOverEvent&&n.type==="mouseover"&&this._emit("pointerover",n)}handleOutEvent(n){this.enableOutEvent&&n.type==="mouseout"&&this._emit("pointerout",n)}handleEnterEvent(n){this.enableEnterEvent&&n.type==="mouseenter"&&this._emit("pointerenter",n)}handleLeaveEvent(n){this.enableLeaveEvent&&n.type==="mouseleave"&&this._emit("pointerleave",n)}handleMoveEvent(n){if(this.enableMoveEvent)switch(n.type){case"mousedown":n.button>=0&&(this.pressed=!0);break;case"mousemove":n.buttons===0&&(this.pressed=!1),this.pressed||this._emit("pointermove",n);break;case"mouseup":this.pressed=!1;break;default:}}_emit(n,r){this.callback({type:n,center:{x:r.clientX,y:r.clientY},srcEvent:r,pointerType:"mouse",target:r.target})}};var amt=["keydown","keyup"],fle=class extends Xy{constructor(n,r,c){super(n,r,{enable:!0,tabIndex:0,...c}),this.handleEvent=d=>{let b=d.target||d.srcElement;b.tagName==="INPUT"&&b.type==="text"||b.tagName==="TEXTAREA"||(this.enableDownEvent&&d.type==="keydown"&&this.callback({type:"keydown",srcEvent:d,key:d.key,target:d.target}),this.enableUpEvent&&d.type==="keyup"&&this.callback({type:"keyup",srcEvent:d,key:d.key,target:d.target}))};let{enable:u=!1}=this.options;this.enableDownEvent=u,this.enableUpEvent=u,n.tabIndex=this.options.tabIndex,n.style.outline="none",u&&amt.forEach(d=>this.listen(d,!0))}destroy(){amt.forEach(n=>this.listen(n,!1))}enableEventType(n,r){n==="keydown"&&this.enableDownEvent!==r&&(this.enableDownEvent=r,this.listen(n,r)),n==="keyup"&&this.enableUpEvent!==r&&(this.enableUpEvent=r,this.listen(n,r))}};var hle=class extends Xy{constructor(n,r,c){c.enable=c.enable??!1,super(n,r,c),this.handleEvent=u=>{this.options.enable&&this.callback({type:"contextmenu",center:{x:u.clientX,y:u.clientY},srcEvent:u,pointerType:"mouse",target:u.target})},c.enable&&this.listen("contextmenu",!0)}destroy(){this.listen("contextmenu",!1)}enableEventType(n,r){n==="contextmenu"&&this.options.enable!==r&&(this.options.enable=r,this.listen("contextmenu",r))}};var UJt={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},zJt=0,GJt=1,jJt=2,$Jt=1,VJt=2,WJt=4;function cmt(s){let n=UJt[s.srcEvent.type];if(!n)return null;let{buttons:r,button:c}=s.srcEvent,u=!1,d=!1,b=!1;return n===2?(u=!!(r&$Jt),d=!!(r&WJt),b=!!(r&VJt)):(u=c===zJt,d=c===GJt,b=c===jJt),{leftButton:u,middleButton:d,rightButton:b}}function lmt(s,n){let r=s.center;if(!r)return null;let c=n.getBoundingClientRect(),u=c.width/n.offsetWidth||1,d=c.height/n.offsetHeight||1,b={x:(r.x-c.left-n.clientLeft)/u,y:(r.y-c.top-n.clientTop)/d};return{center:r,offsetCenter:b}}var HJt={srcElement:"root",priority:0},dle=class{constructor(n,r){this.handleEvent=c=>{if(this.isEmpty())return;let u=this._normalizeEvent(c),d=c.srcEvent.target;for(;d&&d!==u.rootElement;){if(this._emit(u,d),u.handled)return;d=d.parentNode}this._emit(u,"root")},this.eventManager=n,this.recognizerName=r,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(n,r,c,u=!1,d=!1){let{handlers:b,handlersByElement:w}=this,_={...HJt,...c},x=w.get(_.srcElement);x||(x=[],w.set(_.srcElement,x));let T={type:n,handler:r,srcElement:_.srcElement,priority:_.priority};u&&(T.once=!0),d&&(T.passive=!0),b.push(T),this._active=this._active||!T.passive;let M=x.length-1;for(;M>=0&&!(x[M].priority>=T.priority);)M--;x.splice(M+1,0,T)}remove(n,r){let{handlers:c,handlersByElement:u}=this;for(let d=c.length-1;d>=0;d--){let b=c[d];if(b.type===n&&b.handler===r){c.splice(d,1);let w=u.get(b.srcElement);w.splice(w.indexOf(b),1),w.length===0&&u.delete(b.srcElement)}}this._active=c.some(d=>!d.passive)}_emit(n,r){let c=this.handlersByElement.get(r);if(c){let u=!1,d=()=>{n.handled=!0},b=()=>{n.handled=!0,u=!0},w=[];for(let _=0;_{n.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:r}}};function qJt(s){if("recognizer"in s)return s;let n,r=Array.isArray(s)?[...s]:[s];if(typeof r[0]=="function"){let c=r.shift(),u=r.shift()||{};n=new c(u)}else n=r.shift();return{recognizer:n,recognizeWith:typeof r[0]=="string"?[r[0]]:r[0],requireFailure:typeof r[1]=="string"?[r[1]]:r[1]}}var H$=class{constructor(n=null,r={}){if(this._onBasicInput=c=>{this.manager.emit(c.srcEvent.type,c)},this._onOtherEvent=c=>{this.manager.emit(c.type,c)},this.options={recognizers:[],events:{},touchAction:"compute",tabIndex:0,cssProps:{},...r},this.events=new Map,this.element=n,this.wheelSession=new lle(n),!!n){this.manager=new W$(n,this.options);for(let c of this.options.recognizers){let{recognizer:u,recognizeWith:d,requireFailure:b}=qJt(c);this.manager.add(u),d&&u.recognizeWith(d),b&&u.requireFailure(b)}this.manager.on("hammer.input",this._onBasicInput),this.wheelInput=new cle(n,this._onOtherEvent,{enable:!1,wheelSession:this.wheelSession}),this.moveInput=new ule(n,this._onOtherEvent,{enable:!1}),this.keyInput=new fle(n,this._onOtherEvent,{enable:!1,tabIndex:r.tabIndex}),this.contextmenuInput=new hle(n,this._onOtherEvent,{enable:!1}),this.on(this.options.events)}}getElement(){return this.element}destroy(){if(!this.element){this.wheelSession.destroy();return}this.wheelInput.destroy(),this.wheelSession.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy()}on(n,r,c){this._addEventHandler(n,r,c,!1)}once(n,r,c){this._addEventHandler(n,r,c,!0)}watch(n,r,c){this._addEventHandler(n,r,c,!1,!0)}off(n,r){this._removeEventHandler(n,r)}emit(n){this.manager?.emit(n.type,n)}_toggleRecognizer(n,r){let{manager:c}=this;if(!c)return;let u=c.get(n);u&&(u.set({enable:r,wheelSession:this.wheelSession}),c.touchAction.update()),this.wheelInput?.enableEventType(n,r),this.moveInput?.enableEventType(n,r),this.keyInput?.enableEventType(n,r),this.contextmenuInput?.enableEventType(n,r)}_addEventHandler(n,r,c,u,d){if(typeof n!="string"){c=r;for(let[x,T]of Object.entries(n))this._addEventHandler(x,T,c,u,d);return}let{manager:b,events:w}=this;if(!b)return;let _=w.get(n);if(!_){let x=this._getRecognizerName(n)||n;_=new dle(this,x),w.set(n,_),b&&b.on(n,_.handleEvent)}_.add(n,r,c,u,d),_.isEmpty()||this._toggleRecognizer(_.recognizerName,!0)}_removeEventHandler(n,r){if(typeof n!="string"){for(let[d,b]of Object.entries(n))this._removeEventHandler(d,b);return}let{events:c}=this,u=c.get(n);if(u&&(u.remove(n,r),u.isEmpty())){let{recognizerName:d}=u,b=!1;for(let w of c.values())if(w.recognizerName===d&&!w.isEmpty()){b=!0;break}b||this._toggleRecognizer(d,!1)}}_getRecognizerName(n){return this.manager.recognizers.find(r=>r.getEventNames().includes(n))?.options.event}};var yke={DEFAULT:"default",LNGLAT:"lnglat",METER_OFFSETS:"meter-offsets",LNGLAT_OFFSETS:"lnglat-offsets",CARTESIAN:"cartesian"};Object.defineProperty(yke,"IDENTITY",{get:()=>(Bs.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),yke.CARTESIAN)});var $h={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},Pb={common:0,meters:1,pixels:2},iB={click:"onClick",dblclick:"onClick",panstart:"onDragStart",panmove:"onDrag",panend:"onDragEnd"},xke={multipan:[WM,{threshold:10,pointers:2,trackpad:!0}],pinch:[nB,{trackpad:!0},null,["multipan"]],pan:[WM,{threshold:1},["pinch"],["multipan"]],dblclick:[w4,{event:"dblclick",taps:2,enable:!1}],dblclickdrag:[eB,{event:"dblclickdrag",enable:!1},["dblclick"],null],click:[w4,{event:"click"},["dblclickdrag"],["dblclick","dblclickdrag"]]};function XJt(s,n){if(s===n)return!0;if(Array.isArray(s)){let r=s.length;if(!n||n.length!==r)return!1;for(let c=0;c{for(let u in c)if(!XJt(c[u],n[u])){r=s(c),n=c;break}return r}}var umt=[0,0,0,0],YJt=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],fmt=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],ZJt=[0,0,0],hmt=[0,0,0],KJt={default:-1,cartesian:0,lnglat:1,"meter-offsets":2,"lnglat-offsets":3};function v4(s){let n=KJt[s];if(n===void 0)throw new Error(`Invalid coordinateSystem: ${s}`);return n}var JJt=Yy(eQt);function Eke(s,n,r=hmt){r.length<3&&(r=[r[0],r[1],0]);let c=r,u,d=!0;switch(n==="lnglat-offsets"||n==="meter-offsets"?u=r:u=s.isGeospatial?[Math.fround(s.longitude),Math.fround(s.latitude),0]:null,s.projectionMode){case $h.WEB_MERCATOR:(n==="lnglat"||n==="cartesian")&&(u=[0,0,0],d=!1);break;case $h.WEB_MERCATOR_AUTO_OFFSET:n==="lnglat"?c=u:n==="cartesian"&&(c=[Math.fround(s.center[0]),Math.fround(s.center[1]),0],u=s.unprojectPosition(c),c[0]-=r[0],c[1]-=r[1],c[2]-=r[2]);break;case $h.IDENTITY:c=s.position.map(Math.fround),c[2]=c[2]||0;break;case $h.GLOBE:d=!1,u=null;break;default:d=!1}return{geospatialOrigin:u,shaderCoordinateOrigin:c,offsetMode:d}}function QJt(s,n,r){let{viewMatrixUncentered:c,projectionMatrix:u}=s,{viewMatrix:d,viewProjectionMatrix:b}=s,w=umt,_=umt,x=s.cameraPosition,{geospatialOrigin:T,shaderCoordinateOrigin:M,offsetMode:L}=Eke(s,n,r);return L&&(_=s.projectPosition(T||M),x=[x[0]-_[0],x[1]-_[1],x[2]-_[2]],_[3]=1,w=U1.transformMat4([],_,b),d=c||d,b=fh.multiply([],u,d),b=fh.multiply([],b,YJt)),{viewMatrix:d,viewProjectionMatrix:b,projectionCenter:w,originCommon:_,cameraPosCommon:x,shaderCoordinateOrigin:M,geospatialOrigin:T}}function dmt({viewport:s,devicePixelRatio:n=1,modelMatrix:r=null,coordinateSystem:c="default",coordinateOrigin:u=hmt,autoWrapLongitude:d=!1}){c==="default"&&(c=s.isGeospatial?"lnglat":"cartesian");let b=JJt({viewport:s,devicePixelRatio:n,coordinateSystem:c,coordinateOrigin:u});return b.wrapLongitude=d,b.modelMatrix=r||fmt,b}function eQt({viewport:s,devicePixelRatio:n,coordinateSystem:r,coordinateOrigin:c}){let{projectionCenter:u,viewProjectionMatrix:d,originCommon:b,cameraPosCommon:w,shaderCoordinateOrigin:_,geospatialOrigin:x}=QJt(s,r,c),T=s.getDistanceScales(),M=[s.width*n,s.height*n],L=U1.transformMat4([],[0,0,-s.focalDistance,1],s.projectionMatrix)[3]||1,I={coordinateSystem:v4(r),projectionMode:s.projectionMode,coordinateOrigin:_,commonOrigin:b.slice(0,3),center:u,pseudoMeters:!!s._pseudoMeters,viewportSize:M,devicePixelRatio:n,focalDistance:L,commonUnitsPerMeter:T.unitsPerMeter,commonUnitsPerWorldUnit:T.unitsPerMeter,commonUnitsPerWorldUnit2:ZJt,scale:s.scale,wrapLongitude:!1,viewProjectionMatrix:d,modelMatrix:fmt,cameraPosition:w};if(x){let D=s.getDistanceScales(x);switch(r){case"meter-offsets":I.commonUnitsPerWorldUnit=D.unitsPerMeter,I.commonUnitsPerWorldUnit2=D.unitsPerMeter2;break;case"lnglat":case"lnglat-offsets":s._pseudoMeters||(I.commonUnitsPerMeter=D.unitsPerMeter),I.commonUnitsPerWorldUnit=D.unitsPerDegree,I.commonUnitsPerWorldUnit2=D.unitsPerDegree2;break;case"cartesian":I.commonUnitsPerWorldUnit=[1,1,D.unitsPerMeter[2]],I.commonUnitsPerWorldUnit2=[0,0,D.unitsPerMeter2[2]];break;default:break}}if(s.projectionMode===$h.GLOBE&&r==="meter-offsets"){let O=c[0]*Math.PI/180,z=c[1]*Math.PI/180,Z=Math.cos(z),H=((c[2]||0)/6370972+1)*256;I.commonOrigin=[Math.sin(O)*Z*H,-Math.cos(O)*Z*H,Math.sin(z)*H]}return I}var tQt=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],nQt=tQt.map(s=>`const COORDINATE_SYSTEM_${s.toUpperCase().replaceAll("-","_")}: i32 = ${v4(s)};`).join(""),iQt=Object.keys($h).map(s=>`const PROJECTION_MODE_${s}: i32 = ${$h[s]};`).join(""),rQt=Object.keys(Pb).map(s=>`const UNIT_${s.toUpperCase()}: i32 = ${Pb[s]};`).join(""),sQt=`${nQt} -${iQt} -${rQt} +`,ile={name:"geometry",source:uJt,vs:fJt,fs:hJt};vm();Nf();var rs;(function(s){s[s.Start=1]="Start",s[s.Move=2]="Move",s[s.End=4]="End",s[s.Cancel=8]="Cancel"})(rs||(rs={}));var Jl;(function(s){s[s.None=0]="None",s[s.Left=1]="Left",s[s.Right=2]="Right",s[s.Up=4]="Up",s[s.Down=8]="Down",s[s.Horizontal=3]="Horizontal",s[s.Vertical=12]="Vertical",s[s.All=15]="All"})(Jl||(Jl={}));var Wi;(function(s){s[s.Possible=1]="Possible",s[s.Began=2]="Began",s[s.Changed=4]="Changed",s[s.Ended=8]="Ended",s[s.Recognized=8]="Recognized",s[s.Cancelled=16]="Cancelled",s[s.Failed=32]="Failed"})(Wi||(Wi={}));var Vgt="compute",hke="auto",g4="manipulation",m4="none",U$="pan-x",z$="pan-y";function dke(s){if(s.includes(m4))return m4;let n=s.includes(U$),r=s.includes(z$);return n&&r?m4:n||r?n?U$:z$:s.includes(g4)?g4:hke}var G$=class{constructor(n,r){this.actions="",this.manager=n,this.set(r)}set(n){n===Vgt&&(n=this.compute()),this.manager.element&&(this.manager.element.style.touchAction=n,this.actions=n)}update(){this.set(this.manager.options.touchAction)}compute(){let n=[];for(let r of this.manager.recognizers)r.options.enable&&(n=n.concat(r.getTouchAction()));return dke(n.join(" "))}};function KD(s){return s.trim().split(/\s+/g)}function rle(s,n,r){if(s)for(let c of KD(n))s.addEventListener(c,r,!1)}function sle(s,n,r){if(s)for(let c of KD(n))s.removeEventListener(c,r,!1)}function pke(s){return(s.ownerDocument||s).defaultView}function gke(s,n){let r=s;for(;r;){if(r===n)return!0;r=r.parentNode}return!1}function ole(s){let n=s.length;if(n===1)return{x:Math.round(s[0].clientX),y:Math.round(s[0].clientY)};let r=0,c=0,u=0;for(;u=Math.abs(n)?s<0?Jl.Left:Jl.Right:n<0?Jl.Up:Jl.Down}function Hgt(s,n){let r=n.center,c=s.offsetDelta,u=s.prevDelta,d=s.prevInput;return(n.eventType===rs.Start||d?.eventType===rs.End)&&(u=s.prevDelta={x:d?.deltaX||0,y:d?.deltaY||0},c=s.offsetDelta={x:r.x,y:r.y}),{deltaX:u.x+(r.x-c.x),deltaY:u.y+(r.y-c.y)}}function ale(s,n,r){return{x:n/s||0,y:r/s||0}}function qgt(s,n){return j$(n[0],n[1])/j$(s[0],s[1])}function Xgt(s,n){return bke(n[1],n[0])-bke(s[1],s[0])}function Ygt(s,n){let r=s.lastInterval||n,c=n.timeStamp-r.timeStamp,u,d,b,w;if(n.eventType!==rs.Cancel&&(c>25||r.velocity===void 0)){let _=n.deltaX-r.deltaX,x=n.deltaY-r.deltaY,T=ale(c,_,x);d=T.x,b=T.y,u=Math.abs(T.x)>Math.abs(T.y)?T.x:T.y,w=QD(_,x),s.lastInterval=n}else u=r.velocity,d=r.velocityX,b=r.velocityY,w=r.direction;n.velocity=u,n.velocityX=d,n.velocityY=b,n.direction=w}function wke(s,n){return"pointerId"in s?s.pointerId:n}function Zgt(s,n){s.movementOrigin=new Map(n.map((r,c)=>[wke(r,c),{clientX:r.clientX,clientY:r.clientY}])),s.firstMovementTime=void 0}function pJt(s,n){let r=n.pointers.map(wke);if(s.movementOrigin?.size===r.length&&r.every(u=>s.movementOrigin.has(u))||Zgt(s,n.pointers),n.distancePerPointer=n.pointers.map((u,d)=>j$(s.movementOrigin.get(r[d]),u)),n.eventType&rs.Move&&n.distancePerPointer.some(u=>u>0)&&(s.firstMovementTime??(s.firstMovementTime=n.timeStamp)),n.movementDeltaTime=s.firstMovementTime===void 0?0:n.timeStamp-s.firstMovementTime,n.eventType&(rs.End|rs.Cancel)){let u=n.changedPointers.map(d=>wke(d,n.pointers.indexOf(d)));Zgt(s,n.pointers.filter((d,b)=>!u.includes(r[b])))}}function Kgt(s,n){let{session:r}=s,{pointers:c}=n,{length:u}=c;r.firstInput||(r.firstInput=mke(n)),u>1&&!r.firstMultiple?r.firstMultiple=mke(n):u===1&&(r.firstMultiple=!1);let{firstInput:d,firstMultiple:b}=r,w=b?b.center:d.center,_=n.center=ole(c);n.timeStamp=Date.now(),n.deltaTime=n.timeStamp-d.timeStamp,pJt(r,n),n.angle=Wgt(w,_),n.distance=JD(w,_);let{deltaX:x,deltaY:T}=Hgt(r,n);n.deltaX=x,n.deltaY=T,n.offsetDirection=QD(n.deltaX,n.deltaY);let M=ale(n.deltaTime,n.deltaX,n.deltaY);n.overallVelocityX=M.x,n.overallVelocityY=M.y,n.overallVelocity=Math.abs(M.x)>Math.abs(M.y)?M.x:M.y,n.scale=b?qgt(b.pointers,c):1,n.rotation=b?Xgt(b.pointers,c):0,n.maxPointers=r.prevInput?n.pointers.length>r.prevInput.maxPointers?n.pointers.length:r.prevInput.maxPointers:n.pointers.length;let L=s.element;return gke(n.srcEvent.target,L)&&(L=n.srcEvent.target),n.target=L,Ygt(r,n),n}function Jgt(s,n,r){let c=r.pointers.length,u=r.changedPointers.length,d=n&rs.Start&&c-u===0,b=n&(rs.End|rs.Cancel)&&c-u===0;r.isFirst=!!d,r.isFinal=!!b,d&&(s.session={}),r.eventType=n;let w=Kgt(s,r);s.emit("hammer.input",w),s.recognize(w),s.session.prevInput=w}var $$=class{constructor(n){this.evEl="",this.evWin="",this.evTarget="",this.domHandler=r=>{this.manager.options.enable&&this.handler(r)},this.manager=n,this.element=n.element,this.target=n.options.inputTarget||n.element}callback(n,r){Jgt(this.manager,n,r)}init(){rle(this.element,this.evEl,this.domHandler),rle(this.target,this.evTarget,this.domHandler),rle(pke(this.element),this.evWin,this.domHandler)}destroy(){sle(this.element,this.evEl,this.domHandler),sle(this.target,this.evTarget,this.domHandler),sle(pke(this.element),this.evWin,this.domHandler)}};var gJt={pointerdown:rs.Start,pointermove:rs.Move,pointerup:rs.End,pointercancel:rs.Cancel,pointerout:rs.Cancel},mJt="pointerdown",bJt="pointermove pointerup pointercancel",V$=class extends $${constructor(n){super(n),this.evEl=mJt,this.evWin=bJt,this.store=this.manager.session.pointerEvents=[],this.init()}handler(n){let{store:r}=this,c=!1,u=gJt[n.type],d=n.pointerType,b=d==="touch",w=r.findIndex(_=>_.pointerId===n.pointerId);u&rs.Start&&(n.buttons||b)?w<0&&(r.push(n),w=r.length-1):u&(rs.End|rs.Cancel)&&(c=!0),!(w<0)&&(r[w]=n,this.callback(u,{pointers:r,changedPointers:[n],eventType:u,pointerType:d,srcEvent:n}),c&&r.splice(w,1))}};var wJt=["","webkit","Moz","MS","ms","o"];function Qgt(s,n){let r=n[0].toUpperCase()+n.slice(1);for(let c of wJt){let u=c?c+r:n;if(u in s)return u}}var vJt=1,emt=2,tmt={touchAction:"compute",enable:!0,inputTarget:null,cssProps:{userSelect:"none",userDrag:"none",touchCallout:"none",tapHighlightColor:"rgba(0,0,0,0)"}},W$=class{constructor(n,r){this.options={...tmt,...r,cssProps:{...tmt.cssProps,...r.cssProps},inputTarget:r.inputTarget||n},this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=n,this.input=new V$(this),this.touchAction=new G$(this,this.options.touchAction),this.toggleCssProps(!0)}set(n){return Object.assign(this.options,n),n.touchAction&&this.touchAction.update(),n.inputTarget&&(this.input.destroy(),this.input.target=n.inputTarget,this.input.init()),this}stop(n){this.session.stopped=n?emt:vJt}recognize(n){let{session:r}=this;if(r.stopped)return;this.session.prevented&&n.srcEvent.preventDefault();let c,{recognizers:u}=this,{curRecognizer:d}=r;(!d||d&&d.state&Wi.Recognized)&&(d=r.curRecognizer=null);let b=0;for(;b-1&&this.requireFail.splice(c,1)}return this}hasRequireFailures(){return!!this.requireFail.find(n=>n.options.enable)}canRecognizeWith(n){return!!this.simultaneous[n.id]}emit(n){if(!n)return;let{state:r}=this;r=Wi.Ended&&this.manager.emit(this.options.event+vke(r),n)}tryEmit(n){this.canEmit()?this.emit(n):this.state=Wi.Failed}canEmit(){let n=0;for(;n=n.distance)&&(n.distancePerPointer===void 0||s.distancePerPointer.length>0&&s.distancePerPointer.every(r=>r>=n.distancePerPointer))&&(n.movementDeltaTime===void 0||s.movementDeltaTime>=n.movementDeltaTime)&&(n.rotation===void 0||yJt(s.rotation)>=n.rotation)&&(n.scale===void 0||Math.abs(s.scale-1)>=n.scale)}var b4=class extends uv{attrTest(n){let r=this.options.pointers;return r===0||n.pointers.length===r}coherentTest(n){let r=this.options.coherent;return!r?.length||r.some(c=>xJt(n,c))}process(n){let{state:r}=this,{eventType:c}=n,u=r&(Wi.Began|Wi.Changed),d=this.attrTest(n);return u&&(c&rs.Cancel||!d)?r|Wi.Cancelled:u||d?c&rs.End?r|Wi.Ended:r&Wi.Began?r|Wi.Changed:Wi.Began:Wi.Failed}};var EJt=["","start","move","end","cancel"],eB=class extends uv{constructor(n={}){super({enable:!0,event:"doubleclickdrag",pointers:1,interval:500,time:350,threshold:28,dragThreshold:1,pixelsPerScale:120,...n}),this._tapStart=null,this._lastTap=null,this._drag=null,this._emittedStart=!1}getTouchAction(){return[g4]}getEventNames(){return EJt.map(n=>this.options.event+n)}process(n){let{options:r}=this;return n.pointers.length===r.pointers?n.eventType&rs.Start?this._handleStart(n):n.eventType&rs.Move?this._handleMove(n):n.eventType&rs.Cancel?this._handleEnd(n,!0):n.eventType&rs.End?this._handleEnd(n,!1):Wi.Failed:(this.reset(),Wi.Failed)}reset(){this._tapStart=null,this._lastTap=null,this._drag=null,this._emittedStart=!1}emit(n){if(n){if(this.state===Wi.Began){if(!this._drag?.active||this._emittedStart)return;this._emittedStart=!0,this.manager.emit(`${this.options.event}start`,n),this.manager.emit(this.options.event,n);return}if(this.state===Wi.Changed){if(!this._emittedStart)return;this.manager.emit(`${this.options.event}move`,n),this.manager.emit(this.options.event,n);return}if(this.state===Wi.Ended){if(!this._emittedStart)return;this.manager.emit(this.options.event,n),this.manager.emit(`${this.options.event}end`,n),this._emittedStart=!1;return}if(this.state===Wi.Cancelled){if(!this._emittedStart)return;this.manager.emit(this.options.event,n),this.manager.emit(`${this.options.event}cancel`,n),this._emittedStart=!1}}}_handleStart(n){let r=this._getPointerId(n);return this._lastTap&&this._isTapMatch(n,this._lastTap)?(this._tapStart=null,this._lastTap=null,this._drag={startCenter:n.center,pointerId:r,active:!1},this._emittedStart=!1,Wi.Began):(this._tapStart={center:n.center,timeStamp:n.timeStamp,pointerId:r},this._lastTap=null,this._drag=null,this._emittedStart=!1,Wi.Failed)}_handleMove(n){if(!this._drag||!this._isSamePointer(n,this._drag.pointerId))return Wi.Failed;let r=this._drag.startCenter.y-n.center.y;return!this._drag.active&&Math.abs(r){this.state=Wi.Recognized,this.tryEmit(this._input)},r.interval),Wi.Began):Wi.Recognized}return Wi.Failed}failTimeout(){return this._timer=setTimeout(()=>{this.state=Wi.Failed},this.options.interval),Wi.Failed}reset(){clearTimeout(this._timer)}emit(n){this.state===Wi.Recognized&&(n.tapCount=this.count,this.manager.emit(this.options.event,n))}};var tB=class extends b4{constructor(){super(...arguments),this.wheelSession=null,this.wheelSessionUnsubscribe=null,this.handleWheelSessionEvent=n=>{n.device==="trackpad"&&this.handleTrackpadEvent(n)}}set(n){let{wheelSession:r,...c}=n;return r&&r!==this.wheelSession&&(this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=null,this.wheelSession=r),super.set(c),this.updateWheelSessionSubscription(),this}getTrackpadInput(n,r={}){let{srcEvent:c}=n,u=r.deltaX??n.deltaX,d=r.deltaY??n.deltaY,b=QD(u,d),w=Math.sqrt(n.deltaX*n.deltaX+n.deltaY*n.deltaY),_=c;return{pointers:[_,_],changedPointers:[_,_],pointerType:"trackpad",srcEvent:_,eventType:n.eventType,timeStamp:n.timeStamp,deltaTime:n.deltaTime,center:n.center,deltaX:u,deltaY:d,angle:Math.atan2(d,u)*180/Math.PI,distance:Math.sqrt(u*u+d*d),distancePerPointer:[w,w],movementDeltaTime:n.deltaTime,scale:1,rotation:0,direction:b,offsetDirection:b,velocity:n.velocity,velocityX:n.velocityX,velocityY:n.velocityY,overallVelocity:n.overallVelocity,overallVelocityX:n.overallVelocityX,overallVelocityY:n.overallVelocityY,maxPointers:2,target:c.target||this.manager.element,additionalEvent:"",...r}}updateWheelSessionSubscription(){let n=!!(this.wheelSession&&this.options.enable&&this.options.trackpad&&this.options.pointers===2);n&&!this.wheelSessionUnsubscribe?this.wheelSessionUnsubscribe=this.wheelSession.on(this.handleWheelSessionEvent):!n&&this.wheelSessionUnsubscribe&&(this.wheelSessionUnsubscribe(),this.wheelSessionUnsubscribe=null)}};var SJt=["","start","move","end","cancel","up","down","left","right"],WM=class extends tB{constructor(n={}){super({enable:!0,pointers:1,event:"pan",threshold:10,direction:Jl.All,trackpad:!1,coherent:[],...n}),this.trackpadGesture=!1,this.pX=null,this.pY=null}getTouchAction(){let{options:{direction:n}}=this,r=[];return n&Jl.Horizontal&&r.push(z$),n&Jl.Vertical&&r.push(U$),r}getEventNames(){return SJt.map(n=>this.options.event+n)}directionTest(n){let{options:r}=this,c=!0,{distance:u}=n,{direction:d}=n,b=n.deltaX,w=n.deltaY;return d&r.direction||(r.direction&Jl.Horizontal?(d=b===0?Jl.None:b<0?Jl.Left:Jl.Right,c=b!==this.pX,u=Math.abs(n.deltaX)):(d=w===0?Jl.None:w<0?Jl.Up:Jl.Down,c=w!==this.pY,u=Math.abs(n.deltaY))),n.direction=d,c&&u>r.threshold&&!!(d&r.direction)}attrTest(n){let r=!!(this.state&Wi.Began),c=!(this.options.coherent?.length&&n.eventType&(rs.End|rs.Cancel));return super.attrTest(n)&&(r||c&&this.coherentTest(n)&&this.directionTest(n))}emit(n){this.pX=n.deltaX,this.pY=n.deltaY;let r=Jl[n.direction].toLowerCase();r&&(n.additionalEvent=this.options.event+r),super.emit(n)}handleTrackpadEvent(n){n.isFirst&&(this.trackpadGesture=!n.srcEvent.ctrlKey,!this.trackpadGesture&&this.state&(Wi.Recognized|Wi.Cancelled|Wi.Failed)&&(this.state=Wi.Possible)),this.trackpadGesture&&(this.recognize(this.getTrackpadInput(n,{deltaX:-n.deltaX,deltaY:-n.deltaY,velocity:-n.velocity,velocityX:-n.velocityX,velocityY:-n.velocityY,overallVelocity:-n.overallVelocity,overallVelocityX:-n.overallVelocityX,overallVelocityY:-n.overallVelocityY})),n.isFinal&&(this.trackpadGesture=!1))}};var MJt=["","start","move","end","cancel","in","out"],nB=class extends tB{constructor(n={}){super({enable:!0,event:"pinch",threshold:0,pointers:2,trackpad:!1,coherent:[],...n}),this.trackpadGesture=!1}getTouchAction(){return[m4]}getEventNames(){return MJt.map(n=>this.options.event+n)}attrTest(n){let r=!!this.options.coherent?.length,c=!!(this.state&Wi.Began),u=!(r&&n.eventType&(rs.End|rs.Cancel));return super.attrTest(n)&&(c||u&&(r?this.coherentTest(n):Math.abs(n.scale-1)>this.options.threshold))}emit(n){if(n.scale!==1){let r=n.scale<1?"in":"out";n.additionalEvent=this.options.event+r}super.emit(n)}handleTrackpadEvent(n){n.isFirst&&(this.trackpadGesture=n.srcEvent.ctrlKey,!this.trackpadGesture&&this.state&(Wi.Recognized|Wi.Cancelled|Wi.Failed)&&(this.state=Wi.Possible)),this.trackpadGesture&&(this.recognize(this.getTrackpadInput(n,{deltaX:0,deltaY:0,velocity:0,velocityX:0,velocityY:0,overallVelocity:0,overallVelocityX:0,overallVelocityY:0,scale:Math.exp(-n.deltaY/100)})),n.isFinal&&(this.trackpadGesture=!1))}};var Xy=class{constructor(n,r,c){this.element=n,this.callback=r,this.options=c}listen(n,r){r?this.element.addEventListener(n,this.handleEvent,{passive:!1}):this.element.removeEventListener(n,this.handleEvent)}};var imt=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"";var PJt=imt.indexOf("firefox")!==-1,LJt=40,kJt=.25,cle=class extends Xy{constructor(n,r,c){c.enable=c.enable??!1,super(n,r,c),this.handleEvent=u=>{if(!this.options.enable)return;let d=u.deltaY;globalThis.WheelEvent&&(PJt&&u.deltaMode===globalThis.WheelEvent.DOM_DELTA_PIXEL&&(d/=globalThis.devicePixelRatio),u.deltaMode===globalThis.WheelEvent.DOM_DELTA_LINE&&(d*=LJt)),u.shiftKey&&d&&(d=d*kJt),this.callback({type:"wheel",center:{x:u.clientX,y:u.clientY},delta:-d,device:this.options.wheelSession?.device??"unknown",srcEvent:u,pointerType:"mouse",target:u.target})},c.enable&&(this.wheelSessionUnsubscribe=this.options.wheelSession?.on(()=>{}),this.listen("wheel",!0))}destroy(){this.listen("wheel",!1),this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=void 0}enableEventType(n,r){n==="wheel"&&this.options.enable!==r&&(this.options.enable=r,r&&!this.wheelSessionUnsubscribe&&(this.wheelSessionUnsubscribe=this.options.wheelSession?.on(()=>{})),this.listen("wheel",r),r||(this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=void 0))}};var RJt=4.000244140625,rmt=40,IJt=0,DJt=1,BJt=40,smt=40,OJt=120,NJt={classificationDelay:32,endDelay:80},lle=class{constructor(n,r={}){this.subscriptions=new Map,this.session=null,this.classificationTimer=null,this.endTimer=null,this.pressedControlKeys=new Set,this.listeningForControlKeys=!1,this.handleEvent=c=>{if(!this.hasSubscribers)return"unknown";let u=UJt(c,this.pressedControlKeys.size>0),d=this.session;if(d&&u.timeStamp-d.lastTimeStamp>=this.options.endDelay){if(this.end(),!this.hasSubscribers)return"unknown";d=null}d?(this.scheduleEnd(),this.addSample(d,u)):(d=this.startPendingSession(u),this.scheduleEnd());let{device:b}=d;return b==="unknown"&&(b=_ke(d.samples,!1),b!=="unknown"&&this.begin(d,b)),b},this.finishClassification=()=>{if(this.classificationTimer=null,!this.session||this.session.device!=="unknown")return;let c=this.session,u=_ke(c.samples,!0);this.begin(c,u==="unknown"?"mouse":u)},this.end=()=>{if(!this.session)return;if(this.session.device==="unknown"){let u=this.session,d=_ke(u.samples,!0);this.begin(u,d==="unknown"?"mouse":d)}if(!this.session)return;let c=this.session;this.emit(rs.End,c.lastEvent),this.reset()},this.handleKeyDown=c=>{c.key==="Control"&&this.pressedControlKeys.add(c.code||c.key)},this.handleKeyUp=c=>{c.key==="Control"&&(c.code?this.pressedControlKeys.delete(c.code):this.pressedControlKeys.clear())},this.handleWindowBlur=()=>{this.pressedControlKeys.clear()},this.element=n,this.options={...NJt,...r},this.element?.addEventListener("wheel",this.handleEvent,{passive:!0})}get hasSubscribers(){return this.subscriptions.size>0}get device(){return this.session?.device??"unknown"}on(n){let r={listener:n};return this.subscriptions.set(n,r),this.updateControlKeyEventListeners(),()=>{this.subscriptions.get(n)===r&&this.off(n)}}off(n){this.subscriptions.delete(n),this.updateControlKeyEventListeners(),this.hasSubscribers||this.reset()}cancel(){let n=this.session;n&&n.device!=="unknown"&&this.emit(rs.Cancel,n.lastEvent),this.reset()}destroy(){this.cancel(),this.subscriptions.clear(),this.updateControlKeyEventListeners(),this.element?.removeEventListener("wheel",this.handleEvent)}startPendingSession(n){let r={samples:[n],device:"unknown",firstTimeStamp:n.timeStamp,lastTimeStamp:n.timeStamp,totalDeltaX:n.deltaX,totalDeltaY:n.deltaY,velocityX:0,velocityY:0,lastEvent:n.event};return this.session=r,this.classificationTimer=globalThis.setTimeout(this.finishClassification,this.options.classificationDelay),r}addSample(n,r){if(n.samples.push(r),n.lastTimeStamp=r.timeStamp,n.lastEvent=r.event,n.totalDeltaX+=r.deltaX,n.totalDeltaY+=r.deltaY,n.device!=="unknown"){let c=n.samples[n.samples.length-2],u=r.timeStamp-c.timeStamp;n.velocityX=u>0?r.deltaX/u:0,n.velocityY=u>0?r.deltaY/u:0,this.emit(rs.Move,r.event,{velocityX:n.velocityX,velocityY:n.velocityY})}}begin(n,r){n.device=r,this.clearClassificationTimer(),this.emit(rs.Start,n.samples[0].event);let c=n.lastTimeStamp-n.firstTimeStamp;n.velocityX=c>0?n.totalDeltaX/c:0,n.velocityY=c>0?n.totalDeltaY/c:0,this.emit(rs.Move,n.lastEvent,{velocityX:n.velocityX,velocityY:n.velocityY})}scheduleEnd(){this.clearEndTimer(),this.endTimer=globalThis.setTimeout(this.end,this.options.endDelay)}emit(n,r,c){let u=this.session;if(!u||u.device==="unknown")return;let d=n===rs.Start,b=n===rs.End||n===rs.Cancel,w=d?u.firstTimeStamp:u.lastTimeStamp,_=d?0:Math.max(0,w-u.firstTimeStamp),x=d?0:u.totalDeltaX,T=d?0:u.totalDeltaY,M=_>0?x/_:0,L=_>0?T/_:0,I=d?0:c?.velocityX??u.velocityX,D=d?0:c?.velocityY??u.velocityY,F={eventType:n,device:u.device,srcEvent:r,timeStamp:w,center:{x:r.clientX,y:r.clientY},deltaX:x,deltaY:T,deltaTime:_,velocity:Math.abs(I)>Math.abs(D)?I:D,velocityX:I,velocityY:D,overallVelocity:Math.abs(M)>Math.abs(L)?M:L,overallVelocityX:M,overallVelocityY:L,isFirst:d,isFinal:b};for(let{listener:O}of[...this.subscriptions.values()])O(F)}reset(){this.clearClassificationTimer(),this.clearEndTimer(),this.session=null}clearClassificationTimer(){this.classificationTimer!==null&&(globalThis.clearTimeout(this.classificationTimer),this.classificationTimer=null)}clearEndTimer(){this.endTimer!==null&&(globalThis.clearTimeout(this.endTimer),this.endTimer=null)}updateControlKeyEventListeners(){let n=this.hasSubscribers,r=FJt();!r||n===this.listeningForControlKeys||(this.listeningForControlKeys=n,n?(r.addEventListener("keydown",this.handleKeyDown,!0),r.addEventListener("keyup",this.handleKeyUp,!0),r.addEventListener("blur",this.handleWindowBlur)):(r.removeEventListener("keydown",this.handleKeyDown,!0),r.removeEventListener("keyup",this.handleKeyUp,!0),r.removeEventListener("blur",this.handleWindowBlur),this.pressedControlKeys.clear()))}};function FJt(){return typeof window<"u"?window:globalThis.document?.defaultView}function UJt(s,n){let r=s.deltaX,c=s.deltaY;return s.deltaMode===DJt&&(r*=rmt,c*=rmt),{event:s,timeStamp:s.timeStamp,deltaX:r,deltaY:c,isControlKeyDown:n}}function _ke(s,n){return s.some(({event:r,isControlKeyDown:c})=>r.ctrlKey&&!c)?"trackpad":s.some(({event:r})=>r.deltaMode!==IJt)||s.some(zJt)||s.every(({event:r})=>{let c=r.wheelDelta;return c!==void 0&&Math.abs(c)%40===0})?"mouse":s.some(({deltaX:r})=>r!==0)||s.length>1&&GJt(s)?"trackpad":n?"mouse":"unknown"}function zJt({event:s,deltaX:n,deltaY:r}){if(n!==0||r===0)return!1;let c=Math.abs(r/RJt);if(Number.isInteger(c))return!0;let u=s.wheelDelta;return typeof u=="number"&&u!==0&&u%OJt===0}function GJt(s){for(let n=0;nsmt||Math.abs(r.deltaY)>smt||n>0&&r.timeStamp-s[n-1].timeStamp>BJt)return!1}return!0}var omt=["mousedown","mousemove","mouseup","mouseover","mouseout","mouseenter","mouseleave"],ule=class extends Xy{constructor(n,r,c){super(n,r,{enable:!0,...c}),this.handleEvent=d=>{this.handleOverEvent(d),this.handleOutEvent(d),this.handleEnterEvent(d),this.handleLeaveEvent(d),this.handleMoveEvent(d)},this.pressed=!1;let{enable:u=!1}=this.options;this.enableMoveEvent=u,this.enableLeaveEvent=u,this.enableEnterEvent=u,this.enableOutEvent=u,this.enableOverEvent=u,u&&omt.forEach(d=>this.listen(d,!0))}destroy(){omt.forEach(n=>this.listen(n,!1))}enableEventType(n,r){switch(n){case"pointermove":this.enableMoveEvent!==r&&(this.enableMoveEvent=r,this.listen("mousedown",r),this.listen("mousemove",r),this.listen("mouseup",r));break;case"pointerover":this.enableOverEvent!==r&&(this.enableOverEvent=r,this.listen("mouseover",r));break;case"pointerout":this.enableOutEvent!==r&&(this.enableOutEvent=r,this.listen("mouseout",r));break;case"pointerenter":this.enableEnterEvent!==r&&(this.enableEnterEvent=r,this.listen("mouseenter",r));break;case"pointerleave":this.enableLeaveEvent!==r&&(this.enableLeaveEvent=r,this.listen("mouseleave",r));break;default:}}handleOverEvent(n){this.enableOverEvent&&n.type==="mouseover"&&this._emit("pointerover",n)}handleOutEvent(n){this.enableOutEvent&&n.type==="mouseout"&&this._emit("pointerout",n)}handleEnterEvent(n){this.enableEnterEvent&&n.type==="mouseenter"&&this._emit("pointerenter",n)}handleLeaveEvent(n){this.enableLeaveEvent&&n.type==="mouseleave"&&this._emit("pointerleave",n)}handleMoveEvent(n){if(this.enableMoveEvent)switch(n.type){case"mousedown":n.button>=0&&(this.pressed=!0);break;case"mousemove":n.buttons===0&&(this.pressed=!1),this.pressed||this._emit("pointermove",n);break;case"mouseup":this.pressed=!1;break;default:}}_emit(n,r){this.callback({type:n,center:{x:r.clientX,y:r.clientY},srcEvent:r,pointerType:"mouse",target:r.target})}};var amt=["keydown","keyup"],fle=class extends Xy{constructor(n,r,c){super(n,r,{enable:!0,tabIndex:0,...c}),this.handleEvent=d=>{let b=d.target||d.srcElement;b.tagName==="INPUT"&&b.type==="text"||b.tagName==="TEXTAREA"||(this.enableDownEvent&&d.type==="keydown"&&this.callback({type:"keydown",srcEvent:d,key:d.key,target:d.target}),this.enableUpEvent&&d.type==="keyup"&&this.callback({type:"keyup",srcEvent:d,key:d.key,target:d.target}))};let{enable:u=!1}=this.options;this.enableDownEvent=u,this.enableUpEvent=u,n.tabIndex=this.options.tabIndex,n.style.outline="none",u&&amt.forEach(d=>this.listen(d,!0))}destroy(){amt.forEach(n=>this.listen(n,!1))}enableEventType(n,r){n==="keydown"&&this.enableDownEvent!==r&&(this.enableDownEvent=r,this.listen(n,r)),n==="keyup"&&this.enableUpEvent!==r&&(this.enableUpEvent=r,this.listen(n,r))}};var hle=class extends Xy{constructor(n,r,c){c.enable=c.enable??!1,super(n,r,c),this.handleEvent=u=>{this.options.enable&&this.callback({type:"contextmenu",center:{x:u.clientX,y:u.clientY},srcEvent:u,pointerType:"mouse",target:u.target})},c.enable&&this.listen("contextmenu",!0)}destroy(){this.listen("contextmenu",!1)}enableEventType(n,r){n==="contextmenu"&&this.options.enable!==r&&(this.options.enable=r,this.listen("contextmenu",r))}};var jJt={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},$Jt=0,VJt=1,WJt=2,HJt=1,qJt=2,XJt=4;function cmt(s){let n=jJt[s.srcEvent.type];if(!n)return null;let{buttons:r,button:c}=s.srcEvent,u=!1,d=!1,b=!1;return n===2?(u=!!(r&HJt),d=!!(r&XJt),b=!!(r&qJt)):(u=c===$Jt,d=c===VJt,b=c===WJt),{leftButton:u,middleButton:d,rightButton:b}}function lmt(s,n){let r=s.center;if(!r)return null;let c=n.getBoundingClientRect(),u=c.width/n.offsetWidth||1,d=c.height/n.offsetHeight||1,b={x:(r.x-c.left-n.clientLeft)/u,y:(r.y-c.top-n.clientTop)/d};return{center:r,offsetCenter:b}}var YJt={srcElement:"root",priority:0},dle=class{constructor(n,r){this.handleEvent=c=>{if(this.isEmpty())return;let u=this._normalizeEvent(c),d=c.srcEvent.target;for(;d&&d!==u.rootElement;){if(this._emit(u,d),u.handled)return;d=d.parentNode}this._emit(u,"root")},this.eventManager=n,this.recognizerName=r,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(n,r,c,u=!1,d=!1){let{handlers:b,handlersByElement:w}=this,_={...YJt,...c},x=w.get(_.srcElement);x||(x=[],w.set(_.srcElement,x));let T={type:n,handler:r,srcElement:_.srcElement,priority:_.priority};u&&(T.once=!0),d&&(T.passive=!0),b.push(T),this._active=this._active||!T.passive;let M=x.length-1;for(;M>=0&&!(x[M].priority>=T.priority);)M--;x.splice(M+1,0,T)}remove(n,r){let{handlers:c,handlersByElement:u}=this;for(let d=c.length-1;d>=0;d--){let b=c[d];if(b.type===n&&b.handler===r){c.splice(d,1);let w=u.get(b.srcElement);w.splice(w.indexOf(b),1),w.length===0&&u.delete(b.srcElement)}}this._active=c.some(d=>!d.passive)}_emit(n,r){let c=this.handlersByElement.get(r);if(c){let u=!1,d=()=>{n.handled=!0},b=()=>{n.handled=!0,u=!0},w=[];for(let _=0;_{n.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:r}}};function ZJt(s){if("recognizer"in s)return s;let n,r=Array.isArray(s)?[...s]:[s];if(typeof r[0]=="function"){let c=r.shift(),u=r.shift()||{};n=new c(u)}else n=r.shift();return{recognizer:n,recognizeWith:typeof r[0]=="string"?[r[0]]:r[0],requireFailure:typeof r[1]=="string"?[r[1]]:r[1]}}var H$=class{constructor(n=null,r={}){if(this._onBasicInput=c=>{this.manager.emit(c.srcEvent.type,c)},this._onOtherEvent=c=>{this.manager.emit(c.type,c)},this.options={recognizers:[],events:{},touchAction:"compute",tabIndex:0,cssProps:{},...r},this.events=new Map,this.element=n,this.wheelSession=new lle(n),!!n){this.manager=new W$(n,this.options);for(let c of this.options.recognizers){let{recognizer:u,recognizeWith:d,requireFailure:b}=ZJt(c);this.manager.add(u),d&&u.recognizeWith(d),b&&u.requireFailure(b)}this.manager.on("hammer.input",this._onBasicInput),this.wheelInput=new cle(n,this._onOtherEvent,{enable:!1,wheelSession:this.wheelSession}),this.moveInput=new ule(n,this._onOtherEvent,{enable:!1}),this.keyInput=new fle(n,this._onOtherEvent,{enable:!1,tabIndex:r.tabIndex}),this.contextmenuInput=new hle(n,this._onOtherEvent,{enable:!1}),this.on(this.options.events)}}getElement(){return this.element}destroy(){if(!this.element){this.wheelSession.destroy();return}this.wheelInput.destroy(),this.wheelSession.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy()}on(n,r,c){this._addEventHandler(n,r,c,!1)}once(n,r,c){this._addEventHandler(n,r,c,!0)}watch(n,r,c){this._addEventHandler(n,r,c,!1,!0)}off(n,r){this._removeEventHandler(n,r)}emit(n){this.manager?.emit(n.type,n)}_toggleRecognizer(n,r){let{manager:c}=this;if(!c)return;let u=c.get(n);u&&(u.set({enable:r,wheelSession:this.wheelSession}),c.touchAction.update()),this.wheelInput?.enableEventType(n,r),this.moveInput?.enableEventType(n,r),this.keyInput?.enableEventType(n,r),this.contextmenuInput?.enableEventType(n,r)}_addEventHandler(n,r,c,u,d){if(typeof n!="string"){c=r;for(let[x,T]of Object.entries(n))this._addEventHandler(x,T,c,u,d);return}let{manager:b,events:w}=this;if(!b)return;let _=w.get(n);if(!_){let x=this._getRecognizerName(n)||n;_=new dle(this,x),w.set(n,_),b&&b.on(n,_.handleEvent)}_.add(n,r,c,u,d),_.isEmpty()||this._toggleRecognizer(_.recognizerName,!0)}_removeEventHandler(n,r){if(typeof n!="string"){for(let[d,b]of Object.entries(n))this._removeEventHandler(d,b);return}let{events:c}=this,u=c.get(n);if(u&&(u.remove(n,r),u.isEmpty())){let{recognizerName:d}=u,b=!1;for(let w of c.values())if(w.recognizerName===d&&!w.isEmpty()){b=!0;break}b||this._toggleRecognizer(d,!1)}}_getRecognizerName(n){return this.manager.recognizers.find(r=>r.getEventNames().includes(n))?.options.event}};var yke={DEFAULT:"default",LNGLAT:"lnglat",METER_OFFSETS:"meter-offsets",LNGLAT_OFFSETS:"lnglat-offsets",CARTESIAN:"cartesian"};Object.defineProperty(yke,"IDENTITY",{get:()=>(Bs.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),yke.CARTESIAN)});var $h={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},Ab={common:0,meters:1,pixels:2},iB={click:"onClick",dblclick:"onClick",panstart:"onDragStart",panmove:"onDrag",panend:"onDragEnd"},xke={multipan:[WM,{threshold:10,pointers:2,trackpad:!0}],pinch:[nB,{trackpad:!0},null,["multipan"]],pan:[WM,{threshold:1},["pinch"],["multipan"]],dblclick:[w4,{event:"dblclick",taps:2,enable:!1}],dblclickdrag:[eB,{event:"dblclickdrag",enable:!1},["dblclick"],null],click:[w4,{event:"click"},["dblclickdrag"],["dblclick","dblclickdrag"]]};function KJt(s,n){if(s===n)return!0;if(Array.isArray(s)){let r=s.length;if(!n||n.length!==r)return!1;for(let c=0;c{for(let u in c)if(!KJt(c[u],n[u])){r=s(c),n=c;break}return r}}var umt=[0,0,0,0],JJt=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],fmt=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],QJt=[0,0,0],hmt=[0,0,0],eQt={default:-1,cartesian:0,lnglat:1,"meter-offsets":2,"lnglat-offsets":3};function v4(s){let n=eQt[s];if(n===void 0)throw new Error(`Invalid coordinateSystem: ${s}`);return n}var tQt=Yy(iQt);function Eke(s,n,r=hmt){r.length<3&&(r=[r[0],r[1],0]);let c=r,u,d=!0;switch(n==="lnglat-offsets"||n==="meter-offsets"?u=r:u=s.isGeospatial?[Math.fround(s.longitude),Math.fround(s.latitude),0]:null,s.projectionMode){case $h.WEB_MERCATOR:(n==="lnglat"||n==="cartesian")&&(u=[0,0,0],d=!1);break;case $h.WEB_MERCATOR_AUTO_OFFSET:n==="lnglat"?c=u:n==="cartesian"&&(c=[Math.fround(s.center[0]),Math.fround(s.center[1]),0],u=s.unprojectPosition(c),c[0]-=r[0],c[1]-=r[1],c[2]-=r[2]);break;case $h.IDENTITY:c=s.position.map(Math.fround),c[2]=c[2]||0;break;case $h.GLOBE:d=!1,u=null;break;default:d=!1}return{geospatialOrigin:u,shaderCoordinateOrigin:c,offsetMode:d}}function nQt(s,n,r){let{viewMatrixUncentered:c,projectionMatrix:u}=s,{viewMatrix:d,viewProjectionMatrix:b}=s,w=umt,_=umt,x=s.cameraPosition,{geospatialOrigin:T,shaderCoordinateOrigin:M,offsetMode:L}=Eke(s,n,r);return L&&(_=s.projectPosition(T||M),x=[x[0]-_[0],x[1]-_[1],x[2]-_[2]],_[3]=1,w=U1.transformMat4([],_,b),d=c||d,b=hh.multiply([],u,d),b=hh.multiply([],b,JJt)),{viewMatrix:d,viewProjectionMatrix:b,projectionCenter:w,originCommon:_,cameraPosCommon:x,shaderCoordinateOrigin:M,geospatialOrigin:T}}function dmt({viewport:s,devicePixelRatio:n=1,modelMatrix:r=null,coordinateSystem:c="default",coordinateOrigin:u=hmt,autoWrapLongitude:d=!1}){c==="default"&&(c=s.isGeospatial?"lnglat":"cartesian");let b=tQt({viewport:s,devicePixelRatio:n,coordinateSystem:c,coordinateOrigin:u});return b.wrapLongitude=d,b.modelMatrix=r||fmt,b}function iQt({viewport:s,devicePixelRatio:n,coordinateSystem:r,coordinateOrigin:c}){let{projectionCenter:u,viewProjectionMatrix:d,originCommon:b,cameraPosCommon:w,shaderCoordinateOrigin:_,geospatialOrigin:x}=nQt(s,r,c),T=s.getDistanceScales(),M=[s.width*n,s.height*n],L=U1.transformMat4([],[0,0,-s.focalDistance,1],s.projectionMatrix)[3]||1,I={coordinateSystem:v4(r),projectionMode:s.projectionMode,coordinateOrigin:_,commonOrigin:b.slice(0,3),center:u,pseudoMeters:!!s._pseudoMeters,viewportSize:M,devicePixelRatio:n,focalDistance:L,commonUnitsPerMeter:T.unitsPerMeter,commonUnitsPerWorldUnit:T.unitsPerMeter,commonUnitsPerWorldUnit2:QJt,scale:s.scale,wrapLongitude:!1,viewProjectionMatrix:d,modelMatrix:fmt,cameraPosition:w};if(x){let D=s.getDistanceScales(x);switch(r){case"meter-offsets":I.commonUnitsPerWorldUnit=D.unitsPerMeter,I.commonUnitsPerWorldUnit2=D.unitsPerMeter2;break;case"lnglat":case"lnglat-offsets":s._pseudoMeters||(I.commonUnitsPerMeter=D.unitsPerMeter),I.commonUnitsPerWorldUnit=D.unitsPerDegree,I.commonUnitsPerWorldUnit2=D.unitsPerDegree2;break;case"cartesian":I.commonUnitsPerWorldUnit=[1,1,D.unitsPerMeter[2]],I.commonUnitsPerWorldUnit2=[0,0,D.unitsPerMeter2[2]];break;default:break}}if(s.projectionMode===$h.GLOBE&&r==="meter-offsets"){let O=c[0]*Math.PI/180,z=c[1]*Math.PI/180,Z=Math.cos(z),H=((c[2]||0)/6370972+1)*256;I.commonOrigin=[Math.sin(O)*Z*H,-Math.cos(O)*Z*H,Math.sin(z)*H]}return I}var rQt=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],sQt=rQt.map(s=>`const COORDINATE_SYSTEM_${s.toUpperCase().replaceAll("-","_")}: i32 = ${v4(s)};`).join(""),oQt=Object.keys($h).map(s=>`const PROJECTION_MODE_${s}: i32 = ${$h[s]};`).join(""),aQt=Object.keys(Ab).map(s=>`const UNIT_${s.toUpperCase()}: i32 = ${Ab[s]};`).join(""),cQt=`${sQt} +${oQt} +${aQt} const TILE_SIZE: f32 = 512.0; const PI: f32 = 3.1415926536; @@ -3470,7 +3470,7 @@ struct Geometry { }; var geometry: Geometry; -`,pmt=`${sQt} +`,pmt=`${cQt} // ----------------------------------------------------------------------------- // Functions @@ -3706,9 +3706,9 @@ fn project_pixel_size_float(pixels: f32) -> f32 { fn project_pixel_size_vec2(pixels: vec2) -> vec2 { return pixels / project.scale; } -`;var oQt=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],aQt=oQt.map(s=>`const int COORDINATE_SYSTEM_${s.toUpperCase().replaceAll("-","_")} = ${v4(s)};`).join(""),cQt=Object.keys($h).map(s=>`const int PROJECTION_MODE_${s} = ${$h[s]};`).join(""),lQt=Object.keys(Pb).map(s=>`const int UNIT_${s.toUpperCase()} = ${Pb[s]};`).join(""),gmt=`${aQt} -${cQt} -${lQt} +`;var lQt=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],uQt=lQt.map(s=>`const int COORDINATE_SYSTEM_${s.toUpperCase().replaceAll("-","_")} = ${v4(s)};`).join(""),fQt=Object.keys($h).map(s=>`const int PROJECTION_MODE_${s} = ${$h[s]};`).join(""),hQt=Object.keys(Ab).map(s=>`const int UNIT_${s.toUpperCase()} = ${Ab[s]};`).join(""),gmt=`${uQt} +${fQt} +${hQt} layout(std140) uniform projectUniforms { bool wrapLongitude; int coordinateSystem; @@ -3906,7 +3906,7 @@ return pixels / project.scale; vec2 project_pixel_size(vec2 pixels) { return pixels / project.scale; } -`;var uQt={};function fQt(s=uQt){return"viewport"in s?dmt(s):{}}var fv={name:"project",dependencies:[d4,ile],source:pmt,vs:gmt,getUniforms:fQt,uniformTypes:{wrapLongitude:"f32",coordinateSystem:"i32",commonUnitsPerMeter:"vec3",projectionMode:"i32",scale:"f32",commonUnitsPerWorldUnit:"vec3",commonUnitsPerWorldUnit2:"vec3",center:"vec4",modelMatrix:"mat4x4",viewProjectionMatrix:"mat4x4",viewportSize:"vec2",devicePixelRatio:"f32",focalDistance:"f32",cameraPosition:"vec3",coordinateOrigin:"vec3",commonOrigin:"vec3",pseudoMeters:"f32"}};var hQt=`// Define a structure to hold both the clip-space position and the common position. +`;var dQt={};function pQt(s=dQt){return"viewport"in s?dmt(s):{}}var fv={name:"project",dependencies:[d4,ile],source:pmt,vs:gmt,getUniforms:pQt,uniformTypes:{wrapLongitude:"f32",coordinateSystem:"i32",commonUnitsPerMeter:"vec3",projectionMode:"i32",scale:"f32",commonUnitsPerWorldUnit:"vec3",commonUnitsPerWorldUnit2:"vec3",center:"vec4",modelMatrix:"mat4x4",viewProjectionMatrix:"mat4x4",viewportSize:"vec2",devicePixelRatio:"f32",focalDistance:"f32",cameraPosition:"vec3",coordinateOrigin:"vec3",commonOrigin:"vec3",pseudoMeters:"f32"}};var gQt=`// Define a structure to hold both the clip-space position and the common position. struct ProjectResult { clipPosition: vec4, commonPosition: vec4, @@ -3949,7 +3949,7 @@ fn project_position_to_clipspace( ) -> vec4 { return project_position_to_clipspace_and_commonspace(position, position64Low, offset).clipPosition; } -`,dQt=`vec4 project_position_to_clipspace( +`,mQt=`vec4 project_position_to_clipspace( vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition ) { vec3 projectedPosition = project_position(position, position64Low); @@ -3969,7 +3969,7 @@ vec4 project_position_to_clipspace( vec4 commonPosition; return project_position_to_clipspace(position, position64Low, offset, commonPosition); } -`,Zy={name:"project32",dependencies:[fv],source:hQt,vs:dQt};Of();Of();function Ske(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function HM(s,n){let r=U1.transformMat4([],n,s);return U1.scale(r,r,1/r[3]),r}function q$(s,n,r){return sr?r:s}function pQt(s){return Math.log(s)*Math.LOG2E}var X$=Math.log2||pQt;Of();function hv(s,n){if(!s)throw new Error(n||"@math.gl/web-mercator: assertion failed.")}var dv=Math.PI,mmt=dv/4,Lb=dv/180,Mke=180/dv,rB=512,ple=4003e4,sB=85.051129,bmt=1.5;function Tke(s){return X$(s)}function cg(s){let[n,r]=s;hv(Number.isFinite(n)),hv(Number.isFinite(r)&&r>=-90&&r<=90,"invalid latitude");let c=n*Lb,u=r*Lb,d=rB*(c+dv)/(2*dv),b=rB*(dv+Math.log(Math.tan(mmt+u*.5)))/(2*dv);return[d,b]}function z1(s){let[n,r]=s,c=n/rB*(2*dv)-dv,u=2*(Math.atan(Math.exp(r/rB*(2*dv)-dv))-mmt);return[c*Mke,u*Mke]}function Cke(s){let{latitude:n}=s;hv(Number.isFinite(n));let r=Math.cos(n*Lb);return Tke(ple*r)-9}function Y$(s){let n=Math.cos(s*Lb);return rB/ple/n}function oB(s){let{latitude:n,longitude:r,highPrecision:c=!1}=s;hv(Number.isFinite(n)&&Number.isFinite(r));let u=rB,d=Math.cos(n*Lb),b=u/360,w=b/d,_=u/ple/d,x={unitsPerMeter:[_,_,_],metersPerUnit:[1/_,1/_,1/_],unitsPerDegree:[b,w,_],degreesPerUnit:[1/b,1/w,1/_]};if(c){let T=Lb*Math.tan(n*Lb)/d,M=b*T/2,L=u/ple*T,I=L/w*_;x.unitsPerDegree2=[0,M,L],x.unitsPerMeter2=[I,0,I]}return x}function Z$(s,n){let[r,c,u]=s,[d,b,w]=n,{unitsPerMeter:_,unitsPerMeter2:x}=oB({longitude:r,latitude:c,highPrecision:!0}),T=cg(s);T[0]+=d*(_[0]+x[0]*b),T[1]+=b*(_[1]+x[1]*b);let M=z1(T),L=(u||0)+(w||0);return Number.isFinite(u)||Number.isFinite(w)?[M[0],M[1],L]:M}function gle(s){let{height:n,pitch:r,bearing:c,altitude:u,scale:d,center:b}=s,w=Ske();fh.translate(w,w,[0,0,-u]),fh.rotateX(w,w,-r*Lb),fh.rotateZ(w,w,c*Lb);let _=d/n;return fh.scale(w,w,[_,_,_]),b&&fh.translate(w,w,wm.negate([],b)),w}function Ake(s){let{width:n,height:r,altitude:c,pitch:u=0,offset:d,center:b,scale:w,nearZMultiplier:_=1,farZMultiplier:x=1}=s,{fovy:T=_4(bmt)}=s;c!==void 0&&(T=_4(c));let M=T*Lb,L=u*Lb,I=K$(T),D=I;b&&(D+=b[2]*w/Math.cos(L)/r);let F=M*(.5+(d?d[1]:0)/r),O=Math.sin(F)*D/Math.sin(q$(Math.PI/2-L-F,.01,Math.PI-.01)),z=Math.sin(L)*O+D,Z=D*10,H=Math.min(z*x,Z);return{fov:M,aspect:n/r,focalDistance:I,near:_,far:H}}function _4(s){return 2*Math.atan(.5/s)*Mke}function K$(s){return .5/Math.tan(.5*s*Lb)}function qM(s,n){let[r,c,u=0]=s;return hv(Number.isFinite(r)&&Number.isFinite(c)&&Number.isFinite(u)),HM(n,[r,c,u,1])}function Ky(s,n,r=0){let[c,u,d]=s;if(hv(Number.isFinite(c)&&Number.isFinite(u),"invalid pixel coordinate"),Number.isFinite(d))return HM(n,[c,u,d,1]);let b=HM(n,[c,u,0,1]),w=HM(n,[c,u,1,1]),_=b[2],x=w[2],T=_===x?0:((r||0)-_)/(x-_);return ag.lerp([],b,w,T)}function mle(s){let{width:n,height:r,bounds:c,minExtent:u=0,maxZoom:d=24,offset:b=[0,0]}=s,[[w,_],[x,T]]=c,M=gQt(s.padding),L=cg([w,q$(T,-sB,sB)]),I=cg([x,q$(_,-sB,sB)]),D=[Math.max(Math.abs(I[0]-L[0]),u),Math.max(Math.abs(I[1]-L[1]),u)],F=[n-M.left-M.right-Math.abs(b[0])*2,r-M.top-M.bottom-Math.abs(b[1])*2];hv(F[0]>0&&F[1]>0);let O=F[0]/D[0],z=F[1]/D[1],Z=(M.right-M.left)/2/O,H=(M.top-M.bottom)/2/z,te=[(I[0]+L[0])/2+Z,(I[1]+L[1])/2+H],oe=z1(te),ne=Math.min(d,X$(Math.abs(Math.min(O,z))));return hv(Number.isFinite(ne)),{longitude:oe[0],latitude:oe[1],zoom:ne}}function gQt(s=0){return typeof s=="number"?{top:s,bottom:s,left:s,right:s}:(hv(Number.isFinite(s.top)&&Number.isFinite(s.bottom)&&Number.isFinite(s.left)&&Number.isFinite(s.right)),s)}Of();var wmt=Math.PI/180;function ble(s,n=0){let{width:r,height:c,unproject:u}=s,d={targetZ:n},b=u([0,c],d),w=u([r,c],d),_,x,T=s.fovy?.5*s.fovy*wmt:Math.atan(.5/s.altitude),M=(90-s.pitch)*wmt;return T>M-.01?(_=vmt(s,0,n),x=vmt(s,r,n)):(_=u([0,0],d),x=u([r,0],d)),[b,w,x,_]}function vmt(s,n,r){let{pixelUnprojectionMatrix:c}=s,u=HM(c,[n,0,1,1]),d=HM(c,[n,s.height,1,1]),w=(r*s.distanceScales.unitsPerMeter[2]-u[2])/(d[2]-u[2]),_=ag.lerp([],u,d,w),x=z1(_);return x.push(r),x}var ymt=` +`,Zy={name:"project32",dependencies:[fv],source:gQt,vs:mQt};Nf();Nf();function Ske(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function HM(s,n){let r=U1.transformMat4([],n,s);return U1.scale(r,r,1/r[3]),r}function q$(s,n,r){return sr?r:s}function bQt(s){return Math.log(s)*Math.LOG2E}var X$=Math.log2||bQt;Nf();function hv(s,n){if(!s)throw new Error(n||"@math.gl/web-mercator: assertion failed.")}var dv=Math.PI,mmt=dv/4,Pb=dv/180,Mke=180/dv,rB=512,ple=4003e4,sB=85.051129,bmt=1.5;function Tke(s){return X$(s)}function cg(s){let[n,r]=s;hv(Number.isFinite(n)),hv(Number.isFinite(r)&&r>=-90&&r<=90,"invalid latitude");let c=n*Pb,u=r*Pb,d=rB*(c+dv)/(2*dv),b=rB*(dv+Math.log(Math.tan(mmt+u*.5)))/(2*dv);return[d,b]}function z1(s){let[n,r]=s,c=n/rB*(2*dv)-dv,u=2*(Math.atan(Math.exp(r/rB*(2*dv)-dv))-mmt);return[c*Mke,u*Mke]}function Cke(s){let{latitude:n}=s;hv(Number.isFinite(n));let r=Math.cos(n*Pb);return Tke(ple*r)-9}function Y$(s){let n=Math.cos(s*Pb);return rB/ple/n}function oB(s){let{latitude:n,longitude:r,highPrecision:c=!1}=s;hv(Number.isFinite(n)&&Number.isFinite(r));let u=rB,d=Math.cos(n*Pb),b=u/360,w=b/d,_=u/ple/d,x={unitsPerMeter:[_,_,_],metersPerUnit:[1/_,1/_,1/_],unitsPerDegree:[b,w,_],degreesPerUnit:[1/b,1/w,1/_]};if(c){let T=Pb*Math.tan(n*Pb)/d,M=b*T/2,L=u/ple*T,I=L/w*_;x.unitsPerDegree2=[0,M,L],x.unitsPerMeter2=[I,0,I]}return x}function Z$(s,n){let[r,c,u]=s,[d,b,w]=n,{unitsPerMeter:_,unitsPerMeter2:x}=oB({longitude:r,latitude:c,highPrecision:!0}),T=cg(s);T[0]+=d*(_[0]+x[0]*b),T[1]+=b*(_[1]+x[1]*b);let M=z1(T),L=(u||0)+(w||0);return Number.isFinite(u)||Number.isFinite(w)?[M[0],M[1],L]:M}function gle(s){let{height:n,pitch:r,bearing:c,altitude:u,scale:d,center:b}=s,w=Ske();hh.translate(w,w,[0,0,-u]),hh.rotateX(w,w,-r*Pb),hh.rotateZ(w,w,c*Pb);let _=d/n;return hh.scale(w,w,[_,_,_]),b&&hh.translate(w,w,wm.negate([],b)),w}function Ake(s){let{width:n,height:r,altitude:c,pitch:u=0,offset:d,center:b,scale:w,nearZMultiplier:_=1,farZMultiplier:x=1}=s,{fovy:T=_4(bmt)}=s;c!==void 0&&(T=_4(c));let M=T*Pb,L=u*Pb,I=K$(T),D=I;b&&(D+=b[2]*w/Math.cos(L)/r);let F=M*(.5+(d?d[1]:0)/r),O=Math.sin(F)*D/Math.sin(q$(Math.PI/2-L-F,.01,Math.PI-.01)),z=Math.sin(L)*O+D,Z=D*10,H=Math.min(z*x,Z);return{fov:M,aspect:n/r,focalDistance:I,near:_,far:H}}function _4(s){return 2*Math.atan(.5/s)*Mke}function K$(s){return .5/Math.tan(.5*s*Pb)}function qM(s,n){let[r,c,u=0]=s;return hv(Number.isFinite(r)&&Number.isFinite(c)&&Number.isFinite(u)),HM(n,[r,c,u,1])}function Ky(s,n,r=0){let[c,u,d]=s;if(hv(Number.isFinite(c)&&Number.isFinite(u),"invalid pixel coordinate"),Number.isFinite(d))return HM(n,[c,u,d,1]);let b=HM(n,[c,u,0,1]),w=HM(n,[c,u,1,1]),_=b[2],x=w[2],T=_===x?0:((r||0)-_)/(x-_);return ag.lerp([],b,w,T)}function mle(s){let{width:n,height:r,bounds:c,minExtent:u=0,maxZoom:d=24,offset:b=[0,0]}=s,[[w,_],[x,T]]=c,M=wQt(s.padding),L=cg([w,q$(T,-sB,sB)]),I=cg([x,q$(_,-sB,sB)]),D=[Math.max(Math.abs(I[0]-L[0]),u),Math.max(Math.abs(I[1]-L[1]),u)],F=[n-M.left-M.right-Math.abs(b[0])*2,r-M.top-M.bottom-Math.abs(b[1])*2];hv(F[0]>0&&F[1]>0);let O=F[0]/D[0],z=F[1]/D[1],Z=(M.right-M.left)/2/O,H=(M.top-M.bottom)/2/z,te=[(I[0]+L[0])/2+Z,(I[1]+L[1])/2+H],oe=z1(te),ne=Math.min(d,X$(Math.abs(Math.min(O,z))));return hv(Number.isFinite(ne)),{longitude:oe[0],latitude:oe[1],zoom:ne}}function wQt(s=0){return typeof s=="number"?{top:s,bottom:s,left:s,right:s}:(hv(Number.isFinite(s.top)&&Number.isFinite(s.bottom)&&Number.isFinite(s.left)&&Number.isFinite(s.right)),s)}Nf();var wmt=Math.PI/180;function ble(s,n=0){let{width:r,height:c,unproject:u}=s,d={targetZ:n},b=u([0,c],d),w=u([r,c],d),_,x,T=s.fovy?.5*s.fovy*wmt:Math.atan(.5/s.altitude),M=(90-s.pitch)*wmt;return T>M-.01?(_=vmt(s,0,n),x=vmt(s,r,n)):(_=u([0,0],d),x=u([r,0],d)),[b,w,x,_]}function vmt(s,n,r){let{pixelUnprojectionMatrix:c}=s,u=HM(c,[n,0,1,1]),d=HM(c,[n,s.height,1,1]),w=(r*s.distanceScales.unitsPerMeter[2]-u[2])/(d[2]-u[2]),_=ag.lerp([],u,d,w),x=z1(_);return x.push(r),x}var ymt=` layout(std140) uniform shadowUniforms { bool drawShadowMap; bool useShadowMap; @@ -3981,7 +3981,7 @@ layout(std140) uniform shadowUniforms { vec4 projectCenter0; vec4 projectCenter1; } shadow; -`,wQt=` +`,yQt=` const int max_lights = 2; out vec3 shadow_vPosition[max_lights]; @@ -4007,10 +4007,10 @@ vec4 shadow_setVertexPosition(vec4 position_commonspace) { } return gl_Position; } -`,vQt=` +`,xQt=` ${ymt} -${wQt} -`,_Qt=` +${yQt} +`,EQt=` const int max_lights = 2; uniform sampler2D shadow_uShadowMap0; uniform sampler2D shadow_uShadowMap1; @@ -4050,20 +4050,20 @@ vec4 shadow_filterShadowColor(vec4 color) { } return color; } -`,yQt=` +`,SQt=` ${ymt} -${_Qt} -`,xQt=Yy(CQt),EQt=Yy(AQt),SQt=[0,0,0,1],MQt=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];function TQt(s,n){let[r,c,u]=s,d=Ky([r,c,u],n);return Number.isFinite(u)?d:[d[0],d[1],0]}function CQt({viewport:s,center:n}){return new Bf(s.viewProjectionMatrix).invert().transform(n)}function AQt({viewport:s,shadowMatrices:n}){let r=[],c=s.pixelUnprojectionMatrix,u=s.isGeospatial?void 0:1,d=[[0,0,u],[s.width,0,u],[0,s.height,u],[s.width,s.height,u],[0,0,-1],[s.width,0,-1],[0,s.height,-1],[s.width,s.height,-1]].map(b=>TQt(b,c));for(let b of n){let w=b.clone().translate(new lp(s.center).negate()),_=d.map(T=>w.transform(T)),x=new Bf().ortho({left:Math.min(..._.map(T=>T[0])),right:Math.max(..._.map(T=>T[0])),bottom:Math.min(..._.map(T=>T[1])),top:Math.max(..._.map(T=>T[1])),near:Math.min(..._.map(T=>-T[2])),far:Math.max(..._.map(T=>-T[2]))});r.push(x.multiplyRight(b))}return r}function PQt(s){let{shadowEnabled:n=!0,project:r}=s;if(!n||!r||!s.shadowMatrices||!s.shadowMatrices.length)return{drawShadowMap:!1,useShadowMap:!1,shadow_uShadowMap0:s.dummyShadowMap,shadow_uShadowMap1:s.dummyShadowMap};let c=fv.getUniforms(r),u=xQt({viewport:r.viewport,center:c.center}),d=[],b=EQt({shadowMatrices:s.shadowMatrices,viewport:r.viewport}).slice();for(let _=0;_0:!1,color:s.shadowColor||SQt,lightId:s.shadowLightId||0,lightCount:s.shadowMatrices.length,shadow_uShadowMap0:s.dummyShadowMap,shadow_uShadowMap1:s.dummyShadowMap};for(let _=0;_PQt(b,c));for(let b of n){let w=b.clone().translate(new lp(s.center).negate()),_=d.map(T=>w.transform(T)),x=new Of().ortho({left:Math.min(..._.map(T=>T[0])),right:Math.max(..._.map(T=>T[0])),bottom:Math.min(..._.map(T=>T[1])),top:Math.max(..._.map(T=>T[1])),near:Math.min(..._.map(T=>-T[2])),far:Math.max(..._.map(T=>-T[2]))});r.push(x.multiplyRight(b))}return r}function RQt(s){let{shadowEnabled:n=!0,project:r}=s;if(!n||!r||!s.shadowMatrices||!s.shadowMatrices.length)return{drawShadowMap:!1,useShadowMap:!1,shadow_uShadowMap0:s.dummyShadowMap,shadow_uShadowMap1:s.dummyShadowMap};let c=fv.getUniforms(r),u=MQt({viewport:r.viewport,center:c.center}),d=[],b=TQt({shadowMatrices:s.shadowMatrices,viewport:r.viewport}).slice();for(let _=0;_0:!1,color:s.shadowColor||CQt,lightId:s.shadowLightId||0,lightCount:s.shadowMatrices.length,shadow_uShadowMap0:s.dummyShadowMap,shadow_uShadowMap1:s.dummyShadowMap};for(let _=0;_",lightId:"i32",lightCount:"f32",viewProjectionMatrix0:"mat4x4",viewProjectionMatrix1:"mat4x4",projectCenter0:"vec4",projectCenter1:"vec4"}};vm();var vle=10,J$=16777215;function Emt(s,n){s.length===vle?Bs.warn(`pickMultipleObjects can only exclude ${vle} previously picked objects for layers without picking buffers`)():s.push(n)}var LQt=` float disabledPickingIndexCount; + `},getUniforms:RQt,uniformTypes:{drawShadowMap:"f32",useShadowMap:"f32",color:"vec4",lightId:"i32",lightCount:"f32",viewProjectionMatrix0:"mat4x4",viewProjectionMatrix1:"mat4x4",projectCenter0:"vec4",projectCenter1:"vec4"}};vm();var vle=10,J$=16777215;function Emt(s,n){s.length===vle?Bs.warn(`pickMultipleObjects can only exclude ${vle} previously picked objects for layers without picking buffers`)():s.push(n)}var IQt=` float disabledPickingIndexCount; vec4 disabledPickingIndices0; vec4 disabledPickingIndices1; vec4 disabledPickingIndices2; `;function xmt(s){return s.replace(` vec4 highlightColor; } picking;`,` vec4 highlightColor; -${LQt}} picking;`)}function Pke(s,n){return[s[n]||0,s[n+1]||0,s[n+2]||0,s[n+3]||0]}var kQt=`vec3 picking_getPickingColorFromIndex(float objectIndex) { +${IQt}} picking;`)}function Pke(s,n){return[s[n]||0,s[n+1]||0,s[n+2]||0,s[n+3]||0]}var DQt=`vec3 picking_getPickingColorFromIndex(float objectIndex) { if (objectIndex < 0.0 || objectIndex >= ${J$}.0) { return vec3(0.0); } @@ -4100,7 +4100,7 @@ vec3 picking_getPickingColorFromInstanceID() { void picking_setPickingColorFromInstanceID() { picking_setPickingColor(picking_getPickingColorFromInstanceID()); } -`,RQt=`struct pickingUniforms { +`,BQt=`struct pickingUniforms { isActive: f32, isAttribute: f32, isHighlightActive: f32, @@ -4159,7 +4159,7 @@ fn picking_getPickingColorFromIndex(objectIndex: u32) -> vec3 { ) / 255.0; } `,Jy={...VM,vs:`${xmt(VM.vs)} -${kQt}`,fs:xmt(VM.fs),source:RQt,uniformTypes:{...VM.uniformTypes,disabledPickingIndexCount:"f32",disabledPickingIndices0:"vec4",disabledPickingIndices1:"vec4",disabledPickingIndices2:"vec4"},defaultUniforms:{...VM.defaultUniforms,useByteColors:!0,disabledPickingIndexCount:0,disabledPickingIndices0:[0,0,0,0],disabledPickingIndices1:[0,0,0,0],disabledPickingIndices2:[0,0,0,0]},getUniforms(s,n){let r=VM.getUniforms(s,n),c=s.disabledPickingIndices||[];return r.disabledPickingIndexCount=c.length,r.disabledPickingIndices0=Pke(c,0),r.disabledPickingIndices1=Pke(c,4),r.disabledPickingIndices2=Pke(c,8),r},inject:{"vs:DECKGL_FILTER_GL_POSITION":` +${DQt}`,fs:xmt(VM.fs),source:BQt,uniformTypes:{...VM.uniformTypes,disabledPickingIndexCount:"f32",disabledPickingIndices0:"vec4",disabledPickingIndices1:"vec4",disabledPickingIndices2:"vec4"},defaultUniforms:{...VM.defaultUniforms,useByteColors:!0,disabledPickingIndexCount:0,disabledPickingIndices0:[0,0,0,0],disabledPickingIndices1:[0,0,0,0],disabledPickingIndices2:[0,0,0,0]},getUniforms(s,n){let r=VM.getUniforms(s,n),c=s.disabledPickingIndices||[];return r.disabledPickingIndexCount=c.length,r.disabledPickingIndices0=Pke(c,0),r.disabledPickingIndices1=Pke(c,4),r.disabledPickingIndices2=Pke(c,8),r},inject:{"vs:DECKGL_FILTER_GL_POSITION":` // for picking depth values picking_setPickingAttribute(position.z / position.w); `,"vs:DECKGL_FILTER_COLOR":` @@ -4170,10 +4170,10 @@ ${kQt}`,fs:xmt(VM.fs),source:RQt,uniformTypes:{...VM.uniformTypes,disabledPickin // use picking color if rendering to picking FBO. color = picking_filterPickingColor(color); - `}}};var DQt=[ile],BQt=["vs:DECKGL_FILTER_SIZE(inout vec3 size, VertexGeometry geometry)","vs:DECKGL_FILTER_GL_POSITION(inout vec4 position, VertexGeometry geometry)","vs:DECKGL_FILTER_COLOR(inout vec4 color, VertexGeometry geometry)","fs:DECKGL_FILTER_COLOR(inout vec4 color, FragmentGeometry geometry)"],OQt=[];function Smt(s){let n=Cb.getDefaultShaderAssembler(s);for(let c of DQt)n.addDefaultModule(c);n._hookFunctions.length=0;let r=s==="glsl"?BQt:OQt;for(let c of r)n.addShaderHook(c);return n}var NQt=[255,255,255],FQt=1,UQt=0,_le=class{constructor(n={}){this.type="ambient";let{color:r=NQt}=n,{intensity:c=FQt}=n;this.id=n.id||`ambient-${UQt++}`,this.color=r,this.intensity=c}};Of();var zQt=[255,255,255],GQt=1,jQt=[0,0,-1],$Qt=0,Q$=class{constructor(n={}){this.type="directional";let{color:r=zQt}=n,{intensity:c=GQt}=n,{direction:u=jQt}=n,{_shadow:d=!1}=n;this.id=n.id||`directional-${$Qt++}`,this.color=r,this.intensity=c,this.type="directional",this.direction=new lp(u).normalize().toArray(),this.shadow=d}getProjectedLight(n){return this}};Of();var eV=class{constructor(n,r={id:"pass"}){let{id:c}=r;this.id=c,this.device=n,this.props={...r}}setProps(n){Object.assign(this.props,n)}render(n){}cleanup(){}};var VQt={depthWriteEnabled:!0,depthCompare:"less-equal",blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one-minus-src-alpha",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha"},k3=class extends eV{constructor(){super(...arguments),this._lastRenderIndex=-1}render(n){this._render(n)}_render(n){let{canvasContext:r=this.device.canvasContext}=n,c=n.target??r.getCurrentFramebuffer(),[u,d]=r.getDrawingBufferSize(),b=n.clearCanvas??!0,w=n.clearColor??(b?[0,0,0,0]:!1),_=b?1:!1,x=b?0:!1,T=n.colorMask??15,M={viewport:[0,0,u,d]};n.colorMask&&(M.colorMask=T),n.scissorRect&&(M.scissorRect=n.scissorRect);let{shaderModuleProps:L,viewports:I,views:D,onViewportActive:F,clearStack:O=!0}=n,z=n.pass||"unknown",Z=this.device.type==="webgpu";O&&(this._lastRenderIndex=-1);let H=[];if(!I.length)return this.device.beginRenderPass({framebuffer:c,parameters:M,clearColor:w,clearDepth:_,clearStencil:x}).end(),this.device.submit(),H;try{for(let te of I){F?.(te);let oe=this._getDrawLayerParams(te,n),ne=D&&D[te.id],ue=te.subViewports||[te],Te=Z?ue.map(Q=>[Q]):[ue];for(let Q of Te){let ge=this.device.beginRenderPass({framebuffer:c,parameters:M,clearColor:w,clearDepth:_,clearStencil:x});try{for(let Qe of Q){let st=this._drawLayersInViewport(ge,{target:c,canvasContext:r,shaderModuleProps:L,viewport:Qe,view:ne,pass:z,layers:n.layers,isPicking:n.isPicking},oe);H.push(st)}}finally{ge.end(),Z&&this.device.submit()}w=!1,_=!1,x=!1}}return H}finally{Z||this.device.submit()}}_getDrawLayerParams(n,{layers:r,pass:c,isPicking:u=!1,layerFilter:d,cullRect:b,views:w,effects:_,canvasContext:x=this.device.canvasContext,shaderModuleProps:T},M=!1){let L=[],I=Tmt(this._lastRenderIndex+1),D={layer:r[0],viewport:n,isPicking:u,renderPass:c,cullRect:b},F={};for(let O=0;Ooe/255):D===!1&&(z=!1),F!==void 0&&(Z=F),O!==void 0&&(H=O),this.device.beginRenderPass({framebuffer:d,parameters:{viewport:M,scissorRect:M},clearColor:z,clearDepth:Z,clearStencil:H}).end()}}let L={totalCount:r.length,visibleCount:0,compositeCount:0,pickableCount:0};n.setParameters({viewport:M});for(let I=0;I{let b=u.props._offset,w=u.id,_=u.parent&&u.parent.id,x;if(_&&!(_ in n)&&c(u.parent,!1),_ in r){let T=r[_]=r[_]||Tmt(n[_],n);x=T(u,d),r[w]=T}else Number.isFinite(b)?(x=b+(n[_]||0),r[w]=null):x=s;return d&&x>=s&&(s=x+1),n[w]=x,x};return c}function WQt(s,{canvasContext:n=s.canvasContext,shaderModuleProps:r,target:c,viewport:u}){let d=r?.project?.devicePixelRatio??n.cssToDeviceRatio(),[,b]=n.getDrawingBufferSize(),w=c?c.height:b,_=u;return[_.x*d,w-(_.y+_.height)*d,_.width*d,_.height*d]}function Mmt(s,...n){for(let r of n)if(r)for(let c in r)s[c]?Object.assign(s[c],r[c]):s[c]=r[c];return s}var tV=class extends k3{constructor(n,r){super(n,r);let c=n.createTexture({format:"rgba8unorm",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),u=n.createTexture({format:"depth16unorm",width:1,height:1});this.fbo=n.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[c],depthStencilAttachment:u})}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null)}getShadowMap(){return this.fbo.colorAttachments[0].texture}render(n){let r=this.fbo,c=this.device.canvasContext.cssToDeviceRatio(),u=n.viewports[0],d=u.width*c,b=u.height*c,w=[1,1,1,1];(d!==r.width||b!==r.height)&&r.resize({width:d,height:b}),super.render({...n,clearColor:w,target:r,pass:"shadow"})}getLayerParameters(n,r,c){return{...n.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal"}}shouldDrawLayer(n){return n.props.shadowEnabled!==!1}getShaderModuleProps(n,r,c){return{shadow:{project:c.project,drawToShadowMap:!0}}}};var HQt={color:[255,255,255],intensity:1},Cmt=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],qQt=[0,0,0,200/255],aB=class{constructor(n={}){this.id="lighting-effect",this.shadowColor=qQt,this.shadow=!1,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.dummyShadowMap=null,this.setProps(n)}setup(n){this.context=n;let{device:r,deck:c}=n;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(r),c._addDefaultShaderModule(wle),this.dummyShadowMap=r.createTexture({width:1,height:1}))}setProps(n){this.ambientLight=void 0,this.directionalLights=[],this.pointLights=[];for(let r in n){let c=n[r];switch(c.type){case"ambient":this.ambientLight=c;break;case"directional":this.directionalLights.push(c);break;case"point":this.pointLights.push(c);break;default:}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(r=>r.shadow),this.context&&this.setup(this.context),this.props=n}preRender({layers:n,layerFilter:r,viewports:c,onViewportActive:u,views:d}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let b=0;bb.getShadowMap()),dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{},u={enabled:!0,lights:this._getLights(n)},d=n.props.material;return{shadow:c,lighting:u,phongMaterial:d,gouraudMaterial:d}}cleanup(n){for(let r of this.shadowPasses)r.delete();this.shadowPasses.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,n.deck._removeDefaultShaderModule(wle))}_calculateMatrices(){let n=[];for(let r of this.directionalLights){let c=new Bf().lookAt({eye:new lp(r.direction).negate()});n.push(c)}return n}_createShadowPasses(n){for(let r=0;ru&&(d=u);let b=this._pool,w=n.BYTES_PER_ELEMENT*d,_=b.findIndex(x=>x.byteLength>=w);if(_>=0){let x=new n(b.splice(_,1)[0],0,d);return c&&x.fill(0),x}return new n(d)}_release(n){if(!ArrayBuffer.isView(n))return;let r=this._pool,{buffer:c}=n,{byteLength:u}=c,d=r.findIndex(b=>b.byteLength>=u);d<0?r.push(c):(d>0||r.lengththis.opts.poolSize&&r.shift()}},pv=new Lke;Of();function lB(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function kke(s,n){let r=s%n;return r<0?n+r:r}function Pmt(s){return[s[12],s[13],s[14]]}function Lmt(s){return{left:cB(s[3]+s[0],s[7]+s[4],s[11]+s[8],s[15]+s[12]),right:cB(s[3]-s[0],s[7]-s[4],s[11]-s[8],s[15]-s[12]),bottom:cB(s[3]+s[1],s[7]+s[5],s[11]+s[9],s[15]+s[13]),top:cB(s[3]-s[1],s[7]-s[5],s[11]-s[9],s[15]-s[13]),near:cB(s[3]+s[2],s[7]+s[6],s[11]+s[10],s[15]+s[14]),far:cB(s[3]-s[2],s[7]-s[6],s[11]-s[10],s[15]-s[14])}}var Amt=new lp;function cB(s,n,r,c){Amt.set(s,n,r);let u=Amt.len();return{distance:c/u,normal:new lp(-s/u,-n/u,-r/u)}}function XQt(s){return s-Math.fround(s)}var nV;function uB(s,n){let{size:r=1,startIndex:c=0}=n,u=n.endIndex!==void 0?n.endIndex:s.length,d=(u-c)/r;nV=pv.allocate(nV,d,{type:Float32Array,size:r*2});let b=c,w=0;for(;bne.useInPicking),pass:I,canvasContext:F,isPicking:!0,shaderModuleProps:O,clearColor:z??[0,0,0,0],colorMask:15,scissorRect:H});return this._colorEncoderState=null,{decodePickingColor:Z&&Oen.bind(null,Z),stats:te}}shouldDrawLayer(n){let{pickable:r,operation:c}=n.props;return r&&c.includes("draw")||c.includes("terrain")||c.includes("mask")}getShaderModuleProps(n,r,c){return{picking:{isActive:1,isAttribute:this.pickZ,disabledPickingIndices:n.internalState?.disabledPickingIndices},lighting:{enabled:!1}}}getLayerParameters(n,r,c){let u={...n.props.parameters},{pickable:d,operation:b}=n.props;return this._colorEncoderState?d&&b.includes("draw")?(Object.assign(u,Ben),u.blend=!0,this.device.type==="webgpu"?u.blendConstant=d1t(this._colorEncoderState,n,c):u.blendColor=d1t(this._colorEncoderState,n,c),b.includes("terrain")&&n.state?._hasPickingCover&&(u.blendAlphaSrcFactor="one")):b.includes("terrain")&&(u.blend=!1):u.blend=!1,u}_resetColorEncoder(n){return this._colorEncoderState=n?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}};function d1t(s,n,r){let{byLayer:c,byAlpha:u}=s,d,b=c.get(n);return b?(b.viewports.push(r),d=b.a):(d=c.size+1,d<=255?(b={a:d,layer:n,viewports:[r]},c.set(n,b),u[d]=b):(Bs.warn("Too many pickable layers, only picking the first 255")(),d=0)),[0,0,0,d/255]}function Oen(s,n){let r=s.byAlpha[n[3]];return r&&{pickedLayer:r.layer,pickedViewports:r.viewports,pickedObjectIndex:r.layer.decodePickingColor(n)}}Ql();var XM={NO_STATE:"Awaiting state",MATCHED:"Matched. State transferred from previous layer",INITIALIZED:"Initialized",AWAITING_GC:"Discarded. Awaiting garbage collection",AWAITING_FINALIZATION:"No longer matched. Awaiting garbage collection",FINALIZED:"Finalized! Awaiting garbage collection"},bB=Symbol.for("component"),t2=Symbol.for("propTypes"),Cle=Symbol.for("deprecatedProps"),I3=Symbol.for("asyncPropDefaults"),n2=Symbol.for("asyncPropOriginal"),gv=Symbol.for("asyncPropResolved");function Ale(s,n=()=>!0){return Array.isArray(s)?p1t(s,n,[]):n(s)?[s]:[]}function p1t(s,n,r){let c=-1;for(;++c0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(n,r){if(n===this._data&&!r)return;this._data=n;let c=++this._loadCount,u=n;typeof n=="string"&&(u=BD(n)),u instanceof Promise?(this.isLoaded=!1,this._loader=u.then(d=>{this._loadCount===c&&(this.isLoaded=!0,this._error=void 0,this._content=d)}).catch(d=>{this._loadCount===c&&(this.isLoaded=!0,this._error=d||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=n);for(let d of this._subscribers)d.onChange(this.getData())}};var cV=class{constructor(n){this.protocol=n.protocol||"resource://",this._context={device:n.device,gl:n.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(n){return n.startsWith(this.protocol)?!0:n in this._resources}add({resourceId:n,data:r,forceUpdate:c=!1,persistent:u=!0}){let d=this._resources[n];d?d.setData(r,c):(d=new aV(n,r,this._context),this._resources[n]=d),d.persistent=u}remove(n){let r=this._resources[n];r&&(r.delete(),delete this._resources[n])}unsubscribe({consumerId:n}){let r=this._consumers[n];if(r){for(let c in r){let u=r[c],d=this._resources[u.resourceId];d&&d.unsubscribe(u)}delete this._consumers[n],this.prune()}}subscribe({resourceId:n,onChange:r,consumerId:c,requestId:u="default"}){let{_resources:d,protocol:b}=this;n.startsWith(b)&&(n=n.replace(b,""),d[n]||this.add({resourceId:n,data:null,persistent:!1}));let w=d[n];if(this._track(c,u,w,r),w)return w.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(let n in this._resources)this._resources[n].delete()}_track(n,r,c,u){let d=this._consumers,b=d[n]=d[n]||{},w=b[r],_=w&&w.resourceId&&this._resources[w.resourceId];_&&(_.unsubscribe(w),this.prune()),c&&(w?(w.onChange=u,w.resourceId=c.id):w={onChange:u,resourceId:c.id},b[r]=w,c.subscribe(w))}_prune(){this._pruneRequest=null;for(let n of Object.keys(this._resources)){let r=this._resources[n];!r.persistent&&!r.inUse()&&(r.delete(),delete this._resources[n])}}};var Nen="layerManager.setLayers",Fen="layerManager.activateViewport",lV=class{constructor(n,r){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=w=>{Df(Fen,this,w),w&&(this.context.viewport=w)};let{deck:c,stats:u,viewport:d,timeline:b}=r||{};this.layers=[],this.resourceManager=new cV({device:n,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:n,gl:n?.gl,deck:c,shaderAssembler:Smt(n?.info?.shadingLanguage||"glsl"),defaultShaderModules:[fke],renderPass:void 0,stats:u||new Eb({id:"deck.gl"}),viewport:d||new fB({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:b||new x4,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(let n of this.layers)this._finalizeLayer(n)}needsRedraw(n={clearRedrawFlags:!1}){let r=this._needsRedraw;n.clearRedrawFlags&&(this._needsRedraw=!1);for(let c of this.layers){let u=c.getNeedsRedraw(n);r=r||u}return r}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(n){this._needsRedraw=this._needsRedraw||n}setNeedsUpdate(n){this._needsUpdate=this._needsUpdate||n}getLayers({layerIds:n}={}){return n?this.layers.filter(r=>n.find(c=>r.id.indexOf(c)===0)):this.layers}setProps(n){"debug"in n&&(this._debug=n.debug),"userData"in n&&(this.context.userData=n.userData),"layers"in n&&(this._nextLayers=n.layers),"onError"in n&&(this.context.onError=n.onError)}setLayers(n,r){Df(Nen,this,r,n),this._lastRenderedLayers=n;let c=Ale(n,Boolean);for(let u of c)u.context=this.context;this._updateLayers(this.layers,c)}updateLayers(){let n=this.needsUpdate();n&&(this.setNeedsRedraw(`updating layers: ${n}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,n)),this._nextLayers=null}addDefaultShaderModule(n){let{defaultShaderModules:r}=this.context;r.find(c=>c.name===n.name)||(r.push(n),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(n){let{defaultShaderModules:r}=this.context,c=r.findIndex(u=>u.name===n.name);c>=0&&(r.splice(c,1),this._defaultShaderModulesChanged=!0)}_handleError(n,r,c){c.raiseError(r,`${n} of ${c}`)}_updateLayers(n,r){let c={};for(let b of n)c[b.id]?Bs.warn(`Multiple old layers with same id ${b.id}`)():c[b.id]=b;if(this._defaultShaderModulesChanged){for(let b of n)b.setNeedsUpdate(),b.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}let u=[];this._updateSublayersRecursively(r,c,u),this._finalizeOldLayers(c);let d=!1;for(let b of u)if(b.hasUniformTransition()){d=`Uniform transition in ${b}`;break}this._needsUpdate=d,this.layers=u}_updateSublayersRecursively(n,r,c){for(let u of n){u.context=this.context;let d=r[u.id];d===null&&Bs.warn(`Multiple new layers with same id ${u.id}`)(),r[u.id]=null;let b=null;try{this._debug&&d!==u&&u.validateProps(),d?(this._transferLayerState(d,u),this._updateLayer(u)):this._initializeLayer(u),c.push(u),b=u.isComposite?u.getSubLayers():null}catch(w){this._handleError("matching",w,u)}b&&this._updateSublayersRecursively(b,r,c)}}_finalizeOldLayers(n){for(let r in n){let c=n[r];c&&this._finalizeLayer(c)}}_initializeLayer(n){try{n._initialize(),n.lifecycle=XM.INITIALIZED}catch(r){this._handleError("initialization",r,n)}}_transferLayerState(n,r){r._transferState(n),r.lifecycle=XM.MATCHED,r!==n&&(n.lifecycle=XM.AWAITING_GC)}_updateLayer(n){try{n._update()}catch(r){this._handleError("update",r,n)}}_finalizeLayer(n){this._needsRedraw=this._needsRedraw||`finalized ${n}`,n.lifecycle=XM.AWAITING_FINALIZATION;try{n._finalize(),n.lifecycle=XM.FINALIZED}catch(r){this._handleError("finalization",r,n)}}};function Ac(s,n,r){if(s===n)return!0;if(!r||!s||!n)return!1;if(Array.isArray(s)){if(!Array.isArray(n)||s.length!==n.length)return!1;for(let c=0;c{let c=!n.canvasId||this.getCanvasId(r.id)===n.canvasId,u=!("x"in n)||r.containsPixel(n);return c&&u}):this._viewports}getViews(){let n={};return this.views.forEach(r=>{n[r.id]=r}),n}getView(n){return this.views.find(r=>r.id===n)}getViewState(n){let r=typeof n=="string"?this.getView(n):n,c=r&&this.viewState[r.getViewStateId()]||this.viewState;return r?r.filterViewState(c):c}getViewport(n){return this._viewportMap[n]}getCanvasId(n){let r=typeof n=="string"?this.getView(n):n;return r?this._viewEventManagers[r.id]?.canvasId||this._getCanvasIdFromView(r):void 0}unproject(n,r){let c=this.getViewports(),u={x:n[0],y:n[1]};for(let d=c.length-1;d>=0;--d){let b=c[d];if(b.containsPixel(u)){let w=n.slice();return w[0]-=b.x,w[1]-=b.y,b.unproject(w,r)}}return null}setProps(n){n.views&&this._setViews(n.views),n.viewState&&this._setViewState(n.viewState),("width"in n||"height"in n)&&this._setSize(n.width,n.height),"pickPosition"in n&&(this._pickPosition=n.pickPosition),"eventManagers"in n&&this._setEventManagers(n.eventManagers||{}),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(n,r){(n!==this.width||r!==this.height)&&(this.width=n,this.height=r,this.setNeedsUpdate("Size changed"))}_setViews(n){n=Ale(n,Boolean),this._diffViews(n,this.views)&&this.setNeedsUpdate("views changed"),this.views=n}_setViewState(n){n?(!Ac(n,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=n):Bs.warn("missing `viewState` or `initialViewState`")()}_setEventManagers(n){this._eventManagers!==n&&(this._eventManagers=n,this.setNeedsUpdate("eventManagers changed"))}_getCanvasIdFromView(n){return n.props.canvasId||this._getCanvasContext?.(n.id)?.id||YM}_getCanvasDimensions(n){let r=this._getCanvasContext?.(n.id),[c,u]=r?.getCSSSize()||[this.width,this.height];return{width:c,height:u}}_getViewEventManager(n){let r=this.getCanvasId(n)||YM;return{canvasId:r,eventManager:this._eventManagers[r]||this._eventManager}}_startViewportRebuild(){let n=this.controllers,r=this._viewEventManagers;return this._viewports=[],this.controllers={},this._viewEventManagers={},{oldControllers:n,oldViewEventManagers:r}}_getReusableController(n,r,c){return n&&(r?.canvasId!==c.canvasId||r?.eventManager!==c.eventManager)?(n.finalize(),null):n}_createController(n,r){let c=r.type;return new c({timeline:this.timeline,eventManager:this._getViewEventManager(n).eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:d=>this.getView(n.id)?.makeViewport({viewState:d,...this._getCanvasDimensions(n)}),pickPosition:(d,b)=>this._pickPosition?.(d,b,n.id)})}_updateController(n,r,c,u){let d=n.controller;if(d&&c){let b={...r,...d,id:n.id,x:c.x,y:c.y,width:c.width,height:c.height};return(!u||u.constructor!==d.type)&&(u=this._createController(n,b)),u&&u.setProps(b),u}return null}_rebuildViewports(){let{views:n}=this,{oldControllers:r,oldViewEventManagers:c}=this._startViewportRebuild(),u=!1;for(let d=n.length;d--;){let b=n[d],{width:w,height:_}=this._getCanvasDimensions(b),x=this._getViewEventManager(b);this._viewEventManagers[b.id]=x;let T=this.getViewState(b),M=b.makeViewport({viewState:T,width:w,height:_}),L=this._getReusableController(r[b.id],c[b.id],x),I=!!b.controller;I&&!L&&(u=!0),(u||!I)&&L&&(L.finalize(),L=null),this.controllers[b.id]=this._updateController(b,T,M,L),M&&this._viewports.unshift(M)}for(let d in r){let b=r[d];b&&!this.controllers[d]&&b.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(n=>{n.id&&(this._viewportMap[n.id]=this._viewportMap[n.id]||n)})}_diffViews(n,r){return n.length!==r.length?!0:n.some((c,u)=>!n[u].equals(r[u]))}};var Uen=/^(?:\d+\.?\d*|\.\d+)$/;function _m(s){switch(typeof s){case"number":if(!Number.isFinite(s))throw new Error(`Could not parse position string ${s}`);return{type:"literal",value:s};case"string":try{let n=zen(s);return new Hke(n).parseExpression()}catch(n){let r=n instanceof Error?n.message:String(n);throw new Error(`Could not parse position string ${s}: ${r}`)}default:throw new Error(`Could not parse position string ${s}`)}}function Wke(s,n){switch(s.type){case"literal":return s.value;case"percentage":return Math.round(s.value*n);case"binary":let r=Wke(s.left,n),c=Wke(s.right,n);return s.operator==="+"?r+c:r-c;default:throw new Error("Unknown layout expression type")}}function ym(s,n){return Wke(s,n)}function zen(s){let n=[],r=0;for(;r="0"&&s<="9"}function b1t(s){return s>="a"&&s<="z"||s>="A"&&s<="Z"}function Gen(s){return!!(s&&s.type==="symbol"&&(s.value==="+"||s.value==="-"))}function w1t(s,n){let r={...s};for(let c in n)c!=="id"&&(Array.isArray(r[c])&&Array.isArray(n[c])?r[c]=jen(r[c],n[c]):r[c]=n[c]);return r}function jen(s,n){s=s.slice();for(let r=0;r{},_1t={mode:"preserve"},$en={mode:"hard"},qke={BREAK:1,SNAP_TO_END:2,IGNORE:3},Ven=s=>s,Wen=qke.BREAK,fV=class{constructor(n){this._onTransitionUpdate=r=>{let{time:c,settings:{interpolator:u,startProps:d,endProps:b,duration:w,easing:_}}=r,x=_(c/w),T=u.interpolateProps(d,b,x);this.propsInTransition=this.getControllerState({...this.props,...T},_1t).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=n.getControllerState,this.propsInTransition=null,this.transition=new mv(n.timeline),this.onViewStateChange=n.onViewStateChange||v1t,this.onStateChange=n.onStateChange||v1t}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(n){let r=!1,c=this.props;if(this.props=n,!c||this._shouldIgnoreViewportChange(c,n))return!1;if(this._isTransitionEnabled(n)){let u=c;if(this.transition.inProgress){let{interruption:d,endProps:b}=this.transition.settings;u={...c,...d===qke.SNAP_TO_END?b:this.propsInTransition||c}}this._triggerTransition(u,n),r=!0}else this.transition.cancel();return r}updateTransition(){this.transition.update()}_isTransitionEnabled(n){let{transitionDuration:r,transitionInterpolator:c}=n;return(r>0||r==="auto")&&!!c}_isUpdateDueToCurrentTransition(n){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(n,this.propsInTransition):!1}_shouldIgnoreViewportChange(n,r){return this.transition.inProgress?this.transition.settings.interruption===qke.IGNORE||this._isUpdateDueToCurrentTransition(r):this._isTransitionEnabled(r)?r.transitionInterpolator.arePropsEqual(n,r):!0}_triggerTransition(n,r){let c=this.getControllerState(n,_1t),u=this.getControllerState(r,$en).shortestPathFrom(c),d=r.transitionInterpolator,b=d.getDuration?d.getDuration(n,r):r.transitionDuration;if(b===0)return;let w=d.initializeProps(n,u);this.propsInTransition={};let _={duration:b,easing:r.transitionEasing||Ven,interpolator:d,interruption:r.transitionInterruption||Wen,startProps:w.start,endProps:w.end,onStart:r.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(r.onTransitionInterrupt),onEnd:this._onTransitionEnd(r.onTransitionEnd)};this.transition.start(_),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(n){return r=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),n?.(r)}}};Of();function La(s,n){if(!s)throw new Error(n||"deck.gl: assertion failed.")}var hV=class{constructor(n){let{compare:r,extract:c,required:u}=n;this._propsToCompare=r,this._propsToExtract=c||r,this._requiredProps=u}arePropsEqual(n,r){for(let c of this._propsToCompare)if(!(c in n)||!(c in r)||!Wy(n[c],r[c]))return!1;return!0}initializeProps(n,r){let c={},u={};for(let d of this._propsToExtract)(d in n||d in r)&&(c[d]=n[d],u[d]=r[d]);return this._checkRequiredProps(c),this._checkRequiredProps(u),{start:c,end:u}}getDuration(n,r){return r.transitionDuration}_checkRequiredProps(n){this._requiredProps&&this._requiredProps.forEach(r=>{let c=n[r];La(Number.isFinite(c)||Array.isArray(c),`${r} is required for transition`)})}};Of();var Hen=["longitude","latitude","zoom","bearing","pitch"],qen=["longitude","latitude","zoom"],D3=class extends hV{constructor(n={}){let r=Array.isArray(n)?n:n.transitionProps,c=Array.isArray(n)?{}:n;c.transitionProps=Array.isArray(r)?{compare:r,required:r}:r||{compare:Hen,required:qen},super(c.transitionProps),this.opts=c}initializeProps(n,r){let c=super.initializeProps(n,r),{makeViewport:u,around:d}=this.opts;if(u&&d){let b=u(n),w=u(r),_=b.unproject(d);c.start.around=d,Object.assign(c.end,{around:w.project(_),aroundPosition:_,width:r.width,height:r.height})}return c}interpolateProps(n,r,c){let u={};for(let d of this._propsToExtract)u[d]=lv(n[d]||0,r[d]||0,c);if(r.aroundPosition&&this.opts.makeViewport){let d=this.opts.makeViewport({...r,...u});Object.assign(u,d.panByPosition(r.aroundPosition,lv(n.around,r.around,c)))}return u}};var i2={transitionDuration:0},Xen=300,Yen=300,Xke=s=>1-(1-s)*(1-s),Zen=s=>s===1?1:1-Math.pow(2,-10*s),M4={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],MULTI_PAN:["multipanstart","multipanmove","multipanend"],DOUBLE_CLICK:["dblclick"],DOUBLE_CLICK_DRAG:["dblclickdragstart","dblclickdragmove","dblclickdragend","dblclickdragcancel"],KEYBOARD:["keydown"]},T4={},C4=class{constructor(n){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this._multiPanMode=null,this._multiPanStartCenter=null,this._doubleClickDragAnchor=null,this._suppressDoubleClickUntil=0,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.doubleClickDragZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.multiTouchDrag=null,this.trackpadGesture=!1,this.zoomAround="pointer",this.keyboard=!0,this.transitionManager=new fV({...n,getControllerState:(r,c)=>new this.ControllerState({...r,constraintContext:c,makeViewport:n.makeViewport}),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=n.eventManager,this.onViewStateChange=n.onViewStateChange||(()=>{}),this.onStateChange=n.onStateChange||(()=>{}),this.makeViewport=n.makeViewport,this.pickPosition=n.pickPosition}set events(n){this.toggleEvents(this._customEvents,!1),this.toggleEvents(n,!0),this._customEvents=n,this.props&&this.setProps(this.props)}finalize(){for(let n in this._events)this._events[n]&&this.eventManager?.off(n,this.handleEvent);this.transitionManager.finalize()}handleEvent(n){this._controllerState=void 0;let r=this._eventStartBlocked;switch(n.type){case"panstart":return r?!1:this._onPanStart(n);case"panmove":return this._onPan(n);case"panend":return this._onPanEnd(n);case"pinchstart":return r||!this._isTrackpadGestureAllowed(n)?!1:this._onPinchStart(n);case"pinchmove":return this._isTrackpadGestureAllowed(n)?this._onPinch(n):!1;case"pinchend":return this._isTrackpadGestureAllowed(n)?this._onPinchEnd(n):!1;case"multipanstart":return r?!1:this._onMultiPanStart(n);case"multipanmove":return this._onMultiPan(n);case"multipanend":return this._onMultiPanEnd(n);case"dblclick":return this._onDoubleClick(n);case"dblclickdragstart":return r?!1:this._onDoubleClickDragStart(n);case"dblclickdragmove":return this._onDoubleClickDrag(n);case"dblclickdragend":case"dblclickdragcancel":return this._onDoubleClickDragEnd(n);case"wheel":return this._onWheel(n);case"keydown":return this._onKeyDown(n);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(n){let{x:r,y:c}=this.props,{offsetCenter:u}=n;return[u.x-r,u.y-c]}getZoomPosition(n){if(this.zoomAround==="pointer")return n;let r=this.makeViewport(this.controllerState.getViewportProps()),[c,u]=qM(r.center,r.pixelProjectionMatrix);return[c,u]}isPointInBounds(n,r){let{width:c,height:u}=this.props;if(r&&r.handled)return!1;let d=n[0]>=0&&n[0]<=c&&n[1]>=0&&n[1]<=u;return d&&r&&r.stopPropagation(),d}isFunctionKeyPressed(n){let{srcEvent:r}=n;return!!(r.metaKey||r.altKey||r.ctrlKey||r.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(n){let r=setTimeout(()=>{this._eventStartBlocked===r&&(this._eventStartBlocked=null)},n);this._eventStartBlocked=r}setProps(n){n.maxBoundsPadding===void 0&&(n.maxBoundsPadding=null),n.dragMode&&(this.dragMode=n.dragMode);let r=this.props;this.props=n,"transitionInterpolator"in n||(n.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(n);let{inertia:c}=n;this.inertia=Number.isFinite(c)?c:c===!0?Xen:0;let{scrollZoom:u=!0,dragPan:d=!0,dragRotate:b=!0,doubleClickZoom:w=!0,doubleClickDragZoom:_=!1,touchZoom:x=!0,touchRotate:T=!1,multiTouchDrag:M=T?"rotate":null,trackpadGesture:L=!1,zoomAround:I="pointer",keyboard:D=!0}=n,F=!!this.onViewStateChange;if(this.toggleEvents(M4.WHEEL,F&&u),this.toggleEvents(M4.PAN,F),this.toggleEvents(M4.PINCH,F&&(x||M==="rotate")),this.toggleEvents(M4.MULTI_PAN,F&&!!M),this.toggleEvents(M4.DOUBLE_CLICK,F&&w),this.toggleEvents(M4.DOUBLE_CLICK_DRAG,F&&_),this.toggleEvents(M4.KEYBOARD,F&&D),this.scrollZoom=u,this.dragPan=d,this.dragRotate=b,this.doubleClickZoom=w,this.doubleClickDragZoom=_,this.touchZoom=x,this.touchRotate=M==="rotate",this.multiTouchDrag=M,this.trackpadGesture=L,this.zoomAround=I,this.keyboard=D,(!r||r.height!==n.height||r.width!==n.width||r.maxBounds!==n.maxBounds||r.maxBoundsPadding!==n.maxBoundsPadding)&&n.maxBounds){let z=new this.ControllerState({...n,makeViewport:this.makeViewport}),Z=z.getViewportProps();Object.keys(Z).some(te=>!Ac(Z[te],n[te],1))&&this.updateViewport(z)}}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(n,r){this.eventManager&&n.forEach(c=>{this._events[c]!==r&&(this._events[c]=r,r?this.eventManager.on(c,this.handleEvent):this.eventManager.off(c,this.handleEvent))})}updateViewport(n,r=null,c={}){let u={...n.getViewportProps(),...r},d=this.controllerState!==n;if(this.state=n.getState(),this._setInteractionState(c),d){let b=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:u,interactionState:this._interactionState,oldViewState:b,viewId:this.props.id})}}_onTransition(n){this.onViewStateChange({...n,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(n){Object.assign(this._interactionState,n),this.onStateChange(this._interactionState)}_getConstraintContext(n,r){return this.props.rubberBand?{mode:r==="update"?"elastic":r==="end"?"rebound":"hard"}:{mode:"hard"}}_getReboundTransition(n,r){if(n.mode!=="rebound")return null;let c=r.getViewportProps();return Object.keys(c).some(d=>!Ac(this.props[d],c[d],1))?{...this._getTransitionProps(),transitionDuration:Yen,transitionEasing:Zen}:null}_onPanStart(n){let r=this.getCenter(n);if(!this.isPointInBounds(r,n))return!1;let c=this.isFunctionKeyPressed(n)||n.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(c=!c);let u=c?"pan":"rotate",d=this._getConstraintContext(u,"start"),b=c?this.controllerState.panStart({pos:r},d):this.controllerState.rotateStart({pos:r},d);return this._panMove=c,this.updateViewport(b,i2,{isDragging:!0}),!0}_onPan(n){return this.isDragging()?this._panMove?this._onPanMove(n):this._onPanRotate(n):!1}_onPanEnd(n){return this.isDragging()?this._panMove?this._onPanMoveEnd(n):this._onPanRotateEnd(n):!1}_onPanMove(n){if(!this.dragPan)return!1;let r=this.getCenter(n),c=this.controllerState.pan({pos:r},this._getConstraintContext("pan","update"));return this.updateViewport(c,i2,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(n){let{inertia:r}=this;if(this.dragPan&&r&&n.velocity){let c=this.getCenter(n),u=[c[0]+n.velocityX*r/2,c[1]+n.velocityY*r/2],d=this.controllerState.pan({pos:u}).panEnd();this.updateViewport(d,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Xke},{isDragging:!1,isPanning:!0})}else{let c=this.controllerState,u=this._getConstraintContext("pan","end"),d=c.panEnd(u),b=this._getReboundTransition(u,d);this.updateViewport(d,b,{isDragging:!1,isPanning:!!b})}return!0}_onPanRotate(n){if(!this.dragRotate)return!1;let r=this.getCenter(n),c=this.controllerState.rotate({pos:r},this._getConstraintContext("rotate","update"));return this.updateViewport(c,i2,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(n){let{inertia:r}=this;if(this.dragRotate&&r&&n.velocity){let c=this.getCenter(n),u=[c[0]+n.velocityX*r/2,c[1]+n.velocityY*r/2],d=this.controllerState.rotate({pos:u}).rotateEnd();this.updateViewport(d,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Xke},{isDragging:!1,isRotating:!0})}else{let c=this.controllerState,u=this._getConstraintContext("rotate","end"),d=c.rotateEnd(u),b=this._getReboundTransition(u,d);this.updateViewport(d,b,{isDragging:!1,isRotating:!!b})}return!0}_onWheel(n){if(!this.scrollZoom||this.trackpadGesture&&n.device!=="mouse")return!1;let r=this.getCenter(n);if(!this.isPointInBounds(r,n))return!1;n.srcEvent.preventDefault();let{speed:c=.01,smooth:u=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:d}=n,b=2/(1+Math.exp(-Math.abs(d*c)));d<0&&b!==0&&(b=1/b);let w=this.getZoomPosition(r),_=u?{...this._getTransitionProps({around:w}),transitionDuration:250}:i2,x=this.controllerState.zoom({pos:w,scale:b});return this.updateViewport(x,_,{isZooming:!0,isPanning:!0}),u||this._setInteractionState({isZooming:!1,isPanning:!1}),!0}_onMultiPanStart(n){let{multiTouchDrag:r}=this;if(!r||!this._isMultiPanEventAllowed(n,r))return!1;let c=n.offsetCenter;if(!this.isPointInBounds(this.getCenter(n),n))return!1;let u=n.pointerType==="trackpad",d={x:c.x-(u?0:n.deltaX),y:c.y-(u?0:n.deltaY)},b={...n,offsetCenter:d},w=this.getCenter(b),_=r==="pan"?this.controllerState.panStart({pos:w},this._getConstraintContext("pan","start")):this.controllerState.rotateStart({pos:w},this._getConstraintContext("rotate","start"));return this._multiPanMode=r,this._multiPanStartCenter=d,this.updateViewport(_,i2,{isDragging:!0}),!0}_onMultiPan(n){let{mode:r,event:c}=this._getMultiPanEvent(n);return!r||!c||!this.isDragging()?!1:r==="pan"?this._onPanMove(c):this._onPanRotate(c)}_onMultiPanEnd(n){let{mode:r,event:c}=this._getMultiPanEvent(n);if(!r||!c||!this.isDragging())return this._resetMultiPan(),!1;let u=r==="pan"?this._onPanMoveEnd(c):this._onPanRotateEnd(c);return this._resetMultiPan(),u}_isTrackpadGestureAllowed(n){return n.pointerType!=="trackpad"||this.trackpadGesture}_isMultiPanEventAllowed(n,r){return n.pointerType==="trackpad"?this.trackpadGesture&&(r==="pan"?this.dragPan:this.dragRotate):n.pointerType==="touch"&&(r==="pan"?this.dragPan:this.dragRotate)}_getMultiPanEvent(n){let r=this._multiPanMode,c=this._multiPanStartCenter;return!r||!c?{mode:null,event:null}:{mode:r,event:{...n,offsetCenter:{x:c.x+n.deltaX,y:c.y+n.deltaY}}}}_resetMultiPan(){this._multiPanMode=null,this._multiPanStartCenter=null}_onPinchStart(n){this._doubleClickDragAnchor=null;let r=this.getCenter(n);if(!this.isPointInBounds(r,n))return!1;let c=this.controllerState.zoomStart({pos:this.getZoomPosition(r)},this._getConstraintContext("zoom","start")).rotateStart({pos:r},this._getConstraintContext("rotate","start"));return T4._startPinchRotation=n.rotation,T4._lastPinchEvent=n,this.updateViewport(c,i2,{isDragging:!0}),!0}_onPinch(n){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let r=this.controllerState;if(this.touchZoom){let{scale:c}=n,u=this.getCenter(n);r=r.zoom({pos:this.getZoomPosition(u),scale:c},this._getConstraintContext("zoom","update"))}if(this.touchRotate){let{rotation:c}=n;r=r.rotate({deltaAngleX:T4._startPinchRotation-c},this._getConstraintContext("rotate","update"))}return this.updateViewport(r,i2,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),T4._lastPinchEvent=n,!0}_onPinchEnd(n){if(!this.isDragging())return!1;let{inertia:r}=this,{_lastPinchEvent:c}=T4;if(this.touchZoom&&r&&c&&n.scale!==c.scale){let u=this.getCenter(n),d=this.getZoomPosition(u),b=this.controllerState.rotateEnd(),w=Math.log2(n.scale),_=(w-Math.log2(c.scale))/(n.deltaTime-c.deltaTime),x=Math.pow(2,w+_*r/2);b=b.zoom({pos:d,scale:x}).zoomEnd(),this.updateViewport(b,{...this._getTransitionProps({around:d}),transitionDuration:r,transitionEasing:Xke},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(r)}else{let u=this.controllerState,d=this._getConstraintContext("zoom","end"),b=this._getConstraintContext("rotate","end"),w=u.zoomEnd(d).rotateEnd(b),_=this._getReboundTransition(this.touchZoom?d:b,w);this.updateViewport(w,_,{isDragging:!1,isPanning:!!_&&this.touchZoom,isZooming:!!_&&this.touchZoom,isRotating:!!_&&this.touchRotate})}return T4._startPinchRotation=null,T4._lastPinchEvent=null,!0}_onDoubleClick(n){if(!this.doubleClickZoom||Date.now()90&&(n=Math.sign(n)*90),Number.isFinite(s)){let[c,u]=cg([s,n]);return[c,Kl(u,0,x1t)]}let[,r]=cg([0,n]);return[s,Kl(r,0,x1t)]}var Yke=class extends A4{constructor(n){let{width:r,height:c,latitude:u,longitude:d,zoom:b,bearing:w=0,pitch:_=0,altitude:x=1.5,position:T=[0,0,0],maxZoom:M=20,minZoom:L=0,maxPitch:I=60,minPitch:D=0,startPanLngLat:F,startZoomLngLat:O,startRotatePos:z,startRotateLngLat:Z,startBearing:H,startPitch:te,startZoom:oe,normalize:ne=!0,rubberBand:ue=!1}=n,{[Rb]:Te}=n;La(Number.isFinite(d)),La(Number.isFinite(u)),La(Number.isFinite(b));let Q=n.maxBounds||(ne?E1t:null),ge=n.maxBoundsPadding||null;super({width:r,height:c,latitude:u,longitude:d,zoom:b,bearing:w,pitch:_,altitude:x,maxZoom:M,minZoom:L,maxPitch:I,minPitch:D,normalize:ne,position:T,maxBounds:Q,maxBoundsPadding:ge,rubberBand:ue,[Rb]:Te},{startPanLngLat:F,startZoomLngLat:O,startRotatePos:z,startRotateLngLat:Z,startBearing:H,startPitch:te,startZoom:oe},n.makeViewport,n.constraintContext),this.getAltitude=n.getAltitude}panStart({pos:n},r){return this._getUpdatedState({startPanLngLat:this._unproject(n)},r)}pan({pos:n,startPos:r},c){let u=this.getState().startPanLngLat||this._unproject(r);if(!u)return this;let b=this.makeViewport(this.getViewportProps()).panByPosition(u,n);return this._getUpdatedState(b,c)}panEnd(n){return this._getUpdatedState({startPanLngLat:null},n)}rotateStart({pos:n}){let r=this.getAltitude?.(n);return this._getUpdatedState({startRotatePos:n,startRotateLngLat:r!==void 0?this._unproject3D(n,r):void 0,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:n,deltaAngleX:r=0,deltaAngleY:c=0}){let{startRotatePos:u,startRotateLngLat:d,startBearing:b,startPitch:w}=this.getState();if(!u||b===void 0||w===void 0)return this;let _;if(n?_=this._getNewRotation(n,u,w,b):_={bearing:b+r,pitch:w+c},d){let x=this.makeViewport({...this.getViewportProps(),..._}),T="panByPosition3D"in x?"panByPosition3D":"panByPosition";return this._getUpdatedState({..._,...x[T](d,u)})}return this._getUpdatedState(_)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startRotateLngLat:null,startBearing:null,startPitch:null})}zoomStart({pos:n},r){return this._getUpdatedState({startZoomLngLat:this._unproject(n),startZoom:this.getViewportProps().zoom},r)}zoom({pos:n,startPos:r,scale:c},u){let{startZoom:d,startZoomLngLat:b}=this.getState();return b||(d=this.getViewportProps().zoom,b=this._unproject(r)||this._unproject(n)),b?this._getUpdatedState({zoom:d+Math.log2(c),[Rb]:{position:b,screenPosition:n}},u):this}zoomEnd(n){return this._getUpdatedState({startZoomLngLat:null,startZoom:null},n)}zoomIn(n=2,r){return this._zoomFromCenter(n,r)}zoomOut(n=2,r){return this._zoomFromCenter(1/n,r)}moveLeft(n=100,r){return this._panFromCenter([n,0],r)}moveRight(n=100,r){return this._panFromCenter([-n,0],r)}moveUp(n=100,r){return this._panFromCenter([0,n],r)}moveDown(n=100,r){return this._panFromCenter([0,-n],r)}rotateLeft(n=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-n})}rotateRight(n=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+n})}rotateUp(n=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+n})}rotateDown(n=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-n})}shortestPathFrom(n){let r=n.getViewportProps(),c={...this.getViewportProps()},{bearing:u,longitude:d}=c;return Math.abs(u-r.bearing)>180&&(c.bearing=u<0?u+360:u-360),Math.abs(d-r.longitude)>180&&(c.longitude=d<0?d+360:d-360),c}applyConstraints(n,r){let c=n,u=c[Rb];delete c[Rb];let{maxPitch:d,minPitch:b,pitch:w,bearing:_,normalize:x,maxBounds:T,rubberBand:M}=n;x&&(_<-180||_>180)&&(n.bearing=kke(_+180,360)-180),n.pitch=Kl(w,b,d);let L=this._constrainZoom(n.zoom,n),I=M&&r?.mode==="elastic";if(n.zoom=r?.mode==="preserve"?n.zoom:I?ZM(n.zoom,L,Jen):L,u){let D=this.makeViewport(n);Object.assign(n,D.panByPosition(u.position,u.screenPosition))}if(x&&(n.longitude<-180||n.longitude>180)&&(n.longitude=kke(n.longitude+180,360)-180),T){let D=wB(n.width,n.height,n.maxBoundsPadding),F=this.makeViewport({...n,bearing:0,pitch:0}),O=Ple(F,[n.longitude,n.latitude],D),z=dV(T[0]),Z=dV(T[1]),H=2**n.zoom,te=[z[0]+O.left/H,z[1]+O.bottom/H],oe=[Z[0]-O.right/H,Z[1]-O.top/H],ne=dV([n.longitude,n.latitude]),ue=[Kl(ne[0],te[0],oe[0]),Kl(ne[1],te[1],oe[1])],Te=ne.slice();if(D.width>=0&&(Te[0]=r?.mode==="preserve"?ne[0]:I?ZM(ne[0],ue[0],D.width/2/H):ue[0]),D.height>=0&&(Te[1]=r?.mode==="preserve"?ne[1]:I?ZM(ne[1],ue[1],D.height/2/H):ue[1]),Te[0]!==ne[0]||Te[1]!==ne[1]){let[Q,ge]=z1(Te);Te[0]!==ne[0]&&(n.longitude=Q),Te[1]!==ne[1]&&(n.latitude=ge)}}return n}_constrainZoom(n,r){r||(r=this.getViewportProps());let{maxZoom:c,maxBounds:u}=r,d=u!==null&&r.width>0&&r.height>0,{minZoom:b}=r;if(d){let w=wB(r.width,r.height,r.maxBoundsPadding),_=dV(u[0]),x=dV(u[1]),T=x[0]-_[0],M=x[1]-_[1];w.width>0&&Number.isFinite(T)&&T>0&&(b=Math.max(b,Math.log2(w.width/T))),w.height>0&&Number.isFinite(M)&&M>0&&(b=Math.max(b,Math.log2(w.height/M))),b>c&&(b=c)}return Kl(n,b,c)}_zoomFromCenter(n,r){let{width:c,height:u}=this.getViewportProps();return this.zoom({pos:[c/2,u/2],scale:n},r)}_panFromCenter(n,r){let{width:c,height:u}=this.getViewportProps();return this.pan({startPos:[c/2,u/2],pos:[c/2+n[0],u/2+n[1]]},r)}_getUpdatedState(n,r){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...n,constraintContext:r})}_unproject(n){let r=this.makeViewport(this.getViewportProps());return n&&r.unproject(n)}_unproject3D(n,r){return this.makeViewport(this.getViewportProps()).unproject(n,{targetZ:r})}_getNewRotation(n,r,c,u){let d=n[0]-r[0],b=n[1]-r[1],w=n[1],_=r[1],{width:x,height:T}=this.getViewportProps(),M=d/x,L=0;b>0?Math.abs(T-_)>y1t&&(L=b/(_-T)*Ken):b<0&&_>y1t&&(L=1-w/_),L=Kl(L,-1,1);let{minPitch:I,maxPitch:D}=this.getViewportProps(),F=u+180*M,O=c;return L>0?O=c+L*(D-c):L<0&&(O=c-L*(I-c)),{pitch:O,bearing:F}}},pV=class extends C4{constructor(){super(...arguments),this.ControllerState=Yke,this.transition={transitionDuration:300,transitionInterpolator:new D3({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan",this.rotationPivot="center",this._getAltitude=n=>{if(this.rotationPivot==="2d")return 0;if(this.rotationPivot==="3d"&&this.pickPosition){let{x:r,y:c}=this.props,u=this.pickPosition(r+n[0],c+n[1]);if(u&&u.coordinate&&u.coordinate.length>=3)return u.coordinate[2]}}}setProps(n){"rotationPivot"in n&&(this.rotationPivot=n.rotationPivot||"center"),n.getAltitude=this._getAltitude,n.position=n.position||[0,0,0],n.maxBounds=n.maxBounds||(n.normalize===!1?null:E1t),super.setProps(n)}updateViewport(n,r=null,c={}){let u=n.getState();c.isDragging&&u.startRotateLngLat?c={...c,rotationPivotPosition:u.startRotateLngLat}:c.isDragging===!1&&(c={...c,rotationPivotPosition:void 0}),super.updateViewport(n,r,c)}};var Lle=class extends S4{constructor(n={}){super(n)}getViewportType(){return R3}get ControllerType(){return pV}};Lle.displayName="MapView";var S1t=Lle;var Qen=new aB;function etn(s,n){let r=s.order??1/0,c=n.order??1/0;return r-c}var gV=class{constructor(n){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=n,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(n){let r=this._defaultEffects;if(!r.find(c=>c.id===n.id)){let c=r.findIndex(u=>etn(u,n)>0);c<0?r.push(n):r.splice(c,0,n),n.setup(this._context),this._setEffects(this.effects)}}setProps(n){"effects"in n&&(Ac(n.effects,this.effects,1)||this._setEffects(n.effects))}needsRedraw(n={clearRedrawFlags:!1}){let r=this._needsRedraw;return n.clearRedrawFlags&&(this._needsRedraw=!1),r}getEffects(){return this._resolvedEffects}_setEffects(n){let r={};for(let u of this.effects)r[u.id]=u;let c=[];for(let u of n){let d=r[u.id],b=u;d&&d!==u?d.setProps?(d.setProps(u.props),b=d):d.cleanup(this._context):d||u.setup(this._context),c.push(b),delete r[u.id]}for(let u in r)r[u].cleanup(this._context);this.effects=c,this._resolvedEffects=c.concat(this._defaultEffects),n.some(u=>u instanceof aB)||this._resolvedEffects.push(Qen),this._needsRedraw="effects changed"}finalize(){for(let n of this._resolvedEffects)n.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}};var mV=class extends k3{shouldDrawLayer(n){let{operation:r}=n.props;return r.includes("draw")||r.includes("terrain")}render(n){return this._render(n)}};var ttn="deckRenderer.renderLayers",bV=class{constructor(n,r={}){this.device=n,this.stats=r.stats,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new mV(n),this.pickLayersPass=new E4(n),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(n){this.layerFilter!==n.layerFilter&&(this.layerFilter=n.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==n.drawPickingColors&&(this.drawPickingColors=n.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(n){let r=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,c={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...n};if(!n.viewports.length){let w=r.render(c),_="stats"in w?w.stats:w;this._updateStats(_);return}c.effects&&this._preRender(c.effects,c);let u=this.lastPostProcessEffect?this.renderBuffers[0]:c.target;this.lastPostProcessEffect&&(c.clearColor=[0,0,0,0],c.clearCanvas=!0);let d=r.render({...c,target:u}),b="stats"in d?d.stats:d;c.effects&&(this.lastPostProcessEffect&&(c.clearCanvas=n.clearCanvas===void 0?!0:n.clearCanvas),this._postRender(c.effects,c)),this.renderCount++,Df(ttn,this,b,n),this._updateStats(b)}needsRedraw(n={clearRedrawFlags:!1}){let r=this._needsRedraw;return n.clearRedrawFlags&&(this._needsRedraw=!1),r}finalize(){let{renderBuffers:n}=this;for(let r of n)r.delete();n.length=0}_updateStats(n){if(!this.stats)return;let r=0;for(let{visibleCount:c}of n)r+=c;this.stats.get("Layers rendered").addCount(r)}_preRender(n,r){this.lastPostProcessEffect=null,r.preRenderStats=r.preRenderStats||{};for(let c of n)r.preRenderStats[c.id]=c.preRender(r),c.postRender&&(this.lastPostProcessEffect=c.id);this.lastPostProcessEffect&&this._resizeRenderBuffers(r.canvasContext)}_resizeRenderBuffers(n=this.device.canvasContext){let{renderBuffers:r}=this,c=n.getDrawingBufferSize(),[u,d]=c;r.length===0&&[0,1].map(b=>{let w=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"},width:u,height:d});r.push(this.device.createFramebuffer({id:`deck-renderbuffer-${b}`,colorAttachments:[w]}))});for(let b of r)b.resize(c)}_postRender(n,r){let{renderBuffers:c}=this,u=r.target??r.canvasContext?.getCurrentFramebuffer()??r.target,d={...r,inputBuffer:c[0],swapBuffer:c[1]};for(let b of n)if(b.postRender){d.target=b.id===this.lastPostProcessEffect?u:void 0;let w=b.postRender(d);d.inputBuffer=w,d.swapBuffer=w===c[0]?c[1]:c[0]}}};Vr();var ntn={pickedColor:null,pickedObjectIndex:-1};function Zke({pickedColors:s,decodePickingColor:n,deviceX:r,deviceY:c,deviceRadius:u,deviceRect:d}){let{x:b,y:w,width:_,height:x}=d,T=u*u,M=-1,L=0;for(let I=0;IT)L+=4*_;else for(let O=0;O<_;O++){if(s[L+3]-1>=0){let Z=O+b-r,H=Z*Z+F;H<=T&&(T=H,M=L)}L+=4}}if(M>=0){let I=s.slice(M,M+4),D=n(I);if(D){let F=Math.floor(M/4/_),O=M/4-F*_;return{...D,pickedColor:I,pickedX:b+O,pickedY:w+F}}Bs.error("Picked non-existent layer. Is picking buffer corrupt?")()}return ntn}function Kke({pickedColors:s,decodePickingColor:n}){let r=new Map;if(s){for(let c=0;c=0){let d=s.slice(c,c+4),b=d.join(",");if(!r.has(b)){let w=n(d);w?r.set(b,{...w,color:d}):Bs.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(r.values())}function kle({pickInfo:s,viewports:n,pixelRatio:r,x:c,y:u,z:d}){let b=n[0];n.length>1&&(b=itn(s?.pickedViewports||n,{x:c,y:u}));let w;if(b){let _=[c-b.x,u-b.y];d!==void 0&&(_[2]=d),w=b.unproject(_)}return{color:null,layer:null,viewport:b,index:-1,picked:!1,x:c,y:u,pixel:[c,u],coordinate:w,devicePixel:s&&"pickedX"in s?[s.pickedX,s.pickedY]:void 0,pixelRatio:r}}function Jke(s){let{pickInfo:n,lastPickedInfo:r,mode:c,layers:u}=s,{pickedColor:d,pickedLayer:b,pickedObjectIndex:w}=n,_=b?[b]:[];if(c==="hover"){let M=r.index,L=r.layerId,I=b?b.props.id:null;if(I!==L||w!==M){if(I!==L){let D=u.find(F=>F.props.id===L);D&&_.unshift(D)}r.layerId=I,r.index=w,r.info=null}}let x=kle(s),T=new Map;return T.set(null,x),_.forEach(M=>{let L={...x};M===b&&(L.color=d,L.index=w,L.picked=!0),L=Rle({layer:M,info:L,mode:c});let I=L.layer;M===b&&c==="hover"&&(r.info=L),T.set(I.id,L),c==="hover"&&I.updateAutoHighlight(L)}),T}function Rle({layer:s,info:n,mode:r}){for(;s&&n;){let c=n.layer||null;n.sourceLayer=c,n.layer=s,n=s.getPickingInfo({info:n,mode:r,sourceLayer:c}),s=s.parent}return n}function itn(s,n){for(let r=s.length-1;r>=0;r--){let c=s[r];if(c.containsPixel(n))return c}return s[0]}var wV=class{constructor(n,r={}){this._pickable=!0,this.device=n,this.stats=r.stats,this.pickLayersPass=new E4(n),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(n){"layerFilter"in n&&(this.layerFilter=n.layerFilter),"_pickable"in n&&(this._pickable=n._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObjectAsync(n){return this._pickClosestObjectAsync(n)}pickObjectsAsync(n){return this._pickVisibleObjectsAsync(n)}pickObject(n){return this._pickClosestObject(n)}pickObjects(n){return this._pickVisibleObjects(n)}getLastPickedObject({x:n,y:r,layers:c,viewports:u},d=this.lastPickedInfo.info){let b=d&&d.layer&&d.layer.id,w=d&&d.viewport&&d.viewport.id,_=b?c.find(L=>L.id===b):null,x=w&&u.find(L=>L.id===w)||u[0],T=x&&x.unproject([n-x.x,r-x.y]);return{...d,...{x:n,y:r,viewport:x,coordinate:T,layer:_}}}_resizeBuffer(n=this.device.getDefaultCanvasContext()){if(!this.pickingFBO){let u=this.device.createTexture({format:"rgba8unorm",width:1,height:1,usage:Pa.RENDER_ATTACHMENT|Pa.COPY_SRC});if(this.pickingFBO=this.device.createFramebuffer({colorAttachments:[u],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float")){let d=this.device.createTexture({format:"rgba32float",width:1,height:1,usage:Pa.RENDER_ATTACHMENT|Pa.COPY_SRC}),b=this.device.createFramebuffer({colorAttachments:[d],depthStencilAttachment:"depth16unorm"});this.depthFBO=b}}let[r,c]=n.getDrawingBufferSize();this.pickingFBO?.resize({width:r,height:c}),this.depthFBO?.resize({width:r,height:c})}_getPickable(n){if(this._pickable===!1)return null;let r=n.filter(c=>this.pickLayersPass.shouldDrawLayer(c)&&!c.isComposite);return r.length?r:null}async _pickClosestObjectAsync({layers:n,views:r,viewports:c,x:u,y:d,radius:b=0,depth:w=1,mode:_="query",unproject3D:x,canvasContext:T=this.device.getDefaultCanvasContext(),onViewportActive:M,effects:L}){let I=T.cssToDeviceRatio(),D=this._getPickable(n);if(!D||c.length===0)return{result:[],emptyInfo:kle({viewports:c,x:u,y:d,pixelRatio:I})};this._resizeBuffer(T);let F=T.cssToDevicePixels([u,d],!0),O=[F.x+Math.floor(F.width/2),F.y+Math.floor(F.height/2)],z=Math.round(b*I),{width:Z,height:H}=this.pickingFBO,te=this._getPickingRect({deviceX:O[0],deviceY:O[1],deviceRadius:z,deviceWidth:Z,deviceHeight:H}),oe={x:u-b,y:d-b,width:b*2+1,height:b*2+1},ne,ue=[],Te=new Set;for(let Q=0;Q0){let{pickedColors:at}=await this._drawAndSampleAsync({layers:st,views:r,viewports:c,onViewportActive:M,deviceRect:{x:ge.pickedX??O[0],y:ge.pickedY??O[1],width:1,height:1},cullRect:oe,effects:L,pass:`picking:${_}:z`,canvasContext:T},!0);at[3]&&(Qe=at[0])}ge.pickedLayer&&Q+10){let{pickedColors:at}=this._drawAndSample({layers:st,views:r,viewports:c,onViewportActive:M,deviceRect:{x:ge.pickedX??O[0],y:ge.pickedY??O[1],width:1,height:1},cullRect:oe,effects:L,pass:`picking:${_}:z`,canvasContext:T},!0);at[3]&&(Qe=at[0])}ge.pickedLayer&&Q+1=x);Qe++){let st=ue[Qe],at={color:st.pickedColor,layer:null,index:st.pickedObjectIndex,picked:!0,x:u,y:d,pixelRatio:D};at=Rle({layer:st.pickedLayer,info:at,mode:_});let Ne=at.layer.id;Te.has(Ne)||Te.set(Ne,new Set);let tt=Te.get(Ne),ot=at.object??at.index;tt.has(ot)||(tt.add(ot),Q.push(at))}return Q}_pickVisibleObjects({layers:n,views:r,viewports:c,x:u,y:d,width:b=1,height:w=1,mode:_="query",maxObjects:x=null,canvasContext:T=this.device.getDefaultCanvasContext(),onViewportActive:M,effects:L}){let I=this._getPickable(n);if(!I||c.length===0)return[];this._resizeBuffer(T);let D=T.cssToDeviceRatio(),F=T.cssToDevicePixels([u,d],!0),O=F.x,z=F.y+F.height,Z=T.cssToDevicePixels([u+b,d+w],!0),H=Z.x+Z.width,te=Z.y,oe={x:O,y:te,width:H-O,height:z-te},ne=this._drawAndSample({layers:I,views:r,viewports:c,onViewportActive:M,deviceRect:oe,cullRect:{x:u,y:d,width:b,height:w},effects:L,pass:`picking:${_}`,canvasContext:T}),ue=Kke(ne),Te=new Map,Q=[],ge=Number.isFinite(x);for(let Qe=0;Qe=x);Qe++){let st=ue[Qe],at={color:st.pickedColor,layer:null,index:st.pickedObjectIndex,picked:!0,x:u,y:d,pixelRatio:D};at=Rle({layer:st.pickedLayer,info:at,mode:_});let Ne=at.layer.id;Te.has(Ne)||Te.set(Ne,new Set);let tt=Te.get(Ne),ot=at.object??at.index;tt.has(ot)||(tt.add(ot),Q.push(at))}return Q}async _drawAndSampleAsync({layers:n,views:r,viewports:c,onViewportActive:u,deviceRect:d,cullRect:b,effects:w,pass:_,canvasContext:x},T=!1){let M=T?this.depthFBO:this.pickingFBO,L={layers:n,layerFilter:this.layerFilter,views:r,viewports:c,onViewportActive:u,pickingFBO:M,deviceRect:d,cullRect:b,effects:w,pass:_,canvasContext:x,pickZ:T,preRenderStats:{},isPicking:!0};for(let oe of w)oe.useInPicking&&(L.preRenderStats[oe.id]=oe.preRender(L));let{decodePickingColor:I,stats:D}=this.pickLayersPass.render(L);this._updateStats(D);let{x:F,y:O,width:z,height:Z}=d,H=M.colorAttachments[0]?.texture;if(!H)throw new Error("Picking framebuffer color attachment is missing");let te=await this._readTextureDataAsync(H,{x:F,y:O,width:z,height:Z},T?Float32Array:Uint8Array);if(!T){let oe=!1;for(let ne=3;ne0&&Bs.warn("Async pick readback returned only zero alpha values",{deviceRect:d,bytes:Array.from(te.subarray(0,Math.min(te.length,16)))})()}return{pickedColors:te,decodePickingColor:I}}async _readTextureDataAsync(n,r,c){let{width:u,height:d}=r,b=n.computeMemoryLayout(r),w=this.device.createBuffer({byteLength:b.byteLength,usage:cs.COPY_DST|cs.MAP_READ});try{n.readBuffer(r,w);let _=await w.readAsync(0,b.byteLength),x=c.BYTES_PER_ELEMENT;if(b.bytesPerRow%x!==0)throw new Error(`Texture readback row stride ${b.bytesPerRow} is not aligned to ${x}-byte elements.`);let T=new c(_.buffer,_.byteOffset,b.byteLength/x),M=u*4,L=b.bytesPerRow/x;if(Lb.props.operation.includes("terrain"))}_getPickingRect({deviceX:n,deviceY:r,deviceRadius:c,deviceWidth:u,deviceHeight:d}){let b=Math.max(0,n-c),w=Math.max(0,r-c),_=Math.min(u,n+c+1)-b,x=Math.min(d,r+c+1)-w;return _<=0||x<=0?null:{x:b,y:w,width:_,height:x}}};var rtn={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},stn="top-left",M1t="root",Ile=class{constructor({deck:n,parentElement:r}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=n,r?.classList.add("deck-widget-container"),this.parentElement=r}getWidgets(){return this.resolvedWidgets}setProps(n){if(n.widgets&&!Ac(n.widgets,this.widgets,1)){let r=n.widgets.filter(Boolean);this._setWidgets(r)}}finalize(){for(let n of this.getWidgets())this._removeWidget(n);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(let n in this.containers)this.containers[n].remove()}addDefault(n){this.defaultWidgets.find(r=>r.id===n.id)||(this._addWidget(n),this.defaultWidgets.push(n),this._setWidgets(this.widgets))}onRedraw({viewports:n,layers:r}){let c=n.reduce((u,d)=>(u[d.id]=d,u),{});for(let u of this.getWidgets()){let{viewId:d}=u;if(d){let b=c[d];b&&(u.onViewportChange&&u.onViewportChange(b),u.onRedraw?.({viewports:[b],layers:r}))}else{if(u.onViewportChange)for(let b of n)u.onViewportChange(b);u.onRedraw?.({viewports:n,layers:r})}}this.lastViewports=c,this._updateContainers()}onHover(n,r){for(let c of this.getWidgets()){let{viewId:u}=c;(!u||u===n.viewport?.id)&&c.onHover?.(n,r)}}getCanvasBounds(n){let c=this.deck?.getCanvas?.()?.getBoundingClientRect(),u=this.parentElement?.getBoundingClientRect(),d=this.deck?.getCanvasContext?.(n?.id);if(d&&u){d.updatePosition();let[b,w]=d.getPosition(),[_,x]=d.getCSSSize();return{x:b-u.left,y:w-u.top,width:_,height:x}}return{x:c&&u?c.left-u.left:0,y:c&&u?c.top-u.top:0,width:c?.width||this.deck?.width||0,height:c?.height||this.deck?.height||0}}onEvent(n,r){let c=iB[r.type];if(c)for(let u of this.getWidgets()){let{viewId:d}=u;(!d||d===n.viewport?.id)&&u[c]?.(n,r)}}_setWidgets(n){let r={};for(let c of this.resolvedWidgets)r[c.id]=c;this.resolvedWidgets.length=0;for(let c of this.defaultWidgets)r[c.id]=null,this.resolvedWidgets.push(c);for(let c of n){let u=r[c.id];u?u.viewId!==c.viewId||u.placement!==c.placement?(this._removeWidget(u),this._addWidget(c)):c!==u&&(u.setProps(c.props),c=u):this._addWidget(c),r[c.id]=null,this.resolvedWidgets.push(c)}for(let c in r){let u=r[c];u&&this._removeWidget(u)}this.widgets=n}_addWidget(n){let{viewId:r=null,placement:c=stn}=n,u=n.props._container??r;n.widgetManager=this,n.deck=this.deck,n.rootElement=n._onAdd({deck:this.deck,viewId:r}),n.rootElement&&this._getContainer(u,c).append(n.rootElement),n.updateHTML()}_removeWidget(n){n.onRemove?.(),n.rootElement&&n.rootElement.remove(),n.rootElement=void 0,n.deck=void 0,n.widgetManager=void 0}_getContainer(n,r){if(n&&typeof n!="string")return n;let c=n||M1t,u=this.containers[c];u||(u=document.createElement("div"),u.style.pointerEvents="none",u.style.position="absolute",u.style.overflow="hidden",this.parentElement?.append(u),this.containers[c]=u);let d=u.querySelector(`.${r}`);return d||(d=globalThis.document.createElement("div"),d.className=r,d.style.position="absolute",d.style.zIndex="2",Object.assign(d.style,rtn[r]),u.append(d)),d}_updateContainers(){for(let n in this.containers){let r=this.lastViewports[n]||null,c=n===M1t||r,u=this.containers[n];if(c){let d=this._getContainerBounds(r);u.style.display="block",u.style.left=`${d.x}px`,u.style.top=`${d.y}px`,u.style.width=`${d.width}px`,u.style.height=`${d.height}px`}else u.style.display="none"}}_getContainerBounds(n){if(!n)return{x:0,y:0,width:this.parentElement?.clientWidth||this.deck.width,height:this.parentElement?.clientHeight||this.deck.height};let r=this.getCanvasBounds(n);return{x:r.x+n.x,y:r.y+n.y,width:n.width,height:n.height}}};function Qke(s,n){n&&Object.entries(n).map(([r,c])=>{r.startsWith("--")?s.style.setProperty(r,c):s.style[r]=c})}function T1t(s,n){n&&Object.keys(n).map(r=>{r.startsWith("--")?s.style.removeProperty(r):s.style[r]=""})}var vB=class{constructor(n){this.viewId=null,this.props={...this.constructor.defaultProps,...n},this.id=this.props.id}setProps(n){let r=this.props,c=this.rootElement;c&&r.className!==n.className&&(r.className&&c.classList.remove(r.className),n.className&&c.classList.add(n.className)),c&&!Ac(r.style,n.style,1)&&(T1t(c,r.style),Qke(c,n.style)),Object.assign(this.props,n),this.updateHTML()}updateHTML(){this.rootElement&&this.onRenderHTML(this.rootElement)}get viewIds(){return this.viewId?[this.viewId]:this.deck?.getViews().map(n=>n.id)??[]}getViewState(n){return this.deck?.viewManager?.getViewState(n)||{}}setViewState(n,r){this.deck?._onViewStateChange({viewId:n,viewState:r,interactionState:{}})}onCreateRootElement(){let n=["deck-widget",this.className,this.props.className],r=document.createElement("div");return n.filter(c=>typeof c=="string"&&c.length>0).forEach(c=>r.classList.add(c)),Qke(r,this.props.style),r}_onAdd(n){return this.onAdd(n)??this.onCreateRootElement()}onAdd(n){}onRemove(){}onViewportChange(n){}onRedraw(n){}onHover(n,r){}onClick(n,r){}onDrag(n,r){}onDragStart(n,r){}onDragEnd(n,r){}};vB.defaultProps={id:"widget",style:{},_container:null,className:""};var otn={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"},vV=class extends vB{constructor(n={}){super(n),this.id="default-tooltip",this.placement="fill",this.className="deck-tooltip",this.isVisible=!1,this.setProps(n)}onCreateRootElement(){let n=document.createElement("div");return n.className=this.className,Object.assign(n.style,otn),n}onRenderHTML(n){}onViewportChange(n){this.isVisible&&n.id===this.lastViewport?.id&&!n.equals(this.lastViewport)&&this.setTooltip(null),this.lastViewport=n}onHover(n){let{deck:r}=this,c=r&&r.props.getTooltip;if(!c)return;let u=c(n),d=this.widgetManager?.getCanvasBounds(n.viewport),b=n.x+(d?.x||0),w=n.y+(d?.y||0);this.setTooltip(u,b,w)}setTooltip(n,r,c){let u=this.rootElement;if(u){if(typeof n=="string")u.innerText=n;else if(n)n.text&&(u.innerText=n.text),n.html&&(u.innerHTML=n.html),n.className&&(u.className=n.className);else{this.isVisible=!1,u.style.display="none";return}this.isVisible=!0,u.style.display="block",u.style.transform=`translate(${r}px, ${c}px)`,n&&typeof n=="object"&&"style"in n&&Object.assign(u.style,n.style)}}};vV.defaultProps={...vB.defaultProps};var _V=class{constructor(n){this.targets={},this.order=[],this.eventManagers={},this._eventRootToCanvasId=new WeakMap,this._createEventManager=n.createEventManager,this._getEventRoot=n.getEventRoot}finalize(){for(let n of Object.values(this.targets))n.eventManager.destroy(),n.presentationContext.destroy();this.targets={},this.order=[],this.eventManagers={},this._eventRootToCanvasId=new WeakMap}syncCanvasEntries(n){let r=this._normalizeCanvasList(n.canvases),c={},u=[],d=new Map;for(let{canvas:w}of r){let _=this._getEventRoot(w);d.set(_,(d.get(_)||0)+1)}for(let{id:w,canvas:_}of r){let x=this._getEventRoot(_),T=d.get(x)===1?x:_,M=this.targets[w];if(!M||M.device!==n.device||M.canvas!==_||M.eventRoot!==T){M?.eventManager.destroy(),M?.presentationContext.destroy();let L=n.device.createPresentationContext({id:w,canvas:_,useDevicePixels:n.useDevicePixels,autoResize:!0});M={id:w,device:n.device,canvas:_,eventRoot:T,presentationContext:L,eventManager:this._createEventManager(T)}}this._eventRootToCanvasId.set(T,w),this._eventRootToCanvasId.set(_,w),c[w]=M,u.push(w)}for(let[w,_]of Object.entries(this.targets))c[w]||(_.eventManager.destroy(),_.presentationContext.destroy());this.targets=c,this.order=u;let b=Object.fromEntries(Object.entries(c).map(([w,_])=>[w,_.eventManager]));this._haveSameEventManagers(b)||(this.eventManagers=b)}getCanvasIdFromEvent(n){return n?this._eventRootToCanvasId.get(n):void 0}getTarget(n){return this.targets[n||this.order[0]||YM]||null}_normalizeCanvasList(n=[]){let r=new Set;return n.map((c,u)=>{let d,b;return typeof c=="string"?(d=document.getElementById(c),La(d,`Canvas with id ${c} not found`),b=c):(d=c,b=d.id||`deckgl-canvas-${u}`),La(!r.has(b),`Duplicate canvas id ${b}`),r.add(b),{id:b,canvas:d}})}_haveSameEventManagers(n){let r=Object.keys(n),c=Object.keys(this.eventManagers);return r.length===c.length&&r.every(u=>n[u]===this.eventManagers[u])}};Vr();fue();Ql();Ql();Kj();function B3(){}var bnn=({isDragging:s})=>s?"grabbing":"grab",J0t={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,pickAsync:"auto",layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{},gl:null,canvas:null,_canvases:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:B3,onWebGLInitialized:B3,onResize:B3,onViewStateChange:B3,onInteractionStateChange:B3,onBeforeRender:B3,onAfterRender:B3,onLoad:B3,onError:s=>Bs.error(s.message,s.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:bnn,getTooltip:null,debug:!1,drawPickingColors:!1},RV=class{constructor(n){this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.eventManagers={},this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this._canvasContext=null,this._deviceResizeHandler=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new Eb({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,layersCount:0,drawLayersCount:0,updateLayersCount:0,updateAttributesCount:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,pickLayersCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._hoverPickSequence=0,this._pointerDownPickSequence=0,this._needsRedraw="Initial render",this._canvasManager=new _V({createEventManager:u=>this._createEventManager(u),getEventRoot:u=>this._getEventRoot(u)}),this._ownedCanvas=null,this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,canvasId:void 0,event:null,unproject3D:!1},this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this._onPointerMove=u=>{let{_pickRequest:d}=this,b=this._getCanvasIdFromEvent(u);if(u.type==="pointerleave")d.x=-1,d.y=-1,d.radius=0,d.canvasId=b;else{if(u.leftButton||u.rightButton)return;{let w=u.offsetCenter;if(!w)return;d.x=w.x,d.y=w.y,d.radius=this.props.pickingRadius,d.canvasId=b}}this.layerManager&&(this.layerManager.context.mousePosition={x:d.x,y:d.y}),d.event=u},this._onEvent=u=>{let d=iB[u.type],b=u.offsetCenter,w=this._getCanvasIdFromEvent(u);if(!d||!b||!this.layerManager)return;let _=this.layerManager.getLayers(),x=this._getInternalPickingMode();if(!x)return;if(x==="sync"){let M=u.type==="click"&&this._shouldUnproject3D(_)?this._getFirstPickedInfo(this._pickPointSync(this._getPointPickOptions(b.x,b.y,{unproject3D:!0,canvasId:w},_))):this._getLastPointerDownPickingInfo(b.x,b.y,w,_);this._dispatchPickingEvent(M,u);return}(this._lastPointerDownInfoPromise||Promise.resolve(this._getLastPointerDownPickingInfo(b.x,b.y,w,_))).then(M=>{this._dispatchPickingEvent(M,u)}).catch(M=>this.props.onError?.(M))},this._onPointerDown=u=>{let d=u.offsetCenter,b=this._getCanvasIdFromEvent(u);if(!d)return;let w=this._getInternalPickingMode();if(!w)return;let _=this.layerManager?.getLayers()||[],x=++this._pointerDownPickSequence;if(w==="sync"){let M=this._pickPointSync({x:d.x,y:d.y,canvasId:b,radius:this.props.pickingRadius}),L=this._getFirstPickedInfo(M);this._lastPointerDownInfo=L,this._lastPointerDownInfoPromise=Promise.resolve(L);return}let T=this._pickPointAsync(this._getPointPickOptions(d.x,d.y,{canvasId:b},_)).then(M=>this._getFirstPickedInfo(M)).then(M=>(x===this._pointerDownPickSequence&&(this._lastPointerDownInfo=M),M)).catch(M=>{this.props.onError?.(M);let L=this.deckPicker&&this.viewManager?this._getLastPointerDownPickingInfo(d.x,d.y,b,_):{};return x===this._pointerDownPickSequence&&(this._lastPointerDownInfo=L),L});this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=T};let r=n;this.props={...J0t,...n},n=this.props,this._validateCanvasConfiguration(n),n.viewState&&n.initialViewState&&Bs.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,n.device&&(this.device=n.device,this._setDeviceCanvasContext(n.device));let c=this.device;!c&&n.gl&&(n.gl instanceof WebGLRenderingContext&&Bs.error("WebGL1 context not supported.")(),c=kV.attach(n.gl,{_cacheShaders:!0,_cachePipelines:!0,...this.props.deviceProps})),c||(c=this._createDevice(n)),this.animationLoop=this._createAnimationLoop(c,n),this.setProps(r),n._typedArrayManagerProps&&pv.setOptions(n._typedArrayManagerProps),this.animationLoop.start()}finalize(){this._restoreDeviceResizeHandler(),this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._hoverPickSequence++,this._pointerDownPickSequence++,this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this.layerManager?.finalize(),this.layerManager=null,this.viewManager?.finalize(),this.viewManager=null,this.effectManager?.finalize(),this.effectManager=null,this.deckRenderer?.finalize(),this.deckRenderer=null,this.deckPicker?.finalize(),this.deckPicker=null,Object.keys(this._canvasManager.targets).length||this.eventManager?.destroy(),this.eventManager=null,this.eventManagers={},this.widgetManager?.finalize(),this.widgetManager=null,this._canvasManager.finalize(),this._isMultiCanvasMode()?this.canvas=null:this.canvas&&this.canvas===this._ownedCanvas&&(this.canvas.parentElement?.removeChild(this.canvas),this.canvas=null,this._ownedCanvas=null),this._canvasContext=null}setProps(n){this.stats.get("setProps Time").timeStart(),"onLayerHover"in n&&Bs.removed("onLayerHover","onHover")(),"onLayerClick"in n&&Bs.removed("onLayerClick","onClick")(),n.initialViewState&&!Ac(this.props.initialViewState,n.initialViewState,3)&&(this.viewState=n.initialViewState),La(!("_canvases"in n)||Array.isArray(n._canvases)===this._isMultiCanvasMode()),Object.assign(this.props,n),this._validateCanvasConfiguration(this.props),this._validateInternalPickingMode(),this.device&&this._isMultiCanvasMode()&&this._syncCanvasTargets(),this._setCanvasSize(this.props);let r=Object.create(this.props);if(Object.assign(r,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState(),eventManagers:this.eventManagers}),n.device&&n.device.id!==this.device?.id){let c=n.device.getDefaultCanvasContext();this.animationLoop?.stop(),!this._isMultiCanvasMode()&&this.canvas!==c.canvas&&(this.canvas?.remove(),this.eventManager?.destroy(),this.canvas=null),this._setDeviceCanvasContext(n.device),Bs.log(`recreating animation loop for new device! id=${n.device.id}`)(),this.animationLoop=this._createAnimationLoop(n.device,n),this.animationLoop.start()}if(this.animationLoop?.setProps(r),n.useDevicePixels!==void 0&&this._canvasContext?.setProps){this._canvasContext.setProps({useDevicePixels:n.useDevicePixels});for(let c of Object.values(this._canvasManager.targets))c.presentationContext.setProps({useDevicePixels:n.useDevicePixels})}this.layerManager&&(this.viewManager.setProps(r),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(r),this.effectManager.setProps(r),this.deckRenderer.setProps(r),this.deckPicker.setProps(r),this.widgetManager.setProps(r)),this.stats.get("setProps Time").timeEnd()}needsRedraw(n={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let r=this._needsRedraw;n.clearRedrawFlags&&(this._needsRedraw=!1);let c=this.viewManager.needsRedraw(n),u=this.layerManager.needsRedraw(n),d=this.effectManager.needsRedraw(n),b=this.deckRenderer.needsRedraw(n);return r=r||c||u||d||b,r}redraw(n){if(!this.layerManager)return;let r=this.needsRedraw({clearRedrawFlags:!0});r=n||r,r&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(r):this._drawLayers(r))}get isInitialized(){return this.viewManager!==null}getViews(){return La(this.viewManager),this.viewManager.views}getView(n){return La(this.viewManager),this.viewManager.getView(n)}getViewports(n){return La(this.viewManager),this.viewManager.getViewports(n)}getCanvas(){return this.canvas}getCanvasContext(n){let r=n?this.viewManager?.getView(n)?.props.canvasId:void 0;return this._getCanvasContext(r)}getEventManager(n){if(!n||!this.viewManager)return this.eventManager;let r=this.viewManager.getCanvasId(n)||YM;return this.eventManagers[r]||this.eventManager}async pickObjectAsync(n){let r=(await this._pickAsync("pickObjectAsync","pickObject Time",n)).result;return r.length?r[0]:null}async pickObjectsAsync(n){return await this._pickAsync("pickObjectsAsync","pickObjects Time",n)}pickObject(n){let r=this._pick("pickObject","pickObject Time",n).result;return r.length?r[0]:null}pickMultipleObjects(n){return n.depth=n.depth||10,this._pick("pickObject","pickMultipleObjects Time",n).result}pickObjects(n){return this._pick("pickObjects","pickObjects Time",n)}_pickPositionForController(n,r,c){return this._getInternalPickingMode()!=="sync"?null:this.pickObject({x:n,y:r,radius:0,unproject3D:!0,canvasId:c?this.viewManager?.getCanvasId(c):void 0})}_addResources(n,r=!1){for(let c in n)this.layerManager.resourceManager.add({resourceId:c,data:n[c],forceUpdate:r})}_removeResources(n){for(let r of n)this.layerManager.resourceManager.remove(r)}_addDefaultEffect(n){this.effectManager.addDefaultEffect(n)}_addDefaultShaderModule(n){this.layerManager.addDefaultShaderModule(n)}_removeDefaultShaderModule(n){this.layerManager?.removeDefaultShaderModule(n)}_resolveInternalPickingMode(){let{pickAsync:n}=this.props,r=this.device?.type||this.props.deviceProps?.type;if(n==="auto")return r==="webgpu"?"async":"sync";if(n==="sync"&&r==="webgpu")throw new Error('`pickAsync: "sync"` is not supported when Deck is using a WebGPU device.');return n}_getInternalPickingMode(){try{return this._resolveInternalPickingMode()}catch(n){return this.props.onError?.(n),null}}_validateInternalPickingMode(){this._getInternalPickingMode()}_getFirstPickedInfo({result:n,emptyInfo:r}){return n[0]||r}_shouldUnproject3D(n=this.layerManager?.getLayers()||[]){return n.some(r=>r.props.pickable==="3d")}_getPointPickOptions(n,r,c={},u=this.layerManager?.getLayers()||[]){return{x:n,y:r,canvasId:c.canvasId,radius:this.props.pickingRadius,unproject3D:this._shouldUnproject3D(u),...c}}_pickPointSync(n){return this._pick("pickObject","pickObject Time",n)}_pickPointAsync(n){return this._pickAsync("pickObjectAsync","pickObject Time",n)}_getLastPointerDownPickingInfo(n,r,c,u=this.layerManager?.getLayers()||[]){return this.deckPicker.getLastPickedObject({x:n,y:r,layers:u,viewports:this.getViewports({x:n,y:r,canvasId:c})},this._lastPointerDownInfo)}_applyHoverCallbacks({result:n,emptyInfo:r},c){if(!this.widgetManager)return;this.cursorState.isHovering=n.length>0;let u=r,d=!1;for(let b of n)u=b,d=b.layer?.onHover(b,c)||d;d||(this.props.onHover?.(u,c),this.widgetManager.onHover(u,c))}_dispatchPickingEvent(n,r){if(!this.layerManager||!this.widgetManager)return;let c=iB[r.type];if(!c)return;let{layer:u}=n,d=u&&(u[c]||u.props[c]),b=this.props[c],w=!1;d&&(w=d.call(u,n,r)),w||(b?.(n,r),this.widgetManager.onEvent(n,r))}_pickAsync(n,r,c){La(this.deckPicker);let{stats:u}=this,d=this._isMultiCanvasMode()?c.canvasId||this._getDefaultCanvasId():c.canvasId,b=this._getCanvasContext(d)||void 0;u.get("Pick Count").incrementCount(),u.get(r).timeStart(),this._resizeForCanvasTarget(d);let w=this.deckPicker[n]({layers:this.layerManager.getLayers(c),views:this.viewManager.getViews(),viewports:this.getViewports({...c,canvasId:d}),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...c,canvasId:d,canvasContext:b});return u.get(r).timeEnd(),w}_pick(n,r,c){La(this.deckPicker);let{stats:u}=this,d=this._isMultiCanvasMode()?c.canvasId||this._getDefaultCanvasId():c.canvasId,b=this._getCanvasContext(d)||void 0;u.get("Pick Count").incrementCount(),u.get(r).timeStart(),this._resizeForCanvasTarget(d);let w=this.deckPicker[n]({layers:this.layerManager.getLayers(c),views:this.viewManager.getViews(),viewports:this.getViewports({...c,canvasId:d}),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...c,canvasId:d,canvasContext:b});return u.get(r).timeEnd(),w}_createCanvas(n){let r=n.canvas;return typeof r=="string"&&(r=document.getElementById(r),La(r)),r?this._ownedCanvas=null:(r=document.createElement("canvas"),r.id=n.id||"deckgl-overlay",n.width&&typeof n.width=="number"&&(r.width=n.width),n.height&&typeof n.height=="number"&&(r.height=n.height),(n.parent||document.body).appendChild(r),this._ownedCanvas=r),Object.assign(r.style,n.style),r}_isMultiCanvasMode(){return Array.isArray(this.props._canvases)}_getDefaultCanvasId(){return this._canvasManager.order[0]||YM}_validateCanvasConfiguration(n){Array.isArray(n._canvases)&&(La(!n.canvas),La(!n.gl),La(!n.device?.canvasContext||n.device.getDefaultCanvasContext().offscreenCanvas))}_createEventManager(n){let r=new H$(n,{touchAction:this.props.touchAction,recognizers:Object.keys(xke).map(c=>{let[u,d,b,w]=xke[c],_=this.props.eventRecognizerOptions?.[c],x={...d,..._,event:c};return{recognizer:new u(x),recognizeWith:b,requireFailure:w}}),events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(let c in iB)c==="dblclick"?r.watch(c,this._onEvent):r.on(c,this._onEvent);return r}_getEventRoot(n){return n.closest(".deck-events-root")||this.props.parent?.querySelector(".deck-events-root")||n}_syncCanvasTargets(){if(!this.device||!this._isMultiCanvasMode())return;this._canvasManager.syncCanvasEntries({device:this.device,canvases:this.props._canvases||[],useDevicePixels:this.props.useDevicePixels}),this.eventManagers=this._canvasManager.eventManagers;let n=this._getDefaultCanvasId();this.eventManager=this.eventManagers[n]||null,this.canvas=this._canvasManager.targets[n]?.canvas||null}_setCanvasContext(n){this._canvasContext=n,"style"in n.canvas&&(this.canvas=n.canvas)}_setDeviceCanvasContext(n,r={}){let c=n.getDefaultCanvasContext();this._setCanvasContext(c),this._setDeviceResizeHandler(n,r)}_setDeviceResizeHandler(n,r={}){let c=!!r.syncDrawingBuffer;if(this._deviceResizeHandler?.device===n){this._deviceResizeHandler.syncDrawingBuffer=c;return}this._restoreDeviceResizeHandler();let u=d=>{this._isMultiCanvasMode()?this._updateMultiCanvasDimensions():d===this._canvasContext&&this._canvasContext&&this._onCanvasContextResize(this._canvasContext,{syncDrawingBuffer:this._deviceResizeHandler?.syncDrawingBuffer})};n.props.onResize=u,this._deviceResizeHandler={device:n,onResize:u,syncDrawingBuffer:c}}_restoreDeviceResizeHandler(){let n=this._deviceResizeHandler;n&&n.device.props?.onResize===n.onResize&&(n.device.props.onResize=B3),this._deviceResizeHandler=null}_setCanvasSize(n){if(this._isMultiCanvasMode()||!this.canvas)return;let{width:r,height:c}=n;if(r||r===0){let u=Number.isFinite(r)?`${r}px`:r;this.canvas.style.width=u}if(c||c===0){let u=Number.isFinite(c)?`${c}px`:c;this.canvas.style.position=n.style?.position||"absolute",this.canvas.style.height=u}}_getCanvasIdFromEvent(n){return this._canvasManager.getCanvasIdFromEvent(n?.rootElement)}_getCanvasContext(n){return this._canvasManager.getTarget(n)?.presentationContext||this._canvasContext}_resizeForCanvasTarget(n){let r=this._canvasManager.getTarget(n);if(!r||!this.device?.canvasContext)return;let[c,u]=r.presentationContext.getDrawingBufferSize();this.device.canvasContext.setDrawingBufferSize(c,u)}_createDeviceCanvas(n){if(this._isMultiCanvasMode()){let r=globalThis.OffscreenCanvas;if(!r)throw new Error("`_canvases` requires OffscreenCanvas support.");let c=typeof n.width=="number"&&Number.isFinite(n.width)?n.width:1,u=typeof n.height=="number"&&Number.isFinite(n.height)?n.height:1;return new r(c,u)}return this._createCanvas(n)}_updateCanvasSize(n=this._canvasContext){if(this._isMultiCanvasMode()){this._updateMultiCanvasDimensions();return}let{canvas:r}=this,[c,u]=n?n.getCSSSize():[r?.clientWidth??r?.width??0,r?.clientHeight??r?.height??0];(c!==this.width||u!==this.height)&&(this.width=c,this.height=u,this.viewManager?.setProps({width:c,height:u}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:c,height:u},n||void 0))}_onCanvasContextResize(n,r={}){if(r.syncDrawingBuffer){let{width:c,height:u}=n.canvas;n.setDrawingBufferSize(c,u)}this._needsRedraw="Canvas resized",this._updateCanvasSize(n)}_updateMultiCanvasDimensions(){let[n,r]=this._getCanvasContext()?.getCSSSize()||[0,0];(n!==this.width||r!==this.height)&&(this.width=n,this.height=r,this.props.onResize({width:n,height:r})),this._needsRedraw="Canvas resized",this.viewManager?.setNeedsUpdate("Canvas resized"),this.viewManager?.setProps({width:this.width,height:this.height})}_createAnimationLoop(n,r){let{gl:c,onError:u}=r;return new iV({device:n,autoResizeDrawingBuffer:!c&&!Array.isArray(r._canvases),autoResizeViewport:!1,onInitialize:d=>this._setDevice(d.device),onRender:this._onRenderFrame.bind(this),onError:u})}_createDevice(n){let r=this.props.deviceProps?.createCanvasContext,c=typeof r=="object"?r:void 0,u={adapters:[],_cacheShaders:!0,_cachePipelines:!0,...n.deviceProps};u.adapters.includes(kV)||u.adapters.push(kV);let d={alphaMode:this.props.deviceProps?.type==="webgpu"?"premultiplied":void 0};return UD.createDevice({_reuseDevices:!0,type:"webgl",...u,createCanvasContext:{...d,...c,canvas:this._createDeviceCanvas(n),useDevicePixels:this.props.useDevicePixels,autoResize:!0}})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let{views:n}=this.props,r=Array.isArray(n)?n:n?[n]:[new S1t({id:"default-view"})];return r.length&&this.props.controller&&(r[0]=r[0].clone({controller:this.props.controller})),r}_onContextLost(){let{onError:n}=this.props;this.animationLoop&&n&&n(new Error("WebGL context is lost"))}_pickAndCallback(){let{_pickRequest:n}=this;if(n.event){let r=n.event,c=this.layerManager?.getLayers()||[],u=this._getPointPickOptions(n.x,n.y,{canvasId:n.canvasId,radius:n.radius,mode:n.mode},c),d=this._getInternalPickingMode(),b=++this._hoverPickSequence;if(n.event=null,n.canvasId=void 0,!d)return;if(d==="sync"){this._applyHoverCallbacks(this._pickPointSync(u),r);return}this._pickPointAsync(u).then(({result:w,emptyInfo:_})=>{b===this._hoverPickSequence&&this._applyHoverCallbacks({result:w,emptyInfo:_},r)}).catch(w=>this.props.onError?.(w))}}_updateCursor(){let n=this.props.getCursor(this.cursorState);if(this._isMultiCanvasMode()){for(let c of Object.values(this._canvasManager.targets))c.canvas.style.cursor=n;return}let r=this.props.parent||this.canvas;r&&(r.style.cursor=n)}_setDevice(n){if(this.device=n,this._validateInternalPickingMode(),!this.animationLoop)return;this._setDeviceCanvasContext(n,{syncDrawingBuffer:!!(this.props.gl&&this.props.device!==n)}),this._isMultiCanvasMode()?this._syncCanvasTargets():this.canvas&&!this.canvas.isConnected&&this.props.parent&&this.props.parent.insertBefore(this.canvas,this.props.parent.firstChild),this.device.type==="webgl"&&this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),this.device.type==="webgl"&&this.props.onWebGLInitialized(this.device.gl);let r=new x4;if(r.play(),this.animationLoop.attachTimeline(r),!this._isMultiCanvasMode()){let d=this.canvas&&this._getEventRoot(this.canvas);La(d),this.eventManager=this._createEventManager(d),this.eventManagers={[YM]:this.eventManager}}this.viewManager=new uV({timeline:r,eventManager:this.eventManager,eventManagers:this.eventManagers,getCanvasContext:this._isMultiCanvasMode()?this.getCanvasContext.bind(this):void 0,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),pickPosition:this._pickPositionForController.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});let c=this.viewManager.getViewports()[0];this.layerManager=new lV(this.device,{deck:this,stats:this.stats,viewport:c,timeline:r}),this.effectManager=new gV({deck:this,device:this.device}),this.deckRenderer=new bV(this.device,{stats:this.stats}),this.deckPicker=new wV(this.device,{stats:this.stats});let u=this.props.parent?.querySelector(".deck-widgets-root")||(this._isMultiCanvasMode()?this.props.parent||this.canvas?.parentElement:null)||this.canvas?.parentElement;this.widgetManager=new Ile({deck:this,parentElement:u}),this.widgetManager.addDefault(new vV),this.setProps({}),this._updateCanvasSize(this._canvasContext),this.props.onLoad()}_drawLayers(n,r){let{device:c,gl:u}=this.layerManager.context;this.props.onBeforeRender({device:c,gl:u});let d={target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:"screen",effects:this.effectManager.getEffects(),...r};if(this._isMultiCanvasMode()&&d.pass==="screen"&&!d.target&&this._canvasManager.order.length)for(let b of this._canvasManager.order){let w=d.viewports.filter(T=>this.viewManager.getCanvasId(T.id)===b);if(!w.length){let T=this._canvasManager.targets[b];this._resizeForCanvasTarget(b),this.deckRenderer?.renderLayers({...d,canvasContext:T.presentationContext,target:T.presentationContext.getCurrentFramebuffer(),viewports:[],clearCanvas:!0}),T.presentationContext.present();continue}let _=this._canvasManager.targets[b];this._resizeForCanvasTarget(b);let x=_.presentationContext.getCurrentFramebuffer();this.deckRenderer?.renderLayers({...d,canvasContext:_.presentationContext,target:x,viewports:w}),_.presentationContext.present()}else this.deckRenderer?.renderLayers(d);d.pass==="screen"&&this.widgetManager.onRedraw({viewports:d.viewports,layers:d.layers}),this.props.onAfterRender({device:c,gl:u})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60===0&&(this._getMetrics(),this.stats.reset(),Bs.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCursor(),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(n){let r=this.props.onViewStateChange(n)||n.viewState;this.viewState&&(this.viewState={...this.viewState,[n.viewId]:r},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(n){this.cursorState.isDragging=n.isDragging||!1,this.props.onInteractionStateChange(n)}_getFrameStats(){let{stats:n}=this;n.get("frameRate").timeEnd(),n.get("frameRate").timeStart();let r=this.animationLoop.stats;n.get("GPU Time").addTime(r.get("GPU Time").lastTiming),n.get("CPU Time").addTime(r.get("CPU Time").lastTiming)}_getMetrics(){let{metrics:n,stats:r}=this;n.fps=r.get("frameRate").getHz(),n.setPropsTime=r.get("setProps Time").time,n.updateAttributesTime=r.get("Update Attributes").time,n.framesRedrawn=r.get("Redraw Count").count,n.pickTime=r.get("pickObject Time").time+r.get("pickMultipleObjects Time").time+r.get("pickObjects Time").time,n.pickCount=r.get("Pick Count").count,n.layersCount=this.layerManager?.layers.length??0,n.drawLayersCount=r.get("Layers rendered").lastSampleCount,n.pickLayersCount=r.get("Layers picked").lastSampleCount,n.updateLayersCount=r.get("Layer updates").count,n.updateAttributesCount=r.get("Attributes updated").count,n.gpuTime=r.get("GPU Time").time,n.cpuTime=r.get("CPU Time").time,n.gpuTimePerFrame=r.get("GPU Time").getAverageTime(),n.cpuTimePerFrame=r.get("CPU Time").getAverageTime();let c=UD.stats.get("GPU Time and Memory");n.bufferMemory=c.get("Buffer Memory").count,n.textureMemory=c.get("Texture Memory").count,n.renderbufferMemory=c.get("Renderbuffer Memory").count,n.gpuMemory=c.get("GPU Memory").count}};RV.defaultProps=J0t;RV.VERSION=sht;var CRe=RV;Vr();Vr();function Q0t(s){switch(s){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return JL(s)}}var ebt=Md.getDataType.bind(Md);function IV(s,n,r){if(n.size>4)return null;let c=r==="webgpu"&&n.type==="uint8"?"unorm8":n.type,u=n.size,d=!!(r!=="webgpu"&&u===3&&c&&["uint8","sint8","unorm8","snorm8","uint16","sint16","unorm16","snorm16"].includes(c));return{attribute:s,format:u>1?`${c}x${u}${d?"-webgl":""}`:n.type,byteOffset:n.offset||0}}function Ib(s){return s.stride||s.size*s.bytesPerElement}function tbt(s,n){return s.type===n.type&&s.size===n.size&&Ib(s)===Ib(n)&&(s.offset||0)===(n.offset||0)}function ARe(s,n){n.offset&&Bs.removed("shaderAttribute.offset","vertexOffset, elementOffset")();let r=Ib(s),c=n.vertexOffset!==void 0?n.vertexOffset:s.vertexOffset||0,u=n.elementOffset||0,d=c*r+u*s.bytesPerElement+(s.offset||0);return{...n,offset:d,stride:r}}function wnn(s,n){let r=ARe(s,n);return{high:r,low:{...r,offset:r.offset+s.size*4}}}var DV=class{constructor(n,r,c){this._buffer=null,this.device=n,this.id=r.id||"",this.size=r.size||1;let u=r.logicalType||r.type,d=u==="float64",{defaultValue:b}=r;b=Number.isFinite(b)?[b]:b||new Array(this.size).fill(0);let w;d?w="float32":!u&&r.isIndexed?w="uint32":w=u||"float32";let _=Q0t(u||w);this.doublePrecision=d,d&&r.fp64===!1&&(_=Float32Array),this.value=null,this.settings={...r,defaultType:_,defaultValue:b,logicalType:u,type:w,normalized:w.includes("norm"),size:this.size,bytesPerElement:_.BYTES_PER_ELEMENT},this.state={...c,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){let n=this.getAccessor();return n.vertexOffset?n.vertexOffset*Ib(n):0}get numInstances(){return this.state.numInstances}set numInstances(n){this.state.numInstances=n}get isDoublePrecisionBuffer(){return this._shouldSplitDoublePrecisionValue(this.value)}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),pv.release(this.state.allocatedValue),this.state.allocatedValue=null}getBuffer(){return this.state.constant&&this.device.type!=="webgpu"?null:this.state.externalBuffer||this._buffer}getValue(n=this.id,r=null){let c={};if(this.state.constant){let u=this.value;if(this.device.type==="webgpu"&&this._buffer)c[n]=this._buffer;else if(r){let d=ARe(this.getAccessor(),r),b=d.offset/u.BYTES_PER_ELEMENT,w=d.size||this.size;c[n]=u.subarray(b,b+w)}else c[n]=u}else c[n]=this.getBuffer();return this.doublePrecision&&(this.isDoublePrecisionBuffer?c[`${n}64Low`]=c[n]:c[`${n}64Low`]=new Float32Array(this.size)),c}_getBufferLayout(n=this.id,r=null){let c=this.getAccessor(),u=[],d={name:this.id,byteStride:this.device.type==="webgpu"&&this.state.constant?0:Ib(c)};if(this.doublePrecision){let b=wnn(c,r||{});u.push(IV(n,{...c,...b.high},this.device.type),IV(`${n}64Low`,{...c,...b.low},this.device.type))}else if(r){let b=ARe(c,r);u.push(IV(n,{...c,...b},this.device.type))}else u.push(IV(n,c,this.device.type));return d.attributes=u.filter(Boolean),d}setAccessor(n){this.state.bufferAccessor=n}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let n=null;if(this.state.constant&&this.value){let r=Array.from(this.value);n=[r,r]}else{let{value:r,numInstances:c,size:u}=this,d=c*u;if(r&&d&&r.length>=d){let b=new Array(u).fill(1/0),w=new Array(u).fill(-1/0);for(let _=0;_w[x]&&(w[x]=T)}n=[b,w]}}return this.state.bounds=n,n}setData(n){let{state:r}=this,c;ArrayBuffer.isView(n)?c={value:n}:n instanceof cs?c={buffer:n}:c=n;let u={...this.settings,...c};if(ArrayBuffer.isView(c.value)){if(!c.type)if(this.doublePrecision&&c.value instanceof Float64Array)u.type="float32";else{let b=ebt(c.value);u.type=u.normalized?b.replace("int","norm"):b}u.bytesPerElement=c.value.BYTES_PER_ELEMENT,u.stride=Ib(u)}if(r.bounds=null,c.constant){let d=c.value;if(d=this._normalizeValue(d,[],0),this.settings.normalized&&(d=this.normalizeConstant(d)),!(!r.constant||!this._areValuesEqual(d,this.value)))return!1;r.externalBuffer=null,r.constant=!0,this.value=ArrayBuffer.isView(d)?d:new Float32Array(d)}else if(c.buffer){let d=c.buffer;r.externalBuffer=d,r.constant=!1,this.value=c.value||null}else if(c.value){this._checkExternalBuffer(c);let d=c.value,b=d;r.externalBuffer=null,r.constant=!1,this.value=d,this._shouldSplitDoublePrecisionValue(b)&&(b=uB(b,u),d instanceof Float32Array&&(u.stride=u.size*2*Float32Array.BYTES_PER_ELEMENT));let{buffer:w}=this,_=Ib(u),x=(u.vertexOffset||0)*_;if(this.settings.isIndexed){let M=this.settings.defaultType;b.constructor!==M&&(b=new M(b))}let T=b.byteLength+x+_*2;(!w||w.byteLength(r+128)/255*2-1);case"snorm16":return new Float32Array(n).map(r=>(r+32768)/65535*2-1);case"unorm8":return new Float32Array(n).map(r=>r/255);case"unorm16":return new Float32Array(n).map(r=>r/65535);default:return n}}_normalizeValue(n,r,c){let{defaultValue:u,size:d}=this.settings;if(Number.isFinite(n))return r[c]=n,r;if(!n){let b=d;for(;--b>=0;)r[c+b]=u[b];return r}switch(d){case 4:r[c+3]=Number.isFinite(n[3])?n[3]:u[3];case 3:r[c+2]=Number.isFinite(n[2])?n[2]:u[2];case 2:r[c+1]=Number.isFinite(n[1])?n[1]:u[1];case 1:r[c+0]=Number.isFinite(n[0])?n[0]:u[0];break;default:let b=d;for(;--b>=0;)r[c+b]=Number.isFinite(n[b])?n[b]:u[b]}return r}_areValuesEqual(n,r){if(!n||!r)return!1;let{size:c}=this;for(let u=0;u0&&(ibt.length=s.length,c=ibt):c=nbt,(n>0||Number.isFinite(r))&&(c=(Array.isArray(c)?c:Array.from(c)).slice(n,r),u.index=n-1),{iterable:c,objectInfo:u}}function mue(s){return s&&s[Symbol.asyncIterator]}function bue(s,n){let{size:r,stride:c,offset:u,startIndices:d,nested:b}=n,w=s.BYTES_PER_ELEMENT,_=c?c/w:r,x=u?u/w:0,T=Math.floor((s.length-x)/_);return(M,{index:L,target:I})=>{if(!d){let z=L*_+x;for(let Z=0;Z=n[1]))return s;let r=[],c=s.length,u=0;for(let d=0;dn[1]?r.push(b):n=[Math.min(b[0],n[0]),Math.max(b[1],n[1])]}return r.splice(u,0,n),r}var _nn={interpolation:{duration:0,easing:s=>s},spring:{stiffness:.05,damping:.5}};function wue(s,n){if(!s)return null;Number.isFinite(s)&&(s={type:"interpolation",duration:s});let r=s.type||"interpolation";return{..._nn[r],...n,...s,type:r}}var k4=class extends DV{constructor(n,r){super(n,r,{startIndices:null,constantValue:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:BV}),this.constant=!1,this.settings.update=r.update||(r.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(n){this.state.startIndices=n}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:n=!1}={}){let r=this.state.needsRedraw;return this.state.needsRedraw=r&&!n,r}layoutChanged(){return this.state.layoutChanged}setAccessor(n){var r;(r=this.state).layoutChanged||(r.layoutChanged=!tbt(n,this.getAccessor())),super.setAccessor(n)}getUpdateTriggers(){let{accessor:n}=this.settings;return[this.id].concat(typeof n!="function"&&n||[])}supportsTransition(){return!!this.settings.transition}getTransitionSetting(n){if(!n||!this.supportsTransition())return null;let{accessor:r}=this.settings,c=this.settings.transition,u=Array.isArray(r)?n[r.find(d=>n[d])]:n[r];return wue(u,c)}setNeedsUpdate(n=this.id,r){if(this.state.needsUpdate=this.state.needsUpdate||n,this.setNeedsRedraw(n),r){let{startRow:c=0,endRow:u=1/0}=r;this.state.updateRanges=sbt(this.state.updateRanges,[c,u])}else this.state.updateRanges=BV}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=rbt}setNeedsRedraw(n=this.id){this.state.needsRedraw=this.state.needsRedraw||n}allocate(n){let{state:r,settings:c}=this;if(c.noAlloc)return!1;if(c.update){let u=this.isConstant;return super.allocate(n,r.updateRanges!==BV),r.layoutChanged||(r.layoutChanged=u&&this.device.type==="webgpu"),!0}return!1}updateBuffer({numInstances:n,data:r,props:c,context:u}){if(!this.needsUpdate())return!1;let{state:{updateRanges:d},settings:{update:b,noAlloc:w}}=this,_=!0;if(b){for(let[x,T]of d)b.call(u,this,{data:r,startRow:x,endRow:T,props:c,numInstances:n});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLengthT?x.set(H,F):(n._normalizeValue(H,z.target,0),g1t({target:x,source:z.target,start:F,count:te}));F+=te*T}else n._normalizeValue(H,x,F),F+=T}}_validateAttributeUpdaters(){let{settings:n}=this;if(!(n.noAlloc||typeof n.update=="function"))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){let{value:n}=this,r=Math.min(4,this.size);if(n&&n.length>=r){let c=!0;switch(r){case 4:c=c&&Number.isFinite(n[3]);case 3:c=c&&Number.isFinite(n[2]);case 2:c=c&&Number.isFinite(n[1]);case 1:c=c&&Number.isFinite(n[0]);break;default:c=!1}if(!c)throw new Error(`Illegal attribute generated for ${this.id}`)}}};F3();DRe();F3();var NV=class s{gpuDataEvaluators;format;length;id;_gpuVector;_ownsGPUDataEvaluators;_destroyed=!1;static fromGPUVector(n){if(n.bufferLayout)throw new Error(`GPUVectorEvaluator.fromGPUVector() does not accept interleaved vector "${n.name}"`);if(n.data.length===0)throw new Error(`GPUVectorEvaluator.fromGPUVector() requires GPUData for "${n.name}"`);return new s({id:n.name,gpuDataEvaluators:n.data.map(r=>fc.fromGPUData(r,{id:n.name})),gpuVector:n,format:n.format})}static fromGPUDataEvaluators(n,r={}){return new s({id:r.id,gpuDataEvaluators:n,format:r.format})}constructor({id:n,gpuDataEvaluators:r,gpuVector:c,format:u}){if(r.length===0)throw new Error("GPUVectorEvaluator requires at least one GPUData evaluator");Inn(r),this.id=n,this.gpuDataEvaluators=r,this.format=u??r[0].format,this.length=r.reduce((d,b)=>d+b.length,0),this._gpuVector=c,this._ownsGPUDataEvaluators=!c}get evaluated(){return!!this._gpuVector}get gpuVector(){if(!this._gpuVector)throw new Error(`${this} not evaluated`);return this._gpuVector}mapGPUData(n){return s.fromGPUDataEvaluators(this.gpuDataEvaluators.map((r,c)=>n(r,c)),{id:this.id})}async evaluate(n,r={}){if(this._destroyed)throw new Error(`GPUVectorEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let c=await Promise.all(this.gpuDataEvaluators.map(w=>w.evaluate(n,r))),u=c[0],d=c.map(bbt),b=r.format??this.format??u.format;return this._gpuVector=new c2({type:"data",name:r.name??this.id??"vector",format:b,data:d,stride:u.stride,byteStride:u.byteStride,rowByteLength:u.rowByteLength,bufferLayout:u.bufferLayout}),this._gpuVector}evaluateSync(n,r={}){if(this._destroyed)throw new Error(`GPUVectorEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let c=this.gpuDataEvaluators.map(w=>w.evaluateSync(n,r)),u=c[0],d=c.map(bbt),b=r.format??this.format??u.format;return this._gpuVector=new c2({type:"data",name:r.name??this.id??"vector",format:b,data:d,stride:u.stride,byteStride:u.byteStride,rowByteLength:u.rowByteLength,bufferLayout:u.bufferLayout}),this._gpuVector}destroy(){if(this._ownsGPUDataEvaluators)for(let n of this.gpuDataEvaluators)n.destroy();this._gpuVector=void 0,this._destroyed=!0}toString(){return this.id??this.constructor.name}};function Inn(s){let n=s[0];for(let r of s.slice(1))if(r.type!==n.type||r.size!==n.size||r.normalized!==n.normalized||r.format!==n.format)throw new Error("GPUVectorEvaluator requires matching GPUData evaluator layouts")}function bbt(s){let[n,...r]=s.data;if(!n||r.length>0)throw new Error(`GPUVectorEvaluator requires one GPUData chunk for "${s.name}"`);return n}F3();Vr();var FRe={};Oy(FRe,{arithmetic:()=>wbt,dot:()=>Sbt,equalAll:()=>Mbt,extent:()=>_bt,fround:()=>ybt,gather:()=>xbt,interleave:()=>Ebt,length:()=>Tbt,segmentedMap:()=>Cbt,select:()=>Abt,sequence:()=>Pbt,swizzle:()=>Lbt});Tue();function TB({elementWise:s,func:n,inputs:r,output:c,outputBuffer:u}){let d=Array.isArray(r)?r:Object.values(r);for(let D of d)if(!D.value)throw new Error(`${D} does not have CPU value`);let b=c.length,w=c.size,_=new c.ValueType(b*w);for(let D=0;Dpf(O,D));if(s)for(let O=0;Oz[O]));else n.call(null,_.subarray(D*w,D*w+w),...F)}let x=c.ValueType.BYTES_PER_ELEMENT,T=c.offset/x,M=c.stride/x,L=w,I=_;if(T!==0||M!==L){I=new c.ValueType(T+c.byteLength/x);for(let D=0;D{for(let u of Object.values(s.namedInputs))if(!u.value)throw new Error(`${u} does not have CPU value`);let c=new n.ValueType(n.length*n.size);for(let u=0;u[b,pf(w,u)]));for(let b=0;bvbt(u,n,r));switch(s.op){case"add":return c[0]+c[1];case"subtract":return c[0]-c[1];case"multiply":return c[0]*c[1];case"divide":return c[0]/c[1];case"pow":return Math.pow(c[0],c[1]);case"sqrt":return Math.sqrt(c[0]);case"abs":return Math.abs(c[0]);case"sin":return Math.sin(c[0]);case"cos":return Math.cos(c[0]);case"tan":return Math.tan(c[0]);case"exp":return Math.exp(c[0]);case"log":return Math.log(c[0]);default:{let u=s.op;throw new Error(`Unsupported arithmetic op ${u}`)}}}default:{let c=s;throw new Error(`Unsupported expression node ${c.kind}`)}}}function Bnn(s,n){let r=MB[s].arity;if(n!==r)throw new Error(`Arithmetic op '${s}' expects ${r} args, got ${n}`)}var _bt=({inputs:s,output:n,target:r})=>{let{sourceValues:c}=s;if(!c.value)throw new Error(`${c} does not have CPU value`);let d=new n.ValueType(n.length*n.size);if(c.length===0)return{success:!1,error:new Error(`${c} is empty`)};for(let b=0;bd[x]&&(d[x]=M)}}return r.write(d),{success:!0,value:d}};var ybt=({inputs:s,output:n,target:r})=>TB({func:(c,u)=>{let d=c.length/2,b=new Float64Array(u.buffer);for(let w=0;w{let{ids:c,sourceValues:u}=s,d=c.value,b=u.value;if(!d)throw new Error(`${c} does not have CPU value`);if(!b)throw new Error(`${u} does not have CPU value`);let w=new n.ValueType(n.length*n.size),_=new Array(n.size).fill(0);for(let x=0;x=0&&sTB({func:(c,...u)=>{let d=0;for(let b of u)c.set(b,d),d+=b.length},inputs:s,output:n,outputBuffer:r});var Sbt=({inputs:s,output:n,target:r})=>{let{x:c,y:u}=s,d=new n.ValueType(n.length);for(let b=0;b{let{x:c,y:u}=s,d=new n.ValueType(n.length);for(let b=0;b{let{x:c}=s,u=new n.ValueType(n.length);for(let d=0;d{let{segments:c,vertexCount:u}=s,d=c.value;if(!d)throw new Error(`${c} does not have CPU value`);Nnn(d,c,u);let b=new n.ValueType(n.length*n.size),w=0;for(let _=0;_0&&dr)throw new Error(`segmentedMap last segment start must be <= vertexCount, got ${c} > ${r}`)}function ORe(s,n){return s.offset/s.ValueType.BYTES_PER_ELEMENT+n*(s.stride/s.ValueType.BYTES_PER_ELEMENT)}var Abt=async({inputs:s,output:n,target:r})=>{let{condition:c,whenTrue:u,whenFalse:d}=s,b=new n.ValueType(n.length*n.size);for(let w=0;w{let c=new n.ValueType(n.length);for(let u=0;u{let{columns:c}=s;return TB({func:(u,d)=>{for(let b=0;b({...b,...w}));return this._modules[n]=d,d.then(b=>{this._modules[n]=b}).catch(b=>{Qt.error(`Failed to register ${n} backend: ${b}`)()}),d}if(c&&typeof c.then=="function"){let d=Promise.resolve(c).then(b=>({...b,...r})).then(b=>(this._modules[n]=b,b)).catch(b=>{throw Qt.error(`Failed to register ${n} backend: ${b}`)(),b});return this._modules[n]=d,d}let u={...c||{},...r};return this._modules[n]=u,Promise.resolve(u)}async get(n,r){let c=this._modules[n];if(!c)if(n==="webgl")c=this.add("webgl",Promise.resolve().then(()=>(owt(),swt)));else if(n==="webgpu")c=this.add("webgpu",Promise.resolve().then(()=>(ZRe(),Rwt)));else throw new Error(`${n} backend not registered`);let d=(await c)[r];if(typeof d!="function")throw new Error(`${n} backend does not implement ${r}`);return d}getSync(n,r){let c=this._modules[n];if(!c)throw new Error(`${n} backend not registered`);if(typeof c.then=="function")throw new Error(`${n} backend is not loaded yet`);let d=c[r];if(typeof d!="function")throw new Error(`${n} backend does not implement ${r}`);return d}clear(){this._modules={}}},RB=new KRe;var Bue=class{inputs;dependencies;constructor(n){this.inputs=n,this.dependencies=Array.from(n instanceof Array?n:Object.values(n)).filter(r=>r instanceof fc)}async execute(n,r){return await this._resolveDependencies(n),await this._executeWithHandler(await RB.get(this._getHandlerRegistry(n),this.name),r)}executeSync(n,r){this._resolveDependenciesSync(n);let c=this._executeWithHandler(RB.getSync(this._getHandlerRegistry(n),this.name),r);if(Ain(c))throw new Error(`${this.name} returned a Promise in executeSync()`);return c}shouldExecuteOnCPU(){return this.output.length<=1&&Array.from(this.dependencies).every(n=>!!n.value)}_getHandlerRegistry(n){return this.shouldExecuteOnCPU()?"cpu":n.type}async _resolveDependencies(n){for(let c of this.dependencies)await c.evaluate(n);if(this._getHandlerRegistry(n)==="cpu"||n.type==="null")for(let c of this.dependencies)await c.ensureCPUValue()}_resolveDependenciesSync(n){for(let c of this.dependencies)c.evaluateSync(n);if(this._getHandlerRegistry(n)==="cpu"||n.type==="null")for(let c of this.dependencies)c.ensureCPUValueSync()}_executeWithHandler(n,r){return n({device:r.device,inputs:this.inputs,output:this.output,target:r})}};function Ain(s){return typeof s?.then=="function"}function Iwt(...s){let n=Pin(s.map(r=>r.type));return n[0]!=="f"&&s.some(r=>r.normalized)&&(n="float32"),{isConstant:s.every(r=>r.isConstant),type:n,size:s.reduce((r,c)=>Math.max(r,c.size),0),length:s.reduce((r,c)=>Math.max(r,c.length),0)}}function Pin(s){let n=0,r=0;for(let c of s){if(c[0]==="f")return"float32";let u=c.endsWith("8")?8:c.endsWith("6")?16:32;c[0]==="u"?n=Math.max(n,u):r=Math.max(r,u)}return n&&!r?`uint${n}`:r&&n<32?`sint${Math.max(r,n*2)}`:"float32"}F3();var JRe=class extends Bue{name="interleave";output;constructor(n){super(n);let{isConstant:r,type:c,length:u}=Iwt(...n);this.output=new fc({isConstant:r,type:c,size:n.reduce((d,b)=>d+b.size,0),length:u,source:this})}toString(){return`_${this.inputs.join("_")}_`}};function QRe(...s){if(s.length===0)throw new Error("interleave() requires at least one input");return s.length===1?Mue(s[0]):new JRe(s.map(Mue)).output}Ql();F3();function tIe(s,n){let r=kin(n);for(let c of r)c.evaluateSync(s);return Lin(r),n}function Lin(s){let n=new Set(s.flatMap(Iin)),r=new Set;for(let c of s)Oue(c,r);for(let c of r)c.evaluated&&!n.has(c.buffer)&&c.destroy()}function kin(s){let n=new Set;return eIe(s,n,new Set),Array.from(n)}function eIe(s,n,r){if(Din(s)){n.add(s);return}if(!(!s||typeof s!="object"||r.has(s))){if(r.add(s),Array.isArray(s)){for(let c of s)eIe(c,n,r);return}if(Rin(s))for(let c of Object.values(s))eIe(c,n,r)}}function Rin(s){let n=Object.getPrototypeOf(s);return n===Object.prototype||n===null}function Oue(s,n){if(s instanceof NV){for(let c of s.gpuDataEvaluators)Oue(c,n);return}let r=s.source;if(r){if(r instanceof fc){n.has(r)||(n.add(r),Oue(r,n));return}for(let c of r.dependencies)n.has(c)||(n.add(c),Oue(c,n))}}function Iin(s){return s instanceof fc?[s.buffer]:s.gpuVector.data.map(n=>n.buffer instanceof up?n.buffer.buffer:n.buffer)}function Din(s){return s instanceof fc||s instanceof NV}ZRe();var UV=class{constructor(n,{id:r,isTransitionAttribute:c}){this.packedBuffers={},this.device=n,this.id=r,this.isTransitionAttribute=c,this.device.type==="webgpu"&&RB.add("webgpu",{interleave:Due})}hasGroups(n){return this.device.type==="webgpu"&&Object.values(n).some(r=>!!r.settings.bufferGroup)}finalize(){for(let n of Object.values(this.packedBuffers))n.packed.destroy();this.packedBuffers={}}getBufferLayouts(n,r){let c=this._getPackedGroups(n,r,{requireValues:!1,excludeAttributes:{}});return this._getBufferLayouts(n,c,r)}getBindings(n,r,c,u){let d=this._getPackedGroups(n,c,{requireValues:!0,excludeAttributes:u}),b={},w=new Set;for(let _ of d.values()){let x=!this.packedBuffers[_.id]||_.attributes.some(T=>!!r[T.id]);b[_.id]=this._getPackedBuffer(_,x);for(let T of _.attributes)w.add(T.id)}return{bufferLayouts:this._getBufferLayouts(n,d,c).filter(_=>!u[_.name]&&!n[_.name]?.settings.isIndexed),buffers:b,groupedAttributeIds:w}}_getPackedGroups(n,r,{requireValues:c,excludeAttributes:u}){let d=new Map;for(let w of Object.values(n)){let _=w.settings.bufferGroup;if(!_)continue;let x=d.get(_)||[];x.push(w),d.set(_,x)}let b=new Map;for(let[w,_]of d){let x=this._getPackedGroup(w,_,r,c,u);x&&b.set(w,x)}return b}_getPackedGroup(n,r,c,u,d){if(r.length<2)return null;let b=r.map(I=>I.getBufferLayout(c)),w=b[0].stepMode,_=Math.max(1,r[0].numInstances),x=u&&r.every(I=>I.isConstant);for(let I=0;Ithis._getInterleaveInput(n,u)),c=QRe(...r);return tIe(this.device,c),c}_getInterleaveInput(n,r){let c=Ib(r.getAccessor()),u=n.byteOffsets[r.id];if(FV(`${n.id}.${r.id} rowByteLength`,c),FV(`${n.id}.${r.id} groupByteOffset`,u),r.isConstant){let _=r.getConstantValue();if(!_)throw new Error(`Attribute group ${n.id} is missing constant value ${r.id}`);return FV(`${n.id}.${r.id} constant byteOffset`,_.byteOffset),new fc({id:r.id,type:"uint32",size:c/4,isConstant:!0,value:new Uint32Array(_.buffer,_.byteOffset,c/Uint32Array.BYTES_PER_ELEMENT)})}let d=r.getBuffer(),b=r.byteOffset,w=r.getAccessor().stride||c;if(FV(`${n.id}.${r.id} byteOffset`,b),FV(`${n.id}.${r.id} stride`,w),!d)throw new Error(`Attribute group ${n.id} cannot interleave missing buffer ${r.id}`);return new fc({id:r.id,type:"uint32",size:c/4,offset:b,stride:w,length:n.rowCount,buffer:d})}};function Dwt(s){return Math.ceil(s/4)*4}function FV(s,n){if(n%4!==0)throw new Error(`Attribute buffer groups require 32-bit alignment: ${s}=${n}`)}Ql();vm();function nIe(s){let{source:n,target:r,start:c=0,size:u,getData:d}=s,b=s.end||r.length,w=n.length,_=b-c;if(w>_){r.set(n.subarray(0,_),c);return}if(r.set(n,c),!d)return;let x=w;for(;x<_;){let T=d(x,n);for(let M=0;Mc(T+w,M)),x=Math.min(u.length,d.length);for(let T=1;Tw}){let w=r.isDoublePrecisionBuffer?2:1,_=r.size*w,x=r.byteOffset,T=r.settings.bytesPerElement<4?x/r.settings.bytesPerElement*4:x,M=r.startIndices,L=d&&M,I=r.isConstant;if(!L&&n&&c>=u)return n;let D=r.value instanceof Float64Array?Float32Array:r.value.constructor,F=I?r.value:new D(r.getBuffer().readSyncWebGL(x,u*D.BYTES_PER_ELEMENT).buffer);if(r.settings.normalized&&!I){let H=b;b=(te,oe)=>r.normalizeConstant(H(te,oe))}let O=I?(H,te)=>b(F,te):(H,te)=>b(F.subarray(H+x,H+x+_),te),z=n?new Float32Array(n.readSyncWebGL(T,c*4).buffer):new Float32Array(0),Z=new Float32Array(u);return Bwt({source:z,target:Z,sourceStartIndices:d,targetStartIndices:M,size:_,getData:O}),(!n||n.byteLength[Q]):[ue];for(let Q of Te){let ge=this.device.beginRenderPass({framebuffer:c,parameters:M,clearColor:w,clearDepth:_,clearStencil:x});try{for(let Qe of Q){let st=this._drawLayersInViewport(ge,{target:c,canvasContext:r,shaderModuleProps:L,viewport:Qe,view:ne,pass:z,layers:n.layers,isPicking:n.isPicking},oe);H.push(st)}}finally{ge.end(),Z&&this.device.submit()}w=!1,_=!1,x=!1}}return H}finally{Z||this.device.submit()}}_getDrawLayerParams(n,{layers:r,pass:c,isPicking:u=!1,layerFilter:d,cullRect:b,views:w,effects:_,canvasContext:x=this.device.canvasContext,shaderModuleProps:T},M=!1){let L=[],I=Tmt(this._lastRenderIndex+1),D={layer:r[0],viewport:n,isPicking:u,renderPass:c,cullRect:b},F={};for(let O=0;Ooe/255):D===!1&&(z=!1),F!==void 0&&(Z=F),O!==void 0&&(H=O),this.device.beginRenderPass({framebuffer:d,parameters:{viewport:M,scissorRect:M},clearColor:z,clearDepth:Z,clearStencil:H}).end()}}let L={totalCount:r.length,visibleCount:0,compositeCount:0,pickableCount:0};n.setParameters({viewport:M});for(let I=0;I{let b=u.props._offset,w=u.id,_=u.parent&&u.parent.id,x;if(_&&!(_ in n)&&c(u.parent,!1),_ in r){let T=r[_]=r[_]||Tmt(n[_],n);x=T(u,d),r[w]=T}else Number.isFinite(b)?(x=b+(n[_]||0),r[w]=null):x=s;return d&&x>=s&&(s=x+1),n[w]=x,x};return c}function XQt(s,{canvasContext:n=s.canvasContext,shaderModuleProps:r,target:c,viewport:u}){let d=r?.project?.devicePixelRatio??n.cssToDeviceRatio(),[,b]=n.getDrawingBufferSize(),w=c?c.height:b,_=u;return[_.x*d,w-(_.y+_.height)*d,_.width*d,_.height*d]}function Mmt(s,...n){for(let r of n)if(r)for(let c in r)s[c]?Object.assign(s[c],r[c]):s[c]=r[c];return s}var tV=class extends k3{constructor(n,r){super(n,r);let c=n.createTexture({format:"rgba8unorm",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),u=n.createTexture({format:"depth16unorm",width:1,height:1});this.fbo=n.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[c],depthStencilAttachment:u})}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null)}getShadowMap(){return this.fbo.colorAttachments[0].texture}render(n){let r=this.fbo,c=this.device.canvasContext.cssToDeviceRatio(),u=n.viewports[0],d=u.width*c,b=u.height*c,w=[1,1,1,1];(d!==r.width||b!==r.height)&&r.resize({width:d,height:b}),super.render({...n,clearColor:w,target:r,pass:"shadow"})}getLayerParameters(n,r,c){return{...n.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal"}}shouldDrawLayer(n){return n.props.shadowEnabled!==!1}getShaderModuleProps(n,r,c){return{shadow:{project:c.project,drawToShadowMap:!0}}}};var YQt={color:[255,255,255],intensity:1},Cmt=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],ZQt=[0,0,0,200/255],aB=class{constructor(n={}){this.id="lighting-effect",this.shadowColor=ZQt,this.shadow=!1,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.dummyShadowMap=null,this.setProps(n)}setup(n){this.context=n;let{device:r,deck:c}=n;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(r),c._addDefaultShaderModule(wle),this.dummyShadowMap=r.createTexture({width:1,height:1}))}setProps(n){this.ambientLight=void 0,this.directionalLights=[],this.pointLights=[];for(let r in n){let c=n[r];switch(c.type){case"ambient":this.ambientLight=c;break;case"directional":this.directionalLights.push(c);break;case"point":this.pointLights.push(c);break;default:}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(r=>r.shadow),this.context&&this.setup(this.context),this.props=n}preRender({layers:n,layerFilter:r,viewports:c,onViewportActive:u,views:d}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let b=0;bb.getShadowMap()),dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{},u={enabled:!0,lights:this._getLights(n)},d=n.props.material;return{shadow:c,lighting:u,phongMaterial:d,gouraudMaterial:d}}cleanup(n){for(let r of this.shadowPasses)r.delete();this.shadowPasses.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,n.deck._removeDefaultShaderModule(wle))}_calculateMatrices(){let n=[];for(let r of this.directionalLights){let c=new Of().lookAt({eye:new lp(r.direction).negate()});n.push(c)}return n}_createShadowPasses(n){for(let r=0;ru&&(d=u);let b=this._pool,w=n.BYTES_PER_ELEMENT*d,_=b.findIndex(x=>x.byteLength>=w);if(_>=0){let x=new n(b.splice(_,1)[0],0,d);return c&&x.fill(0),x}return new n(d)}_release(n){if(!ArrayBuffer.isView(n))return;let r=this._pool,{buffer:c}=n,{byteLength:u}=c,d=r.findIndex(b=>b.byteLength>=u);d<0?r.push(c):(d>0||r.lengththis.opts.poolSize&&r.shift()}},pv=new Lke;Nf();function lB(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function kke(s,n){let r=s%n;return r<0?n+r:r}function Pmt(s){return[s[12],s[13],s[14]]}function Lmt(s){return{left:cB(s[3]+s[0],s[7]+s[4],s[11]+s[8],s[15]+s[12]),right:cB(s[3]-s[0],s[7]-s[4],s[11]-s[8],s[15]-s[12]),bottom:cB(s[3]+s[1],s[7]+s[5],s[11]+s[9],s[15]+s[13]),top:cB(s[3]-s[1],s[7]-s[5],s[11]-s[9],s[15]-s[13]),near:cB(s[3]+s[2],s[7]+s[6],s[11]+s[10],s[15]+s[14]),far:cB(s[3]-s[2],s[7]-s[6],s[11]-s[10],s[15]-s[14])}}var Amt=new lp;function cB(s,n,r,c){Amt.set(s,n,r);let u=Amt.len();return{distance:c/u,normal:new lp(-s/u,-n/u,-r/u)}}function KQt(s){return s-Math.fround(s)}var nV;function uB(s,n){let{size:r=1,startIndex:c=0}=n,u=n.endIndex!==void 0?n.endIndex:s.length,d=(u-c)/r;nV=pv.allocate(nV,d,{type:Float32Array,size:r*2});let b=c,w=0;for(;bne.useInPicking),pass:I,canvasContext:F,isPicking:!0,shaderModuleProps:O,clearColor:z??[0,0,0,0],colorMask:15,scissorRect:H});return this._colorEncoderState=null,{decodePickingColor:Z&&Uen.bind(null,Z),stats:te}}shouldDrawLayer(n){let{pickable:r,operation:c}=n.props;return r&&c.includes("draw")||c.includes("terrain")||c.includes("mask")}getShaderModuleProps(n,r,c){return{picking:{isActive:1,isAttribute:this.pickZ,disabledPickingIndices:n.internalState?.disabledPickingIndices},lighting:{enabled:!1}}}getLayerParameters(n,r,c){let u={...n.props.parameters},{pickable:d,operation:b}=n.props;return this._colorEncoderState?d&&b.includes("draw")?(Object.assign(u,Fen),u.blend=!0,this.device.type==="webgpu"?u.blendConstant=d1t(this._colorEncoderState,n,c):u.blendColor=d1t(this._colorEncoderState,n,c),b.includes("terrain")&&n.state?._hasPickingCover&&(u.blendAlphaSrcFactor="one")):b.includes("terrain")&&(u.blend=!1):u.blend=!1,u}_resetColorEncoder(n){return this._colorEncoderState=n?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}};function d1t(s,n,r){let{byLayer:c,byAlpha:u}=s,d,b=c.get(n);return b?(b.viewports.push(r),d=b.a):(d=c.size+1,d<=255?(b={a:d,layer:n,viewports:[r]},c.set(n,b),u[d]=b):(Bs.warn("Too many pickable layers, only picking the first 255")(),d=0)),[0,0,0,d/255]}function Uen(s,n){let r=s.byAlpha[n[3]];return r&&{pickedLayer:r.layer,pickedViewports:r.viewports,pickedObjectIndex:r.layer.decodePickingColor(n)}}Ql();var XM={NO_STATE:"Awaiting state",MATCHED:"Matched. State transferred from previous layer",INITIALIZED:"Initialized",AWAITING_GC:"Discarded. Awaiting garbage collection",AWAITING_FINALIZATION:"No longer matched. Awaiting garbage collection",FINALIZED:"Finalized! Awaiting garbage collection"},bB=Symbol.for("component"),t2=Symbol.for("propTypes"),Cle=Symbol.for("deprecatedProps"),I3=Symbol.for("asyncPropDefaults"),n2=Symbol.for("asyncPropOriginal"),gv=Symbol.for("asyncPropResolved");function Ale(s,n=()=>!0){return Array.isArray(s)?p1t(s,n,[]):n(s)?[s]:[]}function p1t(s,n,r){let c=-1;for(;++c0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(n,r){if(n===this._data&&!r)return;this._data=n;let c=++this._loadCount,u=n;typeof n=="string"&&(u=BD(n)),u instanceof Promise?(this.isLoaded=!1,this._loader=u.then(d=>{this._loadCount===c&&(this.isLoaded=!0,this._error=void 0,this._content=d)}).catch(d=>{this._loadCount===c&&(this.isLoaded=!0,this._error=d||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=n);for(let d of this._subscribers)d.onChange(this.getData())}};var cV=class{constructor(n){this.protocol=n.protocol||"resource://",this._context={device:n.device,gl:n.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(n){return n.startsWith(this.protocol)?!0:n in this._resources}add({resourceId:n,data:r,forceUpdate:c=!1,persistent:u=!0}){let d=this._resources[n];d?d.setData(r,c):(d=new aV(n,r,this._context),this._resources[n]=d),d.persistent=u}remove(n){let r=this._resources[n];r&&(r.delete(),delete this._resources[n])}unsubscribe({consumerId:n}){let r=this._consumers[n];if(r){for(let c in r){let u=r[c],d=this._resources[u.resourceId];d&&d.unsubscribe(u)}delete this._consumers[n],this.prune()}}subscribe({resourceId:n,onChange:r,consumerId:c,requestId:u="default"}){let{_resources:d,protocol:b}=this;n.startsWith(b)&&(n=n.replace(b,""),d[n]||this.add({resourceId:n,data:null,persistent:!1}));let w=d[n];if(this._track(c,u,w,r),w)return w.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(let n in this._resources)this._resources[n].delete()}_track(n,r,c,u){let d=this._consumers,b=d[n]=d[n]||{},w=b[r],_=w&&w.resourceId&&this._resources[w.resourceId];_&&(_.unsubscribe(w),this.prune()),c&&(w?(w.onChange=u,w.resourceId=c.id):w={onChange:u,resourceId:c.id},b[r]=w,c.subscribe(w))}_prune(){this._pruneRequest=null;for(let n of Object.keys(this._resources)){let r=this._resources[n];!r.persistent&&!r.inUse()&&(r.delete(),delete this._resources[n])}}};var zen="layerManager.setLayers",Gen="layerManager.activateViewport",lV=class{constructor(n,r){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=w=>{Bf(Gen,this,w),w&&(this.context.viewport=w)};let{deck:c,stats:u,viewport:d,timeline:b}=r||{};this.layers=[],this.resourceManager=new cV({device:n,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:n,gl:n?.gl,deck:c,shaderAssembler:Smt(n?.info?.shadingLanguage||"glsl"),defaultShaderModules:[fke],renderPass:void 0,stats:u||new xb({id:"deck.gl"}),viewport:d||new fB({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:b||new x4,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(let n of this.layers)this._finalizeLayer(n)}needsRedraw(n={clearRedrawFlags:!1}){let r=this._needsRedraw;n.clearRedrawFlags&&(this._needsRedraw=!1);for(let c of this.layers){let u=c.getNeedsRedraw(n);r=r||u}return r}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(n){this._needsRedraw=this._needsRedraw||n}setNeedsUpdate(n){this._needsUpdate=this._needsUpdate||n}getLayers({layerIds:n}={}){return n?this.layers.filter(r=>n.find(c=>r.id.indexOf(c)===0)):this.layers}setProps(n){"debug"in n&&(this._debug=n.debug),"userData"in n&&(this.context.userData=n.userData),"layers"in n&&(this._nextLayers=n.layers),"onError"in n&&(this.context.onError=n.onError)}setLayers(n,r){Bf(zen,this,r,n),this._lastRenderedLayers=n;let c=Ale(n,Boolean);for(let u of c)u.context=this.context;this._updateLayers(this.layers,c)}updateLayers(){let n=this.needsUpdate();n&&(this.setNeedsRedraw(`updating layers: ${n}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,n)),this._nextLayers=null}addDefaultShaderModule(n){let{defaultShaderModules:r}=this.context;r.find(c=>c.name===n.name)||(r.push(n),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(n){let{defaultShaderModules:r}=this.context,c=r.findIndex(u=>u.name===n.name);c>=0&&(r.splice(c,1),this._defaultShaderModulesChanged=!0)}_handleError(n,r,c){c.raiseError(r,`${n} of ${c}`)}_updateLayers(n,r){let c={};for(let b of n)c[b.id]?Bs.warn(`Multiple old layers with same id ${b.id}`)():c[b.id]=b;if(this._defaultShaderModulesChanged){for(let b of n)b.setNeedsUpdate(),b.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}let u=[];this._updateSublayersRecursively(r,c,u),this._finalizeOldLayers(c);let d=!1;for(let b of u)if(b.hasUniformTransition()){d=`Uniform transition in ${b}`;break}this._needsUpdate=d,this.layers=u}_updateSublayersRecursively(n,r,c){for(let u of n){u.context=this.context;let d=r[u.id];d===null&&Bs.warn(`Multiple new layers with same id ${u.id}`)(),r[u.id]=null;let b=null;try{this._debug&&d!==u&&u.validateProps(),d?(this._transferLayerState(d,u),this._updateLayer(u)):this._initializeLayer(u),c.push(u),b=u.isComposite?u.getSubLayers():null}catch(w){this._handleError("matching",w,u)}b&&this._updateSublayersRecursively(b,r,c)}}_finalizeOldLayers(n){for(let r in n){let c=n[r];c&&this._finalizeLayer(c)}}_initializeLayer(n){try{n._initialize(),n.lifecycle=XM.INITIALIZED}catch(r){this._handleError("initialization",r,n)}}_transferLayerState(n,r){r._transferState(n),r.lifecycle=XM.MATCHED,r!==n&&(n.lifecycle=XM.AWAITING_GC)}_updateLayer(n){try{n._update()}catch(r){this._handleError("update",r,n)}}_finalizeLayer(n){this._needsRedraw=this._needsRedraw||`finalized ${n}`,n.lifecycle=XM.AWAITING_FINALIZATION;try{n._finalize(),n.lifecycle=XM.FINALIZED}catch(r){this._handleError("finalization",r,n)}}};function Ac(s,n,r){if(s===n)return!0;if(!r||!s||!n)return!1;if(Array.isArray(s)){if(!Array.isArray(n)||s.length!==n.length)return!1;for(let c=0;c{let c=!n.canvasId||this.getCanvasId(r.id)===n.canvasId,u=!("x"in n)||r.containsPixel(n);return c&&u}):this._viewports}getViews(){let n={};return this.views.forEach(r=>{n[r.id]=r}),n}getView(n){return this.views.find(r=>r.id===n)}getViewState(n){let r=typeof n=="string"?this.getView(n):n,c=r&&this.viewState[r.getViewStateId()]||this.viewState;return r?r.filterViewState(c):c}getViewport(n){return this._viewportMap[n]}getCanvasId(n){let r=typeof n=="string"?this.getView(n):n;return r?this._viewEventManagers[r.id]?.canvasId||this._getCanvasIdFromView(r):void 0}unproject(n,r){let c=this.getViewports(),u={x:n[0],y:n[1]};for(let d=c.length-1;d>=0;--d){let b=c[d];if(b.containsPixel(u)){let w=n.slice();return w[0]-=b.x,w[1]-=b.y,b.unproject(w,r)}}return null}setProps(n){n.views&&this._setViews(n.views),n.viewState&&this._setViewState(n.viewState),("width"in n||"height"in n)&&this._setSize(n.width,n.height),"pickPosition"in n&&(this._pickPosition=n.pickPosition),"eventManagers"in n&&this._setEventManagers(n.eventManagers||{}),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(n,r){(n!==this.width||r!==this.height)&&(this.width=n,this.height=r,this.setNeedsUpdate("Size changed"))}_setViews(n){n=Ale(n,Boolean),this._diffViews(n,this.views)&&this.setNeedsUpdate("views changed"),this.views=n}_setViewState(n){n?(!Ac(n,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=n):Bs.warn("missing `viewState` or `initialViewState`")()}_setEventManagers(n){this._eventManagers!==n&&(this._eventManagers=n,this.setNeedsUpdate("eventManagers changed"))}_getCanvasIdFromView(n){return n.props.canvasId||this._getCanvasContext?.(n.id)?.id||YM}_getCanvasDimensions(n){let r=this._getCanvasContext?.(n.id),[c,u]=r?.getCSSSize()||[this.width,this.height];return{width:c,height:u}}_getViewEventManager(n){let r=this.getCanvasId(n)||YM;return{canvasId:r,eventManager:this._eventManagers[r]||this._eventManager}}_startViewportRebuild(){let n=this.controllers,r=this._viewEventManagers;return this._viewports=[],this.controllers={},this._viewEventManagers={},{oldControllers:n,oldViewEventManagers:r}}_getReusableController(n,r,c){return n&&(r?.canvasId!==c.canvasId||r?.eventManager!==c.eventManager)?(n.finalize(),null):n}_createController(n,r){let c=r.type;return new c({timeline:this.timeline,eventManager:this._getViewEventManager(n).eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:d=>this.getView(n.id)?.makeViewport({viewState:d,...this._getCanvasDimensions(n)}),pickPosition:(d,b)=>this._pickPosition?.(d,b,n.id)})}_updateController(n,r,c,u){let d=n.controller;if(d&&c){let b={...r,...d,id:n.id,x:c.x,y:c.y,width:c.width,height:c.height};return(!u||u.constructor!==d.type)&&(u=this._createController(n,b)),u&&u.setProps(b),u}return null}_rebuildViewports(){let{views:n}=this,{oldControllers:r,oldViewEventManagers:c}=this._startViewportRebuild(),u=!1;for(let d=n.length;d--;){let b=n[d],{width:w,height:_}=this._getCanvasDimensions(b),x=this._getViewEventManager(b);this._viewEventManagers[b.id]=x;let T=this.getViewState(b),M=b.makeViewport({viewState:T,width:w,height:_}),L=this._getReusableController(r[b.id],c[b.id],x),I=!!b.controller;I&&!L&&(u=!0),(u||!I)&&L&&(L.finalize(),L=null),this.controllers[b.id]=this._updateController(b,T,M,L),M&&this._viewports.unshift(M)}for(let d in r){let b=r[d];b&&!this.controllers[d]&&b.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(n=>{n.id&&(this._viewportMap[n.id]=this._viewportMap[n.id]||n)})}_diffViews(n,r){return n.length!==r.length?!0:n.some((c,u)=>!n[u].equals(r[u]))}};var jen=/^(?:\d+\.?\d*|\.\d+)$/;function _m(s){switch(typeof s){case"number":if(!Number.isFinite(s))throw new Error(`Could not parse position string ${s}`);return{type:"literal",value:s};case"string":try{let n=$en(s);return new Hke(n).parseExpression()}catch(n){let r=n instanceof Error?n.message:String(n);throw new Error(`Could not parse position string ${s}: ${r}`)}default:throw new Error(`Could not parse position string ${s}`)}}function Wke(s,n){switch(s.type){case"literal":return s.value;case"percentage":return Math.round(s.value*n);case"binary":let r=Wke(s.left,n),c=Wke(s.right,n);return s.operator==="+"?r+c:r-c;default:throw new Error("Unknown layout expression type")}}function ym(s,n){return Wke(s,n)}function $en(s){let n=[],r=0;for(;r="0"&&s<="9"}function b1t(s){return s>="a"&&s<="z"||s>="A"&&s<="Z"}function Ven(s){return!!(s&&s.type==="symbol"&&(s.value==="+"||s.value==="-"))}function w1t(s,n){let r={...s};for(let c in n)c!=="id"&&(Array.isArray(r[c])&&Array.isArray(n[c])?r[c]=Wen(r[c],n[c]):r[c]=n[c]);return r}function Wen(s,n){s=s.slice();for(let r=0;r{},_1t={mode:"preserve"},Hen={mode:"hard"},qke={BREAK:1,SNAP_TO_END:2,IGNORE:3},qen=s=>s,Xen=qke.BREAK,fV=class{constructor(n){this._onTransitionUpdate=r=>{let{time:c,settings:{interpolator:u,startProps:d,endProps:b,duration:w,easing:_}}=r,x=_(c/w),T=u.interpolateProps(d,b,x);this.propsInTransition=this.getControllerState({...this.props,...T},_1t).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=n.getControllerState,this.propsInTransition=null,this.transition=new mv(n.timeline),this.onViewStateChange=n.onViewStateChange||v1t,this.onStateChange=n.onStateChange||v1t}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(n){let r=!1,c=this.props;if(this.props=n,!c||this._shouldIgnoreViewportChange(c,n))return!1;if(this._isTransitionEnabled(n)){let u=c;if(this.transition.inProgress){let{interruption:d,endProps:b}=this.transition.settings;u={...c,...d===qke.SNAP_TO_END?b:this.propsInTransition||c}}this._triggerTransition(u,n),r=!0}else this.transition.cancel();return r}updateTransition(){this.transition.update()}_isTransitionEnabled(n){let{transitionDuration:r,transitionInterpolator:c}=n;return(r>0||r==="auto")&&!!c}_isUpdateDueToCurrentTransition(n){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(n,this.propsInTransition):!1}_shouldIgnoreViewportChange(n,r){return this.transition.inProgress?this.transition.settings.interruption===qke.IGNORE||this._isUpdateDueToCurrentTransition(r):this._isTransitionEnabled(r)?r.transitionInterpolator.arePropsEqual(n,r):!0}_triggerTransition(n,r){let c=this.getControllerState(n,_1t),u=this.getControllerState(r,Hen).shortestPathFrom(c),d=r.transitionInterpolator,b=d.getDuration?d.getDuration(n,r):r.transitionDuration;if(b===0)return;let w=d.initializeProps(n,u);this.propsInTransition={};let _={duration:b,easing:r.transitionEasing||qen,interpolator:d,interruption:r.transitionInterruption||Xen,startProps:w.start,endProps:w.end,onStart:r.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(r.onTransitionInterrupt),onEnd:this._onTransitionEnd(r.onTransitionEnd)};this.transition.start(_),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(n){return r=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),n?.(r)}}};Nf();function La(s,n){if(!s)throw new Error(n||"deck.gl: assertion failed.")}var hV=class{constructor(n){let{compare:r,extract:c,required:u}=n;this._propsToCompare=r,this._propsToExtract=c||r,this._requiredProps=u}arePropsEqual(n,r){for(let c of this._propsToCompare)if(!(c in n)||!(c in r)||!Wy(n[c],r[c]))return!1;return!0}initializeProps(n,r){let c={},u={};for(let d of this._propsToExtract)(d in n||d in r)&&(c[d]=n[d],u[d]=r[d]);return this._checkRequiredProps(c),this._checkRequiredProps(u),{start:c,end:u}}getDuration(n,r){return r.transitionDuration}_checkRequiredProps(n){this._requiredProps&&this._requiredProps.forEach(r=>{let c=n[r];La(Number.isFinite(c)||Array.isArray(c),`${r} is required for transition`)})}};Nf();var Yen=["longitude","latitude","zoom","bearing","pitch"],Zen=["longitude","latitude","zoom"],D3=class extends hV{constructor(n={}){let r=Array.isArray(n)?n:n.transitionProps,c=Array.isArray(n)?{}:n;c.transitionProps=Array.isArray(r)?{compare:r,required:r}:r||{compare:Yen,required:Zen},super(c.transitionProps),this.opts=c}initializeProps(n,r){let c=super.initializeProps(n,r),{makeViewport:u,around:d}=this.opts;if(u&&d){let b=u(n),w=u(r),_=b.unproject(d);c.start.around=d,Object.assign(c.end,{around:w.project(_),aroundPosition:_,width:r.width,height:r.height})}return c}interpolateProps(n,r,c){let u={};for(let d of this._propsToExtract)u[d]=lv(n[d]||0,r[d]||0,c);if(r.aroundPosition&&this.opts.makeViewport){let d=this.opts.makeViewport({...r,...u});Object.assign(u,d.panByPosition(r.aroundPosition,lv(n.around,r.around,c)))}return u}};var i2={transitionDuration:0},Ken=300,Jen=300,Xke=s=>1-(1-s)*(1-s),Qen=s=>s===1?1:1-Math.pow(2,-10*s),M4={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],MULTI_PAN:["multipanstart","multipanmove","multipanend"],DOUBLE_CLICK:["dblclick"],DOUBLE_CLICK_DRAG:["dblclickdragstart","dblclickdragmove","dblclickdragend","dblclickdragcancel"],KEYBOARD:["keydown"]},T4={},C4=class{constructor(n){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this._multiPanMode=null,this._multiPanStartCenter=null,this._doubleClickDragAnchor=null,this._suppressDoubleClickUntil=0,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.doubleClickDragZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.multiTouchDrag=null,this.trackpadGesture=!1,this.zoomAround="pointer",this.keyboard=!0,this.transitionManager=new fV({...n,getControllerState:(r,c)=>new this.ControllerState({...r,constraintContext:c,makeViewport:n.makeViewport}),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=n.eventManager,this.onViewStateChange=n.onViewStateChange||(()=>{}),this.onStateChange=n.onStateChange||(()=>{}),this.makeViewport=n.makeViewport,this.pickPosition=n.pickPosition}set events(n){this.toggleEvents(this._customEvents,!1),this.toggleEvents(n,!0),this._customEvents=n,this.props&&this.setProps(this.props)}finalize(){for(let n in this._events)this._events[n]&&this.eventManager?.off(n,this.handleEvent);this.transitionManager.finalize()}handleEvent(n){this._controllerState=void 0;let r=this._eventStartBlocked;switch(n.type){case"panstart":return r?!1:this._onPanStart(n);case"panmove":return this._onPan(n);case"panend":return this._onPanEnd(n);case"pinchstart":return r||!this._isTrackpadGestureAllowed(n)?!1:this._onPinchStart(n);case"pinchmove":return this._isTrackpadGestureAllowed(n)?this._onPinch(n):!1;case"pinchend":return this._isTrackpadGestureAllowed(n)?this._onPinchEnd(n):!1;case"multipanstart":return r?!1:this._onMultiPanStart(n);case"multipanmove":return this._onMultiPan(n);case"multipanend":return this._onMultiPanEnd(n);case"dblclick":return this._onDoubleClick(n);case"dblclickdragstart":return r?!1:this._onDoubleClickDragStart(n);case"dblclickdragmove":return this._onDoubleClickDrag(n);case"dblclickdragend":case"dblclickdragcancel":return this._onDoubleClickDragEnd(n);case"wheel":return this._onWheel(n);case"keydown":return this._onKeyDown(n);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(n){let{x:r,y:c}=this.props,{offsetCenter:u}=n;return[u.x-r,u.y-c]}getZoomPosition(n){if(this.zoomAround==="pointer")return n;let r=this.makeViewport(this.controllerState.getViewportProps()),[c,u]=qM(r.center,r.pixelProjectionMatrix);return[c,u]}isPointInBounds(n,r){let{width:c,height:u}=this.props;if(r&&r.handled)return!1;let d=n[0]>=0&&n[0]<=c&&n[1]>=0&&n[1]<=u;return d&&r&&r.stopPropagation(),d}isFunctionKeyPressed(n){let{srcEvent:r}=n;return!!(r.metaKey||r.altKey||r.ctrlKey||r.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(n){let r=setTimeout(()=>{this._eventStartBlocked===r&&(this._eventStartBlocked=null)},n);this._eventStartBlocked=r}setProps(n){n.maxBoundsPadding===void 0&&(n.maxBoundsPadding=null),n.dragMode&&(this.dragMode=n.dragMode);let r=this.props;this.props=n,"transitionInterpolator"in n||(n.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(n);let{inertia:c}=n;this.inertia=Number.isFinite(c)?c:c===!0?Ken:0;let{scrollZoom:u=!0,dragPan:d=!0,dragRotate:b=!0,doubleClickZoom:w=!0,doubleClickDragZoom:_=!1,touchZoom:x=!0,touchRotate:T=!1,multiTouchDrag:M=T?"rotate":null,trackpadGesture:L=!1,zoomAround:I="pointer",keyboard:D=!0}=n,F=!!this.onViewStateChange;if(this.toggleEvents(M4.WHEEL,F&&u),this.toggleEvents(M4.PAN,F),this.toggleEvents(M4.PINCH,F&&(x||M==="rotate")),this.toggleEvents(M4.MULTI_PAN,F&&!!M),this.toggleEvents(M4.DOUBLE_CLICK,F&&w),this.toggleEvents(M4.DOUBLE_CLICK_DRAG,F&&_),this.toggleEvents(M4.KEYBOARD,F&&D),this.scrollZoom=u,this.dragPan=d,this.dragRotate=b,this.doubleClickZoom=w,this.doubleClickDragZoom=_,this.touchZoom=x,this.touchRotate=M==="rotate",this.multiTouchDrag=M,this.trackpadGesture=L,this.zoomAround=I,this.keyboard=D,(!r||r.height!==n.height||r.width!==n.width||r.maxBounds!==n.maxBounds||r.maxBoundsPadding!==n.maxBoundsPadding)&&n.maxBounds){let z=new this.ControllerState({...n,makeViewport:this.makeViewport}),Z=z.getViewportProps();Object.keys(Z).some(te=>!Ac(Z[te],n[te],1))&&this.updateViewport(z)}}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(n,r){this.eventManager&&n.forEach(c=>{this._events[c]!==r&&(this._events[c]=r,r?this.eventManager.on(c,this.handleEvent):this.eventManager.off(c,this.handleEvent))})}updateViewport(n,r=null,c={}){let u={...n.getViewportProps(),...r},d=this.controllerState!==n;if(this.state=n.getState(),this._setInteractionState(c),d){let b=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:u,interactionState:this._interactionState,oldViewState:b,viewId:this.props.id})}}_onTransition(n){this.onViewStateChange({...n,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(n){Object.assign(this._interactionState,n),this.onStateChange(this._interactionState)}_getConstraintContext(n,r){return this.props.rubberBand?{mode:r==="update"?"elastic":r==="end"?"rebound":"hard"}:{mode:"hard"}}_getReboundTransition(n,r){if(n.mode!=="rebound")return null;let c=r.getViewportProps();return Object.keys(c).some(d=>!Ac(this.props[d],c[d],1))?{...this._getTransitionProps(),transitionDuration:Jen,transitionEasing:Qen}:null}_onPanStart(n){let r=this.getCenter(n);if(!this.isPointInBounds(r,n))return!1;let c=this.isFunctionKeyPressed(n)||n.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(c=!c);let u=c?"pan":"rotate",d=this._getConstraintContext(u,"start"),b=c?this.controllerState.panStart({pos:r},d):this.controllerState.rotateStart({pos:r},d);return this._panMove=c,this.updateViewport(b,i2,{isDragging:!0}),!0}_onPan(n){return this.isDragging()?this._panMove?this._onPanMove(n):this._onPanRotate(n):!1}_onPanEnd(n){return this.isDragging()?this._panMove?this._onPanMoveEnd(n):this._onPanRotateEnd(n):!1}_onPanMove(n){if(!this.dragPan)return!1;let r=this.getCenter(n),c=this.controllerState.pan({pos:r},this._getConstraintContext("pan","update"));return this.updateViewport(c,i2,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(n){let{inertia:r}=this;if(this.dragPan&&r&&n.velocity){let c=this.getCenter(n),u=[c[0]+n.velocityX*r/2,c[1]+n.velocityY*r/2],d=this.controllerState.pan({pos:u}).panEnd();this.updateViewport(d,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Xke},{isDragging:!1,isPanning:!0})}else{let c=this.controllerState,u=this._getConstraintContext("pan","end"),d=c.panEnd(u),b=this._getReboundTransition(u,d);this.updateViewport(d,b,{isDragging:!1,isPanning:!!b})}return!0}_onPanRotate(n){if(!this.dragRotate)return!1;let r=this.getCenter(n),c=this.controllerState.rotate({pos:r},this._getConstraintContext("rotate","update"));return this.updateViewport(c,i2,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(n){let{inertia:r}=this;if(this.dragRotate&&r&&n.velocity){let c=this.getCenter(n),u=[c[0]+n.velocityX*r/2,c[1]+n.velocityY*r/2],d=this.controllerState.rotate({pos:u}).rotateEnd();this.updateViewport(d,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Xke},{isDragging:!1,isRotating:!0})}else{let c=this.controllerState,u=this._getConstraintContext("rotate","end"),d=c.rotateEnd(u),b=this._getReboundTransition(u,d);this.updateViewport(d,b,{isDragging:!1,isRotating:!!b})}return!0}_onWheel(n){if(!this.scrollZoom||this.trackpadGesture&&n.device!=="mouse")return!1;let r=this.getCenter(n);if(!this.isPointInBounds(r,n))return!1;n.srcEvent.preventDefault();let{speed:c=.01,smooth:u=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:d}=n,b=2/(1+Math.exp(-Math.abs(d*c)));d<0&&b!==0&&(b=1/b);let w=this.getZoomPosition(r),_=u?{...this._getTransitionProps({around:w}),transitionDuration:250}:i2,x=this.controllerState.zoom({pos:w,scale:b});return this.updateViewport(x,_,{isZooming:!0,isPanning:!0}),u||this._setInteractionState({isZooming:!1,isPanning:!1}),!0}_onMultiPanStart(n){let{multiTouchDrag:r}=this;if(!r||!this._isMultiPanEventAllowed(n,r))return!1;let c=n.offsetCenter;if(!this.isPointInBounds(this.getCenter(n),n))return!1;let u=n.pointerType==="trackpad",d={x:c.x-(u?0:n.deltaX),y:c.y-(u?0:n.deltaY)},b={...n,offsetCenter:d},w=this.getCenter(b),_=r==="pan"?this.controllerState.panStart({pos:w},this._getConstraintContext("pan","start")):this.controllerState.rotateStart({pos:w},this._getConstraintContext("rotate","start"));return this._multiPanMode=r,this._multiPanStartCenter=d,this.updateViewport(_,i2,{isDragging:!0}),!0}_onMultiPan(n){let{mode:r,event:c}=this._getMultiPanEvent(n);return!r||!c||!this.isDragging()?!1:r==="pan"?this._onPanMove(c):this._onPanRotate(c)}_onMultiPanEnd(n){let{mode:r,event:c}=this._getMultiPanEvent(n);if(!r||!c||!this.isDragging())return this._resetMultiPan(),!1;let u=r==="pan"?this._onPanMoveEnd(c):this._onPanRotateEnd(c);return this._resetMultiPan(),u}_isTrackpadGestureAllowed(n){return n.pointerType!=="trackpad"||this.trackpadGesture}_isMultiPanEventAllowed(n,r){return n.pointerType==="trackpad"?this.trackpadGesture&&(r==="pan"?this.dragPan:this.dragRotate):n.pointerType==="touch"&&(r==="pan"?this.dragPan:this.dragRotate)}_getMultiPanEvent(n){let r=this._multiPanMode,c=this._multiPanStartCenter;return!r||!c?{mode:null,event:null}:{mode:r,event:{...n,offsetCenter:{x:c.x+n.deltaX,y:c.y+n.deltaY}}}}_resetMultiPan(){this._multiPanMode=null,this._multiPanStartCenter=null}_onPinchStart(n){this._doubleClickDragAnchor=null;let r=this.getCenter(n);if(!this.isPointInBounds(r,n))return!1;let c=this.controllerState.zoomStart({pos:this.getZoomPosition(r)},this._getConstraintContext("zoom","start")).rotateStart({pos:r},this._getConstraintContext("rotate","start"));return T4._startPinchRotation=n.rotation,T4._lastPinchEvent=n,this.updateViewport(c,i2,{isDragging:!0}),!0}_onPinch(n){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let r=this.controllerState;if(this.touchZoom){let{scale:c}=n,u=this.getCenter(n);r=r.zoom({pos:this.getZoomPosition(u),scale:c},this._getConstraintContext("zoom","update"))}if(this.touchRotate){let{rotation:c}=n;r=r.rotate({deltaAngleX:T4._startPinchRotation-c},this._getConstraintContext("rotate","update"))}return this.updateViewport(r,i2,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),T4._lastPinchEvent=n,!0}_onPinchEnd(n){if(!this.isDragging())return!1;let{inertia:r}=this,{_lastPinchEvent:c}=T4;if(this.touchZoom&&r&&c&&n.scale!==c.scale){let u=this.getCenter(n),d=this.getZoomPosition(u),b=this.controllerState.rotateEnd(),w=Math.log2(n.scale),_=(w-Math.log2(c.scale))/(n.deltaTime-c.deltaTime),x=Math.pow(2,w+_*r/2);b=b.zoom({pos:d,scale:x}).zoomEnd(),this.updateViewport(b,{...this._getTransitionProps({around:d}),transitionDuration:r,transitionEasing:Xke},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(r)}else{let u=this.controllerState,d=this._getConstraintContext("zoom","end"),b=this._getConstraintContext("rotate","end"),w=u.zoomEnd(d).rotateEnd(b),_=this._getReboundTransition(this.touchZoom?d:b,w);this.updateViewport(w,_,{isDragging:!1,isPanning:!!_&&this.touchZoom,isZooming:!!_&&this.touchZoom,isRotating:!!_&&this.touchRotate})}return T4._startPinchRotation=null,T4._lastPinchEvent=null,!0}_onDoubleClick(n){if(!this.doubleClickZoom||Date.now()90&&(n=Math.sign(n)*90),Number.isFinite(s)){let[c,u]=cg([s,n]);return[c,Kl(u,0,x1t)]}let[,r]=cg([0,n]);return[s,Kl(r,0,x1t)]}var Yke=class extends A4{constructor(n){let{width:r,height:c,latitude:u,longitude:d,zoom:b,bearing:w=0,pitch:_=0,altitude:x=1.5,position:T=[0,0,0],maxZoom:M=20,minZoom:L=0,maxPitch:I=60,minPitch:D=0,startPanLngLat:F,startZoomLngLat:O,startRotatePos:z,startRotateLngLat:Z,startBearing:H,startPitch:te,startZoom:oe,normalize:ne=!0,rubberBand:ue=!1}=n,{[kb]:Te}=n;La(Number.isFinite(d)),La(Number.isFinite(u)),La(Number.isFinite(b));let Q=n.maxBounds||(ne?E1t:null),ge=n.maxBoundsPadding||null;super({width:r,height:c,latitude:u,longitude:d,zoom:b,bearing:w,pitch:_,altitude:x,maxZoom:M,minZoom:L,maxPitch:I,minPitch:D,normalize:ne,position:T,maxBounds:Q,maxBoundsPadding:ge,rubberBand:ue,[kb]:Te},{startPanLngLat:F,startZoomLngLat:O,startRotatePos:z,startRotateLngLat:Z,startBearing:H,startPitch:te,startZoom:oe},n.makeViewport,n.constraintContext),this.getAltitude=n.getAltitude}panStart({pos:n},r){return this._getUpdatedState({startPanLngLat:this._unproject(n)},r)}pan({pos:n,startPos:r},c){let u=this.getState().startPanLngLat||this._unproject(r);if(!u)return this;let b=this.makeViewport(this.getViewportProps()).panByPosition(u,n);return this._getUpdatedState(b,c)}panEnd(n){return this._getUpdatedState({startPanLngLat:null},n)}rotateStart({pos:n}){let r=this.getAltitude?.(n);return this._getUpdatedState({startRotatePos:n,startRotateLngLat:r!==void 0?this._unproject3D(n,r):void 0,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:n,deltaAngleX:r=0,deltaAngleY:c=0}){let{startRotatePos:u,startRotateLngLat:d,startBearing:b,startPitch:w}=this.getState();if(!u||b===void 0||w===void 0)return this;let _;if(n?_=this._getNewRotation(n,u,w,b):_={bearing:b+r,pitch:w+c},d){let x=this.makeViewport({...this.getViewportProps(),..._}),T="panByPosition3D"in x?"panByPosition3D":"panByPosition";return this._getUpdatedState({..._,...x[T](d,u)})}return this._getUpdatedState(_)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startRotateLngLat:null,startBearing:null,startPitch:null})}zoomStart({pos:n},r){return this._getUpdatedState({startZoomLngLat:this._unproject(n),startZoom:this.getViewportProps().zoom},r)}zoom({pos:n,startPos:r,scale:c},u){let{startZoom:d,startZoomLngLat:b}=this.getState();return b||(d=this.getViewportProps().zoom,b=this._unproject(r)||this._unproject(n)),b?this._getUpdatedState({zoom:d+Math.log2(c),[kb]:{position:b,screenPosition:n}},u):this}zoomEnd(n){return this._getUpdatedState({startZoomLngLat:null,startZoom:null},n)}zoomIn(n=2,r){return this._zoomFromCenter(n,r)}zoomOut(n=2,r){return this._zoomFromCenter(1/n,r)}moveLeft(n=100,r){return this._panFromCenter([n,0],r)}moveRight(n=100,r){return this._panFromCenter([-n,0],r)}moveUp(n=100,r){return this._panFromCenter([0,n],r)}moveDown(n=100,r){return this._panFromCenter([0,-n],r)}rotateLeft(n=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-n})}rotateRight(n=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+n})}rotateUp(n=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+n})}rotateDown(n=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-n})}shortestPathFrom(n){let r=n.getViewportProps(),c={...this.getViewportProps()},{bearing:u,longitude:d}=c;return Math.abs(u-r.bearing)>180&&(c.bearing=u<0?u+360:u-360),Math.abs(d-r.longitude)>180&&(c.longitude=d<0?d+360:d-360),c}applyConstraints(n,r){let c=n,u=c[kb];delete c[kb];let{maxPitch:d,minPitch:b,pitch:w,bearing:_,normalize:x,maxBounds:T,rubberBand:M}=n;x&&(_<-180||_>180)&&(n.bearing=kke(_+180,360)-180),n.pitch=Kl(w,b,d);let L=this._constrainZoom(n.zoom,n),I=M&&r?.mode==="elastic";if(n.zoom=r?.mode==="preserve"?n.zoom:I?ZM(n.zoom,L,ttn):L,u){let D=this.makeViewport(n);Object.assign(n,D.panByPosition(u.position,u.screenPosition))}if(x&&(n.longitude<-180||n.longitude>180)&&(n.longitude=kke(n.longitude+180,360)-180),T){let D=wB(n.width,n.height,n.maxBoundsPadding),F=this.makeViewport({...n,bearing:0,pitch:0}),O=Ple(F,[n.longitude,n.latitude],D),z=dV(T[0]),Z=dV(T[1]),H=2**n.zoom,te=[z[0]+O.left/H,z[1]+O.bottom/H],oe=[Z[0]-O.right/H,Z[1]-O.top/H],ne=dV([n.longitude,n.latitude]),ue=[Kl(ne[0],te[0],oe[0]),Kl(ne[1],te[1],oe[1])],Te=ne.slice();if(D.width>=0&&(Te[0]=r?.mode==="preserve"?ne[0]:I?ZM(ne[0],ue[0],D.width/2/H):ue[0]),D.height>=0&&(Te[1]=r?.mode==="preserve"?ne[1]:I?ZM(ne[1],ue[1],D.height/2/H):ue[1]),Te[0]!==ne[0]||Te[1]!==ne[1]){let[Q,ge]=z1(Te);Te[0]!==ne[0]&&(n.longitude=Q),Te[1]!==ne[1]&&(n.latitude=ge)}}return n}_constrainZoom(n,r){r||(r=this.getViewportProps());let{maxZoom:c,maxBounds:u}=r,d=u!==null&&r.width>0&&r.height>0,{minZoom:b}=r;if(d){let w=wB(r.width,r.height,r.maxBoundsPadding),_=dV(u[0]),x=dV(u[1]),T=x[0]-_[0],M=x[1]-_[1];w.width>0&&Number.isFinite(T)&&T>0&&(b=Math.max(b,Math.log2(w.width/T))),w.height>0&&Number.isFinite(M)&&M>0&&(b=Math.max(b,Math.log2(w.height/M))),b>c&&(b=c)}return Kl(n,b,c)}_zoomFromCenter(n,r){let{width:c,height:u}=this.getViewportProps();return this.zoom({pos:[c/2,u/2],scale:n},r)}_panFromCenter(n,r){let{width:c,height:u}=this.getViewportProps();return this.pan({startPos:[c/2,u/2],pos:[c/2+n[0],u/2+n[1]]},r)}_getUpdatedState(n,r){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...n,constraintContext:r})}_unproject(n){let r=this.makeViewport(this.getViewportProps());return n&&r.unproject(n)}_unproject3D(n,r){return this.makeViewport(this.getViewportProps()).unproject(n,{targetZ:r})}_getNewRotation(n,r,c,u){let d=n[0]-r[0],b=n[1]-r[1],w=n[1],_=r[1],{width:x,height:T}=this.getViewportProps(),M=d/x,L=0;b>0?Math.abs(T-_)>y1t&&(L=b/(_-T)*etn):b<0&&_>y1t&&(L=1-w/_),L=Kl(L,-1,1);let{minPitch:I,maxPitch:D}=this.getViewportProps(),F=u+180*M,O=c;return L>0?O=c+L*(D-c):L<0&&(O=c-L*(I-c)),{pitch:O,bearing:F}}},pV=class extends C4{constructor(){super(...arguments),this.ControllerState=Yke,this.transition={transitionDuration:300,transitionInterpolator:new D3({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan",this.rotationPivot="center",this._getAltitude=n=>{if(this.rotationPivot==="2d")return 0;if(this.rotationPivot==="3d"&&this.pickPosition){let{x:r,y:c}=this.props,u=this.pickPosition(r+n[0],c+n[1]);if(u&&u.coordinate&&u.coordinate.length>=3)return u.coordinate[2]}}}setProps(n){"rotationPivot"in n&&(this.rotationPivot=n.rotationPivot||"center"),n.getAltitude=this._getAltitude,n.position=n.position||[0,0,0],n.maxBounds=n.maxBounds||(n.normalize===!1?null:E1t),super.setProps(n)}updateViewport(n,r=null,c={}){let u=n.getState();c.isDragging&&u.startRotateLngLat?c={...c,rotationPivotPosition:u.startRotateLngLat}:c.isDragging===!1&&(c={...c,rotationPivotPosition:void 0}),super.updateViewport(n,r,c)}};var Lle=class extends S4{constructor(n={}){super(n)}getViewportType(){return R3}get ControllerType(){return pV}};Lle.displayName="MapView";var S1t=Lle;var ntn=new aB;function itn(s,n){let r=s.order??1/0,c=n.order??1/0;return r-c}var gV=class{constructor(n){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=n,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(n){let r=this._defaultEffects;if(!r.find(c=>c.id===n.id)){let c=r.findIndex(u=>itn(u,n)>0);c<0?r.push(n):r.splice(c,0,n),n.setup(this._context),this._setEffects(this.effects)}}setProps(n){"effects"in n&&(Ac(n.effects,this.effects,1)||this._setEffects(n.effects))}needsRedraw(n={clearRedrawFlags:!1}){let r=this._needsRedraw;return n.clearRedrawFlags&&(this._needsRedraw=!1),r}getEffects(){return this._resolvedEffects}_setEffects(n){let r={};for(let u of this.effects)r[u.id]=u;let c=[];for(let u of n){let d=r[u.id],b=u;d&&d!==u?d.setProps?(d.setProps(u.props),b=d):d.cleanup(this._context):d||u.setup(this._context),c.push(b),delete r[u.id]}for(let u in r)r[u].cleanup(this._context);this.effects=c,this._resolvedEffects=c.concat(this._defaultEffects),n.some(u=>u instanceof aB)||this._resolvedEffects.push(ntn),this._needsRedraw="effects changed"}finalize(){for(let n of this._resolvedEffects)n.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}};var mV=class extends k3{shouldDrawLayer(n){let{operation:r}=n.props;return r.includes("draw")||r.includes("terrain")}render(n){return this._render(n)}};var rtn="deckRenderer.renderLayers",bV=class{constructor(n,r={}){this.device=n,this.stats=r.stats,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new mV(n),this.pickLayersPass=new E4(n),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(n){this.layerFilter!==n.layerFilter&&(this.layerFilter=n.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==n.drawPickingColors&&(this.drawPickingColors=n.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(n){let r=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,c={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...n};if(!n.viewports.length){let w=r.render(c),_="stats"in w?w.stats:w;this._updateStats(_);return}c.effects&&this._preRender(c.effects,c);let u=this.lastPostProcessEffect?this.renderBuffers[0]:c.target;this.lastPostProcessEffect&&(c.clearColor=[0,0,0,0],c.clearCanvas=!0);let d=r.render({...c,target:u}),b="stats"in d?d.stats:d;c.effects&&(this.lastPostProcessEffect&&(c.clearCanvas=n.clearCanvas===void 0?!0:n.clearCanvas),this._postRender(c.effects,c)),this.renderCount++,Bf(rtn,this,b,n),this._updateStats(b)}needsRedraw(n={clearRedrawFlags:!1}){let r=this._needsRedraw;return n.clearRedrawFlags&&(this._needsRedraw=!1),r}finalize(){let{renderBuffers:n}=this;for(let r of n)r.delete();n.length=0}_updateStats(n){if(!this.stats)return;let r=0;for(let{visibleCount:c}of n)r+=c;this.stats.get("Layers rendered").addCount(r)}_preRender(n,r){this.lastPostProcessEffect=null,r.preRenderStats=r.preRenderStats||{};for(let c of n)r.preRenderStats[c.id]=c.preRender(r),c.postRender&&(this.lastPostProcessEffect=c.id);this.lastPostProcessEffect&&this._resizeRenderBuffers(r.canvasContext)}_resizeRenderBuffers(n=this.device.canvasContext){let{renderBuffers:r}=this,c=n.getDrawingBufferSize(),[u,d]=c;r.length===0&&[0,1].map(b=>{let w=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"},width:u,height:d});r.push(this.device.createFramebuffer({id:`deck-renderbuffer-${b}`,colorAttachments:[w]}))});for(let b of r)b.resize(c)}_postRender(n,r){let{renderBuffers:c}=this,u=r.target??r.canvasContext?.getCurrentFramebuffer()??r.target,d={...r,inputBuffer:c[0],swapBuffer:c[1]};for(let b of n)if(b.postRender){d.target=b.id===this.lastPostProcessEffect?u:void 0;let w=b.postRender(d);d.inputBuffer=w,d.swapBuffer=w===c[0]?c[1]:c[0]}}};Vr();var stn={pickedColor:null,pickedObjectIndex:-1};function Zke({pickedColors:s,decodePickingColor:n,deviceX:r,deviceY:c,deviceRadius:u,deviceRect:d}){let{x:b,y:w,width:_,height:x}=d,T=u*u,M=-1,L=0;for(let I=0;IT)L+=4*_;else for(let O=0;O<_;O++){if(s[L+3]-1>=0){let Z=O+b-r,H=Z*Z+F;H<=T&&(T=H,M=L)}L+=4}}if(M>=0){let I=s.slice(M,M+4),D=n(I);if(D){let F=Math.floor(M/4/_),O=M/4-F*_;return{...D,pickedColor:I,pickedX:b+O,pickedY:w+F}}Bs.error("Picked non-existent layer. Is picking buffer corrupt?")()}return stn}function Kke({pickedColors:s,decodePickingColor:n}){let r=new Map;if(s){for(let c=0;c=0){let d=s.slice(c,c+4),b=d.join(",");if(!r.has(b)){let w=n(d);w?r.set(b,{...w,color:d}):Bs.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(r.values())}function kle({pickInfo:s,viewports:n,pixelRatio:r,x:c,y:u,z:d}){let b=n[0];n.length>1&&(b=otn(s?.pickedViewports||n,{x:c,y:u}));let w;if(b){let _=[c-b.x,u-b.y];d!==void 0&&(_[2]=d),w=b.unproject(_)}return{color:null,layer:null,viewport:b,index:-1,picked:!1,x:c,y:u,pixel:[c,u],coordinate:w,devicePixel:s&&"pickedX"in s?[s.pickedX,s.pickedY]:void 0,pixelRatio:r}}function Jke(s){let{pickInfo:n,lastPickedInfo:r,mode:c,layers:u}=s,{pickedColor:d,pickedLayer:b,pickedObjectIndex:w}=n,_=b?[b]:[];if(c==="hover"){let M=r.index,L=r.layerId,I=b?b.props.id:null;if(I!==L||w!==M){if(I!==L){let D=u.find(F=>F.props.id===L);D&&_.unshift(D)}r.layerId=I,r.index=w,r.info=null}}let x=kle(s),T=new Map;return T.set(null,x),_.forEach(M=>{let L={...x};M===b&&(L.color=d,L.index=w,L.picked=!0),L=Rle({layer:M,info:L,mode:c});let I=L.layer;M===b&&c==="hover"&&(r.info=L),T.set(I.id,L),c==="hover"&&I.updateAutoHighlight(L)}),T}function Rle({layer:s,info:n,mode:r}){for(;s&&n;){let c=n.layer||null;n.sourceLayer=c,n.layer=s,n=s.getPickingInfo({info:n,mode:r,sourceLayer:c}),s=s.parent}return n}function otn(s,n){for(let r=s.length-1;r>=0;r--){let c=s[r];if(c.containsPixel(n))return c}return s[0]}var wV=class{constructor(n,r={}){this._pickable=!0,this.device=n,this.stats=r.stats,this.pickLayersPass=new E4(n),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(n){"layerFilter"in n&&(this.layerFilter=n.layerFilter),"_pickable"in n&&(this._pickable=n._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObjectAsync(n){return this._pickClosestObjectAsync(n)}pickObjectsAsync(n){return this._pickVisibleObjectsAsync(n)}pickObject(n){return this._pickClosestObject(n)}pickObjects(n){return this._pickVisibleObjects(n)}getLastPickedObject({x:n,y:r,layers:c,viewports:u},d=this.lastPickedInfo.info){let b=d&&d.layer&&d.layer.id,w=d&&d.viewport&&d.viewport.id,_=b?c.find(L=>L.id===b):null,x=w&&u.find(L=>L.id===w)||u[0],T=x&&x.unproject([n-x.x,r-x.y]);return{...d,...{x:n,y:r,viewport:x,coordinate:T,layer:_}}}_resizeBuffer(n=this.device.getDefaultCanvasContext()){if(!this.pickingFBO){let u=this.device.createTexture({format:"rgba8unorm",width:1,height:1,usage:Pa.RENDER_ATTACHMENT|Pa.COPY_SRC});if(this.pickingFBO=this.device.createFramebuffer({colorAttachments:[u],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float")){let d=this.device.createTexture({format:"rgba32float",width:1,height:1,usage:Pa.RENDER_ATTACHMENT|Pa.COPY_SRC}),b=this.device.createFramebuffer({colorAttachments:[d],depthStencilAttachment:"depth16unorm"});this.depthFBO=b}}let[r,c]=n.getDrawingBufferSize();this.pickingFBO?.resize({width:r,height:c}),this.depthFBO?.resize({width:r,height:c})}_getPickable(n){if(this._pickable===!1)return null;let r=n.filter(c=>this.pickLayersPass.shouldDrawLayer(c)&&!c.isComposite);return r.length?r:null}async _pickClosestObjectAsync({layers:n,views:r,viewports:c,x:u,y:d,radius:b=0,depth:w=1,mode:_="query",unproject3D:x,canvasContext:T=this.device.getDefaultCanvasContext(),onViewportActive:M,effects:L}){let I=T.cssToDeviceRatio(),D=this._getPickable(n);if(!D||c.length===0)return{result:[],emptyInfo:kle({viewports:c,x:u,y:d,pixelRatio:I})};this._resizeBuffer(T);let F=T.cssToDevicePixels([u,d],!0),O=[F.x+Math.floor(F.width/2),F.y+Math.floor(F.height/2)],z=Math.round(b*I),{width:Z,height:H}=this.pickingFBO,te=this._getPickingRect({deviceX:O[0],deviceY:O[1],deviceRadius:z,deviceWidth:Z,deviceHeight:H}),oe={x:u-b,y:d-b,width:b*2+1,height:b*2+1},ne,ue=[],Te=new Set;for(let Q=0;Q0){let{pickedColors:at}=await this._drawAndSampleAsync({layers:st,views:r,viewports:c,onViewportActive:M,deviceRect:{x:ge.pickedX??O[0],y:ge.pickedY??O[1],width:1,height:1},cullRect:oe,effects:L,pass:`picking:${_}:z`,canvasContext:T},!0);at[3]&&(Qe=at[0])}ge.pickedLayer&&Q+10){let{pickedColors:at}=this._drawAndSample({layers:st,views:r,viewports:c,onViewportActive:M,deviceRect:{x:ge.pickedX??O[0],y:ge.pickedY??O[1],width:1,height:1},cullRect:oe,effects:L,pass:`picking:${_}:z`,canvasContext:T},!0);at[3]&&(Qe=at[0])}ge.pickedLayer&&Q+1=x);Qe++){let st=ue[Qe],at={color:st.pickedColor,layer:null,index:st.pickedObjectIndex,picked:!0,x:u,y:d,pixelRatio:D};at=Rle({layer:st.pickedLayer,info:at,mode:_});let Ne=at.layer.id;Te.has(Ne)||Te.set(Ne,new Set);let tt=Te.get(Ne),ot=at.object??at.index;tt.has(ot)||(tt.add(ot),Q.push(at))}return Q}_pickVisibleObjects({layers:n,views:r,viewports:c,x:u,y:d,width:b=1,height:w=1,mode:_="query",maxObjects:x=null,canvasContext:T=this.device.getDefaultCanvasContext(),onViewportActive:M,effects:L}){let I=this._getPickable(n);if(!I||c.length===0)return[];this._resizeBuffer(T);let D=T.cssToDeviceRatio(),F=T.cssToDevicePixels([u,d],!0),O=F.x,z=F.y+F.height,Z=T.cssToDevicePixels([u+b,d+w],!0),H=Z.x+Z.width,te=Z.y,oe={x:O,y:te,width:H-O,height:z-te},ne=this._drawAndSample({layers:I,views:r,viewports:c,onViewportActive:M,deviceRect:oe,cullRect:{x:u,y:d,width:b,height:w},effects:L,pass:`picking:${_}`,canvasContext:T}),ue=Kke(ne),Te=new Map,Q=[],ge=Number.isFinite(x);for(let Qe=0;Qe=x);Qe++){let st=ue[Qe],at={color:st.pickedColor,layer:null,index:st.pickedObjectIndex,picked:!0,x:u,y:d,pixelRatio:D};at=Rle({layer:st.pickedLayer,info:at,mode:_});let Ne=at.layer.id;Te.has(Ne)||Te.set(Ne,new Set);let tt=Te.get(Ne),ot=at.object??at.index;tt.has(ot)||(tt.add(ot),Q.push(at))}return Q}async _drawAndSampleAsync({layers:n,views:r,viewports:c,onViewportActive:u,deviceRect:d,cullRect:b,effects:w,pass:_,canvasContext:x},T=!1){let M=T?this.depthFBO:this.pickingFBO,L={layers:n,layerFilter:this.layerFilter,views:r,viewports:c,onViewportActive:u,pickingFBO:M,deviceRect:d,cullRect:b,effects:w,pass:_,canvasContext:x,pickZ:T,preRenderStats:{},isPicking:!0};for(let oe of w)oe.useInPicking&&(L.preRenderStats[oe.id]=oe.preRender(L));let{decodePickingColor:I,stats:D}=this.pickLayersPass.render(L);this._updateStats(D);let{x:F,y:O,width:z,height:Z}=d,H=M.colorAttachments[0]?.texture;if(!H)throw new Error("Picking framebuffer color attachment is missing");let te=await this._readTextureDataAsync(H,{x:F,y:O,width:z,height:Z},T?Float32Array:Uint8Array);if(!T){let oe=!1;for(let ne=3;ne0&&Bs.warn("Async pick readback returned only zero alpha values",{deviceRect:d,bytes:Array.from(te.subarray(0,Math.min(te.length,16)))})()}return{pickedColors:te,decodePickingColor:I}}async _readTextureDataAsync(n,r,c){let{width:u,height:d}=r,b=n.computeMemoryLayout(r),w=this.device.createBuffer({byteLength:b.byteLength,usage:cs.COPY_DST|cs.MAP_READ});try{n.readBuffer(r,w);let _=await w.readAsync(0,b.byteLength),x=c.BYTES_PER_ELEMENT;if(b.bytesPerRow%x!==0)throw new Error(`Texture readback row stride ${b.bytesPerRow} is not aligned to ${x}-byte elements.`);let T=new c(_.buffer,_.byteOffset,b.byteLength/x),M=u*4,L=b.bytesPerRow/x;if(Lb.props.operation.includes("terrain"))}_getPickingRect({deviceX:n,deviceY:r,deviceRadius:c,deviceWidth:u,deviceHeight:d}){let b=Math.max(0,n-c),w=Math.max(0,r-c),_=Math.min(u,n+c+1)-b,x=Math.min(d,r+c+1)-w;return _<=0||x<=0?null:{x:b,y:w,width:_,height:x}}};var atn={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},ctn="top-left",M1t="root",Ile=class{constructor({deck:n,parentElement:r}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=n,r?.classList.add("deck-widget-container"),this.parentElement=r}getWidgets(){return this.resolvedWidgets}setProps(n){if(n.widgets&&!Ac(n.widgets,this.widgets,1)){let r=n.widgets.filter(Boolean);this._setWidgets(r)}}finalize(){for(let n of this.getWidgets())this._removeWidget(n);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(let n in this.containers)this.containers[n].remove()}addDefault(n){this.defaultWidgets.find(r=>r.id===n.id)||(this._addWidget(n),this.defaultWidgets.push(n),this._setWidgets(this.widgets))}onRedraw({viewports:n,layers:r}){let c=n.reduce((u,d)=>(u[d.id]=d,u),{});for(let u of this.getWidgets()){let{viewId:d}=u;if(d){let b=c[d];b&&(u.onViewportChange&&u.onViewportChange(b),u.onRedraw?.({viewports:[b],layers:r}))}else{if(u.onViewportChange)for(let b of n)u.onViewportChange(b);u.onRedraw?.({viewports:n,layers:r})}}this.lastViewports=c,this._updateContainers()}onHover(n,r){for(let c of this.getWidgets()){let{viewId:u}=c;(!u||u===n.viewport?.id)&&c.onHover?.(n,r)}}getCanvasBounds(n){let c=this.deck?.getCanvas?.()?.getBoundingClientRect(),u=this.parentElement?.getBoundingClientRect(),d=this.deck?.getCanvasContext?.(n?.id);if(d&&u){d.updatePosition();let[b,w]=d.getPosition(),[_,x]=d.getCSSSize();return{x:b-u.left,y:w-u.top,width:_,height:x}}return{x:c&&u?c.left-u.left:0,y:c&&u?c.top-u.top:0,width:c?.width||this.deck?.width||0,height:c?.height||this.deck?.height||0}}onEvent(n,r){let c=iB[r.type];if(c)for(let u of this.getWidgets()){let{viewId:d}=u;(!d||d===n.viewport?.id)&&u[c]?.(n,r)}}_setWidgets(n){let r={};for(let c of this.resolvedWidgets)r[c.id]=c;this.resolvedWidgets.length=0;for(let c of this.defaultWidgets)r[c.id]=null,this.resolvedWidgets.push(c);for(let c of n){let u=r[c.id];u?u.viewId!==c.viewId||u.placement!==c.placement?(this._removeWidget(u),this._addWidget(c)):c!==u&&(u.setProps(c.props),c=u):this._addWidget(c),r[c.id]=null,this.resolvedWidgets.push(c)}for(let c in r){let u=r[c];u&&this._removeWidget(u)}this.widgets=n}_addWidget(n){let{viewId:r=null,placement:c=ctn}=n,u=n.props._container??r;n.widgetManager=this,n.deck=this.deck,n.rootElement=n._onAdd({deck:this.deck,viewId:r}),n.rootElement&&this._getContainer(u,c).append(n.rootElement),n.updateHTML()}_removeWidget(n){n.onRemove?.(),n.rootElement&&n.rootElement.remove(),n.rootElement=void 0,n.deck=void 0,n.widgetManager=void 0}_getContainer(n,r){if(n&&typeof n!="string")return n;let c=n||M1t,u=this.containers[c];u||(u=document.createElement("div"),u.style.pointerEvents="none",u.style.position="absolute",u.style.overflow="hidden",this.parentElement?.append(u),this.containers[c]=u);let d=u.querySelector(`.${r}`);return d||(d=globalThis.document.createElement("div"),d.className=r,d.style.position="absolute",d.style.zIndex="2",Object.assign(d.style,atn[r]),u.append(d)),d}_updateContainers(){for(let n in this.containers){let r=this.lastViewports[n]||null,c=n===M1t||r,u=this.containers[n];if(c){let d=this._getContainerBounds(r);u.style.display="block",u.style.left=`${d.x}px`,u.style.top=`${d.y}px`,u.style.width=`${d.width}px`,u.style.height=`${d.height}px`}else u.style.display="none"}}_getContainerBounds(n){if(!n)return{x:0,y:0,width:this.parentElement?.clientWidth||this.deck.width,height:this.parentElement?.clientHeight||this.deck.height};let r=this.getCanvasBounds(n);return{x:r.x+n.x,y:r.y+n.y,width:n.width,height:n.height}}};function Qke(s,n){n&&Object.entries(n).map(([r,c])=>{r.startsWith("--")?s.style.setProperty(r,c):s.style[r]=c})}function T1t(s,n){n&&Object.keys(n).map(r=>{r.startsWith("--")?s.style.removeProperty(r):s.style[r]=""})}var vB=class{constructor(n){this.viewId=null,this.props={...this.constructor.defaultProps,...n},this.id=this.props.id}setProps(n){let r=this.props,c=this.rootElement;c&&r.className!==n.className&&(r.className&&c.classList.remove(r.className),n.className&&c.classList.add(n.className)),c&&!Ac(r.style,n.style,1)&&(T1t(c,r.style),Qke(c,n.style)),Object.assign(this.props,n),this.updateHTML()}updateHTML(){this.rootElement&&this.onRenderHTML(this.rootElement)}get viewIds(){return this.viewId?[this.viewId]:this.deck?.getViews().map(n=>n.id)??[]}getViewState(n){return this.deck?.viewManager?.getViewState(n)||{}}setViewState(n,r){this.deck?._onViewStateChange({viewId:n,viewState:r,interactionState:{}})}onCreateRootElement(){let n=["deck-widget",this.className,this.props.className],r=document.createElement("div");return n.filter(c=>typeof c=="string"&&c.length>0).forEach(c=>r.classList.add(c)),Qke(r,this.props.style),r}_onAdd(n){return this.onAdd(n)??this.onCreateRootElement()}onAdd(n){}onRemove(){}onViewportChange(n){}onRedraw(n){}onHover(n,r){}onClick(n,r){}onDrag(n,r){}onDragStart(n,r){}onDragEnd(n,r){}};vB.defaultProps={id:"widget",style:{},_container:null,className:""};var ltn={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"},vV=class extends vB{constructor(n={}){super(n),this.id="default-tooltip",this.placement="fill",this.className="deck-tooltip",this.isVisible=!1,this.setProps(n)}onCreateRootElement(){let n=document.createElement("div");return n.className=this.className,Object.assign(n.style,ltn),n}onRenderHTML(n){}onViewportChange(n){this.isVisible&&n.id===this.lastViewport?.id&&!n.equals(this.lastViewport)&&this.setTooltip(null),this.lastViewport=n}onHover(n){let{deck:r}=this,c=r&&r.props.getTooltip;if(!c)return;let u=c(n),d=this.widgetManager?.getCanvasBounds(n.viewport),b=n.x+(d?.x||0),w=n.y+(d?.y||0);this.setTooltip(u,b,w)}setTooltip(n,r,c){let u=this.rootElement;if(u){if(typeof n=="string")u.innerText=n;else if(n)n.text&&(u.innerText=n.text),n.html&&(u.innerHTML=n.html),n.className&&(u.className=n.className);else{this.isVisible=!1,u.style.display="none";return}this.isVisible=!0,u.style.display="block",u.style.transform=`translate(${r}px, ${c}px)`,n&&typeof n=="object"&&"style"in n&&Object.assign(u.style,n.style)}}};vV.defaultProps={...vB.defaultProps};var _V=class{constructor(n){this.targets={},this.order=[],this.eventManagers={},this._eventRootToCanvasId=new WeakMap,this._createEventManager=n.createEventManager,this._getEventRoot=n.getEventRoot}finalize(){for(let n of Object.values(this.targets))n.eventManager.destroy(),n.presentationContext.destroy();this.targets={},this.order=[],this.eventManagers={},this._eventRootToCanvasId=new WeakMap}syncCanvasEntries(n){let r=this._normalizeCanvasList(n.canvases),c={},u=[],d=new Map;for(let{canvas:w}of r){let _=this._getEventRoot(w);d.set(_,(d.get(_)||0)+1)}for(let{id:w,canvas:_}of r){let x=this._getEventRoot(_),T=d.get(x)===1?x:_,M=this.targets[w];if(!M||M.device!==n.device||M.canvas!==_||M.eventRoot!==T){M?.eventManager.destroy(),M?.presentationContext.destroy();let L=n.device.createPresentationContext({id:w,canvas:_,useDevicePixels:n.useDevicePixels,autoResize:!0});M={id:w,device:n.device,canvas:_,eventRoot:T,presentationContext:L,eventManager:this._createEventManager(T)}}this._eventRootToCanvasId.set(T,w),this._eventRootToCanvasId.set(_,w),c[w]=M,u.push(w)}for(let[w,_]of Object.entries(this.targets))c[w]||(_.eventManager.destroy(),_.presentationContext.destroy());this.targets=c,this.order=u;let b=Object.fromEntries(Object.entries(c).map(([w,_])=>[w,_.eventManager]));this._haveSameEventManagers(b)||(this.eventManagers=b)}getCanvasIdFromEvent(n){return n?this._eventRootToCanvasId.get(n):void 0}getTarget(n){return this.targets[n||this.order[0]||YM]||null}_normalizeCanvasList(n=[]){let r=new Set;return n.map((c,u)=>{let d,b;return typeof c=="string"?(d=document.getElementById(c),La(d,`Canvas with id ${c} not found`),b=c):(d=c,b=d.id||`deckgl-canvas-${u}`),La(!r.has(b),`Duplicate canvas id ${b}`),r.add(b),{id:b,canvas:d}})}_haveSameEventManagers(n){let r=Object.keys(n),c=Object.keys(this.eventManagers);return r.length===c.length&&r.every(u=>n[u]===this.eventManagers[u])}};Vr();fue();Ql();Ql();Kj();function B3(){}var _nn=({isDragging:s})=>s?"grabbing":"grab",J0t={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,pickAsync:"auto",layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{},gl:null,canvas:null,_canvases:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:B3,onWebGLInitialized:B3,onResize:B3,onViewStateChange:B3,onInteractionStateChange:B3,onBeforeRender:B3,onAfterRender:B3,onLoad:B3,onError:s=>Bs.error(s.message,s.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:_nn,getTooltip:null,debug:!1,drawPickingColors:!1},RV=class{constructor(n){this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.eventManagers={},this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this._canvasContext=null,this._deviceResizeHandler=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new xb({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,layersCount:0,drawLayersCount:0,updateLayersCount:0,updateAttributesCount:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,pickLayersCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._hoverPickSequence=0,this._pointerDownPickSequence=0,this._needsRedraw="Initial render",this._canvasManager=new _V({createEventManager:u=>this._createEventManager(u),getEventRoot:u=>this._getEventRoot(u)}),this._ownedCanvas=null,this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,canvasId:void 0,event:null,unproject3D:!1},this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this._onPointerMove=u=>{let{_pickRequest:d}=this,b=this._getCanvasIdFromEvent(u);if(u.type==="pointerleave")d.x=-1,d.y=-1,d.radius=0,d.canvasId=b;else{if(u.leftButton||u.rightButton)return;{let w=u.offsetCenter;if(!w)return;d.x=w.x,d.y=w.y,d.radius=this.props.pickingRadius,d.canvasId=b}}this.layerManager&&(this.layerManager.context.mousePosition={x:d.x,y:d.y}),d.event=u},this._onEvent=u=>{let d=iB[u.type],b=u.offsetCenter,w=this._getCanvasIdFromEvent(u);if(!d||!b||!this.layerManager)return;let _=this.layerManager.getLayers(),x=this._getInternalPickingMode();if(!x)return;if(x==="sync"){let M=u.type==="click"&&this._shouldUnproject3D(_)?this._getFirstPickedInfo(this._pickPointSync(this._getPointPickOptions(b.x,b.y,{unproject3D:!0,canvasId:w},_))):this._getLastPointerDownPickingInfo(b.x,b.y,w,_);this._dispatchPickingEvent(M,u);return}(this._lastPointerDownInfoPromise||Promise.resolve(this._getLastPointerDownPickingInfo(b.x,b.y,w,_))).then(M=>{this._dispatchPickingEvent(M,u)}).catch(M=>this.props.onError?.(M))},this._onPointerDown=u=>{let d=u.offsetCenter,b=this._getCanvasIdFromEvent(u);if(!d)return;let w=this._getInternalPickingMode();if(!w)return;let _=this.layerManager?.getLayers()||[],x=++this._pointerDownPickSequence;if(w==="sync"){let M=this._pickPointSync({x:d.x,y:d.y,canvasId:b,radius:this.props.pickingRadius}),L=this._getFirstPickedInfo(M);this._lastPointerDownInfo=L,this._lastPointerDownInfoPromise=Promise.resolve(L);return}let T=this._pickPointAsync(this._getPointPickOptions(d.x,d.y,{canvasId:b},_)).then(M=>this._getFirstPickedInfo(M)).then(M=>(x===this._pointerDownPickSequence&&(this._lastPointerDownInfo=M),M)).catch(M=>{this.props.onError?.(M);let L=this.deckPicker&&this.viewManager?this._getLastPointerDownPickingInfo(d.x,d.y,b,_):{};return x===this._pointerDownPickSequence&&(this._lastPointerDownInfo=L),L});this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=T};let r=n;this.props={...J0t,...n},n=this.props,this._validateCanvasConfiguration(n),n.viewState&&n.initialViewState&&Bs.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,n.device&&(this.device=n.device,this._setDeviceCanvasContext(n.device));let c=this.device;!c&&n.gl&&(n.gl instanceof WebGLRenderingContext&&Bs.error("WebGL1 context not supported.")(),c=kV.attach(n.gl,{_cacheShaders:!0,_cachePipelines:!0,...this.props.deviceProps})),c||(c=this._createDevice(n)),this.animationLoop=this._createAnimationLoop(c,n),this.setProps(r),n._typedArrayManagerProps&&pv.setOptions(n._typedArrayManagerProps),this.animationLoop.start()}finalize(){this._restoreDeviceResizeHandler(),this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._hoverPickSequence++,this._pointerDownPickSequence++,this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this.layerManager?.finalize(),this.layerManager=null,this.viewManager?.finalize(),this.viewManager=null,this.effectManager?.finalize(),this.effectManager=null,this.deckRenderer?.finalize(),this.deckRenderer=null,this.deckPicker?.finalize(),this.deckPicker=null,Object.keys(this._canvasManager.targets).length||this.eventManager?.destroy(),this.eventManager=null,this.eventManagers={},this.widgetManager?.finalize(),this.widgetManager=null,this._canvasManager.finalize(),this._isMultiCanvasMode()?this.canvas=null:this.canvas&&this.canvas===this._ownedCanvas&&(this.canvas.parentElement?.removeChild(this.canvas),this.canvas=null,this._ownedCanvas=null),this._canvasContext=null}setProps(n){this.stats.get("setProps Time").timeStart(),"onLayerHover"in n&&Bs.removed("onLayerHover","onHover")(),"onLayerClick"in n&&Bs.removed("onLayerClick","onClick")(),n.initialViewState&&!Ac(this.props.initialViewState,n.initialViewState,3)&&(this.viewState=n.initialViewState),La(!("_canvases"in n)||Array.isArray(n._canvases)===this._isMultiCanvasMode()),Object.assign(this.props,n),this._validateCanvasConfiguration(this.props),this._validateInternalPickingMode(),this.device&&this._isMultiCanvasMode()&&this._syncCanvasTargets(),this._setCanvasSize(this.props);let r=Object.create(this.props);if(Object.assign(r,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState(),eventManagers:this.eventManagers}),n.device&&n.device.id!==this.device?.id){let c=n.device.getDefaultCanvasContext();this.animationLoop?.stop(),!this._isMultiCanvasMode()&&this.canvas!==c.canvas&&(this.canvas?.remove(),this.eventManager?.destroy(),this.canvas=null),this._setDeviceCanvasContext(n.device),Bs.log(`recreating animation loop for new device! id=${n.device.id}`)(),this.animationLoop=this._createAnimationLoop(n.device,n),this.animationLoop.start()}if(this.animationLoop?.setProps(r),n.useDevicePixels!==void 0&&this._canvasContext?.setProps){this._canvasContext.setProps({useDevicePixels:n.useDevicePixels});for(let c of Object.values(this._canvasManager.targets))c.presentationContext.setProps({useDevicePixels:n.useDevicePixels})}this.layerManager&&(this.viewManager.setProps(r),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(r),this.effectManager.setProps(r),this.deckRenderer.setProps(r),this.deckPicker.setProps(r),this.widgetManager.setProps(r)),this.stats.get("setProps Time").timeEnd()}needsRedraw(n={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let r=this._needsRedraw;n.clearRedrawFlags&&(this._needsRedraw=!1);let c=this.viewManager.needsRedraw(n),u=this.layerManager.needsRedraw(n),d=this.effectManager.needsRedraw(n),b=this.deckRenderer.needsRedraw(n);return r=r||c||u||d||b,r}redraw(n){if(!this.layerManager)return;let r=this.needsRedraw({clearRedrawFlags:!0});r=n||r,r&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(r):this._drawLayers(r))}get isInitialized(){return this.viewManager!==null}getViews(){return La(this.viewManager),this.viewManager.views}getView(n){return La(this.viewManager),this.viewManager.getView(n)}getViewports(n){return La(this.viewManager),this.viewManager.getViewports(n)}getCanvas(){return this.canvas}getCanvasContext(n){let r=n?this.viewManager?.getView(n)?.props.canvasId:void 0;return this._getCanvasContext(r)}getEventManager(n){if(!n||!this.viewManager)return this.eventManager;let r=this.viewManager.getCanvasId(n)||YM;return this.eventManagers[r]||this.eventManager}async pickObjectAsync(n){let r=(await this._pickAsync("pickObjectAsync","pickObject Time",n)).result;return r.length?r[0]:null}async pickObjectsAsync(n){return await this._pickAsync("pickObjectsAsync","pickObjects Time",n)}pickObject(n){let r=this._pick("pickObject","pickObject Time",n).result;return r.length?r[0]:null}pickMultipleObjects(n){return n.depth=n.depth||10,this._pick("pickObject","pickMultipleObjects Time",n).result}pickObjects(n){return this._pick("pickObjects","pickObjects Time",n)}_pickPositionForController(n,r,c){return this._getInternalPickingMode()!=="sync"?null:this.pickObject({x:n,y:r,radius:0,unproject3D:!0,canvasId:c?this.viewManager?.getCanvasId(c):void 0})}_addResources(n,r=!1){for(let c in n)this.layerManager.resourceManager.add({resourceId:c,data:n[c],forceUpdate:r})}_removeResources(n){for(let r of n)this.layerManager.resourceManager.remove(r)}_addDefaultEffect(n){this.effectManager.addDefaultEffect(n)}_addDefaultShaderModule(n){this.layerManager.addDefaultShaderModule(n)}_removeDefaultShaderModule(n){this.layerManager?.removeDefaultShaderModule(n)}_resolveInternalPickingMode(){let{pickAsync:n}=this.props,r=this.device?.type||this.props.deviceProps?.type;if(n==="auto")return r==="webgpu"?"async":"sync";if(n==="sync"&&r==="webgpu")throw new Error('`pickAsync: "sync"` is not supported when Deck is using a WebGPU device.');return n}_getInternalPickingMode(){try{return this._resolveInternalPickingMode()}catch(n){return this.props.onError?.(n),null}}_validateInternalPickingMode(){this._getInternalPickingMode()}_getFirstPickedInfo({result:n,emptyInfo:r}){return n[0]||r}_shouldUnproject3D(n=this.layerManager?.getLayers()||[]){return n.some(r=>r.props.pickable==="3d")}_getPointPickOptions(n,r,c={},u=this.layerManager?.getLayers()||[]){return{x:n,y:r,canvasId:c.canvasId,radius:this.props.pickingRadius,unproject3D:this._shouldUnproject3D(u),...c}}_pickPointSync(n){return this._pick("pickObject","pickObject Time",n)}_pickPointAsync(n){return this._pickAsync("pickObjectAsync","pickObject Time",n)}_getLastPointerDownPickingInfo(n,r,c,u=this.layerManager?.getLayers()||[]){return this.deckPicker.getLastPickedObject({x:n,y:r,layers:u,viewports:this.getViewports({x:n,y:r,canvasId:c})},this._lastPointerDownInfo)}_applyHoverCallbacks({result:n,emptyInfo:r},c){if(!this.widgetManager)return;this.cursorState.isHovering=n.length>0;let u=r,d=!1;for(let b of n)u=b,d=b.layer?.onHover(b,c)||d;d||(this.props.onHover?.(u,c),this.widgetManager.onHover(u,c))}_dispatchPickingEvent(n,r){if(!this.layerManager||!this.widgetManager)return;let c=iB[r.type];if(!c)return;let{layer:u}=n,d=u&&(u[c]||u.props[c]),b=this.props[c],w=!1;d&&(w=d.call(u,n,r)),w||(b?.(n,r),this.widgetManager.onEvent(n,r))}_pickAsync(n,r,c){La(this.deckPicker);let{stats:u}=this,d=this._isMultiCanvasMode()?c.canvasId||this._getDefaultCanvasId():c.canvasId,b=this._getCanvasContext(d)||void 0;u.get("Pick Count").incrementCount(),u.get(r).timeStart(),this._resizeForCanvasTarget(d);let w=this.deckPicker[n]({layers:this.layerManager.getLayers(c),views:this.viewManager.getViews(),viewports:this.getViewports({...c,canvasId:d}),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...c,canvasId:d,canvasContext:b});return u.get(r).timeEnd(),w}_pick(n,r,c){La(this.deckPicker);let{stats:u}=this,d=this._isMultiCanvasMode()?c.canvasId||this._getDefaultCanvasId():c.canvasId,b=this._getCanvasContext(d)||void 0;u.get("Pick Count").incrementCount(),u.get(r).timeStart(),this._resizeForCanvasTarget(d);let w=this.deckPicker[n]({layers:this.layerManager.getLayers(c),views:this.viewManager.getViews(),viewports:this.getViewports({...c,canvasId:d}),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...c,canvasId:d,canvasContext:b});return u.get(r).timeEnd(),w}_createCanvas(n){let r=n.canvas;return typeof r=="string"&&(r=document.getElementById(r),La(r)),r?this._ownedCanvas=null:(r=document.createElement("canvas"),r.id=n.id||"deckgl-overlay",n.width&&typeof n.width=="number"&&(r.width=n.width),n.height&&typeof n.height=="number"&&(r.height=n.height),(n.parent||document.body).appendChild(r),this._ownedCanvas=r),Object.assign(r.style,n.style),r}_isMultiCanvasMode(){return Array.isArray(this.props._canvases)}_getDefaultCanvasId(){return this._canvasManager.order[0]||YM}_validateCanvasConfiguration(n){Array.isArray(n._canvases)&&(La(!n.canvas),La(!n.gl),La(!n.device?.canvasContext||n.device.getDefaultCanvasContext().offscreenCanvas))}_createEventManager(n){let r=new H$(n,{touchAction:this.props.touchAction,recognizers:Object.keys(xke).map(c=>{let[u,d,b,w]=xke[c],_=this.props.eventRecognizerOptions?.[c],x={...d,..._,event:c};return{recognizer:new u(x),recognizeWith:b,requireFailure:w}}),events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(let c in iB)c==="dblclick"?r.watch(c,this._onEvent):r.on(c,this._onEvent);return r}_getEventRoot(n){return n.closest(".deck-events-root")||this.props.parent?.querySelector(".deck-events-root")||n}_syncCanvasTargets(){if(!this.device||!this._isMultiCanvasMode())return;this._canvasManager.syncCanvasEntries({device:this.device,canvases:this.props._canvases||[],useDevicePixels:this.props.useDevicePixels}),this.eventManagers=this._canvasManager.eventManagers;let n=this._getDefaultCanvasId();this.eventManager=this.eventManagers[n]||null,this.canvas=this._canvasManager.targets[n]?.canvas||null}_setCanvasContext(n){this._canvasContext=n,"style"in n.canvas&&(this.canvas=n.canvas)}_setDeviceCanvasContext(n,r={}){let c=n.getDefaultCanvasContext();this._setCanvasContext(c),this._setDeviceResizeHandler(n,r)}_setDeviceResizeHandler(n,r={}){let c=!!r.syncDrawingBuffer;if(this._deviceResizeHandler?.device===n){this._deviceResizeHandler.syncDrawingBuffer=c;return}this._restoreDeviceResizeHandler();let u=d=>{this._isMultiCanvasMode()?this._updateMultiCanvasDimensions():d===this._canvasContext&&this._canvasContext&&this._onCanvasContextResize(this._canvasContext,{syncDrawingBuffer:this._deviceResizeHandler?.syncDrawingBuffer})};n.props.onResize=u,this._deviceResizeHandler={device:n,onResize:u,syncDrawingBuffer:c}}_restoreDeviceResizeHandler(){let n=this._deviceResizeHandler;n&&n.device.props?.onResize===n.onResize&&(n.device.props.onResize=B3),this._deviceResizeHandler=null}_setCanvasSize(n){if(this._isMultiCanvasMode()||!this.canvas)return;let{width:r,height:c}=n;if(r||r===0){let u=Number.isFinite(r)?`${r}px`:r;this.canvas.style.width=u}if(c||c===0){let u=Number.isFinite(c)?`${c}px`:c;this.canvas.style.position=n.style?.position||"absolute",this.canvas.style.height=u}}_getCanvasIdFromEvent(n){return this._canvasManager.getCanvasIdFromEvent(n?.rootElement)}_getCanvasContext(n){return this._canvasManager.getTarget(n)?.presentationContext||this._canvasContext}_resizeForCanvasTarget(n){let r=this._canvasManager.getTarget(n);if(!r||!this.device?.canvasContext)return;let[c,u]=r.presentationContext.getDrawingBufferSize();this.device.canvasContext.setDrawingBufferSize(c,u)}_createDeviceCanvas(n){if(this._isMultiCanvasMode()){let r=globalThis.OffscreenCanvas;if(!r)throw new Error("`_canvases` requires OffscreenCanvas support.");let c=typeof n.width=="number"&&Number.isFinite(n.width)?n.width:1,u=typeof n.height=="number"&&Number.isFinite(n.height)?n.height:1;return new r(c,u)}return this._createCanvas(n)}_updateCanvasSize(n=this._canvasContext){if(this._isMultiCanvasMode()){this._updateMultiCanvasDimensions();return}let{canvas:r}=this,[c,u]=n?n.getCSSSize():[r?.clientWidth??r?.width??0,r?.clientHeight??r?.height??0];(c!==this.width||u!==this.height)&&(this.width=c,this.height=u,this.viewManager?.setProps({width:c,height:u}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:c,height:u},n||void 0))}_onCanvasContextResize(n,r={}){if(r.syncDrawingBuffer){let{width:c,height:u}=n.canvas;n.setDrawingBufferSize(c,u)}this._needsRedraw="Canvas resized",this._updateCanvasSize(n)}_updateMultiCanvasDimensions(){let[n,r]=this._getCanvasContext()?.getCSSSize()||[0,0];(n!==this.width||r!==this.height)&&(this.width=n,this.height=r,this.props.onResize({width:n,height:r})),this._needsRedraw="Canvas resized",this.viewManager?.setNeedsUpdate("Canvas resized"),this.viewManager?.setProps({width:this.width,height:this.height})}_createAnimationLoop(n,r){let{gl:c,onError:u}=r;return new iV({device:n,autoResizeDrawingBuffer:!c&&!Array.isArray(r._canvases),autoResizeViewport:!1,onInitialize:d=>this._setDevice(d.device),onRender:this._onRenderFrame.bind(this),onError:u})}_createDevice(n){let r=this.props.deviceProps?.createCanvasContext,c=typeof r=="object"?r:void 0,u={adapters:[],_cacheShaders:!0,_cachePipelines:!0,...n.deviceProps};u.adapters.includes(kV)||u.adapters.push(kV);let d={alphaMode:this.props.deviceProps?.type==="webgpu"?"premultiplied":void 0};return UD.createDevice({_reuseDevices:!0,type:"webgl",...u,createCanvasContext:{...d,...c,canvas:this._createDeviceCanvas(n),useDevicePixels:this.props.useDevicePixels,autoResize:!0}})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let{views:n}=this.props,r=Array.isArray(n)?n:n?[n]:[new S1t({id:"default-view"})];return r.length&&this.props.controller&&(r[0]=r[0].clone({controller:this.props.controller})),r}_onContextLost(){let{onError:n}=this.props;this.animationLoop&&n&&n(new Error("WebGL context is lost"))}_pickAndCallback(){let{_pickRequest:n}=this;if(n.event){let r=n.event,c=this.layerManager?.getLayers()||[],u=this._getPointPickOptions(n.x,n.y,{canvasId:n.canvasId,radius:n.radius,mode:n.mode},c),d=this._getInternalPickingMode(),b=++this._hoverPickSequence;if(n.event=null,n.canvasId=void 0,!d)return;if(d==="sync"){this._applyHoverCallbacks(this._pickPointSync(u),r);return}this._pickPointAsync(u).then(({result:w,emptyInfo:_})=>{b===this._hoverPickSequence&&this._applyHoverCallbacks({result:w,emptyInfo:_},r)}).catch(w=>this.props.onError?.(w))}}_updateCursor(){let n=this.props.getCursor(this.cursorState);if(this._isMultiCanvasMode()){for(let c of Object.values(this._canvasManager.targets))c.canvas.style.cursor=n;return}let r=this.props.parent||this.canvas;r&&(r.style.cursor=n)}_setDevice(n){if(this.device=n,this._validateInternalPickingMode(),!this.animationLoop)return;this._setDeviceCanvasContext(n,{syncDrawingBuffer:!!(this.props.gl&&this.props.device!==n)}),this._isMultiCanvasMode()?this._syncCanvasTargets():this.canvas&&!this.canvas.isConnected&&this.props.parent&&this.props.parent.insertBefore(this.canvas,this.props.parent.firstChild),this.device.type==="webgl"&&this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),this.device.type==="webgl"&&this.props.onWebGLInitialized(this.device.gl);let r=new x4;if(r.play(),this.animationLoop.attachTimeline(r),!this._isMultiCanvasMode()){let d=this.canvas&&this._getEventRoot(this.canvas);La(d),this.eventManager=this._createEventManager(d),this.eventManagers={[YM]:this.eventManager}}this.viewManager=new uV({timeline:r,eventManager:this.eventManager,eventManagers:this.eventManagers,getCanvasContext:this._isMultiCanvasMode()?this.getCanvasContext.bind(this):void 0,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),pickPosition:this._pickPositionForController.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});let c=this.viewManager.getViewports()[0];this.layerManager=new lV(this.device,{deck:this,stats:this.stats,viewport:c,timeline:r}),this.effectManager=new gV({deck:this,device:this.device}),this.deckRenderer=new bV(this.device,{stats:this.stats}),this.deckPicker=new wV(this.device,{stats:this.stats});let u=this.props.parent?.querySelector(".deck-widgets-root")||(this._isMultiCanvasMode()?this.props.parent||this.canvas?.parentElement:null)||this.canvas?.parentElement;this.widgetManager=new Ile({deck:this,parentElement:u}),this.widgetManager.addDefault(new vV),this.setProps({}),this._updateCanvasSize(this._canvasContext),this.props.onLoad()}_drawLayers(n,r){let{device:c,gl:u}=this.layerManager.context;this.props.onBeforeRender({device:c,gl:u});let d={target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:"screen",effects:this.effectManager.getEffects(),...r};if(this._isMultiCanvasMode()&&d.pass==="screen"&&!d.target&&this._canvasManager.order.length)for(let b of this._canvasManager.order){let w=d.viewports.filter(T=>this.viewManager.getCanvasId(T.id)===b);if(!w.length){let T=this._canvasManager.targets[b];this._resizeForCanvasTarget(b),this.deckRenderer?.renderLayers({...d,canvasContext:T.presentationContext,target:T.presentationContext.getCurrentFramebuffer(),viewports:[],clearCanvas:!0}),T.presentationContext.present();continue}let _=this._canvasManager.targets[b];this._resizeForCanvasTarget(b);let x=_.presentationContext.getCurrentFramebuffer();this.deckRenderer?.renderLayers({...d,canvasContext:_.presentationContext,target:x,viewports:w}),_.presentationContext.present()}else this.deckRenderer?.renderLayers(d);d.pass==="screen"&&this.widgetManager.onRedraw({viewports:d.viewports,layers:d.layers}),this.props.onAfterRender({device:c,gl:u})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60===0&&(this._getMetrics(),this.stats.reset(),Bs.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCursor(),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(n){let r=this.props.onViewStateChange(n)||n.viewState;this.viewState&&(this.viewState={...this.viewState,[n.viewId]:r},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(n){this.cursorState.isDragging=n.isDragging||!1,this.props.onInteractionStateChange(n)}_getFrameStats(){let{stats:n}=this;n.get("frameRate").timeEnd(),n.get("frameRate").timeStart();let r=this.animationLoop.stats;n.get("GPU Time").addTime(r.get("GPU Time").lastTiming),n.get("CPU Time").addTime(r.get("CPU Time").lastTiming)}_getMetrics(){let{metrics:n,stats:r}=this;n.fps=r.get("frameRate").getHz(),n.setPropsTime=r.get("setProps Time").time,n.updateAttributesTime=r.get("Update Attributes").time,n.framesRedrawn=r.get("Redraw Count").count,n.pickTime=r.get("pickObject Time").time+r.get("pickMultipleObjects Time").time+r.get("pickObjects Time").time,n.pickCount=r.get("Pick Count").count,n.layersCount=this.layerManager?.layers.length??0,n.drawLayersCount=r.get("Layers rendered").lastSampleCount,n.pickLayersCount=r.get("Layers picked").lastSampleCount,n.updateLayersCount=r.get("Layer updates").count,n.updateAttributesCount=r.get("Attributes updated").count,n.gpuTime=r.get("GPU Time").time,n.cpuTime=r.get("CPU Time").time,n.gpuTimePerFrame=r.get("GPU Time").getAverageTime(),n.cpuTimePerFrame=r.get("CPU Time").getAverageTime();let c=UD.stats.get("GPU Time and Memory");n.bufferMemory=c.get("Buffer Memory").count,n.textureMemory=c.get("Texture Memory").count,n.renderbufferMemory=c.get("Renderbuffer Memory").count,n.gpuMemory=c.get("GPU Memory").count}};RV.defaultProps=J0t;RV.VERSION=sht;var CRe=RV;Vr();Vr();function Q0t(s){switch(s){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return JL(s)}}var ebt=Md.getDataType.bind(Md);function IV(s,n,r){if(n.size>4)return null;let c=r==="webgpu"&&n.type==="uint8"?"unorm8":n.type,u=n.size,d=!!(r!=="webgpu"&&u===3&&c&&["uint8","sint8","unorm8","snorm8","uint16","sint16","unorm16","snorm16"].includes(c));return{attribute:s,format:u>1?`${c}x${u}${d?"-webgl":""}`:n.type,byteOffset:n.offset||0}}function Rb(s){return s.stride||s.size*s.bytesPerElement}function tbt(s,n){return s.type===n.type&&s.size===n.size&&Rb(s)===Rb(n)&&(s.offset||0)===(n.offset||0)}function ARe(s,n){n.offset&&Bs.removed("shaderAttribute.offset","vertexOffset, elementOffset")();let r=Rb(s),c=n.vertexOffset!==void 0?n.vertexOffset:s.vertexOffset||0,u=n.elementOffset||0,d=c*r+u*s.bytesPerElement+(s.offset||0);return{...n,offset:d,stride:r}}function ynn(s,n){let r=ARe(s,n);return{high:r,low:{...r,offset:r.offset+s.size*4}}}var DV=class{constructor(n,r,c){this._buffer=null,this.device=n,this.id=r.id||"",this.size=r.size||1;let u=r.logicalType||r.type,d=u==="float64",{defaultValue:b}=r;b=Number.isFinite(b)?[b]:b||new Array(this.size).fill(0);let w;d?w="float32":!u&&r.isIndexed?w="uint32":w=u||"float32";let _=Q0t(u||w);this.doublePrecision=d,d&&r.fp64===!1&&(_=Float32Array),this.value=null,this.settings={...r,defaultType:_,defaultValue:b,logicalType:u,type:w,normalized:w.includes("norm"),size:this.size,bytesPerElement:_.BYTES_PER_ELEMENT},this.state={...c,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){let n=this.getAccessor();return n.vertexOffset?n.vertexOffset*Rb(n):0}get numInstances(){return this.state.numInstances}set numInstances(n){this.state.numInstances=n}get isDoublePrecisionBuffer(){return this._shouldSplitDoublePrecisionValue(this.value)}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),pv.release(this.state.allocatedValue),this.state.allocatedValue=null}getBuffer(){return this.state.constant&&this.device.type!=="webgpu"?null:this.state.externalBuffer||this._buffer}getValue(n=this.id,r=null){let c={};if(this.state.constant){let u=this.value;if(this.device.type==="webgpu"&&this._buffer)c[n]=this._buffer;else if(r){let d=ARe(this.getAccessor(),r),b=d.offset/u.BYTES_PER_ELEMENT,w=d.size||this.size;c[n]=u.subarray(b,b+w)}else c[n]=u}else c[n]=this.getBuffer();return this.doublePrecision&&(this.isDoublePrecisionBuffer?c[`${n}64Low`]=c[n]:c[`${n}64Low`]=new Float32Array(this.size)),c}_getBufferLayout(n=this.id,r=null){let c=this.getAccessor(),u=[],d={name:this.id,byteStride:this.device.type==="webgpu"&&this.state.constant?0:Rb(c)};if(this.doublePrecision){let b=ynn(c,r||{});u.push(IV(n,{...c,...b.high},this.device.type),IV(`${n}64Low`,{...c,...b.low},this.device.type))}else if(r){let b=ARe(c,r);u.push(IV(n,{...c,...b},this.device.type))}else u.push(IV(n,c,this.device.type));return d.attributes=u.filter(Boolean),d}setAccessor(n){this.state.bufferAccessor=n}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let n=null;if(this.state.constant&&this.value){let r=Array.from(this.value);n=[r,r]}else{let{value:r,numInstances:c,size:u}=this,d=c*u;if(r&&d&&r.length>=d){let b=new Array(u).fill(1/0),w=new Array(u).fill(-1/0);for(let _=0;_w[x]&&(w[x]=T)}n=[b,w]}}return this.state.bounds=n,n}setData(n){let{state:r}=this,c;ArrayBuffer.isView(n)?c={value:n}:n instanceof cs?c={buffer:n}:c=n;let u={...this.settings,...c};if(ArrayBuffer.isView(c.value)){if(!c.type)if(this.doublePrecision&&c.value instanceof Float64Array)u.type="float32";else{let b=ebt(c.value);u.type=u.normalized?b.replace("int","norm"):b}u.bytesPerElement=c.value.BYTES_PER_ELEMENT,u.stride=Rb(u)}if(r.bounds=null,c.constant){let d=c.value;if(d=this._normalizeValue(d,[],0),this.settings.normalized&&(d=this.normalizeConstant(d)),!(!r.constant||!this._areValuesEqual(d,this.value)))return!1;r.externalBuffer=null,r.constant=!0,this.value=ArrayBuffer.isView(d)?d:new Float32Array(d)}else if(c.buffer){let d=c.buffer;r.externalBuffer=d,r.constant=!1,this.value=c.value||null}else if(c.value){this._checkExternalBuffer(c);let d=c.value,b=d;r.externalBuffer=null,r.constant=!1,this.value=d,this._shouldSplitDoublePrecisionValue(b)&&(b=uB(b,u),d instanceof Float32Array&&(u.stride=u.size*2*Float32Array.BYTES_PER_ELEMENT));let{buffer:w}=this,_=Rb(u),x=(u.vertexOffset||0)*_;if(this.settings.isIndexed){let M=this.settings.defaultType;b.constructor!==M&&(b=new M(b))}let T=b.byteLength+x+_*2;(!w||w.byteLength(r+128)/255*2-1);case"snorm16":return new Float32Array(n).map(r=>(r+32768)/65535*2-1);case"unorm8":return new Float32Array(n).map(r=>r/255);case"unorm16":return new Float32Array(n).map(r=>r/65535);default:return n}}_normalizeValue(n,r,c){let{defaultValue:u,size:d}=this.settings;if(Number.isFinite(n))return r[c]=n,r;if(!n){let b=d;for(;--b>=0;)r[c+b]=u[b];return r}switch(d){case 4:r[c+3]=Number.isFinite(n[3])?n[3]:u[3];case 3:r[c+2]=Number.isFinite(n[2])?n[2]:u[2];case 2:r[c+1]=Number.isFinite(n[1])?n[1]:u[1];case 1:r[c+0]=Number.isFinite(n[0])?n[0]:u[0];break;default:let b=d;for(;--b>=0;)r[c+b]=Number.isFinite(n[b])?n[b]:u[b]}return r}_areValuesEqual(n,r){if(!n||!r)return!1;let{size:c}=this;for(let u=0;u0&&(ibt.length=s.length,c=ibt):c=nbt,(n>0||Number.isFinite(r))&&(c=(Array.isArray(c)?c:Array.from(c)).slice(n,r),u.index=n-1),{iterable:c,objectInfo:u}}function mue(s){return s&&s[Symbol.asyncIterator]}function bue(s,n){let{size:r,stride:c,offset:u,startIndices:d,nested:b}=n,w=s.BYTES_PER_ELEMENT,_=c?c/w:r,x=u?u/w:0,T=Math.floor((s.length-x)/_);return(M,{index:L,target:I})=>{if(!d){let z=L*_+x;for(let Z=0;Z=n[1]))return s;let r=[],c=s.length,u=0;for(let d=0;dn[1]?r.push(b):n=[Math.min(b[0],n[0]),Math.max(b[1],n[1])]}return r.splice(u,0,n),r}var Enn={interpolation:{duration:0,easing:s=>s},spring:{stiffness:.05,damping:.5}};function wue(s,n){if(!s)return null;Number.isFinite(s)&&(s={type:"interpolation",duration:s});let r=s.type||"interpolation";return{...Enn[r],...n,...s,type:r}}var k4=class extends DV{constructor(n,r){super(n,r,{startIndices:null,constantValue:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:BV}),this.constant=!1,this.settings.update=r.update||(r.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(n){this.state.startIndices=n}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:n=!1}={}){let r=this.state.needsRedraw;return this.state.needsRedraw=r&&!n,r}layoutChanged(){return this.state.layoutChanged}setAccessor(n){var r;(r=this.state).layoutChanged||(r.layoutChanged=!tbt(n,this.getAccessor())),super.setAccessor(n)}getUpdateTriggers(){let{accessor:n}=this.settings;return[this.id].concat(typeof n!="function"&&n||[])}supportsTransition(){return!!this.settings.transition}getTransitionSetting(n){if(!n||!this.supportsTransition())return null;let{accessor:r}=this.settings,c=this.settings.transition,u=Array.isArray(r)?n[r.find(d=>n[d])]:n[r];return wue(u,c)}setNeedsUpdate(n=this.id,r){if(this.state.needsUpdate=this.state.needsUpdate||n,this.setNeedsRedraw(n),r){let{startRow:c=0,endRow:u=1/0}=r;this.state.updateRanges=sbt(this.state.updateRanges,[c,u])}else this.state.updateRanges=BV}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=rbt}setNeedsRedraw(n=this.id){this.state.needsRedraw=this.state.needsRedraw||n}allocate(n){let{state:r,settings:c}=this;if(c.noAlloc)return!1;if(c.update){let u=this.isConstant;return super.allocate(n,r.updateRanges!==BV),r.layoutChanged||(r.layoutChanged=u&&this.device.type==="webgpu"),!0}return!1}updateBuffer({numInstances:n,data:r,props:c,context:u}){if(!this.needsUpdate())return!1;let{state:{updateRanges:d},settings:{update:b,noAlloc:w}}=this,_=!0;if(b){for(let[x,T]of d)b.call(u,this,{data:r,startRow:x,endRow:T,props:c,numInstances:n});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLengthT?x.set(H,F):(n._normalizeValue(H,z.target,0),g1t({target:x,source:z.target,start:F,count:te}));F+=te*T}else n._normalizeValue(H,x,F),F+=T}}_validateAttributeUpdaters(){let{settings:n}=this;if(!(n.noAlloc||typeof n.update=="function"))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){let{value:n}=this,r=Math.min(4,this.size);if(n&&n.length>=r){let c=!0;switch(r){case 4:c=c&&Number.isFinite(n[3]);case 3:c=c&&Number.isFinite(n[2]);case 2:c=c&&Number.isFinite(n[1]);case 1:c=c&&Number.isFinite(n[0]);break;default:c=!1}if(!c)throw new Error(`Illegal attribute generated for ${this.id}`)}}};F3();DRe();F3();var NV=class s{gpuDataEvaluators;format;length;id;_gpuVector;_ownsGPUDataEvaluators;_destroyed=!1;static fromGPUVector(n){if(n.bufferLayout)throw new Error(`GPUVectorEvaluator.fromGPUVector() does not accept interleaved vector "${n.name}"`);if(n.data.length===0)throw new Error(`GPUVectorEvaluator.fromGPUVector() requires GPUData for "${n.name}"`);return new s({id:n.name,gpuDataEvaluators:n.data.map(r=>fc.fromGPUData(r,{id:n.name})),gpuVector:n,format:n.format})}static fromGPUDataEvaluators(n,r={}){return new s({id:r.id,gpuDataEvaluators:n,format:r.format})}constructor({id:n,gpuDataEvaluators:r,gpuVector:c,format:u}){if(r.length===0)throw new Error("GPUVectorEvaluator requires at least one GPUData evaluator");Onn(r),this.id=n,this.gpuDataEvaluators=r,this.format=u??r[0].format,this.length=r.reduce((d,b)=>d+b.length,0),this._gpuVector=c,this._ownsGPUDataEvaluators=!c}get evaluated(){return!!this._gpuVector}get gpuVector(){if(!this._gpuVector)throw new Error(`${this} not evaluated`);return this._gpuVector}mapGPUData(n){return s.fromGPUDataEvaluators(this.gpuDataEvaluators.map((r,c)=>n(r,c)),{id:this.id})}async evaluate(n,r={}){if(this._destroyed)throw new Error(`GPUVectorEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let c=await Promise.all(this.gpuDataEvaluators.map(w=>w.evaluate(n,r))),u=c[0],d=c.map(bbt),b=r.format??this.format??u.format;return this._gpuVector=new c2({type:"data",name:r.name??this.id??"vector",format:b,data:d,stride:u.stride,byteStride:u.byteStride,rowByteLength:u.rowByteLength,bufferLayout:u.bufferLayout}),this._gpuVector}evaluateSync(n,r={}){if(this._destroyed)throw new Error(`GPUVectorEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let c=this.gpuDataEvaluators.map(w=>w.evaluateSync(n,r)),u=c[0],d=c.map(bbt),b=r.format??this.format??u.format;return this._gpuVector=new c2({type:"data",name:r.name??this.id??"vector",format:b,data:d,stride:u.stride,byteStride:u.byteStride,rowByteLength:u.rowByteLength,bufferLayout:u.bufferLayout}),this._gpuVector}destroy(){if(this._ownsGPUDataEvaluators)for(let n of this.gpuDataEvaluators)n.destroy();this._gpuVector=void 0,this._destroyed=!0}toString(){return this.id??this.constructor.name}};function Onn(s){let n=s[0];for(let r of s.slice(1))if(r.type!==n.type||r.size!==n.size||r.normalized!==n.normalized||r.format!==n.format)throw new Error("GPUVectorEvaluator requires matching GPUData evaluator layouts")}function bbt(s){let[n,...r]=s.data;if(!n||r.length>0)throw new Error(`GPUVectorEvaluator requires one GPUData chunk for "${s.name}"`);return n}F3();Vr();var FRe={};Oy(FRe,{arithmetic:()=>wbt,dot:()=>Sbt,equalAll:()=>Mbt,extent:()=>_bt,fround:()=>ybt,gather:()=>xbt,interleave:()=>Ebt,length:()=>Tbt,segmentedMap:()=>Cbt,select:()=>Abt,sequence:()=>Pbt,swizzle:()=>Lbt});Tue();function TB({elementWise:s,func:n,inputs:r,output:c,outputBuffer:u}){let d=Array.isArray(r)?r:Object.values(r);for(let D of d)if(!D.value)throw new Error(`${D} does not have CPU value`);let b=c.length,w=c.size,_=new c.ValueType(b*w);for(let D=0;Dpf(O,D));if(s)for(let O=0;Oz[O]));else n.call(null,_.subarray(D*w,D*w+w),...F)}let x=c.ValueType.BYTES_PER_ELEMENT,T=c.offset/x,M=c.stride/x,L=w,I=_;if(T!==0||M!==L){I=new c.ValueType(T+c.byteLength/x);for(let D=0;D{for(let u of Object.values(s.namedInputs))if(!u.value)throw new Error(`${u} does not have CPU value`);let c=new n.ValueType(n.length*n.size);for(let u=0;u[b,pf(w,u)]));for(let b=0;bvbt(u,n,r));switch(s.op){case"add":return c[0]+c[1];case"subtract":return c[0]-c[1];case"multiply":return c[0]*c[1];case"divide":return c[0]/c[1];case"pow":return Math.pow(c[0],c[1]);case"sqrt":return Math.sqrt(c[0]);case"abs":return Math.abs(c[0]);case"sin":return Math.sin(c[0]);case"cos":return Math.cos(c[0]);case"tan":return Math.tan(c[0]);case"exp":return Math.exp(c[0]);case"log":return Math.log(c[0]);default:{let u=s.op;throw new Error(`Unsupported arithmetic op ${u}`)}}}default:{let c=s;throw new Error(`Unsupported expression node ${c.kind}`)}}}function Fnn(s,n){let r=MB[s].arity;if(n!==r)throw new Error(`Arithmetic op '${s}' expects ${r} args, got ${n}`)}var _bt=({inputs:s,output:n,target:r})=>{let{sourceValues:c}=s;if(!c.value)throw new Error(`${c} does not have CPU value`);let d=new n.ValueType(n.length*n.size);if(c.length===0)return{success:!1,error:new Error(`${c} is empty`)};for(let b=0;bd[x]&&(d[x]=M)}}return r.write(d),{success:!0,value:d}};var ybt=({inputs:s,output:n,target:r})=>TB({func:(c,u)=>{let d=c.length/2,b=new Float64Array(u.buffer);for(let w=0;w{let{ids:c,sourceValues:u}=s,d=c.value,b=u.value;if(!d)throw new Error(`${c} does not have CPU value`);if(!b)throw new Error(`${u} does not have CPU value`);let w=new n.ValueType(n.length*n.size),_=new Array(n.size).fill(0);for(let x=0;x=0&&sTB({func:(c,...u)=>{let d=0;for(let b of u)c.set(b,d),d+=b.length},inputs:s,output:n,outputBuffer:r});var Sbt=({inputs:s,output:n,target:r})=>{let{x:c,y:u}=s,d=new n.ValueType(n.length);for(let b=0;b{let{x:c,y:u}=s,d=new n.ValueType(n.length);for(let b=0;b{let{x:c}=s,u=new n.ValueType(n.length);for(let d=0;d{let{segments:c,vertexCount:u}=s,d=c.value;if(!d)throw new Error(`${c} does not have CPU value`);znn(d,c,u);let b=new n.ValueType(n.length*n.size),w=0;for(let _=0;_0&&dr)throw new Error(`segmentedMap last segment start must be <= vertexCount, got ${c} > ${r}`)}function ORe(s,n){return s.offset/s.ValueType.BYTES_PER_ELEMENT+n*(s.stride/s.ValueType.BYTES_PER_ELEMENT)}var Abt=async({inputs:s,output:n,target:r})=>{let{condition:c,whenTrue:u,whenFalse:d}=s,b=new n.ValueType(n.length*n.size);for(let w=0;w{let c=new n.ValueType(n.length);for(let u=0;u{let{columns:c}=s;return TB({func:(u,d)=>{for(let b=0;b({...b,...w}));return this._modules[n]=d,d.then(b=>{this._modules[n]=b}).catch(b=>{Qt.error(`Failed to register ${n} backend: ${b}`)()}),d}if(c&&typeof c.then=="function"){let d=Promise.resolve(c).then(b=>({...b,...r})).then(b=>(this._modules[n]=b,b)).catch(b=>{throw Qt.error(`Failed to register ${n} backend: ${b}`)(),b});return this._modules[n]=d,d}let u={...c||{},...r};return this._modules[n]=u,Promise.resolve(u)}async get(n,r){let c=this._modules[n];if(!c)if(n==="webgl")c=this.add("webgl",Promise.resolve().then(()=>(owt(),swt)));else if(n==="webgpu")c=this.add("webgpu",Promise.resolve().then(()=>(ZRe(),Rwt)));else throw new Error(`${n} backend not registered`);let d=(await c)[r];if(typeof d!="function")throw new Error(`${n} backend does not implement ${r}`);return d}getSync(n,r){let c=this._modules[n];if(!c)throw new Error(`${n} backend not registered`);if(typeof c.then=="function")throw new Error(`${n} backend is not loaded yet`);let d=c[r];if(typeof d!="function")throw new Error(`${n} backend does not implement ${r}`);return d}clear(){this._modules={}}},RB=new KRe;var Bue=class{inputs;dependencies;constructor(n){this.inputs=n,this.dependencies=Array.from(n instanceof Array?n:Object.values(n)).filter(r=>r instanceof fc)}async execute(n,r){return await this._resolveDependencies(n),await this._executeWithHandler(await RB.get(this._getHandlerRegistry(n),this.name),r)}executeSync(n,r){this._resolveDependenciesSync(n);let c=this._executeWithHandler(RB.getSync(this._getHandlerRegistry(n),this.name),r);if(kin(c))throw new Error(`${this.name} returned a Promise in executeSync()`);return c}shouldExecuteOnCPU(){return this.output.length<=1&&Array.from(this.dependencies).every(n=>!!n.value)}_getHandlerRegistry(n){return this.shouldExecuteOnCPU()?"cpu":n.type}async _resolveDependencies(n){for(let c of this.dependencies)await c.evaluate(n);if(this._getHandlerRegistry(n)==="cpu"||n.type==="null")for(let c of this.dependencies)await c.ensureCPUValue()}_resolveDependenciesSync(n){for(let c of this.dependencies)c.evaluateSync(n);if(this._getHandlerRegistry(n)==="cpu"||n.type==="null")for(let c of this.dependencies)c.ensureCPUValueSync()}_executeWithHandler(n,r){return n({device:r.device,inputs:this.inputs,output:this.output,target:r})}};function kin(s){return typeof s?.then=="function"}function Iwt(...s){let n=Rin(s.map(r=>r.type));return n[0]!=="f"&&s.some(r=>r.normalized)&&(n="float32"),{isConstant:s.every(r=>r.isConstant),type:n,size:s.reduce((r,c)=>Math.max(r,c.size),0),length:s.reduce((r,c)=>Math.max(r,c.length),0)}}function Rin(s){let n=0,r=0;for(let c of s){if(c[0]==="f")return"float32";let u=c.endsWith("8")?8:c.endsWith("6")?16:32;c[0]==="u"?n=Math.max(n,u):r=Math.max(r,u)}return n&&!r?`uint${n}`:r&&n<32?`sint${Math.max(r,n*2)}`:"float32"}F3();var JRe=class extends Bue{name="interleave";output;constructor(n){super(n);let{isConstant:r,type:c,length:u}=Iwt(...n);this.output=new fc({isConstant:r,type:c,size:n.reduce((d,b)=>d+b.size,0),length:u,source:this})}toString(){return`_${this.inputs.join("_")}_`}};function QRe(...s){if(s.length===0)throw new Error("interleave() requires at least one input");return s.length===1?Mue(s[0]):new JRe(s.map(Mue)).output}Ql();F3();function tIe(s,n){let r=Din(n);for(let c of r)c.evaluateSync(s);return Iin(r),n}function Iin(s){let n=new Set(s.flatMap(Oin)),r=new Set;for(let c of s)Oue(c,r);for(let c of r)c.evaluated&&!n.has(c.buffer)&&c.destroy()}function Din(s){let n=new Set;return eIe(s,n,new Set),Array.from(n)}function eIe(s,n,r){if(Nin(s)){n.add(s);return}if(!(!s||typeof s!="object"||r.has(s))){if(r.add(s),Array.isArray(s)){for(let c of s)eIe(c,n,r);return}if(Bin(s))for(let c of Object.values(s))eIe(c,n,r)}}function Bin(s){let n=Object.getPrototypeOf(s);return n===Object.prototype||n===null}function Oue(s,n){if(s instanceof NV){for(let c of s.gpuDataEvaluators)Oue(c,n);return}let r=s.source;if(r){if(r instanceof fc){n.has(r)||(n.add(r),Oue(r,n));return}for(let c of r.dependencies)n.has(c)||(n.add(c),Oue(c,n))}}function Oin(s){return s instanceof fc?[s.buffer]:s.gpuVector.data.map(n=>n.buffer instanceof up?n.buffer.buffer:n.buffer)}function Nin(s){return s instanceof fc||s instanceof NV}ZRe();var UV=class{constructor(n,{id:r,isTransitionAttribute:c}){this.packedBuffers={},this.device=n,this.id=r,this.isTransitionAttribute=c,this.device.type==="webgpu"&&RB.add("webgpu",{interleave:Due})}hasGroups(n){return this.device.type==="webgpu"&&Object.values(n).some(r=>!!r.settings.bufferGroup)}finalize(){for(let n of Object.values(this.packedBuffers))n.packed.destroy();this.packedBuffers={}}getBufferLayouts(n,r){let c=this._getPackedGroups(n,r,{requireValues:!1,excludeAttributes:{}});return this._getBufferLayouts(n,c,r)}getBindings(n,r,c,u){let d=this._getPackedGroups(n,c,{requireValues:!0,excludeAttributes:u}),b={},w=new Set;for(let _ of d.values()){let x=!this.packedBuffers[_.id]||_.attributes.some(T=>!!r[T.id]);b[_.id]=this._getPackedBuffer(_,x);for(let T of _.attributes)w.add(T.id)}return{bufferLayouts:this._getBufferLayouts(n,d,c).filter(_=>!u[_.name]&&!n[_.name]?.settings.isIndexed),buffers:b,groupedAttributeIds:w}}_getPackedGroups(n,r,{requireValues:c,excludeAttributes:u}){let d=new Map;for(let w of Object.values(n)){let _=w.settings.bufferGroup;if(!_)continue;let x=d.get(_)||[];x.push(w),d.set(_,x)}let b=new Map;for(let[w,_]of d){let x=this._getPackedGroup(w,_,r,c,u);x&&b.set(w,x)}return b}_getPackedGroup(n,r,c,u,d){if(r.length<2)return null;let b=r.map(I=>I.getBufferLayout(c)),w=b[0].stepMode,_=Math.max(1,r[0].numInstances),x=u&&r.every(I=>I.isConstant);for(let I=0;Ithis._getInterleaveInput(n,u)),c=QRe(...r);return tIe(this.device,c),c}_getInterleaveInput(n,r){let c=Rb(r.getAccessor()),u=n.byteOffsets[r.id];if(FV(`${n.id}.${r.id} rowByteLength`,c),FV(`${n.id}.${r.id} groupByteOffset`,u),r.isConstant){let _=r.getConstantValue();if(!_)throw new Error(`Attribute group ${n.id} is missing constant value ${r.id}`);return FV(`${n.id}.${r.id} constant byteOffset`,_.byteOffset),new fc({id:r.id,type:"uint32",size:c/4,isConstant:!0,value:new Uint32Array(_.buffer,_.byteOffset,c/Uint32Array.BYTES_PER_ELEMENT)})}let d=r.getBuffer(),b=r.byteOffset,w=r.getAccessor().stride||c;if(FV(`${n.id}.${r.id} byteOffset`,b),FV(`${n.id}.${r.id} stride`,w),!d)throw new Error(`Attribute group ${n.id} cannot interleave missing buffer ${r.id}`);return new fc({id:r.id,type:"uint32",size:c/4,offset:b,stride:w,length:n.rowCount,buffer:d})}};function Dwt(s){return Math.ceil(s/4)*4}function FV(s,n){if(n%4!==0)throw new Error(`Attribute buffer groups require 32-bit alignment: ${s}=${n}`)}Ql();vm();function nIe(s){let{source:n,target:r,start:c=0,size:u,getData:d}=s,b=s.end||r.length,w=n.length,_=b-c;if(w>_){r.set(n.subarray(0,_),c);return}if(r.set(n,c),!d)return;let x=w;for(;x<_;){let T=d(x,n);for(let M=0;Mc(T+w,M)),x=Math.min(u.length,d.length);for(let T=1;Tw}){let w=r.isDoublePrecisionBuffer?2:1,_=r.size*w,x=r.byteOffset,T=r.settings.bytesPerElement<4?x/r.settings.bytesPerElement*4:x,M=r.startIndices,L=d&&M,I=r.isConstant;if(!L&&n&&c>=u)return n;let D=r.value instanceof Float64Array?Float32Array:r.value.constructor,F=I?r.value:new D(r.getBuffer().readSyncWebGL(x,u*D.BYTES_PER_ELEMENT).buffer);if(r.settings.normalized&&!I){let H=b;b=(te,oe)=>r.normalizeConstant(H(te,oe))}let O=I?(H,te)=>b(F,te):(H,te)=>b(F.subarray(H+x,H+x+_),te),z=n?new Float32Array(n.readSyncWebGL(T,c*4).buffer):new Float32Array(0),Z=new Float32Array(u);return Bwt({source:z,target:Z,sourceStartIndices:d,targetStartIndices:M,size:_,getData:O}),(!n||n.byteLength0||u.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}},Uin=`layout(std140) uniform springUniforms { +`;function Uwt(s){return s.isDoublePrecisionBuffer}function Gin(s,n){let r=n.size,c=Nue(r),u=Fue(r),d=n.getBufferLayout();return Uwt(n)?new fp(s,{vs:zin,bufferLayout:[{name:"aFrom",byteStride:8*r,attributes:[{attribute:"aFrom",format:u,byteOffset:0},{attribute:"aFrom64Low",format:u,byteOffset:4*r}]},{name:"aTo",byteStride:8*r,attributes:[{attribute:"aTo",format:u,byteOffset:0},{attribute:"aTo64Low",format:u,byteOffset:4*r}]}],modules:[lke,Fwt],defines:{ATTRIBUTE_TYPE:c,ATTRIBUTE_SIZE:r},moduleSettings:{},varyings:["vCurrent","vCurrent64Low"],bufferMode:35980,disableWarnings:!0}):new fp(s,{vs:Uin,bufferLayout:[{name:"aFrom",format:u},{name:"aTo",format:d.attributes[0].format}],modules:[Fwt],defines:{ATTRIBUTE_TYPE:c},varyings:["vCurrent"],disableWarnings:!0})}Ql();var GV=class extends IB{constructor({device:n,attribute:r,timeline:c}){super({device:n,attribute:r,timeline:c}),this.type="spring",this.texture=qin(n),this.framebuffer=Xin(n,this.texture),this.transform=Hin(n,r)}start(n,r){let c=this.currentLength,u=this.currentStartIndices;super.start(n,r);let{buffers:d,attribute:b}=this;for(let _=0;_<2;_++)d[_]=Gue({device:this.device,buffer:d[_],attribute:b,fromLength:c,toLength:this.currentLength,fromStartIndices:u,getData:n.enter});d[2]=zue({device:this.device,source:d[0],target:d[2]}),this.setBuffer(d[1]);let{model:w}=this.transform;w.setVertexCount(Math.floor(this.currentLength/b.size)),b.isConstant?w.setConstantAttributes({aTo:b.value}):w.setAttributes({aTo:b.getBuffer()})}onUpdate(){let{buffers:n,transform:r,framebuffer:c,transition:u}=this,d=this.settings;r.model.setAttributes({aPrev:n[0],aCur:n[1]}),r.transformFeedback.setBuffers({vNext:n[2]});let b={stiffness:d.stiffness,damping:d.damping};r.model.shaderInputs.setProps({spring:b}),r.run({framebuffer:c,discard:!1,parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]}),Uue(n),this.setBuffer(n[1]),this.device.readPixelsToArrayWebGL(c)[0]>0||u.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}},jin=`layout(std140) uniform springUniforms { float damping; float stiffness; } spring; -`,zin={name:"spring",vs:Uin,uniformTypes:{damping:"f32",stiffness:"f32"}},Gin=`#version 300 es +`,$in={name:"spring",vs:jin,uniformTypes:{damping:"f32",stiffness:"f32"}},Vin=`#version 300 es #define SHADER_NAME spring-transition-vertex-shader #define EPSILON 0.00001 @@ -4238,7 +4238,7 @@ void main(void) { gl_Position = vec4(0, 0, 0, 1); gl_PointSize = 100.0; } -`,jin=`#version 300 es +`,Win=`#version 300 es #define SHADER_NAME spring-transition-is-transitioning-fragment-shader in float vIsTransitioningFlag; @@ -4250,7 +4250,7 @@ void main(void) { discard; } fragColor = vec4(1.0); -}`;function $in(s,n){let r=Nue(n.size),c=Fue(n.size);return new fp(s,{vs:Gin,fs:jin,bufferLayout:[{name:"aPrev",format:c},{name:"aCur",format:c},{name:"aTo",format:n.getBufferLayout().attributes[0].format}],varyings:["vNext"],modules:[zin],defines:{ATTRIBUTE_TYPE:r},parameters:{depthCompare:"always",blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}})}function Vin(s){return s.createTexture({data:new Uint8Array(4),format:"rgba8unorm",width:1,height:1})}function Win(s,n){return s.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[n]})}var Hin={interpolation:zV,spring:GV},jV=class{constructor(n,{id:r,timeline:c}){if(!n)throw new Error("AttributeTransitionManager is constructed without device");this.id=r,this.device=n,this.timeline=c,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(let n in this.transitions)this._removeTransition(n)}update({attributes:n,transitions:r,numInstances:c}){this.numInstances=c||1;for(let u in n){let d=n[u],b=d.getTransitionSetting(r);b&&this._updateAttribute(u,d,b)}for(let u in this.transitions){let d=n[u];(!d||!d.getTransitionSetting(r))&&this._removeTransition(u)}}hasAttribute(n){let r=this.transitions[n];return r&&r.inProgress}getAttributes(){let n={};for(let r in this.transitions){let c=this.transitions[r];c.inProgress&&(n[r]=c.attributeInTransition)}return n}run(){if(this.numInstances===0)return!1;for(let r in this.transitions)this.transitions[r].update()&&(this.needsRedraw=!0);let n=this.needsRedraw;return this.needsRedraw=!1,n}_removeTransition(n){this.transitions[n].delete(),delete this.transitions[n]}_updateAttribute(n,r,c){let u=this.transitions[n],d=!u||u.type!==c.type;if(d){u&&this._removeTransition(n);let b=Hin[c.type];b?this.transitions[n]=new b({attribute:r,timeline:this.timeline,device:this.device}):(Bs.error(`unsupported transition type '${c.type}'`)(),d=!1)}(d||r.needsRedraw())&&(this.needsRedraw=!0,this.transitions[n].start(c,this.numInstances))}};var zwt="attributeManager.invalidate",qin="attributeManager.updateStart",Xin="attributeManager.updateEnd",Yin="attribute.updateStart",Zin="attribute.allocate",Kin="attribute.updateEnd",$V=class{constructor(n,{id:r="attribute-manager",stats:c,timeline:u}={}){this.mergeBoundsMemoized=Yy(kmt),this.id=r,this.device=n,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=c,this.attributeTransitionManager=new jV(n,{id:`${r}-transitions`,timeline:u}),this.attributeBufferGroups=n.type==="webgpu"?new UV(n,{id:r,isTransitionAttribute:d=>this.attributeTransitionManager.hasAttribute(d)}):null,Object.seal(this)}finalize(){this.attributeBufferGroups?.finalize();for(let n in this.attributes)this.attributes[n].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(n={clearRedrawFlags:!1}){let r=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!n.clearRedrawFlags,r&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(n){this._add(n)}addInstanced(n){this._add(n,{stepMode:"instance"})}remove(n){for(let r of n)this.attributes[r]!==void 0&&(this.attributes[r].delete(),delete this.attributes[r])}invalidate(n,r){let c=this._invalidateTrigger(n,r);Df(zwt,this,n,c)}invalidateAll(n){for(let r in this.attributes)this.attributes[r].setNeedsUpdate(r,n);Df(zwt,this,"all")}update({data:n,numInstances:r,startIndices:c=null,transitions:u,props:d={},buffers:b={},context:w={}}){let _=!1;Df(qin,this),this.stats&&this.stats.get("Update Attributes").timeStart();for(let x in this.attributes){let T=this.attributes[x],M=T.settings.accessor;T.startIndices=c,T.numInstances=r,d[x]&&Bs.removed(`props.${x}`,`data.attributes.${x}`)(),T.setExternalBuffer(b[x])||T.setBinaryValue(typeof M=="string"?b[M]:void 0,n.startIndices)||typeof M=="string"&&!b[M]&&T.setConstantValue(w,d[M])||T.needsUpdate()&&(_=!0,this._updateAttribute({attribute:T,numInstances:r,data:n,props:d,context:w})),this.needsRedraw=this.needsRedraw||T.needsRedraw()}_&&Df(Xin,this,r),this.stats&&(this.stats.get("Update Attributes").timeEnd(),_&&this.stats.get("Attributes updated").incrementCount()),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:r,transitions:u})}updateTransition(){let{attributeTransitionManager:n}=this,r=n.run();return this.needsRedraw=this.needsRedraw||r,r}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(n){let r=n.map(c=>this.attributes[c]?.getBounds());return this.mergeBoundsMemoized(r)}getChangedAttributes(n={clearChangedFlags:!1}){let{attributes:r,attributeTransitionManager:c}=this,u={...c.getAttributes()};for(let d in r){let b=r[d];b.needsRedraw(n)&&!c.hasAttribute(d)&&(u[d]=b)}return u}getBufferLayouts(n){return this.hasBufferGroups()?this.attributeBufferGroups.getBufferLayouts(this.getAttributes(),n):Object.values(this.getAttributes()).map(r=>r.getBufferLayout(n))}hasBufferGroups(){return!!this.attributeBufferGroups?.hasGroups(this.attributes)}getBufferGroupBindings(n,r,c={}){return this.attributeBufferGroups?this.attributeBufferGroups.getBindings(this.getAttributes(),n,r,c):{bufferLayouts:this.getBufferLayouts(r),buffers:{},groupedAttributeIds:new Set}}_add(n,r){for(let c in n){let u=n[c],d={...u,id:c,size:u.isIndexed&&1||u.size||1,...r};this.attributes[c]=new k4(this.device,d)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){let n={};for(let r in this.attributes)this.attributes[r].getUpdateTriggers().forEach(u=>{n[u]||(n[u]=[]),n[u].push(r)});this.updateTriggers=n}_invalidateTrigger(n,r){let{attributes:c,updateTriggers:u}=this,d=u[n];return d&&d.forEach(b=>{let w=c[b];w&&w.setNeedsUpdate(w.id,r)}),d}_updateAttribute(n){let{attribute:r,numInstances:c}=n;if(Df(Yin,r),r.constant){r.setConstantValue(n.context,r.value);return}r.allocate(c)&&Df(Zin,r,c),r.updateBuffer(n)&&(this.needsRedraw=!0,Df(Kin,r,c))}};Vr();fue();Of();var VV=class extends mv{get value(){return this._value}_onUpdate(){let{time:n,settings:{fromValue:r,toValue:c,duration:u,easing:d}}=this,b=d(n/u);this._value=lv(r,c,b)}};var Gwt=1e-5;function jwt(s,n,r,c,u){let d=n-s,w=(r-n)*u,_=-d*c;return w+_+d+n}function Jin(s,n,r,c,u){if(Array.isArray(r)){let d=[];for(let b=0;b0}add(n,r,c,u){let{transitions:d}=this;if(d.has(n)){let _=d.get(n),{value:x=_.settings.fromValue}=_;r=x,this.remove(n)}if(u=wue(u),!u)return;let b=Qin[u.type];if(!b){Bs.error(`unsupported transition type '${u.type}'`)();return}let w=new b(this.timeline);w.start({...u,fromValue:r,toValue:c}),d.set(n,w)}remove(n){let{transitions:r}=this;r.has(n)&&(r.get(n).cancel(),r.delete(n))}update(){let n={};for(let[r,c]of this.transitions)c.update(),n[r]=c.value,c.inProgress||this.remove(r);return n}clear(){for(let n of this.transitions.keys())this.remove(n)}};function Wwt(s){let n=s[t2];for(let r in n){let c=n[r],{validate:u}=c;if(u&&!u(s[r],c))throw new Error(`Invalid prop ${r}: ${s[r]}`)}}function Hwt(s,n){let r=qwt({newProps:s,oldProps:n,propTypes:s[t2],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),c=trn(s,n),u=!1;return c||(u=nrn(s,n)),{dataChanged:c,propsChanged:r,updateTriggersChanged:u,extensionsChanged:irn(s,n),transitionsChanged:ern(s,n)}}function ern(s,n){if(!s.transitions)return!1;let r={},c=s[t2],u=!1;for(let d in s.transitions){let b=c[d],w=b&&b.type;(w==="number"||w==="color"||w==="array")&&iIe(s[d],n[d],b)&&(r[d]=!0,u=!0)}return u?r:!1}function qwt({newProps:s,oldProps:n,ignoreProps:r={},propTypes:c={},triggerName:u="props"}){if(n===s)return!1;if(typeof s!="object"||s===null)return`${u} changed shallowly`;if(typeof n!="object"||n===null)return`${u} changed shallowly`;for(let d of Object.keys(s))if(!(d in r)){if(!(d in n))return`${u}.${d} added`;let b=iIe(s[d],n[d],c[d]);if(b)return`${u}.${d} ${b}`}for(let d of Object.keys(n))if(!(d in r)){if(!(d in s))return`${u}.${d} dropped`;if(!Object.hasOwnProperty.call(s,d)){let b=iIe(s[d],n[d],c[d]);if(b)return`${u}.${d} ${b}`}}return!1}function iIe(s,n,r){let c=r&&r.equal;return c&&!c(s,n,r)||!c&&(c=s&&n&&s.equals,c&&!c.call(s,n))?"changed deeply":!c&&n!==s?"changed shallowly":null}function trn(s,n){if(n===null)return"oldProps is null, initial diff";let r=!1,{dataComparator:c,_dataDiff:u}=s;return c?c(s.data,n.data)||(r="Data comparator detected a change"):s.data!==n.data&&(r="A new data container was supplied"),r&&u&&(r=u(s.data,n.data)||r),r}function nrn(s,n){if(n===null)return{all:!0};if("all"in s.updateTriggers&&Vwt(s,n,"all"))return{all:!0};let r={},c=!1;for(let u in s.updateTriggers)u!=="all"&&Vwt(s,n,u)&&(r[u]=!0,c=!0);return c?r:!1}function irn(s,n){if(n===null)return!0;let r=n.extensions,{extensions:c}=s;if(c===r)return!1;if(!r||!c||c.length!==r.length)return!0;for(let u=0;uc.name==="project64"))){let c=r.modules.findIndex(u=>u.name==="project32");c>=0&&r.modules.splice(c,1)}if("inject"in n)if(!s.inject)r.inject=n.inject;else{let c={...s.inject};for(let u in n.inject)c[u]=(c[u]||"")+n.inject[u];r.inject=c}return r}Vr();var crn={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},rIe={};function Ywt(s,n,r,c){if(r instanceof Pa)return r;r.constructor&&r.constructor.name!=="Object"&&(r={data:r});let u=null;r.compressed&&(u={minFilter:"linear",mipmapFilter:r.data.length>1?"nearest":"linear"});let{width:d,height:b}=r.data,w=n.createTexture({...r,sampler:{...crn,...u,...c},mipLevels:n.getMipLevelCount(d,b)});return n.type==="webgl"?w.generateMipmapsWebGL():n.type==="webgpu"&&n.generateMipmapsWebGPU(w),rIe[w.id]=s,w}function Zwt(s,n){!n||!(n instanceof Pa)||rIe[n.id]===s&&(n.delete(),delete rIe[n.id])}var lrn={boolean:{validate(s,n){return!0},equal(s,n,r){return!!s==!!n}},number:{validate(s,n){return Number.isFinite(s)&&(!("max"in n)||s<=n.max)&&(!("min"in n)||s>=n.min)}},color:{validate(s,n){return n.optional&&!s||sIe(s)&&(s.length===3||s.length===4)},equal(s,n,r){return Ac(s,n,1)}},accessor:{validate(s,n){let r=jue(s);return r==="function"||r===jue(n.value)},equal(s,n,r){return typeof n=="function"?!0:Ac(s,n,1)}},array:{validate(s,n){return n.optional&&!s||sIe(s)},equal(s,n,r){let{compare:c}=r,u=Number.isInteger(c)?c:c?1:0;return c?Ac(s,n,u):s===n}},object:{equal(s,n,r){if(r.ignore)return!0;let{compare:c}=r,u=Number.isInteger(c)?c:c?1:0;return c?Ac(s,n,u):s===n}},function:{validate(s,n){return n.optional&&!s||typeof s=="function"},equal(s,n,r){return!r.compare&&r.ignore!==!1||s===n}},data:{transform:(s,n,r)=>{if(!s)return s;let{dataTransform:c}=r.props;return c?c(s):typeof s.shape=="string"&&s.shape.endsWith("-table")&&Array.isArray(s.data)?s.data:s}},image:{transform:(s,n,r)=>{let c=r.context;return!c||!c.device?null:Ywt(r.id,c.device,s,{...n.parameters,...r.props.textureParameters})},release:(s,n,r)=>{Zwt(r.id,s)}}};function Kwt(s){let n={},r={},c={};for(let[u,d]of Object.entries(s)){let b=d?.deprecatedFor;if(b)c[u]=Array.isArray(b)?b:[b];else{let w=urn(u,d);n[u]=w,r[u]=w.value}}return{propTypes:n,defaultProps:r,deprecatedProps:c}}function urn(s,n){switch(jue(n)){case"object":return qV(s,n);case"array":return qV(s,{type:"array",value:n,compare:!1});case"boolean":return qV(s,{type:"boolean",value:n});case"number":return qV(s,{type:"number",value:n});case"function":return qV(s,{type:"function",value:n,compare:!0});default:return{name:s,type:"unknown",value:n}}}function qV(s,n){return"type"in n?{name:s,...lrn[n.type],...n}:"value"in n?{name:s,type:jue(n.value),...n}:{name:s,type:"object",value:n}}function sIe(s){return Array.isArray(s)||ArrayBuffer.isView(s)}function jue(s){return sIe(s)?"array":s===null?"null":typeof s}function Jwt(s,n){let r;for(let d=n.length-1;d>=0;d--){let b=n[d];"extensions"in b&&(r=b.extensions)}let c=oIe(s.constructor,r),u=Object.create(c);u[bB]=s,u[n2]={},u[gv]={};for(let d=0;d{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(let n in this.asyncProps){let r=this.asyncProps[n];r&&r.type&&r.type.release&&r.type.release(r.resolvedValue,r.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||vrn}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(n){return n in this.asyncProps}getAsyncProp(n){let r=this.asyncProps[n];return r&&r.resolvedValue}isAsyncPropLoading(n){if(n){let r=this.asyncProps[n];return!!(r&&r.pendingLoadCount>0&&r.pendingLoadCount!==r.resolvedLoadCount)}for(let r in this.asyncProps)if(this.isAsyncPropLoading(r))return!0;return!1}reloadAsyncProp(n,r){this._watchPromise(n,Promise.resolve(r))}setAsyncProps(n){this.component=n[bB]||this.component;let r=n[gv]||{},c=n[n2]||n,u=n[I3]||{};for(let d in r){let b=r[d];this._createAsyncPropData(d,u[d]),this._updateAsyncProp(d,b),r[d]=this.getAsyncProp(d)}for(let d in c){let b=c[d];this._createAsyncPropData(d,u[d]),this._updateAsyncProp(d,b)}}_fetch(n,r){return null}_onResolve(n,r){}_onError(n,r){}_updateAsyncProp(n,r){if(this._didAsyncInputValueChange(n,r)){if(typeof r=="string"&&(r=this._fetch(n,r)),r instanceof Promise){this._watchPromise(n,r);return}if(mue(r)){this._resolveAsyncIterable(n,r);return}this._setPropValue(n,r)}}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(let n in this.asyncProps)Object.defineProperty(this.oldAsyncProps,n,{enumerable:!0,value:this.oldProps[n]})}}_didAsyncInputValueChange(n,r){let c=this.asyncProps[n];return r===c.resolvedValue||r===c.lastValue?!1:(c.lastValue=r,!0)}_setPropValue(n,r){this._freezeAsyncOldProps();let c=this.asyncProps[n];c&&(r=this._postProcessValue(c,r),c.resolvedValue=r,c.pendingLoadCount++,c.resolvedLoadCount=c.pendingLoadCount)}_setAsyncPropValue(n,r,c){let u=this.asyncProps[n];u&&c>=u.resolvedLoadCount&&r!==void 0&&(this._freezeAsyncOldProps(),u.resolvedValue=r,u.resolvedLoadCount=c,this.onAsyncPropUpdated(n,r))}_watchPromise(n,r){let c=this.asyncProps[n];if(c){c.pendingLoadCount++;let u=c.pendingLoadCount;r.then(d=>{this.component&&(d=this._postProcessValue(c,d),this._setAsyncPropValue(n,d,u),this._onResolve(n,d))}).catch(d=>{this._onError(n,d)})}}async _resolveAsyncIterable(n,r){if(n!=="data"){this._setPropValue(n,r);return}let c=this.asyncProps[n];if(!c)return;c.pendingLoadCount++;let u=c.pendingLoadCount,d=[],b=0;for await(let w of r){if(!this.component)return;let{dataTransform:_}=this.component.props;_?d=_(w,d):d=d.concat(w),Object.defineProperty(d,"__diff",{enumerable:!1,value:[{startRow:b,endRow:d.length}]}),b=d.length,this._setAsyncPropValue(n,d,u)}this._onResolve(n,d)}_postProcessValue(n,r){let c=n.type;return c&&this.component&&(c.release&&c.release(n.resolvedValue,c,this.component),c.transform)?c.transform(r,c,this.component):r}_createAsyncPropData(n,r){if(!this.asyncProps[n]){let u=this.component&&this.component.props[t2];this.asyncProps[n]={type:u&&u[n],lastValue:null,resolvedValue:r,pendingLoadCount:0,resolvedLoadCount:0}}}};var ZV=class extends YV{constructor({attributeManager:n,layer:r}){super(r),this.attributeManager=n,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1,this.disabledPickingIndices=[]}get layer(){return this.component}_fetch(n,r){let c=this.layer,u=c?.props.fetch;return u?u(r,{propName:n,layer:c}):super._fetch(n,r)}_onResolve(n,r){let c=this.layer;if(c){let u=c.props.onDataLoad;n==="data"&&u&&u(r,{propName:n,layer:c})}}_onError(n,r){let c=this.layer;c&&c.raiseError(r,`loading ${n} of ${this.layer}`)}};var _rn="layer.changeFlag",yrn="layer.initialize",xrn="layer.update",Ern="layer.finalize",Srn="layer.matched",evt=2**24-1,Mrn=Object.freeze([]),Trn=Yy(({oldViewport:s,viewport:n})=>s.equals(n)),Db=new Uint8ClampedArray(0);function tvt(s){return s.rowIndexes||s.pickingColors||s.instancePickingColors}function cIe(s){return s.rowIndexes}function lIe(s){return s.pickingColors||s.instancePickingColors}var Crn={data:{type:"data",value:Mrn,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:s=>s&&s.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(s,{propName:n,layer:r,loaders:c,loadOptions:u,signal:d})=>{let{resourceManager:b}=r.context;u=u||r.getLoadOptions(),c=c||r.props.loaders,d&&(u={...u,core:{...u?.core,fetch:{...u?.core?.fetch,signal:d}}});let w=b.contains(s);return!w&&!u&&(b.add({resourceId:s,data:BD(s,c),persistent:!1}),w=!0),w?b.subscribe({resourceId:s,onChange:_=>r.internalState?.reloadAsyncProp(n,_),consumerId:r.id,requestId:n}):BD(s,c,u)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:"default",coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:s})=>[0,-s*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}},KV=class extends $ue{constructor(){super(...arguments),this.internalState=null,this.lifecycle=XM.NO_STATE,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let n=this;for(;n.parent;)n=n.parent;return n}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(n){La(this.internalState);let r=this.internalState.viewport||this.context.viewport,c=Ele(n,{viewport:r,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[u,d,b]=qM(c,r.pixelProjectionMatrix);return n.length===2?[u,d]:[u,d,b]}unproject(n){return La(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(n)}projectPosition(n,r){La(this.internalState);let c=this.internalState.viewport||this.context.viewport;return Dmt(n,{viewport:c,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...r})}get isComposite(){return!1}get isDrawable(){return!0}setState(n){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,n),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return this.internalState?!this.internalState.isAsyncPropLoading():!1}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){let n=this.state;return n&&(n.models||n.model&&[n.model])||[]}setShaderModuleProps(...n){for(let r of this.getModels())r.shaderInputs.setProps(...n)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){let{coordinateSystem:n}=this.props;return n==="default"||n==="lnglat"||n==="cartesian"}onHover(n,r){return this.props.onHover&&this.props.onHover(n,r)||!1}onClick(n,r){return this.props.onClick&&this.props.onClick(n,r)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(n,r=[]){return r[0]=n+1&255,r[1]=n+1>>8&255,r[2]=n+1>>8>>8&255,r}decodePickingColor(n){La(n instanceof Uint8Array);let[r,c,u]=n;return r+c*256+u*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:Xwt(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds(["positions","instancePositions"])}getShaders(n){n=D4(n,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(let r of this.props.extensions)n=D4(n,r.getShaders.call(this,r));return n}shouldUpdateState(n){return n.changeFlags.propsOrDataChanged}updateState(n){let r=this.getAttributeManager(),{dataChanged:c}=n.changeFlags;if(c&&r)if(Array.isArray(c))for(let u of c)r.invalidateAll(u);else r.invalidateAll();if(r){let{props:u}=n,d=this.internalState.hasPickingBuffer,b=Number.isInteger(u.highlightedObjectIndex)||!!u.pickable||u.extensions.some(w=>w.getNeedsPickingBuffer.call(this,w));if(d!==b){this.internalState.hasPickingBuffer=b;let w=tvt(r.attributes);w&&(b&&w.constant&&(w.constant=!1,r.invalidate(w.id)),!w.value&&!b&&(w.constant=!0,w.value=cIe(r.attributes)?[J$]:[0,0,0]))}}}finalizeState(n){for(let c of this.getModels())c.destroy();let r=this.getAttributeManager();r&&r.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(n){for(let r of this.getModels())r.draw(n.renderPass)}getPickingInfo({info:n,mode:r,sourceLayer:c}){let{index:u}=n;return u>=0&&Array.isArray(this.props.data)&&(n.object=this.props.data[u]),n}raiseError(n,r){r&&(n=new Error(`${r}: ${n.message}`,{cause:n})),this.props.onError?.(n)||this.context?.onError?.(n,this)}getNeedsRedraw(n={clearRedrawFlags:!1}){return this._getNeedsRedraw(n)}needsUpdate(){return this.internalState?this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()):!1}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(n){if(!this.internalState)return;let r=this.internalState.viewport;this.internalState.viewport=n,(!r||!Trn({oldViewport:r,viewport:n}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(n="all"){let r=this.getAttributeManager();r&&(n==="all"?r.invalidateAll():r.invalidate(n))}updateAttributes(n){let r=!1;for(let c in n)n[c].layoutChanged()&&(r=!0);for(let c of this.getModels())this._setModelAttributes(c,n,r)}_updateAttributes(){let n=this.getAttributeManager();if(!n)return;let r=this.props,c=this.getNumInstances(),u=this.getStartIndices();n.update({data:r.data,numInstances:c,startIndices:u,props:r,transitions:r.transitions,buffers:r.data.attributes,context:this});let d=n.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(d)}_updateAttributeTransition(){let n=this.getAttributeManager();n&&n.updateTransition()}_updateUniformTransition(){let{uniformTransitions:n}=this.internalState;if(n.active){let r=n.update(),c=Object.create(this.props);for(let u in r)Object.defineProperty(c,u,{value:r[u]});return c}return this.props}calculateInstancePickingColors(n,{numInstances:r}){if(n.constant)return;let c=Math.floor(Db.length/4);this.internalState.usesPickingColorCache=!0;let u=r>0&&Db[0]===0;if(cevt&&Bs.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),Db=pv.allocate(Db,r,{size:4,copy:!0,maxCount:Math.max(r,evt)});let d=Math.floor(Db.length/4),b=[0,0,0],w=u?0:c;for(let _=w;_(Bs.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),n)}),this.internalState.uniformTransitions=new HV(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(let r of this.props.extensions)r.initializeState.call(this,this.context,r);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(n){Df(Srn,this,this===n);let{state:r,internalState:c}=n;this!==n&&(this.internalState=c,this.state=r,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){let n=this.needsUpdate();if(Df(xrn,this,n),!n)return;this.context.stats.get("Layer updates").incrementCount();let r=this.props,c=this.context,u=this.internalState,d=c.viewport,b=this._updateUniformTransition();u.propsInTransition=b,c.viewport=u.viewport||d,this.props=b;try{let w=this._getUpdateParams(),_=this.getModels();if(c.device)this.updateState(w);else try{this.updateState(w)}catch{}for(let T of this.props.extensions)T.updateState.call(this,w,T);this.setNeedsRedraw(),this._updateAttributes();let x=this.getModels()[0]!==_[0];this._postUpdate(w,x)}finally{c.viewport=d,this.props=r,this._clearChangeFlags(),u.needsUpdate=!1,u.resetOldProps()}}_finalize(){Df(Ern,this),this.finalizeState(this.context);for(let n of this.props.extensions)n.finalizeState.call(this,this.context,n)}_drawLayer({renderPass:n,shaderModuleProps:r=null,uniforms:c={},parameters:u={}}){this._updateAttributeTransition();let d=this.props,b=this.context;this.props=this.internalState.propsInTransition||d;try{r&&this.setShaderModuleProps(r);let{getPolygonOffset:w}=this.props,_=w&&w(c)||[0,0];b.device instanceof KM&&b.device.setParametersWebGL({polygonOffset:_});let x=b.device instanceof KM?null:Arn(u);if(Prn(this.getModels(),n,u,x),b.device instanceof KM)b.device.withParametersWebGL(u,()=>{let T={renderPass:n,shaderModuleProps:r,uniforms:c,parameters:u,context:b};for(let M of this.props.extensions)M.draw.call(this,T,M);this.draw(T)});else{x?.renderPassParameters&&n.setParameters(x.renderPassParameters);let T={renderPass:n,shaderModuleProps:r,uniforms:c,parameters:u,context:b};for(let M of this.props.extensions)M.draw.call(this,T,M);this.draw(T)}}finally{this.props=d}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(n){if(!this.internalState)return;let{changeFlags:r}=this.internalState;for(let u in n)if(n[u]){let d=!1;switch(u){case"dataChanged":let b=n[u],w=r[u];b&&Array.isArray(w)&&(r.dataChanged=Array.isArray(b)?w.concat(b):b,d=!0);default:r[u]||(r[u]=n[u],d=!0)}d&&Df(_rn,this,u,n)}let c=!!(r.dataChanged||r.updateTriggersChanged||r.propsChanged||r.extensionsChanged);r.propsOrDataChanged=c,r.somethingChanged=c||r.viewportChanged||r.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(n,r){let c=Hwt(n,r);if(c.updateTriggersChanged)for(let u in c.updateTriggersChanged)c.updateTriggersChanged[u]&&this.invalidateAttribute(u);if(c.transitionsChanged)for(let u in c.transitionsChanged)this.internalState.uniformTransitions.add(u,r[u],n[u],n.transitions?.[u]);return this.setChangeFlags(c)}validateProps(){Wwt(this.props)}updateAutoHighlight(n){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(n)}_updateAutoHighlight(n){let r={highlightedObjectColor:n.picked?n.color:null},{highlightColor:c}=this.props;n.picked&&typeof c=="function"&&(r.highlightColor=c(n)),this.setShaderModuleProps({picking:r}),this.setNeedsRedraw()}_getAttributeManager(){let n=this.context;return new $V(n.device,{id:this.props.id,stats:n.stats,timeline:n.timeline})}_postUpdate(n,r){let{props:c,oldProps:u}=n,d=this.state.model;d?.isInstanced&&d.setInstanceCount(this.getNumInstances());let{autoHighlight:b,highlightedObjectIndex:w,highlightColor:_}=c;if(r||u.autoHighlight!==b||u.highlightedObjectIndex!==w||u.highlightColor!==_){let x={};Array.isArray(_)&&(x.highlightColor=_),(r||u.autoHighlight!==b||w!==u.highlightedObjectIndex)&&(x.highlightedObjectColor=Number.isFinite(w)&&w>=0?this.encodePickingColor(w):null),this.setShaderModuleProps({picking:x})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(n){if(!this.internalState)return!1;let r=!1;r=r||this.internalState.needsRedraw&&this.id;let c=this.getAttributeManager(),u=c?c.getNeedsRedraw(n):!1;if(r=r||u,r)for(let d of this.props.extensions)d.onNeedsRedraw.call(this,d);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!n.clearRedrawFlags,r}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}};KV.defaultProps=Crn;KV.layerName="Layer";var z3=KV;function Arn(s){let{blendConstant:n,...r}=s;return n?{pipelineParameters:r,renderPassParameters:{blendConstant:n}}:{pipelineParameters:r}}function Prn(s,n,r,c){for(let u of s)u.device.type==="webgpu"?(Lrn(u,n),u.setParameters({...u.parameters,...c?.pipelineParameters})):u.setParameters(r)}function Lrn(s,n){let r=n.props.framebuffer||(n.framebuffer??null);if(!r)return;let c=r.colorAttachments.map(b=>b?.texture?.format??null),u=r.depthStencilAttachment?.texture?.format,d=s;(!krn(d.props.colorAttachmentFormats,c)||d.props.depthStencilAttachmentFormat!==u)&&(d.props.colorAttachmentFormats=c,d.props.depthStencilAttachmentFormat=u,d._setPipelineNeedsUpdate("attachment formats"))}function krn(s,n){if(s===n)return!0;if(!s||!n||s.length!==n.length)return!1;for(let r=0;r{let ne=L.slice();ne[oe]+=1;let ue=D.project(ne)[oe]-O[oe];return Number.isFinite(ue)?ue:2**(oe===0?_:x)*(oe===0?1:-1)}),Z=z.map((oe,ne)=>{let ue=ne===0?F.left:F.top,Te=ne===0?F.right:F.bottom,Q=Math.abs(oe);return oe>=0?[ue/Q,Te/Q]:[Te/Q,ue/Q]}),H=L.slice(),te=[I.width,I.height];for(let[oe,[ne,ue]]of Z.entries()){if(te[oe]<0)continue;let{minimum:Te,maximum:Q,midpoint:ge,settledTarget:Qe}=Drn(T,oe,ne,ue,L[oe]);if(r?.mode!=="preserve"&&M&&(!Number.isFinite(ne)||!Number.isFinite(ue))){H[oe]=ge;continue}let st=M?Qe:Kl(L[oe],Te,Q);H[oe]=r?.mode==="preserve"?L[oe]:w?ZM(L[oe],st,(oe===0?I.width:I.height)/2/Math.abs(z[oe])):st}(H[0]!==L[0]||H[1]!==L[1])&&(n.target=H)}return n}_constrainZoom({zoomX:n,zoomY:r},c){c||(c=this.getViewportProps());let{zoomAxis:u,maxZoomX:d,maxZoomY:b,maxBounds:w}=c,{minZoomX:_,minZoomY:x}=c;if(w!==null&&c.width>0&&c.height>0){let M=wB(c.width,c.height,c.maxBoundsPadding),L=w[0],I=w[1],D=I[0]-L[0],F=I[1]-L[1];M.width>0&&Number.isFinite(D)&&D>0&&(_=Math.max(_,Math.log2(M.width/D)),_>d&&(_=d)),M.height>0&&Number.isFinite(F)&&F>0&&(x=Math.max(x,Math.log2(M.height/F)),x>b&&(x=b))}switch(u){case"X":n=Kl(n,_,d);break;case"Y":r=Kl(r,x,b);break;default:let M=Math.min(d-n,b-r,0);M===0&&(M=Math.max(_-n,x-r,0)),M!==0&&(n+=M,r+=M)}return{zoomX:n,zoomY:r}}},JV=class extends C4{constructor(){super(...arguments),this.ControllerState=fIe,this.transition={transitionDuration:300,transitionInterpolator:new D3(["target","zoomX","zoomY"])},this.dragMode="pan"}setProps(n){Object.assign(n,uIe(n)),super.setProps(n)}_onMultiPanStart(n){return this.multiTouchDrag==="pan"&&super._onMultiPanStart(n)}_onPanRotate(){return!1}};var Wue=class extends S4{constructor(n={}){super(n)}getViewportType(){return nvt}get ControllerType(){return JV}};Wue.displayName="OrthographicView";var hIe=Wue;var QV=class{static get componentName(){return Object.prototype.hasOwnProperty.call(this,"extensionName")?this.extensionName:""}constructor(n){n&&(this.opts=n)}equals(n){return this===n?!0:this.constructor===n.constructor&&Ac(this.opts,n.opts,1)}getShaders(n){return null}getSubLayerProps(n){let{defaultProps:r}=n.constructor,c={updateTriggers:{}};for(let u in r)if(u in this.props){let d=r[u],b=this.props[u];c[u]=b,d&&d.type==="accessor"&&(c.updateTriggers[u]=this.props.updateTriggers[u],typeof b=="function"&&(c[u]=this.getSubLayerAccessor(b)))}return c}initializeState(n,r){}updateState(n,r){}onNeedsRedraw(n){}getNeedsPickingBuffer(n){return!1}draw(n,r){}finalizeState(n,r){}};QV.defaultProps={};QV.extensionName="LayerExtension";var dIe=QV;Vr();var nT=class{constructor(n){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;let{attributes:r={}}=n;this.typedArrayManager=pv,this.attributes={},this._attributeDefs=r,this.opts=n,this.updateGeometry(n)}updateGeometry(n){Object.assign(this.opts,n);let{data:r,buffers:c={},getGeometry:u,geometryBuffer:d,positionFormat:b,dataChanged:w,normalize:_=!0}=this.opts;if(this.data=r,this.getGeometry=u,this.positionSize=d&&d.size||(b==="XY"?2:3),this.buffers=c,this.normalize=_,d&&(La(r.startIndices),this.getGeometry=this.getGeometryFromBuffer(d),_||(c.vertexPositions=d)),this.geometryBuffer=c.vertexPositions,Array.isArray(w))for(let x of w)this._rebuildGeometry(x);else this._rebuildGeometry()}updatePartialGeometry({startRow:n,endRow:r}){this._rebuildGeometry({startRow:n,endRow:r})}getGeometryFromBuffer(n){let r=n.value||n;return ArrayBuffer.isView(r)?bue(r,{size:this.positionSize,offset:n.offset,stride:n.stride,startIndices:this.data.startIndices}):null}_allocate(n,r){let{attributes:c,buffers:u,_attributeDefs:d,typedArrayManager:b}=this;for(let w in d)if(w in u)b.release(c[w]),c[w]=null;else{let _=d[w];_.copy=r,c[w]=b.allocate(c[w],n,_)}}_forEachGeometry(n,r,c){let{data:u,getGeometry:d}=this,{iterable:b,objectInfo:w}=gue(u,r,c);for(let _ of b){w.index++;let x=d?d(_,w):null;n(x,w.index)}}_rebuildGeometry(n){if(!this.data)return;let{indexStarts:r,vertexStarts:c,instanceCount:u}=this,{data:d,geometryBuffer:b}=this,{startRow:w=0,endRow:_=1/0}=n||{},x={};if(n||(r=[0],c=[0]),this.normalize||!b)this._forEachGeometry((M,L)=>{let I=M&&this.normalizeGeometry(M);x[L]=I,c[L+1]=c[L]+(I?this.getGeometrySize(I):0)},w,_),u=c[c.length-1];else if(c=d.startIndices,u=c[d.length]||0,ArrayBuffer.isView(b))u=u||b.length/this.positionSize;else if(b instanceof cs){let M=this.positionSize*4;u=u||b.byteLength/M}else if(b.buffer){let M=b.stride||this.positionSize*4;u=u||b.buffer.byteLength/M}else if(b.value){let M=b.value,L=b.stride/M.BYTES_PER_ELEMENT||this.positionSize;u=u||M.length/L}this._allocate(u,!!n),this.indexStarts=r,this.vertexStarts=c,this.instanceCount=u;let T={};this._forEachGeometry((M,L)=>{let I=x[L]||M;T.vertexStart=c[L],T.indexStart=r[L];let D=Lthis.attributeTransitionManager.hasAttribute(d)}):null,Object.seal(this)}finalize(){this.attributeBufferGroups?.finalize();for(let n in this.attributes)this.attributes[n].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(n={clearRedrawFlags:!1}){let r=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!n.clearRedrawFlags,r&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(n){this._add(n)}addInstanced(n){this._add(n,{stepMode:"instance"})}remove(n){for(let r of n)this.attributes[r]!==void 0&&(this.attributes[r].delete(),delete this.attributes[r])}invalidate(n,r){let c=this._invalidateTrigger(n,r);Bf(zwt,this,n,c)}invalidateAll(n){for(let r in this.attributes)this.attributes[r].setNeedsUpdate(r,n);Bf(zwt,this,"all")}update({data:n,numInstances:r,startIndices:c=null,transitions:u,props:d={},buffers:b={},context:w={}}){let _=!1;Bf(Zin,this),this.stats&&this.stats.get("Update Attributes").timeStart();for(let x in this.attributes){let T=this.attributes[x],M=T.settings.accessor;T.startIndices=c,T.numInstances=r,d[x]&&Bs.removed(`props.${x}`,`data.attributes.${x}`)(),T.setExternalBuffer(b[x])||T.setBinaryValue(typeof M=="string"?b[M]:void 0,n.startIndices)||typeof M=="string"&&!b[M]&&T.setConstantValue(w,d[M])||T.needsUpdate()&&(_=!0,this._updateAttribute({attribute:T,numInstances:r,data:n,props:d,context:w})),this.needsRedraw=this.needsRedraw||T.needsRedraw()}_&&Bf(Kin,this,r),this.stats&&(this.stats.get("Update Attributes").timeEnd(),_&&this.stats.get("Attributes updated").incrementCount()),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:r,transitions:u})}updateTransition(){let{attributeTransitionManager:n}=this,r=n.run();return this.needsRedraw=this.needsRedraw||r,r}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(n){let r=n.map(c=>this.attributes[c]?.getBounds());return this.mergeBoundsMemoized(r)}getChangedAttributes(n={clearChangedFlags:!1}){let{attributes:r,attributeTransitionManager:c}=this,u={...c.getAttributes()};for(let d in r){let b=r[d];b.needsRedraw(n)&&!c.hasAttribute(d)&&(u[d]=b)}return u}getBufferLayouts(n){return this.hasBufferGroups()?this.attributeBufferGroups.getBufferLayouts(this.getAttributes(),n):Object.values(this.getAttributes()).map(r=>r.getBufferLayout(n))}hasBufferGroups(){return!!this.attributeBufferGroups?.hasGroups(this.attributes)}getBufferGroupBindings(n,r,c={}){return this.attributeBufferGroups?this.attributeBufferGroups.getBindings(this.getAttributes(),n,r,c):{bufferLayouts:this.getBufferLayouts(r),buffers:{},groupedAttributeIds:new Set}}_add(n,r){for(let c in n){let u=n[c],d={...u,id:c,size:u.isIndexed&&1||u.size||1,...r};this.attributes[c]=new k4(this.device,d)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){let n={};for(let r in this.attributes)this.attributes[r].getUpdateTriggers().forEach(u=>{n[u]||(n[u]=[]),n[u].push(r)});this.updateTriggers=n}_invalidateTrigger(n,r){let{attributes:c,updateTriggers:u}=this,d=u[n];return d&&d.forEach(b=>{let w=c[b];w&&w.setNeedsUpdate(w.id,r)}),d}_updateAttribute(n){let{attribute:r,numInstances:c}=n;if(Bf(Jin,r),r.constant){r.setConstantValue(n.context,r.value);return}r.allocate(c)&&Bf(Qin,r,c),r.updateBuffer(n)&&(this.needsRedraw=!0,Bf(ern,r,c))}};Vr();fue();Nf();var VV=class extends mv{get value(){return this._value}_onUpdate(){let{time:n,settings:{fromValue:r,toValue:c,duration:u,easing:d}}=this,b=d(n/u);this._value=lv(r,c,b)}};var Gwt=1e-5;function jwt(s,n,r,c,u){let d=n-s,w=(r-n)*u,_=-d*c;return w+_+d+n}function trn(s,n,r,c,u){if(Array.isArray(r)){let d=[];for(let b=0;b0}add(n,r,c,u){let{transitions:d}=this;if(d.has(n)){let _=d.get(n),{value:x=_.settings.fromValue}=_;r=x,this.remove(n)}if(u=wue(u),!u)return;let b=nrn[u.type];if(!b){Bs.error(`unsupported transition type '${u.type}'`)();return}let w=new b(this.timeline);w.start({...u,fromValue:r,toValue:c}),d.set(n,w)}remove(n){let{transitions:r}=this;r.has(n)&&(r.get(n).cancel(),r.delete(n))}update(){let n={};for(let[r,c]of this.transitions)c.update(),n[r]=c.value,c.inProgress||this.remove(r);return n}clear(){for(let n of this.transitions.keys())this.remove(n)}};function Wwt(s){let n=s[t2];for(let r in n){let c=n[r],{validate:u}=c;if(u&&!u(s[r],c))throw new Error(`Invalid prop ${r}: ${s[r]}`)}}function Hwt(s,n){let r=qwt({newProps:s,oldProps:n,propTypes:s[t2],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),c=rrn(s,n),u=!1;return c||(u=srn(s,n)),{dataChanged:c,propsChanged:r,updateTriggersChanged:u,extensionsChanged:orn(s,n),transitionsChanged:irn(s,n)}}function irn(s,n){if(!s.transitions)return!1;let r={},c=s[t2],u=!1;for(let d in s.transitions){let b=c[d],w=b&&b.type;(w==="number"||w==="color"||w==="array")&&iIe(s[d],n[d],b)&&(r[d]=!0,u=!0)}return u?r:!1}function qwt({newProps:s,oldProps:n,ignoreProps:r={},propTypes:c={},triggerName:u="props"}){if(n===s)return!1;if(typeof s!="object"||s===null)return`${u} changed shallowly`;if(typeof n!="object"||n===null)return`${u} changed shallowly`;for(let d of Object.keys(s))if(!(d in r)){if(!(d in n))return`${u}.${d} added`;let b=iIe(s[d],n[d],c[d]);if(b)return`${u}.${d} ${b}`}for(let d of Object.keys(n))if(!(d in r)){if(!(d in s))return`${u}.${d} dropped`;if(!Object.hasOwnProperty.call(s,d)){let b=iIe(s[d],n[d],c[d]);if(b)return`${u}.${d} ${b}`}}return!1}function iIe(s,n,r){let c=r&&r.equal;return c&&!c(s,n,r)||!c&&(c=s&&n&&s.equals,c&&!c.call(s,n))?"changed deeply":!c&&n!==s?"changed shallowly":null}function rrn(s,n){if(n===null)return"oldProps is null, initial diff";let r=!1,{dataComparator:c,_dataDiff:u}=s;return c?c(s.data,n.data)||(r="Data comparator detected a change"):s.data!==n.data&&(r="A new data container was supplied"),r&&u&&(r=u(s.data,n.data)||r),r}function srn(s,n){if(n===null)return{all:!0};if("all"in s.updateTriggers&&Vwt(s,n,"all"))return{all:!0};let r={},c=!1;for(let u in s.updateTriggers)u!=="all"&&Vwt(s,n,u)&&(r[u]=!0,c=!0);return c?r:!1}function orn(s,n){if(n===null)return!0;let r=n.extensions,{extensions:c}=s;if(c===r)return!1;if(!r||!c||c.length!==r.length)return!0;for(let u=0;uc.name==="project64"))){let c=r.modules.findIndex(u=>u.name==="project32");c>=0&&r.modules.splice(c,1)}if("inject"in n)if(!s.inject)r.inject=n.inject;else{let c={...s.inject};for(let u in n.inject)c[u]=(c[u]||"")+n.inject[u];r.inject=c}return r}Vr();var frn={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},rIe={};function Ywt(s,n,r,c){if(r instanceof Pa)return r;r.constructor&&r.constructor.name!=="Object"&&(r={data:r});let u=null;r.compressed&&(u={minFilter:"linear",mipmapFilter:r.data.length>1?"nearest":"linear"});let{width:d,height:b}=r.data,w=n.createTexture({...r,sampler:{...frn,...u,...c},mipLevels:n.getMipLevelCount(d,b)});return n.type==="webgl"?w.generateMipmapsWebGL():n.type==="webgpu"&&n.generateMipmapsWebGPU(w),rIe[w.id]=s,w}function Zwt(s,n){!n||!(n instanceof Pa)||rIe[n.id]===s&&(n.delete(),delete rIe[n.id])}var hrn={boolean:{validate(s,n){return!0},equal(s,n,r){return!!s==!!n}},number:{validate(s,n){return Number.isFinite(s)&&(!("max"in n)||s<=n.max)&&(!("min"in n)||s>=n.min)}},color:{validate(s,n){return n.optional&&!s||sIe(s)&&(s.length===3||s.length===4)},equal(s,n,r){return Ac(s,n,1)}},accessor:{validate(s,n){let r=jue(s);return r==="function"||r===jue(n.value)},equal(s,n,r){return typeof n=="function"?!0:Ac(s,n,1)}},array:{validate(s,n){return n.optional&&!s||sIe(s)},equal(s,n,r){let{compare:c}=r,u=Number.isInteger(c)?c:c?1:0;return c?Ac(s,n,u):s===n}},object:{equal(s,n,r){if(r.ignore)return!0;let{compare:c}=r,u=Number.isInteger(c)?c:c?1:0;return c?Ac(s,n,u):s===n}},function:{validate(s,n){return n.optional&&!s||typeof s=="function"},equal(s,n,r){return!r.compare&&r.ignore!==!1||s===n}},data:{transform:(s,n,r)=>{if(!s)return s;let{dataTransform:c}=r.props;return c?c(s):typeof s.shape=="string"&&s.shape.endsWith("-table")&&Array.isArray(s.data)?s.data:s}},image:{transform:(s,n,r)=>{let c=r.context;return!c||!c.device?null:Ywt(r.id,c.device,s,{...n.parameters,...r.props.textureParameters})},release:(s,n,r)=>{Zwt(r.id,s)}}};function Kwt(s){let n={},r={},c={};for(let[u,d]of Object.entries(s)){let b=d?.deprecatedFor;if(b)c[u]=Array.isArray(b)?b:[b];else{let w=drn(u,d);n[u]=w,r[u]=w.value}}return{propTypes:n,defaultProps:r,deprecatedProps:c}}function drn(s,n){switch(jue(n)){case"object":return qV(s,n);case"array":return qV(s,{type:"array",value:n,compare:!1});case"boolean":return qV(s,{type:"boolean",value:n});case"number":return qV(s,{type:"number",value:n});case"function":return qV(s,{type:"function",value:n,compare:!0});default:return{name:s,type:"unknown",value:n}}}function qV(s,n){return"type"in n?{name:s,...hrn[n.type],...n}:"value"in n?{name:s,type:jue(n.value),...n}:{name:s,type:"object",value:n}}function sIe(s){return Array.isArray(s)||ArrayBuffer.isView(s)}function jue(s){return sIe(s)?"array":s===null?"null":typeof s}function Jwt(s,n){let r;for(let d=n.length-1;d>=0;d--){let b=n[d];"extensions"in b&&(r=b.extensions)}let c=oIe(s.constructor,r),u=Object.create(c);u[bB]=s,u[n2]={},u[gv]={};for(let d=0;d{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(let n in this.asyncProps){let r=this.asyncProps[n];r&&r.type&&r.type.release&&r.type.release(r.resolvedValue,r.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||xrn}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(n){return n in this.asyncProps}getAsyncProp(n){let r=this.asyncProps[n];return r&&r.resolvedValue}isAsyncPropLoading(n){if(n){let r=this.asyncProps[n];return!!(r&&r.pendingLoadCount>0&&r.pendingLoadCount!==r.resolvedLoadCount)}for(let r in this.asyncProps)if(this.isAsyncPropLoading(r))return!0;return!1}reloadAsyncProp(n,r){this._watchPromise(n,Promise.resolve(r))}setAsyncProps(n){this.component=n[bB]||this.component;let r=n[gv]||{},c=n[n2]||n,u=n[I3]||{};for(let d in r){let b=r[d];this._createAsyncPropData(d,u[d]),this._updateAsyncProp(d,b),r[d]=this.getAsyncProp(d)}for(let d in c){let b=c[d];this._createAsyncPropData(d,u[d]),this._updateAsyncProp(d,b)}}_fetch(n,r){return null}_onResolve(n,r){}_onError(n,r){}_updateAsyncProp(n,r){if(this._didAsyncInputValueChange(n,r)){if(typeof r=="string"&&(r=this._fetch(n,r)),r instanceof Promise){this._watchPromise(n,r);return}if(mue(r)){this._resolveAsyncIterable(n,r);return}this._setPropValue(n,r)}}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(let n in this.asyncProps)Object.defineProperty(this.oldAsyncProps,n,{enumerable:!0,value:this.oldProps[n]})}}_didAsyncInputValueChange(n,r){let c=this.asyncProps[n];return r===c.resolvedValue||r===c.lastValue?!1:(c.lastValue=r,!0)}_setPropValue(n,r){this._freezeAsyncOldProps();let c=this.asyncProps[n];c&&(r=this._postProcessValue(c,r),c.resolvedValue=r,c.pendingLoadCount++,c.resolvedLoadCount=c.pendingLoadCount)}_setAsyncPropValue(n,r,c){let u=this.asyncProps[n];u&&c>=u.resolvedLoadCount&&r!==void 0&&(this._freezeAsyncOldProps(),u.resolvedValue=r,u.resolvedLoadCount=c,this.onAsyncPropUpdated(n,r))}_watchPromise(n,r){let c=this.asyncProps[n];if(c){c.pendingLoadCount++;let u=c.pendingLoadCount;r.then(d=>{this.component&&(d=this._postProcessValue(c,d),this._setAsyncPropValue(n,d,u),this._onResolve(n,d))}).catch(d=>{this._onError(n,d)})}}async _resolveAsyncIterable(n,r){if(n!=="data"){this._setPropValue(n,r);return}let c=this.asyncProps[n];if(!c)return;c.pendingLoadCount++;let u=c.pendingLoadCount,d=[],b=0;for await(let w of r){if(!this.component)return;let{dataTransform:_}=this.component.props;_?d=_(w,d):d=d.concat(w),Object.defineProperty(d,"__diff",{enumerable:!1,value:[{startRow:b,endRow:d.length}]}),b=d.length,this._setAsyncPropValue(n,d,u)}this._onResolve(n,d)}_postProcessValue(n,r){let c=n.type;return c&&this.component&&(c.release&&c.release(n.resolvedValue,c,this.component),c.transform)?c.transform(r,c,this.component):r}_createAsyncPropData(n,r){if(!this.asyncProps[n]){let u=this.component&&this.component.props[t2];this.asyncProps[n]={type:u&&u[n],lastValue:null,resolvedValue:r,pendingLoadCount:0,resolvedLoadCount:0}}}};var ZV=class extends YV{constructor({attributeManager:n,layer:r}){super(r),this.attributeManager=n,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1,this.disabledPickingIndices=[]}get layer(){return this.component}_fetch(n,r){let c=this.layer,u=c?.props.fetch;return u?u(r,{propName:n,layer:c}):super._fetch(n,r)}_onResolve(n,r){let c=this.layer;if(c){let u=c.props.onDataLoad;n==="data"&&u&&u(r,{propName:n,layer:c})}}_onError(n,r){let c=this.layer;c&&c.raiseError(r,`loading ${n} of ${this.layer}`)}};var Ern="layer.changeFlag",Srn="layer.initialize",Mrn="layer.update",Trn="layer.finalize",Crn="layer.matched",evt=2**24-1,Arn=Object.freeze([]),Prn=Yy(({oldViewport:s,viewport:n})=>s.equals(n)),Ib=new Uint8ClampedArray(0);function tvt(s){return s.rowIndexes||s.pickingColors||s.instancePickingColors}function cIe(s){return s.rowIndexes}function lIe(s){return s.pickingColors||s.instancePickingColors}var Lrn={data:{type:"data",value:Arn,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:s=>s&&s.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(s,{propName:n,layer:r,loaders:c,loadOptions:u,signal:d})=>{let{resourceManager:b}=r.context;u=u||r.getLoadOptions(),c=c||r.props.loaders,d&&(u={...u,core:{...u?.core,fetch:{...u?.core?.fetch,signal:d}}});let w=b.contains(s);return!w&&!u&&(b.add({resourceId:s,data:BD(s,c),persistent:!1}),w=!0),w?b.subscribe({resourceId:s,onChange:_=>r.internalState?.reloadAsyncProp(n,_),consumerId:r.id,requestId:n}):BD(s,c,u)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:"default",coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:s})=>[0,-s*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}},KV=class extends $ue{constructor(){super(...arguments),this.internalState=null,this.lifecycle=XM.NO_STATE,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let n=this;for(;n.parent;)n=n.parent;return n}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(n){La(this.internalState);let r=this.internalState.viewport||this.context.viewport,c=Ele(n,{viewport:r,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[u,d,b]=qM(c,r.pixelProjectionMatrix);return n.length===2?[u,d]:[u,d,b]}unproject(n){return La(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(n)}projectPosition(n,r){La(this.internalState);let c=this.internalState.viewport||this.context.viewport;return Dmt(n,{viewport:c,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...r})}get isComposite(){return!1}get isDrawable(){return!0}setState(n){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,n),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return this.internalState?!this.internalState.isAsyncPropLoading():!1}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){let n=this.state;return n&&(n.models||n.model&&[n.model])||[]}setShaderModuleProps(...n){for(let r of this.getModels())r.shaderInputs.setProps(...n)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){let{coordinateSystem:n}=this.props;return n==="default"||n==="lnglat"||n==="cartesian"}onHover(n,r){return this.props.onHover&&this.props.onHover(n,r)||!1}onClick(n,r){return this.props.onClick&&this.props.onClick(n,r)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(n,r=[]){return r[0]=n+1&255,r[1]=n+1>>8&255,r[2]=n+1>>8>>8&255,r}decodePickingColor(n){La(n instanceof Uint8Array);let[r,c,u]=n;return r+c*256+u*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:Xwt(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds(["positions","instancePositions"])}getShaders(n){n=D4(n,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(let r of this.props.extensions)n=D4(n,r.getShaders.call(this,r));return n}shouldUpdateState(n){return n.changeFlags.propsOrDataChanged}updateState(n){let r=this.getAttributeManager(),{dataChanged:c}=n.changeFlags;if(c&&r)if(Array.isArray(c))for(let u of c)r.invalidateAll(u);else r.invalidateAll();if(r){let{props:u}=n,d=this.internalState.hasPickingBuffer,b=Number.isInteger(u.highlightedObjectIndex)||!!u.pickable||u.extensions.some(w=>w.getNeedsPickingBuffer.call(this,w));if(d!==b){this.internalState.hasPickingBuffer=b;let w=tvt(r.attributes);w&&(b&&w.constant&&(w.constant=!1,r.invalidate(w.id)),!w.value&&!b&&(w.constant=!0,w.value=cIe(r.attributes)?[J$]:[0,0,0]))}}}finalizeState(n){for(let c of this.getModels())c.destroy();let r=this.getAttributeManager();r&&r.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(n){for(let r of this.getModels())r.draw(n.renderPass)}getPickingInfo({info:n,mode:r,sourceLayer:c}){let{index:u}=n;return u>=0&&Array.isArray(this.props.data)&&(n.object=this.props.data[u]),n}raiseError(n,r){r&&(n=new Error(`${r}: ${n.message}`,{cause:n})),this.props.onError?.(n)||this.context?.onError?.(n,this)}getNeedsRedraw(n={clearRedrawFlags:!1}){return this._getNeedsRedraw(n)}needsUpdate(){return this.internalState?this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()):!1}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(n){if(!this.internalState)return;let r=this.internalState.viewport;this.internalState.viewport=n,(!r||!Prn({oldViewport:r,viewport:n}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(n="all"){let r=this.getAttributeManager();r&&(n==="all"?r.invalidateAll():r.invalidate(n))}updateAttributes(n){let r=!1;for(let c in n)n[c].layoutChanged()&&(r=!0);for(let c of this.getModels())this._setModelAttributes(c,n,r)}_updateAttributes(){let n=this.getAttributeManager();if(!n)return;let r=this.props,c=this.getNumInstances(),u=this.getStartIndices();n.update({data:r.data,numInstances:c,startIndices:u,props:r,transitions:r.transitions,buffers:r.data.attributes,context:this});let d=n.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(d)}_updateAttributeTransition(){let n=this.getAttributeManager();n&&n.updateTransition()}_updateUniformTransition(){let{uniformTransitions:n}=this.internalState;if(n.active){let r=n.update(),c=Object.create(this.props);for(let u in r)Object.defineProperty(c,u,{value:r[u]});return c}return this.props}calculateInstancePickingColors(n,{numInstances:r}){if(n.constant)return;let c=Math.floor(Ib.length/4);this.internalState.usesPickingColorCache=!0;let u=r>0&&Ib[0]===0;if(cevt&&Bs.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),Ib=pv.allocate(Ib,r,{size:4,copy:!0,maxCount:Math.max(r,evt)});let d=Math.floor(Ib.length/4),b=[0,0,0],w=u?0:c;for(let _=w;_(Bs.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),n)}),this.internalState.uniformTransitions=new HV(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(let r of this.props.extensions)r.initializeState.call(this,this.context,r);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(n){Bf(Crn,this,this===n);let{state:r,internalState:c}=n;this!==n&&(this.internalState=c,this.state=r,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){let n=this.needsUpdate();if(Bf(Mrn,this,n),!n)return;this.context.stats.get("Layer updates").incrementCount();let r=this.props,c=this.context,u=this.internalState,d=c.viewport,b=this._updateUniformTransition();u.propsInTransition=b,c.viewport=u.viewport||d,this.props=b;try{let w=this._getUpdateParams(),_=this.getModels();if(c.device)this.updateState(w);else try{this.updateState(w)}catch{}for(let T of this.props.extensions)T.updateState.call(this,w,T);this.setNeedsRedraw(),this._updateAttributes();let x=this.getModels()[0]!==_[0];this._postUpdate(w,x)}finally{c.viewport=d,this.props=r,this._clearChangeFlags(),u.needsUpdate=!1,u.resetOldProps()}}_finalize(){Bf(Trn,this),this.finalizeState(this.context);for(let n of this.props.extensions)n.finalizeState.call(this,this.context,n)}_drawLayer({renderPass:n,shaderModuleProps:r=null,uniforms:c={},parameters:u={}}){this._updateAttributeTransition();let d=this.props,b=this.context;this.props=this.internalState.propsInTransition||d;try{r&&this.setShaderModuleProps(r);let{getPolygonOffset:w}=this.props,_=w&&w(c)||[0,0];b.device instanceof KM&&b.device.setParametersWebGL({polygonOffset:_});let x=b.device instanceof KM?null:krn(u);if(Rrn(this.getModels(),n,u,x),b.device instanceof KM)b.device.withParametersWebGL(u,()=>{let T={renderPass:n,shaderModuleProps:r,uniforms:c,parameters:u,context:b};for(let M of this.props.extensions)M.draw.call(this,T,M);this.draw(T)});else{x?.renderPassParameters&&n.setParameters(x.renderPassParameters);let T={renderPass:n,shaderModuleProps:r,uniforms:c,parameters:u,context:b};for(let M of this.props.extensions)M.draw.call(this,T,M);this.draw(T)}}finally{this.props=d}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(n){if(!this.internalState)return;let{changeFlags:r}=this.internalState;for(let u in n)if(n[u]){let d=!1;switch(u){case"dataChanged":let b=n[u],w=r[u];b&&Array.isArray(w)&&(r.dataChanged=Array.isArray(b)?w.concat(b):b,d=!0);default:r[u]||(r[u]=n[u],d=!0)}d&&Bf(Ern,this,u,n)}let c=!!(r.dataChanged||r.updateTriggersChanged||r.propsChanged||r.extensionsChanged);r.propsOrDataChanged=c,r.somethingChanged=c||r.viewportChanged||r.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(n,r){let c=Hwt(n,r);if(c.updateTriggersChanged)for(let u in c.updateTriggersChanged)c.updateTriggersChanged[u]&&this.invalidateAttribute(u);if(c.transitionsChanged)for(let u in c.transitionsChanged)this.internalState.uniformTransitions.add(u,r[u],n[u],n.transitions?.[u]);return this.setChangeFlags(c)}validateProps(){Wwt(this.props)}updateAutoHighlight(n){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(n)}_updateAutoHighlight(n){let r={highlightedObjectColor:n.picked?n.color:null},{highlightColor:c}=this.props;n.picked&&typeof c=="function"&&(r.highlightColor=c(n)),this.setShaderModuleProps({picking:r}),this.setNeedsRedraw()}_getAttributeManager(){let n=this.context;return new $V(n.device,{id:this.props.id,stats:n.stats,timeline:n.timeline})}_postUpdate(n,r){let{props:c,oldProps:u}=n,d=this.state.model;d?.isInstanced&&d.setInstanceCount(this.getNumInstances());let{autoHighlight:b,highlightedObjectIndex:w,highlightColor:_}=c;if(r||u.autoHighlight!==b||u.highlightedObjectIndex!==w||u.highlightColor!==_){let x={};Array.isArray(_)&&(x.highlightColor=_),(r||u.autoHighlight!==b||w!==u.highlightedObjectIndex)&&(x.highlightedObjectColor=Number.isFinite(w)&&w>=0?this.encodePickingColor(w):null),this.setShaderModuleProps({picking:x})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(n){if(!this.internalState)return!1;let r=!1;r=r||this.internalState.needsRedraw&&this.id;let c=this.getAttributeManager(),u=c?c.getNeedsRedraw(n):!1;if(r=r||u,r)for(let d of this.props.extensions)d.onNeedsRedraw.call(this,d);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!n.clearRedrawFlags,r}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}};KV.defaultProps=Lrn;KV.layerName="Layer";var z3=KV;function krn(s){let{blendConstant:n,...r}=s;return n?{pipelineParameters:r,renderPassParameters:{blendConstant:n}}:{pipelineParameters:r}}function Rrn(s,n,r,c){for(let u of s)u.device.type==="webgpu"?(Irn(u,n),u.setParameters({...u.parameters,...c?.pipelineParameters})):u.setParameters(r)}function Irn(s,n){let r=n.props.framebuffer||(n.framebuffer??null);if(!r)return;let c=r.colorAttachments.map(b=>b?.texture?.format??null),u=r.depthStencilAttachment?.texture?.format,d=s;(!Drn(d.props.colorAttachmentFormats,c)||d.props.depthStencilAttachmentFormat!==u)&&(d.props.colorAttachmentFormats=c,d.props.depthStencilAttachmentFormat=u,d._setPipelineNeedsUpdate("attachment formats"))}function Drn(s,n){if(s===n)return!0;if(!s||!n||s.length!==n.length)return!1;for(let r=0;r{let ne=L.slice();ne[oe]+=1;let ue=D.project(ne)[oe]-O[oe];return Number.isFinite(ue)?ue:2**(oe===0?_:x)*(oe===0?1:-1)}),Z=z.map((oe,ne)=>{let ue=ne===0?F.left:F.top,Te=ne===0?F.right:F.bottom,Q=Math.abs(oe);return oe>=0?[ue/Q,Te/Q]:[Te/Q,ue/Q]}),H=L.slice(),te=[I.width,I.height];for(let[oe,[ne,ue]]of Z.entries()){if(te[oe]<0)continue;let{minimum:Te,maximum:Q,midpoint:ge,settledTarget:Qe}=Nrn(T,oe,ne,ue,L[oe]);if(r?.mode!=="preserve"&&M&&(!Number.isFinite(ne)||!Number.isFinite(ue))){H[oe]=ge;continue}let st=M?Qe:Kl(L[oe],Te,Q);H[oe]=r?.mode==="preserve"?L[oe]:w?ZM(L[oe],st,(oe===0?I.width:I.height)/2/Math.abs(z[oe])):st}(H[0]!==L[0]||H[1]!==L[1])&&(n.target=H)}return n}_constrainZoom({zoomX:n,zoomY:r},c){c||(c=this.getViewportProps());let{zoomAxis:u,maxZoomX:d,maxZoomY:b,maxBounds:w}=c,{minZoomX:_,minZoomY:x}=c;if(w!==null&&c.width>0&&c.height>0){let M=wB(c.width,c.height,c.maxBoundsPadding),L=w[0],I=w[1],D=I[0]-L[0],F=I[1]-L[1];M.width>0&&Number.isFinite(D)&&D>0&&(_=Math.max(_,Math.log2(M.width/D)),_>d&&(_=d)),M.height>0&&Number.isFinite(F)&&F>0&&(x=Math.max(x,Math.log2(M.height/F)),x>b&&(x=b))}switch(u){case"X":n=Kl(n,_,d);break;case"Y":r=Kl(r,x,b);break;default:let M=Math.min(d-n,b-r,0);M===0&&(M=Math.max(_-n,x-r,0)),M!==0&&(n+=M,r+=M)}return{zoomX:n,zoomY:r}}},JV=class extends C4{constructor(){super(...arguments),this.ControllerState=fIe,this.transition={transitionDuration:300,transitionInterpolator:new D3(["target","zoomX","zoomY"])},this.dragMode="pan"}setProps(n){Object.assign(n,uIe(n)),super.setProps(n)}_onMultiPanStart(n){return this.multiTouchDrag==="pan"&&super._onMultiPanStart(n)}_onPanRotate(){return!1}};var Wue=class extends S4{constructor(n={}){super(n)}getViewportType(){return nvt}get ControllerType(){return JV}};Wue.displayName="OrthographicView";var hIe=Wue;var QV=class{static get componentName(){return Object.prototype.hasOwnProperty.call(this,"extensionName")?this.extensionName:""}constructor(n){n&&(this.opts=n)}equals(n){return this===n?!0:this.constructor===n.constructor&&Ac(this.opts,n.opts,1)}getShaders(n){return null}getSubLayerProps(n){let{defaultProps:r}=n.constructor,c={updateTriggers:{}};for(let u in r)if(u in this.props){let d=r[u],b=this.props[u];c[u]=b,d&&d.type==="accessor"&&(c.updateTriggers[u]=this.props.updateTriggers[u],typeof b=="function"&&(c[u]=this.getSubLayerAccessor(b)))}return c}initializeState(n,r){}updateState(n,r){}onNeedsRedraw(n){}getNeedsPickingBuffer(n){return!1}draw(n,r){}finalizeState(n,r){}};QV.defaultProps={};QV.extensionName="LayerExtension";var dIe=QV;Vr();var nT=class{constructor(n){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;let{attributes:r={}}=n;this.typedArrayManager=pv,this.attributes={},this._attributeDefs=r,this.opts=n,this.updateGeometry(n)}updateGeometry(n){Object.assign(this.opts,n);let{data:r,buffers:c={},getGeometry:u,geometryBuffer:d,positionFormat:b,dataChanged:w,normalize:_=!0}=this.opts;if(this.data=r,this.getGeometry=u,this.positionSize=d&&d.size||(b==="XY"?2:3),this.buffers=c,this.normalize=_,d&&(La(r.startIndices),this.getGeometry=this.getGeometryFromBuffer(d),_||(c.vertexPositions=d)),this.geometryBuffer=c.vertexPositions,Array.isArray(w))for(let x of w)this._rebuildGeometry(x);else this._rebuildGeometry()}updatePartialGeometry({startRow:n,endRow:r}){this._rebuildGeometry({startRow:n,endRow:r})}getGeometryFromBuffer(n){let r=n.value||n;return ArrayBuffer.isView(r)?bue(r,{size:this.positionSize,offset:n.offset,stride:n.stride,startIndices:this.data.startIndices}):null}_allocate(n,r){let{attributes:c,buffers:u,_attributeDefs:d,typedArrayManager:b}=this;for(let w in d)if(w in u)b.release(c[w]),c[w]=null;else{let _=d[w];_.copy=r,c[w]=b.allocate(c[w],n,_)}}_forEachGeometry(n,r,c){let{data:u,getGeometry:d}=this,{iterable:b,objectInfo:w}=gue(u,r,c);for(let _ of b){w.index++;let x=d?d(_,w):null;n(x,w.index)}}_rebuildGeometry(n){if(!this.data)return;let{indexStarts:r,vertexStarts:c,instanceCount:u}=this,{data:d,geometryBuffer:b}=this,{startRow:w=0,endRow:_=1/0}=n||{},x={};if(n||(r=[0],c=[0]),this.normalize||!b)this._forEachGeometry((M,L)=>{let I=M&&this.normalizeGeometry(M);x[L]=I,c[L+1]=c[L]+(I?this.getGeometrySize(I):0)},w,_),u=c[c.length-1];else if(c=d.startIndices,u=c[d.length]||0,ArrayBuffer.isView(b))u=u||b.length/this.positionSize;else if(b instanceof cs){let M=this.positionSize*4;u=u||b.byteLength/M}else if(b.buffer){let M=b.stride||this.positionSize*4;u=u||b.buffer.byteLength/M}else if(b.value){let M=b.value,L=b.stride/M.BYTES_PER_ELEMENT||this.positionSize;u=u||M.length/L}this._allocate(u,!!n),this.indexStarts=r,this.vertexStarts=c,this.instanceCount=u;let T={};this._forEachGeometry((M,L)=>{let I=x[L]||M;T.vertexStart=c[L],T.indexStart=r[L];let D=L 1.0) { discard; } #endif -`}};var Brn={getDashArray:{type:"accessor",value:[0,0]},getOffset:{type:"accessor",value:0},dashJustified:!1,dashGapPickable:!1,dashUnits:"widths"},Orn={widths:0,pixels:1,meters:2,common:3},Nrn=["instanceDashArrays","instanceDashOffsets","instanceOffsets"];function Frn({props:s,oldProps:n}){return!Ac(s.modelMatrix,n.modelMatrix,2)||s.coordinateSystem!==n.coordinateSystem||!Ac(s.coordinateOrigin,n.coordinateOrigin,1)}function cvt(s,n,r){let c=s.context.viewport;if(!(c instanceof R3)||c.zoom<12)return s.projectPosition(n,{autoOffset:!1});let u=U1.transformMat4([],[n[0],n[1],n[2]||0,1],r.modelMatrix),d=s.props.coordinateSystem==="default"?"lnglat":s.props.coordinateSystem;if(d==="lnglat"){if(Math.abs(u[1]-r.coordinateOrigin[1])>.25){let _=u[0];r.wrapLongitude&&(_=((_+180)%360+360)%360-180);let x=c.projectPosition([_,u[1],0]);return[x[0]-r.commonOrigin[0],x[1]-r.commonOrigin[1],u[2]*r.commonUnitsPerMeter[2]]}wm.sub(u,u,r.coordinateOrigin)}else d==="cartesian"&&wm.sub(u,u,r.coordinateOrigin);let b=u[1],w=wm.scaleAndAdd([],r.commonUnitsPerWorldUnit,r.commonUnitsPerWorldUnit2,b);return wm.multiply([],u,w)}var eW=class extends dIe{constructor({dash:n=!1,offset:r=!1,dashMode:c,highPrecisionDash:u=!1}={}){let d=c??(u?"path":"segment");super({dash:n||u||c!==void 0,offset:r,dashMode:d,highPrecisionDash:d==="path"})}getLayerType(n){if("pathTesselator"in n.state)return"path";let r=n.constructor.layerName;return r==="ScatterplotLayer"?"scatterplot":r==="TextBackgroundLayer"?"textBackground":null}synchronizeAttributes(n){let r=n.getAttributeManager(),c=this.getLayerType(n);if(!r||!c)return!1;let u=r.getAttributes(),d=new Set;this.opts.dash&&d.add("instanceDashArrays"),c==="path"&&this.opts.dash&&this.opts.dashMode==="path"&&d.add("instanceDashOffsets"),c==="path"&&this.opts.offset&&d.add("instanceOffsets");let b=!1;for(let w of Nrn)u[w]&&!d.has(w)&&(r.remove([w]),b=!0);return d.has("instanceDashArrays")&&!u.instanceDashArrays&&(r.addInstanced({instanceDashArrays:{size:2,accessor:"getDashArray"}}),b=!0),d.has("instanceDashOffsets")&&!u.instanceDashOffsets&&(r.addInstanced({instanceDashOffsets:{size:2,accessor:["getPath"],update:this.calculateDashMetrics}}),b=!0),d.has("instanceOffsets")&&!u.instanceOffsets&&(r.addInstanced({instanceOffsets:{size:1,accessor:"getOffset"}}),b=!0),b}isEnabled(n){return this.getLayerType(n)!==null}getShaders(n){let r=n.getLayerType(this);if(!r)return null;if(r==="scatterplot"||r==="textBackground")return n.opts.dash?{modules:[{name:"pathStyle",inject:r==="scatterplot"?svt.inject:ovt.inject,uniformTypes:{dashGapPickable:"i32"}}]}:null;let c={},u={};n.opts.dash&&(c=D4(c,rvt),u.DASH_ENABLED=!0,n.opts.dashMode==="path"&&(u.HIGH_PRECISION_DASH=!0)),n.opts.offset&&(c=D4(c,avt),u.PATH_STYLE_OFFSET=!0);let{inject:d}=c,b={name:"pathStyle",inject:d};return n.opts.dash&&(b.uniformTypes={dashAlignMode:"f32",dashGapPickable:"i32",dashUnits:"i32"}),{modules:[b],defines:u}}initializeState(n,r){r.synchronizeAttributes(this)}updateState(n,r){if(r.isEnabled(this)){if(n.changeFlags.extensionsChanged){let c=r.synchronizeAttributes(this),u=this.getAttributeManager();if(u&&c){u.invalidateAll();for(let d of this.getModels())d.setBufferLayout(u.getBufferLayouts(d))}}if(r.opts.dash){let c=r.getLayerType(this);if(c==="path"&&r.opts.dashMode==="path"&&Frn(n)&&this.getAttributeManager()?.invalidate("instanceDashOffsets"),c==="scatterplot"||c==="textBackground"){let u={dashGapPickable:!!this.props.dashGapPickable};this.setShaderModuleProps({pathStyle:u})}else{let u={dashAlignMode:this.props.dashJustified?1:0,dashGapPickable:!!this.props.dashGapPickable,dashUnits:Orn[this.props.dashUnits??"widths"]};this.setShaderModuleProps({pathStyle:u})}}}}calculateDashMetrics(n,{startRow:r,endRow:c}){let u=this.state.pathTesselator,d=u?.vertexStarts,b=u?.instanceCount,w=u?.get("positions");if(!d||b===void 0||typeof u?.getPathSegmentIndices!="function")throw new Error("PathStyleExtension requires PathLayer tessellation data for path dashes.");let _=this.props.data?.attributes?.getPath,x=ArrayBuffer.isView(_)?_:_?.value,T=ArrayBuffer.isView(x),M=w&&(!_||u.normalize||u.opts?.isWebGPU);if(_&&!T||!M&&!T)throw new Error("PathStyleExtension cannot calculate whole-path dash metrics from GPU-only getPath data; supply data.attributes.instanceDashOffsets.");let L=n.value,I=n.size,D=Math.max(0,r),F=Math.min(c,d.length-1),O=3,z=3,Z=0;if(!M){let ne=x.BYTES_PER_ELEMENT;O=_?.size||(this.props.positionFormat==="XY"?2:3),z=_?.stride?_.stride/ne:O,Z=_?.offset?_.offset/ne:0}let H=new Array(3),te=fv.getUniforms({viewport:this.context.viewport,modelMatrix:this.props.modelMatrix,coordinateSystem:this.props.coordinateSystem,coordinateOrigin:this.props.coordinateOrigin,autoWrapLongitude:this.wrapLongitude}),oe=ne=>{if(M)H[0]=w[ne*3],H[1]=w[ne*3+1],H[2]=w[ne*3+2];else{let ue=Z+ne*z;H[0]=x[ue],H[1]=x[ue+1],H[2]=O===3?x[ue+2]:0}return H};n.startIndices=d;for(let ne=D;ne1)for(let at=ue;at0&&(r[_]=r[_-1]+wm.dist(w,b)),w=b;return r[d-1]=0,r}};eW.defaultProps=Brn;eW.extensionName="PathStyleExtension";var pIe=eW;Ql();Of();var Urn=new Uint32Array([0,2,1,0,3,2]),zrn=new Float32Array([0,1,0,0,1,0,1,1]);function gIe(s,n){if(!n)return Grn(s);let r=Math.max(Math.abs(s[0][0]-s[3][0]),Math.abs(s[1][0]-s[2][0])),c=Math.max(Math.abs(s[1][1]-s[0][1]),Math.abs(s[2][1]-s[3][1])),u=Math.ceil(r/n)+1,d=Math.ceil(c/n)+1,b=(u-1)*(d-1)*6,w=new Uint32Array(b),_=new Float32Array(u*d*2),x=new Float64Array(u*d*3),T=0,M=0;for(let L=0;L0&&D>0&&(w[M++]=T-d,w[M++]=T-d-1,w[M++]=T-1,w[M++]=T-d,w[M++]=T-1,w[M++]=T),T++}}return{vertexCount:b,positions:x,indices:w,texCoords:_}}function Grn(s){let n=new Float64Array(12);for(let r=0;r.25){let _=u[0];r.wrapLongitude&&(_=((_+180)%360+360)%360-180);let x=c.projectPosition([_,u[1],0]);return[x[0]-r.commonOrigin[0],x[1]-r.commonOrigin[1],u[2]*r.commonUnitsPerMeter[2]]}wm.sub(u,u,r.coordinateOrigin)}else d==="cartesian"&&wm.sub(u,u,r.coordinateOrigin);let b=u[1],w=wm.scaleAndAdd([],r.commonUnitsPerWorldUnit,r.commonUnitsPerWorldUnit2,b);return wm.multiply([],u,w)}var eW=class extends dIe{constructor({dash:n=!1,offset:r=!1,dashMode:c,highPrecisionDash:u=!1}={}){let d=c??(u?"path":"segment");super({dash:n||u||c!==void 0,offset:r,dashMode:d,highPrecisionDash:d==="path"})}getLayerType(n){if("pathTesselator"in n.state)return"path";let r=n.constructor.layerName;return r==="ScatterplotLayer"?"scatterplot":r==="TextBackgroundLayer"?"textBackground":null}synchronizeAttributes(n){let r=n.getAttributeManager(),c=this.getLayerType(n);if(!r||!c)return!1;let u=r.getAttributes(),d=new Set;this.opts.dash&&d.add("instanceDashArrays"),c==="path"&&this.opts.dash&&this.opts.dashMode==="path"&&d.add("instanceDashOffsets"),c==="path"&&this.opts.offset&&d.add("instanceOffsets");let b=!1;for(let w of zrn)u[w]&&!d.has(w)&&(r.remove([w]),b=!0);return d.has("instanceDashArrays")&&!u.instanceDashArrays&&(r.addInstanced({instanceDashArrays:{size:2,accessor:"getDashArray"}}),b=!0),d.has("instanceDashOffsets")&&!u.instanceDashOffsets&&(r.addInstanced({instanceDashOffsets:{size:2,accessor:["getPath"],update:this.calculateDashMetrics}}),b=!0),d.has("instanceOffsets")&&!u.instanceOffsets&&(r.addInstanced({instanceOffsets:{size:1,accessor:"getOffset"}}),b=!0),b}isEnabled(n){return this.getLayerType(n)!==null}getShaders(n){let r=n.getLayerType(this);if(!r)return null;if(r==="scatterplot"||r==="textBackground")return n.opts.dash?{modules:[{name:"pathStyle",inject:r==="scatterplot"?svt.inject:ovt.inject,uniformTypes:{dashGapPickable:"i32"}}]}:null;let c={},u={};n.opts.dash&&(c=D4(c,rvt),u.DASH_ENABLED=!0,n.opts.dashMode==="path"&&(u.HIGH_PRECISION_DASH=!0)),n.opts.offset&&(c=D4(c,avt),u.PATH_STYLE_OFFSET=!0);let{inject:d}=c,b={name:"pathStyle",inject:d};return n.opts.dash&&(b.uniformTypes={dashAlignMode:"f32",dashGapPickable:"i32",dashUnits:"i32"}),{modules:[b],defines:u}}initializeState(n,r){r.synchronizeAttributes(this)}updateState(n,r){if(r.isEnabled(this)){if(n.changeFlags.extensionsChanged){let c=r.synchronizeAttributes(this),u=this.getAttributeManager();if(u&&c){u.invalidateAll();for(let d of this.getModels())d.setBufferLayout(u.getBufferLayouts(d))}}if(r.opts.dash){let c=r.getLayerType(this);if(c==="path"&&r.opts.dashMode==="path"&&Grn(n)&&this.getAttributeManager()?.invalidate("instanceDashOffsets"),c==="scatterplot"||c==="textBackground"){let u={dashGapPickable:!!this.props.dashGapPickable};this.setShaderModuleProps({pathStyle:u})}else{let u={dashAlignMode:this.props.dashJustified?1:0,dashGapPickable:!!this.props.dashGapPickable,dashUnits:Urn[this.props.dashUnits??"widths"]};this.setShaderModuleProps({pathStyle:u})}}}}calculateDashMetrics(n,{startRow:r,endRow:c}){let u=this.state.pathTesselator,d=u?.vertexStarts,b=u?.instanceCount,w=u?.get("positions");if(!d||b===void 0||typeof u?.getPathSegmentIndices!="function")throw new Error("PathStyleExtension requires PathLayer tessellation data for path dashes.");let _=this.props.data?.attributes?.getPath,x=ArrayBuffer.isView(_)?_:_?.value,T=ArrayBuffer.isView(x),M=w&&(!_||u.normalize||u.opts?.isWebGPU);if(_&&!T||!M&&!T)throw new Error("PathStyleExtension cannot calculate whole-path dash metrics from GPU-only getPath data; supply data.attributes.instanceDashOffsets.");let L=n.value,I=n.size,D=Math.max(0,r),F=Math.min(c,d.length-1),O=3,z=3,Z=0;if(!M){let ne=x.BYTES_PER_ELEMENT;O=_?.size||(this.props.positionFormat==="XY"?2:3),z=_?.stride?_.stride/ne:O,Z=_?.offset?_.offset/ne:0}let H=new Array(3),te=fv.getUniforms({viewport:this.context.viewport,modelMatrix:this.props.modelMatrix,coordinateSystem:this.props.coordinateSystem,coordinateOrigin:this.props.coordinateOrigin,autoWrapLongitude:this.wrapLongitude}),oe=ne=>{if(M)H[0]=w[ne*3],H[1]=w[ne*3+1],H[2]=w[ne*3+2];else{let ue=Z+ne*z;H[0]=x[ue],H[1]=x[ue+1],H[2]=O===3?x[ue+2]:0}return H};n.startIndices=d;for(let ne=D;ne1)for(let at=ue;at0&&(r[_]=r[_-1]+wm.dist(w,b)),w=b;return r[d-1]=0,r}};eW.defaultProps=Frn;eW.extensionName="PathStyleExtension";var pIe=eW;Ql();Nf();var jrn=new Uint32Array([0,2,1,0,3,2]),$rn=new Float32Array([0,1,0,0,1,0,1,1]);function gIe(s,n){if(!n)return Vrn(s);let r=Math.max(Math.abs(s[0][0]-s[3][0]),Math.abs(s[1][0]-s[2][0])),c=Math.max(Math.abs(s[1][1]-s[0][1]),Math.abs(s[2][1]-s[3][1])),u=Math.ceil(r/n)+1,d=Math.ceil(c/n)+1,b=(u-1)*(d-1)*6,w=new Uint32Array(b),_=new Float32Array(u*d*2),x=new Float64Array(u*d*3),T=0,M=0;for(let L=0;L0&&D>0&&(w[M++]=T-d,w[M++]=T-d-1,w[M++]=T-1,w[M++]=T-d,w[M++]=T-1,w[M++]=T),T++}}return{vertexCount:b,positions:x,indices:w,texCoords:_}}function Vrn(s){let n=new Float64Array(12);for(let r=0;r, coordinateConversion: f32, @@ -4616,7 +4616,7 @@ struct BitmapUniforms { vec3 tintColor; vec4 transparentColor; } bitmap; -`,uvt={name:"bitmap",source:$rn,vs:lvt,fs:lvt,uniformTypes:{bounds:"vec4",coordinateConversion:"f32",desaturate:"f32",tintColor:"vec3",transparentColor:"vec4"}};var fvt=`struct Attributes { +`,uvt={name:"bitmap",source:Hrn,vs:lvt,fs:lvt,uniformTypes:{bounds:"vec4",coordinateConversion:"f32",desaturate:"f32",tintColor:"vec3",transparentColor:"vec4"}};var fvt=`struct Attributes { @location(0) positions: vec3, @location(1) positions64Low: vec3, @location(2) texCoords: vec2, @@ -4786,7 +4786,7 @@ void main(void) { vec4 color = vec4(0.0); DECKGL_FILTER_COLOR(color, geometry); } -`;var Vrn=` +`;var qrn=` vec3 packUVsIntoRGB(vec2 uv) { // Extract the top 8 bits. We want values to be truncated down so we can add a fraction vec2 uv8bit = floor(uv * 256.); @@ -4869,7 +4869,7 @@ vec2 getUV(vec2 pos) { ); } -${Vrn} +${qrn} void main(void) { vec2 uv = vTexCoord; @@ -4892,7 +4892,7 @@ void main(void) { fragColor.rgb = packUVsIntoRGB(uv); } } -`;var Wrn={image:{type:"image",value:null,async:!0},bounds:{type:"array",value:[1,0,0,1],compare:!0},_imageCoordinateSystem:"default",desaturate:{type:"number",min:0,max:1,value:0},transparentColor:{type:"color",value:[0,0,0,0]},tintColor:{type:"color",value:[255,255,255]},textureParameters:{type:"object",ignore:!0,value:null}},tW=class extends z3{getShaders(){return super.getShaders({vs:hvt,fs:dvt,source:fvt,modules:[qy,Zy,Jy,uvt]})}initializeState(){let n=this.getAttributeManager(),r=!0;n.add({indices:{size:1,isIndexed:!0,update:c=>c.value=this.state.mesh.indices,noAlloc:r},positions:{size:3,type:"float64",fp64:this.use64bitPositions(),update:c=>c.value=this.state.mesh.positions,noAlloc:r},texCoords:{size:2,update:c=>c.value=this.state.mesh.texCoords,noAlloc:r}})}updateState({props:n,oldProps:r,changeFlags:c}){let u=this.getAttributeManager();if(c.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),u.invalidateAll()),n.bounds!==r.bounds){let d=this.state.mesh,b=this._createMesh();this.state.model.setVertexCount(b.vertexCount);for(let w in b)d&&d[w]!==b[w]&&u.invalidate(w);this.setState({mesh:b,...this._getCoordinateUniforms()})}else n._imageCoordinateSystem!==r._imageCoordinateSystem&&this.setState(this._getCoordinateUniforms())}getPickingInfo(n){let{image:r}=this.props,c=n.info;if(!c.color||!r)return c.bitmap=null,c;let{width:u,height:d}=r;c.index=0;let b=Hrn(c.color);return c.bitmap={size:{width:u,height:d},uv:b,pixel:[Math.floor(b[0]*u),Math.floor(b[1]*d)]},c}disablePickingIndex(){this.setState({disablePicking:!0})}restorePickingColors(){this.setState({disablePicking:!1})}_updateAutoHighlight(n){super._updateAutoHighlight({...n,color:this.encodePickingColor(0)})}_createMesh(){let{bounds:n}=this.props,r=n;return pvt(n)&&(r=[[n[0],n[1]],[n[0],n[3]],[n[2],n[3]],[n[2],n[1]]]),gIe(r,this.context.viewport.resolution)}_getModel(){let n=this.context.device.type==="webgpu"?this.getAttributeManager().getBufferLayouts({isInstanced:!1}).filter(r=>r.name!=="indices"):this.getAttributeManager().getBufferLayouts();return new Vh(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:n,topology:"triangle-list",isInstanced:!1})}draw(n){let{shaderModuleProps:r}=n,{model:c,coordinateConversion:u,bounds:d,disablePicking:b}=this.state,{image:w,desaturate:_,transparentColor:x,tintColor:T}=this.props;if(!(r.picking.isActive&&b)&&w&&c){let M={bitmapTexture:w,bounds:d,coordinateConversion:u,desaturate:_,tintColor:T.slice(0,3).map(L=>L/255),transparentColor:x.map(L=>L/255)};c.shaderInputs.setProps({bitmap:M}),c.draw(this.context.renderPass)}}_getCoordinateUniforms(){let{_imageCoordinateSystem:n}=this.props;if(n!=="default"){let{bounds:r}=this.props;if(!pvt(r))throw new Error("_imageCoordinateSystem only supports rectangular bounds");let c=this.context.viewport.resolution?"lnglat":"cartesian";if(n=n==="lnglat"?"lnglat":"cartesian",n==="lnglat"&&c==="cartesian")return{coordinateConversion:-1,bounds:r};if(n==="cartesian"&&c==="lnglat"){let u=cg([r[0],r[1]]),d=cg([r[2],r[3]]);return{coordinateConversion:1,bounds:[u[0],u[1],d[0],d[1]]}}}return{coordinateConversion:0,bounds:[0,0,0,0]}}};tW.layerName="BitmapLayer";tW.defaultProps=Wrn;var mIe=tW;function Hrn(s){let[n,r,c]=s,u=(c&240)/256,d=(c&15)/16;return[(n+d)/256,(r+u)/256]}function pvt(s){return Number.isFinite(s[0])}Ql();var gvt=`layout(std140) uniform scatterplotUniforms { +`;var Xrn={image:{type:"image",value:null,async:!0},bounds:{type:"array",value:[1,0,0,1],compare:!0},_imageCoordinateSystem:"default",desaturate:{type:"number",min:0,max:1,value:0},transparentColor:{type:"color",value:[0,0,0,0]},tintColor:{type:"color",value:[255,255,255]},textureParameters:{type:"object",ignore:!0,value:null}},tW=class extends z3{getShaders(){return super.getShaders({vs:hvt,fs:dvt,source:fvt,modules:[qy,Zy,Jy,uvt]})}initializeState(){let n=this.getAttributeManager(),r=!0;n.add({indices:{size:1,isIndexed:!0,update:c=>c.value=this.state.mesh.indices,noAlloc:r},positions:{size:3,type:"float64",fp64:this.use64bitPositions(),update:c=>c.value=this.state.mesh.positions,noAlloc:r},texCoords:{size:2,update:c=>c.value=this.state.mesh.texCoords,noAlloc:r}})}updateState({props:n,oldProps:r,changeFlags:c}){let u=this.getAttributeManager();if(c.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),u.invalidateAll()),n.bounds!==r.bounds){let d=this.state.mesh,b=this._createMesh();this.state.model.setVertexCount(b.vertexCount);for(let w in b)d&&d[w]!==b[w]&&u.invalidate(w);this.setState({mesh:b,...this._getCoordinateUniforms()})}else n._imageCoordinateSystem!==r._imageCoordinateSystem&&this.setState(this._getCoordinateUniforms())}getPickingInfo(n){let{image:r}=this.props,c=n.info;if(!c.color||!r)return c.bitmap=null,c;let{width:u,height:d}=r;c.index=0;let b=Yrn(c.color);return c.bitmap={size:{width:u,height:d},uv:b,pixel:[Math.floor(b[0]*u),Math.floor(b[1]*d)]},c}disablePickingIndex(){this.setState({disablePicking:!0})}restorePickingColors(){this.setState({disablePicking:!1})}_updateAutoHighlight(n){super._updateAutoHighlight({...n,color:this.encodePickingColor(0)})}_createMesh(){let{bounds:n}=this.props,r=n;return pvt(n)&&(r=[[n[0],n[1]],[n[0],n[3]],[n[2],n[3]],[n[2],n[1]]]),gIe(r,this.context.viewport.resolution)}_getModel(){let n=this.context.device.type==="webgpu"?this.getAttributeManager().getBufferLayouts({isInstanced:!1}).filter(r=>r.name!=="indices"):this.getAttributeManager().getBufferLayouts();return new Vh(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:n,topology:"triangle-list",isInstanced:!1})}draw(n){let{shaderModuleProps:r}=n,{model:c,coordinateConversion:u,bounds:d,disablePicking:b}=this.state,{image:w,desaturate:_,transparentColor:x,tintColor:T}=this.props;if(!(r.picking.isActive&&b)&&w&&c){let M={bitmapTexture:w,bounds:d,coordinateConversion:u,desaturate:_,tintColor:T.slice(0,3).map(L=>L/255),transparentColor:x.map(L=>L/255)};c.shaderInputs.setProps({bitmap:M}),c.draw(this.context.renderPass)}}_getCoordinateUniforms(){let{_imageCoordinateSystem:n}=this.props;if(n!=="default"){let{bounds:r}=this.props;if(!pvt(r))throw new Error("_imageCoordinateSystem only supports rectangular bounds");let c=this.context.viewport.resolution?"lnglat":"cartesian";if(n=n==="lnglat"?"lnglat":"cartesian",n==="lnglat"&&c==="cartesian")return{coordinateConversion:-1,bounds:r};if(n==="cartesian"&&c==="lnglat"){let u=cg([r[0],r[1]]),d=cg([r[2],r[3]]);return{coordinateConversion:1,bounds:[u[0],u[1],d[0],d[1]]}}}return{coordinateConversion:0,bounds:[0,0,0,0]}}};tW.layerName="BitmapLayer";tW.defaultProps=Xrn;var mIe=tW;function Yrn(s){let[n,r,c]=s,u=(c&240)/256,d=(c&15)/16;return[(n+d)/256,(r+u)/256]}function pvt(s){return Number.isFinite(s[0])}Ql();var gvt=`layout(std140) uniform scatterplotUniforms { float radiusScale; float radiusMinPixels; float radiusMaxPixels; @@ -5001,7 +5001,7 @@ fragColor = vFillColor; fragColor.a *= inCircle; DECKGL_FILTER_COLOR(fragColor, geometry); } -`;var qrn=`// Main shaders +`;var Zrn=`// Main shaders struct ScatterplotUniforms { radiusScale: f32, @@ -5205,7 +5205,7 @@ fn fragmentMain(varyings: Varyings) -> @location(0) vec4 { return fragColor; // return vec4(0, 0, 1, 1); } -`;function vvt(s){return qrn.replace("PICKING_COLOR_ATTRIBUTE",s?"@location(8) rowIndexes: u32,":"").replace("PICKING_COLOR_VALUE",s?"picking_getPickingColorFromIndex(attributes.rowIndexes)":"picking_getPickingColorFromIndex(attributes.instanceIndex)")}var Xrn=`struct ClipUniforms { +`;function vvt(s){return Zrn.replace("PICKING_COLOR_ATTRIBUTE",s?"@location(8) rowIndexes: u32,":"").replace("PICKING_COLOR_VALUE",s?"picking_getPickingColorFromIndex(attributes.rowIndexes)":"picking_getPickingColorFromIndex(attributes.instanceIndex)")}var Krn=`struct ClipUniforms { enabled: i32, mode: i32, bounds: vec4, @@ -5239,7 +5239,7 @@ fn clip_filterColor(geometryCoordinates: vec2) { discard; } } -`,Yrn={name:"clip",source:Xrn,props:{},uniforms:{},bindingLayout:[{name:"clip",group:2}],uniformTypes:{enabled:"i32",mode:"i32",bounds:"vec4"},defaultUniforms:{enabled:0,mode:0,bounds:[0,0,1,1]},getUniforms(s={}){let n={};return s.enabled!==void 0&&(n.enabled=s.enabled?1:0),s.mode!==void 0&&(n.mode=s.mode==="instance"?1:0),s.bounds!==void 0&&(n.bounds=s.bounds),n}},DB=Yrn;var _vt=[0,0,0,255],Zrn={radiusUnits:"meters",radiusScale:{type:"number",min:0,value:1},radiusMinPixels:{type:"number",min:0,value:0},radiusMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},lineWidthUnits:"meters",lineWidthScale:{type:"number",min:0,value:1},lineWidthMinPixels:{type:"number",min:0,value:0},lineWidthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,getPosition:{type:"accessor",value:s=>s.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:_vt},getLineColor:{type:"accessor",value:_vt},getLineWidth:{type:"accessor",value:1},getPixelOffset:{type:"accessor",value:[0,0]},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}},nW=class extends z3{getShaders(){let n=!!this.props.data?.attributes?.rowIndexes;return super.getShaders({vs:bvt,fs:wvt,source:vvt(n),defines:n?{USE_ROW_INDEXES:!0}:{},modules:[Zy,qy,Jy,mvt,...this.context.device.type==="webgpu"?[DB]:[]]})}initializeState(){let n=this.props.data?.attributes?.rowIndexes?{rowIndexes:{size:1,type:"uint32",noAlloc:!0}}:{};this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceRadius:{size:1,transition:!0,accessor:"getRadius",defaultValue:1,bufferGroup:"scatterplot-instance-data"},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255],bufferGroup:"scatterplot-instance-data"},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255],bufferGroup:"scatterplot-instance-data"},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1,bufferGroup:"scatterplot-instance-data"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset",bufferGroup:"scatterplot-instance-data"},...n})}updateState(n){super.updateState(n),n.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:n}){let{radiusUnits:r,radiusScale:c,radiusMinPixels:u,radiusMaxPixels:d,stroked:b,filled:w,billboard:_,antialiasing:x,lineWidthUnits:T,lineWidthScale:M,lineWidthMinPixels:L,lineWidthMaxPixels:I}=this.props,D={stroked:b,filled:w,billboard:_,antialiasing:x,radiusUnits:Pb[r],radiusScale:c,radiusMinPixels:u,radiusMaxPixels:d,lineWidthUnits:Pb[T],lineWidthScale:M,lineWidthMinPixels:L,lineWidthMaxPixels:I},F=this.state.model;F.shaderInputs.setProps({scatterplot:D}),F.draw(this.context.renderPass)}_getModel(){let n=[-1,-1,0,1,-1,0,-1,1,0,1,1,0];return new Vh(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new kb({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(n)}}}),isInstanced:!0})}};nW.defaultProps=Zrn;nW.layerName="ScatterplotLayer";var bIe=nW;var Hue={CLOCKWISE:1,COUNTER_CLOCKWISE:-1};function iW(s,n,r={}){return yvt(s,r)!==n?(Krn(s,r),!0):!1}function yvt(s,n={}){return Math.sign(que(s,n))}var wIe={x:0,y:1,z:2};function que(s,n={}){let{start:r=0,end:c=s.length,plane:u="xy"}=n,d=n.size||2,b=0,w=wIe[u[0]],_=wIe[u[1]];for(let x=r,T=c-d;x0){let u=!0;for(let d=0;dn[2]&&(r|=2),s[1]n[3]&&(r|=8),r}function oW(s,n){let{size:r=2,broken:c=!1,gridResolution:u=10,gridOffset:d=[0,0],startIndex:b=0,endIndex:w=s.length}=n||{},_=(w-b)/r,x=[],T=[x],M=iT(s,0,r,b),L,I,D=Svt(M,u,d,[]),F=[];xm(x,M);for(let O=1;O<_;O++){for(L=iT(s,O,r,b,L),I=sW(L,D);I;){Xue(M,L,I,D,F);let z=sW(F,D);z&&(Xue(M,F,z,D,F),I=z),xm(x,F),rW(M,F),esn(D,u,I),c&&x.length>r&&(x=[],T.push(x),xm(x,M)),I=sW(L,D)}xm(x,L),rW(M,L)}return c?T:T[0]}var xvt=0,Qrn=1;function aW(s,n=null,r){if(!s.length)return[];let{size:c=2,gridResolution:u=10,gridOffset:d=[0,0],edgeTypes:b=!1}=r||{},w=[],_=[{pos:s,types:b?new Array(s.length/c).fill(Qrn):null,holes:n||[]}],x=[[],[]],T=[];for(;_.length;){let{pos:M,types:L,holes:I}=_.shift();tsn(M,c,I[0]||M.length,x),T=Svt(x[0],u,d,T);let D=sW(x[1],T);if(D){let F=Evt(M,L,c,0,I[0]||M.length,T,D),O={pos:F[0].pos,types:F[0].types,holes:[]},z={pos:F[1].pos,types:F[1].types,holes:[]};_.push(O,z);for(let Z=0;Z=0?(xm(x,I)&&M.push(F),te+=D):M.length&&(M[M.length-1]=xvt),rW(O,I),z=D,Z=F;return[H?{pos:_,types:n&&T}:null,te?{pos:x,types:n&&M}:null]}function Svt(s,n,r,c){let u=Math.floor((s[0]-r[0])/n)*n+r[0],d=Math.floor((s[1]-r[1])/n)*n+r[1];return c[0]=u,c[1]=d,c[2]=u+n,c[3]=d+n,c}function esn(s,n,r){r&8?(s[1]+=n,s[3]+=n):r&4?(s[1]-=n,s[3]-=n):r&2?(s[0]+=n,s[2]+=n):r&1&&(s[0]-=n,s[2]-=n)}function tsn(s,n,r,c){let u=1/0,d=-1/0,b=1/0,w=-1/0;for(let _=0;_d?x:d,b=Tw?T:w}return c[0][0]=u,c[0][1]=b,c[1][0]=d,c[1][1]=w,c}function Yue(s,n){for(let r=0;ru&&(u=w,d=b-1)}return d}function rsn(s,n,r,c,u=nsn){let d=s[r],b=s[c-n];if(Math.abs(d-b)>180){let w=iT(s,0,n,r);w[0]+=Math.round((b-d)/360)*360,xm(s,w),w[1]=Math.sign(w[1])*u,xm(s,w),w[0]=d,xm(s,w)}}function Mvt(s,n,r,c){let u=s[0],d;for(let b=r;b180||w<-180)&&(d-=Math.round(w/360)*360),s[b]=u=d}}function Tvt(s,n){let r,c=s.length/n;for(let d=0;d=n.length&&(r+=1-n.length/u);let d=r*u;return c[0]=n[d],c[1]=n[d+1],c[2]=u===3&&n[d+2]||0,c}isClosed(n){if(!this.normalize)return!!this.opts.loop;let{positionSize:r}=this,c=n.length-r;return n[0]===n[c]&&n[1]===n[c+1]&&(r===2||n[2]===n[c+2])}};function Avt(s){return Array.isArray(s[0])}var csn=`struct PathUniforms { +`,Jrn={name:"clip",source:Krn,props:{},uniforms:{},bindingLayout:[{name:"clip",group:2}],uniformTypes:{enabled:"i32",mode:"i32",bounds:"vec4"},defaultUniforms:{enabled:0,mode:0,bounds:[0,0,1,1]},getUniforms(s={}){let n={};return s.enabled!==void 0&&(n.enabled=s.enabled?1:0),s.mode!==void 0&&(n.mode=s.mode==="instance"?1:0),s.bounds!==void 0&&(n.bounds=s.bounds),n}},DB=Jrn;var _vt=[0,0,0,255],Qrn={radiusUnits:"meters",radiusScale:{type:"number",min:0,value:1},radiusMinPixels:{type:"number",min:0,value:0},radiusMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},lineWidthUnits:"meters",lineWidthScale:{type:"number",min:0,value:1},lineWidthMinPixels:{type:"number",min:0,value:0},lineWidthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,getPosition:{type:"accessor",value:s=>s.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:_vt},getLineColor:{type:"accessor",value:_vt},getLineWidth:{type:"accessor",value:1},getPixelOffset:{type:"accessor",value:[0,0]},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}},nW=class extends z3{getShaders(){let n=!!this.props.data?.attributes?.rowIndexes;return super.getShaders({vs:bvt,fs:wvt,source:vvt(n),defines:n?{USE_ROW_INDEXES:!0}:{},modules:[Zy,qy,Jy,mvt,...this.context.device.type==="webgpu"?[DB]:[]]})}initializeState(){let n=this.props.data?.attributes?.rowIndexes?{rowIndexes:{size:1,type:"uint32",noAlloc:!0}}:{};this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceRadius:{size:1,transition:!0,accessor:"getRadius",defaultValue:1,bufferGroup:"scatterplot-instance-data"},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255],bufferGroup:"scatterplot-instance-data"},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255],bufferGroup:"scatterplot-instance-data"},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1,bufferGroup:"scatterplot-instance-data"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset",bufferGroup:"scatterplot-instance-data"},...n})}updateState(n){super.updateState(n),n.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:n}){let{radiusUnits:r,radiusScale:c,radiusMinPixels:u,radiusMaxPixels:d,stroked:b,filled:w,billboard:_,antialiasing:x,lineWidthUnits:T,lineWidthScale:M,lineWidthMinPixels:L,lineWidthMaxPixels:I}=this.props,D={stroked:b,filled:w,billboard:_,antialiasing:x,radiusUnits:Ab[r],radiusScale:c,radiusMinPixels:u,radiusMaxPixels:d,lineWidthUnits:Ab[T],lineWidthScale:M,lineWidthMinPixels:L,lineWidthMaxPixels:I},F=this.state.model;F.shaderInputs.setProps({scatterplot:D}),F.draw(this.context.renderPass)}_getModel(){let n=[-1,-1,0,1,-1,0,-1,1,0,1,1,0];return new Vh(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Lb({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(n)}}}),isInstanced:!0})}};nW.defaultProps=Qrn;nW.layerName="ScatterplotLayer";var bIe=nW;var Hue={CLOCKWISE:1,COUNTER_CLOCKWISE:-1};function iW(s,n,r={}){return yvt(s,r)!==n?(esn(s,r),!0):!1}function yvt(s,n={}){return Math.sign(que(s,n))}var wIe={x:0,y:1,z:2};function que(s,n={}){let{start:r=0,end:c=s.length,plane:u="xy"}=n,d=n.size||2,b=0,w=wIe[u[0]],_=wIe[u[1]];for(let x=r,T=c-d;x0){let u=!0;for(let d=0;dn[2]&&(r|=2),s[1]n[3]&&(r|=8),r}function oW(s,n){let{size:r=2,broken:c=!1,gridResolution:u=10,gridOffset:d=[0,0],startIndex:b=0,endIndex:w=s.length}=n||{},_=(w-b)/r,x=[],T=[x],M=iT(s,0,r,b),L,I,D=Svt(M,u,d,[]),F=[];xm(x,M);for(let O=1;O<_;O++){for(L=iT(s,O,r,b,L),I=sW(L,D);I;){Xue(M,L,I,D,F);let z=sW(F,D);z&&(Xue(M,F,z,D,F),I=z),xm(x,F),rW(M,F),isn(D,u,I),c&&x.length>r&&(x=[],T.push(x),xm(x,M)),I=sW(L,D)}xm(x,L),rW(M,L)}return c?T:T[0]}var xvt=0,nsn=1;function aW(s,n=null,r){if(!s.length)return[];let{size:c=2,gridResolution:u=10,gridOffset:d=[0,0],edgeTypes:b=!1}=r||{},w=[],_=[{pos:s,types:b?new Array(s.length/c).fill(nsn):null,holes:n||[]}],x=[[],[]],T=[];for(;_.length;){let{pos:M,types:L,holes:I}=_.shift();rsn(M,c,I[0]||M.length,x),T=Svt(x[0],u,d,T);let D=sW(x[1],T);if(D){let F=Evt(M,L,c,0,I[0]||M.length,T,D),O={pos:F[0].pos,types:F[0].types,holes:[]},z={pos:F[1].pos,types:F[1].types,holes:[]};_.push(O,z);for(let Z=0;Z=0?(xm(x,I)&&M.push(F),te+=D):M.length&&(M[M.length-1]=xvt),rW(O,I),z=D,Z=F;return[H?{pos:_,types:n&&T}:null,te?{pos:x,types:n&&M}:null]}function Svt(s,n,r,c){let u=Math.floor((s[0]-r[0])/n)*n+r[0],d=Math.floor((s[1]-r[1])/n)*n+r[1];return c[0]=u,c[1]=d,c[2]=u+n,c[3]=d+n,c}function isn(s,n,r){r&8?(s[1]+=n,s[3]+=n):r&4?(s[1]-=n,s[3]-=n):r&2?(s[0]+=n,s[2]+=n):r&1&&(s[0]-=n,s[2]-=n)}function rsn(s,n,r,c){let u=1/0,d=-1/0,b=1/0,w=-1/0;for(let _=0;_d?x:d,b=Tw?T:w}return c[0][0]=u,c[0][1]=b,c[1][0]=d,c[1][1]=w,c}function Yue(s,n){for(let r=0;ru&&(u=w,d=b-1)}return d}function asn(s,n,r,c,u=ssn){let d=s[r],b=s[c-n];if(Math.abs(d-b)>180){let w=iT(s,0,n,r);w[0]+=Math.round((b-d)/360)*360,xm(s,w),w[1]=Math.sign(w[1])*u,xm(s,w),w[0]=d,xm(s,w)}}function Mvt(s,n,r,c){let u=s[0],d;for(let b=r;b180||w<-180)&&(d-=Math.round(w/360)*360),s[b]=u=d}}function Tvt(s,n){let r,c=s.length/n;for(let d=0;d=n.length&&(r+=1-n.length/u);let d=r*u;return c[0]=n[d],c[1]=n[d+1],c[2]=u===3&&n[d+2]||0,c}isClosed(n){if(!this.normalize)return!!this.opts.loop;let{positionSize:r}=this,c=n.length-r;return n[0]===n[c]&&n[1]===n[c+1]&&(r===2||n[2]===n[c+2])}};function Avt(s){return Array.isArray(s[0])}var fsn=`struct PathUniforms { widthScale: f32, widthMinPixels: f32, widthMaxPixels: f32, @@ -5262,7 +5262,7 @@ var path: PathUniforms; bool billboard; highp int widthUnits; } path; -`,Lvt={name:"path",source:csn,vs:Pvt,fs:Pvt,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",jointType:"f32",capType:"f32",miterLimit:"f32",billboard:"f32",widthUnits:"i32"}};var kvt=`const EPSILON: f32 = 0.001; +`,Lvt={name:"path",source:fsn,vs:Pvt,fs:Pvt,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",jointType:"f32",capType:"f32",miterLimit:"f32",billboard:"f32",widthUnits:"i32"}};var kvt=`const EPSILON: f32 = 0.001; const ZERO_OFFSET: vec3 = vec3(0.0, 0.0, 0.0); struct JoinResult { @@ -6094,7 +6094,7 @@ fragColor = vColor; #endif DECKGL_FILTER_COLOR(fragColor, geometry); } -`;var Bvt=[0,0,0,255],lsn={widthUnits:"meters",widthScale:{type:"number",min:0,value:1},widthMinPixels:{type:"number",min:0,value:0},widthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},jointRounded:!1,capRounded:!1,miterLimit:{type:"number",min:0,value:4},antialiasing:!1,billboard:!1,_pathType:null,getPath:{type:"accessor",value:s=>s.path},getColor:{type:"accessor",value:Bvt},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},yIe={enter:(s,n)=>n.length?n.subarray(n.length-s.length):s};function usn(s){if(s.isGeospatial)return null;let{unitsPerMeter:n}=s.distanceScales;return[n[0],n[1],n[2]]}function Dvt(s,n){return s===n||!!(s&&n&&s.length===n.length&&s.every((r,c)=>r===n[c]))}var uW=class extends z3{getShaders(){let{antialiasing:n}=this.props;return super.getShaders({vs:Rvt,fs:Ivt,source:kvt,defines:n?{ANTIALIASING:1}:{},modules:[Zy,qy,Jy,Lvt,...this.context.device.type==="webgpu"?[DB]:[]]})}get wrapLongitude(){return!1}getBounds(){return this.context.device.type==="webgpu"?null:this.getAttributeManager()?.getBounds(["vertexPositions"])}getPathProjectionScale(n){let r=this.props.coordinateSystem;if(!!!this.getAttributeManager()?.getAttributes().instanceDashOffsets)return null;if(n instanceof R3&&n.zoom>=12&&(r==="default"||r==="lnglat"||r==="cartesian")){let b=fv.getUniforms({viewport:n,coordinateSystem:r,coordinateOrigin:this.props.coordinateOrigin,autoWrapLongitude:this.wrapLongitude});return[n.projectionMode,b.coordinateOrigin[1],b.commonOrigin[1],...b.commonUnitsPerWorldUnit,...b.commonUnitsPerWorldUnit2,b.commonUnitsPerMeter[2]]}let d=usn(n);return d?[n.projectionMode,...d]:[n.projectionMode]}shouldUpdateState(n){let{viewport:r}=this.context;return super.shouldUpdateState(n)||this.state?.tessellationResolution!==r.resolution||!Dvt(this.state?.pathProjectionScale,this.getPathProjectionScale(r))}initializeState(){let r=this.context.device.type==="webgpu";this.getAttributeManager().addInstanced({...r?{pathPositions:{size:24,type:"float32",transition:!1,accessor:"getPath",update:this.calculateWebGPUPositions,shaderAttributes:{instanceLeftPositions:{size:3,elementOffset:0},instanceStartPositions:{size:3,elementOffset:3},instanceEndPositions:{size:3,elementOffset:6},instanceRightPositions:{size:3,elementOffset:9},instanceLeftPositions64Low:{size:3,elementOffset:12},instanceStartPositions64Low:{size:3,elementOffset:15},instanceEndPositions64Low:{size:3,elementOffset:18},instanceRightPositions64Low:{size:3,elementOffset:21}},noAlloc:!0}}:{vertexPositions:{size:3,vertexOffset:1,type:"float64",fp64:this.use64bitPositions(),transition:yIe,accessor:"getPath",update:this.calculatePositions,noAlloc:!0,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}}},instanceTypes:{size:1,type:r?"float32":"uint8",update:this.calculateSegmentTypes,noAlloc:!0},instanceStrokeWidths:{size:1,accessor:"getWidth",transition:r?!1:yIe,defaultValue:1,bufferGroup:"path-instance-data"},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",accessor:"getColor",transition:r?!1:yIe,defaultValue:Bvt,bufferGroup:"path-instance-data"},rowIndexes:{size:1,type:"uint32",accessor:(u,{index:d})=>u&&u.__source?u.__source.index:d,bufferGroup:"path-instance-data"}}),this.setState({pathTesselator:new lW({fp64:this.use64bitPositions(),isWebGPU:r}),tessellationResolution:this.context.viewport.resolution,pathProjectionScale:this.getPathProjectionScale(this.context.viewport)})}updateState(n){super.updateState(n);let{props:r,oldProps:c,changeFlags:u}=n,d=this.getAttributeManager(),{viewport:b}=this.context,w=this.state.tessellationResolution!==b.resolution,_=this.getPathProjectionScale(b),x=!Dvt(this.state.pathProjectionScale,_),M=u.updateTriggersChanged&&(u.updateTriggersChanged.all||u.updateTriggersChanged.getPath)||r._pathType!==c._pathType||r.positionFormat!==c.positionFormat||r.wrapLongitude!==c.wrapLongitude||w;if(u.dataChanged||M){let{pathTesselator:I}=this.state,D=r.data.attributes||{};I.updateGeometry({data:r.data,geometryBuffer:D.getPath,buffers:D,normalize:!r._pathType,loop:r._pathType==="loop",getGeometry:r.getPath,positionFormat:r.positionFormat,wrapLongitude:r.wrapLongitude,resolution:b.resolution,dataChanged:M?void 0:u.dataChanged}),this.setState({numInstances:I.instanceCount,startIndices:I.vertexStarts,tessellationResolution:b.resolution,pathProjectionScale:_}),!u.dataChanged||M?d.invalidateAll():x&&d.invalidate("instanceDashOffsets")}else x&&(this.setState({pathProjectionScale:_}),d.invalidate("instanceDashOffsets"));(u.extensionsChanged||r.antialiasing!==c.antialiasing)&&(this.state.model?.destroy(),this.state.model=this._getModel(),d.invalidateAll())}getPickingInfo(n){let r=super.getPickingInfo(n),{index:c}=r,u=this.props.data;return u[0]&&u[0].__source&&(r.object=u.find(d=>d.__source.index===c)),r}disablePickingIndex(n){let r=this.props.data;if(r[0]&&r[0].__source)for(let c=0;c=0&&T=1&&s[0].length>=2&&Number.isFinite(s[0][0])}function Psn(s){let n=s[0],r=s[s.length-1];return n[0]===r[0]&&n[1]===r[1]&&n[2]===r[2]}function Lsn(s,n,r,c){for(let u=0;uw/n));let d=OB(s),b=c&&n===3;if(r){let w=d.length;d=d.slice();let _=[];for(let x=0;x_&&w>x||(_>x?(r||(d=d.slice()),Vvt(d,0,2,1)):(r||(d=d.slice()),Vvt(d,2,0,1)))}return(0,Wvt.default)(d,u,n)}var gW=class extends nT{constructor(n){let{fp64:r,IndexType:c=Uint32Array}=n;super({...n,attributes:{positions:{size:3,type:r?Float64Array:Float32Array},vertexValid:{type:Uint16Array,size:1},indices:{type:c,size:1}}})}get(n){let{attributes:r}=this;return n==="indices"?r.indices&&r.indices.subarray(0,this.vertexCount):r[n]}updateGeometry(n){super.updateGeometry(n);let r=this.buffers.indices;if(r)this.vertexCount=(r.value||r).length;else if(this.data&&!this.getGeometry)throw new Error("missing indices buffer")}normalizeGeometry(n){if(this.normalize){let r=Hvt(n,this.positionSize);return this.opts.resolution?aW(OB(r),pW(r),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?_Ie(OB(r),pW(r),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):r}return n}getGeometrySize(n){if(Xvt(n)){let r=0;for(let c of n)r+=this.getGeometrySize(c);return r}return OB(n).length/this.positionSize}getGeometryFromBuffer(n){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(n):null}updateGeometryAttributes(n,r){if(n&&Xvt(n))for(let c of n){let u=this.getGeometrySize(c);r.geometrySize=u,this.updateGeometryAttributes(c,r),r.vertexStart+=u,r.indexStart=this.indexStarts[r.geometryIndex+1]}else{let c=n;this._updateIndices(c,r),this._updatePositions(c,r),this._updateVertexValid(c,r)}}_updateIndices(n,{geometryIndex:r,vertexStart:c,indexStart:u}){let{attributes:d,indexStarts:b,typedArrayManager:w}=this,_=d.indices;if(!_||!n)return;let x=u,T=qvt(n,this.positionSize,this.opts.preproject,this.opts.full3d);_=w.allocate(_,u+T.length,{copy:!0});for(let M=0;M2?b[_*d+2]:0;u[w*3]=x,u[w*3+1]=T,u[w*3+2]=M}}_updateVertexValid(n,{vertexStart:r,geometrySize:c}){let{positionSize:u}=this,d=this.attributes.vertexValid,b=n&&pW(n);if(n&&n.edgeTypes?d.set(n.edgeTypes,r):d.fill(1,r,r+c),b)for(let w=0;w0&&!Number.isFinite(s[0])}var Rsn=`struct SolidPolygonUniforms { +`;var Bvt=[0,0,0,255],hsn={widthUnits:"meters",widthScale:{type:"number",min:0,value:1},widthMinPixels:{type:"number",min:0,value:0},widthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},jointRounded:!1,capRounded:!1,miterLimit:{type:"number",min:0,value:4},antialiasing:!1,billboard:!1,_pathType:null,getPath:{type:"accessor",value:s=>s.path},getColor:{type:"accessor",value:Bvt},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},yIe={enter:(s,n)=>n.length?n.subarray(n.length-s.length):s};function dsn(s){if(s.isGeospatial)return null;let{unitsPerMeter:n}=s.distanceScales;return[n[0],n[1],n[2]]}function Dvt(s,n){return s===n||!!(s&&n&&s.length===n.length&&s.every((r,c)=>r===n[c]))}var uW=class extends z3{getShaders(){let{antialiasing:n}=this.props;return super.getShaders({vs:Rvt,fs:Ivt,source:kvt,defines:n?{ANTIALIASING:1}:{},modules:[Zy,qy,Jy,Lvt,...this.context.device.type==="webgpu"?[DB]:[]]})}get wrapLongitude(){return!1}getBounds(){return this.context.device.type==="webgpu"?null:this.getAttributeManager()?.getBounds(["vertexPositions"])}getPathProjectionScale(n){let r=this.props.coordinateSystem;if(!!!this.getAttributeManager()?.getAttributes().instanceDashOffsets)return null;if(n instanceof R3&&n.zoom>=12&&(r==="default"||r==="lnglat"||r==="cartesian")){let b=fv.getUniforms({viewport:n,coordinateSystem:r,coordinateOrigin:this.props.coordinateOrigin,autoWrapLongitude:this.wrapLongitude});return[n.projectionMode,b.coordinateOrigin[1],b.commonOrigin[1],...b.commonUnitsPerWorldUnit,...b.commonUnitsPerWorldUnit2,b.commonUnitsPerMeter[2]]}let d=dsn(n);return d?[n.projectionMode,...d]:[n.projectionMode]}shouldUpdateState(n){let{viewport:r}=this.context;return super.shouldUpdateState(n)||this.state?.tessellationResolution!==r.resolution||!Dvt(this.state?.pathProjectionScale,this.getPathProjectionScale(r))}initializeState(){let r=this.context.device.type==="webgpu";this.getAttributeManager().addInstanced({...r?{pathPositions:{size:24,type:"float32",transition:!1,accessor:"getPath",update:this.calculateWebGPUPositions,shaderAttributes:{instanceLeftPositions:{size:3,elementOffset:0},instanceStartPositions:{size:3,elementOffset:3},instanceEndPositions:{size:3,elementOffset:6},instanceRightPositions:{size:3,elementOffset:9},instanceLeftPositions64Low:{size:3,elementOffset:12},instanceStartPositions64Low:{size:3,elementOffset:15},instanceEndPositions64Low:{size:3,elementOffset:18},instanceRightPositions64Low:{size:3,elementOffset:21}},noAlloc:!0}}:{vertexPositions:{size:3,vertexOffset:1,type:"float64",fp64:this.use64bitPositions(),transition:yIe,accessor:"getPath",update:this.calculatePositions,noAlloc:!0,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}}},instanceTypes:{size:1,type:r?"float32":"uint8",update:this.calculateSegmentTypes,noAlloc:!0},instanceStrokeWidths:{size:1,accessor:"getWidth",transition:r?!1:yIe,defaultValue:1,bufferGroup:"path-instance-data"},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",accessor:"getColor",transition:r?!1:yIe,defaultValue:Bvt,bufferGroup:"path-instance-data"},rowIndexes:{size:1,type:"uint32",accessor:(u,{index:d})=>u&&u.__source?u.__source.index:d,bufferGroup:"path-instance-data"}}),this.setState({pathTesselator:new lW({fp64:this.use64bitPositions(),isWebGPU:r}),tessellationResolution:this.context.viewport.resolution,pathProjectionScale:this.getPathProjectionScale(this.context.viewport)})}updateState(n){super.updateState(n);let{props:r,oldProps:c,changeFlags:u}=n,d=this.getAttributeManager(),{viewport:b}=this.context,w=this.state.tessellationResolution!==b.resolution,_=this.getPathProjectionScale(b),x=!Dvt(this.state.pathProjectionScale,_),M=u.updateTriggersChanged&&(u.updateTriggersChanged.all||u.updateTriggersChanged.getPath)||r._pathType!==c._pathType||r.positionFormat!==c.positionFormat||r.wrapLongitude!==c.wrapLongitude||w;if(u.dataChanged||M){let{pathTesselator:I}=this.state,D=r.data.attributes||{};I.updateGeometry({data:r.data,geometryBuffer:D.getPath,buffers:D,normalize:!r._pathType,loop:r._pathType==="loop",getGeometry:r.getPath,positionFormat:r.positionFormat,wrapLongitude:r.wrapLongitude,resolution:b.resolution,dataChanged:M?void 0:u.dataChanged}),this.setState({numInstances:I.instanceCount,startIndices:I.vertexStarts,tessellationResolution:b.resolution,pathProjectionScale:_}),!u.dataChanged||M?d.invalidateAll():x&&d.invalidate("instanceDashOffsets")}else x&&(this.setState({pathProjectionScale:_}),d.invalidate("instanceDashOffsets"));(u.extensionsChanged||r.antialiasing!==c.antialiasing)&&(this.state.model?.destroy(),this.state.model=this._getModel(),d.invalidateAll())}getPickingInfo(n){let r=super.getPickingInfo(n),{index:c}=r,u=this.props.data;return u[0]&&u[0].__source&&(r.object=u.find(d=>d.__source.index===c)),r}disablePickingIndex(n){let r=this.props.data;if(r[0]&&r[0].__source)for(let c=0;c=0&&T=1&&s[0].length>=2&&Number.isFinite(s[0][0])}function Rsn(s){let n=s[0],r=s[s.length-1];return n[0]===r[0]&&n[1]===r[1]&&n[2]===r[2]}function Isn(s,n,r,c){for(let u=0;uw/n));let d=OB(s),b=c&&n===3;if(r){let w=d.length;d=d.slice();let _=[];for(let x=0;x_&&w>x||(_>x?(r||(d=d.slice()),Vvt(d,0,2,1)):(r||(d=d.slice()),Vvt(d,2,0,1)))}return(0,Wvt.default)(d,u,n)}var gW=class extends nT{constructor(n){let{fp64:r,IndexType:c=Uint32Array}=n;super({...n,attributes:{positions:{size:3,type:r?Float64Array:Float32Array},vertexValid:{type:Uint16Array,size:1},indices:{type:c,size:1}}})}get(n){let{attributes:r}=this;return n==="indices"?r.indices&&r.indices.subarray(0,this.vertexCount):r[n]}updateGeometry(n){super.updateGeometry(n);let r=this.buffers.indices;if(r)this.vertexCount=(r.value||r).length;else if(this.data&&!this.getGeometry)throw new Error("missing indices buffer")}normalizeGeometry(n){if(this.normalize){let r=Hvt(n,this.positionSize);return this.opts.resolution?aW(OB(r),pW(r),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?_Ie(OB(r),pW(r),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):r}return n}getGeometrySize(n){if(Xvt(n)){let r=0;for(let c of n)r+=this.getGeometrySize(c);return r}return OB(n).length/this.positionSize}getGeometryFromBuffer(n){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(n):null}updateGeometryAttributes(n,r){if(n&&Xvt(n))for(let c of n){let u=this.getGeometrySize(c);r.geometrySize=u,this.updateGeometryAttributes(c,r),r.vertexStart+=u,r.indexStart=this.indexStarts[r.geometryIndex+1]}else{let c=n;this._updateIndices(c,r),this._updatePositions(c,r),this._updateVertexValid(c,r)}}_updateIndices(n,{geometryIndex:r,vertexStart:c,indexStart:u}){let{attributes:d,indexStarts:b,typedArrayManager:w}=this,_=d.indices;if(!_||!n)return;let x=u,T=qvt(n,this.positionSize,this.opts.preproject,this.opts.full3d);_=w.allocate(_,u+T.length,{copy:!0});for(let M=0;M2?b[_*d+2]:0;u[w*3]=x,u[w*3+1]=T,u[w*3+2]=M}}_updateVertexValid(n,{vertexStart:r,geometrySize:c}){let{positionSize:u}=this,d=this.attributes.vertexValid,b=n&&pW(n);if(n&&n.edgeTypes?d.set(n.edgeTypes,r):d.fill(1,r,r+c),b)for(let w=0;w0&&!Number.isFinite(s[0])}var Bsn=`struct SolidPolygonUniforms { extruded: f32, isWireframe: f32, elevationScale: f32, @@ -6106,7 +6106,7 @@ DECKGL_FILTER_COLOR(fragColor, geometry); bool isWireframe; float elevationScale; } solidPolygon; -`,Zvt={name:"solidPolygon",source:Rsn,vs:Yvt,fs:Yvt,uniformTypes:{extruded:"f32",isWireframe:"f32",elevationScale:"f32"}};var tfe=`in vec4 fillColors; +`,Zvt={name:"solidPolygon",source:Bsn,vs:Yvt,fs:Yvt,uniformTypes:{extruded:"f32",isWireframe:"f32",elevationScale:"f32"}};var tfe=`in vec4 fillColors; in vec4 lineColors; in float rowIndexes; out vec4 vColor; @@ -6272,7 +6272,7 @@ fn fragmentMain(inp: Varyings) -> @location(0) vec4 { return deckgl_premultiplied_alpha(fragColor); } -`}function Isn(){return`${e_t()} +`}function Osn(){return`${e_t()} struct Attributes { @location(0) vertexPositions: vec3, @@ -6328,7 +6328,7 @@ fn vertexMain(attributes: Attributes) -> Varyings { } ${t_t()} -`}function Dsn(s){return`const RING_WINDING_ORDER_CW: bool = ${s?"true":"false"}; +`}function Nsn(s){return`const RING_WINDING_ORDER_CW: bool = ${s?"true":"false"}; ${e_t()} @@ -6418,11 +6418,11 @@ fn vertexMain(attributes: Attributes) -> Varyings { } ${t_t()} -`}function n_t(s,n){return s==="top"?Isn():Dsn(n)}var ife=[0,0,0,255],Bsn={filled:!0,extruded:!1,wireframe:!1,_normalize:!0,_windingOrder:"CW",_full3d:!1,elevationScale:{type:"number",min:0,value:1},getPolygon:{type:"accessor",value:s=>s.polygon},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:ife},getLineColor:{type:"accessor",value:ife},material:!0},nfe={enter:(s,n)=>n.length?n.subarray(n.length-s.length):s},mW=class extends z3{getShaders(n){let r=!this.props._normalize&&this.props._windingOrder==="CCW"?0:1;return super.getShaders({vs:n==="top"?Kvt:Jvt,fs:Qvt,source:n_t(n,!!r),defines:{RING_WINDING_ORDER_CW:r},modules:[Zy,qy,ZD,Jy,Zvt,...this.context.device.type==="webgpu"?[DB]:[]]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){let{viewport:n}=this.context,{coordinateSystem:r}=this.props,{_full3d:c}=this.props;n.isGeospatial&&r==="default"&&(r="lnglat");let u;r==="lnglat"&&(c?u=n.projectPosition.bind(n):u=n.projectFlat.bind(n)),this.setState({numInstances:0,polygonTesselator:new gW({preproject:u,fp64:this.use64bitPositions(),IndexType:Uint32Array})});let d=this.getAttributeManager(),b=!0,w=this.context.device.type==="webgpu";d.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:b},vertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:nfe,accessor:"getPolygon",update:this.calculatePositions,noAlloc:b,...w?{}:{shaderAttributes:{nextVertexPositions:{vertexOffset:1}}}},...w?{nextVertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:!1,update:this.calculateNextPositions,noAlloc:b}}:{},[w?"vertexValid":"instanceVertexValid"]:{size:1,type:w?"float32":"uint16",stepMode:"instance",update:this.calculateVertexValid,noAlloc:b},elevations:{size:1,stepMode:"dynamic",transition:nfe,accessor:"getElevation",bufferGroup:"solid-polygon-instance-data"},fillColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:nfe,accessor:"getFillColor",defaultValue:ife,bufferGroup:"solid-polygon-instance-data"},lineColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:nfe,accessor:"getLineColor",defaultValue:ife,bufferGroup:"solid-polygon-instance-data"},rowIndexes:{size:1,type:"uint32",stepMode:"dynamic",accessor:(_,{index:x})=>_&&_.__source?_.__source.index:x,bufferGroup:"solid-polygon-instance-data"}})}getPickingInfo(n){let r=super.getPickingInfo(n),{index:c}=r,u=this.props.data;return u[0]&&u[0].__source&&(r.object=u.find(d=>d.__source.index===c)),r}disablePickingIndex(n){let r=this.props.data;if(r[0]&&r[0].__source)for(let c=0;cw.destroy()),this.setState(this._getModels()),d.invalidateAll())}updateGeometry({props:n,oldProps:r,changeFlags:c}){if(c.dataChanged||c.updateTriggersChanged&&(c.updateTriggersChanged.all||c.updateTriggersChanged.getPolygon)){let{polygonTesselator:d}=this.state,b=n.data.attributes||{};d.updateGeometry({data:n.data,normalize:n._normalize,geometryBuffer:b.getPolygon,buffers:this.context.device.type==="webgpu"?{...b}:b,getGeometry:n.getPolygon,positionFormat:n.positionFormat,wrapLongitude:n.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:c.dataChanged,full3d:n._full3d}),this.setState({numInstances:d.instanceCount,startIndices:d.vertexStarts}),c.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(){let{id:n,filled:r,extruded:c}=this.props,u,d,b;if(r){let w=this.getShaders("top");w.defines={...w.defines,NON_INSTANCED_MODEL:1};let _=this.getAttributeManager().getBufferLayouts({isInstanced:!1});this.context.device.type==="webgpu"&&(_=_.filter(x=>x.name!=="indices"&&x.name!=="vertexValid"&&x.name!=="instanceVertexValid"&&x.name!=="nextVertexPositions")),u=new Vh(this.context.device,{...w,id:`${n}-top`,topology:"triangle-list",bufferLayout:_,isIndexed:!0,userData:{excludeAttributes:{vertexValid:!0,instanceVertexValid:!0,nextVertexPositions:!0}}})}if(c){let w=this.getAttributeManager().getBufferLayouts({isInstanced:!0});this.context.device.type==="webgpu"&&(w=w.filter(_=>_.name!=="indices")),d=new Vh(this.context.device,{...this.getShaders("side"),id:`${n}-side`,bufferLayout:w,geometry:new kb({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,1,1,0,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}}),b=new Vh(this.context.device,{...this.getShaders("side"),id:`${n}-wireframe`,bufferLayout:w,geometry:new kb({topology:"line-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,0,1,1,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}})}return{models:[d,b,u].filter(Boolean),topModel:u,sideModel:d,wireframeModel:b}}calculateIndices(n){let{polygonTesselator:r}=this.state;n.startIndices=r.indexStarts,n.value=r.get("indices")}calculatePositions(n){let{polygonTesselator:r}=this.state;n.startIndices=r.vertexStarts;let c=this.props.data.attributes?.getPolygon;if(this.context.device.type==="webgpu"&&ArrayBuffer.isView(c?.value)){let{value:u,size:d=3,offset:b=0,stride:w}=c,_=b/u.BYTES_PER_ELEMENT,x=w?w/u.BYTES_PER_ELEMENT:d,T=new Float64Array(r.instanceCount*3);for(let M=0;M2?u[L+2]:0}n.value=T;return}n.value=r.get("positions")}calculateVertexValid(n){let r=this.props.data.attributes?.instanceVertexValid?.value,c=this.context.device.type==="webgpu"&&r?r:this.state.polygonTesselator.get("vertexValid");n.value=this.context.device.type==="webgpu"&&c?Float32Array.from(c):c}calculateNextPositions(n){let{polygonTesselator:r}=this.state,c=this.getAttributeManager().getAttributes(),u=c.vertexPositions.value,d=this.props.data.attributes?.instanceVertexValid?.value||c.vertexValid?.value||r.get("vertexValid");if(n.startIndices=r.vertexStarts,!u){n.value=u;return}let b=u.length/3,w=new u.constructor(u.length);for(let _=0;_phe,BoxGeometry:()=>X4,Color:()=>Go,DirectionalLight:()=>dhe,DoubleSide:()=>Mv,EdgesGeometry:()=>uhe,GridHelper:()=>mhe,Group:()=>dT,InstancedMesh:()=>lhe,LineBasicMaterial:()=>pO,LineSegments:()=>zW,Matrix4:()=>Il,Mesh:()=>Mm,MeshBasicMaterial:()=>hO,MeshPhongMaterial:()=>fhe,PerspectiveCamera:()=>pg,Quaternion:()=>h2,Raycaster:()=>ghe,Scene:()=>ahe,Vector2:()=>ka,Vector3:()=>Gt,WebGLRenderer:()=>UW});var a5e="160";var oon=0,N_t=1,aon=2;var g2t=1,con=2,H3=3,bT=0,Tm=1,Mv=2;var pT=0,oO=1,F_t=2,U_t=3,z_t=4,lon=5,j4=100,uon=101,fon=102,G_t=103,j_t=104,hon=200,don=201,pon=202,gon=203,x6e=204,E6e=205,mon=206,bon=207,won=208,von=209,_on=210,yon=211,xon=212,Eon=213,Son=214,Mon=0,Ton=1,Con=2,jfe=3,Aon=4,Pon=5,Lon=6,kon=7,c5e=0,Ron=1,Ion=2,gT=0,Don=1,Bon=2,Oon=3,Non=4,Fon=5,Uon=6;var m2t=300,lO=301,uO=302,S6e=303,M6e=304,bhe=306,T6e=1e3,Tv=1001,C6e=1002,dg=1003,$_t=1004;var $Ie=1005;var Ob=1006,zon=1007;var DW=1008;var mT=1009,Gon=1010,jon=1011,l5e=1012,b2t=1013,fT=1014,hT=1015,BW=1016,w2t=1017,v2t=1018,W4=1020,$on=1021,Cv=1023,Von=1024,Won=1025,H4=1026,fO=1027,Hon=1028,_2t=1029,qon=1030,y2t=1031,x2t=1033,VIe=33776,WIe=33777,HIe=33778,qIe=33779,V_t=35840,W_t=35841,H_t=35842,q_t=35843,E2t=36196,X_t=37492,Y_t=37496,Z_t=37808,K_t=37809,J_t=37810,Q_t=37811,eyt=37812,tyt=37813,nyt=37814,iyt=37815,ryt=37816,syt=37817,oyt=37818,ayt=37819,cyt=37820,lyt=37821,XIe=36492,uyt=36494,fyt=36495,Xon=36283,hyt=36284,dyt=36285,pyt=36286;var $fe=2300,Vfe=2301,YIe=2302,gyt=2400,myt=2401,byt=2402;var S2t=3e3,q4=3001,Yon=3200,Zon=3201,M2t=0,Kon=1,Nb="",Td="srgb",Y3="srgb-linear",u5e="display-p3",whe="display-p3-linear",Wfe="linear",dl="srgb",Hfe="rec709",qfe="p3";var GB=7680;var wyt=519,Jon=512,Qon=513,ean=514,T2t=515,tan=516,nan=517,ian=518,ran=519,vyt=35044;var _yt="300 es",A6e=1035,X3=2e3,Xfe=2001,wT=class{addEventListener(n,r){this._listeners===void 0&&(this._listeners={});let c=this._listeners;c[n]===void 0&&(c[n]=[]),c[n].indexOf(r)===-1&&c[n].push(r)}hasEventListener(n,r){if(this._listeners===void 0)return!1;let c=this._listeners;return c[n]!==void 0&&c[n].indexOf(r)!==-1}removeEventListener(n,r){if(this._listeners===void 0)return;let u=this._listeners[n];if(u!==void 0){let d=u.indexOf(r);d!==-1&&u.splice(d,1)}}dispatchEvent(n){if(this._listeners===void 0)return;let c=this._listeners[n.type];if(c!==void 0){n.target=this;let u=c.slice(0);for(let d=0,b=u.length;d>8&255]+gp[s>>16&255]+gp[s>>24&255]+"-"+gp[n&255]+gp[n>>8&255]+"-"+gp[n>>16&15|64]+gp[n>>24&255]+"-"+gp[r&63|128]+gp[r>>8&255]+"-"+gp[r>>16&255]+gp[r>>24&255]+gp[c&255]+gp[c>>8&255]+gp[c>>16&255]+gp[c>>24&255]).toLowerCase()}function Sm(s,n,r){return Math.max(n,Math.min(r,s))}function san(s,n){return(s%n+n)%n}function ZIe(s,n,r){return(1-r)*s+r*n}function yyt(s){return(s&s-1)===0&&s!==0}function L6e(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function MW(s,n){switch(n.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function Em(s,n){switch(n.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}var ka=class s{constructor(n=0,r=0){s.prototype.isVector2=!0,this.x=n,this.y=r}get width(){return this.x}set width(n){this.x=n}get height(){return this.y}set height(n){this.y=n}set(n,r){return this.x=n,this.y=r,this}setScalar(n){return this.x=n,this.y=n,this}setX(n){return this.x=n,this}setY(n){return this.y=n,this}setComponent(n,r){switch(n){case 0:this.x=r;break;case 1:this.y=r;break;default:throw new Error("index is out of range: "+n)}return this}getComponent(n){switch(n){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+n)}}clone(){return new this.constructor(this.x,this.y)}copy(n){return this.x=n.x,this.y=n.y,this}add(n){return this.x+=n.x,this.y+=n.y,this}addScalar(n){return this.x+=n,this.y+=n,this}addVectors(n,r){return this.x=n.x+r.x,this.y=n.y+r.y,this}addScaledVector(n,r){return this.x+=n.x*r,this.y+=n.y*r,this}sub(n){return this.x-=n.x,this.y-=n.y,this}subScalar(n){return this.x-=n,this.y-=n,this}subVectors(n,r){return this.x=n.x-r.x,this.y=n.y-r.y,this}multiply(n){return this.x*=n.x,this.y*=n.y,this}multiplyScalar(n){return this.x*=n,this.y*=n,this}divide(n){return this.x/=n.x,this.y/=n.y,this}divideScalar(n){return this.multiplyScalar(1/n)}applyMatrix3(n){let r=this.x,c=this.y,u=n.elements;return this.x=u[0]*r+u[3]*c+u[6],this.y=u[1]*r+u[4]*c+u[7],this}min(n){return this.x=Math.min(this.x,n.x),this.y=Math.min(this.y,n.y),this}max(n){return this.x=Math.max(this.x,n.x),this.y=Math.max(this.y,n.y),this}clamp(n,r){return this.x=Math.max(n.x,Math.min(r.x,this.x)),this.y=Math.max(n.y,Math.min(r.y,this.y)),this}clampScalar(n,r){return this.x=Math.max(n,Math.min(r,this.x)),this.y=Math.max(n,Math.min(r,this.y)),this}clampLength(n,r){let c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(n,Math.min(r,c)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(n){return this.x*n.x+this.y*n.y}cross(n){return this.x*n.y-this.y*n.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(n){let r=Math.sqrt(this.lengthSq()*n.lengthSq());if(r===0)return Math.PI/2;let c=this.dot(n)/r;return Math.acos(Sm(c,-1,1))}distanceTo(n){return Math.sqrt(this.distanceToSquared(n))}distanceToSquared(n){let r=this.x-n.x,c=this.y-n.y;return r*r+c*c}manhattanDistanceTo(n){return Math.abs(this.x-n.x)+Math.abs(this.y-n.y)}setLength(n){return this.normalize().multiplyScalar(n)}lerp(n,r){return this.x+=(n.x-this.x)*r,this.y+=(n.y-this.y)*r,this}lerpVectors(n,r,c){return this.x=n.x+(r.x-n.x)*c,this.y=n.y+(r.y-n.y)*c,this}equals(n){return n.x===this.x&&n.y===this.y}fromArray(n,r=0){return this.x=n[r],this.y=n[r+1],this}toArray(n=[],r=0){return n[r]=this.x,n[r+1]=this.y,n}fromBufferAttribute(n,r){return this.x=n.getX(r),this.y=n.getY(r),this}rotateAround(n,r){let c=Math.cos(r),u=Math.sin(r),d=this.x-n.x,b=this.y-n.y;return this.x=d*c-b*u+n.x,this.y=d*u+b*c+n.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Xo=class s{constructor(n,r,c,u,d,b,w,_,x){s.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],n!==void 0&&this.set(n,r,c,u,d,b,w,_,x)}set(n,r,c,u,d,b,w,_,x){let T=this.elements;return T[0]=n,T[1]=u,T[2]=w,T[3]=r,T[4]=d,T[5]=_,T[6]=c,T[7]=b,T[8]=x,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(n){let r=this.elements,c=n.elements;return r[0]=c[0],r[1]=c[1],r[2]=c[2],r[3]=c[3],r[4]=c[4],r[5]=c[5],r[6]=c[6],r[7]=c[7],r[8]=c[8],this}extractBasis(n,r,c){return n.setFromMatrix3Column(this,0),r.setFromMatrix3Column(this,1),c.setFromMatrix3Column(this,2),this}setFromMatrix4(n){let r=n.elements;return this.set(r[0],r[4],r[8],r[1],r[5],r[9],r[2],r[6],r[10]),this}multiply(n){return this.multiplyMatrices(this,n)}premultiply(n){return this.multiplyMatrices(n,this)}multiplyMatrices(n,r){let c=n.elements,u=r.elements,d=this.elements,b=c[0],w=c[3],_=c[6],x=c[1],T=c[4],M=c[7],L=c[2],I=c[5],D=c[8],F=u[0],O=u[3],z=u[6],Z=u[1],H=u[4],te=u[7],oe=u[2],ne=u[5],ue=u[8];return d[0]=b*F+w*Z+_*oe,d[3]=b*O+w*H+_*ne,d[6]=b*z+w*te+_*ue,d[1]=x*F+T*Z+M*oe,d[4]=x*O+T*H+M*ne,d[7]=x*z+T*te+M*ue,d[2]=L*F+I*Z+D*oe,d[5]=L*O+I*H+D*ne,d[8]=L*z+I*te+D*ue,this}multiplyScalar(n){let r=this.elements;return r[0]*=n,r[3]*=n,r[6]*=n,r[1]*=n,r[4]*=n,r[7]*=n,r[2]*=n,r[5]*=n,r[8]*=n,this}determinant(){let n=this.elements,r=n[0],c=n[1],u=n[2],d=n[3],b=n[4],w=n[5],_=n[6],x=n[7],T=n[8];return r*b*T-r*w*x-c*d*T+c*w*_+u*d*x-u*b*_}invert(){let n=this.elements,r=n[0],c=n[1],u=n[2],d=n[3],b=n[4],w=n[5],_=n[6],x=n[7],T=n[8],M=T*b-w*x,L=w*_-T*d,I=x*d-b*_,D=r*M+c*L+u*I;if(D===0)return this.set(0,0,0,0,0,0,0,0,0);let F=1/D;return n[0]=M*F,n[1]=(u*x-T*c)*F,n[2]=(w*c-u*b)*F,n[3]=L*F,n[4]=(T*r-u*_)*F,n[5]=(u*d-w*r)*F,n[6]=I*F,n[7]=(c*_-x*r)*F,n[8]=(b*r-c*d)*F,this}transpose(){let n,r=this.elements;return n=r[1],r[1]=r[3],r[3]=n,n=r[2],r[2]=r[6],r[6]=n,n=r[5],r[5]=r[7],r[7]=n,this}getNormalMatrix(n){return this.setFromMatrix4(n).invert().transpose()}transposeIntoArray(n){let r=this.elements;return n[0]=r[0],n[1]=r[3],n[2]=r[6],n[3]=r[1],n[4]=r[4],n[5]=r[7],n[6]=r[2],n[7]=r[5],n[8]=r[8],this}setUvTransform(n,r,c,u,d,b,w){let _=Math.cos(d),x=Math.sin(d);return this.set(c*_,c*x,-c*(_*b+x*w)+b+n,-u*x,u*_,-u*(-x*b+_*w)+w+r,0,0,1),this}scale(n,r){return this.premultiply(KIe.makeScale(n,r)),this}rotate(n){return this.premultiply(KIe.makeRotation(-n)),this}translate(n,r){return this.premultiply(KIe.makeTranslation(n,r)),this}makeTranslation(n,r){return n.isVector2?this.set(1,0,n.x,0,1,n.y,0,0,1):this.set(1,0,n,0,1,r,0,0,1),this}makeRotation(n){let r=Math.cos(n),c=Math.sin(n);return this.set(r,-c,0,c,r,0,0,0,1),this}makeScale(n,r){return this.set(n,0,0,0,r,0,0,0,1),this}equals(n){let r=this.elements,c=n.elements;for(let u=0;u<9;u++)if(r[u]!==c[u])return!1;return!0}fromArray(n,r=0){for(let c=0;c<9;c++)this.elements[c]=n[c+r];return this}toArray(n=[],r=0){let c=this.elements;return n[r]=c[0],n[r+1]=c[1],n[r+2]=c[2],n[r+3]=c[3],n[r+4]=c[4],n[r+5]=c[5],n[r+6]=c[6],n[r+7]=c[7],n[r+8]=c[8],n}clone(){return new this.constructor().fromArray(this.elements)}},KIe=new Xo;function C2t(s){for(let n=s.length-1;n>=0;--n)if(s[n]>=65535)return!0;return!1}function Yfe(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function oan(){let s=Yfe("canvas");return s.style.display="block",s}var xyt={};function RW(s){s in xyt||(xyt[s]=!0,console.warn(s))}var Eyt=new Xo().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Syt=new Xo().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),dfe={[Y3]:{transfer:Wfe,primaries:Hfe,toReference:s=>s,fromReference:s=>s},[Td]:{transfer:dl,primaries:Hfe,toReference:s=>s.convertSRGBToLinear(),fromReference:s=>s.convertLinearToSRGB()},[whe]:{transfer:Wfe,primaries:qfe,toReference:s=>s.applyMatrix3(Syt),fromReference:s=>s.applyMatrix3(Eyt)},[u5e]:{transfer:dl,primaries:qfe,toReference:s=>s.convertSRGBToLinear().applyMatrix3(Syt),fromReference:s=>s.applyMatrix3(Eyt).convertLinearToSRGB()}},aan=new Set([Y3,whe]),Pc={enabled:!0,_workingColorSpace:Y3,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(s){if(!aan.has(s))throw new Error(`Unsupported working color space, "${s}".`);this._workingColorSpace=s},convert:function(s,n,r){if(this.enabled===!1||n===r||!n||!r)return s;let c=dfe[n].toReference,u=dfe[r].fromReference;return u(c(s))},fromWorkingColorSpace:function(s,n){return this.convert(s,this._workingColorSpace,n)},toWorkingColorSpace:function(s,n){return this.convert(s,n,this._workingColorSpace)},getPrimaries:function(s){return dfe[s].primaries},getTransfer:function(s){return s===Nb?Wfe:dfe[s].transfer}};function aO(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function JIe(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}var jB,Zfe=class{static getDataURL(n){if(/^data:/i.test(n.src)||typeof HTMLCanvasElement>"u")return n.src;let r;if(n instanceof HTMLCanvasElement)r=n;else{jB===void 0&&(jB=Yfe("canvas")),jB.width=n.width,jB.height=n.height;let c=jB.getContext("2d");n instanceof ImageData?c.putImageData(n,0,0):c.drawImage(n,0,0,n.width,n.height),r=jB}return r.width>2048||r.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",n),r.toDataURL("image/jpeg",.6)):r.toDataURL("image/png")}static sRGBToLinear(n){if(typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap){let r=Yfe("canvas");r.width=n.width,r.height=n.height;let c=r.getContext("2d");c.drawImage(n,0,0,n.width,n.height);let u=c.getImageData(0,0,n.width,n.height),d=u.data;for(let b=0;b0&&(c.userData=this.userData),r||(n.textures[this.uuid]=c),c}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(n){if(this.mapping!==m2t)return n;if(n.applyMatrix3(this.matrix),n.x<0||n.x>1)switch(this.wrapS){case T6e:n.x=n.x-Math.floor(n.x);break;case Tv:n.x=n.x<0?0:1;break;case C6e:Math.abs(Math.floor(n.x)%2)===1?n.x=Math.ceil(n.x)-n.x:n.x=n.x-Math.floor(n.x);break}if(n.y<0||n.y>1)switch(this.wrapT){case T6e:n.y=n.y-Math.floor(n.y);break;case Tv:n.y=n.y<0?0:1;break;case C6e:Math.abs(Math.floor(n.y)%2)===1?n.y=Math.ceil(n.y)-n.y:n.y=n.y-Math.floor(n.y);break}return this.flipY&&(n.y=1-n.y),n}set needsUpdate(n){n===!0&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return RW("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Td?q4:S2t}set encoding(n){RW("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=n===q4?Td:Nb}};Av.DEFAULT_IMAGE=null;Av.DEFAULT_MAPPING=m2t;Av.DEFAULT_ANISOTROPY=1;var qh=class s{constructor(n=0,r=0,c=0,u=1){s.prototype.isVector4=!0,this.x=n,this.y=r,this.z=c,this.w=u}get width(){return this.z}set width(n){this.z=n}get height(){return this.w}set height(n){this.w=n}set(n,r,c,u){return this.x=n,this.y=r,this.z=c,this.w=u,this}setScalar(n){return this.x=n,this.y=n,this.z=n,this.w=n,this}setX(n){return this.x=n,this}setY(n){return this.y=n,this}setZ(n){return this.z=n,this}setW(n){return this.w=n,this}setComponent(n,r){switch(n){case 0:this.x=r;break;case 1:this.y=r;break;case 2:this.z=r;break;case 3:this.w=r;break;default:throw new Error("index is out of range: "+n)}return this}getComponent(n){switch(n){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+n)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(n){return this.x=n.x,this.y=n.y,this.z=n.z,this.w=n.w!==void 0?n.w:1,this}add(n){return this.x+=n.x,this.y+=n.y,this.z+=n.z,this.w+=n.w,this}addScalar(n){return this.x+=n,this.y+=n,this.z+=n,this.w+=n,this}addVectors(n,r){return this.x=n.x+r.x,this.y=n.y+r.y,this.z=n.z+r.z,this.w=n.w+r.w,this}addScaledVector(n,r){return this.x+=n.x*r,this.y+=n.y*r,this.z+=n.z*r,this.w+=n.w*r,this}sub(n){return this.x-=n.x,this.y-=n.y,this.z-=n.z,this.w-=n.w,this}subScalar(n){return this.x-=n,this.y-=n,this.z-=n,this.w-=n,this}subVectors(n,r){return this.x=n.x-r.x,this.y=n.y-r.y,this.z=n.z-r.z,this.w=n.w-r.w,this}multiply(n){return this.x*=n.x,this.y*=n.y,this.z*=n.z,this.w*=n.w,this}multiplyScalar(n){return this.x*=n,this.y*=n,this.z*=n,this.w*=n,this}applyMatrix4(n){let r=this.x,c=this.y,u=this.z,d=this.w,b=n.elements;return this.x=b[0]*r+b[4]*c+b[8]*u+b[12]*d,this.y=b[1]*r+b[5]*c+b[9]*u+b[13]*d,this.z=b[2]*r+b[6]*c+b[10]*u+b[14]*d,this.w=b[3]*r+b[7]*c+b[11]*u+b[15]*d,this}divideScalar(n){return this.multiplyScalar(1/n)}setAxisAngleFromQuaternion(n){this.w=2*Math.acos(n.w);let r=Math.sqrt(1-n.w*n.w);return r<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=n.x/r,this.y=n.y/r,this.z=n.z/r),this}setAxisAngleFromRotationMatrix(n){let r,c,u,d,_=n.elements,x=_[0],T=_[4],M=_[8],L=_[1],I=_[5],D=_[9],F=_[2],O=_[6],z=_[10];if(Math.abs(T-L)<.01&&Math.abs(M-F)<.01&&Math.abs(D-O)<.01){if(Math.abs(T+L)<.1&&Math.abs(M+F)<.1&&Math.abs(D+O)<.1&&Math.abs(x+I+z-3)<.1)return this.set(1,0,0,0),this;r=Math.PI;let H=(x+1)/2,te=(I+1)/2,oe=(z+1)/2,ne=(T+L)/4,ue=(M+F)/4,Te=(D+O)/4;return H>te&&H>oe?H<.01?(c=0,u=.707106781,d=.707106781):(c=Math.sqrt(H),u=ne/c,d=ue/c):te>oe?te<.01?(c=.707106781,u=0,d=.707106781):(u=Math.sqrt(te),c=ne/u,d=Te/u):oe<.01?(c=.707106781,u=.707106781,d=0):(d=Math.sqrt(oe),c=ue/d,u=Te/d),this.set(c,u,d,r),this}let Z=Math.sqrt((O-D)*(O-D)+(M-F)*(M-F)+(L-T)*(L-T));return Math.abs(Z)<.001&&(Z=1),this.x=(O-D)/Z,this.y=(M-F)/Z,this.z=(L-T)/Z,this.w=Math.acos((x+I+z-1)/2),this}min(n){return this.x=Math.min(this.x,n.x),this.y=Math.min(this.y,n.y),this.z=Math.min(this.z,n.z),this.w=Math.min(this.w,n.w),this}max(n){return this.x=Math.max(this.x,n.x),this.y=Math.max(this.y,n.y),this.z=Math.max(this.z,n.z),this.w=Math.max(this.w,n.w),this}clamp(n,r){return this.x=Math.max(n.x,Math.min(r.x,this.x)),this.y=Math.max(n.y,Math.min(r.y,this.y)),this.z=Math.max(n.z,Math.min(r.z,this.z)),this.w=Math.max(n.w,Math.min(r.w,this.w)),this}clampScalar(n,r){return this.x=Math.max(n,Math.min(r,this.x)),this.y=Math.max(n,Math.min(r,this.y)),this.z=Math.max(n,Math.min(r,this.z)),this.w=Math.max(n,Math.min(r,this.w)),this}clampLength(n,r){let c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(n,Math.min(r,c)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(n){return this.x*n.x+this.y*n.y+this.z*n.z+this.w*n.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(n){return this.normalize().multiplyScalar(n)}lerp(n,r){return this.x+=(n.x-this.x)*r,this.y+=(n.y-this.y)*r,this.z+=(n.z-this.z)*r,this.w+=(n.w-this.w)*r,this}lerpVectors(n,r,c){return this.x=n.x+(r.x-n.x)*c,this.y=n.y+(r.y-n.y)*c,this.z=n.z+(r.z-n.z)*c,this.w=n.w+(r.w-n.w)*c,this}equals(n){return n.x===this.x&&n.y===this.y&&n.z===this.z&&n.w===this.w}fromArray(n,r=0){return this.x=n[r],this.y=n[r+1],this.z=n[r+2],this.w=n[r+3],this}toArray(n=[],r=0){return n[r]=this.x,n[r+1]=this.y,n[r+2]=this.z,n[r+3]=this.w,n}fromBufferAttribute(n,r){return this.x=n.getX(r),this.y=n.getY(r),this.z=n.getZ(r),this.w=n.getW(r),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},k6e=class extends wT{constructor(n=1,r=1,c={}){super(),this.isRenderTarget=!0,this.width=n,this.height=r,this.depth=1,this.scissor=new qh(0,0,n,r),this.scissorTest=!1,this.viewport=new qh(0,0,n,r);let u={width:n,height:r,depth:1};c.encoding!==void 0&&(RW("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),c.colorSpace=c.encoding===q4?Td:Nb),c=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ob,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},c),this.texture=new Av(u,c.mapping,c.wrapS,c.wrapT,c.magFilter,c.minFilter,c.format,c.type,c.anisotropy,c.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=c.generateMipmaps,this.texture.internalFormat=c.internalFormat,this.depthBuffer=c.depthBuffer,this.stencilBuffer=c.stencilBuffer,this.depthTexture=c.depthTexture,this.samples=c.samples}setSize(n,r,c=1){(this.width!==n||this.height!==r||this.depth!==c)&&(this.width=n,this.height=r,this.depth=c,this.texture.image.width=n,this.texture.image.height=r,this.texture.image.depth=c,this.dispose()),this.viewport.set(0,0,n,r),this.scissor.set(0,0,n,r)}clone(){return new this.constructor().copy(this)}copy(n){this.width=n.width,this.height=n.height,this.depth=n.depth,this.scissor.copy(n.scissor),this.scissorTest=n.scissorTest,this.viewport.copy(n.viewport),this.texture=n.texture.clone(),this.texture.isRenderTargetTexture=!0;let r=Object.assign({},n.texture.image);return this.texture.source=new Kfe(r),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,n.depthTexture!==null&&(this.depthTexture=n.depthTexture.clone()),this.samples=n.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},Z3=class extends k6e{constructor(n=1,r=1,c={}){super(n,r,c),this.isWebGLRenderTarget=!0}},Jfe=class extends Av{constructor(n=null,r=1,c=1,u=1){super(null),this.isDataArrayTexture=!0,this.image={data:n,width:r,height:c,depth:u},this.magFilter=dg,this.minFilter=dg,this.wrapR=Tv,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var R6e=class extends Av{constructor(n=null,r=1,c=1,u=1){super(null),this.isData3DTexture=!0,this.image={data:n,width:r,height:c,depth:u},this.magFilter=dg,this.minFilter=dg,this.wrapR=Tv,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var h2=class{constructor(n=0,r=0,c=0,u=1){this.isQuaternion=!0,this._x=n,this._y=r,this._z=c,this._w=u}static slerpFlat(n,r,c,u,d,b,w){let _=c[u+0],x=c[u+1],T=c[u+2],M=c[u+3],L=d[b+0],I=d[b+1],D=d[b+2],F=d[b+3];if(w===0){n[r+0]=_,n[r+1]=x,n[r+2]=T,n[r+3]=M;return}if(w===1){n[r+0]=L,n[r+1]=I,n[r+2]=D,n[r+3]=F;return}if(M!==F||_!==L||x!==I||T!==D){let O=1-w,z=_*L+x*I+T*D+M*F,Z=z>=0?1:-1,H=1-z*z;if(H>Number.EPSILON){let oe=Math.sqrt(H),ne=Math.atan2(oe,z*Z);O=Math.sin(O*ne)/oe,w=Math.sin(w*ne)/oe}let te=w*Z;if(_=_*O+L*te,x=x*O+I*te,T=T*O+D*te,M=M*O+F*te,O===1-w){let oe=1/Math.sqrt(_*_+x*x+T*T+M*M);_*=oe,x*=oe,T*=oe,M*=oe}}n[r]=_,n[r+1]=x,n[r+2]=T,n[r+3]=M}static multiplyQuaternionsFlat(n,r,c,u,d,b){let w=c[u],_=c[u+1],x=c[u+2],T=c[u+3],M=d[b],L=d[b+1],I=d[b+2],D=d[b+3];return n[r]=w*D+T*M+_*I-x*L,n[r+1]=_*D+T*L+x*M-w*I,n[r+2]=x*D+T*I+w*L-_*M,n[r+3]=T*D-w*M-_*L-x*I,n}get x(){return this._x}set x(n){this._x=n,this._onChangeCallback()}get y(){return this._y}set y(n){this._y=n,this._onChangeCallback()}get z(){return this._z}set z(n){this._z=n,this._onChangeCallback()}get w(){return this._w}set w(n){this._w=n,this._onChangeCallback()}set(n,r,c,u){return this._x=n,this._y=r,this._z=c,this._w=u,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(n){return this._x=n.x,this._y=n.y,this._z=n.z,this._w=n.w,this._onChangeCallback(),this}setFromEuler(n,r=!0){let c=n._x,u=n._y,d=n._z,b=n._order,w=Math.cos,_=Math.sin,x=w(c/2),T=w(u/2),M=w(d/2),L=_(c/2),I=_(u/2),D=_(d/2);switch(b){case"XYZ":this._x=L*T*M+x*I*D,this._y=x*I*M-L*T*D,this._z=x*T*D+L*I*M,this._w=x*T*M-L*I*D;break;case"YXZ":this._x=L*T*M+x*I*D,this._y=x*I*M-L*T*D,this._z=x*T*D-L*I*M,this._w=x*T*M+L*I*D;break;case"ZXY":this._x=L*T*M-x*I*D,this._y=x*I*M+L*T*D,this._z=x*T*D+L*I*M,this._w=x*T*M-L*I*D;break;case"ZYX":this._x=L*T*M-x*I*D,this._y=x*I*M+L*T*D,this._z=x*T*D-L*I*M,this._w=x*T*M+L*I*D;break;case"YZX":this._x=L*T*M+x*I*D,this._y=x*I*M+L*T*D,this._z=x*T*D-L*I*M,this._w=x*T*M-L*I*D;break;case"XZY":this._x=L*T*M-x*I*D,this._y=x*I*M-L*T*D,this._z=x*T*D+L*I*M,this._w=x*T*M+L*I*D;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+b)}return r===!0&&this._onChangeCallback(),this}setFromAxisAngle(n,r){let c=r/2,u=Math.sin(c);return this._x=n.x*u,this._y=n.y*u,this._z=n.z*u,this._w=Math.cos(c),this._onChangeCallback(),this}setFromRotationMatrix(n){let r=n.elements,c=r[0],u=r[4],d=r[8],b=r[1],w=r[5],_=r[9],x=r[2],T=r[6],M=r[10],L=c+w+M;if(L>0){let I=.5/Math.sqrt(L+1);this._w=.25/I,this._x=(T-_)*I,this._y=(d-x)*I,this._z=(b-u)*I}else if(c>w&&c>M){let I=2*Math.sqrt(1+c-w-M);this._w=(T-_)/I,this._x=.25*I,this._y=(u+b)/I,this._z=(d+x)/I}else if(w>M){let I=2*Math.sqrt(1+w-c-M);this._w=(d-x)/I,this._x=(u+b)/I,this._y=.25*I,this._z=(_+T)/I}else{let I=2*Math.sqrt(1+M-c-w);this._w=(b-u)/I,this._x=(d+x)/I,this._y=(_+T)/I,this._z=.25*I}return this._onChangeCallback(),this}setFromUnitVectors(n,r){let c=n.dot(r)+1;return cMath.abs(n.z)?(this._x=-n.y,this._y=n.x,this._z=0,this._w=c):(this._x=0,this._y=-n.z,this._z=n.y,this._w=c)):(this._x=n.y*r.z-n.z*r.y,this._y=n.z*r.x-n.x*r.z,this._z=n.x*r.y-n.y*r.x,this._w=c),this.normalize()}angleTo(n){return 2*Math.acos(Math.abs(Sm(this.dot(n),-1,1)))}rotateTowards(n,r){let c=this.angleTo(n);if(c===0)return this;let u=Math.min(1,r/c);return this.slerp(n,u),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(n){return this._x*n._x+this._y*n._y+this._z*n._z+this._w*n._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let n=this.length();return n===0?(this._x=0,this._y=0,this._z=0,this._w=1):(n=1/n,this._x=this._x*n,this._y=this._y*n,this._z=this._z*n,this._w=this._w*n),this._onChangeCallback(),this}multiply(n){return this.multiplyQuaternions(this,n)}premultiply(n){return this.multiplyQuaternions(n,this)}multiplyQuaternions(n,r){let c=n._x,u=n._y,d=n._z,b=n._w,w=r._x,_=r._y,x=r._z,T=r._w;return this._x=c*T+b*w+u*x-d*_,this._y=u*T+b*_+d*w-c*x,this._z=d*T+b*x+c*_-u*w,this._w=b*T-c*w-u*_-d*x,this._onChangeCallback(),this}slerp(n,r){if(r===0)return this;if(r===1)return this.copy(n);let c=this._x,u=this._y,d=this._z,b=this._w,w=b*n._w+c*n._x+u*n._y+d*n._z;if(w<0?(this._w=-n._w,this._x=-n._x,this._y=-n._y,this._z=-n._z,w=-w):this.copy(n),w>=1)return this._w=b,this._x=c,this._y=u,this._z=d,this;let _=1-w*w;if(_<=Number.EPSILON){let I=1-r;return this._w=I*b+r*this._w,this._x=I*c+r*this._x,this._y=I*u+r*this._y,this._z=I*d+r*this._z,this.normalize(),this}let x=Math.sqrt(_),T=Math.atan2(x,w),M=Math.sin((1-r)*T)/x,L=Math.sin(r*T)/x;return this._w=b*M+this._w*L,this._x=c*M+this._x*L,this._y=u*M+this._y*L,this._z=d*M+this._z*L,this._onChangeCallback(),this}slerpQuaternions(n,r,c){return this.copy(n).slerp(r,c)}random(){let n=Math.random(),r=Math.sqrt(1-n),c=Math.sqrt(n),u=2*Math.PI*Math.random(),d=2*Math.PI*Math.random();return this.set(r*Math.cos(u),c*Math.sin(d),c*Math.cos(d),r*Math.sin(u))}equals(n){return n._x===this._x&&n._y===this._y&&n._z===this._z&&n._w===this._w}fromArray(n,r=0){return this._x=n[r],this._y=n[r+1],this._z=n[r+2],this._w=n[r+3],this._onChangeCallback(),this}toArray(n=[],r=0){return n[r]=this._x,n[r+1]=this._y,n[r+2]=this._z,n[r+3]=this._w,n}fromBufferAttribute(n,r){return this._x=n.getX(r),this._y=n.getY(r),this._z=n.getZ(r),this._w=n.getW(r),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(n){return this._onChangeCallback=n,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},Gt=class s{constructor(n=0,r=0,c=0){s.prototype.isVector3=!0,this.x=n,this.y=r,this.z=c}set(n,r,c){return c===void 0&&(c=this.z),this.x=n,this.y=r,this.z=c,this}setScalar(n){return this.x=n,this.y=n,this.z=n,this}setX(n){return this.x=n,this}setY(n){return this.y=n,this}setZ(n){return this.z=n,this}setComponent(n,r){switch(n){case 0:this.x=r;break;case 1:this.y=r;break;case 2:this.z=r;break;default:throw new Error("index is out of range: "+n)}return this}getComponent(n){switch(n){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+n)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(n){return this.x=n.x,this.y=n.y,this.z=n.z,this}add(n){return this.x+=n.x,this.y+=n.y,this.z+=n.z,this}addScalar(n){return this.x+=n,this.y+=n,this.z+=n,this}addVectors(n,r){return this.x=n.x+r.x,this.y=n.y+r.y,this.z=n.z+r.z,this}addScaledVector(n,r){return this.x+=n.x*r,this.y+=n.y*r,this.z+=n.z*r,this}sub(n){return this.x-=n.x,this.y-=n.y,this.z-=n.z,this}subScalar(n){return this.x-=n,this.y-=n,this.z-=n,this}subVectors(n,r){return this.x=n.x-r.x,this.y=n.y-r.y,this.z=n.z-r.z,this}multiply(n){return this.x*=n.x,this.y*=n.y,this.z*=n.z,this}multiplyScalar(n){return this.x*=n,this.y*=n,this.z*=n,this}multiplyVectors(n,r){return this.x=n.x*r.x,this.y=n.y*r.y,this.z=n.z*r.z,this}applyEuler(n){return this.applyQuaternion(Myt.setFromEuler(n))}applyAxisAngle(n,r){return this.applyQuaternion(Myt.setFromAxisAngle(n,r))}applyMatrix3(n){let r=this.x,c=this.y,u=this.z,d=n.elements;return this.x=d[0]*r+d[3]*c+d[6]*u,this.y=d[1]*r+d[4]*c+d[7]*u,this.z=d[2]*r+d[5]*c+d[8]*u,this}applyNormalMatrix(n){return this.applyMatrix3(n).normalize()}applyMatrix4(n){let r=this.x,c=this.y,u=this.z,d=n.elements,b=1/(d[3]*r+d[7]*c+d[11]*u+d[15]);return this.x=(d[0]*r+d[4]*c+d[8]*u+d[12])*b,this.y=(d[1]*r+d[5]*c+d[9]*u+d[13])*b,this.z=(d[2]*r+d[6]*c+d[10]*u+d[14])*b,this}applyQuaternion(n){let r=this.x,c=this.y,u=this.z,d=n.x,b=n.y,w=n.z,_=n.w,x=2*(b*u-w*c),T=2*(w*r-d*u),M=2*(d*c-b*r);return this.x=r+_*x+b*M-w*T,this.y=c+_*T+w*x-d*M,this.z=u+_*M+d*T-b*x,this}project(n){return this.applyMatrix4(n.matrixWorldInverse).applyMatrix4(n.projectionMatrix)}unproject(n){return this.applyMatrix4(n.projectionMatrixInverse).applyMatrix4(n.matrixWorld)}transformDirection(n){let r=this.x,c=this.y,u=this.z,d=n.elements;return this.x=d[0]*r+d[4]*c+d[8]*u,this.y=d[1]*r+d[5]*c+d[9]*u,this.z=d[2]*r+d[6]*c+d[10]*u,this.normalize()}divide(n){return this.x/=n.x,this.y/=n.y,this.z/=n.z,this}divideScalar(n){return this.multiplyScalar(1/n)}min(n){return this.x=Math.min(this.x,n.x),this.y=Math.min(this.y,n.y),this.z=Math.min(this.z,n.z),this}max(n){return this.x=Math.max(this.x,n.x),this.y=Math.max(this.y,n.y),this.z=Math.max(this.z,n.z),this}clamp(n,r){return this.x=Math.max(n.x,Math.min(r.x,this.x)),this.y=Math.max(n.y,Math.min(r.y,this.y)),this.z=Math.max(n.z,Math.min(r.z,this.z)),this}clampScalar(n,r){return this.x=Math.max(n,Math.min(r,this.x)),this.y=Math.max(n,Math.min(r,this.y)),this.z=Math.max(n,Math.min(r,this.z)),this}clampLength(n,r){let c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(n,Math.min(r,c)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(n){return this.x*n.x+this.y*n.y+this.z*n.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(n){return this.normalize().multiplyScalar(n)}lerp(n,r){return this.x+=(n.x-this.x)*r,this.y+=(n.y-this.y)*r,this.z+=(n.z-this.z)*r,this}lerpVectors(n,r,c){return this.x=n.x+(r.x-n.x)*c,this.y=n.y+(r.y-n.y)*c,this.z=n.z+(r.z-n.z)*c,this}cross(n){return this.crossVectors(this,n)}crossVectors(n,r){let c=n.x,u=n.y,d=n.z,b=r.x,w=r.y,_=r.z;return this.x=u*_-d*w,this.y=d*b-c*_,this.z=c*w-u*b,this}projectOnVector(n){let r=n.lengthSq();if(r===0)return this.set(0,0,0);let c=n.dot(this)/r;return this.copy(n).multiplyScalar(c)}projectOnPlane(n){return e6e.copy(this).projectOnVector(n),this.sub(e6e)}reflect(n){return this.sub(e6e.copy(n).multiplyScalar(2*this.dot(n)))}angleTo(n){let r=Math.sqrt(this.lengthSq()*n.lengthSq());if(r===0)return Math.PI/2;let c=this.dot(n)/r;return Math.acos(Sm(c,-1,1))}distanceTo(n){return Math.sqrt(this.distanceToSquared(n))}distanceToSquared(n){let r=this.x-n.x,c=this.y-n.y,u=this.z-n.z;return r*r+c*c+u*u}manhattanDistanceTo(n){return Math.abs(this.x-n.x)+Math.abs(this.y-n.y)+Math.abs(this.z-n.z)}setFromSpherical(n){return this.setFromSphericalCoords(n.radius,n.phi,n.theta)}setFromSphericalCoords(n,r,c){let u=Math.sin(r)*n;return this.x=u*Math.sin(c),this.y=Math.cos(r)*n,this.z=u*Math.cos(c),this}setFromCylindrical(n){return this.setFromCylindricalCoords(n.radius,n.theta,n.y)}setFromCylindricalCoords(n,r,c){return this.x=n*Math.sin(r),this.y=c,this.z=n*Math.cos(r),this}setFromMatrixPosition(n){let r=n.elements;return this.x=r[12],this.y=r[13],this.z=r[14],this}setFromMatrixScale(n){let r=this.setFromMatrixColumn(n,0).length(),c=this.setFromMatrixColumn(n,1).length(),u=this.setFromMatrixColumn(n,2).length();return this.x=r,this.y=c,this.z=u,this}setFromMatrixColumn(n,r){return this.fromArray(n.elements,r*4)}setFromMatrix3Column(n,r){return this.fromArray(n.elements,r*3)}setFromEuler(n){return this.x=n._x,this.y=n._y,this.z=n._z,this}setFromColor(n){return this.x=n.r,this.y=n.g,this.z=n.b,this}equals(n){return n.x===this.x&&n.y===this.y&&n.z===this.z}fromArray(n,r=0){return this.x=n[r],this.y=n[r+1],this.z=n[r+2],this}toArray(n=[],r=0){return n[r]=this.x,n[r+1]=this.y,n[r+2]=this.z,n}fromBufferAttribute(n,r){return this.x=n.getX(r),this.y=n.getY(r),this.z=n.getZ(r),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let n=(Math.random()-.5)*2,r=Math.random()*Math.PI*2,c=Math.sqrt(1-n**2);return this.x=c*Math.cos(r),this.y=c*Math.sin(r),this.z=n,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},e6e=new Gt,Myt=new h2,K3=class{constructor(n=new Gt(1/0,1/0,1/0),r=new Gt(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=n,this.max=r}set(n,r){return this.min.copy(n),this.max.copy(r),this}setFromArray(n){this.makeEmpty();for(let r=0,c=n.length;rthis.max.x||n.ythis.max.y||n.zthis.max.z)}containsBox(n){return this.min.x<=n.min.x&&n.max.x<=this.max.x&&this.min.y<=n.min.y&&n.max.y<=this.max.y&&this.min.z<=n.min.z&&n.max.z<=this.max.z}getParameter(n,r){return r.set((n.x-this.min.x)/(this.max.x-this.min.x),(n.y-this.min.y)/(this.max.y-this.min.y),(n.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(n){return!(n.max.xthis.max.x||n.max.ythis.max.y||n.max.zthis.max.z)}intersectsSphere(n){return this.clampPoint(n.center,xv),xv.distanceToSquared(n.center)<=n.radius*n.radius}intersectsPlane(n){let r,c;return n.normal.x>0?(r=n.normal.x*this.min.x,c=n.normal.x*this.max.x):(r=n.normal.x*this.max.x,c=n.normal.x*this.min.x),n.normal.y>0?(r+=n.normal.y*this.min.y,c+=n.normal.y*this.max.y):(r+=n.normal.y*this.max.y,c+=n.normal.y*this.min.y),n.normal.z>0?(r+=n.normal.z*this.min.z,c+=n.normal.z*this.max.z):(r+=n.normal.z*this.max.z,c+=n.normal.z*this.min.z),r<=-n.constant&&c>=-n.constant}intersectsTriangle(n){if(this.isEmpty())return!1;this.getCenter(TW),gfe.subVectors(this.max,TW),$B.subVectors(n.a,TW),VB.subVectors(n.b,TW),WB.subVectors(n.c,TW),oT.subVectors(VB,$B),aT.subVectors(WB,VB),N4.subVectors($B,WB);let r=[0,-oT.z,oT.y,0,-aT.z,aT.y,0,-N4.z,N4.y,oT.z,0,-oT.x,aT.z,0,-aT.x,N4.z,0,-N4.x,-oT.y,oT.x,0,-aT.y,aT.x,0,-N4.y,N4.x,0];return!t6e(r,$B,VB,WB,gfe)||(r=[1,0,0,0,1,0,0,0,1],!t6e(r,$B,VB,WB,gfe))?!1:(mfe.crossVectors(oT,aT),r=[mfe.x,mfe.y,mfe.z],t6e(r,$B,VB,WB,gfe))}clampPoint(n,r){return r.copy(n).clamp(this.min,this.max)}distanceToPoint(n){return this.clampPoint(n,xv).distanceTo(n)}getBoundingSphere(n){return this.isEmpty()?n.makeEmpty():(this.getCenter(n.center),n.radius=this.getSize(xv).length()*.5),n}intersect(n){return this.min.max(n.min),this.max.min(n.max),this.isEmpty()&&this.makeEmpty(),this}union(n){return this.min.min(n.min),this.max.max(n.max),this}applyMatrix4(n){return this.isEmpty()?this:(G3[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(n),G3[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(n),G3[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(n),G3[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(n),G3[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(n),G3[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(n),G3[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(n),G3[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(n),this.setFromPoints(G3),this)}translate(n){return this.min.add(n),this.max.add(n),this}equals(n){return n.min.equals(this.min)&&n.max.equals(this.max)}},G3=[new Gt,new Gt,new Gt,new Gt,new Gt,new Gt,new Gt,new Gt],xv=new Gt,pfe=new K3,$B=new Gt,VB=new Gt,WB=new Gt,oT=new Gt,aT=new Gt,N4=new Gt,TW=new Gt,gfe=new Gt,mfe=new Gt,F4=new Gt;function t6e(s,n,r,c,u){for(let d=0,b=s.length-3;d<=b;d+=3){F4.fromArray(s,d);let w=u.x*Math.abs(F4.x)+u.y*Math.abs(F4.y)+u.z*Math.abs(F4.z),_=n.dot(F4),x=r.dot(F4),T=c.dot(F4);if(Math.max(-Math.max(_,x,T),Math.min(_,x,T))>w)return!1}return!0}var uan=new K3,CW=new Gt,n6e=new Gt,vT=class{constructor(n=new Gt,r=-1){this.isSphere=!0,this.center=n,this.radius=r}set(n,r){return this.center.copy(n),this.radius=r,this}setFromPoints(n,r){let c=this.center;r!==void 0?c.copy(r):uan.setFromPoints(n).getCenter(c);let u=0;for(let d=0,b=n.length;dthis.radius*this.radius&&(r.sub(this.center).normalize(),r.multiplyScalar(this.radius).add(this.center)),r}getBoundingBox(n){return this.isEmpty()?(n.makeEmpty(),n):(n.set(this.center,this.center),n.expandByScalar(this.radius),n)}applyMatrix4(n){return this.center.applyMatrix4(n),this.radius=this.radius*n.getMaxScaleOnAxis(),this}translate(n){return this.center.add(n),this}expandByPoint(n){if(this.isEmpty())return this.center.copy(n),this.radius=0,this;CW.subVectors(n,this.center);let r=CW.lengthSq();if(r>this.radius*this.radius){let c=Math.sqrt(r),u=(c-this.radius)*.5;this.center.addScaledVector(CW,u/c),this.radius+=u}return this}union(n){return n.isEmpty()?this:this.isEmpty()?(this.copy(n),this):(this.center.equals(n.center)===!0?this.radius=Math.max(this.radius,n.radius):(n6e.subVectors(n.center,this.center).setLength(n.radius),this.expandByPoint(CW.copy(n.center).add(n6e)),this.expandByPoint(CW.copy(n.center).sub(n6e))),this)}equals(n){return n.center.equals(this.center)&&n.radius===this.radius}clone(){return new this.constructor().copy(this)}},j3=new Gt,i6e=new Gt,bfe=new Gt,cT=new Gt,r6e=new Gt,wfe=new Gt,s6e=new Gt,OW=class{constructor(n=new Gt,r=new Gt(0,0,-1)){this.origin=n,this.direction=r}set(n,r){return this.origin.copy(n),this.direction.copy(r),this}copy(n){return this.origin.copy(n.origin),this.direction.copy(n.direction),this}at(n,r){return r.copy(this.origin).addScaledVector(this.direction,n)}lookAt(n){return this.direction.copy(n).sub(this.origin).normalize(),this}recast(n){return this.origin.copy(this.at(n,j3)),this}closestPointToPoint(n,r){r.subVectors(n,this.origin);let c=r.dot(this.direction);return c<0?r.copy(this.origin):r.copy(this.origin).addScaledVector(this.direction,c)}distanceToPoint(n){return Math.sqrt(this.distanceSqToPoint(n))}distanceSqToPoint(n){let r=j3.subVectors(n,this.origin).dot(this.direction);return r<0?this.origin.distanceToSquared(n):(j3.copy(this.origin).addScaledVector(this.direction,r),j3.distanceToSquared(n))}distanceSqToSegment(n,r,c,u){i6e.copy(n).add(r).multiplyScalar(.5),bfe.copy(r).sub(n).normalize(),cT.copy(this.origin).sub(i6e);let d=n.distanceTo(r)*.5,b=-this.direction.dot(bfe),w=cT.dot(this.direction),_=-cT.dot(bfe),x=cT.lengthSq(),T=Math.abs(1-b*b),M,L,I,D;if(T>0)if(M=b*_-w,L=b*w-_,D=d*T,M>=0)if(L>=-D)if(L<=D){let F=1/T;M*=F,L*=F,I=M*(M+b*L+2*w)+L*(b*M+L+2*_)+x}else L=d,M=Math.max(0,-(b*L+w)),I=-M*M+L*(L+2*_)+x;else L=-d,M=Math.max(0,-(b*L+w)),I=-M*M+L*(L+2*_)+x;else L<=-D?(M=Math.max(0,-(-b*d+w)),L=M>0?-d:Math.min(Math.max(-d,-_),d),I=-M*M+L*(L+2*_)+x):L<=D?(M=0,L=Math.min(Math.max(-d,-_),d),I=L*(L+2*_)+x):(M=Math.max(0,-(b*d+w)),L=M>0?d:Math.min(Math.max(-d,-_),d),I=-M*M+L*(L+2*_)+x);else L=b>0?-d:d,M=Math.max(0,-(b*L+w)),I=-M*M+L*(L+2*_)+x;return c&&c.copy(this.origin).addScaledVector(this.direction,M),u&&u.copy(i6e).addScaledVector(bfe,L),I}intersectSphere(n,r){j3.subVectors(n.center,this.origin);let c=j3.dot(this.direction),u=j3.dot(j3)-c*c,d=n.radius*n.radius;if(u>d)return null;let b=Math.sqrt(d-u),w=c-b,_=c+b;return _<0?null:w<0?this.at(_,r):this.at(w,r)}intersectsSphere(n){return this.distanceSqToPoint(n.center)<=n.radius*n.radius}distanceToPlane(n){let r=n.normal.dot(this.direction);if(r===0)return n.distanceToPoint(this.origin)===0?0:null;let c=-(this.origin.dot(n.normal)+n.constant)/r;return c>=0?c:null}intersectPlane(n,r){let c=this.distanceToPlane(n);return c===null?null:this.at(c,r)}intersectsPlane(n){let r=n.distanceToPoint(this.origin);return r===0||n.normal.dot(this.direction)*r<0}intersectBox(n,r){let c,u,d,b,w,_,x=1/this.direction.x,T=1/this.direction.y,M=1/this.direction.z,L=this.origin;return x>=0?(c=(n.min.x-L.x)*x,u=(n.max.x-L.x)*x):(c=(n.max.x-L.x)*x,u=(n.min.x-L.x)*x),T>=0?(d=(n.min.y-L.y)*T,b=(n.max.y-L.y)*T):(d=(n.max.y-L.y)*T,b=(n.min.y-L.y)*T),c>b||d>u||((d>c||isNaN(c))&&(c=d),(b=0?(w=(n.min.z-L.z)*M,_=(n.max.z-L.z)*M):(w=(n.max.z-L.z)*M,_=(n.min.z-L.z)*M),c>_||w>u)||((w>c||c!==c)&&(c=w),(_=0?c:u,r)}intersectsBox(n){return this.intersectBox(n,j3)!==null}intersectTriangle(n,r,c,u,d){r6e.subVectors(r,n),wfe.subVectors(c,n),s6e.crossVectors(r6e,wfe);let b=this.direction.dot(s6e),w;if(b>0){if(u)return null;w=1}else if(b<0)w=-1,b=-b;else return null;cT.subVectors(this.origin,n);let _=w*this.direction.dot(wfe.crossVectors(cT,wfe));if(_<0)return null;let x=w*this.direction.dot(r6e.cross(cT));if(x<0||_+x>b)return null;let T=-w*cT.dot(s6e);return T<0?null:this.at(T/b,d)}applyMatrix4(n){return this.origin.applyMatrix4(n),this.direction.transformDirection(n),this}equals(n){return n.origin.equals(this.origin)&&n.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Il=class s{constructor(n,r,c,u,d,b,w,_,x,T,M,L,I,D,F,O){s.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],n!==void 0&&this.set(n,r,c,u,d,b,w,_,x,T,M,L,I,D,F,O)}set(n,r,c,u,d,b,w,_,x,T,M,L,I,D,F,O){let z=this.elements;return z[0]=n,z[4]=r,z[8]=c,z[12]=u,z[1]=d,z[5]=b,z[9]=w,z[13]=_,z[2]=x,z[6]=T,z[10]=M,z[14]=L,z[3]=I,z[7]=D,z[11]=F,z[15]=O,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new s().fromArray(this.elements)}copy(n){let r=this.elements,c=n.elements;return r[0]=c[0],r[1]=c[1],r[2]=c[2],r[3]=c[3],r[4]=c[4],r[5]=c[5],r[6]=c[6],r[7]=c[7],r[8]=c[8],r[9]=c[9],r[10]=c[10],r[11]=c[11],r[12]=c[12],r[13]=c[13],r[14]=c[14],r[15]=c[15],this}copyPosition(n){let r=this.elements,c=n.elements;return r[12]=c[12],r[13]=c[13],r[14]=c[14],this}setFromMatrix3(n){let r=n.elements;return this.set(r[0],r[3],r[6],0,r[1],r[4],r[7],0,r[2],r[5],r[8],0,0,0,0,1),this}extractBasis(n,r,c){return n.setFromMatrixColumn(this,0),r.setFromMatrixColumn(this,1),c.setFromMatrixColumn(this,2),this}makeBasis(n,r,c){return this.set(n.x,r.x,c.x,0,n.y,r.y,c.y,0,n.z,r.z,c.z,0,0,0,0,1),this}extractRotation(n){let r=this.elements,c=n.elements,u=1/HB.setFromMatrixColumn(n,0).length(),d=1/HB.setFromMatrixColumn(n,1).length(),b=1/HB.setFromMatrixColumn(n,2).length();return r[0]=c[0]*u,r[1]=c[1]*u,r[2]=c[2]*u,r[3]=0,r[4]=c[4]*d,r[5]=c[5]*d,r[6]=c[6]*d,r[7]=0,r[8]=c[8]*b,r[9]=c[9]*b,r[10]=c[10]*b,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,this}makeRotationFromEuler(n){let r=this.elements,c=n.x,u=n.y,d=n.z,b=Math.cos(c),w=Math.sin(c),_=Math.cos(u),x=Math.sin(u),T=Math.cos(d),M=Math.sin(d);if(n.order==="XYZ"){let L=b*T,I=b*M,D=w*T,F=w*M;r[0]=_*T,r[4]=-_*M,r[8]=x,r[1]=I+D*x,r[5]=L-F*x,r[9]=-w*_,r[2]=F-L*x,r[6]=D+I*x,r[10]=b*_}else if(n.order==="YXZ"){let L=_*T,I=_*M,D=x*T,F=x*M;r[0]=L+F*w,r[4]=D*w-I,r[8]=b*x,r[1]=b*M,r[5]=b*T,r[9]=-w,r[2]=I*w-D,r[6]=F+L*w,r[10]=b*_}else if(n.order==="ZXY"){let L=_*T,I=_*M,D=x*T,F=x*M;r[0]=L-F*w,r[4]=-b*M,r[8]=D+I*w,r[1]=I+D*w,r[5]=b*T,r[9]=F-L*w,r[2]=-b*x,r[6]=w,r[10]=b*_}else if(n.order==="ZYX"){let L=b*T,I=b*M,D=w*T,F=w*M;r[0]=_*T,r[4]=D*x-I,r[8]=L*x+F,r[1]=_*M,r[5]=F*x+L,r[9]=I*x-D,r[2]=-x,r[6]=w*_,r[10]=b*_}else if(n.order==="YZX"){let L=b*_,I=b*x,D=w*_,F=w*x;r[0]=_*T,r[4]=F-L*M,r[8]=D*M+I,r[1]=M,r[5]=b*T,r[9]=-w*T,r[2]=-x*T,r[6]=I*M+D,r[10]=L-F*M}else if(n.order==="XZY"){let L=b*_,I=b*x,D=w*_,F=w*x;r[0]=_*T,r[4]=-M,r[8]=x*T,r[1]=L*M+F,r[5]=b*T,r[9]=I*M-D,r[2]=D*M-I,r[6]=w*T,r[10]=F*M+L}return r[3]=0,r[7]=0,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,this}makeRotationFromQuaternion(n){return this.compose(fan,n,han)}lookAt(n,r,c){let u=this.elements;return W1.subVectors(n,r),W1.lengthSq()===0&&(W1.z=1),W1.normalize(),lT.crossVectors(c,W1),lT.lengthSq()===0&&(Math.abs(c.z)===1?W1.x+=1e-4:W1.z+=1e-4,W1.normalize(),lT.crossVectors(c,W1)),lT.normalize(),vfe.crossVectors(W1,lT),u[0]=lT.x,u[4]=vfe.x,u[8]=W1.x,u[1]=lT.y,u[5]=vfe.y,u[9]=W1.y,u[2]=lT.z,u[6]=vfe.z,u[10]=W1.z,this}multiply(n){return this.multiplyMatrices(this,n)}premultiply(n){return this.multiplyMatrices(n,this)}multiplyMatrices(n,r){let c=n.elements,u=r.elements,d=this.elements,b=c[0],w=c[4],_=c[8],x=c[12],T=c[1],M=c[5],L=c[9],I=c[13],D=c[2],F=c[6],O=c[10],z=c[14],Z=c[3],H=c[7],te=c[11],oe=c[15],ne=u[0],ue=u[4],Te=u[8],Q=u[12],ge=u[1],Qe=u[5],st=u[9],at=u[13],Ne=u[2],tt=u[6],ot=u[10],Tt=u[14],jt=u[3],en=u[7],mn=u[11],cn=u[15];return d[0]=b*ne+w*ge+_*Ne+x*jt,d[4]=b*ue+w*Qe+_*tt+x*en,d[8]=b*Te+w*st+_*ot+x*mn,d[12]=b*Q+w*at+_*Tt+x*cn,d[1]=T*ne+M*ge+L*Ne+I*jt,d[5]=T*ue+M*Qe+L*tt+I*en,d[9]=T*Te+M*st+L*ot+I*mn,d[13]=T*Q+M*at+L*Tt+I*cn,d[2]=D*ne+F*ge+O*Ne+z*jt,d[6]=D*ue+F*Qe+O*tt+z*en,d[10]=D*Te+F*st+O*ot+z*mn,d[14]=D*Q+F*at+O*Tt+z*cn,d[3]=Z*ne+H*ge+te*Ne+oe*jt,d[7]=Z*ue+H*Qe+te*tt+oe*en,d[11]=Z*Te+H*st+te*ot+oe*mn,d[15]=Z*Q+H*at+te*Tt+oe*cn,this}multiplyScalar(n){let r=this.elements;return r[0]*=n,r[4]*=n,r[8]*=n,r[12]*=n,r[1]*=n,r[5]*=n,r[9]*=n,r[13]*=n,r[2]*=n,r[6]*=n,r[10]*=n,r[14]*=n,r[3]*=n,r[7]*=n,r[11]*=n,r[15]*=n,this}determinant(){let n=this.elements,r=n[0],c=n[4],u=n[8],d=n[12],b=n[1],w=n[5],_=n[9],x=n[13],T=n[2],M=n[6],L=n[10],I=n[14],D=n[3],F=n[7],O=n[11],z=n[15];return D*(+d*_*M-u*x*M-d*w*L+c*x*L+u*w*I-c*_*I)+F*(+r*_*I-r*x*L+d*b*L-u*b*I+u*x*T-d*_*T)+O*(+r*x*M-r*w*I-d*b*M+c*b*I+d*w*T-c*x*T)+z*(-u*w*T-r*_*M+r*w*L+u*b*M-c*b*L+c*_*T)}transpose(){let n=this.elements,r;return r=n[1],n[1]=n[4],n[4]=r,r=n[2],n[2]=n[8],n[8]=r,r=n[6],n[6]=n[9],n[9]=r,r=n[3],n[3]=n[12],n[12]=r,r=n[7],n[7]=n[13],n[13]=r,r=n[11],n[11]=n[14],n[14]=r,this}setPosition(n,r,c){let u=this.elements;return n.isVector3?(u[12]=n.x,u[13]=n.y,u[14]=n.z):(u[12]=n,u[13]=r,u[14]=c),this}invert(){let n=this.elements,r=n[0],c=n[1],u=n[2],d=n[3],b=n[4],w=n[5],_=n[6],x=n[7],T=n[8],M=n[9],L=n[10],I=n[11],D=n[12],F=n[13],O=n[14],z=n[15],Z=M*O*x-F*L*x+F*_*I-w*O*I-M*_*z+w*L*z,H=D*L*x-T*O*x-D*_*I+b*O*I+T*_*z-b*L*z,te=T*F*x-D*M*x+D*w*I-b*F*I-T*w*z+b*M*z,oe=D*M*_-T*F*_-D*w*L+b*F*L+T*w*O-b*M*O,ne=r*Z+c*H+u*te+d*oe;if(ne===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let ue=1/ne;return n[0]=Z*ue,n[1]=(F*L*d-M*O*d-F*u*I+c*O*I+M*u*z-c*L*z)*ue,n[2]=(w*O*d-F*_*d+F*u*x-c*O*x-w*u*z+c*_*z)*ue,n[3]=(M*_*d-w*L*d-M*u*x+c*L*x+w*u*I-c*_*I)*ue,n[4]=H*ue,n[5]=(T*O*d-D*L*d+D*u*I-r*O*I-T*u*z+r*L*z)*ue,n[6]=(D*_*d-b*O*d-D*u*x+r*O*x+b*u*z-r*_*z)*ue,n[7]=(b*L*d-T*_*d+T*u*x-r*L*x-b*u*I+r*_*I)*ue,n[8]=te*ue,n[9]=(D*M*d-T*F*d-D*c*I+r*F*I+T*c*z-r*M*z)*ue,n[10]=(b*F*d-D*w*d+D*c*x-r*F*x-b*c*z+r*w*z)*ue,n[11]=(T*w*d-b*M*d-T*c*x+r*M*x+b*c*I-r*w*I)*ue,n[12]=oe*ue,n[13]=(T*F*u-D*M*u+D*c*L-r*F*L-T*c*O+r*M*O)*ue,n[14]=(D*w*u-b*F*u-D*c*_+r*F*_+b*c*O-r*w*O)*ue,n[15]=(b*M*u-T*w*u+T*c*_-r*M*_-b*c*L+r*w*L)*ue,this}scale(n){let r=this.elements,c=n.x,u=n.y,d=n.z;return r[0]*=c,r[4]*=u,r[8]*=d,r[1]*=c,r[5]*=u,r[9]*=d,r[2]*=c,r[6]*=u,r[10]*=d,r[3]*=c,r[7]*=u,r[11]*=d,this}getMaxScaleOnAxis(){let n=this.elements,r=n[0]*n[0]+n[1]*n[1]+n[2]*n[2],c=n[4]*n[4]+n[5]*n[5]+n[6]*n[6],u=n[8]*n[8]+n[9]*n[9]+n[10]*n[10];return Math.sqrt(Math.max(r,c,u))}makeTranslation(n,r,c){return n.isVector3?this.set(1,0,0,n.x,0,1,0,n.y,0,0,1,n.z,0,0,0,1):this.set(1,0,0,n,0,1,0,r,0,0,1,c,0,0,0,1),this}makeRotationX(n){let r=Math.cos(n),c=Math.sin(n);return this.set(1,0,0,0,0,r,-c,0,0,c,r,0,0,0,0,1),this}makeRotationY(n){let r=Math.cos(n),c=Math.sin(n);return this.set(r,0,c,0,0,1,0,0,-c,0,r,0,0,0,0,1),this}makeRotationZ(n){let r=Math.cos(n),c=Math.sin(n);return this.set(r,-c,0,0,c,r,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(n,r){let c=Math.cos(r),u=Math.sin(r),d=1-c,b=n.x,w=n.y,_=n.z,x=d*b,T=d*w;return this.set(x*b+c,x*w-u*_,x*_+u*w,0,x*w+u*_,T*w+c,T*_-u*b,0,x*_-u*w,T*_+u*b,d*_*_+c,0,0,0,0,1),this}makeScale(n,r,c){return this.set(n,0,0,0,0,r,0,0,0,0,c,0,0,0,0,1),this}makeShear(n,r,c,u,d,b){return this.set(1,c,d,0,n,1,b,0,r,u,1,0,0,0,0,1),this}compose(n,r,c){let u=this.elements,d=r._x,b=r._y,w=r._z,_=r._w,x=d+d,T=b+b,M=w+w,L=d*x,I=d*T,D=d*M,F=b*T,O=b*M,z=w*M,Z=_*x,H=_*T,te=_*M,oe=c.x,ne=c.y,ue=c.z;return u[0]=(1-(F+z))*oe,u[1]=(I+te)*oe,u[2]=(D-H)*oe,u[3]=0,u[4]=(I-te)*ne,u[5]=(1-(L+z))*ne,u[6]=(O+Z)*ne,u[7]=0,u[8]=(D+H)*ue,u[9]=(O-Z)*ue,u[10]=(1-(L+F))*ue,u[11]=0,u[12]=n.x,u[13]=n.y,u[14]=n.z,u[15]=1,this}decompose(n,r,c){let u=this.elements,d=HB.set(u[0],u[1],u[2]).length(),b=HB.set(u[4],u[5],u[6]).length(),w=HB.set(u[8],u[9],u[10]).length();this.determinant()<0&&(d=-d),n.x=u[12],n.y=u[13],n.z=u[14],Ev.copy(this);let x=1/d,T=1/b,M=1/w;return Ev.elements[0]*=x,Ev.elements[1]*=x,Ev.elements[2]*=x,Ev.elements[4]*=T,Ev.elements[5]*=T,Ev.elements[6]*=T,Ev.elements[8]*=M,Ev.elements[9]*=M,Ev.elements[10]*=M,r.setFromRotationMatrix(Ev),c.x=d,c.y=b,c.z=w,this}makePerspective(n,r,c,u,d,b,w=X3){let _=this.elements,x=2*d/(r-n),T=2*d/(c-u),M=(r+n)/(r-n),L=(c+u)/(c-u),I,D;if(w===X3)I=-(b+d)/(b-d),D=-2*b*d/(b-d);else if(w===Xfe)I=-b/(b-d),D=-b*d/(b-d);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+w);return _[0]=x,_[4]=0,_[8]=M,_[12]=0,_[1]=0,_[5]=T,_[9]=L,_[13]=0,_[2]=0,_[6]=0,_[10]=I,_[14]=D,_[3]=0,_[7]=0,_[11]=-1,_[15]=0,this}makeOrthographic(n,r,c,u,d,b,w=X3){let _=this.elements,x=1/(r-n),T=1/(c-u),M=1/(b-d),L=(r+n)*x,I=(c+u)*T,D,F;if(w===X3)D=(b+d)*M,F=-2*M;else if(w===Xfe)D=d*M,F=-1*M;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+w);return _[0]=2*x,_[4]=0,_[8]=0,_[12]=-L,_[1]=0,_[5]=2*T,_[9]=0,_[13]=-I,_[2]=0,_[6]=0,_[10]=F,_[14]=-D,_[3]=0,_[7]=0,_[11]=0,_[15]=1,this}equals(n){let r=this.elements,c=n.elements;for(let u=0;u<16;u++)if(r[u]!==c[u])return!1;return!0}fromArray(n,r=0){for(let c=0;c<16;c++)this.elements[c]=n[c+r];return this}toArray(n=[],r=0){let c=this.elements;return n[r]=c[0],n[r+1]=c[1],n[r+2]=c[2],n[r+3]=c[3],n[r+4]=c[4],n[r+5]=c[5],n[r+6]=c[6],n[r+7]=c[7],n[r+8]=c[8],n[r+9]=c[9],n[r+10]=c[10],n[r+11]=c[11],n[r+12]=c[12],n[r+13]=c[13],n[r+14]=c[14],n[r+15]=c[15],n}},HB=new Gt,Ev=new Il,fan=new Gt(0,0,0),han=new Gt(1,1,1),lT=new Gt,vfe=new Gt,W1=new Gt,Tyt=new Il,Cyt=new h2,Qfe=class s{constructor(n=0,r=0,c=0,u=s.DEFAULT_ORDER){this.isEuler=!0,this._x=n,this._y=r,this._z=c,this._order=u}get x(){return this._x}set x(n){this._x=n,this._onChangeCallback()}get y(){return this._y}set y(n){this._y=n,this._onChangeCallback()}get z(){return this._z}set z(n){this._z=n,this._onChangeCallback()}get order(){return this._order}set order(n){this._order=n,this._onChangeCallback()}set(n,r,c,u=this._order){return this._x=n,this._y=r,this._z=c,this._order=u,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(n){return this._x=n._x,this._y=n._y,this._z=n._z,this._order=n._order,this._onChangeCallback(),this}setFromRotationMatrix(n,r=this._order,c=!0){let u=n.elements,d=u[0],b=u[4],w=u[8],_=u[1],x=u[5],T=u[9],M=u[2],L=u[6],I=u[10];switch(r){case"XYZ":this._y=Math.asin(Sm(w,-1,1)),Math.abs(w)<.9999999?(this._x=Math.atan2(-T,I),this._z=Math.atan2(-b,d)):(this._x=Math.atan2(L,x),this._z=0);break;case"YXZ":this._x=Math.asin(-Sm(T,-1,1)),Math.abs(T)<.9999999?(this._y=Math.atan2(w,I),this._z=Math.atan2(_,x)):(this._y=Math.atan2(-M,d),this._z=0);break;case"ZXY":this._x=Math.asin(Sm(L,-1,1)),Math.abs(L)<.9999999?(this._y=Math.atan2(-M,I),this._z=Math.atan2(-b,x)):(this._y=0,this._z=Math.atan2(_,d));break;case"ZYX":this._y=Math.asin(-Sm(M,-1,1)),Math.abs(M)<.9999999?(this._x=Math.atan2(L,I),this._z=Math.atan2(_,d)):(this._x=0,this._z=Math.atan2(-b,x));break;case"YZX":this._z=Math.asin(Sm(_,-1,1)),Math.abs(_)<.9999999?(this._x=Math.atan2(-T,x),this._y=Math.atan2(-M,d)):(this._x=0,this._y=Math.atan2(w,I));break;case"XZY":this._z=Math.asin(-Sm(b,-1,1)),Math.abs(b)<.9999999?(this._x=Math.atan2(L,x),this._y=Math.atan2(w,d)):(this._x=Math.atan2(-T,I),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+r)}return this._order=r,c===!0&&this._onChangeCallback(),this}setFromQuaternion(n,r,c){return Tyt.makeRotationFromQuaternion(n),this.setFromRotationMatrix(Tyt,r,c)}setFromVector3(n,r=this._order){return this.set(n.x,n.y,n.z,r)}reorder(n){return Cyt.setFromEuler(this),this.setFromQuaternion(Cyt,n)}equals(n){return n._x===this._x&&n._y===this._y&&n._z===this._z&&n._order===this._order}fromArray(n){return this._x=n[0],this._y=n[1],this._z=n[2],n[3]!==void 0&&(this._order=n[3]),this._onChangeCallback(),this}toArray(n=[],r=0){return n[r]=this._x,n[r+1]=this._y,n[r+2]=this._z,n[r+3]=this._order,n}_onChange(n){return this._onChangeCallback=n,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Qfe.DEFAULT_ORDER="XYZ";var NW=class{constructor(){this.mask=1}set(n){this.mask=(1<>>0}enable(n){this.mask|=1<1){for(let r=0;r1){for(let c=0;c0&&(u.userData=this.userData),u.layers=this.layers.mask,u.matrix=this.matrix.toArray(),u.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(u.matrixAutoUpdate=!1),this.isInstancedMesh&&(u.type="InstancedMesh",u.count=this.count,u.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(u.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(u.type="BatchedMesh",u.perObjectFrustumCulled=this.perObjectFrustumCulled,u.sortObjects=this.sortObjects,u.drawRanges=this._drawRanges,u.reservedRanges=this._reservedRanges,u.visibility=this._visibility,u.active=this._active,u.bounds=this._bounds.map(w=>({boxInitialized:w.boxInitialized,boxMin:w.box.min.toArray(),boxMax:w.box.max.toArray(),sphereInitialized:w.sphereInitialized,sphereRadius:w.sphere.radius,sphereCenter:w.sphere.center.toArray()})),u.maxGeometryCount=this._maxGeometryCount,u.maxVertexCount=this._maxVertexCount,u.maxIndexCount=this._maxIndexCount,u.geometryInitialized=this._geometryInitialized,u.geometryCount=this._geometryCount,u.matricesTexture=this._matricesTexture.toJSON(n),this.boundingSphere!==null&&(u.boundingSphere={center:u.boundingSphere.center.toArray(),radius:u.boundingSphere.radius}),this.boundingBox!==null&&(u.boundingBox={min:u.boundingBox.min.toArray(),max:u.boundingBox.max.toArray()}));function d(w,_){return w[_.uuid]===void 0&&(w[_.uuid]=_.toJSON(n)),_.uuid}if(this.isScene)this.background&&(this.background.isColor?u.background=this.background.toJSON():this.background.isTexture&&(u.background=this.background.toJSON(n).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(u.environment=this.environment.toJSON(n).uuid);else if(this.isMesh||this.isLine||this.isPoints){u.geometry=d(n.geometries,this.geometry);let w=this.geometry.parameters;if(w!==void 0&&w.shapes!==void 0){let _=w.shapes;if(Array.isArray(_))for(let x=0,T=_.length;x0){u.children=[];for(let w=0;w0){u.animations=[];for(let w=0;w0&&(c.geometries=w),_.length>0&&(c.materials=_),x.length>0&&(c.textures=x),T.length>0&&(c.images=T),M.length>0&&(c.shapes=M),L.length>0&&(c.skeletons=L),I.length>0&&(c.animations=I),D.length>0&&(c.nodes=D)}return c.object=u,c;function b(w){let _=[];for(let x in w){let T=w[x];delete T.metadata,_.push(T)}return _}}clone(n){return new this.constructor().copy(this,n)}copy(n,r=!0){if(this.name=n.name,this.up.copy(n.up),this.position.copy(n.position),this.rotation.order=n.rotation.order,this.quaternion.copy(n.quaternion),this.scale.copy(n.scale),this.matrix.copy(n.matrix),this.matrixWorld.copy(n.matrixWorld),this.matrixAutoUpdate=n.matrixAutoUpdate,this.matrixWorldAutoUpdate=n.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=n.matrixWorldNeedsUpdate,this.layers.mask=n.layers.mask,this.visible=n.visible,this.castShadow=n.castShadow,this.receiveShadow=n.receiveShadow,this.frustumCulled=n.frustumCulled,this.renderOrder=n.renderOrder,this.animations=n.animations.slice(),this.userData=JSON.parse(JSON.stringify(n.userData)),r===!0)for(let c=0;c0?u.multiplyScalar(1/Math.sqrt(d)):u.set(0,0,0)}static getBarycoord(n,r,c,u,d){Sv.subVectors(u,r),V3.subVectors(c,r),o6e.subVectors(n,r);let b=Sv.dot(Sv),w=Sv.dot(V3),_=Sv.dot(o6e),x=V3.dot(V3),T=V3.dot(o6e),M=b*x-w*w;if(M===0)return d.set(0,0,0),null;let L=1/M,I=(x*_-w*T)*L,D=(b*T-w*_)*L;return d.set(1-I-D,D,I)}static containsPoint(n,r,c,u){return this.getBarycoord(n,r,c,u,W3)===null?!1:W3.x>=0&&W3.y>=0&&W3.x+W3.y<=1}static getUV(n,r,c,u,d,b,w,_){return yfe===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),yfe=!0),this.getInterpolation(n,r,c,u,d,b,w,_)}static getInterpolation(n,r,c,u,d,b,w,_){return this.getBarycoord(n,r,c,u,W3)===null?(_.x=0,_.y=0,"z"in _&&(_.z=0),"w"in _&&(_.w=0),null):(_.setScalar(0),_.addScaledVector(d,W3.x),_.addScaledVector(b,W3.y),_.addScaledVector(w,W3.z),_)}static isFrontFacing(n,r,c,u){return Sv.subVectors(c,r),V3.subVectors(n,r),Sv.cross(V3).dot(u)<0}set(n,r,c){return this.a.copy(n),this.b.copy(r),this.c.copy(c),this}setFromPointsAndIndices(n,r,c,u){return this.a.copy(n[r]),this.b.copy(n[c]),this.c.copy(n[u]),this}setFromAttributeAndIndices(n,r,c,u){return this.a.fromBufferAttribute(n,r),this.b.fromBufferAttribute(n,c),this.c.fromBufferAttribute(n,u),this}clone(){return new this.constructor().copy(this)}copy(n){return this.a.copy(n.a),this.b.copy(n.b),this.c.copy(n.c),this}getArea(){return Sv.subVectors(this.c,this.b),V3.subVectors(this.a,this.b),Sv.cross(V3).length()*.5}getMidpoint(n){return n.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(n){return s.getNormal(this.a,this.b,this.c,n)}getPlane(n){return n.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(n,r){return s.getBarycoord(n,this.a,this.b,this.c,r)}getUV(n,r,c,u,d){return yfe===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),yfe=!0),s.getInterpolation(n,this.a,this.b,this.c,r,c,u,d)}getInterpolation(n,r,c,u,d){return s.getInterpolation(n,this.a,this.b,this.c,r,c,u,d)}containsPoint(n){return s.containsPoint(n,this.a,this.b,this.c)}isFrontFacing(n){return s.isFrontFacing(this.a,this.b,this.c,n)}intersectsBox(n){return n.intersectsTriangle(this)}closestPointToPoint(n,r){let c=this.a,u=this.b,d=this.c,b,w;XB.subVectors(u,c),YB.subVectors(d,c),a6e.subVectors(n,c);let _=XB.dot(a6e),x=YB.dot(a6e);if(_<=0&&x<=0)return r.copy(c);c6e.subVectors(n,u);let T=XB.dot(c6e),M=YB.dot(c6e);if(T>=0&&M<=T)return r.copy(u);let L=_*M-T*x;if(L<=0&&_>=0&&T<=0)return b=_/(_-T),r.copy(c).addScaledVector(XB,b);l6e.subVectors(n,d);let I=XB.dot(l6e),D=YB.dot(l6e);if(D>=0&&I<=D)return r.copy(d);let F=I*x-_*D;if(F<=0&&x>=0&&D<=0)return w=x/(x-D),r.copy(c).addScaledVector(YB,w);let O=T*D-I*M;if(O<=0&&M-T>=0&&I-D>=0)return Ryt.subVectors(d,u),w=(M-T)/(M-T+(I-D)),r.copy(u).addScaledVector(Ryt,w);let z=1/(O+F+L);return b=F*z,w=L*z,r.copy(c).addScaledVector(XB,b).addScaledVector(YB,w)}equals(n){return n.a.equals(this.a)&&n.b.equals(this.b)&&n.c.equals(this.c)}},A2t={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},uT={h:0,s:0,l:0},xfe={h:0,s:0,l:0};function u6e(s,n,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?s+(n-s)*6*r:r<1/2?n:r<2/3?s+(n-s)*6*(2/3-r):s}var Go=class{constructor(n,r,c){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(n,r,c)}set(n,r,c){if(r===void 0&&c===void 0){let u=n;u&&u.isColor?this.copy(u):typeof u=="number"?this.setHex(u):typeof u=="string"&&this.setStyle(u)}else this.setRGB(n,r,c);return this}setScalar(n){return this.r=n,this.g=n,this.b=n,this}setHex(n,r=Td){return n=Math.floor(n),this.r=(n>>16&255)/255,this.g=(n>>8&255)/255,this.b=(n&255)/255,Pc.toWorkingColorSpace(this,r),this}setRGB(n,r,c,u=Pc.workingColorSpace){return this.r=n,this.g=r,this.b=c,Pc.toWorkingColorSpace(this,u),this}setHSL(n,r,c,u=Pc.workingColorSpace){if(n=san(n,1),r=Sm(r,0,1),c=Sm(c,0,1),r===0)this.r=this.g=this.b=c;else{let d=c<=.5?c*(1+r):c+r-c*r,b=2*c-d;this.r=u6e(b,d,n+1/3),this.g=u6e(b,d,n),this.b=u6e(b,d,n-1/3)}return Pc.toWorkingColorSpace(this,u),this}setStyle(n,r=Td){function c(d){d!==void 0&&parseFloat(d)<1&&console.warn("THREE.Color: Alpha component of "+n+" will be ignored.")}let u;if(u=/^(\w+)\(([^\)]*)\)/.exec(n)){let d,b=u[1],w=u[2];switch(b){case"rgb":case"rgba":if(d=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(w))return c(d[4]),this.setRGB(Math.min(255,parseInt(d[1],10))/255,Math.min(255,parseInt(d[2],10))/255,Math.min(255,parseInt(d[3],10))/255,r);if(d=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(w))return c(d[4]),this.setRGB(Math.min(100,parseInt(d[1],10))/100,Math.min(100,parseInt(d[2],10))/100,Math.min(100,parseInt(d[3],10))/100,r);break;case"hsl":case"hsla":if(d=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(w))return c(d[4]),this.setHSL(parseFloat(d[1])/360,parseFloat(d[2])/100,parseFloat(d[3])/100,r);break;default:console.warn("THREE.Color: Unknown color model "+n)}}else if(u=/^\#([A-Fa-f\d]+)$/.exec(n)){let d=u[1],b=d.length;if(b===3)return this.setRGB(parseInt(d.charAt(0),16)/15,parseInt(d.charAt(1),16)/15,parseInt(d.charAt(2),16)/15,r);if(b===6)return this.setHex(parseInt(d,16),r);console.warn("THREE.Color: Invalid hex color "+n)}else if(n&&n.length>0)return this.setColorName(n,r);return this}setColorName(n,r=Td){let c=A2t[n.toLowerCase()];return c!==void 0?this.setHex(c,r):console.warn("THREE.Color: Unknown color "+n),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(n){return this.r=n.r,this.g=n.g,this.b=n.b,this}copySRGBToLinear(n){return this.r=aO(n.r),this.g=aO(n.g),this.b=aO(n.b),this}copyLinearToSRGB(n){return this.r=JIe(n.r),this.g=JIe(n.g),this.b=JIe(n.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(n=Td){return Pc.fromWorkingColorSpace(mp.copy(this),n),Math.round(Sm(mp.r*255,0,255))*65536+Math.round(Sm(mp.g*255,0,255))*256+Math.round(Sm(mp.b*255,0,255))}getHexString(n=Td){return("000000"+this.getHex(n).toString(16)).slice(-6)}getHSL(n,r=Pc.workingColorSpace){Pc.fromWorkingColorSpace(mp.copy(this),r);let c=mp.r,u=mp.g,d=mp.b,b=Math.max(c,u,d),w=Math.min(c,u,d),_,x,T=(w+b)/2;if(w===b)_=0,x=0;else{let M=b-w;switch(x=T<=.5?M/(b+w):M/(2-b-w),b){case c:_=(u-d)/M+(u0!=n>0&&this.version++,this._alphaTest=n}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(n){if(n!==void 0)for(let r in n){let c=n[r];if(c===void 0){console.warn(`THREE.Material: parameter '${r}' has value of undefined.`);continue}let u=this[r];if(u===void 0){console.warn(`THREE.Material: '${r}' is not a property of THREE.${this.type}.`);continue}u&&u.isColor?u.set(c):u&&u.isVector3&&c&&c.isVector3?u.copy(c):this[r]=c}}toJSON(n){let r=n===void 0||typeof n=="string";r&&(n={textures:{},images:{}});let c={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};c.uuid=this.uuid,c.type=this.type,this.name!==""&&(c.name=this.name),this.color&&this.color.isColor&&(c.color=this.color.getHex()),this.roughness!==void 0&&(c.roughness=this.roughness),this.metalness!==void 0&&(c.metalness=this.metalness),this.sheen!==void 0&&(c.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(c.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(c.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(c.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(c.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(c.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(c.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(c.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(c.shininess=this.shininess),this.clearcoat!==void 0&&(c.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(c.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(c.clearcoatMap=this.clearcoatMap.toJSON(n).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(c.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(n).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(c.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(n).uuid,c.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(c.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(c.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(c.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(c.iridescenceMap=this.iridescenceMap.toJSON(n).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(c.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(n).uuid),this.anisotropy!==void 0&&(c.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(c.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(c.anisotropyMap=this.anisotropyMap.toJSON(n).uuid),this.map&&this.map.isTexture&&(c.map=this.map.toJSON(n).uuid),this.matcap&&this.matcap.isTexture&&(c.matcap=this.matcap.toJSON(n).uuid),this.alphaMap&&this.alphaMap.isTexture&&(c.alphaMap=this.alphaMap.toJSON(n).uuid),this.lightMap&&this.lightMap.isTexture&&(c.lightMap=this.lightMap.toJSON(n).uuid,c.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(c.aoMap=this.aoMap.toJSON(n).uuid,c.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(c.bumpMap=this.bumpMap.toJSON(n).uuid,c.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(c.normalMap=this.normalMap.toJSON(n).uuid,c.normalMapType=this.normalMapType,c.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(c.displacementMap=this.displacementMap.toJSON(n).uuid,c.displacementScale=this.displacementScale,c.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(c.roughnessMap=this.roughnessMap.toJSON(n).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(c.metalnessMap=this.metalnessMap.toJSON(n).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(c.emissiveMap=this.emissiveMap.toJSON(n).uuid),this.specularMap&&this.specularMap.isTexture&&(c.specularMap=this.specularMap.toJSON(n).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(c.specularIntensityMap=this.specularIntensityMap.toJSON(n).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(c.specularColorMap=this.specularColorMap.toJSON(n).uuid),this.envMap&&this.envMap.isTexture&&(c.envMap=this.envMap.toJSON(n).uuid,this.combine!==void 0&&(c.combine=this.combine)),this.envMapIntensity!==void 0&&(c.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(c.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(c.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(c.gradientMap=this.gradientMap.toJSON(n).uuid),this.transmission!==void 0&&(c.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(c.transmissionMap=this.transmissionMap.toJSON(n).uuid),this.thickness!==void 0&&(c.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(c.thicknessMap=this.thicknessMap.toJSON(n).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(c.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(c.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(c.size=this.size),this.shadowSide!==null&&(c.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(c.sizeAttenuation=this.sizeAttenuation),this.blending!==oO&&(c.blending=this.blending),this.side!==bT&&(c.side=this.side),this.vertexColors===!0&&(c.vertexColors=!0),this.opacity<1&&(c.opacity=this.opacity),this.transparent===!0&&(c.transparent=!0),this.blendSrc!==x6e&&(c.blendSrc=this.blendSrc),this.blendDst!==E6e&&(c.blendDst=this.blendDst),this.blendEquation!==j4&&(c.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(c.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(c.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(c.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(c.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(c.blendAlpha=this.blendAlpha),this.depthFunc!==jfe&&(c.depthFunc=this.depthFunc),this.depthTest===!1&&(c.depthTest=this.depthTest),this.depthWrite===!1&&(c.depthWrite=this.depthWrite),this.colorWrite===!1&&(c.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(c.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==wyt&&(c.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(c.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(c.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==GB&&(c.stencilFail=this.stencilFail),this.stencilZFail!==GB&&(c.stencilZFail=this.stencilZFail),this.stencilZPass!==GB&&(c.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(c.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(c.rotation=this.rotation),this.polygonOffset===!0&&(c.polygonOffset=!0),this.polygonOffsetFactor!==0&&(c.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(c.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(c.linewidth=this.linewidth),this.dashSize!==void 0&&(c.dashSize=this.dashSize),this.gapSize!==void 0&&(c.gapSize=this.gapSize),this.scale!==void 0&&(c.scale=this.scale),this.dithering===!0&&(c.dithering=!0),this.alphaTest>0&&(c.alphaTest=this.alphaTest),this.alphaHash===!0&&(c.alphaHash=!0),this.alphaToCoverage===!0&&(c.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(c.premultipliedAlpha=!0),this.forceSinglePass===!0&&(c.forceSinglePass=!0),this.wireframe===!0&&(c.wireframe=!0),this.wireframeLinewidth>1&&(c.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(c.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(c.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(c.flatShading=!0),this.visible===!1&&(c.visible=!1),this.toneMapped===!1&&(c.toneMapped=!1),this.fog===!1&&(c.fog=!1),Object.keys(this.userData).length>0&&(c.userData=this.userData);function u(d){let b=[];for(let w in d){let _=d[w];delete _.metadata,b.push(_)}return b}if(r){let d=u(n.textures),b=u(n.images);d.length>0&&(c.textures=d),b.length>0&&(c.images=b)}return c}clone(){return new this.constructor().copy(this)}copy(n){this.name=n.name,this.blending=n.blending,this.side=n.side,this.vertexColors=n.vertexColors,this.opacity=n.opacity,this.transparent=n.transparent,this.blendSrc=n.blendSrc,this.blendDst=n.blendDst,this.blendEquation=n.blendEquation,this.blendSrcAlpha=n.blendSrcAlpha,this.blendDstAlpha=n.blendDstAlpha,this.blendEquationAlpha=n.blendEquationAlpha,this.blendColor.copy(n.blendColor),this.blendAlpha=n.blendAlpha,this.depthFunc=n.depthFunc,this.depthTest=n.depthTest,this.depthWrite=n.depthWrite,this.stencilWriteMask=n.stencilWriteMask,this.stencilFunc=n.stencilFunc,this.stencilRef=n.stencilRef,this.stencilFuncMask=n.stencilFuncMask,this.stencilFail=n.stencilFail,this.stencilZFail=n.stencilZFail,this.stencilZPass=n.stencilZPass,this.stencilWrite=n.stencilWrite;let r=n.clippingPlanes,c=null;if(r!==null){let u=r.length;c=new Array(u);for(let d=0;d!==u;++d)c[d]=r[d].clone()}return this.clippingPlanes=c,this.clipIntersection=n.clipIntersection,this.clipShadows=n.clipShadows,this.shadowSide=n.shadowSide,this.colorWrite=n.colorWrite,this.precision=n.precision,this.polygonOffset=n.polygonOffset,this.polygonOffsetFactor=n.polygonOffsetFactor,this.polygonOffsetUnits=n.polygonOffsetUnits,this.dithering=n.dithering,this.alphaTest=n.alphaTest,this.alphaHash=n.alphaHash,this.alphaToCoverage=n.alphaToCoverage,this.premultipliedAlpha=n.premultipliedAlpha,this.forceSinglePass=n.forceSinglePass,this.visible=n.visible,this.toneMapped=n.toneMapped,this.userData=JSON.parse(JSON.stringify(n.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(n){n===!0&&this.version++}},hO=class extends _T{constructor(n){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Go(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=c5e,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(n)}copy(n){return super.copy(n),this.color.copy(n.color),this.map=n.map,this.lightMap=n.lightMap,this.lightMapIntensity=n.lightMapIntensity,this.aoMap=n.aoMap,this.aoMapIntensity=n.aoMapIntensity,this.specularMap=n.specularMap,this.alphaMap=n.alphaMap,this.envMap=n.envMap,this.combine=n.combine,this.reflectivity=n.reflectivity,this.refractionRatio=n.refractionRatio,this.wireframe=n.wireframe,this.wireframeLinewidth=n.wireframeLinewidth,this.wireframeLinecap=n.wireframeLinecap,this.wireframeLinejoin=n.wireframeLinejoin,this.fog=n.fog,this}};var Ff=new Gt,Efe=new ka,q1=class{constructor(n,r,c=!1){if(Array.isArray(n))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=n,this.itemSize=r,this.count=n!==void 0?n.length/r:0,this.normalized=c,this.usage=vyt,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=hT,this.version=0}onUploadCallback(){}set needsUpdate(n){n===!0&&this.version++}get updateRange(){return console.warn("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(n){return this.usage=n,this}addUpdateRange(n,r){this.updateRanges.push({start:n,count:r})}clearUpdateRanges(){this.updateRanges.length=0}copy(n){return this.name=n.name,this.array=new n.array.constructor(n.array),this.itemSize=n.itemSize,this.count=n.count,this.normalized=n.normalized,this.usage=n.usage,this.gpuType=n.gpuType,this}copyAt(n,r,c){n*=this.itemSize,c*=r.itemSize;for(let u=0,d=this.itemSize;u0&&(n.userData=this.userData),this.parameters!==void 0){let _=this.parameters;for(let x in _)_[x]!==void 0&&(n[x]=_[x]);return n}n.data={attributes:{}};let r=this.index;r!==null&&(n.data.index={type:r.array.constructor.name,array:Array.prototype.slice.call(r.array)});let c=this.attributes;for(let _ in c){let x=c[_];n.data.attributes[_]=x.toJSON(n.data)}let u={},d=!1;for(let _ in this.morphAttributes){let x=this.morphAttributes[_],T=[];for(let M=0,L=x.length;M0&&(u[_]=T,d=!0)}d&&(n.data.morphAttributes=u,n.data.morphTargetsRelative=this.morphTargetsRelative);let b=this.groups;b.length>0&&(n.data.groups=JSON.parse(JSON.stringify(b)));let w=this.boundingSphere;return w!==null&&(n.data.boundingSphere={center:w.center.toArray(),radius:w.radius}),n}clone(){return new this.constructor().copy(this)}copy(n){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let r={};this.name=n.name;let c=n.index;c!==null&&this.setIndex(c.clone(r));let u=n.attributes;for(let x in u){let T=u[x];this.setAttribute(x,T.clone(r))}let d=n.morphAttributes;for(let x in d){let T=[],M=d[x];for(let L=0,I=M.length;L0){let u=r[c[0]];if(u!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let d=0,b=u.length;d(n.far-n.near)**2))&&(Iyt.copy(d).invert(),U4.copy(n.ray).applyMatrix4(Iyt),!(c.boundingBox!==null&&U4.intersectsBox(c.boundingBox)===!1)&&this._computeIntersections(n,r,U4)))}_computeIntersections(n,r,c){let u,d=this.geometry,b=this.material,w=d.index,_=d.attributes.position,x=d.attributes.uv,T=d.attributes.uv1,M=d.attributes.normal,L=d.groups,I=d.drawRange;if(w!==null)if(Array.isArray(b))for(let D=0,F=L.length;Dr.far?null:{distance:x,point:Lfe.clone(),object:s}}function kfe(s,n,r,c,u,d,b,w,_,x){s.getVertexPosition(w,KB),s.getVertexPosition(_,JB),s.getVertexPosition(x,QB);let T=_an(s,n,r,c,KB,JB,QB,Pfe);if(T){u&&(Tfe.fromBufferAttribute(u,w),Cfe.fromBufferAttribute(u,_),Afe.fromBufferAttribute(u,x),T.uv=V4.getInterpolation(Pfe,KB,JB,QB,Tfe,Cfe,Afe,new ka)),d&&(Tfe.fromBufferAttribute(d,w),Cfe.fromBufferAttribute(d,_),Afe.fromBufferAttribute(d,x),T.uv1=V4.getInterpolation(Pfe,KB,JB,QB,Tfe,Cfe,Afe,new ka),T.uv2=T.uv1),b&&(Byt.fromBufferAttribute(b,w),Oyt.fromBufferAttribute(b,_),Nyt.fromBufferAttribute(b,x),T.normal=V4.getInterpolation(Pfe,KB,JB,QB,Byt,Oyt,Nyt,new Gt),T.normal.dot(c.direction)>0&&T.normal.multiplyScalar(-1));let M={a:w,b:_,c:x,normal:new Gt,materialIndex:0};V4.getNormal(KB,JB,QB,M.normal),T.face=M}return T}var X4=class s extends d2{constructor(n=1,r=1,c=1,u=1,d=1,b=1){super(),this.type="BoxGeometry",this.parameters={width:n,height:r,depth:c,widthSegments:u,heightSegments:d,depthSegments:b};let w=this;u=Math.floor(u),d=Math.floor(d),b=Math.floor(b);let _=[],x=[],T=[],M=[],L=0,I=0;D("z","y","x",-1,-1,c,r,n,b,d,0),D("z","y","x",1,-1,c,r,-n,b,d,1),D("x","z","y",1,1,n,c,r,u,b,2),D("x","z","y",1,-1,n,c,-r,u,b,3),D("x","y","z",1,-1,n,r,c,u,d,4),D("x","y","z",-1,-1,n,r,-c,u,d,5),this.setIndex(_),this.setAttribute("position",new Cm(x,3)),this.setAttribute("normal",new Cm(T,3)),this.setAttribute("uv",new Cm(M,2));function D(F,O,z,Z,H,te,oe,ne,ue,Te,Q){let ge=te/ue,Qe=oe/Te,st=te/2,at=oe/2,Ne=ne/2,tt=ue+1,ot=Te+1,Tt=0,jt=0,en=new Gt;for(let mn=0;mn0?1:-1,T.push(en.x,en.y,en.z),M.push(bi/ue),M.push(1-mn/Te),Tt+=1}}for(let mn=0;mns.polygon},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:ife},getLineColor:{type:"accessor",value:ife},material:!0},nfe={enter:(s,n)=>n.length?n.subarray(n.length-s.length):s},mW=class extends z3{getShaders(n){let r=!this.props._normalize&&this.props._windingOrder==="CCW"?0:1;return super.getShaders({vs:n==="top"?Kvt:Jvt,fs:Qvt,source:n_t(n,!!r),defines:{RING_WINDING_ORDER_CW:r},modules:[Zy,qy,ZD,Jy,Zvt,...this.context.device.type==="webgpu"?[DB]:[]]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){let{viewport:n}=this.context,{coordinateSystem:r}=this.props,{_full3d:c}=this.props;n.isGeospatial&&r==="default"&&(r="lnglat");let u;r==="lnglat"&&(c?u=n.projectPosition.bind(n):u=n.projectFlat.bind(n)),this.setState({numInstances:0,polygonTesselator:new gW({preproject:u,fp64:this.use64bitPositions(),IndexType:Uint32Array})});let d=this.getAttributeManager(),b=!0,w=this.context.device.type==="webgpu";d.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:b},vertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:nfe,accessor:"getPolygon",update:this.calculatePositions,noAlloc:b,...w?{}:{shaderAttributes:{nextVertexPositions:{vertexOffset:1}}}},...w?{nextVertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:!1,update:this.calculateNextPositions,noAlloc:b}}:{},[w?"vertexValid":"instanceVertexValid"]:{size:1,type:w?"float32":"uint16",stepMode:"instance",update:this.calculateVertexValid,noAlloc:b},elevations:{size:1,stepMode:"dynamic",transition:nfe,accessor:"getElevation",bufferGroup:"solid-polygon-instance-data"},fillColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:nfe,accessor:"getFillColor",defaultValue:ife,bufferGroup:"solid-polygon-instance-data"},lineColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:nfe,accessor:"getLineColor",defaultValue:ife,bufferGroup:"solid-polygon-instance-data"},rowIndexes:{size:1,type:"uint32",stepMode:"dynamic",accessor:(_,{index:x})=>_&&_.__source?_.__source.index:x,bufferGroup:"solid-polygon-instance-data"}})}getPickingInfo(n){let r=super.getPickingInfo(n),{index:c}=r,u=this.props.data;return u[0]&&u[0].__source&&(r.object=u.find(d=>d.__source.index===c)),r}disablePickingIndex(n){let r=this.props.data;if(r[0]&&r[0].__source)for(let c=0;cw.destroy()),this.setState(this._getModels()),d.invalidateAll())}updateGeometry({props:n,oldProps:r,changeFlags:c}){if(c.dataChanged||c.updateTriggersChanged&&(c.updateTriggersChanged.all||c.updateTriggersChanged.getPolygon)){let{polygonTesselator:d}=this.state,b=n.data.attributes||{};d.updateGeometry({data:n.data,normalize:n._normalize,geometryBuffer:b.getPolygon,buffers:this.context.device.type==="webgpu"?{...b}:b,getGeometry:n.getPolygon,positionFormat:n.positionFormat,wrapLongitude:n.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:c.dataChanged,full3d:n._full3d}),this.setState({numInstances:d.instanceCount,startIndices:d.vertexStarts}),c.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(){let{id:n,filled:r,extruded:c}=this.props,u,d,b;if(r){let w=this.getShaders("top");w.defines={...w.defines,NON_INSTANCED_MODEL:1};let _=this.getAttributeManager().getBufferLayouts({isInstanced:!1});this.context.device.type==="webgpu"&&(_=_.filter(x=>x.name!=="indices"&&x.name!=="vertexValid"&&x.name!=="instanceVertexValid"&&x.name!=="nextVertexPositions")),u=new Vh(this.context.device,{...w,id:`${n}-top`,topology:"triangle-list",bufferLayout:_,isIndexed:!0,userData:{excludeAttributes:{vertexValid:!0,instanceVertexValid:!0,nextVertexPositions:!0}}})}if(c){let w=this.getAttributeManager().getBufferLayouts({isInstanced:!0});this.context.device.type==="webgpu"&&(w=w.filter(_=>_.name!=="indices")),d=new Vh(this.context.device,{...this.getShaders("side"),id:`${n}-side`,bufferLayout:w,geometry:new Lb({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,1,1,0,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}}),b=new Vh(this.context.device,{...this.getShaders("side"),id:`${n}-wireframe`,bufferLayout:w,geometry:new Lb({topology:"line-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,0,1,1,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}})}return{models:[d,b,u].filter(Boolean),topModel:u,sideModel:d,wireframeModel:b}}calculateIndices(n){let{polygonTesselator:r}=this.state;n.startIndices=r.indexStarts,n.value=r.get("indices")}calculatePositions(n){let{polygonTesselator:r}=this.state;n.startIndices=r.vertexStarts;let c=this.props.data.attributes?.getPolygon;if(this.context.device.type==="webgpu"&&ArrayBuffer.isView(c?.value)){let{value:u,size:d=3,offset:b=0,stride:w}=c,_=b/u.BYTES_PER_ELEMENT,x=w?w/u.BYTES_PER_ELEMENT:d,T=new Float64Array(r.instanceCount*3);for(let M=0;M2?u[L+2]:0}n.value=T;return}n.value=r.get("positions")}calculateVertexValid(n){let r=this.props.data.attributes?.instanceVertexValid?.value,c=this.context.device.type==="webgpu"&&r?r:this.state.polygonTesselator.get("vertexValid");n.value=this.context.device.type==="webgpu"&&c?Float32Array.from(c):c}calculateNextPositions(n){let{polygonTesselator:r}=this.state,c=this.getAttributeManager().getAttributes(),u=c.vertexPositions.value,d=this.props.data.attributes?.instanceVertexValid?.value||c.vertexValid?.value||r.get("vertexValid");if(n.startIndices=r.vertexStarts,!u){n.value=u;return}let b=u.length/3,w=new u.constructor(u.length);for(let _=0;_phe,BoxGeometry:()=>X4,Color:()=>Go,DirectionalLight:()=>dhe,DoubleSide:()=>Mv,EdgesGeometry:()=>uhe,GridHelper:()=>mhe,Group:()=>dT,InstancedMesh:()=>lhe,LineBasicMaterial:()=>pO,LineSegments:()=>zW,Matrix4:()=>Il,Mesh:()=>Mm,MeshBasicMaterial:()=>hO,MeshPhongMaterial:()=>fhe,PerspectiveCamera:()=>pg,Quaternion:()=>h2,Raycaster:()=>ghe,Scene:()=>ahe,Vector2:()=>ka,Vector3:()=>Gt,WebGLRenderer:()=>UW});var a5e="160";var lon=0,N_t=1,uon=2;var g2t=1,fon=2,H3=3,bT=0,Tm=1,Mv=2;var pT=0,oO=1,F_t=2,U_t=3,z_t=4,hon=5,j4=100,don=101,pon=102,G_t=103,j_t=104,gon=200,mon=201,bon=202,won=203,x6e=204,E6e=205,von=206,_on=207,yon=208,xon=209,Eon=210,Son=211,Mon=212,Ton=213,Con=214,Aon=0,Pon=1,Lon=2,jfe=3,kon=4,Ron=5,Ion=6,Don=7,c5e=0,Bon=1,Oon=2,gT=0,Non=1,Fon=2,Uon=3,zon=4,Gon=5,jon=6;var m2t=300,lO=301,uO=302,S6e=303,M6e=304,bhe=306,T6e=1e3,Tv=1001,C6e=1002,dg=1003,$_t=1004;var $Ie=1005;var Bb=1006,$on=1007;var DW=1008;var mT=1009,Von=1010,Won=1011,l5e=1012,b2t=1013,fT=1014,hT=1015,BW=1016,w2t=1017,v2t=1018,W4=1020,Hon=1021,Cv=1023,qon=1024,Xon=1025,H4=1026,fO=1027,Yon=1028,_2t=1029,Zon=1030,y2t=1031,x2t=1033,VIe=33776,WIe=33777,HIe=33778,qIe=33779,V_t=35840,W_t=35841,H_t=35842,q_t=35843,E2t=36196,X_t=37492,Y_t=37496,Z_t=37808,K_t=37809,J_t=37810,Q_t=37811,eyt=37812,tyt=37813,nyt=37814,iyt=37815,ryt=37816,syt=37817,oyt=37818,ayt=37819,cyt=37820,lyt=37821,XIe=36492,uyt=36494,fyt=36495,Kon=36283,hyt=36284,dyt=36285,pyt=36286;var $fe=2300,Vfe=2301,YIe=2302,gyt=2400,myt=2401,byt=2402;var S2t=3e3,q4=3001,Jon=3200,Qon=3201,M2t=0,ean=1,Ob="",Td="srgb",Y3="srgb-linear",u5e="display-p3",whe="display-p3-linear",Wfe="linear",dl="srgb",Hfe="rec709",qfe="p3";var GB=7680;var wyt=519,tan=512,nan=513,ian=514,T2t=515,ran=516,san=517,oan=518,aan=519,vyt=35044;var _yt="300 es",A6e=1035,X3=2e3,Xfe=2001,wT=class{addEventListener(n,r){this._listeners===void 0&&(this._listeners={});let c=this._listeners;c[n]===void 0&&(c[n]=[]),c[n].indexOf(r)===-1&&c[n].push(r)}hasEventListener(n,r){if(this._listeners===void 0)return!1;let c=this._listeners;return c[n]!==void 0&&c[n].indexOf(r)!==-1}removeEventListener(n,r){if(this._listeners===void 0)return;let u=this._listeners[n];if(u!==void 0){let d=u.indexOf(r);d!==-1&&u.splice(d,1)}}dispatchEvent(n){if(this._listeners===void 0)return;let c=this._listeners[n.type];if(c!==void 0){n.target=this;let u=c.slice(0);for(let d=0,b=u.length;d>8&255]+gp[s>>16&255]+gp[s>>24&255]+"-"+gp[n&255]+gp[n>>8&255]+"-"+gp[n>>16&15|64]+gp[n>>24&255]+"-"+gp[r&63|128]+gp[r>>8&255]+"-"+gp[r>>16&255]+gp[r>>24&255]+gp[c&255]+gp[c>>8&255]+gp[c>>16&255]+gp[c>>24&255]).toLowerCase()}function Sm(s,n,r){return Math.max(n,Math.min(r,s))}function can(s,n){return(s%n+n)%n}function ZIe(s,n,r){return(1-r)*s+r*n}function yyt(s){return(s&s-1)===0&&s!==0}function L6e(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function MW(s,n){switch(n.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function Em(s,n){switch(n.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}var ka=class s{constructor(n=0,r=0){s.prototype.isVector2=!0,this.x=n,this.y=r}get width(){return this.x}set width(n){this.x=n}get height(){return this.y}set height(n){this.y=n}set(n,r){return this.x=n,this.y=r,this}setScalar(n){return this.x=n,this.y=n,this}setX(n){return this.x=n,this}setY(n){return this.y=n,this}setComponent(n,r){switch(n){case 0:this.x=r;break;case 1:this.y=r;break;default:throw new Error("index is out of range: "+n)}return this}getComponent(n){switch(n){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+n)}}clone(){return new this.constructor(this.x,this.y)}copy(n){return this.x=n.x,this.y=n.y,this}add(n){return this.x+=n.x,this.y+=n.y,this}addScalar(n){return this.x+=n,this.y+=n,this}addVectors(n,r){return this.x=n.x+r.x,this.y=n.y+r.y,this}addScaledVector(n,r){return this.x+=n.x*r,this.y+=n.y*r,this}sub(n){return this.x-=n.x,this.y-=n.y,this}subScalar(n){return this.x-=n,this.y-=n,this}subVectors(n,r){return this.x=n.x-r.x,this.y=n.y-r.y,this}multiply(n){return this.x*=n.x,this.y*=n.y,this}multiplyScalar(n){return this.x*=n,this.y*=n,this}divide(n){return this.x/=n.x,this.y/=n.y,this}divideScalar(n){return this.multiplyScalar(1/n)}applyMatrix3(n){let r=this.x,c=this.y,u=n.elements;return this.x=u[0]*r+u[3]*c+u[6],this.y=u[1]*r+u[4]*c+u[7],this}min(n){return this.x=Math.min(this.x,n.x),this.y=Math.min(this.y,n.y),this}max(n){return this.x=Math.max(this.x,n.x),this.y=Math.max(this.y,n.y),this}clamp(n,r){return this.x=Math.max(n.x,Math.min(r.x,this.x)),this.y=Math.max(n.y,Math.min(r.y,this.y)),this}clampScalar(n,r){return this.x=Math.max(n,Math.min(r,this.x)),this.y=Math.max(n,Math.min(r,this.y)),this}clampLength(n,r){let c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(n,Math.min(r,c)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(n){return this.x*n.x+this.y*n.y}cross(n){return this.x*n.y-this.y*n.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(n){let r=Math.sqrt(this.lengthSq()*n.lengthSq());if(r===0)return Math.PI/2;let c=this.dot(n)/r;return Math.acos(Sm(c,-1,1))}distanceTo(n){return Math.sqrt(this.distanceToSquared(n))}distanceToSquared(n){let r=this.x-n.x,c=this.y-n.y;return r*r+c*c}manhattanDistanceTo(n){return Math.abs(this.x-n.x)+Math.abs(this.y-n.y)}setLength(n){return this.normalize().multiplyScalar(n)}lerp(n,r){return this.x+=(n.x-this.x)*r,this.y+=(n.y-this.y)*r,this}lerpVectors(n,r,c){return this.x=n.x+(r.x-n.x)*c,this.y=n.y+(r.y-n.y)*c,this}equals(n){return n.x===this.x&&n.y===this.y}fromArray(n,r=0){return this.x=n[r],this.y=n[r+1],this}toArray(n=[],r=0){return n[r]=this.x,n[r+1]=this.y,n}fromBufferAttribute(n,r){return this.x=n.getX(r),this.y=n.getY(r),this}rotateAround(n,r){let c=Math.cos(r),u=Math.sin(r),d=this.x-n.x,b=this.y-n.y;return this.x=d*c-b*u+n.x,this.y=d*u+b*c+n.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Xo=class s{constructor(n,r,c,u,d,b,w,_,x){s.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],n!==void 0&&this.set(n,r,c,u,d,b,w,_,x)}set(n,r,c,u,d,b,w,_,x){let T=this.elements;return T[0]=n,T[1]=u,T[2]=w,T[3]=r,T[4]=d,T[5]=_,T[6]=c,T[7]=b,T[8]=x,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(n){let r=this.elements,c=n.elements;return r[0]=c[0],r[1]=c[1],r[2]=c[2],r[3]=c[3],r[4]=c[4],r[5]=c[5],r[6]=c[6],r[7]=c[7],r[8]=c[8],this}extractBasis(n,r,c){return n.setFromMatrix3Column(this,0),r.setFromMatrix3Column(this,1),c.setFromMatrix3Column(this,2),this}setFromMatrix4(n){let r=n.elements;return this.set(r[0],r[4],r[8],r[1],r[5],r[9],r[2],r[6],r[10]),this}multiply(n){return this.multiplyMatrices(this,n)}premultiply(n){return this.multiplyMatrices(n,this)}multiplyMatrices(n,r){let c=n.elements,u=r.elements,d=this.elements,b=c[0],w=c[3],_=c[6],x=c[1],T=c[4],M=c[7],L=c[2],I=c[5],D=c[8],F=u[0],O=u[3],z=u[6],Z=u[1],H=u[4],te=u[7],oe=u[2],ne=u[5],ue=u[8];return d[0]=b*F+w*Z+_*oe,d[3]=b*O+w*H+_*ne,d[6]=b*z+w*te+_*ue,d[1]=x*F+T*Z+M*oe,d[4]=x*O+T*H+M*ne,d[7]=x*z+T*te+M*ue,d[2]=L*F+I*Z+D*oe,d[5]=L*O+I*H+D*ne,d[8]=L*z+I*te+D*ue,this}multiplyScalar(n){let r=this.elements;return r[0]*=n,r[3]*=n,r[6]*=n,r[1]*=n,r[4]*=n,r[7]*=n,r[2]*=n,r[5]*=n,r[8]*=n,this}determinant(){let n=this.elements,r=n[0],c=n[1],u=n[2],d=n[3],b=n[4],w=n[5],_=n[6],x=n[7],T=n[8];return r*b*T-r*w*x-c*d*T+c*w*_+u*d*x-u*b*_}invert(){let n=this.elements,r=n[0],c=n[1],u=n[2],d=n[3],b=n[4],w=n[5],_=n[6],x=n[7],T=n[8],M=T*b-w*x,L=w*_-T*d,I=x*d-b*_,D=r*M+c*L+u*I;if(D===0)return this.set(0,0,0,0,0,0,0,0,0);let F=1/D;return n[0]=M*F,n[1]=(u*x-T*c)*F,n[2]=(w*c-u*b)*F,n[3]=L*F,n[4]=(T*r-u*_)*F,n[5]=(u*d-w*r)*F,n[6]=I*F,n[7]=(c*_-x*r)*F,n[8]=(b*r-c*d)*F,this}transpose(){let n,r=this.elements;return n=r[1],r[1]=r[3],r[3]=n,n=r[2],r[2]=r[6],r[6]=n,n=r[5],r[5]=r[7],r[7]=n,this}getNormalMatrix(n){return this.setFromMatrix4(n).invert().transpose()}transposeIntoArray(n){let r=this.elements;return n[0]=r[0],n[1]=r[3],n[2]=r[6],n[3]=r[1],n[4]=r[4],n[5]=r[7],n[6]=r[2],n[7]=r[5],n[8]=r[8],this}setUvTransform(n,r,c,u,d,b,w){let _=Math.cos(d),x=Math.sin(d);return this.set(c*_,c*x,-c*(_*b+x*w)+b+n,-u*x,u*_,-u*(-x*b+_*w)+w+r,0,0,1),this}scale(n,r){return this.premultiply(KIe.makeScale(n,r)),this}rotate(n){return this.premultiply(KIe.makeRotation(-n)),this}translate(n,r){return this.premultiply(KIe.makeTranslation(n,r)),this}makeTranslation(n,r){return n.isVector2?this.set(1,0,n.x,0,1,n.y,0,0,1):this.set(1,0,n,0,1,r,0,0,1),this}makeRotation(n){let r=Math.cos(n),c=Math.sin(n);return this.set(r,-c,0,c,r,0,0,0,1),this}makeScale(n,r){return this.set(n,0,0,0,r,0,0,0,1),this}equals(n){let r=this.elements,c=n.elements;for(let u=0;u<9;u++)if(r[u]!==c[u])return!1;return!0}fromArray(n,r=0){for(let c=0;c<9;c++)this.elements[c]=n[c+r];return this}toArray(n=[],r=0){let c=this.elements;return n[r]=c[0],n[r+1]=c[1],n[r+2]=c[2],n[r+3]=c[3],n[r+4]=c[4],n[r+5]=c[5],n[r+6]=c[6],n[r+7]=c[7],n[r+8]=c[8],n}clone(){return new this.constructor().fromArray(this.elements)}},KIe=new Xo;function C2t(s){for(let n=s.length-1;n>=0;--n)if(s[n]>=65535)return!0;return!1}function Yfe(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function lan(){let s=Yfe("canvas");return s.style.display="block",s}var xyt={};function RW(s){s in xyt||(xyt[s]=!0,console.warn(s))}var Eyt=new Xo().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Syt=new Xo().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),dfe={[Y3]:{transfer:Wfe,primaries:Hfe,toReference:s=>s,fromReference:s=>s},[Td]:{transfer:dl,primaries:Hfe,toReference:s=>s.convertSRGBToLinear(),fromReference:s=>s.convertLinearToSRGB()},[whe]:{transfer:Wfe,primaries:qfe,toReference:s=>s.applyMatrix3(Syt),fromReference:s=>s.applyMatrix3(Eyt)},[u5e]:{transfer:dl,primaries:qfe,toReference:s=>s.convertSRGBToLinear().applyMatrix3(Syt),fromReference:s=>s.applyMatrix3(Eyt).convertLinearToSRGB()}},uan=new Set([Y3,whe]),Pc={enabled:!0,_workingColorSpace:Y3,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(s){if(!uan.has(s))throw new Error(`Unsupported working color space, "${s}".`);this._workingColorSpace=s},convert:function(s,n,r){if(this.enabled===!1||n===r||!n||!r)return s;let c=dfe[n].toReference,u=dfe[r].fromReference;return u(c(s))},fromWorkingColorSpace:function(s,n){return this.convert(s,this._workingColorSpace,n)},toWorkingColorSpace:function(s,n){return this.convert(s,n,this._workingColorSpace)},getPrimaries:function(s){return dfe[s].primaries},getTransfer:function(s){return s===Ob?Wfe:dfe[s].transfer}};function aO(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function JIe(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}var jB,Zfe=class{static getDataURL(n){if(/^data:/i.test(n.src)||typeof HTMLCanvasElement>"u")return n.src;let r;if(n instanceof HTMLCanvasElement)r=n;else{jB===void 0&&(jB=Yfe("canvas")),jB.width=n.width,jB.height=n.height;let c=jB.getContext("2d");n instanceof ImageData?c.putImageData(n,0,0):c.drawImage(n,0,0,n.width,n.height),r=jB}return r.width>2048||r.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",n),r.toDataURL("image/jpeg",.6)):r.toDataURL("image/png")}static sRGBToLinear(n){if(typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap){let r=Yfe("canvas");r.width=n.width,r.height=n.height;let c=r.getContext("2d");c.drawImage(n,0,0,n.width,n.height);let u=c.getImageData(0,0,n.width,n.height),d=u.data;for(let b=0;b0&&(c.userData=this.userData),r||(n.textures[this.uuid]=c),c}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(n){if(this.mapping!==m2t)return n;if(n.applyMatrix3(this.matrix),n.x<0||n.x>1)switch(this.wrapS){case T6e:n.x=n.x-Math.floor(n.x);break;case Tv:n.x=n.x<0?0:1;break;case C6e:Math.abs(Math.floor(n.x)%2)===1?n.x=Math.ceil(n.x)-n.x:n.x=n.x-Math.floor(n.x);break}if(n.y<0||n.y>1)switch(this.wrapT){case T6e:n.y=n.y-Math.floor(n.y);break;case Tv:n.y=n.y<0?0:1;break;case C6e:Math.abs(Math.floor(n.y)%2)===1?n.y=Math.ceil(n.y)-n.y:n.y=n.y-Math.floor(n.y);break}return this.flipY&&(n.y=1-n.y),n}set needsUpdate(n){n===!0&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return RW("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Td?q4:S2t}set encoding(n){RW("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=n===q4?Td:Ob}};Av.DEFAULT_IMAGE=null;Av.DEFAULT_MAPPING=m2t;Av.DEFAULT_ANISOTROPY=1;var qh=class s{constructor(n=0,r=0,c=0,u=1){s.prototype.isVector4=!0,this.x=n,this.y=r,this.z=c,this.w=u}get width(){return this.z}set width(n){this.z=n}get height(){return this.w}set height(n){this.w=n}set(n,r,c,u){return this.x=n,this.y=r,this.z=c,this.w=u,this}setScalar(n){return this.x=n,this.y=n,this.z=n,this.w=n,this}setX(n){return this.x=n,this}setY(n){return this.y=n,this}setZ(n){return this.z=n,this}setW(n){return this.w=n,this}setComponent(n,r){switch(n){case 0:this.x=r;break;case 1:this.y=r;break;case 2:this.z=r;break;case 3:this.w=r;break;default:throw new Error("index is out of range: "+n)}return this}getComponent(n){switch(n){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+n)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(n){return this.x=n.x,this.y=n.y,this.z=n.z,this.w=n.w!==void 0?n.w:1,this}add(n){return this.x+=n.x,this.y+=n.y,this.z+=n.z,this.w+=n.w,this}addScalar(n){return this.x+=n,this.y+=n,this.z+=n,this.w+=n,this}addVectors(n,r){return this.x=n.x+r.x,this.y=n.y+r.y,this.z=n.z+r.z,this.w=n.w+r.w,this}addScaledVector(n,r){return this.x+=n.x*r,this.y+=n.y*r,this.z+=n.z*r,this.w+=n.w*r,this}sub(n){return this.x-=n.x,this.y-=n.y,this.z-=n.z,this.w-=n.w,this}subScalar(n){return this.x-=n,this.y-=n,this.z-=n,this.w-=n,this}subVectors(n,r){return this.x=n.x-r.x,this.y=n.y-r.y,this.z=n.z-r.z,this.w=n.w-r.w,this}multiply(n){return this.x*=n.x,this.y*=n.y,this.z*=n.z,this.w*=n.w,this}multiplyScalar(n){return this.x*=n,this.y*=n,this.z*=n,this.w*=n,this}applyMatrix4(n){let r=this.x,c=this.y,u=this.z,d=this.w,b=n.elements;return this.x=b[0]*r+b[4]*c+b[8]*u+b[12]*d,this.y=b[1]*r+b[5]*c+b[9]*u+b[13]*d,this.z=b[2]*r+b[6]*c+b[10]*u+b[14]*d,this.w=b[3]*r+b[7]*c+b[11]*u+b[15]*d,this}divideScalar(n){return this.multiplyScalar(1/n)}setAxisAngleFromQuaternion(n){this.w=2*Math.acos(n.w);let r=Math.sqrt(1-n.w*n.w);return r<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=n.x/r,this.y=n.y/r,this.z=n.z/r),this}setAxisAngleFromRotationMatrix(n){let r,c,u,d,_=n.elements,x=_[0],T=_[4],M=_[8],L=_[1],I=_[5],D=_[9],F=_[2],O=_[6],z=_[10];if(Math.abs(T-L)<.01&&Math.abs(M-F)<.01&&Math.abs(D-O)<.01){if(Math.abs(T+L)<.1&&Math.abs(M+F)<.1&&Math.abs(D+O)<.1&&Math.abs(x+I+z-3)<.1)return this.set(1,0,0,0),this;r=Math.PI;let H=(x+1)/2,te=(I+1)/2,oe=(z+1)/2,ne=(T+L)/4,ue=(M+F)/4,Te=(D+O)/4;return H>te&&H>oe?H<.01?(c=0,u=.707106781,d=.707106781):(c=Math.sqrt(H),u=ne/c,d=ue/c):te>oe?te<.01?(c=.707106781,u=0,d=.707106781):(u=Math.sqrt(te),c=ne/u,d=Te/u):oe<.01?(c=.707106781,u=.707106781,d=0):(d=Math.sqrt(oe),c=ue/d,u=Te/d),this.set(c,u,d,r),this}let Z=Math.sqrt((O-D)*(O-D)+(M-F)*(M-F)+(L-T)*(L-T));return Math.abs(Z)<.001&&(Z=1),this.x=(O-D)/Z,this.y=(M-F)/Z,this.z=(L-T)/Z,this.w=Math.acos((x+I+z-1)/2),this}min(n){return this.x=Math.min(this.x,n.x),this.y=Math.min(this.y,n.y),this.z=Math.min(this.z,n.z),this.w=Math.min(this.w,n.w),this}max(n){return this.x=Math.max(this.x,n.x),this.y=Math.max(this.y,n.y),this.z=Math.max(this.z,n.z),this.w=Math.max(this.w,n.w),this}clamp(n,r){return this.x=Math.max(n.x,Math.min(r.x,this.x)),this.y=Math.max(n.y,Math.min(r.y,this.y)),this.z=Math.max(n.z,Math.min(r.z,this.z)),this.w=Math.max(n.w,Math.min(r.w,this.w)),this}clampScalar(n,r){return this.x=Math.max(n,Math.min(r,this.x)),this.y=Math.max(n,Math.min(r,this.y)),this.z=Math.max(n,Math.min(r,this.z)),this.w=Math.max(n,Math.min(r,this.w)),this}clampLength(n,r){let c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(n,Math.min(r,c)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(n){return this.x*n.x+this.y*n.y+this.z*n.z+this.w*n.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(n){return this.normalize().multiplyScalar(n)}lerp(n,r){return this.x+=(n.x-this.x)*r,this.y+=(n.y-this.y)*r,this.z+=(n.z-this.z)*r,this.w+=(n.w-this.w)*r,this}lerpVectors(n,r,c){return this.x=n.x+(r.x-n.x)*c,this.y=n.y+(r.y-n.y)*c,this.z=n.z+(r.z-n.z)*c,this.w=n.w+(r.w-n.w)*c,this}equals(n){return n.x===this.x&&n.y===this.y&&n.z===this.z&&n.w===this.w}fromArray(n,r=0){return this.x=n[r],this.y=n[r+1],this.z=n[r+2],this.w=n[r+3],this}toArray(n=[],r=0){return n[r]=this.x,n[r+1]=this.y,n[r+2]=this.z,n[r+3]=this.w,n}fromBufferAttribute(n,r){return this.x=n.getX(r),this.y=n.getY(r),this.z=n.getZ(r),this.w=n.getW(r),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},k6e=class extends wT{constructor(n=1,r=1,c={}){super(),this.isRenderTarget=!0,this.width=n,this.height=r,this.depth=1,this.scissor=new qh(0,0,n,r),this.scissorTest=!1,this.viewport=new qh(0,0,n,r);let u={width:n,height:r,depth:1};c.encoding!==void 0&&(RW("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),c.colorSpace=c.encoding===q4?Td:Ob),c=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Bb,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},c),this.texture=new Av(u,c.mapping,c.wrapS,c.wrapT,c.magFilter,c.minFilter,c.format,c.type,c.anisotropy,c.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=c.generateMipmaps,this.texture.internalFormat=c.internalFormat,this.depthBuffer=c.depthBuffer,this.stencilBuffer=c.stencilBuffer,this.depthTexture=c.depthTexture,this.samples=c.samples}setSize(n,r,c=1){(this.width!==n||this.height!==r||this.depth!==c)&&(this.width=n,this.height=r,this.depth=c,this.texture.image.width=n,this.texture.image.height=r,this.texture.image.depth=c,this.dispose()),this.viewport.set(0,0,n,r),this.scissor.set(0,0,n,r)}clone(){return new this.constructor().copy(this)}copy(n){this.width=n.width,this.height=n.height,this.depth=n.depth,this.scissor.copy(n.scissor),this.scissorTest=n.scissorTest,this.viewport.copy(n.viewport),this.texture=n.texture.clone(),this.texture.isRenderTargetTexture=!0;let r=Object.assign({},n.texture.image);return this.texture.source=new Kfe(r),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,n.depthTexture!==null&&(this.depthTexture=n.depthTexture.clone()),this.samples=n.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},Z3=class extends k6e{constructor(n=1,r=1,c={}){super(n,r,c),this.isWebGLRenderTarget=!0}},Jfe=class extends Av{constructor(n=null,r=1,c=1,u=1){super(null),this.isDataArrayTexture=!0,this.image={data:n,width:r,height:c,depth:u},this.magFilter=dg,this.minFilter=dg,this.wrapR=Tv,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var R6e=class extends Av{constructor(n=null,r=1,c=1,u=1){super(null),this.isData3DTexture=!0,this.image={data:n,width:r,height:c,depth:u},this.magFilter=dg,this.minFilter=dg,this.wrapR=Tv,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var h2=class{constructor(n=0,r=0,c=0,u=1){this.isQuaternion=!0,this._x=n,this._y=r,this._z=c,this._w=u}static slerpFlat(n,r,c,u,d,b,w){let _=c[u+0],x=c[u+1],T=c[u+2],M=c[u+3],L=d[b+0],I=d[b+1],D=d[b+2],F=d[b+3];if(w===0){n[r+0]=_,n[r+1]=x,n[r+2]=T,n[r+3]=M;return}if(w===1){n[r+0]=L,n[r+1]=I,n[r+2]=D,n[r+3]=F;return}if(M!==F||_!==L||x!==I||T!==D){let O=1-w,z=_*L+x*I+T*D+M*F,Z=z>=0?1:-1,H=1-z*z;if(H>Number.EPSILON){let oe=Math.sqrt(H),ne=Math.atan2(oe,z*Z);O=Math.sin(O*ne)/oe,w=Math.sin(w*ne)/oe}let te=w*Z;if(_=_*O+L*te,x=x*O+I*te,T=T*O+D*te,M=M*O+F*te,O===1-w){let oe=1/Math.sqrt(_*_+x*x+T*T+M*M);_*=oe,x*=oe,T*=oe,M*=oe}}n[r]=_,n[r+1]=x,n[r+2]=T,n[r+3]=M}static multiplyQuaternionsFlat(n,r,c,u,d,b){let w=c[u],_=c[u+1],x=c[u+2],T=c[u+3],M=d[b],L=d[b+1],I=d[b+2],D=d[b+3];return n[r]=w*D+T*M+_*I-x*L,n[r+1]=_*D+T*L+x*M-w*I,n[r+2]=x*D+T*I+w*L-_*M,n[r+3]=T*D-w*M-_*L-x*I,n}get x(){return this._x}set x(n){this._x=n,this._onChangeCallback()}get y(){return this._y}set y(n){this._y=n,this._onChangeCallback()}get z(){return this._z}set z(n){this._z=n,this._onChangeCallback()}get w(){return this._w}set w(n){this._w=n,this._onChangeCallback()}set(n,r,c,u){return this._x=n,this._y=r,this._z=c,this._w=u,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(n){return this._x=n.x,this._y=n.y,this._z=n.z,this._w=n.w,this._onChangeCallback(),this}setFromEuler(n,r=!0){let c=n._x,u=n._y,d=n._z,b=n._order,w=Math.cos,_=Math.sin,x=w(c/2),T=w(u/2),M=w(d/2),L=_(c/2),I=_(u/2),D=_(d/2);switch(b){case"XYZ":this._x=L*T*M+x*I*D,this._y=x*I*M-L*T*D,this._z=x*T*D+L*I*M,this._w=x*T*M-L*I*D;break;case"YXZ":this._x=L*T*M+x*I*D,this._y=x*I*M-L*T*D,this._z=x*T*D-L*I*M,this._w=x*T*M+L*I*D;break;case"ZXY":this._x=L*T*M-x*I*D,this._y=x*I*M+L*T*D,this._z=x*T*D+L*I*M,this._w=x*T*M-L*I*D;break;case"ZYX":this._x=L*T*M-x*I*D,this._y=x*I*M+L*T*D,this._z=x*T*D-L*I*M,this._w=x*T*M+L*I*D;break;case"YZX":this._x=L*T*M+x*I*D,this._y=x*I*M+L*T*D,this._z=x*T*D-L*I*M,this._w=x*T*M-L*I*D;break;case"XZY":this._x=L*T*M-x*I*D,this._y=x*I*M-L*T*D,this._z=x*T*D+L*I*M,this._w=x*T*M+L*I*D;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+b)}return r===!0&&this._onChangeCallback(),this}setFromAxisAngle(n,r){let c=r/2,u=Math.sin(c);return this._x=n.x*u,this._y=n.y*u,this._z=n.z*u,this._w=Math.cos(c),this._onChangeCallback(),this}setFromRotationMatrix(n){let r=n.elements,c=r[0],u=r[4],d=r[8],b=r[1],w=r[5],_=r[9],x=r[2],T=r[6],M=r[10],L=c+w+M;if(L>0){let I=.5/Math.sqrt(L+1);this._w=.25/I,this._x=(T-_)*I,this._y=(d-x)*I,this._z=(b-u)*I}else if(c>w&&c>M){let I=2*Math.sqrt(1+c-w-M);this._w=(T-_)/I,this._x=.25*I,this._y=(u+b)/I,this._z=(d+x)/I}else if(w>M){let I=2*Math.sqrt(1+w-c-M);this._w=(d-x)/I,this._x=(u+b)/I,this._y=.25*I,this._z=(_+T)/I}else{let I=2*Math.sqrt(1+M-c-w);this._w=(b-u)/I,this._x=(d+x)/I,this._y=(_+T)/I,this._z=.25*I}return this._onChangeCallback(),this}setFromUnitVectors(n,r){let c=n.dot(r)+1;return cMath.abs(n.z)?(this._x=-n.y,this._y=n.x,this._z=0,this._w=c):(this._x=0,this._y=-n.z,this._z=n.y,this._w=c)):(this._x=n.y*r.z-n.z*r.y,this._y=n.z*r.x-n.x*r.z,this._z=n.x*r.y-n.y*r.x,this._w=c),this.normalize()}angleTo(n){return 2*Math.acos(Math.abs(Sm(this.dot(n),-1,1)))}rotateTowards(n,r){let c=this.angleTo(n);if(c===0)return this;let u=Math.min(1,r/c);return this.slerp(n,u),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(n){return this._x*n._x+this._y*n._y+this._z*n._z+this._w*n._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let n=this.length();return n===0?(this._x=0,this._y=0,this._z=0,this._w=1):(n=1/n,this._x=this._x*n,this._y=this._y*n,this._z=this._z*n,this._w=this._w*n),this._onChangeCallback(),this}multiply(n){return this.multiplyQuaternions(this,n)}premultiply(n){return this.multiplyQuaternions(n,this)}multiplyQuaternions(n,r){let c=n._x,u=n._y,d=n._z,b=n._w,w=r._x,_=r._y,x=r._z,T=r._w;return this._x=c*T+b*w+u*x-d*_,this._y=u*T+b*_+d*w-c*x,this._z=d*T+b*x+c*_-u*w,this._w=b*T-c*w-u*_-d*x,this._onChangeCallback(),this}slerp(n,r){if(r===0)return this;if(r===1)return this.copy(n);let c=this._x,u=this._y,d=this._z,b=this._w,w=b*n._w+c*n._x+u*n._y+d*n._z;if(w<0?(this._w=-n._w,this._x=-n._x,this._y=-n._y,this._z=-n._z,w=-w):this.copy(n),w>=1)return this._w=b,this._x=c,this._y=u,this._z=d,this;let _=1-w*w;if(_<=Number.EPSILON){let I=1-r;return this._w=I*b+r*this._w,this._x=I*c+r*this._x,this._y=I*u+r*this._y,this._z=I*d+r*this._z,this.normalize(),this}let x=Math.sqrt(_),T=Math.atan2(x,w),M=Math.sin((1-r)*T)/x,L=Math.sin(r*T)/x;return this._w=b*M+this._w*L,this._x=c*M+this._x*L,this._y=u*M+this._y*L,this._z=d*M+this._z*L,this._onChangeCallback(),this}slerpQuaternions(n,r,c){return this.copy(n).slerp(r,c)}random(){let n=Math.random(),r=Math.sqrt(1-n),c=Math.sqrt(n),u=2*Math.PI*Math.random(),d=2*Math.PI*Math.random();return this.set(r*Math.cos(u),c*Math.sin(d),c*Math.cos(d),r*Math.sin(u))}equals(n){return n._x===this._x&&n._y===this._y&&n._z===this._z&&n._w===this._w}fromArray(n,r=0){return this._x=n[r],this._y=n[r+1],this._z=n[r+2],this._w=n[r+3],this._onChangeCallback(),this}toArray(n=[],r=0){return n[r]=this._x,n[r+1]=this._y,n[r+2]=this._z,n[r+3]=this._w,n}fromBufferAttribute(n,r){return this._x=n.getX(r),this._y=n.getY(r),this._z=n.getZ(r),this._w=n.getW(r),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(n){return this._onChangeCallback=n,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},Gt=class s{constructor(n=0,r=0,c=0){s.prototype.isVector3=!0,this.x=n,this.y=r,this.z=c}set(n,r,c){return c===void 0&&(c=this.z),this.x=n,this.y=r,this.z=c,this}setScalar(n){return this.x=n,this.y=n,this.z=n,this}setX(n){return this.x=n,this}setY(n){return this.y=n,this}setZ(n){return this.z=n,this}setComponent(n,r){switch(n){case 0:this.x=r;break;case 1:this.y=r;break;case 2:this.z=r;break;default:throw new Error("index is out of range: "+n)}return this}getComponent(n){switch(n){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+n)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(n){return this.x=n.x,this.y=n.y,this.z=n.z,this}add(n){return this.x+=n.x,this.y+=n.y,this.z+=n.z,this}addScalar(n){return this.x+=n,this.y+=n,this.z+=n,this}addVectors(n,r){return this.x=n.x+r.x,this.y=n.y+r.y,this.z=n.z+r.z,this}addScaledVector(n,r){return this.x+=n.x*r,this.y+=n.y*r,this.z+=n.z*r,this}sub(n){return this.x-=n.x,this.y-=n.y,this.z-=n.z,this}subScalar(n){return this.x-=n,this.y-=n,this.z-=n,this}subVectors(n,r){return this.x=n.x-r.x,this.y=n.y-r.y,this.z=n.z-r.z,this}multiply(n){return this.x*=n.x,this.y*=n.y,this.z*=n.z,this}multiplyScalar(n){return this.x*=n,this.y*=n,this.z*=n,this}multiplyVectors(n,r){return this.x=n.x*r.x,this.y=n.y*r.y,this.z=n.z*r.z,this}applyEuler(n){return this.applyQuaternion(Myt.setFromEuler(n))}applyAxisAngle(n,r){return this.applyQuaternion(Myt.setFromAxisAngle(n,r))}applyMatrix3(n){let r=this.x,c=this.y,u=this.z,d=n.elements;return this.x=d[0]*r+d[3]*c+d[6]*u,this.y=d[1]*r+d[4]*c+d[7]*u,this.z=d[2]*r+d[5]*c+d[8]*u,this}applyNormalMatrix(n){return this.applyMatrix3(n).normalize()}applyMatrix4(n){let r=this.x,c=this.y,u=this.z,d=n.elements,b=1/(d[3]*r+d[7]*c+d[11]*u+d[15]);return this.x=(d[0]*r+d[4]*c+d[8]*u+d[12])*b,this.y=(d[1]*r+d[5]*c+d[9]*u+d[13])*b,this.z=(d[2]*r+d[6]*c+d[10]*u+d[14])*b,this}applyQuaternion(n){let r=this.x,c=this.y,u=this.z,d=n.x,b=n.y,w=n.z,_=n.w,x=2*(b*u-w*c),T=2*(w*r-d*u),M=2*(d*c-b*r);return this.x=r+_*x+b*M-w*T,this.y=c+_*T+w*x-d*M,this.z=u+_*M+d*T-b*x,this}project(n){return this.applyMatrix4(n.matrixWorldInverse).applyMatrix4(n.projectionMatrix)}unproject(n){return this.applyMatrix4(n.projectionMatrixInverse).applyMatrix4(n.matrixWorld)}transformDirection(n){let r=this.x,c=this.y,u=this.z,d=n.elements;return this.x=d[0]*r+d[4]*c+d[8]*u,this.y=d[1]*r+d[5]*c+d[9]*u,this.z=d[2]*r+d[6]*c+d[10]*u,this.normalize()}divide(n){return this.x/=n.x,this.y/=n.y,this.z/=n.z,this}divideScalar(n){return this.multiplyScalar(1/n)}min(n){return this.x=Math.min(this.x,n.x),this.y=Math.min(this.y,n.y),this.z=Math.min(this.z,n.z),this}max(n){return this.x=Math.max(this.x,n.x),this.y=Math.max(this.y,n.y),this.z=Math.max(this.z,n.z),this}clamp(n,r){return this.x=Math.max(n.x,Math.min(r.x,this.x)),this.y=Math.max(n.y,Math.min(r.y,this.y)),this.z=Math.max(n.z,Math.min(r.z,this.z)),this}clampScalar(n,r){return this.x=Math.max(n,Math.min(r,this.x)),this.y=Math.max(n,Math.min(r,this.y)),this.z=Math.max(n,Math.min(r,this.z)),this}clampLength(n,r){let c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(n,Math.min(r,c)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(n){return this.x*n.x+this.y*n.y+this.z*n.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(n){return this.normalize().multiplyScalar(n)}lerp(n,r){return this.x+=(n.x-this.x)*r,this.y+=(n.y-this.y)*r,this.z+=(n.z-this.z)*r,this}lerpVectors(n,r,c){return this.x=n.x+(r.x-n.x)*c,this.y=n.y+(r.y-n.y)*c,this.z=n.z+(r.z-n.z)*c,this}cross(n){return this.crossVectors(this,n)}crossVectors(n,r){let c=n.x,u=n.y,d=n.z,b=r.x,w=r.y,_=r.z;return this.x=u*_-d*w,this.y=d*b-c*_,this.z=c*w-u*b,this}projectOnVector(n){let r=n.lengthSq();if(r===0)return this.set(0,0,0);let c=n.dot(this)/r;return this.copy(n).multiplyScalar(c)}projectOnPlane(n){return e6e.copy(this).projectOnVector(n),this.sub(e6e)}reflect(n){return this.sub(e6e.copy(n).multiplyScalar(2*this.dot(n)))}angleTo(n){let r=Math.sqrt(this.lengthSq()*n.lengthSq());if(r===0)return Math.PI/2;let c=this.dot(n)/r;return Math.acos(Sm(c,-1,1))}distanceTo(n){return Math.sqrt(this.distanceToSquared(n))}distanceToSquared(n){let r=this.x-n.x,c=this.y-n.y,u=this.z-n.z;return r*r+c*c+u*u}manhattanDistanceTo(n){return Math.abs(this.x-n.x)+Math.abs(this.y-n.y)+Math.abs(this.z-n.z)}setFromSpherical(n){return this.setFromSphericalCoords(n.radius,n.phi,n.theta)}setFromSphericalCoords(n,r,c){let u=Math.sin(r)*n;return this.x=u*Math.sin(c),this.y=Math.cos(r)*n,this.z=u*Math.cos(c),this}setFromCylindrical(n){return this.setFromCylindricalCoords(n.radius,n.theta,n.y)}setFromCylindricalCoords(n,r,c){return this.x=n*Math.sin(r),this.y=c,this.z=n*Math.cos(r),this}setFromMatrixPosition(n){let r=n.elements;return this.x=r[12],this.y=r[13],this.z=r[14],this}setFromMatrixScale(n){let r=this.setFromMatrixColumn(n,0).length(),c=this.setFromMatrixColumn(n,1).length(),u=this.setFromMatrixColumn(n,2).length();return this.x=r,this.y=c,this.z=u,this}setFromMatrixColumn(n,r){return this.fromArray(n.elements,r*4)}setFromMatrix3Column(n,r){return this.fromArray(n.elements,r*3)}setFromEuler(n){return this.x=n._x,this.y=n._y,this.z=n._z,this}setFromColor(n){return this.x=n.r,this.y=n.g,this.z=n.b,this}equals(n){return n.x===this.x&&n.y===this.y&&n.z===this.z}fromArray(n,r=0){return this.x=n[r],this.y=n[r+1],this.z=n[r+2],this}toArray(n=[],r=0){return n[r]=this.x,n[r+1]=this.y,n[r+2]=this.z,n}fromBufferAttribute(n,r){return this.x=n.getX(r),this.y=n.getY(r),this.z=n.getZ(r),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let n=(Math.random()-.5)*2,r=Math.random()*Math.PI*2,c=Math.sqrt(1-n**2);return this.x=c*Math.cos(r),this.y=c*Math.sin(r),this.z=n,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},e6e=new Gt,Myt=new h2,K3=class{constructor(n=new Gt(1/0,1/0,1/0),r=new Gt(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=n,this.max=r}set(n,r){return this.min.copy(n),this.max.copy(r),this}setFromArray(n){this.makeEmpty();for(let r=0,c=n.length;rthis.max.x||n.ythis.max.y||n.zthis.max.z)}containsBox(n){return this.min.x<=n.min.x&&n.max.x<=this.max.x&&this.min.y<=n.min.y&&n.max.y<=this.max.y&&this.min.z<=n.min.z&&n.max.z<=this.max.z}getParameter(n,r){return r.set((n.x-this.min.x)/(this.max.x-this.min.x),(n.y-this.min.y)/(this.max.y-this.min.y),(n.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(n){return!(n.max.xthis.max.x||n.max.ythis.max.y||n.max.zthis.max.z)}intersectsSphere(n){return this.clampPoint(n.center,xv),xv.distanceToSquared(n.center)<=n.radius*n.radius}intersectsPlane(n){let r,c;return n.normal.x>0?(r=n.normal.x*this.min.x,c=n.normal.x*this.max.x):(r=n.normal.x*this.max.x,c=n.normal.x*this.min.x),n.normal.y>0?(r+=n.normal.y*this.min.y,c+=n.normal.y*this.max.y):(r+=n.normal.y*this.max.y,c+=n.normal.y*this.min.y),n.normal.z>0?(r+=n.normal.z*this.min.z,c+=n.normal.z*this.max.z):(r+=n.normal.z*this.max.z,c+=n.normal.z*this.min.z),r<=-n.constant&&c>=-n.constant}intersectsTriangle(n){if(this.isEmpty())return!1;this.getCenter(TW),gfe.subVectors(this.max,TW),$B.subVectors(n.a,TW),VB.subVectors(n.b,TW),WB.subVectors(n.c,TW),oT.subVectors(VB,$B),aT.subVectors(WB,VB),N4.subVectors($B,WB);let r=[0,-oT.z,oT.y,0,-aT.z,aT.y,0,-N4.z,N4.y,oT.z,0,-oT.x,aT.z,0,-aT.x,N4.z,0,-N4.x,-oT.y,oT.x,0,-aT.y,aT.x,0,-N4.y,N4.x,0];return!t6e(r,$B,VB,WB,gfe)||(r=[1,0,0,0,1,0,0,0,1],!t6e(r,$B,VB,WB,gfe))?!1:(mfe.crossVectors(oT,aT),r=[mfe.x,mfe.y,mfe.z],t6e(r,$B,VB,WB,gfe))}clampPoint(n,r){return r.copy(n).clamp(this.min,this.max)}distanceToPoint(n){return this.clampPoint(n,xv).distanceTo(n)}getBoundingSphere(n){return this.isEmpty()?n.makeEmpty():(this.getCenter(n.center),n.radius=this.getSize(xv).length()*.5),n}intersect(n){return this.min.max(n.min),this.max.min(n.max),this.isEmpty()&&this.makeEmpty(),this}union(n){return this.min.min(n.min),this.max.max(n.max),this}applyMatrix4(n){return this.isEmpty()?this:(G3[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(n),G3[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(n),G3[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(n),G3[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(n),G3[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(n),G3[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(n),G3[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(n),G3[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(n),this.setFromPoints(G3),this)}translate(n){return this.min.add(n),this.max.add(n),this}equals(n){return n.min.equals(this.min)&&n.max.equals(this.max)}},G3=[new Gt,new Gt,new Gt,new Gt,new Gt,new Gt,new Gt,new Gt],xv=new Gt,pfe=new K3,$B=new Gt,VB=new Gt,WB=new Gt,oT=new Gt,aT=new Gt,N4=new Gt,TW=new Gt,gfe=new Gt,mfe=new Gt,F4=new Gt;function t6e(s,n,r,c,u){for(let d=0,b=s.length-3;d<=b;d+=3){F4.fromArray(s,d);let w=u.x*Math.abs(F4.x)+u.y*Math.abs(F4.y)+u.z*Math.abs(F4.z),_=n.dot(F4),x=r.dot(F4),T=c.dot(F4);if(Math.max(-Math.max(_,x,T),Math.min(_,x,T))>w)return!1}return!0}var dan=new K3,CW=new Gt,n6e=new Gt,vT=class{constructor(n=new Gt,r=-1){this.isSphere=!0,this.center=n,this.radius=r}set(n,r){return this.center.copy(n),this.radius=r,this}setFromPoints(n,r){let c=this.center;r!==void 0?c.copy(r):dan.setFromPoints(n).getCenter(c);let u=0;for(let d=0,b=n.length;dthis.radius*this.radius&&(r.sub(this.center).normalize(),r.multiplyScalar(this.radius).add(this.center)),r}getBoundingBox(n){return this.isEmpty()?(n.makeEmpty(),n):(n.set(this.center,this.center),n.expandByScalar(this.radius),n)}applyMatrix4(n){return this.center.applyMatrix4(n),this.radius=this.radius*n.getMaxScaleOnAxis(),this}translate(n){return this.center.add(n),this}expandByPoint(n){if(this.isEmpty())return this.center.copy(n),this.radius=0,this;CW.subVectors(n,this.center);let r=CW.lengthSq();if(r>this.radius*this.radius){let c=Math.sqrt(r),u=(c-this.radius)*.5;this.center.addScaledVector(CW,u/c),this.radius+=u}return this}union(n){return n.isEmpty()?this:this.isEmpty()?(this.copy(n),this):(this.center.equals(n.center)===!0?this.radius=Math.max(this.radius,n.radius):(n6e.subVectors(n.center,this.center).setLength(n.radius),this.expandByPoint(CW.copy(n.center).add(n6e)),this.expandByPoint(CW.copy(n.center).sub(n6e))),this)}equals(n){return n.center.equals(this.center)&&n.radius===this.radius}clone(){return new this.constructor().copy(this)}},j3=new Gt,i6e=new Gt,bfe=new Gt,cT=new Gt,r6e=new Gt,wfe=new Gt,s6e=new Gt,OW=class{constructor(n=new Gt,r=new Gt(0,0,-1)){this.origin=n,this.direction=r}set(n,r){return this.origin.copy(n),this.direction.copy(r),this}copy(n){return this.origin.copy(n.origin),this.direction.copy(n.direction),this}at(n,r){return r.copy(this.origin).addScaledVector(this.direction,n)}lookAt(n){return this.direction.copy(n).sub(this.origin).normalize(),this}recast(n){return this.origin.copy(this.at(n,j3)),this}closestPointToPoint(n,r){r.subVectors(n,this.origin);let c=r.dot(this.direction);return c<0?r.copy(this.origin):r.copy(this.origin).addScaledVector(this.direction,c)}distanceToPoint(n){return Math.sqrt(this.distanceSqToPoint(n))}distanceSqToPoint(n){let r=j3.subVectors(n,this.origin).dot(this.direction);return r<0?this.origin.distanceToSquared(n):(j3.copy(this.origin).addScaledVector(this.direction,r),j3.distanceToSquared(n))}distanceSqToSegment(n,r,c,u){i6e.copy(n).add(r).multiplyScalar(.5),bfe.copy(r).sub(n).normalize(),cT.copy(this.origin).sub(i6e);let d=n.distanceTo(r)*.5,b=-this.direction.dot(bfe),w=cT.dot(this.direction),_=-cT.dot(bfe),x=cT.lengthSq(),T=Math.abs(1-b*b),M,L,I,D;if(T>0)if(M=b*_-w,L=b*w-_,D=d*T,M>=0)if(L>=-D)if(L<=D){let F=1/T;M*=F,L*=F,I=M*(M+b*L+2*w)+L*(b*M+L+2*_)+x}else L=d,M=Math.max(0,-(b*L+w)),I=-M*M+L*(L+2*_)+x;else L=-d,M=Math.max(0,-(b*L+w)),I=-M*M+L*(L+2*_)+x;else L<=-D?(M=Math.max(0,-(-b*d+w)),L=M>0?-d:Math.min(Math.max(-d,-_),d),I=-M*M+L*(L+2*_)+x):L<=D?(M=0,L=Math.min(Math.max(-d,-_),d),I=L*(L+2*_)+x):(M=Math.max(0,-(b*d+w)),L=M>0?d:Math.min(Math.max(-d,-_),d),I=-M*M+L*(L+2*_)+x);else L=b>0?-d:d,M=Math.max(0,-(b*L+w)),I=-M*M+L*(L+2*_)+x;return c&&c.copy(this.origin).addScaledVector(this.direction,M),u&&u.copy(i6e).addScaledVector(bfe,L),I}intersectSphere(n,r){j3.subVectors(n.center,this.origin);let c=j3.dot(this.direction),u=j3.dot(j3)-c*c,d=n.radius*n.radius;if(u>d)return null;let b=Math.sqrt(d-u),w=c-b,_=c+b;return _<0?null:w<0?this.at(_,r):this.at(w,r)}intersectsSphere(n){return this.distanceSqToPoint(n.center)<=n.radius*n.radius}distanceToPlane(n){let r=n.normal.dot(this.direction);if(r===0)return n.distanceToPoint(this.origin)===0?0:null;let c=-(this.origin.dot(n.normal)+n.constant)/r;return c>=0?c:null}intersectPlane(n,r){let c=this.distanceToPlane(n);return c===null?null:this.at(c,r)}intersectsPlane(n){let r=n.distanceToPoint(this.origin);return r===0||n.normal.dot(this.direction)*r<0}intersectBox(n,r){let c,u,d,b,w,_,x=1/this.direction.x,T=1/this.direction.y,M=1/this.direction.z,L=this.origin;return x>=0?(c=(n.min.x-L.x)*x,u=(n.max.x-L.x)*x):(c=(n.max.x-L.x)*x,u=(n.min.x-L.x)*x),T>=0?(d=(n.min.y-L.y)*T,b=(n.max.y-L.y)*T):(d=(n.max.y-L.y)*T,b=(n.min.y-L.y)*T),c>b||d>u||((d>c||isNaN(c))&&(c=d),(b=0?(w=(n.min.z-L.z)*M,_=(n.max.z-L.z)*M):(w=(n.max.z-L.z)*M,_=(n.min.z-L.z)*M),c>_||w>u)||((w>c||c!==c)&&(c=w),(_=0?c:u,r)}intersectsBox(n){return this.intersectBox(n,j3)!==null}intersectTriangle(n,r,c,u,d){r6e.subVectors(r,n),wfe.subVectors(c,n),s6e.crossVectors(r6e,wfe);let b=this.direction.dot(s6e),w;if(b>0){if(u)return null;w=1}else if(b<0)w=-1,b=-b;else return null;cT.subVectors(this.origin,n);let _=w*this.direction.dot(wfe.crossVectors(cT,wfe));if(_<0)return null;let x=w*this.direction.dot(r6e.cross(cT));if(x<0||_+x>b)return null;let T=-w*cT.dot(s6e);return T<0?null:this.at(T/b,d)}applyMatrix4(n){return this.origin.applyMatrix4(n),this.direction.transformDirection(n),this}equals(n){return n.origin.equals(this.origin)&&n.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Il=class s{constructor(n,r,c,u,d,b,w,_,x,T,M,L,I,D,F,O){s.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],n!==void 0&&this.set(n,r,c,u,d,b,w,_,x,T,M,L,I,D,F,O)}set(n,r,c,u,d,b,w,_,x,T,M,L,I,D,F,O){let z=this.elements;return z[0]=n,z[4]=r,z[8]=c,z[12]=u,z[1]=d,z[5]=b,z[9]=w,z[13]=_,z[2]=x,z[6]=T,z[10]=M,z[14]=L,z[3]=I,z[7]=D,z[11]=F,z[15]=O,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new s().fromArray(this.elements)}copy(n){let r=this.elements,c=n.elements;return r[0]=c[0],r[1]=c[1],r[2]=c[2],r[3]=c[3],r[4]=c[4],r[5]=c[5],r[6]=c[6],r[7]=c[7],r[8]=c[8],r[9]=c[9],r[10]=c[10],r[11]=c[11],r[12]=c[12],r[13]=c[13],r[14]=c[14],r[15]=c[15],this}copyPosition(n){let r=this.elements,c=n.elements;return r[12]=c[12],r[13]=c[13],r[14]=c[14],this}setFromMatrix3(n){let r=n.elements;return this.set(r[0],r[3],r[6],0,r[1],r[4],r[7],0,r[2],r[5],r[8],0,0,0,0,1),this}extractBasis(n,r,c){return n.setFromMatrixColumn(this,0),r.setFromMatrixColumn(this,1),c.setFromMatrixColumn(this,2),this}makeBasis(n,r,c){return this.set(n.x,r.x,c.x,0,n.y,r.y,c.y,0,n.z,r.z,c.z,0,0,0,0,1),this}extractRotation(n){let r=this.elements,c=n.elements,u=1/HB.setFromMatrixColumn(n,0).length(),d=1/HB.setFromMatrixColumn(n,1).length(),b=1/HB.setFromMatrixColumn(n,2).length();return r[0]=c[0]*u,r[1]=c[1]*u,r[2]=c[2]*u,r[3]=0,r[4]=c[4]*d,r[5]=c[5]*d,r[6]=c[6]*d,r[7]=0,r[8]=c[8]*b,r[9]=c[9]*b,r[10]=c[10]*b,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,this}makeRotationFromEuler(n){let r=this.elements,c=n.x,u=n.y,d=n.z,b=Math.cos(c),w=Math.sin(c),_=Math.cos(u),x=Math.sin(u),T=Math.cos(d),M=Math.sin(d);if(n.order==="XYZ"){let L=b*T,I=b*M,D=w*T,F=w*M;r[0]=_*T,r[4]=-_*M,r[8]=x,r[1]=I+D*x,r[5]=L-F*x,r[9]=-w*_,r[2]=F-L*x,r[6]=D+I*x,r[10]=b*_}else if(n.order==="YXZ"){let L=_*T,I=_*M,D=x*T,F=x*M;r[0]=L+F*w,r[4]=D*w-I,r[8]=b*x,r[1]=b*M,r[5]=b*T,r[9]=-w,r[2]=I*w-D,r[6]=F+L*w,r[10]=b*_}else if(n.order==="ZXY"){let L=_*T,I=_*M,D=x*T,F=x*M;r[0]=L-F*w,r[4]=-b*M,r[8]=D+I*w,r[1]=I+D*w,r[5]=b*T,r[9]=F-L*w,r[2]=-b*x,r[6]=w,r[10]=b*_}else if(n.order==="ZYX"){let L=b*T,I=b*M,D=w*T,F=w*M;r[0]=_*T,r[4]=D*x-I,r[8]=L*x+F,r[1]=_*M,r[5]=F*x+L,r[9]=I*x-D,r[2]=-x,r[6]=w*_,r[10]=b*_}else if(n.order==="YZX"){let L=b*_,I=b*x,D=w*_,F=w*x;r[0]=_*T,r[4]=F-L*M,r[8]=D*M+I,r[1]=M,r[5]=b*T,r[9]=-w*T,r[2]=-x*T,r[6]=I*M+D,r[10]=L-F*M}else if(n.order==="XZY"){let L=b*_,I=b*x,D=w*_,F=w*x;r[0]=_*T,r[4]=-M,r[8]=x*T,r[1]=L*M+F,r[5]=b*T,r[9]=I*M-D,r[2]=D*M-I,r[6]=w*T,r[10]=F*M+L}return r[3]=0,r[7]=0,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,this}makeRotationFromQuaternion(n){return this.compose(pan,n,gan)}lookAt(n,r,c){let u=this.elements;return W1.subVectors(n,r),W1.lengthSq()===0&&(W1.z=1),W1.normalize(),lT.crossVectors(c,W1),lT.lengthSq()===0&&(Math.abs(c.z)===1?W1.x+=1e-4:W1.z+=1e-4,W1.normalize(),lT.crossVectors(c,W1)),lT.normalize(),vfe.crossVectors(W1,lT),u[0]=lT.x,u[4]=vfe.x,u[8]=W1.x,u[1]=lT.y,u[5]=vfe.y,u[9]=W1.y,u[2]=lT.z,u[6]=vfe.z,u[10]=W1.z,this}multiply(n){return this.multiplyMatrices(this,n)}premultiply(n){return this.multiplyMatrices(n,this)}multiplyMatrices(n,r){let c=n.elements,u=r.elements,d=this.elements,b=c[0],w=c[4],_=c[8],x=c[12],T=c[1],M=c[5],L=c[9],I=c[13],D=c[2],F=c[6],O=c[10],z=c[14],Z=c[3],H=c[7],te=c[11],oe=c[15],ne=u[0],ue=u[4],Te=u[8],Q=u[12],ge=u[1],Qe=u[5],st=u[9],at=u[13],Ne=u[2],tt=u[6],ot=u[10],Tt=u[14],jt=u[3],en=u[7],mn=u[11],cn=u[15];return d[0]=b*ne+w*ge+_*Ne+x*jt,d[4]=b*ue+w*Qe+_*tt+x*en,d[8]=b*Te+w*st+_*ot+x*mn,d[12]=b*Q+w*at+_*Tt+x*cn,d[1]=T*ne+M*ge+L*Ne+I*jt,d[5]=T*ue+M*Qe+L*tt+I*en,d[9]=T*Te+M*st+L*ot+I*mn,d[13]=T*Q+M*at+L*Tt+I*cn,d[2]=D*ne+F*ge+O*Ne+z*jt,d[6]=D*ue+F*Qe+O*tt+z*en,d[10]=D*Te+F*st+O*ot+z*mn,d[14]=D*Q+F*at+O*Tt+z*cn,d[3]=Z*ne+H*ge+te*Ne+oe*jt,d[7]=Z*ue+H*Qe+te*tt+oe*en,d[11]=Z*Te+H*st+te*ot+oe*mn,d[15]=Z*Q+H*at+te*Tt+oe*cn,this}multiplyScalar(n){let r=this.elements;return r[0]*=n,r[4]*=n,r[8]*=n,r[12]*=n,r[1]*=n,r[5]*=n,r[9]*=n,r[13]*=n,r[2]*=n,r[6]*=n,r[10]*=n,r[14]*=n,r[3]*=n,r[7]*=n,r[11]*=n,r[15]*=n,this}determinant(){let n=this.elements,r=n[0],c=n[4],u=n[8],d=n[12],b=n[1],w=n[5],_=n[9],x=n[13],T=n[2],M=n[6],L=n[10],I=n[14],D=n[3],F=n[7],O=n[11],z=n[15];return D*(+d*_*M-u*x*M-d*w*L+c*x*L+u*w*I-c*_*I)+F*(+r*_*I-r*x*L+d*b*L-u*b*I+u*x*T-d*_*T)+O*(+r*x*M-r*w*I-d*b*M+c*b*I+d*w*T-c*x*T)+z*(-u*w*T-r*_*M+r*w*L+u*b*M-c*b*L+c*_*T)}transpose(){let n=this.elements,r;return r=n[1],n[1]=n[4],n[4]=r,r=n[2],n[2]=n[8],n[8]=r,r=n[6],n[6]=n[9],n[9]=r,r=n[3],n[3]=n[12],n[12]=r,r=n[7],n[7]=n[13],n[13]=r,r=n[11],n[11]=n[14],n[14]=r,this}setPosition(n,r,c){let u=this.elements;return n.isVector3?(u[12]=n.x,u[13]=n.y,u[14]=n.z):(u[12]=n,u[13]=r,u[14]=c),this}invert(){let n=this.elements,r=n[0],c=n[1],u=n[2],d=n[3],b=n[4],w=n[5],_=n[6],x=n[7],T=n[8],M=n[9],L=n[10],I=n[11],D=n[12],F=n[13],O=n[14],z=n[15],Z=M*O*x-F*L*x+F*_*I-w*O*I-M*_*z+w*L*z,H=D*L*x-T*O*x-D*_*I+b*O*I+T*_*z-b*L*z,te=T*F*x-D*M*x+D*w*I-b*F*I-T*w*z+b*M*z,oe=D*M*_-T*F*_-D*w*L+b*F*L+T*w*O-b*M*O,ne=r*Z+c*H+u*te+d*oe;if(ne===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let ue=1/ne;return n[0]=Z*ue,n[1]=(F*L*d-M*O*d-F*u*I+c*O*I+M*u*z-c*L*z)*ue,n[2]=(w*O*d-F*_*d+F*u*x-c*O*x-w*u*z+c*_*z)*ue,n[3]=(M*_*d-w*L*d-M*u*x+c*L*x+w*u*I-c*_*I)*ue,n[4]=H*ue,n[5]=(T*O*d-D*L*d+D*u*I-r*O*I-T*u*z+r*L*z)*ue,n[6]=(D*_*d-b*O*d-D*u*x+r*O*x+b*u*z-r*_*z)*ue,n[7]=(b*L*d-T*_*d+T*u*x-r*L*x-b*u*I+r*_*I)*ue,n[8]=te*ue,n[9]=(D*M*d-T*F*d-D*c*I+r*F*I+T*c*z-r*M*z)*ue,n[10]=(b*F*d-D*w*d+D*c*x-r*F*x-b*c*z+r*w*z)*ue,n[11]=(T*w*d-b*M*d-T*c*x+r*M*x+b*c*I-r*w*I)*ue,n[12]=oe*ue,n[13]=(T*F*u-D*M*u+D*c*L-r*F*L-T*c*O+r*M*O)*ue,n[14]=(D*w*u-b*F*u-D*c*_+r*F*_+b*c*O-r*w*O)*ue,n[15]=(b*M*u-T*w*u+T*c*_-r*M*_-b*c*L+r*w*L)*ue,this}scale(n){let r=this.elements,c=n.x,u=n.y,d=n.z;return r[0]*=c,r[4]*=u,r[8]*=d,r[1]*=c,r[5]*=u,r[9]*=d,r[2]*=c,r[6]*=u,r[10]*=d,r[3]*=c,r[7]*=u,r[11]*=d,this}getMaxScaleOnAxis(){let n=this.elements,r=n[0]*n[0]+n[1]*n[1]+n[2]*n[2],c=n[4]*n[4]+n[5]*n[5]+n[6]*n[6],u=n[8]*n[8]+n[9]*n[9]+n[10]*n[10];return Math.sqrt(Math.max(r,c,u))}makeTranslation(n,r,c){return n.isVector3?this.set(1,0,0,n.x,0,1,0,n.y,0,0,1,n.z,0,0,0,1):this.set(1,0,0,n,0,1,0,r,0,0,1,c,0,0,0,1),this}makeRotationX(n){let r=Math.cos(n),c=Math.sin(n);return this.set(1,0,0,0,0,r,-c,0,0,c,r,0,0,0,0,1),this}makeRotationY(n){let r=Math.cos(n),c=Math.sin(n);return this.set(r,0,c,0,0,1,0,0,-c,0,r,0,0,0,0,1),this}makeRotationZ(n){let r=Math.cos(n),c=Math.sin(n);return this.set(r,-c,0,0,c,r,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(n,r){let c=Math.cos(r),u=Math.sin(r),d=1-c,b=n.x,w=n.y,_=n.z,x=d*b,T=d*w;return this.set(x*b+c,x*w-u*_,x*_+u*w,0,x*w+u*_,T*w+c,T*_-u*b,0,x*_-u*w,T*_+u*b,d*_*_+c,0,0,0,0,1),this}makeScale(n,r,c){return this.set(n,0,0,0,0,r,0,0,0,0,c,0,0,0,0,1),this}makeShear(n,r,c,u,d,b){return this.set(1,c,d,0,n,1,b,0,r,u,1,0,0,0,0,1),this}compose(n,r,c){let u=this.elements,d=r._x,b=r._y,w=r._z,_=r._w,x=d+d,T=b+b,M=w+w,L=d*x,I=d*T,D=d*M,F=b*T,O=b*M,z=w*M,Z=_*x,H=_*T,te=_*M,oe=c.x,ne=c.y,ue=c.z;return u[0]=(1-(F+z))*oe,u[1]=(I+te)*oe,u[2]=(D-H)*oe,u[3]=0,u[4]=(I-te)*ne,u[5]=(1-(L+z))*ne,u[6]=(O+Z)*ne,u[7]=0,u[8]=(D+H)*ue,u[9]=(O-Z)*ue,u[10]=(1-(L+F))*ue,u[11]=0,u[12]=n.x,u[13]=n.y,u[14]=n.z,u[15]=1,this}decompose(n,r,c){let u=this.elements,d=HB.set(u[0],u[1],u[2]).length(),b=HB.set(u[4],u[5],u[6]).length(),w=HB.set(u[8],u[9],u[10]).length();this.determinant()<0&&(d=-d),n.x=u[12],n.y=u[13],n.z=u[14],Ev.copy(this);let x=1/d,T=1/b,M=1/w;return Ev.elements[0]*=x,Ev.elements[1]*=x,Ev.elements[2]*=x,Ev.elements[4]*=T,Ev.elements[5]*=T,Ev.elements[6]*=T,Ev.elements[8]*=M,Ev.elements[9]*=M,Ev.elements[10]*=M,r.setFromRotationMatrix(Ev),c.x=d,c.y=b,c.z=w,this}makePerspective(n,r,c,u,d,b,w=X3){let _=this.elements,x=2*d/(r-n),T=2*d/(c-u),M=(r+n)/(r-n),L=(c+u)/(c-u),I,D;if(w===X3)I=-(b+d)/(b-d),D=-2*b*d/(b-d);else if(w===Xfe)I=-b/(b-d),D=-b*d/(b-d);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+w);return _[0]=x,_[4]=0,_[8]=M,_[12]=0,_[1]=0,_[5]=T,_[9]=L,_[13]=0,_[2]=0,_[6]=0,_[10]=I,_[14]=D,_[3]=0,_[7]=0,_[11]=-1,_[15]=0,this}makeOrthographic(n,r,c,u,d,b,w=X3){let _=this.elements,x=1/(r-n),T=1/(c-u),M=1/(b-d),L=(r+n)*x,I=(c+u)*T,D,F;if(w===X3)D=(b+d)*M,F=-2*M;else if(w===Xfe)D=d*M,F=-1*M;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+w);return _[0]=2*x,_[4]=0,_[8]=0,_[12]=-L,_[1]=0,_[5]=2*T,_[9]=0,_[13]=-I,_[2]=0,_[6]=0,_[10]=F,_[14]=-D,_[3]=0,_[7]=0,_[11]=0,_[15]=1,this}equals(n){let r=this.elements,c=n.elements;for(let u=0;u<16;u++)if(r[u]!==c[u])return!1;return!0}fromArray(n,r=0){for(let c=0;c<16;c++)this.elements[c]=n[c+r];return this}toArray(n=[],r=0){let c=this.elements;return n[r]=c[0],n[r+1]=c[1],n[r+2]=c[2],n[r+3]=c[3],n[r+4]=c[4],n[r+5]=c[5],n[r+6]=c[6],n[r+7]=c[7],n[r+8]=c[8],n[r+9]=c[9],n[r+10]=c[10],n[r+11]=c[11],n[r+12]=c[12],n[r+13]=c[13],n[r+14]=c[14],n[r+15]=c[15],n}},HB=new Gt,Ev=new Il,pan=new Gt(0,0,0),gan=new Gt(1,1,1),lT=new Gt,vfe=new Gt,W1=new Gt,Tyt=new Il,Cyt=new h2,Qfe=class s{constructor(n=0,r=0,c=0,u=s.DEFAULT_ORDER){this.isEuler=!0,this._x=n,this._y=r,this._z=c,this._order=u}get x(){return this._x}set x(n){this._x=n,this._onChangeCallback()}get y(){return this._y}set y(n){this._y=n,this._onChangeCallback()}get z(){return this._z}set z(n){this._z=n,this._onChangeCallback()}get order(){return this._order}set order(n){this._order=n,this._onChangeCallback()}set(n,r,c,u=this._order){return this._x=n,this._y=r,this._z=c,this._order=u,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(n){return this._x=n._x,this._y=n._y,this._z=n._z,this._order=n._order,this._onChangeCallback(),this}setFromRotationMatrix(n,r=this._order,c=!0){let u=n.elements,d=u[0],b=u[4],w=u[8],_=u[1],x=u[5],T=u[9],M=u[2],L=u[6],I=u[10];switch(r){case"XYZ":this._y=Math.asin(Sm(w,-1,1)),Math.abs(w)<.9999999?(this._x=Math.atan2(-T,I),this._z=Math.atan2(-b,d)):(this._x=Math.atan2(L,x),this._z=0);break;case"YXZ":this._x=Math.asin(-Sm(T,-1,1)),Math.abs(T)<.9999999?(this._y=Math.atan2(w,I),this._z=Math.atan2(_,x)):(this._y=Math.atan2(-M,d),this._z=0);break;case"ZXY":this._x=Math.asin(Sm(L,-1,1)),Math.abs(L)<.9999999?(this._y=Math.atan2(-M,I),this._z=Math.atan2(-b,x)):(this._y=0,this._z=Math.atan2(_,d));break;case"ZYX":this._y=Math.asin(-Sm(M,-1,1)),Math.abs(M)<.9999999?(this._x=Math.atan2(L,I),this._z=Math.atan2(_,d)):(this._x=0,this._z=Math.atan2(-b,x));break;case"YZX":this._z=Math.asin(Sm(_,-1,1)),Math.abs(_)<.9999999?(this._x=Math.atan2(-T,x),this._y=Math.atan2(-M,d)):(this._x=0,this._y=Math.atan2(w,I));break;case"XZY":this._z=Math.asin(-Sm(b,-1,1)),Math.abs(b)<.9999999?(this._x=Math.atan2(L,x),this._y=Math.atan2(w,d)):(this._x=Math.atan2(-T,I),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+r)}return this._order=r,c===!0&&this._onChangeCallback(),this}setFromQuaternion(n,r,c){return Tyt.makeRotationFromQuaternion(n),this.setFromRotationMatrix(Tyt,r,c)}setFromVector3(n,r=this._order){return this.set(n.x,n.y,n.z,r)}reorder(n){return Cyt.setFromEuler(this),this.setFromQuaternion(Cyt,n)}equals(n){return n._x===this._x&&n._y===this._y&&n._z===this._z&&n._order===this._order}fromArray(n){return this._x=n[0],this._y=n[1],this._z=n[2],n[3]!==void 0&&(this._order=n[3]),this._onChangeCallback(),this}toArray(n=[],r=0){return n[r]=this._x,n[r+1]=this._y,n[r+2]=this._z,n[r+3]=this._order,n}_onChange(n){return this._onChangeCallback=n,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Qfe.DEFAULT_ORDER="XYZ";var NW=class{constructor(){this.mask=1}set(n){this.mask=(1<>>0}enable(n){this.mask|=1<1){for(let r=0;r1){for(let c=0;c0&&(u.userData=this.userData),u.layers=this.layers.mask,u.matrix=this.matrix.toArray(),u.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(u.matrixAutoUpdate=!1),this.isInstancedMesh&&(u.type="InstancedMesh",u.count=this.count,u.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(u.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(u.type="BatchedMesh",u.perObjectFrustumCulled=this.perObjectFrustumCulled,u.sortObjects=this.sortObjects,u.drawRanges=this._drawRanges,u.reservedRanges=this._reservedRanges,u.visibility=this._visibility,u.active=this._active,u.bounds=this._bounds.map(w=>({boxInitialized:w.boxInitialized,boxMin:w.box.min.toArray(),boxMax:w.box.max.toArray(),sphereInitialized:w.sphereInitialized,sphereRadius:w.sphere.radius,sphereCenter:w.sphere.center.toArray()})),u.maxGeometryCount=this._maxGeometryCount,u.maxVertexCount=this._maxVertexCount,u.maxIndexCount=this._maxIndexCount,u.geometryInitialized=this._geometryInitialized,u.geometryCount=this._geometryCount,u.matricesTexture=this._matricesTexture.toJSON(n),this.boundingSphere!==null&&(u.boundingSphere={center:u.boundingSphere.center.toArray(),radius:u.boundingSphere.radius}),this.boundingBox!==null&&(u.boundingBox={min:u.boundingBox.min.toArray(),max:u.boundingBox.max.toArray()}));function d(w,_){return w[_.uuid]===void 0&&(w[_.uuid]=_.toJSON(n)),_.uuid}if(this.isScene)this.background&&(this.background.isColor?u.background=this.background.toJSON():this.background.isTexture&&(u.background=this.background.toJSON(n).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(u.environment=this.environment.toJSON(n).uuid);else if(this.isMesh||this.isLine||this.isPoints){u.geometry=d(n.geometries,this.geometry);let w=this.geometry.parameters;if(w!==void 0&&w.shapes!==void 0){let _=w.shapes;if(Array.isArray(_))for(let x=0,T=_.length;x0){u.children=[];for(let w=0;w0){u.animations=[];for(let w=0;w0&&(c.geometries=w),_.length>0&&(c.materials=_),x.length>0&&(c.textures=x),T.length>0&&(c.images=T),M.length>0&&(c.shapes=M),L.length>0&&(c.skeletons=L),I.length>0&&(c.animations=I),D.length>0&&(c.nodes=D)}return c.object=u,c;function b(w){let _=[];for(let x in w){let T=w[x];delete T.metadata,_.push(T)}return _}}clone(n){return new this.constructor().copy(this,n)}copy(n,r=!0){if(this.name=n.name,this.up.copy(n.up),this.position.copy(n.position),this.rotation.order=n.rotation.order,this.quaternion.copy(n.quaternion),this.scale.copy(n.scale),this.matrix.copy(n.matrix),this.matrixWorld.copy(n.matrixWorld),this.matrixAutoUpdate=n.matrixAutoUpdate,this.matrixWorldAutoUpdate=n.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=n.matrixWorldNeedsUpdate,this.layers.mask=n.layers.mask,this.visible=n.visible,this.castShadow=n.castShadow,this.receiveShadow=n.receiveShadow,this.frustumCulled=n.frustumCulled,this.renderOrder=n.renderOrder,this.animations=n.animations.slice(),this.userData=JSON.parse(JSON.stringify(n.userData)),r===!0)for(let c=0;c0?u.multiplyScalar(1/Math.sqrt(d)):u.set(0,0,0)}static getBarycoord(n,r,c,u,d){Sv.subVectors(u,r),V3.subVectors(c,r),o6e.subVectors(n,r);let b=Sv.dot(Sv),w=Sv.dot(V3),_=Sv.dot(o6e),x=V3.dot(V3),T=V3.dot(o6e),M=b*x-w*w;if(M===0)return d.set(0,0,0),null;let L=1/M,I=(x*_-w*T)*L,D=(b*T-w*_)*L;return d.set(1-I-D,D,I)}static containsPoint(n,r,c,u){return this.getBarycoord(n,r,c,u,W3)===null?!1:W3.x>=0&&W3.y>=0&&W3.x+W3.y<=1}static getUV(n,r,c,u,d,b,w,_){return yfe===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),yfe=!0),this.getInterpolation(n,r,c,u,d,b,w,_)}static getInterpolation(n,r,c,u,d,b,w,_){return this.getBarycoord(n,r,c,u,W3)===null?(_.x=0,_.y=0,"z"in _&&(_.z=0),"w"in _&&(_.w=0),null):(_.setScalar(0),_.addScaledVector(d,W3.x),_.addScaledVector(b,W3.y),_.addScaledVector(w,W3.z),_)}static isFrontFacing(n,r,c,u){return Sv.subVectors(c,r),V3.subVectors(n,r),Sv.cross(V3).dot(u)<0}set(n,r,c){return this.a.copy(n),this.b.copy(r),this.c.copy(c),this}setFromPointsAndIndices(n,r,c,u){return this.a.copy(n[r]),this.b.copy(n[c]),this.c.copy(n[u]),this}setFromAttributeAndIndices(n,r,c,u){return this.a.fromBufferAttribute(n,r),this.b.fromBufferAttribute(n,c),this.c.fromBufferAttribute(n,u),this}clone(){return new this.constructor().copy(this)}copy(n){return this.a.copy(n.a),this.b.copy(n.b),this.c.copy(n.c),this}getArea(){return Sv.subVectors(this.c,this.b),V3.subVectors(this.a,this.b),Sv.cross(V3).length()*.5}getMidpoint(n){return n.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(n){return s.getNormal(this.a,this.b,this.c,n)}getPlane(n){return n.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(n,r){return s.getBarycoord(n,this.a,this.b,this.c,r)}getUV(n,r,c,u,d){return yfe===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),yfe=!0),s.getInterpolation(n,this.a,this.b,this.c,r,c,u,d)}getInterpolation(n,r,c,u,d){return s.getInterpolation(n,this.a,this.b,this.c,r,c,u,d)}containsPoint(n){return s.containsPoint(n,this.a,this.b,this.c)}isFrontFacing(n){return s.isFrontFacing(this.a,this.b,this.c,n)}intersectsBox(n){return n.intersectsTriangle(this)}closestPointToPoint(n,r){let c=this.a,u=this.b,d=this.c,b,w;XB.subVectors(u,c),YB.subVectors(d,c),a6e.subVectors(n,c);let _=XB.dot(a6e),x=YB.dot(a6e);if(_<=0&&x<=0)return r.copy(c);c6e.subVectors(n,u);let T=XB.dot(c6e),M=YB.dot(c6e);if(T>=0&&M<=T)return r.copy(u);let L=_*M-T*x;if(L<=0&&_>=0&&T<=0)return b=_/(_-T),r.copy(c).addScaledVector(XB,b);l6e.subVectors(n,d);let I=XB.dot(l6e),D=YB.dot(l6e);if(D>=0&&I<=D)return r.copy(d);let F=I*x-_*D;if(F<=0&&x>=0&&D<=0)return w=x/(x-D),r.copy(c).addScaledVector(YB,w);let O=T*D-I*M;if(O<=0&&M-T>=0&&I-D>=0)return Ryt.subVectors(d,u),w=(M-T)/(M-T+(I-D)),r.copy(u).addScaledVector(Ryt,w);let z=1/(O+F+L);return b=F*z,w=L*z,r.copy(c).addScaledVector(XB,b).addScaledVector(YB,w)}equals(n){return n.a.equals(this.a)&&n.b.equals(this.b)&&n.c.equals(this.c)}},A2t={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},uT={h:0,s:0,l:0},xfe={h:0,s:0,l:0};function u6e(s,n,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?s+(n-s)*6*r:r<1/2?n:r<2/3?s+(n-s)*6*(2/3-r):s}var Go=class{constructor(n,r,c){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(n,r,c)}set(n,r,c){if(r===void 0&&c===void 0){let u=n;u&&u.isColor?this.copy(u):typeof u=="number"?this.setHex(u):typeof u=="string"&&this.setStyle(u)}else this.setRGB(n,r,c);return this}setScalar(n){return this.r=n,this.g=n,this.b=n,this}setHex(n,r=Td){return n=Math.floor(n),this.r=(n>>16&255)/255,this.g=(n>>8&255)/255,this.b=(n&255)/255,Pc.toWorkingColorSpace(this,r),this}setRGB(n,r,c,u=Pc.workingColorSpace){return this.r=n,this.g=r,this.b=c,Pc.toWorkingColorSpace(this,u),this}setHSL(n,r,c,u=Pc.workingColorSpace){if(n=can(n,1),r=Sm(r,0,1),c=Sm(c,0,1),r===0)this.r=this.g=this.b=c;else{let d=c<=.5?c*(1+r):c+r-c*r,b=2*c-d;this.r=u6e(b,d,n+1/3),this.g=u6e(b,d,n),this.b=u6e(b,d,n-1/3)}return Pc.toWorkingColorSpace(this,u),this}setStyle(n,r=Td){function c(d){d!==void 0&&parseFloat(d)<1&&console.warn("THREE.Color: Alpha component of "+n+" will be ignored.")}let u;if(u=/^(\w+)\(([^\)]*)\)/.exec(n)){let d,b=u[1],w=u[2];switch(b){case"rgb":case"rgba":if(d=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(w))return c(d[4]),this.setRGB(Math.min(255,parseInt(d[1],10))/255,Math.min(255,parseInt(d[2],10))/255,Math.min(255,parseInt(d[3],10))/255,r);if(d=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(w))return c(d[4]),this.setRGB(Math.min(100,parseInt(d[1],10))/100,Math.min(100,parseInt(d[2],10))/100,Math.min(100,parseInt(d[3],10))/100,r);break;case"hsl":case"hsla":if(d=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(w))return c(d[4]),this.setHSL(parseFloat(d[1])/360,parseFloat(d[2])/100,parseFloat(d[3])/100,r);break;default:console.warn("THREE.Color: Unknown color model "+n)}}else if(u=/^\#([A-Fa-f\d]+)$/.exec(n)){let d=u[1],b=d.length;if(b===3)return this.setRGB(parseInt(d.charAt(0),16)/15,parseInt(d.charAt(1),16)/15,parseInt(d.charAt(2),16)/15,r);if(b===6)return this.setHex(parseInt(d,16),r);console.warn("THREE.Color: Invalid hex color "+n)}else if(n&&n.length>0)return this.setColorName(n,r);return this}setColorName(n,r=Td){let c=A2t[n.toLowerCase()];return c!==void 0?this.setHex(c,r):console.warn("THREE.Color: Unknown color "+n),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(n){return this.r=n.r,this.g=n.g,this.b=n.b,this}copySRGBToLinear(n){return this.r=aO(n.r),this.g=aO(n.g),this.b=aO(n.b),this}copyLinearToSRGB(n){return this.r=JIe(n.r),this.g=JIe(n.g),this.b=JIe(n.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(n=Td){return Pc.fromWorkingColorSpace(mp.copy(this),n),Math.round(Sm(mp.r*255,0,255))*65536+Math.round(Sm(mp.g*255,0,255))*256+Math.round(Sm(mp.b*255,0,255))}getHexString(n=Td){return("000000"+this.getHex(n).toString(16)).slice(-6)}getHSL(n,r=Pc.workingColorSpace){Pc.fromWorkingColorSpace(mp.copy(this),r);let c=mp.r,u=mp.g,d=mp.b,b=Math.max(c,u,d),w=Math.min(c,u,d),_,x,T=(w+b)/2;if(w===b)_=0,x=0;else{let M=b-w;switch(x=T<=.5?M/(b+w):M/(2-b-w),b){case c:_=(u-d)/M+(u0!=n>0&&this.version++,this._alphaTest=n}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(n){if(n!==void 0)for(let r in n){let c=n[r];if(c===void 0){console.warn(`THREE.Material: parameter '${r}' has value of undefined.`);continue}let u=this[r];if(u===void 0){console.warn(`THREE.Material: '${r}' is not a property of THREE.${this.type}.`);continue}u&&u.isColor?u.set(c):u&&u.isVector3&&c&&c.isVector3?u.copy(c):this[r]=c}}toJSON(n){let r=n===void 0||typeof n=="string";r&&(n={textures:{},images:{}});let c={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};c.uuid=this.uuid,c.type=this.type,this.name!==""&&(c.name=this.name),this.color&&this.color.isColor&&(c.color=this.color.getHex()),this.roughness!==void 0&&(c.roughness=this.roughness),this.metalness!==void 0&&(c.metalness=this.metalness),this.sheen!==void 0&&(c.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(c.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(c.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(c.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(c.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(c.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(c.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(c.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(c.shininess=this.shininess),this.clearcoat!==void 0&&(c.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(c.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(c.clearcoatMap=this.clearcoatMap.toJSON(n).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(c.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(n).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(c.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(n).uuid,c.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(c.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(c.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(c.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(c.iridescenceMap=this.iridescenceMap.toJSON(n).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(c.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(n).uuid),this.anisotropy!==void 0&&(c.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(c.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(c.anisotropyMap=this.anisotropyMap.toJSON(n).uuid),this.map&&this.map.isTexture&&(c.map=this.map.toJSON(n).uuid),this.matcap&&this.matcap.isTexture&&(c.matcap=this.matcap.toJSON(n).uuid),this.alphaMap&&this.alphaMap.isTexture&&(c.alphaMap=this.alphaMap.toJSON(n).uuid),this.lightMap&&this.lightMap.isTexture&&(c.lightMap=this.lightMap.toJSON(n).uuid,c.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(c.aoMap=this.aoMap.toJSON(n).uuid,c.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(c.bumpMap=this.bumpMap.toJSON(n).uuid,c.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(c.normalMap=this.normalMap.toJSON(n).uuid,c.normalMapType=this.normalMapType,c.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(c.displacementMap=this.displacementMap.toJSON(n).uuid,c.displacementScale=this.displacementScale,c.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(c.roughnessMap=this.roughnessMap.toJSON(n).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(c.metalnessMap=this.metalnessMap.toJSON(n).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(c.emissiveMap=this.emissiveMap.toJSON(n).uuid),this.specularMap&&this.specularMap.isTexture&&(c.specularMap=this.specularMap.toJSON(n).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(c.specularIntensityMap=this.specularIntensityMap.toJSON(n).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(c.specularColorMap=this.specularColorMap.toJSON(n).uuid),this.envMap&&this.envMap.isTexture&&(c.envMap=this.envMap.toJSON(n).uuid,this.combine!==void 0&&(c.combine=this.combine)),this.envMapIntensity!==void 0&&(c.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(c.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(c.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(c.gradientMap=this.gradientMap.toJSON(n).uuid),this.transmission!==void 0&&(c.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(c.transmissionMap=this.transmissionMap.toJSON(n).uuid),this.thickness!==void 0&&(c.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(c.thicknessMap=this.thicknessMap.toJSON(n).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(c.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(c.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(c.size=this.size),this.shadowSide!==null&&(c.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(c.sizeAttenuation=this.sizeAttenuation),this.blending!==oO&&(c.blending=this.blending),this.side!==bT&&(c.side=this.side),this.vertexColors===!0&&(c.vertexColors=!0),this.opacity<1&&(c.opacity=this.opacity),this.transparent===!0&&(c.transparent=!0),this.blendSrc!==x6e&&(c.blendSrc=this.blendSrc),this.blendDst!==E6e&&(c.blendDst=this.blendDst),this.blendEquation!==j4&&(c.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(c.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(c.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(c.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(c.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(c.blendAlpha=this.blendAlpha),this.depthFunc!==jfe&&(c.depthFunc=this.depthFunc),this.depthTest===!1&&(c.depthTest=this.depthTest),this.depthWrite===!1&&(c.depthWrite=this.depthWrite),this.colorWrite===!1&&(c.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(c.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==wyt&&(c.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(c.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(c.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==GB&&(c.stencilFail=this.stencilFail),this.stencilZFail!==GB&&(c.stencilZFail=this.stencilZFail),this.stencilZPass!==GB&&(c.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(c.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(c.rotation=this.rotation),this.polygonOffset===!0&&(c.polygonOffset=!0),this.polygonOffsetFactor!==0&&(c.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(c.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(c.linewidth=this.linewidth),this.dashSize!==void 0&&(c.dashSize=this.dashSize),this.gapSize!==void 0&&(c.gapSize=this.gapSize),this.scale!==void 0&&(c.scale=this.scale),this.dithering===!0&&(c.dithering=!0),this.alphaTest>0&&(c.alphaTest=this.alphaTest),this.alphaHash===!0&&(c.alphaHash=!0),this.alphaToCoverage===!0&&(c.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(c.premultipliedAlpha=!0),this.forceSinglePass===!0&&(c.forceSinglePass=!0),this.wireframe===!0&&(c.wireframe=!0),this.wireframeLinewidth>1&&(c.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(c.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(c.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(c.flatShading=!0),this.visible===!1&&(c.visible=!1),this.toneMapped===!1&&(c.toneMapped=!1),this.fog===!1&&(c.fog=!1),Object.keys(this.userData).length>0&&(c.userData=this.userData);function u(d){let b=[];for(let w in d){let _=d[w];delete _.metadata,b.push(_)}return b}if(r){let d=u(n.textures),b=u(n.images);d.length>0&&(c.textures=d),b.length>0&&(c.images=b)}return c}clone(){return new this.constructor().copy(this)}copy(n){this.name=n.name,this.blending=n.blending,this.side=n.side,this.vertexColors=n.vertexColors,this.opacity=n.opacity,this.transparent=n.transparent,this.blendSrc=n.blendSrc,this.blendDst=n.blendDst,this.blendEquation=n.blendEquation,this.blendSrcAlpha=n.blendSrcAlpha,this.blendDstAlpha=n.blendDstAlpha,this.blendEquationAlpha=n.blendEquationAlpha,this.blendColor.copy(n.blendColor),this.blendAlpha=n.blendAlpha,this.depthFunc=n.depthFunc,this.depthTest=n.depthTest,this.depthWrite=n.depthWrite,this.stencilWriteMask=n.stencilWriteMask,this.stencilFunc=n.stencilFunc,this.stencilRef=n.stencilRef,this.stencilFuncMask=n.stencilFuncMask,this.stencilFail=n.stencilFail,this.stencilZFail=n.stencilZFail,this.stencilZPass=n.stencilZPass,this.stencilWrite=n.stencilWrite;let r=n.clippingPlanes,c=null;if(r!==null){let u=r.length;c=new Array(u);for(let d=0;d!==u;++d)c[d]=r[d].clone()}return this.clippingPlanes=c,this.clipIntersection=n.clipIntersection,this.clipShadows=n.clipShadows,this.shadowSide=n.shadowSide,this.colorWrite=n.colorWrite,this.precision=n.precision,this.polygonOffset=n.polygonOffset,this.polygonOffsetFactor=n.polygonOffsetFactor,this.polygonOffsetUnits=n.polygonOffsetUnits,this.dithering=n.dithering,this.alphaTest=n.alphaTest,this.alphaHash=n.alphaHash,this.alphaToCoverage=n.alphaToCoverage,this.premultipliedAlpha=n.premultipliedAlpha,this.forceSinglePass=n.forceSinglePass,this.visible=n.visible,this.toneMapped=n.toneMapped,this.userData=JSON.parse(JSON.stringify(n.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(n){n===!0&&this.version++}},hO=class extends _T{constructor(n){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Go(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=c5e,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(n)}copy(n){return super.copy(n),this.color.copy(n.color),this.map=n.map,this.lightMap=n.lightMap,this.lightMapIntensity=n.lightMapIntensity,this.aoMap=n.aoMap,this.aoMapIntensity=n.aoMapIntensity,this.specularMap=n.specularMap,this.alphaMap=n.alphaMap,this.envMap=n.envMap,this.combine=n.combine,this.reflectivity=n.reflectivity,this.refractionRatio=n.refractionRatio,this.wireframe=n.wireframe,this.wireframeLinewidth=n.wireframeLinewidth,this.wireframeLinecap=n.wireframeLinecap,this.wireframeLinejoin=n.wireframeLinejoin,this.fog=n.fog,this}};var Uf=new Gt,Efe=new ka,q1=class{constructor(n,r,c=!1){if(Array.isArray(n))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=n,this.itemSize=r,this.count=n!==void 0?n.length/r:0,this.normalized=c,this.usage=vyt,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=hT,this.version=0}onUploadCallback(){}set needsUpdate(n){n===!0&&this.version++}get updateRange(){return console.warn("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(n){return this.usage=n,this}addUpdateRange(n,r){this.updateRanges.push({start:n,count:r})}clearUpdateRanges(){this.updateRanges.length=0}copy(n){return this.name=n.name,this.array=new n.array.constructor(n.array),this.itemSize=n.itemSize,this.count=n.count,this.normalized=n.normalized,this.usage=n.usage,this.gpuType=n.gpuType,this}copyAt(n,r,c){n*=this.itemSize,c*=r.itemSize;for(let u=0,d=this.itemSize;u0&&(n.userData=this.userData),this.parameters!==void 0){let _=this.parameters;for(let x in _)_[x]!==void 0&&(n[x]=_[x]);return n}n.data={attributes:{}};let r=this.index;r!==null&&(n.data.index={type:r.array.constructor.name,array:Array.prototype.slice.call(r.array)});let c=this.attributes;for(let _ in c){let x=c[_];n.data.attributes[_]=x.toJSON(n.data)}let u={},d=!1;for(let _ in this.morphAttributes){let x=this.morphAttributes[_],T=[];for(let M=0,L=x.length;M0&&(u[_]=T,d=!0)}d&&(n.data.morphAttributes=u,n.data.morphTargetsRelative=this.morphTargetsRelative);let b=this.groups;b.length>0&&(n.data.groups=JSON.parse(JSON.stringify(b)));let w=this.boundingSphere;return w!==null&&(n.data.boundingSphere={center:w.center.toArray(),radius:w.radius}),n}clone(){return new this.constructor().copy(this)}copy(n){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let r={};this.name=n.name;let c=n.index;c!==null&&this.setIndex(c.clone(r));let u=n.attributes;for(let x in u){let T=u[x];this.setAttribute(x,T.clone(r))}let d=n.morphAttributes;for(let x in d){let T=[],M=d[x];for(let L=0,I=M.length;L0){let u=r[c[0]];if(u!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let d=0,b=u.length;d(n.far-n.near)**2))&&(Iyt.copy(d).invert(),U4.copy(n.ray).applyMatrix4(Iyt),!(c.boundingBox!==null&&U4.intersectsBox(c.boundingBox)===!1)&&this._computeIntersections(n,r,U4)))}_computeIntersections(n,r,c){let u,d=this.geometry,b=this.material,w=d.index,_=d.attributes.position,x=d.attributes.uv,T=d.attributes.uv1,M=d.attributes.normal,L=d.groups,I=d.drawRange;if(w!==null)if(Array.isArray(b))for(let D=0,F=L.length;Dr.far?null:{distance:x,point:Lfe.clone(),object:s}}function kfe(s,n,r,c,u,d,b,w,_,x){s.getVertexPosition(w,KB),s.getVertexPosition(_,JB),s.getVertexPosition(x,QB);let T=Ean(s,n,r,c,KB,JB,QB,Pfe);if(T){u&&(Tfe.fromBufferAttribute(u,w),Cfe.fromBufferAttribute(u,_),Afe.fromBufferAttribute(u,x),T.uv=V4.getInterpolation(Pfe,KB,JB,QB,Tfe,Cfe,Afe,new ka)),d&&(Tfe.fromBufferAttribute(d,w),Cfe.fromBufferAttribute(d,_),Afe.fromBufferAttribute(d,x),T.uv1=V4.getInterpolation(Pfe,KB,JB,QB,Tfe,Cfe,Afe,new ka),T.uv2=T.uv1),b&&(Byt.fromBufferAttribute(b,w),Oyt.fromBufferAttribute(b,_),Nyt.fromBufferAttribute(b,x),T.normal=V4.getInterpolation(Pfe,KB,JB,QB,Byt,Oyt,Nyt,new Gt),T.normal.dot(c.direction)>0&&T.normal.multiplyScalar(-1));let M={a:w,b:_,c:x,normal:new Gt,materialIndex:0};V4.getNormal(KB,JB,QB,M.normal),T.face=M}return T}var X4=class s extends d2{constructor(n=1,r=1,c=1,u=1,d=1,b=1){super(),this.type="BoxGeometry",this.parameters={width:n,height:r,depth:c,widthSegments:u,heightSegments:d,depthSegments:b};let w=this;u=Math.floor(u),d=Math.floor(d),b=Math.floor(b);let _=[],x=[],T=[],M=[],L=0,I=0;D("z","y","x",-1,-1,c,r,n,b,d,0),D("z","y","x",1,-1,c,r,-n,b,d,1),D("x","z","y",1,1,n,c,r,u,b,2),D("x","z","y",1,-1,n,c,-r,u,b,3),D("x","y","z",1,-1,n,r,c,u,d,4),D("x","y","z",-1,-1,n,r,-c,u,d,5),this.setIndex(_),this.setAttribute("position",new Cm(x,3)),this.setAttribute("normal",new Cm(T,3)),this.setAttribute("uv",new Cm(M,2));function D(F,O,z,Z,H,te,oe,ne,ue,Te,Q){let ge=te/ue,Qe=oe/Te,st=te/2,at=oe/2,Ne=ne/2,tt=ue+1,ot=Te+1,Tt=0,jt=0,en=new Gt;for(let mn=0;mn0?1:-1,T.push(en.x,en.y,en.z),M.push(bi/ue),M.push(1-mn/Te),Tt+=1}}for(let mn=0;mn0&&(r.defines=this.defines),r.vertexShader=this.vertexShader,r.fragmentShader=this.fragmentShader,r.lights=this.lights,r.clipping=this.clipping;let c={};for(let u in this.extensions)this.extensions[u]===!0&&(c[u]=!0);return Object.keys(c).length>0&&(r.extensions=c),r}},nhe=class extends gg{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Il,this.projectionMatrix=new Il,this.projectionMatrixInverse=new Il,this.coordinateSystem=X3}copy(n,r){return super.copy(n,r),this.matrixWorldInverse.copy(n.matrixWorldInverse),this.projectionMatrix.copy(n.projectionMatrix),this.projectionMatrixInverse.copy(n.projectionMatrixInverse),this.coordinateSystem=n.coordinateSystem,this}getWorldDirection(n){return super.getWorldDirection(n).negate()}updateMatrixWorld(n){super.updateMatrixWorld(n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(n,r){super.updateWorldMatrix(n,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},pg=class extends nhe{constructor(n=50,r=1,c=.1,u=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=n,this.zoom=1,this.near=c,this.far=u,this.focus=10,this.aspect=r,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(n,r){return super.copy(n,r),this.fov=n.fov,this.zoom=n.zoom,this.near=n.near,this.far=n.far,this.focus=n.focus,this.aspect=n.aspect,this.view=n.view===null?null:Object.assign({},n.view),this.filmGauge=n.filmGauge,this.filmOffset=n.filmOffset,this}setFocalLength(n){let r=.5*this.getFilmHeight()/n;this.fov=P6e*2*Math.atan(r),this.updateProjectionMatrix()}getFocalLength(){let n=Math.tan(Gfe*.5*this.fov);return .5*this.getFilmHeight()/n}getEffectiveFOV(){return P6e*2*Math.atan(Math.tan(Gfe*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(n,r,c,u,d,b){this.aspect=n/r,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=n,this.view.fullHeight=r,this.view.offsetX=c,this.view.offsetY=u,this.view.width=d,this.view.height=b,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let n=this.near,r=n*Math.tan(Gfe*.5*this.fov)/this.zoom,c=2*r,u=this.aspect*c,d=-.5*u,b=this.view;if(this.view!==null&&this.view.enabled){let _=b.fullWidth,x=b.fullHeight;d+=b.offsetX*u/_,r-=b.offsetY*c/x,u*=b.width/_,c*=b.height/x}let w=this.filmOffset;w!==0&&(d+=n*w/this.getFilmWidth()),this.projectionMatrix.makePerspective(d,d+u,r,r-c,n,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(n){let r=super.toJSON(n);return r.object.fov=this.fov,r.object.zoom=this.zoom,r.object.near=this.near,r.object.far=this.far,r.object.focus=this.focus,r.object.aspect=this.aspect,this.view!==null&&(r.object.view=Object.assign({},this.view)),r.object.filmGauge=this.filmGauge,r.object.filmOffset=this.filmOffset,r}},eO=-90,tO=1,I6e=class extends gg{constructor(n,r,c){super(),this.type="CubeCamera",this.renderTarget=c,this.coordinateSystem=null,this.activeMipmapLevel=0;let u=new pg(eO,tO,n,r);u.layers=this.layers,this.add(u);let d=new pg(eO,tO,n,r);d.layers=this.layers,this.add(d);let b=new pg(eO,tO,n,r);b.layers=this.layers,this.add(b);let w=new pg(eO,tO,n,r);w.layers=this.layers,this.add(w);let _=new pg(eO,tO,n,r);_.layers=this.layers,this.add(_);let x=new pg(eO,tO,n,r);x.layers=this.layers,this.add(x)}updateCoordinateSystem(){let n=this.coordinateSystem,r=this.children.concat(),[c,u,d,b,w,_]=r;for(let x of r)this.remove(x);if(n===X3)c.up.set(0,1,0),c.lookAt(1,0,0),u.up.set(0,1,0),u.lookAt(-1,0,0),d.up.set(0,0,-1),d.lookAt(0,1,0),b.up.set(0,0,1),b.lookAt(0,-1,0),w.up.set(0,1,0),w.lookAt(0,0,1),_.up.set(0,1,0),_.lookAt(0,0,-1);else if(n===Xfe)c.up.set(0,-1,0),c.lookAt(-1,0,0),u.up.set(0,-1,0),u.lookAt(1,0,0),d.up.set(0,0,1),d.lookAt(0,1,0),b.up.set(0,0,-1),b.lookAt(0,-1,0),w.up.set(0,-1,0),w.lookAt(0,0,1),_.up.set(0,-1,0),_.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+n);for(let x of r)this.add(x),x.updateMatrixWorld()}update(n,r){this.parent===null&&this.updateMatrixWorld();let{renderTarget:c,activeMipmapLevel:u}=this;this.coordinateSystem!==n.coordinateSystem&&(this.coordinateSystem=n.coordinateSystem,this.updateCoordinateSystem());let[d,b,w,_,x,T]=this.children,M=n.getRenderTarget(),L=n.getActiveCubeFace(),I=n.getActiveMipmapLevel(),D=n.xr.enabled;n.xr.enabled=!1;let F=c.texture.generateMipmaps;c.texture.generateMipmaps=!1,n.setRenderTarget(c,0,u),n.render(r,d),n.setRenderTarget(c,1,u),n.render(r,b),n.setRenderTarget(c,2,u),n.render(r,w),n.setRenderTarget(c,3,u),n.render(r,_),n.setRenderTarget(c,4,u),n.render(r,x),c.texture.generateMipmaps=F,n.setRenderTarget(c,5,u),n.render(r,T),n.setRenderTarget(M,L,I),n.xr.enabled=D,c.texture.needsPMREMUpdate=!0}},ihe=class extends Av{constructor(n,r,c,u,d,b,w,_,x,T){n=n!==void 0?n:[],r=r!==void 0?r:lO,super(n,r,c,u,d,b,w,_,x,T),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(n){this.image=n}},D6e=class extends Z3{constructor(n=1,r={}){super(n,n,r),this.isWebGLCubeRenderTarget=!0;let c={width:n,height:n,depth:1},u=[c,c,c,c,c,c];r.encoding!==void 0&&(RW("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===q4?Td:Nb),this.texture=new ihe(u,r.mapping,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=r.generateMipmaps!==void 0?r.generateMipmaps:!1,this.texture.minFilter=r.minFilter!==void 0?r.minFilter:Ob}fromEquirectangularTexture(n,r){this.texture.type=r.type,this.texture.colorSpace=r.colorSpace,this.texture.generateMipmaps=r.generateMipmaps,this.texture.minFilter=r.minFilter,this.texture.magFilter=r.magFilter;let c={uniforms:{tEquirect:{value:null}},vertexShader:` +}`,J3=class extends _T{constructor(n){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Tan,this.fragmentShader=Can,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1,clipCullDistance:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,n!==void 0&&this.setValues(n)}copy(n){return super.copy(n),this.fragmentShader=n.fragmentShader,this.vertexShader=n.vertexShader,this.uniforms=dO(n.uniforms),this.uniformsGroups=San(n.uniformsGroups),this.defines=Object.assign({},n.defines),this.wireframe=n.wireframe,this.wireframeLinewidth=n.wireframeLinewidth,this.fog=n.fog,this.lights=n.lights,this.clipping=n.clipping,this.extensions=Object.assign({},n.extensions),this.glslVersion=n.glslVersion,this}toJSON(n){let r=super.toJSON(n);r.glslVersion=this.glslVersion,r.uniforms={};for(let u in this.uniforms){let b=this.uniforms[u].value;b&&b.isTexture?r.uniforms[u]={type:"t",value:b.toJSON(n).uuid}:b&&b.isColor?r.uniforms[u]={type:"c",value:b.getHex()}:b&&b.isVector2?r.uniforms[u]={type:"v2",value:b.toArray()}:b&&b.isVector3?r.uniforms[u]={type:"v3",value:b.toArray()}:b&&b.isVector4?r.uniforms[u]={type:"v4",value:b.toArray()}:b&&b.isMatrix3?r.uniforms[u]={type:"m3",value:b.toArray()}:b&&b.isMatrix4?r.uniforms[u]={type:"m4",value:b.toArray()}:r.uniforms[u]={value:b}}Object.keys(this.defines).length>0&&(r.defines=this.defines),r.vertexShader=this.vertexShader,r.fragmentShader=this.fragmentShader,r.lights=this.lights,r.clipping=this.clipping;let c={};for(let u in this.extensions)this.extensions[u]===!0&&(c[u]=!0);return Object.keys(c).length>0&&(r.extensions=c),r}},nhe=class extends gg{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Il,this.projectionMatrix=new Il,this.projectionMatrixInverse=new Il,this.coordinateSystem=X3}copy(n,r){return super.copy(n,r),this.matrixWorldInverse.copy(n.matrixWorldInverse),this.projectionMatrix.copy(n.projectionMatrix),this.projectionMatrixInverse.copy(n.projectionMatrixInverse),this.coordinateSystem=n.coordinateSystem,this}getWorldDirection(n){return super.getWorldDirection(n).negate()}updateMatrixWorld(n){super.updateMatrixWorld(n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(n,r){super.updateWorldMatrix(n,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},pg=class extends nhe{constructor(n=50,r=1,c=.1,u=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=n,this.zoom=1,this.near=c,this.far=u,this.focus=10,this.aspect=r,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(n,r){return super.copy(n,r),this.fov=n.fov,this.zoom=n.zoom,this.near=n.near,this.far=n.far,this.focus=n.focus,this.aspect=n.aspect,this.view=n.view===null?null:Object.assign({},n.view),this.filmGauge=n.filmGauge,this.filmOffset=n.filmOffset,this}setFocalLength(n){let r=.5*this.getFilmHeight()/n;this.fov=P6e*2*Math.atan(r),this.updateProjectionMatrix()}getFocalLength(){let n=Math.tan(Gfe*.5*this.fov);return .5*this.getFilmHeight()/n}getEffectiveFOV(){return P6e*2*Math.atan(Math.tan(Gfe*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(n,r,c,u,d,b){this.aspect=n/r,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=n,this.view.fullHeight=r,this.view.offsetX=c,this.view.offsetY=u,this.view.width=d,this.view.height=b,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let n=this.near,r=n*Math.tan(Gfe*.5*this.fov)/this.zoom,c=2*r,u=this.aspect*c,d=-.5*u,b=this.view;if(this.view!==null&&this.view.enabled){let _=b.fullWidth,x=b.fullHeight;d+=b.offsetX*u/_,r-=b.offsetY*c/x,u*=b.width/_,c*=b.height/x}let w=this.filmOffset;w!==0&&(d+=n*w/this.getFilmWidth()),this.projectionMatrix.makePerspective(d,d+u,r,r-c,n,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(n){let r=super.toJSON(n);return r.object.fov=this.fov,r.object.zoom=this.zoom,r.object.near=this.near,r.object.far=this.far,r.object.focus=this.focus,r.object.aspect=this.aspect,this.view!==null&&(r.object.view=Object.assign({},this.view)),r.object.filmGauge=this.filmGauge,r.object.filmOffset=this.filmOffset,r}},eO=-90,tO=1,I6e=class extends gg{constructor(n,r,c){super(),this.type="CubeCamera",this.renderTarget=c,this.coordinateSystem=null,this.activeMipmapLevel=0;let u=new pg(eO,tO,n,r);u.layers=this.layers,this.add(u);let d=new pg(eO,tO,n,r);d.layers=this.layers,this.add(d);let b=new pg(eO,tO,n,r);b.layers=this.layers,this.add(b);let w=new pg(eO,tO,n,r);w.layers=this.layers,this.add(w);let _=new pg(eO,tO,n,r);_.layers=this.layers,this.add(_);let x=new pg(eO,tO,n,r);x.layers=this.layers,this.add(x)}updateCoordinateSystem(){let n=this.coordinateSystem,r=this.children.concat(),[c,u,d,b,w,_]=r;for(let x of r)this.remove(x);if(n===X3)c.up.set(0,1,0),c.lookAt(1,0,0),u.up.set(0,1,0),u.lookAt(-1,0,0),d.up.set(0,0,-1),d.lookAt(0,1,0),b.up.set(0,0,1),b.lookAt(0,-1,0),w.up.set(0,1,0),w.lookAt(0,0,1),_.up.set(0,1,0),_.lookAt(0,0,-1);else if(n===Xfe)c.up.set(0,-1,0),c.lookAt(-1,0,0),u.up.set(0,-1,0),u.lookAt(1,0,0),d.up.set(0,0,1),d.lookAt(0,1,0),b.up.set(0,0,-1),b.lookAt(0,-1,0),w.up.set(0,-1,0),w.lookAt(0,0,1),_.up.set(0,-1,0),_.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+n);for(let x of r)this.add(x),x.updateMatrixWorld()}update(n,r){this.parent===null&&this.updateMatrixWorld();let{renderTarget:c,activeMipmapLevel:u}=this;this.coordinateSystem!==n.coordinateSystem&&(this.coordinateSystem=n.coordinateSystem,this.updateCoordinateSystem());let[d,b,w,_,x,T]=this.children,M=n.getRenderTarget(),L=n.getActiveCubeFace(),I=n.getActiveMipmapLevel(),D=n.xr.enabled;n.xr.enabled=!1;let F=c.texture.generateMipmaps;c.texture.generateMipmaps=!1,n.setRenderTarget(c,0,u),n.render(r,d),n.setRenderTarget(c,1,u),n.render(r,b),n.setRenderTarget(c,2,u),n.render(r,w),n.setRenderTarget(c,3,u),n.render(r,_),n.setRenderTarget(c,4,u),n.render(r,x),c.texture.generateMipmaps=F,n.setRenderTarget(c,5,u),n.render(r,T),n.setRenderTarget(M,L,I),n.xr.enabled=D,c.texture.needsPMREMUpdate=!0}},ihe=class extends Av{constructor(n,r,c,u,d,b,w,_,x,T){n=n!==void 0?n:[],r=r!==void 0?r:lO,super(n,r,c,u,d,b,w,_,x,T),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(n){this.image=n}},D6e=class extends Z3{constructor(n=1,r={}){super(n,n,r),this.isWebGLCubeRenderTarget=!0;let c={width:n,height:n,depth:1},u=[c,c,c,c,c,c];r.encoding!==void 0&&(RW("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===q4?Td:Ob),this.texture=new ihe(u,r.mapping,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=r.generateMipmaps!==void 0?r.generateMipmaps:!1,this.texture.minFilter=r.minFilter!==void 0?r.minFilter:Bb}fromEquirectangularTexture(n,r){this.texture.type=r.type,this.texture.colorSpace=r.colorSpace,this.texture.generateMipmaps=r.generateMipmaps,this.texture.minFilter=r.minFilter,this.texture.magFilter=r.magFilter;let c={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; @@ -6457,9 +6457,9 @@ ${t_t()} gl_FragColor = texture2D( tEquirect, sampleUV ); } - `},u=new X4(5,5,5),d=new J3({name:"CubemapFromEquirect",uniforms:dO(c.uniforms),vertexShader:c.vertexShader,fragmentShader:c.fragmentShader,side:Tm,blending:pT});d.uniforms.tEquirect.value=r;let b=new Mm(u,d),w=r.minFilter;return r.minFilter===DW&&(r.minFilter=Ob),new I6e(1,10,this).update(n,b),r.minFilter=w,b.geometry.dispose(),b.material.dispose(),this}clear(n,r,c,u){let d=n.getRenderTarget();for(let b=0;b<6;b++)n.setRenderTarget(this,b),n.clear(r,c,u);n.setRenderTarget(d)}},d6e=new Gt,Man=new Gt,Tan=new Xo,q3=class{constructor(n=new Gt(1,0,0),r=0){this.isPlane=!0,this.normal=n,this.constant=r}set(n,r){return this.normal.copy(n),this.constant=r,this}setComponents(n,r,c,u){return this.normal.set(n,r,c),this.constant=u,this}setFromNormalAndCoplanarPoint(n,r){return this.normal.copy(n),this.constant=-r.dot(this.normal),this}setFromCoplanarPoints(n,r,c){let u=d6e.subVectors(c,r).cross(Man.subVectors(n,r)).normalize();return this.setFromNormalAndCoplanarPoint(u,n),this}copy(n){return this.normal.copy(n.normal),this.constant=n.constant,this}normalize(){let n=1/this.normal.length();return this.normal.multiplyScalar(n),this.constant*=n,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(n){return this.normal.dot(n)+this.constant}distanceToSphere(n){return this.distanceToPoint(n.center)-n.radius}projectPoint(n,r){return r.copy(n).addScaledVector(this.normal,-this.distanceToPoint(n))}intersectLine(n,r){let c=n.delta(d6e),u=this.normal.dot(c);if(u===0)return this.distanceToPoint(n.start)===0?r.copy(n.start):null;let d=-(n.start.dot(this.normal)+this.constant)/u;return d<0||d>1?null:r.copy(n.start).addScaledVector(c,d)}intersectsLine(n){let r=this.distanceToPoint(n.start),c=this.distanceToPoint(n.end);return r<0&&c>0||c<0&&r>0}intersectsBox(n){return n.intersectsPlane(this)}intersectsSphere(n){return n.intersectsPlane(this)}coplanarPoint(n){return n.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(n,r){let c=r||Tan.getNormalMatrix(n),u=this.coplanarPoint(d6e).applyMatrix4(n),d=this.normal.applyMatrix3(c).normalize();return this.constant=-u.dot(d),this}translate(n){return this.constant-=n.dot(this.normal),this}equals(n){return n.normal.equals(this.normal)&&n.constant===this.constant}clone(){return new this.constructor().copy(this)}},z4=new vT,Rfe=new Gt,FW=class{constructor(n=new q3,r=new q3,c=new q3,u=new q3,d=new q3,b=new q3){this.planes=[n,r,c,u,d,b]}set(n,r,c,u,d,b){let w=this.planes;return w[0].copy(n),w[1].copy(r),w[2].copy(c),w[3].copy(u),w[4].copy(d),w[5].copy(b),this}copy(n){let r=this.planes;for(let c=0;c<6;c++)r[c].copy(n.planes[c]);return this}setFromProjectionMatrix(n,r=X3){let c=this.planes,u=n.elements,d=u[0],b=u[1],w=u[2],_=u[3],x=u[4],T=u[5],M=u[6],L=u[7],I=u[8],D=u[9],F=u[10],O=u[11],z=u[12],Z=u[13],H=u[14],te=u[15];if(c[0].setComponents(_-d,L-x,O-I,te-z).normalize(),c[1].setComponents(_+d,L+x,O+I,te+z).normalize(),c[2].setComponents(_+b,L+T,O+D,te+Z).normalize(),c[3].setComponents(_-b,L-T,O-D,te-Z).normalize(),c[4].setComponents(_-w,L-M,O-F,te-H).normalize(),r===X3)c[5].setComponents(_+w,L+M,O+F,te+H).normalize();else if(r===Xfe)c[5].setComponents(w,M,F,H).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+r);return this}intersectsObject(n){if(n.boundingSphere!==void 0)n.boundingSphere===null&&n.computeBoundingSphere(),z4.copy(n.boundingSphere).applyMatrix4(n.matrixWorld);else{let r=n.geometry;r.boundingSphere===null&&r.computeBoundingSphere(),z4.copy(r.boundingSphere).applyMatrix4(n.matrixWorld)}return this.intersectsSphere(z4)}intersectsSprite(n){return z4.center.set(0,0,0),z4.radius=.7071067811865476,z4.applyMatrix4(n.matrixWorld),this.intersectsSphere(z4)}intersectsSphere(n){let r=this.planes,c=n.center,u=-n.radius;for(let d=0;d<6;d++)if(r[d].distanceToPoint(c)0?n.max.x:n.min.x,Rfe.y=u.normal.y>0?n.max.y:n.min.y,Rfe.z=u.normal.z>0?n.max.z:n.min.z,u.distanceToPoint(Rfe)<0)return!1}return!0}containsPoint(n){let r=this.planes;for(let c=0;c<6;c++)if(r[c].distanceToPoint(n)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function L2t(){let s=null,n=!1,r=null,c=null;function u(d,b){r(d,b),c=s.requestAnimationFrame(u)}return{start:function(){n!==!0&&r!==null&&(c=s.requestAnimationFrame(u),n=!0)},stop:function(){s.cancelAnimationFrame(c),n=!1},setAnimationLoop:function(d){r=d},setContext:function(d){s=d}}}function Can(s,n){let r=n.isWebGL2,c=new WeakMap;function u(x,T){let M=x.array,L=x.usage,I=M.byteLength,D=s.createBuffer();s.bindBuffer(T,D),s.bufferData(T,M,L),x.onUploadCallback();let F;if(M instanceof Float32Array)F=s.FLOAT;else if(M instanceof Uint16Array)if(x.isFloat16BufferAttribute)if(r)F=s.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else F=s.UNSIGNED_SHORT;else if(M instanceof Int16Array)F=s.SHORT;else if(M instanceof Uint32Array)F=s.UNSIGNED_INT;else if(M instanceof Int32Array)F=s.INT;else if(M instanceof Int8Array)F=s.BYTE;else if(M instanceof Uint8Array)F=s.UNSIGNED_BYTE;else if(M instanceof Uint8ClampedArray)F=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+M);return{buffer:D,type:F,bytesPerElement:M.BYTES_PER_ELEMENT,version:x.version,size:I}}function d(x,T,M){let L=T.array,I=T._updateRange,D=T.updateRanges;if(s.bindBuffer(M,x),I.count===-1&&D.length===0&&s.bufferSubData(M,0,L),D.length!==0){for(let F=0,O=D.length;F1?null:r.copy(n.start).addScaledVector(c,d)}intersectsLine(n){let r=this.distanceToPoint(n.start),c=this.distanceToPoint(n.end);return r<0&&c>0||c<0&&r>0}intersectsBox(n){return n.intersectsPlane(this)}intersectsSphere(n){return n.intersectsPlane(this)}coplanarPoint(n){return n.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(n,r){let c=r||Pan.getNormalMatrix(n),u=this.coplanarPoint(d6e).applyMatrix4(n),d=this.normal.applyMatrix3(c).normalize();return this.constant=-u.dot(d),this}translate(n){return this.constant-=n.dot(this.normal),this}equals(n){return n.normal.equals(this.normal)&&n.constant===this.constant}clone(){return new this.constructor().copy(this)}},z4=new vT,Rfe=new Gt,FW=class{constructor(n=new q3,r=new q3,c=new q3,u=new q3,d=new q3,b=new q3){this.planes=[n,r,c,u,d,b]}set(n,r,c,u,d,b){let w=this.planes;return w[0].copy(n),w[1].copy(r),w[2].copy(c),w[3].copy(u),w[4].copy(d),w[5].copy(b),this}copy(n){let r=this.planes;for(let c=0;c<6;c++)r[c].copy(n.planes[c]);return this}setFromProjectionMatrix(n,r=X3){let c=this.planes,u=n.elements,d=u[0],b=u[1],w=u[2],_=u[3],x=u[4],T=u[5],M=u[6],L=u[7],I=u[8],D=u[9],F=u[10],O=u[11],z=u[12],Z=u[13],H=u[14],te=u[15];if(c[0].setComponents(_-d,L-x,O-I,te-z).normalize(),c[1].setComponents(_+d,L+x,O+I,te+z).normalize(),c[2].setComponents(_+b,L+T,O+D,te+Z).normalize(),c[3].setComponents(_-b,L-T,O-D,te-Z).normalize(),c[4].setComponents(_-w,L-M,O-F,te-H).normalize(),r===X3)c[5].setComponents(_+w,L+M,O+F,te+H).normalize();else if(r===Xfe)c[5].setComponents(w,M,F,H).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+r);return this}intersectsObject(n){if(n.boundingSphere!==void 0)n.boundingSphere===null&&n.computeBoundingSphere(),z4.copy(n.boundingSphere).applyMatrix4(n.matrixWorld);else{let r=n.geometry;r.boundingSphere===null&&r.computeBoundingSphere(),z4.copy(r.boundingSphere).applyMatrix4(n.matrixWorld)}return this.intersectsSphere(z4)}intersectsSprite(n){return z4.center.set(0,0,0),z4.radius=.7071067811865476,z4.applyMatrix4(n.matrixWorld),this.intersectsSphere(z4)}intersectsSphere(n){let r=this.planes,c=n.center,u=-n.radius;for(let d=0;d<6;d++)if(r[d].distanceToPoint(c)0?n.max.x:n.min.x,Rfe.y=u.normal.y>0?n.max.y:n.min.y,Rfe.z=u.normal.z>0?n.max.z:n.min.z,u.distanceToPoint(Rfe)<0)return!1}return!0}containsPoint(n){let r=this.planes;for(let c=0;c<6;c++)if(r[c].distanceToPoint(n)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function L2t(){let s=null,n=!1,r=null,c=null;function u(d,b){r(d,b),c=s.requestAnimationFrame(u)}return{start:function(){n!==!0&&r!==null&&(c=s.requestAnimationFrame(u),n=!0)},stop:function(){s.cancelAnimationFrame(c),n=!1},setAnimationLoop:function(d){r=d},setContext:function(d){s=d}}}function Lan(s,n){let r=n.isWebGL2,c=new WeakMap;function u(x,T){let M=x.array,L=x.usage,I=M.byteLength,D=s.createBuffer();s.bindBuffer(T,D),s.bufferData(T,M,L),x.onUploadCallback();let F;if(M instanceof Float32Array)F=s.FLOAT;else if(M instanceof Uint16Array)if(x.isFloat16BufferAttribute)if(r)F=s.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else F=s.UNSIGNED_SHORT;else if(M instanceof Int16Array)F=s.SHORT;else if(M instanceof Uint32Array)F=s.UNSIGNED_INT;else if(M instanceof Int32Array)F=s.INT;else if(M instanceof Int8Array)F=s.BYTE;else if(M instanceof Uint8Array)F=s.UNSIGNED_BYTE;else if(M instanceof Uint8ClampedArray)F=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+M);return{buffer:D,type:F,bytesPerElement:M.BYTES_PER_ELEMENT,version:x.version,size:I}}function d(x,T,M){let L=T.array,I=T._updateRange,D=T.updateRanges;if(s.bindBuffer(M,x),I.count===-1&&D.length===0&&s.bufferSubData(M,0,L),D.length!==0){for(let F=0,O=D.length;F 0 +#endif`,Han=`#if NUM_CLIPPING_PLANES > 0 vec4 plane; #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { @@ -6656,26 +6656,26 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve #pragma unroll_loop_end if ( clipped ) discard; #endif -#endif`,Van=`#if NUM_CLIPPING_PLANES > 0 +#endif`,qan=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; -#endif`,Wan=`#if NUM_CLIPPING_PLANES > 0 +#endif`,Xan=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; -#endif`,Han=`#if NUM_CLIPPING_PLANES > 0 +#endif`,Yan=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; -#endif`,qan=`#if defined( USE_COLOR_ALPHA ) +#endif`,Zan=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; -#endif`,Xan=`#if defined( USE_COLOR_ALPHA ) +#endif`,Kan=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; -#endif`,Yan=`#if defined( USE_COLOR_ALPHA ) +#endif`,Jan=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) varying vec3 vColor; -#endif`,Zan=`#if defined( USE_COLOR_ALPHA ) +#endif`,Qan=`#if defined( USE_COLOR_ALPHA ) vColor = vec4( 1.0 ); #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) vColor = vec3( 1.0 ); @@ -6685,7 +6685,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve #endif #ifdef USE_INSTANCING_COLOR vColor.xyz *= instanceColor.xyz; -#endif`,Kan=`#define PI 3.141592653589793 +#endif`,ecn=`#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 @@ -6763,7 +6763,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); -} // validated`,Jan=`#ifdef ENVMAP_TYPE_CUBE_UV +} // validated`,tcn=`#ifdef ENVMAP_TYPE_CUBE_UV #define cubeUV_minMipLevel 4.0 #define cubeUV_minTileSize 16.0 float getFace( vec3 direction ) { @@ -6856,7 +6856,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { return vec4( mix( color0, color1, mipF ), 1.0 ); } } -#endif`,Qan=`vec3 transformedNormal = objectNormal; +#endif`,ncn=`vec3 transformedNormal = objectNormal; #ifdef USE_TANGENT vec3 transformedTangent = objectTangent; #endif @@ -6885,18 +6885,18 @@ transformedNormal = normalMatrix * transformedNormal; #ifdef FLIP_SIDED transformedTangent = - transformedTangent; #endif -#endif`,ecn=`#ifdef USE_DISPLACEMENTMAP +#endif`,icn=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; -#endif`,tcn=`#ifdef USE_DISPLACEMENTMAP +#endif`,rcn=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); -#endif`,ncn=`#ifdef USE_EMISSIVEMAP +#endif`,scn=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); totalEmissiveRadiance *= emissiveColor.rgb; -#endif`,icn=`#ifdef USE_EMISSIVEMAP +#endif`,ocn=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; -#endif`,rcn="gl_FragColor = linearToOutputTexel( gl_FragColor );",scn=` +#endif`,acn="gl_FragColor = linearToOutputTexel( gl_FragColor );",ccn=` const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3( vec3( 0.8224621, 0.177538, 0.0 ), vec3( 0.0331941, 0.9668058, 0.0 ), @@ -6924,7 +6924,7 @@ vec4 LinearToLinear( in vec4 value ) { } vec4 LinearTosRGB( in vec4 value ) { return sRGBTransferOETF( value ); -}`,ocn=`#ifdef USE_ENVMAP +}`,lcn=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { @@ -6953,7 +6953,7 @@ vec4 LinearTosRGB( in vec4 value ) { #elif defined( ENVMAP_BLENDING_ADD ) outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif -#endif`,acn=`#ifdef USE_ENVMAP +#endif`,ucn=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; #ifdef ENVMAP_TYPE_CUBE @@ -6962,7 +6962,7 @@ vec4 LinearTosRGB( in vec4 value ) { uniform sampler2D envMap; #endif -#endif`,ccn=`#ifdef USE_ENVMAP +#endif`,fcn=`#ifdef USE_ENVMAP uniform float reflectivity; #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS @@ -6973,7 +6973,7 @@ vec4 LinearTosRGB( in vec4 value ) { #else varying vec3 vReflect; #endif -#endif`,lcn=`#ifdef USE_ENVMAP +#endif`,hcn=`#ifdef USE_ENVMAP #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif @@ -6984,7 +6984,7 @@ vec4 LinearTosRGB( in vec4 value ) { varying vec3 vReflect; uniform float refractionRatio; #endif -#endif`,ucn=`#ifdef USE_ENVMAP +#endif`,dcn=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vWorldPosition = worldPosition.xyz; #else @@ -7001,18 +7001,18 @@ vec4 LinearTosRGB( in vec4 value ) { vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); #endif #endif -#endif`,fcn=`#ifdef USE_FOG +#endif`,pcn=`#ifdef USE_FOG vFogDepth = - mvPosition.z; -#endif`,hcn=`#ifdef USE_FOG +#endif`,gcn=`#ifdef USE_FOG varying float vFogDepth; -#endif`,dcn=`#ifdef USE_FOG +#endif`,mcn=`#ifdef USE_FOG #ifdef FOG_EXP2 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); #else float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); #endif gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); -#endif`,pcn=`#ifdef USE_FOG +#endif`,bcn=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 @@ -7021,7 +7021,7 @@ vec4 LinearTosRGB( in vec4 value ) { uniform float fogNear; uniform float fogFar; #endif -#endif`,gcn=`#ifdef USE_GRADIENTMAP +#endif`,wcn=`#ifdef USE_GRADIENTMAP uniform sampler2D gradientMap; #endif vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { @@ -7033,16 +7033,16 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { vec2 fw = fwidth( coord ) * 0.5; return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); #endif -}`,mcn=`#ifdef USE_LIGHTMAP +}`,vcn=`#ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; reflectedLight.indirectDiffuse += lightMapIrradiance; -#endif`,bcn=`#ifdef USE_LIGHTMAP +#endif`,_cn=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; -#endif`,wcn=`LambertMaterial material; +#endif`,ycn=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; -material.specularStrength = specularStrength;`,vcn=`varying vec3 vViewPosition; +material.specularStrength = specularStrength;`,xcn=`varying vec3 vViewPosition; struct LambertMaterial { vec3 diffuseColor; float specularStrength; @@ -7056,7 +7056,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Lambert -#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,_cn=`uniform bool receiveShadow; +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Ecn=`uniform bool receiveShadow; uniform vec3 ambientLightColor; #if defined( USE_LIGHT_PROBES ) uniform vec3 lightProbe[ 9 ]; @@ -7179,7 +7179,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); return irradiance; } -#endif`,ycn=`#ifdef USE_ENVMAP +#endif`,Scn=`#ifdef USE_ENVMAP vec3 getIBLIrradiance( const in vec3 normal ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); @@ -7212,8 +7212,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi #endif } #endif -#endif`,xcn=`ToonMaterial material; -material.diffuseColor = diffuseColor.rgb;`,Ecn=`varying vec3 vViewPosition; +#endif`,Mcn=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,Tcn=`varying vec3 vViewPosition; struct ToonMaterial { vec3 diffuseColor; }; @@ -7225,11 +7225,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon -#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Scn=`BlinnPhongMaterial material; +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Ccn=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; -material.specularStrength = specularStrength;`,Mcn=`varying vec3 vViewPosition; +material.specularStrength = specularStrength;`,Acn=`varying vec3 vViewPosition; struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; @@ -7246,7 +7246,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_BlinnPhong -#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Tcn=`PhysicalMaterial material; +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Pcn=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); @@ -7329,7 +7329,7 @@ material.roughness = min( material.roughness, 1.0 ); material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; -#endif`,Ccn=`struct PhysicalMaterial { +#endif`,Lcn=`struct PhysicalMaterial { vec3 diffuseColor; float roughness; vec3 specularColor; @@ -7629,7 +7629,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); -}`,Acn=` +}`,kcn=` vec3 geometryPosition = - vViewPosition; vec3 geometryNormal = normal; vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); @@ -7744,7 +7744,7 @@ IncidentLight directLight; #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); -#endif`,Pcn=`#if defined( RE_IndirectDiffuse ) +#endif`,Rcn=`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; @@ -7763,25 +7763,25 @@ IncidentLight directLight; #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); #endif -#endif`,Lcn=`#if defined( RE_IndirectDiffuse ) +#endif`,Icn=`#if defined( RE_IndirectDiffuse ) RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); -#endif`,kcn=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) +#endif`,Dcn=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; -#endif`,Rcn=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) +#endif`,Bcn=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; -#endif`,Icn=`#ifdef USE_LOGDEPTHBUF +#endif`,Ocn=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT varying float vFragDepth; varying float vIsPerspective; #else uniform float logDepthBufFC; #endif -#endif`,Dcn=`#ifdef USE_LOGDEPTHBUF +#endif`,Ncn=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); @@ -7791,16 +7791,16 @@ IncidentLight directLight; gl_Position.z *= gl_Position.w; } #endif -#endif`,Bcn=`#ifdef USE_MAP +#endif`,Fcn=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w ); #endif diffuseColor *= sampledDiffuseColor; -#endif`,Ocn=`#ifdef USE_MAP +#endif`,Ucn=`#ifdef USE_MAP uniform sampler2D map; -#endif`,Ncn=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) +#endif`,zcn=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) #if defined( USE_POINTS_UV ) vec2 uv = vUv; #else @@ -7812,7 +7812,7 @@ IncidentLight directLight; #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; -#endif`,Fcn=`#if defined( USE_POINTS_UV ) +#endif`,Gcn=`#if defined( USE_POINTS_UV ) varying vec2 vUv; #else #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) @@ -7824,13 +7824,13 @@ IncidentLight directLight; #endif #ifdef USE_ALPHAMAP uniform sampler2D alphaMap; -#endif`,Ucn=`float metalnessFactor = metalness; +#endif`,jcn=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; -#endif`,zcn=`#ifdef USE_METALNESSMAP +#endif`,$cn=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; -#endif`,Gcn=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE ) +#endif`,Vcn=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE ) vColor *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { #if defined( USE_COLOR_ALPHA ) @@ -7839,7 +7839,7 @@ IncidentLight directLight; if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; #endif } -#endif`,jcn=`#ifdef USE_MORPHNORMALS +#endif`,Wcn=`#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { @@ -7851,7 +7851,7 @@ IncidentLight directLight; objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; #endif -#endif`,$cn=`#ifdef USE_MORPHTARGETS +#endif`,Hcn=`#ifdef USE_MORPHTARGETS uniform float morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; @@ -7871,7 +7871,7 @@ IncidentLight directLight; uniform float morphTargetInfluences[ 4 ]; #endif #endif -#endif`,Vcn=`#ifdef USE_MORPHTARGETS +#endif`,qcn=`#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { @@ -7889,7 +7889,7 @@ IncidentLight directLight; transformed += morphTarget7 * morphTargetInfluences[ 7 ]; #endif #endif -#endif`,Wcn=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#endif`,Xcn=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; #ifdef FLAT_SHADED vec3 fdx = dFdx( vViewPosition ); vec3 fdy = dFdy( vViewPosition ); @@ -7930,7 +7930,7 @@ IncidentLight directLight; tbn2[1] *= faceDirection; #endif #endif -vec3 nonPerturbedNormal = normal;`,Hcn=`#ifdef USE_NORMALMAP_OBJECTSPACE +vec3 nonPerturbedNormal = normal;`,Ycn=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; @@ -7945,25 +7945,25 @@ vec3 nonPerturbedNormal = normal;`,Hcn=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = normalize( tbn * mapN ); #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); -#endif`,qcn=`#ifndef FLAT_SHADED +#endif`,Zcn=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif -#endif`,Xcn=`#ifndef FLAT_SHADED +#endif`,Kcn=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif -#endif`,Ycn=`#ifndef FLAT_SHADED +#endif`,Jcn=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif -#endif`,Zcn=`#ifdef USE_NORMALMAP +#endif`,Qcn=`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif @@ -7985,13 +7985,13 @@ vec3 nonPerturbedNormal = normal;`,Hcn=`#ifdef USE_NORMALMAP_OBJECTSPACE float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); return mat3( T * scale, B * scale, N ); } -#endif`,Kcn=`#ifdef USE_CLEARCOAT +#endif`,eln=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; -#endif`,Jcn=`#ifdef USE_CLEARCOAT_NORMALMAP +#endif`,tln=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); -#endif`,Qcn=`#ifdef USE_CLEARCOATMAP +#endif`,nln=`#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP @@ -8000,18 +8000,18 @@ vec3 nonPerturbedNormal = normal;`,Hcn=`#ifdef USE_NORMALMAP_OBJECTSPACE #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; -#endif`,eln=`#ifdef USE_IRIDESCENCEMAP +#endif`,iln=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; -#endif`,tln=`#ifdef OPAQUE +#endif`,rln=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif -gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,nln=`vec3 packNormalToRGB( const in vec3 normal ) { +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,sln=`vec3 packNormalToRGB( const in vec3 normal ) { return normalize( normal ) * 0.5 + 0.5; } vec3 unpackRGBToNormal( const in vec3 rgb ) { @@ -8052,9 +8052,9 @@ float viewZToPerspectiveDepth( const in float viewZ, const in float near, const } float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { return ( near * far ) / ( ( far - near ) * depth - far ); -}`,iln=`#ifdef PREMULTIPLIED_ALPHA +}`,oln=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; -#endif`,rln=`vec4 mvPosition = vec4( transformed, 1.0 ); +#endif`,aln=`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING mvPosition = batchingMatrix * mvPosition; #endif @@ -8062,22 +8062,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; -gl_Position = projectionMatrix * mvPosition;`,sln=`#ifdef DITHERING +gl_Position = projectionMatrix * mvPosition;`,cln=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); -#endif`,oln=`#ifdef DITHERING +#endif`,lln=`#ifdef DITHERING vec3 dithering( vec3 color ) { float grid_position = rand( gl_FragCoord.xy ); vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); return color + dither_shift_RGB; } -#endif`,aln=`float roughnessFactor = roughness; +#endif`,uln=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; -#endif`,cln=`#ifdef USE_ROUGHNESSMAP +#endif`,fln=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; -#endif`,lln=`#if NUM_SPOT_LIGHT_COORDS > 0 +#endif`,hln=`#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #if NUM_SPOT_LIGHT_MAPS > 0 @@ -8254,7 +8254,7 @@ gl_Position = projectionMatrix * mvPosition;`,sln=`#ifdef DITHERING return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); #endif } -#endif`,uln=`#if NUM_SPOT_LIGHT_COORDS > 0 +#endif`,dln=`#if NUM_SPOT_LIGHT_COORDS > 0 uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif @@ -8292,7 +8292,7 @@ gl_Position = projectionMatrix * mvPosition;`,sln=`#ifdef DITHERING }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif -#endif`,fln=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) +#endif`,pln=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); vec4 shadowWorldPosition; #endif @@ -8324,7 +8324,7 @@ gl_Position = projectionMatrix * mvPosition;`,sln=`#ifdef DITHERING vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end -#endif`,hln=`float getShadowMask() { +#endif`,gln=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 @@ -8356,12 +8356,12 @@ gl_Position = projectionMatrix * mvPosition;`,sln=`#ifdef DITHERING #endif #endif return shadow; -}`,dln=`#ifdef USE_SKINNING +}`,mln=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); -#endif`,pln=`#ifdef USE_SKINNING +#endif`,bln=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; @@ -8376,7 +8376,7 @@ gl_Position = projectionMatrix * mvPosition;`,sln=`#ifdef DITHERING vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); return mat4( v1, v2, v3, v4 ); } -#endif`,gln=`#ifdef USE_SKINNING +#endif`,wln=`#ifdef USE_SKINNING vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); vec4 skinned = vec4( 0.0 ); skinned += boneMatX * skinVertex * skinWeight.x; @@ -8384,7 +8384,7 @@ gl_Position = projectionMatrix * mvPosition;`,sln=`#ifdef DITHERING skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; -#endif`,mln=`#ifdef USE_SKINNING +#endif`,vln=`#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; @@ -8395,17 +8395,17 @@ gl_Position = projectionMatrix * mvPosition;`,sln=`#ifdef DITHERING #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif -#endif`,bln=`float specularStrength; +#endif`,_ln=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; -#endif`,wln=`#ifdef USE_SPECULARMAP +#endif`,yln=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; -#endif`,vln=`#if defined( TONE_MAPPING ) +#endif`,xln=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); -#endif`,_ln=`#ifndef saturate +#endif`,Eln=`#ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; @@ -8486,7 +8486,7 @@ vec3 AgXToneMapping( vec3 color ) { color = LINEAR_REC2020_TO_LINEAR_SRGB * color; return color; } -vec3 CustomToneMapping( vec3 color ) { return color; }`,yln=`#ifdef USE_TRANSMISSION +vec3 CustomToneMapping( vec3 color ) { return color; }`,Sln=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; @@ -8507,7 +8507,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,yln=`#ifdef USE_TRANSMIS material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); -#endif`,xln=`#ifdef USE_TRANSMISSION +#endif`,Mln=`#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; @@ -8613,7 +8613,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,yln=`#ifdef USE_TRANSMIS float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); } -#endif`,Eln=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,Tln=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP @@ -8683,7 +8683,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,yln=`#ifdef USE_TRANSMIS #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; -#endif`,Sln=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,Cln=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP @@ -8777,7 +8777,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,yln=`#ifdef USE_TRANSMIS #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; -#endif`,Mln=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,Aln=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) vUv = vec3( uv, 1 ).xy; #endif #ifdef USE_MAP @@ -8848,7 +8848,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,yln=`#ifdef USE_TRANSMIS #endif #ifdef USE_THICKNESSMAP vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; -#endif`,Tln=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 +#endif`,Pln=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING worldPosition = batchingMatrix * worldPosition; @@ -8857,12 +8857,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,yln=`#ifdef USE_TRANSMIS worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; -#endif`,Cln=`varying vec2 vUv; +#endif`,Lln=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); -}`,Aln=`uniform sampler2D t2D; +}`,kln=`uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { @@ -8874,14 +8874,14 @@ void main() { gl_FragColor = texColor; #include #include -}`,Pln=`varying vec3 vWorldDirection; +}`,Rln=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; -}`,Lln=`#ifdef ENVMAP_TYPE_CUBE +}`,Iln=`#ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #elif defined( ENVMAP_TYPE_CUBE_UV ) uniform sampler2D envMap; @@ -8903,14 +8903,14 @@ void main() { gl_FragColor = texColor; #include #include -}`,kln=`varying vec3 vWorldDirection; +}`,Dln=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; -}`,Rln=`uniform samplerCube tCube; +}`,Bln=`uniform samplerCube tCube; uniform float tFlip; uniform float opacity; varying vec3 vWorldDirection; @@ -8920,7 +8920,7 @@ void main() { gl_FragColor.a *= opacity; #include #include -}`,Iln=`#include +}`,Oln=`#include #include #include #include @@ -8946,7 +8946,7 @@ void main() { #include #include vHighPrecisionZW = gl_Position.zw; -}`,Dln=`#if DEPTH_PACKING == 3200 +}`,Nln=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include @@ -8976,7 +8976,7 @@ void main() { #elif DEPTH_PACKING == 3201 gl_FragColor = packDepthToRGBA( fragCoordZ ); #endif -}`,Bln=`#define DISTANCE +}`,Fln=`#define DISTANCE varying vec3 vWorldPosition; #include #include @@ -9002,7 +9002,7 @@ void main() { #include #include vWorldPosition = worldPosition.xyz; -}`,Oln=`#define DISTANCE +}`,Uln=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; @@ -9026,13 +9026,13 @@ void main () { dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); -}`,Nln=`varying vec3 vWorldDirection; +}`,zln=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include -}`,Fln=`uniform sampler2D tEquirect; +}`,Gln=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { @@ -9041,7 +9041,7 @@ void main() { gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include -}`,Uln=`uniform float scale; +}`,jln=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include @@ -9062,7 +9062,7 @@ void main() { #include #include #include -}`,zln=`uniform vec3 diffuse; +}`,$ln=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; @@ -9090,7 +9090,7 @@ void main() { #include #include #include -}`,Gln=`#include +}`,Vln=`#include #include #include #include @@ -9121,7 +9121,7 @@ void main() { #include #include #include -}`,jln=`uniform vec3 diffuse; +}`,Wln=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; @@ -9169,7 +9169,7 @@ void main() { #include #include #include -}`,$ln=`#define LAMBERT +}`,Hln=`#define LAMBERT varying vec3 vViewPosition; #include #include @@ -9207,7 +9207,7 @@ void main() { #include #include #include -}`,Vln=`#define LAMBERT +}`,qln=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; @@ -9264,7 +9264,7 @@ void main() { #include #include #include -}`,Wln=`#define MATCAP +}`,Xln=`#define MATCAP varying vec3 vViewPosition; #include #include @@ -9297,7 +9297,7 @@ void main() { #include #include vViewPosition = - mvPosition.xyz; -}`,Hln=`#define MATCAP +}`,Yln=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; @@ -9343,7 +9343,7 @@ void main() { #include #include #include -}`,qln=`#define NORMAL +}`,Zln=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif @@ -9375,7 +9375,7 @@ void main() { #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) vViewPosition = - mvPosition.xyz; #endif -}`,Xln=`#define NORMAL +}`,Kln=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; @@ -9396,7 +9396,7 @@ void main() { #ifdef OPAQUE gl_FragColor.a = 1.0; #endif -}`,Yln=`#define PHONG +}`,Jln=`#define PHONG varying vec3 vViewPosition; #include #include @@ -9434,7 +9434,7 @@ void main() { #include #include #include -}`,Zln=`#define PHONG +}`,Qln=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; @@ -9493,7 +9493,7 @@ void main() { #include #include #include -}`,Kln=`#define STANDARD +}`,eun=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; @@ -9535,7 +9535,7 @@ void main() { #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif -}`,Jln=`#define STANDARD +}`,tun=`#define STANDARD #ifdef PHYSICAL #define IOR #define USE_SPECULAR @@ -9657,7 +9657,7 @@ void main() { #include #include #include -}`,Qln=`#define TOON +}`,nun=`#define TOON varying vec3 vViewPosition; #include #include @@ -9693,7 +9693,7 @@ void main() { #include #include #include -}`,eun=`#define TOON +}`,iun=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; @@ -9746,7 +9746,7 @@ void main() { #include #include #include -}`,tun=`uniform float size; +}`,run=`uniform float size; uniform float scale; #include #include @@ -9776,7 +9776,7 @@ void main() { #include #include #include -}`,nun=`uniform vec3 diffuse; +}`,sun=`uniform vec3 diffuse; uniform float opacity; #include #include @@ -9801,7 +9801,7 @@ void main() { #include #include #include -}`,iun=`#include +}`,oun=`#include #include #include #include @@ -9823,7 +9823,7 @@ void main() { #include #include #include -}`,run=`uniform vec3 color; +}`,aun=`uniform vec3 color; uniform float opacity; #include #include @@ -9839,7 +9839,7 @@ void main() { #include #include #include -}`,sun=`uniform float rotation; +}`,cun=`uniform float rotation; uniform vec2 center; #include #include @@ -9865,7 +9865,7 @@ void main() { #include #include #include -}`,oun=`uniform vec3 diffuse; +}`,lun=`uniform vec3 diffuse; uniform float opacity; #include #include @@ -9890,7 +9890,7 @@ void main() { #include #include #include -}`,Ro={alphahash_fragment:Aan,alphahash_pars_fragment:Pan,alphamap_fragment:Lan,alphamap_pars_fragment:kan,alphatest_fragment:Ran,alphatest_pars_fragment:Ian,aomap_fragment:Dan,aomap_pars_fragment:Ban,batching_pars_vertex:Oan,batching_vertex:Nan,begin_vertex:Fan,beginnormal_vertex:Uan,bsdfs:zan,iridescence_fragment:Gan,bumpmap_pars_fragment:jan,clipping_planes_fragment:$an,clipping_planes_pars_fragment:Van,clipping_planes_pars_vertex:Wan,clipping_planes_vertex:Han,color_fragment:qan,color_pars_fragment:Xan,color_pars_vertex:Yan,color_vertex:Zan,common:Kan,cube_uv_reflection_fragment:Jan,defaultnormal_vertex:Qan,displacementmap_pars_vertex:ecn,displacementmap_vertex:tcn,emissivemap_fragment:ncn,emissivemap_pars_fragment:icn,colorspace_fragment:rcn,colorspace_pars_fragment:scn,envmap_fragment:ocn,envmap_common_pars_fragment:acn,envmap_pars_fragment:ccn,envmap_pars_vertex:lcn,envmap_physical_pars_fragment:ycn,envmap_vertex:ucn,fog_vertex:fcn,fog_pars_vertex:hcn,fog_fragment:dcn,fog_pars_fragment:pcn,gradientmap_pars_fragment:gcn,lightmap_fragment:mcn,lightmap_pars_fragment:bcn,lights_lambert_fragment:wcn,lights_lambert_pars_fragment:vcn,lights_pars_begin:_cn,lights_toon_fragment:xcn,lights_toon_pars_fragment:Ecn,lights_phong_fragment:Scn,lights_phong_pars_fragment:Mcn,lights_physical_fragment:Tcn,lights_physical_pars_fragment:Ccn,lights_fragment_begin:Acn,lights_fragment_maps:Pcn,lights_fragment_end:Lcn,logdepthbuf_fragment:kcn,logdepthbuf_pars_fragment:Rcn,logdepthbuf_pars_vertex:Icn,logdepthbuf_vertex:Dcn,map_fragment:Bcn,map_pars_fragment:Ocn,map_particle_fragment:Ncn,map_particle_pars_fragment:Fcn,metalnessmap_fragment:Ucn,metalnessmap_pars_fragment:zcn,morphcolor_vertex:Gcn,morphnormal_vertex:jcn,morphtarget_pars_vertex:$cn,morphtarget_vertex:Vcn,normal_fragment_begin:Wcn,normal_fragment_maps:Hcn,normal_pars_fragment:qcn,normal_pars_vertex:Xcn,normal_vertex:Ycn,normalmap_pars_fragment:Zcn,clearcoat_normal_fragment_begin:Kcn,clearcoat_normal_fragment_maps:Jcn,clearcoat_pars_fragment:Qcn,iridescence_pars_fragment:eln,opaque_fragment:tln,packing:nln,premultiplied_alpha_fragment:iln,project_vertex:rln,dithering_fragment:sln,dithering_pars_fragment:oln,roughnessmap_fragment:aln,roughnessmap_pars_fragment:cln,shadowmap_pars_fragment:lln,shadowmap_pars_vertex:uln,shadowmap_vertex:fln,shadowmask_pars_fragment:hln,skinbase_vertex:dln,skinning_pars_vertex:pln,skinning_vertex:gln,skinnormal_vertex:mln,specularmap_fragment:bln,specularmap_pars_fragment:wln,tonemapping_fragment:vln,tonemapping_pars_fragment:_ln,transmission_fragment:yln,transmission_pars_fragment:xln,uv_pars_fragment:Eln,uv_pars_vertex:Sln,uv_vertex:Mln,worldpos_vertex:Tln,background_vert:Cln,background_frag:Aln,backgroundCube_vert:Pln,backgroundCube_frag:Lln,cube_vert:kln,cube_frag:Rln,depth_vert:Iln,depth_frag:Dln,distanceRGBA_vert:Bln,distanceRGBA_frag:Oln,equirect_vert:Nln,equirect_frag:Fln,linedashed_vert:Uln,linedashed_frag:zln,meshbasic_vert:Gln,meshbasic_frag:jln,meshlambert_vert:$ln,meshlambert_frag:Vln,meshmatcap_vert:Wln,meshmatcap_frag:Hln,meshnormal_vert:qln,meshnormal_frag:Xln,meshphong_vert:Yln,meshphong_frag:Zln,meshphysical_vert:Kln,meshphysical_frag:Jln,meshtoon_vert:Qln,meshtoon_frag:eun,points_vert:tun,points_frag:nun,shadow_vert:iun,shadow_frag:run,sprite_vert:sun,sprite_frag:oun},ji={common:{diffuse:{value:new Go(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Xo},alphaMap:{value:null},alphaMapTransform:{value:new Xo},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Xo}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Xo}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Xo}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Xo},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Xo},normalScale:{value:new ka(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Xo},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Xo}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Xo}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Xo}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Go(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Go(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Xo},alphaTest:{value:0},uvTransform:{value:new Xo}},sprite:{diffuse:{value:new Go(16777215)},opacity:{value:1},center:{value:new ka(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Xo},alphaMap:{value:null},alphaMapTransform:{value:new Xo},alphaTest:{value:0}}},f2={basic:{uniforms:hg([ji.common,ji.specularmap,ji.envmap,ji.aomap,ji.lightmap,ji.fog]),vertexShader:Ro.meshbasic_vert,fragmentShader:Ro.meshbasic_frag},lambert:{uniforms:hg([ji.common,ji.specularmap,ji.envmap,ji.aomap,ji.lightmap,ji.emissivemap,ji.bumpmap,ji.normalmap,ji.displacementmap,ji.fog,ji.lights,{emissive:{value:new Go(0)}}]),vertexShader:Ro.meshlambert_vert,fragmentShader:Ro.meshlambert_frag},phong:{uniforms:hg([ji.common,ji.specularmap,ji.envmap,ji.aomap,ji.lightmap,ji.emissivemap,ji.bumpmap,ji.normalmap,ji.displacementmap,ji.fog,ji.lights,{emissive:{value:new Go(0)},specular:{value:new Go(1118481)},shininess:{value:30}}]),vertexShader:Ro.meshphong_vert,fragmentShader:Ro.meshphong_frag},standard:{uniforms:hg([ji.common,ji.envmap,ji.aomap,ji.lightmap,ji.emissivemap,ji.bumpmap,ji.normalmap,ji.displacementmap,ji.roughnessmap,ji.metalnessmap,ji.fog,ji.lights,{emissive:{value:new Go(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ro.meshphysical_vert,fragmentShader:Ro.meshphysical_frag},toon:{uniforms:hg([ji.common,ji.aomap,ji.lightmap,ji.emissivemap,ji.bumpmap,ji.normalmap,ji.displacementmap,ji.gradientmap,ji.fog,ji.lights,{emissive:{value:new Go(0)}}]),vertexShader:Ro.meshtoon_vert,fragmentShader:Ro.meshtoon_frag},matcap:{uniforms:hg([ji.common,ji.bumpmap,ji.normalmap,ji.displacementmap,ji.fog,{matcap:{value:null}}]),vertexShader:Ro.meshmatcap_vert,fragmentShader:Ro.meshmatcap_frag},points:{uniforms:hg([ji.points,ji.fog]),vertexShader:Ro.points_vert,fragmentShader:Ro.points_frag},dashed:{uniforms:hg([ji.common,ji.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ro.linedashed_vert,fragmentShader:Ro.linedashed_frag},depth:{uniforms:hg([ji.common,ji.displacementmap]),vertexShader:Ro.depth_vert,fragmentShader:Ro.depth_frag},normal:{uniforms:hg([ji.common,ji.bumpmap,ji.normalmap,ji.displacementmap,{opacity:{value:1}}]),vertexShader:Ro.meshnormal_vert,fragmentShader:Ro.meshnormal_frag},sprite:{uniforms:hg([ji.sprite,ji.fog]),vertexShader:Ro.sprite_vert,fragmentShader:Ro.sprite_frag},background:{uniforms:{uvTransform:{value:new Xo},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ro.background_vert,fragmentShader:Ro.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Ro.backgroundCube_vert,fragmentShader:Ro.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ro.cube_vert,fragmentShader:Ro.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ro.equirect_vert,fragmentShader:Ro.equirect_frag},distanceRGBA:{uniforms:hg([ji.common,ji.displacementmap,{referencePosition:{value:new Gt},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ro.distanceRGBA_vert,fragmentShader:Ro.distanceRGBA_frag},shadow:{uniforms:hg([ji.lights,ji.fog,{color:{value:new Go(0)},opacity:{value:1}}]),vertexShader:Ro.shadow_vert,fragmentShader:Ro.shadow_frag}};f2.physical={uniforms:hg([f2.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Xo},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Xo},clearcoatNormalScale:{value:new ka(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Xo},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Xo},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Xo},sheen:{value:0},sheenColor:{value:new Go(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Xo},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Xo},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Xo},transmissionSamplerSize:{value:new ka},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Xo},attenuationDistance:{value:0},attenuationColor:{value:new Go(0)},specularColor:{value:new Go(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Xo},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Xo},anisotropyVector:{value:new ka},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Xo}}]),vertexShader:Ro.meshphysical_vert,fragmentShader:Ro.meshphysical_frag};var Ife={r:0,b:0,g:0};function aun(s,n,r,c,u,d,b){let w=new Go(0),_=d===!0?0:1,x,T,M=null,L=0,I=null;function D(O,z){let Z=!1,H=z.isScene===!0?z.background:null;H&&H.isTexture&&(H=(z.backgroundBlurriness>0?r:n).get(H)),H===null?F(w,_):H&&H.isColor&&(F(H,1),Z=!0);let te=s.xr.getEnvironmentBlendMode();te==="additive"?c.buffers.color.setClear(0,0,0,1,b):te==="alpha-blend"&&c.buffers.color.setClear(0,0,0,0,b),(s.autoClear||Z)&&s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil),H&&(H.isCubeTexture||H.mapping===bhe)?(T===void 0&&(T=new Mm(new X4(1,1,1),new J3({name:"BackgroundCubeMaterial",uniforms:dO(f2.backgroundCube.uniforms),vertexShader:f2.backgroundCube.vertexShader,fragmentShader:f2.backgroundCube.fragmentShader,side:Tm,depthTest:!1,depthWrite:!1,fog:!1})),T.geometry.deleteAttribute("normal"),T.geometry.deleteAttribute("uv"),T.onBeforeRender=function(oe,ne,ue){this.matrixWorld.copyPosition(ue.matrixWorld)},Object.defineProperty(T.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),u.update(T)),T.material.uniforms.envMap.value=H,T.material.uniforms.flipEnvMap.value=H.isCubeTexture&&H.isRenderTargetTexture===!1?-1:1,T.material.uniforms.backgroundBlurriness.value=z.backgroundBlurriness,T.material.uniforms.backgroundIntensity.value=z.backgroundIntensity,T.material.toneMapped=Pc.getTransfer(H.colorSpace)!==dl,(M!==H||L!==H.version||I!==s.toneMapping)&&(T.material.needsUpdate=!0,M=H,L=H.version,I=s.toneMapping),T.layers.enableAll(),O.unshift(T,T.geometry,T.material,0,0,null)):H&&H.isTexture&&(x===void 0&&(x=new Mm(new B6e(2,2),new J3({name:"BackgroundMaterial",uniforms:dO(f2.background.uniforms),vertexShader:f2.background.vertexShader,fragmentShader:f2.background.fragmentShader,side:bT,depthTest:!1,depthWrite:!1,fog:!1})),x.geometry.deleteAttribute("normal"),Object.defineProperty(x.material,"map",{get:function(){return this.uniforms.t2D.value}}),u.update(x)),x.material.uniforms.t2D.value=H,x.material.uniforms.backgroundIntensity.value=z.backgroundIntensity,x.material.toneMapped=Pc.getTransfer(H.colorSpace)!==dl,H.matrixAutoUpdate===!0&&H.updateMatrix(),x.material.uniforms.uvTransform.value.copy(H.matrix),(M!==H||L!==H.version||I!==s.toneMapping)&&(x.material.needsUpdate=!0,M=H,L=H.version,I=s.toneMapping),x.layers.enableAll(),O.unshift(x,x.geometry,x.material,0,0,null))}function F(O,z){O.getRGB(Ife,P2t(s)),c.buffers.color.setClear(Ife.r,Ife.g,Ife.b,z,b)}return{getClearColor:function(){return w},setClearColor:function(O,z=1){w.set(O),_=z,F(w,_)},getClearAlpha:function(){return _},setClearAlpha:function(O){_=O,F(w,_)},render:D}}function cun(s,n,r,c){let u=s.getParameter(s.MAX_VERTEX_ATTRIBS),d=c.isWebGL2?null:n.get("OES_vertex_array_object"),b=c.isWebGL2||d!==null,w={},_=O(null),x=_,T=!1;function M(Ne,tt,ot,Tt,jt){let en=!1;if(b){let mn=F(Tt,ot,tt);x!==mn&&(x=mn,I(x.object)),en=z(Ne,Tt,ot,jt),en&&Z(Ne,Tt,ot,jt)}else{let mn=tt.wireframe===!0;(x.geometry!==Tt.id||x.program!==ot.id||x.wireframe!==mn)&&(x.geometry=Tt.id,x.program=ot.id,x.wireframe=mn,en=!0)}jt!==null&&r.update(jt,s.ELEMENT_ARRAY_BUFFER),(en||T)&&(T=!1,Te(Ne,tt,ot,Tt),jt!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,r.get(jt).buffer))}function L(){return c.isWebGL2?s.createVertexArray():d.createVertexArrayOES()}function I(Ne){return c.isWebGL2?s.bindVertexArray(Ne):d.bindVertexArrayOES(Ne)}function D(Ne){return c.isWebGL2?s.deleteVertexArray(Ne):d.deleteVertexArrayOES(Ne)}function F(Ne,tt,ot){let Tt=ot.wireframe===!0,jt=w[Ne.id];jt===void 0&&(jt={},w[Ne.id]=jt);let en=jt[tt.id];en===void 0&&(en={},jt[tt.id]=en);let mn=en[Tt];return mn===void 0&&(mn=O(L()),en[Tt]=mn),mn}function O(Ne){let tt=[],ot=[],Tt=[];for(let jt=0;jt=0){let pn=jt[bi],qn=en[bi];if(qn===void 0&&(bi==="instanceMatrix"&&Ne.instanceMatrix&&(qn=Ne.instanceMatrix),bi==="instanceColor"&&Ne.instanceColor&&(qn=Ne.instanceColor)),pn===void 0||pn.attribute!==qn||qn&&pn.data!==qn.data)return!0;mn++}return x.attributesNum!==mn||x.index!==Tt}function Z(Ne,tt,ot,Tt){let jt={},en=tt.attributes,mn=0,cn=ot.getAttributes();for(let bi in cn)if(cn[bi].location>=0){let pn=en[bi];pn===void 0&&(bi==="instanceMatrix"&&Ne.instanceMatrix&&(pn=Ne.instanceMatrix),bi==="instanceColor"&&Ne.instanceColor&&(pn=Ne.instanceColor));let qn={};qn.attribute=pn,pn&&pn.data&&(qn.data=pn.data),jt[bi]=qn,mn++}x.attributes=jt,x.attributesNum=mn,x.index=Tt}function H(){let Ne=x.newAttributes;for(let tt=0,ot=Ne.length;tt=0){let Vt=jt[cn];if(Vt===void 0&&(cn==="instanceMatrix"&&Ne.instanceMatrix&&(Vt=Ne.instanceMatrix),cn==="instanceColor"&&Ne.instanceColor&&(Vt=Ne.instanceColor)),Vt!==void 0){let pn=Vt.normalized,qn=Vt.itemSize,Yi=r.get(Vt);if(Yi===void 0)continue;let $i=Yi.buffer,Tr=Yi.type,wr=Yi.bytesPerElement,Si=c.isWebGL2===!0&&(Tr===s.INT||Tr===s.UNSIGNED_INT||Vt.gpuType===b2t);if(Vt.isInterleavedBufferAttribute){let Fr=Vt.data,se=Fr.stride,de=Vt.offset;if(Fr.isInstancedInterleavedBuffer){for(let it=0;it0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";ue="mediump"}return ue==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let b=typeof WebGL2RenderingContext<"u"&&s.constructor.name==="WebGL2RenderingContext",w=r.precision!==void 0?r.precision:"highp",_=d(w);_!==w&&(console.warn("THREE.WebGLRenderer:",w,"not supported, using",_,"instead."),w=_);let x=b||n.has("WEBGL_draw_buffers"),T=r.logarithmicDepthBuffer===!0,M=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),L=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),I=s.getParameter(s.MAX_TEXTURE_SIZE),D=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),F=s.getParameter(s.MAX_VERTEX_ATTRIBS),O=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),z=s.getParameter(s.MAX_VARYING_VECTORS),Z=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),H=L>0,te=b||n.has("OES_texture_float"),oe=H&&te,ne=b?s.getParameter(s.MAX_SAMPLES):0;return{isWebGL2:b,drawBuffers:x,getMaxAnisotropy:u,getMaxPrecision:d,precision:w,logarithmicDepthBuffer:T,maxTextures:M,maxVertexTextures:L,maxTextureSize:I,maxCubemapSize:D,maxAttributes:F,maxVertexUniforms:O,maxVaryings:z,maxFragmentUniforms:Z,vertexTextures:H,floatFragmentTextures:te,floatVertexTextures:oe,maxSamples:ne}}function fun(s){let n=this,r=null,c=0,u=!1,d=!1,b=new q3,w=new Xo,_={value:null,needsUpdate:!1};this.uniform=_,this.numPlanes=0,this.numIntersection=0,this.init=function(M,L){let I=M.length!==0||L||c!==0||u;return u=L,c=M.length,I},this.beginShadows=function(){d=!0,T(null)},this.endShadows=function(){d=!1},this.setGlobalState=function(M,L){r=T(M,L,0)},this.setState=function(M,L,I){let D=M.clippingPlanes,F=M.clipIntersection,O=M.clipShadows,z=s.get(M);if(!u||D===null||D.length===0||d&&!O)d?T(null):x();else{let Z=d?0:c,H=Z*4,te=z.clippingState||null;_.value=te,te=T(D,L,H,I);for(let oe=0;oe!==H;++oe)te[oe]=r[oe];z.clippingState=te,this.numIntersection=F?this.numPlanes:0,this.numPlanes+=Z}};function x(){_.value!==r&&(_.value=r,_.needsUpdate=c>0),n.numPlanes=c,n.numIntersection=0}function T(M,L,I,D){let F=M!==null?M.length:0,O=null;if(F!==0){if(O=_.value,D!==!0||O===null){let z=I+F*4,Z=L.matrixWorldInverse;w.getNormalMatrix(Z),(O===null||O.length0){let x=new D6e(_.height/2);return x.fromEquirectangularTexture(s,b),n.set(b,x),b.addEventListener("dispose",u),r(x.texture,b.mapping)}else return null}}return b}function u(b){let w=b.target;w.removeEventListener("dispose",u);let _=n.get(w);_!==void 0&&(n.delete(w),_.dispose())}function d(){n=new WeakMap}return{get:c,dispose:d}}var rhe=class extends nhe{constructor(n=-1,r=1,c=1,u=-1,d=.1,b=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=n,this.right=r,this.top=c,this.bottom=u,this.near=d,this.far=b,this.updateProjectionMatrix()}copy(n,r){return super.copy(n,r),this.left=n.left,this.right=n.right,this.top=n.top,this.bottom=n.bottom,this.near=n.near,this.far=n.far,this.zoom=n.zoom,this.view=n.view===null?null:Object.assign({},n.view),this}setViewOffset(n,r,c,u,d,b){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=n,this.view.fullHeight=r,this.view.offsetX=c,this.view.offsetY=u,this.view.width=d,this.view.height=b,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let n=(this.right-this.left)/(2*this.zoom),r=(this.top-this.bottom)/(2*this.zoom),c=(this.right+this.left)/2,u=(this.top+this.bottom)/2,d=c-n,b=c+n,w=u+r,_=u-r;if(this.view!==null&&this.view.enabled){let x=(this.right-this.left)/this.view.fullWidth/this.zoom,T=(this.top-this.bottom)/this.view.fullHeight/this.zoom;d+=x*this.view.offsetX,b=d+x*this.view.width,w-=T*this.view.offsetY,_=w-T*this.view.height}this.projectionMatrix.makeOrthographic(d,b,w,_,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(n){let r=super.toJSON(n);return r.object.zoom=this.zoom,r.object.left=this.left,r.object.right=this.right,r.object.top=this.top,r.object.bottom=this.bottom,r.object.near=this.near,r.object.far=this.far,this.view!==null&&(r.object.view=Object.assign({},this.view)),r}},rO=4,Fyt=[.125,.215,.35,.446,.526,.582],$4=20,p6e=new rhe,Uyt=new Go,g6e=null,m6e=0,b6e=0,G4=(1+Math.sqrt(5))/2,nO=1/G4,zyt=[new Gt(1,1,1),new Gt(-1,1,1),new Gt(1,1,-1),new Gt(-1,1,-1),new Gt(0,G4,nO),new Gt(0,G4,-nO),new Gt(nO,0,G4),new Gt(-nO,0,G4),new Gt(G4,nO,0),new Gt(-G4,nO,0)],she=class{constructor(n){this._renderer=n,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(n,r=0,c=.1,u=100){g6e=this._renderer.getRenderTarget(),m6e=this._renderer.getActiveCubeFace(),b6e=this._renderer.getActiveMipmapLevel(),this._setSize(256);let d=this._allocateTargets();return d.depthBuffer=!0,this._sceneToCubeUV(n,c,u,d),r>0&&this._blur(d,0,0,r),this._applyPMREM(d),this._cleanup(d),d}fromEquirectangular(n,r=null){return this._fromTexture(n,r)}fromCubemap(n,r=null){return this._fromTexture(n,r)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=$yt(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=jyt(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(n){this._lodMax=Math.floor(Math.log2(n)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let n=0;n2?H:0,H,H),T.setRenderTarget(u),F&&T.render(D,w),T.render(n,w)}D.geometry.dispose(),D.material.dispose(),T.toneMapping=L,T.autoClear=M,n.background=O}_textureToCubeUV(n,r){let c=this._renderer,u=n.mapping===lO||n.mapping===uO;u?(this._cubemapMaterial===null&&(this._cubemapMaterial=$yt()),this._cubemapMaterial.uniforms.flipEnvMap.value=n.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=jyt());let d=u?this._cubemapMaterial:this._equirectMaterial,b=new Mm(this._lodPlanes[0],d),w=d.uniforms;w.envMap.value=n;let _=this._cubeSize;Dfe(r,0,0,3*_,2*_),c.setRenderTarget(r),c.render(b,p6e)}_applyPMREM(n){let r=this._renderer,c=r.autoClear;r.autoClear=!1;for(let u=1;u$4&&console.warn(`sigmaRadians, ${d}, is too large and will clip, as it requested ${O} samples when the maximum is set to ${$4}`);let z=[],Z=0;for(let ue=0;ue<$4;++ue){let Te=ue/F,Q=Math.exp(-Te*Te/2);z.push(Q),ue===0?Z+=Q:ueH-rO?u-H+rO:0),ne=4*(this._cubeSize-te);Dfe(r,oe,ne,3*te,2*te),_.setRenderTarget(r),_.render(M,p6e)}};function dun(s){let n=[],r=[],c=[],u=s,d=s-rO+1+Fyt.length;for(let b=0;bs-rO?_=Fyt[b-s+rO-1]:b===0&&(_=0),c.push(_);let x=1/(w-2),T=-x,M=1+x,L=[T,T,M,T,M,M,T,T,M,M,T,M],I=6,D=6,F=3,O=2,z=1,Z=new Float32Array(F*D*I),H=new Float32Array(O*D*I),te=new Float32Array(z*D*I);for(let ne=0;ne2?0:-1,Q=[ue,Te,0,ue+2/3,Te,0,ue+2/3,Te+1,0,ue,Te,0,ue+2/3,Te+1,0,ue,Te+1,0];Z.set(Q,F*D*ne),H.set(L,O*D*ne);let ge=[ne,ne,ne,ne,ne,ne];te.set(ge,z*D*ne)}let oe=new d2;oe.setAttribute("position",new q1(Z,F)),oe.setAttribute("uv",new q1(H,O)),oe.setAttribute("faceIndex",new q1(te,z)),n.push(oe),u>rO&&u--}return{lodPlanes:n,sizeLods:r,sigmas:c}}function Gyt(s,n,r){let c=new Z3(s,n,r);return c.texture.mapping=bhe,c.texture.name="PMREM.cubeUv",c.scissorTest=!0,c}function Dfe(s,n,r,c,u){s.viewport.set(n,r,c,u),s.scissor.set(n,r,c,u)}function pun(s,n,r){let c=new Float32Array($4),u=new Gt(0,1,0);return new J3({name:"SphericalGaussianBlur",defines:{n:$4,CUBEUV_TEXEL_WIDTH:1/n,CUBEUV_TEXEL_HEIGHT:1/r,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:c},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:u}},vertexShader:f5e(),fragmentShader:` +}`,Ro={alphahash_fragment:kan,alphahash_pars_fragment:Ran,alphamap_fragment:Ian,alphamap_pars_fragment:Dan,alphatest_fragment:Ban,alphatest_pars_fragment:Oan,aomap_fragment:Nan,aomap_pars_fragment:Fan,batching_pars_vertex:Uan,batching_vertex:zan,begin_vertex:Gan,beginnormal_vertex:jan,bsdfs:$an,iridescence_fragment:Van,bumpmap_pars_fragment:Wan,clipping_planes_fragment:Han,clipping_planes_pars_fragment:qan,clipping_planes_pars_vertex:Xan,clipping_planes_vertex:Yan,color_fragment:Zan,color_pars_fragment:Kan,color_pars_vertex:Jan,color_vertex:Qan,common:ecn,cube_uv_reflection_fragment:tcn,defaultnormal_vertex:ncn,displacementmap_pars_vertex:icn,displacementmap_vertex:rcn,emissivemap_fragment:scn,emissivemap_pars_fragment:ocn,colorspace_fragment:acn,colorspace_pars_fragment:ccn,envmap_fragment:lcn,envmap_common_pars_fragment:ucn,envmap_pars_fragment:fcn,envmap_pars_vertex:hcn,envmap_physical_pars_fragment:Scn,envmap_vertex:dcn,fog_vertex:pcn,fog_pars_vertex:gcn,fog_fragment:mcn,fog_pars_fragment:bcn,gradientmap_pars_fragment:wcn,lightmap_fragment:vcn,lightmap_pars_fragment:_cn,lights_lambert_fragment:ycn,lights_lambert_pars_fragment:xcn,lights_pars_begin:Ecn,lights_toon_fragment:Mcn,lights_toon_pars_fragment:Tcn,lights_phong_fragment:Ccn,lights_phong_pars_fragment:Acn,lights_physical_fragment:Pcn,lights_physical_pars_fragment:Lcn,lights_fragment_begin:kcn,lights_fragment_maps:Rcn,lights_fragment_end:Icn,logdepthbuf_fragment:Dcn,logdepthbuf_pars_fragment:Bcn,logdepthbuf_pars_vertex:Ocn,logdepthbuf_vertex:Ncn,map_fragment:Fcn,map_pars_fragment:Ucn,map_particle_fragment:zcn,map_particle_pars_fragment:Gcn,metalnessmap_fragment:jcn,metalnessmap_pars_fragment:$cn,morphcolor_vertex:Vcn,morphnormal_vertex:Wcn,morphtarget_pars_vertex:Hcn,morphtarget_vertex:qcn,normal_fragment_begin:Xcn,normal_fragment_maps:Ycn,normal_pars_fragment:Zcn,normal_pars_vertex:Kcn,normal_vertex:Jcn,normalmap_pars_fragment:Qcn,clearcoat_normal_fragment_begin:eln,clearcoat_normal_fragment_maps:tln,clearcoat_pars_fragment:nln,iridescence_pars_fragment:iln,opaque_fragment:rln,packing:sln,premultiplied_alpha_fragment:oln,project_vertex:aln,dithering_fragment:cln,dithering_pars_fragment:lln,roughnessmap_fragment:uln,roughnessmap_pars_fragment:fln,shadowmap_pars_fragment:hln,shadowmap_pars_vertex:dln,shadowmap_vertex:pln,shadowmask_pars_fragment:gln,skinbase_vertex:mln,skinning_pars_vertex:bln,skinning_vertex:wln,skinnormal_vertex:vln,specularmap_fragment:_ln,specularmap_pars_fragment:yln,tonemapping_fragment:xln,tonemapping_pars_fragment:Eln,transmission_fragment:Sln,transmission_pars_fragment:Mln,uv_pars_fragment:Tln,uv_pars_vertex:Cln,uv_vertex:Aln,worldpos_vertex:Pln,background_vert:Lln,background_frag:kln,backgroundCube_vert:Rln,backgroundCube_frag:Iln,cube_vert:Dln,cube_frag:Bln,depth_vert:Oln,depth_frag:Nln,distanceRGBA_vert:Fln,distanceRGBA_frag:Uln,equirect_vert:zln,equirect_frag:Gln,linedashed_vert:jln,linedashed_frag:$ln,meshbasic_vert:Vln,meshbasic_frag:Wln,meshlambert_vert:Hln,meshlambert_frag:qln,meshmatcap_vert:Xln,meshmatcap_frag:Yln,meshnormal_vert:Zln,meshnormal_frag:Kln,meshphong_vert:Jln,meshphong_frag:Qln,meshphysical_vert:eun,meshphysical_frag:tun,meshtoon_vert:nun,meshtoon_frag:iun,points_vert:run,points_frag:sun,shadow_vert:oun,shadow_frag:aun,sprite_vert:cun,sprite_frag:lun},ji={common:{diffuse:{value:new Go(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Xo},alphaMap:{value:null},alphaMapTransform:{value:new Xo},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Xo}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Xo}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Xo}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Xo},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Xo},normalScale:{value:new ka(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Xo},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Xo}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Xo}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Xo}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Go(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Go(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Xo},alphaTest:{value:0},uvTransform:{value:new Xo}},sprite:{diffuse:{value:new Go(16777215)},opacity:{value:1},center:{value:new ka(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Xo},alphaMap:{value:null},alphaMapTransform:{value:new Xo},alphaTest:{value:0}}},f2={basic:{uniforms:hg([ji.common,ji.specularmap,ji.envmap,ji.aomap,ji.lightmap,ji.fog]),vertexShader:Ro.meshbasic_vert,fragmentShader:Ro.meshbasic_frag},lambert:{uniforms:hg([ji.common,ji.specularmap,ji.envmap,ji.aomap,ji.lightmap,ji.emissivemap,ji.bumpmap,ji.normalmap,ji.displacementmap,ji.fog,ji.lights,{emissive:{value:new Go(0)}}]),vertexShader:Ro.meshlambert_vert,fragmentShader:Ro.meshlambert_frag},phong:{uniforms:hg([ji.common,ji.specularmap,ji.envmap,ji.aomap,ji.lightmap,ji.emissivemap,ji.bumpmap,ji.normalmap,ji.displacementmap,ji.fog,ji.lights,{emissive:{value:new Go(0)},specular:{value:new Go(1118481)},shininess:{value:30}}]),vertexShader:Ro.meshphong_vert,fragmentShader:Ro.meshphong_frag},standard:{uniforms:hg([ji.common,ji.envmap,ji.aomap,ji.lightmap,ji.emissivemap,ji.bumpmap,ji.normalmap,ji.displacementmap,ji.roughnessmap,ji.metalnessmap,ji.fog,ji.lights,{emissive:{value:new Go(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ro.meshphysical_vert,fragmentShader:Ro.meshphysical_frag},toon:{uniforms:hg([ji.common,ji.aomap,ji.lightmap,ji.emissivemap,ji.bumpmap,ji.normalmap,ji.displacementmap,ji.gradientmap,ji.fog,ji.lights,{emissive:{value:new Go(0)}}]),vertexShader:Ro.meshtoon_vert,fragmentShader:Ro.meshtoon_frag},matcap:{uniforms:hg([ji.common,ji.bumpmap,ji.normalmap,ji.displacementmap,ji.fog,{matcap:{value:null}}]),vertexShader:Ro.meshmatcap_vert,fragmentShader:Ro.meshmatcap_frag},points:{uniforms:hg([ji.points,ji.fog]),vertexShader:Ro.points_vert,fragmentShader:Ro.points_frag},dashed:{uniforms:hg([ji.common,ji.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ro.linedashed_vert,fragmentShader:Ro.linedashed_frag},depth:{uniforms:hg([ji.common,ji.displacementmap]),vertexShader:Ro.depth_vert,fragmentShader:Ro.depth_frag},normal:{uniforms:hg([ji.common,ji.bumpmap,ji.normalmap,ji.displacementmap,{opacity:{value:1}}]),vertexShader:Ro.meshnormal_vert,fragmentShader:Ro.meshnormal_frag},sprite:{uniforms:hg([ji.sprite,ji.fog]),vertexShader:Ro.sprite_vert,fragmentShader:Ro.sprite_frag},background:{uniforms:{uvTransform:{value:new Xo},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ro.background_vert,fragmentShader:Ro.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Ro.backgroundCube_vert,fragmentShader:Ro.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ro.cube_vert,fragmentShader:Ro.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ro.equirect_vert,fragmentShader:Ro.equirect_frag},distanceRGBA:{uniforms:hg([ji.common,ji.displacementmap,{referencePosition:{value:new Gt},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ro.distanceRGBA_vert,fragmentShader:Ro.distanceRGBA_frag},shadow:{uniforms:hg([ji.lights,ji.fog,{color:{value:new Go(0)},opacity:{value:1}}]),vertexShader:Ro.shadow_vert,fragmentShader:Ro.shadow_frag}};f2.physical={uniforms:hg([f2.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Xo},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Xo},clearcoatNormalScale:{value:new ka(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Xo},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Xo},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Xo},sheen:{value:0},sheenColor:{value:new Go(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Xo},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Xo},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Xo},transmissionSamplerSize:{value:new ka},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Xo},attenuationDistance:{value:0},attenuationColor:{value:new Go(0)},specularColor:{value:new Go(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Xo},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Xo},anisotropyVector:{value:new ka},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Xo}}]),vertexShader:Ro.meshphysical_vert,fragmentShader:Ro.meshphysical_frag};var Ife={r:0,b:0,g:0};function uun(s,n,r,c,u,d,b){let w=new Go(0),_=d===!0?0:1,x,T,M=null,L=0,I=null;function D(O,z){let Z=!1,H=z.isScene===!0?z.background:null;H&&H.isTexture&&(H=(z.backgroundBlurriness>0?r:n).get(H)),H===null?F(w,_):H&&H.isColor&&(F(H,1),Z=!0);let te=s.xr.getEnvironmentBlendMode();te==="additive"?c.buffers.color.setClear(0,0,0,1,b):te==="alpha-blend"&&c.buffers.color.setClear(0,0,0,0,b),(s.autoClear||Z)&&s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil),H&&(H.isCubeTexture||H.mapping===bhe)?(T===void 0&&(T=new Mm(new X4(1,1,1),new J3({name:"BackgroundCubeMaterial",uniforms:dO(f2.backgroundCube.uniforms),vertexShader:f2.backgroundCube.vertexShader,fragmentShader:f2.backgroundCube.fragmentShader,side:Tm,depthTest:!1,depthWrite:!1,fog:!1})),T.geometry.deleteAttribute("normal"),T.geometry.deleteAttribute("uv"),T.onBeforeRender=function(oe,ne,ue){this.matrixWorld.copyPosition(ue.matrixWorld)},Object.defineProperty(T.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),u.update(T)),T.material.uniforms.envMap.value=H,T.material.uniforms.flipEnvMap.value=H.isCubeTexture&&H.isRenderTargetTexture===!1?-1:1,T.material.uniforms.backgroundBlurriness.value=z.backgroundBlurriness,T.material.uniforms.backgroundIntensity.value=z.backgroundIntensity,T.material.toneMapped=Pc.getTransfer(H.colorSpace)!==dl,(M!==H||L!==H.version||I!==s.toneMapping)&&(T.material.needsUpdate=!0,M=H,L=H.version,I=s.toneMapping),T.layers.enableAll(),O.unshift(T,T.geometry,T.material,0,0,null)):H&&H.isTexture&&(x===void 0&&(x=new Mm(new B6e(2,2),new J3({name:"BackgroundMaterial",uniforms:dO(f2.background.uniforms),vertexShader:f2.background.vertexShader,fragmentShader:f2.background.fragmentShader,side:bT,depthTest:!1,depthWrite:!1,fog:!1})),x.geometry.deleteAttribute("normal"),Object.defineProperty(x.material,"map",{get:function(){return this.uniforms.t2D.value}}),u.update(x)),x.material.uniforms.t2D.value=H,x.material.uniforms.backgroundIntensity.value=z.backgroundIntensity,x.material.toneMapped=Pc.getTransfer(H.colorSpace)!==dl,H.matrixAutoUpdate===!0&&H.updateMatrix(),x.material.uniforms.uvTransform.value.copy(H.matrix),(M!==H||L!==H.version||I!==s.toneMapping)&&(x.material.needsUpdate=!0,M=H,L=H.version,I=s.toneMapping),x.layers.enableAll(),O.unshift(x,x.geometry,x.material,0,0,null))}function F(O,z){O.getRGB(Ife,P2t(s)),c.buffers.color.setClear(Ife.r,Ife.g,Ife.b,z,b)}return{getClearColor:function(){return w},setClearColor:function(O,z=1){w.set(O),_=z,F(w,_)},getClearAlpha:function(){return _},setClearAlpha:function(O){_=O,F(w,_)},render:D}}function fun(s,n,r,c){let u=s.getParameter(s.MAX_VERTEX_ATTRIBS),d=c.isWebGL2?null:n.get("OES_vertex_array_object"),b=c.isWebGL2||d!==null,w={},_=O(null),x=_,T=!1;function M(Ne,tt,ot,Tt,jt){let en=!1;if(b){let mn=F(Tt,ot,tt);x!==mn&&(x=mn,I(x.object)),en=z(Ne,Tt,ot,jt),en&&Z(Ne,Tt,ot,jt)}else{let mn=tt.wireframe===!0;(x.geometry!==Tt.id||x.program!==ot.id||x.wireframe!==mn)&&(x.geometry=Tt.id,x.program=ot.id,x.wireframe=mn,en=!0)}jt!==null&&r.update(jt,s.ELEMENT_ARRAY_BUFFER),(en||T)&&(T=!1,Te(Ne,tt,ot,Tt),jt!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,r.get(jt).buffer))}function L(){return c.isWebGL2?s.createVertexArray():d.createVertexArrayOES()}function I(Ne){return c.isWebGL2?s.bindVertexArray(Ne):d.bindVertexArrayOES(Ne)}function D(Ne){return c.isWebGL2?s.deleteVertexArray(Ne):d.deleteVertexArrayOES(Ne)}function F(Ne,tt,ot){let Tt=ot.wireframe===!0,jt=w[Ne.id];jt===void 0&&(jt={},w[Ne.id]=jt);let en=jt[tt.id];en===void 0&&(en={},jt[tt.id]=en);let mn=en[Tt];return mn===void 0&&(mn=O(L()),en[Tt]=mn),mn}function O(Ne){let tt=[],ot=[],Tt=[];for(let jt=0;jt=0){let pn=jt[bi],qn=en[bi];if(qn===void 0&&(bi==="instanceMatrix"&&Ne.instanceMatrix&&(qn=Ne.instanceMatrix),bi==="instanceColor"&&Ne.instanceColor&&(qn=Ne.instanceColor)),pn===void 0||pn.attribute!==qn||qn&&pn.data!==qn.data)return!0;mn++}return x.attributesNum!==mn||x.index!==Tt}function Z(Ne,tt,ot,Tt){let jt={},en=tt.attributes,mn=0,cn=ot.getAttributes();for(let bi in cn)if(cn[bi].location>=0){let pn=en[bi];pn===void 0&&(bi==="instanceMatrix"&&Ne.instanceMatrix&&(pn=Ne.instanceMatrix),bi==="instanceColor"&&Ne.instanceColor&&(pn=Ne.instanceColor));let qn={};qn.attribute=pn,pn&&pn.data&&(qn.data=pn.data),jt[bi]=qn,mn++}x.attributes=jt,x.attributesNum=mn,x.index=Tt}function H(){let Ne=x.newAttributes;for(let tt=0,ot=Ne.length;tt=0){let Vt=jt[cn];if(Vt===void 0&&(cn==="instanceMatrix"&&Ne.instanceMatrix&&(Vt=Ne.instanceMatrix),cn==="instanceColor"&&Ne.instanceColor&&(Vt=Ne.instanceColor)),Vt!==void 0){let pn=Vt.normalized,qn=Vt.itemSize,Yi=r.get(Vt);if(Yi===void 0)continue;let $i=Yi.buffer,Tr=Yi.type,wr=Yi.bytesPerElement,Si=c.isWebGL2===!0&&(Tr===s.INT||Tr===s.UNSIGNED_INT||Vt.gpuType===b2t);if(Vt.isInterleavedBufferAttribute){let Fr=Vt.data,se=Fr.stride,de=Vt.offset;if(Fr.isInstancedInterleavedBuffer){for(let it=0;it0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";ue="mediump"}return ue==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let b=typeof WebGL2RenderingContext<"u"&&s.constructor.name==="WebGL2RenderingContext",w=r.precision!==void 0?r.precision:"highp",_=d(w);_!==w&&(console.warn("THREE.WebGLRenderer:",w,"not supported, using",_,"instead."),w=_);let x=b||n.has("WEBGL_draw_buffers"),T=r.logarithmicDepthBuffer===!0,M=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),L=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),I=s.getParameter(s.MAX_TEXTURE_SIZE),D=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),F=s.getParameter(s.MAX_VERTEX_ATTRIBS),O=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),z=s.getParameter(s.MAX_VARYING_VECTORS),Z=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),H=L>0,te=b||n.has("OES_texture_float"),oe=H&&te,ne=b?s.getParameter(s.MAX_SAMPLES):0;return{isWebGL2:b,drawBuffers:x,getMaxAnisotropy:u,getMaxPrecision:d,precision:w,logarithmicDepthBuffer:T,maxTextures:M,maxVertexTextures:L,maxTextureSize:I,maxCubemapSize:D,maxAttributes:F,maxVertexUniforms:O,maxVaryings:z,maxFragmentUniforms:Z,vertexTextures:H,floatFragmentTextures:te,floatVertexTextures:oe,maxSamples:ne}}function pun(s){let n=this,r=null,c=0,u=!1,d=!1,b=new q3,w=new Xo,_={value:null,needsUpdate:!1};this.uniform=_,this.numPlanes=0,this.numIntersection=0,this.init=function(M,L){let I=M.length!==0||L||c!==0||u;return u=L,c=M.length,I},this.beginShadows=function(){d=!0,T(null)},this.endShadows=function(){d=!1},this.setGlobalState=function(M,L){r=T(M,L,0)},this.setState=function(M,L,I){let D=M.clippingPlanes,F=M.clipIntersection,O=M.clipShadows,z=s.get(M);if(!u||D===null||D.length===0||d&&!O)d?T(null):x();else{let Z=d?0:c,H=Z*4,te=z.clippingState||null;_.value=te,te=T(D,L,H,I);for(let oe=0;oe!==H;++oe)te[oe]=r[oe];z.clippingState=te,this.numIntersection=F?this.numPlanes:0,this.numPlanes+=Z}};function x(){_.value!==r&&(_.value=r,_.needsUpdate=c>0),n.numPlanes=c,n.numIntersection=0}function T(M,L,I,D){let F=M!==null?M.length:0,O=null;if(F!==0){if(O=_.value,D!==!0||O===null){let z=I+F*4,Z=L.matrixWorldInverse;w.getNormalMatrix(Z),(O===null||O.length0){let x=new D6e(_.height/2);return x.fromEquirectangularTexture(s,b),n.set(b,x),b.addEventListener("dispose",u),r(x.texture,b.mapping)}else return null}}return b}function u(b){let w=b.target;w.removeEventListener("dispose",u);let _=n.get(w);_!==void 0&&(n.delete(w),_.dispose())}function d(){n=new WeakMap}return{get:c,dispose:d}}var rhe=class extends nhe{constructor(n=-1,r=1,c=1,u=-1,d=.1,b=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=n,this.right=r,this.top=c,this.bottom=u,this.near=d,this.far=b,this.updateProjectionMatrix()}copy(n,r){return super.copy(n,r),this.left=n.left,this.right=n.right,this.top=n.top,this.bottom=n.bottom,this.near=n.near,this.far=n.far,this.zoom=n.zoom,this.view=n.view===null?null:Object.assign({},n.view),this}setViewOffset(n,r,c,u,d,b){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=n,this.view.fullHeight=r,this.view.offsetX=c,this.view.offsetY=u,this.view.width=d,this.view.height=b,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let n=(this.right-this.left)/(2*this.zoom),r=(this.top-this.bottom)/(2*this.zoom),c=(this.right+this.left)/2,u=(this.top+this.bottom)/2,d=c-n,b=c+n,w=u+r,_=u-r;if(this.view!==null&&this.view.enabled){let x=(this.right-this.left)/this.view.fullWidth/this.zoom,T=(this.top-this.bottom)/this.view.fullHeight/this.zoom;d+=x*this.view.offsetX,b=d+x*this.view.width,w-=T*this.view.offsetY,_=w-T*this.view.height}this.projectionMatrix.makeOrthographic(d,b,w,_,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(n){let r=super.toJSON(n);return r.object.zoom=this.zoom,r.object.left=this.left,r.object.right=this.right,r.object.top=this.top,r.object.bottom=this.bottom,r.object.near=this.near,r.object.far=this.far,this.view!==null&&(r.object.view=Object.assign({},this.view)),r}},rO=4,Fyt=[.125,.215,.35,.446,.526,.582],$4=20,p6e=new rhe,Uyt=new Go,g6e=null,m6e=0,b6e=0,G4=(1+Math.sqrt(5))/2,nO=1/G4,zyt=[new Gt(1,1,1),new Gt(-1,1,1),new Gt(1,1,-1),new Gt(-1,1,-1),new Gt(0,G4,nO),new Gt(0,G4,-nO),new Gt(nO,0,G4),new Gt(-nO,0,G4),new Gt(G4,nO,0),new Gt(-G4,nO,0)],she=class{constructor(n){this._renderer=n,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(n,r=0,c=.1,u=100){g6e=this._renderer.getRenderTarget(),m6e=this._renderer.getActiveCubeFace(),b6e=this._renderer.getActiveMipmapLevel(),this._setSize(256);let d=this._allocateTargets();return d.depthBuffer=!0,this._sceneToCubeUV(n,c,u,d),r>0&&this._blur(d,0,0,r),this._applyPMREM(d),this._cleanup(d),d}fromEquirectangular(n,r=null){return this._fromTexture(n,r)}fromCubemap(n,r=null){return this._fromTexture(n,r)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=$yt(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=jyt(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(n){this._lodMax=Math.floor(Math.log2(n)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let n=0;n2?H:0,H,H),T.setRenderTarget(u),F&&T.render(D,w),T.render(n,w)}D.geometry.dispose(),D.material.dispose(),T.toneMapping=L,T.autoClear=M,n.background=O}_textureToCubeUV(n,r){let c=this._renderer,u=n.mapping===lO||n.mapping===uO;u?(this._cubemapMaterial===null&&(this._cubemapMaterial=$yt()),this._cubemapMaterial.uniforms.flipEnvMap.value=n.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=jyt());let d=u?this._cubemapMaterial:this._equirectMaterial,b=new Mm(this._lodPlanes[0],d),w=d.uniforms;w.envMap.value=n;let _=this._cubeSize;Dfe(r,0,0,3*_,2*_),c.setRenderTarget(r),c.render(b,p6e)}_applyPMREM(n){let r=this._renderer,c=r.autoClear;r.autoClear=!1;for(let u=1;u$4&&console.warn(`sigmaRadians, ${d}, is too large and will clip, as it requested ${O} samples when the maximum is set to ${$4}`);let z=[],Z=0;for(let ue=0;ue<$4;++ue){let Te=ue/F,Q=Math.exp(-Te*Te/2);z.push(Q),ue===0?Z+=Q:ueH-rO?u-H+rO:0),ne=4*(this._cubeSize-te);Dfe(r,oe,ne,3*te,2*te),_.setRenderTarget(r),_.render(M,p6e)}};function mun(s){let n=[],r=[],c=[],u=s,d=s-rO+1+Fyt.length;for(let b=0;bs-rO?_=Fyt[b-s+rO-1]:b===0&&(_=0),c.push(_);let x=1/(w-2),T=-x,M=1+x,L=[T,T,M,T,M,M,T,T,M,M,T,M],I=6,D=6,F=3,O=2,z=1,Z=new Float32Array(F*D*I),H=new Float32Array(O*D*I),te=new Float32Array(z*D*I);for(let ne=0;ne2?0:-1,Q=[ue,Te,0,ue+2/3,Te,0,ue+2/3,Te+1,0,ue,Te,0,ue+2/3,Te+1,0,ue,Te+1,0];Z.set(Q,F*D*ne),H.set(L,O*D*ne);let ge=[ne,ne,ne,ne,ne,ne];te.set(ge,z*D*ne)}let oe=new d2;oe.setAttribute("position",new q1(Z,F)),oe.setAttribute("uv",new q1(H,O)),oe.setAttribute("faceIndex",new q1(te,z)),n.push(oe),u>rO&&u--}return{lodPlanes:n,sizeLods:r,sigmas:c}}function Gyt(s,n,r){let c=new Z3(s,n,r);return c.texture.mapping=bhe,c.texture.name="PMREM.cubeUv",c.scissorTest=!0,c}function Dfe(s,n,r,c,u){s.viewport.set(n,r,c,u),s.scissor.set(n,r,c,u)}function bun(s,n,r){let c=new Float32Array($4),u=new Gt(0,1,0);return new J3({name:"SphericalGaussianBlur",defines:{n:$4,CUBEUV_TEXEL_WIDTH:1/n,CUBEUV_TEXEL_HEIGHT:1/r,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:c},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:u}},vertexShader:f5e(),fragmentShader:` precision mediump float; precision mediump int; @@ -10040,27 +10040,27 @@ void main() { gl_Position = vec4( position, 1.0 ); } - `}function gun(s){let n=new WeakMap,r=null;function c(w){if(w&&w.isTexture){let _=w.mapping,x=_===S6e||_===M6e,T=_===lO||_===uO;if(x||T)if(w.isRenderTargetTexture&&w.needsPMREMUpdate===!0){w.needsPMREMUpdate=!1;let M=n.get(w);return r===null&&(r=new she(s)),M=x?r.fromEquirectangular(w,M):r.fromCubemap(w,M),n.set(w,M),M.texture}else{if(n.has(w))return n.get(w).texture;{let M=w.image;if(x&&M&&M.height>0||T&&M&&u(M)){r===null&&(r=new she(s));let L=x?r.fromEquirectangular(w):r.fromCubemap(w);return n.set(w,L),w.addEventListener("dispose",d),L.texture}else return null}}}return w}function u(w){let _=0,x=6;for(let T=0;Tn.maxTextureSize&&(ge=Math.ceil(Q/n.maxTextureSize),Q=n.maxTextureSize);let Qe=new Float32Array(Q*ge*4*D),st=new Jfe(Qe,Q,ge,D);st.type=hT,st.needsUpdate=!0;let at=Te*4;for(let tt=0;tt0)return s;let u=n*r,d=Vyt[u];if(d===void 0&&(d=new Float32Array(u),Vyt[u]=d),n!==0){c.toArray(d,0);for(let b=1,w=0;b!==n;++b)w+=r,s[b].toArray(d,w)}return d}function hh(s,n){if(s.length!==n.length)return!1;for(let r=0,c=s.length;r0||T&&M&&u(M)){r===null&&(r=new she(s));let L=x?r.fromEquirectangular(w):r.fromCubemap(w);return n.set(w,L),w.addEventListener("dispose",d),L.texture}else return null}}}return w}function u(w){let _=0,x=6;for(let T=0;Tn.maxTextureSize&&(ge=Math.ceil(Q/n.maxTextureSize),Q=n.maxTextureSize);let Qe=new Float32Array(Q*ge*4*D),st=new Jfe(Qe,Q,ge,D);st.type=hT,st.needsUpdate=!0;let at=Te*4;for(let tt=0;tt0)return s;let u=n*r,d=Vyt[u];if(d===void 0&&(d=new Float32Array(u),Vyt[u]=d),n!==0){c.toArray(d,0);for(let b=1,w=0;b!==n;++b)w+=r,s[b].toArray(d,w)}return d}function dh(s,n){if(s.length!==n.length)return!1;for(let r=0,c=s.length;r":" "} ${w}: ${r[b]}`)}return c.join(` -`)}function pfn(s){let n=Pc.getPrimaries(Pc.workingColorSpace),r=Pc.getPrimaries(s),c;switch(n===r?c="":n===qfe&&r===Hfe?c="LinearDisplayP3ToLinearSRGB":n===Hfe&&r===qfe&&(c="LinearSRGBToLinearDisplayP3"),s){case Y3:case whe:return[c,"LinearTransferOETF"];case Td:case u5e:return[c,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",s),[c,"LinearTransferOETF"]}}function Kyt(s,n,r){let c=s.getShaderParameter(n,s.COMPILE_STATUS),u=s.getShaderInfoLog(n).trim();if(c&&u==="")return"";let d=/ERROR: 0:(\d+)/.exec(u);if(d){let b=parseInt(d[1]);return r.toUpperCase()+` +`)}function bfn(s){let n=Pc.getPrimaries(Pc.workingColorSpace),r=Pc.getPrimaries(s),c;switch(n===r?c="":n===qfe&&r===Hfe?c="LinearDisplayP3ToLinearSRGB":n===Hfe&&r===qfe&&(c="LinearSRGBToLinearDisplayP3"),s){case Y3:case whe:return[c,"LinearTransferOETF"];case Td:case u5e:return[c,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",s),[c,"LinearTransferOETF"]}}function Kyt(s,n,r){let c=s.getShaderParameter(n,s.COMPILE_STATUS),u=s.getShaderInfoLog(n).trim();if(c&&u==="")return"";let d=/ERROR: 0:(\d+)/.exec(u);if(d){let b=parseInt(d[1]);return r.toUpperCase()+` `+u+` -`+dfn(s.getShaderSource(n),b)}else return u}function gfn(s,n){let r=pfn(n);return`vec4 ${s}( vec4 value ) { return ${r[0]}( ${r[1]}( value ) ); }`}function mfn(s,n){let r;switch(n){case Don:r="Linear";break;case Bon:r="Reinhard";break;case Oon:r="OptimizedCineon";break;case Non:r="ACESFilmic";break;case Uon:r="AgX";break;case Fon:r="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",n),r="Linear"}return"vec3 "+s+"( vec3 color ) { return "+r+"ToneMapping( color ); }"}function bfn(s){return[s.extensionDerivatives||s.envMapCubeUVHeight||s.bumpMap||s.normalMapTangentSpace||s.clearcoatNormalMap||s.flatShading||s.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(s.extensionFragDepth||s.logarithmicDepthBuffer)&&s.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",s.extensionDrawBuffers&&s.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(s.extensionShaderTextureLOD||s.envMap||s.transmission)&&s.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(sO).join(` -`)}function wfn(s){return[s.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":""].filter(sO).join(` -`)}function vfn(s){let n=[];for(let r in s){let c=s[r];c!==!1&&n.push("#define "+r+" "+c)}return n.join(` -`)}function _fn(s,n){let r={},c=s.getProgramParameter(n,s.ACTIVE_ATTRIBUTES);for(let u=0;u/gm;function U6e(s){return s.replace(yfn,Efn)}var xfn=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function Efn(s,n){let r=Ro[n];if(r===void 0){let c=xfn.get(n);if(c!==void 0)r=Ro[c],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',n,c);else throw new Error("Can not resolve #include <"+n+">")}return U6e(r)}var Sfn=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function e2t(s){return s.replace(Sfn,Mfn)}function Mfn(s,n,r,c){let u="";for(let d=parseInt(n);d/gm;function U6e(s){return s.replace(Sfn,Tfn)}var Mfn=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function Tfn(s,n){let r=Ro[n];if(r===void 0){let c=Mfn.get(n);if(c!==void 0)r=Ro[c],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',n,c);else throw new Error("Can not resolve #include <"+n+">")}return U6e(r)}var Cfn=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function e2t(s){return s.replace(Cfn,Afn)}function Afn(s,n,r,c){let u="";for(let d=parseInt(n);d0&&(z+=` `),Z=[I,"#define SHADER_TYPE "+r.shaderType,"#define SHADER_NAME "+r.shaderName,F].filter(sO).join(` `),Z.length>0&&(Z+=` `)):(z=[t2t(r),"#define SHADER_TYPE "+r.shaderType,"#define SHADER_NAME "+r.shaderName,F,r.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",r.batching?"#define USE_BATCHING":"",r.instancing?"#define USE_INSTANCING":"",r.instancingColor?"#define USE_INSTANCING_COLOR":"",r.useFog&&r.fog?"#define USE_FOG":"",r.useFog&&r.fogExp2?"#define FOG_EXP2":"",r.map?"#define USE_MAP":"",r.envMap?"#define USE_ENVMAP":"",r.envMap?"#define "+T:"",r.lightMap?"#define USE_LIGHTMAP":"",r.aoMap?"#define USE_AOMAP":"",r.bumpMap?"#define USE_BUMPMAP":"",r.normalMap?"#define USE_NORMALMAP":"",r.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",r.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",r.displacementMap?"#define USE_DISPLACEMENTMAP":"",r.emissiveMap?"#define USE_EMISSIVEMAP":"",r.anisotropy?"#define USE_ANISOTROPY":"",r.anisotropyMap?"#define USE_ANISOTROPYMAP":"",r.clearcoatMap?"#define USE_CLEARCOATMAP":"",r.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",r.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",r.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",r.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",r.specularMap?"#define USE_SPECULARMAP":"",r.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",r.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",r.roughnessMap?"#define USE_ROUGHNESSMAP":"",r.metalnessMap?"#define USE_METALNESSMAP":"",r.alphaMap?"#define USE_ALPHAMAP":"",r.alphaHash?"#define USE_ALPHAHASH":"",r.transmission?"#define USE_TRANSMISSION":"",r.transmissionMap?"#define USE_TRANSMISSIONMAP":"",r.thicknessMap?"#define USE_THICKNESSMAP":"",r.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",r.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",r.mapUv?"#define MAP_UV "+r.mapUv:"",r.alphaMapUv?"#define ALPHAMAP_UV "+r.alphaMapUv:"",r.lightMapUv?"#define LIGHTMAP_UV "+r.lightMapUv:"",r.aoMapUv?"#define AOMAP_UV "+r.aoMapUv:"",r.emissiveMapUv?"#define EMISSIVEMAP_UV "+r.emissiveMapUv:"",r.bumpMapUv?"#define BUMPMAP_UV "+r.bumpMapUv:"",r.normalMapUv?"#define NORMALMAP_UV "+r.normalMapUv:"",r.displacementMapUv?"#define DISPLACEMENTMAP_UV "+r.displacementMapUv:"",r.metalnessMapUv?"#define METALNESSMAP_UV "+r.metalnessMapUv:"",r.roughnessMapUv?"#define ROUGHNESSMAP_UV "+r.roughnessMapUv:"",r.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+r.anisotropyMapUv:"",r.clearcoatMapUv?"#define CLEARCOATMAP_UV "+r.clearcoatMapUv:"",r.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+r.clearcoatNormalMapUv:"",r.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+r.clearcoatRoughnessMapUv:"",r.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+r.iridescenceMapUv:"",r.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+r.iridescenceThicknessMapUv:"",r.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+r.sheenColorMapUv:"",r.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+r.sheenRoughnessMapUv:"",r.specularMapUv?"#define SPECULARMAP_UV "+r.specularMapUv:"",r.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+r.specularColorMapUv:"",r.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+r.specularIntensityMapUv:"",r.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+r.transmissionMapUv:"",r.thicknessMapUv?"#define THICKNESSMAP_UV "+r.thicknessMapUv:"",r.vertexTangents&&r.flatShading===!1?"#define USE_TANGENT":"",r.vertexColors?"#define USE_COLOR":"",r.vertexAlphas?"#define USE_COLOR_ALPHA":"",r.vertexUv1s?"#define USE_UV1":"",r.vertexUv2s?"#define USE_UV2":"",r.vertexUv3s?"#define USE_UV3":"",r.pointsUvs?"#define USE_POINTS_UV":"",r.flatShading?"#define FLAT_SHADED":"",r.skinning?"#define USE_SKINNING":"",r.morphTargets?"#define USE_MORPHTARGETS":"",r.morphNormals&&r.flatShading===!1?"#define USE_MORPHNORMALS":"",r.morphColors&&r.isWebGL2?"#define USE_MORPHCOLORS":"",r.morphTargetsCount>0&&r.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",r.morphTargetsCount>0&&r.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+r.morphTextureStride:"",r.morphTargetsCount>0&&r.isWebGL2?"#define MORPHTARGETS_COUNT "+r.morphTargetsCount:"",r.doubleSided?"#define DOUBLE_SIDED":"",r.flipSided?"#define FLIP_SIDED":"",r.shadowMapEnabled?"#define USE_SHADOWMAP":"",r.shadowMapEnabled?"#define "+_:"",r.sizeAttenuation?"#define USE_SIZEATTENUATION":"",r.numLightProbes>0?"#define USE_LIGHT_PROBES":"",r.useLegacyLights?"#define LEGACY_LIGHTS":"",r.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",r.logarithmicDepthBuffer&&r.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter(sO).join(` -`),Z=[I,t2t(r),"#define SHADER_TYPE "+r.shaderType,"#define SHADER_NAME "+r.shaderName,F,r.useFog&&r.fog?"#define USE_FOG":"",r.useFog&&r.fogExp2?"#define FOG_EXP2":"",r.map?"#define USE_MAP":"",r.matcap?"#define USE_MATCAP":"",r.envMap?"#define USE_ENVMAP":"",r.envMap?"#define "+x:"",r.envMap?"#define "+T:"",r.envMap?"#define "+M:"",L?"#define CUBEUV_TEXEL_WIDTH "+L.texelWidth:"",L?"#define CUBEUV_TEXEL_HEIGHT "+L.texelHeight:"",L?"#define CUBEUV_MAX_MIP "+L.maxMip+".0":"",r.lightMap?"#define USE_LIGHTMAP":"",r.aoMap?"#define USE_AOMAP":"",r.bumpMap?"#define USE_BUMPMAP":"",r.normalMap?"#define USE_NORMALMAP":"",r.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",r.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",r.emissiveMap?"#define USE_EMISSIVEMAP":"",r.anisotropy?"#define USE_ANISOTROPY":"",r.anisotropyMap?"#define USE_ANISOTROPYMAP":"",r.clearcoat?"#define USE_CLEARCOAT":"",r.clearcoatMap?"#define USE_CLEARCOATMAP":"",r.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",r.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",r.iridescence?"#define USE_IRIDESCENCE":"",r.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",r.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",r.specularMap?"#define USE_SPECULARMAP":"",r.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",r.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",r.roughnessMap?"#define USE_ROUGHNESSMAP":"",r.metalnessMap?"#define USE_METALNESSMAP":"",r.alphaMap?"#define USE_ALPHAMAP":"",r.alphaTest?"#define USE_ALPHATEST":"",r.alphaHash?"#define USE_ALPHAHASH":"",r.sheen?"#define USE_SHEEN":"",r.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",r.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",r.transmission?"#define USE_TRANSMISSION":"",r.transmissionMap?"#define USE_TRANSMISSIONMAP":"",r.thicknessMap?"#define USE_THICKNESSMAP":"",r.vertexTangents&&r.flatShading===!1?"#define USE_TANGENT":"",r.vertexColors||r.instancingColor?"#define USE_COLOR":"",r.vertexAlphas?"#define USE_COLOR_ALPHA":"",r.vertexUv1s?"#define USE_UV1":"",r.vertexUv2s?"#define USE_UV2":"",r.vertexUv3s?"#define USE_UV3":"",r.pointsUvs?"#define USE_POINTS_UV":"",r.gradientMap?"#define USE_GRADIENTMAP":"",r.flatShading?"#define FLAT_SHADED":"",r.doubleSided?"#define DOUBLE_SIDED":"",r.flipSided?"#define FLIP_SIDED":"",r.shadowMapEnabled?"#define USE_SHADOWMAP":"",r.shadowMapEnabled?"#define "+_:"",r.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",r.numLightProbes>0?"#define USE_LIGHT_PROBES":"",r.useLegacyLights?"#define LEGACY_LIGHTS":"",r.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",r.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",r.logarithmicDepthBuffer&&r.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",r.toneMapping!==gT?"#define TONE_MAPPING":"",r.toneMapping!==gT?Ro.tonemapping_pars_fragment:"",r.toneMapping!==gT?mfn("toneMapping",r.toneMapping):"",r.dithering?"#define DITHERING":"",r.opaque?"#define OPAQUE":"",Ro.colorspace_pars_fragment,gfn("linearToOutputTexel",r.outputColorSpace),r.useDepthPacking?"#define DEPTH_PACKING "+r.depthPacking:"",` +`),Z=[I,t2t(r),"#define SHADER_TYPE "+r.shaderType,"#define SHADER_NAME "+r.shaderName,F,r.useFog&&r.fog?"#define USE_FOG":"",r.useFog&&r.fogExp2?"#define FOG_EXP2":"",r.map?"#define USE_MAP":"",r.matcap?"#define USE_MATCAP":"",r.envMap?"#define USE_ENVMAP":"",r.envMap?"#define "+x:"",r.envMap?"#define "+T:"",r.envMap?"#define "+M:"",L?"#define CUBEUV_TEXEL_WIDTH "+L.texelWidth:"",L?"#define CUBEUV_TEXEL_HEIGHT "+L.texelHeight:"",L?"#define CUBEUV_MAX_MIP "+L.maxMip+".0":"",r.lightMap?"#define USE_LIGHTMAP":"",r.aoMap?"#define USE_AOMAP":"",r.bumpMap?"#define USE_BUMPMAP":"",r.normalMap?"#define USE_NORMALMAP":"",r.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",r.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",r.emissiveMap?"#define USE_EMISSIVEMAP":"",r.anisotropy?"#define USE_ANISOTROPY":"",r.anisotropyMap?"#define USE_ANISOTROPYMAP":"",r.clearcoat?"#define USE_CLEARCOAT":"",r.clearcoatMap?"#define USE_CLEARCOATMAP":"",r.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",r.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",r.iridescence?"#define USE_IRIDESCENCE":"",r.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",r.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",r.specularMap?"#define USE_SPECULARMAP":"",r.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",r.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",r.roughnessMap?"#define USE_ROUGHNESSMAP":"",r.metalnessMap?"#define USE_METALNESSMAP":"",r.alphaMap?"#define USE_ALPHAMAP":"",r.alphaTest?"#define USE_ALPHATEST":"",r.alphaHash?"#define USE_ALPHAHASH":"",r.sheen?"#define USE_SHEEN":"",r.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",r.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",r.transmission?"#define USE_TRANSMISSION":"",r.transmissionMap?"#define USE_TRANSMISSIONMAP":"",r.thicknessMap?"#define USE_THICKNESSMAP":"",r.vertexTangents&&r.flatShading===!1?"#define USE_TANGENT":"",r.vertexColors||r.instancingColor?"#define USE_COLOR":"",r.vertexAlphas?"#define USE_COLOR_ALPHA":"",r.vertexUv1s?"#define USE_UV1":"",r.vertexUv2s?"#define USE_UV2":"",r.vertexUv3s?"#define USE_UV3":"",r.pointsUvs?"#define USE_POINTS_UV":"",r.gradientMap?"#define USE_GRADIENTMAP":"",r.flatShading?"#define FLAT_SHADED":"",r.doubleSided?"#define DOUBLE_SIDED":"",r.flipSided?"#define FLIP_SIDED":"",r.shadowMapEnabled?"#define USE_SHADOWMAP":"",r.shadowMapEnabled?"#define "+_:"",r.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",r.numLightProbes>0?"#define USE_LIGHT_PROBES":"",r.useLegacyLights?"#define LEGACY_LIGHTS":"",r.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",r.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",r.logarithmicDepthBuffer&&r.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",r.toneMapping!==gT?"#define TONE_MAPPING":"",r.toneMapping!==gT?Ro.tonemapping_pars_fragment:"",r.toneMapping!==gT?vfn("toneMapping",r.toneMapping):"",r.dithering?"#define DITHERING":"",r.opaque?"#define OPAQUE":"",Ro.colorspace_pars_fragment,wfn("linearToOutputTexel",r.outputColorSpace),r.useDepthPacking?"#define DEPTH_PACKING "+r.depthPacking:"",` `].filter(sO).join(` `)),b=U6e(b),b=Jyt(b,r),b=Qyt(b,r),w=U6e(w),w=Jyt(w,r),w=Qyt(w,r),b=e2t(b),w=e2t(w),r.isWebGL2&&r.isRawShaderMaterial!==!0&&(H=`#version 300 es `,z=[D,"precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(` @@ -10071,9 +10071,9 @@ precision `+s.precision+" int;";return s.precision==="highp"?n+=` Program Info Log: `+at+` `+jt+` -`+en)}else at!==""?console.warn("THREE.WebGLProgram: Program Info Log:",at):(Ne===""||tt==="")&&(Tt=!1);Tt&&(st.diagnostics={runnable:ot,programLog:at,vertexShader:{log:Ne,prefix:z},fragmentShader:{log:tt,prefix:Z}})}u.deleteShader(ne),u.deleteShader(ue),Q=new cO(u,O),ge=_fn(u,O)}let Q;this.getUniforms=function(){return Q===void 0&&Te(this),Q};let ge;this.getAttributes=function(){return ge===void 0&&Te(this),ge};let Qe=r.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return Qe===!1&&(Qe=u.getProgramParameter(O,ffn)),Qe},this.destroy=function(){c.releaseStatesOfProgram(this),u.deleteProgram(O),this.program=void 0},this.type=r.shaderType,this.name=r.shaderName,this.id=hfn++,this.cacheKey=n,this.usedTimes=1,this.program=O,this.vertexShader=ne,this.fragmentShader=ue,this}var Rfn=0,z6e=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(n){let r=n.vertexShader,c=n.fragmentShader,u=this._getShaderStage(r),d=this._getShaderStage(c),b=this._getShaderCacheForMaterial(n);return b.has(u)===!1&&(b.add(u),u.usedTimes++),b.has(d)===!1&&(b.add(d),d.usedTimes++),this}remove(n){let r=this.materialCache.get(n);for(let c of r)c.usedTimes--,c.usedTimes===0&&this.shaderCache.delete(c.code);return this.materialCache.delete(n),this}getVertexShaderID(n){return this._getShaderStage(n.vertexShader).id}getFragmentShaderID(n){return this._getShaderStage(n.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(n){let r=this.materialCache,c=r.get(n);return c===void 0&&(c=new Set,r.set(n,c)),c}_getShaderStage(n){let r=this.shaderCache,c=r.get(n);return c===void 0&&(c=new G6e(n),r.set(n,c)),c}},G6e=class{constructor(n){this.id=Rfn++,this.code=n,this.usedTimes=0}};function Ifn(s,n,r,c,u,d,b){let w=new NW,_=new z6e,x=[],T=u.isWebGL2,M=u.logarithmicDepthBuffer,L=u.vertexTextures,I=u.precision,D={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function F(Q){return Q===0?"uv":`uv${Q}`}function O(Q,ge,Qe,st,at){let Ne=st.fog,tt=at.geometry,ot=Q.isMeshStandardMaterial?st.environment:null,Tt=(Q.isMeshStandardMaterial?r:n).get(Q.envMap||ot),jt=Tt&&Tt.mapping===bhe?Tt.image.height:null,en=D[Q.type];Q.precision!==null&&(I=u.getMaxPrecision(Q.precision),I!==Q.precision&&console.warn("THREE.WebGLProgram.getParameters:",Q.precision,"not supported, using",I,"instead."));let mn=tt.morphAttributes.position||tt.morphAttributes.normal||tt.morphAttributes.color,cn=mn!==void 0?mn.length:0,bi=0;tt.morphAttributes.position!==void 0&&(bi=1),tt.morphAttributes.normal!==void 0&&(bi=2),tt.morphAttributes.color!==void 0&&(bi=3);let Vt,pn,qn,Yi;if(en){let xn=f2[en];Vt=xn.vertexShader,pn=xn.fragmentShader}else Vt=Q.vertexShader,pn=Q.fragmentShader,_.update(Q),qn=_.getVertexShaderID(Q),Yi=_.getFragmentShaderID(Q);let $i=s.getRenderTarget(),Tr=at.isInstancedMesh===!0,wr=at.isBatchedMesh===!0,Si=!!Q.map,Fr=!!Q.matcap,se=!!Tt,de=!!Q.aoMap,it=!!Q.lightMap,We=!!Q.bumpMap,En=!!Q.normalMap,hr=!!Q.displacementMap,qi=!!Q.emissiveMap,Me=!!Q.metalnessMap,ve=!!Q.roughnessMap,wt=Q.anisotropy>0,gn=Q.clearcoat>0,vn=Q.iridescence>0,Mn=Q.sheen>0,xi=Q.transmission>0,mi=wt&&!!Q.anisotropyMap,ri=gn&&!!Q.clearcoatMap,Ge=gn&&!!Q.clearcoatNormalMap,Ae=gn&&!!Q.clearcoatRoughnessMap,Le=vn&&!!Q.iridescenceMap,ht=vn&&!!Q.iridescenceThicknessMap,Ye=Mn&&!!Q.sheenColorMap,ct=Mn&&!!Q.sheenRoughnessMap,Ze=!!Q.specularMap,Ke=!!Q.specularColorMap,pt=!!Q.specularIntensityMap,Xn=xi&&!!Q.transmissionMap,_i=xi&&!!Q.thicknessMap,Hi=!!Q.gradientMap,_n=!!Q.alphaMap,Je=Q.alphaTest>0,Qn=!!Q.alphaHash,ei=!!Q.extensions,ar=!!tt.attributes.uv1,yn=!!tt.attributes.uv2,Re=!!tt.attributes.uv3,nt=gT;return Q.toneMapped&&($i===null||$i.isXRRenderTarget===!0)&&(nt=s.toneMapping),{isWebGL2:T,shaderID:en,shaderType:Q.type,shaderName:Q.name,vertexShader:Vt,fragmentShader:pn,defines:Q.defines,customVertexShaderID:qn,customFragmentShaderID:Yi,isRawShaderMaterial:Q.isRawShaderMaterial===!0,glslVersion:Q.glslVersion,precision:I,batching:wr,instancing:Tr,instancingColor:Tr&&at.instanceColor!==null,supportsVertexTextures:L,outputColorSpace:$i===null?s.outputColorSpace:$i.isXRRenderTarget===!0?$i.texture.colorSpace:Y3,map:Si,matcap:Fr,envMap:se,envMapMode:se&&Tt.mapping,envMapCubeUVHeight:jt,aoMap:de,lightMap:it,bumpMap:We,normalMap:En,displacementMap:L&&hr,emissiveMap:qi,normalMapObjectSpace:En&&Q.normalMapType===Kon,normalMapTangentSpace:En&&Q.normalMapType===M2t,metalnessMap:Me,roughnessMap:ve,anisotropy:wt,anisotropyMap:mi,clearcoat:gn,clearcoatMap:ri,clearcoatNormalMap:Ge,clearcoatRoughnessMap:Ae,iridescence:vn,iridescenceMap:Le,iridescenceThicknessMap:ht,sheen:Mn,sheenColorMap:Ye,sheenRoughnessMap:ct,specularMap:Ze,specularColorMap:Ke,specularIntensityMap:pt,transmission:xi,transmissionMap:Xn,thicknessMap:_i,gradientMap:Hi,opaque:Q.transparent===!1&&Q.blending===oO,alphaMap:_n,alphaTest:Je,alphaHash:Qn,combine:Q.combine,mapUv:Si&&F(Q.map.channel),aoMapUv:de&&F(Q.aoMap.channel),lightMapUv:it&&F(Q.lightMap.channel),bumpMapUv:We&&F(Q.bumpMap.channel),normalMapUv:En&&F(Q.normalMap.channel),displacementMapUv:hr&&F(Q.displacementMap.channel),emissiveMapUv:qi&&F(Q.emissiveMap.channel),metalnessMapUv:Me&&F(Q.metalnessMap.channel),roughnessMapUv:ve&&F(Q.roughnessMap.channel),anisotropyMapUv:mi&&F(Q.anisotropyMap.channel),clearcoatMapUv:ri&&F(Q.clearcoatMap.channel),clearcoatNormalMapUv:Ge&&F(Q.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ae&&F(Q.clearcoatRoughnessMap.channel),iridescenceMapUv:Le&&F(Q.iridescenceMap.channel),iridescenceThicknessMapUv:ht&&F(Q.iridescenceThicknessMap.channel),sheenColorMapUv:Ye&&F(Q.sheenColorMap.channel),sheenRoughnessMapUv:ct&&F(Q.sheenRoughnessMap.channel),specularMapUv:Ze&&F(Q.specularMap.channel),specularColorMapUv:Ke&&F(Q.specularColorMap.channel),specularIntensityMapUv:pt&&F(Q.specularIntensityMap.channel),transmissionMapUv:Xn&&F(Q.transmissionMap.channel),thicknessMapUv:_i&&F(Q.thicknessMap.channel),alphaMapUv:_n&&F(Q.alphaMap.channel),vertexTangents:!!tt.attributes.tangent&&(En||wt),vertexColors:Q.vertexColors,vertexAlphas:Q.vertexColors===!0&&!!tt.attributes.color&&tt.attributes.color.itemSize===4,vertexUv1s:ar,vertexUv2s:yn,vertexUv3s:Re,pointsUvs:at.isPoints===!0&&!!tt.attributes.uv&&(Si||_n),fog:!!Ne,useFog:Q.fog===!0,fogExp2:Ne&&Ne.isFogExp2,flatShading:Q.flatShading===!0,sizeAttenuation:Q.sizeAttenuation===!0,logarithmicDepthBuffer:M,skinning:at.isSkinnedMesh===!0,morphTargets:tt.morphAttributes.position!==void 0,morphNormals:tt.morphAttributes.normal!==void 0,morphColors:tt.morphAttributes.color!==void 0,morphTargetsCount:cn,morphTextureStride:bi,numDirLights:ge.directional.length,numPointLights:ge.point.length,numSpotLights:ge.spot.length,numSpotLightMaps:ge.spotLightMap.length,numRectAreaLights:ge.rectArea.length,numHemiLights:ge.hemi.length,numDirLightShadows:ge.directionalShadowMap.length,numPointLightShadows:ge.pointShadowMap.length,numSpotLightShadows:ge.spotShadowMap.length,numSpotLightShadowsWithMaps:ge.numSpotLightShadowsWithMaps,numLightProbes:ge.numLightProbes,numClippingPlanes:b.numPlanes,numClipIntersection:b.numIntersection,dithering:Q.dithering,shadowMapEnabled:s.shadowMap.enabled&&Qe.length>0,shadowMapType:s.shadowMap.type,toneMapping:nt,useLegacyLights:s._useLegacyLights,decodeVideoTexture:Si&&Q.map.isVideoTexture===!0&&Pc.getTransfer(Q.map.colorSpace)===dl,premultipliedAlpha:Q.premultipliedAlpha,doubleSided:Q.side===Mv,flipSided:Q.side===Tm,useDepthPacking:Q.depthPacking>=0,depthPacking:Q.depthPacking||0,index0AttributeName:Q.index0AttributeName,extensionDerivatives:ei&&Q.extensions.derivatives===!0,extensionFragDepth:ei&&Q.extensions.fragDepth===!0,extensionDrawBuffers:ei&&Q.extensions.drawBuffers===!0,extensionShaderTextureLOD:ei&&Q.extensions.shaderTextureLOD===!0,extensionClipCullDistance:ei&&Q.extensions.clipCullDistance&&c.has("WEBGL_clip_cull_distance"),rendererExtensionFragDepth:T||c.has("EXT_frag_depth"),rendererExtensionDrawBuffers:T||c.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:T||c.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:c.has("KHR_parallel_shader_compile"),customProgramCacheKey:Q.customProgramCacheKey()}}function z(Q){let ge=[];if(Q.shaderID?ge.push(Q.shaderID):(ge.push(Q.customVertexShaderID),ge.push(Q.customFragmentShaderID)),Q.defines!==void 0)for(let Qe in Q.defines)ge.push(Qe),ge.push(Q.defines[Qe]);return Q.isRawShaderMaterial===!1&&(Z(ge,Q),H(ge,Q),ge.push(s.outputColorSpace)),ge.push(Q.customProgramCacheKey),ge.join()}function Z(Q,ge){Q.push(ge.precision),Q.push(ge.outputColorSpace),Q.push(ge.envMapMode),Q.push(ge.envMapCubeUVHeight),Q.push(ge.mapUv),Q.push(ge.alphaMapUv),Q.push(ge.lightMapUv),Q.push(ge.aoMapUv),Q.push(ge.bumpMapUv),Q.push(ge.normalMapUv),Q.push(ge.displacementMapUv),Q.push(ge.emissiveMapUv),Q.push(ge.metalnessMapUv),Q.push(ge.roughnessMapUv),Q.push(ge.anisotropyMapUv),Q.push(ge.clearcoatMapUv),Q.push(ge.clearcoatNormalMapUv),Q.push(ge.clearcoatRoughnessMapUv),Q.push(ge.iridescenceMapUv),Q.push(ge.iridescenceThicknessMapUv),Q.push(ge.sheenColorMapUv),Q.push(ge.sheenRoughnessMapUv),Q.push(ge.specularMapUv),Q.push(ge.specularColorMapUv),Q.push(ge.specularIntensityMapUv),Q.push(ge.transmissionMapUv),Q.push(ge.thicknessMapUv),Q.push(ge.combine),Q.push(ge.fogExp2),Q.push(ge.sizeAttenuation),Q.push(ge.morphTargetsCount),Q.push(ge.morphAttributeCount),Q.push(ge.numDirLights),Q.push(ge.numPointLights),Q.push(ge.numSpotLights),Q.push(ge.numSpotLightMaps),Q.push(ge.numHemiLights),Q.push(ge.numRectAreaLights),Q.push(ge.numDirLightShadows),Q.push(ge.numPointLightShadows),Q.push(ge.numSpotLightShadows),Q.push(ge.numSpotLightShadowsWithMaps),Q.push(ge.numLightProbes),Q.push(ge.shadowMapType),Q.push(ge.toneMapping),Q.push(ge.numClippingPlanes),Q.push(ge.numClipIntersection),Q.push(ge.depthPacking)}function H(Q,ge){w.disableAll(),ge.isWebGL2&&w.enable(0),ge.supportsVertexTextures&&w.enable(1),ge.instancing&&w.enable(2),ge.instancingColor&&w.enable(3),ge.matcap&&w.enable(4),ge.envMap&&w.enable(5),ge.normalMapObjectSpace&&w.enable(6),ge.normalMapTangentSpace&&w.enable(7),ge.clearcoat&&w.enable(8),ge.iridescence&&w.enable(9),ge.alphaTest&&w.enable(10),ge.vertexColors&&w.enable(11),ge.vertexAlphas&&w.enable(12),ge.vertexUv1s&&w.enable(13),ge.vertexUv2s&&w.enable(14),ge.vertexUv3s&&w.enable(15),ge.vertexTangents&&w.enable(16),ge.anisotropy&&w.enable(17),ge.alphaHash&&w.enable(18),ge.batching&&w.enable(19),Q.push(w.mask),w.disableAll(),ge.fog&&w.enable(0),ge.useFog&&w.enable(1),ge.flatShading&&w.enable(2),ge.logarithmicDepthBuffer&&w.enable(3),ge.skinning&&w.enable(4),ge.morphTargets&&w.enable(5),ge.morphNormals&&w.enable(6),ge.morphColors&&w.enable(7),ge.premultipliedAlpha&&w.enable(8),ge.shadowMapEnabled&&w.enable(9),ge.useLegacyLights&&w.enable(10),ge.doubleSided&&w.enable(11),ge.flipSided&&w.enable(12),ge.useDepthPacking&&w.enable(13),ge.dithering&&w.enable(14),ge.transmission&&w.enable(15),ge.sheen&&w.enable(16),ge.opaque&&w.enable(17),ge.pointsUvs&&w.enable(18),ge.decodeVideoTexture&&w.enable(19),Q.push(w.mask)}function te(Q){let ge=D[Q.type],Qe;if(ge){let st=f2[ge];Qe=xan.clone(st.uniforms)}else Qe=Q.uniforms;return Qe}function oe(Q,ge){let Qe;for(let st=0,at=x.length;st0?c.push(z):I.transparent===!0?u.push(z):r.push(z)}function _(M,L,I,D,F,O){let z=b(M,L,I,D,F,O);I.transmission>0?c.unshift(z):I.transparent===!0?u.unshift(z):r.unshift(z)}function x(M,L){r.length>1&&r.sort(M||Bfn),c.length>1&&c.sort(L||n2t),u.length>1&&u.sort(L||n2t)}function T(){for(let M=n,L=s.length;M=d.length?(b=new i2t,d.push(b)):b=d[u],b}function r(){s=new WeakMap}return{get:n,dispose:r}}function Nfn(){let s={};return{get:function(n){if(s[n.id]!==void 0)return s[n.id];let r;switch(n.type){case"DirectionalLight":r={direction:new Gt,color:new Go};break;case"SpotLight":r={position:new Gt,direction:new Gt,color:new Go,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":r={position:new Gt,color:new Go,distance:0,decay:0};break;case"HemisphereLight":r={direction:new Gt,skyColor:new Go,groundColor:new Go};break;case"RectAreaLight":r={color:new Go,position:new Gt,halfWidth:new Gt,halfHeight:new Gt};break}return s[n.id]=r,r}}}function Ffn(){let s={};return{get:function(n){if(s[n.id]!==void 0)return s[n.id];let r;switch(n.type){case"DirectionalLight":r={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ka};break;case"SpotLight":r={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ka};break;case"PointLight":r={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ka,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[n.id]=r,r}}}var Ufn=0;function zfn(s,n){return(n.castShadow?2:0)-(s.castShadow?2:0)+(n.map?1:0)-(s.map?1:0)}function Gfn(s,n){let r=new Nfn,c=Ffn(),u={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let T=0;T<9;T++)u.probe.push(new Gt);let d=new Gt,b=new Il,w=new Il;function _(T,M){let L=0,I=0,D=0;for(let st=0;st<9;st++)u.probe[st].set(0,0,0);let F=0,O=0,z=0,Z=0,H=0,te=0,oe=0,ne=0,ue=0,Te=0,Q=0;T.sort(zfn);let ge=M===!0?Math.PI:1;for(let st=0,at=T.length;st0&&(n.isWebGL2?s.has("OES_texture_float_linear")===!0?(u.rectAreaLTC1=ji.LTC_FLOAT_1,u.rectAreaLTC2=ji.LTC_FLOAT_2):(u.rectAreaLTC1=ji.LTC_HALF_1,u.rectAreaLTC2=ji.LTC_HALF_2):s.has("OES_texture_float_linear")===!0?(u.rectAreaLTC1=ji.LTC_FLOAT_1,u.rectAreaLTC2=ji.LTC_FLOAT_2):s.has("OES_texture_half_float_linear")===!0?(u.rectAreaLTC1=ji.LTC_HALF_1,u.rectAreaLTC2=ji.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),u.ambient[0]=L,u.ambient[1]=I,u.ambient[2]=D;let Qe=u.hash;(Qe.directionalLength!==F||Qe.pointLength!==O||Qe.spotLength!==z||Qe.rectAreaLength!==Z||Qe.hemiLength!==H||Qe.numDirectionalShadows!==te||Qe.numPointShadows!==oe||Qe.numSpotShadows!==ne||Qe.numSpotMaps!==ue||Qe.numLightProbes!==Q)&&(u.directional.length=F,u.spot.length=z,u.rectArea.length=Z,u.point.length=O,u.hemi.length=H,u.directionalShadow.length=te,u.directionalShadowMap.length=te,u.pointShadow.length=oe,u.pointShadowMap.length=oe,u.spotShadow.length=ne,u.spotShadowMap.length=ne,u.directionalShadowMatrix.length=te,u.pointShadowMatrix.length=oe,u.spotLightMatrix.length=ne+ue-Te,u.spotLightMap.length=ue,u.numSpotLightShadowsWithMaps=Te,u.numLightProbes=Q,Qe.directionalLength=F,Qe.pointLength=O,Qe.spotLength=z,Qe.rectAreaLength=Z,Qe.hemiLength=H,Qe.numDirectionalShadows=te,Qe.numPointShadows=oe,Qe.numSpotShadows=ne,Qe.numSpotMaps=ue,Qe.numLightProbes=Q,u.version=Ufn++)}function x(T,M){let L=0,I=0,D=0,F=0,O=0,z=M.matrixWorldInverse;for(let Z=0,H=T.length;Z=w.length?(_=new r2t(s,n),w.push(_)):_=w[b],_}function u(){r=new WeakMap}return{get:c,dispose:u}}var j6e=class extends _T{constructor(n){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Yon,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(n)}copy(n){return super.copy(n),this.depthPacking=n.depthPacking,this.map=n.map,this.alphaMap=n.alphaMap,this.displacementMap=n.displacementMap,this.displacementScale=n.displacementScale,this.displacementBias=n.displacementBias,this.wireframe=n.wireframe,this.wireframeLinewidth=n.wireframeLinewidth,this}},$6e=class extends _T{constructor(n){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(n)}copy(n){return super.copy(n),this.map=n.map,this.alphaMap=n.alphaMap,this.displacementMap=n.displacementMap,this.displacementScale=n.displacementScale,this.displacementBias=n.displacementBias,this}},$fn=`void main() { +`+en)}else at!==""?console.warn("THREE.WebGLProgram: Program Info Log:",at):(Ne===""||tt==="")&&(Tt=!1);Tt&&(st.diagnostics={runnable:ot,programLog:at,vertexShader:{log:Ne,prefix:z},fragmentShader:{log:tt,prefix:Z}})}u.deleteShader(ne),u.deleteShader(ue),Q=new cO(u,O),ge=Efn(u,O)}let Q;this.getUniforms=function(){return Q===void 0&&Te(this),Q};let ge;this.getAttributes=function(){return ge===void 0&&Te(this),ge};let Qe=r.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return Qe===!1&&(Qe=u.getProgramParameter(O,pfn)),Qe},this.destroy=function(){c.releaseStatesOfProgram(this),u.deleteProgram(O),this.program=void 0},this.type=r.shaderType,this.name=r.shaderName,this.id=gfn++,this.cacheKey=n,this.usedTimes=1,this.program=O,this.vertexShader=ne,this.fragmentShader=ue,this}var Bfn=0,z6e=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(n){let r=n.vertexShader,c=n.fragmentShader,u=this._getShaderStage(r),d=this._getShaderStage(c),b=this._getShaderCacheForMaterial(n);return b.has(u)===!1&&(b.add(u),u.usedTimes++),b.has(d)===!1&&(b.add(d),d.usedTimes++),this}remove(n){let r=this.materialCache.get(n);for(let c of r)c.usedTimes--,c.usedTimes===0&&this.shaderCache.delete(c.code);return this.materialCache.delete(n),this}getVertexShaderID(n){return this._getShaderStage(n.vertexShader).id}getFragmentShaderID(n){return this._getShaderStage(n.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(n){let r=this.materialCache,c=r.get(n);return c===void 0&&(c=new Set,r.set(n,c)),c}_getShaderStage(n){let r=this.shaderCache,c=r.get(n);return c===void 0&&(c=new G6e(n),r.set(n,c)),c}},G6e=class{constructor(n){this.id=Bfn++,this.code=n,this.usedTimes=0}};function Ofn(s,n,r,c,u,d,b){let w=new NW,_=new z6e,x=[],T=u.isWebGL2,M=u.logarithmicDepthBuffer,L=u.vertexTextures,I=u.precision,D={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function F(Q){return Q===0?"uv":`uv${Q}`}function O(Q,ge,Qe,st,at){let Ne=st.fog,tt=at.geometry,ot=Q.isMeshStandardMaterial?st.environment:null,Tt=(Q.isMeshStandardMaterial?r:n).get(Q.envMap||ot),jt=Tt&&Tt.mapping===bhe?Tt.image.height:null,en=D[Q.type];Q.precision!==null&&(I=u.getMaxPrecision(Q.precision),I!==Q.precision&&console.warn("THREE.WebGLProgram.getParameters:",Q.precision,"not supported, using",I,"instead."));let mn=tt.morphAttributes.position||tt.morphAttributes.normal||tt.morphAttributes.color,cn=mn!==void 0?mn.length:0,bi=0;tt.morphAttributes.position!==void 0&&(bi=1),tt.morphAttributes.normal!==void 0&&(bi=2),tt.morphAttributes.color!==void 0&&(bi=3);let Vt,pn,qn,Yi;if(en){let xn=f2[en];Vt=xn.vertexShader,pn=xn.fragmentShader}else Vt=Q.vertexShader,pn=Q.fragmentShader,_.update(Q),qn=_.getVertexShaderID(Q),Yi=_.getFragmentShaderID(Q);let $i=s.getRenderTarget(),Tr=at.isInstancedMesh===!0,wr=at.isBatchedMesh===!0,Si=!!Q.map,Fr=!!Q.matcap,se=!!Tt,de=!!Q.aoMap,it=!!Q.lightMap,We=!!Q.bumpMap,En=!!Q.normalMap,hr=!!Q.displacementMap,qi=!!Q.emissiveMap,Me=!!Q.metalnessMap,ve=!!Q.roughnessMap,wt=Q.anisotropy>0,gn=Q.clearcoat>0,vn=Q.iridescence>0,Mn=Q.sheen>0,xi=Q.transmission>0,mi=wt&&!!Q.anisotropyMap,ri=gn&&!!Q.clearcoatMap,Ge=gn&&!!Q.clearcoatNormalMap,Ae=gn&&!!Q.clearcoatRoughnessMap,Le=vn&&!!Q.iridescenceMap,ht=vn&&!!Q.iridescenceThicknessMap,Ye=Mn&&!!Q.sheenColorMap,ct=Mn&&!!Q.sheenRoughnessMap,Ze=!!Q.specularMap,Ke=!!Q.specularColorMap,pt=!!Q.specularIntensityMap,Xn=xi&&!!Q.transmissionMap,_i=xi&&!!Q.thicknessMap,Hi=!!Q.gradientMap,_n=!!Q.alphaMap,Je=Q.alphaTest>0,Qn=!!Q.alphaHash,ei=!!Q.extensions,ar=!!tt.attributes.uv1,yn=!!tt.attributes.uv2,Re=!!tt.attributes.uv3,nt=gT;return Q.toneMapped&&($i===null||$i.isXRRenderTarget===!0)&&(nt=s.toneMapping),{isWebGL2:T,shaderID:en,shaderType:Q.type,shaderName:Q.name,vertexShader:Vt,fragmentShader:pn,defines:Q.defines,customVertexShaderID:qn,customFragmentShaderID:Yi,isRawShaderMaterial:Q.isRawShaderMaterial===!0,glslVersion:Q.glslVersion,precision:I,batching:wr,instancing:Tr,instancingColor:Tr&&at.instanceColor!==null,supportsVertexTextures:L,outputColorSpace:$i===null?s.outputColorSpace:$i.isXRRenderTarget===!0?$i.texture.colorSpace:Y3,map:Si,matcap:Fr,envMap:se,envMapMode:se&&Tt.mapping,envMapCubeUVHeight:jt,aoMap:de,lightMap:it,bumpMap:We,normalMap:En,displacementMap:L&&hr,emissiveMap:qi,normalMapObjectSpace:En&&Q.normalMapType===ean,normalMapTangentSpace:En&&Q.normalMapType===M2t,metalnessMap:Me,roughnessMap:ve,anisotropy:wt,anisotropyMap:mi,clearcoat:gn,clearcoatMap:ri,clearcoatNormalMap:Ge,clearcoatRoughnessMap:Ae,iridescence:vn,iridescenceMap:Le,iridescenceThicknessMap:ht,sheen:Mn,sheenColorMap:Ye,sheenRoughnessMap:ct,specularMap:Ze,specularColorMap:Ke,specularIntensityMap:pt,transmission:xi,transmissionMap:Xn,thicknessMap:_i,gradientMap:Hi,opaque:Q.transparent===!1&&Q.blending===oO,alphaMap:_n,alphaTest:Je,alphaHash:Qn,combine:Q.combine,mapUv:Si&&F(Q.map.channel),aoMapUv:de&&F(Q.aoMap.channel),lightMapUv:it&&F(Q.lightMap.channel),bumpMapUv:We&&F(Q.bumpMap.channel),normalMapUv:En&&F(Q.normalMap.channel),displacementMapUv:hr&&F(Q.displacementMap.channel),emissiveMapUv:qi&&F(Q.emissiveMap.channel),metalnessMapUv:Me&&F(Q.metalnessMap.channel),roughnessMapUv:ve&&F(Q.roughnessMap.channel),anisotropyMapUv:mi&&F(Q.anisotropyMap.channel),clearcoatMapUv:ri&&F(Q.clearcoatMap.channel),clearcoatNormalMapUv:Ge&&F(Q.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ae&&F(Q.clearcoatRoughnessMap.channel),iridescenceMapUv:Le&&F(Q.iridescenceMap.channel),iridescenceThicknessMapUv:ht&&F(Q.iridescenceThicknessMap.channel),sheenColorMapUv:Ye&&F(Q.sheenColorMap.channel),sheenRoughnessMapUv:ct&&F(Q.sheenRoughnessMap.channel),specularMapUv:Ze&&F(Q.specularMap.channel),specularColorMapUv:Ke&&F(Q.specularColorMap.channel),specularIntensityMapUv:pt&&F(Q.specularIntensityMap.channel),transmissionMapUv:Xn&&F(Q.transmissionMap.channel),thicknessMapUv:_i&&F(Q.thicknessMap.channel),alphaMapUv:_n&&F(Q.alphaMap.channel),vertexTangents:!!tt.attributes.tangent&&(En||wt),vertexColors:Q.vertexColors,vertexAlphas:Q.vertexColors===!0&&!!tt.attributes.color&&tt.attributes.color.itemSize===4,vertexUv1s:ar,vertexUv2s:yn,vertexUv3s:Re,pointsUvs:at.isPoints===!0&&!!tt.attributes.uv&&(Si||_n),fog:!!Ne,useFog:Q.fog===!0,fogExp2:Ne&&Ne.isFogExp2,flatShading:Q.flatShading===!0,sizeAttenuation:Q.sizeAttenuation===!0,logarithmicDepthBuffer:M,skinning:at.isSkinnedMesh===!0,morphTargets:tt.morphAttributes.position!==void 0,morphNormals:tt.morphAttributes.normal!==void 0,morphColors:tt.morphAttributes.color!==void 0,morphTargetsCount:cn,morphTextureStride:bi,numDirLights:ge.directional.length,numPointLights:ge.point.length,numSpotLights:ge.spot.length,numSpotLightMaps:ge.spotLightMap.length,numRectAreaLights:ge.rectArea.length,numHemiLights:ge.hemi.length,numDirLightShadows:ge.directionalShadowMap.length,numPointLightShadows:ge.pointShadowMap.length,numSpotLightShadows:ge.spotShadowMap.length,numSpotLightShadowsWithMaps:ge.numSpotLightShadowsWithMaps,numLightProbes:ge.numLightProbes,numClippingPlanes:b.numPlanes,numClipIntersection:b.numIntersection,dithering:Q.dithering,shadowMapEnabled:s.shadowMap.enabled&&Qe.length>0,shadowMapType:s.shadowMap.type,toneMapping:nt,useLegacyLights:s._useLegacyLights,decodeVideoTexture:Si&&Q.map.isVideoTexture===!0&&Pc.getTransfer(Q.map.colorSpace)===dl,premultipliedAlpha:Q.premultipliedAlpha,doubleSided:Q.side===Mv,flipSided:Q.side===Tm,useDepthPacking:Q.depthPacking>=0,depthPacking:Q.depthPacking||0,index0AttributeName:Q.index0AttributeName,extensionDerivatives:ei&&Q.extensions.derivatives===!0,extensionFragDepth:ei&&Q.extensions.fragDepth===!0,extensionDrawBuffers:ei&&Q.extensions.drawBuffers===!0,extensionShaderTextureLOD:ei&&Q.extensions.shaderTextureLOD===!0,extensionClipCullDistance:ei&&Q.extensions.clipCullDistance&&c.has("WEBGL_clip_cull_distance"),rendererExtensionFragDepth:T||c.has("EXT_frag_depth"),rendererExtensionDrawBuffers:T||c.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:T||c.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:c.has("KHR_parallel_shader_compile"),customProgramCacheKey:Q.customProgramCacheKey()}}function z(Q){let ge=[];if(Q.shaderID?ge.push(Q.shaderID):(ge.push(Q.customVertexShaderID),ge.push(Q.customFragmentShaderID)),Q.defines!==void 0)for(let Qe in Q.defines)ge.push(Qe),ge.push(Q.defines[Qe]);return Q.isRawShaderMaterial===!1&&(Z(ge,Q),H(ge,Q),ge.push(s.outputColorSpace)),ge.push(Q.customProgramCacheKey),ge.join()}function Z(Q,ge){Q.push(ge.precision),Q.push(ge.outputColorSpace),Q.push(ge.envMapMode),Q.push(ge.envMapCubeUVHeight),Q.push(ge.mapUv),Q.push(ge.alphaMapUv),Q.push(ge.lightMapUv),Q.push(ge.aoMapUv),Q.push(ge.bumpMapUv),Q.push(ge.normalMapUv),Q.push(ge.displacementMapUv),Q.push(ge.emissiveMapUv),Q.push(ge.metalnessMapUv),Q.push(ge.roughnessMapUv),Q.push(ge.anisotropyMapUv),Q.push(ge.clearcoatMapUv),Q.push(ge.clearcoatNormalMapUv),Q.push(ge.clearcoatRoughnessMapUv),Q.push(ge.iridescenceMapUv),Q.push(ge.iridescenceThicknessMapUv),Q.push(ge.sheenColorMapUv),Q.push(ge.sheenRoughnessMapUv),Q.push(ge.specularMapUv),Q.push(ge.specularColorMapUv),Q.push(ge.specularIntensityMapUv),Q.push(ge.transmissionMapUv),Q.push(ge.thicknessMapUv),Q.push(ge.combine),Q.push(ge.fogExp2),Q.push(ge.sizeAttenuation),Q.push(ge.morphTargetsCount),Q.push(ge.morphAttributeCount),Q.push(ge.numDirLights),Q.push(ge.numPointLights),Q.push(ge.numSpotLights),Q.push(ge.numSpotLightMaps),Q.push(ge.numHemiLights),Q.push(ge.numRectAreaLights),Q.push(ge.numDirLightShadows),Q.push(ge.numPointLightShadows),Q.push(ge.numSpotLightShadows),Q.push(ge.numSpotLightShadowsWithMaps),Q.push(ge.numLightProbes),Q.push(ge.shadowMapType),Q.push(ge.toneMapping),Q.push(ge.numClippingPlanes),Q.push(ge.numClipIntersection),Q.push(ge.depthPacking)}function H(Q,ge){w.disableAll(),ge.isWebGL2&&w.enable(0),ge.supportsVertexTextures&&w.enable(1),ge.instancing&&w.enable(2),ge.instancingColor&&w.enable(3),ge.matcap&&w.enable(4),ge.envMap&&w.enable(5),ge.normalMapObjectSpace&&w.enable(6),ge.normalMapTangentSpace&&w.enable(7),ge.clearcoat&&w.enable(8),ge.iridescence&&w.enable(9),ge.alphaTest&&w.enable(10),ge.vertexColors&&w.enable(11),ge.vertexAlphas&&w.enable(12),ge.vertexUv1s&&w.enable(13),ge.vertexUv2s&&w.enable(14),ge.vertexUv3s&&w.enable(15),ge.vertexTangents&&w.enable(16),ge.anisotropy&&w.enable(17),ge.alphaHash&&w.enable(18),ge.batching&&w.enable(19),Q.push(w.mask),w.disableAll(),ge.fog&&w.enable(0),ge.useFog&&w.enable(1),ge.flatShading&&w.enable(2),ge.logarithmicDepthBuffer&&w.enable(3),ge.skinning&&w.enable(4),ge.morphTargets&&w.enable(5),ge.morphNormals&&w.enable(6),ge.morphColors&&w.enable(7),ge.premultipliedAlpha&&w.enable(8),ge.shadowMapEnabled&&w.enable(9),ge.useLegacyLights&&w.enable(10),ge.doubleSided&&w.enable(11),ge.flipSided&&w.enable(12),ge.useDepthPacking&&w.enable(13),ge.dithering&&w.enable(14),ge.transmission&&w.enable(15),ge.sheen&&w.enable(16),ge.opaque&&w.enable(17),ge.pointsUvs&&w.enable(18),ge.decodeVideoTexture&&w.enable(19),Q.push(w.mask)}function te(Q){let ge=D[Q.type],Qe;if(ge){let st=f2[ge];Qe=Man.clone(st.uniforms)}else Qe=Q.uniforms;return Qe}function oe(Q,ge){let Qe;for(let st=0,at=x.length;st0?c.push(z):I.transparent===!0?u.push(z):r.push(z)}function _(M,L,I,D,F,O){let z=b(M,L,I,D,F,O);I.transmission>0?c.unshift(z):I.transparent===!0?u.unshift(z):r.unshift(z)}function x(M,L){r.length>1&&r.sort(M||Ffn),c.length>1&&c.sort(L||n2t),u.length>1&&u.sort(L||n2t)}function T(){for(let M=n,L=s.length;M=d.length?(b=new i2t,d.push(b)):b=d[u],b}function r(){s=new WeakMap}return{get:n,dispose:r}}function zfn(){let s={};return{get:function(n){if(s[n.id]!==void 0)return s[n.id];let r;switch(n.type){case"DirectionalLight":r={direction:new Gt,color:new Go};break;case"SpotLight":r={position:new Gt,direction:new Gt,color:new Go,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":r={position:new Gt,color:new Go,distance:0,decay:0};break;case"HemisphereLight":r={direction:new Gt,skyColor:new Go,groundColor:new Go};break;case"RectAreaLight":r={color:new Go,position:new Gt,halfWidth:new Gt,halfHeight:new Gt};break}return s[n.id]=r,r}}}function Gfn(){let s={};return{get:function(n){if(s[n.id]!==void 0)return s[n.id];let r;switch(n.type){case"DirectionalLight":r={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ka};break;case"SpotLight":r={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ka};break;case"PointLight":r={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ka,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[n.id]=r,r}}}var jfn=0;function $fn(s,n){return(n.castShadow?2:0)-(s.castShadow?2:0)+(n.map?1:0)-(s.map?1:0)}function Vfn(s,n){let r=new zfn,c=Gfn(),u={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let T=0;T<9;T++)u.probe.push(new Gt);let d=new Gt,b=new Il,w=new Il;function _(T,M){let L=0,I=0,D=0;for(let st=0;st<9;st++)u.probe[st].set(0,0,0);let F=0,O=0,z=0,Z=0,H=0,te=0,oe=0,ne=0,ue=0,Te=0,Q=0;T.sort($fn);let ge=M===!0?Math.PI:1;for(let st=0,at=T.length;st0&&(n.isWebGL2?s.has("OES_texture_float_linear")===!0?(u.rectAreaLTC1=ji.LTC_FLOAT_1,u.rectAreaLTC2=ji.LTC_FLOAT_2):(u.rectAreaLTC1=ji.LTC_HALF_1,u.rectAreaLTC2=ji.LTC_HALF_2):s.has("OES_texture_float_linear")===!0?(u.rectAreaLTC1=ji.LTC_FLOAT_1,u.rectAreaLTC2=ji.LTC_FLOAT_2):s.has("OES_texture_half_float_linear")===!0?(u.rectAreaLTC1=ji.LTC_HALF_1,u.rectAreaLTC2=ji.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),u.ambient[0]=L,u.ambient[1]=I,u.ambient[2]=D;let Qe=u.hash;(Qe.directionalLength!==F||Qe.pointLength!==O||Qe.spotLength!==z||Qe.rectAreaLength!==Z||Qe.hemiLength!==H||Qe.numDirectionalShadows!==te||Qe.numPointShadows!==oe||Qe.numSpotShadows!==ne||Qe.numSpotMaps!==ue||Qe.numLightProbes!==Q)&&(u.directional.length=F,u.spot.length=z,u.rectArea.length=Z,u.point.length=O,u.hemi.length=H,u.directionalShadow.length=te,u.directionalShadowMap.length=te,u.pointShadow.length=oe,u.pointShadowMap.length=oe,u.spotShadow.length=ne,u.spotShadowMap.length=ne,u.directionalShadowMatrix.length=te,u.pointShadowMatrix.length=oe,u.spotLightMatrix.length=ne+ue-Te,u.spotLightMap.length=ue,u.numSpotLightShadowsWithMaps=Te,u.numLightProbes=Q,Qe.directionalLength=F,Qe.pointLength=O,Qe.spotLength=z,Qe.rectAreaLength=Z,Qe.hemiLength=H,Qe.numDirectionalShadows=te,Qe.numPointShadows=oe,Qe.numSpotShadows=ne,Qe.numSpotMaps=ue,Qe.numLightProbes=Q,u.version=jfn++)}function x(T,M){let L=0,I=0,D=0,F=0,O=0,z=M.matrixWorldInverse;for(let Z=0,H=T.length;Z=w.length?(_=new r2t(s,n),w.push(_)):_=w[b],_}function u(){r=new WeakMap}return{get:c,dispose:u}}var j6e=class extends _T{constructor(n){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Jon,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(n)}copy(n){return super.copy(n),this.depthPacking=n.depthPacking,this.map=n.map,this.alphaMap=n.alphaMap,this.displacementMap=n.displacementMap,this.displacementScale=n.displacementScale,this.displacementBias=n.displacementBias,this.wireframe=n.wireframe,this.wireframeLinewidth=n.wireframeLinewidth,this}},$6e=class extends _T{constructor(n){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(n)}copy(n){return super.copy(n),this.map=n.map,this.alphaMap=n.alphaMap,this.displacementMap=n.displacementMap,this.displacementScale=n.displacementScale,this.displacementBias=n.displacementBias,this}},Hfn=`void main() { gl_Position = vec4( position, 1.0 ); -}`,Vfn=`uniform sampler2D shadow_pass; +}`,qfn=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include @@ -10099,7 +10099,7 @@ void main() { squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); -}`;function Wfn(s,n,r){let c=new FW,u=new ka,d=new ka,b=new qh,w=new j6e({depthPacking:Zon}),_=new $6e,x={},T=r.maxTextureSize,M={[bT]:Tm,[Tm]:bT,[Mv]:Mv},L=new J3({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ka},radius:{value:4}},vertexShader:$fn,fragmentShader:Vfn}),I=L.clone();I.defines.HORIZONTAL_PASS=1;let D=new d2;D.setAttribute("position",new q1(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let F=new Mm(D,L),O=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=g2t;let z=this.type;this.render=function(ne,ue,Te){if(O.enabled===!1||O.autoUpdate===!1&&O.needsUpdate===!1||ne.length===0)return;let Q=s.getRenderTarget(),ge=s.getActiveCubeFace(),Qe=s.getActiveMipmapLevel(),st=s.state;st.setBlending(pT),st.buffers.color.setClear(1,1,1,1),st.buffers.depth.setTest(!0),st.setScissorTest(!1);let at=z!==H3&&this.type===H3,Ne=z===H3&&this.type!==H3;for(let tt=0,ot=ne.length;ttT||u.y>T)&&(u.x>T&&(d.x=Math.floor(T/en.x),u.x=d.x*en.x,jt.mapSize.x=d.x),u.y>T&&(d.y=Math.floor(T/en.y),u.y=d.y*en.y,jt.mapSize.y=d.y)),jt.map===null||at===!0||Ne===!0){let cn=this.type!==H3?{minFilter:dg,magFilter:dg}:{};jt.map!==null&&jt.map.dispose(),jt.map=new Z3(u.x,u.y,cn),jt.map.texture.name=Tt.name+".shadowMap",jt.camera.updateProjectionMatrix()}s.setRenderTarget(jt.map),s.clear();let mn=jt.getViewportCount();for(let cn=0;cn0||ue.map&&ue.alphaTest>0){let st=ge.uuid,at=ue.uuid,Ne=x[st];Ne===void 0&&(Ne={},x[st]=Ne);let tt=Ne[at];tt===void 0&&(tt=ge.clone(),Ne[at]=tt,ue.addEventListener("dispose",oe)),ge=tt}if(ge.visible=ue.visible,ge.wireframe=ue.wireframe,Q===H3?ge.side=ue.shadowSide!==null?ue.shadowSide:ue.side:ge.side=ue.shadowSide!==null?ue.shadowSide:M[ue.side],ge.alphaMap=ue.alphaMap,ge.alphaTest=ue.alphaTest,ge.map=ue.map,ge.clipShadows=ue.clipShadows,ge.clippingPlanes=ue.clippingPlanes,ge.clipIntersection=ue.clipIntersection,ge.displacementMap=ue.displacementMap,ge.displacementScale=ue.displacementScale,ge.displacementBias=ue.displacementBias,ge.wireframeLinewidth=ue.wireframeLinewidth,ge.linewidth=ue.linewidth,Te.isPointLight===!0&&ge.isMeshDistanceMaterial===!0){let st=s.properties.get(ge);st.light=Te}return ge}function te(ne,ue,Te,Q,ge){if(ne.visible===!1)return;if(ne.layers.test(ue.layers)&&(ne.isMesh||ne.isLine||ne.isPoints)&&(ne.castShadow||ne.receiveShadow&&ge===H3)&&(!ne.frustumCulled||c.intersectsObject(ne))){ne.modelViewMatrix.multiplyMatrices(Te.matrixWorldInverse,ne.matrixWorld);let at=n.update(ne),Ne=ne.material;if(Array.isArray(Ne)){let tt=at.groups;for(let ot=0,Tt=tt.length;ot=1):mn.indexOf("OpenGL ES")!==-1&&(en=parseFloat(/^OpenGL ES (\d)/.exec(mn)[1]),jt=en>=2);let cn=null,bi={},Vt=s.getParameter(s.SCISSOR_BOX),pn=s.getParameter(s.VIEWPORT),qn=new qh().fromArray(Vt),Yi=new qh().fromArray(pn);function $i(Je,Qn,ei,ar){let yn=new Uint8Array(4),Re=s.createTexture();s.bindTexture(Je,Re),s.texParameteri(Je,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(Je,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let nt=0;nt"u"?!1:/OculusBrowser/g.test(navigator.userAgent),T=new WeakMap,M,L=new WeakMap,I=!1;try{I=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function D(Me,ve){return I?new OffscreenCanvas(Me,ve):Yfe("canvas")}function F(Me,ve,wt,gn){let vn=1;if((Me.width>gn||Me.height>gn)&&(vn=gn/Math.max(Me.width,Me.height)),vn<1||ve===!0)if(typeof HTMLImageElement<"u"&&Me instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&Me instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&Me instanceof ImageBitmap){let Mn=ve?L6e:Math.floor,xi=Mn(vn*Me.width),mi=Mn(vn*Me.height);M===void 0&&(M=D(xi,mi));let ri=wt?D(xi,mi):M;return ri.width=xi,ri.height=mi,ri.getContext("2d").drawImage(Me,0,0,xi,mi),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Me.width+"x"+Me.height+") to ("+xi+"x"+mi+")."),ri}else return"data"in Me&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Me.width+"x"+Me.height+")."),Me;return Me}function O(Me){return yyt(Me.width)&&yyt(Me.height)}function z(Me){return w?!1:Me.wrapS!==Tv||Me.wrapT!==Tv||Me.minFilter!==dg&&Me.minFilter!==Ob}function Z(Me,ve){return Me.generateMipmaps&&ve&&Me.minFilter!==dg&&Me.minFilter!==Ob}function H(Me){s.generateMipmap(Me)}function te(Me,ve,wt,gn,vn=!1){if(w===!1)return ve;if(Me!==null){if(s[Me]!==void 0)return s[Me];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+Me+"'")}let Mn=ve;if(ve===s.RED&&(wt===s.FLOAT&&(Mn=s.R32F),wt===s.HALF_FLOAT&&(Mn=s.R16F),wt===s.UNSIGNED_BYTE&&(Mn=s.R8)),ve===s.RED_INTEGER&&(wt===s.UNSIGNED_BYTE&&(Mn=s.R8UI),wt===s.UNSIGNED_SHORT&&(Mn=s.R16UI),wt===s.UNSIGNED_INT&&(Mn=s.R32UI),wt===s.BYTE&&(Mn=s.R8I),wt===s.SHORT&&(Mn=s.R16I),wt===s.INT&&(Mn=s.R32I)),ve===s.RG&&(wt===s.FLOAT&&(Mn=s.RG32F),wt===s.HALF_FLOAT&&(Mn=s.RG16F),wt===s.UNSIGNED_BYTE&&(Mn=s.RG8)),ve===s.RGBA){let xi=vn?Wfe:Pc.getTransfer(gn);wt===s.FLOAT&&(Mn=s.RGBA32F),wt===s.HALF_FLOAT&&(Mn=s.RGBA16F),wt===s.UNSIGNED_BYTE&&(Mn=xi===dl?s.SRGB8_ALPHA8:s.RGBA8),wt===s.UNSIGNED_SHORT_4_4_4_4&&(Mn=s.RGBA4),wt===s.UNSIGNED_SHORT_5_5_5_1&&(Mn=s.RGB5_A1)}return(Mn===s.R16F||Mn===s.R32F||Mn===s.RG16F||Mn===s.RG32F||Mn===s.RGBA16F||Mn===s.RGBA32F)&&n.get("EXT_color_buffer_float"),Mn}function oe(Me,ve,wt){return Z(Me,wt)===!0||Me.isFramebufferTexture&&Me.minFilter!==dg&&Me.minFilter!==Ob?Math.log2(Math.max(ve.width,ve.height))+1:Me.mipmaps!==void 0&&Me.mipmaps.length>0?Me.mipmaps.length:Me.isCompressedTexture&&Array.isArray(Me.image)?ve.mipmaps.length:1}function ne(Me){return Me===dg||Me===$_t||Me===$Ie?s.NEAREST:s.LINEAR}function ue(Me){let ve=Me.target;ve.removeEventListener("dispose",ue),Q(ve),ve.isVideoTexture&&T.delete(ve)}function Te(Me){let ve=Me.target;ve.removeEventListener("dispose",Te),Qe(ve)}function Q(Me){let ve=c.get(Me);if(ve.__webglInit===void 0)return;let wt=Me.source,gn=L.get(wt);if(gn){let vn=gn[ve.__cacheKey];vn.usedTimes--,vn.usedTimes===0&&ge(Me),Object.keys(gn).length===0&&L.delete(wt)}c.remove(Me)}function ge(Me){let ve=c.get(Me);s.deleteTexture(ve.__webglTexture);let wt=Me.source,gn=L.get(wt);delete gn[ve.__cacheKey],b.memory.textures--}function Qe(Me){let ve=Me.texture,wt=c.get(Me),gn=c.get(ve);if(gn.__webglTexture!==void 0&&(s.deleteTexture(gn.__webglTexture),b.memory.textures--),Me.depthTexture&&Me.depthTexture.dispose(),Me.isWebGLCubeRenderTarget)for(let vn=0;vn<6;vn++){if(Array.isArray(wt.__webglFramebuffer[vn]))for(let Mn=0;Mn=u.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+Me+" texture units while this GPU supports only "+u.maxTextures),st+=1,Me}function tt(Me){let ve=[];return ve.push(Me.wrapS),ve.push(Me.wrapT),ve.push(Me.wrapR||0),ve.push(Me.magFilter),ve.push(Me.minFilter),ve.push(Me.anisotropy),ve.push(Me.internalFormat),ve.push(Me.format),ve.push(Me.type),ve.push(Me.generateMipmaps),ve.push(Me.premultiplyAlpha),ve.push(Me.flipY),ve.push(Me.unpackAlignment),ve.push(Me.colorSpace),ve.join()}function ot(Me,ve){let wt=c.get(Me);if(Me.isVideoTexture&&hr(Me),Me.isRenderTargetTexture===!1&&Me.version>0&&wt.__version!==Me.version){let gn=Me.image;if(gn===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(gn.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{qn(wt,Me,ve);return}}r.bindTexture(s.TEXTURE_2D,wt.__webglTexture,s.TEXTURE0+ve)}function Tt(Me,ve){let wt=c.get(Me);if(Me.version>0&&wt.__version!==Me.version){qn(wt,Me,ve);return}r.bindTexture(s.TEXTURE_2D_ARRAY,wt.__webglTexture,s.TEXTURE0+ve)}function jt(Me,ve){let wt=c.get(Me);if(Me.version>0&&wt.__version!==Me.version){qn(wt,Me,ve);return}r.bindTexture(s.TEXTURE_3D,wt.__webglTexture,s.TEXTURE0+ve)}function en(Me,ve){let wt=c.get(Me);if(Me.version>0&&wt.__version!==Me.version){Yi(wt,Me,ve);return}r.bindTexture(s.TEXTURE_CUBE_MAP,wt.__webglTexture,s.TEXTURE0+ve)}let mn={[T6e]:s.REPEAT,[Tv]:s.CLAMP_TO_EDGE,[C6e]:s.MIRRORED_REPEAT},cn={[dg]:s.NEAREST,[$_t]:s.NEAREST_MIPMAP_NEAREST,[$Ie]:s.NEAREST_MIPMAP_LINEAR,[Ob]:s.LINEAR,[zon]:s.LINEAR_MIPMAP_NEAREST,[DW]:s.LINEAR_MIPMAP_LINEAR},bi={[Jon]:s.NEVER,[ran]:s.ALWAYS,[Qon]:s.LESS,[T2t]:s.LEQUAL,[ean]:s.EQUAL,[ian]:s.GEQUAL,[tan]:s.GREATER,[nan]:s.NOTEQUAL};function Vt(Me,ve,wt){if(wt?(s.texParameteri(Me,s.TEXTURE_WRAP_S,mn[ve.wrapS]),s.texParameteri(Me,s.TEXTURE_WRAP_T,mn[ve.wrapT]),(Me===s.TEXTURE_3D||Me===s.TEXTURE_2D_ARRAY)&&s.texParameteri(Me,s.TEXTURE_WRAP_R,mn[ve.wrapR]),s.texParameteri(Me,s.TEXTURE_MAG_FILTER,cn[ve.magFilter]),s.texParameteri(Me,s.TEXTURE_MIN_FILTER,cn[ve.minFilter])):(s.texParameteri(Me,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(Me,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),(Me===s.TEXTURE_3D||Me===s.TEXTURE_2D_ARRAY)&&s.texParameteri(Me,s.TEXTURE_WRAP_R,s.CLAMP_TO_EDGE),(ve.wrapS!==Tv||ve.wrapT!==Tv)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),s.texParameteri(Me,s.TEXTURE_MAG_FILTER,ne(ve.magFilter)),s.texParameteri(Me,s.TEXTURE_MIN_FILTER,ne(ve.minFilter)),ve.minFilter!==dg&&ve.minFilter!==Ob&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),ve.compareFunction&&(s.texParameteri(Me,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(Me,s.TEXTURE_COMPARE_FUNC,bi[ve.compareFunction])),n.has("EXT_texture_filter_anisotropic")===!0){let gn=n.get("EXT_texture_filter_anisotropic");if(ve.magFilter===dg||ve.minFilter!==$Ie&&ve.minFilter!==DW||ve.type===hT&&n.has("OES_texture_float_linear")===!1||w===!1&&ve.type===BW&&n.has("OES_texture_half_float_linear")===!1)return;(ve.anisotropy>1||c.get(ve).__currentAnisotropy)&&(s.texParameterf(Me,gn.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(ve.anisotropy,u.getMaxAnisotropy())),c.get(ve).__currentAnisotropy=ve.anisotropy)}}function pn(Me,ve){let wt=!1;Me.__webglInit===void 0&&(Me.__webglInit=!0,ve.addEventListener("dispose",ue));let gn=ve.source,vn=L.get(gn);vn===void 0&&(vn={},L.set(gn,vn));let Mn=tt(ve);if(Mn!==Me.__cacheKey){vn[Mn]===void 0&&(vn[Mn]={texture:s.createTexture(),usedTimes:0},b.memory.textures++,wt=!0),vn[Mn].usedTimes++;let xi=vn[Me.__cacheKey];xi!==void 0&&(vn[Me.__cacheKey].usedTimes--,xi.usedTimes===0&&ge(ve)),Me.__cacheKey=Mn,Me.__webglTexture=vn[Mn].texture}return wt}function qn(Me,ve,wt){let gn=s.TEXTURE_2D;(ve.isDataArrayTexture||ve.isCompressedArrayTexture)&&(gn=s.TEXTURE_2D_ARRAY),ve.isData3DTexture&&(gn=s.TEXTURE_3D);let vn=pn(Me,ve),Mn=ve.source;r.bindTexture(gn,Me.__webglTexture,s.TEXTURE0+wt);let xi=c.get(Mn);if(Mn.version!==xi.__version||vn===!0){r.activeTexture(s.TEXTURE0+wt);let mi=Pc.getPrimaries(Pc.workingColorSpace),ri=ve.colorSpace===Nb?null:Pc.getPrimaries(ve.colorSpace),Ge=ve.colorSpace===Nb||mi===ri?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,ve.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ve.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,ve.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ge);let Ae=z(ve)&&O(ve.image)===!1,Le=F(ve.image,Ae,!1,u.maxTextureSize);Le=qi(ve,Le);let ht=O(Le)||w,Ye=d.convert(ve.format,ve.colorSpace),ct=d.convert(ve.type),Ze=te(ve.internalFormat,Ye,ct,ve.colorSpace,ve.isVideoTexture);Vt(gn,ve,ht);let Ke,pt=ve.mipmaps,Xn=w&&ve.isVideoTexture!==!0&&Ze!==E2t,_i=xi.__version===void 0||vn===!0,Hi=oe(ve,Le,ht);if(ve.isDepthTexture)Ze=s.DEPTH_COMPONENT,w?ve.type===hT?Ze=s.DEPTH_COMPONENT32F:ve.type===fT?Ze=s.DEPTH_COMPONENT24:ve.type===W4?Ze=s.DEPTH24_STENCIL8:Ze=s.DEPTH_COMPONENT16:ve.type===hT&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),ve.format===H4&&Ze===s.DEPTH_COMPONENT&&ve.type!==l5e&&ve.type!==fT&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),ve.type=fT,ct=d.convert(ve.type)),ve.format===fO&&Ze===s.DEPTH_COMPONENT&&(Ze=s.DEPTH_STENCIL,ve.type!==W4&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),ve.type=W4,ct=d.convert(ve.type))),_i&&(Xn?r.texStorage2D(s.TEXTURE_2D,1,Ze,Le.width,Le.height):r.texImage2D(s.TEXTURE_2D,0,Ze,Le.width,Le.height,0,Ye,ct,null));else if(ve.isDataTexture)if(pt.length>0&&ht){Xn&&_i&&r.texStorage2D(s.TEXTURE_2D,Hi,Ze,pt[0].width,pt[0].height);for(let _n=0,Je=pt.length;_n>=1,Je>>=1}}else if(pt.length>0&&ht){Xn&&_i&&r.texStorage2D(s.TEXTURE_2D,Hi,Ze,pt[0].width,pt[0].height);for(let _n=0,Je=pt.length;_n0&&_i++,r.texStorage2D(s.TEXTURE_CUBE_MAP,_i,Ke,Le[0].width,Le[0].height));for(let _n=0;_n<6;_n++)if(Ae){pt?r.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+_n,0,0,0,Le[_n].width,Le[_n].height,ct,Ze,Le[_n].data):r.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+_n,0,Ke,Le[_n].width,Le[_n].height,0,ct,Ze,Le[_n].data);for(let Je=0;Je>Mn),Le=Math.max(1,ve.height>>Mn);vn===s.TEXTURE_3D||vn===s.TEXTURE_2D_ARRAY?r.texImage3D(vn,Mn,ri,Ae,Le,ve.depth,0,xi,mi,null):r.texImage2D(vn,Mn,ri,Ae,Le,0,xi,mi,null)}r.bindFramebuffer(s.FRAMEBUFFER,Me),En(ve)?_.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,gn,vn,c.get(wt).__webglTexture,0,We(ve)):(vn===s.TEXTURE_2D||vn>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&vn<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,gn,vn,c.get(wt).__webglTexture,Mn),r.bindFramebuffer(s.FRAMEBUFFER,null)}function Tr(Me,ve,wt){if(s.bindRenderbuffer(s.RENDERBUFFER,Me),ve.depthBuffer&&!ve.stencilBuffer){let gn=w===!0?s.DEPTH_COMPONENT24:s.DEPTH_COMPONENT16;if(wt||En(ve)){let vn=ve.depthTexture;vn&&vn.isDepthTexture&&(vn.type===hT?gn=s.DEPTH_COMPONENT32F:vn.type===fT&&(gn=s.DEPTH_COMPONENT24));let Mn=We(ve);En(ve)?_.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Mn,gn,ve.width,ve.height):s.renderbufferStorageMultisample(s.RENDERBUFFER,Mn,gn,ve.width,ve.height)}else s.renderbufferStorage(s.RENDERBUFFER,gn,ve.width,ve.height);s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,Me)}else if(ve.depthBuffer&&ve.stencilBuffer){let gn=We(ve);wt&&En(ve)===!1?s.renderbufferStorageMultisample(s.RENDERBUFFER,gn,s.DEPTH24_STENCIL8,ve.width,ve.height):En(ve)?_.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,gn,s.DEPTH24_STENCIL8,ve.width,ve.height):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,ve.width,ve.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,Me)}else{let gn=ve.isWebGLMultipleRenderTargets===!0?ve.texture:[ve.texture];for(let vn=0;vn0){wt.__webglFramebuffer[mi]=[];for(let ri=0;ri0){wt.__webglFramebuffer=[];for(let mi=0;mi0&&En(Me)===!1){let mi=Mn?ve:[ve];wt.__webglMultisampledFramebuffer=s.createFramebuffer(),wt.__webglColorRenderbuffer=[],r.bindFramebuffer(s.FRAMEBUFFER,wt.__webglMultisampledFramebuffer);for(let ri=0;ri0)for(let ri=0;ri0)for(let ri=0;ri0&&En(Me)===!1){let ve=Me.isWebGLMultipleRenderTargets?Me.texture:[Me.texture],wt=Me.width,gn=Me.height,vn=s.COLOR_BUFFER_BIT,Mn=[],xi=Me.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,mi=c.get(Me),ri=Me.isWebGLMultipleRenderTargets===!0;if(ri)for(let Ge=0;Ge0&&n.has("WEBGL_multisampled_render_to_texture")===!0&&ve.__useRenderToTexture!==!1}function hr(Me){let ve=b.render.frame;T.get(Me)!==ve&&(T.set(Me,ve),Me.update())}function qi(Me,ve){let wt=Me.colorSpace,gn=Me.format,vn=Me.type;return Me.isCompressedTexture===!0||Me.isVideoTexture===!0||Me.format===A6e||wt!==Y3&&wt!==Nb&&(Pc.getTransfer(wt)===dl?w===!1?n.has("EXT_sRGB")===!0&&gn===Cv?(Me.format=A6e,Me.minFilter=Ob,Me.generateMipmaps=!1):ve=Zfe.sRGBToLinear(ve):(gn!==Cv||vn!==mT)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",wt)),ve}this.allocateTextureUnit=Ne,this.resetTextureUnits=at,this.setTexture2D=ot,this.setTexture2DArray=Tt,this.setTexture3D=jt,this.setTextureCube=en,this.rebindTextures=Fr,this.setupRenderTarget=se,this.updateRenderTargetMipmap=de,this.updateMultisampleRenderTarget=it,this.setupDepthRenderbuffer=Si,this.setupFrameBufferTexture=$i,this.useMultisampledRTT=En}function Xfn(s,n,r){let c=r.isWebGL2;function u(d,b=Nb){let w,_=Pc.getTransfer(b);if(d===mT)return s.UNSIGNED_BYTE;if(d===w2t)return s.UNSIGNED_SHORT_4_4_4_4;if(d===v2t)return s.UNSIGNED_SHORT_5_5_5_1;if(d===Gon)return s.BYTE;if(d===jon)return s.SHORT;if(d===l5e)return s.UNSIGNED_SHORT;if(d===b2t)return s.INT;if(d===fT)return s.UNSIGNED_INT;if(d===hT)return s.FLOAT;if(d===BW)return c?s.HALF_FLOAT:(w=n.get("OES_texture_half_float"),w!==null?w.HALF_FLOAT_OES:null);if(d===$on)return s.ALPHA;if(d===Cv)return s.RGBA;if(d===Von)return s.LUMINANCE;if(d===Won)return s.LUMINANCE_ALPHA;if(d===H4)return s.DEPTH_COMPONENT;if(d===fO)return s.DEPTH_STENCIL;if(d===A6e)return w=n.get("EXT_sRGB"),w!==null?w.SRGB_ALPHA_EXT:null;if(d===Hon)return s.RED;if(d===_2t)return s.RED_INTEGER;if(d===qon)return s.RG;if(d===y2t)return s.RG_INTEGER;if(d===x2t)return s.RGBA_INTEGER;if(d===VIe||d===WIe||d===HIe||d===qIe)if(_===dl)if(w=n.get("WEBGL_compressed_texture_s3tc_srgb"),w!==null){if(d===VIe)return w.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(d===WIe)return w.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(d===HIe)return w.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(d===qIe)return w.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(w=n.get("WEBGL_compressed_texture_s3tc"),w!==null){if(d===VIe)return w.COMPRESSED_RGB_S3TC_DXT1_EXT;if(d===WIe)return w.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(d===HIe)return w.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(d===qIe)return w.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(d===V_t||d===W_t||d===H_t||d===q_t)if(w=n.get("WEBGL_compressed_texture_pvrtc"),w!==null){if(d===V_t)return w.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(d===W_t)return w.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(d===H_t)return w.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(d===q_t)return w.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(d===E2t)return w=n.get("WEBGL_compressed_texture_etc1"),w!==null?w.COMPRESSED_RGB_ETC1_WEBGL:null;if(d===X_t||d===Y_t)if(w=n.get("WEBGL_compressed_texture_etc"),w!==null){if(d===X_t)return _===dl?w.COMPRESSED_SRGB8_ETC2:w.COMPRESSED_RGB8_ETC2;if(d===Y_t)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:w.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(d===Z_t||d===K_t||d===J_t||d===Q_t||d===eyt||d===tyt||d===nyt||d===iyt||d===ryt||d===syt||d===oyt||d===ayt||d===cyt||d===lyt)if(w=n.get("WEBGL_compressed_texture_astc"),w!==null){if(d===Z_t)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:w.COMPRESSED_RGBA_ASTC_4x4_KHR;if(d===K_t)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:w.COMPRESSED_RGBA_ASTC_5x4_KHR;if(d===J_t)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:w.COMPRESSED_RGBA_ASTC_5x5_KHR;if(d===Q_t)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:w.COMPRESSED_RGBA_ASTC_6x5_KHR;if(d===eyt)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:w.COMPRESSED_RGBA_ASTC_6x6_KHR;if(d===tyt)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:w.COMPRESSED_RGBA_ASTC_8x5_KHR;if(d===nyt)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:w.COMPRESSED_RGBA_ASTC_8x6_KHR;if(d===iyt)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:w.COMPRESSED_RGBA_ASTC_8x8_KHR;if(d===ryt)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:w.COMPRESSED_RGBA_ASTC_10x5_KHR;if(d===syt)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:w.COMPRESSED_RGBA_ASTC_10x6_KHR;if(d===oyt)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:w.COMPRESSED_RGBA_ASTC_10x8_KHR;if(d===ayt)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:w.COMPRESSED_RGBA_ASTC_10x10_KHR;if(d===cyt)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:w.COMPRESSED_RGBA_ASTC_12x10_KHR;if(d===lyt)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:w.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(d===XIe||d===uyt||d===fyt)if(w=n.get("EXT_texture_compression_bptc"),w!==null){if(d===XIe)return _===dl?w.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:w.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(d===uyt)return w.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(d===fyt)return w.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(d===Xon||d===hyt||d===dyt||d===pyt)if(w=n.get("EXT_texture_compression_rgtc"),w!==null){if(d===XIe)return w.COMPRESSED_RED_RGTC1_EXT;if(d===hyt)return w.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(d===dyt)return w.COMPRESSED_RED_GREEN_RGTC2_EXT;if(d===pyt)return w.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return d===W4?c?s.UNSIGNED_INT_24_8:(w=n.get("WEBGL_depth_texture"),w!==null?w.UNSIGNED_INT_24_8_WEBGL:null):s[d]!==void 0?s[d]:null}return{convert:u}}var V6e=class extends pg{constructor(n=[]){super(),this.isArrayCamera=!0,this.cameras=n}},dT=class extends gg{constructor(){super(),this.isGroup=!0,this.type="Group"}},Yfn={type:"move"},IW=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new dT,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new dT,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Gt,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Gt),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new dT,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Gt,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Gt),this._grip}dispatchEvent(n){return this._targetRay!==null&&this._targetRay.dispatchEvent(n),this._grip!==null&&this._grip.dispatchEvent(n),this._hand!==null&&this._hand.dispatchEvent(n),this}connect(n){if(n&&n.hand){let r=this._hand;if(r)for(let c of n.hand.values())this._getHandJoint(r,c)}return this.dispatchEvent({type:"connected",data:n}),this}disconnect(n){return this.dispatchEvent({type:"disconnected",data:n}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(n,r,c){let u=null,d=null,b=null,w=this._targetRay,_=this._grip,x=this._hand;if(n&&r.session.visibilityState!=="visible-blurred"){if(x&&n.hand){b=!0;for(let F of n.hand.values()){let O=r.getJointPose(F,c),z=this._getHandJoint(x,F);O!==null&&(z.matrix.fromArray(O.transform.matrix),z.matrix.decompose(z.position,z.rotation,z.scale),z.matrixWorldNeedsUpdate=!0,z.jointRadius=O.radius),z.visible=O!==null}let T=x.joints["index-finger-tip"],M=x.joints["thumb-tip"],L=T.position.distanceTo(M.position),I=.02,D=.005;x.inputState.pinching&&L>I+D?(x.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:n.handedness,target:this})):!x.inputState.pinching&&L<=I-D&&(x.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:n.handedness,target:this}))}else _!==null&&n.gripSpace&&(d=r.getPose(n.gripSpace,c),d!==null&&(_.matrix.fromArray(d.transform.matrix),_.matrix.decompose(_.position,_.rotation,_.scale),_.matrixWorldNeedsUpdate=!0,d.linearVelocity?(_.hasLinearVelocity=!0,_.linearVelocity.copy(d.linearVelocity)):_.hasLinearVelocity=!1,d.angularVelocity?(_.hasAngularVelocity=!0,_.angularVelocity.copy(d.angularVelocity)):_.hasAngularVelocity=!1));w!==null&&(u=r.getPose(n.targetRaySpace,c),u===null&&d!==null&&(u=d),u!==null&&(w.matrix.fromArray(u.transform.matrix),w.matrix.decompose(w.position,w.rotation,w.scale),w.matrixWorldNeedsUpdate=!0,u.linearVelocity?(w.hasLinearVelocity=!0,w.linearVelocity.copy(u.linearVelocity)):w.hasLinearVelocity=!1,u.angularVelocity?(w.hasAngularVelocity=!0,w.angularVelocity.copy(u.angularVelocity)):w.hasAngularVelocity=!1,this.dispatchEvent(Yfn)))}return w!==null&&(w.visible=u!==null),_!==null&&(_.visible=d!==null),x!==null&&(x.visible=b!==null),this}_getHandJoint(n,r){if(n.joints[r.jointName]===void 0){let c=new dT;c.matrixAutoUpdate=!1,c.visible=!1,n.joints[r.jointName]=c,n.add(c)}return n.joints[r.jointName]}},W6e=class extends wT{constructor(n,r){super();let c=this,u=null,d=1,b=null,w="local-floor",_=1,x=null,T=null,M=null,L=null,I=null,D=null,F=r.getContextAttributes(),O=null,z=null,Z=[],H=[],te=new ka,oe=null,ne=new pg;ne.layers.enable(1),ne.viewport=new qh;let ue=new pg;ue.layers.enable(2),ue.viewport=new qh;let Te=[ne,ue],Q=new V6e;Q.layers.enable(1),Q.layers.enable(2);let ge=null,Qe=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Vt){let pn=Z[Vt];return pn===void 0&&(pn=new IW,Z[Vt]=pn),pn.getTargetRaySpace()},this.getControllerGrip=function(Vt){let pn=Z[Vt];return pn===void 0&&(pn=new IW,Z[Vt]=pn),pn.getGripSpace()},this.getHand=function(Vt){let pn=Z[Vt];return pn===void 0&&(pn=new IW,Z[Vt]=pn),pn.getHandSpace()};function st(Vt){let pn=H.indexOf(Vt.inputSource);if(pn===-1)return;let qn=Z[pn];qn!==void 0&&(qn.update(Vt.inputSource,Vt.frame,x||b),qn.dispatchEvent({type:Vt.type,data:Vt.inputSource}))}function at(){u.removeEventListener("select",st),u.removeEventListener("selectstart",st),u.removeEventListener("selectend",st),u.removeEventListener("squeeze",st),u.removeEventListener("squeezestart",st),u.removeEventListener("squeezeend",st),u.removeEventListener("end",at),u.removeEventListener("inputsourceschange",Ne);for(let Vt=0;Vt=0&&(H[Yi]=null,Z[Yi].disconnect(qn))}for(let pn=0;pn=H.length){H.push(qn),Yi=Tr;break}else if(H[Tr]===null){H[Tr]=qn,Yi=Tr;break}if(Yi===-1)break}let $i=Z[Yi];$i&&$i.connect(qn)}}let tt=new Gt,ot=new Gt;function Tt(Vt,pn,qn){tt.setFromMatrixPosition(pn.matrixWorld),ot.setFromMatrixPosition(qn.matrixWorld);let Yi=tt.distanceTo(ot),$i=pn.projectionMatrix.elements,Tr=qn.projectionMatrix.elements,wr=$i[14]/($i[10]-1),Si=$i[14]/($i[10]+1),Fr=($i[9]+1)/$i[5],se=($i[9]-1)/$i[5],de=($i[8]-1)/$i[0],it=(Tr[8]+1)/Tr[0],We=wr*de,En=wr*it,hr=Yi/(-de+it),qi=hr*-de;pn.matrixWorld.decompose(Vt.position,Vt.quaternion,Vt.scale),Vt.translateX(qi),Vt.translateZ(hr),Vt.matrixWorld.compose(Vt.position,Vt.quaternion,Vt.scale),Vt.matrixWorldInverse.copy(Vt.matrixWorld).invert();let Me=wr+hr,ve=Si+hr,wt=We-qi,gn=En+(Yi-qi),vn=Fr*Si/ve*Me,Mn=se*Si/ve*Me;Vt.projectionMatrix.makePerspective(wt,gn,vn,Mn,Me,ve),Vt.projectionMatrixInverse.copy(Vt.projectionMatrix).invert()}function jt(Vt,pn){pn===null?Vt.matrixWorld.copy(Vt.matrix):Vt.matrixWorld.multiplyMatrices(pn.matrixWorld,Vt.matrix),Vt.matrixWorldInverse.copy(Vt.matrixWorld).invert()}this.updateCamera=function(Vt){if(u===null)return;Q.near=ue.near=ne.near=Vt.near,Q.far=ue.far=ne.far=Vt.far,(ge!==Q.near||Qe!==Q.far)&&(u.updateRenderState({depthNear:Q.near,depthFar:Q.far}),ge=Q.near,Qe=Q.far);let pn=Vt.parent,qn=Q.cameras;jt(Q,pn);for(let Yi=0;Yi0&&(O.alphaTest.value=z.alphaTest);let Z=n.get(z).envMap;if(Z&&(O.envMap.value=Z,O.flipEnvMap.value=Z.isCubeTexture&&Z.isRenderTargetTexture===!1?-1:1,O.reflectivity.value=z.reflectivity,O.ior.value=z.ior,O.refractionRatio.value=z.refractionRatio),z.lightMap){O.lightMap.value=z.lightMap;let H=s._useLegacyLights===!0?Math.PI:1;O.lightMapIntensity.value=z.lightMapIntensity*H,r(z.lightMap,O.lightMapTransform)}z.aoMap&&(O.aoMap.value=z.aoMap,O.aoMapIntensity.value=z.aoMapIntensity,r(z.aoMap,O.aoMapTransform))}function b(O,z){O.diffuse.value.copy(z.color),O.opacity.value=z.opacity,z.map&&(O.map.value=z.map,r(z.map,O.mapTransform))}function w(O,z){O.dashSize.value=z.dashSize,O.totalSize.value=z.dashSize+z.gapSize,O.scale.value=z.scale}function _(O,z,Z,H){O.diffuse.value.copy(z.color),O.opacity.value=z.opacity,O.size.value=z.size*Z,O.scale.value=H*.5,z.map&&(O.map.value=z.map,r(z.map,O.uvTransform)),z.alphaMap&&(O.alphaMap.value=z.alphaMap,r(z.alphaMap,O.alphaMapTransform)),z.alphaTest>0&&(O.alphaTest.value=z.alphaTest)}function x(O,z){O.diffuse.value.copy(z.color),O.opacity.value=z.opacity,O.rotation.value=z.rotation,z.map&&(O.map.value=z.map,r(z.map,O.mapTransform)),z.alphaMap&&(O.alphaMap.value=z.alphaMap,r(z.alphaMap,O.alphaMapTransform)),z.alphaTest>0&&(O.alphaTest.value=z.alphaTest)}function T(O,z){O.specular.value.copy(z.specular),O.shininess.value=Math.max(z.shininess,1e-4)}function M(O,z){z.gradientMap&&(O.gradientMap.value=z.gradientMap)}function L(O,z){O.metalness.value=z.metalness,z.metalnessMap&&(O.metalnessMap.value=z.metalnessMap,r(z.metalnessMap,O.metalnessMapTransform)),O.roughness.value=z.roughness,z.roughnessMap&&(O.roughnessMap.value=z.roughnessMap,r(z.roughnessMap,O.roughnessMapTransform)),n.get(z).envMap&&(O.envMapIntensity.value=z.envMapIntensity)}function I(O,z,Z){O.ior.value=z.ior,z.sheen>0&&(O.sheenColor.value.copy(z.sheenColor).multiplyScalar(z.sheen),O.sheenRoughness.value=z.sheenRoughness,z.sheenColorMap&&(O.sheenColorMap.value=z.sheenColorMap,r(z.sheenColorMap,O.sheenColorMapTransform)),z.sheenRoughnessMap&&(O.sheenRoughnessMap.value=z.sheenRoughnessMap,r(z.sheenRoughnessMap,O.sheenRoughnessMapTransform))),z.clearcoat>0&&(O.clearcoat.value=z.clearcoat,O.clearcoatRoughness.value=z.clearcoatRoughness,z.clearcoatMap&&(O.clearcoatMap.value=z.clearcoatMap,r(z.clearcoatMap,O.clearcoatMapTransform)),z.clearcoatRoughnessMap&&(O.clearcoatRoughnessMap.value=z.clearcoatRoughnessMap,r(z.clearcoatRoughnessMap,O.clearcoatRoughnessMapTransform)),z.clearcoatNormalMap&&(O.clearcoatNormalMap.value=z.clearcoatNormalMap,r(z.clearcoatNormalMap,O.clearcoatNormalMapTransform),O.clearcoatNormalScale.value.copy(z.clearcoatNormalScale),z.side===Tm&&O.clearcoatNormalScale.value.negate())),z.iridescence>0&&(O.iridescence.value=z.iridescence,O.iridescenceIOR.value=z.iridescenceIOR,O.iridescenceThicknessMinimum.value=z.iridescenceThicknessRange[0],O.iridescenceThicknessMaximum.value=z.iridescenceThicknessRange[1],z.iridescenceMap&&(O.iridescenceMap.value=z.iridescenceMap,r(z.iridescenceMap,O.iridescenceMapTransform)),z.iridescenceThicknessMap&&(O.iridescenceThicknessMap.value=z.iridescenceThicknessMap,r(z.iridescenceThicknessMap,O.iridescenceThicknessMapTransform))),z.transmission>0&&(O.transmission.value=z.transmission,O.transmissionSamplerMap.value=Z.texture,O.transmissionSamplerSize.value.set(Z.width,Z.height),z.transmissionMap&&(O.transmissionMap.value=z.transmissionMap,r(z.transmissionMap,O.transmissionMapTransform)),O.thickness.value=z.thickness,z.thicknessMap&&(O.thicknessMap.value=z.thicknessMap,r(z.thicknessMap,O.thicknessMapTransform)),O.attenuationDistance.value=z.attenuationDistance,O.attenuationColor.value.copy(z.attenuationColor)),z.anisotropy>0&&(O.anisotropyVector.value.set(z.anisotropy*Math.cos(z.anisotropyRotation),z.anisotropy*Math.sin(z.anisotropyRotation)),z.anisotropyMap&&(O.anisotropyMap.value=z.anisotropyMap,r(z.anisotropyMap,O.anisotropyMapTransform))),O.specularIntensity.value=z.specularIntensity,O.specularColor.value.copy(z.specularColor),z.specularColorMap&&(O.specularColorMap.value=z.specularColorMap,r(z.specularColorMap,O.specularColorMapTransform)),z.specularIntensityMap&&(O.specularIntensityMap.value=z.specularIntensityMap,r(z.specularIntensityMap,O.specularIntensityMapTransform))}function D(O,z){z.matcap&&(O.matcap.value=z.matcap)}function F(O,z){let Z=n.get(z).light;O.referencePosition.value.setFromMatrixPosition(Z.matrixWorld),O.nearDistance.value=Z.shadow.camera.near,O.farDistance.value=Z.shadow.camera.far}return{refreshFogUniforms:c,refreshMaterialUniforms:u}}function Kfn(s,n,r,c){let u={},d={},b=[],w=r.isWebGL2?s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS):0;function _(Z,H){let te=H.program;c.uniformBlockBinding(Z,te)}function x(Z,H){let te=u[Z.id];te===void 0&&(D(Z),te=T(Z),u[Z.id]=te,Z.addEventListener("dispose",O));let oe=H.program;c.updateUBOMapping(Z,oe);let ne=n.render.frame;d[Z.id]!==ne&&(L(Z),d[Z.id]=ne)}function T(Z){let H=M();Z.__bindingPointIndex=H;let te=s.createBuffer(),oe=Z.__size,ne=Z.usage;return s.bindBuffer(s.UNIFORM_BUFFER,te),s.bufferData(s.UNIFORM_BUFFER,oe,ne),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,H,te),te}function M(){for(let Z=0;Z0&&(te+=oe-ne),Z.__size=te,Z.__cache={},this}function F(Z){let H={boundary:0,storage:0};return typeof Z=="number"||typeof Z=="boolean"?(H.boundary=4,H.storage=4):Z.isVector2?(H.boundary=8,H.storage=8):Z.isVector3||Z.isColor?(H.boundary=16,H.storage=12):Z.isVector4?(H.boundary=16,H.storage=16):Z.isMatrix3?(H.boundary=48,H.storage=48):Z.isMatrix4?(H.boundary=64,H.storage=64):Z.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",Z),H}function O(Z){let H=Z.target;H.removeEventListener("dispose",O);let te=b.indexOf(H.__bindingPointIndex);b.splice(te,1),s.deleteBuffer(u[H.id]),delete u[H.id],delete d[H.id]}function z(){for(let Z in u)s.deleteBuffer(u[Z]);b=[],u={},d={}}return{bind:_,update:x,dispose:z}}var UW=class{constructor(n={}){let{canvas:r=oan(),context:c=null,depth:u=!0,stencil:d=!0,alpha:b=!1,antialias:w=!1,premultipliedAlpha:_=!0,preserveDrawingBuffer:x=!1,powerPreference:T="default",failIfMajorPerformanceCaveat:M=!1}=n;this.isWebGLRenderer=!0;let L;c!==null?L=c.getContextAttributes().alpha:L=b;let I=new Uint32Array(4),D=new Int32Array(4),F=null,O=null,z=[],Z=[];this.domElement=r,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Td,this._useLegacyLights=!1,this.toneMapping=gT,this.toneMappingExposure=1;let H=this,te=!1,oe=0,ne=0,ue=null,Te=-1,Q=null,ge=new qh,Qe=new qh,st=null,at=new Go(0),Ne=0,tt=r.width,ot=r.height,Tt=1,jt=null,en=null,mn=new qh(0,0,tt,ot),cn=new qh(0,0,tt,ot),bi=!1,Vt=new FW,pn=!1,qn=!1,Yi=null,$i=new Il,Tr=new ka,wr=new Gt,Si={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Fr(){return ue===null?Tt:1}let se=c;function de(Pe,xt){for(let Kt=0;Kt{function Zi(){if(tn.forEach(function(Rr){qi.get(Rr).currentProgram.isReady()&&tn.delete(Rr)}),tn.size===0){Yt(Pe);return}setTimeout(Zi,10)}it.get("KHR_parallel_shader_compile")!==null?Zi():setTimeout(Zi,10)})};let nt=null;function kt(Pe){nt&&nt(Pe)}function xn(){Xi.stop()}function Ei(){Xi.start()}let Xi=new L2t;Xi.setAnimationLoop(kt),typeof self<"u"&&Xi.setContext(self),this.setAnimationLoop=function(Pe){nt=Pe,Hi.setAnimationLoop(Pe),Pe===null?Xi.stop():Xi.start()},Hi.addEventListener("sessionstart",xn),Hi.addEventListener("sessionend",Ei),this.render=function(Pe,xt){if(xt!==void 0&&xt.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(te===!0)return;Pe.matrixWorldAutoUpdate===!0&&Pe.updateMatrixWorld(),xt.parent===null&&xt.matrixWorldAutoUpdate===!0&&xt.updateMatrixWorld(),Hi.enabled===!0&&Hi.isPresenting===!0&&(Hi.cameraAutoUpdate===!0&&Hi.updateCamera(xt),xt=Hi.getCamera()),Pe.isScene===!0&&Pe.onBeforeRender(H,Pe,xt,ue),O=Ge.get(Pe,Z.length),O.init(),Z.push(O),$i.multiplyMatrices(xt.projectionMatrix,xt.matrixWorldInverse),Vt.setFromProjectionMatrix($i),qn=this.localClippingEnabled,pn=Ae.init(this.clippingPlanes,qn),F=ri.get(Pe,z.length),F.init(),z.push(F),cr(Pe,xt,0,H.sortObjects),F.finish(),H.sortObjects===!0&&F.sort(jt,en),this.info.render.frame++,pn===!0&&Ae.beginShadows();let Kt=O.state.shadowsArray;if(Le.render(Kt,Pe,xt),pn===!0&&Ae.endShadows(),this.info.autoReset===!0&&this.info.reset(),ht.render(F,Pe),O.setupLights(H._useLegacyLights),xt.isArrayCamera){let tn=xt.cameras;for(let Yt=0,Zi=tn.length;Yt0?O=Z[Z.length-1]:O=null,z.pop(),z.length>0?F=z[z.length-1]:F=null};function cr(Pe,xt,Kt,tn){if(Pe.visible===!1)return;if(Pe.layers.test(xt.layers)){if(Pe.isGroup)Kt=Pe.renderOrder;else if(Pe.isLOD)Pe.autoUpdate===!0&&Pe.update(xt);else if(Pe.isLight)O.pushLight(Pe),Pe.castShadow&&O.pushShadow(Pe);else if(Pe.isSprite){if(!Pe.frustumCulled||Vt.intersectsSprite(Pe)){tn&&wr.setFromMatrixPosition(Pe.matrixWorld).applyMatrix4($i);let Rr=Mn.update(Pe),Xr=Pe.material;Xr.visible&&F.push(Pe,Rr,Xr,Kt,wr.z,null)}}else if((Pe.isMesh||Pe.isLine||Pe.isPoints)&&(!Pe.frustumCulled||Vt.intersectsObject(Pe))){let Rr=Mn.update(Pe),Xr=Pe.material;if(tn&&(Pe.boundingSphere!==void 0?(Pe.boundingSphere===null&&Pe.computeBoundingSphere(),wr.copy(Pe.boundingSphere.center)):(Rr.boundingSphere===null&&Rr.computeBoundingSphere(),wr.copy(Rr.boundingSphere.center)),wr.applyMatrix4(Pe.matrixWorld).applyMatrix4($i)),Array.isArray(Xr)){let bs=Rr.groups;for(let Vs=0,xs=bs.length;Vs0&&Ks(Yt,Zi,xt,Kt),tn&&En.viewport(ge.copy(tn)),Yt.length>0&&Bi(Yt,xt,Kt),Zi.length>0&&Bi(Zi,xt,Kt),Rr.length>0&&Bi(Rr,xt,Kt),En.buffers.depth.setTest(!0),En.buffers.depth.setMask(!0),En.buffers.color.setMask(!0),En.setPolygonOffset(!1)}function Ks(Pe,xt,Kt,tn){if((Kt.isScene===!0?Kt.overrideMaterial:null)!==null)return;let Zi=We.isWebGL2;Yi===null&&(Yi=new Z3(1,1,{generateMipmaps:!0,type:it.has("EXT_color_buffer_half_float")?BW:mT,minFilter:DW,samples:Zi?4:0})),H.getDrawingBufferSize(Tr),Zi?Yi.setSize(Tr.x,Tr.y):Yi.setSize(L6e(Tr.x),L6e(Tr.y));let Rr=H.getRenderTarget();H.setRenderTarget(Yi),H.getClearColor(at),Ne=H.getClearAlpha(),Ne<1&&H.setClearColor(16777215,.5),H.clear();let Xr=H.toneMapping;H.toneMapping=gT,Bi(Pe,Kt,tn),Me.updateMultisampleRenderTarget(Yi),Me.updateRenderTargetMipmap(Yi);let bs=!1;for(let Vs=0,xs=xt.length;Vs0),Cs=!!Kt.morphAttributes.position,Lc=!!Kt.morphAttributes.normal,zf=!!Kt.morphAttributes.color,pl=gT;tn.toneMapped&&(ue===null||ue.isXRRenderTarget===!0)&&(pl=H.toneMapping);let bg=Kt.morphAttributes.position||Kt.morphAttributes.normal||Kt.morphAttributes.color,hc=bg!==void 0?bg.length:0,Js=qi.get(tn),w2=O.state.lights;if(pn===!0&&(qn===!0||Pe!==Q)){let gh=Pe===Q&&tn.id===Te;Ae.setState(tn,Pe,gh)}let dc=!1;tn.version===Js.__version?(Js.needsLights&&Js.lightsStateVersion!==w2.state.version||Js.outputColorSpace!==Xr||Yt.isBatchedMesh&&Js.batching===!1||!Yt.isBatchedMesh&&Js.batching===!0||Yt.isInstancedMesh&&Js.instancing===!1||!Yt.isInstancedMesh&&Js.instancing===!0||Yt.isSkinnedMesh&&Js.skinning===!1||!Yt.isSkinnedMesh&&Js.skinning===!0||Yt.isInstancedMesh&&Js.instancingColor===!0&&Yt.instanceColor===null||Yt.isInstancedMesh&&Js.instancingColor===!1&&Yt.instanceColor!==null||Js.envMap!==bs||tn.fog===!0&&Js.fog!==Zi||Js.numClippingPlanes!==void 0&&(Js.numClippingPlanes!==Ae.numPlanes||Js.numIntersection!==Ae.numIntersection)||Js.vertexAlphas!==Vs||Js.vertexTangents!==xs||Js.morphTargets!==Cs||Js.morphNormals!==Lc||Js.morphColors!==zf||Js.toneMapping!==pl||We.isWebGL2===!0&&Js.morphTargetsCount!==hc)&&(dc=!0):(dc=!0,Js.__version=tn.version);let km=Js.currentProgram;dc===!0&&(km=gf(tn,xt,Yt));let v2=!1,Iv=!1,_2=!1,gl=km.getUniforms(),Rm=Js.uniforms;if(En.useProgram(km.program)&&(v2=!0,Iv=!0,_2=!0),tn.id!==Te&&(Te=tn.id,Iv=!0),v2||Q!==Pe){gl.setValue(se,"projectionMatrix",Pe.projectionMatrix),gl.setValue(se,"viewMatrix",Pe.matrixWorldInverse);let gh=gl.map.cameraPosition;gh!==void 0&&gh.setValue(se,wr.setFromMatrixPosition(Pe.matrixWorld)),We.logarithmicDepthBuffer&&gl.setValue(se,"logDepthBufFC",2/(Math.log(Pe.far+1)/Math.LN2)),(tn.isMeshPhongMaterial||tn.isMeshToonMaterial||tn.isMeshLambertMaterial||tn.isMeshBasicMaterial||tn.isMeshStandardMaterial||tn.isShaderMaterial)&&gl.setValue(se,"isOrthographic",Pe.isOrthographicCamera===!0),Q!==Pe&&(Q=Pe,Iv=!0,_2=!0)}if(Yt.isSkinnedMesh){gl.setOptional(se,Yt,"bindMatrix"),gl.setOptional(se,Yt,"bindMatrixInverse");let gh=Yt.skeleton;gh&&(We.floatVertexTextures?(gh.boneTexture===null&&gh.computeBoneTexture(),gl.setValue(se,"boneTexture",gh.boneTexture,Me)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}Yt.isBatchedMesh&&(gl.setOptional(se,Yt,"batchingTexture"),gl.setValue(se,"batchingTexture",Yt._matricesTexture,Me));let rE=Kt.morphAttributes;if((rE.position!==void 0||rE.normal!==void 0||rE.color!==void 0&&We.isWebGL2===!0)&&Ye.update(Yt,Kt,km),(Iv||Js.receiveShadow!==Yt.receiveShadow)&&(Js.receiveShadow=Yt.receiveShadow,gl.setValue(se,"receiveShadow",Yt.receiveShadow)),tn.isMeshGouraudMaterial&&tn.envMap!==null&&(Rm.envMap.value=bs,Rm.flipEnvMap.value=bs.isCubeTexture&&bs.isRenderTargetTexture===!1?-1:1),Iv&&(gl.setValue(se,"toneMappingExposure",H.toneMappingExposure),Js.needsLights&&zb(Rm,_2),Zi&&tn.fog===!0&&mi.refreshFogUniforms(Rm,Zi),mi.refreshMaterialUniforms(Rm,tn,Tt,ot,Yi),cO.upload(se,Q1(Js),Rm,Me)),tn.isShaderMaterial&&tn.uniformsNeedUpdate===!0&&(cO.upload(se,Q1(Js),Rm,Me),tn.uniformsNeedUpdate=!1),tn.isSpriteMaterial&&gl.setValue(se,"center",Yt.center),gl.setValue(se,"modelViewMatrix",Yt.modelViewMatrix),gl.setValue(se,"normalMatrix",Yt.normalMatrix),gl.setValue(se,"modelMatrix",Yt.matrixWorld),tn.isShaderMaterial||tn.isRawShaderMaterial){let gh=tn.uniformsGroups;for(let y2=0,sE=gh.length;y20&&Me.useMultisampledRTT(Pe)===!1?Yt=qi.get(Pe).__webglMultisampledFramebuffer:Array.isArray(xs)?Yt=xs[Kt]:Yt=xs,ge.copy(Pe.viewport),Qe.copy(Pe.scissor),st=Pe.scissorTest}else ge.copy(mn).multiplyScalar(Tt).floor(),Qe.copy(cn).multiplyScalar(Tt).floor(),st=bi;if(En.bindFramebuffer(se.FRAMEBUFFER,Yt)&&We.drawBuffers&&tn&&En.drawBuffers(Pe,Yt),En.viewport(ge),En.scissor(Qe),En.setScissorTest(st),Zi){let bs=qi.get(Pe.texture);se.framebufferTexture2D(se.FRAMEBUFFER,se.COLOR_ATTACHMENT0,se.TEXTURE_CUBE_MAP_POSITIVE_X+xt,bs.__webglTexture,Kt)}else if(Rr){let bs=qi.get(Pe.texture),Vs=xt||0;se.framebufferTextureLayer(se.FRAMEBUFFER,se.COLOR_ATTACHMENT0,bs.__webglTexture,Kt||0,Vs)}Te=-1},this.readRenderTargetPixels=function(Pe,xt,Kt,tn,Yt,Zi,Rr){if(!(Pe&&Pe.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Xr=qi.get(Pe).__webglFramebuffer;if(Pe.isWebGLCubeRenderTarget&&Rr!==void 0&&(Xr=Xr[Rr]),Xr){En.bindFramebuffer(se.FRAMEBUFFER,Xr);try{let bs=Pe.texture,Vs=bs.format,xs=bs.type;if(Vs!==Cv&&Ke.convert(Vs)!==se.getParameter(se.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Cs=xs===BW&&(it.has("EXT_color_buffer_half_float")||We.isWebGL2&&it.has("EXT_color_buffer_float"));if(xs!==mT&&Ke.convert(xs)!==se.getParameter(se.IMPLEMENTATION_COLOR_READ_TYPE)&&!(xs===hT&&(We.isWebGL2||it.has("OES_texture_float")||it.has("WEBGL_color_buffer_float")))&&!Cs){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}xt>=0&&xt<=Pe.width-tn&&Kt>=0&&Kt<=Pe.height-Yt&&se.readPixels(xt,Kt,tn,Yt,Ke.convert(Vs),Ke.convert(xs),Zi)}finally{let bs=ue!==null?qi.get(ue).__webglFramebuffer:null;En.bindFramebuffer(se.FRAMEBUFFER,bs)}}},this.copyFramebufferToTexture=function(Pe,xt,Kt=0){let tn=Math.pow(2,-Kt),Yt=Math.floor(xt.image.width*tn),Zi=Math.floor(xt.image.height*tn);Me.setTexture2D(xt,0),se.copyTexSubImage2D(se.TEXTURE_2D,Kt,0,0,Pe.x,Pe.y,Yt,Zi),En.unbindTexture()},this.copyTextureToTexture=function(Pe,xt,Kt,tn=0){let Yt=xt.image.width,Zi=xt.image.height,Rr=Ke.convert(Kt.format),Xr=Ke.convert(Kt.type);Me.setTexture2D(Kt,0),se.pixelStorei(se.UNPACK_FLIP_Y_WEBGL,Kt.flipY),se.pixelStorei(se.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Kt.premultiplyAlpha),se.pixelStorei(se.UNPACK_ALIGNMENT,Kt.unpackAlignment),xt.isDataTexture?se.texSubImage2D(se.TEXTURE_2D,tn,Pe.x,Pe.y,Yt,Zi,Rr,Xr,xt.image.data):xt.isCompressedTexture?se.compressedTexSubImage2D(se.TEXTURE_2D,tn,Pe.x,Pe.y,xt.mipmaps[0].width,xt.mipmaps[0].height,Rr,xt.mipmaps[0].data):se.texSubImage2D(se.TEXTURE_2D,tn,Pe.x,Pe.y,Rr,Xr,xt.image),tn===0&&Kt.generateMipmaps&&se.generateMipmap(se.TEXTURE_2D),En.unbindTexture()},this.copyTextureToTexture3D=function(Pe,xt,Kt,tn,Yt=0){if(H.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Zi=Pe.max.x-Pe.min.x+1,Rr=Pe.max.y-Pe.min.y+1,Xr=Pe.max.z-Pe.min.z+1,bs=Ke.convert(tn.format),Vs=Ke.convert(tn.type),xs;if(tn.isData3DTexture)Me.setTexture3D(tn,0),xs=se.TEXTURE_3D;else if(tn.isDataArrayTexture||tn.isCompressedArrayTexture)Me.setTexture2DArray(tn,0),xs=se.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}se.pixelStorei(se.UNPACK_FLIP_Y_WEBGL,tn.flipY),se.pixelStorei(se.UNPACK_PREMULTIPLY_ALPHA_WEBGL,tn.premultiplyAlpha),se.pixelStorei(se.UNPACK_ALIGNMENT,tn.unpackAlignment);let Cs=se.getParameter(se.UNPACK_ROW_LENGTH),Lc=se.getParameter(se.UNPACK_IMAGE_HEIGHT),zf=se.getParameter(se.UNPACK_SKIP_PIXELS),pl=se.getParameter(se.UNPACK_SKIP_ROWS),bg=se.getParameter(se.UNPACK_SKIP_IMAGES),hc=Kt.isCompressedTexture?Kt.mipmaps[Yt]:Kt.image;se.pixelStorei(se.UNPACK_ROW_LENGTH,hc.width),se.pixelStorei(se.UNPACK_IMAGE_HEIGHT,hc.height),se.pixelStorei(se.UNPACK_SKIP_PIXELS,Pe.min.x),se.pixelStorei(se.UNPACK_SKIP_ROWS,Pe.min.y),se.pixelStorei(se.UNPACK_SKIP_IMAGES,Pe.min.z),Kt.isDataTexture||Kt.isData3DTexture?se.texSubImage3D(xs,Yt,xt.x,xt.y,xt.z,Zi,Rr,Xr,bs,Vs,hc.data):Kt.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),se.compressedTexSubImage3D(xs,Yt,xt.x,xt.y,xt.z,Zi,Rr,Xr,bs,hc.data)):se.texSubImage3D(xs,Yt,xt.x,xt.y,xt.z,Zi,Rr,Xr,bs,Vs,hc),se.pixelStorei(se.UNPACK_ROW_LENGTH,Cs),se.pixelStorei(se.UNPACK_IMAGE_HEIGHT,Lc),se.pixelStorei(se.UNPACK_SKIP_PIXELS,zf),se.pixelStorei(se.UNPACK_SKIP_ROWS,pl),se.pixelStorei(se.UNPACK_SKIP_IMAGES,bg),Yt===0&&tn.generateMipmaps&&se.generateMipmap(xs),En.unbindTexture()},this.initTexture=function(Pe){Pe.isCubeTexture?Me.setTextureCube(Pe,0):Pe.isData3DTexture?Me.setTexture3D(Pe,0):Pe.isDataArrayTexture||Pe.isCompressedArrayTexture?Me.setTexture2DArray(Pe,0):Me.setTexture2D(Pe,0),En.unbindTexture()},this.resetState=function(){oe=0,ne=0,ue=null,En.reset(),pt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return X3}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(n){this._outputColorSpace=n;let r=this.getContext();r.drawingBufferColorSpace=n===u5e?"display-p3":"srgb",r.unpackColorSpace=Pc.workingColorSpace===whe?"display-p3":"srgb"}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Td?q4:S2t}set outputEncoding(n){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=n===q4?Td:Y3}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(n){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=n}},H6e=class extends UW{};H6e.prototype.isWebGL1Renderer=!0;var ahe=class extends gg{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(n,r){return super.copy(n,r),n.background!==null&&(this.background=n.background.clone()),n.environment!==null&&(this.environment=n.environment.clone()),n.fog!==null&&(this.fog=n.fog.clone()),this.backgroundBlurriness=n.backgroundBlurriness,this.backgroundIntensity=n.backgroundIntensity,n.overrideMaterial!==null&&(this.overrideMaterial=n.overrideMaterial.clone()),this.matrixAutoUpdate=n.matrixAutoUpdate,this}toJSON(n){let r=super.toJSON(n);return this.fog!==null&&(r.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(r.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(r.object.backgroundIntensity=this.backgroundIntensity),r}};var che=class extends q1{constructor(n,r,c,u=1){super(n,r,c),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=u}copy(n){return super.copy(n),this.meshPerAttribute=n.meshPerAttribute,this}toJSON(){let n=super.toJSON();return n.meshPerAttribute=this.meshPerAttribute,n.isInstancedBufferAttribute=!0,n}},iO=new Il,s2t=new Il,Bfe=[],o2t=new K3,Jfn=new Il,LW=new Mm,kW=new vT,lhe=class extends Mm{constructor(n,r,c){super(n,r),this.isInstancedMesh=!0,this.instanceMatrix=new che(new Float32Array(c*16),16),this.instanceColor=null,this.count=c,this.boundingBox=null,this.boundingSphere=null;for(let u=0;u_)continue;L.applyMatrix4(this.matrixWorld);let Te=n.ray.origin.distanceTo(L);Ten.far||r.push({distance:Te,point:M.clone().applyMatrix4(this.matrixWorld),index:H,face:null,faceIndex:null,object:this})}}else{let z=Math.max(0,b.start),Z=Math.min(O.count,b.start+b.count);for(let H=z,te=Z-1;H_)continue;L.applyMatrix4(this.matrixWorld);let ne=n.ray.origin.distanceTo(L);nen.far||r.push({distance:ne,point:M.clone().applyMatrix4(this.matrixWorld),index:H,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let r=this.geometry.morphAttributes,c=Object.keys(r);if(c.length>0){let u=r[c[0]];if(u!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let d=0,b=u.length;d=d)){let w=r[1];n=d)break t}b=c,c=0;break n}break e}for(;c>>1;nr;)--b;if(++b,d!==0||b!==u){d>=b&&(b=Math.max(b,1),d=b-1);let w=this.getValueSize();this.times=c.slice(d,b),this.values=this.values.slice(d*w,b*w)}return this}validate(){let n=!0,r=this.getValueSize();r-Math.floor(r)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),n=!1);let c=this.times,u=this.values,d=c.length;d===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),n=!1);let b=null;for(let w=0;w!==d;w++){let _=c[w];if(typeof _=="number"&&isNaN(_)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,w,_),n=!1;break}if(b!==null&&b>_){console.error("THREE.KeyframeTrack: Out of order keys.",this,w,_,b),n=!1;break}b=_}if(u!==void 0&&Qfn(u))for(let w=0,_=u.length;w!==_;++w){let x=u[w];if(isNaN(x)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,w,x),n=!1;break}}return n}optimize(){let n=this.times.slice(),r=this.values.slice(),c=this.getValueSize(),u=this.getInterpolation()===YIe,d=n.length-1,b=1;for(let w=1;w0){n[b]=n[d];for(let w=d*c,_=b*c,x=0;x!==c;++x)r[_+x]=r[w+x];++b}return b!==n.length?(this.times=n.slice(0,b),this.values=r.slice(0,b*c)):(this.times=n,this.values=r),this}clone(){let n=this.times.slice(),r=this.values.slice(),c=this.constructor,u=new c(this.name,n,r);return u.createInterpolant=this.createInterpolant,u}};Pv.prototype.TimeBufferType=Float32Array;Pv.prototype.ValueBufferType=Float32Array;Pv.prototype.DefaultInterpolation=Vfe;var Y4=class extends Pv{};Y4.prototype.ValueTypeName="bool";Y4.prototype.ValueBufferType=Array;Y4.prototype.DefaultInterpolation=$fe;Y4.prototype.InterpolantFactoryMethodLinear=void 0;Y4.prototype.InterpolantFactoryMethodSmooth=void 0;var K6e=class extends Pv{};K6e.prototype.ValueTypeName="color";var J6e=class extends Pv{};J6e.prototype.ValueTypeName="number";var Q6e=class extends gO{constructor(n,r,c,u){super(n,r,c,u)}interpolate_(n,r,c,u){let d=this.resultBuffer,b=this.sampleValues,w=this.valueSize,_=(c-r)/(u-r),x=n*w;for(let T=x+w;x!==T;x+=4)h2.slerpFlat(d,0,b,x-w,b,x,_);return d}},GW=class extends Pv{InterpolantFactoryMethodLinear(n){return new Q6e(this.times,this.values,this.getValueSize(),n)}};GW.prototype.ValueTypeName="quaternion";GW.prototype.DefaultInterpolation=Vfe;GW.prototype.InterpolantFactoryMethodSmooth=void 0;var Z4=class extends Pv{};Z4.prototype.ValueTypeName="string";Z4.prototype.ValueBufferType=Array;Z4.prototype.DefaultInterpolation=$fe;Z4.prototype.InterpolantFactoryMethodLinear=void 0;Z4.prototype.InterpolantFactoryMethodSmooth=void 0;var e5e=class extends Pv{};e5e.prototype.ValueTypeName="vector";var t5e=class{constructor(n,r,c){let u=this,d=!1,b=0,w=0,_,x=[];this.onStart=void 0,this.onLoad=n,this.onProgress=r,this.onError=c,this.itemStart=function(T){w++,d===!1&&u.onStart!==void 0&&u.onStart(T,b,w),d=!0},this.itemEnd=function(T){b++,u.onProgress!==void 0&&u.onProgress(T,b,w),b===w&&(d=!1,u.onLoad!==void 0&&u.onLoad())},this.itemError=function(T){u.onError!==void 0&&u.onError(T)},this.resolveURL=function(T){return _?_(T):T},this.setURLModifier=function(T){return _=T,this},this.addHandler=function(T,M){return x.push(T,M),this},this.removeHandler=function(T){let M=x.indexOf(T);return M!==-1&&x.splice(M,2),this},this.getHandler=function(T){for(let M=0,L=x.length;MT||u.y>T)&&(u.x>T&&(d.x=Math.floor(T/en.x),u.x=d.x*en.x,jt.mapSize.x=d.x),u.y>T&&(d.y=Math.floor(T/en.y),u.y=d.y*en.y,jt.mapSize.y=d.y)),jt.map===null||at===!0||Ne===!0){let cn=this.type!==H3?{minFilter:dg,magFilter:dg}:{};jt.map!==null&&jt.map.dispose(),jt.map=new Z3(u.x,u.y,cn),jt.map.texture.name=Tt.name+".shadowMap",jt.camera.updateProjectionMatrix()}s.setRenderTarget(jt.map),s.clear();let mn=jt.getViewportCount();for(let cn=0;cn0||ue.map&&ue.alphaTest>0){let st=ge.uuid,at=ue.uuid,Ne=x[st];Ne===void 0&&(Ne={},x[st]=Ne);let tt=Ne[at];tt===void 0&&(tt=ge.clone(),Ne[at]=tt,ue.addEventListener("dispose",oe)),ge=tt}if(ge.visible=ue.visible,ge.wireframe=ue.wireframe,Q===H3?ge.side=ue.shadowSide!==null?ue.shadowSide:ue.side:ge.side=ue.shadowSide!==null?ue.shadowSide:M[ue.side],ge.alphaMap=ue.alphaMap,ge.alphaTest=ue.alphaTest,ge.map=ue.map,ge.clipShadows=ue.clipShadows,ge.clippingPlanes=ue.clippingPlanes,ge.clipIntersection=ue.clipIntersection,ge.displacementMap=ue.displacementMap,ge.displacementScale=ue.displacementScale,ge.displacementBias=ue.displacementBias,ge.wireframeLinewidth=ue.wireframeLinewidth,ge.linewidth=ue.linewidth,Te.isPointLight===!0&&ge.isMeshDistanceMaterial===!0){let st=s.properties.get(ge);st.light=Te}return ge}function te(ne,ue,Te,Q,ge){if(ne.visible===!1)return;if(ne.layers.test(ue.layers)&&(ne.isMesh||ne.isLine||ne.isPoints)&&(ne.castShadow||ne.receiveShadow&&ge===H3)&&(!ne.frustumCulled||c.intersectsObject(ne))){ne.modelViewMatrix.multiplyMatrices(Te.matrixWorldInverse,ne.matrixWorld);let at=n.update(ne),Ne=ne.material;if(Array.isArray(Ne)){let tt=at.groups;for(let ot=0,Tt=tt.length;ot=1):mn.indexOf("OpenGL ES")!==-1&&(en=parseFloat(/^OpenGL ES (\d)/.exec(mn)[1]),jt=en>=2);let cn=null,bi={},Vt=s.getParameter(s.SCISSOR_BOX),pn=s.getParameter(s.VIEWPORT),qn=new qh().fromArray(Vt),Yi=new qh().fromArray(pn);function $i(Je,Qn,ei,ar){let yn=new Uint8Array(4),Re=s.createTexture();s.bindTexture(Je,Re),s.texParameteri(Je,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(Je,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let nt=0;nt"u"?!1:/OculusBrowser/g.test(navigator.userAgent),T=new WeakMap,M,L=new WeakMap,I=!1;try{I=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function D(Me,ve){return I?new OffscreenCanvas(Me,ve):Yfe("canvas")}function F(Me,ve,wt,gn){let vn=1;if((Me.width>gn||Me.height>gn)&&(vn=gn/Math.max(Me.width,Me.height)),vn<1||ve===!0)if(typeof HTMLImageElement<"u"&&Me instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&Me instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&Me instanceof ImageBitmap){let Mn=ve?L6e:Math.floor,xi=Mn(vn*Me.width),mi=Mn(vn*Me.height);M===void 0&&(M=D(xi,mi));let ri=wt?D(xi,mi):M;return ri.width=xi,ri.height=mi,ri.getContext("2d").drawImage(Me,0,0,xi,mi),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Me.width+"x"+Me.height+") to ("+xi+"x"+mi+")."),ri}else return"data"in Me&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Me.width+"x"+Me.height+")."),Me;return Me}function O(Me){return yyt(Me.width)&&yyt(Me.height)}function z(Me){return w?!1:Me.wrapS!==Tv||Me.wrapT!==Tv||Me.minFilter!==dg&&Me.minFilter!==Bb}function Z(Me,ve){return Me.generateMipmaps&&ve&&Me.minFilter!==dg&&Me.minFilter!==Bb}function H(Me){s.generateMipmap(Me)}function te(Me,ve,wt,gn,vn=!1){if(w===!1)return ve;if(Me!==null){if(s[Me]!==void 0)return s[Me];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+Me+"'")}let Mn=ve;if(ve===s.RED&&(wt===s.FLOAT&&(Mn=s.R32F),wt===s.HALF_FLOAT&&(Mn=s.R16F),wt===s.UNSIGNED_BYTE&&(Mn=s.R8)),ve===s.RED_INTEGER&&(wt===s.UNSIGNED_BYTE&&(Mn=s.R8UI),wt===s.UNSIGNED_SHORT&&(Mn=s.R16UI),wt===s.UNSIGNED_INT&&(Mn=s.R32UI),wt===s.BYTE&&(Mn=s.R8I),wt===s.SHORT&&(Mn=s.R16I),wt===s.INT&&(Mn=s.R32I)),ve===s.RG&&(wt===s.FLOAT&&(Mn=s.RG32F),wt===s.HALF_FLOAT&&(Mn=s.RG16F),wt===s.UNSIGNED_BYTE&&(Mn=s.RG8)),ve===s.RGBA){let xi=vn?Wfe:Pc.getTransfer(gn);wt===s.FLOAT&&(Mn=s.RGBA32F),wt===s.HALF_FLOAT&&(Mn=s.RGBA16F),wt===s.UNSIGNED_BYTE&&(Mn=xi===dl?s.SRGB8_ALPHA8:s.RGBA8),wt===s.UNSIGNED_SHORT_4_4_4_4&&(Mn=s.RGBA4),wt===s.UNSIGNED_SHORT_5_5_5_1&&(Mn=s.RGB5_A1)}return(Mn===s.R16F||Mn===s.R32F||Mn===s.RG16F||Mn===s.RG32F||Mn===s.RGBA16F||Mn===s.RGBA32F)&&n.get("EXT_color_buffer_float"),Mn}function oe(Me,ve,wt){return Z(Me,wt)===!0||Me.isFramebufferTexture&&Me.minFilter!==dg&&Me.minFilter!==Bb?Math.log2(Math.max(ve.width,ve.height))+1:Me.mipmaps!==void 0&&Me.mipmaps.length>0?Me.mipmaps.length:Me.isCompressedTexture&&Array.isArray(Me.image)?ve.mipmaps.length:1}function ne(Me){return Me===dg||Me===$_t||Me===$Ie?s.NEAREST:s.LINEAR}function ue(Me){let ve=Me.target;ve.removeEventListener("dispose",ue),Q(ve),ve.isVideoTexture&&T.delete(ve)}function Te(Me){let ve=Me.target;ve.removeEventListener("dispose",Te),Qe(ve)}function Q(Me){let ve=c.get(Me);if(ve.__webglInit===void 0)return;let wt=Me.source,gn=L.get(wt);if(gn){let vn=gn[ve.__cacheKey];vn.usedTimes--,vn.usedTimes===0&&ge(Me),Object.keys(gn).length===0&&L.delete(wt)}c.remove(Me)}function ge(Me){let ve=c.get(Me);s.deleteTexture(ve.__webglTexture);let wt=Me.source,gn=L.get(wt);delete gn[ve.__cacheKey],b.memory.textures--}function Qe(Me){let ve=Me.texture,wt=c.get(Me),gn=c.get(ve);if(gn.__webglTexture!==void 0&&(s.deleteTexture(gn.__webglTexture),b.memory.textures--),Me.depthTexture&&Me.depthTexture.dispose(),Me.isWebGLCubeRenderTarget)for(let vn=0;vn<6;vn++){if(Array.isArray(wt.__webglFramebuffer[vn]))for(let Mn=0;Mn=u.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+Me+" texture units while this GPU supports only "+u.maxTextures),st+=1,Me}function tt(Me){let ve=[];return ve.push(Me.wrapS),ve.push(Me.wrapT),ve.push(Me.wrapR||0),ve.push(Me.magFilter),ve.push(Me.minFilter),ve.push(Me.anisotropy),ve.push(Me.internalFormat),ve.push(Me.format),ve.push(Me.type),ve.push(Me.generateMipmaps),ve.push(Me.premultiplyAlpha),ve.push(Me.flipY),ve.push(Me.unpackAlignment),ve.push(Me.colorSpace),ve.join()}function ot(Me,ve){let wt=c.get(Me);if(Me.isVideoTexture&&hr(Me),Me.isRenderTargetTexture===!1&&Me.version>0&&wt.__version!==Me.version){let gn=Me.image;if(gn===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(gn.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{qn(wt,Me,ve);return}}r.bindTexture(s.TEXTURE_2D,wt.__webglTexture,s.TEXTURE0+ve)}function Tt(Me,ve){let wt=c.get(Me);if(Me.version>0&&wt.__version!==Me.version){qn(wt,Me,ve);return}r.bindTexture(s.TEXTURE_2D_ARRAY,wt.__webglTexture,s.TEXTURE0+ve)}function jt(Me,ve){let wt=c.get(Me);if(Me.version>0&&wt.__version!==Me.version){qn(wt,Me,ve);return}r.bindTexture(s.TEXTURE_3D,wt.__webglTexture,s.TEXTURE0+ve)}function en(Me,ve){let wt=c.get(Me);if(Me.version>0&&wt.__version!==Me.version){Yi(wt,Me,ve);return}r.bindTexture(s.TEXTURE_CUBE_MAP,wt.__webglTexture,s.TEXTURE0+ve)}let mn={[T6e]:s.REPEAT,[Tv]:s.CLAMP_TO_EDGE,[C6e]:s.MIRRORED_REPEAT},cn={[dg]:s.NEAREST,[$_t]:s.NEAREST_MIPMAP_NEAREST,[$Ie]:s.NEAREST_MIPMAP_LINEAR,[Bb]:s.LINEAR,[$on]:s.LINEAR_MIPMAP_NEAREST,[DW]:s.LINEAR_MIPMAP_LINEAR},bi={[tan]:s.NEVER,[aan]:s.ALWAYS,[nan]:s.LESS,[T2t]:s.LEQUAL,[ian]:s.EQUAL,[oan]:s.GEQUAL,[ran]:s.GREATER,[san]:s.NOTEQUAL};function Vt(Me,ve,wt){if(wt?(s.texParameteri(Me,s.TEXTURE_WRAP_S,mn[ve.wrapS]),s.texParameteri(Me,s.TEXTURE_WRAP_T,mn[ve.wrapT]),(Me===s.TEXTURE_3D||Me===s.TEXTURE_2D_ARRAY)&&s.texParameteri(Me,s.TEXTURE_WRAP_R,mn[ve.wrapR]),s.texParameteri(Me,s.TEXTURE_MAG_FILTER,cn[ve.magFilter]),s.texParameteri(Me,s.TEXTURE_MIN_FILTER,cn[ve.minFilter])):(s.texParameteri(Me,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(Me,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),(Me===s.TEXTURE_3D||Me===s.TEXTURE_2D_ARRAY)&&s.texParameteri(Me,s.TEXTURE_WRAP_R,s.CLAMP_TO_EDGE),(ve.wrapS!==Tv||ve.wrapT!==Tv)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),s.texParameteri(Me,s.TEXTURE_MAG_FILTER,ne(ve.magFilter)),s.texParameteri(Me,s.TEXTURE_MIN_FILTER,ne(ve.minFilter)),ve.minFilter!==dg&&ve.minFilter!==Bb&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),ve.compareFunction&&(s.texParameteri(Me,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(Me,s.TEXTURE_COMPARE_FUNC,bi[ve.compareFunction])),n.has("EXT_texture_filter_anisotropic")===!0){let gn=n.get("EXT_texture_filter_anisotropic");if(ve.magFilter===dg||ve.minFilter!==$Ie&&ve.minFilter!==DW||ve.type===hT&&n.has("OES_texture_float_linear")===!1||w===!1&&ve.type===BW&&n.has("OES_texture_half_float_linear")===!1)return;(ve.anisotropy>1||c.get(ve).__currentAnisotropy)&&(s.texParameterf(Me,gn.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(ve.anisotropy,u.getMaxAnisotropy())),c.get(ve).__currentAnisotropy=ve.anisotropy)}}function pn(Me,ve){let wt=!1;Me.__webglInit===void 0&&(Me.__webglInit=!0,ve.addEventListener("dispose",ue));let gn=ve.source,vn=L.get(gn);vn===void 0&&(vn={},L.set(gn,vn));let Mn=tt(ve);if(Mn!==Me.__cacheKey){vn[Mn]===void 0&&(vn[Mn]={texture:s.createTexture(),usedTimes:0},b.memory.textures++,wt=!0),vn[Mn].usedTimes++;let xi=vn[Me.__cacheKey];xi!==void 0&&(vn[Me.__cacheKey].usedTimes--,xi.usedTimes===0&&ge(ve)),Me.__cacheKey=Mn,Me.__webglTexture=vn[Mn].texture}return wt}function qn(Me,ve,wt){let gn=s.TEXTURE_2D;(ve.isDataArrayTexture||ve.isCompressedArrayTexture)&&(gn=s.TEXTURE_2D_ARRAY),ve.isData3DTexture&&(gn=s.TEXTURE_3D);let vn=pn(Me,ve),Mn=ve.source;r.bindTexture(gn,Me.__webglTexture,s.TEXTURE0+wt);let xi=c.get(Mn);if(Mn.version!==xi.__version||vn===!0){r.activeTexture(s.TEXTURE0+wt);let mi=Pc.getPrimaries(Pc.workingColorSpace),ri=ve.colorSpace===Ob?null:Pc.getPrimaries(ve.colorSpace),Ge=ve.colorSpace===Ob||mi===ri?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,ve.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ve.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,ve.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ge);let Ae=z(ve)&&O(ve.image)===!1,Le=F(ve.image,Ae,!1,u.maxTextureSize);Le=qi(ve,Le);let ht=O(Le)||w,Ye=d.convert(ve.format,ve.colorSpace),ct=d.convert(ve.type),Ze=te(ve.internalFormat,Ye,ct,ve.colorSpace,ve.isVideoTexture);Vt(gn,ve,ht);let Ke,pt=ve.mipmaps,Xn=w&&ve.isVideoTexture!==!0&&Ze!==E2t,_i=xi.__version===void 0||vn===!0,Hi=oe(ve,Le,ht);if(ve.isDepthTexture)Ze=s.DEPTH_COMPONENT,w?ve.type===hT?Ze=s.DEPTH_COMPONENT32F:ve.type===fT?Ze=s.DEPTH_COMPONENT24:ve.type===W4?Ze=s.DEPTH24_STENCIL8:Ze=s.DEPTH_COMPONENT16:ve.type===hT&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),ve.format===H4&&Ze===s.DEPTH_COMPONENT&&ve.type!==l5e&&ve.type!==fT&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),ve.type=fT,ct=d.convert(ve.type)),ve.format===fO&&Ze===s.DEPTH_COMPONENT&&(Ze=s.DEPTH_STENCIL,ve.type!==W4&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),ve.type=W4,ct=d.convert(ve.type))),_i&&(Xn?r.texStorage2D(s.TEXTURE_2D,1,Ze,Le.width,Le.height):r.texImage2D(s.TEXTURE_2D,0,Ze,Le.width,Le.height,0,Ye,ct,null));else if(ve.isDataTexture)if(pt.length>0&&ht){Xn&&_i&&r.texStorage2D(s.TEXTURE_2D,Hi,Ze,pt[0].width,pt[0].height);for(let _n=0,Je=pt.length;_n>=1,Je>>=1}}else if(pt.length>0&&ht){Xn&&_i&&r.texStorage2D(s.TEXTURE_2D,Hi,Ze,pt[0].width,pt[0].height);for(let _n=0,Je=pt.length;_n0&&_i++,r.texStorage2D(s.TEXTURE_CUBE_MAP,_i,Ke,Le[0].width,Le[0].height));for(let _n=0;_n<6;_n++)if(Ae){pt?r.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+_n,0,0,0,Le[_n].width,Le[_n].height,ct,Ze,Le[_n].data):r.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+_n,0,Ke,Le[_n].width,Le[_n].height,0,ct,Ze,Le[_n].data);for(let Je=0;Je>Mn),Le=Math.max(1,ve.height>>Mn);vn===s.TEXTURE_3D||vn===s.TEXTURE_2D_ARRAY?r.texImage3D(vn,Mn,ri,Ae,Le,ve.depth,0,xi,mi,null):r.texImage2D(vn,Mn,ri,Ae,Le,0,xi,mi,null)}r.bindFramebuffer(s.FRAMEBUFFER,Me),En(ve)?_.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,gn,vn,c.get(wt).__webglTexture,0,We(ve)):(vn===s.TEXTURE_2D||vn>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&vn<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,gn,vn,c.get(wt).__webglTexture,Mn),r.bindFramebuffer(s.FRAMEBUFFER,null)}function Tr(Me,ve,wt){if(s.bindRenderbuffer(s.RENDERBUFFER,Me),ve.depthBuffer&&!ve.stencilBuffer){let gn=w===!0?s.DEPTH_COMPONENT24:s.DEPTH_COMPONENT16;if(wt||En(ve)){let vn=ve.depthTexture;vn&&vn.isDepthTexture&&(vn.type===hT?gn=s.DEPTH_COMPONENT32F:vn.type===fT&&(gn=s.DEPTH_COMPONENT24));let Mn=We(ve);En(ve)?_.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Mn,gn,ve.width,ve.height):s.renderbufferStorageMultisample(s.RENDERBUFFER,Mn,gn,ve.width,ve.height)}else s.renderbufferStorage(s.RENDERBUFFER,gn,ve.width,ve.height);s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,Me)}else if(ve.depthBuffer&&ve.stencilBuffer){let gn=We(ve);wt&&En(ve)===!1?s.renderbufferStorageMultisample(s.RENDERBUFFER,gn,s.DEPTH24_STENCIL8,ve.width,ve.height):En(ve)?_.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,gn,s.DEPTH24_STENCIL8,ve.width,ve.height):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,ve.width,ve.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,Me)}else{let gn=ve.isWebGLMultipleRenderTargets===!0?ve.texture:[ve.texture];for(let vn=0;vn0){wt.__webglFramebuffer[mi]=[];for(let ri=0;ri0){wt.__webglFramebuffer=[];for(let mi=0;mi0&&En(Me)===!1){let mi=Mn?ve:[ve];wt.__webglMultisampledFramebuffer=s.createFramebuffer(),wt.__webglColorRenderbuffer=[],r.bindFramebuffer(s.FRAMEBUFFER,wt.__webglMultisampledFramebuffer);for(let ri=0;ri0)for(let ri=0;ri0)for(let ri=0;ri0&&En(Me)===!1){let ve=Me.isWebGLMultipleRenderTargets?Me.texture:[Me.texture],wt=Me.width,gn=Me.height,vn=s.COLOR_BUFFER_BIT,Mn=[],xi=Me.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,mi=c.get(Me),ri=Me.isWebGLMultipleRenderTargets===!0;if(ri)for(let Ge=0;Ge0&&n.has("WEBGL_multisampled_render_to_texture")===!0&&ve.__useRenderToTexture!==!1}function hr(Me){let ve=b.render.frame;T.get(Me)!==ve&&(T.set(Me,ve),Me.update())}function qi(Me,ve){let wt=Me.colorSpace,gn=Me.format,vn=Me.type;return Me.isCompressedTexture===!0||Me.isVideoTexture===!0||Me.format===A6e||wt!==Y3&&wt!==Ob&&(Pc.getTransfer(wt)===dl?w===!1?n.has("EXT_sRGB")===!0&&gn===Cv?(Me.format=A6e,Me.minFilter=Bb,Me.generateMipmaps=!1):ve=Zfe.sRGBToLinear(ve):(gn!==Cv||vn!==mT)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",wt)),ve}this.allocateTextureUnit=Ne,this.resetTextureUnits=at,this.setTexture2D=ot,this.setTexture2DArray=Tt,this.setTexture3D=jt,this.setTextureCube=en,this.rebindTextures=Fr,this.setupRenderTarget=se,this.updateRenderTargetMipmap=de,this.updateMultisampleRenderTarget=it,this.setupDepthRenderbuffer=Si,this.setupFrameBufferTexture=$i,this.useMultisampledRTT=En}function Kfn(s,n,r){let c=r.isWebGL2;function u(d,b=Ob){let w,_=Pc.getTransfer(b);if(d===mT)return s.UNSIGNED_BYTE;if(d===w2t)return s.UNSIGNED_SHORT_4_4_4_4;if(d===v2t)return s.UNSIGNED_SHORT_5_5_5_1;if(d===Von)return s.BYTE;if(d===Won)return s.SHORT;if(d===l5e)return s.UNSIGNED_SHORT;if(d===b2t)return s.INT;if(d===fT)return s.UNSIGNED_INT;if(d===hT)return s.FLOAT;if(d===BW)return c?s.HALF_FLOAT:(w=n.get("OES_texture_half_float"),w!==null?w.HALF_FLOAT_OES:null);if(d===Hon)return s.ALPHA;if(d===Cv)return s.RGBA;if(d===qon)return s.LUMINANCE;if(d===Xon)return s.LUMINANCE_ALPHA;if(d===H4)return s.DEPTH_COMPONENT;if(d===fO)return s.DEPTH_STENCIL;if(d===A6e)return w=n.get("EXT_sRGB"),w!==null?w.SRGB_ALPHA_EXT:null;if(d===Yon)return s.RED;if(d===_2t)return s.RED_INTEGER;if(d===Zon)return s.RG;if(d===y2t)return s.RG_INTEGER;if(d===x2t)return s.RGBA_INTEGER;if(d===VIe||d===WIe||d===HIe||d===qIe)if(_===dl)if(w=n.get("WEBGL_compressed_texture_s3tc_srgb"),w!==null){if(d===VIe)return w.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(d===WIe)return w.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(d===HIe)return w.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(d===qIe)return w.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(w=n.get("WEBGL_compressed_texture_s3tc"),w!==null){if(d===VIe)return w.COMPRESSED_RGB_S3TC_DXT1_EXT;if(d===WIe)return w.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(d===HIe)return w.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(d===qIe)return w.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(d===V_t||d===W_t||d===H_t||d===q_t)if(w=n.get("WEBGL_compressed_texture_pvrtc"),w!==null){if(d===V_t)return w.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(d===W_t)return w.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(d===H_t)return w.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(d===q_t)return w.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(d===E2t)return w=n.get("WEBGL_compressed_texture_etc1"),w!==null?w.COMPRESSED_RGB_ETC1_WEBGL:null;if(d===X_t||d===Y_t)if(w=n.get("WEBGL_compressed_texture_etc"),w!==null){if(d===X_t)return _===dl?w.COMPRESSED_SRGB8_ETC2:w.COMPRESSED_RGB8_ETC2;if(d===Y_t)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:w.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(d===Z_t||d===K_t||d===J_t||d===Q_t||d===eyt||d===tyt||d===nyt||d===iyt||d===ryt||d===syt||d===oyt||d===ayt||d===cyt||d===lyt)if(w=n.get("WEBGL_compressed_texture_astc"),w!==null){if(d===Z_t)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:w.COMPRESSED_RGBA_ASTC_4x4_KHR;if(d===K_t)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:w.COMPRESSED_RGBA_ASTC_5x4_KHR;if(d===J_t)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:w.COMPRESSED_RGBA_ASTC_5x5_KHR;if(d===Q_t)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:w.COMPRESSED_RGBA_ASTC_6x5_KHR;if(d===eyt)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:w.COMPRESSED_RGBA_ASTC_6x6_KHR;if(d===tyt)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:w.COMPRESSED_RGBA_ASTC_8x5_KHR;if(d===nyt)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:w.COMPRESSED_RGBA_ASTC_8x6_KHR;if(d===iyt)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:w.COMPRESSED_RGBA_ASTC_8x8_KHR;if(d===ryt)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:w.COMPRESSED_RGBA_ASTC_10x5_KHR;if(d===syt)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:w.COMPRESSED_RGBA_ASTC_10x6_KHR;if(d===oyt)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:w.COMPRESSED_RGBA_ASTC_10x8_KHR;if(d===ayt)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:w.COMPRESSED_RGBA_ASTC_10x10_KHR;if(d===cyt)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:w.COMPRESSED_RGBA_ASTC_12x10_KHR;if(d===lyt)return _===dl?w.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:w.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(d===XIe||d===uyt||d===fyt)if(w=n.get("EXT_texture_compression_bptc"),w!==null){if(d===XIe)return _===dl?w.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:w.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(d===uyt)return w.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(d===fyt)return w.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(d===Kon||d===hyt||d===dyt||d===pyt)if(w=n.get("EXT_texture_compression_rgtc"),w!==null){if(d===XIe)return w.COMPRESSED_RED_RGTC1_EXT;if(d===hyt)return w.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(d===dyt)return w.COMPRESSED_RED_GREEN_RGTC2_EXT;if(d===pyt)return w.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return d===W4?c?s.UNSIGNED_INT_24_8:(w=n.get("WEBGL_depth_texture"),w!==null?w.UNSIGNED_INT_24_8_WEBGL:null):s[d]!==void 0?s[d]:null}return{convert:u}}var V6e=class extends pg{constructor(n=[]){super(),this.isArrayCamera=!0,this.cameras=n}},dT=class extends gg{constructor(){super(),this.isGroup=!0,this.type="Group"}},Jfn={type:"move"},IW=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new dT,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new dT,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Gt,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Gt),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new dT,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Gt,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Gt),this._grip}dispatchEvent(n){return this._targetRay!==null&&this._targetRay.dispatchEvent(n),this._grip!==null&&this._grip.dispatchEvent(n),this._hand!==null&&this._hand.dispatchEvent(n),this}connect(n){if(n&&n.hand){let r=this._hand;if(r)for(let c of n.hand.values())this._getHandJoint(r,c)}return this.dispatchEvent({type:"connected",data:n}),this}disconnect(n){return this.dispatchEvent({type:"disconnected",data:n}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(n,r,c){let u=null,d=null,b=null,w=this._targetRay,_=this._grip,x=this._hand;if(n&&r.session.visibilityState!=="visible-blurred"){if(x&&n.hand){b=!0;for(let F of n.hand.values()){let O=r.getJointPose(F,c),z=this._getHandJoint(x,F);O!==null&&(z.matrix.fromArray(O.transform.matrix),z.matrix.decompose(z.position,z.rotation,z.scale),z.matrixWorldNeedsUpdate=!0,z.jointRadius=O.radius),z.visible=O!==null}let T=x.joints["index-finger-tip"],M=x.joints["thumb-tip"],L=T.position.distanceTo(M.position),I=.02,D=.005;x.inputState.pinching&&L>I+D?(x.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:n.handedness,target:this})):!x.inputState.pinching&&L<=I-D&&(x.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:n.handedness,target:this}))}else _!==null&&n.gripSpace&&(d=r.getPose(n.gripSpace,c),d!==null&&(_.matrix.fromArray(d.transform.matrix),_.matrix.decompose(_.position,_.rotation,_.scale),_.matrixWorldNeedsUpdate=!0,d.linearVelocity?(_.hasLinearVelocity=!0,_.linearVelocity.copy(d.linearVelocity)):_.hasLinearVelocity=!1,d.angularVelocity?(_.hasAngularVelocity=!0,_.angularVelocity.copy(d.angularVelocity)):_.hasAngularVelocity=!1));w!==null&&(u=r.getPose(n.targetRaySpace,c),u===null&&d!==null&&(u=d),u!==null&&(w.matrix.fromArray(u.transform.matrix),w.matrix.decompose(w.position,w.rotation,w.scale),w.matrixWorldNeedsUpdate=!0,u.linearVelocity?(w.hasLinearVelocity=!0,w.linearVelocity.copy(u.linearVelocity)):w.hasLinearVelocity=!1,u.angularVelocity?(w.hasAngularVelocity=!0,w.angularVelocity.copy(u.angularVelocity)):w.hasAngularVelocity=!1,this.dispatchEvent(Jfn)))}return w!==null&&(w.visible=u!==null),_!==null&&(_.visible=d!==null),x!==null&&(x.visible=b!==null),this}_getHandJoint(n,r){if(n.joints[r.jointName]===void 0){let c=new dT;c.matrixAutoUpdate=!1,c.visible=!1,n.joints[r.jointName]=c,n.add(c)}return n.joints[r.jointName]}},W6e=class extends wT{constructor(n,r){super();let c=this,u=null,d=1,b=null,w="local-floor",_=1,x=null,T=null,M=null,L=null,I=null,D=null,F=r.getContextAttributes(),O=null,z=null,Z=[],H=[],te=new ka,oe=null,ne=new pg;ne.layers.enable(1),ne.viewport=new qh;let ue=new pg;ue.layers.enable(2),ue.viewport=new qh;let Te=[ne,ue],Q=new V6e;Q.layers.enable(1),Q.layers.enable(2);let ge=null,Qe=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Vt){let pn=Z[Vt];return pn===void 0&&(pn=new IW,Z[Vt]=pn),pn.getTargetRaySpace()},this.getControllerGrip=function(Vt){let pn=Z[Vt];return pn===void 0&&(pn=new IW,Z[Vt]=pn),pn.getGripSpace()},this.getHand=function(Vt){let pn=Z[Vt];return pn===void 0&&(pn=new IW,Z[Vt]=pn),pn.getHandSpace()};function st(Vt){let pn=H.indexOf(Vt.inputSource);if(pn===-1)return;let qn=Z[pn];qn!==void 0&&(qn.update(Vt.inputSource,Vt.frame,x||b),qn.dispatchEvent({type:Vt.type,data:Vt.inputSource}))}function at(){u.removeEventListener("select",st),u.removeEventListener("selectstart",st),u.removeEventListener("selectend",st),u.removeEventListener("squeeze",st),u.removeEventListener("squeezestart",st),u.removeEventListener("squeezeend",st),u.removeEventListener("end",at),u.removeEventListener("inputsourceschange",Ne);for(let Vt=0;Vt=0&&(H[Yi]=null,Z[Yi].disconnect(qn))}for(let pn=0;pn=H.length){H.push(qn),Yi=Tr;break}else if(H[Tr]===null){H[Tr]=qn,Yi=Tr;break}if(Yi===-1)break}let $i=Z[Yi];$i&&$i.connect(qn)}}let tt=new Gt,ot=new Gt;function Tt(Vt,pn,qn){tt.setFromMatrixPosition(pn.matrixWorld),ot.setFromMatrixPosition(qn.matrixWorld);let Yi=tt.distanceTo(ot),$i=pn.projectionMatrix.elements,Tr=qn.projectionMatrix.elements,wr=$i[14]/($i[10]-1),Si=$i[14]/($i[10]+1),Fr=($i[9]+1)/$i[5],se=($i[9]-1)/$i[5],de=($i[8]-1)/$i[0],it=(Tr[8]+1)/Tr[0],We=wr*de,En=wr*it,hr=Yi/(-de+it),qi=hr*-de;pn.matrixWorld.decompose(Vt.position,Vt.quaternion,Vt.scale),Vt.translateX(qi),Vt.translateZ(hr),Vt.matrixWorld.compose(Vt.position,Vt.quaternion,Vt.scale),Vt.matrixWorldInverse.copy(Vt.matrixWorld).invert();let Me=wr+hr,ve=Si+hr,wt=We-qi,gn=En+(Yi-qi),vn=Fr*Si/ve*Me,Mn=se*Si/ve*Me;Vt.projectionMatrix.makePerspective(wt,gn,vn,Mn,Me,ve),Vt.projectionMatrixInverse.copy(Vt.projectionMatrix).invert()}function jt(Vt,pn){pn===null?Vt.matrixWorld.copy(Vt.matrix):Vt.matrixWorld.multiplyMatrices(pn.matrixWorld,Vt.matrix),Vt.matrixWorldInverse.copy(Vt.matrixWorld).invert()}this.updateCamera=function(Vt){if(u===null)return;Q.near=ue.near=ne.near=Vt.near,Q.far=ue.far=ne.far=Vt.far,(ge!==Q.near||Qe!==Q.far)&&(u.updateRenderState({depthNear:Q.near,depthFar:Q.far}),ge=Q.near,Qe=Q.far);let pn=Vt.parent,qn=Q.cameras;jt(Q,pn);for(let Yi=0;Yi0&&(O.alphaTest.value=z.alphaTest);let Z=n.get(z).envMap;if(Z&&(O.envMap.value=Z,O.flipEnvMap.value=Z.isCubeTexture&&Z.isRenderTargetTexture===!1?-1:1,O.reflectivity.value=z.reflectivity,O.ior.value=z.ior,O.refractionRatio.value=z.refractionRatio),z.lightMap){O.lightMap.value=z.lightMap;let H=s._useLegacyLights===!0?Math.PI:1;O.lightMapIntensity.value=z.lightMapIntensity*H,r(z.lightMap,O.lightMapTransform)}z.aoMap&&(O.aoMap.value=z.aoMap,O.aoMapIntensity.value=z.aoMapIntensity,r(z.aoMap,O.aoMapTransform))}function b(O,z){O.diffuse.value.copy(z.color),O.opacity.value=z.opacity,z.map&&(O.map.value=z.map,r(z.map,O.mapTransform))}function w(O,z){O.dashSize.value=z.dashSize,O.totalSize.value=z.dashSize+z.gapSize,O.scale.value=z.scale}function _(O,z,Z,H){O.diffuse.value.copy(z.color),O.opacity.value=z.opacity,O.size.value=z.size*Z,O.scale.value=H*.5,z.map&&(O.map.value=z.map,r(z.map,O.uvTransform)),z.alphaMap&&(O.alphaMap.value=z.alphaMap,r(z.alphaMap,O.alphaMapTransform)),z.alphaTest>0&&(O.alphaTest.value=z.alphaTest)}function x(O,z){O.diffuse.value.copy(z.color),O.opacity.value=z.opacity,O.rotation.value=z.rotation,z.map&&(O.map.value=z.map,r(z.map,O.mapTransform)),z.alphaMap&&(O.alphaMap.value=z.alphaMap,r(z.alphaMap,O.alphaMapTransform)),z.alphaTest>0&&(O.alphaTest.value=z.alphaTest)}function T(O,z){O.specular.value.copy(z.specular),O.shininess.value=Math.max(z.shininess,1e-4)}function M(O,z){z.gradientMap&&(O.gradientMap.value=z.gradientMap)}function L(O,z){O.metalness.value=z.metalness,z.metalnessMap&&(O.metalnessMap.value=z.metalnessMap,r(z.metalnessMap,O.metalnessMapTransform)),O.roughness.value=z.roughness,z.roughnessMap&&(O.roughnessMap.value=z.roughnessMap,r(z.roughnessMap,O.roughnessMapTransform)),n.get(z).envMap&&(O.envMapIntensity.value=z.envMapIntensity)}function I(O,z,Z){O.ior.value=z.ior,z.sheen>0&&(O.sheenColor.value.copy(z.sheenColor).multiplyScalar(z.sheen),O.sheenRoughness.value=z.sheenRoughness,z.sheenColorMap&&(O.sheenColorMap.value=z.sheenColorMap,r(z.sheenColorMap,O.sheenColorMapTransform)),z.sheenRoughnessMap&&(O.sheenRoughnessMap.value=z.sheenRoughnessMap,r(z.sheenRoughnessMap,O.sheenRoughnessMapTransform))),z.clearcoat>0&&(O.clearcoat.value=z.clearcoat,O.clearcoatRoughness.value=z.clearcoatRoughness,z.clearcoatMap&&(O.clearcoatMap.value=z.clearcoatMap,r(z.clearcoatMap,O.clearcoatMapTransform)),z.clearcoatRoughnessMap&&(O.clearcoatRoughnessMap.value=z.clearcoatRoughnessMap,r(z.clearcoatRoughnessMap,O.clearcoatRoughnessMapTransform)),z.clearcoatNormalMap&&(O.clearcoatNormalMap.value=z.clearcoatNormalMap,r(z.clearcoatNormalMap,O.clearcoatNormalMapTransform),O.clearcoatNormalScale.value.copy(z.clearcoatNormalScale),z.side===Tm&&O.clearcoatNormalScale.value.negate())),z.iridescence>0&&(O.iridescence.value=z.iridescence,O.iridescenceIOR.value=z.iridescenceIOR,O.iridescenceThicknessMinimum.value=z.iridescenceThicknessRange[0],O.iridescenceThicknessMaximum.value=z.iridescenceThicknessRange[1],z.iridescenceMap&&(O.iridescenceMap.value=z.iridescenceMap,r(z.iridescenceMap,O.iridescenceMapTransform)),z.iridescenceThicknessMap&&(O.iridescenceThicknessMap.value=z.iridescenceThicknessMap,r(z.iridescenceThicknessMap,O.iridescenceThicknessMapTransform))),z.transmission>0&&(O.transmission.value=z.transmission,O.transmissionSamplerMap.value=Z.texture,O.transmissionSamplerSize.value.set(Z.width,Z.height),z.transmissionMap&&(O.transmissionMap.value=z.transmissionMap,r(z.transmissionMap,O.transmissionMapTransform)),O.thickness.value=z.thickness,z.thicknessMap&&(O.thicknessMap.value=z.thicknessMap,r(z.thicknessMap,O.thicknessMapTransform)),O.attenuationDistance.value=z.attenuationDistance,O.attenuationColor.value.copy(z.attenuationColor)),z.anisotropy>0&&(O.anisotropyVector.value.set(z.anisotropy*Math.cos(z.anisotropyRotation),z.anisotropy*Math.sin(z.anisotropyRotation)),z.anisotropyMap&&(O.anisotropyMap.value=z.anisotropyMap,r(z.anisotropyMap,O.anisotropyMapTransform))),O.specularIntensity.value=z.specularIntensity,O.specularColor.value.copy(z.specularColor),z.specularColorMap&&(O.specularColorMap.value=z.specularColorMap,r(z.specularColorMap,O.specularColorMapTransform)),z.specularIntensityMap&&(O.specularIntensityMap.value=z.specularIntensityMap,r(z.specularIntensityMap,O.specularIntensityMapTransform))}function D(O,z){z.matcap&&(O.matcap.value=z.matcap)}function F(O,z){let Z=n.get(z).light;O.referencePosition.value.setFromMatrixPosition(Z.matrixWorld),O.nearDistance.value=Z.shadow.camera.near,O.farDistance.value=Z.shadow.camera.far}return{refreshFogUniforms:c,refreshMaterialUniforms:u}}function ehn(s,n,r,c){let u={},d={},b=[],w=r.isWebGL2?s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS):0;function _(Z,H){let te=H.program;c.uniformBlockBinding(Z,te)}function x(Z,H){let te=u[Z.id];te===void 0&&(D(Z),te=T(Z),u[Z.id]=te,Z.addEventListener("dispose",O));let oe=H.program;c.updateUBOMapping(Z,oe);let ne=n.render.frame;d[Z.id]!==ne&&(L(Z),d[Z.id]=ne)}function T(Z){let H=M();Z.__bindingPointIndex=H;let te=s.createBuffer(),oe=Z.__size,ne=Z.usage;return s.bindBuffer(s.UNIFORM_BUFFER,te),s.bufferData(s.UNIFORM_BUFFER,oe,ne),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,H,te),te}function M(){for(let Z=0;Z0&&(te+=oe-ne),Z.__size=te,Z.__cache={},this}function F(Z){let H={boundary:0,storage:0};return typeof Z=="number"||typeof Z=="boolean"?(H.boundary=4,H.storage=4):Z.isVector2?(H.boundary=8,H.storage=8):Z.isVector3||Z.isColor?(H.boundary=16,H.storage=12):Z.isVector4?(H.boundary=16,H.storage=16):Z.isMatrix3?(H.boundary=48,H.storage=48):Z.isMatrix4?(H.boundary=64,H.storage=64):Z.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",Z),H}function O(Z){let H=Z.target;H.removeEventListener("dispose",O);let te=b.indexOf(H.__bindingPointIndex);b.splice(te,1),s.deleteBuffer(u[H.id]),delete u[H.id],delete d[H.id]}function z(){for(let Z in u)s.deleteBuffer(u[Z]);b=[],u={},d={}}return{bind:_,update:x,dispose:z}}var UW=class{constructor(n={}){let{canvas:r=lan(),context:c=null,depth:u=!0,stencil:d=!0,alpha:b=!1,antialias:w=!1,premultipliedAlpha:_=!0,preserveDrawingBuffer:x=!1,powerPreference:T="default",failIfMajorPerformanceCaveat:M=!1}=n;this.isWebGLRenderer=!0;let L;c!==null?L=c.getContextAttributes().alpha:L=b;let I=new Uint32Array(4),D=new Int32Array(4),F=null,O=null,z=[],Z=[];this.domElement=r,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Td,this._useLegacyLights=!1,this.toneMapping=gT,this.toneMappingExposure=1;let H=this,te=!1,oe=0,ne=0,ue=null,Te=-1,Q=null,ge=new qh,Qe=new qh,st=null,at=new Go(0),Ne=0,tt=r.width,ot=r.height,Tt=1,jt=null,en=null,mn=new qh(0,0,tt,ot),cn=new qh(0,0,tt,ot),bi=!1,Vt=new FW,pn=!1,qn=!1,Yi=null,$i=new Il,Tr=new ka,wr=new Gt,Si={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Fr(){return ue===null?Tt:1}let se=c;function de(Pe,xt){for(let Kt=0;Kt{function Zi(){if(tn.forEach(function(Rr){qi.get(Rr).currentProgram.isReady()&&tn.delete(Rr)}),tn.size===0){Yt(Pe);return}setTimeout(Zi,10)}it.get("KHR_parallel_shader_compile")!==null?Zi():setTimeout(Zi,10)})};let nt=null;function kt(Pe){nt&&nt(Pe)}function xn(){Xi.stop()}function Ei(){Xi.start()}let Xi=new L2t;Xi.setAnimationLoop(kt),typeof self<"u"&&Xi.setContext(self),this.setAnimationLoop=function(Pe){nt=Pe,Hi.setAnimationLoop(Pe),Pe===null?Xi.stop():Xi.start()},Hi.addEventListener("sessionstart",xn),Hi.addEventListener("sessionend",Ei),this.render=function(Pe,xt){if(xt!==void 0&&xt.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(te===!0)return;Pe.matrixWorldAutoUpdate===!0&&Pe.updateMatrixWorld(),xt.parent===null&&xt.matrixWorldAutoUpdate===!0&&xt.updateMatrixWorld(),Hi.enabled===!0&&Hi.isPresenting===!0&&(Hi.cameraAutoUpdate===!0&&Hi.updateCamera(xt),xt=Hi.getCamera()),Pe.isScene===!0&&Pe.onBeforeRender(H,Pe,xt,ue),O=Ge.get(Pe,Z.length),O.init(),Z.push(O),$i.multiplyMatrices(xt.projectionMatrix,xt.matrixWorldInverse),Vt.setFromProjectionMatrix($i),qn=this.localClippingEnabled,pn=Ae.init(this.clippingPlanes,qn),F=ri.get(Pe,z.length),F.init(),z.push(F),cr(Pe,xt,0,H.sortObjects),F.finish(),H.sortObjects===!0&&F.sort(jt,en),this.info.render.frame++,pn===!0&&Ae.beginShadows();let Kt=O.state.shadowsArray;if(Le.render(Kt,Pe,xt),pn===!0&&Ae.endShadows(),this.info.autoReset===!0&&this.info.reset(),ht.render(F,Pe),O.setupLights(H._useLegacyLights),xt.isArrayCamera){let tn=xt.cameras;for(let Yt=0,Zi=tn.length;Yt0?O=Z[Z.length-1]:O=null,z.pop(),z.length>0?F=z[z.length-1]:F=null};function cr(Pe,xt,Kt,tn){if(Pe.visible===!1)return;if(Pe.layers.test(xt.layers)){if(Pe.isGroup)Kt=Pe.renderOrder;else if(Pe.isLOD)Pe.autoUpdate===!0&&Pe.update(xt);else if(Pe.isLight)O.pushLight(Pe),Pe.castShadow&&O.pushShadow(Pe);else if(Pe.isSprite){if(!Pe.frustumCulled||Vt.intersectsSprite(Pe)){tn&&wr.setFromMatrixPosition(Pe.matrixWorld).applyMatrix4($i);let Rr=Mn.update(Pe),Xr=Pe.material;Xr.visible&&F.push(Pe,Rr,Xr,Kt,wr.z,null)}}else if((Pe.isMesh||Pe.isLine||Pe.isPoints)&&(!Pe.frustumCulled||Vt.intersectsObject(Pe))){let Rr=Mn.update(Pe),Xr=Pe.material;if(tn&&(Pe.boundingSphere!==void 0?(Pe.boundingSphere===null&&Pe.computeBoundingSphere(),wr.copy(Pe.boundingSphere.center)):(Rr.boundingSphere===null&&Rr.computeBoundingSphere(),wr.copy(Rr.boundingSphere.center)),wr.applyMatrix4(Pe.matrixWorld).applyMatrix4($i)),Array.isArray(Xr)){let bs=Rr.groups;for(let Vs=0,xs=bs.length;Vs0&&Ks(Yt,Zi,xt,Kt),tn&&En.viewport(ge.copy(tn)),Yt.length>0&&Bi(Yt,xt,Kt),Zi.length>0&&Bi(Zi,xt,Kt),Rr.length>0&&Bi(Rr,xt,Kt),En.buffers.depth.setTest(!0),En.buffers.depth.setMask(!0),En.buffers.color.setMask(!0),En.setPolygonOffset(!1)}function Ks(Pe,xt,Kt,tn){if((Kt.isScene===!0?Kt.overrideMaterial:null)!==null)return;let Zi=We.isWebGL2;Yi===null&&(Yi=new Z3(1,1,{generateMipmaps:!0,type:it.has("EXT_color_buffer_half_float")?BW:mT,minFilter:DW,samples:Zi?4:0})),H.getDrawingBufferSize(Tr),Zi?Yi.setSize(Tr.x,Tr.y):Yi.setSize(L6e(Tr.x),L6e(Tr.y));let Rr=H.getRenderTarget();H.setRenderTarget(Yi),H.getClearColor(at),Ne=H.getClearAlpha(),Ne<1&&H.setClearColor(16777215,.5),H.clear();let Xr=H.toneMapping;H.toneMapping=gT,Bi(Pe,Kt,tn),Me.updateMultisampleRenderTarget(Yi),Me.updateRenderTargetMipmap(Yi);let bs=!1;for(let Vs=0,xs=xt.length;Vs0),Cs=!!Kt.morphAttributes.position,Lc=!!Kt.morphAttributes.normal,Gf=!!Kt.morphAttributes.color,pl=gT;tn.toneMapped&&(ue===null||ue.isXRRenderTarget===!0)&&(pl=H.toneMapping);let bg=Kt.morphAttributes.position||Kt.morphAttributes.normal||Kt.morphAttributes.color,hc=bg!==void 0?bg.length:0,Js=qi.get(tn),w2=O.state.lights;if(pn===!0&&(qn===!0||Pe!==Q)){let gh=Pe===Q&&tn.id===Te;Ae.setState(tn,Pe,gh)}let dc=!1;tn.version===Js.__version?(Js.needsLights&&Js.lightsStateVersion!==w2.state.version||Js.outputColorSpace!==Xr||Yt.isBatchedMesh&&Js.batching===!1||!Yt.isBatchedMesh&&Js.batching===!0||Yt.isInstancedMesh&&Js.instancing===!1||!Yt.isInstancedMesh&&Js.instancing===!0||Yt.isSkinnedMesh&&Js.skinning===!1||!Yt.isSkinnedMesh&&Js.skinning===!0||Yt.isInstancedMesh&&Js.instancingColor===!0&&Yt.instanceColor===null||Yt.isInstancedMesh&&Js.instancingColor===!1&&Yt.instanceColor!==null||Js.envMap!==bs||tn.fog===!0&&Js.fog!==Zi||Js.numClippingPlanes!==void 0&&(Js.numClippingPlanes!==Ae.numPlanes||Js.numIntersection!==Ae.numIntersection)||Js.vertexAlphas!==Vs||Js.vertexTangents!==xs||Js.morphTargets!==Cs||Js.morphNormals!==Lc||Js.morphColors!==Gf||Js.toneMapping!==pl||We.isWebGL2===!0&&Js.morphTargetsCount!==hc)&&(dc=!0):(dc=!0,Js.__version=tn.version);let km=Js.currentProgram;dc===!0&&(km=mf(tn,xt,Yt));let v2=!1,Iv=!1,_2=!1,gl=km.getUniforms(),Rm=Js.uniforms;if(En.useProgram(km.program)&&(v2=!0,Iv=!0,_2=!0),tn.id!==Te&&(Te=tn.id,Iv=!0),v2||Q!==Pe){gl.setValue(se,"projectionMatrix",Pe.projectionMatrix),gl.setValue(se,"viewMatrix",Pe.matrixWorldInverse);let gh=gl.map.cameraPosition;gh!==void 0&&gh.setValue(se,wr.setFromMatrixPosition(Pe.matrixWorld)),We.logarithmicDepthBuffer&&gl.setValue(se,"logDepthBufFC",2/(Math.log(Pe.far+1)/Math.LN2)),(tn.isMeshPhongMaterial||tn.isMeshToonMaterial||tn.isMeshLambertMaterial||tn.isMeshBasicMaterial||tn.isMeshStandardMaterial||tn.isShaderMaterial)&&gl.setValue(se,"isOrthographic",Pe.isOrthographicCamera===!0),Q!==Pe&&(Q=Pe,Iv=!0,_2=!0)}if(Yt.isSkinnedMesh){gl.setOptional(se,Yt,"bindMatrix"),gl.setOptional(se,Yt,"bindMatrixInverse");let gh=Yt.skeleton;gh&&(We.floatVertexTextures?(gh.boneTexture===null&&gh.computeBoneTexture(),gl.setValue(se,"boneTexture",gh.boneTexture,Me)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}Yt.isBatchedMesh&&(gl.setOptional(se,Yt,"batchingTexture"),gl.setValue(se,"batchingTexture",Yt._matricesTexture,Me));let rE=Kt.morphAttributes;if((rE.position!==void 0||rE.normal!==void 0||rE.color!==void 0&&We.isWebGL2===!0)&&Ye.update(Yt,Kt,km),(Iv||Js.receiveShadow!==Yt.receiveShadow)&&(Js.receiveShadow=Yt.receiveShadow,gl.setValue(se,"receiveShadow",Yt.receiveShadow)),tn.isMeshGouraudMaterial&&tn.envMap!==null&&(Rm.envMap.value=bs,Rm.flipEnvMap.value=bs.isCubeTexture&&bs.isRenderTargetTexture===!1?-1:1),Iv&&(gl.setValue(se,"toneMappingExposure",H.toneMappingExposure),Js.needsLights&&zb(Rm,_2),Zi&&tn.fog===!0&&mi.refreshFogUniforms(Rm,Zi),mi.refreshMaterialUniforms(Rm,tn,Tt,ot,Yi),cO.upload(se,J1(Js),Rm,Me)),tn.isShaderMaterial&&tn.uniformsNeedUpdate===!0&&(cO.upload(se,J1(Js),Rm,Me),tn.uniformsNeedUpdate=!1),tn.isSpriteMaterial&&gl.setValue(se,"center",Yt.center),gl.setValue(se,"modelViewMatrix",Yt.modelViewMatrix),gl.setValue(se,"normalMatrix",Yt.normalMatrix),gl.setValue(se,"modelMatrix",Yt.matrixWorld),tn.isShaderMaterial||tn.isRawShaderMaterial){let gh=tn.uniformsGroups;for(let y2=0,sE=gh.length;y20&&Me.useMultisampledRTT(Pe)===!1?Yt=qi.get(Pe).__webglMultisampledFramebuffer:Array.isArray(xs)?Yt=xs[Kt]:Yt=xs,ge.copy(Pe.viewport),Qe.copy(Pe.scissor),st=Pe.scissorTest}else ge.copy(mn).multiplyScalar(Tt).floor(),Qe.copy(cn).multiplyScalar(Tt).floor(),st=bi;if(En.bindFramebuffer(se.FRAMEBUFFER,Yt)&&We.drawBuffers&&tn&&En.drawBuffers(Pe,Yt),En.viewport(ge),En.scissor(Qe),En.setScissorTest(st),Zi){let bs=qi.get(Pe.texture);se.framebufferTexture2D(se.FRAMEBUFFER,se.COLOR_ATTACHMENT0,se.TEXTURE_CUBE_MAP_POSITIVE_X+xt,bs.__webglTexture,Kt)}else if(Rr){let bs=qi.get(Pe.texture),Vs=xt||0;se.framebufferTextureLayer(se.FRAMEBUFFER,se.COLOR_ATTACHMENT0,bs.__webglTexture,Kt||0,Vs)}Te=-1},this.readRenderTargetPixels=function(Pe,xt,Kt,tn,Yt,Zi,Rr){if(!(Pe&&Pe.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Xr=qi.get(Pe).__webglFramebuffer;if(Pe.isWebGLCubeRenderTarget&&Rr!==void 0&&(Xr=Xr[Rr]),Xr){En.bindFramebuffer(se.FRAMEBUFFER,Xr);try{let bs=Pe.texture,Vs=bs.format,xs=bs.type;if(Vs!==Cv&&Ke.convert(Vs)!==se.getParameter(se.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Cs=xs===BW&&(it.has("EXT_color_buffer_half_float")||We.isWebGL2&&it.has("EXT_color_buffer_float"));if(xs!==mT&&Ke.convert(xs)!==se.getParameter(se.IMPLEMENTATION_COLOR_READ_TYPE)&&!(xs===hT&&(We.isWebGL2||it.has("OES_texture_float")||it.has("WEBGL_color_buffer_float")))&&!Cs){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}xt>=0&&xt<=Pe.width-tn&&Kt>=0&&Kt<=Pe.height-Yt&&se.readPixels(xt,Kt,tn,Yt,Ke.convert(Vs),Ke.convert(xs),Zi)}finally{let bs=ue!==null?qi.get(ue).__webglFramebuffer:null;En.bindFramebuffer(se.FRAMEBUFFER,bs)}}},this.copyFramebufferToTexture=function(Pe,xt,Kt=0){let tn=Math.pow(2,-Kt),Yt=Math.floor(xt.image.width*tn),Zi=Math.floor(xt.image.height*tn);Me.setTexture2D(xt,0),se.copyTexSubImage2D(se.TEXTURE_2D,Kt,0,0,Pe.x,Pe.y,Yt,Zi),En.unbindTexture()},this.copyTextureToTexture=function(Pe,xt,Kt,tn=0){let Yt=xt.image.width,Zi=xt.image.height,Rr=Ke.convert(Kt.format),Xr=Ke.convert(Kt.type);Me.setTexture2D(Kt,0),se.pixelStorei(se.UNPACK_FLIP_Y_WEBGL,Kt.flipY),se.pixelStorei(se.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Kt.premultiplyAlpha),se.pixelStorei(se.UNPACK_ALIGNMENT,Kt.unpackAlignment),xt.isDataTexture?se.texSubImage2D(se.TEXTURE_2D,tn,Pe.x,Pe.y,Yt,Zi,Rr,Xr,xt.image.data):xt.isCompressedTexture?se.compressedTexSubImage2D(se.TEXTURE_2D,tn,Pe.x,Pe.y,xt.mipmaps[0].width,xt.mipmaps[0].height,Rr,xt.mipmaps[0].data):se.texSubImage2D(se.TEXTURE_2D,tn,Pe.x,Pe.y,Rr,Xr,xt.image),tn===0&&Kt.generateMipmaps&&se.generateMipmap(se.TEXTURE_2D),En.unbindTexture()},this.copyTextureToTexture3D=function(Pe,xt,Kt,tn,Yt=0){if(H.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Zi=Pe.max.x-Pe.min.x+1,Rr=Pe.max.y-Pe.min.y+1,Xr=Pe.max.z-Pe.min.z+1,bs=Ke.convert(tn.format),Vs=Ke.convert(tn.type),xs;if(tn.isData3DTexture)Me.setTexture3D(tn,0),xs=se.TEXTURE_3D;else if(tn.isDataArrayTexture||tn.isCompressedArrayTexture)Me.setTexture2DArray(tn,0),xs=se.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}se.pixelStorei(se.UNPACK_FLIP_Y_WEBGL,tn.flipY),se.pixelStorei(se.UNPACK_PREMULTIPLY_ALPHA_WEBGL,tn.premultiplyAlpha),se.pixelStorei(se.UNPACK_ALIGNMENT,tn.unpackAlignment);let Cs=se.getParameter(se.UNPACK_ROW_LENGTH),Lc=se.getParameter(se.UNPACK_IMAGE_HEIGHT),Gf=se.getParameter(se.UNPACK_SKIP_PIXELS),pl=se.getParameter(se.UNPACK_SKIP_ROWS),bg=se.getParameter(se.UNPACK_SKIP_IMAGES),hc=Kt.isCompressedTexture?Kt.mipmaps[Yt]:Kt.image;se.pixelStorei(se.UNPACK_ROW_LENGTH,hc.width),se.pixelStorei(se.UNPACK_IMAGE_HEIGHT,hc.height),se.pixelStorei(se.UNPACK_SKIP_PIXELS,Pe.min.x),se.pixelStorei(se.UNPACK_SKIP_ROWS,Pe.min.y),se.pixelStorei(se.UNPACK_SKIP_IMAGES,Pe.min.z),Kt.isDataTexture||Kt.isData3DTexture?se.texSubImage3D(xs,Yt,xt.x,xt.y,xt.z,Zi,Rr,Xr,bs,Vs,hc.data):Kt.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),se.compressedTexSubImage3D(xs,Yt,xt.x,xt.y,xt.z,Zi,Rr,Xr,bs,hc.data)):se.texSubImage3D(xs,Yt,xt.x,xt.y,xt.z,Zi,Rr,Xr,bs,Vs,hc),se.pixelStorei(se.UNPACK_ROW_LENGTH,Cs),se.pixelStorei(se.UNPACK_IMAGE_HEIGHT,Lc),se.pixelStorei(se.UNPACK_SKIP_PIXELS,Gf),se.pixelStorei(se.UNPACK_SKIP_ROWS,pl),se.pixelStorei(se.UNPACK_SKIP_IMAGES,bg),Yt===0&&tn.generateMipmaps&&se.generateMipmap(xs),En.unbindTexture()},this.initTexture=function(Pe){Pe.isCubeTexture?Me.setTextureCube(Pe,0):Pe.isData3DTexture?Me.setTexture3D(Pe,0):Pe.isDataArrayTexture||Pe.isCompressedArrayTexture?Me.setTexture2DArray(Pe,0):Me.setTexture2D(Pe,0),En.unbindTexture()},this.resetState=function(){oe=0,ne=0,ue=null,En.reset(),pt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return X3}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(n){this._outputColorSpace=n;let r=this.getContext();r.drawingBufferColorSpace=n===u5e?"display-p3":"srgb",r.unpackColorSpace=Pc.workingColorSpace===whe?"display-p3":"srgb"}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Td?q4:S2t}set outputEncoding(n){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=n===q4?Td:Y3}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(n){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=n}},H6e=class extends UW{};H6e.prototype.isWebGL1Renderer=!0;var ahe=class extends gg{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(n,r){return super.copy(n,r),n.background!==null&&(this.background=n.background.clone()),n.environment!==null&&(this.environment=n.environment.clone()),n.fog!==null&&(this.fog=n.fog.clone()),this.backgroundBlurriness=n.backgroundBlurriness,this.backgroundIntensity=n.backgroundIntensity,n.overrideMaterial!==null&&(this.overrideMaterial=n.overrideMaterial.clone()),this.matrixAutoUpdate=n.matrixAutoUpdate,this}toJSON(n){let r=super.toJSON(n);return this.fog!==null&&(r.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(r.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(r.object.backgroundIntensity=this.backgroundIntensity),r}};var che=class extends q1{constructor(n,r,c,u=1){super(n,r,c),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=u}copy(n){return super.copy(n),this.meshPerAttribute=n.meshPerAttribute,this}toJSON(){let n=super.toJSON();return n.meshPerAttribute=this.meshPerAttribute,n.isInstancedBufferAttribute=!0,n}},iO=new Il,s2t=new Il,Bfe=[],o2t=new K3,thn=new Il,LW=new Mm,kW=new vT,lhe=class extends Mm{constructor(n,r,c){super(n,r),this.isInstancedMesh=!0,this.instanceMatrix=new che(new Float32Array(c*16),16),this.instanceColor=null,this.count=c,this.boundingBox=null,this.boundingSphere=null;for(let u=0;u_)continue;L.applyMatrix4(this.matrixWorld);let Te=n.ray.origin.distanceTo(L);Ten.far||r.push({distance:Te,point:M.clone().applyMatrix4(this.matrixWorld),index:H,face:null,faceIndex:null,object:this})}}else{let z=Math.max(0,b.start),Z=Math.min(O.count,b.start+b.count);for(let H=z,te=Z-1;H_)continue;L.applyMatrix4(this.matrixWorld);let ne=n.ray.origin.distanceTo(L);nen.far||r.push({distance:ne,point:M.clone().applyMatrix4(this.matrixWorld),index:H,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let r=this.geometry.morphAttributes,c=Object.keys(r);if(c.length>0){let u=r[c[0]];if(u!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let d=0,b=u.length;d=d)){let w=r[1];n=d)break t}b=c,c=0;break n}break e}for(;c>>1;nr;)--b;if(++b,d!==0||b!==u){d>=b&&(b=Math.max(b,1),d=b-1);let w=this.getValueSize();this.times=c.slice(d,b),this.values=this.values.slice(d*w,b*w)}return this}validate(){let n=!0,r=this.getValueSize();r-Math.floor(r)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),n=!1);let c=this.times,u=this.values,d=c.length;d===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),n=!1);let b=null;for(let w=0;w!==d;w++){let _=c[w];if(typeof _=="number"&&isNaN(_)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,w,_),n=!1;break}if(b!==null&&b>_){console.error("THREE.KeyframeTrack: Out of order keys.",this,w,_,b),n=!1;break}b=_}if(u!==void 0&&nhn(u))for(let w=0,_=u.length;w!==_;++w){let x=u[w];if(isNaN(x)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,w,x),n=!1;break}}return n}optimize(){let n=this.times.slice(),r=this.values.slice(),c=this.getValueSize(),u=this.getInterpolation()===YIe,d=n.length-1,b=1;for(let w=1;w0){n[b]=n[d];for(let w=d*c,_=b*c,x=0;x!==c;++x)r[_+x]=r[w+x];++b}return b!==n.length?(this.times=n.slice(0,b),this.values=r.slice(0,b*c)):(this.times=n,this.values=r),this}clone(){let n=this.times.slice(),r=this.values.slice(),c=this.constructor,u=new c(this.name,n,r);return u.createInterpolant=this.createInterpolant,u}};Pv.prototype.TimeBufferType=Float32Array;Pv.prototype.ValueBufferType=Float32Array;Pv.prototype.DefaultInterpolation=Vfe;var Y4=class extends Pv{};Y4.prototype.ValueTypeName="bool";Y4.prototype.ValueBufferType=Array;Y4.prototype.DefaultInterpolation=$fe;Y4.prototype.InterpolantFactoryMethodLinear=void 0;Y4.prototype.InterpolantFactoryMethodSmooth=void 0;var K6e=class extends Pv{};K6e.prototype.ValueTypeName="color";var J6e=class extends Pv{};J6e.prototype.ValueTypeName="number";var Q6e=class extends gO{constructor(n,r,c,u){super(n,r,c,u)}interpolate_(n,r,c,u){let d=this.resultBuffer,b=this.sampleValues,w=this.valueSize,_=(c-r)/(u-r),x=n*w;for(let T=x+w;x!==T;x+=4)h2.slerpFlat(d,0,b,x-w,b,x,_);return d}},GW=class extends Pv{InterpolantFactoryMethodLinear(n){return new Q6e(this.times,this.values,this.getValueSize(),n)}};GW.prototype.ValueTypeName="quaternion";GW.prototype.DefaultInterpolation=Vfe;GW.prototype.InterpolantFactoryMethodSmooth=void 0;var Z4=class extends Pv{};Z4.prototype.ValueTypeName="string";Z4.prototype.ValueBufferType=Array;Z4.prototype.DefaultInterpolation=$fe;Z4.prototype.InterpolantFactoryMethodLinear=void 0;Z4.prototype.InterpolantFactoryMethodSmooth=void 0;var e5e=class extends Pv{};e5e.prototype.ValueTypeName="vector";var t5e=class{constructor(n,r,c){let u=this,d=!1,b=0,w=0,_,x=[];this.onStart=void 0,this.onLoad=n,this.onProgress=r,this.onError=c,this.itemStart=function(T){w++,d===!1&&u.onStart!==void 0&&u.onStart(T,b,w),d=!0},this.itemEnd=function(T){b++,u.onProgress!==void 0&&u.onProgress(T,b,w),b===w&&(d=!1,u.onLoad!==void 0&&u.onLoad())},this.itemError=function(T){u.onError!==void 0&&u.onError(T)},this.resolveURL=function(T){return _?_(T):T},this.setURLModifier=function(T){return _=T,this},this.addHandler=function(T,M){return x.push(T,M),this},this.removeHandler=function(T){let M=x.indexOf(T);return M!==-1&&x.splice(M,2),this},this.getHandler=function(T){for(let M=0,L=x.length;Mandnandornorxorxnornotbufdffinputconstantoutputhi:lohi:lohi:lohi:logenericout0out1in0in1aoi21aoi22aoi211aoi221aoi222aoi33oai21oai22oai211oai221oai222oai33and3nand3or3nor3and4nand4or4nor4`;window.netlistsvg=uhn;window.openroadSkin=O2t;window.THREE=p5e;var _he=globalThis,xhe=_he.ShadowRoot&&(_he.ShadyCSS===void 0||_he.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,F2t=Symbol(),N2t=new WeakMap,yhe=class{constructor(n,r,c){if(this._$cssResult$=!0,c!==F2t)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=n,this.t=r}get styleSheet(){let n=this.o,r=this.t;if(xhe&&n===void 0){let c=r!==void 0&&r.length===1;c&&(n=N2t.get(r)),n===void 0&&((this.o=n=new CSSStyleSheet).replaceSync(this.cssText),c&&N2t.set(r,n))}return n}toString(){return this.cssText}},U2t=s=>new yhe(typeof s=="string"?s:s+"",void 0,F2t);var z2t=(s,n)=>{if(xhe)s.adoptedStyleSheets=n.map(r=>r instanceof CSSStyleSheet?r:r.styleSheet);else for(let r of n){let c=document.createElement("style"),u=_he.litNonce;u!==void 0&&c.setAttribute("nonce",u),c.textContent=r.cssText,s.appendChild(c)}},g5e=xhe?s=>s:s=>s instanceof CSSStyleSheet?(n=>{let r="";for(let c of n.cssRules)r+=c.cssText;return U2t(r)})(s):s;var{is:fhn,defineProperty:hhn,getOwnPropertyDescriptor:dhn,getOwnPropertyNames:phn,getOwnPropertySymbols:ghn,getPrototypeOf:mhn}=Object,Ehe=globalThis,G2t=Ehe.trustedTypes,bhn=G2t?G2t.emptyScript:"",whn=Ehe.reactiveElementPolyfillSupport,$W=(s,n)=>s,m5e={toAttribute(s,n){switch(n){case Boolean:s=s?bhn:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,n){let r=s;switch(n){case Boolean:r=s!==null;break;case Number:r=s===null?null:Number(s);break;case Object:case Array:try{r=JSON.parse(s)}catch{r=null}}return r}},$2t=(s,n)=>!fhn(s,n),j2t={attribute:!0,type:String,converter:m5e,reflect:!1,useDefault:!1,hasChanged:$2t};Symbol.metadata??=Symbol("metadata"),Ehe.litPropertyMetadata??=new WeakMap;var Q3=class extends HTMLElement{static addInitializer(n){this._$Ei(),(this.l??=[]).push(n)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(n,r=j2t){if(r.state&&(r.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(n)&&((r=Object.create(r)).wrapped=!0),this.elementProperties.set(n,r),!r.noAccessor){let c=Symbol(),u=this.getPropertyDescriptor(n,c,r);u!==void 0&&hhn(this.prototype,n,u)}}static getPropertyDescriptor(n,r,c){let{get:u,set:d}=dhn(this.prototype,n)??{get(){return this[r]},set(b){this[r]=b}};return{get:u,set(b){let w=u?.call(this);d?.call(this,b),this.requestUpdate(n,w,c)},configurable:!0,enumerable:!0}}static getPropertyOptions(n){return this.elementProperties.get(n)??j2t}static _$Ei(){if(this.hasOwnProperty($W("elementProperties")))return;let n=mhn(this);n.finalize(),n.l!==void 0&&(this.l=[...n.l]),this.elementProperties=new Map(n.elementProperties)}static finalize(){if(this.hasOwnProperty($W("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty($W("properties"))){let r=this.properties,c=[...phn(r),...ghn(r)];for(let u of c)this.createProperty(u,r[u])}let n=this[Symbol.metadata];if(n!==null){let r=litPropertyMetadata.get(n);if(r!==void 0)for(let[c,u]of r)this.elementProperties.set(c,u)}this._$Eh=new Map;for(let[r,c]of this.elementProperties){let u=this._$Eu(r,c);u!==void 0&&this._$Eh.set(u,r)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(n){let r=[];if(Array.isArray(n)){let c=new Set(n.flat(1/0).reverse());for(let u of c)r.unshift(g5e(u))}else n!==void 0&&r.push(g5e(n));return r}static _$Eu(n,r){let c=r.attribute;return c===!1?void 0:typeof c=="string"?c:typeof n=="string"?n.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(n=>this.enableUpdating=n),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(n=>n(this))}addController(n){(this._$EO??=new Set).add(n),this.renderRoot!==void 0&&this.isConnected&&n.hostConnected?.()}removeController(n){this._$EO?.delete(n)}_$E_(){let n=new Map,r=this.constructor.elementProperties;for(let c of r.keys())this.hasOwnProperty(c)&&(n.set(c,this[c]),delete this[c]);n.size>0&&(this._$Ep=n)}createRenderRoot(){let n=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return z2t(n,this.constructor.elementStyles),n}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(n=>n.hostConnected?.())}enableUpdating(n){}disconnectedCallback(){this._$EO?.forEach(n=>n.hostDisconnected?.())}attributeChangedCallback(n,r,c){this._$AK(n,c)}_$ET(n,r){let c=this.constructor.elementProperties.get(n),u=this.constructor._$Eu(n,c);if(u!==void 0&&c.reflect===!0){let d=(c.converter?.toAttribute!==void 0?c.converter:m5e).toAttribute(r,c.type);this._$Em=n,d==null?this.removeAttribute(u):this.setAttribute(u,d),this._$Em=null}}_$AK(n,r){let c=this.constructor,u=c._$Eh.get(n);if(u!==void 0&&this._$Em!==u){let d=c.getPropertyOptions(u),b=typeof d.converter=="function"?{fromAttribute:d.converter}:d.converter?.fromAttribute!==void 0?d.converter:m5e;this._$Em=u;let w=b.fromAttribute(r,d.type);this[u]=w??this._$Ej?.get(u)??w,this._$Em=null}}requestUpdate(n,r,c,u=!1,d){if(n!==void 0){let b=this.constructor;if(u===!1&&(d=this[n]),c??=b.getPropertyOptions(n),!((c.hasChanged??$2t)(d,r)||c.useDefault&&c.reflect&&d===this._$Ej?.get(n)&&!this.hasAttribute(b._$Eu(n,c))))return;this.C(n,r,c)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(n,r,{useDefault:c,reflect:u,wrapped:d},b){c&&!(this._$Ej??=new Map).has(n)&&(this._$Ej.set(n,b??r??this[n]),d!==!0||b!==void 0)||(this._$AL.has(n)||(this.hasUpdated||c||(r=void 0),this._$AL.set(n,r)),u===!0&&this._$Em!==n&&(this._$Eq??=new Set).add(n))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(r){Promise.reject(r)}let n=this.scheduleUpdate();return n!=null&&await n,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[u,d]of this._$Ep)this[u]=d;this._$Ep=void 0}let c=this.constructor.elementProperties;if(c.size>0)for(let[u,d]of c){let{wrapped:b}=d,w=this[u];b!==!0||this._$AL.has(u)||w===void 0||this.C(u,void 0,d,w)}}let n=!1,r=this._$AL;try{n=this.shouldUpdate(r),n?(this.willUpdate(r),this._$EO?.forEach(c=>c.hostUpdate?.()),this.update(r)):this._$EM()}catch(c){throw n=!1,this._$EM(),c}n&&this._$AE(r)}willUpdate(n){}_$AE(n){this._$EO?.forEach(r=>r.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(n)),this.updated(n)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(n){return!0}update(n){this._$Eq&&=this._$Eq.forEach(r=>this._$ET(r,this[r])),this._$EM()}updated(n){}firstUpdated(n){}};Q3.elementStyles=[],Q3.shadowRootOptions={mode:"open"},Q3[$W("elementProperties")]=new Map,Q3[$W("finalized")]=new Map,whn?.({ReactiveElement:Q3}),(Ehe.reactiveElementVersions??=[]).push("2.1.2");var w5e=globalThis,V2t=s=>s,She=w5e.trustedTypes,W2t=She?She.createPolicy("lit-html",{createHTML:s=>s}):void 0,v5e="$lit$",eE=`lit$${Math.random().toFixed(9).slice(2)}$`,_5e="?"+eE,vhn=`<${_5e}>`,Q4=document,WW=()=>Q4.createComment(""),HW=s=>s===null||typeof s!="object"&&typeof s!="function",y5e=Array.isArray,K2t=s=>y5e(s)||typeof s?.[Symbol.iterator]=="function",b5e=`[ + the output wire straight to it. -->aoi21aoi22aoi211aoi221aoi222aoi33oai21oai22oai211oai221oai222oai33and3nand3or3nor3and4nand4or4nor4`;window.netlistsvg=dhn;window.openroadSkin=O2t;window.THREE=p5e;var _he=globalThis,xhe=_he.ShadowRoot&&(_he.ShadyCSS===void 0||_he.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,F2t=Symbol(),N2t=new WeakMap,yhe=class{constructor(n,r,c){if(this._$cssResult$=!0,c!==F2t)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=n,this.t=r}get styleSheet(){let n=this.o,r=this.t;if(xhe&&n===void 0){let c=r!==void 0&&r.length===1;c&&(n=N2t.get(r)),n===void 0&&((this.o=n=new CSSStyleSheet).replaceSync(this.cssText),c&&N2t.set(r,n))}return n}toString(){return this.cssText}},U2t=s=>new yhe(typeof s=="string"?s:s+"",void 0,F2t);var z2t=(s,n)=>{if(xhe)s.adoptedStyleSheets=n.map(r=>r instanceof CSSStyleSheet?r:r.styleSheet);else for(let r of n){let c=document.createElement("style"),u=_he.litNonce;u!==void 0&&c.setAttribute("nonce",u),c.textContent=r.cssText,s.appendChild(c)}},g5e=xhe?s=>s:s=>s instanceof CSSStyleSheet?(n=>{let r="";for(let c of n.cssRules)r+=c.cssText;return U2t(r)})(s):s;var{is:phn,defineProperty:ghn,getOwnPropertyDescriptor:mhn,getOwnPropertyNames:bhn,getOwnPropertySymbols:whn,getPrototypeOf:vhn}=Object,Ehe=globalThis,G2t=Ehe.trustedTypes,_hn=G2t?G2t.emptyScript:"",yhn=Ehe.reactiveElementPolyfillSupport,$W=(s,n)=>s,m5e={toAttribute(s,n){switch(n){case Boolean:s=s?_hn:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,n){let r=s;switch(n){case Boolean:r=s!==null;break;case Number:r=s===null?null:Number(s);break;case Object:case Array:try{r=JSON.parse(s)}catch{r=null}}return r}},$2t=(s,n)=>!phn(s,n),j2t={attribute:!0,type:String,converter:m5e,reflect:!1,useDefault:!1,hasChanged:$2t};Symbol.metadata??=Symbol("metadata"),Ehe.litPropertyMetadata??=new WeakMap;var Q3=class extends HTMLElement{static addInitializer(n){this._$Ei(),(this.l??=[]).push(n)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(n,r=j2t){if(r.state&&(r.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(n)&&((r=Object.create(r)).wrapped=!0),this.elementProperties.set(n,r),!r.noAccessor){let c=Symbol(),u=this.getPropertyDescriptor(n,c,r);u!==void 0&&ghn(this.prototype,n,u)}}static getPropertyDescriptor(n,r,c){let{get:u,set:d}=mhn(this.prototype,n)??{get(){return this[r]},set(b){this[r]=b}};return{get:u,set(b){let w=u?.call(this);d?.call(this,b),this.requestUpdate(n,w,c)},configurable:!0,enumerable:!0}}static getPropertyOptions(n){return this.elementProperties.get(n)??j2t}static _$Ei(){if(this.hasOwnProperty($W("elementProperties")))return;let n=vhn(this);n.finalize(),n.l!==void 0&&(this.l=[...n.l]),this.elementProperties=new Map(n.elementProperties)}static finalize(){if(this.hasOwnProperty($W("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty($W("properties"))){let r=this.properties,c=[...bhn(r),...whn(r)];for(let u of c)this.createProperty(u,r[u])}let n=this[Symbol.metadata];if(n!==null){let r=litPropertyMetadata.get(n);if(r!==void 0)for(let[c,u]of r)this.elementProperties.set(c,u)}this._$Eh=new Map;for(let[r,c]of this.elementProperties){let u=this._$Eu(r,c);u!==void 0&&this._$Eh.set(u,r)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(n){let r=[];if(Array.isArray(n)){let c=new Set(n.flat(1/0).reverse());for(let u of c)r.unshift(g5e(u))}else n!==void 0&&r.push(g5e(n));return r}static _$Eu(n,r){let c=r.attribute;return c===!1?void 0:typeof c=="string"?c:typeof n=="string"?n.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(n=>this.enableUpdating=n),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(n=>n(this))}addController(n){(this._$EO??=new Set).add(n),this.renderRoot!==void 0&&this.isConnected&&n.hostConnected?.()}removeController(n){this._$EO?.delete(n)}_$E_(){let n=new Map,r=this.constructor.elementProperties;for(let c of r.keys())this.hasOwnProperty(c)&&(n.set(c,this[c]),delete this[c]);n.size>0&&(this._$Ep=n)}createRenderRoot(){let n=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return z2t(n,this.constructor.elementStyles),n}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(n=>n.hostConnected?.())}enableUpdating(n){}disconnectedCallback(){this._$EO?.forEach(n=>n.hostDisconnected?.())}attributeChangedCallback(n,r,c){this._$AK(n,c)}_$ET(n,r){let c=this.constructor.elementProperties.get(n),u=this.constructor._$Eu(n,c);if(u!==void 0&&c.reflect===!0){let d=(c.converter?.toAttribute!==void 0?c.converter:m5e).toAttribute(r,c.type);this._$Em=n,d==null?this.removeAttribute(u):this.setAttribute(u,d),this._$Em=null}}_$AK(n,r){let c=this.constructor,u=c._$Eh.get(n);if(u!==void 0&&this._$Em!==u){let d=c.getPropertyOptions(u),b=typeof d.converter=="function"?{fromAttribute:d.converter}:d.converter?.fromAttribute!==void 0?d.converter:m5e;this._$Em=u;let w=b.fromAttribute(r,d.type);this[u]=w??this._$Ej?.get(u)??w,this._$Em=null}}requestUpdate(n,r,c,u=!1,d){if(n!==void 0){let b=this.constructor;if(u===!1&&(d=this[n]),c??=b.getPropertyOptions(n),!((c.hasChanged??$2t)(d,r)||c.useDefault&&c.reflect&&d===this._$Ej?.get(n)&&!this.hasAttribute(b._$Eu(n,c))))return;this.C(n,r,c)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(n,r,{useDefault:c,reflect:u,wrapped:d},b){c&&!(this._$Ej??=new Map).has(n)&&(this._$Ej.set(n,b??r??this[n]),d!==!0||b!==void 0)||(this._$AL.has(n)||(this.hasUpdated||c||(r=void 0),this._$AL.set(n,r)),u===!0&&this._$Em!==n&&(this._$Eq??=new Set).add(n))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(r){Promise.reject(r)}let n=this.scheduleUpdate();return n!=null&&await n,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[u,d]of this._$Ep)this[u]=d;this._$Ep=void 0}let c=this.constructor.elementProperties;if(c.size>0)for(let[u,d]of c){let{wrapped:b}=d,w=this[u];b!==!0||this._$AL.has(u)||w===void 0||this.C(u,void 0,d,w)}}let n=!1,r=this._$AL;try{n=this.shouldUpdate(r),n?(this.willUpdate(r),this._$EO?.forEach(c=>c.hostUpdate?.()),this.update(r)):this._$EM()}catch(c){throw n=!1,this._$EM(),c}n&&this._$AE(r)}willUpdate(n){}_$AE(n){this._$EO?.forEach(r=>r.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(n)),this.updated(n)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(n){return!0}update(n){this._$Eq&&=this._$Eq.forEach(r=>this._$ET(r,this[r])),this._$EM()}updated(n){}firstUpdated(n){}};Q3.elementStyles=[],Q3.shadowRootOptions={mode:"open"},Q3[$W("elementProperties")]=new Map,Q3[$W("finalized")]=new Map,yhn?.({ReactiveElement:Q3}),(Ehe.reactiveElementVersions??=[]).push("2.1.2");var w5e=globalThis,V2t=s=>s,She=w5e.trustedTypes,W2t=She?She.createPolicy("lit-html",{createHTML:s=>s}):void 0,v5e="$lit$",eE=`lit$${Math.random().toFixed(9).slice(2)}$`,_5e="?"+eE,xhn=`<${_5e}>`,Q4=document,WW=()=>Q4.createComment(""),HW=s=>s===null||typeof s!="object"&&typeof s!="function",y5e=Array.isArray,K2t=s=>y5e(s)||typeof s?.[Symbol.iterator]=="function",b5e=`[ \f\r]`,VW=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,H2t=/-->/g,q2t=/>/g,K4=RegExp(`>|${b5e}(?:([^\\s"'>=/]+)(${b5e}*=${b5e}*(?:[^ -\f\r"'\`<>=]|("|')|))|$)`,"g"),X2t=/'/g,Y2t=/"/g,J2t=/^(?:script|style|textarea|title)$/i,x5e=s=>(n,...r)=>({_$litType$:s,strings:n,values:r}),ik=x5e(1),cci=x5e(2),lci=x5e(3),ek=Symbol.for("lit-noChange"),tu=Symbol.for("lit-nothing"),Z2t=new WeakMap,J4=Q4.createTreeWalker(Q4,129);function Q2t(s,n){if(!y5e(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return W2t!==void 0?W2t.createHTML(n):n}var ext=(s,n)=>{let r=s.length-1,c=[],u,d=n===2?"":n===3?"":"",b=VW;for(let w=0;w"?(b=u??VW,M=-1):T[1]===void 0?M=-2:(M=b.lastIndex-T[2].length,x=T[1],b=T[3]===void 0?K4:T[3]==='"'?Y2t:X2t):b===Y2t||b===X2t?b=K4:b===H2t||b===q2t?b=VW:(b=K4,u=void 0);let I=b===K4&&s[w+1].startsWith("/>")?" ":"";d+=b===VW?_+vhn:M>=0?(c.push(x),_.slice(0,M)+v5e+_.slice(M)+eE+I):_+eE+(M===-2?w:I)}return[Q2t(s,d+(s[r]||"")+(n===2?"":n===3?"":"")),c]},qW=class s{constructor({strings:n,_$litType$:r},c){let u;this.parts=[];let d=0,b=0,w=n.length-1,_=this.parts,[x,T]=ext(n,r);if(this.el=s.createElement(x,c),J4.currentNode=this.el.content,r===2||r===3){let M=this.el.content.firstChild;M.replaceWith(...M.childNodes)}for(;(u=J4.nextNode())!==null&&_.length0){u.textContent=She?She.emptyScript:"";for(let I=0;I2||c[0]!==""||c[1]!==""?(this._$AH=Array(c.length-1).fill(new String),this.strings=c):this._$AH=tu}_$AI(n,r=this,c,u){let d=this.strings,b=!1;if(d===void 0)n=tk(this,n,r,0),b=!HW(n)||n!==this._$AH&&n!==ek,b&&(this._$AH=n);else{let w=n,_,x;for(n=d[0],_=0;_{let c=r?.renderBefore??n,u=c._$litPart$;if(u===void 0){let d=r?.renderBefore??null;c._$litPart$=u=new bO(n.insertBefore(WW(),d),d,void 0,r??{})}return u._$AI(s),u};var E5e=globalThis,p2=class extends Q3{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let n=super.createRenderRoot();return this.renderOptions.renderBefore??=n.firstChild,n}update(n){let r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(n),this._$Do=nxt(r,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return ek}};p2._$litElement$=!0,p2.finalized=!0,E5e.litElementHydrateSupport?.({LitElement:p2});var yhn=E5e.litElementPolyfillSupport;yhn?.({LitElement:p2});(E5e.litElementVersions??=[]).push("4.2.2");var{I:Eci}=txt;var ixt=s=>s.strings===void 0;var rxt={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},S5e=s=>(...n)=>({_$litDirective$:s,values:n}),Lhe=class{constructor(n){}get _$AU(){return this._$AM._$AU}_$AT(n,r,c){this._$Ct=n,this._$AM=r,this._$Ci=c}_$AS(n,r){return this.update(n,r)}update(n,r){return this.render(...r)}};var XW=(s,n)=>{let r=s._$AN;if(r===void 0)return!1;for(let c of r)c._$AO?.(n,!1),XW(c,n);return!0},khe=s=>{let n,r;do{if((n=s._$AM)===void 0)break;r=n._$AN,r.delete(s),s=n}while(r?.size===0)},sxt=s=>{for(let n;n=s._$AM;s=n){let r=n._$AN;if(r===void 0)n._$AN=r=new Set;else if(r.has(s))break;r.add(s),Shn(n)}};function xhn(s){this._$AN!==void 0?(khe(this),this._$AM=s,sxt(this)):this._$AM=s}function Ehn(s,n=!1,r=0){let c=this._$AH,u=this._$AN;if(u!==void 0&&u.size!==0)if(n)if(Array.isArray(c))for(let d=r;d{s.type==rxt.CHILD&&(s._$AP??=Ehn,s._$AQ??=xhn)},Rhe=class extends Lhe{constructor(){super(...arguments),this._$AN=void 0}_$AT(n,r,c){super._$AT(n,r,c),sxt(this),this.isConnected=n._$AU}_$AO(n,r=!0){n!==this.isConnected&&(this.isConnected=n,n?this.reconnected?.():this.disconnected?.()),r&&(XW(this,n),khe(this))}setValue(n){if(ixt(this._$Ct))this._$Ct._$AI(n,this);else{let r=[...this._$Ct._$AH];r[this._$Ci]=n,this._$Ct._$AI(r,this,0)}}disconnected(){}reconnected(){}};var tE=()=>new T5e,T5e=class{},M5e=new WeakMap,nE=S5e(class extends Rhe{render(s){return tu}update(s,[n]){let r=n!==this.G;return r&&this.rt(void 0),(r||this.lt!==this.ct)&&(this.G=n,this.ht=s.options?.host,this.rt(this.ct=s.element)),tu}rt(s){if(this.G!==void 0)if(this.isConnected||(s=void 0),typeof this.G=="function"){let n=this.ht??globalThis,r=M5e.get(n);r===void 0&&(r=new WeakMap,M5e.set(n,r)),r.get(this.G)!==void 0&&this.G.call(this.ht,void 0),r.set(this.G,s),s!==void 0&&this.G.call(this.ht,s)}else this.G.value=s}get lt(){return typeof this.G=="function"?M5e.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});function YW(s,n,r){return s?n(s):r?.(s)}var C5e=s=>s??tu;var A5e=class extends p2{static properties={name:{type:String,reflect:!0},maximizable:{type:Boolean,reflect:!0},collapsible:{type:Boolean,reflect:!0},maximized:{type:Boolean,reflect:!0},collapsed:{type:Boolean,reflect:!0}};constructor(){super(),this.tabsRef=tE(),this.contentRef=tE(),this.headerRef=tE(),this.controlsRef=tE(),this.maximizeBtnRef=tE(),this.collapseBtnRef=tE(),this._onMaximizeClick=this._onMaximizeClick.bind(this),this._onCollapseClick=this._onCollapseClick.bind(this),this._onResetLayoutClick=this._onResetLayoutClick.bind(this)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.classList.add("ide-pane",`ide-pane-${this.paneName}`),this.performUpdate()}get paneName(){return this.name||this.getAttribute("name")||this.id.replace(/^pane-/,"")||"pane"}get tabsEl(){return this.hasUpdated||this.performUpdate(),this.tabsRef.value}get contentEl(){return this.hasUpdated||this.performUpdate(),this.contentRef.value}get headerEl(){return this.hasUpdated||this.performUpdate(),this.headerRef.value}get controlsEl(){return this.hasUpdated||this.performUpdate(),this.controlsRef.value}get maximizeBtn(){return this.hasUpdated||this.performUpdate(),this.maximizeBtnRef.value}get collapseBtn(){return this.hasUpdated||this.performUpdate(),this.collapseBtnRef.value}get _collapseIcon(){let n=this.paneName;return n==="bottom"?this.collapsed?"\u25B2":"\u25BC":n==="left"?this.collapsed?"\u25B6":"\u25C0":n==="right"?this.collapsed?"\u25C0":"\u25B6":"\u25BC"}get _collapseTitle(){let n=this.paneName,r=n.charAt(0).toUpperCase()+n.slice(1);return n==="bottom"?this.collapsed?"Expand Console":"Collapse Console":n==="left"?this.collapsed?"Expand Left Panel":"Collapse Left Panel":n==="right"?this.collapsed?"Expand Right Panel":"Collapse Right Panel":`Collapse ${r}`}_emit(n,r={}){this.dispatchEvent(new CustomEvent(n,{bubbles:!0,composed:!0,detail:r}))}_onMaximizeClick(n){n.stopPropagation(),this._emit("ide-pane-maximize",{pane:this.paneName})}_onCollapseClick(n){n.stopPropagation(),this._emit("ide-pane-collapse",{pane:this.paneName})}_onResetLayoutClick(n){n.stopPropagation(),this._emit("ide-layout-reset")}setMaximized(n){this.maximized=!!n,this.classList.toggle("maximized",this.maximized),this.maximizeBtn&&(this.maximizeBtn.textContent=this.maximized?"\u29C9":"\u2922",this.maximizeBtn.title=this.maximized?"Restore":"Maximize")}setCollapsed(n){this.collapsed=!!n,this.classList.toggle("collapsed",this.collapsed),this.collapseBtn&&(this.collapseBtn.textContent=this._collapseIcon,this.collapseBtn.title=this._collapseTitle)}build(){this.hasUpdated||this.performUpdate()}updated(n){super.updated(n),n.has("maximized")&&this.classList.toggle("maximized",!!this.maximized),n.has("collapsed")&&this.classList.toggle("collapsed",!!this.collapsed)}render(){let n=this.paneName,r=this.id||`pane-${n}`,c=this.maximizable||this.hasAttribute("maximizable"),u=this.collapsible||this.hasAttribute("collapsible");return ik` +\f\r"'\`<>=]|("|')|))|$)`,"g"),X2t=/'/g,Y2t=/"/g,J2t=/^(?:script|style|textarea|title)$/i,x5e=s=>(n,...r)=>({_$litType$:s,strings:n,values:r}),ik=x5e(1),hci=x5e(2),dci=x5e(3),ek=Symbol.for("lit-noChange"),tu=Symbol.for("lit-nothing"),Z2t=new WeakMap,J4=Q4.createTreeWalker(Q4,129);function Q2t(s,n){if(!y5e(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return W2t!==void 0?W2t.createHTML(n):n}var ext=(s,n)=>{let r=s.length-1,c=[],u,d=n===2?"":n===3?"":"",b=VW;for(let w=0;w"?(b=u??VW,M=-1):T[1]===void 0?M=-2:(M=b.lastIndex-T[2].length,x=T[1],b=T[3]===void 0?K4:T[3]==='"'?Y2t:X2t):b===Y2t||b===X2t?b=K4:b===H2t||b===q2t?b=VW:(b=K4,u=void 0);let I=b===K4&&s[w+1].startsWith("/>")?" ":"";d+=b===VW?_+xhn:M>=0?(c.push(x),_.slice(0,M)+v5e+_.slice(M)+eE+I):_+eE+(M===-2?w:I)}return[Q2t(s,d+(s[r]||"")+(n===2?"":n===3?"":"")),c]},qW=class s{constructor({strings:n,_$litType$:r},c){let u;this.parts=[];let d=0,b=0,w=n.length-1,_=this.parts,[x,T]=ext(n,r);if(this.el=s.createElement(x,c),J4.currentNode=this.el.content,r===2||r===3){let M=this.el.content.firstChild;M.replaceWith(...M.childNodes)}for(;(u=J4.nextNode())!==null&&_.length0){u.textContent=She?She.emptyScript:"";for(let I=0;I2||c[0]!==""||c[1]!==""?(this._$AH=Array(c.length-1).fill(new String),this.strings=c):this._$AH=tu}_$AI(n,r=this,c,u){let d=this.strings,b=!1;if(d===void 0)n=tk(this,n,r,0),b=!HW(n)||n!==this._$AH&&n!==ek,b&&(this._$AH=n);else{let w=n,_,x;for(n=d[0],_=0;_{let c=r?.renderBefore??n,u=c._$litPart$;if(u===void 0){let d=r?.renderBefore??null;c._$litPart$=u=new bO(n.insertBefore(WW(),d),d,void 0,r??{})}return u._$AI(s),u};var E5e=globalThis,p2=class extends Q3{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let n=super.createRenderRoot();return this.renderOptions.renderBefore??=n.firstChild,n}update(n){let r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(n),this._$Do=nxt(r,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return ek}};p2._$litElement$=!0,p2.finalized=!0,E5e.litElementHydrateSupport?.({LitElement:p2});var Shn=E5e.litElementPolyfillSupport;Shn?.({LitElement:p2});(E5e.litElementVersions??=[]).push("4.2.2");var{I:Cci}=txt;var ixt=s=>s.strings===void 0;var rxt={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},S5e=s=>(...n)=>({_$litDirective$:s,values:n}),Lhe=class{constructor(n){}get _$AU(){return this._$AM._$AU}_$AT(n,r,c){this._$Ct=n,this._$AM=r,this._$Ci=c}_$AS(n,r){return this.update(n,r)}update(n,r){return this.render(...r)}};var XW=(s,n)=>{let r=s._$AN;if(r===void 0)return!1;for(let c of r)c._$AO?.(n,!1),XW(c,n);return!0},khe=s=>{let n,r;do{if((n=s._$AM)===void 0)break;r=n._$AN,r.delete(s),s=n}while(r?.size===0)},sxt=s=>{for(let n;n=s._$AM;s=n){let r=n._$AN;if(r===void 0)n._$AN=r=new Set;else if(r.has(s))break;r.add(s),Chn(n)}};function Mhn(s){this._$AN!==void 0?(khe(this),this._$AM=s,sxt(this)):this._$AM=s}function Thn(s,n=!1,r=0){let c=this._$AH,u=this._$AN;if(u!==void 0&&u.size!==0)if(n)if(Array.isArray(c))for(let d=r;d{s.type==rxt.CHILD&&(s._$AP??=Thn,s._$AQ??=Mhn)},Rhe=class extends Lhe{constructor(){super(...arguments),this._$AN=void 0}_$AT(n,r,c){super._$AT(n,r,c),sxt(this),this.isConnected=n._$AU}_$AO(n,r=!0){n!==this.isConnected&&(this.isConnected=n,n?this.reconnected?.():this.disconnected?.()),r&&(XW(this,n),khe(this))}setValue(n){if(ixt(this._$Ct))this._$Ct._$AI(n,this);else{let r=[...this._$Ct._$AH];r[this._$Ci]=n,this._$Ct._$AI(r,this,0)}}disconnected(){}reconnected(){}};var tE=()=>new T5e,T5e=class{},M5e=new WeakMap,nE=S5e(class extends Rhe{render(s){return tu}update(s,[n]){let r=n!==this.G;return r&&this.rt(void 0),(r||this.lt!==this.ct)&&(this.G=n,this.ht=s.options?.host,this.rt(this.ct=s.element)),tu}rt(s){if(this.G!==void 0)if(this.isConnected||(s=void 0),typeof this.G=="function"){let n=this.ht??globalThis,r=M5e.get(n);r===void 0&&(r=new WeakMap,M5e.set(n,r)),r.get(this.G)!==void 0&&this.G.call(this.ht,void 0),r.set(this.G,s),s!==void 0&&this.G.call(this.ht,s)}else this.G.value=s}get lt(){return typeof this.G=="function"?M5e.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});function YW(s,n,r){return s?n(s):r?.(s)}var C5e=s=>s??tu;var A5e=class extends p2{static properties={name:{type:String,reflect:!0},maximizable:{type:Boolean,reflect:!0},collapsible:{type:Boolean,reflect:!0},maximized:{type:Boolean,reflect:!0},collapsed:{type:Boolean,reflect:!0}};constructor(){super(),this.tabsRef=tE(),this.contentRef=tE(),this.headerRef=tE(),this.controlsRef=tE(),this.maximizeBtnRef=tE(),this.collapseBtnRef=tE(),this._onMaximizeClick=this._onMaximizeClick.bind(this),this._onCollapseClick=this._onCollapseClick.bind(this),this._onResetLayoutClick=this._onResetLayoutClick.bind(this)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.classList.add("ide-pane",`ide-pane-${this.paneName}`),this.performUpdate()}get paneName(){return this.name||this.getAttribute("name")||this.id.replace(/^pane-/,"")||"pane"}get tabsEl(){return this.hasUpdated||this.performUpdate(),this.tabsRef.value}get contentEl(){return this.hasUpdated||this.performUpdate(),this.contentRef.value}get headerEl(){return this.hasUpdated||this.performUpdate(),this.headerRef.value}get controlsEl(){return this.hasUpdated||this.performUpdate(),this.controlsRef.value}get maximizeBtn(){return this.hasUpdated||this.performUpdate(),this.maximizeBtnRef.value}get collapseBtn(){return this.hasUpdated||this.performUpdate(),this.collapseBtnRef.value}get _collapseIcon(){let n=this.paneName;return n==="bottom"?this.collapsed?"\u25B2":"\u25BC":n==="left"?this.collapsed?"\u25B6":"\u25C0":n==="right"?this.collapsed?"\u25C0":"\u25B6":"\u25BC"}get _collapseTitle(){let n=this.paneName,r=n.charAt(0).toUpperCase()+n.slice(1);return n==="bottom"?this.collapsed?"Expand Console":"Collapse Console":n==="left"?this.collapsed?"Expand Left Panel":"Collapse Left Panel":n==="right"?this.collapsed?"Expand Right Panel":"Collapse Right Panel":`Collapse ${r}`}_emit(n,r={}){this.dispatchEvent(new CustomEvent(n,{bubbles:!0,composed:!0,detail:r}))}_onMaximizeClick(n){n.stopPropagation(),this._emit("ide-pane-maximize",{pane:this.paneName})}_onCollapseClick(n){n.stopPropagation(),this._emit("ide-pane-collapse",{pane:this.paneName})}_onResetLayoutClick(n){n.stopPropagation(),this._emit("ide-layout-reset")}setMaximized(n){this.maximized=!!n,this.classList.toggle("maximized",this.maximized),this.maximizeBtn&&(this.maximizeBtn.textContent=this.maximized?"\u29C9":"\u2922",this.maximizeBtn.title=this.maximized?"Restore":"Maximize")}setCollapsed(n){this.collapsed=!!n,this.classList.toggle("collapsed",this.collapsed),this.collapseBtn&&(this.collapseBtn.textContent=this._collapseIcon,this.collapseBtn.title=this._collapseTitle)}build(){this.hasUpdated||this.performUpdate()}updated(n){super.updated(n),n.has("maximized")&&this.classList.toggle("maximized",!!this.maximized),n.has("collapsed")&&this.classList.toggle("collapsed",!!this.collapsed)}render(){let n=this.paneName,r=this.id||`pane-${n}`,c=this.maximizable||this.hasAttribute("maximizable"),u=this.collapsible||this.hasAttribute("collapsible");return ik`
@@ -10192,7 +10192,7 @@ path, rect, circle, polygon { @click=${this._onCloseClick} >✕ `)} - `}};customElements.get("ide-pane")||customElements.define("ide-pane",A5e);customElements.get("ide-splitter")||customElements.define("ide-splitter",Dhe);customElements.get("ide-tab")||customElements.define("ide-tab",L5e);var oxt={DisplayControls:{pane:"left",title:"Display Controls",closable:!1},LayoutViewer:{pane:"main",title:"Layout",closable:!1},SchematicWidget:{pane:"main",title:"Schematic",closable:!0},"3DViewer":{pane:"main",title:"3D Viewer",closable:!0},TclConsole:{pane:"bottom",title:"Tcl Console",closable:!1},Inspector:{pane:"right",title:"Inspector",closable:!0},Browser:{pane:"right",title:"Hierarchy",closable:!0},TimingWidget:{pane:"right",title:"Timing",closable:!0},DRCWidget:{pane:"right",title:"DRC",closable:!0},SelectHighlight:{pane:"right",title:"Select Highlight",closable:!0},ClockWidget:{pane:"right",title:"Clock Tree",closable:!0},ChartsWidget:{pane:"right",title:"Charts",closable:!0},HelpWidget:{pane:"right",title:"Help",closable:!0}},Ihe={left:{cssVar:"--pane-left-width",defaultSize:"240px",minSize:140,maxFraction:.45,dimension:"width",isVertical:!0,invertDelta:!1},right:{cssVar:"--pane-right-width",defaultSize:"340px",minSize:160,maxFraction:.5,dimension:"width",isVertical:!0,invertDelta:!0},bottom:{cssVar:"--pane-bottom-height",defaultSize:"220px",minSize:70,maxFraction:.75,dimension:"height",isVertical:!1,invertDelta:!0}},Bhe=class{constructor(n){this.containerEl=n,this.factories=new Map,this.components=new Map,this.activeTabs={left:null,main:null,bottom:null,right:null},this.closedComponents=new Set,this.eventListeners=new Map,this._resizeScheduled=!1,this._ensureDOM(),this._initSplitters(),this._initControls(),this._initResizeObserver()}on(n,r){this.eventListeners.has(n)||this.eventListeners.set(n,new Set),this.eventListeners.get(n).add(r)}off(n,r){this.eventListeners.get(n)?.delete(r)}emit(n,...r){let c=this.eventListeners.get(n);if(c)for(let u of c)try{u(...r)}catch(d){console.error(d)}}_ensureDOM(){this.containerEl.classList.add("ide-layout"),this.containerEl.querySelector("#pane-left")||this._buildInitialLayoutTree(),this._resolvePaneReferences()}_buildInitialLayoutTree(){this.containerEl.appendChild(this._createGutterButton("left","\u25B6 Display Controls","Restore Display Controls")),this.containerEl.appendChild(this._createGutterButton("right","\u25C0 Tools & Inspector","Restore Right Panel")),this.containerEl.appendChild(this._createPane("pane-left","left")),this.containerEl.appendChild(this._createSplitter("splitter-left","left","vertical","Drag to resize panel"));let n=document.createElement("main");n.id="pane-center",n.className="ide-center",n.appendChild(this._createPane("pane-main","main",{maximizable:!0})),n.appendChild(this._createSplitter("splitter-bottom","bottom","horizontal","Drag to resize console")),n.appendChild(this._createGutterButton("bottom","\u25B2 Tcl Console","Restore Tcl Console")),n.appendChild(this._createPane("pane-bottom","bottom",{maximizable:!0,collapsible:!0})),this.containerEl.appendChild(n),this.containerEl.appendChild(this._createSplitter("splitter-right","right","vertical","Drag to resize panel")),this.containerEl.appendChild(this._createPane("pane-right","right",{maximizable:!0,collapsible:!0}))}_createGutterButton(n,r,c){let u=document.createElement("button");u.id=`gutter-expand-${n}`,u.className=`ide-gutter-expand ide-gutter-${n}`,u.title=c;let d=document.createElement("span");return d.textContent=r,u.appendChild(d),u}_createPane(n,r,c={}){let u=document.createElement("ide-pane");return u.id=n,u.setAttribute("name",r),c.maximizable&&u.setAttribute("maximizable",""),c.collapsible&&u.setAttribute("collapsible",""),u}_createSplitter(n,r,c,u){let d=document.createElement("ide-splitter");return d.id=n,d.setAttribute("for",r),d.setAttribute("orientation",c),d.title=u,d}_resolvePaneReferences(){let n=["left","main","bottom","right"];this.panes={};for(let r of n){let c=this.containerEl.querySelector(`#pane-${r}`);c?.build&&c.build(),this.panes[r]={el:c,paneComponent:c,tabsEl:c?.tabsEl||this.containerEl.querySelector(`#pane-${r}-tabs`),contentEl:c?.contentEl||this.containerEl.querySelector(`#pane-${r}-content`)}}this.centerEl=this.containerEl.querySelector("#pane-center")}_initSplitters(){let n=null;this.containerEl.addEventListener("ide-splitter-start",r=>{let c=r.detail?.for,u=Ihe[c];if(!u)return;let b=(c==="bottom"?this.centerEl||this.containerEl:this.containerEl).getBoundingClientRect(),w=this.panes[c]?.el?.getBoundingClientRect()||{},_=u.dimension==="width"?b.width:b.height,x=u.dimension==="width"?w.width||240:w.height||220;n={paneName:c,cfg:u,startSize:x,maxLimit:Math.round(_*u.maxFraction)||500}}),this.containerEl.addEventListener("ide-splitter-drag",r=>{if(!n||n.paneName!==r.detail?.for)return;let{cfg:c,startSize:u,maxLimit:d}=n,b=c.invertDelta?-r.detail.delta:r.detail.delta,w=Math.round(u+b),_=Math.max(c.minSize,Math.min(d,w));this.containerEl.style.setProperty(c.cssVar,`${_}px`),this.notifyResize()}),this.containerEl.addEventListener("ide-splitter-end",()=>{n=null,this.saveLayout(),this.notifyResize()}),this.containerEl.addEventListener("ide-splitter-reset",r=>{let c=r.detail?.for;this._resetSplitterPane(c)}),this._setupFallbackSplitters()}_resetSplitterPane(n){let r=Ihe[n];r&&(this.containerEl.style.setProperty(r.cssVar,r.defaultSize),this.isPaneCollapsed(n)?this.restorePane(n):(this.saveLayout(),this.notifyResize()))}_setupFallbackSplitters(){for(let[n,r]of Object.entries(Ihe)){let c=this.containerEl.querySelector(`#splitter-${n}`);if(!c||c instanceof Dhe)continue;let u=!r.invertDelta,d=r.isVertical;c.addEventListener("pointerdown",b=>{b.preventDefault();try{c.setPointerCapture(b.pointerId)}catch{}c.classList.add("dragging"),document.body&&document.body.classList.add("is-resizing",d?"is-resizing-v":"is-resizing-h");let w=d?b.clientX:b.clientY,x=(n==="bottom"?this.centerEl||this.containerEl:this.containerEl).getBoundingClientRect(),T=this.panes[n]?.el?.getBoundingClientRect()||{},M=r.dimension==="width"?T.width||240:T.height||220,L=r.dimension==="width"?x.width:x.height,I=Math.round(L*r.maxFraction)||500,D=new AbortController,{signal:F}=D,O=Z=>{let H=d?Z.clientX:Z.clientY,te=u?H-w:w-H,oe=Math.round(M+te),ne=Math.max(r.minSize,Math.min(I,oe));this.containerEl.style.setProperty(r.cssVar,`${ne}px`),this.notifyResize()},z=Z=>{try{c.releasePointerCapture(Z.pointerId)}catch{}c.classList.remove("dragging"),document.body&&document.body.classList.remove("is-resizing","is-resizing-v","is-resizing-h"),D.abort(),this.saveLayout(),this.notifyResize()};window.addEventListener("pointermove",O,{signal:F}),window.addEventListener("pointerup",z,{signal:F}),window.addEventListener("pointercancel",z,{signal:F})}),c.addEventListener("dblclick",()=>{this._resetSplitterPane(n)})}}_initControls(){this.containerEl.addEventListener("ide-pane-maximize",r=>{this.toggleMaximize(r.detail?.pane)}),this.containerEl.addEventListener("ide-pane-collapse",r=>{this.toggleCollapse(r.detail?.pane)}),this.containerEl.addEventListener("ide-layout-reset",()=>{this.resetLayout()});for(let r of["left","right","bottom"]){let c=this.containerEl.querySelector(`#gutter-expand-${r}`);c&&c.addEventListener("click",()=>this.restorePane(r))}let n=[{sel:"#btn-collapse-left",handler:()=>this.toggleCollapse("left")},{sel:"#btn-collapse-right",handler:()=>this.toggleCollapse("right")},{sel:"#btn-collapse-bottom",handler:()=>this.toggleCollapse("bottom")},{sel:"#btn-maximize-main",handler:()=>this.toggleMaximize("main")},{sel:"#btn-maximize-bottom",handler:()=>this.toggleMaximize("bottom")},{sel:"#btn-maximize-right",handler:()=>this.toggleMaximize("right")},{sel:"#btn-empty-reset-layout",handler:()=>this.resetLayout()}];for(let{sel:r,handler:c}of n){let u=this.containerEl.querySelector(r);u&&!u.closest("ide-pane")&&u.addEventListener("click",c)}}isPaneMaximized(n){return n?this.containerEl.classList.contains(`maximized-${n}`):this.containerEl.classList.contains("maximized-main")||this.containerEl.classList.contains("maximized-bottom")||this.containerEl.classList.contains("maximized-right")}setMaximizedPane(n,r=!0){let c=["main","bottom","right"];if(n&&!c.includes(n))return!1;let u=r?n:null;for(let d of c){let b=d===u;this.containerEl.classList.toggle(`maximized-${d}`,b),this.panes[d]?.paneComponent?.setMaximized(b);let w=this.containerEl.querySelector(`#btn-maximize-${d}`);w&&(w.textContent=b?"\u29C9":"\u2922",w.title=b?"Restore":"Maximize")}return this.notifyResize(),!!u}maximizePane(n){return this.setMaximizedPane(n,!0)}restoreMaximized(){return this.setMaximizedPane(null,!1)}toggleMaximize(n){return this.setMaximizedPane(n,!this.isPaneMaximized(n))}isPaneCollapsed(n){let r=n==="bottom"?this.centerEl:this.containerEl;return r?r.classList.contains(`hide-${n}`):!1}_setPaneCollapsed(n,r){let c=n==="bottom"?this.centerEl:this.containerEl;if(!c)return;c.classList.toggle(`hide-${n}`,r),this.panes[n]?.paneComponent?.setCollapsed?.(r);let u=this.containerEl.querySelector(`#btn-collapse-${n}`);if(u){let b={bottom:{collapsed:"\u25B2",expanded:"\u25BC"},left:{collapsed:"\u25B6",expanded:"\u25C0"},right:{collapsed:"\u25C0",expanded:"\u25B6"}}[n]||{collapsed:"\u25B6",expanded:"\u25C0"};u.textContent=r?b.collapsed:b.expanded,u.title=r?`Expand ${n.charAt(0).toUpperCase()+n.slice(1)}`:`Collapse ${n.charAt(0).toUpperCase()+n.slice(1)}`}this.saveLayout(),this.notifyResize()}toggleCollapse(n){this._setPaneCollapsed(n,!this.isPaneCollapsed(n))}collapsePane(n){this._setPaneCollapsed(n,!0)}restorePane(n){this._setPaneCollapsed(n,!1)}_updateEmptyState(){let n=this.containerEl.querySelector("#ide-empty-state");if(!n)return;let r=!!this.activeTabs.main;n.style.display=r?"none":"flex"}resetLayout(){try{localStorage.removeItem("or_ide_layout")}catch{}for(let[n,r]of Object.entries(Ihe))this.containerEl.style.setProperty(r.cssVar,r.defaultSize);for(let n of["left","right","bottom"])this.restorePane(n);this.restoreMaximized(),this.closedComponents.clear();for(let n of this.components.values())n.tabEl.style.display="",n.contentDiv.style.display="";this.components.has("DisplayControls")&&this.activateTab("DisplayControls"),this.components.has("LayoutViewer")&&this.activateTab("LayoutViewer"),this.components.has("TclConsole")&&this.activateTab("TclConsole"),this.components.has("Inspector")&&this.activateTab("Inspector"),this._updateEmptyState(),this.saveLayout(),this.notifyResize(),this.emit("stateChanged"),typeof app<"u"&&app.map&&setTimeout(()=>app.map.invalidateSize({animate:!1}),0)}_initResizeObserver(){typeof ResizeObserver<"u"&&new ResizeObserver(()=>{this.notifyResize()}).observe(this.containerEl)}registerComponentFactoryFunction(n,r){this.factories.set(n,r)}loadLayout(n){for(let[c,u]of Object.entries(oxt)){let d=this.factories.get(c);d&&this._mountComponent(c,u.pane,u.title,u.closable,d)}let r=null;try{let c=localStorage.getItem("or_ide_layout");c&&(r=JSON.parse(c))}catch{}if(r){if(r.leftWidth&&this.containerEl.style.setProperty("--pane-left-width",`${r.leftWidth}px`),r.rightWidth&&this.containerEl.style.setProperty("--pane-right-width",`${r.rightWidth}px`),r.bottomHeight&&this.containerEl.style.setProperty("--pane-bottom-height",`${r.bottomHeight}px`),r.closed)for(let c of r.closed)this.closeComponent(c,!1);this.activateTab(r.activeTabs?.left||"DisplayControls"),this.activateTab(r.activeTabs?.main||"LayoutViewer"),this.activateTab(r.activeTabs?.bottom||"TclConsole"),this.activateTab(r.activeTabs?.right||"Inspector"),r.hideLeft&&this.collapsePane("left"),r.hideRight&&this.collapsePane("right"),r.hideBottom&&this.collapsePane("bottom")}else this.activateTab("DisplayControls"),this.activateTab("LayoutViewer"),this.activateTab("TclConsole"),this.activateTab("Inspector");this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}_mountComponent(n,r,c,u,d){if(this.components.has(n))return;let b=this.panes[r];if(!b)return;let w=document.createElement("div");w.className="ide-component-container",w.id=`cmp-${n}`,b.contentEl.appendChild(w);let _=document.createElement("ide-tab");_.id=`tab-${n}`,_.setAttribute("for",n),_.setAttribute("data-component",n),_.setAttribute("title",c),u&&_.setAttribute("closable",""),_.addEventListener("tab-select",()=>{this.activateTab(n)}),_.addEventListener("tab-close",()=>{this.closeComponent(n)}),b.tabsEl.appendChild(_);let x=new Map,T={element:w,get width(){return w.clientWidth},get height(){return w.clientHeight},title:c,on:(L,I)=>{x.has(L)||x.set(L,new Set),x.get(L).add(I)},off:(L,I)=>{x.get(L)?.delete(I)},fire:(L,...I)=>{let D=x.get(L);if(D)for(let F of D)try{F(...I)}catch(O){console.error(O)}},focus:()=>this.focusComponent(n),close:()=>this.closeComponent(n)},M={componentType:n,paneName:r,title:c,closable:u,tabEl:_,contentDiv:w,container:T};this.components.set(n,M);try{d(T)}catch(L){console.error(`Failed to initialize component ${n}:`,L)}}isComponentActive(n){return n?!!n.contentDiv?.classList.contains("active"):!1}_setComponentActive(n,r){if(!n)return;let c=!!r;n.tabEl?.setActive(c),n.contentDiv?.classList.toggle("active",c)}activateTab(n){let r=this.components.get(n);if(!r||!this.panes[r.paneName])return;["left","right","bottom"].includes(r.paneName)&&this.isPaneCollapsed(r.paneName)&&this.restorePane(r.paneName);let u=this.activeTabs[r.paneName];if(u&&u!==n){let d=this.components.get(u);d&&(this._setComponentActive(d,!1),d.container.fire("hide"))}this.activeTabs[r.paneName]=n,r.tabEl.style.display="",r.contentDiv.style.display="",this._setComponentActive(r,!0),this.closedComponents.delete(n),r.container.fire("show"),r.container.fire("open"),r.container.fire("resize"),typeof app<"u"&&(n==="LayoutViewer"&&app.map&&setTimeout(()=>app.map.invalidateSize({animate:!1}),0),n==="3DViewer"&&app.threeDViewerWidget&&setTimeout(()=>app.threeDViewerWidget.onOpen(),0));try{r.tabEl.scrollIntoView({behavior:"smooth",inline:"nearest",block:"nearest"})}catch{}this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}closeComponent(n,r=!0){let c=this.components.get(n);if(!(!c||!c.closable)){if(c.tabEl.style.display="none",c.contentDiv.style.display="none",this._setComponentActive(c,!1),c.container.fire("hide"),this.closedComponents.add(n),r&&this.activeTabs[c.paneName]===n){let u=null;for(let d of this.components.values())if(d.paneName===c.paneName&&!this.closedComponents.has(d.componentType)){u=d;break}u?this.activateTab(u.componentType):(this.activeTabs[c.paneName]=null,["left","right","bottom"].includes(c.paneName)&&this.collapsePane(c.paneName))}this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}}focusComponent(n){if(!this.components.get(n)){let c=this.factories.get(n);if(c){let u=oxt[n]||{pane:"right",title:n,closable:!0};this._mountComponent(n,u.pane,u.title,u.closable,c)}else return}this.activateTab(n)}saveLayout(){let n={leftWidth:parseInt(this.containerEl.style.getPropertyValue("--pane-left-width")||"240",10),rightWidth:parseInt(this.containerEl.style.getPropertyValue("--pane-right-width")||"340",10),bottomHeight:parseInt(this.containerEl.style.getPropertyValue("--pane-bottom-height")||"220",10),hideLeft:this.isPaneCollapsed("left"),hideRight:this.isPaneCollapsed("right"),hideBottom:this.isPaneCollapsed("bottom"),activeTabs:{...this.activeTabs},closed:Array.from(this.closedComponents)};try{localStorage.setItem("or_ide_layout",JSON.stringify(n))}catch{}return n}notifyResize(){if(this._resizeScheduled)return;this._resizeScheduled=!0,(typeof requestAnimationFrame=="function"?requestAnimationFrame:r=>{r()})(()=>{this._resizeScheduled=!1;for(let r of this.components.values())this.isComponentActive(r)&&r.container.fire("resize");typeof app<"u"&&app&&app.map&&app.map.invalidateSize({animate:!1}),window.dispatchEvent(new Event("resize"))})}updateSize(){this.notifyResize()}setSize(n,r){this.notifyResize()}addComponent(n,r,c){this.focusComponent(n)}get rootItem(){return{contentItems:Array.from(this.components.keys()).map(n=>({isComponent:!0,componentType:n,focus:()=>this.focusComponent(n)}))}}};function Lv(s,n,r,c=0,u=0){return[(s-c)*r,(n-u)*r]}function kv(s,n,r,c=0,u=0){return{dbuX:Math.round(c+s/r),dbuY:Math.round(u+n/r)}}function X1(s,n,r,c,u,d=0,b=0){let[w,_]=Lv(s,n,u,d,b),[x,T]=Lv(r,c,u,d,b);return[Math.min(w,x),Math.min(_,T),Math.max(w,x),Math.max(_,T)]}var ZW=class s{constructor(n,r){this.url=n,this.socket=null,this.nextId=1,this.pending=new Map,this._queue=new Map,this._bgQueue=new Map,this._bgSent=new Set,this._inFlight=0,this._inFlightIds=new Set,this._unknownPayloadTypes=new Set,this._maxInFlight=48,this._lastRecvAt=0,this._bufStuckSince=0,this._lastBuffered=0,this.reconnectDelay=1e3,this.readyPromise=null,this.readyResolve=null,this.onStatusChange=r||(()=>{}),this.onPush=null,this._cache=null,this._isConnected=!1,this._shutdown=!1,this._livenessTimer=void 0,this._startLivenessMonitor(),this.connect()}get isConnected(){return this._isConnected||this.socket&&this.socket.readyState===WebSocket.OPEN}get pendingCount(){return this.pending.size-this._bgSent.size+(this._queue?this._queue.size:0)}static fromCache(n,r){let c=Object.create(s.prototype);return c.url=null,c.socket=null,c.nextId=1,c.pending=new Map,c._queue=new Map,c._bgQueue=new Map,c._bgSent=new Set,c._inFlight=0,c._inFlightIds=new Set,c._unknownPayloadTypes=new Set,c._maxInFlight=48,c._lastRecvAt=0,c.reconnectDelay=0,c.onStatusChange=r||(()=>{}),c.onPush=null,c._cache=n,c._isConnected=!0,c.readyPromise=Promise.resolve(),c.readyResolve=null,c}get isStaticMode(){return!!this._cache}connect(){this.readyPromise=new Promise(n=>{this.readyResolve=n}),this.socket=new WebSocket(this.url),this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{console.log("WebSocket connected");let n=this._everConnected===!0;this._everConnected=!0,this._isConnected=!0,this.reconnectDelay=1e3,this._lastRecvAt=typeof performance<"u"?performance.now():0,this.readyResolve(),this.onStatusChange(),this._pump(),n&&this.onReconnected&&this.onReconnected()},this.socket.onmessage=n=>{this.handleMessage(n.data)},this.socket.onclose=()=>this._handleClose(),this.socket.onerror=n=>{console.error("WebSocket error:",n)}}_handleClose(){this._isConnected=!1,this._inFlight=0,this._inFlightIds.clear(),this._bufStuckSince=0,this.onStatusChange();for(let[n,r]of this.pending)r.reject(new Error("WebSocket closed"));this.pending.clear(),this._bgSent.clear();for(let n of[this._queue,this._bgQueue]){for(let[r,c]of n)c.reject(new Error("WebSocket closed"));n.clear()}if(this._shutdown){console.log("WebSocket closed (server stopped)"),this._stopLivenessMonitor();return}console.log("WebSocket closed, reconnecting..."),setTimeout(()=>this.connect(),this.reconnectDelay),this.reconnectDelay=Math.min(this.reconnectDelay*2,3e4)}_forceReconnect(){let n=this.socket;if(this.socket=null,n){n.onopen=null,n.onmessage=null,n.onclose=null,n.onerror=null;try{n.close()}catch{}}this._handleClose()}handleMessage(n){let r=new DataView(n),c=r.getUint32(0),u=r.getUint8(4);if(this._lastRecvAt=typeof performance<"u"?performance.now():0,c===0&&u===0){let w=n.slice(8),_;try{_=JSON.parse(new TextDecoder().decode(w))}catch(x){console.error("Failed to parse server push JSON:",x);return}if(_&&_.type==="config"){Number.isFinite(_.max_in_flight)&&(this._maxInFlight=Math.max(1,Math.min(4096,Math.floor(_.max_in_flight))),this._pump());return}this.onPush&&this.onPush(_);return}this._inFlightIds.delete(c)&&this._inFlight>0&&this._inFlight--;let d=this.pending.get(c);if(!d){this._pump();return}this.pending.delete(c),this._bgSent.delete(c),this._pump(),this.onStatusChange();let b=n.slice(8);if(u===2)d.reject(new Error(new TextDecoder().decode(b)));else if(u===0)try{d.resolve(JSON.parse(new TextDecoder().decode(b)))}catch(w){d.reject(new Error("JSON parse error: "+w.message))}else u===1?d.resolve(new Blob([b],{type:"image/png"})):u===3?d.resolve(null):(this._unknownPayloadTypes.has(u)||(this._unknownPayloadTypes.add(u),console.warn(`Unrecognized websocket payload type ${u}. The server is likely newer than this page \u2014 reload to pick up the current client.`)),d.reject(new Error(`Unsupported websocket payload type ${u}`)))}request(n,{background:r=!1}={}){if(this._cache)return this._cacheRequest(n);let c=this.nextId++;if(n.id=c,!this.socket||this.socket.readyState!==WebSocket.OPEN)return Promise.reject(new Error("WebSocket not connected"));let u,d,b=new Promise((w,_)=>{u=w,d=_});return b.requestId=c,(r?this._bgQueue:this._queue).set(c,{msg:n,resolve:u,reject:d}),this._pump(),b}_pump(){if(!(!this.socket||this.socket.readyState!==WebSocket.OPEN)){for(;this._inFlight0||this._bgQueue.size>0)&&this.socket.bufferedAmount<524288;){let n=this._queue.size===0,r=n?this._bgQueue:this._queue,[c,u]=r.entries().next().value;r.delete(c),this.pending.set(c,{resolve:u.resolve,reject:u.reject}),n&&this._bgSent.add(c),this.socket.send(JSON.stringify(u.msg)),this._inFlightIds.add(c),this._inFlight++}this.onStatusChange()}}promote(n){let r=this._bgQueue.get(n);r?(this._bgQueue.delete(n),this._queue.set(n,r),this._pump()):this._bgSent.delete(n)&&this.onStatusChange()}cancel(n){let r=this._queue.get(n)||this._bgQueue.get(n);if(r){this._queue.delete(n),this._bgQueue.delete(n),r.reject(new Error("Request cancelled")),this.onStatusChange();return}let c=this.pending.get(n),u=this.pending.delete(n);this._bgSent.delete(n),c&&c.reject(new Error("Request cancelled")),u&&!this._cache&&this.socket&&this.socket.readyState===WebSocket.OPEN&&this.socket.send(JSON.stringify({type:"cancel",cancel_id:n,id:this.nextId++})),this.onStatusChange()}_startLivenessMonitor(){typeof setInterval>"u"||(this._livenessTimer=setInterval(()=>this._checkLiveness(),3e3),this._livenessTimer&&typeof this._livenessTimer.unref=="function"&&this._livenessTimer.unref())}_stopLivenessMonitor(){this._livenessTimer!==void 0&&typeof clearInterval<"u"&&(clearInterval(this._livenessTimer),this._livenessTimer=void 0)}_checkLiveness(){if(this._cache)return;let n=this.socket;if(!n||n.readyState!==WebSocket.OPEN){this._bufStuckSince=0,this._lastBuffered=0;return}let r=n.bufferedAmount,c=typeof performance<"u"?performance.now():0,u=!1,d="";r<=262144||r12e3&&(u=!0,d=`send buffer stuck at ${r}B for ${Math.round(c-this._bufStuckSince)}ms`),this._lastBuffered=r,!u&&this._inFlight>=this._maxInFlight&&this._queue.size+this._bgQueue.size>0&&this._lastRecvAt>0&&c-this._lastRecvAt>3e4&&(u=!0,d=`saturated (${this._inFlight} in flight, ${this._queue.size} queued) but silent for ${Math.round(c-this._lastRecvAt)}ms`),u&&(console.warn(`WebSocket connection wedged \u2014 ${d}; reconnecting to recover`),this._bufStuckSince=0,this._forceReconnect())}_cacheRequest(n){let r=n.type;if(r==="tile"){let d=n.layer+"/"+n.z+"/"+n.x+"/"+n.y,b=this._cache.tiles&&this._cache.tiles[d];return b?Promise.resolve("data:image/png;base64,"+b):Promise.reject(new Error("Tile not cached: "+d))}if(r==="timing_highlight"){let d=n.path_index;if(d>=0&&this._cache.overlays){let b=n.is_setup?"setup":"hold",w=this._cache.overlays[b]?.[d];this._cache.setPathOverlay&&this._cache.setPathOverlay(w?"data:image/png;base64,"+w:null)}else this._cache.setPathOverlay&&this._cache.setPathOverlay(null);return Promise.resolve({})}if(r==="set_module_colors")return Promise.resolve({ok:1,count:0});let c=r;r==="timing_report"?c="timing_report:"+(n.is_setup?"setup":"hold"):r==="slack_histogram"&&(c="slack_histogram:"+(n.is_setup?"setup":"hold"));let u=this._cache.json&&this._cache.json[c];if(u!==void 0){if(r==="timing_report"&&n.slack_min!=null&&n.slack_max!=null&&u.paths){let d=[];return u.paths.forEach((b,w)=>{b.slack>=n.slack_min&&b.slackb||w>_?null:{z:n,x0:d,x1:b,y0:w,y1:_}}function R5e([s,n,r,c],u){let d=(r-s)*u,b=(c-n)*u;return[s-d,n-b,r+d,c+b]}function Fhe(s,n=1){if(!s)return null;let r=Math.pow(2,s.z);return{z:s.z,x0:Math.max(0,s.x0-n),x1:Math.min(r-1,s.x1+n),y0:Math.max(0,s.y0-n),y1:Math.min(r-1,s.y1+n)}}function Am(s,n,r){return!!s&&n>=s.x0&&n<=s.x1&&r>=s.y0&&r<=s.y1}function JW(s){if(!s)return[];let n=(s.x0+s.x1)/2,r=(s.y0+s.y1)/2,c=[];for(let u=s.y0;u<=s.y1;u++)for(let d=s.x0;d<=s.x1;d++)c.push({z:s.z,x:d,y:u,d:(d-n)**2+(u-r)**2});return c.sort((u,d)=>u.d-d.d),c.map(({z:u,x:d,y:b})=>({z:u,x:d,y:b}))}function cxt(s,n,r,c){let u=c/Math.pow(2,s);return[n*u,c-(r+1)*u,(n+1)*u,c-r*u]}function I5e(s,n){return s[0]Math.log2(d/ue);if(D<1e-12){let ue=Math.log(M/T)/r;return{S:Math.abs(ue),at:Te=>({target:[b+Te*L,w+Te*I],zoom:F(T*Math.exp(r*Te*ue))})}}let O=Math.sqrt(D),z=(M*M-T*T+u*D)/(2*T*c*O),Z=(M*M-T*T-u*D)/(2*M*c*O),H=Math.log(Math.sqrt(z*z+1)-z),oe=(Math.log(Math.sqrt(Z*Z+1)-Z)-H)/r,ne=Math.cosh(H);return{S:oe,at:ue=>{if(ue>=1)return{target:[_,x],zoom:n.zoom};let Te=ue*oe,Q=T/(c*O)*(ne*Math.tanh(r*Te+H)-Math.sinh(H));return{target:[b+Q*L,w+Q*I],zoom:F(T*ne/Math.cosh(r*Te+H))}}}}function yO(s,n,r){return`${s}/${n}/${r}`}var Uhe=class{constructor({source:n,onChange:r=()=>{},keepBuffer:c=2}={}){this.source=n,this.onChange=r,this.keepBuffer=c,this.tiles=new Map,this.z=null,this.range=null,this.ring=null,this.extra=[],this._generation=0,this._loads=0,this._cancels=0}update({z:n,range:r,ring:c=r,extra:u=[],hold:d=null}){this.z=n,this.range=r,this.ring=c,this.extra=u.filter(_=>_.z!==n&&_.range);let b=new Map(this.extra.map(_=>[_.z,_]));for(let _ of[...this.tiles.values()]){if(_.z!==n){let x=b.get(_.z),T=x&&x.range;(T?!Am(T,_.x,_.y)&&(_.loading||!this._inKeepBuffer(_,T)):_.loading&&!_.drawable)?this._drop(_):T&&this._stale(_)&&Am(T,_.x,_.y)&&this._load(_,x.background!==!1);continue}if(this._stale(_)&&Am(c,_.x,_.y)&&this._load(_,!Am(r,_.x,_.y)),Am(c,_.x,_.y)){_.loading&&_.background&&Am(r,_.x,_.y)&&(_.background=!1,_.handle?.promote?.());continue}(_.loading||!(this._inKeepBuffer(_)||d&&Am(d,_.x,_.y)))&&this._drop(_)}let w=[...JW(r),...JW(c).filter(_=>!Am(r,_.x,_.y))];for(let{x:_,y:x}of w)this.tiles.has(yO(n,_,x))||this._load(this._newTile(n,_,x),!Am(r,_,x));for(let _ of this.extra)for(let{x,y:T}of JW(_.range))this.tiles.has(yO(_.z,x,T))||this._load(this._newTile(_.z,x,T),_.background!==!1)}refresh(){this._generation++;let n=new Map(this.extra.map(r=>[r.z,r]));for(let r of[...this.tiles.values()]){let c=n.get(r.z),u=r.z===this.z?this.ring:c&&c.range;u&&(Am(u,r.x,r.y)?(r.handle?.cancel?.(),this._load(r,c?c.background!==!1:!Am(this.range,r.x,r.y))):r.loading&&this._drop(r))}}isSettled(){for(let n of this.tiles.values())if(n.z===this.z&&n.loading&&Am(this.range,n.x,n.y))return!1;return!0}settledIn(n,r){for(let{x:c,y:u}of JW(r)){let d=this.tiles.get(yO(n,c,u));if(!d||d.loading)return!1}return!0}hasContentAt(n){for(let r of this.tiles.values())if(r.z===n&&r.drawable)return!0;return!1}drawableTilesAt(n){let r=[];for(let c of this.tiles.values())c.z===n&&c.drawable&&r.push(c);return r}prune(n){let r=new Set(n);for(let c of[...this.tiles.values()])r.has(c.z)||this._drop(c)}clear(){for(let n of[...this.tiles.values()])this._drop(n);this.z=null,this.range=null,this.ring=null,this.extra=[]}stats(){let n=0,r=0;for(let c of this.tiles.values())c.loading&&n++,c.drawable&&r++;return{tiles:this.tiles.size,loading:n,drawable:r,loads:this._loads,cancels:this._cancels}}_newTile(n,r,c){let u={z:n,x:r,y:c,key:yO(n,r,c),drawable:null,loading:!1,background:!1,handle:null,generation:-1};return this.tiles.set(u.key,u),u}_load(n,r){let c=this._generation,u=()=>this.tiles.get(n.key)===n&&n.generation===c;n.generation=c,n.loading=!0,n.background=r,this._loads++;let d=this.source.load({z:n.z,x:n.x,y:n.y},{background:r,onPartial:b=>{if(!u()){this.source.release?.(b);return}this._setDrawable(n,b),this.onChange(n)}});n.handle=d,d.promise.then(b=>{if(!u()){this.source.release?.(b);return}b!==void 0&&this._setDrawable(n,b),n.loading=!1,n.handle=null,this.onChange(n)},()=>{u()&&(n.loading=!1,n.handle=null,this.onChange(n))})}_setDrawable(n,r){n.drawable&&n.drawable!==r&&this.source.release?.(n.drawable),n.drawable=r||null}_stale(n){return!n.loading&&n.generation!==this._generation}_inKeepBuffer(n,r=this.range){return Am(Fhe(r,this.keepBuffer),n.x,n.y)}_drop(n){n.loading&&(this._cancels++,n.handle?.cancel?.()),n.drawable&&this.source.release?.(n.drawable),n.drawable=null,n.loading=!1,this.tiles.delete(n.key)}};function Mhn(s){return!Number.isFinite(s)||s<=1?1:Math.round(Math.min(s,3)*100)/100}var iE=240,Thn=256,D5e=iE;function Fb(){return D5e}function fxt(){D5e=Thn}var eli=1/64,B5e=120;function hxt(s){D5e=s}function O5e(s,n){return Math.max(1,Math.round(s*n))}function xO(){let s=typeof window<"u"&&window.devicePixelRatio?window.devicePixelRatio:1;return!Number.isFinite(s)||s<=1?1:Math.min(s,3)}function zhe(s,n=Fb()){return{dpr:Mhn(s),tile_px:O5e(n,s)}}function dxt(s,n,r,c=Fb()){let{selectability:u,selectableLayers:d,app:b}=n,w={...gxt(s,n,r,c),selectable_layers:d?[...d]:[]};if(u)for(let[_,x]of Object.entries(u))w["s_"+_]=!!x;return _=>{let x={type:"tile",layer:_,...w},T=mxt(b,_);return T!==1&&(x.pattern=T),x}}function pxt(s,n,r,c,u=Fb()){let d={type:"tile_group",layers:[...n],...gxt(s,r,c,u)},b=n.map(w=>mxt(r.app,w));return b.some(w=>w!==1)&&(d.patterns=b),d}function gxt(s,n,r,c){let{visibility:u,visibleLayers:d,app:b}=n,w={z:s.z,x:s.x,y:s.y,...zhe(r,c),visible_layers:d?[...d]:[]};for(let[_,x]of Object.entries(u||{}))w[_]=!!x;return b&&b.visibleChiplets instanceof Set&&(w.visible_chiplets=[...b.visibleChiplets]),w}function mxt(s,n){let r=s&&s.layerPatterns?s.layerPatterns[n]:void 0;return r===void 0?1:r}function bxt(s){if(typeof window>"u"||typeof window.matchMedia!="function"||typeof s!="function")return()=>{};let n=!1,r=null,c=null,u=()=>{if(n)return;let d=window.devicePixelRatio||1;r=window.matchMedia(`(resolution: ${d}dppx)`),c=()=>{n||(u(),s(window.devicePixelRatio||1))},r.addEventListener("change",c,{once:!0})};return u(),()=>{n=!0,r&&c&&r.removeEventListener("change",c),r=null,c=null}}function wxt(s,n){if(!s)return!1;let r=!!n;return!!s.visible===r?!1:(s.visible=r,!0)}function vxt(s,n,r){if(!s||!(r>0))return 0;s.clearRect(0,0,r,r);let c=0;for(let u of n||[]){let d=u?u.image:null;if(!d)continue;let b=u.opacity===void 0?1:u.opacity;b>0&&(s.globalAlpha=Math.min(1,b),s.drawImage(d,0,0,r,r),c++)}return s.globalAlpha=1,c}function N5e(s){for(let n of s||[])n&&typeof n.close=="function"&&n.close()}async function _xt({items:s,request:n,decode:r,draw:c,release:u=N5e,isStale:d=()=>!1,incremental:b=!0}={}){let w=Array.isArray(s)?s:[],_={requested:w.length,arrived:0,decoded:0,drawn:0,paints:0,failed:0,stale:!1};if(w.length===0)return typeof c=="function"&&c([]),_;let x=new Array(w.length).fill(null),T=!1;function M(){if(d()){_.stale=!0;return}_.drawn=c(w.map((L,I)=>({image:x[I],opacity:L.opacity})))||0,_.paints++,T=!0}try{await Promise.all(w.map(async(L,I)=>{let D=null;try{D=await n(L)}catch{_.failed++;return}if(D==null)return;_.arrived++;let F=null;try{F=await r(D)}catch{return}F&&(x[I]=F,_.decoded++,b&&M())})),T||M()}finally{u(x)}return _}var Chn=["tracks_pref","tracks_non_pref","debug","debug_renderers"],Ahn=1/16;function F5e(s,n){if(s==null)return!1;if(!Array.isArray(s)||s.length!==4||!n)return!0;let r=Math.pow(2,n.z),c=Ahn/r,u=n.x/r-c,d=n.y/r-c,b=(n.x+1)/r+c,w=(n.y+1)/r+c,[_,x,T,M]=s;return _<=b&&T>=u&&x<=w&&M>=d}function Phn(s,n,r){let c=s&&Array.isArray(s.by_size)?s.by_size:[];if(c.length===0||!n||!(r>0))return!0;let u=s.min_css_px/(r*Math.pow(2,n.z)),d=c[0];for(let b of c)b[0]<=u&&(d=b);return F5e(d[1],n)}var Ghe=class{constructor(){this._layers=null,this._gated=new Map,this._sized=new Map,this._generation=0}invalidate(){return this._generation++,this._layers=null,this._gated=new Map,this._sized=new Map,this._generation}apply(n,r){if(n!==this._generation)return!1;if(!r||r.supported!==!0||!r.layers||typeof r.layers!="object")return this._layers=null,!1;let c=new Map;if(r.gated&&typeof r.gated=="object")for(let[u,d]of Object.entries(r.gated))d&&typeof d=="object"&&c.set(u,new Map(Object.entries(d)));return this._layers=new Map(Object.entries(r.layers)),this._gated=c,this._sized=new Map(r.sized&&typeof r.sized=="object"?Object.entries(r.sized):[]),!0}refetch(n){let r=this.invalidate();return Promise.resolve().then(()=>n({type:"layer_extents"})).then(c=>this.apply(r,c)).catch(()=>!1)}mayHaveContent(n,r,c,u=256){if(!this._layers||c&&Chn.some(d=>c[d]))return!0;if(this._sized.has(n))return Phn(this._sized.get(n),r,u);if(!this._layers.has(n)||F5e(this._layers.get(n),r))return!0;for(let[d,b]of this._gated)if(!(c&&c[d]===!1)&&b.has(n)&&F5e(b.get(n),r))return!0;return!1}};function yxt(s,n,r){let c=s&&s.app&&s.app.layerExtents;return c?c.mayHaveContent(n,r,s.visibility,Fb()):!0}function xxt(s){return s==null?Promise.resolve(null):typeof s=="string"?new Promise(n=>{let r=document.createElement("img");r.onload=()=>n(r),r.onerror=()=>n(null),r.src=s}):createImageBitmap(s,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).catch(()=>null)}function U5e(s){N5e([s&&s.image])}function Lhn(s){return{width:s.naturalWidth||s.width,height:s.naturalHeight||s.height}}function jhe(s){return s?{image:s,...Lhn(s)}:null}function khn(s){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(s,s);let n=document.createElement("canvas");return n.width=s,n.height=s,n}function z5e(s){let n=document.createElement("canvas");return n.width=s.width,n.height=s.height,n.getContext("2d").drawImage(s,0,0),n}function Rhn(s){return typeof s.transferToImageBitmap=="function"?jhe(s.transferToImageBitmap()):jhe(z5e(s))}var Ext=Object.freeze({promise:Promise.resolve(null),cancel(){},promote(){}});function Sxt(s,n,r,c){let u=s.request(r,{background:c});return u.requestId!=null&&n.push(u.requestId),u}function Mxt(s,n,r,c){return{promise:r,cancel(){c();for(let u of n)s.cancel(u)},promote(){for(let u of n)s.promote?.(u)}}}var Txt=3;function Ihn(s,n){let r=new Map,c=0,u=0;for(let d of s)if(!(!d||r.has(d.layer))){if(d.layer.startsWith("_")){r.set(d.layer,null),c++,u=0;continue}r.set(d.layer,`${c}:${Math.floor(u++/n)}`)}return r}function Dhn(s,n,r,c,u,d,b,w){let _=Ihn(s,r),x=[],T=null,M=()=>{T&&(x.push({opacity:1,msg:pxt(u,T.layers,d,b,w)}),T=null)};for(let L of n){let I=_.get(L.layer);if(I==null){M(),x.push({opacity:1,msg:c(L.layer)});continue}T&&T.id!==I&&M(),T=T||{id:I,layers:[]},T.layers.push(L.layer)}return M(),x}function Cxt({wm:s,ctx:n,getItems:r,dpr:c=()=>1,tileSize:u=()=>240,isDoubleBuffer:d=()=>!0,decode:b=xxt,makeCanvas:w=khn,snapshot:_=Rhn,groupLayers:x=()=>0}){return{load({z:T,x:M,y:L},{background:I=!1,onPartial:D}={}){let F=r()||[],O=F.filter(tt=>tt&&tt.visible!==!1&&yxt(n,tt.layer,{z:T,x:M,y:L})),z=c(),Z=u(),H=new Set,te=O.filter(tt=>!H.has(tt.layer)&&H.add(tt.layer));if(te.length===0)return Ext;let oe=dxt({z:T,x:M,y:L},n,z,Z),ne=x(),ue=ne>0&&te.every(tt=>(tt.opacity??1)===1)?Dhn(F,te,ne,oe,{z:T,x:M,y:L},n,z,Z):te.map(tt=>({opacity:tt.opacity,msg:oe(tt.layer)})),Te=O5e(Z,z),Q=null,ge=null,Qe=[],st=!1,at=!d()&&typeof D=="function",Ne=_xt({items:ue,request:tt=>Sxt(s,Qe,tt.msg,I),decode:b,draw:tt=>{if(!Q){if(!tt.some(Tt=>Tt.image))return 0;Q=w(Te),ge=Q.getContext("2d")}let ot=vxt(ge,tt,Te);return at&&ot>0&&!st&&D(_(Q)),ot},isStale:()=>st,incremental:at}).then(tt=>{if(st)throw new Error("Tile cancelled");if(tt.failed===tt.requested)throw new Error("Tile requests failed");return tt.drawn===0?null:at?void 0:_(Q)});return Mxt(s,Qe,Ne,()=>{st=!0})},release:U5e}}function G5e({wm:s,buildRequest:n,dpr:r=()=>1,tileSize:c=()=>240,decode:u=xxt}){return{load({z:d,x:b,y:w},{background:_=!1}={}){let x=n({z:d,x:b,y:w},r(),c());if(!x)return Ext;let T=[],M=!1,L=Sxt(s,T,x,_).then(I=>u(I)).then(I=>{if(M)throw U5e(jhe(I)),new Error("Tile cancelled");return jhe(I)});return Mxt(s,T,L,()=>{M=!0})},release:U5e}}function Axt({z:s,x:n,y:r},c,u,d,b){let w={type:"overlay_tile",z:s,x:n,y:r,...zhe(c,u),debug_renderers:!!d.debug_renderers,debug_live:!!d.debug_live,flywires_only:!!d.flywires_only,poly_decomp:!!(b&&b.polyDecomp),focused_nets_guides:!!d.focused_nets_guides,highlight_selected:d.highlight_selected!==!1,draw_labels:d.labels!==!1};return b&&b.visibleLayerNames&&(w.visible_layers=[...b.visibleLayerNames]),w}function Pxt({z:s,x:n,y:r},c,u,d){let b=d&&d.activeHeatMap;return b?{type:"heatmap_tile",name:b,z:s,x:n,y:r,...zhe(c,u)}:null}function ua(s){return!!s?.websocketManager?.isStaticMode}function Ixt(s,n){let r={};for(let[c,u]of Object.entries(s||{}))r[c]=!!u;for(let[c,u]of Object.entries(n||{}))r["s_"+c]=!!u;return r}function EO(s,n){n&&typeof n.sel_has_inst=="boolean"&&(s.selHasInst=n.sel_has_inst,s.selHasNet=!!n.sel_has_net)}var j5e=null;function Y1(s,n=4e3){let r=document.getElementById("or-toast");return r||(r=document.createElement("div"),r.id="or-toast",document.body.appendChild(r)),r.textContent=s,r.classList.add("visible"),j5e&&clearTimeout(j5e),j5e=setTimeout(()=>r.classList.remove("visible"),n),r}function Dxt(s){return!s||s.gpuType!=="cpu"?null:"Software rendering detected (reduced performance). Make sure 'Use graphics acceleration when available' (or 'Use hardware acceleration when available') is turned on in your browser settings, then restart the browser."}function Bxt({title:s,message:n,confirmLabel:r="OK",danger:c=!1}){return new Promise(u=>{let d=document.createElement("div");d.className="or-modal-overlay";let b=document.createElement("div");b.className="or-modal";let w=document.createElement("div");w.className="or-modal-title",w.textContent=s;let _=document.createElement("div");_.className="or-modal-message",_.textContent=n;let x=document.createElement("div");x.className="or-modal-buttons";let T=document.createElement("button");T.className="or-btn",T.textContent="Cancel";let M=document.createElement("button");M.className="or-btn"+(c?" or-btn-danger":""),M.textContent=r;let L=D=>{document.removeEventListener("keydown",I,!0),d.remove(),u(D)},I=D=>{D.key==="Escape"&&(D.stopPropagation(),L(!1))};T.addEventListener("click",()=>L(!1)),M.addEventListener("click",()=>L(!0)),d.addEventListener("click",D=>{D.target===d&&L(!1)}),document.addEventListener("keydown",I,!0),x.appendChild(T),x.appendChild(M),b.appendChild(w),b.appendChild(_),b.appendChild(x),d.appendChild(b),document.body.appendChild(d),T.focus()})}var Bhn=.05;function Ohn([[s,n],[r,c]],u){let d=(c-n)*u,b=(r-s)*u;return[[s-b,n-d],[r+b,c+d]]}function $5e(s,n=256,r=null){if(!Lxt(s))return null;let c=s[0][0],u=s[0][1],d=Math.max(s[1][1]-u,s[1][0]-c),b=n/d,w=Lxt(r)?r:s,[[_,x],[T,M]]=Ohn(w,Bhn);return{scale:b,maxDXDY:d,originX:u,originY:c,fitRect:X1(x,_,M,T,b,u,c)}}function Lxt(s){return!!s&&s[1][0]>s[0][0]&&s[1][1]>s[0][1]}function Oxt(s,n){return!!s&&!!n&&s[0][0]===n[0][0]&&s[0][1]===n[0][1]&&s[1][0]===n[1][0]&&s[1][1]===n[1][1]}function Pm(s){s.selectionToken=(s.selectionToken||0)+1;for(let n of s.selectionResetters||[])n();return s.selectionToken}function Z1(s,n){return s.selectionToken===n}function Nxt(s,n){s.selectionResetters||(s.selectionResetters=[]),s.selectionResetters.push(n)}var V5e=80,QW=10,eH=1e3;function tH(s){let n=s===""||s===null?NaN:Math.round(Number(s));return Number.isFinite(n)?Math.min(eH,Math.max(QW,n)):V5e}function sk(s="vis-group-header"){let n=document.createElement("div");n.className=s;let r=document.createElement("span");r.className="vis-arrow",n.appendChild(r);let c=document.createElement("span");return c.className="vis-name",n.appendChild(c),{header:n,arrow:r,name:c}}function ok(s,n,r,c){let u=d=>{r.classList.toggle("collapsed",d),n.textContent=d?"\u25B6":"\u25BC"};u(!!c),s.addEventListener("click",d=>{let b=d.target&&d.target.parentNode===s&&d.target.classList&&d.target.classList.contains("vis-name");d.target!==s&&d.target!==n&&!b||u(!r.classList.contains("collapsed"))})}var kxt=30;function Fxt(s,n=8){if(!Number.isFinite(s)||s<=0)return kxt;let r=Math.ceil(Math.log2(n/s));return Math.max(1,Math.min(kxt,r))}function Uxt({designBounds:s,fitRect:n,viewW:r,viewH:c}){let u=$5e(s,iE,n),d=I=>Number.isFinite(I)&&I>0;if(!u||!d(r)||!d(c))return iE;let b=u.fitRect[2]-u.fitRect[0],w=u.fitRect[3]-u.fitRect[1],_=Math.min(r/b,c/w),x=Math.log2(_);if(!Number.isFinite(x)||x<0)return iE;let T=Math.floor(x),M=iE*2**(x-T),L=Math.floor(M/B5e)*B5e;return L>iE&&Math.log2(iE*_/L)>=T?L:iE}function zxt(s,{showDbu:n,dbuPerMicron:r},c=!1){if(n)return String(Math.round(s));let u=r>0?r:1e3,d=Math.ceil(Math.log10(u)),b=(s/u).toFixed(d);return c?b+" \xB5m":b}function Gxt(s,{showDbu:n,dbuPerMicron:r}){let c=parseFloat(s);if(!Number.isFinite(c))return null;if(n)return Math.round(c);let u=r>0?r:1e3;return Math.round(c*u)}function jxt(s,{showDbu:n,dbuPerMicron:r}){if(n)return String(Math.round(s));let c=r>0?r:1e3,u=s/c;return u>=1e3?(u/1e3).toFixed(3)+" mm":u>=1?u.toFixed(3)+" um":(u*1e3).toFixed(1)+" nm"}function $xt({showDbu:s}){return s?"DBU":"\xB5m"}function SO(s){return typeof s=="string"&&/^#[0-9a-fA-F]{6}$/.test(s)}function Vxt(s){if(typeof s!="string")return null;let n=s.trim();if(SO(n))return n.toLowerCase();let r=n.match(/^#([0-9a-fA-F]{3})$/);if(r)return"#"+r[1].split("").map(u=>u+u).join("").toLowerCase();let c=n.match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/);if(c){let u=c.slice(1).map(Number);return u.some(d=>d>255)?null:"#"+u.map(d=>d.toString(16).padStart(2,"0")).join("")}return null}function yT(s,n=r=>requestAnimationFrame(r)){let r=!1;return()=>{r||(r=!0,n(()=>{r=!1,s()}))}}function nH(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function Rxt(s){let n=Math.pow(10,Math.floor(Math.log10(s))),r=s/n,c;return r<1.5?c=1:r<3.5?c=2:r<7.5?c=5:c=10,{value:c*n,digit:c}}function Wxt({targetPx:s,pxPerDbu:n,dbuPerMicron:r,showDbu:c}){if(!Number.isFinite(n)||n<=0||!Number.isFinite(s)||s<=0)return null;let u,d,b;if(c){let _=Rxt(Math.max(1,s/n));b=_.digit,u=Math.round(_.value*n),d=String(Math.round(_.value))}else{let _=Number.isFinite(r)&&r>0?r:1e3,x=n*_,T=Rxt(s/x);b=T.digit;let M=T.value;u=Math.round(M*x);let L,I;M>=1e3?(L=1/1e3,I="mm"):M>=1?(L=1,I="\xB5m"):M>=.001?(L=1e3,I="nm"):(L=1e6,I="pm"),d=Math.round(M*L)+" "+I}return{barPx:u,label:d,segments:b===1?5:b}}function iH(s,n,r){return n?typeof s.runTclScript=="function"?s.runTclScript(n,r):(r&&typeof s.echoTcl=="function"&&s.echoTcl(n),s.websocketManager.request({type:"tcl_eval",cmd:n}).catch(()=>{})):Promise.resolve()}function ak(s,n){let r=s.querySelectorAll("thead th");(!n||!n[0])&&(s.style.tableLayout="auto",r.forEach(c=>c.style.width=""),n=Array.from(r,c=>c.offsetWidth+"px")),r.forEach((c,u)=>c.style.width=n[u]||""),s.style.tableLayout="fixed",r.forEach((c,u)=>{if(u===r.length-1)return;let d=document.createElement("div");d.className="col-resize-grip",c.style.position="relative",c.appendChild(d);let b,w,_=T=>{c.style.width=Math.max(30,w+T.clientX-b)+"px"},x=()=>{document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",x);let T=M=>M.stopPropagation();document.addEventListener("click",T,{capture:!0,once:!0}),setTimeout(()=>{document.removeEventListener("click",T,{capture:!0})},0)};d.addEventListener("mousedown",T=>{T.preventDefault(),b=T.clientX,w=c.offsetWidth,document.addEventListener("mousemove",_),document.addEventListener("mouseup",x)})})}var Nhn={Layout:'',Schematic:'',"3D Viewer":'',"Display Controls":'',Inspector:'',Hierarchy:'',Timing:'',DRC:'',"Select Highlight":'',"Clock Tree":'',Charts:'',"Tcl Console":'',Help:''};function Fhn(s){let n=Nhn[s];if(!n)return null;let r=document.createElement("span");return r.className="or-tab-icon",r.innerHTML='",r}function Hxt(s=document){let n=0;for(let r of s.querySelectorAll(".lm_tab:not([data-or-icon])")){let c=r.querySelector(".lm_title");if(!c)continue;let u=c.textContent.trim();if(!u)continue;r.setAttribute("data-or-icon","");let d=Fhn(u);d&&(r.insertBefore(d,c),n++)}return n}function MO(s,n,r,c){let u=document.createElement("div");u.className="modal-overlay",u.innerHTML=` + `}};customElements.get("ide-pane")||customElements.define("ide-pane",A5e);customElements.get("ide-splitter")||customElements.define("ide-splitter",Dhe);customElements.get("ide-tab")||customElements.define("ide-tab",L5e);var oxt={DisplayControls:{pane:"left",title:"Display Controls",closable:!1},LayoutViewer:{pane:"main",title:"Layout",closable:!1},SchematicWidget:{pane:"main",title:"Schematic",closable:!0},"3DViewer":{pane:"main",title:"3D Viewer",closable:!0},TclConsole:{pane:"bottom",title:"Tcl Console",closable:!1},Inspector:{pane:"right",title:"Inspector",closable:!0},Browser:{pane:"right",title:"Hierarchy",closable:!0},TimingWidget:{pane:"right",title:"Timing",closable:!0},DRCWidget:{pane:"right",title:"DRC",closable:!0},SelectHighlight:{pane:"right",title:"Select Highlight",closable:!0},ClockWidget:{pane:"right",title:"Clock Tree",closable:!0},ChartsWidget:{pane:"right",title:"Charts",closable:!0},HelpWidget:{pane:"right",title:"Help",closable:!0}},Ihe={left:{cssVar:"--pane-left-width",defaultSize:"240px",minSize:140,maxFraction:.45,dimension:"width",isVertical:!0,invertDelta:!1},right:{cssVar:"--pane-right-width",defaultSize:"340px",minSize:160,maxFraction:.5,dimension:"width",isVertical:!0,invertDelta:!0},bottom:{cssVar:"--pane-bottom-height",defaultSize:"220px",minSize:70,maxFraction:.75,dimension:"height",isVertical:!1,invertDelta:!0}},Bhe=class{constructor(n){this.containerEl=n,this.factories=new Map,this.components=new Map,this.activeTabs={left:null,main:null,bottom:null,right:null},this.closedComponents=new Set,this.eventListeners=new Map,this._resizeScheduled=!1,this._ensureDOM(),this._initSplitters(),this._initControls(),this._initResizeObserver()}on(n,r){this.eventListeners.has(n)||this.eventListeners.set(n,new Set),this.eventListeners.get(n).add(r)}off(n,r){this.eventListeners.get(n)?.delete(r)}emit(n,...r){let c=this.eventListeners.get(n);if(c)for(let u of c)try{u(...r)}catch(d){console.error(d)}}_ensureDOM(){this.containerEl.classList.add("ide-layout"),this.containerEl.querySelector("#pane-left")||this._buildInitialLayoutTree(),this._resolvePaneReferences()}_buildInitialLayoutTree(){this.containerEl.appendChild(this._createGutterButton("left","\u25B6 Display Controls","Restore Display Controls")),this.containerEl.appendChild(this._createGutterButton("right","\u25C0 Tools & Inspector","Restore Right Panel")),this.containerEl.appendChild(this._createPane("pane-left","left")),this.containerEl.appendChild(this._createSplitter("splitter-left","left","vertical","Drag to resize panel"));let n=document.createElement("main");n.id="pane-center",n.className="ide-center",n.appendChild(this._createPane("pane-main","main",{maximizable:!0})),n.appendChild(this._createSplitter("splitter-bottom","bottom","horizontal","Drag to resize console")),n.appendChild(this._createGutterButton("bottom","\u25B2 Tcl Console","Restore Tcl Console")),n.appendChild(this._createPane("pane-bottom","bottom",{maximizable:!0,collapsible:!0})),this.containerEl.appendChild(n),this.containerEl.appendChild(this._createSplitter("splitter-right","right","vertical","Drag to resize panel")),this.containerEl.appendChild(this._createPane("pane-right","right",{maximizable:!0,collapsible:!0}))}_createGutterButton(n,r,c){let u=document.createElement("button");u.id=`gutter-expand-${n}`,u.className=`ide-gutter-expand ide-gutter-${n}`,u.title=c;let d=document.createElement("span");return d.textContent=r,u.appendChild(d),u}_createPane(n,r,c={}){let u=document.createElement("ide-pane");return u.id=n,u.setAttribute("name",r),c.maximizable&&u.setAttribute("maximizable",""),c.collapsible&&u.setAttribute("collapsible",""),u}_createSplitter(n,r,c,u){let d=document.createElement("ide-splitter");return d.id=n,d.setAttribute("for",r),d.setAttribute("orientation",c),d.title=u,d}_resolvePaneReferences(){let n=["left","main","bottom","right"];this.panes={};for(let r of n){let c=this.containerEl.querySelector(`#pane-${r}`);c?.build&&c.build(),this.panes[r]={el:c,paneComponent:c,tabsEl:c?.tabsEl||this.containerEl.querySelector(`#pane-${r}-tabs`),contentEl:c?.contentEl||this.containerEl.querySelector(`#pane-${r}-content`)}}this.centerEl=this.containerEl.querySelector("#pane-center")}_initSplitters(){let n=null;this.containerEl.addEventListener("ide-splitter-start",r=>{let c=r.detail?.for,u=Ihe[c];if(!u)return;let b=(c==="bottom"?this.centerEl||this.containerEl:this.containerEl).getBoundingClientRect(),w=this.panes[c]?.el?.getBoundingClientRect()||{},_=u.dimension==="width"?b.width:b.height,x=u.dimension==="width"?w.width||240:w.height||220;n={paneName:c,cfg:u,startSize:x,maxLimit:Math.round(_*u.maxFraction)||500}}),this.containerEl.addEventListener("ide-splitter-drag",r=>{if(!n||n.paneName!==r.detail?.for)return;let{cfg:c,startSize:u,maxLimit:d}=n,b=c.invertDelta?-r.detail.delta:r.detail.delta,w=Math.round(u+b),_=Math.max(c.minSize,Math.min(d,w));this.containerEl.style.setProperty(c.cssVar,`${_}px`),this.notifyResize()}),this.containerEl.addEventListener("ide-splitter-end",()=>{n=null,this.saveLayout(),this.notifyResize()}),this.containerEl.addEventListener("ide-splitter-reset",r=>{let c=r.detail?.for;this._resetSplitterPane(c)}),this._setupFallbackSplitters()}_resetSplitterPane(n){let r=Ihe[n];r&&(this.containerEl.style.setProperty(r.cssVar,r.defaultSize),this.isPaneCollapsed(n)?this.restorePane(n):(this.saveLayout(),this.notifyResize()))}_setupFallbackSplitters(){for(let[n,r]of Object.entries(Ihe)){let c=this.containerEl.querySelector(`#splitter-${n}`);if(!c||c instanceof Dhe)continue;let u=!r.invertDelta,d=r.isVertical;c.addEventListener("pointerdown",b=>{b.preventDefault();try{c.setPointerCapture(b.pointerId)}catch{}c.classList.add("dragging"),document.body&&document.body.classList.add("is-resizing",d?"is-resizing-v":"is-resizing-h");let w=d?b.clientX:b.clientY,x=(n==="bottom"?this.centerEl||this.containerEl:this.containerEl).getBoundingClientRect(),T=this.panes[n]?.el?.getBoundingClientRect()||{},M=r.dimension==="width"?T.width||240:T.height||220,L=r.dimension==="width"?x.width:x.height,I=Math.round(L*r.maxFraction)||500,D=new AbortController,{signal:F}=D,O=Z=>{let H=d?Z.clientX:Z.clientY,te=u?H-w:w-H,oe=Math.round(M+te),ne=Math.max(r.minSize,Math.min(I,oe));this.containerEl.style.setProperty(r.cssVar,`${ne}px`),this.notifyResize()},z=Z=>{try{c.releasePointerCapture(Z.pointerId)}catch{}c.classList.remove("dragging"),document.body&&document.body.classList.remove("is-resizing","is-resizing-v","is-resizing-h"),D.abort(),this.saveLayout(),this.notifyResize()};window.addEventListener("pointermove",O,{signal:F}),window.addEventListener("pointerup",z,{signal:F}),window.addEventListener("pointercancel",z,{signal:F})}),c.addEventListener("dblclick",()=>{this._resetSplitterPane(n)})}}_initControls(){this.containerEl.addEventListener("ide-pane-maximize",r=>{this.toggleMaximize(r.detail?.pane)}),this.containerEl.addEventListener("ide-pane-collapse",r=>{this.toggleCollapse(r.detail?.pane)}),this.containerEl.addEventListener("ide-layout-reset",()=>{this.resetLayout()});for(let r of["left","right","bottom"]){let c=this.containerEl.querySelector(`#gutter-expand-${r}`);c&&c.addEventListener("click",()=>this.restorePane(r))}let n=[{sel:"#btn-collapse-left",handler:()=>this.toggleCollapse("left")},{sel:"#btn-collapse-right",handler:()=>this.toggleCollapse("right")},{sel:"#btn-collapse-bottom",handler:()=>this.toggleCollapse("bottom")},{sel:"#btn-maximize-main",handler:()=>this.toggleMaximize("main")},{sel:"#btn-maximize-bottom",handler:()=>this.toggleMaximize("bottom")},{sel:"#btn-maximize-right",handler:()=>this.toggleMaximize("right")},{sel:"#btn-empty-reset-layout",handler:()=>this.resetLayout()}];for(let{sel:r,handler:c}of n){let u=this.containerEl.querySelector(r);u&&!u.closest("ide-pane")&&u.addEventListener("click",c)}}isPaneMaximized(n){return n?this.containerEl.classList.contains(`maximized-${n}`):this.containerEl.classList.contains("maximized-main")||this.containerEl.classList.contains("maximized-bottom")||this.containerEl.classList.contains("maximized-right")}setMaximizedPane(n,r=!0){let c=["main","bottom","right"];if(n&&!c.includes(n))return!1;let u=r?n:null;for(let d of c){let b=d===u;this.containerEl.classList.toggle(`maximized-${d}`,b),this.panes[d]?.paneComponent?.setMaximized(b);let w=this.containerEl.querySelector(`#btn-maximize-${d}`);w&&(w.textContent=b?"\u29C9":"\u2922",w.title=b?"Restore":"Maximize")}return this.notifyResize(),!!u}maximizePane(n){return this.setMaximizedPane(n,!0)}restoreMaximized(){return this.setMaximizedPane(null,!1)}toggleMaximize(n){return this.setMaximizedPane(n,!this.isPaneMaximized(n))}isPaneCollapsed(n){let r=n==="bottom"?this.centerEl:this.containerEl;return r?r.classList.contains(`hide-${n}`):!1}_setPaneCollapsed(n,r){let c=n==="bottom"?this.centerEl:this.containerEl;if(!c)return;c.classList.toggle(`hide-${n}`,r),this.panes[n]?.paneComponent?.setCollapsed?.(r);let u=this.containerEl.querySelector(`#btn-collapse-${n}`);if(u){let b={bottom:{collapsed:"\u25B2",expanded:"\u25BC"},left:{collapsed:"\u25B6",expanded:"\u25C0"},right:{collapsed:"\u25C0",expanded:"\u25B6"}}[n]||{collapsed:"\u25B6",expanded:"\u25C0"};u.textContent=r?b.collapsed:b.expanded,u.title=r?`Expand ${n.charAt(0).toUpperCase()+n.slice(1)}`:`Collapse ${n.charAt(0).toUpperCase()+n.slice(1)}`}this.saveLayout(),this.notifyResize()}toggleCollapse(n){this._setPaneCollapsed(n,!this.isPaneCollapsed(n))}collapsePane(n){this._setPaneCollapsed(n,!0)}restorePane(n){this._setPaneCollapsed(n,!1)}_updateEmptyState(){let n=this.containerEl.querySelector("#ide-empty-state");if(!n)return;let r=!!this.activeTabs.main;n.style.display=r?"none":"flex"}resetLayout(){try{localStorage.removeItem("or_ide_layout")}catch{}for(let[n,r]of Object.entries(Ihe))this.containerEl.style.setProperty(r.cssVar,r.defaultSize);for(let n of["left","right","bottom"])this.restorePane(n);this.restoreMaximized(),this.closedComponents.clear();for(let n of this.components.values())n.tabEl.style.display="",n.contentDiv.style.display="";this.components.has("DisplayControls")&&this.activateTab("DisplayControls"),this.components.has("LayoutViewer")&&this.activateTab("LayoutViewer"),this.components.has("TclConsole")&&this.activateTab("TclConsole"),this.components.has("Inspector")&&this.activateTab("Inspector"),this._updateEmptyState(),this.saveLayout(),this.notifyResize(),this.emit("stateChanged"),typeof app<"u"&&app.map&&setTimeout(()=>app.map.invalidateSize({animate:!1}),0)}_initResizeObserver(){typeof ResizeObserver<"u"&&new ResizeObserver(()=>{this.notifyResize()}).observe(this.containerEl)}registerComponentFactoryFunction(n,r){this.factories.set(n,r)}loadLayout(n){for(let[c,u]of Object.entries(oxt)){let d=this.factories.get(c);d&&this._mountComponent(c,u.pane,u.title,u.closable,d)}let r=null;try{let c=localStorage.getItem("or_ide_layout");c&&(r=JSON.parse(c))}catch{}if(r){if(r.leftWidth&&this.containerEl.style.setProperty("--pane-left-width",`${r.leftWidth}px`),r.rightWidth&&this.containerEl.style.setProperty("--pane-right-width",`${r.rightWidth}px`),r.bottomHeight&&this.containerEl.style.setProperty("--pane-bottom-height",`${r.bottomHeight}px`),r.closed)for(let c of r.closed)this.closeComponent(c,!1);this.activateTab(r.activeTabs?.left||"DisplayControls"),this.activateTab(r.activeTabs?.main||"LayoutViewer"),this.activateTab(r.activeTabs?.bottom||"TclConsole"),this.activateTab(r.activeTabs?.right||"Inspector"),r.hideLeft&&this.collapsePane("left"),r.hideRight&&this.collapsePane("right"),r.hideBottom&&this.collapsePane("bottom")}else this.activateTab("DisplayControls"),this.activateTab("LayoutViewer"),this.activateTab("TclConsole"),this.activateTab("Inspector");this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}_mountComponent(n,r,c,u,d){if(this.components.has(n))return;let b=this.panes[r];if(!b)return;let w=document.createElement("div");w.className="ide-component-container",w.id=`cmp-${n}`,b.contentEl.appendChild(w);let _=document.createElement("ide-tab");_.id=`tab-${n}`,_.setAttribute("for",n),_.setAttribute("data-component",n),_.setAttribute("title",c),u&&_.setAttribute("closable",""),_.addEventListener("tab-select",()=>{this.activateTab(n)}),_.addEventListener("tab-close",()=>{this.closeComponent(n)}),b.tabsEl.appendChild(_);let x=new Map,T={element:w,get width(){return w.clientWidth},get height(){return w.clientHeight},title:c,on:(L,I)=>{x.has(L)||x.set(L,new Set),x.get(L).add(I)},off:(L,I)=>{x.get(L)?.delete(I)},fire:(L,...I)=>{let D=x.get(L);if(D)for(let F of D)try{F(...I)}catch(O){console.error(O)}},focus:()=>this.focusComponent(n),close:()=>this.closeComponent(n)},M={componentType:n,paneName:r,title:c,closable:u,tabEl:_,contentDiv:w,container:T};this.components.set(n,M);try{d(T)}catch(L){console.error(`Failed to initialize component ${n}:`,L)}}isComponentActive(n){return n?!!n.contentDiv?.classList.contains("active"):!1}_setComponentActive(n,r){if(!n)return;let c=!!r;n.tabEl?.setActive(c),n.contentDiv?.classList.toggle("active",c)}activateTab(n){let r=this.components.get(n);if(!r||!this.panes[r.paneName])return;["left","right","bottom"].includes(r.paneName)&&this.isPaneCollapsed(r.paneName)&&this.restorePane(r.paneName);let u=this.activeTabs[r.paneName];if(u&&u!==n){let d=this.components.get(u);d&&(this._setComponentActive(d,!1),d.container.fire("hide"))}this.activeTabs[r.paneName]=n,r.tabEl.style.display="",r.contentDiv.style.display="",this._setComponentActive(r,!0),this.closedComponents.delete(n),r.container.fire("show"),r.container.fire("open"),r.container.fire("resize"),typeof app<"u"&&(n==="LayoutViewer"&&app.map&&setTimeout(()=>app.map.invalidateSize({animate:!1}),0),n==="3DViewer"&&app.threeDViewerWidget&&setTimeout(()=>app.threeDViewerWidget.onOpen(),0));try{r.tabEl.scrollIntoView({behavior:"smooth",inline:"nearest",block:"nearest"})}catch{}this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}closeComponent(n,r=!0){let c=this.components.get(n);if(!(!c||!c.closable)){if(c.tabEl.style.display="none",c.contentDiv.style.display="none",this._setComponentActive(c,!1),c.container.fire("hide"),this.closedComponents.add(n),r&&this.activeTabs[c.paneName]===n){let u=null;for(let d of this.components.values())if(d.paneName===c.paneName&&!this.closedComponents.has(d.componentType)){u=d;break}u?this.activateTab(u.componentType):(this.activeTabs[c.paneName]=null,["left","right","bottom"].includes(c.paneName)&&this.collapsePane(c.paneName))}this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}}focusComponent(n){if(!this.components.get(n)){let c=this.factories.get(n);if(c){let u=oxt[n]||{pane:"right",title:n,closable:!0};this._mountComponent(n,u.pane,u.title,u.closable,c)}else return}this.activateTab(n)}saveLayout(){let n={leftWidth:parseInt(this.containerEl.style.getPropertyValue("--pane-left-width")||"240",10),rightWidth:parseInt(this.containerEl.style.getPropertyValue("--pane-right-width")||"340",10),bottomHeight:parseInt(this.containerEl.style.getPropertyValue("--pane-bottom-height")||"220",10),hideLeft:this.isPaneCollapsed("left"),hideRight:this.isPaneCollapsed("right"),hideBottom:this.isPaneCollapsed("bottom"),activeTabs:{...this.activeTabs},closed:Array.from(this.closedComponents)};try{localStorage.setItem("or_ide_layout",JSON.stringify(n))}catch{}return n}notifyResize(){if(this._resizeScheduled)return;this._resizeScheduled=!0,(typeof requestAnimationFrame=="function"?requestAnimationFrame:r=>{r()})(()=>{this._resizeScheduled=!1;for(let r of this.components.values())this.isComponentActive(r)&&r.container.fire("resize");typeof app<"u"&&app&&app.map&&app.map.invalidateSize({animate:!1}),window.dispatchEvent(new Event("resize"))})}updateSize(){this.notifyResize()}setSize(n,r){this.notifyResize()}addComponent(n,r,c){this.focusComponent(n)}get rootItem(){return{contentItems:Array.from(this.components.keys()).map(n=>({isComponent:!0,componentType:n,focus:()=>this.focusComponent(n)}))}}};function Lv(s,n,r,c=0,u=0){return[(s-c)*r,(n-u)*r]}function kv(s,n,r,c=0,u=0){return{dbuX:Math.round(c+s/r),dbuY:Math.round(u+n/r)}}function X1(s,n,r,c,u,d=0,b=0){let[w,_]=Lv(s,n,u,d,b),[x,T]=Lv(r,c,u,d,b);return[Math.min(w,x),Math.min(_,T),Math.max(w,x),Math.max(_,T)]}var ZW=class s{constructor(n,r){this.url=n,this.socket=null,this.nextId=1,this.pending=new Map,this._queue=new Map,this._bgQueue=new Map,this._bgSent=new Set,this._inFlight=0,this._inFlightIds=new Set,this._unknownPayloadTypes=new Set,this._maxInFlight=48,this._lastRecvAt=0,this._bufStuckSince=0,this._lastBuffered=0,this.reconnectDelay=1e3,this.readyPromise=null,this.readyResolve=null,this.onStatusChange=r||(()=>{}),this.onPush=null,this._cache=null,this._isConnected=!1,this._shutdown=!1,this._livenessTimer=void 0,this._startLivenessMonitor(),this.connect()}get isConnected(){return this._isConnected||this.socket&&this.socket.readyState===WebSocket.OPEN}get pendingCount(){return this.pending.size-this._bgSent.size+(this._queue?this._queue.size:0)}static fromCache(n,r){let c=Object.create(s.prototype);return c.url=null,c.socket=null,c.nextId=1,c.pending=new Map,c._queue=new Map,c._bgQueue=new Map,c._bgSent=new Set,c._inFlight=0,c._inFlightIds=new Set,c._unknownPayloadTypes=new Set,c._maxInFlight=48,c._lastRecvAt=0,c.reconnectDelay=0,c.onStatusChange=r||(()=>{}),c.onPush=null,c._cache=n,c._isConnected=!0,c.readyPromise=Promise.resolve(),c.readyResolve=null,c}get isStaticMode(){return!!this._cache}connect(){this.readyPromise=new Promise(n=>{this.readyResolve=n}),this.socket=new WebSocket(this.url),this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{console.log("WebSocket connected");let n=this._everConnected===!0;this._everConnected=!0,this._isConnected=!0,this.reconnectDelay=1e3,this._lastRecvAt=typeof performance<"u"?performance.now():0,this.readyResolve(),this.onStatusChange(),this._pump(),n&&this.onReconnected&&this.onReconnected()},this.socket.onmessage=n=>{this.handleMessage(n.data)},this.socket.onclose=()=>this._handleClose(),this.socket.onerror=n=>{console.error("WebSocket error:",n)}}_handleClose(){this._isConnected=!1,this._inFlight=0,this._inFlightIds.clear(),this._bufStuckSince=0,this.onStatusChange();for(let[n,r]of this.pending)r.reject(new Error("WebSocket closed"));this.pending.clear(),this._bgSent.clear();for(let n of[this._queue,this._bgQueue]){for(let[r,c]of n)c.reject(new Error("WebSocket closed"));n.clear()}if(this._shutdown){console.log("WebSocket closed (server stopped)"),this._stopLivenessMonitor();return}console.log("WebSocket closed, reconnecting..."),setTimeout(()=>this.connect(),this.reconnectDelay),this.reconnectDelay=Math.min(this.reconnectDelay*2,3e4)}_forceReconnect(){let n=this.socket;if(this.socket=null,n){n.onopen=null,n.onmessage=null,n.onclose=null,n.onerror=null;try{n.close()}catch{}}this._handleClose()}handleMessage(n){let r=new DataView(n),c=r.getUint32(0),u=r.getUint8(4);if(this._lastRecvAt=typeof performance<"u"?performance.now():0,c===0&&u===0){let w=n.slice(8),_;try{_=JSON.parse(new TextDecoder().decode(w))}catch(x){console.error("Failed to parse server push JSON:",x);return}if(_&&_.type==="config"){Number.isFinite(_.max_in_flight)&&(this._maxInFlight=Math.max(1,Math.min(4096,Math.floor(_.max_in_flight))),this._pump());return}this.onPush&&this.onPush(_);return}this._inFlightIds.delete(c)&&this._inFlight>0&&this._inFlight--;let d=this.pending.get(c);if(!d){this._pump();return}this.pending.delete(c),this._bgSent.delete(c),this._pump(),this.onStatusChange();let b=n.slice(8);if(u===2)d.reject(new Error(new TextDecoder().decode(b)));else if(u===0)try{d.resolve(JSON.parse(new TextDecoder().decode(b)))}catch(w){d.reject(new Error("JSON parse error: "+w.message))}else u===1?d.resolve(new Blob([b],{type:"image/png"})):u===3?d.resolve(null):(this._unknownPayloadTypes.has(u)||(this._unknownPayloadTypes.add(u),console.warn(`Unrecognized websocket payload type ${u}. The server is likely newer than this page \u2014 reload to pick up the current client.`)),d.reject(new Error(`Unsupported websocket payload type ${u}`)))}request(n,{background:r=!1}={}){if(this._cache)return this._cacheRequest(n);let c=this.nextId++;if(n.id=c,!this.socket||this.socket.readyState!==WebSocket.OPEN)return Promise.reject(new Error("WebSocket not connected"));let u,d,b=new Promise((w,_)=>{u=w,d=_});return b.requestId=c,(r?this._bgQueue:this._queue).set(c,{msg:n,resolve:u,reject:d}),this._pump(),b}_pump(){if(!(!this.socket||this.socket.readyState!==WebSocket.OPEN)){for(;this._inFlight0||this._bgQueue.size>0)&&this.socket.bufferedAmount<524288;){let n=this._queue.size===0,r=n?this._bgQueue:this._queue,[c,u]=r.entries().next().value;r.delete(c),this.pending.set(c,{resolve:u.resolve,reject:u.reject}),n&&this._bgSent.add(c),this.socket.send(JSON.stringify(u.msg)),this._inFlightIds.add(c),this._inFlight++}this.onStatusChange()}}promote(n){let r=this._bgQueue.get(n);r?(this._bgQueue.delete(n),this._queue.set(n,r),this._pump()):this._bgSent.delete(n)&&this.onStatusChange()}cancel(n){let r=this._queue.get(n)||this._bgQueue.get(n);if(r){this._queue.delete(n),this._bgQueue.delete(n),r.reject(new Error("Request cancelled")),this.onStatusChange();return}let c=this.pending.get(n),u=this.pending.delete(n);this._bgSent.delete(n),c&&c.reject(new Error("Request cancelled")),u&&!this._cache&&this.socket&&this.socket.readyState===WebSocket.OPEN&&this.socket.send(JSON.stringify({type:"cancel",cancel_id:n,id:this.nextId++})),this.onStatusChange()}_startLivenessMonitor(){typeof setInterval>"u"||(this._livenessTimer=setInterval(()=>this._checkLiveness(),3e3),this._livenessTimer&&typeof this._livenessTimer.unref=="function"&&this._livenessTimer.unref())}_stopLivenessMonitor(){this._livenessTimer!==void 0&&typeof clearInterval<"u"&&(clearInterval(this._livenessTimer),this._livenessTimer=void 0)}_checkLiveness(){if(this._cache)return;let n=this.socket;if(!n||n.readyState!==WebSocket.OPEN){this._bufStuckSince=0,this._lastBuffered=0;return}let r=n.bufferedAmount,c=typeof performance<"u"?performance.now():0,u=!1,d="";r<=262144||r12e3&&(u=!0,d=`send buffer stuck at ${r}B for ${Math.round(c-this._bufStuckSince)}ms`),this._lastBuffered=r,!u&&this._inFlight>=this._maxInFlight&&this._queue.size+this._bgQueue.size>0&&this._lastRecvAt>0&&c-this._lastRecvAt>3e4&&(u=!0,d=`saturated (${this._inFlight} in flight, ${this._queue.size} queued) but silent for ${Math.round(c-this._lastRecvAt)}ms`),u&&(console.warn(`WebSocket connection wedged \u2014 ${d}; reconnecting to recover`),this._bufStuckSince=0,this._forceReconnect())}_cacheRequest(n){let r=n.type;if(r==="tile"){let d=n.layer+"/"+n.z+"/"+n.x+"/"+n.y,b=this._cache.tiles&&this._cache.tiles[d];return b?Promise.resolve("data:image/png;base64,"+b):Promise.reject(new Error("Tile not cached: "+d))}if(r==="timing_highlight"){let d=n.path_index;if(d>=0&&this._cache.overlays){let b=n.is_setup?"setup":"hold",w=this._cache.overlays[b]?.[d];this._cache.setPathOverlay&&this._cache.setPathOverlay(w?"data:image/png;base64,"+w:null)}else this._cache.setPathOverlay&&this._cache.setPathOverlay(null);return Promise.resolve({})}if(r==="set_module_colors")return Promise.resolve({ok:1,count:0});let c=r;r==="timing_report"?c="timing_report:"+(n.is_setup?"setup":"hold"):r==="slack_histogram"&&(c="slack_histogram:"+(n.is_setup?"setup":"hold"));let u=this._cache.json&&this._cache.json[c];if(u!==void 0){if(r==="timing_report"&&n.slack_min!=null&&n.slack_max!=null&&u.paths){let d=[];return u.paths.forEach((b,w)=>{b.slack>=n.slack_min&&b.slackb||w>_?null:{z:n,x0:d,x1:b,y0:w,y1:_}}function R5e([s,n,r,c],u){let d=(r-s)*u,b=(c-n)*u;return[s-d,n-b,r+d,c+b]}function Fhe(s,n=1){if(!s)return null;let r=Math.pow(2,s.z);return{z:s.z,x0:Math.max(0,s.x0-n),x1:Math.min(r-1,s.x1+n),y0:Math.max(0,s.y0-n),y1:Math.min(r-1,s.y1+n)}}function Am(s,n,r){return!!s&&n>=s.x0&&n<=s.x1&&r>=s.y0&&r<=s.y1}function JW(s){if(!s)return[];let n=(s.x0+s.x1)/2,r=(s.y0+s.y1)/2,c=[];for(let u=s.y0;u<=s.y1;u++)for(let d=s.x0;d<=s.x1;d++)c.push({z:s.z,x:d,y:u,d:(d-n)**2+(u-r)**2});return c.sort((u,d)=>u.d-d.d),c.map(({z:u,x:d,y:b})=>({z:u,x:d,y:b}))}function cxt(s,n,r,c){let u=c/Math.pow(2,s);return[n*u,c-(r+1)*u,(n+1)*u,c-r*u]}function I5e(s,n){return s[0]Math.log2(d/ue);if(D<1e-12){let ue=Math.log(M/T)/r;return{S:Math.abs(ue),at:Te=>({target:[b+Te*L,w+Te*I],zoom:F(T*Math.exp(r*Te*ue))})}}let O=Math.sqrt(D),z=(M*M-T*T+u*D)/(2*T*c*O),Z=(M*M-T*T-u*D)/(2*M*c*O),H=Math.log(Math.sqrt(z*z+1)-z),oe=(Math.log(Math.sqrt(Z*Z+1)-Z)-H)/r,ne=Math.cosh(H);return{S:oe,at:ue=>{if(ue>=1)return{target:[_,x],zoom:n.zoom};let Te=ue*oe,Q=T/(c*O)*(ne*Math.tanh(r*Te+H)-Math.sinh(H));return{target:[b+Q*L,w+Q*I],zoom:F(T*ne/Math.cosh(r*Te+H))}}}}function yO(s,n,r){return`${s}/${n}/${r}`}var Uhe=class{constructor({source:n,onChange:r=()=>{},keepBuffer:c=2}={}){this.source=n,this.onChange=r,this.keepBuffer=c,this.tiles=new Map,this.z=null,this.range=null,this.ring=null,this.extra=[],this._generation=0,this._loads=0,this._cancels=0}update({z:n,range:r,ring:c=r,extra:u=[],hold:d=null}){this.z=n,this.range=r,this.ring=c,this.extra=u.filter(_=>_.z!==n&&_.range);let b=new Map(this.extra.map(_=>[_.z,_]));for(let _ of[...this.tiles.values()]){if(_.z!==n){let x=b.get(_.z),T=x&&x.range;(T?!Am(T,_.x,_.y)&&(_.loading||!this._inKeepBuffer(_,T)):_.loading&&!_.drawable)?this._drop(_):T&&this._stale(_)&&Am(T,_.x,_.y)&&this._load(_,x.background!==!1);continue}if(this._stale(_)&&Am(c,_.x,_.y)&&this._load(_,!Am(r,_.x,_.y)),Am(c,_.x,_.y)){_.loading&&_.background&&Am(r,_.x,_.y)&&(_.background=!1,_.handle?.promote?.());continue}(_.loading||!(this._inKeepBuffer(_)||d&&Am(d,_.x,_.y)))&&this._drop(_)}let w=[...JW(r),...JW(c).filter(_=>!Am(r,_.x,_.y))];for(let{x:_,y:x}of w)this.tiles.has(yO(n,_,x))||this._load(this._newTile(n,_,x),!Am(r,_,x));for(let _ of this.extra)for(let{x,y:T}of JW(_.range))this.tiles.has(yO(_.z,x,T))||this._load(this._newTile(_.z,x,T),_.background!==!1)}refresh(){this._generation++;let n=new Map(this.extra.map(r=>[r.z,r]));for(let r of[...this.tiles.values()]){let c=n.get(r.z),u=r.z===this.z?this.ring:c&&c.range;u&&(Am(u,r.x,r.y)?(r.handle?.cancel?.(),this._load(r,c?c.background!==!1:!Am(this.range,r.x,r.y))):r.loading&&this._drop(r))}}isSettled(){for(let n of this.tiles.values())if(n.z===this.z&&n.loading&&Am(this.range,n.x,n.y))return!1;return!0}settledIn(n,r){for(let{x:c,y:u}of JW(r)){let d=this.tiles.get(yO(n,c,u));if(!d||d.loading)return!1}return!0}hasContentAt(n){for(let r of this.tiles.values())if(r.z===n&&r.drawable)return!0;return!1}drawableTilesAt(n){let r=[];for(let c of this.tiles.values())c.z===n&&c.drawable&&r.push(c);return r}prune(n){let r=new Set(n);for(let c of[...this.tiles.values()])r.has(c.z)||this._drop(c)}clear(){for(let n of[...this.tiles.values()])this._drop(n);this.z=null,this.range=null,this.ring=null,this.extra=[]}stats(){let n=0,r=0;for(let c of this.tiles.values())c.loading&&n++,c.drawable&&r++;return{tiles:this.tiles.size,loading:n,drawable:r,loads:this._loads,cancels:this._cancels}}_newTile(n,r,c){let u={z:n,x:r,y:c,key:yO(n,r,c),drawable:null,loading:!1,background:!1,handle:null,generation:-1};return this.tiles.set(u.key,u),u}_load(n,r){let c=this._generation,u=()=>this.tiles.get(n.key)===n&&n.generation===c;n.generation=c,n.loading=!0,n.background=r,this._loads++;let d=this.source.load({z:n.z,x:n.x,y:n.y},{background:r,onPartial:b=>{if(!u()){this.source.release?.(b);return}this._setDrawable(n,b),this.onChange(n)}});n.handle=d,d.promise.then(b=>{if(!u()){this.source.release?.(b);return}b!==void 0&&this._setDrawable(n,b),n.loading=!1,n.handle=null,this.onChange(n)},()=>{u()&&(n.loading=!1,n.handle=null,this.onChange(n))})}_setDrawable(n,r){n.drawable&&n.drawable!==r&&this.source.release?.(n.drawable),n.drawable=r||null}_stale(n){return!n.loading&&n.generation!==this._generation}_inKeepBuffer(n,r=this.range){return Am(Fhe(r,this.keepBuffer),n.x,n.y)}_drop(n){n.loading&&(this._cancels++,n.handle?.cancel?.()),n.drawable&&this.source.release?.(n.drawable),n.drawable=null,n.loading=!1,this.tiles.delete(n.key)}};function Ahn(s){return!Number.isFinite(s)||s<=1?1:Math.round(Math.min(s,3)*100)/100}var iE=240,Phn=256,D5e=iE;function Nb(){return D5e}function fxt(){D5e=Phn}var rli=1/64,B5e=120;function hxt(s){D5e=s}function O5e(s,n){return Math.max(1,Math.round(s*n))}function xO(){let s=typeof window<"u"&&window.devicePixelRatio?window.devicePixelRatio:1;return!Number.isFinite(s)||s<=1?1:Math.min(s,3)}function zhe(s,n=Nb()){return{dpr:Ahn(s),tile_px:O5e(n,s)}}function dxt(s,n,r,c=Nb()){let{selectability:u,selectableLayers:d,app:b}=n,w={...gxt(s,n,r,c),selectable_layers:d?[...d]:[]};if(u)for(let[_,x]of Object.entries(u))w["s_"+_]=!!x;return _=>{let x={type:"tile",layer:_,...w},T=mxt(b,_);return T!==1&&(x.pattern=T),x}}function pxt(s,n,r,c,u=Nb()){let d={type:"tile_group",layers:[...n],...gxt(s,r,c,u)},b=n.map(w=>mxt(r.app,w));return b.some(w=>w!==1)&&(d.patterns=b),d}function gxt(s,n,r,c){let{visibility:u,visibleLayers:d,app:b}=n,w={z:s.z,x:s.x,y:s.y,...zhe(r,c),visible_layers:d?[...d]:[]};for(let[_,x]of Object.entries(u||{}))w[_]=!!x;return b&&b.visibleChiplets instanceof Set&&(w.visible_chiplets=[...b.visibleChiplets]),w}function mxt(s,n){let r=s&&s.layerPatterns?s.layerPatterns[n]:void 0;return r===void 0?1:r}function bxt(s){if(typeof window>"u"||typeof window.matchMedia!="function"||typeof s!="function")return()=>{};let n=!1,r=null,c=null,u=()=>{if(n)return;let d=window.devicePixelRatio||1;r=window.matchMedia(`(resolution: ${d}dppx)`),c=()=>{n||(u(),s(window.devicePixelRatio||1))},r.addEventListener("change",c,{once:!0})};return u(),()=>{n=!0,r&&c&&r.removeEventListener("change",c),r=null,c=null}}function wxt(s,n){if(!s)return!1;let r=!!n;return!!s.visible===r?!1:(s.visible=r,!0)}function vxt(s,n,r){if(!s||!(r>0))return 0;s.clearRect(0,0,r,r);let c=0;for(let u of n||[]){let d=u?u.image:null;if(!d)continue;let b=u.opacity===void 0?1:u.opacity;b>0&&(s.globalAlpha=Math.min(1,b),s.drawImage(d,0,0,r,r),c++)}return s.globalAlpha=1,c}function N5e(s){for(let n of s||[])n&&typeof n.close=="function"&&n.close()}async function _xt({items:s,request:n,decode:r,draw:c,release:u=N5e,isStale:d=()=>!1,incremental:b=!0}={}){let w=Array.isArray(s)?s:[],_={requested:w.length,arrived:0,decoded:0,drawn:0,paints:0,failed:0,stale:!1};if(w.length===0)return typeof c=="function"&&c([]),_;let x=new Array(w.length).fill(null),T=!1;function M(){if(d()){_.stale=!0;return}_.drawn=c(w.map((L,I)=>({image:x[I],opacity:L.opacity})))||0,_.paints++,T=!0}try{await Promise.all(w.map(async(L,I)=>{let D=null;try{D=await n(L)}catch{_.failed++;return}if(D==null)return;_.arrived++;let F=null;try{F=await r(D)}catch{return}F&&(x[I]=F,_.decoded++,b&&M())})),T||M()}finally{u(x)}return _}var Lhn=["tracks_pref","tracks_non_pref","debug","debug_renderers"],khn=1/16;function F5e(s,n){if(s==null)return!1;if(!Array.isArray(s)||s.length!==4||!n)return!0;let r=Math.pow(2,n.z),c=khn/r,u=n.x/r-c,d=n.y/r-c,b=(n.x+1)/r+c,w=(n.y+1)/r+c,[_,x,T,M]=s;return _<=b&&T>=u&&x<=w&&M>=d}function Rhn(s,n,r){let c=s&&Array.isArray(s.by_size)?s.by_size:[];if(c.length===0||!n||!(r>0))return!0;let u=s.min_css_px/(r*Math.pow(2,n.z)),d=c[0];for(let b of c)b[0]<=u&&(d=b);return F5e(d[1],n)}var Ghe=class{constructor(){this._layers=null,this._gated=new Map,this._sized=new Map,this._generation=0}invalidate(){return this._generation++,this._layers=null,this._gated=new Map,this._sized=new Map,this._generation}apply(n,r){if(n!==this._generation)return!1;if(!r||r.supported!==!0||!r.layers||typeof r.layers!="object")return this._layers=null,!1;let c=new Map;if(r.gated&&typeof r.gated=="object")for(let[u,d]of Object.entries(r.gated))d&&typeof d=="object"&&c.set(u,new Map(Object.entries(d)));return this._layers=new Map(Object.entries(r.layers)),this._gated=c,this._sized=new Map(r.sized&&typeof r.sized=="object"?Object.entries(r.sized):[]),!0}refetch(n){let r=this.invalidate();return Promise.resolve().then(()=>n({type:"layer_extents"})).then(c=>this.apply(r,c)).catch(()=>!1)}mayHaveContent(n,r,c,u=256){if(!this._layers||c&&Lhn.some(d=>c[d]))return!0;if(this._sized.has(n))return Rhn(this._sized.get(n),r,u);if(!this._layers.has(n)||F5e(this._layers.get(n),r))return!0;for(let[d,b]of this._gated)if(!(c&&c[d]===!1)&&b.has(n)&&F5e(b.get(n),r))return!0;return!1}};function yxt(s,n,r){let c=s&&s.app&&s.app.layerExtents;return c?c.mayHaveContent(n,r,s.visibility,Nb()):!0}function xxt(s){return s==null?Promise.resolve(null):typeof s=="string"?new Promise(n=>{let r=document.createElement("img");r.onload=()=>n(r),r.onerror=()=>n(null),r.src=s}):createImageBitmap(s,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).catch(()=>null)}function U5e(s){N5e([s&&s.image])}function Ihn(s){return{width:s.naturalWidth||s.width,height:s.naturalHeight||s.height}}function jhe(s){return s?{image:s,...Ihn(s)}:null}function Dhn(s){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(s,s);let n=document.createElement("canvas");return n.width=s,n.height=s,n}function z5e(s){let n=document.createElement("canvas");return n.width=s.width,n.height=s.height,n.getContext("2d").drawImage(s,0,0),n}function Bhn(s){return typeof s.transferToImageBitmap=="function"?jhe(s.transferToImageBitmap()):jhe(z5e(s))}var Ext=Object.freeze({promise:Promise.resolve(null),cancel(){},promote(){}});function Sxt(s,n,r,c){let u=s.request(r,{background:c});return u.requestId!=null&&n.push(u.requestId),u}function Mxt(s,n,r,c){return{promise:r,cancel(){c();for(let u of n)s.cancel(u)},promote(){for(let u of n)s.promote?.(u)}}}var Txt=3;function Ohn(s,n){let r=new Map,c=0,u=0;for(let d of s)if(!(!d||r.has(d.layer))){if(d.layer.startsWith("_")){r.set(d.layer,null),c++,u=0;continue}r.set(d.layer,`${c}:${Math.floor(u++/n)}`)}return r}function Nhn(s,n,r,c,u,d,b,w){let _=Ohn(s,r),x=[],T=null,M=()=>{T&&(x.push({opacity:1,msg:pxt(u,T.layers,d,b,w)}),T=null)};for(let L of n){let I=_.get(L.layer);if(I==null){M(),x.push({opacity:1,msg:c(L.layer)});continue}T&&T.id!==I&&M(),T=T||{id:I,layers:[]},T.layers.push(L.layer)}return M(),x}function Cxt({wm:s,ctx:n,getItems:r,dpr:c=()=>1,tileSize:u=()=>240,isDoubleBuffer:d=()=>!0,decode:b=xxt,makeCanvas:w=Dhn,snapshot:_=Bhn,groupLayers:x=()=>0}){return{load({z:T,x:M,y:L},{background:I=!1,onPartial:D}={}){let F=r()||[],O=F.filter(tt=>tt&&tt.visible!==!1&&yxt(n,tt.layer,{z:T,x:M,y:L})),z=c(),Z=u(),H=new Set,te=O.filter(tt=>!H.has(tt.layer)&&H.add(tt.layer));if(te.length===0)return Ext;let oe=dxt({z:T,x:M,y:L},n,z,Z),ne=x(),ue=ne>0&&te.every(tt=>(tt.opacity??1)===1)?Nhn(F,te,ne,oe,{z:T,x:M,y:L},n,z,Z):te.map(tt=>({opacity:tt.opacity,msg:oe(tt.layer)})),Te=O5e(Z,z),Q=null,ge=null,Qe=[],st=!1,at=!d()&&typeof D=="function",Ne=_xt({items:ue,request:tt=>Sxt(s,Qe,tt.msg,I),decode:b,draw:tt=>{if(!Q){if(!tt.some(Tt=>Tt.image))return 0;Q=w(Te),ge=Q.getContext("2d")}let ot=vxt(ge,tt,Te);return at&&ot>0&&!st&&D(_(Q)),ot},isStale:()=>st,incremental:at}).then(tt=>{if(st)throw new Error("Tile cancelled");if(tt.failed===tt.requested)throw new Error("Tile requests failed");return tt.drawn===0?null:at?void 0:_(Q)});return Mxt(s,Qe,Ne,()=>{st=!0})},release:U5e}}function G5e({wm:s,buildRequest:n,dpr:r=()=>1,tileSize:c=()=>240,decode:u=xxt}){return{load({z:d,x:b,y:w},{background:_=!1}={}){let x=n({z:d,x:b,y:w},r(),c());if(!x)return Ext;let T=[],M=!1,L=Sxt(s,T,x,_).then(I=>u(I)).then(I=>{if(M)throw U5e(jhe(I)),new Error("Tile cancelled");return jhe(I)});return Mxt(s,T,L,()=>{M=!0})},release:U5e}}function Axt({z:s,x:n,y:r},c,u,d,b){let w={type:"overlay_tile",z:s,x:n,y:r,...zhe(c,u),debug_renderers:!!d.debug_renderers,debug_live:!!d.debug_live,flywires_only:!!d.flywires_only,poly_decomp:!!(b&&b.polyDecomp),focused_nets_guides:!!d.focused_nets_guides,highlight_selected:d.highlight_selected!==!1,draw_labels:d.labels!==!1};return b&&b.visibleLayerNames&&(w.visible_layers=[...b.visibleLayerNames]),w}function Pxt({z:s,x:n,y:r},c,u,d){let b=d&&d.activeHeatMap;return b?{type:"heatmap_tile",name:b,z:s,x:n,y:r,...zhe(c,u)}:null}function ua(s){return!!s?.websocketManager?.isStaticMode}function Dxt(s,n){let r={};for(let[c,u]of Object.entries(s||{}))r[c]=!!u;for(let[c,u]of Object.entries(n||{}))r["s_"+c]=!!u;return r}function EO(s,n){n&&typeof n.sel_has_inst=="boolean"&&(s.selHasInst=n.sel_has_inst,s.selHasNet=!!n.sel_has_net)}var j5e=null;function Fb(s,n=4e3){let r=document.getElementById("or-toast");return r||(r=document.createElement("div"),r.id="or-toast",document.body.appendChild(r)),r.textContent=s,r.classList.add("visible"),j5e&&clearTimeout(j5e),j5e=setTimeout(()=>r.classList.remove("visible"),n),r}function Bxt(s,{dontShowAgain:n}={}){let r=document.createElement("div");r.className="or-corner-warning",r.setAttribute("role","alert");let c=document.createElement("div"),u=document.createElement("span");if(u.textContent=s,c.append(u),n){let b=document.createElement("button");b.type="button",b.className="or-corner-warning-never",b.textContent="Don't show again",b.addEventListener("click",()=>{n(),r.remove()}),c.append(b)}let d=document.createElement("button");return d.type="button",d.className="or-corner-warning-close",d.title="Close",d.setAttribute("aria-label","Close"),d.textContent="\xD7",d.addEventListener("click",()=>r.remove()),r.append(c,d),document.body.appendChild(r),r}var Fhn=/SwiftShader|llvmpipe|lavapipe|softpipe|Basic Render Driver/i,Lxt="If hardware acceleration is turned off in your browser settings ('Use graphics acceleration when available' or 'Use hardware acceleration when available'), turn it on and restart the browser.";function Oxt(s){if(!s)return null;if(s.gpuType==="none")return{kind:"nowebgl",message:"WebGL is not available, so the layout view cannot be drawn. "+Lxt};let n=`${s.vendor||""} ${s.renderer||""}`;return s.gpuType!=="cpu"&&!Fhn.test(n)?null:{kind:"software",message:"The layout view is being drawn in software, without the GPU, which is slower. "+Lxt}}function Nxt({title:s,message:n,confirmLabel:r="OK",danger:c=!1}){return new Promise(u=>{let d=document.createElement("div");d.className="or-modal-overlay";let b=document.createElement("div");b.className="or-modal";let w=document.createElement("div");w.className="or-modal-title",w.textContent=s;let _=document.createElement("div");_.className="or-modal-message",_.textContent=n;let x=document.createElement("div");x.className="or-modal-buttons";let T=document.createElement("button");T.className="or-btn",T.textContent="Cancel";let M=document.createElement("button");M.className="or-btn"+(c?" or-btn-danger":""),M.textContent=r;let L=D=>{document.removeEventListener("keydown",I,!0),d.remove(),u(D)},I=D=>{D.key==="Escape"&&(D.stopPropagation(),L(!1))};T.addEventListener("click",()=>L(!1)),M.addEventListener("click",()=>L(!0)),d.addEventListener("click",D=>{D.target===d&&L(!1)}),document.addEventListener("keydown",I,!0),x.appendChild(T),x.appendChild(M),b.appendChild(w),b.appendChild(_),b.appendChild(x),d.appendChild(b),document.body.appendChild(d),T.focus()})}var Uhn=.05;function zhn([[s,n],[r,c]],u){let d=(c-n)*u,b=(r-s)*u;return[[s-b,n-d],[r+b,c+d]]}function $5e(s,n=256,r=null){if(!kxt(s))return null;let c=s[0][0],u=s[0][1],d=Math.max(s[1][1]-u,s[1][0]-c),b=n/d,w=kxt(r)?r:s,[[_,x],[T,M]]=zhn(w,Uhn);return{scale:b,maxDXDY:d,originX:u,originY:c,fitRect:X1(x,_,M,T,b,u,c)}}function kxt(s){return!!s&&s[1][0]>s[0][0]&&s[1][1]>s[0][1]}function Fxt(s,n){return!!s&&!!n&&s[0][0]===n[0][0]&&s[0][1]===n[0][1]&&s[1][0]===n[1][0]&&s[1][1]===n[1][1]}function Pm(s){s.selectionToken=(s.selectionToken||0)+1;for(let n of s.selectionResetters||[])n();return s.selectionToken}function Y1(s,n){return s.selectionToken===n}function Uxt(s,n){s.selectionResetters||(s.selectionResetters=[]),s.selectionResetters.push(n)}var V5e=80,QW=10,eH=1e3;function tH(s){let n=s===""||s===null?NaN:Math.round(Number(s));return Number.isFinite(n)?Math.min(eH,Math.max(QW,n)):V5e}function sk(s="vis-group-header"){let n=document.createElement("div");n.className=s;let r=document.createElement("span");r.className="vis-arrow",n.appendChild(r);let c=document.createElement("span");return c.className="vis-name",n.appendChild(c),{header:n,arrow:r,name:c}}function ok(s,n,r,c){let u=d=>{r.classList.toggle("collapsed",d),n.textContent=d?"\u25B6":"\u25BC"};u(!!c),s.addEventListener("click",d=>{let b=d.target&&d.target.parentNode===s&&d.target.classList&&d.target.classList.contains("vis-name");d.target!==s&&d.target!==n&&!b||u(!r.classList.contains("collapsed"))})}var Rxt=30;function zxt(s,n=8){if(!Number.isFinite(s)||s<=0)return Rxt;let r=Math.ceil(Math.log2(n/s));return Math.max(1,Math.min(Rxt,r))}function Gxt({designBounds:s,fitRect:n,viewW:r,viewH:c}){let u=$5e(s,iE,n),d=I=>Number.isFinite(I)&&I>0;if(!u||!d(r)||!d(c))return iE;let b=u.fitRect[2]-u.fitRect[0],w=u.fitRect[3]-u.fitRect[1],_=Math.min(r/b,c/w),x=Math.log2(_);if(!Number.isFinite(x)||x<0)return iE;let T=Math.floor(x),M=iE*2**(x-T),L=Math.floor(M/B5e)*B5e;return L>iE&&Math.log2(iE*_/L)>=T?L:iE}function jxt(s,{showDbu:n,dbuPerMicron:r},c=!1){if(n)return String(Math.round(s));let u=r>0?r:1e3,d=Math.ceil(Math.log10(u)),b=(s/u).toFixed(d);return c?b+" \xB5m":b}function $xt(s,{showDbu:n,dbuPerMicron:r}){let c=parseFloat(s);if(!Number.isFinite(c))return null;if(n)return Math.round(c);let u=r>0?r:1e3;return Math.round(c*u)}function Vxt(s,{showDbu:n,dbuPerMicron:r}){if(n)return String(Math.round(s));let c=r>0?r:1e3,u=s/c;return u>=1e3?(u/1e3).toFixed(3)+" mm":u>=1?u.toFixed(3)+" um":(u*1e3).toFixed(1)+" nm"}function Wxt({showDbu:s}){return s?"DBU":"\xB5m"}function SO(s){return typeof s=="string"&&/^#[0-9a-fA-F]{6}$/.test(s)}function Hxt(s){if(typeof s!="string")return null;let n=s.trim();if(SO(n))return n.toLowerCase();let r=n.match(/^#([0-9a-fA-F]{3})$/);if(r)return"#"+r[1].split("").map(u=>u+u).join("").toLowerCase();let c=n.match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/);if(c){let u=c.slice(1).map(Number);return u.some(d=>d>255)?null:"#"+u.map(d=>d.toString(16).padStart(2,"0")).join("")}return null}function yT(s,n=r=>requestAnimationFrame(r)){let r=!1;return()=>{r||(r=!0,n(()=>{r=!1,s()}))}}function nH(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function Ixt(s){let n=Math.pow(10,Math.floor(Math.log10(s))),r=s/n,c;return r<1.5?c=1:r<3.5?c=2:r<7.5?c=5:c=10,{value:c*n,digit:c}}function qxt({targetPx:s,pxPerDbu:n,dbuPerMicron:r,showDbu:c}){if(!Number.isFinite(n)||n<=0||!Number.isFinite(s)||s<=0)return null;let u,d,b;if(c){let _=Ixt(Math.max(1,s/n));b=_.digit,u=Math.round(_.value*n),d=String(Math.round(_.value))}else{let _=Number.isFinite(r)&&r>0?r:1e3,x=n*_,T=Ixt(s/x);b=T.digit;let M=T.value;u=Math.round(M*x);let L,I;M>=1e3?(L=1/1e3,I="mm"):M>=1?(L=1,I="\xB5m"):M>=.001?(L=1e3,I="nm"):(L=1e6,I="pm"),d=Math.round(M*L)+" "+I}return{barPx:u,label:d,segments:b===1?5:b}}function iH(s,n,r){return n?typeof s.runTclScript=="function"?s.runTclScript(n,r):(r&&typeof s.echoTcl=="function"&&s.echoTcl(n),s.websocketManager.request({type:"tcl_eval",cmd:n}).catch(()=>{})):Promise.resolve()}function ak(s,n){let r=s.querySelectorAll("thead th");(!n||!n[0])&&(s.style.tableLayout="auto",r.forEach(c=>c.style.width=""),n=Array.from(r,c=>c.offsetWidth+"px")),r.forEach((c,u)=>c.style.width=n[u]||""),s.style.tableLayout="fixed",r.forEach((c,u)=>{if(u===r.length-1)return;let d=document.createElement("div");d.className="col-resize-grip",c.style.position="relative",c.appendChild(d);let b,w,_=T=>{c.style.width=Math.max(30,w+T.clientX-b)+"px"},x=()=>{document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",x);let T=M=>M.stopPropagation();document.addEventListener("click",T,{capture:!0,once:!0}),setTimeout(()=>{document.removeEventListener("click",T,{capture:!0})},0)};d.addEventListener("mousedown",T=>{T.preventDefault(),b=T.clientX,w=c.offsetWidth,document.addEventListener("mousemove",_),document.addEventListener("mouseup",x)})})}var Ghn={Layout:'',Schematic:'',"3D Viewer":'',"Display Controls":'',Inspector:'',Hierarchy:'',Timing:'',DRC:'',"Select Highlight":'',"Clock Tree":'',Charts:'',"Tcl Console":'',Help:''};function jhn(s){let n=Ghn[s];if(!n)return null;let r=document.createElement("span");return r.className="or-tab-icon",r.innerHTML='",r}function Xxt(s=document){let n=0;for(let r of s.querySelectorAll(".lm_tab:not([data-or-icon])")){let c=r.querySelector(".lm_title");if(!c)continue;let u=c.textContent.trim();if(!u)continue;r.setAttribute("data-or-icon","");let d=jhn(u);d&&(r.insertBefore(d,c),n++)}return n}function MO(s,n,r,c){let u=document.createElement("div");u.className="modal-overlay",u.innerHTML=` -
`,document.body.appendChild(u);let d=()=>u.remove();u.addEventListener("click",_=>{_.target===u&&d()}),u.addEventListener("keydown",_=>{_.key==="Escape"&&d()}),u.querySelector(".cancel").addEventListener("click",d),u.querySelector(".modal-close").addEventListener("click",d);let b=u.querySelector(".modal-error"),w=(_,x)=>{b.textContent=_,b.style.display=_?"block":"none",b.classList.toggle("info",!!x)};return{overlay:u,close:d,okBtn:u.querySelector(".ok"),showError:w}}var Uhn=1e4,zhn=150,Ghn=3;function jhn(s){return 1-(1-s)*(1-s)}var $he=class{constructor({isEnabled:n=()=>!0,isSmooth:r=()=>!1,reducedMotion:c=nH,now:u=()=>performance.now(),setTimer:d=(T,M)=>setTimeout(T,M),clearTimer:b=T=>clearTimeout(T),timeoutMs:w=Uhn,fadeMs:_=zhn,onChange:x=()=>{}}={}){Object.assign(this,{isEnabled:n,isSmooth:r,reducedMotion:c,now:u,setTimer:d,clearTimer:b,timeoutMs:w,fadeMs:_,onChange:x}),this.shownZ=null,this.pendingZ=null,this.under=[],this.fade=null,this._timer=null}wantedZ(){return this.pendingZ!==null?this.pendingZ:this.shownZ}setZoom(n,{hasContent:r=!0}={}){n!==this.wantedZ()&&(this.endFade(),this._clearTimer(),this.shownZ===null?(this.shownZ=n,this.pendingZ=null,this.under=[]):r?n===this.shownZ?this.pendingZ=null:this.isEnabled()?(this.pendingZ=n,this.under=[],this._timer=this.setTimer(()=>this.reveal(),this.timeoutMs)):(this.under=[...this.under.filter(c=>c!==n),this.shownZ].slice(-Ghn),this.shownZ=n,this.pendingZ=null):(this.shownZ=n,this.pendingZ=null,this.under=this.under.filter(c=>c!==n)),this.onChange())}check({settled:n,animating:r=!1}){return this.pendingZ!==null?r||!n&&this.isEnabled()?!1:(this.reveal(),!0):this.under.length>0&&n&&!r?(this.under=[],this.onChange(),!0):!1}reveal(){if(this.pendingZ===null)return;this._clearTimer();let n=this.shownZ;this.shownZ=this.pendingZ,this.pendingZ=null;let r=this.isSmooth()&&!this.reducedMotion()?this.fadeMs:0;this.fade=r>0&&n!==null?{fromZ:n,toZ:this.shownZ,start:this.now(),ms:r}:null,this.onChange()}endFade(){this.fade&&(this.fade=null,this.onChange())}plan(n=this.now()){if(this.fade){let r=(n-this.fade.start)/this.fade.ms;if(r<1)return{draw:[{z:this.fade.fromZ,opacity:1},{z:this.fade.toZ,opacity:jhn(Math.max(0,r))}],fading:!0};this.fade=null}return this.shownZ===null?{draw:[],fading:!1}:this.pendingZ!==null?{draw:[{z:this.shownZ,opacity:1}],fading:!1}:this.under.length>0?{draw:[...this.under,this.shownZ].map(r=>({z:r,opacity:1})),fading:!1}:{draw:[{z:this.shownZ,opacity:1}],fading:!1}}isIdle(n=this.now()){return this.pendingZ===null&&this.under.length===0&&!this.plan(n).fading}dispose(){this._clearTimer()}_clearTimer(){this._timer!==null&&(this.clearTimer(this._timer),this._timer=null)}};var bp=Object.freeze({base:10,overlay:20,heatmap:30,top:40,pathImage:50,selection:60,highlight:70,ruler:80}),ck={depthCompare:"always",depthWriteEnabled:!1},qxt=250,Xxt=4,W5e=300,$hn=1,Vhn=2,Whn=300,Hhn=300,qhn=400,Xhn=1e3,Yxt=100,Yhn=.05,Zxt=1200,Kxt=30;function K1(s,n=1){if(Array.isArray(s)){let u=s.length>3?s[3]:255;return[s[0],s[1],s[2],Math.round(u*n)]}let r=String(s||"#000").replace("#","");r.length===3&&(r=r.split("").map(u=>u+u).join(""));let c=parseInt(r.slice(0,6),16)||0;return[c>>16&255,c>>8&255,c&255,Math.round(255*n)]}function Zhn(s){return 1-Math.pow(1-s,3)}function Khn(s){return s<.5?4*s*s*s:1-Math.pow(2-2*s,3)/2}function Jhn(){let s=new Map;return{on(n,r){for(let c of n.split(/\s+/))s.has(c)||s.set(c,new Set),s.get(c).add(r)},off(n,r){for(let c of n.split(/\s+/))s.get(c)?.delete(r)},emit(n,r){for(let c of[...s.get(n)||[]])c(r)}}}function Qhn(s){let n=s&&s.device&&s.device.info||{};return{gpuType:n.gpuType||"unknown",renderer:n.renderer||"",vendor:n.vendor||""}}function Jxt(s,n={}){let r=n.deckApi!==void 0?n.deckApi:globalThis.deck,c=n.copyCanvas||z5e,u={smooth:()=>!1,doubleBuffer:()=>!0,defer:()=>!1,...n.prefs||{}},d=n.tileSize||(()=>240),b=n.dpr||(()=>typeof devicePixelRatio=="number"?devicePixelRatio:1),w=n.raf||(Re=>requestAnimationFrame(Re)),_=n.now||(()=>performance.now()),x=Jhn(),T={target:[0,0],zoom:0,width:1,height:1},M={minZoom:-1/0,maxZoom:Kxt},L=null,I=!1,D=[],F=null,O=[],z=null,Z=null,H=!1,te=!1,oe=0,ne=new Set,ue=!1;s.classList.add("or-view");let Te=document.createElement("div");Te.className="or-view-canvas",s.appendChild(Te);let Q=document.createElement("div");Q.className="or-view-markers",s.appendChild(Q);let ge=new Map,Qe=new Map,st=new Map,at=new Map,Ne=new WeakMap,tt=[],ot=yT(_i,w),Tt=new $he({isEnabled:()=>u.doubleBuffer(),isSmooth:()=>u.smooth(),now:_,onChange:()=>ot()}),jt=null;function en(){return{dragPan:!0,dragRotate:!1,scrollZoom:!1,doubleClickZoom:!1,touchZoom:!n.isStatic,touchRotate:!1,keyboard:!1,inertia:!1}}function mn(){return{target:[T.target[0],T.target[1],0],zoom:T.zoom,minZoom:M.minZoom,maxZoom:M.maxZoom}}function cn(){return new r.Deck({parent:Te,views:new r.OrthographicView({id:"main",flipY:!1,controller:en()}),viewState:mn(),layers:[],useDevicePixels:!0,deviceProps:{webgl:{preserveDrawingBuffer:!!n.preserveDrawingBuffer}},getCursor:({isDragging:Re})=>ne.size?"crosshair":Re?"grabbing":"default",onViewStateChange:({viewState:Re})=>{if(L=null,Yi(Re.target,Re.zoom),I){let nt=_();O.push({t:nt,target:[...T.target],zoom:T.zoom}),O=O.filter(kt=>nt-kt.t<=Yxt)}return mn()},onInteractionStateChange:Re=>{let nt=!!(Re.isDragging||Re.isPanning||Re.isZooming||Re.inTransition);if(nt!==I){if(I=nt,nt){O=[],Tr();return}queueMicrotask(()=>{!I&&!L&&!Si()&&wr()})}},onLoad:()=>{bi(),F=Qhn(jt),x.emit("renderer",F),ot()},onAfterRender:()=>{let Re=D;D=[],Re.forEach(nt=>nt())}})}function bi(){let Re=jt.getCanvas&&jt.getCanvas();Re?.addEventListener("webglcontextlost",nt=>{if(nt.preventDefault(),ue)return;x.emit("contextlost");let kt=jt;jt=null,Ne=new WeakMap,tt=[];try{kt.finalize?.()}catch{}Re.remove();try{jt=cn(),x.emit("contextrestored")}catch(xn){x.emit("contextfailed",xn)}ot()})}r&&typeof r.Deck=="function"&&(jt=cn());function Vt(){let Re=b(),nt=Math.max(1,Math.floor(s.clientWidth*Re)/Re),kt=Math.max(1,Math.floor(s.clientHeight*Re)/Re),xn=nt!==T.width||kt!==T.height;return T.width=nt,T.height=kt,Te.style.width=nt+"px",Te.style.height=kt+"px",xn}Vt();let pn=null;typeof ResizeObserver=="function"&&(pn=new ResizeObserver(()=>qn()),pn.observe(s));function qn(){Vt()?($i(),x.emit("resize",ar())):ot()}function Yi(Re,nt,{tiles:kt=!0}={}){let xn=rk(nt,M),Ei=xn!==T.zoom;T.target=[Re[0],Re[1]],T.zoom=xn,$i(Ei,kt)}function $i(Re=!1,nt=!0){jt&&jt.setProps({viewState:mn()}),Re&&x.emit("zoom"),x.emit("move"),nt&&hr(),ot()}function Tr(){te||(te=!0,x.emit("movestart"))}function wr(){if(L||I)return;let Re=Math.round(T.zoom);if(Math.abs(Re-T.zoom)>1e-9){se({target:Nhe(T,[T.width/2,T.height/2],Re),zoom:Re},{anchor:null});return}T.target=lxt(T,b());let nt=te;te=!1,$i(),nt&&(x.emit("moveend"),x.emit("zoomend"))}function Si(){let Re=O;if(O=[],!u.smooth()||Re.length<2)return!1;let nt=Re[0],kt=Re[Re.length-1],xn=kt.t-nt.t;if(xn<=0||_()-kt.t>Yxt||nt.zoom!==kt.zoom)return!1;let Ei=(kt.target[0]-nt.target[0])/xn,Xi=(kt.target[1]-nt.target[1])/xn;return Math.hypot(Ei,Xi)*Math.pow(2,T.zoom)Xxt?0:qxt}function se(Re,{anchor:nt=null,ms:kt=void 0,settle:xn=!0,curve:Ei=!1}={}){Re={target:Re.target,zoom:rk(Re.zoom,M)};let Xi=Ei&&kt===void 0?de(Re):null;if(kt===void 0&&(kt=Xi?Xi.ms:Fr(Re)),Tr(),Re.zoom!==T.zoom&&x.emit("zoomstart"),kt<=0){L=null;let cr=xn&&!I;Yi(Re.target,Re.zoom,{tiles:!cr}),xn&&wr();return}Z=null,L={from:{...T,target:[...T.target]},to:Re,anchor:nt,start:Xi?null:_(),created:_(),ms:kt,flight:Xi},hr(),We()}function de(Re){if(!u.smooth()||!(Math.hypot(Re.target[0]-T.target[0],Re.target[1]-T.target[1])*Math.pow(2,Math.min(T.zoom,Re.zoom))>Vhn*Math.max(T.width,T.height))&&Math.abs(Re.zoom-T.zoom)<=Xxt)return null;let xn=uxt(T,{...T,...Re}),Ei=1/0,Xi=null;for(let Ks=0;Ks<=16;Ks++){let Bi=xn.at(Ks/16);Ei=Math.min(Ei,Bi.zoom);let io=_O({...T,...Bi});Xi=Xi?[Math.min(Xi[0],io[0]),Math.min(Xi[1],io[1]),Math.max(Xi[2],io[2]),Math.max(Xi[3],io[3])]:io}let cr=Math.max(0,k5e(Ei)),So=KW(Xi,cr,d());return{path:xn,ms:Math.min(Xhn,Math.max(qhn,Hhn*xn.S)),apex:So?{z:cr,range:So}:null}}function it(Re){return!Re||[...ge.values()].every(nt=>!nt.visible||nt.grid.settledIn(Re.z,Re.range))}function We(){if(!L||ue)return;if(L.start===null){if(!it(L.flight.apex)&&_()-L.created=1){let Ei=L.to;Z=L.flight?L.flight.apex:null,L=null,Yi(Ei.target,Ei.zoom),wr();return}Yi(xn,kt),w(We)}function En(){return L?{...T,target:L.to.target,zoom:L.to.zoom}:T}function hr(){if(ge.size===0)return;let Re=u.doubleBuffer(),nt=rk(k5e(T.zoom,{targetZoom:L?L.to.zoom:null,hidingNewLevels:Re}),{minZoom:0,maxZoom:Kxt}),kt=En(),xn=KW(_O(kt),nt,d()),Ei=Fhe(xn),Xi=Tt.shownZ,cr=u.defer()&&I;cr||Tt.setZoom(nt,{hasContent:[...ge.values()].some(io=>io.visible&&Xi!==null&&io.grid.hasContentAt(Xi))});let So=[];nt>0&&!L&&!I&&!te&&Tt.pendingZ===null&&(z=nt-1,So.push({z,range:KW(R5e(_O(kt),$hn),z,d())}));let Ks=qi();Ks&&So.push({...Ks,background:!1});let Bi=L?KW(_O(T),nt,d()):null;for(let io of ge.values())io.visible&&!cr&&io.grid.update({z:nt,range:xn,ring:Ei,extra:So,hold:Bi});gn()}function qi(){return L&&L.flight&&L.flight.apex||Z}function Me(Re){let nt=[];for(let kt of[qi()?.z,Tt.pendingZ])kt!=null&&!nt.includes(kt)&&!Re.some(xn=>xn.z===kt)&&nt.push(kt);return nt}function ve(){H||(H=!0,queueMicrotask(()=>{H=!1,ue||hr()}))}function wt(){for(let Re of ge.values())if(Re.visible&&!Re.grid.isSettled())return!1;return!0}function gn(Re){let nt=Tt.check({settled:wt(),animating:!!L});nt&&Tt.pendingZ===null&&ve();let kt=!1;Z&&!L&&Tt.isIdle()&&wt()&&(Z=null,kt=!0),(nt||kt||!Re||vn(Re.z))&&ot()}function vn(Re){let nt=Tt.plan(_()).draw;return nt.some(kt=>kt.z===Re)||Me(nt).includes(Re)}function Mn(Re,{order:nt,source:kt,visible:xn=!0}){let Ei={load:(cr,So)=>kt.load(cr,So),release:cr=>{let So=cr&&Ne.get(cr);So&&(Ne.delete(cr),tt.push(So)),kt.release?.(cr)}},Xi={id:Re,order:nt,visible:xn,grid:new Uhe({source:Ei,onChange:cr=>gn(cr)})};return ge.set(Re,Xi),hr(),{id:Re,setVisible(cr){Xi.visible!==!!cr&&(Xi.visible=!!cr,Xi.visible||Xi.grid.clear(),hr())},isVisible:()=>Xi.visible,refresh(){Xi.visible&&(Xi.grid.refresh(),ot())},remove(){Xi.grid.clear(),ge.delete(Re),ot()}}}function xi(Re){if(!jt||!jt.device)return Re.image;let nt=Ne.get(Re);if(!nt){try{nt=jt.device.createTexture({data:Re.image,width:Re.width,height:Re.height,mipLevels:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}})}catch{return Re.image}Ne.set(Re,nt)}return nt}function mi(Re){if(Re>=oe)return 1;let nt=(Zxt-(oe-Re))%400/400;return 1-.7*(.5-.5*Math.cos(2*Math.PI*nt))}let ri=new WeakMap,Ge=null;function Ae(Re){let nt=d();nt!==Ge&&(ri=new WeakMap,Ge=nt);let kt=ri.get(Re);return kt||(kt=cxt(Re.z,Re.x,Re.y,nt),ri.set(Re,kt)),kt}function Le(Re,nt,kt,xn,Ei,Xi){for(let cr of nt.grid.drawableTilesAt(kt)){let So=Ae(cr);I5e(So,xn)&&Re.push({order:nt.order,props:{id:`${nt.id}:${Ei}${cr.key}`,image:xi(cr.drawable),bounds:So,opacity:Xi,parameters:ck}})}}function ht(Re,nt){let kt=[],xn=Tt.plan(Re);if(!xn.fading&&Tt.pendingZ===null&&xn.draw.length>0){let Ks=[...xn.draw.map(Bi=>Bi.z),z,qi()?.z].filter(Bi=>Bi!=null);for(let Bi of ge.values())Bi.grid.prune(Ks)}let Ei=mi(Re),Xi=[...ge.values()].sort((Ks,Bi)=>Ks.order-Bi.order),cr=Xi.find(Ks=>Ks.visible),So=Me(xn.draw);for(let Ks of Xi)if(Ks.visible){Ks===cr&&So.length>0&&kt.push(...Ye(Ks,So,xn.draw,nt,Ei));for(let Bi of xn.draw)Le(kt,Ks,Bi.z,nt,"",Bi.opacity*Ei)}return{layers:kt,animate:xn.fading||Reio.z===Ks.z)||Ks.loading&&!Ks.drawable)continue;let Bi=Ae(Ks);if(I5e(Bi,xn)){let[io,gf,Q1,Lm]=Bi;So.push([[io-cr,gf-cr],[Q1+cr,gf-cr],[Q1+cr,Lm+cr],[io-cr,Lm+cr]])}}return So.length&&Xi.push({order:Re.order,kind:"SolidPolygonLayer",props:{id:`${Re.id}:mask`,data:So,getPolygon:Ks=>Ks,getFillColor:ct(),parameters:ck}}),Xi}function ct(){let Re=(getComputedStyle(s).backgroundColor||"").match(/[\d.]+/g);return!Re||Re.length<3||Re.length>3&&Number(Re[3])===0?[0,0,0,255]:[Number(Re[0]),Number(Re[1]),Number(Re[2]),255]}function Ze(Re,nt,kt){let xn=[],Ei=[],Xi=[],cr=[];for(let Bi of nt){if(Bi.kind==="circle"){cr.push(Bi);continue}let io=Bi.kind==="rect"?[[Bi.rect[0],Bi.rect[1]],[Bi.rect[2],Bi.rect[1]],[Bi.rect[2],Bi.rect[3]],[Bi.rect[0],Bi.rect[3]]]:Bi.points;if(Bi.fill&&Ei.push({polygon:io,color:Bi.fill}),Bi.stroke){let gf=Bi.kind==="rect"||Bi.closed;Xi.push({path:gf?[...io,io[0]]:io,color:Bi.stroke,width:Bi.width||1,dash:Bi.dash||null})}}Ei.length&&xn.push({order:kt,kind:"SolidPolygonLayer",props:{id:`${Re}:fill`,data:Ei,getPolygon:Bi=>Bi.polygon,getFillColor:Bi=>Bi.color,parameters:ck}});let So=Xi.filter(Bi=>!Bi.dash),Ks=Xi.filter(Bi=>Bi.dash);if(So.length&&xn.push({order:kt,kind:"PathLayer",props:{id:`${Re}:stroke`,data:So,widthUnits:"pixels",getPath:Bi=>Bi.path,getColor:Bi=>Bi.color,getWidth:Bi=>Bi.width,parameters:ck}}),Ks.length){let Bi={id:`${Re}:dash`,data:Ks,widthUnits:"pixels",getPath:io=>io.path,getColor:io=>io.color,getWidth:io=>io.width,getDashArray:io=>io.dash.map(gf=>gf/io.width),dashJustified:!0,parameters:ck};r?.PathStyleExtension&&(Bi.extensions=[new r.PathStyleExtension({dash:!0})]),xn.push({order:kt,kind:"PathLayer",props:Bi})}return cr.length&&xn.push({order:kt,kind:"ScatterplotLayer",props:{id:`${Re}:circle`,data:cr,radiusUnits:"pixels",lineWidthUnits:"pixels",getPosition:Bi=>Bi.center,getRadius:Bi=>Bi.radius,stroked:!0,filled:!0,getLineColor:Bi=>Bi.stroke||[0,0,0,0],getFillColor:Bi=>Bi.fill||[0,0,0,0],getLineWidth:Bi=>Bi.width||1,parameters:ck}}),xn}function Ke(){let Re=[];for(let nt of Qe.values())Re.push(...nt);return Re.push(...st.values()),Re}function pt(Re){return Re.map(nt=>new r[nt.kind||"BitmapLayer"](nt.props))}let Xn=0;function _i(){if(ue)return;let Re=_(),nt=ht(Re,R5e(_O(T),.5)),kt=[...nt.layers,...Ke()].sort((xn,Ei)=>xn.order-Ei.order);Xn=kt.length,jt&&jt.setProps({layers:pt(kt)});for(let xn of tt.splice(0))xn.destroy?.();ei(),nt.animate&&ot(),x.emit("render")}function Hi(Re=32,nt=20){let kt=ge.get("base");if(!kt)return null;let xn=d(),Ei=Tt.plan(_()).draw,Xi=[...Ei,...Me(Ei).map(Ks=>({z:Ks}))],cr=0,So=0;for(let Ks=0;Ks=xn||gf>=xn)continue;cr++,Xi.some(({z:Lm})=>{let b2=xn/2**Lm,zb=kt.grid.tiles.get(yO(Lm,Math.floor(io/b2),Math.floor((xn-gf)/b2)));return zb&&(zb.drawable||!zb.loading)})&&So++}return cr?So/cr:null}function _n(Re){return at.has(Re)||at.set(Re,{visible:!0,items:new Map}),at.get(Re)}function Je(Re,nt){let[kt,xn]=Ohe(Re.world,T);Re.el.style.display=nt?"":"none",Re.el.style.transform=`translate(${kt}px, ${xn}px)`+(Re.center?" translate(-50%, -50%)":"")}function Qn(Re){for(let nt of Re.items.values())Je(nt,Re.visible)}function ei(){for(let Re of at.values())Qn(Re)}function ar(){return{width:T.width,height:T.height}}let yn={DRAW_ORDER:bp,getContainer:()=>s,getRendererInfo:()=>F,getSize:ar,getZoom:()=>T.zoom,getTargetZoom:()=>L?L.to.zoom:T.zoom,getCenter:()=>[...T.target],getViewState:()=>({...T,target:[...T.target]}),isAnimating:()=>!!L,isMoving:()=>te,project:Re=>Ohe(Re,T),unproject:Re=>vO(Re,T),on:x.on,off:x.off,setLimits({minZoom:Re,maxZoom:nt}={}){Re!==void 0&&(M.minZoom=Re),nt!==void 0&&(M.maxZoom=nt);let kt=rk(T.zoom,M);kt!==T.zoom?Yi(T.target,kt):jt&&jt.setProps({viewState:mn()}),x.emit("limits")},getLimits:()=>({...M}),setView(Re,nt=T.zoom,{animate:kt}={}){let xn={target:[Re[0],Re[1]],zoom:nt};se(xn,kt===!1?{ms:0}:{curve:!0})},fitWorldRect(Re,{padding:nt=[0,0],animate:kt}={}){let xn=axt(Re,T,{padding:nt,...M});se(xn,kt===!1?{ms:0}:{curve:!0})},zoomAround(Re,nt,{animate:kt,settle:xn=!0}={}){let Ei=rk(yn.getTargetZoom()+nt,M),Xi=En(),cr=Re||[T.width/2,T.height/2],So=Nhe(Xi,cr,Ei);se({target:So,zoom:Ei},kt===!1?{ms:0,settle:xn}:{anchor:Re?cr:null})},zoomIn:()=>yn.zoomAround(null,1),zoomOut:()=>yn.zoomAround(null,-1),panByPx(Re,nt,{animate:kt}={}){let xn=En(),Ei=Math.pow(2,xn.zoom),Xi=[xn.target[0]+Re/Ei,xn.target[1]-nt/Ei],cr=kt===!1||!u.smooth()?0:qxt;se({target:Xi,zoom:xn.zoom},{ms:cr})},invalidateSize:qn,applyPrefs(){hr()},addTileSlot:Mn,setOverlay(Re,nt,{order:kt=bp.selection}={}){!nt||nt.length===0?Qe.delete(Re):Qe.set(Re,Ze(Re,nt,kt)),ot()},hasOverlay:Re=>Qe.has(Re),setImageOverlay(Re,nt,{order:kt=bp.pathImage}={}){nt?st.set(Re,{order:kt,kind:"BitmapLayer",props:{id:`image:${Re}`,image:nt.image,bounds:nt.rect,parameters:ck}}):st.delete(Re),ot()},addMarker(Re,nt,kt,xn,{center:Ei=!1}={}){let Xi=_n(Re),cr=Xi.items.get(nt);cr&&cr.el.remove(),xn.classList.add("or-view-marker"),Q.appendChild(xn);let So={el:xn,world:[kt[0],kt[1]],center:Ei};return Xi.items.set(nt,So),Je(So,Xi.visible),xn},moveMarker(Re,nt,kt){let xn=_n(Re),Ei=xn.items.get(nt);Ei&&(Ei.world=[kt[0],kt[1]],Je(Ei,xn.visible))},clearMarkers(Re){let nt=_n(Re);for(let kt of nt.items.values())kt.el.remove();nt.items.clear()},setMarkerGroupVisible(Re,nt){let kt=_n(Re);kt.visible=!!nt,Qn(kt)},setCursorMode(Re,nt=!0){nt?ne.add(Re):ne.delete(Re),s.classList.toggle(`${Re}-mode-cursor`,!!nt);let kt=jt&&jt.getCanvas&&jt.getCanvas();kt&&(kt.style.cursor=ne.size?"crosshair":"default")},flashTiles(){oe=_()+Zxt,ot()},whenTilesSettled({timeoutMs:Re=6e3}={}){let nt=_()+Re;return new Promise(kt=>{let xn=()=>{if(wt()&&Tt.isIdle()&&!L&&!te||_()>=nt){kt();return}setTimeout(xn,32)};xn()})},captureCanvas({timeoutMs:Re=500}={}){return jt?.getCanvas()?(_i(),new Promise(nt=>{let kt=null,xn=()=>{clearTimeout(kt),D=D.filter(Xi=>Xi!==xn);let Ei=jt?.getCanvas();nt(Ei?{image:c(Ei),rect:Ei.getBoundingClientRect()}:null)};D.push(xn),kt=setTimeout(()=>{jt?.redraw("capture"),xn()},Re)})):Promise.resolve(null)},redraw:()=>ot(),debugSnapshot(){let Re=Tt.plan();return{zoom:T.zoom,target:[...T.target],width:T.width,height:T.height,animating:!!L,moving:te,interacting:I,shownZ:Tt.shownZ,pendingZ:Tt.pendingZ,fading:Re.fading,drawLevels:Re.draw,layers:Xn,coverage:Hi(),overlays:[...Qe.keys()],markers:Object.fromEntries([...at].map(([nt,kt])=>[nt,kt.items.size])),slots:[...ge.values()].map(nt=>({id:nt.id,visible:nt.visible,settled:nt.grid.isSettled(),...nt.grid.stats()}))}},destroy(){ue=!0,pn?.disconnect(),Tt.dispose();for(let Re of ge.values())Re.grid.clear();jt?.finalize?.()}};return yn}var edn=4.000244140625;function tdn(s){return s.deltaMode!==0?!0:s.deltaX!==0||s.deltaY===0?!1:Number.isInteger(s.deltaY)&&Math.abs(s.deltaY)>=50||s.deltaY%edn===0}function ndn(s){let n=Math.abs(s);return n<.2?0:Math.sign(s)*Math.max(1,Math.round(n))}function idn(s,n){let c=1;return s.deltaMode===1?c=16:s.deltaMode===2&&(c=n.clientHeight||16),[s.deltaX*c,s.deltaY*c]}function rdn(s,n,r){let c=r?3*n:n;switch(s){case"ArrowLeft":return[-c,0];case"ArrowRight":return[c,0];case"ArrowUp":return[0,-c];case"ArrowDown":return[0,c];default:return null}}function e3t(s,n={}){let r=s.getContainer(),c=n.isStatic||(()=>!1),u=n.wheelZoom||(()=>!0),d=n.arrowStep||(()=>80),b=n.gestureIdleMs??200,w=n.contextEnabled||(()=>!0),_=[],x=(ne,ue,Te,Q)=>{ne.addEventListener(ue,Te,Q),_.push(()=>ne.removeEventListener(ue,Te,Q))},T=ne=>{let ue=r.getBoundingClientRect();return[ne.clientX-ue.left,ne.clientY-ue.top]},M=ne=>s.unproject(T(ne)),L=ne=>ne.target===r||!!ne.target?.closest?.(".or-view-canvas");r.tabIndex<0&&(r.tabIndex=0);let I=null;function D(ne,ue){I||(I={z0:s.getZoom()}),I.pt=ne,clearTimeout(I.timer),I.timer=setTimeout(F,b),s.zoomAround(ne,ue,{animate:!1,settle:!1})}function F(){if(!I)return;let ne=I;I=null,clearTimeout(ne.timer);let ue=s.getZoom();s.zoomAround(ne.pt,ne.z0+ndn(ue-ne.z0)-ue)}_.push(()=>{clearTimeout(I?.timer),I=null}),x(r,"wheel",ne=>{if(ne.preventDefault(),c())return;let ue=tdn(ne);if(!ue&&ne.ctrlKey){D(T(ne),-ne.deltaY/(100*Math.LN2));return}if(u()===ne.ctrlKey){let[Te,Q]=idn(ne,r);s.panByPx(Te,Q,{animate:!1});return}if(!ue){D(T(ne),-ne.deltaY/100);return}F(),s.zoomAround(T(ne),ne.deltaY<0?1:-1)},{passive:!1}),x(r,"keydown",ne=>{if(ne.altKey||ne.ctrlKey||ne.metaKey)return;let ue=rdn(ne.key,d(),ne.shiftKey);if(ue){ne.preventDefault(),s.panByPx(ue[0],ue[1]);return}if(c())return;let Te={"+":1,"=":1,"-":-1,_:-1};ne.key in Te&&(ne.preventDefault(),s.zoomAround(null,Te[ne.key]*(ne.shiftKey?3:1)))});let O=null,z=null;x(r,"pointerdown",ne=>{ne.button!==0||!L(ne)||(r.focus({preventScroll:!0}),O={x:ne.clientX,y:ne.clientY,moved:!1,box:ne.shiftKey&&!c()},O.box&&ne.stopPropagation())},{capture:!0}),x(window,"pointermove",ne=>{if(!O)return;let ue=ne.clientX-O.x,Te=ne.clientY-O.y;(Math.abs(ue)>3||Math.abs(Te)>3)&&(O.moved=!0),O.box&&O.moved&&(z=Qxt(z,O,ne))}),x(window,"pointerup",ne=>{if(!O||ne.button!==0)return;let ue=O;if(O=null,z&&(z.remove(),z=null),ue.box&&ue.moved){oe(ue,ne);return}!ue.moved&&n.onClick&&te(ne)&&n.onClick(M(ne),ne)}),x(r,"dblclick",ne=>{c()||!L(ne)||s.zoomAround(T(ne),ne.shiftKey?-1:1)});let Z=null,H=null;x(r,"contextmenu",ne=>ne.preventDefault()),x(r,"pointerdown",ne=>{ne.button!==2||c()||!L(ne)||(ne.stopPropagation(),Z={x:ne.clientX,y:ne.clientY})},{capture:!0}),x(window,"pointermove",ne=>{if(!Z)return;let ue=ne.clientX-Z.x,Te=ne.clientY-Z.y;(H||Math.abs(ue)>=4&&Math.abs(Te)>=4)&&(H=Qxt(H,Z,ne))}),x(window,"pointerup",ne=>{if(!Z||ne.button!==2)return;let ue=Z;if(Z=null,H){H.remove(),H=null,oe(ue,ne);return}te(ne)&&w()&&n.onContextClick&&n.onContextClick(M(ne),ne)}),x(r,"pointermove",ne=>{n.onMove&&n.onMove(M(ne),ne)}),x(r,"pointerleave",ne=>{n.onLeave&&n.onLeave(ne)});function te(ne){let ue=r.getBoundingClientRect();return ne.clientX>=ue.left&&ne.clientX<=ue.right&&ne.clientY>=ue.top&&ne.clientY<=ue.bottom}function oe(ne,ue){let Te=r.getBoundingClientRect(),Q=s.unproject([ne.x-Te.left,ne.y-Te.top]),ge=s.unproject([ue.clientX-Te.left,ue.clientY-Te.top]);s.fitWorldRect([Math.min(Q[0],ge[0]),Math.min(Q[1],ge[1]),Math.max(Q[0],ge[0]),Math.max(Q[1],ge[1])])}return{dispose(){for(let ne of _.splice(0))ne()}}}function Qxt(s,n,r){return s||(s=document.createElement("div"),s.className="rubber-band",document.body.appendChild(s)),s.style.left=Math.min(n.x,r.clientX)+"px",s.style.top=Math.min(n.y,r.clientY)+"px",s.style.width=Math.abs(r.clientX-n.x)+"px",s.style.height=Math.abs(r.clientY-n.y)+"px",s}var uk=class s{constructor(n,r,c){this._app=n,this._redrawAllLayers=r,this._refreshOverlay=c||r,this._currentTab="setup",this._setupPaths=[],this._holdPaths=[],this._selectedPathIndex=-1,this._detailTab="data",this._selectedDetailIndex=-1,this._sortCol="slack",this._sortAscending=!0,this._build()}_build(){let n=document.createElement("div");n.className="timing-widget";let r=document.createElement("div");r.className="timing-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",ua(this._app)&&(this._updateBtn.style.display="none"),this._pathCountLabel=document.createElement("span"),this._pathCountLabel.className="timing-path-count",r.appendChild(this._updateBtn),r.appendChild(this._pathCountLabel),n.appendChild(r),n.appendChild(this._buildConePanel());let c=document.createElement("div");c.className="timing-tab-bar",this._setupTab=this._makeTab("Setup",!0),this._holdTab=this._makeTab("Hold",!1),c.appendChild(this._setupTab),c.appendChild(this._holdTab),n.appendChild(c),this._pathTableContainer=document.createElement("div"),this._pathTableContainer.className="timing-path-table-container",this._pathTable=document.createElement("table"),this._pathTable.className="timing-table",this._pathTableContainer.appendChild(this._pathTable),n.appendChild(this._pathTableContainer);let u=document.createElement("div");u.className="timing-tab-bar",this._dataTab=this._makeTab("Data Path",!0),this._captureTab=this._makeTab("Capture Path",!1),u.appendChild(this._dataTab),u.appendChild(this._captureTab),n.appendChild(u),this._detailTableContainer=document.createElement("div"),this._detailTableContainer.className="timing-detail-table-container",this._detailTable=document.createElement("table"),this._detailTable.className="timing-table",this._detailTableContainer.appendChild(this._detailTable),n.appendChild(this._detailTableContainer),this._headerTooltip=document.createElement("div"),this._headerTooltip.className="or-tooltip or-tooltip-fixed",n.appendChild(this._headerTooltip),this.element=n,this._bindEvents(),ua(this._app)&&setTimeout(()=>this.update(),0)}_makeTab(n,r){let c=document.createElement("button");return c.className="timing-tab"+(r?" active":""),c.textContent=n,c}_bindEvents(){this._setupTab.addEventListener("click",()=>{this._currentTab="setup",this._setupTab.classList.add("active"),this._holdTab.classList.remove("active"),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}),this._holdTab.addEventListener("click",()=>{this._currentTab="hold",this._holdTab.classList.add("active"),this._setupTab.classList.remove("active"),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}),this._dataTab.addEventListener("click",()=>{this._detailTab="data",this._dataTab.classList.add("active"),this._captureTab.classList.remove("active"),this._renderDetailTable()}),this._captureTab.addEventListener("click",()=>{this._detailTab="capture",this._captureTab.classList.add("active"),this._dataTab.classList.remove("active"),this._renderDetailTable()}),this._updateBtn.addEventListener("click",()=>this.update()),this._pathTableContainer.setAttribute("tabindex","0"),this._pathTableContainer.style.outline="none",this._pathTableContainer.addEventListener("keydown",n=>{if(n.key==="ArrowDown"){n.preventDefault();let r=this._pathTable.querySelectorAll("tbody tr");this._selectedPathIndex0&&this._selectPathRow(this._selectedPathIndex-1))}),this._detailTableContainer.setAttribute("tabindex","0"),this._detailTableContainer.style.outline="none",this._detailTableContainer.addEventListener("keydown",n=>{if(n.key==="ArrowDown"){n.preventDefault();let r=this._detailTable.querySelectorAll("tbody tr");this._selectedDetailIndex0&&this._selectDetailRow(this._selectedDetailIndex-1))})}_buildConePanel(){let n=document.createElement("div");n.className="timing-cone-panel";let r=document.createElement("span");r.className="timing-cone-title",r.textContent="Timing cone:",n.appendChild(r);let c=(T,M,L=!1)=>{let I=document.createElement("input");I.type="checkbox",I.id=T,I.checked=L;let D=document.createElement("label");return D.htmlFor=T,D.textContent=M,{input:I,lbl:D}},u=c("cone-fanin","Fanin",!0),d=c("cone-fanout","Fanout",!0);this._coneFanin=u.input,this._coneFanout=d.input,n.append(u.input,u.lbl,d.input,d.lbl);let b=T=>{let M=document.createElement("label");M.className="timing-cone-depth-label",M.textContent=T;let L=document.createElement("input");return L.type="number",L.min="0",L.value="0",L.className="timing-cone-depth",L.title="0 = unlimited",M.appendChild(L),{lbl:M,input:L}},w=b("in\u2264"),_=b("out\u2264");this._coneFaninDepth=w.input,this._coneFanoutDepth=_.input,n.append(w.lbl,_.lbl),this._coneColorMode=document.createElement("select"),this._coneColorMode.className="timing-cone-colormode";for(let[T,M]of[["slack","by slack"],["depth","by depth"]]){let L=document.createElement("option");L.value=T,L.textContent=M,this._coneColorMode.appendChild(L)}n.appendChild(this._coneColorMode);let x=c("cone-sync-schematic","Sync schematic");return this._coneSyncSchematic=x.input,n.append(x.input,x.lbl),this._coneApplyBtn=document.createElement("button"),this._coneApplyBtn.className="or-btn",this._coneApplyBtn.textContent="Cone",this._coneApplyBtn.title="Show the timing cone for the selected instance",this._coneClearBtn=document.createElement("button"),this._coneClearBtn.className="or-btn",this._coneClearBtn.textContent="Clear",n.append(this._coneApplyBtn,this._coneClearBtn),this._coneStatus=document.createElement("span"),this._coneStatus.className="timing-cone-status",n.appendChild(this._coneStatus),this._coneApplyBtn.addEventListener("click",()=>this._applyCone()),this._coneClearBtn.addEventListener("click",()=>this._clearCone()),n}_coneTarget(){return this._app.selectedInstanceName||""}async _applyCone(){let n=this._coneFanin.checked,r=this._coneFanout.checked;if(!n&&!r){this._coneStatus.textContent="select fanin and/or fanout";return}let c=this._coneTarget();if(!c){this._coneStatus.textContent="select an instance first";return}let u={type:"timing_cone",fanin:n,fanout:r,fanin_depth:Math.max(0,parseInt(this._coneFaninDepth.value,10)||0),fanout_depth:Math.max(0,parseInt(this._coneFanoutDepth.value,10)||0),color_mode:this._coneColorMode.value,inst_name:c};this._coneApplyBtn.disabled=!0,this._coneStatus.textContent="computing\u2026";try{let d=await this._app.websocketManager.request(u);this._refreshOverlay(),this._renderConeStatus(d),this._coneSyncSchematic.checked&&c&&document.dispatchEvent(new CustomEvent("openroad-cone-sync",{detail:{inst_name:c,fanin:u.fanin,fanout:u.fanout,fanin_depth:u.fanin_depth,fanout_depth:u.fanout_depth}}))}catch(d){this._coneStatus.textContent="cone error: "+(d.message||d)}this._coneApplyBtn.disabled=!1}_renderConeStatus(n){if(!n){this._coneStatus.textContent="";return}let r=n.node_count||0;if(r===0){this._coneStatus.textContent="empty cone";return}let c=r+" pins";if(n.color_mode==="depth")c+=`, depth \xB1${n.max_depth}`;else if(n.constrained){let u=n.time_unit||"";c+=`, slack ${lk(n.min_slack)}\u2026${lk(n.max_slack)}${u}`}else c+=", unconstrained";this._coneStatus.textContent=c}_clearCone(){this._app.websocketManager.request({type:"timing_cone",clear:!0}).then(()=>this._refreshOverlay()),this._coneStatus.textContent=""}showPaths(n,r){this._currentTab=n,n==="setup"?(this._setupPaths=[...r],this._setupTab.classList.add("active"),this._holdTab.classList.remove("active")):(this._holdPaths=[...r],this._holdTab.classList.add("active"),this._setupTab.classList.remove("active")),this._applySort(),this._selectedPathIndex=-1,this._pathCountLabel.textContent=r.length+" paths",this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...";try{let[n,r]=await Promise.all([this._app.websocketManager.request({type:"timing_report",is_setup:!0,max_paths:100}),this._app.websocketManager.request({type:"timing_report",is_setup:!1,max_paths:100})]);this._setupPaths=[...n.paths||[]],this._holdPaths=[...r.paths||[]],this._applySort(),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}catch(n){console.error("Timing fetch failed:",n)}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}_applySort(){for(let n of[this._setupPaths,this._holdPaths]){n.forEach((u,d)=>{u._originalIndex===void 0&&(u._originalIndex=d)});let r=this._sortAscending?1:-1,c=this._sortCol;n.sort((u,d)=>{let b=u[c],w=d[c],_=typeof b=="number"&&typeof w=="number"?b-w:String(b).localeCompare(String(w));return r*_})}}_showHeaderTooltip(n,r){if(n.buttons!==0){this._hideHeaderTooltip();return}let c=this._headerTooltip;c.textContent=r,c.style.display="block";let u=Math.min(n.clientX+12,window.innerWidth-c.offsetWidth-8);c.style.left=Math.max(0,u)+"px",c.style.top=n.clientY+14+"px"}_hideHeaderTooltip(){this._headerTooltip.style.display="none"}_sortBy(n){this._sortCol===n?this._sortAscending=!this._sortAscending:(this._sortCol=n,this._sortAscending=!0),this._applySort(),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}_clearTimingHighlight(){this._app.websocketManager.request({type:"timing_highlight",path_index:-1}).then(()=>this._refreshOverlay())}_selectPathRow(n){let r=this._pathTable.querySelectorAll("tbody tr");if(n<0||n>=r.length)return;this._selectedPathIndex=n;for(let d of r)d.classList.remove("selected");r[n].classList.add("selected"),r[n].scrollIntoView({block:"nearest"}),this._pathTableContainer.focus(),this._renderDetailTable();let u=(this._currentTab==="setup"?this._setupPaths:this._holdPaths)[n]?._originalIndex??n;this._app.websocketManager.request({type:"timing_highlight",path_index:u,is_setup:this._currentTab==="setup"}).then(()=>this._refreshOverlay()).catch(d=>console.error("timing_highlight error:",d))}_renderPathTable(){this._hideHeaderTooltip();let n=this._currentTab==="setup"?this._setupPaths:this._holdPaths;this._pathCountLabel.textContent=n.length+" paths";let r=this._pathTable.querySelectorAll("thead th"),c=Array.from(r,_=>_.style.width);this._pathTable.innerHTML="";let u=document.createElement("thead"),d=document.createElement("tr");for(let _ of s.PATH_COLS){let x=document.createElement("th");x.classList.add("sortable"),_.num&&x.classList.add("num"),x.textContent=_.label+(_.key===this._sortCol?this._sortAscending?" \u25B2":" \u25BC":""),_.tooltip&&(x.addEventListener("mousemove",T=>this._showHeaderTooltip(T,_.tooltip)),x.addEventListener("mouseleave",()=>this._hideHeaderTooltip())),x.addEventListener("click",()=>this._sortBy(_.key)),d.appendChild(x)}u.appendChild(d),this._pathTable.appendChild(u);let b=document.createElement("tbody"),w=n.reduce((_,x)=>Math.max(_,Math.abs(Number(x.slack)||0)),0);if(n.forEach((_,x)=>{let T=document.createElement("tr");x===this._selectedPathIndex&&T.classList.add("selected");for(let M of s.PATH_COLS){let L=document.createElement("td"),I=_[M.key];if(L.textContent=M.time?lk(I):I,M.num&&L.classList.add("num"),M.key==="slack"){let D=Number(_.slack);D<0&&L.classList.add("slack-negative"),Number.isFinite(D)&&w>0&&(L.classList.add("slack-cell",D<0?"slack-under":"slack-over"),L.style.setProperty("--slack-frac",String(Math.abs(D)/w)))}T.appendChild(L)}T.style.cursor="pointer",T.addEventListener("click",()=>this._selectPathRow(x)),b.appendChild(T)}),n.length===0){let _=document.createElement("tr"),x=document.createElement("td");x.colSpan=s.PATH_COLS.length,x.style.textAlign="center",x.style.color="var(--fg-secondary)",x.textContent=ua(this._app)?"No timing data available":'Click "Update" to load timing paths',_.appendChild(x),b.appendChild(_)}this._pathTable.appendChild(b),ak(this._pathTable,c)}_selectDetailRow(n){let r=this._detailTable.querySelectorAll("tbody tr");if(n<0||n>=r.length)return;this._selectedDetailIndex=n;for(let w of r)w.classList.remove("timing-selected-row");r[n].classList.add("timing-selected-row"),r[n].scrollIntoView({block:"nearest"}),this._detailTableContainer.focus();let u=(this._currentTab==="setup"?this._setupPaths:this._holdPaths)[this._selectedPathIndex],d=this._detailTab==="data"?u.data_nodes:u.capture_nodes,b=u._originalIndex??this._selectedPathIndex;this._app.websocketManager.request({type:"timing_highlight",path_index:b,is_setup:this._currentTab==="setup",pin_name:d[n].pin}).then(()=>this._refreshOverlay())}_renderDetailTable(){let n=this._detailTable.querySelectorAll("thead th"),r=Array.from(n,x=>x.style.width);this._detailTable.innerHTML="",this._selectedDetailIndex=-1;let c=this._currentTab==="setup"?this._setupPaths:this._holdPaths;if(this._selectedPathIndex<0||this._selectedPathIndex>=c.length)return;let u=c[this._selectedPathIndex],d=this._detailTab==="data"?u.data_nodes:u.capture_nodes,b=document.createElement("thead"),w=document.createElement("tr");for(let x of s.DETAIL_COLS){let T=document.createElement("th");s.DETAIL_NUM_COLS.has(x)&&T.classList.add("num"),T.textContent=x,w.appendChild(T)}b.appendChild(w),this._detailTable.appendChild(b);let _=document.createElement("tbody");if(d.forEach((x,T)=>{let M=document.createElement("tr");x.clk&&M.classList.add("timing-clock-row"),[x.pin,x.fanout,x.rise?"\u2191":"\u2193",lk(x.time),lk(x.delay),lk(x.slew),lk(x.load)].forEach((I,D)=>{let F=document.createElement("td");s.DETAIL_NUM_COLS.has(s.DETAIL_COLS[D])&&F.classList.add("num"),F.textContent=I,M.appendChild(F)}),M.style.cursor="pointer",M.addEventListener("click",()=>this._selectDetailRow(T)),_.appendChild(M)}),this._detailTable.appendChild(_),ak(this._detailTable,r),!r[0]){let x=this._detailTable.querySelector("thead th");x&&(x.style.width="30ch")}}};function lk(s){return s==null?"":typeof s=="number"?s.toFixed(4):String(s)}uk.PATH_COLS=[{label:"Clock",key:"end_clk"},{label:"Required",key:"required",time:!0,num:!0},{label:"Arrival",key:"arrival",time:!0,num:!0},{label:"Slack",key:"slack",time:!0,num:!0},{label:"Skew",key:"skew",time:!0,num:!0,tooltip:`The difference in arrival times between +
`,document.body.appendChild(u);let d=()=>u.remove();u.addEventListener("click",_=>{_.target===u&&d()}),u.addEventListener("keydown",_=>{_.key==="Escape"&&d()}),u.querySelector(".cancel").addEventListener("click",d),u.querySelector(".modal-close").addEventListener("click",d);let b=u.querySelector(".modal-error"),w=(_,x)=>{b.textContent=_,b.style.display=_?"block":"none",b.classList.toggle("info",!!x)};return{overlay:u,close:d,okBtn:u.querySelector(".ok"),showError:w}}var $hn=1e4,Vhn=150,Whn=3;function Hhn(s){return 1-(1-s)*(1-s)}var $he=class{constructor({isEnabled:n=()=>!0,isSmooth:r=()=>!1,reducedMotion:c=nH,now:u=()=>performance.now(),setTimer:d=(T,M)=>setTimeout(T,M),clearTimer:b=T=>clearTimeout(T),timeoutMs:w=$hn,fadeMs:_=Vhn,onChange:x=()=>{}}={}){Object.assign(this,{isEnabled:n,isSmooth:r,reducedMotion:c,now:u,setTimer:d,clearTimer:b,timeoutMs:w,fadeMs:_,onChange:x}),this.shownZ=null,this.pendingZ=null,this.under=[],this.fade=null,this._timer=null}wantedZ(){return this.pendingZ!==null?this.pendingZ:this.shownZ}setZoom(n,{hasContent:r=!0}={}){n!==this.wantedZ()&&(this.endFade(),this._clearTimer(),this.shownZ===null?(this.shownZ=n,this.pendingZ=null,this.under=[]):r?n===this.shownZ?this.pendingZ=null:this.isEnabled()?(this.pendingZ=n,this.under=[],this._timer=this.setTimer(()=>this.reveal(),this.timeoutMs)):(this.under=[...this.under.filter(c=>c!==n),this.shownZ].slice(-Whn),this.shownZ=n,this.pendingZ=null):(this.shownZ=n,this.pendingZ=null,this.under=this.under.filter(c=>c!==n)),this.onChange())}check({settled:n,animating:r=!1}){return this.pendingZ!==null?r||!n&&this.isEnabled()?!1:(this.reveal(),!0):this.under.length>0&&n&&!r?(this.under=[],this.onChange(),!0):!1}reveal(){if(this.pendingZ===null)return;this._clearTimer();let n=this.shownZ;this.shownZ=this.pendingZ,this.pendingZ=null;let r=this.isSmooth()&&!this.reducedMotion()?this.fadeMs:0;this.fade=r>0&&n!==null?{fromZ:n,toZ:this.shownZ,start:this.now(),ms:r}:null,this.onChange()}endFade(){this.fade&&(this.fade=null,this.onChange())}plan(n=this.now()){if(this.fade){let r=(n-this.fade.start)/this.fade.ms;if(r<1)return{draw:[{z:this.fade.fromZ,opacity:1},{z:this.fade.toZ,opacity:Hhn(Math.max(0,r))}],fading:!0};this.fade=null}return this.shownZ===null?{draw:[],fading:!1}:this.pendingZ!==null?{draw:[{z:this.shownZ,opacity:1}],fading:!1}:this.under.length>0?{draw:[...this.under,this.shownZ].map(r=>({z:r,opacity:1})),fading:!1}:{draw:[{z:this.shownZ,opacity:1}],fading:!1}}isIdle(n=this.now()){return this.pendingZ===null&&this.under.length===0&&!this.plan(n).fading}dispose(){this._clearTimer()}_clearTimer(){this._timer!==null&&(this.clearTimer(this._timer),this._timer=null)}};var bp=Object.freeze({base:10,overlay:20,heatmap:30,top:40,pathImage:50,selection:60,highlight:70,ruler:80}),ck={depthCompare:"always",depthWriteEnabled:!1},Yxt=250,Zxt=4,W5e=300,qhn=1,Xhn=2,Yhn=300,Zhn=300,Khn=400,Jhn=1e3,Kxt=100,Qhn=.05,Jxt=1200,Qxt=30;function Z1(s,n=1){if(Array.isArray(s)){let u=s.length>3?s[3]:255;return[s[0],s[1],s[2],Math.round(u*n)]}let r=String(s||"#000").replace("#","");r.length===3&&(r=r.split("").map(u=>u+u).join(""));let c=parseInt(r.slice(0,6),16)||0;return[c>>16&255,c>>8&255,c&255,Math.round(255*n)]}function edn(s){return 1-Math.pow(1-s,3)}function tdn(s){return s<.5?4*s*s*s:1-Math.pow(2-2*s,3)/2}function ndn(){let s=new Map;return{on(n,r){for(let c of n.split(/\s+/))s.has(c)||s.set(c,new Set),s.get(c).add(r)},off(n,r){for(let c of n.split(/\s+/))s.get(c)?.delete(r)},emit(n,r){for(let c of[...s.get(n)||[]])c(r)}}}function idn(s){let n=s&&s.device&&s.device.info||{};return{gpuType:n.gpuType||"unknown",renderer:n.renderer||"",vendor:n.vendor||""}}function e3t(s,n={}){let r=n.deckApi!==void 0?n.deckApi:globalThis.deck,c=n.copyCanvas||z5e,u={smooth:()=>!1,doubleBuffer:()=>!0,defer:()=>!1,...n.prefs||{}},d=n.tileSize||(()=>240),b=n.dpr||(()=>typeof devicePixelRatio=="number"?devicePixelRatio:1),w=n.raf||(Re=>requestAnimationFrame(Re)),_=n.now||(()=>performance.now()),x=ndn(),T={target:[0,0],zoom:0,width:1,height:1},M={minZoom:-1/0,maxZoom:Qxt},L=null,I=!1,D=[],F=null,O=[],z=null,Z=null,H=!1,te=!1,oe=0,ne=new Set,ue=!1;s.classList.add("or-view");let Te=document.createElement("div");Te.className="or-view-canvas",s.appendChild(Te);let Q=document.createElement("div");Q.className="or-view-markers",s.appendChild(Q);let ge=new Map,Qe=new Map,st=new Map,at=new Map,Ne=new WeakMap,tt=[],ot=yT(_i,w),Tt=new $he({isEnabled:()=>u.doubleBuffer(),isSmooth:()=>u.smooth(),now:_,onChange:()=>ot()}),jt=null;function en(){return{dragPan:!0,dragRotate:!1,scrollZoom:!1,doubleClickZoom:!1,touchZoom:!n.isStatic,touchRotate:!1,keyboard:!1,inertia:!1}}function mn(){return{target:[T.target[0],T.target[1],0],zoom:T.zoom,minZoom:M.minZoom,maxZoom:M.maxZoom}}function cn(){return new r.Deck({parent:Te,views:new r.OrthographicView({id:"main",flipY:!1,controller:en()}),viewState:mn(),layers:[],useDevicePixels:!0,deviceProps:{webgl:{preserveDrawingBuffer:!!n.preserveDrawingBuffer}},getCursor:({isDragging:Re})=>ne.size?"crosshair":Re?"grabbing":"default",onViewStateChange:({viewState:Re})=>{if(L=null,Yi(Re.target,Re.zoom),I){let nt=_();O.push({t:nt,target:[...T.target],zoom:T.zoom}),O=O.filter(kt=>nt-kt.t<=Kxt)}return mn()},onInteractionStateChange:Re=>{let nt=!!(Re.isDragging||Re.isPanning||Re.isZooming||Re.inTransition);if(nt!==I){if(I=nt,nt){O=[],Tr();return}queueMicrotask(()=>{!I&&!L&&!Si()&&wr()})}},onLoad:()=>{bi(),F=idn(jt),x.emit("renderer",F),ot()},onError:Re=>{console.error("Layout view:",Re),F||(F={gpuType:"none",renderer:"",vendor:""},x.emit("renderer",F))},onAfterRender:()=>{let Re=D;D=[],Re.forEach(nt=>nt())}})}function bi(){let Re=jt.getCanvas&&jt.getCanvas();Re?.addEventListener("webglcontextlost",nt=>{if(nt.preventDefault(),ue)return;x.emit("contextlost");let kt=jt;jt=null,Ne=new WeakMap,tt=[];try{kt.finalize?.()}catch{}Re.remove();try{jt=cn(),x.emit("contextrestored")}catch(xn){x.emit("contextfailed",xn)}ot()})}r&&typeof r.Deck=="function"&&(jt=cn());function Vt(){let Re=b(),nt=Math.max(1,Math.floor(s.clientWidth*Re)/Re),kt=Math.max(1,Math.floor(s.clientHeight*Re)/Re),xn=nt!==T.width||kt!==T.height;return T.width=nt,T.height=kt,Te.style.width=nt+"px",Te.style.height=kt+"px",xn}Vt();let pn=null;typeof ResizeObserver=="function"&&(pn=new ResizeObserver(()=>qn()),pn.observe(s));function qn(){Vt()?($i(),x.emit("resize",ar())):ot()}function Yi(Re,nt,{tiles:kt=!0}={}){let xn=rk(nt,M),Ei=xn!==T.zoom;T.target=[Re[0],Re[1]],T.zoom=xn,$i(Ei,kt)}function $i(Re=!1,nt=!0){jt&&jt.setProps({viewState:mn()}),Re&&x.emit("zoom"),x.emit("move"),nt&&hr(),ot()}function Tr(){te||(te=!0,x.emit("movestart"))}function wr(){if(L||I)return;let Re=Math.round(T.zoom);if(Math.abs(Re-T.zoom)>1e-9){se({target:Nhe(T,[T.width/2,T.height/2],Re),zoom:Re},{anchor:null});return}T.target=lxt(T,b());let nt=te;te=!1,$i(),nt&&(x.emit("moveend"),x.emit("zoomend"))}function Si(){let Re=O;if(O=[],!u.smooth()||Re.length<2)return!1;let nt=Re[0],kt=Re[Re.length-1],xn=kt.t-nt.t;if(xn<=0||_()-kt.t>Kxt||nt.zoom!==kt.zoom)return!1;let Ei=(kt.target[0]-nt.target[0])/xn,Xi=(kt.target[1]-nt.target[1])/xn;return Math.hypot(Ei,Xi)*Math.pow(2,T.zoom)Zxt?0:Yxt}function se(Re,{anchor:nt=null,ms:kt=void 0,settle:xn=!0,curve:Ei=!1}={}){Re={target:Re.target,zoom:rk(Re.zoom,M)};let Xi=Ei&&kt===void 0?de(Re):null;if(kt===void 0&&(kt=Xi?Xi.ms:Fr(Re)),Tr(),Re.zoom!==T.zoom&&x.emit("zoomstart"),kt<=0){L=null;let cr=xn&&!I;Yi(Re.target,Re.zoom,{tiles:!cr}),xn&&wr();return}Z=null,L={from:{...T,target:[...T.target]},to:Re,anchor:nt,start:Xi?null:_(),created:_(),ms:kt,flight:Xi},hr(),We()}function de(Re){if(!u.smooth()||!(Math.hypot(Re.target[0]-T.target[0],Re.target[1]-T.target[1])*Math.pow(2,Math.min(T.zoom,Re.zoom))>Xhn*Math.max(T.width,T.height))&&Math.abs(Re.zoom-T.zoom)<=Zxt)return null;let xn=uxt(T,{...T,...Re}),Ei=1/0,Xi=null;for(let Ks=0;Ks<=16;Ks++){let Bi=xn.at(Ks/16);Ei=Math.min(Ei,Bi.zoom);let io=_O({...T,...Bi});Xi=Xi?[Math.min(Xi[0],io[0]),Math.min(Xi[1],io[1]),Math.max(Xi[2],io[2]),Math.max(Xi[3],io[3])]:io}let cr=Math.max(0,k5e(Ei)),So=KW(Xi,cr,d());return{path:xn,ms:Math.min(Jhn,Math.max(Khn,Zhn*xn.S)),apex:So?{z:cr,range:So}:null}}function it(Re){return!Re||[...ge.values()].every(nt=>!nt.visible||nt.grid.settledIn(Re.z,Re.range))}function We(){if(!L||ue)return;if(L.start===null){if(!it(L.flight.apex)&&_()-L.created=1){let Ei=L.to;Z=L.flight?L.flight.apex:null,L=null,Yi(Ei.target,Ei.zoom),wr();return}Yi(xn,kt),w(We)}function En(){return L?{...T,target:L.to.target,zoom:L.to.zoom}:T}function hr(){if(ge.size===0)return;let Re=u.doubleBuffer(),nt=rk(k5e(T.zoom,{targetZoom:L?L.to.zoom:null,hidingNewLevels:Re}),{minZoom:0,maxZoom:Qxt}),kt=En(),xn=KW(_O(kt),nt,d()),Ei=Fhe(xn),Xi=Tt.shownZ,cr=u.defer()&&I;cr||Tt.setZoom(nt,{hasContent:[...ge.values()].some(io=>io.visible&&Xi!==null&&io.grid.hasContentAt(Xi))});let So=[];nt>0&&!L&&!I&&!te&&Tt.pendingZ===null&&(z=nt-1,So.push({z,range:KW(R5e(_O(kt),qhn),z,d())}));let Ks=qi();Ks&&So.push({...Ks,background:!1});let Bi=L?KW(_O(T),nt,d()):null;for(let io of ge.values())io.visible&&!cr&&io.grid.update({z:nt,range:xn,ring:Ei,extra:So,hold:Bi});gn()}function qi(){return L&&L.flight&&L.flight.apex||Z}function Me(Re){let nt=[];for(let kt of[qi()?.z,Tt.pendingZ])kt!=null&&!nt.includes(kt)&&!Re.some(xn=>xn.z===kt)&&nt.push(kt);return nt}function ve(){H||(H=!0,queueMicrotask(()=>{H=!1,ue||hr()}))}function wt(){for(let Re of ge.values())if(Re.visible&&!Re.grid.isSettled())return!1;return!0}function gn(Re){let nt=Tt.check({settled:wt(),animating:!!L});nt&&Tt.pendingZ===null&&ve();let kt=!1;Z&&!L&&Tt.isIdle()&&wt()&&(Z=null,kt=!0),(nt||kt||!Re||vn(Re.z))&&ot()}function vn(Re){let nt=Tt.plan(_()).draw;return nt.some(kt=>kt.z===Re)||Me(nt).includes(Re)}function Mn(Re,{order:nt,source:kt,visible:xn=!0}){let Ei={load:(cr,So)=>kt.load(cr,So),release:cr=>{let So=cr&&Ne.get(cr);So&&(Ne.delete(cr),tt.push(So)),kt.release?.(cr)}},Xi={id:Re,order:nt,visible:xn,grid:new Uhe({source:Ei,onChange:cr=>gn(cr)})};return ge.set(Re,Xi),hr(),{id:Re,setVisible(cr){Xi.visible!==!!cr&&(Xi.visible=!!cr,Xi.visible||Xi.grid.clear(),hr())},isVisible:()=>Xi.visible,refresh(){Xi.visible&&(Xi.grid.refresh(),ot())},remove(){Xi.grid.clear(),ge.delete(Re),ot()}}}function xi(Re){if(!jt||!jt.device)return Re.image;let nt=Ne.get(Re);if(!nt){try{nt=jt.device.createTexture({data:Re.image,width:Re.width,height:Re.height,mipLevels:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}})}catch{return Re.image}Ne.set(Re,nt)}return nt}function mi(Re){if(Re>=oe)return 1;let nt=(Jxt-(oe-Re))%400/400;return 1-.7*(.5-.5*Math.cos(2*Math.PI*nt))}let ri=new WeakMap,Ge=null;function Ae(Re){let nt=d();nt!==Ge&&(ri=new WeakMap,Ge=nt);let kt=ri.get(Re);return kt||(kt=cxt(Re.z,Re.x,Re.y,nt),ri.set(Re,kt)),kt}function Le(Re,nt,kt,xn,Ei,Xi){for(let cr of nt.grid.drawableTilesAt(kt)){let So=Ae(cr);I5e(So,xn)&&Re.push({order:nt.order,props:{id:`${nt.id}:${Ei}${cr.key}`,image:xi(cr.drawable),bounds:So,opacity:Xi,parameters:ck}})}}function ht(Re,nt){let kt=[],xn=Tt.plan(Re);if(!xn.fading&&Tt.pendingZ===null&&xn.draw.length>0){let Ks=[...xn.draw.map(Bi=>Bi.z),z,qi()?.z].filter(Bi=>Bi!=null);for(let Bi of ge.values())Bi.grid.prune(Ks)}let Ei=mi(Re),Xi=[...ge.values()].sort((Ks,Bi)=>Ks.order-Bi.order),cr=Xi.find(Ks=>Ks.visible),So=Me(xn.draw);for(let Ks of Xi)if(Ks.visible){Ks===cr&&So.length>0&&kt.push(...Ye(Ks,So,xn.draw,nt,Ei));for(let Bi of xn.draw)Le(kt,Ks,Bi.z,nt,"",Bi.opacity*Ei)}return{layers:kt,animate:xn.fading||Reio.z===Ks.z)||Ks.loading&&!Ks.drawable)continue;let Bi=Ae(Ks);if(I5e(Bi,xn)){let[io,mf,J1,Lm]=Bi;So.push([[io-cr,mf-cr],[J1+cr,mf-cr],[J1+cr,Lm+cr],[io-cr,Lm+cr]])}}return So.length&&Xi.push({order:Re.order,kind:"SolidPolygonLayer",props:{id:`${Re.id}:mask`,data:So,getPolygon:Ks=>Ks,getFillColor:ct(),parameters:ck}}),Xi}function ct(){let Re=(getComputedStyle(s).backgroundColor||"").match(/[\d.]+/g);return!Re||Re.length<3||Re.length>3&&Number(Re[3])===0?[0,0,0,255]:[Number(Re[0]),Number(Re[1]),Number(Re[2]),255]}function Ze(Re,nt,kt){let xn=[],Ei=[],Xi=[],cr=[];for(let Bi of nt){if(Bi.kind==="circle"){cr.push(Bi);continue}let io=Bi.kind==="rect"?[[Bi.rect[0],Bi.rect[1]],[Bi.rect[2],Bi.rect[1]],[Bi.rect[2],Bi.rect[3]],[Bi.rect[0],Bi.rect[3]]]:Bi.points;if(Bi.fill&&Ei.push({polygon:io,color:Bi.fill}),Bi.stroke){let mf=Bi.kind==="rect"||Bi.closed;Xi.push({path:mf?[...io,io[0]]:io,color:Bi.stroke,width:Bi.width||1,dash:Bi.dash||null})}}Ei.length&&xn.push({order:kt,kind:"SolidPolygonLayer",props:{id:`${Re}:fill`,data:Ei,getPolygon:Bi=>Bi.polygon,getFillColor:Bi=>Bi.color,parameters:ck}});let So=Xi.filter(Bi=>!Bi.dash),Ks=Xi.filter(Bi=>Bi.dash);if(So.length&&xn.push({order:kt,kind:"PathLayer",props:{id:`${Re}:stroke`,data:So,widthUnits:"pixels",getPath:Bi=>Bi.path,getColor:Bi=>Bi.color,getWidth:Bi=>Bi.width,parameters:ck}}),Ks.length){let Bi={id:`${Re}:dash`,data:Ks,widthUnits:"pixels",getPath:io=>io.path,getColor:io=>io.color,getWidth:io=>io.width,getDashArray:io=>io.dash.map(mf=>mf/io.width),dashJustified:!0,parameters:ck};r?.PathStyleExtension&&(Bi.extensions=[new r.PathStyleExtension({dash:!0})]),xn.push({order:kt,kind:"PathLayer",props:Bi})}return cr.length&&xn.push({order:kt,kind:"ScatterplotLayer",props:{id:`${Re}:circle`,data:cr,radiusUnits:"pixels",lineWidthUnits:"pixels",getPosition:Bi=>Bi.center,getRadius:Bi=>Bi.radius,stroked:!0,filled:!0,getLineColor:Bi=>Bi.stroke||[0,0,0,0],getFillColor:Bi=>Bi.fill||[0,0,0,0],getLineWidth:Bi=>Bi.width||1,parameters:ck}}),xn}function Ke(){let Re=[];for(let nt of Qe.values())Re.push(...nt);return Re.push(...st.values()),Re}function pt(Re){return Re.map(nt=>new r[nt.kind||"BitmapLayer"](nt.props))}let Xn=0;function _i(){if(ue)return;let Re=_(),nt=ht(Re,R5e(_O(T),.5)),kt=[...nt.layers,...Ke()].sort((xn,Ei)=>xn.order-Ei.order);Xn=kt.length,jt&&jt.setProps({layers:pt(kt)});for(let xn of tt.splice(0))xn.destroy?.();ei(),nt.animate&&ot(),x.emit("render")}function Hi(Re=32,nt=20){let kt=ge.get("base");if(!kt)return null;let xn=d(),Ei=Tt.plan(_()).draw,Xi=[...Ei,...Me(Ei).map(Ks=>({z:Ks}))],cr=0,So=0;for(let Ks=0;Ks=xn||mf>=xn)continue;cr++,Xi.some(({z:Lm})=>{let b2=xn/2**Lm,zb=kt.grid.tiles.get(yO(Lm,Math.floor(io/b2),Math.floor((xn-mf)/b2)));return zb&&(zb.drawable||!zb.loading)})&&So++}return cr?So/cr:null}function _n(Re){return at.has(Re)||at.set(Re,{visible:!0,items:new Map}),at.get(Re)}function Je(Re,nt){let[kt,xn]=Ohe(Re.world,T);Re.el.style.display=nt?"":"none",Re.el.style.transform=`translate(${kt}px, ${xn}px)`+(Re.center?" translate(-50%, -50%)":"")}function Qn(Re){for(let nt of Re.items.values())Je(nt,Re.visible)}function ei(){for(let Re of at.values())Qn(Re)}function ar(){return{width:T.width,height:T.height}}let yn={DRAW_ORDER:bp,getContainer:()=>s,getRendererInfo:()=>F,getSize:ar,getZoom:()=>T.zoom,getTargetZoom:()=>L?L.to.zoom:T.zoom,getCenter:()=>[...T.target],getViewState:()=>({...T,target:[...T.target]}),isAnimating:()=>!!L,isMoving:()=>te,project:Re=>Ohe(Re,T),unproject:Re=>vO(Re,T),on:x.on,off:x.off,setLimits({minZoom:Re,maxZoom:nt}={}){Re!==void 0&&(M.minZoom=Re),nt!==void 0&&(M.maxZoom=nt);let kt=rk(T.zoom,M);kt!==T.zoom?Yi(T.target,kt):jt&&jt.setProps({viewState:mn()}),x.emit("limits")},getLimits:()=>({...M}),setView(Re,nt=T.zoom,{animate:kt}={}){let xn={target:[Re[0],Re[1]],zoom:nt};se(xn,kt===!1?{ms:0}:{curve:!0})},fitWorldRect(Re,{padding:nt=[0,0],animate:kt}={}){let xn=axt(Re,T,{padding:nt,...M});se(xn,kt===!1?{ms:0}:{curve:!0})},zoomAround(Re,nt,{animate:kt,settle:xn=!0}={}){let Ei=rk(yn.getTargetZoom()+nt,M),Xi=En(),cr=Re||[T.width/2,T.height/2],So=Nhe(Xi,cr,Ei);se({target:So,zoom:Ei},kt===!1?{ms:0,settle:xn}:{anchor:Re?cr:null})},zoomIn:()=>yn.zoomAround(null,1),zoomOut:()=>yn.zoomAround(null,-1),panByPx(Re,nt,{animate:kt}={}){let xn=En(),Ei=Math.pow(2,xn.zoom),Xi=[xn.target[0]+Re/Ei,xn.target[1]-nt/Ei],cr=kt===!1||!u.smooth()?0:Yxt;se({target:Xi,zoom:xn.zoom},{ms:cr})},invalidateSize:qn,applyPrefs(){hr()},addTileSlot:Mn,setOverlay(Re,nt,{order:kt=bp.selection}={}){!nt||nt.length===0?Qe.delete(Re):Qe.set(Re,Ze(Re,nt,kt)),ot()},hasOverlay:Re=>Qe.has(Re),setImageOverlay(Re,nt,{order:kt=bp.pathImage}={}){nt?st.set(Re,{order:kt,kind:"BitmapLayer",props:{id:`image:${Re}`,image:nt.image,bounds:nt.rect,parameters:ck}}):st.delete(Re),ot()},addMarker(Re,nt,kt,xn,{center:Ei=!1}={}){let Xi=_n(Re),cr=Xi.items.get(nt);cr&&cr.el.remove(),xn.classList.add("or-view-marker"),Q.appendChild(xn);let So={el:xn,world:[kt[0],kt[1]],center:Ei};return Xi.items.set(nt,So),Je(So,Xi.visible),xn},moveMarker(Re,nt,kt){let xn=_n(Re),Ei=xn.items.get(nt);Ei&&(Ei.world=[kt[0],kt[1]],Je(Ei,xn.visible))},clearMarkers(Re){let nt=_n(Re);for(let kt of nt.items.values())kt.el.remove();nt.items.clear()},setMarkerGroupVisible(Re,nt){let kt=_n(Re);kt.visible=!!nt,Qn(kt)},setCursorMode(Re,nt=!0){nt?ne.add(Re):ne.delete(Re),s.classList.toggle(`${Re}-mode-cursor`,!!nt);let kt=jt&&jt.getCanvas&&jt.getCanvas();kt&&(kt.style.cursor=ne.size?"crosshair":"default")},flashTiles(){oe=_()+Jxt,ot()},whenTilesSettled({timeoutMs:Re=6e3}={}){let nt=_()+Re;return new Promise(kt=>{let xn=()=>{if(wt()&&Tt.isIdle()&&!L&&!te||_()>=nt){kt();return}setTimeout(xn,32)};xn()})},captureCanvas({timeoutMs:Re=500}={}){return jt?.getCanvas()?(_i(),new Promise(nt=>{let kt=null,xn=()=>{clearTimeout(kt),D=D.filter(Xi=>Xi!==xn);let Ei=jt?.getCanvas();nt(Ei?{image:c(Ei),rect:Ei.getBoundingClientRect()}:null)};D.push(xn),kt=setTimeout(()=>{jt?.redraw("capture"),xn()},Re)})):Promise.resolve(null)},redraw:()=>ot(),debugSnapshot(){let Re=Tt.plan();return{zoom:T.zoom,target:[...T.target],width:T.width,height:T.height,animating:!!L,moving:te,interacting:I,shownZ:Tt.shownZ,pendingZ:Tt.pendingZ,fading:Re.fading,drawLevels:Re.draw,layers:Xn,coverage:Hi(),overlays:[...Qe.keys()],markers:Object.fromEntries([...at].map(([nt,kt])=>[nt,kt.items.size])),slots:[...ge.values()].map(nt=>({id:nt.id,visible:nt.visible,settled:nt.grid.isSettled(),...nt.grid.stats()}))}},destroy(){ue=!0,pn?.disconnect(),Tt.dispose();for(let Re of ge.values())Re.grid.clear();jt?.finalize?.()}};return yn}var rdn=4.000244140625;function sdn(s){return s.deltaMode!==0?!0:s.deltaX!==0||s.deltaY===0?!1:Number.isInteger(s.deltaY)&&Math.abs(s.deltaY)>=50||s.deltaY%rdn===0}function odn(s){let n=Math.abs(s);return n<.2?0:Math.sign(s)*Math.max(1,Math.round(n))}function adn(s,n){let c=1;return s.deltaMode===1?c=16:s.deltaMode===2&&(c=n.clientHeight||16),[s.deltaX*c,s.deltaY*c]}function cdn(s,n,r){let c=r?3*n:n;switch(s){case"ArrowLeft":return[-c,0];case"ArrowRight":return[c,0];case"ArrowUp":return[0,-c];case"ArrowDown":return[0,c];default:return null}}function n3t(s,n={}){let r=s.getContainer(),c=n.isStatic||(()=>!1),u=n.wheelZoom||(()=>!0),d=n.arrowStep||(()=>80),b=n.gestureIdleMs??200,w=n.contextEnabled||(()=>!0),_=[],x=(ne,ue,Te,Q)=>{ne.addEventListener(ue,Te,Q),_.push(()=>ne.removeEventListener(ue,Te,Q))},T=ne=>{let ue=r.getBoundingClientRect();return[ne.clientX-ue.left,ne.clientY-ue.top]},M=ne=>s.unproject(T(ne)),L=ne=>ne.target===r||!!ne.target?.closest?.(".or-view-canvas");r.tabIndex<0&&(r.tabIndex=0);let I=null;function D(ne,ue){I||(I={z0:s.getZoom()}),I.pt=ne,clearTimeout(I.timer),I.timer=setTimeout(F,b),s.zoomAround(ne,ue,{animate:!1,settle:!1})}function F(){if(!I)return;let ne=I;I=null,clearTimeout(ne.timer);let ue=s.getZoom();s.zoomAround(ne.pt,ne.z0+odn(ue-ne.z0)-ue)}_.push(()=>{clearTimeout(I?.timer),I=null}),x(r,"wheel",ne=>{if(ne.preventDefault(),c())return;let ue=sdn(ne);if(!ue&&ne.ctrlKey){D(T(ne),-ne.deltaY/(100*Math.LN2));return}if(u()===ne.ctrlKey){let[Te,Q]=adn(ne,r);s.panByPx(Te,Q,{animate:!1});return}if(!ue){D(T(ne),-ne.deltaY/100);return}F(),s.zoomAround(T(ne),ne.deltaY<0?1:-1)},{passive:!1}),x(r,"keydown",ne=>{if(ne.altKey||ne.ctrlKey||ne.metaKey)return;let ue=cdn(ne.key,d(),ne.shiftKey);if(ue){ne.preventDefault(),s.panByPx(ue[0],ue[1]);return}if(c())return;let Te={"+":1,"=":1,"-":-1,_:-1};ne.key in Te&&(ne.preventDefault(),s.zoomAround(null,Te[ne.key]*(ne.shiftKey?3:1)))});let O=null,z=null;x(r,"pointerdown",ne=>{ne.button!==0||!L(ne)||(r.focus({preventScroll:!0}),O={x:ne.clientX,y:ne.clientY,moved:!1,box:ne.shiftKey&&!c()},O.box&&ne.stopPropagation())},{capture:!0}),x(window,"pointermove",ne=>{if(!O)return;let ue=ne.clientX-O.x,Te=ne.clientY-O.y;(Math.abs(ue)>3||Math.abs(Te)>3)&&(O.moved=!0),O.box&&O.moved&&(z=t3t(z,O,ne))}),x(window,"pointerup",ne=>{if(!O||ne.button!==0)return;let ue=O;if(O=null,z&&(z.remove(),z=null),ue.box&&ue.moved){oe(ue,ne);return}!ue.moved&&n.onClick&&te(ne)&&n.onClick(M(ne),ne)}),x(r,"dblclick",ne=>{c()||!L(ne)||s.zoomAround(T(ne),ne.shiftKey?-1:1)});let Z=null,H=null;x(r,"contextmenu",ne=>ne.preventDefault()),x(r,"pointerdown",ne=>{ne.button!==2||c()||!L(ne)||(ne.stopPropagation(),Z={x:ne.clientX,y:ne.clientY})},{capture:!0}),x(window,"pointermove",ne=>{if(!Z)return;let ue=ne.clientX-Z.x,Te=ne.clientY-Z.y;(H||Math.abs(ue)>=4&&Math.abs(Te)>=4)&&(H=t3t(H,Z,ne))}),x(window,"pointerup",ne=>{if(!Z||ne.button!==2)return;let ue=Z;if(Z=null,H){H.remove(),H=null,oe(ue,ne);return}te(ne)&&w()&&n.onContextClick&&n.onContextClick(M(ne),ne)}),x(r,"pointermove",ne=>{n.onMove&&n.onMove(M(ne),ne)}),x(r,"pointerleave",ne=>{n.onLeave&&n.onLeave(ne)});function te(ne){let ue=r.getBoundingClientRect();return ne.clientX>=ue.left&&ne.clientX<=ue.right&&ne.clientY>=ue.top&&ne.clientY<=ue.bottom}function oe(ne,ue){let Te=r.getBoundingClientRect(),Q=s.unproject([ne.x-Te.left,ne.y-Te.top]),ge=s.unproject([ue.clientX-Te.left,ue.clientY-Te.top]);s.fitWorldRect([Math.min(Q[0],ge[0]),Math.min(Q[1],ge[1]),Math.max(Q[0],ge[0]),Math.max(Q[1],ge[1])])}return{dispose(){for(let ne of _.splice(0))ne()}}}function t3t(s,n,r){return s||(s=document.createElement("div"),s.className="rubber-band",document.body.appendChild(s)),s.style.left=Math.min(n.x,r.clientX)+"px",s.style.top=Math.min(n.y,r.clientY)+"px",s.style.width=Math.abs(r.clientX-n.x)+"px",s.style.height=Math.abs(r.clientY-n.y)+"px",s}var uk=class s{constructor(n,r,c){this._app=n,this._redrawAllLayers=r,this._refreshOverlay=c||r,this._currentTab="setup",this._setupPaths=[],this._holdPaths=[],this._selectedPathIndex=-1,this._detailTab="data",this._selectedDetailIndex=-1,this._sortCol="slack",this._sortAscending=!0,this._build()}_build(){let n=document.createElement("div");n.className="timing-widget";let r=document.createElement("div");r.className="timing-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",ua(this._app)&&(this._updateBtn.style.display="none"),this._pathCountLabel=document.createElement("span"),this._pathCountLabel.className="timing-path-count",r.appendChild(this._updateBtn),r.appendChild(this._pathCountLabel),n.appendChild(r),n.appendChild(this._buildConePanel());let c=document.createElement("div");c.className="timing-tab-bar",this._setupTab=this._makeTab("Setup",!0),this._holdTab=this._makeTab("Hold",!1),c.appendChild(this._setupTab),c.appendChild(this._holdTab),n.appendChild(c),this._pathTableContainer=document.createElement("div"),this._pathTableContainer.className="timing-path-table-container",this._pathTable=document.createElement("table"),this._pathTable.className="timing-table",this._pathTableContainer.appendChild(this._pathTable),n.appendChild(this._pathTableContainer);let u=document.createElement("div");u.className="timing-tab-bar",this._dataTab=this._makeTab("Data Path",!0),this._captureTab=this._makeTab("Capture Path",!1),u.appendChild(this._dataTab),u.appendChild(this._captureTab),n.appendChild(u),this._detailTableContainer=document.createElement("div"),this._detailTableContainer.className="timing-detail-table-container",this._detailTable=document.createElement("table"),this._detailTable.className="timing-table",this._detailTableContainer.appendChild(this._detailTable),n.appendChild(this._detailTableContainer),this._headerTooltip=document.createElement("div"),this._headerTooltip.className="or-tooltip or-tooltip-fixed",n.appendChild(this._headerTooltip),this.element=n,this._bindEvents(),ua(this._app)&&setTimeout(()=>this.update(),0)}_makeTab(n,r){let c=document.createElement("button");return c.className="timing-tab"+(r?" active":""),c.textContent=n,c}_bindEvents(){this._setupTab.addEventListener("click",()=>{this._currentTab="setup",this._setupTab.classList.add("active"),this._holdTab.classList.remove("active"),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}),this._holdTab.addEventListener("click",()=>{this._currentTab="hold",this._holdTab.classList.add("active"),this._setupTab.classList.remove("active"),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}),this._dataTab.addEventListener("click",()=>{this._detailTab="data",this._dataTab.classList.add("active"),this._captureTab.classList.remove("active"),this._renderDetailTable()}),this._captureTab.addEventListener("click",()=>{this._detailTab="capture",this._captureTab.classList.add("active"),this._dataTab.classList.remove("active"),this._renderDetailTable()}),this._updateBtn.addEventListener("click",()=>this.update()),this._pathTableContainer.setAttribute("tabindex","0"),this._pathTableContainer.style.outline="none",this._pathTableContainer.addEventListener("keydown",n=>{if(n.key==="ArrowDown"){n.preventDefault();let r=this._pathTable.querySelectorAll("tbody tr");this._selectedPathIndex0&&this._selectPathRow(this._selectedPathIndex-1))}),this._detailTableContainer.setAttribute("tabindex","0"),this._detailTableContainer.style.outline="none",this._detailTableContainer.addEventListener("keydown",n=>{if(n.key==="ArrowDown"){n.preventDefault();let r=this._detailTable.querySelectorAll("tbody tr");this._selectedDetailIndex0&&this._selectDetailRow(this._selectedDetailIndex-1))})}_buildConePanel(){let n=document.createElement("div");n.className="timing-cone-panel";let r=document.createElement("span");r.className="timing-cone-title",r.textContent="Timing cone:",n.appendChild(r);let c=(T,M,L=!1)=>{let I=document.createElement("input");I.type="checkbox",I.id=T,I.checked=L;let D=document.createElement("label");return D.htmlFor=T,D.textContent=M,{input:I,lbl:D}},u=c("cone-fanin","Fanin",!0),d=c("cone-fanout","Fanout",!0);this._coneFanin=u.input,this._coneFanout=d.input,n.append(u.input,u.lbl,d.input,d.lbl);let b=T=>{let M=document.createElement("label");M.className="timing-cone-depth-label",M.textContent=T;let L=document.createElement("input");return L.type="number",L.min="0",L.value="0",L.className="timing-cone-depth",L.title="0 = unlimited",M.appendChild(L),{lbl:M,input:L}},w=b("in\u2264"),_=b("out\u2264");this._coneFaninDepth=w.input,this._coneFanoutDepth=_.input,n.append(w.lbl,_.lbl),this._coneColorMode=document.createElement("select"),this._coneColorMode.className="timing-cone-colormode";for(let[T,M]of[["slack","by slack"],["depth","by depth"]]){let L=document.createElement("option");L.value=T,L.textContent=M,this._coneColorMode.appendChild(L)}n.appendChild(this._coneColorMode);let x=c("cone-sync-schematic","Sync schematic");return this._coneSyncSchematic=x.input,n.append(x.input,x.lbl),this._coneApplyBtn=document.createElement("button"),this._coneApplyBtn.className="or-btn",this._coneApplyBtn.textContent="Cone",this._coneApplyBtn.title="Show the timing cone for the selected instance",this._coneClearBtn=document.createElement("button"),this._coneClearBtn.className="or-btn",this._coneClearBtn.textContent="Clear",n.append(this._coneApplyBtn,this._coneClearBtn),this._coneStatus=document.createElement("span"),this._coneStatus.className="timing-cone-status",n.appendChild(this._coneStatus),this._coneApplyBtn.addEventListener("click",()=>this._applyCone()),this._coneClearBtn.addEventListener("click",()=>this._clearCone()),n}_coneTarget(){return this._app.selectedInstanceName||""}async _applyCone(){let n=this._coneFanin.checked,r=this._coneFanout.checked;if(!n&&!r){this._coneStatus.textContent="select fanin and/or fanout";return}let c=this._coneTarget();if(!c){this._coneStatus.textContent="select an instance first";return}let u={type:"timing_cone",fanin:n,fanout:r,fanin_depth:Math.max(0,parseInt(this._coneFaninDepth.value,10)||0),fanout_depth:Math.max(0,parseInt(this._coneFanoutDepth.value,10)||0),color_mode:this._coneColorMode.value,inst_name:c};this._coneApplyBtn.disabled=!0,this._coneStatus.textContent="computing\u2026";try{let d=await this._app.websocketManager.request(u);this._refreshOverlay(),this._renderConeStatus(d),this._coneSyncSchematic.checked&&c&&document.dispatchEvent(new CustomEvent("openroad-cone-sync",{detail:{inst_name:c,fanin:u.fanin,fanout:u.fanout,fanin_depth:u.fanin_depth,fanout_depth:u.fanout_depth}}))}catch(d){this._coneStatus.textContent="cone error: "+(d.message||d)}this._coneApplyBtn.disabled=!1}_renderConeStatus(n){if(!n){this._coneStatus.textContent="";return}let r=n.node_count||0;if(r===0){this._coneStatus.textContent="empty cone";return}let c=r+" pins";if(n.color_mode==="depth")c+=`, depth \xB1${n.max_depth}`;else if(n.constrained){let u=n.time_unit||"";c+=`, slack ${lk(n.min_slack)}\u2026${lk(n.max_slack)}${u}`}else c+=", unconstrained";this._coneStatus.textContent=c}_clearCone(){this._app.websocketManager.request({type:"timing_cone",clear:!0}).then(()=>this._refreshOverlay()),this._coneStatus.textContent=""}showPaths(n,r){this._currentTab=n,n==="setup"?(this._setupPaths=[...r],this._setupTab.classList.add("active"),this._holdTab.classList.remove("active")):(this._holdPaths=[...r],this._holdTab.classList.add("active"),this._setupTab.classList.remove("active")),this._applySort(),this._selectedPathIndex=-1,this._pathCountLabel.textContent=r.length+" paths",this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...";try{let[n,r]=await Promise.all([this._app.websocketManager.request({type:"timing_report",is_setup:!0,max_paths:100}),this._app.websocketManager.request({type:"timing_report",is_setup:!1,max_paths:100})]);this._setupPaths=[...n.paths||[]],this._holdPaths=[...r.paths||[]],this._applySort(),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}catch(n){console.error("Timing fetch failed:",n)}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}_applySort(){for(let n of[this._setupPaths,this._holdPaths]){n.forEach((u,d)=>{u._originalIndex===void 0&&(u._originalIndex=d)});let r=this._sortAscending?1:-1,c=this._sortCol;n.sort((u,d)=>{let b=u[c],w=d[c],_=typeof b=="number"&&typeof w=="number"?b-w:String(b).localeCompare(String(w));return r*_})}}_showHeaderTooltip(n,r){if(n.buttons!==0){this._hideHeaderTooltip();return}let c=this._headerTooltip;c.textContent=r,c.style.display="block";let u=Math.min(n.clientX+12,window.innerWidth-c.offsetWidth-8);c.style.left=Math.max(0,u)+"px",c.style.top=n.clientY+14+"px"}_hideHeaderTooltip(){this._headerTooltip.style.display="none"}_sortBy(n){this._sortCol===n?this._sortAscending=!this._sortAscending:(this._sortCol=n,this._sortAscending=!0),this._applySort(),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}_clearTimingHighlight(){this._app.websocketManager.request({type:"timing_highlight",path_index:-1}).then(()=>this._refreshOverlay())}_selectPathRow(n){let r=this._pathTable.querySelectorAll("tbody tr");if(n<0||n>=r.length)return;this._selectedPathIndex=n;for(let d of r)d.classList.remove("selected");r[n].classList.add("selected"),r[n].scrollIntoView({block:"nearest"}),this._pathTableContainer.focus(),this._renderDetailTable();let u=(this._currentTab==="setup"?this._setupPaths:this._holdPaths)[n]?._originalIndex??n;this._app.websocketManager.request({type:"timing_highlight",path_index:u,is_setup:this._currentTab==="setup"}).then(()=>this._refreshOverlay()).catch(d=>console.error("timing_highlight error:",d))}_renderPathTable(){this._hideHeaderTooltip();let n=this._currentTab==="setup"?this._setupPaths:this._holdPaths;this._pathCountLabel.textContent=n.length+" paths";let r=this._pathTable.querySelectorAll("thead th"),c=Array.from(r,_=>_.style.width);this._pathTable.innerHTML="";let u=document.createElement("thead"),d=document.createElement("tr");for(let _ of s.PATH_COLS){let x=document.createElement("th");x.classList.add("sortable"),_.num&&x.classList.add("num"),x.textContent=_.label+(_.key===this._sortCol?this._sortAscending?" \u25B2":" \u25BC":""),_.tooltip&&(x.addEventListener("mousemove",T=>this._showHeaderTooltip(T,_.tooltip)),x.addEventListener("mouseleave",()=>this._hideHeaderTooltip())),x.addEventListener("click",()=>this._sortBy(_.key)),d.appendChild(x)}u.appendChild(d),this._pathTable.appendChild(u);let b=document.createElement("tbody"),w=n.reduce((_,x)=>Math.max(_,Math.abs(Number(x.slack)||0)),0);if(n.forEach((_,x)=>{let T=document.createElement("tr");x===this._selectedPathIndex&&T.classList.add("selected");for(let M of s.PATH_COLS){let L=document.createElement("td"),I=_[M.key];if(L.textContent=M.time?lk(I):I,M.num&&L.classList.add("num"),M.key==="slack"){let D=Number(_.slack);D<0&&L.classList.add("slack-negative"),Number.isFinite(D)&&w>0&&(L.classList.add("slack-cell",D<0?"slack-under":"slack-over"),L.style.setProperty("--slack-frac",String(Math.abs(D)/w)))}T.appendChild(L)}T.style.cursor="pointer",T.addEventListener("click",()=>this._selectPathRow(x)),b.appendChild(T)}),n.length===0){let _=document.createElement("tr"),x=document.createElement("td");x.colSpan=s.PATH_COLS.length,x.style.textAlign="center",x.style.color="var(--fg-secondary)",x.textContent=ua(this._app)?"No timing data available":'Click "Update" to load timing paths',_.appendChild(x),b.appendChild(_)}this._pathTable.appendChild(b),ak(this._pathTable,c)}_selectDetailRow(n){let r=this._detailTable.querySelectorAll("tbody tr");if(n<0||n>=r.length)return;this._selectedDetailIndex=n;for(let w of r)w.classList.remove("timing-selected-row");r[n].classList.add("timing-selected-row"),r[n].scrollIntoView({block:"nearest"}),this._detailTableContainer.focus();let u=(this._currentTab==="setup"?this._setupPaths:this._holdPaths)[this._selectedPathIndex],d=this._detailTab==="data"?u.data_nodes:u.capture_nodes,b=u._originalIndex??this._selectedPathIndex;this._app.websocketManager.request({type:"timing_highlight",path_index:b,is_setup:this._currentTab==="setup",pin_name:d[n].pin}).then(()=>this._refreshOverlay())}_renderDetailTable(){let n=this._detailTable.querySelectorAll("thead th"),r=Array.from(n,x=>x.style.width);this._detailTable.innerHTML="",this._selectedDetailIndex=-1;let c=this._currentTab==="setup"?this._setupPaths:this._holdPaths;if(this._selectedPathIndex<0||this._selectedPathIndex>=c.length)return;let u=c[this._selectedPathIndex],d=this._detailTab==="data"?u.data_nodes:u.capture_nodes,b=document.createElement("thead"),w=document.createElement("tr");for(let x of s.DETAIL_COLS){let T=document.createElement("th");s.DETAIL_NUM_COLS.has(x)&&T.classList.add("num"),T.textContent=x,w.appendChild(T)}b.appendChild(w),this._detailTable.appendChild(b);let _=document.createElement("tbody");if(d.forEach((x,T)=>{let M=document.createElement("tr");x.clk&&M.classList.add("timing-clock-row"),[x.pin,x.fanout,x.rise?"\u2191":"\u2193",lk(x.time),lk(x.delay),lk(x.slew),lk(x.load)].forEach((I,D)=>{let F=document.createElement("td");s.DETAIL_NUM_COLS.has(s.DETAIL_COLS[D])&&F.classList.add("num"),F.textContent=I,M.appendChild(F)}),M.style.cursor="pointer",M.addEventListener("click",()=>this._selectDetailRow(T)),_.appendChild(M)}),this._detailTable.appendChild(_),ak(this._detailTable,r),!r[0]){let x=this._detailTable.querySelector("thead th");x&&(x.style.width="30ch")}}};function lk(s){return s==null?"":typeof s=="number"?s.toFixed(4):String(s)}uk.PATH_COLS=[{label:"Clock",key:"end_clk"},{label:"Required",key:"required",time:!0,num:!0},{label:"Arrival",key:"arrival",time:!0,num:!0},{label:"Slack",key:"slack",time:!0,num:!0},{label:"Skew",key:"skew",time:!0,num:!0,tooltip:`The difference in arrival times between source and destination clock pins of a macro/register, adjusted for CRPR and subtracting a clock period. -Setup and hold times account for internal clock delays.`},{label:"Logic Delay",key:"path_delay",time:!0,num:!0,tooltip:"Path delay from instances (excluding buffers and consecutive inverter pairs)"},{label:"Logic Depth",key:"logic_depth",num:!0,tooltip:"Path instances (excluding buffers and consecutive inverter pairs)"},{label:"Fanout",key:"fanout",num:!0},{label:"Start",key:"start_pin"},{label:"End",key:"end_pin"}];uk.DETAIL_COLS=["Pin","Fanout","R/F","Time","Delay","Slew","Load"];uk.DETAIL_NUM_COLS=new Set(["Fanout","Time","Delay","Slew","Load"]);function ph(s){let n=document.cookie.match("(?:^|; )"+s+"=([^;]*)");return n?n[1]:null}function Uf(s,n){document.cookie=s+"="+n+"; path=/; max-age=31536000; SameSite=Lax"}function Vhe(s){document.cookie=s+"=; path=/; max-age=0; SameSite=Lax"}function Whe(s){Uf("or_theme",s);try{window.localStorage.setItem("or_theme",s)}catch{}}function t3t(){Vhe("or_theme");try{window.localStorage.removeItem("or_theme")}catch{}}function H5e(s){let n=document.getElementById("gl-theme-dark"),r=document.getElementById("gl-theme-light");!n||!r||(n.disabled=s!=="dark",r.disabled=s!=="light")}function n3t(s,n){SO(s)&&(document.documentElement.style.setProperty("--bg-map",s),Uf("or_bg_color",s),r3t(n),n.syncDisplayState())}function i3t(s){document.documentElement.style.removeProperty("--bg-map"),Vhe("or_bg_color"),r3t(s),s.syncDisplayState()}function q5e(){return Vxt(getComputedStyle(document.documentElement).getPropertyValue("--bg-map"))??"#000000"}function r3t(s){s.threeDViewerWidget?.render?.()}if(typeof document<"u"){let s=ph("or_theme")||typeof localStorage<"u"&&localStorage.getItem("or_theme")||(matchMedia("(prefers-color-scheme: light)").matches?"light":"dark");document.documentElement.dataset.theme=s,H5e(s);let n=ph("or_bg_color");SO(n)&&document.documentElement.style.setProperty("--bg-map",n)}function fk(){let s=getComputedStyle(document.documentElement),n=r=>s.getPropertyValue(r).trim();return{canvasBg:n("--canvas-bg"),canvasText:n("--canvas-text"),canvasAxis:n("--canvas-axis"),canvasLabel:n("--canvas-label"),canvasGrid:n("--canvas-grid"),canvasTitle:n("--canvas-title"),fgPrimary:n("--fg-primary"),fgMuted:n("--fg-muted"),bgPanel:n("--bg-panel"),bgMap:n("--bg-map"),fontMono:n("--font-mono"),fontSans:n("--font-sans")}}function hk(s,n){let r=document.createElement("a");r.href=s,r.download=n,document.body.appendChild(r),r.click(),r.remove()}function s3t(s,n){let r=URL.createObjectURL(s);hk(r,n),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function X5e(s){let n=s.cloneNode(!0);if(n.getAttribute("xmlns")||n.setAttribute("xmlns","http://www.w3.org/2000/svg"),n.getAttribute("xmlns:xlink")||n.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),!n.getAttribute("width")||!n.getAttribute("height")){let r=s.viewBox&&s.viewBox.baseVal;r&&r.width&&r.height&&(n.setAttribute("width",r.width),n.setAttribute("height",r.height))}return` -`+new XMLSerializer().serializeToString(n)}function sdn(s){let n=s.viewBox&&s.viewBox.baseVal;if(n&&n.width&&n.height)return{width:n.width,height:n.height};let r=parseFloat(s.getAttribute("width")),c=parseFloat(s.getAttribute("height"));if(r&&c)return{width:r,height:c};let u=s.getBoundingClientRect();return{width:u.width||800,height:u.height||600}}function Y5e(s,n=2){let{width:r,height:c}=sdn(s),u=X5e(s),d=new Blob([u],{type:"image/svg+xml;charset=utf-8"}),b=URL.createObjectURL(d);return new Promise((w,_)=>{let x=new Image;x.onload=()=>{let T=document.createElement("canvas");T.width=Math.max(1,Math.round(r*n)),T.height=Math.max(1,Math.round(c*n));let M=T.getContext("2d");M.fillStyle="#ffffff",M.fillRect(0,0,T.width,T.height),M.drawImage(x,0,0,T.width,T.height),URL.revokeObjectURL(b),w(T.toDataURL("image/png"))},x.onerror=T=>{URL.revokeObjectURL(b),_(T)},x.src=b})}async function Hhe(s){try{if(!navigator.clipboard||!window.ClipboardItem)return!1;let n=await(await fetch(s)).blob();return await navigator.clipboard.write([new ClipboardItem({"image/png":n})]),!0}catch{return!1}}function odn(s){return(String(s||"").replace(/[^A-Za-z0-9._-]/g,"_").replace(/^_+|_+$/g,"")||"clock_tree")+".png"}var Z5e=24,K5e=10,Xhe=40,adn=40,J5e=70,cdn=20,qhe={root:"#ff4444",buffer:"#4488ff",inverter:"#00b0b0",clock_gate:"#cc44cc",register:"#ff4444",macro:"#00b0b0",unknown:"#888888"};function ldn(s){let n=parseInt(s.slice(1,3),16),r=parseInt(s.slice(3,5),16),c=parseInt(s.slice(5,7),16),u=b=>Math.round((b+255)/2),d=b=>b.toString(16).padStart(2,"0");return"#"+d(u(n))+d(u(r))+d(u(c))}function udn(s){let n=s.nodes;if(!n||n.length===0)return{layout:[],layoutWidth:0,layoutHeight:0,timeMin:0,timeMax:0,timeUnit:"",sceneHeight:0,layoutById:new Map};let r=new Map;for(let Z of n)r.set(Z.id,[]);for(let Z of n)Z.parent_id>=0&&r.has(Z.parent_id)&&r.get(Z.parent_id).push(Z.id);let c=new Map;for(let Z of n)c.set(Z.id,Z);let u=new Map,d=Z=>{let H=r.get(Z)||[];if(H.length===0)return u.set(Z,1),1;let te=0;for(let oe of H)te+=d(oe);return u.set(Z,te),te},b=n.filter(Z=>Z.parent_id===-1),w=0;for(let Z of b)w+=d(Z.id);let _=s.min_arrival,x=s.max_arrival,T=x-_||1,M=Math.max(200,w*Z5e*.6),L=[],I=(Z,H)=>{let te=c.get(Z),oe=u.get(Z),ne=J5e+(H+oe/2)*Z5e,ue=Xhe+(te.arrival-_)/T*M;L.push({id:te.id,x:ne,y:ue,type:te.type,name:te.name,pin_name:te.pin_name,arrival:te.arrival,delay:te.delay,fanout:te.fanout,level:te.level,parent_id:te.parent_id});let Te=H,Q=r.get(Z)||[];for(let ge of Q)I(ge,Te),Te+=u.get(ge)},D=0;for(let Z of b)I(Z.id,D),D+=u.get(Z.id);let F=J5e+w*Z5e+cdn,O=Xhe+M+adn,z=new Map;for(let Z of L)z.set(Z.id,Z);return{layout:L,layoutWidth:F,layoutHeight:O,timeMin:_,timeMax:x,timeUnit:s.time_unit||"",sceneHeight:M,layoutById:z}}var Yhe=class{constructor(n,r,c,u){this._app=r,this._redrawAllLayers=c,this._refreshOverlay=u||c,this._clockData=[],this._selectedClockIdx=0,this._selectedNodeId=-1,this._tx=0,this._ty=0,this._scale=1,this._layout=[],this._dragging=!1,this._dragStartX=0,this._dragStartY=0,this._dragStartTx=0,this._dragStartTy=0,this._build(n)}_build(n){let r=document.createElement("div");r.className="clock-tree-widget";let c=document.createElement("div");c.className="clock-tree-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",ua(this._app)&&(this._updateBtn.style.display="none"),this._fitBtn=document.createElement("button"),this._fitBtn.className="or-btn",this._fitBtn.textContent="Fit",this._pngBtn=document.createElement("button"),this._pngBtn.className="or-btn",this._pngBtn.textContent="PNG",this._pngBtn.title="Export the clock tree as a PNG image",this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",c.appendChild(this._updateBtn),c.appendChild(this._fitBtn),c.appendChild(this._pngBtn),c.appendChild(this._statusLabel),r.appendChild(c),this._tabBar=document.createElement("div"),this._tabBar.className="timing-tab-bar",r.appendChild(this._tabBar),this._canvas=document.createElement("canvas"),this._canvas.className="clock-tree-canvas",r.appendChild(this._canvas),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._tooltip.style.display="none",r.appendChild(this._tooltip),n.element.appendChild(r),this._el=r,this._ctx=this._canvas.getContext("2d"),this._bindEvents(),ua(this._app)&&setTimeout(()=>this.update(),0)}_fit(){this._sizeCanvas(),this._fitToView(),this._render()}_pngFileName(){let n=this._clockData[this._selectedClockIdx];return odn(n&&n.name)}_exportPng(){try{hk(this._canvas.toDataURL("image/png"),this._pngFileName())}catch(n){console.error("PNG export failed:",n)}}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update()),this._fitBtn.addEventListener("click",()=>this._fit()),this._pngBtn.addEventListener("click",()=>this._exportPng()),this._canvas.addEventListener("keydown",n=>{n.key==="f"&&this._fit()}),this._canvas.tabIndex=0,this._canvas.addEventListener("wheel",n=>{n.preventDefault();let r=this._canvas.getBoundingClientRect(),c=n.clientX-r.left,u=n.clientY-r.top,d=n.deltaY<0?1.15:1/1.15;this._tx=c-(c-this._tx)*d,this._ty=u-(u-this._ty)*d,this._scale*=d,this._render()}),this._canvas.addEventListener("mousedown",n=>{this._dragging=!0,this._dragStartX=n.clientX,this._dragStartY=n.clientY,this._dragStartTx=this._tx,this._dragStartTy=this._ty,this._canvas.style.cursor="grabbing"}),window.addEventListener("mousemove",n=>{this._dragging?(this._tx=this._dragStartTx+(n.clientX-this._dragStartX),this._ty=this._dragStartTy+(n.clientY-this._dragStartY),this._render()):this._handleHover(n)}),window.addEventListener("mouseup",()=>{this._dragging&&(this._dragging=!1,this._canvas.style.cursor="grab")}),this._canvas.addEventListener("click",n=>this._handleClick(n)),this._resizeObserver=new ResizeObserver(()=>{this._sizeCanvas(),this._render()}),this._resizeObserver.observe(this._canvas)}_sizeCanvas(){let n=this._canvas.getBoundingClientRect(),r=window.devicePixelRatio||1;this._canvas.width=n.width*r,this._canvas.height=n.height*r,this._ctx.setTransform(r,0,0,r,0,0)}async update(){this._statusLabel.textContent="Loading...";try{let n=await this._app.websocketManager.request({type:"clock_tree"});this._clockData=n.clocks||[],this._buildTabs(),this._selectClock(0),this._statusLabel.textContent=this._clockData.length+" clock"+(this._clockData.length!==1?"s":"")}catch(n){console.error("Clock tree error:",n),this._statusLabel.textContent="Error: "+n.message}}_buildTabs(){this._tabBar.innerHTML="",this._clockData.forEach((n,r)=>{let c=document.createElement("button");c.className="timing-tab"+(r===this._selectedClockIdx?" active":""),c.textContent=n.name,c.addEventListener("click",()=>this._selectClock(r)),this._tabBar.appendChild(c)})}_selectClock(n){if(n<0||n>=this._clockData.length)return;this._selectedClockIdx=n,this._selectedNodeId=-1,this._tabBar.querySelectorAll(".timing-tab").forEach((c,u)=>{c.classList.toggle("active",u===n)}),this._computeLayout(this._clockData[n]),requestAnimationFrame(()=>{this._sizeCanvas(),this._fitToView(),this._render()})}_computeLayout(n){let r=udn(n);this._layout=r.layout,this._layoutWidth=r.layoutWidth,this._layoutHeight=r.layoutHeight,this._timeMin=r.timeMin,this._timeMax=r.timeMax,this._timeUnit=r.timeUnit,this._sceneHeight=r.sceneHeight,this._layoutById=r.layoutById}_fitToView(){if(!this._layout.length)return;let n=this._canvas.getBoundingClientRect(),r=n.width,c=n.height,u=r/this._layoutWidth,d=c/this._layoutHeight;this._scale=Math.min(u,d)*.9,this._tx=(r-this._layoutWidth*this._scale)/2,this._ty=(c-this._layoutHeight*this._scale)/2}render(){this._render()}_render(){let n=this._ctx,r=this._canvas.getBoundingClientRect(),c=r.width,u=r.height,d=fk();if(n.clearRect(0,0,c,u),n.fillStyle=d.canvasBg,n.fillRect(0,0,c,u),!this._layout.length){n.fillStyle=d.canvasText,n.font="14px "+d.fontSans,n.textAlign="center";let b=ua(this._app)?"No clock tree data available":'Click "Update" to load clock tree data';n.fillText(b,c/2,u/2);return}n.save(),n.translate(this._tx,this._ty),n.scale(this._scale,this._scale),this._drawConnections(n);for(let b of this._layout)this._drawNode(n,b,b.id===this._selectedNodeId);n.restore(),this._drawTimeScale(n,c,u,d)}_drawConnections(n){let r=1.5/this._scale,c=K5e,u=this._timeMax-this._timeMin||1;for(let d of this._layout){if(d.parent_id<0)continue;let b=this._layoutById.get(d.parent_id);if(!b)continue;let w=b.x,_=d.x,x=(b.delay||0)/u*this._sceneHeight,T=b.y+x,M=d.y,L=b.type==="root"?b.y:b.y+c;if(T>L){let D=qhe[b.type]||qhe.unknown;n.strokeStyle=D,n.lineWidth=r,n.beginPath(),n.moveTo(w,L),n.lineTo(w,T);let F=c/20;n.moveTo(w-F,T),n.lineTo(w+F,T),n.stroke()}n.strokeStyle="#006400",n.lineWidth=r;let I=(T+M)/2;n.beginPath(),n.moveTo(w,T),n.bezierCurveTo(w,I,_,I,_,M),n.stroke()}}_drawNode(n,r,c){let u=r.x,d=r.y,b=K5e,w=qhe[r.type]||qhe.unknown;switch(n.fillStyle=ldn(w),n.strokeStyle=w,n.lineWidth=1/this._scale,r.type){case"root":{n.beginPath(),n.moveTo(u-b/2,d-b),n.lineTo(u+b/2,d-b),n.lineTo(u,d),n.closePath(),n.fill(),n.stroke();break}case"buffer":{n.beginPath(),n.moveTo(u-b/2,d),n.lineTo(u+b/2,d),n.lineTo(u,d+b),n.closePath(),n.fill(),n.stroke();break}case"inverter":{let _=b*.1,x=d+b-_;n.beginPath(),n.moveTo(u-b/2,d),n.lineTo(u+b/2,d),n.lineTo(u,x),n.closePath(),n.fill(),n.stroke(),n.beginPath(),n.arc(u,x+_/2,_/2,0,Math.PI*2),n.fill(),n.stroke();break}case"clock_gate":{n.beginPath(),n.arc(u,d+b/2,b/2,0,Math.PI*2),n.fill(),n.stroke();break}case"register":case"macro":{n.beginPath(),n.rect(u-b/2,d,b,b),n.fill(),n.stroke(),n.beginPath(),n.moveTo(u-b/8,d),n.lineTo(u+b/8,d),n.lineTo(u,d+b/4),n.closePath(),n.stroke();break}default:{n.beginPath(),n.arc(u,d+b/2,b/2,0,Math.PI*2),n.fill(),n.stroke();break}}if(c){n.strokeStyle="#ffff00",n.lineWidth=2/this._scale;let _=r.type==="root"?d-b/2:d+b/2;n.beginPath(),n.arc(u,_,b/2+3,0,Math.PI*2),n.stroke()}}_drawTimeScale(n,r,c,u){if(!this._sceneHeight)return;let d=F=>F*this._scale+this._ty,b=d(Xhe),w=d(Xhe+this._sceneHeight);if(w<0||b>c)return;n.save(),n.fillStyle=u.canvasLabel,n.strokeStyle=u.canvasAxis,n.font="11px "+u.fontMono,n.textAlign="right",n.textBaseline="middle";let _=this._timeMax-this._timeMin;if(_<=0){n.restore();return}let x=w-b,T=Math.max(2,Math.floor(x/40)),M=_/T,L=Math.pow(10,Math.floor(Math.log10(M))),I=L;M/L>5?I=10*L:M/L>2?I=5*L:M/L>1&&(I=2*L);let D=Math.ceil(this._timeMin/I)*I;n.beginPath();for(let F=D;F<=this._timeMax;F+=I){let O=(F-this._timeMin)/_,z=b+O*(w-b);n.moveTo(0,z),n.lineTo(r,z);let Z=F.toFixed(I<.01?3:I<.1?2:1)+" "+this._timeUnit;n.fillText(Z,J5e-4,z)}n.stroke(),n.restore()}_screenToLayout(n,r){return{x:(n-this._tx)/this._scale,y:(r-this._ty)/this._scale}}_hitTest(n,r){let c=this._screenToLayout(n,r),u=K5e;for(let d of this._layout){let b=d.type==="root"?d.y-u:d.y,w=d.type==="root"?d.y:d.y+u;if(c.x>=d.x-u/2&&c.x<=d.x+u/2&&c.y>=b&&c.y<=w)return d}return null}_handleClick(n){let r=this._canvas.getBoundingClientRect(),c=n.clientX-r.left,u=n.clientY-r.top,d=this._hitTest(c,u);d?(this._selectedNodeId=d.id,this._render(),this._app.websocketManager.request({type:"clock_tree_highlight",inst_name:d.name}).then(()=>this._refreshOverlay())):this._selectedNodeId>=0&&(this._selectedNodeId=-1,this._render(),this._app.websocketManager.request({type:"clock_tree_highlight",inst_name:""}).then(()=>this._refreshOverlay()))}_handleHover(n){let r=this._canvas.getBoundingClientRect(),c=n.clientX-r.left,u=n.clientY-r.top;if(c<0||u<0||c>r.width||u>r.height){this._tooltip.style.display="none";return}let d=this._hitTest(c,u);if(d){let b=[d.name,"Type: "+d.type,"Arrival: "+d.arrival.toFixed(3)+" "+(this._timeUnit||"")];d.delay&&b.push("Delay: "+d.delay.toFixed(3)+" "+(this._timeUnit||"")),d.fanout&&b.push("Fanout: "+d.fanout),this._tooltip.textContent=b.join(` -`),this._tooltip.style.display="block",this._tooltip.style.left=n.clientX+12+"px",this._tooltip.style.top=n.clientY+12+"px"}else this._tooltip.style.display="none"}};var a3t=60,c3t=20,l3t=30,u3t=50,o3t=2,fdn="#f08080",hdn="#8b0000",ddn="#90ee90",pdn="#006400",xT=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7"],gdn="rgba(240,128,128,0.12)",mdn="rgba(144,238,144,0.12)",bdn="#ff9999",wdn="#b0ffb0",vdn=[{value:"setup",label:"Setup Slack"},{value:"hold",label:"Hold Slack"},{value:"fanout",label:"Net Fanout"},{value:"netlength",label:"Net Length (HPWL)"}];function _dn(s,n,r,c){if(!s||!n||cn.bottom)return null;for(let u of s)if(r>=u.x&&r<=u.x+u.width)return u;return null}function ydn(s,n,r){return r?Math.log10(s+1)/Math.log10(n+1):s/n}function xdn(s,n,r,c={}){let u=!!c.logY,d=s?.bins;if(!d||d.length===0)return{bars:[],yMax:0,yTicks:[],chartArea:null,logY:u};let b=a3t,w=n-c3t,_=l3t,x=r-u3t,T=w-b,M=x-_;if(T<=0||M<=0)return{bars:[],yMax:0,yTicks:[],chartArea:null,logY:u};let L={left:b,right:w,top:_,bottom:x},I=0;for(let Z of d)Z.count>I&&(I=Z.count);I===0&&(I=1);let{yMax:D,yTicks:F}=u?Sdn(I):Edn(I),O=(T-o3t*(d.length-1))/d.length,z=[];for(let Z=0;Z[x.x,...x.ys||[]].join(","));return[w,..._].join(` +Setup and hold times account for internal clock delays.`},{label:"Logic Delay",key:"path_delay",time:!0,num:!0,tooltip:"Path delay from instances (excluding buffers and consecutive inverter pairs)"},{label:"Logic Depth",key:"logic_depth",num:!0,tooltip:"Path instances (excluding buffers and consecutive inverter pairs)"},{label:"Fanout",key:"fanout",num:!0},{label:"Start",key:"start_pin"},{label:"End",key:"end_pin"}];uk.DETAIL_COLS=["Pin","Fanout","R/F","Time","Delay","Slew","Load"];uk.DETAIL_NUM_COLS=new Set(["Fanout","Time","Delay","Slew","Load"]);function zf(s){let n=document.cookie.match("(?:^|; )"+s+"=([^;]*)");return n?n[1]:null}function gf(s,n){document.cookie=s+"="+n+"; path=/; max-age=31536000; SameSite=Lax"}function Vhe(s){document.cookie=s+"=; path=/; max-age=0; SameSite=Lax"}function Whe(s){gf("or_theme",s);try{window.localStorage.setItem("or_theme",s)}catch{}}function i3t(){Vhe("or_theme");try{window.localStorage.removeItem("or_theme")}catch{}}function H5e(s){let n=document.getElementById("gl-theme-dark"),r=document.getElementById("gl-theme-light");!n||!r||(n.disabled=s!=="dark",r.disabled=s!=="light")}function r3t(s,n){SO(s)&&(document.documentElement.style.setProperty("--bg-map",s),gf("or_bg_color",s),o3t(n),n.syncDisplayState())}function s3t(s){document.documentElement.style.removeProperty("--bg-map"),Vhe("or_bg_color"),o3t(s),s.syncDisplayState()}function q5e(){return Hxt(getComputedStyle(document.documentElement).getPropertyValue("--bg-map"))??"#000000"}function o3t(s){s.threeDViewerWidget?.render?.()}if(typeof document<"u"){let s=zf("or_theme")||typeof localStorage<"u"&&localStorage.getItem("or_theme")||(matchMedia("(prefers-color-scheme: light)").matches?"light":"dark");document.documentElement.dataset.theme=s,H5e(s);let n=zf("or_bg_color");SO(n)&&document.documentElement.style.setProperty("--bg-map",n)}function fk(){let s=getComputedStyle(document.documentElement),n=r=>s.getPropertyValue(r).trim();return{canvasBg:n("--canvas-bg"),canvasText:n("--canvas-text"),canvasAxis:n("--canvas-axis"),canvasLabel:n("--canvas-label"),canvasGrid:n("--canvas-grid"),canvasTitle:n("--canvas-title"),fgPrimary:n("--fg-primary"),fgMuted:n("--fg-muted"),bgPanel:n("--bg-panel"),bgMap:n("--bg-map"),fontMono:n("--font-mono"),fontSans:n("--font-sans")}}function hk(s,n){let r=document.createElement("a");r.href=s,r.download=n,document.body.appendChild(r),r.click(),r.remove()}function a3t(s,n){let r=URL.createObjectURL(s);hk(r,n),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function X5e(s){let n=s.cloneNode(!0);if(n.getAttribute("xmlns")||n.setAttribute("xmlns","http://www.w3.org/2000/svg"),n.getAttribute("xmlns:xlink")||n.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),!n.getAttribute("width")||!n.getAttribute("height")){let r=s.viewBox&&s.viewBox.baseVal;r&&r.width&&r.height&&(n.setAttribute("width",r.width),n.setAttribute("height",r.height))}return` +`+new XMLSerializer().serializeToString(n)}function ldn(s){let n=s.viewBox&&s.viewBox.baseVal;if(n&&n.width&&n.height)return{width:n.width,height:n.height};let r=parseFloat(s.getAttribute("width")),c=parseFloat(s.getAttribute("height"));if(r&&c)return{width:r,height:c};let u=s.getBoundingClientRect();return{width:u.width||800,height:u.height||600}}function Y5e(s,n=2){let{width:r,height:c}=ldn(s),u=X5e(s),d=new Blob([u],{type:"image/svg+xml;charset=utf-8"}),b=URL.createObjectURL(d);return new Promise((w,_)=>{let x=new Image;x.onload=()=>{let T=document.createElement("canvas");T.width=Math.max(1,Math.round(r*n)),T.height=Math.max(1,Math.round(c*n));let M=T.getContext("2d");M.fillStyle="#ffffff",M.fillRect(0,0,T.width,T.height),M.drawImage(x,0,0,T.width,T.height),URL.revokeObjectURL(b),w(T.toDataURL("image/png"))},x.onerror=T=>{URL.revokeObjectURL(b),_(T)},x.src=b})}async function Hhe(s){try{if(!navigator.clipboard||!window.ClipboardItem)return!1;let n=await(await fetch(s)).blob();return await navigator.clipboard.write([new ClipboardItem({"image/png":n})]),!0}catch{return!1}}function udn(s){return(String(s||"").replace(/[^A-Za-z0-9._-]/g,"_").replace(/^_+|_+$/g,"")||"clock_tree")+".png"}var Z5e=24,K5e=10,Xhe=40,fdn=40,J5e=70,hdn=20,qhe={root:"#ff4444",buffer:"#4488ff",inverter:"#00b0b0",clock_gate:"#cc44cc",register:"#ff4444",macro:"#00b0b0",unknown:"#888888"};function ddn(s){let n=parseInt(s.slice(1,3),16),r=parseInt(s.slice(3,5),16),c=parseInt(s.slice(5,7),16),u=b=>Math.round((b+255)/2),d=b=>b.toString(16).padStart(2,"0");return"#"+d(u(n))+d(u(r))+d(u(c))}function pdn(s){let n=s.nodes;if(!n||n.length===0)return{layout:[],layoutWidth:0,layoutHeight:0,timeMin:0,timeMax:0,timeUnit:"",sceneHeight:0,layoutById:new Map};let r=new Map;for(let Z of n)r.set(Z.id,[]);for(let Z of n)Z.parent_id>=0&&r.has(Z.parent_id)&&r.get(Z.parent_id).push(Z.id);let c=new Map;for(let Z of n)c.set(Z.id,Z);let u=new Map,d=Z=>{let H=r.get(Z)||[];if(H.length===0)return u.set(Z,1),1;let te=0;for(let oe of H)te+=d(oe);return u.set(Z,te),te},b=n.filter(Z=>Z.parent_id===-1),w=0;for(let Z of b)w+=d(Z.id);let _=s.min_arrival,x=s.max_arrival,T=x-_||1,M=Math.max(200,w*Z5e*.6),L=[],I=(Z,H)=>{let te=c.get(Z),oe=u.get(Z),ne=J5e+(H+oe/2)*Z5e,ue=Xhe+(te.arrival-_)/T*M;L.push({id:te.id,x:ne,y:ue,type:te.type,name:te.name,pin_name:te.pin_name,arrival:te.arrival,delay:te.delay,fanout:te.fanout,level:te.level,parent_id:te.parent_id});let Te=H,Q=r.get(Z)||[];for(let ge of Q)I(ge,Te),Te+=u.get(ge)},D=0;for(let Z of b)I(Z.id,D),D+=u.get(Z.id);let F=J5e+w*Z5e+hdn,O=Xhe+M+fdn,z=new Map;for(let Z of L)z.set(Z.id,Z);return{layout:L,layoutWidth:F,layoutHeight:O,timeMin:_,timeMax:x,timeUnit:s.time_unit||"",sceneHeight:M,layoutById:z}}var Yhe=class{constructor(n,r,c,u){this._app=r,this._redrawAllLayers=c,this._refreshOverlay=u||c,this._clockData=[],this._selectedClockIdx=0,this._selectedNodeId=-1,this._tx=0,this._ty=0,this._scale=1,this._layout=[],this._dragging=!1,this._dragStartX=0,this._dragStartY=0,this._dragStartTx=0,this._dragStartTy=0,this._build(n)}_build(n){let r=document.createElement("div");r.className="clock-tree-widget";let c=document.createElement("div");c.className="clock-tree-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",ua(this._app)&&(this._updateBtn.style.display="none"),this._fitBtn=document.createElement("button"),this._fitBtn.className="or-btn",this._fitBtn.textContent="Fit",this._pngBtn=document.createElement("button"),this._pngBtn.className="or-btn",this._pngBtn.textContent="PNG",this._pngBtn.title="Export the clock tree as a PNG image",this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",c.appendChild(this._updateBtn),c.appendChild(this._fitBtn),c.appendChild(this._pngBtn),c.appendChild(this._statusLabel),r.appendChild(c),this._tabBar=document.createElement("div"),this._tabBar.className="timing-tab-bar",r.appendChild(this._tabBar),this._canvas=document.createElement("canvas"),this._canvas.className="clock-tree-canvas",r.appendChild(this._canvas),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._tooltip.style.display="none",r.appendChild(this._tooltip),n.element.appendChild(r),this._el=r,this._ctx=this._canvas.getContext("2d"),this._bindEvents(),ua(this._app)&&setTimeout(()=>this.update(),0)}_fit(){this._sizeCanvas(),this._fitToView(),this._render()}_pngFileName(){let n=this._clockData[this._selectedClockIdx];return udn(n&&n.name)}_exportPng(){try{hk(this._canvas.toDataURL("image/png"),this._pngFileName())}catch(n){console.error("PNG export failed:",n)}}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update()),this._fitBtn.addEventListener("click",()=>this._fit()),this._pngBtn.addEventListener("click",()=>this._exportPng()),this._canvas.addEventListener("keydown",n=>{n.key==="f"&&this._fit()}),this._canvas.tabIndex=0,this._canvas.addEventListener("wheel",n=>{n.preventDefault();let r=this._canvas.getBoundingClientRect(),c=n.clientX-r.left,u=n.clientY-r.top,d=n.deltaY<0?1.15:1/1.15;this._tx=c-(c-this._tx)*d,this._ty=u-(u-this._ty)*d,this._scale*=d,this._render()}),this._canvas.addEventListener("mousedown",n=>{this._dragging=!0,this._dragStartX=n.clientX,this._dragStartY=n.clientY,this._dragStartTx=this._tx,this._dragStartTy=this._ty,this._canvas.style.cursor="grabbing"}),window.addEventListener("mousemove",n=>{this._dragging?(this._tx=this._dragStartTx+(n.clientX-this._dragStartX),this._ty=this._dragStartTy+(n.clientY-this._dragStartY),this._render()):this._handleHover(n)}),window.addEventListener("mouseup",()=>{this._dragging&&(this._dragging=!1,this._canvas.style.cursor="grab")}),this._canvas.addEventListener("click",n=>this._handleClick(n)),this._resizeObserver=new ResizeObserver(()=>{this._sizeCanvas(),this._render()}),this._resizeObserver.observe(this._canvas)}_sizeCanvas(){let n=this._canvas.getBoundingClientRect(),r=window.devicePixelRatio||1;this._canvas.width=n.width*r,this._canvas.height=n.height*r,this._ctx.setTransform(r,0,0,r,0,0)}async update(){this._statusLabel.textContent="Loading...";try{let n=await this._app.websocketManager.request({type:"clock_tree"});this._clockData=n.clocks||[],this._buildTabs(),this._selectClock(0),this._statusLabel.textContent=this._clockData.length+" clock"+(this._clockData.length!==1?"s":"")}catch(n){console.error("Clock tree error:",n),this._statusLabel.textContent="Error: "+n.message}}_buildTabs(){this._tabBar.innerHTML="",this._clockData.forEach((n,r)=>{let c=document.createElement("button");c.className="timing-tab"+(r===this._selectedClockIdx?" active":""),c.textContent=n.name,c.addEventListener("click",()=>this._selectClock(r)),this._tabBar.appendChild(c)})}_selectClock(n){if(n<0||n>=this._clockData.length)return;this._selectedClockIdx=n,this._selectedNodeId=-1,this._tabBar.querySelectorAll(".timing-tab").forEach((c,u)=>{c.classList.toggle("active",u===n)}),this._computeLayout(this._clockData[n]),requestAnimationFrame(()=>{this._sizeCanvas(),this._fitToView(),this._render()})}_computeLayout(n){let r=pdn(n);this._layout=r.layout,this._layoutWidth=r.layoutWidth,this._layoutHeight=r.layoutHeight,this._timeMin=r.timeMin,this._timeMax=r.timeMax,this._timeUnit=r.timeUnit,this._sceneHeight=r.sceneHeight,this._layoutById=r.layoutById}_fitToView(){if(!this._layout.length)return;let n=this._canvas.getBoundingClientRect(),r=n.width,c=n.height,u=r/this._layoutWidth,d=c/this._layoutHeight;this._scale=Math.min(u,d)*.9,this._tx=(r-this._layoutWidth*this._scale)/2,this._ty=(c-this._layoutHeight*this._scale)/2}render(){this._render()}_render(){let n=this._ctx,r=this._canvas.getBoundingClientRect(),c=r.width,u=r.height,d=fk();if(n.clearRect(0,0,c,u),n.fillStyle=d.canvasBg,n.fillRect(0,0,c,u),!this._layout.length){n.fillStyle=d.canvasText,n.font="14px "+d.fontSans,n.textAlign="center";let b=ua(this._app)?"No clock tree data available":'Click "Update" to load clock tree data';n.fillText(b,c/2,u/2);return}n.save(),n.translate(this._tx,this._ty),n.scale(this._scale,this._scale),this._drawConnections(n);for(let b of this._layout)this._drawNode(n,b,b.id===this._selectedNodeId);n.restore(),this._drawTimeScale(n,c,u,d)}_drawConnections(n){let r=1.5/this._scale,c=K5e,u=this._timeMax-this._timeMin||1;for(let d of this._layout){if(d.parent_id<0)continue;let b=this._layoutById.get(d.parent_id);if(!b)continue;let w=b.x,_=d.x,x=(b.delay||0)/u*this._sceneHeight,T=b.y+x,M=d.y,L=b.type==="root"?b.y:b.y+c;if(T>L){let D=qhe[b.type]||qhe.unknown;n.strokeStyle=D,n.lineWidth=r,n.beginPath(),n.moveTo(w,L),n.lineTo(w,T);let F=c/20;n.moveTo(w-F,T),n.lineTo(w+F,T),n.stroke()}n.strokeStyle="#006400",n.lineWidth=r;let I=(T+M)/2;n.beginPath(),n.moveTo(w,T),n.bezierCurveTo(w,I,_,I,_,M),n.stroke()}}_drawNode(n,r,c){let u=r.x,d=r.y,b=K5e,w=qhe[r.type]||qhe.unknown;switch(n.fillStyle=ddn(w),n.strokeStyle=w,n.lineWidth=1/this._scale,r.type){case"root":{n.beginPath(),n.moveTo(u-b/2,d-b),n.lineTo(u+b/2,d-b),n.lineTo(u,d),n.closePath(),n.fill(),n.stroke();break}case"buffer":{n.beginPath(),n.moveTo(u-b/2,d),n.lineTo(u+b/2,d),n.lineTo(u,d+b),n.closePath(),n.fill(),n.stroke();break}case"inverter":{let _=b*.1,x=d+b-_;n.beginPath(),n.moveTo(u-b/2,d),n.lineTo(u+b/2,d),n.lineTo(u,x),n.closePath(),n.fill(),n.stroke(),n.beginPath(),n.arc(u,x+_/2,_/2,0,Math.PI*2),n.fill(),n.stroke();break}case"clock_gate":{n.beginPath(),n.arc(u,d+b/2,b/2,0,Math.PI*2),n.fill(),n.stroke();break}case"register":case"macro":{n.beginPath(),n.rect(u-b/2,d,b,b),n.fill(),n.stroke(),n.beginPath(),n.moveTo(u-b/8,d),n.lineTo(u+b/8,d),n.lineTo(u,d+b/4),n.closePath(),n.stroke();break}default:{n.beginPath(),n.arc(u,d+b/2,b/2,0,Math.PI*2),n.fill(),n.stroke();break}}if(c){n.strokeStyle="#ffff00",n.lineWidth=2/this._scale;let _=r.type==="root"?d-b/2:d+b/2;n.beginPath(),n.arc(u,_,b/2+3,0,Math.PI*2),n.stroke()}}_drawTimeScale(n,r,c,u){if(!this._sceneHeight)return;let d=F=>F*this._scale+this._ty,b=d(Xhe),w=d(Xhe+this._sceneHeight);if(w<0||b>c)return;n.save(),n.fillStyle=u.canvasLabel,n.strokeStyle=u.canvasAxis,n.font="11px "+u.fontMono,n.textAlign="right",n.textBaseline="middle";let _=this._timeMax-this._timeMin;if(_<=0){n.restore();return}let x=w-b,T=Math.max(2,Math.floor(x/40)),M=_/T,L=Math.pow(10,Math.floor(Math.log10(M))),I=L;M/L>5?I=10*L:M/L>2?I=5*L:M/L>1&&(I=2*L);let D=Math.ceil(this._timeMin/I)*I;n.beginPath();for(let F=D;F<=this._timeMax;F+=I){let O=(F-this._timeMin)/_,z=b+O*(w-b);n.moveTo(0,z),n.lineTo(r,z);let Z=F.toFixed(I<.01?3:I<.1?2:1)+" "+this._timeUnit;n.fillText(Z,J5e-4,z)}n.stroke(),n.restore()}_screenToLayout(n,r){return{x:(n-this._tx)/this._scale,y:(r-this._ty)/this._scale}}_hitTest(n,r){let c=this._screenToLayout(n,r),u=K5e;for(let d of this._layout){let b=d.type==="root"?d.y-u:d.y,w=d.type==="root"?d.y:d.y+u;if(c.x>=d.x-u/2&&c.x<=d.x+u/2&&c.y>=b&&c.y<=w)return d}return null}_handleClick(n){let r=this._canvas.getBoundingClientRect(),c=n.clientX-r.left,u=n.clientY-r.top,d=this._hitTest(c,u);d?(this._selectedNodeId=d.id,this._render(),this._app.websocketManager.request({type:"clock_tree_highlight",inst_name:d.name}).then(()=>this._refreshOverlay())):this._selectedNodeId>=0&&(this._selectedNodeId=-1,this._render(),this._app.websocketManager.request({type:"clock_tree_highlight",inst_name:""}).then(()=>this._refreshOverlay()))}_handleHover(n){let r=this._canvas.getBoundingClientRect(),c=n.clientX-r.left,u=n.clientY-r.top;if(c<0||u<0||c>r.width||u>r.height){this._tooltip.style.display="none";return}let d=this._hitTest(c,u);if(d){let b=[d.name,"Type: "+d.type,"Arrival: "+d.arrival.toFixed(3)+" "+(this._timeUnit||"")];d.delay&&b.push("Delay: "+d.delay.toFixed(3)+" "+(this._timeUnit||"")),d.fanout&&b.push("Fanout: "+d.fanout),this._tooltip.textContent=b.join(` +`),this._tooltip.style.display="block",this._tooltip.style.left=n.clientX+12+"px",this._tooltip.style.top=n.clientY+12+"px"}else this._tooltip.style.display="none"}};var l3t=60,u3t=20,f3t=30,h3t=50,c3t=2,gdn="#f08080",mdn="#8b0000",bdn="#90ee90",wdn="#006400",xT=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7"],vdn="rgba(240,128,128,0.12)",_dn="rgba(144,238,144,0.12)",ydn="#ff9999",xdn="#b0ffb0",Edn=[{value:"setup",label:"Setup Slack"},{value:"hold",label:"Hold Slack"},{value:"fanout",label:"Net Fanout"},{value:"netlength",label:"Net Length (HPWL)"}];function Sdn(s,n,r,c){if(!s||!n||cn.bottom)return null;for(let u of s)if(r>=u.x&&r<=u.x+u.width)return u;return null}function Mdn(s,n,r){return r?Math.log10(s+1)/Math.log10(n+1):s/n}function Tdn(s,n,r,c={}){let u=!!c.logY,d=s?.bins;if(!d||d.length===0)return{bars:[],yMax:0,yTicks:[],chartArea:null,logY:u};let b=l3t,w=n-u3t,_=f3t,x=r-h3t,T=w-b,M=x-_;if(T<=0||M<=0)return{bars:[],yMax:0,yTicks:[],chartArea:null,logY:u};let L={left:b,right:w,top:_,bottom:x},I=0;for(let Z of d)Z.count>I&&(I=Z.count);I===0&&(I=1);let{yMax:D,yTicks:F}=u?Adn(I):Cdn(I),O=(T-c3t*(d.length-1))/d.length,z=[];for(let Z=0;Z[x.x,...x.ys||[]].join(","));return[w,..._].join(` `)}let r=n.bins||[],c=Array.isArray(n.series)?n.series:[],u=["lower","upper","count",...c.map(b=>b.name||"group")].join(","),d=r.map((b,w)=>{let _=[b.lower,b.upper,b.count];for(let x of c)_.push(x.counts&&x.counts[w]||0);return _.join(",")});return[u,...d].join(` -`)}var Zhe=class{constructor(n,r){this._app=n,this._redrawAllLayers=r,this._currentTab="setup",this._histogramData=null,this._bars=[],this._yMax=0,this._yTicks=[],this._chartArea=null,this._hoveredBar=null,this._debugCharts=[],this._activeDebugChart=-1,this._build()}_build(){let n=document.createElement("div");n.className="charts-widget";let r=document.createElement("div");r.className="charts-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",ua(this._app)&&(this._updateBtn.style.display="none"),this._chartSelect=document.createElement("select"),this._chartSelect.className="charts-select",this._csvBtn=document.createElement("button"),this._csvBtn.className="or-btn",this._csvBtn.textContent="CSV",this._csvBtn.title="Export the current chart data as CSV",this._pngBtn=document.createElement("button"),this._pngBtn.className="or-btn",this._pngBtn.textContent="PNG",this._pngBtn.title="Export the current chart as a PNG image",this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",r.appendChild(this._updateBtn),r.appendChild(this._chartSelect),r.appendChild(this._csvBtn),r.appendChild(this._pngBtn),r.appendChild(this._statusLabel),n.appendChild(r);let c=document.createElement("div");c.className="charts-toolbar";let u=document.createElement("span");u.textContent="Path Groups:",u.style.color="var(--fg-muted)",u.style.fontSize="var(--fs-12)",this._pathGroupSelect=document.createElement("select"),this._pathGroupSelect.className="charts-select",this._pathGroupSelect.multiple=!0,this._pathGroupSelect.size=1,this._pathGroupSelect.title="Select 0 = all, or \u22651 to stack by group";let d=document.createElement("span");d.textContent="Clock:",d.style.color="var(--fg-muted)",d.style.fontSize="var(--fs-12)",this._clockSelect=document.createElement("select"),this._clockSelect.className="charts-select",this._clockSelect.innerHTML='',c.appendChild(u),c.appendChild(this._pathGroupSelect),c.appendChild(d),c.appendChild(this._clockSelect),n.appendChild(c),this._canvas=document.createElement("canvas"),this._canvas.className="charts-canvas",n.appendChild(this._canvas),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._tooltip.style.display="none",n.appendChild(this._tooltip),this._filterRow=c,this.element=n,this._ctx=this._canvas.getContext("2d"),this._rebuildSelect(),this._bindEvents(),ua(this._app)&&setTimeout(()=>this.update(),0)}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update()),this._chartSelect.addEventListener("change",()=>this._onSelectChange()),this._csvBtn.addEventListener("click",()=>this._exportCsv()),this._pngBtn.addEventListener("click",()=>this._exportPng()),this._pathGroupSelect.addEventListener("change",()=>this._fetchHistogram()),this._clockSelect.addEventListener("change",()=>this._fetchHistogram()),this._canvas.addEventListener("mousemove",r=>this._handleHover(r)),this._canvas.addEventListener("mouseleave",()=>{this._hoveredBar=null,this._tooltip.style.display="none",this._syncView()}),this._canvas.addEventListener("click",r=>this._handleClick(r)),this._canvas.addEventListener("dblclick",r=>this._handleDblClick(r)),new ResizeObserver(()=>this._syncView()).observe(this._canvas)}_sizeCanvas(){let n=this._canvas.getBoundingClientRect(),r=window.devicePixelRatio||1;this._canvas.width=n.width*r,this._canvas.height=n.height*r,this._ctx.setTransform(r,0,0,r,0,0)}_rebuildSelect(){let n=this._chartSelect;n.innerHTML="";for(let r of vdn){let c=document.createElement("option");c.value=r.value,c.textContent=r.label,n.appendChild(c)}this._debugCharts.forEach((r,c)=>{let u=document.createElement("option");u.value="gen:"+c,u.textContent=r.name||"Chart "+c,n.appendChild(u)}),n.value=this._activeDebugChart>=0?"gen:"+this._activeDebugChart:this._currentTab}_onSelectChange(){let n=this._chartSelect.value;n.startsWith("gen:")?(this._activeDebugChart=parseInt(n.slice(4),10)||0,this._hoveredBar=null,this._tooltip.style.display="none",this._syncView()):this._selectTab(n)}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...",this._statusLabel.textContent="";try{this._activeDebugChart<0?((this._currentTab==="setup"||this._currentTab==="hold")&&await this._fetchFilters(),await Promise.all([this._fetchHistogram(),this._fetchGenericCharts()])):await this._fetchGenericCharts()}catch(n){this._statusLabel.textContent="Error: "+n.message}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}async _fetchFilters(){let n=await this._app.websocketManager.request({type:"chart_filters"});this._populatePathGroups(n.path_groups||[]),this._populateClocks(n.clocks||[])}_populatePathGroups(n){let r=new Set(Array.from(this._pathGroupSelect.selectedOptions,c=>c.value));this._pathGroupSelect.innerHTML="";for(let c of n){let u=document.createElement("option");u.value=c,u.textContent=c,u.selected=r.has(c),this._pathGroupSelect.appendChild(u)}}_populateClocks(n){let r=this._clockSelect.value;this._clockSelect.innerHTML='';for(let c of n){let u=document.createElement("option");u.value=c,u.textContent=c,this._clockSelect.appendChild(u)}n.includes(r)&&(this._clockSelect.value=r)}async _fetchGenericCharts(){try{let n=await this._app.websocketManager.request({type:"debug_charts"});this.setDebugCharts(n.charts||[])}catch{}}async _fetchHistogram(){try{let n=this._currentTab,r;if(n==="fanout")r={type:"fanout_histogram"};else if(n==="netlength")r={type:"net_length_histogram",use_dbu:!!this._app.showDbu};else{r={type:"slack_histogram",is_setup:n==="setup"};let u=Array.from(this._pathGroupSelect.selectedOptions,d=>d.value).filter(Boolean);u.length>0&&(r.path_groups=u),this._clockSelect.value&&(r.clock_name=this._clockSelect.value)}let c=await this._app.websocketManager.request(r);if(this._currentTab!==n)return;if(this._histogramData=c,this._syncView(),n==="fanout"||n==="netlength"){let u=c.total_nets||0;this._statusLabel.textContent=`${u} nets`}else{let u=c.total_endpoints||0,d=c.unconstrained_count||0,b=u-d;this._statusLabel.textContent=`${b} endpoints`+(d>0?`, ${d} unconstrained`:"")}}catch(n){this._statusLabel.textContent="Error: "+n.message}}_selectTab(n){this._currentTab===n&&this._activeDebugChart<0||(this._currentTab=n,this._activeDebugChart=-1,this._chartSelect&&(this._chartSelect.value=n),this._filterRow.style.display=n==="setup"||n==="hold"?"":"none",this._hoveredBar=null,this._tooltip.style.display="none",this.update())}_computeLayout(){if(!this._histogramData)return;let n=this._canvas.getBoundingClientRect(),r=xdn(this._histogramData,n.width,n.height,{logY:this._currentTab==="fanout"});this._bars=r.bars,this._yMax=r.yMax,this._yTicks=r.yTicks,this._chartArea=r.chartArea,this._logY=!!r.logY}render(){this._syncView()}_stackedSeries(){let n=this._histogramData?.series;return Array.isArray(n)&&n.length>1?n:null}_render(){let n=this._canvas.getBoundingClientRect(),r=n.width,c=n.height,u=this._ctx,d=fk();if(u.clearRect(0,0,r,c),u.fillStyle=d.canvasBg,u.fillRect(0,0,r,c),!this._bars||this._bars.length===0){u.fillStyle=d.canvasText,u.font="14px "+d.fontSans,u.textAlign="center",u.textBaseline="middle";let b=ua(this._app)?"No histogram data available":'Click "Update" to load histogram';u.fillText(b,r/2,c/2);return}this._drawAxes(u,d),this._drawBars(u),this._drawTitle(u,r,d),this._stackedSeries()&&this._drawSeriesLegend(u,d)}_drawAxes(n,r){let c=this._chartArea;if(!c)return;n.strokeStyle=r.canvasAxis,n.lineWidth=1,n.beginPath(),n.moveTo(c.left,c.top),n.lineTo(c.left,c.bottom),n.stroke(),n.beginPath(),n.moveTo(c.left,c.bottom),n.lineTo(c.right,c.bottom),n.stroke(),n.fillStyle=r.canvasLabel,n.font="11px "+r.fontMono,n.textAlign="right",n.textBaseline="middle";let u=c.bottom-c.top;for(let L of this._yTicks){let I=this._logY?Math.log10(L+1)/Math.log10(this._yMax+1):L/this._yMax,D=c.bottom-I*u;n.fillText(this._formatCount(L),c.left-6,D),L>0&&(n.strokeStyle=r.canvasGrid,n.beginPath(),n.moveTo(c.left,D),n.lineTo(c.right,D),n.stroke(),n.strokeStyle=r.canvasAxis)}let d=this._currentTab,b=d==="fanout"||d==="netlength";n.save(),n.translate(14,(c.top+c.bottom)/2),n.rotate(-Math.PI/2),n.textAlign="center",n.textBaseline="middle",n.fillStyle=r.canvasTitle,n.font="11px "+r.fontMono,n.fillText(this._logY?"Nets (log)":b?"Nets":"Endpoints",0,0),n.restore(),n.textAlign="center",n.textBaseline="top",n.fillStyle=r.canvasLabel,n.font="10px "+r.fontMono;let w=this._histogramData.bins,_=this._histogramData.time_unit||this._histogramData.length_unit||"",x=w.length>0?w[0].upper-w[0].lower:1,T=d==="fanout"?0:Math.max(0,-Math.floor(Math.log10(x)));for(let L=0;L<=this._bars.length;L++){let I=L=0){this._hoveredBar=null,this._tooltip.style.display="none";return}let r=this._hitTestBar(n);if(r!==this._hoveredBar&&(this._hoveredBar=r,this._render()),r){let c=this._currentTab,u=r.upper-r.lower;if(c==="fanout"){let L=r.upper-1,I=r.lower===L?`${r.lower}`:`[${r.lower}, ${L}]`;this._tooltip.textContent=`Nets: ${r.count} +`)}var Zhe=class{constructor(n,r){this._app=n,this._redrawAllLayers=r,this._currentTab="setup",this._histogramData=null,this._bars=[],this._yMax=0,this._yTicks=[],this._chartArea=null,this._hoveredBar=null,this._debugCharts=[],this._activeDebugChart=-1,this._build()}_build(){let n=document.createElement("div");n.className="charts-widget";let r=document.createElement("div");r.className="charts-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",ua(this._app)&&(this._updateBtn.style.display="none"),this._chartSelect=document.createElement("select"),this._chartSelect.className="charts-select",this._csvBtn=document.createElement("button"),this._csvBtn.className="or-btn",this._csvBtn.textContent="CSV",this._csvBtn.title="Export the current chart data as CSV",this._pngBtn=document.createElement("button"),this._pngBtn.className="or-btn",this._pngBtn.textContent="PNG",this._pngBtn.title="Export the current chart as a PNG image",this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",r.appendChild(this._updateBtn),r.appendChild(this._chartSelect),r.appendChild(this._csvBtn),r.appendChild(this._pngBtn),r.appendChild(this._statusLabel),n.appendChild(r);let c=document.createElement("div");c.className="charts-toolbar";let u=document.createElement("span");u.textContent="Path Groups:",u.style.color="var(--fg-muted)",u.style.fontSize="var(--fs-12)",this._pathGroupSelect=document.createElement("select"),this._pathGroupSelect.className="charts-select",this._pathGroupSelect.multiple=!0,this._pathGroupSelect.size=1,this._pathGroupSelect.title="Select 0 = all, or \u22651 to stack by group";let d=document.createElement("span");d.textContent="Clock:",d.style.color="var(--fg-muted)",d.style.fontSize="var(--fs-12)",this._clockSelect=document.createElement("select"),this._clockSelect.className="charts-select",this._clockSelect.innerHTML='',c.appendChild(u),c.appendChild(this._pathGroupSelect),c.appendChild(d),c.appendChild(this._clockSelect),n.appendChild(c),this._canvas=document.createElement("canvas"),this._canvas.className="charts-canvas",n.appendChild(this._canvas),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._tooltip.style.display="none",n.appendChild(this._tooltip),this._filterRow=c,this.element=n,this._ctx=this._canvas.getContext("2d"),this._rebuildSelect(),this._bindEvents(),ua(this._app)&&setTimeout(()=>this.update(),0)}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update()),this._chartSelect.addEventListener("change",()=>this._onSelectChange()),this._csvBtn.addEventListener("click",()=>this._exportCsv()),this._pngBtn.addEventListener("click",()=>this._exportPng()),this._pathGroupSelect.addEventListener("change",()=>this._fetchHistogram()),this._clockSelect.addEventListener("change",()=>this._fetchHistogram()),this._canvas.addEventListener("mousemove",r=>this._handleHover(r)),this._canvas.addEventListener("mouseleave",()=>{this._hoveredBar=null,this._tooltip.style.display="none",this._syncView()}),this._canvas.addEventListener("click",r=>this._handleClick(r)),this._canvas.addEventListener("dblclick",r=>this._handleDblClick(r)),new ResizeObserver(()=>this._syncView()).observe(this._canvas)}_sizeCanvas(){let n=this._canvas.getBoundingClientRect(),r=window.devicePixelRatio||1;this._canvas.width=n.width*r,this._canvas.height=n.height*r,this._ctx.setTransform(r,0,0,r,0,0)}_rebuildSelect(){let n=this._chartSelect;n.innerHTML="";for(let r of Edn){let c=document.createElement("option");c.value=r.value,c.textContent=r.label,n.appendChild(c)}this._debugCharts.forEach((r,c)=>{let u=document.createElement("option");u.value="gen:"+c,u.textContent=r.name||"Chart "+c,n.appendChild(u)}),n.value=this._activeDebugChart>=0?"gen:"+this._activeDebugChart:this._currentTab}_onSelectChange(){let n=this._chartSelect.value;n.startsWith("gen:")?(this._activeDebugChart=parseInt(n.slice(4),10)||0,this._hoveredBar=null,this._tooltip.style.display="none",this._syncView()):this._selectTab(n)}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...",this._statusLabel.textContent="";try{this._activeDebugChart<0?((this._currentTab==="setup"||this._currentTab==="hold")&&await this._fetchFilters(),await Promise.all([this._fetchHistogram(),this._fetchGenericCharts()])):await this._fetchGenericCharts()}catch(n){this._statusLabel.textContent="Error: "+n.message}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}async _fetchFilters(){let n=await this._app.websocketManager.request({type:"chart_filters"});this._populatePathGroups(n.path_groups||[]),this._populateClocks(n.clocks||[])}_populatePathGroups(n){let r=new Set(Array.from(this._pathGroupSelect.selectedOptions,c=>c.value));this._pathGroupSelect.innerHTML="";for(let c of n){let u=document.createElement("option");u.value=c,u.textContent=c,u.selected=r.has(c),this._pathGroupSelect.appendChild(u)}}_populateClocks(n){let r=this._clockSelect.value;this._clockSelect.innerHTML='';for(let c of n){let u=document.createElement("option");u.value=c,u.textContent=c,this._clockSelect.appendChild(u)}n.includes(r)&&(this._clockSelect.value=r)}async _fetchGenericCharts(){try{let n=await this._app.websocketManager.request({type:"debug_charts"});this.setDebugCharts(n.charts||[])}catch{}}async _fetchHistogram(){try{let n=this._currentTab,r;if(n==="fanout")r={type:"fanout_histogram"};else if(n==="netlength")r={type:"net_length_histogram",use_dbu:!!this._app.showDbu};else{r={type:"slack_histogram",is_setup:n==="setup"};let u=Array.from(this._pathGroupSelect.selectedOptions,d=>d.value).filter(Boolean);u.length>0&&(r.path_groups=u),this._clockSelect.value&&(r.clock_name=this._clockSelect.value)}let c=await this._app.websocketManager.request(r);if(this._currentTab!==n)return;if(this._histogramData=c,this._syncView(),n==="fanout"||n==="netlength"){let u=c.total_nets||0;this._statusLabel.textContent=`${u} nets`}else{let u=c.total_endpoints||0,d=c.unconstrained_count||0,b=u-d;this._statusLabel.textContent=`${b} endpoints`+(d>0?`, ${d} unconstrained`:"")}}catch(n){this._statusLabel.textContent="Error: "+n.message}}_selectTab(n){this._currentTab===n&&this._activeDebugChart<0||(this._currentTab=n,this._activeDebugChart=-1,this._chartSelect&&(this._chartSelect.value=n),this._filterRow.style.display=n==="setup"||n==="hold"?"":"none",this._hoveredBar=null,this._tooltip.style.display="none",this.update())}_computeLayout(){if(!this._histogramData)return;let n=this._canvas.getBoundingClientRect(),r=Tdn(this._histogramData,n.width,n.height,{logY:this._currentTab==="fanout"});this._bars=r.bars,this._yMax=r.yMax,this._yTicks=r.yTicks,this._chartArea=r.chartArea,this._logY=!!r.logY}render(){this._syncView()}_stackedSeries(){let n=this._histogramData?.series;return Array.isArray(n)&&n.length>1?n:null}_render(){let n=this._canvas.getBoundingClientRect(),r=n.width,c=n.height,u=this._ctx,d=fk();if(u.clearRect(0,0,r,c),u.fillStyle=d.canvasBg,u.fillRect(0,0,r,c),!this._bars||this._bars.length===0){u.fillStyle=d.canvasText,u.font="14px "+d.fontSans,u.textAlign="center",u.textBaseline="middle";let b=ua(this._app)?"No histogram data available":'Click "Update" to load histogram';u.fillText(b,r/2,c/2);return}this._drawAxes(u,d),this._drawBars(u),this._drawTitle(u,r,d),this._stackedSeries()&&this._drawSeriesLegend(u,d)}_drawAxes(n,r){let c=this._chartArea;if(!c)return;n.strokeStyle=r.canvasAxis,n.lineWidth=1,n.beginPath(),n.moveTo(c.left,c.top),n.lineTo(c.left,c.bottom),n.stroke(),n.beginPath(),n.moveTo(c.left,c.bottom),n.lineTo(c.right,c.bottom),n.stroke(),n.fillStyle=r.canvasLabel,n.font="11px "+r.fontMono,n.textAlign="right",n.textBaseline="middle";let u=c.bottom-c.top;for(let L of this._yTicks){let I=this._logY?Math.log10(L+1)/Math.log10(this._yMax+1):L/this._yMax,D=c.bottom-I*u;n.fillText(this._formatCount(L),c.left-6,D),L>0&&(n.strokeStyle=r.canvasGrid,n.beginPath(),n.moveTo(c.left,D),n.lineTo(c.right,D),n.stroke(),n.strokeStyle=r.canvasAxis)}let d=this._currentTab,b=d==="fanout"||d==="netlength";n.save(),n.translate(14,(c.top+c.bottom)/2),n.rotate(-Math.PI/2),n.textAlign="center",n.textBaseline="middle",n.fillStyle=r.canvasTitle,n.font="11px "+r.fontMono,n.fillText(this._logY?"Nets (log)":b?"Nets":"Endpoints",0,0),n.restore(),n.textAlign="center",n.textBaseline="top",n.fillStyle=r.canvasLabel,n.font="10px "+r.fontMono;let w=this._histogramData.bins,_=this._histogramData.time_unit||this._histogramData.length_unit||"",x=w.length>0?w[0].upper-w[0].lower:1,T=d==="fanout"?0:Math.max(0,-Math.floor(Math.log10(x)));for(let L=0;L<=this._bars.length;L++){let I=L=0){this._hoveredBar=null,this._tooltip.style.display="none";return}let r=this._hitTestBar(n);if(r!==this._hoveredBar&&(this._hoveredBar=r,this._render()),r){let c=this._currentTab,u=r.upper-r.lower;if(c==="fanout"){let L=r.upper-1,I=r.lower===L?`${r.lower}`:`[${r.lower}, ${L}]`;this._tooltip.textContent=`Nets: ${r.count} Fanout: ${I}`}else if(c==="netlength"){let L=this._histogramData?.length_unit||"",I=Math.max(0,-Math.floor(Math.log10(u)));this._tooltip.textContent=`Nets: ${r.count} Length: [${r.lower.toFixed(I)}, ${r.upper.toFixed(I)}) ${L}`}else{let L=this._histogramData?.time_unit||"",I=Math.max(0,-Math.floor(Math.log10(u)));this._tooltip.textContent=`Endpoints: ${r.count} -Slack: [${r.lower.toFixed(I)}, ${r.upper.toFixed(I)}) ${L}`}this._tooltip.style.display="block";let d=this.element.getBoundingClientRect(),b=this._tooltip.getBoundingClientRect(),w=4,_=n.clientX-d.left,x=n.clientY-d.top,T=_+12;T+b.width>d.width-w&&(T=_-12-b.width),T=Math.max(w,T);let M=x-10;M=Math.min(d.height-b.height-w,Math.max(w,M)),this._tooltip.style.left=T+"px",this._tooltip.style.top=M+"px"}else this._tooltip.style.display="none"}async _handleClick(n){if(this._activeDebugChart>=0||this._currentTab==="fanout"||this._currentTab==="netlength")return;let r=this._hitTestBar(n);if(!(!r||r.count===0))try{let c=await this._app.websocketManager.request({type:"timing_report",is_setup:this._currentTab==="setup",max_paths:50,slack_min:r.lower,slack_max:r.upper});this._app.timingWidget&&(this._app.timingWidget.showPaths(this._currentTab,c.paths||[]),this._app.focusComponent&&this._app.focusComponent("TimingWidget"))}catch(c){console.error("Charts bar click error:",c)}}async _handleDblClick(n){if(this._activeDebugChart>=0)return;let r;if(this._currentTab==="fanout")r="select_fanout_bin";else if(this._currentTab==="netlength")r="select_net_length_bin";else return;let c=this._hitTestBar(n);if(!c||c.count===0)return;let u=Pm(this._app);try{let d=await this._app.websocketManager.request({type:r,lower:c.lower,upper:c.upper,use_dbu:this._app.showDbu});if(!Z1(this._app,u))return;d&&d.truncated&&console.warn(`Bin has ${d.count} nets; selection capped at ${d.selection_limit} for performance.`),this._app.updateInspector&&this._app.updateInspector(d),this._app.focusComponent&&this._app.focusComponent("Inspector"),this._redrawAllLayers&&this._redrawAllLayers()}catch(d){console.error("Net bin select failed:",d)}}_activeChartData(){return this._activeDebugChart>=0?{kind:"generic",data:this._debugCharts[this._activeDebugChart]}:{kind:"histogram",data:this._histogramData}}_chartBaseName(){return this._activeDebugChart>=0?this._debugCharts[this._activeDebugChart].name||"chart":this._currentTab}_triggerDownload(n,r,{revoke:c=!1}={}){let u=document.createElement("a");u.href=r,u.download=n,document.body.appendChild(u),u.click(),u.remove(),c&&URL.revokeObjectURL(r)}_download(n,r,c){try{let u=URL.createObjectURL(new Blob([c],{type:r}));this._triggerDownload(n,u,{revoke:!0})}catch(u){console.error("Download failed:",u)}}_exportCsv(){let{kind:n,data:r}=this._activeChartData();if(!r)return;let c=Mdn(n,r);this._download(this._chartBaseName()+".csv","text/csv",c)}_exportPng(){try{let n=this._canvas.toDataURL("image/png");this._triggerDownload(this._chartBaseName()+".png",n)}catch(n){console.error("PNG export failed:",n)}}setDebugCharts(n){this._debugCharts=n,n.length===0?this._activeDebugChart=-1:this._activeDebugChart>=n.length&&(this._activeDebugChart=0),this._rebuildSelect(),this._syncView()}_syncView(){let n=this._activeDebugChart>=0;n&&(this._hoveredBar=null,this._tooltip.style.display="none");let r=!n&&(this._currentTab==="setup"||this._currentTab==="hold");this._filterRow&&(this._filterRow.style.display=r?"":"none"),this._sizeCanvas(),n?this._renderLineChart(this._debugCharts[this._activeDebugChart]):(this._computeLayout(),this._render())}_renderLineChart(n){let r=this._canvas.getBoundingClientRect(),c=r.width,u=r.height,d=this._ctx,b=fk();d.clearRect(0,0,c,u),d.fillStyle=b.canvasBg,d.fillRect(0,0,c,u);let w=n.points;if(!w||w.length===0){d.fillStyle=b.canvasText,d.font="14px "+b.fontSans,d.textAlign="center",d.textBaseline="middle",d.fillText("No data points yet",c/2,u/2);return}let _=n.y_labels?n.y_labels.length:1,x=a3t,T=c-c3t,M=l3t,L=u-u3t,I=T-x,D=L-M;if(I<=0||D<=0)return;let F=w[0].x,O=w[0].x,z=1/0,Z=-1/0;for(let ue of w){ue.xO&&(O=ue.x);for(let Te of ue.ys)TeZ&&(Z=Te)}F===O&&(O=F+1),(!isFinite(z)||!isFinite(Z))&&(z=0,Z=1);let H=(Z-z)*.05||1;z-=H,Z+=H;let te=ue=>x+(ue-F)/(O-F)*I,oe=ue=>L-(ue-z)/(Z-z)*D;d.strokeStyle=b.canvasAxis,d.lineWidth=1,d.beginPath(),d.moveTo(x,M),d.lineTo(x,L),d.lineTo(T,L),d.stroke(),d.fillStyle=b.canvasLabel,d.font="10px "+b.fontMono,d.textAlign="right",d.textBaseline="middle";let ne=5;for(let ue=0;ue<=ne;ue++){let Te=z+(Z-z)*ue/ne,Q=oe(Te);d.fillText(this._formatNum(Te),x-4,Q),ue>0&&ue1&&n.y_labels){d.font="10px "+b.fontMono,d.textAlign="left",d.textBaseline="top";let ue=x+8,Te=M+4;for(let Q=0;Q<_;Q++){let ge=xT[Q%xT.length];d.fillStyle=ge,d.fillRect(ue,Te+Q*14,12,10),d.fillStyle=b.canvasLabel,d.fillText(n.y_labels[Q],ue+16,Te+Q*14)}}}_formatNum(n){let r=Math.abs(n);return r===0?"0":r>=1e6?(n/1e6).toFixed(1)+"M":r>=1e3?(n/1e3).toFixed(1)+"k":r>=1?n.toFixed(1):n.toPrecision(3)}_formatCount(n){return n===0?"0":n>=1e6?n/1e6+"M":n>=1e3?n/1e3+"k":String(n)}};var Rv=class{constructor(n){this.onChange=n,this.roots=[],this._nodeMap=new Map}addFromSpec(n,r=null){let c=this._makeNode(n.id,r,n);if(c.checked=n.checked!==!1,n.children){for(let u of n.children)c.children.push(this.addFromSpec(u,c));c.hasCheckbox&&this._computeParent(c)}return r||this.roots.push(c),c}buildFromNodes(n){this._nodeMap.clear(),this.roots=[];for(let r of n)this._makeNode(r.id,null,r);for(let r of n){let c=this._nodeMap.get(r.id);if(r.parentId!=null&&this._nodeMap.has(r.parentId)){let u=this._nodeMap.get(r.parentId);c.parent=u,u.children.push(c)}else this.roots.push(c)}for(let r=n.length-1;r>=0;r--){let c=this._nodeMap.get(n[r].id);c.hasCheckbox&&c.children.length>0&&this._computeParent(c)}return this.roots}get(n){return this._nodeMap.get(n)}isVisible(n){let r=this.get(n);return r?r.checked:!1}check(n,r){let c=this._nodeMap.get(n);if(c){c.checked=r,c.indeterminate=!1;for(let u of c.children)this._setSubtree(u,r);for(let u=c.parent;u;u=u.parent)u.hasCheckbox&&this._computeParent(u);this.onChange()}}cascadeQuiet(n,r){let c=this._nodeMap.get(n);if(c){c.checked=r,c.indeterminate=!1;for(let u of c.children)this._setSubtree(u,r);for(let u=c.parent;u;u=u.parent)u.hasCheckbox&&this._computeParent(u)}}checkSet(n){for(let[r,c]of Object.entries(n)){let u=this._nodeMap.get(r);u&&(u.checked=c,u.indeterminate=!1)}this._recomputeAllParents(),this.onChange()}mirrorStates(n){this._applyMirror(n),this.onChange()}mirrorStatesQuiet(n){this._applyMirror(n)}_applyMirror(n){for(let[r,c]of Object.entries(n)){let u=this._nodeMap.get(r);u&&(u.checked=!!c.checked,u.indeterminate=!!c.indeterminate)}}forEach(n){let r=c=>{n(c);for(let u of c.children)r(u)};for(let c of this.roots)r(c)}_makeNode(n,r,c){let u={id:n,parent:r,children:[],hasCheckbox:c.hasCheckbox!==!1,checked:c.checked!==!1,indeterminate:!1,data:c.data!=null?c.data:c};return this._nodeMap.set(n,u),u}_checkboxDescendants(n){let r=[];for(let c of n.children)c.hasCheckbox?r.push(c):r.push(...this._checkboxDescendants(c));return r}_computeParent(n){let r=this._checkboxDescendants(n);if(r.length===0)return;let c=r.every(d=>d.checked&&!d.indeterminate),u=r.every(d=>!d.checked&&!d.indeterminate);n.checked=c,n.indeterminate=!c&&!u}_setSubtree(n,r){n.hasCheckbox&&(n.checked=r,n.indeterminate=!1);for(let c of n.children)this._setSubtree(c,r)}_recomputeAllParents(){let n=r=>{for(let c of r.children)n(c);r.hasCheckbox&&r.children.length>0&&this._computeParent(r)};for(let r of this.roots)n(r)}};var f3t=["Instance","Module","Instances","Macros","Modules","Area","Local Inst","Local Macros","Local Modules"],ET={MODULE:0,LEAF_GROUP:1,TYPE_GROUP:2,INSTANCE:3,NAME_GROUP:4};function dk(s){return s===ET.MODULE||s===ET.NAME_GROUP}var Khe=class{constructor(n,r,c){this._app=r,this._redrawAllLayers=c,this._nodes=[],this._nameGrouped=!1,this._nameGroupsCapped=!1,this._rows=[],this._childrenMap=new Map,this._collapsed=new Set,this._moduleState=new Map,this._checkModel=null,this._build(n),r.hierarchyBrowser=this,ua(r)&&this.update()}_build(n){let r=document.createElement("div");r.className="hierarchy-widget";let c=document.createElement("div");c.className="timing-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",ua(this._app)&&(this._updateBtn.style.display="none"),this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",c.appendChild(this._updateBtn),c.appendChild(this._statusLabel),r.appendChild(c),this._tableContainer=document.createElement("div"),this._tableContainer.className="hierarchy-table-container",this._table=document.createElement("table"),this._table.className="timing-table",this._tableContainer.appendChild(this._table),r.appendChild(this._tableContainer),n.element.appendChild(r),this._bindEvents()}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update())}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...",this._statusLabel.textContent="";try{let n=await this._app.websocketManager.request({type:"module_hierarchy"});this._nodes=n.nodes||[],this._nameGrouped=!!n.name_grouped,this._nameGroupsCapped=!!n.name_groups_capped,this._buildTree(),this._readServerColors(),this._computeEffectiveColors(),this._render(),this._statusLabel.textContent=this._statusText(),await this._sendModuleColors()}catch(n){this._statusLabel.textContent="Error: "+n.message}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}_statusText(){let n=this._nodes.filter(u=>dk(u.node_kind||0)).length;if(!this._nameGrouped)return n+" modules";let c=Math.max(0,n-1)+" groups from instance names \u2014 this design has no module hierarchy";return this._nameGroupsCapped&&(c+=" (truncated: too many groups)"),c}_buildTree(){this._childrenMap.clear(),this._collapsed.clear();for(let r of this._nodes)this._childrenMap.set(r.id,[]);for(let r of this._nodes)r.parent_id>=0&&this._childrenMap.has(r.parent_id)&&this._childrenMap.get(r.parent_id).push(r.id);this._nodeMap=new Map;for(let r of this._nodes)this._nodeMap.set(r.id,r);for(let r of this._nodes){let c=this._childrenMap.get(r.id);if(!c||c.length===0)continue;let u=r.node_kind||0;u===ET.LEAF_GROUP||u===ET.TYPE_GROUP?this._collapsed.add(r.id):dk(u)&&r.parent_id>=0&&this._collapsed.add(r.id)}this._rows=[];let n=this._nodes.filter(r=>r.parent_id<0);for(let r of n)this._dfs(r.id,0);this._checkModel=new Rv(()=>{this._checkModel.forEach(r=>{if(!r.hasCheckbox)return;let c=this._moduleState.get(r.data.odb_id);c&&(c.visible=r.checked)}),this._sendModuleColors()}),this._checkModel.buildFromNodes(this._nodes.map(r=>({id:r.id,parentId:r.parent_id,hasCheckbox:dk(r.node_kind||0)&&r.odb_id!=null,checked:!0,data:r})))}_readServerColors(){this._moduleState.clear();for(let n of this._rows){let r=this._nodeMap.get(n.id);if(!r||!dk(r.node_kind||0)||r.odb_id==null)continue;let c=r.color||[128,128,128];this._moduleState.set(r.odb_id,{color:c,effectiveColor:c,visible:!0,nodeId:r.id})}}_computeEffectiveColors(){for(let n of this._rows){let r=this._nodeMap.get(n.id);if(!r||!dk(r.node_kind||0))continue;let c=this._moduleState.get(r.odb_id);if(!c)continue;let u=r.parent_id,d=null;for(;u>=0;){let b=this._nodeMap.get(u);if(!b)break;if(dk(b.node_kind||0)){let w=this._moduleState.get(b.odb_id);w&&this._collapsed.has(b.id)&&(d=w.effectiveColor)}u=b.parent_id}c.effectiveColor=d||c.color}}async _sendModuleColors(){let n=[];for(let[c,u]of this._moduleState){if(!u.visible)continue;let[d,b,w]=u.effectiveColor;n.push(`${c}:${d},${b},${w},100`)}let r=n.join(";");try{let c=await this._app.websocketManager.request({type:"set_module_colors",colors:r});console.log("set_module_colors:",c.count,"modules,",n.length,"sent")}catch(c){console.error("set_module_colors failed:",c)}this._redrawAllLayers()}_dfs(n,r){this._rows.push({id:n,depth:r});let c=this._childrenMap.get(n)||[];for(let u of c)this._dfs(u,r+1)}_render(){this._table.innerHTML="";let n=document.createElement("thead"),r=document.createElement("tr");for(let u of f3t){let d=document.createElement("th");d.textContent=u,r.appendChild(d)}n.appendChild(r),this._table.appendChild(n);let c=document.createElement("tbody");for(let u of this._rows){let d=this._nodeMap.get(u.id);if(!d||this._isHidden(d))continue;let b=document.createElement("tr"),w=d.node_kind||0,x=(this._childrenMap.get(u.id)||[]).length>0,T=this._collapsed.has(u.id);w===ET.LEAF_GROUP||w===ET.TYPE_GROUP?(b.style.fontStyle="italic",b.style.color="var(--fg-disabled)"):w===ET.INSTANCE?b.style.color="var(--fg-secondary)":w===ET.NAME_GROUP&&(b.classList.add("hierarchy-name-group"),b.title="Recovered from instance names \u2014 this design has no module hierarchy");let M=document.createElement("td");if(M.style.paddingLeft=8+u.depth*16+"px",M.style.whiteSpace="nowrap",dk(w)&&d.odb_id!=null){let D=this._moduleState.get(d.odb_id),F=this._checkModel?this._checkModel.get(d.id):null;if(D&&F){let O=document.createElement("input");O.type="checkbox",O.checked=F.checked,O.indeterminate=F.indeterminate,O.className="hierarchy-module-cb",F.cb=O,O.addEventListener("change",oe=>{oe.stopPropagation(),this._checkModel.check(d.id,O.checked),this._render()}),M.appendChild(O);let z=document.createElement("span");z.className="hierarchy-color-swatch";let[Z,H,te]=D.effectiveColor;z.style.backgroundColor=`rgb(${Z},${H},${te})`,M.appendChild(z)}}if(x){let D=document.createElement("span");D.className="hierarchy-arrow",D.textContent=T?"\u25B6":"\u25BC",D.addEventListener("click",F=>{F.stopPropagation(),this._toggleNode(u.id)}),M.appendChild(D)}else{let D=document.createElement("span");D.className="hierarchy-arrow",D.style.visibility="hidden",D.textContent="\u25B6",M.appendChild(D)}let L=document.createElement("span");L.textContent=d.inst_name,M.appendChild(L),b.appendChild(M);let I=[d.module_name,TO(d.insts),TO(d.macros),TO(d.modules),this._fmtArea(d.area),TO(d.local_insts),TO(d.local_macros),TO(d.local_modules)];for(let D of I){let F=document.createElement("td");F.textContent=D,F.style.textAlign="right",b.appendChild(F)}b.children[1].style.textAlign="left",c.appendChild(b)}if(this._rows.length===0){let u=document.createElement("tr"),d=document.createElement("td");d.colSpan=f3t.length,d.style.textAlign="center",d.style.color="var(--fg-secondary)",d.textContent=ua(this._app)?"No hierarchy data available":'Click "Update" to load hierarchy',u.appendChild(d),c.appendChild(u)}this._table.appendChild(c),ak(this._table)}_isHidden(n){let r=n.parent_id;for(;r>=0;){if(this._collapsed.has(r))return!0;let c=this._nodeMap.get(r);if(!c)break;r=c.parent_id}return!1}_toggleNode(n){this._collapsed.has(n)?this._collapsed.delete(n):this._collapsed.add(n),this._computeEffectiveColors(),this._render(),this._sendModuleColors()}_fmtArea(n){if(n==null)return"";if(this._app.showDbu){let r=this._app.getDbuPerMicron();return String(Math.round(n*r*r))}return n>=1e6?(n/1e6).toFixed(3)+" mm\xB2":n.toFixed(3)+" \u03BCm\xB2"}};function TO(s){return s!=null?String(s):""}var Tdn='',Cdn='',Adn='',Pdn='',Ldn='',kdn='',Rdn='',Idn='',Ddn='',Bdn='',Odn='',Ndn='';function h3t(s,n,r){r=r||n;let c=null,u=null,d=null,b=!1,w=10;function _(Ge,Ae){return b?Promise.resolve():(b=!0,s.websocketManager.request({type:"set_property",name:Ge,use_dbu:s.showDbu,...Ae}).then(Le=>{!Le.ok&&Le.error&&Y1(Le.error),xi(Le),Le.ok&&Le.bbox&&Si(Le.bbox)}).catch(Le=>{console.error("set_property failed:",Le),Y1("Edit failed: "+Le),c&&xi(c)}).finally(()=>{b=!1}))}function x(Ge,Ae){let Le=document.createElement("select");Le.className="inspector-editor-select";let ht=Ge.editor.type==="bool"?["True","False"]:Ge.editor.options||[];for(let Ye of ht){let ct=document.createElement("option");ct.value=Ye,ct.textContent=Ye,Ye===Ge.value&&(ct.selected=!0),Le.appendChild(ct)}if(!ht.includes(Ge.value)){let Ye=document.createElement("option");Ye.value=Ge.value||"",Ye.textContent=Ge.value||"",Ye.selected=!0,Ye.disabled=!0,Le.insertBefore(Ye,Le.firstChild)}return Le.addEventListener("change",()=>{if(Ae.onPropertyChange){Ae.onPropertyChange(Ge.name,Le.value);return}if(Ge.editor.type==="bool")Ae.onPropertyEdit(Ge,{value:Le.value==="True"});else{let Ye=(Ge.editor.options||[]).indexOf(Le.value);Ae.onPropertyEdit(Ge,{option_index:Ye,option_name:Le.value})}}),Le}async function T(Ge,Ae){if(!b&&!(Ge==="Delete"&&!await Bxt({title:"Delete "+(Ae.type||"object"),message:"Delete "+(Ae.type||"object")+' "'+(Ae.name||"")+'"? This cannot be undone.',confirmLabel:"Delete",danger:!0}))){b=!0;try{let Le=await s.websocketManager.request({type:"trigger_action",name:Ge,use_dbu:s.showDbu});!Le.ok&&Le.error&&Y1(Le.error),xi(Le.properties?Le:null),Le.deleted&&qn(),ot(),r()}catch(Le){console.error("trigger_action failed:",Le),Y1("Action failed: "+Le)}finally{b=!1}}}function M(Ge){s.websocketManager.request({...Ge,use_dbu:s.showDbu}).then(Ae=>{!Ae.ok&&Ae.error&&Y1(Ae.error),xi(Ae),r()}).catch(Ae=>{console.error(Ge.type+" failed:",Ae)})}function L(){let Ge=document.getElementById("highlight-picker");Ge&&Ge.remove()}function I(Ge,Ae){L();let Le=s.techData?.highlight_colors||[];if(!Le.length)return;let ht=document.createElement("div");ht.id="highlight-picker";let Ye=document.createElement("div");if(Ye.className="highlight-swatch-grid",Le.forEach((Ke,pt)=>{let Xn=document.createElement("button");Xn.className="highlight-swatch",Xn.title="Group "+(pt+1),Xn.style.backgroundColor=`rgb(${Ke[0]}, ${Ke[1]}, ${Ke[2]})`,pt===Ae.highlight_group&&Xn.classList.add("active"),Xn.addEventListener("click",()=>{L(),M({type:"highlight",group:pt})}),Ye.appendChild(Xn)}),ht.appendChild(Ye),Ae.highlight_group>=0){let Ke=document.createElement("button");Ke.className="highlight-remove",Ke.textContent="Remove highlight",Ke.addEventListener("click",()=>{L(),M({type:"unhighlight"})}),ht.appendChild(Ke)}document.body.appendChild(ht);let ct=Ge.getBoundingClientRect();ht.style.left=ct.left+"px",ht.style.top=ct.bottom+4+"px";let Ze=Ke=>{Ke.type==="keydown"&&Ke.key!=="Escape"||Ke.type==="mousedown"&&ht.contains(Ke.target)||(L(),document.removeEventListener("mousedown",Ze,!0),document.removeEventListener("keydown",Ze,!0))};setTimeout(()=>{document.addEventListener("mousedown",Ze,!0),document.addEventListener("keydown",Ze,!0)},0)}function D(){if(!s.inspectorEl)return;s.inspectorEl.innerHTML="";let Ge=document.createElement("div");Ge.className="stub-panel",Ge.innerHTML='
Loading\u2026
Fetching properties from server.
',s.inspectorEl.appendChild(Ge)}async function F(Ge){let Ae=s.focusNets.has(Ge)?"remove":"add";Ae==="add"?s.focusNets.add(Ge):s.focusNets.delete(Ge);try{await s.websocketManager.request({type:"set_focus_nets",action:Ae,net_name:Ge})}catch(Le){console.error("set_focus_nets failed:",Le)}n(),c&&xi(c)}async function O(){s.focusNets.clear();try{await s.websocketManager.request({type:"set_focus_nets",action:"clear",net_name:""})}catch(Ge){console.error("set_focus_nets clear failed:",Ge)}n(),c&&xi(c)}async function z(Ge){let Ae=s.routeGuideNets.has(Ge)?"remove":"add";Ae==="add"?s.routeGuideNets.add(Ge):s.routeGuideNets.delete(Ge);try{await s.websocketManager.request({type:"set_route_guides",action:Ae,net_name:Ge})}catch(Le){console.error("set_route_guides failed:",Le)}r(),c&&xi(c)}function Z(Ge,Ae,Le,ht){return X1(Ge,Ae,Le,ht,s.designScale,s.designOriginX,s.designOriginY)}function H(Ge,Ae,Le){return Ge+(Ae-Ge)*Le}function te(Ge,Ae,Le){return Ge.map((ht,Ye)=>Math.round(H(ht,Ae[Ye],Le)))}function oe(Ge,Ae){let Le=0;for(;LeGe[Le+1].at;)Le++;let ht=Ge[Le],Ye=Ge[Le+1],ct=Math.max(0,Math.min(1,(Ae-ht.at)/(Ye.at-ht.at))),Ze={};for(let Ke of Object.keys(ht))Ke!=="at"&&(Ze[Ke]=Array.isArray(ht[Ke])?te(ht[Ke],Ye[Ke],ct):H(ht[Ke],Ye[Ke],ct));return Ze}function ne(Ge,Ae,Le,ht){if(nH()||typeof requestAnimationFrame!="function")return ht(),()=>{};let Ye=performance.now(),ct=!1,Ze=()=>{if(ct)return;let Ke=performance.now()-Ye;if(Ke>=Ge*Ae){ht();return}Le(Ke%Ge/Ge),requestAnimationFrame(Ze)};return Ze(),()=>{ct=!0}}function ue(Ge,Ae,Le=bp.highlight){s.view&&s.view.setOverlay(Ge,Ae,{order:Le})}let Te=null,Q=()=>{},ge=[255,242,122],Qe=[{at:0,stroke:[255,246,176],width:7,alpha:1,fill:.28},{at:.55,stroke:[255,255,255],width:5,alpha:1,fill:.06},{at:1,stroke:[255,232,92],width:3,alpha:.95,fill:.14}],st={stroke:[255,232,92],width:3,alpha:1,fill:.14};function at(Ge,Ae,Le,ht){let[Ye,ct,Ze,Ke]=Z(Ge,Ae,Le,ht),pt=w/2**s.view.getZoom(),Xn=Math.max(0,(pt-(Ze-Ye))/2),_i=Math.max(0,(pt-(Ke-ct))/2);return[Ye-Xn,ct-_i,Ze+Xn,Ke+_i]}function Ne(Ge){Te&&ue("hover",Te.map(([Ae,Le,ht,Ye])=>({kind:"rect",rect:at(Ae,Le,ht,Ye),stroke:K1(Ge.stroke,Ge.alpha),width:Ge.width,fill:K1(ge,Ge.fill)})))}function tt(){Ne(st)}function ot(){Q(),Te=null,ue("hover",null),s.view?.off("zoom",tt)}function Tt(){ot(),s.websocketManager.request({type:"hover",select_id:-1}).then(()=>{}).catch(()=>{})}function jt(Ge){ot(),!(!s.view||!s.designScale||!Ge||Ge.length===0)&&(Te=Ge,s.view.on("zoom",tt),Q=ne(900,3,Ae=>Ne(oe(Qe,1-Math.pow(1-Ae,2))),()=>Ne(st)))}function en(Ge,Ae){Ge.classList.add("inspector-link"),Ge.addEventListener("click",Le=>{Le.stopPropagation(),cn(Ae)}),Ge.addEventListener("mouseenter",()=>{d!==null&&(s.websocketManager.cancel(d),d=null);let Le=s.websocketManager.request({type:"hover",select_id:Ae});d=Le.requestId,Le.then(ht=>{d=null,jt(ht.rects||[]),r()}).catch(()=>{d=null})}),Ge.addEventListener("mouseleave",()=>{Tt(),r()})}function mn(Ge){let Ae=Ge>0?"select_next":"select_prev";u!==null&&(s.websocketManager.cancel(u),u=null),D();let Le=Pm(s),ht=s.websocketManager.request({type:Ae,use_dbu:s.showDbu});u=ht.requestId,ht.then(Ye=>{if(u=null,!!Z1(s,Le)){if(Ye.error){console.error("Selection cycle error:",Ye.error),xi(c);return}if(xi(Ye),Ye.type==="Inst"&&Ye.name&&(s.selectedInstanceName=Ye.name,s.schematicWidget&&s.schematicWidget.refresh()),ot(),qn(),Ye.bbox&&s.view&&s.designScale){let[ct,Ze,Ke,pt]=Ye.bbox;Ye.type!=="Inst"&&Yi(ct,Ze,Ke,pt,Ye.type),Ye.selection_count>1?it(Ye.bbox):Si(Ye.bbox,Ye.type)}n()}}).catch(Ye=>{u=null,console.error("Selection cycle failed:",Ye),xi(c)})}function cn(Ge){u!==null&&(s.websocketManager.cancel(u),u=null),D();let Ae=Pm(s),Le=s.websocketManager.request({type:"inspect",select_id:Ge,use_dbu:s.showDbu});u=Le.requestId,Le.then(ht=>{if(u=null,!!Z1(s,Ae)){if(ht.error){console.error("Inspect error:",ht.error);return}if(xi(ht),ot(),qn(),ht.bbox&&s.view&&s.designScale){let[Ye,ct,Ze,Ke]=ht.bbox;ht.type!=="Inst"&&Yi(Ye,ct,Ze,Ke,ht.type),Si(ht.bbox,ht.type)}r()}}).catch(ht=>{u=null,console.error("Inspect failed:",ht)})}function bi(){u!==null&&(s.websocketManager.cancel(u),u=null),D();let Ge=Pm(s),Ae=s.websocketManager.request({type:"inspect_back",use_dbu:s.showDbu});u=Ae.requestId,Ae.then(Le=>{if(u=null,!!Z1(s,Ge)){if(Le.error){console.error("Inspect back error:",Le.error);return}if(xi(Le),ot(),qn(),Le.bbox&&s.view&&s.designScale){if(Le.type!=="Inst"){let[ht,Ye,ct,Ze]=Le.bbox;Yi(ht,Ye,ct,Ze,Le.type)}Si(Le.bbox,Le.type)}r()}}).catch(Le=>{u=null,console.error("Inspect back failed:",Le)})}let Vt=null;function pn(){let Ge=Vt&&s.designScale&&!(s.visibility&&s.visibility.highlight_selected===!1);ue("selection",Ge?[{kind:"rect",rect:Z(...Vt),stroke:K1("#ff0"),width:2,dash:[6,4]}]:null,bp.selection)}function qn(){Vt=null,pn()}function Yi(Ge,Ae,Le,ht,Ye){Vt=Ye==="Net"?null:[Ge,Ae,Le,ht],pn()}let $i=null,Tr=[{at:0,alpha:0,fill:0},{at:.5,alpha:1,fill:.28},{at:1,alpha:0,fill:0}];function wr(){$i&&($i(),$i=null),ue("pulse",null)}function Si(Ge,Ae){if(!Ge||!s.view||!s.designScale||(Fr!==null&&de(),wr(),s.visibility&&s.visibility.highlight_selected===!1)||Ae==="Net")return;let Le=Z(...Ge);$i=ne(350,3,ht=>{let Ye=oe(Tr,.5-.5*Math.cos(Math.PI*ht));ue("pulse",[{kind:"rect",rect:Le,stroke:K1("#ff0",Ye.alpha),width:3,fill:K1("#ff0",Ye.fill)}])},()=>{$i=null,ue("pulse",null)})}let Fr=null;function se(Ge,Ae){ue("anim",[{kind:"rect",rect:Ge,stroke:K1("#ff0"),width:Ae,fill:K1("#ff0",Ae===1?.39:0)}])}function de(){Fr!==null&&(clearInterval(Fr),Fr=null),ue("anim",null)}function it(Ge,{repeats:Ae=6,intervalMs:Le=300}={}){if(!Ge||!s.view||!s.designScale)return;if(de(),nH()){Si(Ge);return}let ht=Z(...Ge);se(ht,1);let Ye=0,ct=Ae>0?Ae*3:1/0;Fr=setInterval(()=>{if(Ye+=1,Ye>=ct){de();return}se(ht,Ye%3+1)},Le)}s.clearSelectionPulse=wr,s.renderSelectionOutline=pn,s.clearSelectionOutline=qn;function We(Ge,Ae,Le){let ht=document.createElement("div");ht.className="inspector-group";let Ye=document.createElement("div");Ye.className="inspector-group-header";let ct=document.createElement("span");ct.className="vis-arrow";let Ze=document.createElement("span");if(Ze.className="inspector-prop-name",Ze.textContent=Ge,Ze.title=Ge,Ye.appendChild(ct),Ye.appendChild(Ze),Ae!==null){let pt=document.createElement("span");pt.className="inspector-count",pt.textContent=`(${Ae})`,Ye.appendChild(pt)}ht.appendChild(Ye);let Ke=document.createElement("div");return Ke.className="inspector-group-children"+(Le?" collapsed":""),ct.textContent=Le?"\u25B6":"\u25BC",ht.appendChild(Ke),Ye.addEventListener("click",()=>{Ke.classList.toggle("collapsed"),ct.textContent=Ke.classList.contains("collapsed")?"\u25B6":"\u25BC"}),{group:ht,header:Ye,arrow:ct,body:Ke}}function En(Ge){let Ae=Ge.column_headers||[],Le=Ge.row_headers||[],ht=Ge.data||[],Ye=Ae.some(pt=>pt!==""),ct=Le.some(pt=>pt!==""),Ze=document.createElement("table");if(Ze.className="inspector-table",Ye){let pt=document.createElement("thead"),Xn=document.createElement("tr");ct&&Xn.appendChild(document.createElement("th"));for(let _i of Ae){let Hi=document.createElement("th");Hi.textContent=_i,Xn.appendChild(Hi)}pt.appendChild(Xn),Ze.appendChild(pt)}let Ke=document.createElement("tbody");return ht.forEach((pt,Xn)=>{let _i=document.createElement("tr");if(ct){let Hi=document.createElement("th");Hi.textContent=Le[Xn]||"",_i.appendChild(Hi)}for(let Hi of pt){let _n=document.createElement("td");_n.textContent=Hi,_i.appendChild(_n)}Ke.appendChild(_i)}),Ze.appendChild(Ke),Ze}function hr(Ge,Ae){if(Ge.table){let Ze=(Ge.table.data||[]).length,{group:Ke,body:pt}=We(Ge.name,Ze,Ze>=10),Xn=document.createElement("div");return Xn.className="inspector-table-scroll",Xn.appendChild(En(Ge.table)),pt.appendChild(Xn),Ke}if(Ge.children){let Ze=Ge.children.length<10,{group:Ke,body:pt}=We(Ge.name,Ge.children.length,!Ze);for(let Xn of Ge.children)pt.appendChild(hr(Xn,Ae));return Ke}let Le=document.createElement("div");Le.className="inspector-prop";let ht=document.createElement("span");ht.className="inspector-prop-name",ht.textContent=Ge.name||"",ht.title=Ge.name||"";let Ye=document.createElement("span");Ye.className="inspector-prop-value",Ye.textContent=Ge.value||"",Le.appendChild(ht),Le.appendChild(Ye);let ct=Ge.editable&&Ae&&(Ae.onPropertyEdit||Ae.onPropertyChange)&&Ge.editor&&(Ge.editor.type==="list"||Ge.editor.type==="bool");if(ct&&Ge.value_select_id===void 0)Le.replaceChild(x(Ge,Ae),Ye);else if(ct){let Ze=document.createElement("button");Ze.className="inspector-edit-btn",Ze.title="Edit "+Ge.name,Ze.textContent="\u270E",Ze.addEventListener("click",Ke=>{Ke.stopPropagation();let pt=x(Ge,Ae);Le.replaceChild(pt,Ye),Ze.remove(),pt.focus()}),Le.appendChild(Ze)}else Ge.editable&&Ae&&(Ae.onPropertyChange||Ae.onPropertyEdit)&&(Ye.contentEditable=!0,Ye.classList.add("inspector-editable"),Ye.addEventListener("blur",()=>{let Ze=Ye.textContent;if(Ze!==Ge.value){if(Ae.onPropertyChange){Ae.onPropertyChange(Ge.name,Ze);return}if(Ge.editor&&Ge.editor.type==="number"){let Ke=Number(Ze);if(Ze.trim()===""||Number.isNaN(Ke)){Y1("Not a number: "+Ze),Ye.textContent=Ge.value;return}Ae.onPropertyEdit(Ge,{value:Ke});return}Ae.onPropertyEdit(Ge,{value:Ze})}}),Ye.addEventListener("keydown",Ze=>{Ze.key==="Enter"&&(Ze.preventDefault(),Ye.blur()),Ze.key==="Escape"&&(Ye.textContent=Ge.value,Ye.blur())}));return Ge.name_select_id!==void 0&&Ge.value_select_id===void 0?(en(Le,Ge.name_select_id),ht.classList.add("inspector-link")):Ge.name_select_id!==void 0&&en(ht,Ge.name_select_id),Ge.value_select_id!==void 0&&en(Ye,Ge.value_select_id),Le}let qi=140,Me=60,ve=500,wt=qi;function gn(){s.inspectorEl&&s.inspectorEl.style.setProperty("--inspector-name-w",wt+"px")}function vn(){let Ge=document.createElement("div");return Ge.className="inspector-col-resizer",Ge.title="Drag to resize the name column",Ge.addEventListener("mousedown",Ae=>{Ae.preventDefault();let Le=Ae.clientX,ht=wt;Ge.classList.add("dragging");let Ye=Ze=>{wt=Math.max(Me,Math.min(ve,ht+Ze.clientX-Le)),gn()},ct=()=>{Ge.classList.remove("dragging"),document.removeEventListener("mousemove",Ye),document.removeEventListener("mouseup",ct)};document.addEventListener("mousemove",Ye),document.addEventListener("mouseup",ct)}),Ge}function Mn(Ge){!Ge||!s.view||!s.designScale||s.view.fitWorldRect(Z(...Ge),{padding:[20,20]})}function xi(Ge){if(!s.inspectorEl)return;if(c=Ge,s.inspectorEl.innerHTML="",!Ge||!Ge.properties||Ge.properties.length===0){de();let Ye=document.createElement("div");Ye.className="stub-panel",Ye.innerHTML='
Inspector
Select an object in the layout to inspect its properties.
',s.inspectorEl.appendChild(Ye);return}if(!Ge.onPropertyChange&&!Ge.onPropertyEdit&&!ua(s)&&(Ge.onPropertyEdit=(Ye,ct)=>_(Ye.name,ct)),Ge){let Ye=document.createElement("div");Ye.className="inspector-toolbar";let ct=document.createElement("button");if(ct.className="or-btn or-btn-icon",ct.title="Back",ct.innerHTML=Pdn,ct.disabled=!Ge.can_navigate_back,ct.addEventListener("click",()=>bi()),Ye.appendChild(ct),Ge.bbox){let Ze=document.createElement("button");Ze.className="or-btn or-btn-icon",Ze.title="Zoom to",Ze.innerHTML=Adn,Ze.addEventListener("click",()=>Mn(Ge.bbox)),Ye.appendChild(Ze)}if(Ge.type==="Net"&&Ge.name){let Ze=s.focusNets.has(Ge.name),Ke=document.createElement("button");Ke.className="or-btn or-btn-icon",Ke.title=Ze?"De-focus net":"Focus net",Ke.innerHTML=Ze?kdn:Ldn,Ke.addEventListener("click",()=>F(Ge.name)),Ye.appendChild(Ke)}if(Ge.type==="Net"&&Ge.name&&Ge.has_guides){let Ze=s.routeGuideNets.has(Ge.name),Ke=document.createElement("button");Ke.className="or-btn or-btn-icon",Ke.title=Ze?"Hide route guides":"Show route guides",Ke.innerHTML=Ze?Idn:Rdn,Ke.addEventListener("click",()=>z(Ge.name)),Ye.appendChild(Ke)}if(Ge.type==="Net"&&Ge.name&&s.showInsertBufferDialog){let Ze=document.createElement("button");Ze.className="or-btn or-btn-icon",Ze.title="Insert buffer",Ze.innerHTML=Ndn,Ze.addEventListener("click",()=>s.showInsertBufferDialog(Ge.name)),Ye.appendChild(Ze)}if(s.focusNets.size>0){let Ze=document.createElement("button");Ze.className="or-btn or-btn-icon",Ze.title="Clear focus nets",Ze.innerHTML=Ddn,Ze.addEventListener("click",()=>O()),Ye.appendChild(Ze)}if(typeof Ge.highlight_group=="number"&&!ua(s)&&(s.techData?.highlight_colors||[]).length){let Ze=document.createElement("button");Ze.className="or-btn or-btn-icon inspector-highlight-btn";let Ke=Ge.highlight_group;if(Ze.title=Ke>=0?"Highlight group "+(Ke+1):"Add to highlight group",Ze.innerHTML=Cdn,Ke>=0){let pt=s.techData.highlight_colors[Ke];Ze.style.backgroundColor=`rgba(${pt[0]}, ${pt[1]}, ${pt[2]}, 0.45)`,Ze.style.borderColor=`rgb(${pt[0]}, ${pt[1]}, ${pt[2]})`}Ze.addEventListener("click",()=>I(Ze,Ge)),Ye.appendChild(Ze)}if(Array.isArray(Ge.actions)&&!ua(s))for(let Ze of Ge.actions){let Ke=document.createElement("button");Ke.className="or-btn inspector-action-btn",Ke.title=Ze,Ze==="Delete"?(Ke.classList.add("or-btn-icon","or-btn-danger-hover"),Ke.innerHTML=Tdn):(Ke.classList.add("or-btn-sm"),Ke.textContent=Ze),Ke.addEventListener("click",()=>T(Ze,Ge)),Ye.appendChild(Ke)}s.inspectorEl.appendChild(Ye)}let Ae=Ge.selection_count||0,Le=typeof Ge.selection_index=="number"?Ge.selection_index:-1;if(Ae>1&&Le>=0){let Ye=document.createElement("div");Ye.className="inspector-selection-nav";let ct=document.createElement("button");ct.className="or-btn or-btn-icon",ct.title="Previous (Shift+click to multi-select)",ct.innerHTML=Bdn,ct.addEventListener("click",()=>mn(-1));let Ze=document.createElement("span");Ze.className="inspector-selection-label",Ze.textContent=Le+1+" / "+Ae;let Ke=document.createElement("button");Ke.className="or-btn or-btn-icon",Ke.title="Next",Ke.innerHTML=Odn,Ke.addEventListener("click",()=>mn(1)),Ye.appendChild(ct),Ye.appendChild(Ze),Ye.appendChild(Ke),s.inspectorEl.appendChild(Ye)}let ht=document.createElement("div");ht.className="inspector-rows";for(let Ye of Ge.properties)ht.appendChild(hr(Ye,Ge));ht.appendChild(vn()),s.inspectorEl.appendChild(ht),gn()}function mi(Ge){let Ae=document.createElement("div");Ae.className="inspector",s.inspectorEl=Ae,Ge.element.appendChild(Ae),xi(null)}function ri(){if(c){if(c.type==="Ruler"){s.rulerManager&&s.rulerManager._selectedRulerId!==null&&s.rulerManager._selectRuler(s.rulerManager._selectedRulerId);return}s.websocketManager&&cn(-1)}}return{createInspector:mi,updateInspector:xi,highlightBBox:Yi,pulseHighlight:Si,animateSelection:it,stopSelectionAnimation:de,navigateInspector:cn,refreshInspector:ri}}var Jhe=class{constructor(n,r,c){this._app=r,this._refreshOverlay=c||(()=>{}),this._data={selection:[],groups:[],truncated:!1},this._tab="selected",this._filter="",this._sortKey=null,this._sortAsc=!0,this._pendingRefresh=null,this._inFlight=!1,this._staleWhileInFlight=!1,this._visible=!0,this._el=document.createElement("div"),this._el.className="selection-browser",n.element.appendChild(this._el),n.on?.("show",()=>{this._visible=!0,this.refresh()}),n.on?.("hide",()=>{this._visible=!1}),n.on?.("destroy",()=>{this._visible=!1,this._staleWhileInFlight=!1,this._pendingRefresh!==null&&(clearTimeout(this._pendingRefresh),this._pendingRefresh=null)}),this._render(),this.refresh()}scheduleRefresh(){!this._visible||this._pendingRefresh!==null||(this._pendingRefresh=setTimeout(()=>{this._pendingRefresh=null,this.refresh()},150))}refresh(){if(!this._visible||ua(this._app))return;if(this._inFlight){this._staleWhileInFlight=!0;return}this._inFlight=!0;let n=()=>{this._inFlight=!1,this._staleWhileInFlight&&(this._staleWhileInFlight=!1,this.refresh())};this._app.websocketManager.request({type:"list_selection"}).then(r=>{r.ok&&(this._data=r,this._render()),n()}).catch(n)}_entries(){let n;this._tab==="selected"?n=(this._data.selection||[]).map((c,u)=>({row:c,index:u,group:-1})):n=(this._data.groups||[]).flatMap((c,u)=>c.map((d,b)=>({row:d,index:b,group:u})));let r=this._filter.trim().toLowerCase();if(r&&(n=n.filter(({row:c})=>(c.name||"").toLowerCase().includes(r)||(c.type||"").toLowerCase().includes(r))),this._sortKey){let c=this._sortKey,u=this._sortAsc?1:-1;n=n.slice().sort((d,b)=>u*String(d.row[c]||"").localeCompare(String(b.row[c]||"")))}return n}_fmtCoord(n){if(this._app.showDbu)return String(n);let r=this._app.getDbuPerMicron?this._app.getDbuPerMicron():1e3;return(n/r).toFixed(3)}_fmtBounds(n){if(!n)return"";let[r,c,u,d]=n;return`(${this._fmtCoord(r)}, ${this._fmtCoord(c)}), (${this._fmtCoord(u)}, ${this._fmtCoord(d)})`}_inspectRow(n,r){let c=n.group<0?{type:"inspect_selection",index:n.index,use_dbu:this._app.showDbu}:{type:"inspect_group",group:n.group,index:n.index,use_dbu:this._app.showDbu};this._app.websocketManager.request(c).then(u=>{if(!u.ok){this.refresh();return}this._app.updateInspector&&this._app.updateInspector(u),r&&this._app.focusComponent&&this._app.focusComponent("Inspector"),this._refreshOverlay()}).catch(()=>{})}_deselectRow(n){this._app.websocketManager.request({type:"deselect",index:n.index}).then(()=>{this.refresh(),this._refreshOverlay()}).catch(()=>{})}_clearHighlights(){this._app.websocketManager.request({type:"clear_highlights",group:-1}).then(()=>{this.refresh(),this._refreshOverlay(),this._app.refreshInspector&&this._app.refreshInspector()}).catch(()=>{})}_zoomToBBox(n){if(!n||!this._app.designScale||!this._app.view)return;let[r,c,u,d]=n,b=this._app.getDbuPerMicron?this._app.getDbuPerMicron():1e3,w=Math.min(10*b,2*Math.max(u-r,d-c));this._app.view.fitWorldRect(X1(r-w,c-w,u+w,d+w,this._app.designScale,this._app.designOriginX,this._app.designOriginY))}_render(){this._app.stopSelectionAnimation&&this._app.stopSelectionAnimation(),this._el.innerHTML="";let n=(this._data.selection||[]).length,r=(this._data.groups||[]).reduce((b,w)=>b+w.length,0),c=document.createElement("div");c.className="sb-tabs";for(let[b,w,_]of[["selected","Selected",n],["highlighted","Highlighted",r]]){let x=document.createElement("button");x.className="sb-tab"+(this._tab===b?" active":""),x.textContent=`${w} (${_})`,x.addEventListener("click",()=>{this._tab=b,this._render()}),c.appendChild(x)}let u=document.createElement("button");if(u.className="or-btn or-btn-sm sb-tool",u.title="Refresh",u.textContent="\u27F3",u.addEventListener("click",()=>this.refresh()),c.appendChild(u),this._tab==="highlighted"&&r>0){let b=document.createElement("button");b.className="or-btn or-btn-sm sb-tool",b.title="Clear all highlights",b.textContent="Clear",b.addEventListener("click",()=>this._clearHighlights()),c.appendChild(b)}this._el.appendChild(c);let d=document.createElement("input");if(d.type="text",d.className="sb-filter",d.placeholder="Filter by name or type\u2026",d.value=this._filter,d.addEventListener("input",()=>{this._filter=d.value,this._renderTable()}),this._el.appendChild(d),this._data.truncated){let b=document.createElement("div");b.className="sb-truncated",b.textContent="List truncated \u2014 showing the first 1000 entries per set.",this._el.appendChild(b)}this._tableWrap=document.createElement("div"),this._tableWrap.className="sb-table-wrap",this._el.appendChild(this._tableWrap),this._renderTable()}_renderTable(){this._tableWrap.innerHTML="";let n=this._entries();if(!n.length){let _=document.createElement("div");_.className="sb-empty",_.textContent=this._tab==="selected"?"Nothing selected.":"Nothing highlighted.",this._tableWrap.appendChild(_);return}let r=document.createElement("table");r.className="sb-table";let c=document.createElement("thead"),u=document.createElement("tr"),d=[["name","Object"],["type","Type"],[null,"Bounds"]];this._tab==="highlighted"&&d.push([null,"Group"]),d.push([null,""]);for(let[_,x]of d){let T=document.createElement("th");T.textContent=x,_&&(T.classList.add("sb-sortable"),this._sortKey===_&&(T.textContent+=this._sortAsc?" \u25B2":" \u25BC"),T.addEventListener("click",()=>{this._sortKey===_?this._sortAsc=!this._sortAsc:(this._sortKey=_,this._sortAsc=!0),this._renderTable()})),u.appendChild(T)}c.appendChild(u),r.appendChild(c);let b=document.createElement("tbody"),w=this._app.techData?.highlight_colors||[];for(let _ of n){let x=document.createElement("tr");x.className="sb-row";let T=document.createElement("td");T.textContent=_.row.name||"";let M=document.createElement("td");M.textContent=_.row.type||"";let L=document.createElement("td");if(L.textContent=this._fmtBounds(_.row.bbox),x.appendChild(T),x.appendChild(M),x.appendChild(L),this._tab==="highlighted"){let D=document.createElement("td"),F=document.createElement("span");F.className="sb-chip";let O=w[_.group];O&&(F.style.backgroundColor=`rgb(${O[0]}, ${O[1]}, ${O[2]})`),D.appendChild(F),D.appendChild(document.createTextNode(` Group ${_.group+1}`)),x.appendChild(D)}let I=document.createElement("td");if(I.className="sb-actions",_.row.bbox){let D=document.createElement("button");D.className="sb-row-btn",D.title="Zoom to",D.textContent="\u2316",D.addEventListener("click",F=>{F.stopPropagation(),this._zoomToBBox(_.row.bbox)}),I.appendChild(D)}if(this._tab==="selected"){let D=document.createElement("button");D.className="sb-row-btn",D.title="De-select",D.textContent="\u2715",D.addEventListener("click",F=>{F.stopPropagation(),this._deselectRow(_)}),I.appendChild(D)}x.appendChild(I),x.addEventListener("click",()=>this._inspectRow(_,!1)),x.addEventListener("dblclick",()=>this._inspectRow(_,!0)),_.row.bbox&&(x.addEventListener("mouseenter",()=>{this._app.animateSelection&&this._app.animateSelection(_.row.bbox,{repeats:0})}),x.addEventListener("mouseleave",()=>{this._app.stopSelectionAnimation&&this._app.stopSelectionAnimation()})),b.appendChild(x)}r.appendChild(b),this._tableWrap.appendChild(r),ak(r)}};var p3t="options-dialog",d3t=[{label:"System default",value:""},{label:"Sans-serif",value:"sans-serif"},{label:"Serif",value:"serif"},{label:"Monospace",value:"monospace"},{label:"Helvetica / Arial",value:"Helvetica, Arial, sans-serif"},{label:"Georgia",value:"Georgia, 'Times New Roman', serif"},{label:"Courier",value:"'Courier New', Courier, monospace"}],Fdn=100,Qhe=70,ede=200;function rH(s){let n=s===""||s===null?NaN:Math.round(Number(s));return Number.isFinite(n)?Math.min(ede,Math.max(Qhe,n)):Fdn}function g3t(s){let{overlay:n,close:r,okBtn:c,showError:u}=MO("Arrow keys scroll step",` +Slack: [${r.lower.toFixed(I)}, ${r.upper.toFixed(I)}) ${L}`}this._tooltip.style.display="block";let d=this.element.getBoundingClientRect(),b=this._tooltip.getBoundingClientRect(),w=4,_=n.clientX-d.left,x=n.clientY-d.top,T=_+12;T+b.width>d.width-w&&(T=_-12-b.width),T=Math.max(w,T);let M=x-10;M=Math.min(d.height-b.height-w,Math.max(w,M)),this._tooltip.style.left=T+"px",this._tooltip.style.top=M+"px"}else this._tooltip.style.display="none"}async _handleClick(n){if(this._activeDebugChart>=0||this._currentTab==="fanout"||this._currentTab==="netlength")return;let r=this._hitTestBar(n);if(!(!r||r.count===0))try{let c=await this._app.websocketManager.request({type:"timing_report",is_setup:this._currentTab==="setup",max_paths:50,slack_min:r.lower,slack_max:r.upper});this._app.timingWidget&&(this._app.timingWidget.showPaths(this._currentTab,c.paths||[]),this._app.focusComponent&&this._app.focusComponent("TimingWidget"))}catch(c){console.error("Charts bar click error:",c)}}async _handleDblClick(n){if(this._activeDebugChart>=0)return;let r;if(this._currentTab==="fanout")r="select_fanout_bin";else if(this._currentTab==="netlength")r="select_net_length_bin";else return;let c=this._hitTestBar(n);if(!c||c.count===0)return;let u=Pm(this._app);try{let d=await this._app.websocketManager.request({type:r,lower:c.lower,upper:c.upper,use_dbu:this._app.showDbu});if(!Y1(this._app,u))return;d&&d.truncated&&console.warn(`Bin has ${d.count} nets; selection capped at ${d.selection_limit} for performance.`),this._app.updateInspector&&this._app.updateInspector(d),this._app.focusComponent&&this._app.focusComponent("Inspector"),this._redrawAllLayers&&this._redrawAllLayers()}catch(d){console.error("Net bin select failed:",d)}}_activeChartData(){return this._activeDebugChart>=0?{kind:"generic",data:this._debugCharts[this._activeDebugChart]}:{kind:"histogram",data:this._histogramData}}_chartBaseName(){return this._activeDebugChart>=0?this._debugCharts[this._activeDebugChart].name||"chart":this._currentTab}_triggerDownload(n,r,{revoke:c=!1}={}){let u=document.createElement("a");u.href=r,u.download=n,document.body.appendChild(u),u.click(),u.remove(),c&&URL.revokeObjectURL(r)}_download(n,r,c){try{let u=URL.createObjectURL(new Blob([c],{type:r}));this._triggerDownload(n,u,{revoke:!0})}catch(u){console.error("Download failed:",u)}}_exportCsv(){let{kind:n,data:r}=this._activeChartData();if(!r)return;let c=Pdn(n,r);this._download(this._chartBaseName()+".csv","text/csv",c)}_exportPng(){try{let n=this._canvas.toDataURL("image/png");this._triggerDownload(this._chartBaseName()+".png",n)}catch(n){console.error("PNG export failed:",n)}}setDebugCharts(n){this._debugCharts=n,n.length===0?this._activeDebugChart=-1:this._activeDebugChart>=n.length&&(this._activeDebugChart=0),this._rebuildSelect(),this._syncView()}_syncView(){let n=this._activeDebugChart>=0;n&&(this._hoveredBar=null,this._tooltip.style.display="none");let r=!n&&(this._currentTab==="setup"||this._currentTab==="hold");this._filterRow&&(this._filterRow.style.display=r?"":"none"),this._sizeCanvas(),n?this._renderLineChart(this._debugCharts[this._activeDebugChart]):(this._computeLayout(),this._render())}_renderLineChart(n){let r=this._canvas.getBoundingClientRect(),c=r.width,u=r.height,d=this._ctx,b=fk();d.clearRect(0,0,c,u),d.fillStyle=b.canvasBg,d.fillRect(0,0,c,u);let w=n.points;if(!w||w.length===0){d.fillStyle=b.canvasText,d.font="14px "+b.fontSans,d.textAlign="center",d.textBaseline="middle",d.fillText("No data points yet",c/2,u/2);return}let _=n.y_labels?n.y_labels.length:1,x=l3t,T=c-u3t,M=f3t,L=u-h3t,I=T-x,D=L-M;if(I<=0||D<=0)return;let F=w[0].x,O=w[0].x,z=1/0,Z=-1/0;for(let ue of w){ue.xO&&(O=ue.x);for(let Te of ue.ys)TeZ&&(Z=Te)}F===O&&(O=F+1),(!isFinite(z)||!isFinite(Z))&&(z=0,Z=1);let H=(Z-z)*.05||1;z-=H,Z+=H;let te=ue=>x+(ue-F)/(O-F)*I,oe=ue=>L-(ue-z)/(Z-z)*D;d.strokeStyle=b.canvasAxis,d.lineWidth=1,d.beginPath(),d.moveTo(x,M),d.lineTo(x,L),d.lineTo(T,L),d.stroke(),d.fillStyle=b.canvasLabel,d.font="10px "+b.fontMono,d.textAlign="right",d.textBaseline="middle";let ne=5;for(let ue=0;ue<=ne;ue++){let Te=z+(Z-z)*ue/ne,Q=oe(Te);d.fillText(this._formatNum(Te),x-4,Q),ue>0&&ue1&&n.y_labels){d.font="10px "+b.fontMono,d.textAlign="left",d.textBaseline="top";let ue=x+8,Te=M+4;for(let Q=0;Q<_;Q++){let ge=xT[Q%xT.length];d.fillStyle=ge,d.fillRect(ue,Te+Q*14,12,10),d.fillStyle=b.canvasLabel,d.fillText(n.y_labels[Q],ue+16,Te+Q*14)}}}_formatNum(n){let r=Math.abs(n);return r===0?"0":r>=1e6?(n/1e6).toFixed(1)+"M":r>=1e3?(n/1e3).toFixed(1)+"k":r>=1?n.toFixed(1):n.toPrecision(3)}_formatCount(n){return n===0?"0":n>=1e6?n/1e6+"M":n>=1e3?n/1e3+"k":String(n)}};var Rv=class{constructor(n){this.onChange=n,this.roots=[],this._nodeMap=new Map}addFromSpec(n,r=null){let c=this._makeNode(n.id,r,n);if(c.checked=n.checked!==!1,n.children){for(let u of n.children)c.children.push(this.addFromSpec(u,c));c.hasCheckbox&&this._computeParent(c)}return r||this.roots.push(c),c}buildFromNodes(n){this._nodeMap.clear(),this.roots=[];for(let r of n)this._makeNode(r.id,null,r);for(let r of n){let c=this._nodeMap.get(r.id);if(r.parentId!=null&&this._nodeMap.has(r.parentId)){let u=this._nodeMap.get(r.parentId);c.parent=u,u.children.push(c)}else this.roots.push(c)}for(let r=n.length-1;r>=0;r--){let c=this._nodeMap.get(n[r].id);c.hasCheckbox&&c.children.length>0&&this._computeParent(c)}return this.roots}get(n){return this._nodeMap.get(n)}isVisible(n){let r=this.get(n);return r?r.checked:!1}check(n,r){let c=this._nodeMap.get(n);if(c){c.checked=r,c.indeterminate=!1;for(let u of c.children)this._setSubtree(u,r);for(let u=c.parent;u;u=u.parent)u.hasCheckbox&&this._computeParent(u);this.onChange()}}cascadeQuiet(n,r){let c=this._nodeMap.get(n);if(c){c.checked=r,c.indeterminate=!1;for(let u of c.children)this._setSubtree(u,r);for(let u=c.parent;u;u=u.parent)u.hasCheckbox&&this._computeParent(u)}}checkSet(n){for(let[r,c]of Object.entries(n)){let u=this._nodeMap.get(r);u&&(u.checked=c,u.indeterminate=!1)}this._recomputeAllParents(),this.onChange()}mirrorStates(n){this._applyMirror(n),this.onChange()}mirrorStatesQuiet(n){this._applyMirror(n)}_applyMirror(n){for(let[r,c]of Object.entries(n)){let u=this._nodeMap.get(r);u&&(u.checked=!!c.checked,u.indeterminate=!!c.indeterminate)}}forEach(n){let r=c=>{n(c);for(let u of c.children)r(u)};for(let c of this.roots)r(c)}_makeNode(n,r,c){let u={id:n,parent:r,children:[],hasCheckbox:c.hasCheckbox!==!1,checked:c.checked!==!1,indeterminate:!1,data:c.data!=null?c.data:c};return this._nodeMap.set(n,u),u}_checkboxDescendants(n){let r=[];for(let c of n.children)c.hasCheckbox?r.push(c):r.push(...this._checkboxDescendants(c));return r}_computeParent(n){let r=this._checkboxDescendants(n);if(r.length===0)return;let c=r.every(d=>d.checked&&!d.indeterminate),u=r.every(d=>!d.checked&&!d.indeterminate);n.checked=c,n.indeterminate=!c&&!u}_setSubtree(n,r){n.hasCheckbox&&(n.checked=r,n.indeterminate=!1);for(let c of n.children)this._setSubtree(c,r)}_recomputeAllParents(){let n=r=>{for(let c of r.children)n(c);r.hasCheckbox&&r.children.length>0&&this._computeParent(r)};for(let r of this.roots)n(r)}};var d3t=["Instance","Module","Instances","Macros","Modules","Area","Local Inst","Local Macros","Local Modules"],ET={MODULE:0,LEAF_GROUP:1,TYPE_GROUP:2,INSTANCE:3,NAME_GROUP:4};function dk(s){return s===ET.MODULE||s===ET.NAME_GROUP}var Khe=class{constructor(n,r,c){this._app=r,this._redrawAllLayers=c,this._nodes=[],this._nameGrouped=!1,this._nameGroupsCapped=!1,this._rows=[],this._childrenMap=new Map,this._collapsed=new Set,this._moduleState=new Map,this._checkModel=null,this._build(n),r.hierarchyBrowser=this,ua(r)&&this.update()}_build(n){let r=document.createElement("div");r.className="hierarchy-widget";let c=document.createElement("div");c.className="timing-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",ua(this._app)&&(this._updateBtn.style.display="none"),this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",c.appendChild(this._updateBtn),c.appendChild(this._statusLabel),r.appendChild(c),this._tableContainer=document.createElement("div"),this._tableContainer.className="hierarchy-table-container",this._table=document.createElement("table"),this._table.className="timing-table",this._tableContainer.appendChild(this._table),r.appendChild(this._tableContainer),n.element.appendChild(r),this._bindEvents()}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update())}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...",this._statusLabel.textContent="";try{let n=await this._app.websocketManager.request({type:"module_hierarchy"});this._nodes=n.nodes||[],this._nameGrouped=!!n.name_grouped,this._nameGroupsCapped=!!n.name_groups_capped,this._buildTree(),this._readServerColors(),this._computeEffectiveColors(),this._render(),this._statusLabel.textContent=this._statusText(),await this._sendModuleColors()}catch(n){this._statusLabel.textContent="Error: "+n.message}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}_statusText(){let n=this._nodes.filter(u=>dk(u.node_kind||0)).length;if(!this._nameGrouped)return n+" modules";let c=Math.max(0,n-1)+" groups from instance names \u2014 this design has no module hierarchy";return this._nameGroupsCapped&&(c+=" (truncated: too many groups)"),c}_buildTree(){this._childrenMap.clear(),this._collapsed.clear();for(let r of this._nodes)this._childrenMap.set(r.id,[]);for(let r of this._nodes)r.parent_id>=0&&this._childrenMap.has(r.parent_id)&&this._childrenMap.get(r.parent_id).push(r.id);this._nodeMap=new Map;for(let r of this._nodes)this._nodeMap.set(r.id,r);for(let r of this._nodes){let c=this._childrenMap.get(r.id);if(!c||c.length===0)continue;let u=r.node_kind||0;u===ET.LEAF_GROUP||u===ET.TYPE_GROUP?this._collapsed.add(r.id):dk(u)&&r.parent_id>=0&&this._collapsed.add(r.id)}this._rows=[];let n=this._nodes.filter(r=>r.parent_id<0);for(let r of n)this._dfs(r.id,0);this._checkModel=new Rv(()=>{this._checkModel.forEach(r=>{if(!r.hasCheckbox)return;let c=this._moduleState.get(r.data.odb_id);c&&(c.visible=r.checked)}),this._sendModuleColors()}),this._checkModel.buildFromNodes(this._nodes.map(r=>({id:r.id,parentId:r.parent_id,hasCheckbox:dk(r.node_kind||0)&&r.odb_id!=null,checked:!0,data:r})))}_readServerColors(){this._moduleState.clear();for(let n of this._rows){let r=this._nodeMap.get(n.id);if(!r||!dk(r.node_kind||0)||r.odb_id==null)continue;let c=r.color||[128,128,128];this._moduleState.set(r.odb_id,{color:c,effectiveColor:c,visible:!0,nodeId:r.id})}}_computeEffectiveColors(){for(let n of this._rows){let r=this._nodeMap.get(n.id);if(!r||!dk(r.node_kind||0))continue;let c=this._moduleState.get(r.odb_id);if(!c)continue;let u=r.parent_id,d=null;for(;u>=0;){let b=this._nodeMap.get(u);if(!b)break;if(dk(b.node_kind||0)){let w=this._moduleState.get(b.odb_id);w&&this._collapsed.has(b.id)&&(d=w.effectiveColor)}u=b.parent_id}c.effectiveColor=d||c.color}}async _sendModuleColors(){let n=[];for(let[c,u]of this._moduleState){if(!u.visible)continue;let[d,b,w]=u.effectiveColor;n.push(`${c}:${d},${b},${w},100`)}let r=n.join(";");try{let c=await this._app.websocketManager.request({type:"set_module_colors",colors:r});console.log("set_module_colors:",c.count,"modules,",n.length,"sent")}catch(c){console.error("set_module_colors failed:",c)}this._redrawAllLayers()}_dfs(n,r){this._rows.push({id:n,depth:r});let c=this._childrenMap.get(n)||[];for(let u of c)this._dfs(u,r+1)}_render(){this._table.innerHTML="";let n=document.createElement("thead"),r=document.createElement("tr");for(let u of d3t){let d=document.createElement("th");d.textContent=u,r.appendChild(d)}n.appendChild(r),this._table.appendChild(n);let c=document.createElement("tbody");for(let u of this._rows){let d=this._nodeMap.get(u.id);if(!d||this._isHidden(d))continue;let b=document.createElement("tr"),w=d.node_kind||0,x=(this._childrenMap.get(u.id)||[]).length>0,T=this._collapsed.has(u.id);w===ET.LEAF_GROUP||w===ET.TYPE_GROUP?(b.style.fontStyle="italic",b.style.color="var(--fg-disabled)"):w===ET.INSTANCE?b.style.color="var(--fg-secondary)":w===ET.NAME_GROUP&&(b.classList.add("hierarchy-name-group"),b.title="Recovered from instance names \u2014 this design has no module hierarchy");let M=document.createElement("td");if(M.style.paddingLeft=8+u.depth*16+"px",M.style.whiteSpace="nowrap",dk(w)&&d.odb_id!=null){let D=this._moduleState.get(d.odb_id),F=this._checkModel?this._checkModel.get(d.id):null;if(D&&F){let O=document.createElement("input");O.type="checkbox",O.checked=F.checked,O.indeterminate=F.indeterminate,O.className="hierarchy-module-cb",F.cb=O,O.addEventListener("change",oe=>{oe.stopPropagation(),this._checkModel.check(d.id,O.checked),this._render()}),M.appendChild(O);let z=document.createElement("span");z.className="hierarchy-color-swatch";let[Z,H,te]=D.effectiveColor;z.style.backgroundColor=`rgb(${Z},${H},${te})`,M.appendChild(z)}}if(x){let D=document.createElement("span");D.className="hierarchy-arrow",D.textContent=T?"\u25B6":"\u25BC",D.addEventListener("click",F=>{F.stopPropagation(),this._toggleNode(u.id)}),M.appendChild(D)}else{let D=document.createElement("span");D.className="hierarchy-arrow",D.style.visibility="hidden",D.textContent="\u25B6",M.appendChild(D)}let L=document.createElement("span");L.textContent=d.inst_name,M.appendChild(L),b.appendChild(M);let I=[d.module_name,TO(d.insts),TO(d.macros),TO(d.modules),this._fmtArea(d.area),TO(d.local_insts),TO(d.local_macros),TO(d.local_modules)];for(let D of I){let F=document.createElement("td");F.textContent=D,F.style.textAlign="right",b.appendChild(F)}b.children[1].style.textAlign="left",c.appendChild(b)}if(this._rows.length===0){let u=document.createElement("tr"),d=document.createElement("td");d.colSpan=d3t.length,d.style.textAlign="center",d.style.color="var(--fg-secondary)",d.textContent=ua(this._app)?"No hierarchy data available":'Click "Update" to load hierarchy',u.appendChild(d),c.appendChild(u)}this._table.appendChild(c),ak(this._table)}_isHidden(n){let r=n.parent_id;for(;r>=0;){if(this._collapsed.has(r))return!0;let c=this._nodeMap.get(r);if(!c)break;r=c.parent_id}return!1}_toggleNode(n){this._collapsed.has(n)?this._collapsed.delete(n):this._collapsed.add(n),this._computeEffectiveColors(),this._render(),this._sendModuleColors()}_fmtArea(n){if(n==null)return"";if(this._app.showDbu){let r=this._app.getDbuPerMicron();return String(Math.round(n*r*r))}return n>=1e6?(n/1e6).toFixed(3)+" mm\xB2":n.toFixed(3)+" \u03BCm\xB2"}};function TO(s){return s!=null?String(s):""}var Ldn='',kdn='',Rdn='',Idn='',Ddn='',Bdn='',Odn='',Ndn='',Fdn='',Udn='',zdn='',Gdn='';function p3t(s,n,r){r=r||n;let c=null,u=null,d=null,b=!1,w=10;function _(Ge,Ae){return b?Promise.resolve():(b=!0,s.websocketManager.request({type:"set_property",name:Ge,use_dbu:s.showDbu,...Ae}).then(Le=>{!Le.ok&&Le.error&&Fb(Le.error),xi(Le),Le.ok&&Le.bbox&&Si(Le.bbox)}).catch(Le=>{console.error("set_property failed:",Le),Fb("Edit failed: "+Le),c&&xi(c)}).finally(()=>{b=!1}))}function x(Ge,Ae){let Le=document.createElement("select");Le.className="inspector-editor-select";let ht=Ge.editor.type==="bool"?["True","False"]:Ge.editor.options||[];for(let Ye of ht){let ct=document.createElement("option");ct.value=Ye,ct.textContent=Ye,Ye===Ge.value&&(ct.selected=!0),Le.appendChild(ct)}if(!ht.includes(Ge.value)){let Ye=document.createElement("option");Ye.value=Ge.value||"",Ye.textContent=Ge.value||"",Ye.selected=!0,Ye.disabled=!0,Le.insertBefore(Ye,Le.firstChild)}return Le.addEventListener("change",()=>{if(Ae.onPropertyChange){Ae.onPropertyChange(Ge.name,Le.value);return}if(Ge.editor.type==="bool")Ae.onPropertyEdit(Ge,{value:Le.value==="True"});else{let Ye=(Ge.editor.options||[]).indexOf(Le.value);Ae.onPropertyEdit(Ge,{option_index:Ye,option_name:Le.value})}}),Le}async function T(Ge,Ae){if(!b&&!(Ge==="Delete"&&!await Nxt({title:"Delete "+(Ae.type||"object"),message:"Delete "+(Ae.type||"object")+' "'+(Ae.name||"")+'"? This cannot be undone.',confirmLabel:"Delete",danger:!0}))){b=!0;try{let Le=await s.websocketManager.request({type:"trigger_action",name:Ge,use_dbu:s.showDbu});!Le.ok&&Le.error&&Fb(Le.error),xi(Le.properties?Le:null),Le.deleted&&qn(),ot(),r()}catch(Le){console.error("trigger_action failed:",Le),Fb("Action failed: "+Le)}finally{b=!1}}}function M(Ge){s.websocketManager.request({...Ge,use_dbu:s.showDbu}).then(Ae=>{!Ae.ok&&Ae.error&&Fb(Ae.error),xi(Ae),r()}).catch(Ae=>{console.error(Ge.type+" failed:",Ae)})}function L(){let Ge=document.getElementById("highlight-picker");Ge&&Ge.remove()}function I(Ge,Ae){L();let Le=s.techData?.highlight_colors||[];if(!Le.length)return;let ht=document.createElement("div");ht.id="highlight-picker";let Ye=document.createElement("div");if(Ye.className="highlight-swatch-grid",Le.forEach((Ke,pt)=>{let Xn=document.createElement("button");Xn.className="highlight-swatch",Xn.title="Group "+(pt+1),Xn.style.backgroundColor=`rgb(${Ke[0]}, ${Ke[1]}, ${Ke[2]})`,pt===Ae.highlight_group&&Xn.classList.add("active"),Xn.addEventListener("click",()=>{L(),M({type:"highlight",group:pt})}),Ye.appendChild(Xn)}),ht.appendChild(Ye),Ae.highlight_group>=0){let Ke=document.createElement("button");Ke.className="highlight-remove",Ke.textContent="Remove highlight",Ke.addEventListener("click",()=>{L(),M({type:"unhighlight"})}),ht.appendChild(Ke)}document.body.appendChild(ht);let ct=Ge.getBoundingClientRect();ht.style.left=ct.left+"px",ht.style.top=ct.bottom+4+"px";let Ze=Ke=>{Ke.type==="keydown"&&Ke.key!=="Escape"||Ke.type==="mousedown"&&ht.contains(Ke.target)||(L(),document.removeEventListener("mousedown",Ze,!0),document.removeEventListener("keydown",Ze,!0))};setTimeout(()=>{document.addEventListener("mousedown",Ze,!0),document.addEventListener("keydown",Ze,!0)},0)}function D(){if(!s.inspectorEl)return;s.inspectorEl.innerHTML="";let Ge=document.createElement("div");Ge.className="stub-panel",Ge.innerHTML='
Loading\u2026
Fetching properties from server.
',s.inspectorEl.appendChild(Ge)}async function F(Ge){let Ae=s.focusNets.has(Ge)?"remove":"add";Ae==="add"?s.focusNets.add(Ge):s.focusNets.delete(Ge);try{await s.websocketManager.request({type:"set_focus_nets",action:Ae,net_name:Ge})}catch(Le){console.error("set_focus_nets failed:",Le)}n(),c&&xi(c)}async function O(){s.focusNets.clear();try{await s.websocketManager.request({type:"set_focus_nets",action:"clear",net_name:""})}catch(Ge){console.error("set_focus_nets clear failed:",Ge)}n(),c&&xi(c)}async function z(Ge){let Ae=s.routeGuideNets.has(Ge)?"remove":"add";Ae==="add"?s.routeGuideNets.add(Ge):s.routeGuideNets.delete(Ge);try{await s.websocketManager.request({type:"set_route_guides",action:Ae,net_name:Ge})}catch(Le){console.error("set_route_guides failed:",Le)}r(),c&&xi(c)}function Z(Ge,Ae,Le,ht){return X1(Ge,Ae,Le,ht,s.designScale,s.designOriginX,s.designOriginY)}function H(Ge,Ae,Le){return Ge+(Ae-Ge)*Le}function te(Ge,Ae,Le){return Ge.map((ht,Ye)=>Math.round(H(ht,Ae[Ye],Le)))}function oe(Ge,Ae){let Le=0;for(;LeGe[Le+1].at;)Le++;let ht=Ge[Le],Ye=Ge[Le+1],ct=Math.max(0,Math.min(1,(Ae-ht.at)/(Ye.at-ht.at))),Ze={};for(let Ke of Object.keys(ht))Ke!=="at"&&(Ze[Ke]=Array.isArray(ht[Ke])?te(ht[Ke],Ye[Ke],ct):H(ht[Ke],Ye[Ke],ct));return Ze}function ne(Ge,Ae,Le,ht){if(nH()||typeof requestAnimationFrame!="function")return ht(),()=>{};let Ye=performance.now(),ct=!1,Ze=()=>{if(ct)return;let Ke=performance.now()-Ye;if(Ke>=Ge*Ae){ht();return}Le(Ke%Ge/Ge),requestAnimationFrame(Ze)};return Ze(),()=>{ct=!0}}function ue(Ge,Ae,Le=bp.highlight){s.view&&s.view.setOverlay(Ge,Ae,{order:Le})}let Te=null,Q=()=>{},ge=[255,242,122],Qe=[{at:0,stroke:[255,246,176],width:7,alpha:1,fill:.28},{at:.55,stroke:[255,255,255],width:5,alpha:1,fill:.06},{at:1,stroke:[255,232,92],width:3,alpha:.95,fill:.14}],st={stroke:[255,232,92],width:3,alpha:1,fill:.14};function at(Ge,Ae,Le,ht){let[Ye,ct,Ze,Ke]=Z(Ge,Ae,Le,ht),pt=w/2**s.view.getZoom(),Xn=Math.max(0,(pt-(Ze-Ye))/2),_i=Math.max(0,(pt-(Ke-ct))/2);return[Ye-Xn,ct-_i,Ze+Xn,Ke+_i]}function Ne(Ge){Te&&ue("hover",Te.map(([Ae,Le,ht,Ye])=>({kind:"rect",rect:at(Ae,Le,ht,Ye),stroke:Z1(Ge.stroke,Ge.alpha),width:Ge.width,fill:Z1(ge,Ge.fill)})))}function tt(){Ne(st)}function ot(){Q(),Te=null,ue("hover",null),s.view?.off("zoom",tt)}function Tt(){ot(),s.websocketManager.request({type:"hover",select_id:-1}).then(()=>{}).catch(()=>{})}function jt(Ge){ot(),!(!s.view||!s.designScale||!Ge||Ge.length===0)&&(Te=Ge,s.view.on("zoom",tt),Q=ne(900,3,Ae=>Ne(oe(Qe,1-Math.pow(1-Ae,2))),()=>Ne(st)))}function en(Ge,Ae){Ge.classList.add("inspector-link"),Ge.addEventListener("click",Le=>{Le.stopPropagation(),cn(Ae)}),Ge.addEventListener("mouseenter",()=>{d!==null&&(s.websocketManager.cancel(d),d=null);let Le=s.websocketManager.request({type:"hover",select_id:Ae});d=Le.requestId,Le.then(ht=>{d=null,jt(ht.rects||[]),r()}).catch(()=>{d=null})}),Ge.addEventListener("mouseleave",()=>{Tt(),r()})}function mn(Ge){let Ae=Ge>0?"select_next":"select_prev";u!==null&&(s.websocketManager.cancel(u),u=null),D();let Le=Pm(s),ht=s.websocketManager.request({type:Ae,use_dbu:s.showDbu});u=ht.requestId,ht.then(Ye=>{if(u=null,!!Y1(s,Le)){if(Ye.error){console.error("Selection cycle error:",Ye.error),xi(c);return}if(xi(Ye),Ye.type==="Inst"&&Ye.name&&(s.selectedInstanceName=Ye.name,s.schematicWidget&&s.schematicWidget.refresh()),ot(),qn(),Ye.bbox&&s.view&&s.designScale){let[ct,Ze,Ke,pt]=Ye.bbox;Ye.type!=="Inst"&&Yi(ct,Ze,Ke,pt,Ye.type),Ye.selection_count>1?it(Ye.bbox):Si(Ye.bbox,Ye.type)}n()}}).catch(Ye=>{u=null,console.error("Selection cycle failed:",Ye),xi(c)})}function cn(Ge){u!==null&&(s.websocketManager.cancel(u),u=null),D();let Ae=Pm(s),Le=s.websocketManager.request({type:"inspect",select_id:Ge,use_dbu:s.showDbu});u=Le.requestId,Le.then(ht=>{if(u=null,!!Y1(s,Ae)){if(ht.error){console.error("Inspect error:",ht.error);return}if(xi(ht),ot(),qn(),ht.bbox&&s.view&&s.designScale){let[Ye,ct,Ze,Ke]=ht.bbox;ht.type!=="Inst"&&Yi(Ye,ct,Ze,Ke,ht.type),Si(ht.bbox,ht.type)}r()}}).catch(ht=>{u=null,console.error("Inspect failed:",ht)})}function bi(){u!==null&&(s.websocketManager.cancel(u),u=null),D();let Ge=Pm(s),Ae=s.websocketManager.request({type:"inspect_back",use_dbu:s.showDbu});u=Ae.requestId,Ae.then(Le=>{if(u=null,!!Y1(s,Ge)){if(Le.error){console.error("Inspect back error:",Le.error);return}if(xi(Le),ot(),qn(),Le.bbox&&s.view&&s.designScale){if(Le.type!=="Inst"){let[ht,Ye,ct,Ze]=Le.bbox;Yi(ht,Ye,ct,Ze,Le.type)}Si(Le.bbox,Le.type)}r()}}).catch(Le=>{u=null,console.error("Inspect back failed:",Le)})}let Vt=null;function pn(){let Ge=Vt&&s.designScale&&!(s.visibility&&s.visibility.highlight_selected===!1);ue("selection",Ge?[{kind:"rect",rect:Z(...Vt),stroke:Z1("#ff0"),width:2,dash:[6,4]}]:null,bp.selection)}function qn(){Vt=null,pn()}function Yi(Ge,Ae,Le,ht,Ye){Vt=Ye==="Net"?null:[Ge,Ae,Le,ht],pn()}let $i=null,Tr=[{at:0,alpha:0,fill:0},{at:.5,alpha:1,fill:.28},{at:1,alpha:0,fill:0}];function wr(){$i&&($i(),$i=null),ue("pulse",null)}function Si(Ge,Ae){if(!Ge||!s.view||!s.designScale||(Fr!==null&&de(),wr(),s.visibility&&s.visibility.highlight_selected===!1)||Ae==="Net")return;let Le=Z(...Ge);$i=ne(350,3,ht=>{let Ye=oe(Tr,.5-.5*Math.cos(Math.PI*ht));ue("pulse",[{kind:"rect",rect:Le,stroke:Z1("#ff0",Ye.alpha),width:3,fill:Z1("#ff0",Ye.fill)}])},()=>{$i=null,ue("pulse",null)})}let Fr=null;function se(Ge,Ae){ue("anim",[{kind:"rect",rect:Ge,stroke:Z1("#ff0"),width:Ae,fill:Z1("#ff0",Ae===1?.39:0)}])}function de(){Fr!==null&&(clearInterval(Fr),Fr=null),ue("anim",null)}function it(Ge,{repeats:Ae=6,intervalMs:Le=300}={}){if(!Ge||!s.view||!s.designScale)return;if(de(),nH()){Si(Ge);return}let ht=Z(...Ge);se(ht,1);let Ye=0,ct=Ae>0?Ae*3:1/0;Fr=setInterval(()=>{if(Ye+=1,Ye>=ct){de();return}se(ht,Ye%3+1)},Le)}s.clearSelectionPulse=wr,s.renderSelectionOutline=pn,s.clearSelectionOutline=qn;function We(Ge,Ae,Le){let ht=document.createElement("div");ht.className="inspector-group";let Ye=document.createElement("div");Ye.className="inspector-group-header";let ct=document.createElement("span");ct.className="vis-arrow";let Ze=document.createElement("span");if(Ze.className="inspector-prop-name",Ze.textContent=Ge,Ze.title=Ge,Ye.appendChild(ct),Ye.appendChild(Ze),Ae!==null){let pt=document.createElement("span");pt.className="inspector-count",pt.textContent=`(${Ae})`,Ye.appendChild(pt)}ht.appendChild(Ye);let Ke=document.createElement("div");return Ke.className="inspector-group-children"+(Le?" collapsed":""),ct.textContent=Le?"\u25B6":"\u25BC",ht.appendChild(Ke),Ye.addEventListener("click",()=>{Ke.classList.toggle("collapsed"),ct.textContent=Ke.classList.contains("collapsed")?"\u25B6":"\u25BC"}),{group:ht,header:Ye,arrow:ct,body:Ke}}function En(Ge){let Ae=Ge.column_headers||[],Le=Ge.row_headers||[],ht=Ge.data||[],Ye=Ae.some(pt=>pt!==""),ct=Le.some(pt=>pt!==""),Ze=document.createElement("table");if(Ze.className="inspector-table",Ye){let pt=document.createElement("thead"),Xn=document.createElement("tr");ct&&Xn.appendChild(document.createElement("th"));for(let _i of Ae){let Hi=document.createElement("th");Hi.textContent=_i,Xn.appendChild(Hi)}pt.appendChild(Xn),Ze.appendChild(pt)}let Ke=document.createElement("tbody");return ht.forEach((pt,Xn)=>{let _i=document.createElement("tr");if(ct){let Hi=document.createElement("th");Hi.textContent=Le[Xn]||"",_i.appendChild(Hi)}for(let Hi of pt){let _n=document.createElement("td");_n.textContent=Hi,_i.appendChild(_n)}Ke.appendChild(_i)}),Ze.appendChild(Ke),Ze}function hr(Ge,Ae){if(Ge.table){let Ze=(Ge.table.data||[]).length,{group:Ke,body:pt}=We(Ge.name,Ze,Ze>=10),Xn=document.createElement("div");return Xn.className="inspector-table-scroll",Xn.appendChild(En(Ge.table)),pt.appendChild(Xn),Ke}if(Ge.children){let Ze=Ge.children.length<10,{group:Ke,body:pt}=We(Ge.name,Ge.children.length,!Ze);for(let Xn of Ge.children)pt.appendChild(hr(Xn,Ae));return Ke}let Le=document.createElement("div");Le.className="inspector-prop";let ht=document.createElement("span");ht.className="inspector-prop-name",ht.textContent=Ge.name||"",ht.title=Ge.name||"";let Ye=document.createElement("span");Ye.className="inspector-prop-value",Ye.textContent=Ge.value||"",Le.appendChild(ht),Le.appendChild(Ye);let ct=Ge.editable&&Ae&&(Ae.onPropertyEdit||Ae.onPropertyChange)&&Ge.editor&&(Ge.editor.type==="list"||Ge.editor.type==="bool");if(ct&&Ge.value_select_id===void 0)Le.replaceChild(x(Ge,Ae),Ye);else if(ct){let Ze=document.createElement("button");Ze.className="inspector-edit-btn",Ze.title="Edit "+Ge.name,Ze.textContent="\u270E",Ze.addEventListener("click",Ke=>{Ke.stopPropagation();let pt=x(Ge,Ae);Le.replaceChild(pt,Ye),Ze.remove(),pt.focus()}),Le.appendChild(Ze)}else Ge.editable&&Ae&&(Ae.onPropertyChange||Ae.onPropertyEdit)&&(Ye.contentEditable=!0,Ye.classList.add("inspector-editable"),Ye.addEventListener("blur",()=>{let Ze=Ye.textContent;if(Ze!==Ge.value){if(Ae.onPropertyChange){Ae.onPropertyChange(Ge.name,Ze);return}if(Ge.editor&&Ge.editor.type==="number"){let Ke=Number(Ze);if(Ze.trim()===""||Number.isNaN(Ke)){Fb("Not a number: "+Ze),Ye.textContent=Ge.value;return}Ae.onPropertyEdit(Ge,{value:Ke});return}Ae.onPropertyEdit(Ge,{value:Ze})}}),Ye.addEventListener("keydown",Ze=>{Ze.key==="Enter"&&(Ze.preventDefault(),Ye.blur()),Ze.key==="Escape"&&(Ye.textContent=Ge.value,Ye.blur())}));return Ge.name_select_id!==void 0&&Ge.value_select_id===void 0?(en(Le,Ge.name_select_id),ht.classList.add("inspector-link")):Ge.name_select_id!==void 0&&en(ht,Ge.name_select_id),Ge.value_select_id!==void 0&&en(Ye,Ge.value_select_id),Le}let qi=140,Me=60,ve=500,wt=qi;function gn(){s.inspectorEl&&s.inspectorEl.style.setProperty("--inspector-name-w",wt+"px")}function vn(){let Ge=document.createElement("div");return Ge.className="inspector-col-resizer",Ge.title="Drag to resize the name column",Ge.addEventListener("mousedown",Ae=>{Ae.preventDefault();let Le=Ae.clientX,ht=wt;Ge.classList.add("dragging");let Ye=Ze=>{wt=Math.max(Me,Math.min(ve,ht+Ze.clientX-Le)),gn()},ct=()=>{Ge.classList.remove("dragging"),document.removeEventListener("mousemove",Ye),document.removeEventListener("mouseup",ct)};document.addEventListener("mousemove",Ye),document.addEventListener("mouseup",ct)}),Ge}function Mn(Ge){!Ge||!s.view||!s.designScale||s.view.fitWorldRect(Z(...Ge),{padding:[20,20]})}function xi(Ge){if(!s.inspectorEl)return;if(c=Ge,s.inspectorEl.innerHTML="",!Ge||!Ge.properties||Ge.properties.length===0){de();let Ye=document.createElement("div");Ye.className="stub-panel",Ye.innerHTML='
Inspector
Select an object in the layout to inspect its properties.
',s.inspectorEl.appendChild(Ye);return}if(!Ge.onPropertyChange&&!Ge.onPropertyEdit&&!ua(s)&&(Ge.onPropertyEdit=(Ye,ct)=>_(Ye.name,ct)),Ge){let Ye=document.createElement("div");Ye.className="inspector-toolbar";let ct=document.createElement("button");if(ct.className="or-btn or-btn-icon",ct.title="Back",ct.innerHTML=Idn,ct.disabled=!Ge.can_navigate_back,ct.addEventListener("click",()=>bi()),Ye.appendChild(ct),Ge.bbox){let Ze=document.createElement("button");Ze.className="or-btn or-btn-icon",Ze.title="Zoom to",Ze.innerHTML=Rdn,Ze.addEventListener("click",()=>Mn(Ge.bbox)),Ye.appendChild(Ze)}if(Ge.type==="Net"&&Ge.name){let Ze=s.focusNets.has(Ge.name),Ke=document.createElement("button");Ke.className="or-btn or-btn-icon",Ke.title=Ze?"De-focus net":"Focus net",Ke.innerHTML=Ze?Bdn:Ddn,Ke.addEventListener("click",()=>F(Ge.name)),Ye.appendChild(Ke)}if(Ge.type==="Net"&&Ge.name&&Ge.has_guides){let Ze=s.routeGuideNets.has(Ge.name),Ke=document.createElement("button");Ke.className="or-btn or-btn-icon",Ke.title=Ze?"Hide route guides":"Show route guides",Ke.innerHTML=Ze?Ndn:Odn,Ke.addEventListener("click",()=>z(Ge.name)),Ye.appendChild(Ke)}if(Ge.type==="Net"&&Ge.name&&s.showInsertBufferDialog){let Ze=document.createElement("button");Ze.className="or-btn or-btn-icon",Ze.title="Insert buffer",Ze.innerHTML=Gdn,Ze.addEventListener("click",()=>s.showInsertBufferDialog(Ge.name)),Ye.appendChild(Ze)}if(s.focusNets.size>0){let Ze=document.createElement("button");Ze.className="or-btn or-btn-icon",Ze.title="Clear focus nets",Ze.innerHTML=Fdn,Ze.addEventListener("click",()=>O()),Ye.appendChild(Ze)}if(typeof Ge.highlight_group=="number"&&!ua(s)&&(s.techData?.highlight_colors||[]).length){let Ze=document.createElement("button");Ze.className="or-btn or-btn-icon inspector-highlight-btn";let Ke=Ge.highlight_group;if(Ze.title=Ke>=0?"Highlight group "+(Ke+1):"Add to highlight group",Ze.innerHTML=kdn,Ke>=0){let pt=s.techData.highlight_colors[Ke];Ze.style.backgroundColor=`rgba(${pt[0]}, ${pt[1]}, ${pt[2]}, 0.45)`,Ze.style.borderColor=`rgb(${pt[0]}, ${pt[1]}, ${pt[2]})`}Ze.addEventListener("click",()=>I(Ze,Ge)),Ye.appendChild(Ze)}if(Array.isArray(Ge.actions)&&!ua(s))for(let Ze of Ge.actions){let Ke=document.createElement("button");Ke.className="or-btn inspector-action-btn",Ke.title=Ze,Ze==="Delete"?(Ke.classList.add("or-btn-icon","or-btn-danger-hover"),Ke.innerHTML=Ldn):(Ke.classList.add("or-btn-sm"),Ke.textContent=Ze),Ke.addEventListener("click",()=>T(Ze,Ge)),Ye.appendChild(Ke)}s.inspectorEl.appendChild(Ye)}let Ae=Ge.selection_count||0,Le=typeof Ge.selection_index=="number"?Ge.selection_index:-1;if(Ae>1&&Le>=0){let Ye=document.createElement("div");Ye.className="inspector-selection-nav";let ct=document.createElement("button");ct.className="or-btn or-btn-icon",ct.title="Previous (Shift+click to multi-select)",ct.innerHTML=Udn,ct.addEventListener("click",()=>mn(-1));let Ze=document.createElement("span");Ze.className="inspector-selection-label",Ze.textContent=Le+1+" / "+Ae;let Ke=document.createElement("button");Ke.className="or-btn or-btn-icon",Ke.title="Next",Ke.innerHTML=zdn,Ke.addEventListener("click",()=>mn(1)),Ye.appendChild(ct),Ye.appendChild(Ze),Ye.appendChild(Ke),s.inspectorEl.appendChild(Ye)}let ht=document.createElement("div");ht.className="inspector-rows";for(let Ye of Ge.properties)ht.appendChild(hr(Ye,Ge));ht.appendChild(vn()),s.inspectorEl.appendChild(ht),gn()}function mi(Ge){let Ae=document.createElement("div");Ae.className="inspector",s.inspectorEl=Ae,Ge.element.appendChild(Ae),xi(null)}function ri(){if(c){if(c.type==="Ruler"){s.rulerManager&&s.rulerManager._selectedRulerId!==null&&s.rulerManager._selectRuler(s.rulerManager._selectedRulerId);return}s.websocketManager&&cn(-1)}}return{createInspector:mi,updateInspector:xi,highlightBBox:Yi,pulseHighlight:Si,animateSelection:it,stopSelectionAnimation:de,navigateInspector:cn,refreshInspector:ri}}var Jhe=class{constructor(n,r,c){this._app=r,this._refreshOverlay=c||(()=>{}),this._data={selection:[],groups:[],truncated:!1},this._tab="selected",this._filter="",this._sortKey=null,this._sortAsc=!0,this._pendingRefresh=null,this._inFlight=!1,this._staleWhileInFlight=!1,this._visible=!0,this._el=document.createElement("div"),this._el.className="selection-browser",n.element.appendChild(this._el),n.on?.("show",()=>{this._visible=!0,this.refresh()}),n.on?.("hide",()=>{this._visible=!1}),n.on?.("destroy",()=>{this._visible=!1,this._staleWhileInFlight=!1,this._pendingRefresh!==null&&(clearTimeout(this._pendingRefresh),this._pendingRefresh=null)}),this._render(),this.refresh()}scheduleRefresh(){!this._visible||this._pendingRefresh!==null||(this._pendingRefresh=setTimeout(()=>{this._pendingRefresh=null,this.refresh()},150))}refresh(){if(!this._visible||ua(this._app))return;if(this._inFlight){this._staleWhileInFlight=!0;return}this._inFlight=!0;let n=()=>{this._inFlight=!1,this._staleWhileInFlight&&(this._staleWhileInFlight=!1,this.refresh())};this._app.websocketManager.request({type:"list_selection"}).then(r=>{r.ok&&(this._data=r,this._render()),n()}).catch(n)}_entries(){let n;this._tab==="selected"?n=(this._data.selection||[]).map((c,u)=>({row:c,index:u,group:-1})):n=(this._data.groups||[]).flatMap((c,u)=>c.map((d,b)=>({row:d,index:b,group:u})));let r=this._filter.trim().toLowerCase();if(r&&(n=n.filter(({row:c})=>(c.name||"").toLowerCase().includes(r)||(c.type||"").toLowerCase().includes(r))),this._sortKey){let c=this._sortKey,u=this._sortAsc?1:-1;n=n.slice().sort((d,b)=>u*String(d.row[c]||"").localeCompare(String(b.row[c]||"")))}return n}_fmtCoord(n){if(this._app.showDbu)return String(n);let r=this._app.getDbuPerMicron?this._app.getDbuPerMicron():1e3;return(n/r).toFixed(3)}_fmtBounds(n){if(!n)return"";let[r,c,u,d]=n;return`(${this._fmtCoord(r)}, ${this._fmtCoord(c)}), (${this._fmtCoord(u)}, ${this._fmtCoord(d)})`}_inspectRow(n,r){let c=n.group<0?{type:"inspect_selection",index:n.index,use_dbu:this._app.showDbu}:{type:"inspect_group",group:n.group,index:n.index,use_dbu:this._app.showDbu};this._app.websocketManager.request(c).then(u=>{if(!u.ok){this.refresh();return}this._app.updateInspector&&this._app.updateInspector(u),r&&this._app.focusComponent&&this._app.focusComponent("Inspector"),this._refreshOverlay()}).catch(()=>{})}_deselectRow(n){this._app.websocketManager.request({type:"deselect",index:n.index}).then(()=>{this.refresh(),this._refreshOverlay()}).catch(()=>{})}_clearHighlights(){this._app.websocketManager.request({type:"clear_highlights",group:-1}).then(()=>{this.refresh(),this._refreshOverlay(),this._app.refreshInspector&&this._app.refreshInspector()}).catch(()=>{})}_zoomToBBox(n){if(!n||!this._app.designScale||!this._app.view)return;let[r,c,u,d]=n,b=this._app.getDbuPerMicron?this._app.getDbuPerMicron():1e3,w=Math.min(10*b,2*Math.max(u-r,d-c));this._app.view.fitWorldRect(X1(r-w,c-w,u+w,d+w,this._app.designScale,this._app.designOriginX,this._app.designOriginY))}_render(){this._app.stopSelectionAnimation&&this._app.stopSelectionAnimation(),this._el.innerHTML="";let n=(this._data.selection||[]).length,r=(this._data.groups||[]).reduce((b,w)=>b+w.length,0),c=document.createElement("div");c.className="sb-tabs";for(let[b,w,_]of[["selected","Selected",n],["highlighted","Highlighted",r]]){let x=document.createElement("button");x.className="sb-tab"+(this._tab===b?" active":""),x.textContent=`${w} (${_})`,x.addEventListener("click",()=>{this._tab=b,this._render()}),c.appendChild(x)}let u=document.createElement("button");if(u.className="or-btn or-btn-sm sb-tool",u.title="Refresh",u.textContent="\u27F3",u.addEventListener("click",()=>this.refresh()),c.appendChild(u),this._tab==="highlighted"&&r>0){let b=document.createElement("button");b.className="or-btn or-btn-sm sb-tool",b.title="Clear all highlights",b.textContent="Clear",b.addEventListener("click",()=>this._clearHighlights()),c.appendChild(b)}this._el.appendChild(c);let d=document.createElement("input");if(d.type="text",d.className="sb-filter",d.placeholder="Filter by name or type\u2026",d.value=this._filter,d.addEventListener("input",()=>{this._filter=d.value,this._renderTable()}),this._el.appendChild(d),this._data.truncated){let b=document.createElement("div");b.className="sb-truncated",b.textContent="List truncated \u2014 showing the first 1000 entries per set.",this._el.appendChild(b)}this._tableWrap=document.createElement("div"),this._tableWrap.className="sb-table-wrap",this._el.appendChild(this._tableWrap),this._renderTable()}_renderTable(){this._tableWrap.innerHTML="";let n=this._entries();if(!n.length){let _=document.createElement("div");_.className="sb-empty",_.textContent=this._tab==="selected"?"Nothing selected.":"Nothing highlighted.",this._tableWrap.appendChild(_);return}let r=document.createElement("table");r.className="sb-table";let c=document.createElement("thead"),u=document.createElement("tr"),d=[["name","Object"],["type","Type"],[null,"Bounds"]];this._tab==="highlighted"&&d.push([null,"Group"]),d.push([null,""]);for(let[_,x]of d){let T=document.createElement("th");T.textContent=x,_&&(T.classList.add("sb-sortable"),this._sortKey===_&&(T.textContent+=this._sortAsc?" \u25B2":" \u25BC"),T.addEventListener("click",()=>{this._sortKey===_?this._sortAsc=!this._sortAsc:(this._sortKey=_,this._sortAsc=!0),this._renderTable()})),u.appendChild(T)}c.appendChild(u),r.appendChild(c);let b=document.createElement("tbody"),w=this._app.techData?.highlight_colors||[];for(let _ of n){let x=document.createElement("tr");x.className="sb-row";let T=document.createElement("td");T.textContent=_.row.name||"";let M=document.createElement("td");M.textContent=_.row.type||"";let L=document.createElement("td");if(L.textContent=this._fmtBounds(_.row.bbox),x.appendChild(T),x.appendChild(M),x.appendChild(L),this._tab==="highlighted"){let D=document.createElement("td"),F=document.createElement("span");F.className="sb-chip";let O=w[_.group];O&&(F.style.backgroundColor=`rgb(${O[0]}, ${O[1]}, ${O[2]})`),D.appendChild(F),D.appendChild(document.createTextNode(` Group ${_.group+1}`)),x.appendChild(D)}let I=document.createElement("td");if(I.className="sb-actions",_.row.bbox){let D=document.createElement("button");D.className="sb-row-btn",D.title="Zoom to",D.textContent="\u2316",D.addEventListener("click",F=>{F.stopPropagation(),this._zoomToBBox(_.row.bbox)}),I.appendChild(D)}if(this._tab==="selected"){let D=document.createElement("button");D.className="sb-row-btn",D.title="De-select",D.textContent="\u2715",D.addEventListener("click",F=>{F.stopPropagation(),this._deselectRow(_)}),I.appendChild(D)}x.appendChild(I),x.addEventListener("click",()=>this._inspectRow(_,!1)),x.addEventListener("dblclick",()=>this._inspectRow(_,!0)),_.row.bbox&&(x.addEventListener("mouseenter",()=>{this._app.animateSelection&&this._app.animateSelection(_.row.bbox,{repeats:0})}),x.addEventListener("mouseleave",()=>{this._app.stopSelectionAnimation&&this._app.stopSelectionAnimation()})),b.appendChild(x)}r.appendChild(b),this._tableWrap.appendChild(r),ak(r)}};var m3t="options-dialog",g3t=[{label:"System default",value:""},{label:"Sans-serif",value:"sans-serif"},{label:"Serif",value:"serif"},{label:"Monospace",value:"monospace"},{label:"Helvetica / Arial",value:"Helvetica, Arial, sans-serif"},{label:"Georgia",value:"Georgia, 'Times New Roman', serif"},{label:"Courier",value:"'Courier New', Courier, monospace"}],jdn=100,Qhe=70,ede=200;function rH(s){let n=s===""||s===null?NaN:Math.round(Number(s));return Number.isFinite(n)?Math.min(ede,Math.max(Qhe,n)):jdn}function b3t(s){let{overlay:n,close:r,okBtn:c,showError:u}=MO("Arrow keys scroll step",`
How far one arrow-key press pans the layout. - Default ${V5e}.
`,"Apply",p3t),d=n.querySelector(".opt-step");d.focus(),d.select();function b(){let w=d.value.trim(),_=Number(w);if(w===""||!Number.isFinite(_)){u("Step must be a number.");return}if(_eH){u(`Step must be between ${QW} and ${eH} px.`);return}s.setArrowStep(_),r()}return c.addEventListener("click",b),d.addEventListener("keydown",w=>{w.key==="Enter"&&(w.preventDefault(),b())}),{close:r}}function m3t(s){let n=s.fontFamily||"",r=d3t.some(D=>D.value===n),c=d3t.map(D=>``).join("")+(r?"":``),{overlay:u,close:d,okBtn:b,showError:w}=MO("Application font",` + Default ${V5e}.`,"Apply",m3t),d=n.querySelector(".opt-step");d.focus(),d.select();function b(){let w=d.value.trim(),_=Number(w);if(w===""||!Number.isFinite(_)){u("Step must be a number.");return}if(_eH){u(`Step must be between ${QW} and ${eH} px.`);return}s.setArrowStep(_),r()}return c.addEventListener("click",b),d.addEventListener("keydown",w=>{w.key==="Enter"&&(w.preventDefault(),b())}),{close:r}}function w3t(s){let n=s.fontFamily||"",r=g3t.some(D=>D.value===n),c=g3t.map(D=>``).join("")+(r?"":``),{overlay:u,close:d,okBtn:b,showError:w}=MO("Application font",`
@@ -10241,7 +10241,7 @@ Slack: [${r.lower.toFixed(I)}, ${r.upper.toFixed(I)}) ${L}`}this._tooltip.style. 0123456789
Applies to the panels, menus and console. Text drawn into the layout is rendered on the server and is not - affected.
`,"Apply",p3t),_=u.querySelector(".opt-family"),x=u.querySelector(".opt-custom"),T=u.querySelector(".opt-scale"),M=u.querySelector(".opt-preview");function L(){M.style.fontFamily=x.value.trim()||_.value,M.style.fontSize=`calc(13px * ${rH(T.value)/100})`}for(let D of[_,x,T])D.addEventListener("input",L);L();function I(){let D=T.value.trim(),F=Number(D);if(D===""||!Number.isFinite(F)){w("Size must be a number.");return}if(Fede){w(`Size must be between ${Qhe} and ${ede} %.`);return}s.setAppFont({family:x.value.trim()||_.value,scale:F}),d()}b.addEventListener("click",I);for(let D of[x,T])D.addEventListener("keydown",F=>{F.key==="Enter"&&(F.preventDefault(),I())});return{close:d}}function Q5e(s){return String(s).replace(/&/g,"&").replace(/"/g,""").replace(//g,">")}var Udn='',zdn='';function CO(s){let n=document.createElement("span");return n.className="vis-name",s!=null&&(n.textContent=s),n}function ST(){let s=document.createElement("span");return s.className="vis-sel-cb vis-sel-spacer",s}function b3t(){let s=document.createElement("div");s.className="display-controls-header",s.appendChild(CO(""));for(let[n,r]of[[Udn,"Visible"],[zdn,"Selectable"]]){let c=document.createElement("span");c.className="vis-header-icon",c.title=r,c.innerHTML=n,s.appendChild(c)}return s}var tde=class{constructor(n,r,c){this.visibility=n,this.selectability=r,this.onChange=c;let u=()=>{this._syncAll(),this.onChange()};this.model=new Rv(u),this.selModel=new Rv(u)}add(n){return this.model.addFromSpec(this._enrichSpec(n,"")),this.selModel.addFromSpec(this._enrichSelSpec(n,"",!1)),this}render(n){for(let r of this.model.roots)n.appendChild(this._dom(r));this._syncAll()}_nodeId(n,r){let c=n.key||n.label;return r?r+"/"+c:c}_enrichSpec(n,r){let c=this._nodeId(n,r),u={id:c,data:n};return n.children?u.children=n.children.map(d=>this._enrichSpec(d,c)):n.key&&(u.checked=!!this.visibility[n.key]),n.disabled!=null&&(u.disabled=n.disabled),u}_enrichSelSpec(n,r,c){let u=n.addSelectable===!0?!0:n.addSelectable===!1?!1:c,d=this._nodeId(n,r),b={id:d,data:n,hasCheckbox:!1};if(n.children){b.children=n.children.map(_=>this._enrichSelSpec(_,d,u));let w=_=>_.some(x=>x.hasCheckbox||x.children&&w(x.children));b.hasCheckbox=w(b.children),b.hasCheckbox&&(b.checked=!0)}else if(n.key){let w=n.selectable===!0||n.selectable!==!1&&c;b.hasCheckbox=w,w&&(b.checked=this.selectability[n.key]!==!1)}return b}_syncAll(){this.model.forEach(n=>{n.cb&&(n.cb.checked=n.checked,n.cb.indeterminate=n.indeterminate);let r=n.data;r.key&&(this.visibility[r.key]=n.checked),r.visKey&&(this.visibility[r.visKey]=n.checked||n.indeterminate)}),this.selModel.forEach(n=>{if(!n.hasCheckbox)return;let r=n.data;if(r.key&&(this.selectability[r.key]=n.checked),!n.selCb)return;n.selCb.checked=n.checked,n.selCb.indeterminate=n.indeterminate;let c=this.model.get(n.id),u=c&&!c.checked&&!c.indeterminate;n.selCb.disabled=u,n.selLabel&&n.selLabel.classList.toggle("vis-sel-disabled",u)}),this.model.forEach(n=>{let r=n.data;if(r.disabledBy&&n.el){let c=!this.visibility[r.disabledBy];n.el.classList.toggle("disabled",c)}})}_buildSelCheckbox(n){let r=this.selModel.get(n.id);if(!r||!r.hasCheckbox)return null;let c=document.createElement("input");return c.type="checkbox",c.className="vis-sel-cb",c.title="Selectable",c.addEventListener("change",()=>{this.selModel.check(r.id,c.checked)}),r.selCb=c,c}_dom(n){let r=n.data,c=document.createElement("input");c.type="checkbox",c.className="vis-cb",c.title="Visible",n.cb=c,c.addEventListener("change",()=>this.model.check(n.id,c.checked));let u=this._buildSelCheckbox(n),d=M=>{if(M.appendChild(c),u){M.appendChild(u);let L=this.selModel.get(n.id);L&&(L.selLabel=M)}else M.appendChild(ST())};if(!n.children.length){let M=document.createElement("div");M.className="vis-leaf";let L=document.createElement("span");return L.className="vis-arrow",L.style.visibility="hidden",L.textContent="\u25B6",M.appendChild(L),M.appendChild(CO(r.label)),d(M),n.el=M,M}let b=document.createElement("div");b.className="vis-group";let{header:w,arrow:_,name:x}=sk();x.textContent=r.label,d(w),b.appendChild(w);let T=document.createElement("div");T.className="vis-group-children",r.disabled&&T.classList.add("disabled");for(let M of n.children)T.appendChild(this._dom(M));return b.appendChild(T),ok(w,_,T,!0),b}};function sH(s,n,r,c){let u=new Set,d=Math.max(0,s-n),b=Math.min(c-1,s+r);for(let w=d;w<=b;w++)u.add(w);return u}function Gdn(s){let n={};for(let[r,c]of Object.entries(s||{}))c!==1&&(n[r]=c);return n}function nde(s,n){return(s||[]).some(r=>r.every(c=>!!n[c]))}function jdn(s,n){return s.map(r=>{let c=!n.has(r.path);return{id:r.path,parentId:r.parent!=null?r.parent:null,hasCheckbox:r.parent!=null,checked:c,data:{path:r.path,name:r.name,master:r.master,depth:r.depth}}})}var $dn=3,w3t=[[70,130,210],[200,50,50],[50,180,80],[200,160,40],[160,60,200],[40,190,190],[220,120,50],[180,70,150]];function Vdn(s){return!s.forceComposite||ua(s)?0:s.groupLayers||Txt}function v3t(s,n,r,c,u,d){if(!s.displayControlsEl)return;s.displayControlsEl.innerHTML="",s.displayControlsEl.appendChild(b3t());for(let Ae of s.allLayers||[])Ae.remove();s.allLayers=[],s.baseSlot=null,s.topSlot=null;let b=new Set;function w(){for(let Ae of b)Ae.refresh();b.clear()}function _(){s.baseSlot&&b.add(s.baseSlot)}function x(Ae){return{layer:Ae,opacity:1,visible:!1}}function T(Ae,Le){wxt(Ae,Le)&&_()}function M(Ae,Le,ht){let Ye={layer:Ae,opacity:1,visible:!!ht};return Le&&(s[Le]=Ye),Ye}let L=[M("_instances",null,!0),M("_pins","pinsLayer",n.pins),M("_modules","modulesLayer",n.module_view)],I=[];s.overlayLayers=(c&&c.overlays||[]).map(Ae=>({def:Ae,layer:M(Ae.name,null,nde(Ae.shown_by,n)),under:Ae.z_index<$dn}));for(let{layer:Ae,under:Le}of[...s.overlayLayers].sort((ht,Ye)=>ht.def.z_index-Ye.def.z_index))(Le?L:I).push(Ae);let D=[],F=[],O=null,z=new Set,Z=new Set;try{let Ae=window.sessionStorage.getItem("or_hidden_layers");Ae&&(z=new Set(JSON.parse(Ae)))}catch{}try{let Ae=window.sessionStorage.getItem("or_nonselectable_layers");Ae&&(Z=new Set(JSON.parse(Ae)))}catch{}try{let Ae=window.sessionStorage.getItem("or_layer_patterns");Ae&&Object.assign(s.layerPatterns,JSON.parse(Ae))}catch{}function H(){try{window.sessionStorage.setItem("or_layer_patterns",JSON.stringify(Gdn(s.layerPatterns)))}catch{}}function te(Ae,Le){Le===1?delete s.layerPatterns[Ae]:s.layerPatterns[Ae]=Le,H(),_(),w()}let oe=[{label:"Solid",value:1},{label:"Diagonal",value:2},{label:"Cross",value:3},{label:"Dots",value:4},{label:"None (no fill)",value:0}],ne=0;function ue(Ae,Le="layers",ht=void 0){let Ye=[],ct=Ae.type==="category"?ht:Ae.path,Ze=Ae.flipped===!0,Ke=Ae.instances||[],pt=Ke.filter(ei=>ei.type!=="category"),Xn=Ke.filter(ei=>ei.type==="category"),_i=Ae.layers||[],Hi=ne;ne+=_i.length;function _n(ei,ar){let yn=ei.map((Re,nt)=>nt);ar&&yn.reverse(),yn.forEach(Re=>{let nt=ei[Re],kt=Le+"/"+(nt.name||Re);Ye.push(ue(nt,kt,ct))})}function Je(){(Ze?_i.map((ar,yn)=>yn).reverse():_i.map((ar,yn)=>yn)).forEach(ar=>{let yn=_i[ar],Re=yn.name||yn,nt=Hi+ar,kt=x(Re),xn=`${Le}/${Re}`,Ei=!z.has(xn);Ei&&(T(kt,!0),s.visibleLayers.add(xn),s.visibleLayerNames.add(Re)),D.push(kt),F.push(xn),Ye.push({id:xn,data:{name:Re,layer:kt,color:yn.color,colorIndex:nt,nodeId:xn,ownerChipletPath:ct},checked:Ei})})}_n(pt,!1),Ze&&Je(),_n(Xn,Ze),Ze||Je();let Qn={name:Ae.name,isInstance:!0};return Ae.type==="category"&&(Ae.name==="Implant"||Ae.name==="Other")&&(Qn.startCollapsed=!0),Ae.type!=="category"&&(Qn.chipletPath=Ae.path),{id:Le,data:Qn,children:Ye}}let Te;c.layer_hierarchy?Te=ue(c.layer_hierarchy,"layers_parent"):Te={id:"layers_parent",children:c.layers.map((Ae,Le)=>{let ht=x(Ae),Ye=`layers_parent/${Ae}`,ct=!z.has(Ye);return ct&&(T(ht,!0),s.visibleLayers.add(Ye),s.visibleLayerNames.add(Ae)),D.push(ht),F.push(Ye),{id:Ye,data:{name:Ae,layer:ht,colorIndex:Le,nodeId:Ye},checked:ct}})};function Q(Ae,Le,ht){let Ye=s.view.addTileSlot(Ae,{order:Le,source:Cxt({wm:s.websocketManager,ctx:s.tileCtx,getItems:()=>ht,dpr:xO,tileSize:Fb,isDoubleBuffer:()=>s.doubleBuffer,groupLayers:()=>Vdn(s)})});return Ye.items=ht,Ye}s.baseSlot=Q("base",bp.base,[...L,...D]),s.topSlot=Q("top",bp.top,I),s.allLayers=[s.baseSlot,s.topSlot];function ge(Ae){if(!Ae.children||Ae.children.length===0){let Le=Ae.data&&Ae.data.name,ht=Le?!Z.has(Le):!0;return ht&&Le&&s.selectableLayers.add(Le),{id:Ae.id,data:{name:Le},checked:ht}}return{id:Ae.id,data:{name:Ae.data&&Ae.data.name},children:Ae.children.map(ge)}}let Qe=ge(Te),st=new Rv(()=>{s.visibleLayerNames.clear();let Ae=[],Le={},ht=!1,Ye=!1,ct=O&&s.visibleChiplets instanceof Set;if(st.forEach(Ke=>{if(Ke.cb&&(Ke.cb.checked=Ke.checked,Ke.cb.indeterminate=Ke.indeterminate),Ke.data&&Ke.data.layer){let pt=Ke.data.nodeId||Ke.data.name;Ae.push(pt),T(Ke.data.layer,Ke.checked),Ke.checked?(s.visibleLayers.add(pt),s.visibleLayerNames.add(Ke.data.name)):s.visibleLayers.delete(pt)}if(ct&&Ke.data&&Ke.data.chipletPath){let pt=Ke.data.chipletPath,Xn=O.get(pt);if(Xn){let _i=Ke.checked||Ke.indeterminate,Hi={checked:Ke.checked,indeterminate:Ke.indeterminate};(Xn.checked!==Ke.checked||Xn.indeterminate!==Ke.indeterminate)&&(Le[pt]=Hi,ht=!0),s.visibleChiplets.has(pt)!==_i&&(Ye=!0)}}}),s.baseSlot&&b.has(s.baseSlot))for(let{def:Ke,under:pt}of s.overlayLayers)nde(Ke.layers_by,n)&&b.add(pt?s.baseSlot:s.topSlot);w(),Ne();let Ze=Ae.filter(Ke=>!s.visibleLayers.has(Ke));try{window.sessionStorage.setItem("or_hidden_layers",JSON.stringify(Ze))}catch{}s.syncDisplayState(),Ye?O.mirrorStates(Le):ht&&(O.mirrorStatesQuiet(Le),O.forEach(Ke=>{Ke.cb&&(Ke.cb.checked=Ke.checked,Ke.cb.indeterminate=Ke.indeterminate)}))});s.layerModel=st,st.addFromSpec(Te);let at=new Rv(()=>{s.selectableLayers.clear(),at.forEach(Le=>{Le.checked&&Le.data&&Le.data.name&&s.selectableLayers.add(Le.data.name)}),Ne();let Ae=c.layers.filter(Le=>!s.selectableLayers.has(Le));try{window.sessionStorage.setItem("or_nonselectable_layers",JSON.stringify(Ae))}catch{}s.syncDisplayState()});at.addFromSpec(Qe);function Ne(){at.forEach(Ae=>{if(!Ae.selCb)return;Ae.selCb.checked=Ae.checked,Ae.selCb.indeterminate=Ae.indeterminate;let Le=st.get(Ae.id),ht=Le&&!Le.checked&&!Le.indeterminate;Ae.selCb.disabled=ht})}let tt=document.createElement("div");tt.className="context-menu",tt.style.display="none",document.body.appendChild(tt);function ot(Ae){let Le={};F.forEach((ht,Ye)=>{ht&&(Le[ht]=Ae.has(Ye))}),st.checkSet(Le)}function Tt(){tt.style.display="none"}function jt(Ae,Le){let ht=document.createElement("div");ht.className="context-menu-item",ht.textContent=Ae,ht.addEventListener("click",()=>{Le(),Tt()}),tt.appendChild(ht)}let en=D.length,mn=[{label:"Show only this layer",fn:Ae=>sH(Ae,0,0,en)},{label:"Show layer range \u2195",fn:Ae=>sH(Ae,1,1,en)},{label:"Show layer range \u2195\u2195",fn:Ae=>sH(Ae,2,2,en)},{label:"Show layer range \u2193",fn:Ae=>sH(Ae,1,0,en)},{label:"Show layer range \u2191",fn:Ae=>sH(Ae,0,1,en)}];document.addEventListener("click",Ae=>{tt.contains(Ae.target)||Tt()}),document.addEventListener("keydown",Ae=>{Ae.key==="Escape"&&Tt()});let cn=!ua(s),bi=null;function Vt(){bi&&(bi.classList.remove("vis-row-selected"),bi=null)}cn&&Nxt(s,Vt);function pn(Ae,Le,ht){let Ye=Pm(s);bi=Ae,Ae.classList.add("vis-row-selected");let ct={type:"select_layer",layer:Le,use_dbu:s.showDbu};ht&&(ct.chiplet=ht),s.websocketManager.request(ct).then(Ze=>{Z1(s,Ye)&&(s.updateInspector&&s.updateInspector(Ze),s.focusComponent&&s.focusComponent("Inspector"),s.refreshOverlay&&s.refreshOverlay())}).catch(Ze=>{console.error("select_layer failed:",Ze),Z1(s,Ye)&&Vt()})}function qn(Ae,Le=!1){let ht=at.get(Ae.id);if(!Ae.children||Ae.children.length===0){let Ye=document.createElement("div");Ye.className=cn?"vis-leaf vis-leaf-selectable":"vis-leaf";let ct=document.createElement("span");ct.className="vis-arrow",ct.style.visibility="hidden",ct.textContent="\u25B6",Ye.appendChild(ct);let Ze=Ae.data.colorIndex,Ke=Ae.data.name,pt=CO(),Xn=document.createElement("span");Xn.className="layer-color";let _i=Ae.data.color||c.layer_colors&&c.layer_colors[Ze]||w3t[Ze%w3t.length];Xn.style.backgroundColor=`rgb(${_i[0]},${_i[1]},${_i[2]})`,pt.appendChild(Xn),pt.appendChild(document.createTextNode(Ke)),Ye.appendChild(pt),cn&&pt.addEventListener("click",()=>{pn(Ye,Ke,Ae.data.ownerChipletPath)});let Hi=document.createElement("input");if(Hi.type="checkbox",Hi.className="vis-cb",Hi.title="Visible",Hi.checked=Ae.checked,Ae.cb=Hi,Hi.addEventListener("change",()=>{st.check(Ae.id,Hi.checked)}),Ye.appendChild(Hi),ht){let _n=document.createElement("input");_n.type="checkbox",_n.className="vis-sel-cb",_n.title="Selectable",_n.checked=ht.checked,ht.selCb=_n,_n.addEventListener("change",()=>{at.check(Ae.id,_n.checked)}),Ye.appendChild(_n)}else Ye.appendChild(ST());return Ye.addEventListener("contextmenu",_n=>{_n.preventDefault(),_n.stopPropagation(),tt.innerHTML="";for(let ei of mn)jt(ei.label,()=>ot(ei.fn(Ze)));let Je=document.createElement("div");Je.className="context-menu-separator",Je.style.borderTop="1px solid #555",Je.style.margin="4px 0",tt.appendChild(Je);let Qn=s.layerPatterns[Ke]??1;for(let ei of oe){let ar=Qn===ei.value?"\u25CF ":" ";jt(ar+"Fill: "+ei.label,()=>te(Ke,ei.value))}tt.style.left=_n.clientX+"px",tt.style.top=_n.clientY+"px",tt.style.display="block"}),Ye}else{let Ye=document.createElement("div");Ye.className="vis-group";let{header:ct,arrow:Ze,name:Ke}=sk();Ke.textContent=Le?"Layers":Ae.data.name||"Group";let pt=document.createElement("input");if(pt.type="checkbox",pt.className="vis-cb",pt.title="Visible",pt.checked=Ae.checked,pt.indeterminate=Ae.indeterminate,Ae.cb=pt,pt.addEventListener("change",()=>{st.check(Ae.id,pt.checked)}),ct.appendChild(pt),ht){let _i=document.createElement("input");_i.type="checkbox",_i.className="vis-sel-cb",_i.title="Selectable",_i.checked=ht.checked,_i.indeterminate=ht.indeterminate,ht.selCb=_i,_i.addEventListener("change",()=>{at.check(Ae.id,_i.checked)}),ct.appendChild(_i)}else ct.appendChild(ST());Ye.appendChild(ct);let Xn=document.createElement("div");Xn.className="vis-group-children";for(let _i of Ae.children)Xn.appendChild(qn(_i,!1));return Ye.appendChild(Xn),ok(ct,Ze,Xn,!!(Ae.data&&Ae.data.startCollapsed)),Ye}}let Yi=st.roots[0]||st.get("layers_parent"),$i=qn(Yi,!0);s.displayControlsEl.appendChild($i),Ne();let Tr=c&&Array.isArray(c.chiplets)?c.chiplets:[];if(Tr.length>1){let Xn=function(yn,Re){let nt=pt.get(yn);nt&&(st.cascadeQuiet(nt.id,Re),st.onChange())},ar=function(yn){let Re=yn.data;if(yn!==Qn){let nt=document.createElement("div");nt.className="vis-leaf",nt.style.paddingLeft=8*(Re.depth-1)+"px",nt.title=Re.path+(Re.master?` (${Re.master})`:""),nt.appendChild(CO(Re.name));let kt=document.createElement("input");kt.type="checkbox",kt.className="vis-cb",kt.checked=yn.checked,kt.indeterminate=yn.indeterminate,yn.cb=kt,kt.addEventListener("change",()=>{O.check(yn.id,kt.checked),Xn(Re.path,kt.checked)}),nt.appendChild(kt),nt.appendChild(ST()),ei.appendChild(nt)}yn.children&&yn.children.forEach(ar)},Ae=c&&c.block_name||"",Le=Ae!=="",ht={};if(Le)try{let yn=ph("or_hidden_chiplets");if(yn){let Re=JSON.parse(decodeURIComponent(yn));Re&&typeof Re=="object"&&!Array.isArray(Re)&&(ht=Re)}}catch{}let Ye=new Set(Array.isArray(ht[Ae])?ht[Ae]:[]),ct=jdn(Tr,Ye),Ze=ct.findIndex(yn=>yn.parentId===null),Ke=Ze>=0?ct[Ze].id:null;if(Ze>=0&&(ct[Ze].hasCheckbox=!0),s.visibleChiplets=new Set(Tr.filter(yn=>!Ye.has(yn.path)).map(yn=>yn.path)),O=new Rv(()=>{let yn=new Set;if(O.forEach(Re=>{Re.cb&&(Re.cb.checked=Re.checked,Re.cb.indeterminate=Re.indeterminate),Re.data&&Re.data.path&&(Re.checked||Re.indeterminate)&&yn.add(Re.data.path)}),s.visibleChiplets=yn,Le){let Re=Tr.filter(kt=>!yn.has(kt.path)).map(kt=>kt.path),nt={};try{let kt=ph("or_hidden_chiplets");if(kt){let xn=JSON.parse(decodeURIComponent(kt));xn&&typeof xn=="object"&&!Array.isArray(xn)&&(nt=xn)}}catch{}Re.length===0?delete nt[Ae]:nt[Ae]=Re,Uf("or_hidden_chiplets",encodeURIComponent(JSON.stringify(nt)))}u()}),O.buildFromNodes(ct),typeof console<"u"&&console.warn){let yn=new Set;st.forEach(nt=>{nt.data&&nt.data.chipletPath&&yn.add(nt.data.chipletPath)});let Re=new Set;O.forEach(nt=>{nt.data&&nt.data.path&&Re.add(nt.data.path)});for(let nt of Re)yn.has(nt)||console.warn(`[display-controls] chiplet "${nt}" missing from layer_hierarchy \u2014 Layers/Chiplets sync may drift`);for(let nt of yn)Re.has(nt)||console.warn(`[display-controls] layer hierarchy node "${nt}" has no matching chiplet \u2014 Layers/Chiplets sync may drift`)}let pt=new Map;st.forEach(yn=>{yn.data&&yn.data.chipletPath&&pt.set(yn.data.chipletPath,yn)});{let yn={};if(st.forEach(Re=>{if(!Re.data||!Re.data.chipletPath)return;let nt=Re.data.chipletPath;Ye.has(nt)||O.get(nt)&&(yn[nt]={checked:Re.checked,indeterminate:Re.indeterminate})}),Object.keys(yn).length>0){O.mirrorStatesQuiet(yn);let Re=new Set;O.forEach(nt=>{nt.data&&nt.data.path&&(nt.checked||nt.indeterminate)&&Re.add(nt.data.path)}),s.visibleChiplets=Re}}let _i=document.createElement("div");_i.className="vis-group";let{header:Hi,arrow:_n,name:Je}=sk();Je.textContent="Chiplets";let Qn=Ke!=null?O.get(Ke):null;if(Qn){let yn=document.createElement("input");yn.type="checkbox",yn.className="vis-cb",yn.checked=Qn.checked,yn.indeterminate=Qn.indeterminate,Qn.cb=yn,yn.addEventListener("change",Re=>{Re.stopPropagation(),O.check(Ke,yn.checked),Qn.data&&Qn.data.path&&Xn(Qn.data.path,yn.checked)}),Hi.appendChild(yn)}Hi.appendChild(ST()),_i.appendChild(Hi);let ei=document.createElement("div");ei.className="vis-group-children",O.roots.forEach(ar),_i.appendChild(ei),ok(Hi,_n,ei,!1),s.displayControlsEl.appendChild(_i)}else s.visibleChiplets=null;let wr=!!n.debug_renderers,Si=new tde(n,r,()=>{u(),!!n.debug_renderers!==wr&&(wr=!!n.debug_renderers,s.refreshRendererControls&&s.refreshRendererControls())});Si.add({label:"Nets",addSelectable:!0,children:[{key:"net_signal",label:"Signal"},{key:"net_power",label:"Power"},{key:"net_ground",label:"Ground"},{key:"net_clock",label:"Clock"},{key:"net_reset",label:"Reset"},{key:"net_tieoff",label:"Tie off"},{key:"net_scan",label:"Scan"},{key:"net_analog",label:"Analog"}]}),Si.add({label:"Instances",addSelectable:!0,children:[{label:"Std Cells",visKey:"stdcells",disabled:!s.hasLiberty,children:[{label:"Bufs/Invs",children:[{key:"std_bufinv_timing",label:"Timing opt."},{key:"std_bufinv",label:"Netlist"}]},{key:"std_combinational",label:"Combinational"},{key:"std_sequential",label:"Sequential"},{label:"Clock tree",children:[{key:"std_clock_bufinv",label:"Buffer/Inverter"},{key:"std_clock_gate",label:"Clock gate"}]},{key:"std_level_shift",label:"Level shifter"}]},{key:"macros",label:"Macros"},{label:"Pads",children:[{key:"pad_input",label:"Input"},{key:"pad_output",label:"Output"},{key:"pad_inout",label:"Inout"},{key:"pad_power",label:"Power"},{key:"pad_spacer",label:"Spacer"},{key:"pad_areaio",label:"Area IO"},{key:"pad_other",label:"Other"}]},{label:"Physical",children:[{key:"phys_fill",label:"Fill"},{key:"phys_endcap",label:"Endcap"},{key:"phys_welltap",label:"Welltap"},{key:"phys_tie",label:"Tie Hi/Lo"},{key:"phys_antenna",label:"Antenna"},{key:"phys_cover",label:"Cover"},{key:"phys_bump",label:"Bump"},{key:"phys_other",label:"Other"}]}]}),Si.add({label:"Blockages",addSelectable:!0,children:[{key:"placement_blockages",label:"Placement"},{key:"routing_obstructions",label:"Routing"}]}),c.sites&&c.sites.length>0&&Si.add({label:"Rows",visKey:"rows",addSelectable:!0,children:c.sites.map(Ae=>({key:"site_"+Ae,label:Ae}))}),Si.add({label:"Tracks",children:[{key:"tracks_pref",label:"Pref"},{key:"tracks_non_pref",label:"Non Pref"}]}),Si.add({label:"Shapes",children:[{label:"Routing",visKey:"routing",children:[{key:"routing_segments",label:"Segments"},{key:"routing_vias",label:"Vias"}]},{label:"Special Routing",visKey:"special_nets",children:[{key:"srouting_segments",label:"Segments"},{key:"srouting_vias",label:"Vias"}]},{key:"pins",label:"Pins",selectable:!0},{key:"pin_names",label:"Pin Names",disabledBy:"pins"},{key:"fills",label:"Fills"}]}),Si.add({label:"Misc",children:[{label:"Instances",children:[{key:"inst_names",label:"Names"},{key:"inst_pins",label:"Pins",selectable:!0},{key:"inst_pin_names",label:"Pin Names",disabledBy:"inst_pins"},{key:"blockages",label:"Blockages"}]},{key:"detailed",label:"Detailed view"},{key:"rulers",label:"Rulers"},{key:"labels",label:"Labels"},{key:"scale_bar",label:"Scale bar"},{key:"access_points",label:"Access Points"},{key:"regions",label:"Regions"},{key:"mfg_grid",label:"Manufacturing grid"},{key:"gcell_grid",label:"GCell grid"},{key:"flywires_only",label:"Flywires only"},{key:"focused_nets_guides",label:"Focused nets guides"},{key:"highlight_selected",label:"Highlight selected"}]}),Si.add({key:"module_view",label:"Module view"}),Si.add({label:"Debug Graphics",children:[{key:"debug_renderers",label:"Renderers"},{key:"debug_live",label:"Live (don't require pause)",disabledBy:"debug_renderers"},{key:"debug",label:"Tiles"}]}),Si.render(s.displayControlsEl);let Fr=document.createElement("div");Fr.className="renderer-controls",s.displayControlsEl.appendChild(Fr);function se(Ae){return Promise.all(Ae.map(({path:Le,value:ht})=>s.websocketManager.request({type:"set_renderer_control",path:Le,value:ht}))).catch(()=>{})}function de(Ae){Fr.innerHTML="";let Le=new Map;for(let ht of Ae||[]){let Ye=ht.group||"";Le.has(Ye)||Le.set(Ye,[]),Le.get(Ye).push(ht)}for(let[ht,Ye]of Le){let ct=Fr;if(ht){let Ze=document.createElement("div");Ze.className="vis-group";let{header:Ke,arrow:pt,name:Xn}=sk();Xn.textContent=ht;let _i=document.createElement("input");_i.type="checkbox",_i.className="vis-cb",_i.title="Visible";let Hi=Ye.filter(Je=>Je.visible).length;_i.checked=Hi===Ye.length,_i.indeterminate=Hi>0&&Hi{let Je=_i.checked;se(Ye.filter(Qn=>!!Qn.visible!==Je).map(Qn=>({path:Qn.path,value:Je})))}),Ke.appendChild(_i),Ke.appendChild(ST()),Ze.appendChild(Ke);let _n=document.createElement("div");_n.className="vis-group-children",Ze.appendChild(_n),ok(Ke,pt,_n,!1),Fr.appendChild(Ze),ct=_n}for(let Ze of Ye){let Ke=document.createElement("div");Ke.className="vis-leaf";let pt=document.createElement("span");pt.className="vis-arrow",pt.style.visibility="hidden",pt.textContent="\u25B6",Ke.appendChild(pt),Ke.appendChild(CO(Ze.name));let Xn=document.createElement("input");Xn.type="checkbox",Xn.className="vis-cb",Xn.title="Visible",Xn.checked=!!Ze.visible,Xn.addEventListener("change",()=>se([{path:Ze.path,value:Xn.checked}])),Ke.appendChild(Xn),Ke.appendChild(ST()),ct.appendChild(Ke)}}}s.refreshRendererControls=function(){return!s.websocketManager||ua(s)||!n.debug_renderers?(Fr.innerHTML="",Promise.resolve()):s.websocketManager.request({type:"renderer_controls"}).then(Ae=>de(Ae.controls)).catch(()=>{})},s.refreshRendererControls();let it=document.createElement("div");it.className="bg-color-row";let We=document.createElement("span");We.textContent="Background";let En=document.createElement("input");En.type="color",En.className="bg-color-input",En.title="Layout background color";let hr=ph("or_bg_color");En.value=SO(hr)?hr:q5e(),En.addEventListener("input",()=>{document.documentElement.style.setProperty("--bg-map",En.value)}),En.addEventListener("change",()=>{n3t(En.value,s)});let qi=document.createElement("button");qi.className="bg-color-reset",qi.textContent="Reset",qi.title="Reset background to the theme default",qi.addEventListener("click",()=>{i3t(s),En.value=q5e()}),it.appendChild(We),it.appendChild(En),it.appendChild(qi),!s.heatMapLayer&&d&&(s.heatMapLayer=d());let Me=document.createElement("div");Me.className="vis-group heatmap-controls",s.displayControlsEl.appendChild(Me);let{header:ve,arrow:wt,name:gn}=sk("vis-group-header heatmap-header");gn.textContent="Heat Maps",Me.appendChild(ve);let vn=document.createElement("div");vn.className="vis-group-children heatmap-group-children",Me.appendChild(vn),ok(ve,wt,vn,!0),s.displayControlsEl.appendChild(it);function Mn(Ae,Le,ht,Ye){let ct=document.createElement("label");ct.className="heatmap-setting";let Ze=document.createElement("input");Ze.type="checkbox",Ze.checked=ht,Ze.addEventListener("change",()=>Ye(Ze.checked)),ct.appendChild(Ze),ct.appendChild(document.createTextNode(Le)),Ae.appendChild(ct)}function xi(Ae,Le,ht,Ye,ct){let Ze=document.createElement("label");Ze.className="heatmap-setting";let Ke=document.createElement("span");Ke.textContent=Le;let pt=document.createElement("input");pt.type="number",pt.value=String(ht),pt.step=String(Ye||1),pt.addEventListener("change",()=>ct(parseFloat(pt.value))),Ze.appendChild(Ke),Ze.appendChild(pt),Ae.appendChild(Ze)}function mi(Ae,Le,ht,Ye,ct){let Ze=document.createElement("label");Ze.className="heatmap-setting";let Ke=document.createElement("span");Ke.textContent=Le;let pt=document.createElement("select");for(let Xn of Ye){let _i=document.createElement("option");_i.value=Xn,_i.textContent=Xn,Xn===ht&&(_i.selected=!0),pt.appendChild(_i)}pt.addEventListener("change",()=>ct(pt.value)),Ze.appendChild(Ke),Ze.appendChild(pt),Ae.appendChild(Ze)}function ri(Ae){s.websocketManager.request(Ae).then(Le=>{s.updateHeatMaps&&s.updateHeatMaps(Le)}).catch(Le=>console.error("Heat map update failed",Le))}function Ge(Ae){if(!s.heatMapLegendEl)return;let Le=s.heatMapLegendEl;if(Le.innerHTML="",!Ae||!Ae.show_legend||!Ae.legend||Ae.legend.length===0){Le.classList.add("hidden");return}let ht=document.createElement("div");ht.className="heatmap-map-legend-title",ht.textContent=Ae.title,Le.appendChild(ht);let Ye=document.createElement("div");Ye.className="heatmap-map-legend-units",Ye.textContent=Ae.units||"",Le.appendChild(Ye);let ct=document.createElement("div");ct.className="heatmap-map-legend-list";for(let Ze of Ae.legend){let Ke=document.createElement("div");Ke.className="heatmap-legend-row";let pt=document.createElement("span");pt.className="heatmap-legend-swatch",pt.style.backgroundColor=`rgba(${Ze.color[0]}, ${Ze.color[1]}, ${Ze.color[2]}, ${Ze.color[3]/255})`;let Xn=document.createElement("span");Xn.textContent=Ze.value,Ke.appendChild(pt),Ke.appendChild(Xn),ct.appendChild(Ke)}Le.appendChild(ct),Le.classList.remove("hidden")}s.renderHeatMapControls=Ae=>{vn.innerHTML="";let Le=document.createElement("div");Le.className="heatmap-list",vn.appendChild(Le);let ht=document.createElement("label");ht.className="heatmap-setting";let Ye=document.createElement("input");Ye.type="radio",Ye.name="active-heatmap",Ye.checked=!Ae.active,Ye.addEventListener("change",()=>{ri({type:"set_active_heatmap",name:""})}),ht.appendChild(Ye),ht.appendChild(document.createTextNode("Off")),Le.appendChild(ht);for(let pt of Ae.heatmaps||[]){let Xn=document.createElement("label");Xn.className="heatmap-setting";let _i=document.createElement("input");_i.type="radio",_i.name="active-heatmap",_i.checked=pt.name===Ae.active,_i.addEventListener("change",()=>{ri({type:"set_active_heatmap",name:pt.name})}),Xn.appendChild(_i),Xn.appendChild(document.createTextNode(pt.title)),Le.appendChild(Xn)}let ct=(Ae.heatmaps||[]).find(pt=>pt.name===Ae.active);if(Ge(ct),!ct)return;let Ze=document.createElement("div");Ze.className="heatmap-settings",vn.appendChild(Ze),xi(Ze,"Display min",ct.display_min,ct.display_range_increment,pt=>{ri({type:"set_heatmap",name:ct.name,option:"DisplayMin",value:pt})}),xi(Ze,"Display max",ct.display_max,ct.display_range_increment,pt=>{ri({type:"set_heatmap",name:ct.name,option:"DisplayMax",value:pt})}),Mn(Ze,"Show below min",ct.draw_below_min,pt=>{ri({type:"set_heatmap",name:ct.name,option:"ShowMin",value:pt})}),Mn(Ze,"Show above max",ct.draw_above_max,pt=>{ri({type:"set_heatmap",name:ct.name,option:"ShowMax",value:pt})}),Mn(Ze,"Log scale",ct.log_scale,pt=>{ri({type:"set_heatmap",name:ct.name,option:"LogScale",value:pt})}),Mn(Ze,"Reverse log",ct.reverse_log,pt=>{ri({type:"set_heatmap",name:ct.name,option:"ReverseLog",value:pt})}),ct.can_adjust_grid&&(xi(Ze,"Grid X",ct.grid_x,.1,pt=>{ri({type:"set_heatmap",name:ct.name,option:"GridX",value:pt})}),xi(Ze,"Grid Y",ct.grid_y,.1,pt=>{ri({type:"set_heatmap",name:ct.name,option:"GridY",value:pt})})),xi(Ze,"Alpha",ct.alpha,1,pt=>{ri({type:"set_heatmap",name:ct.name,option:"Alpha",value:pt})}),Mn(Ze,"Legend",ct.show_legend,pt=>{ri({type:"set_heatmap",name:ct.name,option:"ShowLegend",value:pt})}),ct.supports_numbers&&Mn(Ze,"Show numbers",ct.show_numbers,pt=>{ri({type:"set_heatmap",name:ct.name,option:"ShowNumbers",value:pt})});for(let pt of ct.options||[])pt.type==="bool"?Mn(Ze,pt.label,pt.value,Xn=>{ri({type:"set_heatmap",name:ct.name,option:pt.name,value:Xn})}):pt.type==="choice"&&mi(Ze,pt.label,pt.value,pt.choices||[],Xn=>{ri({type:"set_heatmap",name:ct.name,option:pt.name,value:Xn})});ct.selection_filter_label&&Mn(Ze,ct.selection_filter_label,ct.use_selected_only,pt=>{ri({type:"set_heatmap",name:ct.name,option:"use_selected_only",value:pt})});let Ke=document.createElement("button");Ke.className="or-btn or-btn-sm heatmap-rebuild",Ke.textContent="Rebuild data",Ke.addEventListener("click",()=>{ri({type:"set_heatmap",name:ct.name,option:"rebuild",value:1})}),Ze.appendChild(Ke)}}var _3t="search-nav-dialog",Wdn=[{label:"Instance",value:"inst"},{label:"Net",value:"net"},{label:"Port",value:"port"}];function ide(s){if(!s.designScale)return;let n=Wdn.map(T=>``).join(""),{overlay:r,close:c,okBtn:u,showError:d}=MO("Find Object",` + affected.`,"Apply",m3t),_=u.querySelector(".opt-family"),x=u.querySelector(".opt-custom"),T=u.querySelector(".opt-scale"),M=u.querySelector(".opt-preview");function L(){M.style.fontFamily=x.value.trim()||_.value,M.style.fontSize=`calc(13px * ${rH(T.value)/100})`}for(let D of[_,x,T])D.addEventListener("input",L);L();function I(){let D=T.value.trim(),F=Number(D);if(D===""||!Number.isFinite(F)){w("Size must be a number.");return}if(Fede){w(`Size must be between ${Qhe} and ${ede} %.`);return}s.setAppFont({family:x.value.trim()||_.value,scale:F}),d()}b.addEventListener("click",I);for(let D of[x,T])D.addEventListener("keydown",F=>{F.key==="Enter"&&(F.preventDefault(),I())});return{close:d}}function Q5e(s){return String(s).replace(/&/g,"&").replace(/"/g,""").replace(//g,">")}var $dn='',Vdn='';function CO(s){let n=document.createElement("span");return n.className="vis-name",s!=null&&(n.textContent=s),n}function ST(){let s=document.createElement("span");return s.className="vis-sel-cb vis-sel-spacer",s}function v3t(){let s=document.createElement("div");s.className="display-controls-header",s.appendChild(CO(""));for(let[n,r]of[[$dn,"Visible"],[Vdn,"Selectable"]]){let c=document.createElement("span");c.className="vis-header-icon",c.title=r,c.innerHTML=n,s.appendChild(c)}return s}var tde=class{constructor(n,r,c){this.visibility=n,this.selectability=r,this.onChange=c;let u=()=>{this._syncAll(),this.onChange()};this.model=new Rv(u),this.selModel=new Rv(u)}add(n){return this.model.addFromSpec(this._enrichSpec(n,"")),this.selModel.addFromSpec(this._enrichSelSpec(n,"",!1)),this}render(n){for(let r of this.model.roots)n.appendChild(this._dom(r));this._syncAll()}_nodeId(n,r){let c=n.key||n.label;return r?r+"/"+c:c}_enrichSpec(n,r){let c=this._nodeId(n,r),u={id:c,data:n};return n.children?u.children=n.children.map(d=>this._enrichSpec(d,c)):n.key&&(u.checked=!!this.visibility[n.key]),n.disabled!=null&&(u.disabled=n.disabled),u}_enrichSelSpec(n,r,c){let u=n.addSelectable===!0?!0:n.addSelectable===!1?!1:c,d=this._nodeId(n,r),b={id:d,data:n,hasCheckbox:!1};if(n.children){b.children=n.children.map(_=>this._enrichSelSpec(_,d,u));let w=_=>_.some(x=>x.hasCheckbox||x.children&&w(x.children));b.hasCheckbox=w(b.children),b.hasCheckbox&&(b.checked=!0)}else if(n.key){let w=n.selectable===!0||n.selectable!==!1&&c;b.hasCheckbox=w,w&&(b.checked=this.selectability[n.key]!==!1)}return b}_syncAll(){this.model.forEach(n=>{n.cb&&(n.cb.checked=n.checked,n.cb.indeterminate=n.indeterminate);let r=n.data;r.key&&(this.visibility[r.key]=n.checked),r.visKey&&(this.visibility[r.visKey]=n.checked||n.indeterminate)}),this.selModel.forEach(n=>{if(!n.hasCheckbox)return;let r=n.data;if(r.key&&(this.selectability[r.key]=n.checked),!n.selCb)return;n.selCb.checked=n.checked,n.selCb.indeterminate=n.indeterminate;let c=this.model.get(n.id),u=c&&!c.checked&&!c.indeterminate;n.selCb.disabled=u,n.selLabel&&n.selLabel.classList.toggle("vis-sel-disabled",u)}),this.model.forEach(n=>{let r=n.data;if(r.disabledBy&&n.el){let c=!this.visibility[r.disabledBy];n.el.classList.toggle("disabled",c)}})}_buildSelCheckbox(n){let r=this.selModel.get(n.id);if(!r||!r.hasCheckbox)return null;let c=document.createElement("input");return c.type="checkbox",c.className="vis-sel-cb",c.title="Selectable",c.addEventListener("change",()=>{this.selModel.check(r.id,c.checked)}),r.selCb=c,c}_dom(n){let r=n.data,c=document.createElement("input");c.type="checkbox",c.className="vis-cb",c.title="Visible",n.cb=c,c.addEventListener("change",()=>this.model.check(n.id,c.checked));let u=this._buildSelCheckbox(n),d=M=>{if(M.appendChild(c),u){M.appendChild(u);let L=this.selModel.get(n.id);L&&(L.selLabel=M)}else M.appendChild(ST())};if(!n.children.length){let M=document.createElement("div");M.className="vis-leaf";let L=document.createElement("span");return L.className="vis-arrow",L.style.visibility="hidden",L.textContent="\u25B6",M.appendChild(L),M.appendChild(CO(r.label)),d(M),n.el=M,M}let b=document.createElement("div");b.className="vis-group";let{header:w,arrow:_,name:x}=sk();x.textContent=r.label,d(w),b.appendChild(w);let T=document.createElement("div");T.className="vis-group-children",r.disabled&&T.classList.add("disabled");for(let M of n.children)T.appendChild(this._dom(M));return b.appendChild(T),ok(w,_,T,!0),b}};function sH(s,n,r,c){let u=new Set,d=Math.max(0,s-n),b=Math.min(c-1,s+r);for(let w=d;w<=b;w++)u.add(w);return u}function Wdn(s){let n={};for(let[r,c]of Object.entries(s||{}))c!==1&&(n[r]=c);return n}function nde(s,n){return(s||[]).some(r=>r.every(c=>!!n[c]))}function Hdn(s,n){return s.map(r=>{let c=!n.has(r.path);return{id:r.path,parentId:r.parent!=null?r.parent:null,hasCheckbox:r.parent!=null,checked:c,data:{path:r.path,name:r.name,master:r.master,depth:r.depth}}})}var qdn=3,_3t=[[70,130,210],[200,50,50],[50,180,80],[200,160,40],[160,60,200],[40,190,190],[220,120,50],[180,70,150]];function Xdn(s){return!s.forceComposite||ua(s)?0:s.groupLayers||Txt}function y3t(s,n,r,c,u,d){if(!s.displayControlsEl)return;s.displayControlsEl.innerHTML="",s.displayControlsEl.appendChild(v3t());for(let Ae of s.allLayers||[])Ae.remove();s.allLayers=[],s.baseSlot=null,s.topSlot=null;let b=new Set;function w(){for(let Ae of b)Ae.refresh();b.clear()}function _(){s.baseSlot&&b.add(s.baseSlot)}function x(Ae){return{layer:Ae,opacity:1,visible:!1}}function T(Ae,Le){wxt(Ae,Le)&&_()}function M(Ae,Le,ht){let Ye={layer:Ae,opacity:1,visible:!!ht};return Le&&(s[Le]=Ye),Ye}let L=[M("_instances",null,!0),M("_pins","pinsLayer",n.pins),M("_modules","modulesLayer",n.module_view)],I=[];s.overlayLayers=(c&&c.overlays||[]).map(Ae=>({def:Ae,layer:M(Ae.name,null,nde(Ae.shown_by,n)),under:Ae.z_indexht.def.z_index-Ye.def.z_index))(Le?L:I).push(Ae);let D=[],F=[],O=null,z=new Set,Z=new Set;try{let Ae=window.sessionStorage.getItem("or_hidden_layers");Ae&&(z=new Set(JSON.parse(Ae)))}catch{}try{let Ae=window.sessionStorage.getItem("or_nonselectable_layers");Ae&&(Z=new Set(JSON.parse(Ae)))}catch{}try{let Ae=window.sessionStorage.getItem("or_layer_patterns");Ae&&Object.assign(s.layerPatterns,JSON.parse(Ae))}catch{}function H(){try{window.sessionStorage.setItem("or_layer_patterns",JSON.stringify(Wdn(s.layerPatterns)))}catch{}}function te(Ae,Le){Le===1?delete s.layerPatterns[Ae]:s.layerPatterns[Ae]=Le,H(),_(),w()}let oe=[{label:"Solid",value:1},{label:"Diagonal",value:2},{label:"Cross",value:3},{label:"Dots",value:4},{label:"None (no fill)",value:0}],ne=0;function ue(Ae,Le="layers",ht=void 0){let Ye=[],ct=Ae.type==="category"?ht:Ae.path,Ze=Ae.flipped===!0,Ke=Ae.instances||[],pt=Ke.filter(ei=>ei.type!=="category"),Xn=Ke.filter(ei=>ei.type==="category"),_i=Ae.layers||[],Hi=ne;ne+=_i.length;function _n(ei,ar){let yn=ei.map((Re,nt)=>nt);ar&&yn.reverse(),yn.forEach(Re=>{let nt=ei[Re],kt=Le+"/"+(nt.name||Re);Ye.push(ue(nt,kt,ct))})}function Je(){(Ze?_i.map((ar,yn)=>yn).reverse():_i.map((ar,yn)=>yn)).forEach(ar=>{let yn=_i[ar],Re=yn.name||yn,nt=Hi+ar,kt=x(Re),xn=`${Le}/${Re}`,Ei=!z.has(xn);Ei&&(T(kt,!0),s.visibleLayers.add(xn),s.visibleLayerNames.add(Re)),D.push(kt),F.push(xn),Ye.push({id:xn,data:{name:Re,layer:kt,color:yn.color,colorIndex:nt,nodeId:xn,ownerChipletPath:ct},checked:Ei})})}_n(pt,!1),Ze&&Je(),_n(Xn,Ze),Ze||Je();let Qn={name:Ae.name,isInstance:!0};return Ae.type==="category"&&(Ae.name==="Implant"||Ae.name==="Other")&&(Qn.startCollapsed=!0),Ae.type!=="category"&&(Qn.chipletPath=Ae.path),{id:Le,data:Qn,children:Ye}}let Te;c.layer_hierarchy?Te=ue(c.layer_hierarchy,"layers_parent"):Te={id:"layers_parent",children:c.layers.map((Ae,Le)=>{let ht=x(Ae),Ye=`layers_parent/${Ae}`,ct=!z.has(Ye);return ct&&(T(ht,!0),s.visibleLayers.add(Ye),s.visibleLayerNames.add(Ae)),D.push(ht),F.push(Ye),{id:Ye,data:{name:Ae,layer:ht,colorIndex:Le,nodeId:Ye},checked:ct}})};function Q(Ae,Le,ht){let Ye=s.view.addTileSlot(Ae,{order:Le,source:Cxt({wm:s.websocketManager,ctx:s.tileCtx,getItems:()=>ht,dpr:xO,tileSize:Nb,isDoubleBuffer:()=>s.doubleBuffer,groupLayers:()=>Xdn(s)})});return Ye.items=ht,Ye}s.baseSlot=Q("base",bp.base,[...L,...D]),s.topSlot=Q("top",bp.top,I),s.allLayers=[s.baseSlot,s.topSlot];function ge(Ae){if(!Ae.children||Ae.children.length===0){let Le=Ae.data&&Ae.data.name,ht=Le?!Z.has(Le):!0;return ht&&Le&&s.selectableLayers.add(Le),{id:Ae.id,data:{name:Le},checked:ht}}return{id:Ae.id,data:{name:Ae.data&&Ae.data.name},children:Ae.children.map(ge)}}let Qe=ge(Te),st=new Rv(()=>{s.visibleLayerNames.clear();let Ae=[],Le={},ht=!1,Ye=!1,ct=O&&s.visibleChiplets instanceof Set;if(st.forEach(Ke=>{if(Ke.cb&&(Ke.cb.checked=Ke.checked,Ke.cb.indeterminate=Ke.indeterminate),Ke.data&&Ke.data.layer){let pt=Ke.data.nodeId||Ke.data.name;Ae.push(pt),T(Ke.data.layer,Ke.checked),Ke.checked?(s.visibleLayers.add(pt),s.visibleLayerNames.add(Ke.data.name)):s.visibleLayers.delete(pt)}if(ct&&Ke.data&&Ke.data.chipletPath){let pt=Ke.data.chipletPath,Xn=O.get(pt);if(Xn){let _i=Ke.checked||Ke.indeterminate,Hi={checked:Ke.checked,indeterminate:Ke.indeterminate};(Xn.checked!==Ke.checked||Xn.indeterminate!==Ke.indeterminate)&&(Le[pt]=Hi,ht=!0),s.visibleChiplets.has(pt)!==_i&&(Ye=!0)}}}),s.baseSlot&&b.has(s.baseSlot))for(let{def:Ke,under:pt}of s.overlayLayers)nde(Ke.layers_by,n)&&b.add(pt?s.baseSlot:s.topSlot);w(),Ne();let Ze=Ae.filter(Ke=>!s.visibleLayers.has(Ke));try{window.sessionStorage.setItem("or_hidden_layers",JSON.stringify(Ze))}catch{}s.syncDisplayState(),Ye?O.mirrorStates(Le):ht&&(O.mirrorStatesQuiet(Le),O.forEach(Ke=>{Ke.cb&&(Ke.cb.checked=Ke.checked,Ke.cb.indeterminate=Ke.indeterminate)}))});s.layerModel=st,st.addFromSpec(Te);let at=new Rv(()=>{s.selectableLayers.clear(),at.forEach(Le=>{Le.checked&&Le.data&&Le.data.name&&s.selectableLayers.add(Le.data.name)}),Ne();let Ae=c.layers.filter(Le=>!s.selectableLayers.has(Le));try{window.sessionStorage.setItem("or_nonselectable_layers",JSON.stringify(Ae))}catch{}s.syncDisplayState()});at.addFromSpec(Qe);function Ne(){at.forEach(Ae=>{if(!Ae.selCb)return;Ae.selCb.checked=Ae.checked,Ae.selCb.indeterminate=Ae.indeterminate;let Le=st.get(Ae.id),ht=Le&&!Le.checked&&!Le.indeterminate;Ae.selCb.disabled=ht})}let tt=document.createElement("div");tt.className="context-menu",tt.style.display="none",document.body.appendChild(tt);function ot(Ae){let Le={};F.forEach((ht,Ye)=>{ht&&(Le[ht]=Ae.has(Ye))}),st.checkSet(Le)}function Tt(){tt.style.display="none"}function jt(Ae,Le){let ht=document.createElement("div");ht.className="context-menu-item",ht.textContent=Ae,ht.addEventListener("click",()=>{Le(),Tt()}),tt.appendChild(ht)}let en=D.length,mn=[{label:"Show only this layer",fn:Ae=>sH(Ae,0,0,en)},{label:"Show layer range \u2195",fn:Ae=>sH(Ae,1,1,en)},{label:"Show layer range \u2195\u2195",fn:Ae=>sH(Ae,2,2,en)},{label:"Show layer range \u2193",fn:Ae=>sH(Ae,1,0,en)},{label:"Show layer range \u2191",fn:Ae=>sH(Ae,0,1,en)}];document.addEventListener("click",Ae=>{tt.contains(Ae.target)||Tt()}),document.addEventListener("keydown",Ae=>{Ae.key==="Escape"&&Tt()});let cn=!ua(s),bi=null;function Vt(){bi&&(bi.classList.remove("vis-row-selected"),bi=null)}cn&&Uxt(s,Vt);function pn(Ae,Le,ht){let Ye=Pm(s);bi=Ae,Ae.classList.add("vis-row-selected");let ct={type:"select_layer",layer:Le,use_dbu:s.showDbu};ht&&(ct.chiplet=ht),s.websocketManager.request(ct).then(Ze=>{Y1(s,Ye)&&(s.updateInspector&&s.updateInspector(Ze),s.focusComponent&&s.focusComponent("Inspector"),s.refreshOverlay&&s.refreshOverlay())}).catch(Ze=>{console.error("select_layer failed:",Ze),Y1(s,Ye)&&Vt()})}function qn(Ae,Le=!1){let ht=at.get(Ae.id);if(!Ae.children||Ae.children.length===0){let Ye=document.createElement("div");Ye.className=cn?"vis-leaf vis-leaf-selectable":"vis-leaf";let ct=document.createElement("span");ct.className="vis-arrow",ct.style.visibility="hidden",ct.textContent="\u25B6",Ye.appendChild(ct);let Ze=Ae.data.colorIndex,Ke=Ae.data.name,pt=CO(),Xn=document.createElement("span");Xn.className="layer-color";let _i=Ae.data.color||c.layer_colors&&c.layer_colors[Ze]||_3t[Ze%_3t.length];Xn.style.backgroundColor=`rgb(${_i[0]},${_i[1]},${_i[2]})`,pt.appendChild(Xn),pt.appendChild(document.createTextNode(Ke)),Ye.appendChild(pt),cn&&pt.addEventListener("click",()=>{pn(Ye,Ke,Ae.data.ownerChipletPath)});let Hi=document.createElement("input");if(Hi.type="checkbox",Hi.className="vis-cb",Hi.title="Visible",Hi.checked=Ae.checked,Ae.cb=Hi,Hi.addEventListener("change",()=>{st.check(Ae.id,Hi.checked)}),Ye.appendChild(Hi),ht){let _n=document.createElement("input");_n.type="checkbox",_n.className="vis-sel-cb",_n.title="Selectable",_n.checked=ht.checked,ht.selCb=_n,_n.addEventListener("change",()=>{at.check(Ae.id,_n.checked)}),Ye.appendChild(_n)}else Ye.appendChild(ST());return Ye.addEventListener("contextmenu",_n=>{_n.preventDefault(),_n.stopPropagation(),tt.innerHTML="";for(let ei of mn)jt(ei.label,()=>ot(ei.fn(Ze)));let Je=document.createElement("div");Je.className="context-menu-separator",Je.style.borderTop="1px solid #555",Je.style.margin="4px 0",tt.appendChild(Je);let Qn=s.layerPatterns[Ke]??1;for(let ei of oe){let ar=Qn===ei.value?"\u25CF ":" ";jt(ar+"Fill: "+ei.label,()=>te(Ke,ei.value))}tt.style.left=_n.clientX+"px",tt.style.top=_n.clientY+"px",tt.style.display="block"}),Ye}else{let Ye=document.createElement("div");Ye.className="vis-group";let{header:ct,arrow:Ze,name:Ke}=sk();Ke.textContent=Le?"Layers":Ae.data.name||"Group";let pt=document.createElement("input");if(pt.type="checkbox",pt.className="vis-cb",pt.title="Visible",pt.checked=Ae.checked,pt.indeterminate=Ae.indeterminate,Ae.cb=pt,pt.addEventListener("change",()=>{st.check(Ae.id,pt.checked)}),ct.appendChild(pt),ht){let _i=document.createElement("input");_i.type="checkbox",_i.className="vis-sel-cb",_i.title="Selectable",_i.checked=ht.checked,_i.indeterminate=ht.indeterminate,ht.selCb=_i,_i.addEventListener("change",()=>{at.check(Ae.id,_i.checked)}),ct.appendChild(_i)}else ct.appendChild(ST());Ye.appendChild(ct);let Xn=document.createElement("div");Xn.className="vis-group-children";for(let _i of Ae.children)Xn.appendChild(qn(_i,!1));return Ye.appendChild(Xn),ok(ct,Ze,Xn,!!(Ae.data&&Ae.data.startCollapsed)),Ye}}let Yi=st.roots[0]||st.get("layers_parent"),$i=qn(Yi,!0);s.displayControlsEl.appendChild($i),Ne();let Tr=c&&Array.isArray(c.chiplets)?c.chiplets:[];if(Tr.length>1){let Xn=function(yn,Re){let nt=pt.get(yn);nt&&(st.cascadeQuiet(nt.id,Re),st.onChange())},ar=function(yn){let Re=yn.data;if(yn!==Qn){let nt=document.createElement("div");nt.className="vis-leaf",nt.style.paddingLeft=8*(Re.depth-1)+"px",nt.title=Re.path+(Re.master?` (${Re.master})`:""),nt.appendChild(CO(Re.name));let kt=document.createElement("input");kt.type="checkbox",kt.className="vis-cb",kt.checked=yn.checked,kt.indeterminate=yn.indeterminate,yn.cb=kt,kt.addEventListener("change",()=>{O.check(yn.id,kt.checked),Xn(Re.path,kt.checked)}),nt.appendChild(kt),nt.appendChild(ST()),ei.appendChild(nt)}yn.children&&yn.children.forEach(ar)},Ae=c&&c.block_name||"",Le=Ae!=="",ht={};if(Le)try{let yn=zf("or_hidden_chiplets");if(yn){let Re=JSON.parse(decodeURIComponent(yn));Re&&typeof Re=="object"&&!Array.isArray(Re)&&(ht=Re)}}catch{}let Ye=new Set(Array.isArray(ht[Ae])?ht[Ae]:[]),ct=Hdn(Tr,Ye),Ze=ct.findIndex(yn=>yn.parentId===null),Ke=Ze>=0?ct[Ze].id:null;if(Ze>=0&&(ct[Ze].hasCheckbox=!0),s.visibleChiplets=new Set(Tr.filter(yn=>!Ye.has(yn.path)).map(yn=>yn.path)),O=new Rv(()=>{let yn=new Set;if(O.forEach(Re=>{Re.cb&&(Re.cb.checked=Re.checked,Re.cb.indeterminate=Re.indeterminate),Re.data&&Re.data.path&&(Re.checked||Re.indeterminate)&&yn.add(Re.data.path)}),s.visibleChiplets=yn,Le){let Re=Tr.filter(kt=>!yn.has(kt.path)).map(kt=>kt.path),nt={};try{let kt=zf("or_hidden_chiplets");if(kt){let xn=JSON.parse(decodeURIComponent(kt));xn&&typeof xn=="object"&&!Array.isArray(xn)&&(nt=xn)}}catch{}Re.length===0?delete nt[Ae]:nt[Ae]=Re,gf("or_hidden_chiplets",encodeURIComponent(JSON.stringify(nt)))}u()}),O.buildFromNodes(ct),typeof console<"u"&&console.warn){let yn=new Set;st.forEach(nt=>{nt.data&&nt.data.chipletPath&&yn.add(nt.data.chipletPath)});let Re=new Set;O.forEach(nt=>{nt.data&&nt.data.path&&Re.add(nt.data.path)});for(let nt of Re)yn.has(nt)||console.warn(`[display-controls] chiplet "${nt}" missing from layer_hierarchy \u2014 Layers/Chiplets sync may drift`);for(let nt of yn)Re.has(nt)||console.warn(`[display-controls] layer hierarchy node "${nt}" has no matching chiplet \u2014 Layers/Chiplets sync may drift`)}let pt=new Map;st.forEach(yn=>{yn.data&&yn.data.chipletPath&&pt.set(yn.data.chipletPath,yn)});{let yn={};if(st.forEach(Re=>{if(!Re.data||!Re.data.chipletPath)return;let nt=Re.data.chipletPath;Ye.has(nt)||O.get(nt)&&(yn[nt]={checked:Re.checked,indeterminate:Re.indeterminate})}),Object.keys(yn).length>0){O.mirrorStatesQuiet(yn);let Re=new Set;O.forEach(nt=>{nt.data&&nt.data.path&&(nt.checked||nt.indeterminate)&&Re.add(nt.data.path)}),s.visibleChiplets=Re}}let _i=document.createElement("div");_i.className="vis-group";let{header:Hi,arrow:_n,name:Je}=sk();Je.textContent="Chiplets";let Qn=Ke!=null?O.get(Ke):null;if(Qn){let yn=document.createElement("input");yn.type="checkbox",yn.className="vis-cb",yn.checked=Qn.checked,yn.indeterminate=Qn.indeterminate,Qn.cb=yn,yn.addEventListener("change",Re=>{Re.stopPropagation(),O.check(Ke,yn.checked),Qn.data&&Qn.data.path&&Xn(Qn.data.path,yn.checked)}),Hi.appendChild(yn)}Hi.appendChild(ST()),_i.appendChild(Hi);let ei=document.createElement("div");ei.className="vis-group-children",O.roots.forEach(ar),_i.appendChild(ei),ok(Hi,_n,ei,!1),s.displayControlsEl.appendChild(_i)}else s.visibleChiplets=null;let wr=!!n.debug_renderers,Si=new tde(n,r,()=>{u(),!!n.debug_renderers!==wr&&(wr=!!n.debug_renderers,s.refreshRendererControls&&s.refreshRendererControls())});Si.add({label:"Nets",addSelectable:!0,children:[{key:"net_signal",label:"Signal"},{key:"net_power",label:"Power"},{key:"net_ground",label:"Ground"},{key:"net_clock",label:"Clock"},{key:"net_reset",label:"Reset"},{key:"net_tieoff",label:"Tie off"},{key:"net_scan",label:"Scan"},{key:"net_analog",label:"Analog"}]}),Si.add({label:"Instances",addSelectable:!0,children:[{label:"Std Cells",visKey:"stdcells",disabled:!s.hasLiberty,children:[{label:"Bufs/Invs",children:[{key:"std_bufinv_timing",label:"Timing opt."},{key:"std_bufinv",label:"Netlist"}]},{key:"std_combinational",label:"Combinational"},{key:"std_sequential",label:"Sequential"},{label:"Clock tree",children:[{key:"std_clock_bufinv",label:"Buffer/Inverter"},{key:"std_clock_gate",label:"Clock gate"}]},{key:"std_level_shift",label:"Level shifter"}]},{key:"macros",label:"Macros"},{label:"Pads",children:[{key:"pad_input",label:"Input"},{key:"pad_output",label:"Output"},{key:"pad_inout",label:"Inout"},{key:"pad_power",label:"Power"},{key:"pad_spacer",label:"Spacer"},{key:"pad_areaio",label:"Area IO"},{key:"pad_other",label:"Other"}]},{label:"Physical",children:[{key:"phys_fill",label:"Fill"},{key:"phys_endcap",label:"Endcap"},{key:"phys_welltap",label:"Welltap"},{key:"phys_tie",label:"Tie Hi/Lo"},{key:"phys_antenna",label:"Antenna"},{key:"phys_cover",label:"Cover"},{key:"phys_bump",label:"Bump"},{key:"phys_other",label:"Other"}]}]}),Si.add({label:"Blockages",addSelectable:!0,children:[{key:"placement_blockages",label:"Placement"},{key:"routing_obstructions",label:"Routing"}]}),c.sites&&c.sites.length>0&&Si.add({label:"Rows",visKey:"rows",addSelectable:!0,children:c.sites.map(Ae=>({key:"site_"+Ae,label:Ae}))}),Si.add({label:"Tracks",children:[{key:"tracks_pref",label:"Pref"},{key:"tracks_non_pref",label:"Non Pref"}]}),Si.add({label:"Shapes",children:[{label:"Routing",visKey:"routing",children:[{key:"routing_segments",label:"Segments"},{key:"routing_vias",label:"Vias"}]},{label:"Special Routing",visKey:"special_nets",children:[{key:"srouting_segments",label:"Segments"},{key:"srouting_vias",label:"Vias"}]},{key:"pins",label:"Pins",selectable:!0},{key:"pin_names",label:"Pin Names",disabledBy:"pins"},{key:"fills",label:"Fills"}]}),Si.add({label:"Misc",children:[{label:"Instances",children:[{key:"inst_names",label:"Names"},{key:"inst_pins",label:"Pins",selectable:!0},{key:"inst_pin_names",label:"Pin Names",disabledBy:"inst_pins"},{key:"blockages",label:"Blockages"}]},{key:"detailed",label:"Detailed view"},{key:"rulers",label:"Rulers"},{key:"labels",label:"Labels"},{key:"scale_bar",label:"Scale bar"},{key:"access_points",label:"Access Points"},{key:"regions",label:"Regions"},{key:"mfg_grid",label:"Manufacturing grid"},{key:"gcell_grid",label:"GCell grid"},{key:"flywires_only",label:"Flywires only"},{key:"focused_nets_guides",label:"Focused nets guides"},{key:"highlight_selected",label:"Highlight selected"}]}),Si.add({key:"module_view",label:"Module view"}),Si.add({label:"Debug Graphics",children:[{key:"debug_renderers",label:"Renderers"},{key:"debug_live",label:"Live (don't require pause)",disabledBy:"debug_renderers"},{key:"debug",label:"Tiles"}]}),Si.render(s.displayControlsEl);let Fr=document.createElement("div");Fr.className="renderer-controls",s.displayControlsEl.appendChild(Fr);function se(Ae){return Promise.all(Ae.map(({path:Le,value:ht})=>s.websocketManager.request({type:"set_renderer_control",path:Le,value:ht}))).catch(()=>{})}function de(Ae){Fr.innerHTML="";let Le=new Map;for(let ht of Ae||[]){let Ye=ht.group||"";Le.has(Ye)||Le.set(Ye,[]),Le.get(Ye).push(ht)}for(let[ht,Ye]of Le){let ct=Fr;if(ht){let Ze=document.createElement("div");Ze.className="vis-group";let{header:Ke,arrow:pt,name:Xn}=sk();Xn.textContent=ht;let _i=document.createElement("input");_i.type="checkbox",_i.className="vis-cb",_i.title="Visible";let Hi=Ye.filter(Je=>Je.visible).length;_i.checked=Hi===Ye.length,_i.indeterminate=Hi>0&&Hi{let Je=_i.checked;se(Ye.filter(Qn=>!!Qn.visible!==Je).map(Qn=>({path:Qn.path,value:Je})))}),Ke.appendChild(_i),Ke.appendChild(ST()),Ze.appendChild(Ke);let _n=document.createElement("div");_n.className="vis-group-children",Ze.appendChild(_n),ok(Ke,pt,_n,!1),Fr.appendChild(Ze),ct=_n}for(let Ze of Ye){let Ke=document.createElement("div");Ke.className="vis-leaf";let pt=document.createElement("span");pt.className="vis-arrow",pt.style.visibility="hidden",pt.textContent="\u25B6",Ke.appendChild(pt),Ke.appendChild(CO(Ze.name));let Xn=document.createElement("input");Xn.type="checkbox",Xn.className="vis-cb",Xn.title="Visible",Xn.checked=!!Ze.visible,Xn.addEventListener("change",()=>se([{path:Ze.path,value:Xn.checked}])),Ke.appendChild(Xn),Ke.appendChild(ST()),ct.appendChild(Ke)}}}s.refreshRendererControls=function(){return!s.websocketManager||ua(s)||!n.debug_renderers?(Fr.innerHTML="",Promise.resolve()):s.websocketManager.request({type:"renderer_controls"}).then(Ae=>de(Ae.controls)).catch(()=>{})},s.refreshRendererControls();let it=document.createElement("div");it.className="bg-color-row";let We=document.createElement("span");We.textContent="Background";let En=document.createElement("input");En.type="color",En.className="bg-color-input",En.title="Layout background color";let hr=zf("or_bg_color");En.value=SO(hr)?hr:q5e(),En.addEventListener("input",()=>{document.documentElement.style.setProperty("--bg-map",En.value)}),En.addEventListener("change",()=>{r3t(En.value,s)});let qi=document.createElement("button");qi.className="bg-color-reset",qi.textContent="Reset",qi.title="Reset background to the theme default",qi.addEventListener("click",()=>{s3t(s),En.value=q5e()}),it.appendChild(We),it.appendChild(En),it.appendChild(qi),!s.heatMapLayer&&d&&(s.heatMapLayer=d());let Me=document.createElement("div");Me.className="vis-group heatmap-controls",s.displayControlsEl.appendChild(Me);let{header:ve,arrow:wt,name:gn}=sk("vis-group-header heatmap-header");gn.textContent="Heat Maps",Me.appendChild(ve);let vn=document.createElement("div");vn.className="vis-group-children heatmap-group-children",Me.appendChild(vn),ok(ve,wt,vn,!0),s.displayControlsEl.appendChild(it);function Mn(Ae,Le,ht,Ye){let ct=document.createElement("label");ct.className="heatmap-setting";let Ze=document.createElement("input");Ze.type="checkbox",Ze.checked=ht,Ze.addEventListener("change",()=>Ye(Ze.checked)),ct.appendChild(Ze),ct.appendChild(document.createTextNode(Le)),Ae.appendChild(ct)}function xi(Ae,Le,ht,Ye,ct){let Ze=document.createElement("label");Ze.className="heatmap-setting";let Ke=document.createElement("span");Ke.textContent=Le;let pt=document.createElement("input");pt.type="number",pt.value=String(ht),pt.step=String(Ye||1),pt.addEventListener("change",()=>ct(parseFloat(pt.value))),Ze.appendChild(Ke),Ze.appendChild(pt),Ae.appendChild(Ze)}function mi(Ae,Le,ht,Ye,ct){let Ze=document.createElement("label");Ze.className="heatmap-setting";let Ke=document.createElement("span");Ke.textContent=Le;let pt=document.createElement("select");for(let Xn of Ye){let _i=document.createElement("option");_i.value=Xn,_i.textContent=Xn,Xn===ht&&(_i.selected=!0),pt.appendChild(_i)}pt.addEventListener("change",()=>ct(pt.value)),Ze.appendChild(Ke),Ze.appendChild(pt),Ae.appendChild(Ze)}function ri(Ae){s.websocketManager.request(Ae).then(Le=>{s.updateHeatMaps&&s.updateHeatMaps(Le)}).catch(Le=>console.error("Heat map update failed",Le))}function Ge(Ae){if(!s.heatMapLegendEl)return;let Le=s.heatMapLegendEl;if(Le.innerHTML="",!Ae||!Ae.show_legend||!Ae.legend||Ae.legend.length===0){Le.classList.add("hidden");return}let ht=document.createElement("div");ht.className="heatmap-map-legend-title",ht.textContent=Ae.title,Le.appendChild(ht);let Ye=document.createElement("div");Ye.className="heatmap-map-legend-units",Ye.textContent=Ae.units||"",Le.appendChild(Ye);let ct=document.createElement("div");ct.className="heatmap-map-legend-list";for(let Ze of Ae.legend){let Ke=document.createElement("div");Ke.className="heatmap-legend-row";let pt=document.createElement("span");pt.className="heatmap-legend-swatch",pt.style.backgroundColor=`rgba(${Ze.color[0]}, ${Ze.color[1]}, ${Ze.color[2]}, ${Ze.color[3]/255})`;let Xn=document.createElement("span");Xn.textContent=Ze.value,Ke.appendChild(pt),Ke.appendChild(Xn),ct.appendChild(Ke)}Le.appendChild(ct),Le.classList.remove("hidden")}s.renderHeatMapControls=Ae=>{vn.innerHTML="";let Le=document.createElement("div");Le.className="heatmap-list",vn.appendChild(Le);let ht=document.createElement("label");ht.className="heatmap-setting";let Ye=document.createElement("input");Ye.type="radio",Ye.name="active-heatmap",Ye.checked=!Ae.active,Ye.addEventListener("change",()=>{ri({type:"set_active_heatmap",name:""})}),ht.appendChild(Ye),ht.appendChild(document.createTextNode("Off")),Le.appendChild(ht);for(let pt of Ae.heatmaps||[]){let Xn=document.createElement("label");Xn.className="heatmap-setting";let _i=document.createElement("input");_i.type="radio",_i.name="active-heatmap",_i.checked=pt.name===Ae.active,_i.addEventListener("change",()=>{ri({type:"set_active_heatmap",name:pt.name})}),Xn.appendChild(_i),Xn.appendChild(document.createTextNode(pt.title)),Le.appendChild(Xn)}let ct=(Ae.heatmaps||[]).find(pt=>pt.name===Ae.active);if(Ge(ct),!ct)return;let Ze=document.createElement("div");Ze.className="heatmap-settings",vn.appendChild(Ze),xi(Ze,"Display min",ct.display_min,ct.display_range_increment,pt=>{ri({type:"set_heatmap",name:ct.name,option:"DisplayMin",value:pt})}),xi(Ze,"Display max",ct.display_max,ct.display_range_increment,pt=>{ri({type:"set_heatmap",name:ct.name,option:"DisplayMax",value:pt})}),Mn(Ze,"Show below min",ct.draw_below_min,pt=>{ri({type:"set_heatmap",name:ct.name,option:"ShowMin",value:pt})}),Mn(Ze,"Show above max",ct.draw_above_max,pt=>{ri({type:"set_heatmap",name:ct.name,option:"ShowMax",value:pt})}),Mn(Ze,"Log scale",ct.log_scale,pt=>{ri({type:"set_heatmap",name:ct.name,option:"LogScale",value:pt})}),Mn(Ze,"Reverse log",ct.reverse_log,pt=>{ri({type:"set_heatmap",name:ct.name,option:"ReverseLog",value:pt})}),ct.can_adjust_grid&&(xi(Ze,"Grid X",ct.grid_x,.1,pt=>{ri({type:"set_heatmap",name:ct.name,option:"GridX",value:pt})}),xi(Ze,"Grid Y",ct.grid_y,.1,pt=>{ri({type:"set_heatmap",name:ct.name,option:"GridY",value:pt})})),xi(Ze,"Alpha",ct.alpha,1,pt=>{ri({type:"set_heatmap",name:ct.name,option:"Alpha",value:pt})}),Mn(Ze,"Legend",ct.show_legend,pt=>{ri({type:"set_heatmap",name:ct.name,option:"ShowLegend",value:pt})}),ct.supports_numbers&&Mn(Ze,"Show numbers",ct.show_numbers,pt=>{ri({type:"set_heatmap",name:ct.name,option:"ShowNumbers",value:pt})});for(let pt of ct.options||[])pt.type==="bool"?Mn(Ze,pt.label,pt.value,Xn=>{ri({type:"set_heatmap",name:ct.name,option:pt.name,value:Xn})}):pt.type==="choice"&&mi(Ze,pt.label,pt.value,pt.choices||[],Xn=>{ri({type:"set_heatmap",name:ct.name,option:pt.name,value:Xn})});ct.selection_filter_label&&Mn(Ze,ct.selection_filter_label,ct.use_selected_only,pt=>{ri({type:"set_heatmap",name:ct.name,option:"use_selected_only",value:pt})});let Ke=document.createElement("button");Ke.className="or-btn or-btn-sm heatmap-rebuild",Ke.textContent="Rebuild data",Ke.addEventListener("click",()=>{ri({type:"set_heatmap",name:ct.name,option:"rebuild",value:1})}),Ze.appendChild(Ke)}}var x3t="search-nav-dialog",Ydn=[{label:"Instance",value:"inst"},{label:"Net",value:"net"},{label:"Port",value:"port"}];function ide(s){if(!s.designScale)return;let n=Ydn.map(T=>``).join(""),{overlay:r,close:c,okBtn:u,showError:d}=MO("Find Object",`
`,"Find",_3t),b=r.querySelector(".sn-pattern"),w=r.querySelector(".sn-type"),_=r.querySelector(".sn-case");b.focus();function x(){let T=b.value.trim();if(!T){d("Enter a name or glob pattern.");return}s.websocketManager&&(d("Searching\u2026",!0),s.websocketManager.request({type:"find",obj_type:w.value,pattern:T,match_case:_.checked}).then(M=>{EO(s,M);let L=M&&M.count?M.count:0;if(!L){d("No objects found.");return}Array.isArray(M.bbox)&&(s.lastSelectionBounds=M.bbox.slice(0,4),s.view.fitWorldRect(X1(...s.lastSelectionBounds,s.designScale,s.designOriginX,s.designOriginY))),typeof s.updateInspector=="function"&&s.updateInspector(M),typeof s.redrawAllLayers=="function"&&s.redrawAllLayers();let I=M.selection_count||L;d(M.truncated?`${L} found (showing first ${I}).`:`${L} found.`,!0)}).catch(M=>d("Find failed: "+M)))}return u.addEventListener("click",x),b.addEventListener("keydown",T=>{T.key==="Enter"&&(T.preventDefault(),x())}),{close:c}}function rde(s){if(!s.designScale||!s.view)return;let n=D=>s.formatDbu(D),r=D=>s.parseDbu(D),c=s.unitLabel(),u=s.view.getCenter(),d=kv(u[0],u[1],s.designScale,s.designOriginX,s.designOriginY),{overlay:b,close:w,okBtn:_,showError:x}=MO("Go to Position",` + `,"Find",x3t),b=r.querySelector(".sn-pattern"),w=r.querySelector(".sn-type"),_=r.querySelector(".sn-case");b.focus();function x(){let T=b.value.trim();if(!T){d("Enter a name or glob pattern.");return}s.websocketManager&&(d("Searching\u2026",!0),s.websocketManager.request({type:"find",obj_type:w.value,pattern:T,match_case:_.checked}).then(M=>{EO(s,M);let L=M&&M.count?M.count:0;if(!L){d("No objects found.");return}Array.isArray(M.bbox)&&(s.lastSelectionBounds=M.bbox.slice(0,4),s.view.fitWorldRect(X1(...s.lastSelectionBounds,s.designScale,s.designOriginX,s.designOriginY))),typeof s.updateInspector=="function"&&s.updateInspector(M),typeof s.redrawAllLayers=="function"&&s.redrawAllLayers();let I=M.selection_count||L;d(M.truncated?`${L} found (showing first ${I}).`:`${L} found.`,!0)}).catch(M=>d("Find failed: "+M)))}return u.addEventListener("click",x),b.addEventListener("keydown",T=>{T.key==="Enter"&&(T.preventDefault(),x())}),{close:c}}function rde(s){if(!s.designScale||!s.view)return;let n=D=>s.formatDbu(D),r=D=>s.parseDbu(D),c=s.unitLabel(),u=s.view.getCenter(),d=kv(u[0],u[1],s.designScale,s.designOriginX,s.designOriginY),{overlay:b,close:w,okBtn:_,showError:x}=MO("Go to Position",`
-
`,"Go to",_3t),T=b.querySelector(".sn-x"),M=b.querySelector(".sn-y"),L=b.querySelector(".sn-size");T.focus(),T.select();function I(){let D=r(T.value),F=r(M.value);if(D===null||F===null){x(`X and Y must be numbers (${c}).`);return}let O=L.value.trim(),z=O?r(O):null;if(z!==null&&z>0){let Z=z/2;s.view.fitWorldRect(X1(D-Z,F-Z,D+Z,F+Z,s.designScale,s.designOriginX,s.designOriginY))}else s.view.setView(Lv(D,F,s.designScale,s.designOriginX,s.designOriginY),s.view.getZoom());w()}_.addEventListener("click",I);for(let D of[T,M,L])D.addEventListener("keydown",F=>{F.key==="Enter"&&(F.preventDefault(),I())});return{close:w}}var y3t={ctrl:"ctrl",control:"ctrl",shift:"shift",alt:"alt",meta:"meta",cmd:"meta",command:"meta",super:"meta"};function Hdn(s){if(typeof s!="string")return null;let n=s.split("+").map(d=>d.trim().toLowerCase()).filter(Boolean);if(n.length===0)return null;let r=n.pop();if(y3t[r]!==void 0)return null;let c=new Set;for(let d of n){let b=y3t[d];if(b===void 0)return null;c.add(b)}return[...["ctrl","alt","shift","meta"].filter(d=>c.has(d)),r].join("+")}function qdn(s){let n=[];return s.ctrlKey&&n.push("ctrl"),s.altKey&&n.push("alt"),s.shiftKey&&n.push("shift"),s.metaKey&&n.push("meta"),[...n,String(s.key).toLowerCase()].join("+")}function E3t(s){let n=[{label:"File",items:[{label:"Open DB...",action:()=>x3t(s,"Open DB","read_db"),enabledWhen:()=>!s.designScale},{label:"Save DB...",action:()=>x3t(s,"Save DB","write_db"),enabledWhen:()=>!!s.designScale}]},{label:"View",items:[{label:"Fit",shortcut:"F",action:()=>{s.fitRect&&s.view.fitWorldRect(s.fitRect)}},{label:"Zoom In",shortcut:"Z",action:()=>s.view.zoomIn()},{label:"Zoom Out",shortcut:"Shift+Z",action:()=>s.view.zoomOut()},{type:"separator"},{label:"Toggle Theme",shortcut:"T",action:()=>s.toggleTheme()},{type:"separator"},{label:"Find...",shortcut:"Ctrl+F",action:()=>ide(s),enabledWhen:()=>!!s.designScale},{label:"Go to Position...",shortcut:"Shift+G",action:()=>rde(s),enabledWhen:()=>!!s.designScale}]},{label:"Tools",items:[{label:"Ruler",shortcut:"K",action:()=>{s.rulerManager&&s.rulerManager.toggleRulerMode()}},{label:"Clear Rulers",shortcut:"Shift+K",action:()=>{s.rulerManager&&s.rulerManager.clearAllRulers()}},{type:"separator"},{label:"Add Label",shortcut:"L",action:()=>{s.labelManager&&s.labelManager.toggleLabelMode()}},{label:"Clear Labels",action:()=>{s.labelManager&&s.labelManager.clearAllLabels()}},{type:"separator"},{label:"Clear Highlights",action:()=>{s.websocketManager.request({type:"clear_highlights",group:-1}).then(()=>{s.refreshOverlay&&s.refreshOverlay(),s.refreshInspector&&s.refreshInspector()}).catch(()=>{})}},{type:"separator"},{label:"Global Connect...",action:()=>{s.showGlobalConnectDialog&&s.showGlobalConnectDialog()},enabledWhen:()=>!!s.designScale}]},{label:"Options",items:[{label:"Show DBU",action:()=>s.toggleShowDbu(),checked:()=>s.showDbu},{label:"Make euclidian rulers",action:()=>s.toggleRulerStyle(),checked:()=>s.rulerStyle!=="manhattan"},{type:"separator"},{label:"Mouse wheel mapped to zoom by default",action:()=>s.toggleWheelZoom(),checked:()=>s.wheelZoom},{label:"Arrow keys scroll step...",action:()=>s.showArrowStepDialog()},{label:"Application font...",action:()=>s.showAppFontDialog()},{type:"separator"},{label:"Smooth zoom and pan",action:()=>s.toggleControlSmoothing(),checked:()=>s.controlSmoothing},{label:"Double buffering",action:()=>s.toggleDoubleBuffer(),checked:()=>s.doubleBuffer},{label:"Defer tile updates while panning",action:()=>s.toggleDeferTileUpdates(),checked:()=>s.deferTileUpdates},{type:"separator"},{label:"Show polygon decomposition",action:()=>s.togglePolyDecomp(),checked:()=>s.polyDecomp,enabledWhen:()=>!!s.designScale}]},{label:"Windows",items:[{label:"Layout Viewer",action:()=>s.focusComponent("LayoutViewer")},{label:"3D Viewer",action:()=>s.focusComponent("3DViewer")},{label:"Display Controls",action:()=>s.focusComponent("DisplayControls")},{label:"Inspector",action:()=>s.focusComponent("Inspector")},{label:"Selection Browser",action:()=>s.focusComponent("SelectHighlight")},{label:"Tcl Console",action:()=>s.focusComponent("TclConsole")},{label:"Hierarchy Browser",action:()=>s.focusComponent("Browser")},{label:"Timing",action:()=>s.focusComponent("TimingWidget")},{label:"DRC Viewer",action:()=>s.focusComponent("DRCWidget")},{label:"Clock Tree",action:()=>s.focusComponent("ClockWidget")},{label:"Charts",action:()=>s.focusComponent("ChartsWidget")},{label:"Help",action:()=>s.focusComponent("HelpWidget")},{type:"separator"},{label:"Reset to Default Layout",action:()=>s.resetLayout()}]},{label:"Help",items:[{label:"Keyboard Shortcuts",action:()=>s.focusComponent("HelpWidget")}]}],r=document.getElementById("menu-bar"),c=null,u=new Map;function d(){c&&(c.classList.remove("open"),c=null)}function b(){let x=n.map(I=>({label:I.label,items:I.items.slice()})),T=new Map(x.map(I=>[I.label,I]));function M(I){let D=T.get(I);return D||(D={label:I,items:[]},T.set(I,D),x.push(D)),D}function L(I,D){let F=I.items.find(O=>O.submenu&&O.label===D);return F||(F={label:D,submenu:{label:D,items:[]}},I.items.push(F)),F.submenu}for(let I of s.customMenu||[]){let D=String(I.path||"Custom Scripts").split("/").map(Z=>Z.trim()).filter(Boolean);D.length===0&&D.push("Custom Scripts");let F=M(D[0]);for(let Z=1;ZiH(s,I.script,I.echo);F.items.push({label:I.text,shortcut:I.shortcut,action:O});let z=Hdn(I.shortcut);z&&u.set(z,O)}return x}function w(x,T){for(let M of T){if(M.type==="separator"){let D=document.createElement("div");D.className="menu-separator",x.appendChild(D);continue}let L=document.createElement("div");if(L.className="menu-item",M.submenu){L.classList.add("submenu-item");let D=document.createElement("span");D.textContent=M.label,L.appendChild(D);let F=document.createElement("span");F.className="submenu-arrow",F.textContent="\u25B8",L.appendChild(F);let O=document.createElement("div");O.className="menu-dropdown submenu",w(O,M.submenu.items),L.appendChild(O),x.appendChild(L);continue}if(M.disabled&&L.classList.add("disabled"),M.enabledWhen&&(L._enabledWhen=M.enabledWhen),M.checked){let D=document.createElement("span");D.className="menu-check",D.textContent=M.checked()?"\u2713":"",L.appendChild(D),L._checkedFn=M.checked}let I=document.createElement("span");if(I.textContent=M.label,L.appendChild(I),M.shortcut){let D=document.createElement("span");D.className="shortcut",D.textContent=M.shortcut,L.appendChild(D)}M.action&&L.addEventListener("click",D=>{L.classList.contains("disabled")||(D.stopPropagation(),d(),M.action())}),x.appendChild(L)}}function _(){for(let T of r.querySelectorAll(":scope > .menu-label"))T.remove();let x=r.firstChild;c=null,u.clear();for(let T of b()){let I=function(){for(let D of L.querySelectorAll(".menu-item"))if(D._enabledWhen&&D.classList.toggle("disabled",!D._enabledWhen()),D._checkedFn){let F=D.querySelector(".menu-check");F&&(F.textContent=D._checkedFn()?"\u2713":"")}},M=document.createElement("div");M.className="menu-label",M.textContent=T.label;let L=document.createElement("div");L.className="menu-dropdown",w(L,T.items),M.appendChild(L),M.addEventListener("click",D=>{D.stopPropagation(),c===M?d():(d(),I(),M.classList.add("open"),c=M)}),M.addEventListener("mouseenter",()=>{c&&c!==M&&(d(),I(),M.classList.add("open"),c=M)}),r.insertBefore(M,x)}}_(),s.rebuildMenuBar=_,document.addEventListener("click",d),Xdn(u)}function Xdn(s){document.addEventListener("keydown",n=>{if(s.size===0)return;let r=n.target.tagName;if(r==="INPUT"||r==="TEXTAREA"||n.target.isContentEditable)return;let c=s.get(qdn(n));c&&(n.preventDefault(),n.stopImmediatePropagation(),c())},!0)}function x3t(s,n,r){let c=r==="write_db",u=document.createElement("div");u.className="modal-overlay",u.innerHTML=` +
`,"Go to",x3t),T=b.querySelector(".sn-x"),M=b.querySelector(".sn-y"),L=b.querySelector(".sn-size");T.focus(),T.select();function I(){let D=r(T.value),F=r(M.value);if(D===null||F===null){x(`X and Y must be numbers (${c}).`);return}let O=L.value.trim(),z=O?r(O):null;if(z!==null&&z>0){let Z=z/2;s.view.fitWorldRect(X1(D-Z,F-Z,D+Z,F+Z,s.designScale,s.designOriginX,s.designOriginY))}else s.view.setView(Lv(D,F,s.designScale,s.designOriginX,s.designOriginY),s.view.getZoom());w()}_.addEventListener("click",I);for(let D of[T,M,L])D.addEventListener("keydown",F=>{F.key==="Enter"&&(F.preventDefault(),I())});return{close:w}}var E3t={ctrl:"ctrl",control:"ctrl",shift:"shift",alt:"alt",meta:"meta",cmd:"meta",command:"meta",super:"meta"};function Zdn(s){if(typeof s!="string")return null;let n=s.split("+").map(d=>d.trim().toLowerCase()).filter(Boolean);if(n.length===0)return null;let r=n.pop();if(E3t[r]!==void 0)return null;let c=new Set;for(let d of n){let b=E3t[d];if(b===void 0)return null;c.add(b)}return[...["ctrl","alt","shift","meta"].filter(d=>c.has(d)),r].join("+")}function Kdn(s){let n=[];return s.ctrlKey&&n.push("ctrl"),s.altKey&&n.push("alt"),s.shiftKey&&n.push("shift"),s.metaKey&&n.push("meta"),[...n,String(s.key).toLowerCase()].join("+")}function M3t(s){let n=[{label:"File",items:[{label:"Open DB...",action:()=>S3t(s,"Open DB","read_db"),enabledWhen:()=>!s.designScale},{label:"Save DB...",action:()=>S3t(s,"Save DB","write_db"),enabledWhen:()=>!!s.designScale}]},{label:"View",items:[{label:"Fit",shortcut:"F",action:()=>{s.fitRect&&s.view.fitWorldRect(s.fitRect)}},{label:"Zoom In",shortcut:"Z",action:()=>s.view.zoomIn()},{label:"Zoom Out",shortcut:"Shift+Z",action:()=>s.view.zoomOut()},{type:"separator"},{label:"Toggle Theme",shortcut:"T",action:()=>s.toggleTheme()},{type:"separator"},{label:"Find...",shortcut:"Ctrl+F",action:()=>ide(s),enabledWhen:()=>!!s.designScale},{label:"Go to Position...",shortcut:"Shift+G",action:()=>rde(s),enabledWhen:()=>!!s.designScale}]},{label:"Tools",items:[{label:"Ruler",shortcut:"K",action:()=>{s.rulerManager&&s.rulerManager.toggleRulerMode()}},{label:"Clear Rulers",shortcut:"Shift+K",action:()=>{s.rulerManager&&s.rulerManager.clearAllRulers()}},{type:"separator"},{label:"Add Label",shortcut:"L",action:()=>{s.labelManager&&s.labelManager.toggleLabelMode()}},{label:"Clear Labels",action:()=>{s.labelManager&&s.labelManager.clearAllLabels()}},{type:"separator"},{label:"Clear Highlights",action:()=>{s.websocketManager.request({type:"clear_highlights",group:-1}).then(()=>{s.refreshOverlay&&s.refreshOverlay(),s.refreshInspector&&s.refreshInspector()}).catch(()=>{})}},{type:"separator"},{label:"Global Connect...",action:()=>{s.showGlobalConnectDialog&&s.showGlobalConnectDialog()},enabledWhen:()=>!!s.designScale}]},{label:"Options",items:[{label:"Show DBU",action:()=>s.toggleShowDbu(),checked:()=>s.showDbu},{label:"Make euclidian rulers",action:()=>s.toggleRulerStyle(),checked:()=>s.rulerStyle!=="manhattan"},{type:"separator"},{label:"Mouse wheel mapped to zoom by default",action:()=>s.toggleWheelZoom(),checked:()=>s.wheelZoom},{label:"Arrow keys scroll step...",action:()=>s.showArrowStepDialog()},{label:"Application font...",action:()=>s.showAppFontDialog()},{type:"separator"},{label:"Smooth zoom and pan",action:()=>s.toggleControlSmoothing(),checked:()=>s.controlSmoothing},{label:"Double buffering",action:()=>s.toggleDoubleBuffer(),checked:()=>s.doubleBuffer},{label:"Defer tile updates while panning",action:()=>s.toggleDeferTileUpdates(),checked:()=>s.deferTileUpdates},{type:"separator"},{label:"Show polygon decomposition",action:()=>s.togglePolyDecomp(),checked:()=>s.polyDecomp,enabledWhen:()=>!!s.designScale}]},{label:"Windows",items:[{label:"Layout Viewer",action:()=>s.focusComponent("LayoutViewer")},{label:"3D Viewer",action:()=>s.focusComponent("3DViewer")},{label:"Display Controls",action:()=>s.focusComponent("DisplayControls")},{label:"Inspector",action:()=>s.focusComponent("Inspector")},{label:"Selection Browser",action:()=>s.focusComponent("SelectHighlight")},{label:"Tcl Console",action:()=>s.focusComponent("TclConsole")},{label:"Hierarchy Browser",action:()=>s.focusComponent("Browser")},{label:"Timing",action:()=>s.focusComponent("TimingWidget")},{label:"DRC Viewer",action:()=>s.focusComponent("DRCWidget")},{label:"Clock Tree",action:()=>s.focusComponent("ClockWidget")},{label:"Charts",action:()=>s.focusComponent("ChartsWidget")},{label:"Help",action:()=>s.focusComponent("HelpWidget")},{type:"separator"},{label:"Reset to Default Layout",action:()=>s.resetLayout()}]},{label:"Help",items:[{label:"Keyboard Shortcuts",action:()=>s.focusComponent("HelpWidget")}]}],r=document.getElementById("menu-bar"),c=null,u=new Map;function d(){c&&(c.classList.remove("open"),c=null)}function b(){let x=n.map(I=>({label:I.label,items:I.items.slice()})),T=new Map(x.map(I=>[I.label,I]));function M(I){let D=T.get(I);return D||(D={label:I,items:[]},T.set(I,D),x.push(D)),D}function L(I,D){let F=I.items.find(O=>O.submenu&&O.label===D);return F||(F={label:D,submenu:{label:D,items:[]}},I.items.push(F)),F.submenu}for(let I of s.customMenu||[]){let D=String(I.path||"Custom Scripts").split("/").map(Z=>Z.trim()).filter(Boolean);D.length===0&&D.push("Custom Scripts");let F=M(D[0]);for(let Z=1;ZiH(s,I.script,I.echo);F.items.push({label:I.text,shortcut:I.shortcut,action:O});let z=Zdn(I.shortcut);z&&u.set(z,O)}return x}function w(x,T){for(let M of T){if(M.type==="separator"){let D=document.createElement("div");D.className="menu-separator",x.appendChild(D);continue}let L=document.createElement("div");if(L.className="menu-item",M.submenu){L.classList.add("submenu-item");let D=document.createElement("span");D.textContent=M.label,L.appendChild(D);let F=document.createElement("span");F.className="submenu-arrow",F.textContent="\u25B8",L.appendChild(F);let O=document.createElement("div");O.className="menu-dropdown submenu",w(O,M.submenu.items),L.appendChild(O),x.appendChild(L);continue}if(M.disabled&&L.classList.add("disabled"),M.enabledWhen&&(L._enabledWhen=M.enabledWhen),M.checked){let D=document.createElement("span");D.className="menu-check",D.textContent=M.checked()?"\u2713":"",L.appendChild(D),L._checkedFn=M.checked}let I=document.createElement("span");if(I.textContent=M.label,L.appendChild(I),M.shortcut){let D=document.createElement("span");D.className="shortcut",D.textContent=M.shortcut,L.appendChild(D)}M.action&&L.addEventListener("click",D=>{L.classList.contains("disabled")||(D.stopPropagation(),d(),M.action())}),x.appendChild(L)}}function _(){for(let T of r.querySelectorAll(":scope > .menu-label"))T.remove();let x=r.firstChild;c=null,u.clear();for(let T of b()){let I=function(){for(let D of L.querySelectorAll(".menu-item"))if(D._enabledWhen&&D.classList.toggle("disabled",!D._enabledWhen()),D._checkedFn){let F=D.querySelector(".menu-check");F&&(F.textContent=D._checkedFn()?"\u2713":"")}},M=document.createElement("div");M.className="menu-label",M.textContent=T.label;let L=document.createElement("div");L.className="menu-dropdown",w(L,T.items),M.appendChild(L),M.addEventListener("click",D=>{D.stopPropagation(),c===M?d():(d(),I(),M.classList.add("open"),c=M)}),M.addEventListener("mouseenter",()=>{c&&c!==M&&(d(),I(),M.classList.add("open"),c=M)}),r.insertBefore(M,x)}}_(),s.rebuildMenuBar=_,document.addEventListener("click",d),Jdn(u)}function Jdn(s){document.addEventListener("keydown",n=>{if(s.size===0)return;let r=n.target.tagName;if(r==="INPUT"||r==="TEXTAREA"||n.target.isContentEditable)return;let c=s.get(Kdn(n));c&&(n.preventDefault(),n.stopImmediatePropagation(),c())},!0)}function S3t(s,n,r){let c=r==="write_db",u=document.createElement("div");u.className="modal-overlay",u.innerHTML=` - `,document.body.appendChild(u);let d=u.querySelector(".fb-breadcrumb"),b=u.querySelector(".fb-file-list"),w=u.querySelector(".fb-path-input"),_=u.querySelector(".modal-error"),x=u.querySelector(".ok"),T=u.querySelector(".cancel"),M="",L=null;function I(){u.remove()}function D(){let H=w.value.trim();x.disabled=!H}function F(H){d.innerHTML="";let te=H.split("/").filter(Boolean),oe=document.createElement("span");oe.className="fb-crumb",oe.textContent="/",oe.addEventListener("click",()=>z("/")),d.appendChild(oe);let ne="";for(let ue of te){ne+="/"+ue;let Te=document.createElement("span");Te.className="fb-crumb-sep",Te.textContent=" / ",d.appendChild(Te);let Q=document.createElement("span");Q.className="fb-crumb",Q.textContent=ue;let ge=ne;Q.addEventListener("click",()=>z(ge)),d.appendChild(Q)}}function O(H){if(b.innerHTML="",L=null,!H||H.length===0){let te=document.createElement("div");te.className="fb-empty",te.textContent="(empty directory)",b.appendChild(te);return}for(let te of H){let oe=document.createElement("div");oe.className="fb-entry",te.is_dir&&oe.classList.add("fb-dir");let ne=document.createElement("span");ne.className="fb-icon",ne.textContent=te.is_dir?"\u{1F4C1}":"\u{1F4C4}",oe.appendChild(ne);let ue=document.createElement("span");if(ue.className="fb-name",ue.textContent=te.name,oe.appendChild(ue),!te.is_dir&&te.size!==void 0){let Te=document.createElement("span");Te.className="fb-size",Te.textContent=Ydn(te.size),oe.appendChild(Te)}te.is_dir?oe.addEventListener("click",()=>{z(M+"/"+te.name)}):(oe.addEventListener("click",()=>{let Te=b.querySelector(".fb-selected");Te&&Te.classList.remove("fb-selected"),oe.classList.add("fb-selected"),L=te,w.value=M+"/"+te.name,D()}),oe.addEventListener("dblclick",()=>{w.value=M+"/"+te.name,D(),Z()})),b.appendChild(oe)}}async function z(H){_.style.display="none",b.innerHTML='
Loading...
';try{let te=await s.websocketManager.request({type:"list_dir",path:H||""});if(M=te.path,F(te.path),O(te.entries),c){let ne=w.value.trim().split("/").pop();ne&&!ne.includes("/")?w.value=M+"/"+ne:w.value=M+"/"}else w.value="",L=null;D()}catch(te){b.innerHTML="",_.textContent=te.message||String(te),_.style.display=""}}async function Z(){let H=w.value.trim();if(H){x.disabled=!0,x.textContent="Working...",_.style.display="none";try{let te=await s.websocketManager.request({type:"tcl_eval",cmd:`${r} ${H}`});if(te.is_error){_.textContent=te.output||te.result||"Command failed",_.style.display="",x.disabled=!1,x.textContent=c?"Save":"Open";return}if(I(),r==="read_db"){window.location.reload();return}}catch(te){_.textContent=te.message||"Request failed",_.style.display="",x.disabled=!1,x.textContent=c?"Save":"Open"}}}w.addEventListener("input",D),w.addEventListener("keydown",H=>{if(H.key==="Enter"){let te=w.value.trim();te.endsWith("/")?z(te.replace(/\/+$/,"")||"/"):Z()}H.key==="Escape"&&I()}),x.addEventListener("click",Z),T.addEventListener("click",I),u.addEventListener("click",H=>{H.target===u&&I()}),z("")}function Ydn(s){return s<1024?s+" B":s<1024*1024?(s/1024).toFixed(1)+" KB":s<1024*1024*1024?(s/(1024*1024)).toFixed(1)+" MB":(s/(1024*1024*1024)).toFixed(1)+" GB"}function S3t(s){let n=document.getElementById("toolbar");if(!n)return;s._toolbarToggleState||(s._toolbarToggleState={});function r(){n.innerHTML="";let c=s.customToolbar||[],u=new Set(c.map(d=>d.key));for(let d of Object.keys(s._toolbarToggleState))u.has(d)||delete s._toolbarToggleState[d];for(let d of c){let b=document.createElement("button");if(b.className="or-btn or-btn-sm toolbar-button",b.dataset.key=d.key,d.tooltip&&(b.title=d.tooltip),d.icon){let w=document.createElement("span");if(w.className="toolbar-icon",/^(data:|https?:|\.?\/)/.test(d.icon)){let _=document.createElement("img");_.src=d.icon,_.alt="",w.appendChild(_)}else w.textContent=d.icon;b.appendChild(w)}if(d.text){let w=document.createElement("span");w.className="toolbar-label",w.textContent=d.text,b.appendChild(w)}d.toggle&&s._toolbarToggleState[d.key]&&b.classList.add("active"),b.addEventListener("click",()=>{if(d.toggle){let w=!s._toolbarToggleState[d.key];s._toolbarToggleState[d.key]=w,b.classList.toggle("active",w),iH(s,w?d.script:d.script_off,d.echo)}else iH(s,d.script,d.echo)}),n.appendChild(b)}}return r(),s.rebuildToolbar=r,{rebuild:r}}function T3t(s,n=""){let r=document.createElement("div");r.className="modal-overlay",r.innerHTML=` + `,document.body.appendChild(u);let d=u.querySelector(".fb-breadcrumb"),b=u.querySelector(".fb-file-list"),w=u.querySelector(".fb-path-input"),_=u.querySelector(".modal-error"),x=u.querySelector(".ok"),T=u.querySelector(".cancel"),M="",L=null;function I(){u.remove()}function D(){let H=w.value.trim();x.disabled=!H}function F(H){d.innerHTML="";let te=H.split("/").filter(Boolean),oe=document.createElement("span");oe.className="fb-crumb",oe.textContent="/",oe.addEventListener("click",()=>z("/")),d.appendChild(oe);let ne="";for(let ue of te){ne+="/"+ue;let Te=document.createElement("span");Te.className="fb-crumb-sep",Te.textContent=" / ",d.appendChild(Te);let Q=document.createElement("span");Q.className="fb-crumb",Q.textContent=ue;let ge=ne;Q.addEventListener("click",()=>z(ge)),d.appendChild(Q)}}function O(H){if(b.innerHTML="",L=null,!H||H.length===0){let te=document.createElement("div");te.className="fb-empty",te.textContent="(empty directory)",b.appendChild(te);return}for(let te of H){let oe=document.createElement("div");oe.className="fb-entry",te.is_dir&&oe.classList.add("fb-dir");let ne=document.createElement("span");ne.className="fb-icon",ne.textContent=te.is_dir?"\u{1F4C1}":"\u{1F4C4}",oe.appendChild(ne);let ue=document.createElement("span");if(ue.className="fb-name",ue.textContent=te.name,oe.appendChild(ue),!te.is_dir&&te.size!==void 0){let Te=document.createElement("span");Te.className="fb-size",Te.textContent=Qdn(te.size),oe.appendChild(Te)}te.is_dir?oe.addEventListener("click",()=>{z(M+"/"+te.name)}):(oe.addEventListener("click",()=>{let Te=b.querySelector(".fb-selected");Te&&Te.classList.remove("fb-selected"),oe.classList.add("fb-selected"),L=te,w.value=M+"/"+te.name,D()}),oe.addEventListener("dblclick",()=>{w.value=M+"/"+te.name,D(),Z()})),b.appendChild(oe)}}async function z(H){_.style.display="none",b.innerHTML='
Loading...
';try{let te=await s.websocketManager.request({type:"list_dir",path:H||""});if(M=te.path,F(te.path),O(te.entries),c){let ne=w.value.trim().split("/").pop();ne&&!ne.includes("/")?w.value=M+"/"+ne:w.value=M+"/"}else w.value="",L=null;D()}catch(te){b.innerHTML="",_.textContent=te.message||String(te),_.style.display=""}}async function Z(){let H=w.value.trim();if(H){x.disabled=!0,x.textContent="Working...",_.style.display="none";try{let te=await s.websocketManager.request({type:"tcl_eval",cmd:`${r} ${H}`});if(te.is_error){_.textContent=te.output||te.result||"Command failed",_.style.display="",x.disabled=!1,x.textContent=c?"Save":"Open";return}if(I(),r==="read_db"){window.location.reload();return}}catch(te){_.textContent=te.message||"Request failed",_.style.display="",x.disabled=!1,x.textContent=c?"Save":"Open"}}}w.addEventListener("input",D),w.addEventListener("keydown",H=>{if(H.key==="Enter"){let te=w.value.trim();te.endsWith("/")?z(te.replace(/\/+$/,"")||"/"):Z()}H.key==="Escape"&&I()}),x.addEventListener("click",Z),T.addEventListener("click",I),u.addEventListener("click",H=>{H.target===u&&I()}),z("")}function Qdn(s){return s<1024?s+" B":s<1024*1024?(s/1024).toFixed(1)+" KB":s<1024*1024*1024?(s/(1024*1024)).toFixed(1)+" MB":(s/(1024*1024*1024)).toFixed(1)+" GB"}function T3t(s){let n=document.getElementById("toolbar");if(!n)return;s._toolbarToggleState||(s._toolbarToggleState={});function r(){n.innerHTML="";let c=s.customToolbar||[],u=new Set(c.map(d=>d.key));for(let d of Object.keys(s._toolbarToggleState))u.has(d)||delete s._toolbarToggleState[d];for(let d of c){let b=document.createElement("button");if(b.className="or-btn or-btn-sm toolbar-button",b.dataset.key=d.key,d.tooltip&&(b.title=d.tooltip),d.icon){let w=document.createElement("span");if(w.className="toolbar-icon",/^(data:|https?:|\.?\/)/.test(d.icon)){let _=document.createElement("img");_.src=d.icon,_.alt="",w.appendChild(_)}else w.textContent=d.icon;b.appendChild(w)}if(d.text){let w=document.createElement("span");w.className="toolbar-label",w.textContent=d.text,b.appendChild(w)}d.toggle&&s._toolbarToggleState[d.key]&&b.classList.add("active"),b.addEventListener("click",()=>{if(d.toggle){let w=!s._toolbarToggleState[d.key];s._toolbarToggleState[d.key]=w,b.classList.toggle("active",w),iH(s,w?d.script:d.script_off,d.echo)}else iH(s,d.script,d.echo)}),n.appendChild(b)}}return r(),s.rebuildToolbar=r,{rebuild:r}}function A3t(s,n=""){let r=document.createElement("div");r.className="modal-overlay",r.innerHTML=` `,document.body.appendChild(r);function c(d){d.key==="Escape"&&u()}let u=()=>{r.remove(),document.removeEventListener("keydown",c)};return r.addEventListener("click",d=>{d.target===r&&u()}),document.addEventListener("keydown",c),{overlay:r,body:r.querySelector(".modal-body"),errorDiv:r.querySelector(".modal-error"),buttons:r.querySelector(".modal-buttons"),close:u}}function g2(s,n){s.textContent=n,s.style.display=n?"":"none"}function AO(s,n,{primary:r=!1}={}){let c=document.createElement("button");return c.textContent=n,c.className="or-btn"+(r?" or-btn-primary":""),s.appendChild(c),c}function sde(s){return"{"+String(s)+"}"}function C3t(s){let n=T3t("Global Connect","gc-dialog"),r=document.createElement("div");r.className="gc-table",n.body.appendChild(r);let c=document.createElement("div");c.className="gc-form";let u=document.createElement("input");u.placeholder="Instance pattern (regex)",u.value=".*";let d=document.createElement("input");d.placeholder="Pin pattern (regex)";let b=document.createElement("select"),w=document.createElement("select"),_=document.createElement("span");_.innerHTML='',c.append(MT("Instance",u),MT("Pin",d),MT("Net",b),MT("Region",w),_);let x=AO(c,"Add rule");n.body.appendChild(c);function T(){let D=d.value.trim()!==""&&b.value!=="";for(let F of[u,d])try{new RegExp(F.value),F.classList.remove("gc-invalid")}catch{F.classList.add("gc-invalid"),D=!1}x.disabled=!D}u.addEventListener("input",T),d.addEventListener("input",T),b.addEventListener("change",T);function M(){s.websocketManager.request({type:"global_connect_info"}).then(D=>{r.innerHTML='
InstancePinNetRegion
',(D.rules||[]).forEach(F=>{let O=document.createElement("div");O.className="gc-row",O.innerHTML=`${oH(F.inst)}${oH(F.pin)}${oH(F.net)}${oH(F.region||"All")}`;let z=document.createElement("button");z.className="or-btn or-btn-sm or-btn-icon",z.textContent="\u2715",z.title="Delete rule",z.addEventListener("click",()=>{s.websocketManager.request({type:"global_connect_delete",inst:F.inst,pin:F.pin,net:F.net,region:F.region||""}).then(M).catch(Z=>g2(n.errorDiv,String(Z)))}),O.appendChild(z),r.appendChild(O)}),eDe(b,D.nets||[]),eDe(w,["All",...D.regions||[]]),T()}).catch(D=>g2(n.errorDiv,String(D)))}x.addEventListener("click",()=>{let D=c.querySelector('input[name="gc-pg"]:checked').value,F=`add_global_connection -net ${sde(b.value)} -inst_pattern ${sde(u.value||".*")} -pin_pattern ${sde(d.value)} -${D}`;w.value&&w.value!=="All"&&(F+=` -region ${sde(w.value)}`),M3t(s,F,n.errorDiv,"Rule added.",M)}),AO(n.buttons,"Apply (force)").addEventListener("click",()=>{s.websocketManager.request({type:"global_connect_apply",force:!0}).then(D=>{if(!D.had_rules){g2(n.errorDiv,"No global-connect rules defined \u2014 add a rule first.");return}g2(n.errorDiv,`Connected ${D.connected} pin(s).`),s.scheduleRedrawAllLayers&&s.scheduleRedrawAllLayers(),M()}).catch(D=>g2(n.errorDiv,D.message||String(D)))}),AO(n.buttons,"Clear all").addEventListener("click",()=>M3t(s,"clear_global_connect",n.errorDiv,"Rules cleared.",M)),AO(n.buttons,"Close").addEventListener("click",n.close),M()}function M3t(s,n,r,c,u){s.websocketManager.request({type:"tcl_eval",cmd:n}).then(d=>{if(d.is_error){g2(r,d.output||d.result||"Command failed");return}g2(r,c||""),s.scheduleRedrawAllLayers&&s.scheduleRedrawAllLayers(),u&&u()}).catch(d=>g2(r,d.message||String(d)))}function A3t(s,n){let r=T3t(`Insert Buffer \u2014 ${oH(n)}`,"buf-dialog"),c=AO(r.buttons,"Insert",{primary:!0});c.disabled=!0,AO(r.buttons,"Cancel").addEventListener("click",r.close),s.websocketManager.request({type:"buffer_info",net:n}).then(d=>{if(!d.can_buffer){r.body.textContent=d.error||"This net has multiple drivers and cannot be buffered.";return}Zdn(s,r,n,d,c)}).catch(d=>{r.body.textContent=String(d)})}function Zdn(s,n,r,c,u){let d=document.createElement("div");d.className="buf-pins";let b=c.drivers||[],w=c.loads||[],_=new Set;function x(){d.innerHTML="";let D=(F,O)=>{let z=document.createElement("label");z.className="buf-pin";let Z=document.createElement("input");Z.type="checkbox",Z.checked=_.has(F.id),Z.addEventListener("change",()=>{if(Z.checked){if(O)_.clear();else for(let H of b)_.delete(H.id);_.add(F.id)}else _.delete(F.id);x(),I()}),z.append(Z,document.createTextNode(" "+F.label)),d.appendChild(z)};b.forEach(F=>D(F,!0)),w.forEach(F=>D(F,!1))}b.length&&_.add(b[0].id),x();let T=document.createElement("select");eDe(T,c.masters||[]);let M=document.createElement("input");M.placeholder="Optional: new buffer name";let L=document.createElement("input");L.placeholder="Optional: new net name",n.body.append(MT("Pins to buffer",d),MT("Buffer master",T),MT("Buffer name",M),MT("Net name",L));function I(){u.disabled=_.size===0||!T.value}T.addEventListener("change",I),I(),u.addEventListener("click",()=>{let D=new Set(b.map(z=>z.id)),F=[..._],O=F.some(z=>D.has(z))?"driver":"loads";s.websocketManager.request({type:"insert_buffer",net:r,mode:O,pins:F,master:T.value,buf_name:M.value.trim(),net_name:L.value.trim()}).then(z=>{if(z.is_error||z.ok===!1){g2(n.errorDiv,z.error||z.result||"Insertion failed");return}n.close(),z.inst&&(s.selectedInstanceName=z.inst),s.scheduleRedrawAllLayers&&s.scheduleRedrawAllLayers()}).catch(z=>g2(n.errorDiv,z.message||String(z)))})}function MT(s,n){let r=document.createElement("label");r.className="edit-field";let c=document.createElement("span");return c.textContent=s,r.append(c,n),r}function eDe(s,n){let r=s.value;s.innerHTML="";for(let c of n){let u=document.createElement("option");u.value=c,u.textContent=c,s.appendChild(u)}n.includes(r)&&(s.value=r)}function oH(s){return String(s??"").replace(/&/g,"&").replace(//g,">")}var P3t="#00ffff",Kdn="#ffff00",L3t="#ffffff",Jdn=4,pk=0,tDe=1,aH=2,ode=class{constructor(n,r,c,u){this._app=n,this._visibility=r,this._updateInspector=c,this._focusComponent=u,this._state=pk,this._rulers=[],this._nextId=0,this._pt0=null,this._selectedRulerId=null,this._ctrlHeld=!1,this._shiftHeld=!1,this._snapTimer=null,this._lastSnapResult=null,this._snapShapes=null,this._preview=null,n.view?.on("zoom",()=>this._renderRulerShapes())}isActive(){return this._state!==pk}updateVisibility(){this._renderAll(),this._drawTransient()}_shown(){return this._visibility.rulers!==!1}toggleRulerMode(){this._state===pk?this._enterFirstPoint():this.cancelRulerBuild()}cancelRulerBuild(){this._state=pk,this._pt0=null,this._lastSnapResult=null,this._clearTransient(),this._setCursor(!1)}clearAllRulers(){this._rulers=[],this._selectedRulerId=null,this._renderAll(),this._clearTransient(),this._state!==pk&&this.cancelRulerBuild()}_enterFirstPoint(){this._state=tDe,this._pt0=null,this._lastSnapResult=null,this._setCursor(!0)}_enterMeasuring(n){this._state=aH,this._pt0=n}_toDbu(n){return kv(n[0],n[1],this._app.designScale,this._app.designOriginX,this._app.designOriginY)}_toWorld(n,r){return Lv(n,r,this._app.designScale,this._app.designOriginX,this._app.designOriginY)}handleMouseMove(n,r){if(this._state===pk)return;this._ctrlHeld=r.ctrlKey||r.metaKey,this._shiftHeld=r.shiftKey;let c=this._toDbu(n);this._snapTimer&&clearTimeout(this._snapTimer),this._snapTimer=setTimeout(()=>{this._requestSnap(c.dbuX,c.dbuY)},50)}handleMapClick(n,r){if(this._state===pk)return;this._ctrlHeld=r.ctrlKey||r.metaKey,this._shiftHeld=r.shiftKey;let c=this._toDbu(n),u=this._getSnappedPoint(c.dbuX,c.dbuY);this._state===tDe?this._enterMeasuring(u):this._state===aH&&(this._createRuler(this._pt0,u),this._state=tDe,this._pt0=null,this._clearTransient(),this._lastSnapResult=null)}async _requestSnap(n,r){let c=this._app;if(!c.websocketManager||!c.designScale)return;if(this._ctrlHeld){this._lastSnapResult=null,this._snapShapes=null,this._updatePreview(n,r);return}let d=c.techData?.dbu_per_micron||1e3,b=c.view.getZoom(),w=Math.pow(2,Math.max(0,b)),_=1/(c.designScale*w),x=Math.max(Math.round(10*_),10),T=!0,M=!0;if(this._shiftHeld)T=!0,M=!0;else if(this._state===aH&&this._pt0){let I=Math.abs(n-this._pt0.x),D=Math.abs(r-this._pt0.y);I>D?(T=!1,M=!0):D>I&&(T=!0,M=!1)}let L={};for(let[I,D]of Object.entries(this._visibility))L[I]=!!D;try{let I=await c.websocketManager.request({type:"snap",dbu_x:n,dbu_y:r,radius:d,point_threshold:x,horizontal:!!T,vertical:!!M,visible_layers:[...c.visibleLayerNames],...L});this._lastSnapResult=I,this._updateSnapIndicator(I),this._updatePreview(n,r)}catch{this._lastSnapResult=null,this._clearSnap()}}_getSnappedPoint(n,r){if(this._ctrlHeld)return{x:n,y:r};let c=this._lastSnapResult,u;if(c?.found&&c.is_point)u={x:c.edge[0][0],y:c.edge[0][1]};else if(c?.found){let d=c.edge;d[0][1]===d[1][1]?u={x:n,y:d[0][1]}:u={x:d[0][0],y:r}}else u={x:n,y:r};if(!this._shiftHeld&&this._state===aH&&this._pt0){let d=Math.abs(u.x-this._pt0.x),b=Math.abs(u.y-this._pt0.y);dthis._toWorld(u.x,u.y))}}_rulerShapes(n){let r=n.id===this._selectedRulerId,c=K1(r?Kdn:P3t),{joinPt:u,points:d}=this._rulerPath(n),b=[{kind:"path",points:d,stroke:c,width:2}],w=this._app.view.getZoom(),_=Math.pow(2,Math.max(0,w)),T=8*(1/(this._app.designScale*_)),M=(L,I,D)=>{let F=Math.sqrt(I*I+D*D);if(F===0)return;let O=-D/F,z=I/F;b.push({kind:"path",stroke:c,width:2,points:[this._toWorld(L.x+O*T,L.y+z*T),this._toWorld(L.x-O*T,L.y-z*T)]})};if(u)M(n.pt0,u.x-n.pt0.x,u.y-n.pt0.y),M(n.pt1,n.pt1.x-u.x,n.pt1.y-u.y);else{let L=n.pt1.x-n.pt0.x,I=n.pt1.y-n.pt0.y;M(n.pt0,L,I),M(n.pt1,L,I)}return b}_renderAll(){this._renderRulerShapes(),this._renderRulerLabels()}_renderRulerShapes(){let n=this._app.view;!n||!this._app.designScale||n.setOverlay("rulers",this._shown()?this._rulers.flatMap(r=>this._rulerShapes(r)):null,{order:bp.ruler})}_renderRulerLabels(){let n=this._app.view;if(!(!n||!this._app.designScale)&&(n.clearMarkers("ruler-labels"),!!this._shown()))for(let r of this._rulers){let{joinPt:c,points:u}=this._rulerPath(r),d=c?u[1]:[(u[0][0]+u[1][0])/2,(u[0][1]+u[1][1])/2],b=this._computeDistance(r.pt0,r.pt1,r.euclidian);n.addMarker("ruler-labels",r.id,d,this._labelElement(this._formatDistance(b)))}}handleRulerClick(n){let r=this._app.view;if(!r||!this._shown()||this._rulers.length===0)return!1;let c=r.project(n);for(let u of this._rulers){let d=this._rulerPath(u).points.map(b=>r.project(b));for(let b=0;b+1x.id===n);if(!r)return;Pm(this._app);let c=Math.abs(r.pt1.x-r.pt0.x),u=Math.abs(r.pt1.y-r.pt0.y),d=r.euclidian?Math.sqrt(c*c+u*u):c+u,b=x=>this._app.formatDbu(x,!0),w=x=>this._app.parseDbu(x),_={type:"Ruler",name:r.name,bbox:[Math.min(r.pt0.x,r.pt1.x),Math.min(r.pt0.y,r.pt1.y),Math.max(r.pt0.x,r.pt1.x),Math.max(r.pt0.y,r.pt1.y)],properties:[{name:"Name",value:r.name,editable:!0},{name:"Label",value:r.label||"",editable:!0},{name:"Point 0 - x",value:b(r.pt0.x),editable:!0},{name:"Point 0 - y",value:b(r.pt0.y),editable:!0},{name:"Point 1 - x",value:b(r.pt1.x),editable:!0},{name:"Point 1 - y",value:b(r.pt1.y),editable:!0},{name:"Delta x",value:b(c)},{name:"Delta y",value:b(u)},{name:"Length",value:b(d)},{name:"Euclidian",value:r.euclidian?"True":"False",editable:!0,editor:{type:"bool"}}],onPropertyChange:(x,T)=>{switch(x){case"Name":r.name=T;break;case"Label":r.label=T;break;case"Point 0 - x":{let M=w(T);M!==null&&(r.pt0.x=M);break}case"Point 0 - y":{let M=w(T);M!==null&&(r.pt0.y=M);break}case"Point 1 - x":{let M=w(T);M!==null&&(r.pt1.x=M);break}case"Point 1 - y":{let M=w(T);M!==null&&(r.pt1.y=M);break}case"Euclidian":r.euclidian=T.trim().toLowerCase()==="true";break}this._renderAll(),this._selectRuler(r.id)}};this._updateInspector(_),this._focusComponent("Inspector"),requestAnimationFrame(()=>{let x=this._app.inspectorEl?.querySelector(".inspector-toolbar");if(!x)return;let T=document.createElement("button");T.className="or-btn or-btn-icon",T.title="Delete ruler",T.innerHTML='',T.addEventListener("click",()=>{this.deleteRuler(n)}),x.appendChild(T)})}deleteRuler(n){let r=this._rulers.findIndex(c=>c.id===n);r!==-1&&(this._rulers.splice(r,1),this._renderAll(),this._selectedRulerId===n&&(this._selectedRulerId=null,this._updateInspector(null)))}_getManhattanJoinPt(n,r){return{x:r.x,y:n.y}}_computeDistance(n,r,c=!0){let u=Math.abs(r.x-n.x),d=Math.abs(r.y-n.y);return c?Math.sqrt(u*u+d*d):u+d}_formatDistance(n){return this._app.formatDistance(n)}_setCursor(n){this._app.view?.setCursorMode("ruler",n)}_clearTransient(){this._preview=null,this._snapShapes=null,this._drawTransient()}_clearSnap(){this._snapShapes=null,this._drawTransient()}};function Qdn(s,n,r){let c=r[0]-n[0],u=r[1]-n[1],d=c*c+u*u,b=d>0?((s[0]-n[0])*c+(s[1]-n[1])*u)/d:0;return b=Math.max(0,Math.min(1,b)),Math.hypot(s[0]-(n[0]+b*c),s[1]-(n[1]+b*u))}var ade="label-handles",k3t=3,cde=class{constructor(n,r,c,u){this._app=n,this._visibility=r,this._updateInspector=c,this._focusComponent=u,this._labels=[],this._anchors=[],this._mode=!1,this._selectedName=null}isActive(){return this._mode}updateVisibility(){this._app.view?.setMarkerGroupVisible(ade,!!this._visibility.labels)}toggleLabelMode(){this._mode=!this._mode,this._setCursor(this._mode)}cancelLabelMode(){this._mode=!1,this._setCursor(!1)}_setCursor(n){this._app.view?.setCursorMode("label",n)}_wm(){return this._app.websocketManager}_applyLabels(n){this._labels=n||[],this._renderHandles()}_refresh(n){this._applyLabels(n&&n.labels),this._app.refreshOverlay()}applyRemoteLabels(n){this._applyLabels(n),this._selectedName&&!this._labels.some(r=>r.name===this._selectedName)&&(this._selectedName=null,this._updateInspector(null),this._renderHandles()),this._app.refreshOverlay()}_updateLabel(n,r){return this._wm().request({type:"update_label",name:n,...r})}async reload(){let n=this._wm();if(n)try{let r=await n.request({type:"list_labels"});this._anchors=r.anchors||[],this._applyLabels(r.labels)}catch{this._applyLabels([])}}async handleMapClick(n,r){let c=window.prompt("Label text:");if(this._mode=!1,this._setCursor(!1),!!c)try{let u=await this._wm().request({type:"add_label",x:Math.round(n),y:Math.round(r),text:c});this._refresh(u)}catch(u){console.error("add_label failed:",u)}}_renderHandles(){let n=this._app.view;if(!n)return;n.clearMarkers(ade);let r=this._app;if(r.designScale)for(let c of this._labels){let u=document.createElement("div");u.className="label-handle"+(c.name===this._selectedName?" label-handle-selected":""),u.title=c.text,this._installDrag(u,c),n.addMarker(ade,c.name,Lv(c.x,c.y,r.designScale,r.designOriginX,r.designOriginY),u,{center:!0})}}_installDrag(n,r){let c=this._app.view,u=w=>{let _=c.getContainer().getBoundingClientRect();return c.unproject([w.clientX-_.left,w.clientY-_.top])},d=null;n.addEventListener("pointerdown",w=>{w.button===0&&(w.stopPropagation(),w.preventDefault(),n.setPointerCapture?.(w.pointerId),d={x:w.clientX,y:w.clientY,moved:!1})}),n.addEventListener("pointermove",w=>{d&&((Math.abs(w.clientX-d.x)>k3t||Math.abs(w.clientY-d.y)>k3t)&&(d.moved=!0),d.moved&&c.moveMarker(ade,r.name,u(w)))});let b=(w,_)=>{if(!d)return;let x=d;if(d=null,n.releasePointerCapture?.(w.pointerId),!_)this._renderHandles();else if(!x.moved)this._select(r.name);else{let T=this._app,[M,L]=u(w),{dbuX:I,dbuY:D}=kv(M,L,T.designScale,T.designOriginX,T.designOriginY);this._commitMove(r,Math.round(I),Math.round(D))}};n.addEventListener("pointerup",w=>b(w,!0)),n.addEventListener("pointercancel",w=>b(w,!1)),n.addEventListener("click",w=>w.stopPropagation())}async _commitMove(n,r,c){try{let u=await this._updateLabel(n.name,{x:r,y:c,text:n.text,size:n.size||0,anchor:n.anchor||"center",color:n.color});this._refresh(u)}catch(u){console.error("move label failed:",u)}}_select(n){this._selectedName=n,this._renderHandles();let r=this._labels.find(d=>d.name===n);if(!r)return;let c=d=>this._app.formatDbu(d,!0),u={type:"Label",name:r.name,bbox:[r.x,r.y,r.x,r.y],properties:[{name:"Name",value:r.name},{name:"Text",value:r.text,editable:!0},{name:"x",value:c(r.x)},{name:"y",value:c(r.y)},{name:"Font size",value:String(r.size||0),editable:!0},{name:"Anchor",value:r.anchor||"center",editable:!0,editor:{type:"list",options:this._anchors}}],onPropertyChange:(d,b)=>{let w={text:r.text,size:r.size||0,anchor:r.anchor||"center"};d==="Text"?w.text=b:d==="Font size"?w.size=parseInt(b,10)||0:d==="Anchor"&&(w.anchor=b.trim()),this._edit(r,w)}};this._updateInspector(u),this._focusComponent("Inspector"),requestAnimationFrame(()=>{let d=this._app.inspectorEl?.querySelector(".inspector-toolbar");if(!d||d.querySelector(".delete-label-btn"))return;let b=document.createElement("button");b.className="or-btn or-btn-icon delete-label-btn",b.title="Delete label",b.innerHTML='',b.addEventListener("click",()=>this.deleteLabel(n)),d.appendChild(b)})}async _edit(n,r){try{let c=await this._updateLabel(n.name,{x:n.x,y:n.y,text:r.text,size:r.size,anchor:r.anchor,color:n.color});this._refresh(c),this._select(n.name)}catch(c){console.error("edit label failed:",c)}}async deleteLabel(n){try{let r=await this._wm().request({type:"delete_label",name:n});this._selectedName===n&&(this._selectedName=null,this._updateInspector(null)),this._refresh(r)}catch(r){console.error("delete_label failed:",r)}}async clearAllLabels(){try{let n=await this._wm().request({type:"clear_labels"});this._selectedName=null,this._refresh(n)}catch(n){console.error("clear_labels failed:",n)}}};var R3t="Select an instance in the layout to view its schematic.",lde=class{constructor(n,r){this.container=n,this.appState=r,this.element=document.createElement("div"),this.element.className="schematic-widget",this.element.style.cssText="width:100%; height:100%; display:flex; flex-direction:column; background:var(--bg-panel); color:var(--fg-primary); overflow:hidden;",this.controls=document.createElement("div"),this.controls.style.cssText="padding:4px 8px; background:var(--bg-header); border-bottom:1px solid var(--border);flex-shrink:0; display:flex; align-items:center; gap:8px; flex-wrap:wrap;",this.controls.innerHTML='',this.element.appendChild(this.controls),this.svgContainer=document.createElement("div"),this.svgContainer.style.cssText="flex:1; overflow:hidden; position:relative; cursor:grab; background:var(--bg-main);",this.element.appendChild(this.svgContainer),this.container.element.appendChild(this.element),this.controls.querySelector("#schematic-refresh").addEventListener("click",()=>this.refresh()),this.controls.querySelector("#schematic-fit").addEventListener("click",()=>this.fitView()),this.controls.querySelector("#schematic-zoom-in").addEventListener("click",()=>this._zoomStep(1.5)),this.controls.querySelector("#schematic-zoom-out").addEventListener("click",()=>this._zoomStep(1/1.5)),this.controls.querySelector("#schematic-select").addEventListener("click",()=>this._toggleSelectMode()),this.controls.querySelector("#schematic-zoom-to").addEventListener("click",()=>this._zoomToSelected()),this.controls.querySelector("#schematic-save-svg").addEventListener("click",()=>this._exportSvg()),this.controls.querySelector("#schematic-save-png").addEventListener("click",()=>this._exportPng()),this.controls.querySelector("#schematic-copy").addEventListener("click",()=>this._copyImage()),this.appState.schematicWidget=this,this.netlistsvg=null,this.skin=null,this._svgEl=null,this._scale=1,this._panX=0,this._panY=0,this._selectMode=!1,this._selectedCell=null,this._svgIdToInstName=new Map,this._setupPanZoom(),this.initNetlistSVG()}_setupPanZoom(){let n=this.svgContainer,r=!1,c,u,d,b;n.addEventListener("wheel",w=>{if(!this._svgEl)return;w.preventDefault();let _=w.deltaY<0?1.2:1/1.2,x=n.getBoundingClientRect(),T=w.clientX-x.left,M=w.clientY-x.top;this._panX=T+(this._panX-T)*_,this._panY=M+(this._panY-M)*_,this._scale*=_,this._applyTransform()},{passive:!1}),n.addEventListener("mousedown",w=>{if(!(!this._svgEl||w.button!==0)){if(this._selectMode){this._handleSelectClick(w);return}r=!0,c=w.clientX,u=w.clientY,d=this._panX,b=this._panY,n.style.cursor="grabbing",w.preventDefault()}}),window.addEventListener("mousemove",w=>{r&&(this._panX=d+(w.clientX-c),this._panY=b+(w.clientY-u),this._applyTransform())}),window.addEventListener("mouseup",()=>{r&&(r=!1,n.style.cursor=this._selectMode?"default":"grab")})}_zoomStep(n){if(!this._svgEl)return;let r=this.svgContainer.getBoundingClientRect(),c=r.width/2,u=r.height/2;this._panX=c+(this._panX-c)*n,this._panY=u+(this._panY-u)*n,this._scale*=n,this._applyTransform()}_toggleSelectMode(){this._selectMode=!this._selectMode;let n=this.controls.querySelector("#schematic-select");this._selectMode?(n.style.background="var(--accent)",n.style.color="var(--fg-white)",this.svgContainer.style.cursor="default"):(n.style.background="",n.style.color="",this.svgContainer.style.cursor="grab",this._clearCellHighlight())}_handleSelectClick(n){if(!this._svgEl)return;let r=n.target,c=null;for(;r&&r!==this._svgEl;){if(r.tagName==="g"&&r.id&&this._svgIdToInstName.has(r.id)){c=r;break}r=r.parentElement}if(this._clearCellHighlight(),!c)return;let u=this._svgIdToInstName.get(c.id);try{let d=c.getBBox(),b=3,w=document.createElementNS("http://www.w3.org/2000/svg","rect");w.setAttribute("x",d.x-b),w.setAttribute("y",d.y-b),w.setAttribute("width",d.width+b*2),w.setAttribute("height",d.height+b*2),w.setAttribute("fill","none"),w.setAttribute("stroke","#e05a00"),w.setAttribute("stroke-width","1.5"),w.setAttribute("rx","3"),w.id="_schematic_highlight",c.appendChild(w),this._selectedCell=c}catch{}this.controls.querySelector("#schematic-zoom-to").disabled=!1,this.setStatus(`Selected: ${u}`),this._fetchInspect(u)}_fetchInspect(n){let r=this.appState.websocketManager;if(!r)return;console.log("[Schematic] inspect:",n);let c=Pm(this.appState);r.request({type:"schematic_inspect",inst_name:n,use_dbu:this.appState.showDbu}).then(u=>{Z1(this.appState,c)&&(this.appState.updateInspector&&this.appState.updateInspector(u),this.appState.focusComponent&&this.appState.focusComponent("Inspector"),this.appState.refreshOverlay&&this.appState.refreshOverlay())}).catch(u=>{console.error("schematic_inspect failed:",u),this.setStatus(`Inspect error: ${u}`)})}_clearCellHighlight(){if(this._svgEl){let n=this._svgEl.querySelector("#_schematic_highlight");n&&n.remove()}this._selectedCell=null,this.controls.querySelector("#schematic-zoom-to").disabled=!0}_zoomToSelected(){if(!this._selectedCell||!this._svgEl)return;let n=this.svgContainer.getBoundingClientRect(),r=this._selectedCell.getBoundingClientRect(),c=(r.left-n.left-this._panX)/this._scale,u=(r.top-n.top-this._panY)/this._scale,d=r.width/this._scale,b=r.height/this._scale,w=Math.min(n.width/d,n.height/b)*.9;this._scale=w,this._panX=n.width/2-(c+d/2)*w,this._panY=n.height/2-(u+b/2)*w,this._applyTransform()}_applyTransform(){this._svgEl&&(this._svgEl.style.transform=`translate(${this._panX}px, ${this._panY}px) scale(${this._scale})`,this._svgEl.style.transformOrigin="0 0")}fitView(){if(!this._svgEl)return;let n=this.svgContainer.getBoundingClientRect();if(n.width===0||n.height===0)return;let r=this._svgEl.viewBox&&this._svgEl.viewBox.baseVal,c=r&&r.width||this._svgEl.clientWidth||1,u=r&&r.height||this._svgEl.clientHeight||1;this._scale=Math.min(n.width/c,n.height/u)*.95,this._panX=(n.width-c*this._scale)/2,this._panY=(n.height-u*this._scale)/2,this._applyTransform()}initNetlistSVG(){this.netlistsvg=globalThis.netlistsvg,this.skin=globalThis.openroadSkin,this._netlistsvgReady=!!(this.netlistsvg&&this.skin),this._netlistsvgReady&&console.log("NetlistSVG ready."),this.setStatus(this._unreadyStatus()??R3t)}_unreadyStatus(){return this._netlistsvgReady?null:ua(this.appState)?"The schematic is not available in saved reports.":"Init error: netlistsvg or its skin is missing from the page."}syncCone(n={}){let r=this.controls.querySelector("#schematic-fanin-depth"),c=this.controls.querySelector("#schematic-fanout-depth"),u=(d,b,w)=>{if(!d)return;let _=parseInt(d.max,10)||10;b===!1?d.value=0:w!==void 0&&(d.value=w>0?Math.min(w,_):_)};u(r,n.fanin,n.fanin_depth),u(c,n.fanout,n.fanout_depth),this.refresh(),this.appState.focusComponent&&this.appState.focusComponent("SchematicWidget")}refresh(){if(!this._netlistsvgReady){this.setStatus(this._unreadyStatus());return}let n=this.appState.selectedInstanceName;if(!n){this.setStatus(R3t);return}let r=this.appState.websocketManager;if(!r){this.setStatus("Waiting for server connection\u2026");return}this.setStatus(`Loading schematic for ${n}\u2026`);let c=parseInt(this.controls.querySelector("#schematic-fanin-depth").value,10),u=parseInt(this.controls.querySelector("#schematic-fanout-depth").value,10),d=isNaN(c)?1:c,b=isNaN(u)?1:u;r.readyPromise.then(()=>{r.request({type:"schematic_cone",inst_name:n,fanin_depth:d,fanout_depth:b}).then(w=>{let _=w.modules&&w.modules.top&&w.modules.top.cells;if(!_||Object.keys(_).length===0){this.setStatus("No cells found for selected instance.");return}this.renderNetlist(w)}).catch(w=>{this.setStatus(`Error: ${w}`)})})}setStatus(n){this.controls.querySelector("#schematic-status").textContent=n}_exportSvg(){if(!this._svgEl){this.setStatus("No schematic to export.");return}let n=X5e(this._svgEl);s3t(new Blob([n],{type:"image/svg+xml;charset=utf-8"}),"schematic.svg")}async _exportPng(){if(!this._svgEl){this.setStatus("No schematic to export.");return}try{let n=await Y5e(this._svgEl,2);hk(n,"schematic.png")}catch{this.setStatus("PNG export failed.")}}async _copyImage(){if(!this._svgEl){this.setStatus("No schematic to export.");return}try{let n=await Y5e(this._svgEl,2),r=await Hhe(n);this.setStatus(r?"Schematic copied to clipboard.":"Clipboard not available.")}catch{this.setStatus("Copy failed.")}}async renderNetlist(n){try{this.setStatus("Rendering\u2026"),typeof window<"u"&&(window.__lastSchematic=n);let r=rpn(n),c,u=this.netlistsvg.render(this.skin,r);if(u&&typeof u.then=="function"?c=await u:c=await new Promise((w,_)=>{this.netlistsvg.render(this.skin,r,(x,T)=>{x?_(x):w(T)})}),typeof c!="string"||!c.includes("requestAnimationFrame(()=>this.fitView()));let b=Object.keys(n.modules.top.cells).length;this.setStatus(`${b} cell${b!==1?"s":""}`)}catch(r){console.error("NetlistSVG render failed:",r),this.setStatus(`Render error: ${r.message||r}`)}}_applyPinLabels(n){if(!this._svgEl)return;let r="http://www.w3.org/2000/svg",c="https://github.com/nturley/netlistsvg",u=n.modules&&n.modules.top&&n.modules.top.cells||{},d=(b,w)=>b.getAttribute("s:"+w)??b.getAttributeNS(c,w);for(let[b,w]of Object.entries(u)){let _=w.port_labels;if(!_)continue;let x=this._svgEl.querySelector("#"+CSS.escape("cell_"+b))||this._svgEl.querySelector("#"+CSS.escape(b));if(!x)continue;let T=w.port_directions||{};for(let M of Array.from(x.children)){if(M.tagName!=="g")continue;let L=d(M,"pid");if(!L||!(L in _))continue;let I=parseFloat(d(M,"x")),D=parseFloat(d(M,"y"));if(!isFinite(I)||!isFinite(D))continue;let F=document.createElementNS(r,"text");T[L]==="input"?(F.setAttribute("class","inputPortLabel"),F.setAttribute("x",I-3)):F.setAttribute("x",I+4),F.setAttribute("y",D-4),F.setAttribute("style","font-size:5px"),F.setAttribute("pointer-events","none"),F.textContent=_[L],x.appendChild(F)}}}_scopeSkinStyles(){if(!this._svgEl)return;let n=".schematic-widget",r=c=>{for(let u of c)u.selectorText?u.selectorText=epn(u.selectorText,n):u.cssRules&&r(u.cssRules)};for(let c of this._svgEl.querySelectorAll("style")){let u=c.sheet;if(u)try{r(u.cssRules)}catch{continue}}}};function epn(s,n){return s.split(",").map(r=>{let c=r.trim();if(!c)return"";let u=c.charAt(n.length);return c.startsWith(n)&&(u===""||!/[\w-]/.test(u))?c:`${n} ${c}`}).filter(Boolean).join(", ")}var I3t={and:"$_AND_",nand:"$_NAND_",or:"$_OR_",nor:"$_NOR_",xor:"$_XOR_",xnor:"$_XNOR_",not:"$_NOT_",buf:"$_BUF_"},tpn=new Set(["aoi21","aoi22","aoi211","aoi221","aoi222","aoi33","oai21","oai22","oai211","oai221","oai222","oai33"]),npn=new Set(["and3","and4","or3","or4","nand3","nand4","nor3","nor4"]),D3t=["A","B","C","D","E","F"];function ipn(s){let n=s&&s.gate_kind;if(!n)return s;let r=s.port_directions||{},c=null,u=[];for(let[M,L]of Object.entries(r))L==="output"&&c===null?c=M:L==="input"&&u.push(M);let d,b={};if(n==="aoi"||n==="oai"){let M=Array.isArray(s.gate_terms)?s.gate_terms:[];if(!M.length)return s;let L=M.map(F=>F.length);if(d=n+L.slice().sort((F,O)=>O-F).join(""),!tpn.has(d))return s;let I=M.map(F=>F.slice()).sort((F,O)=>F.length-O.length),D=0;for(let F of I)for(let O of F)b[O]=D3t[D]||"I"+D,D++}else{let M=u.length;if(n==="not"||n==="buf")d=I3t[n];else if(M<=2)d=I3t[n];else if(d=n+M,!npn.has(d))return s;if(!d)return s;u.forEach((L,I)=>{b[L]=D3t[I]||"I"+I})}c!==null&&(b[c]="Y");let w=s.connections||{},_={},x={};for(let[M,L]of Object.entries(w))b[M]&&(_[b[M]]=L);for(let[M,L]of Object.entries(r))b[M]&&(x[b[M]]=L);let T={};for(let[M,L]of Object.entries(b))T[L]=M;return{...s,type:d,connections:_,port_directions:x,port_labels:T}}function rpn(s){let n=s&&s.modules&&s.modules.top;if(!n||!n.cells)return s;let r={};for(let[c,u]of Object.entries(n.cells))r[c]=ipn(u);return{...s,modules:{...s.modules,top:{...n,cells:r}}}}var ude=class{constructor(n,r,c){this._app=n,this._redrawAllLayers=r,this._refreshOverlay=c||r,this._categories=[],this._activeCategory="",this._markerTree=null,this._expandedNodes=new Set,this._build(),this._app.websocketManager.readyPromise.then(()=>this.refresh())}_build(){let n=document.createElement("div");n.className="drc-widget";let r=document.createElement("div");r.className="drc-toolbar",this._categorySelect=document.createElement("select"),this._categorySelect.className="drc-category-select",r.appendChild(this._categorySelect),this._loadBtn=document.createElement("button"),this._loadBtn.className="or-btn or-btn-sm",this._loadBtn.textContent="Load...",r.appendChild(this._loadBtn),n.appendChild(r),this._infoBar=document.createElement("div"),this._infoBar.className="drc-info-bar",n.appendChild(this._infoBar),this._treeContainer=document.createElement("div"),this._treeContainer.className="drc-tree-container",n.appendChild(this._treeContainer),this.element=n,this._bindEvents()}_bindEvents(){this._categorySelect.addEventListener("change",()=>{this._activeCategory=this._categorySelect.value,this._loadMarkers()}),this._loadBtn.addEventListener("click",()=>{this._showLoadDialog()})}_loadCategories(){return this._app.websocketManager.request({type:"drc_categories"}).then(n=>{this._categories=n.categories||[],this._renderCategorySelect()}).catch(n=>{console.error("Failed to load DRC categories:",n)})}refresh(){this._loadCategories().then(()=>{!this._activeCategory&&this._categories.length>0&&(this._activeCategory=this._categories[0].name,this._categorySelect.value=this._activeCategory),this._activeCategory&&this._loadMarkers()})}_renderCategorySelect(){let n=this._categorySelect,r=n.value;n.innerHTML="";let c=document.createElement("option");c.value="",c.textContent="(none)",n.appendChild(c);for(let u of this._categories){let d=document.createElement("option");d.value=u.name,d.textContent=`${u.name} (${u.count})`,n.appendChild(d)}this._activeCategory&&this._categories.some(u=>u.name===this._activeCategory)?n.value=this._activeCategory:r&&this._categories.some(u=>u.name===r)?(n.value=r,this._activeCategory=r):this._activeCategory=""}_loadMarkers(){if(!this._activeCategory){this._markerTree=null,this._treeContainer.innerHTML="",this._infoBar.textContent="",this._refreshOverlay();return}this._treeContainer.innerHTML='
Loading...
',this._app.websocketManager.request({type:"drc_markers",category:this._activeCategory}).then(n=>{this._markerTree=n,this._renderTree(),this._refreshOverlay()}).catch(n=>{this._treeContainer.innerHTML="";let r=document.createElement("div");r.className="drc-error",r.textContent=`Error: ${n}`,this._treeContainer.appendChild(r),console.error("Failed to load DRC markers:",n)})}_renderTree(){if(this._treeContainer.innerHTML="",!this._markerTree)return;if(this._markerTree.error){let b=document.createElement("div");b.className="drc-error",b.textContent=this._markerTree.error,this._treeContainer.appendChild(b);return}let n=this._markerTree.total_count||0;this._infoBar.textContent=`${n} total violation${n!==1?"s":""}`;let r=this._markerTree.name||this._activeCategory,c=this._markerTree.subcategories||[],u=this._markerTree.markers||[];if(c.length===0&&u.length===0){this._treeContainer.innerHTML='
No violations
';return}let d=document.createElement("div");d.className="drc-tree",u.length>0&&d.appendChild(this._buildCategoryNode({name:r||"Markers",count:u.length,markers:u},[]));for(let b of c)d.appendChild(this._buildCategoryNode(b,[r]));this._treeContainer.appendChild(d)}_buildCategoryNode(n,r=[]){let c=[...r,n.name],u=document.createElement("div");u.className="drc-tree-node";let d=document.createElement("div");d.className="drc-tree-header";let b=document.createElement("span");b.className="drc-toggle";let w=n.subcategories&&n.subcategories.length>0||n.markers&&n.markers.length>0,_=JSON.stringify(c),x=this._expandedNodes.has(_);b.textContent=w?x?"\u25BC":"\u25B6":" ",d.appendChild(b);let T=document.createElement("input");T.type="checkbox",T.checked=this._allMarkersVisible(n),T.className="drc-visibility-check",T.addEventListener("change",D=>{D.stopPropagation(),this._toggleCategoryVisibility(n,T.checked,c)}),d.appendChild(T);let M=document.createElement("span");M.className="drc-category-label",M.textContent=n.name,d.appendChild(M);let L=document.createElement("span");L.className="drc-count",L.textContent=`${n.count} markers`,d.appendChild(L),u.appendChild(d);let I=document.createElement("div");if(I.className="drc-tree-children",I.style.display=x?"":"none",n.subcategories)for(let D of n.subcategories)I.appendChild(this._buildCategoryNode(D,c));if(n.markers)for(let D of n.markers)I.appendChild(this._buildMarkerNode(D));return u.appendChild(I),w&&(d.addEventListener("click",D=>{if(D.target===T)return;let F=I.style.display!=="none";I.style.display=F?"none":"",b.textContent=F?"\u25B6":"\u25BC",F?this._expandedNodes.delete(_):this._expandedNodes.add(_)}),d.style.cursor="pointer"),u}_buildMarkerNode(n){let r=document.createElement("div");r.className="drc-marker-row",r.dataset.markerId=n.id,n.visited||r.classList.add("drc-unvisited");let c=document.createElement("input");c.type="checkbox",c.checked=n.visible,c.className="drc-visibility-check",c.addEventListener("change",b=>{b.stopPropagation(),n.visible=c.checked,this._updateMarker(n.id,"visible",c.checked)}),r.appendChild(c);let u=document.createElement("span");u.className="drc-marker-index",u.textContent=n.index,r.appendChild(u);let d=document.createElement("span");if(d.className="drc-marker-name",d.textContent=n.name,n.layer&&(d.title=`Layer: ${n.layer}`),r.appendChild(d),n.layer){let b=document.createElement("span");b.className="drc-layer-badge",b.textContent=n.layer,r.appendChild(b)}return r.addEventListener("click",b=>{b.target!==c&&this._highlightMarker(n)}),r.addEventListener("dblclick",b=>{b.target!==c&&this._highlightMarker(n,!0)}),r}highlightMarkerById(n,r=!1){let c=this._findMarkerById(n);c&&this._highlightMarker(c,r)}_findMarkerById(n){let r=c=>{if(!c)return null;if(c.markers){for(let u of c.markers)if(u.id===n)return u}if(c.subcategories)for(let u of c.subcategories){let d=r(u);if(d)return d}return null};return r(this._markerTree)}_highlightMarker(n,r=!1){this._app.websocketManager.request({type:"drc_highlight",marker_id:n.id,open_inspector:r}).then(c=>{if(c.ok&&c.bbox){n.visited=!0;let u=this._treeContainer.querySelector(`.drc-marker-row[data-marker-id="${n.id}"]`);u&&u.classList.remove("drc-unvisited"),this._zoomToBBox(c.bbox),this._refreshOverlay(),r&&(c.select_id!=null&&this._app.navigateInspector&&this._app.navigateInspector(c.select_id),this._app.focusComponent&&this._app.focusComponent("Inspector"))}}).catch(c=>{console.error("Failed to highlight DRC marker:",c)})}_zoomToBBox(n){if(!this._app.designScale||!this._app.view)return;let[r,c,u,d]=n,b=u-r,w=d-c,x=10*this._app.getDbuPerMicron(),T=2*Math.max(b,w),M=Math.min(x,T);this._app.view.fitWorldRect(X1(r-M,c-M,u+M,d+M,this._app.designScale,this._app.designOriginX,this._app.designOriginY))}_updateMarker(n,r,c){this._app.websocketManager.request({type:"drc_update_marker",marker_id:n,field:r,value:!!c}).then(()=>{this._refreshOverlay(),r==="visible"&&(this._update3DHighlights(),c&&this._flashHighlight())}).catch(u=>{console.error("Failed to update DRC marker:",u)})}_flashHighlight(){this._app.view?.flashTiles()}_update3DHighlights(){let n=this._app.threeDViewerWidget;if(!n)return;let r=[];this._collectVisibleMarkers(this._markerTree,r),r.length>0?n.highlightDRC(r):n.clearHighlightDRC()}_collectVisibleMarkers(n,r){if(n){if(n.markers)for(let c of n.markers)c.visible&&r.push(c);if(n.subcategories)for(let c of n.subcategories)this._collectVisibleMarkers(c,r)}}_setMarkersVisible(n,r){if(n){if(n.markers)for(let c of n.markers)c.visible=r;if(n.subcategories)for(let c of n.subcategories)this._setMarkersVisible(c,r)}}_snapshotMarkerVisibility(n,r=new Map){if(!n)return r;if(n.markers)for(let c of n.markers)r.set(c.id,c.visible);if(n.subcategories)for(let c of n.subcategories)this._snapshotMarkerVisibility(c,r);return r}_restoreMarkerVisibility(n,r){if(n){if(n.markers)for(let c of n.markers)r.has(c.id)&&(c.visible=r.get(c.id));if(n.subcategories)for(let c of n.subcategories)this._restoreMarkerVisibility(c,r)}}_allMarkersVisible(n){if(n.markers){for(let r of n.markers)if(!r.visible)return!1}if(n.subcategories){for(let r of n.subcategories)if(!this._allMarkersVisible(r))return!1}return!0}_toggleCategoryVisibility(n,r,c){let u=this._snapshotMarkerVisibility(n);this._setMarkersVisible(n,r),this._renderTree(),this._app.websocketManager.request({type:"drc_update_category_visibility",category:n.name,path:c||[n.name],visible:!!r}).then(()=>{this._refreshOverlay(),this._update3DHighlights(),r&&this._flashHighlight()}).catch(d=>{console.error("Failed to update category visibility:",d),this._restoreMarkerVisibility(n,u),this._renderTree()})}_showLoadDialog(){new nDe(this._app,r=>{this._activeCategory=r,this._loadCategories().then(()=>{this._categorySelect.value=this._activeCategory,this._loadMarkers()})}).open()}selectCategory(n){this._activeCategory=n,this._categorySelect.value=n,this._loadMarkers()}},nDe=class{constructor(n,r){this._app=n,this._onLoaded=r,this._currentPath="",this._disposers=[],this._closed=!1}open(){this._overlay=document.createElement("div"),this._overlay.className="modal-overlay",this._overlay.innerHTML=` + `,document.body.appendChild(r);function c(d){d.key==="Escape"&&u()}let u=()=>{r.remove(),document.removeEventListener("keydown",c)};return r.addEventListener("click",d=>{d.target===r&&u()}),document.addEventListener("keydown",c),{overlay:r,body:r.querySelector(".modal-body"),errorDiv:r.querySelector(".modal-error"),buttons:r.querySelector(".modal-buttons"),close:u}}function g2(s,n){s.textContent=n,s.style.display=n?"":"none"}function AO(s,n,{primary:r=!1}={}){let c=document.createElement("button");return c.textContent=n,c.className="or-btn"+(r?" or-btn-primary":""),s.appendChild(c),c}function sde(s){return"{"+String(s)+"}"}function P3t(s){let n=A3t("Global Connect","gc-dialog"),r=document.createElement("div");r.className="gc-table",n.body.appendChild(r);let c=document.createElement("div");c.className="gc-form";let u=document.createElement("input");u.placeholder="Instance pattern (regex)",u.value=".*";let d=document.createElement("input");d.placeholder="Pin pattern (regex)";let b=document.createElement("select"),w=document.createElement("select"),_=document.createElement("span");_.innerHTML='',c.append(MT("Instance",u),MT("Pin",d),MT("Net",b),MT("Region",w),_);let x=AO(c,"Add rule");n.body.appendChild(c);function T(){let D=d.value.trim()!==""&&b.value!=="";for(let F of[u,d])try{new RegExp(F.value),F.classList.remove("gc-invalid")}catch{F.classList.add("gc-invalid"),D=!1}x.disabled=!D}u.addEventListener("input",T),d.addEventListener("input",T),b.addEventListener("change",T);function M(){s.websocketManager.request({type:"global_connect_info"}).then(D=>{r.innerHTML='
InstancePinNetRegion
',(D.rules||[]).forEach(F=>{let O=document.createElement("div");O.className="gc-row",O.innerHTML=`${oH(F.inst)}${oH(F.pin)}${oH(F.net)}${oH(F.region||"All")}`;let z=document.createElement("button");z.className="or-btn or-btn-sm or-btn-icon",z.textContent="\u2715",z.title="Delete rule",z.addEventListener("click",()=>{s.websocketManager.request({type:"global_connect_delete",inst:F.inst,pin:F.pin,net:F.net,region:F.region||""}).then(M).catch(Z=>g2(n.errorDiv,String(Z)))}),O.appendChild(z),r.appendChild(O)}),eDe(b,D.nets||[]),eDe(w,["All",...D.regions||[]]),T()}).catch(D=>g2(n.errorDiv,String(D)))}x.addEventListener("click",()=>{let D=c.querySelector('input[name="gc-pg"]:checked').value,F=`add_global_connection -net ${sde(b.value)} -inst_pattern ${sde(u.value||".*")} -pin_pattern ${sde(d.value)} -${D}`;w.value&&w.value!=="All"&&(F+=` -region ${sde(w.value)}`),C3t(s,F,n.errorDiv,"Rule added.",M)}),AO(n.buttons,"Apply (force)").addEventListener("click",()=>{s.websocketManager.request({type:"global_connect_apply",force:!0}).then(D=>{if(!D.had_rules){g2(n.errorDiv,"No global-connect rules defined \u2014 add a rule first.");return}g2(n.errorDiv,`Connected ${D.connected} pin(s).`),s.scheduleRedrawAllLayers&&s.scheduleRedrawAllLayers(),M()}).catch(D=>g2(n.errorDiv,D.message||String(D)))}),AO(n.buttons,"Clear all").addEventListener("click",()=>C3t(s,"clear_global_connect",n.errorDiv,"Rules cleared.",M)),AO(n.buttons,"Close").addEventListener("click",n.close),M()}function C3t(s,n,r,c,u){s.websocketManager.request({type:"tcl_eval",cmd:n}).then(d=>{if(d.is_error){g2(r,d.output||d.result||"Command failed");return}g2(r,c||""),s.scheduleRedrawAllLayers&&s.scheduleRedrawAllLayers(),u&&u()}).catch(d=>g2(r,d.message||String(d)))}function L3t(s,n){let r=A3t(`Insert Buffer \u2014 ${oH(n)}`,"buf-dialog"),c=AO(r.buttons,"Insert",{primary:!0});c.disabled=!0,AO(r.buttons,"Cancel").addEventListener("click",r.close),s.websocketManager.request({type:"buffer_info",net:n}).then(d=>{if(!d.can_buffer){r.body.textContent=d.error||"This net has multiple drivers and cannot be buffered.";return}epn(s,r,n,d,c)}).catch(d=>{r.body.textContent=String(d)})}function epn(s,n,r,c,u){let d=document.createElement("div");d.className="buf-pins";let b=c.drivers||[],w=c.loads||[],_=new Set;function x(){d.innerHTML="";let D=(F,O)=>{let z=document.createElement("label");z.className="buf-pin";let Z=document.createElement("input");Z.type="checkbox",Z.checked=_.has(F.id),Z.addEventListener("change",()=>{if(Z.checked){if(O)_.clear();else for(let H of b)_.delete(H.id);_.add(F.id)}else _.delete(F.id);x(),I()}),z.append(Z,document.createTextNode(" "+F.label)),d.appendChild(z)};b.forEach(F=>D(F,!0)),w.forEach(F=>D(F,!1))}b.length&&_.add(b[0].id),x();let T=document.createElement("select");eDe(T,c.masters||[]);let M=document.createElement("input");M.placeholder="Optional: new buffer name";let L=document.createElement("input");L.placeholder="Optional: new net name",n.body.append(MT("Pins to buffer",d),MT("Buffer master",T),MT("Buffer name",M),MT("Net name",L));function I(){u.disabled=_.size===0||!T.value}T.addEventListener("change",I),I(),u.addEventListener("click",()=>{let D=new Set(b.map(z=>z.id)),F=[..._],O=F.some(z=>D.has(z))?"driver":"loads";s.websocketManager.request({type:"insert_buffer",net:r,mode:O,pins:F,master:T.value,buf_name:M.value.trim(),net_name:L.value.trim()}).then(z=>{if(z.is_error||z.ok===!1){g2(n.errorDiv,z.error||z.result||"Insertion failed");return}n.close(),z.inst&&(s.selectedInstanceName=z.inst),s.scheduleRedrawAllLayers&&s.scheduleRedrawAllLayers()}).catch(z=>g2(n.errorDiv,z.message||String(z)))})}function MT(s,n){let r=document.createElement("label");r.className="edit-field";let c=document.createElement("span");return c.textContent=s,r.append(c,n),r}function eDe(s,n){let r=s.value;s.innerHTML="";for(let c of n){let u=document.createElement("option");u.value=c,u.textContent=c,s.appendChild(u)}n.includes(r)&&(s.value=r)}function oH(s){return String(s??"").replace(/&/g,"&").replace(//g,">")}var k3t="#00ffff",tpn="#ffff00",R3t="#ffffff",npn=4,pk=0,tDe=1,aH=2,ode=class{constructor(n,r,c,u){this._app=n,this._visibility=r,this._updateInspector=c,this._focusComponent=u,this._state=pk,this._rulers=[],this._nextId=0,this._pt0=null,this._selectedRulerId=null,this._ctrlHeld=!1,this._shiftHeld=!1,this._snapTimer=null,this._lastSnapResult=null,this._snapShapes=null,this._preview=null,n.view?.on("zoom",()=>this._renderRulerShapes())}isActive(){return this._state!==pk}updateVisibility(){this._renderAll(),this._drawTransient()}_shown(){return this._visibility.rulers!==!1}toggleRulerMode(){this._state===pk?this._enterFirstPoint():this.cancelRulerBuild()}cancelRulerBuild(){this._state=pk,this._pt0=null,this._lastSnapResult=null,this._clearTransient(),this._setCursor(!1)}clearAllRulers(){this._rulers=[],this._selectedRulerId=null,this._renderAll(),this._clearTransient(),this._state!==pk&&this.cancelRulerBuild()}_enterFirstPoint(){this._state=tDe,this._pt0=null,this._lastSnapResult=null,this._setCursor(!0)}_enterMeasuring(n){this._state=aH,this._pt0=n}_toDbu(n){return kv(n[0],n[1],this._app.designScale,this._app.designOriginX,this._app.designOriginY)}_toWorld(n,r){return Lv(n,r,this._app.designScale,this._app.designOriginX,this._app.designOriginY)}handleMouseMove(n,r){if(this._state===pk)return;this._ctrlHeld=r.ctrlKey||r.metaKey,this._shiftHeld=r.shiftKey;let c=this._toDbu(n);this._snapTimer&&clearTimeout(this._snapTimer),this._snapTimer=setTimeout(()=>{this._requestSnap(c.dbuX,c.dbuY)},50)}handleMapClick(n,r){if(this._state===pk)return;this._ctrlHeld=r.ctrlKey||r.metaKey,this._shiftHeld=r.shiftKey;let c=this._toDbu(n),u=this._getSnappedPoint(c.dbuX,c.dbuY);this._state===tDe?this._enterMeasuring(u):this._state===aH&&(this._createRuler(this._pt0,u),this._state=tDe,this._pt0=null,this._clearTransient(),this._lastSnapResult=null)}async _requestSnap(n,r){let c=this._app;if(!c.websocketManager||!c.designScale)return;if(this._ctrlHeld){this._lastSnapResult=null,this._snapShapes=null,this._updatePreview(n,r);return}let d=c.techData?.dbu_per_micron||1e3,b=c.view.getZoom(),w=Math.pow(2,Math.max(0,b)),_=1/(c.designScale*w),x=Math.max(Math.round(10*_),10),T=!0,M=!0;if(this._shiftHeld)T=!0,M=!0;else if(this._state===aH&&this._pt0){let I=Math.abs(n-this._pt0.x),D=Math.abs(r-this._pt0.y);I>D?(T=!1,M=!0):D>I&&(T=!0,M=!1)}let L={};for(let[I,D]of Object.entries(this._visibility))L[I]=!!D;try{let I=await c.websocketManager.request({type:"snap",dbu_x:n,dbu_y:r,radius:d,point_threshold:x,horizontal:!!T,vertical:!!M,visible_layers:[...c.visibleLayerNames],...L});this._lastSnapResult=I,this._updateSnapIndicator(I),this._updatePreview(n,r)}catch{this._lastSnapResult=null,this._clearSnap()}}_getSnappedPoint(n,r){if(this._ctrlHeld)return{x:n,y:r};let c=this._lastSnapResult,u;if(c?.found&&c.is_point)u={x:c.edge[0][0],y:c.edge[0][1]};else if(c?.found){let d=c.edge;d[0][1]===d[1][1]?u={x:n,y:d[0][1]}:u={x:d[0][0],y:r}}else u={x:n,y:r};if(!this._shiftHeld&&this._state===aH&&this._pt0){let d=Math.abs(u.x-this._pt0.x),b=Math.abs(u.y-this._pt0.y);dthis._toWorld(u.x,u.y))}}_rulerShapes(n){let r=n.id===this._selectedRulerId,c=Z1(r?tpn:k3t),{joinPt:u,points:d}=this._rulerPath(n),b=[{kind:"path",points:d,stroke:c,width:2}],w=this._app.view.getZoom(),_=Math.pow(2,Math.max(0,w)),T=8*(1/(this._app.designScale*_)),M=(L,I,D)=>{let F=Math.sqrt(I*I+D*D);if(F===0)return;let O=-D/F,z=I/F;b.push({kind:"path",stroke:c,width:2,points:[this._toWorld(L.x+O*T,L.y+z*T),this._toWorld(L.x-O*T,L.y-z*T)]})};if(u)M(n.pt0,u.x-n.pt0.x,u.y-n.pt0.y),M(n.pt1,n.pt1.x-u.x,n.pt1.y-u.y);else{let L=n.pt1.x-n.pt0.x,I=n.pt1.y-n.pt0.y;M(n.pt0,L,I),M(n.pt1,L,I)}return b}_renderAll(){this._renderRulerShapes(),this._renderRulerLabels()}_renderRulerShapes(){let n=this._app.view;!n||!this._app.designScale||n.setOverlay("rulers",this._shown()?this._rulers.flatMap(r=>this._rulerShapes(r)):null,{order:bp.ruler})}_renderRulerLabels(){let n=this._app.view;if(!(!n||!this._app.designScale)&&(n.clearMarkers("ruler-labels"),!!this._shown()))for(let r of this._rulers){let{joinPt:c,points:u}=this._rulerPath(r),d=c?u[1]:[(u[0][0]+u[1][0])/2,(u[0][1]+u[1][1])/2],b=this._computeDistance(r.pt0,r.pt1,r.euclidian);n.addMarker("ruler-labels",r.id,d,this._labelElement(this._formatDistance(b)))}}handleRulerClick(n){let r=this._app.view;if(!r||!this._shown()||this._rulers.length===0)return!1;let c=r.project(n);for(let u of this._rulers){let d=this._rulerPath(u).points.map(b=>r.project(b));for(let b=0;b+1x.id===n);if(!r)return;Pm(this._app);let c=Math.abs(r.pt1.x-r.pt0.x),u=Math.abs(r.pt1.y-r.pt0.y),d=r.euclidian?Math.sqrt(c*c+u*u):c+u,b=x=>this._app.formatDbu(x,!0),w=x=>this._app.parseDbu(x),_={type:"Ruler",name:r.name,bbox:[Math.min(r.pt0.x,r.pt1.x),Math.min(r.pt0.y,r.pt1.y),Math.max(r.pt0.x,r.pt1.x),Math.max(r.pt0.y,r.pt1.y)],properties:[{name:"Name",value:r.name,editable:!0},{name:"Label",value:r.label||"",editable:!0},{name:"Point 0 - x",value:b(r.pt0.x),editable:!0},{name:"Point 0 - y",value:b(r.pt0.y),editable:!0},{name:"Point 1 - x",value:b(r.pt1.x),editable:!0},{name:"Point 1 - y",value:b(r.pt1.y),editable:!0},{name:"Delta x",value:b(c)},{name:"Delta y",value:b(u)},{name:"Length",value:b(d)},{name:"Euclidian",value:r.euclidian?"True":"False",editable:!0,editor:{type:"bool"}}],onPropertyChange:(x,T)=>{switch(x){case"Name":r.name=T;break;case"Label":r.label=T;break;case"Point 0 - x":{let M=w(T);M!==null&&(r.pt0.x=M);break}case"Point 0 - y":{let M=w(T);M!==null&&(r.pt0.y=M);break}case"Point 1 - x":{let M=w(T);M!==null&&(r.pt1.x=M);break}case"Point 1 - y":{let M=w(T);M!==null&&(r.pt1.y=M);break}case"Euclidian":r.euclidian=T.trim().toLowerCase()==="true";break}this._renderAll(),this._selectRuler(r.id)}};this._updateInspector(_),this._focusComponent("Inspector"),requestAnimationFrame(()=>{let x=this._app.inspectorEl?.querySelector(".inspector-toolbar");if(!x)return;let T=document.createElement("button");T.className="or-btn or-btn-icon",T.title="Delete ruler",T.innerHTML='',T.addEventListener("click",()=>{this.deleteRuler(n)}),x.appendChild(T)})}deleteRuler(n){let r=this._rulers.findIndex(c=>c.id===n);r!==-1&&(this._rulers.splice(r,1),this._renderAll(),this._selectedRulerId===n&&(this._selectedRulerId=null,this._updateInspector(null)))}_getManhattanJoinPt(n,r){return{x:r.x,y:n.y}}_computeDistance(n,r,c=!0){let u=Math.abs(r.x-n.x),d=Math.abs(r.y-n.y);return c?Math.sqrt(u*u+d*d):u+d}_formatDistance(n){return this._app.formatDistance(n)}_setCursor(n){this._app.view?.setCursorMode("ruler",n)}_clearTransient(){this._preview=null,this._snapShapes=null,this._drawTransient()}_clearSnap(){this._snapShapes=null,this._drawTransient()}};function ipn(s,n,r){let c=r[0]-n[0],u=r[1]-n[1],d=c*c+u*u,b=d>0?((s[0]-n[0])*c+(s[1]-n[1])*u)/d:0;return b=Math.max(0,Math.min(1,b)),Math.hypot(s[0]-(n[0]+b*c),s[1]-(n[1]+b*u))}var ade="label-handles",I3t=3,cde=class{constructor(n,r,c,u){this._app=n,this._visibility=r,this._updateInspector=c,this._focusComponent=u,this._labels=[],this._anchors=[],this._mode=!1,this._selectedName=null}isActive(){return this._mode}updateVisibility(){this._app.view?.setMarkerGroupVisible(ade,!!this._visibility.labels)}toggleLabelMode(){this._mode=!this._mode,this._setCursor(this._mode)}cancelLabelMode(){this._mode=!1,this._setCursor(!1)}_setCursor(n){this._app.view?.setCursorMode("label",n)}_wm(){return this._app.websocketManager}_applyLabels(n){this._labels=n||[],this._renderHandles()}_refresh(n){this._applyLabels(n&&n.labels),this._app.refreshOverlay()}applyRemoteLabels(n){this._applyLabels(n),this._selectedName&&!this._labels.some(r=>r.name===this._selectedName)&&(this._selectedName=null,this._updateInspector(null),this._renderHandles()),this._app.refreshOverlay()}_updateLabel(n,r){return this._wm().request({type:"update_label",name:n,...r})}async reload(){let n=this._wm();if(n)try{let r=await n.request({type:"list_labels"});this._anchors=r.anchors||[],this._applyLabels(r.labels)}catch{this._applyLabels([])}}async handleMapClick(n,r){let c=window.prompt("Label text:");if(this._mode=!1,this._setCursor(!1),!!c)try{let u=await this._wm().request({type:"add_label",x:Math.round(n),y:Math.round(r),text:c});this._refresh(u)}catch(u){console.error("add_label failed:",u)}}_renderHandles(){let n=this._app.view;if(!n)return;n.clearMarkers(ade);let r=this._app;if(r.designScale)for(let c of this._labels){let u=document.createElement("div");u.className="label-handle"+(c.name===this._selectedName?" label-handle-selected":""),u.title=c.text,this._installDrag(u,c),n.addMarker(ade,c.name,Lv(c.x,c.y,r.designScale,r.designOriginX,r.designOriginY),u,{center:!0})}}_installDrag(n,r){let c=this._app.view,u=w=>{let _=c.getContainer().getBoundingClientRect();return c.unproject([w.clientX-_.left,w.clientY-_.top])},d=null;n.addEventListener("pointerdown",w=>{w.button===0&&(w.stopPropagation(),w.preventDefault(),n.setPointerCapture?.(w.pointerId),d={x:w.clientX,y:w.clientY,moved:!1})}),n.addEventListener("pointermove",w=>{d&&((Math.abs(w.clientX-d.x)>I3t||Math.abs(w.clientY-d.y)>I3t)&&(d.moved=!0),d.moved&&c.moveMarker(ade,r.name,u(w)))});let b=(w,_)=>{if(!d)return;let x=d;if(d=null,n.releasePointerCapture?.(w.pointerId),!_)this._renderHandles();else if(!x.moved)this._select(r.name);else{let T=this._app,[M,L]=u(w),{dbuX:I,dbuY:D}=kv(M,L,T.designScale,T.designOriginX,T.designOriginY);this._commitMove(r,Math.round(I),Math.round(D))}};n.addEventListener("pointerup",w=>b(w,!0)),n.addEventListener("pointercancel",w=>b(w,!1)),n.addEventListener("click",w=>w.stopPropagation())}async _commitMove(n,r,c){try{let u=await this._updateLabel(n.name,{x:r,y:c,text:n.text,size:n.size||0,anchor:n.anchor||"center",color:n.color});this._refresh(u)}catch(u){console.error("move label failed:",u)}}_select(n){this._selectedName=n,this._renderHandles();let r=this._labels.find(d=>d.name===n);if(!r)return;let c=d=>this._app.formatDbu(d,!0),u={type:"Label",name:r.name,bbox:[r.x,r.y,r.x,r.y],properties:[{name:"Name",value:r.name},{name:"Text",value:r.text,editable:!0},{name:"x",value:c(r.x)},{name:"y",value:c(r.y)},{name:"Font size",value:String(r.size||0),editable:!0},{name:"Anchor",value:r.anchor||"center",editable:!0,editor:{type:"list",options:this._anchors}}],onPropertyChange:(d,b)=>{let w={text:r.text,size:r.size||0,anchor:r.anchor||"center"};d==="Text"?w.text=b:d==="Font size"?w.size=parseInt(b,10)||0:d==="Anchor"&&(w.anchor=b.trim()),this._edit(r,w)}};this._updateInspector(u),this._focusComponent("Inspector"),requestAnimationFrame(()=>{let d=this._app.inspectorEl?.querySelector(".inspector-toolbar");if(!d||d.querySelector(".delete-label-btn"))return;let b=document.createElement("button");b.className="or-btn or-btn-icon delete-label-btn",b.title="Delete label",b.innerHTML='',b.addEventListener("click",()=>this.deleteLabel(n)),d.appendChild(b)})}async _edit(n,r){try{let c=await this._updateLabel(n.name,{x:n.x,y:n.y,text:r.text,size:r.size,anchor:r.anchor,color:n.color});this._refresh(c),this._select(n.name)}catch(c){console.error("edit label failed:",c)}}async deleteLabel(n){try{let r=await this._wm().request({type:"delete_label",name:n});this._selectedName===n&&(this._selectedName=null,this._updateInspector(null)),this._refresh(r)}catch(r){console.error("delete_label failed:",r)}}async clearAllLabels(){try{let n=await this._wm().request({type:"clear_labels"});this._selectedName=null,this._refresh(n)}catch(n){console.error("clear_labels failed:",n)}}};var D3t="Select an instance in the layout to view its schematic.",lde=class{constructor(n,r){this.container=n,this.appState=r,this.element=document.createElement("div"),this.element.className="schematic-widget",this.element.style.cssText="width:100%; height:100%; display:flex; flex-direction:column; background:var(--bg-panel); color:var(--fg-primary); overflow:hidden;",this.controls=document.createElement("div"),this.controls.style.cssText="padding:4px 8px; background:var(--bg-header); border-bottom:1px solid var(--border);flex-shrink:0; display:flex; align-items:center; gap:8px; flex-wrap:wrap;",this.controls.innerHTML='',this.element.appendChild(this.controls),this.svgContainer=document.createElement("div"),this.svgContainer.style.cssText="flex:1; overflow:hidden; position:relative; cursor:grab; background:var(--bg-main);",this.element.appendChild(this.svgContainer),this.container.element.appendChild(this.element),this.controls.querySelector("#schematic-refresh").addEventListener("click",()=>this.refresh()),this.controls.querySelector("#schematic-fit").addEventListener("click",()=>this.fitView()),this.controls.querySelector("#schematic-zoom-in").addEventListener("click",()=>this._zoomStep(1.5)),this.controls.querySelector("#schematic-zoom-out").addEventListener("click",()=>this._zoomStep(1/1.5)),this.controls.querySelector("#schematic-select").addEventListener("click",()=>this._toggleSelectMode()),this.controls.querySelector("#schematic-zoom-to").addEventListener("click",()=>this._zoomToSelected()),this.controls.querySelector("#schematic-save-svg").addEventListener("click",()=>this._exportSvg()),this.controls.querySelector("#schematic-save-png").addEventListener("click",()=>this._exportPng()),this.controls.querySelector("#schematic-copy").addEventListener("click",()=>this._copyImage()),this.appState.schematicWidget=this,this.netlistsvg=null,this.skin=null,this._svgEl=null,this._scale=1,this._panX=0,this._panY=0,this._selectMode=!1,this._selectedCell=null,this._svgIdToInstName=new Map,this._setupPanZoom(),this.initNetlistSVG()}_setupPanZoom(){let n=this.svgContainer,r=!1,c,u,d,b;n.addEventListener("wheel",w=>{if(!this._svgEl)return;w.preventDefault();let _=w.deltaY<0?1.2:1/1.2,x=n.getBoundingClientRect(),T=w.clientX-x.left,M=w.clientY-x.top;this._panX=T+(this._panX-T)*_,this._panY=M+(this._panY-M)*_,this._scale*=_,this._applyTransform()},{passive:!1}),n.addEventListener("mousedown",w=>{if(!(!this._svgEl||w.button!==0)){if(this._selectMode){this._handleSelectClick(w);return}r=!0,c=w.clientX,u=w.clientY,d=this._panX,b=this._panY,n.style.cursor="grabbing",w.preventDefault()}}),window.addEventListener("mousemove",w=>{r&&(this._panX=d+(w.clientX-c),this._panY=b+(w.clientY-u),this._applyTransform())}),window.addEventListener("mouseup",()=>{r&&(r=!1,n.style.cursor=this._selectMode?"default":"grab")})}_zoomStep(n){if(!this._svgEl)return;let r=this.svgContainer.getBoundingClientRect(),c=r.width/2,u=r.height/2;this._panX=c+(this._panX-c)*n,this._panY=u+(this._panY-u)*n,this._scale*=n,this._applyTransform()}_toggleSelectMode(){this._selectMode=!this._selectMode;let n=this.controls.querySelector("#schematic-select");this._selectMode?(n.style.background="var(--accent)",n.style.color="var(--fg-white)",this.svgContainer.style.cursor="default"):(n.style.background="",n.style.color="",this.svgContainer.style.cursor="grab",this._clearCellHighlight())}_handleSelectClick(n){if(!this._svgEl)return;let r=n.target,c=null;for(;r&&r!==this._svgEl;){if(r.tagName==="g"&&r.id&&this._svgIdToInstName.has(r.id)){c=r;break}r=r.parentElement}if(this._clearCellHighlight(),!c)return;let u=this._svgIdToInstName.get(c.id);try{let d=c.getBBox(),b=3,w=document.createElementNS("http://www.w3.org/2000/svg","rect");w.setAttribute("x",d.x-b),w.setAttribute("y",d.y-b),w.setAttribute("width",d.width+b*2),w.setAttribute("height",d.height+b*2),w.setAttribute("fill","none"),w.setAttribute("stroke","#e05a00"),w.setAttribute("stroke-width","1.5"),w.setAttribute("rx","3"),w.id="_schematic_highlight",c.appendChild(w),this._selectedCell=c}catch{}this.controls.querySelector("#schematic-zoom-to").disabled=!1,this.setStatus(`Selected: ${u}`),this._fetchInspect(u)}_fetchInspect(n){let r=this.appState.websocketManager;if(!r)return;console.log("[Schematic] inspect:",n);let c=Pm(this.appState);r.request({type:"schematic_inspect",inst_name:n,use_dbu:this.appState.showDbu}).then(u=>{Y1(this.appState,c)&&(this.appState.updateInspector&&this.appState.updateInspector(u),this.appState.focusComponent&&this.appState.focusComponent("Inspector"),this.appState.refreshOverlay&&this.appState.refreshOverlay())}).catch(u=>{console.error("schematic_inspect failed:",u),this.setStatus(`Inspect error: ${u}`)})}_clearCellHighlight(){if(this._svgEl){let n=this._svgEl.querySelector("#_schematic_highlight");n&&n.remove()}this._selectedCell=null,this.controls.querySelector("#schematic-zoom-to").disabled=!0}_zoomToSelected(){if(!this._selectedCell||!this._svgEl)return;let n=this.svgContainer.getBoundingClientRect(),r=this._selectedCell.getBoundingClientRect(),c=(r.left-n.left-this._panX)/this._scale,u=(r.top-n.top-this._panY)/this._scale,d=r.width/this._scale,b=r.height/this._scale,w=Math.min(n.width/d,n.height/b)*.9;this._scale=w,this._panX=n.width/2-(c+d/2)*w,this._panY=n.height/2-(u+b/2)*w,this._applyTransform()}_applyTransform(){this._svgEl&&(this._svgEl.style.transform=`translate(${this._panX}px, ${this._panY}px) scale(${this._scale})`,this._svgEl.style.transformOrigin="0 0")}fitView(){if(!this._svgEl)return;let n=this.svgContainer.getBoundingClientRect();if(n.width===0||n.height===0)return;let r=this._svgEl.viewBox&&this._svgEl.viewBox.baseVal,c=r&&r.width||this._svgEl.clientWidth||1,u=r&&r.height||this._svgEl.clientHeight||1;this._scale=Math.min(n.width/c,n.height/u)*.95,this._panX=(n.width-c*this._scale)/2,this._panY=(n.height-u*this._scale)/2,this._applyTransform()}initNetlistSVG(){this.netlistsvg=globalThis.netlistsvg,this.skin=globalThis.openroadSkin,this._netlistsvgReady=!!(this.netlistsvg&&this.skin),this._netlistsvgReady&&console.log("NetlistSVG ready."),this.setStatus(this._unreadyStatus()??D3t)}_unreadyStatus(){return this._netlistsvgReady?null:ua(this.appState)?"The schematic is not available in saved reports.":"Init error: netlistsvg or its skin is missing from the page."}syncCone(n={}){let r=this.controls.querySelector("#schematic-fanin-depth"),c=this.controls.querySelector("#schematic-fanout-depth"),u=(d,b,w)=>{if(!d)return;let _=parseInt(d.max,10)||10;b===!1?d.value=0:w!==void 0&&(d.value=w>0?Math.min(w,_):_)};u(r,n.fanin,n.fanin_depth),u(c,n.fanout,n.fanout_depth),this.refresh(),this.appState.focusComponent&&this.appState.focusComponent("SchematicWidget")}refresh(){if(!this._netlistsvgReady){this.setStatus(this._unreadyStatus());return}let n=this.appState.selectedInstanceName;if(!n){this.setStatus(D3t);return}let r=this.appState.websocketManager;if(!r){this.setStatus("Waiting for server connection\u2026");return}this.setStatus(`Loading schematic for ${n}\u2026`);let c=parseInt(this.controls.querySelector("#schematic-fanin-depth").value,10),u=parseInt(this.controls.querySelector("#schematic-fanout-depth").value,10),d=isNaN(c)?1:c,b=isNaN(u)?1:u;r.readyPromise.then(()=>{r.request({type:"schematic_cone",inst_name:n,fanin_depth:d,fanout_depth:b}).then(w=>{let _=w.modules&&w.modules.top&&w.modules.top.cells;if(!_||Object.keys(_).length===0){this.setStatus("No cells found for selected instance.");return}this.renderNetlist(w)}).catch(w=>{this.setStatus(`Error: ${w}`)})})}setStatus(n){this.controls.querySelector("#schematic-status").textContent=n}_exportSvg(){if(!this._svgEl){this.setStatus("No schematic to export.");return}let n=X5e(this._svgEl);a3t(new Blob([n],{type:"image/svg+xml;charset=utf-8"}),"schematic.svg")}async _exportPng(){if(!this._svgEl){this.setStatus("No schematic to export.");return}try{let n=await Y5e(this._svgEl,2);hk(n,"schematic.png")}catch{this.setStatus("PNG export failed.")}}async _copyImage(){if(!this._svgEl){this.setStatus("No schematic to export.");return}try{let n=await Y5e(this._svgEl,2),r=await Hhe(n);this.setStatus(r?"Schematic copied to clipboard.":"Clipboard not available.")}catch{this.setStatus("Copy failed.")}}async renderNetlist(n){try{this.setStatus("Rendering\u2026"),typeof window<"u"&&(window.__lastSchematic=n);let r=cpn(n),c,u=this.netlistsvg.render(this.skin,r);if(u&&typeof u.then=="function"?c=await u:c=await new Promise((w,_)=>{this.netlistsvg.render(this.skin,r,(x,T)=>{x?_(x):w(T)})}),typeof c!="string"||!c.includes("requestAnimationFrame(()=>this.fitView()));let b=Object.keys(n.modules.top.cells).length;this.setStatus(`${b} cell${b!==1?"s":""}`)}catch(r){console.error("NetlistSVG render failed:",r),this.setStatus(`Render error: ${r.message||r}`)}}_applyPinLabels(n){if(!this._svgEl)return;let r="http://www.w3.org/2000/svg",c="https://github.com/nturley/netlistsvg",u=n.modules&&n.modules.top&&n.modules.top.cells||{},d=(b,w)=>b.getAttribute("s:"+w)??b.getAttributeNS(c,w);for(let[b,w]of Object.entries(u)){let _=w.port_labels;if(!_)continue;let x=this._svgEl.querySelector("#"+CSS.escape("cell_"+b))||this._svgEl.querySelector("#"+CSS.escape(b));if(!x)continue;let T=w.port_directions||{};for(let M of Array.from(x.children)){if(M.tagName!=="g")continue;let L=d(M,"pid");if(!L||!(L in _))continue;let I=parseFloat(d(M,"x")),D=parseFloat(d(M,"y"));if(!isFinite(I)||!isFinite(D))continue;let F=document.createElementNS(r,"text");T[L]==="input"?(F.setAttribute("class","inputPortLabel"),F.setAttribute("x",I-3)):F.setAttribute("x",I+4),F.setAttribute("y",D-4),F.setAttribute("style","font-size:5px"),F.setAttribute("pointer-events","none"),F.textContent=_[L],x.appendChild(F)}}}_scopeSkinStyles(){if(!this._svgEl)return;let n=".schematic-widget",r=c=>{for(let u of c)u.selectorText?u.selectorText=rpn(u.selectorText,n):u.cssRules&&r(u.cssRules)};for(let c of this._svgEl.querySelectorAll("style")){let u=c.sheet;if(u)try{r(u.cssRules)}catch{continue}}}};function rpn(s,n){return s.split(",").map(r=>{let c=r.trim();if(!c)return"";let u=c.charAt(n.length);return c.startsWith(n)&&(u===""||!/[\w-]/.test(u))?c:`${n} ${c}`}).filter(Boolean).join(", ")}var B3t={and:"$_AND_",nand:"$_NAND_",or:"$_OR_",nor:"$_NOR_",xor:"$_XOR_",xnor:"$_XNOR_",not:"$_NOT_",buf:"$_BUF_"},spn=new Set(["aoi21","aoi22","aoi211","aoi221","aoi222","aoi33","oai21","oai22","oai211","oai221","oai222","oai33"]),opn=new Set(["and3","and4","or3","or4","nand3","nand4","nor3","nor4"]),O3t=["A","B","C","D","E","F"];function apn(s){let n=s&&s.gate_kind;if(!n)return s;let r=s.port_directions||{},c=null,u=[];for(let[M,L]of Object.entries(r))L==="output"&&c===null?c=M:L==="input"&&u.push(M);let d,b={};if(n==="aoi"||n==="oai"){let M=Array.isArray(s.gate_terms)?s.gate_terms:[];if(!M.length)return s;let L=M.map(F=>F.length);if(d=n+L.slice().sort((F,O)=>O-F).join(""),!spn.has(d))return s;let I=M.map(F=>F.slice()).sort((F,O)=>F.length-O.length),D=0;for(let F of I)for(let O of F)b[O]=O3t[D]||"I"+D,D++}else{let M=u.length;if(n==="not"||n==="buf")d=B3t[n];else if(M<=2)d=B3t[n];else if(d=n+M,!opn.has(d))return s;if(!d)return s;u.forEach((L,I)=>{b[L]=O3t[I]||"I"+I})}c!==null&&(b[c]="Y");let w=s.connections||{},_={},x={};for(let[M,L]of Object.entries(w))b[M]&&(_[b[M]]=L);for(let[M,L]of Object.entries(r))b[M]&&(x[b[M]]=L);let T={};for(let[M,L]of Object.entries(b))T[L]=M;return{...s,type:d,connections:_,port_directions:x,port_labels:T}}function cpn(s){let n=s&&s.modules&&s.modules.top;if(!n||!n.cells)return s;let r={};for(let[c,u]of Object.entries(n.cells))r[c]=apn(u);return{...s,modules:{...s.modules,top:{...n,cells:r}}}}var ude=class{constructor(n,r,c){this._app=n,this._redrawAllLayers=r,this._refreshOverlay=c||r,this._categories=[],this._activeCategory="",this._markerTree=null,this._expandedNodes=new Set,this._build(),this._app.websocketManager.readyPromise.then(()=>this.refresh())}_build(){let n=document.createElement("div");n.className="drc-widget";let r=document.createElement("div");r.className="drc-toolbar",this._categorySelect=document.createElement("select"),this._categorySelect.className="drc-category-select",r.appendChild(this._categorySelect),this._loadBtn=document.createElement("button"),this._loadBtn.className="or-btn or-btn-sm",this._loadBtn.textContent="Load...",r.appendChild(this._loadBtn),n.appendChild(r),this._infoBar=document.createElement("div"),this._infoBar.className="drc-info-bar",n.appendChild(this._infoBar),this._treeContainer=document.createElement("div"),this._treeContainer.className="drc-tree-container",n.appendChild(this._treeContainer),this.element=n,this._bindEvents()}_bindEvents(){this._categorySelect.addEventListener("change",()=>{this._activeCategory=this._categorySelect.value,this._loadMarkers()}),this._loadBtn.addEventListener("click",()=>{this._showLoadDialog()})}_loadCategories(){return this._app.websocketManager.request({type:"drc_categories"}).then(n=>{this._categories=n.categories||[],this._renderCategorySelect()}).catch(n=>{console.error("Failed to load DRC categories:",n)})}refresh(){this._loadCategories().then(()=>{!this._activeCategory&&this._categories.length>0&&(this._activeCategory=this._categories[0].name,this._categorySelect.value=this._activeCategory),this._activeCategory&&this._loadMarkers()})}_renderCategorySelect(){let n=this._categorySelect,r=n.value;n.innerHTML="";let c=document.createElement("option");c.value="",c.textContent="(none)",n.appendChild(c);for(let u of this._categories){let d=document.createElement("option");d.value=u.name,d.textContent=`${u.name} (${u.count})`,n.appendChild(d)}this._activeCategory&&this._categories.some(u=>u.name===this._activeCategory)?n.value=this._activeCategory:r&&this._categories.some(u=>u.name===r)?(n.value=r,this._activeCategory=r):this._activeCategory=""}_loadMarkers(){if(!this._activeCategory){this._markerTree=null,this._treeContainer.innerHTML="",this._infoBar.textContent="",this._refreshOverlay();return}this._treeContainer.innerHTML='
Loading...
',this._app.websocketManager.request({type:"drc_markers",category:this._activeCategory}).then(n=>{this._markerTree=n,this._renderTree(),this._refreshOverlay()}).catch(n=>{this._treeContainer.innerHTML="";let r=document.createElement("div");r.className="drc-error",r.textContent=`Error: ${n}`,this._treeContainer.appendChild(r),console.error("Failed to load DRC markers:",n)})}_renderTree(){if(this._treeContainer.innerHTML="",!this._markerTree)return;if(this._markerTree.error){let b=document.createElement("div");b.className="drc-error",b.textContent=this._markerTree.error,this._treeContainer.appendChild(b);return}let n=this._markerTree.total_count||0;this._infoBar.textContent=`${n} total violation${n!==1?"s":""}`;let r=this._markerTree.name||this._activeCategory,c=this._markerTree.subcategories||[],u=this._markerTree.markers||[];if(c.length===0&&u.length===0){this._treeContainer.innerHTML='
No violations
';return}let d=document.createElement("div");d.className="drc-tree",u.length>0&&d.appendChild(this._buildCategoryNode({name:r||"Markers",count:u.length,markers:u},[]));for(let b of c)d.appendChild(this._buildCategoryNode(b,[r]));this._treeContainer.appendChild(d)}_buildCategoryNode(n,r=[]){let c=[...r,n.name],u=document.createElement("div");u.className="drc-tree-node";let d=document.createElement("div");d.className="drc-tree-header";let b=document.createElement("span");b.className="drc-toggle";let w=n.subcategories&&n.subcategories.length>0||n.markers&&n.markers.length>0,_=JSON.stringify(c),x=this._expandedNodes.has(_);b.textContent=w?x?"\u25BC":"\u25B6":" ",d.appendChild(b);let T=document.createElement("input");T.type="checkbox",T.checked=this._allMarkersVisible(n),T.className="drc-visibility-check",T.addEventListener("change",D=>{D.stopPropagation(),this._toggleCategoryVisibility(n,T.checked,c)}),d.appendChild(T);let M=document.createElement("span");M.className="drc-category-label",M.textContent=n.name,d.appendChild(M);let L=document.createElement("span");L.className="drc-count",L.textContent=`${n.count} markers`,d.appendChild(L),u.appendChild(d);let I=document.createElement("div");if(I.className="drc-tree-children",I.style.display=x?"":"none",n.subcategories)for(let D of n.subcategories)I.appendChild(this._buildCategoryNode(D,c));if(n.markers)for(let D of n.markers)I.appendChild(this._buildMarkerNode(D));return u.appendChild(I),w&&(d.addEventListener("click",D=>{if(D.target===T)return;let F=I.style.display!=="none";I.style.display=F?"none":"",b.textContent=F?"\u25B6":"\u25BC",F?this._expandedNodes.delete(_):this._expandedNodes.add(_)}),d.style.cursor="pointer"),u}_buildMarkerNode(n){let r=document.createElement("div");r.className="drc-marker-row",r.dataset.markerId=n.id,n.visited||r.classList.add("drc-unvisited");let c=document.createElement("input");c.type="checkbox",c.checked=n.visible,c.className="drc-visibility-check",c.addEventListener("change",b=>{b.stopPropagation(),n.visible=c.checked,this._updateMarker(n.id,"visible",c.checked)}),r.appendChild(c);let u=document.createElement("span");u.className="drc-marker-index",u.textContent=n.index,r.appendChild(u);let d=document.createElement("span");if(d.className="drc-marker-name",d.textContent=n.name,n.layer&&(d.title=`Layer: ${n.layer}`),r.appendChild(d),n.layer){let b=document.createElement("span");b.className="drc-layer-badge",b.textContent=n.layer,r.appendChild(b)}return r.addEventListener("click",b=>{b.target!==c&&this._highlightMarker(n)}),r.addEventListener("dblclick",b=>{b.target!==c&&this._highlightMarker(n,!0)}),r}highlightMarkerById(n,r=!1){let c=this._findMarkerById(n);c&&this._highlightMarker(c,r)}_findMarkerById(n){let r=c=>{if(!c)return null;if(c.markers){for(let u of c.markers)if(u.id===n)return u}if(c.subcategories)for(let u of c.subcategories){let d=r(u);if(d)return d}return null};return r(this._markerTree)}_highlightMarker(n,r=!1){this._app.websocketManager.request({type:"drc_highlight",marker_id:n.id,open_inspector:r}).then(c=>{if(c.ok&&c.bbox){n.visited=!0;let u=this._treeContainer.querySelector(`.drc-marker-row[data-marker-id="${n.id}"]`);u&&u.classList.remove("drc-unvisited"),this._zoomToBBox(c.bbox),this._refreshOverlay(),r&&(c.select_id!=null&&this._app.navigateInspector&&this._app.navigateInspector(c.select_id),this._app.focusComponent&&this._app.focusComponent("Inspector"))}}).catch(c=>{console.error("Failed to highlight DRC marker:",c)})}_zoomToBBox(n){if(!this._app.designScale||!this._app.view)return;let[r,c,u,d]=n,b=u-r,w=d-c,x=10*this._app.getDbuPerMicron(),T=2*Math.max(b,w),M=Math.min(x,T);this._app.view.fitWorldRect(X1(r-M,c-M,u+M,d+M,this._app.designScale,this._app.designOriginX,this._app.designOriginY))}_updateMarker(n,r,c){this._app.websocketManager.request({type:"drc_update_marker",marker_id:n,field:r,value:!!c}).then(()=>{this._refreshOverlay(),r==="visible"&&(this._update3DHighlights(),c&&this._flashHighlight())}).catch(u=>{console.error("Failed to update DRC marker:",u)})}_flashHighlight(){this._app.view?.flashTiles()}_update3DHighlights(){let n=this._app.threeDViewerWidget;if(!n)return;let r=[];this._collectVisibleMarkers(this._markerTree,r),r.length>0?n.highlightDRC(r):n.clearHighlightDRC()}_collectVisibleMarkers(n,r){if(n){if(n.markers)for(let c of n.markers)c.visible&&r.push(c);if(n.subcategories)for(let c of n.subcategories)this._collectVisibleMarkers(c,r)}}_setMarkersVisible(n,r){if(n){if(n.markers)for(let c of n.markers)c.visible=r;if(n.subcategories)for(let c of n.subcategories)this._setMarkersVisible(c,r)}}_snapshotMarkerVisibility(n,r=new Map){if(!n)return r;if(n.markers)for(let c of n.markers)r.set(c.id,c.visible);if(n.subcategories)for(let c of n.subcategories)this._snapshotMarkerVisibility(c,r);return r}_restoreMarkerVisibility(n,r){if(n){if(n.markers)for(let c of n.markers)r.has(c.id)&&(c.visible=r.get(c.id));if(n.subcategories)for(let c of n.subcategories)this._restoreMarkerVisibility(c,r)}}_allMarkersVisible(n){if(n.markers){for(let r of n.markers)if(!r.visible)return!1}if(n.subcategories){for(let r of n.subcategories)if(!this._allMarkersVisible(r))return!1}return!0}_toggleCategoryVisibility(n,r,c){let u=this._snapshotMarkerVisibility(n);this._setMarkersVisible(n,r),this._renderTree(),this._app.websocketManager.request({type:"drc_update_category_visibility",category:n.name,path:c||[n.name],visible:!!r}).then(()=>{this._refreshOverlay(),this._update3DHighlights(),r&&this._flashHighlight()}).catch(d=>{console.error("Failed to update category visibility:",d),this._restoreMarkerVisibility(n,u),this._renderTree()})}_showLoadDialog(){new nDe(this._app,r=>{this._activeCategory=r,this._loadCategories().then(()=>{this._categorySelect.value=this._activeCategory,this._loadMarkers()})}).open()}selectCategory(n){this._activeCategory=n,this._categorySelect.value=n,this._loadMarkers()}},nDe=class{constructor(n,r){this._app=n,this._onLoaded=r,this._currentPath="",this._disposers=[],this._closed=!1}open(){this._overlay=document.createElement("div"),this._overlay.className="modal-overlay",this._overlay.innerHTML=` - `,document.body.appendChild(this._overlay),this._breadcrumb=this._overlay.querySelector(".fb-breadcrumb"),this._fileList=this._overlay.querySelector(".fb-file-list"),this._pathInput=this._overlay.querySelector(".fb-path-input"),this._errorDiv=this._overlay.querySelector(".modal-error"),this._okBtn=this._overlay.querySelector(".ok"),this._cancelBtn=this._overlay.querySelector(".cancel"),this._listen(this._pathInput,"input",()=>this._updateOkState()),this._listen(this._pathInput,"keydown",n=>{if(n.key==="Enter"){let r=this._pathInput.value.trim();r.endsWith("/")?this._navigate(r.replace(/\/+$/,"")||"/"):this._submit()}else n.key==="Escape"&&this.close()}),this._listen(this._okBtn,"click",()=>this._submit()),this._listen(this._cancelBtn,"click",()=>this.close()),this._listen(this._overlay,"click",n=>{n.target===this._overlay&&this.close()}),this._navigate("")}close(){if(!this._closed){this._closed=!0;for(let n of this._disposers)n();this._disposers.length=0,this._overlay&&(this._overlay.remove(),this._overlay=null)}}_listen(n,r,c){n.addEventListener(r,c),this._disposers.push(()=>n.removeEventListener(r,c))}_updateOkState(){this._okBtn.disabled=!this._pathInput.value.trim()}_renderBreadcrumb(n){this._breadcrumb.innerHTML="";let r=n.split("/").filter(Boolean),c=document.createElement("span");c.className="fb-crumb",c.textContent="/",this._listen(c,"click",()=>this._navigate("/")),this._breadcrumb.appendChild(c);let u="";for(let d of r){u+="/"+d;let b=document.createElement("span");b.className="fb-crumb-sep",b.textContent=" / ",this._breadcrumb.appendChild(b);let w=document.createElement("span");w.className="fb-crumb",w.textContent=d;let _=u;this._listen(w,"click",()=>this._navigate(_)),this._breadcrumb.appendChild(w)}}_renderEntries(n){if(this._fileList.innerHTML="",!n||n.length===0){let r=document.createElement("div");r.className="fb-empty",r.textContent="(empty directory)",this._fileList.appendChild(r);return}for(let r of n){let c=document.createElement("div");c.className="fb-entry",r.is_dir&&c.classList.add("fb-dir");let u=document.createElement("span");u.className="fb-icon",u.textContent=r.is_dir?"\u{1F4C1}":"\u{1F4C4}",c.appendChild(u);let d=document.createElement("span");d.className="fb-name",d.textContent=r.name,c.appendChild(d),r.is_dir?this._listen(c,"click",()=>this._navigate(this._currentPath+"/"+r.name)):(this._listen(c,"click",()=>{let b=this._fileList.querySelector(".fb-selected");b&&b.classList.remove("fb-selected"),c.classList.add("fb-selected"),this._pathInput.value=this._currentPath+"/"+r.name,this._updateOkState()}),this._listen(c,"dblclick",()=>{this._pathInput.value=this._currentPath+"/"+r.name,this._updateOkState(),this._submit()})),this._fileList.appendChild(c)}}async _navigate(n){this._errorDiv.style.display="none",this._fileList.innerHTML='
Loading...
';try{let r=await this._app.websocketManager.request({type:"list_dir",path:n||""});if(this._closed)return;this._currentPath=r.path,this._renderBreadcrumb(r.path),this._renderEntries(r.entries),this._pathInput.value="",this._updateOkState()}catch(r){if(this._closed)return;this._fileList.innerHTML="",this._errorDiv.textContent=r.message||String(r),this._errorDiv.style.display=""}}async _submit(){let n=this._pathInput.value.trim();if(n){this._okBtn.disabled=!0,this._okBtn.textContent="Loading...",this._errorDiv.style.display="none";try{let r=await this._app.websocketManager.request({type:"drc_load_report",path:n});if(this._closed)return;if(r.ok){let c=r.category;this.close(),this._onLoaded(c)}else this._errorDiv.textContent=r.error||"Failed to load report",this._errorDiv.style.display="",this._okBtn.disabled=!1,this._okBtn.textContent="Load"}catch(r){if(this._closed)return;this._errorDiv.textContent=r.message||"Request failed",this._errorDiv.style.display="",this._okBtn.disabled=!1,this._okBtn.textContent="Load"}}}};var spn=` -\r[]{}`;var fde=class{constructor(n,r){this._input=n,this._ws=r,this._popup=null,this._items=[],this._selectedIndex=-1,this._replaceStart=0,this._replaceEnd=0,this._debounceTimer=null,this._commandCache=null,this._history=[],this._historyIndex=-1,this._historyStash="",this._createPopup(),this._onInputBound=this._onInput.bind(this),this._onBlurBound=this._onBlur.bind(this),this._input.addEventListener("input",this._onInputBound),this._input.addEventListener("blur",this._onBlurBound)}_createPopup(){this._popup=document.createElement("div"),this._popup.className="tcl-complete-popup",this._popup.style.display="none",this._input.parentElement.appendChild(this._popup)}handleKeyDown(n){let r=this._popup.style.display!=="none";return n.key==="Tab"?(n.preventDefault(),r?this._tabAccept():this._tabComplete(this._input.value,this._input.selectionStart),!0):n.key==="Escape"?r?(this._hidePopup(),!0):!1:n.key==="ArrowDown"?r?(n.preventDefault(),this._selectItem(this._selectedIndex+1),!0):this._historyIndex>=0?(n.preventDefault(),this._historyIndex--,this._historyIndex<0?this._input.value=this._historyStash:this._input.value=this._history[this._historyIndex],!0):!1:n.key==="ArrowUp"?r?(n.preventDefault(),this._selectItem(this._selectedIndex-1),!0):this._historyIndex{let n=this._input.value,r=this._input.selectionStart,c=this._extractPrefix(n,r);c.length>=2||c.length>=1&&(c[0]==="$"||c[0]==="-")?this._requestCompletions(n,r):this._hidePopup()},100)}_onBlur(){setTimeout(()=>this._hidePopup(),150)}_extractPrefix(n,r){let c=r-1;for(;c>=0&&spn.indexOf(n[c])===-1;)c--;return n.substring(c+1,r)}_fetchCompletions(n,r,c){let u=this._extractPrefix(n,r),d=u.length>0&&u[0]==="$",b=u.length>0&&u[0]==="-",w=!d&&!b,_=r-u.length,x=n.substring(0,_),T=/^[\s\[]*$/.test(x);if(w&&T&&this._commandCache){let M=u.toLowerCase(),L=this._commandCache.filter(I=>I.toLowerCase().startsWith(M));c(L,_,r);return}this._ws.request({type:"tcl_complete",line:n,cursor_pos:r}).then(M=>{M.mode==="commands"&&!this._commandCache&&u===""&&(this._commandCache=M.completions),M.mode==="commands"&&!this._commandCache&&this._ws.request({type:"tcl_complete",line:"",cursor_pos:0}).then(L=>{L.mode==="commands"&&(this._commandCache=L.completions)}).catch(()=>{}),c(M.completions,M.replace_start,M.replace_end)}).catch(()=>c([],0,0))}_requestCompletions(n,r){this._fetchCompletions(n,r,(c,u,d)=>{this._showPopup(c,u,d)})}_tabAccept(){if(this._items.length===0){this._hidePopup();return}if(this._items.length===1){this._selectedIndex=0,this._acceptCompletion();return}this._advanceToCommonPrefix()}_tabComplete(n,r){this._fetchCompletions(n,r,(c,u,d)=>{if(!c||c.length===0){this._hidePopup();return}if(c.length===1){this._items=c,this._replaceStart=u,this._replaceEnd=d,this._selectedIndex=0,this._acceptCompletion();return}this._items=c,this._replaceStart=u,this._replaceEnd=d,this._advanceToCommonPrefix(),this._showPopup(c,this._replaceStart,this._replaceEnd)})}_advanceToCommonPrefix(){if(this._items.length<2)return!1;let n=this._items[0];for(let b=1;b0;b++){let w=this._items[b],_=0;for(;_{let _=document.createElement("div");_.className="tcl-complete-item",_.textContent=b,_.addEventListener("mousedown",x=>{x.preventDefault(),this._selectedIndex=w,this._acceptCompletion()}),this._popup.appendChild(_)}),n.length>15){let b=document.createElement("div");b.className="tcl-complete-more",b.textContent=`... ${n.length-15} more`,this._popup.appendChild(b)}this._selectedIndex=0,this._highlightSelected(),this._popup.style.display="block"}_hidePopup(){this._popup.style.display="none",this._items=[],this._selectedIndex=-1}_selectItem(n){if(this._items.length===0)return;let r=Math.min(this._items.length,15)-1;this._selectedIndex=Math.max(0,Math.min(n,r)),this._highlightSelected()}_highlightSelected(){let n=this._popup.querySelectorAll(".tcl-complete-item");n.forEach((r,c)=>{r.classList.toggle("selected",c===this._selectedIndex)}),n[this._selectedIndex]&&n[this._selectedIndex].scrollIntoView&&n[this._selectedIndex].scrollIntoView({block:"nearest"})}_acceptCompletion(){if(this._selectedIndex<0||this._selectedIndex>=this._items.length){this._hidePopup();return}let n=this._items[this._selectedIndex],r=this._input.value.substring(0,this._replaceStart),c=this._input.value.substring(this._replaceEnd),d=!n.endsWith("/")&&!n.endsWith("::")&&(c.length===0||c[0]!==" ")?" ":"";this._input.value=r+n+d+c;let b=this._replaceStart+n.length+d.length;this._input.setSelectionRange(b,b),this._input.focus(),this._hidePopup()}};var B3t=[{key:"or_visibility",store:"cookie"},{key:"or_selectability",store:"cookie"},{key:"or_hidden_layers",store:"session"},{key:"or_nonselectable_layers",store:"session"},{key:"or_layer_patterns",store:"session"},{key:"or_hidden_chiplets",store:"cookie"},{key:"or_bg_color",store:"cookie"},{key:"or_show_dbu",store:"cookie"},{key:"or_theme",store:"theme"},{key:"or_use_true_z",store:"cookie"},{key:"or_ruler_style",store:"cookie"},{key:"or_wheel_zoom",store:"cookie"},{key:"or_arrow_step",store:"cookie"},{key:"or_font_family",store:"cookie"},{key:"or_font_scale",store:"cookie"},{key:"or_control_smoothing",store:"cookie"},{key:"or_double_buffer",store:"cookie"},{key:"or_defer_tile_updates",store:"cookie"}];function O3t(s){return{controlSmoothing:s("or_control_smoothing")==="1",doubleBuffer:s("or_double_buffer")!=="0",deferTileUpdates:s("or_defer_tile_updates")==="1"}}function opn(s,n){try{return window[s].getItem(n)}catch{return null}}function apn(s,n,r){try{r===null?window[s].removeItem(n):window[s].setItem(n,r)}catch{}}function cpn({key:s,store:n}){return n==="session"?opn("sessionStorage",s):ph(s)}function lpn({key:s,store:n},r){n==="session"?apn("sessionStorage",s,r):n==="theme"?r===null?t3t():Whe(r):r===null?Vhe(s):Uf(s,r)}function N3t(){let s={};for(let n of B3t){let r=cpn(n);r&&(s[n.key]=r)}return{version:1,entries:s}}function upn(s){return typeof s=="string"&&s!==""&&!/[;\r\n]/.test(s)}function F3t(s){for(let n of B3t){let r=s[n.key];lpn(n,upn(r)?r:null)}}function U3t(s,n=typeof document<"u"?document:null){let r="OpenROAD",c=s?`${r} - ${s}`:r;return n&&(n.title=c),c}var $s=globalThis.THREE,z3t=2,fpn=.002,hpn=.9,dpn=1.1,ppn=.1,gpn=20,mpn=3,gk=2,G3t=2,bpn=10,wpn=1e4,vpn=.15,_pn=300,ypn=6,hde=Math.PI/180,j3t=[5025616,2201331,16750592,10233776,48340,16007990,2533018,7951688,15277667,4149685];function xpn(s){let n=new Array(s.length).fill(0),r=new Map;s.forEach((c,u)=>{let d=c.z;r.has(d)||r.set(d,[]),r.get(d).push({idx:u,chiplet:c})});for(let c of r.values()){if(c.length<=1)continue;let u=[];for(let{idx:d,chiplet:b}of c){let w=b.x,_=b.y,x=b.x+b.width,T=b.y+b.height,M=!1;for(let L=0;LwD.x1&&_D.y1)){u[L].push({x1:w,y1:_,x2:x,y2:T}),n[d]=L,M=!0;break}M||(u.push([{x1:w,y1:_,x2:x,y2:T}]),n[d]=u.length-1)}}return n}var dde=class{constructor(n,r){if(this._app=r,this._container=n,this._element=document.createElement("div"),this._element.className="three-d-viewer-widget",n.element.appendChild(this._element),!$s){ua(r)?this._showInfo("The 3D view is not available in saved reports."):this._showError("three.js is missing from the page."),this._destroyed=!0;return}this._canvasContainer=document.createElement("div"),this._canvasContainer.className="three-d-canvas-container",this._element.appendChild(this._canvasContainer),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._canvasContainer.appendChild(this._tooltip),this._optionsOverlay=this._createOptionsOverlay(),this._canvasContainer.appendChild(this._optionsOverlay),this._raycaster=new $s.Raycaster,this._scene=new $s.Scene,this._applyTheme(),this._themeObserver=new MutationObserver(()=>{this._applyTheme(),this.render()}),this._themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),this._camera=new $s.PerspectiveCamera(45,1,10,1e5),this._camera.position.set(0,0,1e3);try{this._renderer=new $s.WebGLRenderer({antialias:!0,preserveDrawingBuffer:!0})}catch(b){console.error("3D viewer: failed to create WebGL context:",b),this._showWebGLUnavailable(b),this._themeObserver&&(this._themeObserver.disconnect(),this._themeObserver=null),this._destroyed=!0;return}this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(n.width,n.height),this._canvasContainer.appendChild(this._renderer.domElement),this._rotation=new $s.Quaternion,this._distance=1e3,this._panX=0,this._panY=0,this._boundingRadius=1,this._sceneCenter=new $s.Vector3,this._mouseDown=!1,this._mouseButton=-1,this._lastMousePos={x:0,y:0},this._setupMouseHandlers();let c=new $s.AmbientLight(16777215,.5);this._scene.add(c);let u=new $s.DirectionalLight(16777215,.8);u.position.set(1,1,1).normalize(),this._scene.add(u);let d=new $s.DirectionalLight(16777215,.3);d.position.set(-1,-.5,.5).normalize(),this._scene.add(d),n.on("resize",this.onResize.bind(this)),n.on("open",this.onOpen.bind(this)),n.on("destroy",this.onDestroy.bind(this)),this._designGroup=new $s.Group,this._scene.add(this._designGroup),this._chipletMeshes=[],this._loading=!1,this._destroyed=!1,this._edgeMaterial=null}_setupMouseHandlers(){let n=this._renderer.domElement;n.addEventListener("mousedown",r=>{this._mouseDown=!0,this._mouseButton=r.button,this._lastMousePos.x=r.clientX,this._lastMousePos.y=r.clientY,n.focus(),r.preventDefault()}),n.addEventListener("contextmenu",r=>r.preventDefault()),this._onMouseMove=r=>{if(!this._mouseDown)return;let c=r.clientX-this._lastMousePos.x,u=r.clientY-this._lastMousePos.y;this._lastMousePos.x=r.clientX,this._lastMousePos.y=r.clientY,!(c===0&&u===0)&&(this._mouseButton===0?this._handleRotate(c,u):this._mouseButton===2&&this._handlePan(c,u),this._updateCamera())},this._onMouseUp=r=>{this._mouseDown&&r.button===this._mouseButton&&(this._mouseDown=!1,this._mouseButton=-1)},window.addEventListener("mousemove",this._onMouseMove),window.addEventListener("mouseup",this._onMouseUp),n.addEventListener("wheel",r=>{r.preventDefault(),r.deltaY<0?this._distance*=hpn:this._distance*=dpn;let c=Math.max(this._boundingRadius*ppn,1),u=Math.max(this._boundingRadius*gpn,c);this._distance=Math.max(c,Math.min(u,this._distance)),this._updateCamera()},{passive:!1}),n.tabIndex=0,n.style.outline="none",n.addEventListener("keydown",r=>{r.key.toLowerCase()==="f"&&this.resetCamera()}),n.addEventListener("dblclick",r=>{r.preventDefault();let c=this._pickDrcMarkerId(r);if(c!=null&&this._app.drcWidget){this._app.drcWidget.highlightMarkerById(c,!0);return}this.resetCamera()}),n.addEventListener("mousemove",r=>{if(this._mouseDown){this._hideTooltip();return}this._updateTooltip(r)}),n.addEventListener("mouseleave",()=>{this._hideTooltip()})}_createOptionsOverlay(){let n=document.createElement("div");n.className="three-d-options";let r=document.createElement("label");r.title="Render chiplets at their true Z (disable stacking offset for overlapping chiplets at same Z).";let c=document.createElement("input");c.type="checkbox",c.checked=!!this._app.useTrueZ,c.addEventListener("change",()=>{this._app.useTrueZ=c.checked,Uf("or_use_true_z",c.checked?"1":"0"),this._app.syncDisplayState(),this.refreshSceneForOptions()}),r.appendChild(c),r.appendChild(document.createTextNode("True Z (no stacking)")),n.appendChild(r);let u=document.createElement("div");u.style.cssText="margin-top:4px; display:flex; gap:4px;";let d=document.createElement("button");d.className="or-btn or-btn-sm",d.textContent="Save PNG",d.title="Save the 3D view as a PNG image (2x resolution)",d.addEventListener("click",()=>this._exportPng(2));let b=document.createElement("button");return b.className="or-btn or-btn-sm",b.textContent="Copy",b.title="Copy the 3D view image to the clipboard",b.addEventListener("click",()=>this._copyImage(2)),u.appendChild(d),u.appendChild(b),n.appendChild(u),n}_capturePng(n=2){if(!this._renderer)return null;let r=this._renderer,c=r.domElement.clientWidth||r.domElement.width,u=r.domElement.clientHeight||r.domElement.height,d=r.getPixelRatio();try{return r.setPixelRatio(d*n),r.setSize(c,u,!1),this.render(),r.domElement.toDataURL("image/png")}finally{r.setPixelRatio(d),r.setSize(c,u,!1),this.render()}}_exportPng(n=2){let r=this._capturePng(n);r&&hk(r,"3d-view.png")}async _copyImage(n=2){let r=this._capturePng(n);r&&await Hhe(r)}_setRaycasterFromEvent(n){let c=this._renderer.domElement.getBoundingClientRect(),u=new $s.Vector2((n.clientX-c.left)/c.width*2-1,-((n.clientY-c.top)/c.height*2-1));this._raycaster.setFromCamera(u,this._camera)}_updateTooltip(n){if(!this._chipletMeshes.length){this._hideTooltip();return}this._setRaycasterFromEvent(n);let r=this._chipletMeshes.map(w=>w.mesh),c=this._raycaster.intersectObjects(r,!1);if(c.length===0){this._hideTooltip();return}let u=c[0].object,d=this._chipletMeshes.find(w=>w.mesh===u);if(!d){this._hideTooltip();return}this._tooltip.textContent=d.data.name,this._tooltip.style.display="block";let b=this._canvasContainer.getBoundingClientRect();this._tooltip.style.left=n.clientX-b.left+12+"px",this._tooltip.style.top=n.clientY-b.top+12+"px"}_hideTooltip(){this._tooltip&&(this._tooltip.style.display="none")}_pickDrcMarkerId(n){if(!this._drcHitboxMesh||!this._drcHitboxMarkerIds)return null;this._setRaycasterFromEvent(n);let r=this._raycaster.intersectObject(this._drcHitboxMesh,!1);if(r.length===0)return null;let c=r[0].instanceId;return c==null?null:this._drcHitboxMarkerIds[c]??null}_handleRotate(n,r){let c=Math.sqrt(n*n+r*r);if(c<.001)return;let u=new $s.Vector3(r/c,n/c,0),d=c/z3t,w=new $s.Quaternion().setFromAxisAngle(u,d*hde).clone().multiply(this._rotation);if(new $s.Vector3(0,0,1).applyQuaternion(w).z>=0)this._rotation.copy(w);else{let x=new $s.Vector3(0,1,0),T=n/z3t*hde,L=new $s.Quaternion().setFromAxisAngle(x,T).clone().multiply(this._rotation);new $s.Vector3(0,0,1).applyQuaternion(L).z>=0&&this._rotation.copy(L)}}_handlePan(n,r){let c=this._distance*fpn;this._panX+=n*c,this._panY-=r*c}_updateCamera(){let n=Math.max(this._boundingRadius,1e3),r=Math.max(this._distance-n*G3t,bpn),c=this._distance+n*G3t;c0;){let n=this._designGroup.children[0];this._designGroup.remove(n),n.geometry&&n.geometry.dispose(),n.material&&!n.material._shared&&n.material.dispose()}this._edgeMaterial&&(this._edgeMaterial.dispose(),this._edgeMaterial=null),this._onMouseMove&&(window.removeEventListener("mousemove",this._onMouseMove),this._onMouseMove=null),this._onMouseUp&&(window.removeEventListener("mouseup",this._onMouseUp),this._onMouseUp=null),this._renderer&&(this._renderer.dispose(),this._renderer=null),this._app.threeDViewerWidget===this&&(this._app.threeDViewerWidget=null)}}_setInitialCameraState(){this._distance=this._boundingRadius*mpn;let n=new $s.Quaternion().setFromAxisAngle(new $s.Vector3(1,0,0),-45*hde),r=new $s.Quaternion().setFromAxisAngle(new $s.Vector3(0,0,1),45*hde);this._rotation=n.multiply(r),this._panX=0,this._panY=0}resetCamera(){this._sceneBounds&&(this._setInitialCameraState(),this._updateCamera())}onResize(){if(this._destroyed)return;let n=this._canvasContainer.getBoundingClientRect(),r=n.width,c=n.height;r===0||c===0||(this._camera.aspect=r/c,this._camera.updateProjectionMatrix(),this._renderer.setSize(r,c),this.render())}render(){this._destroyed||this._renderer&&this._scene&&this._camera&&this._renderer.render(this._scene,this._camera)}_applyTheme(){let r=fk().bgMap||"#000000";this._scene.background=new $s.Color(r)}async loadData(){if(!(this._loading||this._destroyed)){this._loading=!0;for(let n of[".three-d-error",".three-d-info"]){let r=this._element.querySelector(n);r&&r.remove()}try{await this._app.websocketManager.readyPromise;let n=await this._app.websocketManager.request({type:"get_3d_data"});if(this._destroyed)return;if(n&&n.error){this._showError(n.error);return}if(n&&n.info){this._showInfo(n.info);return}this.buildScene(n)}catch(n){if(this._destroyed)return;console.error("Failed to load 3D data:",n),this._showError(n.message||String(n))}finally{this._loading=!1}}}_showOverlay(n,r,c){let u=document.createElement("div");u.className=n,u.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-family:monospace;text-align:center;",u.style.color=c,u.textContent=r,this._element.appendChild(u)}_showError(n){this._showOverlay("three-d-error","Failed to load 3D data: "+n,"var(--error)")}_showInfo(n){this._showOverlay("three-d-info",n,"var(--fg-muted, #888)")}_showWebGLUnavailable(n){let r=document.createElement("div");r.className="three-d-error",r.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-family:monospace;text-align:center;max-width:80%;color:var(--error);";let c=n&&n.message?n.message:String(n||"");r.innerHTML='
3D viewer unavailable: WebGL context could not be created.
In Chrome, open chrome://flags/#ignore-gpu-blocklist and set Override software rendering list to Enabled, then relaunch the browser.
Otherwise enable hardware acceleration or try a different browser. See chrome://gpu for details.
'+(c?'
'+c+"
":""),this._element.appendChild(r)}buildScene(n){if(this._destroyed||(this._lastSceneData=n,this._clearScene(),!n||!n.chiplets||n.chiplets.length===0))return;let r=this._app.getDbuPerMicron(),c=this._buildChiplets(n.chiplets,r);c.minX!==1/0&&(this._buildGrid(c),this._setSceneBoundsAndCenter(c),this._setInitialCameraState(),this._updateCamera())}_clearScene(){for(this._chipletMeshes=[];this._designGroup.children.length>0;){let n=this._designGroup.children[0];this._designGroup.remove(n),n.geometry&&n.geometry.dispose(),n.material&&!n.material._shared&&n.material.dispose()}this._hideTooltip()}_buildChiplets(n,r){let c={minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0};this._edgeMaterial||(this._edgeMaterial=new $s.LineBasicMaterial({color:0,linewidth:1}),this._edgeMaterial._shared=!0);let u=this._app.useTrueZ?new Array(n.length).fill(0):xpn(n);return n.forEach((d,b)=>{let w=d.width/r,_=d.height/r,x=d.thickness/r*gk,T=j3t[b%j3t.length],M=new $s.MeshPhongMaterial({color:T,transparent:!1,opacity:1,side:$s.DoubleSide,shininess:40}),L=new $s.BoxGeometry(w,_,x),I=new $s.Mesh(L,M),D=d.x/r+w/2,F=d.y/r+_/2,O=x*vpn,z=d.z/r*gk+x/2+u[b]*(x+O);I.position.set(D,F,z),this._designGroup.add(I),this._chipletMeshes.push({mesh:I,data:d,color:T});let Z=new $s.EdgesGeometry(L),H=new $s.LineSegments(Z,this._edgeMaterial);H.position.set(D,F,z),this._designGroup.add(H),c.minX=Math.min(c.minX,d.x/r),c.minY=Math.min(c.minY,d.y/r),c.minZ=Math.min(c.minZ,z-x/2),c.maxX=Math.max(c.maxX,d.x/r+w),c.maxY=Math.max(c.maxY,d.y/r+_),c.maxZ=Math.max(c.maxZ,z+x/2)}),c}_buildGrid(n){let r=n.maxX-n.minX,c=n.maxY-n.minY,u=Math.max(r,c)*1.4,d=10,b=new $s.GridHelper(u,d,8947848,4473924);b.rotation.x=Math.PI/2,b.position.set((n.minX+n.maxX)/2,(n.minY+n.maxY)/2,n.minZ-1),this._designGroup.add(b)}_setSceneBoundsAndCenter(n){this._sceneBounds=n;let r=n.maxX-n.minX,c=n.maxY-n.minY,u=n.maxZ-n.minZ;this._boundingRadius=Math.sqrt(r*r+c*c+u*u)/2,this._sceneCenter.set((n.minX+n.maxX)/2,(n.minY+n.maxY)/2,(n.minZ+n.maxZ)/2)}_stackOffsetForPoint(n,r,c,u){for(let{mesh:d,data:b}of this._chipletMeshes){if(n!==b.z||rb.x+b.width||cb.y+b.height)continue;let w=b.thickness/u*gk,_=b.z/u*gk+w/2;return d.position.z-_}return 0}clearHighlightDRC(){this._drcBlinkInterval&&(clearInterval(this._drcBlinkInterval),this._drcBlinkInterval=null),this._drcMeshGroup&&(this._scene.remove(this._drcMeshGroup),this._drcMeshGroup.children.forEach(n=>{n.geometry&&n.geometry.dispose()}),this._drcMaterial&&(this._drcMaterial.dispose(),this._drcMaterial=null),this._drcHitboxMaterial&&(this._drcHitboxMaterial.dispose(),this._drcHitboxMaterial=null),this._drcHitboxMesh=null,this._drcHitboxMarkerIds=null,this._drcMeshGroup=null,this.render())}highlightDRC(n){if(this._destroyed||(this.clearHighlightDRC(),!n||n.length===0))return;let r=this._app.getDbuPerMicron(),c=0,u=1e4/r*gk;this._sceneBounds&&this._sceneBounds.minZ!==1/0&&(c=this._sceneBounds.minZ,u=this._sceneBounds.maxZ),c-=1,u+=1;let d=Math.max(u-c,1);this._drcMeshGroup=new $s.Group,this._drcMaterial=new $s.LineBasicMaterial({color:16776960,transparent:!0,opacity:1,depthTest:!1,depthWrite:!1}),this._drcHitboxMaterial=new $s.MeshBasicMaterial({transparent:!0,opacity:0,depthWrite:!1});let b=[];for(let x of n){let T=x.rects&&x.rects.length>0?x.rects:[x.bbox];for(let M of T){let[L,I,D,F,O,z]=M,Z=Math.max((D-L)/r,.001),H=Math.max((F-I)/r,.001),te=c,oe=d,ne=0;if(M.length>=6&&O!==void 0&&z!==void 0){te=O/r*gk;let ge=z/r*gk;oe=Math.max(ge-te,.001),ne=this._stackOffsetForPoint(O,(L+D)/2,(I+F)/2,r)}let ue=L/r+Z/2,Te=I/r+H/2,Q=te+oe/2+ne;b.push({cx:ue,cy:Te,cz:Q,width:Z,height:H,depth:oe,markerId:x.id})}}if(b.length>0){let x=new $s.BoxGeometry(1,1,1);this._drcHitboxMesh=new $s.InstancedMesh(x,this._drcHitboxMaterial,b.length),this._drcHitboxMarkerIds=new Array(b.length);let T=new $s.Matrix4,M=new $s.Vector3,L=new $s.Vector3,I=new $s.Quaternion;b.forEach((D,F)=>{L.set(D.cx,D.cy,D.cz),M.set(D.width,D.height,D.depth),T.compose(L,I,M),this._drcHitboxMesh.setMatrixAt(F,T),this._drcHitboxMarkerIds[F]=D.markerId;let O=new $s.BoxGeometry(D.width,D.height,D.depth),z=new $s.EdgesGeometry(O);O.dispose();let Z=new $s.LineSegments(z,this._drcMaterial);Z.position.set(D.cx,D.cy,D.cz),Z.renderOrder=999,this._drcMeshGroup.add(Z)}),this._drcHitboxMesh.instanceMatrix.needsUpdate=!0,this._drcMeshGroup.add(this._drcHitboxMesh)}this._drcMeshGroup.renderOrder=999,this._scene.add(this._drcMeshGroup),this.render();let w=!0,_=0;this._drcBlinkInterval=setInterval(()=>{if(!(!this._drcMeshGroup||!this._drcMaterial)){if(_+=1,_>=ypn){this._drcMaterial.opacity=1,this.render(),clearInterval(this._drcBlinkInterval),this._drcBlinkInterval=null;return}w=!w,this._drcMaterial.opacity=w?1:.2,this.render()}},_pn)}refreshSceneForOptions(){this._destroyed||this._lastSceneData&&(this.clearHighlightDRC(),this.buildScene(this._lastSceneData))}};var Epn=[{name:"green",hex:"#00ff00"},{name:"yellow",hex:"#ffff00"},{name:"cyan",hex:"#00ffff"},{name:"magenta",hex:"#ff00ff"},{name:"red",hex:"#ff0000"},{name:"dark_green",hex:"#008000"},{name:"dark_magenta",hex:"#800080"},{name:"blue",hex:"#0000ff"},{name:"orange",hex:"#ffa500"},{name:"purple",hex:"#800080"},{name:"lime",hex:"#bfff00"},{name:"teal",hex:"#008080"},{name:"pink",hex:"#ffc0cb"},{name:"brown",hex:"#8b4513"},{name:"indigo",hex:"#4b0082"},{name:"turquoise",hex:"#40e0d0"}],Spn=[{label:"Connected Insts",suffix:"connected_insts",needsNet:!0},{label:"Output Nets",suffix:"connected_nets",args:{output:!0,input:!1}},{label:"Input Nets",suffix:"connected_nets",args:{output:!1,input:!0}},{label:"All Nets",suffix:"connected_nets",args:{output:!0,input:!0}},{label:"All buffer trees",suffix:"connected_buffer_trees"},{label:"All buffer trees (incl. inverters)",suffix:"connected_buffer_trees",args:{include_inverters:!0}}],pde=class{constructor(n){this._app=n,this._el=document.createElement("div"),this._el.className="context-menu",this._el.style.display="none",this._el.style.zIndex="10000",document.body.appendChild(this._el),this._bindEvents()}_bindEvents(){document.addEventListener("mousedown",n=>{this._el.contains(n.target)||this.hide()}),this._app.view&&this._app.view.on("movestart",()=>this.hide())}show(n){this._el.innerHTML="";let r=!!this._app.selHasInst,c=!!this._app.selHasNet,u=!(r||c),d=I=>Spn.map(D=>({label:D.label,disabled:D.needsNet?!c:!r,...I(D.suffix,D.args||{})})),b=[{label:"Select",disabled:u,subMenu:d((I,D)=>({action:()=>this._sendContextAction("select_"+I,D)}))},{label:"Highlight",disabled:u,subMenu:d((I,D)=>({subMenu:this._buildColorSubmenu("highlight_"+I,D)}))},{label:"Save",subMenu:[{label:"Visible layout",action:()=>this._app.captureLayout?.({entire:!1})},{label:"Entire layout",action:()=>this._app.captureLayout?.({entire:!0})}]},{label:"Clear",subMenu:[{label:"Selections",action:()=>this._sendContextAction("clear_selections")},{label:"Highlights",action:()=>this._sendContextAction("clear_highlights")},{label:"Rulers",action:()=>{this._app.rulerManager?.clearAllRulers()}},{label:"Focus nets",action:()=>this._sendContextAction("clear_focus_nets")},{label:"Route Guides",action:()=>this._sendContextAction("clear_route_guides")},{label:"All",action:()=>{this._sendContextAction("clear_all"),this._app.rulerManager?.clearAllRulers()}}]}];this._buildMenu(b,this._el),this._el.style.display="block";let w=4,_=this._el.getBoundingClientRect(),x=window.innerWidth-_.width-w,T=window.innerHeight-_.height-w,M=Math.max(w,Math.min(n.clientX,x)),L=Math.max(w,Math.min(n.clientY,T));this._el.style.left=M+"px",this._el.style.top=L+"px"}hide(){this._el.style.display="none"}_buildColorSubmenu(n,r={}){return Epn.map(({name:c,hex:u},d)=>({label:c,swatch:u,action:()=>this._sendContextAction(n,{...r,group:d})}))}_buildMenu(n,r){n.forEach(c=>{let u=document.createElement("div");if(u.className="cm-item",c.swatch){let d=document.createElement("span");d.className="cm-swatch",d.style.background=c.swatch,u.appendChild(d)}if(u.appendChild(document.createTextNode(c.label)),c.disabled){u.classList.add("disabled"),c.subMenu&&u.classList.add("has-submenu"),r.appendChild(u);return}if(c.subMenu){u.classList.add("has-submenu");let d=document.createElement("div");d.className="cm-submenu",this._buildMenu(c.subMenu,d),u.appendChild(d),u.addEventListener("mouseenter",()=>{d.classList.remove("flip-left"),d.getBoundingClientRect().right>window.innerWidth&&d.classList.add("flip-left")})}else c.action&&u.addEventListener("click",d=>{d.stopPropagation(),this.hide();try{c.action()}catch(b){console.error("Context menu item action threw:",c.label,b)}});r.appendChild(u)})}_sendContextAction(n,r={}){this._app.websocketManager&&this._app.websocketManager.request({type:"context_action",action:n,...r}).then(c=>{EO(this._app,c),c&&c.connected_count===0&&Y1('Nothing connected \u2014 select an instance (or a net for "Connected Insts") first.'),this._syncAfterAction(n)}).catch(c=>{console.error("Context action failed:",n,c)})}_syncAfterAction(n){let r=this._app;(n==="clear_focus_nets"||n==="clear_route_guides"||n==="clear_all")&&typeof r.redrawAllLayers=="function"&&r.redrawAllLayers(),n==="clear_selections"||n==="clear_all"?(r.updateInspector?.(null),r.stopSelectionAnimation?.(),r.clearSelectionOutline?.(),r.lastSelectionBounds=null):r.refreshInspector?.(),r.refreshOverlay?.()}};function $3t(s,n){if(!s)return;let r=URL.createObjectURL(s),c=document.createElement("a");c.href=r,c.download=n,c.style.display="none",document.body.appendChild(c),c.click(),document.body.removeChild(c),setTimeout(()=>URL.revokeObjectURL(r),0)}function Mpn(s,n,r){s.view.getContainer().querySelectorAll(".or-view-markers .ruler-label").forEach(u=>{let d=u.getBoundingClientRect();if(d.width<=0||d.height<=0)return;let b=u.textContent;if(!b)return;let w=getComputedStyle(u),_=d.left-r.left,x=d.top-r.top;n.save(),n.fillStyle=w.backgroundColor||"rgba(0, 0, 0, 0.75)";let T=Math.min(parseFloat(w.borderTopLeftRadius)||0,d.height/2);T>0&&typeof n.roundRect=="function"?(n.beginPath(),n.roundRect(_,x,d.width,d.height,T),n.fill()):n.fillRect(_,x,d.width,d.height),n.fillStyle=w.color||"#eee",n.font=w.font||`${w.fontSize||"12px"} ${w.fontFamily||"monospace"}`,n.textAlign="left",n.textBaseline="middle",n.fillText(b,_+(parseFloat(w.paddingLeft)||0),x+d.height/2),n.restore()})}async function V3t(s){let n=s.view.getContainer(),r=n.getBoundingClientRect(),c=Math.max(1,Math.round(r.width)),u=Math.max(1,Math.round(r.height)),d=document.createElement("canvas");d.width=c,d.height=u;let b=d.getContext("2d"),w=getComputedStyle(n).backgroundColor;b.fillStyle=w&&w!=="transparent"&&w!=="rgba(0, 0, 0, 0)"?w:"#000",b.fillRect(0,0,c,u);let _=await s.view.captureCanvas();if(_){let x=_.rect;try{b.drawImage(_.image,x.left-r.left,x.top-r.top,x.width,x.height)}catch{}}return Mpn(s,b,r),new Promise(x=>d.toBlob(x,"image/png"))}async function W3t(s,{entire:n=!1}={}){if(!s.view)return;if(!n||!s.fitRect){$3t(await V3t(s),"layout_visible.png");return}let r=s.view.getCenter(),c=s.view.getZoom();try{s.view.fitWorldRect(s.fitRect,{animate:!1}),await s.view.whenTilesSettled(),$3t(await V3t(s),"layout_entire.png")}finally{s.view.setView(r,c,{animate:!1})}}var TT=document.getElementById("websocket-status"),cH=null,Tpn=2e3,Cpn=20;function q3t(){let s=he.websocketManager&&he.websocketManager.isConnected,n=he.websocketManager?he.websocketManager.pendingCount:0;if(s)if(cH&&(clearTimeout(cH),cH=null),n>Cpn){let r=`pending: ${n}`,c=TT.firstElementChild;(!c?.classList.contains("pending-indicator")||c.textContent!==r)&&(TT.innerHTML=`
${r}
`),TT.style.display="block"}else TT.style.display="none";else{if(he.websocketManager?._shutdown)return;cH||(cH=setTimeout(()=>{he.websocketManager?.isConnected||(TT.innerHTML='
\u26A0 OpenROAD disconnected \u2014 retrying\u2026
',TT.style.display="block")},Tpn))}Apn(n)}function Apn(s){let n=he.tileProgressEl;if(!n)return;n.classList.toggle("active",s>0);let r=s>0?`${s} tile requests pending`:"";n.title!==r&&(n.title=r)}var H3t=yT(q3t);function Ppn(s){if(!s)return"";try{return decodeURIComponent(s)}catch{return""}}var he={view:null,fitRect:null,lastSelectionBounds:null,selHasInst:!1,selHasNet:!1,displayControlsEl:null,allLayers:[],designScale:null,designOriginX:0,designOriginY:0,websocketManager:null,goldenLayout:null,hasLiberty:!1,techData:null,inspectorEl:null,tclOutputEl:null,modulesLayer:null,pinsLayer:null,overlayLayers:[],hierarchyBrowser:null,focusNets:new Set,routeGuideNets:new Set,visibleLayers:new Set,visibleLayerNames:new Set,visibleChiplets:null,layerPatterns:{},useTrueZ:ph("or_use_true_z")==="1",showDbu:ph("or_show_dbu")==="1",rulerStyle:ph("or_ruler_style")==="manhattan"?"manhattan":"euclidian",wheelZoom:ph("or_wheel_zoom")!=="0",arrowStep:tH(ph("or_arrow_step")),...O3t(ph),fontFamily:Ppn(ph("or_font_family")),fontScale:rH(ph("or_font_scale")),polyDecomp:!1,labelManager:null,selectableLayers:new Set,heatMapData:null,activeHeatMap:"",heatMapLayer:null,heatMapLegendEl:null,renderHeatMapControls:null,rulerManager:null,selectionToken:0,selectionResetters:[],getDbuPerMicron(){return this.techData?.dbu_per_micron||1e3},unitOpts(){return{showDbu:this.showDbu,dbuPerMicron:this.getDbuPerMicron()}},formatDbu(s,n=!1){return zxt(s,this.unitOpts(),n)},parseDbu(s){return Gxt(s,this.unitOpts())},formatDistance(s){return jxt(s,this.unitOpts())},unitLabel(){return $xt(this.unitOpts())}},mg={stdcells:!0,macros:!0,pad_input:!0,pad_output:!0,pad_inout:!0,pad_power:!0,pad_spacer:!0,pad_areaio:!0,pad_other:!0,phys_fill:!1,phys_endcap:!0,phys_welltap:!0,phys_tie:!0,phys_antenna:!0,phys_cover:!0,phys_bump:!0,phys_other:!0,std_bufinv:!0,std_bufinv_timing:!0,std_clock_bufinv:!0,std_clock_gate:!0,std_level_shift:!0,std_sequential:!0,std_combinational:!0,net_signal:!0,net_power:!0,net_ground:!0,net_clock:!0,net_reset:!0,net_tieoff:!0,net_scan:!0,net_analog:!0,inst_names:!0,inst_pins:!0,inst_pin_names:!1,routing:!0,routing_segments:!0,routing_vias:!0,special_nets:!0,srouting_segments:!0,srouting_vias:!0,pins:!0,pin_names:!0,access_points:!1,regions:!0,mfg_grid:!1,gcell_grid:!1,flywires_only:!1,blockages:!0,placement_blockages:!0,routing_obstructions:!0,fills:!1,rows:!1,tracks_pref:!1,tracks_non_pref:!1,module_view:!1,detailed:!1,rulers:!0,labels:!0,scale_bar:!0,focused_nets_guides:!1,highlight_selected:!0,debug:!1};try{let s=ph("or_visibility");if(s){let n=JSON.parse(decodeURIComponent(s));for(let[r,c]of Object.entries(n))mg[r]=!!c}}catch{}var LO={stdcells:!0,macros:!0,pad_input:!0,pad_output:!0,pad_inout:!0,pad_power:!0,pad_spacer:!0,pad_areaio:!0,pad_other:!0,phys_fill:!0,phys_endcap:!0,phys_welltap:!0,phys_tie:!0,phys_antenna:!0,phys_cover:!0,phys_bump:!0,phys_other:!0,std_bufinv:!0,std_bufinv_timing:!0,std_clock_bufinv:!0,std_clock_gate:!0,std_level_shift:!0,std_sequential:!0,std_combinational:!0,net_signal:!0,net_power:!0,net_ground:!0,net_clock:!0,net_reset:!0,net_tieoff:!0,net_scan:!0,net_analog:!0,pins:!0,inst_pins:!0,placement_blockages:!0,routing_obstructions:!0};he.visibility=mg;he.selectability=LO;try{let s=ph("or_selectability");if(s){let n=JSON.parse(decodeURIComponent(s));for(let[r,c]of Object.entries(n))LO[r]=!!c}}catch{}(function(){let n=null;try{n=new URLSearchParams(window.location.search)}catch{return}he.forceComposite=n.get("composite")==="1",he.preserveBuffer=n.get("preservebuffer")==="1";let r=Number(n.get("grouplayers"));Number.isFinite(r)&&r>0&&(he.groupLayers=Math.floor(r))})();he.tileCtx={visibility:mg,selectability:LO,visibleLayers:he.visibleLayerNames,selectableLayers:he.selectableLayers,app:he};function Lpn(){return he.view.addTileSlot("heatmap",{order:bp.heatmap,visible:!!he.activeHeatMap,source:G5e({wm:he.websocketManager,dpr:xO,tileSize:Fb,buildRequest:(s,n,r)=>Pxt(s,n,r,he)})})}function rDe(s){if(he.heatMapData=s,he.activeHeatMap=s.active||"",he.heatMapLayer){let n=he.heatMapLayer.isVisible();he.heatMapLayer.setVisible(!!he.activeHeatMap),n&&he.heatMapLayer.refresh()}he.renderHeatMapControls&&he.renderHeatMapControls(s)}he.updateHeatMaps=rDe;function sDe(){he.overlayLayer&&he.overlayLayer.refresh()}var mk=yT(()=>{sDe(),he.selectionBrowser&&he.selectionBrowser.scheduleRefresh()});he.refreshOverlay=mk;function J1(){Uf("or_visibility",encodeURIComponent(JSON.stringify(mg))),Uf("or_selectability",encodeURIComponent(JSON.stringify(LO))),Ub();let s=[[he.modulesLayer,mg.module_view],[he.pinsLayer,mg.pins],...he.overlayLayers.map(({def:n,layer:r})=>[r,nde(n.shown_by,mg)])];for(let[n,r]of s)n&&(n.visible=!!r);for(let n of he.allLayers)n.refresh();he.heatMapLayer&&he.heatMapLayer.refresh(),he.renderSelectionOutline&&he.renderSelectionOutline(),!mg.highlight_selected&&he.clearSelectionPulse&&he.clearSelectionPulse(),sDe(),he.rulerManager&&he.rulerManager.updateVisibility(),he.labelManager&&he.labelManager.updateVisibility(),he.updateScaleBar&&he.updateScaleBar()}var PO=yT(J1),Ub=yT(()=>{!he.websocketManager||ua(he)||he.websocketManager.request({type:"set_display_state",state:N3t()}).catch(()=>{})});he.syncDisplayState=Ub;function kpn(s){if(!s||typeof s!="object")return;let n=s.entries;if(!(!n||typeof n!="object")){F3t(n);try{if(he.view&&he.designScale&&typeof sessionStorage<"u"){let[r,c]=he.view.getCenter(),{dbuX:u,dbuY:d}=kv(r,c,he.designScale,he.designOriginX,he.designOriginY);sessionStorage.setItem("or_restore_view",JSON.stringify({dbuX:u,dbuY:d,zoom:he.view.getZoom()}))}}catch{}window.location.reload()}}he.redrawAllLayers=J1;he.captureLayout=(s={})=>W3t(he,s);function Rpn(s){let n=Dxt(s);if(n){try{if(sessionStorage.getItem("or_sw_render_warned"))return;sessionStorage.setItem("or_sw_render_warned","1")}catch{}Y1(n,15e3)}}function Ipn(s){let n=document.createElement("div");n.className="layout-viewer",n.style.width="100%",n.style.height="100%",n.style.backgroundColor="var(--bg-map)",s.element.appendChild(n);let r=document.createElement("div");r.className="or-hud or-hud-bottom-right heatmap-map-legend hidden",n.appendChild(r),he.heatMapLegendEl=r;let c=document.createElement("div");c.className="or-progress",n.appendChild(c),he.tileProgressEl=c,s.on("destroy",()=>{he.tileProgressEl=null,he.heatMapLegendEl=null}),he.view=Jxt(n,{preserveDrawingBuffer:he.preserveBuffer,prefs:{smooth:()=>he.controlSmoothing,doubleBuffer:()=>he.doubleBuffer,defer:()=>he.deferTileUpdates},tileSize:Fb,dpr:xO,isStatic:ua(he)}),he.view.on("contextlost",()=>{console.warn("Layout view: WebGL context lost; rebuilding the view.")}),he.view.on("contextfailed",()=>{Y1("The layout view lost its graphics context and could not get it back; reload the page.",15e3)}),he.view.on("renderer",Rpn),window.__orView=he.view,bxt(()=>{he.view.invalidateSize(),J1()});let u=document.createElement("div");u.className="or-zoom-control";let d=[];for(let[Z,H,te]of[["+","Zoom in",()=>he.view.zoomIn()],["\u2212","Zoom out",()=>he.view.zoomOut()],["\u2922","Fit",()=>{he.fitRect&&he.view.fitWorldRect(he.fitRect)}]]){let oe=document.createElement("button");oe.type="button",oe.title=H,oe.setAttribute("aria-label",H),oe.textContent=Z,oe.addEventListener("click",ne=>{ne.stopPropagation(),te()}),u.appendChild(oe),d.push(oe)}n.appendChild(u);let b=()=>{let{minZoom:Z,maxZoom:H}=he.view.getLimits(),te=he.view.getTargetZoom();d[0].disabled=te>=H,d[1].disabled=te<=Z};he.view.on("zoom zoomend limits",b),b();let w=document.createElement("div");w.className="or-hud or-hud-bottom-left hidden";let _=document.createElement("div");_.id="scale-bar";let x=document.createElement("span");x.className="or-hud-divider";let T=document.createElement("div");T.id="coord-bar",w.appendChild(_),w.appendChild(x),w.appendChild(T),n.appendChild(w);function M(){let Z=_.style.display!=="none"&&_.childElementCount>0,H=T.textContent!=="";x.style.display=Z&&H?"":"none",w.classList.toggle("hidden",!Z&&!H)}M(),e3t(he.view,{isStatic:()=>ua(he),wheelZoom:()=>he.wheelZoom,arrowStep:()=>he.arrowStep,contextEnabled:()=>!(he.rulerManager&&he.rulerManager.isActive()),onClick:(Z,H)=>{he.rulerManager&&he.rulerManager.isActive()?he.rulerManager.handleMapClick(Z,H):he.rulerManager?.handleRulerClick(Z)||he.onMapClick&&he.onMapClick(Z,H)},onContextClick:(Z,H)=>{he.onMapContextClick&&he.onMapContextClick(Z,H)},onMove:(Z,H)=>{if(he.lastMouseWorld=Z,he.rulerManager&&he.rulerManager.isActive()&&he.rulerManager.handleMouseMove(Z,H),!he.designScale)return;let{dbuX:te,dbuY:oe}=kv(Z[0],Z[1],he.designScale,he.designOriginX,he.designOriginY);T.textContent=`X: ${he.formatDbu(te)} Y: ${he.formatDbu(oe)}`,M()},onLeave:()=>{he.lastMouseWorld=null,T.textContent="",M()}});let L=22,I=8,D=22;function F(Z,H,te){let ne=2+I,ue=D,Te=D+Z,Q=L-2,ge=Z>=40,Qe=[];if(Qe.push(``),ge&&te>1)for(let st=1;st`)}ge&&Qe.push(`0`),Qe.push(`${H}`),_.innerHTML=`${Qe.join("")}`}function O(){if(!he.designScale||!mg.scale_bar){_.style.display="none",M();return}let Z=he.designScale*Math.pow(2,he.view.getZoom()),H=he.view.getSize().width||400,te=Wxt({targetPx:H*.15,pxPerDbu:Z,dbuPerMicron:he.techData?.dbu_per_micron,showDbu:he.showDbu});if(!te){_.style.display="none",M();return}_.style.display="",F(te.barPx,te.label,te.segments),M()}let z=yT(O);he.view.on("zoom zoomend resize",z),he.updateScaleBar=O,he.rulerManager=new ode(he,mg,lH,gde),he.labelManager=new cde(he,mg,lH,gde)}function Dpn(s){let n=document.createElement("div");n.className="display-controls",n.innerHTML='
Loading layers...
',s.element.appendChild(n),he.displayControlsEl=n}var iDe="or_restore_console",Bpn=1<<20;function Opn(){try{if(he.tclOutputEl){let s=[...he.tclOutputEl.children].map(u=>[u.textContent,u.className]),n=s.length,r=0;for(;n>0&&r+s[n-1][0].length<=Bpn;)r+=s[--n][0].length;let c=s.slice(n);n>0&&c.unshift([`[earlier output not kept across reload] -`,""]),sessionStorage.setItem(iDe,JSON.stringify(c))}}catch{}window.location.reload()}function Npn(){try{let s=sessionStorage.getItem(iDe);if(!s)return;sessionStorage.removeItem(iDe);for(let[n,r]of JSON.parse(s))CT(n,r)}catch{}}function CT(s,n){if(!he.tclOutputEl)return;let r=document.createElement("span");n&&(r.className=n),r.textContent=s,he.tclOutputEl.appendChild(r),he.tclOutputEl.scrollTop=he.tclOutputEl.scrollHeight}function Fpn(){if(he._shutdownHandled)return;he._shutdownHandled=!0,he.websocketManager&&(he.websocketManager._shutdown=!0,he.websocketManager.onPush=()=>{});let s=document.createElement("div");s.style.cssText="position:fixed;inset:0;z-index:99999;background:#1e1e1e;color:#ddd;display:flex;flex-direction:column;align-items:center;justify-content:center;font-family:system-ui,sans-serif;font-size:16px;padding:24px;text-align:center;",s.innerHTML='
OpenROAD exited
You can close this tab.
',document.body.appendChild(s),setTimeout(()=>{try{window.close()}catch{}},1500)}function Upn(s){let n=document.createElement("div");if(n.className="tcl-console",n.innerHTML='
%
',s.element.appendChild(n),he.tclOutputEl=n.querySelector(".tcl-output"),Npn(),ua(he)){n.querySelector(".tcl-input-row").style.display="none";let u=document.createElement("span");u.className="tcl-static-notice",u.setAttribute("role","status"),u.setAttribute("aria-live","polite"),u.textContent="Tcl console is not available in saved reports.",he.tclOutputEl.appendChild(u);return}let r=n.querySelector(".tcl-input"),c=new fde(r,he.websocketManager);r.addEventListener("keydown",u=>{if(!c.handleKeyDown(u)&&u.key==="Enter"){let d=r.value.trim();if(!d)return;CT(`>>> ${d} + `,document.body.appendChild(this._overlay),this._breadcrumb=this._overlay.querySelector(".fb-breadcrumb"),this._fileList=this._overlay.querySelector(".fb-file-list"),this._pathInput=this._overlay.querySelector(".fb-path-input"),this._errorDiv=this._overlay.querySelector(".modal-error"),this._okBtn=this._overlay.querySelector(".ok"),this._cancelBtn=this._overlay.querySelector(".cancel"),this._listen(this._pathInput,"input",()=>this._updateOkState()),this._listen(this._pathInput,"keydown",n=>{if(n.key==="Enter"){let r=this._pathInput.value.trim();r.endsWith("/")?this._navigate(r.replace(/\/+$/,"")||"/"):this._submit()}else n.key==="Escape"&&this.close()}),this._listen(this._okBtn,"click",()=>this._submit()),this._listen(this._cancelBtn,"click",()=>this.close()),this._listen(this._overlay,"click",n=>{n.target===this._overlay&&this.close()}),this._navigate("")}close(){if(!this._closed){this._closed=!0;for(let n of this._disposers)n();this._disposers.length=0,this._overlay&&(this._overlay.remove(),this._overlay=null)}}_listen(n,r,c){n.addEventListener(r,c),this._disposers.push(()=>n.removeEventListener(r,c))}_updateOkState(){this._okBtn.disabled=!this._pathInput.value.trim()}_renderBreadcrumb(n){this._breadcrumb.innerHTML="";let r=n.split("/").filter(Boolean),c=document.createElement("span");c.className="fb-crumb",c.textContent="/",this._listen(c,"click",()=>this._navigate("/")),this._breadcrumb.appendChild(c);let u="";for(let d of r){u+="/"+d;let b=document.createElement("span");b.className="fb-crumb-sep",b.textContent=" / ",this._breadcrumb.appendChild(b);let w=document.createElement("span");w.className="fb-crumb",w.textContent=d;let _=u;this._listen(w,"click",()=>this._navigate(_)),this._breadcrumb.appendChild(w)}}_renderEntries(n){if(this._fileList.innerHTML="",!n||n.length===0){let r=document.createElement("div");r.className="fb-empty",r.textContent="(empty directory)",this._fileList.appendChild(r);return}for(let r of n){let c=document.createElement("div");c.className="fb-entry",r.is_dir&&c.classList.add("fb-dir");let u=document.createElement("span");u.className="fb-icon",u.textContent=r.is_dir?"\u{1F4C1}":"\u{1F4C4}",c.appendChild(u);let d=document.createElement("span");d.className="fb-name",d.textContent=r.name,c.appendChild(d),r.is_dir?this._listen(c,"click",()=>this._navigate(this._currentPath+"/"+r.name)):(this._listen(c,"click",()=>{let b=this._fileList.querySelector(".fb-selected");b&&b.classList.remove("fb-selected"),c.classList.add("fb-selected"),this._pathInput.value=this._currentPath+"/"+r.name,this._updateOkState()}),this._listen(c,"dblclick",()=>{this._pathInput.value=this._currentPath+"/"+r.name,this._updateOkState(),this._submit()})),this._fileList.appendChild(c)}}async _navigate(n){this._errorDiv.style.display="none",this._fileList.innerHTML='
Loading...
';try{let r=await this._app.websocketManager.request({type:"list_dir",path:n||""});if(this._closed)return;this._currentPath=r.path,this._renderBreadcrumb(r.path),this._renderEntries(r.entries),this._pathInput.value="",this._updateOkState()}catch(r){if(this._closed)return;this._fileList.innerHTML="",this._errorDiv.textContent=r.message||String(r),this._errorDiv.style.display=""}}async _submit(){let n=this._pathInput.value.trim();if(n){this._okBtn.disabled=!0,this._okBtn.textContent="Loading...",this._errorDiv.style.display="none";try{let r=await this._app.websocketManager.request({type:"drc_load_report",path:n});if(this._closed)return;if(r.ok){let c=r.category;this.close(),this._onLoaded(c)}else this._errorDiv.textContent=r.error||"Failed to load report",this._errorDiv.style.display="",this._okBtn.disabled=!1,this._okBtn.textContent="Load"}catch(r){if(this._closed)return;this._errorDiv.textContent=r.message||"Request failed",this._errorDiv.style.display="",this._okBtn.disabled=!1,this._okBtn.textContent="Load"}}}};var lpn=` +\r[]{}`;var fde=class{constructor(n,r){this._input=n,this._ws=r,this._popup=null,this._items=[],this._selectedIndex=-1,this._replaceStart=0,this._replaceEnd=0,this._debounceTimer=null,this._commandCache=null,this._history=[],this._historyIndex=-1,this._historyStash="",this._createPopup(),this._onInputBound=this._onInput.bind(this),this._onBlurBound=this._onBlur.bind(this),this._input.addEventListener("input",this._onInputBound),this._input.addEventListener("blur",this._onBlurBound)}_createPopup(){this._popup=document.createElement("div"),this._popup.className="tcl-complete-popup",this._popup.style.display="none",this._input.parentElement.appendChild(this._popup)}handleKeyDown(n){let r=this._popup.style.display!=="none";return n.key==="Tab"?(n.preventDefault(),r?this._tabAccept():this._tabComplete(this._input.value,this._input.selectionStart),!0):n.key==="Escape"?r?(this._hidePopup(),!0):!1:n.key==="ArrowDown"?r?(n.preventDefault(),this._selectItem(this._selectedIndex+1),!0):this._historyIndex>=0?(n.preventDefault(),this._historyIndex--,this._historyIndex<0?this._input.value=this._historyStash:this._input.value=this._history[this._historyIndex],!0):!1:n.key==="ArrowUp"?r?(n.preventDefault(),this._selectItem(this._selectedIndex-1),!0):this._historyIndex{let n=this._input.value,r=this._input.selectionStart,c=this._extractPrefix(n,r);c.length>=2||c.length>=1&&(c[0]==="$"||c[0]==="-")?this._requestCompletions(n,r):this._hidePopup()},100)}_onBlur(){setTimeout(()=>this._hidePopup(),150)}_extractPrefix(n,r){let c=r-1;for(;c>=0&&lpn.indexOf(n[c])===-1;)c--;return n.substring(c+1,r)}_fetchCompletions(n,r,c){let u=this._extractPrefix(n,r),d=u.length>0&&u[0]==="$",b=u.length>0&&u[0]==="-",w=!d&&!b,_=r-u.length,x=n.substring(0,_),T=/^[\s\[]*$/.test(x);if(w&&T&&this._commandCache){let M=u.toLowerCase(),L=this._commandCache.filter(I=>I.toLowerCase().startsWith(M));c(L,_,r);return}this._ws.request({type:"tcl_complete",line:n,cursor_pos:r}).then(M=>{M.mode==="commands"&&!this._commandCache&&u===""&&(this._commandCache=M.completions),M.mode==="commands"&&!this._commandCache&&this._ws.request({type:"tcl_complete",line:"",cursor_pos:0}).then(L=>{L.mode==="commands"&&(this._commandCache=L.completions)}).catch(()=>{}),c(M.completions,M.replace_start,M.replace_end)}).catch(()=>c([],0,0))}_requestCompletions(n,r){this._fetchCompletions(n,r,(c,u,d)=>{this._showPopup(c,u,d)})}_tabAccept(){if(this._items.length===0){this._hidePopup();return}if(this._items.length===1){this._selectedIndex=0,this._acceptCompletion();return}this._advanceToCommonPrefix()}_tabComplete(n,r){this._fetchCompletions(n,r,(c,u,d)=>{if(!c||c.length===0){this._hidePopup();return}if(c.length===1){this._items=c,this._replaceStart=u,this._replaceEnd=d,this._selectedIndex=0,this._acceptCompletion();return}this._items=c,this._replaceStart=u,this._replaceEnd=d,this._advanceToCommonPrefix(),this._showPopup(c,this._replaceStart,this._replaceEnd)})}_advanceToCommonPrefix(){if(this._items.length<2)return!1;let n=this._items[0];for(let b=1;b0;b++){let w=this._items[b],_=0;for(;_{let _=document.createElement("div");_.className="tcl-complete-item",_.textContent=b,_.addEventListener("mousedown",x=>{x.preventDefault(),this._selectedIndex=w,this._acceptCompletion()}),this._popup.appendChild(_)}),n.length>15){let b=document.createElement("div");b.className="tcl-complete-more",b.textContent=`... ${n.length-15} more`,this._popup.appendChild(b)}this._selectedIndex=0,this._highlightSelected(),this._popup.style.display="block"}_hidePopup(){this._popup.style.display="none",this._items=[],this._selectedIndex=-1}_selectItem(n){if(this._items.length===0)return;let r=Math.min(this._items.length,15)-1;this._selectedIndex=Math.max(0,Math.min(n,r)),this._highlightSelected()}_highlightSelected(){let n=this._popup.querySelectorAll(".tcl-complete-item");n.forEach((r,c)=>{r.classList.toggle("selected",c===this._selectedIndex)}),n[this._selectedIndex]&&n[this._selectedIndex].scrollIntoView&&n[this._selectedIndex].scrollIntoView({block:"nearest"})}_acceptCompletion(){if(this._selectedIndex<0||this._selectedIndex>=this._items.length){this._hidePopup();return}let n=this._items[this._selectedIndex],r=this._input.value.substring(0,this._replaceStart),c=this._input.value.substring(this._replaceEnd),d=!n.endsWith("/")&&!n.endsWith("::")&&(c.length===0||c[0]!==" ")?" ":"";this._input.value=r+n+d+c;let b=this._replaceStart+n.length+d.length;this._input.setSelectionRange(b,b),this._input.focus(),this._hidePopup()}};var N3t=[{key:"or_visibility",store:"cookie"},{key:"or_selectability",store:"cookie"},{key:"or_hidden_layers",store:"session"},{key:"or_nonselectable_layers",store:"session"},{key:"or_layer_patterns",store:"session"},{key:"or_hidden_chiplets",store:"cookie"},{key:"or_bg_color",store:"cookie"},{key:"or_show_dbu",store:"cookie"},{key:"or_theme",store:"theme"},{key:"or_use_true_z",store:"cookie"},{key:"or_ruler_style",store:"cookie"},{key:"or_wheel_zoom",store:"cookie"},{key:"or_arrow_step",store:"cookie"},{key:"or_font_family",store:"cookie"},{key:"or_font_scale",store:"cookie"},{key:"or_control_smoothing",store:"cookie"},{key:"or_double_buffer",store:"cookie"},{key:"or_defer_tile_updates",store:"cookie"}];function F3t(s){return{controlSmoothing:s("or_control_smoothing")==="1",doubleBuffer:s("or_double_buffer")!=="0",deferTileUpdates:s("or_defer_tile_updates")==="1"}}function upn(s,n){try{return window[s].getItem(n)}catch{return null}}function fpn(s,n,r){try{r===null?window[s].removeItem(n):window[s].setItem(n,r)}catch{}}function hpn({key:s,store:n}){return n==="session"?upn("sessionStorage",s):zf(s)}function dpn({key:s,store:n},r){n==="session"?fpn("sessionStorage",s,r):n==="theme"?r===null?i3t():Whe(r):r===null?Vhe(s):gf(s,r)}function U3t(){let s={};for(let n of N3t){let r=hpn(n);r&&(s[n.key]=r)}return{version:1,entries:s}}function ppn(s){return typeof s=="string"&&s!==""&&!/[;\r\n]/.test(s)}function z3t(s){for(let n of N3t){let r=s[n.key];dpn(n,ppn(r)?r:null)}}function G3t(s,n=typeof document<"u"?document:null){let r="OpenROAD",c=s?`${r} - ${s}`:r;return n&&(n.title=c),c}var $s=globalThis.THREE,j3t=2,gpn=.002,mpn=.9,bpn=1.1,wpn=.1,vpn=20,_pn=3,gk=2,$3t=2,ypn=10,xpn=1e4,Epn=.15,Spn=300,Mpn=6,hde=Math.PI/180,V3t=[5025616,2201331,16750592,10233776,48340,16007990,2533018,7951688,15277667,4149685];function Tpn(s){let n=new Array(s.length).fill(0),r=new Map;s.forEach((c,u)=>{let d=c.z;r.has(d)||r.set(d,[]),r.get(d).push({idx:u,chiplet:c})});for(let c of r.values()){if(c.length<=1)continue;let u=[];for(let{idx:d,chiplet:b}of c){let w=b.x,_=b.y,x=b.x+b.width,T=b.y+b.height,M=!1;for(let L=0;LwD.x1&&_D.y1)){u[L].push({x1:w,y1:_,x2:x,y2:T}),n[d]=L,M=!0;break}M||(u.push([{x1:w,y1:_,x2:x,y2:T}]),n[d]=u.length-1)}}return n}var dde=class{constructor(n,r){if(this._app=r,this._container=n,this._element=document.createElement("div"),this._element.className="three-d-viewer-widget",n.element.appendChild(this._element),!$s){ua(r)?this._showInfo("The 3D view is not available in saved reports."):this._showError("three.js is missing from the page."),this._destroyed=!0;return}this._canvasContainer=document.createElement("div"),this._canvasContainer.className="three-d-canvas-container",this._element.appendChild(this._canvasContainer),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._canvasContainer.appendChild(this._tooltip),this._optionsOverlay=this._createOptionsOverlay(),this._canvasContainer.appendChild(this._optionsOverlay),this._raycaster=new $s.Raycaster,this._scene=new $s.Scene,this._applyTheme(),this._themeObserver=new MutationObserver(()=>{this._applyTheme(),this.render()}),this._themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),this._camera=new $s.PerspectiveCamera(45,1,10,1e5),this._camera.position.set(0,0,1e3);try{this._renderer=new $s.WebGLRenderer({antialias:!0,preserveDrawingBuffer:!0})}catch(b){console.error("3D viewer: failed to create WebGL context:",b),this._showWebGLUnavailable(b),this._themeObserver&&(this._themeObserver.disconnect(),this._themeObserver=null),this._destroyed=!0;return}this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(n.width,n.height),this._canvasContainer.appendChild(this._renderer.domElement),this._rotation=new $s.Quaternion,this._distance=1e3,this._panX=0,this._panY=0,this._boundingRadius=1,this._sceneCenter=new $s.Vector3,this._mouseDown=!1,this._mouseButton=-1,this._lastMousePos={x:0,y:0},this._setupMouseHandlers();let c=new $s.AmbientLight(16777215,.5);this._scene.add(c);let u=new $s.DirectionalLight(16777215,.8);u.position.set(1,1,1).normalize(),this._scene.add(u);let d=new $s.DirectionalLight(16777215,.3);d.position.set(-1,-.5,.5).normalize(),this._scene.add(d),n.on("resize",this.onResize.bind(this)),n.on("open",this.onOpen.bind(this)),n.on("destroy",this.onDestroy.bind(this)),this._designGroup=new $s.Group,this._scene.add(this._designGroup),this._chipletMeshes=[],this._loading=!1,this._destroyed=!1,this._edgeMaterial=null}_setupMouseHandlers(){let n=this._renderer.domElement;n.addEventListener("mousedown",r=>{this._mouseDown=!0,this._mouseButton=r.button,this._lastMousePos.x=r.clientX,this._lastMousePos.y=r.clientY,n.focus(),r.preventDefault()}),n.addEventListener("contextmenu",r=>r.preventDefault()),this._onMouseMove=r=>{if(!this._mouseDown)return;let c=r.clientX-this._lastMousePos.x,u=r.clientY-this._lastMousePos.y;this._lastMousePos.x=r.clientX,this._lastMousePos.y=r.clientY,!(c===0&&u===0)&&(this._mouseButton===0?this._handleRotate(c,u):this._mouseButton===2&&this._handlePan(c,u),this._updateCamera())},this._onMouseUp=r=>{this._mouseDown&&r.button===this._mouseButton&&(this._mouseDown=!1,this._mouseButton=-1)},window.addEventListener("mousemove",this._onMouseMove),window.addEventListener("mouseup",this._onMouseUp),n.addEventListener("wheel",r=>{r.preventDefault(),r.deltaY<0?this._distance*=mpn:this._distance*=bpn;let c=Math.max(this._boundingRadius*wpn,1),u=Math.max(this._boundingRadius*vpn,c);this._distance=Math.max(c,Math.min(u,this._distance)),this._updateCamera()},{passive:!1}),n.tabIndex=0,n.style.outline="none",n.addEventListener("keydown",r=>{r.key.toLowerCase()==="f"&&this.resetCamera()}),n.addEventListener("dblclick",r=>{r.preventDefault();let c=this._pickDrcMarkerId(r);if(c!=null&&this._app.drcWidget){this._app.drcWidget.highlightMarkerById(c,!0);return}this.resetCamera()}),n.addEventListener("mousemove",r=>{if(this._mouseDown){this._hideTooltip();return}this._updateTooltip(r)}),n.addEventListener("mouseleave",()=>{this._hideTooltip()})}_createOptionsOverlay(){let n=document.createElement("div");n.className="three-d-options";let r=document.createElement("label");r.title="Render chiplets at their true Z (disable stacking offset for overlapping chiplets at same Z).";let c=document.createElement("input");c.type="checkbox",c.checked=!!this._app.useTrueZ,c.addEventListener("change",()=>{this._app.useTrueZ=c.checked,gf("or_use_true_z",c.checked?"1":"0"),this._app.syncDisplayState(),this.refreshSceneForOptions()}),r.appendChild(c),r.appendChild(document.createTextNode("True Z (no stacking)")),n.appendChild(r);let u=document.createElement("div");u.style.cssText="margin-top:4px; display:flex; gap:4px;";let d=document.createElement("button");d.className="or-btn or-btn-sm",d.textContent="Save PNG",d.title="Save the 3D view as a PNG image (2x resolution)",d.addEventListener("click",()=>this._exportPng(2));let b=document.createElement("button");return b.className="or-btn or-btn-sm",b.textContent="Copy",b.title="Copy the 3D view image to the clipboard",b.addEventListener("click",()=>this._copyImage(2)),u.appendChild(d),u.appendChild(b),n.appendChild(u),n}_capturePng(n=2){if(!this._renderer)return null;let r=this._renderer,c=r.domElement.clientWidth||r.domElement.width,u=r.domElement.clientHeight||r.domElement.height,d=r.getPixelRatio();try{return r.setPixelRatio(d*n),r.setSize(c,u,!1),this.render(),r.domElement.toDataURL("image/png")}finally{r.setPixelRatio(d),r.setSize(c,u,!1),this.render()}}_exportPng(n=2){let r=this._capturePng(n);r&&hk(r,"3d-view.png")}async _copyImage(n=2){let r=this._capturePng(n);r&&await Hhe(r)}_setRaycasterFromEvent(n){let c=this._renderer.domElement.getBoundingClientRect(),u=new $s.Vector2((n.clientX-c.left)/c.width*2-1,-((n.clientY-c.top)/c.height*2-1));this._raycaster.setFromCamera(u,this._camera)}_updateTooltip(n){if(!this._chipletMeshes.length){this._hideTooltip();return}this._setRaycasterFromEvent(n);let r=this._chipletMeshes.map(w=>w.mesh),c=this._raycaster.intersectObjects(r,!1);if(c.length===0){this._hideTooltip();return}let u=c[0].object,d=this._chipletMeshes.find(w=>w.mesh===u);if(!d){this._hideTooltip();return}this._tooltip.textContent=d.data.name,this._tooltip.style.display="block";let b=this._canvasContainer.getBoundingClientRect();this._tooltip.style.left=n.clientX-b.left+12+"px",this._tooltip.style.top=n.clientY-b.top+12+"px"}_hideTooltip(){this._tooltip&&(this._tooltip.style.display="none")}_pickDrcMarkerId(n){if(!this._drcHitboxMesh||!this._drcHitboxMarkerIds)return null;this._setRaycasterFromEvent(n);let r=this._raycaster.intersectObject(this._drcHitboxMesh,!1);if(r.length===0)return null;let c=r[0].instanceId;return c==null?null:this._drcHitboxMarkerIds[c]??null}_handleRotate(n,r){let c=Math.sqrt(n*n+r*r);if(c<.001)return;let u=new $s.Vector3(r/c,n/c,0),d=c/j3t,w=new $s.Quaternion().setFromAxisAngle(u,d*hde).clone().multiply(this._rotation);if(new $s.Vector3(0,0,1).applyQuaternion(w).z>=0)this._rotation.copy(w);else{let x=new $s.Vector3(0,1,0),T=n/j3t*hde,L=new $s.Quaternion().setFromAxisAngle(x,T).clone().multiply(this._rotation);new $s.Vector3(0,0,1).applyQuaternion(L).z>=0&&this._rotation.copy(L)}}_handlePan(n,r){let c=this._distance*gpn;this._panX+=n*c,this._panY-=r*c}_updateCamera(){let n=Math.max(this._boundingRadius,1e3),r=Math.max(this._distance-n*$3t,ypn),c=this._distance+n*$3t;c0;){let n=this._designGroup.children[0];this._designGroup.remove(n),n.geometry&&n.geometry.dispose(),n.material&&!n.material._shared&&n.material.dispose()}this._edgeMaterial&&(this._edgeMaterial.dispose(),this._edgeMaterial=null),this._onMouseMove&&(window.removeEventListener("mousemove",this._onMouseMove),this._onMouseMove=null),this._onMouseUp&&(window.removeEventListener("mouseup",this._onMouseUp),this._onMouseUp=null),this._renderer&&(this._renderer.dispose(),this._renderer=null),this._app.threeDViewerWidget===this&&(this._app.threeDViewerWidget=null)}}_setInitialCameraState(){this._distance=this._boundingRadius*_pn;let n=new $s.Quaternion().setFromAxisAngle(new $s.Vector3(1,0,0),-45*hde),r=new $s.Quaternion().setFromAxisAngle(new $s.Vector3(0,0,1),45*hde);this._rotation=n.multiply(r),this._panX=0,this._panY=0}resetCamera(){this._sceneBounds&&(this._setInitialCameraState(),this._updateCamera())}onResize(){if(this._destroyed)return;let n=this._canvasContainer.getBoundingClientRect(),r=n.width,c=n.height;r===0||c===0||(this._camera.aspect=r/c,this._camera.updateProjectionMatrix(),this._renderer.setSize(r,c),this.render())}render(){this._destroyed||this._renderer&&this._scene&&this._camera&&this._renderer.render(this._scene,this._camera)}_applyTheme(){let r=fk().bgMap||"#000000";this._scene.background=new $s.Color(r)}async loadData(){if(!(this._loading||this._destroyed)){this._loading=!0;for(let n of[".three-d-error",".three-d-info"]){let r=this._element.querySelector(n);r&&r.remove()}try{await this._app.websocketManager.readyPromise;let n=await this._app.websocketManager.request({type:"get_3d_data"});if(this._destroyed)return;if(n&&n.error){this._showError(n.error);return}if(n&&n.info){this._showInfo(n.info);return}this.buildScene(n)}catch(n){if(this._destroyed)return;console.error("Failed to load 3D data:",n),this._showError(n.message||String(n))}finally{this._loading=!1}}}_showOverlay(n,r,c){let u=document.createElement("div");u.className=n,u.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-family:monospace;text-align:center;",u.style.color=c,u.textContent=r,this._element.appendChild(u)}_showError(n){this._showOverlay("three-d-error","Failed to load 3D data: "+n,"var(--error)")}_showInfo(n){this._showOverlay("three-d-info",n,"var(--fg-muted, #888)")}_showWebGLUnavailable(n){let r=document.createElement("div");r.className="three-d-error",r.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-family:monospace;text-align:center;max-width:80%;color:var(--error);";let c=n&&n.message?n.message:String(n||"");r.innerHTML='
3D viewer unavailable: WebGL context could not be created.
In Chrome, open chrome://flags/#ignore-gpu-blocklist and set Override software rendering list to Enabled, then relaunch the browser.
Otherwise enable hardware acceleration or try a different browser. See chrome://gpu for details.
'+(c?'
'+c+"
":""),this._element.appendChild(r)}buildScene(n){if(this._destroyed||(this._lastSceneData=n,this._clearScene(),!n||!n.chiplets||n.chiplets.length===0))return;let r=this._app.getDbuPerMicron(),c=this._buildChiplets(n.chiplets,r);c.minX!==1/0&&(this._buildGrid(c),this._setSceneBoundsAndCenter(c),this._setInitialCameraState(),this._updateCamera())}_clearScene(){for(this._chipletMeshes=[];this._designGroup.children.length>0;){let n=this._designGroup.children[0];this._designGroup.remove(n),n.geometry&&n.geometry.dispose(),n.material&&!n.material._shared&&n.material.dispose()}this._hideTooltip()}_buildChiplets(n,r){let c={minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0};this._edgeMaterial||(this._edgeMaterial=new $s.LineBasicMaterial({color:0,linewidth:1}),this._edgeMaterial._shared=!0);let u=this._app.useTrueZ?new Array(n.length).fill(0):Tpn(n);return n.forEach((d,b)=>{let w=d.width/r,_=d.height/r,x=d.thickness/r*gk,T=V3t[b%V3t.length],M=new $s.MeshPhongMaterial({color:T,transparent:!1,opacity:1,side:$s.DoubleSide,shininess:40}),L=new $s.BoxGeometry(w,_,x),I=new $s.Mesh(L,M),D=d.x/r+w/2,F=d.y/r+_/2,O=x*Epn,z=d.z/r*gk+x/2+u[b]*(x+O);I.position.set(D,F,z),this._designGroup.add(I),this._chipletMeshes.push({mesh:I,data:d,color:T});let Z=new $s.EdgesGeometry(L),H=new $s.LineSegments(Z,this._edgeMaterial);H.position.set(D,F,z),this._designGroup.add(H),c.minX=Math.min(c.minX,d.x/r),c.minY=Math.min(c.minY,d.y/r),c.minZ=Math.min(c.minZ,z-x/2),c.maxX=Math.max(c.maxX,d.x/r+w),c.maxY=Math.max(c.maxY,d.y/r+_),c.maxZ=Math.max(c.maxZ,z+x/2)}),c}_buildGrid(n){let r=n.maxX-n.minX,c=n.maxY-n.minY,u=Math.max(r,c)*1.4,d=10,b=new $s.GridHelper(u,d,8947848,4473924);b.rotation.x=Math.PI/2,b.position.set((n.minX+n.maxX)/2,(n.minY+n.maxY)/2,n.minZ-1),this._designGroup.add(b)}_setSceneBoundsAndCenter(n){this._sceneBounds=n;let r=n.maxX-n.minX,c=n.maxY-n.minY,u=n.maxZ-n.minZ;this._boundingRadius=Math.sqrt(r*r+c*c+u*u)/2,this._sceneCenter.set((n.minX+n.maxX)/2,(n.minY+n.maxY)/2,(n.minZ+n.maxZ)/2)}_stackOffsetForPoint(n,r,c,u){for(let{mesh:d,data:b}of this._chipletMeshes){if(n!==b.z||rb.x+b.width||cb.y+b.height)continue;let w=b.thickness/u*gk,_=b.z/u*gk+w/2;return d.position.z-_}return 0}clearHighlightDRC(){this._drcBlinkInterval&&(clearInterval(this._drcBlinkInterval),this._drcBlinkInterval=null),this._drcMeshGroup&&(this._scene.remove(this._drcMeshGroup),this._drcMeshGroup.children.forEach(n=>{n.geometry&&n.geometry.dispose()}),this._drcMaterial&&(this._drcMaterial.dispose(),this._drcMaterial=null),this._drcHitboxMaterial&&(this._drcHitboxMaterial.dispose(),this._drcHitboxMaterial=null),this._drcHitboxMesh=null,this._drcHitboxMarkerIds=null,this._drcMeshGroup=null,this.render())}highlightDRC(n){if(this._destroyed||(this.clearHighlightDRC(),!n||n.length===0))return;let r=this._app.getDbuPerMicron(),c=0,u=1e4/r*gk;this._sceneBounds&&this._sceneBounds.minZ!==1/0&&(c=this._sceneBounds.minZ,u=this._sceneBounds.maxZ),c-=1,u+=1;let d=Math.max(u-c,1);this._drcMeshGroup=new $s.Group,this._drcMaterial=new $s.LineBasicMaterial({color:16776960,transparent:!0,opacity:1,depthTest:!1,depthWrite:!1}),this._drcHitboxMaterial=new $s.MeshBasicMaterial({transparent:!0,opacity:0,depthWrite:!1});let b=[];for(let x of n){let T=x.rects&&x.rects.length>0?x.rects:[x.bbox];for(let M of T){let[L,I,D,F,O,z]=M,Z=Math.max((D-L)/r,.001),H=Math.max((F-I)/r,.001),te=c,oe=d,ne=0;if(M.length>=6&&O!==void 0&&z!==void 0){te=O/r*gk;let ge=z/r*gk;oe=Math.max(ge-te,.001),ne=this._stackOffsetForPoint(O,(L+D)/2,(I+F)/2,r)}let ue=L/r+Z/2,Te=I/r+H/2,Q=te+oe/2+ne;b.push({cx:ue,cy:Te,cz:Q,width:Z,height:H,depth:oe,markerId:x.id})}}if(b.length>0){let x=new $s.BoxGeometry(1,1,1);this._drcHitboxMesh=new $s.InstancedMesh(x,this._drcHitboxMaterial,b.length),this._drcHitboxMarkerIds=new Array(b.length);let T=new $s.Matrix4,M=new $s.Vector3,L=new $s.Vector3,I=new $s.Quaternion;b.forEach((D,F)=>{L.set(D.cx,D.cy,D.cz),M.set(D.width,D.height,D.depth),T.compose(L,I,M),this._drcHitboxMesh.setMatrixAt(F,T),this._drcHitboxMarkerIds[F]=D.markerId;let O=new $s.BoxGeometry(D.width,D.height,D.depth),z=new $s.EdgesGeometry(O);O.dispose();let Z=new $s.LineSegments(z,this._drcMaterial);Z.position.set(D.cx,D.cy,D.cz),Z.renderOrder=999,this._drcMeshGroup.add(Z)}),this._drcHitboxMesh.instanceMatrix.needsUpdate=!0,this._drcMeshGroup.add(this._drcHitboxMesh)}this._drcMeshGroup.renderOrder=999,this._scene.add(this._drcMeshGroup),this.render();let w=!0,_=0;this._drcBlinkInterval=setInterval(()=>{if(!(!this._drcMeshGroup||!this._drcMaterial)){if(_+=1,_>=Mpn){this._drcMaterial.opacity=1,this.render(),clearInterval(this._drcBlinkInterval),this._drcBlinkInterval=null;return}w=!w,this._drcMaterial.opacity=w?1:.2,this.render()}},Spn)}refreshSceneForOptions(){this._destroyed||this._lastSceneData&&(this.clearHighlightDRC(),this.buildScene(this._lastSceneData))}};var Cpn=[{name:"green",hex:"#00ff00"},{name:"yellow",hex:"#ffff00"},{name:"cyan",hex:"#00ffff"},{name:"magenta",hex:"#ff00ff"},{name:"red",hex:"#ff0000"},{name:"dark_green",hex:"#008000"},{name:"dark_magenta",hex:"#800080"},{name:"blue",hex:"#0000ff"},{name:"orange",hex:"#ffa500"},{name:"purple",hex:"#800080"},{name:"lime",hex:"#bfff00"},{name:"teal",hex:"#008080"},{name:"pink",hex:"#ffc0cb"},{name:"brown",hex:"#8b4513"},{name:"indigo",hex:"#4b0082"},{name:"turquoise",hex:"#40e0d0"}],Apn=[{label:"Connected Insts",suffix:"connected_insts",needsNet:!0},{label:"Output Nets",suffix:"connected_nets",args:{output:!0,input:!1}},{label:"Input Nets",suffix:"connected_nets",args:{output:!1,input:!0}},{label:"All Nets",suffix:"connected_nets",args:{output:!0,input:!0}},{label:"All buffer trees",suffix:"connected_buffer_trees"},{label:"All buffer trees (incl. inverters)",suffix:"connected_buffer_trees",args:{include_inverters:!0}}],pde=class{constructor(n){this._app=n,this._el=document.createElement("div"),this._el.className="context-menu",this._el.style.display="none",this._el.style.zIndex="10000",document.body.appendChild(this._el),this._bindEvents()}_bindEvents(){document.addEventListener("mousedown",n=>{this._el.contains(n.target)||this.hide()}),this._app.view&&this._app.view.on("movestart",()=>this.hide())}show(n){this._el.innerHTML="";let r=!!this._app.selHasInst,c=!!this._app.selHasNet,u=!(r||c),d=I=>Apn.map(D=>({label:D.label,disabled:D.needsNet?!c:!r,...I(D.suffix,D.args||{})})),b=[{label:"Select",disabled:u,subMenu:d((I,D)=>({action:()=>this._sendContextAction("select_"+I,D)}))},{label:"Highlight",disabled:u,subMenu:d((I,D)=>({subMenu:this._buildColorSubmenu("highlight_"+I,D)}))},{label:"Save",subMenu:[{label:"Visible layout",action:()=>this._app.captureLayout?.({entire:!1})},{label:"Entire layout",action:()=>this._app.captureLayout?.({entire:!0})}]},{label:"Clear",subMenu:[{label:"Selections",action:()=>this._sendContextAction("clear_selections")},{label:"Highlights",action:()=>this._sendContextAction("clear_highlights")},{label:"Rulers",action:()=>{this._app.rulerManager?.clearAllRulers()}},{label:"Focus nets",action:()=>this._sendContextAction("clear_focus_nets")},{label:"Route Guides",action:()=>this._sendContextAction("clear_route_guides")},{label:"All",action:()=>{this._sendContextAction("clear_all"),this._app.rulerManager?.clearAllRulers()}}]}];this._buildMenu(b,this._el),this._el.style.display="block";let w=4,_=this._el.getBoundingClientRect(),x=window.innerWidth-_.width-w,T=window.innerHeight-_.height-w,M=Math.max(w,Math.min(n.clientX,x)),L=Math.max(w,Math.min(n.clientY,T));this._el.style.left=M+"px",this._el.style.top=L+"px"}hide(){this._el.style.display="none"}_buildColorSubmenu(n,r={}){return Cpn.map(({name:c,hex:u},d)=>({label:c,swatch:u,action:()=>this._sendContextAction(n,{...r,group:d})}))}_buildMenu(n,r){n.forEach(c=>{let u=document.createElement("div");if(u.className="cm-item",c.swatch){let d=document.createElement("span");d.className="cm-swatch",d.style.background=c.swatch,u.appendChild(d)}if(u.appendChild(document.createTextNode(c.label)),c.disabled){u.classList.add("disabled"),c.subMenu&&u.classList.add("has-submenu"),r.appendChild(u);return}if(c.subMenu){u.classList.add("has-submenu");let d=document.createElement("div");d.className="cm-submenu",this._buildMenu(c.subMenu,d),u.appendChild(d),u.addEventListener("mouseenter",()=>{d.classList.remove("flip-left"),d.getBoundingClientRect().right>window.innerWidth&&d.classList.add("flip-left")})}else c.action&&u.addEventListener("click",d=>{d.stopPropagation(),this.hide();try{c.action()}catch(b){console.error("Context menu item action threw:",c.label,b)}});r.appendChild(u)})}_sendContextAction(n,r={}){this._app.websocketManager&&this._app.websocketManager.request({type:"context_action",action:n,...r}).then(c=>{EO(this._app,c),c&&c.connected_count===0&&Fb('Nothing connected \u2014 select an instance (or a net for "Connected Insts") first.'),this._syncAfterAction(n)}).catch(c=>{console.error("Context action failed:",n,c)})}_syncAfterAction(n){let r=this._app;(n==="clear_focus_nets"||n==="clear_route_guides"||n==="clear_all")&&typeof r.redrawAllLayers=="function"&&r.redrawAllLayers(),n==="clear_selections"||n==="clear_all"?(r.updateInspector?.(null),r.stopSelectionAnimation?.(),r.clearSelectionOutline?.(),r.lastSelectionBounds=null):r.refreshInspector?.(),r.refreshOverlay?.()}};function W3t(s,n){if(!s)return;let r=URL.createObjectURL(s),c=document.createElement("a");c.href=r,c.download=n,c.style.display="none",document.body.appendChild(c),c.click(),document.body.removeChild(c),setTimeout(()=>URL.revokeObjectURL(r),0)}function Ppn(s,n,r){s.view.getContainer().querySelectorAll(".or-view-markers .ruler-label").forEach(u=>{let d=u.getBoundingClientRect();if(d.width<=0||d.height<=0)return;let b=u.textContent;if(!b)return;let w=getComputedStyle(u),_=d.left-r.left,x=d.top-r.top;n.save(),n.fillStyle=w.backgroundColor||"rgba(0, 0, 0, 0.75)";let T=Math.min(parseFloat(w.borderTopLeftRadius)||0,d.height/2);T>0&&typeof n.roundRect=="function"?(n.beginPath(),n.roundRect(_,x,d.width,d.height,T),n.fill()):n.fillRect(_,x,d.width,d.height),n.fillStyle=w.color||"#eee",n.font=w.font||`${w.fontSize||"12px"} ${w.fontFamily||"monospace"}`,n.textAlign="left",n.textBaseline="middle",n.fillText(b,_+(parseFloat(w.paddingLeft)||0),x+d.height/2),n.restore()})}async function H3t(s){let n=s.view.getContainer(),r=n.getBoundingClientRect(),c=Math.max(1,Math.round(r.width)),u=Math.max(1,Math.round(r.height)),d=document.createElement("canvas");d.width=c,d.height=u;let b=d.getContext("2d"),w=getComputedStyle(n).backgroundColor;b.fillStyle=w&&w!=="transparent"&&w!=="rgba(0, 0, 0, 0)"?w:"#000",b.fillRect(0,0,c,u);let _=await s.view.captureCanvas();if(_){let x=_.rect;try{b.drawImage(_.image,x.left-r.left,x.top-r.top,x.width,x.height)}catch{}}return Ppn(s,b,r),new Promise(x=>d.toBlob(x,"image/png"))}async function q3t(s,{entire:n=!1}={}){if(!s.view)return;if(!n||!s.fitRect){W3t(await H3t(s),"layout_visible.png");return}let r=s.view.getCenter(),c=s.view.getZoom();try{s.view.fitWorldRect(s.fitRect,{animate:!1}),await s.view.whenTilesSettled(),W3t(await H3t(s),"layout_entire.png")}finally{s.view.setView(r,c,{animate:!1})}}var TT=document.getElementById("websocket-status"),cH=null,Lpn=2e3,kpn=20;function Z3t(){let s=he.websocketManager&&he.websocketManager.isConnected,n=he.websocketManager?he.websocketManager.pendingCount:0;if(s)if(cH&&(clearTimeout(cH),cH=null),n>kpn){let r=`pending: ${n}`,c=TT.firstElementChild;(!c?.classList.contains("pending-indicator")||c.textContent!==r)&&(TT.innerHTML=`
${r}
`),TT.style.display="block"}else TT.style.display="none";else{if(he.websocketManager?._shutdown)return;cH||(cH=setTimeout(()=>{he.websocketManager?.isConnected||(TT.innerHTML='
\u26A0 OpenROAD disconnected \u2014 retrying\u2026
',TT.style.display="block")},Lpn))}Rpn(n)}function Rpn(s){let n=he.tileProgressEl;if(!n)return;n.classList.toggle("active",s>0);let r=s>0?`${s} tile requests pending`:"";n.title!==r&&(n.title=r)}var X3t=yT(Z3t);function Ipn(s){if(!s)return"";try{return decodeURIComponent(s)}catch{return""}}var he={view:null,fitRect:null,lastSelectionBounds:null,selHasInst:!1,selHasNet:!1,displayControlsEl:null,allLayers:[],designScale:null,designOriginX:0,designOriginY:0,websocketManager:null,goldenLayout:null,hasLiberty:!1,techData:null,inspectorEl:null,tclOutputEl:null,modulesLayer:null,pinsLayer:null,overlayLayers:[],hierarchyBrowser:null,focusNets:new Set,routeGuideNets:new Set,visibleLayers:new Set,visibleLayerNames:new Set,visibleChiplets:null,layerPatterns:{},useTrueZ:zf("or_use_true_z")==="1",showDbu:zf("or_show_dbu")==="1",rulerStyle:zf("or_ruler_style")==="manhattan"?"manhattan":"euclidian",wheelZoom:zf("or_wheel_zoom")!=="0",arrowStep:tH(zf("or_arrow_step")),...F3t(zf),fontFamily:Ipn(zf("or_font_family")),fontScale:rH(zf("or_font_scale")),polyDecomp:!1,labelManager:null,selectableLayers:new Set,heatMapData:null,activeHeatMap:"",heatMapLayer:null,heatMapLegendEl:null,renderHeatMapControls:null,rulerManager:null,selectionToken:0,selectionResetters:[],getDbuPerMicron(){return this.techData?.dbu_per_micron||1e3},unitOpts(){return{showDbu:this.showDbu,dbuPerMicron:this.getDbuPerMicron()}},formatDbu(s,n=!1){return jxt(s,this.unitOpts(),n)},parseDbu(s){return $xt(s,this.unitOpts())},formatDistance(s){return Vxt(s,this.unitOpts())},unitLabel(){return Wxt(this.unitOpts())}},mg={stdcells:!0,macros:!0,pad_input:!0,pad_output:!0,pad_inout:!0,pad_power:!0,pad_spacer:!0,pad_areaio:!0,pad_other:!0,phys_fill:!1,phys_endcap:!0,phys_welltap:!0,phys_tie:!0,phys_antenna:!0,phys_cover:!0,phys_bump:!0,phys_other:!0,std_bufinv:!0,std_bufinv_timing:!0,std_clock_bufinv:!0,std_clock_gate:!0,std_level_shift:!0,std_sequential:!0,std_combinational:!0,net_signal:!0,net_power:!0,net_ground:!0,net_clock:!0,net_reset:!0,net_tieoff:!0,net_scan:!0,net_analog:!0,inst_names:!0,inst_pins:!0,inst_pin_names:!1,routing:!0,routing_segments:!0,routing_vias:!0,special_nets:!0,srouting_segments:!0,srouting_vias:!0,pins:!0,pin_names:!0,access_points:!1,regions:!0,mfg_grid:!1,gcell_grid:!1,flywires_only:!1,blockages:!0,placement_blockages:!0,routing_obstructions:!0,fills:!1,rows:!1,tracks_pref:!1,tracks_non_pref:!1,module_view:!1,detailed:!1,rulers:!0,labels:!0,scale_bar:!0,focused_nets_guides:!1,highlight_selected:!0,debug:!1};try{let s=zf("or_visibility");if(s){let n=JSON.parse(decodeURIComponent(s));for(let[r,c]of Object.entries(n))mg[r]=!!c}}catch{}var LO={stdcells:!0,macros:!0,pad_input:!0,pad_output:!0,pad_inout:!0,pad_power:!0,pad_spacer:!0,pad_areaio:!0,pad_other:!0,phys_fill:!0,phys_endcap:!0,phys_welltap:!0,phys_tie:!0,phys_antenna:!0,phys_cover:!0,phys_bump:!0,phys_other:!0,std_bufinv:!0,std_bufinv_timing:!0,std_clock_bufinv:!0,std_clock_gate:!0,std_level_shift:!0,std_sequential:!0,std_combinational:!0,net_signal:!0,net_power:!0,net_ground:!0,net_clock:!0,net_reset:!0,net_tieoff:!0,net_scan:!0,net_analog:!0,pins:!0,inst_pins:!0,placement_blockages:!0,routing_obstructions:!0};he.visibility=mg;he.selectability=LO;try{let s=zf("or_selectability");if(s){let n=JSON.parse(decodeURIComponent(s));for(let[r,c]of Object.entries(n))LO[r]=!!c}}catch{}(function(){let n=null;try{n=new URLSearchParams(window.location.search)}catch{return}he.forceComposite=n.get("composite")==="1",he.preserveBuffer=n.get("preservebuffer")==="1";let r=Number(n.get("grouplayers"));Number.isFinite(r)&&r>0&&(he.groupLayers=Math.floor(r))})();he.tileCtx={visibility:mg,selectability:LO,visibleLayers:he.visibleLayerNames,selectableLayers:he.selectableLayers,app:he};function Dpn(){return he.view.addTileSlot("heatmap",{order:bp.heatmap,visible:!!he.activeHeatMap,source:G5e({wm:he.websocketManager,dpr:xO,tileSize:Nb,buildRequest:(s,n,r)=>Pxt(s,n,r,he)})})}function rDe(s){if(he.heatMapData=s,he.activeHeatMap=s.active||"",he.heatMapLayer){let n=he.heatMapLayer.isVisible();he.heatMapLayer.setVisible(!!he.activeHeatMap),n&&he.heatMapLayer.refresh()}he.renderHeatMapControls&&he.renderHeatMapControls(s)}he.updateHeatMaps=rDe;function sDe(){he.overlayLayer&&he.overlayLayer.refresh()}var mk=yT(()=>{sDe(),he.selectionBrowser&&he.selectionBrowser.scheduleRefresh()});he.refreshOverlay=mk;function K1(){gf("or_visibility",encodeURIComponent(JSON.stringify(mg))),gf("or_selectability",encodeURIComponent(JSON.stringify(LO))),Ub();let s=[[he.modulesLayer,mg.module_view],[he.pinsLayer,mg.pins],...he.overlayLayers.map(({def:n,layer:r})=>[r,nde(n.shown_by,mg)])];for(let[n,r]of s)n&&(n.visible=!!r);for(let n of he.allLayers)n.refresh();he.heatMapLayer&&he.heatMapLayer.refresh(),he.renderSelectionOutline&&he.renderSelectionOutline(),!mg.highlight_selected&&he.clearSelectionPulse&&he.clearSelectionPulse(),sDe(),he.rulerManager&&he.rulerManager.updateVisibility(),he.labelManager&&he.labelManager.updateVisibility(),he.updateScaleBar&&he.updateScaleBar()}var PO=yT(K1),Ub=yT(()=>{!he.websocketManager||ua(he)||he.websocketManager.request({type:"set_display_state",state:U3t()}).catch(()=>{})});he.syncDisplayState=Ub;function Bpn(s){if(!s||typeof s!="object")return;let n=s.entries;if(!(!n||typeof n!="object")){z3t(n);try{if(he.view&&he.designScale&&typeof sessionStorage<"u"){let[r,c]=he.view.getCenter(),{dbuX:u,dbuY:d}=kv(r,c,he.designScale,he.designOriginX,he.designOriginY);sessionStorage.setItem("or_restore_view",JSON.stringify({dbuX:u,dbuY:d,zoom:he.view.getZoom()}))}}catch{}window.location.reload()}}he.redrawAllLayers=K1;he.captureLayout=(s={})=>q3t(he,s);var Y3t=!1;function Opn(s){let n=Oxt(s);!n||Y3t||n.kind==="software"&&zf("or_hide_software_warning")==="1"||(Y3t=!0,Bxt(n.message,n.kind!=="software"?{}:{dontShowAgain:()=>gf("or_hide_software_warning","1")}))}function Npn(s){let n=document.createElement("div");n.className="layout-viewer",n.style.width="100%",n.style.height="100%",n.style.backgroundColor="var(--bg-map)",s.element.appendChild(n);let r=document.createElement("div");r.className="or-hud or-hud-bottom-right heatmap-map-legend hidden",n.appendChild(r),he.heatMapLegendEl=r;let c=document.createElement("div");c.className="or-progress",n.appendChild(c),he.tileProgressEl=c,s.on("destroy",()=>{he.tileProgressEl=null,he.heatMapLegendEl=null}),he.view=e3t(n,{preserveDrawingBuffer:he.preserveBuffer,prefs:{smooth:()=>he.controlSmoothing,doubleBuffer:()=>he.doubleBuffer,defer:()=>he.deferTileUpdates},tileSize:Nb,dpr:xO,isStatic:ua(he)}),he.view.on("contextlost",()=>{console.warn("Layout view: WebGL context lost; rebuilding the view.")}),he.view.on("contextfailed",()=>{Fb("The layout view lost its graphics context and could not get it back; reload the page.",15e3)}),he.view.on("renderer",Opn),window.__orView=he.view,bxt(()=>{he.view.invalidateSize(),K1()});let u=document.createElement("div");u.className="or-zoom-control";let d=[];for(let[Z,H,te]of[["+","Zoom in",()=>he.view.zoomIn()],["\u2212","Zoom out",()=>he.view.zoomOut()],["\u2922","Fit",()=>{he.fitRect&&he.view.fitWorldRect(he.fitRect)}]]){let oe=document.createElement("button");oe.type="button",oe.title=H,oe.setAttribute("aria-label",H),oe.textContent=Z,oe.addEventListener("click",ne=>{ne.stopPropagation(),te()}),u.appendChild(oe),d.push(oe)}n.appendChild(u);let b=()=>{let{minZoom:Z,maxZoom:H}=he.view.getLimits(),te=he.view.getTargetZoom();d[0].disabled=te>=H,d[1].disabled=te<=Z};he.view.on("zoom zoomend limits",b),b();let w=document.createElement("div");w.className="or-hud or-hud-bottom-left hidden";let _=document.createElement("div");_.id="scale-bar";let x=document.createElement("span");x.className="or-hud-divider";let T=document.createElement("div");T.id="coord-bar",w.appendChild(_),w.appendChild(x),w.appendChild(T),n.appendChild(w);function M(){let Z=_.style.display!=="none"&&_.childElementCount>0,H=T.textContent!=="";x.style.display=Z&&H?"":"none",w.classList.toggle("hidden",!Z&&!H)}M(),n3t(he.view,{isStatic:()=>ua(he),wheelZoom:()=>he.wheelZoom,arrowStep:()=>he.arrowStep,contextEnabled:()=>!(he.rulerManager&&he.rulerManager.isActive()),onClick:(Z,H)=>{he.rulerManager&&he.rulerManager.isActive()?he.rulerManager.handleMapClick(Z,H):he.rulerManager?.handleRulerClick(Z)||he.onMapClick&&he.onMapClick(Z,H)},onContextClick:(Z,H)=>{he.onMapContextClick&&he.onMapContextClick(Z,H)},onMove:(Z,H)=>{if(he.lastMouseWorld=Z,he.rulerManager&&he.rulerManager.isActive()&&he.rulerManager.handleMouseMove(Z,H),!he.designScale)return;let{dbuX:te,dbuY:oe}=kv(Z[0],Z[1],he.designScale,he.designOriginX,he.designOriginY);T.textContent=`X: ${he.formatDbu(te)} Y: ${he.formatDbu(oe)}`,M()},onLeave:()=>{he.lastMouseWorld=null,T.textContent="",M()}});let L=22,I=8,D=22;function F(Z,H,te){let ne=2+I,ue=D,Te=D+Z,Q=L-2,ge=Z>=40,Qe=[];if(Qe.push(``),ge&&te>1)for(let st=1;st`)}ge&&Qe.push(`0`),Qe.push(`${H}`),_.innerHTML=`${Qe.join("")}`}function O(){if(!he.designScale||!mg.scale_bar){_.style.display="none",M();return}let Z=he.designScale*Math.pow(2,he.view.getZoom()),H=he.view.getSize().width||400,te=qxt({targetPx:H*.15,pxPerDbu:Z,dbuPerMicron:he.techData?.dbu_per_micron,showDbu:he.showDbu});if(!te){_.style.display="none",M();return}_.style.display="",F(te.barPx,te.label,te.segments),M()}let z=yT(O);he.view.on("zoom zoomend resize",z),he.updateScaleBar=O,he.rulerManager=new ode(he,mg,lH,gde),he.labelManager=new cde(he,mg,lH,gde)}function Fpn(s){let n=document.createElement("div");n.className="display-controls",n.innerHTML='
Loading layers...
',s.element.appendChild(n),he.displayControlsEl=n}var iDe="or_restore_console",Upn=1<<20;function zpn(){try{if(he.tclOutputEl){let s=[...he.tclOutputEl.children].map(u=>[u.textContent,u.className]),n=s.length,r=0;for(;n>0&&r+s[n-1][0].length<=Upn;)r+=s[--n][0].length;let c=s.slice(n);n>0&&c.unshift([`[earlier output not kept across reload] +`,""]),sessionStorage.setItem(iDe,JSON.stringify(c))}}catch{}window.location.reload()}function Gpn(){try{let s=sessionStorage.getItem(iDe);if(!s)return;sessionStorage.removeItem(iDe);for(let[n,r]of JSON.parse(s))CT(n,r)}catch{}}function CT(s,n){if(!he.tclOutputEl)return;let r=document.createElement("span");n&&(r.className=n),r.textContent=s,he.tclOutputEl.appendChild(r),he.tclOutputEl.scrollTop=he.tclOutputEl.scrollHeight}function jpn(){if(he._shutdownHandled)return;he._shutdownHandled=!0,he.websocketManager&&(he.websocketManager._shutdown=!0,he.websocketManager.onPush=()=>{});let s=document.createElement("div");s.style.cssText="position:fixed;inset:0;z-index:99999;background:#1e1e1e;color:#ddd;display:flex;flex-direction:column;align-items:center;justify-content:center;font-family:system-ui,sans-serif;font-size:16px;padding:24px;text-align:center;",s.innerHTML='
OpenROAD exited
You can close this tab.
',document.body.appendChild(s),setTimeout(()=>{try{window.close()}catch{}},1500)}function $pn(s){let n=document.createElement("div");if(n.className="tcl-console",n.innerHTML='
%
',s.element.appendChild(n),he.tclOutputEl=n.querySelector(".tcl-output"),Gpn(),ua(he)){n.querySelector(".tcl-input-row").style.display="none";let u=document.createElement("span");u.className="tcl-static-notice",u.setAttribute("role","status"),u.setAttribute("aria-live","polite"),u.textContent="Tcl console is not available in saved reports.",he.tclOutputEl.appendChild(u);return}let r=n.querySelector(".tcl-input"),c=new fde(r,he.websocketManager);r.addEventListener("keydown",u=>{if(!c.handleKeyDown(u)&&u.key==="Enter"){let d=r.value.trim();if(!d)return;CT(`>>> ${d} `,"tcl-cmd"),c.addToHistory(d),r.value="",he.websocketManager.request({type:"tcl_eval",cmd:d}).then(b=>{b.result&&CT(b.result+` -`,b.is_error?"tcl-error":""),b.action==="shutdown"&&Fpn(),!b.is_error&&he.drcWidget&&he.drcWidget.refresh()}).catch(b=>CT(`Error: ${b} -`,"tcl-error"))}})}he.visibility=mg;var AT=h3t(he,J1,mk),zpn=AT.createInspector,lH=AT.updateInspector,Gpn=AT.highlightBBox,jpn=AT.pulseHighlight;he.updateInspector=lH;he.navigateInspector=AT.navigateInspector;he.refreshInspector=AT.refreshInspector;he.animateSelection=AT.animateSelection;he.stopSelectionAnimation=AT.stopSelectionAnimation;function $pn(s){new Khe(s,he,J1)}function Vpn(s){he.timingWidget=new uk(he,J1,mk),s.element.appendChild(he.timingWidget.element)}function Wpn(s){he.drcWidget=new ude(he,J1,mk),s.element.appendChild(he.drcWidget.element)}function Hpn(s){he.clockTreeWidget=new Yhe(s,he,J1,mk)}function qpn(s){he.chartsWidget=new Zhe(he,J1),s.element.appendChild(he.chartsWidget.element)}function Xpn(s){let n=document.createElement("div");n.className="help-panel",n.innerHTML="

Keyboard Shortcuts

fFit design to viewport
scrollZoom in/out
dragPan the view
right-dragRubber-band zoom
Shift+clickAdd object to selection
Ctrl/Cmd+clickSelect object and its connected nets
kToggle ruler mode
Shift+KClear all rulers
EscapeCancel ruler (when building)
",s.element.appendChild(n)}function Ypn(s){he.selectionBrowser=new Jhe(s,he,mk)}function Zpn(s){new lde(s,he)}function Kpn(s){he.threeDViewerWidget=new dde(s,he)}var Jpn=28,Qpn={dimensions:{headerHeight:Jpn},root:{type:"row",content:[{type:"component",componentType:"DisplayControls",title:"Display Controls",width:15},{type:"column",width:55,content:[{type:"stack",height:70,content:[{type:"component",componentType:"LayoutViewer",title:"Layout",isClosable:!1},{type:"component",componentType:"SchematicWidget",title:"Schematic"},{type:"component",componentType:"3DViewer",title:"3D Viewer"}]},{type:"component",componentType:"TclConsole",title:"Tcl Console",height:30}]},{type:"stack",width:30,content:[{type:"component",componentType:"Inspector",title:"Inspector"},{type:"component",componentType:"Browser",title:"Hierarchy"},{type:"component",componentType:"TimingWidget",title:"Timing"},{type:"component",componentType:"DRCWidget",title:"DRC"},{type:"component",componentType:"SelectHighlight",title:"Select Highlight"},{type:"component",componentType:"ClockWidget",title:"Clock Tree"},{type:"component",componentType:"ChartsWidget",title:"Charts"},{type:"component",componentType:"HelpWidget",title:"Help"}]}]}};he.goldenLayout=new Bhe(document.getElementById("gl-container"));he.goldenLayout.registerComponentFactoryFunction("LayoutViewer",Ipn);he.goldenLayout.registerComponentFactoryFunction("DisplayControls",Dpn);he.goldenLayout.registerComponentFactoryFunction("TclConsole",Upn);he.goldenLayout.registerComponentFactoryFunction("Inspector",zpn);he.goldenLayout.registerComponentFactoryFunction("Browser",$pn);he.goldenLayout.registerComponentFactoryFunction("TimingWidget",Vpn);he.goldenLayout.registerComponentFactoryFunction("DRCWidget",Wpn);he.goldenLayout.registerComponentFactoryFunction("ClockWidget",Hpn);he.goldenLayout.registerComponentFactoryFunction("ChartsWidget",qpn);he.goldenLayout.registerComponentFactoryFunction("SchematicWidget",Zpn);he.goldenLayout.registerComponentFactoryFunction("3DViewer",Kpn);he.goldenLayout.registerComponentFactoryFunction("HelpWidget",Xpn);he.goldenLayout.registerComponentFactoryFunction("SelectHighlight",Ypn);var m2=window.__STATIC_CACHE__||null;if(m2)fxt(),he.websocketManager=ZW.fromCache(m2,H3t);else{let s=`ws://${window.location.host||"localhost:8080"}/ws`;he.websocketManager=new ZW(s,H3t),he.layerExtents=new Ghe,he.websocketManager.onReconnected=()=>{mde(),cDe(null,null,{reloadOnChange:!0}).catch(()=>{})}}q3t();he.goldenLayout.loadLayout(Qpn);X3t();function X3t(){Hxt(document.getElementById("gl-container"))>0&&he.goldenLayout.updateSize()}he.goldenLayout.on("stateChanged",()=>{X3t()});function oDe(){he.goldenLayout.updateSize()}he.syncLayoutSize=oDe;window.addEventListener("resize",oDe);function gde(s){he.goldenLayout.focusComponent(s)}he.focusComponent=gde;he.resetLayout=function(){he.goldenLayout&&typeof he.goldenLayout.resetLayout=="function"&&he.goldenLayout.resetLayout()};he.toggleTheme=function(){let s=document.documentElement.dataset.theme==="dark"?"light":"dark";document.documentElement.dataset.theme=s,H5e(s),Whe(s),he.chartsWidget&&he.chartsWidget.render(),he.clockTreeWidget&&he.clockTreeWidget.render(),Ub()};he.toggleShowDbu=function(){he.showDbu=!he.showDbu,Uf("or_show_dbu",he.showDbu?"1":"0"),he.rulerManager&&he.rulerManager._renderAll(),he.hierarchyBrowser&&he.hierarchyBrowser._render(),he.updateScaleBar&&he.updateScaleBar(),he.refreshInspector&&he.refreshInspector(),Ub()};he.toggleRulerStyle=function(){he.rulerStyle=he.rulerStyle==="manhattan"?"euclidian":"manhattan",Uf("or_ruler_style",he.rulerStyle),Ub()};he.toggleWheelZoom=function(){he.wheelZoom=!he.wheelZoom,Uf("or_wheel_zoom",he.wheelZoom?"1":"0"),Ub()};he.toggleControlSmoothing=function(){he.controlSmoothing=!he.controlSmoothing,Uf("or_control_smoothing",he.controlSmoothing?"1":"0"),Ub()};he.toggleDoubleBuffer=function(){he.doubleBuffer=!he.doubleBuffer,Uf("or_double_buffer",he.doubleBuffer?"1":"0"),he.view?.applyPrefs(),Ub()};he.toggleDeferTileUpdates=function(){he.deferTileUpdates=!he.deferTileUpdates,Uf("or_defer_tile_updates",he.deferTileUpdates?"1":"0"),he.view?.applyPrefs(),Ub()};he.setArrowStep=function(s){he.arrowStep=tH(s),Uf("or_arrow_step",String(he.arrowStep)),Ub()};he.setAppFont=function({family:s,scale:n}){he.fontFamily=s??he.fontFamily,he.fontScale=rH(n??he.fontScale),Uf("or_font_family",encodeURIComponent(he.fontFamily)),Uf("or_font_scale",String(he.fontScale)),he.applyAppFont(),Ub()};he.applyAppFont=function(){let s=document.documentElement;he.fontFamily?s.style.setProperty("--or-font-family",he.fontFamily):s.style.removeProperty("--or-font-family"),s.style.setProperty("--or-font-scale",String(he.fontScale/100)),he.chartsWidget&&he.chartsWidget.render(),he.clockTreeWidget&&he.clockTreeWidget.render()};he.showArrowStepDialog=()=>g3t(he);he.showAppFontDialog=()=>m3t(he);he.togglePolyDecomp=function(){he.websocketManager&&he.websocketManager.request({type:"poly_decomp",value:!he.polyDecomp}).then(s=>aDe(s.value)).catch(()=>{})};function aDe(s){he.polyDecomp=!!s,he.rebuildMenuBar&&he.rebuildMenuBar(),he.refreshOverlay&&he.refreshOverlay()}he.applyAppFont();he.echoTcl=s=>CT(`>>> ${s} +`,b.is_error?"tcl-error":""),b.action==="shutdown"&&jpn(),!b.is_error&&he.drcWidget&&he.drcWidget.refresh()}).catch(b=>CT(`Error: ${b} +`,"tcl-error"))}})}he.visibility=mg;var AT=p3t(he,K1,mk),Vpn=AT.createInspector,lH=AT.updateInspector,Wpn=AT.highlightBBox,Hpn=AT.pulseHighlight;he.updateInspector=lH;he.navigateInspector=AT.navigateInspector;he.refreshInspector=AT.refreshInspector;he.animateSelection=AT.animateSelection;he.stopSelectionAnimation=AT.stopSelectionAnimation;function qpn(s){new Khe(s,he,K1)}function Xpn(s){he.timingWidget=new uk(he,K1,mk),s.element.appendChild(he.timingWidget.element)}function Ypn(s){he.drcWidget=new ude(he,K1,mk),s.element.appendChild(he.drcWidget.element)}function Zpn(s){he.clockTreeWidget=new Yhe(s,he,K1,mk)}function Kpn(s){he.chartsWidget=new Zhe(he,K1),s.element.appendChild(he.chartsWidget.element)}function Jpn(s){let n=document.createElement("div");n.className="help-panel",n.innerHTML="

Keyboard Shortcuts

fFit design to viewport
scrollZoom in/out
dragPan the view
right-dragRubber-band zoom
Shift+clickAdd object to selection
Ctrl/Cmd+clickSelect object and its connected nets
kToggle ruler mode
Shift+KClear all rulers
EscapeCancel ruler (when building)
",s.element.appendChild(n)}function Qpn(s){he.selectionBrowser=new Jhe(s,he,mk)}function egn(s){new lde(s,he)}function tgn(s){he.threeDViewerWidget=new dde(s,he)}var ngn=28,ign={dimensions:{headerHeight:ngn},root:{type:"row",content:[{type:"component",componentType:"DisplayControls",title:"Display Controls",width:15},{type:"column",width:55,content:[{type:"stack",height:70,content:[{type:"component",componentType:"LayoutViewer",title:"Layout",isClosable:!1},{type:"component",componentType:"SchematicWidget",title:"Schematic"},{type:"component",componentType:"3DViewer",title:"3D Viewer"}]},{type:"component",componentType:"TclConsole",title:"Tcl Console",height:30}]},{type:"stack",width:30,content:[{type:"component",componentType:"Inspector",title:"Inspector"},{type:"component",componentType:"Browser",title:"Hierarchy"},{type:"component",componentType:"TimingWidget",title:"Timing"},{type:"component",componentType:"DRCWidget",title:"DRC"},{type:"component",componentType:"SelectHighlight",title:"Select Highlight"},{type:"component",componentType:"ClockWidget",title:"Clock Tree"},{type:"component",componentType:"ChartsWidget",title:"Charts"},{type:"component",componentType:"HelpWidget",title:"Help"}]}]}};he.goldenLayout=new Bhe(document.getElementById("gl-container"));he.goldenLayout.registerComponentFactoryFunction("LayoutViewer",Npn);he.goldenLayout.registerComponentFactoryFunction("DisplayControls",Fpn);he.goldenLayout.registerComponentFactoryFunction("TclConsole",$pn);he.goldenLayout.registerComponentFactoryFunction("Inspector",Vpn);he.goldenLayout.registerComponentFactoryFunction("Browser",qpn);he.goldenLayout.registerComponentFactoryFunction("TimingWidget",Xpn);he.goldenLayout.registerComponentFactoryFunction("DRCWidget",Ypn);he.goldenLayout.registerComponentFactoryFunction("ClockWidget",Zpn);he.goldenLayout.registerComponentFactoryFunction("ChartsWidget",Kpn);he.goldenLayout.registerComponentFactoryFunction("SchematicWidget",egn);he.goldenLayout.registerComponentFactoryFunction("3DViewer",tgn);he.goldenLayout.registerComponentFactoryFunction("HelpWidget",Jpn);he.goldenLayout.registerComponentFactoryFunction("SelectHighlight",Qpn);var m2=window.__STATIC_CACHE__||null;if(m2)fxt(),he.websocketManager=ZW.fromCache(m2,X3t);else{let s=`ws://${window.location.host||"localhost:8080"}/ws`;he.websocketManager=new ZW(s,X3t),he.layerExtents=new Ghe,he.websocketManager.onReconnected=()=>{mde(),cDe(null,null,{reloadOnChange:!0}).catch(()=>{})}}Z3t();he.goldenLayout.loadLayout(ign);K3t();function K3t(){Xxt(document.getElementById("gl-container"))>0&&he.goldenLayout.updateSize()}he.goldenLayout.on("stateChanged",()=>{K3t()});function oDe(){he.goldenLayout.updateSize()}he.syncLayoutSize=oDe;window.addEventListener("resize",oDe);function gde(s){he.goldenLayout.focusComponent(s)}he.focusComponent=gde;he.resetLayout=function(){he.goldenLayout&&typeof he.goldenLayout.resetLayout=="function"&&he.goldenLayout.resetLayout()};he.toggleTheme=function(){let s=document.documentElement.dataset.theme==="dark"?"light":"dark";document.documentElement.dataset.theme=s,H5e(s),Whe(s),he.chartsWidget&&he.chartsWidget.render(),he.clockTreeWidget&&he.clockTreeWidget.render(),Ub()};he.toggleShowDbu=function(){he.showDbu=!he.showDbu,gf("or_show_dbu",he.showDbu?"1":"0"),he.rulerManager&&he.rulerManager._renderAll(),he.hierarchyBrowser&&he.hierarchyBrowser._render(),he.updateScaleBar&&he.updateScaleBar(),he.refreshInspector&&he.refreshInspector(),Ub()};he.toggleRulerStyle=function(){he.rulerStyle=he.rulerStyle==="manhattan"?"euclidian":"manhattan",gf("or_ruler_style",he.rulerStyle),Ub()};he.toggleWheelZoom=function(){he.wheelZoom=!he.wheelZoom,gf("or_wheel_zoom",he.wheelZoom?"1":"0"),Ub()};he.toggleControlSmoothing=function(){he.controlSmoothing=!he.controlSmoothing,gf("or_control_smoothing",he.controlSmoothing?"1":"0"),Ub()};he.toggleDoubleBuffer=function(){he.doubleBuffer=!he.doubleBuffer,gf("or_double_buffer",he.doubleBuffer?"1":"0"),he.view?.applyPrefs(),Ub()};he.toggleDeferTileUpdates=function(){he.deferTileUpdates=!he.deferTileUpdates,gf("or_defer_tile_updates",he.deferTileUpdates?"1":"0"),he.view?.applyPrefs(),Ub()};he.setArrowStep=function(s){he.arrowStep=tH(s),gf("or_arrow_step",String(he.arrowStep)),Ub()};he.setAppFont=function({family:s,scale:n}){he.fontFamily=s??he.fontFamily,he.fontScale=rH(n??he.fontScale),gf("or_font_family",encodeURIComponent(he.fontFamily)),gf("or_font_scale",String(he.fontScale)),he.applyAppFont(),Ub()};he.applyAppFont=function(){let s=document.documentElement;he.fontFamily?s.style.setProperty("--or-font-family",he.fontFamily):s.style.removeProperty("--or-font-family"),s.style.setProperty("--or-font-scale",String(he.fontScale/100)),he.chartsWidget&&he.chartsWidget.render(),he.clockTreeWidget&&he.clockTreeWidget.render()};he.showArrowStepDialog=()=>b3t(he);he.showAppFontDialog=()=>w3t(he);he.togglePolyDecomp=function(){he.websocketManager&&he.websocketManager.request({type:"poly_decomp",value:!he.polyDecomp}).then(s=>aDe(s.value)).catch(()=>{})};function aDe(s){he.polyDecomp=!!s,he.rebuildMenuBar&&he.rebuildMenuBar(),he.refreshOverlay&&he.refreshOverlay()}he.applyAppFont();he.echoTcl=s=>CT(`>>> ${s} `,"tcl-cmd");he.runTclScript=(s,n)=>s?(n&&he.echoTcl(s),he.websocketManager.request({type:"tcl_eval",cmd:s}).then(r=>(r&&r.result&&CT(r.result+` `,r.is_error?"tcl-error":""),r)).catch(r=>{CT(`Error: ${r} -`,"tcl-error")})):Promise.resolve();function Y3t(s){s&&(he.customMenu=s.menu||[],he.customToolbar=s.toolbar||[],he.rebuildMenuBar&&he.rebuildMenuBar(),he.rebuildToolbar&&he.rebuildToolbar(),oDe())}he.customMenu=[];he.customToolbar=[];he.scheduleRedrawAllLayers=PO;he.showGlobalConnectDialog=()=>C3t(he);he.showInsertBufferDialog=s=>A3t(he,s);E3t(he);S3t(he);he.contextMenu=new pde(he);function egn(){let s=document.getElementById("debug-continue-btn");return s||(s=document.createElement("button"),s.id="debug-continue-btn",s.className="debug-continue-btn",s.textContent="Continue",s.title="Advance the debugger (gpl, cts, ...)",s.addEventListener("click",()=>{he.websocketManager.request({type:"debug_continue"}).catch(()=>{})}),(document.getElementById("menu-bar")||document.body).appendChild(s),s)}function Z3t(s,n){let r=$5e(s,Fb(),n);return r?(he.currentBounds=s,he.designScale=r.scale,he.designOriginX=r.originX,he.designOriginY=r.originY,he.fitRect=r.fitRect,he.view.setLimits({minZoom:0,maxZoom:Fxt(r.scale)}),!0):!1}async function cDe(s,n,{reloadOnChange:r=!1}={}){if(ua(he)||!he.view)return!1;let c=s,u=n;if(!c)try{let x=await he.websocketManager.request({type:"bounds"});c=x.bounds,u=x.fit_bounds}catch{return!1}if(!c||Oxt(he.currentBounds,c))return!1;if(r)return window.location.reload(),!0;let d=!!he.designScale,[b,w]=he.view.getCenter(),_=d?kv(b,w,he.designScale,he.designOriginX,he.designOriginY):null;return Z3t(c,u)?(_&&he.view.setView(Lv(_.dbuX,_.dbuY,he.designScale,he.designOriginX,he.designOriginY),he.view.getZoom(),{animate:!1}),he.clearSelectionOutline&&he.clearSelectionOutline(),J1(),!0):!1}function tgn(){let s=document.getElementById("loading-overlay");s.style.display="flex";let n=()=>{s.style.display!=="none"&&he.websocketManager.request({type:"bounds"}).then(r=>{r.shapes_ready&&(s.style.display="none")}).catch(()=>{}).finally(()=>{s.style.display!=="none"&&setTimeout(n,1e3)})};setTimeout(n,1e3)}function mde(){he.layerExtents&&he.layerExtents.refetch(s=>he.websocketManager.request(s))}function ngn(s){document.getElementById("loading-overlay").style.display="none",mde(),cDe(s.bounds,s.fit_bounds).then(n=>{n||J1()}).catch(()=>J1()),he.refreshInspector&&he.refreshInspector()}function ign(){let s=document.getElementById("script-running-badge");return s||(s=document.createElement("span"),s.id="script-running-badge",s.className="script-running-badge",s.textContent="Script running",s.title="The view updates when the script pauses or finishes",(document.getElementById("menu-bar")||document.body).appendChild(s),s)}function rgn(s){if(he.scriptRunning=s,ign().style.display=s?"block":"none",!s){if(!he.booted||!he.designScale){Opn();return}he.refreshPending&&(he.refreshPending=!1,mde(),he.refreshInspector&&he.refreshInspector()),cDe().then(n=>{n||PO()}).catch(()=>PO())}}he.websocketManager.onPush=s=>{if(s.type==="refresh"){if(he.scriptRunning){he.refreshPending=!0;return}ngn(s)}else if(s.type==="script_running")rgn(!!s.running);else if(s.type==="renderer_controls_changed")he.refreshRendererControls&&he.refreshRendererControls(),PO();else if(s.type==="selection_invalidated")he.updateInspector&&he.updateInspector(null),he.stopSelectionAnimation&&he.stopSelectionAnimation(),he.clearSelectionOutline&&he.clearSelectionOutline(),mk();else if(s.type==="heatmaps_changed")he.websocketManager.request({type:"heatmaps"}).then(rDe).catch(n=>console.error("Heat map refresh failed",n));else if(s.type==="labels_changed")he.labelManager&&he.labelManager.applyRemoteLabels(s.labels);else if(s.type==="drcUpdated")he._drcUpdateTimeout&&clearTimeout(he._drcUpdateTimeout),he._drcUpdateTimeout=setTimeout(()=>{he.drcWidget&&he.drcWidget.refresh()},500);else if(s.type==="debug_paused")he.refreshRendererControls&&he.refreshRendererControls(),egn().style.display="block",PO(),he.chartsWidget&&he.websocketManager.request({type:"debug_charts"}).then(n=>he.chartsWidget.setDebugCharts(n.charts||[])).catch(()=>{});else if(s.type==="debug_resumed"){let n=document.getElementById("debug-continue-btn");n&&(n.style.display="none")}else if(s.type==="debug_refresh"){if(he.scriptRunning)return;he.clearSelectionOutline&&he.clearSelectionOutline(),PO()}else if(s.type==="log"){let n=s.text;n.endsWith(` +`,"tcl-error")})):Promise.resolve();function J3t(s){s&&(he.customMenu=s.menu||[],he.customToolbar=s.toolbar||[],he.rebuildMenuBar&&he.rebuildMenuBar(),he.rebuildToolbar&&he.rebuildToolbar(),oDe())}he.customMenu=[];he.customToolbar=[];he.scheduleRedrawAllLayers=PO;he.showGlobalConnectDialog=()=>P3t(he);he.showInsertBufferDialog=s=>L3t(he,s);M3t(he);T3t(he);he.contextMenu=new pde(he);function rgn(){let s=document.getElementById("debug-continue-btn");return s||(s=document.createElement("button"),s.id="debug-continue-btn",s.className="debug-continue-btn",s.textContent="Continue",s.title="Advance the debugger (gpl, cts, ...)",s.addEventListener("click",()=>{he.websocketManager.request({type:"debug_continue"}).catch(()=>{})}),(document.getElementById("menu-bar")||document.body).appendChild(s),s)}function Q3t(s,n){let r=$5e(s,Nb(),n);return r?(he.currentBounds=s,he.designScale=r.scale,he.designOriginX=r.originX,he.designOriginY=r.originY,he.fitRect=r.fitRect,he.view.setLimits({minZoom:0,maxZoom:zxt(r.scale)}),!0):!1}async function cDe(s,n,{reloadOnChange:r=!1}={}){if(ua(he)||!he.view)return!1;let c=s,u=n;if(!c)try{let x=await he.websocketManager.request({type:"bounds"});c=x.bounds,u=x.fit_bounds}catch{return!1}if(!c||Fxt(he.currentBounds,c))return!1;if(r)return window.location.reload(),!0;let d=!!he.designScale,[b,w]=he.view.getCenter(),_=d?kv(b,w,he.designScale,he.designOriginX,he.designOriginY):null;return Q3t(c,u)?(_&&he.view.setView(Lv(_.dbuX,_.dbuY,he.designScale,he.designOriginX,he.designOriginY),he.view.getZoom(),{animate:!1}),he.clearSelectionOutline&&he.clearSelectionOutline(),K1(),!0):!1}function sgn(){let s=document.getElementById("loading-overlay");s.style.display="flex";let n=()=>{s.style.display!=="none"&&he.websocketManager.request({type:"bounds"}).then(r=>{r.shapes_ready&&(s.style.display="none")}).catch(()=>{}).finally(()=>{s.style.display!=="none"&&setTimeout(n,1e3)})};setTimeout(n,1e3)}function mde(){he.layerExtents&&he.layerExtents.refetch(s=>he.websocketManager.request(s))}function ogn(s){document.getElementById("loading-overlay").style.display="none",mde(),cDe(s.bounds,s.fit_bounds).then(n=>{n||K1()}).catch(()=>K1()),he.refreshInspector&&he.refreshInspector()}function agn(){let s=document.getElementById("script-running-badge");return s||(s=document.createElement("span"),s.id="script-running-badge",s.className="script-running-badge",s.textContent="Script running",s.title="The view updates when the script pauses or finishes",(document.getElementById("menu-bar")||document.body).appendChild(s),s)}function cgn(s){if(he.scriptRunning=s,agn().style.display=s?"block":"none",!s){if(!he.booted||!he.designScale){zpn();return}he.refreshPending&&(he.refreshPending=!1,mde(),he.refreshInspector&&he.refreshInspector()),cDe().then(n=>{n||PO()}).catch(()=>PO())}}he.websocketManager.onPush=s=>{if(s.type==="refresh"){if(he.scriptRunning){he.refreshPending=!0;return}ogn(s)}else if(s.type==="script_running")cgn(!!s.running);else if(s.type==="renderer_controls_changed")he.refreshRendererControls&&he.refreshRendererControls(),PO();else if(s.type==="selection_invalidated")he.updateInspector&&he.updateInspector(null),he.stopSelectionAnimation&&he.stopSelectionAnimation(),he.clearSelectionOutline&&he.clearSelectionOutline(),mk();else if(s.type==="heatmaps_changed")he.websocketManager.request({type:"heatmaps"}).then(rDe).catch(n=>console.error("Heat map refresh failed",n));else if(s.type==="labels_changed")he.labelManager&&he.labelManager.applyRemoteLabels(s.labels);else if(s.type==="drcUpdated")he._drcUpdateTimeout&&clearTimeout(he._drcUpdateTimeout),he._drcUpdateTimeout=setTimeout(()=>{he.drcWidget&&he.drcWidget.refresh()},500);else if(s.type==="debug_paused")he.refreshRendererControls&&he.refreshRendererControls(),rgn().style.display="block",PO(),he.chartsWidget&&he.websocketManager.request({type:"debug_charts"}).then(n=>he.chartsWidget.setDebugCharts(n.charts||[])).catch(()=>{});else if(s.type==="debug_resumed"){let n=document.getElementById("debug-continue-btn");n&&(n.style.display="none")}else if(s.type==="debug_refresh"){if(he.scriptRunning)return;he.clearSelectionOutline&&he.clearSelectionOutline(),PO()}else if(s.type==="log"){let n=s.text;n.endsWith(` `)&&(n=n.slice(0,-1)),n&&CT(n+` -`,"")}else s.type==="restore_display_state"?kpn(s.state):s.type==="custom_ui"?Y3t(s):s.type==="poly_decomp"?aDe(s.value):s.type==="shutdown"&&(he.websocketManager._shutdown=!0,TT.innerHTML='
Server stopped
',TT.style.display="block")};he.websocketManager.readyPromise.then(async()=>{try{let b=function(w,_={}){let{addToSelection:x=!1,focusInspector:T=!0,context:M=!1,showConnectivity:L=!1}=_;if(!he.designScale)return Promise.resolve(null);let{dbuX:I,dbuY:D}=kv(w[0],w[1],he.designScale,he.designOriginX,he.designOriginY);if(he.labelManager&&he.labelManager.isActive())return he.labelManager.handleMapClick(I,D),Promise.resolve(null);let F=Ixt(mg,LO),O={type:"select",dbu_x:I,dbu_y:D,zoom:Math.round(he.view.getZoom()),visible_layers:[...he.visibleLayerNames],selectable_layers:[...he.selectableLayers],use_dbu:he.showDbu,...F};x&&(O.add_to_selection=!0),M&&(O.context=!0),L&&(O.show_connectivity=!0),he.visibleChiplets instanceof Set&&(O.visible_chiplets=[...he.visibleChiplets]);let z=Pm(he);return he.websocketManager.request(O).then(Z=>{if(Z1(he,z)){if(console.log("Select response:",Z,"at dbu",I,D),EO(he,Z),Z.selected&&Z.selected.length>0){let H=Z.selected[0];H.type==="Inst"&&(he.selectedInstanceName=H.name,he.schematicWidget&&he.schematicWidget.refresh()),lH(Z),T&&gde("Inspector"),Z.bbox&&(Gpn(Z.bbox[0],Z.bbox[1],Z.bbox[2],Z.bbox[3],Z.type),jpn(Z.bbox,Z.type),he.lastSelectionBounds=Z.bbox.slice(0,4)),O.show_connectivity&&Z.connected_added>0&&Y1(`Selected ${Z.connected_added} connected net`+(Z.connected_added>1?"s":""))}else!x&&!M&&(lH(null),he.clearSelectionOutline&&he.clearSelectionOutline(),he.lastSelectionBounds=null);return sDe(),Z}}).catch(Z=>(console.error("Select failed:",Z),null))},[s,n,r]=await Promise.all([he.websocketManager.request({type:"tech"}),he.websocketManager.request({type:"bounds"}),he.websocketManager.request({type:"heatmaps"})]);mde(),he.hasLiberty=s.has_liberty,he.techData=s,U3t(s.block_name),he.websocketManager.request({type:"custom_ui"}).then(Y3t).catch(()=>{}),he.websocketManager.request({type:"poly_decomp"}).then(w=>aDe(w.value)).catch(()=>{});let c=n.bounds,u=n.fit_bounds;if(!m2){let w=he.view.getSize();hxt(Uxt({designBounds:c,fitRect:u,viewW:w.width,viewH:w.height}))}let d=Z3t(c,u);if(d){if(he.labelManager&&he.labelManager.reload(),m2){let w=m2.zoom;he.view.setLimits({minZoom:w,maxZoom:w})}if(he.view.fitWorldRect(he.fitRect,{animate:!1}),m2){let w=X1(c[0][1],c[0][0],c[1][1],c[1][0],he.designScale,he.designOriginX,he.designOriginY);m2.setPathOverlay=_=>{he.view.setImageOverlay("timing-path",_?{image:_,rect:w}:null)}}try{let w=sessionStorage.getItem("or_restore_view");if(w){sessionStorage.removeItem("or_restore_view");let _=JSON.parse(w);_&&isFinite(_.dbuX)&&isFinite(_.dbuY)&&isFinite(_.zoom)&&he.view.setView(Lv(_.dbuX,_.dbuY,he.designScale,he.designOriginX,he.designOriginY),_.zoom,{animate:!1})}}catch{}}m2&&(document.getElementById("loading-overlay").style.display="none"),he.selectAtWorld=b,m2||(he.onMapClick=(w,_)=>b(w,{addToSelection:!!_.shiftKey,showConnectivity:!!(_.ctrlKey||_.metaKey)}),he.onMapContextClick=(w,_)=>{b(w,{context:!0,focusInspector:!1}).then(()=>he.contextMenu.show(_))}),v3t(he,mg,LO,s,J1,Lpn),!he.overlayLayer&&!m2&&(he.overlayLayer=he.view.addTileSlot("overlay",{order:bp.overlay,source:G5e({wm:he.websocketManager,dpr:xO,tileSize:Fb,buildRequest:(w,_,x)=>Axt(w,_,x,mg,he)})})),rDe(r),d&&!n.shapes_ready&&tgn(),Ub(),he.booted=!0}catch(s){he.scriptRunning||console.error("Failed to load initial data from server:",s)}});document.addEventListener("openroad-cone-sync",s=>{he.schematicWidget?.syncCone(s.detail||{})});document.addEventListener("keydown",s=>{let n=s.target.tagName;if(n==="INPUT"||n==="TEXTAREA"||s.target.isContentEditable)return;let r=s.key.toLowerCase();if(r==="escape"&&he.rulerManager&&he.rulerManager.isActive())he.rulerManager.cancelRulerBuild();else if(r==="escape"&&he.labelManager&&he.labelManager.isActive())he.labelManager.cancelLabelMode();else if(r==="k"&&!s.shiftKey&&!s.ctrlKey&&!s.metaKey)he.rulerManager&&he.rulerManager.toggleRulerMode();else if(r==="k"&&s.shiftKey&&!s.ctrlKey&&!s.metaKey)he.rulerManager&&he.rulerManager.clearAllRulers();else if(r==="l"&&!s.shiftKey&&!s.ctrlKey&&!s.metaKey)he.labelManager&&he.labelManager.toggleLabelMode();else if(r==="f"&&!s.ctrlKey&&!s.metaKey&&he.fitRect)he.view.fitWorldRect(he.fitRect);else if(r==="z"&&!s.ctrlKey&&he.view){let c=s.shiftKey?-1:1;he.view.zoomAround(he.lastMouseWorld?he.view.project(he.lastMouseWorld):null,c)}else r==="f"&&(s.ctrlKey||s.metaKey)?(s.preventDefault(),he.designScale&&ide(he)):r==="g"&&s.shiftKey&&!s.ctrlKey&&!s.metaKey?(s.preventDefault(),he.designScale&&rde(he)):r==="t"&&!s.shiftKey&&!s.ctrlKey&&!s.metaKey&&he.toggleTheme()},!0);})(); +`,"")}else s.type==="restore_display_state"?Bpn(s.state):s.type==="custom_ui"?J3t(s):s.type==="poly_decomp"?aDe(s.value):s.type==="shutdown"&&(he.websocketManager._shutdown=!0,TT.innerHTML='
Server stopped
',TT.style.display="block")};he.websocketManager.readyPromise.then(async()=>{try{let b=function(w,_={}){let{addToSelection:x=!1,focusInspector:T=!0,context:M=!1,showConnectivity:L=!1}=_;if(!he.designScale)return Promise.resolve(null);let{dbuX:I,dbuY:D}=kv(w[0],w[1],he.designScale,he.designOriginX,he.designOriginY);if(he.labelManager&&he.labelManager.isActive())return he.labelManager.handleMapClick(I,D),Promise.resolve(null);let F=Dxt(mg,LO),O={type:"select",dbu_x:I,dbu_y:D,zoom:Math.round(he.view.getZoom()),visible_layers:[...he.visibleLayerNames],selectable_layers:[...he.selectableLayers],use_dbu:he.showDbu,...F};x&&(O.add_to_selection=!0),M&&(O.context=!0),L&&(O.show_connectivity=!0),he.visibleChiplets instanceof Set&&(O.visible_chiplets=[...he.visibleChiplets]);let z=Pm(he);return he.websocketManager.request(O).then(Z=>{if(Y1(he,z)){if(console.log("Select response:",Z,"at dbu",I,D),EO(he,Z),Z.selected&&Z.selected.length>0){let H=Z.selected[0];H.type==="Inst"&&(he.selectedInstanceName=H.name,he.schematicWidget&&he.schematicWidget.refresh()),lH(Z),T&&gde("Inspector"),Z.bbox&&(Wpn(Z.bbox[0],Z.bbox[1],Z.bbox[2],Z.bbox[3],Z.type),Hpn(Z.bbox,Z.type),he.lastSelectionBounds=Z.bbox.slice(0,4)),O.show_connectivity&&Z.connected_added>0&&Fb(`Selected ${Z.connected_added} connected net`+(Z.connected_added>1?"s":""))}else!x&&!M&&(lH(null),he.clearSelectionOutline&&he.clearSelectionOutline(),he.lastSelectionBounds=null);return sDe(),Z}}).catch(Z=>(console.error("Select failed:",Z),null))},[s,n,r]=await Promise.all([he.websocketManager.request({type:"tech"}),he.websocketManager.request({type:"bounds"}),he.websocketManager.request({type:"heatmaps"})]);mde(),he.hasLiberty=s.has_liberty,he.techData=s,G3t(s.block_name),he.websocketManager.request({type:"custom_ui"}).then(J3t).catch(()=>{}),he.websocketManager.request({type:"poly_decomp"}).then(w=>aDe(w.value)).catch(()=>{});let c=n.bounds,u=n.fit_bounds;if(!m2){let w=he.view.getSize();hxt(Gxt({designBounds:c,fitRect:u,viewW:w.width,viewH:w.height}))}let d=Q3t(c,u);if(d){if(he.labelManager&&he.labelManager.reload(),m2){let w=m2.zoom;he.view.setLimits({minZoom:w,maxZoom:w})}if(he.view.fitWorldRect(he.fitRect,{animate:!1}),m2){let w=X1(c[0][1],c[0][0],c[1][1],c[1][0],he.designScale,he.designOriginX,he.designOriginY);m2.setPathOverlay=_=>{he.view.setImageOverlay("timing-path",_?{image:_,rect:w}:null)}}try{let w=sessionStorage.getItem("or_restore_view");if(w){sessionStorage.removeItem("or_restore_view");let _=JSON.parse(w);_&&isFinite(_.dbuX)&&isFinite(_.dbuY)&&isFinite(_.zoom)&&he.view.setView(Lv(_.dbuX,_.dbuY,he.designScale,he.designOriginX,he.designOriginY),_.zoom,{animate:!1})}}catch{}}m2&&(document.getElementById("loading-overlay").style.display="none"),he.selectAtWorld=b,m2||(he.onMapClick=(w,_)=>b(w,{addToSelection:!!_.shiftKey,showConnectivity:!!(_.ctrlKey||_.metaKey)}),he.onMapContextClick=(w,_)=>{b(w,{context:!0,focusInspector:!1}).then(()=>he.contextMenu.show(_))}),y3t(he,mg,LO,s,K1,Dpn),!he.overlayLayer&&!m2&&(he.overlayLayer=he.view.addTileSlot("overlay",{order:bp.overlay,source:G5e({wm:he.websocketManager,dpr:xO,tileSize:Nb,buildRequest:(w,_,x)=>Axt(w,_,x,mg,he)})})),rDe(r),d&&!n.shapes_ready&&sgn(),Ub(),he.booted=!0}catch(s){he.scriptRunning||console.error("Failed to load initial data from server:",s)}});document.addEventListener("openroad-cone-sync",s=>{he.schematicWidget?.syncCone(s.detail||{})});document.addEventListener("keydown",s=>{let n=s.target.tagName;if(n==="INPUT"||n==="TEXTAREA"||s.target.isContentEditable)return;let r=s.key.toLowerCase();if(r==="escape"&&he.rulerManager&&he.rulerManager.isActive())he.rulerManager.cancelRulerBuild();else if(r==="escape"&&he.labelManager&&he.labelManager.isActive())he.labelManager.cancelLabelMode();else if(r==="k"&&!s.shiftKey&&!s.ctrlKey&&!s.metaKey)he.rulerManager&&he.rulerManager.toggleRulerMode();else if(r==="k"&&s.shiftKey&&!s.ctrlKey&&!s.metaKey)he.rulerManager&&he.rulerManager.clearAllRulers();else if(r==="l"&&!s.shiftKey&&!s.ctrlKey&&!s.metaKey)he.labelManager&&he.labelManager.toggleLabelMode();else if(r==="f"&&!s.ctrlKey&&!s.metaKey&&he.fitRect)he.view.fitWorldRect(he.fitRect);else if(r==="z"&&!s.ctrlKey&&he.view){let c=s.shiftKey?-1:1;he.view.zoomAround(he.lastMouseWorld?he.view.project(he.lastMouseWorld):null,c)}else r==="f"&&(s.ctrlKey||s.metaKey)?(s.preventDefault(),he.designScale&&ide(he)):r==="g"&&s.shiftKey&&!s.ctrlKey&&!s.metaKey?(s.preventDefault(),he.designScale&&rde(he)):r==="t"&&!s.shiftKey&&!s.ctrlKey&&!s.metaKey&&he.toggleTheme()},!0);})(); /*! Bundled license information: sax/lib/sax.js: diff --git a/src/web/dist/index.html b/src/web/dist/index.html index 33aa88f2304..50cfd59c837 100644 --- a/src/web/dist/index.html +++ b/src/web/dist/index.html @@ -19,7 +19,7 @@ - diff --git a/src/web/dist/report.min.js b/src/web/dist/report.min.js index 28f8c9d06a0..9f0c776c056 100644 --- a/src/web/dist/report.min.js +++ b/src/web/dist/report.min.js @@ -1,6 +1,6 @@ -(()=>{var ZM=Object.create;var fp=Object.defineProperty;var XM=Object.getOwnPropertyDescriptor;var KM=Object.getOwnPropertyNames;var QM=Object.getPrototypeOf,JM=Object.prototype.hasOwnProperty;var C=(n,e)=>()=>(n&&(e=n(n=0)),e);var eA=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),mi=(n,e)=>{for(var t in e)fp(n,t,{get:e[t],enumerable:!0})},tA=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of KM(e))!JM.call(n,r)&&r!==t&&fp(n,r,{get:()=>e[r],enumerable:!(i=XM(e,r))||i.enumerable});return n};var nA=(n,e,t)=>(t=n!=null?ZM(QM(n)):{},tA(e||!n||!n.__esModule?fp(t,"default",{value:n,enumerable:!0}):t,n));var ra,cA,Kl,lA,bv,dp=C(()=>{ra=globalThis,cA=globalThis.document||{},Kl=globalThis.process||{},lA=globalThis.console,bv=globalThis.navigator||{}});function Ql(n){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&process.versions?.electron)return!0;let e=typeof navigator<"u"&&navigator.userAgent,t=n||e;return!!(t&&t.indexOf("Electron")>=0)}var hp=C(()=>{});function Tt(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Ql()}var pp=C(()=>{hp()});function mp(n){return!n&&!Tt()?"Node":Ql(n)?"Electron":(n||bv.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var vv=C(()=>{pp();hp();dp()});var gp,vr=C(()=>{dp();pp();vv();gp="4.1.2"});function Is(n,e){if(!n)throw new Error(e||"Assertion failed")}var _p=C(()=>{});function yp(n){if(!n)return 0;let e;switch(typeof n){case"number":e=n;break;case"object":e=n.logLevel||n.priority||0;break;default:return 0}return Is(Number.isFinite(e)&&e>=0),e}function xv(n){let{logLevel:e,message:t}=n;n.logLevel=yp(e);let i=n.args?Array.from(n.args):[];for(;i.length&&i.shift()!==t;);switch(typeof e){case"string":case"function":t!==void 0&&i.unshift(t),n.message=e;break;case"object":Object.assign(n,e);break;default:}typeof n.message=="function"&&(n.message=n.message());let r=typeof n.message;return Is(r==="string"||r==="object"),Object.assign(n,{args:i},n.opts)}var wv=C(()=>{_p()});var xr,Jl,Ev=C(()=>{wv();xr=()=>{},Jl=class{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...t){return this._log("warn",0,e,t,{once:!0})}error(e,...t){return this._log("error",0,e,t)}log(e,t,...i){return this._log("log",e,t,i)}info(e,t,...i){return this._log("info",e,t,i)}once(e,t,...i){return this._log("once",e,t,i,{once:!0})}_log(e,t,i,r,s={}){let o=xv({logLevel:t,message:i,args:this._buildArgs(t,i,r),opts:s});return this._createLogFunction(e,o,s)}_buildArgs(e,t,i){return[e,t,...i]}_createLogFunction(e,t,i){if(!this._shouldLog(t.logLevel))return xr;let r=this._getOnceTag(i.tag??t.tag??t.message);if((i.once||t.once)&&r!==void 0){if(this._onceCache.has(r))return xr;this._onceCache.add(r)}return this._emit(e,t)}_shouldLog(e){return this.getLevel()>=yp(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}}});function fA(n){try{let e=window[n],t="__storage_test__";return e.setItem(t,t),e.removeItem(t),e}catch{return null}}var eu,Sv=C(()=>{eu=class{constructor(e,t,i="sessionStorage"){this.storage=fA(i),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}}_loadConfiguration(){let e={};if(this.storage){let t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}});function Pv(n){let e;return n<10?e=`${n.toFixed(2)}ms`:n<100?e=`${n.toFixed(1)}ms`:n<1e3?e=`${n.toFixed(0)}ms`:e=`${(n/1e3).toFixed(2)}s`,e}function Cv(n,e=8){let t=Math.max(e-n.length,0);return`${" ".repeat(t)}${n}`}var Tv=C(()=>{});function Lv(n){return typeof n!="string"?n:(n=n.toUpperCase(),tu[n]||tu.WHITE)}function Mv(n,e,t){return!Tt&&typeof n=="string"&&(e&&(n=`\x1B[${Lv(e)}m${n}\x1B[39m`),t&&(n=`\x1B[${Lv(t)+dA}m${n}\x1B[49m`)),n}var tu,dA,Av=C(()=>{vr();(function(n){n[n.BLACK=30]="BLACK",n[n.RED=31]="RED",n[n.GREEN=32]="GREEN",n[n.YELLOW=33]="YELLOW",n[n.BLUE=34]="BLUE",n[n.MAGENTA=35]="MAGENTA",n[n.CYAN=36]="CYAN",n[n.WHITE=37]="WHITE",n[n.BRIGHT_BLACK=90]="BRIGHT_BLACK",n[n.BRIGHT_RED=91]="BRIGHT_RED",n[n.BRIGHT_GREEN=92]="BRIGHT_GREEN",n[n.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",n[n.BRIGHT_BLUE=94]="BRIGHT_BLUE",n[n.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",n[n.BRIGHT_CYAN=96]="BRIGHT_CYAN",n[n.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(tu||(tu={}));dA=10});function kv(n,e=["constructor"]){let t=Object.getPrototypeOf(n),i=Object.getOwnPropertyNames(t),r=n;for(let s of i){let o=r[s];typeof o=="function"&&(e.find(a=>s===a)||(r[s]=o.bind(n)))}}var Rv=C(()=>{});var nu,Bn,bp=C(()=>{vr();nu=class{getHighResolutionTimer(){let e;if(Tt()&&ra.performance)e=ra?.performance?.now?.();else if("hrtime"in Kl){let t=Kl?.hrtime?.();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}getMemoryUsageMB(){let t=ra?.performance?.memory?.usedJSHeapSize;return t==null?null:Math.trunc(t/1024/1024)}},Bn=new nu;globalThis.Probe=nu;globalThis.probe=Bn});function hA(n,e,t){if(typeof e=="string"){let i=t.time?Cv(Pv(t.total)):"";e=t.time?`${n}: ${i} ${e}`:`${n}: ${e}`,e=Mv(e,t.color,t.background)}return e}function pA(n){for(let e in n)for(let t in n[e])return t||"untitled";return"empty"}var Bs,vp,ct,xp=C(()=>{vr();Ev();Sv();Tv();Av();Rv();_p();bp();Bs={debug:Tt()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},vp={enabled:!0,level:0},ct=class extends Jl{constructor({id:e}={id:""}){super({level:0}),this.VERSION=gp,this._startTs=Bn.getHighResolutionTimer(),this._deltaTs=Bn.getHighResolutionTimer(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new eu(`__probe-${this.id}__`,{[this.id]:vp}),this.timeStamp(`${this.id} started`),kv(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((Bn.getHighResolutionTimer()-this._startTs).toPrecision(10))}getDelta(){return Number((Bn.getHighResolutionTimer()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,t){this._updateConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw new Error(t||"Assertion failed")}warn(e,...t){return this._log("warn",0,e,t,{method:Bs.warn,once:!0})}error(e,...t){return this._log("error",0,e,t,{method:Bs.error})}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t,...i){let r=Bn.getMemoryUsageMB();if(r!==null){let s=`${r}MB `;typeof t=="function"?t=()=>`${s}${t()}`:typeof t=="string"&&(t=`${s}${t}`)}return this._log("log",e,t,i,{method:Bs.log,time:!0,once:!0})}log(e,t,...i){return this._log("log",e,t,i,{method:Bs.debug})}info(e,t,...i){return this._log("info",e,t,i,{method:console.info})}once(e,t,...i){return this._log("once",e,t,i,{method:Bs.debug||Bs.info,once:!0})}table(e,t,i){return t?this._log("table",e,t,i&&[i]||[],{method:console.table||xr,tag:pA(t)}):xr}time(e,t){return this._log("time",e,t,[],{method:console.time?console.time:console.info})}timeEnd(e,t){return this._log("time",e,t,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,t){return this._log("time",e,t,[],{method:console.timeStamp||xr})}group(e,t,i={collapsed:!1}){let r=(i.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,t,[],{method:r})}groupCollapsed(e,t,i={}){return this.group(e,t,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||xr})}withGroup(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,t){let i=t.method;Is(i),t.total=this.getTotal(),t.delta=this.getDelta(),this._deltaTs=Bn.getHighResolutionTimer();let r=hA(this.id,t.message,t);return i.bind(console,r,...t.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(vp),this._storage.config[this.id]}_updateConfiguration(e){let t=this._storage.config[this.id]||{...vp};this._storage.setConfiguration({[this.id]:{...t,...e}})}};ct.VERSION=gp});var Iv=C(()=>{bp();globalThis.probe||(globalThis.probe=Bn)});var Nj,sa=C(()=>{xp();xp();Iv();Nj=new ct({id:"@probe.gl/log"})});function la(){let n;if(typeof window<"u"&&window.performance)n=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();n=e[0]*1e3+e[1]/1e6}else n=Date.now();return n}var Fp=C(()=>{});var Er,zp=C(()=>{Fp();Er=class{constructor(e,t){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=la(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(la()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}});var Yt,Hv=C(()=>{zp();Yt=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let t of Object.values(this.stats))e(t)}getTable(){let e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(t=>this._getOrCreate(t))}_getOrCreate(e){let{name:t,type:i}=e,r=this.stats[t];return r||(e instanceof Er?r=e:r=new Er(t,i),this.stats[t]=r),r}}});var ua=C(()=>{Hv();zp();Fp()});function wx(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Ex(n){return Array.isArray(n)?n.length===0||typeof n[0]=="number":!1}function _a(n){return wx(n)||Ex(n)}var Sx=C(()=>{});var Jp=C(()=>{Sx()});function $s(n){let e=n.split(""),t=0,i=0,r=!1,s=!1,o=!1;for(;t{var QM=Object.create;var fp=Object.defineProperty;var JM=Object.getOwnPropertyDescriptor;var eA=Object.getOwnPropertyNames;var tA=Object.getPrototypeOf,nA=Object.prototype.hasOwnProperty;var C=(n,e)=>()=>(n&&(e=n(n=0)),e);var iA=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),mi=(n,e)=>{for(var t in e)fp(n,t,{get:e[t],enumerable:!0})},rA=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of eA(e))!nA.call(n,r)&&r!==t&&fp(n,r,{get:()=>e[r],enumerable:!(i=JM(e,r))||i.enumerable});return n};var sA=(n,e,t)=>(t=n!=null?QM(tA(n)):{},rA(e||!n||!n.__esModule?fp(t,"default",{value:n,enumerable:!0}):t,n));var ra,fA,Kl,dA,bv,dp=C(()=>{ra=globalThis,fA=globalThis.document||{},Kl=globalThis.process||{},dA=globalThis.console,bv=globalThis.navigator||{}});function Ql(n){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&process.versions?.electron)return!0;let e=typeof navigator<"u"&&navigator.userAgent,t=n||e;return!!(t&&t.indexOf("Electron")>=0)}var hp=C(()=>{});function Tt(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Ql()}var pp=C(()=>{hp()});function mp(n){return!n&&!Tt()?"Node":Ql(n)?"Electron":(n||bv.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var vv=C(()=>{pp();hp();dp()});var gp,vr=C(()=>{dp();pp();vv();gp="4.1.2"});function Is(n,e){if(!n)throw new Error(e||"Assertion failed")}var _p=C(()=>{});function yp(n){if(!n)return 0;let e;switch(typeof n){case"number":e=n;break;case"object":e=n.logLevel||n.priority||0;break;default:return 0}return Is(Number.isFinite(e)&&e>=0),e}function xv(n){let{logLevel:e,message:t}=n;n.logLevel=yp(e);let i=n.args?Array.from(n.args):[];for(;i.length&&i.shift()!==t;);switch(typeof e){case"string":case"function":t!==void 0&&i.unshift(t),n.message=e;break;case"object":Object.assign(n,e);break;default:}typeof n.message=="function"&&(n.message=n.message());let r=typeof n.message;return Is(r==="string"||r==="object"),Object.assign(n,{args:i},n.opts)}var wv=C(()=>{_p()});var xr,Jl,Ev=C(()=>{wv();xr=()=>{},Jl=class{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...t){return this._log("warn",0,e,t,{once:!0})}error(e,...t){return this._log("error",0,e,t)}log(e,t,...i){return this._log("log",e,t,i)}info(e,t,...i){return this._log("info",e,t,i)}once(e,t,...i){return this._log("once",e,t,i,{once:!0})}_log(e,t,i,r,s={}){let o=xv({logLevel:t,message:i,args:this._buildArgs(t,i,r),opts:s});return this._createLogFunction(e,o,s)}_buildArgs(e,t,i){return[e,t,...i]}_createLogFunction(e,t,i){if(!this._shouldLog(t.logLevel))return xr;let r=this._getOnceTag(i.tag??t.tag??t.message);if((i.once||t.once)&&r!==void 0){if(this._onceCache.has(r))return xr;this._onceCache.add(r)}return this._emit(e,t)}_shouldLog(e){return this.getLevel()>=yp(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}}});function pA(n){try{let e=window[n],t="__storage_test__";return e.setItem(t,t),e.removeItem(t),e}catch{return null}}var eu,Sv=C(()=>{eu=class{constructor(e,t,i="sessionStorage"){this.storage=pA(i),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}}_loadConfiguration(){let e={};if(this.storage){let t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}});function Pv(n){let e;return n<10?e=`${n.toFixed(2)}ms`:n<100?e=`${n.toFixed(1)}ms`:n<1e3?e=`${n.toFixed(0)}ms`:e=`${(n/1e3).toFixed(2)}s`,e}function Cv(n,e=8){let t=Math.max(e-n.length,0);return`${" ".repeat(t)}${n}`}var Tv=C(()=>{});function Lv(n){return typeof n!="string"?n:(n=n.toUpperCase(),tu[n]||tu.WHITE)}function Mv(n,e,t){return!Tt&&typeof n=="string"&&(e&&(n=`\x1B[${Lv(e)}m${n}\x1B[39m`),t&&(n=`\x1B[${Lv(t)+mA}m${n}\x1B[49m`)),n}var tu,mA,Av=C(()=>{vr();(function(n){n[n.BLACK=30]="BLACK",n[n.RED=31]="RED",n[n.GREEN=32]="GREEN",n[n.YELLOW=33]="YELLOW",n[n.BLUE=34]="BLUE",n[n.MAGENTA=35]="MAGENTA",n[n.CYAN=36]="CYAN",n[n.WHITE=37]="WHITE",n[n.BRIGHT_BLACK=90]="BRIGHT_BLACK",n[n.BRIGHT_RED=91]="BRIGHT_RED",n[n.BRIGHT_GREEN=92]="BRIGHT_GREEN",n[n.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",n[n.BRIGHT_BLUE=94]="BRIGHT_BLUE",n[n.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",n[n.BRIGHT_CYAN=96]="BRIGHT_CYAN",n[n.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(tu||(tu={}));mA=10});function kv(n,e=["constructor"]){let t=Object.getPrototypeOf(n),i=Object.getOwnPropertyNames(t),r=n;for(let s of i){let o=r[s];typeof o=="function"&&(e.find(a=>s===a)||(r[s]=o.bind(n)))}}var Rv=C(()=>{});var nu,Bn,bp=C(()=>{vr();nu=class{getHighResolutionTimer(){let e;if(Tt()&&ra.performance)e=ra?.performance?.now?.();else if("hrtime"in Kl){let t=Kl?.hrtime?.();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}getMemoryUsageMB(){let t=ra?.performance?.memory?.usedJSHeapSize;return t==null?null:Math.trunc(t/1024/1024)}},Bn=new nu;globalThis.Probe=nu;globalThis.probe=Bn});function gA(n,e,t){if(typeof e=="string"){let i=t.time?Cv(Pv(t.total)):"";e=t.time?`${n}: ${i} ${e}`:`${n}: ${e}`,e=Mv(e,t.color,t.background)}return e}function _A(n){for(let e in n)for(let t in n[e])return t||"untitled";return"empty"}var Bs,vp,ct,xp=C(()=>{vr();Ev();Sv();Tv();Av();Rv();_p();bp();Bs={debug:Tt()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},vp={enabled:!0,level:0},ct=class extends Jl{constructor({id:e}={id:""}){super({level:0}),this.VERSION=gp,this._startTs=Bn.getHighResolutionTimer(),this._deltaTs=Bn.getHighResolutionTimer(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new eu(`__probe-${this.id}__`,{[this.id]:vp}),this.timeStamp(`${this.id} started`),kv(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((Bn.getHighResolutionTimer()-this._startTs).toPrecision(10))}getDelta(){return Number((Bn.getHighResolutionTimer()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,t){this._updateConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw new Error(t||"Assertion failed")}warn(e,...t){return this._log("warn",0,e,t,{method:Bs.warn,once:!0})}error(e,...t){return this._log("error",0,e,t,{method:Bs.error})}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t,...i){let r=Bn.getMemoryUsageMB();if(r!==null){let s=`${r}MB `;typeof t=="function"?t=()=>`${s}${t()}`:typeof t=="string"&&(t=`${s}${t}`)}return this._log("log",e,t,i,{method:Bs.log,time:!0,once:!0})}log(e,t,...i){return this._log("log",e,t,i,{method:Bs.debug})}info(e,t,...i){return this._log("info",e,t,i,{method:console.info})}once(e,t,...i){return this._log("once",e,t,i,{method:Bs.debug||Bs.info,once:!0})}table(e,t,i){return t?this._log("table",e,t,i&&[i]||[],{method:console.table||xr,tag:_A(t)}):xr}time(e,t){return this._log("time",e,t,[],{method:console.time?console.time:console.info})}timeEnd(e,t){return this._log("time",e,t,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,t){return this._log("time",e,t,[],{method:console.timeStamp||xr})}group(e,t,i={collapsed:!1}){let r=(i.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,t,[],{method:r})}groupCollapsed(e,t,i={}){return this.group(e,t,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||xr})}withGroup(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,t){let i=t.method;Is(i),t.total=this.getTotal(),t.delta=this.getDelta(),this._deltaTs=Bn.getHighResolutionTimer();let r=gA(this.id,t.message,t);return i.bind(console,r,...t.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(vp),this._storage.config[this.id]}_updateConfiguration(e){let t=this._storage.config[this.id]||{...vp};this._storage.setConfiguration({[this.id]:{...t,...e}})}};ct.VERSION=gp});var Iv=C(()=>{bp();globalThis.probe||(globalThis.probe=Bn)});var $j,sa=C(()=>{xp();xp();Iv();$j=new ct({id:"@probe.gl/log"})});function la(){let n;if(typeof window<"u"&&window.performance)n=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();n=e[0]*1e3+e[1]/1e6}else n=Date.now();return n}var Fp=C(()=>{});var Er,zp=C(()=>{Fp();Er=class{constructor(e,t){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=la(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(la()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}});var Ht,Hv=C(()=>{zp();Ht=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let t of Object.values(this.stats))e(t)}getTable(){let e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(t=>this._getOrCreate(t))}_getOrCreate(e){let{name:t,type:i}=e,r=this.stats[t];return r||(e instanceof Er?r=e:r=new Er(t,i),this.stats[t]=r),r}}});var ua=C(()=>{Hv();zp();Fp()});function wx(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Ex(n){return Array.isArray(n)?n.length===0||typeof n[0]=="number":!1}function _a(n){return wx(n)||Ex(n)}var Sx=C(()=>{});var Jp=C(()=>{Sx()});function $s(n){let e=n.split(""),t=0,i=0,r=!1,s=!1,o=!1;for(;t0){if(a==="/"&&c==="*"){e[t]=" ",e[t+1]=" ",i++,t+=2;continue}if(a==="*"&&c==="/"){e[t]=" ",e[t+1]=" ",i--,t+=2;continue}a!==` -`&&a!=="\r"&&(e[t]=" "),t++;continue}if(a==='"'){s=!0,t++;continue}if(a==="/"&&c==="/"){e[t]=" ",e[t+1]=" ",r=!0,t+=2;continue}if(a==="/"&&c==="*"){e[t]=" ",e[t+1]=" ",i=1,t+=2;continue}t++}return e.join("")}function Pr(n,e){let t=$s(n),i=[];for(let r of e){r.lastIndex=0;let s;for(s=r.exec(t);s;){let o=r===e[0],a=s.index,c=s[0].length;i.push({match:n.slice(a,a+c),index:a,length:c,bindingToken:s[o?1:2],groupToken:s[o?2:1],accessDeclaration:s[3]?.trim(),name:s[4]}),s=r.exec(t)}}return i.sort((r,s)=>r.index-s.index)}function om(n,e,t){let i=Pr(n,e);if(!i.length)return n;let r="",s=0;for(let o of i)r+=n.slice(s,o.index),r+=t(o),s=o.index+o.length;return r+=n.slice(s),r}function am(n){return/@binding\(\s*auto\s*\)/.test($s(n))}function zx(n,e){return Pr(n,e===Us||e===gu?kk:e).find(i=>i.bindingToken==="auto")}var At,qt,Us,gu,Fx,kk,_u=C(()=>{At="(?:var<\\s*(uniform|storage(?:\\s*,\\s*[A-Za-z_][A-Za-z0-9_]*)?)\\s*>|var)\\s+([A-Za-z_][A-Za-z0-9_]*)",qt="\\s*",Us=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${qt}@group\\(\\s*(\\d+)\\s*\\)${qt}${At}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${qt}@binding\\(\\s*(auto|\\d+)\\s*\\)${qt}${At}`,"g")],gu=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${qt}@group\\(\\s*(\\d+)\\s*\\)${qt}${At}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${qt}@binding\\(\\s*(auto|\\d+)\\s*\\)${qt}${At}`,"g")],Fx=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)${qt}@group\\(\\s*(\\d+)\\s*\\)${qt}${At}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${qt}@binding\\(\\s*(\\d+)\\s*\\)${qt}${At}`,"g")],kk=[new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${At}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)\\s*${At}`,"g"),new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${At}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${At}`,"g")]});function bu(n,e={}){let t=Ux(n),i=Rk(t);if(!i)return null;let r=Ik(t,i);if(!r)return null;let s=Ok(t,i,r);if(!s)return null;if(e.scanVertexAttributes===!1)return{attributes:[],bindings:s};let o=Bk(t,i);if(!o)return null;let a=Uk(t,i,r,o,e.vertexEntryPoint);return a?{attributes:a,bindings:s}:null}function Ux(n){let e=$s(n),t=/[A-Za-z_][A-Za-z0-9_]*|(?:0[xX][0-9A-Fa-f]+|\d+)|[@(){}<>\[\]:,;=]/g,i=[],r=t.exec(e);for(;r;)i.push({value:r[0],index:r.index}),r=t.exec(e);return i}function Rk(n){let e=[],t=0;for(let i of n){if(i.value==="}"&&t===0)return null;e.push(t),i.value==="{"?t++:i.value==="}"&&t--}return t===0?e:null}function Ik(n,e){let t=new Map;for(let i=0;i");if(y<0)return null;let b=vu(n.slice(f+1,y),",");if(!b)return null;d=b.map(yu),f=y+1}let h=n[f]?.value;if(!va(h)||n[f+1]?.value!==":")return null;let p=Vx(n,e,f+2,";");if(p<0||p===f+2)return null;let m=um(yu(n.slice(f+2,p)),t);if(!m)return null;let g=Dk({name:h,group:l,location:u,addressSpace:d,resourceType:m}),v=`${l}:${u}`;if(!g||r.has(v)||s.has(h))return null;i.push(g),r.add(v),s.add(h),o=p}return zk(i),i.sort((o,a)=>o.group-a.group||o.location-a.location||o.name.localeCompare(a.name))}function Dk(n){let{name:e,group:t,location:i,addressSpace:r,resourceType:s}=n,o={name:e,group:t,location:i};if(r[0]==="uniform"&&r.length===1)return{...o,type:"uniform"};if(r[0]==="storage"&&r.length<=2){let a=r[1]||"read";return a==="read"?{...o,type:"read-only-storage"}:a==="read_write"?{...o,type:"storage"}:null}return r.length>0?null:s==="sampler"||s==="sampler_comparison"?{...o,type:"sampler",...s==="sampler_comparison"?{samplerType:"comparison"}:{}}:s==="texture_external"?{...o,type:"external-texture"}:Nk(o,s)||Fk(o,s)}function Nk(n,e){let t=/^texture_storage_(1d|2d|2d_array|3d)<([A-Za-z0-9_]+),(read|write|read_write)>$/.exec(e);if(!t)return null;let i={read:"read-only",write:"write-only",read_write:"read-write"}[t[3]];return{...n,type:"storage",format:t[2],access:i,viewDimension:lm(t[1])}}function Fk(n,e){let t=/^texture_(multisampled_)?(1d|2d|2d_array|cube|cube_array|3d)<(f32|i32|u32)>$/.exec(e);if(t){if(t[1]&&t[2]!=="2d")return null;let r={f32:"float",i32:"sint",u32:"uint"}[t[3]];return{...n,type:"texture",viewDimension:lm(t[2]),sampleType:r,multisampled:!!t[1]}}let i=/^texture_depth_(multisampled_)?(2d|2d_array|cube|cube_array)$/.exec(e);return!i||i[1]&&i[2]!=="2d"?null:{...n,type:"texture",viewDimension:lm(i[2]),sampleType:"depth",multisampled:!!i[1]}}function zk(n){for(let e of n){if(e.type!=="sampler"||e.samplerType||!e.name.endsWith("Sampler"))continue;let t=e.name.slice(0,-7);n.find(r=>r.type==="texture"&&r.name===t&&r.group===e.group)?.sampleType==="depth"&&(e.samplerType="non-filtering")}}function Uk(n,e,t,i,r){let s=$k(n,e);if(!s)return null;let o=s.filter(h=>h.vertex),a=r?o.find(h=>h.name===r):o.length===1?o[0]:void 0;if(!a)return o.length===0&&!r?[]:null;let c=vu(a.parameters,",");if(!c)return null;let l=[],u=new Set,f=new Set,d=new Set;for(let h of c)if(h.length>0&&!$x({declaration:h,aliases:t,structures:i,attributes:l,attributeLocations:u,attributeNames:f,visitedStructures:d}))return null;return l.sort((h,p)=>h.location-p.location||h.name.localeCompare(p.name))}function $k(n,e){let t=[],i=new Set;for(let r=0;r0&&!$x({...n,declaration:m}))return!1;return a.delete(d),!0}function um(n,e,t=new Set){let i=Ux(n),r="";for(let s of i){let o=e.get(s.value);if(!o){r+=Gk(s.value);continue}if(t.has(s.value))return null;let a=new Set(t);a.add(s.value);let c=um(o,e,a);if(!c)return null;r+=c}return r}function Gk(n){let e=/^(vec[234]|mat[234]x[234])([fiuh])$/.exec(n);if(!e)return n;let t={f:"f32",i:"i32",u:"u32",h:"f16"}[e[2]];return`${e[1]}<${t}>`}function Vk(n){return/^(?:i32|u32|f32|f16|vec[234]<(?:i32|u32|f32|f16)>)$/.test(n)?n:null}function cm(n,e){let t;for(let i=0;it.value==="@"&&n[i+1]?.value===e)}function lm(n){return n.replace("_","-")}function fm(n,e,t,i){let r=0;for(let s=e;s":"<","]":"[","}":"{"};for(let a=0;ar[l]===0)){t.push(n.slice(i,a)),i=a+1;continue}if(c in r)r[c]++;else if(c in o){let l=o[c];if(r[l]--,r[l]<0)return null}}return s.every(a=>r[a]===0)?(t.push(n.slice(i)),t):null}function Wk(n,e){let t=vu(n,e);return t&&t.length===2?t[0].length:-1}function Vx(n,e,t,i){for(let r=t;r=0;i--)if(n[i].value===";"&&e[i]===0||n[i].value==="}"&&e[i]===1)return i+1;return 0}function jk(n){for(let e=n.length-1;e>=0;e--)if(va(n[e].value))return n[e].value;return null}function yu(n){return n.map(e=>e.value).join("")}function va(n){return!!(n&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(n))}var dm=C(()=>{_u()});function yi(n,e){if(!n){let t=new Error(e||"shadertools: assertion failed.");throw Error.captureStackTrace?.(t,yi),t}}var xu=C(()=>{});function Hx(n){let e={};for(let[t,i]of Object.entries(n))e[t]=Hk(i);return e}function Hk(n){let e=jx(n);if(e!=="object")return{value:n,...hm[e],type:e};if(typeof n=="object")return n?n.type!==void 0?{...n,...hm[n.type],type:n.type}:n.value===void 0?{type:"object",value:n}:(e=jx(n.value),{...n,...hm[e],type:e}):{type:"object",value:null};throw new Error("props")}function jx(n){return Array.isArray(n)||ArrayBuffer.isView(n)?"array":typeof n}var hm,Yx=C(()=>{hm={number:{type:"number",validate(n,e){return Number.isFinite(n)&&typeof e=="object"&&(e.max===void 0||n<=e.max)&&(e.min===void 0||n>=e.min)}},array:{type:"array",validate(n,e){return Array.isArray(n)||ArrayBuffer.isView(n)}}}});var qx,Zx,Xx=C(()=>{qx=`#ifdef MODULE_LOGDEPTH +`&&a!=="\r"&&(e[t]=" "),t++;continue}if(a==='"'){s=!0,t++;continue}if(a==="/"&&c==="/"){e[t]=" ",e[t+1]=" ",r=!0,t+=2;continue}if(a==="/"&&c==="*"){e[t]=" ",e[t+1]=" ",i=1,t+=2;continue}t++}return e.join("")}function Pr(n,e){let t=$s(n),i=[];for(let r of e){r.lastIndex=0;let s;for(s=r.exec(t);s;){let o=r===e[0],a=s.index,c=s[0].length;i.push({match:n.slice(a,a+c),index:a,length:c,bindingToken:s[o?1:2],groupToken:s[o?2:1],accessDeclaration:s[3]?.trim(),name:s[4]}),s=r.exec(t)}}return i.sort((r,s)=>r.index-s.index)}function om(n,e,t){let i=Pr(n,e);if(!i.length)return n;let r="",s=0;for(let o of i)r+=n.slice(s,o.index),r+=t(o),s=o.index+o.length;return r+=n.slice(s),r}function am(n){return/@binding\(\s*auto\s*\)/.test($s(n))}function zx(n,e){return Pr(n,e===Us||e===gu?Bk:e).find(i=>i.bindingToken==="auto")}var At,Yt,Us,gu,Fx,Bk,_u=C(()=>{At="(?:var<\\s*(uniform|storage(?:\\s*,\\s*[A-Za-z_][A-Za-z0-9_]*)?)\\s*>|var)\\s+([A-Za-z_][A-Za-z0-9_]*)",Yt="\\s*",Us=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${Yt}@group\\(\\s*(\\d+)\\s*\\)${Yt}${At}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${Yt}@binding\\(\\s*(auto|\\d+)\\s*\\)${Yt}${At}`,"g")],gu=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${Yt}@group\\(\\s*(\\d+)\\s*\\)${Yt}${At}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${Yt}@binding\\(\\s*(auto|\\d+)\\s*\\)${Yt}${At}`,"g")],Fx=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)${Yt}@group\\(\\s*(\\d+)\\s*\\)${Yt}${At}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${Yt}@binding\\(\\s*(\\d+)\\s*\\)${Yt}${At}`,"g")],Bk=[new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${At}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)\\s*${At}`,"g"),new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${At}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${At}`,"g")]});function bu(n,e={}){let t=Ux(n),i=Ok(t);if(!i)return null;let r=Dk(t,i);if(!r)return null;let s=Fk(t,i,r);if(!s)return null;if(e.scanVertexAttributes===!1)return{attributes:[],bindings:s};let o=Nk(t,i);if(!o)return null;let a=Vk(t,i,r,o,e.vertexEntryPoint);return a?{attributes:a,bindings:s}:null}function Ux(n){let e=$s(n),t=/[A-Za-z_][A-Za-z0-9_]*|(?:0[xX][0-9A-Fa-f]+|\d+)|[@(){}<>\[\]:,;=]/g,i=[],r=t.exec(e);for(;r;)i.push({value:r[0],index:r.index}),r=t.exec(e);return i}function Ok(n){let e=[],t=0;for(let i of n){if(i.value==="}"&&t===0)return null;e.push(t),i.value==="{"?t++:i.value==="}"&&t--}return t===0?e:null}function Dk(n,e){let t=new Map;for(let i=0;i");if(y<0)return null;let b=vu(n.slice(f+1,y),",");if(!b)return null;d=b.map(yu),f=y+1}let h=n[f]?.value;if(!va(h)||n[f+1]?.value!==":")return null;let p=Vx(n,e,f+2,";");if(p<0||p===f+2)return null;let m=um(yu(n.slice(f+2,p)),t);if(!m)return null;let g=zk({name:h,group:l,location:u,addressSpace:d,resourceType:m}),v=`${l}:${u}`;if(!g||r.has(v)||s.has(h))return null;i.push(g),r.add(v),s.add(h),o=p}return Gk(i),i.sort((o,a)=>o.group-a.group||o.location-a.location||o.name.localeCompare(a.name))}function zk(n){let{name:e,group:t,location:i,addressSpace:r,resourceType:s}=n,o={name:e,group:t,location:i};if(r[0]==="uniform"&&r.length===1)return{...o,type:"uniform"};if(r[0]==="storage"&&r.length<=2){let a=r[1]||"read";return a==="read"?{...o,type:"read-only-storage"}:a==="read_write"?{...o,type:"storage"}:null}return r.length>0?null:s==="sampler"||s==="sampler_comparison"?{...o,type:"sampler",...s==="sampler_comparison"?{samplerType:"comparison"}:{}}:s==="texture_external"?{...o,type:"external-texture"}:Uk(o,s)||$k(o,s)}function Uk(n,e){let t=/^texture_storage_(1d|2d|2d_array|3d)<([A-Za-z0-9_]+),(read|write|read_write)>$/.exec(e);if(!t)return null;let i={read:"read-only",write:"write-only",read_write:"read-write"}[t[3]];return{...n,type:"storage",format:t[2],access:i,viewDimension:lm(t[1])}}function $k(n,e){let t=/^texture_(multisampled_)?(1d|2d|2d_array|cube|cube_array|3d)<(f32|i32|u32)>$/.exec(e);if(t){if(t[1]&&t[2]!=="2d")return null;let r={f32:"float",i32:"sint",u32:"uint"}[t[3]];return{...n,type:"texture",viewDimension:lm(t[2]),sampleType:r,multisampled:!!t[1]}}let i=/^texture_depth_(multisampled_)?(2d|2d_array|cube|cube_array)$/.exec(e);return!i||i[1]&&i[2]!=="2d"?null:{...n,type:"texture",viewDimension:lm(i[2]),sampleType:"depth",multisampled:!!i[1]}}function Gk(n){for(let e of n){if(e.type!=="sampler"||e.samplerType||!e.name.endsWith("Sampler"))continue;let t=e.name.slice(0,-7);n.find(r=>r.type==="texture"&&r.name===t&&r.group===e.group)?.sampleType==="depth"&&(e.samplerType="non-filtering")}}function Vk(n,e,t,i,r){let s=Wk(n,e);if(!s)return null;let o=s.filter(h=>h.vertex),a=r?o.find(h=>h.name===r):o.length===1?o[0]:void 0;if(!a)return o.length===0&&!r?[]:null;let c=vu(a.parameters,",");if(!c)return null;let l=[],u=new Set,f=new Set,d=new Set;for(let h of c)if(h.length>0&&!$x({declaration:h,aliases:t,structures:i,attributes:l,attributeLocations:u,attributeNames:f,visitedStructures:d}))return null;return l.sort((h,p)=>h.location-p.location||h.name.localeCompare(p.name))}function Wk(n,e){let t=[],i=new Set;for(let r=0;r0&&!$x({...n,declaration:m}))return!1;return a.delete(d),!0}function um(n,e,t=new Set){let i=Ux(n),r="";for(let s of i){let o=e.get(s.value);if(!o){r+=jk(s.value);continue}if(t.has(s.value))return null;let a=new Set(t);a.add(s.value);let c=um(o,e,a);if(!c)return null;r+=c}return r}function jk(n){let e=/^(vec[234]|mat[234]x[234])([fiuh])$/.exec(n);if(!e)return n;let t={f:"f32",i:"i32",u:"u32",h:"f16"}[e[2]];return`${e[1]}<${t}>`}function Hk(n){return/^(?:i32|u32|f32|f16|vec[234]<(?:i32|u32|f32|f16)>)$/.test(n)?n:null}function cm(n,e){let t;for(let i=0;it.value==="@"&&n[i+1]?.value===e)}function lm(n){return n.replace("_","-")}function fm(n,e,t,i){let r=0;for(let s=e;s":"<","]":"[","}":"{"};for(let a=0;ar[l]===0)){t.push(n.slice(i,a)),i=a+1;continue}if(c in r)r[c]++;else if(c in o){let l=o[c];if(r[l]--,r[l]<0)return null}}return s.every(a=>r[a]===0)?(t.push(n.slice(i)),t):null}function Yk(n,e){let t=vu(n,e);return t&&t.length===2?t[0].length:-1}function Vx(n,e,t,i){for(let r=t;r=0;i--)if(n[i].value===";"&&e[i]===0||n[i].value==="}"&&e[i]===1)return i+1;return 0}function qk(n){for(let e=n.length-1;e>=0;e--)if(va(n[e].value))return n[e].value;return null}function yu(n){return n.map(e=>e.value).join("")}function va(n){return!!(n&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(n))}var dm=C(()=>{_u()});function yi(n,e){if(!n){let t=new Error(e||"shadertools: assertion failed.");throw Error.captureStackTrace?.(t,yi),t}}var xu=C(()=>{});function Hx(n){let e={};for(let[t,i]of Object.entries(n))e[t]=Zk(i);return e}function Zk(n){let e=jx(n);if(e!=="object")return{value:n,...hm[e],type:e};if(typeof n=="object")return n?n.type!==void 0?{...n,...hm[n.type],type:n.type}:n.value===void 0?{type:"object",value:n}:(e=jx(n.value),{...n,...hm[e],type:e}):{type:"object",value:null};throw new Error("props")}function jx(n){return Array.isArray(n)||ArrayBuffer.isView(n)?"array":typeof n}var hm,Yx=C(()=>{hm={number:{type:"number",validate(n,e){return Number.isFinite(n)&&typeof e=="object"&&(e.max===void 0||n<=e.max)&&(e.min===void 0||n>=e.min)}},array:{type:"array",validate(n,e){return Array.isArray(n)||ArrayBuffer.isView(n)}}}});var qx,Zx,Xx=C(()=>{qx=`#ifdef MODULE_LOGDEPTH logdepth_adjustPosition(gl_Position); #endif `,Zx=`#ifdef MODULE_MATERIAL @@ -23,22 +23,22 @@ #ifdef MODULE_LOGDEPTH logdepth_setFragDepth(); #endif -`});function Jx(n){let e={vertex:{},fragment:{}};for(let t in n){let i=n[t],r=qk(t);typeof i=="string"&&(i={order:0,injection:i}),e[r][t]=i}return e}function qk(n){let e=n.slice(0,2);switch(e){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(e)}}function wa(n,e,t,i=!1,r="glsl",s={}){let o=e==="vertex";for(let a in t){let c=t[a];c.sort((u,f)=>u.order-f.order),pm.length=c.length;for(let u=0,f=c.length;uu.order-f.order),pm.length=c.length;for(let u=0,f=c.length;uu+l));break;case"vs:#main-end":(r==="wgsl"||o)&&(n=r==="wgsl"?wu(n,"vertex",l,"end",s.vertex):n.replace(Qx,u=>l+u));break;case"fs:#decl":(r==="wgsl"||!o)&&(n=n.replace(xa,l));break;case"fs:#main-start":(r==="wgsl"||!o)&&(n=r==="wgsl"?wu(n,"fragment",l,"start",s.fragment):n.replace(Kx,u=>u+l));break;case"fs:#main-end":(r==="wgsl"||!o)&&(n=r==="wgsl"?wu(n,"fragment",l,"end",s.fragment):n.replace(Qx,u=>l+u));break;default:n=n.replace(a,u=>u+l)}}return n=n.replace(xa,""),i&&(n=n.replace(/\}\s*$/,a=>a+Yk[e])),n}function wu(n,e,t,i,r){let s=Zk(n,e,r);if(!s)return n;if(i==="start"){let o=s.openBraceIndex+1;return`${n.slice(0,o)} -${t}${n.slice(o)}`}return`${n.slice(0,s.closeBraceIndex)}${t}${n.slice(s.closeBraceIndex)}`}function Zk(n,e,t){let i=e==="vertex"?"@vertex":"@fragment",r=n.indexOf(i);if(r<0)return null;let s=t?n.search(new RegExp(`\\bfn\\s+${Xk(t)}\\s*\\(`)):n.indexOf("fn",r);if(s<0)return null;let o=n.indexOf("{",s);if(o<0)return null;let a=0;for(let c=o;c{Xx();Yk={vertex:qx,fragment:Zx},Kx=/void\s+main\s*\([^)]*\)\s*\{\n?/,Qx=/}\n?[^{}]*$/,pm=[],xa="__LUMA_INJECT_DECLARATIONS__"});function Gs(n){n.map(e=>Kk(e))}function Kk(n){if(n.instance)return;Gs(n.dependencies||[]);let{propTypes:e={},deprecations:t=[],inject:i={}}=n,r={normalizedInjections:Jx(i),parsedDeprecations:Qk(t)};e&&(r.propValidators=Hx(e)),n.instance=r;let s={};e&&(s=Object.entries(e).reduce((o,[a,c])=>{let l=c?.value;return l&&(o[a]=l),o},{})),n.defaultUniforms={...n.defaultUniforms,...s}}function gm(n,e,t){n.deprecations?.forEach(i=>{i.regex?.test(e)&&(i.deprecated?t.deprecated(i.old,i.new)():t.removed(i.old,i.new)())})}function Qk(n){return n.forEach(e=>{switch(e.type){case"function":e.regex=new RegExp(`\\b${e.old}\\(`);break;default:e.regex=new RegExp(`${e.type} ${e.old};`)}}),n}var Eu=C(()=>{Yx();mm()});function Cr(n){Gs(n);let e={},t={};e0({modules:n,level:0,moduleMap:e,moduleDepth:t});let i=Object.keys(t).sort((r,s)=>t[s]-t[r]).map(r=>e[r]);return Gs(i),i}function e0(n){let{modules:e,level:t,moduleMap:i,moduleDepth:r}=n;if(t>=5)throw new Error("Possible loop in shader dependency graph");for(let s of e)i[s.name]=s,(r[s.name]===void 0||r[s.name]{Eu()});var N,ut=C(()=>{sa();N=new ct({id:"luma.gl"})});function Jk(n,e){return n!=null?!!n:e!==void 0?e!=="production":!1}function eR(){return Jk(N.get("debug"),tR())}function tR(){let n=globalThis.process;if(n?.env)return n.env.NODE_ENV}var Su,ym=C(()=>{ut();Su={id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,featureLevel:void 0,optionalFeatures:[],xrCompatible:!1,createCanvasContext:void 0,webgl:{},onError:(n,e)=>{},onResize:(n,e)=>{let[t,i]=n.getDevicePixelSize();N.log(1,`${n} resized => ${t}x${i}px`)()},onPositionChange:(n,e)=>{let[t,i]=n.getPosition();N.log(1,`${n} repositioned => ${t},${i}`)()},onVisibilityChange:n=>N.log(1,`${n} Visibility changed ${n.isVisible}`)(),onDevicePixelRatioChange:(n,e)=>N.log(1,`${n} DPR changed ${e.oldRatio} => ${n.devicePixelRatio}`)(),debug:eR(),debugGPUTime:!1,debugShaders:N.get("debug-shaders")||void 0,debugFramebuffers:!!N.get("debug-framebuffers"),debugFactories:!!N.get("debug-factories"),debugWebGL:!!N.get("debug-webgl"),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0}});function rR(n,e){let t=n.stats,i=!1;for(let c of e)t[c]||(n.get(c),i=!0);let r=Object.keys(t).length,s=t0.get(n);if(!i&&s?.orderedStatNames===e&&s.statCount===r)return;let o={},a=n0.get(e);a||(a=new Set(e),n0.set(e,a));for(let c of e)t[c]&&(o[c]=t[c]);for(let[c,l]of Object.entries(t))a.has(c)||(o[c]=l);for(let c of Object.keys(t))delete t[c];Object.assign(t,o),t0.set(n,{orderedStatNames:e,statCount:r})}var nR,iR,t0,n0,bm,Pu,vm=C(()=>{ua();nR="GPU Time and Memory",iR=["Adapter","GPU","GPU Type","GPU Backend","Frame Rate","CPU Time","GPU Time","GPU Memory","Buffer Memory","Texture Memory","External Buffer Memory","External Texture Memory","Swap Chain Texture"],t0=new WeakMap,n0=new WeakMap,bm=class{stats=new Map;getStats(e){return this.get(e)}get(e){this.stats.has(e)||this.stats.set(e,new Yt({id:e}));let t=this.stats.get(e);return e===nR&&rR(t,iR),t}},Pu=new bm});var sR,i0,xm,Vs,r0=C(()=>{ym();vm();ut();sR="set luma.log.level=1 (or higher) to trace rendering",i0="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",xm=class n{static defaultProps={...Su,type:"best-available",adapters:void 0,waitForPageLoad:!0};stats=Pu;log=N;VERSION="9.4.2";spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw N.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),N.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");N.error("This version of luma.gl has already been initialized")()}N.log(1,`${this.VERSION} - ${sR}`)(),globalThis.luma=this}async createDevice(e={}){let t={...n.defaultProps,...e},i=this.selectAdapter(t.type,t.adapters);if(!i)throw new Error(i0);return t.waitForPageLoad&&await i.pageLoaded,await i.create(t)}async attachDevice(e,t){let i=this._getTypeFromHandle(e,t.adapters),r=i&&this.selectAdapter(i,t.adapters);if(!r)throw new Error(i0);return await r?.attach?.(e,t)}registerAdapters(e){for(let t of e)this.preregisteredAdapters.set(t.type,t)}getSupportedAdapters(e=[]){let t=this._getAdapterMap(e);return Array.from(t).map(([,i])=>i).filter(i=>i.isSupported?.()).map(i=>i.type)}getBestAvailableAdapterType(e=[]){let t=["webgpu","webgl","null"],i=this._getAdapterMap(e);for(let r of t)if(i.get(r)?.isSupported?.())return r;return null}selectAdapter(e,t=[]){let i=e;e==="best-available"&&(i=this.getBestAvailableAdapterType(t));let r=this._getAdapterMap(t);return i&&r.get(i)||null}enforceWebGL2(e=!0,t=[]){let r=this._getAdapterMap(t).get("webgl");r||N.warn("enforceWebGL2: webgl adapter not found")(),r?.enforceWebGL2?.(e)}setDefaultDeviceProps(e){Object.assign(n.defaultProps,e)}_getAdapterMap(e=[]){let t=new Map(this.preregisteredAdapters);for(let i of e)t.set(i.type,i);return t}_getTypeFromHandle(e,t=[]){return e instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&e instanceof GPUDevice||e?.queue?"webgpu":e===null?"null":(e instanceof WebGLRenderingContext?N.warn("WebGL1 is not supported",e)():N.warn("Unknown handle type",e)(),null)}},Vs=new xm});function cR(){return Cu||(aR()||typeof window>"u"?Cu=Promise.resolve():Cu=new Promise(n=>window.addEventListener("load",()=>n()))),Cu}var Ea,oR,aR,Cu,s0=C(()=>{vr();Ea=class{get pageLoaded(){return cR()}},oR=Tt()&&typeof document<"u",aR=()=>oR&&document.readyState==="complete",Cu=null});function zn(n="id"){wm[n]=wm[n]||1;let e=wm[n]++;return`${n}-${e}`}var wm,Ws=C(()=>{wm={}});function pR(n,e){let t={...e};for(let i in n)n[i]!==void 0&&(t[i]=n[i]);return t}function f0(n,e){let t=n.stats,i=!1;for(let c of e)t[c]||(n.get(c),i=!0);let r=Object.keys(t).length,s=l0.get(n);if(!i&&s?.orderedStatNames===e&&s.statCount===r)return;let o={},a=u0.get(e);a||(a=new Set(e),u0.set(e,a));for(let c of e)t[c]&&(o[c]=t[c]);for(let[c,l]of Object.entries(t))a.has(c)||(o[c]=l);for(let c of Object.keys(t))delete t[c];Object.assign(t,o),l0.set(n,{orderedStatNames:e,statCount:r})}function d0(n){return n.type==="webgl"?hR:dR}function Sa(n){let e=n.userData[lR];return e?.enabled?e:null}function $i(){return globalThis.performance?.now?.()??Date.now()}function mR(n,e){let t=Sa(n);if(!(!t||!t.activeDefaultFramebufferAcquireDepth))switch(t.transientCanvasResourceCreates=(t.transientCanvasResourceCreates||0)+1,e){case"Texture":t.transientCanvasTextureCreates=(t.transientCanvasTextureCreates||0)+1;break;case"TextureView":t.transientCanvasTextureViewCreates=(t.transientCanvasTextureViewCreates||0)+1;break;case"Sampler":t.transientCanvasSamplerCreates=(t.transientCanvasSamplerCreates||0)+1;break;case"Framebuffer":t.transientCanvasFramebufferCreates=(t.transientCanvasFramebufferCreates||0)+1;break;default:break}}function gR(n){let e=Object.getPrototypeOf(n);for(;e;){let t=Object.getPrototypeOf(e);if(!t||t===te.prototype)return _R(e)||n[Symbol.toStringTag]||n.constructor.name;e=t}return n[Symbol.toStringTag]||n.constructor.name}function _R(n){let e=Object.getOwnPropertyDescriptor(n,Symbol.toStringTag);return typeof e?.get=="function"?e.get.call(n):typeof e?.value=="string"?e.value:null}var lR,o0,a0,c0,uR,fR,dR,hR,l0,u0,te,He=C(()=>{Ws();lR="cpu-hotspot-profiler",o0="GPU Resource Counts",a0="Resource Counts",c0="GPU Time and Memory",uR=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","RenderBundleEncoders","RenderBundles","ComputePasss","CommandEncoders","CommandBuffers"],fR=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","SharedRenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","RenderBundleEncoders","RenderBundles","ComputePasss","CommandEncoders","CommandBuffers"],dR=uR.flatMap(n=>[`${n} Created`,`${n} Active`]),hR=fR.flatMap(n=>[`${n} Created`,`${n} Active`]),l0=new WeakMap,u0=new WeakMap,te=class{static defaultProps={id:"undefined",handle:void 0,_isHandleBorrowed:!1,userData:void 0};toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}toJSON(){return this.toString()}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;allocatedBytesName=null;_attachedResources=new Set;get ownsHandle(){return(this.props.handle===void 0||this.props.handle===null)&&!this.isHandleBorrowed}get isHandleBorrowed(){return!!this.props._isHandleBorrowed}constructor(e,t,i){if(!e)throw new Error("no device");this._device=e,this.props=pR(t,i);let r=this.props.id!=="undefined"?this.props.id:zn(this[Symbol.toStringTag]);this.props.id=r,this.id=r,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyed||this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of this._attachedResources)e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyed||(this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0)}removeStats(){let e=Sa(this._device),t=e?$i():0,i=[this._device.statsManager.getStats(o0),this._device.statsManager.getStats(a0)],r=d0(this._device);for(let o of i)f0(o,r);let s=this.getStatsName();for(let o of i)o.get("Resources Active").decrementCount(),o.get(`${s}s Active`).decrementCount();e&&(e.statsBookkeepingCalls=(e.statsBookkeepingCalls||0)+1,e.statsBookkeepingTimeMs=(e.statsBookkeepingTimeMs||0)+($i()-t))}trackAllocatedMemory(e,t=this.getStatsName()){let i=Sa(this._device),r=i?$i():0,s=this._device.statsManager.getStats(c0);this.allocatedBytes>0&&this.allocatedBytesName&&(s.get("GPU Memory").subtractCount(this.allocatedBytes),s.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes)),s.get("GPU Memory").addCount(e),s.get(`${t} Memory`).addCount(e),i&&(i.statsBookkeepingCalls=(i.statsBookkeepingCalls||0)+1,i.statsBookkeepingTimeMs=(i.statsBookkeepingTimeMs||0)+($i()-r)),this.allocatedBytes=e,this.allocatedBytesName=t}trackReferencedMemory(e,t=this.getStatsName()){this.trackAllocatedMemory(e,`External ${t}`)}trackDeallocatedMemory(e=this.getStatsName()){if(this.allocatedBytes===0){this.allocatedBytesName=null;return}let t=Sa(this._device),i=t?$i():0,r=this._device.statsManager.getStats(c0);r.get("GPU Memory").subtractCount(this.allocatedBytes),r.get(`${this.allocatedBytesName||e} Memory`).subtractCount(this.allocatedBytes),t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+($i()-i)),this.allocatedBytes=0,this.allocatedBytesName=null}trackDeallocatedReferencedMemory(e=this.getStatsName()){this.trackDeallocatedMemory(`Referenced ${e}`)}addStats(){let e=this.getStatsName(),t=Sa(this._device),i=t?$i():0,r=[this._device.statsManager.getStats(o0),this._device.statsManager.getStats(a0)],s=d0(this._device);for(let o of r)f0(o,s);for(let o of r)o.get("Resources Created").incrementCount(),o.get("Resources Active").incrementCount(),o.get(`${e}s Created`).incrementCount(),o.get(`${e}s Active`).incrementCount();t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+($i()-i)),mR(this._device,e)}getStatsName(){return gR(this)}}});var ie,Tu=C(()=>{He();ie=class n extends te{static INDEX=16;static VERTEX=32;static UNIFORM=64;static STORAGE=128;static INDIRECT=256;static QUERY_RESOLVE=512;static MAP_READ=1;static MAP_WRITE=2;static COPY_SRC=4;static COPY_DST=8;get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,t){let i={...t};(t.usage||0)&n.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?i.indexType="uint32":t.data instanceof Uint16Array?i.indexType="uint16":t.data instanceof Uint8Array&&(i.indexType="uint8")),delete i.data,super(e,i,n.defaultProps),this.usage=i.usage||0,this.indexType=i.indexType,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}static DEBUG_DATA_MAX_LENGTH=32;debugData=new ArrayBuffer(0);_setDebugData(e,t,i){if(!this.device.props.debug)return;let r=null,s;ArrayBuffer.isView(e)?(r=e,s=e.buffer):s=e;let o=Math.min(e?e.byteLength:i,n.DEBUG_DATA_MAX_LENGTH);if(s===null)this.debugData=new ArrayBuffer(o);else{let a=Math.min(r?.byteOffset||0,s.byteLength),c=Math.max(0,s.byteLength-a),l=Math.min(o,c);this.debugData=new Uint8Array(s,a,l).slice().buffer}}static defaultProps={...te.defaultProps,handle:void 0,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0}}});function h0(){return Em??Uint16Array}function p0(n){return!!(Em&&n===Em)}var Em,m0=C(()=>{Em=globalThis.Float16Array});function g0(n){let e=n.includes("norm"),t=!e&&!n.startsWith("float"),i=n.startsWith("s"),r=Sm[n],[s,o,a]=r||["uint8 ","i32",1];return{signedType:s,primitiveType:o,byteLength:a,normalized:e,integer:t,signed:i}}function _0(n){let e=n;switch(e){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return e}}function Zt(n,e){switch(e){case 1:return n;case 2:return n+n%2;default:return n+(4-n%4)%4}}function Lu(n){let e=ArrayBuffer.isView(n)?n.constructor:n;if(p0(e))return"float16";if(e===Uint8ClampedArray)return"uint8";let t=Object.values(Sm).find(i=>e===i[4]);if(!t)throw new Error(e.name);return t[0]}function y0(n){return Lu(n)}function Tr(n){if(n==="float16")return h0();let e=Sm[n];if(!e)throw new Error(n);let[,,,,t]=e;return t}function Lr(n){return Tr(n)}var Sm,Mu=C(()=>{m0();Sm={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]}});var Pm,Xe,Au=C(()=>{Mu();Pm=class{getDataTypeInfo(e){return g0(e)}getNormalizedDataType(e){return _0(e)}alignTo(e,t){return Zt(e,t)}getDataType(e){return y0(e)}getTypedArrayConstructor(e){return Lr(e)}},Xe=new Pm});function yR(n,e){try{return Xe.getDataTypeInfo(e)}catch{throw new Error(`Unsupported vertex format: ${n}`)}}function bR(n,e){if(!e)return 1;let t=Number(e);if(t===2||t===3||t===4)return t;throw new Error(`Unsupported vertex format: ${n}`)}function vR(n,e,t){if(t!==3)throw new Error(`Unsupported vertex format: ${n}`);switch(e){case"uint8":case"sint8":case"unorm8":case"snorm8":case"uint16":case"sint16":case"unorm16":case"snorm16":return`${e}x3-webgl`;default:throw new Error(`Unsupported vertex format: ${n}`)}}var Cm,Pe,Pa=C(()=>{Au();Cm=class{getVertexFormatInfo(e){if(e==="unorm10-10-10-2")return{type:"unorm8",components:4,byteLength:4,integer:!1,signed:!1,normalized:!0};let t=e==="unorm8x4-bgra"?"unorm8x4":e,i;t.endsWith("-webgl")&&(t=t.slice(0,-6),i=!0);let r=t.split("x");if(r.length>2)throw new Error(`Unsupported vertex format: ${e}`);let[s,o]=r,a=s,c=bR(e,o),l=yR(e,a),u;try{u=i?vR(e,a,c):this.makeVertexFormat(l.signedType,c,l.normalized)}catch{throw new Error(`Unsupported vertex format: ${e}`)}if(u!==(i?e:t))throw new Error(`Unsupported vertex format: ${e}`);let f={type:a,components:c,byteLength:l.byteLength*c,integer:l.integer,signed:l.signed,normalized:l.normalized};return i&&(f.webglOnly=!0),f}makeVertexFormat(e,t,i){let r=i?Xe.getNormalizedDataType(e):e;switch(r){case"unorm8":return t===1?"unorm8":t===3?"unorm8x3-webgl":`${r}x${t}`;case"snorm8":return t===1?"snorm8":t===3?"snorm8x3-webgl":`${r}x${t}`;case"uint8":case"sint8":if(t===3)throw new Error(`size: ${t}`);return t===1?r:`${r}x${t}`;case"uint16":return t===1?"uint16":t===3?"uint16x3-webgl":`${r}x${t}`;case"sint16":return t===1?"sint16":t===3?"sint16x3-webgl":`${r}x${t}`;case"unorm16":return t===1?"unorm16":t===3?"unorm16x3-webgl":`${r}x${t}`;case"snorm16":return t===1?"snorm16":t===3?"snorm16x3-webgl":`${r}x${t}`;case"float16":if(t===3)throw new Error(`size: ${t}`);return t===1?r:`${r}x${t}`;default:return t===1?r:`${r}x${t}`}}getVertexFormatFromAttribute(e,t,i){if(!t||t>4)throw new Error(`size ${t}`);let r=t,s=Xe.getDataType(e);return this.makeVertexFormat(s,r,i)}getCompatibleVertexFormat(e){let t;switch(e.primitiveType){case"f32":t="float32";break;case"i32":t="sint32";break;case"u32":t="uint32";break;case"f16":return e.components<=2?"float16x2":"float16x4"}return e.components===1?t:`${t}x${e.components}`}},Pe=new Cm});function Bu(n){let e=x0[n];if(!e)throw new Error(`Unsupported texture format ${n}`);return e}function v0(){return x0}var Qe,xe,Un,xR,ku,Tm,Ru,Lm,wR,Mm,Gi,Am,km,Iu,b0,ER,SR,x0,Rm=C(()=>{Qe="texture-compression-bc",xe="texture-compression-astc",Un="texture-compression-etc2",xR="texture-compression-etc1-webgl",ku="texture-compression-pvrtc-webgl",Tm="texture-compression-atc-webgl",Ru="float32-renderable-webgl",Lm="float16-renderable-webgl",wR="rgb9e5ufloat-renderable-webgl",Mm="snorm8-renderable-webgl",Gi="norm16-webgl",Am="norm16-renderable-webgl",km="snorm16-renderable-webgl",Iu="float32-filterable",b0="float16-filterable-webgl";ER={r8unorm:{webgpu:527},rg8unorm:{webgpu:527},"rgb8unorm-webgl":{},rgba8unorm:{webgpu:31},"rgba8unorm-srgb":{webgpu:15},r8snorm:{render:Mm,webgpu:837},rg8snorm:{render:Mm,webgpu:837},"rgb8snorm-webgl":{},rgba8snorm:{render:Mm,webgpu:341},r8uint:{webgpu:515},rg8uint:{webgpu:515},rgba8uint:{webgpu:19},r8sint:{webgpu:515},rg8sint:{webgpu:515},rgba8sint:{webgpu:19},bgra8unorm:{webgpu:15},"bgra8unorm-srgb":{webgpu:15360},r16unorm:{f:Gi,render:Am,webgpu:992},rg16unorm:{f:Gi,render:Am,webgpu:992},"rgb16unorm-webgl":{f:Gi,render:!1},rgba16unorm:{f:Gi,render:Am,webgpu:992},r16snorm:{f:Gi,render:km,webgpu:992},rg16snorm:{f:Gi,render:km,webgpu:992},"rgb16snorm-webgl":{f:Gi,render:!1},rgba16snorm:{f:Gi,render:km,webgpu:992},r16uint:{webgpu:515},rg16uint:{webgpu:515},rgba16uint:{webgpu:19},r16sint:{webgpu:515},rg16sint:{webgpu:515},rgba16sint:{webgpu:19},r16float:{render:Lm,filter:"float16-filterable-webgl",webgpu:527},rg16float:{render:Lm,filter:b0,webgpu:527},rgba16float:{render:Lm,filter:b0,webgpu:31},r32uint:{webgpu:19},rg32uint:{webgpu:16387},rgba32uint:{webgpu:19},r32sint:{webgpu:19},rg32sint:{webgpu:16387},rgba32sint:{webgpu:19},r32float:{render:Ru,filter:Iu,webgpu:19},rg32float:{render:!1,filter:Iu,webgpu:16387},"rgb32float-webgl":{render:Ru,filter:Iu},rgba32float:{render:Ru,filter:Iu,webgpu:19},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:wR,webgpu:5},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:Ru,webgpu:517},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:527},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:515},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8",webgpu:3},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16",webgpu:3},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32",webgpu:3},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32",webgpu:3},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0,webgpu:3},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0,f:"depth32float-stencil8",webgpu:3}},SR={"bc1-rgb-unorm-webgl":{f:Qe},"bc1-rgb-unorm-srgb-webgl":{f:Qe},"bc1-rgba-unorm":{f:Qe},"bc1-rgba-unorm-srgb":{f:Qe},"bc2-rgba-unorm":{f:Qe},"bc2-rgba-unorm-srgb":{f:Qe},"bc3-rgba-unorm":{f:Qe},"bc3-rgba-unorm-srgb":{f:Qe},"bc4-r-unorm":{f:Qe},"bc4-r-snorm":{f:Qe},"bc5-rg-unorm":{f:Qe},"bc5-rg-snorm":{f:Qe},"bc6h-rgb-ufloat":{f:Qe},"bc6h-rgb-float":{f:Qe},"bc7-rgba-unorm":{f:Qe},"bc7-rgba-unorm-srgb":{f:Qe},"etc2-rgb8unorm":{f:Un},"etc2-rgb8unorm-srgb":{f:Un},"etc2-rgb8a1unorm":{f:Un},"etc2-rgb8a1unorm-srgb":{f:Un},"etc2-rgba8unorm":{f:Un},"etc2-rgba8unorm-srgb":{f:Un},"eac-r11unorm":{f:Un},"eac-r11snorm":{f:Un},"eac-rg11unorm":{f:Un},"eac-rg11snorm":{f:Un},"astc-4x4-unorm":{f:xe},"astc-4x4-unorm-srgb":{f:xe},"astc-5x4-unorm":{f:xe},"astc-5x4-unorm-srgb":{f:xe},"astc-5x5-unorm":{f:xe},"astc-5x5-unorm-srgb":{f:xe},"astc-6x5-unorm":{f:xe},"astc-6x5-unorm-srgb":{f:xe},"astc-6x6-unorm":{f:xe},"astc-6x6-unorm-srgb":{f:xe},"astc-8x5-unorm":{f:xe},"astc-8x5-unorm-srgb":{f:xe},"astc-8x6-unorm":{f:xe},"astc-8x6-unorm-srgb":{f:xe},"astc-8x8-unorm":{f:xe},"astc-8x8-unorm-srgb":{f:xe},"astc-10x5-unorm":{f:xe},"astc-10x5-unorm-srgb":{f:xe},"astc-10x6-unorm":{f:xe},"astc-10x6-unorm-srgb":{f:xe},"astc-10x8-unorm":{f:xe},"astc-10x8-unorm-srgb":{f:xe},"astc-10x10-unorm":{f:xe},"astc-10x10-unorm-srgb":{f:xe},"astc-12x10-unorm":{f:xe},"astc-12x10-unorm-srgb":{f:xe},"astc-12x12-unorm":{f:xe},"astc-12x12-unorm-srgb":{f:xe},"pvrtc-rgb4unorm-webgl":{f:ku},"pvrtc-rgba4unorm-webgl":{f:ku},"pvrtc-rgb2unorm-webgl":{f:ku},"pvrtc-rgba2unorm-webgl":{f:ku},"etc1-rbg-unorm-webgl":{f:xR},"atc-rgb-unorm-webgl":{f:Tm},"atc-rgba-unorm-webgl":{f:Tm},"atc-rgbai-unorm-webgl":{f:Tm}},x0={...ER,...SR}});function AR({format:n,width:e,height:t,depth:i,byteAlignment:r}){let s=ft.getInfo(n),{bytesPerPixel:o,bytesPerBlock:a=o,blockWidth:c=1,blockHeight:l=1,compressed:u=!1}=s,f=u?Math.ceil(e/c):e,d=u?Math.ceil(t/l):t,h=f*a,p=Math.ceil(h/r)*r,m=d,g=p*m*i;return{bytesPerPixel:o,bytesPerRow:p,rowsPerImage:m,depthOrArrayLayers:i,bytesPerImage:p*m,byteLength:g}}function kR(n){let e=Bu(n),t={format:n,create:e.f??!0,render:e.render??!0,filter:e.filter??!0,blend:e.blend??!0,store:e.store??!0},i=w0(n),r=n.startsWith("depth")||n.startsWith("stencil"),s=i?.signed,o=i?.integer,a=i?.webgl,c=!!i?.compressed;return t.render&&=!r&&!c,t.filter&&=!r&&!s&&!o&&!a,t}function w0(n){let e=RR(n);if(ft.isCompressed(n)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0,e.bytesPerBlock=BR(n);let i=IR(n);i&&(e.blockWidth=i.blockWidth,e.blockHeight=i.blockHeight)}let t=e.packed?null:PR.exec(n);if(t){let[,i,r,s,o,a]=t,c=`${s}${r}`,l=Xe.getDataTypeInfo(c),u=l.byteLength*8,f=i?.length??1,d=[u,f>=2?u:0,f>=3?u:0,f>=4?u:0];e={format:n,attachment:e.attachment,dataType:l.signedType,components:f,channels:i,integer:l.integer,signed:l.signed,normalized:l.normalized,bitsPerChannel:d,bytesPerPixel:l.byteLength*f,packed:e.packed,srgb:e.srgb},a==="-webgl"&&(e.webgl=!0),o==="-srgb"&&(e.srgb=!0)}return n.endsWith("-webgl")&&(e.webgl=!0),n.endsWith("-srgb")&&(e.srgb=!0),e}function RR(n){let e={...Bu(n)},t=e.bytesPerPixel||1,i=e.bitsPerChannel||[8,8,8,8];return delete e.bitsPerChannel,delete e.bytesPerPixel,delete e.f,delete e.render,delete e.filter,delete e.blend,delete e.store,delete e.webgpu,{...e,format:n,attachment:e.attachment||"color",channels:e.channels||"r",components:e.components||e.channels?.length||1,bytesPerPixel:t,bitsPerChannel:i,dataType:e.dataType||"uint8",srgb:e.srgb??!1,packed:e.packed??!1,webgl:e.webgl??!1,integer:e.integer??!1,signed:e.signed??!1,normalized:e.normalized??!1,compressed:e.compressed??!1}}function IR(n){let t=/.*-(\d+)x(\d+)-.*/.exec(n);if(t){let[,i,r]=t;return{blockWidth:Number(i),blockHeight:Number(r)}}return n.startsWith("bc")||n.startsWith("etc1")||n.startsWith("etc2")||n.startsWith("eac")||n.startsWith("atc")?{blockWidth:4,blockHeight:4}:n.startsWith("pvrtc-rgb4")||n.startsWith("pvrtc-rgba4")?{blockWidth:4,blockHeight:4}:n.startsWith("pvrtc-rgb2")||n.startsWith("pvrtc-rgba2")?{blockWidth:8,blockHeight:4}:null}function BR(n){return n.startsWith("bc1")||n.startsWith("bc4")||n.startsWith("etc1")||n.startsWith("etc2-rgb8")||n.startsWith("etc2-rgb8a1")||n.startsWith("eac-r11")||n==="atc-rgb-unorm-webgl"?8:n.startsWith("bc2")||n.startsWith("bc3")||n.startsWith("bc5")||n.startsWith("bc6h")||n.startsWith("bc7")||n.startsWith("etc2-rgba8")||n.startsWith("eac-rg11")||n.startsWith("astc")||n==="atc-rgba-unorm-webgl"||n==="atc-rgbai-unorm-webgl"?16:n.startsWith("pvrtc")?8:16}var PR,CR,TR,LR,MR,Im,ft,Ou=C(()=>{Au();Rm();PR=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,CR=["rgb","rgba","bgra"],TR=["depth","stencil"],LR=5,MR=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],Im=class{isColor(e){return CR.some(t=>e.startsWith(t))}isDepthStencil(e){return TR.some(t=>e.startsWith(t))}isCompressed(e){return MR.some(t=>e.startsWith(t))}getInfo(e){return w0(e)}getCapabilities(e){return kR(e)}getWebGPUCapabilities(e){let t=Bu(e);return t.webgpu!==void 0?t.webgpu:this.isCompressed(e)&&!e.endsWith("-webgl")?LR:0}computeMemoryLayout(e){return AR(e)}},ft=new Im});function E0(n){return typeof ImageData<"u"&&n instanceof ImageData||typeof ImageBitmap<"u"&&n instanceof ImageBitmap||typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement||typeof VideoFrame<"u"&&n instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas}function S0(n){if(typeof ImageData<"u"&&n instanceof ImageData||typeof ImageBitmap<"u"&&n instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas)return{width:n.width,height:n.height};if(typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement)return{width:n.naturalWidth,height:n.naturalHeight};if(typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement)return{width:n.videoWidth,height:n.videoHeight};if(typeof VideoFrame<"u"&&n instanceof VideoFrame)return{width:n.displayWidth,height:n.displayHeight};throw new Error("Unknown image type")}var P0=C(()=>{});function OR(n,e){let t=Bm(n),i=e.map(Bm).filter(r=>r!==void 0);return[t,...i].filter(r=>r!==void 0)}function Bm(n){if(n!==void 0){if(n===null||typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n;if(n instanceof Error)return n.message;if(Array.isArray(n))return n.map(Bm);if(typeof n=="object"){if(DR(n)){let e=String(n);if(e!=="[object Object]")return e}return NR(n)?FR(n):n.constructor?.name||"Object"}return String(n)}}function DR(n){return"toString"in n&&typeof n.toString=="function"&&n.toString!==Object.prototype.toString}function NR(n){return"message"in n&&"type"in n}function FR(n){let e=typeof n.type=="string"?n.type:"message",t=typeof n.message=="string"?n.message:"",i=typeof n.lineNum=="number"?n.lineNum:null,r=typeof n.linePos=="number"?n.linePos:null,s=i!==null&&r!==null?` @ ${i}:${r}`:i!==null?` @ ${i}`:"";return`${e}${s}: ${t}`.trim()}function Om(){if(typeof HTMLCanvasElement>"u")return!1;let n=HTMLCanvasElement.prototype;return"layoutSubtree"in n&&typeof n.requestPaint=="function"}var Ca,Ta,bi,C0=C(()=>{vm();ut();Ws();Tu();Pa();Ou();P0();Rm();ym();Ca=class{};Ta=class{features;disabledFeatures;constructor(e=[],t){this.features=new Set(e),this.disabledFeatures=t||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures?.[e]&&this.features.has(e)}};bi=class n{static defaultProps={...Su};get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}toJSON(){return this.toString()}id;props;userData={};statsManager=Pu;_factories={};timestamp=0;_reused=!1;_moduleData={};wgslLanguageFeatures=new Set;_textureCaps={};_debugGPUTimeQuery=null;constructor(e){this.props={...n.defaultProps,...e},this.id=this.props.id||zn(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(e){return Pe.getVertexFormatInfo(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return ft.getInfo(e)}getTextureFormatCapabilities(e){let t=this._textureCaps[e];if(!t){let i=this._getDeviceTextureFormatCapabilities(e);t=this._getDeviceSpecificTextureFormatCapabilities(i),this._textureCaps[e]=t}return t}getMipLevelCount(e,t,i=1){let r=Math.max(e,t,i);return 1+Math.floor(Math.log2(r))}isExternalImage(e){return E0(e)}getExternalImageSize(e){return S0(e)}isTextureFormatSupported(e){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return ft.isCompressed(e)}getSupportedCompressedTextureFormats(){let e=[];for(let t of Object.keys(v0()))this.isTextureFormatCompressed(t)&&this.isTextureFormatSupported(t)&&e.push(t);return e}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){this.commandEncoder?.popDebugGroup()}insertDebugMarker(e){this.commandEncoder?.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,t,...i){if(!this.props.onError(e,t)){let s=OR(t,i);return N.error(this.type==="webgl"?"%cWebGL":"%cWebGPU","color: white; background: red; padding: 2px 6px; border-radius: 3px;",e.message,...s)}return()=>{}}debug(){if(this.props.debug)debugger;else{let e=`'Type luma.log.set({debug: true}) in console to enable debug breakpoints', -or create a device with the 'debug: true' prop.`;N.once(0,e)()}}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}createFence(){throw new Error("createFence() not implemented")}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}writeBufferViaCommandEncoder(e,t,i,r=0){throw new Error("writeBufferViaCommandEncoder() not implemented")}generateMipmapsWebGPU(e){throw new Error("not implemented")}_createSharedRenderPipelineWebGL(e){throw new Error("_createSharedRenderPipelineWebGL() not implemented")}_createBindGroupLayoutWebGPU(e,t){throw new Error("_createBindGroupLayoutWebGPU() not implemented")}_createBindGroupWebGPU(e,t,i,r,s){throw new Error("_createBindGroupWebGPU() not implemented")}_supportsDebugGPUTime(){return this.features.has("timestamp-query")&&!!(this.props.debug||this.props.debugGPUTime)}_enableDebugGPUTime(e=256){if(!this._supportsDebugGPUTime())return null;if(this._debugGPUTimeQuery)return this._debugGPUTimeQuery;try{this._debugGPUTimeQuery=this.createQuerySet({type:"timestamp",count:e}),this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id,timeProfilingQuerySet:this._debugGPUTimeQuery})}catch{this._debugGPUTimeQuery=null}return this._debugGPUTimeQuery}_disableDebugGPUTime(){this._debugGPUTimeQuery&&(this.commandEncoder.getTimeProfilingQuerySet()===this._debugGPUTimeQuery&&(this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id})),this._debugGPUTimeQuery.destroy(),this._debugGPUTimeQuery=null)}_isDebugGPUTimeEnabled(){return this._debugGPUTimeQuery!==null}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}getModuleData(e){return this._moduleData[e]||={},this._moduleData[e]}static _getCanvasContextProps(e){return e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){let t=ft.getCapabilities(e),i=s=>(typeof s=="string"?this.features.has(s):s)??!0,r=i(t.create);return{format:e,create:r,render:r&&i(t.render),filter:r&&i(t.filter),blend:r&&i(t.blend),store:r&&i(t.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let t={...e};if((e.usage||0)&ie.INDEX&&(e.indexType||(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array?t.indexType="uint16":e.data instanceof Uint8Array&&(t.data=new Uint16Array(e.data),t.indexType="uint16")),!t.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return t}}});var Du,T0=C(()=>{Du=class{props;_resizeObserver;_intersectionObserver;_observeDevicePixelRatioTimeout=null;_observeDevicePixelRatioMediaQuery=null;_handleDevicePixelRatioChange=()=>this._refreshDevicePixelRatio();_trackPositionInterval=null;_started=!1;get started(){return this._started}constructor(e){this.props=e}start(){if(this._started||!this.props.canvas)return;this._started=!0,this._intersectionObserver||=new IntersectionObserver(t=>this.props.onIntersection(t)),this._resizeObserver||=new ResizeObserver(t=>this.props.onResize(t)),this._intersectionObserver.observe(this.props.canvas);let e=this.props.resizeObserverBox;try{this._resizeObserver.observe(this.props.canvas,{box:e})}catch{this._resizeObserver.observe(this.props.canvas,{box:"content-box"})}this._observeDevicePixelRatioTimeout=setTimeout(()=>this._refreshDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}stop(){this._started&&(this._started=!1,this._observeDevicePixelRatioTimeout&&(clearTimeout(this._observeDevicePixelRatioTimeout),this._observeDevicePixelRatioTimeout=null),this._observeDevicePixelRatioMediaQuery&&(this._observeDevicePixelRatioMediaQuery.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=null),this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null),this._resizeObserver?.disconnect(),this._intersectionObserver?.disconnect())}_refreshDevicePixelRatio(){this._started&&(this.props.onDevicePixelRatioChange(),this._observeDevicePixelRatioMediaQuery?.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._observeDevicePixelRatioMediaQuery.addEventListener("change",this._handleDevicePixelRatioChange,{once:!0}))}_trackPosition(e=100){this._trackPositionInterval||(this._trackPositionInterval=setInterval(()=>{this._started?this.props.onPositionChange():this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null)},e))}}});function L0(){let n,e;return{promise:new Promise((i,r)=>{n=i,e=r}),resolve:n,reject:e}}var M0=C(()=>{});function Vi(n,e){if(!n){let t=new Error(e??"luma.gl assertion failed.");throw Error.captureStackTrace?.(t,Vi),t}}function Wi(n,e){return Vi(n,e),n}var Dm=C(()=>{});function zR(n){if(typeof n=="string"){let e=document.getElementById(n);if(!e)throw new Error(`${n} is not an HTML element`);return e}return n||document.body}function UR(n){let e=document.getElementById(n);if(!ji.isHTMLCanvas(e))throw new Error("Object is not a canvas element");return e}function $R(n){let{width:e,height:t}=n,i=document.createElement("canvas");i.id=zn("lumagl-auto-created-canvas"),i.width=e||1,i.height=t||1,i.style.width=Number.isFinite(e)?`${e}px`:"100%",i.style.height=Number.isFinite(t)?`${t}px`:"100%",n?.visible||(i.style.visibility="hidden");let r=zR(n?.container||null);return r.insertBefore(i,r.firstChild),i}function GR(n,e,t,i,r){let s=n,o=A0(s[0],e,t),a=k0(s[1],e,i,r),c=A0(s[0]+1,e,t),l=c===t-1?c:c-1;c=k0(s[1]+1,e,i,r);let u;return r?(c=c===0?c:c+1,u=a,a=c):u=c===i-1?c:c-1,{x:o,y:a,width:Math.max(l-o+1,1),height:Math.max(u-a+1,1)}}function A0(n,e,t){return Math.min(Math.round(n*e),t-1)}function k0(n,e,t,i){return i?Math.max(0,t-1-Math.round(n*e)):Math.min(Math.round(n*e),t-1)}var ji,Nm=C(()=>{vr();T0();Ws();M0();Dm();ji=class n{static isHTMLCanvas(e){return typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}static defaultProps={id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,pixelSizeSource:"exact",autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",colorFormat:void 0,toneMapping:"standard",trackPosition:!1};id;props;canvas;htmlCanvas;offscreenCanvas;type;initialized;isInitialized=!1;isVisible=!0;cssWidth;cssHeight;devicePixelRatio;devicePixelWidth;devicePixelHeight;drawingBufferWidth;drawingBufferHeight;_initializedResolvers=L0();_canvasObserver;_position=[0,0];destroyed=!1;_needsDrawingBufferResize=!0;_configuredDrawingBufferSize=[0,0];toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(e){this.props={...n.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,Tt()?e.canvas?typeof e.canvas=="string"?this.canvas=UR(e.canvas):this.canvas=e.canvas:this.canvas=$R(e):this.canvas={width:e.width||1,height:e.height||1},n.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):n.isOffscreenCanvas(this.canvas)?(this.id=e.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=e.id||"node-canvas-context",this.type="node"),this.cssWidth=this.htmlCanvas?.clientWidth||this.canvas.width,this.cssHeight=this.htmlCanvas?.clientHeight||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this._configuredDrawingBufferSize=[this.canvas.width,this.canvas.height],this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],this._canvasObserver=new Du({canvas:this.htmlCanvas,trackPosition:this.props.trackPosition,resizeObserverBox:this.props.pixelSizeSource==="css-dpr"?"content-box":"device-pixel-content-box",onResize:t=>this._handleResize(t),onIntersection:t=>this._handleIntersection(t),onDevicePixelRatioChange:()=>this._observeDevicePixelRatio(),onPositionChange:()=>this.updatePosition()})}destroy(){this.destroyed||(this.destroyed=!0,this._stopObservers(),this.device=null)}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCurrentFramebuffer(e){return this._resizeDrawingBufferIfNeeded(),this._getCurrentFramebuffer(e)}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){let e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,t){e=Math.floor(e),t=Math.floor(t),!(this.drawingBufferWidth===e&&this.drawingBufferHeight===t)&&(this.drawingBufferWidth=e,this.drawingBufferHeight=t,this._needsDrawingBufferResize=!0)}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(e,t=!0){let i=this.cssToDeviceRatio(),[r,s]=this.getDrawingBufferSize();return GR(e,i,r,s,t)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){let[e,t]=this.getDrawingBufferSize();return e>0&&t>0?e/t:1}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),[t]=this.getCSSSize();return t?e/t:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}_startObservers(){this.destroyed||this._canvasObserver.start()}_stopObservers(){this._canvasObserver.stop()}_handleIntersection(e){if(this.destroyed)return;let t=e.find(r=>r.target===this.canvas);if(!t)return;let i=t.isIntersecting;this.isVisible!==i&&(this.isVisible=i,this.device.props.onVisibilityChange(this))}_handleResize(e){if(this.destroyed)return;let t=e.find(s=>s.target===this.canvas);if(!t)return;let i=Wi(t.contentBoxSize?.[0]);this.cssWidth=i.inlineSize,this.cssHeight=i.blockSize;let r=this.getDevicePixelSize();this._setDevicePixelSize(this._getDevicePixelSizeFromResizeEntry(t)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:r})}_updateDrawingBufferSize(){if(this.props.autoResize)if(typeof this.props.useDevicePixels=="number"){let e=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*e,this.cssHeight*e)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_getDevicePixelSizeFromResizeEntry(e){let t=Wi(e.contentBoxSize?.[0]);return this.props.pixelSizeSource==="css-dpr"?this._getDevicePixelSizeFromCSSSize(t.inlineSize,t.blockSize):{devicePixelWidth:e.devicePixelContentBoxSize?.[0]?.inlineSize||t.inlineSize*devicePixelRatio,devicePixelHeight:e.devicePixelContentBoxSize?.[0]?.blockSize||t.blockSize*devicePixelRatio}}_getDevicePixelSizeFromCSSSize(e,t){let i=this.getDevicePixelRatio();return{devicePixelWidth:Math.floor(e*i),devicePixelHeight:Math.floor(t*i)}}_setDevicePixelSize({devicePixelWidth:e,devicePixelHeight:t}){let[i,r]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(e,i)),this.devicePixelHeight=Math.max(1,Math.min(t,r))}_resizeDrawingBufferIfNeeded(){if(this._needsDrawingBufferResize){this._needsDrawingBufferResize=!1,(this.drawingBufferWidth!==this.canvas.width||this.drawingBufferHeight!==this.canvas.height)&&(this.canvas.width=this.drawingBufferWidth,this.canvas.height=this.drawingBufferHeight);let[t,i]=this._configuredDrawingBufferSize;(this.drawingBufferWidth!==t||this.drawingBufferHeight!==i)&&(this._configureDevice(),this._configuredDrawingBufferSize=[this.drawingBufferWidth,this.drawingBufferHeight])}}_observeDevicePixelRatio(){if(this.destroyed||!this._canvasObserver.started)return;let e=this.devicePixelRatio;if(this.devicePixelRatio=window.devicePixelRatio,this.props.pixelSizeSource==="css-dpr"){let t=this.getDevicePixelSize();this._setDevicePixelSize(this._getDevicePixelSizeFromCSSSize(this.cssWidth,this.cssHeight)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:t})}this.updatePosition(),this.device.props.onDevicePixelRatioChange?.(this,{oldRatio:e})}updatePosition(){if(this.destroyed)return;let e=this.htmlCanvas?.getBoundingClientRect();if(e){let t=[e.left,e.top];if(this._position??=t,t[0]!==this._position[0]||t[1]!==this._position[1]){let r=this._position;this._position=t,this.device.props.onPositionChange?.(this,{oldPosition:r})}}}}});var La,R0=C(()=>{Nm();La=class extends ji{static defaultProps=ji.defaultProps}});var Ma,I0=C(()=>{Nm();Ma=class extends ji{}});var Mr,Fm=C(()=>{He();Mr=class n extends te{static defaultProps={...te.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1};get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){t=n.normalizeProps(e,t),super(e,t,n.defaultProps)}static normalizeProps(e,t){return t}}});var VR,me,zm=C(()=>{He();Fm();ut();Ou();VR={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},me=class n extends te{static SAMPLE=4;static STORAGE=8;static RENDER=16;static COPY_SRC=1;static COPY_DST=2;static TEXTURE=4;static RENDER_ATTACHMENT=16;dimension;baseDimension;format;width;height;depth;mipLevels;samples;byteAlignment;ready=Promise.resolve(this);isReady=!0;updateTimestamp;get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(e,t,i){if(t=n.normalizeProps(e,t),super(e,t,n.defaultProps),this.dimension=this.props.dimension,this.baseDimension=VR[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.samples=this.props.samples||1,this.dimension==="cube"&&(this.depth=6),this.props.width===void 0||this.props.height===void 0)if(e.isExternalImage(t.data)){let r=e.getExternalImageSize(t.data);this.width=r?.width||1,this.height=r?.height||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&N.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=i?.byteAlignment||1,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createTexture({...this.props,...e})}setSampler(e){this.sampler=e instanceof Mr?e:this.device.createSampler(e)}copyImageData(e){let{data:t,depth:i,...r}=e;this.writeData(t,{...r,depthOrArrayLayers:r.depthOrArrayLayers??i})}computeMemoryLayout(e={}){let t=this._normalizeTextureReadOptions(e),{width:i=this.width,height:r=this.height,depthOrArrayLayers:s=this.depth}=t,{format:o,byteAlignment:a}=this;return ft.computeMemoryLayout({format:o,width:i,height:r,depth:s,byteAlignment:a})}readBuffer(e,t){throw new Error("readBuffer not implemented")}readDataAsync(e){throw new Error("readBuffer not implemented")}writeBuffer(e,t){throw new Error("readBuffer not implemented")}writeData(e,t){throw new Error("readBuffer not implemented")}readDataSyncWebGL(e){throw new Error("readDataSyncWebGL not available")}generateMipmapsWebGL(){throw new Error("generateMipmapsWebGL not available")}static normalizeProps(e,t){let i={...t},{width:r,height:s}=i;return typeof r=="number"&&(i.width=Math.max(1,Math.ceil(r))),typeof s=="number"&&(i.height=Math.max(1,Math.ceil(s))),i}_initializeData(e){this.device.isExternalImage(e)?this.copyExternalImage({image:e,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):e&&this.copyImageData({data:e,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(e){let{data:t,depth:i,...r}=e,s=this._normalizeTextureWriteOptions({...r,depthOrArrayLayers:r.depthOrArrayLayers??i});return{data:t,depth:s.depthOrArrayLayers,...s}}_normalizeCopyExternalImageOptions(e){let t=n._omitUndefined(e),i=t.mipLevel??0,r=this._getMipLevelSize(i),s=this.device.getExternalImageSize(e.image),o={...n.defaultCopyExternalImageOptions,...r,...s,...t};return o.width=Math.min(o.width,r.width-o.x),o.height=Math.min(o.height,r.height-o.y),o.depth=Math.min(o.depth,r.depthOrArrayLayers-o.z),o}_normalizeCopyElementImageOptions(e){let t=n._omitUndefined(e),i=t.mipLevel??0,r=this._getMipLevelSize(i),s={...n.defaultCopyElementImageOptions,...r,...t};return s.width=Math.min(s.width,r.width-s.x),s.height=Math.min(s.height,r.height-s.y),s.depth=Math.min(s.depth,r.depthOrArrayLayers-s.z),s}_normalizeTextureReadOptions(e){let t=n._omitUndefined(e),i=t.mipLevel??0,r=this._getMipLevelSize(i),s={...n.defaultTextureReadOptions,...r,...t};return s.width=Math.min(s.width,r.width-s.x),s.height=Math.min(s.height,r.height-s.y),s.depthOrArrayLayers=Math.min(s.depthOrArrayLayers,r.depthOrArrayLayers-s.z),s}_getSupportedColorReadOptions(e){let t=this._normalizeTextureReadOptions(e),i=ft.getInfo(this.format);switch(this._validateColorReadAspect(t),this._validateColorReadFormat(i),this.dimension){case"2d":case"cube":case"cube-array":case"2d-array":case"3d":return t;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}}_validateColorReadAspect(e){if(e.aspect!=="all")throw new Error(`${this} color readback only supports aspect 'all'`)}_validateColorReadFormat(e){if(e.compressed)throw new Error(`${this} color readback does not support compressed formats (${this.format})`);switch(e.attachment){case"color":return;case"depth":throw new Error(`${this} color readback does not support depth formats (${this.format})`);case"stencil":throw new Error(`${this} color readback does not support stencil formats (${this.format})`);case"depth-stencil":throw new Error(`${this} color readback does not support depth-stencil formats (${this.format})`);default:throw new Error(`${this} color readback does not support format ${this.format}`)}}_normalizeTextureWriteOptions(e){let t=n._omitUndefined(e),i=t.mipLevel??0,r=this._getMipLevelSize(i),s={...n.defaultTextureWriteOptions,...r,...t};s.width=Math.min(s.width,r.width-s.x),s.height=Math.min(s.height,r.height-s.y),s.depthOrArrayLayers=Math.min(s.depthOrArrayLayers,r.depthOrArrayLayers-s.z);let o=ft.computeMemoryLayout({format:this.format,width:s.width,height:s.height,depth:s.depthOrArrayLayers,byteAlignment:this.byteAlignment}),a=o.bytesPerPixel*s.width;if(s.bytesPerRow=t.bytesPerRow??o.bytesPerRow,s.rowsPerImage=t.rowsPerImage??s.height,s.bytesPerRow>e),i=this.baseDimension==="1d"?1:Math.max(1,this.height>>e),r=this.dimension==="3d"?Math.max(1,this.depth>>e):this.depth;return{width:t,height:i,depthOrArrayLayers:r}}getAllocatedByteLength(){let e=0;for(let t=0;tt!==void 0))}static defaultProps={...te.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:n.SAMPLE|n.RENDER|n.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0};static defaultCopyDataOptions={data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,width:void 0,height:void 0,depthOrArrayLayers:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all"};static defaultCopyExternalImageOptions={image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultCopyElementImageOptions={element:void 0,width:void 0,height:void 0,sourceX:0,sourceY:0,sourceWidth:void 0,sourceHeight:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultTextureReadOptions={x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"};static defaultTextureWriteOptions={byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"}}});var Ar,B0=C(()=>{He();Ar=class n extends te{get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,n.defaultProps)}static defaultProps={...te.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0}}});var Aa,O0=C(()=>{He();Aa=class n extends te{width;height;updateTimestamp;get[Symbol.toStringTag](){return"ExternalTexture"}constructor(e,t){super(e,t,n.defaultProps);let i=this.props.source?e.getExternalImageSize(this.props.source):null;this.width=this.props.width||i?.width||0,this.height=this.props.height||i?.height||0,this.updateTimestamp=e.incrementTimestamp()}static defaultProps={...te.defaultProps,source:void 0,width:0,height:0,colorSpace:"srgb",sampler:{}}}});function D0(n,e,t){let i="",r=e.split(/\r?\n/),s=n.slice().sort((o,a)=>o.lineNum-a.lineNum);switch(t?.showSourceCode||"no"){case"all":let o=0;for(let a=1;a<=r.length;a++){let c=r[a-1],l=s[o];for(c&&l&&(i+=N0(c,a,t));s.length>o&&l.lineNum===a;){let u=s[o++];u&&(i+=Um(u,r,u.lineNum,{...t,inlineSource:!1}))}}for(;s.length>o;){let a=s[o++];a&&(i+=Um(a,[],0,{...t,inlineSource:!1}))}return i;case"issues":case"no":for(let a of n)i+=Um(a,r,a.lineNum,{inlineSource:t?.showSourceCode!=="no"});return i}}function Um(n,e,t,i){if(i?.inlineSource){let s=WR(e,t),o=n.linePos>0?`${" ".repeat(n.linePos+5)}^^^ +`;switch(a){case"vs:#decl":(r==="wgsl"||o)&&(n=n.replace(xa,l));break;case"vs:#main-start":(r==="wgsl"||o)&&(n=r==="wgsl"?wu(n,"vertex",l,"start",s.vertex):n.replace(Kx,u=>u+l));break;case"vs:#main-end":(r==="wgsl"||o)&&(n=r==="wgsl"?wu(n,"vertex",l,"end",s.vertex):n.replace(Qx,u=>l+u));break;case"fs:#decl":(r==="wgsl"||!o)&&(n=n.replace(xa,l));break;case"fs:#main-start":(r==="wgsl"||!o)&&(n=r==="wgsl"?wu(n,"fragment",l,"start",s.fragment):n.replace(Kx,u=>u+l));break;case"fs:#main-end":(r==="wgsl"||!o)&&(n=r==="wgsl"?wu(n,"fragment",l,"end",s.fragment):n.replace(Qx,u=>l+u));break;default:n=n.replace(a,u=>u+l)}}return n=n.replace(xa,""),i&&(n=n.replace(/\}\s*$/,a=>a+Xk[e])),n}function wu(n,e,t,i,r){let s=Qk(n,e,r);if(!s)return n;if(i==="start"){let o=s.openBraceIndex+1;return`${n.slice(0,o)} +${t}${n.slice(o)}`}return`${n.slice(0,s.closeBraceIndex)}${t}${n.slice(s.closeBraceIndex)}`}function Qk(n,e,t){let i=e==="vertex"?"@vertex":"@fragment",r=n.indexOf(i);if(r<0)return null;let s=t?n.search(new RegExp(`\\bfn\\s+${Jk(t)}\\s*\\(`)):n.indexOf("fn",r);if(s<0)return null;let o=n.indexOf("{",s);if(o<0)return null;let a=0;for(let c=o;c{Xx();Xk={vertex:qx,fragment:Zx},Kx=/void\s+main\s*\([^)]*\)\s*\{\n?/,Qx=/}\n?[^{}]*$/,pm=[],xa="__LUMA_INJECT_DECLARATIONS__"});function Gs(n){n.map(e=>eR(e))}function eR(n){if(n.instance)return;Gs(n.dependencies||[]);let{propTypes:e={},deprecations:t=[],inject:i={}}=n,r={normalizedInjections:Jx(i),parsedDeprecations:tR(t)};e&&(r.propValidators=Hx(e)),n.instance=r;let s={};e&&(s=Object.entries(e).reduce((o,[a,c])=>{let l=c?.value;return l&&(o[a]=l),o},{})),n.defaultUniforms={...n.defaultUniforms,...s}}function gm(n,e,t){n.deprecations?.forEach(i=>{i.regex?.test(e)&&(i.deprecated?t.deprecated(i.old,i.new)():t.removed(i.old,i.new)())})}function tR(n){return n.forEach(e=>{switch(e.type){case"function":e.regex=new RegExp(`\\b${e.old}\\(`);break;default:e.regex=new RegExp(`${e.type} ${e.old};`)}}),n}var Eu=C(()=>{Yx();mm()});function Cr(n){Gs(n);let e={},t={};e0({modules:n,level:0,moduleMap:e,moduleDepth:t});let i=Object.keys(t).sort((r,s)=>t[s]-t[r]).map(r=>e[r]);return Gs(i),i}function e0(n){let{modules:e,level:t,moduleMap:i,moduleDepth:r}=n;if(t>=5)throw new Error("Possible loop in shader dependency graph");for(let s of e)i[s.name]=s,(r[s.name]===void 0||r[s.name]{Eu()});var N,ut=C(()=>{sa();N=new ct({id:"luma.gl"})});function nR(n,e){return n!=null?!!n:e!==void 0?e!=="production":!1}function iR(){return nR(N.get("debug"),rR())}function rR(){let n=globalThis.process;if(n?.env)return n.env.NODE_ENV}var Su,ym=C(()=>{ut();Su={id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,featureLevel:void 0,optionalFeatures:[],xrCompatible:!1,createCanvasContext:void 0,webgl:{},onError:(n,e)=>{},onResize:(n,e)=>{let[t,i]=n.getDevicePixelSize();N.log(1,`${n} resized => ${t}x${i}px`)()},onPositionChange:(n,e)=>{let[t,i]=n.getPosition();N.log(1,`${n} repositioned => ${t},${i}`)()},onVisibilityChange:n=>N.log(1,`${n} Visibility changed ${n.isVisible}`)(),onDevicePixelRatioChange:(n,e)=>N.log(1,`${n} DPR changed ${e.oldRatio} => ${n.devicePixelRatio}`)(),debug:iR(),debugGPUTime:!1,debugShaders:N.get("debug-shaders")||void 0,debugFramebuffers:!!N.get("debug-framebuffers"),debugFactories:!!N.get("debug-factories"),debugWebGL:!!N.get("debug-webgl"),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0}});function aR(n,e){let t=n.stats,i=!1;for(let c of e)t[c]||(n.get(c),i=!0);let r=Object.keys(t).length,s=t0.get(n);if(!i&&s?.orderedStatNames===e&&s.statCount===r)return;let o={},a=n0.get(e);a||(a=new Set(e),n0.set(e,a));for(let c of e)t[c]&&(o[c]=t[c]);for(let[c,l]of Object.entries(t))a.has(c)||(o[c]=l);for(let c of Object.keys(t))delete t[c];Object.assign(t,o),t0.set(n,{orderedStatNames:e,statCount:r})}var sR,oR,t0,n0,bm,Pu,vm=C(()=>{ua();sR="GPU Time and Memory",oR=["Adapter","GPU","GPU Type","GPU Backend","Frame Rate","CPU Time","GPU Time","GPU Memory","Buffer Memory","Texture Memory","External Buffer Memory","External Texture Memory","Swap Chain Texture"],t0=new WeakMap,n0=new WeakMap,bm=class{stats=new Map;getStats(e){return this.get(e)}get(e){this.stats.has(e)||this.stats.set(e,new Ht({id:e}));let t=this.stats.get(e);return e===sR&&aR(t,oR),t}},Pu=new bm});var cR,i0,xm,Vs,r0=C(()=>{ym();vm();ut();cR="set luma.log.level=1 (or higher) to trace rendering",i0="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",xm=class n{static defaultProps={...Su,type:"best-available",adapters:void 0,waitForPageLoad:!0};stats=Pu;log=N;VERSION="9.4.2";spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw N.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),N.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");N.error("This version of luma.gl has already been initialized")()}N.log(1,`${this.VERSION} - ${cR}`)(),globalThis.luma=this}async createDevice(e={}){let t={...n.defaultProps,...e},i=this.selectAdapter(t.type,t.adapters);if(!i)throw new Error(i0);return t.waitForPageLoad&&await i.pageLoaded,await i.create(t)}async attachDevice(e,t){let i=this._getTypeFromHandle(e,t.adapters),r=i&&this.selectAdapter(i,t.adapters);if(!r)throw new Error(i0);return await r?.attach?.(e,t)}registerAdapters(e){for(let t of e)this.preregisteredAdapters.set(t.type,t)}getSupportedAdapters(e=[]){let t=this._getAdapterMap(e);return Array.from(t).map(([,i])=>i).filter(i=>i.isSupported?.()).map(i=>i.type)}getBestAvailableAdapterType(e=[]){let t=["webgpu","webgl","null"],i=this._getAdapterMap(e);for(let r of t)if(i.get(r)?.isSupported?.())return r;return null}selectAdapter(e,t=[]){let i=e;e==="best-available"&&(i=this.getBestAvailableAdapterType(t));let r=this._getAdapterMap(t);return i&&r.get(i)||null}enforceWebGL2(e=!0,t=[]){let r=this._getAdapterMap(t).get("webgl");r||N.warn("enforceWebGL2: webgl adapter not found")(),r?.enforceWebGL2?.(e)}setDefaultDeviceProps(e){Object.assign(n.defaultProps,e)}_getAdapterMap(e=[]){let t=new Map(this.preregisteredAdapters);for(let i of e)t.set(i.type,i);return t}_getTypeFromHandle(e,t=[]){return e instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&e instanceof GPUDevice||e?.queue?"webgpu":e===null?"null":(e instanceof WebGLRenderingContext?N.warn("WebGL1 is not supported",e)():N.warn("Unknown handle type",e)(),null)}},Vs=new xm});function fR(){return Cu||(uR()||typeof window>"u"?Cu=Promise.resolve():Cu=new Promise(n=>window.addEventListener("load",()=>n()))),Cu}var Ea,lR,uR,Cu,s0=C(()=>{vr();Ea=class{get pageLoaded(){return fR()}},lR=Tt()&&typeof document<"u",uR=()=>lR&&document.readyState==="complete",Cu=null});function zn(n="id"){wm[n]=wm[n]||1;let e=wm[n]++;return`${n}-${e}`}var wm,Ws=C(()=>{wm={}});function _R(n,e){let t={...e};for(let i in n)n[i]!==void 0&&(t[i]=n[i]);return t}function f0(n,e){let t=n.stats,i=!1;for(let c of e)t[c]||(n.get(c),i=!0);let r=Object.keys(t).length,s=l0.get(n);if(!i&&s?.orderedStatNames===e&&s.statCount===r)return;let o={},a=u0.get(e);a||(a=new Set(e),u0.set(e,a));for(let c of e)t[c]&&(o[c]=t[c]);for(let[c,l]of Object.entries(t))a.has(c)||(o[c]=l);for(let c of Object.keys(t))delete t[c];Object.assign(t,o),l0.set(n,{orderedStatNames:e,statCount:r})}function d0(n){return n.type==="webgl"?gR:mR}function Sa(n){let e=n.userData[dR];return e?.enabled?e:null}function $i(){return globalThis.performance?.now?.()??Date.now()}function yR(n,e){let t=Sa(n);if(!(!t||!t.activeDefaultFramebufferAcquireDepth))switch(t.transientCanvasResourceCreates=(t.transientCanvasResourceCreates||0)+1,e){case"Texture":t.transientCanvasTextureCreates=(t.transientCanvasTextureCreates||0)+1;break;case"TextureView":t.transientCanvasTextureViewCreates=(t.transientCanvasTextureViewCreates||0)+1;break;case"Sampler":t.transientCanvasSamplerCreates=(t.transientCanvasSamplerCreates||0)+1;break;case"Framebuffer":t.transientCanvasFramebufferCreates=(t.transientCanvasFramebufferCreates||0)+1;break;default:break}}function bR(n){let e=Object.getPrototypeOf(n);for(;e;){let t=Object.getPrototypeOf(e);if(!t||t===te.prototype)return vR(e)||n[Symbol.toStringTag]||n.constructor.name;e=t}return n[Symbol.toStringTag]||n.constructor.name}function vR(n){let e=Object.getOwnPropertyDescriptor(n,Symbol.toStringTag);return typeof e?.get=="function"?e.get.call(n):typeof e?.value=="string"?e.value:null}var dR,o0,a0,c0,hR,pR,mR,gR,l0,u0,te,He=C(()=>{Ws();dR="cpu-hotspot-profiler",o0="GPU Resource Counts",a0="Resource Counts",c0="GPU Time and Memory",hR=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","RenderBundleEncoders","RenderBundles","ComputePasss","CommandEncoders","CommandBuffers"],pR=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","SharedRenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","RenderBundleEncoders","RenderBundles","ComputePasss","CommandEncoders","CommandBuffers"],mR=hR.flatMap(n=>[`${n} Created`,`${n} Active`]),gR=pR.flatMap(n=>[`${n} Created`,`${n} Active`]),l0=new WeakMap,u0=new WeakMap,te=class{static defaultProps={id:"undefined",handle:void 0,_isHandleBorrowed:!1,userData:void 0};toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}toJSON(){return this.toString()}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;allocatedBytesName=null;_attachedResources=new Set;get ownsHandle(){return(this.props.handle===void 0||this.props.handle===null)&&!this.isHandleBorrowed}get isHandleBorrowed(){return!!this.props._isHandleBorrowed}constructor(e,t,i){if(!e)throw new Error("no device");this._device=e,this.props=_R(t,i);let r=this.props.id!=="undefined"?this.props.id:zn(this[Symbol.toStringTag]);this.props.id=r,this.id=r,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyed||this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of this._attachedResources)e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyed||(this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0)}removeStats(){let e=Sa(this._device),t=e?$i():0,i=[this._device.statsManager.getStats(o0),this._device.statsManager.getStats(a0)],r=d0(this._device);for(let o of i)f0(o,r);let s=this.getStatsName();for(let o of i)o.get("Resources Active").decrementCount(),o.get(`${s}s Active`).decrementCount();e&&(e.statsBookkeepingCalls=(e.statsBookkeepingCalls||0)+1,e.statsBookkeepingTimeMs=(e.statsBookkeepingTimeMs||0)+($i()-t))}trackAllocatedMemory(e,t=this.getStatsName()){let i=Sa(this._device),r=i?$i():0,s=this._device.statsManager.getStats(c0);this.allocatedBytes>0&&this.allocatedBytesName&&(s.get("GPU Memory").subtractCount(this.allocatedBytes),s.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes)),s.get("GPU Memory").addCount(e),s.get(`${t} Memory`).addCount(e),i&&(i.statsBookkeepingCalls=(i.statsBookkeepingCalls||0)+1,i.statsBookkeepingTimeMs=(i.statsBookkeepingTimeMs||0)+($i()-r)),this.allocatedBytes=e,this.allocatedBytesName=t}trackReferencedMemory(e,t=this.getStatsName()){this.trackAllocatedMemory(e,`External ${t}`)}trackDeallocatedMemory(e=this.getStatsName()){if(this.allocatedBytes===0){this.allocatedBytesName=null;return}let t=Sa(this._device),i=t?$i():0,r=this._device.statsManager.getStats(c0);r.get("GPU Memory").subtractCount(this.allocatedBytes),r.get(`${this.allocatedBytesName||e} Memory`).subtractCount(this.allocatedBytes),t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+($i()-i)),this.allocatedBytes=0,this.allocatedBytesName=null}trackDeallocatedReferencedMemory(e=this.getStatsName()){this.trackDeallocatedMemory(`Referenced ${e}`)}addStats(){let e=this.getStatsName(),t=Sa(this._device),i=t?$i():0,r=[this._device.statsManager.getStats(o0),this._device.statsManager.getStats(a0)],s=d0(this._device);for(let o of r)f0(o,s);for(let o of r)o.get("Resources Created").incrementCount(),o.get("Resources Active").incrementCount(),o.get(`${e}s Created`).incrementCount(),o.get(`${e}s Active`).incrementCount();t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+($i()-i)),yR(this._device,e)}getStatsName(){return bR(this)}}});var ie,Tu=C(()=>{He();ie=class n extends te{static INDEX=16;static VERTEX=32;static UNIFORM=64;static STORAGE=128;static INDIRECT=256;static QUERY_RESOLVE=512;static MAP_READ=1;static MAP_WRITE=2;static COPY_SRC=4;static COPY_DST=8;get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,t){let i={...t};(t.usage||0)&n.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?i.indexType="uint32":t.data instanceof Uint16Array?i.indexType="uint16":t.data instanceof Uint8Array&&(i.indexType="uint8")),delete i.data,super(e,i,n.defaultProps),this.usage=i.usage||0,this.indexType=i.indexType,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}static DEBUG_DATA_MAX_LENGTH=32;debugData=new ArrayBuffer(0);_setDebugData(e,t,i){if(!this.device.props.debug)return;let r=null,s;ArrayBuffer.isView(e)?(r=e,s=e.buffer):s=e;let o=Math.min(e?e.byteLength:i,n.DEBUG_DATA_MAX_LENGTH);if(s===null)this.debugData=new ArrayBuffer(o);else{let a=Math.min(r?.byteOffset||0,s.byteLength),c=Math.max(0,s.byteLength-a),l=Math.min(o,c);this.debugData=new Uint8Array(s,a,l).slice().buffer}}static defaultProps={...te.defaultProps,handle:void 0,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0}}});function h0(){return Em??Uint16Array}function p0(n){return!!(Em&&n===Em)}var Em,m0=C(()=>{Em=globalThis.Float16Array});function g0(n){let e=n.includes("norm"),t=!e&&!n.startsWith("float"),i=n.startsWith("s"),r=Sm[n],[s,o,a]=r||["uint8 ","i32",1];return{signedType:s,primitiveType:o,byteLength:a,normalized:e,integer:t,signed:i}}function _0(n){let e=n;switch(e){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return e}}function qt(n,e){switch(e){case 1:return n;case 2:return n+n%2;default:return n+(4-n%4)%4}}function Lu(n){let e=ArrayBuffer.isView(n)?n.constructor:n;if(p0(e))return"float16";if(e===Uint8ClampedArray)return"uint8";let t=Object.values(Sm).find(i=>e===i[4]);if(!t)throw new Error(e.name);return t[0]}function y0(n){return Lu(n)}function Tr(n){if(n==="float16")return h0();let e=Sm[n];if(!e)throw new Error(n);let[,,,,t]=e;return t}function Lr(n){return Tr(n)}var Sm,Mu=C(()=>{m0();Sm={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]}});var Pm,Xe,Au=C(()=>{Mu();Pm=class{getDataTypeInfo(e){return g0(e)}getNormalizedDataType(e){return _0(e)}alignTo(e,t){return qt(e,t)}getDataType(e){return y0(e)}getTypedArrayConstructor(e){return Lr(e)}},Xe=new Pm});function xR(n,e){try{return Xe.getDataTypeInfo(e)}catch{throw new Error(`Unsupported vertex format: ${n}`)}}function wR(n,e){if(!e)return 1;let t=Number(e);if(t===2||t===3||t===4)return t;throw new Error(`Unsupported vertex format: ${n}`)}function ER(n,e,t){if(t!==3)throw new Error(`Unsupported vertex format: ${n}`);switch(e){case"uint8":case"sint8":case"unorm8":case"snorm8":case"uint16":case"sint16":case"unorm16":case"snorm16":return`${e}x3-webgl`;default:throw new Error(`Unsupported vertex format: ${n}`)}}var Cm,Pe,Pa=C(()=>{Au();Cm=class{getVertexFormatInfo(e){if(e==="unorm10-10-10-2")return{type:"unorm8",components:4,byteLength:4,integer:!1,signed:!1,normalized:!0};let t=e==="unorm8x4-bgra"?"unorm8x4":e,i;t.endsWith("-webgl")&&(t=t.slice(0,-6),i=!0);let r=t.split("x");if(r.length>2)throw new Error(`Unsupported vertex format: ${e}`);let[s,o]=r,a=s,c=wR(e,o),l=xR(e,a),u;try{u=i?ER(e,a,c):this.makeVertexFormat(l.signedType,c,l.normalized)}catch{throw new Error(`Unsupported vertex format: ${e}`)}if(u!==(i?e:t))throw new Error(`Unsupported vertex format: ${e}`);let f={type:a,components:c,byteLength:l.byteLength*c,integer:l.integer,signed:l.signed,normalized:l.normalized};return i&&(f.webglOnly=!0),f}makeVertexFormat(e,t,i){let r=i?Xe.getNormalizedDataType(e):e;switch(r){case"unorm8":return t===1?"unorm8":t===3?"unorm8x3-webgl":`${r}x${t}`;case"snorm8":return t===1?"snorm8":t===3?"snorm8x3-webgl":`${r}x${t}`;case"uint8":case"sint8":if(t===3)throw new Error(`size: ${t}`);return t===1?r:`${r}x${t}`;case"uint16":return t===1?"uint16":t===3?"uint16x3-webgl":`${r}x${t}`;case"sint16":return t===1?"sint16":t===3?"sint16x3-webgl":`${r}x${t}`;case"unorm16":return t===1?"unorm16":t===3?"unorm16x3-webgl":`${r}x${t}`;case"snorm16":return t===1?"snorm16":t===3?"snorm16x3-webgl":`${r}x${t}`;case"float16":if(t===3)throw new Error(`size: ${t}`);return t===1?r:`${r}x${t}`;default:return t===1?r:`${r}x${t}`}}getVertexFormatFromAttribute(e,t,i){if(!t||t>4)throw new Error(`size ${t}`);let r=t,s=Xe.getDataType(e);return this.makeVertexFormat(s,r,i)}getCompatibleVertexFormat(e){let t;switch(e.primitiveType){case"f32":t="float32";break;case"i32":t="sint32";break;case"u32":t="uint32";break;case"f16":return e.components<=2?"float16x2":"float16x4"}return e.components===1?t:`${t}x${e.components}`}},Pe=new Cm});function Bu(n){let e=x0[n];if(!e)throw new Error(`Unsupported texture format ${n}`);return e}function v0(){return x0}var Qe,xe,Un,SR,ku,Tm,Ru,Lm,PR,Mm,Gi,Am,km,Iu,b0,CR,TR,x0,Rm=C(()=>{Qe="texture-compression-bc",xe="texture-compression-astc",Un="texture-compression-etc2",SR="texture-compression-etc1-webgl",ku="texture-compression-pvrtc-webgl",Tm="texture-compression-atc-webgl",Ru="float32-renderable-webgl",Lm="float16-renderable-webgl",PR="rgb9e5ufloat-renderable-webgl",Mm="snorm8-renderable-webgl",Gi="norm16-webgl",Am="norm16-renderable-webgl",km="snorm16-renderable-webgl",Iu="float32-filterable",b0="float16-filterable-webgl";CR={r8unorm:{webgpu:527},rg8unorm:{webgpu:527},"rgb8unorm-webgl":{},rgba8unorm:{webgpu:31},"rgba8unorm-srgb":{webgpu:15},r8snorm:{render:Mm,webgpu:837},rg8snorm:{render:Mm,webgpu:837},"rgb8snorm-webgl":{},rgba8snorm:{render:Mm,webgpu:341},r8uint:{webgpu:515},rg8uint:{webgpu:515},rgba8uint:{webgpu:19},r8sint:{webgpu:515},rg8sint:{webgpu:515},rgba8sint:{webgpu:19},bgra8unorm:{webgpu:15},"bgra8unorm-srgb":{webgpu:15360},r16unorm:{f:Gi,render:Am,webgpu:992},rg16unorm:{f:Gi,render:Am,webgpu:992},"rgb16unorm-webgl":{f:Gi,render:!1},rgba16unorm:{f:Gi,render:Am,webgpu:992},r16snorm:{f:Gi,render:km,webgpu:992},rg16snorm:{f:Gi,render:km,webgpu:992},"rgb16snorm-webgl":{f:Gi,render:!1},rgba16snorm:{f:Gi,render:km,webgpu:992},r16uint:{webgpu:515},rg16uint:{webgpu:515},rgba16uint:{webgpu:19},r16sint:{webgpu:515},rg16sint:{webgpu:515},rgba16sint:{webgpu:19},r16float:{render:Lm,filter:"float16-filterable-webgl",webgpu:527},rg16float:{render:Lm,filter:b0,webgpu:527},rgba16float:{render:Lm,filter:b0,webgpu:31},r32uint:{webgpu:19},rg32uint:{webgpu:16387},rgba32uint:{webgpu:19},r32sint:{webgpu:19},rg32sint:{webgpu:16387},rgba32sint:{webgpu:19},r32float:{render:Ru,filter:Iu,webgpu:19},rg32float:{render:!1,filter:Iu,webgpu:16387},"rgb32float-webgl":{render:Ru,filter:Iu},rgba32float:{render:Ru,filter:Iu,webgpu:19},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:PR,webgpu:5},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:Ru,webgpu:517},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:527},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:515},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8",webgpu:3},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16",webgpu:3},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32",webgpu:3},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32",webgpu:3},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0,webgpu:3},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0,f:"depth32float-stencil8",webgpu:3}},TR={"bc1-rgb-unorm-webgl":{f:Qe},"bc1-rgb-unorm-srgb-webgl":{f:Qe},"bc1-rgba-unorm":{f:Qe},"bc1-rgba-unorm-srgb":{f:Qe},"bc2-rgba-unorm":{f:Qe},"bc2-rgba-unorm-srgb":{f:Qe},"bc3-rgba-unorm":{f:Qe},"bc3-rgba-unorm-srgb":{f:Qe},"bc4-r-unorm":{f:Qe},"bc4-r-snorm":{f:Qe},"bc5-rg-unorm":{f:Qe},"bc5-rg-snorm":{f:Qe},"bc6h-rgb-ufloat":{f:Qe},"bc6h-rgb-float":{f:Qe},"bc7-rgba-unorm":{f:Qe},"bc7-rgba-unorm-srgb":{f:Qe},"etc2-rgb8unorm":{f:Un},"etc2-rgb8unorm-srgb":{f:Un},"etc2-rgb8a1unorm":{f:Un},"etc2-rgb8a1unorm-srgb":{f:Un},"etc2-rgba8unorm":{f:Un},"etc2-rgba8unorm-srgb":{f:Un},"eac-r11unorm":{f:Un},"eac-r11snorm":{f:Un},"eac-rg11unorm":{f:Un},"eac-rg11snorm":{f:Un},"astc-4x4-unorm":{f:xe},"astc-4x4-unorm-srgb":{f:xe},"astc-5x4-unorm":{f:xe},"astc-5x4-unorm-srgb":{f:xe},"astc-5x5-unorm":{f:xe},"astc-5x5-unorm-srgb":{f:xe},"astc-6x5-unorm":{f:xe},"astc-6x5-unorm-srgb":{f:xe},"astc-6x6-unorm":{f:xe},"astc-6x6-unorm-srgb":{f:xe},"astc-8x5-unorm":{f:xe},"astc-8x5-unorm-srgb":{f:xe},"astc-8x6-unorm":{f:xe},"astc-8x6-unorm-srgb":{f:xe},"astc-8x8-unorm":{f:xe},"astc-8x8-unorm-srgb":{f:xe},"astc-10x5-unorm":{f:xe},"astc-10x5-unorm-srgb":{f:xe},"astc-10x6-unorm":{f:xe},"astc-10x6-unorm-srgb":{f:xe},"astc-10x8-unorm":{f:xe},"astc-10x8-unorm-srgb":{f:xe},"astc-10x10-unorm":{f:xe},"astc-10x10-unorm-srgb":{f:xe},"astc-12x10-unorm":{f:xe},"astc-12x10-unorm-srgb":{f:xe},"astc-12x12-unorm":{f:xe},"astc-12x12-unorm-srgb":{f:xe},"pvrtc-rgb4unorm-webgl":{f:ku},"pvrtc-rgba4unorm-webgl":{f:ku},"pvrtc-rgb2unorm-webgl":{f:ku},"pvrtc-rgba2unorm-webgl":{f:ku},"etc1-rbg-unorm-webgl":{f:SR},"atc-rgb-unorm-webgl":{f:Tm},"atc-rgba-unorm-webgl":{f:Tm},"atc-rgbai-unorm-webgl":{f:Tm}},x0={...CR,...TR}});function IR({format:n,width:e,height:t,depth:i,byteAlignment:r}){let s=ft.getInfo(n),{bytesPerPixel:o,bytesPerBlock:a=o,blockWidth:c=1,blockHeight:l=1,compressed:u=!1}=s,f=u?Math.ceil(e/c):e,d=u?Math.ceil(t/l):t,h=f*a,p=Math.ceil(h/r)*r,m=d,g=p*m*i;return{bytesPerPixel:o,bytesPerRow:p,rowsPerImage:m,depthOrArrayLayers:i,bytesPerImage:p*m,byteLength:g}}function BR(n){let e=Bu(n),t={format:n,create:e.f??!0,render:e.render??!0,filter:e.filter??!0,blend:e.blend??!0,store:e.store??!0},i=w0(n),r=n.startsWith("depth")||n.startsWith("stencil"),s=i?.signed,o=i?.integer,a=i?.webgl,c=!!i?.compressed;return t.render&&=!r&&!c,t.filter&&=!r&&!s&&!o&&!a,t}function w0(n){let e=OR(n);if(ft.isCompressed(n)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0,e.bytesPerBlock=NR(n);let i=DR(n);i&&(e.blockWidth=i.blockWidth,e.blockHeight=i.blockHeight)}let t=e.packed?null:LR.exec(n);if(t){let[,i,r,s,o,a]=t,c=`${s}${r}`,l=Xe.getDataTypeInfo(c),u=l.byteLength*8,f=i?.length??1,d=[u,f>=2?u:0,f>=3?u:0,f>=4?u:0];e={format:n,attachment:e.attachment,dataType:l.signedType,components:f,channels:i,integer:l.integer,signed:l.signed,normalized:l.normalized,bitsPerChannel:d,bytesPerPixel:l.byteLength*f,packed:e.packed,srgb:e.srgb},a==="-webgl"&&(e.webgl=!0),o==="-srgb"&&(e.srgb=!0)}return n.endsWith("-webgl")&&(e.webgl=!0),n.endsWith("-srgb")&&(e.srgb=!0),e}function OR(n){let e={...Bu(n)},t=e.bytesPerPixel||1,i=e.bitsPerChannel||[8,8,8,8];return delete e.bitsPerChannel,delete e.bytesPerPixel,delete e.f,delete e.render,delete e.filter,delete e.blend,delete e.store,delete e.webgpu,{...e,format:n,attachment:e.attachment||"color",channels:e.channels||"r",components:e.components||e.channels?.length||1,bytesPerPixel:t,bitsPerChannel:i,dataType:e.dataType||"uint8",srgb:e.srgb??!1,packed:e.packed??!1,webgl:e.webgl??!1,integer:e.integer??!1,signed:e.signed??!1,normalized:e.normalized??!1,compressed:e.compressed??!1}}function DR(n){let t=/.*-(\d+)x(\d+)-.*/.exec(n);if(t){let[,i,r]=t;return{blockWidth:Number(i),blockHeight:Number(r)}}return n.startsWith("bc")||n.startsWith("etc1")||n.startsWith("etc2")||n.startsWith("eac")||n.startsWith("atc")?{blockWidth:4,blockHeight:4}:n.startsWith("pvrtc-rgb4")||n.startsWith("pvrtc-rgba4")?{blockWidth:4,blockHeight:4}:n.startsWith("pvrtc-rgb2")||n.startsWith("pvrtc-rgba2")?{blockWidth:8,blockHeight:4}:null}function NR(n){return n.startsWith("bc1")||n.startsWith("bc4")||n.startsWith("etc1")||n.startsWith("etc2-rgb8")||n.startsWith("etc2-rgb8a1")||n.startsWith("eac-r11")||n==="atc-rgb-unorm-webgl"?8:n.startsWith("bc2")||n.startsWith("bc3")||n.startsWith("bc5")||n.startsWith("bc6h")||n.startsWith("bc7")||n.startsWith("etc2-rgba8")||n.startsWith("eac-rg11")||n.startsWith("astc")||n==="atc-rgba-unorm-webgl"||n==="atc-rgbai-unorm-webgl"?16:n.startsWith("pvrtc")?8:16}var LR,MR,AR,kR,RR,Im,ft,Ou=C(()=>{Au();Rm();LR=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,MR=["rgb","rgba","bgra"],AR=["depth","stencil"],kR=5,RR=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],Im=class{isColor(e){return MR.some(t=>e.startsWith(t))}isDepthStencil(e){return AR.some(t=>e.startsWith(t))}isCompressed(e){return RR.some(t=>e.startsWith(t))}getInfo(e){return w0(e)}getCapabilities(e){return BR(e)}getWebGPUCapabilities(e){let t=Bu(e);return t.webgpu!==void 0?t.webgpu:this.isCompressed(e)&&!e.endsWith("-webgl")?kR:0}computeMemoryLayout(e){return IR(e)}},ft=new Im});function E0(n){return typeof ImageData<"u"&&n instanceof ImageData||typeof ImageBitmap<"u"&&n instanceof ImageBitmap||typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement||typeof VideoFrame<"u"&&n instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas}function S0(n){if(typeof ImageData<"u"&&n instanceof ImageData||typeof ImageBitmap<"u"&&n instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas)return{width:n.width,height:n.height};if(typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement)return{width:n.naturalWidth,height:n.naturalHeight};if(typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement)return{width:n.videoWidth,height:n.videoHeight};if(typeof VideoFrame<"u"&&n instanceof VideoFrame)return{width:n.displayWidth,height:n.displayHeight};throw new Error("Unknown image type")}var P0=C(()=>{});function FR(n,e){let t=Bm(n),i=e.map(Bm).filter(r=>r!==void 0);return[t,...i].filter(r=>r!==void 0)}function Bm(n){if(n!==void 0){if(n===null||typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n;if(n instanceof Error)return n.message;if(Array.isArray(n))return n.map(Bm);if(typeof n=="object"){if(zR(n)){let e=String(n);if(e!=="[object Object]")return e}return UR(n)?$R(n):n.constructor?.name||"Object"}return String(n)}}function zR(n){return"toString"in n&&typeof n.toString=="function"&&n.toString!==Object.prototype.toString}function UR(n){return"message"in n&&"type"in n}function $R(n){let e=typeof n.type=="string"?n.type:"message",t=typeof n.message=="string"?n.message:"",i=typeof n.lineNum=="number"?n.lineNum:null,r=typeof n.linePos=="number"?n.linePos:null,s=i!==null&&r!==null?` @ ${i}:${r}`:i!==null?` @ ${i}`:"";return`${e}${s}: ${t}`.trim()}function Om(){if(typeof HTMLCanvasElement>"u")return!1;let n=HTMLCanvasElement.prototype;return"layoutSubtree"in n&&typeof n.requestPaint=="function"}var Ca,Ta,bi,C0=C(()=>{vm();ut();Ws();Tu();Pa();Ou();P0();Rm();ym();Ca=class{};Ta=class{features;disabledFeatures;constructor(e=[],t){this.features=new Set(e),this.disabledFeatures=t||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures?.[e]&&this.features.has(e)}};bi=class n{static defaultProps={...Su};get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}toJSON(){return this.toString()}id;props;userData={};statsManager=Pu;_factories={};timestamp=0;_reused=!1;_moduleData={};wgslLanguageFeatures=new Set;_textureCaps={};_debugGPUTimeQuery=null;constructor(e){this.props={...n.defaultProps,...e},this.id=this.props.id||zn(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(e){return Pe.getVertexFormatInfo(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return ft.getInfo(e)}getTextureFormatCapabilities(e){let t=this._textureCaps[e];if(!t){let i=this._getDeviceTextureFormatCapabilities(e);t=this._getDeviceSpecificTextureFormatCapabilities(i),this._textureCaps[e]=t}return t}getMipLevelCount(e,t,i=1){let r=Math.max(e,t,i);return 1+Math.floor(Math.log2(r))}isExternalImage(e){return E0(e)}getExternalImageSize(e){return S0(e)}isTextureFormatSupported(e){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return ft.isCompressed(e)}getSupportedCompressedTextureFormats(){let e=[];for(let t of Object.keys(v0()))this.isTextureFormatCompressed(t)&&this.isTextureFormatSupported(t)&&e.push(t);return e}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){this.commandEncoder?.popDebugGroup()}insertDebugMarker(e){this.commandEncoder?.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,t,...i){if(!this.props.onError(e,t)){let s=FR(t,i);return N.error(this.type==="webgl"?"%cWebGL":"%cWebGPU","color: white; background: red; padding: 2px 6px; border-radius: 3px;",e.message,...s)}return()=>{}}debug(){if(this.props.debug)debugger;else{let e=`'Type luma.log.set({debug: true}) in console to enable debug breakpoints', +or create a device with the 'debug: true' prop.`;N.once(0,e)()}}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}createFence(){throw new Error("createFence() not implemented")}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}writeBufferViaCommandEncoder(e,t,i,r=0){throw new Error("writeBufferViaCommandEncoder() not implemented")}generateMipmapsWebGPU(e){throw new Error("not implemented")}_createSharedRenderPipelineWebGL(e){throw new Error("_createSharedRenderPipelineWebGL() not implemented")}_createBindGroupLayoutWebGPU(e,t){throw new Error("_createBindGroupLayoutWebGPU() not implemented")}_createBindGroupWebGPU(e,t,i,r,s){throw new Error("_createBindGroupWebGPU() not implemented")}_supportsDebugGPUTime(){return this.features.has("timestamp-query")&&!!(this.props.debug||this.props.debugGPUTime)}_enableDebugGPUTime(e=256){if(!this._supportsDebugGPUTime())return null;if(this._debugGPUTimeQuery)return this._debugGPUTimeQuery;try{this._debugGPUTimeQuery=this.createQuerySet({type:"timestamp",count:e}),this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id,timeProfilingQuerySet:this._debugGPUTimeQuery})}catch{this._debugGPUTimeQuery=null}return this._debugGPUTimeQuery}_disableDebugGPUTime(){this._debugGPUTimeQuery&&(this.commandEncoder.getTimeProfilingQuerySet()===this._debugGPUTimeQuery&&(this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id})),this._debugGPUTimeQuery.destroy(),this._debugGPUTimeQuery=null)}_isDebugGPUTimeEnabled(){return this._debugGPUTimeQuery!==null}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}getModuleData(e){return this._moduleData[e]||={},this._moduleData[e]}static _getCanvasContextProps(e){return e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){let t=ft.getCapabilities(e),i=s=>(typeof s=="string"?this.features.has(s):s)??!0,r=i(t.create);return{format:e,create:r,render:r&&i(t.render),filter:r&&i(t.filter),blend:r&&i(t.blend),store:r&&i(t.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let t={...e};if((e.usage||0)&ie.INDEX&&(e.indexType||(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array?t.indexType="uint16":e.data instanceof Uint8Array&&(t.data=new Uint16Array(e.data),t.indexType="uint16")),!t.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return t}}});var Du,T0=C(()=>{Du=class{props;_resizeObserver;_intersectionObserver;_observeDevicePixelRatioTimeout=null;_observeDevicePixelRatioMediaQuery=null;_handleDevicePixelRatioChange=()=>this._refreshDevicePixelRatio();_trackPositionInterval=null;_started=!1;get started(){return this._started}constructor(e){this.props=e}start(){if(this._started||!this.props.canvas)return;this._started=!0,this._intersectionObserver||=new IntersectionObserver(t=>this.props.onIntersection(t)),this._resizeObserver||=new ResizeObserver(t=>this.props.onResize(t)),this._intersectionObserver.observe(this.props.canvas);let e=this.props.resizeObserverBox;try{this._resizeObserver.observe(this.props.canvas,{box:e})}catch{this._resizeObserver.observe(this.props.canvas,{box:"content-box"})}this._observeDevicePixelRatioTimeout=setTimeout(()=>this._refreshDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}stop(){this._started&&(this._started=!1,this._observeDevicePixelRatioTimeout&&(clearTimeout(this._observeDevicePixelRatioTimeout),this._observeDevicePixelRatioTimeout=null),this._observeDevicePixelRatioMediaQuery&&(this._observeDevicePixelRatioMediaQuery.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=null),this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null),this._resizeObserver?.disconnect(),this._intersectionObserver?.disconnect())}_refreshDevicePixelRatio(){this._started&&(this.props.onDevicePixelRatioChange(),this._observeDevicePixelRatioMediaQuery?.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._observeDevicePixelRatioMediaQuery.addEventListener("change",this._handleDevicePixelRatioChange,{once:!0}))}_trackPosition(e=100){this._trackPositionInterval||(this._trackPositionInterval=setInterval(()=>{this._started?this.props.onPositionChange():this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null)},e))}}});function L0(){let n,e;return{promise:new Promise((i,r)=>{n=i,e=r}),resolve:n,reject:e}}var M0=C(()=>{});function Vi(n,e){if(!n){let t=new Error(e??"luma.gl assertion failed.");throw Error.captureStackTrace?.(t,Vi),t}}function Wi(n,e){return Vi(n,e),n}var Dm=C(()=>{});function GR(n){if(typeof n=="string"){let e=document.getElementById(n);if(!e)throw new Error(`${n} is not an HTML element`);return e}return n||document.body}function VR(n){let e=document.getElementById(n);if(!ji.isHTMLCanvas(e))throw new Error("Object is not a canvas element");return e}function WR(n){let{width:e,height:t}=n,i=document.createElement("canvas");i.id=zn("lumagl-auto-created-canvas"),i.width=e||1,i.height=t||1,i.style.width=Number.isFinite(e)?`${e}px`:"100%",i.style.height=Number.isFinite(t)?`${t}px`:"100%",n?.visible||(i.style.visibility="hidden");let r=GR(n?.container||null);return r.insertBefore(i,r.firstChild),i}function jR(n,e,t,i,r){let s=n,o=A0(s[0],e,t),a=k0(s[1],e,i,r),c=A0(s[0]+1,e,t),l=c===t-1?c:c-1;c=k0(s[1]+1,e,i,r);let u;return r?(c=c===0?c:c+1,u=a,a=c):u=c===i-1?c:c-1,{x:o,y:a,width:Math.max(l-o+1,1),height:Math.max(u-a+1,1)}}function A0(n,e,t){return Math.min(Math.round(n*e),t-1)}function k0(n,e,t,i){return i?Math.max(0,t-1-Math.round(n*e)):Math.min(Math.round(n*e),t-1)}var ji,Nm=C(()=>{vr();T0();Ws();M0();Dm();ji=class n{static isHTMLCanvas(e){return typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}static defaultProps={id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,pixelSizeSource:"exact",autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",colorFormat:void 0,toneMapping:"standard",trackPosition:!1};id;props;canvas;htmlCanvas;offscreenCanvas;type;initialized;isInitialized=!1;isVisible=!0;cssWidth;cssHeight;devicePixelRatio;devicePixelWidth;devicePixelHeight;drawingBufferWidth;drawingBufferHeight;_initializedResolvers=L0();_canvasObserver;_position=[0,0];destroyed=!1;_needsDrawingBufferResize=!0;_configuredDrawingBufferSize=[0,0];toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(e){this.props={...n.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,Tt()?e.canvas?typeof e.canvas=="string"?this.canvas=VR(e.canvas):this.canvas=e.canvas:this.canvas=WR(e):this.canvas={width:e.width||1,height:e.height||1},n.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):n.isOffscreenCanvas(this.canvas)?(this.id=e.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=e.id||"node-canvas-context",this.type="node"),this.cssWidth=this.htmlCanvas?.clientWidth||this.canvas.width,this.cssHeight=this.htmlCanvas?.clientHeight||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this._configuredDrawingBufferSize=[this.canvas.width,this.canvas.height],this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],this._canvasObserver=new Du({canvas:this.htmlCanvas,trackPosition:this.props.trackPosition,resizeObserverBox:this.props.pixelSizeSource==="css-dpr"?"content-box":"device-pixel-content-box",onResize:t=>this._handleResize(t),onIntersection:t=>this._handleIntersection(t),onDevicePixelRatioChange:()=>this._observeDevicePixelRatio(),onPositionChange:()=>this.updatePosition()})}destroy(){this.destroyed||(this.destroyed=!0,this._stopObservers(),this.device=null)}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCurrentFramebuffer(e){return this._resizeDrawingBufferIfNeeded(),this._getCurrentFramebuffer(e)}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){let e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,t){e=Math.floor(e),t=Math.floor(t),!(this.drawingBufferWidth===e&&this.drawingBufferHeight===t)&&(this.drawingBufferWidth=e,this.drawingBufferHeight=t,this._needsDrawingBufferResize=!0)}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(e,t=!0){let i=this.cssToDeviceRatio(),[r,s]=this.getDrawingBufferSize();return jR(e,i,r,s,t)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){let[e,t]=this.getDrawingBufferSize();return e>0&&t>0?e/t:1}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),[t]=this.getCSSSize();return t?e/t:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}_startObservers(){this.destroyed||this._canvasObserver.start()}_stopObservers(){this._canvasObserver.stop()}_handleIntersection(e){if(this.destroyed)return;let t=e.find(r=>r.target===this.canvas);if(!t)return;let i=t.isIntersecting;this.isVisible!==i&&(this.isVisible=i,this.device.props.onVisibilityChange(this))}_handleResize(e){if(this.destroyed)return;let t=e.find(s=>s.target===this.canvas);if(!t)return;let i=Wi(t.contentBoxSize?.[0]);this.cssWidth=i.inlineSize,this.cssHeight=i.blockSize;let r=this.getDevicePixelSize();this._setDevicePixelSize(this._getDevicePixelSizeFromResizeEntry(t)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:r})}_updateDrawingBufferSize(){if(this.props.autoResize)if(typeof this.props.useDevicePixels=="number"){let e=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*e,this.cssHeight*e)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_getDevicePixelSizeFromResizeEntry(e){let t=Wi(e.contentBoxSize?.[0]);return this.props.pixelSizeSource==="css-dpr"?this._getDevicePixelSizeFromCSSSize(t.inlineSize,t.blockSize):{devicePixelWidth:e.devicePixelContentBoxSize?.[0]?.inlineSize||t.inlineSize*devicePixelRatio,devicePixelHeight:e.devicePixelContentBoxSize?.[0]?.blockSize||t.blockSize*devicePixelRatio}}_getDevicePixelSizeFromCSSSize(e,t){let i=this.getDevicePixelRatio();return{devicePixelWidth:Math.floor(e*i),devicePixelHeight:Math.floor(t*i)}}_setDevicePixelSize({devicePixelWidth:e,devicePixelHeight:t}){let[i,r]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(e,i)),this.devicePixelHeight=Math.max(1,Math.min(t,r))}_resizeDrawingBufferIfNeeded(){if(this._needsDrawingBufferResize){this._needsDrawingBufferResize=!1,(this.drawingBufferWidth!==this.canvas.width||this.drawingBufferHeight!==this.canvas.height)&&(this.canvas.width=this.drawingBufferWidth,this.canvas.height=this.drawingBufferHeight);let[t,i]=this._configuredDrawingBufferSize;(this.drawingBufferWidth!==t||this.drawingBufferHeight!==i)&&(this._configureDevice(),this._configuredDrawingBufferSize=[this.drawingBufferWidth,this.drawingBufferHeight])}}_observeDevicePixelRatio(){if(this.destroyed||!this._canvasObserver.started)return;let e=this.devicePixelRatio;if(this.devicePixelRatio=window.devicePixelRatio,this.props.pixelSizeSource==="css-dpr"){let t=this.getDevicePixelSize();this._setDevicePixelSize(this._getDevicePixelSizeFromCSSSize(this.cssWidth,this.cssHeight)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:t})}this.updatePosition(),this.device.props.onDevicePixelRatioChange?.(this,{oldRatio:e})}updatePosition(){if(this.destroyed)return;let e=this.htmlCanvas?.getBoundingClientRect();if(e){let t=[e.left,e.top];if(this._position??=t,t[0]!==this._position[0]||t[1]!==this._position[1]){let r=this._position;this._position=t,this.device.props.onPositionChange?.(this,{oldPosition:r})}}}}});var La,R0=C(()=>{Nm();La=class extends ji{static defaultProps=ji.defaultProps}});var Ma,I0=C(()=>{Nm();Ma=class extends ji{}});var Mr,Fm=C(()=>{He();Mr=class n extends te{static defaultProps={...te.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1};get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){t=n.normalizeProps(e,t),super(e,t,n.defaultProps)}static normalizeProps(e,t){return t}}});var HR,me,zm=C(()=>{He();Fm();ut();Ou();HR={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},me=class n extends te{static SAMPLE=4;static STORAGE=8;static RENDER=16;static COPY_SRC=1;static COPY_DST=2;static TEXTURE=4;static RENDER_ATTACHMENT=16;dimension;baseDimension;format;width;height;depth;mipLevels;samples;byteAlignment;ready=Promise.resolve(this);isReady=!0;updateTimestamp;get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(e,t,i){if(t=n.normalizeProps(e,t),super(e,t,n.defaultProps),this.dimension=this.props.dimension,this.baseDimension=HR[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.samples=this.props.samples||1,this.dimension==="cube"&&(this.depth=6),this.props.width===void 0||this.props.height===void 0)if(e.isExternalImage(t.data)){let r=e.getExternalImageSize(t.data);this.width=r?.width||1,this.height=r?.height||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&N.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=i?.byteAlignment||1,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createTexture({...this.props,...e})}setSampler(e){this.sampler=e instanceof Mr?e:this.device.createSampler(e)}copyImageData(e){let{data:t,depth:i,...r}=e;this.writeData(t,{...r,depthOrArrayLayers:r.depthOrArrayLayers??i})}computeMemoryLayout(e={}){let t=this._normalizeTextureReadOptions(e),{width:i=this.width,height:r=this.height,depthOrArrayLayers:s=this.depth}=t,{format:o,byteAlignment:a}=this;return ft.computeMemoryLayout({format:o,width:i,height:r,depth:s,byteAlignment:a})}readBuffer(e,t){throw new Error("readBuffer not implemented")}readDataAsync(e){throw new Error("readBuffer not implemented")}writeBuffer(e,t){throw new Error("readBuffer not implemented")}writeData(e,t){throw new Error("readBuffer not implemented")}readDataSyncWebGL(e){throw new Error("readDataSyncWebGL not available")}generateMipmapsWebGL(){throw new Error("generateMipmapsWebGL not available")}static normalizeProps(e,t){let i={...t},{width:r,height:s}=i;return typeof r=="number"&&(i.width=Math.max(1,Math.ceil(r))),typeof s=="number"&&(i.height=Math.max(1,Math.ceil(s))),i}_initializeData(e){this.device.isExternalImage(e)?this.copyExternalImage({image:e,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):e&&this.copyImageData({data:e,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(e){let{data:t,depth:i,...r}=e,s=this._normalizeTextureWriteOptions({...r,depthOrArrayLayers:r.depthOrArrayLayers??i});return{data:t,depth:s.depthOrArrayLayers,...s}}_normalizeCopyExternalImageOptions(e){let t=n._omitUndefined(e),i=t.mipLevel??0,r=this._getMipLevelSize(i),s=this.device.getExternalImageSize(e.image),o={...n.defaultCopyExternalImageOptions,...r,...s,...t};return o.width=Math.min(o.width,r.width-o.x),o.height=Math.min(o.height,r.height-o.y),o.depth=Math.min(o.depth,r.depthOrArrayLayers-o.z),o}_normalizeCopyElementImageOptions(e){let t=n._omitUndefined(e),i=t.mipLevel??0,r=this._getMipLevelSize(i),s={...n.defaultCopyElementImageOptions,...r,...t};return s.width=Math.min(s.width,r.width-s.x),s.height=Math.min(s.height,r.height-s.y),s.depth=Math.min(s.depth,r.depthOrArrayLayers-s.z),s}_normalizeTextureReadOptions(e){let t=n._omitUndefined(e),i=t.mipLevel??0,r=this._getMipLevelSize(i),s={...n.defaultTextureReadOptions,...r,...t};return s.width=Math.min(s.width,r.width-s.x),s.height=Math.min(s.height,r.height-s.y),s.depthOrArrayLayers=Math.min(s.depthOrArrayLayers,r.depthOrArrayLayers-s.z),s}_getSupportedColorReadOptions(e){let t=this._normalizeTextureReadOptions(e),i=ft.getInfo(this.format);switch(this._validateColorReadAspect(t),this._validateColorReadFormat(i),this.dimension){case"2d":case"cube":case"cube-array":case"2d-array":case"3d":return t;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}}_validateColorReadAspect(e){if(e.aspect!=="all")throw new Error(`${this} color readback only supports aspect 'all'`)}_validateColorReadFormat(e){if(e.compressed)throw new Error(`${this} color readback does not support compressed formats (${this.format})`);switch(e.attachment){case"color":return;case"depth":throw new Error(`${this} color readback does not support depth formats (${this.format})`);case"stencil":throw new Error(`${this} color readback does not support stencil formats (${this.format})`);case"depth-stencil":throw new Error(`${this} color readback does not support depth-stencil formats (${this.format})`);default:throw new Error(`${this} color readback does not support format ${this.format}`)}}_normalizeTextureWriteOptions(e){let t=n._omitUndefined(e),i=t.mipLevel??0,r=this._getMipLevelSize(i),s={...n.defaultTextureWriteOptions,...r,...t};s.width=Math.min(s.width,r.width-s.x),s.height=Math.min(s.height,r.height-s.y),s.depthOrArrayLayers=Math.min(s.depthOrArrayLayers,r.depthOrArrayLayers-s.z);let o=ft.computeMemoryLayout({format:this.format,width:s.width,height:s.height,depth:s.depthOrArrayLayers,byteAlignment:this.byteAlignment}),a=o.bytesPerPixel*s.width;if(s.bytesPerRow=t.bytesPerRow??o.bytesPerRow,s.rowsPerImage=t.rowsPerImage??s.height,s.bytesPerRow>e),i=this.baseDimension==="1d"?1:Math.max(1,this.height>>e),r=this.dimension==="3d"?Math.max(1,this.depth>>e):this.depth;return{width:t,height:i,depthOrArrayLayers:r}}getAllocatedByteLength(){let e=0;for(let t=0;tt!==void 0))}static defaultProps={...te.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:n.SAMPLE|n.RENDER|n.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0};static defaultCopyDataOptions={data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,width:void 0,height:void 0,depthOrArrayLayers:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all"};static defaultCopyExternalImageOptions={image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultCopyElementImageOptions={element:void 0,width:void 0,height:void 0,sourceX:0,sourceY:0,sourceWidth:void 0,sourceHeight:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultTextureReadOptions={x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"};static defaultTextureWriteOptions={byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"}}});var Ar,B0=C(()=>{He();Ar=class n extends te{get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,n.defaultProps)}static defaultProps={...te.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0}}});var Aa,O0=C(()=>{He();Aa=class n extends te{width;height;updateTimestamp;get[Symbol.toStringTag](){return"ExternalTexture"}constructor(e,t){super(e,t,n.defaultProps);let i=this.props.source?e.getExternalImageSize(this.props.source):null;this.width=this.props.width||i?.width||0,this.height=this.props.height||i?.height||0,this.updateTimestamp=e.incrementTimestamp()}static defaultProps={...te.defaultProps,source:void 0,width:0,height:0,colorSpace:"srgb",sampler:{}}}});function D0(n,e,t){let i="",r=e.split(/\r?\n/),s=n.slice().sort((o,a)=>o.lineNum-a.lineNum);switch(t?.showSourceCode||"no"){case"all":let o=0;for(let a=1;a<=r.length;a++){let c=r[a-1],l=s[o];for(c&&l&&(i+=N0(c,a,t));s.length>o&&l.lineNum===a;){let u=s[o++];u&&(i+=Um(u,r,u.lineNum,{...t,inlineSource:!1}))}}for(;s.length>o;){let a=s[o++];a&&(i+=Um(a,[],0,{...t,inlineSource:!1}))}return i;case"issues":case"no":for(let a of n)i+=Um(a,r,a.lineNum,{inlineSource:t?.showSourceCode!=="no"});return i}}function Um(n,e,t,i){if(i?.inlineSource){let s=YR(e,t),o=n.linePos>0?`${" ".repeat(n.linePos+5)}^^^ `:"";return` ${s}${o}${n.type.toUpperCase()}: ${n.message} -`}let r=n.type==="error"?"red":"orange";return i?.html?`
${n.type.toUpperCase()}: ${n.message}
`:`${n.type.toUpperCase()}: ${n.message}`}function WR(n,e,t){let i="";for(let r=e-2;r<=e;r++){let s=n[r-1];s!==void 0&&(i+=N0(s,e,t))}return i}function N0(n,e,t){let i=t?.html?HR(n):n;return`${jR(String(e),4)}: ${i}${t?.html?"
":` -`}`}function jR(n,e){let t="";for(let i=n.length;i",">").replaceAll('"',""").replaceAll("'","'")}var F0=C(()=>{});function YR(n){return qR(n.source)||n.id||zn(`unnamed ${n.stage}-shader`)}function qR(n,e="unnamed"){return/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(n)?.[1]??e}var kr,$m=C(()=>{He();ut();Ws();F0();kr=class n extends te{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,t){t={...t,debugShaders:t.debugShaders||e.props.debugShaders||"errors"},super(e,{id:YR(t),...t},n.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(){let e=this.props.debugShaders;switch(e){case"never":return;case"errors":if(this.compilationStatus==="success")return;break;case"warnings":case"always":break}try{let t=await this.getCompilationInfo();if(e==="warnings"&&t?.length===0)return;this._displayShaderLog(t,this.id)}catch(t){N.warn(`Shader ${this.id}: failed to fetch compilation info during debug logging`,t)()}}_displayShaderLog(e,t){if(typeof document>"u"||!document?.createElement)return;let i=t,r=`${this.stage} shader "${i}"`,s=D0(e,this.source,{showSourceCode:"all",html:!0}),o=this.getTranslatedSource(),a=document.createElement("div");a.innerHTML=`

Compilation error in ${r}

+`}let r=n.type==="error"?"red":"orange";return i?.html?`
${n.type.toUpperCase()}: ${n.message}
`:`${n.type.toUpperCase()}: ${n.message}`}function YR(n,e,t){let i="";for(let r=e-2;r<=e;r++){let s=n[r-1];s!==void 0&&(i+=N0(s,e,t))}return i}function N0(n,e,t){let i=t?.html?ZR(n):n;return`${qR(String(e),4)}: ${i}${t?.html?"
":` +`}`}function qR(n,e){let t="";for(let i=n.length;i",">").replaceAll('"',""").replaceAll("'","'")}var F0=C(()=>{});function XR(n){return KR(n.source)||n.id||zn(`unnamed ${n.stage}-shader`)}function KR(n,e="unnamed"){return/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(n)?.[1]??e}var kr,$m=C(()=>{He();ut();Ws();F0();kr=class n extends te{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,t){t={...t,debugShaders:t.debugShaders||e.props.debugShaders||"errors"},super(e,{id:XR(t),...t},n.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(){let e=this.props.debugShaders;switch(e){case"never":return;case"errors":if(this.compilationStatus==="success")return;break;case"warnings":case"always":break}try{let t=await this.getCompilationInfo();if(e==="warnings"&&t?.length===0)return;this._displayShaderLog(t,this.id)}catch(t){N.warn(`Shader ${this.id}: failed to fetch compilation info during debug logging`,t)()}}_displayShaderLog(e,t){if(typeof document>"u"||!document?.createElement)return;let i=t,r=`${this.stage} shader "${i}"`,s=D0(e,this.source,{showSourceCode:"all",html:!0}),o=this.getTranslatedSource(),a=document.createElement("div");a.innerHTML=`

Compilation error in ${r}


-
${s}
`,o&&(a.innerHTML+=`

Translated Source



${o}
`),a.style.top="0",a.style.left="0",a.style.background="white",a.style.position="fixed",a.style.zIndex="9999",a.style.maxWidth="100vw",a.style.maxHeight="100vh",a.style.overflowY="auto",document.body.appendChild(a),a.querySelector(".luma-compiler-log-error")?.scrollIntoView(),a.querySelector("button#close").onclick=()=>{a.remove()},a.querySelector("button#copy").onclick=()=>{navigator.clipboard.writeText(this.source)}}static defaultProps={...te.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0}}});var Rr,z0=C(()=>{He();zm();ut();Rr=class n extends te{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(e,t={}){super(e,t,n.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(e){let t=this.colorAttachments.map(r=>r.texture.clone(e)),i=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,...e,colorAttachments:t,depthStencilAttachment:i})}resize(e){let t=!e;if(e){let[i,r]=Array.isArray(e)?e:[e.width,e.height];t=t||r!==this.height||i!==this.width,this.width=i,this.height=r}t&&(N.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map((t,i)=>{if(typeof t=="string"){let r=this.createColorTexture(t,i);return this.attachResource(r),r.view}return t instanceof me?t.view:t});let e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){let t=this.createDepthStencilTexture(e);this.attachResource(t),this.depthStencilAttachment=t.view}else e instanceof me?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,t){return this.device.createTexture({id:`${this.id}-color-attachment-${t}`,usage:me.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(e){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:me.RENDER_ATTACHMENT|me.SAMPLE,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){if(this.colorAttachments.forEach((i,r)=>{let s=i.texture.clone({width:e,height:t});this.destroyAttachedResource(i),this.colorAttachments[r]=s.view,this.attachResource(s.view)}),this.depthStencilAttachment){let i=this.depthStencilAttachment.texture.clone({width:e,height:t});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=i.view,this.attachResource(i)}this.updateAttachments()}static defaultProps={...te.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null}}});var Xt,Gm=C(()=>{He();Xt=class n extends te{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";sharedRenderPipeline=null;get isPending(){return this.linkStatus==="pending"||this.vs.compilationStatus==="pending"||this.fs?.compilationStatus==="pending"}get isErrored(){return this.linkStatus==="error"||this.vs.compilationStatus==="error"||this.fs?.compilationStatus==="error"}constructor(e,t){super(e,t,n.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[],this.sharedRenderPipeline=this.props._sharedRenderPipeline||null}static defaultProps={...te.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},varyings:void 0,bufferMode:void 0,disableWarnings:!1,_sharedRenderPipeline:void 0,_uniformBlockLayouts:[],bindings:void 0,bindGroups:void 0}}});var ka,U0=C(()=>{He();ka=class extends te{get[Symbol.toStringTag](){return"SharedRenderPipeline"}constructor(e,t){super(e,t,{...te.defaultProps,handle:void 0,vs:void 0,fs:void 0,varyings:void 0,bufferMode:void 0})}}});var Hi,Vm=C(()=>{He();Hi=class n extends te{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(e,t){super(e,t,n.defaultProps),this.shaderLayout=t.shaderLayout}static defaultProps={...te.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0}}});var Ir,$0=C(()=>{Vm();Gm();ut();Ws();Ir=class n{static defaultProps={...Xt.defaultProps};static getDefaultPipelineFactory(e){let t=e.getModuleData("@luma.gl/core");return t.defaultPipelineFactory||=new n(e),t.defaultPipelineFactory}device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};_sharedRenderPipelineCache={};get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}constructor(e){this.device=e}createRenderPipeline(e){if(!this.device.props._cachePipelines)return this.device.createRenderPipeline(e);let t={...Xt.defaultProps,...e},i=this._renderPipelineCache,r=this._hashRenderPipeline(t),s=i[r]?.resource;if(s)i[r].useCount++,this.device.props.debugFactories&&N.log(3,`${this}: ${i[r].resource} reused, count=${i[r].useCount}, (id=${e.id})`)();else{let o=this.device.type==="webgl"&&this.device.props._sharePipelines?this.createSharedRenderPipeline(t):void 0;s=this.device.createRenderPipeline({...t,id:t.id?`${t.id}-cached`:zn("unnamed-cached"),_sharedRenderPipeline:o}),s.hash=r,i[r]={resource:s,useCount:1},this.device.props.debugFactories&&N.log(3,`${this}: ${s} created, count=${i[r].useCount}`)()}return s}createComputePipeline(e){if(!this.device.props._cachePipelines)return this.device.createComputePipeline(e);let t={...Hi.defaultProps,...e},i=this._computePipelineCache,r=this._hashComputePipeline(t),s=i[r]?.resource;return s?(i[r].useCount++,this.device.props.debugFactories&&N.log(3,`${this}: ${i[r].resource} reused, count=${i[r].useCount}, (id=${e.id})`)()):(s=this.device.createComputePipeline({...t,id:t.id?`${t.id}-cached`:void 0}),s.hash=r,i[r]={resource:s,useCount:1},this.device.props.debugFactories&&N.log(3,`${this}: ${s} created, count=${i[r].useCount}`)()),s}release(e){if(!this.device.props._cachePipelines){e.destroy();return}let t=this._getCache(e),i=e.hash;t[i].useCount--,t[i].useCount===0?(this._destroyPipeline(e),this.device.props.debugFactories&&N.log(3,`${this}: ${e} released and destroyed`)()):t[i].useCount<0?(N.error(`${this}: ${e} released, useCount < 0, resetting`)(),t[i].useCount=0):this.device.props.debugFactories&&N.log(3,`${this}: ${e} released, count=${t[i].useCount}`)()}createSharedRenderPipeline(e){let t=this._hashSharedRenderPipeline(e),i=this._sharedRenderPipelineCache[t];return i||(i={resource:this.device._createSharedRenderPipelineWebGL(e),useCount:0},this._sharedRenderPipelineCache[t]=i),i.useCount++,i.resource}releaseSharedRenderPipeline(e){if(!e.sharedRenderPipeline)return;let t=this._hashSharedRenderPipeline(e.sharedRenderPipeline.props),i=this._sharedRenderPipelineCache[t];i&&(i.useCount--,i.useCount===0&&(i.resource.destroy(),delete this._sharedRenderPipelineCache[t]))}_destroyPipeline(e){let t=this._getCache(e);return this.device.props._destroyPipelines?(delete t[e.hash],e.destroy(),e instanceof Xt&&this.releaseSharedRenderPipeline(e),!0):!1}_getCache(e){let t;if(e instanceof Hi&&(t=this._computePipelineCache),e instanceof Xt&&(t=this._renderPipelineCache),!t)throw new Error(`${this}`);if(!t[e.hash])throw new Error(`${this}: ${e} matched incorrect entry`);return t}_hashComputePipeline(e){let{type:t}=this.device,i=this._getHash(e.shader.source),r=this._getHash(JSON.stringify(e.shaderLayout));return`${t}/C/${i}SL${r}`}_hashRenderPipeline(e){let t=e.vs?this._getHash(e.vs.source):0,i=e.fs?this._getHash(e.fs.source):0,r=this._getWebGLVaryingHash(e),s=this._getHash(JSON.stringify(e.shaderLayout)),o=this._getHash(JSON.stringify(e._uniformBlockLayouts)),a=this._getHash(JSON.stringify(e.bufferLayout)),{type:c}=this.device;switch(c){case"webgl":let l=this._getHash(JSON.stringify(e.parameters));return`${c}/R/${t}/${i}V${r}T${e.topology}P${l}SL${s}UBL${o}BL${a}`;case"webgpu":default:let u=this._getHash(JSON.stringify({vertexEntryPoint:e.vertexEntryPoint,fragmentEntryPoint:e.fragmentEntryPoint})),f=this._getHash(JSON.stringify(e.parameters)),d=this._getWebGPUAttachmentHash(e);return`${c}/R/${t}/${i}V${r}T${e.topology}EP${u}P${f}SL${s}BL${a}A${d}`}}_hashSharedRenderPipeline(e){let t=e.vs?this._getHash(e.vs.source):0,i=e.fs?this._getHash(e.fs.source):0,r=this._getWebGLVaryingHash(e);return`webgl/S/${t}/${i}V${r}`}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}_getWebGLVaryingHash(e){let{varyings:t=[],bufferMode:i=null}=e;return this._getHash(JSON.stringify({varyings:t,bufferMode:i}))}_getWebGPUAttachmentHash(e){let t=e.colorAttachmentFormats??[this.device.preferredColorFormat],i=e.depthStencilAttachmentFormat??(e.parameters?.depthWriteEnabled?this.device.preferredDepthFormat:null);return this._getHash(JSON.stringify({colorAttachmentFormats:t,depthStencilAttachmentFormat:i}))}}});var Br,G0=C(()=>{$m();ut();Br=class n{static defaultProps={...kr.defaultProps};static getDefaultShaderFactory(e){let t=e.getModuleData("@luma.gl/core");return t.defaultShaderFactory||=new n(e),t.defaultShaderFactory}device;_cache={};get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}constructor(e){this.device=e}createShader(e){if(!this.device.props._cacheShaders)return this.device.createShader(e);let t=this._hashShader(e),i=this._cache[t];if(i)i.useCount++,this.device.props.debugFactories&&N.log(3,`${this}: Reusing shader ${i.resource.id} count=${i.useCount}`)();else{let r=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[t]=i={resource:r,useCount:1},this.device.props.debugFactories&&N.log(3,`${this}: Created new shader ${r.id}`)()}return i.resource}release(e){if(!this.device.props._cacheShaders){e.destroy();return}let t=this._hashShader(e),i=this._cache[t];if(i)if(i.useCount--,i.useCount===0)this.device.props._destroyShaders&&(delete this._cache[t],i.resource.destroy(),this.device.props.debugFactories&&N.log(3,`${this}: Releasing shader ${e.id}, destroyed`)());else{if(i.useCount<0)throw new Error(`ShaderFactory: Shader ${e.id} released too many times`);this.device.props.debugFactories&&N.log(3,`${this}: Releasing shader ${e.id} count=${i.useCount}`)()}}_hashShader(e){return`${e.stage}:${e.source}`}}});function Nu(n,e,t){let i=n.bindings.find(r=>r.name===e||`${r.name.toLocaleLowerCase()}uniforms`===e.toLocaleLowerCase());return!i&&!t?.ignoreWarnings&&N.warn(`Binding ${e} not set: Not found in shader layout.`)(),i||null}function Or(n,e){if(!e)return{};if(ZR(e))return Object.fromEntries(Object.entries(e).map(([r,s])=>[Number(r),{...s}]));let t={};for(let[i,r]of Object.entries(e)){let o=Nu(n,i)?.group??0;t[o]||={},t[o][i]=r}return t}function js(n){let e={};for(let t of Object.values(n))Object.assign(e,t);return e}function ZR(n){let e=Object.keys(n);return e.length>0&&e.every(t=>/^\d+$/.test(t))}var V0=C(()=>{ut()});var Ra,W0=C(()=>{He();Ra=class n extends te{static defaultClearColor=[0,0,0,1];static defaultClearDepth=1;static defaultClearStencil=0;get[Symbol.toStringTag](){return"RenderPass"}constructor(e,t,i=n.defaultProps){t=n.normalizeProps(e,t),super(e,t,i)}static normalizeProps(e,t){return t}static defaultProps={...te.defaultProps,framebuffer:null,resolveTargets:void 0,parameters:void 0,clearColor:n.defaultClearColor,clearColors:void 0,clearDepth:n.defaultClearDepth,clearStencil:n.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0}}});var Ia,j0=C(()=>{He();Ia=class n extends te{get[Symbol.toStringTag](){return"CommandEncoder"}_timeProfilingQuerySet=null;_timeProfilingSlotCount=0;_gpuTimeMs;constructor(e,t){super(e,t,n.defaultProps),this._timeProfilingQuerySet=t.timeProfilingQuerySet??null,this._timeProfilingSlotCount=0,this._gpuTimeMs=void 0}async resolveTimeProfilingQuerySet(){if(this._gpuTimeMs=void 0,!this._timeProfilingQuerySet)return;let e=Math.floor(this._timeProfilingSlotCount/2);if(e<=0)return;let t=e*2,i=await this._timeProfilingQuerySet.readResults({firstQuery:0,queryCount:t}),r=0n;for(let s=0;s=this._timeProfilingQuerySet.props.count?t:(this._timeProfilingSlotCount+=2,{...t,timestampQuerySet:this._timeProfilingQuerySet,beginTimestampIndex:i,endTimestampIndex:i+1})}_supportsTimestampQueries(){return this.device.features.has("timestamp-query")}static defaultProps={...te.defaultProps,measureExecutionTime:void 0,timeProfilingQuerySet:void 0}}});var Ba,H0=C(()=>{He();Ba=class n extends te{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,t){super(e,t,n.defaultProps)}static defaultProps={...te.defaultProps}}});var Oa,Y0=C(()=>{He();Oa=class n extends te{static defaultProps={...te.defaultProps,shaderLayout:void 0,bufferLayout:[]};get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;indexBuffer=null;attributes;constructor(e,t){super(e,t,n.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null)}getBufferSlot(e){return null}getDrawValidationError(){return null}setConstantWebGL(e,t){this.device.reportError(new Error("constant attributes not supported"),this)()}}});var Da,q0=C(()=>{He();Da=class n extends te{static defaultProps={...te.defaultProps,layout:void 0,buffers:{}};get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,n.defaultProps)}}});var Na,Z0=C(()=>{He();Na=class n extends te{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){super(e,t,n.defaultProps)}static defaultProps={...te.defaultProps,type:void 0,count:void 0}}});var Fa,X0=C(()=>{He();Fa=class n extends te{static defaultProps={...te.defaultProps};get[Symbol.toStringTag](){return"Fence"}constructor(e,t={}){super(e,t,n.defaultProps)}}});function Hs(n){let e=Fu(n),t=JR[e];if(!t)throw new Error(`Unsupported variable shader type: ${n}`);return t}function K0(n){let e=Q0(n),t=QR[e];if(!t)throw new Error(`Unsupported attribute shader type: ${n}`);let[i,r]=t,s=i==="i32"||i==="u32",o=i!=="u32",a=KR[i]*r;return{primitiveType:i,components:r,byteLength:a,integer:s,signed:o}}function XR(n,e){return e===1?n:`vec${e}<${n}>`}function Q0(n){return eI[n]||n}function Fu(n){return tI[n]||n}var Wm,kt,KR,QR,JR,eI,tI,za=C(()=>{Wm=class{getVariableShaderTypeInfo(e){return Hs(e)}getAttributeShaderTypeInfo(e){return K0(e)}makeShaderAttributeType(e,t){return XR(e,t)}resolveAttributeShaderTypeAlias(e){return Q0(e)}resolveVariableShaderTypeAlias(e){return Fu(e)}};kt=new Wm,KR={f32:4,f16:2,i32:4,u32:4},QR={f32:["f32",1],"vec2":["f32",2],"vec3":["f32",3],"vec4":["f32",4],f16:["f16",1],"vec2":["f16",2],"vec3":["f16",3],"vec4":["f16",4],i32:["i32",1],"vec2":["i32",2],"vec3":["i32",3],"vec4":["i32",4],u32:["u32",1],"vec2":["u32",2],"vec3":["u32",3],"vec4":["u32",4]},JR={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2":{type:"f32",components:2},"vec3":{type:"f32",components:3},"vec4":{type:"f32",components:4},"vec2":{type:"f16",components:2},"vec3":{type:"f16",components:3},"vec4":{type:"f16",components:4},"vec2":{type:"i32",components:2},"vec3":{type:"i32",components:3},"vec4":{type:"i32",components:4},"vec2":{type:"u32",components:2},"vec3":{type:"u32",components:3},"vec4":{type:"u32",components:4},"mat2x2":{type:"f32",components:4},"mat2x3":{type:"f32",components:6},"mat2x4":{type:"f32",components:8},"mat3x2":{type:"f32",components:6},"mat3x3":{type:"f32",components:9},"mat3x4":{type:"f32",components:12},"mat4x2":{type:"f32",components:8},"mat4x3":{type:"f32",components:12},"mat4x4":{type:"f32",components:16},"mat2x2":{type:"f16",components:4},"mat2x3":{type:"f16",components:6},"mat2x4":{type:"f16",components:8},"mat3x2":{type:"f16",components:6},"mat3x3":{type:"f16",components:9},"mat3x4":{type:"f16",components:12},"mat4x2":{type:"f16",components:8},"mat4x3":{type:"f16",components:12},"mat4x4":{type:"f16",components:16},"mat2x2":{type:"i32",components:4},"mat2x3":{type:"i32",components:6},"mat2x4":{type:"i32",components:8},"mat3x2":{type:"i32",components:6},"mat3x3":{type:"i32",components:9},"mat3x4":{type:"i32",components:12},"mat4x2":{type:"i32",components:8},"mat4x3":{type:"i32",components:12},"mat4x4":{type:"i32",components:16},"mat2x2":{type:"u32",components:4},"mat2x3":{type:"u32",components:6},"mat2x4":{type:"u32",components:8},"mat3x2":{type:"u32",components:6},"mat3x3":{type:"u32",components:9},"mat3x4":{type:"u32",components:12},"mat4x2":{type:"u32",components:8},"mat4x3":{type:"u32",components:12},"mat4x4":{type:"u32",components:16}},eI={vec2i:"vec2",vec3i:"vec3",vec4i:"vec4",vec2u:"vec2",vec3u:"vec3",vec4u:"vec4",vec2f:"vec2",vec3f:"vec3",vec4f:"vec4",vec2h:"vec2",vec3h:"vec3",vec4h:"vec4"},tI={vec2i:"vec2",vec3i:"vec3",vec4i:"vec4",vec2u:"vec2",vec3u:"vec3",vec4u:"vec4",vec2f:"vec2",vec3f:"vec3",vec4f:"vec4",vec2h:"vec2",vec3h:"vec3",vec4h:"vec4",mat2x2f:"mat2x2",mat2x3f:"mat2x3",mat2x4f:"mat2x4",mat3x2f:"mat3x2",mat3x3f:"mat3x3",mat3x4f:"mat3x4",mat4x2f:"mat4x2",mat4x3f:"mat4x3",mat4x4f:"mat4x4",mat2x2i:"mat2x2",mat2x3i:"mat2x3",mat2x4i:"mat2x4",mat3x2i:"mat3x2",mat3x3i:"mat3x3",mat3x4i:"mat3x4",mat4x2i:"mat4x2",mat4x3i:"mat4x3",mat4x4i:"mat4x4",mat2x2u:"mat2x2",mat2x3u:"mat2x3",mat2x4u:"mat2x4",mat3x2u:"mat3x2",mat3x3u:"mat3x3",mat3x4u:"mat3x4",mat4x2u:"mat4x2",mat4x3u:"mat4x3",mat4x4u:"mat4x4",mat2x2h:"mat2x2",mat2x3h:"mat2x3",mat2x4h:"mat2x4",mat3x2h:"mat3x2",mat3x3h:"mat3x3",mat3x4h:"mat3x4",mat4x2h:"mat4x2",mat4x3h:"mat4x3",mat4x4h:"mat4x4"}});function Dr(n,e={}){let t={...n},i=e.layout??"std140",r={},s=0;for(let[o,a]of Object.entries(t))s=jm(r,o,a,s,i);return s=Zt(s,Yi(t,i)),{layout:i,byteLength:s*4,uniformTypes:t,fields:r}}function Ua(n,e){let t=Fu(n),i=Hs(t),r=/^mat(\d)x(\d)<.+>$/.exec(t);if(r){let o=Number(r[1]),a=Number(r[2]),c=J0(a,t,i.type,e),l=iI(c.size,c.alignment,e);return{alignment:c.alignment,size:o*l,components:o*a,columns:o,rows:a,columnStride:l,shaderType:t,type:i.type}}let s=/^vec(\d)<.+>$/.exec(t);return s?J0(Number(s[1]),t,i.type,e):{alignment:1,size:1,components:1,columns:1,rows:1,columnStride:1,shaderType:t,type:i.type}}function Hm(n){return!!n&&typeof n=="object"&&!Array.isArray(n)}function jm(n,e,t,i,r){if(typeof t=="string"){let s=Ua(t,r),o=Zt(i,s.alignment);return n[e]={offset:o,...s},o+s.size}if(Array.isArray(t)){if(Array.isArray(t[0]))throw new Error(`Nested arrays are not supported for ${e}`);let s=t[0],o=t[1],a=tw(s,r),c=Zt(i,Yi(t,r));for(let l=0;l{Mu();za()});function Ym(n){return(!Uu||Uu.byteLength{});function sI(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Ys(n){return Array.isArray(n)?n.length===0||typeof n[0]=="number":sI(n)}var Xm=C(()=>{});function oI(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&!ArrayBuffer.isView(n)}function aI(n,e,t){return Array.prototype.slice.call(n,e,t)}var $u,iw=C(()=>{Zm();Xm();ut();zu();$u=class{layout;constructor(e){this.layout=e}has(e){return!!this.layout.fields[e]}get(e){let t=this.layout.fields[e];return t?{offset:t.offset,size:t.size}:void 0}getFlatUniformValues(e){let t={};for(let[i,r]of Object.entries(e)){let s=this.layout.uniformTypes[i];s?this._flattenCompositeValue(t,i,s,r):this.layout.fields[i]&&(t[i]=r)}return t}getData(e){let t=Ym(this.layout.byteLength);new Uint8Array(t,0,this.layout.byteLength).fill(0);let i={i32:new Int32Array(t),u32:new Uint32Array(t),f32:new Float32Array(t),f16:new Uint16Array(t)},r=this.getFlatUniformValues(e);for(let[s,o]of Object.entries(r))this._writeLeafValue(i,s,o);return new Uint8Array(t,0,this.layout.byteLength)}_flattenCompositeValue(e,t,i,r){if(r!==void 0){if(typeof i=="string"||this.layout.fields[t]){e[t]=r;return}if(Array.isArray(i)){let s=i[0],o=i[1];if(Array.isArray(s))throw new Error(`Nested arrays are not supported for ${t}`);if(typeof s=="string"&&Ys(r)){this._flattenPackedArray(e,t,s,o,r);return}if(!Array.isArray(r)){N.warn(`Unsupported uniform array value for ${t}:`,r)();return}for(let a=0;a=o.length)break;c===1?e[`${t}[${l}]`]=Number(o[u]):e[`${t}[${l}]`]=aI(s,u,u+c)}}_writeLeafValue(e,t,i){let r=this.layout.fields[t];if(!r){N.warn(`Uniform ${t} not found in layout`)();return}let{type:s,components:o,columns:a,rows:c,offset:l,columnStride:u}=r,f=e[s];if(o===1){f[l]=Number(i);return}let d=i;if(a===1){for(let p=0;ps)return!1;for(let o=0;o{Xm();cI=128});var Gu,aw=C(()=>{ow();Gu=class{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(e){if(this.name=e?.name||"unnamed",e?.name&&e?.shaderLayout){let t=e?.shaderLayout.bindings?.find(r=>r.type==="uniform"&&r.name===e?.name);if(!t)throw new Error(e?.name);let i=t;for(let r of i.uniforms||[])this.bindingLayout[r.name]=r}}setUniforms(e){for(let[t,i]of Object.entries(e))this._setUniform(t,i)&&!this.needsRedraw&&this.setNeedsRedraw(`${this.name}.${t}=${i}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){return rw(this.uniforms[e],t)?!1:(this.uniforms[e]=sw(t),this.modifiedUniforms[e]=!0,this.modified=!0,!0)}}});function uI(n){return n.type==="webgpu"?"wgsl-uniform":"std140"}var lI,Nr,cw=C(()=>{Tu();ut();zu();aw();iw();lI=1024,Nr=class{device;uniformBlocks=new Map;shaderBlockLayouts=new Map;shaderBlockWriters=new Map;uniformBuffers=new Map;constructor(e,t){this.device=e;for(let[i,r]of Object.entries(t)){let s=i,o=Dr(r.uniformTypes??{},{layout:r.layout??uI(e)}),a=new $u(o);this.shaderBlockLayouts.set(s,o),this.shaderBlockWriters.set(s,a);let c=new Gu({name:i});c.setUniforms(a.getFlatUniformValues(r.defaultUniforms||{})),this.uniformBlocks.set(s,c)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e,t){for(let[i,r]of Object.entries(e)){let s=i,a=this.shaderBlockWriters.get(s)?.getFlatUniformValues(r||{});this.uniformBlocks.get(s)?.setUniforms(a||{})}this.updateUniformBuffers(t)}getUniformBufferByteLength(e){let t=this.shaderBlockLayouts.get(e)?.byteLength||0;return Math.max(t,lI)}getUniformBufferData(e){let t=this.uniformBlocks.get(e)?.getAllUniforms()||{};return this.shaderBlockWriters.get(e)?.getData(t)||new Uint8Array(0)}createUniformBuffer(e,t){t&&this.setUniforms(t);let i=this.getUniformBufferByteLength(e),r=this.device.createBuffer({usage:ie.UNIFORM|ie.COPY_DST,byteLength:i}),s=this.getUniformBufferData(e);return r.write(s),r}getManagedUniformBuffer(e){if(!this.uniformBuffers.get(e)){let t=this.getUniformBufferByteLength(e),i=this.device.createBuffer({usage:ie.UNIFORM|ie.COPY_DST,byteLength:t});this.uniformBuffers.set(e,i)}return this.uniformBuffers.get(e)}updateUniformBuffers(e){let t=!1;for(let i of this.uniformBlocks.keys()){let r=this.updateUniformBuffer(i,e);t||=r}return t&&N.log(3,`UniformStore.updateUniformBuffers(): ${t}`)(),t}updateUniformBuffer(e,t){let i=this.uniformBlocks.get(e),r=this.uniformBuffers.get(e),s=!1;if(r&&i?.needsRedraw){s||=i.needsRedraw;let o=this.getUniformBufferData(e);if(r=this.uniformBuffers.get(e),r&&(t?this.device.writeBufferViaCommandEncoder(t,r,o):r.write(o)),N.level>=4){let a=this.uniformBlocks.get(e)?.getAllUniforms();N.log(4,`Writing to uniform buffer ${String(e)}`,o,a)()}}return s}}});function qs(n){return n.attributes?n.attributes.map(e=>e.attribute):[n.name]}function Km(n){return Object.fromEntries(n.attributes.map(e=>[e.name,e.location]))}function Vu(n){let e=1/0;for(let t of n)t!==void 0&&(e=Math.min(e,t));return e}function Qm(n,e,t){fI(e);let i=new Map;for(let r of e){let s=dI(r);if(r.attributes)for(let o of r.attributes)i.has(o.attribute)||i.set(o.attribute,{bufferName:r.name,stepMode:r.stepMode,vertexFormat:o.format,byteOffset:o.byteOffset,byteStride:s});else r.format&&!i.has(r.name)&&i.set(r.name,{bufferName:r.name,stepMode:r.stepMode,vertexFormat:r.format,byteOffset:0,byteStride:s})}return n.attributes.map(r=>{let s=i.get(r.name);!s&&t?.warnOnMissingBufferLayout&&N.warn(`layout for attribute "${r.name}" not present in buffer layout`)();let o=kt.getAttributeShaderTypeInfo(r.type),a=s?.vertexFormat||Pe.getCompatibleVertexFormat(o);return{attributeName:r.name,bufferName:s?.bufferName||r.name,location:r.location,vertexFormat:a,byteOffset:s?.byteOffset??0,byteStride:s?.byteStride??Pe.getVertexFormatInfo(a).byteLength,stepMode:s?.stepMode||r.stepMode||(r.name.startsWith("instance")?"instance":"vertex")}}).sort((r,s)=>r.location-s.location)}function fI(n){for(let e of n)(e.attributes&&e.format||!e.attributes&&!e.format)&&N.warn(`BufferLayout ${e.name} must have either 'attributes' or 'format' field`)()}function dI(n){if(typeof n.byteStride=="number")return n.byteStride;if(n.attributes){let e=0;for(let t of n.attributes)e+=Pe.getVertexFormatInfo(t.format).byteLength;return e}return Pe.getVertexFormatInfo(n.format).byteLength}var Jm=C(()=>{ut();za();Pa()});function $a(n,e){let t={},i=Qm(n,e,{warnOnMissingBufferLayout:!0});for(let r of i){let s=hI(n,r);t[r.attributeName]=s}return t}function hI(n,e){let t=pI(n,e.attributeName),i=kt.getAttributeShaderTypeInfo(t.type),r=e.vertexFormat,s=Pe.getVertexFormatInfo(r);return{attributeName:e.attributeName,bufferName:e.bufferName,location:t.location,shaderType:t.type,primitiveType:i.primitiveType,shaderComponents:i.components,vertexFormat:r,bufferDataType:s.type,bufferComponents:s.components,normalized:s.normalized,integer:i.integer,stepMode:e.stepMode,byteOffset:e.byteOffset,byteStride:e.byteStride}}function pI(n,e){let t=n.attributes.find(i=>i.name===e);return t||N.warn(`shader layout attribute "${e}" not present in shader`)(),t||null}var lw=C(()=>{ut();za();Pa();Jm()});var J=C(()=>{r0();s0();C0();R0();I0();Tu();zm();B0();O0();$m();Fm();z0();Gm();U0();$0();G0();W0();Vm();j0();H0();Y0();q0();Z0();X0();zu();cw();Au();Mu();za();Pa();Ou();ut();V0();Dm();Zm();lw();Jm()});function Ga(n=[],e){let t=[],i={},r={},s={},o={};for(let a of n)uw({modules:t,defines:i,injections:r,vertexInputs:s,varyings:o},a),uw({modules:t,defines:i,injections:r,vertexInputs:s,varyings:o},a[e]);for(let a of Object.keys(o))if(s[a])throw new Error(`ShaderPlugin name "${a}" cannot be both a vertex input and a varying`);return{modules:t,defines:i,injections:r,vertexInputs:s,varyings:o}}function Va(n=[],e=[]){let t=[...n],i=new Set(t.map(r=>r.name));for(let r of e)i.has(r.name)||(t.push(r),i.add(r.name));return t}function uw(n,e){if(e){e.modules?.length&&n.modules.push(...e.modules),e.defines&&Object.assign(n.defines,e.defines);for(let[t,i]of Object.entries(e.vertexInputs||{})){fw(t,"vertex input");let r=n.vertexInputs[t];if(r&&r!==i)throw new Error(`ShaderPlugin vertex input "${t}" has conflicting types "${r}" and "${i}"`);n.vertexInputs[t]=i}for(let[t,i]of Object.entries(e.varyings||{})){fw(t,"varying");let r=gI(t,i),s=n.varyings[t];if(s&&(s.type!==r.type||s.interpolation!==r.interpolation))throw new Error(`ShaderPlugin varying "${t}" has conflicting declarations "${s.type}/${s.interpolation}" and "${r.type}/${r.interpolation}"`);n.varyings[t]=r}for(let t of e.injections||[])_I(t.target),n.injections[t.target]||(n.injections[t.target]=[]),n.injections[t.target].push({injection:t.injection,order:t.order??0})}}function fw(n,e){if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(n)||n.startsWith("_luma_"))throw new Error(`ShaderPlugin ${e} "${n}" must be a valid non-reserved identifier`)}function gI(n,e){let{primitiveType:t}=kt.getAttributeShaderTypeInfo(e.type),i=t==="i32"||t==="u32",r=e.interpolation||(i?"flat":"smooth");if(i&&r==="smooth")throw new Error(`ShaderPlugin integer varying "${n}" must use flat interpolation`);return{type:e.type,interpolation:r}}function _I(n){if(!mI.test(n))throw new Error(`ShaderPlugin injection target "${n}" must be a named shader anchor or hook`)}var mI,dw=C(()=>{J();mI=/^(vs|fs):(?:#(?:decl|main-start|main-end)|[A-Za-z_][\w-]*)$/});function Wa(n){return`${n.name}Uniforms`}function pw(n,e){let t=e==="wgsl"?n.source:e==="vertex"?n.vs:n.fs;if(!t)return null;let i=Wa(n);return vI(t,e==="wgsl"?"wgsl":"glsl",i)}function mw(n,e){let t=Object.keys(n.uniformTypes||{});if(!t.length)return null;let i=pw(n,e);return i?{moduleName:n.name,uniformBlockName:Wa(n),stage:e,expectedUniformNames:t,actualUniformNames:i,matches:EI(t,i)}:null}function eg(n,e,t={}){let i=mw(n,e);if(!i||i.matches)return i;let r=SI(i);return t.log?.error?.(r,i)(),t.throwOnError!==!1&&yi(!1,r),i}function ja(n){let e=[],t=PI(n);for(let i of t.matchAll(bI)){let r=i[1]?.trim()||null;e.push({blockName:i[2],body:i[3],instanceName:i[4]||null,layoutQualifier:r,hasLayoutQualifier:!!r,isStd140:!!(r&&/\blayout\s*\([^)]*\bstd140\b[^)]*\)/.exec(r))})}return e}function tg(n,e,t,i){let r=ja(n).filter(o=>!o.isStd140),s=new Set;for(let o of r){if(s.has(o.blockName))continue;s.add(o.blockName);let a=i?.label?`${i.label} `:"",c=o.hasLayoutQualifier?`declares ${CI(o.layoutQualifier)} instead of layout(std140)`:"does not declare layout(std140)",l=`${a}${e} shader uniform block ${o.blockName} ${c}. luma.gl host-side shader block packing assumes explicit layout(std140) for GLSL uniform blocks. Add \`layout(std140)\` to the block declaration.`;t?.warn?.(l,o)()}return r}function vI(n,e,t){let i=e==="wgsl"?xI(n,t):wI(n,t);if(!i)return null;let r=[];for(let s of i.split(` -`)){let o=s.replace(/\/\/.*$/,"").trim();if(!o||o.startsWith("#"))continue;let a=e==="wgsl"?o.match(/^([A-Za-z0-9_]+)\s*:/):o.match(yI);a&&r.push(a[1])}return r}function xI(n,e){let t=new RegExp(`\\bstruct\\s+${e}\\b`,"m").exec(n);if(!t)return null;let i=n.indexOf("{",t.index);if(i<0)return null;let r=0;for(let s=i;si.blockName===e)?.body||null}function EI(n,e){if(n.length!==e.length)return!1;for(let t=0;t!t.includes(a)),r=t.filter(a=>!e.includes(a)),s=[`Expected ${e.length} fields, found ${t.length}.`],o=TI(e,t);return o&&s.push(o),i.length&&s.push(`Missing from shader block (${i.length}): ${hw(i)}.`),r.length&&s.push(`Unexpected in shader block (${r.length}): ${hw(r)}.`),e.length<=12&&t.length<=12&&(i.length||r.length)&&(s.push(`Expected: ${e.join(", ")}.`),s.push(`Actual: ${t.join(", ")}.`)),`${n.moduleName}: ${n.stage} shader uniform block ${n.uniformBlockName} does not match module.uniformTypes. ${s.join(" ")}`}function PI(n){return n.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"")}function CI(n){return n.replace(/\s+/g," ").trim()}function TI(n,e){let t=Math.min(n.length,e.length);for(let i=0;ie.length?`Shader block ends after field ${e.length}; expected next field ${n[e.length]}.`:e.length>n.length?`Shader block has extra field ${e.length}: ${e[n.length]}.`:null}function hw(n,e=8){if(n.length<=e)return n.join(", ");let t=n.length-e;return`${n.slice(0,e).join(", ")}, ... (${t} more)`}var yI,bI,ng=C(()=>{xu();yI=/^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/,bI=/((?:layout\s*\([^)]*\)\s*)*)uniform\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([\s\S]*?)\}\s*([A-Za-z_][A-Za-z0-9_]*)?\s*;/g});function gw(n){switch(n?.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU +
${s}
`,o&&(a.innerHTML+=`

Translated Source



${o}
`),a.style.top="0",a.style.left="0",a.style.background="white",a.style.position="fixed",a.style.zIndex="9999",a.style.maxWidth="100vw",a.style.maxHeight="100vh",a.style.overflowY="auto",document.body.appendChild(a),a.querySelector(".luma-compiler-log-error")?.scrollIntoView(),a.querySelector("button#close").onclick=()=>{a.remove()},a.querySelector("button#copy").onclick=()=>{navigator.clipboard.writeText(this.source)}}static defaultProps={...te.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0}}});var Rr,z0=C(()=>{He();zm();ut();Rr=class n extends te{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(e,t={}){super(e,t,n.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(e){let t=this.colorAttachments.map(r=>r.texture.clone(e)),i=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,...e,colorAttachments:t,depthStencilAttachment:i})}resize(e){let t=!e;if(e){let[i,r]=Array.isArray(e)?e:[e.width,e.height];t=t||r!==this.height||i!==this.width,this.width=i,this.height=r}t&&(N.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map((t,i)=>{if(typeof t=="string"){let r=this.createColorTexture(t,i);return this.attachResource(r),r.view}return t instanceof me?t.view:t});let e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){let t=this.createDepthStencilTexture(e);this.attachResource(t),this.depthStencilAttachment=t.view}else e instanceof me?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,t){return this.device.createTexture({id:`${this.id}-color-attachment-${t}`,usage:me.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(e){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:me.RENDER_ATTACHMENT|me.SAMPLE,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){if(this.colorAttachments.forEach((i,r)=>{let s=i.texture.clone({width:e,height:t});this.destroyAttachedResource(i),this.colorAttachments[r]=s.view,this.attachResource(s.view)}),this.depthStencilAttachment){let i=this.depthStencilAttachment.texture.clone({width:e,height:t});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=i.view,this.attachResource(i)}this.updateAttachments()}static defaultProps={...te.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null}}});var Zt,Gm=C(()=>{He();Zt=class n extends te{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";sharedRenderPipeline=null;get isPending(){return this.linkStatus==="pending"||this.vs.compilationStatus==="pending"||this.fs?.compilationStatus==="pending"}get isErrored(){return this.linkStatus==="error"||this.vs.compilationStatus==="error"||this.fs?.compilationStatus==="error"}constructor(e,t){super(e,t,n.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[],this.sharedRenderPipeline=this.props._sharedRenderPipeline||null}static defaultProps={...te.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},varyings:void 0,bufferMode:void 0,disableWarnings:!1,_sharedRenderPipeline:void 0,_uniformBlockLayouts:[],bindings:void 0,bindGroups:void 0}}});var ka,U0=C(()=>{He();ka=class extends te{get[Symbol.toStringTag](){return"SharedRenderPipeline"}constructor(e,t){super(e,t,{...te.defaultProps,handle:void 0,vs:void 0,fs:void 0,varyings:void 0,bufferMode:void 0})}}});var Hi,Vm=C(()=>{He();Hi=class n extends te{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(e,t){super(e,t,n.defaultProps),this.shaderLayout=t.shaderLayout}static defaultProps={...te.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0}}});var Ir,$0=C(()=>{Vm();Gm();ut();Ws();Ir=class n{static defaultProps={...Zt.defaultProps};static getDefaultPipelineFactory(e){let t=e.getModuleData("@luma.gl/core");return t.defaultPipelineFactory||=new n(e),t.defaultPipelineFactory}device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};_sharedRenderPipelineCache={};get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}constructor(e){this.device=e}createRenderPipeline(e){if(!this.device.props._cachePipelines)return this.device.createRenderPipeline(e);let t={...Zt.defaultProps,...e},i=this._renderPipelineCache,r=this._hashRenderPipeline(t),s=i[r]?.resource;if(s)i[r].useCount++,this.device.props.debugFactories&&N.log(3,`${this}: ${i[r].resource} reused, count=${i[r].useCount}, (id=${e.id})`)();else{let o=this.device.type==="webgl"&&this.device.props._sharePipelines?this.createSharedRenderPipeline(t):void 0;s=this.device.createRenderPipeline({...t,id:t.id?`${t.id}-cached`:zn("unnamed-cached"),_sharedRenderPipeline:o}),s.hash=r,i[r]={resource:s,useCount:1},this.device.props.debugFactories&&N.log(3,`${this}: ${s} created, count=${i[r].useCount}`)()}return s}createComputePipeline(e){if(!this.device.props._cachePipelines)return this.device.createComputePipeline(e);let t={...Hi.defaultProps,...e},i=this._computePipelineCache,r=this._hashComputePipeline(t),s=i[r]?.resource;return s?(i[r].useCount++,this.device.props.debugFactories&&N.log(3,`${this}: ${i[r].resource} reused, count=${i[r].useCount}, (id=${e.id})`)()):(s=this.device.createComputePipeline({...t,id:t.id?`${t.id}-cached`:void 0}),s.hash=r,i[r]={resource:s,useCount:1},this.device.props.debugFactories&&N.log(3,`${this}: ${s} created, count=${i[r].useCount}`)()),s}release(e){if(!this.device.props._cachePipelines){e.destroy();return}let t=this._getCache(e),i=e.hash;t[i].useCount--,t[i].useCount===0?(this._destroyPipeline(e),this.device.props.debugFactories&&N.log(3,`${this}: ${e} released and destroyed`)()):t[i].useCount<0?(N.error(`${this}: ${e} released, useCount < 0, resetting`)(),t[i].useCount=0):this.device.props.debugFactories&&N.log(3,`${this}: ${e} released, count=${t[i].useCount}`)()}createSharedRenderPipeline(e){let t=this._hashSharedRenderPipeline(e),i=this._sharedRenderPipelineCache[t];return i||(i={resource:this.device._createSharedRenderPipelineWebGL(e),useCount:0},this._sharedRenderPipelineCache[t]=i),i.useCount++,i.resource}releaseSharedRenderPipeline(e){if(!e.sharedRenderPipeline)return;let t=this._hashSharedRenderPipeline(e.sharedRenderPipeline.props),i=this._sharedRenderPipelineCache[t];i&&(i.useCount--,i.useCount===0&&(i.resource.destroy(),delete this._sharedRenderPipelineCache[t]))}_destroyPipeline(e){let t=this._getCache(e);return this.device.props._destroyPipelines?(delete t[e.hash],e.destroy(),e instanceof Zt&&this.releaseSharedRenderPipeline(e),!0):!1}_getCache(e){let t;if(e instanceof Hi&&(t=this._computePipelineCache),e instanceof Zt&&(t=this._renderPipelineCache),!t)throw new Error(`${this}`);if(!t[e.hash])throw new Error(`${this}: ${e} matched incorrect entry`);return t}_hashComputePipeline(e){let{type:t}=this.device,i=this._getHash(e.shader.source),r=this._getHash(JSON.stringify(e.shaderLayout));return`${t}/C/${i}SL${r}`}_hashRenderPipeline(e){let t=e.vs?this._getHash(e.vs.source):0,i=e.fs?this._getHash(e.fs.source):0,r=this._getWebGLVaryingHash(e),s=this._getHash(JSON.stringify(e.shaderLayout)),o=this._getHash(JSON.stringify(e._uniformBlockLayouts)),a=this._getHash(JSON.stringify(e.bufferLayout)),{type:c}=this.device;switch(c){case"webgl":let l=this._getHash(JSON.stringify(e.parameters));return`${c}/R/${t}/${i}V${r}T${e.topology}P${l}SL${s}UBL${o}BL${a}`;case"webgpu":default:let u=this._getHash(JSON.stringify({vertexEntryPoint:e.vertexEntryPoint,fragmentEntryPoint:e.fragmentEntryPoint})),f=this._getHash(JSON.stringify(e.parameters)),d=this._getWebGPUAttachmentHash(e);return`${c}/R/${t}/${i}V${r}T${e.topology}EP${u}P${f}SL${s}BL${a}A${d}`}}_hashSharedRenderPipeline(e){let t=e.vs?this._getHash(e.vs.source):0,i=e.fs?this._getHash(e.fs.source):0,r=this._getWebGLVaryingHash(e);return`webgl/S/${t}/${i}V${r}`}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}_getWebGLVaryingHash(e){let{varyings:t=[],bufferMode:i=null}=e;return this._getHash(JSON.stringify({varyings:t,bufferMode:i}))}_getWebGPUAttachmentHash(e){let t=e.colorAttachmentFormats??[this.device.preferredColorFormat],i=e.depthStencilAttachmentFormat??(e.parameters?.depthWriteEnabled?this.device.preferredDepthFormat:null);return this._getHash(JSON.stringify({colorAttachmentFormats:t,depthStencilAttachmentFormat:i}))}}});var Br,G0=C(()=>{$m();ut();Br=class n{static defaultProps={...kr.defaultProps};static getDefaultShaderFactory(e){let t=e.getModuleData("@luma.gl/core");return t.defaultShaderFactory||=new n(e),t.defaultShaderFactory}device;_cache={};get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}constructor(e){this.device=e}createShader(e){if(!this.device.props._cacheShaders)return this.device.createShader(e);let t=this._hashShader(e),i=this._cache[t];if(i)i.useCount++,this.device.props.debugFactories&&N.log(3,`${this}: Reusing shader ${i.resource.id} count=${i.useCount}`)();else{let r=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[t]=i={resource:r,useCount:1},this.device.props.debugFactories&&N.log(3,`${this}: Created new shader ${r.id}`)()}return i.resource}release(e){if(!this.device.props._cacheShaders){e.destroy();return}let t=this._hashShader(e),i=this._cache[t];if(i)if(i.useCount--,i.useCount===0)this.device.props._destroyShaders&&(delete this._cache[t],i.resource.destroy(),this.device.props.debugFactories&&N.log(3,`${this}: Releasing shader ${e.id}, destroyed`)());else{if(i.useCount<0)throw new Error(`ShaderFactory: Shader ${e.id} released too many times`);this.device.props.debugFactories&&N.log(3,`${this}: Releasing shader ${e.id} count=${i.useCount}`)()}}_hashShader(e){return`${e.stage}:${e.source}`}}});function Nu(n,e,t){let i=n.bindings.find(r=>r.name===e||`${r.name.toLocaleLowerCase()}uniforms`===e.toLocaleLowerCase());return!i&&!t?.ignoreWarnings&&N.warn(`Binding ${e} not set: Not found in shader layout.`)(),i||null}function Or(n,e){if(!e)return{};if(QR(e))return Object.fromEntries(Object.entries(e).map(([r,s])=>[Number(r),{...s}]));let t={};for(let[i,r]of Object.entries(e)){let o=Nu(n,i)?.group??0;t[o]||={},t[o][i]=r}return t}function js(n){let e={};for(let t of Object.values(n))Object.assign(e,t);return e}function QR(n){let e=Object.keys(n);return e.length>0&&e.every(t=>/^\d+$/.test(t))}var V0=C(()=>{ut()});var Ra,W0=C(()=>{He();Ra=class n extends te{static defaultClearColor=[0,0,0,1];static defaultClearDepth=1;static defaultClearStencil=0;get[Symbol.toStringTag](){return"RenderPass"}constructor(e,t,i=n.defaultProps){t=n.normalizeProps(e,t),super(e,t,i)}static normalizeProps(e,t){return t}static defaultProps={...te.defaultProps,framebuffer:null,resolveTargets:void 0,parameters:void 0,clearColor:n.defaultClearColor,clearColors:void 0,clearDepth:n.defaultClearDepth,clearStencil:n.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0}}});var Ia,j0=C(()=>{He();Ia=class n extends te{get[Symbol.toStringTag](){return"CommandEncoder"}_timeProfilingQuerySet=null;_timeProfilingSlotCount=0;_gpuTimeMs;constructor(e,t){super(e,t,n.defaultProps),this._timeProfilingQuerySet=t.timeProfilingQuerySet??null,this._timeProfilingSlotCount=0,this._gpuTimeMs=void 0}async resolveTimeProfilingQuerySet(){if(this._gpuTimeMs=void 0,!this._timeProfilingQuerySet)return;let e=Math.floor(this._timeProfilingSlotCount/2);if(e<=0)return;let t=e*2,i=await this._timeProfilingQuerySet.readResults({firstQuery:0,queryCount:t}),r=0n;for(let s=0;s=this._timeProfilingQuerySet.props.count?t:(this._timeProfilingSlotCount+=2,{...t,timestampQuerySet:this._timeProfilingQuerySet,beginTimestampIndex:i,endTimestampIndex:i+1})}_supportsTimestampQueries(){return this.device.features.has("timestamp-query")}static defaultProps={...te.defaultProps,measureExecutionTime:void 0,timeProfilingQuerySet:void 0}}});var Ba,H0=C(()=>{He();Ba=class n extends te{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,t){super(e,t,n.defaultProps)}static defaultProps={...te.defaultProps}}});var Oa,Y0=C(()=>{He();Oa=class n extends te{static defaultProps={...te.defaultProps,shaderLayout:void 0,bufferLayout:[]};get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;indexBuffer=null;attributes;constructor(e,t){super(e,t,n.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null)}getBufferSlot(e){return null}getDrawValidationError(){return null}setConstantWebGL(e,t){this.device.reportError(new Error("constant attributes not supported"),this)()}}});var Da,q0=C(()=>{He();Da=class n extends te{static defaultProps={...te.defaultProps,layout:void 0,buffers:{}};get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,n.defaultProps)}}});var Na,Z0=C(()=>{He();Na=class n extends te{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){super(e,t,n.defaultProps)}static defaultProps={...te.defaultProps,type:void 0,count:void 0}}});var Fa,X0=C(()=>{He();Fa=class n extends te{static defaultProps={...te.defaultProps};get[Symbol.toStringTag](){return"Fence"}constructor(e,t={}){super(e,t,n.defaultProps)}}});function Hs(n){let e=Fu(n),t=nI[e];if(!t)throw new Error(`Unsupported variable shader type: ${n}`);return t}function K0(n){let e=Q0(n),t=tI[e];if(!t)throw new Error(`Unsupported attribute shader type: ${n}`);let[i,r]=t,s=i==="i32"||i==="u32",o=i!=="u32",a=eI[i]*r;return{primitiveType:i,components:r,byteLength:a,integer:s,signed:o}}function JR(n,e){return e===1?n:`vec${e}<${n}>`}function Q0(n){return iI[n]||n}function Fu(n){return rI[n]||n}var Wm,kt,eI,tI,nI,iI,rI,za=C(()=>{Wm=class{getVariableShaderTypeInfo(e){return Hs(e)}getAttributeShaderTypeInfo(e){return K0(e)}makeShaderAttributeType(e,t){return JR(e,t)}resolveAttributeShaderTypeAlias(e){return Q0(e)}resolveVariableShaderTypeAlias(e){return Fu(e)}};kt=new Wm,eI={f32:4,f16:2,i32:4,u32:4},tI={f32:["f32",1],"vec2":["f32",2],"vec3":["f32",3],"vec4":["f32",4],f16:["f16",1],"vec2":["f16",2],"vec3":["f16",3],"vec4":["f16",4],i32:["i32",1],"vec2":["i32",2],"vec3":["i32",3],"vec4":["i32",4],u32:["u32",1],"vec2":["u32",2],"vec3":["u32",3],"vec4":["u32",4]},nI={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2":{type:"f32",components:2},"vec3":{type:"f32",components:3},"vec4":{type:"f32",components:4},"vec2":{type:"f16",components:2},"vec3":{type:"f16",components:3},"vec4":{type:"f16",components:4},"vec2":{type:"i32",components:2},"vec3":{type:"i32",components:3},"vec4":{type:"i32",components:4},"vec2":{type:"u32",components:2},"vec3":{type:"u32",components:3},"vec4":{type:"u32",components:4},"mat2x2":{type:"f32",components:4},"mat2x3":{type:"f32",components:6},"mat2x4":{type:"f32",components:8},"mat3x2":{type:"f32",components:6},"mat3x3":{type:"f32",components:9},"mat3x4":{type:"f32",components:12},"mat4x2":{type:"f32",components:8},"mat4x3":{type:"f32",components:12},"mat4x4":{type:"f32",components:16},"mat2x2":{type:"f16",components:4},"mat2x3":{type:"f16",components:6},"mat2x4":{type:"f16",components:8},"mat3x2":{type:"f16",components:6},"mat3x3":{type:"f16",components:9},"mat3x4":{type:"f16",components:12},"mat4x2":{type:"f16",components:8},"mat4x3":{type:"f16",components:12},"mat4x4":{type:"f16",components:16},"mat2x2":{type:"i32",components:4},"mat2x3":{type:"i32",components:6},"mat2x4":{type:"i32",components:8},"mat3x2":{type:"i32",components:6},"mat3x3":{type:"i32",components:9},"mat3x4":{type:"i32",components:12},"mat4x2":{type:"i32",components:8},"mat4x3":{type:"i32",components:12},"mat4x4":{type:"i32",components:16},"mat2x2":{type:"u32",components:4},"mat2x3":{type:"u32",components:6},"mat2x4":{type:"u32",components:8},"mat3x2":{type:"u32",components:6},"mat3x3":{type:"u32",components:9},"mat3x4":{type:"u32",components:12},"mat4x2":{type:"u32",components:8},"mat4x3":{type:"u32",components:12},"mat4x4":{type:"u32",components:16}},iI={vec2i:"vec2",vec3i:"vec3",vec4i:"vec4",vec2u:"vec2",vec3u:"vec3",vec4u:"vec4",vec2f:"vec2",vec3f:"vec3",vec4f:"vec4",vec2h:"vec2",vec3h:"vec3",vec4h:"vec4"},rI={vec2i:"vec2",vec3i:"vec3",vec4i:"vec4",vec2u:"vec2",vec3u:"vec3",vec4u:"vec4",vec2f:"vec2",vec3f:"vec3",vec4f:"vec4",vec2h:"vec2",vec3h:"vec3",vec4h:"vec4",mat2x2f:"mat2x2",mat2x3f:"mat2x3",mat2x4f:"mat2x4",mat3x2f:"mat3x2",mat3x3f:"mat3x3",mat3x4f:"mat3x4",mat4x2f:"mat4x2",mat4x3f:"mat4x3",mat4x4f:"mat4x4",mat2x2i:"mat2x2",mat2x3i:"mat2x3",mat2x4i:"mat2x4",mat3x2i:"mat3x2",mat3x3i:"mat3x3",mat3x4i:"mat3x4",mat4x2i:"mat4x2",mat4x3i:"mat4x3",mat4x4i:"mat4x4",mat2x2u:"mat2x2",mat2x3u:"mat2x3",mat2x4u:"mat2x4",mat3x2u:"mat3x2",mat3x3u:"mat3x3",mat3x4u:"mat3x4",mat4x2u:"mat4x2",mat4x3u:"mat4x3",mat4x4u:"mat4x4",mat2x2h:"mat2x2",mat2x3h:"mat2x3",mat2x4h:"mat2x4",mat3x2h:"mat3x2",mat3x3h:"mat3x3",mat3x4h:"mat3x4",mat4x2h:"mat4x2",mat4x3h:"mat4x3",mat4x4h:"mat4x4"}});function Dr(n,e={}){let t={...n},i=e.layout??"std140",r={},s=0;for(let[o,a]of Object.entries(t))s=jm(r,o,a,s,i);return s=qt(s,Yi(t,i)),{layout:i,byteLength:s*4,uniformTypes:t,fields:r}}function Ua(n,e){let t=Fu(n),i=Hs(t),r=/^mat(\d)x(\d)<.+>$/.exec(t);if(r){let o=Number(r[1]),a=Number(r[2]),c=J0(a,t,i.type,e),l=oI(c.size,c.alignment,e);return{alignment:c.alignment,size:o*l,components:o*a,columns:o,rows:a,columnStride:l,shaderType:t,type:i.type}}let s=/^vec(\d)<.+>$/.exec(t);return s?J0(Number(s[1]),t,i.type,e):{alignment:1,size:1,components:1,columns:1,rows:1,columnStride:1,shaderType:t,type:i.type}}function Hm(n){return!!n&&typeof n=="object"&&!Array.isArray(n)}function jm(n,e,t,i,r){if(typeof t=="string"){let s=Ua(t,r),o=qt(i,s.alignment);return n[e]={offset:o,...s},o+s.size}if(Array.isArray(t)){if(Array.isArray(t[0]))throw new Error(`Nested arrays are not supported for ${e}`);let s=t[0],o=t[1],a=tw(s,r),c=qt(i,Yi(t,r));for(let l=0;l{Mu();za()});function Ym(n){return(!Uu||Uu.byteLength{});function cI(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Ys(n){return Array.isArray(n)?n.length===0||typeof n[0]=="number":cI(n)}var Xm=C(()=>{});function lI(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&!ArrayBuffer.isView(n)}function uI(n,e,t){return Array.prototype.slice.call(n,e,t)}var $u,iw=C(()=>{Zm();Xm();ut();zu();$u=class{layout;constructor(e){this.layout=e}has(e){return!!this.layout.fields[e]}get(e){let t=this.layout.fields[e];return t?{offset:t.offset,size:t.size}:void 0}getFlatUniformValues(e){let t={};for(let[i,r]of Object.entries(e)){let s=this.layout.uniformTypes[i];s?this._flattenCompositeValue(t,i,s,r):this.layout.fields[i]&&(t[i]=r)}return t}getData(e){let t=Ym(this.layout.byteLength);new Uint8Array(t,0,this.layout.byteLength).fill(0);let i={i32:new Int32Array(t),u32:new Uint32Array(t),f32:new Float32Array(t),f16:new Uint16Array(t)},r=this.getFlatUniformValues(e);for(let[s,o]of Object.entries(r))this._writeLeafValue(i,s,o);return new Uint8Array(t,0,this.layout.byteLength)}_flattenCompositeValue(e,t,i,r){if(r!==void 0){if(typeof i=="string"||this.layout.fields[t]){e[t]=r;return}if(Array.isArray(i)){let s=i[0],o=i[1];if(Array.isArray(s))throw new Error(`Nested arrays are not supported for ${t}`);if(typeof s=="string"&&Ys(r)){this._flattenPackedArray(e,t,s,o,r);return}if(!Array.isArray(r)){N.warn(`Unsupported uniform array value for ${t}:`,r)();return}for(let a=0;a=o.length)break;c===1?e[`${t}[${l}]`]=Number(o[u]):e[`${t}[${l}]`]=uI(s,u,u+c)}}_writeLeafValue(e,t,i){let r=this.layout.fields[t];if(!r){N.warn(`Uniform ${t} not found in layout`)();return}let{type:s,components:o,columns:a,rows:c,offset:l,columnStride:u}=r,f=e[s];if(o===1){f[l]=Number(i);return}let d=i;if(a===1){for(let p=0;ps)return!1;for(let o=0;o{Xm();fI=128});var Gu,aw=C(()=>{ow();Gu=class{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(e){if(this.name=e?.name||"unnamed",e?.name&&e?.shaderLayout){let t=e?.shaderLayout.bindings?.find(r=>r.type==="uniform"&&r.name===e?.name);if(!t)throw new Error(e?.name);let i=t;for(let r of i.uniforms||[])this.bindingLayout[r.name]=r}}setUniforms(e){for(let[t,i]of Object.entries(e))this._setUniform(t,i)&&!this.needsRedraw&&this.setNeedsRedraw(`${this.name}.${t}=${i}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){return rw(this.uniforms[e],t)?!1:(this.uniforms[e]=sw(t),this.modifiedUniforms[e]=!0,this.modified=!0,!0)}}});function hI(n){return n.type==="webgpu"?"wgsl-uniform":"std140"}var dI,Nr,cw=C(()=>{Tu();ut();zu();aw();iw();dI=1024,Nr=class{device;uniformBlocks=new Map;shaderBlockLayouts=new Map;shaderBlockWriters=new Map;uniformBuffers=new Map;constructor(e,t){this.device=e;for(let[i,r]of Object.entries(t)){let s=i,o=Dr(r.uniformTypes??{},{layout:r.layout??hI(e)}),a=new $u(o);this.shaderBlockLayouts.set(s,o),this.shaderBlockWriters.set(s,a);let c=new Gu({name:i});c.setUniforms(a.getFlatUniformValues(r.defaultUniforms||{})),this.uniformBlocks.set(s,c)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e,t){for(let[i,r]of Object.entries(e)){let s=i,a=this.shaderBlockWriters.get(s)?.getFlatUniformValues(r||{});this.uniformBlocks.get(s)?.setUniforms(a||{})}this.updateUniformBuffers(t)}getUniformBufferByteLength(e){let t=this.shaderBlockLayouts.get(e)?.byteLength||0;return Math.max(t,dI)}getUniformBufferData(e){let t=this.uniformBlocks.get(e)?.getAllUniforms()||{};return this.shaderBlockWriters.get(e)?.getData(t)||new Uint8Array(0)}createUniformBuffer(e,t){t&&this.setUniforms(t);let i=this.getUniformBufferByteLength(e),r=this.device.createBuffer({usage:ie.UNIFORM|ie.COPY_DST,byteLength:i}),s=this.getUniformBufferData(e);return r.write(s),r}getManagedUniformBuffer(e){if(!this.uniformBuffers.get(e)){let t=this.getUniformBufferByteLength(e),i=this.device.createBuffer({usage:ie.UNIFORM|ie.COPY_DST,byteLength:t});this.uniformBuffers.set(e,i)}return this.uniformBuffers.get(e)}updateUniformBuffers(e){let t=!1;for(let i of this.uniformBlocks.keys()){let r=this.updateUniformBuffer(i,e);t||=r}return t&&N.log(3,`UniformStore.updateUniformBuffers(): ${t}`)(),t}updateUniformBuffer(e,t){let i=this.uniformBlocks.get(e),r=this.uniformBuffers.get(e),s=!1;if(r&&i?.needsRedraw){s||=i.needsRedraw;let o=this.getUniformBufferData(e);if(r=this.uniformBuffers.get(e),r&&(t?this.device.writeBufferViaCommandEncoder(t,r,o):r.write(o)),N.level>=4){let a=this.uniformBlocks.get(e)?.getAllUniforms();N.log(4,`Writing to uniform buffer ${String(e)}`,o,a)()}}return s}}});function qs(n){return n.attributes?n.attributes.map(e=>e.attribute):[n.name]}function Km(n){return Object.fromEntries(n.attributes.map(e=>[e.name,e.location]))}function Vu(n){let e=1/0;for(let t of n)t!==void 0&&(e=Math.min(e,t));return e}function Qm(n,e,t){pI(e);let i=new Map;for(let r of e){let s=mI(r);if(r.attributes)for(let o of r.attributes)i.has(o.attribute)||i.set(o.attribute,{bufferName:r.name,stepMode:r.stepMode,vertexFormat:o.format,byteOffset:o.byteOffset,byteStride:s});else r.format&&!i.has(r.name)&&i.set(r.name,{bufferName:r.name,stepMode:r.stepMode,vertexFormat:r.format,byteOffset:0,byteStride:s})}return n.attributes.map(r=>{let s=i.get(r.name);!s&&t?.warnOnMissingBufferLayout&&N.warn(`layout for attribute "${r.name}" not present in buffer layout`)();let o=kt.getAttributeShaderTypeInfo(r.type),a=s?.vertexFormat||Pe.getCompatibleVertexFormat(o);return{attributeName:r.name,bufferName:s?.bufferName||r.name,location:r.location,vertexFormat:a,byteOffset:s?.byteOffset??0,byteStride:s?.byteStride??Pe.getVertexFormatInfo(a).byteLength,stepMode:s?.stepMode||r.stepMode||(r.name.startsWith("instance")?"instance":"vertex")}}).sort((r,s)=>r.location-s.location)}function pI(n){for(let e of n)(e.attributes&&e.format||!e.attributes&&!e.format)&&N.warn(`BufferLayout ${e.name} must have either 'attributes' or 'format' field`)()}function mI(n){if(typeof n.byteStride=="number")return n.byteStride;if(n.attributes){let e=0;for(let t of n.attributes)e+=Pe.getVertexFormatInfo(t.format).byteLength;return e}return Pe.getVertexFormatInfo(n.format).byteLength}var Jm=C(()=>{ut();za();Pa()});function $a(n,e){let t={},i=Qm(n,e,{warnOnMissingBufferLayout:!0});for(let r of i){let s=gI(n,r);t[r.attributeName]=s}return t}function gI(n,e){let t=_I(n,e.attributeName),i=kt.getAttributeShaderTypeInfo(t.type),r=e.vertexFormat,s=Pe.getVertexFormatInfo(r);return{attributeName:e.attributeName,bufferName:e.bufferName,location:t.location,shaderType:t.type,primitiveType:i.primitiveType,shaderComponents:i.components,vertexFormat:r,bufferDataType:s.type,bufferComponents:s.components,normalized:s.normalized,integer:i.integer,stepMode:e.stepMode,byteOffset:e.byteOffset,byteStride:e.byteStride}}function _I(n,e){let t=n.attributes.find(i=>i.name===e);return t||N.warn(`shader layout attribute "${e}" not present in shader`)(),t||null}var lw=C(()=>{ut();za();Pa();Jm()});var J=C(()=>{r0();s0();C0();R0();I0();Tu();zm();B0();O0();$m();Fm();z0();Gm();U0();$0();G0();W0();Vm();j0();H0();Y0();q0();Z0();X0();zu();cw();Au();Mu();za();Pa();Ou();ut();V0();Dm();Zm();lw();Jm()});function Ga(n=[],e){let t=[],i={},r={},s={},o={};for(let a of n)uw({modules:t,defines:i,injections:r,vertexInputs:s,varyings:o},a),uw({modules:t,defines:i,injections:r,vertexInputs:s,varyings:o},a[e]);for(let a of Object.keys(o))if(s[a])throw new Error(`ShaderPlugin name "${a}" cannot be both a vertex input and a varying`);return{modules:t,defines:i,injections:r,vertexInputs:s,varyings:o}}function Va(n=[],e=[]){let t=[...n],i=new Set(t.map(r=>r.name));for(let r of e)i.has(r.name)||(t.push(r),i.add(r.name));return t}function uw(n,e){if(e){e.modules?.length&&n.modules.push(...e.modules),e.defines&&Object.assign(n.defines,e.defines);for(let[t,i]of Object.entries(e.vertexInputs||{})){fw(t,"vertex input");let r=n.vertexInputs[t];if(r&&r!==i)throw new Error(`ShaderPlugin vertex input "${t}" has conflicting types "${r}" and "${i}"`);n.vertexInputs[t]=i}for(let[t,i]of Object.entries(e.varyings||{})){fw(t,"varying");let r=bI(t,i),s=n.varyings[t];if(s&&(s.type!==r.type||s.interpolation!==r.interpolation))throw new Error(`ShaderPlugin varying "${t}" has conflicting declarations "${s.type}/${s.interpolation}" and "${r.type}/${r.interpolation}"`);n.varyings[t]=r}for(let t of e.injections||[])vI(t.target),n.injections[t.target]||(n.injections[t.target]=[]),n.injections[t.target].push({injection:t.injection,order:t.order??0})}}function fw(n,e){if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(n)||n.startsWith("_luma_"))throw new Error(`ShaderPlugin ${e} "${n}" must be a valid non-reserved identifier`)}function bI(n,e){let{primitiveType:t}=kt.getAttributeShaderTypeInfo(e.type),i=t==="i32"||t==="u32",r=e.interpolation||(i?"flat":"smooth");if(i&&r==="smooth")throw new Error(`ShaderPlugin integer varying "${n}" must use flat interpolation`);return{type:e.type,interpolation:r}}function vI(n){if(!yI.test(n))throw new Error(`ShaderPlugin injection target "${n}" must be a named shader anchor or hook`)}var yI,dw=C(()=>{J();yI=/^(vs|fs):(?:#(?:decl|main-start|main-end)|[A-Za-z_][\w-]*)$/});function Wa(n){return`${n.name}Uniforms`}function pw(n,e){let t=e==="wgsl"?n.source:e==="vertex"?n.vs:n.fs;if(!t)return null;let i=Wa(n);return EI(t,e==="wgsl"?"wgsl":"glsl",i)}function mw(n,e){let t=Object.keys(n.uniformTypes||{});if(!t.length)return null;let i=pw(n,e);return i?{moduleName:n.name,uniformBlockName:Wa(n),stage:e,expectedUniformNames:t,actualUniformNames:i,matches:CI(t,i)}:null}function eg(n,e,t={}){let i=mw(n,e);if(!i||i.matches)return i;let r=TI(i);return t.log?.error?.(r,i)(),t.throwOnError!==!1&&yi(!1,r),i}function ja(n){let e=[],t=LI(n);for(let i of t.matchAll(wI)){let r=i[1]?.trim()||null;e.push({blockName:i[2],body:i[3],instanceName:i[4]||null,layoutQualifier:r,hasLayoutQualifier:!!r,isStd140:!!(r&&/\blayout\s*\([^)]*\bstd140\b[^)]*\)/.exec(r))})}return e}function tg(n,e,t,i){let r=ja(n).filter(o=>!o.isStd140),s=new Set;for(let o of r){if(s.has(o.blockName))continue;s.add(o.blockName);let a=i?.label?`${i.label} `:"",c=o.hasLayoutQualifier?`declares ${MI(o.layoutQualifier)} instead of layout(std140)`:"does not declare layout(std140)",l=`${a}${e} shader uniform block ${o.blockName} ${c}. luma.gl host-side shader block packing assumes explicit layout(std140) for GLSL uniform blocks. Add \`layout(std140)\` to the block declaration.`;t?.warn?.(l,o)()}return r}function EI(n,e,t){let i=e==="wgsl"?SI(n,t):PI(n,t);if(!i)return null;let r=[];for(let s of i.split(` +`)){let o=s.replace(/\/\/.*$/,"").trim();if(!o||o.startsWith("#"))continue;let a=e==="wgsl"?o.match(/^([A-Za-z0-9_]+)\s*:/):o.match(xI);a&&r.push(a[1])}return r}function SI(n,e){let t=new RegExp(`\\bstruct\\s+${e}\\b`,"m").exec(n);if(!t)return null;let i=n.indexOf("{",t.index);if(i<0)return null;let r=0;for(let s=i;si.blockName===e)?.body||null}function CI(n,e){if(n.length!==e.length)return!1;for(let t=0;t!t.includes(a)),r=t.filter(a=>!e.includes(a)),s=[`Expected ${e.length} fields, found ${t.length}.`],o=AI(e,t);return o&&s.push(o),i.length&&s.push(`Missing from shader block (${i.length}): ${hw(i)}.`),r.length&&s.push(`Unexpected in shader block (${r.length}): ${hw(r)}.`),e.length<=12&&t.length<=12&&(i.length||r.length)&&(s.push(`Expected: ${e.join(", ")}.`),s.push(`Actual: ${t.join(", ")}.`)),`${n.moduleName}: ${n.stage} shader uniform block ${n.uniformBlockName} does not match module.uniformTypes. ${s.join(" ")}`}function LI(n){return n.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"")}function MI(n){return n.replace(/\s+/g," ").trim()}function AI(n,e){let t=Math.min(n.length,e.length);for(let i=0;ie.length?`Shader block ends after field ${e.length}; expected next field ${n[e.length]}.`:e.length>n.length?`Shader block has extra field ${e.length}: ${e[n.length]}.`:null}function hw(n,e=8){if(n.length<=e)return n.join(", ");let t=n.length-e;return`${n.slice(0,e).join(", ")}, ... (${t} more)`}var xI,wI,ng=C(()=>{xu();xI=/^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/,wI=/((?:layout\s*\([^)]*\)\s*)*)uniform\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([\s\S]*?)\}\s*([A-Za-z_][A-Za-z0-9_]*)?\s*;/g});function gw(n){switch(n?.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU // Apple optimizes away the calculation necessary for emulated fp64 #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 @@ -62,36 +62,36 @@ ${s}${o}${n.type.toUpperCase()}: ${n.message} #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 // If the GPU doesn't have full 32 bits precision, will causes overflow #define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 -`}}var _w=C(()=>{});function bw(n,e){if(Number(n.match(/^#version[ \t]+(\d+)/m)?.[1]||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(e){case"vertex":return n=yw(n,LI),n;case"fragment":return n=yw(n,MI),n;default:throw new Error(e)}}function yw(n,e){for(let[t,i]of e)n=n.replace(t,i);return n}function ig(n){return new RegExp(`\\b${n}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}var vw,LI,MI,xw=C(()=>{vw=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es -`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],LI=[...vw,[ig("attribute"),"in $1"],[ig("varying"),"out $1"]],MI=[...vw,[ig("varying"),"in $1"]]});function Wu(n,e,t="glsl"){let i="";for(let r in n){let s=n[r];if(i+=`${t==="wgsl"?"fn":"void"} ${s.signature} { +`}}var _w=C(()=>{});function bw(n,e){if(Number(n.match(/^#version[ \t]+(\d+)/m)?.[1]||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(e){case"vertex":return n=yw(n,kI),n;case"fragment":return n=yw(n,RI),n;default:throw new Error(e)}}function yw(n,e){for(let[t,i]of e)n=n.replace(t,i);return n}function ig(n){return new RegExp(`\\b${n}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}var vw,kI,RI,xw=C(()=>{vw=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es +`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],kI=[...vw,[ig("attribute"),"in $1"],[ig("varying"),"out $1"]],RI=[...vw,[ig("varying"),"in $1"]]});function Wu(n,e,t="glsl"){let i="";for(let r in n){let s=n[r];if(i+=`${t==="wgsl"?"fn":"void"} ${s.signature} { `,s.header&&(i+=` ${s.header}`),e[r]){let a=e[r];a.sort((c,l)=>c.order-l.order);for(let c of a)i+=` ${c.injection} `}s.footer&&(i+=` ${s.footer}`),i+=`} -`}return i}function rg(n){let e={vertex:{},fragment:{}};for(let t of n){let i,r;typeof t!="string"?(i=t,r=i.hook):(i={},r=t),r=r.trim();let s=r.indexOf(":"),o=r.slice(0,s),a=r.slice(s+1),c=r.replace(/\(.+/,""),l=Object.assign(i,{signature:a});switch(o){case"vs":e.vertex[c]=l;break;case"fs":e.fragment[c]=l;break;default:throw new Error(o)}}return e}var ww=C(()=>{});function Ew(n,e){return{name:AI(n,e),language:"glsl",version:kI(n)}}function AI(n,e="unnamed"){let i=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(n);return i?i[1]:e}function kI(n){let e=100,t=n.match(/[^\s]+/g);if(t&&t.length>=2&&t[0]==="#version"){let i=parseInt(t[1],10);Number.isFinite(i)&&(e=i)}if(e!==100&&e!==300)throw new Error(`Invalid GLSL version ${e}`);return e}var Sw=C(()=>{});function ju(n,e=[]){let t=$s(n),i=new Map;for(let s of e)i.set(Cw(s.name,s.group,s.location),s.moduleName);let r=[];for(let s of Pw){s.lastIndex=0;let o;for(o=s.exec(t);o;){let a=s===Pw[0],c=Number(o[a?1:2]),l=Number(o[a?2:1]),u=o[3]?.trim(),f=o[4],d=o[5].trim(),h=i.get(Cw(f,l,c));r.push(RI({name:f,group:l,binding:c,owner:h?"module":"application",moduleName:h,accessDeclaration:u,resourceType:d})),o=s.exec(t)}}return r.sort((s,o)=>s.group!==o.group?s.group-o.group:s.binding!==o.binding?s.binding-o.binding:s.name.localeCompare(o.name))}function RI(n){let e={name:n.name,group:n.group,binding:n.binding,owner:n.owner,kind:"unknown",moduleName:n.moduleName,resourceType:n.resourceType};if(n.accessDeclaration){let t=n.accessDeclaration.split(",").map(i=>i.trim());if(t[0]==="uniform")return{...e,kind:"uniform",access:"uniform"};if(t[0]==="storage"){let i=t[1]||"read_write";return{...e,kind:i==="read"?"read-only-storage":"storage",access:i}}}return n.resourceType==="sampler"||n.resourceType==="sampler_comparison"?{...e,kind:"sampler",samplerKind:n.resourceType==="sampler_comparison"?"comparison":"filtering"}:n.resourceType.startsWith("texture_storage_")?{...e,kind:"storage-texture",access:BI(n.resourceType),viewDimension:Tw(n.resourceType)}:n.resourceType.startsWith("texture_")?{...e,kind:"texture",viewDimension:Tw(n.resourceType),sampleType:II(n.resourceType),multisampled:n.resourceType.startsWith("texture_multisampled_")}:e}function Cw(n,e,t){return`${e}:${t}:${n}`}function Tw(n){if(n.includes("cube_array"))return"cube-array";if(n.includes("2d_array"))return"2d-array";if(n.includes("cube"))return"cube";if(n.includes("3d"))return"3d";if(n.includes("2d"))return"2d";if(n.includes("1d"))return"1d"}function II(n){if(n.startsWith("texture_depth_"))return"depth";if(n.includes(""))return"sint";if(n.includes(""))return"uint";if(n.includes(""))return"float"}function BI(n){return/,\s*([A-Za-z_][A-Za-z0-9_]*)\s*>$/.exec(n)?.[1]}var Pw,sg=C(()=>{_u();Pw=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${At}\\s*:\\s*([^;]+);`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(\\d+)\\s*\\)\\s*${At}\\s*:\\s*([^;]+);`,"g")]});function zr(n,e){let t=n.split(` -`),i=[],r=[],s=!0;for(let o of t){let a=o.match(OI),c=o.match(UI)||o.match(DI),l=o.match(NI),u=o.match(FI),f=o.match($I)||o.match(zI);if(a){let d=GI(a[1],e?.defines||{}),h=s&&d;r.push({parentActive:s,branchTaken:d,active:h}),s=h}else if(c||l){let d=(c||l)?.[1],h=!!e?.defines?.[d],p=c?h:!h,m=s&&p;r.push({parentActive:s,branchTaken:p,active:m}),s=m}else if(u){let d=r[r.length-1];if(!d)throw new Error("Encountered #else without matching #if, #ifdef or #ifndef");d.active=d.parentActive&&!d.branchTaken,d.branchTaken=!0,s=d.active}else f?(r.pop(),s=r.length?r[r.length-1].active:!0):s&&i.push(o)}if(r.length>0)throw new Error("Unterminated conditional block in shader source");return i.join(` -`)}function GI(n,e){let t=n.trim();if(/^[+-]?\d+(?:\.\d+)?$/.test(t))return Number(t)!==0;if(t==="true")return!0;if(t==="false")return!1;let i=t.match(new RegExp(`^!\\s*${Fr}$`));if(i)return!e[i[1]];let r=t.match(new RegExp(`^${Fr}$`));if(r)return!!e[r[1]];let s=t.match(new RegExp(`^defined\\s*\\(\\s*${Fr}\\s*\\)$`));if(s)return e[s[1]]!==void 0;let o=t.match(new RegExp(`^!\\s*defined\\s*\\(\\s*${Fr}\\s*\\)$`));if(o)return e[o[1]]===void 0;throw new Error(`Unsupported #if expression "${n}"`)}var Fr,OI,DI,NI,FI,zI,UI,$I,og=C(()=>{Fr="([a-zA-Z_][a-zA-Z0-9_]*)",OI=/^\s*\#\s*if\s+(.+?)\s*(?:\/\/.*)?$/,DI=new RegExp(`^\\s*\\#\\s*ifdef\\s*${Fr}\\s*$`),NI=new RegExp(`^\\s*\\#\\s*ifndef\\s*${Fr}\\s*(?:\\/\\/.*)?$`),FI=/^\s*\#\s*else\s*(?:\/\/.*)?$/,zI=/^\s*\#\s*endif\s*$/,UI=new RegExp(`^\\s*\\#\\s*ifdef\\s*${Fr}\\s*(?:\\/\\/.*)?$`),$I=/^\s*\#\s*endif\s*(?:\/\/.*)?$/});function Aw(n,e){let t=[];for(let[i,r]of Object.entries(e))VI(n,i),t.push(`in ${Hu(r)} ${i};`);return t.join(` -`)}function kw(n,e,t){let i=Object.entries(t);if(i.length===0)return{source:n,declarations:"",initialization:""};let r=WI(n,e),s=n.slice(r.openParenthesis+1,r.closeParenthesis),o=jI(n,s),a=new Set(o.locations),c=[],l=[],u=[];for(let[m,g]of i){if(o.names.has(m)||qI(n,m))throw new Error(`ShaderPlugin vertex input "${m}" conflicts with an existing WGSL shader input or variable`);let v=ZI(a);a.add(v);let y=`_luma_${m}`;c.push(`@location(${v}) ${y}: ${g}`),l.push(`var ${m}: ${g};`),u.push(`${m} = ${y};`)}let f=s.trim()?`, +`}return i}function rg(n){let e={vertex:{},fragment:{}};for(let t of n){let i,r;typeof t!="string"?(i=t,r=i.hook):(i={},r=t),r=r.trim();let s=r.indexOf(":"),o=r.slice(0,s),a=r.slice(s+1),c=r.replace(/\(.+/,""),l=Object.assign(i,{signature:a});switch(o){case"vs":e.vertex[c]=l;break;case"fs":e.fragment[c]=l;break;default:throw new Error(o)}}return e}var ww=C(()=>{});function Ew(n,e){return{name:II(n,e),language:"glsl",version:BI(n)}}function II(n,e="unnamed"){let i=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(n);return i?i[1]:e}function BI(n){let e=100,t=n.match(/[^\s]+/g);if(t&&t.length>=2&&t[0]==="#version"){let i=parseInt(t[1],10);Number.isFinite(i)&&(e=i)}if(e!==100&&e!==300)throw new Error(`Invalid GLSL version ${e}`);return e}var Sw=C(()=>{});function ju(n,e=[]){let t=$s(n),i=new Map;for(let s of e)i.set(Cw(s.name,s.group,s.location),s.moduleName);let r=[];for(let s of Pw){s.lastIndex=0;let o;for(o=s.exec(t);o;){let a=s===Pw[0],c=Number(o[a?1:2]),l=Number(o[a?2:1]),u=o[3]?.trim(),f=o[4],d=o[5].trim(),h=i.get(Cw(f,l,c));r.push(OI({name:f,group:l,binding:c,owner:h?"module":"application",moduleName:h,accessDeclaration:u,resourceType:d})),o=s.exec(t)}}return r.sort((s,o)=>s.group!==o.group?s.group-o.group:s.binding!==o.binding?s.binding-o.binding:s.name.localeCompare(o.name))}function OI(n){let e={name:n.name,group:n.group,binding:n.binding,owner:n.owner,kind:"unknown",moduleName:n.moduleName,resourceType:n.resourceType};if(n.accessDeclaration){let t=n.accessDeclaration.split(",").map(i=>i.trim());if(t[0]==="uniform")return{...e,kind:"uniform",access:"uniform"};if(t[0]==="storage"){let i=t[1]||"read_write";return{...e,kind:i==="read"?"read-only-storage":"storage",access:i}}}return n.resourceType==="sampler"||n.resourceType==="sampler_comparison"?{...e,kind:"sampler",samplerKind:n.resourceType==="sampler_comparison"?"comparison":"filtering"}:n.resourceType.startsWith("texture_storage_")?{...e,kind:"storage-texture",access:NI(n.resourceType),viewDimension:Tw(n.resourceType)}:n.resourceType.startsWith("texture_")?{...e,kind:"texture",viewDimension:Tw(n.resourceType),sampleType:DI(n.resourceType),multisampled:n.resourceType.startsWith("texture_multisampled_")}:e}function Cw(n,e,t){return`${e}:${t}:${n}`}function Tw(n){if(n.includes("cube_array"))return"cube-array";if(n.includes("2d_array"))return"2d-array";if(n.includes("cube"))return"cube";if(n.includes("3d"))return"3d";if(n.includes("2d"))return"2d";if(n.includes("1d"))return"1d"}function DI(n){if(n.startsWith("texture_depth_"))return"depth";if(n.includes(""))return"sint";if(n.includes(""))return"uint";if(n.includes(""))return"float"}function NI(n){return/,\s*([A-Za-z_][A-Za-z0-9_]*)\s*>$/.exec(n)?.[1]}var Pw,sg=C(()=>{_u();Pw=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${At}\\s*:\\s*([^;]+);`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(\\d+)\\s*\\)\\s*${At}\\s*:\\s*([^;]+);`,"g")]});function zr(n,e){let t=n.split(` +`),i=[],r=[],s=!0;for(let o of t){let a=o.match(FI),c=o.match(VI)||o.match(zI),l=o.match(UI),u=o.match($I),f=o.match(WI)||o.match(GI);if(a){let d=jI(a[1],e?.defines||{}),h=s&&d;r.push({parentActive:s,branchTaken:d,active:h}),s=h}else if(c||l){let d=(c||l)?.[1],h=!!e?.defines?.[d],p=c?h:!h,m=s&&p;r.push({parentActive:s,branchTaken:p,active:m}),s=m}else if(u){let d=r[r.length-1];if(!d)throw new Error("Encountered #else without matching #if, #ifdef or #ifndef");d.active=d.parentActive&&!d.branchTaken,d.branchTaken=!0,s=d.active}else f?(r.pop(),s=r.length?r[r.length-1].active:!0):s&&i.push(o)}if(r.length>0)throw new Error("Unterminated conditional block in shader source");return i.join(` +`)}function jI(n,e){let t=n.trim();if(/^[+-]?\d+(?:\.\d+)?$/.test(t))return Number(t)!==0;if(t==="true")return!0;if(t==="false")return!1;let i=t.match(new RegExp(`^!\\s*${Fr}$`));if(i)return!e[i[1]];let r=t.match(new RegExp(`^${Fr}$`));if(r)return!!e[r[1]];let s=t.match(new RegExp(`^defined\\s*\\(\\s*${Fr}\\s*\\)$`));if(s)return e[s[1]]!==void 0;let o=t.match(new RegExp(`^!\\s*defined\\s*\\(\\s*${Fr}\\s*\\)$`));if(o)return e[o[1]]===void 0;throw new Error(`Unsupported #if expression "${n}"`)}var Fr,FI,zI,UI,$I,GI,VI,WI,og=C(()=>{Fr="([a-zA-Z_][a-zA-Z0-9_]*)",FI=/^\s*\#\s*if\s+(.+?)\s*(?:\/\/.*)?$/,zI=new RegExp(`^\\s*\\#\\s*ifdef\\s*${Fr}\\s*$`),UI=new RegExp(`^\\s*\\#\\s*ifndef\\s*${Fr}\\s*(?:\\/\\/.*)?$`),$I=/^\s*\#\s*else\s*(?:\/\/.*)?$/,GI=/^\s*\#\s*endif\s*$/,VI=new RegExp(`^\\s*\\#\\s*ifdef\\s*${Fr}\\s*(?:\\/\\/.*)?$`),WI=/^\s*\#\s*endif\s*(?:\/\/.*)?$/});function Aw(n,e){let t=[];for(let[i,r]of Object.entries(e))HI(n,i),t.push(`in ${Hu(r)} ${i};`);return t.join(` +`)}function kw(n,e,t){let i=Object.entries(t);if(i.length===0)return{source:n,declarations:"",initialization:""};let r=YI(n,e),s=n.slice(r.openParenthesis+1,r.closeParenthesis),o=qI(n,s),a=new Set(o.locations),c=[],l=[],u=[];for(let[m,g]of i){if(o.names.has(m)||KI(n,m))throw new Error(`ShaderPlugin vertex input "${m}" conflicts with an existing WGSL shader input or variable`);let v=QI(a);a.add(v);let y=`_luma_${m}`;c.push(`@location(${v}) ${y}: ${g}`),l.push(`var ${m}: ${g};`),u.push(`${m} = ${y};`)}let f=s.trim()?`, `:` `,d=s.trim()?"":` `,h=`${s}${f}${c.join(`, `)}${d}`;return{source:n.slice(0,r.openParenthesis+1)+h+n.slice(r.closeParenthesis),declarations:l.join(` `),initialization:u.join(` -`)}}function Hu(n){let{primitiveType:e,components:t}=kt.getAttributeShaderTypeInfo(n),i=e==="i32"?"int":e==="u32"?"uint":"float";return t===1?i:`${i==="int"?"i":i==="uint"?"u":""}vec${t}`}function VI(n,e){let t=Yu(e);if(new RegExp(`\\b(?:in|attribute)\\s+(?:(?:lowp|mediump|highp)\\s+)?[A-Za-z_][A-Za-z0-9_]*\\s+${t}\\s*(?:\\[|;)`).test(n))throw new Error(`ShaderPlugin vertex input "${e}" conflicts with an existing GLSL input`)}function WI(n,e){let i=new RegExp(`\\bfn\\s+${Yu(e)}\\s*\\(`,"g").exec(n);if(!i)throw new Error(`ShaderPlugin vertex inputs require WGSL vertex entry point "${e}"`);let r=n.indexOf("(",i.index),s=Rw(n,r,"(",")");if(s<0)throw new Error(`Unable to parse WGSL vertex entry point "${e}" parameters`);return{openParenthesis:r,closeParenthesis:s}}function jI(n,e){let t=Lw(e),i=new Set(Mw(e)),r=HI(e);for(let s of r){let o=YI(n,s);if(o!==null){t.push(...Lw(o));for(let a of Mw(o))i.add(a)}}return{locations:t,names:i}}function Lw(n){let e=[],t=/@location\s*\(\s*(\d+)\s*\)/g,i=t.exec(n);for(;i;)e.push(Number(i[1])),i=t.exec(n);return e}function Mw(n){let e=[],t=/(?:^|,)\s*(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:/gm,i=t.exec(n);for(;i;)e.push(i[1]),i=t.exec(n);return e}function HI(n){let e=[],t=/:\s*([A-Za-z_][\w]*)\b/g,i=t.exec(n);for(;i;)e.push(i[1]),i=t.exec(n);return e}function YI(n,e){let i=new RegExp(`\\bstruct\\s+${Yu(e)}\\s*\\{`,"g").exec(n);if(!i)return null;let r=n.indexOf("{",i.index),s=Rw(n,r,"{","}");return s<0?null:n.slice(r+1,s)}function qI(n,e){let t=Yu(e),i=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${t}\\b`,"g"),r=i.exec(n);for(;r;){if(XI(n,r.index)===0)return!0;r=i.exec(n)}return!1}function ZI(n){let e=0;for(;n.has(e);)e++;return e}function Rw(n,e,t,i){let r=0,s=0,o=!1;for(let a=e;a0){c==="/"&&l==="*"?(s++,a++):c==="*"&&l==="/"&&(s--,a++);continue}if(c==="/"&&l==="/"){o=!0,a++;continue}if(c==="/"&&l==="*"){s=1,a++;continue}if(c===t&&r++,c===i&&--r===0)return a}return-1}function XI(n,e){let t=0,i=0,r=!1;for(let s=0;s0){o==="/"&&a==="*"?(i++,s++):o==="*"&&a==="/"&&(i--,s++);continue}o==="/"&&a==="/"?(r=!0,s++):o==="/"&&a==="*"?(i=1,s++):o==="{"?t++:o==="}"&&t--}return t}function Yu(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var ag=C(()=>{J()});function Bw(n,e,t){let i=[],r=[];for(let[s,o]of Object.entries(t)){lB(n,s);let a=o.interpolation==="flat"?"flat ":"",c=e==="vertex"?"out":"in";i.push(`${a}${c} ${Hu(o.type)} ${s};`),e==="vertex"&&r.push(`${s} = ${aB(o.type)};`)}return{declarations:i.join(` +`)}}function Hu(n){let{primitiveType:e,components:t}=kt.getAttributeShaderTypeInfo(n),i=e==="i32"?"int":e==="u32"?"uint":"float";return t===1?i:`${i==="int"?"i":i==="uint"?"u":""}vec${t}`}function HI(n,e){let t=Yu(e);if(new RegExp(`\\b(?:in|attribute)\\s+(?:(?:lowp|mediump|highp)\\s+)?[A-Za-z_][A-Za-z0-9_]*\\s+${t}\\s*(?:\\[|;)`).test(n))throw new Error(`ShaderPlugin vertex input "${e}" conflicts with an existing GLSL input`)}function YI(n,e){let i=new RegExp(`\\bfn\\s+${Yu(e)}\\s*\\(`,"g").exec(n);if(!i)throw new Error(`ShaderPlugin vertex inputs require WGSL vertex entry point "${e}"`);let r=n.indexOf("(",i.index),s=Rw(n,r,"(",")");if(s<0)throw new Error(`Unable to parse WGSL vertex entry point "${e}" parameters`);return{openParenthesis:r,closeParenthesis:s}}function qI(n,e){let t=Lw(e),i=new Set(Mw(e)),r=ZI(e);for(let s of r){let o=XI(n,s);if(o!==null){t.push(...Lw(o));for(let a of Mw(o))i.add(a)}}return{locations:t,names:i}}function Lw(n){let e=[],t=/@location\s*\(\s*(\d+)\s*\)/g,i=t.exec(n);for(;i;)e.push(Number(i[1])),i=t.exec(n);return e}function Mw(n){let e=[],t=/(?:^|,)\s*(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:/gm,i=t.exec(n);for(;i;)e.push(i[1]),i=t.exec(n);return e}function ZI(n){let e=[],t=/:\s*([A-Za-z_][\w]*)\b/g,i=t.exec(n);for(;i;)e.push(i[1]),i=t.exec(n);return e}function XI(n,e){let i=new RegExp(`\\bstruct\\s+${Yu(e)}\\s*\\{`,"g").exec(n);if(!i)return null;let r=n.indexOf("{",i.index),s=Rw(n,r,"{","}");return s<0?null:n.slice(r+1,s)}function KI(n,e){let t=Yu(e),i=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${t}\\b`,"g"),r=i.exec(n);for(;r;){if(JI(n,r.index)===0)return!0;r=i.exec(n)}return!1}function QI(n){let e=0;for(;n.has(e);)e++;return e}function Rw(n,e,t,i){let r=0,s=0,o=!1;for(let a=e;a0){c==="/"&&l==="*"?(s++,a++):c==="*"&&l==="/"&&(s--,a++);continue}if(c==="/"&&l==="/"){o=!0,a++;continue}if(c==="/"&&l==="*"){s=1,a++;continue}if(c===t&&r++,c===i&&--r===0)return a}return-1}function JI(n,e){let t=0,i=0,r=!1;for(let s=0;s0){o==="/"&&a==="*"?(i++,s++):o==="*"&&a==="/"&&(i--,s++);continue}o==="/"&&a==="/"?(r=!0,s++):o==="/"&&a==="*"?(i=1,s++):o==="{"?t++:o==="}"&&t--}return t}function Yu(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var ag=C(()=>{J()});function Bw(n,e,t){let i=[],r=[];for(let[s,o]of Object.entries(t)){dB(n,s);let a=o.interpolation==="flat"?"flat ":"",c=e==="vertex"?"out":"in";i.push(`${a}${c} ${Hu(o.type)} ${s};`),e==="vertex"&&r.push(`${s} = ${uB(o.type)};`)}return{declarations:i.join(` `),initialization:r.join(` -`)}}function Ow(n,e,t,i){let r=Object.entries(i);if(r.length===0)return{source:n,declarations:"",vertexInitialization:"",fragmentInitialization:""};let s=n,o=qu(s,e,"vertex"),a=KI(s,o),c=qu(s,t,"fragment"),l=QI(s,c),u=cg(s,a),f=cg(s,l.type),d=new Set([...Zu(o.parameters),...Zu(u.body),...Zu(c.parameters),...Zu(f.body)]),h=new Set([...Iw(u.body),...Iw(f.body)]),p=[],m=[],g=[],v=[];for(let[E,w]of r){if(d.has(E)||sB(s,E))throw new Error(`ShaderPlugin varying "${E}" conflicts with existing WGSL stage I/O or a module variable`);let T=oB(h);h.add(T);let R=w.interpolation==="flat"?" @interpolate(flat)":"";p.push(` @location(${T})${R} ${E}: ${w.type},`),m.push(`var ${E}: ${w.type};`),g.push(`${E} = ${cB(w.type)};`),v.push(`${E} = ${l.name}.${E};`)}JI(s,a,o.openBrace,o.closeBrace),s=eB(s,a,o,r.map(([E])=>E)),o=qu(s,e,"vertex"),s=tB(s,o,r.map(([E])=>E));let b=(a===l.type?[a]:[a,l.type]).map(E=>cg(s,E).closeBrace).sort((E,w)=>w-E);for(let E of b)s=s.slice(0,E)+`${p.join(` +`)}}function Ow(n,e,t,i){let r=Object.entries(i);if(r.length===0)return{source:n,declarations:"",vertexInitialization:"",fragmentInitialization:""};let s=n,o=qu(s,e,"vertex"),a=eB(s,o),c=qu(s,t,"fragment"),l=tB(s,c),u=cg(s,a),f=cg(s,l.type),d=new Set([...Zu(o.parameters),...Zu(u.body),...Zu(c.parameters),...Zu(f.body)]),h=new Set([...Iw(u.body),...Iw(f.body)]),p=[],m=[],g=[],v=[];for(let[E,w]of r){if(d.has(E)||cB(s,E))throw new Error(`ShaderPlugin varying "${E}" conflicts with existing WGSL stage I/O or a module variable`);let T=lB(h);h.add(T);let R=w.interpolation==="flat"?" @interpolate(flat)":"";p.push(` @location(${T})${R} ${E}: ${w.type},`),m.push(`var ${E}: ${w.type};`),g.push(`${E} = ${fB(w.type)};`),v.push(`${E} = ${l.name}.${E};`)}nB(s,a,o.openBrace,o.closeBrace),s=iB(s,a,o,r.map(([E])=>E)),o=qu(s,e,"vertex"),s=rB(s,o,r.map(([E])=>E));let b=(a===l.type?[a]:[a,l.type]).map(E=>cg(s,E).closeBrace).sort((E,w)=>w-E);for(let E of b)s=s.slice(0,E)+`${p.join(` `)} `+s.slice(E);if(c=qu(s,t,"fragment"),!new RegExp(`\\b${Ur(l.name)}\\s*:`).test(c.parameters))throw new Error(`Unable to preserve WGSL fragment input "${l.name}"`);return{source:s,declarations:m.join(` `),vertexInitialization:g.join(` `),fragmentInitialization:v.join(` -`)}}function qu(n,e,t){let r=new RegExp(`\\bfn\\s+${Ur(e)}\\s*\\(`,"g").exec(n);if(!r)throw new Error(`ShaderPlugin varyings require WGSL ${t} entry point "${e}"`);let s=n.indexOf("(",r.index),o=Xu(n,s,"(",")"),a=n.indexOf("{",o),c=Xu(n,a,"{","}");if(o<0||a<0||c<0)throw new Error(`Unable to parse WGSL ${t} entry point "${e}"`);return{openParenthesis:s,closeParenthesis:o,openBrace:a,closeBrace:c,parameters:n.slice(s+1,o)}}function KI(n,e){let t=n.slice(e.closeParenthesis+1,e.openBrace),i=/->\s*([A-Za-z_][\w]*)\s*$/.exec(t.trim());if(!i||lg(n,i[1])===null)throw new Error("ShaderPlugin varyings require the WGSL vertex entry point to return a named struct");return i[1]}function QI(n,e){let t=[];for(let i of rB(e.parameters,",")){let r=/(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:\s*([A-Za-z_][\w]*)\s*$/.exec(i.trim());r&&lg(n,r[2])&&t.push({name:r[1],type:r[2]})}if(t.length!==1)throw new Error(`ShaderPlugin varyings require exactly one named WGSL fragment input struct; found ${t.length}`);return t[0]}function cg(n,e){let t=lg(n,e);if(!t)throw new Error(`Unable to find WGSL stage I/O struct "${e}"`);return t}function lg(n,e){let i=new RegExp(`\\bstruct\\s+${Ur(e)}\\s*\\{`,"g").exec(n);if(!i)return null;let r=n.indexOf("{",i.index),s=Xu(n,r,"{","}");return s<0?null:{openBrace:r,closeBrace:s,body:n.slice(r+1,s)}}function JI(n,e,t,i){let r=new RegExp(`\\b${Ur(e)}\\s*\\(`,"g"),s=r.exec(n);for(;s;){if(s.indexi)throw new Error(`ShaderPlugin varying output struct "${e}" is constructed outside the selected vertex entry point`);s=r.exec(n)}}function eB(n,e,t,i){let r=new RegExp(`\\b${Ur(e)}\\s*\\(`,"g"),s=[],o=r.exec(n);for(;o;){if(o.index>t.openBrace&&o.indext.closeBrace)throw new Error(`Unable to parse WGSL output constructor "${e}"`);s.push({openParenthesis:a,closeParenthesis:c})}o=r.exec(n)}for(let a of s.sort((c,l)=>l.closeParenthesis-c.closeParenthesis)){let l=n.slice(a.openParenthesis+1,a.closeParenthesis).trim()?", ":"";n=n.slice(0,a.closeParenthesis)+l+i.join(", ")+n.slice(a.closeParenthesis)}return n}function tB(n,e,t){let i=nB(n,e.openBrace+1,e.closeBrace);for(let r=i.length-1;r>=0;r--){let s=i[r],o=n.slice(s.expressionStart,s.semicolon).trim();if(!o)throw new Error("ShaderPlugin varying vertex entry point cannot use an empty return");let a=`_luma_vertexOutput${r}`,c=t.map(u=>`${a}.${u} = ${u};`).join(` +`)}}function qu(n,e,t){let r=new RegExp(`\\bfn\\s+${Ur(e)}\\s*\\(`,"g").exec(n);if(!r)throw new Error(`ShaderPlugin varyings require WGSL ${t} entry point "${e}"`);let s=n.indexOf("(",r.index),o=Xu(n,s,"(",")"),a=n.indexOf("{",o),c=Xu(n,a,"{","}");if(o<0||a<0||c<0)throw new Error(`Unable to parse WGSL ${t} entry point "${e}"`);return{openParenthesis:s,closeParenthesis:o,openBrace:a,closeBrace:c,parameters:n.slice(s+1,o)}}function eB(n,e){let t=n.slice(e.closeParenthesis+1,e.openBrace),i=/->\s*([A-Za-z_][\w]*)\s*$/.exec(t.trim());if(!i||lg(n,i[1])===null)throw new Error("ShaderPlugin varyings require the WGSL vertex entry point to return a named struct");return i[1]}function tB(n,e){let t=[];for(let i of aB(e.parameters,",")){let r=/(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:\s*([A-Za-z_][\w]*)\s*$/.exec(i.trim());r&&lg(n,r[2])&&t.push({name:r[1],type:r[2]})}if(t.length!==1)throw new Error(`ShaderPlugin varyings require exactly one named WGSL fragment input struct; found ${t.length}`);return t[0]}function cg(n,e){let t=lg(n,e);if(!t)throw new Error(`Unable to find WGSL stage I/O struct "${e}"`);return t}function lg(n,e){let i=new RegExp(`\\bstruct\\s+${Ur(e)}\\s*\\{`,"g").exec(n);if(!i)return null;let r=n.indexOf("{",i.index),s=Xu(n,r,"{","}");return s<0?null:{openBrace:r,closeBrace:s,body:n.slice(r+1,s)}}function nB(n,e,t,i){let r=new RegExp(`\\b${Ur(e)}\\s*\\(`,"g"),s=r.exec(n);for(;s;){if(s.indexi)throw new Error(`ShaderPlugin varying output struct "${e}" is constructed outside the selected vertex entry point`);s=r.exec(n)}}function iB(n,e,t,i){let r=new RegExp(`\\b${Ur(e)}\\s*\\(`,"g"),s=[],o=r.exec(n);for(;o;){if(o.index>t.openBrace&&o.indext.closeBrace)throw new Error(`Unable to parse WGSL output constructor "${e}"`);s.push({openParenthesis:a,closeParenthesis:c})}o=r.exec(n)}for(let a of s.sort((c,l)=>l.closeParenthesis-c.closeParenthesis)){let l=n.slice(a.openParenthesis+1,a.closeParenthesis).trim()?", ":"";n=n.slice(0,a.closeParenthesis)+l+i.join(", ")+n.slice(a.closeParenthesis)}return n}function rB(n,e,t){let i=sB(n,e.openBrace+1,e.closeBrace);for(let r=i.length-1;r>=0;r--){let s=i[r],o=n.slice(s.expressionStart,s.semicolon).trim();if(!o)throw new Error("ShaderPlugin varying vertex entry point cannot use an empty return");let a=`_luma_vertexOutput${r}`,c=t.map(u=>`${a}.${u} = ${u};`).join(` `),l=`{ var ${a} = ${o}; ${c} return ${a}; -}`;n=n.slice(0,s.start)+l+n.slice(s.semicolon+1)}return n}function nB(n,e,t){let i=[],r=e;for(;rt?t:r+1}if(n[i]==="/"&&n[i+1]==="*"){let r=1;for(i+=2;i0;)n[i]==="/"&&n[i+1]==="*"?(r++,i+=2):n[i]==="*"&&n[i+1]==="/"?(r--,i+=2):i++}return i}function rB(n,e){let t=[],i=0,r=0,s=0;for(let o=0;o"&&s--,a===e&&r===0&&s===0&&(t.push(n.slice(i,o)),i=o+1)}return t.push(n.slice(i)),t}function Iw(n){let e=[],t=/@location\s*\(\s*(\d+)\s*\)/g,i=t.exec(n);for(;i;)e.push(Number(i[1])),i=t.exec(n);return e}function Zu(n){let e=[],t=/(?:^|,)\s*(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:/gm,i=t.exec(n);for(;i;)e.push(i[1]),i=t.exec(n);return e}function sB(n,e){let t=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${Ur(e)}\\b`,"g"),i=t.exec(n);for(;i;){if(uB(n,i.index)===0)return!0;i=t.exec(n)}return!1}function oB(n){let e=0;for(;n.has(e);)e++;return e}function aB(n){let{primitiveType:e,components:t}=kt.getAttributeShaderTypeInfo(n),i=e==="u32"?"0u":e==="i32"?"0":"0.0";return t===1?i:`${Hu(n)}(${i})`}function cB(n){let{primitiveType:e,components:t}=kt.getAttributeShaderTypeInfo(n),i=`${e}(0)`;return t===1?i:`${n}(${i})`}function lB(n,e){if(new RegExp(`\\b(?:flat\\s+|smooth\\s+)?(?:in|out|varying)\\s+(?:(?:lowp|mediump|highp)\\s+)?[A-Za-z_][A-Za-z0-9_]*\\s+${Ur(e)}\\s*(?:\\[|;)`).test(n))throw new Error(`ShaderPlugin varying "${e}" conflicts with existing GLSL stage I/O`)}function Xu(n,e,t,i){let r=0,s=0,o=!1;for(let a=e;a0){c==="/"&&l==="*"?(s++,a++):c==="*"&&l==="/"&&(s--,a++);continue}if(c==="/"&&l==="/"){o=!0,a++;continue}if(c==="/"&&l==="*"){s=1,a++;continue}if(c===t&&r++,c===i&&--r===0)return a}return-1}function uB(n,e){let t=0;for(let i=0;i{J();ag()});function zw(n){let e=Cr(n.modules||[]),{source:t,bindingAssignments:i}=dB(n.platformInfo,{...n,source:n.source,stage:"vertex",modules:e});return{source:t,getUniforms:$w(e),bindingAssignments:i,bindingTable:ju(t,i),shaderLayout:bu(t,{vertexEntryPoint:n.vertexEntryPoint,scanVertexAttributes:n.scanVertexAttributes})}}function Uw(n){let{vs:e,fs:t}=n,i=Cr(n.modules||[]);return{vs:Nw(n.platformInfo,{...n,source:e,stage:"vertex",modules:i}),fs:Nw(n.platformInfo,{...n,source:t,stage:"fragment",modules:i}),getUniforms:$w(i)}}function dB(n,e){let{source:t,stage:i,modules:r,defines:s={},hookFunctions:o=[],inject:a={},pluginInjections:c={},pluginVertexInputs:l={},pluginVaryings:u={},vertexEntryPoint:f="vertexMain",fragmentEntryPoint:d="fragmentMain",log:h}=e;yi(typeof t=="string","shader source must be a string");let p=zr(t,{defines:s}),m=kw(p,f,l),g=Ow(m.source,f,d,u),v=g.source,y="",b=rg(o),x={},E={},w={};Gw(c,x,E,w);for(let V in a){let G=typeof a[V]=="string"?{injection:a[V],order:0}:a[V],q=/^(v|f)s:(#)?([\w-]+)$/.exec(V);if(q){let X=q[2],se=q[3];X?se==="decl"?E[V]=[G]:w[V]=[G]:x[V]=[G]}else w[V]=[G]}hB(m.declarations,m.initialization,E,w),pB(g,E,w);let T=r,R=vB(v),F=bB(R.source),O=SB(T,e._bindingRegistry,F,s),j=[];for(let V of T){h&&gm(V,v,h);let G=zr(Vw(V,"wgsl",h),{defines:s}),q=xB(G,V,{usedBindingsByGroup:F,bindingRegistry:e._bindingRegistry,reservedBindingKeysByGroup:O});j.push(...q.bindingAssignments);let X=q.source;y+=X;let se=mB(V);for(let le in se){let he=/^(v|f)s:#([\w-]+)$/.exec(le);if(he){let Ct=he[2]==="decl"?E:w;Ct[le]=Ct[le]||[],Ct[le].push(se[le])}else x[le]=x[le]||[],x[le].push(se[le])}}return y+=fg,y=wa(y,i,gB(E),!1,"wgsl",{vertex:f,fragment:d}),y+=_B(b,x),y+=AB(j),y+=R.source,y=wa(y,i,w,!1,"wgsl",{vertex:f,fragment:d}),MB(y),{source:y,bindingAssignments:j}}function Nw(n,e){let{source:t,stage:i,language:r="glsl",modules:s,defines:o={},hookFunctions:a=[],inject:c={},pluginInjections:l={},pluginVertexInputs:u={},pluginVaryings:f={},prologue:d=!0,log:h}=e;yi(typeof t=="string","shader source must be a string");let p=r==="glsl"?Ew(t).version:-1,m=n.shaderLanguageVersion,g=p===100?"#version 100":"#version 300 es",y=t.split(` +}`;n=n.slice(0,s.start)+l+n.slice(s.semicolon+1)}return n}function sB(n,e,t){let i=[],r=e;for(;rt?t:r+1}if(n[i]==="/"&&n[i+1]==="*"){let r=1;for(i+=2;i0;)n[i]==="/"&&n[i+1]==="*"?(r++,i+=2):n[i]==="*"&&n[i+1]==="/"?(r--,i+=2):i++}return i}function aB(n,e){let t=[],i=0,r=0,s=0;for(let o=0;o"&&s--,a===e&&r===0&&s===0&&(t.push(n.slice(i,o)),i=o+1)}return t.push(n.slice(i)),t}function Iw(n){let e=[],t=/@location\s*\(\s*(\d+)\s*\)/g,i=t.exec(n);for(;i;)e.push(Number(i[1])),i=t.exec(n);return e}function Zu(n){let e=[],t=/(?:^|,)\s*(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:/gm,i=t.exec(n);for(;i;)e.push(i[1]),i=t.exec(n);return e}function cB(n,e){let t=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${Ur(e)}\\b`,"g"),i=t.exec(n);for(;i;){if(hB(n,i.index)===0)return!0;i=t.exec(n)}return!1}function lB(n){let e=0;for(;n.has(e);)e++;return e}function uB(n){let{primitiveType:e,components:t}=kt.getAttributeShaderTypeInfo(n),i=e==="u32"?"0u":e==="i32"?"0":"0.0";return t===1?i:`${Hu(n)}(${i})`}function fB(n){let{primitiveType:e,components:t}=kt.getAttributeShaderTypeInfo(n),i=`${e}(0)`;return t===1?i:`${n}(${i})`}function dB(n,e){if(new RegExp(`\\b(?:flat\\s+|smooth\\s+)?(?:in|out|varying)\\s+(?:(?:lowp|mediump|highp)\\s+)?[A-Za-z_][A-Za-z0-9_]*\\s+${Ur(e)}\\s*(?:\\[|;)`).test(n))throw new Error(`ShaderPlugin varying "${e}" conflicts with existing GLSL stage I/O`)}function Xu(n,e,t,i){let r=0,s=0,o=!1;for(let a=e;a0){c==="/"&&l==="*"?(s++,a++):c==="*"&&l==="/"&&(s--,a++);continue}if(c==="/"&&l==="/"){o=!0,a++;continue}if(c==="/"&&l==="*"){s=1,a++;continue}if(c===t&&r++,c===i&&--r===0)return a}return-1}function hB(n,e){let t=0;for(let i=0;i{J();ag()});function zw(n){let e=Cr(n.modules||[]),{source:t,bindingAssignments:i}=mB(n.platformInfo,{...n,source:n.source,stage:"vertex",modules:e});return{source:t,getUniforms:$w(e),bindingAssignments:i,bindingTable:ju(t,i),shaderLayout:bu(t,{vertexEntryPoint:n.vertexEntryPoint,scanVertexAttributes:n.scanVertexAttributes})}}function Uw(n){let{vs:e,fs:t}=n,i=Cr(n.modules||[]);return{vs:Nw(n.platformInfo,{...n,source:e,stage:"vertex",modules:i}),fs:Nw(n.platformInfo,{...n,source:t,stage:"fragment",modules:i}),getUniforms:$w(i)}}function mB(n,e){let{source:t,stage:i,modules:r,defines:s={},hookFunctions:o=[],inject:a={},pluginInjections:c={},pluginVertexInputs:l={},pluginVaryings:u={},vertexEntryPoint:f="vertexMain",fragmentEntryPoint:d="fragmentMain",log:h}=e;yi(typeof t=="string","shader source must be a string");let p=zr(t,{defines:s}),m=kw(p,f,l),g=Ow(m.source,f,d,u),v=g.source,y="",b=rg(o),x={},E={},w={};Gw(c,x,E,w);for(let V in a){let G=typeof a[V]=="string"?{injection:a[V],order:0}:a[V],q=/^(v|f)s:(#)?([\w-]+)$/.exec(V);if(q){let X=q[2],se=q[3];X?se==="decl"?E[V]=[G]:w[V]=[G]:x[V]=[G]}else w[V]=[G]}gB(m.declarations,m.initialization,E,w),_B(g,E,w);let T=r,R=EB(v),F=wB(R.source),O=TB(T,e._bindingRegistry,F,s),j=[];for(let V of T){h&&gm(V,v,h);let G=zr(Vw(V,"wgsl",h),{defines:s}),q=SB(G,V,{usedBindingsByGroup:F,bindingRegistry:e._bindingRegistry,reservedBindingKeysByGroup:O});j.push(...q.bindingAssignments);let X=q.source;y+=X;let se=yB(V);for(let le in se){let he=/^(v|f)s:#([\w-]+)$/.exec(le);if(he){let Ct=he[2]==="decl"?E:w;Ct[le]=Ct[le]||[],Ct[le].push(se[le])}else x[le]=x[le]||[],x[le].push(se[le])}}return y+=fg,y=wa(y,i,bB(E),!1,"wgsl",{vertex:f,fragment:d}),y+=vB(b,x),y+=IB(j),y+=R.source,y=wa(y,i,w,!1,"wgsl",{vertex:f,fragment:d}),RB(y),{source:y,bindingAssignments:j}}function Nw(n,e){let{source:t,stage:i,language:r="glsl",modules:s,defines:o={},hookFunctions:a=[],inject:c={},pluginInjections:l={},pluginVertexInputs:u={},pluginVaryings:f={},prologue:d=!0,log:h}=e;yi(typeof t=="string","shader source must be a string");let p=r==="glsl"?Ew(t).version:-1,m=n.shaderLanguageVersion,g=p===100?"#version 100":"#version 300 es",y=t.split(` `).slice(1).join(` `),b={};s.forEach(O=>{Object.assign(b,O.defines)}),Object.assign(b,o);let x="";switch(r){case"wgsl":break;case"glsl":x=d?`${g} @@ -99,35 +99,35 @@ return ${a}; ${`#define SHADER_TYPE_${i.toUpperCase()}`} ${gw(n)} -${i==="fragment"?fB:""} +${i==="fragment"?pB:""} // ----- APPLICATION DEFINES ------------------------- -${yB(b)} +${xB(b)} `:`${g} -`;break}let E=rg(a),w={},T={},R={};Gw(l,w,T,R);for(let O in c){let j=typeof c[O]=="string"?{injection:c[O],order:0}:c[O],V=/^(v|f)s:(#)?([\w-]+)$/.exec(O);if(V){let G=V[2],q=V[3];G?q==="decl"?T[O]=[j]:R[O]=[j]:w[O]=[j]}else R[O]=[j]}if(i==="vertex"){let O=Aw(y,u);O&&(T["vs:#decl"]=T["vs:#decl"]||[],T["vs:#decl"].push({injection:O,order:Number.MIN_SAFE_INTEGER}))}let F=Bw(y,i,f);if(F.declarations){let O=i==="vertex"?"vs:#decl":"fs:#decl";T[O]=T[O]||[],T[O].push({injection:F.declarations,order:Number.MIN_SAFE_INTEGER})}F.initialization&&(R["vs:#main-start"]=R["vs:#main-start"]||[],R["vs:#main-start"].push({injection:F.initialization,order:Number.MIN_SAFE_INTEGER}));for(let O of s){h&&gm(O,y,h);let j=Vw(O,i,h);x+=j;let V=O.instance?.normalizedInjections[i]||{};for(let G in V){let q=/^(v|f)s:#([\w-]+)$/.exec(G);if(q){let se=q[2]==="decl"?T:R;se[G]=se[G]||[],se[G].push(V[G])}else w[G]=w[G]||[],w[G].push(V[G])}}return x+="// ----- MAIN SHADER SOURCE -------------------------",x+=fg,x=wa(x,i,T),x+=Wu(E[i],w),x+=y,x=wa(x,i,R),r==="glsl"&&p!==m&&(x=bw(x,i)),r==="glsl"&&tg(x,i,h),x.trim()}function $w(n){return function(t){let i={};for(let r of n){let s=r.getUniforms?.(t,i);Object.assign(i,s)}return i}}function Gw(n,e,t,i){for(let r in n){let s=/^(v|f)s:(#)?([\w-]+)$/.exec(r);if(s){let o=s[2],a=s[3],c=o?a==="decl"?t:i:e;c[r]=c[r]||[],c[r].push(...n[r])}else i[r]=i[r]||[],i[r].push(...n[r])}}function hB(n,e,t,i){n&&(t["vs:#decl"]=t["vs:#decl"]||[],t["vs:#decl"].push({injection:n,order:Number.MIN_SAFE_INTEGER})),e&&(i["vs:#main-start"]=i["vs:#main-start"]||[],i["vs:#main-start"].push({injection:e,order:Number.MIN_SAFE_INTEGER}))}function pB(n,e,t){n.declarations&&(e["vs:#decl"]=e["vs:#decl"]||[],e["vs:#decl"].push({injection:n.declarations,order:Number.MIN_SAFE_INTEGER})),n.vertexInitialization&&(t["vs:#main-start"]=t["vs:#main-start"]||[],t["vs:#main-start"].push({injection:n.vertexInitialization,order:Number.MIN_SAFE_INTEGER})),n.fragmentInitialization&&(t["fs:#main-start"]=t["fs:#main-start"]||[],t["fs:#main-start"].push({injection:n.fragmentInitialization,order:Number.MIN_SAFE_INTEGER}))}function mB(n){return{...n.instance?.normalizedInjections.vertex||{},...n.instance?.normalizedInjections.fragment||{}}}function gB(n){let e=[...n["vs:#decl"]||[],...n["fs:#decl"]||[]];return e.length?{"vs:#decl":e}:{}}function _B(n,e){return Wu(n.vertex,e,"wgsl")+Wu(n.fragment,e,"wgsl")}function yB(n={}){let e="";for(let t in n){let i=n[t];(i||Number.isFinite(i))&&(e+=`#define ${t.toUpperCase()} ${n[t]} +`;break}let E=rg(a),w={},T={},R={};Gw(l,w,T,R);for(let O in c){let j=typeof c[O]=="string"?{injection:c[O],order:0}:c[O],V=/^(v|f)s:(#)?([\w-]+)$/.exec(O);if(V){let G=V[2],q=V[3];G?q==="decl"?T[O]=[j]:R[O]=[j]:w[O]=[j]}else R[O]=[j]}if(i==="vertex"){let O=Aw(y,u);O&&(T["vs:#decl"]=T["vs:#decl"]||[],T["vs:#decl"].push({injection:O,order:Number.MIN_SAFE_INTEGER}))}let F=Bw(y,i,f);if(F.declarations){let O=i==="vertex"?"vs:#decl":"fs:#decl";T[O]=T[O]||[],T[O].push({injection:F.declarations,order:Number.MIN_SAFE_INTEGER})}F.initialization&&(R["vs:#main-start"]=R["vs:#main-start"]||[],R["vs:#main-start"].push({injection:F.initialization,order:Number.MIN_SAFE_INTEGER}));for(let O of s){h&&gm(O,y,h);let j=Vw(O,i,h);x+=j;let V=O.instance?.normalizedInjections[i]||{};for(let G in V){let q=/^(v|f)s:#([\w-]+)$/.exec(G);if(q){let se=q[2]==="decl"?T:R;se[G]=se[G]||[],se[G].push(V[G])}else w[G]=w[G]||[],w[G].push(V[G])}}return x+="// ----- MAIN SHADER SOURCE -------------------------",x+=fg,x=wa(x,i,T),x+=Wu(E[i],w),x+=y,x=wa(x,i,R),r==="glsl"&&p!==m&&(x=bw(x,i)),r==="glsl"&&tg(x,i,h),x.trim()}function $w(n){return function(t){let i={};for(let r of n){let s=r.getUniforms?.(t,i);Object.assign(i,s)}return i}}function Gw(n,e,t,i){for(let r in n){let s=/^(v|f)s:(#)?([\w-]+)$/.exec(r);if(s){let o=s[2],a=s[3],c=o?a==="decl"?t:i:e;c[r]=c[r]||[],c[r].push(...n[r])}else i[r]=i[r]||[],i[r].push(...n[r])}}function gB(n,e,t,i){n&&(t["vs:#decl"]=t["vs:#decl"]||[],t["vs:#decl"].push({injection:n,order:Number.MIN_SAFE_INTEGER})),e&&(i["vs:#main-start"]=i["vs:#main-start"]||[],i["vs:#main-start"].push({injection:e,order:Number.MIN_SAFE_INTEGER}))}function _B(n,e,t){n.declarations&&(e["vs:#decl"]=e["vs:#decl"]||[],e["vs:#decl"].push({injection:n.declarations,order:Number.MIN_SAFE_INTEGER})),n.vertexInitialization&&(t["vs:#main-start"]=t["vs:#main-start"]||[],t["vs:#main-start"].push({injection:n.vertexInitialization,order:Number.MIN_SAFE_INTEGER})),n.fragmentInitialization&&(t["fs:#main-start"]=t["fs:#main-start"]||[],t["fs:#main-start"].push({injection:n.fragmentInitialization,order:Number.MIN_SAFE_INTEGER}))}function yB(n){return{...n.instance?.normalizedInjections.vertex||{},...n.instance?.normalizedInjections.fragment||{}}}function bB(n){let e=[...n["vs:#decl"]||[],...n["fs:#decl"]||[]];return e.length?{"vs:#decl":e}:{}}function vB(n,e){return Wu(n.vertex,e,"wgsl")+Wu(n.fragment,e,"wgsl")}function xB(n={}){let e="";for(let t in n){let i=n[t];(i||Number.isFinite(i))&&(e+=`#define ${t.toUpperCase()} ${n[t]} `)}return e}function Vw(n,e,t){let i;switch(e){case"vertex":i=n.vs||"";break;case"fragment":i=n.fs||"";break;case"wgsl":i=n.source||"";break;default:yi(!1)}if(!n.name)throw new Error("Shader module must have a name");eg(n,e,{log:t});let r=n.name.toUpperCase().replace(/[^0-9a-z]/gi,"_"),s=`// ----- MODULE ${n.name} --------------- `;return e!=="wgsl"&&(s+=`#define MODULE_${r} `),s+=`${i} -`,s}function bB(n){let e=new Map;for(let t of Pr(n,Fx)){let i=Number(t.bindingToken),r=Number(t.groupToken);dg(r,i,t.name),Zs(e,r,i,`application binding "${t.name}"`)}return e}function vB(n){let e=Pr(n,gu),t=new Map;for(let s of e){if(s.bindingToken==="auto")continue;let o=Number(s.bindingToken),a=Number(s.groupToken);dg(a,o,s.name),Zs(t,a,o,`application binding "${s.name}"`)}let i={sawSupportedBindingDeclaration:e.length>0},r=om(n,gu,s=>EB(s,t,i));if(am(n)&&!i.sawSupportedBindingDeclaration)throw new Error('Unsupported @binding(auto) declaration form in application WGSL. Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.');return{source:r}}function xB(n,e,t){let i=[],s={sawSupportedBindingDeclaration:Pr(n,Us).length>0,nextHintedBindingLocation:typeof e.firstBindingSlot=="number"?e.firstBindingSlot:null},o=om(n,Us,a=>wB(a,{module:e,context:t,bindingAssignments:i,relocationState:s}));if(am(n)&&!s.sawSupportedBindingDeclaration)throw new Error(`Unsupported @binding(auto) declaration form in module "${e.name}". Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.`);return{source:o,bindingAssignments:i}}function wB(n,e){let{module:t,context:i,bindingAssignments:r,relocationState:s}=e,{match:o,bindingToken:a,groupToken:c,name:l}=n,u=Number(c);if(a==="auto"){let d=Ww(u,t.name,l),h=i.bindingRegistry?.get(d),p=h!==void 0?h:TB(u,i.usedBindingsByGroup,t.name,s.nextHintedBindingLocation??void 0,i.bindingRegistry);return Fw(t.name,u,p,l),h!==void 0&&PB(i.reservedBindingKeysByGroup,u,p,d)?(r.push({moduleName:t.name,name:l,group:u,location:p}),o.replace(/@binding\(\s*auto\s*\)/,`@binding(${p})`)):(Zs(i.usedBindingsByGroup,u,p,`module "${t.name}" binding "${l}"`),i.bindingRegistry?.set(d,p),r.push({moduleName:t.name,name:l,group:u,location:p}),s.nextHintedBindingLocation!==null&&h===void 0&&(s.nextHintedBindingLocation=p+1),o.replace(/@binding\(\s*auto\s*\)/,`@binding(${p})`))}let f=Number(a);return Fw(t.name,u,f,l),Zs(i.usedBindingsByGroup,u,f,`module "${t.name}" binding "${l}"`),r.push({moduleName:t.name,name:l,group:u,location:f}),o}function EB(n,e,t){let{match:i,bindingToken:r,groupToken:s,name:o}=n,a=Number(s);if(r==="auto"){let c=LB(a,e);return dg(a,c,o),Zs(e,a,c,`application binding "${o}"`),i.replace(/@binding\(\s*auto\s*\)/,`@binding(${c})`)}return t.sawSupportedBindingDeclaration=!0,i}function SB(n,e,t,i){let r=new Map;if(!e)return r;for(let s of n)for(let o of CB(s,i)){let a=Ww(o.group,s.name,o.name),c=e.get(a);if(c!==void 0){let l=r.get(o.group)||new Map,u=l.get(c);if(u&&u!==a)throw new Error(`Duplicate WGSL binding reservation for modules "${u}" and "${a}": group ${o.group}, binding ${c}.`);Zs(t,o.group,c,`registered module binding "${a}"`),l.set(c,a),r.set(o.group,l)}}return r}function PB(n,e,t,i){let r=n.get(e);if(!r)return!1;let s=r.get(t);if(!s)return!1;if(s!==i)throw new Error(`Registered module binding "${i}" collided with "${s}": group ${e}, binding ${t}.`);return!0}function CB(n,e){let t=[],i=zr(n.source||"",{defines:e});for(let r of Pr(i,Us))t.push({name:r.name,group:Number(r.groupToken)});return t}function dg(n,e,t){if(n===0&&e>=Ha)throw new Error(`Application binding "${t}" in group 0 uses reserved binding ${e}. Application-owned explicit group-0 bindings must stay below ${Ha}.`)}function Fw(n,e,t,i){if(e===0&&t0?Math.max(...s)+1:0);for(;s.has(l)||o.has(l);)l++;for(let[u,f]of r||[])f===l&&u.startsWith(a)&&r?.delete(u);return l}function LB(n,e){let t=e.get(n)||new Set,i=0;for(;t.has(i);)i++;return i}function MB(n){let e=zx(n,Us);if(!e)return;let t=kB(n,e.index);throw t?new Error(`Unresolved @binding(auto) for module "${t}" binding "${e.name}" remained in assembled WGSL source.`):RB(n,e.index)?new Error(`Unresolved @binding(auto) for application binding "${e.name}" remained in assembled WGSL source.`):new Error(`Unresolved @binding(auto) remained in assembled WGSL source near "${IB(e.match)}".`)}function AB(n){if(n.length===0)return"";let e=`// ----- MODULE WGSL BINDING ASSIGNMENTS --------------- +`,s}function wB(n){let e=new Map;for(let t of Pr(n,Fx)){let i=Number(t.bindingToken),r=Number(t.groupToken);dg(r,i,t.name),Zs(e,r,i,`application binding "${t.name}"`)}return e}function EB(n){let e=Pr(n,gu),t=new Map;for(let s of e){if(s.bindingToken==="auto")continue;let o=Number(s.bindingToken),a=Number(s.groupToken);dg(a,o,s.name),Zs(t,a,o,`application binding "${s.name}"`)}let i={sawSupportedBindingDeclaration:e.length>0},r=om(n,gu,s=>CB(s,t,i));if(am(n)&&!i.sawSupportedBindingDeclaration)throw new Error('Unsupported @binding(auto) declaration form in application WGSL. Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.');return{source:r}}function SB(n,e,t){let i=[],s={sawSupportedBindingDeclaration:Pr(n,Us).length>0,nextHintedBindingLocation:typeof e.firstBindingSlot=="number"?e.firstBindingSlot:null},o=om(n,Us,a=>PB(a,{module:e,context:t,bindingAssignments:i,relocationState:s}));if(am(n)&&!s.sawSupportedBindingDeclaration)throw new Error(`Unsupported @binding(auto) declaration form in module "${e.name}". Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.`);return{source:o,bindingAssignments:i}}function PB(n,e){let{module:t,context:i,bindingAssignments:r,relocationState:s}=e,{match:o,bindingToken:a,groupToken:c,name:l}=n,u=Number(c);if(a==="auto"){let d=Ww(u,t.name,l),h=i.bindingRegistry?.get(d),p=h!==void 0?h:AB(u,i.usedBindingsByGroup,t.name,s.nextHintedBindingLocation??void 0,i.bindingRegistry);return Fw(t.name,u,p,l),h!==void 0&&LB(i.reservedBindingKeysByGroup,u,p,d)?(r.push({moduleName:t.name,name:l,group:u,location:p}),o.replace(/@binding\(\s*auto\s*\)/,`@binding(${p})`)):(Zs(i.usedBindingsByGroup,u,p,`module "${t.name}" binding "${l}"`),i.bindingRegistry?.set(d,p),r.push({moduleName:t.name,name:l,group:u,location:p}),s.nextHintedBindingLocation!==null&&h===void 0&&(s.nextHintedBindingLocation=p+1),o.replace(/@binding\(\s*auto\s*\)/,`@binding(${p})`))}let f=Number(a);return Fw(t.name,u,f,l),Zs(i.usedBindingsByGroup,u,f,`module "${t.name}" binding "${l}"`),r.push({moduleName:t.name,name:l,group:u,location:f}),o}function CB(n,e,t){let{match:i,bindingToken:r,groupToken:s,name:o}=n,a=Number(s);if(r==="auto"){let c=kB(a,e);return dg(a,c,o),Zs(e,a,c,`application binding "${o}"`),i.replace(/@binding\(\s*auto\s*\)/,`@binding(${c})`)}return t.sawSupportedBindingDeclaration=!0,i}function TB(n,e,t,i){let r=new Map;if(!e)return r;for(let s of n)for(let o of MB(s,i)){let a=Ww(o.group,s.name,o.name),c=e.get(a);if(c!==void 0){let l=r.get(o.group)||new Map,u=l.get(c);if(u&&u!==a)throw new Error(`Duplicate WGSL binding reservation for modules "${u}" and "${a}": group ${o.group}, binding ${c}.`);Zs(t,o.group,c,`registered module binding "${a}"`),l.set(c,a),r.set(o.group,l)}}return r}function LB(n,e,t,i){let r=n.get(e);if(!r)return!1;let s=r.get(t);if(!s)return!1;if(s!==i)throw new Error(`Registered module binding "${i}" collided with "${s}": group ${e}, binding ${t}.`);return!0}function MB(n,e){let t=[],i=zr(n.source||"",{defines:e});for(let r of Pr(i,Us))t.push({name:r.name,group:Number(r.groupToken)});return t}function dg(n,e,t){if(n===0&&e>=Ha)throw new Error(`Application binding "${t}" in group 0 uses reserved binding ${e}. Application-owned explicit group-0 bindings must stay below ${Ha}.`)}function Fw(n,e,t,i){if(e===0&&t0?Math.max(...s)+1:0);for(;s.has(l)||o.has(l);)l++;for(let[u,f]of r||[])f===l&&u.startsWith(a)&&r?.delete(u);return l}function kB(n,e){let t=e.get(n)||new Set,i=0;for(;t.has(i);)i++;return i}function RB(n){let e=zx(n,Us);if(!e)return;let t=BB(n,e.index);throw t?new Error(`Unresolved @binding(auto) for module "${t}" binding "${e.name}" remained in assembled WGSL source.`):OB(n,e.index)?new Error(`Unresolved @binding(auto) for application binding "${e.name}" remained in assembled WGSL source.`):new Error(`Unresolved @binding(auto) remained in assembled WGSL source near "${DB(e.match)}".`)}function IB(n){if(n.length===0)return"";let e=`// ----- MODULE WGSL BINDING ASSIGNMENTS --------------- `;for(let t of n)e+=`// ${t.moduleName}.${t.name} -> @group(${t.group}) @binding(${t.location}) `;return e+=` -`,e}function Ww(n,e,t){return`${n}:${e}:${t}`}function kB(n,e){let t=/^\/\/ ----- MODULE ([^\n]+) ---------------$/gm,i,r;for(r=t.exec(n);r&&r.index<=e;)i=r[1],r=t.exec(n);return i}function RB(n,e){let t=n.indexOf(fg);return t>=0?e>t:!0}function IB(n){return n.replace(/\s+/g," ").trim()}var fg,Ha,fB,jw=C(()=>{_m();_w();mm();xw();Eu();ng();ww();xu();Sw();sg();dm();og();ag();Dw();_u();fg=` +`,e}function Ww(n,e,t){return`${n}:${e}:${t}`}function BB(n,e){let t=/^\/\/ ----- MODULE ([^\n]+) ---------------$/gm,i,r;for(r=t.exec(n);r&&r.index<=e;)i=r[1],r=t.exec(n);return i}function OB(n,e){let t=n.indexOf(fg);return t>=0?e>t:!0}function DB(n){return n.replace(/\s+/g," ").trim()}var fg,Ha,pB,jw=C(()=>{_m();_w();mm();xw();Eu();ng();ww();xu();Sw();sg();dm();og();ag();Dw();_u();fg=` ${xa} -`,Ha=100,fB=`precision highp float; -`});var Kt,Xs,qi,Hw=C(()=>{Eu();jw();sg();og();dm();xu();Kt=class n{static defaultShaderAssemblers={};_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(e){return yi(e==="glsl"||e==="wgsl"),e==="wgsl"?(n.defaultShaderAssemblers.wgsl=n.defaultShaderAssemblers.wgsl||new qi,n.defaultShaderAssemblers.wgsl):(n.defaultShaderAssemblers.glsl=n.defaultShaderAssemblers.glsl||new Xs,n.defaultShaderAssemblers.glsl)}addDefaultModule(e){this._defaultModules.find(t=>t.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){let t=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(i=>i.name!==t)}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e)}_getModuleList(e=[]){let t=new Array(this._defaultModules.length+e.length),i={},r=0;for(let s=0,o=this._defaultModules.length;s(Object.assign(i,r.defines),i),{}),...e.defines}}static getPlatformPreprocessorDefines(e){let t=e.limits||{};return{LUMA_SUPPORTS_VERTEX_STORAGE_BUFFERS:e.type==="webgpu"&&(t.maxStorageBuffersInVertexStage||0)>0,LUMA_FP32_TAN_PRECISION_WORKAROUND:e.type==="webgpu"&&e.gpu.toLowerCase()!=="nvidia"&&e.gpu.toLowerCase()!=="amd",LUMA_FP64_INTEGER_ARITHMETIC:e.type==="webgpu"&&e.gpu.toLowerCase()==="apple"}}}});function hg(n){let{input:e,inputChannels:t,output:i}=n||{};if(!e)return OB;if(!t)throw new Error("inputChannels");let r=DB(t),s=Yw(e,t);return`#version 300 es +`,Ha=100,pB=`precision highp float; +`});var Xt,Xs,qi,Hw=C(()=>{Eu();jw();sg();og();dm();xu();Xt=class n{static defaultShaderAssemblers={};_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(e){return yi(e==="glsl"||e==="wgsl"),e==="wgsl"?(n.defaultShaderAssemblers.wgsl=n.defaultShaderAssemblers.wgsl||new qi,n.defaultShaderAssemblers.wgsl):(n.defaultShaderAssemblers.glsl=n.defaultShaderAssemblers.glsl||new Xs,n.defaultShaderAssemblers.glsl)}addDefaultModule(e){this._defaultModules.find(t=>t.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){let t=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(i=>i.name!==t)}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e)}_getModuleList(e=[]){let t=new Array(this._defaultModules.length+e.length),i={},r=0;for(let s=0,o=this._defaultModules.length;s(Object.assign(i,r.defines),i),{}),...e.defines}}static getPlatformPreprocessorDefines(e){let t=e.limits||{};return{LUMA_SUPPORTS_VERTEX_STORAGE_BUFFERS:e.type==="webgpu"&&(t.maxStorageBuffersInVertexStage||0)>0,LUMA_FP32_TAN_PRECISION_WORKAROUND:e.type==="webgpu"&&e.gpu.toLowerCase()!=="nvidia"&&e.gpu.toLowerCase()!=="amd",LUMA_FP64_INTEGER_ARITHMETIC:e.type==="webgpu"&&e.gpu.toLowerCase()==="apple"}}}});function hg(n){let{input:e,inputChannels:t,output:i}=n||{};if(!e)return FB;if(!t)throw new Error("inputChannels");let r=zB(t),s=Yw(e,t);return`#version 300 es in ${r} ${e}; out vec4 ${i}; void main() { ${i} = ${s}; -}`}function DB(n){switch(n){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${n}`)}}function Yw(n,e){switch(e){case 1:return`vec4(${n}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${n}, 0.0, 1.0)`;case 3:return`vec4(${n}, 1.0)`;case 4:return n;default:throw new Error(`invalid channels: ${e}`)}}var BB,OB,qw=C(()=>{BB=`out vec4 transform_output; +}`}function zB(n){switch(n){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${n}`)}}function Yw(n,e){switch(e){case 1:return`vec4(${n}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${n}, 0.0, 1.0)`;case 3:return`vec4(${n}, 1.0)`;case 4:return n;default:throw new Error(`invalid channels: ${e}`)}}var NB,FB,qw=C(()=>{NB=`out vec4 transform_output; void main() { transform_output = vec4(0); -}`,OB=`#version 300 es -${BB}`});function pg(n,{precision:e=Ye.precision}={}){return n=FB(n),`${parseFloat(n.toPrecision(e))}`}function vi(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Te(n,e,t){return UB(n,i=>Math.max(e,Math.min(t,i)))}function fn(n,e,t){return vi(n)?n.map((i,r)=>fn(i,e[r],t)):t*e+(1-t)*n}function $n(n,e,t){let i=Ye.EPSILON;t&&(Ye.EPSILON=t);try{if(n===e)return!0;if(vi(n)&&vi(e)){if(n.length!==e.length)return!1;for(let r=0;r{KX=1/Math.PI*180,QX=1/180*Math.PI,NB={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...NB}};Ye=globalThis.mathgl.config});var Qs,mg=C(()=>{Ks();Qs=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,t=0){for(let i=0;i0?", ":"")+pg(this[i],e);return`${e.printTypes?this.constructor.name:""}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t{Ks()});function gg(n,e){if(!n)throw new Error(`math.gl assertion ${e}`)}var Zw=C(()=>{});var Qu,Xw=C(()=>{mg();Ya();Zw();Qu=class extends Qs{get x(){return this[0]}set x(e){this[0]=Je(e)}get y(){return this[1]}set y(e){this[1]=Je(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let t=0;t=0&&e=0&&e=0?Math.round(n):n%.5===0?Math.floor(n):Math.round(n)}var we,Gn,lK,$r=C(()=>{we=typeof Float32Array<"u"?Float32Array:Array,Gn=Math.random;lK=Math.PI/180});var dt={};mi(dt,{add:()=>HB,angle:()=>fO,ceil:()=>YB,clone:()=>GB,copy:()=>WB,create:()=>Kw,cross:()=>rO,dist:()=>vO,distance:()=>tE,div:()=>bO,divide:()=>eE,dot:()=>iO,equals:()=>mO,exactEquals:()=>pO,floor:()=>qB,forEach:()=>EO,fromValues:()=>VB,inverse:()=>tO,len:()=>gO,length:()=>iE,lerp:()=>sO,max:()=>XB,min:()=>ZB,mul:()=>yO,multiply:()=>Jw,negate:()=>eO,normalize:()=>nO,random:()=>oO,rotate:()=>uO,round:()=>KB,scale:()=>QB,scaleAndAdd:()=>JB,set:()=>jB,sqrDist:()=>xO,sqrLen:()=>wO,squaredDistance:()=>nE,squaredLength:()=>rE,str:()=>hO,sub:()=>_O,subtract:()=>Qw,transformMat2:()=>aO,transformMat2d:()=>cO,transformMat3:()=>lO,transformMat4:()=>_g,zero:()=>dO});function Kw(){let n=new we(2);return we!=Float32Array&&(n[0]=0,n[1]=0),n}function GB(n){let e=new we(2);return e[0]=n[0],e[1]=n[1],e}function VB(n,e){let t=new we(2);return t[0]=n,t[1]=e,t}function WB(n,e){return n[0]=e[0],n[1]=e[1],n}function jB(n,e,t){return n[0]=e,n[1]=t,n}function HB(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n}function Qw(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n}function Jw(n,e,t){return n[0]=e[0]*t[0],n[1]=e[1]*t[1],n}function eE(n,e,t){return n[0]=e[0]/t[0],n[1]=e[1]/t[1],n}function YB(n,e){return n[0]=Math.ceil(e[0]),n[1]=Math.ceil(e[1]),n}function qB(n,e){return n[0]=Math.floor(e[0]),n[1]=Math.floor(e[1]),n}function ZB(n,e,t){return n[0]=Math.min(e[0],t[0]),n[1]=Math.min(e[1],t[1]),n}function XB(n,e,t){return n[0]=Math.max(e[0],t[0]),n[1]=Math.max(e[1],t[1]),n}function KB(n,e){return n[0]=Qt(e[0]),n[1]=Qt(e[1]),n}function QB(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n}function JB(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n}function tE(n,e){let t=e[0]-n[0],i=e[1]-n[1];return Math.sqrt(t*t+i*i)}function nE(n,e){let t=e[0]-n[0],i=e[1]-n[1];return t*t+i*i}function iE(n){let e=n[0],t=n[1];return Math.sqrt(e*e+t*t)}function rE(n){let e=n[0],t=n[1];return e*e+t*t}function eO(n,e){return n[0]=-e[0],n[1]=-e[1],n}function tO(n,e){return n[0]=1/e[0],n[1]=1/e[1],n}function nO(n,e){let t=e[0],i=e[1],r=t*t+i*i;return r>0&&(r=1/Math.sqrt(r)),n[0]=e[0]*r,n[1]=e[1]*r,n}function iO(n,e){return n[0]*e[0]+n[1]*e[1]}function rO(n,e,t){let i=e[0]*t[1]-e[1]*t[0];return n[0]=n[1]=0,n[2]=i,n}function sO(n,e,t,i){let r=e[0],s=e[1];return n[0]=r+i*(t[0]-r),n[1]=s+i*(t[1]-s),n}function oO(n,e){e=e===void 0?1:e;let t=Gn()*2*Math.PI;return n[0]=Math.cos(t)*e,n[1]=Math.sin(t)*e,n}function aO(n,e,t){let i=e[0],r=e[1];return n[0]=t[0]*i+t[2]*r,n[1]=t[1]*i+t[3]*r,n}function cO(n,e,t){let i=e[0],r=e[1];return n[0]=t[0]*i+t[2]*r+t[4],n[1]=t[1]*i+t[3]*r+t[5],n}function lO(n,e,t){let i=e[0],r=e[1];return n[0]=t[0]*i+t[3]*r+t[6],n[1]=t[1]*i+t[4]*r+t[7],n}function _g(n,e,t){let i=e[0],r=e[1];return n[0]=t[0]*i+t[4]*r+t[12],n[1]=t[1]*i+t[5]*r+t[13],n}function uO(n,e,t,i){let r=e[0]-t[0],s=e[1]-t[1],o=Math.sin(i),a=Math.cos(i);return n[0]=r*a-s*o+t[0],n[1]=r*o+s*a+t[1],n}function fO(n,e){let t=n[0],i=n[1],r=e[0],s=e[1],o=Math.sqrt((t*t+i*i)*(r*r+s*s)),a=o&&(t*r+i*s)/o;return Math.acos(Math.min(Math.max(a,-1),1))}function dO(n){return n[0]=0,n[1]=0,n}function hO(n){return`vec2(${n[0]}, ${n[1]})`}function pO(n,e){return n[0]===e[0]&&n[1]===e[1]}function mO(n,e){let t=n[0],i=n[1],r=e[0],s=e[1];return Math.abs(t-r)<=1e-6*Math.max(1,Math.abs(t),Math.abs(r))&&Math.abs(i-s)<=1e-6*Math.max(1,Math.abs(i),Math.abs(s))}var gO,_O,yO,bO,vO,xO,wO,EO,yg=C(()=>{$r();gO=iE,_O=Qw,yO=Jw,bO=eE,vO=tE,xO=nE,wO=rE,EO=function(){let n=Kw();return function(e,t,i,r,s,o){let a,c;for(t||(t=2),i||(i=0),r?c=Math.min(r*t+i,e.length):c=e.length,a=i;a{});var bt={};mi(bt,{add:()=>TO,angle:()=>Cg,bezier:()=>UO,ceil:()=>LO,clone:()=>SO,copy:()=>PO,create:()=>ef,cross:()=>Gr,dist:()=>ZO,distance:()=>fE,div:()=>qO,divide:()=>uE,dot:()=>qa,equals:()=>jO,exactEquals:()=>WO,floor:()=>MO,forEach:()=>QO,fromValues:()=>tf,hermite:()=>zO,inverse:()=>DO,len:()=>Tg,length:()=>aE,lerp:()=>NO,max:()=>kO,min:()=>AO,mul:()=>YO,multiply:()=>lE,negate:()=>OO,normalize:()=>vg,random:()=>$O,rotateX:()=>Eg,rotateY:()=>Sg,rotateZ:()=>Pg,round:()=>RO,scale:()=>IO,scaleAndAdd:()=>BO,set:()=>CO,slerp:()=>FO,sqrDist:()=>XO,sqrLen:()=>KO,squaredDistance:()=>dE,squaredLength:()=>hE,str:()=>VO,sub:()=>HO,subtract:()=>cE,transformMat3:()=>xg,transformMat4:()=>Za,transformQuat:()=>wg,zero:()=>GO});function ef(){let n=new we(3);return we!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n}function SO(n){let e=new we(3);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e}function aE(n){let e=n[0],t=n[1],i=n[2];return Math.sqrt(e*e+t*t+i*i)}function tf(n,e,t){let i=new we(3);return i[0]=n,i[1]=e,i[2]=t,i}function PO(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n}function CO(n,e,t,i){return n[0]=e,n[1]=t,n[2]=i,n}function TO(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n}function cE(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n}function lE(n,e,t){return n[0]=e[0]*t[0],n[1]=e[1]*t[1],n[2]=e[2]*t[2],n}function uE(n,e,t){return n[0]=e[0]/t[0],n[1]=e[1]/t[1],n[2]=e[2]/t[2],n}function LO(n,e){return n[0]=Math.ceil(e[0]),n[1]=Math.ceil(e[1]),n[2]=Math.ceil(e[2]),n}function MO(n,e){return n[0]=Math.floor(e[0]),n[1]=Math.floor(e[1]),n[2]=Math.floor(e[2]),n}function AO(n,e,t){return n[0]=Math.min(e[0],t[0]),n[1]=Math.min(e[1],t[1]),n[2]=Math.min(e[2],t[2]),n}function kO(n,e,t){return n[0]=Math.max(e[0],t[0]),n[1]=Math.max(e[1],t[1]),n[2]=Math.max(e[2],t[2]),n}function RO(n,e){return n[0]=Qt(e[0]),n[1]=Qt(e[1]),n[2]=Qt(e[2]),n}function IO(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n}function BO(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n[2]=e[2]+t[2]*i,n}function fE(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2];return Math.sqrt(t*t+i*i+r*r)}function dE(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2];return t*t+i*i+r*r}function hE(n){let e=n[0],t=n[1],i=n[2];return e*e+t*t+i*i}function OO(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n}function DO(n,e){return n[0]=1/e[0],n[1]=1/e[1],n[2]=1/e[2],n}function vg(n,e){let t=e[0],i=e[1],r=e[2],s=t*t+i*i+r*r;return s>0&&(s=1/Math.sqrt(s)),n[0]=e[0]*s,n[1]=e[1]*s,n[2]=e[2]*s,n}function qa(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]}function Gr(n,e,t){let i=e[0],r=e[1],s=e[2],o=t[0],a=t[1],c=t[2];return n[0]=r*c-s*a,n[1]=s*o-i*c,n[2]=i*a-r*o,n}function NO(n,e,t,i){let r=e[0],s=e[1],o=e[2];return n[0]=r+i*(t[0]-r),n[1]=s+i*(t[1]-s),n[2]=o+i*(t[2]-o),n}function FO(n,e,t,i){let r=Math.acos(Math.min(Math.max(qa(e,t),-1),1)),s=Math.sin(r),o=Math.sin((1-i)*r)/s,a=Math.sin(i*r)/s;return n[0]=o*e[0]+a*t[0],n[1]=o*e[1]+a*t[1],n[2]=o*e[2]+a*t[2],n}function zO(n,e,t,i,r,s){let o=s*s,a=o*(2*s-3)+1,c=o*(s-2)+s,l=o*(s-1),u=o*(3-2*s);return n[0]=e[0]*a+t[0]*c+i[0]*l+r[0]*u,n[1]=e[1]*a+t[1]*c+i[1]*l+r[1]*u,n[2]=e[2]*a+t[2]*c+i[2]*l+r[2]*u,n}function UO(n,e,t,i,r,s){let o=1-s,a=o*o,c=s*s,l=a*o,u=3*s*a,f=3*c*o,d=c*s;return n[0]=e[0]*l+t[0]*u+i[0]*f+r[0]*d,n[1]=e[1]*l+t[1]*u+i[1]*f+r[1]*d,n[2]=e[2]*l+t[2]*u+i[2]*f+r[2]*d,n}function $O(n,e){e=e===void 0?1:e;let t=Gn()*2*Math.PI,i=Gn()*2-1,r=Math.sqrt(1-i*i)*e;return n[0]=Math.cos(t)*r,n[1]=Math.sin(t)*r,n[2]=i*e,n}function Za(n,e,t){let i=e[0],r=e[1],s=e[2],o=t[3]*i+t[7]*r+t[11]*s+t[15];return o=o||1,n[0]=(t[0]*i+t[4]*r+t[8]*s+t[12])/o,n[1]=(t[1]*i+t[5]*r+t[9]*s+t[13])/o,n[2]=(t[2]*i+t[6]*r+t[10]*s+t[14])/o,n}function xg(n,e,t){let i=e[0],r=e[1],s=e[2];return n[0]=i*t[0]+r*t[3]+s*t[6],n[1]=i*t[1]+r*t[4]+s*t[7],n[2]=i*t[2]+r*t[5]+s*t[8],n}function wg(n,e,t){let i=t[0],r=t[1],s=t[2],o=t[3],a=e[0],c=e[1],l=e[2],u=r*l-s*c,f=s*a-i*l,d=i*c-r*a,h=r*d-s*f,p=s*u-i*d,m=i*f-r*u,g=o*2;return u*=g,f*=g,d*=g,h*=2,p*=2,m*=2,n[0]=a+u+h,n[1]=c+f+p,n[2]=l+d+m,n}function Eg(n,e,t,i){let r=[],s=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],s[0]=r[0],s[1]=r[1]*Math.cos(i)-r[2]*Math.sin(i),s[2]=r[1]*Math.sin(i)+r[2]*Math.cos(i),n[0]=s[0]+t[0],n[1]=s[1]+t[1],n[2]=s[2]+t[2],n}function Sg(n,e,t,i){let r=[],s=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],s[0]=r[2]*Math.sin(i)+r[0]*Math.cos(i),s[1]=r[1],s[2]=r[2]*Math.cos(i)-r[0]*Math.sin(i),n[0]=s[0]+t[0],n[1]=s[1]+t[1],n[2]=s[2]+t[2],n}function Pg(n,e,t,i){let r=[],s=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],s[0]=r[0]*Math.cos(i)-r[1]*Math.sin(i),s[1]=r[0]*Math.sin(i)+r[1]*Math.cos(i),s[2]=r[2],n[0]=s[0]+t[0],n[1]=s[1]+t[1],n[2]=s[2]+t[2],n}function Cg(n,e){let t=n[0],i=n[1],r=n[2],s=e[0],o=e[1],a=e[2],c=Math.sqrt((t*t+i*i+r*r)*(s*s+o*o+a*a)),l=c&&qa(n,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function GO(n){return n[0]=0,n[1]=0,n[2]=0,n}function VO(n){return`vec3(${n[0]}, ${n[1]}, ${n[2]})`}function WO(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]}function jO(n,e){let t=n[0],i=n[1],r=n[2],s=e[0],o=e[1],a=e[2];return Math.abs(t-s)<=1e-6*Math.max(1,Math.abs(t),Math.abs(s))&&Math.abs(i-o)<=1e-6*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(r-a)<=1e-6*Math.max(1,Math.abs(r),Math.abs(a))}var HO,YO,qO,ZO,XO,Tg,KO,QO,Xa=C(()=>{$r();HO=cE,YO=lE,qO=uE,ZO=fE,XO=dE,Tg=aE,KO=hE,QO=function(){let n=ef();return function(e,t,i,r,s,o){let a,c;for(t||(t=3),i||(i=0),r?c=Math.min(r*t+i,e.length):c=e.length,a=i;a{Xw();Ks();Ya();Xa();bg();Lg=[0,0,0],et=class n extends Qu{static get ZERO(){return nf||(nf=new n(0,0,0),Object.freeze(nf)),nf}constructor(e=0,t=0,i=0){super(-0,-0,-0),arguments.length===1&&vi(e)?this.copy(e):(Ye.debug&&(Je(e),Je(t),Je(i)),this[0]=e,this[1]=t,this[2]=i)}set(e,t,i){return this[0]=e,this[1]=t,this[2]=i,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return Ye.debug&&(Je(e.x),Je(e.y),Je(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=Je(e)}angle(e){return Cg(this,e)}cross(e){return Gr(this,this,e),this.check()}rotateX({radians:e,origin:t=Lg}){return Eg(this,this,t,e),this.check()}rotateY({radians:e,origin:t=Lg}){return Sg(this,this,t,e),this.check()}rotateZ({radians:e,origin:t=Lg}){return Pg(this,this,t,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return Za(this,this,e),this.check()}transformAsVector(e){return Ju(this,this,e),this.check()}transformByMatrix3(e){return xg(this,this,e),this.check()}transformByMatrix2(e){return oE(this,this,e),this.check()}transformByQuaternion(e){return wg(this,this,e),this.check()}}});var rf,mE=C(()=>{mg();Ya();Ks();rf=class extends Qs{toString(){let e="[";if(Ye.printRowMajor){e+="row-major:";for(let t=0;t{$r()});var Ve={};mi(Ve,{add:()=>ED,adjoint:()=>rD,clone:()=>eD,copy:()=>tD,create:()=>JO,decompose:()=>pD,determinant:()=>Rg,equals:()=>TD,exactEquals:()=>CD,frob:()=>wD,fromQuat:()=>zg,fromQuat2:()=>fD,fromRotation:()=>aD,fromRotationTranslation:()=>bE,fromRotationTranslationScale:()=>mD,fromRotationTranslationScaleOrigin:()=>gD,fromScaling:()=>oD,fromTranslation:()=>sD,fromValues:()=>nD,fromXRotation:()=>cD,fromYRotation:()=>lD,fromZRotation:()=>uD,frustum:()=>Ug,getRotation:()=>hD,getScaling:()=>vE,getTranslation:()=>dD,identity:()=>yE,invert:()=>kg,lookAt:()=>Vg,mul:()=>LD,multiply:()=>Ka,multiplyScalar:()=>SD,multiplyScalarAndAdd:()=>PD,ortho:()=>Gg,orthoNO:()=>wE,orthoZO:()=>bD,perspective:()=>$g,perspectiveFromFieldOfView:()=>yD,perspectiveNO:()=>xE,perspectiveZO:()=>_D,rotate:()=>Og,rotateX:()=>Dg,rotateY:()=>Ng,rotateZ:()=>Fg,scale:()=>Bg,set:()=>iD,str:()=>xD,sub:()=>MD,subtract:()=>EE,targetTo:()=>vD,translate:()=>Ig,transpose:()=>Ag});function JO(){let n=new we(16);return we!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0),n[0]=1,n[5]=1,n[10]=1,n[15]=1,n}function eD(n){let e=new we(16);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],e}function tD(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function nD(n,e,t,i,r,s,o,a,c,l,u,f,d,h,p,m){let g=new we(16);return g[0]=n,g[1]=e,g[2]=t,g[3]=i,g[4]=r,g[5]=s,g[6]=o,g[7]=a,g[8]=c,g[9]=l,g[10]=u,g[11]=f,g[12]=d,g[13]=h,g[14]=p,g[15]=m,g}function iD(n,e,t,i,r,s,o,a,c,l,u,f,d,h,p,m,g){return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n[4]=s,n[5]=o,n[6]=a,n[7]=c,n[8]=l,n[9]=u,n[10]=f,n[11]=d,n[12]=h,n[13]=p,n[14]=m,n[15]=g,n}function yE(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Ag(n,e){if(n===e){let t=e[1],i=e[2],r=e[3],s=e[6],o=e[7],a=e[11];n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=t,n[6]=e[9],n[7]=e[13],n[8]=i,n[9]=s,n[11]=e[14],n[12]=r,n[13]=o,n[14]=a}else n[0]=e[0],n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=e[1],n[5]=e[5],n[6]=e[9],n[7]=e[13],n[8]=e[2],n[9]=e[6],n[10]=e[10],n[11]=e[14],n[12]=e[3],n[13]=e[7],n[14]=e[11],n[15]=e[15];return n}function kg(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],d=e[10],h=e[11],p=e[12],m=e[13],g=e[14],v=e[15],y=t*a-i*o,b=t*c-r*o,x=t*l-s*o,E=i*c-r*a,w=i*l-s*a,T=r*l-s*c,R=u*m-f*p,F=u*g-d*p,O=u*v-h*p,j=f*g-d*m,V=f*v-h*m,G=d*v-h*g,q=y*G-b*V+x*j+E*O-w*F+T*R;return q?(q=1/q,n[0]=(a*G-c*V+l*j)*q,n[1]=(r*V-i*G-s*j)*q,n[2]=(m*T-g*w+v*E)*q,n[3]=(d*w-f*T-h*E)*q,n[4]=(c*O-o*G-l*F)*q,n[5]=(t*G-r*O+s*F)*q,n[6]=(g*x-p*T-v*b)*q,n[7]=(u*T-d*x+h*b)*q,n[8]=(o*V-a*O+l*R)*q,n[9]=(i*O-t*V-s*R)*q,n[10]=(p*w-m*x+v*y)*q,n[11]=(f*x-u*w-h*y)*q,n[12]=(a*F-o*j-c*R)*q,n[13]=(t*j-i*F+r*R)*q,n[14]=(m*b-p*E-g*y)*q,n[15]=(u*E-f*b+d*y)*q,n):null}function rD(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],d=e[10],h=e[11],p=e[12],m=e[13],g=e[14],v=e[15],y=t*a-i*o,b=t*c-r*o,x=t*l-s*o,E=i*c-r*a,w=i*l-s*a,T=r*l-s*c,R=u*m-f*p,F=u*g-d*p,O=u*v-h*p,j=f*g-d*m,V=f*v-h*m,G=d*v-h*g;return n[0]=a*G-c*V+l*j,n[1]=r*V-i*G-s*j,n[2]=m*T-g*w+v*E,n[3]=d*w-f*T-h*E,n[4]=c*O-o*G-l*F,n[5]=t*G-r*O+s*F,n[6]=g*x-p*T-v*b,n[7]=u*T-d*x+h*b,n[8]=o*V-a*O+l*R,n[9]=i*O-t*V-s*R,n[10]=p*w-m*x+v*y,n[11]=f*x-u*w-h*y,n[12]=a*F-o*j-c*R,n[13]=t*j-i*F+r*R,n[14]=m*b-p*E-g*y,n[15]=u*E-f*b+d*y,n}function Rg(n){let e=n[0],t=n[1],i=n[2],r=n[3],s=n[4],o=n[5],a=n[6],c=n[7],l=n[8],u=n[9],f=n[10],d=n[11],h=n[12],p=n[13],m=n[14],g=n[15],v=e*o-t*s,y=e*a-i*s,b=t*a-i*o,x=l*p-u*h,E=l*m-f*h,w=u*m-f*p,T=e*w-t*E+i*x,R=s*w-o*E+a*x,F=l*b-u*y+f*v,O=h*b-p*y+m*v;return c*T-r*R+g*F-d*O}function Ka(n,e,t){let i=e[0],r=e[1],s=e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=e[8],d=e[9],h=e[10],p=e[11],m=e[12],g=e[13],v=e[14],y=e[15],b=t[0],x=t[1],E=t[2],w=t[3];return n[0]=b*i+x*a+E*f+w*m,n[1]=b*r+x*c+E*d+w*g,n[2]=b*s+x*l+E*h+w*v,n[3]=b*o+x*u+E*p+w*y,b=t[4],x=t[5],E=t[6],w=t[7],n[4]=b*i+x*a+E*f+w*m,n[5]=b*r+x*c+E*d+w*g,n[6]=b*s+x*l+E*h+w*v,n[7]=b*o+x*u+E*p+w*y,b=t[8],x=t[9],E=t[10],w=t[11],n[8]=b*i+x*a+E*f+w*m,n[9]=b*r+x*c+E*d+w*g,n[10]=b*s+x*l+E*h+w*v,n[11]=b*o+x*u+E*p+w*y,b=t[12],x=t[13],E=t[14],w=t[15],n[12]=b*i+x*a+E*f+w*m,n[13]=b*r+x*c+E*d+w*g,n[14]=b*s+x*l+E*h+w*v,n[15]=b*o+x*u+E*p+w*y,n}function Ig(n,e,t){let i=t[0],r=t[1],s=t[2],o,a,c,l,u,f,d,h,p,m,g,v;return e===n?(n[12]=e[0]*i+e[4]*r+e[8]*s+e[12],n[13]=e[1]*i+e[5]*r+e[9]*s+e[13],n[14]=e[2]*i+e[6]*r+e[10]*s+e[14],n[15]=e[3]*i+e[7]*r+e[11]*s+e[15]):(o=e[0],a=e[1],c=e[2],l=e[3],u=e[4],f=e[5],d=e[6],h=e[7],p=e[8],m=e[9],g=e[10],v=e[11],n[0]=o,n[1]=a,n[2]=c,n[3]=l,n[4]=u,n[5]=f,n[6]=d,n[7]=h,n[8]=p,n[9]=m,n[10]=g,n[11]=v,n[12]=o*i+u*r+p*s+e[12],n[13]=a*i+f*r+m*s+e[13],n[14]=c*i+d*r+g*s+e[14],n[15]=l*i+h*r+v*s+e[15]),n}function Bg(n,e,t){let i=t[0],r=t[1],s=t[2];return n[0]=e[0]*i,n[1]=e[1]*i,n[2]=e[2]*i,n[3]=e[3]*i,n[4]=e[4]*r,n[5]=e[5]*r,n[6]=e[6]*r,n[7]=e[7]*r,n[8]=e[8]*s,n[9]=e[9]*s,n[10]=e[10]*s,n[11]=e[11]*s,n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function Og(n,e,t,i){let r=i[0],s=i[1],o=i[2],a=Math.sqrt(r*r+s*s+o*o),c,l,u,f,d,h,p,m,g,v,y,b,x,E,w,T,R,F,O,j,V,G,q,X;return a<1e-6?null:(a=1/a,r*=a,s*=a,o*=a,l=Math.sin(t),c=Math.cos(t),u=1-c,f=e[0],d=e[1],h=e[2],p=e[3],m=e[4],g=e[5],v=e[6],y=e[7],b=e[8],x=e[9],E=e[10],w=e[11],T=r*r*u+c,R=s*r*u+o*l,F=o*r*u-s*l,O=r*s*u-o*l,j=s*s*u+c,V=o*s*u+r*l,G=r*o*u+s*l,q=s*o*u-r*l,X=o*o*u+c,n[0]=f*T+m*R+b*F,n[1]=d*T+g*R+x*F,n[2]=h*T+v*R+E*F,n[3]=p*T+y*R+w*F,n[4]=f*O+m*j+b*V,n[5]=d*O+g*j+x*V,n[6]=h*O+v*j+E*V,n[7]=p*O+y*j+w*V,n[8]=f*G+m*q+b*X,n[9]=d*G+g*q+x*X,n[10]=h*G+v*q+E*X,n[11]=p*G+y*q+w*X,e!==n&&(n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n)}function Dg(n,e,t){let i=Math.sin(t),r=Math.cos(t),s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],f=e[10],d=e[11];return e!==n&&(n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[4]=s*r+l*i,n[5]=o*r+u*i,n[6]=a*r+f*i,n[7]=c*r+d*i,n[8]=l*r-s*i,n[9]=u*r-o*i,n[10]=f*r-a*i,n[11]=d*r-c*i,n}function Ng(n,e,t){let i=Math.sin(t),r=Math.cos(t),s=e[0],o=e[1],a=e[2],c=e[3],l=e[8],u=e[9],f=e[10],d=e[11];return e!==n&&(n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=s*r-l*i,n[1]=o*r-u*i,n[2]=a*r-f*i,n[3]=c*r-d*i,n[8]=s*i+l*r,n[9]=o*i+u*r,n[10]=a*i+f*r,n[11]=c*i+d*r,n}function Fg(n,e,t){let i=Math.sin(t),r=Math.cos(t),s=e[0],o=e[1],a=e[2],c=e[3],l=e[4],u=e[5],f=e[6],d=e[7];return e!==n&&(n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=s*r+l*i,n[1]=o*r+u*i,n[2]=a*r+f*i,n[3]=c*r+d*i,n[4]=l*r-s*i,n[5]=u*r-o*i,n[6]=f*r-a*i,n[7]=d*r-c*i,n}function sD(n,e){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=e[0],n[13]=e[1],n[14]=e[2],n[15]=1,n}function oD(n,e){return n[0]=e[0],n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=e[1],n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=e[2],n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function aD(n,e,t){let i=t[0],r=t[1],s=t[2],o=Math.sqrt(i*i+r*r+s*s),a,c,l;return o<1e-6?null:(o=1/o,i*=o,r*=o,s*=o,c=Math.sin(e),a=Math.cos(e),l=1-a,n[0]=i*i*l+a,n[1]=r*i*l+s*c,n[2]=s*i*l-r*c,n[3]=0,n[4]=i*r*l-s*c,n[5]=r*r*l+a,n[6]=s*r*l+i*c,n[7]=0,n[8]=i*s*l+r*c,n[9]=r*s*l-i*c,n[10]=s*s*l+a,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n)}function cD(n,e){let t=Math.sin(e),i=Math.cos(e);return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i,n[6]=t,n[7]=0,n[8]=0,n[9]=-t,n[10]=i,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function lD(n,e){let t=Math.sin(e),i=Math.cos(e);return n[0]=i,n[1]=0,n[2]=-t,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=t,n[9]=0,n[10]=i,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function uD(n,e){let t=Math.sin(e),i=Math.cos(e);return n[0]=i,n[1]=t,n[2]=0,n[3]=0,n[4]=-t,n[5]=i,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function bE(n,e,t){let i=e[0],r=e[1],s=e[2],o=e[3],a=i+i,c=r+r,l=s+s,u=i*a,f=i*c,d=i*l,h=r*c,p=r*l,m=s*l,g=o*a,v=o*c,y=o*l;return n[0]=1-(h+m),n[1]=f+y,n[2]=d-v,n[3]=0,n[4]=f-y,n[5]=1-(u+m),n[6]=p+g,n[7]=0,n[8]=d+v,n[9]=p-g,n[10]=1-(u+h),n[11]=0,n[12]=t[0],n[13]=t[1],n[14]=t[2],n[15]=1,n}function fD(n,e){let t=new we(3),i=-e[0],r=-e[1],s=-e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=i*i+r*r+s*s+o*o;return f>0?(t[0]=(a*o+u*i+c*s-l*r)*2/f,t[1]=(c*o+u*r+l*i-a*s)*2/f,t[2]=(l*o+u*s+a*r-c*i)*2/f):(t[0]=(a*o+u*i+c*s-l*r)*2,t[1]=(c*o+u*r+l*i-a*s)*2,t[2]=(l*o+u*s+a*r-c*i)*2),bE(n,e,t),n}function dD(n,e){return n[0]=e[12],n[1]=e[13],n[2]=e[14],n}function vE(n,e){let t=e[0],i=e[1],r=e[2],s=e[4],o=e[5],a=e[6],c=e[8],l=e[9],u=e[10];return n[0]=Math.sqrt(t*t+i*i+r*r),n[1]=Math.sqrt(s*s+o*o+a*a),n[2]=Math.sqrt(c*c+l*l+u*u),n}function hD(n,e){let t=new we(3);vE(t,e);let i=1/t[0],r=1/t[1],s=1/t[2],o=e[0]*i,a=e[1]*r,c=e[2]*s,l=e[4]*i,u=e[5]*r,f=e[6]*s,d=e[8]*i,h=e[9]*r,p=e[10]*s,m=o+u+p,g=0;return m>0?(g=Math.sqrt(m+1)*2,n[3]=.25*g,n[0]=(f-h)/g,n[1]=(d-c)/g,n[2]=(a-l)/g):o>u&&o>p?(g=Math.sqrt(1+o-u-p)*2,n[3]=(f-h)/g,n[0]=.25*g,n[1]=(a+l)/g,n[2]=(d+c)/g):u>p?(g=Math.sqrt(1+u-o-p)*2,n[3]=(d-c)/g,n[0]=(a+l)/g,n[1]=.25*g,n[2]=(f+h)/g):(g=Math.sqrt(1+p-o-u)*2,n[3]=(a-l)/g,n[0]=(d+c)/g,n[1]=(f+h)/g,n[2]=.25*g),n}function pD(n,e,t,i){e[0]=i[12],e[1]=i[13],e[2]=i[14];let r=i[0],s=i[1],o=i[2],a=i[4],c=i[5],l=i[6],u=i[8],f=i[9],d=i[10];t[0]=Math.sqrt(r*r+s*s+o*o),t[1]=Math.sqrt(a*a+c*c+l*l),t[2]=Math.sqrt(u*u+f*f+d*d);let h=1/t[0],p=1/t[1],m=1/t[2],g=r*h,v=s*p,y=o*m,b=a*h,x=c*p,E=l*m,w=u*h,T=f*p,R=d*m,F=g+x+R,O=0;return F>0?(O=Math.sqrt(F+1)*2,n[3]=.25*O,n[0]=(E-T)/O,n[1]=(w-y)/O,n[2]=(v-b)/O):g>x&&g>R?(O=Math.sqrt(1+g-x-R)*2,n[3]=(E-T)/O,n[0]=.25*O,n[1]=(v+b)/O,n[2]=(w+y)/O):x>R?(O=Math.sqrt(1+x-g-R)*2,n[3]=(w-y)/O,n[0]=(v+b)/O,n[1]=.25*O,n[2]=(E+T)/O):(O=Math.sqrt(1+R-g-x)*2,n[3]=(v-b)/O,n[0]=(w+y)/O,n[1]=(E+T)/O,n[2]=.25*O),n}function mD(n,e,t,i){let r=e[0],s=e[1],o=e[2],a=e[3],c=r+r,l=s+s,u=o+o,f=r*c,d=r*l,h=r*u,p=s*l,m=s*u,g=o*u,v=a*c,y=a*l,b=a*u,x=i[0],E=i[1],w=i[2];return n[0]=(1-(p+g))*x,n[1]=(d+b)*x,n[2]=(h-y)*x,n[3]=0,n[4]=(d-b)*E,n[5]=(1-(f+g))*E,n[6]=(m+v)*E,n[7]=0,n[8]=(h+y)*w,n[9]=(m-v)*w,n[10]=(1-(f+p))*w,n[11]=0,n[12]=t[0],n[13]=t[1],n[14]=t[2],n[15]=1,n}function gD(n,e,t,i,r){let s=e[0],o=e[1],a=e[2],c=e[3],l=s+s,u=o+o,f=a+a,d=s*l,h=s*u,p=s*f,m=o*u,g=o*f,v=a*f,y=c*l,b=c*u,x=c*f,E=i[0],w=i[1],T=i[2],R=r[0],F=r[1],O=r[2],j=(1-(m+v))*E,V=(h+x)*E,G=(p-b)*E,q=(h-x)*w,X=(1-(d+v))*w,se=(g+y)*w,le=(p+b)*T,he=(g-y)*T,at=(1-(d+m))*T;return n[0]=j,n[1]=V,n[2]=G,n[3]=0,n[4]=q,n[5]=X,n[6]=se,n[7]=0,n[8]=le,n[9]=he,n[10]=at,n[11]=0,n[12]=t[0]+R-(j*R+q*F+le*O),n[13]=t[1]+F-(V*R+X*F+he*O),n[14]=t[2]+O-(G*R+se*F+at*O),n[15]=1,n}function zg(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],o=t+t,a=i+i,c=r+r,l=t*o,u=i*o,f=i*a,d=r*o,h=r*a,p=r*c,m=s*o,g=s*a,v=s*c;return n[0]=1-f-p,n[1]=u+v,n[2]=d-g,n[3]=0,n[4]=u-v,n[5]=1-l-p,n[6]=h+m,n[7]=0,n[8]=d+g,n[9]=h-m,n[10]=1-l-f,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Ug(n,e,t,i,r,s,o){let a=1/(t-e),c=1/(r-i),l=1/(s-o);return n[0]=s*2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=s*2*c,n[6]=0,n[7]=0,n[8]=(t+e)*a,n[9]=(r+i)*c,n[10]=(o+s)*l,n[11]=-1,n[12]=0,n[13]=0,n[14]=o*s*2*l,n[15]=0,n}function xE(n,e,t,i,r){let s=1/Math.tan(e/2);if(n[0]=s/t,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=s,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,r!=null&&r!==1/0){let o=1/(i-r);n[10]=(r+i)*o,n[14]=2*r*i*o}else n[10]=-1,n[14]=-2*i;return n}function _D(n,e,t,i,r){let s=1/Math.tan(e/2);if(n[0]=s/t,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=s,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,r!=null&&r!==1/0){let o=1/(i-r);n[10]=r*o,n[14]=r*i*o}else n[10]=-1,n[14]=-i;return n}function yD(n,e,t,i){let r=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),o=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),c=2/(o+a),l=2/(r+s);return n[0]=c,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=l,n[6]=0,n[7]=0,n[8]=-((o-a)*c*.5),n[9]=(r-s)*l*.5,n[10]=i/(t-i),n[11]=-1,n[12]=0,n[13]=0,n[14]=i*t/(t-i),n[15]=0,n}function wE(n,e,t,i,r,s,o){let a=1/(e-t),c=1/(i-r),l=1/(s-o);return n[0]=-2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*c,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*l,n[11]=0,n[12]=(e+t)*a,n[13]=(r+i)*c,n[14]=(o+s)*l,n[15]=1,n}function bD(n,e,t,i,r,s,o){let a=1/(e-t),c=1/(i-r),l=1/(s-o);return n[0]=-2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*c,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=l,n[11]=0,n[12]=(e+t)*a,n[13]=(r+i)*c,n[14]=s*l,n[15]=1,n}function Vg(n,e,t,i){let r,s,o,a,c,l,u,f,d,h,p=e[0],m=e[1],g=e[2],v=i[0],y=i[1],b=i[2],x=t[0],E=t[1],w=t[2];return Math.abs(p-x)<1e-6&&Math.abs(m-E)<1e-6&&Math.abs(g-w)<1e-6?yE(n):(f=p-x,d=m-E,h=g-w,r=1/Math.sqrt(f*f+d*d+h*h),f*=r,d*=r,h*=r,s=y*h-b*d,o=b*f-v*h,a=v*d-y*f,r=Math.sqrt(s*s+o*o+a*a),r?(r=1/r,s*=r,o*=r,a*=r):(s=0,o=0,a=0),c=d*a-h*o,l=h*s-f*a,u=f*o-d*s,r=Math.sqrt(c*c+l*l+u*u),r?(r=1/r,c*=r,l*=r,u*=r):(c=0,l=0,u=0),n[0]=s,n[1]=c,n[2]=f,n[3]=0,n[4]=o,n[5]=l,n[6]=d,n[7]=0,n[8]=a,n[9]=u,n[10]=h,n[11]=0,n[12]=-(s*p+o*m+a*g),n[13]=-(c*p+l*m+u*g),n[14]=-(f*p+d*m+h*g),n[15]=1,n)}function vD(n,e,t,i){let r=e[0],s=e[1],o=e[2],a=i[0],c=i[1],l=i[2],u=r-t[0],f=s-t[1],d=o-t[2],h=u*u+f*f+d*d;h>0&&(h=1/Math.sqrt(h),u*=h,f*=h,d*=h);let p=c*d-l*f,m=l*u-a*d,g=a*f-c*u;return h=p*p+m*m+g*g,h>0&&(h=1/Math.sqrt(h),p*=h,m*=h,g*=h),n[0]=p,n[1]=m,n[2]=g,n[3]=0,n[4]=f*g-d*m,n[5]=d*p-u*g,n[6]=u*m-f*p,n[7]=0,n[8]=u,n[9]=f,n[10]=d,n[11]=0,n[12]=r,n[13]=s,n[14]=o,n[15]=1,n}function xD(n){return`mat4(${n[0]}, ${n[1]}, ${n[2]}, ${n[3]}, ${n[4]}, ${n[5]}, ${n[6]}, ${n[7]}, ${n[8]}, ${n[9]}, ${n[10]}, ${n[11]}, ${n[12]}, ${n[13]}, ${n[14]}, ${n[15]})`}function wD(n){return Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]+n[3]*n[3]+n[4]*n[4]+n[5]*n[5]+n[6]*n[6]+n[7]*n[7]+n[8]*n[8]+n[9]*n[9]+n[10]*n[10]+n[11]*n[11]+n[12]*n[12]+n[13]*n[13]+n[14]*n[14]+n[15]*n[15])}function ED(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n[3]=e[3]+t[3],n[4]=e[4]+t[4],n[5]=e[5]+t[5],n[6]=e[6]+t[6],n[7]=e[7]+t[7],n[8]=e[8]+t[8],n[9]=e[9]+t[9],n[10]=e[10]+t[10],n[11]=e[11]+t[11],n[12]=e[12]+t[12],n[13]=e[13]+t[13],n[14]=e[14]+t[14],n[15]=e[15]+t[15],n}function EE(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n[3]=e[3]-t[3],n[4]=e[4]-t[4],n[5]=e[5]-t[5],n[6]=e[6]-t[6],n[7]=e[7]-t[7],n[8]=e[8]-t[8],n[9]=e[9]-t[9],n[10]=e[10]-t[10],n[11]=e[11]-t[11],n[12]=e[12]-t[12],n[13]=e[13]-t[13],n[14]=e[14]-t[14],n[15]=e[15]-t[15],n}function SD(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n[3]=e[3]*t,n[4]=e[4]*t,n[5]=e[5]*t,n[6]=e[6]*t,n[7]=e[7]*t,n[8]=e[8]*t,n[9]=e[9]*t,n[10]=e[10]*t,n[11]=e[11]*t,n[12]=e[12]*t,n[13]=e[13]*t,n[14]=e[14]*t,n[15]=e[15]*t,n}function PD(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n[2]=e[2]+t[2]*i,n[3]=e[3]+t[3]*i,n[4]=e[4]+t[4]*i,n[5]=e[5]+t[5]*i,n[6]=e[6]+t[6]*i,n[7]=e[7]+t[7]*i,n[8]=e[8]+t[8]*i,n[9]=e[9]+t[9]*i,n[10]=e[10]+t[10]*i,n[11]=e[11]+t[11]*i,n[12]=e[12]+t[12]*i,n[13]=e[13]+t[13]*i,n[14]=e[14]+t[14]*i,n[15]=e[15]+t[15]*i,n}function CD(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]&&n[3]===e[3]&&n[4]===e[4]&&n[5]===e[5]&&n[6]===e[6]&&n[7]===e[7]&&n[8]===e[8]&&n[9]===e[9]&&n[10]===e[10]&&n[11]===e[11]&&n[12]===e[12]&&n[13]===e[13]&&n[14]===e[14]&&n[15]===e[15]}function TD(n,e){let t=n[0],i=n[1],r=n[2],s=n[3],o=n[4],a=n[5],c=n[6],l=n[7],u=n[8],f=n[9],d=n[10],h=n[11],p=n[12],m=n[13],g=n[14],v=n[15],y=e[0],b=e[1],x=e[2],E=e[3],w=e[4],T=e[5],R=e[6],F=e[7],O=e[8],j=e[9],V=e[10],G=e[11],q=e[12],X=e[13],se=e[14],le=e[15];return Math.abs(t-y)<=1e-6*Math.max(1,Math.abs(t),Math.abs(y))&&Math.abs(i-b)<=1e-6*Math.max(1,Math.abs(i),Math.abs(b))&&Math.abs(r-x)<=1e-6*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(s-E)<=1e-6*Math.max(1,Math.abs(s),Math.abs(E))&&Math.abs(o-w)<=1e-6*Math.max(1,Math.abs(o),Math.abs(w))&&Math.abs(a-T)<=1e-6*Math.max(1,Math.abs(a),Math.abs(T))&&Math.abs(c-R)<=1e-6*Math.max(1,Math.abs(c),Math.abs(R))&&Math.abs(l-F)<=1e-6*Math.max(1,Math.abs(l),Math.abs(F))&&Math.abs(u-O)<=1e-6*Math.max(1,Math.abs(u),Math.abs(O))&&Math.abs(f-j)<=1e-6*Math.max(1,Math.abs(f),Math.abs(j))&&Math.abs(d-V)<=1e-6*Math.max(1,Math.abs(d),Math.abs(V))&&Math.abs(h-G)<=1e-6*Math.max(1,Math.abs(h),Math.abs(G))&&Math.abs(p-q)<=1e-6*Math.max(1,Math.abs(p),Math.abs(q))&&Math.abs(m-X)<=1e-6*Math.max(1,Math.abs(m),Math.abs(X))&&Math.abs(g-se)<=1e-6*Math.max(1,Math.abs(g),Math.abs(se))&&Math.abs(v-le)<=1e-6*Math.max(1,Math.abs(v),Math.abs(le))}var $g,Gg,LD,MD,Wg=C(()=>{$r();$g=xE;Gg=wE;LD=Ka,MD=EE});var Rt={};mi(Rt,{add:()=>ME,ceil:()=>AD,clone:()=>PE,copy:()=>TE,create:()=>SE,cross:()=>FD,dist:()=>YD,distance:()=>BE,div:()=>HD,divide:()=>RE,dot:()=>DE,equals:()=>VD,exactEquals:()=>FE,floor:()=>kD,forEach:()=>KD,fromValues:()=>CE,inverse:()=>ND,len:()=>ZD,length:()=>jg,lerp:()=>NE,max:()=>ID,min:()=>RD,mul:()=>jD,multiply:()=>kE,negate:()=>DD,normalize:()=>Yg,random:()=>zD,round:()=>BD,scale:()=>IE,scaleAndAdd:()=>OD,set:()=>LE,sqrDist:()=>qD,sqrLen:()=>XD,squaredDistance:()=>OE,squaredLength:()=>Hg,str:()=>GD,sub:()=>WD,subtract:()=>AE,transformMat4:()=>qg,transformQuat:()=>UD,zero:()=>$D});function SE(){let n=new we(4);return we!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0,n[3]=0),n}function PE(n){let e=new we(4);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e}function CE(n,e,t,i){let r=new we(4);return r[0]=n,r[1]=e,r[2]=t,r[3]=i,r}function TE(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n}function LE(n,e,t,i,r){return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n}function ME(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n[3]=e[3]+t[3],n}function AE(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n[3]=e[3]-t[3],n}function kE(n,e,t){return n[0]=e[0]*t[0],n[1]=e[1]*t[1],n[2]=e[2]*t[2],n[3]=e[3]*t[3],n}function RE(n,e,t){return n[0]=e[0]/t[0],n[1]=e[1]/t[1],n[2]=e[2]/t[2],n[3]=e[3]/t[3],n}function AD(n,e){return n[0]=Math.ceil(e[0]),n[1]=Math.ceil(e[1]),n[2]=Math.ceil(e[2]),n[3]=Math.ceil(e[3]),n}function kD(n,e){return n[0]=Math.floor(e[0]),n[1]=Math.floor(e[1]),n[2]=Math.floor(e[2]),n[3]=Math.floor(e[3]),n}function RD(n,e,t){return n[0]=Math.min(e[0],t[0]),n[1]=Math.min(e[1],t[1]),n[2]=Math.min(e[2],t[2]),n[3]=Math.min(e[3],t[3]),n}function ID(n,e,t){return n[0]=Math.max(e[0],t[0]),n[1]=Math.max(e[1],t[1]),n[2]=Math.max(e[2],t[2]),n[3]=Math.max(e[3],t[3]),n}function BD(n,e){return n[0]=Qt(e[0]),n[1]=Qt(e[1]),n[2]=Qt(e[2]),n[3]=Qt(e[3]),n}function IE(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n[3]=e[3]*t,n}function OD(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n[2]=e[2]+t[2]*i,n[3]=e[3]+t[3]*i,n}function BE(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2],s=e[3]-n[3];return Math.sqrt(t*t+i*i+r*r+s*s)}function OE(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2],s=e[3]-n[3];return t*t+i*i+r*r+s*s}function jg(n){let e=n[0],t=n[1],i=n[2],r=n[3];return Math.sqrt(e*e+t*t+i*i+r*r)}function Hg(n){let e=n[0],t=n[1],i=n[2],r=n[3];return e*e+t*t+i*i+r*r}function DD(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n[3]=-e[3],n}function ND(n,e){return n[0]=1/e[0],n[1]=1/e[1],n[2]=1/e[2],n[3]=1/e[3],n}function Yg(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],o=t*t+i*i+r*r+s*s;return o>0&&(o=1/Math.sqrt(o)),n[0]=t*o,n[1]=i*o,n[2]=r*o,n[3]=s*o,n}function DE(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]+n[3]*e[3]}function FD(n,e,t,i){let r=t[0]*i[1]-t[1]*i[0],s=t[0]*i[2]-t[2]*i[0],o=t[0]*i[3]-t[3]*i[0],a=t[1]*i[2]-t[2]*i[1],c=t[1]*i[3]-t[3]*i[1],l=t[2]*i[3]-t[3]*i[2],u=e[0],f=e[1],d=e[2],h=e[3];return n[0]=f*l-d*c+h*a,n[1]=-(u*l)+d*o-h*s,n[2]=u*c-f*o+h*r,n[3]=-(u*a)+f*s-d*r,n}function NE(n,e,t,i){let r=e[0],s=e[1],o=e[2],a=e[3];return n[0]=r+i*(t[0]-r),n[1]=s+i*(t[1]-s),n[2]=o+i*(t[2]-o),n[3]=a+i*(t[3]-a),n}function zD(n,e){e=e===void 0?1:e;let t,i,r,s,o,a;do t=Gn()*2-1,i=Gn()*2-1,o=t*t+i*i;while(o>=1);do r=Gn()*2-1,s=Gn()*2-1,a=r*r+s*s;while(a>=1);let c=Math.sqrt((1-o)/a);return n[0]=e*t,n[1]=e*i,n[2]=e*r*c,n[3]=e*s*c,n}function qg(n,e,t){let i=e[0],r=e[1],s=e[2],o=e[3];return n[0]=t[0]*i+t[4]*r+t[8]*s+t[12]*o,n[1]=t[1]*i+t[5]*r+t[9]*s+t[13]*o,n[2]=t[2]*i+t[6]*r+t[10]*s+t[14]*o,n[3]=t[3]*i+t[7]*r+t[11]*s+t[15]*o,n}function UD(n,e,t){let i=e[0],r=e[1],s=e[2],o=t[0],a=t[1],c=t[2],l=t[3],u=l*i+a*s-c*r,f=l*r+c*i-o*s,d=l*s+o*r-a*i,h=-o*i-a*r-c*s;return n[0]=u*l+h*-o+f*-c-d*-a,n[1]=f*l+h*-a+d*-o-u*-c,n[2]=d*l+h*-c+u*-a-f*-o,n[3]=e[3],n}function $D(n){return n[0]=0,n[1]=0,n[2]=0,n[3]=0,n}function GD(n){return`vec4(${n[0]}, ${n[1]}, ${n[2]}, ${n[3]})`}function FE(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]&&n[3]===e[3]}function VD(n,e){let t=n[0],i=n[1],r=n[2],s=n[3],o=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(t-o)<=1e-6*Math.max(1,Math.abs(t),Math.abs(o))&&Math.abs(i-a)<=1e-6*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(r-c)<=1e-6*Math.max(1,Math.abs(r),Math.abs(c))&&Math.abs(s-l)<=1e-6*Math.max(1,Math.abs(s),Math.abs(l))}var WD,jD,HD,YD,qD,ZD,XD,KD,sf=C(()=>{$r();WD=AE,jD=kE,HD=RE,YD=BE,qD=OE,ZD=jg,XD=Hg,KD=function(){let n=SE();return function(e,t,i,r,s,o){let a,c;for(t||(t=4),i||(i=0),r?c=Math.min(r*t+i,e.length):c=e.length,a=i;aMath.PI*2)throw Error("expected radians")}function i4(n,e,t,i,r,s){let o=2*s/(t-e),a=2*s/(r-i),c=(t+e)/(t-e),l=(r+i)/(r-i),u=-1,f=-1,d=-2*s;return n[0]=o,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=a,n[6]=0,n[7]=0,n[8]=c,n[9]=l,n[10]=u,n[11]=f,n[12]=0,n[13]=0,n[14]=d,n[15]=0,n}var Kg,QD,JD,Zg,Xg,e4,Fe,of,af,UE=C(()=>{mE();Ya();bg();Wg();yg();Xa();sf();(function(n){n[n.COL0ROW0=0]="COL0ROW0",n[n.COL0ROW1=1]="COL0ROW1",n[n.COL0ROW2=2]="COL0ROW2",n[n.COL0ROW3=3]="COL0ROW3",n[n.COL1ROW0=4]="COL1ROW0",n[n.COL1ROW1=5]="COL1ROW1",n[n.COL1ROW2=6]="COL1ROW2",n[n.COL1ROW3=7]="COL1ROW3",n[n.COL2ROW0=8]="COL2ROW0",n[n.COL2ROW1=9]="COL2ROW1",n[n.COL2ROW2=10]="COL2ROW2",n[n.COL2ROW3=11]="COL2ROW3",n[n.COL3ROW0=12]="COL3ROW0",n[n.COL3ROW1=13]="COL3ROW1",n[n.COL3ROW2=14]="COL3ROW2",n[n.COL3ROW3=15]="COL3ROW3"})(Kg||(Kg={}));QD=45*Math.PI/180,JD=1,Zg=.1,Xg=500,e4=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),Fe=class extends rf{static get IDENTITY(){return n4()}static get ZERO(){return t4()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Kg}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,i,r,s,o,a,c,l,u,f,d,h,p,m,g){return this[0]=e,this[1]=t,this[2]=i,this[3]=r,this[4]=s,this[5]=o,this[6]=a,this[7]=c,this[8]=l,this[9]=u,this[10]=f,this[11]=d,this[12]=h,this[13]=p,this[14]=m,this[15]=g,this.check()}setRowMajor(e,t,i,r,s,o,a,c,l,u,f,d,h,p,m,g){return this[0]=e,this[1]=s,this[2]=l,this[3]=h,this[4]=t,this[5]=o,this[6]=u,this[7]=p,this[8]=i,this[9]=a,this[10]=f,this[11]=m,this[12]=r,this[13]=c,this[14]=d,this[15]=g,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(e4)}fromObject(e){return this.check()}fromQuaternion(e){return zg(this,e),this.check()}frustum(e){let{left:t,right:i,bottom:r,top:s,near:o=Zg,far:a=Xg}=e;return a===1/0?i4(this,t,i,r,s,o):Ug(this,t,i,r,s,o,a),this.check()}lookAt(e){let{eye:t,center:i=[0,0,0],up:r=[0,1,0]}=e;return Vg(this,t,i,r),this.check()}ortho(e){let{left:t,right:i,bottom:r,top:s,near:o=Zg,far:a=Xg}=e;return Gg(this,t,i,r,s,o,a),this.check()}orthographic(e){let{fovy:t=QD,aspect:i=JD,focalDistance:r=1,near:s=Zg,far:o=Xg}=e;zE(t);let a=t/2,c=r*Math.tan(a),l=c*i;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:s,far:o})}perspective(e){let{fovy:t=45*Math.PI/180,aspect:i=1,near:r=.1,far:s=500}=e;return zE(t),$g(this,t,i,r,s),this.check()}determinant(){return Rg(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let i=this.getScale(t),r=1/i[0],s=1/i[1],o=1/i[2];return e[0]=this[0]*r,e[1]=this[1]*s,e[2]=this[2]*o,e[3]=0,e[4]=this[4]*r,e[5]=this[5]*s,e[6]=this[6]*o,e[7]=0,e[8]=this[8]*r,e[9]=this[9]*s,e[10]=this[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let i=this.getScale(t),r=1/i[0],s=1/i[1],o=1/i[2];return e[0]=this[0]*r,e[1]=this[1]*s,e[2]=this[2]*o,e[3]=this[4]*r,e[4]=this[5]*s,e[5]=this[6]*o,e[6]=this[8]*r,e[7]=this[9]*s,e[8]=this[10]*o,e}transpose(){return Ag(this,this),this.check()}invert(){return kg(this,this),this.check()}multiplyLeft(e){return Ka(this,e,this),this.check()}multiplyRight(e){return Ka(this,this,e),this.check()}rotateX(e){return Dg(this,this,e),this.check()}rotateY(e){return Ng(this,this,e),this.check()}rotateZ(e){return Fg(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return Og(this,this,e,t),this.check()}scale(e){return Bg(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return Ig(this,this,e),this.check()}transform(e,t){return e.length===4?(t=qg(t||[-0,-0,-0,-0],e,this),Ku(t,4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){let{length:i}=e,r;switch(i){case 2:r=_g(t||[-0,-0],e,this);break;case 3:r=Za(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Ku(r,e.length),r}transformAsVector(e,t){let i;switch(e.length){case 2:i=sE(t||[-0,-0],e,this);break;case 3:i=Ju(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Ku(i,e.length),i}transformPoint(e,t){return this.transformAsPoint(e,t)}transformVector(e,t){return this.transformAsPoint(e,t)}transformDirection(e,t){return this.transformAsVector(e,t)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,i){return this.identity().translate([e,t,i])}}});function $E(){let n=new we(4);return we!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n[3]=1,n}function r4(n,e,t){t=t*.5;let i=Math.sin(t);return n[0]=i*e[0],n[1]=i*e[1],n[2]=i*e[2],n[3]=Math.cos(t),n}function Qg(n,e,t,i){let r=e[0],s=e[1],o=e[2],a=e[3],c=t[0],l=t[1],u=t[2],f=t[3],d,h,p,m,g;return d=r*c+s*l+o*u+a*f,d<0&&(d=-d,c=-c,l=-l,u=-u,f=-f),1-d>1e-6?(h=Math.acos(d),g=Math.sin(h),p=Math.sin((1-i)*h)/g,m=Math.sin(i*h)/g):(p=1-i,m=i),n[0]=p*r+m*c,n[1]=p*s+m*l,n[2]=p*o+m*u,n[3]=p*a+m*f,n}function s4(n,e){let t=e[0]+e[4]+e[8],i;if(t>0)i=Math.sqrt(t+1),n[3]=.5*i,i=.5/i,n[0]=(e[5]-e[7])*i,n[1]=(e[6]-e[2])*i,n[2]=(e[1]-e[3])*i;else{let r=0;e[4]>e[0]&&(r=1),e[8]>e[r*3+r]&&(r=2);let s=(r+1)%3,o=(r+2)%3;i=Math.sqrt(e[r*3+r]-e[s*3+s]-e[o*3+o]+1),n[r]=.5*i,i=.5/i,n[3]=(e[s*3+o]-e[o*3+s])*i,n[s]=(e[s*3+r]+e[r*3+s])*i,n[o]=(e[o*3+r]+e[r*3+o])*i}return n}var GE,MK,AK,kK,VE=C(()=>{$r();Mg();Xa();sf();GE=Yg,MK=function(){let n=ef(),e=tf(1,0,0),t=tf(0,1,0);return function(i,r,s){let o=qa(r,s);return o<-.999999?(Gr(n,e,r),Tg(n)<1e-6&&Gr(n,t,r),vg(n,n),r4(i,n,Math.PI),i):o>.999999?(i[0]=0,i[1]=0,i[2]=0,i[3]=1,i):(Gr(n,r,s),i[0]=n[0],i[1]=n[1],i[2]=n[2],i[3]=1+o,GE(i,i))}}(),AK=function(){let n=$E(),e=$E();return function(t,i,r,s,o,a){return Qg(n,i,o,a),Qg(e,r,s,a),Qg(t,n,e,2*a*(1-a)),t}}(),kK=function(){let n=gE();return function(e,t,i,r){return n[0]=i[0],n[3]=i[1],n[6]=i[2],n[1]=r[0],n[4]=r[1],n[7]=r[2],n[2]=-t[0],n[5]=-t[1],n[8]=-t[2],GE(e,s4(e,n))}}()});var RK,IK,BK,OK,WE=C(()=>{RK=Math.PI/2,IK=Math.PI/4,BK=Math.PI/6,OK=Math.PI*2});var ze=C(()=>{pE();UE();WE();Ks();Mg();Wg();VE();yg();Xa();sf()});function Jg(n,e=[],t=0){let i=Math.fround(n),r=n-i;return e[t]=i,e[t+1]=r,e}function jE(n){return n-Math.fround(n)}function HE(n){let e=new Float32Array(32);for(let t=0;t<4;++t)for(let i=0;i<4;++i){let r=t*4+i;Jg(n[i*4+t],e,r*2)}return e}var YE=C(()=>{});function cf(n,e=!0){return n??e}function e_(n=[0,0,0],e=!0){return e?n.map(t=>t/255):[...n]}function qE(n,e=!0){let t=e_(n.slice(0,3),e),i=Number.isFinite(n[3]),r=i?n[3]:1;return[t[0],t[1],t[2],e&&i?r/255:r]}var t_=C(()=>{});var c4,l4,Vr,ZE=C(()=>{c4=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND +}`,FB=`#version 300 es +${NB}`});function pg(n,{precision:e=Ye.precision}={}){return n=$B(n),`${parseFloat(n.toPrecision(e))}`}function vi(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Te(n,e,t){return VB(n,i=>Math.max(e,Math.min(t,i)))}function fn(n,e,t){return vi(n)?n.map((i,r)=>fn(i,e[r],t)):t*e+(1-t)*n}function $n(n,e,t){let i=Ye.EPSILON;t&&(Ye.EPSILON=t);try{if(n===e)return!0;if(vi(n)&&vi(e)){if(n.length!==e.length)return!1;for(let r=0;r{tK=1/Math.PI*180,nK=1/180*Math.PI,UB={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...UB}};Ye=globalThis.mathgl.config});var Qs,mg=C(()=>{Ks();Qs=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,t=0){for(let i=0;i0?", ":"")+pg(this[i],e);return`${e.printTypes?this.constructor.name:""}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t{Ks()});function gg(n,e){if(!n)throw new Error(`math.gl assertion ${e}`)}var Zw=C(()=>{});var Qu,Xw=C(()=>{mg();Ya();Zw();Qu=class extends Qs{get x(){return this[0]}set x(e){this[0]=Je(e)}get y(){return this[1]}set y(e){this[1]=Je(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let t=0;t=0&&e=0&&e=0?Math.round(n):n%.5===0?Math.floor(n):Math.round(n)}var we,Gn,hK,$r=C(()=>{we=typeof Float32Array<"u"?Float32Array:Array,Gn=Math.random;hK=Math.PI/180});var dt={};mi(dt,{add:()=>ZB,angle:()=>pO,ceil:()=>XB,clone:()=>jB,copy:()=>YB,create:()=>Kw,cross:()=>aO,dist:()=>EO,distance:()=>tE,div:()=>wO,divide:()=>eE,dot:()=>oO,equals:()=>yO,exactEquals:()=>_O,floor:()=>KB,forEach:()=>CO,fromValues:()=>HB,inverse:()=>rO,len:()=>bO,length:()=>iE,lerp:()=>cO,max:()=>JB,min:()=>QB,mul:()=>xO,multiply:()=>Jw,negate:()=>iO,normalize:()=>sO,random:()=>lO,rotate:()=>hO,round:()=>eO,scale:()=>tO,scaleAndAdd:()=>nO,set:()=>qB,sqrDist:()=>SO,sqrLen:()=>PO,squaredDistance:()=>nE,squaredLength:()=>rE,str:()=>gO,sub:()=>vO,subtract:()=>Qw,transformMat2:()=>uO,transformMat2d:()=>fO,transformMat3:()=>dO,transformMat4:()=>_g,zero:()=>mO});function Kw(){let n=new we(2);return we!=Float32Array&&(n[0]=0,n[1]=0),n}function jB(n){let e=new we(2);return e[0]=n[0],e[1]=n[1],e}function HB(n,e){let t=new we(2);return t[0]=n,t[1]=e,t}function YB(n,e){return n[0]=e[0],n[1]=e[1],n}function qB(n,e,t){return n[0]=e,n[1]=t,n}function ZB(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n}function Qw(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n}function Jw(n,e,t){return n[0]=e[0]*t[0],n[1]=e[1]*t[1],n}function eE(n,e,t){return n[0]=e[0]/t[0],n[1]=e[1]/t[1],n}function XB(n,e){return n[0]=Math.ceil(e[0]),n[1]=Math.ceil(e[1]),n}function KB(n,e){return n[0]=Math.floor(e[0]),n[1]=Math.floor(e[1]),n}function QB(n,e,t){return n[0]=Math.min(e[0],t[0]),n[1]=Math.min(e[1],t[1]),n}function JB(n,e,t){return n[0]=Math.max(e[0],t[0]),n[1]=Math.max(e[1],t[1]),n}function eO(n,e){return n[0]=Kt(e[0]),n[1]=Kt(e[1]),n}function tO(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n}function nO(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n}function tE(n,e){let t=e[0]-n[0],i=e[1]-n[1];return Math.sqrt(t*t+i*i)}function nE(n,e){let t=e[0]-n[0],i=e[1]-n[1];return t*t+i*i}function iE(n){let e=n[0],t=n[1];return Math.sqrt(e*e+t*t)}function rE(n){let e=n[0],t=n[1];return e*e+t*t}function iO(n,e){return n[0]=-e[0],n[1]=-e[1],n}function rO(n,e){return n[0]=1/e[0],n[1]=1/e[1],n}function sO(n,e){let t=e[0],i=e[1],r=t*t+i*i;return r>0&&(r=1/Math.sqrt(r)),n[0]=e[0]*r,n[1]=e[1]*r,n}function oO(n,e){return n[0]*e[0]+n[1]*e[1]}function aO(n,e,t){let i=e[0]*t[1]-e[1]*t[0];return n[0]=n[1]=0,n[2]=i,n}function cO(n,e,t,i){let r=e[0],s=e[1];return n[0]=r+i*(t[0]-r),n[1]=s+i*(t[1]-s),n}function lO(n,e){e=e===void 0?1:e;let t=Gn()*2*Math.PI;return n[0]=Math.cos(t)*e,n[1]=Math.sin(t)*e,n}function uO(n,e,t){let i=e[0],r=e[1];return n[0]=t[0]*i+t[2]*r,n[1]=t[1]*i+t[3]*r,n}function fO(n,e,t){let i=e[0],r=e[1];return n[0]=t[0]*i+t[2]*r+t[4],n[1]=t[1]*i+t[3]*r+t[5],n}function dO(n,e,t){let i=e[0],r=e[1];return n[0]=t[0]*i+t[3]*r+t[6],n[1]=t[1]*i+t[4]*r+t[7],n}function _g(n,e,t){let i=e[0],r=e[1];return n[0]=t[0]*i+t[4]*r+t[12],n[1]=t[1]*i+t[5]*r+t[13],n}function hO(n,e,t,i){let r=e[0]-t[0],s=e[1]-t[1],o=Math.sin(i),a=Math.cos(i);return n[0]=r*a-s*o+t[0],n[1]=r*o+s*a+t[1],n}function pO(n,e){let t=n[0],i=n[1],r=e[0],s=e[1],o=Math.sqrt((t*t+i*i)*(r*r+s*s)),a=o&&(t*r+i*s)/o;return Math.acos(Math.min(Math.max(a,-1),1))}function mO(n){return n[0]=0,n[1]=0,n}function gO(n){return`vec2(${n[0]}, ${n[1]})`}function _O(n,e){return n[0]===e[0]&&n[1]===e[1]}function yO(n,e){let t=n[0],i=n[1],r=e[0],s=e[1];return Math.abs(t-r)<=1e-6*Math.max(1,Math.abs(t),Math.abs(r))&&Math.abs(i-s)<=1e-6*Math.max(1,Math.abs(i),Math.abs(s))}var bO,vO,xO,wO,EO,SO,PO,CO,yg=C(()=>{$r();bO=iE,vO=Qw,xO=Jw,wO=eE,EO=tE,SO=nE,PO=rE,CO=function(){let n=Kw();return function(e,t,i,r,s,o){let a,c;for(t||(t=2),i||(i=0),r?c=Math.min(r*t+i,e.length):c=e.length,a=i;a{});var bt={};mi(bt,{add:()=>AO,angle:()=>Cg,bezier:()=>VO,ceil:()=>kO,clone:()=>TO,copy:()=>LO,create:()=>ef,cross:()=>Gr,dist:()=>QO,distance:()=>fE,div:()=>KO,divide:()=>uE,dot:()=>qa,equals:()=>qO,exactEquals:()=>YO,floor:()=>RO,forEach:()=>tD,fromValues:()=>tf,hermite:()=>GO,inverse:()=>zO,len:()=>Tg,length:()=>aE,lerp:()=>UO,max:()=>BO,min:()=>IO,mul:()=>XO,multiply:()=>lE,negate:()=>FO,normalize:()=>vg,random:()=>WO,rotateX:()=>Eg,rotateY:()=>Sg,rotateZ:()=>Pg,round:()=>OO,scale:()=>DO,scaleAndAdd:()=>NO,set:()=>MO,slerp:()=>$O,sqrDist:()=>JO,sqrLen:()=>eD,squaredDistance:()=>dE,squaredLength:()=>hE,str:()=>HO,sub:()=>ZO,subtract:()=>cE,transformMat3:()=>xg,transformMat4:()=>Za,transformQuat:()=>wg,zero:()=>jO});function ef(){let n=new we(3);return we!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n}function TO(n){let e=new we(3);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e}function aE(n){let e=n[0],t=n[1],i=n[2];return Math.sqrt(e*e+t*t+i*i)}function tf(n,e,t){let i=new we(3);return i[0]=n,i[1]=e,i[2]=t,i}function LO(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n}function MO(n,e,t,i){return n[0]=e,n[1]=t,n[2]=i,n}function AO(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n}function cE(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n}function lE(n,e,t){return n[0]=e[0]*t[0],n[1]=e[1]*t[1],n[2]=e[2]*t[2],n}function uE(n,e,t){return n[0]=e[0]/t[0],n[1]=e[1]/t[1],n[2]=e[2]/t[2],n}function kO(n,e){return n[0]=Math.ceil(e[0]),n[1]=Math.ceil(e[1]),n[2]=Math.ceil(e[2]),n}function RO(n,e){return n[0]=Math.floor(e[0]),n[1]=Math.floor(e[1]),n[2]=Math.floor(e[2]),n}function IO(n,e,t){return n[0]=Math.min(e[0],t[0]),n[1]=Math.min(e[1],t[1]),n[2]=Math.min(e[2],t[2]),n}function BO(n,e,t){return n[0]=Math.max(e[0],t[0]),n[1]=Math.max(e[1],t[1]),n[2]=Math.max(e[2],t[2]),n}function OO(n,e){return n[0]=Kt(e[0]),n[1]=Kt(e[1]),n[2]=Kt(e[2]),n}function DO(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n}function NO(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n[2]=e[2]+t[2]*i,n}function fE(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2];return Math.sqrt(t*t+i*i+r*r)}function dE(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2];return t*t+i*i+r*r}function hE(n){let e=n[0],t=n[1],i=n[2];return e*e+t*t+i*i}function FO(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n}function zO(n,e){return n[0]=1/e[0],n[1]=1/e[1],n[2]=1/e[2],n}function vg(n,e){let t=e[0],i=e[1],r=e[2],s=t*t+i*i+r*r;return s>0&&(s=1/Math.sqrt(s)),n[0]=e[0]*s,n[1]=e[1]*s,n[2]=e[2]*s,n}function qa(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]}function Gr(n,e,t){let i=e[0],r=e[1],s=e[2],o=t[0],a=t[1],c=t[2];return n[0]=r*c-s*a,n[1]=s*o-i*c,n[2]=i*a-r*o,n}function UO(n,e,t,i){let r=e[0],s=e[1],o=e[2];return n[0]=r+i*(t[0]-r),n[1]=s+i*(t[1]-s),n[2]=o+i*(t[2]-o),n}function $O(n,e,t,i){let r=Math.acos(Math.min(Math.max(qa(e,t),-1),1)),s=Math.sin(r),o=Math.sin((1-i)*r)/s,a=Math.sin(i*r)/s;return n[0]=o*e[0]+a*t[0],n[1]=o*e[1]+a*t[1],n[2]=o*e[2]+a*t[2],n}function GO(n,e,t,i,r,s){let o=s*s,a=o*(2*s-3)+1,c=o*(s-2)+s,l=o*(s-1),u=o*(3-2*s);return n[0]=e[0]*a+t[0]*c+i[0]*l+r[0]*u,n[1]=e[1]*a+t[1]*c+i[1]*l+r[1]*u,n[2]=e[2]*a+t[2]*c+i[2]*l+r[2]*u,n}function VO(n,e,t,i,r,s){let o=1-s,a=o*o,c=s*s,l=a*o,u=3*s*a,f=3*c*o,d=c*s;return n[0]=e[0]*l+t[0]*u+i[0]*f+r[0]*d,n[1]=e[1]*l+t[1]*u+i[1]*f+r[1]*d,n[2]=e[2]*l+t[2]*u+i[2]*f+r[2]*d,n}function WO(n,e){e=e===void 0?1:e;let t=Gn()*2*Math.PI,i=Gn()*2-1,r=Math.sqrt(1-i*i)*e;return n[0]=Math.cos(t)*r,n[1]=Math.sin(t)*r,n[2]=i*e,n}function Za(n,e,t){let i=e[0],r=e[1],s=e[2],o=t[3]*i+t[7]*r+t[11]*s+t[15];return o=o||1,n[0]=(t[0]*i+t[4]*r+t[8]*s+t[12])/o,n[1]=(t[1]*i+t[5]*r+t[9]*s+t[13])/o,n[2]=(t[2]*i+t[6]*r+t[10]*s+t[14])/o,n}function xg(n,e,t){let i=e[0],r=e[1],s=e[2];return n[0]=i*t[0]+r*t[3]+s*t[6],n[1]=i*t[1]+r*t[4]+s*t[7],n[2]=i*t[2]+r*t[5]+s*t[8],n}function wg(n,e,t){let i=t[0],r=t[1],s=t[2],o=t[3],a=e[0],c=e[1],l=e[2],u=r*l-s*c,f=s*a-i*l,d=i*c-r*a,h=r*d-s*f,p=s*u-i*d,m=i*f-r*u,g=o*2;return u*=g,f*=g,d*=g,h*=2,p*=2,m*=2,n[0]=a+u+h,n[1]=c+f+p,n[2]=l+d+m,n}function Eg(n,e,t,i){let r=[],s=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],s[0]=r[0],s[1]=r[1]*Math.cos(i)-r[2]*Math.sin(i),s[2]=r[1]*Math.sin(i)+r[2]*Math.cos(i),n[0]=s[0]+t[0],n[1]=s[1]+t[1],n[2]=s[2]+t[2],n}function Sg(n,e,t,i){let r=[],s=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],s[0]=r[2]*Math.sin(i)+r[0]*Math.cos(i),s[1]=r[1],s[2]=r[2]*Math.cos(i)-r[0]*Math.sin(i),n[0]=s[0]+t[0],n[1]=s[1]+t[1],n[2]=s[2]+t[2],n}function Pg(n,e,t,i){let r=[],s=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],s[0]=r[0]*Math.cos(i)-r[1]*Math.sin(i),s[1]=r[0]*Math.sin(i)+r[1]*Math.cos(i),s[2]=r[2],n[0]=s[0]+t[0],n[1]=s[1]+t[1],n[2]=s[2]+t[2],n}function Cg(n,e){let t=n[0],i=n[1],r=n[2],s=e[0],o=e[1],a=e[2],c=Math.sqrt((t*t+i*i+r*r)*(s*s+o*o+a*a)),l=c&&qa(n,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function jO(n){return n[0]=0,n[1]=0,n[2]=0,n}function HO(n){return`vec3(${n[0]}, ${n[1]}, ${n[2]})`}function YO(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]}function qO(n,e){let t=n[0],i=n[1],r=n[2],s=e[0],o=e[1],a=e[2];return Math.abs(t-s)<=1e-6*Math.max(1,Math.abs(t),Math.abs(s))&&Math.abs(i-o)<=1e-6*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(r-a)<=1e-6*Math.max(1,Math.abs(r),Math.abs(a))}var ZO,XO,KO,QO,JO,Tg,eD,tD,Xa=C(()=>{$r();ZO=cE,XO=lE,KO=uE,QO=fE,JO=dE,Tg=aE,eD=hE,tD=function(){let n=ef();return function(e,t,i,r,s,o){let a,c;for(t||(t=3),i||(i=0),r?c=Math.min(r*t+i,e.length):c=e.length,a=i;a{Xw();Ks();Ya();Xa();bg();Lg=[0,0,0],et=class n extends Qu{static get ZERO(){return nf||(nf=new n(0,0,0),Object.freeze(nf)),nf}constructor(e=0,t=0,i=0){super(-0,-0,-0),arguments.length===1&&vi(e)?this.copy(e):(Ye.debug&&(Je(e),Je(t),Je(i)),this[0]=e,this[1]=t,this[2]=i)}set(e,t,i){return this[0]=e,this[1]=t,this[2]=i,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return Ye.debug&&(Je(e.x),Je(e.y),Je(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=Je(e)}angle(e){return Cg(this,e)}cross(e){return Gr(this,this,e),this.check()}rotateX({radians:e,origin:t=Lg}){return Eg(this,this,t,e),this.check()}rotateY({radians:e,origin:t=Lg}){return Sg(this,this,t,e),this.check()}rotateZ({radians:e,origin:t=Lg}){return Pg(this,this,t,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return Za(this,this,e),this.check()}transformAsVector(e){return Ju(this,this,e),this.check()}transformByMatrix3(e){return xg(this,this,e),this.check()}transformByMatrix2(e){return oE(this,this,e),this.check()}transformByQuaternion(e){return wg(this,this,e),this.check()}}});var rf,mE=C(()=>{mg();Ya();Ks();rf=class extends Qs{toString(){let e="[";if(Ye.printRowMajor){e+="row-major:";for(let t=0;t{$r()});var We={};mi(We,{add:()=>CD,adjoint:()=>aD,clone:()=>iD,copy:()=>rD,create:()=>nD,decompose:()=>_D,determinant:()=>Rg,equals:()=>AD,exactEquals:()=>MD,frob:()=>PD,fromQuat:()=>zg,fromQuat2:()=>pD,fromRotation:()=>uD,fromRotationTranslation:()=>bE,fromRotationTranslationScale:()=>yD,fromRotationTranslationScaleOrigin:()=>bD,fromScaling:()=>lD,fromTranslation:()=>cD,fromValues:()=>sD,fromXRotation:()=>fD,fromYRotation:()=>dD,fromZRotation:()=>hD,frustum:()=>Ug,getRotation:()=>gD,getScaling:()=>vE,getTranslation:()=>mD,identity:()=>yE,invert:()=>kg,lookAt:()=>Vg,mul:()=>kD,multiply:()=>Ka,multiplyScalar:()=>TD,multiplyScalarAndAdd:()=>LD,ortho:()=>Gg,orthoNO:()=>wE,orthoZO:()=>wD,perspective:()=>$g,perspectiveFromFieldOfView:()=>xD,perspectiveNO:()=>xE,perspectiveZO:()=>vD,rotate:()=>Og,rotateX:()=>Dg,rotateY:()=>Ng,rotateZ:()=>Fg,scale:()=>Bg,set:()=>oD,str:()=>SD,sub:()=>RD,subtract:()=>EE,targetTo:()=>ED,translate:()=>Ig,transpose:()=>Ag});function nD(){let n=new we(16);return we!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0),n[0]=1,n[5]=1,n[10]=1,n[15]=1,n}function iD(n){let e=new we(16);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],e}function rD(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function sD(n,e,t,i,r,s,o,a,c,l,u,f,d,h,p,m){let g=new we(16);return g[0]=n,g[1]=e,g[2]=t,g[3]=i,g[4]=r,g[5]=s,g[6]=o,g[7]=a,g[8]=c,g[9]=l,g[10]=u,g[11]=f,g[12]=d,g[13]=h,g[14]=p,g[15]=m,g}function oD(n,e,t,i,r,s,o,a,c,l,u,f,d,h,p,m,g){return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n[4]=s,n[5]=o,n[6]=a,n[7]=c,n[8]=l,n[9]=u,n[10]=f,n[11]=d,n[12]=h,n[13]=p,n[14]=m,n[15]=g,n}function yE(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Ag(n,e){if(n===e){let t=e[1],i=e[2],r=e[3],s=e[6],o=e[7],a=e[11];n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=t,n[6]=e[9],n[7]=e[13],n[8]=i,n[9]=s,n[11]=e[14],n[12]=r,n[13]=o,n[14]=a}else n[0]=e[0],n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=e[1],n[5]=e[5],n[6]=e[9],n[7]=e[13],n[8]=e[2],n[9]=e[6],n[10]=e[10],n[11]=e[14],n[12]=e[3],n[13]=e[7],n[14]=e[11],n[15]=e[15];return n}function kg(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],d=e[10],h=e[11],p=e[12],m=e[13],g=e[14],v=e[15],y=t*a-i*o,b=t*c-r*o,x=t*l-s*o,E=i*c-r*a,w=i*l-s*a,T=r*l-s*c,R=u*m-f*p,F=u*g-d*p,O=u*v-h*p,j=f*g-d*m,V=f*v-h*m,G=d*v-h*g,q=y*G-b*V+x*j+E*O-w*F+T*R;return q?(q=1/q,n[0]=(a*G-c*V+l*j)*q,n[1]=(r*V-i*G-s*j)*q,n[2]=(m*T-g*w+v*E)*q,n[3]=(d*w-f*T-h*E)*q,n[4]=(c*O-o*G-l*F)*q,n[5]=(t*G-r*O+s*F)*q,n[6]=(g*x-p*T-v*b)*q,n[7]=(u*T-d*x+h*b)*q,n[8]=(o*V-a*O+l*R)*q,n[9]=(i*O-t*V-s*R)*q,n[10]=(p*w-m*x+v*y)*q,n[11]=(f*x-u*w-h*y)*q,n[12]=(a*F-o*j-c*R)*q,n[13]=(t*j-i*F+r*R)*q,n[14]=(m*b-p*E-g*y)*q,n[15]=(u*E-f*b+d*y)*q,n):null}function aD(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],d=e[10],h=e[11],p=e[12],m=e[13],g=e[14],v=e[15],y=t*a-i*o,b=t*c-r*o,x=t*l-s*o,E=i*c-r*a,w=i*l-s*a,T=r*l-s*c,R=u*m-f*p,F=u*g-d*p,O=u*v-h*p,j=f*g-d*m,V=f*v-h*m,G=d*v-h*g;return n[0]=a*G-c*V+l*j,n[1]=r*V-i*G-s*j,n[2]=m*T-g*w+v*E,n[3]=d*w-f*T-h*E,n[4]=c*O-o*G-l*F,n[5]=t*G-r*O+s*F,n[6]=g*x-p*T-v*b,n[7]=u*T-d*x+h*b,n[8]=o*V-a*O+l*R,n[9]=i*O-t*V-s*R,n[10]=p*w-m*x+v*y,n[11]=f*x-u*w-h*y,n[12]=a*F-o*j-c*R,n[13]=t*j-i*F+r*R,n[14]=m*b-p*E-g*y,n[15]=u*E-f*b+d*y,n}function Rg(n){let e=n[0],t=n[1],i=n[2],r=n[3],s=n[4],o=n[5],a=n[6],c=n[7],l=n[8],u=n[9],f=n[10],d=n[11],h=n[12],p=n[13],m=n[14],g=n[15],v=e*o-t*s,y=e*a-i*s,b=t*a-i*o,x=l*p-u*h,E=l*m-f*h,w=u*m-f*p,T=e*w-t*E+i*x,R=s*w-o*E+a*x,F=l*b-u*y+f*v,O=h*b-p*y+m*v;return c*T-r*R+g*F-d*O}function Ka(n,e,t){let i=e[0],r=e[1],s=e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=e[8],d=e[9],h=e[10],p=e[11],m=e[12],g=e[13],v=e[14],y=e[15],b=t[0],x=t[1],E=t[2],w=t[3];return n[0]=b*i+x*a+E*f+w*m,n[1]=b*r+x*c+E*d+w*g,n[2]=b*s+x*l+E*h+w*v,n[3]=b*o+x*u+E*p+w*y,b=t[4],x=t[5],E=t[6],w=t[7],n[4]=b*i+x*a+E*f+w*m,n[5]=b*r+x*c+E*d+w*g,n[6]=b*s+x*l+E*h+w*v,n[7]=b*o+x*u+E*p+w*y,b=t[8],x=t[9],E=t[10],w=t[11],n[8]=b*i+x*a+E*f+w*m,n[9]=b*r+x*c+E*d+w*g,n[10]=b*s+x*l+E*h+w*v,n[11]=b*o+x*u+E*p+w*y,b=t[12],x=t[13],E=t[14],w=t[15],n[12]=b*i+x*a+E*f+w*m,n[13]=b*r+x*c+E*d+w*g,n[14]=b*s+x*l+E*h+w*v,n[15]=b*o+x*u+E*p+w*y,n}function Ig(n,e,t){let i=t[0],r=t[1],s=t[2],o,a,c,l,u,f,d,h,p,m,g,v;return e===n?(n[12]=e[0]*i+e[4]*r+e[8]*s+e[12],n[13]=e[1]*i+e[5]*r+e[9]*s+e[13],n[14]=e[2]*i+e[6]*r+e[10]*s+e[14],n[15]=e[3]*i+e[7]*r+e[11]*s+e[15]):(o=e[0],a=e[1],c=e[2],l=e[3],u=e[4],f=e[5],d=e[6],h=e[7],p=e[8],m=e[9],g=e[10],v=e[11],n[0]=o,n[1]=a,n[2]=c,n[3]=l,n[4]=u,n[5]=f,n[6]=d,n[7]=h,n[8]=p,n[9]=m,n[10]=g,n[11]=v,n[12]=o*i+u*r+p*s+e[12],n[13]=a*i+f*r+m*s+e[13],n[14]=c*i+d*r+g*s+e[14],n[15]=l*i+h*r+v*s+e[15]),n}function Bg(n,e,t){let i=t[0],r=t[1],s=t[2];return n[0]=e[0]*i,n[1]=e[1]*i,n[2]=e[2]*i,n[3]=e[3]*i,n[4]=e[4]*r,n[5]=e[5]*r,n[6]=e[6]*r,n[7]=e[7]*r,n[8]=e[8]*s,n[9]=e[9]*s,n[10]=e[10]*s,n[11]=e[11]*s,n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function Og(n,e,t,i){let r=i[0],s=i[1],o=i[2],a=Math.sqrt(r*r+s*s+o*o),c,l,u,f,d,h,p,m,g,v,y,b,x,E,w,T,R,F,O,j,V,G,q,X;return a<1e-6?null:(a=1/a,r*=a,s*=a,o*=a,l=Math.sin(t),c=Math.cos(t),u=1-c,f=e[0],d=e[1],h=e[2],p=e[3],m=e[4],g=e[5],v=e[6],y=e[7],b=e[8],x=e[9],E=e[10],w=e[11],T=r*r*u+c,R=s*r*u+o*l,F=o*r*u-s*l,O=r*s*u-o*l,j=s*s*u+c,V=o*s*u+r*l,G=r*o*u+s*l,q=s*o*u-r*l,X=o*o*u+c,n[0]=f*T+m*R+b*F,n[1]=d*T+g*R+x*F,n[2]=h*T+v*R+E*F,n[3]=p*T+y*R+w*F,n[4]=f*O+m*j+b*V,n[5]=d*O+g*j+x*V,n[6]=h*O+v*j+E*V,n[7]=p*O+y*j+w*V,n[8]=f*G+m*q+b*X,n[9]=d*G+g*q+x*X,n[10]=h*G+v*q+E*X,n[11]=p*G+y*q+w*X,e!==n&&(n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n)}function Dg(n,e,t){let i=Math.sin(t),r=Math.cos(t),s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],f=e[10],d=e[11];return e!==n&&(n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[4]=s*r+l*i,n[5]=o*r+u*i,n[6]=a*r+f*i,n[7]=c*r+d*i,n[8]=l*r-s*i,n[9]=u*r-o*i,n[10]=f*r-a*i,n[11]=d*r-c*i,n}function Ng(n,e,t){let i=Math.sin(t),r=Math.cos(t),s=e[0],o=e[1],a=e[2],c=e[3],l=e[8],u=e[9],f=e[10],d=e[11];return e!==n&&(n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=s*r-l*i,n[1]=o*r-u*i,n[2]=a*r-f*i,n[3]=c*r-d*i,n[8]=s*i+l*r,n[9]=o*i+u*r,n[10]=a*i+f*r,n[11]=c*i+d*r,n}function Fg(n,e,t){let i=Math.sin(t),r=Math.cos(t),s=e[0],o=e[1],a=e[2],c=e[3],l=e[4],u=e[5],f=e[6],d=e[7];return e!==n&&(n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=s*r+l*i,n[1]=o*r+u*i,n[2]=a*r+f*i,n[3]=c*r+d*i,n[4]=l*r-s*i,n[5]=u*r-o*i,n[6]=f*r-a*i,n[7]=d*r-c*i,n}function cD(n,e){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=e[0],n[13]=e[1],n[14]=e[2],n[15]=1,n}function lD(n,e){return n[0]=e[0],n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=e[1],n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=e[2],n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function uD(n,e,t){let i=t[0],r=t[1],s=t[2],o=Math.sqrt(i*i+r*r+s*s),a,c,l;return o<1e-6?null:(o=1/o,i*=o,r*=o,s*=o,c=Math.sin(e),a=Math.cos(e),l=1-a,n[0]=i*i*l+a,n[1]=r*i*l+s*c,n[2]=s*i*l-r*c,n[3]=0,n[4]=i*r*l-s*c,n[5]=r*r*l+a,n[6]=s*r*l+i*c,n[7]=0,n[8]=i*s*l+r*c,n[9]=r*s*l-i*c,n[10]=s*s*l+a,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n)}function fD(n,e){let t=Math.sin(e),i=Math.cos(e);return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i,n[6]=t,n[7]=0,n[8]=0,n[9]=-t,n[10]=i,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function dD(n,e){let t=Math.sin(e),i=Math.cos(e);return n[0]=i,n[1]=0,n[2]=-t,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=t,n[9]=0,n[10]=i,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function hD(n,e){let t=Math.sin(e),i=Math.cos(e);return n[0]=i,n[1]=t,n[2]=0,n[3]=0,n[4]=-t,n[5]=i,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function bE(n,e,t){let i=e[0],r=e[1],s=e[2],o=e[3],a=i+i,c=r+r,l=s+s,u=i*a,f=i*c,d=i*l,h=r*c,p=r*l,m=s*l,g=o*a,v=o*c,y=o*l;return n[0]=1-(h+m),n[1]=f+y,n[2]=d-v,n[3]=0,n[4]=f-y,n[5]=1-(u+m),n[6]=p+g,n[7]=0,n[8]=d+v,n[9]=p-g,n[10]=1-(u+h),n[11]=0,n[12]=t[0],n[13]=t[1],n[14]=t[2],n[15]=1,n}function pD(n,e){let t=new we(3),i=-e[0],r=-e[1],s=-e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=i*i+r*r+s*s+o*o;return f>0?(t[0]=(a*o+u*i+c*s-l*r)*2/f,t[1]=(c*o+u*r+l*i-a*s)*2/f,t[2]=(l*o+u*s+a*r-c*i)*2/f):(t[0]=(a*o+u*i+c*s-l*r)*2,t[1]=(c*o+u*r+l*i-a*s)*2,t[2]=(l*o+u*s+a*r-c*i)*2),bE(n,e,t),n}function mD(n,e){return n[0]=e[12],n[1]=e[13],n[2]=e[14],n}function vE(n,e){let t=e[0],i=e[1],r=e[2],s=e[4],o=e[5],a=e[6],c=e[8],l=e[9],u=e[10];return n[0]=Math.sqrt(t*t+i*i+r*r),n[1]=Math.sqrt(s*s+o*o+a*a),n[2]=Math.sqrt(c*c+l*l+u*u),n}function gD(n,e){let t=new we(3);vE(t,e);let i=1/t[0],r=1/t[1],s=1/t[2],o=e[0]*i,a=e[1]*r,c=e[2]*s,l=e[4]*i,u=e[5]*r,f=e[6]*s,d=e[8]*i,h=e[9]*r,p=e[10]*s,m=o+u+p,g=0;return m>0?(g=Math.sqrt(m+1)*2,n[3]=.25*g,n[0]=(f-h)/g,n[1]=(d-c)/g,n[2]=(a-l)/g):o>u&&o>p?(g=Math.sqrt(1+o-u-p)*2,n[3]=(f-h)/g,n[0]=.25*g,n[1]=(a+l)/g,n[2]=(d+c)/g):u>p?(g=Math.sqrt(1+u-o-p)*2,n[3]=(d-c)/g,n[0]=(a+l)/g,n[1]=.25*g,n[2]=(f+h)/g):(g=Math.sqrt(1+p-o-u)*2,n[3]=(a-l)/g,n[0]=(d+c)/g,n[1]=(f+h)/g,n[2]=.25*g),n}function _D(n,e,t,i){e[0]=i[12],e[1]=i[13],e[2]=i[14];let r=i[0],s=i[1],o=i[2],a=i[4],c=i[5],l=i[6],u=i[8],f=i[9],d=i[10];t[0]=Math.sqrt(r*r+s*s+o*o),t[1]=Math.sqrt(a*a+c*c+l*l),t[2]=Math.sqrt(u*u+f*f+d*d);let h=1/t[0],p=1/t[1],m=1/t[2],g=r*h,v=s*p,y=o*m,b=a*h,x=c*p,E=l*m,w=u*h,T=f*p,R=d*m,F=g+x+R,O=0;return F>0?(O=Math.sqrt(F+1)*2,n[3]=.25*O,n[0]=(E-T)/O,n[1]=(w-y)/O,n[2]=(v-b)/O):g>x&&g>R?(O=Math.sqrt(1+g-x-R)*2,n[3]=(E-T)/O,n[0]=.25*O,n[1]=(v+b)/O,n[2]=(w+y)/O):x>R?(O=Math.sqrt(1+x-g-R)*2,n[3]=(w-y)/O,n[0]=(v+b)/O,n[1]=.25*O,n[2]=(E+T)/O):(O=Math.sqrt(1+R-g-x)*2,n[3]=(v-b)/O,n[0]=(w+y)/O,n[1]=(E+T)/O,n[2]=.25*O),n}function yD(n,e,t,i){let r=e[0],s=e[1],o=e[2],a=e[3],c=r+r,l=s+s,u=o+o,f=r*c,d=r*l,h=r*u,p=s*l,m=s*u,g=o*u,v=a*c,y=a*l,b=a*u,x=i[0],E=i[1],w=i[2];return n[0]=(1-(p+g))*x,n[1]=(d+b)*x,n[2]=(h-y)*x,n[3]=0,n[4]=(d-b)*E,n[5]=(1-(f+g))*E,n[6]=(m+v)*E,n[7]=0,n[8]=(h+y)*w,n[9]=(m-v)*w,n[10]=(1-(f+p))*w,n[11]=0,n[12]=t[0],n[13]=t[1],n[14]=t[2],n[15]=1,n}function bD(n,e,t,i,r){let s=e[0],o=e[1],a=e[2],c=e[3],l=s+s,u=o+o,f=a+a,d=s*l,h=s*u,p=s*f,m=o*u,g=o*f,v=a*f,y=c*l,b=c*u,x=c*f,E=i[0],w=i[1],T=i[2],R=r[0],F=r[1],O=r[2],j=(1-(m+v))*E,V=(h+x)*E,G=(p-b)*E,q=(h-x)*w,X=(1-(d+v))*w,se=(g+y)*w,le=(p+b)*T,he=(g-y)*T,at=(1-(d+m))*T;return n[0]=j,n[1]=V,n[2]=G,n[3]=0,n[4]=q,n[5]=X,n[6]=se,n[7]=0,n[8]=le,n[9]=he,n[10]=at,n[11]=0,n[12]=t[0]+R-(j*R+q*F+le*O),n[13]=t[1]+F-(V*R+X*F+he*O),n[14]=t[2]+O-(G*R+se*F+at*O),n[15]=1,n}function zg(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],o=t+t,a=i+i,c=r+r,l=t*o,u=i*o,f=i*a,d=r*o,h=r*a,p=r*c,m=s*o,g=s*a,v=s*c;return n[0]=1-f-p,n[1]=u+v,n[2]=d-g,n[3]=0,n[4]=u-v,n[5]=1-l-p,n[6]=h+m,n[7]=0,n[8]=d+g,n[9]=h-m,n[10]=1-l-f,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Ug(n,e,t,i,r,s,o){let a=1/(t-e),c=1/(r-i),l=1/(s-o);return n[0]=s*2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=s*2*c,n[6]=0,n[7]=0,n[8]=(t+e)*a,n[9]=(r+i)*c,n[10]=(o+s)*l,n[11]=-1,n[12]=0,n[13]=0,n[14]=o*s*2*l,n[15]=0,n}function xE(n,e,t,i,r){let s=1/Math.tan(e/2);if(n[0]=s/t,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=s,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,r!=null&&r!==1/0){let o=1/(i-r);n[10]=(r+i)*o,n[14]=2*r*i*o}else n[10]=-1,n[14]=-2*i;return n}function vD(n,e,t,i,r){let s=1/Math.tan(e/2);if(n[0]=s/t,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=s,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,r!=null&&r!==1/0){let o=1/(i-r);n[10]=r*o,n[14]=r*i*o}else n[10]=-1,n[14]=-i;return n}function xD(n,e,t,i){let r=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),o=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),c=2/(o+a),l=2/(r+s);return n[0]=c,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=l,n[6]=0,n[7]=0,n[8]=-((o-a)*c*.5),n[9]=(r-s)*l*.5,n[10]=i/(t-i),n[11]=-1,n[12]=0,n[13]=0,n[14]=i*t/(t-i),n[15]=0,n}function wE(n,e,t,i,r,s,o){let a=1/(e-t),c=1/(i-r),l=1/(s-o);return n[0]=-2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*c,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*l,n[11]=0,n[12]=(e+t)*a,n[13]=(r+i)*c,n[14]=(o+s)*l,n[15]=1,n}function wD(n,e,t,i,r,s,o){let a=1/(e-t),c=1/(i-r),l=1/(s-o);return n[0]=-2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*c,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=l,n[11]=0,n[12]=(e+t)*a,n[13]=(r+i)*c,n[14]=s*l,n[15]=1,n}function Vg(n,e,t,i){let r,s,o,a,c,l,u,f,d,h,p=e[0],m=e[1],g=e[2],v=i[0],y=i[1],b=i[2],x=t[0],E=t[1],w=t[2];return Math.abs(p-x)<1e-6&&Math.abs(m-E)<1e-6&&Math.abs(g-w)<1e-6?yE(n):(f=p-x,d=m-E,h=g-w,r=1/Math.sqrt(f*f+d*d+h*h),f*=r,d*=r,h*=r,s=y*h-b*d,o=b*f-v*h,a=v*d-y*f,r=Math.sqrt(s*s+o*o+a*a),r?(r=1/r,s*=r,o*=r,a*=r):(s=0,o=0,a=0),c=d*a-h*o,l=h*s-f*a,u=f*o-d*s,r=Math.sqrt(c*c+l*l+u*u),r?(r=1/r,c*=r,l*=r,u*=r):(c=0,l=0,u=0),n[0]=s,n[1]=c,n[2]=f,n[3]=0,n[4]=o,n[5]=l,n[6]=d,n[7]=0,n[8]=a,n[9]=u,n[10]=h,n[11]=0,n[12]=-(s*p+o*m+a*g),n[13]=-(c*p+l*m+u*g),n[14]=-(f*p+d*m+h*g),n[15]=1,n)}function ED(n,e,t,i){let r=e[0],s=e[1],o=e[2],a=i[0],c=i[1],l=i[2],u=r-t[0],f=s-t[1],d=o-t[2],h=u*u+f*f+d*d;h>0&&(h=1/Math.sqrt(h),u*=h,f*=h,d*=h);let p=c*d-l*f,m=l*u-a*d,g=a*f-c*u;return h=p*p+m*m+g*g,h>0&&(h=1/Math.sqrt(h),p*=h,m*=h,g*=h),n[0]=p,n[1]=m,n[2]=g,n[3]=0,n[4]=f*g-d*m,n[5]=d*p-u*g,n[6]=u*m-f*p,n[7]=0,n[8]=u,n[9]=f,n[10]=d,n[11]=0,n[12]=r,n[13]=s,n[14]=o,n[15]=1,n}function SD(n){return`mat4(${n[0]}, ${n[1]}, ${n[2]}, ${n[3]}, ${n[4]}, ${n[5]}, ${n[6]}, ${n[7]}, ${n[8]}, ${n[9]}, ${n[10]}, ${n[11]}, ${n[12]}, ${n[13]}, ${n[14]}, ${n[15]})`}function PD(n){return Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]+n[3]*n[3]+n[4]*n[4]+n[5]*n[5]+n[6]*n[6]+n[7]*n[7]+n[8]*n[8]+n[9]*n[9]+n[10]*n[10]+n[11]*n[11]+n[12]*n[12]+n[13]*n[13]+n[14]*n[14]+n[15]*n[15])}function CD(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n[3]=e[3]+t[3],n[4]=e[4]+t[4],n[5]=e[5]+t[5],n[6]=e[6]+t[6],n[7]=e[7]+t[7],n[8]=e[8]+t[8],n[9]=e[9]+t[9],n[10]=e[10]+t[10],n[11]=e[11]+t[11],n[12]=e[12]+t[12],n[13]=e[13]+t[13],n[14]=e[14]+t[14],n[15]=e[15]+t[15],n}function EE(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n[3]=e[3]-t[3],n[4]=e[4]-t[4],n[5]=e[5]-t[5],n[6]=e[6]-t[6],n[7]=e[7]-t[7],n[8]=e[8]-t[8],n[9]=e[9]-t[9],n[10]=e[10]-t[10],n[11]=e[11]-t[11],n[12]=e[12]-t[12],n[13]=e[13]-t[13],n[14]=e[14]-t[14],n[15]=e[15]-t[15],n}function TD(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n[3]=e[3]*t,n[4]=e[4]*t,n[5]=e[5]*t,n[6]=e[6]*t,n[7]=e[7]*t,n[8]=e[8]*t,n[9]=e[9]*t,n[10]=e[10]*t,n[11]=e[11]*t,n[12]=e[12]*t,n[13]=e[13]*t,n[14]=e[14]*t,n[15]=e[15]*t,n}function LD(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n[2]=e[2]+t[2]*i,n[3]=e[3]+t[3]*i,n[4]=e[4]+t[4]*i,n[5]=e[5]+t[5]*i,n[6]=e[6]+t[6]*i,n[7]=e[7]+t[7]*i,n[8]=e[8]+t[8]*i,n[9]=e[9]+t[9]*i,n[10]=e[10]+t[10]*i,n[11]=e[11]+t[11]*i,n[12]=e[12]+t[12]*i,n[13]=e[13]+t[13]*i,n[14]=e[14]+t[14]*i,n[15]=e[15]+t[15]*i,n}function MD(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]&&n[3]===e[3]&&n[4]===e[4]&&n[5]===e[5]&&n[6]===e[6]&&n[7]===e[7]&&n[8]===e[8]&&n[9]===e[9]&&n[10]===e[10]&&n[11]===e[11]&&n[12]===e[12]&&n[13]===e[13]&&n[14]===e[14]&&n[15]===e[15]}function AD(n,e){let t=n[0],i=n[1],r=n[2],s=n[3],o=n[4],a=n[5],c=n[6],l=n[7],u=n[8],f=n[9],d=n[10],h=n[11],p=n[12],m=n[13],g=n[14],v=n[15],y=e[0],b=e[1],x=e[2],E=e[3],w=e[4],T=e[5],R=e[6],F=e[7],O=e[8],j=e[9],V=e[10],G=e[11],q=e[12],X=e[13],se=e[14],le=e[15];return Math.abs(t-y)<=1e-6*Math.max(1,Math.abs(t),Math.abs(y))&&Math.abs(i-b)<=1e-6*Math.max(1,Math.abs(i),Math.abs(b))&&Math.abs(r-x)<=1e-6*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(s-E)<=1e-6*Math.max(1,Math.abs(s),Math.abs(E))&&Math.abs(o-w)<=1e-6*Math.max(1,Math.abs(o),Math.abs(w))&&Math.abs(a-T)<=1e-6*Math.max(1,Math.abs(a),Math.abs(T))&&Math.abs(c-R)<=1e-6*Math.max(1,Math.abs(c),Math.abs(R))&&Math.abs(l-F)<=1e-6*Math.max(1,Math.abs(l),Math.abs(F))&&Math.abs(u-O)<=1e-6*Math.max(1,Math.abs(u),Math.abs(O))&&Math.abs(f-j)<=1e-6*Math.max(1,Math.abs(f),Math.abs(j))&&Math.abs(d-V)<=1e-6*Math.max(1,Math.abs(d),Math.abs(V))&&Math.abs(h-G)<=1e-6*Math.max(1,Math.abs(h),Math.abs(G))&&Math.abs(p-q)<=1e-6*Math.max(1,Math.abs(p),Math.abs(q))&&Math.abs(m-X)<=1e-6*Math.max(1,Math.abs(m),Math.abs(X))&&Math.abs(g-se)<=1e-6*Math.max(1,Math.abs(g),Math.abs(se))&&Math.abs(v-le)<=1e-6*Math.max(1,Math.abs(v),Math.abs(le))}var $g,Gg,kD,RD,Wg=C(()=>{$r();$g=xE;Gg=wE;kD=Ka,RD=EE});var Rt={};mi(Rt,{add:()=>ME,ceil:()=>ID,clone:()=>PE,copy:()=>TE,create:()=>SE,cross:()=>$D,dist:()=>XD,distance:()=>BE,div:()=>ZD,divide:()=>RE,dot:()=>DE,equals:()=>HD,exactEquals:()=>FE,floor:()=>BD,forEach:()=>e4,fromValues:()=>CE,inverse:()=>UD,len:()=>QD,length:()=>jg,lerp:()=>NE,max:()=>DD,min:()=>OD,mul:()=>qD,multiply:()=>kE,negate:()=>zD,normalize:()=>Yg,random:()=>GD,round:()=>ND,scale:()=>IE,scaleAndAdd:()=>FD,set:()=>LE,sqrDist:()=>KD,sqrLen:()=>JD,squaredDistance:()=>OE,squaredLength:()=>Hg,str:()=>jD,sub:()=>YD,subtract:()=>AE,transformMat4:()=>qg,transformQuat:()=>VD,zero:()=>WD});function SE(){let n=new we(4);return we!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0,n[3]=0),n}function PE(n){let e=new we(4);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e}function CE(n,e,t,i){let r=new we(4);return r[0]=n,r[1]=e,r[2]=t,r[3]=i,r}function TE(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n}function LE(n,e,t,i,r){return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n}function ME(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n[3]=e[3]+t[3],n}function AE(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n[3]=e[3]-t[3],n}function kE(n,e,t){return n[0]=e[0]*t[0],n[1]=e[1]*t[1],n[2]=e[2]*t[2],n[3]=e[3]*t[3],n}function RE(n,e,t){return n[0]=e[0]/t[0],n[1]=e[1]/t[1],n[2]=e[2]/t[2],n[3]=e[3]/t[3],n}function ID(n,e){return n[0]=Math.ceil(e[0]),n[1]=Math.ceil(e[1]),n[2]=Math.ceil(e[2]),n[3]=Math.ceil(e[3]),n}function BD(n,e){return n[0]=Math.floor(e[0]),n[1]=Math.floor(e[1]),n[2]=Math.floor(e[2]),n[3]=Math.floor(e[3]),n}function OD(n,e,t){return n[0]=Math.min(e[0],t[0]),n[1]=Math.min(e[1],t[1]),n[2]=Math.min(e[2],t[2]),n[3]=Math.min(e[3],t[3]),n}function DD(n,e,t){return n[0]=Math.max(e[0],t[0]),n[1]=Math.max(e[1],t[1]),n[2]=Math.max(e[2],t[2]),n[3]=Math.max(e[3],t[3]),n}function ND(n,e){return n[0]=Kt(e[0]),n[1]=Kt(e[1]),n[2]=Kt(e[2]),n[3]=Kt(e[3]),n}function IE(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n[3]=e[3]*t,n}function FD(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n[2]=e[2]+t[2]*i,n[3]=e[3]+t[3]*i,n}function BE(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2],s=e[3]-n[3];return Math.sqrt(t*t+i*i+r*r+s*s)}function OE(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2],s=e[3]-n[3];return t*t+i*i+r*r+s*s}function jg(n){let e=n[0],t=n[1],i=n[2],r=n[3];return Math.sqrt(e*e+t*t+i*i+r*r)}function Hg(n){let e=n[0],t=n[1],i=n[2],r=n[3];return e*e+t*t+i*i+r*r}function zD(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n[3]=-e[3],n}function UD(n,e){return n[0]=1/e[0],n[1]=1/e[1],n[2]=1/e[2],n[3]=1/e[3],n}function Yg(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],o=t*t+i*i+r*r+s*s;return o>0&&(o=1/Math.sqrt(o)),n[0]=t*o,n[1]=i*o,n[2]=r*o,n[3]=s*o,n}function DE(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]+n[3]*e[3]}function $D(n,e,t,i){let r=t[0]*i[1]-t[1]*i[0],s=t[0]*i[2]-t[2]*i[0],o=t[0]*i[3]-t[3]*i[0],a=t[1]*i[2]-t[2]*i[1],c=t[1]*i[3]-t[3]*i[1],l=t[2]*i[3]-t[3]*i[2],u=e[0],f=e[1],d=e[2],h=e[3];return n[0]=f*l-d*c+h*a,n[1]=-(u*l)+d*o-h*s,n[2]=u*c-f*o+h*r,n[3]=-(u*a)+f*s-d*r,n}function NE(n,e,t,i){let r=e[0],s=e[1],o=e[2],a=e[3];return n[0]=r+i*(t[0]-r),n[1]=s+i*(t[1]-s),n[2]=o+i*(t[2]-o),n[3]=a+i*(t[3]-a),n}function GD(n,e){e=e===void 0?1:e;let t,i,r,s,o,a;do t=Gn()*2-1,i=Gn()*2-1,o=t*t+i*i;while(o>=1);do r=Gn()*2-1,s=Gn()*2-1,a=r*r+s*s;while(a>=1);let c=Math.sqrt((1-o)/a);return n[0]=e*t,n[1]=e*i,n[2]=e*r*c,n[3]=e*s*c,n}function qg(n,e,t){let i=e[0],r=e[1],s=e[2],o=e[3];return n[0]=t[0]*i+t[4]*r+t[8]*s+t[12]*o,n[1]=t[1]*i+t[5]*r+t[9]*s+t[13]*o,n[2]=t[2]*i+t[6]*r+t[10]*s+t[14]*o,n[3]=t[3]*i+t[7]*r+t[11]*s+t[15]*o,n}function VD(n,e,t){let i=e[0],r=e[1],s=e[2],o=t[0],a=t[1],c=t[2],l=t[3],u=l*i+a*s-c*r,f=l*r+c*i-o*s,d=l*s+o*r-a*i,h=-o*i-a*r-c*s;return n[0]=u*l+h*-o+f*-c-d*-a,n[1]=f*l+h*-a+d*-o-u*-c,n[2]=d*l+h*-c+u*-a-f*-o,n[3]=e[3],n}function WD(n){return n[0]=0,n[1]=0,n[2]=0,n[3]=0,n}function jD(n){return`vec4(${n[0]}, ${n[1]}, ${n[2]}, ${n[3]})`}function FE(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]&&n[3]===e[3]}function HD(n,e){let t=n[0],i=n[1],r=n[2],s=n[3],o=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(t-o)<=1e-6*Math.max(1,Math.abs(t),Math.abs(o))&&Math.abs(i-a)<=1e-6*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(r-c)<=1e-6*Math.max(1,Math.abs(r),Math.abs(c))&&Math.abs(s-l)<=1e-6*Math.max(1,Math.abs(s),Math.abs(l))}var YD,qD,ZD,XD,KD,QD,JD,e4,sf=C(()=>{$r();YD=AE,qD=kE,ZD=RE,XD=BE,KD=OE,QD=jg,JD=Hg,e4=function(){let n=SE();return function(e,t,i,r,s,o){let a,c;for(t||(t=4),i||(i=0),r?c=Math.min(r*t+i,e.length):c=e.length,a=i;aMath.PI*2)throw Error("expected radians")}function o4(n,e,t,i,r,s){let o=2*s/(t-e),a=2*s/(r-i),c=(t+e)/(t-e),l=(r+i)/(r-i),u=-1,f=-1,d=-2*s;return n[0]=o,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=a,n[6]=0,n[7]=0,n[8]=c,n[9]=l,n[10]=u,n[11]=f,n[12]=0,n[13]=0,n[14]=d,n[15]=0,n}var Kg,t4,n4,Zg,Xg,i4,ze,of,af,UE=C(()=>{mE();Ya();bg();Wg();yg();Xa();sf();(function(n){n[n.COL0ROW0=0]="COL0ROW0",n[n.COL0ROW1=1]="COL0ROW1",n[n.COL0ROW2=2]="COL0ROW2",n[n.COL0ROW3=3]="COL0ROW3",n[n.COL1ROW0=4]="COL1ROW0",n[n.COL1ROW1=5]="COL1ROW1",n[n.COL1ROW2=6]="COL1ROW2",n[n.COL1ROW3=7]="COL1ROW3",n[n.COL2ROW0=8]="COL2ROW0",n[n.COL2ROW1=9]="COL2ROW1",n[n.COL2ROW2=10]="COL2ROW2",n[n.COL2ROW3=11]="COL2ROW3",n[n.COL3ROW0=12]="COL3ROW0",n[n.COL3ROW1=13]="COL3ROW1",n[n.COL3ROW2=14]="COL3ROW2",n[n.COL3ROW3=15]="COL3ROW3"})(Kg||(Kg={}));t4=45*Math.PI/180,n4=1,Zg=.1,Xg=500,i4=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),ze=class extends rf{static get IDENTITY(){return s4()}static get ZERO(){return r4()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Kg}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,i,r,s,o,a,c,l,u,f,d,h,p,m,g){return this[0]=e,this[1]=t,this[2]=i,this[3]=r,this[4]=s,this[5]=o,this[6]=a,this[7]=c,this[8]=l,this[9]=u,this[10]=f,this[11]=d,this[12]=h,this[13]=p,this[14]=m,this[15]=g,this.check()}setRowMajor(e,t,i,r,s,o,a,c,l,u,f,d,h,p,m,g){return this[0]=e,this[1]=s,this[2]=l,this[3]=h,this[4]=t,this[5]=o,this[6]=u,this[7]=p,this[8]=i,this[9]=a,this[10]=f,this[11]=m,this[12]=r,this[13]=c,this[14]=d,this[15]=g,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(i4)}fromObject(e){return this.check()}fromQuaternion(e){return zg(this,e),this.check()}frustum(e){let{left:t,right:i,bottom:r,top:s,near:o=Zg,far:a=Xg}=e;return a===1/0?o4(this,t,i,r,s,o):Ug(this,t,i,r,s,o,a),this.check()}lookAt(e){let{eye:t,center:i=[0,0,0],up:r=[0,1,0]}=e;return Vg(this,t,i,r),this.check()}ortho(e){let{left:t,right:i,bottom:r,top:s,near:o=Zg,far:a=Xg}=e;return Gg(this,t,i,r,s,o,a),this.check()}orthographic(e){let{fovy:t=t4,aspect:i=n4,focalDistance:r=1,near:s=Zg,far:o=Xg}=e;zE(t);let a=t/2,c=r*Math.tan(a),l=c*i;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:s,far:o})}perspective(e){let{fovy:t=45*Math.PI/180,aspect:i=1,near:r=.1,far:s=500}=e;return zE(t),$g(this,t,i,r,s),this.check()}determinant(){return Rg(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let i=this.getScale(t),r=1/i[0],s=1/i[1],o=1/i[2];return e[0]=this[0]*r,e[1]=this[1]*s,e[2]=this[2]*o,e[3]=0,e[4]=this[4]*r,e[5]=this[5]*s,e[6]=this[6]*o,e[7]=0,e[8]=this[8]*r,e[9]=this[9]*s,e[10]=this[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let i=this.getScale(t),r=1/i[0],s=1/i[1],o=1/i[2];return e[0]=this[0]*r,e[1]=this[1]*s,e[2]=this[2]*o,e[3]=this[4]*r,e[4]=this[5]*s,e[5]=this[6]*o,e[6]=this[8]*r,e[7]=this[9]*s,e[8]=this[10]*o,e}transpose(){return Ag(this,this),this.check()}invert(){return kg(this,this),this.check()}multiplyLeft(e){return Ka(this,e,this),this.check()}multiplyRight(e){return Ka(this,this,e),this.check()}rotateX(e){return Dg(this,this,e),this.check()}rotateY(e){return Ng(this,this,e),this.check()}rotateZ(e){return Fg(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return Og(this,this,e,t),this.check()}scale(e){return Bg(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return Ig(this,this,e),this.check()}transform(e,t){return e.length===4?(t=qg(t||[-0,-0,-0,-0],e,this),Ku(t,4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){let{length:i}=e,r;switch(i){case 2:r=_g(t||[-0,-0],e,this);break;case 3:r=Za(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Ku(r,e.length),r}transformAsVector(e,t){let i;switch(e.length){case 2:i=sE(t||[-0,-0],e,this);break;case 3:i=Ju(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Ku(i,e.length),i}transformPoint(e,t){return this.transformAsPoint(e,t)}transformVector(e,t){return this.transformAsPoint(e,t)}transformDirection(e,t){return this.transformAsVector(e,t)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,i){return this.identity().translate([e,t,i])}}});function $E(){let n=new we(4);return we!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n[3]=1,n}function a4(n,e,t){t=t*.5;let i=Math.sin(t);return n[0]=i*e[0],n[1]=i*e[1],n[2]=i*e[2],n[3]=Math.cos(t),n}function Qg(n,e,t,i){let r=e[0],s=e[1],o=e[2],a=e[3],c=t[0],l=t[1],u=t[2],f=t[3],d,h,p,m,g;return d=r*c+s*l+o*u+a*f,d<0&&(d=-d,c=-c,l=-l,u=-u,f=-f),1-d>1e-6?(h=Math.acos(d),g=Math.sin(h),p=Math.sin((1-i)*h)/g,m=Math.sin(i*h)/g):(p=1-i,m=i),n[0]=p*r+m*c,n[1]=p*s+m*l,n[2]=p*o+m*u,n[3]=p*a+m*f,n}function c4(n,e){let t=e[0]+e[4]+e[8],i;if(t>0)i=Math.sqrt(t+1),n[3]=.5*i,i=.5/i,n[0]=(e[5]-e[7])*i,n[1]=(e[6]-e[2])*i,n[2]=(e[1]-e[3])*i;else{let r=0;e[4]>e[0]&&(r=1),e[8]>e[r*3+r]&&(r=2);let s=(r+1)%3,o=(r+2)%3;i=Math.sqrt(e[r*3+r]-e[s*3+s]-e[o*3+o]+1),n[r]=.5*i,i=.5/i,n[3]=(e[s*3+o]-e[o*3+s])*i,n[s]=(e[s*3+r]+e[r*3+s])*i,n[o]=(e[o*3+r]+e[r*3+o])*i}return n}var GE,IK,BK,OK,VE=C(()=>{$r();Mg();Xa();sf();GE=Yg,IK=function(){let n=ef(),e=tf(1,0,0),t=tf(0,1,0);return function(i,r,s){let o=qa(r,s);return o<-.999999?(Gr(n,e,r),Tg(n)<1e-6&&Gr(n,t,r),vg(n,n),a4(i,n,Math.PI),i):o>.999999?(i[0]=0,i[1]=0,i[2]=0,i[3]=1,i):(Gr(n,r,s),i[0]=n[0],i[1]=n[1],i[2]=n[2],i[3]=1+o,GE(i,i))}}(),BK=function(){let n=$E(),e=$E();return function(t,i,r,s,o,a){return Qg(n,i,o,a),Qg(e,r,s,a),Qg(t,n,e,2*a*(1-a)),t}}(),OK=function(){let n=gE();return function(e,t,i,r){return n[0]=i[0],n[3]=i[1],n[6]=i[2],n[1]=r[0],n[4]=r[1],n[7]=r[2],n[2]=-t[0],n[5]=-t[1],n[8]=-t[2],GE(e,c4(e,n))}}()});var DK,NK,FK,zK,WE=C(()=>{DK=Math.PI/2,NK=Math.PI/4,FK=Math.PI/6,zK=Math.PI*2});var Ue=C(()=>{pE();UE();WE();Ks();Mg();Wg();VE();yg();Xa();sf()});function Jg(n,e=[],t=0){let i=Math.fround(n),r=n-i;return e[t]=i,e[t+1]=r,e}function jE(n){return n-Math.fround(n)}function HE(n){let e=new Float32Array(32);for(let t=0;t<4;++t)for(let i=0;i<4;++i){let r=t*4+i;Jg(n[i*4+t],e,r*2)}return e}var YE=C(()=>{});function cf(n,e=!0){return n??e}function e_(n=[0,0,0],e=!0){return e?n.map(t=>t/255):[...n]}function qE(n,e=!0){let t=e_(n.slice(0,3),e),i=Number.isFinite(n[3]),r=i?n[3]:1;return[t[0],t[1],t[2],e&&i?r/255:r]}var t_=C(()=>{});var f4,d4,Vr,ZE=C(()=>{f4=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND // All these functions are for substituting tan() function from Intel GPU only const float TWO_PI = 6.2831854820251465; @@ -277,7 +277,7 @@ float tan_fp32(float a) { return tan(a); #endif } -`,l4=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND +`,d4=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND const FP32_TWO_PI: f32 = 6.2831854820251465; const FP32_PI_2: f32 = 1.5707963705062866; const FP32_PI_16: f32 = 0.1963495463132858; @@ -398,7 +398,7 @@ fn tan_fp32(a: f32) -> f32 { return tan(a); } #endif -`,Vr={name:"fp32",source:l4,vs:c4}});var n_,XE=C(()=>{n_=` +`,Vr={name:"fp32",source:d4,vs:f4}});var n_,XE=C(()=>{n_=` layout(std140) uniform fp64arithmeticUniforms { uniform float ONE; uniform float SPLIT; @@ -1946,7 +1946,7 @@ fn compare_fp64(a: vec2f, b: vec2f) -> i32 { return fp64_compare_f32_bits(aLowBits, bLowBits); } #endif -`});var u4,i_,tS=C(()=>{YE();XE();eS();u4={ONE:1,SPLIT:4097},i_={name:"fp64arithmetic",source:JE,fs:n_,vs:n_,defaultUniforms:u4,uniformTypes:{ONE:"f32",SPLIT:"f32"},fp64ify:Jg,fp64LowPart:jE,fp64ifyMatrix4:HE}});function iS(n){return`layout(std140) uniform ${n}Uniforms { +`});var h4,i_,tS=C(()=>{YE();XE();eS();h4={ONE:1,SPLIT:4097},i_={name:"fp64arithmetic",source:JE,fs:n_,vs:n_,defaultUniforms:h4,uniformTypes:{ONE:"f32",SPLIT:"f32"},fp64ify:Jg,fp64LowPart:jE,fp64ifyMatrix4:HE}});function iS(n){return`layout(std140) uniform ${n}Uniforms { float useByteColors; } ${n}; @@ -2006,7 +2006,7 @@ fn ${n}_premultiply_alpha(inputColor: vec4) -> vec4 { fn ${n}_unpremultiply_alpha(inputColor: vec4) -> vec4 { return ${n}_unpremultiplyAlpha(inputColor); } -`}var xi,f4,d4,fQ,dQ,h4,p4,hQ,pQ,nS,mQ,m4,gQ,sS,oS=C(()=>{xi={RGBA8UNORM:0,RGBA16FLOAT:1,RGBA32FLOAT:2},f4={rgba8unorm:4,rgba16float:8,rgba32float:16},d4={...f4},fQ={rgba8unorm:xi.RGBA8UNORM,rgba16float:xi.RGBA16FLOAT,rgba32float:xi.RGBA32FLOAT},dQ={[xi.RGBA8UNORM]:"rgba8unorm",[xi.RGBA16FLOAT]:"rgba16float",[xi.RGBA32FLOAT]:"rgba32float"},h4={useByteColors:"f32"},p4={useByteColors:!0},hQ={format:xi.RGBA8UNORM,wordStride:d4.rgba8unorm/Uint32Array.BYTES_PER_ELEMENT,wordOffset:0,_padding:0},pQ=iS("colors"),nS=iS("floatColors"),mQ=rS("colors"),m4=rS("floatColors"),gQ=`struct storageColorsUniforms { +`}var xi,p4,m4,mQ,gQ,g4,_4,_Q,yQ,nS,bQ,y4,vQ,sS,oS=C(()=>{xi={RGBA8UNORM:0,RGBA16FLOAT:1,RGBA32FLOAT:2},p4={rgba8unorm:4,rgba16float:8,rgba32float:16},m4={...p4},mQ={rgba8unorm:xi.RGBA8UNORM,rgba16float:xi.RGBA16FLOAT,rgba32float:xi.RGBA32FLOAT},gQ={[xi.RGBA8UNORM]:"rgba8unorm",[xi.RGBA16FLOAT]:"rgba16float",[xi.RGBA32FLOAT]:"rgba32float"},g4={useByteColors:"f32"},_4={useByteColors:!0},_Q={format:xi.RGBA8UNORM,wordStride:m4.rgba8unorm/Uint32Array.BYTES_PER_ELEMENT,wordOffset:0,_padding:0},yQ=iS("colors"),nS=iS("floatColors"),bQ=rS("colors"),y4=rS("floatColors"),vQ=`struct storageColorsUniforms { format: u32, wordStride: u32, wordOffset: u32, @@ -2052,7 +2052,7 @@ fn storageColors_readColor(rowIndex: u32) -> vec4 { } return storageColors_readRgba32FloatColor(wordIndex); } -`;sS={name:"floatColors",props:{},uniforms:{},vs:nS,fs:nS,source:m4,uniformTypes:h4,defaultUniforms:p4}});function b4(n={},e){let t={},i=cf(n.useByteColors,!0);if(n.highlightedObjectColor!==void 0)if(n.highlightedObjectColor===null)t.isHighlightActive=!1;else{t.isHighlightActive=!0;let r=n.highlightedObjectColor.slice(0,3);t.highlightedObjectColor=r}return n.highlightColor&&(t.highlightColor=qE(n.highlightColor,i)),n.isActive!==void 0&&(t.isActive=!!n.isActive,t.isAttribute=!!n.isAttribute),n.useByteColors!==void 0&&(t.useByteColors=!!n.useByteColors),t}var g4,_4,y4,Zi,aS=C(()=>{t_();g4=[0,1,1,1],_4=`layout(std140) uniform pickingUniforms { +`;sS={name:"floatColors",props:{},uniforms:{},vs:nS,fs:nS,source:y4,uniformTypes:g4,defaultUniforms:_4}});function w4(n={},e){let t={},i=cf(n.useByteColors,!0);if(n.highlightedObjectColor!==void 0)if(n.highlightedObjectColor===null)t.isHighlightActive=!1;else{t.isHighlightActive=!0;let r=n.highlightedObjectColor.slice(0,3);t.highlightedObjectColor=r}return n.highlightColor&&(t.highlightColor=qE(n.highlightColor,i)),n.isActive!==void 0&&(t.isActive=!!n.isActive,t.isAttribute=!!n.isAttribute),n.useByteColors!==void 0&&(t.useByteColors=!!n.useByteColors),t}var b4,v4,x4,Zi,aS=C(()=>{t_();b4=[0,1,1,1],v4=`layout(std140) uniform pickingUniforms { float isActive; float isAttribute; float isHighlightActive; @@ -2123,7 +2123,7 @@ void picking_setPickingAttribute(vec3 value) { picking_vRGBcolor_Avalid.rgb = value; } } -`,y4=`layout(std140) uniform pickingUniforms { +`,x4=`layout(std140) uniform pickingUniforms { float isActive; float isAttribute; float isHighlightActive; @@ -2179,7 +2179,7 @@ vec4 picking_filterColor(vec4 color) { vec4 highlightColor = picking_filterHighlightColor(color); return picking_filterPickingColor(highlightColor); } -`,Zi={props:{},uniforms:{},name:"picking",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useByteColors:"f32",highlightedObjectColor:"vec3",highlightColor:"vec4"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useByteColors:!0,highlightedObjectColor:[0,0,0],highlightColor:g4},vs:_4,fs:y4,getUniforms:b4}});var r_,cS=C(()=>{r_=`precision highp int; +`,Zi={props:{},uniforms:{},name:"picking",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useByteColors:"f32",highlightedObjectColor:"vec3",highlightColor:"vec4"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useByteColors:!0,highlightedObjectColor:[0,0,0],highlightColor:b4},vs:v4,fs:x4,getUniforms:w4}});var r_,cS=C(()=>{r_=`precision highp int; // #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) struct AmbientLight { @@ -2338,7 +2338,7 @@ fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3) ); return distanceAttenuation / max(coneFactor, 0.0001); } -`});function x4(n,e={}){if(n=n&&{...n},!n)return uf();n.lights&&(n={...n,...E4(n.lights),lights:void 0});let{useByteColors:t,ambientLight:i,pointLights:r,spotLights:s,directionalLights:o}=n||{};if(!(i||r&&r.length>0||s&&s.length>0||o&&o.length>0))return{...uf(),enabled:0};let c={...uf(),...w4({useByteColors:t,ambientLight:i,pointLights:r,spotLights:s,directionalLights:o})};return n.enabled!==void 0&&(c.enabled=n.enabled?1:0),c}function w4({useByteColors:n,ambientLight:e,pointLights:t=[],spotLights:i=[],directionalLights:r=[]}){let s=dS(),o=0,a=0,c=0,l=0;for(let u of t){if(o>=Wr)break;s[o]={...s[o],color:lf(u,n),position:u.position,attenuation:u.attenuation||[1,0,0]},o++,a++}for(let u of i){if(o>=Wr)break;s[o]={...s[o],color:lf(u,n),position:u.position,direction:u.direction,attenuation:u.attenuation||[1,0,0],coneCos:P4(u)},o++,c++}for(let u of r){if(o>=Wr)break;s[o]={...s[o],color:lf(u,n),direction:u.direction},o++,l++}return t.length+i.length+r.length>Wr&&N.warn(`MAX_LIGHTS exceeded, truncating to ${Wr}`)(),{ambientColor:lf(e,n),directionalLightCount:l,pointLightCount:a,spotLightCount:c,lights:s}}function E4(n){let e={pointLights:[],spotLights:[],directionalLights:[]};for(let t of n||[])switch(t.type){case"ambient":e.ambientLight=t;break;case"directional":e.directionalLights?.push(t);break;case"point":e.pointLights?.push(t);break;case"spot":e.spotLights?.push(t);break;default:}return e}function lf(n={},e){let{color:t=[0,0,0],intensity:i=1}=n;return e_(t,cf(e,!0)).map(s=>s*i)}function uf(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:dS()}}function dS(){return Array.from({length:Wr},()=>S4())}function S4(){return{color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}}function P4(n){let e=n.innerConeAngle??0,t=n.outerConeAngle??Math.PI/4;return[Math.cos(e),Math.cos(t)]}var Wr,v4,fS,hS=C(()=>{J();cS();uS();t_();Wr=5,v4={color:"vec3",position:"vec3",direction:"vec3",attenuation:"vec3",coneCos:"vec2"},fS={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",directionalLightCount:"i32",pointLightCount:"i32",spotLightCount:"i32",ambientColor:"vec3",lights:[v4,Wr]},defaultUniforms:uf(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:lS,vs:r_,fs:r_,getUniforms:x4}});var pS,mS,gS=C(()=>{pS=`layout(std140) uniform phongMaterialUniforms { +`});function S4(n,e={}){if(n=n&&{...n},!n)return uf();n.lights&&(n={...n,...C4(n.lights),lights:void 0});let{useByteColors:t,ambientLight:i,pointLights:r,spotLights:s,directionalLights:o}=n||{};if(!(i||r&&r.length>0||s&&s.length>0||o&&o.length>0))return{...uf(),enabled:0};let c={...uf(),...P4({useByteColors:t,ambientLight:i,pointLights:r,spotLights:s,directionalLights:o})};return n.enabled!==void 0&&(c.enabled=n.enabled?1:0),c}function P4({useByteColors:n,ambientLight:e,pointLights:t=[],spotLights:i=[],directionalLights:r=[]}){let s=dS(),o=0,a=0,c=0,l=0;for(let u of t){if(o>=Wr)break;s[o]={...s[o],color:lf(u,n),position:u.position,attenuation:u.attenuation||[1,0,0]},o++,a++}for(let u of i){if(o>=Wr)break;s[o]={...s[o],color:lf(u,n),position:u.position,direction:u.direction,attenuation:u.attenuation||[1,0,0],coneCos:L4(u)},o++,c++}for(let u of r){if(o>=Wr)break;s[o]={...s[o],color:lf(u,n),direction:u.direction},o++,l++}return t.length+i.length+r.length>Wr&&N.warn(`MAX_LIGHTS exceeded, truncating to ${Wr}`)(),{ambientColor:lf(e,n),directionalLightCount:l,pointLightCount:a,spotLightCount:c,lights:s}}function C4(n){let e={pointLights:[],spotLights:[],directionalLights:[]};for(let t of n||[])switch(t.type){case"ambient":e.ambientLight=t;break;case"directional":e.directionalLights?.push(t);break;case"point":e.pointLights?.push(t);break;case"spot":e.spotLights?.push(t);break;default:}return e}function lf(n={},e){let{color:t=[0,0,0],intensity:i=1}=n;return e_(t,cf(e,!0)).map(s=>s*i)}function uf(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:dS()}}function dS(){return Array.from({length:Wr},()=>T4())}function T4(){return{color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}}function L4(n){let e=n.innerConeAngle??0,t=n.outerConeAngle??Math.PI/4;return[Math.cos(e),Math.cos(t)]}var Wr,E4,fS,hS=C(()=>{J();cS();uS();t_();Wr=5,E4={color:"vec3",position:"vec3",direction:"vec3",attenuation:"vec3",coneCos:"vec2"},fS={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",directionalLightCount:"i32",pointLightCount:"i32",spotLightCount:"i32",ambientColor:"vec3",lights:[E4,Wr]},defaultUniforms:uf(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:lS,vs:r_,fs:r_,getUniforms:S4}});var pS,mS,gS=C(()=>{pS=`layout(std140) uniform phongMaterialUniforms { uniform bool unlit; uniform float ambient; uniform float diffuse; @@ -2525,9 +2525,9 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3, position_worldspace } return lightColor; } -`});var C4,eo,bS=C(()=>{oS();hS();gS();yS();C4=[38.25,38.25,38.25],eo={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:mS.replace("phongMaterial","gouraudMaterial"),fs:pS.replace("phongMaterial","gouraudMaterial"),source:_S.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[fS,sS],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:C4},getUniforms(n){return{...eo.defaultUniforms,...n}}}});var vt=C(()=>{_m();dw();ng();Hw();qw();ZE();tS();aS();bS()});function Zn(n="id"){T_[n]=T_[n]||1;let e=T_[n]++;return`${n}-${e}`}var T_,_o=C(()=>{T_={}});function Kr(n){switch(n){case"POSITION":return"positions";case"NORMAL":return"normals";case"TEXCOORD_0":return"texCoords";case"TEXCOORD_1":return"texCoords1";case"COLOR_0":return"colors";default:return n}}function wF(n){let e=[];for(let[t,i]of Object.entries(n)){if(!i)continue;let{value:r,size:s,normalized:o}=i;if(s===void 0)throw new Error(`Attribute ${t} is missing a size`);e.push({name:Kr(t),format:Pe.getVertexFormatFromAttribute(r,s,o)})}return e}var tn,Rf=C(()=>{J();_o();tn=class{id;topology;vertexCount;indices;attributes;bufferLayout;userData={};constructor(e){let{attributes:t={},indices:i=null,vertexCount:r=null}=e;this.id=e.id||Zn("geometry"),this.topology=e.topology,i&&(this.indices=ArrayBuffer.isView(i)?{value:i,size:1}:i),this.attributes={};for(let[s,o]of Object.entries(t)){let a=ArrayBuffer.isView(o)?{value:o}:o;if(!ArrayBuffer.isView(a.value))throw new Error(`${this._print(s)}: must be typed array or object with value as typed array`);if((s==="POSITION"||s==="positions")&&!a.size&&(a.size=3),s==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=a}else{let c=Kr(s),l=Object.keys(this.attributes).find(u=>Kr(u)===c);l&&delete this.attributes[l],this.attributes[s]=a}}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=r||this._calculateVertexCount(this.attributes,this.indices),this.bufferLayout=e.bufferLayout||wF(this.attributes)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,t){return this}_calculateVertexCount(e,t){if(t)return t.value.length;let i=1/0;for(let r of Object.values(e)){if(!r)continue;let{value:s,size:o,constant:a}=r;!a&&s&&o!==void 0&&o>=1&&(i=Math.min(i,s.length/o))}return i}}});function p1(n,e={}){let t=e.bufferName||"geometry";if(EF(n,t))return n;let i=e.minAttributeAlignment||4,r=SF(n,e.attributes),s=[],o=0,a=1/0;for(let[u,f]of r){if(!f)continue;if(f.constant)throw new Error(`Attribute ${u} is constant`);let{value:d,size:h,normalized:p}=f;if(!ArrayBuffer.isView(d))throw new Error(`Attribute ${u} is missing typed array data`);if(h===void 0)throw new Error(`Attribute ${u} is missing a size`);let m=Pe.getVertexFormatFromAttribute(d,h,p),g=Pe.getVertexFormatInfo(m);o=h1(o,i),s.push({sourceName:u,attributeName:Kr(u),value:d,size:h,format:m,byteOffset:o,byteLength:g.byteLength}),o+=g.byteLength;let v=d.length/h;if(!Number.isInteger(v))throw new Error(`Attribute ${u} length is not divisible by size`);a=Math.min(a,v)}if(s.length===0||!Number.isFinite(a))throw new Error(`Geometry ${n.id} has no interleavable attributes`);let c=h1(o,i),l=new ArrayBuffer(a*c);for(let u of s)PF(l,a,c,u);return new tn({id:n.id,topology:n.topology||"triangle-list",vertexCount:n.vertexCount,indices:n.indices,attributes:{[t]:{value:new Uint8Array(l),size:c,byteStride:c}},bufferLayout:[{name:t,stepMode:"vertex",byteStride:c,attributes:s.map(u=>({attribute:u.attributeName,format:u.format,byteOffset:u.byteOffset}))}]})}function EF(n,e){if(n.bufferLayout.length!==1)return!1;let t=n.bufferLayout[0];return t.name===e&&!!t.attributes?.length&&!!n.attributes[e]}function SF(n,e){return e?e.map(t=>[t,n.attributes[t]]):Object.entries(n.attributes)}function PF(n,e,t,i){let r=i.value.constructor,s=r.BYTES_PER_ELEMENT;if(i.byteOffset%s!==0||t%s!==0)throw new Error(`Attribute ${i.sourceName} is not aligned to its component type`);let o=new r(n),a=i.value,c=i.byteOffset/s,l=t/s;for(let u=0;u{J();Rf()});var CF,TF,Qr,g1=C(()=>{CF=1,TF=1,Qr=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){let{delay:t=0,duration:i=Number.POSITIVE_INFINITY,rate:r=1,repeat:s=1}=e,o=CF++,a={time:0,delay:t,duration:i,rate:r,repeat:s};return this._setChannelTime(a,this.time),this.channels.set(o,a),o}removeChannel(e){this.channels.delete(e);for(let[t,i]of this.animations)i.channel===e&&this.detachAnimation(t)}isFinished(e){let t=this.channels.get(e);return t===void 0?!1:this.time>=t.delay+t.duration*t.repeat}getTime(e){if(e===void 0)return this.time;let t=this.channels.get(e);return t===void 0?-1:t.time}setTime(e){this.time=Math.max(0,e);let t=this.channels.values();for(let r of t)this._setChannelTime(r,this.time);let i=this.animations.values();for(let r of i){let{animation:s,channel:o}=r;s.setTime(this.getTime(o))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,t){let i=TF++;return this.animations.set(i,{animation:e,channel:t}),e.setTime(this.getTime(t)),i}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,t){let i=t-e.delay,r=e.duration*e.repeat;i>=r?e.time=e.duration*e.rate:(e.time=Math.max(0,i)%e.duration,e.time*=e.rate)}}});function _1(n){let e=typeof window<"u"?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame:null;return e?e.call(window,n):setTimeout(()=>n(typeof performance<"u"?performance.now():Date.now()),1e3/60)}function y1(n){let e=typeof window<"u"?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame:null;if(e){e.call(window,n);return}clearTimeout(n)}var b1=C(()=>{});var LF,MF,v1,gc,x1=C(()=>{J();b1();ua();LF=0,MF="Animation Loop",v1={requestAnimationFrame:n=>_1(n),cancelAnimationFrame:n=>y1(n)},gc=class n{static defaultAnimationLoopProps={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>{console.error(e)},stats:void 0,autoResizeViewport:!1,animationFrameProvider:v1};device=null;canvas=null;props;animationProps=null;timeline=null;stats;sharedStats;cpuTime;gpuTime;frameRate;display;_needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;_lastFrameTime=0;constructor(e){if(this.props={...n.defaultAnimationLoopProps,...e},e=this.props,!e.device)throw new Error("No device provided");this.stats=e.stats||new Yt({id:`animation-loop-${LF++}`}),this.sharedStats=Vs.stats.get(MF),this.frameRate=this.stats.get("Frame Rate"),this.frameRate.setSampleSize(1),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.setProps({autoResizeViewport:e.autoResizeViewport,animationFrameProvider:e.animationFrameProvider}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null),this.device?._disableDebugGPUTime()}delete(){this.destroy()}reportError(e){this._error=e,this.props.onError(e),this.props.onError===n.defaultAnimationLoopProps.onError&&typeof window<"u"&&typeof ErrorEvent<"u"&&window.dispatchEvent(new ErrorEvent("error",{error:e,message:e.message}))}setNeedsRedraw(e){return this._needsRedraw=this._needsRedraw||e,this}needsRedraw(){let e=this._needsRedraw;return this._needsRedraw=!1,e}setProps(e){if("autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),"animationFrameProvider"in e){let t=e.animationFrameProvider||v1;if(t!==this.props.animationFrameProvider){let i=this._animationFrameId!==null;i&&this._cancelAnimationFrame(),this.props.animationFrameProvider=t,i&&this._requestAnimationFrame()}}return this}async start(){if(this._running)return this;this._running=!0;try{let e;if(!this._initialized){if(this._initialized=!0,await this._initDevice(),this._initialize(),!this._running)return null;await this.props.onInitialize(this._getAnimationProps())}return this._running?(e!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){let t=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(t),t}}stop(){if(this._running){let e=this.animationProps;this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1,this._lastFrameTime=0,e&&this.props.onFinalize(e)}return this}redraw(e,t=null){return this.device?.isLost||this._error?this:(this._beginFrameTimers(e),this._setupFrame(),this.animationProps&&(this.animationProps.animationFrame=t),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeViewport(),this.device?._enableDebugGPUTime()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=this.props.animationFrameProvider.requestAnimationFrame(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(this.props.animationFrameProvider.cancelAnimationFrame(this._animationFrameId),this._animationFrameId=null)}_animationFrame(e,t){if(this._running)try{this.redraw(e,t??null),this._requestAnimationFrame()}catch(i){let r=i instanceof Error?i:new Error(String(i));this.reportError(r),this.stop()}}_renderFrame(e){if(this.display){this.display._renderFrame(e);return}let t=this.props.onRender(this._getAnimationProps());this.device&&t!==!1&&this.device.submit()}_clearNeedsRedraw(){this._needsRedraw=!1}_setupFrame(){this._resizeViewport()}_initializeAnimationProps(){let e=this.device?.getDefaultCanvasContext();if(!this.device||!e)throw new Error("loop");let t=e?.canvas,i=e.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:e,canvas:t,useDevicePixels:i,timeline:this.timeline,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,animationFrame:null,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:e,height:t,aspect:i}=this._getSizeAndAspect();(e!==this.animationProps.width||t!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),i!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=t,this.animationProps.aspect=i,this.animationProps.needsRedraw=this._needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.getDefaultCanvasContext().canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";let t=document.createElement("div");t.style.position="absolute",t.style.left="10px",t.style.bottom="10px",t.style.width="300px",t.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(t);let i=this.props.onAddHTML(t);i&&(t.innerHTML=i)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[e,t]=this.device.getDefaultCanvasContext().getDrawingBufferSize(),i=e>0&&t>0?e/t:1;return{width:e,height:t,aspect:i}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(e){let t=e??(typeof performance<"u"?performance.now():Date.now());if(this._lastFrameTime){let i=t-this._lastFrameTime;i>0&&this.frameRate.addTime(i)}this._lastFrameTime=t,this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeStart()}_endFrameTimers(){this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeEnd(),this._updateSharedStats()}_consumeEncodedGpuTime(){if(!this.device)return;let e=this.device.commandEncoder._gpuTimeMs;e!==void 0&&(this.gpuTime.addTime(e),this.device.commandEncoder._gpuTimeMs=void 0)}_updateSharedStats(){if(this.stats!==this.sharedStats){for(let e of Object.keys(this.sharedStats.stats))this.stats.stats[e]||delete this.sharedStats.stats[e];this.stats.forEach(e=>{let t=this.sharedStats.get(e.name,e.type);t.sampleSize=e.sampleSize,t.time=e.time,t.count=e.count,t.samples=e.samples,t.lastTiming=e.lastTiming,t.lastSampleTime=e.lastSampleTime,t.lastSampleCount=e.lastSampleCount,t._count=e._count,t._time=e._time,t._samples=e._samples,t._startTime=e._startTime,t._timerPending=e._timerPending})}}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}}});function w1(n,e){if(e instanceof If)return e;let t=p1(e),i=AF(n,t),{attributes:r,bufferLayout:s}=kF(n,t);return new If({topology:t.topology||"triangle-list",bufferLayout:s,vertexCount:t.vertexCount,indices:i,attributes:r})}function AF(n,e){if(!e.indices)return;let t=e.indices.value;return n.createBuffer({usage:ie.INDEX,data:t})}function kF(n,e){let t={};for(let[i,r]of Object.entries(e.attributes)){let s=e.bufferLayout.find(o=>o.name===i)?.name||Kr(i);r&&(t[s]=n.createBuffer({data:r.value,id:`${i}-buffer`}))}return{attributes:t,bufferLayout:e.bufferLayout,vertexCount:e.vertexCount}}var If,E1=C(()=>{J();Rf();m1();_o();If=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){if(this.id=e.id||Zn("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&!(this.indices.usage&ie.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){this.indices?.destroy();for(let e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(e){return e.byteLength/12}}});function S1(n,e){let t={},i="Values";if(n.attributes.length===0&&!n.varyings?.length)return{"No attributes or varyings":{[i]:"N/A"}};for(let r of n.attributes)if(r){let s=`${r.location} ${r.name}: ${r.type}`;t[`in ${s}`]={[i]:r.stepMode||"vertex"}}for(let r of n.varyings||[]){let s=`${r.location} ${r.name}`;t[`out ${s}`]={[i]:JSON.stringify(r)}}return t}var P1=C(()=>{});function L1(n,e,t){if(n.device.type!=="webgl")return;let i=BF(n.device);if(!i.flushing){if(DF(n)){RF(n,t,i);return}e&&OF(e)&&e.handle!==null&&(i.queuedFramebuffers.includes(e)||i.queuedFramebuffers.push(e))}}function RF(n,e,t){if(t.queuedFramebuffers.length===0)return;let i=n.device,{gl:r}=i,s=r.getParameter(36010),o=r.getParameter(36006),[a,c]=n.device.getDefaultCanvasContext().getDrawingBufferSize(),l=T1(e.top,8),u=T1(e.left,8);t.flushing=!0;try{for(let f of t.queuedFramebuffers){let[d,h,p,m,g]=IF({framebuffer:f,targetWidth:a,targetHeight:c,topPx:l,leftPx:u,minimap:e.minimap});r.bindFramebuffer(36008,f.handle),r.bindFramebuffer(36009,null),r.blitFramebuffer(0,0,f.width,f.height,d,h,p,m,16384,9728),l+=g+8}}finally{r.bindFramebuffer(36008,s),r.bindFramebuffer(36009,o),t.flushing=!1}}function IF(n){let{framebuffer:e,targetWidth:t,targetHeight:i,topPx:r,leftPx:s,minimap:o}=n,a=o?Math.max(Math.floor(t/4),1):t,c=o?Math.max(Math.floor(i/4),1):i,l=Math.min(a/e.width,c/e.height),u=Math.max(Math.floor(e.width*l),1),f=Math.max(Math.floor(e.height*l),1),d=s,h=Math.max(i-r-f,0),p=d+u,m=h+f;return[d,h,p,m,f]}function BF(n){return n.userData[C1]||={flushing:!1,queuedFramebuffers:[]},n.userData[C1]}function OF(n){return"colorAttachments"in n}function DF(n){let e=n.props.framebuffer;return!e||e.handle===null}function T1(n,e){if(!n)return e;let t=Number.parseInt(n,10);return Number.isFinite(t)?t:e}var C1,M1=C(()=>{C1="__debugFramebufferState"});function yo(n,e,t){if(n===e)return!0;if(!t||!n||!e)return!1;if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let i=0;i{});var bo,k1=C(()=>{J();bo=class{bufferLayouts;constructor(e){this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(t=>t.name===e)||null}getAttributeNamesForBuffer(e){return qs(e)}mergeBufferLayouts(e,t){let i=[...e];for(let r of t){let s=i.findIndex(o=>o.name===r.name);s<0?i.push(r):i[s]=r}return i}}});function R1(n,e){let t=Km(n),i=e.slice();return i.sort((r,s)=>{let o=Vu(qs(r).map(c=>t[c])),a=Vu(qs(s).map(c=>t[c]));return o-a}),i}var I1=C(()=>{J()});function vo(n,e){if(!n||!e.some(i=>i.bindingLayout?.length))return n;let t={...n,bindings:n.bindings.map(i=>({...i}))};"attributes"in(n||{})&&(t.attributes=n?.attributes||[]);for(let i of e)for(let r of i.bindingLayout||[])for(let s of NF(r.name)){let o=t.bindings.find(a=>a.name===s);o?.group===0&&(o.group=r.group),o&&r.visibility!==void 0&&(o.visibility=r.visibility)}return t}function B1(n,e,t=[]){return n?e?{...n,attributes:n.attributes.length?UF(n.attributes,e.attributes.filter(i=>t.includes(i.name))):e.attributes,bindings:zF(n.bindings,e.bindings)}:n:e}function _c(n){return!!(n.uniformTypes&&!FF(n.uniformTypes))}function O1(n){let e=[];for(let t of n){let i=Wa(t),r=new Set([t.vs,t.fs].flatMap(o=>o?ja(o).filter(a=>a.isStd140).map(a=>a.blockName):[])),s=r.has(i)?i:r.size===1?r.values().next().value:void 0;_c(t)&&s&&e.push({name:s,uniformTypes:t.uniformTypes})}return e}function Bf(n,e){let t=[],i=new Set;for(let r of[...n||[],...e||[]])i.has(r.name)||(i.add(r.name),t.push(r));return t}function NF(n){let e=new Set([n,`${n}Uniforms`]);return n.endsWith("Uniforms")||e.add(`${n}Sampler`),[...e]}function FF(n){for(let e in n)return!1;return!0}function zF(n,e){let t=n.map(s=>({...s})),i=new Set(n.map(s=>s.name)),r=new Set(n.map(s=>`${s.group}:${s.location}`));for(let s of e){let o=`${s.group}:${s.location}`;!i.has(s.name)&&!r.has(o)&&t.push({...s})}return t}function UF(n,e){let t=n.map(s=>({...s})),i=new Map(n.map(s=>[s.name,s])),r=new Map(n.map(s=>[s.location,s]));for(let s of e){let o=i.get(s.name);if(o){if(o.type!==s.type||o.location!==s.location)throw new Error(`Shader attribute "${s.name}" conflicts with its inferred type or location`);continue}let a=r.get(s.location);if(a)throw new Error(`Shader attributes "${a.name}" and "${s.name}" both use location ${s.location}`);t.push({...s})}return t}var L_=C(()=>{vt()});function $F(n){return _a(n)||typeof n=="number"||typeof n=="boolean"}function D1(n,e={}){let t={bindings:{},uniforms:{}};return Object.keys(n).forEach(i=>{let r=n[i];Object.prototype.hasOwnProperty.call(e,i)||$F(r)?t.uniforms[i]=r:t.bindings[i]=r}),t}var N1=C(()=>{Jp()});function F1(n={},e={},t={}){let i={...n};for(let[r,s]of Object.entries(e))s!==void 0&&(i[r]=M_(n[r],s,t[r]));return i}function M_(n,e,t){if(!t||typeof t=="string")return yc(e);if(Array.isArray(t)){if(A_(e)||!Array.isArray(e))return yc(e);let o=Array.isArray(n)&&!A_(n)?[...n]:[],a=o.slice();for(let c=0;ct===void 0?void 0:yc(t)):k_(n)?Object.fromEntries(Object.entries(n).map(([e,t])=>[e,t===void 0?void 0:yc(t)])):n}function A_(n){return ArrayBuffer.isView(n)||Array.isArray(n)&&(n.length===0||typeof n[0]=="number")}function k_(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&!ArrayBuffer.isView(n)}function GF(n){return!!n?.dependencies}var xo,R_=C(()=>{J();vt();N1();xo=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;directBindings={};constructor(e,t){Object.assign(this.options,t);let i=Cr(Object.values(e).filter(GF));for(let r of i)e[r.name]=r;N.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(let[r,s]of Object.entries(e))s&&(this._addModule(s),s.name&&r!==s.name&&!this.options.disableWarnings&&N.warn(`Module name: ${r} vs ${s.name}`)())}destroy(){}setProps(e){e.bindings&&Object.assign(this.directBindings,e.bindings);for(let t of Object.keys(e)){if(t==="bindings")continue;let i=t,r=e[i]||{},s=this.modules[i];if(!s)this.options.disableWarnings||N.warn(`Module ${t} not found`)();else{let o=this.moduleUniforms[i],a=this.moduleBindings[i],c=s.getUniforms?.(r,o)||r,{uniforms:l,bindings:u}=D1(c,s.uniformTypes);this.moduleUniforms[i]=F1(o,l,s.uniformTypes),this.moduleBindings[i]={...a,...u}}}}getModules(){return Object.values(this.modules)}addModules(e){let t=Cr(e);for(let i of t){let r=i.name;this.modules[r]||(this.modules[r]=i,this._addModule(i))}}getUniformValues(){return this.moduleUniforms}getBindingValues(){let e={};for(let t of Object.values(this.moduleBindings))Object.assign(e,t);return Object.assign(e,this.directBindings),e}getModuleBindingValues(e){let t=this.moduleBindings[e];return t?{...t}:{}}getDebugTable(){let e={};for(let[t,i]of Object.entries(this.moduleUniforms))for(let[r,s]of Object.entries(i))e[`${t}.${r}`]={type:this.modules[t].uniformTypes?.[r],value:String(s)};return e}_addModule(e){let t=e.name;this.moduleUniforms[t]=F1({},e.defaultUniforms||{},e.uniformTypes),this.moduleBindings[t]={}}}});function I_(n){return n!==null&&typeof n=="object"&&"buffer"in n}function WF(n){return n instanceof tt?n.buffer:n}function z1(n){return{buffer:WF(n.buffer),offset:n.offset,size:n.size}}var VF,tt,B_=C(()=>{J();_o();VF=ie.DEBUG_DATA_MAX_LENGTH,tt=class{device;id;ready;usage;props;isReady=!0;destroyed=!1;generation=0;updateTimestamp;debugData=new ArrayBuffer(0);_debugDataEnabled;_maxDebugDataByteLength;_ownsBuffer;_buffer;get buffer(){return this._buffer}get byteLength(){return this._buffer.byteLength}get[Symbol.toStringTag](){return"DynamicBuffer"}toString(){return`DynamicBuffer:"${this.id}":${this.byteLength}B`}toJSON(){return this.toString()}constructor(e,t){let{debugData:i=!1,buffer:r,ownsBuffer:s=!0,...o}=t;if(r&&r.device!==e)throw new Error("DynamicBuffer adopted buffers must belong to the supplied device");if(r&&(o.byteLength!==void 0||o.data!==void 0))throw new Error("DynamicBuffer cannot combine an adopted buffer with byteLength or data");let a=t.id||r?.id||Zn("dynamic-buffer"),c={...o,id:a,usage:o.usage??r?.usage,indexType:o.indexType??r?.indexType};(c.usage||0)&ie.INDEX&&!c.indexType&&(o.data instanceof Uint32Array?c.indexType="uint32":o.data instanceof Uint16Array?c.indexType="uint16":o.data instanceof Uint8Array&&(c.indexType="uint8")),delete c.data,delete c.byteOffset,this.device=e,this.id=a,this.props=c,this.usage=c.usage||0,this._debugDataEnabled=!!i,this._maxDebugDataByteLength=typeof i=="object"&&i.maxByteLength!==void 0?i.maxByteLength:VF,this._ownsBuffer=s,this._buffer=r??this.device.createBuffer({...o,id:a}),this.ready=Promise.resolve(this._buffer),this.updateTimestamp=this._buffer.updateTimestamp,this._resetDebugData(this._buffer.byteLength),o.data&&this._writeDebugData(o.data,o.byteOffset||0)}write(e,t=0){this._buffer.write(e,t),this._touch(),this._writeDebugData(e,t)}async mapAndWriteAsync(e,t=0,i=this.byteLength-t){let r=null;await this._buffer.mapAndWriteAsync(async(s,o)=>{await e(s,o),r=new Uint8Array(s.slice(0,i))},t,i),this._touch(),r&&this._writeDebugData(r,t)}async readAsync(e=0,t=this.byteLength-e){let i=await this._buffer.readAsync(e,t);return this._writeDebugData(i,e)&&this._touch(),i}async mapAndReadAsync(e,t=0,i=this.byteLength-t){let r=null,s=await this._buffer.mapAndReadAsync(async(o,a)=>(r=new Uint8Array(o.slice(0)),await e(o,a)),t,i);return r&&this._writeDebugData(r,t)&&this._touch(),s}resize(e){let{byteLength:t,preserveData:i=!1}=e;if(t===this.byteLength)return!1;let r=Math.min(e.copyByteLength??Math.min(this.byteLength,t),this.byteLength,t),s=this._buffer,o=this.debugData.slice(0),{data:a,byteOffset:c,...l}=this.props,u=this.device.createBuffer({...l,byteLength:t});return i&&r>0&&this._copyBufferContents(s,u,r),this._buffer=u,this._resetDebugData(t),i&&o.byteLength>0&&this._writeDebugData(o,0),this._ownsBuffer&&s.destroy(),this._ownsBuffer=!0,this.generation++,this._touch(),!0}ensureSize(e,t){return e<=this.byteLength?!1:this.resize({byteLength:e,preserveData:t?.preserveData})}getBinding(e){return e?.offset===void 0&&e?.size===void 0?this._buffer:{buffer:this._buffer,offset:e?.offset,size:e?.size}}destroy(){this.destroyed||(this._ownsBuffer&&this._buffer.destroy(),this.destroyed=!0,this.debugData=new ArrayBuffer(0))}_copyBufferContents(e,t,i){let r=this.device.type==="webgpu"?Math.ceil(i/4)*4:i,s=this.device.createCommandEncoder();s.copyBufferToBuffer({sourceBuffer:e,destinationBuffer:t,size:r}),this.device.submit(s.finish())}_touch(){this.updateTimestamp=this.device.incrementTimestamp()}_resetDebugData(e){if(!this._debugDataEnabled){this.debugData=new ArrayBuffer(0);return}this.debugData=new ArrayBuffer(Math.min(e,this._maxDebugDataByteLength))}_writeDebugData(e,t){if(!this._debugDataEnabled||this.debugData.byteLength===0||t>=this.debugData.byteLength)return!1;let i=ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),r=new Uint8Array(this.debugData),s=Math.min(i.byteLength,r.byteLength-t);return r.set(i.subarray(0,s),t),s>0}}});function bc(n){return n!==null&&typeof n=="object"&&"resolveTextureBinding"in n&&typeof n.resolveTextureBinding=="function"}function jF(n){return n?.type==="texture"||n?.type==="external-texture"}function U1(n,e,t){let i=Nu(n,e,{ignoreWarnings:!0});return jF(i)?i:n.bindings.length===0&&t?.fallbackGroup!==void 0?{type:"texture",name:e,group:t.fallbackGroup,location:0}:null}var $1=C(()=>{J()});function D_(n,e){return n.shaderLanguage!==void 0&&n.shaderLanguage!==e?!1:e==="glsl"?"assembleGLSLShaderPair"in n&&typeof n.assembleGLSLShaderPair=="function":"assembleWGSLShader"in n&&typeof n.assembleWGSLShader=="function"}function qF(n,e){return!n||Object.keys(e).length===0?n:{...n,attributes:n.attributes.map(t=>{let i=t.name.startsWith("_luma_")?t.name.slice(6):null;return i&&e[i]?{...t,name:i}:t})}}function ZF(n,e,t){if(bc(e)){let i=U1(t,n,{fallbackGroup:0});return i?e.resolveTextureBinding(i):null}return e instanceof tt?e.buffer:I_(e)?z1(e):e}function XF(n){return n&&!G1(n)?n:null}function KF(n){return n&&G1(n)?n:void 0}function G1(n){return YF.includes(n)}function QF(n){return{type:n.type,shaderLanguage:n.info.shadingLanguage,shaderLanguageVersion:n.info.shadingLanguageVersion,gpu:n.info.gpu,limits:n.limits,features:n.features}}var Xn,HF,O_,YF,Ze,N_=C(()=>{J();vt();E1();P1();M1();A1();k1();I1();L_();_o();R_();B_();$1();Xn=2,HF=1e4,O_="render pipeline initialization failed",YF=["stencil8","depth16unorm","depth24plus","depth24plus-stencil8","depth32float","depth32float-stencil8"],Ze=class n{static defaultProps={...Xt.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],plugins:[],geometry:null,indexBuffer:null,indexCount:void 0,firstVertex:0,firstIndex:0,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,material:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:Kt.getDefaultShaderAssembler("glsl"),debugShaders:void 0,disableWarnings:void 0};device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexCount;firstVertex;firstIndex;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;material=null;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_dynamicIndexBufferSource=null;_dynamicAttributeBufferSources={};_colorAttachmentFormats;_depthStencilAttachmentFormat;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_drawBlockedReason=!1;_destroyed=!1;_vertexCountSet=!1;_lastDrawTimestamp=-1;_bindingTable=[];get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(e,t){let i=n.defaultProps.shaderAssembler,r=t.vertexCount!==void 0;this.props={...n.defaultProps,...t,shaderAssembler:t.shaderAssembler??(D_(i,e.info.shadingLanguage)?i:Kt.getDefaultShaderAssembler(e.info.shadingLanguage))},this._vertexCountSet=r,t=this.props,this.id=t.id||Zn("model"),this.device=e,Object.assign(this.userData,t.userData),this.material=t.material||null;let s=QF(e),o=Ga(this.props.plugins,s.shaderLanguage),a=Va(this.props.modules,o.modules),c=Object.fromEntries(a.map(h=>[h.name,h])),l=t.shaderInputs||new xo(c,{disableWarnings:this.props.disableWarnings});t.shaderInputs&&o.modules.length>0&&l.addModules(o.modules),this.setShaderInputs(l);let u=Bf(this.props.modules,l.getModules()),f={...o.defines,...this.props.defines};if(this.device.type==="webgl"&&(this.props._uniformBlockLayouts=O1(u)),this.props.shaderLayout=vo(this.props.shaderLayout,u)||null,this.device.type==="webgpu"&&this.props.source){let h=this.props.shaderAssembler;Vi(D_(h,"wgsl"));let{source:p,getUniforms:m,bindingTable:g,shaderLayout:v}=h.assembleWGSLShader({platformInfo:s,...this.props,modules:u,defines:f,pluginInjections:o.injections,pluginVertexInputs:o.vertexInputs,pluginVaryings:o.varyings});this.source=p,this._getModuleUniforms=m,this._bindingTable=g;let y=v??e.getShaderLayout?.(this.source),b=qF(y,o.vertexInputs),x=B1(this.props.shaderLayout,b,Object.keys(o.vertexInputs));this.props.shaderLayout=vo(x||null,u)||null}else{let h=this.props.shaderAssembler;Vi(D_(h,"glsl"));let{vs:p,fs:m,getUniforms:g}=h.assembleGLSLShaderPair({platformInfo:s,...this.props,modules:u,defines:f,pluginInjections:o.injections,pluginVertexInputs:o.vertexInputs,pluginVaryings:o.varyings});this.vs=p,this.fs=m,this._getModuleUniforms=g,this._bindingTable=[]}this.vertexCount=this.props.vertexCount,this.indexCount=this.props.indexCount,this.firstVertex=this.props.firstVertex,this.firstIndex=this.props.firstIndex,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,this._colorAttachmentFormats=this.props.colorAttachmentFormats,this._depthStencilAttachmentFormat=this.props.depthStencilAttachmentFormat,t.geometry&&this.setGeometry(t.geometry),this.pipelineFactory=t.pipelineFactory||Ir.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||Br.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in t&&(this.isInstanced=t.isInstanced),t.instanceCount&&this.setInstanceCount(t.instanceCount),t.vertexCount&&this.setVertexCount(t.vertexCount),t.indexBuffer&&this.setIndexBuffer(t.indexBuffer),t.attributes&&this.setAttributes(t.attributes),t.constantAttributes&&this.setConstantAttributes(t.constantAttributes),t.bindings&&this.setBindings(t.bindings),t.transformFeedback&&(this.transformFeedback=t.transformFeedback)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}getBindingDebugTable(){return this._bindingTable}predraw(e){this._syncDynamicBuffers(),this.updateShaderInputs(e),this.material?.updateShaderInputs(e),this.pipeline=this._updatePipeline()}draw(e){if(this._drawBlockedReason&&!this._pipelineNeedsUpdate)return N.info(Xn,`>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)(),!1;let t=this._areBindingsLoading();if(t)return N.info(Xn,`>>> DRAWING ABORTED ${this.id}: ${t} not loaded`)(),!1;this._syncAttachmentFormats(e);try{e.pushDebugGroup(`${this}.predraw(${e})`),this.device.type==="webgpu"?(this.updateShaderInputs(),this.material?.updateShaderInputs(),this._syncDynamicBuffers(),this.pipeline=this._updatePipeline()):this.predraw(this.device.commandEncoder)}finally{e.popDebugGroup()}let i,r=this.pipeline.isErrored;try{if(e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline(),r=this.pipeline.isErrored,r)N.info(Xn,`>>> DRAWING ABORTED ${this.id}: ${O_}`)(),i=!1;else{let s=this.vertexArray.getDrawValidationError();if(s)N.info(Xn,`>>> DRAWING ABORTED ${this.id}: ${s}`)(),this._drawBlockedReason=s,i=!1;else{let o=this._getCurrentShaderLayout(),a=this._getBindings(o),c=this._getBindGroups(o,a),{indexBuffer:l}=this.vertexArray,u=l?this.indexCount??(this._vertexCountSet?this.vertexCount:l.byteLength/(l.indexType==="uint32"?4:2)):void 0;e.setPipeline(this.pipeline),e.setBindings(c,{_bindGroupCacheKeys:this._getBindGroupCacheKeys()}),e.setVertexArray(this.vertexArray),i=this.isInstanced===!0&&this.instanceCount===0?!0:e.draw({isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.isInstanced?this.instanceCount:void 0,indexCount:u,firstVertex:this.firstVertex,firstIndex:this.firstIndex,transformFeedback:this.transformFeedback||void 0,uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}}}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),i?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):r?(this._needsRedraw=O_,this._drawBlockedReason=O_):this._drawBlockedReason?this._needsRedraw=this._drawBlockedReason:this._needsRedraw="waiting for resource initialization",i}setGeometry(e){this._gpuGeometry?.destroy();let t=e&&w1(this.device,e);if(t){this.setTopology(t.topology||"triangle-list");let i=new bo(this.bufferLayout);this.bufferLayout=i.mergeBufferLayouts(t.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(t)}this._gpuGeometry=t}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){let t=new bo(this.bufferLayout),i=this._gpuGeometry?t.mergeBufferLayouts(e,this._gpuGeometry.bufferLayout):e;yo(i,this.bufferLayout,-1)||(this.bufferLayout=i,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry))}setParameters(e){yo(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,this.isInstanced===void 0&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this._vertexCountSet=!0,this.setNeedsRedraw("vertexCount")}setIndexCount(e){this.indexCount=e,this.setNeedsRedraw("indexCount")}setDrawOffsets({firstVertex:e,firstIndex:t}){this.firstVertex=e,this.firstIndex=t,this.setNeedsRedraw("drawOffsets")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new Nr(this.device,this.shaderInputs.modules);for(let[t,i]of Object.entries(this.shaderInputs.modules))if(_c(i)&&!this.material?.ownsModule(t)){let r=this._uniformStore.getManagedUniformBuffer(t);this.bindings[`${t}Uniforms`]=r}this.setNeedsRedraw("shaderInputs")}setMaterial(e){this.material=e,this.setNeedsRedraw("material")}updateShaderInputs(e){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),e),this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues())),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){let t=e instanceof tt?e.buffer:e;this.indexBuffer=t,this._dynamicIndexBufferSource=e instanceof tt?{source:e,generation:e.generation}:null,this.vertexArray.setIndexBuffer(t),this.setNeedsRedraw("indexBuffer")}setAttributes(e,t){this._drawBlockedReason=!1;let i=t?.disableWarnings??this.props.disableWarnings;e.indices&&N.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=R1(this.pipeline.shaderLayout,this.bufferLayout);let r=new bo(this.bufferLayout);for(let[s,o]of Object.entries(e)){let a=o instanceof tt?o.buffer:o,c=r.getBufferLayout(s);if(!c){i||N.warn(`Model(${this.id}): Missing layout for buffer "${s}".`)();continue}let l=r.getAttributeNamesForBuffer(c),u=!1;for(let f of l){let d=this._attributeInfos[f];if(d){let h=this.device.type==="webgpu"?this.vertexArray.getBufferSlot(d.bufferName):d.location;if(h===null){i||N.warn(`Model(${this.id}): Missing vertex array slot for buffer "${d.bufferName}".`)();continue}this.vertexArray.setBuffer(h,a),o instanceof tt?this._dynamicAttributeBufferSources[h]={source:o,generation:o.generation}:delete this._dynamicAttributeBufferSources[h],u=!0}}!u&&!i&&N.warn(`Model(${this.id}): Ignoring buffer "${a.id}" for unknown attribute "${s}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,t){for(let[i,r]of Object.entries(e)){let s=this._attributeInfos[i];s?this.vertexArray.setConstantWebGL(s.location,r):(t?.disableWarnings??this.props.disableWarnings)||N.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(let e of Object.values(this.bindings))if(bc(e)&&!e.isReady)return e.id;for(let e of Object.values(this.material?.bindings||{}))if(bc(e)&&!e.isReady)return e.id;return!1}_getBindings(e=this._getCurrentShaderLayout()){let t={};for(let[i,r]of Object.entries(this.bindings)){let s=ZF(i,r,e);s&&(t[i]=s)}return t}_getBindGroups(e=this._getCurrentShaderLayout(),t=this._getBindings(e)){let i=e.bindings.length?Or(e,t):{0:t};if(!this.material)return i;for(let[r,s]of Object.entries(this.material.getBindingsByGroup(e))){let o=Number(r);i[o]={...i[o]||{},...s}}return i}_getBindGroupCacheKeys(){let e=this.material?.getBindGroupCacheKey(3);return e?{3:e}:{}}_getBindingsUpdateTimestamp(){let e=0;this._dynamicIndexBufferSource&&(e=Math.max(e,this._dynamicIndexBufferSource.source.updateTimestamp));for(let t of Object.values(this._dynamicAttributeBufferSources))e=Math.max(e,t.source.updateTimestamp);for(let t of Object.values(this.bindings))t instanceof Ar?e=Math.max(e,t.texture.updateTimestamp):t instanceof ie||t instanceof me||t instanceof Aa||t instanceof tt?e=Math.max(e,t.updateTimestamp):bc(t)?e=t.isReady?Math.max(e,t.updateTimestamp):1/0:I_(t)&&(e=Math.max(e,(t.buffer instanceof tt,t.buffer.updateTimestamp)));return Math.max(e,this.material?.getBindingsUpdateTimestamp()||0)}_setGeometryAttributes(e){let t={...e.attributes};for(let[i]of Object.entries(t))!this.pipeline.shaderLayout.attributes.find(r=>r.name===i)&&i!=="positions"&&delete t[i];this.vertexCount=e.vertexCount,this._vertexCountSet=!0,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(t,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this._drawBlockedReason=!1,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,t=null;this.pipeline&&(N.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,t=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let i=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders}),r=null;this.source?r=i:this.fs&&(r=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bindings:void 0,bufferLayout:this.bufferLayout,colorAttachmentFormats:this._colorAttachmentFormats,depthStencilAttachmentFormat:this._depthStencilAttachmentFormat,topology:this.topology,parameters:this.parameters,bindGroups:void 0,vs:i,fs:r}),this._attributeInfos=$a(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&t!==e&&this.shaderFactory.release(t)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=N.level>3?0:HF;N.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:N.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=S1(this.pipeline.shaderLayout,this.id);N.table(Xn,e)();let t=this.shaderInputs.getDebugTable();N.table(Xn,t)();let i=this._getAttributeDebugTable();N.table(Xn,this._attributeInfos)(),N.table(Xn,i)(),N.groupEnd(Xn)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){let t=this.device.props.debugFramebuffers;if(this._drawCount++,!t)return;let i=e.props.framebuffer;L1(e,i,{id:i?.id||`${this.id}-framebuffer`,minimap:!0})}_getAttributeDebugTable(){let e={};for(let[t,i]of Object.entries(this._attributeInfos)){let r=this.vertexArray.attributes[i.location];e[i.location]={name:t,type:i.shaderType,values:r?this._getBufferOrConstantValues(r,i.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:t}=this.vertexArray,i=t.indexType==="uint32"?new Uint32Array(t.debugData):new Uint16Array(t.debugData);e.indices={name:"indices",type:t.indexType,values:i.toString()}}return e}_getBufferOrConstantValues(e,t){let i=Xe.getTypedArrayConstructor(t);return(e instanceof ie?new i(e.debugData):e).toString()}_getNonMaterialBindings(e){if(!this.material)return e;let t={};for(let[i,r]of Object.entries(e))this.material.ownsBinding(i)||(t[i]=r);return t}_getCurrentShaderLayout(){return this.pipeline?.shaderLayout||this.props.shaderLayout||{bindings:[]}}_syncDynamicBuffers(){if(this._dynamicIndexBufferSource&&this._dynamicIndexBufferSource.generation!==this._dynamicIndexBufferSource.source.generation){let e=this._dynamicIndexBufferSource.source.buffer;this.indexBuffer=e,this.vertexArray.setIndexBuffer(e),this._dynamicIndexBufferSource.generation=this._dynamicIndexBufferSource.source.generation,this.setNeedsRedraw("dynamic index buffer")}for(let[e,t]of Object.entries(this._dynamicAttributeBufferSources))t.generation!==t.source.generation&&(this.vertexArray.setBuffer(Number(e),t.source.buffer),t.generation=t.source.generation,this.setNeedsRedraw("dynamic attribute buffer"))}_syncAttachmentFormats(e){if(this.device.type!=="webgpu")return;let t=e.framebuffer||e.props.framebuffer,i=e.props,r=i.colorAttachmentFormats??t?.colorAttachments?.map(o=>XF(o?.texture?.format)),s=i.depthStencilAttachmentFormat===!1?void 0:i.depthStencilAttachmentFormat??KF(t?.depthStencilAttachment?.texture?.format);(!yo(this._colorAttachmentFormats,r,1)||this._depthStencilAttachmentFormat!==s)&&(this._colorAttachmentFormats=r,this._depthStencilAttachmentFormat=s,this._setPipelineNeedsUpdate("attachment formats"))}}});var JF,e6,nt,V1=C(()=>{J();vt();N_();JF=35980,e6=35981,nt=class n{device;model;transformFeedback;static defaultProps={...Ze.defaultProps,feedbackBufferMode:"separate",outputs:void 0,feedbackBuffers:void 0};static isSupported(e){return e?.info?.type==="webgl"}constructor(e,t=n.defaultProps){if(!n.isSupported(e))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=e,this.model=new Ze(this.device,{id:t.id||"buffer-transform-model",fs:t.fs||hg(),topology:t.topology||"point-list",varyings:t.outputs||t.varyings,...t,bufferMode:t.bufferMode||(t.feedbackBufferMode==="interleaved"?JF:e6)}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:t.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){e?.inputBuffers&&this.model.setAttributes(e.inputBuffers),e?.outputBuffers&&this.transformFeedback.setBuffers(e.outputBuffers);let t=this.device.beginRenderPass({discard:!0,...e});this.model.draw(t),t.end()}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){let t=this.getBuffer(e);if(!t)throw new Error("BufferTransform#getBuffer");if(t instanceof ie)return t.readAsync();let{buffer:i,byteOffset:r=0,byteLength:s=i.byteLength}=t;return i.readAsync(r,s)}}});function n6(n){return{type:n.type,shaderLanguage:n.info.shadingLanguage,shaderLanguageVersion:n.info.shadingLanguageVersion,gpu:n.info.gpu,limits:n.limits,features:n.features}}var F_,t6,Bt,W1=C(()=>{J();vt();Jp();R_();L_();_o();F_=2,t6=1e4,Bt=class n{static defaultProps={...Hi.defaultProps,id:"unnamed",handle:void 0,userData:{},source:"",modules:[],defines:{},plugins:[],bindings:void 0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,shaderAssembler:Kt.getDefaultShaderAssembler("wgsl"),debugShaders:void 0};device;id;pipelineFactory;shaderFactory;userData={};bindings={};pipeline;source;shader;shaderInputs;_uniformStore;_pipelineNeedsUpdate="newly created";_getModuleUniforms;props;_destroyed=!1;constructor(e,t){if(e.type!=="webgpu")throw new Error("Computation is only supported in WebGPU");this.props={...n.defaultProps,...t},t=this.props,this.id=t.id||Zn("model"),this.device=e,Object.assign(this.userData,t.userData);let i=n6(e),r=Ga(this.props.plugins,i.shaderLanguage);if(Object.keys(r.vertexInputs).length>0||Object.keys(r.varyings).length>0)throw new Error("Computation does not support ShaderPlugin vertex inputs or varyings");let s=Va(this.props.modules,r.modules),o=Object.fromEntries(s.map(p=>[p.name,p]));this.shaderInputs=t.shaderInputs||new xo(o),t.shaderInputs&&r.modules.length>0&&this.shaderInputs.addModules(r.modules),this.setShaderInputs(this.shaderInputs);let a=Bf(this.props.modules,this.shaderInputs?.getModules()),c={...r.defines,...this.props.defines};this.props.shaderLayout=vo(this.props.shaderLayout,a)||null,this.pipelineFactory=t.pipelineFactory||Ir.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||Br.getDefaultShaderFactory(this.device);let l=this.props.shaderAssembler;Vi(l instanceof qi);let{source:u,getUniforms:f,shaderLayout:d}=l.assembleWGSLShader({platformInfo:i,...this.props,modules:a,defines:c,scanVertexAttributes:!1,pluginInjections:r.injections});this.source=u,this._getModuleUniforms=f;let h=d??e.getShaderLayout?.(this.source,{scanVertexAttributes:!1});this.props.shaderLayout=vo(this.props.shaderLayout||h||null,a)||null,this.pipeline=this._updatePipeline(),t.bindings&&this.setBindings(t.bindings)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.shader),this._uniformStore.destroy(),this._destroyed=!0)}predraw(e){this.updateShaderInputs(e)}dispatch(e,t,i,r){try{this._logDrawCallStart(),this._setPipeline(e),e.dispatch(t,i,r)}finally{this._logDrawCallEnd()}}dispatchIndirect(e,t,i=0){try{this._logDrawCallStart(),this._setPipeline(e),e.dispatchIndirect(t,i)}finally{this._logDrawCallEnd()}}_setPipeline(e){this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings),e.setPipeline(this.pipeline),e.setBindings({})}setVertexCount(e){}setInstanceCount(e){}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new Nr(this.device,this.shaderInputs.modules);for(let[t,i]of Object.entries(this.shaderInputs.modules))if(_c(i)){let r=this._uniformStore.getManagedUniformBuffer(t);this.bindings[`${t}Uniforms`]=r}}setShaderModuleProps(e){let t=this._getModuleUniforms(e),i=Object.keys(t).filter(s=>{let o=t[s];return!_a(o)&&typeof o!="number"&&typeof o!="boolean"}),r={};for(let s of i)r[s]=t[s],delete t[s]}updateShaderInputs(e){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),e)}setBindings(e){Object.assign(this.bindings,e)}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate=this._pipelineNeedsUpdate||e}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null;this.pipeline&&(N.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.shader),this._pipelineNeedsUpdate=!1,this.shader=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"compute",source:this.source,debugShaders:this.props.debugShaders}),this.pipeline=this.pipelineFactory.createComputePipeline({...this.props,shader:this.shader}),e&&this.shaderFactory.release(e)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=N.level>3?0:t6;N.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:N.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=this.shaderInputs.getDebugTable();N.table(F_,e)(),N.groupEnd(F_)(),this._logOpen=!1}}_drawCount=0;_getBufferOrConstantValues(e,t){let i=Xe.getTypedArrayConstructor(t);return(e instanceof ie?new i(e.debugData):e).toString()}}});var Me=C(()=>{g1();x1();N_();V1();Rf();B_();W1()});function s2(n=!0){let e=HTMLCanvasElement.prototype;if(!n&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(t,i){if(t==="webgl"||t==="experimental-webgl"){let r=this.originalGetContext("webgl2",i);return r instanceof HTMLElement&&I6(r),r}return this.originalGetContext(t,i)}}function I6(n){n.getExtension("EXT_color_buffer_float");let e={...M6,WEBGL_disjoint_timer_query:n.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:A6(n),OES_vertex_array_object:k6(n),ANGLE_instanced_arrays:R6(n)},t=n.getExtension.bind(n);n.getExtension=function(r){let s=t(r);return s||(r in e?e[r]:null)};let i=n.getSupportedExtensions;n.getSupportedExtensions=function(){return(i.apply(n)||[])?.concat(Object.keys(e))}}var M6,A6,k6,R6,o2=C(()=>{M6={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},A6=n=>({drawBuffersWEBGL(e){return n.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),k6=n=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return n.createVertexArray()},deleteVertexArrayOES(e){return n.deleteVertexArray(e)},isVertexArrayOES(e){return n.isVertexArray(e)},bindVertexArrayOES(e){return n.bindVertexArray(e)}}),R6=n=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return n.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return n.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return n.vertexAttribDivisor(...e)}})});async function c2(){if(!Gf){Z_();return}await Gf.load()}function l2(n,e){return Gf?Gf.makeDebugContext(n,e):(Z_(),n)}async function u2(n){if(!q_){Z_();return}await q_.load(n)}function f2(n){return q_?.initialize(n)||null}function Z_(){a2||(a2=!0,N.warn("Import @luma.gl/webgl/debug before enabling WebGL debugging.")())}var Gf,q_,a2,X_=C(()=>{J();Gf=null,q_=null,a2=!1});function K_(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Ie(n,e,t){return e[n]!==void 0?e[n]:t[n]}var Oc,Ue,d2,Ot,h2,Bc,p2,m2,Q_,ei,J_,g2,ey=C(()=>{Oc={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},Ue=(n,e,t)=>e?n.enable(t):n.disable(t),d2=(n,e,t)=>n.hint(t,e),Ot=(n,e,t)=>n.pixelStorei(t,e),h2=(n,e,t)=>{let i=t===36006?36009:36008;return n.bindFramebuffer(i,e)},Bc=(n,e,t)=>{let r={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[t];n.bindBuffer(r,e)};p2={3042:Ue,32773:(n,e)=>n.blendColor(...e),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(n,e)=>n.clearColor(...e),3107:(n,e)=>n.colorMask(...e),2884:Ue,2885:(n,e)=>n.cullFace(e),2929:Ue,2931:(n,e)=>n.clearDepth(e),2932:(n,e)=>n.depthFunc(e),2928:(n,e)=>n.depthRange(...e),2930:(n,e)=>n.depthMask(e),3024:Ue,35723:d2,35725:(n,e)=>n.useProgram(e),36007:(n,e)=>n.bindRenderbuffer(36161,e),36389:(n,e)=>n.bindTransformFeedback?.(36386,e),34229:(n,e)=>n.bindVertexArray(e),36006:h2,36010:h2,34964:Bc,36662:Bc,36663:Bc,35053:Bc,35055:Bc,2886:(n,e)=>n.frontFace(e),33170:d2,2849:(n,e)=>n.lineWidth(e),32823:Ue,32824:"polygonOffset",10752:"polygonOffset",35977:Ue,32926:Ue,32928:Ue,32938:"sampleCoverage",32939:"sampleCoverage",3089:Ue,3088:(n,e)=>n.scissor(...e),2960:Ue,2961:(n,e)=>n.clearStencil(e),2968:(n,e)=>n.stencilMaskSeparate(1028,e),36005:(n,e)=>n.stencilMaskSeparate(1029,e),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(n,e)=>n.viewport(...e),34383:Ue,10754:Ue,12288:Ue,12289:Ue,12290:Ue,12291:Ue,12292:Ue,12293:Ue,12294:Ue,12295:Ue,3333:Ot,3317:Ot,37440:Ot,37441:Ot,37443:Ot,3330:Ot,3332:Ot,3331:Ot,3314:Ot,32878:Ot,3316:Ot,3315:Ot,32877:Ot,framebuffer:(n,e)=>{let t=e&&"handle"in e?e.handle:e;return n.bindFramebuffer(36160,t)},blend:(n,e)=>e?n.enable(3042):n.disable(3042),blendColor:(n,e)=>n.blendColor(...e),blendEquation:(n,e)=>{let t=typeof e=="number"?[e,e]:e;n.blendEquationSeparate(...t)},blendFunc:(n,e)=>{let t=e?.length===2?[...e,...e]:e;n.blendFuncSeparate(...t)},clearColor:(n,e)=>n.clearColor(...e),clearDepth:(n,e)=>n.clearDepth(e),clearStencil:(n,e)=>n.clearStencil(e),colorMask:(n,e)=>n.colorMask(...e),cull:(n,e)=>e?n.enable(2884):n.disable(2884),cullFace:(n,e)=>n.cullFace(e),depthTest:(n,e)=>e?n.enable(2929):n.disable(2929),depthFunc:(n,e)=>n.depthFunc(e),depthMask:(n,e)=>n.depthMask(e),depthRange:(n,e)=>n.depthRange(...e),dither:(n,e)=>e?n.enable(3024):n.disable(3024),derivativeHint:(n,e)=>{n.hint(35723,e)},frontFace:(n,e)=>n.frontFace(e),mipmapHint:(n,e)=>n.hint(33170,e),lineWidth:(n,e)=>n.lineWidth(e),polygonOffsetFill:(n,e)=>e?n.enable(32823):n.disable(32823),polygonOffset:(n,e)=>n.polygonOffset(...e),sampleCoverage:(n,e)=>n.sampleCoverage(e[0],e[1]||!1),scissorTest:(n,e)=>e?n.enable(3089):n.disable(3089),scissor:(n,e)=>n.scissor(...e),stencilTest:(n,e)=>e?n.enable(2960):n.disable(2960),stencilMask:(n,e)=>{e=K_(e)?e:[e,e];let[t,i]=e;n.stencilMaskSeparate(1028,t),n.stencilMaskSeparate(1029,i)},stencilFunc:(n,e)=>{e=K_(e)&&e.length===3?[...e,...e]:e;let[t,i,r,s,o,a]=e;n.stencilFuncSeparate(1028,t,i,r),n.stencilFuncSeparate(1029,s,o,a)},stencilOp:(n,e)=>{e=K_(e)&&e.length===3?[...e,...e]:e;let[t,i,r,s,o,a]=e;n.stencilOpSeparate(1028,t,i,r),n.stencilOpSeparate(1029,s,o,a)},viewport:(n,e)=>n.viewport(...e)};m2={blendEquation:(n,e,t)=>n.blendEquationSeparate(Ie(32777,e,t),Ie(34877,e,t)),blendFunc:(n,e,t)=>n.blendFuncSeparate(Ie(32969,e,t),Ie(32968,e,t),Ie(32971,e,t),Ie(32970,e,t)),polygonOffset:(n,e,t)=>n.polygonOffset(Ie(32824,e,t),Ie(10752,e,t)),sampleCoverage:(n,e,t)=>n.sampleCoverage(Ie(32938,e,t),Ie(32939,e,t)),stencilFuncFront:(n,e,t)=>n.stencilFuncSeparate(1028,Ie(2962,e,t),Ie(2967,e,t),Ie(2963,e,t)),stencilFuncBack:(n,e,t)=>n.stencilFuncSeparate(1029,Ie(34816,e,t),Ie(36003,e,t),Ie(36004,e,t)),stencilOpFront:(n,e,t)=>n.stencilOpSeparate(1028,Ie(2964,e,t),Ie(2965,e,t),Ie(2966,e,t)),stencilOpBack:(n,e,t)=>n.stencilOpSeparate(1029,Ie(34817,e,t),Ie(34818,e,t),Ie(34819,e,t))},Q_={enable:(n,e)=>n({[e]:!0}),disable:(n,e)=>n({[e]:!1}),pixelStorei:(n,e,t)=>n({[e]:t}),hint:(n,e,t)=>n({[e]:t}),useProgram:(n,e)=>n({35725:e}),bindRenderbuffer:(n,e,t)=>n({36007:t}),bindTransformFeedback:(n,e,t)=>n({36389:t}),bindVertexArray:(n,e)=>n({34229:e}),bindFramebuffer:(n,e,t)=>{switch(e){case 36160:return n({36006:t,36010:t});case 36009:return n({36006:t});case 36008:return n({36010:t});default:return null}},bindBuffer:(n,e,t)=>{let i={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[e];return i?n({[i]:t}):{valueChanged:!0}},blendColor:(n,e,t,i,r)=>n({32773:new Float32Array([e,t,i,r])}),blendEquation:(n,e)=>n({32777:e,34877:e}),blendEquationSeparate:(n,e,t)=>n({32777:e,34877:t}),blendFunc:(n,e,t)=>n({32969:e,32968:t,32971:e,32970:t}),blendFuncSeparate:(n,e,t,i,r)=>n({32969:e,32968:t,32971:i,32970:r}),clearColor:(n,e,t,i,r)=>n({3106:new Float32Array([e,t,i,r])}),clearDepth:(n,e)=>n({2931:e}),clearStencil:(n,e)=>n({2961:e}),colorMask:(n,e,t,i,r)=>n({3107:[e,t,i,r]}),cullFace:(n,e)=>n({2885:e}),depthFunc:(n,e)=>n({2932:e}),depthRange:(n,e,t)=>n({2928:new Float32Array([e,t])}),depthMask:(n,e)=>n({2930:e}),frontFace:(n,e)=>n({2886:e}),lineWidth:(n,e)=>n({2849:e}),polygonOffset:(n,e,t)=>n({32824:e,10752:t}),sampleCoverage:(n,e,t)=>n({32938:e,32939:t}),scissor:(n,e,t,i,r)=>n({3088:new Int32Array([e,t,i,r])}),stencilMask:(n,e)=>n({2968:e,36005:e}),stencilMaskSeparate:(n,e,t)=>n({[e===1028?2968:36005]:t}),stencilFunc:(n,e,t,i)=>n({2962:e,2967:t,2963:i,34816:e,36003:t,36004:i}),stencilFuncSeparate:(n,e,t,i,r)=>n({[e===1028?2962:34816]:t,[e===1028?2967:36003]:i,[e===1028?2963:36004]:r}),stencilOp:(n,e,t,i)=>n({2964:e,2965:t,2966:i,34817:e,34818:t,34819:i}),stencilOpSeparate:(n,e,t,i,r)=>n({[e===1028?2964:34817]:t,[e===1028?2965:34818]:i,[e===1028?2966:34819]:r}),viewport:(n,e,t,i,r)=>n({2978:[e,t,i,r]})},ei=(n,e)=>n.isEnabled(e),J_={3042:ei,2884:ei,2929:ei,3024:ei,32823:ei,32926:ei,32928:ei,3089:ei,2960:ei,35977:ei},g2=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068])});function bn(n,e){if(B6(e))return;let t={};for(let r in e){let s=Number(r),o=p2[r];o&&(typeof o=="string"?t[o]=!0:o(n,e[r],s))}let i=n.lumaState?.cache;if(i)for(let r in t){let s=m2[r];s(n,e,i)}}function Vf(n,e=Oc){if(typeof e=="number"){let r=e,s=J_[r];return s?s(n,r):n.getParameter(r)}let t=Array.isArray(e)?e:Object.keys(e),i={};for(let r of t){let s=J_[r];i[r]=s?s(n,Number(r)):n.getParameter(Number(r))}return i}function _2(n){bn(n,Oc)}function B6(n){for(let e in n)return!1;return!0}var Po=C(()=>{ey()});function b2(n,e){if(n===e)return!0;if(y2(n)&&y2(e)&&n.length===e.length){for(let t=0;t{});function x2(n,e){let t=n[e].bind(n);n[e]=function(r){if(r===void 0||g2.has(r))return t(r);let s=vn.get(n);return r in s.cache||(s.cache[r]=t(r)),s.enable?s.cache[r]:t(r)},Object.defineProperty(n[e],"name",{value:`${e}-from-cache`,configurable:!1})}function O6(n,e,t){if(!n[e])return;let i=n[e].bind(n);n[e]=function(...s){let o=vn.get(n),{valueChanged:a,oldValue:c}=t(o._updateCache,...s);return a&&i(...s),c},Object.defineProperty(n[e],"name",{value:`${e}-to-cache`,configurable:!1})}function D6(n){let e=n.useProgram.bind(n);n.useProgram=function(i){let r=vn.get(n);r.program!==i&&(e(i),r.program=i)}}var vn,ty=C(()=>{Po();v2();ey();vn=class{static get(e){return e.lumaState}gl;program=null;stateStack=[];enable=!0;cache=null;log;initialized=!1;constructor(e,t){this.gl=e,this.log=t?.log||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){let e=this.stateStack[this.stateStack.length-1];bn(this.gl,e),this.stateStack.pop()}trackState(e,t){if(this.cache=t?.copyState?Vf(e):Object.assign({},Oc),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.lumaState=this,D6(e);for(let i in Q_){let r=Q_[i];O6(e,i,r)}x2(e,"getParameter"),x2(e,"isEnabled")}_updateCache(e){let t=!1,i,r=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let s in e){let o=e[s],a=this.cache[s];b2(o,a)||(t=!0,i=a,r&&!(s in r)&&(r[s]=a),this.cache[s]=o)}return{valueChanged:t,oldValue:i}}}});function Dc(n){let e=n.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return e._polyfilled??=!1,e.extensions||={},n.luma=e,e}var ny=C(()=>{});function w2(n,e,t){let i="",r=c=>{let l=c.statusMessage;l&&(i||=l)};n.addEventListener("webglcontextcreationerror",r,!1);let s=t.failIfMajorPerformanceCaveat!==!0,o={preserveDrawingBuffer:!0,...t,failIfMajorPerformanceCaveat:!0},a=null;try{a||=n.getContext("webgl2",o),!a&&o.failIfMajorPerformanceCaveat&&(i||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.");let c=!1;if(!a&&s&&(o.failIfMajorPerformanceCaveat=!1,a=n.getContext("webgl2",o),c=!0),a||(a=n.getContext("webgl",{}),a&&(a=null,i||="Your browser only supports WebGL1")),!a)throw i||="Your browser does not support WebGL",new Error(`Failed to create WebGL context: ${i}`);let l=Dc(a);l.softwareRenderer=c;let{onContextLost:u,onContextRestored:f}=e;return n.addEventListener("webglcontextlost",d=>u(d),!1),n.addEventListener("webglcontextrestored",d=>f(d),!1),a}finally{n.removeEventListener("webglcontextcreationerror",r,!1)}}var E2=C(()=>{ny()});function xn(n,e,t){return t[e]===void 0&&(t[e]=n.getExtension(e)||null),t[e]}var Nc=C(()=>{});function S2(n,e){let t=n.getParameter(7936),i=n.getParameter(7937);xn(n,"WEBGL_debug_renderer_info",e);let r=e.WEBGL_debug_renderer_info,s=n.getParameter(r?r.UNMASKED_VENDOR_WEBGL:7936),o=n.getParameter(r?r.UNMASKED_RENDERER_WEBGL:7937),a=s||t,c=o||i,l=n.getParameter(7938),u=P2(a,c),f=N6(a,c),d=F6(a,c);return{type:"webgl",gpu:u,gpuType:d,gpuBackend:f,vendor:a,renderer:c,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function P2(n,e){return/NVIDIA/i.exec(n)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(n)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(n)||/Apple/i.exec(e)?"apple":/AMD/i.exec(n)||/AMD/i.exec(e)||/ATI/i.exec(n)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(n)||/SwiftShader/i.exec(e)?"software":"unknown"}function N6(n,e){return/Metal/i.exec(n)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(n)||/ANGLE/i.exec(e)?"opengl":"unknown"}function F6(n,e){if(/SwiftShader/i.exec(n)||/SwiftShader/i.exec(e))return"cpu";switch(P2(n,e)){case"apple":return z6(n,e)?"integrated":"unknown";case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function z6(n,e){return/Apple (M\d|A\d|GPU)/i.test(`${n} ${e}`)}var C2=C(()=>{Nc()});function Wf(n){switch(n){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(n))}var iy=C(()=>{});function M2(n){return n in Hf}function cy(n,e,t){return A2(n,e,t,new Set)}function A2(n,e,t,i){let r=Hf[e];if(!r||i.has(e))return!1;i.add(e);let s=(r.features||[]).every(o=>A2(n,o,t,i));return i.delete(e),s?(r.extensions||[]).every(o=>!!xn(n,o,t)):!1}function k2(n,e,t){let i=e.create,r=Yf[e.format];r?.gl===void 0&&(i=!1),r?.x&&(i=i&&!!xn(n,r.x,t)),e.format==="stencil8"&&(i=!1);let s=r?.r===!1?!1:r?.r===void 0||cy(n,r.r,t),o=i&&e.render&&s&&Y6(n,e.format,t);return{format:e.format,create:i&&e.create,render:o,filter:i&&e.filter,blend:i&&e.blend,store:i&&e.store}}function Y6(n,e,t){let i=Yf[e],r=i?.gl;if(r===void 0||i?.x&&!xn(n,i.x,t))return!1;let s=n.getParameter(32873),o=n.getParameter(36006),a=n.createTexture(),c=n.createFramebuffer();if(!a||!c)return!1;let l=0,u=Number(n.getError());for(;u!==l;)u=n.getError();let f=!1;try{if(n.bindTexture(3553,a),n.texStorage2D(3553,1,r,1,1),Number(n.getError())!==l)return!1;n.bindFramebuffer(36160,c),n.framebufferTexture2D(36160,36064,3553,a,0),f=Number(n.checkFramebufferStatus(36160))===36053&&Number(n.getError())===l}finally{n.bindFramebuffer(36160,o),n.deleteFramebuffer(c),n.bindTexture(3553,s),n.deleteTexture(a)}return f}function qf(n){let e=Yf[n],t=Z6(n),i=ft.getInfo(n);return i.compressed&&(e.dataFormat=t),{internalFormat:t,format:e?.dataFormat||q6(i.channels,i.integer,i.normalized,t),type:i.dataType?Wf(i.dataType):e?.types?.[0]||5121,compressed:i.compressed||!1}}function R2(n){switch(ft.getInfo(n).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${n}`)}}function q6(n,e,t,i){if(i===6408||i===6407)return i;switch(n){case"r":return e&&!t?36244:6403;case"rg":return e&&!t?33320:33319;case"rgb":return e&&!t?36248:6407;case"rgba":return e&&!t?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function Z6(n){let t=Yf[n]?.gl;if(t===void 0)throw new Error(`Unsupported texture format ${n}`);return t}var Fc,zc,Co,To,U6,$6,G6,V6,W6,j6,T2,L2,ry,sy,oy,ay,jf,H6,Hf,Yf,Lo=C(()=>{J();Nc();iy();Fc="WEBGL_compressed_texture_s3tc",zc="WEBGL_compressed_texture_s3tc_srgb",Co="EXT_texture_compression_rgtc",To="EXT_texture_compression_bptc",U6="WEBGL_compressed_texture_etc",$6="WEBGL_compressed_texture_astc",G6="WEBGL_compressed_texture_etc1",V6="WEBGL_compressed_texture_pvrtc",W6="WEBGL_compressed_texture_atc",j6="EXT_texture_norm16",T2="EXT_render_snorm",L2="EXT_color_buffer_float",ry="snorm8-renderable-webgl",sy="norm16-renderable-webgl",oy="snorm16-renderable-webgl",ay="float16-renderable-webgl",jf="float32-renderable-webgl",H6="rgb9e5ufloat-renderable-webgl",Hf={"float32-renderable-webgl":{extensions:[L2]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[T2]},"norm16-webgl":{extensions:[j6]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[T2]},"float32-filterable":{extensions:["OES_texture_float_linear"]},"float16-filterable-webgl":{extensions:["OES_texture_half_float_linear"]},"texture-filterable-anisotropic-webgl":{extensions:["EXT_texture_filter_anisotropic"]},"texture-blend-float-webgl":{extensions:["EXT_float_blend"]},"texture-compression-bc":{extensions:[Fc,zc,Co,To]},"texture-compression-bc5-webgl":{extensions:[Co]},"texture-compression-bc7-webgl":{extensions:[To]},"texture-compression-etc2":{extensions:[U6]},"texture-compression-astc":{extensions:[$6]},"texture-compression-etc1-webgl":{extensions:[G6]},"texture-compression-pvrtc-webgl":{extensions:[V6]},"texture-compression-atc-webgl":{extensions:[W6]}};Yf={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:ry},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:ry},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0,r:ay},r16unorm:{gl:33322,rb:!0,r:sy},r16snorm:{gl:36760,r:oy},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759,r:ry},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:ay},rg16unorm:{gl:33324,r:sy},rg16snorm:{gl:36761,r:oy},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:jf},rgb9e5ufloat:{gl:35901,r:H6},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852,r:!1},"rgb16snorm-webgl":{gl:36762,r:!1},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0,r:jf},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:ay},rgba16unorm:{gl:32859,rb:!0,r:sy},rgba16snorm:{gl:36763,r:oy},"rgb32float-webgl":{gl:34837,x:L2,r:jf,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:jf},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:Fc},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:zc},"bc1-rgba-unorm":{gl:33777,x:Fc},"bc1-rgba-unorm-srgb":{gl:35916,x:zc},"bc2-rgba-unorm":{gl:33778,x:Fc},"bc2-rgba-unorm-srgb":{gl:35918,x:zc},"bc3-rgba-unorm":{gl:33779,x:Fc},"bc3-rgba-unorm-srgb":{gl:35919,x:zc},"bc4-r-unorm":{gl:36283,x:Co},"bc4-r-snorm":{gl:36284,x:Co},"bc5-rg-unorm":{gl:36285,x:Co},"bc5-rg-snorm":{gl:36286,x:Co},"bc6h-rgb-ufloat":{gl:36495,x:To},"bc6h-rgb-float":{gl:36494,x:To},"bc7-rgba-unorm":{gl:36492,x:To},"bc7-rgba-unorm-srgb":{gl:36493,x:To},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37816},"astc-10x5-unorm-srgb":{gl:37848},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rgb2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}}});var I2,Zf,B2=C(()=>{J();Nc();Lo();I2={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","html-in-canvas":n=>Om()&&typeof n.texElementImage2D=="function","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},Zf=class extends Ta{gl;extensions;testedFeatures=new Set;constructor(e,t,i){super([],i),this.gl=e,this.extensions=t,xn(e,"EXT_color_buffer_float",t)}*[Symbol.iterator](){let e=this.getFeatures();for(let t of e)this.has(t)&&(yield t);return[]}has(e){return this.disabledFeatures?.[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),M2(e)&&cy(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){let e=this.getFeatures().filter(t=>t!=="polygon-mode-webgl");for(let t of e)this.has(t)}getFeatures(){return[...Object.keys(I2),...Object.keys(Hf)]}getWebGLFeature(e){let t=I2[e];return typeof t=="string"?!!xn(this.gl,t,this.extensions):typeof t=="function"?t(this.gl):!!t}}});var Xf,O2=C(()=>{J();Xf=class extends Ca{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxBindGroupsPlusVertexBuffers(){return 0}get maxBindingsPerBindGroup(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageBuffersInVertexStage(){return 0}get maxStorageBuffersInFragmentStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxStorageTexturesInVertexStage(){return 0}get maxStorageTexturesInFragmentStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get maxBufferSize(){return Number.MAX_SAFE_INTEGER}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxColorAttachments(){return this.getParameter(36063)}get maxColorAttachmentBytesPerSample(){return 0}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]||0}}});function X6(n){return n<34069?n+34069:n}function K6(n){switch(n){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${n}`}}var ti,Kf=C(()=>{J();Lo();ti=class extends Rr{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(e,t){super(e,t);let i=t.handle,r=i===null;this.device=e,this.gl=e.gl,this.handle=i||r?i:this.gl.createFramebuffer(),r||(e._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),t.handle||(this.autoCreateAttachmentTextures(),this.updateAttachments()))}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&!this.props.handle&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){let e=this.gl.bindFramebuffer(36160,this.handle);for(let t=0;t{J();Kf();Qf=class extends La{device;handle=null;_framebuffer=null;get[Symbol.toStringTag](){return"WebGLCanvasContext"}constructor(e,t){super(t),this.device=e,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._configureDevice()}_configureDevice(){(this.drawingBufferWidth!==this._framebuffer?.width||this.drawingBufferHeight!==this._framebuffer?.height)&&this._framebuffer?.resize([this.drawingBufferWidth,this.drawingBufferHeight])}_getCurrentFramebuffer(){return this._framebuffer||=new ti(this.device,{id:"canvas-context-framebuffer",handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}}});var Jf,N2=C(()=>{J();Jf=class extends Ma{device;handle=null;context2d;get[Symbol.toStringTag](){return"WebGLPresentationContext"}constructor(e,t={}){super(t),this.device=e;let i=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw new Error(`${i}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);let s=this.canvas.getContext("2d");if(!s)throw new Error(`${i}: Failed to create 2d presentation context`);this.context2d=s,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();let e=this.device.getDefaultCanvasContext(),[t,i]=e.getDrawingBufferSize();if(!(this.drawingBufferWidth===0||this.drawingBufferHeight===0||t===0||i===0||e.canvas.width===0||e.canvas.height===0)){if(t!==this.drawingBufferWidth||i!==this.drawingBufferHeight||e.canvas.width!==this.drawingBufferWidth||e.canvas.height!==this.drawingBufferHeight)throw new Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${t}x${i} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(e.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(e){let t=this.device.getDefaultCanvasContext();return t.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),t.getCurrentFramebuffer(e)}}});function F2(n="id"){ly[n]=ly[n]||1;let e=ly[n]++;return`${n}-${e}`}var ly,z2=C(()=>{ly={}});function Q6(n){return n&ie.INDEX?34963:n&ie.VERTEX?34962:n&ie.UNIFORM?35345:34962}function J6(n){return n&ie.INDEX||n&ie.VERTEX?35044:n&ie.UNIFORM?35048:35044}var wn,ed=C(()=>{J();wn=class extends ie{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength=0;bytesUsed=0;constructor(e,t={}){super(e,t),this.device=e,this.gl=this.device.gl;let i=typeof t=="object"?t.handle:void 0;this.handle=i||this.gl.createBuffer(),e._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=Q6(this.props.usage),this.glUsage=J6(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,t.data?this._initWithData(t.data,t.byteOffset,t.byteLength):this._initWithByteLength(t.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Buffer"):(this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle)),this.destroyed=!0,this.handle=null)}_initWithData(e,t=0,i=e.byteLength+t){let r=this.glTarget;this.gl.bindBuffer(r,this.handle),this.gl.bufferData(r,i,this.glUsage),this.gl.bufferSubData(r,t,e),this.gl.bindBuffer(r,null),this.bytesUsed=i,this.byteLength=i,this._setDebugData(e,t,i),this.props.handle?this.trackReferencedMemory(i,"Buffer"):this.trackAllocatedMemory(i)}_initWithByteLength(e){let t=e;e===0&&(t=new Float32Array(0));let i=this.glTarget;return this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,t,this.glUsage),this.gl.bindBuffer(i,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.props.handle?this.trackReferencedMemory(e,"Buffer"):this.trackAllocatedMemory(e),this}write(e,t=0){let i=ArrayBuffer.isView(e)?e:new Uint8Array(e),r=0,s=void 0,o=36663;this.gl.bindBuffer(o,this.handle),r!==0||s!==void 0?this.gl.bufferSubData(o,t,i,r,s):this.gl.bufferSubData(o,t,i),this.gl.bindBuffer(o,null),this._setDebugData(e,t,e.byteLength)}async mapAndWriteAsync(e,t=0,i=this.byteLength-t){let r=new ArrayBuffer(i);await e(r,"copied"),this.write(r,t)}async readAsync(e=0,t){return this.readSyncWebGL(e,t)}async mapAndReadAsync(e,t=0,i){let r=await this.readAsync(t,i);return await e(r.buffer,"copied")}readSyncWebGL(e=0,t){t=t??this.byteLength-e;let i=new Uint8Array(t),r=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,i,r,t),this.gl.bindBuffer(36662,null),this._setDebugData(i,e,t),i}}});function U2(n){let e=n.split(/\r?\n/),t=[];for(let i of e){if(i.length<=1)continue;let r=i.trim(),s=i.split(":"),o=s[0]?.trim();if(s.length===2){let[h,p]=s;if(!h||!p){t.push({message:r,type:td(o||"info"),lineNum:0,linePos:0});continue}t.push({message:p.trim(),type:td(h),lineNum:0,linePos:0});continue}let[a,c,l,...u]=s;if(!a||!c||!l){t.push({message:s.slice(1).join(":").trim()||r,type:td(o||"info"),lineNum:0,linePos:0});continue}let f=parseInt(l,10);Number.isNaN(f)&&(f=0);let d=parseInt(c,10);Number.isNaN(d)&&(d=0),t.push({message:u.join(":").trim(),type:td(a),lineNum:f,linePos:d})}return t}function td(n){let e=["warning","error","info"],t=n.toLowerCase();return e.includes(t)?t:"info"}var $2=C(()=>{});function ez(n){return n.split(/\r?\n/).find(e=>e.trim())?.trim()}var nd,G2=C(()=>{J();$2();nd=class extends kr{device;handle;_compilationInfoLog="";constructor(e,t){super(e,t),this.device=e;let i=this.props.handle;switch(this.props.stage){case"vertex":this.handle=i||this.device.gl.createShader(35633);break;case"fragment":this.handle=i||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}e._setWebGLDebugMetadata(this.handle,this,{spector:this.props});let r=this._compile(this.source);r&&typeof r.catch=="function"&&r.catch(()=>{this.compilationStatus="error"})}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this._getCompilationInfoLog();return e?U2(e):[]}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)||null}_compile(e){e=e.startsWith("#version ")?e:`#version 300 es -${e}`;let{gl:t}=this.device;if(t.shaderSource(this.handle,e),t.compileShader(this.handle),!this.device.props.debug){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus==="error")throw new Error(this._getCompilationErrorMessage(e));return}return N.once(1,"Shader compilation is asynchronous")(),this._waitForCompilationComplete().then(()=>{N.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()})}async _waitForCompilationComplete(){let e=async r=>await new Promise(s=>setTimeout(s,r));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error",this.compilationStatus==="error"&&this._getCompilationInfoLog()}_getCompilationErrorMessage(e){let t=`${this.props.stage} shader ${this.props.id}`,i=ez(this._getCompilationInfoLog()),r=this.getCompilationInfoSync(),s=r.find(u=>u.type==="error"&&u.message.trim())||r.find(u=>u.message.trim())||r.find(u=>u.type==="error")||r[0];if(!s)return i?`GLSL compilation errors in ${t}: ${i}`:`GLSL compilation errors in ${t}: WebGL did not provide a shader compiler log`;let o=s.lineNum?e.split(/\r?\n/)[s.lineNum-1]?.trim():void 0,a=s.lineNum?` line ${s.lineNum}`:"",c=o?` -Source: ${o}`:"",l=s.message.trim()||i||"WebGL did not provide a shader compiler log";return`GLSL compilation errors in ${t}:${a}: ${l}${c}`}_getCompilationInfoLog(){let e=this.device.gl.getShaderInfoLog(this.handle)?.trim();return e&&(this._compilationInfoLog=e),this._compilationInfoLog}}});function W2(n,e,t,i){if(rz(e))return i(n);let r=n;r.pushState();try{return tz(n,e),bn(r.gl,t),i(n)}finally{r.popState()}}function tz(n,e){let t=n,{gl:i}=t;if(e.cullMode)switch(e.cullMode){case"none":i.disable(2884);break;case"front":i.enable(2884),i.cullFace(1028);break;case"back":i.enable(2884),i.cullFace(1029);break}if(e.frontFace&&i.frontFace(ss("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&n.features.has("depth-clip-control")&&i.enable(34383),e.depthBias!==void 0&&(i.enable(32823),i.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&n.features.has("provoking-vertex-webgl")){let s=t.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,o=ss("provokingVertex",e.provokingVertex,{first:36429,last:36430});s?.provokingVertexWEBGL(o)}if((e.polygonMode||e.polygonOffsetLine)&&n.features.has("polygon-mode-webgl")){if(e.polygonMode){let s=t.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,o=ss("polygonMode",e.polygonMode,{fill:6914,line:6913});s?.polygonModeWEBGL(1028,o),s?.polygonModeWEBGL(1029,o)}e.polygonOffsetLine&&i.enable(10754)}if(n.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&i.enable(12288),e.clipDistance1&&i.enable(12289),e.clipDistance2&&i.enable(12290),e.clipDistance3&&i.enable(12291),e.clipDistance4&&i.enable(12292),e.clipDistance5&&i.enable(12293),e.clipDistance6&&i.enable(12294),e.clipDistance7&&i.enable(12295)),e.depthWriteEnabled!==void 0&&i.depthMask(iz("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?i.enable(2929):i.disable(2929),i.depthFunc(rd("depthCompare",e.depthCompare))),e.clearDepth!==void 0&&i.clearDepth(e.clearDepth),e.stencilWriteMask){let r=e.stencilWriteMask;i.stencilMaskSeparate(1028,r),i.stencilMaskSeparate(1029,r)}if(e.stencilReadMask&&N.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){let r=e.stencilReadMask||4294967295,s=rd("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?i.enable(2960):i.disable(2960),i.stencilFuncSeparate(1028,s,0,r),i.stencilFuncSeparate(1029,s,0,r)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){let r=uy("stencilPassOperation",e.stencilPassOperation),s=uy("stencilFailOperation",e.stencilFailOperation),o=uy("stencilDepthFailOperation",e.stencilDepthFailOperation);i.stencilOpSeparate(1028,s,o,r),i.stencilOpSeparate(1029,s,o,r)}switch(e.blend){case!0:i.enable(3042);break;case!1:i.disable(3042);break;default:}if(e.blendColorOperation||e.blendAlphaOperation){let r=V2("blendColorOperation",e.blendColorOperation||"add"),s=V2("blendAlphaOperation",e.blendAlphaOperation||"add");i.blendEquationSeparate(r,s);let o=id("blendColorSrcFactor",e.blendColorSrcFactor||"one"),a=id("blendColorDstFactor",e.blendColorDstFactor||"zero"),c=id("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),l=id("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");i.blendFuncSeparate(o,a,c,l)}}function rd(n,e){return ss(n,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function uy(n,e){return ss(n,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function V2(n,e){return ss(n,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function id(n,e,t="color"){return ss(n,e,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:t==="color"?32769:32771,"one-minus-constant":t==="color"?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function nz(n,e){return`Illegal parameter ${e} for ${n}`}function ss(n,e,t){if(!(e in t))throw new Error(nz(n,e));return t[e]}function iz(n,e){return e}function rz(n){let e=!0;for(let t in n){e=!1;break}return e}var fy=C(()=>{J();Po()});function sd(n){let e={};return n.addressModeU&&(e[10242]=dy(n.addressModeU)),n.addressModeV&&(e[10243]=dy(n.addressModeV)),n.addressModeW&&(e[32882]=dy(n.addressModeW)),n.magFilter&&(e[10240]=hy(n.magFilter)),(n.minFilter||n.mipmapFilter)&&(e[10241]=sz(n.minFilter||"linear",n.mipmapFilter)),n.lodMinClamp!==void 0&&(e[33082]=n.lodMinClamp),n.lodMaxClamp!==void 0&&(e[33083]=n.lodMaxClamp),n.type==="comparison-sampler"&&(e[34892]=34894),n.compare&&(e[34893]=rd("compare",n.compare)),n.maxAnisotropy&&(e[34046]=n.maxAnisotropy),e}function dy(n){switch(n){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function hy(n){switch(n){case"nearest":return 9728;case"linear":return 9729}}function sz(n,e="none"){if(!e)return hy(n);switch(e){case"none":return hy(n);case"nearest":switch(n){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(n){case"nearest":return 9986;case"linear":return 9987}}}var py=C(()=>{fy()});var od,j2=C(()=>{J();py();od=class extends Mr{device;handle;parameters;constructor(e,t){super(e,t),this.device=e,this.parameters=sd(t),this.handle=t.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(let[t,i]of Object.entries(e)){let r=Number(t);switch(r){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,r,i);break;default:this.device.gl.samplerParameteri(this.handle,r,i);break}}}}});function En(n,e,t){if(oz(e))return t(n);let{nocatch:i=!0}=e,r=vn.get(n);r.push(),bn(n,e);let s;if(i)s=t(n),r.pop();else try{s=t(n)}finally{r.pop()}return s}function oz(n){for(let e in n)return!1;return!0}var ad=C(()=>{Po();ty()});var ni,my=C(()=>{J();ni=class extends Ar{device;gl;handle;texture;constructor(e,t){super(e,{...me.defaultProps,...t}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=t.texture}}});function cd(n){return az[n]}var az,gy=C(()=>{az={5124:"sint32",5125:"uint32",5122:"sint16",5123:"uint16",5120:"sint8",5121:"uint8",5126:"float32",5131:"float16",33635:"uint16",32819:"uint16",32820:"uint16",33640:"uint32",35899:"uint32",35902:"uint32",34042:"uint32",36269:"uint32"}});function cz(n,e=0){return e?new n.constructor(n.buffer,n.byteOffset+e,(n.byteLength-e)/n.BYTES_PER_ELEMENT):n}function lz(n,e){if(e%n.BYTES_PER_ELEMENT!==0)throw new Error(`Texture byteOffset ${e} must align to typed array element size ${n.BYTES_PER_ELEMENT}`);return e/n.BYTES_PER_ELEMENT}function uz(n){switch(n){case"1d":break;case"2d":return 3553;case"3d":return 32879;case"cube":return 34067;case"2d-array":return 35866;case"cube-array":break}throw new Error(n)}function Uc(n,e,t){return e==="cube"?34069+t:n}var ii,ld=C(()=>{J();Lo();py();ad();my();gy();ii=class extends me{device;gl;handle;sampler=void 0;view;glTarget;glFormat;glType;glInternalFormat;compressed;_textureUnit=0;_framebuffer=null;_framebufferAttachmentKey=null;constructor(e,t){super(e,t,{byteAlignment:1}),this.device=e,this.gl=this.device.gl;let i=qf(this.props.format);if(this.glTarget=uz(this.props.dimension),this.glInternalFormat=i.internalFormat,this.glFormat=i.format,this.glType=i.type,this.compressed=i.compressed,this.isHandleBorrowed&&this.props.handle===void 0)throw new Error("Borrowed WebGL textures require a texture handle");if(this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),!this.isHandleBorrowed){this.gl.bindTexture(this.glTarget,this.handle);let{dimension:r,width:s,height:o,depth:a,mipLevels:c,glTarget:l,glInternalFormat:u}=this;if(!this.compressed)switch(r){case"2d":case"cube":this.gl.texStorage2D(l,c,u,s,o);break;case"2d-array":case"3d":this.gl.texStorage3D(l,c,u,s,o,a);break;default:throw new Error(r)}this.gl.bindTexture(this.glTarget,null),this._initializeData(t.data)}this.ownsHandle?this.trackAllocatedMemory(this.getAllocatedByteLength(),"Texture"):this.trackReferencedMemory(this.getAllocatedByteLength(),"Texture"),this.isHandleBorrowed||this.setSampler(this.props.sampler),this.view=new ni(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this._framebuffer?.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.ownsHandle?(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory("Texture")):this.trackDeallocatedReferencedMemory("Texture"),this.destroyed=!0)}createView(e){return new ni(this.device,{...e,texture:this})}clone(e){if(this.isHandleBorrowed&&e&&(e.width!==this.width||e.height!==this.height))throw new Error(`Cannot resize borrowed read-only ${this}`);return super.clone(e)}setSampler(e={}){this._assertWritable("set sampler parameters on"),super.setSampler(e);let t=sd(this.sampler.props);this._setSamplerParameters(t)}copyExternalImage(e){this._assertWritable("copy external image data into");let t=this._normalizeCopyExternalImageOptions(e);if(t.sourceX||t.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");let{glFormat:i,glType:r}=this,{image:s,depth:o,mipLevel:a,x:c,y:l,z:u,width:f,height:d}=t,h=Uc(this.glTarget,this.dimension,u),p=t.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),En(this.gl,p,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(h,a,c,l,f,d,i,r,s);break;case"2d-array":case"3d":this.gl.texSubImage3D(h,a,c,l,u,f,d,o,i,r,s);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:t.width,height:t.height}}copyElementImage(e){this._assertWritable("copy element image data into");let t=this._normalizeCopyElementImageOptions(e),{glFormat:i}=this,{element:r,depth:s,mipLevel:o,sourceX:a,sourceY:c,sourceWidth:l,sourceHeight:u,x:f,y:d,z:h,width:p,height:m}=t,g=Uc(this.glTarget,this.dimension,h),v=t.flipY?{37440:!0}:{},y=this.gl;if(s!==1||this.dimension!=="2d"&&this.dimension!=="cube")throw new Error(`${this} copyElementImage only supports 2d and cube textures on WebGL`);if(o!==0||f!==0||d!==0)throw new Error(`${this} copyElementImage only supports full base-level uploads on WebGL`);if(typeof y.texElementImage2D!="function")throw new Error(`${this} copyElementImage is not supported by this WebGL implementation`);return this.gl.bindTexture(this.glTarget,this.handle),En(this.gl,v,()=>{y.texElementImage2D?.(g,i,r,{sx:a,sy:c,swidth:l??p,sheight:u??m,width:p,height:m})}),this.gl.bindTexture(this.glTarget,null),{width:t.width,height:t.height}}copyImageData(e){super.copyImageData(e)}readBuffer(e={},t){if(!t)throw new Error(`${this} readBuffer requires a destination buffer`);let i=this._getSupportedColorReadOptions(e),r=e.byteOffset??0,s=this.computeMemoryLayout(i);if(t.byteLength{this.gl.readPixels(i.x,i.y,i.width,i.height,this.glFormat,this.glType,r+a)})}finally{this.gl.bindBuffer(35051,null)}return t}async readDataAsync(e={}){throw new Error(`${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`)}writeBuffer(e,t={}){this._assertWritable("write buffer data into");let i=this._normalizeTextureWriteOptions(t),{width:r,height:s,depthOrArrayLayers:o,mipLevel:a,byteOffset:c,x:l,y:u,z:f}=i,{glFormat:d,glType:h,compressed:p}=this,m=Uc(this.glTarget,this.dimension,f);if(p)throw new Error("writeBuffer for compressed textures is not implemented in WebGL");let{bytesPerPixel:g}=this.device.getTextureFormatInfo(this.format),v=g?i.bytesPerRow/g:void 0,y={3317:this.byteAlignment,...v!==void 0?{3314:v}:{},32878:i.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,e.handle),En(this.gl,y,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(m,a,l,u,r,s,d,h,c);break;case"2d-array":case"3d":this.gl.texSubImage3D(m,a,l,u,f,r,s,o,d,h,c);break;default:}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(e,t={}){this._assertWritable("write data into");let i=this._normalizeTextureWriteOptions(t),r=ArrayBuffer.isView(e)?e:new Uint8Array(e),{width:s,height:o,depthOrArrayLayers:a,mipLevel:c,x:l,y:u,z:f,byteOffset:d}=i,{glFormat:h,glType:p,compressed:m}=this,g=Uc(this.glTarget,this.dimension,f),v;if(!m){let{bytesPerPixel:T}=this.device.getTextureFormatInfo(this.format);T&&(v=i.bytesPerRow/T)}let y=this.compressed?{}:{3317:this.byteAlignment,...v!==void 0?{3314:v}:{},32878:i.rowsPerImage},b=lz(r,d),x=m?cz(r,d):r,E=this._getMipLevelSize(c),w=l===0&&u===0&&f===0&&s===E.width&&o===E.height&&a===E.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),En(this.gl,y,()=>{switch(this.dimension){case"2d":case"cube":m?w?this.gl.compressedTexImage2D(g,c,h,s,o,0,x):this.gl.compressedTexSubImage2D(g,c,l,u,s,o,h,x):this.gl.texSubImage2D(g,c,l,u,s,o,h,p,r,b);break;case"2d-array":case"3d":m?w?this.gl.compressedTexImage3D(g,c,h,s,o,a,0,x):this.gl.compressedTexSubImage3D(g,c,l,u,f,s,o,a,h,x):this.gl.texSubImage3D(g,c,l,u,f,s,o,a,h,p,r,b);break;default:}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(e,t){return 1}_getFramebuffer(){return this._framebuffer||=this.device.createFramebuffer({id:`framebuffer-for-${this.id}`,width:this.width,height:this.height,colorAttachments:[this]}),this._framebuffer}readDataSyncWebGL(e={}){let t=this._getSupportedColorReadOptions(e),i=this.computeMemoryLayout(t),r=cd(this.glType),s=Lr(r),o=new s(i.byteLength/s.BYTES_PER_ELEMENT);return this._readColorTextureLayers(t,i,a=>{let c=new s(o.buffer,o.byteOffset+a,i.bytesPerImage/s.BYTES_PER_ELEMENT);this.gl.readPixels(t.x,t.y,t.width,t.height,this.glFormat,this.glType,c)}),o.buffer}_readColorTextureLayers(e,t,i){let r=this._getFramebuffer(),s=t.bytesPerRow/t.bytesPerPixel,o={3333:this.byteAlignment,...s!==e.width?{3330:s}:{}},a=this.gl.getParameter(3074),c=this.gl.bindFramebuffer(36160,r.handle);try{this.gl.readBuffer(36064),En(this.gl,o,()=>{for(let l=0;l=2&&N.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(e))(),this.gl.bindTexture(this.glTarget,this.handle);for(let[t,i]of Object.entries(e)){let r=Number(t),s=i;switch(r){case 33082:case 33083:this.gl.texParameterf(this.glTarget,r,s);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,r,s);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,r,s);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,r,s);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,r,s);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(e){let{gl:t}=this;return e!==void 0&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,this.handle),e}_unbind(e){let{gl:t}=this;return e!==void 0&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,null),e}_assertWritable(e){if(this.isHandleBorrowed)throw new Error(`Cannot ${e} borrowed read-only ${this}`)}}});function H2(n,e,t,i){let r=n,s=i;s===!0&&(s=1),s===!1&&(s=0);let o=typeof s=="number"?[s]:s;switch(t){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof i!="number")throw new Error("samplers must be set to integers");return n.uniform1i(e,i);case 5126:return n.uniform1fv(e,o);case 35664:return n.uniform2fv(e,o);case 35665:return n.uniform3fv(e,o);case 35666:return n.uniform4fv(e,o);case 5124:return n.uniform1iv(e,o);case 35667:return n.uniform2iv(e,o);case 35668:return n.uniform3iv(e,o);case 35669:return n.uniform4iv(e,o);case 35670:return n.uniform1iv(e,o);case 35671:return n.uniform2iv(e,o);case 35672:return n.uniform3iv(e,o);case 35673:return n.uniform4iv(e,o);case 5125:return r.uniform1uiv(e,o,1);case 36294:return r.uniform2uiv(e,o,2);case 36295:return r.uniform3uiv(e,o,3);case 36296:return r.uniform4uiv(e,o,4);case 35674:return n.uniformMatrix2fv(e,!1,o);case 35675:return n.uniformMatrix3fv(e,!1,o);case 35676:return n.uniformMatrix4fv(e,!1,o);case 35685:return r.uniformMatrix2x3fv(e,!1,o);case 35686:return r.uniformMatrix2x4fv(e,!1,o);case 35687:return r.uniformMatrix3x2fv(e,!1,o);case 35688:return r.uniformMatrix3x4fv(e,!1,o);case 35689:return r.uniformMatrix4x2fv(e,!1,o);case 35690:return r.uniformMatrix4x3fv(e,!1,o)}throw new Error("Illegal uniform")}var Y2=C(()=>{});function q2(n){return dz[n]}function ud(n){return fz[n]}function fd(n){return!!X2[n]}function Z2(n){return X2[n]}var fz,X2,dz,dd=C(()=>{fz={5126:"f32",35664:"vec2",35665:"vec3",35666:"vec4",5124:"i32",35667:"vec2",35668:"vec3",35669:"vec4",5125:"u32",36294:"vec2",36295:"vec3",36296:"vec4",35670:"f32",35671:"vec2",35672:"vec3",35673:"vec4",35674:"mat2x2",35685:"mat2x3",35686:"mat2x4",35687:"mat3x2",35675:"mat3x3",35688:"mat3x4",35689:"mat4x2",35690:"mat4x3",35676:"mat4x4"},X2={35678:{viewDimension:"2d",sampleType:"float"},35680:{viewDimension:"cube",sampleType:"float"},35679:{viewDimension:"3d",sampleType:"float"},35682:{viewDimension:"3d",sampleType:"depth"},36289:{viewDimension:"2d-array",sampleType:"float"},36292:{viewDimension:"2d-array",sampleType:"depth"},36293:{viewDimension:"cube",sampleType:"float"},36298:{viewDimension:"2d",sampleType:"sint"},36299:{viewDimension:"3d",sampleType:"sint"},36300:{viewDimension:"cube",sampleType:"sint"},36303:{viewDimension:"2d-array",sampleType:"uint"},36306:{viewDimension:"2d",sampleType:"uint"},36307:{viewDimension:"3d",sampleType:"uint"},36308:{viewDimension:"cube",sampleType:"uint"},36311:{viewDimension:"2d-array",sampleType:"uint"}},dz={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126}});function Q2(n,e,t={}){let i={attributes:[],bindings:[]};i.attributes=hz(n,e);let r=gz(n,e,t);for(let c of r){let l=c.uniforms.map(u=>({name:u.name,format:u.format,byteOffset:u.byteOffset,byteStride:u.byteStride,arrayLength:u.arrayLength}));i.bindings.push({type:"uniform",name:c.name,group:0,location:c.location,visibility:(c.vertex?1:0)|(c.fragment?2:0),minBindingSize:c.byteLength,uniforms:l})}let s=mz(n,e),o=0;for(let c of s)if(fd(c.type)){let{viewDimension:l,sampleType:u}=Z2(c.type);i.bindings.push({type:"texture",name:c.name,group:0,location:o,viewDimension:l,sampleType:u}),c.textureUnit=o,o+=1}s.length&&(i.uniforms=s);let a=pz(n,e);return a?.length&&(i.varyings=a),i}function hz(n,e){let t=[],i=n.getProgramParameter(e,35721);for(let r=0;r=0){let l=ud(a),u=/instance/i.test(o)?"instance":"vertex";t.push({name:o,location:c,stepMode:u,type:l})}}return t.sort((r,s)=>r.location-s.location),t}function pz(n,e){let t=[],i=n.getProgramParameter(e,35971);for(let r=0;rr.location-s.location),t}function mz(n,e){let t=[],i=n.getProgramParameter(e,35718);for(let r=0;r1)for(let h=0;ho.location-a.location),i}function _z(n,e){for(let t of n.uniforms){let i=e.uniforms.find(r=>t.name===r.name||t.name.endsWith(`.${r.name}`));if(!i)throw new Error(`Failed to validate WebGL uniform block "${e.name}": reflected unexpected member "${t.name}"`);if(t.format!==i.format||t.arrayLength!==i.arrayLength||t.byteOffset!==i.byteOffset||t.byteStride!==i.byteStride)throw new Error(`Failed to validate WebGL uniform block "${e.name}": reflected layout for "${t.name}" does not match supplied std140 metadata`)}}function yz(n,e,t){let i=new Map;for(let s of t.uniformBlockLayouts||[])i.set(s.name,vz(s));for(let s of t.shaderLayout?.bindings||[])wz(s)&&i.set(s.name,s);let r=new Map;for(let s of i.values()){let o=bz(n,e,s.name);if(!o)continue;let{blockIndex:a,blockName:c}=o;if(r.has(a))throw new Error(`Multiple supplied uniform block layouts resolve to active WebGL block "${c}"`);r.set(a,{name:c,location:a,byteLength:s.minBindingSize,vertex:!!(s.visibility&&s.visibility&1),fragment:!!(s.visibility&&s.visibility&2),uniformCount:s.uniforms.length,uniforms:s.uniforms.map(l=>({...l}))})}return r}function bz(n,e,t){let i=t.endsWith("Uniforms")?[t,t.slice(0,-8)]:[t,`${t}Uniforms`];for(let r of i){let s=n.getUniformBlockIndex(e,r);if(s!==4294967295){if(!Number.isInteger(s)||s<0)throw new Error(`Failed to resolve WebGL uniform block "${r}": getUniformBlockIndex returned ${String(s)}`);return{blockIndex:s,blockName:r}}}return null}function K2(n,e,t,i){let r=i||n.getActiveUniformBlockName(e,t);if(!r)throw new Error(`Failed to reflect WebGL uniform block at index ${t}: missing block name`);let s=(b,x)=>{let E=n.getActiveUniformBlockParameter(e,t,b);if(E==null)throw new Error(`Failed to reflect WebGL uniform block "${r}": ${x} returned null`);return E},o=os(s(35391,"UNIFORM_BLOCK_BINDING"),r,"UNIFORM_BLOCK_BINDING",0),a=os(s(35392,"UNIFORM_BLOCK_DATA_SIZE"),r,"UNIFORM_BLOCK_DATA_SIZE",0),c=os(s(35394,"UNIFORM_BLOCK_ACTIVE_UNIFORMS"),r,"UNIFORM_BLOCK_ACTIVE_UNIFORMS",0),l=J2(s(35395,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES"),r,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",c),u=$c(n,e,l,35383,"UNIFORM_TYPE",r,c),f=$c(n,e,l,35384,"UNIFORM_SIZE",r,c),d=$c(n,e,l,35386,"UNIFORM_BLOCK_INDEX",r,c),h=$c(n,e,l,35387,"UNIFORM_OFFSET",r,c),p=$c(n,e,l,35388,"UNIFORM_ARRAY_STRIDE",r,c),m=[];for(let b=0;bb.name.split(".")[0]).filter(b=>!!b)),y=g.name.replace(/Uniforms$/,"");if(v.size===1&&!v.has(g.name)&&!v.has(y)){let[b]=v;N.warn(`Uniform block "${g.name}" uses GLSL instance "${b}". luma.gl binds uniform buffers by block name ("${g.name}") and alias ("${y}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}return g}function $c(n,e,t,i,r,s,o){let a=n.getActiveUniforms(e,t,i);if(a===null)throw new Error(`Failed to reflect WebGL uniform block "${s}": ${r} returned null`);return J2(a,s,r,o)}function J2(n,e,t,i){if(!Array.isArray(n)&&!ArrayBuffer.isView(n))throw new Error(`Failed to reflect WebGL uniform block "${e}": ${t} returned a non-array value`);let r=Array.from(n);if(r.length!==i||r.some(s=>!Number.isInteger(s)))throw new Error(`Failed to reflect WebGL uniform block "${e}": ${t} returned ${r.length} invalid values, expected ${i}`);return r}function os(n,e,t,i){if(!Number.isInteger(n)||n{if(typeof o=="string"){let a=e[s];if(!a)throw new Error(`Missing std140 layout field ${s}`);t.push({name:s,format:a.shaderType,arrayLength:1,byteOffset:a.offset*4,byteStride:0});return}if(Array.isArray(o)){r(s,o[0],o[1]);return}for(let[a,c]of Object.entries(o))i(`${s}.${a}`,c)},r=(s,o,a)=>{if(typeof o=="string"){let c=e[`${s}[0]`],l=a>1?e[`${s}[1]`]:void 0;if(!c)throw new Error(`Missing std140 array layout field ${s}[0]`);t.push({name:`${s}[0]`,format:c.shaderType,arrayLength:a,byteOffset:c.offset*4,byteStride:l?(l.offset-c.offset)*4:0});return}if(Array.isArray(o))throw new Error(`Nested uniform arrays are not supported for ${s}`);for(let[c,l]of Object.entries(o)){if(typeof l!="string")throw new Error(`Composite uniform array members are not supported for ${s}`);let u=`${s}[0].${c}`,f=`${s}[1].${c}`,d=e[u],h=a>1?e[f]:void 0;if(!d)throw new Error(`Missing std140 array layout field ${u}`);t.push({name:u,format:d.shaderType,arrayLength:a,byteOffset:d.offset*4,byteStride:h?(h.offset-d.offset)*4:0})}};for(let[s,o]of Object.entries(n))i(s,o);return t}function wz(n){return n.type==="uniform"&&Number.isInteger(n.minBindingSize)&&n.minBindingSize>=0&&Array.isArray(n.uniforms)&&n.uniforms.every(e=>typeof e.name=="string"&&typeof e.format=="string"&&Number.isInteger(e.arrayLength)&&e.arrayLength>0&&Number.isInteger(e.byteOffset)&&e.byteOffset>=0&&Number.isInteger(e.byteStride)&&e.byteStride>=0)}function Ez(n){if(n[n.length-1]!=="]")return{name:n,length:1,isArray:!1};let t=/([^[]*)(\[[0-9]+\])?/.exec(n);return{name:Wi(t?.[1],`Failed to parse GLSL uniform name ${n}`),length:t?.[2]?1:0,isArray:!!t?.[2]}}var eP=C(()=>{J();dd()});function Sz(n,e){let t={...n,attributes:n.attributes.map(i=>({...i})),bindings:n.bindings.map(i=>({...i}))};for(let i of e?.attributes||[]){let r=t.attributes.find(s=>s.name===i.name);r?(r.type=i.type||r.type,r.stepMode=i.stepMode||r.stepMode):N.warn(`shader layout attribute ${i.name} not present in shader`)}for(let i of e?.bindings||[]){let r=nP(t,i.name);if(!r){N.warn(`shader layout binding ${i.name} not present in shader`);continue}Object.assign(r,i)}return t}function nP(n,e){return n.bindings.find(t=>t.name===e||t.name===`${e}Uniforms`||`${t.name}Uniforms`===e)}function tP(n,e){return n[e]||n[`${e}Uniforms`]||n[e.replace(/Uniforms$/,"")]}var hd,iP=C(()=>{J();Y2();ed();Kf();ld();my();eP();hd=class extends Xt{device;handle;vs;fs;introspectedLayout;bindings={};uniforms={};varyings=null;_uniformCount=0;_uniformSetters={};get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}constructor(e,t){super(e,t),this.device=e;let i=this.sharedRenderPipeline||this.device._createSharedRenderPipelineWebGL(t);this.sharedRenderPipeline=i,this.handle=i.handle,this.vs=i.vs,this.fs=i.fs,this.linkStatus=i.linkStatus,this.introspectedLayout=Q2(this.device.gl,this.handle,{uniformBlockLayouts:t._uniformBlockLayouts,shaderLayout:t.shaderLayout}),this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.shaderLayout=t.shaderLayout?Sz(this.introspectedLayout,t.shaderLayout):this.introspectedLayout}destroy(){this.destroyed||(this.sharedRenderPipeline&&!this.props._sharedRenderPipeline&&this.sharedRenderPipeline.destroy(),this.destroyResource())}setBindings(e,t){let i=js(Or(this.shaderLayout,e));for(let[r,s]of Object.entries(i)){let o=nP(this.shaderLayout,r);if(o){switch(s||N.warn(`Unsetting binding "${r}" in render pipeline "${this.id}"`)(),o.type){case"uniform":if(!(s instanceof wn)&&!(s.buffer instanceof wn))throw new Error("buffer value");break;case"texture":if(!(s instanceof ni||s instanceof ii||s instanceof ti))throw new Error(`${this} Bad texture binding for ${r}`);break;case"sampler":N.warn(`Ignoring sampler ${r}`)();break;default:throw new Error(o.type)}this.bindings[r]=s}else{let a=this.shaderLayout.bindings.map(c=>`"${c.name}"`).join(", ");t?.disableWarnings||N.warn(`No binding "${r}" in render pipeline "${this.id}", expected one of ${a}`,s)()}}}draw(e){let t=e.renderPass,i=e.bindGroups?js(e.bindGroups):e.bindings||this.bindings;return t.setPipeline(this),t.setBindings(i),t.setVertexArray(e.vertexArray),t.draw({parameters:e.parameters,topology:e.topology,isInstanced:e.isInstanced,vertexCount:e.vertexCount,indexCount:e.indexCount,instanceCount:e.instanceCount,firstVertex:e.firstVertex,firstIndex:e.firstIndex,firstInstance:e.firstInstance,baseVertex:e.baseVertex,transformFeedback:e.transformFeedback,uniforms:e.uniforms})}_areTexturesRenderable(e){let t=!0;for(let i of this.shaderLayout.bindings)tP(e,i.name)||(N.warn(`Binding ${i.name} not found in ${this.id}`)(),t=!1);return t}_applyBindings(e,t){if(this._syncLinkStatus(),this.linkStatus!=="success")return;let{gl:i}=this.device;i.useProgram(this.handle);let r=0,s=0;for(let o of this.shaderLayout.bindings){let a=tP(e,o.name);if(!a)throw new Error(`No value for binding ${o.name} in ${this.id}`);switch(o.type){case"uniform":let{name:c}=o,l=i.getUniformBlockIndex(this.handle,c);if(l===4294967295)throw new Error(`Invalid uniform block name ${c}`);if(i.uniformBlockBinding(this.handle,l,s),a instanceof wn)i.bindBufferBase(35345,s,a.handle);else{let f=a;i.bindBufferRange(35345,s,f.buffer.handle,f.offset||0,f.size||f.buffer.byteLength-(f.offset||0))}s+=1;break;case"texture":if(!(a instanceof ni||a instanceof ii||a instanceof ti))throw new Error("texture");let u;if(a instanceof ni)u=a.texture;else if(a instanceof ii)u=a;else if(a instanceof ti&&a.colorAttachments[0]instanceof ni)N.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),u=a.colorAttachments[0].texture;else throw new Error("No texture");i.activeTexture(33984+r),i.bindTexture(u.glTarget,u.handle),r+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${o.type}' not supported in WebGL`)}}}_applyUniforms(e){for(let t of this.shaderLayout.uniforms||[]){let{name:i,location:r,type:s,textureUnit:o}=t,a=e[i]??o;a!==void 0&&H2(this.device.gl,r,s,a)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}}});var rP,pd,sP=C(()=>{J();dd();rP=4,pd=class extends ka{device;handle;vs;fs;linkStatus="pending";constructor(e,t){super(e,t),this.device=e,this.handle=t.handle||this.device.gl.createProgram(),this.vs=t.vs,this.fs=t.fs,t.varyings&&t.varyings.length>0&&this.device.gl.transformFeedbackVaryings(this.handle,t.varyings,t.bufferMode||35981),this._linkShaders()}destroy(){this.destroyed||(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.handle.destroyed=!0,this.destroyResource())}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),N.time(rP,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),N.timeEnd(rP,`linkProgram for ${this.id}`)(),!this.device.features.has("compilation-status-async-webgl")){let i=this._getLinkStatus();this._reportLinkStatus(i);return}N.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),N.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let t=this._getLinkStatus();this._reportLinkStatus(t)}async _reportLinkStatus(e){switch(e){case"success":return;default:let t=e==="link-error"?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${t} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader();break;case"success":break}switch(this.fs?.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`${this} ${t} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader();break;case"success":break}let i=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${t} during ${e}: ${i}`),this)(),this.device.debug()}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(this._initializeSamplerUniforms(),e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}_initializeSamplerUniforms(){let{gl:e}=this.device;e.useProgram(this.handle);let t=0,i=e.getProgramParameter(this.handle,35718);for(let r=0;r1){let o=Int32Array.from({length:t.size},(a,c)=>r+c);return s.uniform1iv(e,o),r+t.size}return s.uniform1i(e,r),r+1}async _waitForLinkComplete(){let e=async r=>await new Promise(s=>setTimeout(s,r));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getProgramParameter(this.handle,37297))return;await e(10)}}}});function Pz(n,e){let t=e.sourceBuffer,i=e.destinationBuffer;n.gl.bindBuffer(36662,t.handle),n.gl.bindBuffer(36663,i.handle),n.gl.copyBufferSubData(36662,36663,e.sourceOffset??0,e.destinationOffset??0,e.size),n.gl.bindBuffer(36662,null),n.gl.bindBuffer(36663,null)}function Cz(n,e){let{sourceBuffer:t,byteOffset:i=0,destinationTexture:r,mipLevel:s=0,origin:o=[0,0,0],aspect:a="all",bytesPerRow:c,rowsPerImage:l,size:u}=e;if(a!=="all")throw new Error("copyBufferToTexture aspect is not supported in WebGL");r.writeBuffer(t,{byteOffset:i,bytesPerRow:c,rowsPerImage:l,mipLevel:s,x:o[0]??0,y:o[1]??0,z:o[2]??0,width:u[0],height:u[1],depthOrArrayLayers:u[2]})}function Tz(n,e){let{sourceTexture:t,mipLevel:i=0,aspect:r="all",width:s=e.sourceTexture.width,height:o=e.sourceTexture.height,depthOrArrayLayers:a,origin:c=[0,0,0],destinationBuffer:l,byteOffset:u=0,bytesPerRow:f,rowsPerImage:d}=e;if(t instanceof me){t.readBuffer({x:c[0]??0,y:c[1]??0,z:c[2]??0,width:s,height:o,depthOrArrayLayers:a,mipLevel:i,aspect:r,byteOffset:u},l);return}if(r!=="all")throw new Error("aspect not supported in WebGL");if(i!==0||a!==void 0||f||d)throw new Error("not implemented");let{framebuffer:h,destroyFramebuffer:p}=oP(t),m;try{let g=l,v=s||h.width,y=o||h.height,b=Wi(h.colorAttachments[0]),x=qf(b.texture.props.format),E=x.format,w=x.type;n.gl.bindBuffer(35051,g.handle),m=n.gl.bindFramebuffer(36160,h.handle),n.gl.readPixels(c[0],c[1],v,y,E,w,u)}finally{n.gl.bindBuffer(35051,null),m!==void 0&&n.gl.bindFramebuffer(36160,m),p&&h.destroy()}}function Lz(n,e){let{sourceTexture:t,destinationMipLevel:i=0,origin:r=[0,0],destinationOrigin:s=[0,0,0],destinationTexture:o}=e,{width:a=e.destinationTexture.width,height:c=e.destinationTexture.height}=e,{framebuffer:l,destroyFramebuffer:u}=oP(t),[f=0,d=0]=r,[h,p,m]=s,g=n.gl.bindFramebuffer(36160,l.handle),v,y;if(o instanceof ii)v=o,a=Number.isFinite(a)?a:v.width,c=Number.isFinite(c)?c:v.height,v._bind(0),y=v.glTarget;else throw new Error("invalid destination");switch(y){case 3553:case 34067:n.gl.copyTexSubImage2D(y,i,h,p,f,d,a,c);break;case 35866:case 32879:n.gl.copyTexSubImage3D(y,i,h,p,m,f,d,a,c);break;default:}v&&v._unbind(),n.gl.bindFramebuffer(36160,g),u&&l.destroy()}function oP(n){if(n instanceof me){let{width:e,height:t,id:i}=n;return{framebuffer:n.device.createFramebuffer({id:`framebuffer-for-${i}`,width:e,height:t,colorAttachments:[n]}),destroyFramebuffer:!0}}return{framebuffer:n,destroyFramebuffer:!1}}var md,aP=C(()=>{J();Lo();ld();md=class extends Ba{device;handle=null;commands=[];constructor(e,t={}){super(e,t),this.device=e}_executeCommands(e=this.commands){for(let t of e)switch(t.name){case"copy-buffer-to-buffer":Pz(this.device,t.options);break;case"copy-buffer-to-texture":Cz(this.device,t.options);break;case"copy-texture-to-buffer":Tz(this.device,t.options);break;case"copy-texture-to-texture":Lz(this.device,t.options);break;default:throw new Error(t.name)}}}});function cP(n){switch(n){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"triangle-list":return 4;case"triangle-strip":return 5;default:throw new Error(n)}}function lP(n){switch(n){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;default:throw new Error(n)}}var _y=C(()=>{});var Mz,gd,uP=C(()=>{J();ad();Po();_y();fy();Mz=[1,2,4,8],gd=class extends Ra{device;handle=null;glParameters={};pipeline=null;bindings={};bindingsPipeline=null;vertexArray=null;constructor(e,t){super(e,t),this.device=e;let i=this.props.framebuffer,r=!i||i.handle===null;r&&e.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();let s;if(!t?.parameters?.viewport)if(!r&&i){let{width:o,height:a}=i;s=[0,0,o,a]}else{let[o,a]=e.getDefaultCanvasContext().getDrawingBufferSize();s=[0,0,o,a]}if(this.device.pushState(),this.setParameters({viewport:s,...this.props.parameters}),!r&&i?.colorAttachments.length){let o=i.colorAttachments.map((a,c)=>36064+c);this.device.gl.drawBuffers(o)}else r&&this.device.gl.drawBuffers([1029]);this.clear(),this.props.timestampQuerySet&&this.props.beginTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.beginTimestampIndex)}end(){this.destroyed||(this.props.timestampQuerySet&&this.props.endTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.endTimestampIndex),this.device.popState(),this.destroy())}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}executeBundles(e){throw new Error("Render bundles are only supported in WebGPU")}setParameters(e={}){let t={...this.glParameters};t.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(t.depthMask=!this.props.depthReadOnly),t.stencilMask=this.props.stencilReadOnly?0:1,t[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(t.viewport=e.viewport.slice(0,4),t.depthRange=[e.viewport[4],e.viewport[5]]):t.viewport=e.viewport),e.scissorRect&&(t.scissorTest=!0,t.scissor=e.scissorRect),e.blendConstant&&(t.blendColor=e.blendConstant),e.stencilReference!==void 0&&(t[2967]=e.stencilReference,t[36003]=e.stencilReference),"colorMask"in e&&(t.colorMask=Mz.map(i=>!!(i&e.colorMask))),this.glParameters=t,bn(this.device.gl,t)}setPipeline(e){this.pipeline=e}setBindings(e,t){if(!this.pipeline)throw new Error("RenderPass.setPipeline() must be called before setBindings()");this.bindings=js(Or(this.pipeline.shaderLayout,e)),this.bindingsPipeline=this.pipeline}setVertexArray(e){this.vertexArray=e}draw(e){let t=this.pipeline,i=this.vertexArray;if(!t)throw new Error("RenderPass.setPipeline() must be called before draw()");if(!i)throw new Error("RenderPass.setVertexArray() must be called before draw()");if(t.shaderLayout.bindings.length>0&&this.bindingsPipeline!==t)throw new Error("RenderPass.setBindings() must be called after setPipeline() before draw()");t._syncLinkStatus();let{parameters:r=t.props.parameters,topology:s=t.props.topology,vertexCount:o,indexCount:a,instanceCount:c,isInstanced:l=!1,firstVertex:u=0,transformFeedback:f,uniforms:d=t.uniforms}=e,h=cP(s),p=!!i.indexBuffer,m=i.indexBuffer?.glIndexType,g=a??o??0;if(t.linkStatus!=="success")return N.info(2,`RenderPipeline:${t.id}.draw() aborted - waiting for shader linking`)(),!1;if(!t._areTexturesRenderable(this.bindings))return N.info(2,`RenderPipeline:${t.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(t.handle),i.bindBeforeRender(this);let v=f;return v&&v.begin(t.props.topology),t._applyBindings(this.bindings,{disableWarnings:t.props.disableWarnings}),t._applyUniforms(d),W2(this.device,r,this.glParameters,()=>{p&&l?this.device.gl.drawElementsInstanced(h,g,m,u,c||0):p?this.device.gl.drawElements(h,g,m,u):l?this.device.gl.drawArraysInstanced(h,u,o||0,c||0):this.device.gl.drawArrays(h,u,o||0),v&&v.end()}),i.unbindAfterRender(this),!0}drawIndirect(e,t=0){throw new Error("Indirect drawing is only supported in WebGPU")}drawIndexedIndirect(e,t=0){throw new Error("Indirect drawing is only supported in WebGPU")}beginOcclusionQuery(e){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let e={...this.glParameters},t=0;this.props.clearColors&&this.props.clearColors.forEach((i,r)=>{i&&this.clearColorBuffer(r,i)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(t|=16384,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(t|=256,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(t|=1024,e.clearStencil=this.props.clearStencil),t!==0&&En(this.device.gl,e,()=>{this.device.gl.clear(t)})}clearColorBuffer(e=0,t=[0,0,0,0]){En(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,e,t);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,e,t);break;case Float32Array:this.device.gl.clearBufferfv(6144,e,t);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}});var Gc,fP=C(()=>{J();aP();uP();Gc=class extends Ia{device;handle=null;commandBuffer;constructor(e,t){super(e,t),this.device=e,this.commandBuffer=new md(e,{id:this.id,userData:this.userData})}destroy(){this.destroyResource()}finish(){return this.destroy(),this.commandBuffer}beginRenderPass(e={}){return new gd(this.device,this._applyTimeProfilingToPassProps(e))}beginComputePass(e={}){throw new Error("ComputePass not supported in WebGL")}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,t,i){throw new Error("resolveQuerySet is not supported in WebGL")}writeTimestamp(e,t){e.writeTimestamp(t)}}});function dP(n){let{target:e,source:t,start:i=0,count:r=1}=n,s=t.length,o=r*s,a=0;for(let c=i;a{});function Az(n){return Array.isArray(n)?new Float32Array(n):n}function kz(n,e){if(!n||!e||n.length!==e.length||n.constructor!==e.constructor)return!1;for(let t=0;t{J();vr();iy();hP();_d=class n extends Oa{get[Symbol.toStringTag](){return"VertexArray"}device;handle;attributeInfosByLocation;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return mp()==="Chrome"}constructor(e,t){super(e,t),this.device=e,this.handle=this.device.gl.createVertexArray(),this.attributeInfosByLocation=new Array(this.maxVertexAttributes).fill(null);for(let i of Object.values($a(t.shaderLayout,t.bufferLayout)))this.attributeInfosByLocation[i.location]=i}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){let t=e;if(t&&t.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,t?t.handle:null),this.indexBuffer=t,this.device.gl.bindVertexArray(null)}setBuffer(e,t){let i=t;if(i.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:r,type:s,stride:o,offset:a,normalized:c,integer:l,divisor:u}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,i.handle),l?this.device.gl.vertexAttribIPointer(e,r,s,o,a):this.device.gl.vertexAttribPointer(e,r,s,c,o,a),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,u||0),this.attributes[e]=i,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,t){this._enable(e,!1),this.attributes[e]=t}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e{J();bd();_y();yd=class extends Da{device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(e,t){super(e,t),this.device=e,this.gl=e.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,t.buffers&&this.setBuffers(t.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(e="point-list"){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(lP(e))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(e){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let[t,i]of Object.entries(e))this.setBuffer(t,i)})}setBuffer(e,t){let i=this._getVaryingIndex(e),{buffer:r,byteLength:s,byteOffset:o}=this._getBufferRange(t);if(i<0){this.unusedBuffers[e]=r,N.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[i]={buffer:r,byteLength:s,byteOffset:o},this.bindOnUse||this._bindBuffer(i,r,o,s)}getBuffer(e){if(mP(e))return this.buffers[e]||null;let t=this._getVaryingIndex(e);return this.buffers[t]??null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(36386,e),this;let t;return this._bound?t=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,t=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),t}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof wn)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:t,byteOffset:i=0,byteLength:r=e.buffer.byteLength}=e;return{buffer:t,byteOffset:i,byteLength:r}}_getVaryingIndex(e){if(mP(e))return Number(e);for(let t of this.layout.varyings||[])if(e===t.name)return t.location;return-1}_bindBuffers(){for(let[e,t]of Object.entries(this.buffers)){let{buffer:i,byteLength:r,byteOffset:s}=this._getBufferRange(t);this._bindBuffer(Number(e),i,s,r)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,t,i=0,r){let s=t&&t.handle;!s||r===void 0?this.gl.bindBufferBase(35982,e,s):this.gl.bindBufferRange(35982,e,s,i,r)}}});var vd,_P=C(()=>{J();vd=class extends Na{device;handle;_timestampPairs=[];_pendingReads=new Set;_occlusionQuery=null;_occlusionActive=!1;get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){if(super(e,t),this.device=e,t.type==="timestamp"){if(t.count<2)throw new Error("Timestamp QuerySet requires at least two query slots");this._timestampPairs=new Array(Math.ceil(t.count/2)).fill(null).map(()=>({activeQuery:null,completedQueries:[]})),this.handle=null}else{if(t.count>1)throw new Error("WebGL occlusion QuerySet can only have one value");let i=this.device.gl.createQuery();if(!i)throw new Error("WebGL query not supported");this.handle=i}Object.seal(this)}destroy(){if(!this.destroyed){this.handle&&this.device.gl.deleteQuery(this.handle);for(let e of this._timestampPairs){e.activeQuery&&(this._cancelPendingQuery(e.activeQuery),this.device.gl.deleteQuery(e.activeQuery.handle));for(let t of e.completedQueries)this._cancelPendingQuery(t),this.device.gl.deleteQuery(t.handle)}this._occlusionQuery&&(this._cancelPendingQuery(this._occlusionQuery),this.device.gl.deleteQuery(this._occlusionQuery.handle));for(let e of Array.from(this._pendingReads))this._cancelPendingQuery(e);this.destroyResource()}}isResultAvailable(e){return this.props.type==="timestamp"?e===void 0?this._timestampPairs.some((t,i)=>this._isTimestampPairAvailable(i)):this._isTimestampPairAvailable(this._getTimestampPairIndex(e)):this._occlusionQuery?this._pollQueryAvailability(this._occlusionQuery):!1}async readResults(e){let t=e?.firstQuery||0,i=e?.queryCount||this.props.count-t;if(this._validateRange(t,i),this.props.type==="timestamp"){let r=new Array(i).fill(0n),s=Math.floor(t/2),o=Math.floor((t+i-1)/2);for(let a=s;a<=o;a++){let c=await this._consumeTimestampPairResult(a),l=a*2,u=l+1;l>=t&&l=t&&u=this.props.count||t<=e)throw new Error("Timestamp duration range is out of bounds");if(e%2!==0||t!==e+1)throw new Error("WebGL timestamp durations require adjacent even/odd query indices");let i=await this._consumeTimestampPairResult(this._getTimestampPairIndex(e));return Number(i)/1e6}beginOcclusionQuery(){if(this.props.type!=="occlusion")throw new Error("Occlusion queries require an occlusion QuerySet");if(!this.handle)throw new Error("WebGL occlusion query is not available");if(this._occlusionActive)throw new Error("Occlusion query is already active");this.device.gl.beginQuery(35887,this.handle),this._occlusionQuery={handle:this.handle,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null},this._occlusionActive=!0}endOcclusionQuery(){if(!this._occlusionActive)throw new Error("Occlusion query is not active");this.device.gl.endQuery(35887),this._occlusionActive=!1}writeTimestamp(e){if(this.props.type!=="timestamp")throw new Error("Timestamp writes require a timestamp QuerySet");let t=this._getTimestampPairIndex(e),i=this._timestampPairs[t];if(e%2===0){if(i.activeQuery)throw new Error("Timestamp query pair is already active");let r=this.device.gl.createQuery();if(!r)throw new Error("WebGL query not supported");let s={handle:r,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null};this.device.gl.beginQuery(35007,r),i.activeQuery=s;return}if(!i.activeQuery)throw new Error("Timestamp query pair was ended before it was started");this.device.gl.endQuery(35007),i.completedQueries.push(i.activeQuery),i.activeQuery=null}_validateRange(e,t){if(e<0||t<0||e+t>this.props.count)throw new Error("Query read range is out of bounds")}_getTimestampPairIndex(e){if(e<0||e>=this.props.count)throw new Error("Query index is out of bounds");return Math.floor(e/2)}_isTimestampPairAvailable(e){let t=this._timestampPairs[e];return!t||t.completedQueries.length===0?!1:this._pollQueryAvailability(t.completedQueries[0])}_pollQueryAvailability(e){if(e.cancelled||this.destroyed)return e.result=0n,!0;if(e.result!==null||e.disjoint)return!0;if(!this.device.gl.getQueryParameter(e.handle,34919))return!1;let i=!!this.device.gl.getParameter(36795);return e.disjoint=i,e.result=i?0n:BigInt(this.device.gl.getQueryParameter(e.handle,34918)),!0}async _consumeTimestampPairResult(e){let t=this._timestampPairs[e];if(!t||t.completedQueries.length===0)throw new Error("Timestamp query pair has no completed result");let i=t.completedQueries.shift();try{return await this._consumeQueryResult(i)}finally{this.device.gl.deleteQuery(i.handle)}}_consumeQueryResult(e){return e.promise||(this._pendingReads.add(e),e.promise=new Promise((t,i)=>{e.resolve=t,e.reject=i;let r=()=>{if(e.pollRequestId=null,e.cancelled||this.destroyed){this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,t(0n);return}if(!this._pollQueryAvailability(e)){e.pollRequestId=this._requestAnimationFrame(r);return}this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,e.disjoint?i(new Error("GPU timestamp query was invalidated by a disjoint event")):t(e.result||0n)};r()})),e.promise}_cancelPendingQuery(e){if(this._pendingReads.delete(e),e.cancelled=!0,e.pollRequestId!==null&&(this._cancelAnimationFrame(e.pollRequestId),e.pollRequestId=null),e.resolve){let t=e.resolve;e.promise=null,e.resolve=null,e.reject=null,t(0n)}}_requestAnimationFrame(e){return requestAnimationFrame(e)}_cancelAnimationFrame(e){cancelAnimationFrame(e)}}});var xd,yP=C(()=>{J();xd=class extends Fa{device;gl;handle;signaled;_signaled=!1;constructor(e,t={}){super(e,{}),this.device=e,this.gl=e.gl;let i=this.props.handle||this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE,0);if(!i)throw new Error("Failed to create WebGL fence");this.handle=i,this.signaled=new Promise(r=>{let s=()=>{let o=this.gl.clientWaitSync(this.handle,0,0);o===this.gl.ALREADY_SIGNALED||o===this.gl.CONDITION_SATISFIED?(this._signaled=!0,r()):setTimeout(s,1)};s()})}isSignaled(){if(this._signaled)return!0;let e=this.gl.getSyncParameter(this.handle,this.gl.SYNC_STATUS);return this._signaled=e===this.gl.SIGNALED,this._signaled}destroy(){this.destroyed||this.gl.deleteSync(this.handle)}}});function yy(n){switch(n){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function bP(n){switch(n){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}var vP=C(()=>{});function xP(n,e){let{sourceX:t=0,sourceY:i=0,sourceAttachment:r=0}=e||{},{target:s=null,sourceWidth:o,sourceHeight:a,sourceDepth:c,sourceFormat:l,sourceType:u}=e||{},{framebuffer:f,deleteFramebuffer:d}=EP(n),{gl:h,handle:p}=f;o||=f.width,a||=f.height;let m=f.colorAttachments[r]?.texture;if(!m)throw new Error(`Invalid framebuffer attachment ${r}`);c=m?.depth||1,l||=m?.glFormat||6408,u||=m?.glType||5121,s=Iz(s,u,l,o,a,c);let g=Xe.getDataType(s);u=u||q2(g);let v=h.bindFramebuffer(36160,p);return h.readBuffer(36064+r),h.readPixels(t,i,o,a,l,u,s),h.readBuffer(36064),h.bindFramebuffer(36160,v||null),d&&f.destroy(),s}function wP(n,e){let{target:t,sourceX:i=0,sourceY:r=0,sourceFormat:s=6408,targetByteOffset:o=0}=e||{},{sourceWidth:a,sourceHeight:c,sourceType:l}=e||{},{framebuffer:u,deleteFramebuffer:f}=EP(n);a=a||u.width,c=c||u.height;let d=u;l=l||5121;let h=t;if(!h){let m=yy(s),g=bP(l),v=o+a*c*m*g;h=d.device.createBuffer({byteLength:v})}let p=n.device.createCommandEncoder();return p.copyTextureToBuffer({sourceTexture:n,width:a,height:c,origin:[i,r],destinationBuffer:h,byteOffset:o}),p.destroy(),f&&u.destroy(),h}function EP(n){return n instanceof Rr?{framebuffer:n,deleteFramebuffer:!1}:{framebuffer:Rz(n),deleteFramebuffer:!0}}function Rz(n,e){let{device:t,width:i,height:r,id:s}=n;return t.createFramebuffer({...e,id:`framebuffer-for-${s}`,width:i,height:r,colorAttachments:[n]})}function Iz(n,e,t,i,r,s){if(n)return n;e||=5121;let o=cd(e),a=Xe.getTypedArrayConstructor(o),c=yy(t);return new a(i*r*c)}var SP=C(()=>{J();dd();vP();gy()});function PP(n){let e=new Map;for(let t in n){let i=n[t];if(t<"a"){let r=e.get(i);e.set(i,r?`${r}, GL.${t}`:`GL.${t}`)}}return e}var CP=C(()=>{});var by={};mi(by,{WebGLDevice:()=>nr});function Bz(n,e,t){switch(t.length){case 1:n.gl.vertexAttrib1fv(e,t);break;case 2:n.gl.vertexAttrib2fv(e,t);break;case 3:n.gl.vertexAttrib3fv(e,t);break;case 4:n.gl.vertexAttrib4fv(e,t);break;default:}}function Oz(n,e,t){n.gl.vertexAttribI4iv(e,t)}function Dz(n,e,t){n.gl.vertexAttribI4uiv(e,t)}function Nz(n,e){if(!n||!e||n.length!==e.length||n.constructor!==e.constructor)return!1;for(let t=0;t{J();ty();E2();ny();C2();B2();O2();D2();N2();X_();Lo();z2();ed();G2();j2();ld();Kf();iP();sP();fP();pP();gP();_P();yP();SP();Po();ad();Nc();CP();nr=class n extends bi{static getDeviceFromContext(e){return e?e.luma?.device??null:null}type="webgl";handle;features;limits;info;canvasContext;preferredColorFormat="rgba8unorm";preferredDepthFormat="depth24plus";commandEncoder;lost;_resolveContextLost;_isLost=!1;gl;_glKeyByValue=null;_constants;extensions;_polyfilled=!1;spectorJS;get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(e){switch(e){case"unorm8x4-bgra":return!1;default:return!0}}constructor(e){super({...e,id:e.id||F2("webgl-device")});let t=bi._getCanvasContextProps(e);if(!t)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let i=t.canvas?.gl??null,r=n.getDeviceFromContext(i);if(r)throw new Error(`WebGL context already attached to device ${r.id}`);this.canvasContext=new Qf(this,t),this.lost=new Promise(u=>{this._resolveContextLost=u});let s={...e.webgl};t.alphaMode==="premultiplied"&&(s.premultipliedAlpha=!0),e.powerPreference!==void 0&&(s.powerPreference=e.powerPreference),e.failIfMajorPerformanceCaveat!==void 0&&(s.failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat);let a=this.props._handle||w2(this.canvasContext.canvas,{onContextLost:u=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."}),onContextRestored:u=>{console.log("WebGL context restored")}},s);if(!a)throw new Error("WebGL context creation failed");if(r=n.getDeviceFromContext(a),r){if(e._reuseDevices)return N.log(1,`Not creating a new Device, instead returning a reference to Device ${r.id} already attached to WebGL context`,r)(),this.canvasContext.destroy(),r._reused=!0,r;throw new Error(`WebGL context already attached to device ${r.id}`)}this.handle=a,this.gl=a,this.spectorJS=f2({...this.props,gl:this.handle});let c=Dc(this.handle);c.device=this,c.extensions||(c.extensions={}),this.extensions=c.extensions,this.info=S2(this.gl,this.extensions),this.limits=new Xf(this.gl),this.features=new Zf(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new vn(this.gl,{log:(...u)=>N.log(1,...u)()}).trackState(this.gl,{copyState:!1}),(e.debug||e.debugWebGL)&&(this.gl=l2(this.gl,{debugWebGL:!0,traceWebGL:e.debugWebGL}),N.warn("WebGL debug mode activated. Performance reduced.")()),e.debugWebGL&&(N.level=Math.max(N.level,1)),this.commandEncoder=new Gc(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}destroy(){if(!this.props._reuseDevices&&!this._reused){this._isLost=!0,this.commandEncoder?.destroy();let e=Dc(this.handle);e.device=null}}get isLost(){return this._isLost||this.gl.isContextLost()}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createPresentationContext(e){return new Jf(this,e||{})}createBuffer(e){let t=this._normalizeBufferProps(e);return new wn(this,t)}createTexture(e){return new ii(this,e)}createExternalTexture(e){throw new Error("ExternalTexture is not available on WebGL")}createSampler(e){return new od(this,e)}createShader(e){return new nd(this,e)}createFramebuffer(e){return new ti(this,e)}createVertexArray(e){return new _d(this,e)}createTransformFeedback(e){return new yd(this,e)}createQuerySet(e){return new vd(this,e)}createFence(){return new xd(this)}createRenderPipeline(e){return new hd(this,e)}_createSharedRenderPipelineWebGL(e){return new pd(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}createRenderBundleEncoder(e){throw new Error("Render bundles are only supported in WebGPU")}createCommandEncoder(e={}){return new Gc(this,e)}submit(e){let t=null;e||({submittedCommandEncoder:t,commandBuffer:e}=this._finalizeDefaultCommandEncoderForSubmit());try{e._executeCommands(),t&&t.resolveTimeProfilingQuerySet().then(()=>{this.commandEncoder._gpuTimeMs=t._gpuTimeMs}).catch(()=>{})}finally{e.destroy()}}writeBufferViaCommandEncoder(e,t,i,r=0){t.write(i,r)}_finalizeDefaultCommandEncoderForSubmit(){let e=this.commandEncoder,t=e.finish();return this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:e.props.id,timeProfilingQuerySet:e.getTimeProfilingQuerySet()}),{submittedCommandEncoder:e,commandBuffer:t}}readPixelsToArrayWebGL(e,t){return xP(e,t)}readPixelsToBufferWebGL(e,t){return wP(e,t)}setParametersWebGL(e){bn(this.gl,e)}getParametersWebGL(e){return Vf(this.gl,e)}withParametersWebGL(e,t){return En(this.gl,e,t)}resetWebGL(){N.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),_2(this.gl)}_getDeviceSpecificTextureFormatCapabilities(e){return k2(this.gl,e,this.extensions)}loseDevice(){let e=!1,i=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return i&&(e=!0,i.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){vn.get(this.gl).push()}popState(){vn.get(this.gl).pop()}getGLKey(e,t){let i=this._getGLKeyByValue().get(Number(e));return i||(t?.emptyIfUnknown?"":String(e))}getGLKeys(e){let t={emptyIfUnknown:!0};return Object.entries(e).reduce((i,[r,s])=>(i[`${r}:${this.getGLKey(r,t)}`]=`${s}:${this.getGLKey(s,t)}`,i),{})}_getGLKeyByValue(){return this._glKeyByValue??=PP(this.gl),this._glKeyByValue}setConstantAttributeWebGL(e,t){let i=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(i).fill(null);let r=this._constants[e];switch(r&&Nz(r,t)&&N.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=t,t.constructor){case Float32Array:Bz(this,e,t);break;case Int32Array:Oz(this,e,t);break;case Uint32Array:Dz(this,e,t);break;default:throw new Error("constant")}}getExtension(e){return xn(this.gl,e,this.extensions),this.extensions}_setWebGLDebugMetadata(e,t,i){e.luma=t;let r={props:i.spector,id:i.spector.id};e.__SPECTOR_Metadata=r}}});function Fz(n){return typeof WebGL2RenderingContext<"u"&&n instanceof WebGL2RenderingContext?!0:!!(n&&typeof n.createVertexArray=="function")}function TP(n){return{...n,debug:n.debug??bi.defaultProps.debug,debugWebGL:n.debugWebGL??bi.defaultProps.debugWebGL,debugSpectorJS:n.debugSpectorJS??!!N.get("debug-spectorjs")}}async function LP(n){let e=[];(n.debugWebGL||n.debug)&&e.push(c2()),n.debugSpectorJS&&e.push(u2(n));let t=await Promise.allSettled(e);for(let i of t)i.status==="rejected"&&N.error(`Failed to initialize debug libraries ${i.reason}`)()}var Vc,vy,Wc,MP=C(()=>{J();o2();X_();Vc=1,vy=class extends Ea{type="webgl";enforceWebGL2(e){s2(e)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext&&N.warn("WebGL1 is not supported",e)(),!1)}async attach(e,t={}){let{WebGLDevice:i}=await Promise.resolve().then(()=>(wd(),by));if(e instanceof i)return e;let r=i.getDeviceFromContext(e);if(r)return r;if(!Fz(e))throw new Error("Invalid WebGL2RenderingContext");t=TP(t),await LP(t);let s=t.createCanvasContext===!0?{}:t.createCanvasContext;return new i({...t,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...s}})}async create(e={}){let{WebGLDevice:t}=await Promise.resolve().then(()=>(wd(),by));e=TP(e),await LP(e);try{let i=new t(e);N.groupCollapsed(Vc,`WebGLDevice ${i.id} created`)();let r=`${i._reused?"Reusing":"Created"} device with WebGL2 ${i.props.debug?"debug ":""}context: ${i.info.vendor}, ${i.info.renderer} for canvas: ${i.canvasContext.id}`;return N.probe(Vc,r)(),N.table(Vc,i.info)(),i}finally{N.groupEnd(Vc)(),N.info(Vc,"%cWebGL call tracing: luma.log.set('debug-webgl') ","color: white; background: blue; padding: 2px 6px; border-radius: 3px;")()}}};Wc=new vy});var bd=C(()=>{MP();wd();ed()});function Td(n){return FP.test(n)}function Ld(n){return zP.test(n)}function UP(n){let e=FP.exec(n),t=zP.exec(n),i=e?.[1]??t?.[1]??n;try{Pe.getVertexFormatInfo(i)}catch{throw new Error(`Unsupported GPUVector format ${n}`)}return i}function Ti(n){let e=UP(n),t=Td(n),i=Ld(n),r=Pe.getVertexFormatInfo(e),s=r.type,o=r.normalized,a=Vz(s,o);return{format:n,elementFormat:e,vertexList:t,valueList:i,type:s,signedDataType:Wz(e,s),primitiveType:a,components:r.components,byteLength:r.byteLength,integer:r.integer,signed:r.signed,normalized:o,...r.webglOnly?{webglOnly:!0}:{}}}function Vz(n,e){if(e)return"f32";switch(n){case"float32":return"f32";case"float16":return"f16";case"uint8":case"uint16":case"uint32":return"u32";case"sint8":case"sint16":case"sint32":return"i32";default:throw new Error(`Unsupported GPUVector component type ${n}`)}}function Wz(n,e){if(n==="unorm10-10-10-2")return"uint32";switch(e){case"unorm8":return"uint8";case"snorm8":return"sint8";case"unorm16":return"uint16";case"snorm16":return"sint16";default:return e}}var FP,zP,Md=C(()=>{J();FP=/^vertex-list<([^<>]+)>$/,zP=/^value-list<([^<>]+)>$/});function Ey(n,e){if(!Number.isSafeInteger(n)||n<0)throw new Error(`${e} must be a non-negative safe integer`)}var Li,Sy=C(()=>{J();Li=class{buffer;format;length;byteOffset;byteStride;constructor(e){let t=Pe.getVertexFormatInfo(e.format).byteLength,i=e.byteOffset??0,r=e.byteStride??t;if(Ey(e.length,"GPUDataView length"),Ey(i,"GPUDataView byteOffset"),Ey(r,"GPUDataView byteStride"),re.buffer.byteLength)throw new Error("GPUDataView exceeds its backing buffer byte length");this.buffer=e.buffer,this.format=e.format,this.length=e.length,this.byteOffset=i,this.byteStride=r}get elementByteLength(){return Pe.getVertexFormatInfo(this.format).byteLength}get byteLength(){return this.length===0?0:(this.length-1)*this.byteStride+this.elementByteLength}}});function kd(n){return!!(n&&typeof n=="object"&&n.type==="struct")}function GP(n,e){let t=Object.entries(n);if(t.length===0)throw new Error("GPUData struct format must declare at least one field");return e==="packed"?jz(t):Hz(t)}function jz(n){let e=[],t=0,i=0;for(let[r,s]of n){let o=Pe.getVertexFormatInfo(s);if(o.webglOnly)throw new Error(`Packed GPUData struct field "${r}" uses WebGL-only format ${s}`);t=$P(t,Math.min(4,o.byteLength)),e.push([r,Object.freeze({format:s,byteOffset:t,byteLength:o.byteLength})]),t+=o.byteLength,i+=o.components}return Object.freeze({type:"struct",layout:"packed",fields:Object.freeze(Object.fromEntries(e)),components:i,byteStride:$P(t,4),rowByteLength:t})}function Hz(n){let e=Object.fromEntries(n.map(([o,a])=>[o,Yz(a)])),t=Dr(e,{layout:"wgsl-storage"}),i=[],r=0,s=0;for(let[o,a]of n){let c=Pe.getVertexFormatInfo(a),l=t.fields[o].offset*4;i.push([o,Object.freeze({format:a,byteOffset:l,byteLength:c.byteLength})]),r=Math.max(r,l+c.byteLength),s+=c.components}return Object.freeze({type:"struct",layout:"wgsl-storage",fields:Object.freeze(Object.fromEntries(i)),components:s,byteStride:t.byteLength,rowByteLength:r})}function Yz(n){let e=Pe.getVertexFormatInfo(n);switch(e.type){case"float32":return Ad("f32",e.components);case"sint32":return Ad("i32",e.components);case"uint32":return Ad("u32",e.components);default:{let t=Math.ceil(e.byteLength/4);return Ad("u32",t)}}}function Ad(n,e){return e===1?n:`vec${e}<${n}>`}function $P(n,e){return Math.ceil(n/e)*e}var VP=C(()=>{J()});var Py,Cy,Mo,Ty=C(()=>{Sy();VP();Md();Py=class{buffer;ownsDataBuffer;constructor(e,t){this.buffer=e,this.ownsDataBuffer=t}get ownsBuffer(){return this.ownsDataBuffer}transferBufferOwnership(e){if(e.buffer!==this.buffer)throw new Error("GPUData ownership can only be transferred to the same buffer");e.ownsDataBuffer=this.ownsDataBuffer,this.ownsDataBuffer=!1}destroy(){this.ownsDataBuffer&&(this.buffer.destroy(),this.ownsDataBuffer=!1)}},Cy=class extends Py{dataType;format;length;valueLength;stride;byteOffset;byteStride;rowByteLength;readbackMetadata;valueOffsets;nullBitmap;valueByteLength;constructor(e){let{buffer:t,format:i,length:r,valueLength:s,stride:o,byteOffset:a=0,byteStride:c,rowByteLength:l,ownsBuffer:u=!1,readbackMetadata:f,valueOffsets:d,nullBitmap:h,valueByteLength:p,dataType:m}=e;super(t,u);let g;i?typeof i=="string"?g=i:g=GP(i,e.layout??"wgsl-storage"):g=void 0;let v=kd(g)?g:void 0,y=typeof g=="string"?Ti(g):void 0;if(this.dataType=m,this.format=g,this.length=r,this.valueLength=s??r,this.stride=o??y?.components??v?.components??c??l??1,this.byteOffset=a,this.rowByteLength=l??v?.rowByteLength??y?.byteLength??c??this.stride,this.byteStride=c??v?.byteStride??this.rowByteLength,v){if(this.rowByteLengthi.format!==e))throw new Error("GPUVector data chunks must share the declared format")}var ri,jP=C(()=>{Ty();Md();ri=class{name;dataType;format;length;valueLength;stride;byteOffset;byteStride;rowByteLength;bufferLayout;data=[];device;bufferProps;isAppendable=!1;ownsDataChunks=!0;ownedVectors=[];appendableByteLength=0;constructor(e){switch(e.type){case"buffer":{let{name:t,buffer:i,format:r,length:s,valueLength:o=s,byteOffset:a=0,ownsBuffer:c=!1}=e,{stride:l,byteStride:u,rowByteLength:f}=WP(e);this.name=t,this.dataType=e.dataType,this.format=r,this.length=s,this.valueLength=o,this.stride=l,this.byteOffset=a,this.byteStride=u,this.rowByteLength=f,this.data.push(new Mo({buffer:i,format:r,length:s,valueLength:o,stride:l,byteOffset:a,byteStride:u,rowByteLength:f,ownsBuffer:c,dataType:e.dataType}));return}case"interleaved":{let{name:t,buffer:i,format:r,length:s,valueLength:o=s,byteOffset:a=0,byteStride:c,attributes:l,ownsBuffer:u=!1}=e;this.name=t,this.dataType=e.dataType,this.format=r,this.length=s,this.valueLength=o,this.stride=c,this.byteOffset=a,this.byteStride=c,this.rowByteLength=c,this.bufferLayout={name:t,byteStride:c,attributes:l},this.data.push(new Mo({buffer:i,format:r,length:s,valueLength:o,stride:c,byteOffset:a,byteStride:c,rowByteLength:c,ownsBuffer:u,dataType:e.dataType}));return}case"data":{let t=e.format??qz(e.data),i=t?Ti(t):void 0,{name:r,data:s,stride:o=s[0]?.stride??i?.components??1,valueLength:a=s.reduce((d,h)=>d+h.valueLength,0),byteStride:c=s[0]?.byteStride??i?.byteLength,rowByteLength:l=s[0]?.rowByteLength??i?.byteLength,bufferLayout:u,ownsData:f=!1}=e;if(c===void 0||l===void 0)throw new Error("GPUVector requires format or explicit byte layout metadata");t&&Zz(s,t),this.name=r,this.dataType=e.dataType,this.format=t,this.length=s.reduce((d,h)=>d+h.length,0),this.valueLength=a,this.stride=o,this.byteOffset=s.length===1?s[0].byteOffset:0,this.byteStride=c,this.rowByteLength=l,this.bufferLayout=u,this.ownsDataChunks=f,this.data.push(...s);return}case"appendable":{let{name:t,device:i,format:r,valueLength:s=0,bufferProps:o}=e,{stride:a,byteStride:c,rowByteLength:l}=WP(e);this.name=t,this.dataType=e.dataType,this.format=r,this.length=0,this.valueLength=s,this.stride=a,this.byteOffset=0,this.byteStride=c,this.rowByteLength=l,this.device=i,this.bufferProps=o,this.isAppendable=!0;return}}}get ownsBuffer(){return this.ownsDataChunks&&this.data.some(e=>e.ownsBuffer)||this.ownedVectors.some(e=>e.ownsBuffer)}get capacityRows(){return this.isAppendable?this.length:void 0}get appendedByteLength(){return this.appendableByteLength}addData(e){if(this.format&&e.format!==this.format)throw new Error("GPUVector.addData() requires matching formats");if(e.byteStride!==this.byteStride)throw new Error("GPUVector.addData() requires matching byteStride");if(e.rowByteLength!==this.rowByteLength)throw new Error("GPUVector.addData() requires matching rowByteLength");return this.data.push(e),this.length+=e.length,this.valueLength+=e.valueLength,this}appendDataChunk(e,t=this.appendableByteLength+e.buffer.byteLength){if(!this.isAppendable)throw new Error("GPUVector.appendDataChunk() requires appendable vector storage");if(this.format&&e.format!==this.format)throw new Error("GPUVector.appendDataChunk() requires matching formats");if(e.byteStride!==this.byteStride||e.rowByteLength!==this.rowByteLength)throw new Error("GPUVector.appendDataChunk() requires matching byte layout metadata");return this.data.push(e),this.length+=e.length,this.valueLength+=e.valueLength,this.appendableByteLength=t,this}resetLastBatch(){if(!this.isAppendable)throw new Error("GPUVector.resetLastBatch() requires appendable vector storage");for(let e of this.data.splice(0))e.destroy();return this.length=0,this.valueLength=0,this.appendableByteLength=0,this}retainOwnedVectors(e){return this.ownedVectors.push(...e),this}transferBufferOwnership(e){let t=this.data[0],i=e.data[0];if(!t||!i||t.buffer!==i.buffer)throw new Error("GPUVector ownership can only be transferred to the same buffer");t.transferBufferOwnership(i)}destroy(){if(this.ownsDataChunks)for(let e of this.data)e.destroy();for(let e of this.ownedVectors.splice(0))e.destroy()}}});var Ly=C(()=>{Ty();Sy();jP();Md()});var My,pt,Zc=C(()=>{J();My=class{poolSize=20;bufferPools;constructor(){this.bufferPools=new Map}createOrReuse(e,t){if(t>e.limits.maxBufferSize)throw new Error(`Buffer pool cannot allocate ${t} bytes: device.limits.maxBufferSize is ${e.limits.maxBufferSize}`);let i=this.bufferPools.get(e),r=i?i.findIndex(o=>o.byteLength>=t):-1;if(r<0)return e.createBuffer({usage:ie.VERTEX|ie.STORAGE|ie.COPY_DST|ie.COPY_SRC,byteLength:t});let[s]=i.splice(r,1);return s}recycle(e){let t=e.device;this.bufferPools.has(t)||this.bufferPools.set(t,[]);let i=this.bufferPools.get(t),r=i.findIndex(s=>s.byteLength>e.byteLength);r<0?i.push(e):i.splice(r,0,e),this.purge()}purge(){for(let[e,t]of this.bufferPools){let i=e.isLost?0:this.poolSize;for(;t.length>i;)t.shift().destroy();t.length===0&&this.bufferPools.delete(e)}}},pt=new My});function Xz(n,e,t,i){let{ValueType:r,size:s,offset:o,stride:a}=n,c=a/r.BYTES_PER_ELEMENT,l=o/r.BYTES_PER_ELEMENT,u=i-t;if(c===s){let d=l+t*c;return e.subarray(d,d+u*s)}let f=new r(u*s);for(let d=0;d0)throw new Error(`GPUDataEvaluator requires exactly one GPUData chunk for "${n.name}"`);return e}function Jz(n){let e=[];return YP(n,e,{byteOffset:0}),e}function YP(n,e,t){let i=n.source;if(i&&!(i instanceof ve)&&i.name==="interleave"){for(let r of Object.values(i.inputs))r instanceof ve&&YP(r,e,t);return}e.push({attribute:n.id??n.toString(),format:qP(n.type,n.size,n.normalized),byteOffset:t.byteOffset}),t.byteOffset+=n.ValueType.BYTES_PER_ELEMENT*n.size}function qP(n,e,t=!1){if(e<1||e>4)throw new Error(`Cannot synthesize a GPUVector vertex format with ${e} components`);let i=n;if(t)switch(n){case"uint8":i="unorm8";break;case"sint8":i="snorm8";break;case"uint16":i="unorm16";break;case"sint16":i="snorm16";break;case"float32":i="float32";break;default:throw new Error(`Unsupported normalized vertex format for ${n}`)}return(i==="uint8"||i==="sint8"||i==="uint16"||i==="sint16"||i==="unorm8"||i==="snorm8"||i==="unorm16"||i==="snorm16")&&e===3?`${i}x3-webgl`:`${i}${e===1?"":`x${e}`}`}function eU(n,e,t=!1){return e>=1&&e<=4?qP(n,e,t):void 0}var ve,Mi=C(()=>{J();Me();Ly();Zc();ve=class n{static get bufferPoolSize(){return pt.poolSize}static set bufferPoolSize(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("GPUDataEvaluator.bufferPoolSize must be a non-negative safe integer");pt.poolSize=e,pt.purge()}type;size;get offset(){return this._offset}get stride(){return this._stride}normalized;isConstant;length;get byteLength(){return this._byteLength}ValueType;source=null;format;_id;_destroyed=!1;_value;_offset;_stride;_byteLength;_gpuVector;_bufferOwnership="owned";_targetBuffer;static fromArray(e,{type:t,size:i=1,offset:r=0,stride:s=0,normalized:o=!1}){let a=t,c;if(Array.isArray(e)){a=a||"float32";let u=Tr(a);c=new u(e)}else e instanceof Float64Array?(a="uint32",i*=2,r*=2,s*=2,c=new Uint32Array(e.buffer,e.byteOffset,e.byteLength/4)):(a=a||Lu(e),c=e);let l=`<${a} * ${i}>`;return new n({id:l,type:a,size:i,offset:r,stride:s,normalized:o,value:c})}static fromConstant(e,t="float32"){let i=Tr(t),r;return Array.isArray(e)?r=`[${e.join(",")}]`:(r=String(e),e=[e]),new n({id:r,isConstant:!0,type:t,size:e.length,value:new i(e)})}static fromGPUData(e,t={}){Kz(e);let i=new Li({buffer:e.buffer,format:e.format,length:e.length,byteOffset:e.byteOffset,byteStride:e.byteStride});return new n({...HP(i),id:t.id,gpuData:e})}static fromGPUDataView(e,t={}){return new n({...HP(e),id:t.id,buffer:e.buffer})}constructor(e){let{id:t,value:i,buffer:r,gpuData:s,format:o,source:a=null,isConstant:c=!1}=e;if(!a&&!i&&!r&&!s)throw new Error("GPUDataEvaluator must have a value source");let{type:l,size:u,offset:f,stride:d,normalized:h,length:p}=e;if(a instanceof n?(l=l??a.type,u=u??a.size,f=f??a.offset,d=d??a.stride,h=h??a.normalized,p=p??a.length):(u=u??1,f=f??0,h=h??!1,p=c?1:p),!l)throw new Error("GPUDataEvaluator: type not defined");if(this._id=t,this.type=l,this.size=u,this.ValueType=Tr(this.type),this._offset=f,this._stride=d||this.ValueType.BYTES_PER_ELEMENT*u,this.normalized=h,this.source=a,this.format=o,p===void 0)if(c)p=1;else{if(!i)throw new Error("GPUDataEvaluator: length not defined");p=Math.ceil(i.byteLength/this.stride)}this.isConstant=c,this.length=p;let m=this.ValueType.BYTES_PER_ELEMENT*this.size;this._byteLength=p===0?0:(p-1)*this.stride+m,this._value=i,this._bufferOwnership=a instanceof n||r||s?"borrowed":"owned",s?this._gpuVector=new ri({type:"data",name:this._id??"data",format:s.format,data:[s],stride:s.stride,byteStride:s.byteStride,rowByteLength:s.rowByteLength}):r&&(this._gpuVector=this.createGPUVectorView({buffer:r,name:this._id,format:this.format}))}get value(){return this._value||(this.source instanceof n?this.source.value:void 0)}get evaluated(){return!!this._gpuVector}get id(){return this._id}get gpuVector(){if(!this._gpuVector)throw new Error(`${this} not evaluated`);return this._gpuVector}get buffer(){return Rd(this.gpuVector)}setTargetBuffer({buffer:e,byteOffset:t=0,byteStride:i=this.stride}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)throw new Error(`GPUDataEvaluator ${this} already evaluated`);if(!this.source||this.source instanceof n)throw new Error("GPUDataEvaluator target buffers require a deferred operation source");this._targetBuffer={buffer:e,byteOffset:t,byteStride:i}}async evaluate(e,t={}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let i;if(this.source instanceof n){let r=await this.source.evaluate(e);return this._gpuVector=this.createGPUVectorView({...t,buffer:Rd(r)}),this._gpuVector}if(i=this._getEvaluationBuffer(e),this._value)i.write(this._value);else{let r=await this.source.execute(e,i);if(!r.success)throw r.error||new Error(`${this.source} evaluation failed`);r.value&&(this._value=r.value)}return this._gpuVector=this.createGPUVectorView({...t,buffer:i}),this._gpuVector}evaluateSync(e,t={}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let i;if(this.source instanceof n){let r=this.source.evaluateSync(e);return this._gpuVector=this.createGPUVectorView({...t,buffer:Rd(r)}),this._gpuVector}if(i=this._getEvaluationBuffer(e),this._value)i.write(this._value);else{let r=this.source.executeSync(e,i);if(!r.success)throw r.error||new Error(`${this.source} evaluation failed`);r.value&&(this._value=r.value)}return this._gpuVector=this.createGPUVectorView({...t,buffer:i}),this._gpuVector}createGPUVectorView(e){let t=e.name??this._id??"vector",i=e.format??this.format??eU(this.type,this.size,this.normalized);if(e.interleaved){let r=typeof e.interleaved=="object"&&e.interleaved.attributes?e.interleaved.attributes:Jz(this);return new ri({type:"interleaved",name:t,buffer:e.buffer,format:e.format??this.format,length:this.length,byteOffset:this.offset,byteStride:this.stride,attributes:r,ownsBuffer:!1})}return new ri({type:"buffer",name:t,buffer:e.buffer,format:i,length:this.length,stride:this.size,byteOffset:this.offset,byteStride:this.stride,rowByteLength:this.ValueType.BYTES_PER_ELEMENT*this.size,ownsBuffer:!1})}_getEvaluationBuffer(e){let t=this._targetBuffer;if(!t)return pt.createOrReuse(e,this.byteLength);if(t.buffer.device!==e)throw new Error("GPUDataEvaluator target buffer belongs to a different device");let i=this.ValueType.BYTES_PER_ELEMENT*this.size,r=this.length===0?0:(this.length-1)*t.byteStride+i;if(t.byteOffset+r>t.buffer.byteLength)throw new Error("GPUDataEvaluator target buffer is too small for the output layout");return this._offset=t.byteOffset,this._stride=t.byteStride,this._byteLength=r,this._bufferOwnership="borrowed",this._targetBuffer=void 0,t.buffer}async readValue(e=0,t){let{ValueType:i}=this,{size:r,offset:s,stride:o,length:a}=this,c=i.BYTES_PER_ELEMENT*r;if(t=t??a,e=Math.max(0,Math.min(a,e)),t=Math.max(e,Math.min(a,t)),this._value)return Xz(this,this._value,e,t);let l=t-e;if(l===0)return new i(0);let u=s+e*o,f=o===c?l*c:(l-1)*o+c,d=await this.buffer.readAsync(u,f),h=new i(d.buffer,d.byteOffset,d.byteLength/i.BYTES_PER_ELEMENT);if(o===c)return h;let p=new Uint8Array(c*l);for(let m=0;m{Ao={add:{arity:2,symbol:"arithmetic_add"},subtract:{arity:2,symbol:"arithmetic_subtract"},multiply:{arity:2,symbol:"arithmetic_multiply"},divide:{arity:2,symbol:"arithmetic_divide"},pow:{arity:2,symbol:"pow"},sqrt:{arity:1,symbol:"sqrt"},abs:{arity:1,symbol:"abs"},sin:{arity:1,symbol:"sin"},cos:{arity:1,symbol:"cos"},tan:{arity:1,symbol:"arithmetic_tan"},exp:{arity:1,symbol:"exp"},log:{arity:1,symbol:"log"}}});function lC(n,{operations:e,inputs:t}){switch(n.kind){case"input":if(!(n.name in t))throw new Error(`Unknown expression input '${n.name}'`);return;case"literal":if(Array.isArray(n.value)){for(let i of n.value)if(!Number.isFinite(i))throw new Error(`Expression literal array must contain only finite values, got ${i}`)}else if(!Number.isFinite(n.value))throw new Error(`Expression literal must be finite, got ${n.value}`);return;case"call":{let i=e[n.op];if(!i)throw new Error(`Unknown expression op '${n.op}'`);if(n.args.length!==i.arity)throw new Error(`Expression op '${n.op}' expects ${i.arity} args, got ${n.args.length}`);for(let r of n.args)lC(r,{operations:e,inputs:t});return}default:{let i=n;throw new Error(`Unsupported expression node ${i.kind}`)}}}function Od(n,e){return lC(n,e),uC(n,e)}function uC(n,e){switch(n.kind){case"input":{let t=e.inputs[n.name];return e.laneIndexuC(r,e));return e.formatCall(t.symbol,i)}default:{let t=n;throw new Error(`Unsupported expression node ${t.kind}`)}}}var Iy=C(()=>{});function it(n,e,t=!1){if(t)return e===1?"float":`vec${e}`;switch(n){case"uint8":case"uint16":case"uint32":return e===1?"uint":`uvec${e}`;case"sint8":case"sint16":case"sint32":return e===1?"int":`ivec${e}`;default:return e===1?"float":`vec${e}`}}function Dd(n,e,t=!1){let i;if(t)switch(n){case"uint8":i="unorm8";break;case"sint8":i="snorm8";break;case"uint16":i="unorm16";break;case"sint16":i="snorm16";break;case"float32":i="float32";break;default:throw new Error(`Unsupported normalized vertex format for ${n}`)}else i=n;return e===1?i:e===3&&!i.startsWith("float32")&&!i.endsWith("32")?`${i}x3-webgl`:`${i}x${e}`}function ir(n){switch(n[0]){case"u":return"0u";case"s":return"0";default:return"0."}}function fC(n,e){switch(n){case"uint8":case"uint16":case"uint32":return`${Math.trunc(e)}u`;case"sint8":case"sint16":case"sint32":return`${Math.trunc(e)}`;default:return Number.isInteger(e)?`${e}.0`:`${e}`}}function dC(n){switch(n){case"uint8":return"r8uint";case"sint8":return"r8sint";case"uint16":return"r16uint";case"sint16":return"r16sint";case"uint32":return"r32uint";case"sint32":return"r32sint";case"float32":return"r32float";default:throw new Error(`Unsupported WebGL gather texture format for ${n}`)}}function hC(n){switch(n){case"uint32":return"usampler2D";case"sint32":return"isampler2D";case"float32":return"sampler2D";default:throw new Error(`Unsupported WebGL gather sampler type for ${n}`)}}var Ro=C(()=>{});function rt({module:n,elementWise:e=!1,expression:t,inputs:i,output:r,operationType:s=r.type,outputBuffer:o}){let a=o.device,c=cs("result",r.type,r.size,r.normalized),l=[n,c],u=[],f={},d=it(r.type,1,r.normalized),h=it(s,1,r.normalized),p="",m=null,g={TYPE:h,RESULT_LEN:r.size.toString()},v=lU(i);for(let[E,w]of v)l.push(By(E,w.type,w.size,w.normalized,s)),u.push(Oy(E,w)),w instanceof ve?f[E]=w.buffer:(m=m||pt.createOrReuse(a,o.byteLength),f[E]=m),p+=`TYPE ${E}[${w.size}]; get_${E}(${E}); +`});var M4,eo,bS=C(()=>{oS();hS();gS();yS();M4=[38.25,38.25,38.25],eo={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:mS.replace("phongMaterial","gouraudMaterial"),fs:pS.replace("phongMaterial","gouraudMaterial"),source:_S.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[fS,sS],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:M4},getUniforms(n){return{...eo.defaultUniforms,...n}}}});var vt=C(()=>{_m();dw();ng();Hw();qw();ZE();tS();aS();bS()});function Zn(n="id"){T_[n]=T_[n]||1;let e=T_[n]++;return`${n}-${e}`}var T_,_o=C(()=>{T_={}});function Kr(n){switch(n){case"POSITION":return"positions";case"NORMAL":return"normals";case"TEXCOORD_0":return"texCoords";case"TEXCOORD_1":return"texCoords1";case"COLOR_0":return"colors";default:return n}}function PF(n){let e=[];for(let[t,i]of Object.entries(n)){if(!i)continue;let{value:r,size:s,normalized:o}=i;if(s===void 0)throw new Error(`Attribute ${t} is missing a size`);e.push({name:Kr(t),format:Pe.getVertexFormatFromAttribute(r,s,o)})}return e}var en,Rf=C(()=>{J();_o();en=class{id;topology;vertexCount;indices;attributes;bufferLayout;userData={};constructor(e){let{attributes:t={},indices:i=null,vertexCount:r=null}=e;this.id=e.id||Zn("geometry"),this.topology=e.topology,i&&(this.indices=ArrayBuffer.isView(i)?{value:i,size:1}:i),this.attributes={};for(let[s,o]of Object.entries(t)){let a=ArrayBuffer.isView(o)?{value:o}:o;if(!ArrayBuffer.isView(a.value))throw new Error(`${this._print(s)}: must be typed array or object with value as typed array`);if((s==="POSITION"||s==="positions")&&!a.size&&(a.size=3),s==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=a}else{let c=Kr(s),l=Object.keys(this.attributes).find(u=>Kr(u)===c);l&&delete this.attributes[l],this.attributes[s]=a}}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=r||this._calculateVertexCount(this.attributes,this.indices),this.bufferLayout=e.bufferLayout||PF(this.attributes)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,t){return this}_calculateVertexCount(e,t){if(t)return t.value.length;let i=1/0;for(let r of Object.values(e)){if(!r)continue;let{value:s,size:o,constant:a}=r;!a&&s&&o!==void 0&&o>=1&&(i=Math.min(i,s.length/o))}return i}}});function p1(n,e={}){let t=e.bufferName||"geometry";if(CF(n,t))return n;let i=e.minAttributeAlignment||4,r=TF(n,e.attributes),s=[],o=0,a=1/0;for(let[u,f]of r){if(!f)continue;if(f.constant)throw new Error(`Attribute ${u} is constant`);let{value:d,size:h,normalized:p}=f;if(!ArrayBuffer.isView(d))throw new Error(`Attribute ${u} is missing typed array data`);if(h===void 0)throw new Error(`Attribute ${u} is missing a size`);let m=Pe.getVertexFormatFromAttribute(d,h,p),g=Pe.getVertexFormatInfo(m);o=h1(o,i),s.push({sourceName:u,attributeName:Kr(u),value:d,size:h,format:m,byteOffset:o,byteLength:g.byteLength}),o+=g.byteLength;let v=d.length/h;if(!Number.isInteger(v))throw new Error(`Attribute ${u} length is not divisible by size`);a=Math.min(a,v)}if(s.length===0||!Number.isFinite(a))throw new Error(`Geometry ${n.id} has no interleavable attributes`);let c=h1(o,i),l=new ArrayBuffer(a*c);for(let u of s)LF(l,a,c,u);return new en({id:n.id,topology:n.topology||"triangle-list",vertexCount:n.vertexCount,indices:n.indices,attributes:{[t]:{value:new Uint8Array(l),size:c,byteStride:c}},bufferLayout:[{name:t,stepMode:"vertex",byteStride:c,attributes:s.map(u=>({attribute:u.attributeName,format:u.format,byteOffset:u.byteOffset}))}]})}function CF(n,e){if(n.bufferLayout.length!==1)return!1;let t=n.bufferLayout[0];return t.name===e&&!!t.attributes?.length&&!!n.attributes[e]}function TF(n,e){return e?e.map(t=>[t,n.attributes[t]]):Object.entries(n.attributes)}function LF(n,e,t,i){let r=i.value.constructor,s=r.BYTES_PER_ELEMENT;if(i.byteOffset%s!==0||t%s!==0)throw new Error(`Attribute ${i.sourceName} is not aligned to its component type`);let o=new r(n),a=i.value,c=i.byteOffset/s,l=t/s;for(let u=0;u{J();Rf()});var MF,AF,Qr,g1=C(()=>{MF=1,AF=1,Qr=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){let{delay:t=0,duration:i=Number.POSITIVE_INFINITY,rate:r=1,repeat:s=1}=e,o=MF++,a={time:0,delay:t,duration:i,rate:r,repeat:s};return this._setChannelTime(a,this.time),this.channels.set(o,a),o}removeChannel(e){this.channels.delete(e);for(let[t,i]of this.animations)i.channel===e&&this.detachAnimation(t)}isFinished(e){let t=this.channels.get(e);return t===void 0?!1:this.time>=t.delay+t.duration*t.repeat}getTime(e){if(e===void 0)return this.time;let t=this.channels.get(e);return t===void 0?-1:t.time}setTime(e){this.time=Math.max(0,e);let t=this.channels.values();for(let r of t)this._setChannelTime(r,this.time);let i=this.animations.values();for(let r of i){let{animation:s,channel:o}=r;s.setTime(this.getTime(o))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,t){let i=AF++;return this.animations.set(i,{animation:e,channel:t}),e.setTime(this.getTime(t)),i}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,t){let i=t-e.delay,r=e.duration*e.repeat;i>=r?e.time=e.duration*e.rate:(e.time=Math.max(0,i)%e.duration,e.time*=e.rate)}}});function _1(n){let e=typeof window<"u"?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame:null;return e?e.call(window,n):setTimeout(()=>n(typeof performance<"u"?performance.now():Date.now()),1e3/60)}function y1(n){let e=typeof window<"u"?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame:null;if(e){e.call(window,n);return}clearTimeout(n)}var b1=C(()=>{});var kF,RF,v1,gc,x1=C(()=>{J();b1();ua();kF=0,RF="Animation Loop",v1={requestAnimationFrame:n=>_1(n),cancelAnimationFrame:n=>y1(n)},gc=class n{static defaultAnimationLoopProps={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>{console.error(e)},stats:void 0,autoResizeViewport:!1,animationFrameProvider:v1};device=null;canvas=null;props;animationProps=null;timeline=null;stats;sharedStats;cpuTime;gpuTime;frameRate;display;_needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;_lastFrameTime=0;constructor(e){if(this.props={...n.defaultAnimationLoopProps,...e},e=this.props,!e.device)throw new Error("No device provided");this.stats=e.stats||new Ht({id:`animation-loop-${kF++}`}),this.sharedStats=Vs.stats.get(RF),this.frameRate=this.stats.get("Frame Rate"),this.frameRate.setSampleSize(1),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.setProps({autoResizeViewport:e.autoResizeViewport,animationFrameProvider:e.animationFrameProvider}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null),this.device?._disableDebugGPUTime()}delete(){this.destroy()}reportError(e){this._error=e,this.props.onError(e),this.props.onError===n.defaultAnimationLoopProps.onError&&typeof window<"u"&&typeof ErrorEvent<"u"&&window.dispatchEvent(new ErrorEvent("error",{error:e,message:e.message}))}setNeedsRedraw(e){return this._needsRedraw=this._needsRedraw||e,this}needsRedraw(){let e=this._needsRedraw;return this._needsRedraw=!1,e}setProps(e){if("autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),"animationFrameProvider"in e){let t=e.animationFrameProvider||v1;if(t!==this.props.animationFrameProvider){let i=this._animationFrameId!==null;i&&this._cancelAnimationFrame(),this.props.animationFrameProvider=t,i&&this._requestAnimationFrame()}}return this}async start(){if(this._running)return this;this._running=!0;try{let e;if(!this._initialized){if(this._initialized=!0,await this._initDevice(),this._initialize(),!this._running)return null;await this.props.onInitialize(this._getAnimationProps())}return this._running?(e!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){let t=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(t),t}}stop(){if(this._running){let e=this.animationProps;this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1,this._lastFrameTime=0,e&&this.props.onFinalize(e)}return this}redraw(e,t=null){return this.device?.isLost||this._error?this:(this._beginFrameTimers(e),this._setupFrame(),this.animationProps&&(this.animationProps.animationFrame=t),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeViewport(),this.device?._enableDebugGPUTime()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=this.props.animationFrameProvider.requestAnimationFrame(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(this.props.animationFrameProvider.cancelAnimationFrame(this._animationFrameId),this._animationFrameId=null)}_animationFrame(e,t){if(this._running)try{this.redraw(e,t??null),this._requestAnimationFrame()}catch(i){let r=i instanceof Error?i:new Error(String(i));this.reportError(r),this.stop()}}_renderFrame(e){if(this.display){this.display._renderFrame(e);return}let t=this.props.onRender(this._getAnimationProps());this.device&&t!==!1&&this.device.submit()}_clearNeedsRedraw(){this._needsRedraw=!1}_setupFrame(){this._resizeViewport()}_initializeAnimationProps(){let e=this.device?.getDefaultCanvasContext();if(!this.device||!e)throw new Error("loop");let t=e?.canvas,i=e.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:e,canvas:t,useDevicePixels:i,timeline:this.timeline,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,animationFrame:null,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:e,height:t,aspect:i}=this._getSizeAndAspect();(e!==this.animationProps.width||t!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),i!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=t,this.animationProps.aspect=i,this.animationProps.needsRedraw=this._needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.getDefaultCanvasContext().canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";let t=document.createElement("div");t.style.position="absolute",t.style.left="10px",t.style.bottom="10px",t.style.width="300px",t.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(t);let i=this.props.onAddHTML(t);i&&(t.innerHTML=i)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[e,t]=this.device.getDefaultCanvasContext().getDrawingBufferSize(),i=e>0&&t>0?e/t:1;return{width:e,height:t,aspect:i}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(e){let t=e??(typeof performance<"u"?performance.now():Date.now());if(this._lastFrameTime){let i=t-this._lastFrameTime;i>0&&this.frameRate.addTime(i)}this._lastFrameTime=t,this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeStart()}_endFrameTimers(){this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeEnd(),this._updateSharedStats()}_consumeEncodedGpuTime(){if(!this.device)return;let e=this.device.commandEncoder._gpuTimeMs;e!==void 0&&(this.gpuTime.addTime(e),this.device.commandEncoder._gpuTimeMs=void 0)}_updateSharedStats(){if(this.stats!==this.sharedStats){for(let e of Object.keys(this.sharedStats.stats))this.stats.stats[e]||delete this.sharedStats.stats[e];this.stats.forEach(e=>{let t=this.sharedStats.get(e.name,e.type);t.sampleSize=e.sampleSize,t.time=e.time,t.count=e.count,t.samples=e.samples,t.lastTiming=e.lastTiming,t.lastSampleTime=e.lastSampleTime,t.lastSampleCount=e.lastSampleCount,t._count=e._count,t._time=e._time,t._samples=e._samples,t._startTime=e._startTime,t._timerPending=e._timerPending})}}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}}});function w1(n,e){if(e instanceof If)return e;let t=p1(e),i=IF(n,t),{attributes:r,bufferLayout:s}=BF(n,t);return new If({topology:t.topology||"triangle-list",bufferLayout:s,vertexCount:t.vertexCount,indices:i,attributes:r})}function IF(n,e){if(!e.indices)return;let t=e.indices.value;return n.createBuffer({usage:ie.INDEX,data:t})}function BF(n,e){let t={};for(let[i,r]of Object.entries(e.attributes)){let s=e.bufferLayout.find(o=>o.name===i)?.name||Kr(i);r&&(t[s]=n.createBuffer({data:r.value,id:`${i}-buffer`}))}return{attributes:t,bufferLayout:e.bufferLayout,vertexCount:e.vertexCount}}var If,E1=C(()=>{J();Rf();m1();_o();If=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){if(this.id=e.id||Zn("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&!(this.indices.usage&ie.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){this.indices?.destroy();for(let e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(e){return e.byteLength/12}}});function S1(n,e){let t={},i="Values";if(n.attributes.length===0&&!n.varyings?.length)return{"No attributes or varyings":{[i]:"N/A"}};for(let r of n.attributes)if(r){let s=`${r.location} ${r.name}: ${r.type}`;t[`in ${s}`]={[i]:r.stepMode||"vertex"}}for(let r of n.varyings||[]){let s=`${r.location} ${r.name}`;t[`out ${s}`]={[i]:JSON.stringify(r)}}return t}var P1=C(()=>{});function L1(n,e,t){if(n.device.type!=="webgl")return;let i=NF(n.device);if(!i.flushing){if(zF(n)){OF(n,t,i);return}e&&FF(e)&&e.handle!==null&&(i.queuedFramebuffers.includes(e)||i.queuedFramebuffers.push(e))}}function OF(n,e,t){if(t.queuedFramebuffers.length===0)return;let i=n.device,{gl:r}=i,s=r.getParameter(36010),o=r.getParameter(36006),[a,c]=n.device.getDefaultCanvasContext().getDrawingBufferSize(),l=T1(e.top,8),u=T1(e.left,8);t.flushing=!0;try{for(let f of t.queuedFramebuffers){let[d,h,p,m,g]=DF({framebuffer:f,targetWidth:a,targetHeight:c,topPx:l,leftPx:u,minimap:e.minimap});r.bindFramebuffer(36008,f.handle),r.bindFramebuffer(36009,null),r.blitFramebuffer(0,0,f.width,f.height,d,h,p,m,16384,9728),l+=g+8}}finally{r.bindFramebuffer(36008,s),r.bindFramebuffer(36009,o),t.flushing=!1}}function DF(n){let{framebuffer:e,targetWidth:t,targetHeight:i,topPx:r,leftPx:s,minimap:o}=n,a=o?Math.max(Math.floor(t/4),1):t,c=o?Math.max(Math.floor(i/4),1):i,l=Math.min(a/e.width,c/e.height),u=Math.max(Math.floor(e.width*l),1),f=Math.max(Math.floor(e.height*l),1),d=s,h=Math.max(i-r-f,0),p=d+u,m=h+f;return[d,h,p,m,f]}function NF(n){return n.userData[C1]||={flushing:!1,queuedFramebuffers:[]},n.userData[C1]}function FF(n){return"colorAttachments"in n}function zF(n){let e=n.props.framebuffer;return!e||e.handle===null}function T1(n,e){if(!n)return e;let t=Number.parseInt(n,10);return Number.isFinite(t)?t:e}var C1,M1=C(()=>{C1="__debugFramebufferState"});function yo(n,e,t){if(n===e)return!0;if(!t||!n||!e)return!1;if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let i=0;i{});var bo,k1=C(()=>{J();bo=class{bufferLayouts;constructor(e){this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(t=>t.name===e)||null}getAttributeNamesForBuffer(e){return qs(e)}mergeBufferLayouts(e,t){let i=[...e];for(let r of t){let s=i.findIndex(o=>o.name===r.name);s<0?i.push(r):i[s]=r}return i}}});function R1(n,e){let t=Km(n),i=e.slice();return i.sort((r,s)=>{let o=Vu(qs(r).map(c=>t[c])),a=Vu(qs(s).map(c=>t[c]));return o-a}),i}var I1=C(()=>{J()});function vo(n,e){if(!n||!e.some(i=>i.bindingLayout?.length))return n;let t={...n,bindings:n.bindings.map(i=>({...i}))};"attributes"in(n||{})&&(t.attributes=n?.attributes||[]);for(let i of e)for(let r of i.bindingLayout||[])for(let s of UF(r.name)){let o=t.bindings.find(a=>a.name===s);o?.group===0&&(o.group=r.group),o&&r.visibility!==void 0&&(o.visibility=r.visibility)}return t}function B1(n,e,t=[]){return n?e?{...n,attributes:n.attributes.length?VF(n.attributes,e.attributes.filter(i=>t.includes(i.name))):e.attributes,bindings:GF(n.bindings,e.bindings)}:n:e}function _c(n){return!!(n.uniformTypes&&!$F(n.uniformTypes))}function O1(n){let e=[];for(let t of n){let i=Wa(t),r=new Set([t.vs,t.fs].flatMap(o=>o?ja(o).filter(a=>a.isStd140).map(a=>a.blockName):[])),s=r.has(i)?i:r.size===1?r.values().next().value:void 0;_c(t)&&s&&e.push({name:s,uniformTypes:t.uniformTypes})}return e}function Bf(n,e){let t=[],i=new Set;for(let r of[...n||[],...e||[]])i.has(r.name)||(i.add(r.name),t.push(r));return t}function UF(n){let e=new Set([n,`${n}Uniforms`]);return n.endsWith("Uniforms")||e.add(`${n}Sampler`),[...e]}function $F(n){for(let e in n)return!1;return!0}function GF(n,e){let t=n.map(s=>({...s})),i=new Set(n.map(s=>s.name)),r=new Set(n.map(s=>`${s.group}:${s.location}`));for(let s of e){let o=`${s.group}:${s.location}`;!i.has(s.name)&&!r.has(o)&&t.push({...s})}return t}function VF(n,e){let t=n.map(s=>({...s})),i=new Map(n.map(s=>[s.name,s])),r=new Map(n.map(s=>[s.location,s]));for(let s of e){let o=i.get(s.name);if(o){if(o.type!==s.type||o.location!==s.location)throw new Error(`Shader attribute "${s.name}" conflicts with its inferred type or location`);continue}let a=r.get(s.location);if(a)throw new Error(`Shader attributes "${a.name}" and "${s.name}" both use location ${s.location}`);t.push({...s})}return t}var L_=C(()=>{vt()});function WF(n){return _a(n)||typeof n=="number"||typeof n=="boolean"}function D1(n,e={}){let t={bindings:{},uniforms:{}};return Object.keys(n).forEach(i=>{let r=n[i];Object.prototype.hasOwnProperty.call(e,i)||WF(r)?t.uniforms[i]=r:t.bindings[i]=r}),t}var N1=C(()=>{Jp()});function F1(n={},e={},t={}){let i={...n};for(let[r,s]of Object.entries(e))s!==void 0&&(i[r]=M_(n[r],s,t[r]));return i}function M_(n,e,t){if(!t||typeof t=="string")return yc(e);if(Array.isArray(t)){if(A_(e)||!Array.isArray(e))return yc(e);let o=Array.isArray(n)&&!A_(n)?[...n]:[],a=o.slice();for(let c=0;ct===void 0?void 0:yc(t)):k_(n)?Object.fromEntries(Object.entries(n).map(([e,t])=>[e,t===void 0?void 0:yc(t)])):n}function A_(n){return ArrayBuffer.isView(n)||Array.isArray(n)&&(n.length===0||typeof n[0]=="number")}function k_(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&!ArrayBuffer.isView(n)}function jF(n){return!!n?.dependencies}var xo,R_=C(()=>{J();vt();N1();xo=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;directBindings={};constructor(e,t){Object.assign(this.options,t);let i=Cr(Object.values(e).filter(jF));for(let r of i)e[r.name]=r;N.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(let[r,s]of Object.entries(e))s&&(this._addModule(s),s.name&&r!==s.name&&!this.options.disableWarnings&&N.warn(`Module name: ${r} vs ${s.name}`)())}destroy(){}setProps(e){e.bindings&&Object.assign(this.directBindings,e.bindings);for(let t of Object.keys(e)){if(t==="bindings")continue;let i=t,r=e[i]||{},s=this.modules[i];if(!s)this.options.disableWarnings||N.warn(`Module ${t} not found`)();else{let o=this.moduleUniforms[i],a=this.moduleBindings[i],c=s.getUniforms?.(r,o)||r,{uniforms:l,bindings:u}=D1(c,s.uniformTypes);this.moduleUniforms[i]=F1(o,l,s.uniformTypes),this.moduleBindings[i]={...a,...u}}}}getModules(){return Object.values(this.modules)}addModules(e){let t=Cr(e);for(let i of t){let r=i.name;this.modules[r]||(this.modules[r]=i,this._addModule(i))}}getUniformValues(){return this.moduleUniforms}getBindingValues(){let e={};for(let t of Object.values(this.moduleBindings))Object.assign(e,t);return Object.assign(e,this.directBindings),e}getModuleBindingValues(e){let t=this.moduleBindings[e];return t?{...t}:{}}getDebugTable(){let e={};for(let[t,i]of Object.entries(this.moduleUniforms))for(let[r,s]of Object.entries(i))e[`${t}.${r}`]={type:this.modules[t].uniformTypes?.[r],value:String(s)};return e}_addModule(e){let t=e.name;this.moduleUniforms[t]=F1({},e.defaultUniforms||{},e.uniformTypes),this.moduleBindings[t]={}}}});function I_(n){return n!==null&&typeof n=="object"&&"buffer"in n}function YF(n){return n instanceof tt?n.buffer:n}function z1(n){return{buffer:YF(n.buffer),offset:n.offset,size:n.size}}var HF,tt,B_=C(()=>{J();_o();HF=ie.DEBUG_DATA_MAX_LENGTH,tt=class{device;id;ready;usage;props;isReady=!0;destroyed=!1;generation=0;updateTimestamp;debugData=new ArrayBuffer(0);_debugDataEnabled;_maxDebugDataByteLength;_ownsBuffer;_buffer;get buffer(){return this._buffer}get byteLength(){return this._buffer.byteLength}get[Symbol.toStringTag](){return"DynamicBuffer"}toString(){return`DynamicBuffer:"${this.id}":${this.byteLength}B`}toJSON(){return this.toString()}constructor(e,t){let{debugData:i=!1,buffer:r,ownsBuffer:s=!0,...o}=t;if(r&&r.device!==e)throw new Error("DynamicBuffer adopted buffers must belong to the supplied device");if(r&&(o.byteLength!==void 0||o.data!==void 0))throw new Error("DynamicBuffer cannot combine an adopted buffer with byteLength or data");let a=t.id||r?.id||Zn("dynamic-buffer"),c={...o,id:a,usage:o.usage??r?.usage,indexType:o.indexType??r?.indexType};(c.usage||0)&ie.INDEX&&!c.indexType&&(o.data instanceof Uint32Array?c.indexType="uint32":o.data instanceof Uint16Array?c.indexType="uint16":o.data instanceof Uint8Array&&(c.indexType="uint8")),delete c.data,delete c.byteOffset,this.device=e,this.id=a,this.props=c,this.usage=c.usage||0,this._debugDataEnabled=!!i,this._maxDebugDataByteLength=typeof i=="object"&&i.maxByteLength!==void 0?i.maxByteLength:HF,this._ownsBuffer=s,this._buffer=r??this.device.createBuffer({...o,id:a}),this.ready=Promise.resolve(this._buffer),this.updateTimestamp=this._buffer.updateTimestamp,this._resetDebugData(this._buffer.byteLength),o.data&&this._writeDebugData(o.data,o.byteOffset||0)}write(e,t=0){this._buffer.write(e,t),this._touch(),this._writeDebugData(e,t)}async mapAndWriteAsync(e,t=0,i=this.byteLength-t){let r=null;await this._buffer.mapAndWriteAsync(async(s,o)=>{await e(s,o),r=new Uint8Array(s.slice(0,i))},t,i),this._touch(),r&&this._writeDebugData(r,t)}async readAsync(e=0,t=this.byteLength-e){let i=await this._buffer.readAsync(e,t);return this._writeDebugData(i,e)&&this._touch(),i}async mapAndReadAsync(e,t=0,i=this.byteLength-t){let r=null,s=await this._buffer.mapAndReadAsync(async(o,a)=>(r=new Uint8Array(o.slice(0)),await e(o,a)),t,i);return r&&this._writeDebugData(r,t)&&this._touch(),s}resize(e){let{byteLength:t,preserveData:i=!1}=e;if(t===this.byteLength)return!1;let r=Math.min(e.copyByteLength??Math.min(this.byteLength,t),this.byteLength,t),s=this._buffer,o=this.debugData.slice(0),{data:a,byteOffset:c,...l}=this.props,u=this.device.createBuffer({...l,byteLength:t});return i&&r>0&&this._copyBufferContents(s,u,r),this._buffer=u,this._resetDebugData(t),i&&o.byteLength>0&&this._writeDebugData(o,0),this._ownsBuffer&&s.destroy(),this._ownsBuffer=!0,this.generation++,this._touch(),!0}ensureSize(e,t){return e<=this.byteLength?!1:this.resize({byteLength:e,preserveData:t?.preserveData})}getBinding(e){return e?.offset===void 0&&e?.size===void 0?this._buffer:{buffer:this._buffer,offset:e?.offset,size:e?.size}}destroy(){this.destroyed||(this._ownsBuffer&&this._buffer.destroy(),this.destroyed=!0,this.debugData=new ArrayBuffer(0))}_copyBufferContents(e,t,i){let r=this.device.type==="webgpu"?Math.ceil(i/4)*4:i,s=this.device.createCommandEncoder();s.copyBufferToBuffer({sourceBuffer:e,destinationBuffer:t,size:r}),this.device.submit(s.finish())}_touch(){this.updateTimestamp=this.device.incrementTimestamp()}_resetDebugData(e){if(!this._debugDataEnabled){this.debugData=new ArrayBuffer(0);return}this.debugData=new ArrayBuffer(Math.min(e,this._maxDebugDataByteLength))}_writeDebugData(e,t){if(!this._debugDataEnabled||this.debugData.byteLength===0||t>=this.debugData.byteLength)return!1;let i=ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),r=new Uint8Array(this.debugData),s=Math.min(i.byteLength,r.byteLength-t);return r.set(i.subarray(0,s),t),s>0}}});function bc(n){return n!==null&&typeof n=="object"&&"resolveTextureBinding"in n&&typeof n.resolveTextureBinding=="function"}function qF(n){return n?.type==="texture"||n?.type==="external-texture"}function U1(n,e,t){let i=Nu(n,e,{ignoreWarnings:!0});return qF(i)?i:n.bindings.length===0&&t?.fallbackGroup!==void 0?{type:"texture",name:e,group:t.fallbackGroup,location:0}:null}var $1=C(()=>{J()});function D_(n,e){return n.shaderLanguage!==void 0&&n.shaderLanguage!==e?!1:e==="glsl"?"assembleGLSLShaderPair"in n&&typeof n.assembleGLSLShaderPair=="function":"assembleWGSLShader"in n&&typeof n.assembleWGSLShader=="function"}function KF(n,e){return!n||Object.keys(e).length===0?n:{...n,attributes:n.attributes.map(t=>{let i=t.name.startsWith("_luma_")?t.name.slice(6):null;return i&&e[i]?{...t,name:i}:t})}}function QF(n,e,t){if(bc(e)){let i=U1(t,n,{fallbackGroup:0});return i?e.resolveTextureBinding(i):null}return e instanceof tt?e.buffer:I_(e)?z1(e):e}function JF(n){return n&&!G1(n)?n:null}function e6(n){return n&&G1(n)?n:void 0}function G1(n){return XF.includes(n)}function t6(n){return{type:n.type,shaderLanguage:n.info.shadingLanguage,shaderLanguageVersion:n.info.shadingLanguageVersion,gpu:n.info.gpu,limits:n.limits,features:n.features}}var Xn,ZF,O_,XF,Ze,N_=C(()=>{J();vt();E1();P1();M1();A1();k1();I1();L_();_o();R_();B_();$1();Xn=2,ZF=1e4,O_="render pipeline initialization failed",XF=["stencil8","depth16unorm","depth24plus","depth24plus-stencil8","depth32float","depth32float-stencil8"],Ze=class n{static defaultProps={...Zt.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],plugins:[],geometry:null,indexBuffer:null,indexCount:void 0,firstVertex:0,firstIndex:0,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,material:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:Xt.getDefaultShaderAssembler("glsl"),debugShaders:void 0,disableWarnings:void 0};device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexCount;firstVertex;firstIndex;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;material=null;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_dynamicIndexBufferSource=null;_dynamicAttributeBufferSources={};_colorAttachmentFormats;_depthStencilAttachmentFormat;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_drawBlockedReason=!1;_destroyed=!1;_vertexCountSet=!1;_lastDrawTimestamp=-1;_bindingTable=[];get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(e,t){let i=n.defaultProps.shaderAssembler,r=t.vertexCount!==void 0;this.props={...n.defaultProps,...t,shaderAssembler:t.shaderAssembler??(D_(i,e.info.shadingLanguage)?i:Xt.getDefaultShaderAssembler(e.info.shadingLanguage))},this._vertexCountSet=r,t=this.props,this.id=t.id||Zn("model"),this.device=e,Object.assign(this.userData,t.userData),this.material=t.material||null;let s=t6(e),o=Ga(this.props.plugins,s.shaderLanguage),a=Va(this.props.modules,o.modules),c=Object.fromEntries(a.map(h=>[h.name,h])),l=t.shaderInputs||new xo(c,{disableWarnings:this.props.disableWarnings});t.shaderInputs&&o.modules.length>0&&l.addModules(o.modules),this.setShaderInputs(l);let u=Bf(this.props.modules,l.getModules()),f={...o.defines,...this.props.defines};if(this.device.type==="webgl"&&(this.props._uniformBlockLayouts=O1(u)),this.props.shaderLayout=vo(this.props.shaderLayout,u)||null,this.device.type==="webgpu"&&this.props.source){let h=this.props.shaderAssembler;Vi(D_(h,"wgsl"));let{source:p,getUniforms:m,bindingTable:g,shaderLayout:v}=h.assembleWGSLShader({platformInfo:s,...this.props,modules:u,defines:f,pluginInjections:o.injections,pluginVertexInputs:o.vertexInputs,pluginVaryings:o.varyings});this.source=p,this._getModuleUniforms=m,this._bindingTable=g;let y=v??e.getShaderLayout?.(this.source),b=KF(y,o.vertexInputs),x=B1(this.props.shaderLayout,b,Object.keys(o.vertexInputs));this.props.shaderLayout=vo(x||null,u)||null}else{let h=this.props.shaderAssembler;Vi(D_(h,"glsl"));let{vs:p,fs:m,getUniforms:g}=h.assembleGLSLShaderPair({platformInfo:s,...this.props,modules:u,defines:f,pluginInjections:o.injections,pluginVertexInputs:o.vertexInputs,pluginVaryings:o.varyings});this.vs=p,this.fs=m,this._getModuleUniforms=g,this._bindingTable=[]}this.vertexCount=this.props.vertexCount,this.indexCount=this.props.indexCount,this.firstVertex=this.props.firstVertex,this.firstIndex=this.props.firstIndex,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,this._colorAttachmentFormats=this.props.colorAttachmentFormats,this._depthStencilAttachmentFormat=this.props.depthStencilAttachmentFormat,t.geometry&&this.setGeometry(t.geometry),this.pipelineFactory=t.pipelineFactory||Ir.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||Br.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in t&&(this.isInstanced=t.isInstanced),t.instanceCount&&this.setInstanceCount(t.instanceCount),t.vertexCount&&this.setVertexCount(t.vertexCount),t.indexBuffer&&this.setIndexBuffer(t.indexBuffer),t.attributes&&this.setAttributes(t.attributes),t.constantAttributes&&this.setConstantAttributes(t.constantAttributes),t.bindings&&this.setBindings(t.bindings),t.transformFeedback&&(this.transformFeedback=t.transformFeedback)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}getBindingDebugTable(){return this._bindingTable}predraw(e){this._syncDynamicBuffers(),this.updateShaderInputs(e),this.material?.updateShaderInputs(e),this.pipeline=this._updatePipeline()}draw(e){if(this._drawBlockedReason&&!this._pipelineNeedsUpdate)return N.info(Xn,`>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)(),!1;let t=this._areBindingsLoading();if(t)return N.info(Xn,`>>> DRAWING ABORTED ${this.id}: ${t} not loaded`)(),!1;this._syncAttachmentFormats(e);try{e.pushDebugGroup(`${this}.predraw(${e})`),this.device.type==="webgpu"?(this.updateShaderInputs(),this.material?.updateShaderInputs(),this._syncDynamicBuffers(),this.pipeline=this._updatePipeline()):this.predraw(this.device.commandEncoder)}finally{e.popDebugGroup()}let i,r=this.pipeline.isErrored;try{if(e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline(),r=this.pipeline.isErrored,r)N.info(Xn,`>>> DRAWING ABORTED ${this.id}: ${O_}`)(),i=!1;else{let s=this.vertexArray.getDrawValidationError();if(s)N.info(Xn,`>>> DRAWING ABORTED ${this.id}: ${s}`)(),this._drawBlockedReason=s,i=!1;else{let o=this._getCurrentShaderLayout(),a=this._getBindings(o),c=this._getBindGroups(o,a),{indexBuffer:l}=this.vertexArray,u=l?this.indexCount??(this._vertexCountSet?this.vertexCount:l.byteLength/(l.indexType==="uint32"?4:2)):void 0;e.setPipeline(this.pipeline),e.setBindings(c,{_bindGroupCacheKeys:this._getBindGroupCacheKeys()}),e.setVertexArray(this.vertexArray),i=this.isInstanced===!0&&this.instanceCount===0?!0:e.draw({isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.isInstanced?this.instanceCount:void 0,indexCount:u,firstVertex:this.firstVertex,firstIndex:this.firstIndex,transformFeedback:this.transformFeedback||void 0,uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}}}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),i?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):r?(this._needsRedraw=O_,this._drawBlockedReason=O_):this._drawBlockedReason?this._needsRedraw=this._drawBlockedReason:this._needsRedraw="waiting for resource initialization",i}setGeometry(e){this._gpuGeometry?.destroy();let t=e&&w1(this.device,e);if(t){this.setTopology(t.topology||"triangle-list");let i=new bo(this.bufferLayout);this.bufferLayout=i.mergeBufferLayouts(t.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(t)}this._gpuGeometry=t}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){let t=new bo(this.bufferLayout),i=this._gpuGeometry?t.mergeBufferLayouts(e,this._gpuGeometry.bufferLayout):e;yo(i,this.bufferLayout,-1)||(this.bufferLayout=i,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry))}setParameters(e){yo(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,this.isInstanced===void 0&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this._vertexCountSet=!0,this.setNeedsRedraw("vertexCount")}setIndexCount(e){this.indexCount=e,this.setNeedsRedraw("indexCount")}setDrawOffsets({firstVertex:e,firstIndex:t}){this.firstVertex=e,this.firstIndex=t,this.setNeedsRedraw("drawOffsets")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new Nr(this.device,this.shaderInputs.modules);for(let[t,i]of Object.entries(this.shaderInputs.modules))if(_c(i)&&!this.material?.ownsModule(t)){let r=this._uniformStore.getManagedUniformBuffer(t);this.bindings[`${t}Uniforms`]=r}this.setNeedsRedraw("shaderInputs")}setMaterial(e){this.material=e,this.setNeedsRedraw("material")}updateShaderInputs(e){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),e),this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues())),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){let t=e instanceof tt?e.buffer:e;this.indexBuffer=t,this._dynamicIndexBufferSource=e instanceof tt?{source:e,generation:e.generation}:null,this.vertexArray.setIndexBuffer(t),this.setNeedsRedraw("indexBuffer")}setAttributes(e,t){this._drawBlockedReason=!1;let i=t?.disableWarnings??this.props.disableWarnings;e.indices&&N.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=R1(this.pipeline.shaderLayout,this.bufferLayout);let r=new bo(this.bufferLayout);for(let[s,o]of Object.entries(e)){let a=o instanceof tt?o.buffer:o,c=r.getBufferLayout(s);if(!c){i||N.warn(`Model(${this.id}): Missing layout for buffer "${s}".`)();continue}let l=r.getAttributeNamesForBuffer(c),u=!1;for(let f of l){let d=this._attributeInfos[f];if(d){let h=this.device.type==="webgpu"?this.vertexArray.getBufferSlot(d.bufferName):d.location;if(h===null){i||N.warn(`Model(${this.id}): Missing vertex array slot for buffer "${d.bufferName}".`)();continue}this.vertexArray.setBuffer(h,a),o instanceof tt?this._dynamicAttributeBufferSources[h]={source:o,generation:o.generation}:delete this._dynamicAttributeBufferSources[h],u=!0}}!u&&!i&&N.warn(`Model(${this.id}): Ignoring buffer "${a.id}" for unknown attribute "${s}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,t){for(let[i,r]of Object.entries(e)){let s=this._attributeInfos[i];s?this.vertexArray.setConstantWebGL(s.location,r):(t?.disableWarnings??this.props.disableWarnings)||N.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(let e of Object.values(this.bindings))if(bc(e)&&!e.isReady)return e.id;for(let e of Object.values(this.material?.bindings||{}))if(bc(e)&&!e.isReady)return e.id;return!1}_getBindings(e=this._getCurrentShaderLayout()){let t={};for(let[i,r]of Object.entries(this.bindings)){let s=QF(i,r,e);s&&(t[i]=s)}return t}_getBindGroups(e=this._getCurrentShaderLayout(),t=this._getBindings(e)){let i=e.bindings.length?Or(e,t):{0:t};if(!this.material)return i;for(let[r,s]of Object.entries(this.material.getBindingsByGroup(e))){let o=Number(r);i[o]={...i[o]||{},...s}}return i}_getBindGroupCacheKeys(){let e=this.material?.getBindGroupCacheKey(3);return e?{3:e}:{}}_getBindingsUpdateTimestamp(){let e=0;this._dynamicIndexBufferSource&&(e=Math.max(e,this._dynamicIndexBufferSource.source.updateTimestamp));for(let t of Object.values(this._dynamicAttributeBufferSources))e=Math.max(e,t.source.updateTimestamp);for(let t of Object.values(this.bindings))t instanceof Ar?e=Math.max(e,t.texture.updateTimestamp):t instanceof ie||t instanceof me||t instanceof Aa||t instanceof tt?e=Math.max(e,t.updateTimestamp):bc(t)?e=t.isReady?Math.max(e,t.updateTimestamp):1/0:I_(t)&&(e=Math.max(e,(t.buffer instanceof tt,t.buffer.updateTimestamp)));return Math.max(e,this.material?.getBindingsUpdateTimestamp()||0)}_setGeometryAttributes(e){let t={...e.attributes};for(let[i]of Object.entries(t))!this.pipeline.shaderLayout.attributes.find(r=>r.name===i)&&i!=="positions"&&delete t[i];this.vertexCount=e.vertexCount,this._vertexCountSet=!0,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(t,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this._drawBlockedReason=!1,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,t=null;this.pipeline&&(N.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,t=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let i=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders}),r=null;this.source?r=i:this.fs&&(r=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bindings:void 0,bufferLayout:this.bufferLayout,colorAttachmentFormats:this._colorAttachmentFormats,depthStencilAttachmentFormat:this._depthStencilAttachmentFormat,topology:this.topology,parameters:this.parameters,bindGroups:void 0,vs:i,fs:r}),this._attributeInfos=$a(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&t!==e&&this.shaderFactory.release(t)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=N.level>3?0:ZF;N.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:N.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=S1(this.pipeline.shaderLayout,this.id);N.table(Xn,e)();let t=this.shaderInputs.getDebugTable();N.table(Xn,t)();let i=this._getAttributeDebugTable();N.table(Xn,this._attributeInfos)(),N.table(Xn,i)(),N.groupEnd(Xn)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){let t=this.device.props.debugFramebuffers;if(this._drawCount++,!t)return;let i=e.props.framebuffer;L1(e,i,{id:i?.id||`${this.id}-framebuffer`,minimap:!0})}_getAttributeDebugTable(){let e={};for(let[t,i]of Object.entries(this._attributeInfos)){let r=this.vertexArray.attributes[i.location];e[i.location]={name:t,type:i.shaderType,values:r?this._getBufferOrConstantValues(r,i.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:t}=this.vertexArray,i=t.indexType==="uint32"?new Uint32Array(t.debugData):new Uint16Array(t.debugData);e.indices={name:"indices",type:t.indexType,values:i.toString()}}return e}_getBufferOrConstantValues(e,t){let i=Xe.getTypedArrayConstructor(t);return(e instanceof ie?new i(e.debugData):e).toString()}_getNonMaterialBindings(e){if(!this.material)return e;let t={};for(let[i,r]of Object.entries(e))this.material.ownsBinding(i)||(t[i]=r);return t}_getCurrentShaderLayout(){return this.pipeline?.shaderLayout||this.props.shaderLayout||{bindings:[]}}_syncDynamicBuffers(){if(this._dynamicIndexBufferSource&&this._dynamicIndexBufferSource.generation!==this._dynamicIndexBufferSource.source.generation){let e=this._dynamicIndexBufferSource.source.buffer;this.indexBuffer=e,this.vertexArray.setIndexBuffer(e),this._dynamicIndexBufferSource.generation=this._dynamicIndexBufferSource.source.generation,this.setNeedsRedraw("dynamic index buffer")}for(let[e,t]of Object.entries(this._dynamicAttributeBufferSources))t.generation!==t.source.generation&&(this.vertexArray.setBuffer(Number(e),t.source.buffer),t.generation=t.source.generation,this.setNeedsRedraw("dynamic attribute buffer"))}_syncAttachmentFormats(e){if(this.device.type!=="webgpu")return;let t=e.framebuffer||e.props.framebuffer,i=e.props,r=i.colorAttachmentFormats??t?.colorAttachments?.map(o=>JF(o?.texture?.format)),s=i.depthStencilAttachmentFormat===!1?void 0:i.depthStencilAttachmentFormat??e6(t?.depthStencilAttachment?.texture?.format);(!yo(this._colorAttachmentFormats,r,1)||this._depthStencilAttachmentFormat!==s)&&(this._colorAttachmentFormats=r,this._depthStencilAttachmentFormat=s,this._setPipelineNeedsUpdate("attachment formats"))}}});var n6,i6,nt,V1=C(()=>{J();vt();N_();n6=35980,i6=35981,nt=class n{device;model;transformFeedback;static defaultProps={...Ze.defaultProps,feedbackBufferMode:"separate",outputs:void 0,feedbackBuffers:void 0};static isSupported(e){return e?.info?.type==="webgl"}constructor(e,t=n.defaultProps){if(!n.isSupported(e))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=e,this.model=new Ze(this.device,{id:t.id||"buffer-transform-model",fs:t.fs||hg(),topology:t.topology||"point-list",varyings:t.outputs||t.varyings,...t,bufferMode:t.bufferMode||(t.feedbackBufferMode==="interleaved"?n6:i6)}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:t.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){e?.inputBuffers&&this.model.setAttributes(e.inputBuffers),e?.outputBuffers&&this.transformFeedback.setBuffers(e.outputBuffers);let t=this.device.beginRenderPass({discard:!0,...e});this.model.draw(t),t.end()}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){let t=this.getBuffer(e);if(!t)throw new Error("BufferTransform#getBuffer");if(t instanceof ie)return t.readAsync();let{buffer:i,byteOffset:r=0,byteLength:s=i.byteLength}=t;return i.readAsync(r,s)}}});function s6(n){return{type:n.type,shaderLanguage:n.info.shadingLanguage,shaderLanguageVersion:n.info.shadingLanguageVersion,gpu:n.info.gpu,limits:n.limits,features:n.features}}var F_,r6,Bt,W1=C(()=>{J();vt();Jp();R_();L_();_o();F_=2,r6=1e4,Bt=class n{static defaultProps={...Hi.defaultProps,id:"unnamed",handle:void 0,userData:{},source:"",modules:[],defines:{},plugins:[],bindings:void 0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,shaderAssembler:Xt.getDefaultShaderAssembler("wgsl"),debugShaders:void 0};device;id;pipelineFactory;shaderFactory;userData={};bindings={};pipeline;source;shader;shaderInputs;_uniformStore;_pipelineNeedsUpdate="newly created";_getModuleUniforms;props;_destroyed=!1;constructor(e,t){if(e.type!=="webgpu")throw new Error("Computation is only supported in WebGPU");this.props={...n.defaultProps,...t},t=this.props,this.id=t.id||Zn("model"),this.device=e,Object.assign(this.userData,t.userData);let i=s6(e),r=Ga(this.props.plugins,i.shaderLanguage);if(Object.keys(r.vertexInputs).length>0||Object.keys(r.varyings).length>0)throw new Error("Computation does not support ShaderPlugin vertex inputs or varyings");let s=Va(this.props.modules,r.modules),o=Object.fromEntries(s.map(p=>[p.name,p]));this.shaderInputs=t.shaderInputs||new xo(o),t.shaderInputs&&r.modules.length>0&&this.shaderInputs.addModules(r.modules),this.setShaderInputs(this.shaderInputs);let a=Bf(this.props.modules,this.shaderInputs?.getModules()),c={...r.defines,...this.props.defines};this.props.shaderLayout=vo(this.props.shaderLayout,a)||null,this.pipelineFactory=t.pipelineFactory||Ir.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||Br.getDefaultShaderFactory(this.device);let l=this.props.shaderAssembler;Vi(l instanceof qi);let{source:u,getUniforms:f,shaderLayout:d}=l.assembleWGSLShader({platformInfo:i,...this.props,modules:a,defines:c,scanVertexAttributes:!1,pluginInjections:r.injections});this.source=u,this._getModuleUniforms=f;let h=d??e.getShaderLayout?.(this.source,{scanVertexAttributes:!1});this.props.shaderLayout=vo(this.props.shaderLayout||h||null,a)||null,this.pipeline=this._updatePipeline(),t.bindings&&this.setBindings(t.bindings)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.shader),this._uniformStore.destroy(),this._destroyed=!0)}predraw(e){this.updateShaderInputs(e)}dispatch(e,t,i,r){try{this._logDrawCallStart(),this._setPipeline(e),e.dispatch(t,i,r)}finally{this._logDrawCallEnd()}}dispatchIndirect(e,t,i=0){try{this._logDrawCallStart(),this._setPipeline(e),e.dispatchIndirect(t,i)}finally{this._logDrawCallEnd()}}_setPipeline(e){this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings),e.setPipeline(this.pipeline),e.setBindings({})}setVertexCount(e){}setInstanceCount(e){}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new Nr(this.device,this.shaderInputs.modules);for(let[t,i]of Object.entries(this.shaderInputs.modules))if(_c(i)){let r=this._uniformStore.getManagedUniformBuffer(t);this.bindings[`${t}Uniforms`]=r}}setShaderModuleProps(e){let t=this._getModuleUniforms(e),i=Object.keys(t).filter(s=>{let o=t[s];return!_a(o)&&typeof o!="number"&&typeof o!="boolean"}),r={};for(let s of i)r[s]=t[s],delete t[s]}updateShaderInputs(e){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),e)}setBindings(e){Object.assign(this.bindings,e)}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate=this._pipelineNeedsUpdate||e}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null;this.pipeline&&(N.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.shader),this._pipelineNeedsUpdate=!1,this.shader=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"compute",source:this.source,debugShaders:this.props.debugShaders}),this.pipeline=this.pipelineFactory.createComputePipeline({...this.props,shader:this.shader}),e&&this.shaderFactory.release(e)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=N.level>3?0:r6;N.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:N.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=this.shaderInputs.getDebugTable();N.table(F_,e)(),N.groupEnd(F_)(),this._logOpen=!1}}_drawCount=0;_getBufferOrConstantValues(e,t){let i=Xe.getTypedArrayConstructor(t);return(e instanceof ie?new i(e.debugData):e).toString()}}});var Me=C(()=>{g1();x1();N_();V1();Rf();B_();W1()});function s2(n=!0){let e=HTMLCanvasElement.prototype;if(!n&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(t,i){if(t==="webgl"||t==="experimental-webgl"){let r=this.originalGetContext("webgl2",i);return r instanceof HTMLElement&&D6(r),r}return this.originalGetContext(t,i)}}function D6(n){n.getExtension("EXT_color_buffer_float");let e={...R6,WEBGL_disjoint_timer_query:n.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:I6(n),OES_vertex_array_object:B6(n),ANGLE_instanced_arrays:O6(n)},t=n.getExtension.bind(n);n.getExtension=function(r){let s=t(r);return s||(r in e?e[r]:null)};let i=n.getSupportedExtensions;n.getSupportedExtensions=function(){return(i.apply(n)||[])?.concat(Object.keys(e))}}var R6,I6,B6,O6,o2=C(()=>{R6={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},I6=n=>({drawBuffersWEBGL(e){return n.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),B6=n=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return n.createVertexArray()},deleteVertexArrayOES(e){return n.deleteVertexArray(e)},isVertexArrayOES(e){return n.isVertexArray(e)},bindVertexArrayOES(e){return n.bindVertexArray(e)}}),O6=n=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return n.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return n.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return n.vertexAttribDivisor(...e)}})});async function c2(){if(!Gf){Z_();return}await Gf.load()}function l2(n,e){return Gf?Gf.makeDebugContext(n,e):(Z_(),n)}async function u2(n){if(!q_){Z_();return}await q_.load(n)}function f2(n){return q_?.initialize(n)||null}function Z_(){a2||(a2=!0,N.warn("Import @luma.gl/webgl/debug before enabling WebGL debugging.")())}var Gf,q_,a2,X_=C(()=>{J();Gf=null,q_=null,a2=!1});function K_(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Ie(n,e,t){return e[n]!==void 0?e[n]:t[n]}var Oc,$e,d2,Ot,h2,Bc,p2,m2,Q_,ei,J_,g2,ey=C(()=>{Oc={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},$e=(n,e,t)=>e?n.enable(t):n.disable(t),d2=(n,e,t)=>n.hint(t,e),Ot=(n,e,t)=>n.pixelStorei(t,e),h2=(n,e,t)=>{let i=t===36006?36009:36008;return n.bindFramebuffer(i,e)},Bc=(n,e,t)=>{let r={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[t];n.bindBuffer(r,e)};p2={3042:$e,32773:(n,e)=>n.blendColor(...e),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(n,e)=>n.clearColor(...e),3107:(n,e)=>n.colorMask(...e),2884:$e,2885:(n,e)=>n.cullFace(e),2929:$e,2931:(n,e)=>n.clearDepth(e),2932:(n,e)=>n.depthFunc(e),2928:(n,e)=>n.depthRange(...e),2930:(n,e)=>n.depthMask(e),3024:$e,35723:d2,35725:(n,e)=>n.useProgram(e),36007:(n,e)=>n.bindRenderbuffer(36161,e),36389:(n,e)=>n.bindTransformFeedback?.(36386,e),34229:(n,e)=>n.bindVertexArray(e),36006:h2,36010:h2,34964:Bc,36662:Bc,36663:Bc,35053:Bc,35055:Bc,2886:(n,e)=>n.frontFace(e),33170:d2,2849:(n,e)=>n.lineWidth(e),32823:$e,32824:"polygonOffset",10752:"polygonOffset",35977:$e,32926:$e,32928:$e,32938:"sampleCoverage",32939:"sampleCoverage",3089:$e,3088:(n,e)=>n.scissor(...e),2960:$e,2961:(n,e)=>n.clearStencil(e),2968:(n,e)=>n.stencilMaskSeparate(1028,e),36005:(n,e)=>n.stencilMaskSeparate(1029,e),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(n,e)=>n.viewport(...e),34383:$e,10754:$e,12288:$e,12289:$e,12290:$e,12291:$e,12292:$e,12293:$e,12294:$e,12295:$e,3333:Ot,3317:Ot,37440:Ot,37441:Ot,37443:Ot,3330:Ot,3332:Ot,3331:Ot,3314:Ot,32878:Ot,3316:Ot,3315:Ot,32877:Ot,framebuffer:(n,e)=>{let t=e&&"handle"in e?e.handle:e;return n.bindFramebuffer(36160,t)},blend:(n,e)=>e?n.enable(3042):n.disable(3042),blendColor:(n,e)=>n.blendColor(...e),blendEquation:(n,e)=>{let t=typeof e=="number"?[e,e]:e;n.blendEquationSeparate(...t)},blendFunc:(n,e)=>{let t=e?.length===2?[...e,...e]:e;n.blendFuncSeparate(...t)},clearColor:(n,e)=>n.clearColor(...e),clearDepth:(n,e)=>n.clearDepth(e),clearStencil:(n,e)=>n.clearStencil(e),colorMask:(n,e)=>n.colorMask(...e),cull:(n,e)=>e?n.enable(2884):n.disable(2884),cullFace:(n,e)=>n.cullFace(e),depthTest:(n,e)=>e?n.enable(2929):n.disable(2929),depthFunc:(n,e)=>n.depthFunc(e),depthMask:(n,e)=>n.depthMask(e),depthRange:(n,e)=>n.depthRange(...e),dither:(n,e)=>e?n.enable(3024):n.disable(3024),derivativeHint:(n,e)=>{n.hint(35723,e)},frontFace:(n,e)=>n.frontFace(e),mipmapHint:(n,e)=>n.hint(33170,e),lineWidth:(n,e)=>n.lineWidth(e),polygonOffsetFill:(n,e)=>e?n.enable(32823):n.disable(32823),polygonOffset:(n,e)=>n.polygonOffset(...e),sampleCoverage:(n,e)=>n.sampleCoverage(e[0],e[1]||!1),scissorTest:(n,e)=>e?n.enable(3089):n.disable(3089),scissor:(n,e)=>n.scissor(...e),stencilTest:(n,e)=>e?n.enable(2960):n.disable(2960),stencilMask:(n,e)=>{e=K_(e)?e:[e,e];let[t,i]=e;n.stencilMaskSeparate(1028,t),n.stencilMaskSeparate(1029,i)},stencilFunc:(n,e)=>{e=K_(e)&&e.length===3?[...e,...e]:e;let[t,i,r,s,o,a]=e;n.stencilFuncSeparate(1028,t,i,r),n.stencilFuncSeparate(1029,s,o,a)},stencilOp:(n,e)=>{e=K_(e)&&e.length===3?[...e,...e]:e;let[t,i,r,s,o,a]=e;n.stencilOpSeparate(1028,t,i,r),n.stencilOpSeparate(1029,s,o,a)},viewport:(n,e)=>n.viewport(...e)};m2={blendEquation:(n,e,t)=>n.blendEquationSeparate(Ie(32777,e,t),Ie(34877,e,t)),blendFunc:(n,e,t)=>n.blendFuncSeparate(Ie(32969,e,t),Ie(32968,e,t),Ie(32971,e,t),Ie(32970,e,t)),polygonOffset:(n,e,t)=>n.polygonOffset(Ie(32824,e,t),Ie(10752,e,t)),sampleCoverage:(n,e,t)=>n.sampleCoverage(Ie(32938,e,t),Ie(32939,e,t)),stencilFuncFront:(n,e,t)=>n.stencilFuncSeparate(1028,Ie(2962,e,t),Ie(2967,e,t),Ie(2963,e,t)),stencilFuncBack:(n,e,t)=>n.stencilFuncSeparate(1029,Ie(34816,e,t),Ie(36003,e,t),Ie(36004,e,t)),stencilOpFront:(n,e,t)=>n.stencilOpSeparate(1028,Ie(2964,e,t),Ie(2965,e,t),Ie(2966,e,t)),stencilOpBack:(n,e,t)=>n.stencilOpSeparate(1029,Ie(34817,e,t),Ie(34818,e,t),Ie(34819,e,t))},Q_={enable:(n,e)=>n({[e]:!0}),disable:(n,e)=>n({[e]:!1}),pixelStorei:(n,e,t)=>n({[e]:t}),hint:(n,e,t)=>n({[e]:t}),useProgram:(n,e)=>n({35725:e}),bindRenderbuffer:(n,e,t)=>n({36007:t}),bindTransformFeedback:(n,e,t)=>n({36389:t}),bindVertexArray:(n,e)=>n({34229:e}),bindFramebuffer:(n,e,t)=>{switch(e){case 36160:return n({36006:t,36010:t});case 36009:return n({36006:t});case 36008:return n({36010:t});default:return null}},bindBuffer:(n,e,t)=>{let i={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[e];return i?n({[i]:t}):{valueChanged:!0}},blendColor:(n,e,t,i,r)=>n({32773:new Float32Array([e,t,i,r])}),blendEquation:(n,e)=>n({32777:e,34877:e}),blendEquationSeparate:(n,e,t)=>n({32777:e,34877:t}),blendFunc:(n,e,t)=>n({32969:e,32968:t,32971:e,32970:t}),blendFuncSeparate:(n,e,t,i,r)=>n({32969:e,32968:t,32971:i,32970:r}),clearColor:(n,e,t,i,r)=>n({3106:new Float32Array([e,t,i,r])}),clearDepth:(n,e)=>n({2931:e}),clearStencil:(n,e)=>n({2961:e}),colorMask:(n,e,t,i,r)=>n({3107:[e,t,i,r]}),cullFace:(n,e)=>n({2885:e}),depthFunc:(n,e)=>n({2932:e}),depthRange:(n,e,t)=>n({2928:new Float32Array([e,t])}),depthMask:(n,e)=>n({2930:e}),frontFace:(n,e)=>n({2886:e}),lineWidth:(n,e)=>n({2849:e}),polygonOffset:(n,e,t)=>n({32824:e,10752:t}),sampleCoverage:(n,e,t)=>n({32938:e,32939:t}),scissor:(n,e,t,i,r)=>n({3088:new Int32Array([e,t,i,r])}),stencilMask:(n,e)=>n({2968:e,36005:e}),stencilMaskSeparate:(n,e,t)=>n({[e===1028?2968:36005]:t}),stencilFunc:(n,e,t,i)=>n({2962:e,2967:t,2963:i,34816:e,36003:t,36004:i}),stencilFuncSeparate:(n,e,t,i,r)=>n({[e===1028?2962:34816]:t,[e===1028?2967:36003]:i,[e===1028?2963:36004]:r}),stencilOp:(n,e,t,i)=>n({2964:e,2965:t,2966:i,34817:e,34818:t,34819:i}),stencilOpSeparate:(n,e,t,i,r)=>n({[e===1028?2964:34817]:t,[e===1028?2965:34818]:i,[e===1028?2966:34819]:r}),viewport:(n,e,t,i,r)=>n({2978:[e,t,i,r]})},ei=(n,e)=>n.isEnabled(e),J_={3042:ei,2884:ei,2929:ei,3024:ei,32823:ei,32926:ei,32928:ei,3089:ei,2960:ei,35977:ei},g2=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068])});function bn(n,e){if(N6(e))return;let t={};for(let r in e){let s=Number(r),o=p2[r];o&&(typeof o=="string"?t[o]=!0:o(n,e[r],s))}let i=n.lumaState?.cache;if(i)for(let r in t){let s=m2[r];s(n,e,i)}}function Vf(n,e=Oc){if(typeof e=="number"){let r=e,s=J_[r];return s?s(n,r):n.getParameter(r)}let t=Array.isArray(e)?e:Object.keys(e),i={};for(let r of t){let s=J_[r];i[r]=s?s(n,Number(r)):n.getParameter(Number(r))}return i}function _2(n){bn(n,Oc)}function N6(n){for(let e in n)return!1;return!0}var Po=C(()=>{ey()});function b2(n,e){if(n===e)return!0;if(y2(n)&&y2(e)&&n.length===e.length){for(let t=0;t{});function x2(n,e){let t=n[e].bind(n);n[e]=function(r){if(r===void 0||g2.has(r))return t(r);let s=vn.get(n);return r in s.cache||(s.cache[r]=t(r)),s.enable?s.cache[r]:t(r)},Object.defineProperty(n[e],"name",{value:`${e}-from-cache`,configurable:!1})}function F6(n,e,t){if(!n[e])return;let i=n[e].bind(n);n[e]=function(...s){let o=vn.get(n),{valueChanged:a,oldValue:c}=t(o._updateCache,...s);return a&&i(...s),c},Object.defineProperty(n[e],"name",{value:`${e}-to-cache`,configurable:!1})}function z6(n){let e=n.useProgram.bind(n);n.useProgram=function(i){let r=vn.get(n);r.program!==i&&(e(i),r.program=i)}}var vn,ty=C(()=>{Po();v2();ey();vn=class{static get(e){return e.lumaState}gl;program=null;stateStack=[];enable=!0;cache=null;log;initialized=!1;constructor(e,t){this.gl=e,this.log=t?.log||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){let e=this.stateStack[this.stateStack.length-1];bn(this.gl,e),this.stateStack.pop()}trackState(e,t){if(this.cache=t?.copyState?Vf(e):Object.assign({},Oc),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.lumaState=this,z6(e);for(let i in Q_){let r=Q_[i];F6(e,i,r)}x2(e,"getParameter"),x2(e,"isEnabled")}_updateCache(e){let t=!1,i,r=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let s in e){let o=e[s],a=this.cache[s];b2(o,a)||(t=!0,i=a,r&&!(s in r)&&(r[s]=a),this.cache[s]=o)}return{valueChanged:t,oldValue:i}}}});function Dc(n){let e=n.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return e._polyfilled??=!1,e.extensions||={},n.luma=e,e}var ny=C(()=>{});function w2(n,e,t){let i="",r=c=>{let l=c.statusMessage;l&&(i||=l)};n.addEventListener("webglcontextcreationerror",r,!1);let s=t.failIfMajorPerformanceCaveat!==!0,o={preserveDrawingBuffer:!0,...t,failIfMajorPerformanceCaveat:!0},a=null;try{a||=n.getContext("webgl2",o),!a&&o.failIfMajorPerformanceCaveat&&(i||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.");let c=!1;if(!a&&s&&(o.failIfMajorPerformanceCaveat=!1,a=n.getContext("webgl2",o),c=!0),a||(a=n.getContext("webgl",{}),a&&(a=null,i||="Your browser only supports WebGL1")),!a)throw i||="Your browser does not support WebGL",new Error(`Failed to create WebGL context: ${i}`);let l=Dc(a);l.softwareRenderer=c;let{onContextLost:u,onContextRestored:f}=e;return n.addEventListener("webglcontextlost",d=>u(d),!1),n.addEventListener("webglcontextrestored",d=>f(d),!1),a}finally{n.removeEventListener("webglcontextcreationerror",r,!1)}}var E2=C(()=>{ny()});function xn(n,e,t){return t[e]===void 0&&(t[e]=n.getExtension(e)||null),t[e]}var Nc=C(()=>{});function S2(n,e){let t=n.getParameter(7936),i=n.getParameter(7937);xn(n,"WEBGL_debug_renderer_info",e);let r=e.WEBGL_debug_renderer_info,s=n.getParameter(r?r.UNMASKED_VENDOR_WEBGL:7936),o=n.getParameter(r?r.UNMASKED_RENDERER_WEBGL:7937),a=s||t,c=o||i,l=n.getParameter(7938),u=P2(a,c),f=U6(a,c),d=$6(a,c);return{type:"webgl",gpu:u,gpuType:d,gpuBackend:f,vendor:a,renderer:c,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function P2(n,e){return/NVIDIA/i.exec(n)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(n)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(n)||/Apple/i.exec(e)?"apple":/AMD/i.exec(n)||/AMD/i.exec(e)||/ATI/i.exec(n)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(n)||/SwiftShader/i.exec(e)?"software":"unknown"}function U6(n,e){return/Metal/i.exec(n)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(n)||/ANGLE/i.exec(e)?"opengl":"unknown"}function $6(n,e){if(/SwiftShader/i.exec(n)||/SwiftShader/i.exec(e))return"cpu";switch(P2(n,e)){case"apple":return G6(n,e)?"integrated":"unknown";case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function G6(n,e){return/Apple (M\d|A\d|GPU)/i.test(`${n} ${e}`)}var C2=C(()=>{Nc()});function Wf(n){switch(n){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(n))}var iy=C(()=>{});function M2(n){return n in Hf}function cy(n,e,t){return A2(n,e,t,new Set)}function A2(n,e,t,i){let r=Hf[e];if(!r||i.has(e))return!1;i.add(e);let s=(r.features||[]).every(o=>A2(n,o,t,i));return i.delete(e),s?(r.extensions||[]).every(o=>!!xn(n,o,t)):!1}function k2(n,e,t){let i=e.create,r=Yf[e.format];r?.gl===void 0&&(i=!1),r?.x&&(i=i&&!!xn(n,r.x,t)),e.format==="stencil8"&&(i=!1);let s=r?.r===!1?!1:r?.r===void 0||cy(n,r.r,t),o=i&&e.render&&s&&X6(n,e.format,t);return{format:e.format,create:i&&e.create,render:o,filter:i&&e.filter,blend:i&&e.blend,store:i&&e.store}}function X6(n,e,t){let i=Yf[e],r=i?.gl;if(r===void 0||i?.x&&!xn(n,i.x,t))return!1;let s=n.getParameter(32873),o=n.getParameter(36006),a=n.createTexture(),c=n.createFramebuffer();if(!a||!c)return!1;let l=0,u=Number(n.getError());for(;u!==l;)u=n.getError();let f=!1;try{if(n.bindTexture(3553,a),n.texStorage2D(3553,1,r,1,1),Number(n.getError())!==l)return!1;n.bindFramebuffer(36160,c),n.framebufferTexture2D(36160,36064,3553,a,0),f=Number(n.checkFramebufferStatus(36160))===36053&&Number(n.getError())===l}finally{n.bindFramebuffer(36160,o),n.deleteFramebuffer(c),n.bindTexture(3553,s),n.deleteTexture(a)}return f}function qf(n){let e=Yf[n],t=Q6(n),i=ft.getInfo(n);return i.compressed&&(e.dataFormat=t),{internalFormat:t,format:e?.dataFormat||K6(i.channels,i.integer,i.normalized,t),type:i.dataType?Wf(i.dataType):e?.types?.[0]||5121,compressed:i.compressed||!1}}function R2(n){switch(ft.getInfo(n).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${n}`)}}function K6(n,e,t,i){if(i===6408||i===6407)return i;switch(n){case"r":return e&&!t?36244:6403;case"rg":return e&&!t?33320:33319;case"rgb":return e&&!t?36248:6407;case"rgba":return e&&!t?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function Q6(n){let t=Yf[n]?.gl;if(t===void 0)throw new Error(`Unsupported texture format ${n}`);return t}var Fc,zc,Co,To,V6,W6,j6,H6,Y6,q6,T2,L2,ry,sy,oy,ay,jf,Z6,Hf,Yf,Lo=C(()=>{J();Nc();iy();Fc="WEBGL_compressed_texture_s3tc",zc="WEBGL_compressed_texture_s3tc_srgb",Co="EXT_texture_compression_rgtc",To="EXT_texture_compression_bptc",V6="WEBGL_compressed_texture_etc",W6="WEBGL_compressed_texture_astc",j6="WEBGL_compressed_texture_etc1",H6="WEBGL_compressed_texture_pvrtc",Y6="WEBGL_compressed_texture_atc",q6="EXT_texture_norm16",T2="EXT_render_snorm",L2="EXT_color_buffer_float",ry="snorm8-renderable-webgl",sy="norm16-renderable-webgl",oy="snorm16-renderable-webgl",ay="float16-renderable-webgl",jf="float32-renderable-webgl",Z6="rgb9e5ufloat-renderable-webgl",Hf={"float32-renderable-webgl":{extensions:[L2]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[T2]},"norm16-webgl":{extensions:[q6]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[T2]},"float32-filterable":{extensions:["OES_texture_float_linear"]},"float16-filterable-webgl":{extensions:["OES_texture_half_float_linear"]},"texture-filterable-anisotropic-webgl":{extensions:["EXT_texture_filter_anisotropic"]},"texture-blend-float-webgl":{extensions:["EXT_float_blend"]},"texture-compression-bc":{extensions:[Fc,zc,Co,To]},"texture-compression-bc5-webgl":{extensions:[Co]},"texture-compression-bc7-webgl":{extensions:[To]},"texture-compression-etc2":{extensions:[V6]},"texture-compression-astc":{extensions:[W6]},"texture-compression-etc1-webgl":{extensions:[j6]},"texture-compression-pvrtc-webgl":{extensions:[H6]},"texture-compression-atc-webgl":{extensions:[Y6]}};Yf={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:ry},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:ry},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0,r:ay},r16unorm:{gl:33322,rb:!0,r:sy},r16snorm:{gl:36760,r:oy},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759,r:ry},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:ay},rg16unorm:{gl:33324,r:sy},rg16snorm:{gl:36761,r:oy},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:jf},rgb9e5ufloat:{gl:35901,r:Z6},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852,r:!1},"rgb16snorm-webgl":{gl:36762,r:!1},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0,r:jf},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:ay},rgba16unorm:{gl:32859,rb:!0,r:sy},rgba16snorm:{gl:36763,r:oy},"rgb32float-webgl":{gl:34837,x:L2,r:jf,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:jf},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:Fc},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:zc},"bc1-rgba-unorm":{gl:33777,x:Fc},"bc1-rgba-unorm-srgb":{gl:35916,x:zc},"bc2-rgba-unorm":{gl:33778,x:Fc},"bc2-rgba-unorm-srgb":{gl:35918,x:zc},"bc3-rgba-unorm":{gl:33779,x:Fc},"bc3-rgba-unorm-srgb":{gl:35919,x:zc},"bc4-r-unorm":{gl:36283,x:Co},"bc4-r-snorm":{gl:36284,x:Co},"bc5-rg-unorm":{gl:36285,x:Co},"bc5-rg-snorm":{gl:36286,x:Co},"bc6h-rgb-ufloat":{gl:36495,x:To},"bc6h-rgb-float":{gl:36494,x:To},"bc7-rgba-unorm":{gl:36492,x:To},"bc7-rgba-unorm-srgb":{gl:36493,x:To},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37816},"astc-10x5-unorm-srgb":{gl:37848},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rgb2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}}});var I2,Zf,B2=C(()=>{J();Nc();Lo();I2={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","html-in-canvas":n=>Om()&&typeof n.texElementImage2D=="function","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},Zf=class extends Ta{gl;extensions;testedFeatures=new Set;constructor(e,t,i){super([],i),this.gl=e,this.extensions=t,xn(e,"EXT_color_buffer_float",t)}*[Symbol.iterator](){let e=this.getFeatures();for(let t of e)this.has(t)&&(yield t);return[]}has(e){return this.disabledFeatures?.[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),M2(e)&&cy(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){let e=this.getFeatures().filter(t=>t!=="polygon-mode-webgl");for(let t of e)this.has(t)}getFeatures(){return[...Object.keys(I2),...Object.keys(Hf)]}getWebGLFeature(e){let t=I2[e];return typeof t=="string"?!!xn(this.gl,t,this.extensions):typeof t=="function"?t(this.gl):!!t}}});var Xf,O2=C(()=>{J();Xf=class extends Ca{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxBindGroupsPlusVertexBuffers(){return 0}get maxBindingsPerBindGroup(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageBuffersInVertexStage(){return 0}get maxStorageBuffersInFragmentStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxStorageTexturesInVertexStage(){return 0}get maxStorageTexturesInFragmentStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get maxBufferSize(){return Number.MAX_SAFE_INTEGER}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxColorAttachments(){return this.getParameter(36063)}get maxColorAttachmentBytesPerSample(){return 0}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]||0}}});function J6(n){return n<34069?n+34069:n}function ez(n){switch(n){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${n}`}}var ti,Kf=C(()=>{J();Lo();ti=class extends Rr{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(e,t){super(e,t);let i=t.handle,r=i===null;this.device=e,this.gl=e.gl,this.handle=i||r?i:this.gl.createFramebuffer(),r||(e._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),t.handle||(this.autoCreateAttachmentTextures(),this.updateAttachments()))}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&!this.props.handle&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){let e=this.gl.bindFramebuffer(36160,this.handle);for(let t=0;t{J();Kf();Qf=class extends La{device;handle=null;_framebuffer=null;get[Symbol.toStringTag](){return"WebGLCanvasContext"}constructor(e,t){super(t),this.device=e,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._configureDevice()}_configureDevice(){(this.drawingBufferWidth!==this._framebuffer?.width||this.drawingBufferHeight!==this._framebuffer?.height)&&this._framebuffer?.resize([this.drawingBufferWidth,this.drawingBufferHeight])}_getCurrentFramebuffer(){return this._framebuffer||=new ti(this.device,{id:"canvas-context-framebuffer",handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}}});var Jf,N2=C(()=>{J();Jf=class extends Ma{device;handle=null;context2d;get[Symbol.toStringTag](){return"WebGLPresentationContext"}constructor(e,t={}){super(t),this.device=e;let i=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw new Error(`${i}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);let s=this.canvas.getContext("2d");if(!s)throw new Error(`${i}: Failed to create 2d presentation context`);this.context2d=s,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();let e=this.device.getDefaultCanvasContext(),[t,i]=e.getDrawingBufferSize();if(!(this.drawingBufferWidth===0||this.drawingBufferHeight===0||t===0||i===0||e.canvas.width===0||e.canvas.height===0)){if(t!==this.drawingBufferWidth||i!==this.drawingBufferHeight||e.canvas.width!==this.drawingBufferWidth||e.canvas.height!==this.drawingBufferHeight)throw new Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${t}x${i} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(e.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(e){let t=this.device.getDefaultCanvasContext();return t.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),t.getCurrentFramebuffer(e)}}});function F2(n="id"){ly[n]=ly[n]||1;let e=ly[n]++;return`${n}-${e}`}var ly,z2=C(()=>{ly={}});function tz(n){return n&ie.INDEX?34963:n&ie.VERTEX?34962:n&ie.UNIFORM?35345:34962}function nz(n){return n&ie.INDEX||n&ie.VERTEX?35044:n&ie.UNIFORM?35048:35044}var wn,ed=C(()=>{J();wn=class extends ie{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength=0;bytesUsed=0;constructor(e,t={}){super(e,t),this.device=e,this.gl=this.device.gl;let i=typeof t=="object"?t.handle:void 0;this.handle=i||this.gl.createBuffer(),e._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=tz(this.props.usage),this.glUsage=nz(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,t.data?this._initWithData(t.data,t.byteOffset,t.byteLength):this._initWithByteLength(t.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Buffer"):(this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle)),this.destroyed=!0,this.handle=null)}_initWithData(e,t=0,i=e.byteLength+t){let r=this.glTarget;this.gl.bindBuffer(r,this.handle),this.gl.bufferData(r,i,this.glUsage),this.gl.bufferSubData(r,t,e),this.gl.bindBuffer(r,null),this.bytesUsed=i,this.byteLength=i,this._setDebugData(e,t,i),this.props.handle?this.trackReferencedMemory(i,"Buffer"):this.trackAllocatedMemory(i)}_initWithByteLength(e){let t=e;e===0&&(t=new Float32Array(0));let i=this.glTarget;return this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,t,this.glUsage),this.gl.bindBuffer(i,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.props.handle?this.trackReferencedMemory(e,"Buffer"):this.trackAllocatedMemory(e),this}write(e,t=0){let i=ArrayBuffer.isView(e)?e:new Uint8Array(e),r=0,s=void 0,o=36663;this.gl.bindBuffer(o,this.handle),r!==0||s!==void 0?this.gl.bufferSubData(o,t,i,r,s):this.gl.bufferSubData(o,t,i),this.gl.bindBuffer(o,null),this._setDebugData(e,t,e.byteLength)}async mapAndWriteAsync(e,t=0,i=this.byteLength-t){let r=new ArrayBuffer(i);await e(r,"copied"),this.write(r,t)}async readAsync(e=0,t){return this.readSyncWebGL(e,t)}async mapAndReadAsync(e,t=0,i){let r=await this.readAsync(t,i);return await e(r.buffer,"copied")}readSyncWebGL(e=0,t){t=t??this.byteLength-e;let i=new Uint8Array(t),r=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,i,r,t),this.gl.bindBuffer(36662,null),this._setDebugData(i,e,t),i}}});function U2(n){let e=n.split(/\r?\n/),t=[];for(let i of e){if(i.length<=1)continue;let r=i.trim(),s=i.split(":"),o=s[0]?.trim();if(s.length===2){let[h,p]=s;if(!h||!p){t.push({message:r,type:td(o||"info"),lineNum:0,linePos:0});continue}t.push({message:p.trim(),type:td(h),lineNum:0,linePos:0});continue}let[a,c,l,...u]=s;if(!a||!c||!l){t.push({message:s.slice(1).join(":").trim()||r,type:td(o||"info"),lineNum:0,linePos:0});continue}let f=parseInt(l,10);Number.isNaN(f)&&(f=0);let d=parseInt(c,10);Number.isNaN(d)&&(d=0),t.push({message:u.join(":").trim(),type:td(a),lineNum:f,linePos:d})}return t}function td(n){let e=["warning","error","info"],t=n.toLowerCase();return e.includes(t)?t:"info"}var $2=C(()=>{});function iz(n){return n.split(/\r?\n/).find(e=>e.trim())?.trim()}var nd,G2=C(()=>{J();$2();nd=class extends kr{device;handle;_compilationInfoLog="";constructor(e,t){super(e,t),this.device=e;let i=this.props.handle;switch(this.props.stage){case"vertex":this.handle=i||this.device.gl.createShader(35633);break;case"fragment":this.handle=i||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}e._setWebGLDebugMetadata(this.handle,this,{spector:this.props});let r=this._compile(this.source);r&&typeof r.catch=="function"&&r.catch(()=>{this.compilationStatus="error"})}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this._getCompilationInfoLog();return e?U2(e):[]}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)||null}_compile(e){e=e.startsWith("#version ")?e:`#version 300 es +${e}`;let{gl:t}=this.device;if(t.shaderSource(this.handle,e),t.compileShader(this.handle),!this.device.props.debug){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus==="error")throw new Error(this._getCompilationErrorMessage(e));return}return N.once(1,"Shader compilation is asynchronous")(),this._waitForCompilationComplete().then(()=>{N.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()})}async _waitForCompilationComplete(){let e=async r=>await new Promise(s=>setTimeout(s,r));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error",this.compilationStatus==="error"&&this._getCompilationInfoLog()}_getCompilationErrorMessage(e){let t=`${this.props.stage} shader ${this.props.id}`,i=iz(this._getCompilationInfoLog()),r=this.getCompilationInfoSync(),s=r.find(u=>u.type==="error"&&u.message.trim())||r.find(u=>u.message.trim())||r.find(u=>u.type==="error")||r[0];if(!s)return i?`GLSL compilation errors in ${t}: ${i}`:`GLSL compilation errors in ${t}: WebGL did not provide a shader compiler log`;let o=s.lineNum?e.split(/\r?\n/)[s.lineNum-1]?.trim():void 0,a=s.lineNum?` line ${s.lineNum}`:"",c=o?` +Source: ${o}`:"",l=s.message.trim()||i||"WebGL did not provide a shader compiler log";return`GLSL compilation errors in ${t}:${a}: ${l}${c}`}_getCompilationInfoLog(){let e=this.device.gl.getShaderInfoLog(this.handle)?.trim();return e&&(this._compilationInfoLog=e),this._compilationInfoLog}}});function W2(n,e,t,i){if(az(e))return i(n);let r=n;r.pushState();try{return rz(n,e),bn(r.gl,t),i(n)}finally{r.popState()}}function rz(n,e){let t=n,{gl:i}=t;if(e.cullMode)switch(e.cullMode){case"none":i.disable(2884);break;case"front":i.enable(2884),i.cullFace(1028);break;case"back":i.enable(2884),i.cullFace(1029);break}if(e.frontFace&&i.frontFace(ss("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&n.features.has("depth-clip-control")&&i.enable(34383),e.depthBias!==void 0&&(i.enable(32823),i.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&n.features.has("provoking-vertex-webgl")){let s=t.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,o=ss("provokingVertex",e.provokingVertex,{first:36429,last:36430});s?.provokingVertexWEBGL(o)}if((e.polygonMode||e.polygonOffsetLine)&&n.features.has("polygon-mode-webgl")){if(e.polygonMode){let s=t.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,o=ss("polygonMode",e.polygonMode,{fill:6914,line:6913});s?.polygonModeWEBGL(1028,o),s?.polygonModeWEBGL(1029,o)}e.polygonOffsetLine&&i.enable(10754)}if(n.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&i.enable(12288),e.clipDistance1&&i.enable(12289),e.clipDistance2&&i.enable(12290),e.clipDistance3&&i.enable(12291),e.clipDistance4&&i.enable(12292),e.clipDistance5&&i.enable(12293),e.clipDistance6&&i.enable(12294),e.clipDistance7&&i.enable(12295)),e.depthWriteEnabled!==void 0&&i.depthMask(oz("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?i.enable(2929):i.disable(2929),i.depthFunc(rd("depthCompare",e.depthCompare))),e.clearDepth!==void 0&&i.clearDepth(e.clearDepth),e.stencilWriteMask){let r=e.stencilWriteMask;i.stencilMaskSeparate(1028,r),i.stencilMaskSeparate(1029,r)}if(e.stencilReadMask&&N.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){let r=e.stencilReadMask||4294967295,s=rd("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?i.enable(2960):i.disable(2960),i.stencilFuncSeparate(1028,s,0,r),i.stencilFuncSeparate(1029,s,0,r)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){let r=uy("stencilPassOperation",e.stencilPassOperation),s=uy("stencilFailOperation",e.stencilFailOperation),o=uy("stencilDepthFailOperation",e.stencilDepthFailOperation);i.stencilOpSeparate(1028,s,o,r),i.stencilOpSeparate(1029,s,o,r)}switch(e.blend){case!0:i.enable(3042);break;case!1:i.disable(3042);break;default:}if(e.blendColorOperation||e.blendAlphaOperation){let r=V2("blendColorOperation",e.blendColorOperation||"add"),s=V2("blendAlphaOperation",e.blendAlphaOperation||"add");i.blendEquationSeparate(r,s);let o=id("blendColorSrcFactor",e.blendColorSrcFactor||"one"),a=id("blendColorDstFactor",e.blendColorDstFactor||"zero"),c=id("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),l=id("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");i.blendFuncSeparate(o,a,c,l)}}function rd(n,e){return ss(n,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function uy(n,e){return ss(n,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function V2(n,e){return ss(n,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function id(n,e,t="color"){return ss(n,e,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:t==="color"?32769:32771,"one-minus-constant":t==="color"?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function sz(n,e){return`Illegal parameter ${e} for ${n}`}function ss(n,e,t){if(!(e in t))throw new Error(sz(n,e));return t[e]}function oz(n,e){return e}function az(n){let e=!0;for(let t in n){e=!1;break}return e}var fy=C(()=>{J();Po()});function sd(n){let e={};return n.addressModeU&&(e[10242]=dy(n.addressModeU)),n.addressModeV&&(e[10243]=dy(n.addressModeV)),n.addressModeW&&(e[32882]=dy(n.addressModeW)),n.magFilter&&(e[10240]=hy(n.magFilter)),(n.minFilter||n.mipmapFilter)&&(e[10241]=cz(n.minFilter||"linear",n.mipmapFilter)),n.lodMinClamp!==void 0&&(e[33082]=n.lodMinClamp),n.lodMaxClamp!==void 0&&(e[33083]=n.lodMaxClamp),n.type==="comparison-sampler"&&(e[34892]=34894),n.compare&&(e[34893]=rd("compare",n.compare)),n.maxAnisotropy&&(e[34046]=n.maxAnisotropy),e}function dy(n){switch(n){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function hy(n){switch(n){case"nearest":return 9728;case"linear":return 9729}}function cz(n,e="none"){if(!e)return hy(n);switch(e){case"none":return hy(n);case"nearest":switch(n){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(n){case"nearest":return 9986;case"linear":return 9987}}}var py=C(()=>{fy()});var od,j2=C(()=>{J();py();od=class extends Mr{device;handle;parameters;constructor(e,t){super(e,t),this.device=e,this.parameters=sd(t),this.handle=t.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(let[t,i]of Object.entries(e)){let r=Number(t);switch(r){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,r,i);break;default:this.device.gl.samplerParameteri(this.handle,r,i);break}}}}});function En(n,e,t){if(lz(e))return t(n);let{nocatch:i=!0}=e,r=vn.get(n);r.push(),bn(n,e);let s;if(i)s=t(n),r.pop();else try{s=t(n)}finally{r.pop()}return s}function lz(n){for(let e in n)return!1;return!0}var ad=C(()=>{Po();ty()});var ni,my=C(()=>{J();ni=class extends Ar{device;gl;handle;texture;constructor(e,t){super(e,{...me.defaultProps,...t}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=t.texture}}});function cd(n){return uz[n]}var uz,gy=C(()=>{uz={5124:"sint32",5125:"uint32",5122:"sint16",5123:"uint16",5120:"sint8",5121:"uint8",5126:"float32",5131:"float16",33635:"uint16",32819:"uint16",32820:"uint16",33640:"uint32",35899:"uint32",35902:"uint32",34042:"uint32",36269:"uint32"}});function fz(n,e=0){return e?new n.constructor(n.buffer,n.byteOffset+e,(n.byteLength-e)/n.BYTES_PER_ELEMENT):n}function dz(n,e){if(e%n.BYTES_PER_ELEMENT!==0)throw new Error(`Texture byteOffset ${e} must align to typed array element size ${n.BYTES_PER_ELEMENT}`);return e/n.BYTES_PER_ELEMENT}function hz(n){switch(n){case"1d":break;case"2d":return 3553;case"3d":return 32879;case"cube":return 34067;case"2d-array":return 35866;case"cube-array":break}throw new Error(n)}function Uc(n,e,t){return e==="cube"?34069+t:n}var ii,ld=C(()=>{J();Lo();py();ad();my();gy();ii=class extends me{device;gl;handle;sampler=void 0;view;glTarget;glFormat;glType;glInternalFormat;compressed;_textureUnit=0;_framebuffer=null;_framebufferAttachmentKey=null;constructor(e,t){super(e,t,{byteAlignment:1}),this.device=e,this.gl=this.device.gl;let i=qf(this.props.format);if(this.glTarget=hz(this.props.dimension),this.glInternalFormat=i.internalFormat,this.glFormat=i.format,this.glType=i.type,this.compressed=i.compressed,this.isHandleBorrowed&&this.props.handle===void 0)throw new Error("Borrowed WebGL textures require a texture handle");if(this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),!this.isHandleBorrowed){this.gl.bindTexture(this.glTarget,this.handle);let{dimension:r,width:s,height:o,depth:a,mipLevels:c,glTarget:l,glInternalFormat:u}=this;if(!this.compressed)switch(r){case"2d":case"cube":this.gl.texStorage2D(l,c,u,s,o);break;case"2d-array":case"3d":this.gl.texStorage3D(l,c,u,s,o,a);break;default:throw new Error(r)}this.gl.bindTexture(this.glTarget,null),this._initializeData(t.data)}this.ownsHandle?this.trackAllocatedMemory(this.getAllocatedByteLength(),"Texture"):this.trackReferencedMemory(this.getAllocatedByteLength(),"Texture"),this.isHandleBorrowed||this.setSampler(this.props.sampler),this.view=new ni(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this._framebuffer?.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.ownsHandle?(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory("Texture")):this.trackDeallocatedReferencedMemory("Texture"),this.destroyed=!0)}createView(e){return new ni(this.device,{...e,texture:this})}clone(e){if(this.isHandleBorrowed&&e&&(e.width!==this.width||e.height!==this.height))throw new Error(`Cannot resize borrowed read-only ${this}`);return super.clone(e)}setSampler(e={}){this._assertWritable("set sampler parameters on"),super.setSampler(e);let t=sd(this.sampler.props);this._setSamplerParameters(t)}copyExternalImage(e){this._assertWritable("copy external image data into");let t=this._normalizeCopyExternalImageOptions(e);if(t.sourceX||t.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");let{glFormat:i,glType:r}=this,{image:s,depth:o,mipLevel:a,x:c,y:l,z:u,width:f,height:d}=t,h=Uc(this.glTarget,this.dimension,u),p=t.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),En(this.gl,p,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(h,a,c,l,f,d,i,r,s);break;case"2d-array":case"3d":this.gl.texSubImage3D(h,a,c,l,u,f,d,o,i,r,s);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:t.width,height:t.height}}copyElementImage(e){this._assertWritable("copy element image data into");let t=this._normalizeCopyElementImageOptions(e),{glFormat:i}=this,{element:r,depth:s,mipLevel:o,sourceX:a,sourceY:c,sourceWidth:l,sourceHeight:u,x:f,y:d,z:h,width:p,height:m}=t,g=Uc(this.glTarget,this.dimension,h),v=t.flipY?{37440:!0}:{},y=this.gl;if(s!==1||this.dimension!=="2d"&&this.dimension!=="cube")throw new Error(`${this} copyElementImage only supports 2d and cube textures on WebGL`);if(o!==0||f!==0||d!==0)throw new Error(`${this} copyElementImage only supports full base-level uploads on WebGL`);if(typeof y.texElementImage2D!="function")throw new Error(`${this} copyElementImage is not supported by this WebGL implementation`);return this.gl.bindTexture(this.glTarget,this.handle),En(this.gl,v,()=>{y.texElementImage2D?.(g,i,r,{sx:a,sy:c,swidth:l??p,sheight:u??m,width:p,height:m})}),this.gl.bindTexture(this.glTarget,null),{width:t.width,height:t.height}}copyImageData(e){super.copyImageData(e)}readBuffer(e={},t){if(!t)throw new Error(`${this} readBuffer requires a destination buffer`);let i=this._getSupportedColorReadOptions(e),r=e.byteOffset??0,s=this.computeMemoryLayout(i);if(t.byteLength{this.gl.readPixels(i.x,i.y,i.width,i.height,this.glFormat,this.glType,r+a)})}finally{this.gl.bindBuffer(35051,null)}return t}async readDataAsync(e={}){throw new Error(`${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`)}writeBuffer(e,t={}){this._assertWritable("write buffer data into");let i=this._normalizeTextureWriteOptions(t),{width:r,height:s,depthOrArrayLayers:o,mipLevel:a,byteOffset:c,x:l,y:u,z:f}=i,{glFormat:d,glType:h,compressed:p}=this,m=Uc(this.glTarget,this.dimension,f);if(p)throw new Error("writeBuffer for compressed textures is not implemented in WebGL");let{bytesPerPixel:g}=this.device.getTextureFormatInfo(this.format),v=g?i.bytesPerRow/g:void 0,y={3317:this.byteAlignment,...v!==void 0?{3314:v}:{},32878:i.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,e.handle),En(this.gl,y,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(m,a,l,u,r,s,d,h,c);break;case"2d-array":case"3d":this.gl.texSubImage3D(m,a,l,u,f,r,s,o,d,h,c);break;default:}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(e,t={}){this._assertWritable("write data into");let i=this._normalizeTextureWriteOptions(t),r=ArrayBuffer.isView(e)?e:new Uint8Array(e),{width:s,height:o,depthOrArrayLayers:a,mipLevel:c,x:l,y:u,z:f,byteOffset:d}=i,{glFormat:h,glType:p,compressed:m}=this,g=Uc(this.glTarget,this.dimension,f),v;if(!m){let{bytesPerPixel:T}=this.device.getTextureFormatInfo(this.format);T&&(v=i.bytesPerRow/T)}let y=this.compressed?{}:{3317:this.byteAlignment,...v!==void 0?{3314:v}:{},32878:i.rowsPerImage},b=dz(r,d),x=m?fz(r,d):r,E=this._getMipLevelSize(c),w=l===0&&u===0&&f===0&&s===E.width&&o===E.height&&a===E.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),En(this.gl,y,()=>{switch(this.dimension){case"2d":case"cube":m?w?this.gl.compressedTexImage2D(g,c,h,s,o,0,x):this.gl.compressedTexSubImage2D(g,c,l,u,s,o,h,x):this.gl.texSubImage2D(g,c,l,u,s,o,h,p,r,b);break;case"2d-array":case"3d":m?w?this.gl.compressedTexImage3D(g,c,h,s,o,a,0,x):this.gl.compressedTexSubImage3D(g,c,l,u,f,s,o,a,h,x):this.gl.texSubImage3D(g,c,l,u,f,s,o,a,h,p,r,b);break;default:}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(e,t){return 1}_getFramebuffer(){return this._framebuffer||=this.device.createFramebuffer({id:`framebuffer-for-${this.id}`,width:this.width,height:this.height,colorAttachments:[this]}),this._framebuffer}readDataSyncWebGL(e={}){let t=this._getSupportedColorReadOptions(e),i=this.computeMemoryLayout(t),r=cd(this.glType),s=Lr(r),o=new s(i.byteLength/s.BYTES_PER_ELEMENT);return this._readColorTextureLayers(t,i,a=>{let c=new s(o.buffer,o.byteOffset+a,i.bytesPerImage/s.BYTES_PER_ELEMENT);this.gl.readPixels(t.x,t.y,t.width,t.height,this.glFormat,this.glType,c)}),o.buffer}_readColorTextureLayers(e,t,i){let r=this._getFramebuffer(),s=t.bytesPerRow/t.bytesPerPixel,o={3333:this.byteAlignment,...s!==e.width?{3330:s}:{}},a=this.gl.getParameter(3074),c=this.gl.bindFramebuffer(36160,r.handle);try{this.gl.readBuffer(36064),En(this.gl,o,()=>{for(let l=0;l=2&&N.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(e))(),this.gl.bindTexture(this.glTarget,this.handle);for(let[t,i]of Object.entries(e)){let r=Number(t),s=i;switch(r){case 33082:case 33083:this.gl.texParameterf(this.glTarget,r,s);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,r,s);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,r,s);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,r,s);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,r,s);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(e){let{gl:t}=this;return e!==void 0&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,this.handle),e}_unbind(e){let{gl:t}=this;return e!==void 0&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,null),e}_assertWritable(e){if(this.isHandleBorrowed)throw new Error(`Cannot ${e} borrowed read-only ${this}`)}}});function H2(n,e,t,i){let r=n,s=i;s===!0&&(s=1),s===!1&&(s=0);let o=typeof s=="number"?[s]:s;switch(t){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof i!="number")throw new Error("samplers must be set to integers");return n.uniform1i(e,i);case 5126:return n.uniform1fv(e,o);case 35664:return n.uniform2fv(e,o);case 35665:return n.uniform3fv(e,o);case 35666:return n.uniform4fv(e,o);case 5124:return n.uniform1iv(e,o);case 35667:return n.uniform2iv(e,o);case 35668:return n.uniform3iv(e,o);case 35669:return n.uniform4iv(e,o);case 35670:return n.uniform1iv(e,o);case 35671:return n.uniform2iv(e,o);case 35672:return n.uniform3iv(e,o);case 35673:return n.uniform4iv(e,o);case 5125:return r.uniform1uiv(e,o,1);case 36294:return r.uniform2uiv(e,o,2);case 36295:return r.uniform3uiv(e,o,3);case 36296:return r.uniform4uiv(e,o,4);case 35674:return n.uniformMatrix2fv(e,!1,o);case 35675:return n.uniformMatrix3fv(e,!1,o);case 35676:return n.uniformMatrix4fv(e,!1,o);case 35685:return r.uniformMatrix2x3fv(e,!1,o);case 35686:return r.uniformMatrix2x4fv(e,!1,o);case 35687:return r.uniformMatrix3x2fv(e,!1,o);case 35688:return r.uniformMatrix3x4fv(e,!1,o);case 35689:return r.uniformMatrix4x2fv(e,!1,o);case 35690:return r.uniformMatrix4x3fv(e,!1,o)}throw new Error("Illegal uniform")}var Y2=C(()=>{});function q2(n){return mz[n]}function ud(n){return pz[n]}function fd(n){return!!X2[n]}function Z2(n){return X2[n]}var pz,X2,mz,dd=C(()=>{pz={5126:"f32",35664:"vec2",35665:"vec3",35666:"vec4",5124:"i32",35667:"vec2",35668:"vec3",35669:"vec4",5125:"u32",36294:"vec2",36295:"vec3",36296:"vec4",35670:"f32",35671:"vec2",35672:"vec3",35673:"vec4",35674:"mat2x2",35685:"mat2x3",35686:"mat2x4",35687:"mat3x2",35675:"mat3x3",35688:"mat3x4",35689:"mat4x2",35690:"mat4x3",35676:"mat4x4"},X2={35678:{viewDimension:"2d",sampleType:"float"},35680:{viewDimension:"cube",sampleType:"float"},35679:{viewDimension:"3d",sampleType:"float"},35682:{viewDimension:"3d",sampleType:"depth"},36289:{viewDimension:"2d-array",sampleType:"float"},36292:{viewDimension:"2d-array",sampleType:"depth"},36293:{viewDimension:"cube",sampleType:"float"},36298:{viewDimension:"2d",sampleType:"sint"},36299:{viewDimension:"3d",sampleType:"sint"},36300:{viewDimension:"cube",sampleType:"sint"},36303:{viewDimension:"2d-array",sampleType:"uint"},36306:{viewDimension:"2d",sampleType:"uint"},36307:{viewDimension:"3d",sampleType:"uint"},36308:{viewDimension:"cube",sampleType:"uint"},36311:{viewDimension:"2d-array",sampleType:"uint"}},mz={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126}});function Q2(n,e,t={}){let i={attributes:[],bindings:[]};i.attributes=gz(n,e);let r=bz(n,e,t);for(let c of r){let l=c.uniforms.map(u=>({name:u.name,format:u.format,byteOffset:u.byteOffset,byteStride:u.byteStride,arrayLength:u.arrayLength}));i.bindings.push({type:"uniform",name:c.name,group:0,location:c.location,visibility:(c.vertex?1:0)|(c.fragment?2:0),minBindingSize:c.byteLength,uniforms:l})}let s=yz(n,e),o=0;for(let c of s)if(fd(c.type)){let{viewDimension:l,sampleType:u}=Z2(c.type);i.bindings.push({type:"texture",name:c.name,group:0,location:o,viewDimension:l,sampleType:u}),c.textureUnit=o,o+=1}s.length&&(i.uniforms=s);let a=_z(n,e);return a?.length&&(i.varyings=a),i}function gz(n,e){let t=[],i=n.getProgramParameter(e,35721);for(let r=0;r=0){let l=ud(a),u=/instance/i.test(o)?"instance":"vertex";t.push({name:o,location:c,stepMode:u,type:l})}}return t.sort((r,s)=>r.location-s.location),t}function _z(n,e){let t=[],i=n.getProgramParameter(e,35971);for(let r=0;rr.location-s.location),t}function yz(n,e){let t=[],i=n.getProgramParameter(e,35718);for(let r=0;r1)for(let h=0;ho.location-a.location),i}function vz(n,e){for(let t of n.uniforms){let i=e.uniforms.find(r=>t.name===r.name||t.name.endsWith(`.${r.name}`));if(!i)throw new Error(`Failed to validate WebGL uniform block "${e.name}": reflected unexpected member "${t.name}"`);if(t.format!==i.format||t.arrayLength!==i.arrayLength||t.byteOffset!==i.byteOffset||t.byteStride!==i.byteStride)throw new Error(`Failed to validate WebGL uniform block "${e.name}": reflected layout for "${t.name}" does not match supplied std140 metadata`)}}function xz(n,e,t){let i=new Map;for(let s of t.uniformBlockLayouts||[])i.set(s.name,Ez(s));for(let s of t.shaderLayout?.bindings||[])Pz(s)&&i.set(s.name,s);let r=new Map;for(let s of i.values()){let o=wz(n,e,s.name);if(!o)continue;let{blockIndex:a,blockName:c}=o;if(r.has(a))throw new Error(`Multiple supplied uniform block layouts resolve to active WebGL block "${c}"`);r.set(a,{name:c,location:a,byteLength:s.minBindingSize,vertex:!!(s.visibility&&s.visibility&1),fragment:!!(s.visibility&&s.visibility&2),uniformCount:s.uniforms.length,uniforms:s.uniforms.map(l=>({...l}))})}return r}function wz(n,e,t){let i=t.endsWith("Uniforms")?[t,t.slice(0,-8)]:[t,`${t}Uniforms`];for(let r of i){let s=n.getUniformBlockIndex(e,r);if(s!==4294967295){if(!Number.isInteger(s)||s<0)throw new Error(`Failed to resolve WebGL uniform block "${r}": getUniformBlockIndex returned ${String(s)}`);return{blockIndex:s,blockName:r}}}return null}function K2(n,e,t,i){let r=i||n.getActiveUniformBlockName(e,t);if(!r)throw new Error(`Failed to reflect WebGL uniform block at index ${t}: missing block name`);let s=(b,x)=>{let E=n.getActiveUniformBlockParameter(e,t,b);if(E==null)throw new Error(`Failed to reflect WebGL uniform block "${r}": ${x} returned null`);return E},o=os(s(35391,"UNIFORM_BLOCK_BINDING"),r,"UNIFORM_BLOCK_BINDING",0),a=os(s(35392,"UNIFORM_BLOCK_DATA_SIZE"),r,"UNIFORM_BLOCK_DATA_SIZE",0),c=os(s(35394,"UNIFORM_BLOCK_ACTIVE_UNIFORMS"),r,"UNIFORM_BLOCK_ACTIVE_UNIFORMS",0),l=J2(s(35395,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES"),r,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",c),u=$c(n,e,l,35383,"UNIFORM_TYPE",r,c),f=$c(n,e,l,35384,"UNIFORM_SIZE",r,c),d=$c(n,e,l,35386,"UNIFORM_BLOCK_INDEX",r,c),h=$c(n,e,l,35387,"UNIFORM_OFFSET",r,c),p=$c(n,e,l,35388,"UNIFORM_ARRAY_STRIDE",r,c),m=[];for(let b=0;bb.name.split(".")[0]).filter(b=>!!b)),y=g.name.replace(/Uniforms$/,"");if(v.size===1&&!v.has(g.name)&&!v.has(y)){let[b]=v;N.warn(`Uniform block "${g.name}" uses GLSL instance "${b}". luma.gl binds uniform buffers by block name ("${g.name}") and alias ("${y}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}return g}function $c(n,e,t,i,r,s,o){let a=n.getActiveUniforms(e,t,i);if(a===null)throw new Error(`Failed to reflect WebGL uniform block "${s}": ${r} returned null`);return J2(a,s,r,o)}function J2(n,e,t,i){if(!Array.isArray(n)&&!ArrayBuffer.isView(n))throw new Error(`Failed to reflect WebGL uniform block "${e}": ${t} returned a non-array value`);let r=Array.from(n);if(r.length!==i||r.some(s=>!Number.isInteger(s)))throw new Error(`Failed to reflect WebGL uniform block "${e}": ${t} returned ${r.length} invalid values, expected ${i}`);return r}function os(n,e,t,i){if(!Number.isInteger(n)||n{if(typeof o=="string"){let a=e[s];if(!a)throw new Error(`Missing std140 layout field ${s}`);t.push({name:s,format:a.shaderType,arrayLength:1,byteOffset:a.offset*4,byteStride:0});return}if(Array.isArray(o)){r(s,o[0],o[1]);return}for(let[a,c]of Object.entries(o))i(`${s}.${a}`,c)},r=(s,o,a)=>{if(typeof o=="string"){let c=e[`${s}[0]`],l=a>1?e[`${s}[1]`]:void 0;if(!c)throw new Error(`Missing std140 array layout field ${s}[0]`);t.push({name:`${s}[0]`,format:c.shaderType,arrayLength:a,byteOffset:c.offset*4,byteStride:l?(l.offset-c.offset)*4:0});return}if(Array.isArray(o))throw new Error(`Nested uniform arrays are not supported for ${s}`);for(let[c,l]of Object.entries(o)){if(typeof l!="string")throw new Error(`Composite uniform array members are not supported for ${s}`);let u=`${s}[0].${c}`,f=`${s}[1].${c}`,d=e[u],h=a>1?e[f]:void 0;if(!d)throw new Error(`Missing std140 array layout field ${u}`);t.push({name:u,format:d.shaderType,arrayLength:a,byteOffset:d.offset*4,byteStride:h?(h.offset-d.offset)*4:0})}};for(let[s,o]of Object.entries(n))i(s,o);return t}function Pz(n){return n.type==="uniform"&&Number.isInteger(n.minBindingSize)&&n.minBindingSize>=0&&Array.isArray(n.uniforms)&&n.uniforms.every(e=>typeof e.name=="string"&&typeof e.format=="string"&&Number.isInteger(e.arrayLength)&&e.arrayLength>0&&Number.isInteger(e.byteOffset)&&e.byteOffset>=0&&Number.isInteger(e.byteStride)&&e.byteStride>=0)}function Cz(n){if(n[n.length-1]!=="]")return{name:n,length:1,isArray:!1};let t=/([^[]*)(\[[0-9]+\])?/.exec(n);return{name:Wi(t?.[1],`Failed to parse GLSL uniform name ${n}`),length:t?.[2]?1:0,isArray:!!t?.[2]}}var eP=C(()=>{J();dd()});function Tz(n,e){let t={...n,attributes:n.attributes.map(i=>({...i})),bindings:n.bindings.map(i=>({...i}))};for(let i of e?.attributes||[]){let r=t.attributes.find(s=>s.name===i.name);r?(r.type=i.type||r.type,r.stepMode=i.stepMode||r.stepMode):N.warn(`shader layout attribute ${i.name} not present in shader`)}for(let i of e?.bindings||[]){let r=nP(t,i.name);if(!r){N.warn(`shader layout binding ${i.name} not present in shader`);continue}Object.assign(r,i)}return t}function nP(n,e){return n.bindings.find(t=>t.name===e||t.name===`${e}Uniforms`||`${t.name}Uniforms`===e)}function tP(n,e){return n[e]||n[`${e}Uniforms`]||n[e.replace(/Uniforms$/,"")]}var hd,iP=C(()=>{J();Y2();ed();Kf();ld();my();eP();hd=class extends Zt{device;handle;vs;fs;introspectedLayout;bindings={};uniforms={};varyings=null;_uniformCount=0;_uniformSetters={};get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}constructor(e,t){super(e,t),this.device=e;let i=this.sharedRenderPipeline||this.device._createSharedRenderPipelineWebGL(t);this.sharedRenderPipeline=i,this.handle=i.handle,this.vs=i.vs,this.fs=i.fs,this.linkStatus=i.linkStatus,this.introspectedLayout=Q2(this.device.gl,this.handle,{uniformBlockLayouts:t._uniformBlockLayouts,shaderLayout:t.shaderLayout}),this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.shaderLayout=t.shaderLayout?Tz(this.introspectedLayout,t.shaderLayout):this.introspectedLayout}destroy(){this.destroyed||(this.sharedRenderPipeline&&!this.props._sharedRenderPipeline&&this.sharedRenderPipeline.destroy(),this.destroyResource())}setBindings(e,t){let i=js(Or(this.shaderLayout,e));for(let[r,s]of Object.entries(i)){let o=nP(this.shaderLayout,r);if(o){switch(s||N.warn(`Unsetting binding "${r}" in render pipeline "${this.id}"`)(),o.type){case"uniform":if(!(s instanceof wn)&&!(s.buffer instanceof wn))throw new Error("buffer value");break;case"texture":if(!(s instanceof ni||s instanceof ii||s instanceof ti))throw new Error(`${this} Bad texture binding for ${r}`);break;case"sampler":N.warn(`Ignoring sampler ${r}`)();break;default:throw new Error(o.type)}this.bindings[r]=s}else{let a=this.shaderLayout.bindings.map(c=>`"${c.name}"`).join(", ");t?.disableWarnings||N.warn(`No binding "${r}" in render pipeline "${this.id}", expected one of ${a}`,s)()}}}draw(e){let t=e.renderPass,i=e.bindGroups?js(e.bindGroups):e.bindings||this.bindings;return t.setPipeline(this),t.setBindings(i),t.setVertexArray(e.vertexArray),t.draw({parameters:e.parameters,topology:e.topology,isInstanced:e.isInstanced,vertexCount:e.vertexCount,indexCount:e.indexCount,instanceCount:e.instanceCount,firstVertex:e.firstVertex,firstIndex:e.firstIndex,firstInstance:e.firstInstance,baseVertex:e.baseVertex,transformFeedback:e.transformFeedback,uniforms:e.uniforms})}_areTexturesRenderable(e){let t=!0;for(let i of this.shaderLayout.bindings)tP(e,i.name)||(N.warn(`Binding ${i.name} not found in ${this.id}`)(),t=!1);return t}_applyBindings(e,t){if(this._syncLinkStatus(),this.linkStatus!=="success")return;let{gl:i}=this.device;i.useProgram(this.handle);let r=0,s=0;for(let o of this.shaderLayout.bindings){let a=tP(e,o.name);if(!a)throw new Error(`No value for binding ${o.name} in ${this.id}`);switch(o.type){case"uniform":let{name:c}=o,l=i.getUniformBlockIndex(this.handle,c);if(l===4294967295)throw new Error(`Invalid uniform block name ${c}`);if(i.uniformBlockBinding(this.handle,l,s),a instanceof wn)i.bindBufferBase(35345,s,a.handle);else{let f=a;i.bindBufferRange(35345,s,f.buffer.handle,f.offset||0,f.size||f.buffer.byteLength-(f.offset||0))}s+=1;break;case"texture":if(!(a instanceof ni||a instanceof ii||a instanceof ti))throw new Error("texture");let u;if(a instanceof ni)u=a.texture;else if(a instanceof ii)u=a;else if(a instanceof ti&&a.colorAttachments[0]instanceof ni)N.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),u=a.colorAttachments[0].texture;else throw new Error("No texture");i.activeTexture(33984+r),i.bindTexture(u.glTarget,u.handle),r+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${o.type}' not supported in WebGL`)}}}_applyUniforms(e){for(let t of this.shaderLayout.uniforms||[]){let{name:i,location:r,type:s,textureUnit:o}=t,a=e[i]??o;a!==void 0&&H2(this.device.gl,r,s,a)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}}});var rP,pd,sP=C(()=>{J();dd();rP=4,pd=class extends ka{device;handle;vs;fs;linkStatus="pending";constructor(e,t){super(e,t),this.device=e,this.handle=t.handle||this.device.gl.createProgram(),this.vs=t.vs,this.fs=t.fs,t.varyings&&t.varyings.length>0&&this.device.gl.transformFeedbackVaryings(this.handle,t.varyings,t.bufferMode||35981),this._linkShaders()}destroy(){this.destroyed||(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.handle.destroyed=!0,this.destroyResource())}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),N.time(rP,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),N.timeEnd(rP,`linkProgram for ${this.id}`)(),!this.device.features.has("compilation-status-async-webgl")){let i=this._getLinkStatus();this._reportLinkStatus(i);return}N.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),N.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let t=this._getLinkStatus();this._reportLinkStatus(t)}async _reportLinkStatus(e){switch(e){case"success":return;default:let t=e==="link-error"?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${t} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader();break;case"success":break}switch(this.fs?.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`${this} ${t} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader();break;case"success":break}let i=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${t} during ${e}: ${i}`),this)(),this.device.debug()}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(this._initializeSamplerUniforms(),e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}_initializeSamplerUniforms(){let{gl:e}=this.device;e.useProgram(this.handle);let t=0,i=e.getProgramParameter(this.handle,35718);for(let r=0;r1){let o=Int32Array.from({length:t.size},(a,c)=>r+c);return s.uniform1iv(e,o),r+t.size}return s.uniform1i(e,r),r+1}async _waitForLinkComplete(){let e=async r=>await new Promise(s=>setTimeout(s,r));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getProgramParameter(this.handle,37297))return;await e(10)}}}});function Lz(n,e){let t=e.sourceBuffer,i=e.destinationBuffer;n.gl.bindBuffer(36662,t.handle),n.gl.bindBuffer(36663,i.handle),n.gl.copyBufferSubData(36662,36663,e.sourceOffset??0,e.destinationOffset??0,e.size),n.gl.bindBuffer(36662,null),n.gl.bindBuffer(36663,null)}function Mz(n,e){let{sourceBuffer:t,byteOffset:i=0,destinationTexture:r,mipLevel:s=0,origin:o=[0,0,0],aspect:a="all",bytesPerRow:c,rowsPerImage:l,size:u}=e;if(a!=="all")throw new Error("copyBufferToTexture aspect is not supported in WebGL");r.writeBuffer(t,{byteOffset:i,bytesPerRow:c,rowsPerImage:l,mipLevel:s,x:o[0]??0,y:o[1]??0,z:o[2]??0,width:u[0],height:u[1],depthOrArrayLayers:u[2]})}function Az(n,e){let{sourceTexture:t,mipLevel:i=0,aspect:r="all",width:s=e.sourceTexture.width,height:o=e.sourceTexture.height,depthOrArrayLayers:a,origin:c=[0,0,0],destinationBuffer:l,byteOffset:u=0,bytesPerRow:f,rowsPerImage:d}=e;if(t instanceof me){t.readBuffer({x:c[0]??0,y:c[1]??0,z:c[2]??0,width:s,height:o,depthOrArrayLayers:a,mipLevel:i,aspect:r,byteOffset:u},l);return}if(r!=="all")throw new Error("aspect not supported in WebGL");if(i!==0||a!==void 0||f||d)throw new Error("not implemented");let{framebuffer:h,destroyFramebuffer:p}=oP(t),m;try{let g=l,v=s||h.width,y=o||h.height,b=Wi(h.colorAttachments[0]),x=qf(b.texture.props.format),E=x.format,w=x.type;n.gl.bindBuffer(35051,g.handle),m=n.gl.bindFramebuffer(36160,h.handle),n.gl.readPixels(c[0],c[1],v,y,E,w,u)}finally{n.gl.bindBuffer(35051,null),m!==void 0&&n.gl.bindFramebuffer(36160,m),p&&h.destroy()}}function kz(n,e){let{sourceTexture:t,destinationMipLevel:i=0,origin:r=[0,0],destinationOrigin:s=[0,0,0],destinationTexture:o}=e,{width:a=e.destinationTexture.width,height:c=e.destinationTexture.height}=e,{framebuffer:l,destroyFramebuffer:u}=oP(t),[f=0,d=0]=r,[h,p,m]=s,g=n.gl.bindFramebuffer(36160,l.handle),v,y;if(o instanceof ii)v=o,a=Number.isFinite(a)?a:v.width,c=Number.isFinite(c)?c:v.height,v._bind(0),y=v.glTarget;else throw new Error("invalid destination");switch(y){case 3553:case 34067:n.gl.copyTexSubImage2D(y,i,h,p,f,d,a,c);break;case 35866:case 32879:n.gl.copyTexSubImage3D(y,i,h,p,m,f,d,a,c);break;default:}v&&v._unbind(),n.gl.bindFramebuffer(36160,g),u&&l.destroy()}function oP(n){if(n instanceof me){let{width:e,height:t,id:i}=n;return{framebuffer:n.device.createFramebuffer({id:`framebuffer-for-${i}`,width:e,height:t,colorAttachments:[n]}),destroyFramebuffer:!0}}return{framebuffer:n,destroyFramebuffer:!1}}var md,aP=C(()=>{J();Lo();ld();md=class extends Ba{device;handle=null;commands=[];constructor(e,t={}){super(e,t),this.device=e}_executeCommands(e=this.commands){for(let t of e)switch(t.name){case"copy-buffer-to-buffer":Lz(this.device,t.options);break;case"copy-buffer-to-texture":Mz(this.device,t.options);break;case"copy-texture-to-buffer":Az(this.device,t.options);break;case"copy-texture-to-texture":kz(this.device,t.options);break;default:throw new Error(t.name)}}}});function cP(n){switch(n){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"triangle-list":return 4;case"triangle-strip":return 5;default:throw new Error(n)}}function lP(n){switch(n){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;default:throw new Error(n)}}var _y=C(()=>{});var Rz,gd,uP=C(()=>{J();ad();Po();_y();fy();Rz=[1,2,4,8],gd=class extends Ra{device;handle=null;glParameters={};pipeline=null;bindings={};bindingsPipeline=null;vertexArray=null;constructor(e,t){super(e,t),this.device=e;let i=this.props.framebuffer,r=!i||i.handle===null;r&&e.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();let s;if(!t?.parameters?.viewport)if(!r&&i){let{width:o,height:a}=i;s=[0,0,o,a]}else{let[o,a]=e.getDefaultCanvasContext().getDrawingBufferSize();s=[0,0,o,a]}if(this.device.pushState(),this.setParameters({viewport:s,...this.props.parameters}),!r&&i?.colorAttachments.length){let o=i.colorAttachments.map((a,c)=>36064+c);this.device.gl.drawBuffers(o)}else r&&this.device.gl.drawBuffers([1029]);this.clear(),this.props.timestampQuerySet&&this.props.beginTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.beginTimestampIndex)}end(){this.destroyed||(this.props.timestampQuerySet&&this.props.endTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.endTimestampIndex),this.device.popState(),this.destroy())}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}executeBundles(e){throw new Error("Render bundles are only supported in WebGPU")}setParameters(e={}){let t={...this.glParameters};t.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(t.depthMask=!this.props.depthReadOnly),t.stencilMask=this.props.stencilReadOnly?0:1,t[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(t.viewport=e.viewport.slice(0,4),t.depthRange=[e.viewport[4],e.viewport[5]]):t.viewport=e.viewport),e.scissorRect&&(t.scissorTest=!0,t.scissor=e.scissorRect),e.blendConstant&&(t.blendColor=e.blendConstant),e.stencilReference!==void 0&&(t[2967]=e.stencilReference,t[36003]=e.stencilReference),"colorMask"in e&&(t.colorMask=Rz.map(i=>!!(i&e.colorMask))),this.glParameters=t,bn(this.device.gl,t)}setPipeline(e){this.pipeline=e}setBindings(e,t){if(!this.pipeline)throw new Error("RenderPass.setPipeline() must be called before setBindings()");this.bindings=js(Or(this.pipeline.shaderLayout,e)),this.bindingsPipeline=this.pipeline}setVertexArray(e){this.vertexArray=e}draw(e){let t=this.pipeline,i=this.vertexArray;if(!t)throw new Error("RenderPass.setPipeline() must be called before draw()");if(!i)throw new Error("RenderPass.setVertexArray() must be called before draw()");if(t.shaderLayout.bindings.length>0&&this.bindingsPipeline!==t)throw new Error("RenderPass.setBindings() must be called after setPipeline() before draw()");t._syncLinkStatus();let{parameters:r=t.props.parameters,topology:s=t.props.topology,vertexCount:o,indexCount:a,instanceCount:c,isInstanced:l=!1,firstVertex:u=0,transformFeedback:f,uniforms:d=t.uniforms}=e,h=cP(s),p=!!i.indexBuffer,m=i.indexBuffer?.glIndexType,g=a??o??0;if(t.linkStatus!=="success")return N.info(2,`RenderPipeline:${t.id}.draw() aborted - waiting for shader linking`)(),!1;if(!t._areTexturesRenderable(this.bindings))return N.info(2,`RenderPipeline:${t.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(t.handle),i.bindBeforeRender(this);let v=f;return v&&v.begin(t.props.topology),t._applyBindings(this.bindings,{disableWarnings:t.props.disableWarnings}),t._applyUniforms(d),W2(this.device,r,this.glParameters,()=>{p&&l?this.device.gl.drawElementsInstanced(h,g,m,u,c||0):p?this.device.gl.drawElements(h,g,m,u):l?this.device.gl.drawArraysInstanced(h,u,o||0,c||0):this.device.gl.drawArrays(h,u,o||0),v&&v.end()}),i.unbindAfterRender(this),!0}drawIndirect(e,t=0){throw new Error("Indirect drawing is only supported in WebGPU")}drawIndexedIndirect(e,t=0){throw new Error("Indirect drawing is only supported in WebGPU")}beginOcclusionQuery(e){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let e={...this.glParameters},t=0;this.props.clearColors&&this.props.clearColors.forEach((i,r)=>{i&&this.clearColorBuffer(r,i)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(t|=16384,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(t|=256,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(t|=1024,e.clearStencil=this.props.clearStencil),t!==0&&En(this.device.gl,e,()=>{this.device.gl.clear(t)})}clearColorBuffer(e=0,t=[0,0,0,0]){En(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,e,t);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,e,t);break;case Float32Array:this.device.gl.clearBufferfv(6144,e,t);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}});var Gc,fP=C(()=>{J();aP();uP();Gc=class extends Ia{device;handle=null;commandBuffer;constructor(e,t){super(e,t),this.device=e,this.commandBuffer=new md(e,{id:this.id,userData:this.userData})}destroy(){this.destroyResource()}finish(){return this.destroy(),this.commandBuffer}beginRenderPass(e={}){return new gd(this.device,this._applyTimeProfilingToPassProps(e))}beginComputePass(e={}){throw new Error("ComputePass not supported in WebGL")}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,t,i){throw new Error("resolveQuerySet is not supported in WebGL")}writeTimestamp(e,t){e.writeTimestamp(t)}}});function dP(n){let{target:e,source:t,start:i=0,count:r=1}=n,s=t.length,o=r*s,a=0;for(let c=i;a{});function Iz(n){return Array.isArray(n)?new Float32Array(n):n}function Bz(n,e){if(!n||!e||n.length!==e.length||n.constructor!==e.constructor)return!1;for(let t=0;t{J();vr();iy();hP();_d=class n extends Oa{get[Symbol.toStringTag](){return"VertexArray"}device;handle;attributeInfosByLocation;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return mp()==="Chrome"}constructor(e,t){super(e,t),this.device=e,this.handle=this.device.gl.createVertexArray(),this.attributeInfosByLocation=new Array(this.maxVertexAttributes).fill(null);for(let i of Object.values($a(t.shaderLayout,t.bufferLayout)))this.attributeInfosByLocation[i.location]=i}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){let t=e;if(t&&t.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,t?t.handle:null),this.indexBuffer=t,this.device.gl.bindVertexArray(null)}setBuffer(e,t){let i=t;if(i.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:r,type:s,stride:o,offset:a,normalized:c,integer:l,divisor:u}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,i.handle),l?this.device.gl.vertexAttribIPointer(e,r,s,o,a):this.device.gl.vertexAttribPointer(e,r,s,c,o,a),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,u||0),this.attributes[e]=i,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,t){this._enable(e,!1),this.attributes[e]=t}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e{J();bd();_y();yd=class extends Da{device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(e,t){super(e,t),this.device=e,this.gl=e.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,t.buffers&&this.setBuffers(t.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(e="point-list"){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(lP(e))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(e){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let[t,i]of Object.entries(e))this.setBuffer(t,i)})}setBuffer(e,t){let i=this._getVaryingIndex(e),{buffer:r,byteLength:s,byteOffset:o}=this._getBufferRange(t);if(i<0){this.unusedBuffers[e]=r,N.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[i]={buffer:r,byteLength:s,byteOffset:o},this.bindOnUse||this._bindBuffer(i,r,o,s)}getBuffer(e){if(mP(e))return this.buffers[e]||null;let t=this._getVaryingIndex(e);return this.buffers[t]??null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(36386,e),this;let t;return this._bound?t=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,t=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),t}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof wn)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:t,byteOffset:i=0,byteLength:r=e.buffer.byteLength}=e;return{buffer:t,byteOffset:i,byteLength:r}}_getVaryingIndex(e){if(mP(e))return Number(e);for(let t of this.layout.varyings||[])if(e===t.name)return t.location;return-1}_bindBuffers(){for(let[e,t]of Object.entries(this.buffers)){let{buffer:i,byteLength:r,byteOffset:s}=this._getBufferRange(t);this._bindBuffer(Number(e),i,s,r)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,t,i=0,r){let s=t&&t.handle;!s||r===void 0?this.gl.bindBufferBase(35982,e,s):this.gl.bindBufferRange(35982,e,s,i,r)}}});var vd,_P=C(()=>{J();vd=class extends Na{device;handle;_timestampPairs=[];_pendingReads=new Set;_occlusionQuery=null;_occlusionActive=!1;get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){if(super(e,t),this.device=e,t.type==="timestamp"){if(t.count<2)throw new Error("Timestamp QuerySet requires at least two query slots");this._timestampPairs=new Array(Math.ceil(t.count/2)).fill(null).map(()=>({activeQuery:null,completedQueries:[]})),this.handle=null}else{if(t.count>1)throw new Error("WebGL occlusion QuerySet can only have one value");let i=this.device.gl.createQuery();if(!i)throw new Error("WebGL query not supported");this.handle=i}Object.seal(this)}destroy(){if(!this.destroyed){this.handle&&this.device.gl.deleteQuery(this.handle);for(let e of this._timestampPairs){e.activeQuery&&(this._cancelPendingQuery(e.activeQuery),this.device.gl.deleteQuery(e.activeQuery.handle));for(let t of e.completedQueries)this._cancelPendingQuery(t),this.device.gl.deleteQuery(t.handle)}this._occlusionQuery&&(this._cancelPendingQuery(this._occlusionQuery),this.device.gl.deleteQuery(this._occlusionQuery.handle));for(let e of Array.from(this._pendingReads))this._cancelPendingQuery(e);this.destroyResource()}}isResultAvailable(e){return this.props.type==="timestamp"?e===void 0?this._timestampPairs.some((t,i)=>this._isTimestampPairAvailable(i)):this._isTimestampPairAvailable(this._getTimestampPairIndex(e)):this._occlusionQuery?this._pollQueryAvailability(this._occlusionQuery):!1}async readResults(e){let t=e?.firstQuery||0,i=e?.queryCount||this.props.count-t;if(this._validateRange(t,i),this.props.type==="timestamp"){let r=new Array(i).fill(0n),s=Math.floor(t/2),o=Math.floor((t+i-1)/2);for(let a=s;a<=o;a++){let c=await this._consumeTimestampPairResult(a),l=a*2,u=l+1;l>=t&&l=t&&u=this.props.count||t<=e)throw new Error("Timestamp duration range is out of bounds");if(e%2!==0||t!==e+1)throw new Error("WebGL timestamp durations require adjacent even/odd query indices");let i=await this._consumeTimestampPairResult(this._getTimestampPairIndex(e));return Number(i)/1e6}beginOcclusionQuery(){if(this.props.type!=="occlusion")throw new Error("Occlusion queries require an occlusion QuerySet");if(!this.handle)throw new Error("WebGL occlusion query is not available");if(this._occlusionActive)throw new Error("Occlusion query is already active");this.device.gl.beginQuery(35887,this.handle),this._occlusionQuery={handle:this.handle,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null},this._occlusionActive=!0}endOcclusionQuery(){if(!this._occlusionActive)throw new Error("Occlusion query is not active");this.device.gl.endQuery(35887),this._occlusionActive=!1}writeTimestamp(e){if(this.props.type!=="timestamp")throw new Error("Timestamp writes require a timestamp QuerySet");let t=this._getTimestampPairIndex(e),i=this._timestampPairs[t];if(e%2===0){if(i.activeQuery)throw new Error("Timestamp query pair is already active");let r=this.device.gl.createQuery();if(!r)throw new Error("WebGL query not supported");let s={handle:r,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null};this.device.gl.beginQuery(35007,r),i.activeQuery=s;return}if(!i.activeQuery)throw new Error("Timestamp query pair was ended before it was started");this.device.gl.endQuery(35007),i.completedQueries.push(i.activeQuery),i.activeQuery=null}_validateRange(e,t){if(e<0||t<0||e+t>this.props.count)throw new Error("Query read range is out of bounds")}_getTimestampPairIndex(e){if(e<0||e>=this.props.count)throw new Error("Query index is out of bounds");return Math.floor(e/2)}_isTimestampPairAvailable(e){let t=this._timestampPairs[e];return!t||t.completedQueries.length===0?!1:this._pollQueryAvailability(t.completedQueries[0])}_pollQueryAvailability(e){if(e.cancelled||this.destroyed)return e.result=0n,!0;if(e.result!==null||e.disjoint)return!0;if(!this.device.gl.getQueryParameter(e.handle,34919))return!1;let i=!!this.device.gl.getParameter(36795);return e.disjoint=i,e.result=i?0n:BigInt(this.device.gl.getQueryParameter(e.handle,34918)),!0}async _consumeTimestampPairResult(e){let t=this._timestampPairs[e];if(!t||t.completedQueries.length===0)throw new Error("Timestamp query pair has no completed result");let i=t.completedQueries.shift();try{return await this._consumeQueryResult(i)}finally{this.device.gl.deleteQuery(i.handle)}}_consumeQueryResult(e){return e.promise||(this._pendingReads.add(e),e.promise=new Promise((t,i)=>{e.resolve=t,e.reject=i;let r=()=>{if(e.pollRequestId=null,e.cancelled||this.destroyed){this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,t(0n);return}if(!this._pollQueryAvailability(e)){e.pollRequestId=this._requestAnimationFrame(r);return}this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,e.disjoint?i(new Error("GPU timestamp query was invalidated by a disjoint event")):t(e.result||0n)};r()})),e.promise}_cancelPendingQuery(e){if(this._pendingReads.delete(e),e.cancelled=!0,e.pollRequestId!==null&&(this._cancelAnimationFrame(e.pollRequestId),e.pollRequestId=null),e.resolve){let t=e.resolve;e.promise=null,e.resolve=null,e.reject=null,t(0n)}}_requestAnimationFrame(e){return requestAnimationFrame(e)}_cancelAnimationFrame(e){cancelAnimationFrame(e)}}});var xd,yP=C(()=>{J();xd=class extends Fa{device;gl;handle;signaled;_signaled=!1;constructor(e,t={}){super(e,{}),this.device=e,this.gl=e.gl;let i=this.props.handle||this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE,0);if(!i)throw new Error("Failed to create WebGL fence");this.handle=i,this.signaled=new Promise(r=>{let s=()=>{let o=this.gl.clientWaitSync(this.handle,0,0);o===this.gl.ALREADY_SIGNALED||o===this.gl.CONDITION_SATISFIED?(this._signaled=!0,r()):setTimeout(s,1)};s()})}isSignaled(){if(this._signaled)return!0;let e=this.gl.getSyncParameter(this.handle,this.gl.SYNC_STATUS);return this._signaled=e===this.gl.SIGNALED,this._signaled}destroy(){this.destroyed||this.gl.deleteSync(this.handle)}}});function yy(n){switch(n){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function bP(n){switch(n){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}var vP=C(()=>{});function xP(n,e){let{sourceX:t=0,sourceY:i=0,sourceAttachment:r=0}=e||{},{target:s=null,sourceWidth:o,sourceHeight:a,sourceDepth:c,sourceFormat:l,sourceType:u}=e||{},{framebuffer:f,deleteFramebuffer:d}=EP(n),{gl:h,handle:p}=f;o||=f.width,a||=f.height;let m=f.colorAttachments[r]?.texture;if(!m)throw new Error(`Invalid framebuffer attachment ${r}`);c=m?.depth||1,l||=m?.glFormat||6408,u||=m?.glType||5121,s=Dz(s,u,l,o,a,c);let g=Xe.getDataType(s);u=u||q2(g);let v=h.bindFramebuffer(36160,p);return h.readBuffer(36064+r),h.readPixels(t,i,o,a,l,u,s),h.readBuffer(36064),h.bindFramebuffer(36160,v||null),d&&f.destroy(),s}function wP(n,e){let{target:t,sourceX:i=0,sourceY:r=0,sourceFormat:s=6408,targetByteOffset:o=0}=e||{},{sourceWidth:a,sourceHeight:c,sourceType:l}=e||{},{framebuffer:u,deleteFramebuffer:f}=EP(n);a=a||u.width,c=c||u.height;let d=u;l=l||5121;let h=t;if(!h){let m=yy(s),g=bP(l),v=o+a*c*m*g;h=d.device.createBuffer({byteLength:v})}let p=n.device.createCommandEncoder();return p.copyTextureToBuffer({sourceTexture:n,width:a,height:c,origin:[i,r],destinationBuffer:h,byteOffset:o}),p.destroy(),f&&u.destroy(),h}function EP(n){return n instanceof Rr?{framebuffer:n,deleteFramebuffer:!1}:{framebuffer:Oz(n),deleteFramebuffer:!0}}function Oz(n,e){let{device:t,width:i,height:r,id:s}=n;return t.createFramebuffer({...e,id:`framebuffer-for-${s}`,width:i,height:r,colorAttachments:[n]})}function Dz(n,e,t,i,r,s){if(n)return n;e||=5121;let o=cd(e),a=Xe.getTypedArrayConstructor(o),c=yy(t);return new a(i*r*c)}var SP=C(()=>{J();dd();vP();gy()});function PP(n){let e=new Map;for(let t in n){let i=n[t];if(t<"a"){let r=e.get(i);e.set(i,r?`${r}, GL.${t}`:`GL.${t}`)}}return e}var CP=C(()=>{});var by={};mi(by,{WebGLDevice:()=>nr});function Nz(n,e,t){switch(t.length){case 1:n.gl.vertexAttrib1fv(e,t);break;case 2:n.gl.vertexAttrib2fv(e,t);break;case 3:n.gl.vertexAttrib3fv(e,t);break;case 4:n.gl.vertexAttrib4fv(e,t);break;default:}}function Fz(n,e,t){n.gl.vertexAttribI4iv(e,t)}function zz(n,e,t){n.gl.vertexAttribI4uiv(e,t)}function Uz(n,e){if(!n||!e||n.length!==e.length||n.constructor!==e.constructor)return!1;for(let t=0;t{J();ty();E2();ny();C2();B2();O2();D2();N2();X_();Lo();z2();ed();G2();j2();ld();Kf();iP();sP();fP();pP();gP();_P();yP();SP();Po();ad();Nc();CP();nr=class n extends bi{static getDeviceFromContext(e){return e?e.luma?.device??null:null}type="webgl";handle;features;limits;info;canvasContext;preferredColorFormat="rgba8unorm";preferredDepthFormat="depth24plus";commandEncoder;lost;_resolveContextLost;_isLost=!1;gl;_glKeyByValue=null;_constants;extensions;_polyfilled=!1;spectorJS;get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(e){switch(e){case"unorm8x4-bgra":return!1;default:return!0}}constructor(e){super({...e,id:e.id||F2("webgl-device")});let t=bi._getCanvasContextProps(e);if(!t)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let i=t.canvas?.gl??null,r=n.getDeviceFromContext(i);if(r)throw new Error(`WebGL context already attached to device ${r.id}`);this.canvasContext=new Qf(this,t),this.lost=new Promise(u=>{this._resolveContextLost=u});let s={...e.webgl};t.alphaMode==="premultiplied"&&(s.premultipliedAlpha=!0),e.powerPreference!==void 0&&(s.powerPreference=e.powerPreference),e.failIfMajorPerformanceCaveat!==void 0&&(s.failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat);let a=this.props._handle||w2(this.canvasContext.canvas,{onContextLost:u=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."}),onContextRestored:u=>{console.log("WebGL context restored")}},s);if(!a)throw new Error("WebGL context creation failed");if(r=n.getDeviceFromContext(a),r){if(e._reuseDevices)return N.log(1,`Not creating a new Device, instead returning a reference to Device ${r.id} already attached to WebGL context`,r)(),this.canvasContext.destroy(),r._reused=!0,r;throw new Error(`WebGL context already attached to device ${r.id}`)}this.handle=a,this.gl=a,this.spectorJS=f2({...this.props,gl:this.handle});let c=Dc(this.handle);c.device=this,c.extensions||(c.extensions={}),this.extensions=c.extensions,this.info=S2(this.gl,this.extensions),this.limits=new Xf(this.gl),this.features=new Zf(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new vn(this.gl,{log:(...u)=>N.log(1,...u)()}).trackState(this.gl,{copyState:!1}),(e.debug||e.debugWebGL)&&(this.gl=l2(this.gl,{debugWebGL:!0,traceWebGL:e.debugWebGL}),N.warn("WebGL debug mode activated. Performance reduced.")()),e.debugWebGL&&(N.level=Math.max(N.level,1)),this.commandEncoder=new Gc(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}destroy(){if(!this.props._reuseDevices&&!this._reused){this._isLost=!0,this.commandEncoder?.destroy();let e=Dc(this.handle);e.device=null}}get isLost(){return this._isLost||this.gl.isContextLost()}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createPresentationContext(e){return new Jf(this,e||{})}createBuffer(e){let t=this._normalizeBufferProps(e);return new wn(this,t)}createTexture(e){return new ii(this,e)}createExternalTexture(e){throw new Error("ExternalTexture is not available on WebGL")}createSampler(e){return new od(this,e)}createShader(e){return new nd(this,e)}createFramebuffer(e){return new ti(this,e)}createVertexArray(e){return new _d(this,e)}createTransformFeedback(e){return new yd(this,e)}createQuerySet(e){return new vd(this,e)}createFence(){return new xd(this)}createRenderPipeline(e){return new hd(this,e)}_createSharedRenderPipelineWebGL(e){return new pd(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}createRenderBundleEncoder(e){throw new Error("Render bundles are only supported in WebGPU")}createCommandEncoder(e={}){return new Gc(this,e)}submit(e){let t=null;e||({submittedCommandEncoder:t,commandBuffer:e}=this._finalizeDefaultCommandEncoderForSubmit());try{e._executeCommands(),t&&t.resolveTimeProfilingQuerySet().then(()=>{this.commandEncoder._gpuTimeMs=t._gpuTimeMs}).catch(()=>{})}finally{e.destroy()}}writeBufferViaCommandEncoder(e,t,i,r=0){t.write(i,r)}_finalizeDefaultCommandEncoderForSubmit(){let e=this.commandEncoder,t=e.finish();return this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:e.props.id,timeProfilingQuerySet:e.getTimeProfilingQuerySet()}),{submittedCommandEncoder:e,commandBuffer:t}}readPixelsToArrayWebGL(e,t){return xP(e,t)}readPixelsToBufferWebGL(e,t){return wP(e,t)}setParametersWebGL(e){bn(this.gl,e)}getParametersWebGL(e){return Vf(this.gl,e)}withParametersWebGL(e,t){return En(this.gl,e,t)}resetWebGL(){N.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),_2(this.gl)}_getDeviceSpecificTextureFormatCapabilities(e){return k2(this.gl,e,this.extensions)}loseDevice(){let e=!1,i=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return i&&(e=!0,i.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){vn.get(this.gl).push()}popState(){vn.get(this.gl).pop()}getGLKey(e,t){let i=this._getGLKeyByValue().get(Number(e));return i||(t?.emptyIfUnknown?"":String(e))}getGLKeys(e){let t={emptyIfUnknown:!0};return Object.entries(e).reduce((i,[r,s])=>(i[`${r}:${this.getGLKey(r,t)}`]=`${s}:${this.getGLKey(s,t)}`,i),{})}_getGLKeyByValue(){return this._glKeyByValue??=PP(this.gl),this._glKeyByValue}setConstantAttributeWebGL(e,t){let i=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(i).fill(null);let r=this._constants[e];switch(r&&Uz(r,t)&&N.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=t,t.constructor){case Float32Array:Nz(this,e,t);break;case Int32Array:Fz(this,e,t);break;case Uint32Array:zz(this,e,t);break;default:throw new Error("constant")}}getExtension(e){return xn(this.gl,e,this.extensions),this.extensions}_setWebGLDebugMetadata(e,t,i){e.luma=t;let r={props:i.spector,id:i.spector.id};e.__SPECTOR_Metadata=r}}});function $z(n){return typeof WebGL2RenderingContext<"u"&&n instanceof WebGL2RenderingContext?!0:!!(n&&typeof n.createVertexArray=="function")}function TP(n){return{...n,debug:n.debug??bi.defaultProps.debug,debugWebGL:n.debugWebGL??bi.defaultProps.debugWebGL,debugSpectorJS:n.debugSpectorJS??!!N.get("debug-spectorjs")}}async function LP(n){let e=[];(n.debugWebGL||n.debug)&&e.push(c2()),n.debugSpectorJS&&e.push(u2(n));let t=await Promise.allSettled(e);for(let i of t)i.status==="rejected"&&N.error(`Failed to initialize debug libraries ${i.reason}`)()}var Vc,vy,Wc,MP=C(()=>{J();o2();X_();Vc=1,vy=class extends Ea{type="webgl";enforceWebGL2(e){s2(e)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext&&N.warn("WebGL1 is not supported",e)(),!1)}async attach(e,t={}){let{WebGLDevice:i}=await Promise.resolve().then(()=>(wd(),by));if(e instanceof i)return e;let r=i.getDeviceFromContext(e);if(r)return r;if(!$z(e))throw new Error("Invalid WebGL2RenderingContext");t=TP(t),await LP(t);let s=t.createCanvasContext===!0?{}:t.createCanvasContext;return new i({...t,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...s}})}async create(e={}){let{WebGLDevice:t}=await Promise.resolve().then(()=>(wd(),by));e=TP(e),await LP(e);try{let i=new t(e);N.groupCollapsed(Vc,`WebGLDevice ${i.id} created`)();let r=`${i._reused?"Reusing":"Created"} device with WebGL2 ${i.props.debug?"debug ":""}context: ${i.info.vendor}, ${i.info.renderer} for canvas: ${i.canvasContext.id}`;return N.probe(Vc,r)(),N.table(Vc,i.info)(),i}finally{N.groupEnd(Vc)(),N.info(Vc,"%cWebGL call tracing: luma.log.set('debug-webgl') ","color: white; background: blue; padding: 2px 6px; border-radius: 3px;")()}}};Wc=new vy});var bd=C(()=>{MP();wd();ed()});function Td(n){return FP.test(n)}function Ld(n){return zP.test(n)}function UP(n){let e=FP.exec(n),t=zP.exec(n),i=e?.[1]??t?.[1]??n;try{Pe.getVertexFormatInfo(i)}catch{throw new Error(`Unsupported GPUVector format ${n}`)}return i}function Ti(n){let e=UP(n),t=Td(n),i=Ld(n),r=Pe.getVertexFormatInfo(e),s=r.type,o=r.normalized,a=Hz(s,o);return{format:n,elementFormat:e,vertexList:t,valueList:i,type:s,signedDataType:Yz(e,s),primitiveType:a,components:r.components,byteLength:r.byteLength,integer:r.integer,signed:r.signed,normalized:o,...r.webglOnly?{webglOnly:!0}:{}}}function Hz(n,e){if(e)return"f32";switch(n){case"float32":return"f32";case"float16":return"f16";case"uint8":case"uint16":case"uint32":return"u32";case"sint8":case"sint16":case"sint32":return"i32";default:throw new Error(`Unsupported GPUVector component type ${n}`)}}function Yz(n,e){if(n==="unorm10-10-10-2")return"uint32";switch(e){case"unorm8":return"uint8";case"snorm8":return"sint8";case"unorm16":return"uint16";case"snorm16":return"sint16";default:return e}}var FP,zP,Md=C(()=>{J();FP=/^vertex-list<([^<>]+)>$/,zP=/^value-list<([^<>]+)>$/});function Ey(n,e){if(!Number.isSafeInteger(n)||n<0)throw new Error(`${e} must be a non-negative safe integer`)}var Li,Sy=C(()=>{J();Li=class{buffer;format;length;byteOffset;byteStride;constructor(e){let t=Pe.getVertexFormatInfo(e.format).byteLength,i=e.byteOffset??0,r=e.byteStride??t;if(Ey(e.length,"GPUDataView length"),Ey(i,"GPUDataView byteOffset"),Ey(r,"GPUDataView byteStride"),re.buffer.byteLength)throw new Error("GPUDataView exceeds its backing buffer byte length");this.buffer=e.buffer,this.format=e.format,this.length=e.length,this.byteOffset=i,this.byteStride=r}get elementByteLength(){return Pe.getVertexFormatInfo(this.format).byteLength}get byteLength(){return this.length===0?0:(this.length-1)*this.byteStride+this.elementByteLength}}});function kd(n){return!!(n&&typeof n=="object"&&n.type==="struct")}function GP(n,e){let t=Object.entries(n);if(t.length===0)throw new Error("GPUData struct format must declare at least one field");return e==="packed"?qz(t):Zz(t)}function qz(n){let e=[],t=0,i=0;for(let[r,s]of n){let o=Pe.getVertexFormatInfo(s);if(o.webglOnly)throw new Error(`Packed GPUData struct field "${r}" uses WebGL-only format ${s}`);t=$P(t,Math.min(4,o.byteLength)),e.push([r,Object.freeze({format:s,byteOffset:t,byteLength:o.byteLength})]),t+=o.byteLength,i+=o.components}return Object.freeze({type:"struct",layout:"packed",fields:Object.freeze(Object.fromEntries(e)),components:i,byteStride:$P(t,4),rowByteLength:t})}function Zz(n){let e=Object.fromEntries(n.map(([o,a])=>[o,Xz(a)])),t=Dr(e,{layout:"wgsl-storage"}),i=[],r=0,s=0;for(let[o,a]of n){let c=Pe.getVertexFormatInfo(a),l=t.fields[o].offset*4;i.push([o,Object.freeze({format:a,byteOffset:l,byteLength:c.byteLength})]),r=Math.max(r,l+c.byteLength),s+=c.components}return Object.freeze({type:"struct",layout:"wgsl-storage",fields:Object.freeze(Object.fromEntries(i)),components:s,byteStride:t.byteLength,rowByteLength:r})}function Xz(n){let e=Pe.getVertexFormatInfo(n);switch(e.type){case"float32":return Ad("f32",e.components);case"sint32":return Ad("i32",e.components);case"uint32":return Ad("u32",e.components);default:{let t=Math.ceil(e.byteLength/4);return Ad("u32",t)}}}function Ad(n,e){return e===1?n:`vec${e}<${n}>`}function $P(n,e){return Math.ceil(n/e)*e}var VP=C(()=>{J()});var Py,Cy,Mo,Ty=C(()=>{Sy();VP();Md();Py=class{buffer;ownsDataBuffer;constructor(e,t){this.buffer=e,this.ownsDataBuffer=t}get ownsBuffer(){return this.ownsDataBuffer}transferBufferOwnership(e){if(e.buffer!==this.buffer)throw new Error("GPUData ownership can only be transferred to the same buffer");e.ownsDataBuffer=this.ownsDataBuffer,this.ownsDataBuffer=!1}destroy(){this.ownsDataBuffer&&(this.buffer.destroy(),this.ownsDataBuffer=!1)}},Cy=class extends Py{dataType;format;length;valueLength;stride;byteOffset;byteStride;rowByteLength;readbackMetadata;valueOffsets;nullBitmap;valueByteLength;constructor(e){let{buffer:t,format:i,length:r,valueLength:s,stride:o,byteOffset:a=0,byteStride:c,rowByteLength:l,ownsBuffer:u=!1,readbackMetadata:f,valueOffsets:d,nullBitmap:h,valueByteLength:p,dataType:m}=e;super(t,u);let g;i?typeof i=="string"?g=i:g=GP(i,e.layout??"wgsl-storage"):g=void 0;let v=kd(g)?g:void 0,y=typeof g=="string"?Ti(g):void 0;if(this.dataType=m,this.format=g,this.length=r,this.valueLength=s??r,this.stride=o??y?.components??v?.components??c??l??1,this.byteOffset=a,this.rowByteLength=l??v?.rowByteLength??y?.byteLength??c??this.stride,this.byteStride=c??v?.byteStride??this.rowByteLength,v){if(this.rowByteLengthi.format!==e))throw new Error("GPUVector data chunks must share the declared format")}var ri,jP=C(()=>{Ty();Md();ri=class{name;dataType;format;length;valueLength;stride;byteOffset;byteStride;rowByteLength;bufferLayout;data=[];device;bufferProps;isAppendable=!1;ownsDataChunks=!0;ownedVectors=[];appendableByteLength=0;constructor(e){switch(e.type){case"buffer":{let{name:t,buffer:i,format:r,length:s,valueLength:o=s,byteOffset:a=0,ownsBuffer:c=!1}=e,{stride:l,byteStride:u,rowByteLength:f}=WP(e);this.name=t,this.dataType=e.dataType,this.format=r,this.length=s,this.valueLength=o,this.stride=l,this.byteOffset=a,this.byteStride=u,this.rowByteLength=f,this.data.push(new Mo({buffer:i,format:r,length:s,valueLength:o,stride:l,byteOffset:a,byteStride:u,rowByteLength:f,ownsBuffer:c,dataType:e.dataType}));return}case"interleaved":{let{name:t,buffer:i,format:r,length:s,valueLength:o=s,byteOffset:a=0,byteStride:c,attributes:l,ownsBuffer:u=!1}=e;this.name=t,this.dataType=e.dataType,this.format=r,this.length=s,this.valueLength=o,this.stride=c,this.byteOffset=a,this.byteStride=c,this.rowByteLength=c,this.bufferLayout={name:t,byteStride:c,attributes:l},this.data.push(new Mo({buffer:i,format:r,length:s,valueLength:o,stride:c,byteOffset:a,byteStride:c,rowByteLength:c,ownsBuffer:u,dataType:e.dataType}));return}case"data":{let t=e.format??Kz(e.data),i=t?Ti(t):void 0,{name:r,data:s,stride:o=s[0]?.stride??i?.components??1,valueLength:a=s.reduce((d,h)=>d+h.valueLength,0),byteStride:c=s[0]?.byteStride??i?.byteLength,rowByteLength:l=s[0]?.rowByteLength??i?.byteLength,bufferLayout:u,ownsData:f=!1}=e;if(c===void 0||l===void 0)throw new Error("GPUVector requires format or explicit byte layout metadata");t&&Qz(s,t),this.name=r,this.dataType=e.dataType,this.format=t,this.length=s.reduce((d,h)=>d+h.length,0),this.valueLength=a,this.stride=o,this.byteOffset=s.length===1?s[0].byteOffset:0,this.byteStride=c,this.rowByteLength=l,this.bufferLayout=u,this.ownsDataChunks=f,this.data.push(...s);return}case"appendable":{let{name:t,device:i,format:r,valueLength:s=0,bufferProps:o}=e,{stride:a,byteStride:c,rowByteLength:l}=WP(e);this.name=t,this.dataType=e.dataType,this.format=r,this.length=0,this.valueLength=s,this.stride=a,this.byteOffset=0,this.byteStride=c,this.rowByteLength=l,this.device=i,this.bufferProps=o,this.isAppendable=!0;return}}}get ownsBuffer(){return this.ownsDataChunks&&this.data.some(e=>e.ownsBuffer)||this.ownedVectors.some(e=>e.ownsBuffer)}get capacityRows(){return this.isAppendable?this.length:void 0}get appendedByteLength(){return this.appendableByteLength}addData(e){if(this.format&&e.format!==this.format)throw new Error("GPUVector.addData() requires matching formats");if(e.byteStride!==this.byteStride)throw new Error("GPUVector.addData() requires matching byteStride");if(e.rowByteLength!==this.rowByteLength)throw new Error("GPUVector.addData() requires matching rowByteLength");return this.data.push(e),this.length+=e.length,this.valueLength+=e.valueLength,this}appendDataChunk(e,t=this.appendableByteLength+e.buffer.byteLength){if(!this.isAppendable)throw new Error("GPUVector.appendDataChunk() requires appendable vector storage");if(this.format&&e.format!==this.format)throw new Error("GPUVector.appendDataChunk() requires matching formats");if(e.byteStride!==this.byteStride||e.rowByteLength!==this.rowByteLength)throw new Error("GPUVector.appendDataChunk() requires matching byte layout metadata");return this.data.push(e),this.length+=e.length,this.valueLength+=e.valueLength,this.appendableByteLength=t,this}resetLastBatch(){if(!this.isAppendable)throw new Error("GPUVector.resetLastBatch() requires appendable vector storage");for(let e of this.data.splice(0))e.destroy();return this.length=0,this.valueLength=0,this.appendableByteLength=0,this}retainOwnedVectors(e){return this.ownedVectors.push(...e),this}transferBufferOwnership(e){let t=this.data[0],i=e.data[0];if(!t||!i||t.buffer!==i.buffer)throw new Error("GPUVector ownership can only be transferred to the same buffer");t.transferBufferOwnership(i)}destroy(){if(this.ownsDataChunks)for(let e of this.data)e.destroy();for(let e of this.ownedVectors.splice(0))e.destroy()}}});var Ly=C(()=>{Ty();Sy();jP();Md()});var My,pt,Zc=C(()=>{J();My=class{poolSize=20;bufferPools;constructor(){this.bufferPools=new Map}createOrReuse(e,t){if(t>e.limits.maxBufferSize)throw new Error(`Buffer pool cannot allocate ${t} bytes: device.limits.maxBufferSize is ${e.limits.maxBufferSize}`);let i=this.bufferPools.get(e),r=i?i.findIndex(o=>o.byteLength>=t):-1;if(r<0)return e.createBuffer({usage:ie.VERTEX|ie.STORAGE|ie.COPY_DST|ie.COPY_SRC,byteLength:t});let[s]=i.splice(r,1);return s}recycle(e){let t=e.device;this.bufferPools.has(t)||this.bufferPools.set(t,[]);let i=this.bufferPools.get(t),r=i.findIndex(s=>s.byteLength>e.byteLength);r<0?i.push(e):i.splice(r,0,e),this.purge()}purge(){for(let[e,t]of this.bufferPools){let i=e.isLost?0:this.poolSize;for(;t.length>i;)t.shift().destroy();t.length===0&&this.bufferPools.delete(e)}}},pt=new My});function Jz(n,e,t,i){let{ValueType:r,size:s,offset:o,stride:a}=n,c=a/r.BYTES_PER_ELEMENT,l=o/r.BYTES_PER_ELEMENT,u=i-t;if(c===s){let d=l+t*c;return e.subarray(d,d+u*s)}let f=new r(u*s);for(let d=0;d0)throw new Error(`GPUDataEvaluator requires exactly one GPUData chunk for "${n.name}"`);return e}function nU(n){let e=[];return YP(n,e,{byteOffset:0}),e}function YP(n,e,t){let i=n.source;if(i&&!(i instanceof ve)&&i.name==="interleave"){for(let r of Object.values(i.inputs))r instanceof ve&&YP(r,e,t);return}e.push({attribute:n.id??n.toString(),format:qP(n.type,n.size,n.normalized),byteOffset:t.byteOffset}),t.byteOffset+=n.ValueType.BYTES_PER_ELEMENT*n.size}function qP(n,e,t=!1){if(e<1||e>4)throw new Error(`Cannot synthesize a GPUVector vertex format with ${e} components`);let i=n;if(t)switch(n){case"uint8":i="unorm8";break;case"sint8":i="snorm8";break;case"uint16":i="unorm16";break;case"sint16":i="snorm16";break;case"float32":i="float32";break;default:throw new Error(`Unsupported normalized vertex format for ${n}`)}return(i==="uint8"||i==="sint8"||i==="uint16"||i==="sint16"||i==="unorm8"||i==="snorm8"||i==="unorm16"||i==="snorm16")&&e===3?`${i}x3-webgl`:`${i}${e===1?"":`x${e}`}`}function iU(n,e,t=!1){return e>=1&&e<=4?qP(n,e,t):void 0}var ve,Mi=C(()=>{J();Me();Ly();Zc();ve=class n{static get bufferPoolSize(){return pt.poolSize}static set bufferPoolSize(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("GPUDataEvaluator.bufferPoolSize must be a non-negative safe integer");pt.poolSize=e,pt.purge()}type;size;get offset(){return this._offset}get stride(){return this._stride}normalized;isConstant;length;get byteLength(){return this._byteLength}ValueType;source=null;format;_id;_destroyed=!1;_value;_offset;_stride;_byteLength;_gpuVector;_bufferOwnership="owned";_targetBuffer;static fromArray(e,{type:t,size:i=1,offset:r=0,stride:s=0,normalized:o=!1}){let a=t,c;if(Array.isArray(e)){a=a||"float32";let u=Tr(a);c=new u(e)}else e instanceof Float64Array?(a="uint32",i*=2,r*=2,s*=2,c=new Uint32Array(e.buffer,e.byteOffset,e.byteLength/4)):(a=a||Lu(e),c=e);let l=`<${a} * ${i}>`;return new n({id:l,type:a,size:i,offset:r,stride:s,normalized:o,value:c})}static fromConstant(e,t="float32"){let i=Tr(t),r;return Array.isArray(e)?r=`[${e.join(",")}]`:(r=String(e),e=[e]),new n({id:r,isConstant:!0,type:t,size:e.length,value:new i(e)})}static fromGPUData(e,t={}){eU(e);let i=new Li({buffer:e.buffer,format:e.format,length:e.length,byteOffset:e.byteOffset,byteStride:e.byteStride});return new n({...HP(i),id:t.id,gpuData:e})}static fromGPUDataView(e,t={}){return new n({...HP(e),id:t.id,buffer:e.buffer})}constructor(e){let{id:t,value:i,buffer:r,gpuData:s,format:o,source:a=null,isConstant:c=!1}=e;if(!a&&!i&&!r&&!s)throw new Error("GPUDataEvaluator must have a value source");let{type:l,size:u,offset:f,stride:d,normalized:h,length:p}=e;if(a instanceof n?(l=l??a.type,u=u??a.size,f=f??a.offset,d=d??a.stride,h=h??a.normalized,p=p??a.length):(u=u??1,f=f??0,h=h??!1,p=c?1:p),!l)throw new Error("GPUDataEvaluator: type not defined");if(this._id=t,this.type=l,this.size=u,this.ValueType=Tr(this.type),this._offset=f,this._stride=d||this.ValueType.BYTES_PER_ELEMENT*u,this.normalized=h,this.source=a,this.format=o,p===void 0)if(c)p=1;else{if(!i)throw new Error("GPUDataEvaluator: length not defined");p=Math.ceil(i.byteLength/this.stride)}this.isConstant=c,this.length=p;let m=this.ValueType.BYTES_PER_ELEMENT*this.size;this._byteLength=p===0?0:(p-1)*this.stride+m,this._value=i,this._bufferOwnership=a instanceof n||r||s?"borrowed":"owned",s?this._gpuVector=new ri({type:"data",name:this._id??"data",format:s.format,data:[s],stride:s.stride,byteStride:s.byteStride,rowByteLength:s.rowByteLength}):r&&(this._gpuVector=this.createGPUVectorView({buffer:r,name:this._id,format:this.format}))}get value(){return this._value||(this.source instanceof n?this.source.value:void 0)}get evaluated(){return!!this._gpuVector}get id(){return this._id}get gpuVector(){if(!this._gpuVector)throw new Error(`${this} not evaluated`);return this._gpuVector}get buffer(){return Rd(this.gpuVector)}setTargetBuffer({buffer:e,byteOffset:t=0,byteStride:i=this.stride}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)throw new Error(`GPUDataEvaluator ${this} already evaluated`);if(!this.source||this.source instanceof n)throw new Error("GPUDataEvaluator target buffers require a deferred operation source");this._targetBuffer={buffer:e,byteOffset:t,byteStride:i}}async evaluate(e,t={}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let i;if(this.source instanceof n){let r=await this.source.evaluate(e);return this._gpuVector=this.createGPUVectorView({...t,buffer:Rd(r)}),this._gpuVector}if(i=this._getEvaluationBuffer(e),this._value)i.write(this._value);else{let r=await this.source.execute(e,i);if(!r.success)throw r.error||new Error(`${this.source} evaluation failed`);r.value&&(this._value=r.value)}return this._gpuVector=this.createGPUVectorView({...t,buffer:i}),this._gpuVector}evaluateSync(e,t={}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let i;if(this.source instanceof n){let r=this.source.evaluateSync(e);return this._gpuVector=this.createGPUVectorView({...t,buffer:Rd(r)}),this._gpuVector}if(i=this._getEvaluationBuffer(e),this._value)i.write(this._value);else{let r=this.source.executeSync(e,i);if(!r.success)throw r.error||new Error(`${this.source} evaluation failed`);r.value&&(this._value=r.value)}return this._gpuVector=this.createGPUVectorView({...t,buffer:i}),this._gpuVector}createGPUVectorView(e){let t=e.name??this._id??"vector",i=e.format??this.format??iU(this.type,this.size,this.normalized);if(e.interleaved){let r=typeof e.interleaved=="object"&&e.interleaved.attributes?e.interleaved.attributes:nU(this);return new ri({type:"interleaved",name:t,buffer:e.buffer,format:e.format??this.format,length:this.length,byteOffset:this.offset,byteStride:this.stride,attributes:r,ownsBuffer:!1})}return new ri({type:"buffer",name:t,buffer:e.buffer,format:i,length:this.length,stride:this.size,byteOffset:this.offset,byteStride:this.stride,rowByteLength:this.ValueType.BYTES_PER_ELEMENT*this.size,ownsBuffer:!1})}_getEvaluationBuffer(e){let t=this._targetBuffer;if(!t)return pt.createOrReuse(e,this.byteLength);if(t.buffer.device!==e)throw new Error("GPUDataEvaluator target buffer belongs to a different device");let i=this.ValueType.BYTES_PER_ELEMENT*this.size,r=this.length===0?0:(this.length-1)*t.byteStride+i;if(t.byteOffset+r>t.buffer.byteLength)throw new Error("GPUDataEvaluator target buffer is too small for the output layout");return this._offset=t.byteOffset,this._stride=t.byteStride,this._byteLength=r,this._bufferOwnership="borrowed",this._targetBuffer=void 0,t.buffer}async readValue(e=0,t){let{ValueType:i}=this,{size:r,offset:s,stride:o,length:a}=this,c=i.BYTES_PER_ELEMENT*r;if(t=t??a,e=Math.max(0,Math.min(a,e)),t=Math.max(e,Math.min(a,t)),this._value)return Jz(this,this._value,e,t);let l=t-e;if(l===0)return new i(0);let u=s+e*o,f=o===c?l*c:(l-1)*o+c,d=await this.buffer.readAsync(u,f),h=new i(d.buffer,d.byteOffset,d.byteLength/i.BYTES_PER_ELEMENT);if(o===c)return h;let p=new Uint8Array(c*l);for(let m=0;m{Ao={add:{arity:2,symbol:"arithmetic_add"},subtract:{arity:2,symbol:"arithmetic_subtract"},multiply:{arity:2,symbol:"arithmetic_multiply"},divide:{arity:2,symbol:"arithmetic_divide"},pow:{arity:2,symbol:"pow"},sqrt:{arity:1,symbol:"sqrt"},abs:{arity:1,symbol:"abs"},sin:{arity:1,symbol:"sin"},cos:{arity:1,symbol:"cos"},tan:{arity:1,symbol:"arithmetic_tan"},exp:{arity:1,symbol:"exp"},log:{arity:1,symbol:"log"}}});function lC(n,{operations:e,inputs:t}){switch(n.kind){case"input":if(!(n.name in t))throw new Error(`Unknown expression input '${n.name}'`);return;case"literal":if(Array.isArray(n.value)){for(let i of n.value)if(!Number.isFinite(i))throw new Error(`Expression literal array must contain only finite values, got ${i}`)}else if(!Number.isFinite(n.value))throw new Error(`Expression literal must be finite, got ${n.value}`);return;case"call":{let i=e[n.op];if(!i)throw new Error(`Unknown expression op '${n.op}'`);if(n.args.length!==i.arity)throw new Error(`Expression op '${n.op}' expects ${i.arity} args, got ${n.args.length}`);for(let r of n.args)lC(r,{operations:e,inputs:t});return}default:{let i=n;throw new Error(`Unsupported expression node ${i.kind}`)}}}function Od(n,e){return lC(n,e),uC(n,e)}function uC(n,e){switch(n.kind){case"input":{let t=e.inputs[n.name];return e.laneIndexuC(r,e));return e.formatCall(t.symbol,i)}default:{let t=n;throw new Error(`Unsupported expression node ${t.kind}`)}}}var Iy=C(()=>{});function it(n,e,t=!1){if(t)return e===1?"float":`vec${e}`;switch(n){case"uint8":case"uint16":case"uint32":return e===1?"uint":`uvec${e}`;case"sint8":case"sint16":case"sint32":return e===1?"int":`ivec${e}`;default:return e===1?"float":`vec${e}`}}function Dd(n,e,t=!1){let i;if(t)switch(n){case"uint8":i="unorm8";break;case"sint8":i="snorm8";break;case"uint16":i="unorm16";break;case"sint16":i="snorm16";break;case"float32":i="float32";break;default:throw new Error(`Unsupported normalized vertex format for ${n}`)}else i=n;return e===1?i:e===3&&!i.startsWith("float32")&&!i.endsWith("32")?`${i}x3-webgl`:`${i}x${e}`}function ir(n){switch(n[0]){case"u":return"0u";case"s":return"0";default:return"0."}}function fC(n,e){switch(n){case"uint8":case"uint16":case"uint32":return`${Math.trunc(e)}u`;case"sint8":case"sint16":case"sint32":return`${Math.trunc(e)}`;default:return Number.isInteger(e)?`${e}.0`:`${e}`}}function dC(n){switch(n){case"uint8":return"r8uint";case"sint8":return"r8sint";case"uint16":return"r16uint";case"sint16":return"r16sint";case"uint32":return"r32uint";case"sint32":return"r32sint";case"float32":return"r32float";default:throw new Error(`Unsupported WebGL gather texture format for ${n}`)}}function hC(n){switch(n){case"uint32":return"usampler2D";case"sint32":return"isampler2D";case"float32":return"sampler2D";default:throw new Error(`Unsupported WebGL gather sampler type for ${n}`)}}var Ro=C(()=>{});function rt({module:n,elementWise:e=!1,expression:t,inputs:i,output:r,operationType:s=r.type,outputBuffer:o}){let a=o.device,c=cs("result",r.type,r.size,r.normalized),l=[n,c],u=[],f={},d=it(r.type,1,r.normalized),h=it(s,1,r.normalized),p="",m=null,g={TYPE:h,RESULT_LEN:r.size.toString()},v=dU(i);for(let[E,w]of v)l.push(By(E,w.type,w.size,w.normalized,s)),u.push(Oy(E,w)),w instanceof ve?f[E]=w.buffer:(m=m||pt.createOrReuse(a,o.byteLength),f[E]=m),p+=`TYPE ${E}[${w.size}]; get_${E}(${E}); `,g[`${E.toUpperCase()}_LEN`]=w.size.toString();let y="";if(t)for(let E=0;EEE).join(", ")}, result);`;let b=`#version 300 es @@ -2538,7 +2538,7 @@ ${d} result[${r.size}]; ${y} set_result(result); } - `,x=new nt(a,{vs:b,shaderAssembler:cU,defines:g,modules:l,bufferLayout:u,vertexCount:1,instanceCount:r.length,attributes:f,feedbackBufferMode:"interleaved",outputs:c.varyings});a.statsManager.getStats(oU).get(aU).incrementCount(),x.run({inputBuffers:f,outputBuffers:{[c.varyings[0]]:r.offset===0?o:{buffer:o,byteOffset:r.offset,byteLength:r.byteLength}}}),m&&pt.recycle(m)}function lU(n){return Array.isArray(n)?n.map((e,t)=>[`x${t}`,e]):Object.entries(n)}function By(n,e,t,i=!1,r=e){let s="",o="";for(let c=0;c[`x${t}`,e]):Object.entries(n)}function By(n,e,t,i=!1,r=e){let s="",o="";for(let c=0;c1&&(d=`${d}[${f}]`),(i||e!==r)&&(d=`TYPE(${d})`),o+=`v[${c+f}]=${d}; `}}let a=` ${s} @@ -2552,7 +2552,7 @@ ${o} void set_${n}(in ${s} v[${t}]) { ${a} } -`}}var oU,aU,cU,Dt=C(()=>{Me();vt();Mi();Zc();Ro();oU="GPGPU Operation Counts",aU="Transform Runs",cU=new Xs});var uU,Nd,Dy=C(()=>{vt();Iy();Bd();Dt();Ro();uU=`TYPE arithmetic_add(TYPE x, TYPE y) { +`}}var lU,uU,fU,Dt=C(()=>{Me();vt();Mi();Zc();Ro();lU="GPGPU Operation Counts",uU="Transform Runs",fU=new Xs});var hU,Nd,Dy=C(()=>{vt();Iy();Bd();Dt();Ro();hU=`TYPE arithmetic_add(TYPE x, TYPE y) { return x + y; } @@ -2571,7 +2571,7 @@ TYPE arithmetic_divide(TYPE x, TYPE y) { float arithmetic_tan(float x) { return tan_fp32(x); } -`,Nd=({inputs:n,output:e,target:t})=>{let i=e.type,r=it(i,1,e.normalized),s=ir(r),o=n.namedInputs;return rt({module:{name:"arithmetic",dependencies:[Vr],vs:uU},inputs:o,output:e,operationType:i,outputBuffer:t,expression:a=>Od(n.expression,{operations:Ao,inputs:o,laneIndex:a,formatInput:c=>`${c}[${a}]`,formatOutOfBoundsInput:c=>o[c].size===1?`${c}[0]`:s,formatLiteral:c=>{let l=Array.isArray(c)?c[a]??0:c;return`${r}(${fC(i,l)})`},formatCall:(c,l)=>`${c}(${l.join(", ")})`})}),{success:!0}}});var fU,dU,mC,pC,gC=C(()=>{J();Me();Mi();Zc();Dy();Dt();fU="GPGPU Operation Counts",dU="Transform Runs",mC=({inputs:n,output:e,target:t})=>{let{sourceValues:i}=n,r=t.device;if(i.length===0){let f=new e.ValueType(e.length*e.size);return t.write(f),{success:!0,value:f}}if(i.isConstant){let f=i.value,d=new e.ValueType(e.length*e.size);for(let h=0;h{let i=e.type,r=it(i,1,e.normalized),s=ir(r),o=n.namedInputs;return rt({module:{name:"arithmetic",dependencies:[Vr],vs:hU},inputs:o,output:e,operationType:i,outputBuffer:t,expression:a=>Od(n.expression,{operations:Ao,inputs:o,laneIndex:a,formatInput:c=>`${c}[${a}]`,formatOutOfBoundsInput:c=>o[c].size===1?`${c}[0]`:s,formatLiteral:c=>{let l=Array.isArray(c)?c[a]??0:c;return`${r}(${fC(i,l)})`},formatCall:(c,l)=>`${c}(${l.join(", ")})`})}),{success:!0}}});var pU,mU,mC,pC,gC=C(()=>{J();Me();Mi();Zc();Dy();Dt();pU="GPGPU Operation Counts",mU="Transform Runs",mC=({inputs:n,output:e,target:t})=>{let{sourceValues:i}=n,r=t.device;if(i.length===0){let f=new e.ValueType(e.length*e.size);return t.write(f),{success:!0,value:f}}if(i.isConstant){let f=i.value,d=new e.ValueType(e.length*e.size);for(let h=0;hi+Math.ceil(r.size/4),0);if(t>n)throw new Error(`interleave() requires ${t} vertex attributes, exceeding device limit ${n}`)}function pU(n,e){if(e.size>n)throw new Error(`interleave() output size ${e.size} exceeds device inter-stage component limit ${n}`)}var _C,yC=C(()=>{Dt();_C=({inputs:n,output:e,target:t})=>{let i=n.map((c,l)=>[`x${l}`,c]);hU(t.device.limits.maxVertexAttributes,i),pU(t.device.limits.maxInterStageShaderVariables,e);let r=i.map(([c,l])=>`in TYPE ${c}[${l.size}]`).join(", "),s=0,o=i.map(([c,l])=>{let u=Array.from({length:l.size},(f,d)=>` result[${s+d}] = ${c}[${d}];`).join(` + `,l=new Ze(r,{vs:a,fs:c,topology:"point-list",parameters:{depthCompare:"always",blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one",blendColorOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",blendAlphaOperation:"max"},modules:[By("sourceValues",i.type,i.size,i.normalized)],defines:{TYPE:"float",SOURCE_VALUES_LEN:i.size.toString(),CHANNEL_COUNT:e.length.toString()},attributes:{sourceValues:i.buffer},bufferLayout:[Oy("sourceValues",i)],instanceCount:i.length,vertexCount:e.length,disableWarnings:!0}),u=pt.createOrReuse(r,e.byteLength);try{let f=r.beginRenderPass({framebuffer:o,parameters:{viewport:[0,0,1,e.length]},clearColor:[-pC,-pC,0,0],clearDepth:!1,clearStencil:!1});r.statsManager.getStats(pU).get(mU).incrementCount(),l.draw(f),f.end();let d=r.createCommandEncoder();return d.copyTextureToBuffer({sourceTexture:s,width:1,height:e.length,destinationBuffer:u,byteOffset:0,bytesPerRow:8}),r.submit(d.finish()),Nd({device:r,inputs:{expression:{kind:"call",op:"multiply",args:[{kind:"input",name:"x"},{kind:"literal",value:[-1,1]}]},namedInputs:{x:new ve({buffer:u,size:2,type:"float32",length:e.length})}},output:e,target:t})}finally{l.destroy(),pt.recycle(u),o.destroy(),s.destroy()}},pC=3e38});function gU(n,e){let t=e.reduce((i,[,r])=>i+Math.ceil(r.size/4),0);if(t>n)throw new Error(`interleave() requires ${t} vertex attributes, exceeding device limit ${n}`)}function _U(n,e){if(e.size>n)throw new Error(`interleave() output size ${e.size} exceeds device inter-stage component limit ${n}`)}var _C,yC=C(()=>{Dt();_C=({inputs:n,output:e,target:t})=>{let i=n.map((c,l)=>[`x${l}`,c]);gU(t.device.limits.maxVertexAttributes,i),_U(t.device.limits.maxInterStageShaderVariables,e);let r=i.map(([c,l])=>`in TYPE ${c}[${l.size}]`).join(", "),s=0,o=i.map(([c,l])=>{let u=Array.from({length:l.size},(f,d)=>` result[${s+d}] = ${c}[${d}];`).join(` `);return s+=l.size,u}).join(` `),a=`void interleave(${r}, out TYPE result[RESULT_LEN]) { ${o} } -`;return rt({module:{name:"interleave",vs:a},inputs:n,output:e,outputBuffer:t}),{success:!0}}});function mU(){let n=new Uint16Array([255]);return new Uint8Array(n.buffer)[0]>0}var gU,bC,vC=C(()=>{Dt();gU=`#define LE ${mU()?1:0} +`;return rt({module:{name:"interleave",vs:a},inputs:n,output:e,outputBuffer:t}),{success:!0}}});function yU(){let n=new Uint16Array([255]);return new Uint8Array(n.buffer)[0]>0}var bU,bC,vC=C(()=>{Dt();bU=`#define LE ${yU()?1:0} const uint F32_NAN = 0xffffffffu; const uint F32_INF = 0x7f800000u; @@ -2773,18 +2773,18 @@ void fround(in uint x[X_LEN], out float result[X_LEN]) { result[i + n] = uintBitsToFloat(f.y); } } -`,bC=({inputs:n,output:e,target:t})=>(rt({module:{name:"fround",vs:gU},inputs:n,output:e,operationType:"uint32",outputBuffer:t}),{success:!0})});function Fd(n,e,t){let i=hC(t),r=it(e,1),s=Array.from({length:n.size},(o,a)=>` v[${a}] = ${r}(texelFetch(source_values_texture, ivec2(${a}, rowIndex), 0).r);`).join(` +`,bC=({inputs:n,output:e,target:t})=>(rt({module:{name:"fround",vs:bU},inputs:n,output:e,operationType:"uint32",outputBuffer:t}),{success:!0})});function Fd(n,e,t){let i=hC(t),r=it(e,1),s=Array.from({length:n.size},(o,a)=>` v[${a}] = ${r}(texelFetch(source_values_texture, ivec2(${a}, rowIndex), 0).r);`).join(` `);return{name:"source_values_texture",vs:` uniform highp ${i} source_values_texture; void read_source_values(int rowIndex, out TYPE v[${n.size}]) { ${s} } -`}}function zd(n,e,t){let i=t.createTexture({width:Math.max(n.size,1),height:n.length,format:dC(e),usage:me.SAMPLE|me.COPY_DST});if(n.length===0)return i;let r=t.createCommandEncoder();return r.copyBufferToTexture({sourceBuffer:n.buffer,destinationTexture:i,byteOffset:n.offset,bytesPerRow:n.stride,rowsPerImage:n.length,size:[n.size,n.length,1]}),t.submit(r.finish()),i}var Ny=C(()=>{J();Ro()});function _U(n,e){let t=it(n.type,1),i="aids_0";return n.type!==vU(e)&&(i=`${e}(${i})`),{name:"ids",vs:` +`}}function zd(n,e,t){let i=t.createTexture({width:Math.max(n.size,1),height:n.length,format:dC(e),usage:me.SAMPLE|me.COPY_DST});if(n.length===0)return i;let r=t.createCommandEncoder();return r.copyBufferToTexture({sourceBuffer:n.buffer,destinationTexture:i,byteOffset:n.offset,bytesPerRow:n.stride,rowsPerImage:n.length,size:[n.size,n.length,1]}),t.submit(r.finish()),i}var Ny=C(()=>{J();Ro()});function vU(n,e){let t=it(n.type,1),i="aids_0";return n.type!==EU(e)&&(i=`${e}(${i})`),{name:"ids",vs:` in ${t} aids_0; void get_ids(out INDEX_TYPE v[1]) { v[0] = ${i}; } -`}}function yU(n){return{name:"ids",stepMode:n.isConstant?"vertex":"instance",byteStride:n.stride,attributes:[{attribute:"aids_0",format:Dd(n.type,1,n.normalized),byteOffset:n.offset}]}}function bU(n){return{name:"gather",vs:` +`}}function xU(n){return{name:"ids",stepMode:n.isConstant?"vertex":"instance",byteStride:n.stride,attributes:[{attribute:"aids_0",format:Dd(n.type,1,n.normalized),byteOffset:n.offset}]}}function wU(n){return{name:"gather",vs:` void zero_result(out TYPE result[RESULT_LEN]) { for (int i = 0; i < RESULT_LEN; i++) { result[i] = ${ir(n)}; @@ -2799,7 +2799,7 @@ void gather(in INDEX_TYPE ids[1], out TYPE result[RESULT_LEN]) { } read_source_values(sourceIndex, result); } -`}}function vU(n){switch(n){case"uint":return"uint32";case"int":return"sint32";default:return"float32"}}var xC,wC=C(()=>{Me();Ro();Dt();Ny();xC=async({inputs:n,output:e,target:t})=>{let{ids:i,sourceValues:r}=n,s=t.device,o=cs("result",e.type,e.size),a=it(i.type,1),c=it(e.type,1),l=e.type,u=zd(r,l,s),f=`#version 300 es +`}}function EU(n){switch(n){case"uint":return"uint32";case"int":return"sint32";default:return"float32"}}var xC,wC=C(()=>{Me();Ro();Dt();Ny();xC=async({inputs:n,output:e,target:t})=>{let{ids:i,sourceValues:r}=n,s=t.device,o=cs("result",e.type,e.size),a=it(i.type,1),c=it(e.type,1),l=e.type,u=zd(r,l,s),f=`#version 300 es void main() { INDEX_TYPE ids[1]; @@ -2808,14 +2808,14 @@ void main() { gather(ids, result); set_result(result); } - `,d=new nt(s,{vs:f,defines:{INDEX_TYPE:a,TYPE:c,RESULT_LEN:e.size.toString(),SOURCE_VALUES_ROWS:r.length.toString()},modules:[_U(i,a),Fd(r,e.type,l),bU(e.type),o],bindings:{source_values_texture:u},bufferLayout:[yU(i)],vertexCount:1,instanceCount:e.length,feedbackBufferMode:"interleaved",outputs:o.varyings});try{return d.run({inputBuffers:{ids:i.buffer},outputBuffers:{[o.varyings[0]]:t}}),{success:!0}}finally{d.destroy(),u.destroy()}}});var xU,EC,SC=C(()=>{Dt();xU=`void row_dot(in TYPE x[X_LEN], in TYPE y[Y_LEN], out float result[1]) { + `,d=new nt(s,{vs:f,defines:{INDEX_TYPE:a,TYPE:c,RESULT_LEN:e.size.toString(),SOURCE_VALUES_ROWS:r.length.toString()},modules:[vU(i,a),Fd(r,e.type,l),wU(e.type),o],bindings:{source_values_texture:u},bufferLayout:[xU(i)],vertexCount:1,instanceCount:e.length,feedbackBufferMode:"interleaved",outputs:o.varyings});try{return d.run({inputBuffers:{ids:i.buffer},outputBuffers:{[o.varyings[0]]:t}}),{success:!0}}finally{d.destroy(),u.destroy()}}});var SU,EC,SC=C(()=>{Dt();SU=`void row_dot(in TYPE x[X_LEN], in TYPE y[Y_LEN], out float result[1]) { float sum = 0.0; for (int i = 0; i < X_LEN; i++) { sum += float(x[i]) * float(y[i]); } result[0] = sum; } -`,EC=({inputs:n,output:e,target:t})=>(rt({module:{name:"row_dot",vs:xU},inputs:n,output:e,operationType:"float32",outputBuffer:t}),{success:!0})});var wU,PC,CC=C(()=>{Dt();wU=`void equalAll(in TYPE x[X_LEN], in TYPE y[Y_LEN], out uint result[1]) { +`,EC=({inputs:n,output:e,target:t})=>(rt({module:{name:"row_dot",vs:SU},inputs:n,output:e,operationType:"float32",outputBuffer:t}),{success:!0})});var PU,PC,CC=C(()=>{Dt();PU=`void equalAll(in TYPE x[X_LEN], in TYPE y[Y_LEN], out uint result[1]) { uint allEqual = uint(1); for (int i = 0; i < X_LEN; i++) { if (x[i] != y[i]) { @@ -2825,14 +2825,14 @@ void main() { } result[0] = allEqual; } -`,PC=({inputs:n,output:e,target:t})=>(rt({module:{name:"equalAll",vs:wU},inputs:n,output:e,operationType:e.type==="uint32"?n.x.type:e.type,outputBuffer:t}),{success:!0})});var EU,TC,LC=C(()=>{Dt();EU=`void row_length(in TYPE x[X_LEN], out float result[1]) { +`,PC=({inputs:n,output:e,target:t})=>(rt({module:{name:"equalAll",vs:PU},inputs:n,output:e,operationType:e.type==="uint32"?n.x.type:e.type,outputBuffer:t}),{success:!0})});var CU,TC,LC=C(()=>{Dt();CU=`void row_length(in TYPE x[X_LEN], out float result[1]) { float sum = 0.0; for (int i = 0; i < X_LEN; i++) { sum += float(x[i]) * float(x[i]); } result[0] = sqrt(sum); } -`,TC=({inputs:n,output:e,target:t})=>(rt({module:{name:"row_length",vs:EU},inputs:n,output:e,operationType:"float32",outputBuffer:t}),{success:!0})});function SU(){return{name:"segmentedMap",vs:` +`,TC=({inputs:n,output:e,target:t})=>(rt({module:{name:"row_length",vs:CU},inputs:n,output:e,operationType:"float32",outputBuffer:t}),{success:!0})});function TU(){return{name:"segmentedMap",vs:` uint read_segment_start(int segmentIndex) { TYPE value[1]; read_source_values(segmentIndex, value); @@ -2866,21 +2866,21 @@ void main() { segmentedMap(result); set_result(result); } -`,defines:{TYPE:"uint",RESULT_LEN:e.size.toString(),SEGMENTS_LENGTH:i.length.toString()},modules:[Fd(i,e.type,o),SU(),s],bindings:{source_values_texture:a},vertexCount:1,instanceCount:e.length,feedbackBufferMode:"interleaved",outputs:s.varyings});try{return c.run({outputBuffers:{[s.varyings[0]]:t}}),{success:!0}}finally{c.destroy(),a.destroy()}}});function Fy(n,e,t,i){return t{Dt();Ro();kC=async({inputs:n,output:e,target:t})=>{let i=it(e.type,1,e.normalized),r=ir(i);return rt({module:{name:"select",vs:""},inputs:n,output:e,operationType:e.type,outputBuffer:t,expression:s=>{let o=Fy("condition",n.condition,s,r),a=Fy("whenTrue",n.whenTrue,s,r),c=Fy("whenFalse",n.whenFalse,s,r);return`(${o} != ${r} ? ${a} : ${c})`}}),{success:!0}}});var IC,BC=C(()=>{Me();Dt();IC=({inputs:n,output:e,target:t})=>{let i=cs("result",e.type,e.size),r=new nt(t.device,{vs:`#version 300 es +`,defines:{TYPE:"uint",RESULT_LEN:e.size.toString(),SEGMENTS_LENGTH:i.length.toString()},modules:[Fd(i,e.type,o),TU(),s],bindings:{source_values_texture:a},vertexCount:1,instanceCount:e.length,feedbackBufferMode:"interleaved",outputs:s.varyings});try{return c.run({outputBuffers:{[s.varyings[0]]:t}}),{success:!0}}finally{c.destroy(),a.destroy()}}});function Fy(n,e,t,i){return t{Dt();Ro();kC=async({inputs:n,output:e,target:t})=>{let i=it(e.type,1,e.normalized),r=ir(i);return rt({module:{name:"select",vs:""},inputs:n,output:e,operationType:e.type,outputBuffer:t,expression:s=>{let o=Fy("condition",n.condition,s,r),a=Fy("whenTrue",n.whenTrue,s,r),c=Fy("whenFalse",n.whenFalse,s,r);return`(${o} != ${r} ? ${a} : ${c})`}}),{success:!0}}});var IC,BC=C(()=>{Me();Dt();IC=({inputs:n,output:e,target:t})=>{let i=cs("result",e.type,e.size),r=new nt(t.device,{vs:`#version 300 es void main() { int result[1]; result[0] = START + gl_InstanceID * STEP; set_result(result); } -`,defines:{START:n.start.toString(),STEP:n.step.toString()},modules:[i],vertexCount:1,instanceCount:e.length,feedbackBufferMode:"interleaved",outputs:i.varyings});try{return r.run({outputBuffers:{[i.varyings[0]]:t}}),{success:!0}}finally{r.destroy()}}});var OC,DC=C(()=>{Dt();OC=({inputs:n,output:e,target:t})=>{let{columns:i}=n;return rt({module:{name:"swizzle",vs:"// swizzle expression handled inline"},expression:r=>`x[${i[r]}]`,inputs:{x:n.x},output:e,outputBuffer:t}),{success:!0}}});var NC={};mi(NC,{arithmetic:()=>Nd,dot:()=>EC,equalAll:()=>PC,extent:()=>mC,fround:()=>bC,gather:()=>xC,interleave:()=>_C,length:()=>TC,segmentedMap:()=>MC,select:()=>kC,sequence:()=>IC,swizzle:()=>OC});var FC=C(()=>{Dy();gC();yC();vC();wC();SC();CC();LC();AC();RC();BC();DC()});function si(n,e){let t=PU(e),i=Math.max(1,Math.ceil(n)),r=Math.min(i,t),s=Math.min(Math.ceil(i/r),t),o=Math.ceil(i/r/s);if(o>t)throw new Error(`WebGPU dispatch requires ${i} workgroups, exceeding the 3D dispatch limit of ${t} per dimension`);return{x:r,y:s,z:o}}function zy(n,e="workgroupId"){return`((${e}.z * ${n.y}u + ${e}.y) * ${n.x}u + ${e}.x)`}function rr(n,e,t="workgroupId",i="localId"){return`(${zy(n,t)} * ${e}u + ${i}.x)`}function PU(n){return Number.isFinite(n)&&n>0?Math.floor(n):65535}var Io=C(()=>{});function sr(n,e){switch(n){case"u32":return`${e}u`;case"f32":return Number.isInteger(e)?`${e}.0`:`${e}`;default:return`${e}`}}function zC(n,e){switch(n){case"uint32":return sr("u32",Math.trunc(e));case"sint32":return`${Math.trunc(e)}`;case"float32":return sr("f32",e);default:throw new Error(`WebGPU operations only support 32-bit output types, got ${n}`)}}function or(n){switch(n){case"uint32":return"0u";case"sint32":return"0";case"float32":return"0.0";default:throw new Error(`WebGPU operations only support 32-bit output types, got ${n}`)}}function Se(n){switch(n){case"uint32":return"u32";case"sint32":return"i32";case"float32":return"f32";default:throw new Error(`WebGPU operations only support 32-bit storage types, got ${n}`)}}var ls=C(()=>{});function st({module:n,elementWise:e=!1,expression:t,inputs:i,output:r,operationType:s=r.type,outputBuffer:o}){if(!n.source)throw new Error(`WebGPU computation ${n.name} requires WGSL source`);let a=BU(i),c=a.map(([y,b])=>({name:y,input:b})),l=c.filter(({input:y})=>!y.isConstant).map((y,b)=>({...y,index:b})),u=Se(s),f=Se(r.type),d={TYPE:u,RESULT_LEN:r.size.toString()},h=si(Math.ceil(r.length/Uy),o.device.limits.maxComputeWorkgroupsPerDimension);for(let[y,b]of a)d[`${y.toUpperCase()}_LEN`]=b.size.toString();let p=` -${DU(n.source,d)} -${l.map(({name:y,input:b,index:x})=>MU(y,b,x)).join(` +`,defines:{START:n.start.toString(),STEP:n.step.toString()},modules:[i],vertexCount:1,instanceCount:e.length,feedbackBufferMode:"interleaved",outputs:i.varyings});try{return r.run({outputBuffers:{[i.varyings[0]]:t}}),{success:!0}}finally{r.destroy()}}});var OC,DC=C(()=>{Dt();OC=({inputs:n,output:e,target:t})=>{let{columns:i}=n;return rt({module:{name:"swizzle",vs:"// swizzle expression handled inline"},expression:r=>`x[${i[r]}]`,inputs:{x:n.x},output:e,outputBuffer:t}),{success:!0}}});var NC={};mi(NC,{arithmetic:()=>Nd,dot:()=>EC,equalAll:()=>PC,extent:()=>mC,fround:()=>bC,gather:()=>xC,interleave:()=>_C,length:()=>TC,segmentedMap:()=>MC,select:()=>kC,sequence:()=>IC,swizzle:()=>OC});var FC=C(()=>{Dy();gC();yC();vC();wC();SC();CC();LC();AC();RC();BC();DC()});function si(n,e){let t=LU(e),i=Math.max(1,Math.ceil(n)),r=Math.min(i,t),s=Math.min(Math.ceil(i/r),t),o=Math.ceil(i/r/s);if(o>t)throw new Error(`WebGPU dispatch requires ${i} workgroups, exceeding the 3D dispatch limit of ${t} per dimension`);return{x:r,y:s,z:o}}function zy(n,e="workgroupId"){return`((${e}.z * ${n.y}u + ${e}.y) * ${n.x}u + ${e}.x)`}function rr(n,e,t="workgroupId",i="localId"){return`(${zy(n,t)} * ${e}u + ${i}.x)`}function LU(n){return Number.isFinite(n)&&n>0?Math.floor(n):65535}var Io=C(()=>{});function sr(n,e){switch(n){case"u32":return`${e}u`;case"f32":return Number.isInteger(e)?`${e}.0`:`${e}`;default:return`${e}`}}function zC(n,e){switch(n){case"uint32":return sr("u32",Math.trunc(e));case"sint32":return`${Math.trunc(e)}`;case"float32":return sr("f32",e);default:throw new Error(`WebGPU operations only support 32-bit output types, got ${n}`)}}function or(n){switch(n){case"uint32":return"0u";case"sint32":return"0";case"float32":return"0.0";default:throw new Error(`WebGPU operations only support 32-bit output types, got ${n}`)}}function Se(n){switch(n){case"uint32":return"u32";case"sint32":return"i32";case"float32":return"f32";default:throw new Error(`WebGPU operations only support 32-bit storage types, got ${n}`)}}var ls=C(()=>{});function st({module:n,elementWise:e=!1,expression:t,inputs:i,output:r,operationType:s=r.type,outputBuffer:o}){if(!n.source)throw new Error(`WebGPU computation ${n.name} requires WGSL source`);let a=NU(i),c=a.map(([y,b])=>({name:y,input:b})),l=c.filter(({input:y})=>!y.isConstant).map((y,b)=>({...y,index:b})),u=Se(s),f=Se(r.type),d={TYPE:u,RESULT_LEN:r.size.toString()},h=si(Math.ceil(r.length/Uy),o.device.limits.maxComputeWorkgroupsPerDimension);for(let[y,b]of a)d[`${y.toUpperCase()}_LEN`]=b.size.toString();let p=` +${zU(n.source,d)} +${l.map(({name:y,input:b,index:x})=>RU(y,b,x)).join(` `)} -${c.map(({name:y,input:b})=>AU(y,b,s)).join(` +${c.map(({name:y,input:b})=>IU(y,b,s)).join(` `)} -${kU(r,l.length)} -${RU(r)} +${BU(r,l.length)} +${OU(r)} @compute @workgroup_size(${Uy}) fn main( @builtin(workgroup_id) workgroupId: vec3, @@ -2894,24 +2894,24 @@ ${RU(r)} ${c.map(({name:y})=>` let ${y} = read_${y}(rowIndex);`).join(` `)} var result: array<${f}, ${r.size}>; -${IU(n.name,a,r,e,t)} +${DU(n.name,a,r,e,t)} write_result(rowIndex, result); } -`,m=new Bt(o.device,{source:p,modules:n.dependencies,shaderAssembler:LU,shaderLayout:{bindings:[...l.map(({name:y},b)=>({name:y,type:"storage",group:0,location:b})),{name:"result",type:"storage",group:0,location:l.length}]}}),g=Object.fromEntries(l.map(({name:y,input:b})=>[y,b.buffer]));g.result=o,m.setBindings(g);let v=o.device.beginComputePass({});o.device.statsManager.getStats(CU).get(TU).incrementCount(),m.dispatch(v,h.x,h.y,h.z),v.end(),o.device.submit(),m.destroy()}function MU(n,e,t){if(e.isConstant)return"";let i=Se(e.type);return`@group(0) @binding(${t}) var ${n}: array<${i}>;`}function AU(n,e,t){let i=Se(t),r=e.type===t?"":i,s=e.stride/e.ValueType.BYTES_PER_ELEMENT,o=e.offset/e.ValueType.BYTES_PER_ELEMENT;return e.isConstant?`fn read_${n}(_rowIndex: u32) -> array<${i}, ${e.size}> { - return array<${i}, ${e.size}>(${OU(e,r)}); +`,m=new Bt(o.device,{source:p,modules:n.dependencies,shaderAssembler:kU,shaderLayout:{bindings:[...l.map(({name:y},b)=>({name:y,type:"storage",group:0,location:b})),{name:"result",type:"storage",group:0,location:l.length}]}}),g=Object.fromEntries(l.map(({name:y,input:b})=>[y,b.buffer]));g.result=o,m.setBindings(g);let v=o.device.beginComputePass({});o.device.statsManager.getStats(MU).get(AU).incrementCount(),m.dispatch(v,h.x,h.y,h.z),v.end(),o.device.submit(),m.destroy()}function RU(n,e,t){if(e.isConstant)return"";let i=Se(e.type);return`@group(0) @binding(${t}) var ${n}: array<${i}>;`}function IU(n,e,t){let i=Se(t),r=e.type===t?"":i,s=e.stride/e.ValueType.BYTES_PER_ELEMENT,o=e.offset/e.ValueType.BYTES_PER_ELEMENT;return e.isConstant?`fn read_${n}(_rowIndex: u32) -> array<${i}, ${e.size}> { + return array<${i}, ${e.size}>(${FU(e,r)}); }`:`fn read_${n}(rowIndex: u32) -> array<${i}, ${e.size}> { var value: array<${i}, ${e.size}>; let rowOffset = ${o}u + rowIndex * ${s}u; ${Array.from({length:e.size},(a,c)=>r?` value[${c}] = ${r}(${n}[rowOffset + ${c}u]);`:` value[${c}] = ${n}[rowOffset + ${c}u];`).join(` `)} return value; -}`}function kU(n,e){let t=Se(n.type);return`@group(0) @binding(${e}) var result: array<${t}>;`}function RU(n){let e=n.stride/n.ValueType.BYTES_PER_ELEMENT,t=n.offset/n.ValueType.BYTES_PER_ELEMENT;return`fn write_result(rowIndex: u32, value: array<${Se(n.type)}, ${n.size}>) { +}`}function BU(n,e){let t=Se(n.type);return`@group(0) @binding(${e}) var result: array<${t}>;`}function OU(n){let e=n.stride/n.ValueType.BYTES_PER_ELEMENT,t=n.offset/n.ValueType.BYTES_PER_ELEMENT;return`fn write_result(rowIndex: u32, value: array<${Se(n.type)}, ${n.size}>) { let rowOffset = ${t}u + rowIndex * ${e}u; ${Array.from({length:n.size},(r,s)=>` result[rowOffset + ${s}u] = value[${s}];`).join(` `)} -}`}function IU(n,e,t,i,r){let s="";if(r)for(let o=0;oco).join(", ")});`;return s.trimEnd()}function BU(n){return Array.isArray(n)?n.map((e,t)=>[`x${t}`,e]):Object.entries(n)}function OU(n,e){let t=n.value;if(!t)throw new Error(`Constant input ${n} is missing CPU values`);return Array.from({length:n.size},(i,r)=>sr(e,t[r]??0)).join(", ")}function DU(n,e){for(let t in e)n=n.replaceAll(`{${t}}`,e[t]);return n}var Uy,CU,TU,LU,Ai=C(()=>{Me();vt();Io();ls();Uy=64,CU="GPGPU Operation Counts",TU="Computation Runs",LU=new qi});var NU,UC,$C=C(()=>{vt();Iy();Bd();Ai();ls();NU=`fn arithmetic_add(x: {TYPE}, y: {TYPE}) -> {TYPE} { +`}}else s+=`result = ${n}(${e.map(([o])=>o).join(", ")});`;return s.trimEnd()}function NU(n){return Array.isArray(n)?n.map((e,t)=>[`x${t}`,e]):Object.entries(n)}function FU(n,e){let t=n.value;if(!t)throw new Error(`Constant input ${n} is missing CPU values`);return Array.from({length:n.size},(i,r)=>sr(e,t[r]??0)).join(", ")}function zU(n,e){for(let t in e)n=n.replaceAll(`{${t}}`,e[t]);return n}var Uy,MU,AU,kU,Ai=C(()=>{Me();vt();Io();ls();Uy=64,MU="GPGPU Operation Counts",AU="Computation Runs",kU=new qi});var UU,UC,$C=C(()=>{vt();Iy();Bd();Ai();ls();UU=`fn arithmetic_add(x: {TYPE}, y: {TYPE}) -> {TYPE} { return x + y; } @@ -2930,14 +2930,14 @@ fn arithmetic_divide(x: {TYPE}, y: {TYPE}) -> {TYPE} { fn arithmetic_tan(x: f32) -> f32 { return tan_fp32(x); } -`,UC=({inputs:n,output:e,target:t})=>{let i=e.type,r=Se(i),s=or(i),o=n.namedInputs;return st({module:{name:"arithmetic",source:NU,dependencies:[Vr]},inputs:o,output:e,operationType:i,outputBuffer:t,expression:a=>Od(n.expression,{operations:Ao,inputs:o,laneIndex:a,formatInput:c=>`${c}[${a}]`,formatOutOfBoundsInput:c=>o[c].size===1?`${c}[0]`:s,formatLiteral:c=>{let l=Array.isArray(c)?c[a]??0:c;return`${r}(${zC(i,l)})`},formatCall:(c,l)=>`${c}(${l.join(", ")})`})}),{success:!0}}});var FU,GC,VC=C(()=>{Ai();FU=`fn row_dot(x: array<{TYPE}, {X_LEN}>, y: array<{TYPE}, {Y_LEN}>) -> array { +`,UC=({inputs:n,output:e,target:t})=>{let i=e.type,r=Se(i),s=or(i),o=n.namedInputs;return st({module:{name:"arithmetic",source:UU,dependencies:[Vr]},inputs:o,output:e,operationType:i,outputBuffer:t,expression:a=>Od(n.expression,{operations:Ao,inputs:o,laneIndex:a,formatInput:c=>`${c}[${a}]`,formatOutOfBoundsInput:c=>o[c].size===1?`${c}[0]`:s,formatLiteral:c=>{let l=Array.isArray(c)?c[a]??0:c;return`${r}(${zC(i,l)})`},formatCall:(c,l)=>`${c}(${l.join(", ")})`})}),{success:!0}}});var $U,GC,VC=C(()=>{Ai();$U=`fn row_dot(x: array<{TYPE}, {X_LEN}>, y: array<{TYPE}, {Y_LEN}>) -> array { var sum = 0.0; for (var i = 0u; i < {X_LEN}u; i = i + 1u) { sum += f32(x[i]) * f32(y[i]); } return array(sum); } -`,GC=({inputs:n,output:e,target:t})=>(st({module:{name:"row_dot",source:FU},inputs:n,output:e,operationType:"float32",outputBuffer:t}),{success:!0})});var zU,WC,jC=C(()=>{Ai();zU=`fn equalAll(x: array<{TYPE}, {X_LEN}>, y: array<{TYPE}, {Y_LEN}>) -> array { +`,GC=({inputs:n,output:e,target:t})=>(st({module:{name:"row_dot",source:$U},inputs:n,output:e,operationType:"float32",outputBuffer:t}),{success:!0})});var GU,WC,jC=C(()=>{Ai();GU=`fn equalAll(x: array<{TYPE}, {X_LEN}>, y: array<{TYPE}, {Y_LEN}>) -> array { var allEqual = 1u; for (var i = 0u; i < {X_LEN}u; i = i + 1u) { if (x[i] != y[i]) { @@ -2947,7 +2947,7 @@ fn arithmetic_tan(x: f32) -> f32 { } return array(allEqual); } -`,WC=({inputs:n,output:e,target:t})=>(st({module:{name:"equalAll",source:zU},inputs:n,output:e,operationType:n.x.type,outputBuffer:t}),{success:!0})});function Bo(n,e,t){let i=Se(e.type);return`@group(0) @binding(${t}) var ${n}: array<${i}>;`}function $y(n,e,t,i=n){let r=Se(t);if(e.isConstant){let l=e.value;if(!l)throw new Error(`Constant input ${e} is missing CPU values`);return`fn read_${i}(_sourceIndex: u32) -> array<${r}, ${e.size}> { +`,WC=({inputs:n,output:e,target:t})=>(st({module:{name:"equalAll",source:GU},inputs:n,output:e,operationType:n.x.type,outputBuffer:t}),{success:!0})});function Bo(n,e,t){let i=Se(e.type);return`@group(0) @binding(${t}) var ${n}: array<${i}>;`}function $y(n,e,t,i=n){let r=Se(t);if(e.isConstant){let l=e.value;if(!l)throw new Error(`Constant input ${e} is missing CPU values`);return`fn read_${i}(_sourceIndex: u32) -> array<${r}, ${e.size}> { return array<${r}, ${e.size}>(${Array.from({length:e.size},(u,f)=>sr(r,l[f]??0)).join(", ")}); }`}let s=e.stride/e.ValueType.BYTES_PER_ELEMENT,o=e.offset/e.ValueType.BYTES_PER_ELEMENT,c=Se(e.type)===r?"":`${r}`;return`fn read_${i}(sourceIndex: u32) -> array<${r}, ${e.size}> { var value: array<${r}, ${e.size}>; @@ -2964,12 +2964,12 @@ ${Array.from({length:n.size},(r,s)=>` result[rowOffset + ${s}u] = value[${s}];` ${Array.from({length:e},(i,r)=>` result[${r}] = ${t};`).join(` `)} return result; -}`}var mt,$d=C(()=>{ls();mt=64});function UU({input:n,inputMode:e,inputGroupCount:t,channelCount:i,outputType:r,outputBuffer:s,outputLength:o,outputStride:a,outputOffset:c}){let l=Se(r),u=si(o,s.device.limits.maxComputeWorkgroupsPerDimension),f=new ve({buffer:s,type:r,size:2,length:o,stride:a,offset:c}),d=` +}`}var mt,$d=C(()=>{ls();mt=64});function VU({input:n,inputMode:e,inputGroupCount:t,channelCount:i,outputType:r,outputBuffer:s,outputLength:o,outputStride:a,outputOffset:c}){let l=Se(r),u=si(o,s.device.limits.maxComputeWorkgroupsPerDimension),f=new ve({buffer:s,type:r,size:2,length:o,stride:a,offset:c}),d=` ${n.isConstant?"":Bo("sourceValues",n,0)} ${Ud(n,r)} ${Oo(f,n.isConstant?0:1)} ${Do(f)} -${$U(e,r,i,t)} +${WU(e,r,i,t)} var sharedMin: array<${l}, ${mt}>; var sharedMax: array<${l}, ${mt}>; @@ -3014,7 +3014,7 @@ var sharedMax: array<${l}, ${mt}>; write_result(outputRowIndex, array<${l}, 2>(sharedMin[0], sharedMax[0])); } } -`,h=new Bt(s.device,{source:d,shaderLayout:{bindings:[...n.isConstant?[]:[{name:"sourceValues",type:"storage",group:0,location:0}],{name:"result",type:"storage",group:0,location:n.isConstant?0:1}]}}),p={result:s};n.isConstant||(p.sourceValues=n.buffer),h.setBindings(p);let m=s.device.beginComputePass({});h.dispatch(m,u.x,u.y,u.z),m.end(),s.device.submit(),h.destroy()}function $U(n,e,t,i){let r=Se(e),[s,o]=GU(e);return n==="raw"?`fn extent_pass(channelIndex: u32, inputGroupIndex: u32) -> array<${r}, 2> { +`,h=new Bt(s.device,{source:d,shaderLayout:{bindings:[...n.isConstant?[]:[{name:"sourceValues",type:"storage",group:0,location:0}],{name:"result",type:"storage",group:0,location:n.isConstant?0:1}]}}),p={result:s};n.isConstant||(p.sourceValues=n.buffer),h.setBindings(p);let m=s.device.beginComputePass({});h.dispatch(m,u.x,u.y,u.z),m.end(),s.device.submit(),h.destroy()}function WU(n,e,t,i){let r=Se(e),[s,o]=jU(e);return n==="raw"?`fn extent_pass(channelIndex: u32, inputGroupIndex: u32) -> array<${r}, 2> { var result: array<${r}, 2>; result[0] = ${s}; result[1] = ${o}; @@ -3039,7 +3039,7 @@ var sharedMax: array<${l}, ${mt}>; } return result; -}`}function GU(n){switch(n){case"uint32":return["0xffffffffu","0u"];case"sint32":return["2147483647","-2147483648"];case"float32":return["3.402823e38","-3.402823e38"];default:throw new Error(`Unsupported WebGPU extent type for ${n}`)}}var YC,qC=C(()=>{Me();Mi();Zc();Io();ls();$d();YC=({inputs:n,output:e,target:t})=>{let{sourceValues:i}=n;if(i.length===0){let c=new e.ValueType(e.length*e.size);return t.write(c),{success:!0,value:c}}if(i.isConstant){let c=i.value;if(!c)throw new Error(`Constant input ${i} is missing CPU values`);let l=new e.ValueType(e.length*e.size);for(let u=0;u1&&r.push(u),UU({input:s,inputMode:o,inputGroupCount:a,channelCount:e.length,outputType:e.type,outputBuffer:u,outputLength:l,outputStride:e.stride,outputOffset:e.offset}),c===1)break;s=new ve({buffer:u,type:e.type,size:2,length:l}),o="partial",a=c}return{success:!0}}finally{for(let c of r)pt.recycle(c)}}});function VU(){let n=new Uint16Array([255]);return new Uint8Array(n.buffer)[0]>0}var WU,ZC,XC=C(()=>{Ai();WU=`const LE: bool = ${VU()?"true":"false"}; +}`}function jU(n){switch(n){case"uint32":return["0xffffffffu","0u"];case"sint32":return["2147483647","-2147483648"];case"float32":return["3.402823e38","-3.402823e38"];default:throw new Error(`Unsupported WebGPU extent type for ${n}`)}}var YC,qC=C(()=>{Me();Mi();Zc();Io();ls();$d();YC=({inputs:n,output:e,target:t})=>{let{sourceValues:i}=n;if(i.length===0){let c=new e.ValueType(e.length*e.size);return t.write(c),{success:!0,value:c}}if(i.isConstant){let c=i.value;if(!c)throw new Error(`Constant input ${i} is missing CPU values`);let l=new e.ValueType(e.length*e.size);for(let u=0;u1&&r.push(u),VU({input:s,inputMode:o,inputGroupCount:a,channelCount:e.length,outputType:e.type,outputBuffer:u,outputLength:l,outputStride:e.stride,outputOffset:e.offset}),c===1)break;s=new ve({buffer:u,type:e.type,size:2,length:l}),o="partial",a=c}return{success:!0}}finally{for(let c of r)pt.recycle(c)}}});function HU(){let n=new Uint16Array([255]);return new Uint8Array(n.buffer)[0]>0}var YU,ZC,XC=C(()=>{Ai();YU=`const LE: bool = ${HU()?"true":"false"}; const F32_NAN: u32 = 0xffffffffu; const F32_INF: u32 = 0x7f800000u; @@ -3178,12 +3178,12 @@ fn fround(x: array) -> array { } return result; } -`,ZC=({inputs:n,output:e,target:t})=>(st({module:{name:"fround",source:WU},inputs:n,output:e,operationType:"uint32",outputBuffer:t}),{success:!0})});function jU(n,e){if(n.isConstant){let r=n.value;if(!r)throw new Error(`Constant input ${n} is missing CPU values`);return`fn read_ids(_rowIndex: u32) -> ${e} { +`,ZC=({inputs:n,output:e,target:t})=>(st({module:{name:"fround",source:YU},inputs:n,output:e,operationType:"uint32",outputBuffer:t}),{success:!0})});function qU(n,e){if(n.isConstant){let r=n.value;if(!r)throw new Error(`Constant input ${n} is missing CPU values`);return`fn read_ids(_rowIndex: u32) -> ${e} { return ${sr(e,r[0]??0)}; }`}let t=n.stride/n.ValueType.BYTES_PER_ELEMENT,i=n.offset/n.ValueType.BYTES_PER_ELEMENT;return`fn read_ids(rowIndex: u32) -> ${e} { let rowOffset = ${i}u + rowIndex * ${t}u; return ids[rowOffset]; -}`}function HU(n,e,t,i){let r=Se(n),s=Se(e);return`fn gather(idsValue: ${r}) -> array<${s}, ${t}> { +}`}function ZU(n,e,t,i){let r=Se(n),s=Se(e);return`fn gather(idsValue: ${r}) -> array<${s}, ${t}> { let sourceIndex = ${r==="u32"?"i32(idsValue)":r==="i32"?"idsValue":"i32(idsValue)"}; if (sourceIndex < 0 || sourceIndex >= ${i}) { return zero_result(); @@ -3192,12 +3192,12 @@ fn fround(x: array) -> array { }`}var KC,QC=C(()=>{Me();Io();ls();$d();KC=async({inputs:n,output:e,target:t})=>{let{ids:i,sourceValues:r}=n,s=Se(i.type),o=[];i.isConstant||o.push({name:"ids",input:i,index:o.length}),r.isConstant||o.push({name:"sourceValues",input:r,index:o.length});let a=si(Math.ceil(e.length/mt),t.device.limits.maxComputeWorkgroupsPerDimension),c=` ${o.map(({name:d,input:h,index:p})=>Bo(d,h,p)).join(` `)} -${jU(i,s)} +${qU(i,s)} ${Ud(r,e.type)} ${Oo(e,o.length)} ${Do(e)} ${HC(e.type,e.size)} -${HU(i.type,e.type,e.size,r.length)} +${ZU(i.type,e.type,e.size,r.length)} @compute @workgroup_size(${mt}) fn main( @builtin(workgroup_id) workgroupId: vec3, @@ -3212,7 +3212,7 @@ ${HU(i.type,e.type,e.size,r.length)} let result = gather(idsValue); write_result(rowIndex, result); } -`,l=new Bt(t.device,{source:c,shaderLayout:{bindings:[...o.map(({name:d,index:h})=>({name:d,type:"storage",group:0,location:h})),{name:"result",type:"storage",group:0,location:o.length}]}}),u={};i.isConstant||(u.ids=i.buffer),r.isConstant||(u.sourceValues=r.buffer),u.result=t,l.setBindings(u);let f=t.device.beginComputePass({});return l.dispatch(f,a.x,a.y,a.z),f.end(),t.device.submit(),l.destroy(),{success:!0}}});function YU(n){return`fn segmented_map(vertexIndex: u32) -> array { +`,l=new Bt(t.device,{source:c,shaderLayout:{bindings:[...o.map(({name:d,index:h})=>({name:d,type:"storage",group:0,location:h})),{name:"result",type:"storage",group:0,location:o.length}]}}),u={};i.isConstant||(u.ids=i.buffer),r.isConstant||(u.sourceValues=r.buffer),u.result=t,l.setBindings(u);let f=t.device.beginComputePass({});return l.dispatch(f,a.x,a.y,a.z),f.end(),t.device.submit(),l.destroy(),{success:!0}}});function XU(n){return`fn segmented_map(vertexIndex: u32) -> array { var low = 0i; var high = ${n}i; while (low < high) { @@ -3234,7 +3234,7 @@ ${r.map(({name:u,input:f,index:d})=>Bo(u,f,d)).join(` ${$y("segments",i,"uint32")} ${Oo(e,r.length)} ${Do(e)} -${YU(i.length)} +${XU(i.length)} @compute @workgroup_size(${mt}) fn main( @builtin(workgroup_id) workgroupId: vec3, @@ -3248,21 +3248,21 @@ ${YU(i.length)} let result = segmented_map(rowIndex); write_result(rowIndex, result); } -`,a=new Bt(t.device,{source:o,shaderLayout:{bindings:[...r.map(({name:u,index:f})=>({name:u,type:"storage",group:0,location:f})),{name:"result",type:"storage",group:0,location:r.length}]}}),c=Object.fromEntries(r.map(({name:u,input:f})=>[u,f.buffer]));c.result=t,a.setBindings(c);let l=t.device.beginComputePass({});return a.dispatch(l,s.x,s.y,s.z),l.end(),t.device.submit(),a.destroy(),{success:!0}}});function qU(n,e){let i=e.filter(([,r])=>!r.isConstant).length+1;if(i>n.maxStorageBuffersPerShaderStage)throw new Error(`interleave() requires ${i} storage buffers, exceeding device limit ${n.maxStorageBuffersPerShaderStage}`);if(i>n.maxBindingsPerBindGroup)throw new Error(`interleave() requires ${i} bindings, exceeding bind group limit ${n.maxBindingsPerBindGroup}`)}var Gd,tT=C(()=>{Ai();Gd=({inputs:n,output:e,target:t})=>{let i=n.map((c,l)=>[`x${l}`,c]);qU(t.device.limits,i);let r=i.map(([c,l])=>`${c}: array<{TYPE}, ${l.size}>`).join(", "),s=0,o=i.map(([c,l])=>{let u=Array.from({length:l.size},(f,d)=>` out[${s+d}] = ${c}[${d}];`).join(` +`,a=new Bt(t.device,{source:o,shaderLayout:{bindings:[...r.map(({name:u,index:f})=>({name:u,type:"storage",group:0,location:f})),{name:"result",type:"storage",group:0,location:r.length}]}}),c=Object.fromEntries(r.map(({name:u,input:f})=>[u,f.buffer]));c.result=t,a.setBindings(c);let l=t.device.beginComputePass({});return a.dispatch(l,s.x,s.y,s.z),l.end(),t.device.submit(),a.destroy(),{success:!0}}});function KU(n,e){let i=e.filter(([,r])=>!r.isConstant).length+1;if(i>n.maxStorageBuffersPerShaderStage)throw new Error(`interleave() requires ${i} storage buffers, exceeding device limit ${n.maxStorageBuffersPerShaderStage}`);if(i>n.maxBindingsPerBindGroup)throw new Error(`interleave() requires ${i} bindings, exceeding bind group limit ${n.maxBindingsPerBindGroup}`)}var Gd,tT=C(()=>{Ai();Gd=({inputs:n,output:e,target:t})=>{let i=n.map((c,l)=>[`x${l}`,c]);KU(t.device.limits,i);let r=i.map(([c,l])=>`${c}: array<{TYPE}, ${l.size}>`).join(", "),s=0,o=i.map(([c,l])=>{let u=Array.from({length:l.size},(f,d)=>` out[${s+d}] = ${c}[${d}];`).join(` `);return s+=l.size,u}).join(` `),a=`fn interleave(${r}) -> array<{TYPE}, {RESULT_LEN}> { var out: array<{TYPE}, {RESULT_LEN}>; ${o} return out; } -`;return st({module:{name:"interleave",source:a},inputs:n,output:e,outputBuffer:t}),{success:!0}}});var ZU,nT,iT=C(()=>{Ai();ZU=`fn row_length(x: array<{TYPE}, {X_LEN}>) -> array { +`;return st({module:{name:"interleave",source:a},inputs:n,output:e,outputBuffer:t}),{success:!0}}});var QU,nT,iT=C(()=>{Ai();QU=`fn row_length(x: array<{TYPE}, {X_LEN}>) -> array { var sum = 0.0; for (var i = 0u; i < {X_LEN}u; i = i + 1u) { sum += f32(x[i]) * f32(x[i]); } return array(sqrt(sum)); } -`,nT=({inputs:n,output:e,target:t})=>(st({module:{name:"row_length",source:ZU},inputs:n,output:e,operationType:"float32",outputBuffer:t}),{success:!0})});function Gy(n,e,t,i){return t{Ai();ls();rT=async({inputs:n,output:e,target:t})=>{let i=or(e.type);return st({module:{name:"select",source:`// inline expression select +`,nT=({inputs:n,output:e,target:t})=>(st({module:{name:"row_length",source:QU},inputs:n,output:e,operationType:"float32",outputBuffer:t}),{success:!0})});function Gy(n,e,t,i){return t{Ai();ls();rT=async({inputs:n,output:e,target:t})=>{let i=or(e.type);return st({module:{name:"select",source:`// inline expression select `},inputs:n,output:e,operationType:e.type,outputBuffer:t,expression:r=>{let s=Gy("condition",n.condition,r,i),o=Gy("whenTrue",n.whenTrue,r,i);return`select(${Gy("whenFalse",n.whenFalse,r,i)}, ${o}, ${s} != ${i})`}}),{success:!0}}});var Vy,oT,aT=C(()=>{Me();Io();Vy=64,oT=({inputs:n,output:e,target:t})=>{let i=si(Math.ceil(e.length/Vy),t.device.limits.maxComputeWorkgroupsPerDimension),r=`@group(0) @binding(0) var result: array; @compute @workgroup_size(${Vy}) fn main( @@ -3277,12 +3277,12 @@ ${o} let rowOffset = ${e.offset/e.ValueType.BYTES_PER_ELEMENT}u + rowIndex * ${e.stride/e.ValueType.BYTES_PER_ELEMENT}u; result[rowOffset] = ${n.start} + i32(rowIndex) * ${n.step}; } -`,s=new Bt(t.device,{source:r,shaderLayout:{bindings:[{name:"result",type:"storage",group:0,location:0}]}});s.setBindings({result:t});let o=t.device.beginComputePass({});return s.dispatch(o,i.x,i.y,i.z),o.end(),t.device.submit(),s.destroy(),{success:!0}}});var cT,lT=C(()=>{Ai();cT=({inputs:n,output:e,target:t})=>{let{columns:i}=n;return st({module:{name:"swizzle",source:"// swizzle expression handled inline"},expression:r=>`x[${i[r]}]`,inputs:{x:n.x},output:e,outputBuffer:t}),{success:!0}}});var uT={};mi(uT,{arithmetic:()=>UC,dot:()=>GC,equalAll:()=>WC,extent:()=>YC,fround:()=>ZC,gather:()=>KC,interleave:()=>Gd,length:()=>nT,segmentedMap:()=>JC,select:()=>rT,sequence:()=>oT,swizzle:()=>cT});var Wy=C(()=>{$C();VC();jC();qC();XC();QC();eT();tT();iT();sT();aT();lT()});var yL=eA((sye,vb)=>{"use strict";vb.exports=oh;vb.exports.default=oh;function oh(n,e,t){t=t||2;var i=e&&e.length,r=i?e[0]*t:n.length,s=mL(n,0,r,t,!0),o=[];if(!s||s.next===s.prev)return o;var a,c,l,u,f,d,h;if(i&&(s=NG(n,e,s,t)),n.length>80*t){a=l=n[0],c=u=n[1];for(var p=t;pl&&(l=f),d>u&&(u=d);h=Math.max(l-a,u-c),h=h!==0?32767/h:0}return Sl(s,o,t,a,c,h,0),o}function mL(n,e,t,i,r){var s,o;if(r===bb(n,e,t,i)>0)for(s=e;s=e;s-=i)o=pL(s,n[s],n[s+1],o);return o&&ah(o,o.next)&&(Cl(o),o=o.next),o}function fs(n,e){if(!n)return n;e||(e=n);var t=n,i;do if(i=!1,!t.steiner&&(ah(t,t.next)||Ae(t.prev,t,t.next)===0)){if(Cl(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Sl(n,e,t,i,r,s,o){if(n){!o&&s&&GG(n,i,r,s);for(var a=n,c,l;n.prev!==n.next;){if(c=n.prev,l=n.next,s?BG(n,i,r,s):IG(n)){e.push(c.i/t|0),e.push(n.i/t|0),e.push(l.i/t|0),Cl(n),n=l.next,a=l.next;continue}if(n=l,n===a){o?o===1?(n=OG(fs(n),e,t),Sl(n,e,t,i,r,s,2)):o===2&&DG(n,e,t,i,r,s):Sl(fs(n),e,t,i,r,s,1);break}}}}function IG(n){var e=n.prev,t=n,i=n.next;if(Ae(e,t,i)>=0)return!1;for(var r=e.x,s=t.x,o=i.x,a=e.y,c=t.y,l=i.y,u=rs?r>o?r:o:s>o?s:o,h=a>c?a>l?a:l:c>l?c:l,p=i.next;p!==e;){if(p.x>=u&&p.x<=d&&p.y>=f&&p.y<=h&&Uo(r,a,s,c,o,l,p.x,p.y)&&Ae(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function BG(n,e,t,i){var r=n.prev,s=n,o=n.next;if(Ae(r,s,o)>=0)return!1;for(var a=r.x,c=s.x,l=o.x,u=r.y,f=s.y,d=o.y,h=ac?a>l?a:l:c>l?c:l,g=u>f?u>d?u:d:f>d?f:d,v=_b(h,p,e,t,i),y=_b(m,g,e,t,i),b=n.prevZ,x=n.nextZ;b&&b.z>=v&&x&&x.z<=y;){if(b.x>=h&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==o&&Uo(a,u,c,f,l,d,b.x,b.y)&&Ae(b.prev,b,b.next)>=0||(b=b.prevZ,x.x>=h&&x.x<=m&&x.y>=p&&x.y<=g&&x!==r&&x!==o&&Uo(a,u,c,f,l,d,x.x,x.y)&&Ae(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;b&&b.z>=v;){if(b.x>=h&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==o&&Uo(a,u,c,f,l,d,b.x,b.y)&&Ae(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;x&&x.z<=y;){if(x.x>=h&&x.x<=m&&x.y>=p&&x.y<=g&&x!==r&&x!==o&&Uo(a,u,c,f,l,d,x.x,x.y)&&Ae(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function OG(n,e,t){var i=n;do{var r=i.prev,s=i.next.next;!ah(r,s)&&gL(r,i,i.next,s)&&Pl(r,s)&&Pl(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),Cl(i),Cl(i.next),i=n=s),i=i.next}while(i!==n);return fs(i)}function DG(n,e,t,i,r,s){var o=n;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&jG(o,a)){var c=_L(o,a);o=fs(o,o.next),c=fs(c,c.next),Sl(o,e,t,i,r,s,0),Sl(c,e,t,i,r,s,0);return}a=a.next}o=o.next}while(o!==n)}function NG(n,e,t,i){var r=[],s,o,a,c,l;for(s=0,o=e.length;s=t.next.y&&t.next.y!==t.y){var a=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(a<=i&&a>s&&(s=a,o=t.x=t.x&&t.x>=l&&i!==t.x&&Uo(ro.x||t.x===o.x&&$G(o,t)))&&(o=t,f=d)),t=t.next;while(t!==c);return o}function $G(n,e){return Ae(n.prev,n,e.prev)<0&&Ae(e.next,n,n.next)<0}function GG(n,e,t,i){var r=n;do r.z===0&&(r.z=_b(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,VG(r)}function VG(n){var e,t,i,r,s,o,a,c,l=1;do{for(t=n,n=null,s=null,o=0;t;){for(o++,i=t,a=0,e=0;e0||c>0&&i;)a!==0&&(c===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,a--):(r=i,i=i.nextZ,c--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,l*=2}while(o>1);return n}function _b(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function WG(n){var e=n,t=n;do(e.x=(n-o)*(s-a)&&(n-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(i-a)}function jG(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!HG(n,e)&&(Pl(n,e)&&Pl(e,n)&&YG(n,e)&&(Ae(n.prev,n,e.prev)||Ae(n,e.prev,e))||ah(n,e)&&Ae(n.prev,n,n.next)>0&&Ae(e.prev,e,e.next)>0)}function Ae(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function ah(n,e){return n.x===e.x&&n.y===e.y}function gL(n,e,t,i){var r=sh(Ae(n,e,t)),s=sh(Ae(n,e,i)),o=sh(Ae(t,i,n)),a=sh(Ae(t,i,e));return!!(r!==s&&o!==a||r===0&&rh(n,t,e)||s===0&&rh(n,i,e)||o===0&&rh(t,n,i)||a===0&&rh(t,e,i))}function rh(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function sh(n){return n>0?1:n<0?-1:0}function HG(n,e){var t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&gL(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Pl(n,e){return Ae(n.prev,n,n.next)<0?Ae(n,e,n.next)>=0&&Ae(n,n.prev,e)>=0:Ae(n,e,n.prev)<0||Ae(n,n.next,e)<0}function YG(n,e){var t=n,i=!1,r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function _L(n,e){var t=new yb(n.i,n.x,n.y),i=new yb(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function pL(n,e,t,i){var r=new yb(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Cl(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function yb(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}oh.deviation=function(n,e,t,i){var r=e&&e.length,s=r?e[0]*t:n.length,o=Math.abs(bb(n,0,s,t));if(r)for(var a=0,c=e.length;a0&&(i+=n[r-1].length,t.holes.push(i))}return t}});function Fi(n,e){if(!n)throw new Error(e||"loader assertion failed.")}var In={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},iA=In.self||In.window||In.global||{},rA=In.window||In.self||In.global||{},sA=In.global||In.self||In.window||{},oA=In.document||{};var br=!!(typeof process!="object"||String(process)!=="[object process]"||process.browser);var yv=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),aA=yv&&parseFloat(yv[1])||0;sa();var wp="4.5.4",mA=wp[0]>="0"&&wp[0]<="9"?`v${wp}`:"";function gA(){let n=new ct({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=n,globalThis.loaders.version=mA,globalThis.probe||={},globalThis.probe.loaders=n,n}var Ep=gA();var _A=n=>typeof n=="boolean",On=n=>typeof n=="function",Dn=n=>n!==null&&typeof n=="object",iu=n=>Dn(n)&&n.constructor==={}.constructor;var Sp=n=>typeof SharedArrayBuffer<"u"&&n instanceof SharedArrayBuffer,Os=n=>Dn(n)&&typeof n.byteLength=="number"&&typeof n.slice=="function";var Pp=n=>!!n&&On(n[Symbol.iterator]),Cp=n=>!!n&&On(n[Symbol.asyncIterator]);var Lt=n=>typeof Response<"u"&&n instanceof Response||Dn(n)&&On(n.arrayBuffer)&&On(n.text)&&On(n.json);var Mt=n=>typeof Blob<"u"&&n instanceof Blob;var Bv=n=>typeof ReadableStream<"u"&&n instanceof ReadableStream||Dn(n)&&On(n.tee)&&On(n.cancel)&&On(n.getReader);var Ov=n=>Dn(n)&&On(n.read)&&On(n.pipe)&&_A(n.readable),oa=n=>Bv(n)||Ov(n);function Tp(n,e){return Dv(n||{},e)}function Dv(n,e,t=0){if(t>3)return e;let i={...n};for(let[r,s]of Object.entries(e))s&&typeof s=="object"&&!Array.isArray(s)?i[r]=Dv(i[r]||{},e[r],t+1):i[r]=e[r];return i}var Nv="latest";function yA(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.5.4"),globalThis._loadersgl_.version}var Fv=yA();function lt(n,e){if(!n)throw new Error(e||"loaders.gl assertion failed.")}var Nn={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},qj=Nn.self||Nn.window||Nn.global||{},Zj=Nn.window||Nn.self||Nn.global||{},Xj=Nn.global||Nn.self||Nn.window||{},Kj=Nn.document||{};var Ht=typeof process!="object"||String(process)!=="[object process]"||process.browser;var Uv=typeof window<"u"&&typeof window.orientation<"u",zv=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),Qj=zv&&parseFloat(zv[1])||0;var aa=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,t){this.name=e,this.workerThread=t,this.result=new Promise((i,r)=>{this._resolve=i,this._reject=r})}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){lt(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){lt(this.isRunning),this.isRunning=!1,this._reject(e)}};var Ds=class{terminate(){}};var Lp=new Map;function $v(n){lt(n.source&&!n.url||!n.source&&n.url);let e=Lp.get(n.source||n.url);return e||(n.url&&(e=bA(n.url),Lp.set(n.url,e)),n.source&&(e=Gv(n.source),Lp.set(n.source,e))),lt(e),e}function bA(n){if(!n.startsWith("http"))return n;let e=vA(n);return Gv(e)}function Gv(n){let e=new Blob([n],{type:"application/javascript"});return URL.createObjectURL(e)}function vA(n){return`try { +`,s=new Bt(t.device,{source:r,shaderLayout:{bindings:[{name:"result",type:"storage",group:0,location:0}]}});s.setBindings({result:t});let o=t.device.beginComputePass({});return s.dispatch(o,i.x,i.y,i.z),o.end(),t.device.submit(),s.destroy(),{success:!0}}});var cT,lT=C(()=>{Ai();cT=({inputs:n,output:e,target:t})=>{let{columns:i}=n;return st({module:{name:"swizzle",source:"// swizzle expression handled inline"},expression:r=>`x[${i[r]}]`,inputs:{x:n.x},output:e,outputBuffer:t}),{success:!0}}});var uT={};mi(uT,{arithmetic:()=>UC,dot:()=>GC,equalAll:()=>WC,extent:()=>YC,fround:()=>ZC,gather:()=>KC,interleave:()=>Gd,length:()=>nT,segmentedMap:()=>JC,select:()=>rT,sequence:()=>oT,swizzle:()=>cT});var Wy=C(()=>{$C();VC();jC();qC();XC();QC();eT();tT();iT();sT();aT();lT()});var yL=iA((lye,vb)=>{"use strict";vb.exports=oh;vb.exports.default=oh;function oh(n,e,t){t=t||2;var i=e&&e.length,r=i?e[0]*t:n.length,s=mL(n,0,r,t,!0),o=[];if(!s||s.next===s.prev)return o;var a,c,l,u,f,d,h;if(i&&(s=UG(n,e,s,t)),n.length>80*t){a=l=n[0],c=u=n[1];for(var p=t;pl&&(l=f),d>u&&(u=d);h=Math.max(l-a,u-c),h=h!==0?32767/h:0}return Sl(s,o,t,a,c,h,0),o}function mL(n,e,t,i,r){var s,o;if(r===bb(n,e,t,i)>0)for(s=e;s=e;s-=i)o=pL(s,n[s],n[s+1],o);return o&&ah(o,o.next)&&(Cl(o),o=o.next),o}function fs(n,e){if(!n)return n;e||(e=n);var t=n,i;do if(i=!1,!t.steiner&&(ah(t,t.next)||Ae(t.prev,t,t.next)===0)){if(Cl(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Sl(n,e,t,i,r,s,o){if(n){!o&&s&&jG(n,i,r,s);for(var a=n,c,l;n.prev!==n.next;){if(c=n.prev,l=n.next,s?NG(n,i,r,s):DG(n)){e.push(c.i/t|0),e.push(n.i/t|0),e.push(l.i/t|0),Cl(n),n=l.next,a=l.next;continue}if(n=l,n===a){o?o===1?(n=FG(fs(n),e,t),Sl(n,e,t,i,r,s,2)):o===2&&zG(n,e,t,i,r,s):Sl(fs(n),e,t,i,r,s,1);break}}}}function DG(n){var e=n.prev,t=n,i=n.next;if(Ae(e,t,i)>=0)return!1;for(var r=e.x,s=t.x,o=i.x,a=e.y,c=t.y,l=i.y,u=rs?r>o?r:o:s>o?s:o,h=a>c?a>l?a:l:c>l?c:l,p=i.next;p!==e;){if(p.x>=u&&p.x<=d&&p.y>=f&&p.y<=h&&Uo(r,a,s,c,o,l,p.x,p.y)&&Ae(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function NG(n,e,t,i){var r=n.prev,s=n,o=n.next;if(Ae(r,s,o)>=0)return!1;for(var a=r.x,c=s.x,l=o.x,u=r.y,f=s.y,d=o.y,h=ac?a>l?a:l:c>l?c:l,g=u>f?u>d?u:d:f>d?f:d,v=_b(h,p,e,t,i),y=_b(m,g,e,t,i),b=n.prevZ,x=n.nextZ;b&&b.z>=v&&x&&x.z<=y;){if(b.x>=h&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==o&&Uo(a,u,c,f,l,d,b.x,b.y)&&Ae(b.prev,b,b.next)>=0||(b=b.prevZ,x.x>=h&&x.x<=m&&x.y>=p&&x.y<=g&&x!==r&&x!==o&&Uo(a,u,c,f,l,d,x.x,x.y)&&Ae(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;b&&b.z>=v;){if(b.x>=h&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==o&&Uo(a,u,c,f,l,d,b.x,b.y)&&Ae(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;x&&x.z<=y;){if(x.x>=h&&x.x<=m&&x.y>=p&&x.y<=g&&x!==r&&x!==o&&Uo(a,u,c,f,l,d,x.x,x.y)&&Ae(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function FG(n,e,t){var i=n;do{var r=i.prev,s=i.next.next;!ah(r,s)&&gL(r,i,i.next,s)&&Pl(r,s)&&Pl(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),Cl(i),Cl(i.next),i=n=s),i=i.next}while(i!==n);return fs(i)}function zG(n,e,t,i,r,s){var o=n;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&qG(o,a)){var c=_L(o,a);o=fs(o,o.next),c=fs(c,c.next),Sl(o,e,t,i,r,s,0),Sl(c,e,t,i,r,s,0);return}a=a.next}o=o.next}while(o!==n)}function UG(n,e,t,i){var r=[],s,o,a,c,l;for(s=0,o=e.length;s=t.next.y&&t.next.y!==t.y){var a=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(a<=i&&a>s&&(s=a,o=t.x=t.x&&t.x>=l&&i!==t.x&&Uo(ro.x||t.x===o.x&&WG(o,t)))&&(o=t,f=d)),t=t.next;while(t!==c);return o}function WG(n,e){return Ae(n.prev,n,e.prev)<0&&Ae(e.next,n,n.next)<0}function jG(n,e,t,i){var r=n;do r.z===0&&(r.z=_b(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,HG(r)}function HG(n){var e,t,i,r,s,o,a,c,l=1;do{for(t=n,n=null,s=null,o=0;t;){for(o++,i=t,a=0,e=0;e0||c>0&&i;)a!==0&&(c===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,a--):(r=i,i=i.nextZ,c--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,l*=2}while(o>1);return n}function _b(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function YG(n){var e=n,t=n;do(e.x=(n-o)*(s-a)&&(n-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(i-a)}function qG(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!ZG(n,e)&&(Pl(n,e)&&Pl(e,n)&&XG(n,e)&&(Ae(n.prev,n,e.prev)||Ae(n,e.prev,e))||ah(n,e)&&Ae(n.prev,n,n.next)>0&&Ae(e.prev,e,e.next)>0)}function Ae(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function ah(n,e){return n.x===e.x&&n.y===e.y}function gL(n,e,t,i){var r=sh(Ae(n,e,t)),s=sh(Ae(n,e,i)),o=sh(Ae(t,i,n)),a=sh(Ae(t,i,e));return!!(r!==s&&o!==a||r===0&&rh(n,t,e)||s===0&&rh(n,i,e)||o===0&&rh(t,n,i)||a===0&&rh(t,e,i))}function rh(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function sh(n){return n>0?1:n<0?-1:0}function ZG(n,e){var t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&gL(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Pl(n,e){return Ae(n.prev,n,n.next)<0?Ae(n,e,n.next)>=0&&Ae(n,n.prev,e)>=0:Ae(n,e,n.prev)<0||Ae(n,n.next,e)<0}function XG(n,e){var t=n,i=!1,r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function _L(n,e){var t=new yb(n.i,n.x,n.y),i=new yb(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function pL(n,e,t,i){var r=new yb(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Cl(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function yb(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}oh.deviation=function(n,e,t,i){var r=e&&e.length,s=r?e[0]*t:n.length,o=Math.abs(bb(n,0,s,t));if(r)for(var a=0,c=e.length;a0&&(i+=n[r-1].length,t.holes.push(i))}return t}});function Fi(n,e){if(!n)throw new Error(e||"loader assertion failed.")}var In={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},oA=In.self||In.window||In.global||{},aA=In.window||In.self||In.global||{},cA=In.global||In.self||In.window||{},lA=In.document||{};var br=!!(typeof process!="object"||String(process)!=="[object process]"||process.browser);var yv=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),uA=yv&&parseFloat(yv[1])||0;sa();var wp="4.5.4",yA=wp[0]>="0"&&wp[0]<="9"?`v${wp}`:"";function bA(){let n=new ct({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=n,globalThis.loaders.version=yA,globalThis.probe||={},globalThis.probe.loaders=n,n}var Ep=bA();var vA=n=>typeof n=="boolean",On=n=>typeof n=="function",Dn=n=>n!==null&&typeof n=="object",iu=n=>Dn(n)&&n.constructor==={}.constructor;var Sp=n=>typeof SharedArrayBuffer<"u"&&n instanceof SharedArrayBuffer,Os=n=>Dn(n)&&typeof n.byteLength=="number"&&typeof n.slice=="function";var Pp=n=>!!n&&On(n[Symbol.iterator]),Cp=n=>!!n&&On(n[Symbol.asyncIterator]);var Lt=n=>typeof Response<"u"&&n instanceof Response||Dn(n)&&On(n.arrayBuffer)&&On(n.text)&&On(n.json);var Mt=n=>typeof Blob<"u"&&n instanceof Blob;var Bv=n=>typeof ReadableStream<"u"&&n instanceof ReadableStream||Dn(n)&&On(n.tee)&&On(n.cancel)&&On(n.getReader);var Ov=n=>Dn(n)&&On(n.read)&&On(n.pipe)&&vA(n.readable),oa=n=>Bv(n)||Ov(n);function Tp(n,e){return Dv(n||{},e)}function Dv(n,e,t=0){if(t>3)return e;let i={...n};for(let[r,s]of Object.entries(e))s&&typeof s=="object"&&!Array.isArray(s)?i[r]=Dv(i[r]||{},e[r],t+1):i[r]=e[r];return i}var Nv="latest";function xA(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.5.4"),globalThis._loadersgl_.version}var Fv=xA();function lt(n,e){if(!n)throw new Error(e||"loaders.gl assertion failed.")}var Nn={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},Qj=Nn.self||Nn.window||Nn.global||{},Jj=Nn.window||Nn.self||Nn.global||{},e8=Nn.global||Nn.self||Nn.window||{},t8=Nn.document||{};var jt=typeof process!="object"||String(process)!=="[object process]"||process.browser;var Uv=typeof window<"u"&&typeof window.orientation<"u",zv=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),n8=zv&&parseFloat(zv[1])||0;var aa=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,t){this.name=e,this.workerThread=t,this.result=new Promise((i,r)=>{this._resolve=i,this._reject=r})}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){lt(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){lt(this.isRunning),this.isRunning=!1,this._reject(e)}};var Ds=class{terminate(){}};var Lp=new Map;function $v(n){lt(n.source&&!n.url||!n.source&&n.url);let e=Lp.get(n.source||n.url);return e||(n.url&&(e=wA(n.url),Lp.set(n.url,e)),n.source&&(e=Gv(n.source),Lp.set(n.source,e))),lt(e),e}function wA(n){if(!n.startsWith("http"))return n;let e=EA(n);return Gv(e)}function Gv(n){let e=new Blob([n],{type:"application/javascript"});return URL.createObjectURL(e)}function EA(n){return`try { importScripts('${n}'); } catch (error) { console.error(error); throw error; -}`}function Mp(n,e=!0,t){let i=t||new Set;if(n){if(Vv(n))i.add(n);else if(Vv(n.buffer))i.add(n.buffer);else if(!ArrayBuffer.isView(n)){if(e&&typeof n=="object")for(let r in n)Mp(n[r],e,i)}}return t===void 0?Array.from(i):[]}function Vv(n){return n?n instanceof ArrayBuffer||typeof MessagePort<"u"&&n instanceof MessagePort||typeof ImageBitmap<"u"&&n instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas:!1}var Ap=()=>{},zi=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&Ht||typeof Ds<"u"&&!Ht}constructor(e){let{name:t,source:i,url:r}=e;lt(i||r),this.name=t,this.source=i,this.url=r,this.onMessage=Ap,this.onError=s=>console.log(s),this.worker=Ht?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=Ap,this.onError=Ap,this.worker.terminate(),this.terminated=!0}get isRunning(){return!!this.onMessage}postMessage(e,t){t=t||Mp(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+=`worker ${this.name} from ${this.url}. `,e.message&&(t+=`${e.message} in `),e.lineno&&(t+=`:${e.lineno}:${e.colno}`),new Error(t)}_createBrowserWorker(){this._loadableURL=$v({source:this.source,url:this.url});let e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=t=>{t.data?this.onMessage(t.data):this.onError(new Error("No data received"))},e.onerror=t=>{this.onError(this._getErrorFromErrorEvent(t)),this.terminated=!0},e.onmessageerror=t=>console.error(t),e}_createNodeWorker(){let e;if(this.url){let i=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`,r=this.url.endsWith(".ts")||this.url.endsWith(".mjs")?"module":"commonjs";e=new Ds(i,{eval:!1,type:r})}else if(this.source)e=new Ds(this.source,{eval:!0});else throw new Error("no worker");return e.on("message",t=>{this.onMessage(t)}),e.on("error",t=>{this.onError(t)}),e.on("exit",t=>{}),e}};var ca=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return zi.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},e.name!==void 0&&(this.name=e.name),e.maxConcurrency!==void 0&&(this.maxConcurrency=e.maxConcurrency),e.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=e.maxMobileConcurrency),e.reuseWorkers!==void 0&&(this.reuseWorkers=e.reuseWorkers),e.onDebug!==void 0&&(this.onDebug=e.onDebug)}async startJob(e,t=(r,s,o)=>r.done(o),i=(r,s)=>r.error(s)){let r=new Promise(s=>(this.jobQueue.push({name:e,onMessage:t,onError:i,onStart:s}),this));return this._startQueuedJob(),await r}async _startQueuedJob(){if(!this.jobQueue.length)return;let e=this._getAvailableWorker();if(!e)return;let t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});let i=new aa(t.name,e);e.onMessage=r=>t.onMessage(i,r.type,r.payload),e.onError=r=>t.onError(i,r),t.onStart(i);try{await i.result}catch(r){console.error(`Worker exception: ${r}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!Ht||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count{}},wr=class n{props;workerPools=new Map;static _workerFarm;static isSupported(){return zi.isSupported()}static getWorkerFarm(e={}){return n._workerFarm=n._workerFarm||new n({}),n._workerFarm.setProps(e),n._workerFarm}constructor(e){this.props={...xA},this.setProps(e),this.workerPools=new Map}destroy(){for(let e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(let t of this.workerPools.values())t.setProps(this._getWorkerPoolProps())}getWorkerPool(e){let{name:t,source:i,url:r}=e,s=this.workerPools.get(t);return s||(s=new ca({name:t,source:i,url:r}),s.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,s)),s}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}};function kp(n,e={}){let t=e[n.id]||{},i=Ht?n.workerFile||`${n.id}-worker.js`:`${n.id}-worker-node.js`,r=t.workerUrl;if(!r&&n.id==="compression"&&(r=e.workerUrl),(e._workerType||e?.core?._workerType)==="test"&&(Ht?r=`modules/${n.module}/dist/${i}`:r=`modules/${n.module}/src/workers/${n.id}-worker-node.ts`),!r){let o=n.version;o==="latest"&&(o=Nv);let a=o?`@${o}`:"";r=`loaders.gl-cdn-disabled/${n.module}${a}/dist/${i}`}return lt(r),r}function Rp(n,e=Fv){lt(n,"no worker provided");let t=n.version;return!(!e||!t)}function Ip(n,e){if(!wr.isSupported())return!1;let t=e?._nodeWorkers??e?.core?._nodeWorkers;if(!Ht&&!t)return!1;let i=e?.worker??e?.core?.worker;return!!(n.worker&&i)}async function Bp(n,e,t,i,r){let s=n.id,o=kp(n,t),c=wr.getWorkerFarm(t?.core).getWorkerPool({name:s,url:o});t=JSON.parse(JSON.stringify(t||{})),t._workerLoaderId=n.id,i=JSON.parse(JSON.stringify(i||{}));let l=await c.startJob("process-on-worker",wA.bind(null,r));return l.postMessage("process",{input:e,options:t,context:i}),await(await l.result).result}async function wA(n,e,t,i){switch(t){case"done":e.done(i);break;case"error":e.error(new Error(i.error));break;case"process":let{id:r,input:s,options:o}=i;try{let a=await n(s,o);e.postMessage("done",{id:r,result:a})}catch(a){let c=a instanceof Error?a.message:"unknown error";e.postMessage("error",{id:r,error:c})}break;default:console.warn(`parse-with-worker unknown message ${t}`)}}function Op(n,e,t){if(t=t||n.byteLength,n.byteLengths instanceof ArrayBuffer?new Uint8Array(s):s),t=e.reduce((s,o)=>s+o.byteLength,0),i=new Uint8Array(t),r=0;for(let s of e)i.set(s,r),r+=s.byteLength;return i.buffer}async function Np(n){let e=[];for await(let t of n)e.push(EA(t));return Dp(...e)}function EA(n){if(n instanceof ArrayBuffer)return n;if(ArrayBuffer.isView(n)){let{buffer:e,byteOffset:t,byteLength:i}=n;return jv(e,t,i)}return jv(n)}function jv(n,e=0,t=n.byteLength-e){let i=new Uint8Array(n,e,t),r=new Uint8Array(i.length);return r.set(i),r.buffer}var SA="",Yv={};function Up(n){for(let e in Yv)if(n.startsWith(e)){let t=Yv[e];n=n.replace(e,t)}return!n.startsWith("http://")&&!n.startsWith("https://")&&(n=`${SA}${n}`),n}function su(n){return n&&typeof n=="object"&&n.isBuffer}function Ns(n){if(su(n))return n;if(n instanceof ArrayBuffer)return n;if(Sp(n))return ru(n);if(ArrayBuffer.isView(n)){let e=n.buffer;return n.byteOffset===0&&n.byteLength===n.buffer.byteLength?e:e.slice(n.byteOffset,n.byteOffset+n.byteLength)}if(typeof n=="string"){let e=n;return new TextEncoder().encode(e).buffer}if(n&&typeof n=="object"&&n._toArrayBuffer)return n._toArrayBuffer();throw new Error("toArrayBuffer")}function fa(n){if(n instanceof ArrayBuffer)return n;if(Sp(n))return ru(n);let{buffer:e,byteOffset:t,byteLength:i}=n;return e instanceof ArrayBuffer&&t===0&&i===e.byteLength?e:ru(e,t,i)}function ru(n,e=0,t=n.byteLength-e){let i=new Uint8Array(n,e,t),r=new Uint8Array(i.length);return r.set(i),r.buffer}function $p(n){return ArrayBuffer.isView(n)?n:new Uint8Array(n)}var gi={};mi(gi,{dirname:()=>CA,filename:()=>PA,join:()=>TA,resolve:()=>LA});function qv(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let n=window.location?.pathname;return n?.slice(0,n.lastIndexOf("/")+1)||""}function PA(n){let e=n?n.lastIndexOf("/"):-1;return e>=0?n.substr(e+1):n}function CA(n){let e=n?n.lastIndexOf("/"):-1;return e>=0?n.substr(0,e):""}function TA(...n){let e="/";return n=n.map((t,i)=>(i&&(t=t.replace(new RegExp(`^${e}`),"")),i!==n.length-1&&(t=t.replace(new RegExp(`${e}$`),"")),t)),n.join(e)}function LA(...n){let e=[];for(let s=0;s=-1&&!i;s--){let o;s>=0?o=e[s]:(r===void 0&&(r=qv()),o=r),o.length!==0&&(t=`${o}/${t}`,i=o.charCodeAt(0)===da)}return t=MA(t,!i),i?`/${t}`:t.length>0?t:"."}var da=47,Gp=46;function MA(n,e){let t="",i=-1,r=0,s,o=!1;for(let a=0;a<=n.length;++a){if(a2){let c=t.length-1,l=c;for(;l>=0&&t.charCodeAt(l)!==da;--l);if(l!==c){t=l===-1?"":t.slice(0,l),i=a,r=0,o=!1;continue}}else if(t.length===2||t.length===1){t="",i=a,r=0,o=!1;continue}}e&&(t.length>0?t+="/..":t="..",o=!0)}else{let c=n.slice(i+1,a);t.length>0?t+=`/${c}`:t=c,o=!1}i=a,r=0}else s===Gp&&r!==-1?++r:r=-1}return t}var ou=class extends Error{constructor(e,t){super(e),this.reason=t.reason,this.url=t.url,this.response=t.response}reason;url;response};var RA=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,IA=/^([-\w.]+\/[-\w.+]+)/;function Vp(n,e){return n.toLowerCase()===e.toLowerCase()}function Zv(n){let e=IA.exec(n);return e?e[1]:n}function Wp(n){let e=RA.exec(n);return e?e[1]:""}var Xv=/\?.*/;function Kv(n){let e=n.match(Xv);return e&&e[0]}function Ui(n){return n.replace(Xv,"")}function Qv(n){if(n.length<50)return n;let e=n.slice(n.length-15);return`${n.substr(0,32)}...${e}`}function Sr(n){return Lt(n)?n.url:Mt(n)?("name"in n?n.name:"")||"":typeof n=="string"?n:""}function Fs(n){if(Lt(n)){let e=n.headers.get("content-type")||"",t=Ui(n.url);return Zv(e)||Wp(t)}return Mt(n)?n.type||"":typeof n=="string"?Wp(n):""}function Jv(n){return Lt(n)?n.headers["content-length"]||-1:Mt(n)?n.size:typeof n=="string"?n.length:n instanceof ArrayBuffer||ArrayBuffer.isView(n)?n.byteLength:-1}async function au(n){if(Lt(n))return n;let e={},t=Jv(n);t>=0&&(e["content-length"]=String(t));let i=Sr(n),r=Fs(n);r&&(e["content-type"]=r);let s=await OA(n);s&&(e["x-first-bytes"]=s),typeof n=="string"&&(n=new TextEncoder().encode(n));let o=new Response(n,{headers:e});return Object.defineProperty(o,"url",{value:i}),o}async function ex(n){if(!n.ok)throw await BA(n)}async function BA(n){let e=Qv(n.url),t=`Failed to fetch resource (${n.status}) ${n.statusText}: ${e}`;t=t.length>100?`${t.slice(0,100)}...`:t;let i={reason:n.statusText,url:n.url,response:n};try{let r=n.headers.get("Content-Type");i.reason=!n.bodyUsed&&r?.includes("application/json")?await n.json():await n.text()}catch{}return new ou(t,i)}async function OA(n){if(typeof n=="string")return`data:,${n.slice(0,5)}`;if(n instanceof Blob){let t=n.slice(0,5);return await new Promise(i=>{let r=new FileReader;r.onload=s=>i(s?.target?.result),r.readAsDataURL(t)})}if(n instanceof ArrayBuffer){let t=n.slice(0,5);return`data:base64,${DA(t)}`}return null}function DA(n){let e="",t=new Uint8Array(n);for(let i=0;i{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},lu=class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}};var uu={core:{baseUrl:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new lu,useLocalLibraries:!1,CDN:"loaders.gl-cdn-disabled",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:br,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]}},tx={baseUri:"core.baseUrl",fetch:"core.fetch",mimeType:"core.mimeType",fallbackMimeType:"core.fallbackMimeType",ignoreRegisteredLoaders:"core.ignoreRegisteredLoaders",nothrow:"core.nothrow",log:"core.log",useLocalLibraries:"core.useLocalLibraries",CDN:"core.CDN",worker:"core.worker",maxConcurrency:"core.maxConcurrency",maxMobileConcurrency:"core.maxMobileConcurrency",reuseWorkers:"core.reuseWorkers",_nodeWorkers:"core.nodeWorkers",_workerType:"core._workerType",_worker:"core._workerType",limit:"core.limit",_limitMB:"core._limitMB",batchSize:"core.batchSize",batchDebounceMs:"core.batchDebounceMs",metadata:"core.metadata",transforms:"core.transforms",throws:"nothrow",dataType:"(no longer used)",uri:"core.baseUrl",method:"core.fetch.method",headers:"core.fetch.headers",body:"core.fetch.body",mode:"core.fetch.mode",credentials:"core.fetch.credentials",cache:"core.fetch.cache",redirect:"core.fetch.redirect",referrer:"core.fetch.referrer",referrerPolicy:"core.fetch.referrerPolicy",integrity:"core.fetch.integrity",keepalive:"core.fetch.keepalive",signal:"core.fetch.signal"};var Hp=["baseUrl","fetch","mimeType","fallbackMimeType","ignoreRegisteredLoaders","nothrow","log","useLocalLibraries","CDN","worker","maxConcurrency","maxMobileConcurrency","reuseWorkers","_nodeWorkers","_workerType","limit","_limitMB","batchSize","batchDebounceMs","metadata","transforms"];function Yp(){globalThis.loaders=globalThis.loaders||{};let{loaders:n}=globalThis;return n._state||(n._state={}),n._state}function qp(){let n=Yp();return n.globalOptions=n.globalOptions||{...uu,core:{...uu.core}},_i(n.globalOptions)}function rx(n,e,t,i){return t=t||[],t=Array.isArray(t)?t:[t],UA(n,t),_i(GA(e,n,i))}function _i(n){let e=WA(n);sx(e);for(let t of Hp)e.core&&e.core[t]!==void 0&&delete e[t];return e.core&&e.core._workerType!==void 0&&delete e._worker,e}function UA(n,e){nx(n,null,uu,tx,e);for(let t of e){let i=n&&n[t.id]||{},r=t.options&&t.options[t.id]||{},s=t.deprecatedOptions&&t.deprecatedOptions[t.id]||{};nx(i,t.id,r,s,e)}}function nx(n,e,t,i,r){let s=e||"Top level",o=e?`${e}.`:"";for(let a in n){let c=!e&&Dn(n[a]),l=a==="baseUri"&&!e,u=a==="workerUrl"&&e;if(!(a in t)&&!l&&!u){if(a in i)ha.level>0&&ha.warn(`${s} loader option '${o}${a}' no longer supported, use '${i[a]}'`)();else if(!c&&ha.level>0){let f=$A(a,r);ha.warn(`${s} loader option '${o}${a}' not recognized. ${f}`)()}}}}function $A(n,e){let t=n.toLowerCase(),i="";for(let r of e)for(let s in r.options){if(n===s)return`Did you mean '${r.id}.${s}'?`;let o=s.toLowerCase();(t.startsWith(o)||o.startsWith(t))&&(i=i||`Did you mean '${r.id}.${s}'?`)}return i}function GA(n,e,t){let i=n.options||{},r={...i};i.core&&(r.core={...i.core}),sx(r),r.core?.log===null&&(r.core={...r.core,log:new cu}),ix(r,_i(qp()));let s=_i(e);return ix(r,s),VA(r,t),jA(r),r}function ix(n,e){for(let t in e)if(t in e){let i=e[t];iu(i)&&iu(n[t])?n[t]={...n[t],...e[t]}:n[t]=e[t]}}function VA(n,e){if(!e)return;n.core?.baseUrl!==void 0||(n.core||={},n.core.baseUrl=gi.dirname(Ui(e)))}function WA(n){let e={...n};return n.core&&(e.core={...n.core}),e}function sx(n){n.baseUri!==void 0&&(n.core||={},n.core.baseUrl===void 0&&(n.core.baseUrl=n.baseUri));for(let t of Hp)if(n[t]!==void 0){let r=n.core=n.core||{};r[t]===void 0&&(r[t]=n[t])}let e=n._worker;e!==void 0&&(n.core||={},n.core._workerType===void 0&&(n.core._workerType=e))}function jA(n){let e=n.core;if(e)for(let t of Hp)e[t]!==void 0&&(n[t]=e[t])}function pa(n){return n?(Array.isArray(n)&&(n=n[0]),Array.isArray(n?.extensions)):!1}function ma(n){Fi(n,"null loader"),Fi(pa(n),"invalid loader");let e;return Array.isArray(n)&&(e=n[1],n=n[0],n={...n,options:{...n.options,...e}}),(n?.parseTextSync||n?.parseText)&&(n.text=!0),n.text||(n.binary=!0),n}var ox=()=>{let n=Yp();return n.loaderRegistry=n.loaderRegistry||[],n.loaderRegistry};function Zp(n){let e=ox();n=Array.isArray(n)?n:[n];for(let t of n){let i=ma(t);e.find(r=>i===r)||e.unshift(i)}}function ax(){return ox()}var HA=/\.([^.]+)$/;async function ux(n,e=[],t,i){if(!fx(n))return null;let r=_i(t||{});if(r.core||={},n instanceof Response&&cx(n)){let o=await n.clone().text(),a=fu(o,e,{...r,core:{...r.core,nothrow:!0}},i);if(a)return a}let s=fu(n,e,{...r,core:{...r.core,nothrow:!0}},i);if(s)return s;if(Mt(n)&&(n=await n.slice(0,10).arrayBuffer(),s=fu(n,e,r,i)),!s&&n instanceof Response&&cx(n)){let o=await n.clone().text();s=fu(o,e,r,i)}if(!s&&!r.core.nothrow)throw new Error(dx(n));return s}function cx(n){let e=Fs(n);return!!(e&&(e.startsWith("text/")||e==="application/json"||e.endsWith("+json")))}function fu(n,e=[],t,i){if(!fx(n))return null;let r=_i(t||{});if(r.core||={},e&&!Array.isArray(e))return ma(e);let s=[];e&&(s=s.concat(e)),r.core.ignoreRegisteredLoaders||s.push(...ax()),qA(s);let o=YA(n,s,r,i);if(!o&&!r.core.nothrow)throw new Error(dx(n));return o}function YA(n,e,t,i){let r=Sr(n),s=Fs(n),o=Ui(r)||i?.url,a=null,c="";return t?.core?.mimeType&&(a=Xp(e,t?.core?.mimeType),c=`match forced by supplied MIME type ${t?.core?.mimeType}`),a=a||ZA(e,o),c=c||(a?`matched url ${o}`:""),a=a||Xp(e,s),c=c||(a?`matched MIME type ${s}`:""),a=a||KA(e,n),c=c||(a?`matched initial data ${hx(n)}`:""),t?.core?.fallbackMimeType&&(a=a||Xp(e,t?.core?.fallbackMimeType),c=c||(a?`matched fallback MIME type ${s}`:"")),c&&Ep.log(1,`selectLoader selected ${a?.name}: ${c}.`),a}function fx(n){return!(n instanceof Response&&n.status===204)}function dx(n){let e=Sr(n),t=Fs(n),i="No valid loader found (";i+=e?`${gi.filename(e)}, `:"no url provided, ",i+=`MIME type: ${t?`"${t}"`:"not provided"}, `;let r=n?hx(n):"";return i+=r?` first bytes: "${r}"`:"first bytes: not available",i+=")",i}function qA(n){for(let e of n)ma(e)}function ZA(n,e){let t=e&&HA.exec(e),i=t&&t[1];return i?XA(n,i):null}function XA(n,e){e=e.toLowerCase();for(let t of n)for(let i of t.extensions)if(i.toLowerCase()===e)return t;return null}function Xp(n,e){for(let t of n)if(t.mimeTypes?.some(i=>Vp(e,i))||Vp(e,`application/x.${t.id}`))return t;return null}function KA(n,e){if(!e)return null;for(let t of n)if(typeof e=="string"){if(QA(e,t))return t}else if(ArrayBuffer.isView(e)){if(lx(e.buffer,e.byteOffset,t))return t}else if(e instanceof ArrayBuffer&&lx(e,0,t))return t;return null}function QA(n,e){return e.testText?e.testText(n):(Array.isArray(e.tests)?e.tests:[e.tests]).some(i=>n.startsWith(i))}function lx(n,e,t){return(Array.isArray(t.tests)?t.tests:[t.tests]).some(r=>JA(n,e,t,r))}function JA(n,e,t,i){if(Os(i))return Op(i,n,i.byteLength);switch(typeof i){case"function":return i(fa(n));case"string":let r=Kp(n,e,i.length);return i===r;default:return!1}}function hx(n,e=5){return typeof n=="string"?n.slice(0,e):ArrayBuffer.isView(n)?Kp(n.buffer,n.byteOffset,e):n instanceof ArrayBuffer?Kp(n,0,e):""}function Kp(n,e,t){if(n.byteLengthjp(s,r):e?.fetch?e?.fetch:jp}function vx(n,e,t){if(t)return t;let i={fetch:du(e,n),...n};if(i.url){let r=Ui(i.url);i.baseUrl=r,i.queryString=Kv(i.url),i.filename=gi.filename(r),i.baseUrl=gi.dirname(r)}return Array.isArray(i.loaders)||(i.loaders=null),i}function xx(n,e){if(n&&!Array.isArray(n))return n;let t;if(n&&(t=Array.isArray(n)?n:[n]),e&&e.loaders){let i=Array.isArray(e.loaders)?e.loaders:[e.loaders];t=t?[...t,...i]:i}return t&&t.length?t:void 0}async function ga(n,e,t,i){e&&!Array.isArray(e)&&!pa(e)&&(i=void 0,t=e,e=void 0),n=await n,t=t||{};let r=Sr(n),o=xx(e,i),a=await ux(n,o,t);if(!a)return null;let c=rx(t,a,o,r);return i=vx({url:r,_parse:ga,loaders:o},c,i||null),await rk(a,n,c,i)}async function rk(n,e,t,i){if(Rp(n),t=Tp(n.options,t),Lt(e)){let{ok:s,redirected:o,status:a,statusText:c,type:l,url:u}=e,f=Object.fromEntries(e.headers.entries());i.response={headers:f,ok:s,redirected:o,status:a,statusText:c,type:l,url:u}}e=await bx(e,n,t);let r=n;if(r.parseTextSync&&typeof e=="string")return r.parseTextSync(e,t,i);if(Ip(n,t))return await Bp(n,e,t,i,ga);if(r.parseText&&typeof e=="string")return await r.parseText(e,t,i);if(r.parse)return await r.parse(e,t,i);throw lt(!r.parseSync),new Error(`${n.id} loader - no parser found and worker is disabled`)}async function zs(n,e,t,i){let r,s;!Array.isArray(e)&&!pa(e)?(r=[],s=e,i=void 0):(r=e,s=t);let o=du(s),a=n;return typeof n=="string"&&(a=await o(n)),Mt(n)&&(a=await o(n)),typeof n=="string"&&(_i(s||{}).core?.baseUrl||(s={...s,core:{...s?.core,baseUrl:n}})),Array.isArray(r)?await ga(a,r,s):await ga(a,r,s)}var Px="4.5.4";var sk=globalThis.loaders?.parseImageNode,em=typeof Image<"u",tm=typeof ImageBitmap<"u",ok=!!sk,nm=br?!0:ok;function Cx(n){switch(n){case"auto":return tm||em||nm;case"imagebitmap":return tm;case"image":return em;case"data":return nm;default:throw new Error(`@loaders.gl/images: image ${n} not supported in this environment`)}}function Tx(){if(tm)return"imagebitmap";if(em)return"image";if(nm)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function ak(n){let e=ck(n);if(!e)throw new Error("Not an image");return e}function Lx(n){switch(ak(n)){case"data":return n;case"image":case"imagebitmap":let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)throw new Error("getImageData");return e.width=n.width,e.height=n.height,t.drawImage(n,0,0),t.getImageData(0,0,n.width,n.height);default:throw new Error("getImageData")}}function ck(n){return typeof ImageBitmap<"u"&&n instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&n instanceof Image?"image":n&&typeof n=="object"&&n.data&&n.width&&n.height?"data":null}var lk=/^data:image\/svg\+xml/,uk=/\.svg((\?|#).*)?$/;function hu(n){return n&&(lk.test(n)||uk.test(n))}function Mx(n,e){if(hu(e)){let i=new TextDecoder().decode(n);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(i=unescape(encodeURIComponent(i)))}catch(s){throw new Error(s.message)}return`data:image/svg+xml;base64,${btoa(i)}`}return im(n,e)}function im(n,e){if(hu(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(n)])}async function pu(n,e,t){let i=Mx(n,t),r=self.URL||self.webkitURL,s=typeof i!="string"&&r.createObjectURL(i);try{return await fk(s||i,e)}finally{s&&r.revokeObjectURL(s)}}async function fk(n,e){let t=new Image;return t.src=n,e.image&&e.image.decode&&t.decode?(await t.decode(),t):await new Promise((i,r)=>{try{t.onload=()=>i(t),t.onerror=s=>{let o=s instanceof Error?s.message:"error";r(new Error(o))}}catch(s){r(s)}})}var Ax=!0;async function kx(n,e,t){let i;hu(t)?i=await pu(n,e,t):i=im(n,t);let r=e&&e.imagebitmap;return await dk(i,r)}async function dk(n,e=null){if((hk(e)||!Ax)&&(e=null),e)try{return await createImageBitmap(n,e)}catch(t){console.warn(t),Ax=!1}return await createImageBitmap(n)}function hk(n){if(!n)return!0;for(let e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}function Rx(n){return!_k(n,"ftyp",4)||!(n[8]&96)?null:pk(n)}function pk(n){switch(mk(n,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function mk(n,e,t){return String.fromCharCode(...n.slice(e,t))}function gk(n){return[...n].map(e=>e.charCodeAt(0))}function _k(n,e,t=0){let i=gk(e);for(let r=0;r=24&&e.getUint32(0,Fn)===2303741511?{mimeType:"image/png",width:e.getUint32(16,Fn),height:e.getUint32(20,Fn)}:null}function vk(n){let e=ba(n);return e.byteLength>=10&&e.getUint32(0,Fn)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,ya),height:e.getUint16(8,ya)}:null}function xk(n){let e=ba(n);return e.byteLength>=14&&e.getUint16(0,Fn)===16973&&e.getUint32(2,ya)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,ya),height:e.getUint32(22,ya)}:null}function wk(n){let e=ba(n);if(!(e.byteLength>=3&&e.getUint16(0,Fn)===65496&&e.getUint8(2)===255))return null;let{tableMarkers:i,sofMarkers:r}=Ek(),s=2;for(;s+9!!mu(new DataView(n))],options:Tk};sa();var Lk=new ct({id:"deck"}),ae=Lk;var sm={};function Ox(n){sm=n}function Ne(n,e,t,i){ae.level>0&&sm[n]&&sm[n].call(null,e,t,i)}function Mk(n){let e=n[0],t=n[n.length-1];return e==="{"&&t==="}"||e==="["&&t==="]"}var Dx={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:Mk,parseTextSync:JSON.parse};function Ak(){let n="9.4.0",e=globalThis.deck&&globalThis.deck.VERSION;if(e&&e!==n)throw new Error(`deck.gl - multiple versions detected: ${e} vs ${n}`);return e||(ae.log(1,`deck.gl ${n}`)(),globalThis.deck={...globalThis.deck,VERSION:n,version:n,log:ae,_registerLoggers:Ox},Zp([Dx,[rm,{imagebitmap:{premultiplyAlpha:"none"}}]])),n}var Nx=Ak();vt();var T4=`struct LayerUniforms { +}`}function Mp(n,e=!0,t){let i=t||new Set;if(n){if(Vv(n))i.add(n);else if(Vv(n.buffer))i.add(n.buffer);else if(!ArrayBuffer.isView(n)){if(e&&typeof n=="object")for(let r in n)Mp(n[r],e,i)}}return t===void 0?Array.from(i):[]}function Vv(n){return n?n instanceof ArrayBuffer||typeof MessagePort<"u"&&n instanceof MessagePort||typeof ImageBitmap<"u"&&n instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas:!1}var Ap=()=>{},zi=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&jt||typeof Ds<"u"&&!jt}constructor(e){let{name:t,source:i,url:r}=e;lt(i||r),this.name=t,this.source=i,this.url=r,this.onMessage=Ap,this.onError=s=>console.log(s),this.worker=jt?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=Ap,this.onError=Ap,this.worker.terminate(),this.terminated=!0}get isRunning(){return!!this.onMessage}postMessage(e,t){t=t||Mp(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+=`worker ${this.name} from ${this.url}. `,e.message&&(t+=`${e.message} in `),e.lineno&&(t+=`:${e.lineno}:${e.colno}`),new Error(t)}_createBrowserWorker(){this._loadableURL=$v({source:this.source,url:this.url});let e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=t=>{t.data?this.onMessage(t.data):this.onError(new Error("No data received"))},e.onerror=t=>{this.onError(this._getErrorFromErrorEvent(t)),this.terminated=!0},e.onmessageerror=t=>console.error(t),e}_createNodeWorker(){let e;if(this.url){let i=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`,r=this.url.endsWith(".ts")||this.url.endsWith(".mjs")?"module":"commonjs";e=new Ds(i,{eval:!1,type:r})}else if(this.source)e=new Ds(this.source,{eval:!0});else throw new Error("no worker");return e.on("message",t=>{this.onMessage(t)}),e.on("error",t=>{this.onError(t)}),e.on("exit",t=>{}),e}};var ca=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return zi.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},e.name!==void 0&&(this.name=e.name),e.maxConcurrency!==void 0&&(this.maxConcurrency=e.maxConcurrency),e.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=e.maxMobileConcurrency),e.reuseWorkers!==void 0&&(this.reuseWorkers=e.reuseWorkers),e.onDebug!==void 0&&(this.onDebug=e.onDebug)}async startJob(e,t=(r,s,o)=>r.done(o),i=(r,s)=>r.error(s)){let r=new Promise(s=>(this.jobQueue.push({name:e,onMessage:t,onError:i,onStart:s}),this));return this._startQueuedJob(),await r}async _startQueuedJob(){if(!this.jobQueue.length)return;let e=this._getAvailableWorker();if(!e)return;let t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});let i=new aa(t.name,e);e.onMessage=r=>t.onMessage(i,r.type,r.payload),e.onError=r=>t.onError(i,r),t.onStart(i);try{await i.result}catch(r){console.error(`Worker exception: ${r}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!jt||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count{}},wr=class n{props;workerPools=new Map;static _workerFarm;static isSupported(){return zi.isSupported()}static getWorkerFarm(e={}){return n._workerFarm=n._workerFarm||new n({}),n._workerFarm.setProps(e),n._workerFarm}constructor(e){this.props={...SA},this.setProps(e),this.workerPools=new Map}destroy(){for(let e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(let t of this.workerPools.values())t.setProps(this._getWorkerPoolProps())}getWorkerPool(e){let{name:t,source:i,url:r}=e,s=this.workerPools.get(t);return s||(s=new ca({name:t,source:i,url:r}),s.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,s)),s}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}};function kp(n,e={}){let t=e[n.id]||{},i=jt?n.workerFile||`${n.id}-worker.js`:`${n.id}-worker-node.js`,r=t.workerUrl;if(!r&&n.id==="compression"&&(r=e.workerUrl),(e._workerType||e?.core?._workerType)==="test"&&(jt?r=`modules/${n.module}/dist/${i}`:r=`modules/${n.module}/src/workers/${n.id}-worker-node.ts`),!r){let o=n.version;o==="latest"&&(o=Nv);let a=o?`@${o}`:"";r=`loaders.gl-cdn-disabled/${n.module}${a}/dist/${i}`}return lt(r),r}function Rp(n,e=Fv){lt(n,"no worker provided");let t=n.version;return!(!e||!t)}function Ip(n,e){if(!wr.isSupported())return!1;let t=e?._nodeWorkers??e?.core?._nodeWorkers;if(!jt&&!t)return!1;let i=e?.worker??e?.core?.worker;return!!(n.worker&&i)}async function Bp(n,e,t,i,r){let s=n.id,o=kp(n,t),c=wr.getWorkerFarm(t?.core).getWorkerPool({name:s,url:o});t=JSON.parse(JSON.stringify(t||{})),t._workerLoaderId=n.id,i=JSON.parse(JSON.stringify(i||{}));let l=await c.startJob("process-on-worker",PA.bind(null,r));return l.postMessage("process",{input:e,options:t,context:i}),await(await l.result).result}async function PA(n,e,t,i){switch(t){case"done":e.done(i);break;case"error":e.error(new Error(i.error));break;case"process":let{id:r,input:s,options:o}=i;try{let a=await n(s,o);e.postMessage("done",{id:r,result:a})}catch(a){let c=a instanceof Error?a.message:"unknown error";e.postMessage("error",{id:r,error:c})}break;default:console.warn(`parse-with-worker unknown message ${t}`)}}function Op(n,e,t){if(t=t||n.byteLength,n.byteLengths instanceof ArrayBuffer?new Uint8Array(s):s),t=e.reduce((s,o)=>s+o.byteLength,0),i=new Uint8Array(t),r=0;for(let s of e)i.set(s,r),r+=s.byteLength;return i.buffer}async function Np(n){let e=[];for await(let t of n)e.push(CA(t));return Dp(...e)}function CA(n){if(n instanceof ArrayBuffer)return n;if(ArrayBuffer.isView(n)){let{buffer:e,byteOffset:t,byteLength:i}=n;return jv(e,t,i)}return jv(n)}function jv(n,e=0,t=n.byteLength-e){let i=new Uint8Array(n,e,t),r=new Uint8Array(i.length);return r.set(i),r.buffer}var TA="",Yv={};function Up(n){for(let e in Yv)if(n.startsWith(e)){let t=Yv[e];n=n.replace(e,t)}return!n.startsWith("http://")&&!n.startsWith("https://")&&(n=`${TA}${n}`),n}function su(n){return n&&typeof n=="object"&&n.isBuffer}function Ns(n){if(su(n))return n;if(n instanceof ArrayBuffer)return n;if(Sp(n))return ru(n);if(ArrayBuffer.isView(n)){let e=n.buffer;return n.byteOffset===0&&n.byteLength===n.buffer.byteLength?e:e.slice(n.byteOffset,n.byteOffset+n.byteLength)}if(typeof n=="string"){let e=n;return new TextEncoder().encode(e).buffer}if(n&&typeof n=="object"&&n._toArrayBuffer)return n._toArrayBuffer();throw new Error("toArrayBuffer")}function fa(n){if(n instanceof ArrayBuffer)return n;if(Sp(n))return ru(n);let{buffer:e,byteOffset:t,byteLength:i}=n;return e instanceof ArrayBuffer&&t===0&&i===e.byteLength?e:ru(e,t,i)}function ru(n,e=0,t=n.byteLength-e){let i=new Uint8Array(n,e,t),r=new Uint8Array(i.length);return r.set(i),r.buffer}function $p(n){return ArrayBuffer.isView(n)?n:new Uint8Array(n)}var gi={};mi(gi,{dirname:()=>MA,filename:()=>LA,join:()=>AA,resolve:()=>kA});function qv(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let n=window.location?.pathname;return n?.slice(0,n.lastIndexOf("/")+1)||""}function LA(n){let e=n?n.lastIndexOf("/"):-1;return e>=0?n.substr(e+1):n}function MA(n){let e=n?n.lastIndexOf("/"):-1;return e>=0?n.substr(0,e):""}function AA(...n){let e="/";return n=n.map((t,i)=>(i&&(t=t.replace(new RegExp(`^${e}`),"")),i!==n.length-1&&(t=t.replace(new RegExp(`${e}$`),"")),t)),n.join(e)}function kA(...n){let e=[];for(let s=0;s=-1&&!i;s--){let o;s>=0?o=e[s]:(r===void 0&&(r=qv()),o=r),o.length!==0&&(t=`${o}/${t}`,i=o.charCodeAt(0)===da)}return t=RA(t,!i),i?`/${t}`:t.length>0?t:"."}var da=47,Gp=46;function RA(n,e){let t="",i=-1,r=0,s,o=!1;for(let a=0;a<=n.length;++a){if(a2){let c=t.length-1,l=c;for(;l>=0&&t.charCodeAt(l)!==da;--l);if(l!==c){t=l===-1?"":t.slice(0,l),i=a,r=0,o=!1;continue}}else if(t.length===2||t.length===1){t="",i=a,r=0,o=!1;continue}}e&&(t.length>0?t+="/..":t="..",o=!0)}else{let c=n.slice(i+1,a);t.length>0?t+=`/${c}`:t=c,o=!1}i=a,r=0}else s===Gp&&r!==-1?++r:r=-1}return t}var ou=class extends Error{constructor(e,t){super(e),this.reason=t.reason,this.url=t.url,this.response=t.response}reason;url;response};var OA=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,DA=/^([-\w.]+\/[-\w.+]+)/;function Vp(n,e){return n.toLowerCase()===e.toLowerCase()}function Zv(n){let e=DA.exec(n);return e?e[1]:n}function Wp(n){let e=OA.exec(n);return e?e[1]:""}var Xv=/\?.*/;function Kv(n){let e=n.match(Xv);return e&&e[0]}function Ui(n){return n.replace(Xv,"")}function Qv(n){if(n.length<50)return n;let e=n.slice(n.length-15);return`${n.substr(0,32)}...${e}`}function Sr(n){return Lt(n)?n.url:Mt(n)?("name"in n?n.name:"")||"":typeof n=="string"?n:""}function Fs(n){if(Lt(n)){let e=n.headers.get("content-type")||"",t=Ui(n.url);return Zv(e)||Wp(t)}return Mt(n)?n.type||"":typeof n=="string"?Wp(n):""}function Jv(n){return Lt(n)?n.headers["content-length"]||-1:Mt(n)?n.size:typeof n=="string"?n.length:n instanceof ArrayBuffer||ArrayBuffer.isView(n)?n.byteLength:-1}async function au(n){if(Lt(n))return n;let e={},t=Jv(n);t>=0&&(e["content-length"]=String(t));let i=Sr(n),r=Fs(n);r&&(e["content-type"]=r);let s=await FA(n);s&&(e["x-first-bytes"]=s),typeof n=="string"&&(n=new TextEncoder().encode(n));let o=new Response(n,{headers:e});return Object.defineProperty(o,"url",{value:i}),o}async function ex(n){if(!n.ok)throw await NA(n)}async function NA(n){let e=Qv(n.url),t=`Failed to fetch resource (${n.status}) ${n.statusText}: ${e}`;t=t.length>100?`${t.slice(0,100)}...`:t;let i={reason:n.statusText,url:n.url,response:n};try{let r=n.headers.get("Content-Type");i.reason=!n.bodyUsed&&r?.includes("application/json")?await n.json():await n.text()}catch{}return new ou(t,i)}async function FA(n){if(typeof n=="string")return`data:,${n.slice(0,5)}`;if(n instanceof Blob){let t=n.slice(0,5);return await new Promise(i=>{let r=new FileReader;r.onload=s=>i(s?.target?.result),r.readAsDataURL(t)})}if(n instanceof ArrayBuffer){let t=n.slice(0,5);return`data:base64,${zA(t)}`}return null}function zA(n){let e="",t=new Uint8Array(n);for(let i=0;i{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},lu=class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}};var uu={core:{baseUrl:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new lu,useLocalLibraries:!1,CDN:"loaders.gl-cdn-disabled",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:br,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]}},tx={baseUri:"core.baseUrl",fetch:"core.fetch",mimeType:"core.mimeType",fallbackMimeType:"core.fallbackMimeType",ignoreRegisteredLoaders:"core.ignoreRegisteredLoaders",nothrow:"core.nothrow",log:"core.log",useLocalLibraries:"core.useLocalLibraries",CDN:"core.CDN",worker:"core.worker",maxConcurrency:"core.maxConcurrency",maxMobileConcurrency:"core.maxMobileConcurrency",reuseWorkers:"core.reuseWorkers",_nodeWorkers:"core.nodeWorkers",_workerType:"core._workerType",_worker:"core._workerType",limit:"core.limit",_limitMB:"core._limitMB",batchSize:"core.batchSize",batchDebounceMs:"core.batchDebounceMs",metadata:"core.metadata",transforms:"core.transforms",throws:"nothrow",dataType:"(no longer used)",uri:"core.baseUrl",method:"core.fetch.method",headers:"core.fetch.headers",body:"core.fetch.body",mode:"core.fetch.mode",credentials:"core.fetch.credentials",cache:"core.fetch.cache",redirect:"core.fetch.redirect",referrer:"core.fetch.referrer",referrerPolicy:"core.fetch.referrerPolicy",integrity:"core.fetch.integrity",keepalive:"core.fetch.keepalive",signal:"core.fetch.signal"};var Hp=["baseUrl","fetch","mimeType","fallbackMimeType","ignoreRegisteredLoaders","nothrow","log","useLocalLibraries","CDN","worker","maxConcurrency","maxMobileConcurrency","reuseWorkers","_nodeWorkers","_workerType","limit","_limitMB","batchSize","batchDebounceMs","metadata","transforms"];function Yp(){globalThis.loaders=globalThis.loaders||{};let{loaders:n}=globalThis;return n._state||(n._state={}),n._state}function qp(){let n=Yp();return n.globalOptions=n.globalOptions||{...uu,core:{...uu.core}},_i(n.globalOptions)}function rx(n,e,t,i){return t=t||[],t=Array.isArray(t)?t:[t],VA(n,t),_i(jA(e,n,i))}function _i(n){let e=YA(n);sx(e);for(let t of Hp)e.core&&e.core[t]!==void 0&&delete e[t];return e.core&&e.core._workerType!==void 0&&delete e._worker,e}function VA(n,e){nx(n,null,uu,tx,e);for(let t of e){let i=n&&n[t.id]||{},r=t.options&&t.options[t.id]||{},s=t.deprecatedOptions&&t.deprecatedOptions[t.id]||{};nx(i,t.id,r,s,e)}}function nx(n,e,t,i,r){let s=e||"Top level",o=e?`${e}.`:"";for(let a in n){let c=!e&&Dn(n[a]),l=a==="baseUri"&&!e,u=a==="workerUrl"&&e;if(!(a in t)&&!l&&!u){if(a in i)ha.level>0&&ha.warn(`${s} loader option '${o}${a}' no longer supported, use '${i[a]}'`)();else if(!c&&ha.level>0){let f=WA(a,r);ha.warn(`${s} loader option '${o}${a}' not recognized. ${f}`)()}}}}function WA(n,e){let t=n.toLowerCase(),i="";for(let r of e)for(let s in r.options){if(n===s)return`Did you mean '${r.id}.${s}'?`;let o=s.toLowerCase();(t.startsWith(o)||o.startsWith(t))&&(i=i||`Did you mean '${r.id}.${s}'?`)}return i}function jA(n,e,t){let i=n.options||{},r={...i};i.core&&(r.core={...i.core}),sx(r),r.core?.log===null&&(r.core={...r.core,log:new cu}),ix(r,_i(qp()));let s=_i(e);return ix(r,s),HA(r,t),qA(r),r}function ix(n,e){for(let t in e)if(t in e){let i=e[t];iu(i)&&iu(n[t])?n[t]={...n[t],...e[t]}:n[t]=e[t]}}function HA(n,e){if(!e)return;n.core?.baseUrl!==void 0||(n.core||={},n.core.baseUrl=gi.dirname(Ui(e)))}function YA(n){let e={...n};return n.core&&(e.core={...n.core}),e}function sx(n){n.baseUri!==void 0&&(n.core||={},n.core.baseUrl===void 0&&(n.core.baseUrl=n.baseUri));for(let t of Hp)if(n[t]!==void 0){let r=n.core=n.core||{};r[t]===void 0&&(r[t]=n[t])}let e=n._worker;e!==void 0&&(n.core||={},n.core._workerType===void 0&&(n.core._workerType=e))}function qA(n){let e=n.core;if(e)for(let t of Hp)e[t]!==void 0&&(n[t]=e[t])}function pa(n){return n?(Array.isArray(n)&&(n=n[0]),Array.isArray(n?.extensions)):!1}function ma(n){Fi(n,"null loader"),Fi(pa(n),"invalid loader");let e;return Array.isArray(n)&&(e=n[1],n=n[0],n={...n,options:{...n.options,...e}}),(n?.parseTextSync||n?.parseText)&&(n.text=!0),n.text||(n.binary=!0),n}var ox=()=>{let n=Yp();return n.loaderRegistry=n.loaderRegistry||[],n.loaderRegistry};function Zp(n){let e=ox();n=Array.isArray(n)?n:[n];for(let t of n){let i=ma(t);e.find(r=>i===r)||e.unshift(i)}}function ax(){return ox()}var ZA=/\.([^.]+)$/;async function ux(n,e=[],t,i){if(!fx(n))return null;let r=_i(t||{});if(r.core||={},n instanceof Response&&cx(n)){let o=await n.clone().text(),a=fu(o,e,{...r,core:{...r.core,nothrow:!0}},i);if(a)return a}let s=fu(n,e,{...r,core:{...r.core,nothrow:!0}},i);if(s)return s;if(Mt(n)&&(n=await n.slice(0,10).arrayBuffer(),s=fu(n,e,r,i)),!s&&n instanceof Response&&cx(n)){let o=await n.clone().text();s=fu(o,e,r,i)}if(!s&&!r.core.nothrow)throw new Error(dx(n));return s}function cx(n){let e=Fs(n);return!!(e&&(e.startsWith("text/")||e==="application/json"||e.endsWith("+json")))}function fu(n,e=[],t,i){if(!fx(n))return null;let r=_i(t||{});if(r.core||={},e&&!Array.isArray(e))return ma(e);let s=[];e&&(s=s.concat(e)),r.core.ignoreRegisteredLoaders||s.push(...ax()),KA(s);let o=XA(n,s,r,i);if(!o&&!r.core.nothrow)throw new Error(dx(n));return o}function XA(n,e,t,i){let r=Sr(n),s=Fs(n),o=Ui(r)||i?.url,a=null,c="";return t?.core?.mimeType&&(a=Xp(e,t?.core?.mimeType),c=`match forced by supplied MIME type ${t?.core?.mimeType}`),a=a||QA(e,o),c=c||(a?`matched url ${o}`:""),a=a||Xp(e,s),c=c||(a?`matched MIME type ${s}`:""),a=a||ek(e,n),c=c||(a?`matched initial data ${hx(n)}`:""),t?.core?.fallbackMimeType&&(a=a||Xp(e,t?.core?.fallbackMimeType),c=c||(a?`matched fallback MIME type ${s}`:"")),c&&Ep.log(1,`selectLoader selected ${a?.name}: ${c}.`),a}function fx(n){return!(n instanceof Response&&n.status===204)}function dx(n){let e=Sr(n),t=Fs(n),i="No valid loader found (";i+=e?`${gi.filename(e)}, `:"no url provided, ",i+=`MIME type: ${t?`"${t}"`:"not provided"}, `;let r=n?hx(n):"";return i+=r?` first bytes: "${r}"`:"first bytes: not available",i+=")",i}function KA(n){for(let e of n)ma(e)}function QA(n,e){let t=e&&ZA.exec(e),i=t&&t[1];return i?JA(n,i):null}function JA(n,e){e=e.toLowerCase();for(let t of n)for(let i of t.extensions)if(i.toLowerCase()===e)return t;return null}function Xp(n,e){for(let t of n)if(t.mimeTypes?.some(i=>Vp(e,i))||Vp(e,`application/x.${t.id}`))return t;return null}function ek(n,e){if(!e)return null;for(let t of n)if(typeof e=="string"){if(tk(e,t))return t}else if(ArrayBuffer.isView(e)){if(lx(e.buffer,e.byteOffset,t))return t}else if(e instanceof ArrayBuffer&&lx(e,0,t))return t;return null}function tk(n,e){return e.testText?e.testText(n):(Array.isArray(e.tests)?e.tests:[e.tests]).some(i=>n.startsWith(i))}function lx(n,e,t){return(Array.isArray(t.tests)?t.tests:[t.tests]).some(r=>nk(n,e,t,r))}function nk(n,e,t,i){if(Os(i))return Op(i,n,i.byteLength);switch(typeof i){case"function":return i(fa(n));case"string":let r=Kp(n,e,i.length);return i===r;default:return!1}}function hx(n,e=5){return typeof n=="string"?n.slice(0,e):ArrayBuffer.isView(n)?Kp(n.buffer,n.byteOffset,e):n instanceof ArrayBuffer?Kp(n,0,e):""}function Kp(n,e,t){if(n.byteLengthjp(s,r):e?.fetch?e?.fetch:jp}function vx(n,e,t){if(t)return t;let i={fetch:du(e,n),...n};if(i.url){let r=Ui(i.url);i.baseUrl=r,i.queryString=Kv(i.url),i.filename=gi.filename(r),i.baseUrl=gi.dirname(r)}return Array.isArray(i.loaders)||(i.loaders=null),i}function xx(n,e){if(n&&!Array.isArray(n))return n;let t;if(n&&(t=Array.isArray(n)?n:[n]),e&&e.loaders){let i=Array.isArray(e.loaders)?e.loaders:[e.loaders];t=t?[...t,...i]:i}return t&&t.length?t:void 0}async function ga(n,e,t,i){e&&!Array.isArray(e)&&!pa(e)&&(i=void 0,t=e,e=void 0),n=await n,t=t||{};let r=Sr(n),o=xx(e,i),a=await ux(n,o,t);if(!a)return null;let c=rx(t,a,o,r);return i=vx({url:r,_parse:ga,loaders:o},c,i||null),await ak(a,n,c,i)}async function ak(n,e,t,i){if(Rp(n),t=Tp(n.options,t),Lt(e)){let{ok:s,redirected:o,status:a,statusText:c,type:l,url:u}=e,f=Object.fromEntries(e.headers.entries());i.response={headers:f,ok:s,redirected:o,status:a,statusText:c,type:l,url:u}}e=await bx(e,n,t);let r=n;if(r.parseTextSync&&typeof e=="string")return r.parseTextSync(e,t,i);if(Ip(n,t))return await Bp(n,e,t,i,ga);if(r.parseText&&typeof e=="string")return await r.parseText(e,t,i);if(r.parse)return await r.parse(e,t,i);throw lt(!r.parseSync),new Error(`${n.id} loader - no parser found and worker is disabled`)}async function zs(n,e,t,i){let r,s;!Array.isArray(e)&&!pa(e)?(r=[],s=e,i=void 0):(r=e,s=t);let o=du(s),a=n;return typeof n=="string"&&(a=await o(n)),Mt(n)&&(a=await o(n)),typeof n=="string"&&(_i(s||{}).core?.baseUrl||(s={...s,core:{...s?.core,baseUrl:n}})),Array.isArray(r)?await ga(a,r,s):await ga(a,r,s)}var Px="4.5.4";var ck=globalThis.loaders?.parseImageNode,em=typeof Image<"u",tm=typeof ImageBitmap<"u",lk=!!ck,nm=br?!0:lk;function Cx(n){switch(n){case"auto":return tm||em||nm;case"imagebitmap":return tm;case"image":return em;case"data":return nm;default:throw new Error(`@loaders.gl/images: image ${n} not supported in this environment`)}}function Tx(){if(tm)return"imagebitmap";if(em)return"image";if(nm)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function uk(n){let e=fk(n);if(!e)throw new Error("Not an image");return e}function Lx(n){switch(uk(n)){case"data":return n;case"image":case"imagebitmap":let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)throw new Error("getImageData");return e.width=n.width,e.height=n.height,t.drawImage(n,0,0),t.getImageData(0,0,n.width,n.height);default:throw new Error("getImageData")}}function fk(n){return typeof ImageBitmap<"u"&&n instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&n instanceof Image?"image":n&&typeof n=="object"&&n.data&&n.width&&n.height?"data":null}var dk=/^data:image\/svg\+xml/,hk=/\.svg((\?|#).*)?$/;function hu(n){return n&&(dk.test(n)||hk.test(n))}function Mx(n,e){if(hu(e)){let i=new TextDecoder().decode(n);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(i=unescape(encodeURIComponent(i)))}catch(s){throw new Error(s.message)}return`data:image/svg+xml;base64,${btoa(i)}`}return im(n,e)}function im(n,e){if(hu(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(n)])}async function pu(n,e,t){let i=Mx(n,t),r=self.URL||self.webkitURL,s=typeof i!="string"&&r.createObjectURL(i);try{return await pk(s||i,e)}finally{s&&r.revokeObjectURL(s)}}async function pk(n,e){let t=new Image;return t.src=n,e.image&&e.image.decode&&t.decode?(await t.decode(),t):await new Promise((i,r)=>{try{t.onload=()=>i(t),t.onerror=s=>{let o=s instanceof Error?s.message:"error";r(new Error(o))}}catch(s){r(s)}})}var Ax=!0;async function kx(n,e,t){let i;hu(t)?i=await pu(n,e,t):i=im(n,t);let r=e&&e.imagebitmap;return await mk(i,r)}async function mk(n,e=null){if((gk(e)||!Ax)&&(e=null),e)try{return await createImageBitmap(n,e)}catch(t){console.warn(t),Ax=!1}return await createImageBitmap(n)}function gk(n){if(!n)return!0;for(let e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}function Rx(n){return!vk(n,"ftyp",4)||!(n[8]&96)?null:_k(n)}function _k(n){switch(yk(n,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function yk(n,e,t){return String.fromCharCode(...n.slice(e,t))}function bk(n){return[...n].map(e=>e.charCodeAt(0))}function vk(n,e,t=0){let i=bk(e);for(let r=0;r=24&&e.getUint32(0,Fn)===2303741511?{mimeType:"image/png",width:e.getUint32(16,Fn),height:e.getUint32(20,Fn)}:null}function Ek(n){let e=ba(n);return e.byteLength>=10&&e.getUint32(0,Fn)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,ya),height:e.getUint16(8,ya)}:null}function Sk(n){let e=ba(n);return e.byteLength>=14&&e.getUint16(0,Fn)===16973&&e.getUint32(2,ya)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,ya),height:e.getUint32(22,ya)}:null}function Pk(n){let e=ba(n);if(!(e.byteLength>=3&&e.getUint16(0,Fn)===65496&&e.getUint8(2)===255))return null;let{tableMarkers:i,sofMarkers:r}=Ck(),s=2;for(;s+9!!mu(new DataView(n))],options:Ak};sa();var kk=new ct({id:"deck"}),ae=kk;var sm={};function Ox(n){sm=n}function Fe(n,e,t,i){ae.level>0&&sm[n]&&sm[n].call(null,e,t,i)}function Rk(n){let e=n[0],t=n[n.length-1];return e==="{"&&t==="}"||e==="["&&t==="]"}var Dx={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:Rk,parseTextSync:JSON.parse};function Ik(){let n="9.4.0",e=globalThis.deck&&globalThis.deck.VERSION;if(e&&e!==n)throw new Error(`deck.gl - multiple versions detected: ${e} vs ${n}`);return e||(ae.log(1,`deck.gl ${n}`)(),globalThis.deck={...globalThis.deck,VERSION:n,version:n,log:ae,_registerLoggers:Ox},Zp([Dx,[rm,{imagebitmap:{premultiplyAlpha:"none"}}]])),n}var Nx=Ik();vt();var A4=`struct LayerUniforms { opacity: f32, }; @@ -3291,13 +3291,13 @@ var layer: LayerUniforms; `,vS=`layout(std140) uniform layerUniforms { uniform float opacity; } layer; -`,s_={name:"layer",source:T4,vs:vS,fs:vS,getUniforms:n=>({opacity:Math.pow(n.opacity,.45454545454545453)}),uniformTypes:{opacity:"f32"}};var L4=` +`,s_={name:"layer",source:A4,vs:vS,fs:vS,getUniforms:n=>({opacity:Math.pow(n.opacity,.45454545454545453)}),uniformTypes:{opacity:"f32"}};var k4=` @must_use fn deckgl_premultiplied_alpha(fragColor: vec4) -> vec4 { return vec4(fragColor.rgb * fragColor.a, fragColor.a); }; -`,Vn={name:"color",dependencies:[],source:L4,getUniforms:n=>({})};var M4=`const SMOOTH_EDGE_RADIUS: f32 = 0.5; +`,Vn={name:"color",dependencies:[],source:k4,getUniforms:n=>({})};var R4=`const SMOOTH_EDGE_RADIUS: f32 = 0.5; struct VertexGeometry { position: vec4, @@ -3326,7 +3326,7 @@ var fragmentGeometry: FragmentGeometry; fn smoothedge(edge: f32, x: f32) -> f32 { return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x); } -`,xS="#define SMOOTH_EDGE_RADIUS 0.5",A4=`${xS} +`,xS="#define SMOOTH_EDGE_RADIUS 0.5",I4=`${xS} struct VertexGeometry { vec4 position; @@ -3343,7 +3343,7 @@ struct VertexGeometry { vec2(0.0), vec3(0.0) ); -`,k4=`${xS} +`,B4=`${xS} struct FragmentGeometry { vec2 uv; @@ -3353,9 +3353,9 @@ FragmentGeometry geometry; float smoothedge(float edge, float x) { return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x); } -`,ff={name:"geometry",source:M4,vs:A4,fs:k4};vt();ze();var ne;(function(n){n[n.Start=1]="Start",n[n.Move=2]="Move",n[n.End=4]="End",n[n.Cancel=8]="Cancel"})(ne||(ne={}));var Le;(function(n){n[n.None=0]="None",n[n.Left=1]="Left",n[n.Right=2]="Right",n[n.Up=4]="Up",n[n.Down=8]="Down",n[n.Horizontal=3]="Horizontal",n[n.Vertical=12]="Vertical",n[n.All=15]="All"})(Le||(Le={}));var H;(function(n){n[n.Possible=1]="Possible",n[n.Began=2]="Began",n[n.Changed=4]="Changed",n[n.Ended=8]="Ended",n[n.Recognized=8]="Recognized",n[n.Cancelled=16]="Cancelled",n[n.Failed=32]="Failed"})(H||(H={}));var wS="compute",o_="auto",jr="manipulation",Hr="none",Qa="pan-x",Ja="pan-y";function a_(n){if(n.includes(Hr))return Hr;let e=n.includes(Qa),t=n.includes(Ja);return e&&t?Hr:e||t?e?Qa:Ja:n.includes(jr)?jr:o_}var ec=class{constructor(e,t){this.actions="",this.manager=e,this.set(t)}set(e){e===wS&&(e=this.compute()),this.manager.element&&(this.manager.element.style.touchAction=e,this.actions=e)}update(){this.set(this.manager.options.touchAction)}compute(){let e=[];for(let t of this.manager.recognizers)t.options.enable&&(e=e.concat(t.getTouchAction()));return a_(e.join(" "))}};function to(n){return n.trim().split(/\s+/g)}function df(n,e,t){if(n)for(let i of to(e))n.addEventListener(i,t,!1)}function hf(n,e,t){if(n)for(let i of to(e))n.removeEventListener(i,t,!1)}function c_(n){return(n.ownerDocument||n).defaultView}function l_(n,e){let t=n;for(;t;){if(t===e)return!0;t=t.parentNode}return!1}function pf(n){let e=n.length;if(e===1)return{x:Math.round(n[0].clientX),y:Math.round(n[0].clientY)};let t=0,i=0,r=0;for(;r=Math.abs(e)?n<0?Le.Left:Le.Right:e<0?Le.Up:Le.Down}function SS(n,e){let t=e.center,i=n.offsetDelta,r=n.prevDelta,s=n.prevInput;return(e.eventType===ne.Start||s?.eventType===ne.End)&&(r=n.prevDelta={x:s?.deltaX||0,y:s?.deltaY||0},i=n.offsetDelta={x:t.x,y:t.y}),{deltaX:r.x+(t.x-i.x),deltaY:r.y+(t.y-i.y)}}function mf(n,e,t){return{x:e/n||0,y:t/n||0}}function PS(n,e){return tc(e[0],e[1])/tc(n[0],n[1])}function CS(n,e){return f_(e[1],e[0])-f_(n[1],n[0])}function TS(n,e){let t=n.lastInterval||e,i=e.timeStamp-t.timeStamp,r,s,o,a;if(e.eventType!==ne.Cancel&&(i>25||t.velocity===void 0)){let c=e.deltaX-t.deltaX,l=e.deltaY-t.deltaY,u=mf(i,c,l);s=u.x,o=u.y,r=Math.abs(u.x)>Math.abs(u.y)?u.x:u.y,a=io(c,l),n.lastInterval=e}else r=t.velocity,s=t.velocityX,o=t.velocityY,a=t.direction;e.velocity=r,e.velocityX=s,e.velocityY=o,e.direction=a}function d_(n,e){return"pointerId"in n?n.pointerId:e}function LS(n,e){n.movementOrigin=new Map(e.map((t,i)=>[d_(t,i),{clientX:t.clientX,clientY:t.clientY}])),n.firstMovementTime=void 0}function I4(n,e){let t=e.pointers.map(d_);if(n.movementOrigin?.size===t.length&&t.every(r=>n.movementOrigin.has(r))||LS(n,e.pointers),e.distancePerPointer=e.pointers.map((r,s)=>tc(n.movementOrigin.get(t[s]),r)),e.eventType&ne.Move&&e.distancePerPointer.some(r=>r>0)&&(n.firstMovementTime??(n.firstMovementTime=e.timeStamp)),e.movementDeltaTime=n.firstMovementTime===void 0?0:e.timeStamp-n.firstMovementTime,e.eventType&(ne.End|ne.Cancel)){let r=e.changedPointers.map(s=>d_(s,e.pointers.indexOf(s)));LS(n,e.pointers.filter((s,o)=>!r.includes(t[o])))}}function MS(n,e){let{session:t}=n,{pointers:i}=e,{length:r}=i;t.firstInput||(t.firstInput=u_(e)),r>1&&!t.firstMultiple?t.firstMultiple=u_(e):r===1&&(t.firstMultiple=!1);let{firstInput:s,firstMultiple:o}=t,a=o?o.center:s.center,c=e.center=pf(i);e.timeStamp=Date.now(),e.deltaTime=e.timeStamp-s.timeStamp,I4(t,e),e.angle=ES(a,c),e.distance=no(a,c);let{deltaX:l,deltaY:u}=SS(t,e);e.deltaX=l,e.deltaY=u,e.offsetDirection=io(e.deltaX,e.deltaY);let f=mf(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=f.x,e.overallVelocityY=f.y,e.overallVelocity=Math.abs(f.x)>Math.abs(f.y)?f.x:f.y,e.scale=o?PS(o.pointers,i):1,e.rotation=o?CS(o.pointers,i):0,e.maxPointers=t.prevInput?e.pointers.length>t.prevInput.maxPointers?e.pointers.length:t.prevInput.maxPointers:e.pointers.length;let d=n.element;return l_(e.srcEvent.target,d)&&(d=e.srcEvent.target),e.target=d,TS(t,e),e}function AS(n,e,t){let i=t.pointers.length,r=t.changedPointers.length,s=e&ne.Start&&i-r===0,o=e&(ne.End|ne.Cancel)&&i-r===0;t.isFirst=!!s,t.isFinal=!!o,s&&(n.session={}),t.eventType=e;let a=MS(n,t);n.emit("hammer.input",a),n.recognize(a),n.session.prevInput=a}var nc=class{constructor(e){this.evEl="",this.evWin="",this.evTarget="",this.domHandler=t=>{this.manager.options.enable&&this.handler(t)},this.manager=e,this.element=e.element,this.target=e.options.inputTarget||e.element}callback(e,t){AS(this.manager,e,t)}init(){df(this.element,this.evEl,this.domHandler),df(this.target,this.evTarget,this.domHandler),df(c_(this.element),this.evWin,this.domHandler)}destroy(){hf(this.element,this.evEl,this.domHandler),hf(this.target,this.evTarget,this.domHandler),hf(c_(this.element),this.evWin,this.domHandler)}};var B4={pointerdown:ne.Start,pointermove:ne.Move,pointerup:ne.End,pointercancel:ne.Cancel,pointerout:ne.Cancel},O4="pointerdown",D4="pointermove pointerup pointercancel",ic=class extends nc{constructor(e){super(e),this.evEl=O4,this.evWin=D4,this.store=this.manager.session.pointerEvents=[],this.init()}handler(e){let{store:t}=this,i=!1,r=B4[e.type],s=e.pointerType,o=s==="touch",a=t.findIndex(c=>c.pointerId===e.pointerId);r&ne.Start&&(e.buttons||o)?a<0&&(t.push(e),a=t.length-1):r&(ne.End|ne.Cancel)&&(i=!0),!(a<0)&&(t[a]=e,this.callback(r,{pointers:t,changedPointers:[e],eventType:r,pointerType:s,srcEvent:e}),i&&t.splice(a,1))}};var N4=["","webkit","Moz","MS","ms","o"];function kS(n,e){let t=e[0].toUpperCase()+e.slice(1);for(let i of N4){let r=i?i+t:e;if(r in n)return r}}var F4=1,RS=2,IS={touchAction:"compute",enable:!0,inputTarget:null,cssProps:{userSelect:"none",userDrag:"none",touchCallout:"none",tapHighlightColor:"rgba(0,0,0,0)"}},rc=class{constructor(e,t){this.options={...IS,...t,cssProps:{...IS.cssProps,...t.cssProps},inputTarget:t.inputTarget||e},this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=new ic(this),this.touchAction=new ec(this,this.options.touchAction),this.toggleCssProps(!0)}set(e){return Object.assign(this.options,e),e.touchAction&&this.touchAction.update(),e.inputTarget&&(this.input.destroy(),this.input.target=e.inputTarget,this.input.init()),this}stop(e){this.session.stopped=e?RS:F4}recognize(e){let{session:t}=this;if(t.stopped)return;this.session.prevented&&e.srcEvent.preventDefault();let i,{recognizers:r}=this,{curRecognizer:s}=t;(!s||s&&s.state&H.Recognized)&&(s=t.curRecognizer=null);let o=0;for(;o-1&&this.requireFail.splice(i,1)}return this}hasRequireFailures(){return!!this.requireFail.find(e=>e.options.enable)}canRecognizeWith(e){return!!this.simultaneous[e.id]}emit(e){if(!e)return;let{state:t}=this;t=H.Ended&&this.manager.emit(this.options.event+h_(t),e)}tryEmit(e){this.canEmit()?this.emit(e):this.state=H.Failed}canEmit(){let e=0;for(;e=e.distance)&&(e.distancePerPointer===void 0||n.distancePerPointer.length>0&&n.distancePerPointer.every(t=>t>=e.distancePerPointer))&&(e.movementDeltaTime===void 0||n.movementDeltaTime>=e.movementDeltaTime)&&(e.rotation===void 0||U4(n.rotation)>=e.rotation)&&(e.scale===void 0||Math.abs(n.scale-1)>=e.scale)}var Yr=class extends dn{attrTest(e){let t=this.options.pointers;return t===0||e.pointers.length===t}coherentTest(e){let t=this.options.coherent;return!t?.length||t.some(i=>$4(e,i))}process(e){let{state:t}=this,{eventType:i}=e,r=t&(H.Began|H.Changed),s=this.attrTest(e);return r&&(i&ne.Cancel||!s)?t|H.Cancelled:r||s?i&ne.End?t|H.Ended:t&H.Began?t|H.Changed:H.Began:H.Failed}};var G4=["","start","move","end","cancel"],ro=class extends dn{constructor(e={}){super({enable:!0,event:"doubleclickdrag",pointers:1,interval:500,time:350,threshold:28,dragThreshold:1,pixelsPerScale:120,...e}),this._tapStart=null,this._lastTap=null,this._drag=null,this._emittedStart=!1}getTouchAction(){return[jr]}getEventNames(){return G4.map(e=>this.options.event+e)}process(e){let{options:t}=this;return e.pointers.length===t.pointers?e.eventType&ne.Start?this._handleStart(e):e.eventType&ne.Move?this._handleMove(e):e.eventType&ne.Cancel?this._handleEnd(e,!0):e.eventType&ne.End?this._handleEnd(e,!1):H.Failed:(this.reset(),H.Failed)}reset(){this._tapStart=null,this._lastTap=null,this._drag=null,this._emittedStart=!1}emit(e){if(e){if(this.state===H.Began){if(!this._drag?.active||this._emittedStart)return;this._emittedStart=!0,this.manager.emit(`${this.options.event}start`,e),this.manager.emit(this.options.event,e);return}if(this.state===H.Changed){if(!this._emittedStart)return;this.manager.emit(`${this.options.event}move`,e),this.manager.emit(this.options.event,e);return}if(this.state===H.Ended){if(!this._emittedStart)return;this.manager.emit(this.options.event,e),this.manager.emit(`${this.options.event}end`,e),this._emittedStart=!1;return}if(this.state===H.Cancelled){if(!this._emittedStart)return;this.manager.emit(this.options.event,e),this.manager.emit(`${this.options.event}cancel`,e),this._emittedStart=!1}}}_handleStart(e){let t=this._getPointerId(e);return this._lastTap&&this._isTapMatch(e,this._lastTap)?(this._tapStart=null,this._lastTap=null,this._drag={startCenter:e.center,pointerId:t,active:!1},this._emittedStart=!1,H.Began):(this._tapStart={center:e.center,timeStamp:e.timeStamp,pointerId:t},this._lastTap=null,this._drag=null,this._emittedStart=!1,H.Failed)}_handleMove(e){if(!this._drag||!this._isSamePointer(e,this._drag.pointerId))return H.Failed;let t=this._drag.startCenter.y-e.center.y;return!this._drag.active&&Math.abs(t){this.state=H.Recognized,this.tryEmit(this._input)},t.interval),H.Began):H.Recognized}return H.Failed}failTimeout(){return this._timer=setTimeout(()=>{this.state=H.Failed},this.options.interval),H.Failed}reset(){clearTimeout(this._timer)}emit(e){this.state===H.Recognized&&(e.tapCount=this.count,this.manager.emit(this.options.event,e))}};var so=class extends Yr{constructor(){super(...arguments),this.wheelSession=null,this.wheelSessionUnsubscribe=null,this.handleWheelSessionEvent=e=>{e.device==="trackpad"&&this.handleTrackpadEvent(e)}}set(e){let{wheelSession:t,...i}=e;return t&&t!==this.wheelSession&&(this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=null,this.wheelSession=t),super.set(i),this.updateWheelSessionSubscription(),this}getTrackpadInput(e,t={}){let{srcEvent:i}=e,r=t.deltaX??e.deltaX,s=t.deltaY??e.deltaY,o=io(r,s),a=Math.sqrt(e.deltaX*e.deltaX+e.deltaY*e.deltaY),c=i;return{pointers:[c,c],changedPointers:[c,c],pointerType:"trackpad",srcEvent:c,eventType:e.eventType,timeStamp:e.timeStamp,deltaTime:e.deltaTime,center:e.center,deltaX:r,deltaY:s,angle:Math.atan2(s,r)*180/Math.PI,distance:Math.sqrt(r*r+s*s),distancePerPointer:[a,a],movementDeltaTime:e.deltaTime,scale:1,rotation:0,direction:o,offsetDirection:o,velocity:e.velocity,velocityX:e.velocityX,velocityY:e.velocityY,overallVelocity:e.overallVelocity,overallVelocityX:e.overallVelocityX,overallVelocityY:e.overallVelocityY,maxPointers:2,target:i.target||this.manager.element,additionalEvent:"",...t}}updateWheelSessionSubscription(){let e=!!(this.wheelSession&&this.options.enable&&this.options.trackpad&&this.options.pointers===2);e&&!this.wheelSessionUnsubscribe?this.wheelSessionUnsubscribe=this.wheelSession.on(this.handleWheelSessionEvent):!e&&this.wheelSessionUnsubscribe&&(this.wheelSessionUnsubscribe(),this.wheelSessionUnsubscribe=null)}};var V4=["","start","move","end","cancel","up","down","left","right"],Xi=class extends so{constructor(e={}){super({enable:!0,pointers:1,event:"pan",threshold:10,direction:Le.All,trackpad:!1,coherent:[],...e}),this.trackpadGesture=!1,this.pX=null,this.pY=null}getTouchAction(){let{options:{direction:e}}=this,t=[];return e&Le.Horizontal&&t.push(Ja),e&Le.Vertical&&t.push(Qa),t}getEventNames(){return V4.map(e=>this.options.event+e)}directionTest(e){let{options:t}=this,i=!0,{distance:r}=e,{direction:s}=e,o=e.deltaX,a=e.deltaY;return s&t.direction||(t.direction&Le.Horizontal?(s=o===0?Le.None:o<0?Le.Left:Le.Right,i=o!==this.pX,r=Math.abs(e.deltaX)):(s=a===0?Le.None:a<0?Le.Up:Le.Down,i=a!==this.pY,r=Math.abs(e.deltaY))),e.direction=s,i&&r>t.threshold&&!!(s&t.direction)}attrTest(e){let t=!!(this.state&H.Began),i=!(this.options.coherent?.length&&e.eventType&(ne.End|ne.Cancel));return super.attrTest(e)&&(t||i&&this.coherentTest(e)&&this.directionTest(e))}emit(e){this.pX=e.deltaX,this.pY=e.deltaY;let t=Le[e.direction].toLowerCase();t&&(e.additionalEvent=this.options.event+t),super.emit(e)}handleTrackpadEvent(e){e.isFirst&&(this.trackpadGesture=!e.srcEvent.ctrlKey,!this.trackpadGesture&&this.state&(H.Recognized|H.Cancelled|H.Failed)&&(this.state=H.Possible)),this.trackpadGesture&&(this.recognize(this.getTrackpadInput(e,{deltaX:-e.deltaX,deltaY:-e.deltaY,velocity:-e.velocity,velocityX:-e.velocityX,velocityY:-e.velocityY,overallVelocity:-e.overallVelocity,overallVelocityX:-e.overallVelocityX,overallVelocityY:-e.overallVelocityY})),e.isFinal&&(this.trackpadGesture=!1))}};var W4=["","start","move","end","cancel","in","out"],oo=class extends so{constructor(e={}){super({enable:!0,event:"pinch",threshold:0,pointers:2,trackpad:!1,coherent:[],...e}),this.trackpadGesture=!1}getTouchAction(){return[Hr]}getEventNames(){return W4.map(e=>this.options.event+e)}attrTest(e){let t=!!this.options.coherent?.length,i=!!(this.state&H.Began),r=!(t&&e.eventType&(ne.End|ne.Cancel));return super.attrTest(e)&&(i||r&&(t?this.coherentTest(e):Math.abs(e.scale-1)>this.options.threshold))}emit(e){if(e.scale!==1){let t=e.scale<1?"in":"out";e.additionalEvent=this.options.event+t}super.emit(e)}handleTrackpadEvent(e){e.isFirst&&(this.trackpadGesture=e.srcEvent.ctrlKey,!this.trackpadGesture&&this.state&(H.Recognized|H.Cancelled|H.Failed)&&(this.state=H.Possible)),this.trackpadGesture&&(this.recognize(this.getTrackpadInput(e,{deltaX:0,deltaY:0,velocity:0,velocityX:0,velocityY:0,overallVelocity:0,overallVelocityX:0,overallVelocityY:0,scale:Math.exp(-e.deltaY/100)})),e.isFinal&&(this.trackpadGesture=!1))}};var Wn=class{constructor(e,t,i){this.element=e,this.callback=t,this.options=i}listen(e,t){t?this.element.addEventListener(e,this.handleEvent,{passive:!1}):this.element.removeEventListener(e,this.handleEvent)}};var OS=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"";var q4=OS.indexOf("firefox")!==-1,Z4=40,X4=.25,gf=class extends Wn{constructor(e,t,i){i.enable=i.enable??!1,super(e,t,i),this.handleEvent=r=>{if(!this.options.enable)return;let s=r.deltaY;globalThis.WheelEvent&&(q4&&r.deltaMode===globalThis.WheelEvent.DOM_DELTA_PIXEL&&(s/=globalThis.devicePixelRatio),r.deltaMode===globalThis.WheelEvent.DOM_DELTA_LINE&&(s*=Z4)),r.shiftKey&&s&&(s=s*X4),this.callback({type:"wheel",center:{x:r.clientX,y:r.clientY},delta:-s,device:this.options.wheelSession?.device??"unknown",srcEvent:r,pointerType:"mouse",target:r.target})},i.enable&&(this.wheelSessionUnsubscribe=this.options.wheelSession?.on(()=>{}),this.listen("wheel",!0))}destroy(){this.listen("wheel",!1),this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=void 0}enableEventType(e,t){e==="wheel"&&this.options.enable!==t&&(this.options.enable=t,t&&!this.wheelSessionUnsubscribe&&(this.wheelSessionUnsubscribe=this.options.wheelSession?.on(()=>{})),this.listen("wheel",t),t||(this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=void 0))}};var K4=4.000244140625,DS=40,Q4=0,J4=1,eN=40,NS=40,tN=120,nN={classificationDelay:32,endDelay:80},_f=class{constructor(e,t={}){this.subscriptions=new Map,this.session=null,this.classificationTimer=null,this.endTimer=null,this.pressedControlKeys=new Set,this.listeningForControlKeys=!1,this.handleEvent=i=>{if(!this.hasSubscribers)return"unknown";let r=rN(i,this.pressedControlKeys.size>0),s=this.session;if(s&&r.timeStamp-s.lastTimeStamp>=this.options.endDelay){if(this.end(),!this.hasSubscribers)return"unknown";s=null}s?(this.scheduleEnd(),this.addSample(s,r)):(s=this.startPendingSession(r),this.scheduleEnd());let{device:o}=s;return o==="unknown"&&(o=p_(s.samples,!1),o!=="unknown"&&this.begin(s,o)),o},this.finishClassification=()=>{if(this.classificationTimer=null,!this.session||this.session.device!=="unknown")return;let i=this.session,r=p_(i.samples,!0);this.begin(i,r==="unknown"?"mouse":r)},this.end=()=>{if(!this.session)return;if(this.session.device==="unknown"){let r=this.session,s=p_(r.samples,!0);this.begin(r,s==="unknown"?"mouse":s)}if(!this.session)return;let i=this.session;this.emit(ne.End,i.lastEvent),this.reset()},this.handleKeyDown=i=>{i.key==="Control"&&this.pressedControlKeys.add(i.code||i.key)},this.handleKeyUp=i=>{i.key==="Control"&&(i.code?this.pressedControlKeys.delete(i.code):this.pressedControlKeys.clear())},this.handleWindowBlur=()=>{this.pressedControlKeys.clear()},this.element=e,this.options={...nN,...t},this.element?.addEventListener("wheel",this.handleEvent,{passive:!0})}get hasSubscribers(){return this.subscriptions.size>0}get device(){return this.session?.device??"unknown"}on(e){let t={listener:e};return this.subscriptions.set(e,t),this.updateControlKeyEventListeners(),()=>{this.subscriptions.get(e)===t&&this.off(e)}}off(e){this.subscriptions.delete(e),this.updateControlKeyEventListeners(),this.hasSubscribers||this.reset()}cancel(){let e=this.session;e&&e.device!=="unknown"&&this.emit(ne.Cancel,e.lastEvent),this.reset()}destroy(){this.cancel(),this.subscriptions.clear(),this.updateControlKeyEventListeners(),this.element?.removeEventListener("wheel",this.handleEvent)}startPendingSession(e){let t={samples:[e],device:"unknown",firstTimeStamp:e.timeStamp,lastTimeStamp:e.timeStamp,totalDeltaX:e.deltaX,totalDeltaY:e.deltaY,velocityX:0,velocityY:0,lastEvent:e.event};return this.session=t,this.classificationTimer=globalThis.setTimeout(this.finishClassification,this.options.classificationDelay),t}addSample(e,t){if(e.samples.push(t),e.lastTimeStamp=t.timeStamp,e.lastEvent=t.event,e.totalDeltaX+=t.deltaX,e.totalDeltaY+=t.deltaY,e.device!=="unknown"){let i=e.samples[e.samples.length-2],r=t.timeStamp-i.timeStamp;e.velocityX=r>0?t.deltaX/r:0,e.velocityY=r>0?t.deltaY/r:0,this.emit(ne.Move,t.event,{velocityX:e.velocityX,velocityY:e.velocityY})}}begin(e,t){e.device=t,this.clearClassificationTimer(),this.emit(ne.Start,e.samples[0].event);let i=e.lastTimeStamp-e.firstTimeStamp;e.velocityX=i>0?e.totalDeltaX/i:0,e.velocityY=i>0?e.totalDeltaY/i:0,this.emit(ne.Move,e.lastEvent,{velocityX:e.velocityX,velocityY:e.velocityY})}scheduleEnd(){this.clearEndTimer(),this.endTimer=globalThis.setTimeout(this.end,this.options.endDelay)}emit(e,t,i){let r=this.session;if(!r||r.device==="unknown")return;let s=e===ne.Start,o=e===ne.End||e===ne.Cancel,a=s?r.firstTimeStamp:r.lastTimeStamp,c=s?0:Math.max(0,a-r.firstTimeStamp),l=s?0:r.totalDeltaX,u=s?0:r.totalDeltaY,f=c>0?l/c:0,d=c>0?u/c:0,h=s?0:i?.velocityX??r.velocityX,p=s?0:i?.velocityY??r.velocityY,m={eventType:e,device:r.device,srcEvent:t,timeStamp:a,center:{x:t.clientX,y:t.clientY},deltaX:l,deltaY:u,deltaTime:c,velocity:Math.abs(h)>Math.abs(p)?h:p,velocityX:h,velocityY:p,overallVelocity:Math.abs(f)>Math.abs(d)?f:d,overallVelocityX:f,overallVelocityY:d,isFirst:s,isFinal:o};for(let{listener:g}of[...this.subscriptions.values()])g(m)}reset(){this.clearClassificationTimer(),this.clearEndTimer(),this.session=null}clearClassificationTimer(){this.classificationTimer!==null&&(globalThis.clearTimeout(this.classificationTimer),this.classificationTimer=null)}clearEndTimer(){this.endTimer!==null&&(globalThis.clearTimeout(this.endTimer),this.endTimer=null)}updateControlKeyEventListeners(){let e=this.hasSubscribers,t=iN();!t||e===this.listeningForControlKeys||(this.listeningForControlKeys=e,e?(t.addEventListener("keydown",this.handleKeyDown,!0),t.addEventListener("keyup",this.handleKeyUp,!0),t.addEventListener("blur",this.handleWindowBlur)):(t.removeEventListener("keydown",this.handleKeyDown,!0),t.removeEventListener("keyup",this.handleKeyUp,!0),t.removeEventListener("blur",this.handleWindowBlur),this.pressedControlKeys.clear()))}};function iN(){return typeof window<"u"?window:globalThis.document?.defaultView}function rN(n,e){let t=n.deltaX,i=n.deltaY;return n.deltaMode===J4&&(t*=DS,i*=DS),{event:n,timeStamp:n.timeStamp,deltaX:t,deltaY:i,isControlKeyDown:e}}function p_(n,e){return n.some(({event:t,isControlKeyDown:i})=>t.ctrlKey&&!i)?"trackpad":n.some(({event:t})=>t.deltaMode!==Q4)||n.some(sN)||n.every(({event:t})=>{let i=t.wheelDelta;return i!==void 0&&Math.abs(i)%40===0})?"mouse":n.some(({deltaX:t})=>t!==0)||n.length>1&&oN(n)?"trackpad":e?"mouse":"unknown"}function sN({event:n,deltaX:e,deltaY:t}){if(e!==0||t===0)return!1;let i=Math.abs(t/K4);if(Number.isInteger(i))return!0;let r=n.wheelDelta;return typeof r=="number"&&r!==0&&r%tN===0}function oN(n){for(let e=0;eNS||Math.abs(t.deltaY)>NS||e>0&&t.timeStamp-n[e-1].timeStamp>eN)return!1}return!0}var FS=["mousedown","mousemove","mouseup","mouseover","mouseout","mouseenter","mouseleave"],yf=class extends Wn{constructor(e,t,i){super(e,t,{enable:!0,...i}),this.handleEvent=s=>{this.handleOverEvent(s),this.handleOutEvent(s),this.handleEnterEvent(s),this.handleLeaveEvent(s),this.handleMoveEvent(s)},this.pressed=!1;let{enable:r=!1}=this.options;this.enableMoveEvent=r,this.enableLeaveEvent=r,this.enableEnterEvent=r,this.enableOutEvent=r,this.enableOverEvent=r,r&&FS.forEach(s=>this.listen(s,!0))}destroy(){FS.forEach(e=>this.listen(e,!1))}enableEventType(e,t){switch(e){case"pointermove":this.enableMoveEvent!==t&&(this.enableMoveEvent=t,this.listen("mousedown",t),this.listen("mousemove",t),this.listen("mouseup",t));break;case"pointerover":this.enableOverEvent!==t&&(this.enableOverEvent=t,this.listen("mouseover",t));break;case"pointerout":this.enableOutEvent!==t&&(this.enableOutEvent=t,this.listen("mouseout",t));break;case"pointerenter":this.enableEnterEvent!==t&&(this.enableEnterEvent=t,this.listen("mouseenter",t));break;case"pointerleave":this.enableLeaveEvent!==t&&(this.enableLeaveEvent=t,this.listen("mouseleave",t));break;default:}}handleOverEvent(e){this.enableOverEvent&&e.type==="mouseover"&&this._emit("pointerover",e)}handleOutEvent(e){this.enableOutEvent&&e.type==="mouseout"&&this._emit("pointerout",e)}handleEnterEvent(e){this.enableEnterEvent&&e.type==="mouseenter"&&this._emit("pointerenter",e)}handleLeaveEvent(e){this.enableLeaveEvent&&e.type==="mouseleave"&&this._emit("pointerleave",e)}handleMoveEvent(e){if(this.enableMoveEvent)switch(e.type){case"mousedown":e.button>=0&&(this.pressed=!0);break;case"mousemove":e.buttons===0&&(this.pressed=!1),this.pressed||this._emit("pointermove",e);break;case"mouseup":this.pressed=!1;break;default:}}_emit(e,t){this.callback({type:e,center:{x:t.clientX,y:t.clientY},srcEvent:t,pointerType:"mouse",target:t.target})}};var zS=["keydown","keyup"],bf=class extends Wn{constructor(e,t,i){super(e,t,{enable:!0,tabIndex:0,...i}),this.handleEvent=s=>{let o=s.target||s.srcElement;o.tagName==="INPUT"&&o.type==="text"||o.tagName==="TEXTAREA"||(this.enableDownEvent&&s.type==="keydown"&&this.callback({type:"keydown",srcEvent:s,key:s.key,target:s.target}),this.enableUpEvent&&s.type==="keyup"&&this.callback({type:"keyup",srcEvent:s,key:s.key,target:s.target}))};let{enable:r=!1}=this.options;this.enableDownEvent=r,this.enableUpEvent=r,e.tabIndex=this.options.tabIndex,e.style.outline="none",r&&zS.forEach(s=>this.listen(s,!0))}destroy(){zS.forEach(e=>this.listen(e,!1))}enableEventType(e,t){e==="keydown"&&this.enableDownEvent!==t&&(this.enableDownEvent=t,this.listen(e,t)),e==="keyup"&&this.enableUpEvent!==t&&(this.enableUpEvent=t,this.listen(e,t))}};var vf=class extends Wn{constructor(e,t,i){i.enable=i.enable??!1,super(e,t,i),this.handleEvent=r=>{this.options.enable&&this.callback({type:"contextmenu",center:{x:r.clientX,y:r.clientY},srcEvent:r,pointerType:"mouse",target:r.target})},i.enable&&this.listen("contextmenu",!0)}destroy(){this.listen("contextmenu",!1)}enableEventType(e,t){e==="contextmenu"&&this.options.enable!==t&&(this.options.enable=t,this.listen("contextmenu",t))}};var aN={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},cN=0,lN=1,uN=2,fN=1,dN=2,hN=4;function US(n){let e=aN[n.srcEvent.type];if(!e)return null;let{buttons:t,button:i}=n.srcEvent,r=!1,s=!1,o=!1;return e===2?(r=!!(t&fN),s=!!(t&hN),o=!!(t&dN)):(r=i===cN,s=i===lN,o=i===uN),{leftButton:r,middleButton:s,rightButton:o}}function $S(n,e){let t=n.center;if(!t)return null;let i=e.getBoundingClientRect(),r=i.width/e.offsetWidth||1,s=i.height/e.offsetHeight||1,o={x:(t.x-i.left-e.clientLeft)/r,y:(t.y-i.top-e.clientTop)/s};return{center:t,offsetCenter:o}}var pN={srcElement:"root",priority:0},xf=class{constructor(e,t){this.handleEvent=i=>{if(this.isEmpty())return;let r=this._normalizeEvent(i),s=i.srcEvent.target;for(;s&&s!==r.rootElement;){if(this._emit(r,s),r.handled)return;s=s.parentNode}this._emit(r,"root")},this.eventManager=e,this.recognizerName=t,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(e,t,i,r=!1,s=!1){let{handlers:o,handlersByElement:a}=this,c={...pN,...i},l=a.get(c.srcElement);l||(l=[],a.set(c.srcElement,l));let u={type:e,handler:t,srcElement:c.srcElement,priority:c.priority};r&&(u.once=!0),s&&(u.passive=!0),o.push(u),this._active=this._active||!u.passive;let f=l.length-1;for(;f>=0&&!(l[f].priority>=u.priority);)f--;l.splice(f+1,0,u)}remove(e,t){let{handlers:i,handlersByElement:r}=this;for(let s=i.length-1;s>=0;s--){let o=i[s];if(o.type===e&&o.handler===t){i.splice(s,1);let a=r.get(o.srcElement);a.splice(a.indexOf(o),1),a.length===0&&r.delete(o.srcElement)}}this._active=i.some(s=>!s.passive)}_emit(e,t){let i=this.handlersByElement.get(t);if(i){let r=!1,s=()=>{e.handled=!0},o=()=>{e.handled=!0,r=!0},a=[];for(let c=0;c{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:t}}};function mN(n){if("recognizer"in n)return n;let e,t=Array.isArray(n)?[...n]:[n];if(typeof t[0]=="function"){let i=t.shift(),r=t.shift()||{};e=new i(r)}else e=t.shift();return{recognizer:e,recognizeWith:typeof t[0]=="string"?[t[0]]:t[0],requireFailure:typeof t[1]=="string"?[t[1]]:t[1]}}var sc=class{constructor(e=null,t={}){if(this._onBasicInput=i=>{this.manager.emit(i.srcEvent.type,i)},this._onOtherEvent=i=>{this.manager.emit(i.type,i)},this.options={recognizers:[],events:{},touchAction:"compute",tabIndex:0,cssProps:{},...t},this.events=new Map,this.element=e,this.wheelSession=new _f(e),!!e){this.manager=new rc(e,this.options);for(let i of this.options.recognizers){let{recognizer:r,recognizeWith:s,requireFailure:o}=mN(i);this.manager.add(r),s&&r.recognizeWith(s),o&&r.requireFailure(o)}this.manager.on("hammer.input",this._onBasicInput),this.wheelInput=new gf(e,this._onOtherEvent,{enable:!1,wheelSession:this.wheelSession}),this.moveInput=new yf(e,this._onOtherEvent,{enable:!1}),this.keyInput=new bf(e,this._onOtherEvent,{enable:!1,tabIndex:t.tabIndex}),this.contextmenuInput=new vf(e,this._onOtherEvent,{enable:!1}),this.on(this.options.events)}}getElement(){return this.element}destroy(){if(!this.element){this.wheelSession.destroy();return}this.wheelInput.destroy(),this.wheelSession.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy()}on(e,t,i){this._addEventHandler(e,t,i,!1)}once(e,t,i){this._addEventHandler(e,t,i,!0)}watch(e,t,i){this._addEventHandler(e,t,i,!1,!0)}off(e,t){this._removeEventHandler(e,t)}emit(e){this.manager?.emit(e.type,e)}_toggleRecognizer(e,t){let{manager:i}=this;if(!i)return;let r=i.get(e);r&&(r.set({enable:t,wheelSession:this.wheelSession}),i.touchAction.update()),this.wheelInput?.enableEventType(e,t),this.moveInput?.enableEventType(e,t),this.keyInput?.enableEventType(e,t),this.contextmenuInput?.enableEventType(e,t)}_addEventHandler(e,t,i,r,s){if(typeof e!="string"){i=t;for(let[l,u]of Object.entries(e))this._addEventHandler(l,u,i,r,s);return}let{manager:o,events:a}=this;if(!o)return;let c=a.get(e);if(!c){let l=this._getRecognizerName(e)||e;c=new xf(this,l),a.set(e,c),o&&o.on(e,c.handleEvent)}c.add(e,t,i,r,s),c.isEmpty()||this._toggleRecognizer(c.recognizerName,!0)}_removeEventHandler(e,t){if(typeof e!="string"){for(let[s,o]of Object.entries(e))this._removeEventHandler(s,o);return}let{events:i}=this,r=i.get(e);if(r&&(r.remove(e,t),r.isEmpty())){let{recognizerName:s}=r,o=!1;for(let a of i.values())if(a.recognizerName===s&&!a.isEmpty()){o=!0;break}o||this._toggleRecognizer(s,!1)}}_getRecognizerName(e){return this.manager.recognizers.find(t=>t.getEventNames().includes(e))?.options.event}};var m_={DEFAULT:"default",LNGLAT:"lnglat",METER_OFFSETS:"meter-offsets",LNGLAT_OFFSETS:"lnglat-offsets",CARTESIAN:"cartesian"};Object.defineProperty(m_,"IDENTITY",{get:()=>(ae.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),m_.CARTESIAN)});var qe={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},Jt={common:0,meters:1,pixels:2},ao={click:"onClick",dblclick:"onClick",panstart:"onDragStart",panmove:"onDrag",panend:"onDragEnd"},g_={multipan:[Xi,{threshold:10,pointers:2,trackpad:!0}],pinch:[oo,{trackpad:!0},null,["multipan"]],pan:[Xi,{threshold:1},["pinch"],["multipan"]],dblclick:[qr,{event:"dblclick",taps:2,enable:!1}],dblclickdrag:[ro,{event:"dblclickdrag",enable:!1},["dblclick"],null],click:[qr,{event:"click"},["dblclickdrag"],["dblclick","dblclickdrag"]]};function gN(n,e){if(n===e)return!0;if(Array.isArray(n)){let t=n.length;if(!e||e.length!==t)return!1;for(let i=0;i{for(let r in i)if(!gN(i[r],e[r])){t=n(i),e=i;break}return t}}var GS=[0,0,0,0],_N=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],VS=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],yN=[0,0,0],WS=[0,0,0],bN={default:-1,cartesian:0,lnglat:1,"meter-offsets":2,"lnglat-offsets":3};function Zr(n){let e=bN[n];if(e===void 0)throw new Error(`Invalid coordinateSystem: ${n}`);return e}var vN=jn(wN);function __(n,e,t=WS){t.length<3&&(t=[t[0],t[1],0]);let i=t,r,s=!0;switch(e==="lnglat-offsets"||e==="meter-offsets"?r=t:r=n.isGeospatial?[Math.fround(n.longitude),Math.fround(n.latitude),0]:null,n.projectionMode){case qe.WEB_MERCATOR:(e==="lnglat"||e==="cartesian")&&(r=[0,0,0],s=!1);break;case qe.WEB_MERCATOR_AUTO_OFFSET:e==="lnglat"?i=r:e==="cartesian"&&(i=[Math.fround(n.center[0]),Math.fround(n.center[1]),0],r=n.unprojectPosition(i),i[0]-=t[0],i[1]-=t[1],i[2]-=t[2]);break;case qe.IDENTITY:i=n.position.map(Math.fround),i[2]=i[2]||0;break;case qe.GLOBE:s=!1,r=null;break;default:s=!1}return{geospatialOrigin:r,shaderCoordinateOrigin:i,offsetMode:s}}function xN(n,e,t){let{viewMatrixUncentered:i,projectionMatrix:r}=n,{viewMatrix:s,viewProjectionMatrix:o}=n,a=GS,c=GS,l=n.cameraPosition,{geospatialOrigin:u,shaderCoordinateOrigin:f,offsetMode:d}=__(n,e,t);return d&&(c=n.projectPosition(u||f),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,a=Rt.transformMat4([],c,o),s=i||s,o=Ve.multiply([],r,s),o=Ve.multiply([],o,_N)),{viewMatrix:s,viewProjectionMatrix:o,projectionCenter:a,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:f,geospatialOrigin:u}}function jS({viewport:n,devicePixelRatio:e=1,modelMatrix:t=null,coordinateSystem:i="default",coordinateOrigin:r=WS,autoWrapLongitude:s=!1}){i==="default"&&(i=n.isGeospatial?"lnglat":"cartesian");let o=vN({viewport:n,devicePixelRatio:e,coordinateSystem:i,coordinateOrigin:r});return o.wrapLongitude=s,o.modelMatrix=t||VS,o}function wN({viewport:n,devicePixelRatio:e,coordinateSystem:t,coordinateOrigin:i}){let{projectionCenter:r,viewProjectionMatrix:s,originCommon:o,cameraPosCommon:a,shaderCoordinateOrigin:c,geospatialOrigin:l}=xN(n,t,i),u=n.getDistanceScales(),f=[n.width*e,n.height*e],d=Rt.transformMat4([],[0,0,-n.focalDistance,1],n.projectionMatrix)[3]||1,h={coordinateSystem:Zr(t),projectionMode:n.projectionMode,coordinateOrigin:c,commonOrigin:o.slice(0,3),center:r,pseudoMeters:!!n._pseudoMeters,viewportSize:f,devicePixelRatio:e,focalDistance:d,commonUnitsPerMeter:u.unitsPerMeter,commonUnitsPerWorldUnit:u.unitsPerMeter,commonUnitsPerWorldUnit2:yN,scale:n.scale,wrapLongitude:!1,viewProjectionMatrix:s,modelMatrix:VS,cameraPosition:a};if(l){let p=n.getDistanceScales(l);switch(t){case"meter-offsets":h.commonUnitsPerWorldUnit=p.unitsPerMeter,h.commonUnitsPerWorldUnit2=p.unitsPerMeter2;break;case"lnglat":case"lnglat-offsets":n._pseudoMeters||(h.commonUnitsPerMeter=p.unitsPerMeter),h.commonUnitsPerWorldUnit=p.unitsPerDegree,h.commonUnitsPerWorldUnit2=p.unitsPerDegree2;break;case"cartesian":h.commonUnitsPerWorldUnit=[1,1,p.unitsPerMeter[2]],h.commonUnitsPerWorldUnit2=[0,0,p.unitsPerMeter2[2]];break;default:break}}if(n.projectionMode===qe.GLOBE&&t==="meter-offsets"){let g=i[0]*Math.PI/180,v=i[1]*Math.PI/180,y=Math.cos(v),b=((i[2]||0)/6370972+1)*256;h.commonOrigin=[Math.sin(g)*y*b,-Math.cos(g)*y*b,Math.sin(v)*b]}return h}var EN=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],SN=EN.map(n=>`const COORDINATE_SYSTEM_${n.toUpperCase().replaceAll("-","_")}: i32 = ${Zr(n)};`).join(""),PN=Object.keys(qe).map(n=>`const PROJECTION_MODE_${n}: i32 = ${qe[n]};`).join(""),CN=Object.keys(Jt).map(n=>`const UNIT_${n.toUpperCase()}: i32 = ${Jt[n]};`).join(""),TN=`${SN} -${PN} -${CN} +`,ff={name:"geometry",source:R4,vs:I4,fs:B4};vt();Ue();var ne;(function(n){n[n.Start=1]="Start",n[n.Move=2]="Move",n[n.End=4]="End",n[n.Cancel=8]="Cancel"})(ne||(ne={}));var Le;(function(n){n[n.None=0]="None",n[n.Left=1]="Left",n[n.Right=2]="Right",n[n.Up=4]="Up",n[n.Down=8]="Down",n[n.Horizontal=3]="Horizontal",n[n.Vertical=12]="Vertical",n[n.All=15]="All"})(Le||(Le={}));var H;(function(n){n[n.Possible=1]="Possible",n[n.Began=2]="Began",n[n.Changed=4]="Changed",n[n.Ended=8]="Ended",n[n.Recognized=8]="Recognized",n[n.Cancelled=16]="Cancelled",n[n.Failed=32]="Failed"})(H||(H={}));var wS="compute",o_="auto",jr="manipulation",Hr="none",Qa="pan-x",Ja="pan-y";function a_(n){if(n.includes(Hr))return Hr;let e=n.includes(Qa),t=n.includes(Ja);return e&&t?Hr:e||t?e?Qa:Ja:n.includes(jr)?jr:o_}var ec=class{constructor(e,t){this.actions="",this.manager=e,this.set(t)}set(e){e===wS&&(e=this.compute()),this.manager.element&&(this.manager.element.style.touchAction=e,this.actions=e)}update(){this.set(this.manager.options.touchAction)}compute(){let e=[];for(let t of this.manager.recognizers)t.options.enable&&(e=e.concat(t.getTouchAction()));return a_(e.join(" "))}};function to(n){return n.trim().split(/\s+/g)}function df(n,e,t){if(n)for(let i of to(e))n.addEventListener(i,t,!1)}function hf(n,e,t){if(n)for(let i of to(e))n.removeEventListener(i,t,!1)}function c_(n){return(n.ownerDocument||n).defaultView}function l_(n,e){let t=n;for(;t;){if(t===e)return!0;t=t.parentNode}return!1}function pf(n){let e=n.length;if(e===1)return{x:Math.round(n[0].clientX),y:Math.round(n[0].clientY)};let t=0,i=0,r=0;for(;r=Math.abs(e)?n<0?Le.Left:Le.Right:e<0?Le.Up:Le.Down}function SS(n,e){let t=e.center,i=n.offsetDelta,r=n.prevDelta,s=n.prevInput;return(e.eventType===ne.Start||s?.eventType===ne.End)&&(r=n.prevDelta={x:s?.deltaX||0,y:s?.deltaY||0},i=n.offsetDelta={x:t.x,y:t.y}),{deltaX:r.x+(t.x-i.x),deltaY:r.y+(t.y-i.y)}}function mf(n,e,t){return{x:e/n||0,y:t/n||0}}function PS(n,e){return tc(e[0],e[1])/tc(n[0],n[1])}function CS(n,e){return f_(e[1],e[0])-f_(n[1],n[0])}function TS(n,e){let t=n.lastInterval||e,i=e.timeStamp-t.timeStamp,r,s,o,a;if(e.eventType!==ne.Cancel&&(i>25||t.velocity===void 0)){let c=e.deltaX-t.deltaX,l=e.deltaY-t.deltaY,u=mf(i,c,l);s=u.x,o=u.y,r=Math.abs(u.x)>Math.abs(u.y)?u.x:u.y,a=io(c,l),n.lastInterval=e}else r=t.velocity,s=t.velocityX,o=t.velocityY,a=t.direction;e.velocity=r,e.velocityX=s,e.velocityY=o,e.direction=a}function d_(n,e){return"pointerId"in n?n.pointerId:e}function LS(n,e){n.movementOrigin=new Map(e.map((t,i)=>[d_(t,i),{clientX:t.clientX,clientY:t.clientY}])),n.firstMovementTime=void 0}function D4(n,e){let t=e.pointers.map(d_);if(n.movementOrigin?.size===t.length&&t.every(r=>n.movementOrigin.has(r))||LS(n,e.pointers),e.distancePerPointer=e.pointers.map((r,s)=>tc(n.movementOrigin.get(t[s]),r)),e.eventType&ne.Move&&e.distancePerPointer.some(r=>r>0)&&(n.firstMovementTime??(n.firstMovementTime=e.timeStamp)),e.movementDeltaTime=n.firstMovementTime===void 0?0:e.timeStamp-n.firstMovementTime,e.eventType&(ne.End|ne.Cancel)){let r=e.changedPointers.map(s=>d_(s,e.pointers.indexOf(s)));LS(n,e.pointers.filter((s,o)=>!r.includes(t[o])))}}function MS(n,e){let{session:t}=n,{pointers:i}=e,{length:r}=i;t.firstInput||(t.firstInput=u_(e)),r>1&&!t.firstMultiple?t.firstMultiple=u_(e):r===1&&(t.firstMultiple=!1);let{firstInput:s,firstMultiple:o}=t,a=o?o.center:s.center,c=e.center=pf(i);e.timeStamp=Date.now(),e.deltaTime=e.timeStamp-s.timeStamp,D4(t,e),e.angle=ES(a,c),e.distance=no(a,c);let{deltaX:l,deltaY:u}=SS(t,e);e.deltaX=l,e.deltaY=u,e.offsetDirection=io(e.deltaX,e.deltaY);let f=mf(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=f.x,e.overallVelocityY=f.y,e.overallVelocity=Math.abs(f.x)>Math.abs(f.y)?f.x:f.y,e.scale=o?PS(o.pointers,i):1,e.rotation=o?CS(o.pointers,i):0,e.maxPointers=t.prevInput?e.pointers.length>t.prevInput.maxPointers?e.pointers.length:t.prevInput.maxPointers:e.pointers.length;let d=n.element;return l_(e.srcEvent.target,d)&&(d=e.srcEvent.target),e.target=d,TS(t,e),e}function AS(n,e,t){let i=t.pointers.length,r=t.changedPointers.length,s=e&ne.Start&&i-r===0,o=e&(ne.End|ne.Cancel)&&i-r===0;t.isFirst=!!s,t.isFinal=!!o,s&&(n.session={}),t.eventType=e;let a=MS(n,t);n.emit("hammer.input",a),n.recognize(a),n.session.prevInput=a}var nc=class{constructor(e){this.evEl="",this.evWin="",this.evTarget="",this.domHandler=t=>{this.manager.options.enable&&this.handler(t)},this.manager=e,this.element=e.element,this.target=e.options.inputTarget||e.element}callback(e,t){AS(this.manager,e,t)}init(){df(this.element,this.evEl,this.domHandler),df(this.target,this.evTarget,this.domHandler),df(c_(this.element),this.evWin,this.domHandler)}destroy(){hf(this.element,this.evEl,this.domHandler),hf(this.target,this.evTarget,this.domHandler),hf(c_(this.element),this.evWin,this.domHandler)}};var N4={pointerdown:ne.Start,pointermove:ne.Move,pointerup:ne.End,pointercancel:ne.Cancel,pointerout:ne.Cancel},F4="pointerdown",z4="pointermove pointerup pointercancel",ic=class extends nc{constructor(e){super(e),this.evEl=F4,this.evWin=z4,this.store=this.manager.session.pointerEvents=[],this.init()}handler(e){let{store:t}=this,i=!1,r=N4[e.type],s=e.pointerType,o=s==="touch",a=t.findIndex(c=>c.pointerId===e.pointerId);r&ne.Start&&(e.buttons||o)?a<0&&(t.push(e),a=t.length-1):r&(ne.End|ne.Cancel)&&(i=!0),!(a<0)&&(t[a]=e,this.callback(r,{pointers:t,changedPointers:[e],eventType:r,pointerType:s,srcEvent:e}),i&&t.splice(a,1))}};var U4=["","webkit","Moz","MS","ms","o"];function kS(n,e){let t=e[0].toUpperCase()+e.slice(1);for(let i of U4){let r=i?i+t:e;if(r in n)return r}}var $4=1,RS=2,IS={touchAction:"compute",enable:!0,inputTarget:null,cssProps:{userSelect:"none",userDrag:"none",touchCallout:"none",tapHighlightColor:"rgba(0,0,0,0)"}},rc=class{constructor(e,t){this.options={...IS,...t,cssProps:{...IS.cssProps,...t.cssProps},inputTarget:t.inputTarget||e},this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=new ic(this),this.touchAction=new ec(this,this.options.touchAction),this.toggleCssProps(!0)}set(e){return Object.assign(this.options,e),e.touchAction&&this.touchAction.update(),e.inputTarget&&(this.input.destroy(),this.input.target=e.inputTarget,this.input.init()),this}stop(e){this.session.stopped=e?RS:$4}recognize(e){let{session:t}=this;if(t.stopped)return;this.session.prevented&&e.srcEvent.preventDefault();let i,{recognizers:r}=this,{curRecognizer:s}=t;(!s||s&&s.state&H.Recognized)&&(s=t.curRecognizer=null);let o=0;for(;o-1&&this.requireFail.splice(i,1)}return this}hasRequireFailures(){return!!this.requireFail.find(e=>e.options.enable)}canRecognizeWith(e){return!!this.simultaneous[e.id]}emit(e){if(!e)return;let{state:t}=this;t=H.Ended&&this.manager.emit(this.options.event+h_(t),e)}tryEmit(e){this.canEmit()?this.emit(e):this.state=H.Failed}canEmit(){let e=0;for(;e=e.distance)&&(e.distancePerPointer===void 0||n.distancePerPointer.length>0&&n.distancePerPointer.every(t=>t>=e.distancePerPointer))&&(e.movementDeltaTime===void 0||n.movementDeltaTime>=e.movementDeltaTime)&&(e.rotation===void 0||V4(n.rotation)>=e.rotation)&&(e.scale===void 0||Math.abs(n.scale-1)>=e.scale)}var Yr=class extends dn{attrTest(e){let t=this.options.pointers;return t===0||e.pointers.length===t}coherentTest(e){let t=this.options.coherent;return!t?.length||t.some(i=>W4(e,i))}process(e){let{state:t}=this,{eventType:i}=e,r=t&(H.Began|H.Changed),s=this.attrTest(e);return r&&(i&ne.Cancel||!s)?t|H.Cancelled:r||s?i&ne.End?t|H.Ended:t&H.Began?t|H.Changed:H.Began:H.Failed}};var j4=["","start","move","end","cancel"],ro=class extends dn{constructor(e={}){super({enable:!0,event:"doubleclickdrag",pointers:1,interval:500,time:350,threshold:28,dragThreshold:1,pixelsPerScale:120,...e}),this._tapStart=null,this._lastTap=null,this._drag=null,this._emittedStart=!1}getTouchAction(){return[jr]}getEventNames(){return j4.map(e=>this.options.event+e)}process(e){let{options:t}=this;return e.pointers.length===t.pointers?e.eventType&ne.Start?this._handleStart(e):e.eventType&ne.Move?this._handleMove(e):e.eventType&ne.Cancel?this._handleEnd(e,!0):e.eventType&ne.End?this._handleEnd(e,!1):H.Failed:(this.reset(),H.Failed)}reset(){this._tapStart=null,this._lastTap=null,this._drag=null,this._emittedStart=!1}emit(e){if(e){if(this.state===H.Began){if(!this._drag?.active||this._emittedStart)return;this._emittedStart=!0,this.manager.emit(`${this.options.event}start`,e),this.manager.emit(this.options.event,e);return}if(this.state===H.Changed){if(!this._emittedStart)return;this.manager.emit(`${this.options.event}move`,e),this.manager.emit(this.options.event,e);return}if(this.state===H.Ended){if(!this._emittedStart)return;this.manager.emit(this.options.event,e),this.manager.emit(`${this.options.event}end`,e),this._emittedStart=!1;return}if(this.state===H.Cancelled){if(!this._emittedStart)return;this.manager.emit(this.options.event,e),this.manager.emit(`${this.options.event}cancel`,e),this._emittedStart=!1}}}_handleStart(e){let t=this._getPointerId(e);return this._lastTap&&this._isTapMatch(e,this._lastTap)?(this._tapStart=null,this._lastTap=null,this._drag={startCenter:e.center,pointerId:t,active:!1},this._emittedStart=!1,H.Began):(this._tapStart={center:e.center,timeStamp:e.timeStamp,pointerId:t},this._lastTap=null,this._drag=null,this._emittedStart=!1,H.Failed)}_handleMove(e){if(!this._drag||!this._isSamePointer(e,this._drag.pointerId))return H.Failed;let t=this._drag.startCenter.y-e.center.y;return!this._drag.active&&Math.abs(t){this.state=H.Recognized,this.tryEmit(this._input)},t.interval),H.Began):H.Recognized}return H.Failed}failTimeout(){return this._timer=setTimeout(()=>{this.state=H.Failed},this.options.interval),H.Failed}reset(){clearTimeout(this._timer)}emit(e){this.state===H.Recognized&&(e.tapCount=this.count,this.manager.emit(this.options.event,e))}};var so=class extends Yr{constructor(){super(...arguments),this.wheelSession=null,this.wheelSessionUnsubscribe=null,this.handleWheelSessionEvent=e=>{e.device==="trackpad"&&this.handleTrackpadEvent(e)}}set(e){let{wheelSession:t,...i}=e;return t&&t!==this.wheelSession&&(this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=null,this.wheelSession=t),super.set(i),this.updateWheelSessionSubscription(),this}getTrackpadInput(e,t={}){let{srcEvent:i}=e,r=t.deltaX??e.deltaX,s=t.deltaY??e.deltaY,o=io(r,s),a=Math.sqrt(e.deltaX*e.deltaX+e.deltaY*e.deltaY),c=i;return{pointers:[c,c],changedPointers:[c,c],pointerType:"trackpad",srcEvent:c,eventType:e.eventType,timeStamp:e.timeStamp,deltaTime:e.deltaTime,center:e.center,deltaX:r,deltaY:s,angle:Math.atan2(s,r)*180/Math.PI,distance:Math.sqrt(r*r+s*s),distancePerPointer:[a,a],movementDeltaTime:e.deltaTime,scale:1,rotation:0,direction:o,offsetDirection:o,velocity:e.velocity,velocityX:e.velocityX,velocityY:e.velocityY,overallVelocity:e.overallVelocity,overallVelocityX:e.overallVelocityX,overallVelocityY:e.overallVelocityY,maxPointers:2,target:i.target||this.manager.element,additionalEvent:"",...t}}updateWheelSessionSubscription(){let e=!!(this.wheelSession&&this.options.enable&&this.options.trackpad&&this.options.pointers===2);e&&!this.wheelSessionUnsubscribe?this.wheelSessionUnsubscribe=this.wheelSession.on(this.handleWheelSessionEvent):!e&&this.wheelSessionUnsubscribe&&(this.wheelSessionUnsubscribe(),this.wheelSessionUnsubscribe=null)}};var H4=["","start","move","end","cancel","up","down","left","right"],Xi=class extends so{constructor(e={}){super({enable:!0,pointers:1,event:"pan",threshold:10,direction:Le.All,trackpad:!1,coherent:[],...e}),this.trackpadGesture=!1,this.pX=null,this.pY=null}getTouchAction(){let{options:{direction:e}}=this,t=[];return e&Le.Horizontal&&t.push(Ja),e&Le.Vertical&&t.push(Qa),t}getEventNames(){return H4.map(e=>this.options.event+e)}directionTest(e){let{options:t}=this,i=!0,{distance:r}=e,{direction:s}=e,o=e.deltaX,a=e.deltaY;return s&t.direction||(t.direction&Le.Horizontal?(s=o===0?Le.None:o<0?Le.Left:Le.Right,i=o!==this.pX,r=Math.abs(e.deltaX)):(s=a===0?Le.None:a<0?Le.Up:Le.Down,i=a!==this.pY,r=Math.abs(e.deltaY))),e.direction=s,i&&r>t.threshold&&!!(s&t.direction)}attrTest(e){let t=!!(this.state&H.Began),i=!(this.options.coherent?.length&&e.eventType&(ne.End|ne.Cancel));return super.attrTest(e)&&(t||i&&this.coherentTest(e)&&this.directionTest(e))}emit(e){this.pX=e.deltaX,this.pY=e.deltaY;let t=Le[e.direction].toLowerCase();t&&(e.additionalEvent=this.options.event+t),super.emit(e)}handleTrackpadEvent(e){e.isFirst&&(this.trackpadGesture=!e.srcEvent.ctrlKey,!this.trackpadGesture&&this.state&(H.Recognized|H.Cancelled|H.Failed)&&(this.state=H.Possible)),this.trackpadGesture&&(this.recognize(this.getTrackpadInput(e,{deltaX:-e.deltaX,deltaY:-e.deltaY,velocity:-e.velocity,velocityX:-e.velocityX,velocityY:-e.velocityY,overallVelocity:-e.overallVelocity,overallVelocityX:-e.overallVelocityX,overallVelocityY:-e.overallVelocityY})),e.isFinal&&(this.trackpadGesture=!1))}};var Y4=["","start","move","end","cancel","in","out"],oo=class extends so{constructor(e={}){super({enable:!0,event:"pinch",threshold:0,pointers:2,trackpad:!1,coherent:[],...e}),this.trackpadGesture=!1}getTouchAction(){return[Hr]}getEventNames(){return Y4.map(e=>this.options.event+e)}attrTest(e){let t=!!this.options.coherent?.length,i=!!(this.state&H.Began),r=!(t&&e.eventType&(ne.End|ne.Cancel));return super.attrTest(e)&&(i||r&&(t?this.coherentTest(e):Math.abs(e.scale-1)>this.options.threshold))}emit(e){if(e.scale!==1){let t=e.scale<1?"in":"out";e.additionalEvent=this.options.event+t}super.emit(e)}handleTrackpadEvent(e){e.isFirst&&(this.trackpadGesture=e.srcEvent.ctrlKey,!this.trackpadGesture&&this.state&(H.Recognized|H.Cancelled|H.Failed)&&(this.state=H.Possible)),this.trackpadGesture&&(this.recognize(this.getTrackpadInput(e,{deltaX:0,deltaY:0,velocity:0,velocityX:0,velocityY:0,overallVelocity:0,overallVelocityX:0,overallVelocityY:0,scale:Math.exp(-e.deltaY/100)})),e.isFinal&&(this.trackpadGesture=!1))}};var Wn=class{constructor(e,t,i){this.element=e,this.callback=t,this.options=i}listen(e,t){t?this.element.addEventListener(e,this.handleEvent,{passive:!1}):this.element.removeEventListener(e,this.handleEvent)}};var OS=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"";var K4=OS.indexOf("firefox")!==-1,Q4=40,J4=.25,gf=class extends Wn{constructor(e,t,i){i.enable=i.enable??!1,super(e,t,i),this.handleEvent=r=>{if(!this.options.enable)return;let s=r.deltaY;globalThis.WheelEvent&&(K4&&r.deltaMode===globalThis.WheelEvent.DOM_DELTA_PIXEL&&(s/=globalThis.devicePixelRatio),r.deltaMode===globalThis.WheelEvent.DOM_DELTA_LINE&&(s*=Q4)),r.shiftKey&&s&&(s=s*J4),this.callback({type:"wheel",center:{x:r.clientX,y:r.clientY},delta:-s,device:this.options.wheelSession?.device??"unknown",srcEvent:r,pointerType:"mouse",target:r.target})},i.enable&&(this.wheelSessionUnsubscribe=this.options.wheelSession?.on(()=>{}),this.listen("wheel",!0))}destroy(){this.listen("wheel",!1),this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=void 0}enableEventType(e,t){e==="wheel"&&this.options.enable!==t&&(this.options.enable=t,t&&!this.wheelSessionUnsubscribe&&(this.wheelSessionUnsubscribe=this.options.wheelSession?.on(()=>{})),this.listen("wheel",t),t||(this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=void 0))}};var eN=4.000244140625,DS=40,tN=0,nN=1,iN=40,NS=40,rN=120,sN={classificationDelay:32,endDelay:80},_f=class{constructor(e,t={}){this.subscriptions=new Map,this.session=null,this.classificationTimer=null,this.endTimer=null,this.pressedControlKeys=new Set,this.listeningForControlKeys=!1,this.handleEvent=i=>{if(!this.hasSubscribers)return"unknown";let r=aN(i,this.pressedControlKeys.size>0),s=this.session;if(s&&r.timeStamp-s.lastTimeStamp>=this.options.endDelay){if(this.end(),!this.hasSubscribers)return"unknown";s=null}s?(this.scheduleEnd(),this.addSample(s,r)):(s=this.startPendingSession(r),this.scheduleEnd());let{device:o}=s;return o==="unknown"&&(o=p_(s.samples,!1),o!=="unknown"&&this.begin(s,o)),o},this.finishClassification=()=>{if(this.classificationTimer=null,!this.session||this.session.device!=="unknown")return;let i=this.session,r=p_(i.samples,!0);this.begin(i,r==="unknown"?"mouse":r)},this.end=()=>{if(!this.session)return;if(this.session.device==="unknown"){let r=this.session,s=p_(r.samples,!0);this.begin(r,s==="unknown"?"mouse":s)}if(!this.session)return;let i=this.session;this.emit(ne.End,i.lastEvent),this.reset()},this.handleKeyDown=i=>{i.key==="Control"&&this.pressedControlKeys.add(i.code||i.key)},this.handleKeyUp=i=>{i.key==="Control"&&(i.code?this.pressedControlKeys.delete(i.code):this.pressedControlKeys.clear())},this.handleWindowBlur=()=>{this.pressedControlKeys.clear()},this.element=e,this.options={...sN,...t},this.element?.addEventListener("wheel",this.handleEvent,{passive:!0})}get hasSubscribers(){return this.subscriptions.size>0}get device(){return this.session?.device??"unknown"}on(e){let t={listener:e};return this.subscriptions.set(e,t),this.updateControlKeyEventListeners(),()=>{this.subscriptions.get(e)===t&&this.off(e)}}off(e){this.subscriptions.delete(e),this.updateControlKeyEventListeners(),this.hasSubscribers||this.reset()}cancel(){let e=this.session;e&&e.device!=="unknown"&&this.emit(ne.Cancel,e.lastEvent),this.reset()}destroy(){this.cancel(),this.subscriptions.clear(),this.updateControlKeyEventListeners(),this.element?.removeEventListener("wheel",this.handleEvent)}startPendingSession(e){let t={samples:[e],device:"unknown",firstTimeStamp:e.timeStamp,lastTimeStamp:e.timeStamp,totalDeltaX:e.deltaX,totalDeltaY:e.deltaY,velocityX:0,velocityY:0,lastEvent:e.event};return this.session=t,this.classificationTimer=globalThis.setTimeout(this.finishClassification,this.options.classificationDelay),t}addSample(e,t){if(e.samples.push(t),e.lastTimeStamp=t.timeStamp,e.lastEvent=t.event,e.totalDeltaX+=t.deltaX,e.totalDeltaY+=t.deltaY,e.device!=="unknown"){let i=e.samples[e.samples.length-2],r=t.timeStamp-i.timeStamp;e.velocityX=r>0?t.deltaX/r:0,e.velocityY=r>0?t.deltaY/r:0,this.emit(ne.Move,t.event,{velocityX:e.velocityX,velocityY:e.velocityY})}}begin(e,t){e.device=t,this.clearClassificationTimer(),this.emit(ne.Start,e.samples[0].event);let i=e.lastTimeStamp-e.firstTimeStamp;e.velocityX=i>0?e.totalDeltaX/i:0,e.velocityY=i>0?e.totalDeltaY/i:0,this.emit(ne.Move,e.lastEvent,{velocityX:e.velocityX,velocityY:e.velocityY})}scheduleEnd(){this.clearEndTimer(),this.endTimer=globalThis.setTimeout(this.end,this.options.endDelay)}emit(e,t,i){let r=this.session;if(!r||r.device==="unknown")return;let s=e===ne.Start,o=e===ne.End||e===ne.Cancel,a=s?r.firstTimeStamp:r.lastTimeStamp,c=s?0:Math.max(0,a-r.firstTimeStamp),l=s?0:r.totalDeltaX,u=s?0:r.totalDeltaY,f=c>0?l/c:0,d=c>0?u/c:0,h=s?0:i?.velocityX??r.velocityX,p=s?0:i?.velocityY??r.velocityY,m={eventType:e,device:r.device,srcEvent:t,timeStamp:a,center:{x:t.clientX,y:t.clientY},deltaX:l,deltaY:u,deltaTime:c,velocity:Math.abs(h)>Math.abs(p)?h:p,velocityX:h,velocityY:p,overallVelocity:Math.abs(f)>Math.abs(d)?f:d,overallVelocityX:f,overallVelocityY:d,isFirst:s,isFinal:o};for(let{listener:g}of[...this.subscriptions.values()])g(m)}reset(){this.clearClassificationTimer(),this.clearEndTimer(),this.session=null}clearClassificationTimer(){this.classificationTimer!==null&&(globalThis.clearTimeout(this.classificationTimer),this.classificationTimer=null)}clearEndTimer(){this.endTimer!==null&&(globalThis.clearTimeout(this.endTimer),this.endTimer=null)}updateControlKeyEventListeners(){let e=this.hasSubscribers,t=oN();!t||e===this.listeningForControlKeys||(this.listeningForControlKeys=e,e?(t.addEventListener("keydown",this.handleKeyDown,!0),t.addEventListener("keyup",this.handleKeyUp,!0),t.addEventListener("blur",this.handleWindowBlur)):(t.removeEventListener("keydown",this.handleKeyDown,!0),t.removeEventListener("keyup",this.handleKeyUp,!0),t.removeEventListener("blur",this.handleWindowBlur),this.pressedControlKeys.clear()))}};function oN(){return typeof window<"u"?window:globalThis.document?.defaultView}function aN(n,e){let t=n.deltaX,i=n.deltaY;return n.deltaMode===nN&&(t*=DS,i*=DS),{event:n,timeStamp:n.timeStamp,deltaX:t,deltaY:i,isControlKeyDown:e}}function p_(n,e){return n.some(({event:t,isControlKeyDown:i})=>t.ctrlKey&&!i)?"trackpad":n.some(({event:t})=>t.deltaMode!==tN)||n.some(cN)||n.every(({event:t})=>{let i=t.wheelDelta;return i!==void 0&&Math.abs(i)%40===0})?"mouse":n.some(({deltaX:t})=>t!==0)||n.length>1&&lN(n)?"trackpad":e?"mouse":"unknown"}function cN({event:n,deltaX:e,deltaY:t}){if(e!==0||t===0)return!1;let i=Math.abs(t/eN);if(Number.isInteger(i))return!0;let r=n.wheelDelta;return typeof r=="number"&&r!==0&&r%rN===0}function lN(n){for(let e=0;eNS||Math.abs(t.deltaY)>NS||e>0&&t.timeStamp-n[e-1].timeStamp>iN)return!1}return!0}var FS=["mousedown","mousemove","mouseup","mouseover","mouseout","mouseenter","mouseleave"],yf=class extends Wn{constructor(e,t,i){super(e,t,{enable:!0,...i}),this.handleEvent=s=>{this.handleOverEvent(s),this.handleOutEvent(s),this.handleEnterEvent(s),this.handleLeaveEvent(s),this.handleMoveEvent(s)},this.pressed=!1;let{enable:r=!1}=this.options;this.enableMoveEvent=r,this.enableLeaveEvent=r,this.enableEnterEvent=r,this.enableOutEvent=r,this.enableOverEvent=r,r&&FS.forEach(s=>this.listen(s,!0))}destroy(){FS.forEach(e=>this.listen(e,!1))}enableEventType(e,t){switch(e){case"pointermove":this.enableMoveEvent!==t&&(this.enableMoveEvent=t,this.listen("mousedown",t),this.listen("mousemove",t),this.listen("mouseup",t));break;case"pointerover":this.enableOverEvent!==t&&(this.enableOverEvent=t,this.listen("mouseover",t));break;case"pointerout":this.enableOutEvent!==t&&(this.enableOutEvent=t,this.listen("mouseout",t));break;case"pointerenter":this.enableEnterEvent!==t&&(this.enableEnterEvent=t,this.listen("mouseenter",t));break;case"pointerleave":this.enableLeaveEvent!==t&&(this.enableLeaveEvent=t,this.listen("mouseleave",t));break;default:}}handleOverEvent(e){this.enableOverEvent&&e.type==="mouseover"&&this._emit("pointerover",e)}handleOutEvent(e){this.enableOutEvent&&e.type==="mouseout"&&this._emit("pointerout",e)}handleEnterEvent(e){this.enableEnterEvent&&e.type==="mouseenter"&&this._emit("pointerenter",e)}handleLeaveEvent(e){this.enableLeaveEvent&&e.type==="mouseleave"&&this._emit("pointerleave",e)}handleMoveEvent(e){if(this.enableMoveEvent)switch(e.type){case"mousedown":e.button>=0&&(this.pressed=!0);break;case"mousemove":e.buttons===0&&(this.pressed=!1),this.pressed||this._emit("pointermove",e);break;case"mouseup":this.pressed=!1;break;default:}}_emit(e,t){this.callback({type:e,center:{x:t.clientX,y:t.clientY},srcEvent:t,pointerType:"mouse",target:t.target})}};var zS=["keydown","keyup"],bf=class extends Wn{constructor(e,t,i){super(e,t,{enable:!0,tabIndex:0,...i}),this.handleEvent=s=>{let o=s.target||s.srcElement;o.tagName==="INPUT"&&o.type==="text"||o.tagName==="TEXTAREA"||(this.enableDownEvent&&s.type==="keydown"&&this.callback({type:"keydown",srcEvent:s,key:s.key,target:s.target}),this.enableUpEvent&&s.type==="keyup"&&this.callback({type:"keyup",srcEvent:s,key:s.key,target:s.target}))};let{enable:r=!1}=this.options;this.enableDownEvent=r,this.enableUpEvent=r,e.tabIndex=this.options.tabIndex,e.style.outline="none",r&&zS.forEach(s=>this.listen(s,!0))}destroy(){zS.forEach(e=>this.listen(e,!1))}enableEventType(e,t){e==="keydown"&&this.enableDownEvent!==t&&(this.enableDownEvent=t,this.listen(e,t)),e==="keyup"&&this.enableUpEvent!==t&&(this.enableUpEvent=t,this.listen(e,t))}};var vf=class extends Wn{constructor(e,t,i){i.enable=i.enable??!1,super(e,t,i),this.handleEvent=r=>{this.options.enable&&this.callback({type:"contextmenu",center:{x:r.clientX,y:r.clientY},srcEvent:r,pointerType:"mouse",target:r.target})},i.enable&&this.listen("contextmenu",!0)}destroy(){this.listen("contextmenu",!1)}enableEventType(e,t){e==="contextmenu"&&this.options.enable!==t&&(this.options.enable=t,this.listen("contextmenu",t))}};var uN={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},fN=0,dN=1,hN=2,pN=1,mN=2,gN=4;function US(n){let e=uN[n.srcEvent.type];if(!e)return null;let{buttons:t,button:i}=n.srcEvent,r=!1,s=!1,o=!1;return e===2?(r=!!(t&pN),s=!!(t&gN),o=!!(t&mN)):(r=i===fN,s=i===dN,o=i===hN),{leftButton:r,middleButton:s,rightButton:o}}function $S(n,e){let t=n.center;if(!t)return null;let i=e.getBoundingClientRect(),r=i.width/e.offsetWidth||1,s=i.height/e.offsetHeight||1,o={x:(t.x-i.left-e.clientLeft)/r,y:(t.y-i.top-e.clientTop)/s};return{center:t,offsetCenter:o}}var _N={srcElement:"root",priority:0},xf=class{constructor(e,t){this.handleEvent=i=>{if(this.isEmpty())return;let r=this._normalizeEvent(i),s=i.srcEvent.target;for(;s&&s!==r.rootElement;){if(this._emit(r,s),r.handled)return;s=s.parentNode}this._emit(r,"root")},this.eventManager=e,this.recognizerName=t,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(e,t,i,r=!1,s=!1){let{handlers:o,handlersByElement:a}=this,c={..._N,...i},l=a.get(c.srcElement);l||(l=[],a.set(c.srcElement,l));let u={type:e,handler:t,srcElement:c.srcElement,priority:c.priority};r&&(u.once=!0),s&&(u.passive=!0),o.push(u),this._active=this._active||!u.passive;let f=l.length-1;for(;f>=0&&!(l[f].priority>=u.priority);)f--;l.splice(f+1,0,u)}remove(e,t){let{handlers:i,handlersByElement:r}=this;for(let s=i.length-1;s>=0;s--){let o=i[s];if(o.type===e&&o.handler===t){i.splice(s,1);let a=r.get(o.srcElement);a.splice(a.indexOf(o),1),a.length===0&&r.delete(o.srcElement)}}this._active=i.some(s=>!s.passive)}_emit(e,t){let i=this.handlersByElement.get(t);if(i){let r=!1,s=()=>{e.handled=!0},o=()=>{e.handled=!0,r=!0},a=[];for(let c=0;c{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:t}}};function yN(n){if("recognizer"in n)return n;let e,t=Array.isArray(n)?[...n]:[n];if(typeof t[0]=="function"){let i=t.shift(),r=t.shift()||{};e=new i(r)}else e=t.shift();return{recognizer:e,recognizeWith:typeof t[0]=="string"?[t[0]]:t[0],requireFailure:typeof t[1]=="string"?[t[1]]:t[1]}}var sc=class{constructor(e=null,t={}){if(this._onBasicInput=i=>{this.manager.emit(i.srcEvent.type,i)},this._onOtherEvent=i=>{this.manager.emit(i.type,i)},this.options={recognizers:[],events:{},touchAction:"compute",tabIndex:0,cssProps:{},...t},this.events=new Map,this.element=e,this.wheelSession=new _f(e),!!e){this.manager=new rc(e,this.options);for(let i of this.options.recognizers){let{recognizer:r,recognizeWith:s,requireFailure:o}=yN(i);this.manager.add(r),s&&r.recognizeWith(s),o&&r.requireFailure(o)}this.manager.on("hammer.input",this._onBasicInput),this.wheelInput=new gf(e,this._onOtherEvent,{enable:!1,wheelSession:this.wheelSession}),this.moveInput=new yf(e,this._onOtherEvent,{enable:!1}),this.keyInput=new bf(e,this._onOtherEvent,{enable:!1,tabIndex:t.tabIndex}),this.contextmenuInput=new vf(e,this._onOtherEvent,{enable:!1}),this.on(this.options.events)}}getElement(){return this.element}destroy(){if(!this.element){this.wheelSession.destroy();return}this.wheelInput.destroy(),this.wheelSession.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy()}on(e,t,i){this._addEventHandler(e,t,i,!1)}once(e,t,i){this._addEventHandler(e,t,i,!0)}watch(e,t,i){this._addEventHandler(e,t,i,!1,!0)}off(e,t){this._removeEventHandler(e,t)}emit(e){this.manager?.emit(e.type,e)}_toggleRecognizer(e,t){let{manager:i}=this;if(!i)return;let r=i.get(e);r&&(r.set({enable:t,wheelSession:this.wheelSession}),i.touchAction.update()),this.wheelInput?.enableEventType(e,t),this.moveInput?.enableEventType(e,t),this.keyInput?.enableEventType(e,t),this.contextmenuInput?.enableEventType(e,t)}_addEventHandler(e,t,i,r,s){if(typeof e!="string"){i=t;for(let[l,u]of Object.entries(e))this._addEventHandler(l,u,i,r,s);return}let{manager:o,events:a}=this;if(!o)return;let c=a.get(e);if(!c){let l=this._getRecognizerName(e)||e;c=new xf(this,l),a.set(e,c),o&&o.on(e,c.handleEvent)}c.add(e,t,i,r,s),c.isEmpty()||this._toggleRecognizer(c.recognizerName,!0)}_removeEventHandler(e,t){if(typeof e!="string"){for(let[s,o]of Object.entries(e))this._removeEventHandler(s,o);return}let{events:i}=this,r=i.get(e);if(r&&(r.remove(e,t),r.isEmpty())){let{recognizerName:s}=r,o=!1;for(let a of i.values())if(a.recognizerName===s&&!a.isEmpty()){o=!0;break}o||this._toggleRecognizer(s,!1)}}_getRecognizerName(e){return this.manager.recognizers.find(t=>t.getEventNames().includes(e))?.options.event}};var m_={DEFAULT:"default",LNGLAT:"lnglat",METER_OFFSETS:"meter-offsets",LNGLAT_OFFSETS:"lnglat-offsets",CARTESIAN:"cartesian"};Object.defineProperty(m_,"IDENTITY",{get:()=>(ae.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),m_.CARTESIAN)});var qe={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},Qt={common:0,meters:1,pixels:2},ao={click:"onClick",dblclick:"onClick",panstart:"onDragStart",panmove:"onDrag",panend:"onDragEnd"},g_={multipan:[Xi,{threshold:10,pointers:2,trackpad:!0}],pinch:[oo,{trackpad:!0},null,["multipan"]],pan:[Xi,{threshold:1},["pinch"],["multipan"]],dblclick:[qr,{event:"dblclick",taps:2,enable:!1}],dblclickdrag:[ro,{event:"dblclickdrag",enable:!1},["dblclick"],null],click:[qr,{event:"click"},["dblclickdrag"],["dblclick","dblclickdrag"]]};function bN(n,e){if(n===e)return!0;if(Array.isArray(n)){let t=n.length;if(!e||e.length!==t)return!1;for(let i=0;i{for(let r in i)if(!bN(i[r],e[r])){t=n(i),e=i;break}return t}}var GS=[0,0,0,0],vN=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],VS=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],xN=[0,0,0],WS=[0,0,0],wN={default:-1,cartesian:0,lnglat:1,"meter-offsets":2,"lnglat-offsets":3};function Zr(n){let e=wN[n];if(e===void 0)throw new Error(`Invalid coordinateSystem: ${n}`);return e}var EN=jn(PN);function __(n,e,t=WS){t.length<3&&(t=[t[0],t[1],0]);let i=t,r,s=!0;switch(e==="lnglat-offsets"||e==="meter-offsets"?r=t:r=n.isGeospatial?[Math.fround(n.longitude),Math.fround(n.latitude),0]:null,n.projectionMode){case qe.WEB_MERCATOR:(e==="lnglat"||e==="cartesian")&&(r=[0,0,0],s=!1);break;case qe.WEB_MERCATOR_AUTO_OFFSET:e==="lnglat"?i=r:e==="cartesian"&&(i=[Math.fround(n.center[0]),Math.fround(n.center[1]),0],r=n.unprojectPosition(i),i[0]-=t[0],i[1]-=t[1],i[2]-=t[2]);break;case qe.IDENTITY:i=n.position.map(Math.fround),i[2]=i[2]||0;break;case qe.GLOBE:s=!1,r=null;break;default:s=!1}return{geospatialOrigin:r,shaderCoordinateOrigin:i,offsetMode:s}}function SN(n,e,t){let{viewMatrixUncentered:i,projectionMatrix:r}=n,{viewMatrix:s,viewProjectionMatrix:o}=n,a=GS,c=GS,l=n.cameraPosition,{geospatialOrigin:u,shaderCoordinateOrigin:f,offsetMode:d}=__(n,e,t);return d&&(c=n.projectPosition(u||f),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,a=Rt.transformMat4([],c,o),s=i||s,o=We.multiply([],r,s),o=We.multiply([],o,vN)),{viewMatrix:s,viewProjectionMatrix:o,projectionCenter:a,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:f,geospatialOrigin:u}}function jS({viewport:n,devicePixelRatio:e=1,modelMatrix:t=null,coordinateSystem:i="default",coordinateOrigin:r=WS,autoWrapLongitude:s=!1}){i==="default"&&(i=n.isGeospatial?"lnglat":"cartesian");let o=EN({viewport:n,devicePixelRatio:e,coordinateSystem:i,coordinateOrigin:r});return o.wrapLongitude=s,o.modelMatrix=t||VS,o}function PN({viewport:n,devicePixelRatio:e,coordinateSystem:t,coordinateOrigin:i}){let{projectionCenter:r,viewProjectionMatrix:s,originCommon:o,cameraPosCommon:a,shaderCoordinateOrigin:c,geospatialOrigin:l}=SN(n,t,i),u=n.getDistanceScales(),f=[n.width*e,n.height*e],d=Rt.transformMat4([],[0,0,-n.focalDistance,1],n.projectionMatrix)[3]||1,h={coordinateSystem:Zr(t),projectionMode:n.projectionMode,coordinateOrigin:c,commonOrigin:o.slice(0,3),center:r,pseudoMeters:!!n._pseudoMeters,viewportSize:f,devicePixelRatio:e,focalDistance:d,commonUnitsPerMeter:u.unitsPerMeter,commonUnitsPerWorldUnit:u.unitsPerMeter,commonUnitsPerWorldUnit2:xN,scale:n.scale,wrapLongitude:!1,viewProjectionMatrix:s,modelMatrix:VS,cameraPosition:a};if(l){let p=n.getDistanceScales(l);switch(t){case"meter-offsets":h.commonUnitsPerWorldUnit=p.unitsPerMeter,h.commonUnitsPerWorldUnit2=p.unitsPerMeter2;break;case"lnglat":case"lnglat-offsets":n._pseudoMeters||(h.commonUnitsPerMeter=p.unitsPerMeter),h.commonUnitsPerWorldUnit=p.unitsPerDegree,h.commonUnitsPerWorldUnit2=p.unitsPerDegree2;break;case"cartesian":h.commonUnitsPerWorldUnit=[1,1,p.unitsPerMeter[2]],h.commonUnitsPerWorldUnit2=[0,0,p.unitsPerMeter2[2]];break;default:break}}if(n.projectionMode===qe.GLOBE&&t==="meter-offsets"){let g=i[0]*Math.PI/180,v=i[1]*Math.PI/180,y=Math.cos(v),b=((i[2]||0)/6370972+1)*256;h.commonOrigin=[Math.sin(g)*y*b,-Math.cos(g)*y*b,Math.sin(v)*b]}return h}var CN=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],TN=CN.map(n=>`const COORDINATE_SYSTEM_${n.toUpperCase().replaceAll("-","_")}: i32 = ${Zr(n)};`).join(""),LN=Object.keys(qe).map(n=>`const PROJECTION_MODE_${n}: i32 = ${qe[n]};`).join(""),MN=Object.keys(Qt).map(n=>`const UNIT_${n.toUpperCase()}: i32 = ${Qt[n]};`).join(""),AN=`${TN} +${LN} +${MN} const TILE_SIZE: f32 = 512.0; const PI: f32 = 3.1415926536; @@ -3407,7 +3407,7 @@ struct Geometry { }; var geometry: Geometry; -`,HS=`${TN} +`,HS=`${AN} // ----------------------------------------------------------------------------- // Functions @@ -3643,9 +3643,9 @@ fn project_pixel_size_float(pixels: f32) -> f32 { fn project_pixel_size_vec2(pixels: vec2) -> vec2 { return pixels / project.scale; } -`;var LN=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],MN=LN.map(n=>`const int COORDINATE_SYSTEM_${n.toUpperCase().replaceAll("-","_")} = ${Zr(n)};`).join(""),AN=Object.keys(qe).map(n=>`const int PROJECTION_MODE_${n} = ${qe[n]};`).join(""),kN=Object.keys(Jt).map(n=>`const int UNIT_${n.toUpperCase()} = ${Jt[n]};`).join(""),YS=`${MN} -${AN} -${kN} +`;var kN=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],RN=kN.map(n=>`const int COORDINATE_SYSTEM_${n.toUpperCase().replaceAll("-","_")} = ${Zr(n)};`).join(""),IN=Object.keys(qe).map(n=>`const int PROJECTION_MODE_${n} = ${qe[n]};`).join(""),BN=Object.keys(Qt).map(n=>`const int UNIT_${n.toUpperCase()} = ${Qt[n]};`).join(""),YS=`${RN} +${IN} +${BN} layout(std140) uniform projectUniforms { bool wrapLongitude; int coordinateSystem; @@ -3843,7 +3843,7 @@ return pixels / project.scale; vec2 project_pixel_size(vec2 pixels) { return pixels / project.scale; } -`;var RN={};function IN(n=RN){return"viewport"in n?jS(n):{}}var hn={name:"project",dependencies:[Vr,ff],source:HS,vs:YS,getUniforms:IN,uniformTypes:{wrapLongitude:"f32",coordinateSystem:"i32",commonUnitsPerMeter:"vec3",projectionMode:"i32",scale:"f32",commonUnitsPerWorldUnit:"vec3",commonUnitsPerWorldUnit2:"vec3",center:"vec4",modelMatrix:"mat4x4",viewProjectionMatrix:"mat4x4",viewportSize:"vec2",devicePixelRatio:"f32",focalDistance:"f32",cameraPosition:"vec3",coordinateOrigin:"vec3",commonOrigin:"vec3",pseudoMeters:"f32"}};var BN=`// Define a structure to hold both the clip-space position and the common position. +`;var ON={};function DN(n=ON){return"viewport"in n?jS(n):{}}var hn={name:"project",dependencies:[Vr,ff],source:HS,vs:YS,getUniforms:DN,uniformTypes:{wrapLongitude:"f32",coordinateSystem:"i32",commonUnitsPerMeter:"vec3",projectionMode:"i32",scale:"f32",commonUnitsPerWorldUnit:"vec3",commonUnitsPerWorldUnit2:"vec3",center:"vec4",modelMatrix:"mat4x4",viewProjectionMatrix:"mat4x4",viewportSize:"vec2",devicePixelRatio:"f32",focalDistance:"f32",cameraPosition:"vec3",coordinateOrigin:"vec3",commonOrigin:"vec3",pseudoMeters:"f32"}};var NN=`// Define a structure to hold both the clip-space position and the common position. struct ProjectResult { clipPosition: vec4, commonPosition: vec4, @@ -3886,7 +3886,7 @@ fn project_position_to_clipspace( ) -> vec4 { return project_position_to_clipspace_and_commonspace(position, position64Low, offset).clipPosition; } -`,ON=`vec4 project_position_to_clipspace( +`,FN=`vec4 project_position_to_clipspace( vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition ) { vec3 projectedPosition = project_position(position, position64Low); @@ -3906,7 +3906,7 @@ vec4 project_position_to_clipspace( vec4 commonPosition; return project_position_to_clipspace(position, position64Low, offset, commonPosition); } -`,Hn={name:"project32",dependencies:[hn],source:BN,vs:ON};ze();ze();function y_(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Ki(n,e){let t=Rt.transformMat4([],e,n);return Rt.scale(t,t,1/t[3]),t}function oc(n,e,t){return nt?t:n}function DN(n){return Math.log(n)*Math.LOG2E}var ac=Math.log2||DN;ze();function pn(n,e){if(!n)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}var mn=Math.PI,qS=mn/4,en=mn/180,b_=180/mn,co=512,wf=4003e4,lo=85.051129,ZS=1.5;function v_(n){return ac(n)}function ht(n){let[e,t]=n;pn(Number.isFinite(e)),pn(Number.isFinite(t)&&t>=-90&&t<=90,"invalid latitude");let i=e*en,r=t*en,s=co*(i+mn)/(2*mn),o=co*(mn+Math.log(Math.tan(qS+r*.5)))/(2*mn);return[s,o]}function It(n){let[e,t]=n,i=e/co*(2*mn)-mn,r=2*(Math.atan(Math.exp(t/co*(2*mn)-mn))-qS);return[i*b_,r*b_]}function x_(n){let{latitude:e}=n;pn(Number.isFinite(e));let t=Math.cos(e*en);return v_(wf*t)-9}function cc(n){let e=Math.cos(n*en);return co/wf/e}function uo(n){let{latitude:e,longitude:t,highPrecision:i=!1}=n;pn(Number.isFinite(e)&&Number.isFinite(t));let r=co,s=Math.cos(e*en),o=r/360,a=o/s,c=r/wf/s,l={unitsPerMeter:[c,c,c],metersPerUnit:[1/c,1/c,1/c],unitsPerDegree:[o,a,c],degreesPerUnit:[1/o,1/a,1/c]};if(i){let u=en*Math.tan(e*en)/s,f=o*u/2,d=r/wf*u,h=d/a*c;l.unitsPerDegree2=[0,f,d],l.unitsPerMeter2=[h,0,h]}return l}function lc(n,e){let[t,i,r]=n,[s,o,a]=e,{unitsPerMeter:c,unitsPerMeter2:l}=uo({longitude:t,latitude:i,highPrecision:!0}),u=ht(n);u[0]+=s*(c[0]+l[0]*o),u[1]+=o*(c[1]+l[1]*o);let f=It(u),d=(r||0)+(a||0);return Number.isFinite(r)||Number.isFinite(a)?[f[0],f[1],d]:f}function Ef(n){let{height:e,pitch:t,bearing:i,altitude:r,scale:s,center:o}=n,a=y_();Ve.translate(a,a,[0,0,-r]),Ve.rotateX(a,a,-t*en),Ve.rotateZ(a,a,i*en);let c=s/e;return Ve.scale(a,a,[c,c,c]),o&&Ve.translate(a,a,bt.negate([],o)),a}function w_(n){let{width:e,height:t,altitude:i,pitch:r=0,offset:s,center:o,scale:a,nearZMultiplier:c=1,farZMultiplier:l=1}=n,{fovy:u=Xr(ZS)}=n;i!==void 0&&(u=Xr(i));let f=u*en,d=r*en,h=uc(u),p=h;o&&(p+=o[2]*a/Math.cos(d)/t);let m=f*(.5+(s?s[1]:0)/t),g=Math.sin(m)*p/Math.sin(oc(Math.PI/2-d-m,.01,Math.PI-.01)),v=Math.sin(d)*g+p,y=p*10,b=Math.min(v*l,y);return{fov:f,aspect:e/t,focalDistance:h,near:c,far:b}}function Xr(n){return 2*Math.atan(.5/n)*b_}function uc(n){return .5/Math.tan(.5*n*en)}function Qi(n,e){let[t,i,r=0]=n;return pn(Number.isFinite(t)&&Number.isFinite(i)&&Number.isFinite(r)),Ki(e,[t,i,r,1])}function Yn(n,e,t=0){let[i,r,s]=n;if(pn(Number.isFinite(i)&&Number.isFinite(r),"invalid pixel coordinate"),Number.isFinite(s))return Ki(e,[i,r,s,1]);let o=Ki(e,[i,r,0,1]),a=Ki(e,[i,r,1,1]),c=o[2],l=a[2],u=c===l?0:((t||0)-c)/(l-c);return dt.lerp([],o,a,u)}function Sf(n){let{width:e,height:t,bounds:i,minExtent:r=0,maxZoom:s=24,offset:o=[0,0]}=n,[[a,c],[l,u]]=i,f=NN(n.padding),d=ht([a,oc(u,-lo,lo)]),h=ht([l,oc(c,-lo,lo)]),p=[Math.max(Math.abs(h[0]-d[0]),r),Math.max(Math.abs(h[1]-d[1]),r)],m=[e-f.left-f.right-Math.abs(o[0])*2,t-f.top-f.bottom-Math.abs(o[1])*2];pn(m[0]>0&&m[1]>0);let g=m[0]/p[0],v=m[1]/p[1],y=(f.right-f.left)/2/g,b=(f.top-f.bottom)/2/v,x=[(h[0]+d[0])/2+y,(h[1]+d[1])/2+b],E=It(x),w=Math.min(s,ac(Math.abs(Math.min(g,v))));return pn(Number.isFinite(w)),{longitude:E[0],latitude:E[1],zoom:w}}function NN(n=0){return typeof n=="number"?{top:n,bottom:n,left:n,right:n}:(pn(Number.isFinite(n.top)&&Number.isFinite(n.bottom)&&Number.isFinite(n.left)&&Number.isFinite(n.right)),n)}ze();var XS=Math.PI/180;function Pf(n,e=0){let{width:t,height:i,unproject:r}=n,s={targetZ:e},o=r([0,i],s),a=r([t,i],s),c,l,u=n.fovy?.5*n.fovy*XS:Math.atan(.5/n.altitude),f=(90-n.pitch)*XS;return u>f-.01?(c=KS(n,0,e),l=KS(n,t,e)):(c=r([0,0],s),l=r([t,0],s)),[o,a,l,c]}function KS(n,e,t){let{pixelUnprojectionMatrix:i}=n,r=Ki(i,[e,0,1,1]),s=Ki(i,[e,n.height,1,1]),a=(t*n.distanceScales.unitsPerMeter[2]-r[2])/(s[2]-r[2]),c=dt.lerp([],r,s,a),l=It(c);return l.push(t),l}var JS=` +`,Hn={name:"project32",dependencies:[hn],source:NN,vs:FN};Ue();Ue();function y_(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Ki(n,e){let t=Rt.transformMat4([],e,n);return Rt.scale(t,t,1/t[3]),t}function oc(n,e,t){return nt?t:n}function zN(n){return Math.log(n)*Math.LOG2E}var ac=Math.log2||zN;Ue();function pn(n,e){if(!n)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}var mn=Math.PI,qS=mn/4,Jt=mn/180,b_=180/mn,co=512,wf=4003e4,lo=85.051129,ZS=1.5;function v_(n){return ac(n)}function ht(n){let[e,t]=n;pn(Number.isFinite(e)),pn(Number.isFinite(t)&&t>=-90&&t<=90,"invalid latitude");let i=e*Jt,r=t*Jt,s=co*(i+mn)/(2*mn),o=co*(mn+Math.log(Math.tan(qS+r*.5)))/(2*mn);return[s,o]}function It(n){let[e,t]=n,i=e/co*(2*mn)-mn,r=2*(Math.atan(Math.exp(t/co*(2*mn)-mn))-qS);return[i*b_,r*b_]}function x_(n){let{latitude:e}=n;pn(Number.isFinite(e));let t=Math.cos(e*Jt);return v_(wf*t)-9}function cc(n){let e=Math.cos(n*Jt);return co/wf/e}function uo(n){let{latitude:e,longitude:t,highPrecision:i=!1}=n;pn(Number.isFinite(e)&&Number.isFinite(t));let r=co,s=Math.cos(e*Jt),o=r/360,a=o/s,c=r/wf/s,l={unitsPerMeter:[c,c,c],metersPerUnit:[1/c,1/c,1/c],unitsPerDegree:[o,a,c],degreesPerUnit:[1/o,1/a,1/c]};if(i){let u=Jt*Math.tan(e*Jt)/s,f=o*u/2,d=r/wf*u,h=d/a*c;l.unitsPerDegree2=[0,f,d],l.unitsPerMeter2=[h,0,h]}return l}function lc(n,e){let[t,i,r]=n,[s,o,a]=e,{unitsPerMeter:c,unitsPerMeter2:l}=uo({longitude:t,latitude:i,highPrecision:!0}),u=ht(n);u[0]+=s*(c[0]+l[0]*o),u[1]+=o*(c[1]+l[1]*o);let f=It(u),d=(r||0)+(a||0);return Number.isFinite(r)||Number.isFinite(a)?[f[0],f[1],d]:f}function Ef(n){let{height:e,pitch:t,bearing:i,altitude:r,scale:s,center:o}=n,a=y_();We.translate(a,a,[0,0,-r]),We.rotateX(a,a,-t*Jt),We.rotateZ(a,a,i*Jt);let c=s/e;return We.scale(a,a,[c,c,c]),o&&We.translate(a,a,bt.negate([],o)),a}function w_(n){let{width:e,height:t,altitude:i,pitch:r=0,offset:s,center:o,scale:a,nearZMultiplier:c=1,farZMultiplier:l=1}=n,{fovy:u=Xr(ZS)}=n;i!==void 0&&(u=Xr(i));let f=u*Jt,d=r*Jt,h=uc(u),p=h;o&&(p+=o[2]*a/Math.cos(d)/t);let m=f*(.5+(s?s[1]:0)/t),g=Math.sin(m)*p/Math.sin(oc(Math.PI/2-d-m,.01,Math.PI-.01)),v=Math.sin(d)*g+p,y=p*10,b=Math.min(v*l,y);return{fov:f,aspect:e/t,focalDistance:h,near:c,far:b}}function Xr(n){return 2*Math.atan(.5/n)*b_}function uc(n){return .5/Math.tan(.5*n*Jt)}function Qi(n,e){let[t,i,r=0]=n;return pn(Number.isFinite(t)&&Number.isFinite(i)&&Number.isFinite(r)),Ki(e,[t,i,r,1])}function Yn(n,e,t=0){let[i,r,s]=n;if(pn(Number.isFinite(i)&&Number.isFinite(r),"invalid pixel coordinate"),Number.isFinite(s))return Ki(e,[i,r,s,1]);let o=Ki(e,[i,r,0,1]),a=Ki(e,[i,r,1,1]),c=o[2],l=a[2],u=c===l?0:((t||0)-c)/(l-c);return dt.lerp([],o,a,u)}function Sf(n){let{width:e,height:t,bounds:i,minExtent:r=0,maxZoom:s=24,offset:o=[0,0]}=n,[[a,c],[l,u]]=i,f=UN(n.padding),d=ht([a,oc(u,-lo,lo)]),h=ht([l,oc(c,-lo,lo)]),p=[Math.max(Math.abs(h[0]-d[0]),r),Math.max(Math.abs(h[1]-d[1]),r)],m=[e-f.left-f.right-Math.abs(o[0])*2,t-f.top-f.bottom-Math.abs(o[1])*2];pn(m[0]>0&&m[1]>0);let g=m[0]/p[0],v=m[1]/p[1],y=(f.right-f.left)/2/g,b=(f.top-f.bottom)/2/v,x=[(h[0]+d[0])/2+y,(h[1]+d[1])/2+b],E=It(x),w=Math.min(s,ac(Math.abs(Math.min(g,v))));return pn(Number.isFinite(w)),{longitude:E[0],latitude:E[1],zoom:w}}function UN(n=0){return typeof n=="number"?{top:n,bottom:n,left:n,right:n}:(pn(Number.isFinite(n.top)&&Number.isFinite(n.bottom)&&Number.isFinite(n.left)&&Number.isFinite(n.right)),n)}Ue();var XS=Math.PI/180;function Pf(n,e=0){let{width:t,height:i,unproject:r}=n,s={targetZ:e},o=r([0,i],s),a=r([t,i],s),c,l,u=n.fovy?.5*n.fovy*XS:Math.atan(.5/n.altitude),f=(90-n.pitch)*XS;return u>f-.01?(c=KS(n,0,e),l=KS(n,t,e)):(c=r([0,0],s),l=r([t,0],s)),[o,a,l,c]}function KS(n,e,t){let{pixelUnprojectionMatrix:i}=n,r=Ki(i,[e,0,1,1]),s=Ki(i,[e,n.height,1,1]),a=(t*n.distanceScales.unitsPerMeter[2]-r[2])/(s[2]-r[2]),c=dt.lerp([],r,s,a),l=It(c);return l.push(t),l}var JS=` layout(std140) uniform shadowUniforms { bool drawShadowMap; bool useShadowMap; @@ -3918,7 +3918,7 @@ layout(std140) uniform shadowUniforms { vec4 projectCenter0; vec4 projectCenter1; } shadow; -`,UN=` +`,VN=` const int max_lights = 2; out vec3 shadow_vPosition[max_lights]; @@ -3944,10 +3944,10 @@ vec4 shadow_setVertexPosition(vec4 position_commonspace) { } return gl_Position; } -`,$N=` +`,WN=` ${JS} -${UN} -`,GN=` +${VN} +`,jN=` const int max_lights = 2; uniform sampler2D shadow_uShadowMap0; uniform sampler2D shadow_uShadowMap1; @@ -3987,20 +3987,20 @@ vec4 shadow_filterShadowColor(vec4 color) { } return color; } -`,VN=` +`,HN=` ${JS} -${GN} -`,WN=jn(ZN),jN=jn(XN),HN=[0,0,0,1],YN=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];function qN(n,e){let[t,i,r]=n,s=Yn([t,i,r],e);return Number.isFinite(r)?s:[s[0],s[1],0]}function ZN({viewport:n,center:e}){return new Fe(n.viewProjectionMatrix).invert().transform(e)}function XN({viewport:n,shadowMatrices:e}){let t=[],i=n.pixelUnprojectionMatrix,r=n.isGeospatial?void 0:1,s=[[0,0,r],[n.width,0,r],[0,n.height,r],[n.width,n.height,r],[0,0,-1],[n.width,0,-1],[0,n.height,-1],[n.width,n.height,-1]].map(o=>qN(o,i));for(let o of e){let a=o.clone().translate(new et(n.center).negate()),c=s.map(u=>a.transform(u)),l=new Fe().ortho({left:Math.min(...c.map(u=>u[0])),right:Math.max(...c.map(u=>u[0])),bottom:Math.min(...c.map(u=>u[1])),top:Math.max(...c.map(u=>u[1])),near:Math.min(...c.map(u=>-u[2])),far:Math.max(...c.map(u=>-u[2]))});t.push(l.multiplyRight(o))}return t}function KN(n){let{shadowEnabled:e=!0,project:t}=n;if(!e||!t||!n.shadowMatrices||!n.shadowMatrices.length)return{drawShadowMap:!1,useShadowMap:!1,shadow_uShadowMap0:n.dummyShadowMap,shadow_uShadowMap1:n.dummyShadowMap};let i=hn.getUniforms(t),r=WN({viewport:t.viewport,center:i.center}),s=[],o=jN({shadowMatrices:n.shadowMatrices,viewport:t.viewport}).slice();for(let c=0;c0:!1,color:n.shadowColor||HN,lightId:n.shadowLightId||0,lightCount:n.shadowMatrices.length,shadow_uShadowMap0:n.dummyShadowMap,shadow_uShadowMap1:n.dummyShadowMap};for(let c=0;cKN(o,i));for(let o of e){let a=o.clone().translate(new et(n.center).negate()),c=s.map(u=>a.transform(u)),l=new ze().ortho({left:Math.min(...c.map(u=>u[0])),right:Math.max(...c.map(u=>u[0])),bottom:Math.min(...c.map(u=>u[1])),top:Math.max(...c.map(u=>u[1])),near:Math.min(...c.map(u=>-u[2])),far:Math.max(...c.map(u=>-u[2]))});t.push(l.multiplyRight(o))}return t}function eF(n){let{shadowEnabled:e=!0,project:t}=n;if(!e||!t||!n.shadowMatrices||!n.shadowMatrices.length)return{drawShadowMap:!1,useShadowMap:!1,shadow_uShadowMap0:n.dummyShadowMap,shadow_uShadowMap1:n.dummyShadowMap};let i=hn.getUniforms(t),r=YN({viewport:t.viewport,center:i.center}),s=[],o=qN({shadowMatrices:n.shadowMatrices,viewport:t.viewport}).slice();for(let c=0;c0:!1,color:n.shadowColor||ZN,lightId:n.shadowLightId||0,lightCount:n.shadowMatrices.length,shadow_uShadowMap0:n.dummyShadowMap,shadow_uShadowMap1:n.dummyShadowMap};for(let c=0;c",lightId:"i32",lightCount:"f32",viewProjectionMatrix0:"mat4x4",viewProjectionMatrix1:"mat4x4",projectCenter0:"vec4",projectCenter1:"vec4"}};vt();var Tf=10,fc=16777215;function t1(n,e){n.length===Tf?ae.warn(`pickMultipleObjects can only exclude ${Tf} previously picked objects for layers without picking buffers`)():n.push(e)}var QN=` float disabledPickingIndexCount; + `},getUniforms:eF,uniformTypes:{drawShadowMap:"f32",useShadowMap:"f32",color:"vec4",lightId:"i32",lightCount:"f32",viewProjectionMatrix0:"mat4x4",viewProjectionMatrix1:"mat4x4",projectCenter0:"vec4",projectCenter1:"vec4"}};vt();var Tf=10,fc=16777215;function t1(n,e){n.length===Tf?ae.warn(`pickMultipleObjects can only exclude ${Tf} previously picked objects for layers without picking buffers`)():n.push(e)}var tF=` float disabledPickingIndexCount; vec4 disabledPickingIndices0; vec4 disabledPickingIndices1; vec4 disabledPickingIndices2; `;function e1(n){return n.replace(` vec4 highlightColor; } picking;`,` vec4 highlightColor; -${QN}} picking;`)}function E_(n,e){return[n[e]||0,n[e+1]||0,n[e+2]||0,n[e+3]||0]}var JN=`vec3 picking_getPickingColorFromIndex(float objectIndex) { +${tF}} picking;`)}function E_(n,e){return[n[e]||0,n[e+1]||0,n[e+2]||0,n[e+3]||0]}var nF=`vec3 picking_getPickingColorFromIndex(float objectIndex) { if (objectIndex < 0.0 || objectIndex >= ${fc}.0) { return vec3(0.0); } @@ -4037,7 +4037,7 @@ vec3 picking_getPickingColorFromInstanceID() { void picking_setPickingColorFromInstanceID() { picking_setPickingColor(picking_getPickingColorFromInstanceID()); } -`,eF=`struct pickingUniforms { +`,iF=`struct pickingUniforms { isActive: f32, isAttribute: f32, isHighlightActive: f32, @@ -4096,7 +4096,7 @@ fn picking_getPickingColorFromIndex(objectIndex: u32) -> vec3 { ) / 255.0; } `,qn={...Zi,vs:`${e1(Zi.vs)} -${JN}`,fs:e1(Zi.fs),source:eF,uniformTypes:{...Zi.uniformTypes,disabledPickingIndexCount:"f32",disabledPickingIndices0:"vec4",disabledPickingIndices1:"vec4",disabledPickingIndices2:"vec4"},defaultUniforms:{...Zi.defaultUniforms,useByteColors:!0,disabledPickingIndexCount:0,disabledPickingIndices0:[0,0,0,0],disabledPickingIndices1:[0,0,0,0],disabledPickingIndices2:[0,0,0,0]},getUniforms(n,e){let t=Zi.getUniforms(n,e),i=n.disabledPickingIndices||[];return t.disabledPickingIndexCount=i.length,t.disabledPickingIndices0=E_(i,0),t.disabledPickingIndices1=E_(i,4),t.disabledPickingIndices2=E_(i,8),t},inject:{"vs:DECKGL_FILTER_GL_POSITION":` +${nF}`,fs:e1(Zi.fs),source:iF,uniformTypes:{...Zi.uniformTypes,disabledPickingIndexCount:"f32",disabledPickingIndices0:"vec4",disabledPickingIndices1:"vec4",disabledPickingIndices2:"vec4"},defaultUniforms:{...Zi.defaultUniforms,useByteColors:!0,disabledPickingIndexCount:0,disabledPickingIndices0:[0,0,0,0],disabledPickingIndices1:[0,0,0,0],disabledPickingIndices2:[0,0,0,0]},getUniforms(n,e){let t=Zi.getUniforms(n,e),i=n.disabledPickingIndices||[];return t.disabledPickingIndexCount=i.length,t.disabledPickingIndices0=E_(i,0),t.disabledPickingIndices1=E_(i,4),t.disabledPickingIndices2=E_(i,8),t},inject:{"vs:DECKGL_FILTER_GL_POSITION":` // for picking depth values picking_setPickingAttribute(position.z / position.w); `,"vs:DECKGL_FILTER_COLOR":` @@ -4107,10 +4107,10 @@ ${JN}`,fs:e1(Zi.fs),source:eF,uniformTypes:{...Zi.uniformTypes,disabledPickingIn // use picking color if rendering to picking FBO. color = picking_filterPickingColor(color); - `}}};var nF=[ff],iF=["vs:DECKGL_FILTER_SIZE(inout vec3 size, VertexGeometry geometry)","vs:DECKGL_FILTER_GL_POSITION(inout vec4 position, VertexGeometry geometry)","vs:DECKGL_FILTER_COLOR(inout vec4 color, VertexGeometry geometry)","fs:DECKGL_FILTER_COLOR(inout vec4 color, FragmentGeometry geometry)"],rF=[];function n1(n){let e=Kt.getDefaultShaderAssembler(n);for(let i of nF)e.addDefaultModule(i);e._hookFunctions.length=0;let t=n==="glsl"?iF:rF;for(let i of t)e.addShaderHook(i);return e}var sF=[255,255,255],oF=1,aF=0,Lf=class{constructor(e={}){this.type="ambient";let{color:t=sF}=e,{intensity:i=oF}=e;this.id=e.id||`ambient-${aF++}`,this.color=t,this.intensity=i}};ze();var cF=[255,255,255],lF=1,uF=[0,0,-1],fF=0,dc=class{constructor(e={}){this.type="directional";let{color:t=cF}=e,{intensity:i=lF}=e,{direction:r=uF}=e,{_shadow:s=!1}=e;this.id=e.id||`directional-${fF++}`,this.color=t,this.intensity=i,this.type="directional",this.direction=new et(r).normalize().toArray(),this.shadow=s}getProjectedLight(e){return this}};ze();var hc=class{constructor(e,t={id:"pass"}){let{id:i}=t;this.id=i,this.device=e,this.props={...t}}setProps(e){Object.assign(this.props,e)}render(e){}cleanup(){}};var dF={depthWriteEnabled:!0,depthCompare:"less-equal",blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one-minus-src-alpha",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha"},wi=class extends hc{constructor(){super(...arguments),this._lastRenderIndex=-1}render(e){this._render(e)}_render(e){let{canvasContext:t=this.device.canvasContext}=e,i=e.target??t.getCurrentFramebuffer(),[r,s]=t.getDrawingBufferSize(),o=e.clearCanvas??!0,a=e.clearColor??(o?[0,0,0,0]:!1),c=o?1:!1,l=o?0:!1,u=e.colorMask??15,f={viewport:[0,0,r,s]};e.colorMask&&(f.colorMask=u),e.scissorRect&&(f.scissorRect=e.scissorRect);let{shaderModuleProps:d,viewports:h,views:p,onViewportActive:m,clearStack:g=!0}=e,v=e.pass||"unknown",y=this.device.type==="webgpu";g&&(this._lastRenderIndex=-1);let b=[];if(!h.length)return this.device.beginRenderPass({framebuffer:i,parameters:f,clearColor:a,clearDepth:c,clearStencil:l}).end(),this.device.submit(),b;try{for(let x of h){m?.(x);let E=this._getDrawLayerParams(x,e),w=p&&p[x.id],T=x.subViewports||[x],R=y?T.map(F=>[F]):[T];for(let F of R){let O=this.device.beginRenderPass({framebuffer:i,parameters:f,clearColor:a,clearDepth:c,clearStencil:l});try{for(let j of F){let V=this._drawLayersInViewport(O,{target:i,canvasContext:t,shaderModuleProps:d,viewport:j,view:w,pass:v,layers:e.layers,isPicking:e.isPicking},E);b.push(V)}}finally{O.end(),y&&this.device.submit()}a=!1,c=!1,l=!1}}return b}finally{y||this.device.submit()}}_getDrawLayerParams(e,{layers:t,pass:i,isPicking:r=!1,layerFilter:s,cullRect:o,views:a,effects:c,canvasContext:l=this.device.canvasContext,shaderModuleProps:u},f=!1){let d=[],h=r1(this._lastRenderIndex+1),p={layer:t[0],viewport:e,isPicking:r,renderPass:i,cullRect:o},m={};for(let g=0;gE/255):p===!1&&(v=!1),m!==void 0&&(y=m),g!==void 0&&(b=g),this.device.beginRenderPass({framebuffer:s,parameters:{viewport:f,scissorRect:f},clearColor:v,clearDepth:y,clearStencil:b}).end()}}let d={totalCount:t.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:f});for(let h=0;h{let o=r.props._offset,a=r.id,c=r.parent&&r.parent.id,l;if(c&&!(c in e)&&i(r.parent,!1),c in t){let u=t[c]=t[c]||r1(e[c],e);l=u(r,s),t[a]=u}else Number.isFinite(o)?(l=o+(e[c]||0),t[a]=null):l=n;return s&&l>=n&&(n=l+1),e[a]=l,l};return i}function hF(n,{canvasContext:e=n.canvasContext,shaderModuleProps:t,target:i,viewport:r}){let s=t?.project?.devicePixelRatio??e.cssToDeviceRatio(),[,o]=e.getDrawingBufferSize(),a=i?i.height:o,c=r;return[c.x*s,a-(c.y+c.height)*s,c.width*s,c.height*s]}function i1(n,...e){for(let t of e)if(t)for(let i in t)n[i]?Object.assign(n[i],t[i]):n[i]=t[i];return n}var pc=class extends wi{constructor(e,t){super(e,t);let i=e.createTexture({format:"rgba8unorm",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),r=e.createTexture({format:"depth16unorm",width:1,height:1});this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[i],depthStencilAttachment:r})}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null)}getShadowMap(){return this.fbo.colorAttachments[0].texture}render(e){let t=this.fbo,i=this.device.canvasContext.cssToDeviceRatio(),r=e.viewports[0],s=r.width*i,o=r.height*i,a=[1,1,1,1];(s!==t.width||o!==t.height)&&t.resize({width:s,height:o}),super.render({...e,clearColor:a,target:t,pass:"shadow"})}getLayerParameters(e,t,i){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal"}}shouldDrawLayer(e){return e.props.shadowEnabled!==!1}getShaderModuleProps(e,t,i){return{shadow:{project:i.project,drawToShadowMap:!0}}}};var pF={color:[255,255,255],intensity:1},s1=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],mF=[0,0,0,200/255],fo=class{constructor(e={}){this.id="lighting-effect",this.shadowColor=mF,this.shadow=!1,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;let{device:t,deck:i}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(t),i._addDefaultShaderModule(Cf),this.dummyShadowMap=t.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=void 0,this.directionalLights=[],this.pointLights=[];for(let t in e){let i=e[t];switch(i.type){case"ambient":this.ambientLight=i;break;case"directional":this.directionalLights.push(i);break;case"point":this.pointLights.push(i);break;default:}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(t=>t.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:t,viewports:i,onViewportActive:r,views:s}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let o=0;oo.getShadowMap()),dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{},r={enabled:!0,lights:this._getLights(e)},s=e.props.material;return{shadow:i,lighting:r,phongMaterial:s,gouraudMaterial:s}}cleanup(e){for(let t of this.shadowPasses)t.delete();this.shadowPasses.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(Cf))}_calculateMatrices(){let e=[];for(let t of this.directionalLights){let i=new Fe().lookAt({eye:new et(t.direction).negate()});e.push(i)}return e}_createShadowPasses(e){for(let t=0;tr&&(s=r);let o=this._pool,a=e.BYTES_PER_ELEMENT*s,c=o.findIndex(l=>l.byteLength>=a);if(c>=0){let l=new e(o.splice(c,1)[0],0,s);return i&&l.fill(0),l}return new e(s)}_release(e){if(!ArrayBuffer.isView(e))return;let t=this._pool,{buffer:i}=e,{byteLength:r}=i,s=t.findIndex(o=>o.byteLength>=r);s<0?t.push(i):(s>0||t.lengththis.opts.poolSize&&t.shift()}},gn=new S_;ze();function po(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function P_(n,e){let t=n%e;return t<0?e+t:t}function a1(n){return[n[12],n[13],n[14]]}function c1(n){return{left:ho(n[3]+n[0],n[7]+n[4],n[11]+n[8],n[15]+n[12]),right:ho(n[3]-n[0],n[7]-n[4],n[11]-n[8],n[15]-n[12]),bottom:ho(n[3]+n[1],n[7]+n[5],n[11]+n[9],n[15]+n[13]),top:ho(n[3]-n[1],n[7]-n[5],n[11]-n[9],n[15]-n[13]),near:ho(n[3]+n[2],n[7]+n[6],n[11]+n[10],n[15]+n[14]),far:ho(n[3]-n[2],n[7]-n[6],n[11]-n[10],n[15]-n[14])}}var o1=new et;function ho(n,e,t,i){o1.set(n,e,t);let r=o1.len();return{distance:i/r,normal:new et(-n/r,-e/r,-t/r)}}function gF(n){return n-Math.fround(n)}var mc;function mo(n,e){let{size:t=1,startIndex:i=0}=e,r=e.endIndex!==void 0?e.endIndex:n.length,s=(r-i)/t;mc=gn.allocate(mc,s,{type:Float32Array,size:t*2});let o=i,a=0;for(;ow.useInPicking),pass:h,canvasContext:m,isPicking:!0,shaderModuleProps:g,clearColor:v??[0,0,0,0],colorMask:15,scissorRect:b});return this._colorEncoderState=null,{decodePickingColor:y&&r6.bind(null,y),stats:x}}shouldDrawLayer(e){let{pickable:t,operation:i}=e.props;return t&&i.includes("draw")||i.includes("terrain")||i.includes("mask")}getShaderModuleProps(e,t,i){return{picking:{isActive:1,isAttribute:this.pickZ,disabledPickingIndices:e.internalState?.disabledPickingIndices},lighting:{enabled:!1}}}getLayerParameters(e,t,i){let r={...e.props.parameters},{pickable:s,operation:o}=e.props;return this._colorEncoderState?s&&o.includes("draw")?(Object.assign(r,i6),r.blend=!0,this.device.type==="webgpu"?r.blendConstant=j1(this._colorEncoderState,e,i):r.blendColor=j1(this._colorEncoderState,e,i),o.includes("terrain")&&e.state?._hasPickingCover&&(r.blendAlphaSrcFactor="one")):o.includes("terrain")&&(r.blend=!1):r.blend=!1,r}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}};function j1(n,e,t){let{byLayer:i,byAlpha:r}=n,s,o=i.get(e);return o?(o.viewports.push(t),s=o.a):(s=i.size+1,s<=255?(o={a:s,layer:e,viewports:[t]},i.set(e,o),r[s]=o):(ae.warn("Too many pickable layers, only picking the first 255")(),s=0)),[0,0,0,s/255]}function r6(n,e){let t=n.byAlpha[e[3]];return t&&{pickedLayer:t.layer,pickedViewports:t.viewports,pickedObjectIndex:t.layer.decodePickingColor(e)}}Me();var Ji={NO_STATE:"Awaiting state",MATCHED:"Matched. State transferred from previous layer",INITIALIZED:"Initialized",AWAITING_GC:"Discarded. Awaiting garbage collection",AWAITING_FINALIZATION:"No longer matched. Awaiting garbage collection",FINALIZED:"Finalized! Awaiting garbage collection"},wo=Symbol.for("component"),Kn=Symbol.for("propTypes"),Of=Symbol.for("deprecatedProps"),Si=Symbol.for("asyncPropDefaults"),Qn=Symbol.for("asyncPropOriginal"),_n=Symbol.for("asyncPropResolved");function Df(n,e=()=>!0){return Array.isArray(n)?H1(n,e,[]):e(n)?[n]:[]}function H1(n,e,t){let i=-1;for(;++i0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,t){if(e===this._data&&!t)return;this._data=e;let i=++this._loadCount,r=e;typeof e=="string"&&(r=zs(e)),r instanceof Promise?(this.isLoaded=!1,this._loader=r.then(s=>{this._loadCount===i&&(this.isLoaded=!0,this._error=void 0,this._content=s)}).catch(s=>{this._loadCount===i&&(this.isLoaded=!0,this._error=s||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(let s of this._subscribers)s.onChange(this.getData())}};var xc=class{constructor(e){this.protocol=e.protocol||"resource://",this._context={device:e.device,gl:e.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return e.startsWith(this.protocol)?!0:e in this._resources}add({resourceId:e,data:t,forceUpdate:i=!1,persistent:r=!0}){let s=this._resources[e];s?s.setData(t,i):(s=new vc(e,t,this._context),this._resources[e]=s),s.persistent=r}remove(e){let t=this._resources[e];t&&(t.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){let t=this._consumers[e];if(t){for(let i in t){let r=t[i],s=this._resources[r.resourceId];s&&s.unsubscribe(r)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:t,consumerId:i,requestId:r="default"}){let{_resources:s,protocol:o}=this;e.startsWith(o)&&(e=e.replace(o,""),s[e]||this.add({resourceId:e,data:null,persistent:!1}));let a=s[e];if(this._track(i,r,a,t),a)return a.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(let e in this._resources)this._resources[e].delete()}_track(e,t,i,r){let s=this._consumers,o=s[e]=s[e]||{},a=o[t],c=a&&a.resourceId&&this._resources[a.resourceId];c&&(c.unsubscribe(a),this.prune()),i&&(a?(a.onChange=r,a.resourceId=i.id):a={onChange:r,resourceId:i.id},o[t]=a,i.subscribe(a))}_prune(){this._pruneRequest=null;for(let e of Object.keys(this._resources)){let t=this._resources[e];!t.persistent&&!t.inUse()&&(t.delete(),delete this._resources[e])}}};var s6="layerManager.setLayers",o6="layerManager.activateViewport",wc=class{constructor(e,t){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=a=>{Ne(o6,this,a),a&&(this.context.viewport=a)};let{deck:i,stats:r,viewport:s,timeline:o}=t||{};this.layers=[],this.resourceManager=new xc({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e?.gl,deck:i,shaderAssembler:n1(e?.info?.shadingLanguage||"glsl"),defaultShaderModules:[s_],renderPass:void 0,stats:r||new Yt({id:"deck.gl"}),viewport:s||new go({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:o||new Qr,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(let e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(let i of this.layers){let r=i.getNeedsRedraw(e);t=t||r}return t}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(t=>e.find(i=>t.id.indexOf(i)===0)):this.layers}setProps(e){"debug"in e&&(this._debug=e.debug),"userData"in e&&(this.context.userData=e.userData),"layers"in e&&(this._nextLayers=e.layers),"onError"in e&&(this.context.onError=e.onError)}setLayers(e,t){Ne(s6,this,t,e),this._lastRenderedLayers=e;let i=Df(e,Boolean);for(let r of i)r.context=this.context;this._updateLayers(this.layers,i)}updateLayers(){let e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){let{defaultShaderModules:t}=this.context;t.find(i=>i.name===e.name)||(t.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){let{defaultShaderModules:t}=this.context,i=t.findIndex(r=>r.name===e.name);i>=0&&(t.splice(i,1),this._defaultShaderModulesChanged=!0)}_handleError(e,t,i){i.raiseError(t,`${e} of ${i}`)}_updateLayers(e,t){let i={};for(let o of e)i[o.id]?ae.warn(`Multiple old layers with same id ${o.id}`)():i[o.id]=o;if(this._defaultShaderModulesChanged){for(let o of e)o.setNeedsUpdate(),o.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}let r=[];this._updateSublayersRecursively(t,i,r),this._finalizeOldLayers(i);let s=!1;for(let o of r)if(o.hasUniformTransition()){s=`Uniform transition in ${o}`;break}this._needsUpdate=s,this.layers=r}_updateSublayersRecursively(e,t,i){for(let r of e){r.context=this.context;let s=t[r.id];s===null&&ae.warn(`Multiple new layers with same id ${r.id}`)(),t[r.id]=null;let o=null;try{this._debug&&s!==r&&r.validateProps(),s?(this._transferLayerState(s,r),this._updateLayer(r)):this._initializeLayer(r),i.push(r),o=r.isComposite?r.getSubLayers():null}catch(a){this._handleError("matching",a,r)}o&&this._updateSublayersRecursively(o,t,i)}}_finalizeOldLayers(e){for(let t in e){let i=e[t];i&&this._finalizeLayer(i)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=Ji.INITIALIZED}catch(t){this._handleError("initialization",t,e)}}_transferLayerState(e,t){t._transferState(e),t.lifecycle=Ji.MATCHED,t!==e&&(e.lifecycle=Ji.AWAITING_GC)}_updateLayer(e){try{e._update()}catch(t){this._handleError("update",t,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=Ji.AWAITING_FINALIZATION;try{e._finalize(),e.lifecycle=Ji.FINALIZED}catch(t){this._handleError("finalization",t,e)}}};function Ee(n,e,t){if(n===e)return!0;if(!t||!n||!e)return!1;if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let i=0;i{let i=!e.canvasId||this.getCanvasId(t.id)===e.canvasId,r=!("x"in e)||t.containsPixel(e);return i&&r}):this._viewports}getViews(){let e={};return this.views.forEach(t=>{e[t.id]=t}),e}getView(e){return this.views.find(t=>t.id===e)}getViewState(e){let t=typeof e=="string"?this.getView(e):e,i=t&&this.viewState[t.getViewStateId()]||this.viewState;return t?t.filterViewState(i):i}getViewport(e){return this._viewportMap[e]}getCanvasId(e){let t=typeof e=="string"?this.getView(e):e;return t?this._viewEventManagers[t.id]?.canvasId||this._getCanvasIdFromView(t):void 0}unproject(e,t){let i=this.getViewports(),r={x:e[0],y:e[1]};for(let s=i.length-1;s>=0;--s){let o=i[s];if(o.containsPixel(r)){let a=e.slice();return a[0]-=o.x,a[1]-=o.y,o.unproject(a,t)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),("width"in e||"height"in e)&&this._setSize(e.width,e.height),"pickPosition"in e&&(this._pickPosition=e.pickPosition),"eventManagers"in e&&this._setEventManagers(e.eventManagers||{}),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,t){(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.setNeedsUpdate("Size changed"))}_setViews(e){e=Df(e,Boolean),this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){e?(!Ee(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e):ae.warn("missing `viewState` or `initialViewState`")()}_setEventManagers(e){this._eventManagers!==e&&(this._eventManagers=e,this.setNeedsUpdate("eventManagers changed"))}_getCanvasIdFromView(e){return e.props.canvasId||this._getCanvasContext?.(e.id)?.id||er}_getCanvasDimensions(e){let t=this._getCanvasContext?.(e.id),[i,r]=t?.getCSSSize()||[this.width,this.height];return{width:i,height:r}}_getViewEventManager(e){let t=this.getCanvasId(e)||er;return{canvasId:t,eventManager:this._eventManagers[t]||this._eventManager}}_startViewportRebuild(){let e=this.controllers,t=this._viewEventManagers;return this._viewports=[],this.controllers={},this._viewEventManagers={},{oldControllers:e,oldViewEventManagers:t}}_getReusableController(e,t,i){return e&&(t?.canvasId!==i.canvasId||t?.eventManager!==i.eventManager)?(e.finalize(),null):e}_createController(e,t){let i=t.type;return new i({timeline:this.timeline,eventManager:this._getViewEventManager(e).eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:s=>this.getView(e.id)?.makeViewport({viewState:s,...this._getCanvasDimensions(e)}),pickPosition:(s,o)=>this._pickPosition?.(s,o,e.id)})}_updateController(e,t,i,r){let s=e.controller;if(s&&i){let o={...t,...s,id:e.id,x:i.x,y:i.y,width:i.width,height:i.height};return(!r||r.constructor!==s.type)&&(r=this._createController(e,o)),r&&r.setProps(o),r}return null}_rebuildViewports(){let{views:e}=this,{oldControllers:t,oldViewEventManagers:i}=this._startViewportRebuild(),r=!1;for(let s=e.length;s--;){let o=e[s],{width:a,height:c}=this._getCanvasDimensions(o),l=this._getViewEventManager(o);this._viewEventManagers[o.id]=l;let u=this.getViewState(o),f=o.makeViewport({viewState:u,width:a,height:c}),d=this._getReusableController(t[o.id],i[o.id],l),h=!!o.controller;h&&!d&&(r=!0),(r||!h)&&d&&(d.finalize(),d=null),this.controllers[o.id]=this._updateController(o,u,f,d),f&&this._viewports.unshift(f)}for(let s in t){let o=t[s];o&&!this.controllers[s]&&o.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,t){return e.length!==t.length?!0:e.some((i,r)=>!e[r].equals(t[r]))}};var a6=/^(?:\d+\.?\d*|\.\d+)$/;function xt(n){switch(typeof n){case"number":if(!Number.isFinite(n))throw new Error(`Could not parse position string ${n}`);return{type:"literal",value:n};case"string":try{let e=c6(n);return new U_(e).parseExpression()}catch(e){let t=e instanceof Error?e.message:String(e);throw new Error(`Could not parse position string ${n}: ${t}`)}default:throw new Error(`Could not parse position string ${n}`)}}function z_(n,e){switch(n.type){case"literal":return n.value;case"percentage":return Math.round(n.value*e);case"binary":let t=z_(n.left,e),i=z_(n.right,e);return n.operator==="+"?t+i:t-i;default:throw new Error("Unknown layout expression type")}}function wt(n,e){return z_(n,e)}function c6(n){let e=[],t=0;for(;t="0"&&n<="9"}function Z1(n){return n>="a"&&n<="z"||n>="A"&&n<="Z"}function l6(n){return!!(n&&n.type==="symbol"&&(n.value==="+"||n.value==="-"))}function X1(n,e){let t={...n};for(let i in e)i!=="id"&&(Array.isArray(t[i])&&Array.isArray(e[i])?t[i]=u6(t[i],e[i]):t[i]=e[i]);return t}function u6(n,e){n=n.slice();for(let t=0;t{},Q1={mode:"preserve"},f6={mode:"hard"},$_={BREAK:1,SNAP_TO_END:2,IGNORE:3},d6=n=>n,h6=$_.BREAK,Sc=class{constructor(e){this._onTransitionUpdate=t=>{let{time:i,settings:{interpolator:r,startProps:s,endProps:o,duration:a,easing:c}}=t,l=c(i/a),u=r.interpolateProps(s,o,l);this.propsInTransition=this.getControllerState({...this.props,...u},Q1).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new yn(e.timeline),this.onViewStateChange=e.onViewStateChange||K1,this.onStateChange=e.onStateChange||K1}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let t=!1,i=this.props;if(this.props=e,!i||this._shouldIgnoreViewportChange(i,e))return!1;if(this._isTransitionEnabled(e)){let r=i;if(this.transition.inProgress){let{interruption:s,endProps:o}=this.transition.settings;r={...i,...s===$_.SNAP_TO_END?o:this.propsInTransition||i}}this._triggerTransition(r,e),t=!0}else this.transition.cancel();return t}updateTransition(){this.transition.update()}_isTransitionEnabled(e){let{transitionDuration:t,transitionInterpolator:i}=e;return(t>0||t==="auto")&&!!i}_isUpdateDueToCurrentTransition(e){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition):!1}_shouldIgnoreViewportChange(e,t){return this.transition.inProgress?this.transition.settings.interruption===$_.IGNORE||this._isUpdateDueToCurrentTransition(t):this._isTransitionEnabled(t)?t.transitionInterpolator.arePropsEqual(e,t):!0}_triggerTransition(e,t){let i=this.getControllerState(e,Q1),r=this.getControllerState(t,f6).shortestPathFrom(i),s=t.transitionInterpolator,o=s.getDuration?s.getDuration(e,t):t.transitionDuration;if(o===0)return;let a=s.initializeProps(e,r);this.propsInTransition={};let c={duration:o,easing:t.transitionEasing||d6,interpolator:s,interruption:t.transitionInterruption||h6,startProps:a.start,endProps:a.end,onStart:t.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(t.onTransitionInterrupt),onEnd:this._onTransitionEnd(t.onTransitionEnd)};this.transition.start(c),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return t=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e?.(t)}}};ze();function ge(n,e){if(!n)throw new Error(e||"deck.gl: assertion failed.")}var Pc=class{constructor(e){let{compare:t,extract:i,required:r}=e;this._propsToCompare=t,this._propsToExtract=i||t,this._requiredProps=r}arePropsEqual(e,t){for(let i of this._propsToCompare)if(!(i in e)||!(i in t)||!$n(e[i],t[i]))return!1;return!0}initializeProps(e,t){let i={},r={};for(let s of this._propsToExtract)(s in e||s in t)&&(i[s]=e[s],r[s]=t[s]);return this._checkRequiredProps(i),this._checkRequiredProps(r),{start:i,end:r}}getDuration(e,t){return t.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(t=>{let i=e[t];ge(Number.isFinite(i)||Array.isArray(i),`${t} is required for transition`)})}};ze();var p6=["longitude","latitude","zoom","bearing","pitch"],m6=["longitude","latitude","zoom"],Pi=class extends Pc{constructor(e={}){let t=Array.isArray(e)?e:e.transitionProps,i=Array.isArray(e)?{}:e;i.transitionProps=Array.isArray(t)?{compare:t,required:t}:t||{compare:p6,required:m6},super(i.transitionProps),this.opts=i}initializeProps(e,t){let i=super.initializeProps(e,t),{makeViewport:r,around:s}=this.opts;if(r&&s){let o=r(e),a=r(t),c=o.unproject(s);i.start.around=s,Object.assign(i.end,{around:a.project(c),aroundPosition:c,width:t.width,height:t.height})}return i}interpolateProps(e,t,i){let r={};for(let s of this._propsToExtract)r[s]=fn(e[s]||0,t[s]||0,i);if(t.aroundPosition&&this.opts.makeViewport){let s=this.opts.makeViewport({...t,...r});Object.assign(r,s.panByPosition(t.aroundPosition,fn(e.around,t.around,i)))}return r}};var Jn={transitionDuration:0},g6=300,_6=300,G_=n=>1-(1-n)*(1-n),y6=n=>n===1?1:1-Math.pow(2,-10*n),ts={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],MULTI_PAN:["multipanstart","multipanmove","multipanend"],DOUBLE_CLICK:["dblclick"],DOUBLE_CLICK_DRAG:["dblclickdragstart","dblclickdragmove","dblclickdragend","dblclickdragcancel"],KEYBOARD:["keydown"]},ns={},is=class{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this._multiPanMode=null,this._multiPanStartCenter=null,this._doubleClickDragAnchor=null,this._suppressDoubleClickUntil=0,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.doubleClickDragZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.multiTouchDrag=null,this.trackpadGesture=!1,this.zoomAround="pointer",this.keyboard=!0,this.transitionManager=new Sc({...e,getControllerState:(t,i)=>new this.ControllerState({...t,constraintContext:i,makeViewport:e.makeViewport}),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport,this.pickPosition=e.pickPosition}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){for(let e in this._events)this._events[e]&&this.eventManager?.off(e,this.handleEvent);this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;let t=this._eventStartBlocked;switch(e.type){case"panstart":return t?!1:this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return t||!this._isTrackpadGestureAllowed(e)?!1:this._onPinchStart(e);case"pinchmove":return this._isTrackpadGestureAllowed(e)?this._onPinch(e):!1;case"pinchend":return this._isTrackpadGestureAllowed(e)?this._onPinchEnd(e):!1;case"multipanstart":return t?!1:this._onMultiPanStart(e);case"multipanmove":return this._onMultiPan(e);case"multipanend":return this._onMultiPanEnd(e);case"dblclick":return this._onDoubleClick(e);case"dblclickdragstart":return t?!1:this._onDoubleClickDragStart(e);case"dblclickdragmove":return this._onDoubleClickDrag(e);case"dblclickdragend":case"dblclickdragcancel":return this._onDoubleClickDragEnd(e);case"wheel":return this._onWheel(e);case"keydown":return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){let{x:t,y:i}=this.props,{offsetCenter:r}=e;return[r.x-t,r.y-i]}getZoomPosition(e){if(this.zoomAround==="pointer")return e;let t=this.makeViewport(this.controllerState.getViewportProps()),[i,r]=Qi(t.center,t.pixelProjectionMatrix);return[i,r]}isPointInBounds(e,t){let{width:i,height:r}=this.props;if(t&&t.handled)return!1;let s=e[0]>=0&&e[0]<=i&&e[1]>=0&&e[1]<=r;return s&&t&&t.stopPropagation(),s}isFunctionKeyPressed(e){let{srcEvent:t}=e;return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){let t=setTimeout(()=>{this._eventStartBlocked===t&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=t}setProps(e){e.maxBoundsPadding===void 0&&(e.maxBoundsPadding=null),e.dragMode&&(this.dragMode=e.dragMode);let t=this.props;this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);let{inertia:i}=e;this.inertia=Number.isFinite(i)?i:i===!0?g6:0;let{scrollZoom:r=!0,dragPan:s=!0,dragRotate:o=!0,doubleClickZoom:a=!0,doubleClickDragZoom:c=!1,touchZoom:l=!0,touchRotate:u=!1,multiTouchDrag:f=u?"rotate":null,trackpadGesture:d=!1,zoomAround:h="pointer",keyboard:p=!0}=e,m=!!this.onViewStateChange;if(this.toggleEvents(ts.WHEEL,m&&r),this.toggleEvents(ts.PAN,m),this.toggleEvents(ts.PINCH,m&&(l||f==="rotate")),this.toggleEvents(ts.MULTI_PAN,m&&!!f),this.toggleEvents(ts.DOUBLE_CLICK,m&&a),this.toggleEvents(ts.DOUBLE_CLICK_DRAG,m&&c),this.toggleEvents(ts.KEYBOARD,m&&p),this.scrollZoom=r,this.dragPan=s,this.dragRotate=o,this.doubleClickZoom=a,this.doubleClickDragZoom=c,this.touchZoom=l,this.touchRotate=f==="rotate",this.multiTouchDrag=f,this.trackpadGesture=d,this.zoomAround=h,this.keyboard=p,(!t||t.height!==e.height||t.width!==e.width||t.maxBounds!==e.maxBounds||t.maxBoundsPadding!==e.maxBoundsPadding)&&e.maxBounds){let v=new this.ControllerState({...e,makeViewport:this.makeViewport}),y=v.getViewportProps();Object.keys(y).some(x=>!Ee(y[x],e[x],1))&&this.updateViewport(v)}}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,t){this.eventManager&&e.forEach(i=>{this._events[i]!==t&&(this._events[i]=t,t?this.eventManager.on(i,this.handleEvent):this.eventManager.off(i,this.handleEvent))})}updateViewport(e,t=null,i={}){let r={...e.getViewportProps(),...t},s=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(i),s){let o=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:r,interactionState:this._interactionState,oldViewState:o,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_getConstraintContext(e,t){return this.props.rubberBand?{mode:t==="update"?"elastic":t==="end"?"rebound":"hard"}:{mode:"hard"}}_getReboundTransition(e,t){if(e.mode!=="rebound")return null;let i=t.getViewportProps();return Object.keys(i).some(s=>!Ee(this.props[s],i[s],1))?{...this._getTransitionProps(),transitionDuration:_6,transitionEasing:y6}:null}_onPanStart(e){let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let i=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(i=!i);let r=i?"pan":"rotate",s=this._getConstraintContext(r,"start"),o=i?this.controllerState.panStart({pos:t},s):this.controllerState.rotateStart({pos:t},s);return this._panMove=i,this.updateViewport(o,Jn,{isDragging:!0}),!0}_onPan(e){return this.isDragging()?this._panMove?this._onPanMove(e):this._onPanRotate(e):!1}_onPanEnd(e){return this.isDragging()?this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e):!1}_onPanMove(e){if(!this.dragPan)return!1;let t=this.getCenter(e),i=this.controllerState.pan({pos:t},this._getConstraintContext("pan","update"));return this.updateViewport(i,Jn,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){let{inertia:t}=this;if(this.dragPan&&t&&e.velocity){let i=this.getCenter(e),r=[i[0]+e.velocityX*t/2,i[1]+e.velocityY*t/2],s=this.controllerState.pan({pos:r}).panEnd();this.updateViewport(s,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:G_},{isDragging:!1,isPanning:!0})}else{let i=this.controllerState,r=this._getConstraintContext("pan","end"),s=i.panEnd(r),o=this._getReboundTransition(r,s);this.updateViewport(s,o,{isDragging:!1,isPanning:!!o})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;let t=this.getCenter(e),i=this.controllerState.rotate({pos:t},this._getConstraintContext("rotate","update"));return this.updateViewport(i,Jn,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){let{inertia:t}=this;if(this.dragRotate&&t&&e.velocity){let i=this.getCenter(e),r=[i[0]+e.velocityX*t/2,i[1]+e.velocityY*t/2],s=this.controllerState.rotate({pos:r}).rotateEnd();this.updateViewport(s,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:G_},{isDragging:!1,isRotating:!0})}else{let i=this.controllerState,r=this._getConstraintContext("rotate","end"),s=i.rotateEnd(r),o=this._getReboundTransition(r,s);this.updateViewport(s,o,{isDragging:!1,isRotating:!!o})}return!0}_onWheel(e){if(!this.scrollZoom||this.trackpadGesture&&e.device!=="mouse")return!1;let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;e.srcEvent.preventDefault();let{speed:i=.01,smooth:r=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:s}=e,o=2/(1+Math.exp(-Math.abs(s*i)));s<0&&o!==0&&(o=1/o);let a=this.getZoomPosition(t),c=r?{...this._getTransitionProps({around:a}),transitionDuration:250}:Jn,l=this.controllerState.zoom({pos:a,scale:o});return this.updateViewport(l,c,{isZooming:!0,isPanning:!0}),r||this._setInteractionState({isZooming:!1,isPanning:!1}),!0}_onMultiPanStart(e){let{multiTouchDrag:t}=this;if(!t||!this._isMultiPanEventAllowed(e,t))return!1;let i=e.offsetCenter;if(!this.isPointInBounds(this.getCenter(e),e))return!1;let r=e.pointerType==="trackpad",s={x:i.x-(r?0:e.deltaX),y:i.y-(r?0:e.deltaY)},o={...e,offsetCenter:s},a=this.getCenter(o),c=t==="pan"?this.controllerState.panStart({pos:a},this._getConstraintContext("pan","start")):this.controllerState.rotateStart({pos:a},this._getConstraintContext("rotate","start"));return this._multiPanMode=t,this._multiPanStartCenter=s,this.updateViewport(c,Jn,{isDragging:!0}),!0}_onMultiPan(e){let{mode:t,event:i}=this._getMultiPanEvent(e);return!t||!i||!this.isDragging()?!1:t==="pan"?this._onPanMove(i):this._onPanRotate(i)}_onMultiPanEnd(e){let{mode:t,event:i}=this._getMultiPanEvent(e);if(!t||!i||!this.isDragging())return this._resetMultiPan(),!1;let r=t==="pan"?this._onPanMoveEnd(i):this._onPanRotateEnd(i);return this._resetMultiPan(),r}_isTrackpadGestureAllowed(e){return e.pointerType!=="trackpad"||this.trackpadGesture}_isMultiPanEventAllowed(e,t){return e.pointerType==="trackpad"?this.trackpadGesture&&(t==="pan"?this.dragPan:this.dragRotate):e.pointerType==="touch"&&(t==="pan"?this.dragPan:this.dragRotate)}_getMultiPanEvent(e){let t=this._multiPanMode,i=this._multiPanStartCenter;return!t||!i?{mode:null,event:null}:{mode:t,event:{...e,offsetCenter:{x:i.x+e.deltaX,y:i.y+e.deltaY}}}}_resetMultiPan(){this._multiPanMode=null,this._multiPanStartCenter=null}_onPinchStart(e){this._doubleClickDragAnchor=null;let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let i=this.controllerState.zoomStart({pos:this.getZoomPosition(t)},this._getConstraintContext("zoom","start")).rotateStart({pos:t},this._getConstraintContext("rotate","start"));return ns._startPinchRotation=e.rotation,ns._lastPinchEvent=e,this.updateViewport(i,Jn,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let t=this.controllerState;if(this.touchZoom){let{scale:i}=e,r=this.getCenter(e);t=t.zoom({pos:this.getZoomPosition(r),scale:i},this._getConstraintContext("zoom","update"))}if(this.touchRotate){let{rotation:i}=e;t=t.rotate({deltaAngleX:ns._startPinchRotation-i},this._getConstraintContext("rotate","update"))}return this.updateViewport(t,Jn,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),ns._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;let{inertia:t}=this,{_lastPinchEvent:i}=ns;if(this.touchZoom&&t&&i&&e.scale!==i.scale){let r=this.getCenter(e),s=this.getZoomPosition(r),o=this.controllerState.rotateEnd(),a=Math.log2(e.scale),c=(a-Math.log2(i.scale))/(e.deltaTime-i.deltaTime),l=Math.pow(2,a+c*t/2);o=o.zoom({pos:s,scale:l}).zoomEnd(),this.updateViewport(o,{...this._getTransitionProps({around:s}),transitionDuration:t,transitionEasing:G_},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(t)}else{let r=this.controllerState,s=this._getConstraintContext("zoom","end"),o=this._getConstraintContext("rotate","end"),a=r.zoomEnd(s).rotateEnd(o),c=this._getReboundTransition(this.touchZoom?s:o,a);this.updateViewport(a,c,{isDragging:!1,isPanning:!!c&&this.touchZoom,isZooming:!!c&&this.touchZoom,isRotating:!!c&&this.touchRotate})}return ns._startPinchRotation=null,ns._lastPinchEvent=null,!0}_onDoubleClick(e){if(!this.doubleClickZoom||Date.now()90&&(e=Math.sign(e)*90),Number.isFinite(n)){let[i,r]=ht([n,e]);return[i,Te(r,0,e2)]}let[,t]=ht([0,e]);return[n,Te(t,0,e2)]}var V_=class extends rs{constructor(e){let{width:t,height:i,latitude:r,longitude:s,zoom:o,bearing:a=0,pitch:c=0,altitude:l=1.5,position:u=[0,0,0],maxZoom:f=20,minZoom:d=0,maxPitch:h=60,minPitch:p=0,startPanLngLat:m,startZoomLngLat:g,startRotatePos:v,startRotateLngLat:y,startBearing:b,startPitch:x,startZoom:E,normalize:w=!0,rubberBand:T=!1}=e,{[nn]:R}=e;ge(Number.isFinite(s)),ge(Number.isFinite(r)),ge(Number.isFinite(o));let F=e.maxBounds||(w?t2:null),O=e.maxBoundsPadding||null;super({width:t,height:i,latitude:r,longitude:s,zoom:o,bearing:a,pitch:c,altitude:l,maxZoom:f,minZoom:d,maxPitch:h,minPitch:p,normalize:w,position:u,maxBounds:F,maxBoundsPadding:O,rubberBand:T,[nn]:R},{startPanLngLat:m,startZoomLngLat:g,startRotatePos:v,startRotateLngLat:y,startBearing:b,startPitch:x,startZoom:E},e.makeViewport,e.constraintContext),this.getAltitude=e.getAltitude}panStart({pos:e},t){return this._getUpdatedState({startPanLngLat:this._unproject(e)},t)}pan({pos:e,startPos:t},i){let r=this.getState().startPanLngLat||this._unproject(t);if(!r)return this;let o=this.makeViewport(this.getViewportProps()).panByPosition(r,e);return this._getUpdatedState(o,i)}panEnd(e){return this._getUpdatedState({startPanLngLat:null},e)}rotateStart({pos:e}){let t=this.getAltitude?.(e);return this._getUpdatedState({startRotatePos:e,startRotateLngLat:t!==void 0?this._unproject3D(e,t):void 0,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:t=0,deltaAngleY:i=0}){let{startRotatePos:r,startRotateLngLat:s,startBearing:o,startPitch:a}=this.getState();if(!r||o===void 0||a===void 0)return this;let c;if(e?c=this._getNewRotation(e,r,a,o):c={bearing:o+t,pitch:a+i},s){let l=this.makeViewport({...this.getViewportProps(),...c}),u="panByPosition3D"in l?"panByPosition3D":"panByPosition";return this._getUpdatedState({...c,...l[u](s,r)})}return this._getUpdatedState(c)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startRotateLngLat:null,startBearing:null,startPitch:null})}zoomStart({pos:e},t){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom},t)}zoom({pos:e,startPos:t,scale:i},r){let{startZoom:s,startZoomLngLat:o}=this.getState();return o||(s=this.getViewportProps().zoom,o=this._unproject(t)||this._unproject(e)),o?this._getUpdatedState({zoom:s+Math.log2(i),[nn]:{position:o,screenPosition:e}},r):this}zoomEnd(e){return this._getUpdatedState({startZoomLngLat:null,startZoom:null},e)}zoomIn(e=2,t){return this._zoomFromCenter(e,t)}zoomOut(e=2,t){return this._zoomFromCenter(1/e,t)}moveLeft(e=100,t){return this._panFromCenter([e,0],t)}moveRight(e=100,t){return this._panFromCenter([-e,0],t)}moveUp(e=100,t){return this._panFromCenter([0,e],t)}moveDown(e=100,t){return this._panFromCenter([0,-e],t)}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){let t=e.getViewportProps(),i={...this.getViewportProps()},{bearing:r,longitude:s}=i;return Math.abs(r-t.bearing)>180&&(i.bearing=r<0?r+360:r-360),Math.abs(s-t.longitude)>180&&(i.longitude=s<0?s+360:s-360),i}applyConstraints(e,t){let i=e,r=i[nn];delete i[nn];let{maxPitch:s,minPitch:o,pitch:a,bearing:c,normalize:l,maxBounds:u,rubberBand:f}=e;l&&(c<-180||c>180)&&(e.bearing=P_(c+180,360)-180),e.pitch=Te(a,o,s);let d=this._constrainZoom(e.zoom,e),h=f&&t?.mode==="elastic";if(e.zoom=t?.mode==="preserve"?e.zoom:h?tr(e.zoom,d,v6):d,r){let p=this.makeViewport(e);Object.assign(e,p.panByPosition(r.position,r.screenPosition))}if(l&&(e.longitude<-180||e.longitude>180)&&(e.longitude=P_(e.longitude+180,360)-180),u){let p=Eo(e.width,e.height,e.maxBoundsPadding),m=this.makeViewport({...e,bearing:0,pitch:0}),g=Nf(m,[e.longitude,e.latitude],p),v=Cc(u[0]),y=Cc(u[1]),b=2**e.zoom,x=[v[0]+g.left/b,v[1]+g.bottom/b],E=[y[0]-g.right/b,y[1]-g.top/b],w=Cc([e.longitude,e.latitude]),T=[Te(w[0],x[0],E[0]),Te(w[1],x[1],E[1])],R=w.slice();if(p.width>=0&&(R[0]=t?.mode==="preserve"?w[0]:h?tr(w[0],T[0],p.width/2/b):T[0]),p.height>=0&&(R[1]=t?.mode==="preserve"?w[1]:h?tr(w[1],T[1],p.height/2/b):T[1]),R[0]!==w[0]||R[1]!==w[1]){let[F,O]=It(R);R[0]!==w[0]&&(e.longitude=F),R[1]!==w[1]&&(e.latitude=O)}}return e}_constrainZoom(e,t){t||(t=this.getViewportProps());let{maxZoom:i,maxBounds:r}=t,s=r!==null&&t.width>0&&t.height>0,{minZoom:o}=t;if(s){let a=Eo(t.width,t.height,t.maxBoundsPadding),c=Cc(r[0]),l=Cc(r[1]),u=l[0]-c[0],f=l[1]-c[1];a.width>0&&Number.isFinite(u)&&u>0&&(o=Math.max(o,Math.log2(a.width/u))),a.height>0&&Number.isFinite(f)&&f>0&&(o=Math.max(o,Math.log2(a.height/f))),o>i&&(o=i)}return Te(e,o,i)}_zoomFromCenter(e,t){let{width:i,height:r}=this.getViewportProps();return this.zoom({pos:[i/2,r/2],scale:e},t)}_panFromCenter(e,t){let{width:i,height:r}=this.getViewportProps();return this.pan({startPos:[i/2,r/2],pos:[i/2+e[0],r/2+e[1]]},t)}_getUpdatedState(e,t){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e,constraintContext:t})}_unproject(e){let t=this.makeViewport(this.getViewportProps());return e&&t.unproject(e)}_unproject3D(e,t){return this.makeViewport(this.getViewportProps()).unproject(e,{targetZ:t})}_getNewRotation(e,t,i,r){let s=e[0]-t[0],o=e[1]-t[1],a=e[1],c=t[1],{width:l,height:u}=this.getViewportProps(),f=s/l,d=0;o>0?Math.abs(u-c)>J1&&(d=o/(c-u)*b6):o<0&&c>J1&&(d=1-a/c),d=Te(d,-1,1);let{minPitch:h,maxPitch:p}=this.getViewportProps(),m=r+180*f,g=i;return d>0?g=i+d*(p-i):d<0&&(g=i-d*(h-i)),{pitch:g,bearing:m}}},Tc=class extends is{constructor(){super(...arguments),this.ControllerState=V_,this.transition={transitionDuration:300,transitionInterpolator:new Pi({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan",this.rotationPivot="center",this._getAltitude=e=>{if(this.rotationPivot==="2d")return 0;if(this.rotationPivot==="3d"&&this.pickPosition){let{x:t,y:i}=this.props,r=this.pickPosition(t+e[0],i+e[1]);if(r&&r.coordinate&&r.coordinate.length>=3)return r.coordinate[2]}}}setProps(e){"rotationPivot"in e&&(this.rotationPivot=e.rotationPivot||"center"),e.getAltitude=this._getAltitude,e.position=e.position||[0,0,0],e.maxBounds=e.maxBounds||(e.normalize===!1?null:t2),super.setProps(e)}updateViewport(e,t=null,i={}){let r=e.getState();i.isDragging&&r.startRotateLngLat?i={...i,rotationPivotPosition:r.startRotateLngLat}:i.isDragging===!1&&(i={...i,rotationPivotPosition:void 0}),super.updateViewport(e,t,i)}};var Ff=class extends es{constructor(e={}){super(e)}getViewportType(){return Ei}get ControllerType(){return Tc}};Ff.displayName="MapView";var n2=Ff;var x6=new fo;function w6(n,e){let t=n.order??1/0,i=e.order??1/0;return t-i}var Lc=class{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){let t=this._defaultEffects;if(!t.find(i=>i.id===e.id)){let i=t.findIndex(r=>w6(r,e)>0);i<0?t.push(e):t.splice(i,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&(Ee(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}getEffects(){return this._resolvedEffects}_setEffects(e){let t={};for(let r of this.effects)t[r.id]=r;let i=[];for(let r of e){let s=t[r.id],o=r;s&&s!==r?s.setProps?(s.setProps(r.props),o=s):s.cleanup(this._context):s||r.setup(this._context),i.push(o),delete t[r.id]}for(let r in t)t[r].cleanup(this._context);this.effects=i,this._resolvedEffects=i.concat(this._defaultEffects),e.some(r=>r instanceof fo)||this._resolvedEffects.push(x6),this._needsRedraw="effects changed"}finalize(){for(let e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}};var Mc=class extends wi{shouldDrawLayer(e){let{operation:t}=e.props;return t.includes("draw")||t.includes("terrain")}render(e){return this._render(e)}};var E6="deckRenderer.renderLayers",Ac=class{constructor(e,t={}){this.device=e,this.stats=t.stats,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new Mc(e),this.pickLayersPass=new Jr(e),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(e){let t=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,i={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};if(!e.viewports.length){let a=t.render(i),c="stats"in a?a.stats:a;this._updateStats(c);return}i.effects&&this._preRender(i.effects,i);let r=this.lastPostProcessEffect?this.renderBuffers[0]:i.target;this.lastPostProcessEffect&&(i.clearColor=[0,0,0,0],i.clearCanvas=!0);let s=t.render({...i,target:r}),o="stats"in s?s.stats:s;i.effects&&(this.lastPostProcessEffect&&(i.clearCanvas=e.clearCanvas===void 0?!0:e.clearCanvas),this._postRender(i.effects,i)),this.renderCount++,Ne(E6,this,o,e),this._updateStats(o)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}finalize(){let{renderBuffers:e}=this;for(let t of e)t.delete();e.length=0}_updateStats(e){if(!this.stats)return;let t=0;for(let{visibleCount:i}of e)t+=i;this.stats.get("Layers rendered").addCount(t)}_preRender(e,t){this.lastPostProcessEffect=null,t.preRenderStats=t.preRenderStats||{};for(let i of e)t.preRenderStats[i.id]=i.preRender(t),i.postRender&&(this.lastPostProcessEffect=i.id);this.lastPostProcessEffect&&this._resizeRenderBuffers(t.canvasContext)}_resizeRenderBuffers(e=this.device.canvasContext){let{renderBuffers:t}=this,i=e.getDrawingBufferSize(),[r,s]=i;t.length===0&&[0,1].map(o=>{let a=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"},width:r,height:s});t.push(this.device.createFramebuffer({id:`deck-renderbuffer-${o}`,colorAttachments:[a]}))});for(let o of t)o.resize(i)}_postRender(e,t){let{renderBuffers:i}=this,r=t.target??t.canvasContext?.getCurrentFramebuffer()??t.target,s={...t,inputBuffer:i[0],swapBuffer:i[1]};for(let o of e)if(o.postRender){s.target=o.id===this.lastPostProcessEffect?r:void 0;let a=o.postRender(s);s.inputBuffer=a,s.swapBuffer=a===i[0]?i[1]:i[0]}}};J();var S6={pickedColor:null,pickedObjectIndex:-1};function W_({pickedColors:n,decodePickingColor:e,deviceX:t,deviceY:i,deviceRadius:r,deviceRect:s}){let{x:o,y:a,width:c,height:l}=s,u=r*r,f=-1,d=0;for(let h=0;hu)d+=4*c;else for(let g=0;g=0){let y=g+o-t,b=y*y+m;b<=u&&(u=b,f=d)}d+=4}}if(f>=0){let h=n.slice(f,f+4),p=e(h);if(p){let m=Math.floor(f/4/c),g=f/4-m*c;return{...p,pickedColor:h,pickedX:o+g,pickedY:a+m}}ae.error("Picked non-existent layer. Is picking buffer corrupt?")()}return S6}function j_({pickedColors:n,decodePickingColor:e}){let t=new Map;if(n){for(let i=0;i=0){let s=n.slice(i,i+4),o=s.join(",");if(!t.has(o)){let a=e(s);a?t.set(o,{...a,color:s}):ae.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(t.values())}function zf({pickInfo:n,viewports:e,pixelRatio:t,x:i,y:r,z:s}){let o=e[0];e.length>1&&(o=P6(n?.pickedViewports||e,{x:i,y:r}));let a;if(o){let c=[i-o.x,r-o.y];s!==void 0&&(c[2]=s),a=o.unproject(c)}return{color:null,layer:null,viewport:o,index:-1,picked:!1,x:i,y:r,pixel:[i,r],coordinate:a,devicePixel:n&&"pickedX"in n?[n.pickedX,n.pickedY]:void 0,pixelRatio:t}}function H_(n){let{pickInfo:e,lastPickedInfo:t,mode:i,layers:r}=n,{pickedColor:s,pickedLayer:o,pickedObjectIndex:a}=e,c=o?[o]:[];if(i==="hover"){let f=t.index,d=t.layerId,h=o?o.props.id:null;if(h!==d||a!==f){if(h!==d){let p=r.find(m=>m.props.id===d);p&&c.unshift(p)}t.layerId=h,t.index=a,t.info=null}}let l=zf(n),u=new Map;return u.set(null,l),c.forEach(f=>{let d={...l};f===o&&(d.color=s,d.index=a,d.picked=!0),d=Uf({layer:f,info:d,mode:i});let h=d.layer;f===o&&i==="hover"&&(t.info=d),u.set(h.id,d),i==="hover"&&h.updateAutoHighlight(d)}),u}function Uf({layer:n,info:e,mode:t}){for(;n&&e;){let i=e.layer||null;e.sourceLayer=i,e.layer=n,e=n.getPickingInfo({info:e,mode:t,sourceLayer:i}),n=n.parent}return e}function P6(n,e){for(let t=n.length-1;t>=0;t--){let i=n[t];if(i.containsPixel(e))return i}return n[0]}var kc=class{constructor(e,t={}){this._pickable=!0,this.device=e,this.stats=t.stats,this.pickLayersPass=new Jr(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){"layerFilter"in e&&(this.layerFilter=e.layerFilter),"_pickable"in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObjectAsync(e){return this._pickClosestObjectAsync(e)}pickObjectsAsync(e){return this._pickVisibleObjectsAsync(e)}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:t,layers:i,viewports:r},s=this.lastPickedInfo.info){let o=s&&s.layer&&s.layer.id,a=s&&s.viewport&&s.viewport.id,c=o?i.find(d=>d.id===o):null,l=a&&r.find(d=>d.id===a)||r[0],u=l&&l.unproject([e-l.x,t-l.y]);return{...s,...{x:e,y:t,viewport:l,coordinate:u,layer:c}}}_resizeBuffer(e=this.device.getDefaultCanvasContext()){if(!this.pickingFBO){let r=this.device.createTexture({format:"rgba8unorm",width:1,height:1,usage:me.RENDER_ATTACHMENT|me.COPY_SRC});if(this.pickingFBO=this.device.createFramebuffer({colorAttachments:[r],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float")){let s=this.device.createTexture({format:"rgba32float",width:1,height:1,usage:me.RENDER_ATTACHMENT|me.COPY_SRC}),o=this.device.createFramebuffer({colorAttachments:[s],depthStencilAttachment:"depth16unorm"});this.depthFBO=o}}let[t,i]=e.getDrawingBufferSize();this.pickingFBO?.resize({width:t,height:i}),this.depthFBO?.resize({width:t,height:i})}_getPickable(e){if(this._pickable===!1)return null;let t=e.filter(i=>this.pickLayersPass.shouldDrawLayer(i)&&!i.isComposite);return t.length?t:null}async _pickClosestObjectAsync({layers:e,views:t,viewports:i,x:r,y:s,radius:o=0,depth:a=1,mode:c="query",unproject3D:l,canvasContext:u=this.device.getDefaultCanvasContext(),onViewportActive:f,effects:d}){let h=u.cssToDeviceRatio(),p=this._getPickable(e);if(!p||i.length===0)return{result:[],emptyInfo:zf({viewports:i,x:r,y:s,pixelRatio:h})};this._resizeBuffer(u);let m=u.cssToDevicePixels([r,s],!0),g=[m.x+Math.floor(m.width/2),m.y+Math.floor(m.height/2)],v=Math.round(o*h),{width:y,height:b}=this.pickingFBO,x=this._getPickingRect({deviceX:g[0],deviceY:g[1],deviceRadius:v,deviceWidth:y,deviceHeight:b}),E={x:r-o,y:s-o,width:o*2+1,height:o*2+1},w,T=[],R=new Set;for(let F=0;F0){let{pickedColors:G}=await this._drawAndSampleAsync({layers:V,views:t,viewports:i,onViewportActive:f,deviceRect:{x:O.pickedX??g[0],y:O.pickedY??g[1],width:1,height:1},cullRect:E,effects:d,pass:`picking:${c}:z`,canvasContext:u},!0);G[3]&&(j=G[0])}O.pickedLayer&&F+10){let{pickedColors:G}=this._drawAndSample({layers:V,views:t,viewports:i,onViewportActive:f,deviceRect:{x:O.pickedX??g[0],y:O.pickedY??g[1],width:1,height:1},cullRect:E,effects:d,pass:`picking:${c}:z`,canvasContext:u},!0);G[3]&&(j=G[0])}O.pickedLayer&&F+1=l);j++){let V=T[j],G={color:V.pickedColor,layer:null,index:V.pickedObjectIndex,picked:!0,x:r,y:s,pixelRatio:p};G=Uf({layer:V.pickedLayer,info:G,mode:c});let q=G.layer.id;R.has(q)||R.set(q,new Set);let X=R.get(q),se=G.object??G.index;X.has(se)||(X.add(se),F.push(G))}return F}_pickVisibleObjects({layers:e,views:t,viewports:i,x:r,y:s,width:o=1,height:a=1,mode:c="query",maxObjects:l=null,canvasContext:u=this.device.getDefaultCanvasContext(),onViewportActive:f,effects:d}){let h=this._getPickable(e);if(!h||i.length===0)return[];this._resizeBuffer(u);let p=u.cssToDeviceRatio(),m=u.cssToDevicePixels([r,s],!0),g=m.x,v=m.y+m.height,y=u.cssToDevicePixels([r+o,s+a],!0),b=y.x+y.width,x=y.y,E={x:g,y:x,width:b-g,height:v-x},w=this._drawAndSample({layers:h,views:t,viewports:i,onViewportActive:f,deviceRect:E,cullRect:{x:r,y:s,width:o,height:a},effects:d,pass:`picking:${c}`,canvasContext:u}),T=j_(w),R=new Map,F=[],O=Number.isFinite(l);for(let j=0;j=l);j++){let V=T[j],G={color:V.pickedColor,layer:null,index:V.pickedObjectIndex,picked:!0,x:r,y:s,pixelRatio:p};G=Uf({layer:V.pickedLayer,info:G,mode:c});let q=G.layer.id;R.has(q)||R.set(q,new Set);let X=R.get(q),se=G.object??G.index;X.has(se)||(X.add(se),F.push(G))}return F}async _drawAndSampleAsync({layers:e,views:t,viewports:i,onViewportActive:r,deviceRect:s,cullRect:o,effects:a,pass:c,canvasContext:l},u=!1){let f=u?this.depthFBO:this.pickingFBO,d={layers:e,layerFilter:this.layerFilter,views:t,viewports:i,onViewportActive:r,pickingFBO:f,deviceRect:s,cullRect:o,effects:a,pass:c,canvasContext:l,pickZ:u,preRenderStats:{},isPicking:!0};for(let E of a)E.useInPicking&&(d.preRenderStats[E.id]=E.preRender(d));let{decodePickingColor:h,stats:p}=this.pickLayersPass.render(d);this._updateStats(p);let{x:m,y:g,width:v,height:y}=s,b=f.colorAttachments[0]?.texture;if(!b)throw new Error("Picking framebuffer color attachment is missing");let x=await this._readTextureDataAsync(b,{x:m,y:g,width:v,height:y},u?Float32Array:Uint8Array);if(!u){let E=!1;for(let w=3;w0&&ae.warn("Async pick readback returned only zero alpha values",{deviceRect:s,bytes:Array.from(x.subarray(0,Math.min(x.length,16)))})()}return{pickedColors:x,decodePickingColor:h}}async _readTextureDataAsync(e,t,i){let{width:r,height:s}=t,o=e.computeMemoryLayout(t),a=this.device.createBuffer({byteLength:o.byteLength,usage:ie.COPY_DST|ie.MAP_READ});try{e.readBuffer(t,a);let c=await a.readAsync(0,o.byteLength),l=i.BYTES_PER_ELEMENT;if(o.bytesPerRow%l!==0)throw new Error(`Texture readback row stride ${o.bytesPerRow} is not aligned to ${l}-byte elements.`);let u=new i(c.buffer,c.byteOffset,o.byteLength/l),f=r*4,d=o.bytesPerRow/l;if(do.props.operation.includes("terrain"))}_getPickingRect({deviceX:e,deviceY:t,deviceRadius:i,deviceWidth:r,deviceHeight:s}){let o=Math.max(0,e-i),a=Math.max(0,t-i),c=Math.min(r,e+i+1)-o,l=Math.min(s,t+i+1)-a;return c<=0||l<=0?null:{x:o,y:a,width:c,height:l}}};var C6={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},T6="top-left",i2="root",$f=class{constructor({deck:e,parentElement:t}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,t?.classList.add("deck-widget-container"),this.parentElement=t}getWidgets(){return this.resolvedWidgets}setProps(e){if(e.widgets&&!Ee(e.widgets,this.widgets,1)){let t=e.widgets.filter(Boolean);this._setWidgets(t)}}finalize(){for(let e of this.getWidgets())this._removeWidget(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(let e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(t=>t.id===e.id)||(this._addWidget(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}onRedraw({viewports:e,layers:t}){let i=e.reduce((r,s)=>(r[s.id]=s,r),{});for(let r of this.getWidgets()){let{viewId:s}=r;if(s){let o=i[s];o&&(r.onViewportChange&&r.onViewportChange(o),r.onRedraw?.({viewports:[o],layers:t}))}else{if(r.onViewportChange)for(let o of e)r.onViewportChange(o);r.onRedraw?.({viewports:e,layers:t})}}this.lastViewports=i,this._updateContainers()}onHover(e,t){for(let i of this.getWidgets()){let{viewId:r}=i;(!r||r===e.viewport?.id)&&i.onHover?.(e,t)}}getCanvasBounds(e){let i=this.deck?.getCanvas?.()?.getBoundingClientRect(),r=this.parentElement?.getBoundingClientRect(),s=this.deck?.getCanvasContext?.(e?.id);if(s&&r){s.updatePosition();let[o,a]=s.getPosition(),[c,l]=s.getCSSSize();return{x:o-r.left,y:a-r.top,width:c,height:l}}return{x:i&&r?i.left-r.left:0,y:i&&r?i.top-r.top:0,width:i?.width||this.deck?.width||0,height:i?.height||this.deck?.height||0}}onEvent(e,t){let i=ao[t.type];if(i)for(let r of this.getWidgets()){let{viewId:s}=r;(!s||s===e.viewport?.id)&&r[i]?.(e,t)}}_setWidgets(e){let t={};for(let i of this.resolvedWidgets)t[i.id]=i;this.resolvedWidgets.length=0;for(let i of this.defaultWidgets)t[i.id]=null,this.resolvedWidgets.push(i);for(let i of e){let r=t[i.id];r?r.viewId!==i.viewId||r.placement!==i.placement?(this._removeWidget(r),this._addWidget(i)):i!==r&&(r.setProps(i.props),i=r):this._addWidget(i),t[i.id]=null,this.resolvedWidgets.push(i)}for(let i in t){let r=t[i];r&&this._removeWidget(r)}this.widgets=e}_addWidget(e){let{viewId:t=null,placement:i=T6}=e,r=e.props._container??t;e.widgetManager=this,e.deck=this.deck,e.rootElement=e._onAdd({deck:this.deck,viewId:t}),e.rootElement&&this._getContainer(r,i).append(e.rootElement),e.updateHTML()}_removeWidget(e){e.onRemove?.(),e.rootElement&&e.rootElement.remove(),e.rootElement=void 0,e.deck=void 0,e.widgetManager=void 0}_getContainer(e,t){if(e&&typeof e!="string")return e;let i=e||i2,r=this.containers[i];r||(r=document.createElement("div"),r.style.pointerEvents="none",r.style.position="absolute",r.style.overflow="hidden",this.parentElement?.append(r),this.containers[i]=r);let s=r.querySelector(`.${t}`);return s||(s=globalThis.document.createElement("div"),s.className=t,s.style.position="absolute",s.style.zIndex="2",Object.assign(s.style,C6[t]),r.append(s)),s}_updateContainers(){for(let e in this.containers){let t=this.lastViewports[e]||null,i=e===i2||t,r=this.containers[e];if(i){let s=this._getContainerBounds(t);r.style.display="block",r.style.left=`${s.x}px`,r.style.top=`${s.y}px`,r.style.width=`${s.width}px`,r.style.height=`${s.height}px`}else r.style.display="none"}}_getContainerBounds(e){if(!e)return{x:0,y:0,width:this.parentElement?.clientWidth||this.deck.width,height:this.parentElement?.clientHeight||this.deck.height};let t=this.getCanvasBounds(e);return{x:t.x+e.x,y:t.y+e.y,width:e.width,height:e.height}}};function Y_(n,e){e&&Object.entries(e).map(([t,i])=>{t.startsWith("--")?n.style.setProperty(t,i):n.style[t]=i})}function r2(n,e){e&&Object.keys(e).map(t=>{t.startsWith("--")?n.style.removeProperty(t):n.style[t]=""})}var So=class{constructor(e){this.viewId=null,this.props={...this.constructor.defaultProps,...e},this.id=this.props.id}setProps(e){let t=this.props,i=this.rootElement;i&&t.className!==e.className&&(t.className&&i.classList.remove(t.className),e.className&&i.classList.add(e.className)),i&&!Ee(t.style,e.style,1)&&(r2(i,t.style),Y_(i,e.style)),Object.assign(this.props,e),this.updateHTML()}updateHTML(){this.rootElement&&this.onRenderHTML(this.rootElement)}get viewIds(){return this.viewId?[this.viewId]:this.deck?.getViews().map(e=>e.id)??[]}getViewState(e){return this.deck?.viewManager?.getViewState(e)||{}}setViewState(e,t){this.deck?._onViewStateChange({viewId:e,viewState:t,interactionState:{}})}onCreateRootElement(){let e=["deck-widget",this.className,this.props.className],t=document.createElement("div");return e.filter(i=>typeof i=="string"&&i.length>0).forEach(i=>t.classList.add(i)),Y_(t,this.props.style),t}_onAdd(e){return this.onAdd(e)??this.onCreateRootElement()}onAdd(e){}onRemove(){}onViewportChange(e){}onRedraw(e){}onHover(e,t){}onClick(e,t){}onDrag(e,t){}onDragStart(e,t){}onDragEnd(e,t){}};So.defaultProps={id:"widget",style:{},_container:null,className:""};var L6={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"},Rc=class extends So{constructor(e={}){super(e),this.id="default-tooltip",this.placement="fill",this.className="deck-tooltip",this.isVisible=!1,this.setProps(e)}onCreateRootElement(){let e=document.createElement("div");return e.className=this.className,Object.assign(e.style,L6),e}onRenderHTML(e){}onViewportChange(e){this.isVisible&&e.id===this.lastViewport?.id&&!e.equals(this.lastViewport)&&this.setTooltip(null),this.lastViewport=e}onHover(e){let{deck:t}=this,i=t&&t.props.getTooltip;if(!i)return;let r=i(e),s=this.widgetManager?.getCanvasBounds(e.viewport),o=e.x+(s?.x||0),a=e.y+(s?.y||0);this.setTooltip(r,o,a)}setTooltip(e,t,i){let r=this.rootElement;if(r){if(typeof e=="string")r.innerText=e;else if(e)e.text&&(r.innerText=e.text),e.html&&(r.innerHTML=e.html),e.className&&(r.className=e.className);else{this.isVisible=!1,r.style.display="none";return}this.isVisible=!0,r.style.display="block",r.style.transform=`translate(${t}px, ${i}px)`,e&&typeof e=="object"&&"style"in e&&Object.assign(r.style,e.style)}}};Rc.defaultProps={...So.defaultProps};var Ic=class{constructor(e){this.targets={},this.order=[],this.eventManagers={},this._eventRootToCanvasId=new WeakMap,this._createEventManager=e.createEventManager,this._getEventRoot=e.getEventRoot}finalize(){for(let e of Object.values(this.targets))e.eventManager.destroy(),e.presentationContext.destroy();this.targets={},this.order=[],this.eventManagers={},this._eventRootToCanvasId=new WeakMap}syncCanvasEntries(e){let t=this._normalizeCanvasList(e.canvases),i={},r=[],s=new Map;for(let{canvas:a}of t){let c=this._getEventRoot(a);s.set(c,(s.get(c)||0)+1)}for(let{id:a,canvas:c}of t){let l=this._getEventRoot(c),u=s.get(l)===1?l:c,f=this.targets[a];if(!f||f.device!==e.device||f.canvas!==c||f.eventRoot!==u){f?.eventManager.destroy(),f?.presentationContext.destroy();let d=e.device.createPresentationContext({id:a,canvas:c,useDevicePixels:e.useDevicePixels,autoResize:!0});f={id:a,device:e.device,canvas:c,eventRoot:u,presentationContext:d,eventManager:this._createEventManager(u)}}this._eventRootToCanvasId.set(u,a),this._eventRootToCanvasId.set(c,a),i[a]=f,r.push(a)}for(let[a,c]of Object.entries(this.targets))i[a]||(c.eventManager.destroy(),c.presentationContext.destroy());this.targets=i,this.order=r;let o=Object.fromEntries(Object.entries(i).map(([a,c])=>[a,c.eventManager]));this._haveSameEventManagers(o)||(this.eventManagers=o)}getCanvasIdFromEvent(e){return e?this._eventRootToCanvasId.get(e):void 0}getTarget(e){return this.targets[e||this.order[0]||er]||null}_normalizeCanvasList(e=[]){let t=new Set;return e.map((i,r)=>{let s,o;return typeof i=="string"?(s=document.getElementById(i),ge(s,`Canvas with id ${i} not found`),o=i):(s=i,o=s.id||`deckgl-canvas-${r}`),ge(!t.has(o),`Duplicate canvas id ${o}`),t.add(o),{id:o,canvas:s}})}_haveSameEventManagers(e){let t=Object.keys(e),i=Object.keys(this.eventManagers);return t.length===i.length&&t.every(r=>e[r]===this.eventManagers[r])}};J();bd();Me();Me();ua();function Ci(){}var zz=({isDragging:n})=>n?"grabbing":"grab",AP={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,pickAsync:"auto",layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{},gl:null,canvas:null,_canvases:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:Ci,onWebGLInitialized:Ci,onResize:Ci,onViewStateChange:Ci,onInteractionStateChange:Ci,onBeforeRender:Ci,onAfterRender:Ci,onLoad:Ci,onError:n=>ae.error(n.message,n.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:zz,getTooltip:null,debug:!1,drawPickingColors:!1},jc=class{constructor(e){this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.eventManagers={},this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this._canvasContext=null,this._deviceResizeHandler=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new Yt({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,layersCount:0,drawLayersCount:0,updateLayersCount:0,updateAttributesCount:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,pickLayersCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._hoverPickSequence=0,this._pointerDownPickSequence=0,this._needsRedraw="Initial render",this._canvasManager=new Ic({createEventManager:r=>this._createEventManager(r),getEventRoot:r=>this._getEventRoot(r)}),this._ownedCanvas=null,this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,canvasId:void 0,event:null,unproject3D:!1},this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this._onPointerMove=r=>{let{_pickRequest:s}=this,o=this._getCanvasIdFromEvent(r);if(r.type==="pointerleave")s.x=-1,s.y=-1,s.radius=0,s.canvasId=o;else{if(r.leftButton||r.rightButton)return;{let a=r.offsetCenter;if(!a)return;s.x=a.x,s.y=a.y,s.radius=this.props.pickingRadius,s.canvasId=o}}this.layerManager&&(this.layerManager.context.mousePosition={x:s.x,y:s.y}),s.event=r},this._onEvent=r=>{let s=ao[r.type],o=r.offsetCenter,a=this._getCanvasIdFromEvent(r);if(!s||!o||!this.layerManager)return;let c=this.layerManager.getLayers(),l=this._getInternalPickingMode();if(!l)return;if(l==="sync"){let f=r.type==="click"&&this._shouldUnproject3D(c)?this._getFirstPickedInfo(this._pickPointSync(this._getPointPickOptions(o.x,o.y,{unproject3D:!0,canvasId:a},c))):this._getLastPointerDownPickingInfo(o.x,o.y,a,c);this._dispatchPickingEvent(f,r);return}(this._lastPointerDownInfoPromise||Promise.resolve(this._getLastPointerDownPickingInfo(o.x,o.y,a,c))).then(f=>{this._dispatchPickingEvent(f,r)}).catch(f=>this.props.onError?.(f))},this._onPointerDown=r=>{let s=r.offsetCenter,o=this._getCanvasIdFromEvent(r);if(!s)return;let a=this._getInternalPickingMode();if(!a)return;let c=this.layerManager?.getLayers()||[],l=++this._pointerDownPickSequence;if(a==="sync"){let f=this._pickPointSync({x:s.x,y:s.y,canvasId:o,radius:this.props.pickingRadius}),d=this._getFirstPickedInfo(f);this._lastPointerDownInfo=d,this._lastPointerDownInfoPromise=Promise.resolve(d);return}let u=this._pickPointAsync(this._getPointPickOptions(s.x,s.y,{canvasId:o},c)).then(f=>this._getFirstPickedInfo(f)).then(f=>(l===this._pointerDownPickSequence&&(this._lastPointerDownInfo=f),f)).catch(f=>{this.props.onError?.(f);let d=this.deckPicker&&this.viewManager?this._getLastPointerDownPickingInfo(s.x,s.y,o,c):{};return l===this._pointerDownPickSequence&&(this._lastPointerDownInfo=d),d});this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=u};let t=e;this.props={...AP,...e},e=this.props,this._validateCanvasConfiguration(e),e.viewState&&e.initialViewState&&ae.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,e.device&&(this.device=e.device,this._setDeviceCanvasContext(e.device));let i=this.device;!i&&e.gl&&(e.gl instanceof WebGLRenderingContext&&ae.error("WebGL1 context not supported.")(),i=Wc.attach(e.gl,{_cacheShaders:!0,_cachePipelines:!0,...this.props.deviceProps})),i||(i=this._createDevice(e)),this.animationLoop=this._createAnimationLoop(i,e),this.setProps(t),e._typedArrayManagerProps&&gn.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){this._restoreDeviceResizeHandler(),this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._hoverPickSequence++,this._pointerDownPickSequence++,this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this.layerManager?.finalize(),this.layerManager=null,this.viewManager?.finalize(),this.viewManager=null,this.effectManager?.finalize(),this.effectManager=null,this.deckRenderer?.finalize(),this.deckRenderer=null,this.deckPicker?.finalize(),this.deckPicker=null,Object.keys(this._canvasManager.targets).length||this.eventManager?.destroy(),this.eventManager=null,this.eventManagers={},this.widgetManager?.finalize(),this.widgetManager=null,this._canvasManager.finalize(),this._isMultiCanvasMode()?this.canvas=null:this.canvas&&this.canvas===this._ownedCanvas&&(this.canvas.parentElement?.removeChild(this.canvas),this.canvas=null,this._ownedCanvas=null),this._canvasContext=null}setProps(e){this.stats.get("setProps Time").timeStart(),"onLayerHover"in e&&ae.removed("onLayerHover","onHover")(),"onLayerClick"in e&&ae.removed("onLayerClick","onClick")(),e.initialViewState&&!Ee(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),ge(!("_canvases"in e)||Array.isArray(e._canvases)===this._isMultiCanvasMode()),Object.assign(this.props,e),this._validateCanvasConfiguration(this.props),this._validateInternalPickingMode(),this.device&&this._isMultiCanvasMode()&&this._syncCanvasTargets(),this._setCanvasSize(this.props);let t=Object.create(this.props);if(Object.assign(t,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState(),eventManagers:this.eventManagers}),e.device&&e.device.id!==this.device?.id){let i=e.device.getDefaultCanvasContext();this.animationLoop?.stop(),!this._isMultiCanvasMode()&&this.canvas!==i.canvas&&(this.canvas?.remove(),this.eventManager?.destroy(),this.canvas=null),this._setDeviceCanvasContext(e.device),ae.log(`recreating animation loop for new device! id=${e.device.id}`)(),this.animationLoop=this._createAnimationLoop(e.device,e),this.animationLoop.start()}if(this.animationLoop?.setProps(t),e.useDevicePixels!==void 0&&this._canvasContext?.setProps){this._canvasContext.setProps({useDevicePixels:e.useDevicePixels});for(let i of Object.values(this._canvasManager.targets))i.presentationContext.setProps({useDevicePixels:e.useDevicePixels})}this.layerManager&&(this.viewManager.setProps(t),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(t),this.effectManager.setProps(t),this.deckRenderer.setProps(t),this.deckPicker.setProps(t),this.widgetManager.setProps(t)),this.stats.get("setProps Time").timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);let i=this.viewManager.needsRedraw(e),r=this.layerManager.needsRedraw(e),s=this.effectManager.needsRedraw(e),o=this.deckRenderer.needsRedraw(e);return t=t||i||r||s||o,t}redraw(e){if(!this.layerManager)return;let t=this.needsRedraw({clearRedrawFlags:!0});t=e||t,t&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(t):this._drawLayers(t))}get isInitialized(){return this.viewManager!==null}getViews(){return ge(this.viewManager),this.viewManager.views}getView(e){return ge(this.viewManager),this.viewManager.getView(e)}getViewports(e){return ge(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}getCanvasContext(e){let t=e?this.viewManager?.getView(e)?.props.canvasId:void 0;return this._getCanvasContext(t)}getEventManager(e){if(!e||!this.viewManager)return this.eventManager;let t=this.viewManager.getCanvasId(e)||er;return this.eventManagers[t]||this.eventManager}async pickObjectAsync(e){let t=(await this._pickAsync("pickObjectAsync","pickObject Time",e)).result;return t.length?t[0]:null}async pickObjectsAsync(e){return await this._pickAsync("pickObjectsAsync","pickObjects Time",e)}pickObject(e){let t=this._pick("pickObject","pickObject Time",e).result;return t.length?t[0]:null}pickMultipleObjects(e){return e.depth=e.depth||10,this._pick("pickObject","pickMultipleObjects Time",e).result}pickObjects(e){return this._pick("pickObjects","pickObjects Time",e)}_pickPositionForController(e,t,i){return this._getInternalPickingMode()!=="sync"?null:this.pickObject({x:e,y:t,radius:0,unproject3D:!0,canvasId:i?this.viewManager?.getCanvasId(i):void 0})}_addResources(e,t=!1){for(let i in e)this.layerManager.resourceManager.add({resourceId:i,data:e[i],forceUpdate:t})}_removeResources(e){for(let t of e)this.layerManager.resourceManager.remove(t)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_addDefaultShaderModule(e){this.layerManager.addDefaultShaderModule(e)}_removeDefaultShaderModule(e){this.layerManager?.removeDefaultShaderModule(e)}_resolveInternalPickingMode(){let{pickAsync:e}=this.props,t=this.device?.type||this.props.deviceProps?.type;if(e==="auto")return t==="webgpu"?"async":"sync";if(e==="sync"&&t==="webgpu")throw new Error('`pickAsync: "sync"` is not supported when Deck is using a WebGPU device.');return e}_getInternalPickingMode(){try{return this._resolveInternalPickingMode()}catch(e){return this.props.onError?.(e),null}}_validateInternalPickingMode(){this._getInternalPickingMode()}_getFirstPickedInfo({result:e,emptyInfo:t}){return e[0]||t}_shouldUnproject3D(e=this.layerManager?.getLayers()||[]){return e.some(t=>t.props.pickable==="3d")}_getPointPickOptions(e,t,i={},r=this.layerManager?.getLayers()||[]){return{x:e,y:t,canvasId:i.canvasId,radius:this.props.pickingRadius,unproject3D:this._shouldUnproject3D(r),...i}}_pickPointSync(e){return this._pick("pickObject","pickObject Time",e)}_pickPointAsync(e){return this._pickAsync("pickObjectAsync","pickObject Time",e)}_getLastPointerDownPickingInfo(e,t,i,r=this.layerManager?.getLayers()||[]){return this.deckPicker.getLastPickedObject({x:e,y:t,layers:r,viewports:this.getViewports({x:e,y:t,canvasId:i})},this._lastPointerDownInfo)}_applyHoverCallbacks({result:e,emptyInfo:t},i){if(!this.widgetManager)return;this.cursorState.isHovering=e.length>0;let r=t,s=!1;for(let o of e)r=o,s=o.layer?.onHover(o,i)||s;s||(this.props.onHover?.(r,i),this.widgetManager.onHover(r,i))}_dispatchPickingEvent(e,t){if(!this.layerManager||!this.widgetManager)return;let i=ao[t.type];if(!i)return;let{layer:r}=e,s=r&&(r[i]||r.props[i]),o=this.props[i],a=!1;s&&(a=s.call(r,e,t)),a||(o?.(e,t),this.widgetManager.onEvent(e,t))}_pickAsync(e,t,i){ge(this.deckPicker);let{stats:r}=this,s=this._isMultiCanvasMode()?i.canvasId||this._getDefaultCanvasId():i.canvasId,o=this._getCanvasContext(s)||void 0;r.get("Pick Count").incrementCount(),r.get(t).timeStart(),this._resizeForCanvasTarget(s);let a=this.deckPicker[e]({layers:this.layerManager.getLayers(i),views:this.viewManager.getViews(),viewports:this.getViewports({...i,canvasId:s}),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...i,canvasId:s,canvasContext:o});return r.get(t).timeEnd(),a}_pick(e,t,i){ge(this.deckPicker);let{stats:r}=this,s=this._isMultiCanvasMode()?i.canvasId||this._getDefaultCanvasId():i.canvasId,o=this._getCanvasContext(s)||void 0;r.get("Pick Count").incrementCount(),r.get(t).timeStart(),this._resizeForCanvasTarget(s);let a=this.deckPicker[e]({layers:this.layerManager.getLayers(i),views:this.viewManager.getViews(),viewports:this.getViewports({...i,canvasId:s}),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...i,canvasId:s,canvasContext:o});return r.get(t).timeEnd(),a}_createCanvas(e){let t=e.canvas;return typeof t=="string"&&(t=document.getElementById(t),ge(t)),t?this._ownedCanvas=null:(t=document.createElement("canvas"),t.id=e.id||"deckgl-overlay",e.width&&typeof e.width=="number"&&(t.width=e.width),e.height&&typeof e.height=="number"&&(t.height=e.height),(e.parent||document.body).appendChild(t),this._ownedCanvas=t),Object.assign(t.style,e.style),t}_isMultiCanvasMode(){return Array.isArray(this.props._canvases)}_getDefaultCanvasId(){return this._canvasManager.order[0]||er}_validateCanvasConfiguration(e){Array.isArray(e._canvases)&&(ge(!e.canvas),ge(!e.gl),ge(!e.device?.canvasContext||e.device.getDefaultCanvasContext().offscreenCanvas))}_createEventManager(e){let t=new sc(e,{touchAction:this.props.touchAction,recognizers:Object.keys(g_).map(i=>{let[r,s,o,a]=g_[i],c=this.props.eventRecognizerOptions?.[i],l={...s,...c,event:i};return{recognizer:new r(l),recognizeWith:o,requireFailure:a}}),events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(let i in ao)i==="dblclick"?t.watch(i,this._onEvent):t.on(i,this._onEvent);return t}_getEventRoot(e){return e.closest(".deck-events-root")||this.props.parent?.querySelector(".deck-events-root")||e}_syncCanvasTargets(){if(!this.device||!this._isMultiCanvasMode())return;this._canvasManager.syncCanvasEntries({device:this.device,canvases:this.props._canvases||[],useDevicePixels:this.props.useDevicePixels}),this.eventManagers=this._canvasManager.eventManagers;let e=this._getDefaultCanvasId();this.eventManager=this.eventManagers[e]||null,this.canvas=this._canvasManager.targets[e]?.canvas||null}_setCanvasContext(e){this._canvasContext=e,"style"in e.canvas&&(this.canvas=e.canvas)}_setDeviceCanvasContext(e,t={}){let i=e.getDefaultCanvasContext();this._setCanvasContext(i),this._setDeviceResizeHandler(e,t)}_setDeviceResizeHandler(e,t={}){let i=!!t.syncDrawingBuffer;if(this._deviceResizeHandler?.device===e){this._deviceResizeHandler.syncDrawingBuffer=i;return}this._restoreDeviceResizeHandler();let r=s=>{this._isMultiCanvasMode()?this._updateMultiCanvasDimensions():s===this._canvasContext&&this._canvasContext&&this._onCanvasContextResize(this._canvasContext,{syncDrawingBuffer:this._deviceResizeHandler?.syncDrawingBuffer})};e.props.onResize=r,this._deviceResizeHandler={device:e,onResize:r,syncDrawingBuffer:i}}_restoreDeviceResizeHandler(){let e=this._deviceResizeHandler;e&&e.device.props?.onResize===e.onResize&&(e.device.props.onResize=Ci),this._deviceResizeHandler=null}_setCanvasSize(e){if(this._isMultiCanvasMode()||!this.canvas)return;let{width:t,height:i}=e;if(t||t===0){let r=Number.isFinite(t)?`${t}px`:t;this.canvas.style.width=r}if(i||i===0){let r=Number.isFinite(i)?`${i}px`:i;this.canvas.style.position=e.style?.position||"absolute",this.canvas.style.height=r}}_getCanvasIdFromEvent(e){return this._canvasManager.getCanvasIdFromEvent(e?.rootElement)}_getCanvasContext(e){return this._canvasManager.getTarget(e)?.presentationContext||this._canvasContext}_resizeForCanvasTarget(e){let t=this._canvasManager.getTarget(e);if(!t||!this.device?.canvasContext)return;let[i,r]=t.presentationContext.getDrawingBufferSize();this.device.canvasContext.setDrawingBufferSize(i,r)}_createDeviceCanvas(e){if(this._isMultiCanvasMode()){let t=globalThis.OffscreenCanvas;if(!t)throw new Error("`_canvases` requires OffscreenCanvas support.");let i=typeof e.width=="number"&&Number.isFinite(e.width)?e.width:1,r=typeof e.height=="number"&&Number.isFinite(e.height)?e.height:1;return new t(i,r)}return this._createCanvas(e)}_updateCanvasSize(e=this._canvasContext){if(this._isMultiCanvasMode()){this._updateMultiCanvasDimensions();return}let{canvas:t}=this,[i,r]=e?e.getCSSSize():[t?.clientWidth??t?.width??0,t?.clientHeight??t?.height??0];(i!==this.width||r!==this.height)&&(this.width=i,this.height=r,this.viewManager?.setProps({width:i,height:r}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:i,height:r},e||void 0))}_onCanvasContextResize(e,t={}){if(t.syncDrawingBuffer){let{width:i,height:r}=e.canvas;e.setDrawingBufferSize(i,r)}this._needsRedraw="Canvas resized",this._updateCanvasSize(e)}_updateMultiCanvasDimensions(){let[e,t]=this._getCanvasContext()?.getCSSSize()||[0,0];(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.props.onResize({width:e,height:t})),this._needsRedraw="Canvas resized",this.viewManager?.setNeedsUpdate("Canvas resized"),this.viewManager?.setProps({width:this.width,height:this.height})}_createAnimationLoop(e,t){let{gl:i,onError:r}=t;return new gc({device:e,autoResizeDrawingBuffer:!i&&!Array.isArray(t._canvases),autoResizeViewport:!1,onInitialize:s=>this._setDevice(s.device),onRender:this._onRenderFrame.bind(this),onError:r})}_createDevice(e){let t=this.props.deviceProps?.createCanvasContext,i=typeof t=="object"?t:void 0,r={adapters:[],_cacheShaders:!0,_cachePipelines:!0,...e.deviceProps};r.adapters.includes(Wc)||r.adapters.push(Wc);let s={alphaMode:this.props.deviceProps?.type==="webgpu"?"premultiplied":void 0};return Vs.createDevice({_reuseDevices:!0,type:"webgl",...r,createCanvasContext:{...s,...i,canvas:this._createDeviceCanvas(e),useDevicePixels:this.props.useDevicePixels,autoResize:!0}})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let{views:e}=this.props,t=Array.isArray(e)?e:e?[e]:[new n2({id:"default-view"})];return t.length&&this.props.controller&&(t[0]=t[0].clone({controller:this.props.controller})),t}_onContextLost(){let{onError:e}=this.props;this.animationLoop&&e&&e(new Error("WebGL context is lost"))}_pickAndCallback(){let{_pickRequest:e}=this;if(e.event){let t=e.event,i=this.layerManager?.getLayers()||[],r=this._getPointPickOptions(e.x,e.y,{canvasId:e.canvasId,radius:e.radius,mode:e.mode},i),s=this._getInternalPickingMode(),o=++this._hoverPickSequence;if(e.event=null,e.canvasId=void 0,!s)return;if(s==="sync"){this._applyHoverCallbacks(this._pickPointSync(r),t);return}this._pickPointAsync(r).then(({result:a,emptyInfo:c})=>{o===this._hoverPickSequence&&this._applyHoverCallbacks({result:a,emptyInfo:c},t)}).catch(a=>this.props.onError?.(a))}}_updateCursor(){let e=this.props.getCursor(this.cursorState);if(this._isMultiCanvasMode()){for(let i of Object.values(this._canvasManager.targets))i.canvas.style.cursor=e;return}let t=this.props.parent||this.canvas;t&&(t.style.cursor=e)}_setDevice(e){if(this.device=e,this._validateInternalPickingMode(),!this.animationLoop)return;this._setDeviceCanvasContext(e,{syncDrawingBuffer:!!(this.props.gl&&this.props.device!==e)}),this._isMultiCanvasMode()?this._syncCanvasTargets():this.canvas&&!this.canvas.isConnected&&this.props.parent&&this.props.parent.insertBefore(this.canvas,this.props.parent.firstChild),this.device.type==="webgl"&&this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),this.device.type==="webgl"&&this.props.onWebGLInitialized(this.device.gl);let t=new Qr;if(t.play(),this.animationLoop.attachTimeline(t),!this._isMultiCanvasMode()){let s=this.canvas&&this._getEventRoot(this.canvas);ge(s),this.eventManager=this._createEventManager(s),this.eventManagers={[er]:this.eventManager}}this.viewManager=new Ec({timeline:t,eventManager:this.eventManager,eventManagers:this.eventManagers,getCanvasContext:this._isMultiCanvasMode()?this.getCanvasContext.bind(this):void 0,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),pickPosition:this._pickPositionForController.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});let i=this.viewManager.getViewports()[0];this.layerManager=new wc(this.device,{deck:this,stats:this.stats,viewport:i,timeline:t}),this.effectManager=new Lc({deck:this,device:this.device}),this.deckRenderer=new Ac(this.device,{stats:this.stats}),this.deckPicker=new kc(this.device,{stats:this.stats});let r=this.props.parent?.querySelector(".deck-widgets-root")||(this._isMultiCanvasMode()?this.props.parent||this.canvas?.parentElement:null)||this.canvas?.parentElement;this.widgetManager=new $f({deck:this,parentElement:r}),this.widgetManager.addDefault(new Rc),this.setProps({}),this._updateCanvasSize(this._canvasContext),this.props.onLoad()}_drawLayers(e,t){let{device:i,gl:r}=this.layerManager.context;this.props.onBeforeRender({device:i,gl:r});let s={target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:"screen",effects:this.effectManager.getEffects(),...t};if(this._isMultiCanvasMode()&&s.pass==="screen"&&!s.target&&this._canvasManager.order.length)for(let o of this._canvasManager.order){let a=s.viewports.filter(u=>this.viewManager.getCanvasId(u.id)===o);if(!a.length){let u=this._canvasManager.targets[o];this._resizeForCanvasTarget(o),this.deckRenderer?.renderLayers({...s,canvasContext:u.presentationContext,target:u.presentationContext.getCurrentFramebuffer(),viewports:[],clearCanvas:!0}),u.presentationContext.present();continue}let c=this._canvasManager.targets[o];this._resizeForCanvasTarget(o);let l=c.presentationContext.getCurrentFramebuffer();this.deckRenderer?.renderLayers({...s,canvasContext:c.presentationContext,target:l,viewports:a}),c.presentationContext.present()}else this.deckRenderer?.renderLayers(s);s.pass==="screen"&&this.widgetManager.onRedraw({viewports:s.viewports,layers:s.layers}),this.props.onAfterRender({device:i,gl:r})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60===0&&(this._getMetrics(),this.stats.reset(),ae.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCursor(),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){let t=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:t},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(e){this.cursorState.isDragging=e.isDragging||!1,this.props.onInteractionStateChange(e)}_getFrameStats(){let{stats:e}=this;e.get("frameRate").timeEnd(),e.get("frameRate").timeStart();let t=this.animationLoop.stats;e.get("GPU Time").addTime(t.get("GPU Time").lastTiming),e.get("CPU Time").addTime(t.get("CPU Time").lastTiming)}_getMetrics(){let{metrics:e,stats:t}=this;e.fps=t.get("frameRate").getHz(),e.setPropsTime=t.get("setProps Time").time,e.updateAttributesTime=t.get("Update Attributes").time,e.framesRedrawn=t.get("Redraw Count").count,e.pickTime=t.get("pickObject Time").time+t.get("pickMultipleObjects Time").time+t.get("pickObjects Time").time,e.pickCount=t.get("Pick Count").count,e.layersCount=this.layerManager?.layers.length??0,e.drawLayersCount=t.get("Layers rendered").lastSampleCount,e.pickLayersCount=t.get("Layers picked").lastSampleCount,e.updateLayersCount=t.get("Layer updates").count,e.updateAttributesCount=t.get("Attributes updated").count,e.gpuTime=t.get("GPU Time").time,e.cpuTime=t.get("CPU Time").time,e.gpuTimePerFrame=t.get("GPU Time").getAverageTime(),e.cpuTimePerFrame=t.get("CPU Time").getAverageTime();let i=Vs.stats.get("GPU Time and Memory");e.bufferMemory=i.get("Buffer Memory").count,e.textureMemory=i.get("Texture Memory").count,e.renderbufferMemory=i.get("Renderbuffer Memory").count,e.gpuMemory=i.get("GPU Memory").count}};jc.defaultProps=AP;jc.VERSION=Nx;var xy=jc;J();J();function kP(n){switch(n){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return Lr(n)}}var RP=Xe.getDataType.bind(Xe);function Hc(n,e,t){if(e.size>4)return null;let i=t==="webgpu"&&e.type==="uint8"?"unorm8":e.type,r=e.size,s=!!(t!=="webgpu"&&r===3&&i&&["uint8","sint8","unorm8","snorm8","uint16","sint16","unorm16","snorm16"].includes(i));return{attribute:n,format:r>1?`${i}x${r}${s?"-webgl":""}`:e.type,byteOffset:e.offset||0}}function rn(n){return n.stride||n.size*n.bytesPerElement}function IP(n,e){return n.type===e.type&&n.size===e.size&&rn(n)===rn(e)&&(n.offset||0)===(e.offset||0)}function wy(n,e){e.offset&&ae.removed("shaderAttribute.offset","vertexOffset, elementOffset")();let t=rn(n),i=e.vertexOffset!==void 0?e.vertexOffset:n.vertexOffset||0,r=e.elementOffset||0,s=i*t+r*n.bytesPerElement+(n.offset||0);return{...e,offset:s,stride:t}}function Uz(n,e){let t=wy(n,e);return{high:t,low:{...t,offset:t.offset+n.size*4}}}var Yc=class{constructor(e,t,i){this._buffer=null,this.device=e,this.id=t.id||"",this.size=t.size||1;let r=t.logicalType||t.type,s=r==="float64",{defaultValue:o}=t;o=Number.isFinite(o)?[o]:o||new Array(this.size).fill(0);let a;s?a="float32":!r&&t.isIndexed?a="uint32":a=r||"float32";let c=kP(r||a);this.doublePrecision=s,s&&t.fp64===!1&&(c=Float32Array),this.value=null,this.settings={...t,defaultType:c,defaultValue:o,logicalType:r,type:a,normalized:a.includes("norm"),size:this.size,bytesPerElement:c.BYTES_PER_ELEMENT},this.state={...i,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){let e=this.getAccessor();return e.vertexOffset?e.vertexOffset*rn(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}get isDoublePrecisionBuffer(){return this._shouldSplitDoublePrecisionValue(this.value)}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),gn.release(this.state.allocatedValue),this.state.allocatedValue=null}getBuffer(){return this.state.constant&&this.device.type!=="webgpu"?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,t=null){let i={};if(this.state.constant){let r=this.value;if(this.device.type==="webgpu"&&this._buffer)i[e]=this._buffer;else if(t){let s=wy(this.getAccessor(),t),o=s.offset/r.BYTES_PER_ELEMENT,a=s.size||this.size;i[e]=r.subarray(o,o+a)}else i[e]=r}else i[e]=this.getBuffer();return this.doublePrecision&&(this.isDoublePrecisionBuffer?i[`${e}64Low`]=i[e]:i[`${e}64Low`]=new Float32Array(this.size)),i}_getBufferLayout(e=this.id,t=null){let i=this.getAccessor(),r=[],s={name:this.id,byteStride:this.device.type==="webgpu"&&this.state.constant?0:rn(i)};if(this.doublePrecision){let o=Uz(i,t||{});r.push(Hc(e,{...i,...o.high},this.device.type),Hc(`${e}64Low`,{...i,...o.low},this.device.type))}else if(t){let o=wy(i,t);r.push(Hc(e,{...i,...o},this.device.type))}else r.push(Hc(e,i,this.device.type));return s.attributes=r.filter(Boolean),s}setAccessor(e){this.state.bufferAccessor=e}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let e=null;if(this.state.constant&&this.value){let t=Array.from(this.value);e=[t,t]}else{let{value:t,numInstances:i,size:r}=this,s=i*r;if(t&&s&&t.length>=s){let o=new Array(r).fill(1/0),a=new Array(r).fill(-1/0);for(let c=0;ca[l]&&(a[l]=u)}e=[o,a]}}return this.state.bounds=e,e}setData(e){let{state:t}=this,i;ArrayBuffer.isView(e)?i={value:e}:e instanceof ie?i={buffer:e}:i=e;let r={...this.settings,...i};if(ArrayBuffer.isView(i.value)){if(!i.type)if(this.doublePrecision&&i.value instanceof Float64Array)r.type="float32";else{let o=RP(i.value);r.type=r.normalized?o.replace("int","norm"):o}r.bytesPerElement=i.value.BYTES_PER_ELEMENT,r.stride=rn(r)}if(t.bounds=null,i.constant){let s=i.value;if(s=this._normalizeValue(s,[],0),this.settings.normalized&&(s=this.normalizeConstant(s)),!(!t.constant||!this._areValuesEqual(s,this.value)))return!1;t.externalBuffer=null,t.constant=!0,this.value=ArrayBuffer.isView(s)?s:new Float32Array(s)}else if(i.buffer){let s=i.buffer;t.externalBuffer=s,t.constant=!1,this.value=i.value||null}else if(i.value){this._checkExternalBuffer(i);let s=i.value,o=s;t.externalBuffer=null,t.constant=!1,this.value=s,this._shouldSplitDoublePrecisionValue(o)&&(o=mo(o,r),s instanceof Float32Array&&(r.stride=r.size*2*Float32Array.BYTES_PER_ELEMENT));let{buffer:a}=this,c=rn(r),l=(r.vertexOffset||0)*c;if(this.settings.isIndexed){let f=this.settings.defaultType;o.constructor!==f&&(o=new f(o))}let u=o.byteLength+l+c*2;(!a||a.byteLength(t+128)/255*2-1);case"snorm16":return new Float32Array(e).map(t=>(t+32768)/65535*2-1);case"unorm8":return new Float32Array(e).map(t=>t/255);case"unorm16":return new Float32Array(e).map(t=>t/65535);default:return e}}_normalizeValue(e,t,i){let{defaultValue:r,size:s}=this.settings;if(Number.isFinite(e))return t[i]=e,t;if(!e){let o=s;for(;--o>=0;)t[i+o]=r[o];return t}switch(s){case 4:t[i+3]=Number.isFinite(e[3])?e[3]:r[3];case 3:t[i+2]=Number.isFinite(e[2])?e[2]:r[2];case 2:t[i+1]=Number.isFinite(e[1])?e[1]:r[1];case 1:t[i+0]=Number.isFinite(e[0])?e[0]:r[0];break;default:let o=s;for(;--o>=0;)t[i+o]=Number.isFinite(e[o])?e[o]:r[o]}return t}_areValuesEqual(e,t){if(!e||!t)return!1;let{size:i}=this;for(let r=0;r0&&(OP.length=n.length,i=OP):i=BP,(e>0||Number.isFinite(t))&&(i=(Array.isArray(i)?i:Array.from(i)).slice(e,t),r.index=e-1),{iterable:i,objectInfo:r}}function Sd(n){return n&&n[Symbol.asyncIterator]}function Pd(n,e){let{size:t,stride:i,offset:r,startIndices:s,nested:o}=e,a=n.BYTES_PER_ELEMENT,c=i?i/a:t,l=r?r/a:0,u=Math.floor((n.length-l)/c);return(f,{index:d,target:h})=>{if(!s){let v=d*c+l;for(let y=0;y=e[1]))return n;let t=[],i=n.length,r=0;for(let s=0;se[1]?t.push(o):e=[Math.min(o[0],e[0]),Math.max(o[1],e[1])]}return t.splice(r,0,e),t}var Gz={interpolation:{duration:0,easing:n=>n},spring:{stiffness:.05,damping:.5}};function Cd(n,e){if(!n)return null;Number.isFinite(n)&&(n={type:"interpolation",duration:n});let t=n.type||"interpolation";return{...Gz[t],...e,...n,type:t}}var as=class extends Yc{constructor(e,t){super(e,t,{startIndices:null,constantValue:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:qc}),this.constant=!1,this.settings.update=t.update||(t.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(e){this.state.startIndices=e}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:e=!1}={}){let t=this.state.needsRedraw;return this.state.needsRedraw=t&&!e,t}layoutChanged(){return this.state.layoutChanged}setAccessor(e){var t;(t=this.state).layoutChanged||(t.layoutChanged=!IP(e,this.getAccessor())),super.setAccessor(e)}getUpdateTriggers(){let{accessor:e}=this.settings;return[this.id].concat(typeof e!="function"&&e||[])}supportsTransition(){return!!this.settings.transition}getTransitionSetting(e){if(!e||!this.supportsTransition())return null;let{accessor:t}=this.settings,i=this.settings.transition,r=Array.isArray(t)?e[t.find(s=>e[s])]:e[t];return Cd(r,i)}setNeedsUpdate(e=this.id,t){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),t){let{startRow:i=0,endRow:r=1/0}=t;this.state.updateRanges=NP(this.state.updateRanges,[i,r])}else this.state.updateRanges=qc}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=DP}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){let{state:t,settings:i}=this;if(i.noAlloc)return!1;if(i.update){let r=this.isConstant;return super.allocate(e,t.updateRanges!==qc),t.layoutChanged||(t.layoutChanged=r&&this.device.type==="webgpu"),!0}return!1}updateBuffer({numInstances:e,data:t,props:i,context:r}){if(!this.needsUpdate())return!1;let{state:{updateRanges:s},settings:{update:o,noAlloc:a}}=this,c=!0;if(o){for(let[l,u]of s)o.call(r,this,{data:t,startRow:l,endRow:u,props:i,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLengthu?l.set(b,m):(e._normalizeValue(b,v.target,0),Y1({target:l,source:v.target,start:m,count:x}));m+=x*u}else e._normalizeValue(b,l,m),m+=u}}_validateAttributeUpdaters(){let{settings:e}=this;if(!(e.noAlloc||typeof e.update=="function"))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){let{value:e}=this,t=Math.min(4,this.size);if(e&&e.length>=t){let i=!0;switch(t){case 4:i=i&&Number.isFinite(e[3]);case 3:i=i&&Number.isFinite(e[2]);case 2:i=i&&Number.isFinite(e[1]);case 1:i=i&&Number.isFinite(e[0]);break;default:i=!1}if(!i)throw new Error(`Illegal attribute generated for ${this.id}`)}}};Mi();Ly();Mi();var Xc=class n{gpuDataEvaluators;format;length;id;_gpuVector;_ownsGPUDataEvaluators;_destroyed=!1;static fromGPUVector(e){if(e.bufferLayout)throw new Error(`GPUVectorEvaluator.fromGPUVector() does not accept interleaved vector "${e.name}"`);if(e.data.length===0)throw new Error(`GPUVectorEvaluator.fromGPUVector() requires GPUData for "${e.name}"`);return new n({id:e.name,gpuDataEvaluators:e.data.map(t=>ve.fromGPUData(t,{id:e.name})),gpuVector:e,format:e.format})}static fromGPUDataEvaluators(e,t={}){return new n({id:t.id,gpuDataEvaluators:e,format:t.format})}constructor({id:e,gpuDataEvaluators:t,gpuVector:i,format:r}){if(t.length===0)throw new Error("GPUVectorEvaluator requires at least one GPUData evaluator");tU(t),this.id=e,this.gpuDataEvaluators=t,this.format=r??t[0].format,this.length=t.reduce((s,o)=>s+o.length,0),this._gpuVector=i,this._ownsGPUDataEvaluators=!i}get evaluated(){return!!this._gpuVector}get gpuVector(){if(!this._gpuVector)throw new Error(`${this} not evaluated`);return this._gpuVector}mapGPUData(e){return n.fromGPUDataEvaluators(this.gpuDataEvaluators.map((t,i)=>e(t,i)),{id:this.id})}async evaluate(e,t={}){if(this._destroyed)throw new Error(`GPUVectorEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let i=await Promise.all(this.gpuDataEvaluators.map(a=>a.evaluate(e,t))),r=i[0],s=i.map(ZP),o=t.format??this.format??r.format;return this._gpuVector=new ri({type:"data",name:t.name??this.id??"vector",format:o,data:s,stride:r.stride,byteStride:r.byteStride,rowByteLength:r.rowByteLength,bufferLayout:r.bufferLayout}),this._gpuVector}evaluateSync(e,t={}){if(this._destroyed)throw new Error(`GPUVectorEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let i=this.gpuDataEvaluators.map(a=>a.evaluateSync(e,t)),r=i[0],s=i.map(ZP),o=t.format??this.format??r.format;return this._gpuVector=new ri({type:"data",name:t.name??this.id??"vector",format:o,data:s,stride:r.stride,byteStride:r.byteStride,rowByteLength:r.rowByteLength,bufferLayout:r.bufferLayout}),this._gpuVector}destroy(){if(this._ownsGPUDataEvaluators)for(let e of this.gpuDataEvaluators)e.destroy();this._gpuVector=void 0,this._destroyed=!0}toString(){return this.id??this.constructor.name}};function tU(n){let e=n[0];for(let t of n.slice(1))if(t.type!==e.type||t.size!==e.size||t.normalized!==e.normalized||t.format!==e.format)throw new Error("GPUVectorEvaluator requires matching GPUData evaluator layouts")}function ZP(n){let[e,...t]=n.data;if(!e||t.length>0)throw new Error(`GPUVectorEvaluator requires one GPUData chunk for "${n.name}"`);return e}Mi();J();var Ry={};mi(Ry,{arithmetic:()=>XP,dot:()=>nC,equalAll:()=>iC,extent:()=>QP,fround:()=>JP,gather:()=>eC,interleave:()=>tC,length:()=>rC,segmentedMap:()=>sC,select:()=>oC,sequence:()=>aC,swizzle:()=>cC});Bd();function ko({elementWise:n,func:e,inputs:t,output:i,outputBuffer:r}){let s=Array.isArray(t)?t:Object.values(t);for(let p of s)if(!p.value)throw new Error(`${p} does not have CPU value`);let o=i.length,a=i.size,c=new i.ValueType(o*a);for(let p=0;pDe(g,p));if(n)for(let g=0;gv[g]));else e.call(null,c.subarray(p*a,p*a+a),...m)}let l=i.ValueType.BYTES_PER_ELEMENT,u=i.offset/l,f=i.stride/l,d=a,h=c;if(u!==0||f!==d){h=new i.ValueType(u+i.byteLength/l);for(let p=0;p{for(let r of Object.values(n.namedInputs))if(!r.value)throw new Error(`${r} does not have CPU value`);let i=new e.ValueType(e.length*e.size);for(let r=0;r[o,De(a,r)]));for(let o=0;oKP(r,e,t));switch(n.op){case"add":return i[0]+i[1];case"subtract":return i[0]-i[1];case"multiply":return i[0]*i[1];case"divide":return i[0]/i[1];case"pow":return Math.pow(i[0],i[1]);case"sqrt":return Math.sqrt(i[0]);case"abs":return Math.abs(i[0]);case"sin":return Math.sin(i[0]);case"cos":return Math.cos(i[0]);case"tan":return Math.tan(i[0]);case"exp":return Math.exp(i[0]);case"log":return Math.log(i[0]);default:{let r=n.op;throw new Error(`Unsupported arithmetic op ${r}`)}}}default:{let i=n;throw new Error(`Unsupported expression node ${i.kind}`)}}}function iU(n,e){let t=Ao[n].arity;if(e!==t)throw new Error(`Arithmetic op '${n}' expects ${t} args, got ${e}`)}var QP=({inputs:n,output:e,target:t})=>{let{sourceValues:i}=n;if(!i.value)throw new Error(`${i} does not have CPU value`);let s=new e.ValueType(e.length*e.size);if(i.length===0)return{success:!1,error:new Error(`${i} is empty`)};for(let o=0;os[l]&&(s[l]=f)}}return t.write(s),{success:!0,value:s}};var JP=({inputs:n,output:e,target:t})=>ko({func:(i,r)=>{let s=i.length/2,o=new Float64Array(r.buffer);for(let a=0;a{let{ids:i,sourceValues:r}=n,s=i.value,o=r.value;if(!s)throw new Error(`${i} does not have CPU value`);if(!o)throw new Error(`${r} does not have CPU value`);let a=new e.ValueType(e.length*e.size),c=new Array(e.size).fill(0);for(let l=0;l=0&&nko({func:(i,...r)=>{let s=0;for(let o of r)i.set(o,s),s+=o.length},inputs:n,output:e,outputBuffer:t});var nC=({inputs:n,output:e,target:t})=>{let{x:i,y:r}=n,s=new e.ValueType(e.length);for(let o=0;o{let{x:i,y:r}=n,s=new e.ValueType(e.length);for(let o=0;o{let{x:i}=n,r=new e.ValueType(e.length);for(let s=0;s{let{segments:i,vertexCount:r}=n,s=i.value;if(!s)throw new Error(`${i} does not have CPU value`);sU(s,i,r);let o=new e.ValueType(e.length*e.size),a=0;for(let c=0;c0&&st)throw new Error(`segmentedMap last segment start must be <= vertexCount, got ${i} > ${t}`)}function Ay(n,e){return n.offset/n.ValueType.BYTES_PER_ELEMENT+e*(n.stride/n.ValueType.BYTES_PER_ELEMENT)}var oC=async({inputs:n,output:e,target:t})=>{let{condition:i,whenTrue:r,whenFalse:s}=n,o=new e.ValueType(e.length*e.size);for(let a=0;a{let i=new e.ValueType(e.length);for(let r=0;r{let{columns:i}=n;return ko({func:(r,s)=>{for(let o=0;o({...o,...a}));return this._modules[e]=s,s.then(o=>{this._modules[e]=o}).catch(o=>{N.error(`Failed to register ${e} backend: ${o}`)()}),s}if(i&&typeof i.then=="function"){let s=Promise.resolve(i).then(o=>({...o,...t})).then(o=>(this._modules[e]=o,o)).catch(o=>{throw N.error(`Failed to register ${e} backend: ${o}`)(),o});return this._modules[e]=s,s}let r={...i||{},...t};return this._modules[e]=r,Promise.resolve(r)}async get(e,t){let i=this._modules[e];if(!i)if(e==="webgl")i=this.add("webgl",Promise.resolve().then(()=>(FC(),NC)));else if(e==="webgpu")i=this.add("webgpu",Promise.resolve().then(()=>(Wy(),uT)));else throw new Error(`${e} backend not registered`);let s=(await i)[t];if(typeof s!="function")throw new Error(`${e} backend does not implement ${t}`);return s}getSync(e,t){let i=this._modules[e];if(!i)throw new Error(`${e} backend not registered`);if(typeof i.then=="function")throw new Error(`${e} backend is not loaded yet`);let s=i[t];if(typeof s!="function")throw new Error(`${e} backend does not implement ${t}`);return s}clear(){this._modules={}}},No=new jy;var Vd=class{inputs;dependencies;constructor(e){this.inputs=e,this.dependencies=Array.from(e instanceof Array?e:Object.values(e)).filter(t=>t instanceof ve)}async execute(e,t){return await this._resolveDependencies(e),await this._executeWithHandler(await No.get(this._getHandlerRegistry(e),this.name),t)}executeSync(e,t){this._resolveDependenciesSync(e);let i=this._executeWithHandler(No.getSync(this._getHandlerRegistry(e),this.name),t);if(XU(i))throw new Error(`${this.name} returned a Promise in executeSync()`);return i}shouldExecuteOnCPU(){return this.output.length<=1&&Array.from(this.dependencies).every(e=>!!e.value)}_getHandlerRegistry(e){return this.shouldExecuteOnCPU()?"cpu":e.type}async _resolveDependencies(e){for(let i of this.dependencies)await i.evaluate(e);if(this._getHandlerRegistry(e)==="cpu"||e.type==="null")for(let i of this.dependencies)await i.ensureCPUValue()}_resolveDependenciesSync(e){for(let i of this.dependencies)i.evaluateSync(e);if(this._getHandlerRegistry(e)==="cpu"||e.type==="null")for(let i of this.dependencies)i.ensureCPUValueSync()}_executeWithHandler(e,t){return e({device:t.device,inputs:this.inputs,output:this.output,target:t})}};function XU(n){return typeof n?.then=="function"}function fT(...n){let e=KU(n.map(t=>t.type));return e[0]!=="f"&&n.some(t=>t.normalized)&&(e="float32"),{isConstant:n.every(t=>t.isConstant),type:e,size:n.reduce((t,i)=>Math.max(t,i.size),0),length:n.reduce((t,i)=>Math.max(t,i.length),0)}}function KU(n){let e=0,t=0;for(let i of n){if(i[0]==="f")return"float32";let r=i.endsWith("8")?8:i.endsWith("6")?16:32;i[0]==="u"?e=Math.max(e,r):t=Math.max(t,r)}return e&&!t?`uint${e}`:t&&e<32?`sint${Math.max(t,e*2)}`:"float32"}Mi();var Hy=class extends Vd{name="interleave";output;constructor(e){super(e);let{isConstant:t,type:i,length:r}=fT(...e);this.output=new ve({isConstant:t,type:i,size:e.reduce((s,o)=>s+o.size,0),length:r,source:this})}toString(){return`_${this.inputs.join("_")}_`}};function Yy(...n){if(n.length===0)throw new Error("interleave() requires at least one input");return n.length===1?Id(n[0]):new Hy(n.map(Id)).output}Me();Mi();function Zy(n,e){let t=JU(e);for(let i of t)i.evaluateSync(n);return QU(t),e}function QU(n){let e=new Set(n.flatMap(t$)),t=new Set;for(let i of n)Wd(i,t);for(let i of t)i.evaluated&&!e.has(i.buffer)&&i.destroy()}function JU(n){let e=new Set;return qy(n,e,new Set),Array.from(e)}function qy(n,e,t){if(n$(n)){e.add(n);return}if(!(!n||typeof n!="object"||t.has(n))){if(t.add(n),Array.isArray(n)){for(let i of n)qy(i,e,t);return}if(e$(n))for(let i of Object.values(n))qy(i,e,t)}}function e$(n){let e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function Wd(n,e){if(n instanceof Xc){for(let i of n.gpuDataEvaluators)Wd(i,e);return}let t=n.source;if(t){if(t instanceof ve){e.has(t)||(e.add(t),Wd(t,e));return}for(let i of t.dependencies)e.has(i)||(e.add(i),Wd(i,e))}}function t$(n){return n instanceof ve?[n.buffer]:n.gpuVector.data.map(e=>e.buffer instanceof tt?e.buffer.buffer:e.buffer)}function n$(n){return n instanceof ve||n instanceof Xc}Wy();var Qc=class{constructor(e,{id:t,isTransitionAttribute:i}){this.packedBuffers={},this.device=e,this.id=t,this.isTransitionAttribute=i,this.device.type==="webgpu"&&No.add("webgpu",{interleave:Gd})}hasGroups(e){return this.device.type==="webgpu"&&Object.values(e).some(t=>!!t.settings.bufferGroup)}finalize(){for(let e of Object.values(this.packedBuffers))e.packed.destroy();this.packedBuffers={}}getBufferLayouts(e,t){let i=this._getPackedGroups(e,t,{requireValues:!1,excludeAttributes:{}});return this._getBufferLayouts(e,i,t)}getBindings(e,t,i,r){let s=this._getPackedGroups(e,i,{requireValues:!0,excludeAttributes:r}),o={},a=new Set;for(let c of s.values()){let l=!this.packedBuffers[c.id]||c.attributes.some(u=>!!t[u.id]);o[c.id]=this._getPackedBuffer(c,l);for(let u of c.attributes)a.add(u.id)}return{bufferLayouts:this._getBufferLayouts(e,s,i).filter(c=>!r[c.name]&&!e[c.name]?.settings.isIndexed),buffers:o,groupedAttributeIds:a}}_getPackedGroups(e,t,{requireValues:i,excludeAttributes:r}){let s=new Map;for(let a of Object.values(e)){let c=a.settings.bufferGroup;if(!c)continue;let l=s.get(c)||[];l.push(a),s.set(c,l)}let o=new Map;for(let[a,c]of s){let l=this._getPackedGroup(a,c,t,i,r);l&&o.set(a,l)}return o}_getPackedGroup(e,t,i,r,s){if(t.length<2)return null;let o=t.map(h=>h.getBufferLayout(i)),a=o[0].stepMode,c=Math.max(1,t[0].numInstances),l=r&&t.every(h=>h.isConstant);for(let h=0;hthis._getInterleaveInput(e,r)),i=Yy(...t);return Zy(this.device,i),i}_getInterleaveInput(e,t){let i=rn(t.getAccessor()),r=e.byteOffsets[t.id];if(Kc(`${e.id}.${t.id} rowByteLength`,i),Kc(`${e.id}.${t.id} groupByteOffset`,r),t.isConstant){let c=t.getConstantValue();if(!c)throw new Error(`Attribute group ${e.id} is missing constant value ${t.id}`);return Kc(`${e.id}.${t.id} constant byteOffset`,c.byteOffset),new ve({id:t.id,type:"uint32",size:i/4,isConstant:!0,value:new Uint32Array(c.buffer,c.byteOffset,i/Uint32Array.BYTES_PER_ELEMENT)})}let s=t.getBuffer(),o=t.byteOffset,a=t.getAccessor().stride||i;if(Kc(`${e.id}.${t.id} byteOffset`,o),Kc(`${e.id}.${t.id} stride`,a),!s)throw new Error(`Attribute group ${e.id} cannot interleave missing buffer ${t.id}`);return new ve({id:t.id,type:"uint32",size:i/4,offset:o,stride:a,length:e.rowCount,buffer:s})}};function dT(n){return Math.ceil(n/4)*4}function Kc(n,e){if(e%4!==0)throw new Error(`Attribute buffer groups require 32-bit alignment: ${n}=${e}`)}Me();vt();function Xy(n){let{source:e,target:t,start:i=0,size:r,getData:s}=n,o=n.end||t.length,a=e.length,c=o-i;if(a>c){t.set(e.subarray(0,c),i);return}if(t.set(e,i),!s)return;let l=a;for(;li(u+a,f)),l=Math.min(r.length,s.length);for(let u=1;ua}){let a=t.isDoublePrecisionBuffer?2:1,c=t.size*a,l=t.byteOffset,u=t.settings.bytesPerElement<4?l/t.settings.bytesPerElement*4:l,f=t.startIndices,d=s&&f,h=t.isConstant;if(!d&&e&&i>=r)return e;let p=t.value instanceof Float64Array?Float32Array:t.value.constructor,m=h?t.value:new p(t.getBuffer().readSyncWebGL(l,r*p.BYTES_PER_ELEMENT).buffer);if(t.settings.normalized&&!h){let b=o;o=(x,E)=>t.normalizeConstant(b(x,E))}let g=h?(b,x)=>o(m,x):(b,x)=>o(m.subarray(b+l,b+l+c),x),v=e?new Float32Array(e.readSyncWebGL(u,i*4).buffer):new Float32Array(0),y=new Float32Array(r);return hT({source:v,target:y,sourceStartIndices:s,targetStartIndices:f,size:c,getData:g}),(!e||e.byteLength[F]):[T];for(let F of R){let O=this.device.beginRenderPass({framebuffer:i,parameters:f,clearColor:a,clearDepth:c,clearStencil:l});try{for(let j of F){let V=this._drawLayersInViewport(O,{target:i,canvasContext:t,shaderModuleProps:d,viewport:j,view:w,pass:v,layers:e.layers,isPicking:e.isPicking},E);b.push(V)}}finally{O.end(),y&&this.device.submit()}a=!1,c=!1,l=!1}}return b}finally{y||this.device.submit()}}_getDrawLayerParams(e,{layers:t,pass:i,isPicking:r=!1,layerFilter:s,cullRect:o,views:a,effects:c,canvasContext:l=this.device.canvasContext,shaderModuleProps:u},f=!1){let d=[],h=r1(this._lastRenderIndex+1),p={layer:t[0],viewport:e,isPicking:r,renderPass:i,cullRect:o},m={};for(let g=0;gE/255):p===!1&&(v=!1),m!==void 0&&(y=m),g!==void 0&&(b=g),this.device.beginRenderPass({framebuffer:s,parameters:{viewport:f,scissorRect:f},clearColor:v,clearDepth:y,clearStencil:b}).end()}}let d={totalCount:t.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:f});for(let h=0;h{let o=r.props._offset,a=r.id,c=r.parent&&r.parent.id,l;if(c&&!(c in e)&&i(r.parent,!1),c in t){let u=t[c]=t[c]||r1(e[c],e);l=u(r,s),t[a]=u}else Number.isFinite(o)?(l=o+(e[c]||0),t[a]=null):l=n;return s&&l>=n&&(n=l+1),e[a]=l,l};return i}function gF(n,{canvasContext:e=n.canvasContext,shaderModuleProps:t,target:i,viewport:r}){let s=t?.project?.devicePixelRatio??e.cssToDeviceRatio(),[,o]=e.getDrawingBufferSize(),a=i?i.height:o,c=r;return[c.x*s,a-(c.y+c.height)*s,c.width*s,c.height*s]}function i1(n,...e){for(let t of e)if(t)for(let i in t)n[i]?Object.assign(n[i],t[i]):n[i]=t[i];return n}var pc=class extends wi{constructor(e,t){super(e,t);let i=e.createTexture({format:"rgba8unorm",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),r=e.createTexture({format:"depth16unorm",width:1,height:1});this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[i],depthStencilAttachment:r})}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null)}getShadowMap(){return this.fbo.colorAttachments[0].texture}render(e){let t=this.fbo,i=this.device.canvasContext.cssToDeviceRatio(),r=e.viewports[0],s=r.width*i,o=r.height*i,a=[1,1,1,1];(s!==t.width||o!==t.height)&&t.resize({width:s,height:o}),super.render({...e,clearColor:a,target:t,pass:"shadow"})}getLayerParameters(e,t,i){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal"}}shouldDrawLayer(e){return e.props.shadowEnabled!==!1}getShaderModuleProps(e,t,i){return{shadow:{project:i.project,drawToShadowMap:!0}}}};var _F={color:[255,255,255],intensity:1},s1=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],yF=[0,0,0,200/255],fo=class{constructor(e={}){this.id="lighting-effect",this.shadowColor=yF,this.shadow=!1,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;let{device:t,deck:i}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(t),i._addDefaultShaderModule(Cf),this.dummyShadowMap=t.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=void 0,this.directionalLights=[],this.pointLights=[];for(let t in e){let i=e[t];switch(i.type){case"ambient":this.ambientLight=i;break;case"directional":this.directionalLights.push(i);break;case"point":this.pointLights.push(i);break;default:}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(t=>t.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:t,viewports:i,onViewportActive:r,views:s}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let o=0;oo.getShadowMap()),dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{},r={enabled:!0,lights:this._getLights(e)},s=e.props.material;return{shadow:i,lighting:r,phongMaterial:s,gouraudMaterial:s}}cleanup(e){for(let t of this.shadowPasses)t.delete();this.shadowPasses.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(Cf))}_calculateMatrices(){let e=[];for(let t of this.directionalLights){let i=new ze().lookAt({eye:new et(t.direction).negate()});e.push(i)}return e}_createShadowPasses(e){for(let t=0;tr&&(s=r);let o=this._pool,a=e.BYTES_PER_ELEMENT*s,c=o.findIndex(l=>l.byteLength>=a);if(c>=0){let l=new e(o.splice(c,1)[0],0,s);return i&&l.fill(0),l}return new e(s)}_release(e){if(!ArrayBuffer.isView(e))return;let t=this._pool,{buffer:i}=e,{byteLength:r}=i,s=t.findIndex(o=>o.byteLength>=r);s<0?t.push(i):(s>0||t.lengththis.opts.poolSize&&t.shift()}},gn=new S_;Ue();function po(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function P_(n,e){let t=n%e;return t<0?e+t:t}function a1(n){return[n[12],n[13],n[14]]}function c1(n){return{left:ho(n[3]+n[0],n[7]+n[4],n[11]+n[8],n[15]+n[12]),right:ho(n[3]-n[0],n[7]-n[4],n[11]-n[8],n[15]-n[12]),bottom:ho(n[3]+n[1],n[7]+n[5],n[11]+n[9],n[15]+n[13]),top:ho(n[3]-n[1],n[7]-n[5],n[11]-n[9],n[15]-n[13]),near:ho(n[3]+n[2],n[7]+n[6],n[11]+n[10],n[15]+n[14]),far:ho(n[3]-n[2],n[7]-n[6],n[11]-n[10],n[15]-n[14])}}var o1=new et;function ho(n,e,t,i){o1.set(n,e,t);let r=o1.len();return{distance:i/r,normal:new et(-n/r,-e/r,-t/r)}}function bF(n){return n-Math.fround(n)}var mc;function mo(n,e){let{size:t=1,startIndex:i=0}=e,r=e.endIndex!==void 0?e.endIndex:n.length,s=(r-i)/t;mc=gn.allocate(mc,s,{type:Float32Array,size:t*2});let o=i,a=0;for(;ow.useInPicking),pass:h,canvasContext:m,isPicking:!0,shaderModuleProps:g,clearColor:v??[0,0,0,0],colorMask:15,scissorRect:b});return this._colorEncoderState=null,{decodePickingColor:y&&a6.bind(null,y),stats:x}}shouldDrawLayer(e){let{pickable:t,operation:i}=e.props;return t&&i.includes("draw")||i.includes("terrain")||i.includes("mask")}getShaderModuleProps(e,t,i){return{picking:{isActive:1,isAttribute:this.pickZ,disabledPickingIndices:e.internalState?.disabledPickingIndices},lighting:{enabled:!1}}}getLayerParameters(e,t,i){let r={...e.props.parameters},{pickable:s,operation:o}=e.props;return this._colorEncoderState?s&&o.includes("draw")?(Object.assign(r,o6),r.blend=!0,this.device.type==="webgpu"?r.blendConstant=j1(this._colorEncoderState,e,i):r.blendColor=j1(this._colorEncoderState,e,i),o.includes("terrain")&&e.state?._hasPickingCover&&(r.blendAlphaSrcFactor="one")):o.includes("terrain")&&(r.blend=!1):r.blend=!1,r}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}};function j1(n,e,t){let{byLayer:i,byAlpha:r}=n,s,o=i.get(e);return o?(o.viewports.push(t),s=o.a):(s=i.size+1,s<=255?(o={a:s,layer:e,viewports:[t]},i.set(e,o),r[s]=o):(ae.warn("Too many pickable layers, only picking the first 255")(),s=0)),[0,0,0,s/255]}function a6(n,e){let t=n.byAlpha[e[3]];return t&&{pickedLayer:t.layer,pickedViewports:t.viewports,pickedObjectIndex:t.layer.decodePickingColor(e)}}Me();var Ji={NO_STATE:"Awaiting state",MATCHED:"Matched. State transferred from previous layer",INITIALIZED:"Initialized",AWAITING_GC:"Discarded. Awaiting garbage collection",AWAITING_FINALIZATION:"No longer matched. Awaiting garbage collection",FINALIZED:"Finalized! Awaiting garbage collection"},wo=Symbol.for("component"),Kn=Symbol.for("propTypes"),Of=Symbol.for("deprecatedProps"),Si=Symbol.for("asyncPropDefaults"),Qn=Symbol.for("asyncPropOriginal"),_n=Symbol.for("asyncPropResolved");function Df(n,e=()=>!0){return Array.isArray(n)?H1(n,e,[]):e(n)?[n]:[]}function H1(n,e,t){let i=-1;for(;++i0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,t){if(e===this._data&&!t)return;this._data=e;let i=++this._loadCount,r=e;typeof e=="string"&&(r=zs(e)),r instanceof Promise?(this.isLoaded=!1,this._loader=r.then(s=>{this._loadCount===i&&(this.isLoaded=!0,this._error=void 0,this._content=s)}).catch(s=>{this._loadCount===i&&(this.isLoaded=!0,this._error=s||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(let s of this._subscribers)s.onChange(this.getData())}};var xc=class{constructor(e){this.protocol=e.protocol||"resource://",this._context={device:e.device,gl:e.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return e.startsWith(this.protocol)?!0:e in this._resources}add({resourceId:e,data:t,forceUpdate:i=!1,persistent:r=!0}){let s=this._resources[e];s?s.setData(t,i):(s=new vc(e,t,this._context),this._resources[e]=s),s.persistent=r}remove(e){let t=this._resources[e];t&&(t.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){let t=this._consumers[e];if(t){for(let i in t){let r=t[i],s=this._resources[r.resourceId];s&&s.unsubscribe(r)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:t,consumerId:i,requestId:r="default"}){let{_resources:s,protocol:o}=this;e.startsWith(o)&&(e=e.replace(o,""),s[e]||this.add({resourceId:e,data:null,persistent:!1}));let a=s[e];if(this._track(i,r,a,t),a)return a.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(let e in this._resources)this._resources[e].delete()}_track(e,t,i,r){let s=this._consumers,o=s[e]=s[e]||{},a=o[t],c=a&&a.resourceId&&this._resources[a.resourceId];c&&(c.unsubscribe(a),this.prune()),i&&(a?(a.onChange=r,a.resourceId=i.id):a={onChange:r,resourceId:i.id},o[t]=a,i.subscribe(a))}_prune(){this._pruneRequest=null;for(let e of Object.keys(this._resources)){let t=this._resources[e];!t.persistent&&!t.inUse()&&(t.delete(),delete this._resources[e])}}};var c6="layerManager.setLayers",l6="layerManager.activateViewport",wc=class{constructor(e,t){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=a=>{Fe(l6,this,a),a&&(this.context.viewport=a)};let{deck:i,stats:r,viewport:s,timeline:o}=t||{};this.layers=[],this.resourceManager=new xc({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e?.gl,deck:i,shaderAssembler:n1(e?.info?.shadingLanguage||"glsl"),defaultShaderModules:[s_],renderPass:void 0,stats:r||new Ht({id:"deck.gl"}),viewport:s||new go({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:o||new Qr,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(let e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(let i of this.layers){let r=i.getNeedsRedraw(e);t=t||r}return t}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(t=>e.find(i=>t.id.indexOf(i)===0)):this.layers}setProps(e){"debug"in e&&(this._debug=e.debug),"userData"in e&&(this.context.userData=e.userData),"layers"in e&&(this._nextLayers=e.layers),"onError"in e&&(this.context.onError=e.onError)}setLayers(e,t){Fe(c6,this,t,e),this._lastRenderedLayers=e;let i=Df(e,Boolean);for(let r of i)r.context=this.context;this._updateLayers(this.layers,i)}updateLayers(){let e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){let{defaultShaderModules:t}=this.context;t.find(i=>i.name===e.name)||(t.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){let{defaultShaderModules:t}=this.context,i=t.findIndex(r=>r.name===e.name);i>=0&&(t.splice(i,1),this._defaultShaderModulesChanged=!0)}_handleError(e,t,i){i.raiseError(t,`${e} of ${i}`)}_updateLayers(e,t){let i={};for(let o of e)i[o.id]?ae.warn(`Multiple old layers with same id ${o.id}`)():i[o.id]=o;if(this._defaultShaderModulesChanged){for(let o of e)o.setNeedsUpdate(),o.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}let r=[];this._updateSublayersRecursively(t,i,r),this._finalizeOldLayers(i);let s=!1;for(let o of r)if(o.hasUniformTransition()){s=`Uniform transition in ${o}`;break}this._needsUpdate=s,this.layers=r}_updateSublayersRecursively(e,t,i){for(let r of e){r.context=this.context;let s=t[r.id];s===null&&ae.warn(`Multiple new layers with same id ${r.id}`)(),t[r.id]=null;let o=null;try{this._debug&&s!==r&&r.validateProps(),s?(this._transferLayerState(s,r),this._updateLayer(r)):this._initializeLayer(r),i.push(r),o=r.isComposite?r.getSubLayers():null}catch(a){this._handleError("matching",a,r)}o&&this._updateSublayersRecursively(o,t,i)}}_finalizeOldLayers(e){for(let t in e){let i=e[t];i&&this._finalizeLayer(i)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=Ji.INITIALIZED}catch(t){this._handleError("initialization",t,e)}}_transferLayerState(e,t){t._transferState(e),t.lifecycle=Ji.MATCHED,t!==e&&(e.lifecycle=Ji.AWAITING_GC)}_updateLayer(e){try{e._update()}catch(t){this._handleError("update",t,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=Ji.AWAITING_FINALIZATION;try{e._finalize(),e.lifecycle=Ji.FINALIZED}catch(t){this._handleError("finalization",t,e)}}};function Ee(n,e,t){if(n===e)return!0;if(!t||!n||!e)return!1;if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let i=0;i{let i=!e.canvasId||this.getCanvasId(t.id)===e.canvasId,r=!("x"in e)||t.containsPixel(e);return i&&r}):this._viewports}getViews(){let e={};return this.views.forEach(t=>{e[t.id]=t}),e}getView(e){return this.views.find(t=>t.id===e)}getViewState(e){let t=typeof e=="string"?this.getView(e):e,i=t&&this.viewState[t.getViewStateId()]||this.viewState;return t?t.filterViewState(i):i}getViewport(e){return this._viewportMap[e]}getCanvasId(e){let t=typeof e=="string"?this.getView(e):e;return t?this._viewEventManagers[t.id]?.canvasId||this._getCanvasIdFromView(t):void 0}unproject(e,t){let i=this.getViewports(),r={x:e[0],y:e[1]};for(let s=i.length-1;s>=0;--s){let o=i[s];if(o.containsPixel(r)){let a=e.slice();return a[0]-=o.x,a[1]-=o.y,o.unproject(a,t)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),("width"in e||"height"in e)&&this._setSize(e.width,e.height),"pickPosition"in e&&(this._pickPosition=e.pickPosition),"eventManagers"in e&&this._setEventManagers(e.eventManagers||{}),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,t){(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.setNeedsUpdate("Size changed"))}_setViews(e){e=Df(e,Boolean),this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){e?(!Ee(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e):ae.warn("missing `viewState` or `initialViewState`")()}_setEventManagers(e){this._eventManagers!==e&&(this._eventManagers=e,this.setNeedsUpdate("eventManagers changed"))}_getCanvasIdFromView(e){return e.props.canvasId||this._getCanvasContext?.(e.id)?.id||er}_getCanvasDimensions(e){let t=this._getCanvasContext?.(e.id),[i,r]=t?.getCSSSize()||[this.width,this.height];return{width:i,height:r}}_getViewEventManager(e){let t=this.getCanvasId(e)||er;return{canvasId:t,eventManager:this._eventManagers[t]||this._eventManager}}_startViewportRebuild(){let e=this.controllers,t=this._viewEventManagers;return this._viewports=[],this.controllers={},this._viewEventManagers={},{oldControllers:e,oldViewEventManagers:t}}_getReusableController(e,t,i){return e&&(t?.canvasId!==i.canvasId||t?.eventManager!==i.eventManager)?(e.finalize(),null):e}_createController(e,t){let i=t.type;return new i({timeline:this.timeline,eventManager:this._getViewEventManager(e).eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:s=>this.getView(e.id)?.makeViewport({viewState:s,...this._getCanvasDimensions(e)}),pickPosition:(s,o)=>this._pickPosition?.(s,o,e.id)})}_updateController(e,t,i,r){let s=e.controller;if(s&&i){let o={...t,...s,id:e.id,x:i.x,y:i.y,width:i.width,height:i.height};return(!r||r.constructor!==s.type)&&(r=this._createController(e,o)),r&&r.setProps(o),r}return null}_rebuildViewports(){let{views:e}=this,{oldControllers:t,oldViewEventManagers:i}=this._startViewportRebuild(),r=!1;for(let s=e.length;s--;){let o=e[s],{width:a,height:c}=this._getCanvasDimensions(o),l=this._getViewEventManager(o);this._viewEventManagers[o.id]=l;let u=this.getViewState(o),f=o.makeViewport({viewState:u,width:a,height:c}),d=this._getReusableController(t[o.id],i[o.id],l),h=!!o.controller;h&&!d&&(r=!0),(r||!h)&&d&&(d.finalize(),d=null),this.controllers[o.id]=this._updateController(o,u,f,d),f&&this._viewports.unshift(f)}for(let s in t){let o=t[s];o&&!this.controllers[s]&&o.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,t){return e.length!==t.length?!0:e.some((i,r)=>!e[r].equals(t[r]))}};var u6=/^(?:\d+\.?\d*|\.\d+)$/;function xt(n){switch(typeof n){case"number":if(!Number.isFinite(n))throw new Error(`Could not parse position string ${n}`);return{type:"literal",value:n};case"string":try{let e=f6(n);return new U_(e).parseExpression()}catch(e){let t=e instanceof Error?e.message:String(e);throw new Error(`Could not parse position string ${n}: ${t}`)}default:throw new Error(`Could not parse position string ${n}`)}}function z_(n,e){switch(n.type){case"literal":return n.value;case"percentage":return Math.round(n.value*e);case"binary":let t=z_(n.left,e),i=z_(n.right,e);return n.operator==="+"?t+i:t-i;default:throw new Error("Unknown layout expression type")}}function wt(n,e){return z_(n,e)}function f6(n){let e=[],t=0;for(;t="0"&&n<="9"}function Z1(n){return n>="a"&&n<="z"||n>="A"&&n<="Z"}function d6(n){return!!(n&&n.type==="symbol"&&(n.value==="+"||n.value==="-"))}function X1(n,e){let t={...n};for(let i in e)i!=="id"&&(Array.isArray(t[i])&&Array.isArray(e[i])?t[i]=h6(t[i],e[i]):t[i]=e[i]);return t}function h6(n,e){n=n.slice();for(let t=0;t{},Q1={mode:"preserve"},p6={mode:"hard"},$_={BREAK:1,SNAP_TO_END:2,IGNORE:3},m6=n=>n,g6=$_.BREAK,Sc=class{constructor(e){this._onTransitionUpdate=t=>{let{time:i,settings:{interpolator:r,startProps:s,endProps:o,duration:a,easing:c}}=t,l=c(i/a),u=r.interpolateProps(s,o,l);this.propsInTransition=this.getControllerState({...this.props,...u},Q1).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new yn(e.timeline),this.onViewStateChange=e.onViewStateChange||K1,this.onStateChange=e.onStateChange||K1}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let t=!1,i=this.props;if(this.props=e,!i||this._shouldIgnoreViewportChange(i,e))return!1;if(this._isTransitionEnabled(e)){let r=i;if(this.transition.inProgress){let{interruption:s,endProps:o}=this.transition.settings;r={...i,...s===$_.SNAP_TO_END?o:this.propsInTransition||i}}this._triggerTransition(r,e),t=!0}else this.transition.cancel();return t}updateTransition(){this.transition.update()}_isTransitionEnabled(e){let{transitionDuration:t,transitionInterpolator:i}=e;return(t>0||t==="auto")&&!!i}_isUpdateDueToCurrentTransition(e){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition):!1}_shouldIgnoreViewportChange(e,t){return this.transition.inProgress?this.transition.settings.interruption===$_.IGNORE||this._isUpdateDueToCurrentTransition(t):this._isTransitionEnabled(t)?t.transitionInterpolator.arePropsEqual(e,t):!0}_triggerTransition(e,t){let i=this.getControllerState(e,Q1),r=this.getControllerState(t,p6).shortestPathFrom(i),s=t.transitionInterpolator,o=s.getDuration?s.getDuration(e,t):t.transitionDuration;if(o===0)return;let a=s.initializeProps(e,r);this.propsInTransition={};let c={duration:o,easing:t.transitionEasing||m6,interpolator:s,interruption:t.transitionInterruption||g6,startProps:a.start,endProps:a.end,onStart:t.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(t.onTransitionInterrupt),onEnd:this._onTransitionEnd(t.onTransitionEnd)};this.transition.start(c),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return t=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e?.(t)}}};Ue();function ge(n,e){if(!n)throw new Error(e||"deck.gl: assertion failed.")}var Pc=class{constructor(e){let{compare:t,extract:i,required:r}=e;this._propsToCompare=t,this._propsToExtract=i||t,this._requiredProps=r}arePropsEqual(e,t){for(let i of this._propsToCompare)if(!(i in e)||!(i in t)||!$n(e[i],t[i]))return!1;return!0}initializeProps(e,t){let i={},r={};for(let s of this._propsToExtract)(s in e||s in t)&&(i[s]=e[s],r[s]=t[s]);return this._checkRequiredProps(i),this._checkRequiredProps(r),{start:i,end:r}}getDuration(e,t){return t.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(t=>{let i=e[t];ge(Number.isFinite(i)||Array.isArray(i),`${t} is required for transition`)})}};Ue();var _6=["longitude","latitude","zoom","bearing","pitch"],y6=["longitude","latitude","zoom"],Pi=class extends Pc{constructor(e={}){let t=Array.isArray(e)?e:e.transitionProps,i=Array.isArray(e)?{}:e;i.transitionProps=Array.isArray(t)?{compare:t,required:t}:t||{compare:_6,required:y6},super(i.transitionProps),this.opts=i}initializeProps(e,t){let i=super.initializeProps(e,t),{makeViewport:r,around:s}=this.opts;if(r&&s){let o=r(e),a=r(t),c=o.unproject(s);i.start.around=s,Object.assign(i.end,{around:a.project(c),aroundPosition:c,width:t.width,height:t.height})}return i}interpolateProps(e,t,i){let r={};for(let s of this._propsToExtract)r[s]=fn(e[s]||0,t[s]||0,i);if(t.aroundPosition&&this.opts.makeViewport){let s=this.opts.makeViewport({...t,...r});Object.assign(r,s.panByPosition(t.aroundPosition,fn(e.around,t.around,i)))}return r}};var Jn={transitionDuration:0},b6=300,v6=300,G_=n=>1-(1-n)*(1-n),x6=n=>n===1?1:1-Math.pow(2,-10*n),ts={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],MULTI_PAN:["multipanstart","multipanmove","multipanend"],DOUBLE_CLICK:["dblclick"],DOUBLE_CLICK_DRAG:["dblclickdragstart","dblclickdragmove","dblclickdragend","dblclickdragcancel"],KEYBOARD:["keydown"]},ns={},is=class{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this._multiPanMode=null,this._multiPanStartCenter=null,this._doubleClickDragAnchor=null,this._suppressDoubleClickUntil=0,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.doubleClickDragZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.multiTouchDrag=null,this.trackpadGesture=!1,this.zoomAround="pointer",this.keyboard=!0,this.transitionManager=new Sc({...e,getControllerState:(t,i)=>new this.ControllerState({...t,constraintContext:i,makeViewport:e.makeViewport}),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport,this.pickPosition=e.pickPosition}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){for(let e in this._events)this._events[e]&&this.eventManager?.off(e,this.handleEvent);this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;let t=this._eventStartBlocked;switch(e.type){case"panstart":return t?!1:this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return t||!this._isTrackpadGestureAllowed(e)?!1:this._onPinchStart(e);case"pinchmove":return this._isTrackpadGestureAllowed(e)?this._onPinch(e):!1;case"pinchend":return this._isTrackpadGestureAllowed(e)?this._onPinchEnd(e):!1;case"multipanstart":return t?!1:this._onMultiPanStart(e);case"multipanmove":return this._onMultiPan(e);case"multipanend":return this._onMultiPanEnd(e);case"dblclick":return this._onDoubleClick(e);case"dblclickdragstart":return t?!1:this._onDoubleClickDragStart(e);case"dblclickdragmove":return this._onDoubleClickDrag(e);case"dblclickdragend":case"dblclickdragcancel":return this._onDoubleClickDragEnd(e);case"wheel":return this._onWheel(e);case"keydown":return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){let{x:t,y:i}=this.props,{offsetCenter:r}=e;return[r.x-t,r.y-i]}getZoomPosition(e){if(this.zoomAround==="pointer")return e;let t=this.makeViewport(this.controllerState.getViewportProps()),[i,r]=Qi(t.center,t.pixelProjectionMatrix);return[i,r]}isPointInBounds(e,t){let{width:i,height:r}=this.props;if(t&&t.handled)return!1;let s=e[0]>=0&&e[0]<=i&&e[1]>=0&&e[1]<=r;return s&&t&&t.stopPropagation(),s}isFunctionKeyPressed(e){let{srcEvent:t}=e;return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){let t=setTimeout(()=>{this._eventStartBlocked===t&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=t}setProps(e){e.maxBoundsPadding===void 0&&(e.maxBoundsPadding=null),e.dragMode&&(this.dragMode=e.dragMode);let t=this.props;this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);let{inertia:i}=e;this.inertia=Number.isFinite(i)?i:i===!0?b6:0;let{scrollZoom:r=!0,dragPan:s=!0,dragRotate:o=!0,doubleClickZoom:a=!0,doubleClickDragZoom:c=!1,touchZoom:l=!0,touchRotate:u=!1,multiTouchDrag:f=u?"rotate":null,trackpadGesture:d=!1,zoomAround:h="pointer",keyboard:p=!0}=e,m=!!this.onViewStateChange;if(this.toggleEvents(ts.WHEEL,m&&r),this.toggleEvents(ts.PAN,m),this.toggleEvents(ts.PINCH,m&&(l||f==="rotate")),this.toggleEvents(ts.MULTI_PAN,m&&!!f),this.toggleEvents(ts.DOUBLE_CLICK,m&&a),this.toggleEvents(ts.DOUBLE_CLICK_DRAG,m&&c),this.toggleEvents(ts.KEYBOARD,m&&p),this.scrollZoom=r,this.dragPan=s,this.dragRotate=o,this.doubleClickZoom=a,this.doubleClickDragZoom=c,this.touchZoom=l,this.touchRotate=f==="rotate",this.multiTouchDrag=f,this.trackpadGesture=d,this.zoomAround=h,this.keyboard=p,(!t||t.height!==e.height||t.width!==e.width||t.maxBounds!==e.maxBounds||t.maxBoundsPadding!==e.maxBoundsPadding)&&e.maxBounds){let v=new this.ControllerState({...e,makeViewport:this.makeViewport}),y=v.getViewportProps();Object.keys(y).some(x=>!Ee(y[x],e[x],1))&&this.updateViewport(v)}}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,t){this.eventManager&&e.forEach(i=>{this._events[i]!==t&&(this._events[i]=t,t?this.eventManager.on(i,this.handleEvent):this.eventManager.off(i,this.handleEvent))})}updateViewport(e,t=null,i={}){let r={...e.getViewportProps(),...t},s=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(i),s){let o=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:r,interactionState:this._interactionState,oldViewState:o,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_getConstraintContext(e,t){return this.props.rubberBand?{mode:t==="update"?"elastic":t==="end"?"rebound":"hard"}:{mode:"hard"}}_getReboundTransition(e,t){if(e.mode!=="rebound")return null;let i=t.getViewportProps();return Object.keys(i).some(s=>!Ee(this.props[s],i[s],1))?{...this._getTransitionProps(),transitionDuration:v6,transitionEasing:x6}:null}_onPanStart(e){let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let i=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(i=!i);let r=i?"pan":"rotate",s=this._getConstraintContext(r,"start"),o=i?this.controllerState.panStart({pos:t},s):this.controllerState.rotateStart({pos:t},s);return this._panMove=i,this.updateViewport(o,Jn,{isDragging:!0}),!0}_onPan(e){return this.isDragging()?this._panMove?this._onPanMove(e):this._onPanRotate(e):!1}_onPanEnd(e){return this.isDragging()?this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e):!1}_onPanMove(e){if(!this.dragPan)return!1;let t=this.getCenter(e),i=this.controllerState.pan({pos:t},this._getConstraintContext("pan","update"));return this.updateViewport(i,Jn,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){let{inertia:t}=this;if(this.dragPan&&t&&e.velocity){let i=this.getCenter(e),r=[i[0]+e.velocityX*t/2,i[1]+e.velocityY*t/2],s=this.controllerState.pan({pos:r}).panEnd();this.updateViewport(s,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:G_},{isDragging:!1,isPanning:!0})}else{let i=this.controllerState,r=this._getConstraintContext("pan","end"),s=i.panEnd(r),o=this._getReboundTransition(r,s);this.updateViewport(s,o,{isDragging:!1,isPanning:!!o})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;let t=this.getCenter(e),i=this.controllerState.rotate({pos:t},this._getConstraintContext("rotate","update"));return this.updateViewport(i,Jn,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){let{inertia:t}=this;if(this.dragRotate&&t&&e.velocity){let i=this.getCenter(e),r=[i[0]+e.velocityX*t/2,i[1]+e.velocityY*t/2],s=this.controllerState.rotate({pos:r}).rotateEnd();this.updateViewport(s,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:G_},{isDragging:!1,isRotating:!0})}else{let i=this.controllerState,r=this._getConstraintContext("rotate","end"),s=i.rotateEnd(r),o=this._getReboundTransition(r,s);this.updateViewport(s,o,{isDragging:!1,isRotating:!!o})}return!0}_onWheel(e){if(!this.scrollZoom||this.trackpadGesture&&e.device!=="mouse")return!1;let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;e.srcEvent.preventDefault();let{speed:i=.01,smooth:r=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:s}=e,o=2/(1+Math.exp(-Math.abs(s*i)));s<0&&o!==0&&(o=1/o);let a=this.getZoomPosition(t),c=r?{...this._getTransitionProps({around:a}),transitionDuration:250}:Jn,l=this.controllerState.zoom({pos:a,scale:o});return this.updateViewport(l,c,{isZooming:!0,isPanning:!0}),r||this._setInteractionState({isZooming:!1,isPanning:!1}),!0}_onMultiPanStart(e){let{multiTouchDrag:t}=this;if(!t||!this._isMultiPanEventAllowed(e,t))return!1;let i=e.offsetCenter;if(!this.isPointInBounds(this.getCenter(e),e))return!1;let r=e.pointerType==="trackpad",s={x:i.x-(r?0:e.deltaX),y:i.y-(r?0:e.deltaY)},o={...e,offsetCenter:s},a=this.getCenter(o),c=t==="pan"?this.controllerState.panStart({pos:a},this._getConstraintContext("pan","start")):this.controllerState.rotateStart({pos:a},this._getConstraintContext("rotate","start"));return this._multiPanMode=t,this._multiPanStartCenter=s,this.updateViewport(c,Jn,{isDragging:!0}),!0}_onMultiPan(e){let{mode:t,event:i}=this._getMultiPanEvent(e);return!t||!i||!this.isDragging()?!1:t==="pan"?this._onPanMove(i):this._onPanRotate(i)}_onMultiPanEnd(e){let{mode:t,event:i}=this._getMultiPanEvent(e);if(!t||!i||!this.isDragging())return this._resetMultiPan(),!1;let r=t==="pan"?this._onPanMoveEnd(i):this._onPanRotateEnd(i);return this._resetMultiPan(),r}_isTrackpadGestureAllowed(e){return e.pointerType!=="trackpad"||this.trackpadGesture}_isMultiPanEventAllowed(e,t){return e.pointerType==="trackpad"?this.trackpadGesture&&(t==="pan"?this.dragPan:this.dragRotate):e.pointerType==="touch"&&(t==="pan"?this.dragPan:this.dragRotate)}_getMultiPanEvent(e){let t=this._multiPanMode,i=this._multiPanStartCenter;return!t||!i?{mode:null,event:null}:{mode:t,event:{...e,offsetCenter:{x:i.x+e.deltaX,y:i.y+e.deltaY}}}}_resetMultiPan(){this._multiPanMode=null,this._multiPanStartCenter=null}_onPinchStart(e){this._doubleClickDragAnchor=null;let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let i=this.controllerState.zoomStart({pos:this.getZoomPosition(t)},this._getConstraintContext("zoom","start")).rotateStart({pos:t},this._getConstraintContext("rotate","start"));return ns._startPinchRotation=e.rotation,ns._lastPinchEvent=e,this.updateViewport(i,Jn,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let t=this.controllerState;if(this.touchZoom){let{scale:i}=e,r=this.getCenter(e);t=t.zoom({pos:this.getZoomPosition(r),scale:i},this._getConstraintContext("zoom","update"))}if(this.touchRotate){let{rotation:i}=e;t=t.rotate({deltaAngleX:ns._startPinchRotation-i},this._getConstraintContext("rotate","update"))}return this.updateViewport(t,Jn,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),ns._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;let{inertia:t}=this,{_lastPinchEvent:i}=ns;if(this.touchZoom&&t&&i&&e.scale!==i.scale){let r=this.getCenter(e),s=this.getZoomPosition(r),o=this.controllerState.rotateEnd(),a=Math.log2(e.scale),c=(a-Math.log2(i.scale))/(e.deltaTime-i.deltaTime),l=Math.pow(2,a+c*t/2);o=o.zoom({pos:s,scale:l}).zoomEnd(),this.updateViewport(o,{...this._getTransitionProps({around:s}),transitionDuration:t,transitionEasing:G_},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(t)}else{let r=this.controllerState,s=this._getConstraintContext("zoom","end"),o=this._getConstraintContext("rotate","end"),a=r.zoomEnd(s).rotateEnd(o),c=this._getReboundTransition(this.touchZoom?s:o,a);this.updateViewport(a,c,{isDragging:!1,isPanning:!!c&&this.touchZoom,isZooming:!!c&&this.touchZoom,isRotating:!!c&&this.touchRotate})}return ns._startPinchRotation=null,ns._lastPinchEvent=null,!0}_onDoubleClick(e){if(!this.doubleClickZoom||Date.now()90&&(e=Math.sign(e)*90),Number.isFinite(n)){let[i,r]=ht([n,e]);return[i,Te(r,0,e2)]}let[,t]=ht([0,e]);return[n,Te(t,0,e2)]}var V_=class extends rs{constructor(e){let{width:t,height:i,latitude:r,longitude:s,zoom:o,bearing:a=0,pitch:c=0,altitude:l=1.5,position:u=[0,0,0],maxZoom:f=20,minZoom:d=0,maxPitch:h=60,minPitch:p=0,startPanLngLat:m,startZoomLngLat:g,startRotatePos:v,startRotateLngLat:y,startBearing:b,startPitch:x,startZoom:E,normalize:w=!0,rubberBand:T=!1}=e,{[tn]:R}=e;ge(Number.isFinite(s)),ge(Number.isFinite(r)),ge(Number.isFinite(o));let F=e.maxBounds||(w?t2:null),O=e.maxBoundsPadding||null;super({width:t,height:i,latitude:r,longitude:s,zoom:o,bearing:a,pitch:c,altitude:l,maxZoom:f,minZoom:d,maxPitch:h,minPitch:p,normalize:w,position:u,maxBounds:F,maxBoundsPadding:O,rubberBand:T,[tn]:R},{startPanLngLat:m,startZoomLngLat:g,startRotatePos:v,startRotateLngLat:y,startBearing:b,startPitch:x,startZoom:E},e.makeViewport,e.constraintContext),this.getAltitude=e.getAltitude}panStart({pos:e},t){return this._getUpdatedState({startPanLngLat:this._unproject(e)},t)}pan({pos:e,startPos:t},i){let r=this.getState().startPanLngLat||this._unproject(t);if(!r)return this;let o=this.makeViewport(this.getViewportProps()).panByPosition(r,e);return this._getUpdatedState(o,i)}panEnd(e){return this._getUpdatedState({startPanLngLat:null},e)}rotateStart({pos:e}){let t=this.getAltitude?.(e);return this._getUpdatedState({startRotatePos:e,startRotateLngLat:t!==void 0?this._unproject3D(e,t):void 0,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:t=0,deltaAngleY:i=0}){let{startRotatePos:r,startRotateLngLat:s,startBearing:o,startPitch:a}=this.getState();if(!r||o===void 0||a===void 0)return this;let c;if(e?c=this._getNewRotation(e,r,a,o):c={bearing:o+t,pitch:a+i},s){let l=this.makeViewport({...this.getViewportProps(),...c}),u="panByPosition3D"in l?"panByPosition3D":"panByPosition";return this._getUpdatedState({...c,...l[u](s,r)})}return this._getUpdatedState(c)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startRotateLngLat:null,startBearing:null,startPitch:null})}zoomStart({pos:e},t){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom},t)}zoom({pos:e,startPos:t,scale:i},r){let{startZoom:s,startZoomLngLat:o}=this.getState();return o||(s=this.getViewportProps().zoom,o=this._unproject(t)||this._unproject(e)),o?this._getUpdatedState({zoom:s+Math.log2(i),[tn]:{position:o,screenPosition:e}},r):this}zoomEnd(e){return this._getUpdatedState({startZoomLngLat:null,startZoom:null},e)}zoomIn(e=2,t){return this._zoomFromCenter(e,t)}zoomOut(e=2,t){return this._zoomFromCenter(1/e,t)}moveLeft(e=100,t){return this._panFromCenter([e,0],t)}moveRight(e=100,t){return this._panFromCenter([-e,0],t)}moveUp(e=100,t){return this._panFromCenter([0,e],t)}moveDown(e=100,t){return this._panFromCenter([0,-e],t)}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){let t=e.getViewportProps(),i={...this.getViewportProps()},{bearing:r,longitude:s}=i;return Math.abs(r-t.bearing)>180&&(i.bearing=r<0?r+360:r-360),Math.abs(s-t.longitude)>180&&(i.longitude=s<0?s+360:s-360),i}applyConstraints(e,t){let i=e,r=i[tn];delete i[tn];let{maxPitch:s,minPitch:o,pitch:a,bearing:c,normalize:l,maxBounds:u,rubberBand:f}=e;l&&(c<-180||c>180)&&(e.bearing=P_(c+180,360)-180),e.pitch=Te(a,o,s);let d=this._constrainZoom(e.zoom,e),h=f&&t?.mode==="elastic";if(e.zoom=t?.mode==="preserve"?e.zoom:h?tr(e.zoom,d,E6):d,r){let p=this.makeViewport(e);Object.assign(e,p.panByPosition(r.position,r.screenPosition))}if(l&&(e.longitude<-180||e.longitude>180)&&(e.longitude=P_(e.longitude+180,360)-180),u){let p=Eo(e.width,e.height,e.maxBoundsPadding),m=this.makeViewport({...e,bearing:0,pitch:0}),g=Nf(m,[e.longitude,e.latitude],p),v=Cc(u[0]),y=Cc(u[1]),b=2**e.zoom,x=[v[0]+g.left/b,v[1]+g.bottom/b],E=[y[0]-g.right/b,y[1]-g.top/b],w=Cc([e.longitude,e.latitude]),T=[Te(w[0],x[0],E[0]),Te(w[1],x[1],E[1])],R=w.slice();if(p.width>=0&&(R[0]=t?.mode==="preserve"?w[0]:h?tr(w[0],T[0],p.width/2/b):T[0]),p.height>=0&&(R[1]=t?.mode==="preserve"?w[1]:h?tr(w[1],T[1],p.height/2/b):T[1]),R[0]!==w[0]||R[1]!==w[1]){let[F,O]=It(R);R[0]!==w[0]&&(e.longitude=F),R[1]!==w[1]&&(e.latitude=O)}}return e}_constrainZoom(e,t){t||(t=this.getViewportProps());let{maxZoom:i,maxBounds:r}=t,s=r!==null&&t.width>0&&t.height>0,{minZoom:o}=t;if(s){let a=Eo(t.width,t.height,t.maxBoundsPadding),c=Cc(r[0]),l=Cc(r[1]),u=l[0]-c[0],f=l[1]-c[1];a.width>0&&Number.isFinite(u)&&u>0&&(o=Math.max(o,Math.log2(a.width/u))),a.height>0&&Number.isFinite(f)&&f>0&&(o=Math.max(o,Math.log2(a.height/f))),o>i&&(o=i)}return Te(e,o,i)}_zoomFromCenter(e,t){let{width:i,height:r}=this.getViewportProps();return this.zoom({pos:[i/2,r/2],scale:e},t)}_panFromCenter(e,t){let{width:i,height:r}=this.getViewportProps();return this.pan({startPos:[i/2,r/2],pos:[i/2+e[0],r/2+e[1]]},t)}_getUpdatedState(e,t){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e,constraintContext:t})}_unproject(e){let t=this.makeViewport(this.getViewportProps());return e&&t.unproject(e)}_unproject3D(e,t){return this.makeViewport(this.getViewportProps()).unproject(e,{targetZ:t})}_getNewRotation(e,t,i,r){let s=e[0]-t[0],o=e[1]-t[1],a=e[1],c=t[1],{width:l,height:u}=this.getViewportProps(),f=s/l,d=0;o>0?Math.abs(u-c)>J1&&(d=o/(c-u)*w6):o<0&&c>J1&&(d=1-a/c),d=Te(d,-1,1);let{minPitch:h,maxPitch:p}=this.getViewportProps(),m=r+180*f,g=i;return d>0?g=i+d*(p-i):d<0&&(g=i-d*(h-i)),{pitch:g,bearing:m}}},Tc=class extends is{constructor(){super(...arguments),this.ControllerState=V_,this.transition={transitionDuration:300,transitionInterpolator:new Pi({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan",this.rotationPivot="center",this._getAltitude=e=>{if(this.rotationPivot==="2d")return 0;if(this.rotationPivot==="3d"&&this.pickPosition){let{x:t,y:i}=this.props,r=this.pickPosition(t+e[0],i+e[1]);if(r&&r.coordinate&&r.coordinate.length>=3)return r.coordinate[2]}}}setProps(e){"rotationPivot"in e&&(this.rotationPivot=e.rotationPivot||"center"),e.getAltitude=this._getAltitude,e.position=e.position||[0,0,0],e.maxBounds=e.maxBounds||(e.normalize===!1?null:t2),super.setProps(e)}updateViewport(e,t=null,i={}){let r=e.getState();i.isDragging&&r.startRotateLngLat?i={...i,rotationPivotPosition:r.startRotateLngLat}:i.isDragging===!1&&(i={...i,rotationPivotPosition:void 0}),super.updateViewport(e,t,i)}};var Ff=class extends es{constructor(e={}){super(e)}getViewportType(){return Ei}get ControllerType(){return Tc}};Ff.displayName="MapView";var n2=Ff;var S6=new fo;function P6(n,e){let t=n.order??1/0,i=e.order??1/0;return t-i}var Lc=class{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){let t=this._defaultEffects;if(!t.find(i=>i.id===e.id)){let i=t.findIndex(r=>P6(r,e)>0);i<0?t.push(e):t.splice(i,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&(Ee(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}getEffects(){return this._resolvedEffects}_setEffects(e){let t={};for(let r of this.effects)t[r.id]=r;let i=[];for(let r of e){let s=t[r.id],o=r;s&&s!==r?s.setProps?(s.setProps(r.props),o=s):s.cleanup(this._context):s||r.setup(this._context),i.push(o),delete t[r.id]}for(let r in t)t[r].cleanup(this._context);this.effects=i,this._resolvedEffects=i.concat(this._defaultEffects),e.some(r=>r instanceof fo)||this._resolvedEffects.push(S6),this._needsRedraw="effects changed"}finalize(){for(let e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}};var Mc=class extends wi{shouldDrawLayer(e){let{operation:t}=e.props;return t.includes("draw")||t.includes("terrain")}render(e){return this._render(e)}};var C6="deckRenderer.renderLayers",Ac=class{constructor(e,t={}){this.device=e,this.stats=t.stats,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new Mc(e),this.pickLayersPass=new Jr(e),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(e){let t=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,i={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};if(!e.viewports.length){let a=t.render(i),c="stats"in a?a.stats:a;this._updateStats(c);return}i.effects&&this._preRender(i.effects,i);let r=this.lastPostProcessEffect?this.renderBuffers[0]:i.target;this.lastPostProcessEffect&&(i.clearColor=[0,0,0,0],i.clearCanvas=!0);let s=t.render({...i,target:r}),o="stats"in s?s.stats:s;i.effects&&(this.lastPostProcessEffect&&(i.clearCanvas=e.clearCanvas===void 0?!0:e.clearCanvas),this._postRender(i.effects,i)),this.renderCount++,Fe(C6,this,o,e),this._updateStats(o)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}finalize(){let{renderBuffers:e}=this;for(let t of e)t.delete();e.length=0}_updateStats(e){if(!this.stats)return;let t=0;for(let{visibleCount:i}of e)t+=i;this.stats.get("Layers rendered").addCount(t)}_preRender(e,t){this.lastPostProcessEffect=null,t.preRenderStats=t.preRenderStats||{};for(let i of e)t.preRenderStats[i.id]=i.preRender(t),i.postRender&&(this.lastPostProcessEffect=i.id);this.lastPostProcessEffect&&this._resizeRenderBuffers(t.canvasContext)}_resizeRenderBuffers(e=this.device.canvasContext){let{renderBuffers:t}=this,i=e.getDrawingBufferSize(),[r,s]=i;t.length===0&&[0,1].map(o=>{let a=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"},width:r,height:s});t.push(this.device.createFramebuffer({id:`deck-renderbuffer-${o}`,colorAttachments:[a]}))});for(let o of t)o.resize(i)}_postRender(e,t){let{renderBuffers:i}=this,r=t.target??t.canvasContext?.getCurrentFramebuffer()??t.target,s={...t,inputBuffer:i[0],swapBuffer:i[1]};for(let o of e)if(o.postRender){s.target=o.id===this.lastPostProcessEffect?r:void 0;let a=o.postRender(s);s.inputBuffer=a,s.swapBuffer=a===i[0]?i[1]:i[0]}}};J();var T6={pickedColor:null,pickedObjectIndex:-1};function W_({pickedColors:n,decodePickingColor:e,deviceX:t,deviceY:i,deviceRadius:r,deviceRect:s}){let{x:o,y:a,width:c,height:l}=s,u=r*r,f=-1,d=0;for(let h=0;hu)d+=4*c;else for(let g=0;g=0){let y=g+o-t,b=y*y+m;b<=u&&(u=b,f=d)}d+=4}}if(f>=0){let h=n.slice(f,f+4),p=e(h);if(p){let m=Math.floor(f/4/c),g=f/4-m*c;return{...p,pickedColor:h,pickedX:o+g,pickedY:a+m}}ae.error("Picked non-existent layer. Is picking buffer corrupt?")()}return T6}function j_({pickedColors:n,decodePickingColor:e}){let t=new Map;if(n){for(let i=0;i=0){let s=n.slice(i,i+4),o=s.join(",");if(!t.has(o)){let a=e(s);a?t.set(o,{...a,color:s}):ae.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(t.values())}function zf({pickInfo:n,viewports:e,pixelRatio:t,x:i,y:r,z:s}){let o=e[0];e.length>1&&(o=L6(n?.pickedViewports||e,{x:i,y:r}));let a;if(o){let c=[i-o.x,r-o.y];s!==void 0&&(c[2]=s),a=o.unproject(c)}return{color:null,layer:null,viewport:o,index:-1,picked:!1,x:i,y:r,pixel:[i,r],coordinate:a,devicePixel:n&&"pickedX"in n?[n.pickedX,n.pickedY]:void 0,pixelRatio:t}}function H_(n){let{pickInfo:e,lastPickedInfo:t,mode:i,layers:r}=n,{pickedColor:s,pickedLayer:o,pickedObjectIndex:a}=e,c=o?[o]:[];if(i==="hover"){let f=t.index,d=t.layerId,h=o?o.props.id:null;if(h!==d||a!==f){if(h!==d){let p=r.find(m=>m.props.id===d);p&&c.unshift(p)}t.layerId=h,t.index=a,t.info=null}}let l=zf(n),u=new Map;return u.set(null,l),c.forEach(f=>{let d={...l};f===o&&(d.color=s,d.index=a,d.picked=!0),d=Uf({layer:f,info:d,mode:i});let h=d.layer;f===o&&i==="hover"&&(t.info=d),u.set(h.id,d),i==="hover"&&h.updateAutoHighlight(d)}),u}function Uf({layer:n,info:e,mode:t}){for(;n&&e;){let i=e.layer||null;e.sourceLayer=i,e.layer=n,e=n.getPickingInfo({info:e,mode:t,sourceLayer:i}),n=n.parent}return e}function L6(n,e){for(let t=n.length-1;t>=0;t--){let i=n[t];if(i.containsPixel(e))return i}return n[0]}var kc=class{constructor(e,t={}){this._pickable=!0,this.device=e,this.stats=t.stats,this.pickLayersPass=new Jr(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){"layerFilter"in e&&(this.layerFilter=e.layerFilter),"_pickable"in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObjectAsync(e){return this._pickClosestObjectAsync(e)}pickObjectsAsync(e){return this._pickVisibleObjectsAsync(e)}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:t,layers:i,viewports:r},s=this.lastPickedInfo.info){let o=s&&s.layer&&s.layer.id,a=s&&s.viewport&&s.viewport.id,c=o?i.find(d=>d.id===o):null,l=a&&r.find(d=>d.id===a)||r[0],u=l&&l.unproject([e-l.x,t-l.y]);return{...s,...{x:e,y:t,viewport:l,coordinate:u,layer:c}}}_resizeBuffer(e=this.device.getDefaultCanvasContext()){if(!this.pickingFBO){let r=this.device.createTexture({format:"rgba8unorm",width:1,height:1,usage:me.RENDER_ATTACHMENT|me.COPY_SRC});if(this.pickingFBO=this.device.createFramebuffer({colorAttachments:[r],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float")){let s=this.device.createTexture({format:"rgba32float",width:1,height:1,usage:me.RENDER_ATTACHMENT|me.COPY_SRC}),o=this.device.createFramebuffer({colorAttachments:[s],depthStencilAttachment:"depth16unorm"});this.depthFBO=o}}let[t,i]=e.getDrawingBufferSize();this.pickingFBO?.resize({width:t,height:i}),this.depthFBO?.resize({width:t,height:i})}_getPickable(e){if(this._pickable===!1)return null;let t=e.filter(i=>this.pickLayersPass.shouldDrawLayer(i)&&!i.isComposite);return t.length?t:null}async _pickClosestObjectAsync({layers:e,views:t,viewports:i,x:r,y:s,radius:o=0,depth:a=1,mode:c="query",unproject3D:l,canvasContext:u=this.device.getDefaultCanvasContext(),onViewportActive:f,effects:d}){let h=u.cssToDeviceRatio(),p=this._getPickable(e);if(!p||i.length===0)return{result:[],emptyInfo:zf({viewports:i,x:r,y:s,pixelRatio:h})};this._resizeBuffer(u);let m=u.cssToDevicePixels([r,s],!0),g=[m.x+Math.floor(m.width/2),m.y+Math.floor(m.height/2)],v=Math.round(o*h),{width:y,height:b}=this.pickingFBO,x=this._getPickingRect({deviceX:g[0],deviceY:g[1],deviceRadius:v,deviceWidth:y,deviceHeight:b}),E={x:r-o,y:s-o,width:o*2+1,height:o*2+1},w,T=[],R=new Set;for(let F=0;F0){let{pickedColors:G}=await this._drawAndSampleAsync({layers:V,views:t,viewports:i,onViewportActive:f,deviceRect:{x:O.pickedX??g[0],y:O.pickedY??g[1],width:1,height:1},cullRect:E,effects:d,pass:`picking:${c}:z`,canvasContext:u},!0);G[3]&&(j=G[0])}O.pickedLayer&&F+10){let{pickedColors:G}=this._drawAndSample({layers:V,views:t,viewports:i,onViewportActive:f,deviceRect:{x:O.pickedX??g[0],y:O.pickedY??g[1],width:1,height:1},cullRect:E,effects:d,pass:`picking:${c}:z`,canvasContext:u},!0);G[3]&&(j=G[0])}O.pickedLayer&&F+1=l);j++){let V=T[j],G={color:V.pickedColor,layer:null,index:V.pickedObjectIndex,picked:!0,x:r,y:s,pixelRatio:p};G=Uf({layer:V.pickedLayer,info:G,mode:c});let q=G.layer.id;R.has(q)||R.set(q,new Set);let X=R.get(q),se=G.object??G.index;X.has(se)||(X.add(se),F.push(G))}return F}_pickVisibleObjects({layers:e,views:t,viewports:i,x:r,y:s,width:o=1,height:a=1,mode:c="query",maxObjects:l=null,canvasContext:u=this.device.getDefaultCanvasContext(),onViewportActive:f,effects:d}){let h=this._getPickable(e);if(!h||i.length===0)return[];this._resizeBuffer(u);let p=u.cssToDeviceRatio(),m=u.cssToDevicePixels([r,s],!0),g=m.x,v=m.y+m.height,y=u.cssToDevicePixels([r+o,s+a],!0),b=y.x+y.width,x=y.y,E={x:g,y:x,width:b-g,height:v-x},w=this._drawAndSample({layers:h,views:t,viewports:i,onViewportActive:f,deviceRect:E,cullRect:{x:r,y:s,width:o,height:a},effects:d,pass:`picking:${c}`,canvasContext:u}),T=j_(w),R=new Map,F=[],O=Number.isFinite(l);for(let j=0;j=l);j++){let V=T[j],G={color:V.pickedColor,layer:null,index:V.pickedObjectIndex,picked:!0,x:r,y:s,pixelRatio:p};G=Uf({layer:V.pickedLayer,info:G,mode:c});let q=G.layer.id;R.has(q)||R.set(q,new Set);let X=R.get(q),se=G.object??G.index;X.has(se)||(X.add(se),F.push(G))}return F}async _drawAndSampleAsync({layers:e,views:t,viewports:i,onViewportActive:r,deviceRect:s,cullRect:o,effects:a,pass:c,canvasContext:l},u=!1){let f=u?this.depthFBO:this.pickingFBO,d={layers:e,layerFilter:this.layerFilter,views:t,viewports:i,onViewportActive:r,pickingFBO:f,deviceRect:s,cullRect:o,effects:a,pass:c,canvasContext:l,pickZ:u,preRenderStats:{},isPicking:!0};for(let E of a)E.useInPicking&&(d.preRenderStats[E.id]=E.preRender(d));let{decodePickingColor:h,stats:p}=this.pickLayersPass.render(d);this._updateStats(p);let{x:m,y:g,width:v,height:y}=s,b=f.colorAttachments[0]?.texture;if(!b)throw new Error("Picking framebuffer color attachment is missing");let x=await this._readTextureDataAsync(b,{x:m,y:g,width:v,height:y},u?Float32Array:Uint8Array);if(!u){let E=!1;for(let w=3;w0&&ae.warn("Async pick readback returned only zero alpha values",{deviceRect:s,bytes:Array.from(x.subarray(0,Math.min(x.length,16)))})()}return{pickedColors:x,decodePickingColor:h}}async _readTextureDataAsync(e,t,i){let{width:r,height:s}=t,o=e.computeMemoryLayout(t),a=this.device.createBuffer({byteLength:o.byteLength,usage:ie.COPY_DST|ie.MAP_READ});try{e.readBuffer(t,a);let c=await a.readAsync(0,o.byteLength),l=i.BYTES_PER_ELEMENT;if(o.bytesPerRow%l!==0)throw new Error(`Texture readback row stride ${o.bytesPerRow} is not aligned to ${l}-byte elements.`);let u=new i(c.buffer,c.byteOffset,o.byteLength/l),f=r*4,d=o.bytesPerRow/l;if(do.props.operation.includes("terrain"))}_getPickingRect({deviceX:e,deviceY:t,deviceRadius:i,deviceWidth:r,deviceHeight:s}){let o=Math.max(0,e-i),a=Math.max(0,t-i),c=Math.min(r,e+i+1)-o,l=Math.min(s,t+i+1)-a;return c<=0||l<=0?null:{x:o,y:a,width:c,height:l}}};var M6={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},A6="top-left",i2="root",$f=class{constructor({deck:e,parentElement:t}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,t?.classList.add("deck-widget-container"),this.parentElement=t}getWidgets(){return this.resolvedWidgets}setProps(e){if(e.widgets&&!Ee(e.widgets,this.widgets,1)){let t=e.widgets.filter(Boolean);this._setWidgets(t)}}finalize(){for(let e of this.getWidgets())this._removeWidget(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(let e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(t=>t.id===e.id)||(this._addWidget(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}onRedraw({viewports:e,layers:t}){let i=e.reduce((r,s)=>(r[s.id]=s,r),{});for(let r of this.getWidgets()){let{viewId:s}=r;if(s){let o=i[s];o&&(r.onViewportChange&&r.onViewportChange(o),r.onRedraw?.({viewports:[o],layers:t}))}else{if(r.onViewportChange)for(let o of e)r.onViewportChange(o);r.onRedraw?.({viewports:e,layers:t})}}this.lastViewports=i,this._updateContainers()}onHover(e,t){for(let i of this.getWidgets()){let{viewId:r}=i;(!r||r===e.viewport?.id)&&i.onHover?.(e,t)}}getCanvasBounds(e){let i=this.deck?.getCanvas?.()?.getBoundingClientRect(),r=this.parentElement?.getBoundingClientRect(),s=this.deck?.getCanvasContext?.(e?.id);if(s&&r){s.updatePosition();let[o,a]=s.getPosition(),[c,l]=s.getCSSSize();return{x:o-r.left,y:a-r.top,width:c,height:l}}return{x:i&&r?i.left-r.left:0,y:i&&r?i.top-r.top:0,width:i?.width||this.deck?.width||0,height:i?.height||this.deck?.height||0}}onEvent(e,t){let i=ao[t.type];if(i)for(let r of this.getWidgets()){let{viewId:s}=r;(!s||s===e.viewport?.id)&&r[i]?.(e,t)}}_setWidgets(e){let t={};for(let i of this.resolvedWidgets)t[i.id]=i;this.resolvedWidgets.length=0;for(let i of this.defaultWidgets)t[i.id]=null,this.resolvedWidgets.push(i);for(let i of e){let r=t[i.id];r?r.viewId!==i.viewId||r.placement!==i.placement?(this._removeWidget(r),this._addWidget(i)):i!==r&&(r.setProps(i.props),i=r):this._addWidget(i),t[i.id]=null,this.resolvedWidgets.push(i)}for(let i in t){let r=t[i];r&&this._removeWidget(r)}this.widgets=e}_addWidget(e){let{viewId:t=null,placement:i=A6}=e,r=e.props._container??t;e.widgetManager=this,e.deck=this.deck,e.rootElement=e._onAdd({deck:this.deck,viewId:t}),e.rootElement&&this._getContainer(r,i).append(e.rootElement),e.updateHTML()}_removeWidget(e){e.onRemove?.(),e.rootElement&&e.rootElement.remove(),e.rootElement=void 0,e.deck=void 0,e.widgetManager=void 0}_getContainer(e,t){if(e&&typeof e!="string")return e;let i=e||i2,r=this.containers[i];r||(r=document.createElement("div"),r.style.pointerEvents="none",r.style.position="absolute",r.style.overflow="hidden",this.parentElement?.append(r),this.containers[i]=r);let s=r.querySelector(`.${t}`);return s||(s=globalThis.document.createElement("div"),s.className=t,s.style.position="absolute",s.style.zIndex="2",Object.assign(s.style,M6[t]),r.append(s)),s}_updateContainers(){for(let e in this.containers){let t=this.lastViewports[e]||null,i=e===i2||t,r=this.containers[e];if(i){let s=this._getContainerBounds(t);r.style.display="block",r.style.left=`${s.x}px`,r.style.top=`${s.y}px`,r.style.width=`${s.width}px`,r.style.height=`${s.height}px`}else r.style.display="none"}}_getContainerBounds(e){if(!e)return{x:0,y:0,width:this.parentElement?.clientWidth||this.deck.width,height:this.parentElement?.clientHeight||this.deck.height};let t=this.getCanvasBounds(e);return{x:t.x+e.x,y:t.y+e.y,width:e.width,height:e.height}}};function Y_(n,e){e&&Object.entries(e).map(([t,i])=>{t.startsWith("--")?n.style.setProperty(t,i):n.style[t]=i})}function r2(n,e){e&&Object.keys(e).map(t=>{t.startsWith("--")?n.style.removeProperty(t):n.style[t]=""})}var So=class{constructor(e){this.viewId=null,this.props={...this.constructor.defaultProps,...e},this.id=this.props.id}setProps(e){let t=this.props,i=this.rootElement;i&&t.className!==e.className&&(t.className&&i.classList.remove(t.className),e.className&&i.classList.add(e.className)),i&&!Ee(t.style,e.style,1)&&(r2(i,t.style),Y_(i,e.style)),Object.assign(this.props,e),this.updateHTML()}updateHTML(){this.rootElement&&this.onRenderHTML(this.rootElement)}get viewIds(){return this.viewId?[this.viewId]:this.deck?.getViews().map(e=>e.id)??[]}getViewState(e){return this.deck?.viewManager?.getViewState(e)||{}}setViewState(e,t){this.deck?._onViewStateChange({viewId:e,viewState:t,interactionState:{}})}onCreateRootElement(){let e=["deck-widget",this.className,this.props.className],t=document.createElement("div");return e.filter(i=>typeof i=="string"&&i.length>0).forEach(i=>t.classList.add(i)),Y_(t,this.props.style),t}_onAdd(e){return this.onAdd(e)??this.onCreateRootElement()}onAdd(e){}onRemove(){}onViewportChange(e){}onRedraw(e){}onHover(e,t){}onClick(e,t){}onDrag(e,t){}onDragStart(e,t){}onDragEnd(e,t){}};So.defaultProps={id:"widget",style:{},_container:null,className:""};var k6={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"},Rc=class extends So{constructor(e={}){super(e),this.id="default-tooltip",this.placement="fill",this.className="deck-tooltip",this.isVisible=!1,this.setProps(e)}onCreateRootElement(){let e=document.createElement("div");return e.className=this.className,Object.assign(e.style,k6),e}onRenderHTML(e){}onViewportChange(e){this.isVisible&&e.id===this.lastViewport?.id&&!e.equals(this.lastViewport)&&this.setTooltip(null),this.lastViewport=e}onHover(e){let{deck:t}=this,i=t&&t.props.getTooltip;if(!i)return;let r=i(e),s=this.widgetManager?.getCanvasBounds(e.viewport),o=e.x+(s?.x||0),a=e.y+(s?.y||0);this.setTooltip(r,o,a)}setTooltip(e,t,i){let r=this.rootElement;if(r){if(typeof e=="string")r.innerText=e;else if(e)e.text&&(r.innerText=e.text),e.html&&(r.innerHTML=e.html),e.className&&(r.className=e.className);else{this.isVisible=!1,r.style.display="none";return}this.isVisible=!0,r.style.display="block",r.style.transform=`translate(${t}px, ${i}px)`,e&&typeof e=="object"&&"style"in e&&Object.assign(r.style,e.style)}}};Rc.defaultProps={...So.defaultProps};var Ic=class{constructor(e){this.targets={},this.order=[],this.eventManagers={},this._eventRootToCanvasId=new WeakMap,this._createEventManager=e.createEventManager,this._getEventRoot=e.getEventRoot}finalize(){for(let e of Object.values(this.targets))e.eventManager.destroy(),e.presentationContext.destroy();this.targets={},this.order=[],this.eventManagers={},this._eventRootToCanvasId=new WeakMap}syncCanvasEntries(e){let t=this._normalizeCanvasList(e.canvases),i={},r=[],s=new Map;for(let{canvas:a}of t){let c=this._getEventRoot(a);s.set(c,(s.get(c)||0)+1)}for(let{id:a,canvas:c}of t){let l=this._getEventRoot(c),u=s.get(l)===1?l:c,f=this.targets[a];if(!f||f.device!==e.device||f.canvas!==c||f.eventRoot!==u){f?.eventManager.destroy(),f?.presentationContext.destroy();let d=e.device.createPresentationContext({id:a,canvas:c,useDevicePixels:e.useDevicePixels,autoResize:!0});f={id:a,device:e.device,canvas:c,eventRoot:u,presentationContext:d,eventManager:this._createEventManager(u)}}this._eventRootToCanvasId.set(u,a),this._eventRootToCanvasId.set(c,a),i[a]=f,r.push(a)}for(let[a,c]of Object.entries(this.targets))i[a]||(c.eventManager.destroy(),c.presentationContext.destroy());this.targets=i,this.order=r;let o=Object.fromEntries(Object.entries(i).map(([a,c])=>[a,c.eventManager]));this._haveSameEventManagers(o)||(this.eventManagers=o)}getCanvasIdFromEvent(e){return e?this._eventRootToCanvasId.get(e):void 0}getTarget(e){return this.targets[e||this.order[0]||er]||null}_normalizeCanvasList(e=[]){let t=new Set;return e.map((i,r)=>{let s,o;return typeof i=="string"?(s=document.getElementById(i),ge(s,`Canvas with id ${i} not found`),o=i):(s=i,o=s.id||`deckgl-canvas-${r}`),ge(!t.has(o),`Duplicate canvas id ${o}`),t.add(o),{id:o,canvas:s}})}_haveSameEventManagers(e){let t=Object.keys(e),i=Object.keys(this.eventManagers);return t.length===i.length&&t.every(r=>e[r]===this.eventManagers[r])}};J();bd();Me();Me();ua();function Ci(){}var Gz=({isDragging:n})=>n?"grabbing":"grab",AP={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,pickAsync:"auto",layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{},gl:null,canvas:null,_canvases:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:Ci,onWebGLInitialized:Ci,onResize:Ci,onViewStateChange:Ci,onInteractionStateChange:Ci,onBeforeRender:Ci,onAfterRender:Ci,onLoad:Ci,onError:n=>ae.error(n.message,n.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:Gz,getTooltip:null,debug:!1,drawPickingColors:!1},jc=class{constructor(e){this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.eventManagers={},this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this._canvasContext=null,this._deviceResizeHandler=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new Ht({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,layersCount:0,drawLayersCount:0,updateLayersCount:0,updateAttributesCount:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,pickLayersCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._hoverPickSequence=0,this._pointerDownPickSequence=0,this._needsRedraw="Initial render",this._canvasManager=new Ic({createEventManager:r=>this._createEventManager(r),getEventRoot:r=>this._getEventRoot(r)}),this._ownedCanvas=null,this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,canvasId:void 0,event:null,unproject3D:!1},this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this._onPointerMove=r=>{let{_pickRequest:s}=this,o=this._getCanvasIdFromEvent(r);if(r.type==="pointerleave")s.x=-1,s.y=-1,s.radius=0,s.canvasId=o;else{if(r.leftButton||r.rightButton)return;{let a=r.offsetCenter;if(!a)return;s.x=a.x,s.y=a.y,s.radius=this.props.pickingRadius,s.canvasId=o}}this.layerManager&&(this.layerManager.context.mousePosition={x:s.x,y:s.y}),s.event=r},this._onEvent=r=>{let s=ao[r.type],o=r.offsetCenter,a=this._getCanvasIdFromEvent(r);if(!s||!o||!this.layerManager)return;let c=this.layerManager.getLayers(),l=this._getInternalPickingMode();if(!l)return;if(l==="sync"){let f=r.type==="click"&&this._shouldUnproject3D(c)?this._getFirstPickedInfo(this._pickPointSync(this._getPointPickOptions(o.x,o.y,{unproject3D:!0,canvasId:a},c))):this._getLastPointerDownPickingInfo(o.x,o.y,a,c);this._dispatchPickingEvent(f,r);return}(this._lastPointerDownInfoPromise||Promise.resolve(this._getLastPointerDownPickingInfo(o.x,o.y,a,c))).then(f=>{this._dispatchPickingEvent(f,r)}).catch(f=>this.props.onError?.(f))},this._onPointerDown=r=>{let s=r.offsetCenter,o=this._getCanvasIdFromEvent(r);if(!s)return;let a=this._getInternalPickingMode();if(!a)return;let c=this.layerManager?.getLayers()||[],l=++this._pointerDownPickSequence;if(a==="sync"){let f=this._pickPointSync({x:s.x,y:s.y,canvasId:o,radius:this.props.pickingRadius}),d=this._getFirstPickedInfo(f);this._lastPointerDownInfo=d,this._lastPointerDownInfoPromise=Promise.resolve(d);return}let u=this._pickPointAsync(this._getPointPickOptions(s.x,s.y,{canvasId:o},c)).then(f=>this._getFirstPickedInfo(f)).then(f=>(l===this._pointerDownPickSequence&&(this._lastPointerDownInfo=f),f)).catch(f=>{this.props.onError?.(f);let d=this.deckPicker&&this.viewManager?this._getLastPointerDownPickingInfo(s.x,s.y,o,c):{};return l===this._pointerDownPickSequence&&(this._lastPointerDownInfo=d),d});this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=u};let t=e;this.props={...AP,...e},e=this.props,this._validateCanvasConfiguration(e),e.viewState&&e.initialViewState&&ae.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,e.device&&(this.device=e.device,this._setDeviceCanvasContext(e.device));let i=this.device;!i&&e.gl&&(e.gl instanceof WebGLRenderingContext&&ae.error("WebGL1 context not supported.")(),i=Wc.attach(e.gl,{_cacheShaders:!0,_cachePipelines:!0,...this.props.deviceProps})),i||(i=this._createDevice(e)),this.animationLoop=this._createAnimationLoop(i,e),this.setProps(t),e._typedArrayManagerProps&&gn.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){this._restoreDeviceResizeHandler(),this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._hoverPickSequence++,this._pointerDownPickSequence++,this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this.layerManager?.finalize(),this.layerManager=null,this.viewManager?.finalize(),this.viewManager=null,this.effectManager?.finalize(),this.effectManager=null,this.deckRenderer?.finalize(),this.deckRenderer=null,this.deckPicker?.finalize(),this.deckPicker=null,Object.keys(this._canvasManager.targets).length||this.eventManager?.destroy(),this.eventManager=null,this.eventManagers={},this.widgetManager?.finalize(),this.widgetManager=null,this._canvasManager.finalize(),this._isMultiCanvasMode()?this.canvas=null:this.canvas&&this.canvas===this._ownedCanvas&&(this.canvas.parentElement?.removeChild(this.canvas),this.canvas=null,this._ownedCanvas=null),this._canvasContext=null}setProps(e){this.stats.get("setProps Time").timeStart(),"onLayerHover"in e&&ae.removed("onLayerHover","onHover")(),"onLayerClick"in e&&ae.removed("onLayerClick","onClick")(),e.initialViewState&&!Ee(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),ge(!("_canvases"in e)||Array.isArray(e._canvases)===this._isMultiCanvasMode()),Object.assign(this.props,e),this._validateCanvasConfiguration(this.props),this._validateInternalPickingMode(),this.device&&this._isMultiCanvasMode()&&this._syncCanvasTargets(),this._setCanvasSize(this.props);let t=Object.create(this.props);if(Object.assign(t,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState(),eventManagers:this.eventManagers}),e.device&&e.device.id!==this.device?.id){let i=e.device.getDefaultCanvasContext();this.animationLoop?.stop(),!this._isMultiCanvasMode()&&this.canvas!==i.canvas&&(this.canvas?.remove(),this.eventManager?.destroy(),this.canvas=null),this._setDeviceCanvasContext(e.device),ae.log(`recreating animation loop for new device! id=${e.device.id}`)(),this.animationLoop=this._createAnimationLoop(e.device,e),this.animationLoop.start()}if(this.animationLoop?.setProps(t),e.useDevicePixels!==void 0&&this._canvasContext?.setProps){this._canvasContext.setProps({useDevicePixels:e.useDevicePixels});for(let i of Object.values(this._canvasManager.targets))i.presentationContext.setProps({useDevicePixels:e.useDevicePixels})}this.layerManager&&(this.viewManager.setProps(t),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(t),this.effectManager.setProps(t),this.deckRenderer.setProps(t),this.deckPicker.setProps(t),this.widgetManager.setProps(t)),this.stats.get("setProps Time").timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);let i=this.viewManager.needsRedraw(e),r=this.layerManager.needsRedraw(e),s=this.effectManager.needsRedraw(e),o=this.deckRenderer.needsRedraw(e);return t=t||i||r||s||o,t}redraw(e){if(!this.layerManager)return;let t=this.needsRedraw({clearRedrawFlags:!0});t=e||t,t&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(t):this._drawLayers(t))}get isInitialized(){return this.viewManager!==null}getViews(){return ge(this.viewManager),this.viewManager.views}getView(e){return ge(this.viewManager),this.viewManager.getView(e)}getViewports(e){return ge(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}getCanvasContext(e){let t=e?this.viewManager?.getView(e)?.props.canvasId:void 0;return this._getCanvasContext(t)}getEventManager(e){if(!e||!this.viewManager)return this.eventManager;let t=this.viewManager.getCanvasId(e)||er;return this.eventManagers[t]||this.eventManager}async pickObjectAsync(e){let t=(await this._pickAsync("pickObjectAsync","pickObject Time",e)).result;return t.length?t[0]:null}async pickObjectsAsync(e){return await this._pickAsync("pickObjectsAsync","pickObjects Time",e)}pickObject(e){let t=this._pick("pickObject","pickObject Time",e).result;return t.length?t[0]:null}pickMultipleObjects(e){return e.depth=e.depth||10,this._pick("pickObject","pickMultipleObjects Time",e).result}pickObjects(e){return this._pick("pickObjects","pickObjects Time",e)}_pickPositionForController(e,t,i){return this._getInternalPickingMode()!=="sync"?null:this.pickObject({x:e,y:t,radius:0,unproject3D:!0,canvasId:i?this.viewManager?.getCanvasId(i):void 0})}_addResources(e,t=!1){for(let i in e)this.layerManager.resourceManager.add({resourceId:i,data:e[i],forceUpdate:t})}_removeResources(e){for(let t of e)this.layerManager.resourceManager.remove(t)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_addDefaultShaderModule(e){this.layerManager.addDefaultShaderModule(e)}_removeDefaultShaderModule(e){this.layerManager?.removeDefaultShaderModule(e)}_resolveInternalPickingMode(){let{pickAsync:e}=this.props,t=this.device?.type||this.props.deviceProps?.type;if(e==="auto")return t==="webgpu"?"async":"sync";if(e==="sync"&&t==="webgpu")throw new Error('`pickAsync: "sync"` is not supported when Deck is using a WebGPU device.');return e}_getInternalPickingMode(){try{return this._resolveInternalPickingMode()}catch(e){return this.props.onError?.(e),null}}_validateInternalPickingMode(){this._getInternalPickingMode()}_getFirstPickedInfo({result:e,emptyInfo:t}){return e[0]||t}_shouldUnproject3D(e=this.layerManager?.getLayers()||[]){return e.some(t=>t.props.pickable==="3d")}_getPointPickOptions(e,t,i={},r=this.layerManager?.getLayers()||[]){return{x:e,y:t,canvasId:i.canvasId,radius:this.props.pickingRadius,unproject3D:this._shouldUnproject3D(r),...i}}_pickPointSync(e){return this._pick("pickObject","pickObject Time",e)}_pickPointAsync(e){return this._pickAsync("pickObjectAsync","pickObject Time",e)}_getLastPointerDownPickingInfo(e,t,i,r=this.layerManager?.getLayers()||[]){return this.deckPicker.getLastPickedObject({x:e,y:t,layers:r,viewports:this.getViewports({x:e,y:t,canvasId:i})},this._lastPointerDownInfo)}_applyHoverCallbacks({result:e,emptyInfo:t},i){if(!this.widgetManager)return;this.cursorState.isHovering=e.length>0;let r=t,s=!1;for(let o of e)r=o,s=o.layer?.onHover(o,i)||s;s||(this.props.onHover?.(r,i),this.widgetManager.onHover(r,i))}_dispatchPickingEvent(e,t){if(!this.layerManager||!this.widgetManager)return;let i=ao[t.type];if(!i)return;let{layer:r}=e,s=r&&(r[i]||r.props[i]),o=this.props[i],a=!1;s&&(a=s.call(r,e,t)),a||(o?.(e,t),this.widgetManager.onEvent(e,t))}_pickAsync(e,t,i){ge(this.deckPicker);let{stats:r}=this,s=this._isMultiCanvasMode()?i.canvasId||this._getDefaultCanvasId():i.canvasId,o=this._getCanvasContext(s)||void 0;r.get("Pick Count").incrementCount(),r.get(t).timeStart(),this._resizeForCanvasTarget(s);let a=this.deckPicker[e]({layers:this.layerManager.getLayers(i),views:this.viewManager.getViews(),viewports:this.getViewports({...i,canvasId:s}),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...i,canvasId:s,canvasContext:o});return r.get(t).timeEnd(),a}_pick(e,t,i){ge(this.deckPicker);let{stats:r}=this,s=this._isMultiCanvasMode()?i.canvasId||this._getDefaultCanvasId():i.canvasId,o=this._getCanvasContext(s)||void 0;r.get("Pick Count").incrementCount(),r.get(t).timeStart(),this._resizeForCanvasTarget(s);let a=this.deckPicker[e]({layers:this.layerManager.getLayers(i),views:this.viewManager.getViews(),viewports:this.getViewports({...i,canvasId:s}),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...i,canvasId:s,canvasContext:o});return r.get(t).timeEnd(),a}_createCanvas(e){let t=e.canvas;return typeof t=="string"&&(t=document.getElementById(t),ge(t)),t?this._ownedCanvas=null:(t=document.createElement("canvas"),t.id=e.id||"deckgl-overlay",e.width&&typeof e.width=="number"&&(t.width=e.width),e.height&&typeof e.height=="number"&&(t.height=e.height),(e.parent||document.body).appendChild(t),this._ownedCanvas=t),Object.assign(t.style,e.style),t}_isMultiCanvasMode(){return Array.isArray(this.props._canvases)}_getDefaultCanvasId(){return this._canvasManager.order[0]||er}_validateCanvasConfiguration(e){Array.isArray(e._canvases)&&(ge(!e.canvas),ge(!e.gl),ge(!e.device?.canvasContext||e.device.getDefaultCanvasContext().offscreenCanvas))}_createEventManager(e){let t=new sc(e,{touchAction:this.props.touchAction,recognizers:Object.keys(g_).map(i=>{let[r,s,o,a]=g_[i],c=this.props.eventRecognizerOptions?.[i],l={...s,...c,event:i};return{recognizer:new r(l),recognizeWith:o,requireFailure:a}}),events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(let i in ao)i==="dblclick"?t.watch(i,this._onEvent):t.on(i,this._onEvent);return t}_getEventRoot(e){return e.closest(".deck-events-root")||this.props.parent?.querySelector(".deck-events-root")||e}_syncCanvasTargets(){if(!this.device||!this._isMultiCanvasMode())return;this._canvasManager.syncCanvasEntries({device:this.device,canvases:this.props._canvases||[],useDevicePixels:this.props.useDevicePixels}),this.eventManagers=this._canvasManager.eventManagers;let e=this._getDefaultCanvasId();this.eventManager=this.eventManagers[e]||null,this.canvas=this._canvasManager.targets[e]?.canvas||null}_setCanvasContext(e){this._canvasContext=e,"style"in e.canvas&&(this.canvas=e.canvas)}_setDeviceCanvasContext(e,t={}){let i=e.getDefaultCanvasContext();this._setCanvasContext(i),this._setDeviceResizeHandler(e,t)}_setDeviceResizeHandler(e,t={}){let i=!!t.syncDrawingBuffer;if(this._deviceResizeHandler?.device===e){this._deviceResizeHandler.syncDrawingBuffer=i;return}this._restoreDeviceResizeHandler();let r=s=>{this._isMultiCanvasMode()?this._updateMultiCanvasDimensions():s===this._canvasContext&&this._canvasContext&&this._onCanvasContextResize(this._canvasContext,{syncDrawingBuffer:this._deviceResizeHandler?.syncDrawingBuffer})};e.props.onResize=r,this._deviceResizeHandler={device:e,onResize:r,syncDrawingBuffer:i}}_restoreDeviceResizeHandler(){let e=this._deviceResizeHandler;e&&e.device.props?.onResize===e.onResize&&(e.device.props.onResize=Ci),this._deviceResizeHandler=null}_setCanvasSize(e){if(this._isMultiCanvasMode()||!this.canvas)return;let{width:t,height:i}=e;if(t||t===0){let r=Number.isFinite(t)?`${t}px`:t;this.canvas.style.width=r}if(i||i===0){let r=Number.isFinite(i)?`${i}px`:i;this.canvas.style.position=e.style?.position||"absolute",this.canvas.style.height=r}}_getCanvasIdFromEvent(e){return this._canvasManager.getCanvasIdFromEvent(e?.rootElement)}_getCanvasContext(e){return this._canvasManager.getTarget(e)?.presentationContext||this._canvasContext}_resizeForCanvasTarget(e){let t=this._canvasManager.getTarget(e);if(!t||!this.device?.canvasContext)return;let[i,r]=t.presentationContext.getDrawingBufferSize();this.device.canvasContext.setDrawingBufferSize(i,r)}_createDeviceCanvas(e){if(this._isMultiCanvasMode()){let t=globalThis.OffscreenCanvas;if(!t)throw new Error("`_canvases` requires OffscreenCanvas support.");let i=typeof e.width=="number"&&Number.isFinite(e.width)?e.width:1,r=typeof e.height=="number"&&Number.isFinite(e.height)?e.height:1;return new t(i,r)}return this._createCanvas(e)}_updateCanvasSize(e=this._canvasContext){if(this._isMultiCanvasMode()){this._updateMultiCanvasDimensions();return}let{canvas:t}=this,[i,r]=e?e.getCSSSize():[t?.clientWidth??t?.width??0,t?.clientHeight??t?.height??0];(i!==this.width||r!==this.height)&&(this.width=i,this.height=r,this.viewManager?.setProps({width:i,height:r}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:i,height:r},e||void 0))}_onCanvasContextResize(e,t={}){if(t.syncDrawingBuffer){let{width:i,height:r}=e.canvas;e.setDrawingBufferSize(i,r)}this._needsRedraw="Canvas resized",this._updateCanvasSize(e)}_updateMultiCanvasDimensions(){let[e,t]=this._getCanvasContext()?.getCSSSize()||[0,0];(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.props.onResize({width:e,height:t})),this._needsRedraw="Canvas resized",this.viewManager?.setNeedsUpdate("Canvas resized"),this.viewManager?.setProps({width:this.width,height:this.height})}_createAnimationLoop(e,t){let{gl:i,onError:r}=t;return new gc({device:e,autoResizeDrawingBuffer:!i&&!Array.isArray(t._canvases),autoResizeViewport:!1,onInitialize:s=>this._setDevice(s.device),onRender:this._onRenderFrame.bind(this),onError:r})}_createDevice(e){let t=this.props.deviceProps?.createCanvasContext,i=typeof t=="object"?t:void 0,r={adapters:[],_cacheShaders:!0,_cachePipelines:!0,...e.deviceProps};r.adapters.includes(Wc)||r.adapters.push(Wc);let s={alphaMode:this.props.deviceProps?.type==="webgpu"?"premultiplied":void 0};return Vs.createDevice({_reuseDevices:!0,type:"webgl",...r,createCanvasContext:{...s,...i,canvas:this._createDeviceCanvas(e),useDevicePixels:this.props.useDevicePixels,autoResize:!0}})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let{views:e}=this.props,t=Array.isArray(e)?e:e?[e]:[new n2({id:"default-view"})];return t.length&&this.props.controller&&(t[0]=t[0].clone({controller:this.props.controller})),t}_onContextLost(){let{onError:e}=this.props;this.animationLoop&&e&&e(new Error("WebGL context is lost"))}_pickAndCallback(){let{_pickRequest:e}=this;if(e.event){let t=e.event,i=this.layerManager?.getLayers()||[],r=this._getPointPickOptions(e.x,e.y,{canvasId:e.canvasId,radius:e.radius,mode:e.mode},i),s=this._getInternalPickingMode(),o=++this._hoverPickSequence;if(e.event=null,e.canvasId=void 0,!s)return;if(s==="sync"){this._applyHoverCallbacks(this._pickPointSync(r),t);return}this._pickPointAsync(r).then(({result:a,emptyInfo:c})=>{o===this._hoverPickSequence&&this._applyHoverCallbacks({result:a,emptyInfo:c},t)}).catch(a=>this.props.onError?.(a))}}_updateCursor(){let e=this.props.getCursor(this.cursorState);if(this._isMultiCanvasMode()){for(let i of Object.values(this._canvasManager.targets))i.canvas.style.cursor=e;return}let t=this.props.parent||this.canvas;t&&(t.style.cursor=e)}_setDevice(e){if(this.device=e,this._validateInternalPickingMode(),!this.animationLoop)return;this._setDeviceCanvasContext(e,{syncDrawingBuffer:!!(this.props.gl&&this.props.device!==e)}),this._isMultiCanvasMode()?this._syncCanvasTargets():this.canvas&&!this.canvas.isConnected&&this.props.parent&&this.props.parent.insertBefore(this.canvas,this.props.parent.firstChild),this.device.type==="webgl"&&this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),this.device.type==="webgl"&&this.props.onWebGLInitialized(this.device.gl);let t=new Qr;if(t.play(),this.animationLoop.attachTimeline(t),!this._isMultiCanvasMode()){let s=this.canvas&&this._getEventRoot(this.canvas);ge(s),this.eventManager=this._createEventManager(s),this.eventManagers={[er]:this.eventManager}}this.viewManager=new Ec({timeline:t,eventManager:this.eventManager,eventManagers:this.eventManagers,getCanvasContext:this._isMultiCanvasMode()?this.getCanvasContext.bind(this):void 0,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),pickPosition:this._pickPositionForController.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});let i=this.viewManager.getViewports()[0];this.layerManager=new wc(this.device,{deck:this,stats:this.stats,viewport:i,timeline:t}),this.effectManager=new Lc({deck:this,device:this.device}),this.deckRenderer=new Ac(this.device,{stats:this.stats}),this.deckPicker=new kc(this.device,{stats:this.stats});let r=this.props.parent?.querySelector(".deck-widgets-root")||(this._isMultiCanvasMode()?this.props.parent||this.canvas?.parentElement:null)||this.canvas?.parentElement;this.widgetManager=new $f({deck:this,parentElement:r}),this.widgetManager.addDefault(new Rc),this.setProps({}),this._updateCanvasSize(this._canvasContext),this.props.onLoad()}_drawLayers(e,t){let{device:i,gl:r}=this.layerManager.context;this.props.onBeforeRender({device:i,gl:r});let s={target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:"screen",effects:this.effectManager.getEffects(),...t};if(this._isMultiCanvasMode()&&s.pass==="screen"&&!s.target&&this._canvasManager.order.length)for(let o of this._canvasManager.order){let a=s.viewports.filter(u=>this.viewManager.getCanvasId(u.id)===o);if(!a.length){let u=this._canvasManager.targets[o];this._resizeForCanvasTarget(o),this.deckRenderer?.renderLayers({...s,canvasContext:u.presentationContext,target:u.presentationContext.getCurrentFramebuffer(),viewports:[],clearCanvas:!0}),u.presentationContext.present();continue}let c=this._canvasManager.targets[o];this._resizeForCanvasTarget(o);let l=c.presentationContext.getCurrentFramebuffer();this.deckRenderer?.renderLayers({...s,canvasContext:c.presentationContext,target:l,viewports:a}),c.presentationContext.present()}else this.deckRenderer?.renderLayers(s);s.pass==="screen"&&this.widgetManager.onRedraw({viewports:s.viewports,layers:s.layers}),this.props.onAfterRender({device:i,gl:r})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60===0&&(this._getMetrics(),this.stats.reset(),ae.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCursor(),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){let t=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:t},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(e){this.cursorState.isDragging=e.isDragging||!1,this.props.onInteractionStateChange(e)}_getFrameStats(){let{stats:e}=this;e.get("frameRate").timeEnd(),e.get("frameRate").timeStart();let t=this.animationLoop.stats;e.get("GPU Time").addTime(t.get("GPU Time").lastTiming),e.get("CPU Time").addTime(t.get("CPU Time").lastTiming)}_getMetrics(){let{metrics:e,stats:t}=this;e.fps=t.get("frameRate").getHz(),e.setPropsTime=t.get("setProps Time").time,e.updateAttributesTime=t.get("Update Attributes").time,e.framesRedrawn=t.get("Redraw Count").count,e.pickTime=t.get("pickObject Time").time+t.get("pickMultipleObjects Time").time+t.get("pickObjects Time").time,e.pickCount=t.get("Pick Count").count,e.layersCount=this.layerManager?.layers.length??0,e.drawLayersCount=t.get("Layers rendered").lastSampleCount,e.pickLayersCount=t.get("Layers picked").lastSampleCount,e.updateLayersCount=t.get("Layer updates").count,e.updateAttributesCount=t.get("Attributes updated").count,e.gpuTime=t.get("GPU Time").time,e.cpuTime=t.get("CPU Time").time,e.gpuTimePerFrame=t.get("GPU Time").getAverageTime(),e.cpuTimePerFrame=t.get("CPU Time").getAverageTime();let i=Vs.stats.get("GPU Time and Memory");e.bufferMemory=i.get("Buffer Memory").count,e.textureMemory=i.get("Texture Memory").count,e.renderbufferMemory=i.get("Renderbuffer Memory").count,e.gpuMemory=i.get("GPU Memory").count}};jc.defaultProps=AP;jc.VERSION=Nx;var xy=jc;J();J();function kP(n){switch(n){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return Lr(n)}}var RP=Xe.getDataType.bind(Xe);function Hc(n,e,t){if(e.size>4)return null;let i=t==="webgpu"&&e.type==="uint8"?"unorm8":e.type,r=e.size,s=!!(t!=="webgpu"&&r===3&&i&&["uint8","sint8","unorm8","snorm8","uint16","sint16","unorm16","snorm16"].includes(i));return{attribute:n,format:r>1?`${i}x${r}${s?"-webgl":""}`:e.type,byteOffset:e.offset||0}}function nn(n){return n.stride||n.size*n.bytesPerElement}function IP(n,e){return n.type===e.type&&n.size===e.size&&nn(n)===nn(e)&&(n.offset||0)===(e.offset||0)}function wy(n,e){e.offset&&ae.removed("shaderAttribute.offset","vertexOffset, elementOffset")();let t=nn(n),i=e.vertexOffset!==void 0?e.vertexOffset:n.vertexOffset||0,r=e.elementOffset||0,s=i*t+r*n.bytesPerElement+(n.offset||0);return{...e,offset:s,stride:t}}function Vz(n,e){let t=wy(n,e);return{high:t,low:{...t,offset:t.offset+n.size*4}}}var Yc=class{constructor(e,t,i){this._buffer=null,this.device=e,this.id=t.id||"",this.size=t.size||1;let r=t.logicalType||t.type,s=r==="float64",{defaultValue:o}=t;o=Number.isFinite(o)?[o]:o||new Array(this.size).fill(0);let a;s?a="float32":!r&&t.isIndexed?a="uint32":a=r||"float32";let c=kP(r||a);this.doublePrecision=s,s&&t.fp64===!1&&(c=Float32Array),this.value=null,this.settings={...t,defaultType:c,defaultValue:o,logicalType:r,type:a,normalized:a.includes("norm"),size:this.size,bytesPerElement:c.BYTES_PER_ELEMENT},this.state={...i,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){let e=this.getAccessor();return e.vertexOffset?e.vertexOffset*nn(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}get isDoublePrecisionBuffer(){return this._shouldSplitDoublePrecisionValue(this.value)}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),gn.release(this.state.allocatedValue),this.state.allocatedValue=null}getBuffer(){return this.state.constant&&this.device.type!=="webgpu"?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,t=null){let i={};if(this.state.constant){let r=this.value;if(this.device.type==="webgpu"&&this._buffer)i[e]=this._buffer;else if(t){let s=wy(this.getAccessor(),t),o=s.offset/r.BYTES_PER_ELEMENT,a=s.size||this.size;i[e]=r.subarray(o,o+a)}else i[e]=r}else i[e]=this.getBuffer();return this.doublePrecision&&(this.isDoublePrecisionBuffer?i[`${e}64Low`]=i[e]:i[`${e}64Low`]=new Float32Array(this.size)),i}_getBufferLayout(e=this.id,t=null){let i=this.getAccessor(),r=[],s={name:this.id,byteStride:this.device.type==="webgpu"&&this.state.constant?0:nn(i)};if(this.doublePrecision){let o=Vz(i,t||{});r.push(Hc(e,{...i,...o.high},this.device.type),Hc(`${e}64Low`,{...i,...o.low},this.device.type))}else if(t){let o=wy(i,t);r.push(Hc(e,{...i,...o},this.device.type))}else r.push(Hc(e,i,this.device.type));return s.attributes=r.filter(Boolean),s}setAccessor(e){this.state.bufferAccessor=e}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let e=null;if(this.state.constant&&this.value){let t=Array.from(this.value);e=[t,t]}else{let{value:t,numInstances:i,size:r}=this,s=i*r;if(t&&s&&t.length>=s){let o=new Array(r).fill(1/0),a=new Array(r).fill(-1/0);for(let c=0;ca[l]&&(a[l]=u)}e=[o,a]}}return this.state.bounds=e,e}setData(e){let{state:t}=this,i;ArrayBuffer.isView(e)?i={value:e}:e instanceof ie?i={buffer:e}:i=e;let r={...this.settings,...i};if(ArrayBuffer.isView(i.value)){if(!i.type)if(this.doublePrecision&&i.value instanceof Float64Array)r.type="float32";else{let o=RP(i.value);r.type=r.normalized?o.replace("int","norm"):o}r.bytesPerElement=i.value.BYTES_PER_ELEMENT,r.stride=nn(r)}if(t.bounds=null,i.constant){let s=i.value;if(s=this._normalizeValue(s,[],0),this.settings.normalized&&(s=this.normalizeConstant(s)),!(!t.constant||!this._areValuesEqual(s,this.value)))return!1;t.externalBuffer=null,t.constant=!0,this.value=ArrayBuffer.isView(s)?s:new Float32Array(s)}else if(i.buffer){let s=i.buffer;t.externalBuffer=s,t.constant=!1,this.value=i.value||null}else if(i.value){this._checkExternalBuffer(i);let s=i.value,o=s;t.externalBuffer=null,t.constant=!1,this.value=s,this._shouldSplitDoublePrecisionValue(o)&&(o=mo(o,r),s instanceof Float32Array&&(r.stride=r.size*2*Float32Array.BYTES_PER_ELEMENT));let{buffer:a}=this,c=nn(r),l=(r.vertexOffset||0)*c;if(this.settings.isIndexed){let f=this.settings.defaultType;o.constructor!==f&&(o=new f(o))}let u=o.byteLength+l+c*2;(!a||a.byteLength(t+128)/255*2-1);case"snorm16":return new Float32Array(e).map(t=>(t+32768)/65535*2-1);case"unorm8":return new Float32Array(e).map(t=>t/255);case"unorm16":return new Float32Array(e).map(t=>t/65535);default:return e}}_normalizeValue(e,t,i){let{defaultValue:r,size:s}=this.settings;if(Number.isFinite(e))return t[i]=e,t;if(!e){let o=s;for(;--o>=0;)t[i+o]=r[o];return t}switch(s){case 4:t[i+3]=Number.isFinite(e[3])?e[3]:r[3];case 3:t[i+2]=Number.isFinite(e[2])?e[2]:r[2];case 2:t[i+1]=Number.isFinite(e[1])?e[1]:r[1];case 1:t[i+0]=Number.isFinite(e[0])?e[0]:r[0];break;default:let o=s;for(;--o>=0;)t[i+o]=Number.isFinite(e[o])?e[o]:r[o]}return t}_areValuesEqual(e,t){if(!e||!t)return!1;let{size:i}=this;for(let r=0;r0&&(OP.length=n.length,i=OP):i=BP,(e>0||Number.isFinite(t))&&(i=(Array.isArray(i)?i:Array.from(i)).slice(e,t),r.index=e-1),{iterable:i,objectInfo:r}}function Sd(n){return n&&n[Symbol.asyncIterator]}function Pd(n,e){let{size:t,stride:i,offset:r,startIndices:s,nested:o}=e,a=n.BYTES_PER_ELEMENT,c=i?i/a:t,l=r?r/a:0,u=Math.floor((n.length-l)/c);return(f,{index:d,target:h})=>{if(!s){let v=d*c+l;for(let y=0;y=e[1]))return n;let t=[],i=n.length,r=0;for(let s=0;se[1]?t.push(o):e=[Math.min(o[0],e[0]),Math.max(o[1],e[1])]}return t.splice(r,0,e),t}var jz={interpolation:{duration:0,easing:n=>n},spring:{stiffness:.05,damping:.5}};function Cd(n,e){if(!n)return null;Number.isFinite(n)&&(n={type:"interpolation",duration:n});let t=n.type||"interpolation";return{...jz[t],...e,...n,type:t}}var as=class extends Yc{constructor(e,t){super(e,t,{startIndices:null,constantValue:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:qc}),this.constant=!1,this.settings.update=t.update||(t.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(e){this.state.startIndices=e}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:e=!1}={}){let t=this.state.needsRedraw;return this.state.needsRedraw=t&&!e,t}layoutChanged(){return this.state.layoutChanged}setAccessor(e){var t;(t=this.state).layoutChanged||(t.layoutChanged=!IP(e,this.getAccessor())),super.setAccessor(e)}getUpdateTriggers(){let{accessor:e}=this.settings;return[this.id].concat(typeof e!="function"&&e||[])}supportsTransition(){return!!this.settings.transition}getTransitionSetting(e){if(!e||!this.supportsTransition())return null;let{accessor:t}=this.settings,i=this.settings.transition,r=Array.isArray(t)?e[t.find(s=>e[s])]:e[t];return Cd(r,i)}setNeedsUpdate(e=this.id,t){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),t){let{startRow:i=0,endRow:r=1/0}=t;this.state.updateRanges=NP(this.state.updateRanges,[i,r])}else this.state.updateRanges=qc}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=DP}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){let{state:t,settings:i}=this;if(i.noAlloc)return!1;if(i.update){let r=this.isConstant;return super.allocate(e,t.updateRanges!==qc),t.layoutChanged||(t.layoutChanged=r&&this.device.type==="webgpu"),!0}return!1}updateBuffer({numInstances:e,data:t,props:i,context:r}){if(!this.needsUpdate())return!1;let{state:{updateRanges:s},settings:{update:o,noAlloc:a}}=this,c=!0;if(o){for(let[l,u]of s)o.call(r,this,{data:t,startRow:l,endRow:u,props:i,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLengthu?l.set(b,m):(e._normalizeValue(b,v.target,0),Y1({target:l,source:v.target,start:m,count:x}));m+=x*u}else e._normalizeValue(b,l,m),m+=u}}_validateAttributeUpdaters(){let{settings:e}=this;if(!(e.noAlloc||typeof e.update=="function"))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){let{value:e}=this,t=Math.min(4,this.size);if(e&&e.length>=t){let i=!0;switch(t){case 4:i=i&&Number.isFinite(e[3]);case 3:i=i&&Number.isFinite(e[2]);case 2:i=i&&Number.isFinite(e[1]);case 1:i=i&&Number.isFinite(e[0]);break;default:i=!1}if(!i)throw new Error(`Illegal attribute generated for ${this.id}`)}}};Mi();Ly();Mi();var Xc=class n{gpuDataEvaluators;format;length;id;_gpuVector;_ownsGPUDataEvaluators;_destroyed=!1;static fromGPUVector(e){if(e.bufferLayout)throw new Error(`GPUVectorEvaluator.fromGPUVector() does not accept interleaved vector "${e.name}"`);if(e.data.length===0)throw new Error(`GPUVectorEvaluator.fromGPUVector() requires GPUData for "${e.name}"`);return new n({id:e.name,gpuDataEvaluators:e.data.map(t=>ve.fromGPUData(t,{id:e.name})),gpuVector:e,format:e.format})}static fromGPUDataEvaluators(e,t={}){return new n({id:t.id,gpuDataEvaluators:e,format:t.format})}constructor({id:e,gpuDataEvaluators:t,gpuVector:i,format:r}){if(t.length===0)throw new Error("GPUVectorEvaluator requires at least one GPUData evaluator");rU(t),this.id=e,this.gpuDataEvaluators=t,this.format=r??t[0].format,this.length=t.reduce((s,o)=>s+o.length,0),this._gpuVector=i,this._ownsGPUDataEvaluators=!i}get evaluated(){return!!this._gpuVector}get gpuVector(){if(!this._gpuVector)throw new Error(`${this} not evaluated`);return this._gpuVector}mapGPUData(e){return n.fromGPUDataEvaluators(this.gpuDataEvaluators.map((t,i)=>e(t,i)),{id:this.id})}async evaluate(e,t={}){if(this._destroyed)throw new Error(`GPUVectorEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let i=await Promise.all(this.gpuDataEvaluators.map(a=>a.evaluate(e,t))),r=i[0],s=i.map(ZP),o=t.format??this.format??r.format;return this._gpuVector=new ri({type:"data",name:t.name??this.id??"vector",format:o,data:s,stride:r.stride,byteStride:r.byteStride,rowByteLength:r.rowByteLength,bufferLayout:r.bufferLayout}),this._gpuVector}evaluateSync(e,t={}){if(this._destroyed)throw new Error(`GPUVectorEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let i=this.gpuDataEvaluators.map(a=>a.evaluateSync(e,t)),r=i[0],s=i.map(ZP),o=t.format??this.format??r.format;return this._gpuVector=new ri({type:"data",name:t.name??this.id??"vector",format:o,data:s,stride:r.stride,byteStride:r.byteStride,rowByteLength:r.rowByteLength,bufferLayout:r.bufferLayout}),this._gpuVector}destroy(){if(this._ownsGPUDataEvaluators)for(let e of this.gpuDataEvaluators)e.destroy();this._gpuVector=void 0,this._destroyed=!0}toString(){return this.id??this.constructor.name}};function rU(n){let e=n[0];for(let t of n.slice(1))if(t.type!==e.type||t.size!==e.size||t.normalized!==e.normalized||t.format!==e.format)throw new Error("GPUVectorEvaluator requires matching GPUData evaluator layouts")}function ZP(n){let[e,...t]=n.data;if(!e||t.length>0)throw new Error(`GPUVectorEvaluator requires one GPUData chunk for "${n.name}"`);return e}Mi();J();var Ry={};mi(Ry,{arithmetic:()=>XP,dot:()=>nC,equalAll:()=>iC,extent:()=>QP,fround:()=>JP,gather:()=>eC,interleave:()=>tC,length:()=>rC,segmentedMap:()=>sC,select:()=>oC,sequence:()=>aC,swizzle:()=>cC});Bd();function ko({elementWise:n,func:e,inputs:t,output:i,outputBuffer:r}){let s=Array.isArray(t)?t:Object.values(t);for(let p of s)if(!p.value)throw new Error(`${p} does not have CPU value`);let o=i.length,a=i.size,c=new i.ValueType(o*a);for(let p=0;pDe(g,p));if(n)for(let g=0;gv[g]));else e.call(null,c.subarray(p*a,p*a+a),...m)}let l=i.ValueType.BYTES_PER_ELEMENT,u=i.offset/l,f=i.stride/l,d=a,h=c;if(u!==0||f!==d){h=new i.ValueType(u+i.byteLength/l);for(let p=0;p{for(let r of Object.values(n.namedInputs))if(!r.value)throw new Error(`${r} does not have CPU value`);let i=new e.ValueType(e.length*e.size);for(let r=0;r[o,De(a,r)]));for(let o=0;oKP(r,e,t));switch(n.op){case"add":return i[0]+i[1];case"subtract":return i[0]-i[1];case"multiply":return i[0]*i[1];case"divide":return i[0]/i[1];case"pow":return Math.pow(i[0],i[1]);case"sqrt":return Math.sqrt(i[0]);case"abs":return Math.abs(i[0]);case"sin":return Math.sin(i[0]);case"cos":return Math.cos(i[0]);case"tan":return Math.tan(i[0]);case"exp":return Math.exp(i[0]);case"log":return Math.log(i[0]);default:{let r=n.op;throw new Error(`Unsupported arithmetic op ${r}`)}}}default:{let i=n;throw new Error(`Unsupported expression node ${i.kind}`)}}}function oU(n,e){let t=Ao[n].arity;if(e!==t)throw new Error(`Arithmetic op '${n}' expects ${t} args, got ${e}`)}var QP=({inputs:n,output:e,target:t})=>{let{sourceValues:i}=n;if(!i.value)throw new Error(`${i} does not have CPU value`);let s=new e.ValueType(e.length*e.size);if(i.length===0)return{success:!1,error:new Error(`${i} is empty`)};for(let o=0;os[l]&&(s[l]=f)}}return t.write(s),{success:!0,value:s}};var JP=({inputs:n,output:e,target:t})=>ko({func:(i,r)=>{let s=i.length/2,o=new Float64Array(r.buffer);for(let a=0;a{let{ids:i,sourceValues:r}=n,s=i.value,o=r.value;if(!s)throw new Error(`${i} does not have CPU value`);if(!o)throw new Error(`${r} does not have CPU value`);let a=new e.ValueType(e.length*e.size),c=new Array(e.size).fill(0);for(let l=0;l=0&&nko({func:(i,...r)=>{let s=0;for(let o of r)i.set(o,s),s+=o.length},inputs:n,output:e,outputBuffer:t});var nC=({inputs:n,output:e,target:t})=>{let{x:i,y:r}=n,s=new e.ValueType(e.length);for(let o=0;o{let{x:i,y:r}=n,s=new e.ValueType(e.length);for(let o=0;o{let{x:i}=n,r=new e.ValueType(e.length);for(let s=0;s{let{segments:i,vertexCount:r}=n,s=i.value;if(!s)throw new Error(`${i} does not have CPU value`);cU(s,i,r);let o=new e.ValueType(e.length*e.size),a=0;for(let c=0;c0&&st)throw new Error(`segmentedMap last segment start must be <= vertexCount, got ${i} > ${t}`)}function Ay(n,e){return n.offset/n.ValueType.BYTES_PER_ELEMENT+e*(n.stride/n.ValueType.BYTES_PER_ELEMENT)}var oC=async({inputs:n,output:e,target:t})=>{let{condition:i,whenTrue:r,whenFalse:s}=n,o=new e.ValueType(e.length*e.size);for(let a=0;a{let i=new e.ValueType(e.length);for(let r=0;r{let{columns:i}=n;return ko({func:(r,s)=>{for(let o=0;o({...o,...a}));return this._modules[e]=s,s.then(o=>{this._modules[e]=o}).catch(o=>{N.error(`Failed to register ${e} backend: ${o}`)()}),s}if(i&&typeof i.then=="function"){let s=Promise.resolve(i).then(o=>({...o,...t})).then(o=>(this._modules[e]=o,o)).catch(o=>{throw N.error(`Failed to register ${e} backend: ${o}`)(),o});return this._modules[e]=s,s}let r={...i||{},...t};return this._modules[e]=r,Promise.resolve(r)}async get(e,t){let i=this._modules[e];if(!i)if(e==="webgl")i=this.add("webgl",Promise.resolve().then(()=>(FC(),NC)));else if(e==="webgpu")i=this.add("webgpu",Promise.resolve().then(()=>(Wy(),uT)));else throw new Error(`${e} backend not registered`);let s=(await i)[t];if(typeof s!="function")throw new Error(`${e} backend does not implement ${t}`);return s}getSync(e,t){let i=this._modules[e];if(!i)throw new Error(`${e} backend not registered`);if(typeof i.then=="function")throw new Error(`${e} backend is not loaded yet`);let s=i[t];if(typeof s!="function")throw new Error(`${e} backend does not implement ${t}`);return s}clear(){this._modules={}}},No=new jy;var Vd=class{inputs;dependencies;constructor(e){this.inputs=e,this.dependencies=Array.from(e instanceof Array?e:Object.values(e)).filter(t=>t instanceof ve)}async execute(e,t){return await this._resolveDependencies(e),await this._executeWithHandler(await No.get(this._getHandlerRegistry(e),this.name),t)}executeSync(e,t){this._resolveDependenciesSync(e);let i=this._executeWithHandler(No.getSync(this._getHandlerRegistry(e),this.name),t);if(JU(i))throw new Error(`${this.name} returned a Promise in executeSync()`);return i}shouldExecuteOnCPU(){return this.output.length<=1&&Array.from(this.dependencies).every(e=>!!e.value)}_getHandlerRegistry(e){return this.shouldExecuteOnCPU()?"cpu":e.type}async _resolveDependencies(e){for(let i of this.dependencies)await i.evaluate(e);if(this._getHandlerRegistry(e)==="cpu"||e.type==="null")for(let i of this.dependencies)await i.ensureCPUValue()}_resolveDependenciesSync(e){for(let i of this.dependencies)i.evaluateSync(e);if(this._getHandlerRegistry(e)==="cpu"||e.type==="null")for(let i of this.dependencies)i.ensureCPUValueSync()}_executeWithHandler(e,t){return e({device:t.device,inputs:this.inputs,output:this.output,target:t})}};function JU(n){return typeof n?.then=="function"}function fT(...n){let e=e$(n.map(t=>t.type));return e[0]!=="f"&&n.some(t=>t.normalized)&&(e="float32"),{isConstant:n.every(t=>t.isConstant),type:e,size:n.reduce((t,i)=>Math.max(t,i.size),0),length:n.reduce((t,i)=>Math.max(t,i.length),0)}}function e$(n){let e=0,t=0;for(let i of n){if(i[0]==="f")return"float32";let r=i.endsWith("8")?8:i.endsWith("6")?16:32;i[0]==="u"?e=Math.max(e,r):t=Math.max(t,r)}return e&&!t?`uint${e}`:t&&e<32?`sint${Math.max(t,e*2)}`:"float32"}Mi();var Hy=class extends Vd{name="interleave";output;constructor(e){super(e);let{isConstant:t,type:i,length:r}=fT(...e);this.output=new ve({isConstant:t,type:i,size:e.reduce((s,o)=>s+o.size,0),length:r,source:this})}toString(){return`_${this.inputs.join("_")}_`}};function Yy(...n){if(n.length===0)throw new Error("interleave() requires at least one input");return n.length===1?Id(n[0]):new Hy(n.map(Id)).output}Me();Mi();function Zy(n,e){let t=n$(e);for(let i of t)i.evaluateSync(n);return t$(t),e}function t$(n){let e=new Set(n.flatMap(r$)),t=new Set;for(let i of n)Wd(i,t);for(let i of t)i.evaluated&&!e.has(i.buffer)&&i.destroy()}function n$(n){let e=new Set;return qy(n,e,new Set),Array.from(e)}function qy(n,e,t){if(s$(n)){e.add(n);return}if(!(!n||typeof n!="object"||t.has(n))){if(t.add(n),Array.isArray(n)){for(let i of n)qy(i,e,t);return}if(i$(n))for(let i of Object.values(n))qy(i,e,t)}}function i$(n){let e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function Wd(n,e){if(n instanceof Xc){for(let i of n.gpuDataEvaluators)Wd(i,e);return}let t=n.source;if(t){if(t instanceof ve){e.has(t)||(e.add(t),Wd(t,e));return}for(let i of t.dependencies)e.has(i)||(e.add(i),Wd(i,e))}}function r$(n){return n instanceof ve?[n.buffer]:n.gpuVector.data.map(e=>e.buffer instanceof tt?e.buffer.buffer:e.buffer)}function s$(n){return n instanceof ve||n instanceof Xc}Wy();var Qc=class{constructor(e,{id:t,isTransitionAttribute:i}){this.packedBuffers={},this.device=e,this.id=t,this.isTransitionAttribute=i,this.device.type==="webgpu"&&No.add("webgpu",{interleave:Gd})}hasGroups(e){return this.device.type==="webgpu"&&Object.values(e).some(t=>!!t.settings.bufferGroup)}finalize(){for(let e of Object.values(this.packedBuffers))e.packed.destroy();this.packedBuffers={}}getBufferLayouts(e,t){let i=this._getPackedGroups(e,t,{requireValues:!1,excludeAttributes:{}});return this._getBufferLayouts(e,i,t)}getBindings(e,t,i,r){let s=this._getPackedGroups(e,i,{requireValues:!0,excludeAttributes:r}),o={},a=new Set;for(let c of s.values()){let l=!this.packedBuffers[c.id]||c.attributes.some(u=>!!t[u.id]);o[c.id]=this._getPackedBuffer(c,l);for(let u of c.attributes)a.add(u.id)}return{bufferLayouts:this._getBufferLayouts(e,s,i).filter(c=>!r[c.name]&&!e[c.name]?.settings.isIndexed),buffers:o,groupedAttributeIds:a}}_getPackedGroups(e,t,{requireValues:i,excludeAttributes:r}){let s=new Map;for(let a of Object.values(e)){let c=a.settings.bufferGroup;if(!c)continue;let l=s.get(c)||[];l.push(a),s.set(c,l)}let o=new Map;for(let[a,c]of s){let l=this._getPackedGroup(a,c,t,i,r);l&&o.set(a,l)}return o}_getPackedGroup(e,t,i,r,s){if(t.length<2)return null;let o=t.map(h=>h.getBufferLayout(i)),a=o[0].stepMode,c=Math.max(1,t[0].numInstances),l=r&&t.every(h=>h.isConstant);for(let h=0;hthis._getInterleaveInput(e,r)),i=Yy(...t);return Zy(this.device,i),i}_getInterleaveInput(e,t){let i=nn(t.getAccessor()),r=e.byteOffsets[t.id];if(Kc(`${e.id}.${t.id} rowByteLength`,i),Kc(`${e.id}.${t.id} groupByteOffset`,r),t.isConstant){let c=t.getConstantValue();if(!c)throw new Error(`Attribute group ${e.id} is missing constant value ${t.id}`);return Kc(`${e.id}.${t.id} constant byteOffset`,c.byteOffset),new ve({id:t.id,type:"uint32",size:i/4,isConstant:!0,value:new Uint32Array(c.buffer,c.byteOffset,i/Uint32Array.BYTES_PER_ELEMENT)})}let s=t.getBuffer(),o=t.byteOffset,a=t.getAccessor().stride||i;if(Kc(`${e.id}.${t.id} byteOffset`,o),Kc(`${e.id}.${t.id} stride`,a),!s)throw new Error(`Attribute group ${e.id} cannot interleave missing buffer ${t.id}`);return new ve({id:t.id,type:"uint32",size:i/4,offset:o,stride:a,length:e.rowCount,buffer:s})}};function dT(n){return Math.ceil(n/4)*4}function Kc(n,e){if(e%4!==0)throw new Error(`Attribute buffer groups require 32-bit alignment: ${n}=${e}`)}Me();vt();function Xy(n){let{source:e,target:t,start:i=0,size:r,getData:s}=n,o=n.end||t.length,a=e.length,c=o-i;if(a>c){t.set(e.subarray(0,c),i);return}if(t.set(e,i),!s)return;let l=a;for(;li(u+a,f)),l=Math.min(r.length,s.length);for(let u=1;ua}){let a=t.isDoublePrecisionBuffer?2:1,c=t.size*a,l=t.byteOffset,u=t.settings.bytesPerElement<4?l/t.settings.bytesPerElement*4:l,f=t.startIndices,d=s&&f,h=t.isConstant;if(!d&&e&&i>=r)return e;let p=t.value instanceof Float64Array?Float32Array:t.value.constructor,m=h?t.value:new p(t.getBuffer().readSyncWebGL(l,r*p.BYTES_PER_ELEMENT).buffer);if(t.settings.normalized&&!h){let b=o;o=(x,E)=>t.normalizeConstant(b(x,E))}let g=h?(b,x)=>o(m,x):(b,x)=>o(m.subarray(b+l,b+l+c),x),v=e?new Float32Array(e.readSyncWebGL(u,i*4).buffer):new Float32Array(0),y=new Float32Array(r);return hT({source:v,target:y,sourceStartIndices:s,targetStartIndices:f,size:c,getData:g}),(!e||e.byteLength0||r.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}},a$=`layout(std140) uniform springUniforms { +`;function _T(n){return n.isDoublePrecisionBuffer}function l$(n,e){let t=e.size,i=jd(t),r=Hd(t),s=e.getBufferLayout();return _T(e)?new nt(n,{vs:c$,bufferLayout:[{name:"aFrom",byteStride:8*t,attributes:[{attribute:"aFrom",format:r,byteOffset:0},{attribute:"aFrom64Low",format:r,byteOffset:4*t}]},{name:"aTo",byteStride:8*t,attributes:[{attribute:"aTo",format:r,byteOffset:0},{attribute:"aTo64Low",format:r,byteOffset:4*t}]}],modules:[i_,gT],defines:{ATTRIBUTE_TYPE:i,ATTRIBUTE_SIZE:t},moduleSettings:{},varyings:["vCurrent","vCurrent64Low"],bufferMode:35980,disableWarnings:!0}):new nt(n,{vs:a$,bufferLayout:[{name:"aFrom",format:r},{name:"aTo",format:s.attributes[0].format}],modules:[gT],defines:{ATTRIBUTE_TYPE:i},varyings:["vCurrent"],disableWarnings:!0})}Me();var el=class extends Fo{constructor({device:e,attribute:t,timeline:i}){super({device:e,attribute:t,timeline:i}),this.type="spring",this.texture=m$(e),this.framebuffer=g$(e,this.texture),this.transform=p$(e,t)}start(e,t){let i=this.currentLength,r=this.currentStartIndices;super.start(e,t);let{buffers:s,attribute:o}=this;for(let c=0;c<2;c++)s[c]=Zd({device:this.device,buffer:s[c],attribute:o,fromLength:i,toLength:this.currentLength,fromStartIndices:r,getData:e.enter});s[2]=qd({device:this.device,source:s[0],target:s[2]}),this.setBuffer(s[1]);let{model:a}=this.transform;a.setVertexCount(Math.floor(this.currentLength/o.size)),o.isConstant?a.setConstantAttributes({aTo:o.value}):a.setAttributes({aTo:o.getBuffer()})}onUpdate(){let{buffers:e,transform:t,framebuffer:i,transition:r}=this,s=this.settings;t.model.setAttributes({aPrev:e[0],aCur:e[1]}),t.transformFeedback.setBuffers({vNext:e[2]});let o={stiffness:s.stiffness,damping:s.damping};t.model.shaderInputs.setProps({spring:o}),t.run({framebuffer:i,discard:!1,parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]}),Yd(e),this.setBuffer(e[1]),this.device.readPixelsToArrayWebGL(i)[0]>0||r.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}},u$=`layout(std140) uniform springUniforms { float damping; float stiffness; } spring; -`,c$={name:"spring",vs:a$,uniformTypes:{damping:"f32",stiffness:"f32"}},l$=`#version 300 es +`,f$={name:"spring",vs:u$,uniformTypes:{damping:"f32",stiffness:"f32"}},d$=`#version 300 es #define SHADER_NAME spring-transition-vertex-shader #define EPSILON 0.00001 @@ -4175,7 +4175,7 @@ void main(void) { gl_Position = vec4(0, 0, 0, 1); gl_PointSize = 100.0; } -`,u$=`#version 300 es +`,h$=`#version 300 es #define SHADER_NAME spring-transition-is-transitioning-fragment-shader in float vIsTransitioningFlag; @@ -4187,7 +4187,7 @@ void main(void) { discard; } fragColor = vec4(1.0); -}`;function f$(n,e){let t=jd(e.size),i=Hd(e.size);return new nt(n,{vs:l$,fs:u$,bufferLayout:[{name:"aPrev",format:i},{name:"aCur",format:i},{name:"aTo",format:e.getBufferLayout().attributes[0].format}],varyings:["vNext"],modules:[c$],defines:{ATTRIBUTE_TYPE:t},parameters:{depthCompare:"always",blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}})}function d$(n){return n.createTexture({data:new Uint8Array(4),format:"rgba8unorm",width:1,height:1})}function h$(n,e){return n.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[e]})}var p$={interpolation:Jc,spring:el},tl=class{constructor(e,{id:t,timeline:i}){if(!e)throw new Error("AttributeTransitionManager is constructed without device");this.id=t,this.device=e,this.timeline=i,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(let e in this.transitions)this._removeTransition(e)}update({attributes:e,transitions:t,numInstances:i}){this.numInstances=i||1;for(let r in e){let s=e[r],o=s.getTransitionSetting(t);o&&this._updateAttribute(r,s,o)}for(let r in this.transitions){let s=e[r];(!s||!s.getTransitionSetting(t))&&this._removeTransition(r)}}hasAttribute(e){let t=this.transitions[e];return t&&t.inProgress}getAttributes(){let e={};for(let t in this.transitions){let i=this.transitions[t];i.inProgress&&(e[t]=i.attributeInTransition)}return e}run(){if(this.numInstances===0)return!1;for(let t in this.transitions)this.transitions[t].update()&&(this.needsRedraw=!0);let e=this.needsRedraw;return this.needsRedraw=!1,e}_removeTransition(e){this.transitions[e].delete(),delete this.transitions[e]}_updateAttribute(e,t,i){let r=this.transitions[e],s=!r||r.type!==i.type;if(s){r&&this._removeTransition(e);let o=p$[i.type];o?this.transitions[e]=new o({attribute:t,timeline:this.timeline,device:this.device}):(ae.error(`unsupported transition type '${i.type}'`)(),s=!1)}(s||t.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(i,this.numInstances))}};var yT="attributeManager.invalidate",m$="attributeManager.updateStart",g$="attributeManager.updateEnd",_$="attribute.updateStart",y$="attribute.allocate",b$="attribute.updateEnd",nl=class{constructor(e,{id:t="attribute-manager",stats:i,timeline:r}={}){this.mergeBoundsMemoized=jn(l1),this.id=t,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=i,this.attributeTransitionManager=new tl(e,{id:`${t}-transitions`,timeline:r}),this.attributeBufferGroups=e.type==="webgpu"?new Qc(e,{id:t,isTransitionAttribute:s=>this.attributeTransitionManager.hasAttribute(s)}):null,Object.seal(this)}finalize(){this.attributeBufferGroups?.finalize();for(let e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){let t=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,t&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:"instance"})}remove(e){for(let t of e)this.attributes[t]!==void 0&&(this.attributes[t].delete(),delete this.attributes[t])}invalidate(e,t){let i=this._invalidateTrigger(e,t);Ne(yT,this,e,i)}invalidateAll(e){for(let t in this.attributes)this.attributes[t].setNeedsUpdate(t,e);Ne(yT,this,"all")}update({data:e,numInstances:t,startIndices:i=null,transitions:r,props:s={},buffers:o={},context:a={}}){let c=!1;Ne(m$,this),this.stats&&this.stats.get("Update Attributes").timeStart();for(let l in this.attributes){let u=this.attributes[l],f=u.settings.accessor;u.startIndices=i,u.numInstances=t,s[l]&&ae.removed(`props.${l}`,`data.attributes.${l}`)(),u.setExternalBuffer(o[l])||u.setBinaryValue(typeof f=="string"?o[f]:void 0,e.startIndices)||typeof f=="string"&&!o[f]&&u.setConstantValue(a,s[f])||u.needsUpdate()&&(c=!0,this._updateAttribute({attribute:u,numInstances:t,data:e,props:s,context:a})),this.needsRedraw=this.needsRedraw||u.needsRedraw()}c&&Ne(g$,this,t),this.stats&&(this.stats.get("Update Attributes").timeEnd(),c&&this.stats.get("Attributes updated").incrementCount()),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:t,transitions:r})}updateTransition(){let{attributeTransitionManager:e}=this,t=e.run();return this.needsRedraw=this.needsRedraw||t,t}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){let t=e.map(i=>this.attributes[i]?.getBounds());return this.mergeBoundsMemoized(t)}getChangedAttributes(e={clearChangedFlags:!1}){let{attributes:t,attributeTransitionManager:i}=this,r={...i.getAttributes()};for(let s in t){let o=t[s];o.needsRedraw(e)&&!i.hasAttribute(s)&&(r[s]=o)}return r}getBufferLayouts(e){return this.hasBufferGroups()?this.attributeBufferGroups.getBufferLayouts(this.getAttributes(),e):Object.values(this.getAttributes()).map(t=>t.getBufferLayout(e))}hasBufferGroups(){return!!this.attributeBufferGroups?.hasGroups(this.attributes)}getBufferGroupBindings(e,t,i={}){return this.attributeBufferGroups?this.attributeBufferGroups.getBindings(this.getAttributes(),e,t,i):{bufferLayouts:this.getBufferLayouts(t),buffers:{},groupedAttributeIds:new Set}}_add(e,t){for(let i in e){let r=e[i],s={...r,id:i,size:r.isIndexed&&1||r.size||1,...t};this.attributes[i]=new as(this.device,s)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){let e={};for(let t in this.attributes)this.attributes[t].getUpdateTriggers().forEach(r=>{e[r]||(e[r]=[]),e[r].push(t)});this.updateTriggers=e}_invalidateTrigger(e,t){let{attributes:i,updateTriggers:r}=this,s=r[e];return s&&s.forEach(o=>{let a=i[o];a&&a.setNeedsUpdate(a.id,t)}),s}_updateAttribute(e){let{attribute:t,numInstances:i}=e;if(Ne(_$,t),t.constant){t.setConstantValue(e.context,t.value);return}t.allocate(i)&&Ne(y$,t,i),t.updateBuffer(e)&&(this.needsRedraw=!0,Ne(b$,t,i))}};J();bd();ze();var il=class extends yn{get value(){return this._value}_onUpdate(){let{time:e,settings:{fromValue:t,toValue:i,duration:r,easing:s}}=this,o=s(e/r);this._value=fn(t,i,o)}};var bT=1e-5;function vT(n,e,t,i,r){let s=e-n,a=(t-e)*r,c=-s*i;return a+c+s+e}function v$(n,e,t,i,r){if(Array.isArray(t)){let s=[];for(let o=0;o0}add(e,t,i,r){let{transitions:s}=this;if(s.has(e)){let c=s.get(e),{value:l=c.settings.fromValue}=c;t=l,this.remove(e)}if(r=Cd(r),!r)return;let o=x$[r.type];if(!o){ae.error(`unsupported transition type '${r.type}'`)();return}let a=new o(this.timeline);a.start({...r,fromValue:t,toValue:i}),s.set(e,a)}remove(e){let{transitions:t}=this;t.has(e)&&(t.get(e).cancel(),t.delete(e))}update(){let e={};for(let[t,i]of this.transitions)i.update(),e[t]=i.value,i.inProgress||this.remove(t);return e}clear(){for(let e of this.transitions.keys())this.remove(e)}};function ET(n){let e=n[Kn];for(let t in e){let i=e[t],{validate:r}=i;if(r&&!r(n[t],i))throw new Error(`Invalid prop ${t}: ${n[t]}`)}}function ST(n,e){let t=PT({newProps:n,oldProps:e,propTypes:n[Kn],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),i=E$(n,e),r=!1;return i||(r=S$(n,e)),{dataChanged:i,propsChanged:t,updateTriggersChanged:r,extensionsChanged:P$(n,e),transitionsChanged:w$(n,e)}}function w$(n,e){if(!n.transitions)return!1;let t={},i=n[Kn],r=!1;for(let s in n.transitions){let o=i[s],a=o&&o.type;(a==="number"||a==="color"||a==="array")&&Ky(n[s],e[s],o)&&(t[s]=!0,r=!0)}return r?t:!1}function PT({newProps:n,oldProps:e,ignoreProps:t={},propTypes:i={},triggerName:r="props"}){if(e===n)return!1;if(typeof n!="object"||n===null)return`${r} changed shallowly`;if(typeof e!="object"||e===null)return`${r} changed shallowly`;for(let s of Object.keys(n))if(!(s in t)){if(!(s in e))return`${r}.${s} added`;let o=Ky(n[s],e[s],i[s]);if(o)return`${r}.${s} ${o}`}for(let s of Object.keys(e))if(!(s in t)){if(!(s in n))return`${r}.${s} dropped`;if(!Object.hasOwnProperty.call(n,s)){let o=Ky(n[s],e[s],i[s]);if(o)return`${r}.${s} ${o}`}}return!1}function Ky(n,e,t){let i=t&&t.equal;return i&&!i(n,e,t)||!i&&(i=n&&e&&n.equals,i&&!i.call(n,e))?"changed deeply":!i&&e!==n?"changed shallowly":null}function E$(n,e){if(e===null)return"oldProps is null, initial diff";let t=!1,{dataComparator:i,_dataDiff:r}=n;return i?i(n.data,e.data)||(t="Data comparator detected a change"):n.data!==e.data&&(t="A new data container was supplied"),t&&r&&(t=r(n.data,e.data)||t),t}function S$(n,e){if(e===null)return{all:!0};if("all"in n.updateTriggers&&wT(n,e,"all"))return{all:!0};let t={},i=!1;for(let r in n.updateTriggers)r!=="all"&&wT(n,e,r)&&(t[r]=!0,i=!0);return i?t:!1}function P$(n,e){if(e===null)return!0;let t=e.extensions,{extensions:i}=n;if(i===t)return!1;if(!t||!i||i.length!==t.length)return!0;for(let r=0;ri.name==="project64"))){let i=t.modules.findIndex(r=>r.name==="project32");i>=0&&t.modules.splice(i,1)}if("inject"in e)if(!n.inject)t.inject=e.inject;else{let i={...n.inject};for(let r in e.inject)i[r]=(i[r]||"")+e.inject[r];t.inject=i}return t}J();var A$={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},Qy={};function TT(n,e,t,i){if(t instanceof me)return t;t.constructor&&t.constructor.name!=="Object"&&(t={data:t});let r=null;t.compressed&&(r={minFilter:"linear",mipmapFilter:t.data.length>1?"nearest":"linear"});let{width:s,height:o}=t.data,a=e.createTexture({...t,sampler:{...A$,...r,...i},mipLevels:e.getMipLevelCount(s,o)});return e.type==="webgl"?a.generateMipmapsWebGL():e.type==="webgpu"&&e.generateMipmapsWebGPU(a),Qy[a.id]=n,a}function LT(n,e){!e||!(e instanceof me)||Qy[e.id]===n&&(e.delete(),delete Qy[e.id])}var k$={boolean:{validate(n,e){return!0},equal(n,e,t){return!!n==!!e}},number:{validate(n,e){return Number.isFinite(n)&&(!("max"in e)||n<=e.max)&&(!("min"in e)||n>=e.min)}},color:{validate(n,e){return e.optional&&!n||Jy(n)&&(n.length===3||n.length===4)},equal(n,e,t){return Ee(n,e,1)}},accessor:{validate(n,e){let t=Xd(n);return t==="function"||t===Xd(e.value)},equal(n,e,t){return typeof e=="function"?!0:Ee(n,e,1)}},array:{validate(n,e){return e.optional&&!n||Jy(n)},equal(n,e,t){let{compare:i}=t,r=Number.isInteger(i)?i:i?1:0;return i?Ee(n,e,r):n===e}},object:{equal(n,e,t){if(t.ignore)return!0;let{compare:i}=t,r=Number.isInteger(i)?i:i?1:0;return i?Ee(n,e,r):n===e}},function:{validate(n,e){return e.optional&&!n||typeof n=="function"},equal(n,e,t){return!t.compare&&t.ignore!==!1||n===e}},data:{transform:(n,e,t)=>{if(!n)return n;let{dataTransform:i}=t.props;return i?i(n):typeof n.shape=="string"&&n.shape.endsWith("-table")&&Array.isArray(n.data)?n.data:n}},image:{transform:(n,e,t)=>{let i=t.context;return!i||!i.device?null:TT(t.id,i.device,n,{...e.parameters,...t.props.textureParameters})},release:(n,e,t)=>{LT(t.id,n)}}};function MT(n){let e={},t={},i={};for(let[r,s]of Object.entries(n)){let o=s?.deprecatedFor;if(o)i[r]=Array.isArray(o)?o:[o];else{let a=R$(r,s);e[r]=a,t[r]=a.value}}return{propTypes:e,defaultProps:t,deprecatedProps:i}}function R$(n,e){switch(Xd(e)){case"object":return ol(n,e);case"array":return ol(n,{type:"array",value:e,compare:!1});case"boolean":return ol(n,{type:"boolean",value:e});case"number":return ol(n,{type:"number",value:e});case"function":return ol(n,{type:"function",value:e,compare:!0});default:return{name:n,type:"unknown",value:e}}}function ol(n,e){return"type"in e?{name:n,...k$[e.type],...e}:"value"in e?{name:n,type:Xd(e.value),...e}:{name:n,type:"object",value:e}}function Jy(n){return Array.isArray(n)||ArrayBuffer.isView(n)}function Xd(n){return Jy(n)?"array":n===null?"null":typeof n}function AT(n,e){let t;for(let s=e.length-1;s>=0;s--){let o=e[s];"extensions"in o&&(t=o.extensions)}let i=eb(n.constructor,t),r=Object.create(i);r[wo]=n,r[Qn]={},r[_n]={};for(let s=0;s{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(let e in this.asyncProps){let t=this.asyncProps[e];t&&t.type&&t.type.release&&t.type.release(t.resolvedValue,t.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||$$}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){let t=this.asyncProps[e];return t&&t.resolvedValue}isAsyncPropLoading(e){if(e){let t=this.asyncProps[e];return!!(t&&t.pendingLoadCount>0&&t.pendingLoadCount!==t.resolvedLoadCount)}for(let t in this.asyncProps)if(this.isAsyncPropLoading(t))return!0;return!1}reloadAsyncProp(e,t){this._watchPromise(e,Promise.resolve(t))}setAsyncProps(e){this.component=e[wo]||this.component;let t=e[_n]||{},i=e[Qn]||e,r=e[Si]||{};for(let s in t){let o=t[s];this._createAsyncPropData(s,r[s]),this._updateAsyncProp(s,o),t[s]=this.getAsyncProp(s)}for(let s in i){let o=i[s];this._createAsyncPropData(s,r[s]),this._updateAsyncProp(s,o)}}_fetch(e,t){return null}_onResolve(e,t){}_onError(e,t){}_updateAsyncProp(e,t){if(this._didAsyncInputValueChange(e,t)){if(typeof t=="string"&&(t=this._fetch(e,t)),t instanceof Promise){this._watchPromise(e,t);return}if(Sd(t)){this._resolveAsyncIterable(e,t);return}this._setPropValue(e,t)}}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(let e in this.asyncProps)Object.defineProperty(this.oldAsyncProps,e,{enumerable:!0,value:this.oldProps[e]})}}_didAsyncInputValueChange(e,t){let i=this.asyncProps[e];return t===i.resolvedValue||t===i.lastValue?!1:(i.lastValue=t,!0)}_setPropValue(e,t){this._freezeAsyncOldProps();let i=this.asyncProps[e];i&&(t=this._postProcessValue(i,t),i.resolvedValue=t,i.pendingLoadCount++,i.resolvedLoadCount=i.pendingLoadCount)}_setAsyncPropValue(e,t,i){let r=this.asyncProps[e];r&&i>=r.resolvedLoadCount&&t!==void 0&&(this._freezeAsyncOldProps(),r.resolvedValue=t,r.resolvedLoadCount=i,this.onAsyncPropUpdated(e,t))}_watchPromise(e,t){let i=this.asyncProps[e];if(i){i.pendingLoadCount++;let r=i.pendingLoadCount;t.then(s=>{this.component&&(s=this._postProcessValue(i,s),this._setAsyncPropValue(e,s,r),this._onResolve(e,s))}).catch(s=>{this._onError(e,s)})}}async _resolveAsyncIterable(e,t){if(e!=="data"){this._setPropValue(e,t);return}let i=this.asyncProps[e];if(!i)return;i.pendingLoadCount++;let r=i.pendingLoadCount,s=[],o=0;for await(let a of t){if(!this.component)return;let{dataTransform:c}=this.component.props;c?s=c(a,s):s=s.concat(a),Object.defineProperty(s,"__diff",{enumerable:!1,value:[{startRow:o,endRow:s.length}]}),o=s.length,this._setAsyncPropValue(e,s,r)}this._onResolve(e,s)}_postProcessValue(e,t){let i=e.type;return i&&this.component&&(i.release&&i.release(e.resolvedValue,i,this.component),i.transform)?i.transform(t,i,this.component):t}_createAsyncPropData(e,t){if(!this.asyncProps[e]){let r=this.component&&this.component.props[Kn];this.asyncProps[e]={type:r&&r[e],lastValue:null,resolvedValue:t,pendingLoadCount:0,resolvedLoadCount:0}}}};var ll=class extends cl{constructor({attributeManager:e,layer:t}){super(t),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1,this.disabledPickingIndices=[]}get layer(){return this.component}_fetch(e,t){let i=this.layer,r=i?.props.fetch;return r?r(t,{propName:e,layer:i}):super._fetch(e,t)}_onResolve(e,t){let i=this.layer;if(i){let r=i.props.onDataLoad;e==="data"&&r&&r(t,{propName:e,layer:i})}}_onError(e,t){let i=this.layer;i&&i.raiseError(t,`loading ${e} of ${this.layer}`)}};var G$="layer.changeFlag",V$="layer.initialize",W$="layer.update",j$="layer.finalize",H$="layer.matched",RT=2**24-1,Y$=Object.freeze([]),q$=jn(({oldViewport:n,viewport:e})=>n.equals(e)),sn=new Uint8ClampedArray(0);function IT(n){return n.rowIndexes||n.pickingColors||n.instancePickingColors}function nb(n){return n.rowIndexes}function ib(n){return n.pickingColors||n.instancePickingColors}var Z$={data:{type:"data",value:Y$,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:n=>n&&n.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(n,{propName:e,layer:t,loaders:i,loadOptions:r,signal:s})=>{let{resourceManager:o}=t.context;r=r||t.getLoadOptions(),i=i||t.props.loaders,s&&(r={...r,core:{...r?.core,fetch:{...r?.core?.fetch,signal:s}}});let a=o.contains(n);return!a&&!r&&(o.add({resourceId:n,data:zs(n,i),persistent:!1}),a=!0),a?o.subscribe({resourceId:n,onChange:c=>t.internalState?.reloadAsyncProp(e,c),consumerId:t.id,requestId:e}):zs(n,i,r)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:"default",coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:n})=>[0,-n*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}},ul=class extends Kd{constructor(){super(...arguments),this.internalState=null,this.lifecycle=Ji.NO_STATE,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let e=this;for(;e.parent;)e=e.parent;return e}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(e){ge(this.internalState);let t=this.internalState.viewport||this.context.viewport,i=kf(e,{viewport:t,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[r,s,o]=Qi(i,t.pixelProjectionMatrix);return e.length===2?[r,s]:[r,s,o]}unproject(e){return ge(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,t){ge(this.internalState);let i=this.internalState.viewport||this.context.viewport;return d1(e,{viewport:i,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...t})}get isComposite(){return!1}get isDrawable(){return!0}setState(e){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,e),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return this.internalState?!this.internalState.isAsyncPropLoading():!1}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){let e=this.state;return e&&(e.models||e.model&&[e.model])||[]}setShaderModuleProps(...e){for(let t of this.getModels())t.shaderInputs.setProps(...e)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){let{coordinateSystem:e}=this.props;return e==="default"||e==="lnglat"||e==="cartesian"}onHover(e,t){return this.props.onHover&&this.props.onHover(e,t)||!1}onClick(e,t){return this.props.onClick&&this.props.onClick(e,t)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,t=[]){return t[0]=e+1&255,t[1]=e+1>>8&255,t[2]=e+1>>8>>8&255,t}decodePickingColor(e){ge(e instanceof Uint8Array);let[t,i,r]=e;return t+i*256+r*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:CT(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds(["positions","instancePositions"])}getShaders(e){e=us(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(let t of this.props.extensions)e=us(e,t.getShaders.call(this,t));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){let t=this.getAttributeManager(),{dataChanged:i}=e.changeFlags;if(i&&t)if(Array.isArray(i))for(let r of i)t.invalidateAll(r);else t.invalidateAll();if(t){let{props:r}=e,s=this.internalState.hasPickingBuffer,o=Number.isInteger(r.highlightedObjectIndex)||!!r.pickable||r.extensions.some(a=>a.getNeedsPickingBuffer.call(this,a));if(s!==o){this.internalState.hasPickingBuffer=o;let a=IT(t.attributes);a&&(o&&a.constant&&(a.constant=!1,t.invalidate(a.id)),!a.value&&!o&&(a.constant=!0,a.value=nb(t.attributes)?[fc]:[0,0,0]))}}}finalizeState(e){for(let i of this.getModels())i.destroy();let t=this.getAttributeManager();t&&t.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(let t of this.getModels())t.draw(e.renderPass)}getPickingInfo({info:e,mode:t,sourceLayer:i}){let{index:r}=e;return r>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[r]),e}raiseError(e,t){t&&(e=new Error(`${t}: ${e.message}`,{cause:e})),this.props.onError?.(e)||this.context?.onError?.(e,this)}getNeedsRedraw(e={clearRedrawFlags:!1}){return this._getNeedsRedraw(e)}needsUpdate(){return this.internalState?this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()):!1}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(e){if(!this.internalState)return;let t=this.internalState.viewport;this.internalState.viewport=e,(!t||!q$({oldViewport:t,viewport:e}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e="all"){let t=this.getAttributeManager();t&&(e==="all"?t.invalidateAll():t.invalidate(e))}updateAttributes(e){let t=!1;for(let i in e)e[i].layoutChanged()&&(t=!0);for(let i of this.getModels())this._setModelAttributes(i,e,t)}_updateAttributes(){let e=this.getAttributeManager();if(!e)return;let t=this.props,i=this.getNumInstances(),r=this.getStartIndices();e.update({data:t.data,numInstances:i,startIndices:r,props:t,transitions:t.transitions,buffers:t.data.attributes,context:this});let s=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(s)}_updateAttributeTransition(){let e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){let{uniformTransitions:e}=this.internalState;if(e.active){let t=e.update(),i=Object.create(this.props);for(let r in t)Object.defineProperty(i,r,{value:t[r]});return i}return this.props}calculateInstancePickingColors(e,{numInstances:t}){if(e.constant)return;let i=Math.floor(sn.length/4);this.internalState.usesPickingColorCache=!0;let r=t>0&&sn[0]===0;if(iRT&&ae.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),sn=gn.allocate(sn,t,{size:4,copy:!0,maxCount:Math.max(t,RT)});let s=Math.floor(sn.length/4),o=[0,0,0],a=r?0:i;for(let c=a;c(ae.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new sl(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(let t of this.props.extensions)t.initializeState.call(this,this.context,t);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){Ne(H$,this,this===e);let{state:t,internalState:i}=e;this!==e&&(this.internalState=i,this.state=t,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){let e=this.needsUpdate();if(Ne(W$,this,e),!e)return;this.context.stats.get("Layer updates").incrementCount();let t=this.props,i=this.context,r=this.internalState,s=i.viewport,o=this._updateUniformTransition();r.propsInTransition=o,i.viewport=r.viewport||s,this.props=o;try{let a=this._getUpdateParams(),c=this.getModels();if(i.device)this.updateState(a);else try{this.updateState(a)}catch{}for(let u of this.props.extensions)u.updateState.call(this,a,u);this.setNeedsRedraw(),this._updateAttributes();let l=this.getModels()[0]!==c[0];this._postUpdate(a,l)}finally{i.viewport=s,this.props=t,this._clearChangeFlags(),r.needsUpdate=!1,r.resetOldProps()}}_finalize(){Ne(j$,this),this.finalizeState(this.context);for(let e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,shaderModuleProps:t=null,uniforms:i={},parameters:r={}}){this._updateAttributeTransition();let s=this.props,o=this.context;this.props=this.internalState.propsInTransition||s;try{t&&this.setShaderModuleProps(t);let{getPolygonOffset:a}=this.props,c=a&&a(i)||[0,0];o.device instanceof nr&&o.device.setParametersWebGL({polygonOffset:c});let l=o.device instanceof nr?null:X$(r);if(K$(this.getModels(),e,r,l),o.device instanceof nr)o.device.withParametersWebGL(r,()=>{let u={renderPass:e,shaderModuleProps:t,uniforms:i,parameters:r,context:o};for(let f of this.props.extensions)f.draw.call(this,u,f);this.draw(u)});else{l?.renderPassParameters&&e.setParameters(l.renderPassParameters);let u={renderPass:e,shaderModuleProps:t,uniforms:i,parameters:r,context:o};for(let f of this.props.extensions)f.draw.call(this,u,f);this.draw(u)}}finally{this.props=s}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;let{changeFlags:t}=this.internalState;for(let r in e)if(e[r]){let s=!1;switch(r){case"dataChanged":let o=e[r],a=t[r];o&&Array.isArray(a)&&(t.dataChanged=Array.isArray(o)?a.concat(o):o,s=!0);default:t[r]||(t[r]=e[r],s=!0)}s&&Ne(G$,this,r,e)}let i=!!(t.dataChanged||t.updateTriggersChanged||t.propsChanged||t.extensionsChanged);t.propsOrDataChanged=i,t.somethingChanged=i||t.viewportChanged||t.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,t){let i=ST(e,t);if(i.updateTriggersChanged)for(let r in i.updateTriggersChanged)i.updateTriggersChanged[r]&&this.invalidateAttribute(r);if(i.transitionsChanged)for(let r in i.transitionsChanged)this.internalState.uniformTransitions.add(r,t[r],e[r],e.transitions?.[r]);return this.setChangeFlags(i)}validateProps(){ET(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){let t={highlightedObjectColor:e.picked?e.color:null},{highlightColor:i}=this.props;e.picked&&typeof i=="function"&&(t.highlightColor=i(e)),this.setShaderModuleProps({picking:t}),this.setNeedsRedraw()}_getAttributeManager(){let e=this.context;return new nl(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,t){let{props:i,oldProps:r}=e,s=this.state.model;s?.isInstanced&&s.setInstanceCount(this.getNumInstances());let{autoHighlight:o,highlightedObjectIndex:a,highlightColor:c}=i;if(t||r.autoHighlight!==o||r.highlightedObjectIndex!==a||r.highlightColor!==c){let l={};Array.isArray(c)&&(l.highlightColor=c),(t||r.autoHighlight!==o||a!==r.highlightedObjectIndex)&&(l.highlightedObjectColor=Number.isFinite(a)&&a>=0?this.encodePickingColor(a):null),this.setShaderModuleProps({picking:l})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(e){if(!this.internalState)return!1;let t=!1;t=t||this.internalState.needsRedraw&&this.id;let i=this.getAttributeManager(),r=i?i.getNeedsRedraw(e):!1;if(t=t||r,t)for(let s of this.props.extensions)s.onNeedsRedraw.call(this,s);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,t}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}};ul.defaultProps=Z$;ul.layerName="Layer";var ki=ul;function X$(n){let{blendConstant:e,...t}=n;return e?{pipelineParameters:t,renderPassParameters:{blendConstant:e}}:{pipelineParameters:t}}function K$(n,e,t,i){for(let r of n)r.device.type==="webgpu"?(Q$(r,e),r.setParameters({...r.parameters,...i?.pipelineParameters})):r.setParameters(t)}function Q$(n,e){let t=e.props.framebuffer||(e.framebuffer??null);if(!t)return;let i=t.colorAttachments.map(o=>o?.texture?.format??null),r=t.depthStencilAttachment?.texture?.format,s=n;(!J$(s.props.colorAttachmentFormats,i)||s.props.depthStencilAttachmentFormat!==r)&&(s.props.colorAttachmentFormats=i,s.props.depthStencilAttachmentFormat=r,s._setPipelineNeedsUpdate("attachment formats"))}function J$(n,e){if(n===e)return!0;if(!n||!e||n.length!==e.length)return!1;for(let t=0;t{let w=d.slice();w[E]+=1;let T=p.project(w)[E]-g[E];return Number.isFinite(T)?T:2**(E===0?c:l)*(E===0?1:-1)}),y=v.map((E,w)=>{let T=w===0?m.left:m.top,R=w===0?m.right:m.bottom,F=Math.abs(E);return E>=0?[T/F,R/F]:[R/F,T/F]}),b=d.slice(),x=[h.width,h.height];for(let[E,[w,T]]of y.entries()){if(x[E]<0)continue;let{minimum:R,maximum:F,midpoint:O,settledTarget:j}=nG(u,E,w,T,d[E]);if(t?.mode!=="preserve"&&f&&(!Number.isFinite(w)||!Number.isFinite(T))){b[E]=O;continue}let V=f?j:Te(d[E],R,F);b[E]=t?.mode==="preserve"?d[E]:a?tr(d[E],V,(E===0?h.width:h.height)/2/Math.abs(v[E])):V}(b[0]!==d[0]||b[1]!==d[1])&&(e.target=b)}return e}_constrainZoom({zoomX:e,zoomY:t},i){i||(i=this.getViewportProps());let{zoomAxis:r,maxZoomX:s,maxZoomY:o,maxBounds:a}=i,{minZoomX:c,minZoomY:l}=i;if(a!==null&&i.width>0&&i.height>0){let f=Eo(i.width,i.height,i.maxBoundsPadding),d=a[0],h=a[1],p=h[0]-d[0],m=h[1]-d[1];f.width>0&&Number.isFinite(p)&&p>0&&(c=Math.max(c,Math.log2(f.width/p)),c>s&&(c=s)),f.height>0&&Number.isFinite(m)&&m>0&&(l=Math.max(l,Math.log2(f.height/m)),l>o&&(l=o))}switch(r){case"X":e=Te(e,c,s);break;case"Y":t=Te(t,l,o);break;default:let f=Math.min(s-e,o-t,0);f===0&&(f=Math.max(c-e,l-t,0)),f!==0&&(e+=f,t+=f)}return{zoomX:e,zoomY:t}}},fl=class extends is{constructor(){super(...arguments),this.ControllerState=sb,this.transition={transitionDuration:300,transitionInterpolator:new Pi(["target","zoomX","zoomY"])},this.dragMode="pan"}setProps(e){Object.assign(e,rb(e)),super.setProps(e)}_onMultiPanStart(e){return this.multiTouchDrag==="pan"&&super._onMultiPanStart(e)}_onPanRotate(){return!1}};var Jd=class extends es{constructor(e={}){super(e)}getViewportType(){return BT}get ControllerType(){return fl}};Jd.displayName="OrthographicView";var ob=Jd;var dl=class{static get componentName(){return Object.prototype.hasOwnProperty.call(this,"extensionName")?this.extensionName:""}constructor(e){e&&(this.opts=e)}equals(e){return this===e?!0:this.constructor===e.constructor&&Ee(this.opts,e.opts,1)}getShaders(e){return null}getSubLayerProps(e){let{defaultProps:t}=e.constructor,i={updateTriggers:{}};for(let r in t)if(r in this.props){let s=t[r],o=this.props[r];i[r]=o,s&&s.type==="accessor"&&(i.updateTriggers[r]=this.props.updateTriggers[r],typeof o=="function"&&(i[r]=this.getSubLayerAccessor(o)))}return i}initializeState(e,t){}updateState(e,t){}onNeedsRedraw(e){}getNeedsPickingBuffer(e){return!1}draw(e,t){}finalizeState(e,t){}};dl.defaultProps={};dl.extensionName="LayerExtension";var ab=dl;J();var ar=class{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;let{attributes:t={}}=e;this.typedArrayManager=gn,this.attributes={},this._attributeDefs=t,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);let{data:t,buffers:i={},getGeometry:r,geometryBuffer:s,positionFormat:o,dataChanged:a,normalize:c=!0}=this.opts;if(this.data=t,this.getGeometry=r,this.positionSize=s&&s.size||(o==="XY"?2:3),this.buffers=i,this.normalize=c,s&&(ge(t.startIndices),this.getGeometry=this.getGeometryFromBuffer(s),c||(i.vertexPositions=s)),this.geometryBuffer=i.vertexPositions,Array.isArray(a))for(let l of a)this._rebuildGeometry(l);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:t}){this._rebuildGeometry({startRow:e,endRow:t})}getGeometryFromBuffer(e){let t=e.value||e;return ArrayBuffer.isView(t)?Pd(t,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,t){let{attributes:i,buffers:r,_attributeDefs:s,typedArrayManager:o}=this;for(let a in s)if(a in r)o.release(i[a]),i[a]=null;else{let c=s[a];c.copy=t,i[a]=o.allocate(i[a],e,c)}}_forEachGeometry(e,t,i){let{data:r,getGeometry:s}=this,{iterable:o,objectInfo:a}=Ed(r,t,i);for(let c of o){a.index++;let l=s?s(c,a):null;e(l,a.index)}}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:t,vertexStarts:i,instanceCount:r}=this,{data:s,geometryBuffer:o}=this,{startRow:a=0,endRow:c=1/0}=e||{},l={};if(e||(t=[0],i=[0]),this.normalize||!o)this._forEachGeometry((f,d)=>{let h=f&&this.normalizeGeometry(f);l[d]=h,i[d+1]=i[d]+(h?this.getGeometrySize(h):0)},a,c),r=i[i.length-1];else if(i=s.startIndices,r=i[s.length]||0,ArrayBuffer.isView(o))r=r||o.length/this.positionSize;else if(o instanceof ie){let f=this.positionSize*4;r=r||o.byteLength/f}else if(o.buffer){let f=o.stride||this.positionSize*4;r=r||o.buffer.byteLength/f}else if(o.value){let f=o.value,d=o.stride/f.BYTES_PER_ELEMENT||this.positionSize;r=r||f.length/d}this._allocate(r,!!e),this.indexStarts=t,this.vertexStarts=i,this.instanceCount=r;let u={};this._forEachGeometry((f,d)=>{let h=l[d]||f;u.vertexStart=i[d],u.indexStart=t[d];let p=dthis.attributeTransitionManager.hasAttribute(s)}):null,Object.seal(this)}finalize(){this.attributeBufferGroups?.finalize();for(let e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){let t=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,t&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:"instance"})}remove(e){for(let t of e)this.attributes[t]!==void 0&&(this.attributes[t].delete(),delete this.attributes[t])}invalidate(e,t){let i=this._invalidateTrigger(e,t);Fe(yT,this,e,i)}invalidateAll(e){for(let t in this.attributes)this.attributes[t].setNeedsUpdate(t,e);Fe(yT,this,"all")}update({data:e,numInstances:t,startIndices:i=null,transitions:r,props:s={},buffers:o={},context:a={}}){let c=!1;Fe(y$,this),this.stats&&this.stats.get("Update Attributes").timeStart();for(let l in this.attributes){let u=this.attributes[l],f=u.settings.accessor;u.startIndices=i,u.numInstances=t,s[l]&&ae.removed(`props.${l}`,`data.attributes.${l}`)(),u.setExternalBuffer(o[l])||u.setBinaryValue(typeof f=="string"?o[f]:void 0,e.startIndices)||typeof f=="string"&&!o[f]&&u.setConstantValue(a,s[f])||u.needsUpdate()&&(c=!0,this._updateAttribute({attribute:u,numInstances:t,data:e,props:s,context:a})),this.needsRedraw=this.needsRedraw||u.needsRedraw()}c&&Fe(b$,this,t),this.stats&&(this.stats.get("Update Attributes").timeEnd(),c&&this.stats.get("Attributes updated").incrementCount()),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:t,transitions:r})}updateTransition(){let{attributeTransitionManager:e}=this,t=e.run();return this.needsRedraw=this.needsRedraw||t,t}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){let t=e.map(i=>this.attributes[i]?.getBounds());return this.mergeBoundsMemoized(t)}getChangedAttributes(e={clearChangedFlags:!1}){let{attributes:t,attributeTransitionManager:i}=this,r={...i.getAttributes()};for(let s in t){let o=t[s];o.needsRedraw(e)&&!i.hasAttribute(s)&&(r[s]=o)}return r}getBufferLayouts(e){return this.hasBufferGroups()?this.attributeBufferGroups.getBufferLayouts(this.getAttributes(),e):Object.values(this.getAttributes()).map(t=>t.getBufferLayout(e))}hasBufferGroups(){return!!this.attributeBufferGroups?.hasGroups(this.attributes)}getBufferGroupBindings(e,t,i={}){return this.attributeBufferGroups?this.attributeBufferGroups.getBindings(this.getAttributes(),e,t,i):{bufferLayouts:this.getBufferLayouts(t),buffers:{},groupedAttributeIds:new Set}}_add(e,t){for(let i in e){let r=e[i],s={...r,id:i,size:r.isIndexed&&1||r.size||1,...t};this.attributes[i]=new as(this.device,s)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){let e={};for(let t in this.attributes)this.attributes[t].getUpdateTriggers().forEach(r=>{e[r]||(e[r]=[]),e[r].push(t)});this.updateTriggers=e}_invalidateTrigger(e,t){let{attributes:i,updateTriggers:r}=this,s=r[e];return s&&s.forEach(o=>{let a=i[o];a&&a.setNeedsUpdate(a.id,t)}),s}_updateAttribute(e){let{attribute:t,numInstances:i}=e;if(Fe(v$,t),t.constant){t.setConstantValue(e.context,t.value);return}t.allocate(i)&&Fe(x$,t,i),t.updateBuffer(e)&&(this.needsRedraw=!0,Fe(w$,t,i))}};J();bd();Ue();var il=class extends yn{get value(){return this._value}_onUpdate(){let{time:e,settings:{fromValue:t,toValue:i,duration:r,easing:s}}=this,o=s(e/r);this._value=fn(t,i,o)}};var bT=1e-5;function vT(n,e,t,i,r){let s=e-n,a=(t-e)*r,c=-s*i;return a+c+s+e}function E$(n,e,t,i,r){if(Array.isArray(t)){let s=[];for(let o=0;o0}add(e,t,i,r){let{transitions:s}=this;if(s.has(e)){let c=s.get(e),{value:l=c.settings.fromValue}=c;t=l,this.remove(e)}if(r=Cd(r),!r)return;let o=S$[r.type];if(!o){ae.error(`unsupported transition type '${r.type}'`)();return}let a=new o(this.timeline);a.start({...r,fromValue:t,toValue:i}),s.set(e,a)}remove(e){let{transitions:t}=this;t.has(e)&&(t.get(e).cancel(),t.delete(e))}update(){let e={};for(let[t,i]of this.transitions)i.update(),e[t]=i.value,i.inProgress||this.remove(t);return e}clear(){for(let e of this.transitions.keys())this.remove(e)}};function ET(n){let e=n[Kn];for(let t in e){let i=e[t],{validate:r}=i;if(r&&!r(n[t],i))throw new Error(`Invalid prop ${t}: ${n[t]}`)}}function ST(n,e){let t=PT({newProps:n,oldProps:e,propTypes:n[Kn],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),i=C$(n,e),r=!1;return i||(r=T$(n,e)),{dataChanged:i,propsChanged:t,updateTriggersChanged:r,extensionsChanged:L$(n,e),transitionsChanged:P$(n,e)}}function P$(n,e){if(!n.transitions)return!1;let t={},i=n[Kn],r=!1;for(let s in n.transitions){let o=i[s],a=o&&o.type;(a==="number"||a==="color"||a==="array")&&Ky(n[s],e[s],o)&&(t[s]=!0,r=!0)}return r?t:!1}function PT({newProps:n,oldProps:e,ignoreProps:t={},propTypes:i={},triggerName:r="props"}){if(e===n)return!1;if(typeof n!="object"||n===null)return`${r} changed shallowly`;if(typeof e!="object"||e===null)return`${r} changed shallowly`;for(let s of Object.keys(n))if(!(s in t)){if(!(s in e))return`${r}.${s} added`;let o=Ky(n[s],e[s],i[s]);if(o)return`${r}.${s} ${o}`}for(let s of Object.keys(e))if(!(s in t)){if(!(s in n))return`${r}.${s} dropped`;if(!Object.hasOwnProperty.call(n,s)){let o=Ky(n[s],e[s],i[s]);if(o)return`${r}.${s} ${o}`}}return!1}function Ky(n,e,t){let i=t&&t.equal;return i&&!i(n,e,t)||!i&&(i=n&&e&&n.equals,i&&!i.call(n,e))?"changed deeply":!i&&e!==n?"changed shallowly":null}function C$(n,e){if(e===null)return"oldProps is null, initial diff";let t=!1,{dataComparator:i,_dataDiff:r}=n;return i?i(n.data,e.data)||(t="Data comparator detected a change"):n.data!==e.data&&(t="A new data container was supplied"),t&&r&&(t=r(n.data,e.data)||t),t}function T$(n,e){if(e===null)return{all:!0};if("all"in n.updateTriggers&&wT(n,e,"all"))return{all:!0};let t={},i=!1;for(let r in n.updateTriggers)r!=="all"&&wT(n,e,r)&&(t[r]=!0,i=!0);return i?t:!1}function L$(n,e){if(e===null)return!0;let t=e.extensions,{extensions:i}=n;if(i===t)return!1;if(!t||!i||i.length!==t.length)return!0;for(let r=0;ri.name==="project64"))){let i=t.modules.findIndex(r=>r.name==="project32");i>=0&&t.modules.splice(i,1)}if("inject"in e)if(!n.inject)t.inject=e.inject;else{let i={...n.inject};for(let r in e.inject)i[r]=(i[r]||"")+e.inject[r];t.inject=i}return t}J();var I$={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},Qy={};function TT(n,e,t,i){if(t instanceof me)return t;t.constructor&&t.constructor.name!=="Object"&&(t={data:t});let r=null;t.compressed&&(r={minFilter:"linear",mipmapFilter:t.data.length>1?"nearest":"linear"});let{width:s,height:o}=t.data,a=e.createTexture({...t,sampler:{...I$,...r,...i},mipLevels:e.getMipLevelCount(s,o)});return e.type==="webgl"?a.generateMipmapsWebGL():e.type==="webgpu"&&e.generateMipmapsWebGPU(a),Qy[a.id]=n,a}function LT(n,e){!e||!(e instanceof me)||Qy[e.id]===n&&(e.delete(),delete Qy[e.id])}var B$={boolean:{validate(n,e){return!0},equal(n,e,t){return!!n==!!e}},number:{validate(n,e){return Number.isFinite(n)&&(!("max"in e)||n<=e.max)&&(!("min"in e)||n>=e.min)}},color:{validate(n,e){return e.optional&&!n||Jy(n)&&(n.length===3||n.length===4)},equal(n,e,t){return Ee(n,e,1)}},accessor:{validate(n,e){let t=Xd(n);return t==="function"||t===Xd(e.value)},equal(n,e,t){return typeof e=="function"?!0:Ee(n,e,1)}},array:{validate(n,e){return e.optional&&!n||Jy(n)},equal(n,e,t){let{compare:i}=t,r=Number.isInteger(i)?i:i?1:0;return i?Ee(n,e,r):n===e}},object:{equal(n,e,t){if(t.ignore)return!0;let{compare:i}=t,r=Number.isInteger(i)?i:i?1:0;return i?Ee(n,e,r):n===e}},function:{validate(n,e){return e.optional&&!n||typeof n=="function"},equal(n,e,t){return!t.compare&&t.ignore!==!1||n===e}},data:{transform:(n,e,t)=>{if(!n)return n;let{dataTransform:i}=t.props;return i?i(n):typeof n.shape=="string"&&n.shape.endsWith("-table")&&Array.isArray(n.data)?n.data:n}},image:{transform:(n,e,t)=>{let i=t.context;return!i||!i.device?null:TT(t.id,i.device,n,{...e.parameters,...t.props.textureParameters})},release:(n,e,t)=>{LT(t.id,n)}}};function MT(n){let e={},t={},i={};for(let[r,s]of Object.entries(n)){let o=s?.deprecatedFor;if(o)i[r]=Array.isArray(o)?o:[o];else{let a=O$(r,s);e[r]=a,t[r]=a.value}}return{propTypes:e,defaultProps:t,deprecatedProps:i}}function O$(n,e){switch(Xd(e)){case"object":return ol(n,e);case"array":return ol(n,{type:"array",value:e,compare:!1});case"boolean":return ol(n,{type:"boolean",value:e});case"number":return ol(n,{type:"number",value:e});case"function":return ol(n,{type:"function",value:e,compare:!0});default:return{name:n,type:"unknown",value:e}}}function ol(n,e){return"type"in e?{name:n,...B$[e.type],...e}:"value"in e?{name:n,type:Xd(e.value),...e}:{name:n,type:"object",value:e}}function Jy(n){return Array.isArray(n)||ArrayBuffer.isView(n)}function Xd(n){return Jy(n)?"array":n===null?"null":typeof n}function AT(n,e){let t;for(let s=e.length-1;s>=0;s--){let o=e[s];"extensions"in o&&(t=o.extensions)}let i=eb(n.constructor,t),r=Object.create(i);r[wo]=n,r[Qn]={},r[_n]={};for(let s=0;s{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(let e in this.asyncProps){let t=this.asyncProps[e];t&&t.type&&t.type.release&&t.type.release(t.resolvedValue,t.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||W$}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){let t=this.asyncProps[e];return t&&t.resolvedValue}isAsyncPropLoading(e){if(e){let t=this.asyncProps[e];return!!(t&&t.pendingLoadCount>0&&t.pendingLoadCount!==t.resolvedLoadCount)}for(let t in this.asyncProps)if(this.isAsyncPropLoading(t))return!0;return!1}reloadAsyncProp(e,t){this._watchPromise(e,Promise.resolve(t))}setAsyncProps(e){this.component=e[wo]||this.component;let t=e[_n]||{},i=e[Qn]||e,r=e[Si]||{};for(let s in t){let o=t[s];this._createAsyncPropData(s,r[s]),this._updateAsyncProp(s,o),t[s]=this.getAsyncProp(s)}for(let s in i){let o=i[s];this._createAsyncPropData(s,r[s]),this._updateAsyncProp(s,o)}}_fetch(e,t){return null}_onResolve(e,t){}_onError(e,t){}_updateAsyncProp(e,t){if(this._didAsyncInputValueChange(e,t)){if(typeof t=="string"&&(t=this._fetch(e,t)),t instanceof Promise){this._watchPromise(e,t);return}if(Sd(t)){this._resolveAsyncIterable(e,t);return}this._setPropValue(e,t)}}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(let e in this.asyncProps)Object.defineProperty(this.oldAsyncProps,e,{enumerable:!0,value:this.oldProps[e]})}}_didAsyncInputValueChange(e,t){let i=this.asyncProps[e];return t===i.resolvedValue||t===i.lastValue?!1:(i.lastValue=t,!0)}_setPropValue(e,t){this._freezeAsyncOldProps();let i=this.asyncProps[e];i&&(t=this._postProcessValue(i,t),i.resolvedValue=t,i.pendingLoadCount++,i.resolvedLoadCount=i.pendingLoadCount)}_setAsyncPropValue(e,t,i){let r=this.asyncProps[e];r&&i>=r.resolvedLoadCount&&t!==void 0&&(this._freezeAsyncOldProps(),r.resolvedValue=t,r.resolvedLoadCount=i,this.onAsyncPropUpdated(e,t))}_watchPromise(e,t){let i=this.asyncProps[e];if(i){i.pendingLoadCount++;let r=i.pendingLoadCount;t.then(s=>{this.component&&(s=this._postProcessValue(i,s),this._setAsyncPropValue(e,s,r),this._onResolve(e,s))}).catch(s=>{this._onError(e,s)})}}async _resolveAsyncIterable(e,t){if(e!=="data"){this._setPropValue(e,t);return}let i=this.asyncProps[e];if(!i)return;i.pendingLoadCount++;let r=i.pendingLoadCount,s=[],o=0;for await(let a of t){if(!this.component)return;let{dataTransform:c}=this.component.props;c?s=c(a,s):s=s.concat(a),Object.defineProperty(s,"__diff",{enumerable:!1,value:[{startRow:o,endRow:s.length}]}),o=s.length,this._setAsyncPropValue(e,s,r)}this._onResolve(e,s)}_postProcessValue(e,t){let i=e.type;return i&&this.component&&(i.release&&i.release(e.resolvedValue,i,this.component),i.transform)?i.transform(t,i,this.component):t}_createAsyncPropData(e,t){if(!this.asyncProps[e]){let r=this.component&&this.component.props[Kn];this.asyncProps[e]={type:r&&r[e],lastValue:null,resolvedValue:t,pendingLoadCount:0,resolvedLoadCount:0}}}};var ll=class extends cl{constructor({attributeManager:e,layer:t}){super(t),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1,this.disabledPickingIndices=[]}get layer(){return this.component}_fetch(e,t){let i=this.layer,r=i?.props.fetch;return r?r(t,{propName:e,layer:i}):super._fetch(e,t)}_onResolve(e,t){let i=this.layer;if(i){let r=i.props.onDataLoad;e==="data"&&r&&r(t,{propName:e,layer:i})}}_onError(e,t){let i=this.layer;i&&i.raiseError(t,`loading ${e} of ${this.layer}`)}};var j$="layer.changeFlag",H$="layer.initialize",Y$="layer.update",q$="layer.finalize",Z$="layer.matched",RT=2**24-1,X$=Object.freeze([]),K$=jn(({oldViewport:n,viewport:e})=>n.equals(e)),rn=new Uint8ClampedArray(0);function IT(n){return n.rowIndexes||n.pickingColors||n.instancePickingColors}function nb(n){return n.rowIndexes}function ib(n){return n.pickingColors||n.instancePickingColors}var Q$={data:{type:"data",value:X$,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:n=>n&&n.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(n,{propName:e,layer:t,loaders:i,loadOptions:r,signal:s})=>{let{resourceManager:o}=t.context;r=r||t.getLoadOptions(),i=i||t.props.loaders,s&&(r={...r,core:{...r?.core,fetch:{...r?.core?.fetch,signal:s}}});let a=o.contains(n);return!a&&!r&&(o.add({resourceId:n,data:zs(n,i),persistent:!1}),a=!0),a?o.subscribe({resourceId:n,onChange:c=>t.internalState?.reloadAsyncProp(e,c),consumerId:t.id,requestId:e}):zs(n,i,r)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:"default",coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:n})=>[0,-n*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}},ul=class extends Kd{constructor(){super(...arguments),this.internalState=null,this.lifecycle=Ji.NO_STATE,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let e=this;for(;e.parent;)e=e.parent;return e}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(e){ge(this.internalState);let t=this.internalState.viewport||this.context.viewport,i=kf(e,{viewport:t,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[r,s,o]=Qi(i,t.pixelProjectionMatrix);return e.length===2?[r,s]:[r,s,o]}unproject(e){return ge(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,t){ge(this.internalState);let i=this.internalState.viewport||this.context.viewport;return d1(e,{viewport:i,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...t})}get isComposite(){return!1}get isDrawable(){return!0}setState(e){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,e),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return this.internalState?!this.internalState.isAsyncPropLoading():!1}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){let e=this.state;return e&&(e.models||e.model&&[e.model])||[]}setShaderModuleProps(...e){for(let t of this.getModels())t.shaderInputs.setProps(...e)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){let{coordinateSystem:e}=this.props;return e==="default"||e==="lnglat"||e==="cartesian"}onHover(e,t){return this.props.onHover&&this.props.onHover(e,t)||!1}onClick(e,t){return this.props.onClick&&this.props.onClick(e,t)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,t=[]){return t[0]=e+1&255,t[1]=e+1>>8&255,t[2]=e+1>>8>>8&255,t}decodePickingColor(e){ge(e instanceof Uint8Array);let[t,i,r]=e;return t+i*256+r*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:CT(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds(["positions","instancePositions"])}getShaders(e){e=us(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(let t of this.props.extensions)e=us(e,t.getShaders.call(this,t));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){let t=this.getAttributeManager(),{dataChanged:i}=e.changeFlags;if(i&&t)if(Array.isArray(i))for(let r of i)t.invalidateAll(r);else t.invalidateAll();if(t){let{props:r}=e,s=this.internalState.hasPickingBuffer,o=Number.isInteger(r.highlightedObjectIndex)||!!r.pickable||r.extensions.some(a=>a.getNeedsPickingBuffer.call(this,a));if(s!==o){this.internalState.hasPickingBuffer=o;let a=IT(t.attributes);a&&(o&&a.constant&&(a.constant=!1,t.invalidate(a.id)),!a.value&&!o&&(a.constant=!0,a.value=nb(t.attributes)?[fc]:[0,0,0]))}}}finalizeState(e){for(let i of this.getModels())i.destroy();let t=this.getAttributeManager();t&&t.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(let t of this.getModels())t.draw(e.renderPass)}getPickingInfo({info:e,mode:t,sourceLayer:i}){let{index:r}=e;return r>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[r]),e}raiseError(e,t){t&&(e=new Error(`${t}: ${e.message}`,{cause:e})),this.props.onError?.(e)||this.context?.onError?.(e,this)}getNeedsRedraw(e={clearRedrawFlags:!1}){return this._getNeedsRedraw(e)}needsUpdate(){return this.internalState?this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()):!1}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(e){if(!this.internalState)return;let t=this.internalState.viewport;this.internalState.viewport=e,(!t||!K$({oldViewport:t,viewport:e}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e="all"){let t=this.getAttributeManager();t&&(e==="all"?t.invalidateAll():t.invalidate(e))}updateAttributes(e){let t=!1;for(let i in e)e[i].layoutChanged()&&(t=!0);for(let i of this.getModels())this._setModelAttributes(i,e,t)}_updateAttributes(){let e=this.getAttributeManager();if(!e)return;let t=this.props,i=this.getNumInstances(),r=this.getStartIndices();e.update({data:t.data,numInstances:i,startIndices:r,props:t,transitions:t.transitions,buffers:t.data.attributes,context:this});let s=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(s)}_updateAttributeTransition(){let e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){let{uniformTransitions:e}=this.internalState;if(e.active){let t=e.update(),i=Object.create(this.props);for(let r in t)Object.defineProperty(i,r,{value:t[r]});return i}return this.props}calculateInstancePickingColors(e,{numInstances:t}){if(e.constant)return;let i=Math.floor(rn.length/4);this.internalState.usesPickingColorCache=!0;let r=t>0&&rn[0]===0;if(iRT&&ae.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),rn=gn.allocate(rn,t,{size:4,copy:!0,maxCount:Math.max(t,RT)});let s=Math.floor(rn.length/4),o=[0,0,0],a=r?0:i;for(let c=a;c(ae.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new sl(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(let t of this.props.extensions)t.initializeState.call(this,this.context,t);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){Fe(Z$,this,this===e);let{state:t,internalState:i}=e;this!==e&&(this.internalState=i,this.state=t,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){let e=this.needsUpdate();if(Fe(Y$,this,e),!e)return;this.context.stats.get("Layer updates").incrementCount();let t=this.props,i=this.context,r=this.internalState,s=i.viewport,o=this._updateUniformTransition();r.propsInTransition=o,i.viewport=r.viewport||s,this.props=o;try{let a=this._getUpdateParams(),c=this.getModels();if(i.device)this.updateState(a);else try{this.updateState(a)}catch{}for(let u of this.props.extensions)u.updateState.call(this,a,u);this.setNeedsRedraw(),this._updateAttributes();let l=this.getModels()[0]!==c[0];this._postUpdate(a,l)}finally{i.viewport=s,this.props=t,this._clearChangeFlags(),r.needsUpdate=!1,r.resetOldProps()}}_finalize(){Fe(q$,this),this.finalizeState(this.context);for(let e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,shaderModuleProps:t=null,uniforms:i={},parameters:r={}}){this._updateAttributeTransition();let s=this.props,o=this.context;this.props=this.internalState.propsInTransition||s;try{t&&this.setShaderModuleProps(t);let{getPolygonOffset:a}=this.props,c=a&&a(i)||[0,0];o.device instanceof nr&&o.device.setParametersWebGL({polygonOffset:c});let l=o.device instanceof nr?null:J$(r);if(eG(this.getModels(),e,r,l),o.device instanceof nr)o.device.withParametersWebGL(r,()=>{let u={renderPass:e,shaderModuleProps:t,uniforms:i,parameters:r,context:o};for(let f of this.props.extensions)f.draw.call(this,u,f);this.draw(u)});else{l?.renderPassParameters&&e.setParameters(l.renderPassParameters);let u={renderPass:e,shaderModuleProps:t,uniforms:i,parameters:r,context:o};for(let f of this.props.extensions)f.draw.call(this,u,f);this.draw(u)}}finally{this.props=s}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;let{changeFlags:t}=this.internalState;for(let r in e)if(e[r]){let s=!1;switch(r){case"dataChanged":let o=e[r],a=t[r];o&&Array.isArray(a)&&(t.dataChanged=Array.isArray(o)?a.concat(o):o,s=!0);default:t[r]||(t[r]=e[r],s=!0)}s&&Fe(j$,this,r,e)}let i=!!(t.dataChanged||t.updateTriggersChanged||t.propsChanged||t.extensionsChanged);t.propsOrDataChanged=i,t.somethingChanged=i||t.viewportChanged||t.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,t){let i=ST(e,t);if(i.updateTriggersChanged)for(let r in i.updateTriggersChanged)i.updateTriggersChanged[r]&&this.invalidateAttribute(r);if(i.transitionsChanged)for(let r in i.transitionsChanged)this.internalState.uniformTransitions.add(r,t[r],e[r],e.transitions?.[r]);return this.setChangeFlags(i)}validateProps(){ET(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){let t={highlightedObjectColor:e.picked?e.color:null},{highlightColor:i}=this.props;e.picked&&typeof i=="function"&&(t.highlightColor=i(e)),this.setShaderModuleProps({picking:t}),this.setNeedsRedraw()}_getAttributeManager(){let e=this.context;return new nl(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,t){let{props:i,oldProps:r}=e,s=this.state.model;s?.isInstanced&&s.setInstanceCount(this.getNumInstances());let{autoHighlight:o,highlightedObjectIndex:a,highlightColor:c}=i;if(t||r.autoHighlight!==o||r.highlightedObjectIndex!==a||r.highlightColor!==c){let l={};Array.isArray(c)&&(l.highlightColor=c),(t||r.autoHighlight!==o||a!==r.highlightedObjectIndex)&&(l.highlightedObjectColor=Number.isFinite(a)&&a>=0?this.encodePickingColor(a):null),this.setShaderModuleProps({picking:l})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(e){if(!this.internalState)return!1;let t=!1;t=t||this.internalState.needsRedraw&&this.id;let i=this.getAttributeManager(),r=i?i.getNeedsRedraw(e):!1;if(t=t||r,t)for(let s of this.props.extensions)s.onNeedsRedraw.call(this,s);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,t}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}};ul.defaultProps=Q$;ul.layerName="Layer";var ki=ul;function J$(n){let{blendConstant:e,...t}=n;return e?{pipelineParameters:t,renderPassParameters:{blendConstant:e}}:{pipelineParameters:t}}function eG(n,e,t,i){for(let r of n)r.device.type==="webgpu"?(tG(r,e),r.setParameters({...r.parameters,...i?.pipelineParameters})):r.setParameters(t)}function tG(n,e){let t=e.props.framebuffer||(e.framebuffer??null);if(!t)return;let i=t.colorAttachments.map(o=>o?.texture?.format??null),r=t.depthStencilAttachment?.texture?.format,s=n;(!nG(s.props.colorAttachmentFormats,i)||s.props.depthStencilAttachmentFormat!==r)&&(s.props.colorAttachmentFormats=i,s.props.depthStencilAttachmentFormat=r,s._setPipelineNeedsUpdate("attachment formats"))}function nG(n,e){if(n===e)return!0;if(!n||!e||n.length!==e.length)return!1;for(let t=0;t{let w=d.slice();w[E]+=1;let T=p.project(w)[E]-g[E];return Number.isFinite(T)?T:2**(E===0?c:l)*(E===0?1:-1)}),y=v.map((E,w)=>{let T=w===0?m.left:m.top,R=w===0?m.right:m.bottom,F=Math.abs(E);return E>=0?[T/F,R/F]:[R/F,T/F]}),b=d.slice(),x=[h.width,h.height];for(let[E,[w,T]]of y.entries()){if(x[E]<0)continue;let{minimum:R,maximum:F,midpoint:O,settledTarget:j}=sG(u,E,w,T,d[E]);if(t?.mode!=="preserve"&&f&&(!Number.isFinite(w)||!Number.isFinite(T))){b[E]=O;continue}let V=f?j:Te(d[E],R,F);b[E]=t?.mode==="preserve"?d[E]:a?tr(d[E],V,(E===0?h.width:h.height)/2/Math.abs(v[E])):V}(b[0]!==d[0]||b[1]!==d[1])&&(e.target=b)}return e}_constrainZoom({zoomX:e,zoomY:t},i){i||(i=this.getViewportProps());let{zoomAxis:r,maxZoomX:s,maxZoomY:o,maxBounds:a}=i,{minZoomX:c,minZoomY:l}=i;if(a!==null&&i.width>0&&i.height>0){let f=Eo(i.width,i.height,i.maxBoundsPadding),d=a[0],h=a[1],p=h[0]-d[0],m=h[1]-d[1];f.width>0&&Number.isFinite(p)&&p>0&&(c=Math.max(c,Math.log2(f.width/p)),c>s&&(c=s)),f.height>0&&Number.isFinite(m)&&m>0&&(l=Math.max(l,Math.log2(f.height/m)),l>o&&(l=o))}switch(r){case"X":e=Te(e,c,s);break;case"Y":t=Te(t,l,o);break;default:let f=Math.min(s-e,o-t,0);f===0&&(f=Math.max(c-e,l-t,0)),f!==0&&(e+=f,t+=f)}return{zoomX:e,zoomY:t}}},fl=class extends is{constructor(){super(...arguments),this.ControllerState=sb,this.transition={transitionDuration:300,transitionInterpolator:new Pi(["target","zoomX","zoomY"])},this.dragMode="pan"}setProps(e){Object.assign(e,rb(e)),super.setProps(e)}_onMultiPanStart(e){return this.multiTouchDrag==="pan"&&super._onMultiPanStart(e)}_onPanRotate(){return!1}};var Jd=class extends es{constructor(e={}){super(e)}getViewportType(){return BT}get ControllerType(){return fl}};Jd.displayName="OrthographicView";var ob=Jd;var dl=class{static get componentName(){return Object.prototype.hasOwnProperty.call(this,"extensionName")?this.extensionName:""}constructor(e){e&&(this.opts=e)}equals(e){return this===e?!0:this.constructor===e.constructor&&Ee(this.opts,e.opts,1)}getShaders(e){return null}getSubLayerProps(e){let{defaultProps:t}=e.constructor,i={updateTriggers:{}};for(let r in t)if(r in this.props){let s=t[r],o=this.props[r];i[r]=o,s&&s.type==="accessor"&&(i.updateTriggers[r]=this.props.updateTriggers[r],typeof o=="function"&&(i[r]=this.getSubLayerAccessor(o)))}return i}initializeState(e,t){}updateState(e,t){}onNeedsRedraw(e){}getNeedsPickingBuffer(e){return!1}draw(e,t){}finalizeState(e,t){}};dl.defaultProps={};dl.extensionName="LayerExtension";var ab=dl;J();var ar=class{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;let{attributes:t={}}=e;this.typedArrayManager=gn,this.attributes={},this._attributeDefs=t,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);let{data:t,buffers:i={},getGeometry:r,geometryBuffer:s,positionFormat:o,dataChanged:a,normalize:c=!0}=this.opts;if(this.data=t,this.getGeometry=r,this.positionSize=s&&s.size||(o==="XY"?2:3),this.buffers=i,this.normalize=c,s&&(ge(t.startIndices),this.getGeometry=this.getGeometryFromBuffer(s),c||(i.vertexPositions=s)),this.geometryBuffer=i.vertexPositions,Array.isArray(a))for(let l of a)this._rebuildGeometry(l);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:t}){this._rebuildGeometry({startRow:e,endRow:t})}getGeometryFromBuffer(e){let t=e.value||e;return ArrayBuffer.isView(t)?Pd(t,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,t){let{attributes:i,buffers:r,_attributeDefs:s,typedArrayManager:o}=this;for(let a in s)if(a in r)o.release(i[a]),i[a]=null;else{let c=s[a];c.copy=t,i[a]=o.allocate(i[a],e,c)}}_forEachGeometry(e,t,i){let{data:r,getGeometry:s}=this,{iterable:o,objectInfo:a}=Ed(r,t,i);for(let c of o){a.index++;let l=s?s(c,a):null;e(l,a.index)}}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:t,vertexStarts:i,instanceCount:r}=this,{data:s,geometryBuffer:o}=this,{startRow:a=0,endRow:c=1/0}=e||{},l={};if(e||(t=[0],i=[0]),this.normalize||!o)this._forEachGeometry((f,d)=>{let h=f&&this.normalizeGeometry(f);l[d]=h,i[d+1]=i[d]+(h?this.getGeometrySize(h):0)},a,c),r=i[i.length-1];else if(i=s.startIndices,r=i[s.length]||0,ArrayBuffer.isView(o))r=r||o.length/this.positionSize;else if(o instanceof ie){let f=this.positionSize*4;r=r||o.byteLength/f}else if(o.buffer){let f=o.stride||this.positionSize*4;r=r||o.buffer.byteLength/f}else if(o.value){let f=o.value,d=o.stride/f.BYTES_PER_ELEMENT||this.positionSize;r=r||f.length/d}this._allocate(r,!!e),this.indexStarts=t,this.vertexStarts=i,this.instanceCount=r;let u={};this._forEachGeometry((f,d)=>{let h=l[d]||f;u.vertexStart=i[d],u.indexStart=t[d];let p=d 1.0) { discard; } #endif -`}};var iG={getDashArray:{type:"accessor",value:[0,0]},getOffset:{type:"accessor",value:0},dashJustified:!1,dashGapPickable:!1,dashUnits:"widths"},rG={widths:0,pixels:1,meters:2,common:3},sG=["instanceDashArrays","instanceDashOffsets","instanceOffsets"];function oG({props:n,oldProps:e}){return!Ee(n.modelMatrix,e.modelMatrix,2)||n.coordinateSystem!==e.coordinateSystem||!Ee(n.coordinateOrigin,e.coordinateOrigin,1)}function UT(n,e,t){let i=n.context.viewport;if(!(i instanceof Ei)||i.zoom<12)return n.projectPosition(e,{autoOffset:!1});let r=Rt.transformMat4([],[e[0],e[1],e[2]||0,1],t.modelMatrix),s=n.props.coordinateSystem==="default"?"lnglat":n.props.coordinateSystem;if(s==="lnglat"){if(Math.abs(r[1]-t.coordinateOrigin[1])>.25){let c=r[0];t.wrapLongitude&&(c=((c+180)%360+360)%360-180);let l=i.projectPosition([c,r[1],0]);return[l[0]-t.commonOrigin[0],l[1]-t.commonOrigin[1],r[2]*t.commonUnitsPerMeter[2]]}bt.sub(r,r,t.coordinateOrigin)}else s==="cartesian"&&bt.sub(r,r,t.coordinateOrigin);let o=r[1],a=bt.scaleAndAdd([],t.commonUnitsPerWorldUnit,t.commonUnitsPerWorldUnit2,o);return bt.multiply([],r,a)}var hl=class extends ab{constructor({dash:e=!1,offset:t=!1,dashMode:i,highPrecisionDash:r=!1}={}){let s=i??(r?"path":"segment");super({dash:e||r||i!==void 0,offset:t,dashMode:s,highPrecisionDash:s==="path"})}getLayerType(e){if("pathTesselator"in e.state)return"path";let t=e.constructor.layerName;return t==="ScatterplotLayer"?"scatterplot":t==="TextBackgroundLayer"?"textBackground":null}synchronizeAttributes(e){let t=e.getAttributeManager(),i=this.getLayerType(e);if(!t||!i)return!1;let r=t.getAttributes(),s=new Set;this.opts.dash&&s.add("instanceDashArrays"),i==="path"&&this.opts.dash&&this.opts.dashMode==="path"&&s.add("instanceDashOffsets"),i==="path"&&this.opts.offset&&s.add("instanceOffsets");let o=!1;for(let a of sG)r[a]&&!s.has(a)&&(t.remove([a]),o=!0);return s.has("instanceDashArrays")&&!r.instanceDashArrays&&(t.addInstanced({instanceDashArrays:{size:2,accessor:"getDashArray"}}),o=!0),s.has("instanceDashOffsets")&&!r.instanceDashOffsets&&(t.addInstanced({instanceDashOffsets:{size:2,accessor:["getPath"],update:this.calculateDashMetrics}}),o=!0),s.has("instanceOffsets")&&!r.instanceOffsets&&(t.addInstanced({instanceOffsets:{size:1,accessor:"getOffset"}}),o=!0),o}isEnabled(e){return this.getLayerType(e)!==null}getShaders(e){let t=e.getLayerType(this);if(!t)return null;if(t==="scatterplot"||t==="textBackground")return e.opts.dash?{modules:[{name:"pathStyle",inject:t==="scatterplot"?NT.inject:FT.inject,uniformTypes:{dashGapPickable:"i32"}}]}:null;let i={},r={};e.opts.dash&&(i=us(i,DT),r.DASH_ENABLED=!0,e.opts.dashMode==="path"&&(r.HIGH_PRECISION_DASH=!0)),e.opts.offset&&(i=us(i,zT),r.PATH_STYLE_OFFSET=!0);let{inject:s}=i,o={name:"pathStyle",inject:s};return e.opts.dash&&(o.uniformTypes={dashAlignMode:"f32",dashGapPickable:"i32",dashUnits:"i32"}),{modules:[o],defines:r}}initializeState(e,t){t.synchronizeAttributes(this)}updateState(e,t){if(t.isEnabled(this)){if(e.changeFlags.extensionsChanged){let i=t.synchronizeAttributes(this),r=this.getAttributeManager();if(r&&i){r.invalidateAll();for(let s of this.getModels())s.setBufferLayout(r.getBufferLayouts(s))}}if(t.opts.dash){let i=t.getLayerType(this);if(i==="path"&&t.opts.dashMode==="path"&&oG(e)&&this.getAttributeManager()?.invalidate("instanceDashOffsets"),i==="scatterplot"||i==="textBackground"){let r={dashGapPickable:!!this.props.dashGapPickable};this.setShaderModuleProps({pathStyle:r})}else{let r={dashAlignMode:this.props.dashJustified?1:0,dashGapPickable:!!this.props.dashGapPickable,dashUnits:rG[this.props.dashUnits??"widths"]};this.setShaderModuleProps({pathStyle:r})}}}}calculateDashMetrics(e,{startRow:t,endRow:i}){let r=this.state.pathTesselator,s=r?.vertexStarts,o=r?.instanceCount,a=r?.get("positions");if(!s||o===void 0||typeof r?.getPathSegmentIndices!="function")throw new Error("PathStyleExtension requires PathLayer tessellation data for path dashes.");let c=this.props.data?.attributes?.getPath,l=ArrayBuffer.isView(c)?c:c?.value,u=ArrayBuffer.isView(l),f=a&&(!c||r.normalize||r.opts?.isWebGPU);if(c&&!u||!f&&!u)throw new Error("PathStyleExtension cannot calculate whole-path dash metrics from GPU-only getPath data; supply data.attributes.instanceDashOffsets.");let d=e.value,h=e.size,p=Math.max(0,t),m=Math.min(i,s.length-1),g=3,v=3,y=0;if(!f){let w=l.BYTES_PER_ELEMENT;g=c?.size||(this.props.positionFormat==="XY"?2:3),v=c?.stride?c.stride/w:g,y=c?.offset?c.offset/w:0}let b=new Array(3),x=hn.getUniforms({viewport:this.context.viewport,modelMatrix:this.props.modelMatrix,coordinateSystem:this.props.coordinateSystem,coordinateOrigin:this.props.coordinateOrigin,autoWrapLongitude:this.wrapLongitude}),E=w=>{if(f)b[0]=a[w*3],b[1]=a[w*3+1],b[2]=a[w*3+2];else{let T=y+w*v;b[0]=l[T],b[1]=l[T+1],b[2]=g===3?l[T+2]:0}return b};e.startIndices=s;for(let w=p;w1)for(let G=T;G0&&(t[c]=t[c-1]+bt.dist(a,o)),a=o;return t[s-1]=0,t}};hl.defaultProps=iG;hl.extensionName="PathStyleExtension";var cb=hl;Me();ze();var aG=new Uint32Array([0,2,1,0,3,2]),cG=new Float32Array([0,1,0,0,1,0,1,1]);function lb(n,e){if(!e)return lG(n);let t=Math.max(Math.abs(n[0][0]-n[3][0]),Math.abs(n[1][0]-n[2][0])),i=Math.max(Math.abs(n[1][1]-n[0][1]),Math.abs(n[2][1]-n[3][1])),r=Math.ceil(t/e)+1,s=Math.ceil(i/e)+1,o=(r-1)*(s-1)*6,a=new Uint32Array(o),c=new Float32Array(r*s*2),l=new Float64Array(r*s*3),u=0,f=0;for(let d=0;d0&&p>0&&(a[f++]=u-s,a[f++]=u-s-1,a[f++]=u-1,a[f++]=u-s,a[f++]=u-1,a[f++]=u),u++}}return{vertexCount:o,positions:l,indices:a,texCoords:c}}function lG(n){let e=new Float64Array(12);for(let t=0;t.25){let c=r[0];t.wrapLongitude&&(c=((c+180)%360+360)%360-180);let l=i.projectPosition([c,r[1],0]);return[l[0]-t.commonOrigin[0],l[1]-t.commonOrigin[1],r[2]*t.commonUnitsPerMeter[2]]}bt.sub(r,r,t.coordinateOrigin)}else s==="cartesian"&&bt.sub(r,r,t.coordinateOrigin);let o=r[1],a=bt.scaleAndAdd([],t.commonUnitsPerWorldUnit,t.commonUnitsPerWorldUnit2,o);return bt.multiply([],r,a)}var hl=class extends ab{constructor({dash:e=!1,offset:t=!1,dashMode:i,highPrecisionDash:r=!1}={}){let s=i??(r?"path":"segment");super({dash:e||r||i!==void 0,offset:t,dashMode:s,highPrecisionDash:s==="path"})}getLayerType(e){if("pathTesselator"in e.state)return"path";let t=e.constructor.layerName;return t==="ScatterplotLayer"?"scatterplot":t==="TextBackgroundLayer"?"textBackground":null}synchronizeAttributes(e){let t=e.getAttributeManager(),i=this.getLayerType(e);if(!t||!i)return!1;let r=t.getAttributes(),s=new Set;this.opts.dash&&s.add("instanceDashArrays"),i==="path"&&this.opts.dash&&this.opts.dashMode==="path"&&s.add("instanceDashOffsets"),i==="path"&&this.opts.offset&&s.add("instanceOffsets");let o=!1;for(let a of cG)r[a]&&!s.has(a)&&(t.remove([a]),o=!0);return s.has("instanceDashArrays")&&!r.instanceDashArrays&&(t.addInstanced({instanceDashArrays:{size:2,accessor:"getDashArray"}}),o=!0),s.has("instanceDashOffsets")&&!r.instanceDashOffsets&&(t.addInstanced({instanceDashOffsets:{size:2,accessor:["getPath"],update:this.calculateDashMetrics}}),o=!0),s.has("instanceOffsets")&&!r.instanceOffsets&&(t.addInstanced({instanceOffsets:{size:1,accessor:"getOffset"}}),o=!0),o}isEnabled(e){return this.getLayerType(e)!==null}getShaders(e){let t=e.getLayerType(this);if(!t)return null;if(t==="scatterplot"||t==="textBackground")return e.opts.dash?{modules:[{name:"pathStyle",inject:t==="scatterplot"?NT.inject:FT.inject,uniformTypes:{dashGapPickable:"i32"}}]}:null;let i={},r={};e.opts.dash&&(i=us(i,DT),r.DASH_ENABLED=!0,e.opts.dashMode==="path"&&(r.HIGH_PRECISION_DASH=!0)),e.opts.offset&&(i=us(i,zT),r.PATH_STYLE_OFFSET=!0);let{inject:s}=i,o={name:"pathStyle",inject:s};return e.opts.dash&&(o.uniformTypes={dashAlignMode:"f32",dashGapPickable:"i32",dashUnits:"i32"}),{modules:[o],defines:r}}initializeState(e,t){t.synchronizeAttributes(this)}updateState(e,t){if(t.isEnabled(this)){if(e.changeFlags.extensionsChanged){let i=t.synchronizeAttributes(this),r=this.getAttributeManager();if(r&&i){r.invalidateAll();for(let s of this.getModels())s.setBufferLayout(r.getBufferLayouts(s))}}if(t.opts.dash){let i=t.getLayerType(this);if(i==="path"&&t.opts.dashMode==="path"&&lG(e)&&this.getAttributeManager()?.invalidate("instanceDashOffsets"),i==="scatterplot"||i==="textBackground"){let r={dashGapPickable:!!this.props.dashGapPickable};this.setShaderModuleProps({pathStyle:r})}else{let r={dashAlignMode:this.props.dashJustified?1:0,dashGapPickable:!!this.props.dashGapPickable,dashUnits:aG[this.props.dashUnits??"widths"]};this.setShaderModuleProps({pathStyle:r})}}}}calculateDashMetrics(e,{startRow:t,endRow:i}){let r=this.state.pathTesselator,s=r?.vertexStarts,o=r?.instanceCount,a=r?.get("positions");if(!s||o===void 0||typeof r?.getPathSegmentIndices!="function")throw new Error("PathStyleExtension requires PathLayer tessellation data for path dashes.");let c=this.props.data?.attributes?.getPath,l=ArrayBuffer.isView(c)?c:c?.value,u=ArrayBuffer.isView(l),f=a&&(!c||r.normalize||r.opts?.isWebGPU);if(c&&!u||!f&&!u)throw new Error("PathStyleExtension cannot calculate whole-path dash metrics from GPU-only getPath data; supply data.attributes.instanceDashOffsets.");let d=e.value,h=e.size,p=Math.max(0,t),m=Math.min(i,s.length-1),g=3,v=3,y=0;if(!f){let w=l.BYTES_PER_ELEMENT;g=c?.size||(this.props.positionFormat==="XY"?2:3),v=c?.stride?c.stride/w:g,y=c?.offset?c.offset/w:0}let b=new Array(3),x=hn.getUniforms({viewport:this.context.viewport,modelMatrix:this.props.modelMatrix,coordinateSystem:this.props.coordinateSystem,coordinateOrigin:this.props.coordinateOrigin,autoWrapLongitude:this.wrapLongitude}),E=w=>{if(f)b[0]=a[w*3],b[1]=a[w*3+1],b[2]=a[w*3+2];else{let T=y+w*v;b[0]=l[T],b[1]=l[T+1],b[2]=g===3?l[T+2]:0}return b};e.startIndices=s;for(let w=p;w1)for(let G=T;G0&&(t[c]=t[c-1]+bt.dist(a,o)),a=o;return t[s-1]=0,t}};hl.defaultProps=oG;hl.extensionName="PathStyleExtension";var cb=hl;Me();Ue();var uG=new Uint32Array([0,2,1,0,3,2]),fG=new Float32Array([0,1,0,0,1,0,1,1]);function lb(n,e){if(!e)return dG(n);let t=Math.max(Math.abs(n[0][0]-n[3][0]),Math.abs(n[1][0]-n[2][0])),i=Math.max(Math.abs(n[1][1]-n[0][1]),Math.abs(n[2][1]-n[3][1])),r=Math.ceil(t/e)+1,s=Math.ceil(i/e)+1,o=(r-1)*(s-1)*6,a=new Uint32Array(o),c=new Float32Array(r*s*2),l=new Float64Array(r*s*3),u=0,f=0;for(let d=0;d0&&p>0&&(a[f++]=u-s,a[f++]=u-s-1,a[f++]=u-1,a[f++]=u-s,a[f++]=u-1,a[f++]=u),u++}}return{vertexCount:o,positions:l,indices:a,texCoords:c}}function dG(n){let e=new Float64Array(12);for(let t=0;t, coordinateConversion: f32, @@ -4553,7 +4553,7 @@ struct BitmapUniforms { vec3 tintColor; vec4 transparentColor; } bitmap; -`,GT={name:"bitmap",source:fG,vs:$T,fs:$T,uniformTypes:{bounds:"vec4",coordinateConversion:"f32",desaturate:"f32",tintColor:"vec3",transparentColor:"vec4"}};var VT=`struct Attributes { +`,GT={name:"bitmap",source:pG,vs:$T,fs:$T,uniformTypes:{bounds:"vec4",coordinateConversion:"f32",desaturate:"f32",tintColor:"vec3",transparentColor:"vec4"}};var VT=`struct Attributes { @location(0) positions: vec3, @location(1) positions64Low: vec3, @location(2) texCoords: vec2, @@ -4723,7 +4723,7 @@ void main(void) { vec4 color = vec4(0.0); DECKGL_FILTER_COLOR(color, geometry); } -`;var dG=` +`;var mG=` vec3 packUVsIntoRGB(vec2 uv) { // Extract the top 8 bits. We want values to be truncated down so we can add a fraction vec2 uv8bit = floor(uv * 256.); @@ -4806,7 +4806,7 @@ vec2 getUV(vec2 pos) { ); } -${dG} +${mG} void main(void) { vec2 uv = vTexCoord; @@ -4829,7 +4829,7 @@ void main(void) { fragColor.rgb = packUVsIntoRGB(uv); } } -`;var hG={image:{type:"image",value:null,async:!0},bounds:{type:"array",value:[1,0,0,1],compare:!0},_imageCoordinateSystem:"default",desaturate:{type:"number",min:0,max:1,value:0},transparentColor:{type:"color",value:[0,0,0,0]},tintColor:{type:"color",value:[255,255,255]},textureParameters:{type:"object",ignore:!0,value:null}},pl=class extends ki{getShaders(){return super.getShaders({vs:WT,fs:jT,source:VT,modules:[Vn,Hn,qn,GT]})}initializeState(){let e=this.getAttributeManager(),t=!0;e.add({indices:{size:1,isIndexed:!0,update:i=>i.value=this.state.mesh.indices,noAlloc:t},positions:{size:3,type:"float64",fp64:this.use64bitPositions(),update:i=>i.value=this.state.mesh.positions,noAlloc:t},texCoords:{size:2,update:i=>i.value=this.state.mesh.texCoords,noAlloc:t}})}updateState({props:e,oldProps:t,changeFlags:i}){let r=this.getAttributeManager();if(i.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),r.invalidateAll()),e.bounds!==t.bounds){let s=this.state.mesh,o=this._createMesh();this.state.model.setVertexCount(o.vertexCount);for(let a in o)s&&s[a]!==o[a]&&r.invalidate(a);this.setState({mesh:o,...this._getCoordinateUniforms()})}else e._imageCoordinateSystem!==t._imageCoordinateSystem&&this.setState(this._getCoordinateUniforms())}getPickingInfo(e){let{image:t}=this.props,i=e.info;if(!i.color||!t)return i.bitmap=null,i;let{width:r,height:s}=t;i.index=0;let o=pG(i.color);return i.bitmap={size:{width:r,height:s},uv:o,pixel:[Math.floor(o[0]*r),Math.floor(o[1]*s)]},i}disablePickingIndex(){this.setState({disablePicking:!0})}restorePickingColors(){this.setState({disablePicking:!1})}_updateAutoHighlight(e){super._updateAutoHighlight({...e,color:this.encodePickingColor(0)})}_createMesh(){let{bounds:e}=this.props,t=e;return HT(e)&&(t=[[e[0],e[1]],[e[0],e[3]],[e[2],e[3]],[e[2],e[1]]]),lb(t,this.context.viewport.resolution)}_getModel(){let e=this.context.device.type==="webgpu"?this.getAttributeManager().getBufferLayouts({isInstanced:!1}).filter(t=>t.name!=="indices"):this.getAttributeManager().getBufferLayouts();return new Ze(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:e,topology:"triangle-list",isInstanced:!1})}draw(e){let{shaderModuleProps:t}=e,{model:i,coordinateConversion:r,bounds:s,disablePicking:o}=this.state,{image:a,desaturate:c,transparentColor:l,tintColor:u}=this.props;if(!(t.picking.isActive&&o)&&a&&i){let f={bitmapTexture:a,bounds:s,coordinateConversion:r,desaturate:c,tintColor:u.slice(0,3).map(d=>d/255),transparentColor:l.map(d=>d/255)};i.shaderInputs.setProps({bitmap:f}),i.draw(this.context.renderPass)}}_getCoordinateUniforms(){let{_imageCoordinateSystem:e}=this.props;if(e!=="default"){let{bounds:t}=this.props;if(!HT(t))throw new Error("_imageCoordinateSystem only supports rectangular bounds");let i=this.context.viewport.resolution?"lnglat":"cartesian";if(e=e==="lnglat"?"lnglat":"cartesian",e==="lnglat"&&i==="cartesian")return{coordinateConversion:-1,bounds:t};if(e==="cartesian"&&i==="lnglat"){let r=ht([t[0],t[1]]),s=ht([t[2],t[3]]);return{coordinateConversion:1,bounds:[r[0],r[1],s[0],s[1]]}}}return{coordinateConversion:0,bounds:[0,0,0,0]}}};pl.layerName="BitmapLayer";pl.defaultProps=hG;var ub=pl;function pG(n){let[e,t,i]=n,r=(i&240)/256,s=(i&15)/16;return[(e+s)/256,(t+r)/256]}function HT(n){return Number.isFinite(n[0])}Me();var YT=`layout(std140) uniform scatterplotUniforms { +`;var gG={image:{type:"image",value:null,async:!0},bounds:{type:"array",value:[1,0,0,1],compare:!0},_imageCoordinateSystem:"default",desaturate:{type:"number",min:0,max:1,value:0},transparentColor:{type:"color",value:[0,0,0,0]},tintColor:{type:"color",value:[255,255,255]},textureParameters:{type:"object",ignore:!0,value:null}},pl=class extends ki{getShaders(){return super.getShaders({vs:WT,fs:jT,source:VT,modules:[Vn,Hn,qn,GT]})}initializeState(){let e=this.getAttributeManager(),t=!0;e.add({indices:{size:1,isIndexed:!0,update:i=>i.value=this.state.mesh.indices,noAlloc:t},positions:{size:3,type:"float64",fp64:this.use64bitPositions(),update:i=>i.value=this.state.mesh.positions,noAlloc:t},texCoords:{size:2,update:i=>i.value=this.state.mesh.texCoords,noAlloc:t}})}updateState({props:e,oldProps:t,changeFlags:i}){let r=this.getAttributeManager();if(i.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),r.invalidateAll()),e.bounds!==t.bounds){let s=this.state.mesh,o=this._createMesh();this.state.model.setVertexCount(o.vertexCount);for(let a in o)s&&s[a]!==o[a]&&r.invalidate(a);this.setState({mesh:o,...this._getCoordinateUniforms()})}else e._imageCoordinateSystem!==t._imageCoordinateSystem&&this.setState(this._getCoordinateUniforms())}getPickingInfo(e){let{image:t}=this.props,i=e.info;if(!i.color||!t)return i.bitmap=null,i;let{width:r,height:s}=t;i.index=0;let o=_G(i.color);return i.bitmap={size:{width:r,height:s},uv:o,pixel:[Math.floor(o[0]*r),Math.floor(o[1]*s)]},i}disablePickingIndex(){this.setState({disablePicking:!0})}restorePickingColors(){this.setState({disablePicking:!1})}_updateAutoHighlight(e){super._updateAutoHighlight({...e,color:this.encodePickingColor(0)})}_createMesh(){let{bounds:e}=this.props,t=e;return HT(e)&&(t=[[e[0],e[1]],[e[0],e[3]],[e[2],e[3]],[e[2],e[1]]]),lb(t,this.context.viewport.resolution)}_getModel(){let e=this.context.device.type==="webgpu"?this.getAttributeManager().getBufferLayouts({isInstanced:!1}).filter(t=>t.name!=="indices"):this.getAttributeManager().getBufferLayouts();return new Ze(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:e,topology:"triangle-list",isInstanced:!1})}draw(e){let{shaderModuleProps:t}=e,{model:i,coordinateConversion:r,bounds:s,disablePicking:o}=this.state,{image:a,desaturate:c,transparentColor:l,tintColor:u}=this.props;if(!(t.picking.isActive&&o)&&a&&i){let f={bitmapTexture:a,bounds:s,coordinateConversion:r,desaturate:c,tintColor:u.slice(0,3).map(d=>d/255),transparentColor:l.map(d=>d/255)};i.shaderInputs.setProps({bitmap:f}),i.draw(this.context.renderPass)}}_getCoordinateUniforms(){let{_imageCoordinateSystem:e}=this.props;if(e!=="default"){let{bounds:t}=this.props;if(!HT(t))throw new Error("_imageCoordinateSystem only supports rectangular bounds");let i=this.context.viewport.resolution?"lnglat":"cartesian";if(e=e==="lnglat"?"lnglat":"cartesian",e==="lnglat"&&i==="cartesian")return{coordinateConversion:-1,bounds:t};if(e==="cartesian"&&i==="lnglat"){let r=ht([t[0],t[1]]),s=ht([t[2],t[3]]);return{coordinateConversion:1,bounds:[r[0],r[1],s[0],s[1]]}}}return{coordinateConversion:0,bounds:[0,0,0,0]}}};pl.layerName="BitmapLayer";pl.defaultProps=gG;var ub=pl;function _G(n){let[e,t,i]=n,r=(i&240)/256,s=(i&15)/16;return[(e+s)/256,(t+r)/256]}function HT(n){return Number.isFinite(n[0])}Me();var YT=`layout(std140) uniform scatterplotUniforms { float radiusScale; float radiusMinPixels; float radiusMaxPixels; @@ -4938,7 +4938,7 @@ fragColor = vFillColor; fragColor.a *= inCircle; DECKGL_FILTER_COLOR(fragColor, geometry); } -`;var mG=`// Main shaders +`;var yG=`// Main shaders struct ScatterplotUniforms { radiusScale: f32, @@ -5142,7 +5142,7 @@ fn fragmentMain(varyings: Varyings) -> @location(0) vec4 { return fragColor; // return vec4(0, 0, 1, 1); } -`;function KT(n){return mG.replace("PICKING_COLOR_ATTRIBUTE",n?"@location(8) rowIndexes: u32,":"").replace("PICKING_COLOR_VALUE",n?"picking_getPickingColorFromIndex(attributes.rowIndexes)":"picking_getPickingColorFromIndex(attributes.instanceIndex)")}var gG=`struct ClipUniforms { +`;function KT(n){return yG.replace("PICKING_COLOR_ATTRIBUTE",n?"@location(8) rowIndexes: u32,":"").replace("PICKING_COLOR_VALUE",n?"picking_getPickingColorFromIndex(attributes.rowIndexes)":"picking_getPickingColorFromIndex(attributes.instanceIndex)")}var bG=`struct ClipUniforms { enabled: i32, mode: i32, bounds: vec4, @@ -5176,7 +5176,7 @@ fn clip_filterColor(geometryCoordinates: vec2) { discard; } } -`,_G={name:"clip",source:gG,props:{},uniforms:{},bindingLayout:[{name:"clip",group:2}],uniformTypes:{enabled:"i32",mode:"i32",bounds:"vec4"},defaultUniforms:{enabled:0,mode:0,bounds:[0,0,1,1]},getUniforms(n={}){let e={};return n.enabled!==void 0&&(e.enabled=n.enabled?1:0),n.mode!==void 0&&(e.mode=n.mode==="instance"?1:0),n.bounds!==void 0&&(e.bounds=n.bounds),e}},zo=_G;var QT=[0,0,0,255],yG={radiusUnits:"meters",radiusScale:{type:"number",min:0,value:1},radiusMinPixels:{type:"number",min:0,value:0},radiusMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},lineWidthUnits:"meters",lineWidthScale:{type:"number",min:0,value:1},lineWidthMinPixels:{type:"number",min:0,value:0},lineWidthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,getPosition:{type:"accessor",value:n=>n.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:QT},getLineColor:{type:"accessor",value:QT},getLineWidth:{type:"accessor",value:1},getPixelOffset:{type:"accessor",value:[0,0]},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}},ml=class extends ki{getShaders(){let e=!!this.props.data?.attributes?.rowIndexes;return super.getShaders({vs:ZT,fs:XT,source:KT(e),defines:e?{USE_ROW_INDEXES:!0}:{},modules:[Hn,Vn,qn,qT,...this.context.device.type==="webgpu"?[zo]:[]]})}initializeState(){let e=this.props.data?.attributes?.rowIndexes?{rowIndexes:{size:1,type:"uint32",noAlloc:!0}}:{};this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceRadius:{size:1,transition:!0,accessor:"getRadius",defaultValue:1,bufferGroup:"scatterplot-instance-data"},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255],bufferGroup:"scatterplot-instance-data"},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255],bufferGroup:"scatterplot-instance-data"},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1,bufferGroup:"scatterplot-instance-data"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset",bufferGroup:"scatterplot-instance-data"},...e})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{radiusUnits:t,radiusScale:i,radiusMinPixels:r,radiusMaxPixels:s,stroked:o,filled:a,billboard:c,antialiasing:l,lineWidthUnits:u,lineWidthScale:f,lineWidthMinPixels:d,lineWidthMaxPixels:h}=this.props,p={stroked:o,filled:a,billboard:c,antialiasing:l,radiusUnits:Jt[t],radiusScale:i,radiusMinPixels:r,radiusMaxPixels:s,lineWidthUnits:Jt[u],lineWidthScale:f,lineWidthMinPixels:d,lineWidthMaxPixels:h},m=this.state.model;m.shaderInputs.setProps({scatterplot:p}),m.draw(this.context.renderPass)}_getModel(){let e=[-1,-1,0,1,-1,0,-1,1,0,1,1,0];return new Ze(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new tn({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(e)}}}),isInstanced:!0})}};ml.defaultProps=yG;ml.layerName="ScatterplotLayer";var fb=ml;var eh={CLOCKWISE:1,COUNTER_CLOCKWISE:-1};function gl(n,e,t={}){return JT(n,t)!==e?(bG(n,t),!0):!1}function JT(n,e={}){return Math.sign(th(n,e))}var db={x:0,y:1,z:2};function th(n,e={}){let{start:t=0,end:i=n.length,plane:r="xy"}=e,s=e.size||2,o=0,a=db[r[0]],c=db[r[1]];for(let l=t,u=i-s;l0){let r=!0;for(let s=0;se[2]&&(t|=2),n[1]e[3]&&(t|=8),t}function bl(n,e){let{size:t=2,broken:i=!1,gridResolution:r=10,gridOffset:s=[0,0],startIndex:o=0,endIndex:a=n.length}=e||{},c=(a-o)/t,l=[],u=[l],f=cr(n,0,t,o),d,h,p=nL(f,r,s,[]),m=[];Et(l,f);for(let g=1;gt&&(l=[],u.push(l),Et(l,f)),h=yl(d,p)}Et(l,d),_l(f,d)}return i?u:u[0]}var eL=0,xG=1;function vl(n,e=null,t){if(!n.length)return[];let{size:i=2,gridResolution:r=10,gridOffset:s=[0,0],edgeTypes:o=!1}=t||{},a=[],c=[{pos:n,types:o?new Array(n.length/i).fill(xG):null,holes:e||[]}],l=[[],[]],u=[];for(;c.length;){let{pos:f,types:d,holes:h}=c.shift();EG(f,i,h[0]||f.length,l),u=nL(l[0],r,s,u);let p=yl(l[1],u);if(p){let m=tL(f,d,i,0,h[0]||f.length,u,p),g={pos:m[0].pos,types:m[0].types,holes:[]},v={pos:m[1].pos,types:m[1].types,holes:[]};c.push(g,v);for(let y=0;y=0?(Et(l,h)&&f.push(m),x+=p):f.length&&(f[f.length-1]=eL),_l(g,h),v=p,y=m;return[b?{pos:c,types:e&&u}:null,x?{pos:l,types:e&&f}:null]}function nL(n,e,t,i){let r=Math.floor((n[0]-t[0])/e)*e+t[0],s=Math.floor((n[1]-t[1])/e)*e+t[1];return i[0]=r,i[1]=s,i[2]=r+e,i[3]=s+e,i}function wG(n,e,t){t&8?(n[1]+=e,n[3]+=e):t&4?(n[1]-=e,n[3]-=e):t&2?(n[0]+=e,n[2]+=e):t&1&&(n[0]-=e,n[2]-=e)}function EG(n,e,t,i){let r=1/0,s=-1/0,o=1/0,a=-1/0;for(let c=0;cs?l:s,o=ua?u:a}return i[0][0]=r,i[0][1]=o,i[1][0]=s,i[1][1]=a,i}function ih(n,e){for(let t=0;tr&&(r=a,s=o-1)}return s}function CG(n,e,t,i,r=SG){let s=n[t],o=n[i-e];if(Math.abs(s-o)>180){let a=cr(n,0,e,t);a[0]+=Math.round((o-s)/360)*360,Et(n,a),a[1]=Math.sign(a[1])*r,Et(n,a),a[0]=s,Et(n,a)}}function iL(n,e,t,i){let r=n[0],s;for(let o=t;o180||a<-180)&&(s-=Math.round(a/360)*360),n[o]=r=s}}function rL(n,e){let t,i=n.length/e;for(let s=0;s=e.length&&(t+=1-e.length/r);let s=t*r;return i[0]=e[s],i[1]=e[s+1],i[2]=r===3&&e[s+2]||0,i}isClosed(e){if(!this.normalize)return!!this.opts.loop;let{positionSize:t}=this,i=e.length-t;return e[0]===e[i]&&e[1]===e[i+1]&&(t===2||e[2]===e[i+2])}};function oL(n){return Array.isArray(n[0])}var AG=`struct PathUniforms { +`,vG={name:"clip",source:bG,props:{},uniforms:{},bindingLayout:[{name:"clip",group:2}],uniformTypes:{enabled:"i32",mode:"i32",bounds:"vec4"},defaultUniforms:{enabled:0,mode:0,bounds:[0,0,1,1]},getUniforms(n={}){let e={};return n.enabled!==void 0&&(e.enabled=n.enabled?1:0),n.mode!==void 0&&(e.mode=n.mode==="instance"?1:0),n.bounds!==void 0&&(e.bounds=n.bounds),e}},zo=vG;var QT=[0,0,0,255],xG={radiusUnits:"meters",radiusScale:{type:"number",min:0,value:1},radiusMinPixels:{type:"number",min:0,value:0},radiusMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},lineWidthUnits:"meters",lineWidthScale:{type:"number",min:0,value:1},lineWidthMinPixels:{type:"number",min:0,value:0},lineWidthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,getPosition:{type:"accessor",value:n=>n.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:QT},getLineColor:{type:"accessor",value:QT},getLineWidth:{type:"accessor",value:1},getPixelOffset:{type:"accessor",value:[0,0]},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}},ml=class extends ki{getShaders(){let e=!!this.props.data?.attributes?.rowIndexes;return super.getShaders({vs:ZT,fs:XT,source:KT(e),defines:e?{USE_ROW_INDEXES:!0}:{},modules:[Hn,Vn,qn,qT,...this.context.device.type==="webgpu"?[zo]:[]]})}initializeState(){let e=this.props.data?.attributes?.rowIndexes?{rowIndexes:{size:1,type:"uint32",noAlloc:!0}}:{};this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceRadius:{size:1,transition:!0,accessor:"getRadius",defaultValue:1,bufferGroup:"scatterplot-instance-data"},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255],bufferGroup:"scatterplot-instance-data"},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255],bufferGroup:"scatterplot-instance-data"},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1,bufferGroup:"scatterplot-instance-data"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset",bufferGroup:"scatterplot-instance-data"},...e})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{radiusUnits:t,radiusScale:i,radiusMinPixels:r,radiusMaxPixels:s,stroked:o,filled:a,billboard:c,antialiasing:l,lineWidthUnits:u,lineWidthScale:f,lineWidthMinPixels:d,lineWidthMaxPixels:h}=this.props,p={stroked:o,filled:a,billboard:c,antialiasing:l,radiusUnits:Qt[t],radiusScale:i,radiusMinPixels:r,radiusMaxPixels:s,lineWidthUnits:Qt[u],lineWidthScale:f,lineWidthMinPixels:d,lineWidthMaxPixels:h},m=this.state.model;m.shaderInputs.setProps({scatterplot:p}),m.draw(this.context.renderPass)}_getModel(){let e=[-1,-1,0,1,-1,0,-1,1,0,1,1,0];return new Ze(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new en({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(e)}}}),isInstanced:!0})}};ml.defaultProps=xG;ml.layerName="ScatterplotLayer";var fb=ml;var eh={CLOCKWISE:1,COUNTER_CLOCKWISE:-1};function gl(n,e,t={}){return JT(n,t)!==e?(wG(n,t),!0):!1}function JT(n,e={}){return Math.sign(th(n,e))}var db={x:0,y:1,z:2};function th(n,e={}){let{start:t=0,end:i=n.length,plane:r="xy"}=e,s=e.size||2,o=0,a=db[r[0]],c=db[r[1]];for(let l=t,u=i-s;l0){let r=!0;for(let s=0;se[2]&&(t|=2),n[1]e[3]&&(t|=8),t}function bl(n,e){let{size:t=2,broken:i=!1,gridResolution:r=10,gridOffset:s=[0,0],startIndex:o=0,endIndex:a=n.length}=e||{},c=(a-o)/t,l=[],u=[l],f=cr(n,0,t,o),d,h,p=nL(f,r,s,[]),m=[];Et(l,f);for(let g=1;gt&&(l=[],u.push(l),Et(l,f)),h=yl(d,p)}Et(l,d),_l(f,d)}return i?u:u[0]}var eL=0,SG=1;function vl(n,e=null,t){if(!n.length)return[];let{size:i=2,gridResolution:r=10,gridOffset:s=[0,0],edgeTypes:o=!1}=t||{},a=[],c=[{pos:n,types:o?new Array(n.length/i).fill(SG):null,holes:e||[]}],l=[[],[]],u=[];for(;c.length;){let{pos:f,types:d,holes:h}=c.shift();CG(f,i,h[0]||f.length,l),u=nL(l[0],r,s,u);let p=yl(l[1],u);if(p){let m=tL(f,d,i,0,h[0]||f.length,u,p),g={pos:m[0].pos,types:m[0].types,holes:[]},v={pos:m[1].pos,types:m[1].types,holes:[]};c.push(g,v);for(let y=0;y=0?(Et(l,h)&&f.push(m),x+=p):f.length&&(f[f.length-1]=eL),_l(g,h),v=p,y=m;return[b?{pos:c,types:e&&u}:null,x?{pos:l,types:e&&f}:null]}function nL(n,e,t,i){let r=Math.floor((n[0]-t[0])/e)*e+t[0],s=Math.floor((n[1]-t[1])/e)*e+t[1];return i[0]=r,i[1]=s,i[2]=r+e,i[3]=s+e,i}function PG(n,e,t){t&8?(n[1]+=e,n[3]+=e):t&4?(n[1]-=e,n[3]-=e):t&2?(n[0]+=e,n[2]+=e):t&1&&(n[0]-=e,n[2]-=e)}function CG(n,e,t,i){let r=1/0,s=-1/0,o=1/0,a=-1/0;for(let c=0;cs?l:s,o=ua?u:a}return i[0][0]=r,i[0][1]=o,i[1][0]=s,i[1][1]=a,i}function ih(n,e){for(let t=0;tr&&(r=a,s=o-1)}return s}function MG(n,e,t,i,r=TG){let s=n[t],o=n[i-e];if(Math.abs(s-o)>180){let a=cr(n,0,e,t);a[0]+=Math.round((o-s)/360)*360,Et(n,a),a[1]=Math.sign(a[1])*r,Et(n,a),a[0]=s,Et(n,a)}}function iL(n,e,t,i){let r=n[0],s;for(let o=t;o180||a<-180)&&(s-=Math.round(a/360)*360),n[o]=r=s}}function rL(n,e){let t,i=n.length/e;for(let s=0;s=e.length&&(t+=1-e.length/r);let s=t*r;return i[0]=e[s],i[1]=e[s+1],i[2]=r===3&&e[s+2]||0,i}isClosed(e){if(!this.normalize)return!!this.opts.loop;let{positionSize:t}=this,i=e.length-t;return e[0]===e[i]&&e[1]===e[i+1]&&(t===2||e[2]===e[i+2])}};function oL(n){return Array.isArray(n[0])}var IG=`struct PathUniforms { widthScale: f32, widthMinPixels: f32, widthMaxPixels: f32, @@ -5199,7 +5199,7 @@ var path: PathUniforms; bool billboard; highp int widthUnits; } path; -`,cL={name:"path",source:AG,vs:aL,fs:aL,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",jointType:"f32",capType:"f32",miterLimit:"f32",billboard:"f32",widthUnits:"i32"}};var lL=`const EPSILON: f32 = 0.001; +`,cL={name:"path",source:IG,vs:aL,fs:aL,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",jointType:"f32",capType:"f32",miterLimit:"f32",billboard:"f32",widthUnits:"i32"}};var lL=`const EPSILON: f32 = 0.001; const ZERO_OFFSET: vec3 = vec3(0.0, 0.0, 0.0); struct JoinResult { @@ -6031,7 +6031,7 @@ fragColor = vColor; #endif DECKGL_FILTER_COLOR(fragColor, geometry); } -`;var hL=[0,0,0,255],kG={widthUnits:"meters",widthScale:{type:"number",min:0,value:1},widthMinPixels:{type:"number",min:0,value:0},widthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},jointRounded:!1,capRounded:!1,miterLimit:{type:"number",min:0,value:4},antialiasing:!1,billboard:!1,_pathType:null,getPath:{type:"accessor",value:n=>n.path},getColor:{type:"accessor",value:hL},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},mb={enter:(n,e)=>e.length?e.subarray(e.length-n.length):n};function RG(n){if(n.isGeospatial)return null;let{unitsPerMeter:e}=n.distanceScales;return[e[0],e[1],e[2]]}function dL(n,e){return n===e||!!(n&&e&&n.length===e.length&&n.every((t,i)=>t===e[i]))}var El=class extends ki{getShaders(){let{antialiasing:e}=this.props;return super.getShaders({vs:uL,fs:fL,source:lL,defines:e?{ANTIALIASING:1}:{},modules:[Hn,Vn,qn,cL,...this.context.device.type==="webgpu"?[zo]:[]]})}get wrapLongitude(){return!1}getBounds(){return this.context.device.type==="webgpu"?null:this.getAttributeManager()?.getBounds(["vertexPositions"])}getPathProjectionScale(e){let t=this.props.coordinateSystem;if(!!!this.getAttributeManager()?.getAttributes().instanceDashOffsets)return null;if(e instanceof Ei&&e.zoom>=12&&(t==="default"||t==="lnglat"||t==="cartesian")){let o=hn.getUniforms({viewport:e,coordinateSystem:t,coordinateOrigin:this.props.coordinateOrigin,autoWrapLongitude:this.wrapLongitude});return[e.projectionMode,o.coordinateOrigin[1],o.commonOrigin[1],...o.commonUnitsPerWorldUnit,...o.commonUnitsPerWorldUnit2,o.commonUnitsPerMeter[2]]}let s=RG(e);return s?[e.projectionMode,...s]:[e.projectionMode]}shouldUpdateState(e){let{viewport:t}=this.context;return super.shouldUpdateState(e)||this.state?.tessellationResolution!==t.resolution||!dL(this.state?.pathProjectionScale,this.getPathProjectionScale(t))}initializeState(){let t=this.context.device.type==="webgpu";this.getAttributeManager().addInstanced({...t?{pathPositions:{size:24,type:"float32",transition:!1,accessor:"getPath",update:this.calculateWebGPUPositions,shaderAttributes:{instanceLeftPositions:{size:3,elementOffset:0},instanceStartPositions:{size:3,elementOffset:3},instanceEndPositions:{size:3,elementOffset:6},instanceRightPositions:{size:3,elementOffset:9},instanceLeftPositions64Low:{size:3,elementOffset:12},instanceStartPositions64Low:{size:3,elementOffset:15},instanceEndPositions64Low:{size:3,elementOffset:18},instanceRightPositions64Low:{size:3,elementOffset:21}},noAlloc:!0}}:{vertexPositions:{size:3,vertexOffset:1,type:"float64",fp64:this.use64bitPositions(),transition:mb,accessor:"getPath",update:this.calculatePositions,noAlloc:!0,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}}},instanceTypes:{size:1,type:t?"float32":"uint8",update:this.calculateSegmentTypes,noAlloc:!0},instanceStrokeWidths:{size:1,accessor:"getWidth",transition:t?!1:mb,defaultValue:1,bufferGroup:"path-instance-data"},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",accessor:"getColor",transition:t?!1:mb,defaultValue:hL,bufferGroup:"path-instance-data"},rowIndexes:{size:1,type:"uint32",accessor:(r,{index:s})=>r&&r.__source?r.__source.index:s,bufferGroup:"path-instance-data"}}),this.setState({pathTesselator:new wl({fp64:this.use64bitPositions(),isWebGPU:t}),tessellationResolution:this.context.viewport.resolution,pathProjectionScale:this.getPathProjectionScale(this.context.viewport)})}updateState(e){super.updateState(e);let{props:t,oldProps:i,changeFlags:r}=e,s=this.getAttributeManager(),{viewport:o}=this.context,a=this.state.tessellationResolution!==o.resolution,c=this.getPathProjectionScale(o),l=!dL(this.state.pathProjectionScale,c),f=r.updateTriggersChanged&&(r.updateTriggersChanged.all||r.updateTriggersChanged.getPath)||t._pathType!==i._pathType||t.positionFormat!==i.positionFormat||t.wrapLongitude!==i.wrapLongitude||a;if(r.dataChanged||f){let{pathTesselator:h}=this.state,p=t.data.attributes||{};h.updateGeometry({data:t.data,geometryBuffer:p.getPath,buffers:p,normalize:!t._pathType,loop:t._pathType==="loop",getGeometry:t.getPath,positionFormat:t.positionFormat,wrapLongitude:t.wrapLongitude,resolution:o.resolution,dataChanged:f?void 0:r.dataChanged}),this.setState({numInstances:h.instanceCount,startIndices:h.vertexStarts,tessellationResolution:o.resolution,pathProjectionScale:c}),!r.dataChanged||f?s.invalidateAll():l&&s.invalidate("instanceDashOffsets")}else l&&(this.setState({pathProjectionScale:c}),s.invalidate("instanceDashOffsets"));(r.extensionsChanged||t.antialiasing!==i.antialiasing)&&(this.state.model?.destroy(),this.state.model=this._getModel(),s.invalidateAll())}getPickingInfo(e){let t=super.getPickingInfo(e),{index:i}=t,r=this.props.data;return r[0]&&r[0].__source&&(t.object=r.find(s=>s.__source.index===i)),t}disablePickingIndex(e){let t=this.props.data;if(t[0]&&t[0].__source)for(let i=0;i=0&&u=1&&n[0].length>=2&&Number.isFinite(n[0][0])}function KG(n){let e=n[0],t=n[n.length-1];return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function QG(n,e,t,i){for(let r=0;ra/e));let s=$o(n),o=i&&e===3;if(t){let a=s.length;s=s.slice();let c=[];for(let l=0;lc&&a>l||(c>l?(t||(s=s.slice()),wL(s,0,2,1)):(t||(s=s.slice()),wL(s,2,0,1)))}return(0,EL.default)(s,r,e)}var Ll=class extends ar{constructor(e){let{fp64:t,IndexType:i=Uint32Array}=e;super({...e,attributes:{positions:{size:3,type:t?Float64Array:Float32Array},vertexValid:{type:Uint16Array,size:1},indices:{type:i,size:1}}})}get(e){let{attributes:t}=this;return e==="indices"?t.indices&&t.indices.subarray(0,this.vertexCount):t[e]}updateGeometry(e){super.updateGeometry(e);let t=this.buffers.indices;if(t)this.vertexCount=(t.value||t).length;else if(this.data&&!this.getGeometry)throw new Error("missing indices buffer")}normalizeGeometry(e){if(this.normalize){let t=SL(e,this.positionSize);return this.opts.resolution?vl($o(t),Tl(t),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?pb($o(t),Tl(t),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):t}return e}getGeometrySize(e){if(CL(e)){let t=0;for(let i of e)t+=this.getGeometrySize(i);return t}return $o(e).length/this.positionSize}getGeometryFromBuffer(e){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(e):null}updateGeometryAttributes(e,t){if(e&&CL(e))for(let i of e){let r=this.getGeometrySize(i);t.geometrySize=r,this.updateGeometryAttributes(i,t),t.vertexStart+=r,t.indexStart=this.indexStarts[t.geometryIndex+1]}else{let i=e;this._updateIndices(i,t),this._updatePositions(i,t),this._updateVertexValid(i,t)}}_updateIndices(e,{geometryIndex:t,vertexStart:i,indexStart:r}){let{attributes:s,indexStarts:o,typedArrayManager:a}=this,c=s.indices;if(!c||!e)return;let l=r,u=PL(e,this.positionSize,this.opts.preproject,this.opts.full3d);c=a.allocate(c,r+u.length,{copy:!0});for(let f=0;f2?o[c*s+2]:0;r[a*3]=l,r[a*3+1]=u,r[a*3+2]=f}}_updateVertexValid(e,{vertexStart:t,geometrySize:i}){let{positionSize:r}=this,s=this.attributes.vertexValid,o=e&&Tl(e);if(e&&e.edgeTypes?s.set(e.edgeTypes,t):s.fill(1,t,t+i),o)for(let a=0;a0&&!Number.isFinite(n[0])}var eV=`struct SolidPolygonUniforms { +`;var hL=[0,0,0,255],BG={widthUnits:"meters",widthScale:{type:"number",min:0,value:1},widthMinPixels:{type:"number",min:0,value:0},widthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},jointRounded:!1,capRounded:!1,miterLimit:{type:"number",min:0,value:4},antialiasing:!1,billboard:!1,_pathType:null,getPath:{type:"accessor",value:n=>n.path},getColor:{type:"accessor",value:hL},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},mb={enter:(n,e)=>e.length?e.subarray(e.length-n.length):n};function OG(n){if(n.isGeospatial)return null;let{unitsPerMeter:e}=n.distanceScales;return[e[0],e[1],e[2]]}function dL(n,e){return n===e||!!(n&&e&&n.length===e.length&&n.every((t,i)=>t===e[i]))}var El=class extends ki{getShaders(){let{antialiasing:e}=this.props;return super.getShaders({vs:uL,fs:fL,source:lL,defines:e?{ANTIALIASING:1}:{},modules:[Hn,Vn,qn,cL,...this.context.device.type==="webgpu"?[zo]:[]]})}get wrapLongitude(){return!1}getBounds(){return this.context.device.type==="webgpu"?null:this.getAttributeManager()?.getBounds(["vertexPositions"])}getPathProjectionScale(e){let t=this.props.coordinateSystem;if(!!!this.getAttributeManager()?.getAttributes().instanceDashOffsets)return null;if(e instanceof Ei&&e.zoom>=12&&(t==="default"||t==="lnglat"||t==="cartesian")){let o=hn.getUniforms({viewport:e,coordinateSystem:t,coordinateOrigin:this.props.coordinateOrigin,autoWrapLongitude:this.wrapLongitude});return[e.projectionMode,o.coordinateOrigin[1],o.commonOrigin[1],...o.commonUnitsPerWorldUnit,...o.commonUnitsPerWorldUnit2,o.commonUnitsPerMeter[2]]}let s=OG(e);return s?[e.projectionMode,...s]:[e.projectionMode]}shouldUpdateState(e){let{viewport:t}=this.context;return super.shouldUpdateState(e)||this.state?.tessellationResolution!==t.resolution||!dL(this.state?.pathProjectionScale,this.getPathProjectionScale(t))}initializeState(){let t=this.context.device.type==="webgpu";this.getAttributeManager().addInstanced({...t?{pathPositions:{size:24,type:"float32",transition:!1,accessor:"getPath",update:this.calculateWebGPUPositions,shaderAttributes:{instanceLeftPositions:{size:3,elementOffset:0},instanceStartPositions:{size:3,elementOffset:3},instanceEndPositions:{size:3,elementOffset:6},instanceRightPositions:{size:3,elementOffset:9},instanceLeftPositions64Low:{size:3,elementOffset:12},instanceStartPositions64Low:{size:3,elementOffset:15},instanceEndPositions64Low:{size:3,elementOffset:18},instanceRightPositions64Low:{size:3,elementOffset:21}},noAlloc:!0}}:{vertexPositions:{size:3,vertexOffset:1,type:"float64",fp64:this.use64bitPositions(),transition:mb,accessor:"getPath",update:this.calculatePositions,noAlloc:!0,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}}},instanceTypes:{size:1,type:t?"float32":"uint8",update:this.calculateSegmentTypes,noAlloc:!0},instanceStrokeWidths:{size:1,accessor:"getWidth",transition:t?!1:mb,defaultValue:1,bufferGroup:"path-instance-data"},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",accessor:"getColor",transition:t?!1:mb,defaultValue:hL,bufferGroup:"path-instance-data"},rowIndexes:{size:1,type:"uint32",accessor:(r,{index:s})=>r&&r.__source?r.__source.index:s,bufferGroup:"path-instance-data"}}),this.setState({pathTesselator:new wl({fp64:this.use64bitPositions(),isWebGPU:t}),tessellationResolution:this.context.viewport.resolution,pathProjectionScale:this.getPathProjectionScale(this.context.viewport)})}updateState(e){super.updateState(e);let{props:t,oldProps:i,changeFlags:r}=e,s=this.getAttributeManager(),{viewport:o}=this.context,a=this.state.tessellationResolution!==o.resolution,c=this.getPathProjectionScale(o),l=!dL(this.state.pathProjectionScale,c),f=r.updateTriggersChanged&&(r.updateTriggersChanged.all||r.updateTriggersChanged.getPath)||t._pathType!==i._pathType||t.positionFormat!==i.positionFormat||t.wrapLongitude!==i.wrapLongitude||a;if(r.dataChanged||f){let{pathTesselator:h}=this.state,p=t.data.attributes||{};h.updateGeometry({data:t.data,geometryBuffer:p.getPath,buffers:p,normalize:!t._pathType,loop:t._pathType==="loop",getGeometry:t.getPath,positionFormat:t.positionFormat,wrapLongitude:t.wrapLongitude,resolution:o.resolution,dataChanged:f?void 0:r.dataChanged}),this.setState({numInstances:h.instanceCount,startIndices:h.vertexStarts,tessellationResolution:o.resolution,pathProjectionScale:c}),!r.dataChanged||f?s.invalidateAll():l&&s.invalidate("instanceDashOffsets")}else l&&(this.setState({pathProjectionScale:c}),s.invalidate("instanceDashOffsets"));(r.extensionsChanged||t.antialiasing!==i.antialiasing)&&(this.state.model?.destroy(),this.state.model=this._getModel(),s.invalidateAll())}getPickingInfo(e){let t=super.getPickingInfo(e),{index:i}=t,r=this.props.data;return r[0]&&r[0].__source&&(t.object=r.find(s=>s.__source.index===i)),t}disablePickingIndex(e){let t=this.props.data;if(t[0]&&t[0].__source)for(let i=0;i=0&&u=1&&n[0].length>=2&&Number.isFinite(n[0][0])}function eV(n){let e=n[0],t=n[n.length-1];return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function tV(n,e,t,i){for(let r=0;ra/e));let s=$o(n),o=i&&e===3;if(t){let a=s.length;s=s.slice();let c=[];for(let l=0;lc&&a>l||(c>l?(t||(s=s.slice()),wL(s,0,2,1)):(t||(s=s.slice()),wL(s,2,0,1)))}return(0,EL.default)(s,r,e)}var Ll=class extends ar{constructor(e){let{fp64:t,IndexType:i=Uint32Array}=e;super({...e,attributes:{positions:{size:3,type:t?Float64Array:Float32Array},vertexValid:{type:Uint16Array,size:1},indices:{type:i,size:1}}})}get(e){let{attributes:t}=this;return e==="indices"?t.indices&&t.indices.subarray(0,this.vertexCount):t[e]}updateGeometry(e){super.updateGeometry(e);let t=this.buffers.indices;if(t)this.vertexCount=(t.value||t).length;else if(this.data&&!this.getGeometry)throw new Error("missing indices buffer")}normalizeGeometry(e){if(this.normalize){let t=SL(e,this.positionSize);return this.opts.resolution?vl($o(t),Tl(t),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?pb($o(t),Tl(t),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):t}return e}getGeometrySize(e){if(CL(e)){let t=0;for(let i of e)t+=this.getGeometrySize(i);return t}return $o(e).length/this.positionSize}getGeometryFromBuffer(e){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(e):null}updateGeometryAttributes(e,t){if(e&&CL(e))for(let i of e){let r=this.getGeometrySize(i);t.geometrySize=r,this.updateGeometryAttributes(i,t),t.vertexStart+=r,t.indexStart=this.indexStarts[t.geometryIndex+1]}else{let i=e;this._updateIndices(i,t),this._updatePositions(i,t),this._updateVertexValid(i,t)}}_updateIndices(e,{geometryIndex:t,vertexStart:i,indexStart:r}){let{attributes:s,indexStarts:o,typedArrayManager:a}=this,c=s.indices;if(!c||!e)return;let l=r,u=PL(e,this.positionSize,this.opts.preproject,this.opts.full3d);c=a.allocate(c,r+u.length,{copy:!0});for(let f=0;f2?o[c*s+2]:0;r[a*3]=l,r[a*3+1]=u,r[a*3+2]=f}}_updateVertexValid(e,{vertexStart:t,geometrySize:i}){let{positionSize:r}=this,s=this.attributes.vertexValid,o=e&&Tl(e);if(e&&e.edgeTypes?s.set(e.edgeTypes,t):s.fill(1,t,t+i),o)for(let a=0;a0&&!Number.isFinite(n[0])}var iV=`struct SolidPolygonUniforms { extruded: f32, isWireframe: f32, elevationScale: f32, @@ -6043,7 +6043,7 @@ DECKGL_FILTER_COLOR(fragColor, geometry); bool isWireframe; float elevationScale; } solidPolygon; -`,LL={name:"solidPolygon",source:eV,vs:TL,fs:TL,uniformTypes:{extruded:"f32",isWireframe:"f32",elevationScale:"f32"}};var lh=`in vec4 fillColors; +`,LL={name:"solidPolygon",source:iV,vs:TL,fs:TL,uniformTypes:{extruded:"f32",isWireframe:"f32",elevationScale:"f32"}};var lh=`in vec4 fillColors; in vec4 lineColors; in float rowIndexes; out vec4 vColor; @@ -6209,7 +6209,7 @@ fn fragmentMain(inp: Varyings) -> @location(0) vec4 { return deckgl_premultiplied_alpha(fragColor); } -`}function tV(){return`${RL()} +`}function rV(){return`${RL()} struct Attributes { @location(0) vertexPositions: vec3, @@ -6265,7 +6265,7 @@ fn vertexMain(attributes: Attributes) -> Varyings { } ${IL()} -`}function nV(n){return`const RING_WINDING_ORDER_CW: bool = ${n?"true":"false"}; +`}function sV(n){return`const RING_WINDING_ORDER_CW: bool = ${n?"true":"false"}; ${RL()} @@ -6355,9 +6355,9 @@ fn vertexMain(attributes: Attributes) -> Varyings { } ${IL()} -`}function BL(n,e){return n==="top"?tV():nV(e)}var fh=[0,0,0,255],iV={filled:!0,extruded:!1,wireframe:!1,_normalize:!0,_windingOrder:"CW",_full3d:!1,elevationScale:{type:"number",min:0,value:1},getPolygon:{type:"accessor",value:n=>n.polygon},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:fh},getLineColor:{type:"accessor",value:fh},material:!0},uh={enter:(n,e)=>e.length?e.subarray(e.length-n.length):n},Ml=class extends ki{getShaders(e){let t=!this.props._normalize&&this.props._windingOrder==="CCW"?0:1;return super.getShaders({vs:e==="top"?ML:AL,fs:kL,source:BL(e,!!t),defines:{RING_WINDING_ORDER_CW:t},modules:[Hn,Vn,eo,qn,LL,...this.context.device.type==="webgpu"?[zo]:[]]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){let{viewport:e}=this.context,{coordinateSystem:t}=this.props,{_full3d:i}=this.props;e.isGeospatial&&t==="default"&&(t="lnglat");let r;t==="lnglat"&&(i?r=e.projectPosition.bind(e):r=e.projectFlat.bind(e)),this.setState({numInstances:0,polygonTesselator:new Ll({preproject:r,fp64:this.use64bitPositions(),IndexType:Uint32Array})});let s=this.getAttributeManager(),o=!0,a=this.context.device.type==="webgpu";s.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:o},vertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:uh,accessor:"getPolygon",update:this.calculatePositions,noAlloc:o,...a?{}:{shaderAttributes:{nextVertexPositions:{vertexOffset:1}}}},...a?{nextVertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:!1,update:this.calculateNextPositions,noAlloc:o}}:{},[a?"vertexValid":"instanceVertexValid"]:{size:1,type:a?"float32":"uint16",stepMode:"instance",update:this.calculateVertexValid,noAlloc:o},elevations:{size:1,stepMode:"dynamic",transition:uh,accessor:"getElevation",bufferGroup:"solid-polygon-instance-data"},fillColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:uh,accessor:"getFillColor",defaultValue:fh,bufferGroup:"solid-polygon-instance-data"},lineColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:uh,accessor:"getLineColor",defaultValue:fh,bufferGroup:"solid-polygon-instance-data"},rowIndexes:{size:1,type:"uint32",stepMode:"dynamic",accessor:(c,{index:l})=>c&&c.__source?c.__source.index:l,bufferGroup:"solid-polygon-instance-data"}})}getPickingInfo(e){let t=super.getPickingInfo(e),{index:i}=t,r=this.props.data;return r[0]&&r[0].__source&&(t.object=r.find(s=>s.__source.index===i)),t}disablePickingIndex(e){let t=this.props.data;if(t[0]&&t[0].__source)for(let i=0;ia.destroy()),this.setState(this._getModels()),s.invalidateAll())}updateGeometry({props:e,oldProps:t,changeFlags:i}){if(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getPolygon)){let{polygonTesselator:s}=this.state,o=e.data.attributes||{};s.updateGeometry({data:e.data,normalize:e._normalize,geometryBuffer:o.getPolygon,buffers:this.context.device.type==="webgpu"?{...o}:o,getGeometry:e.getPolygon,positionFormat:e.positionFormat,wrapLongitude:e.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:i.dataChanged,full3d:e._full3d}),this.setState({numInstances:s.instanceCount,startIndices:s.vertexStarts}),i.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(){let{id:e,filled:t,extruded:i}=this.props,r,s,o;if(t){let a=this.getShaders("top");a.defines={...a.defines,NON_INSTANCED_MODEL:1};let c=this.getAttributeManager().getBufferLayouts({isInstanced:!1});this.context.device.type==="webgpu"&&(c=c.filter(l=>l.name!=="indices"&&l.name!=="vertexValid"&&l.name!=="instanceVertexValid"&&l.name!=="nextVertexPositions")),r=new Ze(this.context.device,{...a,id:`${e}-top`,topology:"triangle-list",bufferLayout:c,isIndexed:!0,userData:{excludeAttributes:{vertexValid:!0,instanceVertexValid:!0,nextVertexPositions:!0}}})}if(i){let a=this.getAttributeManager().getBufferLayouts({isInstanced:!0});this.context.device.type==="webgpu"&&(a=a.filter(c=>c.name!=="indices")),s=new Ze(this.context.device,{...this.getShaders("side"),id:`${e}-side`,bufferLayout:a,geometry:new tn({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,1,1,0,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}}),o=new Ze(this.context.device,{...this.getShaders("side"),id:`${e}-wireframe`,bufferLayout:a,geometry:new tn({topology:"line-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,0,1,1,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}})}return{models:[s,o,r].filter(Boolean),topModel:r,sideModel:s,wireframeModel:o}}calculateIndices(e){let{polygonTesselator:t}=this.state;e.startIndices=t.indexStarts,e.value=t.get("indices")}calculatePositions(e){let{polygonTesselator:t}=this.state;e.startIndices=t.vertexStarts;let i=this.props.data.attributes?.getPolygon;if(this.context.device.type==="webgpu"&&ArrayBuffer.isView(i?.value)){let{value:r,size:s=3,offset:o=0,stride:a}=i,c=o/r.BYTES_PER_ELEMENT,l=a?a/r.BYTES_PER_ELEMENT:s,u=new Float64Array(t.instanceCount*3);for(let f=0;f2?r[d+2]:0}e.value=u;return}e.value=t.get("positions")}calculateVertexValid(e){let t=this.props.data.attributes?.instanceVertexValid?.value,i=this.context.device.type==="webgpu"&&t?t:this.state.polygonTesselator.get("vertexValid");e.value=this.context.device.type==="webgpu"&&i?Float32Array.from(i):i}calculateNextPositions(e){let{polygonTesselator:t}=this.state,i=this.getAttributeManager().getAttributes(),r=i.vertexPositions.value,s=this.props.data.attributes?.instanceVertexValid?.value||i.vertexValid?.value||t.get("vertexValid");if(e.startIndices=t.vertexStarts,!r){e.value=r;return}let o=r.length/3,a=new r.constructor(r.length);for(let c=0;cnew hh(typeof n=="string"?n:n+"",void 0,DL);var FL=(n,e)=>{if(ph)n.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(let t of e){let i=document.createElement("style"),r=dh.litNonce;r!==void 0&&i.setAttribute("nonce",r),i.textContent=t.cssText,n.appendChild(i)}},Eb=ph?n=>n:n=>n instanceof CSSStyleSheet?(e=>{let t="";for(let i of e.cssRules)t+=i.cssText;return NL(t)})(n):n;var{is:rV,defineProperty:sV,getOwnPropertyDescriptor:oV,getOwnPropertyNames:aV,getOwnPropertySymbols:cV,getPrototypeOf:lV}=Object,mh=globalThis,zL=mh.trustedTypes,uV=zL?zL.emptyScript:"",fV=mh.reactiveElementPolyfillSupport,Al=(n,e)=>n,Sb={toAttribute(n,e){switch(e){case Boolean:n=n?uV:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,e){let t=n;switch(e){case Boolean:t=n!==null;break;case Number:t=n===null?null:Number(n);break;case Object:case Array:try{t=JSON.parse(n)}catch{t=null}}return t}},$L=(n,e)=>!rV(n,e),UL={attribute:!0,type:String,converter:Sb,reflect:!1,useDefault:!1,hasChanged:$L};Symbol.metadata??=Symbol("metadata"),mh.litPropertyMetadata??=new WeakMap;var Ri=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=UL){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let i=Symbol(),r=this.getPropertyDescriptor(e,i,t);r!==void 0&&sV(this.prototype,e,r)}}static getPropertyDescriptor(e,t,i){let{get:r,set:s}=oV(this.prototype,e)??{get(){return this[t]},set(o){this[t]=o}};return{get:r,set(o){let a=r?.call(this);s?.call(this,o),this.requestUpdate(e,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??UL}static _$Ei(){if(this.hasOwnProperty(Al("elementProperties")))return;let e=lV(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Al("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Al("properties"))){let t=this.properties,i=[...aV(t),...cV(t)];for(let r of i)this.createProperty(r,t[r])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[i,r]of t)this.elementProperties.set(i,r)}this._$Eh=new Map;for(let[t,i]of this.elementProperties){let r=this._$Eu(t,i);r!==void 0&&this._$Eh.set(r,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let i=new Set(e.flat(1/0).reverse());for(let r of i)t.unshift(Eb(r))}else e!==void 0&&t.push(Eb(e));return t}static _$Eu(e,t){let i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return FL(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$ET(e,t){let i=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,i);if(r!==void 0&&i.reflect===!0){let s=(i.converter?.toAttribute!==void 0?i.converter:Sb).toAttribute(t,i.type);this._$Em=e,s==null?this.removeAttribute(r):this.setAttribute(r,s),this._$Em=null}}_$AK(e,t){let i=this.constructor,r=i._$Eh.get(e);if(r!==void 0&&this._$Em!==r){let s=i.getPropertyOptions(r),o=typeof s.converter=="function"?{fromAttribute:s.converter}:s.converter?.fromAttribute!==void 0?s.converter:Sb;this._$Em=r;let a=o.fromAttribute(t,s.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(e,t,i,r=!1,s){if(e!==void 0){let o=this.constructor;if(r===!1&&(s=this[e]),i??=o.getPropertyOptions(e),!((i.hasChanged??$L)(s,t)||i.useDefault&&i.reflect&&s===this._$Ej?.get(e)&&!this.hasAttribute(o._$Eu(e,i))))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:i,reflect:r,wrapped:s},o){i&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,o??t??this[e]),s!==!0||o!==void 0)||(this._$AL.has(e)||(this.hasUpdated||i||(t=void 0),this._$AL.set(e,t)),r===!0&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[r,s]of this._$Ep)this[r]=s;this._$Ep=void 0}let i=this.constructor.elementProperties;if(i.size>0)for(let[r,s]of i){let{wrapped:o}=s,a=this[r];o!==!0||this._$AL.has(r)||a===void 0||this.C(r,void 0,s,a)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(i=>i.hostUpdate?.()),this.update(t)):this._$EM()}catch(i){throw e=!1,this._$EM(),i}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(e){}firstUpdated(e){}};Ri.elementStyles=[],Ri.shadowRootOptions={mode:"open"},Ri[Al("elementProperties")]=new Map,Ri[Al("finalized")]=new Map,fV?.({ReactiveElement:Ri}),(mh.reactiveElementVersions??=[]).push("2.1.2");var Cb=globalThis,GL=n=>n,gh=Cb.trustedTypes,VL=gh?gh.createPolicy("lit-html",{createHTML:n=>n}):void 0,Tb="$lit$",Ii=`lit$${Math.random().toFixed(9).slice(2)}$`,Lb="?"+Ii,dV=`<${Lb}>`,ps=document,Rl=()=>ps.createComment(""),Il=n=>n===null||typeof n!="object"&&typeof n!="function",Mb=Array.isArray,ZL=n=>Mb(n)||typeof n?.[Symbol.iterator]=="function",Pb=`[ +`}function BL(n,e){return n==="top"?rV():sV(e)}var fh=[0,0,0,255],oV={filled:!0,extruded:!1,wireframe:!1,_normalize:!0,_windingOrder:"CW",_full3d:!1,elevationScale:{type:"number",min:0,value:1},getPolygon:{type:"accessor",value:n=>n.polygon},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:fh},getLineColor:{type:"accessor",value:fh},material:!0},uh={enter:(n,e)=>e.length?e.subarray(e.length-n.length):n},Ml=class extends ki{getShaders(e){let t=!this.props._normalize&&this.props._windingOrder==="CCW"?0:1;return super.getShaders({vs:e==="top"?ML:AL,fs:kL,source:BL(e,!!t),defines:{RING_WINDING_ORDER_CW:t},modules:[Hn,Vn,eo,qn,LL,...this.context.device.type==="webgpu"?[zo]:[]]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){let{viewport:e}=this.context,{coordinateSystem:t}=this.props,{_full3d:i}=this.props;e.isGeospatial&&t==="default"&&(t="lnglat");let r;t==="lnglat"&&(i?r=e.projectPosition.bind(e):r=e.projectFlat.bind(e)),this.setState({numInstances:0,polygonTesselator:new Ll({preproject:r,fp64:this.use64bitPositions(),IndexType:Uint32Array})});let s=this.getAttributeManager(),o=!0,a=this.context.device.type==="webgpu";s.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:o},vertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:uh,accessor:"getPolygon",update:this.calculatePositions,noAlloc:o,...a?{}:{shaderAttributes:{nextVertexPositions:{vertexOffset:1}}}},...a?{nextVertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:!1,update:this.calculateNextPositions,noAlloc:o}}:{},[a?"vertexValid":"instanceVertexValid"]:{size:1,type:a?"float32":"uint16",stepMode:"instance",update:this.calculateVertexValid,noAlloc:o},elevations:{size:1,stepMode:"dynamic",transition:uh,accessor:"getElevation",bufferGroup:"solid-polygon-instance-data"},fillColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:uh,accessor:"getFillColor",defaultValue:fh,bufferGroup:"solid-polygon-instance-data"},lineColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:uh,accessor:"getLineColor",defaultValue:fh,bufferGroup:"solid-polygon-instance-data"},rowIndexes:{size:1,type:"uint32",stepMode:"dynamic",accessor:(c,{index:l})=>c&&c.__source?c.__source.index:l,bufferGroup:"solid-polygon-instance-data"}})}getPickingInfo(e){let t=super.getPickingInfo(e),{index:i}=t,r=this.props.data;return r[0]&&r[0].__source&&(t.object=r.find(s=>s.__source.index===i)),t}disablePickingIndex(e){let t=this.props.data;if(t[0]&&t[0].__source)for(let i=0;ia.destroy()),this.setState(this._getModels()),s.invalidateAll())}updateGeometry({props:e,oldProps:t,changeFlags:i}){if(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getPolygon)){let{polygonTesselator:s}=this.state,o=e.data.attributes||{};s.updateGeometry({data:e.data,normalize:e._normalize,geometryBuffer:o.getPolygon,buffers:this.context.device.type==="webgpu"?{...o}:o,getGeometry:e.getPolygon,positionFormat:e.positionFormat,wrapLongitude:e.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:i.dataChanged,full3d:e._full3d}),this.setState({numInstances:s.instanceCount,startIndices:s.vertexStarts}),i.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(){let{id:e,filled:t,extruded:i}=this.props,r,s,o;if(t){let a=this.getShaders("top");a.defines={...a.defines,NON_INSTANCED_MODEL:1};let c=this.getAttributeManager().getBufferLayouts({isInstanced:!1});this.context.device.type==="webgpu"&&(c=c.filter(l=>l.name!=="indices"&&l.name!=="vertexValid"&&l.name!=="instanceVertexValid"&&l.name!=="nextVertexPositions")),r=new Ze(this.context.device,{...a,id:`${e}-top`,topology:"triangle-list",bufferLayout:c,isIndexed:!0,userData:{excludeAttributes:{vertexValid:!0,instanceVertexValid:!0,nextVertexPositions:!0}}})}if(i){let a=this.getAttributeManager().getBufferLayouts({isInstanced:!0});this.context.device.type==="webgpu"&&(a=a.filter(c=>c.name!=="indices")),s=new Ze(this.context.device,{...this.getShaders("side"),id:`${e}-side`,bufferLayout:a,geometry:new en({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,1,1,0,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}}),o=new Ze(this.context.device,{...this.getShaders("side"),id:`${e}-wireframe`,bufferLayout:a,geometry:new en({topology:"line-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,0,1,1,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}})}return{models:[s,o,r].filter(Boolean),topModel:r,sideModel:s,wireframeModel:o}}calculateIndices(e){let{polygonTesselator:t}=this.state;e.startIndices=t.indexStarts,e.value=t.get("indices")}calculatePositions(e){let{polygonTesselator:t}=this.state;e.startIndices=t.vertexStarts;let i=this.props.data.attributes?.getPolygon;if(this.context.device.type==="webgpu"&&ArrayBuffer.isView(i?.value)){let{value:r,size:s=3,offset:o=0,stride:a}=i,c=o/r.BYTES_PER_ELEMENT,l=a?a/r.BYTES_PER_ELEMENT:s,u=new Float64Array(t.instanceCount*3);for(let f=0;f2?r[d+2]:0}e.value=u;return}e.value=t.get("positions")}calculateVertexValid(e){let t=this.props.data.attributes?.instanceVertexValid?.value,i=this.context.device.type==="webgpu"&&t?t:this.state.polygonTesselator.get("vertexValid");e.value=this.context.device.type==="webgpu"&&i?Float32Array.from(i):i}calculateNextPositions(e){let{polygonTesselator:t}=this.state,i=this.getAttributeManager().getAttributes(),r=i.vertexPositions.value,s=this.props.data.attributes?.instanceVertexValid?.value||i.vertexValid?.value||t.get("vertexValid");if(e.startIndices=t.vertexStarts,!r){e.value=r;return}let o=r.length/3,a=new r.constructor(r.length);for(let c=0;cnew hh(typeof n=="string"?n:n+"",void 0,DL);var FL=(n,e)=>{if(ph)n.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(let t of e){let i=document.createElement("style"),r=dh.litNonce;r!==void 0&&i.setAttribute("nonce",r),i.textContent=t.cssText,n.appendChild(i)}},Eb=ph?n=>n:n=>n instanceof CSSStyleSheet?(e=>{let t="";for(let i of e.cssRules)t+=i.cssText;return NL(t)})(n):n;var{is:aV,defineProperty:cV,getOwnPropertyDescriptor:lV,getOwnPropertyNames:uV,getOwnPropertySymbols:fV,getPrototypeOf:dV}=Object,mh=globalThis,zL=mh.trustedTypes,hV=zL?zL.emptyScript:"",pV=mh.reactiveElementPolyfillSupport,Al=(n,e)=>n,Sb={toAttribute(n,e){switch(e){case Boolean:n=n?hV:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,e){let t=n;switch(e){case Boolean:t=n!==null;break;case Number:t=n===null?null:Number(n);break;case Object:case Array:try{t=JSON.parse(n)}catch{t=null}}return t}},$L=(n,e)=>!aV(n,e),UL={attribute:!0,type:String,converter:Sb,reflect:!1,useDefault:!1,hasChanged:$L};Symbol.metadata??=Symbol("metadata"),mh.litPropertyMetadata??=new WeakMap;var Ri=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=UL){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let i=Symbol(),r=this.getPropertyDescriptor(e,i,t);r!==void 0&&cV(this.prototype,e,r)}}static getPropertyDescriptor(e,t,i){let{get:r,set:s}=lV(this.prototype,e)??{get(){return this[t]},set(o){this[t]=o}};return{get:r,set(o){let a=r?.call(this);s?.call(this,o),this.requestUpdate(e,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??UL}static _$Ei(){if(this.hasOwnProperty(Al("elementProperties")))return;let e=dV(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Al("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Al("properties"))){let t=this.properties,i=[...uV(t),...fV(t)];for(let r of i)this.createProperty(r,t[r])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[i,r]of t)this.elementProperties.set(i,r)}this._$Eh=new Map;for(let[t,i]of this.elementProperties){let r=this._$Eu(t,i);r!==void 0&&this._$Eh.set(r,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let i=new Set(e.flat(1/0).reverse());for(let r of i)t.unshift(Eb(r))}else e!==void 0&&t.push(Eb(e));return t}static _$Eu(e,t){let i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return FL(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$ET(e,t){let i=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,i);if(r!==void 0&&i.reflect===!0){let s=(i.converter?.toAttribute!==void 0?i.converter:Sb).toAttribute(t,i.type);this._$Em=e,s==null?this.removeAttribute(r):this.setAttribute(r,s),this._$Em=null}}_$AK(e,t){let i=this.constructor,r=i._$Eh.get(e);if(r!==void 0&&this._$Em!==r){let s=i.getPropertyOptions(r),o=typeof s.converter=="function"?{fromAttribute:s.converter}:s.converter?.fromAttribute!==void 0?s.converter:Sb;this._$Em=r;let a=o.fromAttribute(t,s.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(e,t,i,r=!1,s){if(e!==void 0){let o=this.constructor;if(r===!1&&(s=this[e]),i??=o.getPropertyOptions(e),!((i.hasChanged??$L)(s,t)||i.useDefault&&i.reflect&&s===this._$Ej?.get(e)&&!this.hasAttribute(o._$Eu(e,i))))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:i,reflect:r,wrapped:s},o){i&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,o??t??this[e]),s!==!0||o!==void 0)||(this._$AL.has(e)||(this.hasUpdated||i||(t=void 0),this._$AL.set(e,t)),r===!0&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[r,s]of this._$Ep)this[r]=s;this._$Ep=void 0}let i=this.constructor.elementProperties;if(i.size>0)for(let[r,s]of i){let{wrapped:o}=s,a=this[r];o!==!0||this._$AL.has(r)||a===void 0||this.C(r,void 0,s,a)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(i=>i.hostUpdate?.()),this.update(t)):this._$EM()}catch(i){throw e=!1,this._$EM(),i}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(e){}firstUpdated(e){}};Ri.elementStyles=[],Ri.shadowRootOptions={mode:"open"},Ri[Al("elementProperties")]=new Map,Ri[Al("finalized")]=new Map,pV?.({ReactiveElement:Ri}),(mh.reactiveElementVersions??=[]).push("2.1.2");var Cb=globalThis,GL=n=>n,gh=Cb.trustedTypes,VL=gh?gh.createPolicy("lit-html",{createHTML:n=>n}):void 0,Tb="$lit$",Ii=`lit$${Math.random().toFixed(9).slice(2)}$`,Lb="?"+Ii,mV=`<${Lb}>`,ps=document,Rl=()=>ps.createComment(""),Il=n=>n===null||typeof n!="object"&&typeof n!="function",Mb=Array.isArray,ZL=n=>Mb(n)||typeof n?.[Symbol.iterator]=="function",Pb=`[ \f\r]`,kl=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,WL=/-->/g,jL=/>/g,ds=RegExp(`>|${Pb}(?:([^\\s"'>=/]+)(${Pb}*=${Pb}*(?:[^ -\f\r"'\`<>=]|("|')|))|$)`,"g"),HL=/'/g,YL=/"/g,XL=/^(?:script|style|textarea|title)$/i,Ab=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),ys=Ab(1),$ye=Ab(2),Gye=Ab(3),ms=Symbol.for("lit-noChange"),ke=Symbol.for("lit-nothing"),qL=new WeakMap,hs=ps.createTreeWalker(ps,129);function KL(n,e){if(!Mb(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return VL!==void 0?VL.createHTML(e):e}var QL=(n,e)=>{let t=n.length-1,i=[],r,s=e===2?"":e===3?"":"",o=kl;for(let a=0;a"?(o=r??kl,f=-1):u[1]===void 0?f=-2:(f=o.lastIndex-u[2].length,l=u[1],o=u[3]===void 0?ds:u[3]==='"'?YL:HL):o===YL||o===HL?o=ds:o===WL||o===jL?o=kl:(o=ds,r=void 0);let h=o===ds&&n[a+1].startsWith("/>")?" ":"";s+=o===kl?c+dV:f>=0?(i.push(l),c.slice(0,f)+Tb+c.slice(f)+Ii+h):c+Ii+(f===-2?a:h)}return[KL(n,s+(n[t]||"")+(e===2?"":e===3?"":"")),i]},Bl=class n{constructor({strings:e,_$litType$:t},i){let r;this.parts=[];let s=0,o=0,a=e.length-1,c=this.parts,[l,u]=QL(e,t);if(this.el=n.createElement(l,i),hs.currentNode=this.el.content,t===2||t===3){let f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(r=hs.nextNode())!==null&&c.length0){r.textContent=gh?gh.emptyScript:"";for(let h=0;h2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=ke}_$AI(e,t=this,i,r){let s=this.strings,o=!1;if(s===void 0)e=gs(this,e,t,0),o=!Il(e)||e!==this._$AH&&e!==ms,o&&(this._$AH=e);else{let a=e,c,l;for(e=s[0],c=0;c{let i=t?.renderBefore??e,r=i._$litPart$;if(r===void 0){let s=t?.renderBefore??null;i._$litPart$=r=new Go(e.insertBefore(Rl(),s),s,void 0,t??{})}return r._$AI(n),r};var kb=globalThis,oi=class extends Ri{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=e3(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return ms}};oi._$litElement$=!0,oi.finalized=!0,kb.litElementHydrateSupport?.({LitElement:oi});var pV=kb.litElementPolyfillSupport;pV?.({LitElement:oi});(kb.litElementVersions??=[]).push("4.2.2");var{I:nbe}=JL;var t3=n=>n.strings===void 0;var n3={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Rb=n=>(...e)=>({_$litDirective$:n,values:e}),wh=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}};var Ol=(n,e)=>{let t=n._$AN;if(t===void 0)return!1;for(let i of t)i._$AO?.(e,!1),Ol(i,e);return!0},Eh=n=>{let e,t;do{if((e=n._$AM)===void 0)break;t=e._$AN,t.delete(n),n=e}while(t?.size===0)},i3=n=>{for(let e;e=n._$AM;n=e){let t=e._$AN;if(t===void 0)e._$AN=t=new Set;else if(t.has(n))break;t.add(n),_V(e)}};function mV(n){this._$AN!==void 0?(Eh(this),this._$AM=n,i3(this)):this._$AM=n}function gV(n,e=!1,t=0){let i=this._$AH,r=this._$AN;if(r!==void 0&&r.size!==0)if(e)if(Array.isArray(i))for(let s=t;s{n.type==n3.CHILD&&(n._$AP??=gV,n._$AQ??=mV)},Sh=class extends wh{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,i){super._$AT(e,t,i),i3(this),this.isConnected=e._$AU}_$AO(e,t=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),t&&(Ol(this,e),Eh(this))}setValue(e){if(t3(this._$Ct))this._$Ct._$AI(e,this);else{let t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}};var Bi=()=>new Bb,Bb=class{},Ib=new WeakMap,Oi=Rb(class extends Sh{render(n){return ke}update(n,[e]){let t=e!==this.G;return t&&this.rt(void 0),(t||this.lt!==this.ct)&&(this.G=e,this.ht=n.options?.host,this.rt(this.ct=n.element)),ke}rt(n){if(this.G!==void 0)if(this.isConnected||(n=void 0),typeof this.G=="function"){let e=this.ht??globalThis,t=Ib.get(e);t===void 0&&(t=new WeakMap,Ib.set(e,t)),t.get(this.G)!==void 0&&this.G.call(this.ht,void 0),t.set(this.G,n),n!==void 0&&this.G.call(this.ht,n)}else this.G.value=n}get lt(){return typeof this.G=="function"?Ib.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});function Dl(n,e,t){return n?e(n):t?.(n)}var Ob=n=>n??ke;var Db=class extends oi{static properties={name:{type:String,reflect:!0},maximizable:{type:Boolean,reflect:!0},collapsible:{type:Boolean,reflect:!0},maximized:{type:Boolean,reflect:!0},collapsed:{type:Boolean,reflect:!0}};constructor(){super(),this.tabsRef=Bi(),this.contentRef=Bi(),this.headerRef=Bi(),this.controlsRef=Bi(),this.maximizeBtnRef=Bi(),this.collapseBtnRef=Bi(),this._onMaximizeClick=this._onMaximizeClick.bind(this),this._onCollapseClick=this._onCollapseClick.bind(this),this._onResetLayoutClick=this._onResetLayoutClick.bind(this)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.classList.add("ide-pane",`ide-pane-${this.paneName}`),this.performUpdate()}get paneName(){return this.name||this.getAttribute("name")||this.id.replace(/^pane-/,"")||"pane"}get tabsEl(){return this.hasUpdated||this.performUpdate(),this.tabsRef.value}get contentEl(){return this.hasUpdated||this.performUpdate(),this.contentRef.value}get headerEl(){return this.hasUpdated||this.performUpdate(),this.headerRef.value}get controlsEl(){return this.hasUpdated||this.performUpdate(),this.controlsRef.value}get maximizeBtn(){return this.hasUpdated||this.performUpdate(),this.maximizeBtnRef.value}get collapseBtn(){return this.hasUpdated||this.performUpdate(),this.collapseBtnRef.value}get _collapseIcon(){let e=this.paneName;return e==="bottom"?this.collapsed?"\u25B2":"\u25BC":e==="left"?this.collapsed?"\u25B6":"\u25C0":e==="right"?this.collapsed?"\u25C0":"\u25B6":"\u25BC"}get _collapseTitle(){let e=this.paneName,t=e.charAt(0).toUpperCase()+e.slice(1);return e==="bottom"?this.collapsed?"Expand Console":"Collapse Console":e==="left"?this.collapsed?"Expand Left Panel":"Collapse Left Panel":e==="right"?this.collapsed?"Expand Right Panel":"Collapse Right Panel":`Collapse ${t}`}_emit(e,t={}){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}_onMaximizeClick(e){e.stopPropagation(),this._emit("ide-pane-maximize",{pane:this.paneName})}_onCollapseClick(e){e.stopPropagation(),this._emit("ide-pane-collapse",{pane:this.paneName})}_onResetLayoutClick(e){e.stopPropagation(),this._emit("ide-layout-reset")}setMaximized(e){this.maximized=!!e,this.classList.toggle("maximized",this.maximized),this.maximizeBtn&&(this.maximizeBtn.textContent=this.maximized?"\u29C9":"\u2922",this.maximizeBtn.title=this.maximized?"Restore":"Maximize")}setCollapsed(e){this.collapsed=!!e,this.classList.toggle("collapsed",this.collapsed),this.collapseBtn&&(this.collapseBtn.textContent=this._collapseIcon,this.collapseBtn.title=this._collapseTitle)}build(){this.hasUpdated||this.performUpdate()}updated(e){super.updated(e),e.has("maximized")&&this.classList.toggle("maximized",!!this.maximized),e.has("collapsed")&&this.classList.toggle("collapsed",!!this.collapsed)}render(){let e=this.paneName,t=this.id||`pane-${e}`,i=this.maximizable||this.hasAttribute("maximizable"),r=this.collapsible||this.hasAttribute("collapsible");return ys` +\f\r"'\`<>=]|("|')|))|$)`,"g"),HL=/'/g,YL=/"/g,XL=/^(?:script|style|textarea|title)$/i,Ab=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),ys=Ab(1),jye=Ab(2),Hye=Ab(3),ms=Symbol.for("lit-noChange"),ke=Symbol.for("lit-nothing"),qL=new WeakMap,hs=ps.createTreeWalker(ps,129);function KL(n,e){if(!Mb(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return VL!==void 0?VL.createHTML(e):e}var QL=(n,e)=>{let t=n.length-1,i=[],r,s=e===2?"":e===3?"":"",o=kl;for(let a=0;a"?(o=r??kl,f=-1):u[1]===void 0?f=-2:(f=o.lastIndex-u[2].length,l=u[1],o=u[3]===void 0?ds:u[3]==='"'?YL:HL):o===YL||o===HL?o=ds:o===WL||o===jL?o=kl:(o=ds,r=void 0);let h=o===ds&&n[a+1].startsWith("/>")?" ":"";s+=o===kl?c+mV:f>=0?(i.push(l),c.slice(0,f)+Tb+c.slice(f)+Ii+h):c+Ii+(f===-2?a:h)}return[KL(n,s+(n[t]||"")+(e===2?"":e===3?"":"")),i]},Bl=class n{constructor({strings:e,_$litType$:t},i){let r;this.parts=[];let s=0,o=0,a=e.length-1,c=this.parts,[l,u]=QL(e,t);if(this.el=n.createElement(l,i),hs.currentNode=this.el.content,t===2||t===3){let f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(r=hs.nextNode())!==null&&c.length0){r.textContent=gh?gh.emptyScript:"";for(let h=0;h2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=ke}_$AI(e,t=this,i,r){let s=this.strings,o=!1;if(s===void 0)e=gs(this,e,t,0),o=!Il(e)||e!==this._$AH&&e!==ms,o&&(this._$AH=e);else{let a=e,c,l;for(e=s[0],c=0;c{let i=t?.renderBefore??e,r=i._$litPart$;if(r===void 0){let s=t?.renderBefore??null;i._$litPart$=r=new Go(e.insertBefore(Rl(),s),s,void 0,t??{})}return r._$AI(n),r};var kb=globalThis,oi=class extends Ri{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=e3(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return ms}};oi._$litElement$=!0,oi.finalized=!0,kb.litElementHydrateSupport?.({LitElement:oi});var _V=kb.litElementPolyfillSupport;_V?.({LitElement:oi});(kb.litElementVersions??=[]).push("4.2.2");var{I:obe}=JL;var t3=n=>n.strings===void 0;var n3={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Rb=n=>(...e)=>({_$litDirective$:n,values:e}),wh=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}};var Ol=(n,e)=>{let t=n._$AN;if(t===void 0)return!1;for(let i of t)i._$AO?.(e,!1),Ol(i,e);return!0},Eh=n=>{let e,t;do{if((e=n._$AM)===void 0)break;t=e._$AN,t.delete(n),n=e}while(t?.size===0)},i3=n=>{for(let e;e=n._$AM;n=e){let t=e._$AN;if(t===void 0)e._$AN=t=new Set;else if(t.has(n))break;t.add(n),vV(e)}};function yV(n){this._$AN!==void 0?(Eh(this),this._$AM=n,i3(this)):this._$AM=n}function bV(n,e=!1,t=0){let i=this._$AH,r=this._$AN;if(r!==void 0&&r.size!==0)if(e)if(Array.isArray(i))for(let s=t;s{n.type==n3.CHILD&&(n._$AP??=bV,n._$AQ??=yV)},Sh=class extends wh{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,i){super._$AT(e,t,i),i3(this),this.isConnected=e._$AU}_$AO(e,t=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),t&&(Ol(this,e),Eh(this))}setValue(e){if(t3(this._$Ct))this._$Ct._$AI(e,this);else{let t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}};var Bi=()=>new Bb,Bb=class{},Ib=new WeakMap,Oi=Rb(class extends Sh{render(n){return ke}update(n,[e]){let t=e!==this.G;return t&&this.rt(void 0),(t||this.lt!==this.ct)&&(this.G=e,this.ht=n.options?.host,this.rt(this.ct=n.element)),ke}rt(n){if(this.G!==void 0)if(this.isConnected||(n=void 0),typeof this.G=="function"){let e=this.ht??globalThis,t=Ib.get(e);t===void 0&&(t=new WeakMap,Ib.set(e,t)),t.get(this.G)!==void 0&&this.G.call(this.ht,void 0),t.set(this.G,n),n!==void 0&&this.G.call(this.ht,n)}else this.G.value=n}get lt(){return typeof this.G=="function"?Ib.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});function Dl(n,e,t){return n?e(n):t?.(n)}var Ob=n=>n??ke;var Db=class extends oi{static properties={name:{type:String,reflect:!0},maximizable:{type:Boolean,reflect:!0},collapsible:{type:Boolean,reflect:!0},maximized:{type:Boolean,reflect:!0},collapsed:{type:Boolean,reflect:!0}};constructor(){super(),this.tabsRef=Bi(),this.contentRef=Bi(),this.headerRef=Bi(),this.controlsRef=Bi(),this.maximizeBtnRef=Bi(),this.collapseBtnRef=Bi(),this._onMaximizeClick=this._onMaximizeClick.bind(this),this._onCollapseClick=this._onCollapseClick.bind(this),this._onResetLayoutClick=this._onResetLayoutClick.bind(this)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.classList.add("ide-pane",`ide-pane-${this.paneName}`),this.performUpdate()}get paneName(){return this.name||this.getAttribute("name")||this.id.replace(/^pane-/,"")||"pane"}get tabsEl(){return this.hasUpdated||this.performUpdate(),this.tabsRef.value}get contentEl(){return this.hasUpdated||this.performUpdate(),this.contentRef.value}get headerEl(){return this.hasUpdated||this.performUpdate(),this.headerRef.value}get controlsEl(){return this.hasUpdated||this.performUpdate(),this.controlsRef.value}get maximizeBtn(){return this.hasUpdated||this.performUpdate(),this.maximizeBtnRef.value}get collapseBtn(){return this.hasUpdated||this.performUpdate(),this.collapseBtnRef.value}get _collapseIcon(){let e=this.paneName;return e==="bottom"?this.collapsed?"\u25B2":"\u25BC":e==="left"?this.collapsed?"\u25B6":"\u25C0":e==="right"?this.collapsed?"\u25C0":"\u25B6":"\u25BC"}get _collapseTitle(){let e=this.paneName,t=e.charAt(0).toUpperCase()+e.slice(1);return e==="bottom"?this.collapsed?"Expand Console":"Collapse Console":e==="left"?this.collapsed?"Expand Left Panel":"Collapse Left Panel":e==="right"?this.collapsed?"Expand Right Panel":"Collapse Right Panel":`Collapse ${t}`}_emit(e,t={}){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}_onMaximizeClick(e){e.stopPropagation(),this._emit("ide-pane-maximize",{pane:this.paneName})}_onCollapseClick(e){e.stopPropagation(),this._emit("ide-pane-collapse",{pane:this.paneName})}_onResetLayoutClick(e){e.stopPropagation(),this._emit("ide-layout-reset")}setMaximized(e){this.maximized=!!e,this.classList.toggle("maximized",this.maximized),this.maximizeBtn&&(this.maximizeBtn.textContent=this.maximized?"\u29C9":"\u2922",this.maximizeBtn.title=this.maximized?"Restore":"Maximize")}setCollapsed(e){this.collapsed=!!e,this.classList.toggle("collapsed",this.collapsed),this.collapseBtn&&(this.collapseBtn.textContent=this._collapseIcon,this.collapseBtn.title=this._collapseTitle)}build(){this.hasUpdated||this.performUpdate()}updated(e){super.updated(e),e.has("maximized")&&this.classList.toggle("maximized",!!this.maximized),e.has("collapsed")&&this.classList.toggle("collapsed",!!this.collapsed)}render(){let e=this.paneName,t=this.id||`pane-${e}`,i=this.maximizable||this.hasAttribute("maximizable"),r=this.collapsible||this.hasAttribute("collapsible");return ys`
@@ -6405,7 +6405,7 @@ ${IL()} @click=${this._onCloseClick} >✕ `)} - `}};customElements.get("ide-pane")||customElements.define("ide-pane",Db);customElements.get("ide-splitter")||customElements.define("ide-splitter",Ch);customElements.get("ide-tab")||customElements.define("ide-tab",Fb);var r3={DisplayControls:{pane:"left",title:"Display Controls",closable:!1},LayoutViewer:{pane:"main",title:"Layout",closable:!1},SchematicWidget:{pane:"main",title:"Schematic",closable:!0},"3DViewer":{pane:"main",title:"3D Viewer",closable:!0},TclConsole:{pane:"bottom",title:"Tcl Console",closable:!1},Inspector:{pane:"right",title:"Inspector",closable:!0},Browser:{pane:"right",title:"Hierarchy",closable:!0},TimingWidget:{pane:"right",title:"Timing",closable:!0},DRCWidget:{pane:"right",title:"DRC",closable:!0},SelectHighlight:{pane:"right",title:"Select Highlight",closable:!0},ClockWidget:{pane:"right",title:"Clock Tree",closable:!0},ChartsWidget:{pane:"right",title:"Charts",closable:!0},HelpWidget:{pane:"right",title:"Help",closable:!0}},Ph={left:{cssVar:"--pane-left-width",defaultSize:"240px",minSize:140,maxFraction:.45,dimension:"width",isVertical:!0,invertDelta:!1},right:{cssVar:"--pane-right-width",defaultSize:"340px",minSize:160,maxFraction:.5,dimension:"width",isVertical:!0,invertDelta:!0},bottom:{cssVar:"--pane-bottom-height",defaultSize:"220px",minSize:70,maxFraction:.75,dimension:"height",isVertical:!1,invertDelta:!0}},Th=class{constructor(e){this.containerEl=e,this.factories=new Map,this.components=new Map,this.activeTabs={left:null,main:null,bottom:null,right:null},this.closedComponents=new Set,this.eventListeners=new Map,this._resizeScheduled=!1,this._ensureDOM(),this._initSplitters(),this._initControls(),this._initResizeObserver()}on(e,t){this.eventListeners.has(e)||this.eventListeners.set(e,new Set),this.eventListeners.get(e).add(t)}off(e,t){this.eventListeners.get(e)?.delete(t)}emit(e,...t){let i=this.eventListeners.get(e);if(i)for(let r of i)try{r(...t)}catch(s){console.error(s)}}_ensureDOM(){this.containerEl.classList.add("ide-layout"),this.containerEl.querySelector("#pane-left")||this._buildInitialLayoutTree(),this._resolvePaneReferences()}_buildInitialLayoutTree(){this.containerEl.appendChild(this._createGutterButton("left","\u25B6 Display Controls","Restore Display Controls")),this.containerEl.appendChild(this._createGutterButton("right","\u25C0 Tools & Inspector","Restore Right Panel")),this.containerEl.appendChild(this._createPane("pane-left","left")),this.containerEl.appendChild(this._createSplitter("splitter-left","left","vertical","Drag to resize panel"));let e=document.createElement("main");e.id="pane-center",e.className="ide-center",e.appendChild(this._createPane("pane-main","main",{maximizable:!0})),e.appendChild(this._createSplitter("splitter-bottom","bottom","horizontal","Drag to resize console")),e.appendChild(this._createGutterButton("bottom","\u25B2 Tcl Console","Restore Tcl Console")),e.appendChild(this._createPane("pane-bottom","bottom",{maximizable:!0,collapsible:!0})),this.containerEl.appendChild(e),this.containerEl.appendChild(this._createSplitter("splitter-right","right","vertical","Drag to resize panel")),this.containerEl.appendChild(this._createPane("pane-right","right",{maximizable:!0,collapsible:!0}))}_createGutterButton(e,t,i){let r=document.createElement("button");r.id=`gutter-expand-${e}`,r.className=`ide-gutter-expand ide-gutter-${e}`,r.title=i;let s=document.createElement("span");return s.textContent=t,r.appendChild(s),r}_createPane(e,t,i={}){let r=document.createElement("ide-pane");return r.id=e,r.setAttribute("name",t),i.maximizable&&r.setAttribute("maximizable",""),i.collapsible&&r.setAttribute("collapsible",""),r}_createSplitter(e,t,i,r){let s=document.createElement("ide-splitter");return s.id=e,s.setAttribute("for",t),s.setAttribute("orientation",i),s.title=r,s}_resolvePaneReferences(){let e=["left","main","bottom","right"];this.panes={};for(let t of e){let i=this.containerEl.querySelector(`#pane-${t}`);i?.build&&i.build(),this.panes[t]={el:i,paneComponent:i,tabsEl:i?.tabsEl||this.containerEl.querySelector(`#pane-${t}-tabs`),contentEl:i?.contentEl||this.containerEl.querySelector(`#pane-${t}-content`)}}this.centerEl=this.containerEl.querySelector("#pane-center")}_initSplitters(){let e=null;this.containerEl.addEventListener("ide-splitter-start",t=>{let i=t.detail?.for,r=Ph[i];if(!r)return;let o=(i==="bottom"?this.centerEl||this.containerEl:this.containerEl).getBoundingClientRect(),a=this.panes[i]?.el?.getBoundingClientRect()||{},c=r.dimension==="width"?o.width:o.height,l=r.dimension==="width"?a.width||240:a.height||220;e={paneName:i,cfg:r,startSize:l,maxLimit:Math.round(c*r.maxFraction)||500}}),this.containerEl.addEventListener("ide-splitter-drag",t=>{if(!e||e.paneName!==t.detail?.for)return;let{cfg:i,startSize:r,maxLimit:s}=e,o=i.invertDelta?-t.detail.delta:t.detail.delta,a=Math.round(r+o),c=Math.max(i.minSize,Math.min(s,a));this.containerEl.style.setProperty(i.cssVar,`${c}px`),this.notifyResize()}),this.containerEl.addEventListener("ide-splitter-end",()=>{e=null,this.saveLayout(),this.notifyResize()}),this.containerEl.addEventListener("ide-splitter-reset",t=>{let i=t.detail?.for;this._resetSplitterPane(i)}),this._setupFallbackSplitters()}_resetSplitterPane(e){let t=Ph[e];t&&(this.containerEl.style.setProperty(t.cssVar,t.defaultSize),this.isPaneCollapsed(e)?this.restorePane(e):(this.saveLayout(),this.notifyResize()))}_setupFallbackSplitters(){for(let[e,t]of Object.entries(Ph)){let i=this.containerEl.querySelector(`#splitter-${e}`);if(!i||i instanceof Ch)continue;let r=!t.invertDelta,s=t.isVertical;i.addEventListener("pointerdown",o=>{o.preventDefault();try{i.setPointerCapture(o.pointerId)}catch{}i.classList.add("dragging"),document.body&&document.body.classList.add("is-resizing",s?"is-resizing-v":"is-resizing-h");let a=s?o.clientX:o.clientY,l=(e==="bottom"?this.centerEl||this.containerEl:this.containerEl).getBoundingClientRect(),u=this.panes[e]?.el?.getBoundingClientRect()||{},f=t.dimension==="width"?u.width||240:u.height||220,d=t.dimension==="width"?l.width:l.height,h=Math.round(d*t.maxFraction)||500,p=new AbortController,{signal:m}=p,g=y=>{let b=s?y.clientX:y.clientY,x=r?b-a:a-b,E=Math.round(f+x),w=Math.max(t.minSize,Math.min(h,E));this.containerEl.style.setProperty(t.cssVar,`${w}px`),this.notifyResize()},v=y=>{try{i.releasePointerCapture(y.pointerId)}catch{}i.classList.remove("dragging"),document.body&&document.body.classList.remove("is-resizing","is-resizing-v","is-resizing-h"),p.abort(),this.saveLayout(),this.notifyResize()};window.addEventListener("pointermove",g,{signal:m}),window.addEventListener("pointerup",v,{signal:m}),window.addEventListener("pointercancel",v,{signal:m})}),i.addEventListener("dblclick",()=>{this._resetSplitterPane(e)})}}_initControls(){this.containerEl.addEventListener("ide-pane-maximize",t=>{this.toggleMaximize(t.detail?.pane)}),this.containerEl.addEventListener("ide-pane-collapse",t=>{this.toggleCollapse(t.detail?.pane)}),this.containerEl.addEventListener("ide-layout-reset",()=>{this.resetLayout()});for(let t of["left","right","bottom"]){let i=this.containerEl.querySelector(`#gutter-expand-${t}`);i&&i.addEventListener("click",()=>this.restorePane(t))}let e=[{sel:"#btn-collapse-left",handler:()=>this.toggleCollapse("left")},{sel:"#btn-collapse-right",handler:()=>this.toggleCollapse("right")},{sel:"#btn-collapse-bottom",handler:()=>this.toggleCollapse("bottom")},{sel:"#btn-maximize-main",handler:()=>this.toggleMaximize("main")},{sel:"#btn-maximize-bottom",handler:()=>this.toggleMaximize("bottom")},{sel:"#btn-maximize-right",handler:()=>this.toggleMaximize("right")},{sel:"#btn-empty-reset-layout",handler:()=>this.resetLayout()}];for(let{sel:t,handler:i}of e){let r=this.containerEl.querySelector(t);r&&!r.closest("ide-pane")&&r.addEventListener("click",i)}}isPaneMaximized(e){return e?this.containerEl.classList.contains(`maximized-${e}`):this.containerEl.classList.contains("maximized-main")||this.containerEl.classList.contains("maximized-bottom")||this.containerEl.classList.contains("maximized-right")}setMaximizedPane(e,t=!0){let i=["main","bottom","right"];if(e&&!i.includes(e))return!1;let r=t?e:null;for(let s of i){let o=s===r;this.containerEl.classList.toggle(`maximized-${s}`,o),this.panes[s]?.paneComponent?.setMaximized(o);let a=this.containerEl.querySelector(`#btn-maximize-${s}`);a&&(a.textContent=o?"\u29C9":"\u2922",a.title=o?"Restore":"Maximize")}return this.notifyResize(),!!r}maximizePane(e){return this.setMaximizedPane(e,!0)}restoreMaximized(){return this.setMaximizedPane(null,!1)}toggleMaximize(e){return this.setMaximizedPane(e,!this.isPaneMaximized(e))}isPaneCollapsed(e){let t=e==="bottom"?this.centerEl:this.containerEl;return t?t.classList.contains(`hide-${e}`):!1}_setPaneCollapsed(e,t){let i=e==="bottom"?this.centerEl:this.containerEl;if(!i)return;i.classList.toggle(`hide-${e}`,t),this.panes[e]?.paneComponent?.setCollapsed?.(t);let r=this.containerEl.querySelector(`#btn-collapse-${e}`);if(r){let o={bottom:{collapsed:"\u25B2",expanded:"\u25BC"},left:{collapsed:"\u25B6",expanded:"\u25C0"},right:{collapsed:"\u25C0",expanded:"\u25B6"}}[e]||{collapsed:"\u25B6",expanded:"\u25C0"};r.textContent=t?o.collapsed:o.expanded,r.title=t?`Expand ${e.charAt(0).toUpperCase()+e.slice(1)}`:`Collapse ${e.charAt(0).toUpperCase()+e.slice(1)}`}this.saveLayout(),this.notifyResize()}toggleCollapse(e){this._setPaneCollapsed(e,!this.isPaneCollapsed(e))}collapsePane(e){this._setPaneCollapsed(e,!0)}restorePane(e){this._setPaneCollapsed(e,!1)}_updateEmptyState(){let e=this.containerEl.querySelector("#ide-empty-state");if(!e)return;let t=!!this.activeTabs.main;e.style.display=t?"none":"flex"}resetLayout(){try{localStorage.removeItem("or_ide_layout")}catch{}for(let[e,t]of Object.entries(Ph))this.containerEl.style.setProperty(t.cssVar,t.defaultSize);for(let e of["left","right","bottom"])this.restorePane(e);this.restoreMaximized(),this.closedComponents.clear();for(let e of this.components.values())e.tabEl.style.display="",e.contentDiv.style.display="";this.components.has("DisplayControls")&&this.activateTab("DisplayControls"),this.components.has("LayoutViewer")&&this.activateTab("LayoutViewer"),this.components.has("TclConsole")&&this.activateTab("TclConsole"),this.components.has("Inspector")&&this.activateTab("Inspector"),this._updateEmptyState(),this.saveLayout(),this.notifyResize(),this.emit("stateChanged"),typeof app<"u"&&app.map&&setTimeout(()=>app.map.invalidateSize({animate:!1}),0)}_initResizeObserver(){typeof ResizeObserver<"u"&&new ResizeObserver(()=>{this.notifyResize()}).observe(this.containerEl)}registerComponentFactoryFunction(e,t){this.factories.set(e,t)}loadLayout(e){for(let[i,r]of Object.entries(r3)){let s=this.factories.get(i);s&&this._mountComponent(i,r.pane,r.title,r.closable,s)}let t=null;try{let i=localStorage.getItem("or_ide_layout");i&&(t=JSON.parse(i))}catch{}if(t){if(t.leftWidth&&this.containerEl.style.setProperty("--pane-left-width",`${t.leftWidth}px`),t.rightWidth&&this.containerEl.style.setProperty("--pane-right-width",`${t.rightWidth}px`),t.bottomHeight&&this.containerEl.style.setProperty("--pane-bottom-height",`${t.bottomHeight}px`),t.closed)for(let i of t.closed)this.closeComponent(i,!1);this.activateTab(t.activeTabs?.left||"DisplayControls"),this.activateTab(t.activeTabs?.main||"LayoutViewer"),this.activateTab(t.activeTabs?.bottom||"TclConsole"),this.activateTab(t.activeTabs?.right||"Inspector"),t.hideLeft&&this.collapsePane("left"),t.hideRight&&this.collapsePane("right"),t.hideBottom&&this.collapsePane("bottom")}else this.activateTab("DisplayControls"),this.activateTab("LayoutViewer"),this.activateTab("TclConsole"),this.activateTab("Inspector");this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}_mountComponent(e,t,i,r,s){if(this.components.has(e))return;let o=this.panes[t];if(!o)return;let a=document.createElement("div");a.className="ide-component-container",a.id=`cmp-${e}`,o.contentEl.appendChild(a);let c=document.createElement("ide-tab");c.id=`tab-${e}`,c.setAttribute("for",e),c.setAttribute("data-component",e),c.setAttribute("title",i),r&&c.setAttribute("closable",""),c.addEventListener("tab-select",()=>{this.activateTab(e)}),c.addEventListener("tab-close",()=>{this.closeComponent(e)}),o.tabsEl.appendChild(c);let l=new Map,u={element:a,get width(){return a.clientWidth},get height(){return a.clientHeight},title:i,on:(d,h)=>{l.has(d)||l.set(d,new Set),l.get(d).add(h)},off:(d,h)=>{l.get(d)?.delete(h)},fire:(d,...h)=>{let p=l.get(d);if(p)for(let m of p)try{m(...h)}catch(g){console.error(g)}},focus:()=>this.focusComponent(e),close:()=>this.closeComponent(e)},f={componentType:e,paneName:t,title:i,closable:r,tabEl:c,contentDiv:a,container:u};this.components.set(e,f);try{s(u)}catch(d){console.error(`Failed to initialize component ${e}:`,d)}}isComponentActive(e){return e?!!e.contentDiv?.classList.contains("active"):!1}_setComponentActive(e,t){if(!e)return;let i=!!t;e.tabEl?.setActive(i),e.contentDiv?.classList.toggle("active",i)}activateTab(e){let t=this.components.get(e);if(!t||!this.panes[t.paneName])return;["left","right","bottom"].includes(t.paneName)&&this.isPaneCollapsed(t.paneName)&&this.restorePane(t.paneName);let r=this.activeTabs[t.paneName];if(r&&r!==e){let s=this.components.get(r);s&&(this._setComponentActive(s,!1),s.container.fire("hide"))}this.activeTabs[t.paneName]=e,t.tabEl.style.display="",t.contentDiv.style.display="",this._setComponentActive(t,!0),this.closedComponents.delete(e),t.container.fire("show"),t.container.fire("open"),t.container.fire("resize"),typeof app<"u"&&(e==="LayoutViewer"&&app.map&&setTimeout(()=>app.map.invalidateSize({animate:!1}),0),e==="3DViewer"&&app.threeDViewerWidget&&setTimeout(()=>app.threeDViewerWidget.onOpen(),0));try{t.tabEl.scrollIntoView({behavior:"smooth",inline:"nearest",block:"nearest"})}catch{}this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}closeComponent(e,t=!0){let i=this.components.get(e);if(!(!i||!i.closable)){if(i.tabEl.style.display="none",i.contentDiv.style.display="none",this._setComponentActive(i,!1),i.container.fire("hide"),this.closedComponents.add(e),t&&this.activeTabs[i.paneName]===e){let r=null;for(let s of this.components.values())if(s.paneName===i.paneName&&!this.closedComponents.has(s.componentType)){r=s;break}r?this.activateTab(r.componentType):(this.activeTabs[i.paneName]=null,["left","right","bottom"].includes(i.paneName)&&this.collapsePane(i.paneName))}this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}}focusComponent(e){if(!this.components.get(e)){let i=this.factories.get(e);if(i){let r=r3[e]||{pane:"right",title:e,closable:!0};this._mountComponent(e,r.pane,r.title,r.closable,i)}else return}this.activateTab(e)}saveLayout(){let e={leftWidth:parseInt(this.containerEl.style.getPropertyValue("--pane-left-width")||"240",10),rightWidth:parseInt(this.containerEl.style.getPropertyValue("--pane-right-width")||"340",10),bottomHeight:parseInt(this.containerEl.style.getPropertyValue("--pane-bottom-height")||"220",10),hideLeft:this.isPaneCollapsed("left"),hideRight:this.isPaneCollapsed("right"),hideBottom:this.isPaneCollapsed("bottom"),activeTabs:{...this.activeTabs},closed:Array.from(this.closedComponents)};try{localStorage.setItem("or_ide_layout",JSON.stringify(e))}catch{}return e}notifyResize(){if(this._resizeScheduled)return;this._resizeScheduled=!0,(typeof requestAnimationFrame=="function"?requestAnimationFrame:t=>{t()})(()=>{this._resizeScheduled=!1;for(let t of this.components.values())this.isComponentActive(t)&&t.container.fire("resize");typeof app<"u"&&app&&app.map&&app.map.invalidateSize({animate:!1}),window.dispatchEvent(new Event("resize"))})}updateSize(){this.notifyResize()}setSize(e,t){this.notifyResize()}addComponent(e,t,i){this.focusComponent(e)}get rootItem(){return{contentItems:Array.from(this.components.keys()).map(e=>({isComponent:!0,componentType:e,focus:()=>this.focusComponent(e)}))}}};function Sn(n,e,t,i=0,r=0){return[(n-i)*t,(e-r)*t]}function Pn(n,e,t,i=0,r=0){return{dbuX:Math.round(i+n/t),dbuY:Math.round(r+e/t)}}function Nt(n,e,t,i,r,s=0,o=0){let[a,c]=Sn(n,e,r,s,o),[l,u]=Sn(t,i,r,s,o);return[Math.min(a,l),Math.min(c,u),Math.max(a,l),Math.max(c,u)]}var Nl=class n{constructor(e,t){this.url=e,this.socket=null,this.nextId=1,this.pending=new Map,this._queue=new Map,this._bgQueue=new Map,this._bgSent=new Set,this._inFlight=0,this._inFlightIds=new Set,this._unknownPayloadTypes=new Set,this._maxInFlight=48,this._lastRecvAt=0,this._bufStuckSince=0,this._lastBuffered=0,this.reconnectDelay=1e3,this.readyPromise=null,this.readyResolve=null,this.onStatusChange=t||(()=>{}),this.onPush=null,this._cache=null,this._isConnected=!1,this._shutdown=!1,this._livenessTimer=void 0,this._startLivenessMonitor(),this.connect()}get isConnected(){return this._isConnected||this.socket&&this.socket.readyState===WebSocket.OPEN}get pendingCount(){return this.pending.size-this._bgSent.size+(this._queue?this._queue.size:0)}static fromCache(e,t){let i=Object.create(n.prototype);return i.url=null,i.socket=null,i.nextId=1,i.pending=new Map,i._queue=new Map,i._bgQueue=new Map,i._bgSent=new Set,i._inFlight=0,i._inFlightIds=new Set,i._unknownPayloadTypes=new Set,i._maxInFlight=48,i._lastRecvAt=0,i.reconnectDelay=0,i.onStatusChange=t||(()=>{}),i.onPush=null,i._cache=e,i._isConnected=!0,i.readyPromise=Promise.resolve(),i.readyResolve=null,i}get isStaticMode(){return!!this._cache}connect(){this.readyPromise=new Promise(e=>{this.readyResolve=e}),this.socket=new WebSocket(this.url),this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{console.log("WebSocket connected");let e=this._everConnected===!0;this._everConnected=!0,this._isConnected=!0,this.reconnectDelay=1e3,this._lastRecvAt=typeof performance<"u"?performance.now():0,this.readyResolve(),this.onStatusChange(),this._pump(),e&&this.onReconnected&&this.onReconnected()},this.socket.onmessage=e=>{this.handleMessage(e.data)},this.socket.onclose=()=>this._handleClose(),this.socket.onerror=e=>{console.error("WebSocket error:",e)}}_handleClose(){this._isConnected=!1,this._inFlight=0,this._inFlightIds.clear(),this._bufStuckSince=0,this.onStatusChange();for(let[e,t]of this.pending)t.reject(new Error("WebSocket closed"));this.pending.clear(),this._bgSent.clear();for(let e of[this._queue,this._bgQueue]){for(let[t,i]of e)i.reject(new Error("WebSocket closed"));e.clear()}if(this._shutdown){console.log("WebSocket closed (server stopped)"),this._stopLivenessMonitor();return}console.log("WebSocket closed, reconnecting..."),setTimeout(()=>this.connect(),this.reconnectDelay),this.reconnectDelay=Math.min(this.reconnectDelay*2,3e4)}_forceReconnect(){let e=this.socket;if(this.socket=null,e){e.onopen=null,e.onmessage=null,e.onclose=null,e.onerror=null;try{e.close()}catch{}}this._handleClose()}handleMessage(e){let t=new DataView(e),i=t.getUint32(0),r=t.getUint8(4);if(this._lastRecvAt=typeof performance<"u"?performance.now():0,i===0&&r===0){let a=e.slice(8),c;try{c=JSON.parse(new TextDecoder().decode(a))}catch(l){console.error("Failed to parse server push JSON:",l);return}if(c&&c.type==="config"){Number.isFinite(c.max_in_flight)&&(this._maxInFlight=Math.max(1,Math.min(4096,Math.floor(c.max_in_flight))),this._pump());return}this.onPush&&this.onPush(c);return}this._inFlightIds.delete(i)&&this._inFlight>0&&this._inFlight--;let s=this.pending.get(i);if(!s){this._pump();return}this.pending.delete(i),this._bgSent.delete(i),this._pump(),this.onStatusChange();let o=e.slice(8);if(r===2)s.reject(new Error(new TextDecoder().decode(o)));else if(r===0)try{s.resolve(JSON.parse(new TextDecoder().decode(o)))}catch(a){s.reject(new Error("JSON parse error: "+a.message))}else r===1?s.resolve(new Blob([o],{type:"image/png"})):r===3?s.resolve(null):(this._unknownPayloadTypes.has(r)||(this._unknownPayloadTypes.add(r),console.warn(`Unrecognized websocket payload type ${r}. The server is likely newer than this page \u2014 reload to pick up the current client.`)),s.reject(new Error(`Unsupported websocket payload type ${r}`)))}request(e,{background:t=!1}={}){if(this._cache)return this._cacheRequest(e);let i=this.nextId++;if(e.id=i,!this.socket||this.socket.readyState!==WebSocket.OPEN)return Promise.reject(new Error("WebSocket not connected"));let r,s,o=new Promise((a,c)=>{r=a,s=c});return o.requestId=i,(t?this._bgQueue:this._queue).set(i,{msg:e,resolve:r,reject:s}),this._pump(),o}_pump(){if(!(!this.socket||this.socket.readyState!==WebSocket.OPEN)){for(;this._inFlight0||this._bgQueue.size>0)&&this.socket.bufferedAmount<524288;){let e=this._queue.size===0,t=e?this._bgQueue:this._queue,[i,r]=t.entries().next().value;t.delete(i),this.pending.set(i,{resolve:r.resolve,reject:r.reject}),e&&this._bgSent.add(i),this.socket.send(JSON.stringify(r.msg)),this._inFlightIds.add(i),this._inFlight++}this.onStatusChange()}}promote(e){let t=this._bgQueue.get(e);t?(this._bgQueue.delete(e),this._queue.set(e,t),this._pump()):this._bgSent.delete(e)&&this.onStatusChange()}cancel(e){let t=this._queue.get(e)||this._bgQueue.get(e);if(t){this._queue.delete(e),this._bgQueue.delete(e),t.reject(new Error("Request cancelled")),this.onStatusChange();return}let i=this.pending.get(e),r=this.pending.delete(e);this._bgSent.delete(e),i&&i.reject(new Error("Request cancelled")),r&&!this._cache&&this.socket&&this.socket.readyState===WebSocket.OPEN&&this.socket.send(JSON.stringify({type:"cancel",cancel_id:e,id:this.nextId++})),this.onStatusChange()}_startLivenessMonitor(){typeof setInterval>"u"||(this._livenessTimer=setInterval(()=>this._checkLiveness(),3e3),this._livenessTimer&&typeof this._livenessTimer.unref=="function"&&this._livenessTimer.unref())}_stopLivenessMonitor(){this._livenessTimer!==void 0&&typeof clearInterval<"u"&&(clearInterval(this._livenessTimer),this._livenessTimer=void 0)}_checkLiveness(){if(this._cache)return;let e=this.socket;if(!e||e.readyState!==WebSocket.OPEN){this._bufStuckSince=0,this._lastBuffered=0;return}let t=e.bufferedAmount,i=typeof performance<"u"?performance.now():0,r=!1,s="";t<=262144||t12e3&&(r=!0,s=`send buffer stuck at ${t}B for ${Math.round(i-this._bufStuckSince)}ms`),this._lastBuffered=t,!r&&this._inFlight>=this._maxInFlight&&this._queue.size+this._bgQueue.size>0&&this._lastRecvAt>0&&i-this._lastRecvAt>3e4&&(r=!0,s=`saturated (${this._inFlight} in flight, ${this._queue.size} queued) but silent for ${Math.round(i-this._lastRecvAt)}ms`),r&&(console.warn(`WebSocket connection wedged \u2014 ${s}; reconnecting to recover`),this._bufStuckSince=0,this._forceReconnect())}_cacheRequest(e){let t=e.type;if(t==="tile"){let s=e.layer+"/"+e.z+"/"+e.x+"/"+e.y,o=this._cache.tiles&&this._cache.tiles[s];return o?Promise.resolve("data:image/png;base64,"+o):Promise.reject(new Error("Tile not cached: "+s))}if(t==="timing_highlight"){let s=e.path_index;if(s>=0&&this._cache.overlays){let o=e.is_setup?"setup":"hold",a=this._cache.overlays[o]?.[s];this._cache.setPathOverlay&&this._cache.setPathOverlay(a?"data:image/png;base64,"+a:null)}else this._cache.setPathOverlay&&this._cache.setPathOverlay(null);return Promise.resolve({})}if(t==="set_module_colors")return Promise.resolve({ok:1,count:0});let i=t;t==="timing_report"?i="timing_report:"+(e.is_setup?"setup":"hold"):t==="slack_histogram"&&(i="slack_histogram:"+(e.is_setup?"setup":"hold"));let r=this._cache.json&&this._cache.json[i];if(r!==void 0){if(t==="timing_report"&&e.slack_min!=null&&e.slack_max!=null&&r.paths){let s=[];return r.paths.forEach((o,a)=>{o.slack>=e.slack_min&&o.slacko||a>c?null:{z:e,x0:s,x1:o,y0:a,y1:c}}function Ub([n,e,t,i],r){let s=(t-n)*r,o=(i-e)*r;return[n-s,e-o,t+s,i+o]}function Ah(n,e=1){if(!n)return null;let t=Math.pow(2,n.z);return{z:n.z,x0:Math.max(0,n.x0-e),x1:Math.min(t-1,n.x1+e),y0:Math.max(0,n.y0-e),y1:Math.min(t-1,n.y1+e)}}function St(n,e,t){return!!n&&e>=n.x0&&e<=n.x1&&t>=n.y0&&t<=n.y1}function zl(n){if(!n)return[];let e=(n.x0+n.x1)/2,t=(n.y0+n.y1)/2,i=[];for(let r=n.y0;r<=n.y1;r++)for(let s=n.x0;s<=n.x1;s++)i.push({z:n.z,x:s,y:r,d:(s-e)**2+(r-t)**2});return i.sort((r,s)=>r.d-s.d),i.map(({z:r,x:s,y:o})=>({z:r,x:s,y:o}))}function o3(n,e,t,i){let r=i/Math.pow(2,n);return[e*r,i-(t+1)*r,(e+1)*r,i-t*r]}function $b(n,e){return n[0]Math.log2(s/T);if(p<1e-12){let T=Math.log(f/u)/t;return{S:Math.abs(T),at:R=>({target:[o+R*d,a+R*h],zoom:m(u*Math.exp(t*R*T))})}}let g=Math.sqrt(p),v=(f*f-u*u+r*p)/(2*u*i*g),y=(f*f-u*u-r*p)/(2*f*i*g),b=Math.log(Math.sqrt(v*v+1)-v),E=(Math.log(Math.sqrt(y*y+1)-y)-b)/t,w=Math.cosh(b);return{S:E,at:T=>{if(T>=1)return{target:[c,l],zoom:e.zoom};let R=T*E,F=u/(i*g)*(w*Math.tanh(t*R+b)-Math.sinh(b));return{target:[o+F*d,a+F*h],zoom:m(u*w/Math.cosh(t*R+b))}}}}function Ho(n,e,t){return`${n}/${e}/${t}`}var kh=class{constructor({source:e,onChange:t=()=>{},keepBuffer:i=2}={}){this.source=e,this.onChange=t,this.keepBuffer=i,this.tiles=new Map,this.z=null,this.range=null,this.ring=null,this.extra=[],this._generation=0,this._loads=0,this._cancels=0}update({z:e,range:t,ring:i=t,extra:r=[],hold:s=null}){this.z=e,this.range=t,this.ring=i,this.extra=r.filter(c=>c.z!==e&&c.range);let o=new Map(this.extra.map(c=>[c.z,c]));for(let c of[...this.tiles.values()]){if(c.z!==e){let l=o.get(c.z),u=l&&l.range;(u?!St(u,c.x,c.y)&&(c.loading||!this._inKeepBuffer(c,u)):c.loading&&!c.drawable)?this._drop(c):u&&this._stale(c)&&St(u,c.x,c.y)&&this._load(c,l.background!==!1);continue}if(this._stale(c)&&St(i,c.x,c.y)&&this._load(c,!St(t,c.x,c.y)),St(i,c.x,c.y)){c.loading&&c.background&&St(t,c.x,c.y)&&(c.background=!1,c.handle?.promote?.());continue}(c.loading||!(this._inKeepBuffer(c)||s&&St(s,c.x,c.y)))&&this._drop(c)}let a=[...zl(t),...zl(i).filter(c=>!St(t,c.x,c.y))];for(let{x:c,y:l}of a)this.tiles.has(Ho(e,c,l))||this._load(this._newTile(e,c,l),!St(t,c,l));for(let c of this.extra)for(let{x:l,y:u}of zl(c.range))this.tiles.has(Ho(c.z,l,u))||this._load(this._newTile(c.z,l,u),c.background!==!1)}refresh(){this._generation++;let e=new Map(this.extra.map(t=>[t.z,t]));for(let t of[...this.tiles.values()]){let i=e.get(t.z),r=t.z===this.z?this.ring:i&&i.range;r&&(St(r,t.x,t.y)?(t.handle?.cancel?.(),this._load(t,i?i.background!==!1:!St(this.range,t.x,t.y))):t.loading&&this._drop(t))}}isSettled(){for(let e of this.tiles.values())if(e.z===this.z&&e.loading&&St(this.range,e.x,e.y))return!1;return!0}settledIn(e,t){for(let{x:i,y:r}of zl(t)){let s=this.tiles.get(Ho(e,i,r));if(!s||s.loading)return!1}return!0}hasContentAt(e){for(let t of this.tiles.values())if(t.z===e&&t.drawable)return!0;return!1}drawableTilesAt(e){let t=[];for(let i of this.tiles.values())i.z===e&&i.drawable&&t.push(i);return t}prune(e){let t=new Set(e);for(let i of[...this.tiles.values()])t.has(i.z)||this._drop(i)}clear(){for(let e of[...this.tiles.values()])this._drop(e);this.z=null,this.range=null,this.ring=null,this.extra=[]}stats(){let e=0,t=0;for(let i of this.tiles.values())i.loading&&e++,i.drawable&&t++;return{tiles:this.tiles.size,loading:e,drawable:t,loads:this._loads,cancels:this._cancels}}_newTile(e,t,i){let r={z:e,x:t,y:i,key:Ho(e,t,i),drawable:null,loading:!1,background:!1,handle:null,generation:-1};return this.tiles.set(r.key,r),r}_load(e,t){let i=this._generation,r=()=>this.tiles.get(e.key)===e&&e.generation===i;e.generation=i,e.loading=!0,e.background=t,this._loads++;let s=this.source.load({z:e.z,x:e.x,y:e.y},{background:t,onPartial:o=>{if(!r()){this.source.release?.(o);return}this._setDrawable(e,o),this.onChange(e)}});e.handle=s,s.promise.then(o=>{if(!r()){this.source.release?.(o);return}o!==void 0&&this._setDrawable(e,o),e.loading=!1,e.handle=null,this.onChange(e)},()=>{r()&&(e.loading=!1,e.handle=null,this.onChange(e))})}_setDrawable(e,t){e.drawable&&e.drawable!==t&&this.source.release?.(e.drawable),e.drawable=t||null}_stale(e){return!e.loading&&e.generation!==this._generation}_inKeepBuffer(e,t=this.range){return St(Ah(t,this.keepBuffer),e.x,e.y)}_drop(e){e.loading&&(this._cancels++,e.handle?.cancel?.()),e.drawable&&this.source.release?.(e.drawable),e.drawable=null,e.loading=!1,this.tiles.delete(e.key)}};function yV(n){return!Number.isFinite(n)||n<=1?1:Math.round(Math.min(n,3)*100)/100}var Di=240,bV=256,Gb=Di;function on(){return Gb}function l3(){Gb=bV}var Ibe=1/64,Vb=120;function u3(n){Gb=n}function Wb(n,e){return Math.max(1,Math.round(n*e))}function Yo(){let n=typeof window<"u"&&window.devicePixelRatio?window.devicePixelRatio:1;return!Number.isFinite(n)||n<=1?1:Math.min(n,3)}function Rh(n,e=on()){return{dpr:yV(n),tile_px:Wb(e,n)}}function f3(n,e,t,i=on()){let{selectability:r,selectableLayers:s,app:o}=e,a={...h3(n,e,t,i),selectable_layers:s?[...s]:[]};if(r)for(let[c,l]of Object.entries(r))a["s_"+c]=!!l;return c=>{let l={type:"tile",layer:c,...a},u=p3(o,c);return u!==1&&(l.pattern=u),l}}function d3(n,e,t,i,r=on()){let s={type:"tile_group",layers:[...e],...h3(n,t,i,r)},o=e.map(a=>p3(t.app,a));return o.some(a=>a!==1)&&(s.patterns=o),s}function h3(n,e,t,i){let{visibility:r,visibleLayers:s,app:o}=e,a={z:n.z,x:n.x,y:n.y,...Rh(t,i),visible_layers:s?[...s]:[]};for(let[c,l]of Object.entries(r||{}))a[c]=!!l;return o&&o.visibleChiplets instanceof Set&&(a.visible_chiplets=[...o.visibleChiplets]),a}function p3(n,e){let t=n&&n.layerPatterns?n.layerPatterns[e]:void 0;return t===void 0?1:t}function m3(n){if(typeof window>"u"||typeof window.matchMedia!="function"||typeof n!="function")return()=>{};let e=!1,t=null,i=null,r=()=>{if(e)return;let s=window.devicePixelRatio||1;t=window.matchMedia(`(resolution: ${s}dppx)`),i=()=>{e||(r(),n(window.devicePixelRatio||1))},t.addEventListener("change",i,{once:!0})};return r(),()=>{e=!0,t&&i&&t.removeEventListener("change",i),t=null,i=null}}function g3(n,e){if(!n)return!1;let t=!!e;return!!n.visible===t?!1:(n.visible=t,!0)}function _3(n,e,t){if(!n||!(t>0))return 0;n.clearRect(0,0,t,t);let i=0;for(let r of e||[]){let s=r?r.image:null;if(!s)continue;let o=r.opacity===void 0?1:r.opacity;o>0&&(n.globalAlpha=Math.min(1,o),n.drawImage(s,0,0,t,t),i++)}return n.globalAlpha=1,i}function jb(n){for(let e of n||[])e&&typeof e.close=="function"&&e.close()}async function y3({items:n,request:e,decode:t,draw:i,release:r=jb,isStale:s=()=>!1,incremental:o=!0}={}){let a=Array.isArray(n)?n:[],c={requested:a.length,arrived:0,decoded:0,drawn:0,paints:0,failed:0,stale:!1};if(a.length===0)return typeof i=="function"&&i([]),c;let l=new Array(a.length).fill(null),u=!1;function f(){if(s()){c.stale=!0;return}c.drawn=i(a.map((d,h)=>({image:l[h],opacity:d.opacity})))||0,c.paints++,u=!0}try{await Promise.all(a.map(async(d,h)=>{let p=null;try{p=await e(d)}catch{c.failed++;return}if(p==null)return;c.arrived++;let m=null;try{m=await t(p)}catch{return}m&&(l[h]=m,c.decoded++,o&&f())})),u||f()}finally{r(l)}return c}var vV=["tracks_pref","tracks_non_pref","debug","debug_renderers"],xV=1/16;function Hb(n,e){if(n==null)return!1;if(!Array.isArray(n)||n.length!==4||!e)return!0;let t=Math.pow(2,e.z),i=xV/t,r=e.x/t-i,s=e.y/t-i,o=(e.x+1)/t+i,a=(e.y+1)/t+i,[c,l,u,f]=n;return c<=o&&u>=r&&l<=a&&f>=s}function wV(n,e,t){let i=n&&Array.isArray(n.by_size)?n.by_size:[];if(i.length===0||!e||!(t>0))return!0;let r=n.min_css_px/(t*Math.pow(2,e.z)),s=i[0];for(let o of i)o[0]<=r&&(s=o);return Hb(s[1],e)}var Ih=class{constructor(){this._layers=null,this._gated=new Map,this._sized=new Map,this._generation=0}invalidate(){return this._generation++,this._layers=null,this._gated=new Map,this._sized=new Map,this._generation}apply(e,t){if(e!==this._generation)return!1;if(!t||t.supported!==!0||!t.layers||typeof t.layers!="object")return this._layers=null,!1;let i=new Map;if(t.gated&&typeof t.gated=="object")for(let[r,s]of Object.entries(t.gated))s&&typeof s=="object"&&i.set(r,new Map(Object.entries(s)));return this._layers=new Map(Object.entries(t.layers)),this._gated=i,this._sized=new Map(t.sized&&typeof t.sized=="object"?Object.entries(t.sized):[]),!0}refetch(e){let t=this.invalidate();return Promise.resolve().then(()=>e({type:"layer_extents"})).then(i=>this.apply(t,i)).catch(()=>!1)}mayHaveContent(e,t,i,r=256){if(!this._layers||i&&vV.some(s=>i[s]))return!0;if(this._sized.has(e))return wV(this._sized.get(e),t,r);if(!this._layers.has(e)||Hb(this._layers.get(e),t))return!0;for(let[s,o]of this._gated)if(!(i&&i[s]===!1)&&o.has(e)&&Hb(o.get(e),t))return!0;return!1}};function b3(n,e,t){let i=n&&n.app&&n.app.layerExtents;return i?i.mayHaveContent(e,t,n.visibility,on()):!0}function v3(n){return n==null?Promise.resolve(null):typeof n=="string"?new Promise(e=>{let t=document.createElement("img");t.onload=()=>e(t),t.onerror=()=>e(null),t.src=n}):createImageBitmap(n,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).catch(()=>null)}function Yb(n){jb([n&&n.image])}function EV(n){return{width:n.naturalWidth||n.width,height:n.naturalHeight||n.height}}function Bh(n){return n?{image:n,...EV(n)}:null}function SV(n){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(n,n);let e=document.createElement("canvas");return e.width=n,e.height=n,e}function qb(n){let e=document.createElement("canvas");return e.width=n.width,e.height=n.height,e.getContext("2d").drawImage(n,0,0),e}function PV(n){return typeof n.transferToImageBitmap=="function"?Bh(n.transferToImageBitmap()):Bh(qb(n))}var x3=Object.freeze({promise:Promise.resolve(null),cancel(){},promote(){}});function w3(n,e,t,i){let r=n.request(t,{background:i});return r.requestId!=null&&e.push(r.requestId),r}function E3(n,e,t,i){return{promise:t,cancel(){i();for(let r of e)n.cancel(r)},promote(){for(let r of e)n.promote?.(r)}}}var S3=3;function CV(n,e){let t=new Map,i=0,r=0;for(let s of n)if(!(!s||t.has(s.layer))){if(s.layer.startsWith("_")){t.set(s.layer,null),i++,r=0;continue}t.set(s.layer,`${i}:${Math.floor(r++/e)}`)}return t}function TV(n,e,t,i,r,s,o,a){let c=CV(n,t),l=[],u=null,f=()=>{u&&(l.push({opacity:1,msg:d3(r,u.layers,s,o,a)}),u=null)};for(let d of e){let h=c.get(d.layer);if(h==null){f(),l.push({opacity:1,msg:i(d.layer)});continue}u&&u.id!==h&&f(),u=u||{id:h,layers:[]},u.layers.push(d.layer)}return f(),l}function P3({wm:n,ctx:e,getItems:t,dpr:i=()=>1,tileSize:r=()=>240,isDoubleBuffer:s=()=>!0,decode:o=v3,makeCanvas:a=SV,snapshot:c=PV,groupLayers:l=()=>0}){return{load({z:u,x:f,y:d},{background:h=!1,onPartial:p}={}){let m=t()||[],g=m.filter(X=>X&&X.visible!==!1&&b3(e,X.layer,{z:u,x:f,y:d})),v=i(),y=r(),b=new Set,x=g.filter(X=>!b.has(X.layer)&&b.add(X.layer));if(x.length===0)return x3;let E=f3({z:u,x:f,y:d},e,v,y),w=l(),T=w>0&&x.every(X=>(X.opacity??1)===1)?TV(m,x,w,E,{z:u,x:f,y:d},e,v,y):x.map(X=>({opacity:X.opacity,msg:E(X.layer)})),R=Wb(y,v),F=null,O=null,j=[],V=!1,G=!s()&&typeof p=="function",q=y3({items:T,request:X=>w3(n,j,X.msg,h),decode:o,draw:X=>{if(!F){if(!X.some(le=>le.image))return 0;F=a(R),O=F.getContext("2d")}let se=_3(O,X,R);return G&&se>0&&!V&&p(c(F)),se},isStale:()=>V,incremental:G}).then(X=>{if(V)throw new Error("Tile cancelled");if(X.failed===X.requested)throw new Error("Tile requests failed");return X.drawn===0?null:G?void 0:c(F)});return E3(n,j,q,()=>{V=!0})},release:Yb}}function Zb({wm:n,buildRequest:e,dpr:t=()=>1,tileSize:i=()=>240,decode:r=v3}){return{load({z:s,x:o,y:a},{background:c=!1}={}){let l=e({z:s,x:o,y:a},t(),i());if(!l)return x3;let u=[],f=!1,d=w3(n,u,l,c).then(h=>r(h)).then(h=>{if(f)throw Yb(Bh(h)),new Error("Tile cancelled");return Bh(h)});return E3(n,u,d,()=>{f=!0})},release:Yb}}function C3({z:n,x:e,y:t},i,r,s,o){let a={type:"overlay_tile",z:n,x:e,y:t,...Rh(i,r),debug_renderers:!!s.debug_renderers,debug_live:!!s.debug_live,flywires_only:!!s.flywires_only,poly_decomp:!!(o&&o.polyDecomp),focused_nets_guides:!!s.focused_nets_guides,highlight_selected:s.highlight_selected!==!1,draw_labels:s.labels!==!1};return o&&o.visibleLayerNames&&(a.visible_layers=[...o.visibleLayerNames]),a}function T3({z:n,x:e,y:t},i,r,s){let o=s&&s.activeHeatMap;return o?{type:"heatmap_tile",name:o,z:n,x:e,y:t,...Rh(i,r)}:null}function fe(n){return!!n?.websocketManager?.isStaticMode}function k3(n,e){let t={};for(let[i,r]of Object.entries(n||{}))t[i]=!!r;for(let[i,r]of Object.entries(e||{}))t["s_"+i]=!!r;return t}function qo(n,e){e&&typeof e.sel_has_inst=="boolean"&&(n.selHasInst=e.sel_has_inst,n.selHasNet=!!e.sel_has_net)}var Xb=null;function Ft(n,e=4e3){let t=document.getElementById("or-toast");return t||(t=document.createElement("div"),t.id="or-toast",document.body.appendChild(t)),t.textContent=n,t.classList.add("visible"),Xb&&clearTimeout(Xb),Xb=setTimeout(()=>t.classList.remove("visible"),e),t}function R3(n){return!n||n.gpuType!=="cpu"?null:"Software rendering detected (reduced performance). Make sure 'Use graphics acceleration when available' (or 'Use hardware acceleration when available') is turned on in your browser settings, then restart the browser."}function I3({title:n,message:e,confirmLabel:t="OK",danger:i=!1}){return new Promise(r=>{let s=document.createElement("div");s.className="or-modal-overlay";let o=document.createElement("div");o.className="or-modal";let a=document.createElement("div");a.className="or-modal-title",a.textContent=n;let c=document.createElement("div");c.className="or-modal-message",c.textContent=e;let l=document.createElement("div");l.className="or-modal-buttons";let u=document.createElement("button");u.className="or-btn",u.textContent="Cancel";let f=document.createElement("button");f.className="or-btn"+(i?" or-btn-danger":""),f.textContent=t;let d=p=>{document.removeEventListener("keydown",h,!0),s.remove(),r(p)},h=p=>{p.key==="Escape"&&(p.stopPropagation(),d(!1))};u.addEventListener("click",()=>d(!1)),f.addEventListener("click",()=>d(!0)),s.addEventListener("click",p=>{p.target===s&&d(!1)}),document.addEventListener("keydown",h,!0),l.appendChild(u),l.appendChild(f),o.appendChild(a),o.appendChild(c),o.appendChild(l),s.appendChild(o),document.body.appendChild(s),u.focus()})}var LV=.05;function MV([[n,e],[t,i]],r){let s=(i-e)*r,o=(t-n)*r;return[[n-o,e-s],[t+o,i+s]]}function Kb(n,e=256,t=null){if(!L3(n))return null;let i=n[0][0],r=n[0][1],s=Math.max(n[1][1]-r,n[1][0]-i),o=e/s,a=L3(t)?t:n,[[c,l],[u,f]]=MV(a,LV);return{scale:o,maxDXDY:s,originX:r,originY:i,fitRect:Nt(l,c,f,u,o,r,i)}}function L3(n){return!!n&&n[1][0]>n[0][0]&&n[1][1]>n[0][1]}function B3(n,e){return!!n&&!!e&&n[0][0]===e[0][0]&&n[0][1]===e[0][1]&&n[1][0]===e[1][0]&&n[1][1]===e[1][1]}function Pt(n){n.selectionToken=(n.selectionToken||0)+1;for(let e of n.selectionResetters||[])e();return n.selectionToken}function zt(n,e){return n.selectionToken===e}function O3(n,e){n.selectionResetters||(n.selectionResetters=[]),n.selectionResetters.push(e)}var Qb=80,Ul=10,$l=1e3;function Gl(n){let e=n===""||n===null?NaN:Math.round(Number(n));return Number.isFinite(e)?Math.min($l,Math.max(Ul,e)):Qb}function vs(n="vis-group-header"){let e=document.createElement("div");e.className=n;let t=document.createElement("span");t.className="vis-arrow",e.appendChild(t);let i=document.createElement("span");return i.className="vis-name",e.appendChild(i),{header:e,arrow:t,name:i}}function xs(n,e,t,i){let r=s=>{t.classList.toggle("collapsed",s),e.textContent=s?"\u25B6":"\u25BC"};r(!!i),n.addEventListener("click",s=>{let o=s.target&&s.target.parentNode===n&&s.target.classList&&s.target.classList.contains("vis-name");s.target!==n&&s.target!==e&&!o||r(!t.classList.contains("collapsed"))})}var M3=30;function D3(n,e=8){if(!Number.isFinite(n)||n<=0)return M3;let t=Math.ceil(Math.log2(e/n));return Math.max(1,Math.min(M3,t))}function N3({designBounds:n,fitRect:e,viewW:t,viewH:i}){let r=Kb(n,Di,e),s=h=>Number.isFinite(h)&&h>0;if(!r||!s(t)||!s(i))return Di;let o=r.fitRect[2]-r.fitRect[0],a=r.fitRect[3]-r.fitRect[1],c=Math.min(t/o,i/a),l=Math.log2(c);if(!Number.isFinite(l)||l<0)return Di;let u=Math.floor(l),f=Di*2**(l-u),d=Math.floor(f/Vb)*Vb;return d>Di&&Math.log2(Di*c/d)>=u?d:Di}function F3(n,{showDbu:e,dbuPerMicron:t},i=!1){if(e)return String(Math.round(n));let r=t>0?t:1e3,s=Math.ceil(Math.log10(r)),o=(n/r).toFixed(s);return i?o+" \xB5m":o}function z3(n,{showDbu:e,dbuPerMicron:t}){let i=parseFloat(n);if(!Number.isFinite(i))return null;if(e)return Math.round(i);let r=t>0?t:1e3;return Math.round(i*r)}function U3(n,{showDbu:e,dbuPerMicron:t}){if(e)return String(Math.round(n));let i=t>0?t:1e3,r=n/i;return r>=1e3?(r/1e3).toFixed(3)+" mm":r>=1?r.toFixed(3)+" um":(r*1e3).toFixed(1)+" nm"}function $3({showDbu:n}){return n?"DBU":"\xB5m"}function Zo(n){return typeof n=="string"&&/^#[0-9a-fA-F]{6}$/.test(n)}function G3(n){if(typeof n!="string")return null;let e=n.trim();if(Zo(e))return e.toLowerCase();let t=e.match(/^#([0-9a-fA-F]{3})$/);if(t)return"#"+t[1].split("").map(r=>r+r).join("").toLowerCase();let i=e.match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/);if(i){let r=i.slice(1).map(Number);return r.some(s=>s>255)?null:"#"+r.map(s=>s.toString(16).padStart(2,"0")).join("")}return null}function ur(n,e=t=>requestAnimationFrame(t)){let t=!1;return()=>{t||(t=!0,e(()=>{t=!1,n()}))}}function Vl(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function A3(n){let e=Math.pow(10,Math.floor(Math.log10(n))),t=n/e,i;return t<1.5?i=1:t<3.5?i=2:t<7.5?i=5:i=10,{value:i*e,digit:i}}function V3({targetPx:n,pxPerDbu:e,dbuPerMicron:t,showDbu:i}){if(!Number.isFinite(e)||e<=0||!Number.isFinite(n)||n<=0)return null;let r,s,o;if(i){let c=A3(Math.max(1,n/e));o=c.digit,r=Math.round(c.value*e),s=String(Math.round(c.value))}else{let c=Number.isFinite(t)&&t>0?t:1e3,l=e*c,u=A3(n/l);o=u.digit;let f=u.value;r=Math.round(f*l);let d,h;f>=1e3?(d=1/1e3,h="mm"):f>=1?(d=1,h="\xB5m"):f>=.001?(d=1e3,h="nm"):(d=1e6,h="pm"),s=Math.round(f*d)+" "+h}return{barPx:r,label:s,segments:o===1?5:o}}function Wl(n,e,t){return e?typeof n.runTclScript=="function"?n.runTclScript(e,t):(t&&typeof n.echoTcl=="function"&&n.echoTcl(e),n.websocketManager.request({type:"tcl_eval",cmd:e}).catch(()=>{})):Promise.resolve()}function ws(n,e){let t=n.querySelectorAll("thead th");(!e||!e[0])&&(n.style.tableLayout="auto",t.forEach(i=>i.style.width=""),e=Array.from(t,i=>i.offsetWidth+"px")),t.forEach((i,r)=>i.style.width=e[r]||""),n.style.tableLayout="fixed",t.forEach((i,r)=>{if(r===t.length-1)return;let s=document.createElement("div");s.className="col-resize-grip",i.style.position="relative",i.appendChild(s);let o,a,c=u=>{i.style.width=Math.max(30,a+u.clientX-o)+"px"},l=()=>{document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",l);let u=f=>f.stopPropagation();document.addEventListener("click",u,{capture:!0,once:!0}),setTimeout(()=>{document.removeEventListener("click",u,{capture:!0})},0)};s.addEventListener("mousedown",u=>{u.preventDefault(),o=u.clientX,a=i.offsetWidth,document.addEventListener("mousemove",c),document.addEventListener("mouseup",l)})})}var AV={Layout:'',Schematic:'',"3D Viewer":'',"Display Controls":'',Inspector:'',Hierarchy:'',Timing:'',DRC:'',"Select Highlight":'',"Clock Tree":'',Charts:'',"Tcl Console":'',Help:''};function kV(n){let e=AV[n];if(!e)return null;let t=document.createElement("span");return t.className="or-tab-icon",t.innerHTML='",t}function W3(n=document){let e=0;for(let t of n.querySelectorAll(".lm_tab:not([data-or-icon])")){let i=t.querySelector(".lm_title");if(!i)continue;let r=i.textContent.trim();if(!r)continue;t.setAttribute("data-or-icon","");let s=kV(r);s&&(t.insertBefore(s,i),e++)}return e}function Xo(n,e,t,i){let r=document.createElement("div");r.className="modal-overlay",r.innerHTML=` + `}};customElements.get("ide-pane")||customElements.define("ide-pane",Db);customElements.get("ide-splitter")||customElements.define("ide-splitter",Ch);customElements.get("ide-tab")||customElements.define("ide-tab",Fb);var r3={DisplayControls:{pane:"left",title:"Display Controls",closable:!1},LayoutViewer:{pane:"main",title:"Layout",closable:!1},SchematicWidget:{pane:"main",title:"Schematic",closable:!0},"3DViewer":{pane:"main",title:"3D Viewer",closable:!0},TclConsole:{pane:"bottom",title:"Tcl Console",closable:!1},Inspector:{pane:"right",title:"Inspector",closable:!0},Browser:{pane:"right",title:"Hierarchy",closable:!0},TimingWidget:{pane:"right",title:"Timing",closable:!0},DRCWidget:{pane:"right",title:"DRC",closable:!0},SelectHighlight:{pane:"right",title:"Select Highlight",closable:!0},ClockWidget:{pane:"right",title:"Clock Tree",closable:!0},ChartsWidget:{pane:"right",title:"Charts",closable:!0},HelpWidget:{pane:"right",title:"Help",closable:!0}},Ph={left:{cssVar:"--pane-left-width",defaultSize:"240px",minSize:140,maxFraction:.45,dimension:"width",isVertical:!0,invertDelta:!1},right:{cssVar:"--pane-right-width",defaultSize:"340px",minSize:160,maxFraction:.5,dimension:"width",isVertical:!0,invertDelta:!0},bottom:{cssVar:"--pane-bottom-height",defaultSize:"220px",minSize:70,maxFraction:.75,dimension:"height",isVertical:!1,invertDelta:!0}},Th=class{constructor(e){this.containerEl=e,this.factories=new Map,this.components=new Map,this.activeTabs={left:null,main:null,bottom:null,right:null},this.closedComponents=new Set,this.eventListeners=new Map,this._resizeScheduled=!1,this._ensureDOM(),this._initSplitters(),this._initControls(),this._initResizeObserver()}on(e,t){this.eventListeners.has(e)||this.eventListeners.set(e,new Set),this.eventListeners.get(e).add(t)}off(e,t){this.eventListeners.get(e)?.delete(t)}emit(e,...t){let i=this.eventListeners.get(e);if(i)for(let r of i)try{r(...t)}catch(s){console.error(s)}}_ensureDOM(){this.containerEl.classList.add("ide-layout"),this.containerEl.querySelector("#pane-left")||this._buildInitialLayoutTree(),this._resolvePaneReferences()}_buildInitialLayoutTree(){this.containerEl.appendChild(this._createGutterButton("left","\u25B6 Display Controls","Restore Display Controls")),this.containerEl.appendChild(this._createGutterButton("right","\u25C0 Tools & Inspector","Restore Right Panel")),this.containerEl.appendChild(this._createPane("pane-left","left")),this.containerEl.appendChild(this._createSplitter("splitter-left","left","vertical","Drag to resize panel"));let e=document.createElement("main");e.id="pane-center",e.className="ide-center",e.appendChild(this._createPane("pane-main","main",{maximizable:!0})),e.appendChild(this._createSplitter("splitter-bottom","bottom","horizontal","Drag to resize console")),e.appendChild(this._createGutterButton("bottom","\u25B2 Tcl Console","Restore Tcl Console")),e.appendChild(this._createPane("pane-bottom","bottom",{maximizable:!0,collapsible:!0})),this.containerEl.appendChild(e),this.containerEl.appendChild(this._createSplitter("splitter-right","right","vertical","Drag to resize panel")),this.containerEl.appendChild(this._createPane("pane-right","right",{maximizable:!0,collapsible:!0}))}_createGutterButton(e,t,i){let r=document.createElement("button");r.id=`gutter-expand-${e}`,r.className=`ide-gutter-expand ide-gutter-${e}`,r.title=i;let s=document.createElement("span");return s.textContent=t,r.appendChild(s),r}_createPane(e,t,i={}){let r=document.createElement("ide-pane");return r.id=e,r.setAttribute("name",t),i.maximizable&&r.setAttribute("maximizable",""),i.collapsible&&r.setAttribute("collapsible",""),r}_createSplitter(e,t,i,r){let s=document.createElement("ide-splitter");return s.id=e,s.setAttribute("for",t),s.setAttribute("orientation",i),s.title=r,s}_resolvePaneReferences(){let e=["left","main","bottom","right"];this.panes={};for(let t of e){let i=this.containerEl.querySelector(`#pane-${t}`);i?.build&&i.build(),this.panes[t]={el:i,paneComponent:i,tabsEl:i?.tabsEl||this.containerEl.querySelector(`#pane-${t}-tabs`),contentEl:i?.contentEl||this.containerEl.querySelector(`#pane-${t}-content`)}}this.centerEl=this.containerEl.querySelector("#pane-center")}_initSplitters(){let e=null;this.containerEl.addEventListener("ide-splitter-start",t=>{let i=t.detail?.for,r=Ph[i];if(!r)return;let o=(i==="bottom"?this.centerEl||this.containerEl:this.containerEl).getBoundingClientRect(),a=this.panes[i]?.el?.getBoundingClientRect()||{},c=r.dimension==="width"?o.width:o.height,l=r.dimension==="width"?a.width||240:a.height||220;e={paneName:i,cfg:r,startSize:l,maxLimit:Math.round(c*r.maxFraction)||500}}),this.containerEl.addEventListener("ide-splitter-drag",t=>{if(!e||e.paneName!==t.detail?.for)return;let{cfg:i,startSize:r,maxLimit:s}=e,o=i.invertDelta?-t.detail.delta:t.detail.delta,a=Math.round(r+o),c=Math.max(i.minSize,Math.min(s,a));this.containerEl.style.setProperty(i.cssVar,`${c}px`),this.notifyResize()}),this.containerEl.addEventListener("ide-splitter-end",()=>{e=null,this.saveLayout(),this.notifyResize()}),this.containerEl.addEventListener("ide-splitter-reset",t=>{let i=t.detail?.for;this._resetSplitterPane(i)}),this._setupFallbackSplitters()}_resetSplitterPane(e){let t=Ph[e];t&&(this.containerEl.style.setProperty(t.cssVar,t.defaultSize),this.isPaneCollapsed(e)?this.restorePane(e):(this.saveLayout(),this.notifyResize()))}_setupFallbackSplitters(){for(let[e,t]of Object.entries(Ph)){let i=this.containerEl.querySelector(`#splitter-${e}`);if(!i||i instanceof Ch)continue;let r=!t.invertDelta,s=t.isVertical;i.addEventListener("pointerdown",o=>{o.preventDefault();try{i.setPointerCapture(o.pointerId)}catch{}i.classList.add("dragging"),document.body&&document.body.classList.add("is-resizing",s?"is-resizing-v":"is-resizing-h");let a=s?o.clientX:o.clientY,l=(e==="bottom"?this.centerEl||this.containerEl:this.containerEl).getBoundingClientRect(),u=this.panes[e]?.el?.getBoundingClientRect()||{},f=t.dimension==="width"?u.width||240:u.height||220,d=t.dimension==="width"?l.width:l.height,h=Math.round(d*t.maxFraction)||500,p=new AbortController,{signal:m}=p,g=y=>{let b=s?y.clientX:y.clientY,x=r?b-a:a-b,E=Math.round(f+x),w=Math.max(t.minSize,Math.min(h,E));this.containerEl.style.setProperty(t.cssVar,`${w}px`),this.notifyResize()},v=y=>{try{i.releasePointerCapture(y.pointerId)}catch{}i.classList.remove("dragging"),document.body&&document.body.classList.remove("is-resizing","is-resizing-v","is-resizing-h"),p.abort(),this.saveLayout(),this.notifyResize()};window.addEventListener("pointermove",g,{signal:m}),window.addEventListener("pointerup",v,{signal:m}),window.addEventListener("pointercancel",v,{signal:m})}),i.addEventListener("dblclick",()=>{this._resetSplitterPane(e)})}}_initControls(){this.containerEl.addEventListener("ide-pane-maximize",t=>{this.toggleMaximize(t.detail?.pane)}),this.containerEl.addEventListener("ide-pane-collapse",t=>{this.toggleCollapse(t.detail?.pane)}),this.containerEl.addEventListener("ide-layout-reset",()=>{this.resetLayout()});for(let t of["left","right","bottom"]){let i=this.containerEl.querySelector(`#gutter-expand-${t}`);i&&i.addEventListener("click",()=>this.restorePane(t))}let e=[{sel:"#btn-collapse-left",handler:()=>this.toggleCollapse("left")},{sel:"#btn-collapse-right",handler:()=>this.toggleCollapse("right")},{sel:"#btn-collapse-bottom",handler:()=>this.toggleCollapse("bottom")},{sel:"#btn-maximize-main",handler:()=>this.toggleMaximize("main")},{sel:"#btn-maximize-bottom",handler:()=>this.toggleMaximize("bottom")},{sel:"#btn-maximize-right",handler:()=>this.toggleMaximize("right")},{sel:"#btn-empty-reset-layout",handler:()=>this.resetLayout()}];for(let{sel:t,handler:i}of e){let r=this.containerEl.querySelector(t);r&&!r.closest("ide-pane")&&r.addEventListener("click",i)}}isPaneMaximized(e){return e?this.containerEl.classList.contains(`maximized-${e}`):this.containerEl.classList.contains("maximized-main")||this.containerEl.classList.contains("maximized-bottom")||this.containerEl.classList.contains("maximized-right")}setMaximizedPane(e,t=!0){let i=["main","bottom","right"];if(e&&!i.includes(e))return!1;let r=t?e:null;for(let s of i){let o=s===r;this.containerEl.classList.toggle(`maximized-${s}`,o),this.panes[s]?.paneComponent?.setMaximized(o);let a=this.containerEl.querySelector(`#btn-maximize-${s}`);a&&(a.textContent=o?"\u29C9":"\u2922",a.title=o?"Restore":"Maximize")}return this.notifyResize(),!!r}maximizePane(e){return this.setMaximizedPane(e,!0)}restoreMaximized(){return this.setMaximizedPane(null,!1)}toggleMaximize(e){return this.setMaximizedPane(e,!this.isPaneMaximized(e))}isPaneCollapsed(e){let t=e==="bottom"?this.centerEl:this.containerEl;return t?t.classList.contains(`hide-${e}`):!1}_setPaneCollapsed(e,t){let i=e==="bottom"?this.centerEl:this.containerEl;if(!i)return;i.classList.toggle(`hide-${e}`,t),this.panes[e]?.paneComponent?.setCollapsed?.(t);let r=this.containerEl.querySelector(`#btn-collapse-${e}`);if(r){let o={bottom:{collapsed:"\u25B2",expanded:"\u25BC"},left:{collapsed:"\u25B6",expanded:"\u25C0"},right:{collapsed:"\u25C0",expanded:"\u25B6"}}[e]||{collapsed:"\u25B6",expanded:"\u25C0"};r.textContent=t?o.collapsed:o.expanded,r.title=t?`Expand ${e.charAt(0).toUpperCase()+e.slice(1)}`:`Collapse ${e.charAt(0).toUpperCase()+e.slice(1)}`}this.saveLayout(),this.notifyResize()}toggleCollapse(e){this._setPaneCollapsed(e,!this.isPaneCollapsed(e))}collapsePane(e){this._setPaneCollapsed(e,!0)}restorePane(e){this._setPaneCollapsed(e,!1)}_updateEmptyState(){let e=this.containerEl.querySelector("#ide-empty-state");if(!e)return;let t=!!this.activeTabs.main;e.style.display=t?"none":"flex"}resetLayout(){try{localStorage.removeItem("or_ide_layout")}catch{}for(let[e,t]of Object.entries(Ph))this.containerEl.style.setProperty(t.cssVar,t.defaultSize);for(let e of["left","right","bottom"])this.restorePane(e);this.restoreMaximized(),this.closedComponents.clear();for(let e of this.components.values())e.tabEl.style.display="",e.contentDiv.style.display="";this.components.has("DisplayControls")&&this.activateTab("DisplayControls"),this.components.has("LayoutViewer")&&this.activateTab("LayoutViewer"),this.components.has("TclConsole")&&this.activateTab("TclConsole"),this.components.has("Inspector")&&this.activateTab("Inspector"),this._updateEmptyState(),this.saveLayout(),this.notifyResize(),this.emit("stateChanged"),typeof app<"u"&&app.map&&setTimeout(()=>app.map.invalidateSize({animate:!1}),0)}_initResizeObserver(){typeof ResizeObserver<"u"&&new ResizeObserver(()=>{this.notifyResize()}).observe(this.containerEl)}registerComponentFactoryFunction(e,t){this.factories.set(e,t)}loadLayout(e){for(let[i,r]of Object.entries(r3)){let s=this.factories.get(i);s&&this._mountComponent(i,r.pane,r.title,r.closable,s)}let t=null;try{let i=localStorage.getItem("or_ide_layout");i&&(t=JSON.parse(i))}catch{}if(t){if(t.leftWidth&&this.containerEl.style.setProperty("--pane-left-width",`${t.leftWidth}px`),t.rightWidth&&this.containerEl.style.setProperty("--pane-right-width",`${t.rightWidth}px`),t.bottomHeight&&this.containerEl.style.setProperty("--pane-bottom-height",`${t.bottomHeight}px`),t.closed)for(let i of t.closed)this.closeComponent(i,!1);this.activateTab(t.activeTabs?.left||"DisplayControls"),this.activateTab(t.activeTabs?.main||"LayoutViewer"),this.activateTab(t.activeTabs?.bottom||"TclConsole"),this.activateTab(t.activeTabs?.right||"Inspector"),t.hideLeft&&this.collapsePane("left"),t.hideRight&&this.collapsePane("right"),t.hideBottom&&this.collapsePane("bottom")}else this.activateTab("DisplayControls"),this.activateTab("LayoutViewer"),this.activateTab("TclConsole"),this.activateTab("Inspector");this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}_mountComponent(e,t,i,r,s){if(this.components.has(e))return;let o=this.panes[t];if(!o)return;let a=document.createElement("div");a.className="ide-component-container",a.id=`cmp-${e}`,o.contentEl.appendChild(a);let c=document.createElement("ide-tab");c.id=`tab-${e}`,c.setAttribute("for",e),c.setAttribute("data-component",e),c.setAttribute("title",i),r&&c.setAttribute("closable",""),c.addEventListener("tab-select",()=>{this.activateTab(e)}),c.addEventListener("tab-close",()=>{this.closeComponent(e)}),o.tabsEl.appendChild(c);let l=new Map,u={element:a,get width(){return a.clientWidth},get height(){return a.clientHeight},title:i,on:(d,h)=>{l.has(d)||l.set(d,new Set),l.get(d).add(h)},off:(d,h)=>{l.get(d)?.delete(h)},fire:(d,...h)=>{let p=l.get(d);if(p)for(let m of p)try{m(...h)}catch(g){console.error(g)}},focus:()=>this.focusComponent(e),close:()=>this.closeComponent(e)},f={componentType:e,paneName:t,title:i,closable:r,tabEl:c,contentDiv:a,container:u};this.components.set(e,f);try{s(u)}catch(d){console.error(`Failed to initialize component ${e}:`,d)}}isComponentActive(e){return e?!!e.contentDiv?.classList.contains("active"):!1}_setComponentActive(e,t){if(!e)return;let i=!!t;e.tabEl?.setActive(i),e.contentDiv?.classList.toggle("active",i)}activateTab(e){let t=this.components.get(e);if(!t||!this.panes[t.paneName])return;["left","right","bottom"].includes(t.paneName)&&this.isPaneCollapsed(t.paneName)&&this.restorePane(t.paneName);let r=this.activeTabs[t.paneName];if(r&&r!==e){let s=this.components.get(r);s&&(this._setComponentActive(s,!1),s.container.fire("hide"))}this.activeTabs[t.paneName]=e,t.tabEl.style.display="",t.contentDiv.style.display="",this._setComponentActive(t,!0),this.closedComponents.delete(e),t.container.fire("show"),t.container.fire("open"),t.container.fire("resize"),typeof app<"u"&&(e==="LayoutViewer"&&app.map&&setTimeout(()=>app.map.invalidateSize({animate:!1}),0),e==="3DViewer"&&app.threeDViewerWidget&&setTimeout(()=>app.threeDViewerWidget.onOpen(),0));try{t.tabEl.scrollIntoView({behavior:"smooth",inline:"nearest",block:"nearest"})}catch{}this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}closeComponent(e,t=!0){let i=this.components.get(e);if(!(!i||!i.closable)){if(i.tabEl.style.display="none",i.contentDiv.style.display="none",this._setComponentActive(i,!1),i.container.fire("hide"),this.closedComponents.add(e),t&&this.activeTabs[i.paneName]===e){let r=null;for(let s of this.components.values())if(s.paneName===i.paneName&&!this.closedComponents.has(s.componentType)){r=s;break}r?this.activateTab(r.componentType):(this.activeTabs[i.paneName]=null,["left","right","bottom"].includes(i.paneName)&&this.collapsePane(i.paneName))}this._updateEmptyState(),this.notifyResize(),this.emit("stateChanged")}}focusComponent(e){if(!this.components.get(e)){let i=this.factories.get(e);if(i){let r=r3[e]||{pane:"right",title:e,closable:!0};this._mountComponent(e,r.pane,r.title,r.closable,i)}else return}this.activateTab(e)}saveLayout(){let e={leftWidth:parseInt(this.containerEl.style.getPropertyValue("--pane-left-width")||"240",10),rightWidth:parseInt(this.containerEl.style.getPropertyValue("--pane-right-width")||"340",10),bottomHeight:parseInt(this.containerEl.style.getPropertyValue("--pane-bottom-height")||"220",10),hideLeft:this.isPaneCollapsed("left"),hideRight:this.isPaneCollapsed("right"),hideBottom:this.isPaneCollapsed("bottom"),activeTabs:{...this.activeTabs},closed:Array.from(this.closedComponents)};try{localStorage.setItem("or_ide_layout",JSON.stringify(e))}catch{}return e}notifyResize(){if(this._resizeScheduled)return;this._resizeScheduled=!0,(typeof requestAnimationFrame=="function"?requestAnimationFrame:t=>{t()})(()=>{this._resizeScheduled=!1;for(let t of this.components.values())this.isComponentActive(t)&&t.container.fire("resize");typeof app<"u"&&app&&app.map&&app.map.invalidateSize({animate:!1}),window.dispatchEvent(new Event("resize"))})}updateSize(){this.notifyResize()}setSize(e,t){this.notifyResize()}addComponent(e,t,i){this.focusComponent(e)}get rootItem(){return{contentItems:Array.from(this.components.keys()).map(e=>({isComponent:!0,componentType:e,focus:()=>this.focusComponent(e)}))}}};function Sn(n,e,t,i=0,r=0){return[(n-i)*t,(e-r)*t]}function Pn(n,e,t,i=0,r=0){return{dbuX:Math.round(i+n/t),dbuY:Math.round(r+e/t)}}function Nt(n,e,t,i,r,s=0,o=0){let[a,c]=Sn(n,e,r,s,o),[l,u]=Sn(t,i,r,s,o);return[Math.min(a,l),Math.min(c,u),Math.max(a,l),Math.max(c,u)]}var Nl=class n{constructor(e,t){this.url=e,this.socket=null,this.nextId=1,this.pending=new Map,this._queue=new Map,this._bgQueue=new Map,this._bgSent=new Set,this._inFlight=0,this._inFlightIds=new Set,this._unknownPayloadTypes=new Set,this._maxInFlight=48,this._lastRecvAt=0,this._bufStuckSince=0,this._lastBuffered=0,this.reconnectDelay=1e3,this.readyPromise=null,this.readyResolve=null,this.onStatusChange=t||(()=>{}),this.onPush=null,this._cache=null,this._isConnected=!1,this._shutdown=!1,this._livenessTimer=void 0,this._startLivenessMonitor(),this.connect()}get isConnected(){return this._isConnected||this.socket&&this.socket.readyState===WebSocket.OPEN}get pendingCount(){return this.pending.size-this._bgSent.size+(this._queue?this._queue.size:0)}static fromCache(e,t){let i=Object.create(n.prototype);return i.url=null,i.socket=null,i.nextId=1,i.pending=new Map,i._queue=new Map,i._bgQueue=new Map,i._bgSent=new Set,i._inFlight=0,i._inFlightIds=new Set,i._unknownPayloadTypes=new Set,i._maxInFlight=48,i._lastRecvAt=0,i.reconnectDelay=0,i.onStatusChange=t||(()=>{}),i.onPush=null,i._cache=e,i._isConnected=!0,i.readyPromise=Promise.resolve(),i.readyResolve=null,i}get isStaticMode(){return!!this._cache}connect(){this.readyPromise=new Promise(e=>{this.readyResolve=e}),this.socket=new WebSocket(this.url),this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{console.log("WebSocket connected");let e=this._everConnected===!0;this._everConnected=!0,this._isConnected=!0,this.reconnectDelay=1e3,this._lastRecvAt=typeof performance<"u"?performance.now():0,this.readyResolve(),this.onStatusChange(),this._pump(),e&&this.onReconnected&&this.onReconnected()},this.socket.onmessage=e=>{this.handleMessage(e.data)},this.socket.onclose=()=>this._handleClose(),this.socket.onerror=e=>{console.error("WebSocket error:",e)}}_handleClose(){this._isConnected=!1,this._inFlight=0,this._inFlightIds.clear(),this._bufStuckSince=0,this.onStatusChange();for(let[e,t]of this.pending)t.reject(new Error("WebSocket closed"));this.pending.clear(),this._bgSent.clear();for(let e of[this._queue,this._bgQueue]){for(let[t,i]of e)i.reject(new Error("WebSocket closed"));e.clear()}if(this._shutdown){console.log("WebSocket closed (server stopped)"),this._stopLivenessMonitor();return}console.log("WebSocket closed, reconnecting..."),setTimeout(()=>this.connect(),this.reconnectDelay),this.reconnectDelay=Math.min(this.reconnectDelay*2,3e4)}_forceReconnect(){let e=this.socket;if(this.socket=null,e){e.onopen=null,e.onmessage=null,e.onclose=null,e.onerror=null;try{e.close()}catch{}}this._handleClose()}handleMessage(e){let t=new DataView(e),i=t.getUint32(0),r=t.getUint8(4);if(this._lastRecvAt=typeof performance<"u"?performance.now():0,i===0&&r===0){let a=e.slice(8),c;try{c=JSON.parse(new TextDecoder().decode(a))}catch(l){console.error("Failed to parse server push JSON:",l);return}if(c&&c.type==="config"){Number.isFinite(c.max_in_flight)&&(this._maxInFlight=Math.max(1,Math.min(4096,Math.floor(c.max_in_flight))),this._pump());return}this.onPush&&this.onPush(c);return}this._inFlightIds.delete(i)&&this._inFlight>0&&this._inFlight--;let s=this.pending.get(i);if(!s){this._pump();return}this.pending.delete(i),this._bgSent.delete(i),this._pump(),this.onStatusChange();let o=e.slice(8);if(r===2)s.reject(new Error(new TextDecoder().decode(o)));else if(r===0)try{s.resolve(JSON.parse(new TextDecoder().decode(o)))}catch(a){s.reject(new Error("JSON parse error: "+a.message))}else r===1?s.resolve(new Blob([o],{type:"image/png"})):r===3?s.resolve(null):(this._unknownPayloadTypes.has(r)||(this._unknownPayloadTypes.add(r),console.warn(`Unrecognized websocket payload type ${r}. The server is likely newer than this page \u2014 reload to pick up the current client.`)),s.reject(new Error(`Unsupported websocket payload type ${r}`)))}request(e,{background:t=!1}={}){if(this._cache)return this._cacheRequest(e);let i=this.nextId++;if(e.id=i,!this.socket||this.socket.readyState!==WebSocket.OPEN)return Promise.reject(new Error("WebSocket not connected"));let r,s,o=new Promise((a,c)=>{r=a,s=c});return o.requestId=i,(t?this._bgQueue:this._queue).set(i,{msg:e,resolve:r,reject:s}),this._pump(),o}_pump(){if(!(!this.socket||this.socket.readyState!==WebSocket.OPEN)){for(;this._inFlight0||this._bgQueue.size>0)&&this.socket.bufferedAmount<524288;){let e=this._queue.size===0,t=e?this._bgQueue:this._queue,[i,r]=t.entries().next().value;t.delete(i),this.pending.set(i,{resolve:r.resolve,reject:r.reject}),e&&this._bgSent.add(i),this.socket.send(JSON.stringify(r.msg)),this._inFlightIds.add(i),this._inFlight++}this.onStatusChange()}}promote(e){let t=this._bgQueue.get(e);t?(this._bgQueue.delete(e),this._queue.set(e,t),this._pump()):this._bgSent.delete(e)&&this.onStatusChange()}cancel(e){let t=this._queue.get(e)||this._bgQueue.get(e);if(t){this._queue.delete(e),this._bgQueue.delete(e),t.reject(new Error("Request cancelled")),this.onStatusChange();return}let i=this.pending.get(e),r=this.pending.delete(e);this._bgSent.delete(e),i&&i.reject(new Error("Request cancelled")),r&&!this._cache&&this.socket&&this.socket.readyState===WebSocket.OPEN&&this.socket.send(JSON.stringify({type:"cancel",cancel_id:e,id:this.nextId++})),this.onStatusChange()}_startLivenessMonitor(){typeof setInterval>"u"||(this._livenessTimer=setInterval(()=>this._checkLiveness(),3e3),this._livenessTimer&&typeof this._livenessTimer.unref=="function"&&this._livenessTimer.unref())}_stopLivenessMonitor(){this._livenessTimer!==void 0&&typeof clearInterval<"u"&&(clearInterval(this._livenessTimer),this._livenessTimer=void 0)}_checkLiveness(){if(this._cache)return;let e=this.socket;if(!e||e.readyState!==WebSocket.OPEN){this._bufStuckSince=0,this._lastBuffered=0;return}let t=e.bufferedAmount,i=typeof performance<"u"?performance.now():0,r=!1,s="";t<=262144||t12e3&&(r=!0,s=`send buffer stuck at ${t}B for ${Math.round(i-this._bufStuckSince)}ms`),this._lastBuffered=t,!r&&this._inFlight>=this._maxInFlight&&this._queue.size+this._bgQueue.size>0&&this._lastRecvAt>0&&i-this._lastRecvAt>3e4&&(r=!0,s=`saturated (${this._inFlight} in flight, ${this._queue.size} queued) but silent for ${Math.round(i-this._lastRecvAt)}ms`),r&&(console.warn(`WebSocket connection wedged \u2014 ${s}; reconnecting to recover`),this._bufStuckSince=0,this._forceReconnect())}_cacheRequest(e){let t=e.type;if(t==="tile"){let s=e.layer+"/"+e.z+"/"+e.x+"/"+e.y,o=this._cache.tiles&&this._cache.tiles[s];return o?Promise.resolve("data:image/png;base64,"+o):Promise.reject(new Error("Tile not cached: "+s))}if(t==="timing_highlight"){let s=e.path_index;if(s>=0&&this._cache.overlays){let o=e.is_setup?"setup":"hold",a=this._cache.overlays[o]?.[s];this._cache.setPathOverlay&&this._cache.setPathOverlay(a?"data:image/png;base64,"+a:null)}else this._cache.setPathOverlay&&this._cache.setPathOverlay(null);return Promise.resolve({})}if(t==="set_module_colors")return Promise.resolve({ok:1,count:0});let i=t;t==="timing_report"?i="timing_report:"+(e.is_setup?"setup":"hold"):t==="slack_histogram"&&(i="slack_histogram:"+(e.is_setup?"setup":"hold"));let r=this._cache.json&&this._cache.json[i];if(r!==void 0){if(t==="timing_report"&&e.slack_min!=null&&e.slack_max!=null&&r.paths){let s=[];return r.paths.forEach((o,a)=>{o.slack>=e.slack_min&&o.slacko||a>c?null:{z:e,x0:s,x1:o,y0:a,y1:c}}function Ub([n,e,t,i],r){let s=(t-n)*r,o=(i-e)*r;return[n-s,e-o,t+s,i+o]}function Ah(n,e=1){if(!n)return null;let t=Math.pow(2,n.z);return{z:n.z,x0:Math.max(0,n.x0-e),x1:Math.min(t-1,n.x1+e),y0:Math.max(0,n.y0-e),y1:Math.min(t-1,n.y1+e)}}function St(n,e,t){return!!n&&e>=n.x0&&e<=n.x1&&t>=n.y0&&t<=n.y1}function zl(n){if(!n)return[];let e=(n.x0+n.x1)/2,t=(n.y0+n.y1)/2,i=[];for(let r=n.y0;r<=n.y1;r++)for(let s=n.x0;s<=n.x1;s++)i.push({z:n.z,x:s,y:r,d:(s-e)**2+(r-t)**2});return i.sort((r,s)=>r.d-s.d),i.map(({z:r,x:s,y:o})=>({z:r,x:s,y:o}))}function o3(n,e,t,i){let r=i/Math.pow(2,n);return[e*r,i-(t+1)*r,(e+1)*r,i-t*r]}function $b(n,e){return n[0]Math.log2(s/T);if(p<1e-12){let T=Math.log(f/u)/t;return{S:Math.abs(T),at:R=>({target:[o+R*d,a+R*h],zoom:m(u*Math.exp(t*R*T))})}}let g=Math.sqrt(p),v=(f*f-u*u+r*p)/(2*u*i*g),y=(f*f-u*u-r*p)/(2*f*i*g),b=Math.log(Math.sqrt(v*v+1)-v),E=(Math.log(Math.sqrt(y*y+1)-y)-b)/t,w=Math.cosh(b);return{S:E,at:T=>{if(T>=1)return{target:[c,l],zoom:e.zoom};let R=T*E,F=u/(i*g)*(w*Math.tanh(t*R+b)-Math.sinh(b));return{target:[o+F*d,a+F*h],zoom:m(u*w/Math.cosh(t*R+b))}}}}function Ho(n,e,t){return`${n}/${e}/${t}`}var kh=class{constructor({source:e,onChange:t=()=>{},keepBuffer:i=2}={}){this.source=e,this.onChange=t,this.keepBuffer=i,this.tiles=new Map,this.z=null,this.range=null,this.ring=null,this.extra=[],this._generation=0,this._loads=0,this._cancels=0}update({z:e,range:t,ring:i=t,extra:r=[],hold:s=null}){this.z=e,this.range=t,this.ring=i,this.extra=r.filter(c=>c.z!==e&&c.range);let o=new Map(this.extra.map(c=>[c.z,c]));for(let c of[...this.tiles.values()]){if(c.z!==e){let l=o.get(c.z),u=l&&l.range;(u?!St(u,c.x,c.y)&&(c.loading||!this._inKeepBuffer(c,u)):c.loading&&!c.drawable)?this._drop(c):u&&this._stale(c)&&St(u,c.x,c.y)&&this._load(c,l.background!==!1);continue}if(this._stale(c)&&St(i,c.x,c.y)&&this._load(c,!St(t,c.x,c.y)),St(i,c.x,c.y)){c.loading&&c.background&&St(t,c.x,c.y)&&(c.background=!1,c.handle?.promote?.());continue}(c.loading||!(this._inKeepBuffer(c)||s&&St(s,c.x,c.y)))&&this._drop(c)}let a=[...zl(t),...zl(i).filter(c=>!St(t,c.x,c.y))];for(let{x:c,y:l}of a)this.tiles.has(Ho(e,c,l))||this._load(this._newTile(e,c,l),!St(t,c,l));for(let c of this.extra)for(let{x:l,y:u}of zl(c.range))this.tiles.has(Ho(c.z,l,u))||this._load(this._newTile(c.z,l,u),c.background!==!1)}refresh(){this._generation++;let e=new Map(this.extra.map(t=>[t.z,t]));for(let t of[...this.tiles.values()]){let i=e.get(t.z),r=t.z===this.z?this.ring:i&&i.range;r&&(St(r,t.x,t.y)?(t.handle?.cancel?.(),this._load(t,i?i.background!==!1:!St(this.range,t.x,t.y))):t.loading&&this._drop(t))}}isSettled(){for(let e of this.tiles.values())if(e.z===this.z&&e.loading&&St(this.range,e.x,e.y))return!1;return!0}settledIn(e,t){for(let{x:i,y:r}of zl(t)){let s=this.tiles.get(Ho(e,i,r));if(!s||s.loading)return!1}return!0}hasContentAt(e){for(let t of this.tiles.values())if(t.z===e&&t.drawable)return!0;return!1}drawableTilesAt(e){let t=[];for(let i of this.tiles.values())i.z===e&&i.drawable&&t.push(i);return t}prune(e){let t=new Set(e);for(let i of[...this.tiles.values()])t.has(i.z)||this._drop(i)}clear(){for(let e of[...this.tiles.values()])this._drop(e);this.z=null,this.range=null,this.ring=null,this.extra=[]}stats(){let e=0,t=0;for(let i of this.tiles.values())i.loading&&e++,i.drawable&&t++;return{tiles:this.tiles.size,loading:e,drawable:t,loads:this._loads,cancels:this._cancels}}_newTile(e,t,i){let r={z:e,x:t,y:i,key:Ho(e,t,i),drawable:null,loading:!1,background:!1,handle:null,generation:-1};return this.tiles.set(r.key,r),r}_load(e,t){let i=this._generation,r=()=>this.tiles.get(e.key)===e&&e.generation===i;e.generation=i,e.loading=!0,e.background=t,this._loads++;let s=this.source.load({z:e.z,x:e.x,y:e.y},{background:t,onPartial:o=>{if(!r()){this.source.release?.(o);return}this._setDrawable(e,o),this.onChange(e)}});e.handle=s,s.promise.then(o=>{if(!r()){this.source.release?.(o);return}o!==void 0&&this._setDrawable(e,o),e.loading=!1,e.handle=null,this.onChange(e)},()=>{r()&&(e.loading=!1,e.handle=null,this.onChange(e))})}_setDrawable(e,t){e.drawable&&e.drawable!==t&&this.source.release?.(e.drawable),e.drawable=t||null}_stale(e){return!e.loading&&e.generation!==this._generation}_inKeepBuffer(e,t=this.range){return St(Ah(t,this.keepBuffer),e.x,e.y)}_drop(e){e.loading&&(this._cancels++,e.handle?.cancel?.()),e.drawable&&this.source.release?.(e.drawable),e.drawable=null,e.loading=!1,this.tiles.delete(e.key)}};function xV(n){return!Number.isFinite(n)||n<=1?1:Math.round(Math.min(n,3)*100)/100}var Di=240,wV=256,Gb=Di;function sn(){return Gb}function l3(){Gb=wV}var Nbe=1/64,Vb=120;function u3(n){Gb=n}function Wb(n,e){return Math.max(1,Math.round(n*e))}function Yo(){let n=typeof window<"u"&&window.devicePixelRatio?window.devicePixelRatio:1;return!Number.isFinite(n)||n<=1?1:Math.min(n,3)}function Rh(n,e=sn()){return{dpr:xV(n),tile_px:Wb(e,n)}}function f3(n,e,t,i=sn()){let{selectability:r,selectableLayers:s,app:o}=e,a={...h3(n,e,t,i),selectable_layers:s?[...s]:[]};if(r)for(let[c,l]of Object.entries(r))a["s_"+c]=!!l;return c=>{let l={type:"tile",layer:c,...a},u=p3(o,c);return u!==1&&(l.pattern=u),l}}function d3(n,e,t,i,r=sn()){let s={type:"tile_group",layers:[...e],...h3(n,t,i,r)},o=e.map(a=>p3(t.app,a));return o.some(a=>a!==1)&&(s.patterns=o),s}function h3(n,e,t,i){let{visibility:r,visibleLayers:s,app:o}=e,a={z:n.z,x:n.x,y:n.y,...Rh(t,i),visible_layers:s?[...s]:[]};for(let[c,l]of Object.entries(r||{}))a[c]=!!l;return o&&o.visibleChiplets instanceof Set&&(a.visible_chiplets=[...o.visibleChiplets]),a}function p3(n,e){let t=n&&n.layerPatterns?n.layerPatterns[e]:void 0;return t===void 0?1:t}function m3(n){if(typeof window>"u"||typeof window.matchMedia!="function"||typeof n!="function")return()=>{};let e=!1,t=null,i=null,r=()=>{if(e)return;let s=window.devicePixelRatio||1;t=window.matchMedia(`(resolution: ${s}dppx)`),i=()=>{e||(r(),n(window.devicePixelRatio||1))},t.addEventListener("change",i,{once:!0})};return r(),()=>{e=!0,t&&i&&t.removeEventListener("change",i),t=null,i=null}}function g3(n,e){if(!n)return!1;let t=!!e;return!!n.visible===t?!1:(n.visible=t,!0)}function _3(n,e,t){if(!n||!(t>0))return 0;n.clearRect(0,0,t,t);let i=0;for(let r of e||[]){let s=r?r.image:null;if(!s)continue;let o=r.opacity===void 0?1:r.opacity;o>0&&(n.globalAlpha=Math.min(1,o),n.drawImage(s,0,0,t,t),i++)}return n.globalAlpha=1,i}function jb(n){for(let e of n||[])e&&typeof e.close=="function"&&e.close()}async function y3({items:n,request:e,decode:t,draw:i,release:r=jb,isStale:s=()=>!1,incremental:o=!0}={}){let a=Array.isArray(n)?n:[],c={requested:a.length,arrived:0,decoded:0,drawn:0,paints:0,failed:0,stale:!1};if(a.length===0)return typeof i=="function"&&i([]),c;let l=new Array(a.length).fill(null),u=!1;function f(){if(s()){c.stale=!0;return}c.drawn=i(a.map((d,h)=>({image:l[h],opacity:d.opacity})))||0,c.paints++,u=!0}try{await Promise.all(a.map(async(d,h)=>{let p=null;try{p=await e(d)}catch{c.failed++;return}if(p==null)return;c.arrived++;let m=null;try{m=await t(p)}catch{return}m&&(l[h]=m,c.decoded++,o&&f())})),u||f()}finally{r(l)}return c}var EV=["tracks_pref","tracks_non_pref","debug","debug_renderers"],SV=1/16;function Hb(n,e){if(n==null)return!1;if(!Array.isArray(n)||n.length!==4||!e)return!0;let t=Math.pow(2,e.z),i=SV/t,r=e.x/t-i,s=e.y/t-i,o=(e.x+1)/t+i,a=(e.y+1)/t+i,[c,l,u,f]=n;return c<=o&&u>=r&&l<=a&&f>=s}function PV(n,e,t){let i=n&&Array.isArray(n.by_size)?n.by_size:[];if(i.length===0||!e||!(t>0))return!0;let r=n.min_css_px/(t*Math.pow(2,e.z)),s=i[0];for(let o of i)o[0]<=r&&(s=o);return Hb(s[1],e)}var Ih=class{constructor(){this._layers=null,this._gated=new Map,this._sized=new Map,this._generation=0}invalidate(){return this._generation++,this._layers=null,this._gated=new Map,this._sized=new Map,this._generation}apply(e,t){if(e!==this._generation)return!1;if(!t||t.supported!==!0||!t.layers||typeof t.layers!="object")return this._layers=null,!1;let i=new Map;if(t.gated&&typeof t.gated=="object")for(let[r,s]of Object.entries(t.gated))s&&typeof s=="object"&&i.set(r,new Map(Object.entries(s)));return this._layers=new Map(Object.entries(t.layers)),this._gated=i,this._sized=new Map(t.sized&&typeof t.sized=="object"?Object.entries(t.sized):[]),!0}refetch(e){let t=this.invalidate();return Promise.resolve().then(()=>e({type:"layer_extents"})).then(i=>this.apply(t,i)).catch(()=>!1)}mayHaveContent(e,t,i,r=256){if(!this._layers||i&&EV.some(s=>i[s]))return!0;if(this._sized.has(e))return PV(this._sized.get(e),t,r);if(!this._layers.has(e)||Hb(this._layers.get(e),t))return!0;for(let[s,o]of this._gated)if(!(i&&i[s]===!1)&&o.has(e)&&Hb(o.get(e),t))return!0;return!1}};function b3(n,e,t){let i=n&&n.app&&n.app.layerExtents;return i?i.mayHaveContent(e,t,n.visibility,sn()):!0}function v3(n){return n==null?Promise.resolve(null):typeof n=="string"?new Promise(e=>{let t=document.createElement("img");t.onload=()=>e(t),t.onerror=()=>e(null),t.src=n}):createImageBitmap(n,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).catch(()=>null)}function Yb(n){jb([n&&n.image])}function CV(n){return{width:n.naturalWidth||n.width,height:n.naturalHeight||n.height}}function Bh(n){return n?{image:n,...CV(n)}:null}function TV(n){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(n,n);let e=document.createElement("canvas");return e.width=n,e.height=n,e}function qb(n){let e=document.createElement("canvas");return e.width=n.width,e.height=n.height,e.getContext("2d").drawImage(n,0,0),e}function LV(n){return typeof n.transferToImageBitmap=="function"?Bh(n.transferToImageBitmap()):Bh(qb(n))}var x3=Object.freeze({promise:Promise.resolve(null),cancel(){},promote(){}});function w3(n,e,t,i){let r=n.request(t,{background:i});return r.requestId!=null&&e.push(r.requestId),r}function E3(n,e,t,i){return{promise:t,cancel(){i();for(let r of e)n.cancel(r)},promote(){for(let r of e)n.promote?.(r)}}}var S3=3;function MV(n,e){let t=new Map,i=0,r=0;for(let s of n)if(!(!s||t.has(s.layer))){if(s.layer.startsWith("_")){t.set(s.layer,null),i++,r=0;continue}t.set(s.layer,`${i}:${Math.floor(r++/e)}`)}return t}function AV(n,e,t,i,r,s,o,a){let c=MV(n,t),l=[],u=null,f=()=>{u&&(l.push({opacity:1,msg:d3(r,u.layers,s,o,a)}),u=null)};for(let d of e){let h=c.get(d.layer);if(h==null){f(),l.push({opacity:1,msg:i(d.layer)});continue}u&&u.id!==h&&f(),u=u||{id:h,layers:[]},u.layers.push(d.layer)}return f(),l}function P3({wm:n,ctx:e,getItems:t,dpr:i=()=>1,tileSize:r=()=>240,isDoubleBuffer:s=()=>!0,decode:o=v3,makeCanvas:a=TV,snapshot:c=LV,groupLayers:l=()=>0}){return{load({z:u,x:f,y:d},{background:h=!1,onPartial:p}={}){let m=t()||[],g=m.filter(X=>X&&X.visible!==!1&&b3(e,X.layer,{z:u,x:f,y:d})),v=i(),y=r(),b=new Set,x=g.filter(X=>!b.has(X.layer)&&b.add(X.layer));if(x.length===0)return x3;let E=f3({z:u,x:f,y:d},e,v,y),w=l(),T=w>0&&x.every(X=>(X.opacity??1)===1)?AV(m,x,w,E,{z:u,x:f,y:d},e,v,y):x.map(X=>({opacity:X.opacity,msg:E(X.layer)})),R=Wb(y,v),F=null,O=null,j=[],V=!1,G=!s()&&typeof p=="function",q=y3({items:T,request:X=>w3(n,j,X.msg,h),decode:o,draw:X=>{if(!F){if(!X.some(le=>le.image))return 0;F=a(R),O=F.getContext("2d")}let se=_3(O,X,R);return G&&se>0&&!V&&p(c(F)),se},isStale:()=>V,incremental:G}).then(X=>{if(V)throw new Error("Tile cancelled");if(X.failed===X.requested)throw new Error("Tile requests failed");return X.drawn===0?null:G?void 0:c(F)});return E3(n,j,q,()=>{V=!0})},release:Yb}}function Zb({wm:n,buildRequest:e,dpr:t=()=>1,tileSize:i=()=>240,decode:r=v3}){return{load({z:s,x:o,y:a},{background:c=!1}={}){let l=e({z:s,x:o,y:a},t(),i());if(!l)return x3;let u=[],f=!1,d=w3(n,u,l,c).then(h=>r(h)).then(h=>{if(f)throw Yb(Bh(h)),new Error("Tile cancelled");return Bh(h)});return E3(n,u,d,()=>{f=!0})},release:Yb}}function C3({z:n,x:e,y:t},i,r,s,o){let a={type:"overlay_tile",z:n,x:e,y:t,...Rh(i,r),debug_renderers:!!s.debug_renderers,debug_live:!!s.debug_live,flywires_only:!!s.flywires_only,poly_decomp:!!(o&&o.polyDecomp),focused_nets_guides:!!s.focused_nets_guides,highlight_selected:s.highlight_selected!==!1,draw_labels:s.labels!==!1};return o&&o.visibleLayerNames&&(a.visible_layers=[...o.visibleLayerNames]),a}function T3({z:n,x:e,y:t},i,r,s){let o=s&&s.activeHeatMap;return o?{type:"heatmap_tile",name:o,z:n,x:e,y:t,...Rh(i,r)}:null}function fe(n){return!!n?.websocketManager?.isStaticMode}function R3(n,e){let t={};for(let[i,r]of Object.entries(n||{}))t[i]=!!r;for(let[i,r]of Object.entries(e||{}))t["s_"+i]=!!r;return t}function qo(n,e){e&&typeof e.sel_has_inst=="boolean"&&(n.selHasInst=e.sel_has_inst,n.selHasNet=!!e.sel_has_net)}var Xb=null;function on(n,e=4e3){let t=document.getElementById("or-toast");return t||(t=document.createElement("div"),t.id="or-toast",document.body.appendChild(t)),t.textContent=n,t.classList.add("visible"),Xb&&clearTimeout(Xb),Xb=setTimeout(()=>t.classList.remove("visible"),e),t}function I3(n,{dontShowAgain:e}={}){let t=document.createElement("div");t.className="or-corner-warning",t.setAttribute("role","alert");let i=document.createElement("div"),r=document.createElement("span");if(r.textContent=n,i.append(r),e){let o=document.createElement("button");o.type="button",o.className="or-corner-warning-never",o.textContent="Don't show again",o.addEventListener("click",()=>{e(),t.remove()}),i.append(o)}let s=document.createElement("button");return s.type="button",s.className="or-corner-warning-close",s.title="Close",s.setAttribute("aria-label","Close"),s.textContent="\xD7",s.addEventListener("click",()=>t.remove()),t.append(i,s),document.body.appendChild(t),t}var kV=/SwiftShader|llvmpipe|lavapipe|softpipe|Basic Render Driver/i,L3="If hardware acceleration is turned off in your browser settings ('Use graphics acceleration when available' or 'Use hardware acceleration when available'), turn it on and restart the browser.";function B3(n){if(!n)return null;if(n.gpuType==="none")return{kind:"nowebgl",message:"WebGL is not available, so the layout view cannot be drawn. "+L3};let e=`${n.vendor||""} ${n.renderer||""}`;return n.gpuType!=="cpu"&&!kV.test(e)?null:{kind:"software",message:"The layout view is being drawn in software, without the GPU, which is slower. "+L3}}function O3({title:n,message:e,confirmLabel:t="OK",danger:i=!1}){return new Promise(r=>{let s=document.createElement("div");s.className="or-modal-overlay";let o=document.createElement("div");o.className="or-modal";let a=document.createElement("div");a.className="or-modal-title",a.textContent=n;let c=document.createElement("div");c.className="or-modal-message",c.textContent=e;let l=document.createElement("div");l.className="or-modal-buttons";let u=document.createElement("button");u.className="or-btn",u.textContent="Cancel";let f=document.createElement("button");f.className="or-btn"+(i?" or-btn-danger":""),f.textContent=t;let d=p=>{document.removeEventListener("keydown",h,!0),s.remove(),r(p)},h=p=>{p.key==="Escape"&&(p.stopPropagation(),d(!1))};u.addEventListener("click",()=>d(!1)),f.addEventListener("click",()=>d(!0)),s.addEventListener("click",p=>{p.target===s&&d(!1)}),document.addEventListener("keydown",h,!0),l.appendChild(u),l.appendChild(f),o.appendChild(a),o.appendChild(c),o.appendChild(l),s.appendChild(o),document.body.appendChild(s),u.focus()})}var RV=.05;function IV([[n,e],[t,i]],r){let s=(i-e)*r,o=(t-n)*r;return[[n-o,e-s],[t+o,i+s]]}function Kb(n,e=256,t=null){if(!M3(n))return null;let i=n[0][0],r=n[0][1],s=Math.max(n[1][1]-r,n[1][0]-i),o=e/s,a=M3(t)?t:n,[[c,l],[u,f]]=IV(a,RV);return{scale:o,maxDXDY:s,originX:r,originY:i,fitRect:Nt(l,c,f,u,o,r,i)}}function M3(n){return!!n&&n[1][0]>n[0][0]&&n[1][1]>n[0][1]}function D3(n,e){return!!n&&!!e&&n[0][0]===e[0][0]&&n[0][1]===e[0][1]&&n[1][0]===e[1][0]&&n[1][1]===e[1][1]}function Pt(n){n.selectionToken=(n.selectionToken||0)+1;for(let e of n.selectionResetters||[])e();return n.selectionToken}function Ft(n,e){return n.selectionToken===e}function N3(n,e){n.selectionResetters||(n.selectionResetters=[]),n.selectionResetters.push(e)}var Qb=80,Ul=10,$l=1e3;function Gl(n){let e=n===""||n===null?NaN:Math.round(Number(n));return Number.isFinite(e)?Math.min($l,Math.max(Ul,e)):Qb}function vs(n="vis-group-header"){let e=document.createElement("div");e.className=n;let t=document.createElement("span");t.className="vis-arrow",e.appendChild(t);let i=document.createElement("span");return i.className="vis-name",e.appendChild(i),{header:e,arrow:t,name:i}}function xs(n,e,t,i){let r=s=>{t.classList.toggle("collapsed",s),e.textContent=s?"\u25B6":"\u25BC"};r(!!i),n.addEventListener("click",s=>{let o=s.target&&s.target.parentNode===n&&s.target.classList&&s.target.classList.contains("vis-name");s.target!==n&&s.target!==e&&!o||r(!t.classList.contains("collapsed"))})}var A3=30;function F3(n,e=8){if(!Number.isFinite(n)||n<=0)return A3;let t=Math.ceil(Math.log2(e/n));return Math.max(1,Math.min(A3,t))}function z3({designBounds:n,fitRect:e,viewW:t,viewH:i}){let r=Kb(n,Di,e),s=h=>Number.isFinite(h)&&h>0;if(!r||!s(t)||!s(i))return Di;let o=r.fitRect[2]-r.fitRect[0],a=r.fitRect[3]-r.fitRect[1],c=Math.min(t/o,i/a),l=Math.log2(c);if(!Number.isFinite(l)||l<0)return Di;let u=Math.floor(l),f=Di*2**(l-u),d=Math.floor(f/Vb)*Vb;return d>Di&&Math.log2(Di*c/d)>=u?d:Di}function U3(n,{showDbu:e,dbuPerMicron:t},i=!1){if(e)return String(Math.round(n));let r=t>0?t:1e3,s=Math.ceil(Math.log10(r)),o=(n/r).toFixed(s);return i?o+" \xB5m":o}function $3(n,{showDbu:e,dbuPerMicron:t}){let i=parseFloat(n);if(!Number.isFinite(i))return null;if(e)return Math.round(i);let r=t>0?t:1e3;return Math.round(i*r)}function G3(n,{showDbu:e,dbuPerMicron:t}){if(e)return String(Math.round(n));let i=t>0?t:1e3,r=n/i;return r>=1e3?(r/1e3).toFixed(3)+" mm":r>=1?r.toFixed(3)+" um":(r*1e3).toFixed(1)+" nm"}function V3({showDbu:n}){return n?"DBU":"\xB5m"}function Zo(n){return typeof n=="string"&&/^#[0-9a-fA-F]{6}$/.test(n)}function W3(n){if(typeof n!="string")return null;let e=n.trim();if(Zo(e))return e.toLowerCase();let t=e.match(/^#([0-9a-fA-F]{3})$/);if(t)return"#"+t[1].split("").map(r=>r+r).join("").toLowerCase();let i=e.match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/);if(i){let r=i.slice(1).map(Number);return r.some(s=>s>255)?null:"#"+r.map(s=>s.toString(16).padStart(2,"0")).join("")}return null}function ur(n,e=t=>requestAnimationFrame(t)){let t=!1;return()=>{t||(t=!0,e(()=>{t=!1,n()}))}}function Vl(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function k3(n){let e=Math.pow(10,Math.floor(Math.log10(n))),t=n/e,i;return t<1.5?i=1:t<3.5?i=2:t<7.5?i=5:i=10,{value:i*e,digit:i}}function j3({targetPx:n,pxPerDbu:e,dbuPerMicron:t,showDbu:i}){if(!Number.isFinite(e)||e<=0||!Number.isFinite(n)||n<=0)return null;let r,s,o;if(i){let c=k3(Math.max(1,n/e));o=c.digit,r=Math.round(c.value*e),s=String(Math.round(c.value))}else{let c=Number.isFinite(t)&&t>0?t:1e3,l=e*c,u=k3(n/l);o=u.digit;let f=u.value;r=Math.round(f*l);let d,h;f>=1e3?(d=1/1e3,h="mm"):f>=1?(d=1,h="\xB5m"):f>=.001?(d=1e3,h="nm"):(d=1e6,h="pm"),s=Math.round(f*d)+" "+h}return{barPx:r,label:s,segments:o===1?5:o}}function Wl(n,e,t){return e?typeof n.runTclScript=="function"?n.runTclScript(e,t):(t&&typeof n.echoTcl=="function"&&n.echoTcl(e),n.websocketManager.request({type:"tcl_eval",cmd:e}).catch(()=>{})):Promise.resolve()}function ws(n,e){let t=n.querySelectorAll("thead th");(!e||!e[0])&&(n.style.tableLayout="auto",t.forEach(i=>i.style.width=""),e=Array.from(t,i=>i.offsetWidth+"px")),t.forEach((i,r)=>i.style.width=e[r]||""),n.style.tableLayout="fixed",t.forEach((i,r)=>{if(r===t.length-1)return;let s=document.createElement("div");s.className="col-resize-grip",i.style.position="relative",i.appendChild(s);let o,a,c=u=>{i.style.width=Math.max(30,a+u.clientX-o)+"px"},l=()=>{document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",l);let u=f=>f.stopPropagation();document.addEventListener("click",u,{capture:!0,once:!0}),setTimeout(()=>{document.removeEventListener("click",u,{capture:!0})},0)};s.addEventListener("mousedown",u=>{u.preventDefault(),o=u.clientX,a=i.offsetWidth,document.addEventListener("mousemove",c),document.addEventListener("mouseup",l)})})}var BV={Layout:'',Schematic:'',"3D Viewer":'',"Display Controls":'',Inspector:'',Hierarchy:'',Timing:'',DRC:'',"Select Highlight":'',"Clock Tree":'',Charts:'',"Tcl Console":'',Help:''};function OV(n){let e=BV[n];if(!e)return null;let t=document.createElement("span");return t.className="or-tab-icon",t.innerHTML='",t}function H3(n=document){let e=0;for(let t of n.querySelectorAll(".lm_tab:not([data-or-icon])")){let i=t.querySelector(".lm_title");if(!i)continue;let r=i.textContent.trim();if(!r)continue;t.setAttribute("data-or-icon","");let s=OV(r);s&&(t.insertBefore(s,i),e++)}return e}function Xo(n,e,t,i){let r=document.createElement("div");r.className="modal-overlay",r.innerHTML=` -
`,document.body.appendChild(r);let s=()=>r.remove();r.addEventListener("click",c=>{c.target===r&&s()}),r.addEventListener("keydown",c=>{c.key==="Escape"&&s()}),r.querySelector(".cancel").addEventListener("click",s),r.querySelector(".modal-close").addEventListener("click",s);let o=r.querySelector(".modal-error"),a=(c,l)=>{o.textContent=c,o.style.display=c?"block":"none",o.classList.toggle("info",!!l)};return{overlay:r,close:s,okBtn:r.querySelector(".ok"),showError:a}}var RV=1e4,IV=150,BV=3;function OV(n){return 1-(1-n)*(1-n)}var Oh=class{constructor({isEnabled:e=()=>!0,isSmooth:t=()=>!1,reducedMotion:i=Vl,now:r=()=>performance.now(),setTimer:s=(u,f)=>setTimeout(u,f),clearTimer:o=u=>clearTimeout(u),timeoutMs:a=RV,fadeMs:c=IV,onChange:l=()=>{}}={}){Object.assign(this,{isEnabled:e,isSmooth:t,reducedMotion:i,now:r,setTimer:s,clearTimer:o,timeoutMs:a,fadeMs:c,onChange:l}),this.shownZ=null,this.pendingZ=null,this.under=[],this.fade=null,this._timer=null}wantedZ(){return this.pendingZ!==null?this.pendingZ:this.shownZ}setZoom(e,{hasContent:t=!0}={}){e!==this.wantedZ()&&(this.endFade(),this._clearTimer(),this.shownZ===null?(this.shownZ=e,this.pendingZ=null,this.under=[]):t?e===this.shownZ?this.pendingZ=null:this.isEnabled()?(this.pendingZ=e,this.under=[],this._timer=this.setTimer(()=>this.reveal(),this.timeoutMs)):(this.under=[...this.under.filter(i=>i!==e),this.shownZ].slice(-BV),this.shownZ=e,this.pendingZ=null):(this.shownZ=e,this.pendingZ=null,this.under=this.under.filter(i=>i!==e)),this.onChange())}check({settled:e,animating:t=!1}){return this.pendingZ!==null?t||!e&&this.isEnabled()?!1:(this.reveal(),!0):this.under.length>0&&e&&!t?(this.under=[],this.onChange(),!0):!1}reveal(){if(this.pendingZ===null)return;this._clearTimer();let e=this.shownZ;this.shownZ=this.pendingZ,this.pendingZ=null;let t=this.isSmooth()&&!this.reducedMotion()?this.fadeMs:0;this.fade=t>0&&e!==null?{fromZ:e,toZ:this.shownZ,start:this.now(),ms:t}:null,this.onChange()}endFade(){this.fade&&(this.fade=null,this.onChange())}plan(e=this.now()){if(this.fade){let t=(e-this.fade.start)/this.fade.ms;if(t<1)return{draw:[{z:this.fade.fromZ,opacity:1},{z:this.fade.toZ,opacity:OV(Math.max(0,t))}],fading:!0};this.fade=null}return this.shownZ===null?{draw:[],fading:!1}:this.pendingZ!==null?{draw:[{z:this.shownZ,opacity:1}],fading:!1}:this.under.length>0?{draw:[...this.under,this.shownZ].map(t=>({z:t,opacity:1})),fading:!1}:{draw:[{z:this.shownZ,opacity:1}],fading:!1}}isIdle(e=this.now()){return this.pendingZ===null&&this.under.length===0&&!this.plan(e).fading}dispose(){this._clearTimer()}_clearTimer(){this._timer!==null&&(this.clearTimer(this._timer),this._timer=null)}};var ot=Object.freeze({base:10,overlay:20,heatmap:30,top:40,pathImage:50,selection:60,highlight:70,ruler:80}),Es={depthCompare:"always",depthWriteEnabled:!1},j3=250,H3=4,Jb=300,DV=1,NV=2,FV=300,zV=300,UV=400,$V=1e3,Y3=100,GV=.05,q3=1200,Z3=30;function Ut(n,e=1){if(Array.isArray(n)){let r=n.length>3?n[3]:255;return[n[0],n[1],n[2],Math.round(r*e)]}let t=String(n||"#000").replace("#","");t.length===3&&(t=t.split("").map(r=>r+r).join(""));let i=parseInt(t.slice(0,6),16)||0;return[i>>16&255,i>>8&255,i&255,Math.round(255*e)]}function VV(n){return 1-Math.pow(1-n,3)}function WV(n){return n<.5?4*n*n*n:1-Math.pow(2-2*n,3)/2}function jV(){let n=new Map;return{on(e,t){for(let i of e.split(/\s+/))n.has(i)||n.set(i,new Set),n.get(i).add(t)},off(e,t){for(let i of e.split(/\s+/))n.get(i)?.delete(t)},emit(e,t){for(let i of[...n.get(e)||[]])i(t)}}}function HV(n){let e=n&&n.device&&n.device.info||{};return{gpuType:e.gpuType||"unknown",renderer:e.renderer||"",vendor:e.vendor||""}}function X3(n,e={}){let t=e.deckApi!==void 0?e.deckApi:globalThis.deck,i=e.copyCanvas||qb,r={smooth:()=>!1,doubleBuffer:()=>!0,defer:()=>!1,...e.prefs||{}},s=e.tileSize||(()=>240),o=e.dpr||(()=>typeof devicePixelRatio=="number"?devicePixelRatio:1),a=e.raf||(P=>requestAnimationFrame(P)),c=e.now||(()=>performance.now()),l=jV(),u={target:[0,0],zoom:0,width:1,height:1},f={minZoom:-1/0,maxZoom:Z3},d=null,h=!1,p=[],m=null,g=[],v=null,y=null,b=!1,x=!1,E=0,w=new Set,T=!1;n.classList.add("or-view");let R=document.createElement("div");R.className="or-view-canvas",n.appendChild(R);let F=document.createElement("div");F.className="or-view-markers",n.appendChild(F);let O=new Map,j=new Map,V=new Map,G=new Map,q=new WeakMap,X=[],se=ur(Q,a),le=new Oh({isEnabled:()=>r.doubleBuffer(),isSmooth:()=>r.smooth(),now:c,onChange:()=>se()}),he=null;function at(){return{dragPan:!0,dragRotate:!1,scrollZoom:!1,doubleClickZoom:!1,touchZoom:!e.isStatic,touchRotate:!1,keyboard:!1,inertia:!1}}function Ct(){return{target:[u.target[0],u.target[1],0],zoom:u.zoom,minZoom:f.minZoom,maxZoom:f.maxZoom}}function Tn(){return new t.Deck({parent:R,views:new t.OrthographicView({id:"main",flipY:!1,controller:at()}),viewState:Ct(),layers:[],useDevicePixels:!0,deviceProps:{webgl:{preserveDrawingBuffer:!!e.preserveDrawingBuffer}},getCursor:({isDragging:P})=>w.size?"crosshair":P?"grabbing":"default",onViewStateChange:({viewState:P})=>{if(d=null,Gt(P.target,P.zoom),h){let k=c();g.push({t:k,target:[...u.target],zoom:u.zoom}),g=g.filter($=>k-$.t<=Y3)}return Ct()},onInteractionStateChange:P=>{let k=!!(P.isDragging||P.isPanning||P.isZooming||P.inTransition);if(k!==h){if(h=k,k){g=[],ui();return}queueMicrotask(()=>{!h&&!d&&!Ge()&&fi()})}},onLoad:()=>{Ni(),m=HV(he),l.emit("renderer",m),se()},onAfterRender:()=>{let P=p;p=[],P.forEach(k=>k())}})}function Ni(){let P=he.getCanvas&&he.getCanvas();P?.addEventListener("webglcontextlost",k=>{if(k.preventDefault(),T)return;l.emit("contextlost");let $=he;he=null,q=new WeakMap,X=[];try{$.finalize?.()}catch{}P.remove();try{he=Tn(),l.emit("contextrestored")}catch(W){l.emit("contextfailed",W)}se()})}t&&typeof t.Deck=="function"&&(he=Tn());function Ln(){let P=o(),k=Math.max(1,Math.floor(n.clientWidth*P)/P),$=Math.max(1,Math.floor(n.clientHeight*P)/P),W=k!==u.width||$!==u.height;return u.width=k,u.height=$,R.style.width=k+"px",R.style.height=$+"px",W}Ln();let li=null;typeof ResizeObserver=="function"&&(li=new ResizeObserver(()=>cn()),li.observe(n));function cn(){Ln()?(ln(),l.emit("resize",yt())):se()}function Gt(P,k,{tiles:$=!0}={}){let W=bs(k,f),re=W!==u.zoom;u.target=[P[0],P[1]],u.zoom=W,ln(re,$)}function ln(P=!1,k=!0){he&&he.setProps({viewState:Ct()}),P&&l.emit("zoom"),l.emit("move"),k&&Wt(),se()}function ui(){x||(x=!0,l.emit("movestart"))}function fi(){if(d||h)return;let P=Math.round(u.zoom);if(Math.abs(P-u.zoom)>1e-9){Vt({target:Mh(u,[u.width/2,u.height/2],P),zoom:P},{anchor:null});return}u.target=a3(u,o());let k=x;x=!1,ln(),k&&(l.emit("moveend"),l.emit("zoomend"))}function Ge(){let P=g;if(g=[],!r.smooth()||P.length<2)return!1;let k=P[0],$=P[P.length-1],W=$.t-k.t;if(W<=0||c()-$.t>Y3||k.zoom!==$.zoom)return!1;let re=($.target[0]-k.target[0])/W,ee=($.target[1]-k.target[1])/W;return Math.hypot(re,ee)*Math.pow(2,u.zoom)H3?0:j3}function Vt(P,{anchor:k=null,ms:$=void 0,settle:W=!0,curve:re=!1}={}){P={target:P.target,zoom:bs(P.zoom,f)};let ee=re&&$===void 0?di(P):null;if($===void 0&&($=ee?ee.ms:_t(P)),ui(),P.zoom!==u.zoom&&l.emit("zoomstart"),$<=0){d=null;let oe=W&&!h;Gt(P.target,P.zoom,{tiles:!oe}),W&&fi();return}y=null,d={from:{...u,target:[...u.target]},to:P,anchor:k,start:ee?null:c(),created:c(),ms:$,flight:ee},Wt(),hi()}function di(P){if(!r.smooth()||!(Math.hypot(P.target[0]-u.target[0],P.target[1]-u.target[1])*Math.pow(2,Math.min(u.zoom,P.zoom))>NV*Math.max(u.width,u.height))&&Math.abs(P.zoom-u.zoom)<=H3)return null;let W=c3(u,{...u,...P}),re=1/0,ee=null;for(let de=0;de<=16;de++){let Y=W.at(de/16);re=Math.min(re,Y.zoom);let pe=jo({...u,...Y});ee=ee?[Math.min(ee[0],pe[0]),Math.min(ee[1],pe[1]),Math.max(ee[2],pe[2]),Math.max(ee[3],pe[3])]:pe}let oe=Math.max(0,zb(re)),_e=Fl(ee,oe,s());return{path:W,ms:Math.min($V,Math.max(UV,zV*W.S)),apex:_e?{z:oe,range:_e}:null}}function Mn(P){return!P||[...O.values()].every(k=>!k.visible||k.grid.settledIn(P.z,P.range))}function hi(){if(!d||T)return;if(d.start===null){if(!Mn(d.flight.apex)&&c()-d.created=1){let re=d.to;y=d.flight?d.flight.apex:null,d=null,Gt(re.target,re.zoom),fi();return}Gt(W,$),a(hi)}function Ke(){return d?{...u,target:d.to.target,zoom:d.to.zoom}:u}function Wt(){if(O.size===0)return;let P=r.doubleBuffer(),k=bs(zb(u.zoom,{targetZoom:d?d.to.zoom:null,hidingNewLevels:P}),{minZoom:0,maxZoom:Z3}),$=Ke(),W=Fl(jo($),k,s()),re=Ah(W),ee=le.shownZ,oe=r.defer()&&h;oe||le.setZoom(k,{hasContent:[...O.values()].some(pe=>pe.visible&&ee!==null&&pe.grid.hasContentAt(ee))});let _e=[];k>0&&!d&&!h&&!x&&le.pendingZ===null&&(v=k-1,_e.push({z:v,range:Fl(Ub(jo($),DV),v,s())}));let de=un();de&&_e.push({...de,background:!1});let Y=d?Fl(jo(u),k,s()):null;for(let pe of O.values())pe.visible&&!oe&&pe.grid.update({z:k,range:W,ring:re,extra:_e,hold:Y});yr()}function un(){return d&&d.flight&&d.flight.apex||y}function An(P){let k=[];for(let $ of[un()?.z,le.pendingZ])$!=null&&!k.includes($)&&!P.some(W=>W.z===$)&&k.push($);return k}function Rs(){b||(b=!0,queueMicrotask(()=>{b=!1,T||Wt()}))}function pi(){for(let P of O.values())if(P.visible&&!P.grid.isSettled())return!1;return!0}function yr(P){let k=le.check({settled:pi(),animating:!!d});k&&le.pendingZ===null&&Rs();let $=!1;y&&!d&&le.isIdle()&&pi()&&(y=null,$=!0),(k||$||!P||kn(P.z))&&se()}function kn(P){let k=le.plan(c()).draw;return k.some($=>$.z===P)||An(k).includes(P)}function jt(P,{order:k,source:$,visible:W=!0}){let re={load:(oe,_e)=>$.load(oe,_e),release:oe=>{let _e=oe&&q.get(oe);_e&&(q.delete(oe),X.push(_e)),$.release?.(oe)}},ee={id:P,order:k,visible:W,grid:new kh({source:re,onChange:oe=>yr(oe)})};return O.set(P,ee),Wt(),{id:P,setVisible(oe){ee.visible!==!!oe&&(ee.visible=!!oe,ee.visible||ee.grid.clear(),Wt())},isVisible:()=>ee.visible,refresh(){ee.visible&&(ee.grid.refresh(),se())},remove(){ee.grid.clear(),O.delete(P),se()}}}function Re(P){if(!he||!he.device)return P.image;let k=q.get(P);if(!k){try{k=he.device.createTexture({data:P.image,width:P.width,height:P.height,mipLevels:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}})}catch{return P.image}q.set(P,k)}return k}function na(P){if(P>=E)return 1;let k=(q3-(E-P))%400/400;return 1-.7*(.5-.5*Math.cos(2*Math.PI*k))}let Ce=new WeakMap,M=null;function S(P){let k=s();k!==M&&(Ce=new WeakMap,M=k);let $=Ce.get(P);return $||($=o3(P.z,P.x,P.y,k),Ce.set(P,$)),$}function L(P,k,$,W,re,ee){for(let oe of k.grid.drawableTilesAt($)){let _e=S(oe);$b(_e,W)&&P.push({order:k.order,props:{id:`${k.id}:${re}${oe.key}`,image:Re(oe.drawable),bounds:_e,opacity:ee,parameters:Es}})}}function D(P,k){let $=[],W=le.plan(P);if(!W.fading&&le.pendingZ===null&&W.draw.length>0){let de=[...W.draw.map(Y=>Y.z),v,un()?.z].filter(Y=>Y!=null);for(let Y of O.values())Y.grid.prune(de)}let re=na(P),ee=[...O.values()].sort((de,Y)=>de.order-Y.order),oe=ee.find(de=>de.visible),_e=An(W.draw);for(let de of ee)if(de.visible){de===oe&&_e.length>0&&$.push(...A(de,_e,W.draw,k,re));for(let Y of W.draw)L($,de,Y.z,k,"",Y.opacity*re)}return{layers:$,animate:W.fading||Ppe.z===de.z)||de.loading&&!de.drawable)continue;let Y=S(de);if($b(Y,W)){let[pe,Rn,lp,ia]=Y;_e.push([[pe-oe,Rn-oe],[lp+oe,Rn-oe],[lp+oe,ia+oe],[pe-oe,ia+oe]])}}return _e.length&&ee.push({order:P.order,kind:"SolidPolygonLayer",props:{id:`${P.id}:mask`,data:_e,getPolygon:de=>de,getFillColor:z(),parameters:Es}}),ee}function z(){let P=(getComputedStyle(n).backgroundColor||"").match(/[\d.]+/g);return!P||P.length<3||P.length>3&&Number(P[3])===0?[0,0,0,255]:[Number(P[0]),Number(P[1]),Number(P[2]),255]}function I(P,k,$){let W=[],re=[],ee=[],oe=[];for(let Y of k){if(Y.kind==="circle"){oe.push(Y);continue}let pe=Y.kind==="rect"?[[Y.rect[0],Y.rect[1]],[Y.rect[2],Y.rect[1]],[Y.rect[2],Y.rect[3]],[Y.rect[0],Y.rect[3]]]:Y.points;if(Y.fill&&re.push({polygon:pe,color:Y.fill}),Y.stroke){let Rn=Y.kind==="rect"||Y.closed;ee.push({path:Rn?[...pe,pe[0]]:pe,color:Y.stroke,width:Y.width||1,dash:Y.dash||null})}}re.length&&W.push({order:$,kind:"SolidPolygonLayer",props:{id:`${P}:fill`,data:re,getPolygon:Y=>Y.polygon,getFillColor:Y=>Y.color,parameters:Es}});let _e=ee.filter(Y=>!Y.dash),de=ee.filter(Y=>Y.dash);if(_e.length&&W.push({order:$,kind:"PathLayer",props:{id:`${P}:stroke`,data:_e,widthUnits:"pixels",getPath:Y=>Y.path,getColor:Y=>Y.color,getWidth:Y=>Y.width,parameters:Es}}),de.length){let Y={id:`${P}:dash`,data:de,widthUnits:"pixels",getPath:pe=>pe.path,getColor:pe=>pe.color,getWidth:pe=>pe.width,getDashArray:pe=>pe.dash.map(Rn=>Rn/pe.width),dashJustified:!0,parameters:Es};t?.PathStyleExtension&&(Y.extensions=[new t.PathStyleExtension({dash:!0})]),W.push({order:$,kind:"PathLayer",props:Y})}return oe.length&&W.push({order:$,kind:"ScatterplotLayer",props:{id:`${P}:circle`,data:oe,radiusUnits:"pixels",lineWidthUnits:"pixels",getPosition:Y=>Y.center,getRadius:Y=>Y.radius,stroked:!0,filled:!0,getLineColor:Y=>Y.stroke||[0,0,0,0],getFillColor:Y=>Y.fill||[0,0,0,0],getLineWidth:Y=>Y.width||1,parameters:Es}}),W}function B(){let P=[];for(let k of j.values())P.push(...k);return P.push(...V.values()),P}function U(P){return P.map(k=>new t[k.kind||"BitmapLayer"](k.props))}let Z=0;function Q(){if(T)return;let P=c(),k=D(P,Ub(jo(u),.5)),$=[...k.layers,...B()].sort((W,re)=>W.order-re.order);Z=$.length,he&&he.setProps({layers:U($)});for(let W of X.splice(0))W.destroy?.();Oe(),k.animate&&se(),l.emit("render")}function ye(P=32,k=20){let $=O.get("base");if(!$)return null;let W=s(),re=le.plan(c()).draw,ee=[...re,...An(re).map(de=>({z:de}))],oe=0,_e=0;for(let de=0;de=W||Rn>=W)continue;oe++,ee.some(({z:ia})=>{let _v=W/2**ia,up=$.grid.tiles.get(Ho(ia,Math.floor(pe/_v),Math.floor((W-Rn)/_v)));return up&&(up.drawable||!up.loading)})&&_e++}return oe?_e/oe:null}function be(P){return G.has(P)||G.set(P,{visible:!0,items:new Map}),G.get(P)}function je(P,k){let[$,W]=Lh(P.world,u);P.el.style.display=k?"":"none",P.el.style.transform=`translate(${$}px, ${W}px)`+(P.center?" translate(-50%, -50%)":"")}function Be(P){for(let k of P.items.values())je(k,P.visible)}function Oe(){for(let P of G.values())Be(P)}function yt(){return{width:u.width,height:u.height}}let K={DRAW_ORDER:ot,getContainer:()=>n,getRendererInfo:()=>m,getSize:yt,getZoom:()=>u.zoom,getTargetZoom:()=>d?d.to.zoom:u.zoom,getCenter:()=>[...u.target],getViewState:()=>({...u,target:[...u.target]}),isAnimating:()=>!!d,isMoving:()=>x,project:P=>Lh(P,u),unproject:P=>Wo(P,u),on:l.on,off:l.off,setLimits({minZoom:P,maxZoom:k}={}){P!==void 0&&(f.minZoom=P),k!==void 0&&(f.maxZoom=k);let $=bs(u.zoom,f);$!==u.zoom?Gt(u.target,$):he&&he.setProps({viewState:Ct()}),l.emit("limits")},getLimits:()=>({...f}),setView(P,k=u.zoom,{animate:$}={}){let W={target:[P[0],P[1]],zoom:k};Vt(W,$===!1?{ms:0}:{curve:!0})},fitWorldRect(P,{padding:k=[0,0],animate:$}={}){let W=s3(P,u,{padding:k,...f});Vt(W,$===!1?{ms:0}:{curve:!0})},zoomAround(P,k,{animate:$,settle:W=!0}={}){let re=bs(K.getTargetZoom()+k,f),ee=Ke(),oe=P||[u.width/2,u.height/2],_e=Mh(ee,oe,re);Vt({target:_e,zoom:re},$===!1?{ms:0,settle:W}:{anchor:P?oe:null})},zoomIn:()=>K.zoomAround(null,1),zoomOut:()=>K.zoomAround(null,-1),panByPx(P,k,{animate:$}={}){let W=Ke(),re=Math.pow(2,W.zoom),ee=[W.target[0]+P/re,W.target[1]-k/re],oe=$===!1||!r.smooth()?0:j3;Vt({target:ee,zoom:W.zoom},{ms:oe})},invalidateSize:cn,applyPrefs(){Wt()},addTileSlot:jt,setOverlay(P,k,{order:$=ot.selection}={}){!k||k.length===0?j.delete(P):j.set(P,I(P,k,$)),se()},hasOverlay:P=>j.has(P),setImageOverlay(P,k,{order:$=ot.pathImage}={}){k?V.set(P,{order:$,kind:"BitmapLayer",props:{id:`image:${P}`,image:k.image,bounds:k.rect,parameters:Es}}):V.delete(P),se()},addMarker(P,k,$,W,{center:re=!1}={}){let ee=be(P),oe=ee.items.get(k);oe&&oe.el.remove(),W.classList.add("or-view-marker"),F.appendChild(W);let _e={el:W,world:[$[0],$[1]],center:re};return ee.items.set(k,_e),je(_e,ee.visible),W},moveMarker(P,k,$){let W=be(P),re=W.items.get(k);re&&(re.world=[$[0],$[1]],je(re,W.visible))},clearMarkers(P){let k=be(P);for(let $ of k.items.values())$.el.remove();k.items.clear()},setMarkerGroupVisible(P,k){let $=be(P);$.visible=!!k,Be($)},setCursorMode(P,k=!0){k?w.add(P):w.delete(P),n.classList.toggle(`${P}-mode-cursor`,!!k);let $=he&&he.getCanvas&&he.getCanvas();$&&($.style.cursor=w.size?"crosshair":"default")},flashTiles(){E=c()+q3,se()},whenTilesSettled({timeoutMs:P=6e3}={}){let k=c()+P;return new Promise($=>{let W=()=>{if(pi()&&le.isIdle()&&!d&&!x||c()>=k){$();return}setTimeout(W,32)};W()})},captureCanvas({timeoutMs:P=500}={}){return he?.getCanvas()?(Q(),new Promise(k=>{let $=null,W=()=>{clearTimeout($),p=p.filter(ee=>ee!==W);let re=he?.getCanvas();k(re?{image:i(re),rect:re.getBoundingClientRect()}:null)};p.push(W),$=setTimeout(()=>{he?.redraw("capture"),W()},P)})):Promise.resolve(null)},redraw:()=>se(),debugSnapshot(){let P=le.plan();return{zoom:u.zoom,target:[...u.target],width:u.width,height:u.height,animating:!!d,moving:x,interacting:h,shownZ:le.shownZ,pendingZ:le.pendingZ,fading:P.fading,drawLevels:P.draw,layers:Z,coverage:ye(),overlays:[...j.keys()],markers:Object.fromEntries([...G].map(([k,$])=>[k,$.items.size])),slots:[...O.values()].map(k=>({id:k.id,visible:k.visible,settled:k.grid.isSettled(),...k.grid.stats()}))}},destroy(){T=!0,li?.disconnect(),le.dispose();for(let P of O.values())P.grid.clear();he?.finalize?.()}};return K}var YV=4.000244140625;function qV(n){return n.deltaMode!==0?!0:n.deltaX!==0||n.deltaY===0?!1:Number.isInteger(n.deltaY)&&Math.abs(n.deltaY)>=50||n.deltaY%YV===0}function ZV(n){let e=Math.abs(n);return e<.2?0:Math.sign(n)*Math.max(1,Math.round(e))}function XV(n,e){let i=1;return n.deltaMode===1?i=16:n.deltaMode===2&&(i=e.clientHeight||16),[n.deltaX*i,n.deltaY*i]}function KV(n,e,t){let i=t?3*e:e;switch(n){case"ArrowLeft":return[-i,0];case"ArrowRight":return[i,0];case"ArrowUp":return[0,-i];case"ArrowDown":return[0,i];default:return null}}function Q3(n,e={}){let t=n.getContainer(),i=e.isStatic||(()=>!1),r=e.wheelZoom||(()=>!0),s=e.arrowStep||(()=>80),o=e.gestureIdleMs??200,a=e.contextEnabled||(()=>!0),c=[],l=(w,T,R,F)=>{w.addEventListener(T,R,F),c.push(()=>w.removeEventListener(T,R,F))},u=w=>{let T=t.getBoundingClientRect();return[w.clientX-T.left,w.clientY-T.top]},f=w=>n.unproject(u(w)),d=w=>w.target===t||!!w.target?.closest?.(".or-view-canvas");t.tabIndex<0&&(t.tabIndex=0);let h=null;function p(w,T){h||(h={z0:n.getZoom()}),h.pt=w,clearTimeout(h.timer),h.timer=setTimeout(m,o),n.zoomAround(w,T,{animate:!1,settle:!1})}function m(){if(!h)return;let w=h;h=null,clearTimeout(w.timer);let T=n.getZoom();n.zoomAround(w.pt,w.z0+ZV(T-w.z0)-T)}c.push(()=>{clearTimeout(h?.timer),h=null}),l(t,"wheel",w=>{if(w.preventDefault(),i())return;let T=qV(w);if(!T&&w.ctrlKey){p(u(w),-w.deltaY/(100*Math.LN2));return}if(r()===w.ctrlKey){let[R,F]=XV(w,t);n.panByPx(R,F,{animate:!1});return}if(!T){p(u(w),-w.deltaY/100);return}m(),n.zoomAround(u(w),w.deltaY<0?1:-1)},{passive:!1}),l(t,"keydown",w=>{if(w.altKey||w.ctrlKey||w.metaKey)return;let T=KV(w.key,s(),w.shiftKey);if(T){w.preventDefault(),n.panByPx(T[0],T[1]);return}if(i())return;let R={"+":1,"=":1,"-":-1,_:-1};w.key in R&&(w.preventDefault(),n.zoomAround(null,R[w.key]*(w.shiftKey?3:1)))});let g=null,v=null;l(t,"pointerdown",w=>{w.button!==0||!d(w)||(t.focus({preventScroll:!0}),g={x:w.clientX,y:w.clientY,moved:!1,box:w.shiftKey&&!i()},g.box&&w.stopPropagation())},{capture:!0}),l(window,"pointermove",w=>{if(!g)return;let T=w.clientX-g.x,R=w.clientY-g.y;(Math.abs(T)>3||Math.abs(R)>3)&&(g.moved=!0),g.box&&g.moved&&(v=K3(v,g,w))}),l(window,"pointerup",w=>{if(!g||w.button!==0)return;let T=g;if(g=null,v&&(v.remove(),v=null),T.box&&T.moved){E(T,w);return}!T.moved&&e.onClick&&x(w)&&e.onClick(f(w),w)}),l(t,"dblclick",w=>{i()||!d(w)||n.zoomAround(u(w),w.shiftKey?-1:1)});let y=null,b=null;l(t,"contextmenu",w=>w.preventDefault()),l(t,"pointerdown",w=>{w.button!==2||i()||!d(w)||(w.stopPropagation(),y={x:w.clientX,y:w.clientY})},{capture:!0}),l(window,"pointermove",w=>{if(!y)return;let T=w.clientX-y.x,R=w.clientY-y.y;(b||Math.abs(T)>=4&&Math.abs(R)>=4)&&(b=K3(b,y,w))}),l(window,"pointerup",w=>{if(!y||w.button!==2)return;let T=y;if(y=null,b){b.remove(),b=null,E(T,w);return}x(w)&&a()&&e.onContextClick&&e.onContextClick(f(w),w)}),l(t,"pointermove",w=>{e.onMove&&e.onMove(f(w),w)}),l(t,"pointerleave",w=>{e.onLeave&&e.onLeave(w)});function x(w){let T=t.getBoundingClientRect();return w.clientX>=T.left&&w.clientX<=T.right&&w.clientY>=T.top&&w.clientY<=T.bottom}function E(w,T){let R=t.getBoundingClientRect(),F=n.unproject([w.x-R.left,w.y-R.top]),O=n.unproject([T.clientX-R.left,T.clientY-R.top]);n.fitWorldRect([Math.min(F[0],O[0]),Math.min(F[1],O[1]),Math.max(F[0],O[0]),Math.max(F[1],O[1])])}return{dispose(){for(let w of c.splice(0))w()}}}function K3(n,e,t){return n||(n=document.createElement("div"),n.className="rubber-band",document.body.appendChild(n)),n.style.left=Math.min(e.x,t.clientX)+"px",n.style.top=Math.min(e.y,t.clientY)+"px",n.style.width=Math.abs(t.clientX-e.x)+"px",n.style.height=Math.abs(t.clientY-e.y)+"px",n}var Ps=class n{constructor(e,t,i){this._app=e,this._redrawAllLayers=t,this._refreshOverlay=i||t,this._currentTab="setup",this._setupPaths=[],this._holdPaths=[],this._selectedPathIndex=-1,this._detailTab="data",this._selectedDetailIndex=-1,this._sortCol="slack",this._sortAscending=!0,this._build()}_build(){let e=document.createElement("div");e.className="timing-widget";let t=document.createElement("div");t.className="timing-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",fe(this._app)&&(this._updateBtn.style.display="none"),this._pathCountLabel=document.createElement("span"),this._pathCountLabel.className="timing-path-count",t.appendChild(this._updateBtn),t.appendChild(this._pathCountLabel),e.appendChild(t),e.appendChild(this._buildConePanel());let i=document.createElement("div");i.className="timing-tab-bar",this._setupTab=this._makeTab("Setup",!0),this._holdTab=this._makeTab("Hold",!1),i.appendChild(this._setupTab),i.appendChild(this._holdTab),e.appendChild(i),this._pathTableContainer=document.createElement("div"),this._pathTableContainer.className="timing-path-table-container",this._pathTable=document.createElement("table"),this._pathTable.className="timing-table",this._pathTableContainer.appendChild(this._pathTable),e.appendChild(this._pathTableContainer);let r=document.createElement("div");r.className="timing-tab-bar",this._dataTab=this._makeTab("Data Path",!0),this._captureTab=this._makeTab("Capture Path",!1),r.appendChild(this._dataTab),r.appendChild(this._captureTab),e.appendChild(r),this._detailTableContainer=document.createElement("div"),this._detailTableContainer.className="timing-detail-table-container",this._detailTable=document.createElement("table"),this._detailTable.className="timing-table",this._detailTableContainer.appendChild(this._detailTable),e.appendChild(this._detailTableContainer),this._headerTooltip=document.createElement("div"),this._headerTooltip.className="or-tooltip or-tooltip-fixed",e.appendChild(this._headerTooltip),this.element=e,this._bindEvents(),fe(this._app)&&setTimeout(()=>this.update(),0)}_makeTab(e,t){let i=document.createElement("button");return i.className="timing-tab"+(t?" active":""),i.textContent=e,i}_bindEvents(){this._setupTab.addEventListener("click",()=>{this._currentTab="setup",this._setupTab.classList.add("active"),this._holdTab.classList.remove("active"),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}),this._holdTab.addEventListener("click",()=>{this._currentTab="hold",this._holdTab.classList.add("active"),this._setupTab.classList.remove("active"),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}),this._dataTab.addEventListener("click",()=>{this._detailTab="data",this._dataTab.classList.add("active"),this._captureTab.classList.remove("active"),this._renderDetailTable()}),this._captureTab.addEventListener("click",()=>{this._detailTab="capture",this._captureTab.classList.add("active"),this._dataTab.classList.remove("active"),this._renderDetailTable()}),this._updateBtn.addEventListener("click",()=>this.update()),this._pathTableContainer.setAttribute("tabindex","0"),this._pathTableContainer.style.outline="none",this._pathTableContainer.addEventListener("keydown",e=>{if(e.key==="ArrowDown"){e.preventDefault();let t=this._pathTable.querySelectorAll("tbody tr");this._selectedPathIndex0&&this._selectPathRow(this._selectedPathIndex-1))}),this._detailTableContainer.setAttribute("tabindex","0"),this._detailTableContainer.style.outline="none",this._detailTableContainer.addEventListener("keydown",e=>{if(e.key==="ArrowDown"){e.preventDefault();let t=this._detailTable.querySelectorAll("tbody tr");this._selectedDetailIndex0&&this._selectDetailRow(this._selectedDetailIndex-1))})}_buildConePanel(){let e=document.createElement("div");e.className="timing-cone-panel";let t=document.createElement("span");t.className="timing-cone-title",t.textContent="Timing cone:",e.appendChild(t);let i=(u,f,d=!1)=>{let h=document.createElement("input");h.type="checkbox",h.id=u,h.checked=d;let p=document.createElement("label");return p.htmlFor=u,p.textContent=f,{input:h,lbl:p}},r=i("cone-fanin","Fanin",!0),s=i("cone-fanout","Fanout",!0);this._coneFanin=r.input,this._coneFanout=s.input,e.append(r.input,r.lbl,s.input,s.lbl);let o=u=>{let f=document.createElement("label");f.className="timing-cone-depth-label",f.textContent=u;let d=document.createElement("input");return d.type="number",d.min="0",d.value="0",d.className="timing-cone-depth",d.title="0 = unlimited",f.appendChild(d),{lbl:f,input:d}},a=o("in\u2264"),c=o("out\u2264");this._coneFaninDepth=a.input,this._coneFanoutDepth=c.input,e.append(a.lbl,c.lbl),this._coneColorMode=document.createElement("select"),this._coneColorMode.className="timing-cone-colormode";for(let[u,f]of[["slack","by slack"],["depth","by depth"]]){let d=document.createElement("option");d.value=u,d.textContent=f,this._coneColorMode.appendChild(d)}e.appendChild(this._coneColorMode);let l=i("cone-sync-schematic","Sync schematic");return this._coneSyncSchematic=l.input,e.append(l.input,l.lbl),this._coneApplyBtn=document.createElement("button"),this._coneApplyBtn.className="or-btn",this._coneApplyBtn.textContent="Cone",this._coneApplyBtn.title="Show the timing cone for the selected instance",this._coneClearBtn=document.createElement("button"),this._coneClearBtn.className="or-btn",this._coneClearBtn.textContent="Clear",e.append(this._coneApplyBtn,this._coneClearBtn),this._coneStatus=document.createElement("span"),this._coneStatus.className="timing-cone-status",e.appendChild(this._coneStatus),this._coneApplyBtn.addEventListener("click",()=>this._applyCone()),this._coneClearBtn.addEventListener("click",()=>this._clearCone()),e}_coneTarget(){return this._app.selectedInstanceName||""}async _applyCone(){let e=this._coneFanin.checked,t=this._coneFanout.checked;if(!e&&!t){this._coneStatus.textContent="select fanin and/or fanout";return}let i=this._coneTarget();if(!i){this._coneStatus.textContent="select an instance first";return}let r={type:"timing_cone",fanin:e,fanout:t,fanin_depth:Math.max(0,parseInt(this._coneFaninDepth.value,10)||0),fanout_depth:Math.max(0,parseInt(this._coneFanoutDepth.value,10)||0),color_mode:this._coneColorMode.value,inst_name:i};this._coneApplyBtn.disabled=!0,this._coneStatus.textContent="computing\u2026";try{let s=await this._app.websocketManager.request(r);this._refreshOverlay(),this._renderConeStatus(s),this._coneSyncSchematic.checked&&i&&document.dispatchEvent(new CustomEvent("openroad-cone-sync",{detail:{inst_name:i,fanin:r.fanin,fanout:r.fanout,fanin_depth:r.fanin_depth,fanout_depth:r.fanout_depth}}))}catch(s){this._coneStatus.textContent="cone error: "+(s.message||s)}this._coneApplyBtn.disabled=!1}_renderConeStatus(e){if(!e){this._coneStatus.textContent="";return}let t=e.node_count||0;if(t===0){this._coneStatus.textContent="empty cone";return}let i=t+" pins";if(e.color_mode==="depth")i+=`, depth \xB1${e.max_depth}`;else if(e.constrained){let r=e.time_unit||"";i+=`, slack ${Ss(e.min_slack)}\u2026${Ss(e.max_slack)}${r}`}else i+=", unconstrained";this._coneStatus.textContent=i}_clearCone(){this._app.websocketManager.request({type:"timing_cone",clear:!0}).then(()=>this._refreshOverlay()),this._coneStatus.textContent=""}showPaths(e,t){this._currentTab=e,e==="setup"?(this._setupPaths=[...t],this._setupTab.classList.add("active"),this._holdTab.classList.remove("active")):(this._holdPaths=[...t],this._holdTab.classList.add("active"),this._setupTab.classList.remove("active")),this._applySort(),this._selectedPathIndex=-1,this._pathCountLabel.textContent=t.length+" paths",this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...";try{let[e,t]=await Promise.all([this._app.websocketManager.request({type:"timing_report",is_setup:!0,max_paths:100}),this._app.websocketManager.request({type:"timing_report",is_setup:!1,max_paths:100})]);this._setupPaths=[...e.paths||[]],this._holdPaths=[...t.paths||[]],this._applySort(),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}catch(e){console.error("Timing fetch failed:",e)}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}_applySort(){for(let e of[this._setupPaths,this._holdPaths]){e.forEach((r,s)=>{r._originalIndex===void 0&&(r._originalIndex=s)});let t=this._sortAscending?1:-1,i=this._sortCol;e.sort((r,s)=>{let o=r[i],a=s[i],c=typeof o=="number"&&typeof a=="number"?o-a:String(o).localeCompare(String(a));return t*c})}}_showHeaderTooltip(e,t){if(e.buttons!==0){this._hideHeaderTooltip();return}let i=this._headerTooltip;i.textContent=t,i.style.display="block";let r=Math.min(e.clientX+12,window.innerWidth-i.offsetWidth-8);i.style.left=Math.max(0,r)+"px",i.style.top=e.clientY+14+"px"}_hideHeaderTooltip(){this._headerTooltip.style.display="none"}_sortBy(e){this._sortCol===e?this._sortAscending=!this._sortAscending:(this._sortCol=e,this._sortAscending=!0),this._applySort(),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}_clearTimingHighlight(){this._app.websocketManager.request({type:"timing_highlight",path_index:-1}).then(()=>this._refreshOverlay())}_selectPathRow(e){let t=this._pathTable.querySelectorAll("tbody tr");if(e<0||e>=t.length)return;this._selectedPathIndex=e;for(let s of t)s.classList.remove("selected");t[e].classList.add("selected"),t[e].scrollIntoView({block:"nearest"}),this._pathTableContainer.focus(),this._renderDetailTable();let r=(this._currentTab==="setup"?this._setupPaths:this._holdPaths)[e]?._originalIndex??e;this._app.websocketManager.request({type:"timing_highlight",path_index:r,is_setup:this._currentTab==="setup"}).then(()=>this._refreshOverlay()).catch(s=>console.error("timing_highlight error:",s))}_renderPathTable(){this._hideHeaderTooltip();let e=this._currentTab==="setup"?this._setupPaths:this._holdPaths;this._pathCountLabel.textContent=e.length+" paths";let t=this._pathTable.querySelectorAll("thead th"),i=Array.from(t,c=>c.style.width);this._pathTable.innerHTML="";let r=document.createElement("thead"),s=document.createElement("tr");for(let c of n.PATH_COLS){let l=document.createElement("th");l.classList.add("sortable"),c.num&&l.classList.add("num"),l.textContent=c.label+(c.key===this._sortCol?this._sortAscending?" \u25B2":" \u25BC":""),c.tooltip&&(l.addEventListener("mousemove",u=>this._showHeaderTooltip(u,c.tooltip)),l.addEventListener("mouseleave",()=>this._hideHeaderTooltip())),l.addEventListener("click",()=>this._sortBy(c.key)),s.appendChild(l)}r.appendChild(s),this._pathTable.appendChild(r);let o=document.createElement("tbody"),a=e.reduce((c,l)=>Math.max(c,Math.abs(Number(l.slack)||0)),0);if(e.forEach((c,l)=>{let u=document.createElement("tr");l===this._selectedPathIndex&&u.classList.add("selected");for(let f of n.PATH_COLS){let d=document.createElement("td"),h=c[f.key];if(d.textContent=f.time?Ss(h):h,f.num&&d.classList.add("num"),f.key==="slack"){let p=Number(c.slack);p<0&&d.classList.add("slack-negative"),Number.isFinite(p)&&a>0&&(d.classList.add("slack-cell",p<0?"slack-under":"slack-over"),d.style.setProperty("--slack-frac",String(Math.abs(p)/a)))}u.appendChild(d)}u.style.cursor="pointer",u.addEventListener("click",()=>this._selectPathRow(l)),o.appendChild(u)}),e.length===0){let c=document.createElement("tr"),l=document.createElement("td");l.colSpan=n.PATH_COLS.length,l.style.textAlign="center",l.style.color="var(--fg-secondary)",l.textContent=fe(this._app)?"No timing data available":'Click "Update" to load timing paths',c.appendChild(l),o.appendChild(c)}this._pathTable.appendChild(o),ws(this._pathTable,i)}_selectDetailRow(e){let t=this._detailTable.querySelectorAll("tbody tr");if(e<0||e>=t.length)return;this._selectedDetailIndex=e;for(let a of t)a.classList.remove("timing-selected-row");t[e].classList.add("timing-selected-row"),t[e].scrollIntoView({block:"nearest"}),this._detailTableContainer.focus();let r=(this._currentTab==="setup"?this._setupPaths:this._holdPaths)[this._selectedPathIndex],s=this._detailTab==="data"?r.data_nodes:r.capture_nodes,o=r._originalIndex??this._selectedPathIndex;this._app.websocketManager.request({type:"timing_highlight",path_index:o,is_setup:this._currentTab==="setup",pin_name:s[e].pin}).then(()=>this._refreshOverlay())}_renderDetailTable(){let e=this._detailTable.querySelectorAll("thead th"),t=Array.from(e,l=>l.style.width);this._detailTable.innerHTML="",this._selectedDetailIndex=-1;let i=this._currentTab==="setup"?this._setupPaths:this._holdPaths;if(this._selectedPathIndex<0||this._selectedPathIndex>=i.length)return;let r=i[this._selectedPathIndex],s=this._detailTab==="data"?r.data_nodes:r.capture_nodes,o=document.createElement("thead"),a=document.createElement("tr");for(let l of n.DETAIL_COLS){let u=document.createElement("th");n.DETAIL_NUM_COLS.has(l)&&u.classList.add("num"),u.textContent=l,a.appendChild(u)}o.appendChild(a),this._detailTable.appendChild(o);let c=document.createElement("tbody");if(s.forEach((l,u)=>{let f=document.createElement("tr");l.clk&&f.classList.add("timing-clock-row"),[l.pin,l.fanout,l.rise?"\u2191":"\u2193",Ss(l.time),Ss(l.delay),Ss(l.slew),Ss(l.load)].forEach((h,p)=>{let m=document.createElement("td");n.DETAIL_NUM_COLS.has(n.DETAIL_COLS[p])&&m.classList.add("num"),m.textContent=h,f.appendChild(m)}),f.style.cursor="pointer",f.addEventListener("click",()=>this._selectDetailRow(u)),c.appendChild(f)}),this._detailTable.appendChild(c),ws(this._detailTable,t),!t[0]){let l=this._detailTable.querySelector("thead th");l&&(l.style.width="30ch")}}};function Ss(n){return n==null?"":typeof n=="number"?n.toFixed(4):String(n)}Ps.PATH_COLS=[{label:"Clock",key:"end_clk"},{label:"Required",key:"required",time:!0,num:!0},{label:"Arrival",key:"arrival",time:!0,num:!0},{label:"Slack",key:"slack",time:!0,num:!0},{label:"Skew",key:"skew",time:!0,num:!0,tooltip:`The difference in arrival times between +
`,document.body.appendChild(r);let s=()=>r.remove();r.addEventListener("click",c=>{c.target===r&&s()}),r.addEventListener("keydown",c=>{c.key==="Escape"&&s()}),r.querySelector(".cancel").addEventListener("click",s),r.querySelector(".modal-close").addEventListener("click",s);let o=r.querySelector(".modal-error"),a=(c,l)=>{o.textContent=c,o.style.display=c?"block":"none",o.classList.toggle("info",!!l)};return{overlay:r,close:s,okBtn:r.querySelector(".ok"),showError:a}}var DV=1e4,NV=150,FV=3;function zV(n){return 1-(1-n)*(1-n)}var Oh=class{constructor({isEnabled:e=()=>!0,isSmooth:t=()=>!1,reducedMotion:i=Vl,now:r=()=>performance.now(),setTimer:s=(u,f)=>setTimeout(u,f),clearTimer:o=u=>clearTimeout(u),timeoutMs:a=DV,fadeMs:c=NV,onChange:l=()=>{}}={}){Object.assign(this,{isEnabled:e,isSmooth:t,reducedMotion:i,now:r,setTimer:s,clearTimer:o,timeoutMs:a,fadeMs:c,onChange:l}),this.shownZ=null,this.pendingZ=null,this.under=[],this.fade=null,this._timer=null}wantedZ(){return this.pendingZ!==null?this.pendingZ:this.shownZ}setZoom(e,{hasContent:t=!0}={}){e!==this.wantedZ()&&(this.endFade(),this._clearTimer(),this.shownZ===null?(this.shownZ=e,this.pendingZ=null,this.under=[]):t?e===this.shownZ?this.pendingZ=null:this.isEnabled()?(this.pendingZ=e,this.under=[],this._timer=this.setTimer(()=>this.reveal(),this.timeoutMs)):(this.under=[...this.under.filter(i=>i!==e),this.shownZ].slice(-FV),this.shownZ=e,this.pendingZ=null):(this.shownZ=e,this.pendingZ=null,this.under=this.under.filter(i=>i!==e)),this.onChange())}check({settled:e,animating:t=!1}){return this.pendingZ!==null?t||!e&&this.isEnabled()?!1:(this.reveal(),!0):this.under.length>0&&e&&!t?(this.under=[],this.onChange(),!0):!1}reveal(){if(this.pendingZ===null)return;this._clearTimer();let e=this.shownZ;this.shownZ=this.pendingZ,this.pendingZ=null;let t=this.isSmooth()&&!this.reducedMotion()?this.fadeMs:0;this.fade=t>0&&e!==null?{fromZ:e,toZ:this.shownZ,start:this.now(),ms:t}:null,this.onChange()}endFade(){this.fade&&(this.fade=null,this.onChange())}plan(e=this.now()){if(this.fade){let t=(e-this.fade.start)/this.fade.ms;if(t<1)return{draw:[{z:this.fade.fromZ,opacity:1},{z:this.fade.toZ,opacity:zV(Math.max(0,t))}],fading:!0};this.fade=null}return this.shownZ===null?{draw:[],fading:!1}:this.pendingZ!==null?{draw:[{z:this.shownZ,opacity:1}],fading:!1}:this.under.length>0?{draw:[...this.under,this.shownZ].map(t=>({z:t,opacity:1})),fading:!1}:{draw:[{z:this.shownZ,opacity:1}],fading:!1}}isIdle(e=this.now()){return this.pendingZ===null&&this.under.length===0&&!this.plan(e).fading}dispose(){this._clearTimer()}_clearTimer(){this._timer!==null&&(this.clearTimer(this._timer),this._timer=null)}};var ot=Object.freeze({base:10,overlay:20,heatmap:30,top:40,pathImage:50,selection:60,highlight:70,ruler:80}),Es={depthCompare:"always",depthWriteEnabled:!1},Y3=250,q3=4,Jb=300,UV=1,$V=2,GV=300,VV=300,WV=400,jV=1e3,Z3=100,HV=.05,X3=1200,K3=30;function zt(n,e=1){if(Array.isArray(n)){let r=n.length>3?n[3]:255;return[n[0],n[1],n[2],Math.round(r*e)]}let t=String(n||"#000").replace("#","");t.length===3&&(t=t.split("").map(r=>r+r).join(""));let i=parseInt(t.slice(0,6),16)||0;return[i>>16&255,i>>8&255,i&255,Math.round(255*e)]}function YV(n){return 1-Math.pow(1-n,3)}function qV(n){return n<.5?4*n*n*n:1-Math.pow(2-2*n,3)/2}function ZV(){let n=new Map;return{on(e,t){for(let i of e.split(/\s+/))n.has(i)||n.set(i,new Set),n.get(i).add(t)},off(e,t){for(let i of e.split(/\s+/))n.get(i)?.delete(t)},emit(e,t){for(let i of[...n.get(e)||[]])i(t)}}}function XV(n){let e=n&&n.device&&n.device.info||{};return{gpuType:e.gpuType||"unknown",renderer:e.renderer||"",vendor:e.vendor||""}}function Q3(n,e={}){let t=e.deckApi!==void 0?e.deckApi:globalThis.deck,i=e.copyCanvas||qb,r={smooth:()=>!1,doubleBuffer:()=>!0,defer:()=>!1,...e.prefs||{}},s=e.tileSize||(()=>240),o=e.dpr||(()=>typeof devicePixelRatio=="number"?devicePixelRatio:1),a=e.raf||(P=>requestAnimationFrame(P)),c=e.now||(()=>performance.now()),l=ZV(),u={target:[0,0],zoom:0,width:1,height:1},f={minZoom:-1/0,maxZoom:K3},d=null,h=!1,p=[],m=null,g=[],v=null,y=null,b=!1,x=!1,E=0,w=new Set,T=!1;n.classList.add("or-view");let R=document.createElement("div");R.className="or-view-canvas",n.appendChild(R);let F=document.createElement("div");F.className="or-view-markers",n.appendChild(F);let O=new Map,j=new Map,V=new Map,G=new Map,q=new WeakMap,X=[],se=ur(Q,a),le=new Oh({isEnabled:()=>r.doubleBuffer(),isSmooth:()=>r.smooth(),now:c,onChange:()=>se()}),he=null;function at(){return{dragPan:!0,dragRotate:!1,scrollZoom:!1,doubleClickZoom:!1,touchZoom:!e.isStatic,touchRotate:!1,keyboard:!1,inertia:!1}}function Ct(){return{target:[u.target[0],u.target[1],0],zoom:u.zoom,minZoom:f.minZoom,maxZoom:f.maxZoom}}function Tn(){return new t.Deck({parent:R,views:new t.OrthographicView({id:"main",flipY:!1,controller:at()}),viewState:Ct(),layers:[],useDevicePixels:!0,deviceProps:{webgl:{preserveDrawingBuffer:!!e.preserveDrawingBuffer}},getCursor:({isDragging:P})=>w.size?"crosshair":P?"grabbing":"default",onViewStateChange:({viewState:P})=>{if(d=null,$t(P.target,P.zoom),h){let k=c();g.push({t:k,target:[...u.target],zoom:u.zoom}),g=g.filter($=>k-$.t<=Z3)}return Ct()},onInteractionStateChange:P=>{let k=!!(P.isDragging||P.isPanning||P.isZooming||P.inTransition);if(k!==h){if(h=k,k){g=[],ui();return}queueMicrotask(()=>{!h&&!d&&!Ve()&&fi()})}},onLoad:()=>{Ni(),m=XV(he),l.emit("renderer",m),se()},onError:P=>{console.error("Layout view:",P),m||(m={gpuType:"none",renderer:"",vendor:""},l.emit("renderer",m))},onAfterRender:()=>{let P=p;p=[],P.forEach(k=>k())}})}function Ni(){let P=he.getCanvas&&he.getCanvas();P?.addEventListener("webglcontextlost",k=>{if(k.preventDefault(),T)return;l.emit("contextlost");let $=he;he=null,q=new WeakMap,X=[];try{$.finalize?.()}catch{}P.remove();try{he=Tn(),l.emit("contextrestored")}catch(W){l.emit("contextfailed",W)}se()})}t&&typeof t.Deck=="function"&&(he=Tn());function Ln(){let P=o(),k=Math.max(1,Math.floor(n.clientWidth*P)/P),$=Math.max(1,Math.floor(n.clientHeight*P)/P),W=k!==u.width||$!==u.height;return u.width=k,u.height=$,R.style.width=k+"px",R.style.height=$+"px",W}Ln();let li=null;typeof ResizeObserver=="function"&&(li=new ResizeObserver(()=>cn()),li.observe(n));function cn(){Ln()?(ln(),l.emit("resize",yt())):se()}function $t(P,k,{tiles:$=!0}={}){let W=bs(k,f),re=W!==u.zoom;u.target=[P[0],P[1]],u.zoom=W,ln(re,$)}function ln(P=!1,k=!0){he&&he.setProps({viewState:Ct()}),P&&l.emit("zoom"),l.emit("move"),k&&Vt(),se()}function ui(){x||(x=!0,l.emit("movestart"))}function fi(){if(d||h)return;let P=Math.round(u.zoom);if(Math.abs(P-u.zoom)>1e-9){Gt({target:Mh(u,[u.width/2,u.height/2],P),zoom:P},{anchor:null});return}u.target=a3(u,o());let k=x;x=!1,ln(),k&&(l.emit("moveend"),l.emit("zoomend"))}function Ve(){let P=g;if(g=[],!r.smooth()||P.length<2)return!1;let k=P[0],$=P[P.length-1],W=$.t-k.t;if(W<=0||c()-$.t>Z3||k.zoom!==$.zoom)return!1;let re=($.target[0]-k.target[0])/W,ee=($.target[1]-k.target[1])/W;return Math.hypot(re,ee)*Math.pow(2,u.zoom)q3?0:Y3}function Gt(P,{anchor:k=null,ms:$=void 0,settle:W=!0,curve:re=!1}={}){P={target:P.target,zoom:bs(P.zoom,f)};let ee=re&&$===void 0?di(P):null;if($===void 0&&($=ee?ee.ms:_t(P)),ui(),P.zoom!==u.zoom&&l.emit("zoomstart"),$<=0){d=null;let oe=W&&!h;$t(P.target,P.zoom,{tiles:!oe}),W&&fi();return}y=null,d={from:{...u,target:[...u.target]},to:P,anchor:k,start:ee?null:c(),created:c(),ms:$,flight:ee},Vt(),hi()}function di(P){if(!r.smooth()||!(Math.hypot(P.target[0]-u.target[0],P.target[1]-u.target[1])*Math.pow(2,Math.min(u.zoom,P.zoom))>$V*Math.max(u.width,u.height))&&Math.abs(P.zoom-u.zoom)<=q3)return null;let W=c3(u,{...u,...P}),re=1/0,ee=null;for(let de=0;de<=16;de++){let Y=W.at(de/16);re=Math.min(re,Y.zoom);let pe=jo({...u,...Y});ee=ee?[Math.min(ee[0],pe[0]),Math.min(ee[1],pe[1]),Math.max(ee[2],pe[2]),Math.max(ee[3],pe[3])]:pe}let oe=Math.max(0,zb(re)),_e=Fl(ee,oe,s());return{path:W,ms:Math.min(jV,Math.max(WV,VV*W.S)),apex:_e?{z:oe,range:_e}:null}}function Mn(P){return!P||[...O.values()].every(k=>!k.visible||k.grid.settledIn(P.z,P.range))}function hi(){if(!d||T)return;if(d.start===null){if(!Mn(d.flight.apex)&&c()-d.created=1){let re=d.to;y=d.flight?d.flight.apex:null,d=null,$t(re.target,re.zoom),fi();return}$t(W,$),a(hi)}function Ke(){return d?{...u,target:d.to.target,zoom:d.to.zoom}:u}function Vt(){if(O.size===0)return;let P=r.doubleBuffer(),k=bs(zb(u.zoom,{targetZoom:d?d.to.zoom:null,hidingNewLevels:P}),{minZoom:0,maxZoom:K3}),$=Ke(),W=Fl(jo($),k,s()),re=Ah(W),ee=le.shownZ,oe=r.defer()&&h;oe||le.setZoom(k,{hasContent:[...O.values()].some(pe=>pe.visible&&ee!==null&&pe.grid.hasContentAt(ee))});let _e=[];k>0&&!d&&!h&&!x&&le.pendingZ===null&&(v=k-1,_e.push({z:v,range:Fl(Ub(jo($),UV),v,s())}));let de=un();de&&_e.push({...de,background:!1});let Y=d?Fl(jo(u),k,s()):null;for(let pe of O.values())pe.visible&&!oe&&pe.grid.update({z:k,range:W,ring:re,extra:_e,hold:Y});yr()}function un(){return d&&d.flight&&d.flight.apex||y}function An(P){let k=[];for(let $ of[un()?.z,le.pendingZ])$!=null&&!k.includes($)&&!P.some(W=>W.z===$)&&k.push($);return k}function Rs(){b||(b=!0,queueMicrotask(()=>{b=!1,T||Vt()}))}function pi(){for(let P of O.values())if(P.visible&&!P.grid.isSettled())return!1;return!0}function yr(P){let k=le.check({settled:pi(),animating:!!d});k&&le.pendingZ===null&&Rs();let $=!1;y&&!d&&le.isIdle()&&pi()&&(y=null,$=!0),(k||$||!P||kn(P.z))&&se()}function kn(P){let k=le.plan(c()).draw;return k.some($=>$.z===P)||An(k).includes(P)}function Wt(P,{order:k,source:$,visible:W=!0}){let re={load:(oe,_e)=>$.load(oe,_e),release:oe=>{let _e=oe&&q.get(oe);_e&&(q.delete(oe),X.push(_e)),$.release?.(oe)}},ee={id:P,order:k,visible:W,grid:new kh({source:re,onChange:oe=>yr(oe)})};return O.set(P,ee),Vt(),{id:P,setVisible(oe){ee.visible!==!!oe&&(ee.visible=!!oe,ee.visible||ee.grid.clear(),Vt())},isVisible:()=>ee.visible,refresh(){ee.visible&&(ee.grid.refresh(),se())},remove(){ee.grid.clear(),O.delete(P),se()}}}function Re(P){if(!he||!he.device)return P.image;let k=q.get(P);if(!k){try{k=he.device.createTexture({data:P.image,width:P.width,height:P.height,mipLevels:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}})}catch{return P.image}q.set(P,k)}return k}function na(P){if(P>=E)return 1;let k=(X3-(E-P))%400/400;return 1-.7*(.5-.5*Math.cos(2*Math.PI*k))}let Ce=new WeakMap,M=null;function S(P){let k=s();k!==M&&(Ce=new WeakMap,M=k);let $=Ce.get(P);return $||($=o3(P.z,P.x,P.y,k),Ce.set(P,$)),$}function L(P,k,$,W,re,ee){for(let oe of k.grid.drawableTilesAt($)){let _e=S(oe);$b(_e,W)&&P.push({order:k.order,props:{id:`${k.id}:${re}${oe.key}`,image:Re(oe.drawable),bounds:_e,opacity:ee,parameters:Es}})}}function D(P,k){let $=[],W=le.plan(P);if(!W.fading&&le.pendingZ===null&&W.draw.length>0){let de=[...W.draw.map(Y=>Y.z),v,un()?.z].filter(Y=>Y!=null);for(let Y of O.values())Y.grid.prune(de)}let re=na(P),ee=[...O.values()].sort((de,Y)=>de.order-Y.order),oe=ee.find(de=>de.visible),_e=An(W.draw);for(let de of ee)if(de.visible){de===oe&&_e.length>0&&$.push(...A(de,_e,W.draw,k,re));for(let Y of W.draw)L($,de,Y.z,k,"",Y.opacity*re)}return{layers:$,animate:W.fading||Ppe.z===de.z)||de.loading&&!de.drawable)continue;let Y=S(de);if($b(Y,W)){let[pe,Rn,lp,ia]=Y;_e.push([[pe-oe,Rn-oe],[lp+oe,Rn-oe],[lp+oe,ia+oe],[pe-oe,ia+oe]])}}return _e.length&&ee.push({order:P.order,kind:"SolidPolygonLayer",props:{id:`${P.id}:mask`,data:_e,getPolygon:de=>de,getFillColor:z(),parameters:Es}}),ee}function z(){let P=(getComputedStyle(n).backgroundColor||"").match(/[\d.]+/g);return!P||P.length<3||P.length>3&&Number(P[3])===0?[0,0,0,255]:[Number(P[0]),Number(P[1]),Number(P[2]),255]}function I(P,k,$){let W=[],re=[],ee=[],oe=[];for(let Y of k){if(Y.kind==="circle"){oe.push(Y);continue}let pe=Y.kind==="rect"?[[Y.rect[0],Y.rect[1]],[Y.rect[2],Y.rect[1]],[Y.rect[2],Y.rect[3]],[Y.rect[0],Y.rect[3]]]:Y.points;if(Y.fill&&re.push({polygon:pe,color:Y.fill}),Y.stroke){let Rn=Y.kind==="rect"||Y.closed;ee.push({path:Rn?[...pe,pe[0]]:pe,color:Y.stroke,width:Y.width||1,dash:Y.dash||null})}}re.length&&W.push({order:$,kind:"SolidPolygonLayer",props:{id:`${P}:fill`,data:re,getPolygon:Y=>Y.polygon,getFillColor:Y=>Y.color,parameters:Es}});let _e=ee.filter(Y=>!Y.dash),de=ee.filter(Y=>Y.dash);if(_e.length&&W.push({order:$,kind:"PathLayer",props:{id:`${P}:stroke`,data:_e,widthUnits:"pixels",getPath:Y=>Y.path,getColor:Y=>Y.color,getWidth:Y=>Y.width,parameters:Es}}),de.length){let Y={id:`${P}:dash`,data:de,widthUnits:"pixels",getPath:pe=>pe.path,getColor:pe=>pe.color,getWidth:pe=>pe.width,getDashArray:pe=>pe.dash.map(Rn=>Rn/pe.width),dashJustified:!0,parameters:Es};t?.PathStyleExtension&&(Y.extensions=[new t.PathStyleExtension({dash:!0})]),W.push({order:$,kind:"PathLayer",props:Y})}return oe.length&&W.push({order:$,kind:"ScatterplotLayer",props:{id:`${P}:circle`,data:oe,radiusUnits:"pixels",lineWidthUnits:"pixels",getPosition:Y=>Y.center,getRadius:Y=>Y.radius,stroked:!0,filled:!0,getLineColor:Y=>Y.stroke||[0,0,0,0],getFillColor:Y=>Y.fill||[0,0,0,0],getLineWidth:Y=>Y.width||1,parameters:Es}}),W}function B(){let P=[];for(let k of j.values())P.push(...k);return P.push(...V.values()),P}function U(P){return P.map(k=>new t[k.kind||"BitmapLayer"](k.props))}let Z=0;function Q(){if(T)return;let P=c(),k=D(P,Ub(jo(u),.5)),$=[...k.layers,...B()].sort((W,re)=>W.order-re.order);Z=$.length,he&&he.setProps({layers:U($)});for(let W of X.splice(0))W.destroy?.();Oe(),k.animate&&se(),l.emit("render")}function ye(P=32,k=20){let $=O.get("base");if(!$)return null;let W=s(),re=le.plan(c()).draw,ee=[...re,...An(re).map(de=>({z:de}))],oe=0,_e=0;for(let de=0;de=W||Rn>=W)continue;oe++,ee.some(({z:ia})=>{let _v=W/2**ia,up=$.grid.tiles.get(Ho(ia,Math.floor(pe/_v),Math.floor((W-Rn)/_v)));return up&&(up.drawable||!up.loading)})&&_e++}return oe?_e/oe:null}function be(P){return G.has(P)||G.set(P,{visible:!0,items:new Map}),G.get(P)}function je(P,k){let[$,W]=Lh(P.world,u);P.el.style.display=k?"":"none",P.el.style.transform=`translate(${$}px, ${W}px)`+(P.center?" translate(-50%, -50%)":"")}function Be(P){for(let k of P.items.values())je(k,P.visible)}function Oe(){for(let P of G.values())Be(P)}function yt(){return{width:u.width,height:u.height}}let K={DRAW_ORDER:ot,getContainer:()=>n,getRendererInfo:()=>m,getSize:yt,getZoom:()=>u.zoom,getTargetZoom:()=>d?d.to.zoom:u.zoom,getCenter:()=>[...u.target],getViewState:()=>({...u,target:[...u.target]}),isAnimating:()=>!!d,isMoving:()=>x,project:P=>Lh(P,u),unproject:P=>Wo(P,u),on:l.on,off:l.off,setLimits({minZoom:P,maxZoom:k}={}){P!==void 0&&(f.minZoom=P),k!==void 0&&(f.maxZoom=k);let $=bs(u.zoom,f);$!==u.zoom?$t(u.target,$):he&&he.setProps({viewState:Ct()}),l.emit("limits")},getLimits:()=>({...f}),setView(P,k=u.zoom,{animate:$}={}){let W={target:[P[0],P[1]],zoom:k};Gt(W,$===!1?{ms:0}:{curve:!0})},fitWorldRect(P,{padding:k=[0,0],animate:$}={}){let W=s3(P,u,{padding:k,...f});Gt(W,$===!1?{ms:0}:{curve:!0})},zoomAround(P,k,{animate:$,settle:W=!0}={}){let re=bs(K.getTargetZoom()+k,f),ee=Ke(),oe=P||[u.width/2,u.height/2],_e=Mh(ee,oe,re);Gt({target:_e,zoom:re},$===!1?{ms:0,settle:W}:{anchor:P?oe:null})},zoomIn:()=>K.zoomAround(null,1),zoomOut:()=>K.zoomAround(null,-1),panByPx(P,k,{animate:$}={}){let W=Ke(),re=Math.pow(2,W.zoom),ee=[W.target[0]+P/re,W.target[1]-k/re],oe=$===!1||!r.smooth()?0:Y3;Gt({target:ee,zoom:W.zoom},{ms:oe})},invalidateSize:cn,applyPrefs(){Vt()},addTileSlot:Wt,setOverlay(P,k,{order:$=ot.selection}={}){!k||k.length===0?j.delete(P):j.set(P,I(P,k,$)),se()},hasOverlay:P=>j.has(P),setImageOverlay(P,k,{order:$=ot.pathImage}={}){k?V.set(P,{order:$,kind:"BitmapLayer",props:{id:`image:${P}`,image:k.image,bounds:k.rect,parameters:Es}}):V.delete(P),se()},addMarker(P,k,$,W,{center:re=!1}={}){let ee=be(P),oe=ee.items.get(k);oe&&oe.el.remove(),W.classList.add("or-view-marker"),F.appendChild(W);let _e={el:W,world:[$[0],$[1]],center:re};return ee.items.set(k,_e),je(_e,ee.visible),W},moveMarker(P,k,$){let W=be(P),re=W.items.get(k);re&&(re.world=[$[0],$[1]],je(re,W.visible))},clearMarkers(P){let k=be(P);for(let $ of k.items.values())$.el.remove();k.items.clear()},setMarkerGroupVisible(P,k){let $=be(P);$.visible=!!k,Be($)},setCursorMode(P,k=!0){k?w.add(P):w.delete(P),n.classList.toggle(`${P}-mode-cursor`,!!k);let $=he&&he.getCanvas&&he.getCanvas();$&&($.style.cursor=w.size?"crosshair":"default")},flashTiles(){E=c()+X3,se()},whenTilesSettled({timeoutMs:P=6e3}={}){let k=c()+P;return new Promise($=>{let W=()=>{if(pi()&&le.isIdle()&&!d&&!x||c()>=k){$();return}setTimeout(W,32)};W()})},captureCanvas({timeoutMs:P=500}={}){return he?.getCanvas()?(Q(),new Promise(k=>{let $=null,W=()=>{clearTimeout($),p=p.filter(ee=>ee!==W);let re=he?.getCanvas();k(re?{image:i(re),rect:re.getBoundingClientRect()}:null)};p.push(W),$=setTimeout(()=>{he?.redraw("capture"),W()},P)})):Promise.resolve(null)},redraw:()=>se(),debugSnapshot(){let P=le.plan();return{zoom:u.zoom,target:[...u.target],width:u.width,height:u.height,animating:!!d,moving:x,interacting:h,shownZ:le.shownZ,pendingZ:le.pendingZ,fading:P.fading,drawLevels:P.draw,layers:Z,coverage:ye(),overlays:[...j.keys()],markers:Object.fromEntries([...G].map(([k,$])=>[k,$.items.size])),slots:[...O.values()].map(k=>({id:k.id,visible:k.visible,settled:k.grid.isSettled(),...k.grid.stats()}))}},destroy(){T=!0,li?.disconnect(),le.dispose();for(let P of O.values())P.grid.clear();he?.finalize?.()}};return K}var KV=4.000244140625;function QV(n){return n.deltaMode!==0?!0:n.deltaX!==0||n.deltaY===0?!1:Number.isInteger(n.deltaY)&&Math.abs(n.deltaY)>=50||n.deltaY%KV===0}function JV(n){let e=Math.abs(n);return e<.2?0:Math.sign(n)*Math.max(1,Math.round(e))}function eW(n,e){let i=1;return n.deltaMode===1?i=16:n.deltaMode===2&&(i=e.clientHeight||16),[n.deltaX*i,n.deltaY*i]}function tW(n,e,t){let i=t?3*e:e;switch(n){case"ArrowLeft":return[-i,0];case"ArrowRight":return[i,0];case"ArrowUp":return[0,-i];case"ArrowDown":return[0,i];default:return null}}function eM(n,e={}){let t=n.getContainer(),i=e.isStatic||(()=>!1),r=e.wheelZoom||(()=>!0),s=e.arrowStep||(()=>80),o=e.gestureIdleMs??200,a=e.contextEnabled||(()=>!0),c=[],l=(w,T,R,F)=>{w.addEventListener(T,R,F),c.push(()=>w.removeEventListener(T,R,F))},u=w=>{let T=t.getBoundingClientRect();return[w.clientX-T.left,w.clientY-T.top]},f=w=>n.unproject(u(w)),d=w=>w.target===t||!!w.target?.closest?.(".or-view-canvas");t.tabIndex<0&&(t.tabIndex=0);let h=null;function p(w,T){h||(h={z0:n.getZoom()}),h.pt=w,clearTimeout(h.timer),h.timer=setTimeout(m,o),n.zoomAround(w,T,{animate:!1,settle:!1})}function m(){if(!h)return;let w=h;h=null,clearTimeout(w.timer);let T=n.getZoom();n.zoomAround(w.pt,w.z0+JV(T-w.z0)-T)}c.push(()=>{clearTimeout(h?.timer),h=null}),l(t,"wheel",w=>{if(w.preventDefault(),i())return;let T=QV(w);if(!T&&w.ctrlKey){p(u(w),-w.deltaY/(100*Math.LN2));return}if(r()===w.ctrlKey){let[R,F]=eW(w,t);n.panByPx(R,F,{animate:!1});return}if(!T){p(u(w),-w.deltaY/100);return}m(),n.zoomAround(u(w),w.deltaY<0?1:-1)},{passive:!1}),l(t,"keydown",w=>{if(w.altKey||w.ctrlKey||w.metaKey)return;let T=tW(w.key,s(),w.shiftKey);if(T){w.preventDefault(),n.panByPx(T[0],T[1]);return}if(i())return;let R={"+":1,"=":1,"-":-1,_:-1};w.key in R&&(w.preventDefault(),n.zoomAround(null,R[w.key]*(w.shiftKey?3:1)))});let g=null,v=null;l(t,"pointerdown",w=>{w.button!==0||!d(w)||(t.focus({preventScroll:!0}),g={x:w.clientX,y:w.clientY,moved:!1,box:w.shiftKey&&!i()},g.box&&w.stopPropagation())},{capture:!0}),l(window,"pointermove",w=>{if(!g)return;let T=w.clientX-g.x,R=w.clientY-g.y;(Math.abs(T)>3||Math.abs(R)>3)&&(g.moved=!0),g.box&&g.moved&&(v=J3(v,g,w))}),l(window,"pointerup",w=>{if(!g||w.button!==0)return;let T=g;if(g=null,v&&(v.remove(),v=null),T.box&&T.moved){E(T,w);return}!T.moved&&e.onClick&&x(w)&&e.onClick(f(w),w)}),l(t,"dblclick",w=>{i()||!d(w)||n.zoomAround(u(w),w.shiftKey?-1:1)});let y=null,b=null;l(t,"contextmenu",w=>w.preventDefault()),l(t,"pointerdown",w=>{w.button!==2||i()||!d(w)||(w.stopPropagation(),y={x:w.clientX,y:w.clientY})},{capture:!0}),l(window,"pointermove",w=>{if(!y)return;let T=w.clientX-y.x,R=w.clientY-y.y;(b||Math.abs(T)>=4&&Math.abs(R)>=4)&&(b=J3(b,y,w))}),l(window,"pointerup",w=>{if(!y||w.button!==2)return;let T=y;if(y=null,b){b.remove(),b=null,E(T,w);return}x(w)&&a()&&e.onContextClick&&e.onContextClick(f(w),w)}),l(t,"pointermove",w=>{e.onMove&&e.onMove(f(w),w)}),l(t,"pointerleave",w=>{e.onLeave&&e.onLeave(w)});function x(w){let T=t.getBoundingClientRect();return w.clientX>=T.left&&w.clientX<=T.right&&w.clientY>=T.top&&w.clientY<=T.bottom}function E(w,T){let R=t.getBoundingClientRect(),F=n.unproject([w.x-R.left,w.y-R.top]),O=n.unproject([T.clientX-R.left,T.clientY-R.top]);n.fitWorldRect([Math.min(F[0],O[0]),Math.min(F[1],O[1]),Math.max(F[0],O[0]),Math.max(F[1],O[1])])}return{dispose(){for(let w of c.splice(0))w()}}}function J3(n,e,t){return n||(n=document.createElement("div"),n.className="rubber-band",document.body.appendChild(n)),n.style.left=Math.min(e.x,t.clientX)+"px",n.style.top=Math.min(e.y,t.clientY)+"px",n.style.width=Math.abs(t.clientX-e.x)+"px",n.style.height=Math.abs(t.clientY-e.y)+"px",n}var Ps=class n{constructor(e,t,i){this._app=e,this._redrawAllLayers=t,this._refreshOverlay=i||t,this._currentTab="setup",this._setupPaths=[],this._holdPaths=[],this._selectedPathIndex=-1,this._detailTab="data",this._selectedDetailIndex=-1,this._sortCol="slack",this._sortAscending=!0,this._build()}_build(){let e=document.createElement("div");e.className="timing-widget";let t=document.createElement("div");t.className="timing-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",fe(this._app)&&(this._updateBtn.style.display="none"),this._pathCountLabel=document.createElement("span"),this._pathCountLabel.className="timing-path-count",t.appendChild(this._updateBtn),t.appendChild(this._pathCountLabel),e.appendChild(t),e.appendChild(this._buildConePanel());let i=document.createElement("div");i.className="timing-tab-bar",this._setupTab=this._makeTab("Setup",!0),this._holdTab=this._makeTab("Hold",!1),i.appendChild(this._setupTab),i.appendChild(this._holdTab),e.appendChild(i),this._pathTableContainer=document.createElement("div"),this._pathTableContainer.className="timing-path-table-container",this._pathTable=document.createElement("table"),this._pathTable.className="timing-table",this._pathTableContainer.appendChild(this._pathTable),e.appendChild(this._pathTableContainer);let r=document.createElement("div");r.className="timing-tab-bar",this._dataTab=this._makeTab("Data Path",!0),this._captureTab=this._makeTab("Capture Path",!1),r.appendChild(this._dataTab),r.appendChild(this._captureTab),e.appendChild(r),this._detailTableContainer=document.createElement("div"),this._detailTableContainer.className="timing-detail-table-container",this._detailTable=document.createElement("table"),this._detailTable.className="timing-table",this._detailTableContainer.appendChild(this._detailTable),e.appendChild(this._detailTableContainer),this._headerTooltip=document.createElement("div"),this._headerTooltip.className="or-tooltip or-tooltip-fixed",e.appendChild(this._headerTooltip),this.element=e,this._bindEvents(),fe(this._app)&&setTimeout(()=>this.update(),0)}_makeTab(e,t){let i=document.createElement("button");return i.className="timing-tab"+(t?" active":""),i.textContent=e,i}_bindEvents(){this._setupTab.addEventListener("click",()=>{this._currentTab="setup",this._setupTab.classList.add("active"),this._holdTab.classList.remove("active"),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}),this._holdTab.addEventListener("click",()=>{this._currentTab="hold",this._holdTab.classList.add("active"),this._setupTab.classList.remove("active"),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}),this._dataTab.addEventListener("click",()=>{this._detailTab="data",this._dataTab.classList.add("active"),this._captureTab.classList.remove("active"),this._renderDetailTable()}),this._captureTab.addEventListener("click",()=>{this._detailTab="capture",this._captureTab.classList.add("active"),this._dataTab.classList.remove("active"),this._renderDetailTable()}),this._updateBtn.addEventListener("click",()=>this.update()),this._pathTableContainer.setAttribute("tabindex","0"),this._pathTableContainer.style.outline="none",this._pathTableContainer.addEventListener("keydown",e=>{if(e.key==="ArrowDown"){e.preventDefault();let t=this._pathTable.querySelectorAll("tbody tr");this._selectedPathIndex0&&this._selectPathRow(this._selectedPathIndex-1))}),this._detailTableContainer.setAttribute("tabindex","0"),this._detailTableContainer.style.outline="none",this._detailTableContainer.addEventListener("keydown",e=>{if(e.key==="ArrowDown"){e.preventDefault();let t=this._detailTable.querySelectorAll("tbody tr");this._selectedDetailIndex0&&this._selectDetailRow(this._selectedDetailIndex-1))})}_buildConePanel(){let e=document.createElement("div");e.className="timing-cone-panel";let t=document.createElement("span");t.className="timing-cone-title",t.textContent="Timing cone:",e.appendChild(t);let i=(u,f,d=!1)=>{let h=document.createElement("input");h.type="checkbox",h.id=u,h.checked=d;let p=document.createElement("label");return p.htmlFor=u,p.textContent=f,{input:h,lbl:p}},r=i("cone-fanin","Fanin",!0),s=i("cone-fanout","Fanout",!0);this._coneFanin=r.input,this._coneFanout=s.input,e.append(r.input,r.lbl,s.input,s.lbl);let o=u=>{let f=document.createElement("label");f.className="timing-cone-depth-label",f.textContent=u;let d=document.createElement("input");return d.type="number",d.min="0",d.value="0",d.className="timing-cone-depth",d.title="0 = unlimited",f.appendChild(d),{lbl:f,input:d}},a=o("in\u2264"),c=o("out\u2264");this._coneFaninDepth=a.input,this._coneFanoutDepth=c.input,e.append(a.lbl,c.lbl),this._coneColorMode=document.createElement("select"),this._coneColorMode.className="timing-cone-colormode";for(let[u,f]of[["slack","by slack"],["depth","by depth"]]){let d=document.createElement("option");d.value=u,d.textContent=f,this._coneColorMode.appendChild(d)}e.appendChild(this._coneColorMode);let l=i("cone-sync-schematic","Sync schematic");return this._coneSyncSchematic=l.input,e.append(l.input,l.lbl),this._coneApplyBtn=document.createElement("button"),this._coneApplyBtn.className="or-btn",this._coneApplyBtn.textContent="Cone",this._coneApplyBtn.title="Show the timing cone for the selected instance",this._coneClearBtn=document.createElement("button"),this._coneClearBtn.className="or-btn",this._coneClearBtn.textContent="Clear",e.append(this._coneApplyBtn,this._coneClearBtn),this._coneStatus=document.createElement("span"),this._coneStatus.className="timing-cone-status",e.appendChild(this._coneStatus),this._coneApplyBtn.addEventListener("click",()=>this._applyCone()),this._coneClearBtn.addEventListener("click",()=>this._clearCone()),e}_coneTarget(){return this._app.selectedInstanceName||""}async _applyCone(){let e=this._coneFanin.checked,t=this._coneFanout.checked;if(!e&&!t){this._coneStatus.textContent="select fanin and/or fanout";return}let i=this._coneTarget();if(!i){this._coneStatus.textContent="select an instance first";return}let r={type:"timing_cone",fanin:e,fanout:t,fanin_depth:Math.max(0,parseInt(this._coneFaninDepth.value,10)||0),fanout_depth:Math.max(0,parseInt(this._coneFanoutDepth.value,10)||0),color_mode:this._coneColorMode.value,inst_name:i};this._coneApplyBtn.disabled=!0,this._coneStatus.textContent="computing\u2026";try{let s=await this._app.websocketManager.request(r);this._refreshOverlay(),this._renderConeStatus(s),this._coneSyncSchematic.checked&&i&&document.dispatchEvent(new CustomEvent("openroad-cone-sync",{detail:{inst_name:i,fanin:r.fanin,fanout:r.fanout,fanin_depth:r.fanin_depth,fanout_depth:r.fanout_depth}}))}catch(s){this._coneStatus.textContent="cone error: "+(s.message||s)}this._coneApplyBtn.disabled=!1}_renderConeStatus(e){if(!e){this._coneStatus.textContent="";return}let t=e.node_count||0;if(t===0){this._coneStatus.textContent="empty cone";return}let i=t+" pins";if(e.color_mode==="depth")i+=`, depth \xB1${e.max_depth}`;else if(e.constrained){let r=e.time_unit||"";i+=`, slack ${Ss(e.min_slack)}\u2026${Ss(e.max_slack)}${r}`}else i+=", unconstrained";this._coneStatus.textContent=i}_clearCone(){this._app.websocketManager.request({type:"timing_cone",clear:!0}).then(()=>this._refreshOverlay()),this._coneStatus.textContent=""}showPaths(e,t){this._currentTab=e,e==="setup"?(this._setupPaths=[...t],this._setupTab.classList.add("active"),this._holdTab.classList.remove("active")):(this._holdPaths=[...t],this._holdTab.classList.add("active"),this._setupTab.classList.remove("active")),this._applySort(),this._selectedPathIndex=-1,this._pathCountLabel.textContent=t.length+" paths",this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...";try{let[e,t]=await Promise.all([this._app.websocketManager.request({type:"timing_report",is_setup:!0,max_paths:100}),this._app.websocketManager.request({type:"timing_report",is_setup:!1,max_paths:100})]);this._setupPaths=[...e.paths||[]],this._holdPaths=[...t.paths||[]],this._applySort(),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}catch(e){console.error("Timing fetch failed:",e)}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}_applySort(){for(let e of[this._setupPaths,this._holdPaths]){e.forEach((r,s)=>{r._originalIndex===void 0&&(r._originalIndex=s)});let t=this._sortAscending?1:-1,i=this._sortCol;e.sort((r,s)=>{let o=r[i],a=s[i],c=typeof o=="number"&&typeof a=="number"?o-a:String(o).localeCompare(String(a));return t*c})}}_showHeaderTooltip(e,t){if(e.buttons!==0){this._hideHeaderTooltip();return}let i=this._headerTooltip;i.textContent=t,i.style.display="block";let r=Math.min(e.clientX+12,window.innerWidth-i.offsetWidth-8);i.style.left=Math.max(0,r)+"px",i.style.top=e.clientY+14+"px"}_hideHeaderTooltip(){this._headerTooltip.style.display="none"}_sortBy(e){this._sortCol===e?this._sortAscending=!this._sortAscending:(this._sortCol=e,this._sortAscending=!0),this._applySort(),this._selectedPathIndex=-1,this._renderPathTable(),this._renderDetailTable(),this._clearTimingHighlight()}_clearTimingHighlight(){this._app.websocketManager.request({type:"timing_highlight",path_index:-1}).then(()=>this._refreshOverlay())}_selectPathRow(e){let t=this._pathTable.querySelectorAll("tbody tr");if(e<0||e>=t.length)return;this._selectedPathIndex=e;for(let s of t)s.classList.remove("selected");t[e].classList.add("selected"),t[e].scrollIntoView({block:"nearest"}),this._pathTableContainer.focus(),this._renderDetailTable();let r=(this._currentTab==="setup"?this._setupPaths:this._holdPaths)[e]?._originalIndex??e;this._app.websocketManager.request({type:"timing_highlight",path_index:r,is_setup:this._currentTab==="setup"}).then(()=>this._refreshOverlay()).catch(s=>console.error("timing_highlight error:",s))}_renderPathTable(){this._hideHeaderTooltip();let e=this._currentTab==="setup"?this._setupPaths:this._holdPaths;this._pathCountLabel.textContent=e.length+" paths";let t=this._pathTable.querySelectorAll("thead th"),i=Array.from(t,c=>c.style.width);this._pathTable.innerHTML="";let r=document.createElement("thead"),s=document.createElement("tr");for(let c of n.PATH_COLS){let l=document.createElement("th");l.classList.add("sortable"),c.num&&l.classList.add("num"),l.textContent=c.label+(c.key===this._sortCol?this._sortAscending?" \u25B2":" \u25BC":""),c.tooltip&&(l.addEventListener("mousemove",u=>this._showHeaderTooltip(u,c.tooltip)),l.addEventListener("mouseleave",()=>this._hideHeaderTooltip())),l.addEventListener("click",()=>this._sortBy(c.key)),s.appendChild(l)}r.appendChild(s),this._pathTable.appendChild(r);let o=document.createElement("tbody"),a=e.reduce((c,l)=>Math.max(c,Math.abs(Number(l.slack)||0)),0);if(e.forEach((c,l)=>{let u=document.createElement("tr");l===this._selectedPathIndex&&u.classList.add("selected");for(let f of n.PATH_COLS){let d=document.createElement("td"),h=c[f.key];if(d.textContent=f.time?Ss(h):h,f.num&&d.classList.add("num"),f.key==="slack"){let p=Number(c.slack);p<0&&d.classList.add("slack-negative"),Number.isFinite(p)&&a>0&&(d.classList.add("slack-cell",p<0?"slack-under":"slack-over"),d.style.setProperty("--slack-frac",String(Math.abs(p)/a)))}u.appendChild(d)}u.style.cursor="pointer",u.addEventListener("click",()=>this._selectPathRow(l)),o.appendChild(u)}),e.length===0){let c=document.createElement("tr"),l=document.createElement("td");l.colSpan=n.PATH_COLS.length,l.style.textAlign="center",l.style.color="var(--fg-secondary)",l.textContent=fe(this._app)?"No timing data available":'Click "Update" to load timing paths',c.appendChild(l),o.appendChild(c)}this._pathTable.appendChild(o),ws(this._pathTable,i)}_selectDetailRow(e){let t=this._detailTable.querySelectorAll("tbody tr");if(e<0||e>=t.length)return;this._selectedDetailIndex=e;for(let a of t)a.classList.remove("timing-selected-row");t[e].classList.add("timing-selected-row"),t[e].scrollIntoView({block:"nearest"}),this._detailTableContainer.focus();let r=(this._currentTab==="setup"?this._setupPaths:this._holdPaths)[this._selectedPathIndex],s=this._detailTab==="data"?r.data_nodes:r.capture_nodes,o=r._originalIndex??this._selectedPathIndex;this._app.websocketManager.request({type:"timing_highlight",path_index:o,is_setup:this._currentTab==="setup",pin_name:s[e].pin}).then(()=>this._refreshOverlay())}_renderDetailTable(){let e=this._detailTable.querySelectorAll("thead th"),t=Array.from(e,l=>l.style.width);this._detailTable.innerHTML="",this._selectedDetailIndex=-1;let i=this._currentTab==="setup"?this._setupPaths:this._holdPaths;if(this._selectedPathIndex<0||this._selectedPathIndex>=i.length)return;let r=i[this._selectedPathIndex],s=this._detailTab==="data"?r.data_nodes:r.capture_nodes,o=document.createElement("thead"),a=document.createElement("tr");for(let l of n.DETAIL_COLS){let u=document.createElement("th");n.DETAIL_NUM_COLS.has(l)&&u.classList.add("num"),u.textContent=l,a.appendChild(u)}o.appendChild(a),this._detailTable.appendChild(o);let c=document.createElement("tbody");if(s.forEach((l,u)=>{let f=document.createElement("tr");l.clk&&f.classList.add("timing-clock-row"),[l.pin,l.fanout,l.rise?"\u2191":"\u2193",Ss(l.time),Ss(l.delay),Ss(l.slew),Ss(l.load)].forEach((h,p)=>{let m=document.createElement("td");n.DETAIL_NUM_COLS.has(n.DETAIL_COLS[p])&&m.classList.add("num"),m.textContent=h,f.appendChild(m)}),f.style.cursor="pointer",f.addEventListener("click",()=>this._selectDetailRow(u)),c.appendChild(f)}),this._detailTable.appendChild(c),ws(this._detailTable,t),!t[0]){let l=this._detailTable.querySelector("thead th");l&&(l.style.width="30ch")}}};function Ss(n){return n==null?"":typeof n=="number"?n.toFixed(4):String(n)}Ps.PATH_COLS=[{label:"Clock",key:"end_clk"},{label:"Required",key:"required",time:!0,num:!0},{label:"Arrival",key:"arrival",time:!0,num:!0},{label:"Slack",key:"slack",time:!0,num:!0},{label:"Skew",key:"skew",time:!0,num:!0,tooltip:`The difference in arrival times between source and destination clock pins of a macro/register, adjusted for CRPR and subtracting a clock period. -Setup and hold times account for internal clock delays.`},{label:"Logic Delay",key:"path_delay",time:!0,num:!0,tooltip:"Path delay from instances (excluding buffers and consecutive inverter pairs)"},{label:"Logic Depth",key:"logic_depth",num:!0,tooltip:"Path instances (excluding buffers and consecutive inverter pairs)"},{label:"Fanout",key:"fanout",num:!0},{label:"Start",key:"start_pin"},{label:"End",key:"end_pin"}];Ps.DETAIL_COLS=["Pin","Fanout","R/F","Time","Delay","Slew","Load"];Ps.DETAIL_NUM_COLS=new Set(["Fanout","Time","Delay","Slew","Load"]);function We(n){let e=document.cookie.match("(?:^|; )"+n+"=([^;]*)");return e?e[1]:null}function $e(n,e){document.cookie=n+"="+e+"; path=/; max-age=31536000; SameSite=Lax"}function Dh(n){document.cookie=n+"=; path=/; max-age=0; SameSite=Lax"}function Nh(n){$e("or_theme",n);try{window.localStorage.setItem("or_theme",n)}catch{}}function J3(){Dh("or_theme");try{window.localStorage.removeItem("or_theme")}catch{}}function ev(n){let e=document.getElementById("gl-theme-dark"),t=document.getElementById("gl-theme-light");!e||!t||(e.disabled=n!=="dark",t.disabled=n!=="light")}function eM(n,e){Zo(n)&&(document.documentElement.style.setProperty("--bg-map",n),$e("or_bg_color",n),nM(e),e.syncDisplayState())}function tM(n){document.documentElement.style.removeProperty("--bg-map"),Dh("or_bg_color"),nM(n),n.syncDisplayState()}function tv(){return G3(getComputedStyle(document.documentElement).getPropertyValue("--bg-map"))??"#000000"}function nM(n){n.threeDViewerWidget?.render?.()}if(typeof document<"u"){let n=We("or_theme")||typeof localStorage<"u"&&localStorage.getItem("or_theme")||(matchMedia("(prefers-color-scheme: light)").matches?"light":"dark");document.documentElement.dataset.theme=n,ev(n);let e=We("or_bg_color");Zo(e)&&document.documentElement.style.setProperty("--bg-map",e)}function Cs(){let n=getComputedStyle(document.documentElement),e=t=>n.getPropertyValue(t).trim();return{canvasBg:e("--canvas-bg"),canvasText:e("--canvas-text"),canvasAxis:e("--canvas-axis"),canvasLabel:e("--canvas-label"),canvasGrid:e("--canvas-grid"),canvasTitle:e("--canvas-title"),fgPrimary:e("--fg-primary"),fgMuted:e("--fg-muted"),bgPanel:e("--bg-panel"),bgMap:e("--bg-map"),fontMono:e("--font-mono"),fontSans:e("--font-sans")}}function Ts(n,e){let t=document.createElement("a");t.href=n,t.download=e,document.body.appendChild(t),t.click(),t.remove()}function iM(n,e){let t=URL.createObjectURL(n);Ts(t,e),setTimeout(()=>URL.revokeObjectURL(t),1e3)}function nv(n){let e=n.cloneNode(!0);if(e.getAttribute("xmlns")||e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.getAttribute("xmlns:xlink")||e.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),!e.getAttribute("width")||!e.getAttribute("height")){let t=n.viewBox&&n.viewBox.baseVal;t&&t.width&&t.height&&(e.setAttribute("width",t.width),e.setAttribute("height",t.height))}return` -`+new XMLSerializer().serializeToString(e)}function QV(n){let e=n.viewBox&&n.viewBox.baseVal;if(e&&e.width&&e.height)return{width:e.width,height:e.height};let t=parseFloat(n.getAttribute("width")),i=parseFloat(n.getAttribute("height"));if(t&&i)return{width:t,height:i};let r=n.getBoundingClientRect();return{width:r.width||800,height:r.height||600}}function iv(n,e=2){let{width:t,height:i}=QV(n),r=nv(n),s=new Blob([r],{type:"image/svg+xml;charset=utf-8"}),o=URL.createObjectURL(s);return new Promise((a,c)=>{let l=new Image;l.onload=()=>{let u=document.createElement("canvas");u.width=Math.max(1,Math.round(t*e)),u.height=Math.max(1,Math.round(i*e));let f=u.getContext("2d");f.fillStyle="#ffffff",f.fillRect(0,0,u.width,u.height),f.drawImage(l,0,0,u.width,u.height),URL.revokeObjectURL(o),a(u.toDataURL("image/png"))},l.onerror=u=>{URL.revokeObjectURL(o),c(u)},l.src=o})}async function Fh(n){try{if(!navigator.clipboard||!window.ClipboardItem)return!1;let e=await(await fetch(n)).blob();return await navigator.clipboard.write([new ClipboardItem({"image/png":e})]),!0}catch{return!1}}function JV(n){return(String(n||"").replace(/[^A-Za-z0-9._-]/g,"_").replace(/^_+|_+$/g,"")||"clock_tree")+".png"}var rv=24,sv=10,Uh=40,eW=40,ov=70,tW=20,zh={root:"#ff4444",buffer:"#4488ff",inverter:"#00b0b0",clock_gate:"#cc44cc",register:"#ff4444",macro:"#00b0b0",unknown:"#888888"};function nW(n){let e=parseInt(n.slice(1,3),16),t=parseInt(n.slice(3,5),16),i=parseInt(n.slice(5,7),16),r=o=>Math.round((o+255)/2),s=o=>o.toString(16).padStart(2,"0");return"#"+s(r(e))+s(r(t))+s(r(i))}function iW(n){let e=n.nodes;if(!e||e.length===0)return{layout:[],layoutWidth:0,layoutHeight:0,timeMin:0,timeMax:0,timeUnit:"",sceneHeight:0,layoutById:new Map};let t=new Map;for(let y of e)t.set(y.id,[]);for(let y of e)y.parent_id>=0&&t.has(y.parent_id)&&t.get(y.parent_id).push(y.id);let i=new Map;for(let y of e)i.set(y.id,y);let r=new Map,s=y=>{let b=t.get(y)||[];if(b.length===0)return r.set(y,1),1;let x=0;for(let E of b)x+=s(E);return r.set(y,x),x},o=e.filter(y=>y.parent_id===-1),a=0;for(let y of o)a+=s(y.id);let c=n.min_arrival,l=n.max_arrival,u=l-c||1,f=Math.max(200,a*rv*.6),d=[],h=(y,b)=>{let x=i.get(y),E=r.get(y),w=ov+(b+E/2)*rv,T=Uh+(x.arrival-c)/u*f;d.push({id:x.id,x:w,y:T,type:x.type,name:x.name,pin_name:x.pin_name,arrival:x.arrival,delay:x.delay,fanout:x.fanout,level:x.level,parent_id:x.parent_id});let R=b,F=t.get(y)||[];for(let O of F)h(O,R),R+=r.get(O)},p=0;for(let y of o)h(y.id,p),p+=r.get(y.id);let m=ov+a*rv+tW,g=Uh+f+eW,v=new Map;for(let y of d)v.set(y.id,y);return{layout:d,layoutWidth:m,layoutHeight:g,timeMin:c,timeMax:l,timeUnit:n.time_unit||"",sceneHeight:f,layoutById:v}}var $h=class{constructor(e,t,i,r){this._app=t,this._redrawAllLayers=i,this._refreshOverlay=r||i,this._clockData=[],this._selectedClockIdx=0,this._selectedNodeId=-1,this._tx=0,this._ty=0,this._scale=1,this._layout=[],this._dragging=!1,this._dragStartX=0,this._dragStartY=0,this._dragStartTx=0,this._dragStartTy=0,this._build(e)}_build(e){let t=document.createElement("div");t.className="clock-tree-widget";let i=document.createElement("div");i.className="clock-tree-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",fe(this._app)&&(this._updateBtn.style.display="none"),this._fitBtn=document.createElement("button"),this._fitBtn.className="or-btn",this._fitBtn.textContent="Fit",this._pngBtn=document.createElement("button"),this._pngBtn.className="or-btn",this._pngBtn.textContent="PNG",this._pngBtn.title="Export the clock tree as a PNG image",this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",i.appendChild(this._updateBtn),i.appendChild(this._fitBtn),i.appendChild(this._pngBtn),i.appendChild(this._statusLabel),t.appendChild(i),this._tabBar=document.createElement("div"),this._tabBar.className="timing-tab-bar",t.appendChild(this._tabBar),this._canvas=document.createElement("canvas"),this._canvas.className="clock-tree-canvas",t.appendChild(this._canvas),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._tooltip.style.display="none",t.appendChild(this._tooltip),e.element.appendChild(t),this._el=t,this._ctx=this._canvas.getContext("2d"),this._bindEvents(),fe(this._app)&&setTimeout(()=>this.update(),0)}_fit(){this._sizeCanvas(),this._fitToView(),this._render()}_pngFileName(){let e=this._clockData[this._selectedClockIdx];return JV(e&&e.name)}_exportPng(){try{Ts(this._canvas.toDataURL("image/png"),this._pngFileName())}catch(e){console.error("PNG export failed:",e)}}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update()),this._fitBtn.addEventListener("click",()=>this._fit()),this._pngBtn.addEventListener("click",()=>this._exportPng()),this._canvas.addEventListener("keydown",e=>{e.key==="f"&&this._fit()}),this._canvas.tabIndex=0,this._canvas.addEventListener("wheel",e=>{e.preventDefault();let t=this._canvas.getBoundingClientRect(),i=e.clientX-t.left,r=e.clientY-t.top,s=e.deltaY<0?1.15:1/1.15;this._tx=i-(i-this._tx)*s,this._ty=r-(r-this._ty)*s,this._scale*=s,this._render()}),this._canvas.addEventListener("mousedown",e=>{this._dragging=!0,this._dragStartX=e.clientX,this._dragStartY=e.clientY,this._dragStartTx=this._tx,this._dragStartTy=this._ty,this._canvas.style.cursor="grabbing"}),window.addEventListener("mousemove",e=>{this._dragging?(this._tx=this._dragStartTx+(e.clientX-this._dragStartX),this._ty=this._dragStartTy+(e.clientY-this._dragStartY),this._render()):this._handleHover(e)}),window.addEventListener("mouseup",()=>{this._dragging&&(this._dragging=!1,this._canvas.style.cursor="grab")}),this._canvas.addEventListener("click",e=>this._handleClick(e)),this._resizeObserver=new ResizeObserver(()=>{this._sizeCanvas(),this._render()}),this._resizeObserver.observe(this._canvas)}_sizeCanvas(){let e=this._canvas.getBoundingClientRect(),t=window.devicePixelRatio||1;this._canvas.width=e.width*t,this._canvas.height=e.height*t,this._ctx.setTransform(t,0,0,t,0,0)}async update(){this._statusLabel.textContent="Loading...";try{let e=await this._app.websocketManager.request({type:"clock_tree"});this._clockData=e.clocks||[],this._buildTabs(),this._selectClock(0),this._statusLabel.textContent=this._clockData.length+" clock"+(this._clockData.length!==1?"s":"")}catch(e){console.error("Clock tree error:",e),this._statusLabel.textContent="Error: "+e.message}}_buildTabs(){this._tabBar.innerHTML="",this._clockData.forEach((e,t)=>{let i=document.createElement("button");i.className="timing-tab"+(t===this._selectedClockIdx?" active":""),i.textContent=e.name,i.addEventListener("click",()=>this._selectClock(t)),this._tabBar.appendChild(i)})}_selectClock(e){if(e<0||e>=this._clockData.length)return;this._selectedClockIdx=e,this._selectedNodeId=-1,this._tabBar.querySelectorAll(".timing-tab").forEach((i,r)=>{i.classList.toggle("active",r===e)}),this._computeLayout(this._clockData[e]),requestAnimationFrame(()=>{this._sizeCanvas(),this._fitToView(),this._render()})}_computeLayout(e){let t=iW(e);this._layout=t.layout,this._layoutWidth=t.layoutWidth,this._layoutHeight=t.layoutHeight,this._timeMin=t.timeMin,this._timeMax=t.timeMax,this._timeUnit=t.timeUnit,this._sceneHeight=t.sceneHeight,this._layoutById=t.layoutById}_fitToView(){if(!this._layout.length)return;let e=this._canvas.getBoundingClientRect(),t=e.width,i=e.height,r=t/this._layoutWidth,s=i/this._layoutHeight;this._scale=Math.min(r,s)*.9,this._tx=(t-this._layoutWidth*this._scale)/2,this._ty=(i-this._layoutHeight*this._scale)/2}render(){this._render()}_render(){let e=this._ctx,t=this._canvas.getBoundingClientRect(),i=t.width,r=t.height,s=Cs();if(e.clearRect(0,0,i,r),e.fillStyle=s.canvasBg,e.fillRect(0,0,i,r),!this._layout.length){e.fillStyle=s.canvasText,e.font="14px "+s.fontSans,e.textAlign="center";let o=fe(this._app)?"No clock tree data available":'Click "Update" to load clock tree data';e.fillText(o,i/2,r/2);return}e.save(),e.translate(this._tx,this._ty),e.scale(this._scale,this._scale),this._drawConnections(e);for(let o of this._layout)this._drawNode(e,o,o.id===this._selectedNodeId);e.restore(),this._drawTimeScale(e,i,r,s)}_drawConnections(e){let t=1.5/this._scale,i=sv,r=this._timeMax-this._timeMin||1;for(let s of this._layout){if(s.parent_id<0)continue;let o=this._layoutById.get(s.parent_id);if(!o)continue;let a=o.x,c=s.x,l=(o.delay||0)/r*this._sceneHeight,u=o.y+l,f=s.y,d=o.type==="root"?o.y:o.y+i;if(u>d){let p=zh[o.type]||zh.unknown;e.strokeStyle=p,e.lineWidth=t,e.beginPath(),e.moveTo(a,d),e.lineTo(a,u);let m=i/20;e.moveTo(a-m,u),e.lineTo(a+m,u),e.stroke()}e.strokeStyle="#006400",e.lineWidth=t;let h=(u+f)/2;e.beginPath(),e.moveTo(a,u),e.bezierCurveTo(a,h,c,h,c,f),e.stroke()}}_drawNode(e,t,i){let r=t.x,s=t.y,o=sv,a=zh[t.type]||zh.unknown;switch(e.fillStyle=nW(a),e.strokeStyle=a,e.lineWidth=1/this._scale,t.type){case"root":{e.beginPath(),e.moveTo(r-o/2,s-o),e.lineTo(r+o/2,s-o),e.lineTo(r,s),e.closePath(),e.fill(),e.stroke();break}case"buffer":{e.beginPath(),e.moveTo(r-o/2,s),e.lineTo(r+o/2,s),e.lineTo(r,s+o),e.closePath(),e.fill(),e.stroke();break}case"inverter":{let c=o*.1,l=s+o-c;e.beginPath(),e.moveTo(r-o/2,s),e.lineTo(r+o/2,s),e.lineTo(r,l),e.closePath(),e.fill(),e.stroke(),e.beginPath(),e.arc(r,l+c/2,c/2,0,Math.PI*2),e.fill(),e.stroke();break}case"clock_gate":{e.beginPath(),e.arc(r,s+o/2,o/2,0,Math.PI*2),e.fill(),e.stroke();break}case"register":case"macro":{e.beginPath(),e.rect(r-o/2,s,o,o),e.fill(),e.stroke(),e.beginPath(),e.moveTo(r-o/8,s),e.lineTo(r+o/8,s),e.lineTo(r,s+o/4),e.closePath(),e.stroke();break}default:{e.beginPath(),e.arc(r,s+o/2,o/2,0,Math.PI*2),e.fill(),e.stroke();break}}if(i){e.strokeStyle="#ffff00",e.lineWidth=2/this._scale;let c=t.type==="root"?s-o/2:s+o/2;e.beginPath(),e.arc(r,c,o/2+3,0,Math.PI*2),e.stroke()}}_drawTimeScale(e,t,i,r){if(!this._sceneHeight)return;let s=m=>m*this._scale+this._ty,o=s(Uh),a=s(Uh+this._sceneHeight);if(a<0||o>i)return;e.save(),e.fillStyle=r.canvasLabel,e.strokeStyle=r.canvasAxis,e.font="11px "+r.fontMono,e.textAlign="right",e.textBaseline="middle";let c=this._timeMax-this._timeMin;if(c<=0){e.restore();return}let l=a-o,u=Math.max(2,Math.floor(l/40)),f=c/u,d=Math.pow(10,Math.floor(Math.log10(f))),h=d;f/d>5?h=10*d:f/d>2?h=5*d:f/d>1&&(h=2*d);let p=Math.ceil(this._timeMin/h)*h;e.beginPath();for(let m=p;m<=this._timeMax;m+=h){let g=(m-this._timeMin)/c,v=o+g*(a-o);e.moveTo(0,v),e.lineTo(t,v);let y=m.toFixed(h<.01?3:h<.1?2:1)+" "+this._timeUnit;e.fillText(y,ov-4,v)}e.stroke(),e.restore()}_screenToLayout(e,t){return{x:(e-this._tx)/this._scale,y:(t-this._ty)/this._scale}}_hitTest(e,t){let i=this._screenToLayout(e,t),r=sv;for(let s of this._layout){let o=s.type==="root"?s.y-r:s.y,a=s.type==="root"?s.y:s.y+r;if(i.x>=s.x-r/2&&i.x<=s.x+r/2&&i.y>=o&&i.y<=a)return s}return null}_handleClick(e){let t=this._canvas.getBoundingClientRect(),i=e.clientX-t.left,r=e.clientY-t.top,s=this._hitTest(i,r);s?(this._selectedNodeId=s.id,this._render(),this._app.websocketManager.request({type:"clock_tree_highlight",inst_name:s.name}).then(()=>this._refreshOverlay())):this._selectedNodeId>=0&&(this._selectedNodeId=-1,this._render(),this._app.websocketManager.request({type:"clock_tree_highlight",inst_name:""}).then(()=>this._refreshOverlay()))}_handleHover(e){let t=this._canvas.getBoundingClientRect(),i=e.clientX-t.left,r=e.clientY-t.top;if(i<0||r<0||i>t.width||r>t.height){this._tooltip.style.display="none";return}let s=this._hitTest(i,r);if(s){let o=[s.name,"Type: "+s.type,"Arrival: "+s.arrival.toFixed(3)+" "+(this._timeUnit||"")];s.delay&&o.push("Delay: "+s.delay.toFixed(3)+" "+(this._timeUnit||"")),s.fanout&&o.push("Fanout: "+s.fanout),this._tooltip.textContent=o.join(` -`),this._tooltip.style.display="block",this._tooltip.style.left=e.clientX+12+"px",this._tooltip.style.top=e.clientY+12+"px"}else this._tooltip.style.display="none"}};var sM=60,oM=20,aM=30,cM=50,rM=2,rW="#f08080",sW="#8b0000",oW="#90ee90",aW="#006400",fr=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7"],cW="rgba(240,128,128,0.12)",lW="rgba(144,238,144,0.12)",uW="#ff9999",fW="#b0ffb0",dW=[{value:"setup",label:"Setup Slack"},{value:"hold",label:"Hold Slack"},{value:"fanout",label:"Net Fanout"},{value:"netlength",label:"Net Length (HPWL)"}];function hW(n,e,t,i){if(!n||!e||ie.bottom)return null;for(let r of n)if(t>=r.x&&t<=r.x+r.width)return r;return null}function pW(n,e,t){return t?Math.log10(n+1)/Math.log10(e+1):n/e}function mW(n,e,t,i={}){let r=!!i.logY,s=n?.bins;if(!s||s.length===0)return{bars:[],yMax:0,yTicks:[],chartArea:null,logY:r};let o=sM,a=e-oM,c=aM,l=t-cM,u=a-o,f=l-c;if(u<=0||f<=0)return{bars:[],yMax:0,yTicks:[],chartArea:null,logY:r};let d={left:o,right:a,top:c,bottom:l},h=0;for(let y of s)y.count>h&&(h=y.count);h===0&&(h=1);let{yMax:p,yTicks:m}=r?_W(h):gW(h),g=(u-rM*(s.length-1))/s.length,v=[];for(let y=0;y[l.x,...l.ys||[]].join(","));return[a,...c].join(` +Setup and hold times account for internal clock delays.`},{label:"Logic Delay",key:"path_delay",time:!0,num:!0,tooltip:"Path delay from instances (excluding buffers and consecutive inverter pairs)"},{label:"Logic Depth",key:"logic_depth",num:!0,tooltip:"Path instances (excluding buffers and consecutive inverter pairs)"},{label:"Fanout",key:"fanout",num:!0},{label:"Start",key:"start_pin"},{label:"End",key:"end_pin"}];Ps.DETAIL_COLS=["Pin","Fanout","R/F","Time","Delay","Slew","Load"];Ps.DETAIL_NUM_COLS=new Set(["Fanout","Time","Delay","Slew","Load"]);function Ge(n){let e=document.cookie.match("(?:^|; )"+n+"=([^;]*)");return e?e[1]:null}function Ne(n,e){document.cookie=n+"="+e+"; path=/; max-age=31536000; SameSite=Lax"}function Dh(n){document.cookie=n+"=; path=/; max-age=0; SameSite=Lax"}function Nh(n){Ne("or_theme",n);try{window.localStorage.setItem("or_theme",n)}catch{}}function tM(){Dh("or_theme");try{window.localStorage.removeItem("or_theme")}catch{}}function ev(n){let e=document.getElementById("gl-theme-dark"),t=document.getElementById("gl-theme-light");!e||!t||(e.disabled=n!=="dark",t.disabled=n!=="light")}function nM(n,e){Zo(n)&&(document.documentElement.style.setProperty("--bg-map",n),Ne("or_bg_color",n),rM(e),e.syncDisplayState())}function iM(n){document.documentElement.style.removeProperty("--bg-map"),Dh("or_bg_color"),rM(n),n.syncDisplayState()}function tv(){return W3(getComputedStyle(document.documentElement).getPropertyValue("--bg-map"))??"#000000"}function rM(n){n.threeDViewerWidget?.render?.()}if(typeof document<"u"){let n=Ge("or_theme")||typeof localStorage<"u"&&localStorage.getItem("or_theme")||(matchMedia("(prefers-color-scheme: light)").matches?"light":"dark");document.documentElement.dataset.theme=n,ev(n);let e=Ge("or_bg_color");Zo(e)&&document.documentElement.style.setProperty("--bg-map",e)}function Cs(){let n=getComputedStyle(document.documentElement),e=t=>n.getPropertyValue(t).trim();return{canvasBg:e("--canvas-bg"),canvasText:e("--canvas-text"),canvasAxis:e("--canvas-axis"),canvasLabel:e("--canvas-label"),canvasGrid:e("--canvas-grid"),canvasTitle:e("--canvas-title"),fgPrimary:e("--fg-primary"),fgMuted:e("--fg-muted"),bgPanel:e("--bg-panel"),bgMap:e("--bg-map"),fontMono:e("--font-mono"),fontSans:e("--font-sans")}}function Ts(n,e){let t=document.createElement("a");t.href=n,t.download=e,document.body.appendChild(t),t.click(),t.remove()}function sM(n,e){let t=URL.createObjectURL(n);Ts(t,e),setTimeout(()=>URL.revokeObjectURL(t),1e3)}function nv(n){let e=n.cloneNode(!0);if(e.getAttribute("xmlns")||e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.getAttribute("xmlns:xlink")||e.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),!e.getAttribute("width")||!e.getAttribute("height")){let t=n.viewBox&&n.viewBox.baseVal;t&&t.width&&t.height&&(e.setAttribute("width",t.width),e.setAttribute("height",t.height))}return` +`+new XMLSerializer().serializeToString(e)}function nW(n){let e=n.viewBox&&n.viewBox.baseVal;if(e&&e.width&&e.height)return{width:e.width,height:e.height};let t=parseFloat(n.getAttribute("width")),i=parseFloat(n.getAttribute("height"));if(t&&i)return{width:t,height:i};let r=n.getBoundingClientRect();return{width:r.width||800,height:r.height||600}}function iv(n,e=2){let{width:t,height:i}=nW(n),r=nv(n),s=new Blob([r],{type:"image/svg+xml;charset=utf-8"}),o=URL.createObjectURL(s);return new Promise((a,c)=>{let l=new Image;l.onload=()=>{let u=document.createElement("canvas");u.width=Math.max(1,Math.round(t*e)),u.height=Math.max(1,Math.round(i*e));let f=u.getContext("2d");f.fillStyle="#ffffff",f.fillRect(0,0,u.width,u.height),f.drawImage(l,0,0,u.width,u.height),URL.revokeObjectURL(o),a(u.toDataURL("image/png"))},l.onerror=u=>{URL.revokeObjectURL(o),c(u)},l.src=o})}async function Fh(n){try{if(!navigator.clipboard||!window.ClipboardItem)return!1;let e=await(await fetch(n)).blob();return await navigator.clipboard.write([new ClipboardItem({"image/png":e})]),!0}catch{return!1}}function iW(n){return(String(n||"").replace(/[^A-Za-z0-9._-]/g,"_").replace(/^_+|_+$/g,"")||"clock_tree")+".png"}var rv=24,sv=10,Uh=40,rW=40,ov=70,sW=20,zh={root:"#ff4444",buffer:"#4488ff",inverter:"#00b0b0",clock_gate:"#cc44cc",register:"#ff4444",macro:"#00b0b0",unknown:"#888888"};function oW(n){let e=parseInt(n.slice(1,3),16),t=parseInt(n.slice(3,5),16),i=parseInt(n.slice(5,7),16),r=o=>Math.round((o+255)/2),s=o=>o.toString(16).padStart(2,"0");return"#"+s(r(e))+s(r(t))+s(r(i))}function aW(n){let e=n.nodes;if(!e||e.length===0)return{layout:[],layoutWidth:0,layoutHeight:0,timeMin:0,timeMax:0,timeUnit:"",sceneHeight:0,layoutById:new Map};let t=new Map;for(let y of e)t.set(y.id,[]);for(let y of e)y.parent_id>=0&&t.has(y.parent_id)&&t.get(y.parent_id).push(y.id);let i=new Map;for(let y of e)i.set(y.id,y);let r=new Map,s=y=>{let b=t.get(y)||[];if(b.length===0)return r.set(y,1),1;let x=0;for(let E of b)x+=s(E);return r.set(y,x),x},o=e.filter(y=>y.parent_id===-1),a=0;for(let y of o)a+=s(y.id);let c=n.min_arrival,l=n.max_arrival,u=l-c||1,f=Math.max(200,a*rv*.6),d=[],h=(y,b)=>{let x=i.get(y),E=r.get(y),w=ov+(b+E/2)*rv,T=Uh+(x.arrival-c)/u*f;d.push({id:x.id,x:w,y:T,type:x.type,name:x.name,pin_name:x.pin_name,arrival:x.arrival,delay:x.delay,fanout:x.fanout,level:x.level,parent_id:x.parent_id});let R=b,F=t.get(y)||[];for(let O of F)h(O,R),R+=r.get(O)},p=0;for(let y of o)h(y.id,p),p+=r.get(y.id);let m=ov+a*rv+sW,g=Uh+f+rW,v=new Map;for(let y of d)v.set(y.id,y);return{layout:d,layoutWidth:m,layoutHeight:g,timeMin:c,timeMax:l,timeUnit:n.time_unit||"",sceneHeight:f,layoutById:v}}var $h=class{constructor(e,t,i,r){this._app=t,this._redrawAllLayers=i,this._refreshOverlay=r||i,this._clockData=[],this._selectedClockIdx=0,this._selectedNodeId=-1,this._tx=0,this._ty=0,this._scale=1,this._layout=[],this._dragging=!1,this._dragStartX=0,this._dragStartY=0,this._dragStartTx=0,this._dragStartTy=0,this._build(e)}_build(e){let t=document.createElement("div");t.className="clock-tree-widget";let i=document.createElement("div");i.className="clock-tree-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",fe(this._app)&&(this._updateBtn.style.display="none"),this._fitBtn=document.createElement("button"),this._fitBtn.className="or-btn",this._fitBtn.textContent="Fit",this._pngBtn=document.createElement("button"),this._pngBtn.className="or-btn",this._pngBtn.textContent="PNG",this._pngBtn.title="Export the clock tree as a PNG image",this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",i.appendChild(this._updateBtn),i.appendChild(this._fitBtn),i.appendChild(this._pngBtn),i.appendChild(this._statusLabel),t.appendChild(i),this._tabBar=document.createElement("div"),this._tabBar.className="timing-tab-bar",t.appendChild(this._tabBar),this._canvas=document.createElement("canvas"),this._canvas.className="clock-tree-canvas",t.appendChild(this._canvas),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._tooltip.style.display="none",t.appendChild(this._tooltip),e.element.appendChild(t),this._el=t,this._ctx=this._canvas.getContext("2d"),this._bindEvents(),fe(this._app)&&setTimeout(()=>this.update(),0)}_fit(){this._sizeCanvas(),this._fitToView(),this._render()}_pngFileName(){let e=this._clockData[this._selectedClockIdx];return iW(e&&e.name)}_exportPng(){try{Ts(this._canvas.toDataURL("image/png"),this._pngFileName())}catch(e){console.error("PNG export failed:",e)}}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update()),this._fitBtn.addEventListener("click",()=>this._fit()),this._pngBtn.addEventListener("click",()=>this._exportPng()),this._canvas.addEventListener("keydown",e=>{e.key==="f"&&this._fit()}),this._canvas.tabIndex=0,this._canvas.addEventListener("wheel",e=>{e.preventDefault();let t=this._canvas.getBoundingClientRect(),i=e.clientX-t.left,r=e.clientY-t.top,s=e.deltaY<0?1.15:1/1.15;this._tx=i-(i-this._tx)*s,this._ty=r-(r-this._ty)*s,this._scale*=s,this._render()}),this._canvas.addEventListener("mousedown",e=>{this._dragging=!0,this._dragStartX=e.clientX,this._dragStartY=e.clientY,this._dragStartTx=this._tx,this._dragStartTy=this._ty,this._canvas.style.cursor="grabbing"}),window.addEventListener("mousemove",e=>{this._dragging?(this._tx=this._dragStartTx+(e.clientX-this._dragStartX),this._ty=this._dragStartTy+(e.clientY-this._dragStartY),this._render()):this._handleHover(e)}),window.addEventListener("mouseup",()=>{this._dragging&&(this._dragging=!1,this._canvas.style.cursor="grab")}),this._canvas.addEventListener("click",e=>this._handleClick(e)),this._resizeObserver=new ResizeObserver(()=>{this._sizeCanvas(),this._render()}),this._resizeObserver.observe(this._canvas)}_sizeCanvas(){let e=this._canvas.getBoundingClientRect(),t=window.devicePixelRatio||1;this._canvas.width=e.width*t,this._canvas.height=e.height*t,this._ctx.setTransform(t,0,0,t,0,0)}async update(){this._statusLabel.textContent="Loading...";try{let e=await this._app.websocketManager.request({type:"clock_tree"});this._clockData=e.clocks||[],this._buildTabs(),this._selectClock(0),this._statusLabel.textContent=this._clockData.length+" clock"+(this._clockData.length!==1?"s":"")}catch(e){console.error("Clock tree error:",e),this._statusLabel.textContent="Error: "+e.message}}_buildTabs(){this._tabBar.innerHTML="",this._clockData.forEach((e,t)=>{let i=document.createElement("button");i.className="timing-tab"+(t===this._selectedClockIdx?" active":""),i.textContent=e.name,i.addEventListener("click",()=>this._selectClock(t)),this._tabBar.appendChild(i)})}_selectClock(e){if(e<0||e>=this._clockData.length)return;this._selectedClockIdx=e,this._selectedNodeId=-1,this._tabBar.querySelectorAll(".timing-tab").forEach((i,r)=>{i.classList.toggle("active",r===e)}),this._computeLayout(this._clockData[e]),requestAnimationFrame(()=>{this._sizeCanvas(),this._fitToView(),this._render()})}_computeLayout(e){let t=aW(e);this._layout=t.layout,this._layoutWidth=t.layoutWidth,this._layoutHeight=t.layoutHeight,this._timeMin=t.timeMin,this._timeMax=t.timeMax,this._timeUnit=t.timeUnit,this._sceneHeight=t.sceneHeight,this._layoutById=t.layoutById}_fitToView(){if(!this._layout.length)return;let e=this._canvas.getBoundingClientRect(),t=e.width,i=e.height,r=t/this._layoutWidth,s=i/this._layoutHeight;this._scale=Math.min(r,s)*.9,this._tx=(t-this._layoutWidth*this._scale)/2,this._ty=(i-this._layoutHeight*this._scale)/2}render(){this._render()}_render(){let e=this._ctx,t=this._canvas.getBoundingClientRect(),i=t.width,r=t.height,s=Cs();if(e.clearRect(0,0,i,r),e.fillStyle=s.canvasBg,e.fillRect(0,0,i,r),!this._layout.length){e.fillStyle=s.canvasText,e.font="14px "+s.fontSans,e.textAlign="center";let o=fe(this._app)?"No clock tree data available":'Click "Update" to load clock tree data';e.fillText(o,i/2,r/2);return}e.save(),e.translate(this._tx,this._ty),e.scale(this._scale,this._scale),this._drawConnections(e);for(let o of this._layout)this._drawNode(e,o,o.id===this._selectedNodeId);e.restore(),this._drawTimeScale(e,i,r,s)}_drawConnections(e){let t=1.5/this._scale,i=sv,r=this._timeMax-this._timeMin||1;for(let s of this._layout){if(s.parent_id<0)continue;let o=this._layoutById.get(s.parent_id);if(!o)continue;let a=o.x,c=s.x,l=(o.delay||0)/r*this._sceneHeight,u=o.y+l,f=s.y,d=o.type==="root"?o.y:o.y+i;if(u>d){let p=zh[o.type]||zh.unknown;e.strokeStyle=p,e.lineWidth=t,e.beginPath(),e.moveTo(a,d),e.lineTo(a,u);let m=i/20;e.moveTo(a-m,u),e.lineTo(a+m,u),e.stroke()}e.strokeStyle="#006400",e.lineWidth=t;let h=(u+f)/2;e.beginPath(),e.moveTo(a,u),e.bezierCurveTo(a,h,c,h,c,f),e.stroke()}}_drawNode(e,t,i){let r=t.x,s=t.y,o=sv,a=zh[t.type]||zh.unknown;switch(e.fillStyle=oW(a),e.strokeStyle=a,e.lineWidth=1/this._scale,t.type){case"root":{e.beginPath(),e.moveTo(r-o/2,s-o),e.lineTo(r+o/2,s-o),e.lineTo(r,s),e.closePath(),e.fill(),e.stroke();break}case"buffer":{e.beginPath(),e.moveTo(r-o/2,s),e.lineTo(r+o/2,s),e.lineTo(r,s+o),e.closePath(),e.fill(),e.stroke();break}case"inverter":{let c=o*.1,l=s+o-c;e.beginPath(),e.moveTo(r-o/2,s),e.lineTo(r+o/2,s),e.lineTo(r,l),e.closePath(),e.fill(),e.stroke(),e.beginPath(),e.arc(r,l+c/2,c/2,0,Math.PI*2),e.fill(),e.stroke();break}case"clock_gate":{e.beginPath(),e.arc(r,s+o/2,o/2,0,Math.PI*2),e.fill(),e.stroke();break}case"register":case"macro":{e.beginPath(),e.rect(r-o/2,s,o,o),e.fill(),e.stroke(),e.beginPath(),e.moveTo(r-o/8,s),e.lineTo(r+o/8,s),e.lineTo(r,s+o/4),e.closePath(),e.stroke();break}default:{e.beginPath(),e.arc(r,s+o/2,o/2,0,Math.PI*2),e.fill(),e.stroke();break}}if(i){e.strokeStyle="#ffff00",e.lineWidth=2/this._scale;let c=t.type==="root"?s-o/2:s+o/2;e.beginPath(),e.arc(r,c,o/2+3,0,Math.PI*2),e.stroke()}}_drawTimeScale(e,t,i,r){if(!this._sceneHeight)return;let s=m=>m*this._scale+this._ty,o=s(Uh),a=s(Uh+this._sceneHeight);if(a<0||o>i)return;e.save(),e.fillStyle=r.canvasLabel,e.strokeStyle=r.canvasAxis,e.font="11px "+r.fontMono,e.textAlign="right",e.textBaseline="middle";let c=this._timeMax-this._timeMin;if(c<=0){e.restore();return}let l=a-o,u=Math.max(2,Math.floor(l/40)),f=c/u,d=Math.pow(10,Math.floor(Math.log10(f))),h=d;f/d>5?h=10*d:f/d>2?h=5*d:f/d>1&&(h=2*d);let p=Math.ceil(this._timeMin/h)*h;e.beginPath();for(let m=p;m<=this._timeMax;m+=h){let g=(m-this._timeMin)/c,v=o+g*(a-o);e.moveTo(0,v),e.lineTo(t,v);let y=m.toFixed(h<.01?3:h<.1?2:1)+" "+this._timeUnit;e.fillText(y,ov-4,v)}e.stroke(),e.restore()}_screenToLayout(e,t){return{x:(e-this._tx)/this._scale,y:(t-this._ty)/this._scale}}_hitTest(e,t){let i=this._screenToLayout(e,t),r=sv;for(let s of this._layout){let o=s.type==="root"?s.y-r:s.y,a=s.type==="root"?s.y:s.y+r;if(i.x>=s.x-r/2&&i.x<=s.x+r/2&&i.y>=o&&i.y<=a)return s}return null}_handleClick(e){let t=this._canvas.getBoundingClientRect(),i=e.clientX-t.left,r=e.clientY-t.top,s=this._hitTest(i,r);s?(this._selectedNodeId=s.id,this._render(),this._app.websocketManager.request({type:"clock_tree_highlight",inst_name:s.name}).then(()=>this._refreshOverlay())):this._selectedNodeId>=0&&(this._selectedNodeId=-1,this._render(),this._app.websocketManager.request({type:"clock_tree_highlight",inst_name:""}).then(()=>this._refreshOverlay()))}_handleHover(e){let t=this._canvas.getBoundingClientRect(),i=e.clientX-t.left,r=e.clientY-t.top;if(i<0||r<0||i>t.width||r>t.height){this._tooltip.style.display="none";return}let s=this._hitTest(i,r);if(s){let o=[s.name,"Type: "+s.type,"Arrival: "+s.arrival.toFixed(3)+" "+(this._timeUnit||"")];s.delay&&o.push("Delay: "+s.delay.toFixed(3)+" "+(this._timeUnit||"")),s.fanout&&o.push("Fanout: "+s.fanout),this._tooltip.textContent=o.join(` +`),this._tooltip.style.display="block",this._tooltip.style.left=e.clientX+12+"px",this._tooltip.style.top=e.clientY+12+"px"}else this._tooltip.style.display="none"}};var aM=60,cM=20,lM=30,uM=50,oM=2,cW="#f08080",lW="#8b0000",uW="#90ee90",fW="#006400",fr=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7"],dW="rgba(240,128,128,0.12)",hW="rgba(144,238,144,0.12)",pW="#ff9999",mW="#b0ffb0",gW=[{value:"setup",label:"Setup Slack"},{value:"hold",label:"Hold Slack"},{value:"fanout",label:"Net Fanout"},{value:"netlength",label:"Net Length (HPWL)"}];function _W(n,e,t,i){if(!n||!e||ie.bottom)return null;for(let r of n)if(t>=r.x&&t<=r.x+r.width)return r;return null}function yW(n,e,t){return t?Math.log10(n+1)/Math.log10(e+1):n/e}function bW(n,e,t,i={}){let r=!!i.logY,s=n?.bins;if(!s||s.length===0)return{bars:[],yMax:0,yTicks:[],chartArea:null,logY:r};let o=aM,a=e-cM,c=lM,l=t-uM,u=a-o,f=l-c;if(u<=0||f<=0)return{bars:[],yMax:0,yTicks:[],chartArea:null,logY:r};let d={left:o,right:a,top:c,bottom:l},h=0;for(let y of s)y.count>h&&(h=y.count);h===0&&(h=1);let{yMax:p,yTicks:m}=r?xW(h):vW(h),g=(u-oM*(s.length-1))/s.length,v=[];for(let y=0;y[l.x,...l.ys||[]].join(","));return[a,...c].join(` `)}let t=e.bins||[],i=Array.isArray(e.series)?e.series:[],r=["lower","upper","count",...i.map(o=>o.name||"group")].join(","),s=t.map((o,a)=>{let c=[o.lower,o.upper,o.count];for(let l of i)c.push(l.counts&&l.counts[a]||0);return c.join(",")});return[r,...s].join(` -`)}var Gh=class{constructor(e,t){this._app=e,this._redrawAllLayers=t,this._currentTab="setup",this._histogramData=null,this._bars=[],this._yMax=0,this._yTicks=[],this._chartArea=null,this._hoveredBar=null,this._debugCharts=[],this._activeDebugChart=-1,this._build()}_build(){let e=document.createElement("div");e.className="charts-widget";let t=document.createElement("div");t.className="charts-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",fe(this._app)&&(this._updateBtn.style.display="none"),this._chartSelect=document.createElement("select"),this._chartSelect.className="charts-select",this._csvBtn=document.createElement("button"),this._csvBtn.className="or-btn",this._csvBtn.textContent="CSV",this._csvBtn.title="Export the current chart data as CSV",this._pngBtn=document.createElement("button"),this._pngBtn.className="or-btn",this._pngBtn.textContent="PNG",this._pngBtn.title="Export the current chart as a PNG image",this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",t.appendChild(this._updateBtn),t.appendChild(this._chartSelect),t.appendChild(this._csvBtn),t.appendChild(this._pngBtn),t.appendChild(this._statusLabel),e.appendChild(t);let i=document.createElement("div");i.className="charts-toolbar";let r=document.createElement("span");r.textContent="Path Groups:",r.style.color="var(--fg-muted)",r.style.fontSize="var(--fs-12)",this._pathGroupSelect=document.createElement("select"),this._pathGroupSelect.className="charts-select",this._pathGroupSelect.multiple=!0,this._pathGroupSelect.size=1,this._pathGroupSelect.title="Select 0 = all, or \u22651 to stack by group";let s=document.createElement("span");s.textContent="Clock:",s.style.color="var(--fg-muted)",s.style.fontSize="var(--fs-12)",this._clockSelect=document.createElement("select"),this._clockSelect.className="charts-select",this._clockSelect.innerHTML='',i.appendChild(r),i.appendChild(this._pathGroupSelect),i.appendChild(s),i.appendChild(this._clockSelect),e.appendChild(i),this._canvas=document.createElement("canvas"),this._canvas.className="charts-canvas",e.appendChild(this._canvas),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._tooltip.style.display="none",e.appendChild(this._tooltip),this._filterRow=i,this.element=e,this._ctx=this._canvas.getContext("2d"),this._rebuildSelect(),this._bindEvents(),fe(this._app)&&setTimeout(()=>this.update(),0)}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update()),this._chartSelect.addEventListener("change",()=>this._onSelectChange()),this._csvBtn.addEventListener("click",()=>this._exportCsv()),this._pngBtn.addEventListener("click",()=>this._exportPng()),this._pathGroupSelect.addEventListener("change",()=>this._fetchHistogram()),this._clockSelect.addEventListener("change",()=>this._fetchHistogram()),this._canvas.addEventListener("mousemove",t=>this._handleHover(t)),this._canvas.addEventListener("mouseleave",()=>{this._hoveredBar=null,this._tooltip.style.display="none",this._syncView()}),this._canvas.addEventListener("click",t=>this._handleClick(t)),this._canvas.addEventListener("dblclick",t=>this._handleDblClick(t)),new ResizeObserver(()=>this._syncView()).observe(this._canvas)}_sizeCanvas(){let e=this._canvas.getBoundingClientRect(),t=window.devicePixelRatio||1;this._canvas.width=e.width*t,this._canvas.height=e.height*t,this._ctx.setTransform(t,0,0,t,0,0)}_rebuildSelect(){let e=this._chartSelect;e.innerHTML="";for(let t of dW){let i=document.createElement("option");i.value=t.value,i.textContent=t.label,e.appendChild(i)}this._debugCharts.forEach((t,i)=>{let r=document.createElement("option");r.value="gen:"+i,r.textContent=t.name||"Chart "+i,e.appendChild(r)}),e.value=this._activeDebugChart>=0?"gen:"+this._activeDebugChart:this._currentTab}_onSelectChange(){let e=this._chartSelect.value;e.startsWith("gen:")?(this._activeDebugChart=parseInt(e.slice(4),10)||0,this._hoveredBar=null,this._tooltip.style.display="none",this._syncView()):this._selectTab(e)}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...",this._statusLabel.textContent="";try{this._activeDebugChart<0?((this._currentTab==="setup"||this._currentTab==="hold")&&await this._fetchFilters(),await Promise.all([this._fetchHistogram(),this._fetchGenericCharts()])):await this._fetchGenericCharts()}catch(e){this._statusLabel.textContent="Error: "+e.message}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}async _fetchFilters(){let e=await this._app.websocketManager.request({type:"chart_filters"});this._populatePathGroups(e.path_groups||[]),this._populateClocks(e.clocks||[])}_populatePathGroups(e){let t=new Set(Array.from(this._pathGroupSelect.selectedOptions,i=>i.value));this._pathGroupSelect.innerHTML="";for(let i of e){let r=document.createElement("option");r.value=i,r.textContent=i,r.selected=t.has(i),this._pathGroupSelect.appendChild(r)}}_populateClocks(e){let t=this._clockSelect.value;this._clockSelect.innerHTML='';for(let i of e){let r=document.createElement("option");r.value=i,r.textContent=i,this._clockSelect.appendChild(r)}e.includes(t)&&(this._clockSelect.value=t)}async _fetchGenericCharts(){try{let e=await this._app.websocketManager.request({type:"debug_charts"});this.setDebugCharts(e.charts||[])}catch{}}async _fetchHistogram(){try{let e=this._currentTab,t;if(e==="fanout")t={type:"fanout_histogram"};else if(e==="netlength")t={type:"net_length_histogram",use_dbu:!!this._app.showDbu};else{t={type:"slack_histogram",is_setup:e==="setup"};let r=Array.from(this._pathGroupSelect.selectedOptions,s=>s.value).filter(Boolean);r.length>0&&(t.path_groups=r),this._clockSelect.value&&(t.clock_name=this._clockSelect.value)}let i=await this._app.websocketManager.request(t);if(this._currentTab!==e)return;if(this._histogramData=i,this._syncView(),e==="fanout"||e==="netlength"){let r=i.total_nets||0;this._statusLabel.textContent=`${r} nets`}else{let r=i.total_endpoints||0,s=i.unconstrained_count||0,o=r-s;this._statusLabel.textContent=`${o} endpoints`+(s>0?`, ${s} unconstrained`:"")}}catch(e){this._statusLabel.textContent="Error: "+e.message}}_selectTab(e){this._currentTab===e&&this._activeDebugChart<0||(this._currentTab=e,this._activeDebugChart=-1,this._chartSelect&&(this._chartSelect.value=e),this._filterRow.style.display=e==="setup"||e==="hold"?"":"none",this._hoveredBar=null,this._tooltip.style.display="none",this.update())}_computeLayout(){if(!this._histogramData)return;let e=this._canvas.getBoundingClientRect(),t=mW(this._histogramData,e.width,e.height,{logY:this._currentTab==="fanout"});this._bars=t.bars,this._yMax=t.yMax,this._yTicks=t.yTicks,this._chartArea=t.chartArea,this._logY=!!t.logY}render(){this._syncView()}_stackedSeries(){let e=this._histogramData?.series;return Array.isArray(e)&&e.length>1?e:null}_render(){let e=this._canvas.getBoundingClientRect(),t=e.width,i=e.height,r=this._ctx,s=Cs();if(r.clearRect(0,0,t,i),r.fillStyle=s.canvasBg,r.fillRect(0,0,t,i),!this._bars||this._bars.length===0){r.fillStyle=s.canvasText,r.font="14px "+s.fontSans,r.textAlign="center",r.textBaseline="middle";let o=fe(this._app)?"No histogram data available":'Click "Update" to load histogram';r.fillText(o,t/2,i/2);return}this._drawAxes(r,s),this._drawBars(r),this._drawTitle(r,t,s),this._stackedSeries()&&this._drawSeriesLegend(r,s)}_drawAxes(e,t){let i=this._chartArea;if(!i)return;e.strokeStyle=t.canvasAxis,e.lineWidth=1,e.beginPath(),e.moveTo(i.left,i.top),e.lineTo(i.left,i.bottom),e.stroke(),e.beginPath(),e.moveTo(i.left,i.bottom),e.lineTo(i.right,i.bottom),e.stroke(),e.fillStyle=t.canvasLabel,e.font="11px "+t.fontMono,e.textAlign="right",e.textBaseline="middle";let r=i.bottom-i.top;for(let d of this._yTicks){let h=this._logY?Math.log10(d+1)/Math.log10(this._yMax+1):d/this._yMax,p=i.bottom-h*r;e.fillText(this._formatCount(d),i.left-6,p),d>0&&(e.strokeStyle=t.canvasGrid,e.beginPath(),e.moveTo(i.left,p),e.lineTo(i.right,p),e.stroke(),e.strokeStyle=t.canvasAxis)}let s=this._currentTab,o=s==="fanout"||s==="netlength";e.save(),e.translate(14,(i.top+i.bottom)/2),e.rotate(-Math.PI/2),e.textAlign="center",e.textBaseline="middle",e.fillStyle=t.canvasTitle,e.font="11px "+t.fontMono,e.fillText(this._logY?"Nets (log)":o?"Nets":"Endpoints",0,0),e.restore(),e.textAlign="center",e.textBaseline="top",e.fillStyle=t.canvasLabel,e.font="10px "+t.fontMono;let a=this._histogramData.bins,c=this._histogramData.time_unit||this._histogramData.length_unit||"",l=a.length>0?a[0].upper-a[0].lower:1,u=s==="fanout"?0:Math.max(0,-Math.floor(Math.log10(l)));for(let d=0;d<=this._bars.length;d++){let h=d=0){this._hoveredBar=null,this._tooltip.style.display="none";return}let t=this._hitTestBar(e);if(t!==this._hoveredBar&&(this._hoveredBar=t,this._render()),t){let i=this._currentTab,r=t.upper-t.lower;if(i==="fanout"){let d=t.upper-1,h=t.lower===d?`${t.lower}`:`[${t.lower}, ${d}]`;this._tooltip.textContent=`Nets: ${t.count} +`)}var Gh=class{constructor(e,t){this._app=e,this._redrawAllLayers=t,this._currentTab="setup",this._histogramData=null,this._bars=[],this._yMax=0,this._yTicks=[],this._chartArea=null,this._hoveredBar=null,this._debugCharts=[],this._activeDebugChart=-1,this._build()}_build(){let e=document.createElement("div");e.className="charts-widget";let t=document.createElement("div");t.className="charts-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",fe(this._app)&&(this._updateBtn.style.display="none"),this._chartSelect=document.createElement("select"),this._chartSelect.className="charts-select",this._csvBtn=document.createElement("button"),this._csvBtn.className="or-btn",this._csvBtn.textContent="CSV",this._csvBtn.title="Export the current chart data as CSV",this._pngBtn=document.createElement("button"),this._pngBtn.className="or-btn",this._pngBtn.textContent="PNG",this._pngBtn.title="Export the current chart as a PNG image",this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",t.appendChild(this._updateBtn),t.appendChild(this._chartSelect),t.appendChild(this._csvBtn),t.appendChild(this._pngBtn),t.appendChild(this._statusLabel),e.appendChild(t);let i=document.createElement("div");i.className="charts-toolbar";let r=document.createElement("span");r.textContent="Path Groups:",r.style.color="var(--fg-muted)",r.style.fontSize="var(--fs-12)",this._pathGroupSelect=document.createElement("select"),this._pathGroupSelect.className="charts-select",this._pathGroupSelect.multiple=!0,this._pathGroupSelect.size=1,this._pathGroupSelect.title="Select 0 = all, or \u22651 to stack by group";let s=document.createElement("span");s.textContent="Clock:",s.style.color="var(--fg-muted)",s.style.fontSize="var(--fs-12)",this._clockSelect=document.createElement("select"),this._clockSelect.className="charts-select",this._clockSelect.innerHTML='',i.appendChild(r),i.appendChild(this._pathGroupSelect),i.appendChild(s),i.appendChild(this._clockSelect),e.appendChild(i),this._canvas=document.createElement("canvas"),this._canvas.className="charts-canvas",e.appendChild(this._canvas),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._tooltip.style.display="none",e.appendChild(this._tooltip),this._filterRow=i,this.element=e,this._ctx=this._canvas.getContext("2d"),this._rebuildSelect(),this._bindEvents(),fe(this._app)&&setTimeout(()=>this.update(),0)}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update()),this._chartSelect.addEventListener("change",()=>this._onSelectChange()),this._csvBtn.addEventListener("click",()=>this._exportCsv()),this._pngBtn.addEventListener("click",()=>this._exportPng()),this._pathGroupSelect.addEventListener("change",()=>this._fetchHistogram()),this._clockSelect.addEventListener("change",()=>this._fetchHistogram()),this._canvas.addEventListener("mousemove",t=>this._handleHover(t)),this._canvas.addEventListener("mouseleave",()=>{this._hoveredBar=null,this._tooltip.style.display="none",this._syncView()}),this._canvas.addEventListener("click",t=>this._handleClick(t)),this._canvas.addEventListener("dblclick",t=>this._handleDblClick(t)),new ResizeObserver(()=>this._syncView()).observe(this._canvas)}_sizeCanvas(){let e=this._canvas.getBoundingClientRect(),t=window.devicePixelRatio||1;this._canvas.width=e.width*t,this._canvas.height=e.height*t,this._ctx.setTransform(t,0,0,t,0,0)}_rebuildSelect(){let e=this._chartSelect;e.innerHTML="";for(let t of gW){let i=document.createElement("option");i.value=t.value,i.textContent=t.label,e.appendChild(i)}this._debugCharts.forEach((t,i)=>{let r=document.createElement("option");r.value="gen:"+i,r.textContent=t.name||"Chart "+i,e.appendChild(r)}),e.value=this._activeDebugChart>=0?"gen:"+this._activeDebugChart:this._currentTab}_onSelectChange(){let e=this._chartSelect.value;e.startsWith("gen:")?(this._activeDebugChart=parseInt(e.slice(4),10)||0,this._hoveredBar=null,this._tooltip.style.display="none",this._syncView()):this._selectTab(e)}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...",this._statusLabel.textContent="";try{this._activeDebugChart<0?((this._currentTab==="setup"||this._currentTab==="hold")&&await this._fetchFilters(),await Promise.all([this._fetchHistogram(),this._fetchGenericCharts()])):await this._fetchGenericCharts()}catch(e){this._statusLabel.textContent="Error: "+e.message}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}async _fetchFilters(){let e=await this._app.websocketManager.request({type:"chart_filters"});this._populatePathGroups(e.path_groups||[]),this._populateClocks(e.clocks||[])}_populatePathGroups(e){let t=new Set(Array.from(this._pathGroupSelect.selectedOptions,i=>i.value));this._pathGroupSelect.innerHTML="";for(let i of e){let r=document.createElement("option");r.value=i,r.textContent=i,r.selected=t.has(i),this._pathGroupSelect.appendChild(r)}}_populateClocks(e){let t=this._clockSelect.value;this._clockSelect.innerHTML='';for(let i of e){let r=document.createElement("option");r.value=i,r.textContent=i,this._clockSelect.appendChild(r)}e.includes(t)&&(this._clockSelect.value=t)}async _fetchGenericCharts(){try{let e=await this._app.websocketManager.request({type:"debug_charts"});this.setDebugCharts(e.charts||[])}catch{}}async _fetchHistogram(){try{let e=this._currentTab,t;if(e==="fanout")t={type:"fanout_histogram"};else if(e==="netlength")t={type:"net_length_histogram",use_dbu:!!this._app.showDbu};else{t={type:"slack_histogram",is_setup:e==="setup"};let r=Array.from(this._pathGroupSelect.selectedOptions,s=>s.value).filter(Boolean);r.length>0&&(t.path_groups=r),this._clockSelect.value&&(t.clock_name=this._clockSelect.value)}let i=await this._app.websocketManager.request(t);if(this._currentTab!==e)return;if(this._histogramData=i,this._syncView(),e==="fanout"||e==="netlength"){let r=i.total_nets||0;this._statusLabel.textContent=`${r} nets`}else{let r=i.total_endpoints||0,s=i.unconstrained_count||0,o=r-s;this._statusLabel.textContent=`${o} endpoints`+(s>0?`, ${s} unconstrained`:"")}}catch(e){this._statusLabel.textContent="Error: "+e.message}}_selectTab(e){this._currentTab===e&&this._activeDebugChart<0||(this._currentTab=e,this._activeDebugChart=-1,this._chartSelect&&(this._chartSelect.value=e),this._filterRow.style.display=e==="setup"||e==="hold"?"":"none",this._hoveredBar=null,this._tooltip.style.display="none",this.update())}_computeLayout(){if(!this._histogramData)return;let e=this._canvas.getBoundingClientRect(),t=bW(this._histogramData,e.width,e.height,{logY:this._currentTab==="fanout"});this._bars=t.bars,this._yMax=t.yMax,this._yTicks=t.yTicks,this._chartArea=t.chartArea,this._logY=!!t.logY}render(){this._syncView()}_stackedSeries(){let e=this._histogramData?.series;return Array.isArray(e)&&e.length>1?e:null}_render(){let e=this._canvas.getBoundingClientRect(),t=e.width,i=e.height,r=this._ctx,s=Cs();if(r.clearRect(0,0,t,i),r.fillStyle=s.canvasBg,r.fillRect(0,0,t,i),!this._bars||this._bars.length===0){r.fillStyle=s.canvasText,r.font="14px "+s.fontSans,r.textAlign="center",r.textBaseline="middle";let o=fe(this._app)?"No histogram data available":'Click "Update" to load histogram';r.fillText(o,t/2,i/2);return}this._drawAxes(r,s),this._drawBars(r),this._drawTitle(r,t,s),this._stackedSeries()&&this._drawSeriesLegend(r,s)}_drawAxes(e,t){let i=this._chartArea;if(!i)return;e.strokeStyle=t.canvasAxis,e.lineWidth=1,e.beginPath(),e.moveTo(i.left,i.top),e.lineTo(i.left,i.bottom),e.stroke(),e.beginPath(),e.moveTo(i.left,i.bottom),e.lineTo(i.right,i.bottom),e.stroke(),e.fillStyle=t.canvasLabel,e.font="11px "+t.fontMono,e.textAlign="right",e.textBaseline="middle";let r=i.bottom-i.top;for(let d of this._yTicks){let h=this._logY?Math.log10(d+1)/Math.log10(this._yMax+1):d/this._yMax,p=i.bottom-h*r;e.fillText(this._formatCount(d),i.left-6,p),d>0&&(e.strokeStyle=t.canvasGrid,e.beginPath(),e.moveTo(i.left,p),e.lineTo(i.right,p),e.stroke(),e.strokeStyle=t.canvasAxis)}let s=this._currentTab,o=s==="fanout"||s==="netlength";e.save(),e.translate(14,(i.top+i.bottom)/2),e.rotate(-Math.PI/2),e.textAlign="center",e.textBaseline="middle",e.fillStyle=t.canvasTitle,e.font="11px "+t.fontMono,e.fillText(this._logY?"Nets (log)":o?"Nets":"Endpoints",0,0),e.restore(),e.textAlign="center",e.textBaseline="top",e.fillStyle=t.canvasLabel,e.font="10px "+t.fontMono;let a=this._histogramData.bins,c=this._histogramData.time_unit||this._histogramData.length_unit||"",l=a.length>0?a[0].upper-a[0].lower:1,u=s==="fanout"?0:Math.max(0,-Math.floor(Math.log10(l)));for(let d=0;d<=this._bars.length;d++){let h=d=0){this._hoveredBar=null,this._tooltip.style.display="none";return}let t=this._hitTestBar(e);if(t!==this._hoveredBar&&(this._hoveredBar=t,this._render()),t){let i=this._currentTab,r=t.upper-t.lower;if(i==="fanout"){let d=t.upper-1,h=t.lower===d?`${t.lower}`:`[${t.lower}, ${d}]`;this._tooltip.textContent=`Nets: ${t.count} Fanout: ${h}`}else if(i==="netlength"){let d=this._histogramData?.length_unit||"",h=Math.max(0,-Math.floor(Math.log10(r)));this._tooltip.textContent=`Nets: ${t.count} Length: [${t.lower.toFixed(h)}, ${t.upper.toFixed(h)}) ${d}`}else{let d=this._histogramData?.time_unit||"",h=Math.max(0,-Math.floor(Math.log10(r)));this._tooltip.textContent=`Endpoints: ${t.count} -Slack: [${t.lower.toFixed(h)}, ${t.upper.toFixed(h)}) ${d}`}this._tooltip.style.display="block";let s=this.element.getBoundingClientRect(),o=this._tooltip.getBoundingClientRect(),a=4,c=e.clientX-s.left,l=e.clientY-s.top,u=c+12;u+o.width>s.width-a&&(u=c-12-o.width),u=Math.max(a,u);let f=l-10;f=Math.min(s.height-o.height-a,Math.max(a,f)),this._tooltip.style.left=u+"px",this._tooltip.style.top=f+"px"}else this._tooltip.style.display="none"}async _handleClick(e){if(this._activeDebugChart>=0||this._currentTab==="fanout"||this._currentTab==="netlength")return;let t=this._hitTestBar(e);if(!(!t||t.count===0))try{let i=await this._app.websocketManager.request({type:"timing_report",is_setup:this._currentTab==="setup",max_paths:50,slack_min:t.lower,slack_max:t.upper});this._app.timingWidget&&(this._app.timingWidget.showPaths(this._currentTab,i.paths||[]),this._app.focusComponent&&this._app.focusComponent("TimingWidget"))}catch(i){console.error("Charts bar click error:",i)}}async _handleDblClick(e){if(this._activeDebugChart>=0)return;let t;if(this._currentTab==="fanout")t="select_fanout_bin";else if(this._currentTab==="netlength")t="select_net_length_bin";else return;let i=this._hitTestBar(e);if(!i||i.count===0)return;let r=Pt(this._app);try{let s=await this._app.websocketManager.request({type:t,lower:i.lower,upper:i.upper,use_dbu:this._app.showDbu});if(!zt(this._app,r))return;s&&s.truncated&&console.warn(`Bin has ${s.count} nets; selection capped at ${s.selection_limit} for performance.`),this._app.updateInspector&&this._app.updateInspector(s),this._app.focusComponent&&this._app.focusComponent("Inspector"),this._redrawAllLayers&&this._redrawAllLayers()}catch(s){console.error("Net bin select failed:",s)}}_activeChartData(){return this._activeDebugChart>=0?{kind:"generic",data:this._debugCharts[this._activeDebugChart]}:{kind:"histogram",data:this._histogramData}}_chartBaseName(){return this._activeDebugChart>=0?this._debugCharts[this._activeDebugChart].name||"chart":this._currentTab}_triggerDownload(e,t,{revoke:i=!1}={}){let r=document.createElement("a");r.href=t,r.download=e,document.body.appendChild(r),r.click(),r.remove(),i&&URL.revokeObjectURL(t)}_download(e,t,i){try{let r=URL.createObjectURL(new Blob([i],{type:t}));this._triggerDownload(e,r,{revoke:!0})}catch(r){console.error("Download failed:",r)}}_exportCsv(){let{kind:e,data:t}=this._activeChartData();if(!t)return;let i=yW(e,t);this._download(this._chartBaseName()+".csv","text/csv",i)}_exportPng(){try{let e=this._canvas.toDataURL("image/png");this._triggerDownload(this._chartBaseName()+".png",e)}catch(e){console.error("PNG export failed:",e)}}setDebugCharts(e){this._debugCharts=e,e.length===0?this._activeDebugChart=-1:this._activeDebugChart>=e.length&&(this._activeDebugChart=0),this._rebuildSelect(),this._syncView()}_syncView(){let e=this._activeDebugChart>=0;e&&(this._hoveredBar=null,this._tooltip.style.display="none");let t=!e&&(this._currentTab==="setup"||this._currentTab==="hold");this._filterRow&&(this._filterRow.style.display=t?"":"none"),this._sizeCanvas(),e?this._renderLineChart(this._debugCharts[this._activeDebugChart]):(this._computeLayout(),this._render())}_renderLineChart(e){let t=this._canvas.getBoundingClientRect(),i=t.width,r=t.height,s=this._ctx,o=Cs();s.clearRect(0,0,i,r),s.fillStyle=o.canvasBg,s.fillRect(0,0,i,r);let a=e.points;if(!a||a.length===0){s.fillStyle=o.canvasText,s.font="14px "+o.fontSans,s.textAlign="center",s.textBaseline="middle",s.fillText("No data points yet",i/2,r/2);return}let c=e.y_labels?e.y_labels.length:1,l=sM,u=i-oM,f=aM,d=r-cM,h=u-l,p=d-f;if(h<=0||p<=0)return;let m=a[0].x,g=a[0].x,v=1/0,y=-1/0;for(let T of a){T.xg&&(g=T.x);for(let R of T.ys)Ry&&(y=R)}m===g&&(g=m+1),(!isFinite(v)||!isFinite(y))&&(v=0,y=1);let b=(y-v)*.05||1;v-=b,y+=b;let x=T=>l+(T-m)/(g-m)*h,E=T=>d-(T-v)/(y-v)*p;s.strokeStyle=o.canvasAxis,s.lineWidth=1,s.beginPath(),s.moveTo(l,f),s.lineTo(l,d),s.lineTo(u,d),s.stroke(),s.fillStyle=o.canvasLabel,s.font="10px "+o.fontMono,s.textAlign="right",s.textBaseline="middle";let w=5;for(let T=0;T<=w;T++){let R=v+(y-v)*T/w,F=E(R);s.fillText(this._formatNum(R),l-4,F),T>0&&T1&&e.y_labels){s.font="10px "+o.fontMono,s.textAlign="left",s.textBaseline="top";let T=l+8,R=f+4;for(let F=0;F=1e6?(e/1e6).toFixed(1)+"M":t>=1e3?(e/1e3).toFixed(1)+"k":t>=1?e.toFixed(1):e.toPrecision(3)}_formatCount(e){return e===0?"0":e>=1e6?e/1e6+"M":e>=1e3?e/1e3+"k":String(e)}};var Cn=class{constructor(e){this.onChange=e,this.roots=[],this._nodeMap=new Map}addFromSpec(e,t=null){let i=this._makeNode(e.id,t,e);if(i.checked=e.checked!==!1,e.children){for(let r of e.children)i.children.push(this.addFromSpec(r,i));i.hasCheckbox&&this._computeParent(i)}return t||this.roots.push(i),i}buildFromNodes(e){this._nodeMap.clear(),this.roots=[];for(let t of e)this._makeNode(t.id,null,t);for(let t of e){let i=this._nodeMap.get(t.id);if(t.parentId!=null&&this._nodeMap.has(t.parentId)){let r=this._nodeMap.get(t.parentId);i.parent=r,r.children.push(i)}else this.roots.push(i)}for(let t=e.length-1;t>=0;t--){let i=this._nodeMap.get(e[t].id);i.hasCheckbox&&i.children.length>0&&this._computeParent(i)}return this.roots}get(e){return this._nodeMap.get(e)}isVisible(e){let t=this.get(e);return t?t.checked:!1}check(e,t){let i=this._nodeMap.get(e);if(i){i.checked=t,i.indeterminate=!1;for(let r of i.children)this._setSubtree(r,t);for(let r=i.parent;r;r=r.parent)r.hasCheckbox&&this._computeParent(r);this.onChange()}}cascadeQuiet(e,t){let i=this._nodeMap.get(e);if(i){i.checked=t,i.indeterminate=!1;for(let r of i.children)this._setSubtree(r,t);for(let r=i.parent;r;r=r.parent)r.hasCheckbox&&this._computeParent(r)}}checkSet(e){for(let[t,i]of Object.entries(e)){let r=this._nodeMap.get(t);r&&(r.checked=i,r.indeterminate=!1)}this._recomputeAllParents(),this.onChange()}mirrorStates(e){this._applyMirror(e),this.onChange()}mirrorStatesQuiet(e){this._applyMirror(e)}_applyMirror(e){for(let[t,i]of Object.entries(e)){let r=this._nodeMap.get(t);r&&(r.checked=!!i.checked,r.indeterminate=!!i.indeterminate)}}forEach(e){let t=i=>{e(i);for(let r of i.children)t(r)};for(let i of this.roots)t(i)}_makeNode(e,t,i){let r={id:e,parent:t,children:[],hasCheckbox:i.hasCheckbox!==!1,checked:i.checked!==!1,indeterminate:!1,data:i.data!=null?i.data:i};return this._nodeMap.set(e,r),r}_checkboxDescendants(e){let t=[];for(let i of e.children)i.hasCheckbox?t.push(i):t.push(...this._checkboxDescendants(i));return t}_computeParent(e){let t=this._checkboxDescendants(e);if(t.length===0)return;let i=t.every(s=>s.checked&&!s.indeterminate),r=t.every(s=>!s.checked&&!s.indeterminate);e.checked=i,e.indeterminate=!i&&!r}_setSubtree(e,t){e.hasCheckbox&&(e.checked=t,e.indeterminate=!1);for(let i of e.children)this._setSubtree(i,t)}_recomputeAllParents(){let e=t=>{for(let i of t.children)e(i);t.hasCheckbox&&t.children.length>0&&this._computeParent(t)};for(let t of this.roots)e(t)}};var lM=["Instance","Module","Instances","Macros","Modules","Area","Local Inst","Local Macros","Local Modules"],dr={MODULE:0,LEAF_GROUP:1,TYPE_GROUP:2,INSTANCE:3,NAME_GROUP:4};function Ls(n){return n===dr.MODULE||n===dr.NAME_GROUP}var Vh=class{constructor(e,t,i){this._app=t,this._redrawAllLayers=i,this._nodes=[],this._nameGrouped=!1,this._nameGroupsCapped=!1,this._rows=[],this._childrenMap=new Map,this._collapsed=new Set,this._moduleState=new Map,this._checkModel=null,this._build(e),t.hierarchyBrowser=this,fe(t)&&this.update()}_build(e){let t=document.createElement("div");t.className="hierarchy-widget";let i=document.createElement("div");i.className="timing-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",fe(this._app)&&(this._updateBtn.style.display="none"),this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",i.appendChild(this._updateBtn),i.appendChild(this._statusLabel),t.appendChild(i),this._tableContainer=document.createElement("div"),this._tableContainer.className="hierarchy-table-container",this._table=document.createElement("table"),this._table.className="timing-table",this._tableContainer.appendChild(this._table),t.appendChild(this._tableContainer),e.element.appendChild(t),this._bindEvents()}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update())}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...",this._statusLabel.textContent="";try{let e=await this._app.websocketManager.request({type:"module_hierarchy"});this._nodes=e.nodes||[],this._nameGrouped=!!e.name_grouped,this._nameGroupsCapped=!!e.name_groups_capped,this._buildTree(),this._readServerColors(),this._computeEffectiveColors(),this._render(),this._statusLabel.textContent=this._statusText(),await this._sendModuleColors()}catch(e){this._statusLabel.textContent="Error: "+e.message}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}_statusText(){let e=this._nodes.filter(r=>Ls(r.node_kind||0)).length;if(!this._nameGrouped)return e+" modules";let i=Math.max(0,e-1)+" groups from instance names \u2014 this design has no module hierarchy";return this._nameGroupsCapped&&(i+=" (truncated: too many groups)"),i}_buildTree(){this._childrenMap.clear(),this._collapsed.clear();for(let t of this._nodes)this._childrenMap.set(t.id,[]);for(let t of this._nodes)t.parent_id>=0&&this._childrenMap.has(t.parent_id)&&this._childrenMap.get(t.parent_id).push(t.id);this._nodeMap=new Map;for(let t of this._nodes)this._nodeMap.set(t.id,t);for(let t of this._nodes){let i=this._childrenMap.get(t.id);if(!i||i.length===0)continue;let r=t.node_kind||0;r===dr.LEAF_GROUP||r===dr.TYPE_GROUP?this._collapsed.add(t.id):Ls(r)&&t.parent_id>=0&&this._collapsed.add(t.id)}this._rows=[];let e=this._nodes.filter(t=>t.parent_id<0);for(let t of e)this._dfs(t.id,0);this._checkModel=new Cn(()=>{this._checkModel.forEach(t=>{if(!t.hasCheckbox)return;let i=this._moduleState.get(t.data.odb_id);i&&(i.visible=t.checked)}),this._sendModuleColors()}),this._checkModel.buildFromNodes(this._nodes.map(t=>({id:t.id,parentId:t.parent_id,hasCheckbox:Ls(t.node_kind||0)&&t.odb_id!=null,checked:!0,data:t})))}_readServerColors(){this._moduleState.clear();for(let e of this._rows){let t=this._nodeMap.get(e.id);if(!t||!Ls(t.node_kind||0)||t.odb_id==null)continue;let i=t.color||[128,128,128];this._moduleState.set(t.odb_id,{color:i,effectiveColor:i,visible:!0,nodeId:t.id})}}_computeEffectiveColors(){for(let e of this._rows){let t=this._nodeMap.get(e.id);if(!t||!Ls(t.node_kind||0))continue;let i=this._moduleState.get(t.odb_id);if(!i)continue;let r=t.parent_id,s=null;for(;r>=0;){let o=this._nodeMap.get(r);if(!o)break;if(Ls(o.node_kind||0)){let a=this._moduleState.get(o.odb_id);a&&this._collapsed.has(o.id)&&(s=a.effectiveColor)}r=o.parent_id}i.effectiveColor=s||i.color}}async _sendModuleColors(){let e=[];for(let[i,r]of this._moduleState){if(!r.visible)continue;let[s,o,a]=r.effectiveColor;e.push(`${i}:${s},${o},${a},100`)}let t=e.join(";");try{let i=await this._app.websocketManager.request({type:"set_module_colors",colors:t});console.log("set_module_colors:",i.count,"modules,",e.length,"sent")}catch(i){console.error("set_module_colors failed:",i)}this._redrawAllLayers()}_dfs(e,t){this._rows.push({id:e,depth:t});let i=this._childrenMap.get(e)||[];for(let r of i)this._dfs(r,t+1)}_render(){this._table.innerHTML="";let e=document.createElement("thead"),t=document.createElement("tr");for(let r of lM){let s=document.createElement("th");s.textContent=r,t.appendChild(s)}e.appendChild(t),this._table.appendChild(e);let i=document.createElement("tbody");for(let r of this._rows){let s=this._nodeMap.get(r.id);if(!s||this._isHidden(s))continue;let o=document.createElement("tr"),a=s.node_kind||0,l=(this._childrenMap.get(r.id)||[]).length>0,u=this._collapsed.has(r.id);a===dr.LEAF_GROUP||a===dr.TYPE_GROUP?(o.style.fontStyle="italic",o.style.color="var(--fg-disabled)"):a===dr.INSTANCE?o.style.color="var(--fg-secondary)":a===dr.NAME_GROUP&&(o.classList.add("hierarchy-name-group"),o.title="Recovered from instance names \u2014 this design has no module hierarchy");let f=document.createElement("td");if(f.style.paddingLeft=8+r.depth*16+"px",f.style.whiteSpace="nowrap",Ls(a)&&s.odb_id!=null){let p=this._moduleState.get(s.odb_id),m=this._checkModel?this._checkModel.get(s.id):null;if(p&&m){let g=document.createElement("input");g.type="checkbox",g.checked=m.checked,g.indeterminate=m.indeterminate,g.className="hierarchy-module-cb",m.cb=g,g.addEventListener("change",E=>{E.stopPropagation(),this._checkModel.check(s.id,g.checked),this._render()}),f.appendChild(g);let v=document.createElement("span");v.className="hierarchy-color-swatch";let[y,b,x]=p.effectiveColor;v.style.backgroundColor=`rgb(${y},${b},${x})`,f.appendChild(v)}}if(l){let p=document.createElement("span");p.className="hierarchy-arrow",p.textContent=u?"\u25B6":"\u25BC",p.addEventListener("click",m=>{m.stopPropagation(),this._toggleNode(r.id)}),f.appendChild(p)}else{let p=document.createElement("span");p.className="hierarchy-arrow",p.style.visibility="hidden",p.textContent="\u25B6",f.appendChild(p)}let d=document.createElement("span");d.textContent=s.inst_name,f.appendChild(d),o.appendChild(f);let h=[s.module_name,Ko(s.insts),Ko(s.macros),Ko(s.modules),this._fmtArea(s.area),Ko(s.local_insts),Ko(s.local_macros),Ko(s.local_modules)];for(let p of h){let m=document.createElement("td");m.textContent=p,m.style.textAlign="right",o.appendChild(m)}o.children[1].style.textAlign="left",i.appendChild(o)}if(this._rows.length===0){let r=document.createElement("tr"),s=document.createElement("td");s.colSpan=lM.length,s.style.textAlign="center",s.style.color="var(--fg-secondary)",s.textContent=fe(this._app)?"No hierarchy data available":'Click "Update" to load hierarchy',r.appendChild(s),i.appendChild(r)}this._table.appendChild(i),ws(this._table)}_isHidden(e){let t=e.parent_id;for(;t>=0;){if(this._collapsed.has(t))return!0;let i=this._nodeMap.get(t);if(!i)break;t=i.parent_id}return!1}_toggleNode(e){this._collapsed.has(e)?this._collapsed.delete(e):this._collapsed.add(e),this._computeEffectiveColors(),this._render(),this._sendModuleColors()}_fmtArea(e){if(e==null)return"";if(this._app.showDbu){let t=this._app.getDbuPerMicron();return String(Math.round(e*t*t))}return e>=1e6?(e/1e6).toFixed(3)+" mm\xB2":e.toFixed(3)+" \u03BCm\xB2"}};function Ko(n){return n!=null?String(n):""}var bW='',vW='',xW='',wW='',EW='',SW='',PW='',CW='',TW='',LW='',MW='',AW='';function uM(n,e,t){t=t||e;let i=null,r=null,s=null,o=!1,a=10;function c(M,S){return o?Promise.resolve():(o=!0,n.websocketManager.request({type:"set_property",name:M,use_dbu:n.showDbu,...S}).then(L=>{!L.ok&&L.error&&Ft(L.error),Re(L),L.ok&&L.bbox&&Ge(L.bbox)}).catch(L=>{console.error("set_property failed:",L),Ft("Edit failed: "+L),i&&Re(i)}).finally(()=>{o=!1}))}function l(M,S){let L=document.createElement("select");L.className="inspector-editor-select";let D=M.editor.type==="bool"?["True","False"]:M.editor.options||[];for(let A of D){let z=document.createElement("option");z.value=A,z.textContent=A,A===M.value&&(z.selected=!0),L.appendChild(z)}if(!D.includes(M.value)){let A=document.createElement("option");A.value=M.value||"",A.textContent=M.value||"",A.selected=!0,A.disabled=!0,L.insertBefore(A,L.firstChild)}return L.addEventListener("change",()=>{if(S.onPropertyChange){S.onPropertyChange(M.name,L.value);return}if(M.editor.type==="bool")S.onPropertyEdit(M,{value:L.value==="True"});else{let A=(M.editor.options||[]).indexOf(L.value);S.onPropertyEdit(M,{option_index:A,option_name:L.value})}}),L}async function u(M,S){if(!o&&!(M==="Delete"&&!await I3({title:"Delete "+(S.type||"object"),message:"Delete "+(S.type||"object")+' "'+(S.name||"")+'"? This cannot be undone.',confirmLabel:"Delete",danger:!0}))){o=!0;try{let L=await n.websocketManager.request({type:"trigger_action",name:M,use_dbu:n.showDbu});!L.ok&&L.error&&Ft(L.error),Re(L.properties?L:null),L.deleted&&cn(),se(),t()}catch(L){console.error("trigger_action failed:",L),Ft("Action failed: "+L)}finally{o=!1}}}function f(M){n.websocketManager.request({...M,use_dbu:n.showDbu}).then(S=>{!S.ok&&S.error&&Ft(S.error),Re(S),t()}).catch(S=>{console.error(M.type+" failed:",S)})}function d(){let M=document.getElementById("highlight-picker");M&&M.remove()}function h(M,S){d();let L=n.techData?.highlight_colors||[];if(!L.length)return;let D=document.createElement("div");D.id="highlight-picker";let A=document.createElement("div");if(A.className="highlight-swatch-grid",L.forEach((B,U)=>{let Z=document.createElement("button");Z.className="highlight-swatch",Z.title="Group "+(U+1),Z.style.backgroundColor=`rgb(${B[0]}, ${B[1]}, ${B[2]})`,U===S.highlight_group&&Z.classList.add("active"),Z.addEventListener("click",()=>{d(),f({type:"highlight",group:U})}),A.appendChild(Z)}),D.appendChild(A),S.highlight_group>=0){let B=document.createElement("button");B.className="highlight-remove",B.textContent="Remove highlight",B.addEventListener("click",()=>{d(),f({type:"unhighlight"})}),D.appendChild(B)}document.body.appendChild(D);let z=M.getBoundingClientRect();D.style.left=z.left+"px",D.style.top=z.bottom+4+"px";let I=B=>{B.type==="keydown"&&B.key!=="Escape"||B.type==="mousedown"&&D.contains(B.target)||(d(),document.removeEventListener("mousedown",I,!0),document.removeEventListener("keydown",I,!0))};setTimeout(()=>{document.addEventListener("mousedown",I,!0),document.addEventListener("keydown",I,!0)},0)}function p(){if(!n.inspectorEl)return;n.inspectorEl.innerHTML="";let M=document.createElement("div");M.className="stub-panel",M.innerHTML='
Loading\u2026
Fetching properties from server.
',n.inspectorEl.appendChild(M)}async function m(M){let S=n.focusNets.has(M)?"remove":"add";S==="add"?n.focusNets.add(M):n.focusNets.delete(M);try{await n.websocketManager.request({type:"set_focus_nets",action:S,net_name:M})}catch(L){console.error("set_focus_nets failed:",L)}e(),i&&Re(i)}async function g(){n.focusNets.clear();try{await n.websocketManager.request({type:"set_focus_nets",action:"clear",net_name:""})}catch(M){console.error("set_focus_nets clear failed:",M)}e(),i&&Re(i)}async function v(M){let S=n.routeGuideNets.has(M)?"remove":"add";S==="add"?n.routeGuideNets.add(M):n.routeGuideNets.delete(M);try{await n.websocketManager.request({type:"set_route_guides",action:S,net_name:M})}catch(L){console.error("set_route_guides failed:",L)}t(),i&&Re(i)}function y(M,S,L,D){return Nt(M,S,L,D,n.designScale,n.designOriginX,n.designOriginY)}function b(M,S,L){return M+(S-M)*L}function x(M,S,L){return M.map((D,A)=>Math.round(b(D,S[A],L)))}function E(M,S){let L=0;for(;LM[L+1].at;)L++;let D=M[L],A=M[L+1],z=Math.max(0,Math.min(1,(S-D.at)/(A.at-D.at))),I={};for(let B of Object.keys(D))B!=="at"&&(I[B]=Array.isArray(D[B])?x(D[B],A[B],z):b(D[B],A[B],z));return I}function w(M,S,L,D){if(Vl()||typeof requestAnimationFrame!="function")return D(),()=>{};let A=performance.now(),z=!1,I=()=>{if(z)return;let B=performance.now()-A;if(B>=M*S){D();return}L(B%M/M),requestAnimationFrame(I)};return I(),()=>{z=!0}}function T(M,S,L=ot.highlight){n.view&&n.view.setOverlay(M,S,{order:L})}let R=null,F=()=>{},O=[255,242,122],j=[{at:0,stroke:[255,246,176],width:7,alpha:1,fill:.28},{at:.55,stroke:[255,255,255],width:5,alpha:1,fill:.06},{at:1,stroke:[255,232,92],width:3,alpha:.95,fill:.14}],V={stroke:[255,232,92],width:3,alpha:1,fill:.14};function G(M,S,L,D){let[A,z,I,B]=y(M,S,L,D),U=a/2**n.view.getZoom(),Z=Math.max(0,(U-(I-A))/2),Q=Math.max(0,(U-(B-z))/2);return[A-Z,z-Q,I+Z,B+Q]}function q(M){R&&T("hover",R.map(([S,L,D,A])=>({kind:"rect",rect:G(S,L,D,A),stroke:Ut(M.stroke,M.alpha),width:M.width,fill:Ut(O,M.fill)})))}function X(){q(V)}function se(){F(),R=null,T("hover",null),n.view?.off("zoom",X)}function le(){se(),n.websocketManager.request({type:"hover",select_id:-1}).then(()=>{}).catch(()=>{})}function he(M){se(),!(!n.view||!n.designScale||!M||M.length===0)&&(R=M,n.view.on("zoom",X),F=w(900,3,S=>q(E(j,1-Math.pow(1-S,2))),()=>q(V)))}function at(M,S){M.classList.add("inspector-link"),M.addEventListener("click",L=>{L.stopPropagation(),Tn(S)}),M.addEventListener("mouseenter",()=>{s!==null&&(n.websocketManager.cancel(s),s=null);let L=n.websocketManager.request({type:"hover",select_id:S});s=L.requestId,L.then(D=>{s=null,he(D.rects||[]),t()}).catch(()=>{s=null})}),M.addEventListener("mouseleave",()=>{le(),t()})}function Ct(M){let S=M>0?"select_next":"select_prev";r!==null&&(n.websocketManager.cancel(r),r=null),p();let L=Pt(n),D=n.websocketManager.request({type:S,use_dbu:n.showDbu});r=D.requestId,D.then(A=>{if(r=null,!!zt(n,L)){if(A.error){console.error("Selection cycle error:",A.error),Re(i);return}if(Re(A),A.type==="Inst"&&A.name&&(n.selectedInstanceName=A.name,n.schematicWidget&&n.schematicWidget.refresh()),se(),cn(),A.bbox&&n.view&&n.designScale){let[z,I,B,U]=A.bbox;A.type!=="Inst"&&Gt(z,I,B,U,A.type),A.selection_count>1?Mn(A.bbox):Ge(A.bbox,A.type)}e()}}).catch(A=>{r=null,console.error("Selection cycle failed:",A),Re(i)})}function Tn(M){r!==null&&(n.websocketManager.cancel(r),r=null),p();let S=Pt(n),L=n.websocketManager.request({type:"inspect",select_id:M,use_dbu:n.showDbu});r=L.requestId,L.then(D=>{if(r=null,!!zt(n,S)){if(D.error){console.error("Inspect error:",D.error);return}if(Re(D),se(),cn(),D.bbox&&n.view&&n.designScale){let[A,z,I,B]=D.bbox;D.type!=="Inst"&&Gt(A,z,I,B,D.type),Ge(D.bbox,D.type)}t()}}).catch(D=>{r=null,console.error("Inspect failed:",D)})}function Ni(){r!==null&&(n.websocketManager.cancel(r),r=null),p();let M=Pt(n),S=n.websocketManager.request({type:"inspect_back",use_dbu:n.showDbu});r=S.requestId,S.then(L=>{if(r=null,!!zt(n,M)){if(L.error){console.error("Inspect back error:",L.error);return}if(Re(L),se(),cn(),L.bbox&&n.view&&n.designScale){if(L.type!=="Inst"){let[D,A,z,I]=L.bbox;Gt(D,A,z,I,L.type)}Ge(L.bbox,L.type)}t()}}).catch(L=>{r=null,console.error("Inspect back failed:",L)})}let Ln=null;function li(){let M=Ln&&n.designScale&&!(n.visibility&&n.visibility.highlight_selected===!1);T("selection",M?[{kind:"rect",rect:y(...Ln),stroke:Ut("#ff0"),width:2,dash:[6,4]}]:null,ot.selection)}function cn(){Ln=null,li()}function Gt(M,S,L,D,A){Ln=A==="Net"?null:[M,S,L,D],li()}let ln=null,ui=[{at:0,alpha:0,fill:0},{at:.5,alpha:1,fill:.28},{at:1,alpha:0,fill:0}];function fi(){ln&&(ln(),ln=null),T("pulse",null)}function Ge(M,S){if(!M||!n.view||!n.designScale||(_t!==null&&di(),fi(),n.visibility&&n.visibility.highlight_selected===!1)||S==="Net")return;let L=y(...M);ln=w(350,3,D=>{let A=E(ui,.5-.5*Math.cos(Math.PI*D));T("pulse",[{kind:"rect",rect:L,stroke:Ut("#ff0",A.alpha),width:3,fill:Ut("#ff0",A.fill)}])},()=>{ln=null,T("pulse",null)})}let _t=null;function Vt(M,S){T("anim",[{kind:"rect",rect:M,stroke:Ut("#ff0"),width:S,fill:Ut("#ff0",S===1?.39:0)}])}function di(){_t!==null&&(clearInterval(_t),_t=null),T("anim",null)}function Mn(M,{repeats:S=6,intervalMs:L=300}={}){if(!M||!n.view||!n.designScale)return;if(di(),Vl()){Ge(M);return}let D=y(...M);Vt(D,1);let A=0,z=S>0?S*3:1/0;_t=setInterval(()=>{if(A+=1,A>=z){di();return}Vt(D,A%3+1)},L)}n.clearSelectionPulse=fi,n.renderSelectionOutline=li,n.clearSelectionOutline=cn;function hi(M,S,L){let D=document.createElement("div");D.className="inspector-group";let A=document.createElement("div");A.className="inspector-group-header";let z=document.createElement("span");z.className="vis-arrow";let I=document.createElement("span");if(I.className="inspector-prop-name",I.textContent=M,I.title=M,A.appendChild(z),A.appendChild(I),S!==null){let U=document.createElement("span");U.className="inspector-count",U.textContent=`(${S})`,A.appendChild(U)}D.appendChild(A);let B=document.createElement("div");return B.className="inspector-group-children"+(L?" collapsed":""),z.textContent=L?"\u25B6":"\u25BC",D.appendChild(B),A.addEventListener("click",()=>{B.classList.toggle("collapsed"),z.textContent=B.classList.contains("collapsed")?"\u25B6":"\u25BC"}),{group:D,header:A,arrow:z,body:B}}function Ke(M){let S=M.column_headers||[],L=M.row_headers||[],D=M.data||[],A=S.some(U=>U!==""),z=L.some(U=>U!==""),I=document.createElement("table");if(I.className="inspector-table",A){let U=document.createElement("thead"),Z=document.createElement("tr");z&&Z.appendChild(document.createElement("th"));for(let Q of S){let ye=document.createElement("th");ye.textContent=Q,Z.appendChild(ye)}U.appendChild(Z),I.appendChild(U)}let B=document.createElement("tbody");return D.forEach((U,Z)=>{let Q=document.createElement("tr");if(z){let ye=document.createElement("th");ye.textContent=L[Z]||"",Q.appendChild(ye)}for(let ye of U){let be=document.createElement("td");be.textContent=ye,Q.appendChild(be)}B.appendChild(Q)}),I.appendChild(B),I}function Wt(M,S){if(M.table){let I=(M.table.data||[]).length,{group:B,body:U}=hi(M.name,I,I>=10),Z=document.createElement("div");return Z.className="inspector-table-scroll",Z.appendChild(Ke(M.table)),U.appendChild(Z),B}if(M.children){let I=M.children.length<10,{group:B,body:U}=hi(M.name,M.children.length,!I);for(let Z of M.children)U.appendChild(Wt(Z,S));return B}let L=document.createElement("div");L.className="inspector-prop";let D=document.createElement("span");D.className="inspector-prop-name",D.textContent=M.name||"",D.title=M.name||"";let A=document.createElement("span");A.className="inspector-prop-value",A.textContent=M.value||"",L.appendChild(D),L.appendChild(A);let z=M.editable&&S&&(S.onPropertyEdit||S.onPropertyChange)&&M.editor&&(M.editor.type==="list"||M.editor.type==="bool");if(z&&M.value_select_id===void 0)L.replaceChild(l(M,S),A);else if(z){let I=document.createElement("button");I.className="inspector-edit-btn",I.title="Edit "+M.name,I.textContent="\u270E",I.addEventListener("click",B=>{B.stopPropagation();let U=l(M,S);L.replaceChild(U,A),I.remove(),U.focus()}),L.appendChild(I)}else M.editable&&S&&(S.onPropertyChange||S.onPropertyEdit)&&(A.contentEditable=!0,A.classList.add("inspector-editable"),A.addEventListener("blur",()=>{let I=A.textContent;if(I!==M.value){if(S.onPropertyChange){S.onPropertyChange(M.name,I);return}if(M.editor&&M.editor.type==="number"){let B=Number(I);if(I.trim()===""||Number.isNaN(B)){Ft("Not a number: "+I),A.textContent=M.value;return}S.onPropertyEdit(M,{value:B});return}S.onPropertyEdit(M,{value:I})}}),A.addEventListener("keydown",I=>{I.key==="Enter"&&(I.preventDefault(),A.blur()),I.key==="Escape"&&(A.textContent=M.value,A.blur())}));return M.name_select_id!==void 0&&M.value_select_id===void 0?(at(L,M.name_select_id),D.classList.add("inspector-link")):M.name_select_id!==void 0&&at(D,M.name_select_id),M.value_select_id!==void 0&&at(A,M.value_select_id),L}let un=140,An=60,Rs=500,pi=un;function yr(){n.inspectorEl&&n.inspectorEl.style.setProperty("--inspector-name-w",pi+"px")}function kn(){let M=document.createElement("div");return M.className="inspector-col-resizer",M.title="Drag to resize the name column",M.addEventListener("mousedown",S=>{S.preventDefault();let L=S.clientX,D=pi;M.classList.add("dragging");let A=I=>{pi=Math.max(An,Math.min(Rs,D+I.clientX-L)),yr()},z=()=>{M.classList.remove("dragging"),document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",z)};document.addEventListener("mousemove",A),document.addEventListener("mouseup",z)}),M}function jt(M){!M||!n.view||!n.designScale||n.view.fitWorldRect(y(...M),{padding:[20,20]})}function Re(M){if(!n.inspectorEl)return;if(i=M,n.inspectorEl.innerHTML="",!M||!M.properties||M.properties.length===0){di();let A=document.createElement("div");A.className="stub-panel",A.innerHTML='
Inspector
Select an object in the layout to inspect its properties.
',n.inspectorEl.appendChild(A);return}if(!M.onPropertyChange&&!M.onPropertyEdit&&!fe(n)&&(M.onPropertyEdit=(A,z)=>c(A.name,z)),M){let A=document.createElement("div");A.className="inspector-toolbar";let z=document.createElement("button");if(z.className="or-btn or-btn-icon",z.title="Back",z.innerHTML=wW,z.disabled=!M.can_navigate_back,z.addEventListener("click",()=>Ni()),A.appendChild(z),M.bbox){let I=document.createElement("button");I.className="or-btn or-btn-icon",I.title="Zoom to",I.innerHTML=xW,I.addEventListener("click",()=>jt(M.bbox)),A.appendChild(I)}if(M.type==="Net"&&M.name){let I=n.focusNets.has(M.name),B=document.createElement("button");B.className="or-btn or-btn-icon",B.title=I?"De-focus net":"Focus net",B.innerHTML=I?SW:EW,B.addEventListener("click",()=>m(M.name)),A.appendChild(B)}if(M.type==="Net"&&M.name&&M.has_guides){let I=n.routeGuideNets.has(M.name),B=document.createElement("button");B.className="or-btn or-btn-icon",B.title=I?"Hide route guides":"Show route guides",B.innerHTML=I?CW:PW,B.addEventListener("click",()=>v(M.name)),A.appendChild(B)}if(M.type==="Net"&&M.name&&n.showInsertBufferDialog){let I=document.createElement("button");I.className="or-btn or-btn-icon",I.title="Insert buffer",I.innerHTML=AW,I.addEventListener("click",()=>n.showInsertBufferDialog(M.name)),A.appendChild(I)}if(n.focusNets.size>0){let I=document.createElement("button");I.className="or-btn or-btn-icon",I.title="Clear focus nets",I.innerHTML=TW,I.addEventListener("click",()=>g()),A.appendChild(I)}if(typeof M.highlight_group=="number"&&!fe(n)&&(n.techData?.highlight_colors||[]).length){let I=document.createElement("button");I.className="or-btn or-btn-icon inspector-highlight-btn";let B=M.highlight_group;if(I.title=B>=0?"Highlight group "+(B+1):"Add to highlight group",I.innerHTML=vW,B>=0){let U=n.techData.highlight_colors[B];I.style.backgroundColor=`rgba(${U[0]}, ${U[1]}, ${U[2]}, 0.45)`,I.style.borderColor=`rgb(${U[0]}, ${U[1]}, ${U[2]})`}I.addEventListener("click",()=>h(I,M)),A.appendChild(I)}if(Array.isArray(M.actions)&&!fe(n))for(let I of M.actions){let B=document.createElement("button");B.className="or-btn inspector-action-btn",B.title=I,I==="Delete"?(B.classList.add("or-btn-icon","or-btn-danger-hover"),B.innerHTML=bW):(B.classList.add("or-btn-sm"),B.textContent=I),B.addEventListener("click",()=>u(I,M)),A.appendChild(B)}n.inspectorEl.appendChild(A)}let S=M.selection_count||0,L=typeof M.selection_index=="number"?M.selection_index:-1;if(S>1&&L>=0){let A=document.createElement("div");A.className="inspector-selection-nav";let z=document.createElement("button");z.className="or-btn or-btn-icon",z.title="Previous (Shift+click to multi-select)",z.innerHTML=LW,z.addEventListener("click",()=>Ct(-1));let I=document.createElement("span");I.className="inspector-selection-label",I.textContent=L+1+" / "+S;let B=document.createElement("button");B.className="or-btn or-btn-icon",B.title="Next",B.innerHTML=MW,B.addEventListener("click",()=>Ct(1)),A.appendChild(z),A.appendChild(I),A.appendChild(B),n.inspectorEl.appendChild(A)}let D=document.createElement("div");D.className="inspector-rows";for(let A of M.properties)D.appendChild(Wt(A,M));D.appendChild(kn()),n.inspectorEl.appendChild(D),yr()}function na(M){let S=document.createElement("div");S.className="inspector",n.inspectorEl=S,M.element.appendChild(S),Re(null)}function Ce(){if(i){if(i.type==="Ruler"){n.rulerManager&&n.rulerManager._selectedRulerId!==null&&n.rulerManager._selectRuler(n.rulerManager._selectedRulerId);return}n.websocketManager&&Tn(-1)}}return{createInspector:na,updateInspector:Re,highlightBBox:Gt,pulseHighlight:Ge,animateSelection:Mn,stopSelectionAnimation:di,navigateInspector:Tn,refreshInspector:Ce}}var Wh=class{constructor(e,t,i){this._app=t,this._refreshOverlay=i||(()=>{}),this._data={selection:[],groups:[],truncated:!1},this._tab="selected",this._filter="",this._sortKey=null,this._sortAsc=!0,this._pendingRefresh=null,this._inFlight=!1,this._staleWhileInFlight=!1,this._visible=!0,this._el=document.createElement("div"),this._el.className="selection-browser",e.element.appendChild(this._el),e.on?.("show",()=>{this._visible=!0,this.refresh()}),e.on?.("hide",()=>{this._visible=!1}),e.on?.("destroy",()=>{this._visible=!1,this._staleWhileInFlight=!1,this._pendingRefresh!==null&&(clearTimeout(this._pendingRefresh),this._pendingRefresh=null)}),this._render(),this.refresh()}scheduleRefresh(){!this._visible||this._pendingRefresh!==null||(this._pendingRefresh=setTimeout(()=>{this._pendingRefresh=null,this.refresh()},150))}refresh(){if(!this._visible||fe(this._app))return;if(this._inFlight){this._staleWhileInFlight=!0;return}this._inFlight=!0;let e=()=>{this._inFlight=!1,this._staleWhileInFlight&&(this._staleWhileInFlight=!1,this.refresh())};this._app.websocketManager.request({type:"list_selection"}).then(t=>{t.ok&&(this._data=t,this._render()),e()}).catch(e)}_entries(){let e;this._tab==="selected"?e=(this._data.selection||[]).map((i,r)=>({row:i,index:r,group:-1})):e=(this._data.groups||[]).flatMap((i,r)=>i.map((s,o)=>({row:s,index:o,group:r})));let t=this._filter.trim().toLowerCase();if(t&&(e=e.filter(({row:i})=>(i.name||"").toLowerCase().includes(t)||(i.type||"").toLowerCase().includes(t))),this._sortKey){let i=this._sortKey,r=this._sortAsc?1:-1;e=e.slice().sort((s,o)=>r*String(s.row[i]||"").localeCompare(String(o.row[i]||"")))}return e}_fmtCoord(e){if(this._app.showDbu)return String(e);let t=this._app.getDbuPerMicron?this._app.getDbuPerMicron():1e3;return(e/t).toFixed(3)}_fmtBounds(e){if(!e)return"";let[t,i,r,s]=e;return`(${this._fmtCoord(t)}, ${this._fmtCoord(i)}), (${this._fmtCoord(r)}, ${this._fmtCoord(s)})`}_inspectRow(e,t){let i=e.group<0?{type:"inspect_selection",index:e.index,use_dbu:this._app.showDbu}:{type:"inspect_group",group:e.group,index:e.index,use_dbu:this._app.showDbu};this._app.websocketManager.request(i).then(r=>{if(!r.ok){this.refresh();return}this._app.updateInspector&&this._app.updateInspector(r),t&&this._app.focusComponent&&this._app.focusComponent("Inspector"),this._refreshOverlay()}).catch(()=>{})}_deselectRow(e){this._app.websocketManager.request({type:"deselect",index:e.index}).then(()=>{this.refresh(),this._refreshOverlay()}).catch(()=>{})}_clearHighlights(){this._app.websocketManager.request({type:"clear_highlights",group:-1}).then(()=>{this.refresh(),this._refreshOverlay(),this._app.refreshInspector&&this._app.refreshInspector()}).catch(()=>{})}_zoomToBBox(e){if(!e||!this._app.designScale||!this._app.view)return;let[t,i,r,s]=e,o=this._app.getDbuPerMicron?this._app.getDbuPerMicron():1e3,a=Math.min(10*o,2*Math.max(r-t,s-i));this._app.view.fitWorldRect(Nt(t-a,i-a,r+a,s+a,this._app.designScale,this._app.designOriginX,this._app.designOriginY))}_render(){this._app.stopSelectionAnimation&&this._app.stopSelectionAnimation(),this._el.innerHTML="";let e=(this._data.selection||[]).length,t=(this._data.groups||[]).reduce((o,a)=>o+a.length,0),i=document.createElement("div");i.className="sb-tabs";for(let[o,a,c]of[["selected","Selected",e],["highlighted","Highlighted",t]]){let l=document.createElement("button");l.className="sb-tab"+(this._tab===o?" active":""),l.textContent=`${a} (${c})`,l.addEventListener("click",()=>{this._tab=o,this._render()}),i.appendChild(l)}let r=document.createElement("button");if(r.className="or-btn or-btn-sm sb-tool",r.title="Refresh",r.textContent="\u27F3",r.addEventListener("click",()=>this.refresh()),i.appendChild(r),this._tab==="highlighted"&&t>0){let o=document.createElement("button");o.className="or-btn or-btn-sm sb-tool",o.title="Clear all highlights",o.textContent="Clear",o.addEventListener("click",()=>this._clearHighlights()),i.appendChild(o)}this._el.appendChild(i);let s=document.createElement("input");if(s.type="text",s.className="sb-filter",s.placeholder="Filter by name or type\u2026",s.value=this._filter,s.addEventListener("input",()=>{this._filter=s.value,this._renderTable()}),this._el.appendChild(s),this._data.truncated){let o=document.createElement("div");o.className="sb-truncated",o.textContent="List truncated \u2014 showing the first 1000 entries per set.",this._el.appendChild(o)}this._tableWrap=document.createElement("div"),this._tableWrap.className="sb-table-wrap",this._el.appendChild(this._tableWrap),this._renderTable()}_renderTable(){this._tableWrap.innerHTML="";let e=this._entries();if(!e.length){let c=document.createElement("div");c.className="sb-empty",c.textContent=this._tab==="selected"?"Nothing selected.":"Nothing highlighted.",this._tableWrap.appendChild(c);return}let t=document.createElement("table");t.className="sb-table";let i=document.createElement("thead"),r=document.createElement("tr"),s=[["name","Object"],["type","Type"],[null,"Bounds"]];this._tab==="highlighted"&&s.push([null,"Group"]),s.push([null,""]);for(let[c,l]of s){let u=document.createElement("th");u.textContent=l,c&&(u.classList.add("sb-sortable"),this._sortKey===c&&(u.textContent+=this._sortAsc?" \u25B2":" \u25BC"),u.addEventListener("click",()=>{this._sortKey===c?this._sortAsc=!this._sortAsc:(this._sortKey=c,this._sortAsc=!0),this._renderTable()})),r.appendChild(u)}i.appendChild(r),t.appendChild(i);let o=document.createElement("tbody"),a=this._app.techData?.highlight_colors||[];for(let c of e){let l=document.createElement("tr");l.className="sb-row";let u=document.createElement("td");u.textContent=c.row.name||"";let f=document.createElement("td");f.textContent=c.row.type||"";let d=document.createElement("td");if(d.textContent=this._fmtBounds(c.row.bbox),l.appendChild(u),l.appendChild(f),l.appendChild(d),this._tab==="highlighted"){let p=document.createElement("td"),m=document.createElement("span");m.className="sb-chip";let g=a[c.group];g&&(m.style.backgroundColor=`rgb(${g[0]}, ${g[1]}, ${g[2]})`),p.appendChild(m),p.appendChild(document.createTextNode(` Group ${c.group+1}`)),l.appendChild(p)}let h=document.createElement("td");if(h.className="sb-actions",c.row.bbox){let p=document.createElement("button");p.className="sb-row-btn",p.title="Zoom to",p.textContent="\u2316",p.addEventListener("click",m=>{m.stopPropagation(),this._zoomToBBox(c.row.bbox)}),h.appendChild(p)}if(this._tab==="selected"){let p=document.createElement("button");p.className="sb-row-btn",p.title="De-select",p.textContent="\u2715",p.addEventListener("click",m=>{m.stopPropagation(),this._deselectRow(c)}),h.appendChild(p)}l.appendChild(h),l.addEventListener("click",()=>this._inspectRow(c,!1)),l.addEventListener("dblclick",()=>this._inspectRow(c,!0)),c.row.bbox&&(l.addEventListener("mouseenter",()=>{this._app.animateSelection&&this._app.animateSelection(c.row.bbox,{repeats:0})}),l.addEventListener("mouseleave",()=>{this._app.stopSelectionAnimation&&this._app.stopSelectionAnimation()})),o.appendChild(l)}t.appendChild(o),this._tableWrap.appendChild(t),ws(t)}};var dM="options-dialog",fM=[{label:"System default",value:""},{label:"Sans-serif",value:"sans-serif"},{label:"Serif",value:"serif"},{label:"Monospace",value:"monospace"},{label:"Helvetica / Arial",value:"Helvetica, Arial, sans-serif"},{label:"Georgia",value:"Georgia, 'Times New Roman', serif"},{label:"Courier",value:"'Courier New', Courier, monospace"}],kW=100,jh=70,Hh=200;function jl(n){let e=n===""||n===null?NaN:Math.round(Number(n));return Number.isFinite(e)?Math.min(Hh,Math.max(jh,e)):kW}function hM(n){let{overlay:e,close:t,okBtn:i,showError:r}=Xo("Arrow keys scroll step",` +Slack: [${t.lower.toFixed(h)}, ${t.upper.toFixed(h)}) ${d}`}this._tooltip.style.display="block";let s=this.element.getBoundingClientRect(),o=this._tooltip.getBoundingClientRect(),a=4,c=e.clientX-s.left,l=e.clientY-s.top,u=c+12;u+o.width>s.width-a&&(u=c-12-o.width),u=Math.max(a,u);let f=l-10;f=Math.min(s.height-o.height-a,Math.max(a,f)),this._tooltip.style.left=u+"px",this._tooltip.style.top=f+"px"}else this._tooltip.style.display="none"}async _handleClick(e){if(this._activeDebugChart>=0||this._currentTab==="fanout"||this._currentTab==="netlength")return;let t=this._hitTestBar(e);if(!(!t||t.count===0))try{let i=await this._app.websocketManager.request({type:"timing_report",is_setup:this._currentTab==="setup",max_paths:50,slack_min:t.lower,slack_max:t.upper});this._app.timingWidget&&(this._app.timingWidget.showPaths(this._currentTab,i.paths||[]),this._app.focusComponent&&this._app.focusComponent("TimingWidget"))}catch(i){console.error("Charts bar click error:",i)}}async _handleDblClick(e){if(this._activeDebugChart>=0)return;let t;if(this._currentTab==="fanout")t="select_fanout_bin";else if(this._currentTab==="netlength")t="select_net_length_bin";else return;let i=this._hitTestBar(e);if(!i||i.count===0)return;let r=Pt(this._app);try{let s=await this._app.websocketManager.request({type:t,lower:i.lower,upper:i.upper,use_dbu:this._app.showDbu});if(!Ft(this._app,r))return;s&&s.truncated&&console.warn(`Bin has ${s.count} nets; selection capped at ${s.selection_limit} for performance.`),this._app.updateInspector&&this._app.updateInspector(s),this._app.focusComponent&&this._app.focusComponent("Inspector"),this._redrawAllLayers&&this._redrawAllLayers()}catch(s){console.error("Net bin select failed:",s)}}_activeChartData(){return this._activeDebugChart>=0?{kind:"generic",data:this._debugCharts[this._activeDebugChart]}:{kind:"histogram",data:this._histogramData}}_chartBaseName(){return this._activeDebugChart>=0?this._debugCharts[this._activeDebugChart].name||"chart":this._currentTab}_triggerDownload(e,t,{revoke:i=!1}={}){let r=document.createElement("a");r.href=t,r.download=e,document.body.appendChild(r),r.click(),r.remove(),i&&URL.revokeObjectURL(t)}_download(e,t,i){try{let r=URL.createObjectURL(new Blob([i],{type:t}));this._triggerDownload(e,r,{revoke:!0})}catch(r){console.error("Download failed:",r)}}_exportCsv(){let{kind:e,data:t}=this._activeChartData();if(!t)return;let i=wW(e,t);this._download(this._chartBaseName()+".csv","text/csv",i)}_exportPng(){try{let e=this._canvas.toDataURL("image/png");this._triggerDownload(this._chartBaseName()+".png",e)}catch(e){console.error("PNG export failed:",e)}}setDebugCharts(e){this._debugCharts=e,e.length===0?this._activeDebugChart=-1:this._activeDebugChart>=e.length&&(this._activeDebugChart=0),this._rebuildSelect(),this._syncView()}_syncView(){let e=this._activeDebugChart>=0;e&&(this._hoveredBar=null,this._tooltip.style.display="none");let t=!e&&(this._currentTab==="setup"||this._currentTab==="hold");this._filterRow&&(this._filterRow.style.display=t?"":"none"),this._sizeCanvas(),e?this._renderLineChart(this._debugCharts[this._activeDebugChart]):(this._computeLayout(),this._render())}_renderLineChart(e){let t=this._canvas.getBoundingClientRect(),i=t.width,r=t.height,s=this._ctx,o=Cs();s.clearRect(0,0,i,r),s.fillStyle=o.canvasBg,s.fillRect(0,0,i,r);let a=e.points;if(!a||a.length===0){s.fillStyle=o.canvasText,s.font="14px "+o.fontSans,s.textAlign="center",s.textBaseline="middle",s.fillText("No data points yet",i/2,r/2);return}let c=e.y_labels?e.y_labels.length:1,l=aM,u=i-cM,f=lM,d=r-uM,h=u-l,p=d-f;if(h<=0||p<=0)return;let m=a[0].x,g=a[0].x,v=1/0,y=-1/0;for(let T of a){T.xg&&(g=T.x);for(let R of T.ys)Ry&&(y=R)}m===g&&(g=m+1),(!isFinite(v)||!isFinite(y))&&(v=0,y=1);let b=(y-v)*.05||1;v-=b,y+=b;let x=T=>l+(T-m)/(g-m)*h,E=T=>d-(T-v)/(y-v)*p;s.strokeStyle=o.canvasAxis,s.lineWidth=1,s.beginPath(),s.moveTo(l,f),s.lineTo(l,d),s.lineTo(u,d),s.stroke(),s.fillStyle=o.canvasLabel,s.font="10px "+o.fontMono,s.textAlign="right",s.textBaseline="middle";let w=5;for(let T=0;T<=w;T++){let R=v+(y-v)*T/w,F=E(R);s.fillText(this._formatNum(R),l-4,F),T>0&&T1&&e.y_labels){s.font="10px "+o.fontMono,s.textAlign="left",s.textBaseline="top";let T=l+8,R=f+4;for(let F=0;F=1e6?(e/1e6).toFixed(1)+"M":t>=1e3?(e/1e3).toFixed(1)+"k":t>=1?e.toFixed(1):e.toPrecision(3)}_formatCount(e){return e===0?"0":e>=1e6?e/1e6+"M":e>=1e3?e/1e3+"k":String(e)}};var Cn=class{constructor(e){this.onChange=e,this.roots=[],this._nodeMap=new Map}addFromSpec(e,t=null){let i=this._makeNode(e.id,t,e);if(i.checked=e.checked!==!1,e.children){for(let r of e.children)i.children.push(this.addFromSpec(r,i));i.hasCheckbox&&this._computeParent(i)}return t||this.roots.push(i),i}buildFromNodes(e){this._nodeMap.clear(),this.roots=[];for(let t of e)this._makeNode(t.id,null,t);for(let t of e){let i=this._nodeMap.get(t.id);if(t.parentId!=null&&this._nodeMap.has(t.parentId)){let r=this._nodeMap.get(t.parentId);i.parent=r,r.children.push(i)}else this.roots.push(i)}for(let t=e.length-1;t>=0;t--){let i=this._nodeMap.get(e[t].id);i.hasCheckbox&&i.children.length>0&&this._computeParent(i)}return this.roots}get(e){return this._nodeMap.get(e)}isVisible(e){let t=this.get(e);return t?t.checked:!1}check(e,t){let i=this._nodeMap.get(e);if(i){i.checked=t,i.indeterminate=!1;for(let r of i.children)this._setSubtree(r,t);for(let r=i.parent;r;r=r.parent)r.hasCheckbox&&this._computeParent(r);this.onChange()}}cascadeQuiet(e,t){let i=this._nodeMap.get(e);if(i){i.checked=t,i.indeterminate=!1;for(let r of i.children)this._setSubtree(r,t);for(let r=i.parent;r;r=r.parent)r.hasCheckbox&&this._computeParent(r)}}checkSet(e){for(let[t,i]of Object.entries(e)){let r=this._nodeMap.get(t);r&&(r.checked=i,r.indeterminate=!1)}this._recomputeAllParents(),this.onChange()}mirrorStates(e){this._applyMirror(e),this.onChange()}mirrorStatesQuiet(e){this._applyMirror(e)}_applyMirror(e){for(let[t,i]of Object.entries(e)){let r=this._nodeMap.get(t);r&&(r.checked=!!i.checked,r.indeterminate=!!i.indeterminate)}}forEach(e){let t=i=>{e(i);for(let r of i.children)t(r)};for(let i of this.roots)t(i)}_makeNode(e,t,i){let r={id:e,parent:t,children:[],hasCheckbox:i.hasCheckbox!==!1,checked:i.checked!==!1,indeterminate:!1,data:i.data!=null?i.data:i};return this._nodeMap.set(e,r),r}_checkboxDescendants(e){let t=[];for(let i of e.children)i.hasCheckbox?t.push(i):t.push(...this._checkboxDescendants(i));return t}_computeParent(e){let t=this._checkboxDescendants(e);if(t.length===0)return;let i=t.every(s=>s.checked&&!s.indeterminate),r=t.every(s=>!s.checked&&!s.indeterminate);e.checked=i,e.indeterminate=!i&&!r}_setSubtree(e,t){e.hasCheckbox&&(e.checked=t,e.indeterminate=!1);for(let i of e.children)this._setSubtree(i,t)}_recomputeAllParents(){let e=t=>{for(let i of t.children)e(i);t.hasCheckbox&&t.children.length>0&&this._computeParent(t)};for(let t of this.roots)e(t)}};var fM=["Instance","Module","Instances","Macros","Modules","Area","Local Inst","Local Macros","Local Modules"],dr={MODULE:0,LEAF_GROUP:1,TYPE_GROUP:2,INSTANCE:3,NAME_GROUP:4};function Ls(n){return n===dr.MODULE||n===dr.NAME_GROUP}var Vh=class{constructor(e,t,i){this._app=t,this._redrawAllLayers=i,this._nodes=[],this._nameGrouped=!1,this._nameGroupsCapped=!1,this._rows=[],this._childrenMap=new Map,this._collapsed=new Set,this._moduleState=new Map,this._checkModel=null,this._build(e),t.hierarchyBrowser=this,fe(t)&&this.update()}_build(e){let t=document.createElement("div");t.className="hierarchy-widget";let i=document.createElement("div");i.className="timing-toolbar",this._updateBtn=document.createElement("button"),this._updateBtn.className="or-btn",this._updateBtn.textContent="Update",fe(this._app)&&(this._updateBtn.style.display="none"),this._statusLabel=document.createElement("span"),this._statusLabel.className="timing-path-count",i.appendChild(this._updateBtn),i.appendChild(this._statusLabel),t.appendChild(i),this._tableContainer=document.createElement("div"),this._tableContainer.className="hierarchy-table-container",this._table=document.createElement("table"),this._table.className="timing-table",this._tableContainer.appendChild(this._table),t.appendChild(this._tableContainer),e.element.appendChild(t),this._bindEvents()}_bindEvents(){this._updateBtn.addEventListener("click",()=>this.update())}async update(){this._updateBtn.disabled=!0,this._updateBtn.textContent="Loading...",this._statusLabel.textContent="";try{let e=await this._app.websocketManager.request({type:"module_hierarchy"});this._nodes=e.nodes||[],this._nameGrouped=!!e.name_grouped,this._nameGroupsCapped=!!e.name_groups_capped,this._buildTree(),this._readServerColors(),this._computeEffectiveColors(),this._render(),this._statusLabel.textContent=this._statusText(),await this._sendModuleColors()}catch(e){this._statusLabel.textContent="Error: "+e.message}this._updateBtn.disabled=!1,this._updateBtn.textContent="Update"}_statusText(){let e=this._nodes.filter(r=>Ls(r.node_kind||0)).length;if(!this._nameGrouped)return e+" modules";let i=Math.max(0,e-1)+" groups from instance names \u2014 this design has no module hierarchy";return this._nameGroupsCapped&&(i+=" (truncated: too many groups)"),i}_buildTree(){this._childrenMap.clear(),this._collapsed.clear();for(let t of this._nodes)this._childrenMap.set(t.id,[]);for(let t of this._nodes)t.parent_id>=0&&this._childrenMap.has(t.parent_id)&&this._childrenMap.get(t.parent_id).push(t.id);this._nodeMap=new Map;for(let t of this._nodes)this._nodeMap.set(t.id,t);for(let t of this._nodes){let i=this._childrenMap.get(t.id);if(!i||i.length===0)continue;let r=t.node_kind||0;r===dr.LEAF_GROUP||r===dr.TYPE_GROUP?this._collapsed.add(t.id):Ls(r)&&t.parent_id>=0&&this._collapsed.add(t.id)}this._rows=[];let e=this._nodes.filter(t=>t.parent_id<0);for(let t of e)this._dfs(t.id,0);this._checkModel=new Cn(()=>{this._checkModel.forEach(t=>{if(!t.hasCheckbox)return;let i=this._moduleState.get(t.data.odb_id);i&&(i.visible=t.checked)}),this._sendModuleColors()}),this._checkModel.buildFromNodes(this._nodes.map(t=>({id:t.id,parentId:t.parent_id,hasCheckbox:Ls(t.node_kind||0)&&t.odb_id!=null,checked:!0,data:t})))}_readServerColors(){this._moduleState.clear();for(let e of this._rows){let t=this._nodeMap.get(e.id);if(!t||!Ls(t.node_kind||0)||t.odb_id==null)continue;let i=t.color||[128,128,128];this._moduleState.set(t.odb_id,{color:i,effectiveColor:i,visible:!0,nodeId:t.id})}}_computeEffectiveColors(){for(let e of this._rows){let t=this._nodeMap.get(e.id);if(!t||!Ls(t.node_kind||0))continue;let i=this._moduleState.get(t.odb_id);if(!i)continue;let r=t.parent_id,s=null;for(;r>=0;){let o=this._nodeMap.get(r);if(!o)break;if(Ls(o.node_kind||0)){let a=this._moduleState.get(o.odb_id);a&&this._collapsed.has(o.id)&&(s=a.effectiveColor)}r=o.parent_id}i.effectiveColor=s||i.color}}async _sendModuleColors(){let e=[];for(let[i,r]of this._moduleState){if(!r.visible)continue;let[s,o,a]=r.effectiveColor;e.push(`${i}:${s},${o},${a},100`)}let t=e.join(";");try{let i=await this._app.websocketManager.request({type:"set_module_colors",colors:t});console.log("set_module_colors:",i.count,"modules,",e.length,"sent")}catch(i){console.error("set_module_colors failed:",i)}this._redrawAllLayers()}_dfs(e,t){this._rows.push({id:e,depth:t});let i=this._childrenMap.get(e)||[];for(let r of i)this._dfs(r,t+1)}_render(){this._table.innerHTML="";let e=document.createElement("thead"),t=document.createElement("tr");for(let r of fM){let s=document.createElement("th");s.textContent=r,t.appendChild(s)}e.appendChild(t),this._table.appendChild(e);let i=document.createElement("tbody");for(let r of this._rows){let s=this._nodeMap.get(r.id);if(!s||this._isHidden(s))continue;let o=document.createElement("tr"),a=s.node_kind||0,l=(this._childrenMap.get(r.id)||[]).length>0,u=this._collapsed.has(r.id);a===dr.LEAF_GROUP||a===dr.TYPE_GROUP?(o.style.fontStyle="italic",o.style.color="var(--fg-disabled)"):a===dr.INSTANCE?o.style.color="var(--fg-secondary)":a===dr.NAME_GROUP&&(o.classList.add("hierarchy-name-group"),o.title="Recovered from instance names \u2014 this design has no module hierarchy");let f=document.createElement("td");if(f.style.paddingLeft=8+r.depth*16+"px",f.style.whiteSpace="nowrap",Ls(a)&&s.odb_id!=null){let p=this._moduleState.get(s.odb_id),m=this._checkModel?this._checkModel.get(s.id):null;if(p&&m){let g=document.createElement("input");g.type="checkbox",g.checked=m.checked,g.indeterminate=m.indeterminate,g.className="hierarchy-module-cb",m.cb=g,g.addEventListener("change",E=>{E.stopPropagation(),this._checkModel.check(s.id,g.checked),this._render()}),f.appendChild(g);let v=document.createElement("span");v.className="hierarchy-color-swatch";let[y,b,x]=p.effectiveColor;v.style.backgroundColor=`rgb(${y},${b},${x})`,f.appendChild(v)}}if(l){let p=document.createElement("span");p.className="hierarchy-arrow",p.textContent=u?"\u25B6":"\u25BC",p.addEventListener("click",m=>{m.stopPropagation(),this._toggleNode(r.id)}),f.appendChild(p)}else{let p=document.createElement("span");p.className="hierarchy-arrow",p.style.visibility="hidden",p.textContent="\u25B6",f.appendChild(p)}let d=document.createElement("span");d.textContent=s.inst_name,f.appendChild(d),o.appendChild(f);let h=[s.module_name,Ko(s.insts),Ko(s.macros),Ko(s.modules),this._fmtArea(s.area),Ko(s.local_insts),Ko(s.local_macros),Ko(s.local_modules)];for(let p of h){let m=document.createElement("td");m.textContent=p,m.style.textAlign="right",o.appendChild(m)}o.children[1].style.textAlign="left",i.appendChild(o)}if(this._rows.length===0){let r=document.createElement("tr"),s=document.createElement("td");s.colSpan=fM.length,s.style.textAlign="center",s.style.color="var(--fg-secondary)",s.textContent=fe(this._app)?"No hierarchy data available":'Click "Update" to load hierarchy',r.appendChild(s),i.appendChild(r)}this._table.appendChild(i),ws(this._table)}_isHidden(e){let t=e.parent_id;for(;t>=0;){if(this._collapsed.has(t))return!0;let i=this._nodeMap.get(t);if(!i)break;t=i.parent_id}return!1}_toggleNode(e){this._collapsed.has(e)?this._collapsed.delete(e):this._collapsed.add(e),this._computeEffectiveColors(),this._render(),this._sendModuleColors()}_fmtArea(e){if(e==null)return"";if(this._app.showDbu){let t=this._app.getDbuPerMicron();return String(Math.round(e*t*t))}return e>=1e6?(e/1e6).toFixed(3)+" mm\xB2":e.toFixed(3)+" \u03BCm\xB2"}};function Ko(n){return n!=null?String(n):""}var EW='',SW='',PW='',CW='',TW='',LW='',MW='',AW='',kW='',RW='',IW='',BW='';function dM(n,e,t){t=t||e;let i=null,r=null,s=null,o=!1,a=10;function c(M,S){return o?Promise.resolve():(o=!0,n.websocketManager.request({type:"set_property",name:M,use_dbu:n.showDbu,...S}).then(L=>{!L.ok&&L.error&&on(L.error),Re(L),L.ok&&L.bbox&&Ve(L.bbox)}).catch(L=>{console.error("set_property failed:",L),on("Edit failed: "+L),i&&Re(i)}).finally(()=>{o=!1}))}function l(M,S){let L=document.createElement("select");L.className="inspector-editor-select";let D=M.editor.type==="bool"?["True","False"]:M.editor.options||[];for(let A of D){let z=document.createElement("option");z.value=A,z.textContent=A,A===M.value&&(z.selected=!0),L.appendChild(z)}if(!D.includes(M.value)){let A=document.createElement("option");A.value=M.value||"",A.textContent=M.value||"",A.selected=!0,A.disabled=!0,L.insertBefore(A,L.firstChild)}return L.addEventListener("change",()=>{if(S.onPropertyChange){S.onPropertyChange(M.name,L.value);return}if(M.editor.type==="bool")S.onPropertyEdit(M,{value:L.value==="True"});else{let A=(M.editor.options||[]).indexOf(L.value);S.onPropertyEdit(M,{option_index:A,option_name:L.value})}}),L}async function u(M,S){if(!o&&!(M==="Delete"&&!await O3({title:"Delete "+(S.type||"object"),message:"Delete "+(S.type||"object")+' "'+(S.name||"")+'"? This cannot be undone.',confirmLabel:"Delete",danger:!0}))){o=!0;try{let L=await n.websocketManager.request({type:"trigger_action",name:M,use_dbu:n.showDbu});!L.ok&&L.error&&on(L.error),Re(L.properties?L:null),L.deleted&&cn(),se(),t()}catch(L){console.error("trigger_action failed:",L),on("Action failed: "+L)}finally{o=!1}}}function f(M){n.websocketManager.request({...M,use_dbu:n.showDbu}).then(S=>{!S.ok&&S.error&&on(S.error),Re(S),t()}).catch(S=>{console.error(M.type+" failed:",S)})}function d(){let M=document.getElementById("highlight-picker");M&&M.remove()}function h(M,S){d();let L=n.techData?.highlight_colors||[];if(!L.length)return;let D=document.createElement("div");D.id="highlight-picker";let A=document.createElement("div");if(A.className="highlight-swatch-grid",L.forEach((B,U)=>{let Z=document.createElement("button");Z.className="highlight-swatch",Z.title="Group "+(U+1),Z.style.backgroundColor=`rgb(${B[0]}, ${B[1]}, ${B[2]})`,U===S.highlight_group&&Z.classList.add("active"),Z.addEventListener("click",()=>{d(),f({type:"highlight",group:U})}),A.appendChild(Z)}),D.appendChild(A),S.highlight_group>=0){let B=document.createElement("button");B.className="highlight-remove",B.textContent="Remove highlight",B.addEventListener("click",()=>{d(),f({type:"unhighlight"})}),D.appendChild(B)}document.body.appendChild(D);let z=M.getBoundingClientRect();D.style.left=z.left+"px",D.style.top=z.bottom+4+"px";let I=B=>{B.type==="keydown"&&B.key!=="Escape"||B.type==="mousedown"&&D.contains(B.target)||(d(),document.removeEventListener("mousedown",I,!0),document.removeEventListener("keydown",I,!0))};setTimeout(()=>{document.addEventListener("mousedown",I,!0),document.addEventListener("keydown",I,!0)},0)}function p(){if(!n.inspectorEl)return;n.inspectorEl.innerHTML="";let M=document.createElement("div");M.className="stub-panel",M.innerHTML='
Loading\u2026
Fetching properties from server.
',n.inspectorEl.appendChild(M)}async function m(M){let S=n.focusNets.has(M)?"remove":"add";S==="add"?n.focusNets.add(M):n.focusNets.delete(M);try{await n.websocketManager.request({type:"set_focus_nets",action:S,net_name:M})}catch(L){console.error("set_focus_nets failed:",L)}e(),i&&Re(i)}async function g(){n.focusNets.clear();try{await n.websocketManager.request({type:"set_focus_nets",action:"clear",net_name:""})}catch(M){console.error("set_focus_nets clear failed:",M)}e(),i&&Re(i)}async function v(M){let S=n.routeGuideNets.has(M)?"remove":"add";S==="add"?n.routeGuideNets.add(M):n.routeGuideNets.delete(M);try{await n.websocketManager.request({type:"set_route_guides",action:S,net_name:M})}catch(L){console.error("set_route_guides failed:",L)}t(),i&&Re(i)}function y(M,S,L,D){return Nt(M,S,L,D,n.designScale,n.designOriginX,n.designOriginY)}function b(M,S,L){return M+(S-M)*L}function x(M,S,L){return M.map((D,A)=>Math.round(b(D,S[A],L)))}function E(M,S){let L=0;for(;LM[L+1].at;)L++;let D=M[L],A=M[L+1],z=Math.max(0,Math.min(1,(S-D.at)/(A.at-D.at))),I={};for(let B of Object.keys(D))B!=="at"&&(I[B]=Array.isArray(D[B])?x(D[B],A[B],z):b(D[B],A[B],z));return I}function w(M,S,L,D){if(Vl()||typeof requestAnimationFrame!="function")return D(),()=>{};let A=performance.now(),z=!1,I=()=>{if(z)return;let B=performance.now()-A;if(B>=M*S){D();return}L(B%M/M),requestAnimationFrame(I)};return I(),()=>{z=!0}}function T(M,S,L=ot.highlight){n.view&&n.view.setOverlay(M,S,{order:L})}let R=null,F=()=>{},O=[255,242,122],j=[{at:0,stroke:[255,246,176],width:7,alpha:1,fill:.28},{at:.55,stroke:[255,255,255],width:5,alpha:1,fill:.06},{at:1,stroke:[255,232,92],width:3,alpha:.95,fill:.14}],V={stroke:[255,232,92],width:3,alpha:1,fill:.14};function G(M,S,L,D){let[A,z,I,B]=y(M,S,L,D),U=a/2**n.view.getZoom(),Z=Math.max(0,(U-(I-A))/2),Q=Math.max(0,(U-(B-z))/2);return[A-Z,z-Q,I+Z,B+Q]}function q(M){R&&T("hover",R.map(([S,L,D,A])=>({kind:"rect",rect:G(S,L,D,A),stroke:zt(M.stroke,M.alpha),width:M.width,fill:zt(O,M.fill)})))}function X(){q(V)}function se(){F(),R=null,T("hover",null),n.view?.off("zoom",X)}function le(){se(),n.websocketManager.request({type:"hover",select_id:-1}).then(()=>{}).catch(()=>{})}function he(M){se(),!(!n.view||!n.designScale||!M||M.length===0)&&(R=M,n.view.on("zoom",X),F=w(900,3,S=>q(E(j,1-Math.pow(1-S,2))),()=>q(V)))}function at(M,S){M.classList.add("inspector-link"),M.addEventListener("click",L=>{L.stopPropagation(),Tn(S)}),M.addEventListener("mouseenter",()=>{s!==null&&(n.websocketManager.cancel(s),s=null);let L=n.websocketManager.request({type:"hover",select_id:S});s=L.requestId,L.then(D=>{s=null,he(D.rects||[]),t()}).catch(()=>{s=null})}),M.addEventListener("mouseleave",()=>{le(),t()})}function Ct(M){let S=M>0?"select_next":"select_prev";r!==null&&(n.websocketManager.cancel(r),r=null),p();let L=Pt(n),D=n.websocketManager.request({type:S,use_dbu:n.showDbu});r=D.requestId,D.then(A=>{if(r=null,!!Ft(n,L)){if(A.error){console.error("Selection cycle error:",A.error),Re(i);return}if(Re(A),A.type==="Inst"&&A.name&&(n.selectedInstanceName=A.name,n.schematicWidget&&n.schematicWidget.refresh()),se(),cn(),A.bbox&&n.view&&n.designScale){let[z,I,B,U]=A.bbox;A.type!=="Inst"&&$t(z,I,B,U,A.type),A.selection_count>1?Mn(A.bbox):Ve(A.bbox,A.type)}e()}}).catch(A=>{r=null,console.error("Selection cycle failed:",A),Re(i)})}function Tn(M){r!==null&&(n.websocketManager.cancel(r),r=null),p();let S=Pt(n),L=n.websocketManager.request({type:"inspect",select_id:M,use_dbu:n.showDbu});r=L.requestId,L.then(D=>{if(r=null,!!Ft(n,S)){if(D.error){console.error("Inspect error:",D.error);return}if(Re(D),se(),cn(),D.bbox&&n.view&&n.designScale){let[A,z,I,B]=D.bbox;D.type!=="Inst"&&$t(A,z,I,B,D.type),Ve(D.bbox,D.type)}t()}}).catch(D=>{r=null,console.error("Inspect failed:",D)})}function Ni(){r!==null&&(n.websocketManager.cancel(r),r=null),p();let M=Pt(n),S=n.websocketManager.request({type:"inspect_back",use_dbu:n.showDbu});r=S.requestId,S.then(L=>{if(r=null,!!Ft(n,M)){if(L.error){console.error("Inspect back error:",L.error);return}if(Re(L),se(),cn(),L.bbox&&n.view&&n.designScale){if(L.type!=="Inst"){let[D,A,z,I]=L.bbox;$t(D,A,z,I,L.type)}Ve(L.bbox,L.type)}t()}}).catch(L=>{r=null,console.error("Inspect back failed:",L)})}let Ln=null;function li(){let M=Ln&&n.designScale&&!(n.visibility&&n.visibility.highlight_selected===!1);T("selection",M?[{kind:"rect",rect:y(...Ln),stroke:zt("#ff0"),width:2,dash:[6,4]}]:null,ot.selection)}function cn(){Ln=null,li()}function $t(M,S,L,D,A){Ln=A==="Net"?null:[M,S,L,D],li()}let ln=null,ui=[{at:0,alpha:0,fill:0},{at:.5,alpha:1,fill:.28},{at:1,alpha:0,fill:0}];function fi(){ln&&(ln(),ln=null),T("pulse",null)}function Ve(M,S){if(!M||!n.view||!n.designScale||(_t!==null&&di(),fi(),n.visibility&&n.visibility.highlight_selected===!1)||S==="Net")return;let L=y(...M);ln=w(350,3,D=>{let A=E(ui,.5-.5*Math.cos(Math.PI*D));T("pulse",[{kind:"rect",rect:L,stroke:zt("#ff0",A.alpha),width:3,fill:zt("#ff0",A.fill)}])},()=>{ln=null,T("pulse",null)})}let _t=null;function Gt(M,S){T("anim",[{kind:"rect",rect:M,stroke:zt("#ff0"),width:S,fill:zt("#ff0",S===1?.39:0)}])}function di(){_t!==null&&(clearInterval(_t),_t=null),T("anim",null)}function Mn(M,{repeats:S=6,intervalMs:L=300}={}){if(!M||!n.view||!n.designScale)return;if(di(),Vl()){Ve(M);return}let D=y(...M);Gt(D,1);let A=0,z=S>0?S*3:1/0;_t=setInterval(()=>{if(A+=1,A>=z){di();return}Gt(D,A%3+1)},L)}n.clearSelectionPulse=fi,n.renderSelectionOutline=li,n.clearSelectionOutline=cn;function hi(M,S,L){let D=document.createElement("div");D.className="inspector-group";let A=document.createElement("div");A.className="inspector-group-header";let z=document.createElement("span");z.className="vis-arrow";let I=document.createElement("span");if(I.className="inspector-prop-name",I.textContent=M,I.title=M,A.appendChild(z),A.appendChild(I),S!==null){let U=document.createElement("span");U.className="inspector-count",U.textContent=`(${S})`,A.appendChild(U)}D.appendChild(A);let B=document.createElement("div");return B.className="inspector-group-children"+(L?" collapsed":""),z.textContent=L?"\u25B6":"\u25BC",D.appendChild(B),A.addEventListener("click",()=>{B.classList.toggle("collapsed"),z.textContent=B.classList.contains("collapsed")?"\u25B6":"\u25BC"}),{group:D,header:A,arrow:z,body:B}}function Ke(M){let S=M.column_headers||[],L=M.row_headers||[],D=M.data||[],A=S.some(U=>U!==""),z=L.some(U=>U!==""),I=document.createElement("table");if(I.className="inspector-table",A){let U=document.createElement("thead"),Z=document.createElement("tr");z&&Z.appendChild(document.createElement("th"));for(let Q of S){let ye=document.createElement("th");ye.textContent=Q,Z.appendChild(ye)}U.appendChild(Z),I.appendChild(U)}let B=document.createElement("tbody");return D.forEach((U,Z)=>{let Q=document.createElement("tr");if(z){let ye=document.createElement("th");ye.textContent=L[Z]||"",Q.appendChild(ye)}for(let ye of U){let be=document.createElement("td");be.textContent=ye,Q.appendChild(be)}B.appendChild(Q)}),I.appendChild(B),I}function Vt(M,S){if(M.table){let I=(M.table.data||[]).length,{group:B,body:U}=hi(M.name,I,I>=10),Z=document.createElement("div");return Z.className="inspector-table-scroll",Z.appendChild(Ke(M.table)),U.appendChild(Z),B}if(M.children){let I=M.children.length<10,{group:B,body:U}=hi(M.name,M.children.length,!I);for(let Z of M.children)U.appendChild(Vt(Z,S));return B}let L=document.createElement("div");L.className="inspector-prop";let D=document.createElement("span");D.className="inspector-prop-name",D.textContent=M.name||"",D.title=M.name||"";let A=document.createElement("span");A.className="inspector-prop-value",A.textContent=M.value||"",L.appendChild(D),L.appendChild(A);let z=M.editable&&S&&(S.onPropertyEdit||S.onPropertyChange)&&M.editor&&(M.editor.type==="list"||M.editor.type==="bool");if(z&&M.value_select_id===void 0)L.replaceChild(l(M,S),A);else if(z){let I=document.createElement("button");I.className="inspector-edit-btn",I.title="Edit "+M.name,I.textContent="\u270E",I.addEventListener("click",B=>{B.stopPropagation();let U=l(M,S);L.replaceChild(U,A),I.remove(),U.focus()}),L.appendChild(I)}else M.editable&&S&&(S.onPropertyChange||S.onPropertyEdit)&&(A.contentEditable=!0,A.classList.add("inspector-editable"),A.addEventListener("blur",()=>{let I=A.textContent;if(I!==M.value){if(S.onPropertyChange){S.onPropertyChange(M.name,I);return}if(M.editor&&M.editor.type==="number"){let B=Number(I);if(I.trim()===""||Number.isNaN(B)){on("Not a number: "+I),A.textContent=M.value;return}S.onPropertyEdit(M,{value:B});return}S.onPropertyEdit(M,{value:I})}}),A.addEventListener("keydown",I=>{I.key==="Enter"&&(I.preventDefault(),A.blur()),I.key==="Escape"&&(A.textContent=M.value,A.blur())}));return M.name_select_id!==void 0&&M.value_select_id===void 0?(at(L,M.name_select_id),D.classList.add("inspector-link")):M.name_select_id!==void 0&&at(D,M.name_select_id),M.value_select_id!==void 0&&at(A,M.value_select_id),L}let un=140,An=60,Rs=500,pi=un;function yr(){n.inspectorEl&&n.inspectorEl.style.setProperty("--inspector-name-w",pi+"px")}function kn(){let M=document.createElement("div");return M.className="inspector-col-resizer",M.title="Drag to resize the name column",M.addEventListener("mousedown",S=>{S.preventDefault();let L=S.clientX,D=pi;M.classList.add("dragging");let A=I=>{pi=Math.max(An,Math.min(Rs,D+I.clientX-L)),yr()},z=()=>{M.classList.remove("dragging"),document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",z)};document.addEventListener("mousemove",A),document.addEventListener("mouseup",z)}),M}function Wt(M){!M||!n.view||!n.designScale||n.view.fitWorldRect(y(...M),{padding:[20,20]})}function Re(M){if(!n.inspectorEl)return;if(i=M,n.inspectorEl.innerHTML="",!M||!M.properties||M.properties.length===0){di();let A=document.createElement("div");A.className="stub-panel",A.innerHTML='
Inspector
Select an object in the layout to inspect its properties.
',n.inspectorEl.appendChild(A);return}if(!M.onPropertyChange&&!M.onPropertyEdit&&!fe(n)&&(M.onPropertyEdit=(A,z)=>c(A.name,z)),M){let A=document.createElement("div");A.className="inspector-toolbar";let z=document.createElement("button");if(z.className="or-btn or-btn-icon",z.title="Back",z.innerHTML=CW,z.disabled=!M.can_navigate_back,z.addEventListener("click",()=>Ni()),A.appendChild(z),M.bbox){let I=document.createElement("button");I.className="or-btn or-btn-icon",I.title="Zoom to",I.innerHTML=PW,I.addEventListener("click",()=>Wt(M.bbox)),A.appendChild(I)}if(M.type==="Net"&&M.name){let I=n.focusNets.has(M.name),B=document.createElement("button");B.className="or-btn or-btn-icon",B.title=I?"De-focus net":"Focus net",B.innerHTML=I?LW:TW,B.addEventListener("click",()=>m(M.name)),A.appendChild(B)}if(M.type==="Net"&&M.name&&M.has_guides){let I=n.routeGuideNets.has(M.name),B=document.createElement("button");B.className="or-btn or-btn-icon",B.title=I?"Hide route guides":"Show route guides",B.innerHTML=I?AW:MW,B.addEventListener("click",()=>v(M.name)),A.appendChild(B)}if(M.type==="Net"&&M.name&&n.showInsertBufferDialog){let I=document.createElement("button");I.className="or-btn or-btn-icon",I.title="Insert buffer",I.innerHTML=BW,I.addEventListener("click",()=>n.showInsertBufferDialog(M.name)),A.appendChild(I)}if(n.focusNets.size>0){let I=document.createElement("button");I.className="or-btn or-btn-icon",I.title="Clear focus nets",I.innerHTML=kW,I.addEventListener("click",()=>g()),A.appendChild(I)}if(typeof M.highlight_group=="number"&&!fe(n)&&(n.techData?.highlight_colors||[]).length){let I=document.createElement("button");I.className="or-btn or-btn-icon inspector-highlight-btn";let B=M.highlight_group;if(I.title=B>=0?"Highlight group "+(B+1):"Add to highlight group",I.innerHTML=SW,B>=0){let U=n.techData.highlight_colors[B];I.style.backgroundColor=`rgba(${U[0]}, ${U[1]}, ${U[2]}, 0.45)`,I.style.borderColor=`rgb(${U[0]}, ${U[1]}, ${U[2]})`}I.addEventListener("click",()=>h(I,M)),A.appendChild(I)}if(Array.isArray(M.actions)&&!fe(n))for(let I of M.actions){let B=document.createElement("button");B.className="or-btn inspector-action-btn",B.title=I,I==="Delete"?(B.classList.add("or-btn-icon","or-btn-danger-hover"),B.innerHTML=EW):(B.classList.add("or-btn-sm"),B.textContent=I),B.addEventListener("click",()=>u(I,M)),A.appendChild(B)}n.inspectorEl.appendChild(A)}let S=M.selection_count||0,L=typeof M.selection_index=="number"?M.selection_index:-1;if(S>1&&L>=0){let A=document.createElement("div");A.className="inspector-selection-nav";let z=document.createElement("button");z.className="or-btn or-btn-icon",z.title="Previous (Shift+click to multi-select)",z.innerHTML=RW,z.addEventListener("click",()=>Ct(-1));let I=document.createElement("span");I.className="inspector-selection-label",I.textContent=L+1+" / "+S;let B=document.createElement("button");B.className="or-btn or-btn-icon",B.title="Next",B.innerHTML=IW,B.addEventListener("click",()=>Ct(1)),A.appendChild(z),A.appendChild(I),A.appendChild(B),n.inspectorEl.appendChild(A)}let D=document.createElement("div");D.className="inspector-rows";for(let A of M.properties)D.appendChild(Vt(A,M));D.appendChild(kn()),n.inspectorEl.appendChild(D),yr()}function na(M){let S=document.createElement("div");S.className="inspector",n.inspectorEl=S,M.element.appendChild(S),Re(null)}function Ce(){if(i){if(i.type==="Ruler"){n.rulerManager&&n.rulerManager._selectedRulerId!==null&&n.rulerManager._selectRuler(n.rulerManager._selectedRulerId);return}n.websocketManager&&Tn(-1)}}return{createInspector:na,updateInspector:Re,highlightBBox:$t,pulseHighlight:Ve,animateSelection:Mn,stopSelectionAnimation:di,navigateInspector:Tn,refreshInspector:Ce}}var Wh=class{constructor(e,t,i){this._app=t,this._refreshOverlay=i||(()=>{}),this._data={selection:[],groups:[],truncated:!1},this._tab="selected",this._filter="",this._sortKey=null,this._sortAsc=!0,this._pendingRefresh=null,this._inFlight=!1,this._staleWhileInFlight=!1,this._visible=!0,this._el=document.createElement("div"),this._el.className="selection-browser",e.element.appendChild(this._el),e.on?.("show",()=>{this._visible=!0,this.refresh()}),e.on?.("hide",()=>{this._visible=!1}),e.on?.("destroy",()=>{this._visible=!1,this._staleWhileInFlight=!1,this._pendingRefresh!==null&&(clearTimeout(this._pendingRefresh),this._pendingRefresh=null)}),this._render(),this.refresh()}scheduleRefresh(){!this._visible||this._pendingRefresh!==null||(this._pendingRefresh=setTimeout(()=>{this._pendingRefresh=null,this.refresh()},150))}refresh(){if(!this._visible||fe(this._app))return;if(this._inFlight){this._staleWhileInFlight=!0;return}this._inFlight=!0;let e=()=>{this._inFlight=!1,this._staleWhileInFlight&&(this._staleWhileInFlight=!1,this.refresh())};this._app.websocketManager.request({type:"list_selection"}).then(t=>{t.ok&&(this._data=t,this._render()),e()}).catch(e)}_entries(){let e;this._tab==="selected"?e=(this._data.selection||[]).map((i,r)=>({row:i,index:r,group:-1})):e=(this._data.groups||[]).flatMap((i,r)=>i.map((s,o)=>({row:s,index:o,group:r})));let t=this._filter.trim().toLowerCase();if(t&&(e=e.filter(({row:i})=>(i.name||"").toLowerCase().includes(t)||(i.type||"").toLowerCase().includes(t))),this._sortKey){let i=this._sortKey,r=this._sortAsc?1:-1;e=e.slice().sort((s,o)=>r*String(s.row[i]||"").localeCompare(String(o.row[i]||"")))}return e}_fmtCoord(e){if(this._app.showDbu)return String(e);let t=this._app.getDbuPerMicron?this._app.getDbuPerMicron():1e3;return(e/t).toFixed(3)}_fmtBounds(e){if(!e)return"";let[t,i,r,s]=e;return`(${this._fmtCoord(t)}, ${this._fmtCoord(i)}), (${this._fmtCoord(r)}, ${this._fmtCoord(s)})`}_inspectRow(e,t){let i=e.group<0?{type:"inspect_selection",index:e.index,use_dbu:this._app.showDbu}:{type:"inspect_group",group:e.group,index:e.index,use_dbu:this._app.showDbu};this._app.websocketManager.request(i).then(r=>{if(!r.ok){this.refresh();return}this._app.updateInspector&&this._app.updateInspector(r),t&&this._app.focusComponent&&this._app.focusComponent("Inspector"),this._refreshOverlay()}).catch(()=>{})}_deselectRow(e){this._app.websocketManager.request({type:"deselect",index:e.index}).then(()=>{this.refresh(),this._refreshOverlay()}).catch(()=>{})}_clearHighlights(){this._app.websocketManager.request({type:"clear_highlights",group:-1}).then(()=>{this.refresh(),this._refreshOverlay(),this._app.refreshInspector&&this._app.refreshInspector()}).catch(()=>{})}_zoomToBBox(e){if(!e||!this._app.designScale||!this._app.view)return;let[t,i,r,s]=e,o=this._app.getDbuPerMicron?this._app.getDbuPerMicron():1e3,a=Math.min(10*o,2*Math.max(r-t,s-i));this._app.view.fitWorldRect(Nt(t-a,i-a,r+a,s+a,this._app.designScale,this._app.designOriginX,this._app.designOriginY))}_render(){this._app.stopSelectionAnimation&&this._app.stopSelectionAnimation(),this._el.innerHTML="";let e=(this._data.selection||[]).length,t=(this._data.groups||[]).reduce((o,a)=>o+a.length,0),i=document.createElement("div");i.className="sb-tabs";for(let[o,a,c]of[["selected","Selected",e],["highlighted","Highlighted",t]]){let l=document.createElement("button");l.className="sb-tab"+(this._tab===o?" active":""),l.textContent=`${a} (${c})`,l.addEventListener("click",()=>{this._tab=o,this._render()}),i.appendChild(l)}let r=document.createElement("button");if(r.className="or-btn or-btn-sm sb-tool",r.title="Refresh",r.textContent="\u27F3",r.addEventListener("click",()=>this.refresh()),i.appendChild(r),this._tab==="highlighted"&&t>0){let o=document.createElement("button");o.className="or-btn or-btn-sm sb-tool",o.title="Clear all highlights",o.textContent="Clear",o.addEventListener("click",()=>this._clearHighlights()),i.appendChild(o)}this._el.appendChild(i);let s=document.createElement("input");if(s.type="text",s.className="sb-filter",s.placeholder="Filter by name or type\u2026",s.value=this._filter,s.addEventListener("input",()=>{this._filter=s.value,this._renderTable()}),this._el.appendChild(s),this._data.truncated){let o=document.createElement("div");o.className="sb-truncated",o.textContent="List truncated \u2014 showing the first 1000 entries per set.",this._el.appendChild(o)}this._tableWrap=document.createElement("div"),this._tableWrap.className="sb-table-wrap",this._el.appendChild(this._tableWrap),this._renderTable()}_renderTable(){this._tableWrap.innerHTML="";let e=this._entries();if(!e.length){let c=document.createElement("div");c.className="sb-empty",c.textContent=this._tab==="selected"?"Nothing selected.":"Nothing highlighted.",this._tableWrap.appendChild(c);return}let t=document.createElement("table");t.className="sb-table";let i=document.createElement("thead"),r=document.createElement("tr"),s=[["name","Object"],["type","Type"],[null,"Bounds"]];this._tab==="highlighted"&&s.push([null,"Group"]),s.push([null,""]);for(let[c,l]of s){let u=document.createElement("th");u.textContent=l,c&&(u.classList.add("sb-sortable"),this._sortKey===c&&(u.textContent+=this._sortAsc?" \u25B2":" \u25BC"),u.addEventListener("click",()=>{this._sortKey===c?this._sortAsc=!this._sortAsc:(this._sortKey=c,this._sortAsc=!0),this._renderTable()})),r.appendChild(u)}i.appendChild(r),t.appendChild(i);let o=document.createElement("tbody"),a=this._app.techData?.highlight_colors||[];for(let c of e){let l=document.createElement("tr");l.className="sb-row";let u=document.createElement("td");u.textContent=c.row.name||"";let f=document.createElement("td");f.textContent=c.row.type||"";let d=document.createElement("td");if(d.textContent=this._fmtBounds(c.row.bbox),l.appendChild(u),l.appendChild(f),l.appendChild(d),this._tab==="highlighted"){let p=document.createElement("td"),m=document.createElement("span");m.className="sb-chip";let g=a[c.group];g&&(m.style.backgroundColor=`rgb(${g[0]}, ${g[1]}, ${g[2]})`),p.appendChild(m),p.appendChild(document.createTextNode(` Group ${c.group+1}`)),l.appendChild(p)}let h=document.createElement("td");if(h.className="sb-actions",c.row.bbox){let p=document.createElement("button");p.className="sb-row-btn",p.title="Zoom to",p.textContent="\u2316",p.addEventListener("click",m=>{m.stopPropagation(),this._zoomToBBox(c.row.bbox)}),h.appendChild(p)}if(this._tab==="selected"){let p=document.createElement("button");p.className="sb-row-btn",p.title="De-select",p.textContent="\u2715",p.addEventListener("click",m=>{m.stopPropagation(),this._deselectRow(c)}),h.appendChild(p)}l.appendChild(h),l.addEventListener("click",()=>this._inspectRow(c,!1)),l.addEventListener("dblclick",()=>this._inspectRow(c,!0)),c.row.bbox&&(l.addEventListener("mouseenter",()=>{this._app.animateSelection&&this._app.animateSelection(c.row.bbox,{repeats:0})}),l.addEventListener("mouseleave",()=>{this._app.stopSelectionAnimation&&this._app.stopSelectionAnimation()})),o.appendChild(l)}t.appendChild(o),this._tableWrap.appendChild(t),ws(t)}};var pM="options-dialog",hM=[{label:"System default",value:""},{label:"Sans-serif",value:"sans-serif"},{label:"Serif",value:"serif"},{label:"Monospace",value:"monospace"},{label:"Helvetica / Arial",value:"Helvetica, Arial, sans-serif"},{label:"Georgia",value:"Georgia, 'Times New Roman', serif"},{label:"Courier",value:"'Courier New', Courier, monospace"}],OW=100,jh=70,Hh=200;function jl(n){let e=n===""||n===null?NaN:Math.round(Number(n));return Number.isFinite(e)?Math.min(Hh,Math.max(jh,e)):OW}function mM(n){let{overlay:e,close:t,okBtn:i,showError:r}=Xo("Arrow keys scroll step",`
How far one arrow-key press pans the layout. - Default ${Qb}.
`,"Apply",dM),s=e.querySelector(".opt-step");s.focus(),s.select();function o(){let a=s.value.trim(),c=Number(a);if(a===""||!Number.isFinite(c)){r("Step must be a number.");return}if(c$l){r(`Step must be between ${Ul} and ${$l} px.`);return}n.setArrowStep(c),t()}return i.addEventListener("click",o),s.addEventListener("keydown",a=>{a.key==="Enter"&&(a.preventDefault(),o())}),{close:t}}function pM(n){let e=n.fontFamily||"",t=fM.some(p=>p.value===e),i=fM.map(p=>``).join("")+(t?"":``),{overlay:r,close:s,okBtn:o,showError:a}=Xo("Application font",` + Default ${Qb}.`,"Apply",pM),s=e.querySelector(".opt-step");s.focus(),s.select();function o(){let a=s.value.trim(),c=Number(a);if(a===""||!Number.isFinite(c)){r("Step must be a number.");return}if(c$l){r(`Step must be between ${Ul} and ${$l} px.`);return}n.setArrowStep(c),t()}return i.addEventListener("click",o),s.addEventListener("keydown",a=>{a.key==="Enter"&&(a.preventDefault(),o())}),{close:t}}function gM(n){let e=n.fontFamily||"",t=hM.some(p=>p.value===e),i=hM.map(p=>``).join("")+(t?"":``),{overlay:r,close:s,okBtn:o,showError:a}=Xo("Application font",`
@@ -6454,7 +6454,7 @@ Slack: [${t.lower.toFixed(h)}, ${t.upper.toFixed(h)}) ${d}`}this._tooltip.style. 0123456789
Applies to the panels, menus and console. Text drawn into the layout is rendered on the server and is not - affected.
`,"Apply",dM),c=r.querySelector(".opt-family"),l=r.querySelector(".opt-custom"),u=r.querySelector(".opt-scale"),f=r.querySelector(".opt-preview");function d(){f.style.fontFamily=l.value.trim()||c.value,f.style.fontSize=`calc(13px * ${jl(u.value)/100})`}for(let p of[c,l,u])p.addEventListener("input",d);d();function h(){let p=u.value.trim(),m=Number(p);if(p===""||!Number.isFinite(m)){a("Size must be a number.");return}if(mHh){a(`Size must be between ${jh} and ${Hh} %.`);return}n.setAppFont({family:l.value.trim()||c.value,scale:m}),s()}o.addEventListener("click",h);for(let p of[l,u])p.addEventListener("keydown",m=>{m.key==="Enter"&&(m.preventDefault(),h())});return{close:s}}function av(n){return String(n).replace(/&/g,"&").replace(/"/g,""").replace(//g,">")}var RW='',IW='';function Qo(n){let e=document.createElement("span");return e.className="vis-name",n!=null&&(e.textContent=n),e}function hr(){let n=document.createElement("span");return n.className="vis-sel-cb vis-sel-spacer",n}function mM(){let n=document.createElement("div");n.className="display-controls-header",n.appendChild(Qo(""));for(let[e,t]of[[RW,"Visible"],[IW,"Selectable"]]){let i=document.createElement("span");i.className="vis-header-icon",i.title=t,i.innerHTML=e,n.appendChild(i)}return n}var Yh=class{constructor(e,t,i){this.visibility=e,this.selectability=t,this.onChange=i;let r=()=>{this._syncAll(),this.onChange()};this.model=new Cn(r),this.selModel=new Cn(r)}add(e){return this.model.addFromSpec(this._enrichSpec(e,"")),this.selModel.addFromSpec(this._enrichSelSpec(e,"",!1)),this}render(e){for(let t of this.model.roots)e.appendChild(this._dom(t));this._syncAll()}_nodeId(e,t){let i=e.key||e.label;return t?t+"/"+i:i}_enrichSpec(e,t){let i=this._nodeId(e,t),r={id:i,data:e};return e.children?r.children=e.children.map(s=>this._enrichSpec(s,i)):e.key&&(r.checked=!!this.visibility[e.key]),e.disabled!=null&&(r.disabled=e.disabled),r}_enrichSelSpec(e,t,i){let r=e.addSelectable===!0?!0:e.addSelectable===!1?!1:i,s=this._nodeId(e,t),o={id:s,data:e,hasCheckbox:!1};if(e.children){o.children=e.children.map(c=>this._enrichSelSpec(c,s,r));let a=c=>c.some(l=>l.hasCheckbox||l.children&&a(l.children));o.hasCheckbox=a(o.children),o.hasCheckbox&&(o.checked=!0)}else if(e.key){let a=e.selectable===!0||e.selectable!==!1&&i;o.hasCheckbox=a,a&&(o.checked=this.selectability[e.key]!==!1)}return o}_syncAll(){this.model.forEach(e=>{e.cb&&(e.cb.checked=e.checked,e.cb.indeterminate=e.indeterminate);let t=e.data;t.key&&(this.visibility[t.key]=e.checked),t.visKey&&(this.visibility[t.visKey]=e.checked||e.indeterminate)}),this.selModel.forEach(e=>{if(!e.hasCheckbox)return;let t=e.data;if(t.key&&(this.selectability[t.key]=e.checked),!e.selCb)return;e.selCb.checked=e.checked,e.selCb.indeterminate=e.indeterminate;let i=this.model.get(e.id),r=i&&!i.checked&&!i.indeterminate;e.selCb.disabled=r,e.selLabel&&e.selLabel.classList.toggle("vis-sel-disabled",r)}),this.model.forEach(e=>{let t=e.data;if(t.disabledBy&&e.el){let i=!this.visibility[t.disabledBy];e.el.classList.toggle("disabled",i)}})}_buildSelCheckbox(e){let t=this.selModel.get(e.id);if(!t||!t.hasCheckbox)return null;let i=document.createElement("input");return i.type="checkbox",i.className="vis-sel-cb",i.title="Selectable",i.addEventListener("change",()=>{this.selModel.check(t.id,i.checked)}),t.selCb=i,i}_dom(e){let t=e.data,i=document.createElement("input");i.type="checkbox",i.className="vis-cb",i.title="Visible",e.cb=i,i.addEventListener("change",()=>this.model.check(e.id,i.checked));let r=this._buildSelCheckbox(e),s=f=>{if(f.appendChild(i),r){f.appendChild(r);let d=this.selModel.get(e.id);d&&(d.selLabel=f)}else f.appendChild(hr())};if(!e.children.length){let f=document.createElement("div");f.className="vis-leaf";let d=document.createElement("span");return d.className="vis-arrow",d.style.visibility="hidden",d.textContent="\u25B6",f.appendChild(d),f.appendChild(Qo(t.label)),s(f),e.el=f,f}let o=document.createElement("div");o.className="vis-group";let{header:a,arrow:c,name:l}=vs();l.textContent=t.label,s(a),o.appendChild(a);let u=document.createElement("div");u.className="vis-group-children",t.disabled&&u.classList.add("disabled");for(let f of e.children)u.appendChild(this._dom(f));return o.appendChild(u),xs(a,c,u,!0),o}};function Hl(n,e,t,i){let r=new Set,s=Math.max(0,n-e),o=Math.min(i-1,n+t);for(let a=s;a<=o;a++)r.add(a);return r}function BW(n){let e={};for(let[t,i]of Object.entries(n||{}))i!==1&&(e[t]=i);return e}function qh(n,e){return(n||[]).some(t=>t.every(i=>!!e[i]))}function OW(n,e){return n.map(t=>{let i=!e.has(t.path);return{id:t.path,parentId:t.parent!=null?t.parent:null,hasCheckbox:t.parent!=null,checked:i,data:{path:t.path,name:t.name,master:t.master,depth:t.depth}}})}var DW=3,gM=[[70,130,210],[200,50,50],[50,180,80],[200,160,40],[160,60,200],[40,190,190],[220,120,50],[180,70,150]];function NW(n){return!n.forceComposite||fe(n)?0:n.groupLayers||S3}function _M(n,e,t,i,r,s){if(!n.displayControlsEl)return;n.displayControlsEl.innerHTML="",n.displayControlsEl.appendChild(mM());for(let S of n.allLayers||[])S.remove();n.allLayers=[],n.baseSlot=null,n.topSlot=null;let o=new Set;function a(){for(let S of o)S.refresh();o.clear()}function c(){n.baseSlot&&o.add(n.baseSlot)}function l(S){return{layer:S,opacity:1,visible:!1}}function u(S,L){g3(S,L)&&c()}function f(S,L,D){let A={layer:S,opacity:1,visible:!!D};return L&&(n[L]=A),A}let d=[f("_instances",null,!0),f("_pins","pinsLayer",e.pins),f("_modules","modulesLayer",e.module_view)],h=[];n.overlayLayers=(i&&i.overlays||[]).map(S=>({def:S,layer:f(S.name,null,qh(S.shown_by,e)),under:S.z_indexD.def.z_index-A.def.z_index))(L?d:h).push(S);let p=[],m=[],g=null,v=new Set,y=new Set;try{let S=window.sessionStorage.getItem("or_hidden_layers");S&&(v=new Set(JSON.parse(S)))}catch{}try{let S=window.sessionStorage.getItem("or_nonselectable_layers");S&&(y=new Set(JSON.parse(S)))}catch{}try{let S=window.sessionStorage.getItem("or_layer_patterns");S&&Object.assign(n.layerPatterns,JSON.parse(S))}catch{}function b(){try{window.sessionStorage.setItem("or_layer_patterns",JSON.stringify(BW(n.layerPatterns)))}catch{}}function x(S,L){L===1?delete n.layerPatterns[S]:n.layerPatterns[S]=L,b(),c(),a()}let E=[{label:"Solid",value:1},{label:"Diagonal",value:2},{label:"Cross",value:3},{label:"Dots",value:4},{label:"None (no fill)",value:0}],w=0;function T(S,L="layers",D=void 0){let A=[],z=S.type==="category"?D:S.path,I=S.flipped===!0,B=S.instances||[],U=B.filter(Oe=>Oe.type!=="category"),Z=B.filter(Oe=>Oe.type==="category"),Q=S.layers||[],ye=w;w+=Q.length;function be(Oe,yt){let K=Oe.map((P,k)=>k);yt&&K.reverse(),K.forEach(P=>{let k=Oe[P],$=L+"/"+(k.name||P);A.push(T(k,$,z))})}function je(){(I?Q.map((yt,K)=>K).reverse():Q.map((yt,K)=>K)).forEach(yt=>{let K=Q[yt],P=K.name||K,k=ye+yt,$=l(P),W=`${L}/${P}`,re=!v.has(W);re&&(u($,!0),n.visibleLayers.add(W),n.visibleLayerNames.add(P)),p.push($),m.push(W),A.push({id:W,data:{name:P,layer:$,color:K.color,colorIndex:k,nodeId:W,ownerChipletPath:z},checked:re})})}be(U,!1),I&&je(),be(Z,I),I||je();let Be={name:S.name,isInstance:!0};return S.type==="category"&&(S.name==="Implant"||S.name==="Other")&&(Be.startCollapsed=!0),S.type!=="category"&&(Be.chipletPath=S.path),{id:L,data:Be,children:A}}let R;i.layer_hierarchy?R=T(i.layer_hierarchy,"layers_parent"):R={id:"layers_parent",children:i.layers.map((S,L)=>{let D=l(S),A=`layers_parent/${S}`,z=!v.has(A);return z&&(u(D,!0),n.visibleLayers.add(A),n.visibleLayerNames.add(S)),p.push(D),m.push(A),{id:A,data:{name:S,layer:D,colorIndex:L,nodeId:A},checked:z}})};function F(S,L,D){let A=n.view.addTileSlot(S,{order:L,source:P3({wm:n.websocketManager,ctx:n.tileCtx,getItems:()=>D,dpr:Yo,tileSize:on,isDoubleBuffer:()=>n.doubleBuffer,groupLayers:()=>NW(n)})});return A.items=D,A}n.baseSlot=F("base",ot.base,[...d,...p]),n.topSlot=F("top",ot.top,h),n.allLayers=[n.baseSlot,n.topSlot];function O(S){if(!S.children||S.children.length===0){let L=S.data&&S.data.name,D=L?!y.has(L):!0;return D&&L&&n.selectableLayers.add(L),{id:S.id,data:{name:L},checked:D}}return{id:S.id,data:{name:S.data&&S.data.name},children:S.children.map(O)}}let j=O(R),V=new Cn(()=>{n.visibleLayerNames.clear();let S=[],L={},D=!1,A=!1,z=g&&n.visibleChiplets instanceof Set;if(V.forEach(B=>{if(B.cb&&(B.cb.checked=B.checked,B.cb.indeterminate=B.indeterminate),B.data&&B.data.layer){let U=B.data.nodeId||B.data.name;S.push(U),u(B.data.layer,B.checked),B.checked?(n.visibleLayers.add(U),n.visibleLayerNames.add(B.data.name)):n.visibleLayers.delete(U)}if(z&&B.data&&B.data.chipletPath){let U=B.data.chipletPath,Z=g.get(U);if(Z){let Q=B.checked||B.indeterminate,ye={checked:B.checked,indeterminate:B.indeterminate};(Z.checked!==B.checked||Z.indeterminate!==B.indeterminate)&&(L[U]=ye,D=!0),n.visibleChiplets.has(U)!==Q&&(A=!0)}}}),n.baseSlot&&o.has(n.baseSlot))for(let{def:B,under:U}of n.overlayLayers)qh(B.layers_by,e)&&o.add(U?n.baseSlot:n.topSlot);a(),q();let I=S.filter(B=>!n.visibleLayers.has(B));try{window.sessionStorage.setItem("or_hidden_layers",JSON.stringify(I))}catch{}n.syncDisplayState(),A?g.mirrorStates(L):D&&(g.mirrorStatesQuiet(L),g.forEach(B=>{B.cb&&(B.cb.checked=B.checked,B.cb.indeterminate=B.indeterminate)}))});n.layerModel=V,V.addFromSpec(R);let G=new Cn(()=>{n.selectableLayers.clear(),G.forEach(L=>{L.checked&&L.data&&L.data.name&&n.selectableLayers.add(L.data.name)}),q();let S=i.layers.filter(L=>!n.selectableLayers.has(L));try{window.sessionStorage.setItem("or_nonselectable_layers",JSON.stringify(S))}catch{}n.syncDisplayState()});G.addFromSpec(j);function q(){G.forEach(S=>{if(!S.selCb)return;S.selCb.checked=S.checked,S.selCb.indeterminate=S.indeterminate;let L=V.get(S.id),D=L&&!L.checked&&!L.indeterminate;S.selCb.disabled=D})}let X=document.createElement("div");X.className="context-menu",X.style.display="none",document.body.appendChild(X);function se(S){let L={};m.forEach((D,A)=>{D&&(L[D]=S.has(A))}),V.checkSet(L)}function le(){X.style.display="none"}function he(S,L){let D=document.createElement("div");D.className="context-menu-item",D.textContent=S,D.addEventListener("click",()=>{L(),le()}),X.appendChild(D)}let at=p.length,Ct=[{label:"Show only this layer",fn:S=>Hl(S,0,0,at)},{label:"Show layer range \u2195",fn:S=>Hl(S,1,1,at)},{label:"Show layer range \u2195\u2195",fn:S=>Hl(S,2,2,at)},{label:"Show layer range \u2193",fn:S=>Hl(S,1,0,at)},{label:"Show layer range \u2191",fn:S=>Hl(S,0,1,at)}];document.addEventListener("click",S=>{X.contains(S.target)||le()}),document.addEventListener("keydown",S=>{S.key==="Escape"&&le()});let Tn=!fe(n),Ni=null;function Ln(){Ni&&(Ni.classList.remove("vis-row-selected"),Ni=null)}Tn&&O3(n,Ln);function li(S,L,D){let A=Pt(n);Ni=S,S.classList.add("vis-row-selected");let z={type:"select_layer",layer:L,use_dbu:n.showDbu};D&&(z.chiplet=D),n.websocketManager.request(z).then(I=>{zt(n,A)&&(n.updateInspector&&n.updateInspector(I),n.focusComponent&&n.focusComponent("Inspector"),n.refreshOverlay&&n.refreshOverlay())}).catch(I=>{console.error("select_layer failed:",I),zt(n,A)&&Ln()})}function cn(S,L=!1){let D=G.get(S.id);if(!S.children||S.children.length===0){let A=document.createElement("div");A.className=Tn?"vis-leaf vis-leaf-selectable":"vis-leaf";let z=document.createElement("span");z.className="vis-arrow",z.style.visibility="hidden",z.textContent="\u25B6",A.appendChild(z);let I=S.data.colorIndex,B=S.data.name,U=Qo(),Z=document.createElement("span");Z.className="layer-color";let Q=S.data.color||i.layer_colors&&i.layer_colors[I]||gM[I%gM.length];Z.style.backgroundColor=`rgb(${Q[0]},${Q[1]},${Q[2]})`,U.appendChild(Z),U.appendChild(document.createTextNode(B)),A.appendChild(U),Tn&&U.addEventListener("click",()=>{li(A,B,S.data.ownerChipletPath)});let ye=document.createElement("input");if(ye.type="checkbox",ye.className="vis-cb",ye.title="Visible",ye.checked=S.checked,S.cb=ye,ye.addEventListener("change",()=>{V.check(S.id,ye.checked)}),A.appendChild(ye),D){let be=document.createElement("input");be.type="checkbox",be.className="vis-sel-cb",be.title="Selectable",be.checked=D.checked,D.selCb=be,be.addEventListener("change",()=>{G.check(S.id,be.checked)}),A.appendChild(be)}else A.appendChild(hr());return A.addEventListener("contextmenu",be=>{be.preventDefault(),be.stopPropagation(),X.innerHTML="";for(let Oe of Ct)he(Oe.label,()=>se(Oe.fn(I)));let je=document.createElement("div");je.className="context-menu-separator",je.style.borderTop="1px solid #555",je.style.margin="4px 0",X.appendChild(je);let Be=n.layerPatterns[B]??1;for(let Oe of E){let yt=Be===Oe.value?"\u25CF ":" ";he(yt+"Fill: "+Oe.label,()=>x(B,Oe.value))}X.style.left=be.clientX+"px",X.style.top=be.clientY+"px",X.style.display="block"}),A}else{let A=document.createElement("div");A.className="vis-group";let{header:z,arrow:I,name:B}=vs();B.textContent=L?"Layers":S.data.name||"Group";let U=document.createElement("input");if(U.type="checkbox",U.className="vis-cb",U.title="Visible",U.checked=S.checked,U.indeterminate=S.indeterminate,S.cb=U,U.addEventListener("change",()=>{V.check(S.id,U.checked)}),z.appendChild(U),D){let Q=document.createElement("input");Q.type="checkbox",Q.className="vis-sel-cb",Q.title="Selectable",Q.checked=D.checked,Q.indeterminate=D.indeterminate,D.selCb=Q,Q.addEventListener("change",()=>{G.check(S.id,Q.checked)}),z.appendChild(Q)}else z.appendChild(hr());A.appendChild(z);let Z=document.createElement("div");Z.className="vis-group-children";for(let Q of S.children)Z.appendChild(cn(Q,!1));return A.appendChild(Z),xs(z,I,Z,!!(S.data&&S.data.startCollapsed)),A}}let Gt=V.roots[0]||V.get("layers_parent"),ln=cn(Gt,!0);n.displayControlsEl.appendChild(ln),q();let ui=i&&Array.isArray(i.chiplets)?i.chiplets:[];if(ui.length>1){let Z=function(K,P){let k=U.get(K);k&&(V.cascadeQuiet(k.id,P),V.onChange())},yt=function(K){let P=K.data;if(K!==Be){let k=document.createElement("div");k.className="vis-leaf",k.style.paddingLeft=8*(P.depth-1)+"px",k.title=P.path+(P.master?` (${P.master})`:""),k.appendChild(Qo(P.name));let $=document.createElement("input");$.type="checkbox",$.className="vis-cb",$.checked=K.checked,$.indeterminate=K.indeterminate,K.cb=$,$.addEventListener("change",()=>{g.check(K.id,$.checked),Z(P.path,$.checked)}),k.appendChild($),k.appendChild(hr()),Oe.appendChild(k)}K.children&&K.children.forEach(yt)},S=i&&i.block_name||"",L=S!=="",D={};if(L)try{let K=We("or_hidden_chiplets");if(K){let P=JSON.parse(decodeURIComponent(K));P&&typeof P=="object"&&!Array.isArray(P)&&(D=P)}}catch{}let A=new Set(Array.isArray(D[S])?D[S]:[]),z=OW(ui,A),I=z.findIndex(K=>K.parentId===null),B=I>=0?z[I].id:null;if(I>=0&&(z[I].hasCheckbox=!0),n.visibleChiplets=new Set(ui.filter(K=>!A.has(K.path)).map(K=>K.path)),g=new Cn(()=>{let K=new Set;if(g.forEach(P=>{P.cb&&(P.cb.checked=P.checked,P.cb.indeterminate=P.indeterminate),P.data&&P.data.path&&(P.checked||P.indeterminate)&&K.add(P.data.path)}),n.visibleChiplets=K,L){let P=ui.filter($=>!K.has($.path)).map($=>$.path),k={};try{let $=We("or_hidden_chiplets");if($){let W=JSON.parse(decodeURIComponent($));W&&typeof W=="object"&&!Array.isArray(W)&&(k=W)}}catch{}P.length===0?delete k[S]:k[S]=P,$e("or_hidden_chiplets",encodeURIComponent(JSON.stringify(k)))}r()}),g.buildFromNodes(z),typeof console<"u"&&console.warn){let K=new Set;V.forEach(k=>{k.data&&k.data.chipletPath&&K.add(k.data.chipletPath)});let P=new Set;g.forEach(k=>{k.data&&k.data.path&&P.add(k.data.path)});for(let k of P)K.has(k)||console.warn(`[display-controls] chiplet "${k}" missing from layer_hierarchy \u2014 Layers/Chiplets sync may drift`);for(let k of K)P.has(k)||console.warn(`[display-controls] layer hierarchy node "${k}" has no matching chiplet \u2014 Layers/Chiplets sync may drift`)}let U=new Map;V.forEach(K=>{K.data&&K.data.chipletPath&&U.set(K.data.chipletPath,K)});{let K={};if(V.forEach(P=>{if(!P.data||!P.data.chipletPath)return;let k=P.data.chipletPath;A.has(k)||g.get(k)&&(K[k]={checked:P.checked,indeterminate:P.indeterminate})}),Object.keys(K).length>0){g.mirrorStatesQuiet(K);let P=new Set;g.forEach(k=>{k.data&&k.data.path&&(k.checked||k.indeterminate)&&P.add(k.data.path)}),n.visibleChiplets=P}}let Q=document.createElement("div");Q.className="vis-group";let{header:ye,arrow:be,name:je}=vs();je.textContent="Chiplets";let Be=B!=null?g.get(B):null;if(Be){let K=document.createElement("input");K.type="checkbox",K.className="vis-cb",K.checked=Be.checked,K.indeterminate=Be.indeterminate,Be.cb=K,K.addEventListener("change",P=>{P.stopPropagation(),g.check(B,K.checked),Be.data&&Be.data.path&&Z(Be.data.path,K.checked)}),ye.appendChild(K)}ye.appendChild(hr()),Q.appendChild(ye);let Oe=document.createElement("div");Oe.className="vis-group-children",g.roots.forEach(yt),Q.appendChild(Oe),xs(ye,be,Oe,!1),n.displayControlsEl.appendChild(Q)}else n.visibleChiplets=null;let fi=!!e.debug_renderers,Ge=new Yh(e,t,()=>{r(),!!e.debug_renderers!==fi&&(fi=!!e.debug_renderers,n.refreshRendererControls&&n.refreshRendererControls())});Ge.add({label:"Nets",addSelectable:!0,children:[{key:"net_signal",label:"Signal"},{key:"net_power",label:"Power"},{key:"net_ground",label:"Ground"},{key:"net_clock",label:"Clock"},{key:"net_reset",label:"Reset"},{key:"net_tieoff",label:"Tie off"},{key:"net_scan",label:"Scan"},{key:"net_analog",label:"Analog"}]}),Ge.add({label:"Instances",addSelectable:!0,children:[{label:"Std Cells",visKey:"stdcells",disabled:!n.hasLiberty,children:[{label:"Bufs/Invs",children:[{key:"std_bufinv_timing",label:"Timing opt."},{key:"std_bufinv",label:"Netlist"}]},{key:"std_combinational",label:"Combinational"},{key:"std_sequential",label:"Sequential"},{label:"Clock tree",children:[{key:"std_clock_bufinv",label:"Buffer/Inverter"},{key:"std_clock_gate",label:"Clock gate"}]},{key:"std_level_shift",label:"Level shifter"}]},{key:"macros",label:"Macros"},{label:"Pads",children:[{key:"pad_input",label:"Input"},{key:"pad_output",label:"Output"},{key:"pad_inout",label:"Inout"},{key:"pad_power",label:"Power"},{key:"pad_spacer",label:"Spacer"},{key:"pad_areaio",label:"Area IO"},{key:"pad_other",label:"Other"}]},{label:"Physical",children:[{key:"phys_fill",label:"Fill"},{key:"phys_endcap",label:"Endcap"},{key:"phys_welltap",label:"Welltap"},{key:"phys_tie",label:"Tie Hi/Lo"},{key:"phys_antenna",label:"Antenna"},{key:"phys_cover",label:"Cover"},{key:"phys_bump",label:"Bump"},{key:"phys_other",label:"Other"}]}]}),Ge.add({label:"Blockages",addSelectable:!0,children:[{key:"placement_blockages",label:"Placement"},{key:"routing_obstructions",label:"Routing"}]}),i.sites&&i.sites.length>0&&Ge.add({label:"Rows",visKey:"rows",addSelectable:!0,children:i.sites.map(S=>({key:"site_"+S,label:S}))}),Ge.add({label:"Tracks",children:[{key:"tracks_pref",label:"Pref"},{key:"tracks_non_pref",label:"Non Pref"}]}),Ge.add({label:"Shapes",children:[{label:"Routing",visKey:"routing",children:[{key:"routing_segments",label:"Segments"},{key:"routing_vias",label:"Vias"}]},{label:"Special Routing",visKey:"special_nets",children:[{key:"srouting_segments",label:"Segments"},{key:"srouting_vias",label:"Vias"}]},{key:"pins",label:"Pins",selectable:!0},{key:"pin_names",label:"Pin Names",disabledBy:"pins"},{key:"fills",label:"Fills"}]}),Ge.add({label:"Misc",children:[{label:"Instances",children:[{key:"inst_names",label:"Names"},{key:"inst_pins",label:"Pins",selectable:!0},{key:"inst_pin_names",label:"Pin Names",disabledBy:"inst_pins"},{key:"blockages",label:"Blockages"}]},{key:"detailed",label:"Detailed view"},{key:"rulers",label:"Rulers"},{key:"labels",label:"Labels"},{key:"scale_bar",label:"Scale bar"},{key:"access_points",label:"Access Points"},{key:"regions",label:"Regions"},{key:"mfg_grid",label:"Manufacturing grid"},{key:"gcell_grid",label:"GCell grid"},{key:"flywires_only",label:"Flywires only"},{key:"focused_nets_guides",label:"Focused nets guides"},{key:"highlight_selected",label:"Highlight selected"}]}),Ge.add({key:"module_view",label:"Module view"}),Ge.add({label:"Debug Graphics",children:[{key:"debug_renderers",label:"Renderers"},{key:"debug_live",label:"Live (don't require pause)",disabledBy:"debug_renderers"},{key:"debug",label:"Tiles"}]}),Ge.render(n.displayControlsEl);let _t=document.createElement("div");_t.className="renderer-controls",n.displayControlsEl.appendChild(_t);function Vt(S){return Promise.all(S.map(({path:L,value:D})=>n.websocketManager.request({type:"set_renderer_control",path:L,value:D}))).catch(()=>{})}function di(S){_t.innerHTML="";let L=new Map;for(let D of S||[]){let A=D.group||"";L.has(A)||L.set(A,[]),L.get(A).push(D)}for(let[D,A]of L){let z=_t;if(D){let I=document.createElement("div");I.className="vis-group";let{header:B,arrow:U,name:Z}=vs();Z.textContent=D;let Q=document.createElement("input");Q.type="checkbox",Q.className="vis-cb",Q.title="Visible";let ye=A.filter(je=>je.visible).length;Q.checked=ye===A.length,Q.indeterminate=ye>0&&ye{let je=Q.checked;Vt(A.filter(Be=>!!Be.visible!==je).map(Be=>({path:Be.path,value:je})))}),B.appendChild(Q),B.appendChild(hr()),I.appendChild(B);let be=document.createElement("div");be.className="vis-group-children",I.appendChild(be),xs(B,U,be,!1),_t.appendChild(I),z=be}for(let I of A){let B=document.createElement("div");B.className="vis-leaf";let U=document.createElement("span");U.className="vis-arrow",U.style.visibility="hidden",U.textContent="\u25B6",B.appendChild(U),B.appendChild(Qo(I.name));let Z=document.createElement("input");Z.type="checkbox",Z.className="vis-cb",Z.title="Visible",Z.checked=!!I.visible,Z.addEventListener("change",()=>Vt([{path:I.path,value:Z.checked}])),B.appendChild(Z),B.appendChild(hr()),z.appendChild(B)}}}n.refreshRendererControls=function(){return!n.websocketManager||fe(n)||!e.debug_renderers?(_t.innerHTML="",Promise.resolve()):n.websocketManager.request({type:"renderer_controls"}).then(S=>di(S.controls)).catch(()=>{})},n.refreshRendererControls();let Mn=document.createElement("div");Mn.className="bg-color-row";let hi=document.createElement("span");hi.textContent="Background";let Ke=document.createElement("input");Ke.type="color",Ke.className="bg-color-input",Ke.title="Layout background color";let Wt=We("or_bg_color");Ke.value=Zo(Wt)?Wt:tv(),Ke.addEventListener("input",()=>{document.documentElement.style.setProperty("--bg-map",Ke.value)}),Ke.addEventListener("change",()=>{eM(Ke.value,n)});let un=document.createElement("button");un.className="bg-color-reset",un.textContent="Reset",un.title="Reset background to the theme default",un.addEventListener("click",()=>{tM(n),Ke.value=tv()}),Mn.appendChild(hi),Mn.appendChild(Ke),Mn.appendChild(un),!n.heatMapLayer&&s&&(n.heatMapLayer=s());let An=document.createElement("div");An.className="vis-group heatmap-controls",n.displayControlsEl.appendChild(An);let{header:Rs,arrow:pi,name:yr}=vs("vis-group-header heatmap-header");yr.textContent="Heat Maps",An.appendChild(Rs);let kn=document.createElement("div");kn.className="vis-group-children heatmap-group-children",An.appendChild(kn),xs(Rs,pi,kn,!0),n.displayControlsEl.appendChild(Mn);function jt(S,L,D,A){let z=document.createElement("label");z.className="heatmap-setting";let I=document.createElement("input");I.type="checkbox",I.checked=D,I.addEventListener("change",()=>A(I.checked)),z.appendChild(I),z.appendChild(document.createTextNode(L)),S.appendChild(z)}function Re(S,L,D,A,z){let I=document.createElement("label");I.className="heatmap-setting";let B=document.createElement("span");B.textContent=L;let U=document.createElement("input");U.type="number",U.value=String(D),U.step=String(A||1),U.addEventListener("change",()=>z(parseFloat(U.value))),I.appendChild(B),I.appendChild(U),S.appendChild(I)}function na(S,L,D,A,z){let I=document.createElement("label");I.className="heatmap-setting";let B=document.createElement("span");B.textContent=L;let U=document.createElement("select");for(let Z of A){let Q=document.createElement("option");Q.value=Z,Q.textContent=Z,Z===D&&(Q.selected=!0),U.appendChild(Q)}U.addEventListener("change",()=>z(U.value)),I.appendChild(B),I.appendChild(U),S.appendChild(I)}function Ce(S){n.websocketManager.request(S).then(L=>{n.updateHeatMaps&&n.updateHeatMaps(L)}).catch(L=>console.error("Heat map update failed",L))}function M(S){if(!n.heatMapLegendEl)return;let L=n.heatMapLegendEl;if(L.innerHTML="",!S||!S.show_legend||!S.legend||S.legend.length===0){L.classList.add("hidden");return}let D=document.createElement("div");D.className="heatmap-map-legend-title",D.textContent=S.title,L.appendChild(D);let A=document.createElement("div");A.className="heatmap-map-legend-units",A.textContent=S.units||"",L.appendChild(A);let z=document.createElement("div");z.className="heatmap-map-legend-list";for(let I of S.legend){let B=document.createElement("div");B.className="heatmap-legend-row";let U=document.createElement("span");U.className="heatmap-legend-swatch",U.style.backgroundColor=`rgba(${I.color[0]}, ${I.color[1]}, ${I.color[2]}, ${I.color[3]/255})`;let Z=document.createElement("span");Z.textContent=I.value,B.appendChild(U),B.appendChild(Z),z.appendChild(B)}L.appendChild(z),L.classList.remove("hidden")}n.renderHeatMapControls=S=>{kn.innerHTML="";let L=document.createElement("div");L.className="heatmap-list",kn.appendChild(L);let D=document.createElement("label");D.className="heatmap-setting";let A=document.createElement("input");A.type="radio",A.name="active-heatmap",A.checked=!S.active,A.addEventListener("change",()=>{Ce({type:"set_active_heatmap",name:""})}),D.appendChild(A),D.appendChild(document.createTextNode("Off")),L.appendChild(D);for(let U of S.heatmaps||[]){let Z=document.createElement("label");Z.className="heatmap-setting";let Q=document.createElement("input");Q.type="radio",Q.name="active-heatmap",Q.checked=U.name===S.active,Q.addEventListener("change",()=>{Ce({type:"set_active_heatmap",name:U.name})}),Z.appendChild(Q),Z.appendChild(document.createTextNode(U.title)),L.appendChild(Z)}let z=(S.heatmaps||[]).find(U=>U.name===S.active);if(M(z),!z)return;let I=document.createElement("div");I.className="heatmap-settings",kn.appendChild(I),Re(I,"Display min",z.display_min,z.display_range_increment,U=>{Ce({type:"set_heatmap",name:z.name,option:"DisplayMin",value:U})}),Re(I,"Display max",z.display_max,z.display_range_increment,U=>{Ce({type:"set_heatmap",name:z.name,option:"DisplayMax",value:U})}),jt(I,"Show below min",z.draw_below_min,U=>{Ce({type:"set_heatmap",name:z.name,option:"ShowMin",value:U})}),jt(I,"Show above max",z.draw_above_max,U=>{Ce({type:"set_heatmap",name:z.name,option:"ShowMax",value:U})}),jt(I,"Log scale",z.log_scale,U=>{Ce({type:"set_heatmap",name:z.name,option:"LogScale",value:U})}),jt(I,"Reverse log",z.reverse_log,U=>{Ce({type:"set_heatmap",name:z.name,option:"ReverseLog",value:U})}),z.can_adjust_grid&&(Re(I,"Grid X",z.grid_x,.1,U=>{Ce({type:"set_heatmap",name:z.name,option:"GridX",value:U})}),Re(I,"Grid Y",z.grid_y,.1,U=>{Ce({type:"set_heatmap",name:z.name,option:"GridY",value:U})})),Re(I,"Alpha",z.alpha,1,U=>{Ce({type:"set_heatmap",name:z.name,option:"Alpha",value:U})}),jt(I,"Legend",z.show_legend,U=>{Ce({type:"set_heatmap",name:z.name,option:"ShowLegend",value:U})}),z.supports_numbers&&jt(I,"Show numbers",z.show_numbers,U=>{Ce({type:"set_heatmap",name:z.name,option:"ShowNumbers",value:U})});for(let U of z.options||[])U.type==="bool"?jt(I,U.label,U.value,Z=>{Ce({type:"set_heatmap",name:z.name,option:U.name,value:Z})}):U.type==="choice"&&na(I,U.label,U.value,U.choices||[],Z=>{Ce({type:"set_heatmap",name:z.name,option:U.name,value:Z})});z.selection_filter_label&&jt(I,z.selection_filter_label,z.use_selected_only,U=>{Ce({type:"set_heatmap",name:z.name,option:"use_selected_only",value:U})});let B=document.createElement("button");B.className="or-btn or-btn-sm heatmap-rebuild",B.textContent="Rebuild data",B.addEventListener("click",()=>{Ce({type:"set_heatmap",name:z.name,option:"rebuild",value:1})}),I.appendChild(B)}}var yM="search-nav-dialog",FW=[{label:"Instance",value:"inst"},{label:"Net",value:"net"},{label:"Port",value:"port"}];function Zh(n){if(!n.designScale)return;let e=FW.map(u=>``).join(""),{overlay:t,close:i,okBtn:r,showError:s}=Xo("Find Object",` + affected.`,"Apply",pM),c=r.querySelector(".opt-family"),l=r.querySelector(".opt-custom"),u=r.querySelector(".opt-scale"),f=r.querySelector(".opt-preview");function d(){f.style.fontFamily=l.value.trim()||c.value,f.style.fontSize=`calc(13px * ${jl(u.value)/100})`}for(let p of[c,l,u])p.addEventListener("input",d);d();function h(){let p=u.value.trim(),m=Number(p);if(p===""||!Number.isFinite(m)){a("Size must be a number.");return}if(mHh){a(`Size must be between ${jh} and ${Hh} %.`);return}n.setAppFont({family:l.value.trim()||c.value,scale:m}),s()}o.addEventListener("click",h);for(let p of[l,u])p.addEventListener("keydown",m=>{m.key==="Enter"&&(m.preventDefault(),h())});return{close:s}}function av(n){return String(n).replace(/&/g,"&").replace(/"/g,""").replace(//g,">")}var DW='',NW='';function Qo(n){let e=document.createElement("span");return e.className="vis-name",n!=null&&(e.textContent=n),e}function hr(){let n=document.createElement("span");return n.className="vis-sel-cb vis-sel-spacer",n}function _M(){let n=document.createElement("div");n.className="display-controls-header",n.appendChild(Qo(""));for(let[e,t]of[[DW,"Visible"],[NW,"Selectable"]]){let i=document.createElement("span");i.className="vis-header-icon",i.title=t,i.innerHTML=e,n.appendChild(i)}return n}var Yh=class{constructor(e,t,i){this.visibility=e,this.selectability=t,this.onChange=i;let r=()=>{this._syncAll(),this.onChange()};this.model=new Cn(r),this.selModel=new Cn(r)}add(e){return this.model.addFromSpec(this._enrichSpec(e,"")),this.selModel.addFromSpec(this._enrichSelSpec(e,"",!1)),this}render(e){for(let t of this.model.roots)e.appendChild(this._dom(t));this._syncAll()}_nodeId(e,t){let i=e.key||e.label;return t?t+"/"+i:i}_enrichSpec(e,t){let i=this._nodeId(e,t),r={id:i,data:e};return e.children?r.children=e.children.map(s=>this._enrichSpec(s,i)):e.key&&(r.checked=!!this.visibility[e.key]),e.disabled!=null&&(r.disabled=e.disabled),r}_enrichSelSpec(e,t,i){let r=e.addSelectable===!0?!0:e.addSelectable===!1?!1:i,s=this._nodeId(e,t),o={id:s,data:e,hasCheckbox:!1};if(e.children){o.children=e.children.map(c=>this._enrichSelSpec(c,s,r));let a=c=>c.some(l=>l.hasCheckbox||l.children&&a(l.children));o.hasCheckbox=a(o.children),o.hasCheckbox&&(o.checked=!0)}else if(e.key){let a=e.selectable===!0||e.selectable!==!1&&i;o.hasCheckbox=a,a&&(o.checked=this.selectability[e.key]!==!1)}return o}_syncAll(){this.model.forEach(e=>{e.cb&&(e.cb.checked=e.checked,e.cb.indeterminate=e.indeterminate);let t=e.data;t.key&&(this.visibility[t.key]=e.checked),t.visKey&&(this.visibility[t.visKey]=e.checked||e.indeterminate)}),this.selModel.forEach(e=>{if(!e.hasCheckbox)return;let t=e.data;if(t.key&&(this.selectability[t.key]=e.checked),!e.selCb)return;e.selCb.checked=e.checked,e.selCb.indeterminate=e.indeterminate;let i=this.model.get(e.id),r=i&&!i.checked&&!i.indeterminate;e.selCb.disabled=r,e.selLabel&&e.selLabel.classList.toggle("vis-sel-disabled",r)}),this.model.forEach(e=>{let t=e.data;if(t.disabledBy&&e.el){let i=!this.visibility[t.disabledBy];e.el.classList.toggle("disabled",i)}})}_buildSelCheckbox(e){let t=this.selModel.get(e.id);if(!t||!t.hasCheckbox)return null;let i=document.createElement("input");return i.type="checkbox",i.className="vis-sel-cb",i.title="Selectable",i.addEventListener("change",()=>{this.selModel.check(t.id,i.checked)}),t.selCb=i,i}_dom(e){let t=e.data,i=document.createElement("input");i.type="checkbox",i.className="vis-cb",i.title="Visible",e.cb=i,i.addEventListener("change",()=>this.model.check(e.id,i.checked));let r=this._buildSelCheckbox(e),s=f=>{if(f.appendChild(i),r){f.appendChild(r);let d=this.selModel.get(e.id);d&&(d.selLabel=f)}else f.appendChild(hr())};if(!e.children.length){let f=document.createElement("div");f.className="vis-leaf";let d=document.createElement("span");return d.className="vis-arrow",d.style.visibility="hidden",d.textContent="\u25B6",f.appendChild(d),f.appendChild(Qo(t.label)),s(f),e.el=f,f}let o=document.createElement("div");o.className="vis-group";let{header:a,arrow:c,name:l}=vs();l.textContent=t.label,s(a),o.appendChild(a);let u=document.createElement("div");u.className="vis-group-children",t.disabled&&u.classList.add("disabled");for(let f of e.children)u.appendChild(this._dom(f));return o.appendChild(u),xs(a,c,u,!0),o}};function Hl(n,e,t,i){let r=new Set,s=Math.max(0,n-e),o=Math.min(i-1,n+t);for(let a=s;a<=o;a++)r.add(a);return r}function FW(n){let e={};for(let[t,i]of Object.entries(n||{}))i!==1&&(e[t]=i);return e}function qh(n,e){return(n||[]).some(t=>t.every(i=>!!e[i]))}function zW(n,e){return n.map(t=>{let i=!e.has(t.path);return{id:t.path,parentId:t.parent!=null?t.parent:null,hasCheckbox:t.parent!=null,checked:i,data:{path:t.path,name:t.name,master:t.master,depth:t.depth}}})}var UW=3,yM=[[70,130,210],[200,50,50],[50,180,80],[200,160,40],[160,60,200],[40,190,190],[220,120,50],[180,70,150]];function $W(n){return!n.forceComposite||fe(n)?0:n.groupLayers||S3}function bM(n,e,t,i,r,s){if(!n.displayControlsEl)return;n.displayControlsEl.innerHTML="",n.displayControlsEl.appendChild(_M());for(let S of n.allLayers||[])S.remove();n.allLayers=[],n.baseSlot=null,n.topSlot=null;let o=new Set;function a(){for(let S of o)S.refresh();o.clear()}function c(){n.baseSlot&&o.add(n.baseSlot)}function l(S){return{layer:S,opacity:1,visible:!1}}function u(S,L){g3(S,L)&&c()}function f(S,L,D){let A={layer:S,opacity:1,visible:!!D};return L&&(n[L]=A),A}let d=[f("_instances",null,!0),f("_pins","pinsLayer",e.pins),f("_modules","modulesLayer",e.module_view)],h=[];n.overlayLayers=(i&&i.overlays||[]).map(S=>({def:S,layer:f(S.name,null,qh(S.shown_by,e)),under:S.z_indexD.def.z_index-A.def.z_index))(L?d:h).push(S);let p=[],m=[],g=null,v=new Set,y=new Set;try{let S=window.sessionStorage.getItem("or_hidden_layers");S&&(v=new Set(JSON.parse(S)))}catch{}try{let S=window.sessionStorage.getItem("or_nonselectable_layers");S&&(y=new Set(JSON.parse(S)))}catch{}try{let S=window.sessionStorage.getItem("or_layer_patterns");S&&Object.assign(n.layerPatterns,JSON.parse(S))}catch{}function b(){try{window.sessionStorage.setItem("or_layer_patterns",JSON.stringify(FW(n.layerPatterns)))}catch{}}function x(S,L){L===1?delete n.layerPatterns[S]:n.layerPatterns[S]=L,b(),c(),a()}let E=[{label:"Solid",value:1},{label:"Diagonal",value:2},{label:"Cross",value:3},{label:"Dots",value:4},{label:"None (no fill)",value:0}],w=0;function T(S,L="layers",D=void 0){let A=[],z=S.type==="category"?D:S.path,I=S.flipped===!0,B=S.instances||[],U=B.filter(Oe=>Oe.type!=="category"),Z=B.filter(Oe=>Oe.type==="category"),Q=S.layers||[],ye=w;w+=Q.length;function be(Oe,yt){let K=Oe.map((P,k)=>k);yt&&K.reverse(),K.forEach(P=>{let k=Oe[P],$=L+"/"+(k.name||P);A.push(T(k,$,z))})}function je(){(I?Q.map((yt,K)=>K).reverse():Q.map((yt,K)=>K)).forEach(yt=>{let K=Q[yt],P=K.name||K,k=ye+yt,$=l(P),W=`${L}/${P}`,re=!v.has(W);re&&(u($,!0),n.visibleLayers.add(W),n.visibleLayerNames.add(P)),p.push($),m.push(W),A.push({id:W,data:{name:P,layer:$,color:K.color,colorIndex:k,nodeId:W,ownerChipletPath:z},checked:re})})}be(U,!1),I&&je(),be(Z,I),I||je();let Be={name:S.name,isInstance:!0};return S.type==="category"&&(S.name==="Implant"||S.name==="Other")&&(Be.startCollapsed=!0),S.type!=="category"&&(Be.chipletPath=S.path),{id:L,data:Be,children:A}}let R;i.layer_hierarchy?R=T(i.layer_hierarchy,"layers_parent"):R={id:"layers_parent",children:i.layers.map((S,L)=>{let D=l(S),A=`layers_parent/${S}`,z=!v.has(A);return z&&(u(D,!0),n.visibleLayers.add(A),n.visibleLayerNames.add(S)),p.push(D),m.push(A),{id:A,data:{name:S,layer:D,colorIndex:L,nodeId:A},checked:z}})};function F(S,L,D){let A=n.view.addTileSlot(S,{order:L,source:P3({wm:n.websocketManager,ctx:n.tileCtx,getItems:()=>D,dpr:Yo,tileSize:sn,isDoubleBuffer:()=>n.doubleBuffer,groupLayers:()=>$W(n)})});return A.items=D,A}n.baseSlot=F("base",ot.base,[...d,...p]),n.topSlot=F("top",ot.top,h),n.allLayers=[n.baseSlot,n.topSlot];function O(S){if(!S.children||S.children.length===0){let L=S.data&&S.data.name,D=L?!y.has(L):!0;return D&&L&&n.selectableLayers.add(L),{id:S.id,data:{name:L},checked:D}}return{id:S.id,data:{name:S.data&&S.data.name},children:S.children.map(O)}}let j=O(R),V=new Cn(()=>{n.visibleLayerNames.clear();let S=[],L={},D=!1,A=!1,z=g&&n.visibleChiplets instanceof Set;if(V.forEach(B=>{if(B.cb&&(B.cb.checked=B.checked,B.cb.indeterminate=B.indeterminate),B.data&&B.data.layer){let U=B.data.nodeId||B.data.name;S.push(U),u(B.data.layer,B.checked),B.checked?(n.visibleLayers.add(U),n.visibleLayerNames.add(B.data.name)):n.visibleLayers.delete(U)}if(z&&B.data&&B.data.chipletPath){let U=B.data.chipletPath,Z=g.get(U);if(Z){let Q=B.checked||B.indeterminate,ye={checked:B.checked,indeterminate:B.indeterminate};(Z.checked!==B.checked||Z.indeterminate!==B.indeterminate)&&(L[U]=ye,D=!0),n.visibleChiplets.has(U)!==Q&&(A=!0)}}}),n.baseSlot&&o.has(n.baseSlot))for(let{def:B,under:U}of n.overlayLayers)qh(B.layers_by,e)&&o.add(U?n.baseSlot:n.topSlot);a(),q();let I=S.filter(B=>!n.visibleLayers.has(B));try{window.sessionStorage.setItem("or_hidden_layers",JSON.stringify(I))}catch{}n.syncDisplayState(),A?g.mirrorStates(L):D&&(g.mirrorStatesQuiet(L),g.forEach(B=>{B.cb&&(B.cb.checked=B.checked,B.cb.indeterminate=B.indeterminate)}))});n.layerModel=V,V.addFromSpec(R);let G=new Cn(()=>{n.selectableLayers.clear(),G.forEach(L=>{L.checked&&L.data&&L.data.name&&n.selectableLayers.add(L.data.name)}),q();let S=i.layers.filter(L=>!n.selectableLayers.has(L));try{window.sessionStorage.setItem("or_nonselectable_layers",JSON.stringify(S))}catch{}n.syncDisplayState()});G.addFromSpec(j);function q(){G.forEach(S=>{if(!S.selCb)return;S.selCb.checked=S.checked,S.selCb.indeterminate=S.indeterminate;let L=V.get(S.id),D=L&&!L.checked&&!L.indeterminate;S.selCb.disabled=D})}let X=document.createElement("div");X.className="context-menu",X.style.display="none",document.body.appendChild(X);function se(S){let L={};m.forEach((D,A)=>{D&&(L[D]=S.has(A))}),V.checkSet(L)}function le(){X.style.display="none"}function he(S,L){let D=document.createElement("div");D.className="context-menu-item",D.textContent=S,D.addEventListener("click",()=>{L(),le()}),X.appendChild(D)}let at=p.length,Ct=[{label:"Show only this layer",fn:S=>Hl(S,0,0,at)},{label:"Show layer range \u2195",fn:S=>Hl(S,1,1,at)},{label:"Show layer range \u2195\u2195",fn:S=>Hl(S,2,2,at)},{label:"Show layer range \u2193",fn:S=>Hl(S,1,0,at)},{label:"Show layer range \u2191",fn:S=>Hl(S,0,1,at)}];document.addEventListener("click",S=>{X.contains(S.target)||le()}),document.addEventListener("keydown",S=>{S.key==="Escape"&&le()});let Tn=!fe(n),Ni=null;function Ln(){Ni&&(Ni.classList.remove("vis-row-selected"),Ni=null)}Tn&&N3(n,Ln);function li(S,L,D){let A=Pt(n);Ni=S,S.classList.add("vis-row-selected");let z={type:"select_layer",layer:L,use_dbu:n.showDbu};D&&(z.chiplet=D),n.websocketManager.request(z).then(I=>{Ft(n,A)&&(n.updateInspector&&n.updateInspector(I),n.focusComponent&&n.focusComponent("Inspector"),n.refreshOverlay&&n.refreshOverlay())}).catch(I=>{console.error("select_layer failed:",I),Ft(n,A)&&Ln()})}function cn(S,L=!1){let D=G.get(S.id);if(!S.children||S.children.length===0){let A=document.createElement("div");A.className=Tn?"vis-leaf vis-leaf-selectable":"vis-leaf";let z=document.createElement("span");z.className="vis-arrow",z.style.visibility="hidden",z.textContent="\u25B6",A.appendChild(z);let I=S.data.colorIndex,B=S.data.name,U=Qo(),Z=document.createElement("span");Z.className="layer-color";let Q=S.data.color||i.layer_colors&&i.layer_colors[I]||yM[I%yM.length];Z.style.backgroundColor=`rgb(${Q[0]},${Q[1]},${Q[2]})`,U.appendChild(Z),U.appendChild(document.createTextNode(B)),A.appendChild(U),Tn&&U.addEventListener("click",()=>{li(A,B,S.data.ownerChipletPath)});let ye=document.createElement("input");if(ye.type="checkbox",ye.className="vis-cb",ye.title="Visible",ye.checked=S.checked,S.cb=ye,ye.addEventListener("change",()=>{V.check(S.id,ye.checked)}),A.appendChild(ye),D){let be=document.createElement("input");be.type="checkbox",be.className="vis-sel-cb",be.title="Selectable",be.checked=D.checked,D.selCb=be,be.addEventListener("change",()=>{G.check(S.id,be.checked)}),A.appendChild(be)}else A.appendChild(hr());return A.addEventListener("contextmenu",be=>{be.preventDefault(),be.stopPropagation(),X.innerHTML="";for(let Oe of Ct)he(Oe.label,()=>se(Oe.fn(I)));let je=document.createElement("div");je.className="context-menu-separator",je.style.borderTop="1px solid #555",je.style.margin="4px 0",X.appendChild(je);let Be=n.layerPatterns[B]??1;for(let Oe of E){let yt=Be===Oe.value?"\u25CF ":" ";he(yt+"Fill: "+Oe.label,()=>x(B,Oe.value))}X.style.left=be.clientX+"px",X.style.top=be.clientY+"px",X.style.display="block"}),A}else{let A=document.createElement("div");A.className="vis-group";let{header:z,arrow:I,name:B}=vs();B.textContent=L?"Layers":S.data.name||"Group";let U=document.createElement("input");if(U.type="checkbox",U.className="vis-cb",U.title="Visible",U.checked=S.checked,U.indeterminate=S.indeterminate,S.cb=U,U.addEventListener("change",()=>{V.check(S.id,U.checked)}),z.appendChild(U),D){let Q=document.createElement("input");Q.type="checkbox",Q.className="vis-sel-cb",Q.title="Selectable",Q.checked=D.checked,Q.indeterminate=D.indeterminate,D.selCb=Q,Q.addEventListener("change",()=>{G.check(S.id,Q.checked)}),z.appendChild(Q)}else z.appendChild(hr());A.appendChild(z);let Z=document.createElement("div");Z.className="vis-group-children";for(let Q of S.children)Z.appendChild(cn(Q,!1));return A.appendChild(Z),xs(z,I,Z,!!(S.data&&S.data.startCollapsed)),A}}let $t=V.roots[0]||V.get("layers_parent"),ln=cn($t,!0);n.displayControlsEl.appendChild(ln),q();let ui=i&&Array.isArray(i.chiplets)?i.chiplets:[];if(ui.length>1){let Z=function(K,P){let k=U.get(K);k&&(V.cascadeQuiet(k.id,P),V.onChange())},yt=function(K){let P=K.data;if(K!==Be){let k=document.createElement("div");k.className="vis-leaf",k.style.paddingLeft=8*(P.depth-1)+"px",k.title=P.path+(P.master?` (${P.master})`:""),k.appendChild(Qo(P.name));let $=document.createElement("input");$.type="checkbox",$.className="vis-cb",$.checked=K.checked,$.indeterminate=K.indeterminate,K.cb=$,$.addEventListener("change",()=>{g.check(K.id,$.checked),Z(P.path,$.checked)}),k.appendChild($),k.appendChild(hr()),Oe.appendChild(k)}K.children&&K.children.forEach(yt)},S=i&&i.block_name||"",L=S!=="",D={};if(L)try{let K=Ge("or_hidden_chiplets");if(K){let P=JSON.parse(decodeURIComponent(K));P&&typeof P=="object"&&!Array.isArray(P)&&(D=P)}}catch{}let A=new Set(Array.isArray(D[S])?D[S]:[]),z=zW(ui,A),I=z.findIndex(K=>K.parentId===null),B=I>=0?z[I].id:null;if(I>=0&&(z[I].hasCheckbox=!0),n.visibleChiplets=new Set(ui.filter(K=>!A.has(K.path)).map(K=>K.path)),g=new Cn(()=>{let K=new Set;if(g.forEach(P=>{P.cb&&(P.cb.checked=P.checked,P.cb.indeterminate=P.indeterminate),P.data&&P.data.path&&(P.checked||P.indeterminate)&&K.add(P.data.path)}),n.visibleChiplets=K,L){let P=ui.filter($=>!K.has($.path)).map($=>$.path),k={};try{let $=Ge("or_hidden_chiplets");if($){let W=JSON.parse(decodeURIComponent($));W&&typeof W=="object"&&!Array.isArray(W)&&(k=W)}}catch{}P.length===0?delete k[S]:k[S]=P,Ne("or_hidden_chiplets",encodeURIComponent(JSON.stringify(k)))}r()}),g.buildFromNodes(z),typeof console<"u"&&console.warn){let K=new Set;V.forEach(k=>{k.data&&k.data.chipletPath&&K.add(k.data.chipletPath)});let P=new Set;g.forEach(k=>{k.data&&k.data.path&&P.add(k.data.path)});for(let k of P)K.has(k)||console.warn(`[display-controls] chiplet "${k}" missing from layer_hierarchy \u2014 Layers/Chiplets sync may drift`);for(let k of K)P.has(k)||console.warn(`[display-controls] layer hierarchy node "${k}" has no matching chiplet \u2014 Layers/Chiplets sync may drift`)}let U=new Map;V.forEach(K=>{K.data&&K.data.chipletPath&&U.set(K.data.chipletPath,K)});{let K={};if(V.forEach(P=>{if(!P.data||!P.data.chipletPath)return;let k=P.data.chipletPath;A.has(k)||g.get(k)&&(K[k]={checked:P.checked,indeterminate:P.indeterminate})}),Object.keys(K).length>0){g.mirrorStatesQuiet(K);let P=new Set;g.forEach(k=>{k.data&&k.data.path&&(k.checked||k.indeterminate)&&P.add(k.data.path)}),n.visibleChiplets=P}}let Q=document.createElement("div");Q.className="vis-group";let{header:ye,arrow:be,name:je}=vs();je.textContent="Chiplets";let Be=B!=null?g.get(B):null;if(Be){let K=document.createElement("input");K.type="checkbox",K.className="vis-cb",K.checked=Be.checked,K.indeterminate=Be.indeterminate,Be.cb=K,K.addEventListener("change",P=>{P.stopPropagation(),g.check(B,K.checked),Be.data&&Be.data.path&&Z(Be.data.path,K.checked)}),ye.appendChild(K)}ye.appendChild(hr()),Q.appendChild(ye);let Oe=document.createElement("div");Oe.className="vis-group-children",g.roots.forEach(yt),Q.appendChild(Oe),xs(ye,be,Oe,!1),n.displayControlsEl.appendChild(Q)}else n.visibleChiplets=null;let fi=!!e.debug_renderers,Ve=new Yh(e,t,()=>{r(),!!e.debug_renderers!==fi&&(fi=!!e.debug_renderers,n.refreshRendererControls&&n.refreshRendererControls())});Ve.add({label:"Nets",addSelectable:!0,children:[{key:"net_signal",label:"Signal"},{key:"net_power",label:"Power"},{key:"net_ground",label:"Ground"},{key:"net_clock",label:"Clock"},{key:"net_reset",label:"Reset"},{key:"net_tieoff",label:"Tie off"},{key:"net_scan",label:"Scan"},{key:"net_analog",label:"Analog"}]}),Ve.add({label:"Instances",addSelectable:!0,children:[{label:"Std Cells",visKey:"stdcells",disabled:!n.hasLiberty,children:[{label:"Bufs/Invs",children:[{key:"std_bufinv_timing",label:"Timing opt."},{key:"std_bufinv",label:"Netlist"}]},{key:"std_combinational",label:"Combinational"},{key:"std_sequential",label:"Sequential"},{label:"Clock tree",children:[{key:"std_clock_bufinv",label:"Buffer/Inverter"},{key:"std_clock_gate",label:"Clock gate"}]},{key:"std_level_shift",label:"Level shifter"}]},{key:"macros",label:"Macros"},{label:"Pads",children:[{key:"pad_input",label:"Input"},{key:"pad_output",label:"Output"},{key:"pad_inout",label:"Inout"},{key:"pad_power",label:"Power"},{key:"pad_spacer",label:"Spacer"},{key:"pad_areaio",label:"Area IO"},{key:"pad_other",label:"Other"}]},{label:"Physical",children:[{key:"phys_fill",label:"Fill"},{key:"phys_endcap",label:"Endcap"},{key:"phys_welltap",label:"Welltap"},{key:"phys_tie",label:"Tie Hi/Lo"},{key:"phys_antenna",label:"Antenna"},{key:"phys_cover",label:"Cover"},{key:"phys_bump",label:"Bump"},{key:"phys_other",label:"Other"}]}]}),Ve.add({label:"Blockages",addSelectable:!0,children:[{key:"placement_blockages",label:"Placement"},{key:"routing_obstructions",label:"Routing"}]}),i.sites&&i.sites.length>0&&Ve.add({label:"Rows",visKey:"rows",addSelectable:!0,children:i.sites.map(S=>({key:"site_"+S,label:S}))}),Ve.add({label:"Tracks",children:[{key:"tracks_pref",label:"Pref"},{key:"tracks_non_pref",label:"Non Pref"}]}),Ve.add({label:"Shapes",children:[{label:"Routing",visKey:"routing",children:[{key:"routing_segments",label:"Segments"},{key:"routing_vias",label:"Vias"}]},{label:"Special Routing",visKey:"special_nets",children:[{key:"srouting_segments",label:"Segments"},{key:"srouting_vias",label:"Vias"}]},{key:"pins",label:"Pins",selectable:!0},{key:"pin_names",label:"Pin Names",disabledBy:"pins"},{key:"fills",label:"Fills"}]}),Ve.add({label:"Misc",children:[{label:"Instances",children:[{key:"inst_names",label:"Names"},{key:"inst_pins",label:"Pins",selectable:!0},{key:"inst_pin_names",label:"Pin Names",disabledBy:"inst_pins"},{key:"blockages",label:"Blockages"}]},{key:"detailed",label:"Detailed view"},{key:"rulers",label:"Rulers"},{key:"labels",label:"Labels"},{key:"scale_bar",label:"Scale bar"},{key:"access_points",label:"Access Points"},{key:"regions",label:"Regions"},{key:"mfg_grid",label:"Manufacturing grid"},{key:"gcell_grid",label:"GCell grid"},{key:"flywires_only",label:"Flywires only"},{key:"focused_nets_guides",label:"Focused nets guides"},{key:"highlight_selected",label:"Highlight selected"}]}),Ve.add({key:"module_view",label:"Module view"}),Ve.add({label:"Debug Graphics",children:[{key:"debug_renderers",label:"Renderers"},{key:"debug_live",label:"Live (don't require pause)",disabledBy:"debug_renderers"},{key:"debug",label:"Tiles"}]}),Ve.render(n.displayControlsEl);let _t=document.createElement("div");_t.className="renderer-controls",n.displayControlsEl.appendChild(_t);function Gt(S){return Promise.all(S.map(({path:L,value:D})=>n.websocketManager.request({type:"set_renderer_control",path:L,value:D}))).catch(()=>{})}function di(S){_t.innerHTML="";let L=new Map;for(let D of S||[]){let A=D.group||"";L.has(A)||L.set(A,[]),L.get(A).push(D)}for(let[D,A]of L){let z=_t;if(D){let I=document.createElement("div");I.className="vis-group";let{header:B,arrow:U,name:Z}=vs();Z.textContent=D;let Q=document.createElement("input");Q.type="checkbox",Q.className="vis-cb",Q.title="Visible";let ye=A.filter(je=>je.visible).length;Q.checked=ye===A.length,Q.indeterminate=ye>0&&ye{let je=Q.checked;Gt(A.filter(Be=>!!Be.visible!==je).map(Be=>({path:Be.path,value:je})))}),B.appendChild(Q),B.appendChild(hr()),I.appendChild(B);let be=document.createElement("div");be.className="vis-group-children",I.appendChild(be),xs(B,U,be,!1),_t.appendChild(I),z=be}for(let I of A){let B=document.createElement("div");B.className="vis-leaf";let U=document.createElement("span");U.className="vis-arrow",U.style.visibility="hidden",U.textContent="\u25B6",B.appendChild(U),B.appendChild(Qo(I.name));let Z=document.createElement("input");Z.type="checkbox",Z.className="vis-cb",Z.title="Visible",Z.checked=!!I.visible,Z.addEventListener("change",()=>Gt([{path:I.path,value:Z.checked}])),B.appendChild(Z),B.appendChild(hr()),z.appendChild(B)}}}n.refreshRendererControls=function(){return!n.websocketManager||fe(n)||!e.debug_renderers?(_t.innerHTML="",Promise.resolve()):n.websocketManager.request({type:"renderer_controls"}).then(S=>di(S.controls)).catch(()=>{})},n.refreshRendererControls();let Mn=document.createElement("div");Mn.className="bg-color-row";let hi=document.createElement("span");hi.textContent="Background";let Ke=document.createElement("input");Ke.type="color",Ke.className="bg-color-input",Ke.title="Layout background color";let Vt=Ge("or_bg_color");Ke.value=Zo(Vt)?Vt:tv(),Ke.addEventListener("input",()=>{document.documentElement.style.setProperty("--bg-map",Ke.value)}),Ke.addEventListener("change",()=>{nM(Ke.value,n)});let un=document.createElement("button");un.className="bg-color-reset",un.textContent="Reset",un.title="Reset background to the theme default",un.addEventListener("click",()=>{iM(n),Ke.value=tv()}),Mn.appendChild(hi),Mn.appendChild(Ke),Mn.appendChild(un),!n.heatMapLayer&&s&&(n.heatMapLayer=s());let An=document.createElement("div");An.className="vis-group heatmap-controls",n.displayControlsEl.appendChild(An);let{header:Rs,arrow:pi,name:yr}=vs("vis-group-header heatmap-header");yr.textContent="Heat Maps",An.appendChild(Rs);let kn=document.createElement("div");kn.className="vis-group-children heatmap-group-children",An.appendChild(kn),xs(Rs,pi,kn,!0),n.displayControlsEl.appendChild(Mn);function Wt(S,L,D,A){let z=document.createElement("label");z.className="heatmap-setting";let I=document.createElement("input");I.type="checkbox",I.checked=D,I.addEventListener("change",()=>A(I.checked)),z.appendChild(I),z.appendChild(document.createTextNode(L)),S.appendChild(z)}function Re(S,L,D,A,z){let I=document.createElement("label");I.className="heatmap-setting";let B=document.createElement("span");B.textContent=L;let U=document.createElement("input");U.type="number",U.value=String(D),U.step=String(A||1),U.addEventListener("change",()=>z(parseFloat(U.value))),I.appendChild(B),I.appendChild(U),S.appendChild(I)}function na(S,L,D,A,z){let I=document.createElement("label");I.className="heatmap-setting";let B=document.createElement("span");B.textContent=L;let U=document.createElement("select");for(let Z of A){let Q=document.createElement("option");Q.value=Z,Q.textContent=Z,Z===D&&(Q.selected=!0),U.appendChild(Q)}U.addEventListener("change",()=>z(U.value)),I.appendChild(B),I.appendChild(U),S.appendChild(I)}function Ce(S){n.websocketManager.request(S).then(L=>{n.updateHeatMaps&&n.updateHeatMaps(L)}).catch(L=>console.error("Heat map update failed",L))}function M(S){if(!n.heatMapLegendEl)return;let L=n.heatMapLegendEl;if(L.innerHTML="",!S||!S.show_legend||!S.legend||S.legend.length===0){L.classList.add("hidden");return}let D=document.createElement("div");D.className="heatmap-map-legend-title",D.textContent=S.title,L.appendChild(D);let A=document.createElement("div");A.className="heatmap-map-legend-units",A.textContent=S.units||"",L.appendChild(A);let z=document.createElement("div");z.className="heatmap-map-legend-list";for(let I of S.legend){let B=document.createElement("div");B.className="heatmap-legend-row";let U=document.createElement("span");U.className="heatmap-legend-swatch",U.style.backgroundColor=`rgba(${I.color[0]}, ${I.color[1]}, ${I.color[2]}, ${I.color[3]/255})`;let Z=document.createElement("span");Z.textContent=I.value,B.appendChild(U),B.appendChild(Z),z.appendChild(B)}L.appendChild(z),L.classList.remove("hidden")}n.renderHeatMapControls=S=>{kn.innerHTML="";let L=document.createElement("div");L.className="heatmap-list",kn.appendChild(L);let D=document.createElement("label");D.className="heatmap-setting";let A=document.createElement("input");A.type="radio",A.name="active-heatmap",A.checked=!S.active,A.addEventListener("change",()=>{Ce({type:"set_active_heatmap",name:""})}),D.appendChild(A),D.appendChild(document.createTextNode("Off")),L.appendChild(D);for(let U of S.heatmaps||[]){let Z=document.createElement("label");Z.className="heatmap-setting";let Q=document.createElement("input");Q.type="radio",Q.name="active-heatmap",Q.checked=U.name===S.active,Q.addEventListener("change",()=>{Ce({type:"set_active_heatmap",name:U.name})}),Z.appendChild(Q),Z.appendChild(document.createTextNode(U.title)),L.appendChild(Z)}let z=(S.heatmaps||[]).find(U=>U.name===S.active);if(M(z),!z)return;let I=document.createElement("div");I.className="heatmap-settings",kn.appendChild(I),Re(I,"Display min",z.display_min,z.display_range_increment,U=>{Ce({type:"set_heatmap",name:z.name,option:"DisplayMin",value:U})}),Re(I,"Display max",z.display_max,z.display_range_increment,U=>{Ce({type:"set_heatmap",name:z.name,option:"DisplayMax",value:U})}),Wt(I,"Show below min",z.draw_below_min,U=>{Ce({type:"set_heatmap",name:z.name,option:"ShowMin",value:U})}),Wt(I,"Show above max",z.draw_above_max,U=>{Ce({type:"set_heatmap",name:z.name,option:"ShowMax",value:U})}),Wt(I,"Log scale",z.log_scale,U=>{Ce({type:"set_heatmap",name:z.name,option:"LogScale",value:U})}),Wt(I,"Reverse log",z.reverse_log,U=>{Ce({type:"set_heatmap",name:z.name,option:"ReverseLog",value:U})}),z.can_adjust_grid&&(Re(I,"Grid X",z.grid_x,.1,U=>{Ce({type:"set_heatmap",name:z.name,option:"GridX",value:U})}),Re(I,"Grid Y",z.grid_y,.1,U=>{Ce({type:"set_heatmap",name:z.name,option:"GridY",value:U})})),Re(I,"Alpha",z.alpha,1,U=>{Ce({type:"set_heatmap",name:z.name,option:"Alpha",value:U})}),Wt(I,"Legend",z.show_legend,U=>{Ce({type:"set_heatmap",name:z.name,option:"ShowLegend",value:U})}),z.supports_numbers&&Wt(I,"Show numbers",z.show_numbers,U=>{Ce({type:"set_heatmap",name:z.name,option:"ShowNumbers",value:U})});for(let U of z.options||[])U.type==="bool"?Wt(I,U.label,U.value,Z=>{Ce({type:"set_heatmap",name:z.name,option:U.name,value:Z})}):U.type==="choice"&&na(I,U.label,U.value,U.choices||[],Z=>{Ce({type:"set_heatmap",name:z.name,option:U.name,value:Z})});z.selection_filter_label&&Wt(I,z.selection_filter_label,z.use_selected_only,U=>{Ce({type:"set_heatmap",name:z.name,option:"use_selected_only",value:U})});let B=document.createElement("button");B.className="or-btn or-btn-sm heatmap-rebuild",B.textContent="Rebuild data",B.addEventListener("click",()=>{Ce({type:"set_heatmap",name:z.name,option:"rebuild",value:1})}),I.appendChild(B)}}var vM="search-nav-dialog",GW=[{label:"Instance",value:"inst"},{label:"Net",value:"net"},{label:"Port",value:"port"}];function Zh(n){if(!n.designScale)return;let e=GW.map(u=>``).join(""),{overlay:t,close:i,okBtn:r,showError:s}=Xo("Find Object",`
`,"Find",yM),o=t.querySelector(".sn-pattern"),a=t.querySelector(".sn-type"),c=t.querySelector(".sn-case");o.focus();function l(){let u=o.value.trim();if(!u){s("Enter a name or glob pattern.");return}n.websocketManager&&(s("Searching\u2026",!0),n.websocketManager.request({type:"find",obj_type:a.value,pattern:u,match_case:c.checked}).then(f=>{qo(n,f);let d=f&&f.count?f.count:0;if(!d){s("No objects found.");return}Array.isArray(f.bbox)&&(n.lastSelectionBounds=f.bbox.slice(0,4),n.view.fitWorldRect(Nt(...n.lastSelectionBounds,n.designScale,n.designOriginX,n.designOriginY))),typeof n.updateInspector=="function"&&n.updateInspector(f),typeof n.redrawAllLayers=="function"&&n.redrawAllLayers();let h=f.selection_count||d;s(f.truncated?`${d} found (showing first ${h}).`:`${d} found.`,!0)}).catch(f=>s("Find failed: "+f)))}return r.addEventListener("click",l),o.addEventListener("keydown",u=>{u.key==="Enter"&&(u.preventDefault(),l())}),{close:i}}function Xh(n){if(!n.designScale||!n.view)return;let e=p=>n.formatDbu(p),t=p=>n.parseDbu(p),i=n.unitLabel(),r=n.view.getCenter(),s=Pn(r[0],r[1],n.designScale,n.designOriginX,n.designOriginY),{overlay:o,close:a,okBtn:c,showError:l}=Xo("Go to Position",` + `,"Find",vM),o=t.querySelector(".sn-pattern"),a=t.querySelector(".sn-type"),c=t.querySelector(".sn-case");o.focus();function l(){let u=o.value.trim();if(!u){s("Enter a name or glob pattern.");return}n.websocketManager&&(s("Searching\u2026",!0),n.websocketManager.request({type:"find",obj_type:a.value,pattern:u,match_case:c.checked}).then(f=>{qo(n,f);let d=f&&f.count?f.count:0;if(!d){s("No objects found.");return}Array.isArray(f.bbox)&&(n.lastSelectionBounds=f.bbox.slice(0,4),n.view.fitWorldRect(Nt(...n.lastSelectionBounds,n.designScale,n.designOriginX,n.designOriginY))),typeof n.updateInspector=="function"&&n.updateInspector(f),typeof n.redrawAllLayers=="function"&&n.redrawAllLayers();let h=f.selection_count||d;s(f.truncated?`${d} found (showing first ${h}).`:`${d} found.`,!0)}).catch(f=>s("Find failed: "+f)))}return r.addEventListener("click",l),o.addEventListener("keydown",u=>{u.key==="Enter"&&(u.preventDefault(),l())}),{close:i}}function Xh(n){if(!n.designScale||!n.view)return;let e=p=>n.formatDbu(p),t=p=>n.parseDbu(p),i=n.unitLabel(),r=n.view.getCenter(),s=Pn(r[0],r[1],n.designScale,n.designOriginX,n.designOriginY),{overlay:o,close:a,okBtn:c,showError:l}=Xo("Go to Position",`
-
`,"Go to",yM),u=o.querySelector(".sn-x"),f=o.querySelector(".sn-y"),d=o.querySelector(".sn-size");u.focus(),u.select();function h(){let p=t(u.value),m=t(f.value);if(p===null||m===null){l(`X and Y must be numbers (${i}).`);return}let g=d.value.trim(),v=g?t(g):null;if(v!==null&&v>0){let y=v/2;n.view.fitWorldRect(Nt(p-y,m-y,p+y,m+y,n.designScale,n.designOriginX,n.designOriginY))}else n.view.setView(Sn(p,m,n.designScale,n.designOriginX,n.designOriginY),n.view.getZoom());a()}c.addEventListener("click",h);for(let p of[u,f,d])p.addEventListener("keydown",m=>{m.key==="Enter"&&(m.preventDefault(),h())});return{close:a}}var bM={ctrl:"ctrl",control:"ctrl",shift:"shift",alt:"alt",meta:"meta",cmd:"meta",command:"meta",super:"meta"};function zW(n){if(typeof n!="string")return null;let e=n.split("+").map(s=>s.trim().toLowerCase()).filter(Boolean);if(e.length===0)return null;let t=e.pop();if(bM[t]!==void 0)return null;let i=new Set;for(let s of e){let o=bM[s];if(o===void 0)return null;i.add(o)}return[...["ctrl","alt","shift","meta"].filter(s=>i.has(s)),t].join("+")}function UW(n){let e=[];return n.ctrlKey&&e.push("ctrl"),n.altKey&&e.push("alt"),n.shiftKey&&e.push("shift"),n.metaKey&&e.push("meta"),[...e,String(n.key).toLowerCase()].join("+")}function xM(n){let e=[{label:"File",items:[{label:"Open DB...",action:()=>vM(n,"Open DB","read_db"),enabledWhen:()=>!n.designScale},{label:"Save DB...",action:()=>vM(n,"Save DB","write_db"),enabledWhen:()=>!!n.designScale}]},{label:"View",items:[{label:"Fit",shortcut:"F",action:()=>{n.fitRect&&n.view.fitWorldRect(n.fitRect)}},{label:"Zoom In",shortcut:"Z",action:()=>n.view.zoomIn()},{label:"Zoom Out",shortcut:"Shift+Z",action:()=>n.view.zoomOut()},{type:"separator"},{label:"Toggle Theme",shortcut:"T",action:()=>n.toggleTheme()},{type:"separator"},{label:"Find...",shortcut:"Ctrl+F",action:()=>Zh(n),enabledWhen:()=>!!n.designScale},{label:"Go to Position...",shortcut:"Shift+G",action:()=>Xh(n),enabledWhen:()=>!!n.designScale}]},{label:"Tools",items:[{label:"Ruler",shortcut:"K",action:()=>{n.rulerManager&&n.rulerManager.toggleRulerMode()}},{label:"Clear Rulers",shortcut:"Shift+K",action:()=>{n.rulerManager&&n.rulerManager.clearAllRulers()}},{type:"separator"},{label:"Add Label",shortcut:"L",action:()=>{n.labelManager&&n.labelManager.toggleLabelMode()}},{label:"Clear Labels",action:()=>{n.labelManager&&n.labelManager.clearAllLabels()}},{type:"separator"},{label:"Clear Highlights",action:()=>{n.websocketManager.request({type:"clear_highlights",group:-1}).then(()=>{n.refreshOverlay&&n.refreshOverlay(),n.refreshInspector&&n.refreshInspector()}).catch(()=>{})}},{type:"separator"},{label:"Global Connect...",action:()=>{n.showGlobalConnectDialog&&n.showGlobalConnectDialog()},enabledWhen:()=>!!n.designScale}]},{label:"Options",items:[{label:"Show DBU",action:()=>n.toggleShowDbu(),checked:()=>n.showDbu},{label:"Make euclidian rulers",action:()=>n.toggleRulerStyle(),checked:()=>n.rulerStyle!=="manhattan"},{type:"separator"},{label:"Mouse wheel mapped to zoom by default",action:()=>n.toggleWheelZoom(),checked:()=>n.wheelZoom},{label:"Arrow keys scroll step...",action:()=>n.showArrowStepDialog()},{label:"Application font...",action:()=>n.showAppFontDialog()},{type:"separator"},{label:"Smooth zoom and pan",action:()=>n.toggleControlSmoothing(),checked:()=>n.controlSmoothing},{label:"Double buffering",action:()=>n.toggleDoubleBuffer(),checked:()=>n.doubleBuffer},{label:"Defer tile updates while panning",action:()=>n.toggleDeferTileUpdates(),checked:()=>n.deferTileUpdates},{type:"separator"},{label:"Show polygon decomposition",action:()=>n.togglePolyDecomp(),checked:()=>n.polyDecomp,enabledWhen:()=>!!n.designScale}]},{label:"Windows",items:[{label:"Layout Viewer",action:()=>n.focusComponent("LayoutViewer")},{label:"3D Viewer",action:()=>n.focusComponent("3DViewer")},{label:"Display Controls",action:()=>n.focusComponent("DisplayControls")},{label:"Inspector",action:()=>n.focusComponent("Inspector")},{label:"Selection Browser",action:()=>n.focusComponent("SelectHighlight")},{label:"Tcl Console",action:()=>n.focusComponent("TclConsole")},{label:"Hierarchy Browser",action:()=>n.focusComponent("Browser")},{label:"Timing",action:()=>n.focusComponent("TimingWidget")},{label:"DRC Viewer",action:()=>n.focusComponent("DRCWidget")},{label:"Clock Tree",action:()=>n.focusComponent("ClockWidget")},{label:"Charts",action:()=>n.focusComponent("ChartsWidget")},{label:"Help",action:()=>n.focusComponent("HelpWidget")},{type:"separator"},{label:"Reset to Default Layout",action:()=>n.resetLayout()}]},{label:"Help",items:[{label:"Keyboard Shortcuts",action:()=>n.focusComponent("HelpWidget")}]}],t=document.getElementById("menu-bar"),i=null,r=new Map;function s(){i&&(i.classList.remove("open"),i=null)}function o(){let l=e.map(h=>({label:h.label,items:h.items.slice()})),u=new Map(l.map(h=>[h.label,h]));function f(h){let p=u.get(h);return p||(p={label:h,items:[]},u.set(h,p),l.push(p)),p}function d(h,p){let m=h.items.find(g=>g.submenu&&g.label===p);return m||(m={label:p,submenu:{label:p,items:[]}},h.items.push(m)),m.submenu}for(let h of n.customMenu||[]){let p=String(h.path||"Custom Scripts").split("/").map(y=>y.trim()).filter(Boolean);p.length===0&&p.push("Custom Scripts");let m=f(p[0]);for(let y=1;yWl(n,h.script,h.echo);m.items.push({label:h.text,shortcut:h.shortcut,action:g});let v=zW(h.shortcut);v&&r.set(v,g)}return l}function a(l,u){for(let f of u){if(f.type==="separator"){let p=document.createElement("div");p.className="menu-separator",l.appendChild(p);continue}let d=document.createElement("div");if(d.className="menu-item",f.submenu){d.classList.add("submenu-item");let p=document.createElement("span");p.textContent=f.label,d.appendChild(p);let m=document.createElement("span");m.className="submenu-arrow",m.textContent="\u25B8",d.appendChild(m);let g=document.createElement("div");g.className="menu-dropdown submenu",a(g,f.submenu.items),d.appendChild(g),l.appendChild(d);continue}if(f.disabled&&d.classList.add("disabled"),f.enabledWhen&&(d._enabledWhen=f.enabledWhen),f.checked){let p=document.createElement("span");p.className="menu-check",p.textContent=f.checked()?"\u2713":"",d.appendChild(p),d._checkedFn=f.checked}let h=document.createElement("span");if(h.textContent=f.label,d.appendChild(h),f.shortcut){let p=document.createElement("span");p.className="shortcut",p.textContent=f.shortcut,d.appendChild(p)}f.action&&d.addEventListener("click",p=>{d.classList.contains("disabled")||(p.stopPropagation(),s(),f.action())}),l.appendChild(d)}}function c(){for(let u of t.querySelectorAll(":scope > .menu-label"))u.remove();let l=t.firstChild;i=null,r.clear();for(let u of o()){let h=function(){for(let p of d.querySelectorAll(".menu-item"))if(p._enabledWhen&&p.classList.toggle("disabled",!p._enabledWhen()),p._checkedFn){let m=p.querySelector(".menu-check");m&&(m.textContent=p._checkedFn()?"\u2713":"")}},f=document.createElement("div");f.className="menu-label",f.textContent=u.label;let d=document.createElement("div");d.className="menu-dropdown",a(d,u.items),f.appendChild(d),f.addEventListener("click",p=>{p.stopPropagation(),i===f?s():(s(),h(),f.classList.add("open"),i=f)}),f.addEventListener("mouseenter",()=>{i&&i!==f&&(s(),h(),f.classList.add("open"),i=f)}),t.insertBefore(f,l)}}c(),n.rebuildMenuBar=c,document.addEventListener("click",s),$W(r)}function $W(n){document.addEventListener("keydown",e=>{if(n.size===0)return;let t=e.target.tagName;if(t==="INPUT"||t==="TEXTAREA"||e.target.isContentEditable)return;let i=n.get(UW(e));i&&(e.preventDefault(),e.stopImmediatePropagation(),i())},!0)}function vM(n,e,t){let i=t==="write_db",r=document.createElement("div");r.className="modal-overlay",r.innerHTML=` +
`,"Go to",vM),u=o.querySelector(".sn-x"),f=o.querySelector(".sn-y"),d=o.querySelector(".sn-size");u.focus(),u.select();function h(){let p=t(u.value),m=t(f.value);if(p===null||m===null){l(`X and Y must be numbers (${i}).`);return}let g=d.value.trim(),v=g?t(g):null;if(v!==null&&v>0){let y=v/2;n.view.fitWorldRect(Nt(p-y,m-y,p+y,m+y,n.designScale,n.designOriginX,n.designOriginY))}else n.view.setView(Sn(p,m,n.designScale,n.designOriginX,n.designOriginY),n.view.getZoom());a()}c.addEventListener("click",h);for(let p of[u,f,d])p.addEventListener("keydown",m=>{m.key==="Enter"&&(m.preventDefault(),h())});return{close:a}}var xM={ctrl:"ctrl",control:"ctrl",shift:"shift",alt:"alt",meta:"meta",cmd:"meta",command:"meta",super:"meta"};function VW(n){if(typeof n!="string")return null;let e=n.split("+").map(s=>s.trim().toLowerCase()).filter(Boolean);if(e.length===0)return null;let t=e.pop();if(xM[t]!==void 0)return null;let i=new Set;for(let s of e){let o=xM[s];if(o===void 0)return null;i.add(o)}return[...["ctrl","alt","shift","meta"].filter(s=>i.has(s)),t].join("+")}function WW(n){let e=[];return n.ctrlKey&&e.push("ctrl"),n.altKey&&e.push("alt"),n.shiftKey&&e.push("shift"),n.metaKey&&e.push("meta"),[...e,String(n.key).toLowerCase()].join("+")}function EM(n){let e=[{label:"File",items:[{label:"Open DB...",action:()=>wM(n,"Open DB","read_db"),enabledWhen:()=>!n.designScale},{label:"Save DB...",action:()=>wM(n,"Save DB","write_db"),enabledWhen:()=>!!n.designScale}]},{label:"View",items:[{label:"Fit",shortcut:"F",action:()=>{n.fitRect&&n.view.fitWorldRect(n.fitRect)}},{label:"Zoom In",shortcut:"Z",action:()=>n.view.zoomIn()},{label:"Zoom Out",shortcut:"Shift+Z",action:()=>n.view.zoomOut()},{type:"separator"},{label:"Toggle Theme",shortcut:"T",action:()=>n.toggleTheme()},{type:"separator"},{label:"Find...",shortcut:"Ctrl+F",action:()=>Zh(n),enabledWhen:()=>!!n.designScale},{label:"Go to Position...",shortcut:"Shift+G",action:()=>Xh(n),enabledWhen:()=>!!n.designScale}]},{label:"Tools",items:[{label:"Ruler",shortcut:"K",action:()=>{n.rulerManager&&n.rulerManager.toggleRulerMode()}},{label:"Clear Rulers",shortcut:"Shift+K",action:()=>{n.rulerManager&&n.rulerManager.clearAllRulers()}},{type:"separator"},{label:"Add Label",shortcut:"L",action:()=>{n.labelManager&&n.labelManager.toggleLabelMode()}},{label:"Clear Labels",action:()=>{n.labelManager&&n.labelManager.clearAllLabels()}},{type:"separator"},{label:"Clear Highlights",action:()=>{n.websocketManager.request({type:"clear_highlights",group:-1}).then(()=>{n.refreshOverlay&&n.refreshOverlay(),n.refreshInspector&&n.refreshInspector()}).catch(()=>{})}},{type:"separator"},{label:"Global Connect...",action:()=>{n.showGlobalConnectDialog&&n.showGlobalConnectDialog()},enabledWhen:()=>!!n.designScale}]},{label:"Options",items:[{label:"Show DBU",action:()=>n.toggleShowDbu(),checked:()=>n.showDbu},{label:"Make euclidian rulers",action:()=>n.toggleRulerStyle(),checked:()=>n.rulerStyle!=="manhattan"},{type:"separator"},{label:"Mouse wheel mapped to zoom by default",action:()=>n.toggleWheelZoom(),checked:()=>n.wheelZoom},{label:"Arrow keys scroll step...",action:()=>n.showArrowStepDialog()},{label:"Application font...",action:()=>n.showAppFontDialog()},{type:"separator"},{label:"Smooth zoom and pan",action:()=>n.toggleControlSmoothing(),checked:()=>n.controlSmoothing},{label:"Double buffering",action:()=>n.toggleDoubleBuffer(),checked:()=>n.doubleBuffer},{label:"Defer tile updates while panning",action:()=>n.toggleDeferTileUpdates(),checked:()=>n.deferTileUpdates},{type:"separator"},{label:"Show polygon decomposition",action:()=>n.togglePolyDecomp(),checked:()=>n.polyDecomp,enabledWhen:()=>!!n.designScale}]},{label:"Windows",items:[{label:"Layout Viewer",action:()=>n.focusComponent("LayoutViewer")},{label:"3D Viewer",action:()=>n.focusComponent("3DViewer")},{label:"Display Controls",action:()=>n.focusComponent("DisplayControls")},{label:"Inspector",action:()=>n.focusComponent("Inspector")},{label:"Selection Browser",action:()=>n.focusComponent("SelectHighlight")},{label:"Tcl Console",action:()=>n.focusComponent("TclConsole")},{label:"Hierarchy Browser",action:()=>n.focusComponent("Browser")},{label:"Timing",action:()=>n.focusComponent("TimingWidget")},{label:"DRC Viewer",action:()=>n.focusComponent("DRCWidget")},{label:"Clock Tree",action:()=>n.focusComponent("ClockWidget")},{label:"Charts",action:()=>n.focusComponent("ChartsWidget")},{label:"Help",action:()=>n.focusComponent("HelpWidget")},{type:"separator"},{label:"Reset to Default Layout",action:()=>n.resetLayout()}]},{label:"Help",items:[{label:"Keyboard Shortcuts",action:()=>n.focusComponent("HelpWidget")}]}],t=document.getElementById("menu-bar"),i=null,r=new Map;function s(){i&&(i.classList.remove("open"),i=null)}function o(){let l=e.map(h=>({label:h.label,items:h.items.slice()})),u=new Map(l.map(h=>[h.label,h]));function f(h){let p=u.get(h);return p||(p={label:h,items:[]},u.set(h,p),l.push(p)),p}function d(h,p){let m=h.items.find(g=>g.submenu&&g.label===p);return m||(m={label:p,submenu:{label:p,items:[]}},h.items.push(m)),m.submenu}for(let h of n.customMenu||[]){let p=String(h.path||"Custom Scripts").split("/").map(y=>y.trim()).filter(Boolean);p.length===0&&p.push("Custom Scripts");let m=f(p[0]);for(let y=1;yWl(n,h.script,h.echo);m.items.push({label:h.text,shortcut:h.shortcut,action:g});let v=VW(h.shortcut);v&&r.set(v,g)}return l}function a(l,u){for(let f of u){if(f.type==="separator"){let p=document.createElement("div");p.className="menu-separator",l.appendChild(p);continue}let d=document.createElement("div");if(d.className="menu-item",f.submenu){d.classList.add("submenu-item");let p=document.createElement("span");p.textContent=f.label,d.appendChild(p);let m=document.createElement("span");m.className="submenu-arrow",m.textContent="\u25B8",d.appendChild(m);let g=document.createElement("div");g.className="menu-dropdown submenu",a(g,f.submenu.items),d.appendChild(g),l.appendChild(d);continue}if(f.disabled&&d.classList.add("disabled"),f.enabledWhen&&(d._enabledWhen=f.enabledWhen),f.checked){let p=document.createElement("span");p.className="menu-check",p.textContent=f.checked()?"\u2713":"",d.appendChild(p),d._checkedFn=f.checked}let h=document.createElement("span");if(h.textContent=f.label,d.appendChild(h),f.shortcut){let p=document.createElement("span");p.className="shortcut",p.textContent=f.shortcut,d.appendChild(p)}f.action&&d.addEventListener("click",p=>{d.classList.contains("disabled")||(p.stopPropagation(),s(),f.action())}),l.appendChild(d)}}function c(){for(let u of t.querySelectorAll(":scope > .menu-label"))u.remove();let l=t.firstChild;i=null,r.clear();for(let u of o()){let h=function(){for(let p of d.querySelectorAll(".menu-item"))if(p._enabledWhen&&p.classList.toggle("disabled",!p._enabledWhen()),p._checkedFn){let m=p.querySelector(".menu-check");m&&(m.textContent=p._checkedFn()?"\u2713":"")}},f=document.createElement("div");f.className="menu-label",f.textContent=u.label;let d=document.createElement("div");d.className="menu-dropdown",a(d,u.items),f.appendChild(d),f.addEventListener("click",p=>{p.stopPropagation(),i===f?s():(s(),h(),f.classList.add("open"),i=f)}),f.addEventListener("mouseenter",()=>{i&&i!==f&&(s(),h(),f.classList.add("open"),i=f)}),t.insertBefore(f,l)}}c(),n.rebuildMenuBar=c,document.addEventListener("click",s),jW(r)}function jW(n){document.addEventListener("keydown",e=>{if(n.size===0)return;let t=e.target.tagName;if(t==="INPUT"||t==="TEXTAREA"||e.target.isContentEditable)return;let i=n.get(WW(e));i&&(e.preventDefault(),e.stopImmediatePropagation(),i())},!0)}function wM(n,e,t){let i=t==="write_db",r=document.createElement("div");r.className="modal-overlay",r.innerHTML=` - `,document.body.appendChild(r);let s=r.querySelector(".fb-breadcrumb"),o=r.querySelector(".fb-file-list"),a=r.querySelector(".fb-path-input"),c=r.querySelector(".modal-error"),l=r.querySelector(".ok"),u=r.querySelector(".cancel"),f="",d=null;function h(){r.remove()}function p(){let b=a.value.trim();l.disabled=!b}function m(b){s.innerHTML="";let x=b.split("/").filter(Boolean),E=document.createElement("span");E.className="fb-crumb",E.textContent="/",E.addEventListener("click",()=>v("/")),s.appendChild(E);let w="";for(let T of x){w+="/"+T;let R=document.createElement("span");R.className="fb-crumb-sep",R.textContent=" / ",s.appendChild(R);let F=document.createElement("span");F.className="fb-crumb",F.textContent=T;let O=w;F.addEventListener("click",()=>v(O)),s.appendChild(F)}}function g(b){if(o.innerHTML="",d=null,!b||b.length===0){let x=document.createElement("div");x.className="fb-empty",x.textContent="(empty directory)",o.appendChild(x);return}for(let x of b){let E=document.createElement("div");E.className="fb-entry",x.is_dir&&E.classList.add("fb-dir");let w=document.createElement("span");w.className="fb-icon",w.textContent=x.is_dir?"\u{1F4C1}":"\u{1F4C4}",E.appendChild(w);let T=document.createElement("span");if(T.className="fb-name",T.textContent=x.name,E.appendChild(T),!x.is_dir&&x.size!==void 0){let R=document.createElement("span");R.className="fb-size",R.textContent=GW(x.size),E.appendChild(R)}x.is_dir?E.addEventListener("click",()=>{v(f+"/"+x.name)}):(E.addEventListener("click",()=>{let R=o.querySelector(".fb-selected");R&&R.classList.remove("fb-selected"),E.classList.add("fb-selected"),d=x,a.value=f+"/"+x.name,p()}),E.addEventListener("dblclick",()=>{a.value=f+"/"+x.name,p(),y()})),o.appendChild(E)}}async function v(b){c.style.display="none",o.innerHTML='
Loading...
';try{let x=await n.websocketManager.request({type:"list_dir",path:b||""});if(f=x.path,m(x.path),g(x.entries),i){let w=a.value.trim().split("/").pop();w&&!w.includes("/")?a.value=f+"/"+w:a.value=f+"/"}else a.value="",d=null;p()}catch(x){o.innerHTML="",c.textContent=x.message||String(x),c.style.display=""}}async function y(){let b=a.value.trim();if(b){l.disabled=!0,l.textContent="Working...",c.style.display="none";try{let x=await n.websocketManager.request({type:"tcl_eval",cmd:`${t} ${b}`});if(x.is_error){c.textContent=x.output||x.result||"Command failed",c.style.display="",l.disabled=!1,l.textContent=i?"Save":"Open";return}if(h(),t==="read_db"){window.location.reload();return}}catch(x){c.textContent=x.message||"Request failed",c.style.display="",l.disabled=!1,l.textContent=i?"Save":"Open"}}}a.addEventListener("input",p),a.addEventListener("keydown",b=>{if(b.key==="Enter"){let x=a.value.trim();x.endsWith("/")?v(x.replace(/\/+$/,"")||"/"):y()}b.key==="Escape"&&h()}),l.addEventListener("click",y),u.addEventListener("click",h),r.addEventListener("click",b=>{b.target===r&&h()}),v("")}function GW(n){return n<1024?n+" B":n<1024*1024?(n/1024).toFixed(1)+" KB":n<1024*1024*1024?(n/(1024*1024)).toFixed(1)+" MB":(n/(1024*1024*1024)).toFixed(1)+" GB"}function wM(n){let e=document.getElementById("toolbar");if(!e)return;n._toolbarToggleState||(n._toolbarToggleState={});function t(){e.innerHTML="";let i=n.customToolbar||[],r=new Set(i.map(s=>s.key));for(let s of Object.keys(n._toolbarToggleState))r.has(s)||delete n._toolbarToggleState[s];for(let s of i){let o=document.createElement("button");if(o.className="or-btn or-btn-sm toolbar-button",o.dataset.key=s.key,s.tooltip&&(o.title=s.tooltip),s.icon){let a=document.createElement("span");if(a.className="toolbar-icon",/^(data:|https?:|\.?\/)/.test(s.icon)){let c=document.createElement("img");c.src=s.icon,c.alt="",a.appendChild(c)}else a.textContent=s.icon;o.appendChild(a)}if(s.text){let a=document.createElement("span");a.className="toolbar-label",a.textContent=s.text,o.appendChild(a)}s.toggle&&n._toolbarToggleState[s.key]&&o.classList.add("active"),o.addEventListener("click",()=>{if(s.toggle){let a=!n._toolbarToggleState[s.key];n._toolbarToggleState[s.key]=a,o.classList.toggle("active",a),Wl(n,a?s.script:s.script_off,s.echo)}else Wl(n,s.script,s.echo)}),e.appendChild(o)}}return t(),n.rebuildToolbar=t,{rebuild:t}}function SM(n,e=""){let t=document.createElement("div");t.className="modal-overlay",t.innerHTML=` + `,document.body.appendChild(r);let s=r.querySelector(".fb-breadcrumb"),o=r.querySelector(".fb-file-list"),a=r.querySelector(".fb-path-input"),c=r.querySelector(".modal-error"),l=r.querySelector(".ok"),u=r.querySelector(".cancel"),f="",d=null;function h(){r.remove()}function p(){let b=a.value.trim();l.disabled=!b}function m(b){s.innerHTML="";let x=b.split("/").filter(Boolean),E=document.createElement("span");E.className="fb-crumb",E.textContent="/",E.addEventListener("click",()=>v("/")),s.appendChild(E);let w="";for(let T of x){w+="/"+T;let R=document.createElement("span");R.className="fb-crumb-sep",R.textContent=" / ",s.appendChild(R);let F=document.createElement("span");F.className="fb-crumb",F.textContent=T;let O=w;F.addEventListener("click",()=>v(O)),s.appendChild(F)}}function g(b){if(o.innerHTML="",d=null,!b||b.length===0){let x=document.createElement("div");x.className="fb-empty",x.textContent="(empty directory)",o.appendChild(x);return}for(let x of b){let E=document.createElement("div");E.className="fb-entry",x.is_dir&&E.classList.add("fb-dir");let w=document.createElement("span");w.className="fb-icon",w.textContent=x.is_dir?"\u{1F4C1}":"\u{1F4C4}",E.appendChild(w);let T=document.createElement("span");if(T.className="fb-name",T.textContent=x.name,E.appendChild(T),!x.is_dir&&x.size!==void 0){let R=document.createElement("span");R.className="fb-size",R.textContent=HW(x.size),E.appendChild(R)}x.is_dir?E.addEventListener("click",()=>{v(f+"/"+x.name)}):(E.addEventListener("click",()=>{let R=o.querySelector(".fb-selected");R&&R.classList.remove("fb-selected"),E.classList.add("fb-selected"),d=x,a.value=f+"/"+x.name,p()}),E.addEventListener("dblclick",()=>{a.value=f+"/"+x.name,p(),y()})),o.appendChild(E)}}async function v(b){c.style.display="none",o.innerHTML='
Loading...
';try{let x=await n.websocketManager.request({type:"list_dir",path:b||""});if(f=x.path,m(x.path),g(x.entries),i){let w=a.value.trim().split("/").pop();w&&!w.includes("/")?a.value=f+"/"+w:a.value=f+"/"}else a.value="",d=null;p()}catch(x){o.innerHTML="",c.textContent=x.message||String(x),c.style.display=""}}async function y(){let b=a.value.trim();if(b){l.disabled=!0,l.textContent="Working...",c.style.display="none";try{let x=await n.websocketManager.request({type:"tcl_eval",cmd:`${t} ${b}`});if(x.is_error){c.textContent=x.output||x.result||"Command failed",c.style.display="",l.disabled=!1,l.textContent=i?"Save":"Open";return}if(h(),t==="read_db"){window.location.reload();return}}catch(x){c.textContent=x.message||"Request failed",c.style.display="",l.disabled=!1,l.textContent=i?"Save":"Open"}}}a.addEventListener("input",p),a.addEventListener("keydown",b=>{if(b.key==="Enter"){let x=a.value.trim();x.endsWith("/")?v(x.replace(/\/+$/,"")||"/"):y()}b.key==="Escape"&&h()}),l.addEventListener("click",y),u.addEventListener("click",h),r.addEventListener("click",b=>{b.target===r&&h()}),v("")}function HW(n){return n<1024?n+" B":n<1024*1024?(n/1024).toFixed(1)+" KB":n<1024*1024*1024?(n/(1024*1024)).toFixed(1)+" MB":(n/(1024*1024*1024)).toFixed(1)+" GB"}function SM(n){let e=document.getElementById("toolbar");if(!e)return;n._toolbarToggleState||(n._toolbarToggleState={});function t(){e.innerHTML="";let i=n.customToolbar||[],r=new Set(i.map(s=>s.key));for(let s of Object.keys(n._toolbarToggleState))r.has(s)||delete n._toolbarToggleState[s];for(let s of i){let o=document.createElement("button");if(o.className="or-btn or-btn-sm toolbar-button",o.dataset.key=s.key,s.tooltip&&(o.title=s.tooltip),s.icon){let a=document.createElement("span");if(a.className="toolbar-icon",/^(data:|https?:|\.?\/)/.test(s.icon)){let c=document.createElement("img");c.src=s.icon,c.alt="",a.appendChild(c)}else a.textContent=s.icon;o.appendChild(a)}if(s.text){let a=document.createElement("span");a.className="toolbar-label",a.textContent=s.text,o.appendChild(a)}s.toggle&&n._toolbarToggleState[s.key]&&o.classList.add("active"),o.addEventListener("click",()=>{if(s.toggle){let a=!n._toolbarToggleState[s.key];n._toolbarToggleState[s.key]=a,o.classList.toggle("active",a),Wl(n,a?s.script:s.script_off,s.echo)}else Wl(n,s.script,s.echo)}),e.appendChild(o)}}return t(),n.rebuildToolbar=t,{rebuild:t}}function CM(n,e=""){let t=document.createElement("div");t.className="modal-overlay",t.innerHTML=` `,document.body.appendChild(t);function i(s){s.key==="Escape"&&r()}let r=()=>{t.remove(),document.removeEventListener("keydown",i)};return t.addEventListener("click",s=>{s.target===t&&r()}),document.addEventListener("keydown",i),{overlay:t,body:t.querySelector(".modal-body"),errorDiv:t.querySelector(".modal-error"),buttons:t.querySelector(".modal-buttons"),close:r}}function ai(n,e){n.textContent=e,n.style.display=e?"":"none"}function Jo(n,e,{primary:t=!1}={}){let i=document.createElement("button");return i.textContent=e,i.className="or-btn"+(t?" or-btn-primary":""),n.appendChild(i),i}function Kh(n){return"{"+String(n)+"}"}function PM(n){let e=SM("Global Connect","gc-dialog"),t=document.createElement("div");t.className="gc-table",e.body.appendChild(t);let i=document.createElement("div");i.className="gc-form";let r=document.createElement("input");r.placeholder="Instance pattern (regex)",r.value=".*";let s=document.createElement("input");s.placeholder="Pin pattern (regex)";let o=document.createElement("select"),a=document.createElement("select"),c=document.createElement("span");c.innerHTML='',i.append(pr("Instance",r),pr("Pin",s),pr("Net",o),pr("Region",a),c);let l=Jo(i,"Add rule");e.body.appendChild(i);function u(){let p=s.value.trim()!==""&&o.value!=="";for(let m of[r,s])try{new RegExp(m.value),m.classList.remove("gc-invalid")}catch{m.classList.add("gc-invalid"),p=!1}l.disabled=!p}r.addEventListener("input",u),s.addEventListener("input",u),o.addEventListener("change",u);function f(){n.websocketManager.request({type:"global_connect_info"}).then(p=>{t.innerHTML='
InstancePinNetRegion
',(p.rules||[]).forEach(m=>{let g=document.createElement("div");g.className="gc-row",g.innerHTML=`${Yl(m.inst)}${Yl(m.pin)}${Yl(m.net)}${Yl(m.region||"All")}`;let v=document.createElement("button");v.className="or-btn or-btn-sm or-btn-icon",v.textContent="\u2715",v.title="Delete rule",v.addEventListener("click",()=>{n.websocketManager.request({type:"global_connect_delete",inst:m.inst,pin:m.pin,net:m.net,region:m.region||""}).then(f).catch(y=>ai(e.errorDiv,String(y)))}),g.appendChild(v),t.appendChild(g)}),cv(o,p.nets||[]),cv(a,["All",...p.regions||[]]),u()}).catch(p=>ai(e.errorDiv,String(p)))}l.addEventListener("click",()=>{let p=i.querySelector('input[name="gc-pg"]:checked').value,m=`add_global_connection -net ${Kh(o.value)} -inst_pattern ${Kh(r.value||".*")} -pin_pattern ${Kh(s.value)} -${p}`;a.value&&a.value!=="All"&&(m+=` -region ${Kh(a.value)}`),EM(n,m,e.errorDiv,"Rule added.",f)}),Jo(e.buttons,"Apply (force)").addEventListener("click",()=>{n.websocketManager.request({type:"global_connect_apply",force:!0}).then(p=>{if(!p.had_rules){ai(e.errorDiv,"No global-connect rules defined \u2014 add a rule first.");return}ai(e.errorDiv,`Connected ${p.connected} pin(s).`),n.scheduleRedrawAllLayers&&n.scheduleRedrawAllLayers(),f()}).catch(p=>ai(e.errorDiv,p.message||String(p)))}),Jo(e.buttons,"Clear all").addEventListener("click",()=>EM(n,"clear_global_connect",e.errorDiv,"Rules cleared.",f)),Jo(e.buttons,"Close").addEventListener("click",e.close),f()}function EM(n,e,t,i,r){n.websocketManager.request({type:"tcl_eval",cmd:e}).then(s=>{if(s.is_error){ai(t,s.output||s.result||"Command failed");return}ai(t,i||""),n.scheduleRedrawAllLayers&&n.scheduleRedrawAllLayers(),r&&r()}).catch(s=>ai(t,s.message||String(s)))}function CM(n,e){let t=SM(`Insert Buffer \u2014 ${Yl(e)}`,"buf-dialog"),i=Jo(t.buttons,"Insert",{primary:!0});i.disabled=!0,Jo(t.buttons,"Cancel").addEventListener("click",t.close),n.websocketManager.request({type:"buffer_info",net:e}).then(s=>{if(!s.can_buffer){t.body.textContent=s.error||"This net has multiple drivers and cannot be buffered.";return}VW(n,t,e,s,i)}).catch(s=>{t.body.textContent=String(s)})}function VW(n,e,t,i,r){let s=document.createElement("div");s.className="buf-pins";let o=i.drivers||[],a=i.loads||[],c=new Set;function l(){s.innerHTML="";let p=(m,g)=>{let v=document.createElement("label");v.className="buf-pin";let y=document.createElement("input");y.type="checkbox",y.checked=c.has(m.id),y.addEventListener("change",()=>{if(y.checked){if(g)c.clear();else for(let b of o)c.delete(b.id);c.add(m.id)}else c.delete(m.id);l(),h()}),v.append(y,document.createTextNode(" "+m.label)),s.appendChild(v)};o.forEach(m=>p(m,!0)),a.forEach(m=>p(m,!1))}o.length&&c.add(o[0].id),l();let u=document.createElement("select");cv(u,i.masters||[]);let f=document.createElement("input");f.placeholder="Optional: new buffer name";let d=document.createElement("input");d.placeholder="Optional: new net name",e.body.append(pr("Pins to buffer",s),pr("Buffer master",u),pr("Buffer name",f),pr("Net name",d));function h(){r.disabled=c.size===0||!u.value}u.addEventListener("change",h),h(),r.addEventListener("click",()=>{let p=new Set(o.map(v=>v.id)),m=[...c],g=m.some(v=>p.has(v))?"driver":"loads";n.websocketManager.request({type:"insert_buffer",net:t,mode:g,pins:m,master:u.value,buf_name:f.value.trim(),net_name:d.value.trim()}).then(v=>{if(v.is_error||v.ok===!1){ai(e.errorDiv,v.error||v.result||"Insertion failed");return}e.close(),v.inst&&(n.selectedInstanceName=v.inst),n.scheduleRedrawAllLayers&&n.scheduleRedrawAllLayers()}).catch(v=>ai(e.errorDiv,v.message||String(v)))})}function pr(n,e){let t=document.createElement("label");t.className="edit-field";let i=document.createElement("span");return i.textContent=n,t.append(i,e),t}function cv(n,e){let t=n.value;n.innerHTML="";for(let i of e){let r=document.createElement("option");r.value=i,r.textContent=i,n.appendChild(r)}e.includes(t)&&(n.value=t)}function Yl(n){return String(n??"").replace(/&/g,"&").replace(//g,">")}var TM="#00ffff",WW="#ffff00",LM="#ffffff",jW=4,Ms=0,lv=1,ql=2,Qh=class{constructor(e,t,i,r){this._app=e,this._visibility=t,this._updateInspector=i,this._focusComponent=r,this._state=Ms,this._rulers=[],this._nextId=0,this._pt0=null,this._selectedRulerId=null,this._ctrlHeld=!1,this._shiftHeld=!1,this._snapTimer=null,this._lastSnapResult=null,this._snapShapes=null,this._preview=null,e.view?.on("zoom",()=>this._renderRulerShapes())}isActive(){return this._state!==Ms}updateVisibility(){this._renderAll(),this._drawTransient()}_shown(){return this._visibility.rulers!==!1}toggleRulerMode(){this._state===Ms?this._enterFirstPoint():this.cancelRulerBuild()}cancelRulerBuild(){this._state=Ms,this._pt0=null,this._lastSnapResult=null,this._clearTransient(),this._setCursor(!1)}clearAllRulers(){this._rulers=[],this._selectedRulerId=null,this._renderAll(),this._clearTransient(),this._state!==Ms&&this.cancelRulerBuild()}_enterFirstPoint(){this._state=lv,this._pt0=null,this._lastSnapResult=null,this._setCursor(!0)}_enterMeasuring(e){this._state=ql,this._pt0=e}_toDbu(e){return Pn(e[0],e[1],this._app.designScale,this._app.designOriginX,this._app.designOriginY)}_toWorld(e,t){return Sn(e,t,this._app.designScale,this._app.designOriginX,this._app.designOriginY)}handleMouseMove(e,t){if(this._state===Ms)return;this._ctrlHeld=t.ctrlKey||t.metaKey,this._shiftHeld=t.shiftKey;let i=this._toDbu(e);this._snapTimer&&clearTimeout(this._snapTimer),this._snapTimer=setTimeout(()=>{this._requestSnap(i.dbuX,i.dbuY)},50)}handleMapClick(e,t){if(this._state===Ms)return;this._ctrlHeld=t.ctrlKey||t.metaKey,this._shiftHeld=t.shiftKey;let i=this._toDbu(e),r=this._getSnappedPoint(i.dbuX,i.dbuY);this._state===lv?this._enterMeasuring(r):this._state===ql&&(this._createRuler(this._pt0,r),this._state=lv,this._pt0=null,this._clearTransient(),this._lastSnapResult=null)}async _requestSnap(e,t){let i=this._app;if(!i.websocketManager||!i.designScale)return;if(this._ctrlHeld){this._lastSnapResult=null,this._snapShapes=null,this._updatePreview(e,t);return}let s=i.techData?.dbu_per_micron||1e3,o=i.view.getZoom(),a=Math.pow(2,Math.max(0,o)),c=1/(i.designScale*a),l=Math.max(Math.round(10*c),10),u=!0,f=!0;if(this._shiftHeld)u=!0,f=!0;else if(this._state===ql&&this._pt0){let h=Math.abs(e-this._pt0.x),p=Math.abs(t-this._pt0.y);h>p?(u=!1,f=!0):p>h&&(u=!0,f=!1)}let d={};for(let[h,p]of Object.entries(this._visibility))d[h]=!!p;try{let h=await i.websocketManager.request({type:"snap",dbu_x:e,dbu_y:t,radius:s,point_threshold:l,horizontal:!!u,vertical:!!f,visible_layers:[...i.visibleLayerNames],...d});this._lastSnapResult=h,this._updateSnapIndicator(h),this._updatePreview(e,t)}catch{this._lastSnapResult=null,this._clearSnap()}}_getSnappedPoint(e,t){if(this._ctrlHeld)return{x:e,y:t};let i=this._lastSnapResult,r;if(i?.found&&i.is_point)r={x:i.edge[0][0],y:i.edge[0][1]};else if(i?.found){let s=i.edge;s[0][1]===s[1][1]?r={x:e,y:s[0][1]}:r={x:s[0][0],y:t}}else r={x:e,y:t};if(!this._shiftHeld&&this._state===ql&&this._pt0){let s=Math.abs(r.x-this._pt0.x),o=Math.abs(r.y-this._pt0.y);sthis._toWorld(r.x,r.y))}}_rulerShapes(e){let t=e.id===this._selectedRulerId,i=Ut(t?WW:TM),{joinPt:r,points:s}=this._rulerPath(e),o=[{kind:"path",points:s,stroke:i,width:2}],a=this._app.view.getZoom(),c=Math.pow(2,Math.max(0,a)),u=8*(1/(this._app.designScale*c)),f=(d,h,p)=>{let m=Math.sqrt(h*h+p*p);if(m===0)return;let g=-p/m,v=h/m;o.push({kind:"path",stroke:i,width:2,points:[this._toWorld(d.x+g*u,d.y+v*u),this._toWorld(d.x-g*u,d.y-v*u)]})};if(r)f(e.pt0,r.x-e.pt0.x,r.y-e.pt0.y),f(e.pt1,e.pt1.x-r.x,e.pt1.y-r.y);else{let d=e.pt1.x-e.pt0.x,h=e.pt1.y-e.pt0.y;f(e.pt0,d,h),f(e.pt1,d,h)}return o}_renderAll(){this._renderRulerShapes(),this._renderRulerLabels()}_renderRulerShapes(){let e=this._app.view;!e||!this._app.designScale||e.setOverlay("rulers",this._shown()?this._rulers.flatMap(t=>this._rulerShapes(t)):null,{order:ot.ruler})}_renderRulerLabels(){let e=this._app.view;if(!(!e||!this._app.designScale)&&(e.clearMarkers("ruler-labels"),!!this._shown()))for(let t of this._rulers){let{joinPt:i,points:r}=this._rulerPath(t),s=i?r[1]:[(r[0][0]+r[1][0])/2,(r[0][1]+r[1][1])/2],o=this._computeDistance(t.pt0,t.pt1,t.euclidian);e.addMarker("ruler-labels",t.id,s,this._labelElement(this._formatDistance(o)))}}handleRulerClick(e){let t=this._app.view;if(!t||!this._shown()||this._rulers.length===0)return!1;let i=t.project(e);for(let r of this._rulers){let s=this._rulerPath(r).points.map(o=>t.project(o));for(let o=0;o+1l.id===e);if(!t)return;Pt(this._app);let i=Math.abs(t.pt1.x-t.pt0.x),r=Math.abs(t.pt1.y-t.pt0.y),s=t.euclidian?Math.sqrt(i*i+r*r):i+r,o=l=>this._app.formatDbu(l,!0),a=l=>this._app.parseDbu(l),c={type:"Ruler",name:t.name,bbox:[Math.min(t.pt0.x,t.pt1.x),Math.min(t.pt0.y,t.pt1.y),Math.max(t.pt0.x,t.pt1.x),Math.max(t.pt0.y,t.pt1.y)],properties:[{name:"Name",value:t.name,editable:!0},{name:"Label",value:t.label||"",editable:!0},{name:"Point 0 - x",value:o(t.pt0.x),editable:!0},{name:"Point 0 - y",value:o(t.pt0.y),editable:!0},{name:"Point 1 - x",value:o(t.pt1.x),editable:!0},{name:"Point 1 - y",value:o(t.pt1.y),editable:!0},{name:"Delta x",value:o(i)},{name:"Delta y",value:o(r)},{name:"Length",value:o(s)},{name:"Euclidian",value:t.euclidian?"True":"False",editable:!0,editor:{type:"bool"}}],onPropertyChange:(l,u)=>{switch(l){case"Name":t.name=u;break;case"Label":t.label=u;break;case"Point 0 - x":{let f=a(u);f!==null&&(t.pt0.x=f);break}case"Point 0 - y":{let f=a(u);f!==null&&(t.pt0.y=f);break}case"Point 1 - x":{let f=a(u);f!==null&&(t.pt1.x=f);break}case"Point 1 - y":{let f=a(u);f!==null&&(t.pt1.y=f);break}case"Euclidian":t.euclidian=u.trim().toLowerCase()==="true";break}this._renderAll(),this._selectRuler(t.id)}};this._updateInspector(c),this._focusComponent("Inspector"),requestAnimationFrame(()=>{let l=this._app.inspectorEl?.querySelector(".inspector-toolbar");if(!l)return;let u=document.createElement("button");u.className="or-btn or-btn-icon",u.title="Delete ruler",u.innerHTML='',u.addEventListener("click",()=>{this.deleteRuler(e)}),l.appendChild(u)})}deleteRuler(e){let t=this._rulers.findIndex(i=>i.id===e);t!==-1&&(this._rulers.splice(t,1),this._renderAll(),this._selectedRulerId===e&&(this._selectedRulerId=null,this._updateInspector(null)))}_getManhattanJoinPt(e,t){return{x:t.x,y:e.y}}_computeDistance(e,t,i=!0){let r=Math.abs(t.x-e.x),s=Math.abs(t.y-e.y);return i?Math.sqrt(r*r+s*s):r+s}_formatDistance(e){return this._app.formatDistance(e)}_setCursor(e){this._app.view?.setCursorMode("ruler",e)}_clearTransient(){this._preview=null,this._snapShapes=null,this._drawTransient()}_clearSnap(){this._snapShapes=null,this._drawTransient()}};function HW(n,e,t){let i=t[0]-e[0],r=t[1]-e[1],s=i*i+r*r,o=s>0?((n[0]-e[0])*i+(n[1]-e[1])*r)/s:0;return o=Math.max(0,Math.min(1,o)),Math.hypot(n[0]-(e[0]+o*i),n[1]-(e[1]+o*r))}var Jh="label-handles",MM=3,ep=class{constructor(e,t,i,r){this._app=e,this._visibility=t,this._updateInspector=i,this._focusComponent=r,this._labels=[],this._anchors=[],this._mode=!1,this._selectedName=null}isActive(){return this._mode}updateVisibility(){this._app.view?.setMarkerGroupVisible(Jh,!!this._visibility.labels)}toggleLabelMode(){this._mode=!this._mode,this._setCursor(this._mode)}cancelLabelMode(){this._mode=!1,this._setCursor(!1)}_setCursor(e){this._app.view?.setCursorMode("label",e)}_wm(){return this._app.websocketManager}_applyLabels(e){this._labels=e||[],this._renderHandles()}_refresh(e){this._applyLabels(e&&e.labels),this._app.refreshOverlay()}applyRemoteLabels(e){this._applyLabels(e),this._selectedName&&!this._labels.some(t=>t.name===this._selectedName)&&(this._selectedName=null,this._updateInspector(null),this._renderHandles()),this._app.refreshOverlay()}_updateLabel(e,t){return this._wm().request({type:"update_label",name:e,...t})}async reload(){let e=this._wm();if(e)try{let t=await e.request({type:"list_labels"});this._anchors=t.anchors||[],this._applyLabels(t.labels)}catch{this._applyLabels([])}}async handleMapClick(e,t){let i=window.prompt("Label text:");if(this._mode=!1,this._setCursor(!1),!!i)try{let r=await this._wm().request({type:"add_label",x:Math.round(e),y:Math.round(t),text:i});this._refresh(r)}catch(r){console.error("add_label failed:",r)}}_renderHandles(){let e=this._app.view;if(!e)return;e.clearMarkers(Jh);let t=this._app;if(t.designScale)for(let i of this._labels){let r=document.createElement("div");r.className="label-handle"+(i.name===this._selectedName?" label-handle-selected":""),r.title=i.text,this._installDrag(r,i),e.addMarker(Jh,i.name,Sn(i.x,i.y,t.designScale,t.designOriginX,t.designOriginY),r,{center:!0})}}_installDrag(e,t){let i=this._app.view,r=a=>{let c=i.getContainer().getBoundingClientRect();return i.unproject([a.clientX-c.left,a.clientY-c.top])},s=null;e.addEventListener("pointerdown",a=>{a.button===0&&(a.stopPropagation(),a.preventDefault(),e.setPointerCapture?.(a.pointerId),s={x:a.clientX,y:a.clientY,moved:!1})}),e.addEventListener("pointermove",a=>{s&&((Math.abs(a.clientX-s.x)>MM||Math.abs(a.clientY-s.y)>MM)&&(s.moved=!0),s.moved&&i.moveMarker(Jh,t.name,r(a)))});let o=(a,c)=>{if(!s)return;let l=s;if(s=null,e.releasePointerCapture?.(a.pointerId),!c)this._renderHandles();else if(!l.moved)this._select(t.name);else{let u=this._app,[f,d]=r(a),{dbuX:h,dbuY:p}=Pn(f,d,u.designScale,u.designOriginX,u.designOriginY);this._commitMove(t,Math.round(h),Math.round(p))}};e.addEventListener("pointerup",a=>o(a,!0)),e.addEventListener("pointercancel",a=>o(a,!1)),e.addEventListener("click",a=>a.stopPropagation())}async _commitMove(e,t,i){try{let r=await this._updateLabel(e.name,{x:t,y:i,text:e.text,size:e.size||0,anchor:e.anchor||"center",color:e.color});this._refresh(r)}catch(r){console.error("move label failed:",r)}}_select(e){this._selectedName=e,this._renderHandles();let t=this._labels.find(s=>s.name===e);if(!t)return;let i=s=>this._app.formatDbu(s,!0),r={type:"Label",name:t.name,bbox:[t.x,t.y,t.x,t.y],properties:[{name:"Name",value:t.name},{name:"Text",value:t.text,editable:!0},{name:"x",value:i(t.x)},{name:"y",value:i(t.y)},{name:"Font size",value:String(t.size||0),editable:!0},{name:"Anchor",value:t.anchor||"center",editable:!0,editor:{type:"list",options:this._anchors}}],onPropertyChange:(s,o)=>{let a={text:t.text,size:t.size||0,anchor:t.anchor||"center"};s==="Text"?a.text=o:s==="Font size"?a.size=parseInt(o,10)||0:s==="Anchor"&&(a.anchor=o.trim()),this._edit(t,a)}};this._updateInspector(r),this._focusComponent("Inspector"),requestAnimationFrame(()=>{let s=this._app.inspectorEl?.querySelector(".inspector-toolbar");if(!s||s.querySelector(".delete-label-btn"))return;let o=document.createElement("button");o.className="or-btn or-btn-icon delete-label-btn",o.title="Delete label",o.innerHTML='',o.addEventListener("click",()=>this.deleteLabel(e)),s.appendChild(o)})}async _edit(e,t){try{let i=await this._updateLabel(e.name,{x:e.x,y:e.y,text:t.text,size:t.size,anchor:t.anchor,color:e.color});this._refresh(i),this._select(e.name)}catch(i){console.error("edit label failed:",i)}}async deleteLabel(e){try{let t=await this._wm().request({type:"delete_label",name:e});this._selectedName===e&&(this._selectedName=null,this._updateInspector(null)),this._refresh(t)}catch(t){console.error("delete_label failed:",t)}}async clearAllLabels(){try{let e=await this._wm().request({type:"clear_labels"});this._selectedName=null,this._refresh(e)}catch(e){console.error("clear_labels failed:",e)}}};var AM="Select an instance in the layout to view its schematic.",tp=class{constructor(e,t){this.container=e,this.appState=t,this.element=document.createElement("div"),this.element.className="schematic-widget",this.element.style.cssText="width:100%; height:100%; display:flex; flex-direction:column; background:var(--bg-panel); color:var(--fg-primary); overflow:hidden;",this.controls=document.createElement("div"),this.controls.style.cssText="padding:4px 8px; background:var(--bg-header); border-bottom:1px solid var(--border);flex-shrink:0; display:flex; align-items:center; gap:8px; flex-wrap:wrap;",this.controls.innerHTML='',this.element.appendChild(this.controls),this.svgContainer=document.createElement("div"),this.svgContainer.style.cssText="flex:1; overflow:hidden; position:relative; cursor:grab; background:var(--bg-main);",this.element.appendChild(this.svgContainer),this.container.element.appendChild(this.element),this.controls.querySelector("#schematic-refresh").addEventListener("click",()=>this.refresh()),this.controls.querySelector("#schematic-fit").addEventListener("click",()=>this.fitView()),this.controls.querySelector("#schematic-zoom-in").addEventListener("click",()=>this._zoomStep(1.5)),this.controls.querySelector("#schematic-zoom-out").addEventListener("click",()=>this._zoomStep(1/1.5)),this.controls.querySelector("#schematic-select").addEventListener("click",()=>this._toggleSelectMode()),this.controls.querySelector("#schematic-zoom-to").addEventListener("click",()=>this._zoomToSelected()),this.controls.querySelector("#schematic-save-svg").addEventListener("click",()=>this._exportSvg()),this.controls.querySelector("#schematic-save-png").addEventListener("click",()=>this._exportPng()),this.controls.querySelector("#schematic-copy").addEventListener("click",()=>this._copyImage()),this.appState.schematicWidget=this,this.netlistsvg=null,this.skin=null,this._svgEl=null,this._scale=1,this._panX=0,this._panY=0,this._selectMode=!1,this._selectedCell=null,this._svgIdToInstName=new Map,this._setupPanZoom(),this.initNetlistSVG()}_setupPanZoom(){let e=this.svgContainer,t=!1,i,r,s,o;e.addEventListener("wheel",a=>{if(!this._svgEl)return;a.preventDefault();let c=a.deltaY<0?1.2:1/1.2,l=e.getBoundingClientRect(),u=a.clientX-l.left,f=a.clientY-l.top;this._panX=u+(this._panX-u)*c,this._panY=f+(this._panY-f)*c,this._scale*=c,this._applyTransform()},{passive:!1}),e.addEventListener("mousedown",a=>{if(!(!this._svgEl||a.button!==0)){if(this._selectMode){this._handleSelectClick(a);return}t=!0,i=a.clientX,r=a.clientY,s=this._panX,o=this._panY,e.style.cursor="grabbing",a.preventDefault()}}),window.addEventListener("mousemove",a=>{t&&(this._panX=s+(a.clientX-i),this._panY=o+(a.clientY-r),this._applyTransform())}),window.addEventListener("mouseup",()=>{t&&(t=!1,e.style.cursor=this._selectMode?"default":"grab")})}_zoomStep(e){if(!this._svgEl)return;let t=this.svgContainer.getBoundingClientRect(),i=t.width/2,r=t.height/2;this._panX=i+(this._panX-i)*e,this._panY=r+(this._panY-r)*e,this._scale*=e,this._applyTransform()}_toggleSelectMode(){this._selectMode=!this._selectMode;let e=this.controls.querySelector("#schematic-select");this._selectMode?(e.style.background="var(--accent)",e.style.color="var(--fg-white)",this.svgContainer.style.cursor="default"):(e.style.background="",e.style.color="",this.svgContainer.style.cursor="grab",this._clearCellHighlight())}_handleSelectClick(e){if(!this._svgEl)return;let t=e.target,i=null;for(;t&&t!==this._svgEl;){if(t.tagName==="g"&&t.id&&this._svgIdToInstName.has(t.id)){i=t;break}t=t.parentElement}if(this._clearCellHighlight(),!i)return;let r=this._svgIdToInstName.get(i.id);try{let s=i.getBBox(),o=3,a=document.createElementNS("http://www.w3.org/2000/svg","rect");a.setAttribute("x",s.x-o),a.setAttribute("y",s.y-o),a.setAttribute("width",s.width+o*2),a.setAttribute("height",s.height+o*2),a.setAttribute("fill","none"),a.setAttribute("stroke","#e05a00"),a.setAttribute("stroke-width","1.5"),a.setAttribute("rx","3"),a.id="_schematic_highlight",i.appendChild(a),this._selectedCell=i}catch{}this.controls.querySelector("#schematic-zoom-to").disabled=!1,this.setStatus(`Selected: ${r}`),this._fetchInspect(r)}_fetchInspect(e){let t=this.appState.websocketManager;if(!t)return;console.log("[Schematic] inspect:",e);let i=Pt(this.appState);t.request({type:"schematic_inspect",inst_name:e,use_dbu:this.appState.showDbu}).then(r=>{zt(this.appState,i)&&(this.appState.updateInspector&&this.appState.updateInspector(r),this.appState.focusComponent&&this.appState.focusComponent("Inspector"),this.appState.refreshOverlay&&this.appState.refreshOverlay())}).catch(r=>{console.error("schematic_inspect failed:",r),this.setStatus(`Inspect error: ${r}`)})}_clearCellHighlight(){if(this._svgEl){let e=this._svgEl.querySelector("#_schematic_highlight");e&&e.remove()}this._selectedCell=null,this.controls.querySelector("#schematic-zoom-to").disabled=!0}_zoomToSelected(){if(!this._selectedCell||!this._svgEl)return;let e=this.svgContainer.getBoundingClientRect(),t=this._selectedCell.getBoundingClientRect(),i=(t.left-e.left-this._panX)/this._scale,r=(t.top-e.top-this._panY)/this._scale,s=t.width/this._scale,o=t.height/this._scale,a=Math.min(e.width/s,e.height/o)*.9;this._scale=a,this._panX=e.width/2-(i+s/2)*a,this._panY=e.height/2-(r+o/2)*a,this._applyTransform()}_applyTransform(){this._svgEl&&(this._svgEl.style.transform=`translate(${this._panX}px, ${this._panY}px) scale(${this._scale})`,this._svgEl.style.transformOrigin="0 0")}fitView(){if(!this._svgEl)return;let e=this.svgContainer.getBoundingClientRect();if(e.width===0||e.height===0)return;let t=this._svgEl.viewBox&&this._svgEl.viewBox.baseVal,i=t&&t.width||this._svgEl.clientWidth||1,r=t&&t.height||this._svgEl.clientHeight||1;this._scale=Math.min(e.width/i,e.height/r)*.95,this._panX=(e.width-i*this._scale)/2,this._panY=(e.height-r*this._scale)/2,this._applyTransform()}initNetlistSVG(){this.netlistsvg=globalThis.netlistsvg,this.skin=globalThis.openroadSkin,this._netlistsvgReady=!!(this.netlistsvg&&this.skin),this._netlistsvgReady&&console.log("NetlistSVG ready."),this.setStatus(this._unreadyStatus()??AM)}_unreadyStatus(){return this._netlistsvgReady?null:fe(this.appState)?"The schematic is not available in saved reports.":"Init error: netlistsvg or its skin is missing from the page."}syncCone(e={}){let t=this.controls.querySelector("#schematic-fanin-depth"),i=this.controls.querySelector("#schematic-fanout-depth"),r=(s,o,a)=>{if(!s)return;let c=parseInt(s.max,10)||10;o===!1?s.value=0:a!==void 0&&(s.value=a>0?Math.min(a,c):c)};r(t,e.fanin,e.fanin_depth),r(i,e.fanout,e.fanout_depth),this.refresh(),this.appState.focusComponent&&this.appState.focusComponent("SchematicWidget")}refresh(){if(!this._netlistsvgReady){this.setStatus(this._unreadyStatus());return}let e=this.appState.selectedInstanceName;if(!e){this.setStatus(AM);return}let t=this.appState.websocketManager;if(!t){this.setStatus("Waiting for server connection\u2026");return}this.setStatus(`Loading schematic for ${e}\u2026`);let i=parseInt(this.controls.querySelector("#schematic-fanin-depth").value,10),r=parseInt(this.controls.querySelector("#schematic-fanout-depth").value,10),s=isNaN(i)?1:i,o=isNaN(r)?1:r;t.readyPromise.then(()=>{t.request({type:"schematic_cone",inst_name:e,fanin_depth:s,fanout_depth:o}).then(a=>{let c=a.modules&&a.modules.top&&a.modules.top.cells;if(!c||Object.keys(c).length===0){this.setStatus("No cells found for selected instance.");return}this.renderNetlist(a)}).catch(a=>{this.setStatus(`Error: ${a}`)})})}setStatus(e){this.controls.querySelector("#schematic-status").textContent=e}_exportSvg(){if(!this._svgEl){this.setStatus("No schematic to export.");return}let e=nv(this._svgEl);iM(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),"schematic.svg")}async _exportPng(){if(!this._svgEl){this.setStatus("No schematic to export.");return}try{let e=await iv(this._svgEl,2);Ts(e,"schematic.png")}catch{this.setStatus("PNG export failed.")}}async _copyImage(){if(!this._svgEl){this.setStatus("No schematic to export.");return}try{let e=await iv(this._svgEl,2),t=await Fh(e);this.setStatus(t?"Schematic copied to clipboard.":"Clipboard not available.")}catch{this.setStatus("Copy failed.")}}async renderNetlist(e){try{this.setStatus("Rendering\u2026"),typeof window<"u"&&(window.__lastSchematic=e);let t=KW(e),i,r=this.netlistsvg.render(this.skin,t);if(r&&typeof r.then=="function"?i=await r:i=await new Promise((a,c)=>{this.netlistsvg.render(this.skin,t,(l,u)=>{l?c(l):a(u)})}),typeof i!="string"||!i.includes("requestAnimationFrame(()=>this.fitView()));let o=Object.keys(e.modules.top.cells).length;this.setStatus(`${o} cell${o!==1?"s":""}`)}catch(t){console.error("NetlistSVG render failed:",t),this.setStatus(`Render error: ${t.message||t}`)}}_applyPinLabels(e){if(!this._svgEl)return;let t="http://www.w3.org/2000/svg",i="https://github.com/nturley/netlistsvg",r=e.modules&&e.modules.top&&e.modules.top.cells||{},s=(o,a)=>o.getAttribute("s:"+a)??o.getAttributeNS(i,a);for(let[o,a]of Object.entries(r)){let c=a.port_labels;if(!c)continue;let l=this._svgEl.querySelector("#"+CSS.escape("cell_"+o))||this._svgEl.querySelector("#"+CSS.escape(o));if(!l)continue;let u=a.port_directions||{};for(let f of Array.from(l.children)){if(f.tagName!=="g")continue;let d=s(f,"pid");if(!d||!(d in c))continue;let h=parseFloat(s(f,"x")),p=parseFloat(s(f,"y"));if(!isFinite(h)||!isFinite(p))continue;let m=document.createElementNS(t,"text");u[d]==="input"?(m.setAttribute("class","inputPortLabel"),m.setAttribute("x",h-3)):m.setAttribute("x",h+4),m.setAttribute("y",p-4),m.setAttribute("style","font-size:5px"),m.setAttribute("pointer-events","none"),m.textContent=c[d],l.appendChild(m)}}}_scopeSkinStyles(){if(!this._svgEl)return;let e=".schematic-widget",t=i=>{for(let r of i)r.selectorText?r.selectorText=YW(r.selectorText,e):r.cssRules&&t(r.cssRules)};for(let i of this._svgEl.querySelectorAll("style")){let r=i.sheet;if(r)try{t(r.cssRules)}catch{continue}}}};function YW(n,e){return n.split(",").map(t=>{let i=t.trim();if(!i)return"";let r=i.charAt(e.length);return i.startsWith(e)&&(r===""||!/[\w-]/.test(r))?i:`${e} ${i}`}).filter(Boolean).join(", ")}var kM={and:"$_AND_",nand:"$_NAND_",or:"$_OR_",nor:"$_NOR_",xor:"$_XOR_",xnor:"$_XNOR_",not:"$_NOT_",buf:"$_BUF_"},qW=new Set(["aoi21","aoi22","aoi211","aoi221","aoi222","aoi33","oai21","oai22","oai211","oai221","oai222","oai33"]),ZW=new Set(["and3","and4","or3","or4","nand3","nand4","nor3","nor4"]),RM=["A","B","C","D","E","F"];function XW(n){let e=n&&n.gate_kind;if(!e)return n;let t=n.port_directions||{},i=null,r=[];for(let[f,d]of Object.entries(t))d==="output"&&i===null?i=f:d==="input"&&r.push(f);let s,o={};if(e==="aoi"||e==="oai"){let f=Array.isArray(n.gate_terms)?n.gate_terms:[];if(!f.length)return n;let d=f.map(m=>m.length);if(s=e+d.slice().sort((m,g)=>g-m).join(""),!qW.has(s))return n;let h=f.map(m=>m.slice()).sort((m,g)=>m.length-g.length),p=0;for(let m of h)for(let g of m)o[g]=RM[p]||"I"+p,p++}else{let f=r.length;if(e==="not"||e==="buf")s=kM[e];else if(f<=2)s=kM[e];else if(s=e+f,!ZW.has(s))return n;if(!s)return n;r.forEach((d,h)=>{o[d]=RM[h]||"I"+h})}i!==null&&(o[i]="Y");let a=n.connections||{},c={},l={};for(let[f,d]of Object.entries(a))o[f]&&(c[o[f]]=d);for(let[f,d]of Object.entries(t))o[f]&&(l[o[f]]=d);let u={};for(let[f,d]of Object.entries(o))u[d]=f;return{...n,type:s,connections:c,port_directions:l,port_labels:u}}function KW(n){let e=n&&n.modules&&n.modules.top;if(!e||!e.cells)return n;let t={};for(let[i,r]of Object.entries(e.cells))t[i]=XW(r);return{...n,modules:{...n.modules,top:{...e,cells:t}}}}var np=class{constructor(e,t,i){this._app=e,this._redrawAllLayers=t,this._refreshOverlay=i||t,this._categories=[],this._activeCategory="",this._markerTree=null,this._expandedNodes=new Set,this._build(),this._app.websocketManager.readyPromise.then(()=>this.refresh())}_build(){let e=document.createElement("div");e.className="drc-widget";let t=document.createElement("div");t.className="drc-toolbar",this._categorySelect=document.createElement("select"),this._categorySelect.className="drc-category-select",t.appendChild(this._categorySelect),this._loadBtn=document.createElement("button"),this._loadBtn.className="or-btn or-btn-sm",this._loadBtn.textContent="Load...",t.appendChild(this._loadBtn),e.appendChild(t),this._infoBar=document.createElement("div"),this._infoBar.className="drc-info-bar",e.appendChild(this._infoBar),this._treeContainer=document.createElement("div"),this._treeContainer.className="drc-tree-container",e.appendChild(this._treeContainer),this.element=e,this._bindEvents()}_bindEvents(){this._categorySelect.addEventListener("change",()=>{this._activeCategory=this._categorySelect.value,this._loadMarkers()}),this._loadBtn.addEventListener("click",()=>{this._showLoadDialog()})}_loadCategories(){return this._app.websocketManager.request({type:"drc_categories"}).then(e=>{this._categories=e.categories||[],this._renderCategorySelect()}).catch(e=>{console.error("Failed to load DRC categories:",e)})}refresh(){this._loadCategories().then(()=>{!this._activeCategory&&this._categories.length>0&&(this._activeCategory=this._categories[0].name,this._categorySelect.value=this._activeCategory),this._activeCategory&&this._loadMarkers()})}_renderCategorySelect(){let e=this._categorySelect,t=e.value;e.innerHTML="";let i=document.createElement("option");i.value="",i.textContent="(none)",e.appendChild(i);for(let r of this._categories){let s=document.createElement("option");s.value=r.name,s.textContent=`${r.name} (${r.count})`,e.appendChild(s)}this._activeCategory&&this._categories.some(r=>r.name===this._activeCategory)?e.value=this._activeCategory:t&&this._categories.some(r=>r.name===t)?(e.value=t,this._activeCategory=t):this._activeCategory=""}_loadMarkers(){if(!this._activeCategory){this._markerTree=null,this._treeContainer.innerHTML="",this._infoBar.textContent="",this._refreshOverlay();return}this._treeContainer.innerHTML='
Loading...
',this._app.websocketManager.request({type:"drc_markers",category:this._activeCategory}).then(e=>{this._markerTree=e,this._renderTree(),this._refreshOverlay()}).catch(e=>{this._treeContainer.innerHTML="";let t=document.createElement("div");t.className="drc-error",t.textContent=`Error: ${e}`,this._treeContainer.appendChild(t),console.error("Failed to load DRC markers:",e)})}_renderTree(){if(this._treeContainer.innerHTML="",!this._markerTree)return;if(this._markerTree.error){let o=document.createElement("div");o.className="drc-error",o.textContent=this._markerTree.error,this._treeContainer.appendChild(o);return}let e=this._markerTree.total_count||0;this._infoBar.textContent=`${e} total violation${e!==1?"s":""}`;let t=this._markerTree.name||this._activeCategory,i=this._markerTree.subcategories||[],r=this._markerTree.markers||[];if(i.length===0&&r.length===0){this._treeContainer.innerHTML='
No violations
';return}let s=document.createElement("div");s.className="drc-tree",r.length>0&&s.appendChild(this._buildCategoryNode({name:t||"Markers",count:r.length,markers:r},[]));for(let o of i)s.appendChild(this._buildCategoryNode(o,[t]));this._treeContainer.appendChild(s)}_buildCategoryNode(e,t=[]){let i=[...t,e.name],r=document.createElement("div");r.className="drc-tree-node";let s=document.createElement("div");s.className="drc-tree-header";let o=document.createElement("span");o.className="drc-toggle";let a=e.subcategories&&e.subcategories.length>0||e.markers&&e.markers.length>0,c=JSON.stringify(i),l=this._expandedNodes.has(c);o.textContent=a?l?"\u25BC":"\u25B6":" ",s.appendChild(o);let u=document.createElement("input");u.type="checkbox",u.checked=this._allMarkersVisible(e),u.className="drc-visibility-check",u.addEventListener("change",p=>{p.stopPropagation(),this._toggleCategoryVisibility(e,u.checked,i)}),s.appendChild(u);let f=document.createElement("span");f.className="drc-category-label",f.textContent=e.name,s.appendChild(f);let d=document.createElement("span");d.className="drc-count",d.textContent=`${e.count} markers`,s.appendChild(d),r.appendChild(s);let h=document.createElement("div");if(h.className="drc-tree-children",h.style.display=l?"":"none",e.subcategories)for(let p of e.subcategories)h.appendChild(this._buildCategoryNode(p,i));if(e.markers)for(let p of e.markers)h.appendChild(this._buildMarkerNode(p));return r.appendChild(h),a&&(s.addEventListener("click",p=>{if(p.target===u)return;let m=h.style.display!=="none";h.style.display=m?"none":"",o.textContent=m?"\u25B6":"\u25BC",m?this._expandedNodes.delete(c):this._expandedNodes.add(c)}),s.style.cursor="pointer"),r}_buildMarkerNode(e){let t=document.createElement("div");t.className="drc-marker-row",t.dataset.markerId=e.id,e.visited||t.classList.add("drc-unvisited");let i=document.createElement("input");i.type="checkbox",i.checked=e.visible,i.className="drc-visibility-check",i.addEventListener("change",o=>{o.stopPropagation(),e.visible=i.checked,this._updateMarker(e.id,"visible",i.checked)}),t.appendChild(i);let r=document.createElement("span");r.className="drc-marker-index",r.textContent=e.index,t.appendChild(r);let s=document.createElement("span");if(s.className="drc-marker-name",s.textContent=e.name,e.layer&&(s.title=`Layer: ${e.layer}`),t.appendChild(s),e.layer){let o=document.createElement("span");o.className="drc-layer-badge",o.textContent=e.layer,t.appendChild(o)}return t.addEventListener("click",o=>{o.target!==i&&this._highlightMarker(e)}),t.addEventListener("dblclick",o=>{o.target!==i&&this._highlightMarker(e,!0)}),t}highlightMarkerById(e,t=!1){let i=this._findMarkerById(e);i&&this._highlightMarker(i,t)}_findMarkerById(e){let t=i=>{if(!i)return null;if(i.markers){for(let r of i.markers)if(r.id===e)return r}if(i.subcategories)for(let r of i.subcategories){let s=t(r);if(s)return s}return null};return t(this._markerTree)}_highlightMarker(e,t=!1){this._app.websocketManager.request({type:"drc_highlight",marker_id:e.id,open_inspector:t}).then(i=>{if(i.ok&&i.bbox){e.visited=!0;let r=this._treeContainer.querySelector(`.drc-marker-row[data-marker-id="${e.id}"]`);r&&r.classList.remove("drc-unvisited"),this._zoomToBBox(i.bbox),this._refreshOverlay(),t&&(i.select_id!=null&&this._app.navigateInspector&&this._app.navigateInspector(i.select_id),this._app.focusComponent&&this._app.focusComponent("Inspector"))}}).catch(i=>{console.error("Failed to highlight DRC marker:",i)})}_zoomToBBox(e){if(!this._app.designScale||!this._app.view)return;let[t,i,r,s]=e,o=r-t,a=s-i,l=10*this._app.getDbuPerMicron(),u=2*Math.max(o,a),f=Math.min(l,u);this._app.view.fitWorldRect(Nt(t-f,i-f,r+f,s+f,this._app.designScale,this._app.designOriginX,this._app.designOriginY))}_updateMarker(e,t,i){this._app.websocketManager.request({type:"drc_update_marker",marker_id:e,field:t,value:!!i}).then(()=>{this._refreshOverlay(),t==="visible"&&(this._update3DHighlights(),i&&this._flashHighlight())}).catch(r=>{console.error("Failed to update DRC marker:",r)})}_flashHighlight(){this._app.view?.flashTiles()}_update3DHighlights(){let e=this._app.threeDViewerWidget;if(!e)return;let t=[];this._collectVisibleMarkers(this._markerTree,t),t.length>0?e.highlightDRC(t):e.clearHighlightDRC()}_collectVisibleMarkers(e,t){if(e){if(e.markers)for(let i of e.markers)i.visible&&t.push(i);if(e.subcategories)for(let i of e.subcategories)this._collectVisibleMarkers(i,t)}}_setMarkersVisible(e,t){if(e){if(e.markers)for(let i of e.markers)i.visible=t;if(e.subcategories)for(let i of e.subcategories)this._setMarkersVisible(i,t)}}_snapshotMarkerVisibility(e,t=new Map){if(!e)return t;if(e.markers)for(let i of e.markers)t.set(i.id,i.visible);if(e.subcategories)for(let i of e.subcategories)this._snapshotMarkerVisibility(i,t);return t}_restoreMarkerVisibility(e,t){if(e){if(e.markers)for(let i of e.markers)t.has(i.id)&&(i.visible=t.get(i.id));if(e.subcategories)for(let i of e.subcategories)this._restoreMarkerVisibility(i,t)}}_allMarkersVisible(e){if(e.markers){for(let t of e.markers)if(!t.visible)return!1}if(e.subcategories){for(let t of e.subcategories)if(!this._allMarkersVisible(t))return!1}return!0}_toggleCategoryVisibility(e,t,i){let r=this._snapshotMarkerVisibility(e);this._setMarkersVisible(e,t),this._renderTree(),this._app.websocketManager.request({type:"drc_update_category_visibility",category:e.name,path:i||[e.name],visible:!!t}).then(()=>{this._refreshOverlay(),this._update3DHighlights(),t&&this._flashHighlight()}).catch(s=>{console.error("Failed to update category visibility:",s),this._restoreMarkerVisibility(e,r),this._renderTree()})}_showLoadDialog(){new uv(this._app,t=>{this._activeCategory=t,this._loadCategories().then(()=>{this._categorySelect.value=this._activeCategory,this._loadMarkers()})}).open()}selectCategory(e){this._activeCategory=e,this._categorySelect.value=e,this._loadMarkers()}},uv=class{constructor(e,t){this._app=e,this._onLoaded=t,this._currentPath="",this._disposers=[],this._closed=!1}open(){this._overlay=document.createElement("div"),this._overlay.className="modal-overlay",this._overlay.innerHTML=` + `,document.body.appendChild(t);function i(s){s.key==="Escape"&&r()}let r=()=>{t.remove(),document.removeEventListener("keydown",i)};return t.addEventListener("click",s=>{s.target===t&&r()}),document.addEventListener("keydown",i),{overlay:t,body:t.querySelector(".modal-body"),errorDiv:t.querySelector(".modal-error"),buttons:t.querySelector(".modal-buttons"),close:r}}function ai(n,e){n.textContent=e,n.style.display=e?"":"none"}function Jo(n,e,{primary:t=!1}={}){let i=document.createElement("button");return i.textContent=e,i.className="or-btn"+(t?" or-btn-primary":""),n.appendChild(i),i}function Kh(n){return"{"+String(n)+"}"}function TM(n){let e=CM("Global Connect","gc-dialog"),t=document.createElement("div");t.className="gc-table",e.body.appendChild(t);let i=document.createElement("div");i.className="gc-form";let r=document.createElement("input");r.placeholder="Instance pattern (regex)",r.value=".*";let s=document.createElement("input");s.placeholder="Pin pattern (regex)";let o=document.createElement("select"),a=document.createElement("select"),c=document.createElement("span");c.innerHTML='',i.append(pr("Instance",r),pr("Pin",s),pr("Net",o),pr("Region",a),c);let l=Jo(i,"Add rule");e.body.appendChild(i);function u(){let p=s.value.trim()!==""&&o.value!=="";for(let m of[r,s])try{new RegExp(m.value),m.classList.remove("gc-invalid")}catch{m.classList.add("gc-invalid"),p=!1}l.disabled=!p}r.addEventListener("input",u),s.addEventListener("input",u),o.addEventListener("change",u);function f(){n.websocketManager.request({type:"global_connect_info"}).then(p=>{t.innerHTML='
InstancePinNetRegion
',(p.rules||[]).forEach(m=>{let g=document.createElement("div");g.className="gc-row",g.innerHTML=`${Yl(m.inst)}${Yl(m.pin)}${Yl(m.net)}${Yl(m.region||"All")}`;let v=document.createElement("button");v.className="or-btn or-btn-sm or-btn-icon",v.textContent="\u2715",v.title="Delete rule",v.addEventListener("click",()=>{n.websocketManager.request({type:"global_connect_delete",inst:m.inst,pin:m.pin,net:m.net,region:m.region||""}).then(f).catch(y=>ai(e.errorDiv,String(y)))}),g.appendChild(v),t.appendChild(g)}),cv(o,p.nets||[]),cv(a,["All",...p.regions||[]]),u()}).catch(p=>ai(e.errorDiv,String(p)))}l.addEventListener("click",()=>{let p=i.querySelector('input[name="gc-pg"]:checked').value,m=`add_global_connection -net ${Kh(o.value)} -inst_pattern ${Kh(r.value||".*")} -pin_pattern ${Kh(s.value)} -${p}`;a.value&&a.value!=="All"&&(m+=` -region ${Kh(a.value)}`),PM(n,m,e.errorDiv,"Rule added.",f)}),Jo(e.buttons,"Apply (force)").addEventListener("click",()=>{n.websocketManager.request({type:"global_connect_apply",force:!0}).then(p=>{if(!p.had_rules){ai(e.errorDiv,"No global-connect rules defined \u2014 add a rule first.");return}ai(e.errorDiv,`Connected ${p.connected} pin(s).`),n.scheduleRedrawAllLayers&&n.scheduleRedrawAllLayers(),f()}).catch(p=>ai(e.errorDiv,p.message||String(p)))}),Jo(e.buttons,"Clear all").addEventListener("click",()=>PM(n,"clear_global_connect",e.errorDiv,"Rules cleared.",f)),Jo(e.buttons,"Close").addEventListener("click",e.close),f()}function PM(n,e,t,i,r){n.websocketManager.request({type:"tcl_eval",cmd:e}).then(s=>{if(s.is_error){ai(t,s.output||s.result||"Command failed");return}ai(t,i||""),n.scheduleRedrawAllLayers&&n.scheduleRedrawAllLayers(),r&&r()}).catch(s=>ai(t,s.message||String(s)))}function LM(n,e){let t=CM(`Insert Buffer \u2014 ${Yl(e)}`,"buf-dialog"),i=Jo(t.buttons,"Insert",{primary:!0});i.disabled=!0,Jo(t.buttons,"Cancel").addEventListener("click",t.close),n.websocketManager.request({type:"buffer_info",net:e}).then(s=>{if(!s.can_buffer){t.body.textContent=s.error||"This net has multiple drivers and cannot be buffered.";return}YW(n,t,e,s,i)}).catch(s=>{t.body.textContent=String(s)})}function YW(n,e,t,i,r){let s=document.createElement("div");s.className="buf-pins";let o=i.drivers||[],a=i.loads||[],c=new Set;function l(){s.innerHTML="";let p=(m,g)=>{let v=document.createElement("label");v.className="buf-pin";let y=document.createElement("input");y.type="checkbox",y.checked=c.has(m.id),y.addEventListener("change",()=>{if(y.checked){if(g)c.clear();else for(let b of o)c.delete(b.id);c.add(m.id)}else c.delete(m.id);l(),h()}),v.append(y,document.createTextNode(" "+m.label)),s.appendChild(v)};o.forEach(m=>p(m,!0)),a.forEach(m=>p(m,!1))}o.length&&c.add(o[0].id),l();let u=document.createElement("select");cv(u,i.masters||[]);let f=document.createElement("input");f.placeholder="Optional: new buffer name";let d=document.createElement("input");d.placeholder="Optional: new net name",e.body.append(pr("Pins to buffer",s),pr("Buffer master",u),pr("Buffer name",f),pr("Net name",d));function h(){r.disabled=c.size===0||!u.value}u.addEventListener("change",h),h(),r.addEventListener("click",()=>{let p=new Set(o.map(v=>v.id)),m=[...c],g=m.some(v=>p.has(v))?"driver":"loads";n.websocketManager.request({type:"insert_buffer",net:t,mode:g,pins:m,master:u.value,buf_name:f.value.trim(),net_name:d.value.trim()}).then(v=>{if(v.is_error||v.ok===!1){ai(e.errorDiv,v.error||v.result||"Insertion failed");return}e.close(),v.inst&&(n.selectedInstanceName=v.inst),n.scheduleRedrawAllLayers&&n.scheduleRedrawAllLayers()}).catch(v=>ai(e.errorDiv,v.message||String(v)))})}function pr(n,e){let t=document.createElement("label");t.className="edit-field";let i=document.createElement("span");return i.textContent=n,t.append(i,e),t}function cv(n,e){let t=n.value;n.innerHTML="";for(let i of e){let r=document.createElement("option");r.value=i,r.textContent=i,n.appendChild(r)}e.includes(t)&&(n.value=t)}function Yl(n){return String(n??"").replace(/&/g,"&").replace(//g,">")}var MM="#00ffff",qW="#ffff00",AM="#ffffff",ZW=4,Ms=0,lv=1,ql=2,Qh=class{constructor(e,t,i,r){this._app=e,this._visibility=t,this._updateInspector=i,this._focusComponent=r,this._state=Ms,this._rulers=[],this._nextId=0,this._pt0=null,this._selectedRulerId=null,this._ctrlHeld=!1,this._shiftHeld=!1,this._snapTimer=null,this._lastSnapResult=null,this._snapShapes=null,this._preview=null,e.view?.on("zoom",()=>this._renderRulerShapes())}isActive(){return this._state!==Ms}updateVisibility(){this._renderAll(),this._drawTransient()}_shown(){return this._visibility.rulers!==!1}toggleRulerMode(){this._state===Ms?this._enterFirstPoint():this.cancelRulerBuild()}cancelRulerBuild(){this._state=Ms,this._pt0=null,this._lastSnapResult=null,this._clearTransient(),this._setCursor(!1)}clearAllRulers(){this._rulers=[],this._selectedRulerId=null,this._renderAll(),this._clearTransient(),this._state!==Ms&&this.cancelRulerBuild()}_enterFirstPoint(){this._state=lv,this._pt0=null,this._lastSnapResult=null,this._setCursor(!0)}_enterMeasuring(e){this._state=ql,this._pt0=e}_toDbu(e){return Pn(e[0],e[1],this._app.designScale,this._app.designOriginX,this._app.designOriginY)}_toWorld(e,t){return Sn(e,t,this._app.designScale,this._app.designOriginX,this._app.designOriginY)}handleMouseMove(e,t){if(this._state===Ms)return;this._ctrlHeld=t.ctrlKey||t.metaKey,this._shiftHeld=t.shiftKey;let i=this._toDbu(e);this._snapTimer&&clearTimeout(this._snapTimer),this._snapTimer=setTimeout(()=>{this._requestSnap(i.dbuX,i.dbuY)},50)}handleMapClick(e,t){if(this._state===Ms)return;this._ctrlHeld=t.ctrlKey||t.metaKey,this._shiftHeld=t.shiftKey;let i=this._toDbu(e),r=this._getSnappedPoint(i.dbuX,i.dbuY);this._state===lv?this._enterMeasuring(r):this._state===ql&&(this._createRuler(this._pt0,r),this._state=lv,this._pt0=null,this._clearTransient(),this._lastSnapResult=null)}async _requestSnap(e,t){let i=this._app;if(!i.websocketManager||!i.designScale)return;if(this._ctrlHeld){this._lastSnapResult=null,this._snapShapes=null,this._updatePreview(e,t);return}let s=i.techData?.dbu_per_micron||1e3,o=i.view.getZoom(),a=Math.pow(2,Math.max(0,o)),c=1/(i.designScale*a),l=Math.max(Math.round(10*c),10),u=!0,f=!0;if(this._shiftHeld)u=!0,f=!0;else if(this._state===ql&&this._pt0){let h=Math.abs(e-this._pt0.x),p=Math.abs(t-this._pt0.y);h>p?(u=!1,f=!0):p>h&&(u=!0,f=!1)}let d={};for(let[h,p]of Object.entries(this._visibility))d[h]=!!p;try{let h=await i.websocketManager.request({type:"snap",dbu_x:e,dbu_y:t,radius:s,point_threshold:l,horizontal:!!u,vertical:!!f,visible_layers:[...i.visibleLayerNames],...d});this._lastSnapResult=h,this._updateSnapIndicator(h),this._updatePreview(e,t)}catch{this._lastSnapResult=null,this._clearSnap()}}_getSnappedPoint(e,t){if(this._ctrlHeld)return{x:e,y:t};let i=this._lastSnapResult,r;if(i?.found&&i.is_point)r={x:i.edge[0][0],y:i.edge[0][1]};else if(i?.found){let s=i.edge;s[0][1]===s[1][1]?r={x:e,y:s[0][1]}:r={x:s[0][0],y:t}}else r={x:e,y:t};if(!this._shiftHeld&&this._state===ql&&this._pt0){let s=Math.abs(r.x-this._pt0.x),o=Math.abs(r.y-this._pt0.y);sthis._toWorld(r.x,r.y))}}_rulerShapes(e){let t=e.id===this._selectedRulerId,i=zt(t?qW:MM),{joinPt:r,points:s}=this._rulerPath(e),o=[{kind:"path",points:s,stroke:i,width:2}],a=this._app.view.getZoom(),c=Math.pow(2,Math.max(0,a)),u=8*(1/(this._app.designScale*c)),f=(d,h,p)=>{let m=Math.sqrt(h*h+p*p);if(m===0)return;let g=-p/m,v=h/m;o.push({kind:"path",stroke:i,width:2,points:[this._toWorld(d.x+g*u,d.y+v*u),this._toWorld(d.x-g*u,d.y-v*u)]})};if(r)f(e.pt0,r.x-e.pt0.x,r.y-e.pt0.y),f(e.pt1,e.pt1.x-r.x,e.pt1.y-r.y);else{let d=e.pt1.x-e.pt0.x,h=e.pt1.y-e.pt0.y;f(e.pt0,d,h),f(e.pt1,d,h)}return o}_renderAll(){this._renderRulerShapes(),this._renderRulerLabels()}_renderRulerShapes(){let e=this._app.view;!e||!this._app.designScale||e.setOverlay("rulers",this._shown()?this._rulers.flatMap(t=>this._rulerShapes(t)):null,{order:ot.ruler})}_renderRulerLabels(){let e=this._app.view;if(!(!e||!this._app.designScale)&&(e.clearMarkers("ruler-labels"),!!this._shown()))for(let t of this._rulers){let{joinPt:i,points:r}=this._rulerPath(t),s=i?r[1]:[(r[0][0]+r[1][0])/2,(r[0][1]+r[1][1])/2],o=this._computeDistance(t.pt0,t.pt1,t.euclidian);e.addMarker("ruler-labels",t.id,s,this._labelElement(this._formatDistance(o)))}}handleRulerClick(e){let t=this._app.view;if(!t||!this._shown()||this._rulers.length===0)return!1;let i=t.project(e);for(let r of this._rulers){let s=this._rulerPath(r).points.map(o=>t.project(o));for(let o=0;o+1l.id===e);if(!t)return;Pt(this._app);let i=Math.abs(t.pt1.x-t.pt0.x),r=Math.abs(t.pt1.y-t.pt0.y),s=t.euclidian?Math.sqrt(i*i+r*r):i+r,o=l=>this._app.formatDbu(l,!0),a=l=>this._app.parseDbu(l),c={type:"Ruler",name:t.name,bbox:[Math.min(t.pt0.x,t.pt1.x),Math.min(t.pt0.y,t.pt1.y),Math.max(t.pt0.x,t.pt1.x),Math.max(t.pt0.y,t.pt1.y)],properties:[{name:"Name",value:t.name,editable:!0},{name:"Label",value:t.label||"",editable:!0},{name:"Point 0 - x",value:o(t.pt0.x),editable:!0},{name:"Point 0 - y",value:o(t.pt0.y),editable:!0},{name:"Point 1 - x",value:o(t.pt1.x),editable:!0},{name:"Point 1 - y",value:o(t.pt1.y),editable:!0},{name:"Delta x",value:o(i)},{name:"Delta y",value:o(r)},{name:"Length",value:o(s)},{name:"Euclidian",value:t.euclidian?"True":"False",editable:!0,editor:{type:"bool"}}],onPropertyChange:(l,u)=>{switch(l){case"Name":t.name=u;break;case"Label":t.label=u;break;case"Point 0 - x":{let f=a(u);f!==null&&(t.pt0.x=f);break}case"Point 0 - y":{let f=a(u);f!==null&&(t.pt0.y=f);break}case"Point 1 - x":{let f=a(u);f!==null&&(t.pt1.x=f);break}case"Point 1 - y":{let f=a(u);f!==null&&(t.pt1.y=f);break}case"Euclidian":t.euclidian=u.trim().toLowerCase()==="true";break}this._renderAll(),this._selectRuler(t.id)}};this._updateInspector(c),this._focusComponent("Inspector"),requestAnimationFrame(()=>{let l=this._app.inspectorEl?.querySelector(".inspector-toolbar");if(!l)return;let u=document.createElement("button");u.className="or-btn or-btn-icon",u.title="Delete ruler",u.innerHTML='',u.addEventListener("click",()=>{this.deleteRuler(e)}),l.appendChild(u)})}deleteRuler(e){let t=this._rulers.findIndex(i=>i.id===e);t!==-1&&(this._rulers.splice(t,1),this._renderAll(),this._selectedRulerId===e&&(this._selectedRulerId=null,this._updateInspector(null)))}_getManhattanJoinPt(e,t){return{x:t.x,y:e.y}}_computeDistance(e,t,i=!0){let r=Math.abs(t.x-e.x),s=Math.abs(t.y-e.y);return i?Math.sqrt(r*r+s*s):r+s}_formatDistance(e){return this._app.formatDistance(e)}_setCursor(e){this._app.view?.setCursorMode("ruler",e)}_clearTransient(){this._preview=null,this._snapShapes=null,this._drawTransient()}_clearSnap(){this._snapShapes=null,this._drawTransient()}};function XW(n,e,t){let i=t[0]-e[0],r=t[1]-e[1],s=i*i+r*r,o=s>0?((n[0]-e[0])*i+(n[1]-e[1])*r)/s:0;return o=Math.max(0,Math.min(1,o)),Math.hypot(n[0]-(e[0]+o*i),n[1]-(e[1]+o*r))}var Jh="label-handles",kM=3,ep=class{constructor(e,t,i,r){this._app=e,this._visibility=t,this._updateInspector=i,this._focusComponent=r,this._labels=[],this._anchors=[],this._mode=!1,this._selectedName=null}isActive(){return this._mode}updateVisibility(){this._app.view?.setMarkerGroupVisible(Jh,!!this._visibility.labels)}toggleLabelMode(){this._mode=!this._mode,this._setCursor(this._mode)}cancelLabelMode(){this._mode=!1,this._setCursor(!1)}_setCursor(e){this._app.view?.setCursorMode("label",e)}_wm(){return this._app.websocketManager}_applyLabels(e){this._labels=e||[],this._renderHandles()}_refresh(e){this._applyLabels(e&&e.labels),this._app.refreshOverlay()}applyRemoteLabels(e){this._applyLabels(e),this._selectedName&&!this._labels.some(t=>t.name===this._selectedName)&&(this._selectedName=null,this._updateInspector(null),this._renderHandles()),this._app.refreshOverlay()}_updateLabel(e,t){return this._wm().request({type:"update_label",name:e,...t})}async reload(){let e=this._wm();if(e)try{let t=await e.request({type:"list_labels"});this._anchors=t.anchors||[],this._applyLabels(t.labels)}catch{this._applyLabels([])}}async handleMapClick(e,t){let i=window.prompt("Label text:");if(this._mode=!1,this._setCursor(!1),!!i)try{let r=await this._wm().request({type:"add_label",x:Math.round(e),y:Math.round(t),text:i});this._refresh(r)}catch(r){console.error("add_label failed:",r)}}_renderHandles(){let e=this._app.view;if(!e)return;e.clearMarkers(Jh);let t=this._app;if(t.designScale)for(let i of this._labels){let r=document.createElement("div");r.className="label-handle"+(i.name===this._selectedName?" label-handle-selected":""),r.title=i.text,this._installDrag(r,i),e.addMarker(Jh,i.name,Sn(i.x,i.y,t.designScale,t.designOriginX,t.designOriginY),r,{center:!0})}}_installDrag(e,t){let i=this._app.view,r=a=>{let c=i.getContainer().getBoundingClientRect();return i.unproject([a.clientX-c.left,a.clientY-c.top])},s=null;e.addEventListener("pointerdown",a=>{a.button===0&&(a.stopPropagation(),a.preventDefault(),e.setPointerCapture?.(a.pointerId),s={x:a.clientX,y:a.clientY,moved:!1})}),e.addEventListener("pointermove",a=>{s&&((Math.abs(a.clientX-s.x)>kM||Math.abs(a.clientY-s.y)>kM)&&(s.moved=!0),s.moved&&i.moveMarker(Jh,t.name,r(a)))});let o=(a,c)=>{if(!s)return;let l=s;if(s=null,e.releasePointerCapture?.(a.pointerId),!c)this._renderHandles();else if(!l.moved)this._select(t.name);else{let u=this._app,[f,d]=r(a),{dbuX:h,dbuY:p}=Pn(f,d,u.designScale,u.designOriginX,u.designOriginY);this._commitMove(t,Math.round(h),Math.round(p))}};e.addEventListener("pointerup",a=>o(a,!0)),e.addEventListener("pointercancel",a=>o(a,!1)),e.addEventListener("click",a=>a.stopPropagation())}async _commitMove(e,t,i){try{let r=await this._updateLabel(e.name,{x:t,y:i,text:e.text,size:e.size||0,anchor:e.anchor||"center",color:e.color});this._refresh(r)}catch(r){console.error("move label failed:",r)}}_select(e){this._selectedName=e,this._renderHandles();let t=this._labels.find(s=>s.name===e);if(!t)return;let i=s=>this._app.formatDbu(s,!0),r={type:"Label",name:t.name,bbox:[t.x,t.y,t.x,t.y],properties:[{name:"Name",value:t.name},{name:"Text",value:t.text,editable:!0},{name:"x",value:i(t.x)},{name:"y",value:i(t.y)},{name:"Font size",value:String(t.size||0),editable:!0},{name:"Anchor",value:t.anchor||"center",editable:!0,editor:{type:"list",options:this._anchors}}],onPropertyChange:(s,o)=>{let a={text:t.text,size:t.size||0,anchor:t.anchor||"center"};s==="Text"?a.text=o:s==="Font size"?a.size=parseInt(o,10)||0:s==="Anchor"&&(a.anchor=o.trim()),this._edit(t,a)}};this._updateInspector(r),this._focusComponent("Inspector"),requestAnimationFrame(()=>{let s=this._app.inspectorEl?.querySelector(".inspector-toolbar");if(!s||s.querySelector(".delete-label-btn"))return;let o=document.createElement("button");o.className="or-btn or-btn-icon delete-label-btn",o.title="Delete label",o.innerHTML='',o.addEventListener("click",()=>this.deleteLabel(e)),s.appendChild(o)})}async _edit(e,t){try{let i=await this._updateLabel(e.name,{x:e.x,y:e.y,text:t.text,size:t.size,anchor:t.anchor,color:e.color});this._refresh(i),this._select(e.name)}catch(i){console.error("edit label failed:",i)}}async deleteLabel(e){try{let t=await this._wm().request({type:"delete_label",name:e});this._selectedName===e&&(this._selectedName=null,this._updateInspector(null)),this._refresh(t)}catch(t){console.error("delete_label failed:",t)}}async clearAllLabels(){try{let e=await this._wm().request({type:"clear_labels"});this._selectedName=null,this._refresh(e)}catch(e){console.error("clear_labels failed:",e)}}};var RM="Select an instance in the layout to view its schematic.",tp=class{constructor(e,t){this.container=e,this.appState=t,this.element=document.createElement("div"),this.element.className="schematic-widget",this.element.style.cssText="width:100%; height:100%; display:flex; flex-direction:column; background:var(--bg-panel); color:var(--fg-primary); overflow:hidden;",this.controls=document.createElement("div"),this.controls.style.cssText="padding:4px 8px; background:var(--bg-header); border-bottom:1px solid var(--border);flex-shrink:0; display:flex; align-items:center; gap:8px; flex-wrap:wrap;",this.controls.innerHTML='',this.element.appendChild(this.controls),this.svgContainer=document.createElement("div"),this.svgContainer.style.cssText="flex:1; overflow:hidden; position:relative; cursor:grab; background:var(--bg-main);",this.element.appendChild(this.svgContainer),this.container.element.appendChild(this.element),this.controls.querySelector("#schematic-refresh").addEventListener("click",()=>this.refresh()),this.controls.querySelector("#schematic-fit").addEventListener("click",()=>this.fitView()),this.controls.querySelector("#schematic-zoom-in").addEventListener("click",()=>this._zoomStep(1.5)),this.controls.querySelector("#schematic-zoom-out").addEventListener("click",()=>this._zoomStep(1/1.5)),this.controls.querySelector("#schematic-select").addEventListener("click",()=>this._toggleSelectMode()),this.controls.querySelector("#schematic-zoom-to").addEventListener("click",()=>this._zoomToSelected()),this.controls.querySelector("#schematic-save-svg").addEventListener("click",()=>this._exportSvg()),this.controls.querySelector("#schematic-save-png").addEventListener("click",()=>this._exportPng()),this.controls.querySelector("#schematic-copy").addEventListener("click",()=>this._copyImage()),this.appState.schematicWidget=this,this.netlistsvg=null,this.skin=null,this._svgEl=null,this._scale=1,this._panX=0,this._panY=0,this._selectMode=!1,this._selectedCell=null,this._svgIdToInstName=new Map,this._setupPanZoom(),this.initNetlistSVG()}_setupPanZoom(){let e=this.svgContainer,t=!1,i,r,s,o;e.addEventListener("wheel",a=>{if(!this._svgEl)return;a.preventDefault();let c=a.deltaY<0?1.2:1/1.2,l=e.getBoundingClientRect(),u=a.clientX-l.left,f=a.clientY-l.top;this._panX=u+(this._panX-u)*c,this._panY=f+(this._panY-f)*c,this._scale*=c,this._applyTransform()},{passive:!1}),e.addEventListener("mousedown",a=>{if(!(!this._svgEl||a.button!==0)){if(this._selectMode){this._handleSelectClick(a);return}t=!0,i=a.clientX,r=a.clientY,s=this._panX,o=this._panY,e.style.cursor="grabbing",a.preventDefault()}}),window.addEventListener("mousemove",a=>{t&&(this._panX=s+(a.clientX-i),this._panY=o+(a.clientY-r),this._applyTransform())}),window.addEventListener("mouseup",()=>{t&&(t=!1,e.style.cursor=this._selectMode?"default":"grab")})}_zoomStep(e){if(!this._svgEl)return;let t=this.svgContainer.getBoundingClientRect(),i=t.width/2,r=t.height/2;this._panX=i+(this._panX-i)*e,this._panY=r+(this._panY-r)*e,this._scale*=e,this._applyTransform()}_toggleSelectMode(){this._selectMode=!this._selectMode;let e=this.controls.querySelector("#schematic-select");this._selectMode?(e.style.background="var(--accent)",e.style.color="var(--fg-white)",this.svgContainer.style.cursor="default"):(e.style.background="",e.style.color="",this.svgContainer.style.cursor="grab",this._clearCellHighlight())}_handleSelectClick(e){if(!this._svgEl)return;let t=e.target,i=null;for(;t&&t!==this._svgEl;){if(t.tagName==="g"&&t.id&&this._svgIdToInstName.has(t.id)){i=t;break}t=t.parentElement}if(this._clearCellHighlight(),!i)return;let r=this._svgIdToInstName.get(i.id);try{let s=i.getBBox(),o=3,a=document.createElementNS("http://www.w3.org/2000/svg","rect");a.setAttribute("x",s.x-o),a.setAttribute("y",s.y-o),a.setAttribute("width",s.width+o*2),a.setAttribute("height",s.height+o*2),a.setAttribute("fill","none"),a.setAttribute("stroke","#e05a00"),a.setAttribute("stroke-width","1.5"),a.setAttribute("rx","3"),a.id="_schematic_highlight",i.appendChild(a),this._selectedCell=i}catch{}this.controls.querySelector("#schematic-zoom-to").disabled=!1,this.setStatus(`Selected: ${r}`),this._fetchInspect(r)}_fetchInspect(e){let t=this.appState.websocketManager;if(!t)return;console.log("[Schematic] inspect:",e);let i=Pt(this.appState);t.request({type:"schematic_inspect",inst_name:e,use_dbu:this.appState.showDbu}).then(r=>{Ft(this.appState,i)&&(this.appState.updateInspector&&this.appState.updateInspector(r),this.appState.focusComponent&&this.appState.focusComponent("Inspector"),this.appState.refreshOverlay&&this.appState.refreshOverlay())}).catch(r=>{console.error("schematic_inspect failed:",r),this.setStatus(`Inspect error: ${r}`)})}_clearCellHighlight(){if(this._svgEl){let e=this._svgEl.querySelector("#_schematic_highlight");e&&e.remove()}this._selectedCell=null,this.controls.querySelector("#schematic-zoom-to").disabled=!0}_zoomToSelected(){if(!this._selectedCell||!this._svgEl)return;let e=this.svgContainer.getBoundingClientRect(),t=this._selectedCell.getBoundingClientRect(),i=(t.left-e.left-this._panX)/this._scale,r=(t.top-e.top-this._panY)/this._scale,s=t.width/this._scale,o=t.height/this._scale,a=Math.min(e.width/s,e.height/o)*.9;this._scale=a,this._panX=e.width/2-(i+s/2)*a,this._panY=e.height/2-(r+o/2)*a,this._applyTransform()}_applyTransform(){this._svgEl&&(this._svgEl.style.transform=`translate(${this._panX}px, ${this._panY}px) scale(${this._scale})`,this._svgEl.style.transformOrigin="0 0")}fitView(){if(!this._svgEl)return;let e=this.svgContainer.getBoundingClientRect();if(e.width===0||e.height===0)return;let t=this._svgEl.viewBox&&this._svgEl.viewBox.baseVal,i=t&&t.width||this._svgEl.clientWidth||1,r=t&&t.height||this._svgEl.clientHeight||1;this._scale=Math.min(e.width/i,e.height/r)*.95,this._panX=(e.width-i*this._scale)/2,this._panY=(e.height-r*this._scale)/2,this._applyTransform()}initNetlistSVG(){this.netlistsvg=globalThis.netlistsvg,this.skin=globalThis.openroadSkin,this._netlistsvgReady=!!(this.netlistsvg&&this.skin),this._netlistsvgReady&&console.log("NetlistSVG ready."),this.setStatus(this._unreadyStatus()??RM)}_unreadyStatus(){return this._netlistsvgReady?null:fe(this.appState)?"The schematic is not available in saved reports.":"Init error: netlistsvg or its skin is missing from the page."}syncCone(e={}){let t=this.controls.querySelector("#schematic-fanin-depth"),i=this.controls.querySelector("#schematic-fanout-depth"),r=(s,o,a)=>{if(!s)return;let c=parseInt(s.max,10)||10;o===!1?s.value=0:a!==void 0&&(s.value=a>0?Math.min(a,c):c)};r(t,e.fanin,e.fanin_depth),r(i,e.fanout,e.fanout_depth),this.refresh(),this.appState.focusComponent&&this.appState.focusComponent("SchematicWidget")}refresh(){if(!this._netlistsvgReady){this.setStatus(this._unreadyStatus());return}let e=this.appState.selectedInstanceName;if(!e){this.setStatus(RM);return}let t=this.appState.websocketManager;if(!t){this.setStatus("Waiting for server connection\u2026");return}this.setStatus(`Loading schematic for ${e}\u2026`);let i=parseInt(this.controls.querySelector("#schematic-fanin-depth").value,10),r=parseInt(this.controls.querySelector("#schematic-fanout-depth").value,10),s=isNaN(i)?1:i,o=isNaN(r)?1:r;t.readyPromise.then(()=>{t.request({type:"schematic_cone",inst_name:e,fanin_depth:s,fanout_depth:o}).then(a=>{let c=a.modules&&a.modules.top&&a.modules.top.cells;if(!c||Object.keys(c).length===0){this.setStatus("No cells found for selected instance.");return}this.renderNetlist(a)}).catch(a=>{this.setStatus(`Error: ${a}`)})})}setStatus(e){this.controls.querySelector("#schematic-status").textContent=e}_exportSvg(){if(!this._svgEl){this.setStatus("No schematic to export.");return}let e=nv(this._svgEl);sM(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),"schematic.svg")}async _exportPng(){if(!this._svgEl){this.setStatus("No schematic to export.");return}try{let e=await iv(this._svgEl,2);Ts(e,"schematic.png")}catch{this.setStatus("PNG export failed.")}}async _copyImage(){if(!this._svgEl){this.setStatus("No schematic to export.");return}try{let e=await iv(this._svgEl,2),t=await Fh(e);this.setStatus(t?"Schematic copied to clipboard.":"Clipboard not available.")}catch{this.setStatus("Copy failed.")}}async renderNetlist(e){try{this.setStatus("Rendering\u2026"),typeof window<"u"&&(window.__lastSchematic=e);let t=t5(e),i,r=this.netlistsvg.render(this.skin,t);if(r&&typeof r.then=="function"?i=await r:i=await new Promise((a,c)=>{this.netlistsvg.render(this.skin,t,(l,u)=>{l?c(l):a(u)})}),typeof i!="string"||!i.includes("requestAnimationFrame(()=>this.fitView()));let o=Object.keys(e.modules.top.cells).length;this.setStatus(`${o} cell${o!==1?"s":""}`)}catch(t){console.error("NetlistSVG render failed:",t),this.setStatus(`Render error: ${t.message||t}`)}}_applyPinLabels(e){if(!this._svgEl)return;let t="http://www.w3.org/2000/svg",i="https://github.com/nturley/netlistsvg",r=e.modules&&e.modules.top&&e.modules.top.cells||{},s=(o,a)=>o.getAttribute("s:"+a)??o.getAttributeNS(i,a);for(let[o,a]of Object.entries(r)){let c=a.port_labels;if(!c)continue;let l=this._svgEl.querySelector("#"+CSS.escape("cell_"+o))||this._svgEl.querySelector("#"+CSS.escape(o));if(!l)continue;let u=a.port_directions||{};for(let f of Array.from(l.children)){if(f.tagName!=="g")continue;let d=s(f,"pid");if(!d||!(d in c))continue;let h=parseFloat(s(f,"x")),p=parseFloat(s(f,"y"));if(!isFinite(h)||!isFinite(p))continue;let m=document.createElementNS(t,"text");u[d]==="input"?(m.setAttribute("class","inputPortLabel"),m.setAttribute("x",h-3)):m.setAttribute("x",h+4),m.setAttribute("y",p-4),m.setAttribute("style","font-size:5px"),m.setAttribute("pointer-events","none"),m.textContent=c[d],l.appendChild(m)}}}_scopeSkinStyles(){if(!this._svgEl)return;let e=".schematic-widget",t=i=>{for(let r of i)r.selectorText?r.selectorText=KW(r.selectorText,e):r.cssRules&&t(r.cssRules)};for(let i of this._svgEl.querySelectorAll("style")){let r=i.sheet;if(r)try{t(r.cssRules)}catch{continue}}}};function KW(n,e){return n.split(",").map(t=>{let i=t.trim();if(!i)return"";let r=i.charAt(e.length);return i.startsWith(e)&&(r===""||!/[\w-]/.test(r))?i:`${e} ${i}`}).filter(Boolean).join(", ")}var IM={and:"$_AND_",nand:"$_NAND_",or:"$_OR_",nor:"$_NOR_",xor:"$_XOR_",xnor:"$_XNOR_",not:"$_NOT_",buf:"$_BUF_"},QW=new Set(["aoi21","aoi22","aoi211","aoi221","aoi222","aoi33","oai21","oai22","oai211","oai221","oai222","oai33"]),JW=new Set(["and3","and4","or3","or4","nand3","nand4","nor3","nor4"]),BM=["A","B","C","D","E","F"];function e5(n){let e=n&&n.gate_kind;if(!e)return n;let t=n.port_directions||{},i=null,r=[];for(let[f,d]of Object.entries(t))d==="output"&&i===null?i=f:d==="input"&&r.push(f);let s,o={};if(e==="aoi"||e==="oai"){let f=Array.isArray(n.gate_terms)?n.gate_terms:[];if(!f.length)return n;let d=f.map(m=>m.length);if(s=e+d.slice().sort((m,g)=>g-m).join(""),!QW.has(s))return n;let h=f.map(m=>m.slice()).sort((m,g)=>m.length-g.length),p=0;for(let m of h)for(let g of m)o[g]=BM[p]||"I"+p,p++}else{let f=r.length;if(e==="not"||e==="buf")s=IM[e];else if(f<=2)s=IM[e];else if(s=e+f,!JW.has(s))return n;if(!s)return n;r.forEach((d,h)=>{o[d]=BM[h]||"I"+h})}i!==null&&(o[i]="Y");let a=n.connections||{},c={},l={};for(let[f,d]of Object.entries(a))o[f]&&(c[o[f]]=d);for(let[f,d]of Object.entries(t))o[f]&&(l[o[f]]=d);let u={};for(let[f,d]of Object.entries(o))u[d]=f;return{...n,type:s,connections:c,port_directions:l,port_labels:u}}function t5(n){let e=n&&n.modules&&n.modules.top;if(!e||!e.cells)return n;let t={};for(let[i,r]of Object.entries(e.cells))t[i]=e5(r);return{...n,modules:{...n.modules,top:{...e,cells:t}}}}var np=class{constructor(e,t,i){this._app=e,this._redrawAllLayers=t,this._refreshOverlay=i||t,this._categories=[],this._activeCategory="",this._markerTree=null,this._expandedNodes=new Set,this._build(),this._app.websocketManager.readyPromise.then(()=>this.refresh())}_build(){let e=document.createElement("div");e.className="drc-widget";let t=document.createElement("div");t.className="drc-toolbar",this._categorySelect=document.createElement("select"),this._categorySelect.className="drc-category-select",t.appendChild(this._categorySelect),this._loadBtn=document.createElement("button"),this._loadBtn.className="or-btn or-btn-sm",this._loadBtn.textContent="Load...",t.appendChild(this._loadBtn),e.appendChild(t),this._infoBar=document.createElement("div"),this._infoBar.className="drc-info-bar",e.appendChild(this._infoBar),this._treeContainer=document.createElement("div"),this._treeContainer.className="drc-tree-container",e.appendChild(this._treeContainer),this.element=e,this._bindEvents()}_bindEvents(){this._categorySelect.addEventListener("change",()=>{this._activeCategory=this._categorySelect.value,this._loadMarkers()}),this._loadBtn.addEventListener("click",()=>{this._showLoadDialog()})}_loadCategories(){return this._app.websocketManager.request({type:"drc_categories"}).then(e=>{this._categories=e.categories||[],this._renderCategorySelect()}).catch(e=>{console.error("Failed to load DRC categories:",e)})}refresh(){this._loadCategories().then(()=>{!this._activeCategory&&this._categories.length>0&&(this._activeCategory=this._categories[0].name,this._categorySelect.value=this._activeCategory),this._activeCategory&&this._loadMarkers()})}_renderCategorySelect(){let e=this._categorySelect,t=e.value;e.innerHTML="";let i=document.createElement("option");i.value="",i.textContent="(none)",e.appendChild(i);for(let r of this._categories){let s=document.createElement("option");s.value=r.name,s.textContent=`${r.name} (${r.count})`,e.appendChild(s)}this._activeCategory&&this._categories.some(r=>r.name===this._activeCategory)?e.value=this._activeCategory:t&&this._categories.some(r=>r.name===t)?(e.value=t,this._activeCategory=t):this._activeCategory=""}_loadMarkers(){if(!this._activeCategory){this._markerTree=null,this._treeContainer.innerHTML="",this._infoBar.textContent="",this._refreshOverlay();return}this._treeContainer.innerHTML='
Loading...
',this._app.websocketManager.request({type:"drc_markers",category:this._activeCategory}).then(e=>{this._markerTree=e,this._renderTree(),this._refreshOverlay()}).catch(e=>{this._treeContainer.innerHTML="";let t=document.createElement("div");t.className="drc-error",t.textContent=`Error: ${e}`,this._treeContainer.appendChild(t),console.error("Failed to load DRC markers:",e)})}_renderTree(){if(this._treeContainer.innerHTML="",!this._markerTree)return;if(this._markerTree.error){let o=document.createElement("div");o.className="drc-error",o.textContent=this._markerTree.error,this._treeContainer.appendChild(o);return}let e=this._markerTree.total_count||0;this._infoBar.textContent=`${e} total violation${e!==1?"s":""}`;let t=this._markerTree.name||this._activeCategory,i=this._markerTree.subcategories||[],r=this._markerTree.markers||[];if(i.length===0&&r.length===0){this._treeContainer.innerHTML='
No violations
';return}let s=document.createElement("div");s.className="drc-tree",r.length>0&&s.appendChild(this._buildCategoryNode({name:t||"Markers",count:r.length,markers:r},[]));for(let o of i)s.appendChild(this._buildCategoryNode(o,[t]));this._treeContainer.appendChild(s)}_buildCategoryNode(e,t=[]){let i=[...t,e.name],r=document.createElement("div");r.className="drc-tree-node";let s=document.createElement("div");s.className="drc-tree-header";let o=document.createElement("span");o.className="drc-toggle";let a=e.subcategories&&e.subcategories.length>0||e.markers&&e.markers.length>0,c=JSON.stringify(i),l=this._expandedNodes.has(c);o.textContent=a?l?"\u25BC":"\u25B6":" ",s.appendChild(o);let u=document.createElement("input");u.type="checkbox",u.checked=this._allMarkersVisible(e),u.className="drc-visibility-check",u.addEventListener("change",p=>{p.stopPropagation(),this._toggleCategoryVisibility(e,u.checked,i)}),s.appendChild(u);let f=document.createElement("span");f.className="drc-category-label",f.textContent=e.name,s.appendChild(f);let d=document.createElement("span");d.className="drc-count",d.textContent=`${e.count} markers`,s.appendChild(d),r.appendChild(s);let h=document.createElement("div");if(h.className="drc-tree-children",h.style.display=l?"":"none",e.subcategories)for(let p of e.subcategories)h.appendChild(this._buildCategoryNode(p,i));if(e.markers)for(let p of e.markers)h.appendChild(this._buildMarkerNode(p));return r.appendChild(h),a&&(s.addEventListener("click",p=>{if(p.target===u)return;let m=h.style.display!=="none";h.style.display=m?"none":"",o.textContent=m?"\u25B6":"\u25BC",m?this._expandedNodes.delete(c):this._expandedNodes.add(c)}),s.style.cursor="pointer"),r}_buildMarkerNode(e){let t=document.createElement("div");t.className="drc-marker-row",t.dataset.markerId=e.id,e.visited||t.classList.add("drc-unvisited");let i=document.createElement("input");i.type="checkbox",i.checked=e.visible,i.className="drc-visibility-check",i.addEventListener("change",o=>{o.stopPropagation(),e.visible=i.checked,this._updateMarker(e.id,"visible",i.checked)}),t.appendChild(i);let r=document.createElement("span");r.className="drc-marker-index",r.textContent=e.index,t.appendChild(r);let s=document.createElement("span");if(s.className="drc-marker-name",s.textContent=e.name,e.layer&&(s.title=`Layer: ${e.layer}`),t.appendChild(s),e.layer){let o=document.createElement("span");o.className="drc-layer-badge",o.textContent=e.layer,t.appendChild(o)}return t.addEventListener("click",o=>{o.target!==i&&this._highlightMarker(e)}),t.addEventListener("dblclick",o=>{o.target!==i&&this._highlightMarker(e,!0)}),t}highlightMarkerById(e,t=!1){let i=this._findMarkerById(e);i&&this._highlightMarker(i,t)}_findMarkerById(e){let t=i=>{if(!i)return null;if(i.markers){for(let r of i.markers)if(r.id===e)return r}if(i.subcategories)for(let r of i.subcategories){let s=t(r);if(s)return s}return null};return t(this._markerTree)}_highlightMarker(e,t=!1){this._app.websocketManager.request({type:"drc_highlight",marker_id:e.id,open_inspector:t}).then(i=>{if(i.ok&&i.bbox){e.visited=!0;let r=this._treeContainer.querySelector(`.drc-marker-row[data-marker-id="${e.id}"]`);r&&r.classList.remove("drc-unvisited"),this._zoomToBBox(i.bbox),this._refreshOverlay(),t&&(i.select_id!=null&&this._app.navigateInspector&&this._app.navigateInspector(i.select_id),this._app.focusComponent&&this._app.focusComponent("Inspector"))}}).catch(i=>{console.error("Failed to highlight DRC marker:",i)})}_zoomToBBox(e){if(!this._app.designScale||!this._app.view)return;let[t,i,r,s]=e,o=r-t,a=s-i,l=10*this._app.getDbuPerMicron(),u=2*Math.max(o,a),f=Math.min(l,u);this._app.view.fitWorldRect(Nt(t-f,i-f,r+f,s+f,this._app.designScale,this._app.designOriginX,this._app.designOriginY))}_updateMarker(e,t,i){this._app.websocketManager.request({type:"drc_update_marker",marker_id:e,field:t,value:!!i}).then(()=>{this._refreshOverlay(),t==="visible"&&(this._update3DHighlights(),i&&this._flashHighlight())}).catch(r=>{console.error("Failed to update DRC marker:",r)})}_flashHighlight(){this._app.view?.flashTiles()}_update3DHighlights(){let e=this._app.threeDViewerWidget;if(!e)return;let t=[];this._collectVisibleMarkers(this._markerTree,t),t.length>0?e.highlightDRC(t):e.clearHighlightDRC()}_collectVisibleMarkers(e,t){if(e){if(e.markers)for(let i of e.markers)i.visible&&t.push(i);if(e.subcategories)for(let i of e.subcategories)this._collectVisibleMarkers(i,t)}}_setMarkersVisible(e,t){if(e){if(e.markers)for(let i of e.markers)i.visible=t;if(e.subcategories)for(let i of e.subcategories)this._setMarkersVisible(i,t)}}_snapshotMarkerVisibility(e,t=new Map){if(!e)return t;if(e.markers)for(let i of e.markers)t.set(i.id,i.visible);if(e.subcategories)for(let i of e.subcategories)this._snapshotMarkerVisibility(i,t);return t}_restoreMarkerVisibility(e,t){if(e){if(e.markers)for(let i of e.markers)t.has(i.id)&&(i.visible=t.get(i.id));if(e.subcategories)for(let i of e.subcategories)this._restoreMarkerVisibility(i,t)}}_allMarkersVisible(e){if(e.markers){for(let t of e.markers)if(!t.visible)return!1}if(e.subcategories){for(let t of e.subcategories)if(!this._allMarkersVisible(t))return!1}return!0}_toggleCategoryVisibility(e,t,i){let r=this._snapshotMarkerVisibility(e);this._setMarkersVisible(e,t),this._renderTree(),this._app.websocketManager.request({type:"drc_update_category_visibility",category:e.name,path:i||[e.name],visible:!!t}).then(()=>{this._refreshOverlay(),this._update3DHighlights(),t&&this._flashHighlight()}).catch(s=>{console.error("Failed to update category visibility:",s),this._restoreMarkerVisibility(e,r),this._renderTree()})}_showLoadDialog(){new uv(this._app,t=>{this._activeCategory=t,this._loadCategories().then(()=>{this._categorySelect.value=this._activeCategory,this._loadMarkers()})}).open()}selectCategory(e){this._activeCategory=e,this._categorySelect.value=e,this._loadMarkers()}},uv=class{constructor(e,t){this._app=e,this._onLoaded=t,this._currentPath="",this._disposers=[],this._closed=!1}open(){this._overlay=document.createElement("div"),this._overlay.className="modal-overlay",this._overlay.innerHTML=` - `,document.body.appendChild(this._overlay),this._breadcrumb=this._overlay.querySelector(".fb-breadcrumb"),this._fileList=this._overlay.querySelector(".fb-file-list"),this._pathInput=this._overlay.querySelector(".fb-path-input"),this._errorDiv=this._overlay.querySelector(".modal-error"),this._okBtn=this._overlay.querySelector(".ok"),this._cancelBtn=this._overlay.querySelector(".cancel"),this._listen(this._pathInput,"input",()=>this._updateOkState()),this._listen(this._pathInput,"keydown",e=>{if(e.key==="Enter"){let t=this._pathInput.value.trim();t.endsWith("/")?this._navigate(t.replace(/\/+$/,"")||"/"):this._submit()}else e.key==="Escape"&&this.close()}),this._listen(this._okBtn,"click",()=>this._submit()),this._listen(this._cancelBtn,"click",()=>this.close()),this._listen(this._overlay,"click",e=>{e.target===this._overlay&&this.close()}),this._navigate("")}close(){if(!this._closed){this._closed=!0;for(let e of this._disposers)e();this._disposers.length=0,this._overlay&&(this._overlay.remove(),this._overlay=null)}}_listen(e,t,i){e.addEventListener(t,i),this._disposers.push(()=>e.removeEventListener(t,i))}_updateOkState(){this._okBtn.disabled=!this._pathInput.value.trim()}_renderBreadcrumb(e){this._breadcrumb.innerHTML="";let t=e.split("/").filter(Boolean),i=document.createElement("span");i.className="fb-crumb",i.textContent="/",this._listen(i,"click",()=>this._navigate("/")),this._breadcrumb.appendChild(i);let r="";for(let s of t){r+="/"+s;let o=document.createElement("span");o.className="fb-crumb-sep",o.textContent=" / ",this._breadcrumb.appendChild(o);let a=document.createElement("span");a.className="fb-crumb",a.textContent=s;let c=r;this._listen(a,"click",()=>this._navigate(c)),this._breadcrumb.appendChild(a)}}_renderEntries(e){if(this._fileList.innerHTML="",!e||e.length===0){let t=document.createElement("div");t.className="fb-empty",t.textContent="(empty directory)",this._fileList.appendChild(t);return}for(let t of e){let i=document.createElement("div");i.className="fb-entry",t.is_dir&&i.classList.add("fb-dir");let r=document.createElement("span");r.className="fb-icon",r.textContent=t.is_dir?"\u{1F4C1}":"\u{1F4C4}",i.appendChild(r);let s=document.createElement("span");s.className="fb-name",s.textContent=t.name,i.appendChild(s),t.is_dir?this._listen(i,"click",()=>this._navigate(this._currentPath+"/"+t.name)):(this._listen(i,"click",()=>{let o=this._fileList.querySelector(".fb-selected");o&&o.classList.remove("fb-selected"),i.classList.add("fb-selected"),this._pathInput.value=this._currentPath+"/"+t.name,this._updateOkState()}),this._listen(i,"dblclick",()=>{this._pathInput.value=this._currentPath+"/"+t.name,this._updateOkState(),this._submit()})),this._fileList.appendChild(i)}}async _navigate(e){this._errorDiv.style.display="none",this._fileList.innerHTML='
Loading...
';try{let t=await this._app.websocketManager.request({type:"list_dir",path:e||""});if(this._closed)return;this._currentPath=t.path,this._renderBreadcrumb(t.path),this._renderEntries(t.entries),this._pathInput.value="",this._updateOkState()}catch(t){if(this._closed)return;this._fileList.innerHTML="",this._errorDiv.textContent=t.message||String(t),this._errorDiv.style.display=""}}async _submit(){let e=this._pathInput.value.trim();if(e){this._okBtn.disabled=!0,this._okBtn.textContent="Loading...",this._errorDiv.style.display="none";try{let t=await this._app.websocketManager.request({type:"drc_load_report",path:e});if(this._closed)return;if(t.ok){let i=t.category;this.close(),this._onLoaded(i)}else this._errorDiv.textContent=t.error||"Failed to load report",this._errorDiv.style.display="",this._okBtn.disabled=!1,this._okBtn.textContent="Load"}catch(t){if(this._closed)return;this._errorDiv.textContent=t.message||"Request failed",this._errorDiv.style.display="",this._okBtn.disabled=!1,this._okBtn.textContent="Load"}}}};var QW=` -\r[]{}`;var ip=class{constructor(e,t){this._input=e,this._ws=t,this._popup=null,this._items=[],this._selectedIndex=-1,this._replaceStart=0,this._replaceEnd=0,this._debounceTimer=null,this._commandCache=null,this._history=[],this._historyIndex=-1,this._historyStash="",this._createPopup(),this._onInputBound=this._onInput.bind(this),this._onBlurBound=this._onBlur.bind(this),this._input.addEventListener("input",this._onInputBound),this._input.addEventListener("blur",this._onBlurBound)}_createPopup(){this._popup=document.createElement("div"),this._popup.className="tcl-complete-popup",this._popup.style.display="none",this._input.parentElement.appendChild(this._popup)}handleKeyDown(e){let t=this._popup.style.display!=="none";return e.key==="Tab"?(e.preventDefault(),t?this._tabAccept():this._tabComplete(this._input.value,this._input.selectionStart),!0):e.key==="Escape"?t?(this._hidePopup(),!0):!1:e.key==="ArrowDown"?t?(e.preventDefault(),this._selectItem(this._selectedIndex+1),!0):this._historyIndex>=0?(e.preventDefault(),this._historyIndex--,this._historyIndex<0?this._input.value=this._historyStash:this._input.value=this._history[this._historyIndex],!0):!1:e.key==="ArrowUp"?t?(e.preventDefault(),this._selectItem(this._selectedIndex-1),!0):this._historyIndex{let e=this._input.value,t=this._input.selectionStart,i=this._extractPrefix(e,t);i.length>=2||i.length>=1&&(i[0]==="$"||i[0]==="-")?this._requestCompletions(e,t):this._hidePopup()},100)}_onBlur(){setTimeout(()=>this._hidePopup(),150)}_extractPrefix(e,t){let i=t-1;for(;i>=0&&QW.indexOf(e[i])===-1;)i--;return e.substring(i+1,t)}_fetchCompletions(e,t,i){let r=this._extractPrefix(e,t),s=r.length>0&&r[0]==="$",o=r.length>0&&r[0]==="-",a=!s&&!o,c=t-r.length,l=e.substring(0,c),u=/^[\s\[]*$/.test(l);if(a&&u&&this._commandCache){let f=r.toLowerCase(),d=this._commandCache.filter(h=>h.toLowerCase().startsWith(f));i(d,c,t);return}this._ws.request({type:"tcl_complete",line:e,cursor_pos:t}).then(f=>{f.mode==="commands"&&!this._commandCache&&r===""&&(this._commandCache=f.completions),f.mode==="commands"&&!this._commandCache&&this._ws.request({type:"tcl_complete",line:"",cursor_pos:0}).then(d=>{d.mode==="commands"&&(this._commandCache=d.completions)}).catch(()=>{}),i(f.completions,f.replace_start,f.replace_end)}).catch(()=>i([],0,0))}_requestCompletions(e,t){this._fetchCompletions(e,t,(i,r,s)=>{this._showPopup(i,r,s)})}_tabAccept(){if(this._items.length===0){this._hidePopup();return}if(this._items.length===1){this._selectedIndex=0,this._acceptCompletion();return}this._advanceToCommonPrefix()}_tabComplete(e,t){this._fetchCompletions(e,t,(i,r,s)=>{if(!i||i.length===0){this._hidePopup();return}if(i.length===1){this._items=i,this._replaceStart=r,this._replaceEnd=s,this._selectedIndex=0,this._acceptCompletion();return}this._items=i,this._replaceStart=r,this._replaceEnd=s,this._advanceToCommonPrefix(),this._showPopup(i,this._replaceStart,this._replaceEnd)})}_advanceToCommonPrefix(){if(this._items.length<2)return!1;let e=this._items[0];for(let o=1;o0;o++){let a=this._items[o],c=0;for(;c{let c=document.createElement("div");c.className="tcl-complete-item",c.textContent=o,c.addEventListener("mousedown",l=>{l.preventDefault(),this._selectedIndex=a,this._acceptCompletion()}),this._popup.appendChild(c)}),e.length>15){let o=document.createElement("div");o.className="tcl-complete-more",o.textContent=`... ${e.length-15} more`,this._popup.appendChild(o)}this._selectedIndex=0,this._highlightSelected(),this._popup.style.display="block"}_hidePopup(){this._popup.style.display="none",this._items=[],this._selectedIndex=-1}_selectItem(e){if(this._items.length===0)return;let t=Math.min(this._items.length,15)-1;this._selectedIndex=Math.max(0,Math.min(e,t)),this._highlightSelected()}_highlightSelected(){let e=this._popup.querySelectorAll(".tcl-complete-item");e.forEach((t,i)=>{t.classList.toggle("selected",i===this._selectedIndex)}),e[this._selectedIndex]&&e[this._selectedIndex].scrollIntoView&&e[this._selectedIndex].scrollIntoView({block:"nearest"})}_acceptCompletion(){if(this._selectedIndex<0||this._selectedIndex>=this._items.length){this._hidePopup();return}let e=this._items[this._selectedIndex],t=this._input.value.substring(0,this._replaceStart),i=this._input.value.substring(this._replaceEnd),s=!e.endsWith("/")&&!e.endsWith("::")&&(i.length===0||i[0]!==" ")?" ":"";this._input.value=t+e+s+i;let o=this._replaceStart+e.length+s.length;this._input.setSelectionRange(o,o),this._input.focus(),this._hidePopup()}};var IM=[{key:"or_visibility",store:"cookie"},{key:"or_selectability",store:"cookie"},{key:"or_hidden_layers",store:"session"},{key:"or_nonselectable_layers",store:"session"},{key:"or_layer_patterns",store:"session"},{key:"or_hidden_chiplets",store:"cookie"},{key:"or_bg_color",store:"cookie"},{key:"or_show_dbu",store:"cookie"},{key:"or_theme",store:"theme"},{key:"or_use_true_z",store:"cookie"},{key:"or_ruler_style",store:"cookie"},{key:"or_wheel_zoom",store:"cookie"},{key:"or_arrow_step",store:"cookie"},{key:"or_font_family",store:"cookie"},{key:"or_font_scale",store:"cookie"},{key:"or_control_smoothing",store:"cookie"},{key:"or_double_buffer",store:"cookie"},{key:"or_defer_tile_updates",store:"cookie"}];function BM(n){return{controlSmoothing:n("or_control_smoothing")==="1",doubleBuffer:n("or_double_buffer")!=="0",deferTileUpdates:n("or_defer_tile_updates")==="1"}}function JW(n,e){try{return window[n].getItem(e)}catch{return null}}function e5(n,e,t){try{t===null?window[n].removeItem(e):window[n].setItem(e,t)}catch{}}function t5({key:n,store:e}){return e==="session"?JW("sessionStorage",n):We(n)}function n5({key:n,store:e},t){e==="session"?e5("sessionStorage",n,t):e==="theme"?t===null?J3():Nh(t):t===null?Dh(n):$e(n,t)}function OM(){let n={};for(let e of IM){let t=t5(e);t&&(n[e.key]=t)}return{version:1,entries:n}}function i5(n){return typeof n=="string"&&n!==""&&!/[;\r\n]/.test(n)}function DM(n){for(let e of IM){let t=n[e.key];n5(e,i5(t)?t:null)}}function NM(n,e=typeof document<"u"?document:null){let t="OpenROAD",i=n?`${t} - ${n}`:t;return e&&(e.title=i),i}var ce=globalThis.THREE,FM=2,r5=.002,s5=.9,o5=1.1,a5=.1,c5=20,l5=3,As=2,zM=2,u5=10,f5=1e4,d5=.15,h5=300,p5=6,rp=Math.PI/180,UM=[5025616,2201331,16750592,10233776,48340,16007990,2533018,7951688,15277667,4149685];function m5(n){let e=new Array(n.length).fill(0),t=new Map;n.forEach((i,r)=>{let s=i.z;t.has(s)||t.set(s,[]),t.get(s).push({idx:r,chiplet:i})});for(let i of t.values()){if(i.length<=1)continue;let r=[];for(let{idx:s,chiplet:o}of i){let a=o.x,c=o.y,l=o.x+o.width,u=o.y+o.height,f=!1;for(let d=0;dap.x1&&cp.y1)){r[d].push({x1:a,y1:c,x2:l,y2:u}),e[s]=d,f=!0;break}f||(r.push([{x1:a,y1:c,x2:l,y2:u}]),e[s]=r.length-1)}}return e}var sp=class{constructor(e,t){if(this._app=t,this._container=e,this._element=document.createElement("div"),this._element.className="three-d-viewer-widget",e.element.appendChild(this._element),!ce){fe(t)?this._showInfo("The 3D view is not available in saved reports."):this._showError("three.js is missing from the page."),this._destroyed=!0;return}this._canvasContainer=document.createElement("div"),this._canvasContainer.className="three-d-canvas-container",this._element.appendChild(this._canvasContainer),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._canvasContainer.appendChild(this._tooltip),this._optionsOverlay=this._createOptionsOverlay(),this._canvasContainer.appendChild(this._optionsOverlay),this._raycaster=new ce.Raycaster,this._scene=new ce.Scene,this._applyTheme(),this._themeObserver=new MutationObserver(()=>{this._applyTheme(),this.render()}),this._themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),this._camera=new ce.PerspectiveCamera(45,1,10,1e5),this._camera.position.set(0,0,1e3);try{this._renderer=new ce.WebGLRenderer({antialias:!0,preserveDrawingBuffer:!0})}catch(o){console.error("3D viewer: failed to create WebGL context:",o),this._showWebGLUnavailable(o),this._themeObserver&&(this._themeObserver.disconnect(),this._themeObserver=null),this._destroyed=!0;return}this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(e.width,e.height),this._canvasContainer.appendChild(this._renderer.domElement),this._rotation=new ce.Quaternion,this._distance=1e3,this._panX=0,this._panY=0,this._boundingRadius=1,this._sceneCenter=new ce.Vector3,this._mouseDown=!1,this._mouseButton=-1,this._lastMousePos={x:0,y:0},this._setupMouseHandlers();let i=new ce.AmbientLight(16777215,.5);this._scene.add(i);let r=new ce.DirectionalLight(16777215,.8);r.position.set(1,1,1).normalize(),this._scene.add(r);let s=new ce.DirectionalLight(16777215,.3);s.position.set(-1,-.5,.5).normalize(),this._scene.add(s),e.on("resize",this.onResize.bind(this)),e.on("open",this.onOpen.bind(this)),e.on("destroy",this.onDestroy.bind(this)),this._designGroup=new ce.Group,this._scene.add(this._designGroup),this._chipletMeshes=[],this._loading=!1,this._destroyed=!1,this._edgeMaterial=null}_setupMouseHandlers(){let e=this._renderer.domElement;e.addEventListener("mousedown",t=>{this._mouseDown=!0,this._mouseButton=t.button,this._lastMousePos.x=t.clientX,this._lastMousePos.y=t.clientY,e.focus(),t.preventDefault()}),e.addEventListener("contextmenu",t=>t.preventDefault()),this._onMouseMove=t=>{if(!this._mouseDown)return;let i=t.clientX-this._lastMousePos.x,r=t.clientY-this._lastMousePos.y;this._lastMousePos.x=t.clientX,this._lastMousePos.y=t.clientY,!(i===0&&r===0)&&(this._mouseButton===0?this._handleRotate(i,r):this._mouseButton===2&&this._handlePan(i,r),this._updateCamera())},this._onMouseUp=t=>{this._mouseDown&&t.button===this._mouseButton&&(this._mouseDown=!1,this._mouseButton=-1)},window.addEventListener("mousemove",this._onMouseMove),window.addEventListener("mouseup",this._onMouseUp),e.addEventListener("wheel",t=>{t.preventDefault(),t.deltaY<0?this._distance*=s5:this._distance*=o5;let i=Math.max(this._boundingRadius*a5,1),r=Math.max(this._boundingRadius*c5,i);this._distance=Math.max(i,Math.min(r,this._distance)),this._updateCamera()},{passive:!1}),e.tabIndex=0,e.style.outline="none",e.addEventListener("keydown",t=>{t.key.toLowerCase()==="f"&&this.resetCamera()}),e.addEventListener("dblclick",t=>{t.preventDefault();let i=this._pickDrcMarkerId(t);if(i!=null&&this._app.drcWidget){this._app.drcWidget.highlightMarkerById(i,!0);return}this.resetCamera()}),e.addEventListener("mousemove",t=>{if(this._mouseDown){this._hideTooltip();return}this._updateTooltip(t)}),e.addEventListener("mouseleave",()=>{this._hideTooltip()})}_createOptionsOverlay(){let e=document.createElement("div");e.className="three-d-options";let t=document.createElement("label");t.title="Render chiplets at their true Z (disable stacking offset for overlapping chiplets at same Z).";let i=document.createElement("input");i.type="checkbox",i.checked=!!this._app.useTrueZ,i.addEventListener("change",()=>{this._app.useTrueZ=i.checked,$e("or_use_true_z",i.checked?"1":"0"),this._app.syncDisplayState(),this.refreshSceneForOptions()}),t.appendChild(i),t.appendChild(document.createTextNode("True Z (no stacking)")),e.appendChild(t);let r=document.createElement("div");r.style.cssText="margin-top:4px; display:flex; gap:4px;";let s=document.createElement("button");s.className="or-btn or-btn-sm",s.textContent="Save PNG",s.title="Save the 3D view as a PNG image (2x resolution)",s.addEventListener("click",()=>this._exportPng(2));let o=document.createElement("button");return o.className="or-btn or-btn-sm",o.textContent="Copy",o.title="Copy the 3D view image to the clipboard",o.addEventListener("click",()=>this._copyImage(2)),r.appendChild(s),r.appendChild(o),e.appendChild(r),e}_capturePng(e=2){if(!this._renderer)return null;let t=this._renderer,i=t.domElement.clientWidth||t.domElement.width,r=t.domElement.clientHeight||t.domElement.height,s=t.getPixelRatio();try{return t.setPixelRatio(s*e),t.setSize(i,r,!1),this.render(),t.domElement.toDataURL("image/png")}finally{t.setPixelRatio(s),t.setSize(i,r,!1),this.render()}}_exportPng(e=2){let t=this._capturePng(e);t&&Ts(t,"3d-view.png")}async _copyImage(e=2){let t=this._capturePng(e);t&&await Fh(t)}_setRaycasterFromEvent(e){let i=this._renderer.domElement.getBoundingClientRect(),r=new ce.Vector2((e.clientX-i.left)/i.width*2-1,-((e.clientY-i.top)/i.height*2-1));this._raycaster.setFromCamera(r,this._camera)}_updateTooltip(e){if(!this._chipletMeshes.length){this._hideTooltip();return}this._setRaycasterFromEvent(e);let t=this._chipletMeshes.map(a=>a.mesh),i=this._raycaster.intersectObjects(t,!1);if(i.length===0){this._hideTooltip();return}let r=i[0].object,s=this._chipletMeshes.find(a=>a.mesh===r);if(!s){this._hideTooltip();return}this._tooltip.textContent=s.data.name,this._tooltip.style.display="block";let o=this._canvasContainer.getBoundingClientRect();this._tooltip.style.left=e.clientX-o.left+12+"px",this._tooltip.style.top=e.clientY-o.top+12+"px"}_hideTooltip(){this._tooltip&&(this._tooltip.style.display="none")}_pickDrcMarkerId(e){if(!this._drcHitboxMesh||!this._drcHitboxMarkerIds)return null;this._setRaycasterFromEvent(e);let t=this._raycaster.intersectObject(this._drcHitboxMesh,!1);if(t.length===0)return null;let i=t[0].instanceId;return i==null?null:this._drcHitboxMarkerIds[i]??null}_handleRotate(e,t){let i=Math.sqrt(e*e+t*t);if(i<.001)return;let r=new ce.Vector3(t/i,e/i,0),s=i/FM,a=new ce.Quaternion().setFromAxisAngle(r,s*rp).clone().multiply(this._rotation);if(new ce.Vector3(0,0,1).applyQuaternion(a).z>=0)this._rotation.copy(a);else{let l=new ce.Vector3(0,1,0),u=e/FM*rp,d=new ce.Quaternion().setFromAxisAngle(l,u).clone().multiply(this._rotation);new ce.Vector3(0,0,1).applyQuaternion(d).z>=0&&this._rotation.copy(d)}}_handlePan(e,t){let i=this._distance*r5;this._panX+=e*i,this._panY-=t*i}_updateCamera(){let e=Math.max(this._boundingRadius,1e3),t=Math.max(this._distance-e*zM,u5),i=this._distance+e*zM;i0;){let e=this._designGroup.children[0];this._designGroup.remove(e),e.geometry&&e.geometry.dispose(),e.material&&!e.material._shared&&e.material.dispose()}this._edgeMaterial&&(this._edgeMaterial.dispose(),this._edgeMaterial=null),this._onMouseMove&&(window.removeEventListener("mousemove",this._onMouseMove),this._onMouseMove=null),this._onMouseUp&&(window.removeEventListener("mouseup",this._onMouseUp),this._onMouseUp=null),this._renderer&&(this._renderer.dispose(),this._renderer=null),this._app.threeDViewerWidget===this&&(this._app.threeDViewerWidget=null)}}_setInitialCameraState(){this._distance=this._boundingRadius*l5;let e=new ce.Quaternion().setFromAxisAngle(new ce.Vector3(1,0,0),-45*rp),t=new ce.Quaternion().setFromAxisAngle(new ce.Vector3(0,0,1),45*rp);this._rotation=e.multiply(t),this._panX=0,this._panY=0}resetCamera(){this._sceneBounds&&(this._setInitialCameraState(),this._updateCamera())}onResize(){if(this._destroyed)return;let e=this._canvasContainer.getBoundingClientRect(),t=e.width,i=e.height;t===0||i===0||(this._camera.aspect=t/i,this._camera.updateProjectionMatrix(),this._renderer.setSize(t,i),this.render())}render(){this._destroyed||this._renderer&&this._scene&&this._camera&&this._renderer.render(this._scene,this._camera)}_applyTheme(){let t=Cs().bgMap||"#000000";this._scene.background=new ce.Color(t)}async loadData(){if(!(this._loading||this._destroyed)){this._loading=!0;for(let e of[".three-d-error",".three-d-info"]){let t=this._element.querySelector(e);t&&t.remove()}try{await this._app.websocketManager.readyPromise;let e=await this._app.websocketManager.request({type:"get_3d_data"});if(this._destroyed)return;if(e&&e.error){this._showError(e.error);return}if(e&&e.info){this._showInfo(e.info);return}this.buildScene(e)}catch(e){if(this._destroyed)return;console.error("Failed to load 3D data:",e),this._showError(e.message||String(e))}finally{this._loading=!1}}}_showOverlay(e,t,i){let r=document.createElement("div");r.className=e,r.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-family:monospace;text-align:center;",r.style.color=i,r.textContent=t,this._element.appendChild(r)}_showError(e){this._showOverlay("three-d-error","Failed to load 3D data: "+e,"var(--error)")}_showInfo(e){this._showOverlay("three-d-info",e,"var(--fg-muted, #888)")}_showWebGLUnavailable(e){let t=document.createElement("div");t.className="three-d-error",t.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-family:monospace;text-align:center;max-width:80%;color:var(--error);";let i=e&&e.message?e.message:String(e||"");t.innerHTML='
3D viewer unavailable: WebGL context could not be created.
In Chrome, open chrome://flags/#ignore-gpu-blocklist and set Override software rendering list to Enabled, then relaunch the browser.
Otherwise enable hardware acceleration or try a different browser. See chrome://gpu for details.
'+(i?'
'+i+"
":""),this._element.appendChild(t)}buildScene(e){if(this._destroyed||(this._lastSceneData=e,this._clearScene(),!e||!e.chiplets||e.chiplets.length===0))return;let t=this._app.getDbuPerMicron(),i=this._buildChiplets(e.chiplets,t);i.minX!==1/0&&(this._buildGrid(i),this._setSceneBoundsAndCenter(i),this._setInitialCameraState(),this._updateCamera())}_clearScene(){for(this._chipletMeshes=[];this._designGroup.children.length>0;){let e=this._designGroup.children[0];this._designGroup.remove(e),e.geometry&&e.geometry.dispose(),e.material&&!e.material._shared&&e.material.dispose()}this._hideTooltip()}_buildChiplets(e,t){let i={minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0};this._edgeMaterial||(this._edgeMaterial=new ce.LineBasicMaterial({color:0,linewidth:1}),this._edgeMaterial._shared=!0);let r=this._app.useTrueZ?new Array(e.length).fill(0):m5(e);return e.forEach((s,o)=>{let a=s.width/t,c=s.height/t,l=s.thickness/t*As,u=UM[o%UM.length],f=new ce.MeshPhongMaterial({color:u,transparent:!1,opacity:1,side:ce.DoubleSide,shininess:40}),d=new ce.BoxGeometry(a,c,l),h=new ce.Mesh(d,f),p=s.x/t+a/2,m=s.y/t+c/2,g=l*d5,v=s.z/t*As+l/2+r[o]*(l+g);h.position.set(p,m,v),this._designGroup.add(h),this._chipletMeshes.push({mesh:h,data:s,color:u});let y=new ce.EdgesGeometry(d),b=new ce.LineSegments(y,this._edgeMaterial);b.position.set(p,m,v),this._designGroup.add(b),i.minX=Math.min(i.minX,s.x/t),i.minY=Math.min(i.minY,s.y/t),i.minZ=Math.min(i.minZ,v-l/2),i.maxX=Math.max(i.maxX,s.x/t+a),i.maxY=Math.max(i.maxY,s.y/t+c),i.maxZ=Math.max(i.maxZ,v+l/2)}),i}_buildGrid(e){let t=e.maxX-e.minX,i=e.maxY-e.minY,r=Math.max(t,i)*1.4,s=10,o=new ce.GridHelper(r,s,8947848,4473924);o.rotation.x=Math.PI/2,o.position.set((e.minX+e.maxX)/2,(e.minY+e.maxY)/2,e.minZ-1),this._designGroup.add(o)}_setSceneBoundsAndCenter(e){this._sceneBounds=e;let t=e.maxX-e.minX,i=e.maxY-e.minY,r=e.maxZ-e.minZ;this._boundingRadius=Math.sqrt(t*t+i*i+r*r)/2,this._sceneCenter.set((e.minX+e.maxX)/2,(e.minY+e.maxY)/2,(e.minZ+e.maxZ)/2)}_stackOffsetForPoint(e,t,i,r){for(let{mesh:s,data:o}of this._chipletMeshes){if(e!==o.z||to.x+o.width||io.y+o.height)continue;let a=o.thickness/r*As,c=o.z/r*As+a/2;return s.position.z-c}return 0}clearHighlightDRC(){this._drcBlinkInterval&&(clearInterval(this._drcBlinkInterval),this._drcBlinkInterval=null),this._drcMeshGroup&&(this._scene.remove(this._drcMeshGroup),this._drcMeshGroup.children.forEach(e=>{e.geometry&&e.geometry.dispose()}),this._drcMaterial&&(this._drcMaterial.dispose(),this._drcMaterial=null),this._drcHitboxMaterial&&(this._drcHitboxMaterial.dispose(),this._drcHitboxMaterial=null),this._drcHitboxMesh=null,this._drcHitboxMarkerIds=null,this._drcMeshGroup=null,this.render())}highlightDRC(e){if(this._destroyed||(this.clearHighlightDRC(),!e||e.length===0))return;let t=this._app.getDbuPerMicron(),i=0,r=1e4/t*As;this._sceneBounds&&this._sceneBounds.minZ!==1/0&&(i=this._sceneBounds.minZ,r=this._sceneBounds.maxZ),i-=1,r+=1;let s=Math.max(r-i,1);this._drcMeshGroup=new ce.Group,this._drcMaterial=new ce.LineBasicMaterial({color:16776960,transparent:!0,opacity:1,depthTest:!1,depthWrite:!1}),this._drcHitboxMaterial=new ce.MeshBasicMaterial({transparent:!0,opacity:0,depthWrite:!1});let o=[];for(let l of e){let u=l.rects&&l.rects.length>0?l.rects:[l.bbox];for(let f of u){let[d,h,p,m,g,v]=f,y=Math.max((p-d)/t,.001),b=Math.max((m-h)/t,.001),x=i,E=s,w=0;if(f.length>=6&&g!==void 0&&v!==void 0){x=g/t*As;let O=v/t*As;E=Math.max(O-x,.001),w=this._stackOffsetForPoint(g,(d+p)/2,(h+m)/2,t)}let T=d/t+y/2,R=h/t+b/2,F=x+E/2+w;o.push({cx:T,cy:R,cz:F,width:y,height:b,depth:E,markerId:l.id})}}if(o.length>0){let l=new ce.BoxGeometry(1,1,1);this._drcHitboxMesh=new ce.InstancedMesh(l,this._drcHitboxMaterial,o.length),this._drcHitboxMarkerIds=new Array(o.length);let u=new ce.Matrix4,f=new ce.Vector3,d=new ce.Vector3,h=new ce.Quaternion;o.forEach((p,m)=>{d.set(p.cx,p.cy,p.cz),f.set(p.width,p.height,p.depth),u.compose(d,h,f),this._drcHitboxMesh.setMatrixAt(m,u),this._drcHitboxMarkerIds[m]=p.markerId;let g=new ce.BoxGeometry(p.width,p.height,p.depth),v=new ce.EdgesGeometry(g);g.dispose();let y=new ce.LineSegments(v,this._drcMaterial);y.position.set(p.cx,p.cy,p.cz),y.renderOrder=999,this._drcMeshGroup.add(y)}),this._drcHitboxMesh.instanceMatrix.needsUpdate=!0,this._drcMeshGroup.add(this._drcHitboxMesh)}this._drcMeshGroup.renderOrder=999,this._scene.add(this._drcMeshGroup),this.render();let a=!0,c=0;this._drcBlinkInterval=setInterval(()=>{if(!(!this._drcMeshGroup||!this._drcMaterial)){if(c+=1,c>=p5){this._drcMaterial.opacity=1,this.render(),clearInterval(this._drcBlinkInterval),this._drcBlinkInterval=null;return}a=!a,this._drcMaterial.opacity=a?1:.2,this.render()}},h5)}refreshSceneForOptions(){this._destroyed||this._lastSceneData&&(this.clearHighlightDRC(),this.buildScene(this._lastSceneData))}};var g5=[{name:"green",hex:"#00ff00"},{name:"yellow",hex:"#ffff00"},{name:"cyan",hex:"#00ffff"},{name:"magenta",hex:"#ff00ff"},{name:"red",hex:"#ff0000"},{name:"dark_green",hex:"#008000"},{name:"dark_magenta",hex:"#800080"},{name:"blue",hex:"#0000ff"},{name:"orange",hex:"#ffa500"},{name:"purple",hex:"#800080"},{name:"lime",hex:"#bfff00"},{name:"teal",hex:"#008080"},{name:"pink",hex:"#ffc0cb"},{name:"brown",hex:"#8b4513"},{name:"indigo",hex:"#4b0082"},{name:"turquoise",hex:"#40e0d0"}],_5=[{label:"Connected Insts",suffix:"connected_insts",needsNet:!0},{label:"Output Nets",suffix:"connected_nets",args:{output:!0,input:!1}},{label:"Input Nets",suffix:"connected_nets",args:{output:!1,input:!0}},{label:"All Nets",suffix:"connected_nets",args:{output:!0,input:!0}},{label:"All buffer trees",suffix:"connected_buffer_trees"},{label:"All buffer trees (incl. inverters)",suffix:"connected_buffer_trees",args:{include_inverters:!0}}],op=class{constructor(e){this._app=e,this._el=document.createElement("div"),this._el.className="context-menu",this._el.style.display="none",this._el.style.zIndex="10000",document.body.appendChild(this._el),this._bindEvents()}_bindEvents(){document.addEventListener("mousedown",e=>{this._el.contains(e.target)||this.hide()}),this._app.view&&this._app.view.on("movestart",()=>this.hide())}show(e){this._el.innerHTML="";let t=!!this._app.selHasInst,i=!!this._app.selHasNet,r=!(t||i),s=h=>_5.map(p=>({label:p.label,disabled:p.needsNet?!i:!t,...h(p.suffix,p.args||{})})),o=[{label:"Select",disabled:r,subMenu:s((h,p)=>({action:()=>this._sendContextAction("select_"+h,p)}))},{label:"Highlight",disabled:r,subMenu:s((h,p)=>({subMenu:this._buildColorSubmenu("highlight_"+h,p)}))},{label:"Save",subMenu:[{label:"Visible layout",action:()=>this._app.captureLayout?.({entire:!1})},{label:"Entire layout",action:()=>this._app.captureLayout?.({entire:!0})}]},{label:"Clear",subMenu:[{label:"Selections",action:()=>this._sendContextAction("clear_selections")},{label:"Highlights",action:()=>this._sendContextAction("clear_highlights")},{label:"Rulers",action:()=>{this._app.rulerManager?.clearAllRulers()}},{label:"Focus nets",action:()=>this._sendContextAction("clear_focus_nets")},{label:"Route Guides",action:()=>this._sendContextAction("clear_route_guides")},{label:"All",action:()=>{this._sendContextAction("clear_all"),this._app.rulerManager?.clearAllRulers()}}]}];this._buildMenu(o,this._el),this._el.style.display="block";let a=4,c=this._el.getBoundingClientRect(),l=window.innerWidth-c.width-a,u=window.innerHeight-c.height-a,f=Math.max(a,Math.min(e.clientX,l)),d=Math.max(a,Math.min(e.clientY,u));this._el.style.left=f+"px",this._el.style.top=d+"px"}hide(){this._el.style.display="none"}_buildColorSubmenu(e,t={}){return g5.map(({name:i,hex:r},s)=>({label:i,swatch:r,action:()=>this._sendContextAction(e,{...t,group:s})}))}_buildMenu(e,t){e.forEach(i=>{let r=document.createElement("div");if(r.className="cm-item",i.swatch){let s=document.createElement("span");s.className="cm-swatch",s.style.background=i.swatch,r.appendChild(s)}if(r.appendChild(document.createTextNode(i.label)),i.disabled){r.classList.add("disabled"),i.subMenu&&r.classList.add("has-submenu"),t.appendChild(r);return}if(i.subMenu){r.classList.add("has-submenu");let s=document.createElement("div");s.className="cm-submenu",this._buildMenu(i.subMenu,s),r.appendChild(s),r.addEventListener("mouseenter",()=>{s.classList.remove("flip-left"),s.getBoundingClientRect().right>window.innerWidth&&s.classList.add("flip-left")})}else i.action&&r.addEventListener("click",s=>{s.stopPropagation(),this.hide();try{i.action()}catch(o){console.error("Context menu item action threw:",i.label,o)}});t.appendChild(r)})}_sendContextAction(e,t={}){this._app.websocketManager&&this._app.websocketManager.request({type:"context_action",action:e,...t}).then(i=>{qo(this._app,i),i&&i.connected_count===0&&Ft('Nothing connected \u2014 select an instance (or a net for "Connected Insts") first.'),this._syncAfterAction(e)}).catch(i=>{console.error("Context action failed:",e,i)})}_syncAfterAction(e){let t=this._app;(e==="clear_focus_nets"||e==="clear_route_guides"||e==="clear_all")&&typeof t.redrawAllLayers=="function"&&t.redrawAllLayers(),e==="clear_selections"||e==="clear_all"?(t.updateInspector?.(null),t.stopSelectionAnimation?.(),t.clearSelectionOutline?.(),t.lastSelectionBounds=null):t.refreshInspector?.(),t.refreshOverlay?.()}};function $M(n,e){if(!n)return;let t=URL.createObjectURL(n),i=document.createElement("a");i.href=t,i.download=e,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(t),0)}function y5(n,e,t){n.view.getContainer().querySelectorAll(".or-view-markers .ruler-label").forEach(r=>{let s=r.getBoundingClientRect();if(s.width<=0||s.height<=0)return;let o=r.textContent;if(!o)return;let a=getComputedStyle(r),c=s.left-t.left,l=s.top-t.top;e.save(),e.fillStyle=a.backgroundColor||"rgba(0, 0, 0, 0.75)";let u=Math.min(parseFloat(a.borderTopLeftRadius)||0,s.height/2);u>0&&typeof e.roundRect=="function"?(e.beginPath(),e.roundRect(c,l,s.width,s.height,u),e.fill()):e.fillRect(c,l,s.width,s.height),e.fillStyle=a.color||"#eee",e.font=a.font||`${a.fontSize||"12px"} ${a.fontFamily||"monospace"}`,e.textAlign="left",e.textBaseline="middle",e.fillText(o,c+(parseFloat(a.paddingLeft)||0),l+s.height/2),e.restore()})}async function GM(n){let e=n.view.getContainer(),t=e.getBoundingClientRect(),i=Math.max(1,Math.round(t.width)),r=Math.max(1,Math.round(t.height)),s=document.createElement("canvas");s.width=i,s.height=r;let o=s.getContext("2d"),a=getComputedStyle(e).backgroundColor;o.fillStyle=a&&a!=="transparent"&&a!=="rgba(0, 0, 0, 0)"?a:"#000",o.fillRect(0,0,i,r);let c=await n.view.captureCanvas();if(c){let l=c.rect;try{o.drawImage(c.image,l.left-t.left,l.top-t.top,l.width,l.height)}catch{}}return y5(n,o,t),new Promise(l=>s.toBlob(l,"image/png"))}async function VM(n,{entire:e=!1}={}){if(!n.view)return;if(!e||!n.fitRect){$M(await GM(n),"layout_visible.png");return}let t=n.view.getCenter(),i=n.view.getZoom();try{n.view.fitWorldRect(n.fitRect,{animate:!1}),await n.view.whenTilesSettled(),$M(await GM(n),"layout_entire.png")}finally{n.view.setView(t,i,{animate:!1})}}var mr=document.getElementById("websocket-status"),Zl=null,b5=2e3,v5=20;function jM(){let n=_.websocketManager&&_.websocketManager.isConnected,e=_.websocketManager?_.websocketManager.pendingCount:0;if(n)if(Zl&&(clearTimeout(Zl),Zl=null),e>v5){let t=`pending: ${e}`,i=mr.firstElementChild;(!i?.classList.contains("pending-indicator")||i.textContent!==t)&&(mr.innerHTML=`
${t}
`),mr.style.display="block"}else mr.style.display="none";else{if(_.websocketManager?._shutdown)return;Zl||(Zl=setTimeout(()=>{_.websocketManager?.isConnected||(mr.innerHTML='
\u26A0 OpenROAD disconnected \u2014 retrying\u2026
',mr.style.display="block")},b5))}x5(e)}function x5(n){let e=_.tileProgressEl;if(!e)return;e.classList.toggle("active",n>0);let t=n>0?`${n} tile requests pending`:"";e.title!==t&&(e.title=t)}var WM=ur(jM);function w5(n){if(!n)return"";try{return decodeURIComponent(n)}catch{return""}}var _={view:null,fitRect:null,lastSelectionBounds:null,selHasInst:!1,selHasNet:!1,displayControlsEl:null,allLayers:[],designScale:null,designOriginX:0,designOriginY:0,websocketManager:null,goldenLayout:null,hasLiberty:!1,techData:null,inspectorEl:null,tclOutputEl:null,modulesLayer:null,pinsLayer:null,overlayLayers:[],hierarchyBrowser:null,focusNets:new Set,routeGuideNets:new Set,visibleLayers:new Set,visibleLayerNames:new Set,visibleChiplets:null,layerPatterns:{},useTrueZ:We("or_use_true_z")==="1",showDbu:We("or_show_dbu")==="1",rulerStyle:We("or_ruler_style")==="manhattan"?"manhattan":"euclidian",wheelZoom:We("or_wheel_zoom")!=="0",arrowStep:Gl(We("or_arrow_step")),...BM(We),fontFamily:w5(We("or_font_family")),fontScale:jl(We("or_font_scale")),polyDecomp:!1,labelManager:null,selectableLayers:new Set,heatMapData:null,activeHeatMap:"",heatMapLayer:null,heatMapLegendEl:null,renderHeatMapControls:null,rulerManager:null,selectionToken:0,selectionResetters:[],getDbuPerMicron(){return this.techData?.dbu_per_micron||1e3},unitOpts(){return{showDbu:this.showDbu,dbuPerMicron:this.getDbuPerMicron()}},formatDbu(n,e=!1){return F3(n,this.unitOpts(),e)},parseDbu(n){return z3(n,this.unitOpts())},formatDistance(n){return U3(n,this.unitOpts())},unitLabel(){return $3(this.unitOpts())}},gt={stdcells:!0,macros:!0,pad_input:!0,pad_output:!0,pad_inout:!0,pad_power:!0,pad_spacer:!0,pad_areaio:!0,pad_other:!0,phys_fill:!1,phys_endcap:!0,phys_welltap:!0,phys_tie:!0,phys_antenna:!0,phys_cover:!0,phys_bump:!0,phys_other:!0,std_bufinv:!0,std_bufinv_timing:!0,std_clock_bufinv:!0,std_clock_gate:!0,std_level_shift:!0,std_sequential:!0,std_combinational:!0,net_signal:!0,net_power:!0,net_ground:!0,net_clock:!0,net_reset:!0,net_tieoff:!0,net_scan:!0,net_analog:!0,inst_names:!0,inst_pins:!0,inst_pin_names:!1,routing:!0,routing_segments:!0,routing_vias:!0,special_nets:!0,srouting_segments:!0,srouting_vias:!0,pins:!0,pin_names:!0,access_points:!1,regions:!0,mfg_grid:!1,gcell_grid:!1,flywires_only:!1,blockages:!0,placement_blockages:!0,routing_obstructions:!0,fills:!1,rows:!1,tracks_pref:!1,tracks_non_pref:!1,module_view:!1,detailed:!1,rulers:!0,labels:!0,scale_bar:!0,focused_nets_guides:!1,highlight_selected:!0,debug:!1};try{let n=We("or_visibility");if(n){let e=JSON.parse(decodeURIComponent(n));for(let[t,i]of Object.entries(e))gt[t]=!!i}}catch{}var ta={stdcells:!0,macros:!0,pad_input:!0,pad_output:!0,pad_inout:!0,pad_power:!0,pad_spacer:!0,pad_areaio:!0,pad_other:!0,phys_fill:!0,phys_endcap:!0,phys_welltap:!0,phys_tie:!0,phys_antenna:!0,phys_cover:!0,phys_bump:!0,phys_other:!0,std_bufinv:!0,std_bufinv_timing:!0,std_clock_bufinv:!0,std_clock_gate:!0,std_level_shift:!0,std_sequential:!0,std_combinational:!0,net_signal:!0,net_power:!0,net_ground:!0,net_clock:!0,net_reset:!0,net_tieoff:!0,net_scan:!0,net_analog:!0,pins:!0,inst_pins:!0,placement_blockages:!0,routing_obstructions:!0};_.visibility=gt;_.selectability=ta;try{let n=We("or_selectability");if(n){let e=JSON.parse(decodeURIComponent(n));for(let[t,i]of Object.entries(e))ta[t]=!!i}}catch{}(function(){let e=null;try{e=new URLSearchParams(window.location.search)}catch{return}_.forceComposite=e.get("composite")==="1",_.preserveBuffer=e.get("preservebuffer")==="1";let t=Number(e.get("grouplayers"));Number.isFinite(t)&&t>0&&(_.groupLayers=Math.floor(t))})();_.tileCtx={visibility:gt,selectability:ta,visibleLayers:_.visibleLayerNames,selectableLayers:_.selectableLayers,app:_};function E5(){return _.view.addTileSlot("heatmap",{order:ot.heatmap,visible:!!_.activeHeatMap,source:Zb({wm:_.websocketManager,dpr:Yo,tileSize:on,buildRequest:(n,e,t)=>T3(n,e,t,_)})})}function dv(n){if(_.heatMapData=n,_.activeHeatMap=n.active||"",_.heatMapLayer){let e=_.heatMapLayer.isVisible();_.heatMapLayer.setVisible(!!_.activeHeatMap),e&&_.heatMapLayer.refresh()}_.renderHeatMapControls&&_.renderHeatMapControls(n)}_.updateHeatMaps=dv;function hv(){_.overlayLayer&&_.overlayLayer.refresh()}var ks=ur(()=>{hv(),_.selectionBrowser&&_.selectionBrowser.scheduleRefresh()});_.refreshOverlay=ks;function $t(){$e("or_visibility",encodeURIComponent(JSON.stringify(gt))),$e("or_selectability",encodeURIComponent(JSON.stringify(ta))),an();let n=[[_.modulesLayer,gt.module_view],[_.pinsLayer,gt.pins],..._.overlayLayers.map(({def:e,layer:t})=>[t,qh(e.shown_by,gt)])];for(let[e,t]of n)e&&(e.visible=!!t);for(let e of _.allLayers)e.refresh();_.heatMapLayer&&_.heatMapLayer.refresh(),_.renderSelectionOutline&&_.renderSelectionOutline(),!gt.highlight_selected&&_.clearSelectionPulse&&_.clearSelectionPulse(),hv(),_.rulerManager&&_.rulerManager.updateVisibility(),_.labelManager&&_.labelManager.updateVisibility(),_.updateScaleBar&&_.updateScaleBar()}var ea=ur($t),an=ur(()=>{!_.websocketManager||fe(_)||_.websocketManager.request({type:"set_display_state",state:OM()}).catch(()=>{})});_.syncDisplayState=an;function S5(n){if(!n||typeof n!="object")return;let e=n.entries;if(!(!e||typeof e!="object")){DM(e);try{if(_.view&&_.designScale&&typeof sessionStorage<"u"){let[t,i]=_.view.getCenter(),{dbuX:r,dbuY:s}=Pn(t,i,_.designScale,_.designOriginX,_.designOriginY);sessionStorage.setItem("or_restore_view",JSON.stringify({dbuX:r,dbuY:s,zoom:_.view.getZoom()}))}}catch{}window.location.reload()}}_.redrawAllLayers=$t;_.captureLayout=(n={})=>VM(_,n);function P5(n){let e=R3(n);if(e){try{if(sessionStorage.getItem("or_sw_render_warned"))return;sessionStorage.setItem("or_sw_render_warned","1")}catch{}Ft(e,15e3)}}function C5(n){let e=document.createElement("div");e.className="layout-viewer",e.style.width="100%",e.style.height="100%",e.style.backgroundColor="var(--bg-map)",n.element.appendChild(e);let t=document.createElement("div");t.className="or-hud or-hud-bottom-right heatmap-map-legend hidden",e.appendChild(t),_.heatMapLegendEl=t;let i=document.createElement("div");i.className="or-progress",e.appendChild(i),_.tileProgressEl=i,n.on("destroy",()=>{_.tileProgressEl=null,_.heatMapLegendEl=null}),_.view=X3(e,{preserveDrawingBuffer:_.preserveBuffer,prefs:{smooth:()=>_.controlSmoothing,doubleBuffer:()=>_.doubleBuffer,defer:()=>_.deferTileUpdates},tileSize:on,dpr:Yo,isStatic:fe(_)}),_.view.on("contextlost",()=>{console.warn("Layout view: WebGL context lost; rebuilding the view.")}),_.view.on("contextfailed",()=>{Ft("The layout view lost its graphics context and could not get it back; reload the page.",15e3)}),_.view.on("renderer",P5),window.__orView=_.view,m3(()=>{_.view.invalidateSize(),$t()});let r=document.createElement("div");r.className="or-zoom-control";let s=[];for(let[y,b,x]of[["+","Zoom in",()=>_.view.zoomIn()],["\u2212","Zoom out",()=>_.view.zoomOut()],["\u2922","Fit",()=>{_.fitRect&&_.view.fitWorldRect(_.fitRect)}]]){let E=document.createElement("button");E.type="button",E.title=b,E.setAttribute("aria-label",b),E.textContent=y,E.addEventListener("click",w=>{w.stopPropagation(),x()}),r.appendChild(E),s.push(E)}e.appendChild(r);let o=()=>{let{minZoom:y,maxZoom:b}=_.view.getLimits(),x=_.view.getTargetZoom();s[0].disabled=x>=b,s[1].disabled=x<=y};_.view.on("zoom zoomend limits",o),o();let a=document.createElement("div");a.className="or-hud or-hud-bottom-left hidden";let c=document.createElement("div");c.id="scale-bar";let l=document.createElement("span");l.className="or-hud-divider";let u=document.createElement("div");u.id="coord-bar",a.appendChild(c),a.appendChild(l),a.appendChild(u),e.appendChild(a);function f(){let y=c.style.display!=="none"&&c.childElementCount>0,b=u.textContent!=="";l.style.display=y&&b?"":"none",a.classList.toggle("hidden",!y&&!b)}f(),Q3(_.view,{isStatic:()=>fe(_),wheelZoom:()=>_.wheelZoom,arrowStep:()=>_.arrowStep,contextEnabled:()=>!(_.rulerManager&&_.rulerManager.isActive()),onClick:(y,b)=>{_.rulerManager&&_.rulerManager.isActive()?_.rulerManager.handleMapClick(y,b):_.rulerManager?.handleRulerClick(y)||_.onMapClick&&_.onMapClick(y,b)},onContextClick:(y,b)=>{_.onMapContextClick&&_.onMapContextClick(y,b)},onMove:(y,b)=>{if(_.lastMouseWorld=y,_.rulerManager&&_.rulerManager.isActive()&&_.rulerManager.handleMouseMove(y,b),!_.designScale)return;let{dbuX:x,dbuY:E}=Pn(y[0],y[1],_.designScale,_.designOriginX,_.designOriginY);u.textContent=`X: ${_.formatDbu(x)} Y: ${_.formatDbu(E)}`,f()},onLeave:()=>{_.lastMouseWorld=null,u.textContent="",f()}});let d=22,h=8,p=22;function m(y,b,x){let w=2+h,T=p,R=p+y,F=d-2,O=y>=40,j=[];if(j.push(``),O&&x>1)for(let V=1;V`)}O&&j.push(`0`),j.push(`${b}`),c.innerHTML=`${j.join("")}`}function g(){if(!_.designScale||!gt.scale_bar){c.style.display="none",f();return}let y=_.designScale*Math.pow(2,_.view.getZoom()),b=_.view.getSize().width||400,x=V3({targetPx:b*.15,pxPerDbu:y,dbuPerMicron:_.techData?.dbu_per_micron,showDbu:_.showDbu});if(!x){c.style.display="none",f();return}c.style.display="",m(x.barPx,x.label,x.segments),f()}let v=ur(g);_.view.on("zoom zoomend resize",v),_.updateScaleBar=g,_.rulerManager=new Qh(_,gt,Xl,ap),_.labelManager=new ep(_,gt,Xl,ap)}function T5(n){let e=document.createElement("div");e.className="display-controls",e.innerHTML='
Loading layers...
',n.element.appendChild(e),_.displayControlsEl=e}var fv="or_restore_console",L5=1<<20;function M5(){try{if(_.tclOutputEl){let n=[..._.tclOutputEl.children].map(r=>[r.textContent,r.className]),e=n.length,t=0;for(;e>0&&t+n[e-1][0].length<=L5;)t+=n[--e][0].length;let i=n.slice(e);e>0&&i.unshift([`[earlier output not kept across reload] -`,""]),sessionStorage.setItem(fv,JSON.stringify(i))}}catch{}window.location.reload()}function A5(){try{let n=sessionStorage.getItem(fv);if(!n)return;sessionStorage.removeItem(fv);for(let[e,t]of JSON.parse(n))gr(e,t)}catch{}}function gr(n,e){if(!_.tclOutputEl)return;let t=document.createElement("span");e&&(t.className=e),t.textContent=n,_.tclOutputEl.appendChild(t),_.tclOutputEl.scrollTop=_.tclOutputEl.scrollHeight}function k5(){if(_._shutdownHandled)return;_._shutdownHandled=!0,_.websocketManager&&(_.websocketManager._shutdown=!0,_.websocketManager.onPush=()=>{});let n=document.createElement("div");n.style.cssText="position:fixed;inset:0;z-index:99999;background:#1e1e1e;color:#ddd;display:flex;flex-direction:column;align-items:center;justify-content:center;font-family:system-ui,sans-serif;font-size:16px;padding:24px;text-align:center;",n.innerHTML='
OpenROAD exited
You can close this tab.
',document.body.appendChild(n),setTimeout(()=>{try{window.close()}catch{}},1500)}function R5(n){let e=document.createElement("div");if(e.className="tcl-console",e.innerHTML='
%
',n.element.appendChild(e),_.tclOutputEl=e.querySelector(".tcl-output"),A5(),fe(_)){e.querySelector(".tcl-input-row").style.display="none";let r=document.createElement("span");r.className="tcl-static-notice",r.setAttribute("role","status"),r.setAttribute("aria-live","polite"),r.textContent="Tcl console is not available in saved reports.",_.tclOutputEl.appendChild(r);return}let t=e.querySelector(".tcl-input"),i=new ip(t,_.websocketManager);t.addEventListener("keydown",r=>{if(!i.handleKeyDown(r)&&r.key==="Enter"){let s=t.value.trim();if(!s)return;gr(`>>> ${s} + `,document.body.appendChild(this._overlay),this._breadcrumb=this._overlay.querySelector(".fb-breadcrumb"),this._fileList=this._overlay.querySelector(".fb-file-list"),this._pathInput=this._overlay.querySelector(".fb-path-input"),this._errorDiv=this._overlay.querySelector(".modal-error"),this._okBtn=this._overlay.querySelector(".ok"),this._cancelBtn=this._overlay.querySelector(".cancel"),this._listen(this._pathInput,"input",()=>this._updateOkState()),this._listen(this._pathInput,"keydown",e=>{if(e.key==="Enter"){let t=this._pathInput.value.trim();t.endsWith("/")?this._navigate(t.replace(/\/+$/,"")||"/"):this._submit()}else e.key==="Escape"&&this.close()}),this._listen(this._okBtn,"click",()=>this._submit()),this._listen(this._cancelBtn,"click",()=>this.close()),this._listen(this._overlay,"click",e=>{e.target===this._overlay&&this.close()}),this._navigate("")}close(){if(!this._closed){this._closed=!0;for(let e of this._disposers)e();this._disposers.length=0,this._overlay&&(this._overlay.remove(),this._overlay=null)}}_listen(e,t,i){e.addEventListener(t,i),this._disposers.push(()=>e.removeEventListener(t,i))}_updateOkState(){this._okBtn.disabled=!this._pathInput.value.trim()}_renderBreadcrumb(e){this._breadcrumb.innerHTML="";let t=e.split("/").filter(Boolean),i=document.createElement("span");i.className="fb-crumb",i.textContent="/",this._listen(i,"click",()=>this._navigate("/")),this._breadcrumb.appendChild(i);let r="";for(let s of t){r+="/"+s;let o=document.createElement("span");o.className="fb-crumb-sep",o.textContent=" / ",this._breadcrumb.appendChild(o);let a=document.createElement("span");a.className="fb-crumb",a.textContent=s;let c=r;this._listen(a,"click",()=>this._navigate(c)),this._breadcrumb.appendChild(a)}}_renderEntries(e){if(this._fileList.innerHTML="",!e||e.length===0){let t=document.createElement("div");t.className="fb-empty",t.textContent="(empty directory)",this._fileList.appendChild(t);return}for(let t of e){let i=document.createElement("div");i.className="fb-entry",t.is_dir&&i.classList.add("fb-dir");let r=document.createElement("span");r.className="fb-icon",r.textContent=t.is_dir?"\u{1F4C1}":"\u{1F4C4}",i.appendChild(r);let s=document.createElement("span");s.className="fb-name",s.textContent=t.name,i.appendChild(s),t.is_dir?this._listen(i,"click",()=>this._navigate(this._currentPath+"/"+t.name)):(this._listen(i,"click",()=>{let o=this._fileList.querySelector(".fb-selected");o&&o.classList.remove("fb-selected"),i.classList.add("fb-selected"),this._pathInput.value=this._currentPath+"/"+t.name,this._updateOkState()}),this._listen(i,"dblclick",()=>{this._pathInput.value=this._currentPath+"/"+t.name,this._updateOkState(),this._submit()})),this._fileList.appendChild(i)}}async _navigate(e){this._errorDiv.style.display="none",this._fileList.innerHTML='
Loading...
';try{let t=await this._app.websocketManager.request({type:"list_dir",path:e||""});if(this._closed)return;this._currentPath=t.path,this._renderBreadcrumb(t.path),this._renderEntries(t.entries),this._pathInput.value="",this._updateOkState()}catch(t){if(this._closed)return;this._fileList.innerHTML="",this._errorDiv.textContent=t.message||String(t),this._errorDiv.style.display=""}}async _submit(){let e=this._pathInput.value.trim();if(e){this._okBtn.disabled=!0,this._okBtn.textContent="Loading...",this._errorDiv.style.display="none";try{let t=await this._app.websocketManager.request({type:"drc_load_report",path:e});if(this._closed)return;if(t.ok){let i=t.category;this.close(),this._onLoaded(i)}else this._errorDiv.textContent=t.error||"Failed to load report",this._errorDiv.style.display="",this._okBtn.disabled=!1,this._okBtn.textContent="Load"}catch(t){if(this._closed)return;this._errorDiv.textContent=t.message||"Request failed",this._errorDiv.style.display="",this._okBtn.disabled=!1,this._okBtn.textContent="Load"}}}};var n5=` +\r[]{}`;var ip=class{constructor(e,t){this._input=e,this._ws=t,this._popup=null,this._items=[],this._selectedIndex=-1,this._replaceStart=0,this._replaceEnd=0,this._debounceTimer=null,this._commandCache=null,this._history=[],this._historyIndex=-1,this._historyStash="",this._createPopup(),this._onInputBound=this._onInput.bind(this),this._onBlurBound=this._onBlur.bind(this),this._input.addEventListener("input",this._onInputBound),this._input.addEventListener("blur",this._onBlurBound)}_createPopup(){this._popup=document.createElement("div"),this._popup.className="tcl-complete-popup",this._popup.style.display="none",this._input.parentElement.appendChild(this._popup)}handleKeyDown(e){let t=this._popup.style.display!=="none";return e.key==="Tab"?(e.preventDefault(),t?this._tabAccept():this._tabComplete(this._input.value,this._input.selectionStart),!0):e.key==="Escape"?t?(this._hidePopup(),!0):!1:e.key==="ArrowDown"?t?(e.preventDefault(),this._selectItem(this._selectedIndex+1),!0):this._historyIndex>=0?(e.preventDefault(),this._historyIndex--,this._historyIndex<0?this._input.value=this._historyStash:this._input.value=this._history[this._historyIndex],!0):!1:e.key==="ArrowUp"?t?(e.preventDefault(),this._selectItem(this._selectedIndex-1),!0):this._historyIndex{let e=this._input.value,t=this._input.selectionStart,i=this._extractPrefix(e,t);i.length>=2||i.length>=1&&(i[0]==="$"||i[0]==="-")?this._requestCompletions(e,t):this._hidePopup()},100)}_onBlur(){setTimeout(()=>this._hidePopup(),150)}_extractPrefix(e,t){let i=t-1;for(;i>=0&&n5.indexOf(e[i])===-1;)i--;return e.substring(i+1,t)}_fetchCompletions(e,t,i){let r=this._extractPrefix(e,t),s=r.length>0&&r[0]==="$",o=r.length>0&&r[0]==="-",a=!s&&!o,c=t-r.length,l=e.substring(0,c),u=/^[\s\[]*$/.test(l);if(a&&u&&this._commandCache){let f=r.toLowerCase(),d=this._commandCache.filter(h=>h.toLowerCase().startsWith(f));i(d,c,t);return}this._ws.request({type:"tcl_complete",line:e,cursor_pos:t}).then(f=>{f.mode==="commands"&&!this._commandCache&&r===""&&(this._commandCache=f.completions),f.mode==="commands"&&!this._commandCache&&this._ws.request({type:"tcl_complete",line:"",cursor_pos:0}).then(d=>{d.mode==="commands"&&(this._commandCache=d.completions)}).catch(()=>{}),i(f.completions,f.replace_start,f.replace_end)}).catch(()=>i([],0,0))}_requestCompletions(e,t){this._fetchCompletions(e,t,(i,r,s)=>{this._showPopup(i,r,s)})}_tabAccept(){if(this._items.length===0){this._hidePopup();return}if(this._items.length===1){this._selectedIndex=0,this._acceptCompletion();return}this._advanceToCommonPrefix()}_tabComplete(e,t){this._fetchCompletions(e,t,(i,r,s)=>{if(!i||i.length===0){this._hidePopup();return}if(i.length===1){this._items=i,this._replaceStart=r,this._replaceEnd=s,this._selectedIndex=0,this._acceptCompletion();return}this._items=i,this._replaceStart=r,this._replaceEnd=s,this._advanceToCommonPrefix(),this._showPopup(i,this._replaceStart,this._replaceEnd)})}_advanceToCommonPrefix(){if(this._items.length<2)return!1;let e=this._items[0];for(let o=1;o0;o++){let a=this._items[o],c=0;for(;c{let c=document.createElement("div");c.className="tcl-complete-item",c.textContent=o,c.addEventListener("mousedown",l=>{l.preventDefault(),this._selectedIndex=a,this._acceptCompletion()}),this._popup.appendChild(c)}),e.length>15){let o=document.createElement("div");o.className="tcl-complete-more",o.textContent=`... ${e.length-15} more`,this._popup.appendChild(o)}this._selectedIndex=0,this._highlightSelected(),this._popup.style.display="block"}_hidePopup(){this._popup.style.display="none",this._items=[],this._selectedIndex=-1}_selectItem(e){if(this._items.length===0)return;let t=Math.min(this._items.length,15)-1;this._selectedIndex=Math.max(0,Math.min(e,t)),this._highlightSelected()}_highlightSelected(){let e=this._popup.querySelectorAll(".tcl-complete-item");e.forEach((t,i)=>{t.classList.toggle("selected",i===this._selectedIndex)}),e[this._selectedIndex]&&e[this._selectedIndex].scrollIntoView&&e[this._selectedIndex].scrollIntoView({block:"nearest"})}_acceptCompletion(){if(this._selectedIndex<0||this._selectedIndex>=this._items.length){this._hidePopup();return}let e=this._items[this._selectedIndex],t=this._input.value.substring(0,this._replaceStart),i=this._input.value.substring(this._replaceEnd),s=!e.endsWith("/")&&!e.endsWith("::")&&(i.length===0||i[0]!==" ")?" ":"";this._input.value=t+e+s+i;let o=this._replaceStart+e.length+s.length;this._input.setSelectionRange(o,o),this._input.focus(),this._hidePopup()}};var OM=[{key:"or_visibility",store:"cookie"},{key:"or_selectability",store:"cookie"},{key:"or_hidden_layers",store:"session"},{key:"or_nonselectable_layers",store:"session"},{key:"or_layer_patterns",store:"session"},{key:"or_hidden_chiplets",store:"cookie"},{key:"or_bg_color",store:"cookie"},{key:"or_show_dbu",store:"cookie"},{key:"or_theme",store:"theme"},{key:"or_use_true_z",store:"cookie"},{key:"or_ruler_style",store:"cookie"},{key:"or_wheel_zoom",store:"cookie"},{key:"or_arrow_step",store:"cookie"},{key:"or_font_family",store:"cookie"},{key:"or_font_scale",store:"cookie"},{key:"or_control_smoothing",store:"cookie"},{key:"or_double_buffer",store:"cookie"},{key:"or_defer_tile_updates",store:"cookie"}];function DM(n){return{controlSmoothing:n("or_control_smoothing")==="1",doubleBuffer:n("or_double_buffer")!=="0",deferTileUpdates:n("or_defer_tile_updates")==="1"}}function i5(n,e){try{return window[n].getItem(e)}catch{return null}}function r5(n,e,t){try{t===null?window[n].removeItem(e):window[n].setItem(e,t)}catch{}}function s5({key:n,store:e}){return e==="session"?i5("sessionStorage",n):Ge(n)}function o5({key:n,store:e},t){e==="session"?r5("sessionStorage",n,t):e==="theme"?t===null?tM():Nh(t):t===null?Dh(n):Ne(n,t)}function NM(){let n={};for(let e of OM){let t=s5(e);t&&(n[e.key]=t)}return{version:1,entries:n}}function a5(n){return typeof n=="string"&&n!==""&&!/[;\r\n]/.test(n)}function FM(n){for(let e of OM){let t=n[e.key];o5(e,a5(t)?t:null)}}function zM(n,e=typeof document<"u"?document:null){let t="OpenROAD",i=n?`${t} - ${n}`:t;return e&&(e.title=i),i}var ce=globalThis.THREE,UM=2,c5=.002,l5=.9,u5=1.1,f5=.1,d5=20,h5=3,As=2,$M=2,p5=10,m5=1e4,g5=.15,_5=300,y5=6,rp=Math.PI/180,GM=[5025616,2201331,16750592,10233776,48340,16007990,2533018,7951688,15277667,4149685];function b5(n){let e=new Array(n.length).fill(0),t=new Map;n.forEach((i,r)=>{let s=i.z;t.has(s)||t.set(s,[]),t.get(s).push({idx:r,chiplet:i})});for(let i of t.values()){if(i.length<=1)continue;let r=[];for(let{idx:s,chiplet:o}of i){let a=o.x,c=o.y,l=o.x+o.width,u=o.y+o.height,f=!1;for(let d=0;dap.x1&&cp.y1)){r[d].push({x1:a,y1:c,x2:l,y2:u}),e[s]=d,f=!0;break}f||(r.push([{x1:a,y1:c,x2:l,y2:u}]),e[s]=r.length-1)}}return e}var sp=class{constructor(e,t){if(this._app=t,this._container=e,this._element=document.createElement("div"),this._element.className="three-d-viewer-widget",e.element.appendChild(this._element),!ce){fe(t)?this._showInfo("The 3D view is not available in saved reports."):this._showError("three.js is missing from the page."),this._destroyed=!0;return}this._canvasContainer=document.createElement("div"),this._canvasContainer.className="three-d-canvas-container",this._element.appendChild(this._canvasContainer),this._tooltip=document.createElement("div"),this._tooltip.className="or-tooltip",this._canvasContainer.appendChild(this._tooltip),this._optionsOverlay=this._createOptionsOverlay(),this._canvasContainer.appendChild(this._optionsOverlay),this._raycaster=new ce.Raycaster,this._scene=new ce.Scene,this._applyTheme(),this._themeObserver=new MutationObserver(()=>{this._applyTheme(),this.render()}),this._themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),this._camera=new ce.PerspectiveCamera(45,1,10,1e5),this._camera.position.set(0,0,1e3);try{this._renderer=new ce.WebGLRenderer({antialias:!0,preserveDrawingBuffer:!0})}catch(o){console.error("3D viewer: failed to create WebGL context:",o),this._showWebGLUnavailable(o),this._themeObserver&&(this._themeObserver.disconnect(),this._themeObserver=null),this._destroyed=!0;return}this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(e.width,e.height),this._canvasContainer.appendChild(this._renderer.domElement),this._rotation=new ce.Quaternion,this._distance=1e3,this._panX=0,this._panY=0,this._boundingRadius=1,this._sceneCenter=new ce.Vector3,this._mouseDown=!1,this._mouseButton=-1,this._lastMousePos={x:0,y:0},this._setupMouseHandlers();let i=new ce.AmbientLight(16777215,.5);this._scene.add(i);let r=new ce.DirectionalLight(16777215,.8);r.position.set(1,1,1).normalize(),this._scene.add(r);let s=new ce.DirectionalLight(16777215,.3);s.position.set(-1,-.5,.5).normalize(),this._scene.add(s),e.on("resize",this.onResize.bind(this)),e.on("open",this.onOpen.bind(this)),e.on("destroy",this.onDestroy.bind(this)),this._designGroup=new ce.Group,this._scene.add(this._designGroup),this._chipletMeshes=[],this._loading=!1,this._destroyed=!1,this._edgeMaterial=null}_setupMouseHandlers(){let e=this._renderer.domElement;e.addEventListener("mousedown",t=>{this._mouseDown=!0,this._mouseButton=t.button,this._lastMousePos.x=t.clientX,this._lastMousePos.y=t.clientY,e.focus(),t.preventDefault()}),e.addEventListener("contextmenu",t=>t.preventDefault()),this._onMouseMove=t=>{if(!this._mouseDown)return;let i=t.clientX-this._lastMousePos.x,r=t.clientY-this._lastMousePos.y;this._lastMousePos.x=t.clientX,this._lastMousePos.y=t.clientY,!(i===0&&r===0)&&(this._mouseButton===0?this._handleRotate(i,r):this._mouseButton===2&&this._handlePan(i,r),this._updateCamera())},this._onMouseUp=t=>{this._mouseDown&&t.button===this._mouseButton&&(this._mouseDown=!1,this._mouseButton=-1)},window.addEventListener("mousemove",this._onMouseMove),window.addEventListener("mouseup",this._onMouseUp),e.addEventListener("wheel",t=>{t.preventDefault(),t.deltaY<0?this._distance*=l5:this._distance*=u5;let i=Math.max(this._boundingRadius*f5,1),r=Math.max(this._boundingRadius*d5,i);this._distance=Math.max(i,Math.min(r,this._distance)),this._updateCamera()},{passive:!1}),e.tabIndex=0,e.style.outline="none",e.addEventListener("keydown",t=>{t.key.toLowerCase()==="f"&&this.resetCamera()}),e.addEventListener("dblclick",t=>{t.preventDefault();let i=this._pickDrcMarkerId(t);if(i!=null&&this._app.drcWidget){this._app.drcWidget.highlightMarkerById(i,!0);return}this.resetCamera()}),e.addEventListener("mousemove",t=>{if(this._mouseDown){this._hideTooltip();return}this._updateTooltip(t)}),e.addEventListener("mouseleave",()=>{this._hideTooltip()})}_createOptionsOverlay(){let e=document.createElement("div");e.className="three-d-options";let t=document.createElement("label");t.title="Render chiplets at their true Z (disable stacking offset for overlapping chiplets at same Z).";let i=document.createElement("input");i.type="checkbox",i.checked=!!this._app.useTrueZ,i.addEventListener("change",()=>{this._app.useTrueZ=i.checked,Ne("or_use_true_z",i.checked?"1":"0"),this._app.syncDisplayState(),this.refreshSceneForOptions()}),t.appendChild(i),t.appendChild(document.createTextNode("True Z (no stacking)")),e.appendChild(t);let r=document.createElement("div");r.style.cssText="margin-top:4px; display:flex; gap:4px;";let s=document.createElement("button");s.className="or-btn or-btn-sm",s.textContent="Save PNG",s.title="Save the 3D view as a PNG image (2x resolution)",s.addEventListener("click",()=>this._exportPng(2));let o=document.createElement("button");return o.className="or-btn or-btn-sm",o.textContent="Copy",o.title="Copy the 3D view image to the clipboard",o.addEventListener("click",()=>this._copyImage(2)),r.appendChild(s),r.appendChild(o),e.appendChild(r),e}_capturePng(e=2){if(!this._renderer)return null;let t=this._renderer,i=t.domElement.clientWidth||t.domElement.width,r=t.domElement.clientHeight||t.domElement.height,s=t.getPixelRatio();try{return t.setPixelRatio(s*e),t.setSize(i,r,!1),this.render(),t.domElement.toDataURL("image/png")}finally{t.setPixelRatio(s),t.setSize(i,r,!1),this.render()}}_exportPng(e=2){let t=this._capturePng(e);t&&Ts(t,"3d-view.png")}async _copyImage(e=2){let t=this._capturePng(e);t&&await Fh(t)}_setRaycasterFromEvent(e){let i=this._renderer.domElement.getBoundingClientRect(),r=new ce.Vector2((e.clientX-i.left)/i.width*2-1,-((e.clientY-i.top)/i.height*2-1));this._raycaster.setFromCamera(r,this._camera)}_updateTooltip(e){if(!this._chipletMeshes.length){this._hideTooltip();return}this._setRaycasterFromEvent(e);let t=this._chipletMeshes.map(a=>a.mesh),i=this._raycaster.intersectObjects(t,!1);if(i.length===0){this._hideTooltip();return}let r=i[0].object,s=this._chipletMeshes.find(a=>a.mesh===r);if(!s){this._hideTooltip();return}this._tooltip.textContent=s.data.name,this._tooltip.style.display="block";let o=this._canvasContainer.getBoundingClientRect();this._tooltip.style.left=e.clientX-o.left+12+"px",this._tooltip.style.top=e.clientY-o.top+12+"px"}_hideTooltip(){this._tooltip&&(this._tooltip.style.display="none")}_pickDrcMarkerId(e){if(!this._drcHitboxMesh||!this._drcHitboxMarkerIds)return null;this._setRaycasterFromEvent(e);let t=this._raycaster.intersectObject(this._drcHitboxMesh,!1);if(t.length===0)return null;let i=t[0].instanceId;return i==null?null:this._drcHitboxMarkerIds[i]??null}_handleRotate(e,t){let i=Math.sqrt(e*e+t*t);if(i<.001)return;let r=new ce.Vector3(t/i,e/i,0),s=i/UM,a=new ce.Quaternion().setFromAxisAngle(r,s*rp).clone().multiply(this._rotation);if(new ce.Vector3(0,0,1).applyQuaternion(a).z>=0)this._rotation.copy(a);else{let l=new ce.Vector3(0,1,0),u=e/UM*rp,d=new ce.Quaternion().setFromAxisAngle(l,u).clone().multiply(this._rotation);new ce.Vector3(0,0,1).applyQuaternion(d).z>=0&&this._rotation.copy(d)}}_handlePan(e,t){let i=this._distance*c5;this._panX+=e*i,this._panY-=t*i}_updateCamera(){let e=Math.max(this._boundingRadius,1e3),t=Math.max(this._distance-e*$M,p5),i=this._distance+e*$M;i0;){let e=this._designGroup.children[0];this._designGroup.remove(e),e.geometry&&e.geometry.dispose(),e.material&&!e.material._shared&&e.material.dispose()}this._edgeMaterial&&(this._edgeMaterial.dispose(),this._edgeMaterial=null),this._onMouseMove&&(window.removeEventListener("mousemove",this._onMouseMove),this._onMouseMove=null),this._onMouseUp&&(window.removeEventListener("mouseup",this._onMouseUp),this._onMouseUp=null),this._renderer&&(this._renderer.dispose(),this._renderer=null),this._app.threeDViewerWidget===this&&(this._app.threeDViewerWidget=null)}}_setInitialCameraState(){this._distance=this._boundingRadius*h5;let e=new ce.Quaternion().setFromAxisAngle(new ce.Vector3(1,0,0),-45*rp),t=new ce.Quaternion().setFromAxisAngle(new ce.Vector3(0,0,1),45*rp);this._rotation=e.multiply(t),this._panX=0,this._panY=0}resetCamera(){this._sceneBounds&&(this._setInitialCameraState(),this._updateCamera())}onResize(){if(this._destroyed)return;let e=this._canvasContainer.getBoundingClientRect(),t=e.width,i=e.height;t===0||i===0||(this._camera.aspect=t/i,this._camera.updateProjectionMatrix(),this._renderer.setSize(t,i),this.render())}render(){this._destroyed||this._renderer&&this._scene&&this._camera&&this._renderer.render(this._scene,this._camera)}_applyTheme(){let t=Cs().bgMap||"#000000";this._scene.background=new ce.Color(t)}async loadData(){if(!(this._loading||this._destroyed)){this._loading=!0;for(let e of[".three-d-error",".three-d-info"]){let t=this._element.querySelector(e);t&&t.remove()}try{await this._app.websocketManager.readyPromise;let e=await this._app.websocketManager.request({type:"get_3d_data"});if(this._destroyed)return;if(e&&e.error){this._showError(e.error);return}if(e&&e.info){this._showInfo(e.info);return}this.buildScene(e)}catch(e){if(this._destroyed)return;console.error("Failed to load 3D data:",e),this._showError(e.message||String(e))}finally{this._loading=!1}}}_showOverlay(e,t,i){let r=document.createElement("div");r.className=e,r.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-family:monospace;text-align:center;",r.style.color=i,r.textContent=t,this._element.appendChild(r)}_showError(e){this._showOverlay("three-d-error","Failed to load 3D data: "+e,"var(--error)")}_showInfo(e){this._showOverlay("three-d-info",e,"var(--fg-muted, #888)")}_showWebGLUnavailable(e){let t=document.createElement("div");t.className="three-d-error",t.style.cssText="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-family:monospace;text-align:center;max-width:80%;color:var(--error);";let i=e&&e.message?e.message:String(e||"");t.innerHTML='
3D viewer unavailable: WebGL context could not be created.
In Chrome, open chrome://flags/#ignore-gpu-blocklist and set Override software rendering list to Enabled, then relaunch the browser.
Otherwise enable hardware acceleration or try a different browser. See chrome://gpu for details.
'+(i?'
'+i+"
":""),this._element.appendChild(t)}buildScene(e){if(this._destroyed||(this._lastSceneData=e,this._clearScene(),!e||!e.chiplets||e.chiplets.length===0))return;let t=this._app.getDbuPerMicron(),i=this._buildChiplets(e.chiplets,t);i.minX!==1/0&&(this._buildGrid(i),this._setSceneBoundsAndCenter(i),this._setInitialCameraState(),this._updateCamera())}_clearScene(){for(this._chipletMeshes=[];this._designGroup.children.length>0;){let e=this._designGroup.children[0];this._designGroup.remove(e),e.geometry&&e.geometry.dispose(),e.material&&!e.material._shared&&e.material.dispose()}this._hideTooltip()}_buildChiplets(e,t){let i={minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0};this._edgeMaterial||(this._edgeMaterial=new ce.LineBasicMaterial({color:0,linewidth:1}),this._edgeMaterial._shared=!0);let r=this._app.useTrueZ?new Array(e.length).fill(0):b5(e);return e.forEach((s,o)=>{let a=s.width/t,c=s.height/t,l=s.thickness/t*As,u=GM[o%GM.length],f=new ce.MeshPhongMaterial({color:u,transparent:!1,opacity:1,side:ce.DoubleSide,shininess:40}),d=new ce.BoxGeometry(a,c,l),h=new ce.Mesh(d,f),p=s.x/t+a/2,m=s.y/t+c/2,g=l*g5,v=s.z/t*As+l/2+r[o]*(l+g);h.position.set(p,m,v),this._designGroup.add(h),this._chipletMeshes.push({mesh:h,data:s,color:u});let y=new ce.EdgesGeometry(d),b=new ce.LineSegments(y,this._edgeMaterial);b.position.set(p,m,v),this._designGroup.add(b),i.minX=Math.min(i.minX,s.x/t),i.minY=Math.min(i.minY,s.y/t),i.minZ=Math.min(i.minZ,v-l/2),i.maxX=Math.max(i.maxX,s.x/t+a),i.maxY=Math.max(i.maxY,s.y/t+c),i.maxZ=Math.max(i.maxZ,v+l/2)}),i}_buildGrid(e){let t=e.maxX-e.minX,i=e.maxY-e.minY,r=Math.max(t,i)*1.4,s=10,o=new ce.GridHelper(r,s,8947848,4473924);o.rotation.x=Math.PI/2,o.position.set((e.minX+e.maxX)/2,(e.minY+e.maxY)/2,e.minZ-1),this._designGroup.add(o)}_setSceneBoundsAndCenter(e){this._sceneBounds=e;let t=e.maxX-e.minX,i=e.maxY-e.minY,r=e.maxZ-e.minZ;this._boundingRadius=Math.sqrt(t*t+i*i+r*r)/2,this._sceneCenter.set((e.minX+e.maxX)/2,(e.minY+e.maxY)/2,(e.minZ+e.maxZ)/2)}_stackOffsetForPoint(e,t,i,r){for(let{mesh:s,data:o}of this._chipletMeshes){if(e!==o.z||to.x+o.width||io.y+o.height)continue;let a=o.thickness/r*As,c=o.z/r*As+a/2;return s.position.z-c}return 0}clearHighlightDRC(){this._drcBlinkInterval&&(clearInterval(this._drcBlinkInterval),this._drcBlinkInterval=null),this._drcMeshGroup&&(this._scene.remove(this._drcMeshGroup),this._drcMeshGroup.children.forEach(e=>{e.geometry&&e.geometry.dispose()}),this._drcMaterial&&(this._drcMaterial.dispose(),this._drcMaterial=null),this._drcHitboxMaterial&&(this._drcHitboxMaterial.dispose(),this._drcHitboxMaterial=null),this._drcHitboxMesh=null,this._drcHitboxMarkerIds=null,this._drcMeshGroup=null,this.render())}highlightDRC(e){if(this._destroyed||(this.clearHighlightDRC(),!e||e.length===0))return;let t=this._app.getDbuPerMicron(),i=0,r=1e4/t*As;this._sceneBounds&&this._sceneBounds.minZ!==1/0&&(i=this._sceneBounds.minZ,r=this._sceneBounds.maxZ),i-=1,r+=1;let s=Math.max(r-i,1);this._drcMeshGroup=new ce.Group,this._drcMaterial=new ce.LineBasicMaterial({color:16776960,transparent:!0,opacity:1,depthTest:!1,depthWrite:!1}),this._drcHitboxMaterial=new ce.MeshBasicMaterial({transparent:!0,opacity:0,depthWrite:!1});let o=[];for(let l of e){let u=l.rects&&l.rects.length>0?l.rects:[l.bbox];for(let f of u){let[d,h,p,m,g,v]=f,y=Math.max((p-d)/t,.001),b=Math.max((m-h)/t,.001),x=i,E=s,w=0;if(f.length>=6&&g!==void 0&&v!==void 0){x=g/t*As;let O=v/t*As;E=Math.max(O-x,.001),w=this._stackOffsetForPoint(g,(d+p)/2,(h+m)/2,t)}let T=d/t+y/2,R=h/t+b/2,F=x+E/2+w;o.push({cx:T,cy:R,cz:F,width:y,height:b,depth:E,markerId:l.id})}}if(o.length>0){let l=new ce.BoxGeometry(1,1,1);this._drcHitboxMesh=new ce.InstancedMesh(l,this._drcHitboxMaterial,o.length),this._drcHitboxMarkerIds=new Array(o.length);let u=new ce.Matrix4,f=new ce.Vector3,d=new ce.Vector3,h=new ce.Quaternion;o.forEach((p,m)=>{d.set(p.cx,p.cy,p.cz),f.set(p.width,p.height,p.depth),u.compose(d,h,f),this._drcHitboxMesh.setMatrixAt(m,u),this._drcHitboxMarkerIds[m]=p.markerId;let g=new ce.BoxGeometry(p.width,p.height,p.depth),v=new ce.EdgesGeometry(g);g.dispose();let y=new ce.LineSegments(v,this._drcMaterial);y.position.set(p.cx,p.cy,p.cz),y.renderOrder=999,this._drcMeshGroup.add(y)}),this._drcHitboxMesh.instanceMatrix.needsUpdate=!0,this._drcMeshGroup.add(this._drcHitboxMesh)}this._drcMeshGroup.renderOrder=999,this._scene.add(this._drcMeshGroup),this.render();let a=!0,c=0;this._drcBlinkInterval=setInterval(()=>{if(!(!this._drcMeshGroup||!this._drcMaterial)){if(c+=1,c>=y5){this._drcMaterial.opacity=1,this.render(),clearInterval(this._drcBlinkInterval),this._drcBlinkInterval=null;return}a=!a,this._drcMaterial.opacity=a?1:.2,this.render()}},_5)}refreshSceneForOptions(){this._destroyed||this._lastSceneData&&(this.clearHighlightDRC(),this.buildScene(this._lastSceneData))}};var v5=[{name:"green",hex:"#00ff00"},{name:"yellow",hex:"#ffff00"},{name:"cyan",hex:"#00ffff"},{name:"magenta",hex:"#ff00ff"},{name:"red",hex:"#ff0000"},{name:"dark_green",hex:"#008000"},{name:"dark_magenta",hex:"#800080"},{name:"blue",hex:"#0000ff"},{name:"orange",hex:"#ffa500"},{name:"purple",hex:"#800080"},{name:"lime",hex:"#bfff00"},{name:"teal",hex:"#008080"},{name:"pink",hex:"#ffc0cb"},{name:"brown",hex:"#8b4513"},{name:"indigo",hex:"#4b0082"},{name:"turquoise",hex:"#40e0d0"}],x5=[{label:"Connected Insts",suffix:"connected_insts",needsNet:!0},{label:"Output Nets",suffix:"connected_nets",args:{output:!0,input:!1}},{label:"Input Nets",suffix:"connected_nets",args:{output:!1,input:!0}},{label:"All Nets",suffix:"connected_nets",args:{output:!0,input:!0}},{label:"All buffer trees",suffix:"connected_buffer_trees"},{label:"All buffer trees (incl. inverters)",suffix:"connected_buffer_trees",args:{include_inverters:!0}}],op=class{constructor(e){this._app=e,this._el=document.createElement("div"),this._el.className="context-menu",this._el.style.display="none",this._el.style.zIndex="10000",document.body.appendChild(this._el),this._bindEvents()}_bindEvents(){document.addEventListener("mousedown",e=>{this._el.contains(e.target)||this.hide()}),this._app.view&&this._app.view.on("movestart",()=>this.hide())}show(e){this._el.innerHTML="";let t=!!this._app.selHasInst,i=!!this._app.selHasNet,r=!(t||i),s=h=>x5.map(p=>({label:p.label,disabled:p.needsNet?!i:!t,...h(p.suffix,p.args||{})})),o=[{label:"Select",disabled:r,subMenu:s((h,p)=>({action:()=>this._sendContextAction("select_"+h,p)}))},{label:"Highlight",disabled:r,subMenu:s((h,p)=>({subMenu:this._buildColorSubmenu("highlight_"+h,p)}))},{label:"Save",subMenu:[{label:"Visible layout",action:()=>this._app.captureLayout?.({entire:!1})},{label:"Entire layout",action:()=>this._app.captureLayout?.({entire:!0})}]},{label:"Clear",subMenu:[{label:"Selections",action:()=>this._sendContextAction("clear_selections")},{label:"Highlights",action:()=>this._sendContextAction("clear_highlights")},{label:"Rulers",action:()=>{this._app.rulerManager?.clearAllRulers()}},{label:"Focus nets",action:()=>this._sendContextAction("clear_focus_nets")},{label:"Route Guides",action:()=>this._sendContextAction("clear_route_guides")},{label:"All",action:()=>{this._sendContextAction("clear_all"),this._app.rulerManager?.clearAllRulers()}}]}];this._buildMenu(o,this._el),this._el.style.display="block";let a=4,c=this._el.getBoundingClientRect(),l=window.innerWidth-c.width-a,u=window.innerHeight-c.height-a,f=Math.max(a,Math.min(e.clientX,l)),d=Math.max(a,Math.min(e.clientY,u));this._el.style.left=f+"px",this._el.style.top=d+"px"}hide(){this._el.style.display="none"}_buildColorSubmenu(e,t={}){return v5.map(({name:i,hex:r},s)=>({label:i,swatch:r,action:()=>this._sendContextAction(e,{...t,group:s})}))}_buildMenu(e,t){e.forEach(i=>{let r=document.createElement("div");if(r.className="cm-item",i.swatch){let s=document.createElement("span");s.className="cm-swatch",s.style.background=i.swatch,r.appendChild(s)}if(r.appendChild(document.createTextNode(i.label)),i.disabled){r.classList.add("disabled"),i.subMenu&&r.classList.add("has-submenu"),t.appendChild(r);return}if(i.subMenu){r.classList.add("has-submenu");let s=document.createElement("div");s.className="cm-submenu",this._buildMenu(i.subMenu,s),r.appendChild(s),r.addEventListener("mouseenter",()=>{s.classList.remove("flip-left"),s.getBoundingClientRect().right>window.innerWidth&&s.classList.add("flip-left")})}else i.action&&r.addEventListener("click",s=>{s.stopPropagation(),this.hide();try{i.action()}catch(o){console.error("Context menu item action threw:",i.label,o)}});t.appendChild(r)})}_sendContextAction(e,t={}){this._app.websocketManager&&this._app.websocketManager.request({type:"context_action",action:e,...t}).then(i=>{qo(this._app,i),i&&i.connected_count===0&&on('Nothing connected \u2014 select an instance (or a net for "Connected Insts") first.'),this._syncAfterAction(e)}).catch(i=>{console.error("Context action failed:",e,i)})}_syncAfterAction(e){let t=this._app;(e==="clear_focus_nets"||e==="clear_route_guides"||e==="clear_all")&&typeof t.redrawAllLayers=="function"&&t.redrawAllLayers(),e==="clear_selections"||e==="clear_all"?(t.updateInspector?.(null),t.stopSelectionAnimation?.(),t.clearSelectionOutline?.(),t.lastSelectionBounds=null):t.refreshInspector?.(),t.refreshOverlay?.()}};function VM(n,e){if(!n)return;let t=URL.createObjectURL(n),i=document.createElement("a");i.href=t,i.download=e,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(t),0)}function w5(n,e,t){n.view.getContainer().querySelectorAll(".or-view-markers .ruler-label").forEach(r=>{let s=r.getBoundingClientRect();if(s.width<=0||s.height<=0)return;let o=r.textContent;if(!o)return;let a=getComputedStyle(r),c=s.left-t.left,l=s.top-t.top;e.save(),e.fillStyle=a.backgroundColor||"rgba(0, 0, 0, 0.75)";let u=Math.min(parseFloat(a.borderTopLeftRadius)||0,s.height/2);u>0&&typeof e.roundRect=="function"?(e.beginPath(),e.roundRect(c,l,s.width,s.height,u),e.fill()):e.fillRect(c,l,s.width,s.height),e.fillStyle=a.color||"#eee",e.font=a.font||`${a.fontSize||"12px"} ${a.fontFamily||"monospace"}`,e.textAlign="left",e.textBaseline="middle",e.fillText(o,c+(parseFloat(a.paddingLeft)||0),l+s.height/2),e.restore()})}async function WM(n){let e=n.view.getContainer(),t=e.getBoundingClientRect(),i=Math.max(1,Math.round(t.width)),r=Math.max(1,Math.round(t.height)),s=document.createElement("canvas");s.width=i,s.height=r;let o=s.getContext("2d"),a=getComputedStyle(e).backgroundColor;o.fillStyle=a&&a!=="transparent"&&a!=="rgba(0, 0, 0, 0)"?a:"#000",o.fillRect(0,0,i,r);let c=await n.view.captureCanvas();if(c){let l=c.rect;try{o.drawImage(c.image,l.left-t.left,l.top-t.top,l.width,l.height)}catch{}}return w5(n,o,t),new Promise(l=>s.toBlob(l,"image/png"))}async function jM(n,{entire:e=!1}={}){if(!n.view)return;if(!e||!n.fitRect){VM(await WM(n),"layout_visible.png");return}let t=n.view.getCenter(),i=n.view.getZoom();try{n.view.fitWorldRect(n.fitRect,{animate:!1}),await n.view.whenTilesSettled(),VM(await WM(n),"layout_entire.png")}finally{n.view.setView(t,i,{animate:!1})}}var mr=document.getElementById("websocket-status"),Zl=null,E5=2e3,S5=20;function qM(){let n=_.websocketManager&&_.websocketManager.isConnected,e=_.websocketManager?_.websocketManager.pendingCount:0;if(n)if(Zl&&(clearTimeout(Zl),Zl=null),e>S5){let t=`pending: ${e}`,i=mr.firstElementChild;(!i?.classList.contains("pending-indicator")||i.textContent!==t)&&(mr.innerHTML=`
${t}
`),mr.style.display="block"}else mr.style.display="none";else{if(_.websocketManager?._shutdown)return;Zl||(Zl=setTimeout(()=>{_.websocketManager?.isConnected||(mr.innerHTML='
\u26A0 OpenROAD disconnected \u2014 retrying\u2026
',mr.style.display="block")},E5))}P5(e)}function P5(n){let e=_.tileProgressEl;if(!e)return;e.classList.toggle("active",n>0);let t=n>0?`${n} tile requests pending`:"";e.title!==t&&(e.title=t)}var HM=ur(qM);function C5(n){if(!n)return"";try{return decodeURIComponent(n)}catch{return""}}var _={view:null,fitRect:null,lastSelectionBounds:null,selHasInst:!1,selHasNet:!1,displayControlsEl:null,allLayers:[],designScale:null,designOriginX:0,designOriginY:0,websocketManager:null,goldenLayout:null,hasLiberty:!1,techData:null,inspectorEl:null,tclOutputEl:null,modulesLayer:null,pinsLayer:null,overlayLayers:[],hierarchyBrowser:null,focusNets:new Set,routeGuideNets:new Set,visibleLayers:new Set,visibleLayerNames:new Set,visibleChiplets:null,layerPatterns:{},useTrueZ:Ge("or_use_true_z")==="1",showDbu:Ge("or_show_dbu")==="1",rulerStyle:Ge("or_ruler_style")==="manhattan"?"manhattan":"euclidian",wheelZoom:Ge("or_wheel_zoom")!=="0",arrowStep:Gl(Ge("or_arrow_step")),...DM(Ge),fontFamily:C5(Ge("or_font_family")),fontScale:jl(Ge("or_font_scale")),polyDecomp:!1,labelManager:null,selectableLayers:new Set,heatMapData:null,activeHeatMap:"",heatMapLayer:null,heatMapLegendEl:null,renderHeatMapControls:null,rulerManager:null,selectionToken:0,selectionResetters:[],getDbuPerMicron(){return this.techData?.dbu_per_micron||1e3},unitOpts(){return{showDbu:this.showDbu,dbuPerMicron:this.getDbuPerMicron()}},formatDbu(n,e=!1){return U3(n,this.unitOpts(),e)},parseDbu(n){return $3(n,this.unitOpts())},formatDistance(n){return G3(n,this.unitOpts())},unitLabel(){return V3(this.unitOpts())}},gt={stdcells:!0,macros:!0,pad_input:!0,pad_output:!0,pad_inout:!0,pad_power:!0,pad_spacer:!0,pad_areaio:!0,pad_other:!0,phys_fill:!1,phys_endcap:!0,phys_welltap:!0,phys_tie:!0,phys_antenna:!0,phys_cover:!0,phys_bump:!0,phys_other:!0,std_bufinv:!0,std_bufinv_timing:!0,std_clock_bufinv:!0,std_clock_gate:!0,std_level_shift:!0,std_sequential:!0,std_combinational:!0,net_signal:!0,net_power:!0,net_ground:!0,net_clock:!0,net_reset:!0,net_tieoff:!0,net_scan:!0,net_analog:!0,inst_names:!0,inst_pins:!0,inst_pin_names:!1,routing:!0,routing_segments:!0,routing_vias:!0,special_nets:!0,srouting_segments:!0,srouting_vias:!0,pins:!0,pin_names:!0,access_points:!1,regions:!0,mfg_grid:!1,gcell_grid:!1,flywires_only:!1,blockages:!0,placement_blockages:!0,routing_obstructions:!0,fills:!1,rows:!1,tracks_pref:!1,tracks_non_pref:!1,module_view:!1,detailed:!1,rulers:!0,labels:!0,scale_bar:!0,focused_nets_guides:!1,highlight_selected:!0,debug:!1};try{let n=Ge("or_visibility");if(n){let e=JSON.parse(decodeURIComponent(n));for(let[t,i]of Object.entries(e))gt[t]=!!i}}catch{}var ta={stdcells:!0,macros:!0,pad_input:!0,pad_output:!0,pad_inout:!0,pad_power:!0,pad_spacer:!0,pad_areaio:!0,pad_other:!0,phys_fill:!0,phys_endcap:!0,phys_welltap:!0,phys_tie:!0,phys_antenna:!0,phys_cover:!0,phys_bump:!0,phys_other:!0,std_bufinv:!0,std_bufinv_timing:!0,std_clock_bufinv:!0,std_clock_gate:!0,std_level_shift:!0,std_sequential:!0,std_combinational:!0,net_signal:!0,net_power:!0,net_ground:!0,net_clock:!0,net_reset:!0,net_tieoff:!0,net_scan:!0,net_analog:!0,pins:!0,inst_pins:!0,placement_blockages:!0,routing_obstructions:!0};_.visibility=gt;_.selectability=ta;try{let n=Ge("or_selectability");if(n){let e=JSON.parse(decodeURIComponent(n));for(let[t,i]of Object.entries(e))ta[t]=!!i}}catch{}(function(){let e=null;try{e=new URLSearchParams(window.location.search)}catch{return}_.forceComposite=e.get("composite")==="1",_.preserveBuffer=e.get("preservebuffer")==="1";let t=Number(e.get("grouplayers"));Number.isFinite(t)&&t>0&&(_.groupLayers=Math.floor(t))})();_.tileCtx={visibility:gt,selectability:ta,visibleLayers:_.visibleLayerNames,selectableLayers:_.selectableLayers,app:_};function T5(){return _.view.addTileSlot("heatmap",{order:ot.heatmap,visible:!!_.activeHeatMap,source:Zb({wm:_.websocketManager,dpr:Yo,tileSize:sn,buildRequest:(n,e,t)=>T3(n,e,t,_)})})}function dv(n){if(_.heatMapData=n,_.activeHeatMap=n.active||"",_.heatMapLayer){let e=_.heatMapLayer.isVisible();_.heatMapLayer.setVisible(!!_.activeHeatMap),e&&_.heatMapLayer.refresh()}_.renderHeatMapControls&&_.renderHeatMapControls(n)}_.updateHeatMaps=dv;function hv(){_.overlayLayer&&_.overlayLayer.refresh()}var ks=ur(()=>{hv(),_.selectionBrowser&&_.selectionBrowser.scheduleRefresh()});_.refreshOverlay=ks;function Ut(){Ne("or_visibility",encodeURIComponent(JSON.stringify(gt))),Ne("or_selectability",encodeURIComponent(JSON.stringify(ta))),an();let n=[[_.modulesLayer,gt.module_view],[_.pinsLayer,gt.pins],..._.overlayLayers.map(({def:e,layer:t})=>[t,qh(e.shown_by,gt)])];for(let[e,t]of n)e&&(e.visible=!!t);for(let e of _.allLayers)e.refresh();_.heatMapLayer&&_.heatMapLayer.refresh(),_.renderSelectionOutline&&_.renderSelectionOutline(),!gt.highlight_selected&&_.clearSelectionPulse&&_.clearSelectionPulse(),hv(),_.rulerManager&&_.rulerManager.updateVisibility(),_.labelManager&&_.labelManager.updateVisibility(),_.updateScaleBar&&_.updateScaleBar()}var ea=ur(Ut),an=ur(()=>{!_.websocketManager||fe(_)||_.websocketManager.request({type:"set_display_state",state:NM()}).catch(()=>{})});_.syncDisplayState=an;function L5(n){if(!n||typeof n!="object")return;let e=n.entries;if(!(!e||typeof e!="object")){FM(e);try{if(_.view&&_.designScale&&typeof sessionStorage<"u"){let[t,i]=_.view.getCenter(),{dbuX:r,dbuY:s}=Pn(t,i,_.designScale,_.designOriginX,_.designOriginY);sessionStorage.setItem("or_restore_view",JSON.stringify({dbuX:r,dbuY:s,zoom:_.view.getZoom()}))}}catch{}window.location.reload()}}_.redrawAllLayers=Ut;_.captureLayout=(n={})=>jM(_,n);var YM=!1;function M5(n){let e=B3(n);!e||YM||e.kind==="software"&&Ge("or_hide_software_warning")==="1"||(YM=!0,I3(e.message,e.kind!=="software"?{}:{dontShowAgain:()=>Ne("or_hide_software_warning","1")}))}function A5(n){let e=document.createElement("div");e.className="layout-viewer",e.style.width="100%",e.style.height="100%",e.style.backgroundColor="var(--bg-map)",n.element.appendChild(e);let t=document.createElement("div");t.className="or-hud or-hud-bottom-right heatmap-map-legend hidden",e.appendChild(t),_.heatMapLegendEl=t;let i=document.createElement("div");i.className="or-progress",e.appendChild(i),_.tileProgressEl=i,n.on("destroy",()=>{_.tileProgressEl=null,_.heatMapLegendEl=null}),_.view=Q3(e,{preserveDrawingBuffer:_.preserveBuffer,prefs:{smooth:()=>_.controlSmoothing,doubleBuffer:()=>_.doubleBuffer,defer:()=>_.deferTileUpdates},tileSize:sn,dpr:Yo,isStatic:fe(_)}),_.view.on("contextlost",()=>{console.warn("Layout view: WebGL context lost; rebuilding the view.")}),_.view.on("contextfailed",()=>{on("The layout view lost its graphics context and could not get it back; reload the page.",15e3)}),_.view.on("renderer",M5),window.__orView=_.view,m3(()=>{_.view.invalidateSize(),Ut()});let r=document.createElement("div");r.className="or-zoom-control";let s=[];for(let[y,b,x]of[["+","Zoom in",()=>_.view.zoomIn()],["\u2212","Zoom out",()=>_.view.zoomOut()],["\u2922","Fit",()=>{_.fitRect&&_.view.fitWorldRect(_.fitRect)}]]){let E=document.createElement("button");E.type="button",E.title=b,E.setAttribute("aria-label",b),E.textContent=y,E.addEventListener("click",w=>{w.stopPropagation(),x()}),r.appendChild(E),s.push(E)}e.appendChild(r);let o=()=>{let{minZoom:y,maxZoom:b}=_.view.getLimits(),x=_.view.getTargetZoom();s[0].disabled=x>=b,s[1].disabled=x<=y};_.view.on("zoom zoomend limits",o),o();let a=document.createElement("div");a.className="or-hud or-hud-bottom-left hidden";let c=document.createElement("div");c.id="scale-bar";let l=document.createElement("span");l.className="or-hud-divider";let u=document.createElement("div");u.id="coord-bar",a.appendChild(c),a.appendChild(l),a.appendChild(u),e.appendChild(a);function f(){let y=c.style.display!=="none"&&c.childElementCount>0,b=u.textContent!=="";l.style.display=y&&b?"":"none",a.classList.toggle("hidden",!y&&!b)}f(),eM(_.view,{isStatic:()=>fe(_),wheelZoom:()=>_.wheelZoom,arrowStep:()=>_.arrowStep,contextEnabled:()=>!(_.rulerManager&&_.rulerManager.isActive()),onClick:(y,b)=>{_.rulerManager&&_.rulerManager.isActive()?_.rulerManager.handleMapClick(y,b):_.rulerManager?.handleRulerClick(y)||_.onMapClick&&_.onMapClick(y,b)},onContextClick:(y,b)=>{_.onMapContextClick&&_.onMapContextClick(y,b)},onMove:(y,b)=>{if(_.lastMouseWorld=y,_.rulerManager&&_.rulerManager.isActive()&&_.rulerManager.handleMouseMove(y,b),!_.designScale)return;let{dbuX:x,dbuY:E}=Pn(y[0],y[1],_.designScale,_.designOriginX,_.designOriginY);u.textContent=`X: ${_.formatDbu(x)} Y: ${_.formatDbu(E)}`,f()},onLeave:()=>{_.lastMouseWorld=null,u.textContent="",f()}});let d=22,h=8,p=22;function m(y,b,x){let w=2+h,T=p,R=p+y,F=d-2,O=y>=40,j=[];if(j.push(``),O&&x>1)for(let V=1;V`)}O&&j.push(`0`),j.push(`${b}`),c.innerHTML=`${j.join("")}`}function g(){if(!_.designScale||!gt.scale_bar){c.style.display="none",f();return}let y=_.designScale*Math.pow(2,_.view.getZoom()),b=_.view.getSize().width||400,x=j3({targetPx:b*.15,pxPerDbu:y,dbuPerMicron:_.techData?.dbu_per_micron,showDbu:_.showDbu});if(!x){c.style.display="none",f();return}c.style.display="",m(x.barPx,x.label,x.segments),f()}let v=ur(g);_.view.on("zoom zoomend resize",v),_.updateScaleBar=g,_.rulerManager=new Qh(_,gt,Xl,ap),_.labelManager=new ep(_,gt,Xl,ap)}function k5(n){let e=document.createElement("div");e.className="display-controls",e.innerHTML='
Loading layers...
',n.element.appendChild(e),_.displayControlsEl=e}var fv="or_restore_console",R5=1<<20;function I5(){try{if(_.tclOutputEl){let n=[..._.tclOutputEl.children].map(r=>[r.textContent,r.className]),e=n.length,t=0;for(;e>0&&t+n[e-1][0].length<=R5;)t+=n[--e][0].length;let i=n.slice(e);e>0&&i.unshift([`[earlier output not kept across reload] +`,""]),sessionStorage.setItem(fv,JSON.stringify(i))}}catch{}window.location.reload()}function B5(){try{let n=sessionStorage.getItem(fv);if(!n)return;sessionStorage.removeItem(fv);for(let[e,t]of JSON.parse(n))gr(e,t)}catch{}}function gr(n,e){if(!_.tclOutputEl)return;let t=document.createElement("span");e&&(t.className=e),t.textContent=n,_.tclOutputEl.appendChild(t),_.tclOutputEl.scrollTop=_.tclOutputEl.scrollHeight}function O5(){if(_._shutdownHandled)return;_._shutdownHandled=!0,_.websocketManager&&(_.websocketManager._shutdown=!0,_.websocketManager.onPush=()=>{});let n=document.createElement("div");n.style.cssText="position:fixed;inset:0;z-index:99999;background:#1e1e1e;color:#ddd;display:flex;flex-direction:column;align-items:center;justify-content:center;font-family:system-ui,sans-serif;font-size:16px;padding:24px;text-align:center;",n.innerHTML='
OpenROAD exited
You can close this tab.
',document.body.appendChild(n),setTimeout(()=>{try{window.close()}catch{}},1500)}function D5(n){let e=document.createElement("div");if(e.className="tcl-console",e.innerHTML='
%
',n.element.appendChild(e),_.tclOutputEl=e.querySelector(".tcl-output"),B5(),fe(_)){e.querySelector(".tcl-input-row").style.display="none";let r=document.createElement("span");r.className="tcl-static-notice",r.setAttribute("role","status"),r.setAttribute("aria-live","polite"),r.textContent="Tcl console is not available in saved reports.",_.tclOutputEl.appendChild(r);return}let t=e.querySelector(".tcl-input"),i=new ip(t,_.websocketManager);t.addEventListener("keydown",r=>{if(!i.handleKeyDown(r)&&r.key==="Enter"){let s=t.value.trim();if(!s)return;gr(`>>> ${s} `,"tcl-cmd"),i.addToHistory(s),t.value="",_.websocketManager.request({type:"tcl_eval",cmd:s}).then(o=>{o.result&&gr(o.result+` -`,o.is_error?"tcl-error":""),o.action==="shutdown"&&k5(),!o.is_error&&_.drcWidget&&_.drcWidget.refresh()}).catch(o=>gr(`Error: ${o} -`,"tcl-error"))}})}_.visibility=gt;var _r=uM(_,$t,ks),I5=_r.createInspector,Xl=_r.updateInspector,B5=_r.highlightBBox,O5=_r.pulseHighlight;_.updateInspector=Xl;_.navigateInspector=_r.navigateInspector;_.refreshInspector=_r.refreshInspector;_.animateSelection=_r.animateSelection;_.stopSelectionAnimation=_r.stopSelectionAnimation;function D5(n){new Vh(n,_,$t)}function N5(n){_.timingWidget=new Ps(_,$t,ks),n.element.appendChild(_.timingWidget.element)}function F5(n){_.drcWidget=new np(_,$t,ks),n.element.appendChild(_.drcWidget.element)}function z5(n){_.clockTreeWidget=new $h(n,_,$t,ks)}function U5(n){_.chartsWidget=new Gh(_,$t),n.element.appendChild(_.chartsWidget.element)}function $5(n){let e=document.createElement("div");e.className="help-panel",e.innerHTML="

Keyboard Shortcuts

fFit design to viewport
scrollZoom in/out
dragPan the view
right-dragRubber-band zoom
Shift+clickAdd object to selection
Ctrl/Cmd+clickSelect object and its connected nets
kToggle ruler mode
Shift+KClear all rulers
EscapeCancel ruler (when building)
",n.element.appendChild(e)}function G5(n){_.selectionBrowser=new Wh(n,_,ks)}function V5(n){new tp(n,_)}function W5(n){_.threeDViewerWidget=new sp(n,_)}var j5=28,H5={dimensions:{headerHeight:j5},root:{type:"row",content:[{type:"component",componentType:"DisplayControls",title:"Display Controls",width:15},{type:"column",width:55,content:[{type:"stack",height:70,content:[{type:"component",componentType:"LayoutViewer",title:"Layout",isClosable:!1},{type:"component",componentType:"SchematicWidget",title:"Schematic"},{type:"component",componentType:"3DViewer",title:"3D Viewer"}]},{type:"component",componentType:"TclConsole",title:"Tcl Console",height:30}]},{type:"stack",width:30,content:[{type:"component",componentType:"Inspector",title:"Inspector"},{type:"component",componentType:"Browser",title:"Hierarchy"},{type:"component",componentType:"TimingWidget",title:"Timing"},{type:"component",componentType:"DRCWidget",title:"DRC"},{type:"component",componentType:"SelectHighlight",title:"Select Highlight"},{type:"component",componentType:"ClockWidget",title:"Clock Tree"},{type:"component",componentType:"ChartsWidget",title:"Charts"},{type:"component",componentType:"HelpWidget",title:"Help"}]}]}};_.goldenLayout=new Th(document.getElementById("gl-container"));_.goldenLayout.registerComponentFactoryFunction("LayoutViewer",C5);_.goldenLayout.registerComponentFactoryFunction("DisplayControls",T5);_.goldenLayout.registerComponentFactoryFunction("TclConsole",R5);_.goldenLayout.registerComponentFactoryFunction("Inspector",I5);_.goldenLayout.registerComponentFactoryFunction("Browser",D5);_.goldenLayout.registerComponentFactoryFunction("TimingWidget",N5);_.goldenLayout.registerComponentFactoryFunction("DRCWidget",F5);_.goldenLayout.registerComponentFactoryFunction("ClockWidget",z5);_.goldenLayout.registerComponentFactoryFunction("ChartsWidget",U5);_.goldenLayout.registerComponentFactoryFunction("SchematicWidget",V5);_.goldenLayout.registerComponentFactoryFunction("3DViewer",W5);_.goldenLayout.registerComponentFactoryFunction("HelpWidget",$5);_.goldenLayout.registerComponentFactoryFunction("SelectHighlight",G5);var ci=window.__STATIC_CACHE__||null;if(ci)l3(),_.websocketManager=Nl.fromCache(ci,WM);else{let n=`ws://${window.location.host||"localhost:8080"}/ws`;_.websocketManager=new Nl(n,WM),_.layerExtents=new Ih,_.websocketManager.onReconnected=()=>{cp(),gv(null,null,{reloadOnChange:!0}).catch(()=>{})}}jM();_.goldenLayout.loadLayout(H5);HM();function HM(){W3(document.getElementById("gl-container"))>0&&_.goldenLayout.updateSize()}_.goldenLayout.on("stateChanged",()=>{HM()});function pv(){_.goldenLayout.updateSize()}_.syncLayoutSize=pv;window.addEventListener("resize",pv);function ap(n){_.goldenLayout.focusComponent(n)}_.focusComponent=ap;_.resetLayout=function(){_.goldenLayout&&typeof _.goldenLayout.resetLayout=="function"&&_.goldenLayout.resetLayout()};_.toggleTheme=function(){let n=document.documentElement.dataset.theme==="dark"?"light":"dark";document.documentElement.dataset.theme=n,ev(n),Nh(n),_.chartsWidget&&_.chartsWidget.render(),_.clockTreeWidget&&_.clockTreeWidget.render(),an()};_.toggleShowDbu=function(){_.showDbu=!_.showDbu,$e("or_show_dbu",_.showDbu?"1":"0"),_.rulerManager&&_.rulerManager._renderAll(),_.hierarchyBrowser&&_.hierarchyBrowser._render(),_.updateScaleBar&&_.updateScaleBar(),_.refreshInspector&&_.refreshInspector(),an()};_.toggleRulerStyle=function(){_.rulerStyle=_.rulerStyle==="manhattan"?"euclidian":"manhattan",$e("or_ruler_style",_.rulerStyle),an()};_.toggleWheelZoom=function(){_.wheelZoom=!_.wheelZoom,$e("or_wheel_zoom",_.wheelZoom?"1":"0"),an()};_.toggleControlSmoothing=function(){_.controlSmoothing=!_.controlSmoothing,$e("or_control_smoothing",_.controlSmoothing?"1":"0"),an()};_.toggleDoubleBuffer=function(){_.doubleBuffer=!_.doubleBuffer,$e("or_double_buffer",_.doubleBuffer?"1":"0"),_.view?.applyPrefs(),an()};_.toggleDeferTileUpdates=function(){_.deferTileUpdates=!_.deferTileUpdates,$e("or_defer_tile_updates",_.deferTileUpdates?"1":"0"),_.view?.applyPrefs(),an()};_.setArrowStep=function(n){_.arrowStep=Gl(n),$e("or_arrow_step",String(_.arrowStep)),an()};_.setAppFont=function({family:n,scale:e}){_.fontFamily=n??_.fontFamily,_.fontScale=jl(e??_.fontScale),$e("or_font_family",encodeURIComponent(_.fontFamily)),$e("or_font_scale",String(_.fontScale)),_.applyAppFont(),an()};_.applyAppFont=function(){let n=document.documentElement;_.fontFamily?n.style.setProperty("--or-font-family",_.fontFamily):n.style.removeProperty("--or-font-family"),n.style.setProperty("--or-font-scale",String(_.fontScale/100)),_.chartsWidget&&_.chartsWidget.render(),_.clockTreeWidget&&_.clockTreeWidget.render()};_.showArrowStepDialog=()=>hM(_);_.showAppFontDialog=()=>pM(_);_.togglePolyDecomp=function(){_.websocketManager&&_.websocketManager.request({type:"poly_decomp",value:!_.polyDecomp}).then(n=>mv(n.value)).catch(()=>{})};function mv(n){_.polyDecomp=!!n,_.rebuildMenuBar&&_.rebuildMenuBar(),_.refreshOverlay&&_.refreshOverlay()}_.applyAppFont();_.echoTcl=n=>gr(`>>> ${n} +`,o.is_error?"tcl-error":""),o.action==="shutdown"&&O5(),!o.is_error&&_.drcWidget&&_.drcWidget.refresh()}).catch(o=>gr(`Error: ${o} +`,"tcl-error"))}})}_.visibility=gt;var _r=dM(_,Ut,ks),N5=_r.createInspector,Xl=_r.updateInspector,F5=_r.highlightBBox,z5=_r.pulseHighlight;_.updateInspector=Xl;_.navigateInspector=_r.navigateInspector;_.refreshInspector=_r.refreshInspector;_.animateSelection=_r.animateSelection;_.stopSelectionAnimation=_r.stopSelectionAnimation;function U5(n){new Vh(n,_,Ut)}function $5(n){_.timingWidget=new Ps(_,Ut,ks),n.element.appendChild(_.timingWidget.element)}function G5(n){_.drcWidget=new np(_,Ut,ks),n.element.appendChild(_.drcWidget.element)}function V5(n){_.clockTreeWidget=new $h(n,_,Ut,ks)}function W5(n){_.chartsWidget=new Gh(_,Ut),n.element.appendChild(_.chartsWidget.element)}function j5(n){let e=document.createElement("div");e.className="help-panel",e.innerHTML="

Keyboard Shortcuts

fFit design to viewport
scrollZoom in/out
dragPan the view
right-dragRubber-band zoom
Shift+clickAdd object to selection
Ctrl/Cmd+clickSelect object and its connected nets
kToggle ruler mode
Shift+KClear all rulers
EscapeCancel ruler (when building)
",n.element.appendChild(e)}function H5(n){_.selectionBrowser=new Wh(n,_,ks)}function Y5(n){new tp(n,_)}function q5(n){_.threeDViewerWidget=new sp(n,_)}var Z5=28,X5={dimensions:{headerHeight:Z5},root:{type:"row",content:[{type:"component",componentType:"DisplayControls",title:"Display Controls",width:15},{type:"column",width:55,content:[{type:"stack",height:70,content:[{type:"component",componentType:"LayoutViewer",title:"Layout",isClosable:!1},{type:"component",componentType:"SchematicWidget",title:"Schematic"},{type:"component",componentType:"3DViewer",title:"3D Viewer"}]},{type:"component",componentType:"TclConsole",title:"Tcl Console",height:30}]},{type:"stack",width:30,content:[{type:"component",componentType:"Inspector",title:"Inspector"},{type:"component",componentType:"Browser",title:"Hierarchy"},{type:"component",componentType:"TimingWidget",title:"Timing"},{type:"component",componentType:"DRCWidget",title:"DRC"},{type:"component",componentType:"SelectHighlight",title:"Select Highlight"},{type:"component",componentType:"ClockWidget",title:"Clock Tree"},{type:"component",componentType:"ChartsWidget",title:"Charts"},{type:"component",componentType:"HelpWidget",title:"Help"}]}]}};_.goldenLayout=new Th(document.getElementById("gl-container"));_.goldenLayout.registerComponentFactoryFunction("LayoutViewer",A5);_.goldenLayout.registerComponentFactoryFunction("DisplayControls",k5);_.goldenLayout.registerComponentFactoryFunction("TclConsole",D5);_.goldenLayout.registerComponentFactoryFunction("Inspector",N5);_.goldenLayout.registerComponentFactoryFunction("Browser",U5);_.goldenLayout.registerComponentFactoryFunction("TimingWidget",$5);_.goldenLayout.registerComponentFactoryFunction("DRCWidget",G5);_.goldenLayout.registerComponentFactoryFunction("ClockWidget",V5);_.goldenLayout.registerComponentFactoryFunction("ChartsWidget",W5);_.goldenLayout.registerComponentFactoryFunction("SchematicWidget",Y5);_.goldenLayout.registerComponentFactoryFunction("3DViewer",q5);_.goldenLayout.registerComponentFactoryFunction("HelpWidget",j5);_.goldenLayout.registerComponentFactoryFunction("SelectHighlight",H5);var ci=window.__STATIC_CACHE__||null;if(ci)l3(),_.websocketManager=Nl.fromCache(ci,HM);else{let n=`ws://${window.location.host||"localhost:8080"}/ws`;_.websocketManager=new Nl(n,HM),_.layerExtents=new Ih,_.websocketManager.onReconnected=()=>{cp(),gv(null,null,{reloadOnChange:!0}).catch(()=>{})}}qM();_.goldenLayout.loadLayout(X5);ZM();function ZM(){H3(document.getElementById("gl-container"))>0&&_.goldenLayout.updateSize()}_.goldenLayout.on("stateChanged",()=>{ZM()});function pv(){_.goldenLayout.updateSize()}_.syncLayoutSize=pv;window.addEventListener("resize",pv);function ap(n){_.goldenLayout.focusComponent(n)}_.focusComponent=ap;_.resetLayout=function(){_.goldenLayout&&typeof _.goldenLayout.resetLayout=="function"&&_.goldenLayout.resetLayout()};_.toggleTheme=function(){let n=document.documentElement.dataset.theme==="dark"?"light":"dark";document.documentElement.dataset.theme=n,ev(n),Nh(n),_.chartsWidget&&_.chartsWidget.render(),_.clockTreeWidget&&_.clockTreeWidget.render(),an()};_.toggleShowDbu=function(){_.showDbu=!_.showDbu,Ne("or_show_dbu",_.showDbu?"1":"0"),_.rulerManager&&_.rulerManager._renderAll(),_.hierarchyBrowser&&_.hierarchyBrowser._render(),_.updateScaleBar&&_.updateScaleBar(),_.refreshInspector&&_.refreshInspector(),an()};_.toggleRulerStyle=function(){_.rulerStyle=_.rulerStyle==="manhattan"?"euclidian":"manhattan",Ne("or_ruler_style",_.rulerStyle),an()};_.toggleWheelZoom=function(){_.wheelZoom=!_.wheelZoom,Ne("or_wheel_zoom",_.wheelZoom?"1":"0"),an()};_.toggleControlSmoothing=function(){_.controlSmoothing=!_.controlSmoothing,Ne("or_control_smoothing",_.controlSmoothing?"1":"0"),an()};_.toggleDoubleBuffer=function(){_.doubleBuffer=!_.doubleBuffer,Ne("or_double_buffer",_.doubleBuffer?"1":"0"),_.view?.applyPrefs(),an()};_.toggleDeferTileUpdates=function(){_.deferTileUpdates=!_.deferTileUpdates,Ne("or_defer_tile_updates",_.deferTileUpdates?"1":"0"),_.view?.applyPrefs(),an()};_.setArrowStep=function(n){_.arrowStep=Gl(n),Ne("or_arrow_step",String(_.arrowStep)),an()};_.setAppFont=function({family:n,scale:e}){_.fontFamily=n??_.fontFamily,_.fontScale=jl(e??_.fontScale),Ne("or_font_family",encodeURIComponent(_.fontFamily)),Ne("or_font_scale",String(_.fontScale)),_.applyAppFont(),an()};_.applyAppFont=function(){let n=document.documentElement;_.fontFamily?n.style.setProperty("--or-font-family",_.fontFamily):n.style.removeProperty("--or-font-family"),n.style.setProperty("--or-font-scale",String(_.fontScale/100)),_.chartsWidget&&_.chartsWidget.render(),_.clockTreeWidget&&_.clockTreeWidget.render()};_.showArrowStepDialog=()=>mM(_);_.showAppFontDialog=()=>gM(_);_.togglePolyDecomp=function(){_.websocketManager&&_.websocketManager.request({type:"poly_decomp",value:!_.polyDecomp}).then(n=>mv(n.value)).catch(()=>{})};function mv(n){_.polyDecomp=!!n,_.rebuildMenuBar&&_.rebuildMenuBar(),_.refreshOverlay&&_.refreshOverlay()}_.applyAppFont();_.echoTcl=n=>gr(`>>> ${n} `,"tcl-cmd");_.runTclScript=(n,e)=>n?(e&&_.echoTcl(n),_.websocketManager.request({type:"tcl_eval",cmd:n}).then(t=>(t&&t.result&&gr(t.result+` `,t.is_error?"tcl-error":""),t)).catch(t=>{gr(`Error: ${t} -`,"tcl-error")})):Promise.resolve();function YM(n){n&&(_.customMenu=n.menu||[],_.customToolbar=n.toolbar||[],_.rebuildMenuBar&&_.rebuildMenuBar(),_.rebuildToolbar&&_.rebuildToolbar(),pv())}_.customMenu=[];_.customToolbar=[];_.scheduleRedrawAllLayers=ea;_.showGlobalConnectDialog=()=>PM(_);_.showInsertBufferDialog=n=>CM(_,n);xM(_);wM(_);_.contextMenu=new op(_);function Y5(){let n=document.getElementById("debug-continue-btn");return n||(n=document.createElement("button"),n.id="debug-continue-btn",n.className="debug-continue-btn",n.textContent="Continue",n.title="Advance the debugger (gpl, cts, ...)",n.addEventListener("click",()=>{_.websocketManager.request({type:"debug_continue"}).catch(()=>{})}),(document.getElementById("menu-bar")||document.body).appendChild(n),n)}function qM(n,e){let t=Kb(n,on(),e);return t?(_.currentBounds=n,_.designScale=t.scale,_.designOriginX=t.originX,_.designOriginY=t.originY,_.fitRect=t.fitRect,_.view.setLimits({minZoom:0,maxZoom:D3(t.scale)}),!0):!1}async function gv(n,e,{reloadOnChange:t=!1}={}){if(fe(_)||!_.view)return!1;let i=n,r=e;if(!i)try{let l=await _.websocketManager.request({type:"bounds"});i=l.bounds,r=l.fit_bounds}catch{return!1}if(!i||B3(_.currentBounds,i))return!1;if(t)return window.location.reload(),!0;let s=!!_.designScale,[o,a]=_.view.getCenter(),c=s?Pn(o,a,_.designScale,_.designOriginX,_.designOriginY):null;return qM(i,r)?(c&&_.view.setView(Sn(c.dbuX,c.dbuY,_.designScale,_.designOriginX,_.designOriginY),_.view.getZoom(),{animate:!1}),_.clearSelectionOutline&&_.clearSelectionOutline(),$t(),!0):!1}function q5(){let n=document.getElementById("loading-overlay");n.style.display="flex";let e=()=>{n.style.display!=="none"&&_.websocketManager.request({type:"bounds"}).then(t=>{t.shapes_ready&&(n.style.display="none")}).catch(()=>{}).finally(()=>{n.style.display!=="none"&&setTimeout(e,1e3)})};setTimeout(e,1e3)}function cp(){_.layerExtents&&_.layerExtents.refetch(n=>_.websocketManager.request(n))}function Z5(n){document.getElementById("loading-overlay").style.display="none",cp(),gv(n.bounds,n.fit_bounds).then(e=>{e||$t()}).catch(()=>$t()),_.refreshInspector&&_.refreshInspector()}function X5(){let n=document.getElementById("script-running-badge");return n||(n=document.createElement("span"),n.id="script-running-badge",n.className="script-running-badge",n.textContent="Script running",n.title="The view updates when the script pauses or finishes",(document.getElementById("menu-bar")||document.body).appendChild(n),n)}function K5(n){if(_.scriptRunning=n,X5().style.display=n?"block":"none",!n){if(!_.booted||!_.designScale){M5();return}_.refreshPending&&(_.refreshPending=!1,cp(),_.refreshInspector&&_.refreshInspector()),gv().then(e=>{e||ea()}).catch(()=>ea())}}_.websocketManager.onPush=n=>{if(n.type==="refresh"){if(_.scriptRunning){_.refreshPending=!0;return}Z5(n)}else if(n.type==="script_running")K5(!!n.running);else if(n.type==="renderer_controls_changed")_.refreshRendererControls&&_.refreshRendererControls(),ea();else if(n.type==="selection_invalidated")_.updateInspector&&_.updateInspector(null),_.stopSelectionAnimation&&_.stopSelectionAnimation(),_.clearSelectionOutline&&_.clearSelectionOutline(),ks();else if(n.type==="heatmaps_changed")_.websocketManager.request({type:"heatmaps"}).then(dv).catch(e=>console.error("Heat map refresh failed",e));else if(n.type==="labels_changed")_.labelManager&&_.labelManager.applyRemoteLabels(n.labels);else if(n.type==="drcUpdated")_._drcUpdateTimeout&&clearTimeout(_._drcUpdateTimeout),_._drcUpdateTimeout=setTimeout(()=>{_.drcWidget&&_.drcWidget.refresh()},500);else if(n.type==="debug_paused")_.refreshRendererControls&&_.refreshRendererControls(),Y5().style.display="block",ea(),_.chartsWidget&&_.websocketManager.request({type:"debug_charts"}).then(e=>_.chartsWidget.setDebugCharts(e.charts||[])).catch(()=>{});else if(n.type==="debug_resumed"){let e=document.getElementById("debug-continue-btn");e&&(e.style.display="none")}else if(n.type==="debug_refresh"){if(_.scriptRunning)return;_.clearSelectionOutline&&_.clearSelectionOutline(),ea()}else if(n.type==="log"){let e=n.text;e.endsWith(` +`,"tcl-error")})):Promise.resolve();function XM(n){n&&(_.customMenu=n.menu||[],_.customToolbar=n.toolbar||[],_.rebuildMenuBar&&_.rebuildMenuBar(),_.rebuildToolbar&&_.rebuildToolbar(),pv())}_.customMenu=[];_.customToolbar=[];_.scheduleRedrawAllLayers=ea;_.showGlobalConnectDialog=()=>TM(_);_.showInsertBufferDialog=n=>LM(_,n);EM(_);SM(_);_.contextMenu=new op(_);function K5(){let n=document.getElementById("debug-continue-btn");return n||(n=document.createElement("button"),n.id="debug-continue-btn",n.className="debug-continue-btn",n.textContent="Continue",n.title="Advance the debugger (gpl, cts, ...)",n.addEventListener("click",()=>{_.websocketManager.request({type:"debug_continue"}).catch(()=>{})}),(document.getElementById("menu-bar")||document.body).appendChild(n),n)}function KM(n,e){let t=Kb(n,sn(),e);return t?(_.currentBounds=n,_.designScale=t.scale,_.designOriginX=t.originX,_.designOriginY=t.originY,_.fitRect=t.fitRect,_.view.setLimits({minZoom:0,maxZoom:F3(t.scale)}),!0):!1}async function gv(n,e,{reloadOnChange:t=!1}={}){if(fe(_)||!_.view)return!1;let i=n,r=e;if(!i)try{let l=await _.websocketManager.request({type:"bounds"});i=l.bounds,r=l.fit_bounds}catch{return!1}if(!i||D3(_.currentBounds,i))return!1;if(t)return window.location.reload(),!0;let s=!!_.designScale,[o,a]=_.view.getCenter(),c=s?Pn(o,a,_.designScale,_.designOriginX,_.designOriginY):null;return KM(i,r)?(c&&_.view.setView(Sn(c.dbuX,c.dbuY,_.designScale,_.designOriginX,_.designOriginY),_.view.getZoom(),{animate:!1}),_.clearSelectionOutline&&_.clearSelectionOutline(),Ut(),!0):!1}function Q5(){let n=document.getElementById("loading-overlay");n.style.display="flex";let e=()=>{n.style.display!=="none"&&_.websocketManager.request({type:"bounds"}).then(t=>{t.shapes_ready&&(n.style.display="none")}).catch(()=>{}).finally(()=>{n.style.display!=="none"&&setTimeout(e,1e3)})};setTimeout(e,1e3)}function cp(){_.layerExtents&&_.layerExtents.refetch(n=>_.websocketManager.request(n))}function J5(n){document.getElementById("loading-overlay").style.display="none",cp(),gv(n.bounds,n.fit_bounds).then(e=>{e||Ut()}).catch(()=>Ut()),_.refreshInspector&&_.refreshInspector()}function ej(){let n=document.getElementById("script-running-badge");return n||(n=document.createElement("span"),n.id="script-running-badge",n.className="script-running-badge",n.textContent="Script running",n.title="The view updates when the script pauses or finishes",(document.getElementById("menu-bar")||document.body).appendChild(n),n)}function tj(n){if(_.scriptRunning=n,ej().style.display=n?"block":"none",!n){if(!_.booted||!_.designScale){I5();return}_.refreshPending&&(_.refreshPending=!1,cp(),_.refreshInspector&&_.refreshInspector()),gv().then(e=>{e||ea()}).catch(()=>ea())}}_.websocketManager.onPush=n=>{if(n.type==="refresh"){if(_.scriptRunning){_.refreshPending=!0;return}J5(n)}else if(n.type==="script_running")tj(!!n.running);else if(n.type==="renderer_controls_changed")_.refreshRendererControls&&_.refreshRendererControls(),ea();else if(n.type==="selection_invalidated")_.updateInspector&&_.updateInspector(null),_.stopSelectionAnimation&&_.stopSelectionAnimation(),_.clearSelectionOutline&&_.clearSelectionOutline(),ks();else if(n.type==="heatmaps_changed")_.websocketManager.request({type:"heatmaps"}).then(dv).catch(e=>console.error("Heat map refresh failed",e));else if(n.type==="labels_changed")_.labelManager&&_.labelManager.applyRemoteLabels(n.labels);else if(n.type==="drcUpdated")_._drcUpdateTimeout&&clearTimeout(_._drcUpdateTimeout),_._drcUpdateTimeout=setTimeout(()=>{_.drcWidget&&_.drcWidget.refresh()},500);else if(n.type==="debug_paused")_.refreshRendererControls&&_.refreshRendererControls(),K5().style.display="block",ea(),_.chartsWidget&&_.websocketManager.request({type:"debug_charts"}).then(e=>_.chartsWidget.setDebugCharts(e.charts||[])).catch(()=>{});else if(n.type==="debug_resumed"){let e=document.getElementById("debug-continue-btn");e&&(e.style.display="none")}else if(n.type==="debug_refresh"){if(_.scriptRunning)return;_.clearSelectionOutline&&_.clearSelectionOutline(),ea()}else if(n.type==="log"){let e=n.text;e.endsWith(` `)&&(e=e.slice(0,-1)),e&&gr(e+` -`,"")}else n.type==="restore_display_state"?S5(n.state):n.type==="custom_ui"?YM(n):n.type==="poly_decomp"?mv(n.value):n.type==="shutdown"&&(_.websocketManager._shutdown=!0,mr.innerHTML='
Server stopped
',mr.style.display="block")};_.websocketManager.readyPromise.then(async()=>{try{let o=function(a,c={}){let{addToSelection:l=!1,focusInspector:u=!0,context:f=!1,showConnectivity:d=!1}=c;if(!_.designScale)return Promise.resolve(null);let{dbuX:h,dbuY:p}=Pn(a[0],a[1],_.designScale,_.designOriginX,_.designOriginY);if(_.labelManager&&_.labelManager.isActive())return _.labelManager.handleMapClick(h,p),Promise.resolve(null);let m=k3(gt,ta),g={type:"select",dbu_x:h,dbu_y:p,zoom:Math.round(_.view.getZoom()),visible_layers:[..._.visibleLayerNames],selectable_layers:[..._.selectableLayers],use_dbu:_.showDbu,...m};l&&(g.add_to_selection=!0),f&&(g.context=!0),d&&(g.show_connectivity=!0),_.visibleChiplets instanceof Set&&(g.visible_chiplets=[..._.visibleChiplets]);let v=Pt(_);return _.websocketManager.request(g).then(y=>{if(zt(_,v)){if(console.log("Select response:",y,"at dbu",h,p),qo(_,y),y.selected&&y.selected.length>0){let b=y.selected[0];b.type==="Inst"&&(_.selectedInstanceName=b.name,_.schematicWidget&&_.schematicWidget.refresh()),Xl(y),u&&ap("Inspector"),y.bbox&&(B5(y.bbox[0],y.bbox[1],y.bbox[2],y.bbox[3],y.type),O5(y.bbox,y.type),_.lastSelectionBounds=y.bbox.slice(0,4)),g.show_connectivity&&y.connected_added>0&&Ft(`Selected ${y.connected_added} connected net`+(y.connected_added>1?"s":""))}else!l&&!f&&(Xl(null),_.clearSelectionOutline&&_.clearSelectionOutline(),_.lastSelectionBounds=null);return hv(),y}}).catch(y=>(console.error("Select failed:",y),null))},[n,e,t]=await Promise.all([_.websocketManager.request({type:"tech"}),_.websocketManager.request({type:"bounds"}),_.websocketManager.request({type:"heatmaps"})]);cp(),_.hasLiberty=n.has_liberty,_.techData=n,NM(n.block_name),_.websocketManager.request({type:"custom_ui"}).then(YM).catch(()=>{}),_.websocketManager.request({type:"poly_decomp"}).then(a=>mv(a.value)).catch(()=>{});let i=e.bounds,r=e.fit_bounds;if(!ci){let a=_.view.getSize();u3(N3({designBounds:i,fitRect:r,viewW:a.width,viewH:a.height}))}let s=qM(i,r);if(s){if(_.labelManager&&_.labelManager.reload(),ci){let a=ci.zoom;_.view.setLimits({minZoom:a,maxZoom:a})}if(_.view.fitWorldRect(_.fitRect,{animate:!1}),ci){let a=Nt(i[0][1],i[0][0],i[1][1],i[1][0],_.designScale,_.designOriginX,_.designOriginY);ci.setPathOverlay=c=>{_.view.setImageOverlay("timing-path",c?{image:c,rect:a}:null)}}try{let a=sessionStorage.getItem("or_restore_view");if(a){sessionStorage.removeItem("or_restore_view");let c=JSON.parse(a);c&&isFinite(c.dbuX)&&isFinite(c.dbuY)&&isFinite(c.zoom)&&_.view.setView(Sn(c.dbuX,c.dbuY,_.designScale,_.designOriginX,_.designOriginY),c.zoom,{animate:!1})}}catch{}}ci&&(document.getElementById("loading-overlay").style.display="none"),_.selectAtWorld=o,ci||(_.onMapClick=(a,c)=>o(a,{addToSelection:!!c.shiftKey,showConnectivity:!!(c.ctrlKey||c.metaKey)}),_.onMapContextClick=(a,c)=>{o(a,{context:!0,focusInspector:!1}).then(()=>_.contextMenu.show(c))}),_M(_,gt,ta,n,$t,E5),!_.overlayLayer&&!ci&&(_.overlayLayer=_.view.addTileSlot("overlay",{order:ot.overlay,source:Zb({wm:_.websocketManager,dpr:Yo,tileSize:on,buildRequest:(a,c,l)=>C3(a,c,l,gt,_)})})),dv(t),s&&!e.shapes_ready&&q5(),an(),_.booted=!0}catch(n){_.scriptRunning||console.error("Failed to load initial data from server:",n)}});document.addEventListener("openroad-cone-sync",n=>{_.schematicWidget?.syncCone(n.detail||{})});document.addEventListener("keydown",n=>{let e=n.target.tagName;if(e==="INPUT"||e==="TEXTAREA"||n.target.isContentEditable)return;let t=n.key.toLowerCase();if(t==="escape"&&_.rulerManager&&_.rulerManager.isActive())_.rulerManager.cancelRulerBuild();else if(t==="escape"&&_.labelManager&&_.labelManager.isActive())_.labelManager.cancelLabelMode();else if(t==="k"&&!n.shiftKey&&!n.ctrlKey&&!n.metaKey)_.rulerManager&&_.rulerManager.toggleRulerMode();else if(t==="k"&&n.shiftKey&&!n.ctrlKey&&!n.metaKey)_.rulerManager&&_.rulerManager.clearAllRulers();else if(t==="l"&&!n.shiftKey&&!n.ctrlKey&&!n.metaKey)_.labelManager&&_.labelManager.toggleLabelMode();else if(t==="f"&&!n.ctrlKey&&!n.metaKey&&_.fitRect)_.view.fitWorldRect(_.fitRect);else if(t==="z"&&!n.ctrlKey&&_.view){let i=n.shiftKey?-1:1;_.view.zoomAround(_.lastMouseWorld?_.view.project(_.lastMouseWorld):null,i)}else t==="f"&&(n.ctrlKey||n.metaKey)?(n.preventDefault(),_.designScale&&Zh(_)):t==="g"&&n.shiftKey&&!n.ctrlKey&&!n.metaKey?(n.preventDefault(),_.designScale&&Xh(_)):t==="t"&&!n.shiftKey&&!n.ctrlKey&&!n.metaKey&&_.toggleTheme()},!0);})(); +`,"")}else n.type==="restore_display_state"?L5(n.state):n.type==="custom_ui"?XM(n):n.type==="poly_decomp"?mv(n.value):n.type==="shutdown"&&(_.websocketManager._shutdown=!0,mr.innerHTML='
Server stopped
',mr.style.display="block")};_.websocketManager.readyPromise.then(async()=>{try{let o=function(a,c={}){let{addToSelection:l=!1,focusInspector:u=!0,context:f=!1,showConnectivity:d=!1}=c;if(!_.designScale)return Promise.resolve(null);let{dbuX:h,dbuY:p}=Pn(a[0],a[1],_.designScale,_.designOriginX,_.designOriginY);if(_.labelManager&&_.labelManager.isActive())return _.labelManager.handleMapClick(h,p),Promise.resolve(null);let m=R3(gt,ta),g={type:"select",dbu_x:h,dbu_y:p,zoom:Math.round(_.view.getZoom()),visible_layers:[..._.visibleLayerNames],selectable_layers:[..._.selectableLayers],use_dbu:_.showDbu,...m};l&&(g.add_to_selection=!0),f&&(g.context=!0),d&&(g.show_connectivity=!0),_.visibleChiplets instanceof Set&&(g.visible_chiplets=[..._.visibleChiplets]);let v=Pt(_);return _.websocketManager.request(g).then(y=>{if(Ft(_,v)){if(console.log("Select response:",y,"at dbu",h,p),qo(_,y),y.selected&&y.selected.length>0){let b=y.selected[0];b.type==="Inst"&&(_.selectedInstanceName=b.name,_.schematicWidget&&_.schematicWidget.refresh()),Xl(y),u&&ap("Inspector"),y.bbox&&(F5(y.bbox[0],y.bbox[1],y.bbox[2],y.bbox[3],y.type),z5(y.bbox,y.type),_.lastSelectionBounds=y.bbox.slice(0,4)),g.show_connectivity&&y.connected_added>0&&on(`Selected ${y.connected_added} connected net`+(y.connected_added>1?"s":""))}else!l&&!f&&(Xl(null),_.clearSelectionOutline&&_.clearSelectionOutline(),_.lastSelectionBounds=null);return hv(),y}}).catch(y=>(console.error("Select failed:",y),null))},[n,e,t]=await Promise.all([_.websocketManager.request({type:"tech"}),_.websocketManager.request({type:"bounds"}),_.websocketManager.request({type:"heatmaps"})]);cp(),_.hasLiberty=n.has_liberty,_.techData=n,zM(n.block_name),_.websocketManager.request({type:"custom_ui"}).then(XM).catch(()=>{}),_.websocketManager.request({type:"poly_decomp"}).then(a=>mv(a.value)).catch(()=>{});let i=e.bounds,r=e.fit_bounds;if(!ci){let a=_.view.getSize();u3(z3({designBounds:i,fitRect:r,viewW:a.width,viewH:a.height}))}let s=KM(i,r);if(s){if(_.labelManager&&_.labelManager.reload(),ci){let a=ci.zoom;_.view.setLimits({minZoom:a,maxZoom:a})}if(_.view.fitWorldRect(_.fitRect,{animate:!1}),ci){let a=Nt(i[0][1],i[0][0],i[1][1],i[1][0],_.designScale,_.designOriginX,_.designOriginY);ci.setPathOverlay=c=>{_.view.setImageOverlay("timing-path",c?{image:c,rect:a}:null)}}try{let a=sessionStorage.getItem("or_restore_view");if(a){sessionStorage.removeItem("or_restore_view");let c=JSON.parse(a);c&&isFinite(c.dbuX)&&isFinite(c.dbuY)&&isFinite(c.zoom)&&_.view.setView(Sn(c.dbuX,c.dbuY,_.designScale,_.designOriginX,_.designOriginY),c.zoom,{animate:!1})}}catch{}}ci&&(document.getElementById("loading-overlay").style.display="none"),_.selectAtWorld=o,ci||(_.onMapClick=(a,c)=>o(a,{addToSelection:!!c.shiftKey,showConnectivity:!!(c.ctrlKey||c.metaKey)}),_.onMapContextClick=(a,c)=>{o(a,{context:!0,focusInspector:!1}).then(()=>_.contextMenu.show(c))}),bM(_,gt,ta,n,Ut,T5),!_.overlayLayer&&!ci&&(_.overlayLayer=_.view.addTileSlot("overlay",{order:ot.overlay,source:Zb({wm:_.websocketManager,dpr:Yo,tileSize:sn,buildRequest:(a,c,l)=>C3(a,c,l,gt,_)})})),dv(t),s&&!e.shapes_ready&&Q5(),an(),_.booted=!0}catch(n){_.scriptRunning||console.error("Failed to load initial data from server:",n)}});document.addEventListener("openroad-cone-sync",n=>{_.schematicWidget?.syncCone(n.detail||{})});document.addEventListener("keydown",n=>{let e=n.target.tagName;if(e==="INPUT"||e==="TEXTAREA"||n.target.isContentEditable)return;let t=n.key.toLowerCase();if(t==="escape"&&_.rulerManager&&_.rulerManager.isActive())_.rulerManager.cancelRulerBuild();else if(t==="escape"&&_.labelManager&&_.labelManager.isActive())_.labelManager.cancelLabelMode();else if(t==="k"&&!n.shiftKey&&!n.ctrlKey&&!n.metaKey)_.rulerManager&&_.rulerManager.toggleRulerMode();else if(t==="k"&&n.shiftKey&&!n.ctrlKey&&!n.metaKey)_.rulerManager&&_.rulerManager.clearAllRulers();else if(t==="l"&&!n.shiftKey&&!n.ctrlKey&&!n.metaKey)_.labelManager&&_.labelManager.toggleLabelMode();else if(t==="f"&&!n.ctrlKey&&!n.metaKey&&_.fitRect)_.view.fitWorldRect(_.fitRect);else if(t==="z"&&!n.ctrlKey&&_.view){let i=n.shiftKey?-1:1;_.view.zoomAround(_.lastMouseWorld?_.view.project(_.lastMouseWorld):null,i)}else t==="f"&&(n.ctrlKey||n.metaKey)?(n.preventDefault(),_.designScale&&Zh(_)):t==="g"&&n.shiftKey&&!n.ctrlKey&&!n.metaKey?(n.preventDefault(),_.designScale&&Xh(_)):t==="t"&&!n.shiftKey&&!n.ctrlKey&&!n.metaKey&&_.toggleTheme()},!0);})(); /*! Bundled license information: @lit/reactive-element/css-tag.js: diff --git a/src/web/src/layout-view.js b/src/web/src/layout-view.js index fe7af5850c3..96972072ec6 100644 --- a/src/web/src/layout-view.js +++ b/src/web/src/layout-view.js @@ -244,6 +244,15 @@ export function createLayoutView(container, opts = {}) { events.emit('renderer', rendererInfo); scheduleRender(); }, + // An error before onLoad means the device was never created: the + // browser gave no WebGL, and nothing will be drawn. + onError: (error) => { + console.error('Layout view:', error); + if (!rendererInfo) { + rendererInfo = { gpuType: 'none', renderer: '', vendor: '' }; + events.emit('renderer', rendererInfo); + } + }, onAfterRender: () => { const waiting = afterFrame; afterFrame = []; diff --git a/src/web/src/main.js b/src/web/src/main.js index b5d510ad1d4..a3fb66fdcd8 100644 --- a/src/web/src/main.js +++ b/src/web/src/main.js @@ -23,8 +23,8 @@ import { applySelectionFlags, beginSelection, boundsEqual, buildVisibilityFlags, clampArrowStep, computeBoundsTransforms, computeScaleBar, decorateTabIcons, fittedTileSizeCss, formatDbu, formatDistance, isCurrentSelection, isStaticMode, maxUsefulZoom, - parseDbu, rafCoalesce, showToast, softwareRenderingWarning, - unitLabel } + parseDbu, rafCoalesce, renderingWarning, showCornerWarning, + showToast, unitLabel } from './ui-utils.js'; import { clampFontScale, showAppFontDialog, showArrowStepDialog } from './options-dialogs.js'; @@ -574,21 +574,21 @@ app.redrawAllLayers = redrawAllLayers; // Expose the WYSIWYG capture so the context menu "Save" can grab the scene. app.captureLayout = (opts = {}) => captureLayout(app, opts); -// Once per browser session: the layout view is slow without the GPU. +// Once per page load: the view reports its renderer again after a lost +// context or when reopened. Only the slow-but-working case can be silenced; +// without WebGL nothing is drawn. +let renderWarningShown = false; function warnIfSoftwareRendering(info) { - const message = softwareRenderingWarning(info); - if (!message) { + const warning = renderingWarning(info); + if (!warning || renderWarningShown + || (warning.kind === 'software' + && getCookie('or_hide_software_warning') === '1')) { return; } - try { - if (sessionStorage.getItem('or_sw_render_warned')) { - return; - } - sessionStorage.setItem('or_sw_render_warned', '1'); - } catch (_) { - // Storage blocked: warn on every load instead. - } - showToast(message, 15000); + renderWarningShown = true; + showCornerWarning(warning.message, warning.kind !== 'software' ? {} : { + dontShowAgain: () => setCookie('or_hide_software_warning', '1'), + }); } function createLayoutViewer(container) { diff --git a/src/web/src/style.css b/src/web/src/style.css index 2c5420e9f2d..b7cb13e276c 100644 --- a/src/web/src/style.css +++ b/src/web/src/style.css @@ -2396,6 +2396,49 @@ ide-tab.lm_active, #or-toast.visible { opacity: 1; } +/* A warning that stays in the page's bottom-right corner until closed. */ +.or-corner-warning { + position: fixed; + right: var(--space-md); + bottom: var(--space-md); + max-width: 360px; + display: flex; + align-items: flex-start; + gap: var(--space-sm); + padding: var(--space-md); + background: var(--bg-context); + color: var(--fg-primary); + border: 1px solid var(--border-strong); + border-left: 4px solid var(--sem-warn); + border-radius: var(--radius-md); + box-shadow: 0 6px 20px var(--shadow-strong); + font-size: var(--fs-12); + z-index: 3000; +} +.or-corner-warning-close { + flex: none; + padding: 0 var(--space-sm); + background: none; + border: none; + color: var(--fg-secondary); + font-size: var(--fs-16); + line-height: 1; + cursor: pointer; +} +.or-corner-warning-close:hover { + color: var(--fg-primary); +} +.or-corner-warning-never { + display: block; + margin-top: var(--space-sm); + padding: 0; + background: none; + border: none; + color: var(--accent-link); + font: inherit; + text-decoration: underline; + cursor: pointer; +} /* Holds the property rows so the column divider can be absolutely positioned * over their full height. */ .inspector-rows { diff --git a/src/web/src/ui-utils.js b/src/web/src/ui-utils.js index 44adf4eb506..1a8dd2e69ca 100644 --- a/src/web/src/ui-utils.js +++ b/src/web/src/ui-utils.js @@ -55,16 +55,68 @@ export function showToast(message, durationMs = 4000) { return toast; } -// The notice for a browser that draws the layout view without the GPU -// (luma.gl's gpuType 'cpu'), or null. -export function softwareRenderingWarning(info) { - if (!info || info.gpuType !== 'cpu') { +// A warning in the bottom-right corner of the page that stays until closed. +// With `dontShowAgain`, a second button calls it and closes the warning. +export function showCornerWarning(message, { dontShowAgain } = {}) { + const box = document.createElement('div'); + box.className = 'or-corner-warning'; + box.setAttribute('role', 'alert'); + const body = document.createElement('div'); + const text = document.createElement('span'); + text.textContent = message; + body.append(text); + if (dontShowAgain) { + const never = document.createElement('button'); + never.type = 'button'; + never.className = 'or-corner-warning-never'; + never.textContent = "Don't show again"; + never.addEventListener('click', () => { + dontShowAgain(); + box.remove(); + }); + body.append(never); + } + const close = document.createElement('button'); + close.type = 'button'; + close.className = 'or-corner-warning-close'; + close.title = 'Close'; + close.setAttribute('aria-label', 'Close'); + close.textContent = '×'; + close.addEventListener('click', () => box.remove()); + box.append(body, close); + document.body.appendChild(box); + return box; +} + +// Software rasterizers luma.gl does not flag: it reports only SwiftShader as +// gpuType 'cpu', so Mesa's (Firefox, remote desktops) and Windows' come back +// 'unknown'. +const kSoftwareRenderer = + /SwiftShader|llvmpipe|lavapipe|softpipe|Basic Render Driver/i; + +// A page cannot read the browser's setting, only that there is no GPU, so the +// advice is conditional: without a GPU in the machine, the setting is moot. +const kAccelerationHint = 'If hardware acceleration is turned off in your ' + + "browser settings ('Use graphics acceleration when available' or 'Use " + + "hardware acceleration when available'), turn it on and restart the " + + 'browser.'; + +// What to tell a user whose browser draws the layout view without the GPU: +// { kind: 'nowebgl' | 'software', message }, or null. +export function renderingWarning(info) { + if (!info) { + return null; + } + if (info.gpuType === 'none') { + return { kind: 'nowebgl', message: 'WebGL is not available, so the ' + + 'layout view cannot be drawn. ' + kAccelerationHint }; + } + const name = `${info.vendor || ''} ${info.renderer || ''}`; + if (info.gpuType !== 'cpu' && !kSoftwareRenderer.test(name)) { return null; } - return 'Software rendering detected (reduced performance). Make sure ' - + "'Use graphics acceleration when available' (or 'Use hardware " - + "acceleration when available') is turned on in your browser " - + 'settings, then restart the browser.'; + return { kind: 'software', message: 'The layout view is being drawn in ' + + 'software, without the GPU, which is slower. ' + kAccelerationHint }; } // Themed confirmation dialog. Resolves true when confirmed, false when diff --git a/src/web/test/BUILD b/src/web/test/BUILD index b6bcd771ad9..3c5022ffee4 100644 --- a/src/web/test/BUILD +++ b/src/web/test/BUILD @@ -91,7 +91,7 @@ js_test( js_test( name = "ui_utils_test", - data = JS_FILES, + data = DOM_TEST_DATA, entry_point = "js/test-ui-utils.js", no_copy_to_bin = JS_FILES, ) diff --git a/src/web/test/js/fake-deck.js b/src/web/test/js/fake-deck.js index 78b06182dae..f65f92e4e83 100644 --- a/src/web/test/js/fake-deck.js +++ b/src/web/test/js/fake-deck.js @@ -17,6 +17,8 @@ export function makeFakeDeck() { // What luma.gl's device.info would report. deviceInfo: { gpuType: 'discrete', renderer: 'Fake GPU', vendor: 'Fake' }, + // Set to fail device creation, as a browser without WebGL does. + noWebGL: false, Deck: class { constructor(props) { this.props = { ...props }; @@ -26,6 +28,10 @@ export function makeFakeDeck() { this.loaded = false; api.decks.push(this); queueMicrotask(() => { + if (api.noWebGL) { + this.props.onError?.(new Error('WebGL2 not available')); + return; + } this.loaded = true; this.device = { info: { ...api.deviceInfo } }; this.props.onLoad?.(); diff --git a/src/web/test/js/test-layout-view.js b/src/web/test/js/test-layout-view.js index b17e95a855a..a6fee5f642d 100644 --- a/src/web/test/js/test-layout-view.js +++ b/src/web/test/js/test-layout-view.js @@ -929,4 +929,28 @@ describe('LayoutView renderer', () => { assert.deepEqual(seen, ['cpu', 'integrated']); assert.equal(view.getRendererInfo().gpuType, 'integrated'); }); + + it('reports a browser without WebGL as no renderer at all', async (t) => { + t.mock.method(console, 'error', () => {}); + const deck = makeFakeDeck(); + deck.noWebGL = true; + const { view } = setup({ deck }); + const seen = []; + view.on('renderer', (info) => seen.push(info)); + await tick(); + const none = { gpuType: 'none', renderer: '', vendor: '' }; + assert.deepEqual(seen, [none]); + assert.deepEqual(view.getRendererInfo(), none); + }); + + it('takes a later error for just an error', async (t) => { + t.mock.method(console, 'error', () => {}); + const { view, deck } = setup(); + const seen = []; + view.on('renderer', (info) => seen.push(info.gpuType)); + await tick(); + deck.decks[0].props.onError(new Error('picking failed')); + assert.deepEqual(seen, ['discrete']); + assert.equal(view.getRendererInfo().gpuType, 'discrete'); + }); }); diff --git a/src/web/test/js/test-ui-utils.js b/src/web/test/js/test-ui-utils.js index a069618fb55..01c893f383e 100644 --- a/src/web/test/js/test-ui-utils.js +++ b/src/web/test/js/test-ui-utils.js @@ -1,12 +1,13 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright (c) 2026, The OpenROAD Authors -import { describe, it } from 'node:test'; +import { describe, it, beforeEach, afterEach } from 'node:test'; import assert from 'node:assert/strict'; +import { JSDOM } from 'jsdom'; import { boundsEqual, computeBoundsTransforms, computeScaleBar, cssColorToHex, fittedTileSizeCss, isValidHexColor, kZoomMargin, maxUsefulZoom, MAX_TILE_ZOOM, niceRoundParts, prefersReducedMotion, rafCoalesce, - softwareRenderingWarning } + renderingWarning, showCornerWarning } from '../../src/ui-utils.js'; import { isDeviceExactTileSize, TILE_SIZE_CSS, TILE_SIZE_QUANTUM } from '../../src/tile-request.js'; @@ -402,19 +403,110 @@ describe('prefersReducedMotion', () => { }); }); -describe('softwareRenderingWarning', () => { - it('tells how to turn graphics acceleration on for a software renderer', () => { - const msg = softwareRenderingWarning({ gpuType: 'cpu' }); - assert.match(msg, /Software rendering detected/); +describe('renderingWarning', () => { + // The page cannot see the browser setting, so the advice is conditional. + const hint = (msg) => { + assert.match(msg, /If hardware acceleration is turned off/); assert.match(msg, /Use graphics acceleration when available/); assert.match(msg, /Use hardware acceleration when available/); assert.match(msg, /restart the browser/); + }; + + it('says a software renderer is slower, without claiming why', () => { + const w = renderingWarning({ gpuType: 'cpu' }); + assert.equal(w.kind, 'software'); + assert.match(w.message, /drawn in software, without the GPU/); + assert.doesNotMatch(w.message, /detected/); + hint(w.message); + }); + + it('says the view cannot draw without WebGL', () => { + const w = renderingWarning({ gpuType: 'none' }); + assert.equal(w.kind, 'nowebgl'); + assert.match(w.message, /WebGL is not available/); + hint(w.message); }); it('says nothing when a GPU draws, or before the renderer is known', () => { for (const gpuType of ['discrete', 'integrated', 'unknown']) { - assert.equal(softwareRenderingWarning({ gpuType }), null, gpuType); + assert.equal(renderingWarning({ gpuType }), null, gpuType); + } + assert.equal(renderingWarning(null), null); + }); + + // As the browsers report them; luma.gl calls all of these 'unknown'. + it('recognizes the software rasterizers luma.gl does not', () => { + for (const [vendor, renderer] of [ + ['Mesa', 'llvmpipe, or similar'], // Firefox + ['Google Inc. (Mesa)', + 'ANGLE (Mesa, llvmpipe (LLVM 20.1.2 256 bits), OpenGL 4.5)'], + ['Google Inc. (Mesa)', 'ANGLE (Mesa, Vulkan 1.4.318 (llvmpipe ' + + '(LLVM 20.1.2 256 bits) (0x00000000)), llvmpipe)'], + ['Mesa', 'lavapipe'], + ['Mesa', 'softpipe'], + ['Google Inc. (Microsoft)', + 'ANGLE (Microsoft, Microsoft Basic Render Driver Direct3D11)'], + ]) { + const w = renderingWarning({ gpuType: 'unknown', vendor, renderer }); + assert.equal(w && w.kind, 'software', renderer); } - assert.equal(softwareRenderingWarning(null), null); + }); + + it('leaves GPUs, Mesa hardware drivers included, alone', () => { + for (const [vendor, renderer] of [ + ['Google Inc. (NVIDIA)', + 'ANGLE (NVIDIA, NVIDIA GeForce RTX 3080 Direct3D11 vs_5_0 ps_5_0)'], + ['Intel', 'Mesa Intel(R) UHD Graphics 630 (CFL GT2)'], + ['AMD', 'AMD Radeon RX 6800 (radeonsi, navi21, LLVM 15.0.7)'], + ['Google Inc. (Apple)', 'ANGLE (Apple, Apple M2, OpenGL 4.1)'], + ]) { + assert.equal(renderingWarning( + { gpuType: 'unknown', vendor, renderer }), null, renderer); + } + }); +}); + +describe('showCornerWarning', () => { + let saved; + beforeEach(() => { + saved = globalThis.document; + globalThis.document = new JSDOM('') + .window.document; + }); + afterEach(() => { + globalThis.document = saved; + }); + + it('stays in the page until closed', () => { + const box = showCornerWarning('Drawn in software.'); + assert.equal(box.parentNode, document.body); + assert.equal(box.className, 'or-corner-warning'); + assert.equal(box.getAttribute('role'), 'alert'); + assert.equal(box.querySelector('span').textContent, 'Drawn in software.'); + assert.equal(box.querySelector('.or-corner-warning-never'), null, + 'nothing to silence unless asked'); + const close = box.querySelector('.or-corner-warning-close'); + assert.equal(close.getAttribute('aria-label'), 'Close'); + close.click(); + assert.equal(document.querySelector('.or-corner-warning'), null); + }); + + it('offers to stop showing it, and closes', () => { + let silenced = 0; + const box = showCornerWarning('Drawn in software.', + { dontShowAgain: () => silenced++ }); + const never = box.querySelector('.or-corner-warning-never'); + assert.equal(never.textContent, "Don't show again"); + never.click(); + assert.equal(silenced, 1); + assert.equal(document.querySelector('.or-corner-warning'), null); + }); + + it('closing is not silencing', () => { + let silenced = 0; + const box = showCornerWarning('Drawn in software.', + { dontShowAgain: () => silenced++ }); + box.querySelector('.or-corner-warning-close').click(); + assert.equal(silenced, 0); }); }); From 62c64fcdc0fec20f213c639fe51615dc32edb95c Mon Sep 17 00:00:00 2001 From: Jorge Ferreira Date: Thu, 22 Oct 2026 00:20:23 +0000 Subject: [PATCH 4/8] web: keep the security hook's blocked words out of the bundle luma.gl names a GPU maker the private repository's hook rejects; rename it at build time without changing behavior. Signed-off-by: Jorge Ferreira --- src/web/dist/app.min.js | 14 +++---- src/web/dist/report.min.js | 14 +++---- src/web/esbuild.config.mjs | 28 +++++++++++++- src/web/test/BUILD | 7 ++++ src/web/test/bundle_test.py | 14 +++++++ src/web/test/js/test-esbuild-config.js | 51 ++++++++++++++++++++++++++ src/web/test/js/test-ui-utils.js | 3 +- 7 files changed, 115 insertions(+), 16 deletions(-) create mode 100644 src/web/test/js/test-esbuild-config.js diff --git a/src/web/dist/app.min.js b/src/web/dist/app.min.js index cb9974d57df..93974c092e4 100644 --- a/src/web/dist/app.min.js +++ b/src/web/dist/app.min.js @@ -42,17 +42,17 @@ ${d}${b}${s.type.toUpperCase()}: ${s.message} // Apple optimizes away the calculation necessary for emulated fp64 #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 -// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow +// Int_el GPU doesn't have full 32 bits precision in same cases, causes overflow #define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 `;case"nvidia":return`#define NVIDIA_GPU // Nvidia optimizes away the calculation necessary for emulated fp64 #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 -`;case"intel":return`#define INTEL_GPU -// Intel optimizes away the calculation necessary for emulated fp64 +`;case"int_el":return`#define INT_EL_GPU +// Int_el optimizes away the calculation necessary for emulated fp64 #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 -// Intel's built-in 'tan' function doesn't have acceptable precision +// Int_el's built-in 'tan' function doesn't have acceptable precision #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 -// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow +// Int_el GPU doesn't have full 32 bits precision in same cases, causes overflow #define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 `;case"amd":return`#define AMD_GPU `;default:return`#define DEFAULT_GPU @@ -129,7 +129,7 @@ void main() { }`,mYt=`#version 300 es ${gYt}`});function _4e(s,{precision:n=jh.precision}={}){return s=vYt(s),`${parseFloat(s.toPrecision(n))}`}function P3(s){return Array.isArray(s)||ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Kl(s,n,r){return yYt(s,c=>Math.max(n,Math.min(r,c)))}function lv(s,n,r){return P3(s)?s.map((c,u)=>lv(c,n[u],r)):r*n+(1-r)*s}function Wy(s,n,r){let c=jh.EPSILON;r&&(jh.EPSILON=r);try{if(s===n)return!0;if(P3(s)&&P3(n)){if(s.length!==n.length)return!1;for(let u=0;u{nzn=1/Math.PI*180,izn=1/180*Math.PI,wYt={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...wYt}};jh=globalThis.mathgl.config});var XD,y4e=Ve(()=>{qD();XD=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(n,r=0){for(let c=0;c0?", ":"")+_4e(this[c],n);return`${n.printTypes?this.constructor.name:""}[${r}]`}equals(n){if(!n||this.length!==n.length)return!1;for(let r=0;r{qD()});function x4e(s,n){if(!s)throw new Error(`math.gl assertion ${n}`)}var bpt=Ve(()=>{});var Wce,wpt=Ve(()=>{y4e();D$();bpt();Wce=class extends XD{get x(){return this[0]}set x(n){this[0]=cp(n)}get y(){return this[1]}set y(n){this[1]=cp(n)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let n=0;for(let r=0;r=0&&n=0&&n=0?Math.round(s):s%.5===0?Math.floor(s):Math.round(s)}var Cc,Hy,pzn,f4=Ve(()=>{Cc=typeof Float32Array<"u"?Float32Array:Array,Hy=Math.random;pzn=Math.PI/180});var ag={};Oy(ag,{add:()=>CYt,angle:()=>HYt,ceil:()=>AYt,clone:()=>EYt,copy:()=>MYt,create:()=>vpt,cross:()=>UYt,dist:()=>tZt,distance:()=>Ept,div:()=>eZt,divide:()=>xpt,dot:()=>FYt,equals:()=>ZYt,exactEquals:()=>YYt,floor:()=>PYt,forEach:()=>rZt,fromValues:()=>SYt,inverse:()=>OYt,len:()=>KYt,length:()=>Mpt,lerp:()=>zYt,max:()=>kYt,min:()=>LYt,mul:()=>QYt,multiply:()=>ypt,negate:()=>BYt,normalize:()=>NYt,random:()=>GYt,rotate:()=>WYt,round:()=>RYt,scale:()=>IYt,scaleAndAdd:()=>DYt,set:()=>TYt,sqrDist:()=>nZt,sqrLen:()=>iZt,squaredDistance:()=>Spt,squaredLength:()=>Tpt,str:()=>XYt,sub:()=>JYt,subtract:()=>_pt,transformMat2:()=>jYt,transformMat2d:()=>$Yt,transformMat3:()=>VYt,transformMat4:()=>E4e,zero:()=>qYt});function vpt(){let s=new Cc(2);return Cc!=Float32Array&&(s[0]=0,s[1]=0),s}function EYt(s){let n=new Cc(2);return n[0]=s[0],n[1]=s[1],n}function SYt(s,n){let r=new Cc(2);return r[0]=s,r[1]=n,r}function MYt(s,n){return s[0]=n[0],s[1]=n[1],s}function TYt(s,n,r){return s[0]=n,s[1]=r,s}function CYt(s,n,r){return s[0]=n[0]+r[0],s[1]=n[1]+r[1],s}function _pt(s,n,r){return s[0]=n[0]-r[0],s[1]=n[1]-r[1],s}function ypt(s,n,r){return s[0]=n[0]*r[0],s[1]=n[1]*r[1],s}function xpt(s,n,r){return s[0]=n[0]/r[0],s[1]=n[1]/r[1],s}function AYt(s,n){return s[0]=Math.ceil(n[0]),s[1]=Math.ceil(n[1]),s}function PYt(s,n){return s[0]=Math.floor(n[0]),s[1]=Math.floor(n[1]),s}function LYt(s,n,r){return s[0]=Math.min(n[0],r[0]),s[1]=Math.min(n[1],r[1]),s}function kYt(s,n,r){return s[0]=Math.max(n[0],r[0]),s[1]=Math.max(n[1],r[1]),s}function RYt(s,n){return s[0]=Cb(n[0]),s[1]=Cb(n[1]),s}function IYt(s,n,r){return s[0]=n[0]*r,s[1]=n[1]*r,s}function DYt(s,n,r,c){return s[0]=n[0]+r[0]*c,s[1]=n[1]+r[1]*c,s}function Ept(s,n){let r=n[0]-s[0],c=n[1]-s[1];return Math.sqrt(r*r+c*c)}function Spt(s,n){let r=n[0]-s[0],c=n[1]-s[1];return r*r+c*c}function Mpt(s){let n=s[0],r=s[1];return Math.sqrt(n*n+r*r)}function Tpt(s){let n=s[0],r=s[1];return n*n+r*r}function BYt(s,n){return s[0]=-n[0],s[1]=-n[1],s}function OYt(s,n){return s[0]=1/n[0],s[1]=1/n[1],s}function NYt(s,n){let r=n[0],c=n[1],u=r*r+c*c;return u>0&&(u=1/Math.sqrt(u)),s[0]=n[0]*u,s[1]=n[1]*u,s}function FYt(s,n){return s[0]*n[0]+s[1]*n[1]}function UYt(s,n,r){let c=n[0]*r[1]-n[1]*r[0];return s[0]=s[1]=0,s[2]=c,s}function zYt(s,n,r,c){let u=n[0],d=n[1];return s[0]=u+c*(r[0]-u),s[1]=d+c*(r[1]-d),s}function GYt(s,n){n=n===void 0?1:n;let r=Hy()*2*Math.PI;return s[0]=Math.cos(r)*n,s[1]=Math.sin(r)*n,s}function jYt(s,n,r){let c=n[0],u=n[1];return s[0]=r[0]*c+r[2]*u,s[1]=r[1]*c+r[3]*u,s}function $Yt(s,n,r){let c=n[0],u=n[1];return s[0]=r[0]*c+r[2]*u+r[4],s[1]=r[1]*c+r[3]*u+r[5],s}function VYt(s,n,r){let c=n[0],u=n[1];return s[0]=r[0]*c+r[3]*u+r[6],s[1]=r[1]*c+r[4]*u+r[7],s}function E4e(s,n,r){let c=n[0],u=n[1];return s[0]=r[0]*c+r[4]*u+r[12],s[1]=r[1]*c+r[5]*u+r[13],s}function WYt(s,n,r,c){let u=n[0]-r[0],d=n[1]-r[1],b=Math.sin(c),w=Math.cos(c);return s[0]=u*w-d*b+r[0],s[1]=u*b+d*w+r[1],s}function HYt(s,n){let r=s[0],c=s[1],u=n[0],d=n[1],b=Math.sqrt((r*r+c*c)*(u*u+d*d)),w=b&&(r*u+c*d)/b;return Math.acos(Math.min(Math.max(w,-1),1))}function qYt(s){return s[0]=0,s[1]=0,s}function XYt(s){return`vec2(${s[0]}, ${s[1]})`}function YYt(s,n){return s[0]===n[0]&&s[1]===n[1]}function ZYt(s,n){let r=s[0],c=s[1],u=n[0],d=n[1];return Math.abs(r-u)<=1e-6*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(c-d)<=1e-6*Math.max(1,Math.abs(c),Math.abs(d))}var KYt,JYt,QYt,eZt,tZt,nZt,iZt,rZt,S4e=Ve(()=>{f4();KYt=Mpt,JYt=_pt,QYt=ypt,eZt=xpt,tZt=Ept,nZt=Spt,iZt=Tpt,rZt=function(){let s=vpt();return function(n,r,c,u,d,b){let w,_;for(r||(r=2),c||(c=0),u?_=Math.min(u*r+c,n.length):_=n.length,w=c;w<_;w+=r)s[0]=n[w],s[1]=n[w+1],d(s,s,b),n[w]=s[0],n[w+1]=s[1];return n}}()});function Cpt(s,n,r){let c=n[0],u=n[1],d=r[3]*c+r[7]*u||1;return s[0]=(r[0]*c+r[4]*u)/d,s[1]=(r[1]*c+r[5]*u)/d,s}function Hce(s,n,r){let c=n[0],u=n[1],d=n[2],b=r[3]*c+r[7]*u+r[11]*d||1;return s[0]=(r[0]*c+r[4]*u+r[8]*d)/b,s[1]=(r[1]*c+r[5]*u+r[9]*d)/b,s[2]=(r[2]*c+r[6]*u+r[10]*d)/b,s}function Apt(s,n,r){let c=n[0],u=n[1];return s[0]=r[0]*c+r[2]*u,s[1]=r[1]*c+r[3]*u,s[2]=n[2],s}var M4e=Ve(()=>{});var wm={};Oy(wm,{add:()=>cZt,angle:()=>R4e,bezier:()=>yZt,ceil:()=>lZt,clone:()=>sZt,copy:()=>oZt,create:()=>qce,cross:()=>h4,dist:()=>LZt,distance:()=>Ipt,div:()=>PZt,divide:()=>Rpt,dot:()=>B$,equals:()=>TZt,exactEquals:()=>MZt,floor:()=>uZt,forEach:()=>IZt,fromValues:()=>Xce,hermite:()=>_Zt,inverse:()=>bZt,len:()=>I4e,length:()=>Ppt,lerp:()=>wZt,max:()=>hZt,min:()=>fZt,mul:()=>AZt,multiply:()=>kpt,negate:()=>mZt,normalize:()=>T4e,random:()=>xZt,rotateX:()=>P4e,rotateY:()=>L4e,rotateZ:()=>k4e,round:()=>dZt,scale:()=>pZt,scaleAndAdd:()=>gZt,set:()=>aZt,slerp:()=>vZt,sqrDist:()=>kZt,sqrLen:()=>RZt,squaredDistance:()=>Dpt,squaredLength:()=>Bpt,str:()=>SZt,sub:()=>CZt,subtract:()=>Lpt,transformMat3:()=>C4e,transformMat4:()=>O$,transformQuat:()=>A4e,zero:()=>EZt});function qce(){let s=new Cc(3);return Cc!=Float32Array&&(s[0]=0,s[1]=0,s[2]=0),s}function sZt(s){let n=new Cc(3);return n[0]=s[0],n[1]=s[1],n[2]=s[2],n}function Ppt(s){let n=s[0],r=s[1],c=s[2];return Math.sqrt(n*n+r*r+c*c)}function Xce(s,n,r){let c=new Cc(3);return c[0]=s,c[1]=n,c[2]=r,c}function oZt(s,n){return s[0]=n[0],s[1]=n[1],s[2]=n[2],s}function aZt(s,n,r,c){return s[0]=n,s[1]=r,s[2]=c,s}function cZt(s,n,r){return s[0]=n[0]+r[0],s[1]=n[1]+r[1],s[2]=n[2]+r[2],s}function Lpt(s,n,r){return s[0]=n[0]-r[0],s[1]=n[1]-r[1],s[2]=n[2]-r[2],s}function kpt(s,n,r){return s[0]=n[0]*r[0],s[1]=n[1]*r[1],s[2]=n[2]*r[2],s}function Rpt(s,n,r){return s[0]=n[0]/r[0],s[1]=n[1]/r[1],s[2]=n[2]/r[2],s}function lZt(s,n){return s[0]=Math.ceil(n[0]),s[1]=Math.ceil(n[1]),s[2]=Math.ceil(n[2]),s}function uZt(s,n){return s[0]=Math.floor(n[0]),s[1]=Math.floor(n[1]),s[2]=Math.floor(n[2]),s}function fZt(s,n,r){return s[0]=Math.min(n[0],r[0]),s[1]=Math.min(n[1],r[1]),s[2]=Math.min(n[2],r[2]),s}function hZt(s,n,r){return s[0]=Math.max(n[0],r[0]),s[1]=Math.max(n[1],r[1]),s[2]=Math.max(n[2],r[2]),s}function dZt(s,n){return s[0]=Cb(n[0]),s[1]=Cb(n[1]),s[2]=Cb(n[2]),s}function pZt(s,n,r){return s[0]=n[0]*r,s[1]=n[1]*r,s[2]=n[2]*r,s}function gZt(s,n,r,c){return s[0]=n[0]+r[0]*c,s[1]=n[1]+r[1]*c,s[2]=n[2]+r[2]*c,s}function Ipt(s,n){let r=n[0]-s[0],c=n[1]-s[1],u=n[2]-s[2];return Math.sqrt(r*r+c*c+u*u)}function Dpt(s,n){let r=n[0]-s[0],c=n[1]-s[1],u=n[2]-s[2];return r*r+c*c+u*u}function Bpt(s){let n=s[0],r=s[1],c=s[2];return n*n+r*r+c*c}function mZt(s,n){return s[0]=-n[0],s[1]=-n[1],s[2]=-n[2],s}function bZt(s,n){return s[0]=1/n[0],s[1]=1/n[1],s[2]=1/n[2],s}function T4e(s,n){let r=n[0],c=n[1],u=n[2],d=r*r+c*c+u*u;return d>0&&(d=1/Math.sqrt(d)),s[0]=n[0]*d,s[1]=n[1]*d,s[2]=n[2]*d,s}function B$(s,n){return s[0]*n[0]+s[1]*n[1]+s[2]*n[2]}function h4(s,n,r){let c=n[0],u=n[1],d=n[2],b=r[0],w=r[1],_=r[2];return s[0]=u*_-d*w,s[1]=d*b-c*_,s[2]=c*w-u*b,s}function wZt(s,n,r,c){let u=n[0],d=n[1],b=n[2];return s[0]=u+c*(r[0]-u),s[1]=d+c*(r[1]-d),s[2]=b+c*(r[2]-b),s}function vZt(s,n,r,c){let u=Math.acos(Math.min(Math.max(B$(n,r),-1),1)),d=Math.sin(u),b=Math.sin((1-c)*u)/d,w=Math.sin(c*u)/d;return s[0]=b*n[0]+w*r[0],s[1]=b*n[1]+w*r[1],s[2]=b*n[2]+w*r[2],s}function _Zt(s,n,r,c,u,d){let b=d*d,w=b*(2*d-3)+1,_=b*(d-2)+d,x=b*(d-1),T=b*(3-2*d);return s[0]=n[0]*w+r[0]*_+c[0]*x+u[0]*T,s[1]=n[1]*w+r[1]*_+c[1]*x+u[1]*T,s[2]=n[2]*w+r[2]*_+c[2]*x+u[2]*T,s}function yZt(s,n,r,c,u,d){let b=1-d,w=b*b,_=d*d,x=w*b,T=3*d*w,M=3*_*b,L=_*d;return s[0]=n[0]*x+r[0]*T+c[0]*M+u[0]*L,s[1]=n[1]*x+r[1]*T+c[1]*M+u[1]*L,s[2]=n[2]*x+r[2]*T+c[2]*M+u[2]*L,s}function xZt(s,n){n=n===void 0?1:n;let r=Hy()*2*Math.PI,c=Hy()*2-1,u=Math.sqrt(1-c*c)*n;return s[0]=Math.cos(r)*u,s[1]=Math.sin(r)*u,s[2]=c*n,s}function O$(s,n,r){let c=n[0],u=n[1],d=n[2],b=r[3]*c+r[7]*u+r[11]*d+r[15];return b=b||1,s[0]=(r[0]*c+r[4]*u+r[8]*d+r[12])/b,s[1]=(r[1]*c+r[5]*u+r[9]*d+r[13])/b,s[2]=(r[2]*c+r[6]*u+r[10]*d+r[14])/b,s}function C4e(s,n,r){let c=n[0],u=n[1],d=n[2];return s[0]=c*r[0]+u*r[3]+d*r[6],s[1]=c*r[1]+u*r[4]+d*r[7],s[2]=c*r[2]+u*r[5]+d*r[8],s}function A4e(s,n,r){let c=r[0],u=r[1],d=r[2],b=r[3],w=n[0],_=n[1],x=n[2],T=u*x-d*_,M=d*w-c*x,L=c*_-u*w,I=u*L-d*M,D=d*T-c*L,F=c*M-u*T,O=b*2;return T*=O,M*=O,L*=O,I*=2,D*=2,F*=2,s[0]=w+T+I,s[1]=_+M+D,s[2]=x+L+F,s}function P4e(s,n,r,c){let u=[],d=[];return u[0]=n[0]-r[0],u[1]=n[1]-r[1],u[2]=n[2]-r[2],d[0]=u[0],d[1]=u[1]*Math.cos(c)-u[2]*Math.sin(c),d[2]=u[1]*Math.sin(c)+u[2]*Math.cos(c),s[0]=d[0]+r[0],s[1]=d[1]+r[1],s[2]=d[2]+r[2],s}function L4e(s,n,r,c){let u=[],d=[];return u[0]=n[0]-r[0],u[1]=n[1]-r[1],u[2]=n[2]-r[2],d[0]=u[2]*Math.sin(c)+u[0]*Math.cos(c),d[1]=u[1],d[2]=u[2]*Math.cos(c)-u[0]*Math.sin(c),s[0]=d[0]+r[0],s[1]=d[1]+r[1],s[2]=d[2]+r[2],s}function k4e(s,n,r,c){let u=[],d=[];return u[0]=n[0]-r[0],u[1]=n[1]-r[1],u[2]=n[2]-r[2],d[0]=u[0]*Math.cos(c)-u[1]*Math.sin(c),d[1]=u[0]*Math.sin(c)+u[1]*Math.cos(c),d[2]=u[2],s[0]=d[0]+r[0],s[1]=d[1]+r[1],s[2]=d[2]+r[2],s}function R4e(s,n){let r=s[0],c=s[1],u=s[2],d=n[0],b=n[1],w=n[2],_=Math.sqrt((r*r+c*c+u*u)*(d*d+b*b+w*w)),x=_&&B$(s,n)/_;return Math.acos(Math.min(Math.max(x,-1),1))}function EZt(s){return s[0]=0,s[1]=0,s[2]=0,s}function SZt(s){return`vec3(${s[0]}, ${s[1]}, ${s[2]})`}function MZt(s,n){return s[0]===n[0]&&s[1]===n[1]&&s[2]===n[2]}function TZt(s,n){let r=s[0],c=s[1],u=s[2],d=n[0],b=n[1],w=n[2];return Math.abs(r-d)<=1e-6*Math.max(1,Math.abs(r),Math.abs(d))&&Math.abs(c-b)<=1e-6*Math.max(1,Math.abs(c),Math.abs(b))&&Math.abs(u-w)<=1e-6*Math.max(1,Math.abs(u),Math.abs(w))}var CZt,AZt,PZt,LZt,kZt,I4e,RZt,IZt,N$=Ve(()=>{f4();CZt=Lpt,AZt=kpt,PZt=Rpt,LZt=Ipt,kZt=Dpt,I4e=Ppt,RZt=Bpt,IZt=function(){let s=qce();return function(n,r,c,u,d,b){let w,_;for(r||(r=3),c||(c=0),u?_=Math.min(u*r+c,n.length):_=n.length,w=c;w<_;w+=r)s[0]=n[w],s[1]=n[w+1],s[2]=n[w+2],d(s,s,b),n[w]=s[0],n[w+1]=s[1],n[w+2]=s[2];return n}}()});var D4e,Yce,lp,Opt=Ve(()=>{wpt();qD();D$();N$();M4e();D4e=[0,0,0],lp=class s extends Wce{static get ZERO(){return Yce||(Yce=new s(0,0,0),Object.freeze(Yce)),Yce}constructor(n=0,r=0,c=0){super(-0,-0,-0),arguments.length===1&&P3(n)?this.copy(n):(jh.debug&&(cp(n),cp(r),cp(c)),this[0]=n,this[1]=r,this[2]=c)}set(n,r,c){return this[0]=n,this[1]=r,this[2]=c,this.check()}copy(n){return this[0]=n[0],this[1]=n[1],this[2]=n[2],this.check()}fromObject(n){return jh.debug&&(cp(n.x),cp(n.y),cp(n.z)),this[0]=n.x,this[1]=n.y,this[2]=n.z,this.check()}toObject(n){return n.x=this[0],n.y=this[1],n.z=this[2],n}get ELEMENTS(){return 3}get z(){return this[2]}set z(n){this[2]=cp(n)}angle(n){return R4e(this,n)}cross(n){return h4(this,this,n),this.check()}rotateX({radians:n,origin:r=D4e}){return P4e(this,this,r,n),this.check()}rotateY({radians:n,origin:r=D4e}){return L4e(this,this,r,n),this.check()}rotateZ({radians:n,origin:r=D4e}){return k4e(this,this,r,n),this.check()}transform(n){return this.transformAsPoint(n)}transformAsPoint(n){return O$(this,this,n),this.check()}transformAsVector(n){return Hce(this,this,n),this.check()}transformByMatrix3(n){return C4e(this,this,n),this.check()}transformByMatrix2(n){return Apt(this,this,n),this.check()}transformByQuaternion(n){return A4e(this,this,n),this.check()}}});var Zce,Npt=Ve(()=>{y4e();D$();qD();Zce=class extends XD{toString(){let n="[";if(jh.printRowMajor){n+="row-major:";for(let r=0;r{f4()});var hh={};Oy(hh,{add:()=>rKt,adjoint:()=>UZt,clone:()=>BZt,copy:()=>OZt,create:()=>DZt,decompose:()=>YZt,determinant:()=>F4e,equals:()=>cKt,exactEquals:()=>aKt,frob:()=>iKt,fromQuat:()=>W4e,fromQuat2:()=>HZt,fromRotation:()=>jZt,fromRotationTranslation:()=>Gpt,fromRotationTranslationScale:()=>ZZt,fromRotationTranslationScaleOrigin:()=>KZt,fromScaling:()=>GZt,fromTranslation:()=>zZt,fromValues:()=>NZt,fromXRotation:()=>$Zt,fromYRotation:()=>VZt,fromZRotation:()=>WZt,frustum:()=>H4e,getRotation:()=>XZt,getScaling:()=>jpt,getTranslation:()=>qZt,identity:()=>zpt,invert:()=>N4e,lookAt:()=>Y4e,mul:()=>lKt,multiply:()=>F$,multiplyScalar:()=>sKt,multiplyScalarAndAdd:()=>oKt,ortho:()=>X4e,orthoNO:()=>Vpt,orthoZO:()=>eKt,perspective:()=>q4e,perspectiveFromFieldOfView:()=>QZt,perspectiveNO:()=>$pt,perspectiveZO:()=>JZt,rotate:()=>G4e,rotateX:()=>j4e,rotateY:()=>$4e,rotateZ:()=>V4e,scale:()=>z4e,set:()=>FZt,str:()=>nKt,sub:()=>uKt,subtract:()=>Wpt,targetTo:()=>tKt,translate:()=>U4e,transpose:()=>O4e});function DZt(){let s=new Cc(16);return Cc!=Float32Array&&(s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[11]=0,s[12]=0,s[13]=0,s[14]=0),s[0]=1,s[5]=1,s[10]=1,s[15]=1,s}function BZt(s){let n=new Cc(16);return n[0]=s[0],n[1]=s[1],n[2]=s[2],n[3]=s[3],n[4]=s[4],n[5]=s[5],n[6]=s[6],n[7]=s[7],n[8]=s[8],n[9]=s[9],n[10]=s[10],n[11]=s[11],n[12]=s[12],n[13]=s[13],n[14]=s[14],n[15]=s[15],n}function OZt(s,n){return s[0]=n[0],s[1]=n[1],s[2]=n[2],s[3]=n[3],s[4]=n[4],s[5]=n[5],s[6]=n[6],s[7]=n[7],s[8]=n[8],s[9]=n[9],s[10]=n[10],s[11]=n[11],s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15],s}function NZt(s,n,r,c,u,d,b,w,_,x,T,M,L,I,D,F){let O=new Cc(16);return O[0]=s,O[1]=n,O[2]=r,O[3]=c,O[4]=u,O[5]=d,O[6]=b,O[7]=w,O[8]=_,O[9]=x,O[10]=T,O[11]=M,O[12]=L,O[13]=I,O[14]=D,O[15]=F,O}function FZt(s,n,r,c,u,d,b,w,_,x,T,M,L,I,D,F,O){return s[0]=n,s[1]=r,s[2]=c,s[3]=u,s[4]=d,s[5]=b,s[6]=w,s[7]=_,s[8]=x,s[9]=T,s[10]=M,s[11]=L,s[12]=I,s[13]=D,s[14]=F,s[15]=O,s}function zpt(s){return s[0]=1,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=1,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=1,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function O4e(s,n){if(s===n){let r=n[1],c=n[2],u=n[3],d=n[6],b=n[7],w=n[11];s[1]=n[4],s[2]=n[8],s[3]=n[12],s[4]=r,s[6]=n[9],s[7]=n[13],s[8]=c,s[9]=d,s[11]=n[14],s[12]=u,s[13]=b,s[14]=w}else s[0]=n[0],s[1]=n[4],s[2]=n[8],s[3]=n[12],s[4]=n[1],s[5]=n[5],s[6]=n[9],s[7]=n[13],s[8]=n[2],s[9]=n[6],s[10]=n[10],s[11]=n[14],s[12]=n[3],s[13]=n[7],s[14]=n[11],s[15]=n[15];return s}function N4e(s,n){let r=n[0],c=n[1],u=n[2],d=n[3],b=n[4],w=n[5],_=n[6],x=n[7],T=n[8],M=n[9],L=n[10],I=n[11],D=n[12],F=n[13],O=n[14],z=n[15],Z=r*w-c*b,H=r*_-u*b,te=r*x-d*b,oe=c*_-u*w,ne=c*x-d*w,ue=u*x-d*_,Te=T*F-M*D,Q=T*O-L*D,ge=T*z-I*D,Qe=M*O-L*F,st=M*z-I*F,at=L*z-I*O,Ne=Z*at-H*st+te*Qe+oe*ge-ne*Q+ue*Te;return Ne?(Ne=1/Ne,s[0]=(w*at-_*st+x*Qe)*Ne,s[1]=(u*st-c*at-d*Qe)*Ne,s[2]=(F*ue-O*ne+z*oe)*Ne,s[3]=(L*ne-M*ue-I*oe)*Ne,s[4]=(_*ge-b*at-x*Q)*Ne,s[5]=(r*at-u*ge+d*Q)*Ne,s[6]=(O*te-D*ue-z*H)*Ne,s[7]=(T*ue-L*te+I*H)*Ne,s[8]=(b*st-w*ge+x*Te)*Ne,s[9]=(c*ge-r*st-d*Te)*Ne,s[10]=(D*ne-F*te+z*Z)*Ne,s[11]=(M*te-T*ne-I*Z)*Ne,s[12]=(w*Q-b*Qe-_*Te)*Ne,s[13]=(r*Qe-c*Q+u*Te)*Ne,s[14]=(F*H-D*oe-O*Z)*Ne,s[15]=(T*oe-M*H+L*Z)*Ne,s):null}function UZt(s,n){let r=n[0],c=n[1],u=n[2],d=n[3],b=n[4],w=n[5],_=n[6],x=n[7],T=n[8],M=n[9],L=n[10],I=n[11],D=n[12],F=n[13],O=n[14],z=n[15],Z=r*w-c*b,H=r*_-u*b,te=r*x-d*b,oe=c*_-u*w,ne=c*x-d*w,ue=u*x-d*_,Te=T*F-M*D,Q=T*O-L*D,ge=T*z-I*D,Qe=M*O-L*F,st=M*z-I*F,at=L*z-I*O;return s[0]=w*at-_*st+x*Qe,s[1]=u*st-c*at-d*Qe,s[2]=F*ue-O*ne+z*oe,s[3]=L*ne-M*ue-I*oe,s[4]=_*ge-b*at-x*Q,s[5]=r*at-u*ge+d*Q,s[6]=O*te-D*ue-z*H,s[7]=T*ue-L*te+I*H,s[8]=b*st-w*ge+x*Te,s[9]=c*ge-r*st-d*Te,s[10]=D*ne-F*te+z*Z,s[11]=M*te-T*ne-I*Z,s[12]=w*Q-b*Qe-_*Te,s[13]=r*Qe-c*Q+u*Te,s[14]=F*H-D*oe-O*Z,s[15]=T*oe-M*H+L*Z,s}function F4e(s){let n=s[0],r=s[1],c=s[2],u=s[3],d=s[4],b=s[5],w=s[6],_=s[7],x=s[8],T=s[9],M=s[10],L=s[11],I=s[12],D=s[13],F=s[14],O=s[15],z=n*b-r*d,Z=n*w-c*d,H=r*w-c*b,te=x*D-T*I,oe=x*F-M*I,ne=T*F-M*D,ue=n*ne-r*oe+c*te,Te=d*ne-b*oe+w*te,Q=x*H-T*Z+M*z,ge=I*H-D*Z+F*z;return _*ue-u*Te+O*Q-L*ge}function F$(s,n,r){let c=n[0],u=n[1],d=n[2],b=n[3],w=n[4],_=n[5],x=n[6],T=n[7],M=n[8],L=n[9],I=n[10],D=n[11],F=n[12],O=n[13],z=n[14],Z=n[15],H=r[0],te=r[1],oe=r[2],ne=r[3];return s[0]=H*c+te*w+oe*M+ne*F,s[1]=H*u+te*_+oe*L+ne*O,s[2]=H*d+te*x+oe*I+ne*z,s[3]=H*b+te*T+oe*D+ne*Z,H=r[4],te=r[5],oe=r[6],ne=r[7],s[4]=H*c+te*w+oe*M+ne*F,s[5]=H*u+te*_+oe*L+ne*O,s[6]=H*d+te*x+oe*I+ne*z,s[7]=H*b+te*T+oe*D+ne*Z,H=r[8],te=r[9],oe=r[10],ne=r[11],s[8]=H*c+te*w+oe*M+ne*F,s[9]=H*u+te*_+oe*L+ne*O,s[10]=H*d+te*x+oe*I+ne*z,s[11]=H*b+te*T+oe*D+ne*Z,H=r[12],te=r[13],oe=r[14],ne=r[15],s[12]=H*c+te*w+oe*M+ne*F,s[13]=H*u+te*_+oe*L+ne*O,s[14]=H*d+te*x+oe*I+ne*z,s[15]=H*b+te*T+oe*D+ne*Z,s}function U4e(s,n,r){let c=r[0],u=r[1],d=r[2],b,w,_,x,T,M,L,I,D,F,O,z;return n===s?(s[12]=n[0]*c+n[4]*u+n[8]*d+n[12],s[13]=n[1]*c+n[5]*u+n[9]*d+n[13],s[14]=n[2]*c+n[6]*u+n[10]*d+n[14],s[15]=n[3]*c+n[7]*u+n[11]*d+n[15]):(b=n[0],w=n[1],_=n[2],x=n[3],T=n[4],M=n[5],L=n[6],I=n[7],D=n[8],F=n[9],O=n[10],z=n[11],s[0]=b,s[1]=w,s[2]=_,s[3]=x,s[4]=T,s[5]=M,s[6]=L,s[7]=I,s[8]=D,s[9]=F,s[10]=O,s[11]=z,s[12]=b*c+T*u+D*d+n[12],s[13]=w*c+M*u+F*d+n[13],s[14]=_*c+L*u+O*d+n[14],s[15]=x*c+I*u+z*d+n[15]),s}function z4e(s,n,r){let c=r[0],u=r[1],d=r[2];return s[0]=n[0]*c,s[1]=n[1]*c,s[2]=n[2]*c,s[3]=n[3]*c,s[4]=n[4]*u,s[5]=n[5]*u,s[6]=n[6]*u,s[7]=n[7]*u,s[8]=n[8]*d,s[9]=n[9]*d,s[10]=n[10]*d,s[11]=n[11]*d,s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15],s}function G4e(s,n,r,c){let u=c[0],d=c[1],b=c[2],w=Math.sqrt(u*u+d*d+b*b),_,x,T,M,L,I,D,F,O,z,Z,H,te,oe,ne,ue,Te,Q,ge,Qe,st,at,Ne,tt;return w<1e-6?null:(w=1/w,u*=w,d*=w,b*=w,x=Math.sin(r),_=Math.cos(r),T=1-_,M=n[0],L=n[1],I=n[2],D=n[3],F=n[4],O=n[5],z=n[6],Z=n[7],H=n[8],te=n[9],oe=n[10],ne=n[11],ue=u*u*T+_,Te=d*u*T+b*x,Q=b*u*T-d*x,ge=u*d*T-b*x,Qe=d*d*T+_,st=b*d*T+u*x,at=u*b*T+d*x,Ne=d*b*T-u*x,tt=b*b*T+_,s[0]=M*ue+F*Te+H*Q,s[1]=L*ue+O*Te+te*Q,s[2]=I*ue+z*Te+oe*Q,s[3]=D*ue+Z*Te+ne*Q,s[4]=M*ge+F*Qe+H*st,s[5]=L*ge+O*Qe+te*st,s[6]=I*ge+z*Qe+oe*st,s[7]=D*ge+Z*Qe+ne*st,s[8]=M*at+F*Ne+H*tt,s[9]=L*at+O*Ne+te*tt,s[10]=I*at+z*Ne+oe*tt,s[11]=D*at+Z*Ne+ne*tt,n!==s&&(s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15]),s)}function j4e(s,n,r){let c=Math.sin(r),u=Math.cos(r),d=n[4],b=n[5],w=n[6],_=n[7],x=n[8],T=n[9],M=n[10],L=n[11];return n!==s&&(s[0]=n[0],s[1]=n[1],s[2]=n[2],s[3]=n[3],s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15]),s[4]=d*u+x*c,s[5]=b*u+T*c,s[6]=w*u+M*c,s[7]=_*u+L*c,s[8]=x*u-d*c,s[9]=T*u-b*c,s[10]=M*u-w*c,s[11]=L*u-_*c,s}function $4e(s,n,r){let c=Math.sin(r),u=Math.cos(r),d=n[0],b=n[1],w=n[2],_=n[3],x=n[8],T=n[9],M=n[10],L=n[11];return n!==s&&(s[4]=n[4],s[5]=n[5],s[6]=n[6],s[7]=n[7],s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15]),s[0]=d*u-x*c,s[1]=b*u-T*c,s[2]=w*u-M*c,s[3]=_*u-L*c,s[8]=d*c+x*u,s[9]=b*c+T*u,s[10]=w*c+M*u,s[11]=_*c+L*u,s}function V4e(s,n,r){let c=Math.sin(r),u=Math.cos(r),d=n[0],b=n[1],w=n[2],_=n[3],x=n[4],T=n[5],M=n[6],L=n[7];return n!==s&&(s[8]=n[8],s[9]=n[9],s[10]=n[10],s[11]=n[11],s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15]),s[0]=d*u+x*c,s[1]=b*u+T*c,s[2]=w*u+M*c,s[3]=_*u+L*c,s[4]=x*u-d*c,s[5]=T*u-b*c,s[6]=M*u-w*c,s[7]=L*u-_*c,s}function zZt(s,n){return s[0]=1,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=1,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=1,s[11]=0,s[12]=n[0],s[13]=n[1],s[14]=n[2],s[15]=1,s}function GZt(s,n){return s[0]=n[0],s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=n[1],s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=n[2],s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function jZt(s,n,r){let c=r[0],u=r[1],d=r[2],b=Math.sqrt(c*c+u*u+d*d),w,_,x;return b<1e-6?null:(b=1/b,c*=b,u*=b,d*=b,_=Math.sin(n),w=Math.cos(n),x=1-w,s[0]=c*c*x+w,s[1]=u*c*x+d*_,s[2]=d*c*x-u*_,s[3]=0,s[4]=c*u*x-d*_,s[5]=u*u*x+w,s[6]=d*u*x+c*_,s[7]=0,s[8]=c*d*x+u*_,s[9]=u*d*x-c*_,s[10]=d*d*x+w,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s)}function $Zt(s,n){let r=Math.sin(n),c=Math.cos(n);return s[0]=1,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=c,s[6]=r,s[7]=0,s[8]=0,s[9]=-r,s[10]=c,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function VZt(s,n){let r=Math.sin(n),c=Math.cos(n);return s[0]=c,s[1]=0,s[2]=-r,s[3]=0,s[4]=0,s[5]=1,s[6]=0,s[7]=0,s[8]=r,s[9]=0,s[10]=c,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function WZt(s,n){let r=Math.sin(n),c=Math.cos(n);return s[0]=c,s[1]=r,s[2]=0,s[3]=0,s[4]=-r,s[5]=c,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=1,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function Gpt(s,n,r){let c=n[0],u=n[1],d=n[2],b=n[3],w=c+c,_=u+u,x=d+d,T=c*w,M=c*_,L=c*x,I=u*_,D=u*x,F=d*x,O=b*w,z=b*_,Z=b*x;return s[0]=1-(I+F),s[1]=M+Z,s[2]=L-z,s[3]=0,s[4]=M-Z,s[5]=1-(T+F),s[6]=D+O,s[7]=0,s[8]=L+z,s[9]=D-O,s[10]=1-(T+I),s[11]=0,s[12]=r[0],s[13]=r[1],s[14]=r[2],s[15]=1,s}function HZt(s,n){let r=new Cc(3),c=-n[0],u=-n[1],d=-n[2],b=n[3],w=n[4],_=n[5],x=n[6],T=n[7],M=c*c+u*u+d*d+b*b;return M>0?(r[0]=(w*b+T*c+_*d-x*u)*2/M,r[1]=(_*b+T*u+x*c-w*d)*2/M,r[2]=(x*b+T*d+w*u-_*c)*2/M):(r[0]=(w*b+T*c+_*d-x*u)*2,r[1]=(_*b+T*u+x*c-w*d)*2,r[2]=(x*b+T*d+w*u-_*c)*2),Gpt(s,n,r),s}function qZt(s,n){return s[0]=n[12],s[1]=n[13],s[2]=n[14],s}function jpt(s,n){let r=n[0],c=n[1],u=n[2],d=n[4],b=n[5],w=n[6],_=n[8],x=n[9],T=n[10];return s[0]=Math.sqrt(r*r+c*c+u*u),s[1]=Math.sqrt(d*d+b*b+w*w),s[2]=Math.sqrt(_*_+x*x+T*T),s}function XZt(s,n){let r=new Cc(3);jpt(r,n);let c=1/r[0],u=1/r[1],d=1/r[2],b=n[0]*c,w=n[1]*u,_=n[2]*d,x=n[4]*c,T=n[5]*u,M=n[6]*d,L=n[8]*c,I=n[9]*u,D=n[10]*d,F=b+T+D,O=0;return F>0?(O=Math.sqrt(F+1)*2,s[3]=.25*O,s[0]=(M-I)/O,s[1]=(L-_)/O,s[2]=(w-x)/O):b>T&&b>D?(O=Math.sqrt(1+b-T-D)*2,s[3]=(M-I)/O,s[0]=.25*O,s[1]=(w+x)/O,s[2]=(L+_)/O):T>D?(O=Math.sqrt(1+T-b-D)*2,s[3]=(L-_)/O,s[0]=(w+x)/O,s[1]=.25*O,s[2]=(M+I)/O):(O=Math.sqrt(1+D-b-T)*2,s[3]=(w-x)/O,s[0]=(L+_)/O,s[1]=(M+I)/O,s[2]=.25*O),s}function YZt(s,n,r,c){n[0]=c[12],n[1]=c[13],n[2]=c[14];let u=c[0],d=c[1],b=c[2],w=c[4],_=c[5],x=c[6],T=c[8],M=c[9],L=c[10];r[0]=Math.sqrt(u*u+d*d+b*b),r[1]=Math.sqrt(w*w+_*_+x*x),r[2]=Math.sqrt(T*T+M*M+L*L);let I=1/r[0],D=1/r[1],F=1/r[2],O=u*I,z=d*D,Z=b*F,H=w*I,te=_*D,oe=x*F,ne=T*I,ue=M*D,Te=L*F,Q=O+te+Te,ge=0;return Q>0?(ge=Math.sqrt(Q+1)*2,s[3]=.25*ge,s[0]=(oe-ue)/ge,s[1]=(ne-Z)/ge,s[2]=(z-H)/ge):O>te&&O>Te?(ge=Math.sqrt(1+O-te-Te)*2,s[3]=(oe-ue)/ge,s[0]=.25*ge,s[1]=(z+H)/ge,s[2]=(ne+Z)/ge):te>Te?(ge=Math.sqrt(1+te-O-Te)*2,s[3]=(ne-Z)/ge,s[0]=(z+H)/ge,s[1]=.25*ge,s[2]=(oe+ue)/ge):(ge=Math.sqrt(1+Te-O-te)*2,s[3]=(z-H)/ge,s[0]=(ne+Z)/ge,s[1]=(oe+ue)/ge,s[2]=.25*ge),s}function ZZt(s,n,r,c){let u=n[0],d=n[1],b=n[2],w=n[3],_=u+u,x=d+d,T=b+b,M=u*_,L=u*x,I=u*T,D=d*x,F=d*T,O=b*T,z=w*_,Z=w*x,H=w*T,te=c[0],oe=c[1],ne=c[2];return s[0]=(1-(D+O))*te,s[1]=(L+H)*te,s[2]=(I-Z)*te,s[3]=0,s[4]=(L-H)*oe,s[5]=(1-(M+O))*oe,s[6]=(F+z)*oe,s[7]=0,s[8]=(I+Z)*ne,s[9]=(F-z)*ne,s[10]=(1-(M+D))*ne,s[11]=0,s[12]=r[0],s[13]=r[1],s[14]=r[2],s[15]=1,s}function KZt(s,n,r,c,u){let d=n[0],b=n[1],w=n[2],_=n[3],x=d+d,T=b+b,M=w+w,L=d*x,I=d*T,D=d*M,F=b*T,O=b*M,z=w*M,Z=_*x,H=_*T,te=_*M,oe=c[0],ne=c[1],ue=c[2],Te=u[0],Q=u[1],ge=u[2],Qe=(1-(F+z))*oe,st=(I+te)*oe,at=(D-H)*oe,Ne=(I-te)*ne,tt=(1-(L+z))*ne,ot=(O+Z)*ne,Tt=(D+H)*ue,jt=(O-Z)*ue,en=(1-(L+F))*ue;return s[0]=Qe,s[1]=st,s[2]=at,s[3]=0,s[4]=Ne,s[5]=tt,s[6]=ot,s[7]=0,s[8]=Tt,s[9]=jt,s[10]=en,s[11]=0,s[12]=r[0]+Te-(Qe*Te+Ne*Q+Tt*ge),s[13]=r[1]+Q-(st*Te+tt*Q+jt*ge),s[14]=r[2]+ge-(at*Te+ot*Q+en*ge),s[15]=1,s}function W4e(s,n){let r=n[0],c=n[1],u=n[2],d=n[3],b=r+r,w=c+c,_=u+u,x=r*b,T=c*b,M=c*w,L=u*b,I=u*w,D=u*_,F=d*b,O=d*w,z=d*_;return s[0]=1-M-D,s[1]=T+z,s[2]=L-O,s[3]=0,s[4]=T-z,s[5]=1-x-D,s[6]=I+F,s[7]=0,s[8]=L+O,s[9]=I-F,s[10]=1-x-M,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function H4e(s,n,r,c,u,d,b){let w=1/(r-n),_=1/(u-c),x=1/(d-b);return s[0]=d*2*w,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=d*2*_,s[6]=0,s[7]=0,s[8]=(r+n)*w,s[9]=(u+c)*_,s[10]=(b+d)*x,s[11]=-1,s[12]=0,s[13]=0,s[14]=b*d*2*x,s[15]=0,s}function $pt(s,n,r,c,u){let d=1/Math.tan(n/2);if(s[0]=d/r,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=d,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[11]=-1,s[12]=0,s[13]=0,s[15]=0,u!=null&&u!==1/0){let b=1/(c-u);s[10]=(u+c)*b,s[14]=2*u*c*b}else s[10]=-1,s[14]=-2*c;return s}function JZt(s,n,r,c,u){let d=1/Math.tan(n/2);if(s[0]=d/r,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=d,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[11]=-1,s[12]=0,s[13]=0,s[15]=0,u!=null&&u!==1/0){let b=1/(c-u);s[10]=u*b,s[14]=u*c*b}else s[10]=-1,s[14]=-c;return s}function QZt(s,n,r,c){let u=Math.tan(n.upDegrees*Math.PI/180),d=Math.tan(n.downDegrees*Math.PI/180),b=Math.tan(n.leftDegrees*Math.PI/180),w=Math.tan(n.rightDegrees*Math.PI/180),_=2/(b+w),x=2/(u+d);return s[0]=_,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=x,s[6]=0,s[7]=0,s[8]=-((b-w)*_*.5),s[9]=(u-d)*x*.5,s[10]=c/(r-c),s[11]=-1,s[12]=0,s[13]=0,s[14]=c*r/(r-c),s[15]=0,s}function Vpt(s,n,r,c,u,d,b){let w=1/(n-r),_=1/(c-u),x=1/(d-b);return s[0]=-2*w,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=-2*_,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=2*x,s[11]=0,s[12]=(n+r)*w,s[13]=(u+c)*_,s[14]=(b+d)*x,s[15]=1,s}function eKt(s,n,r,c,u,d,b){let w=1/(n-r),_=1/(c-u),x=1/(d-b);return s[0]=-2*w,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=-2*_,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=x,s[11]=0,s[12]=(n+r)*w,s[13]=(u+c)*_,s[14]=d*x,s[15]=1,s}function Y4e(s,n,r,c){let u,d,b,w,_,x,T,M,L,I,D=n[0],F=n[1],O=n[2],z=c[0],Z=c[1],H=c[2],te=r[0],oe=r[1],ne=r[2];return Math.abs(D-te)<1e-6&&Math.abs(F-oe)<1e-6&&Math.abs(O-ne)<1e-6?zpt(s):(M=D-te,L=F-oe,I=O-ne,u=1/Math.sqrt(M*M+L*L+I*I),M*=u,L*=u,I*=u,d=Z*I-H*L,b=H*M-z*I,w=z*L-Z*M,u=Math.sqrt(d*d+b*b+w*w),u?(u=1/u,d*=u,b*=u,w*=u):(d=0,b=0,w=0),_=L*w-I*b,x=I*d-M*w,T=M*b-L*d,u=Math.sqrt(_*_+x*x+T*T),u?(u=1/u,_*=u,x*=u,T*=u):(_=0,x=0,T=0),s[0]=d,s[1]=_,s[2]=M,s[3]=0,s[4]=b,s[5]=x,s[6]=L,s[7]=0,s[8]=w,s[9]=T,s[10]=I,s[11]=0,s[12]=-(d*D+b*F+w*O),s[13]=-(_*D+x*F+T*O),s[14]=-(M*D+L*F+I*O),s[15]=1,s)}function tKt(s,n,r,c){let u=n[0],d=n[1],b=n[2],w=c[0],_=c[1],x=c[2],T=u-r[0],M=d-r[1],L=b-r[2],I=T*T+M*M+L*L;I>0&&(I=1/Math.sqrt(I),T*=I,M*=I,L*=I);let D=_*L-x*M,F=x*T-w*L,O=w*M-_*T;return I=D*D+F*F+O*O,I>0&&(I=1/Math.sqrt(I),D*=I,F*=I,O*=I),s[0]=D,s[1]=F,s[2]=O,s[3]=0,s[4]=M*O-L*F,s[5]=L*D-T*O,s[6]=T*F-M*D,s[7]=0,s[8]=T,s[9]=M,s[10]=L,s[11]=0,s[12]=u,s[13]=d,s[14]=b,s[15]=1,s}function nKt(s){return`mat4(${s[0]}, ${s[1]}, ${s[2]}, ${s[3]}, ${s[4]}, ${s[5]}, ${s[6]}, ${s[7]}, ${s[8]}, ${s[9]}, ${s[10]}, ${s[11]}, ${s[12]}, ${s[13]}, ${s[14]}, ${s[15]})`}function iKt(s){return Math.sqrt(s[0]*s[0]+s[1]*s[1]+s[2]*s[2]+s[3]*s[3]+s[4]*s[4]+s[5]*s[5]+s[6]*s[6]+s[7]*s[7]+s[8]*s[8]+s[9]*s[9]+s[10]*s[10]+s[11]*s[11]+s[12]*s[12]+s[13]*s[13]+s[14]*s[14]+s[15]*s[15])}function rKt(s,n,r){return s[0]=n[0]+r[0],s[1]=n[1]+r[1],s[2]=n[2]+r[2],s[3]=n[3]+r[3],s[4]=n[4]+r[4],s[5]=n[5]+r[5],s[6]=n[6]+r[6],s[7]=n[7]+r[7],s[8]=n[8]+r[8],s[9]=n[9]+r[9],s[10]=n[10]+r[10],s[11]=n[11]+r[11],s[12]=n[12]+r[12],s[13]=n[13]+r[13],s[14]=n[14]+r[14],s[15]=n[15]+r[15],s}function Wpt(s,n,r){return s[0]=n[0]-r[0],s[1]=n[1]-r[1],s[2]=n[2]-r[2],s[3]=n[3]-r[3],s[4]=n[4]-r[4],s[5]=n[5]-r[5],s[6]=n[6]-r[6],s[7]=n[7]-r[7],s[8]=n[8]-r[8],s[9]=n[9]-r[9],s[10]=n[10]-r[10],s[11]=n[11]-r[11],s[12]=n[12]-r[12],s[13]=n[13]-r[13],s[14]=n[14]-r[14],s[15]=n[15]-r[15],s}function sKt(s,n,r){return s[0]=n[0]*r,s[1]=n[1]*r,s[2]=n[2]*r,s[3]=n[3]*r,s[4]=n[4]*r,s[5]=n[5]*r,s[6]=n[6]*r,s[7]=n[7]*r,s[8]=n[8]*r,s[9]=n[9]*r,s[10]=n[10]*r,s[11]=n[11]*r,s[12]=n[12]*r,s[13]=n[13]*r,s[14]=n[14]*r,s[15]=n[15]*r,s}function oKt(s,n,r,c){return s[0]=n[0]+r[0]*c,s[1]=n[1]+r[1]*c,s[2]=n[2]+r[2]*c,s[3]=n[3]+r[3]*c,s[4]=n[4]+r[4]*c,s[5]=n[5]+r[5]*c,s[6]=n[6]+r[6]*c,s[7]=n[7]+r[7]*c,s[8]=n[8]+r[8]*c,s[9]=n[9]+r[9]*c,s[10]=n[10]+r[10]*c,s[11]=n[11]+r[11]*c,s[12]=n[12]+r[12]*c,s[13]=n[13]+r[13]*c,s[14]=n[14]+r[14]*c,s[15]=n[15]+r[15]*c,s}function aKt(s,n){return s[0]===n[0]&&s[1]===n[1]&&s[2]===n[2]&&s[3]===n[3]&&s[4]===n[4]&&s[5]===n[5]&&s[6]===n[6]&&s[7]===n[7]&&s[8]===n[8]&&s[9]===n[9]&&s[10]===n[10]&&s[11]===n[11]&&s[12]===n[12]&&s[13]===n[13]&&s[14]===n[14]&&s[15]===n[15]}function cKt(s,n){let r=s[0],c=s[1],u=s[2],d=s[3],b=s[4],w=s[5],_=s[6],x=s[7],T=s[8],M=s[9],L=s[10],I=s[11],D=s[12],F=s[13],O=s[14],z=s[15],Z=n[0],H=n[1],te=n[2],oe=n[3],ne=n[4],ue=n[5],Te=n[6],Q=n[7],ge=n[8],Qe=n[9],st=n[10],at=n[11],Ne=n[12],tt=n[13],ot=n[14],Tt=n[15];return Math.abs(r-Z)<=1e-6*Math.max(1,Math.abs(r),Math.abs(Z))&&Math.abs(c-H)<=1e-6*Math.max(1,Math.abs(c),Math.abs(H))&&Math.abs(u-te)<=1e-6*Math.max(1,Math.abs(u),Math.abs(te))&&Math.abs(d-oe)<=1e-6*Math.max(1,Math.abs(d),Math.abs(oe))&&Math.abs(b-ne)<=1e-6*Math.max(1,Math.abs(b),Math.abs(ne))&&Math.abs(w-ue)<=1e-6*Math.max(1,Math.abs(w),Math.abs(ue))&&Math.abs(_-Te)<=1e-6*Math.max(1,Math.abs(_),Math.abs(Te))&&Math.abs(x-Q)<=1e-6*Math.max(1,Math.abs(x),Math.abs(Q))&&Math.abs(T-ge)<=1e-6*Math.max(1,Math.abs(T),Math.abs(ge))&&Math.abs(M-Qe)<=1e-6*Math.max(1,Math.abs(M),Math.abs(Qe))&&Math.abs(L-st)<=1e-6*Math.max(1,Math.abs(L),Math.abs(st))&&Math.abs(I-at)<=1e-6*Math.max(1,Math.abs(I),Math.abs(at))&&Math.abs(D-Ne)<=1e-6*Math.max(1,Math.abs(D),Math.abs(Ne))&&Math.abs(F-tt)<=1e-6*Math.max(1,Math.abs(F),Math.abs(tt))&&Math.abs(O-ot)<=1e-6*Math.max(1,Math.abs(O),Math.abs(ot))&&Math.abs(z-Tt)<=1e-6*Math.max(1,Math.abs(z),Math.abs(Tt))}var q4e,X4e,lKt,uKt,Z4e=Ve(()=>{f4();q4e=$pt;X4e=Vpt;lKt=F$,uKt=Wpt});var U1={};Oy(U1,{add:()=>Kpt,ceil:()=>fKt,clone:()=>qpt,copy:()=>Ypt,create:()=>Hpt,cross:()=>vKt,dist:()=>AKt,distance:()=>ngt,div:()=>CKt,divide:()=>egt,dot:()=>rgt,equals:()=>SKt,exactEquals:()=>ogt,floor:()=>hKt,forEach:()=>RKt,fromValues:()=>Xpt,inverse:()=>wKt,len:()=>LKt,length:()=>K4e,lerp:()=>sgt,max:()=>pKt,min:()=>dKt,mul:()=>TKt,multiply:()=>Qpt,negate:()=>bKt,normalize:()=>Q4e,random:()=>_Kt,round:()=>gKt,scale:()=>tgt,scaleAndAdd:()=>mKt,set:()=>Zpt,sqrDist:()=>PKt,sqrLen:()=>kKt,squaredDistance:()=>igt,squaredLength:()=>J4e,str:()=>EKt,sub:()=>MKt,subtract:()=>Jpt,transformMat4:()=>eke,transformQuat:()=>yKt,zero:()=>xKt});function Hpt(){let s=new Cc(4);return Cc!=Float32Array&&(s[0]=0,s[1]=0,s[2]=0,s[3]=0),s}function qpt(s){let n=new Cc(4);return n[0]=s[0],n[1]=s[1],n[2]=s[2],n[3]=s[3],n}function Xpt(s,n,r,c){let u=new Cc(4);return u[0]=s,u[1]=n,u[2]=r,u[3]=c,u}function Ypt(s,n){return s[0]=n[0],s[1]=n[1],s[2]=n[2],s[3]=n[3],s}function Zpt(s,n,r,c,u){return s[0]=n,s[1]=r,s[2]=c,s[3]=u,s}function Kpt(s,n,r){return s[0]=n[0]+r[0],s[1]=n[1]+r[1],s[2]=n[2]+r[2],s[3]=n[3]+r[3],s}function Jpt(s,n,r){return s[0]=n[0]-r[0],s[1]=n[1]-r[1],s[2]=n[2]-r[2],s[3]=n[3]-r[3],s}function Qpt(s,n,r){return s[0]=n[0]*r[0],s[1]=n[1]*r[1],s[2]=n[2]*r[2],s[3]=n[3]*r[3],s}function egt(s,n,r){return s[0]=n[0]/r[0],s[1]=n[1]/r[1],s[2]=n[2]/r[2],s[3]=n[3]/r[3],s}function fKt(s,n){return s[0]=Math.ceil(n[0]),s[1]=Math.ceil(n[1]),s[2]=Math.ceil(n[2]),s[3]=Math.ceil(n[3]),s}function hKt(s,n){return s[0]=Math.floor(n[0]),s[1]=Math.floor(n[1]),s[2]=Math.floor(n[2]),s[3]=Math.floor(n[3]),s}function dKt(s,n,r){return s[0]=Math.min(n[0],r[0]),s[1]=Math.min(n[1],r[1]),s[2]=Math.min(n[2],r[2]),s[3]=Math.min(n[3],r[3]),s}function pKt(s,n,r){return s[0]=Math.max(n[0],r[0]),s[1]=Math.max(n[1],r[1]),s[2]=Math.max(n[2],r[2]),s[3]=Math.max(n[3],r[3]),s}function gKt(s,n){return s[0]=Cb(n[0]),s[1]=Cb(n[1]),s[2]=Cb(n[2]),s[3]=Cb(n[3]),s}function tgt(s,n,r){return s[0]=n[0]*r,s[1]=n[1]*r,s[2]=n[2]*r,s[3]=n[3]*r,s}function mKt(s,n,r,c){return s[0]=n[0]+r[0]*c,s[1]=n[1]+r[1]*c,s[2]=n[2]+r[2]*c,s[3]=n[3]+r[3]*c,s}function ngt(s,n){let r=n[0]-s[0],c=n[1]-s[1],u=n[2]-s[2],d=n[3]-s[3];return Math.sqrt(r*r+c*c+u*u+d*d)}function igt(s,n){let r=n[0]-s[0],c=n[1]-s[1],u=n[2]-s[2],d=n[3]-s[3];return r*r+c*c+u*u+d*d}function K4e(s){let n=s[0],r=s[1],c=s[2],u=s[3];return Math.sqrt(n*n+r*r+c*c+u*u)}function J4e(s){let n=s[0],r=s[1],c=s[2],u=s[3];return n*n+r*r+c*c+u*u}function bKt(s,n){return s[0]=-n[0],s[1]=-n[1],s[2]=-n[2],s[3]=-n[3],s}function wKt(s,n){return s[0]=1/n[0],s[1]=1/n[1],s[2]=1/n[2],s[3]=1/n[3],s}function Q4e(s,n){let r=n[0],c=n[1],u=n[2],d=n[3],b=r*r+c*c+u*u+d*d;return b>0&&(b=1/Math.sqrt(b)),s[0]=r*b,s[1]=c*b,s[2]=u*b,s[3]=d*b,s}function rgt(s,n){return s[0]*n[0]+s[1]*n[1]+s[2]*n[2]+s[3]*n[3]}function vKt(s,n,r,c){let u=r[0]*c[1]-r[1]*c[0],d=r[0]*c[2]-r[2]*c[0],b=r[0]*c[3]-r[3]*c[0],w=r[1]*c[2]-r[2]*c[1],_=r[1]*c[3]-r[3]*c[1],x=r[2]*c[3]-r[3]*c[2],T=n[0],M=n[1],L=n[2],I=n[3];return s[0]=M*x-L*_+I*w,s[1]=-(T*x)+L*b-I*d,s[2]=T*_-M*b+I*u,s[3]=-(T*w)+M*d-L*u,s}function sgt(s,n,r,c){let u=n[0],d=n[1],b=n[2],w=n[3];return s[0]=u+c*(r[0]-u),s[1]=d+c*(r[1]-d),s[2]=b+c*(r[2]-b),s[3]=w+c*(r[3]-w),s}function _Kt(s,n){n=n===void 0?1:n;let r,c,u,d,b,w;do r=Hy()*2-1,c=Hy()*2-1,b=r*r+c*c;while(b>=1);do u=Hy()*2-1,d=Hy()*2-1,w=u*u+d*d;while(w>=1);let _=Math.sqrt((1-b)/w);return s[0]=n*r,s[1]=n*c,s[2]=n*u*_,s[3]=n*d*_,s}function eke(s,n,r){let c=n[0],u=n[1],d=n[2],b=n[3];return s[0]=r[0]*c+r[4]*u+r[8]*d+r[12]*b,s[1]=r[1]*c+r[5]*u+r[9]*d+r[13]*b,s[2]=r[2]*c+r[6]*u+r[10]*d+r[14]*b,s[3]=r[3]*c+r[7]*u+r[11]*d+r[15]*b,s}function yKt(s,n,r){let c=n[0],u=n[1],d=n[2],b=r[0],w=r[1],_=r[2],x=r[3],T=x*c+w*d-_*u,M=x*u+_*c-b*d,L=x*d+b*u-w*c,I=-b*c-w*u-_*d;return s[0]=T*x+I*-b+M*-_-L*-w,s[1]=M*x+I*-w+L*-b-T*-_,s[2]=L*x+I*-_+T*-w-M*-b,s[3]=n[3],s}function xKt(s){return s[0]=0,s[1]=0,s[2]=0,s[3]=0,s}function EKt(s){return`vec4(${s[0]}, ${s[1]}, ${s[2]}, ${s[3]})`}function ogt(s,n){return s[0]===n[0]&&s[1]===n[1]&&s[2]===n[2]&&s[3]===n[3]}function SKt(s,n){let r=s[0],c=s[1],u=s[2],d=s[3],b=n[0],w=n[1],_=n[2],x=n[3];return Math.abs(r-b)<=1e-6*Math.max(1,Math.abs(r),Math.abs(b))&&Math.abs(c-w)<=1e-6*Math.max(1,Math.abs(c),Math.abs(w))&&Math.abs(u-_)<=1e-6*Math.max(1,Math.abs(u),Math.abs(_))&&Math.abs(d-x)<=1e-6*Math.max(1,Math.abs(d),Math.abs(x))}var MKt,TKt,CKt,AKt,PKt,LKt,kKt,RKt,Kce=Ve(()=>{f4();MKt=Jpt,TKt=Qpt,CKt=egt,AKt=ngt,PKt=igt,LKt=K4e,kKt=J4e,RKt=function(){let s=Hpt();return function(n,r,c,u,d,b){let w,_;for(r||(r=4),c||(c=0),u?_=Math.min(u*r+c,n.length):_=n.length,w=c;w<_;w+=r)s[0]=n[w],s[1]=n[w+1],s[2]=n[w+2],s[3]=n[w+3],d(s,s,b),n[w]=s[0],n[w+1]=s[1],n[w+2]=s[2],n[w+3]=s[3];return n}}()});function OKt(){return Jce||(Jce=new Of([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Jce)),Jce}function NKt(){return Qce||(Qce=new Of,Object.freeze(Qce)),Qce}function agt(s){if(s>Math.PI*2)throw Error("expected radians")}function FKt(s,n,r,c,u,d){let b=2*d/(r-n),w=2*d/(u-c),_=(r+n)/(r-n),x=(u+c)/(u-c),T=-1,M=-1,L=-2*d;return s[0]=b,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=w,s[6]=0,s[7]=0,s[8]=_,s[9]=x,s[10]=T,s[11]=M,s[12]=0,s[13]=0,s[14]=L,s[15]=0,s}var ike,IKt,DKt,tke,nke,BKt,Of,Jce,Qce,cgt=Ve(()=>{Npt();D$();M4e();Z4e();S4e();N$();Kce();(function(s){s[s.COL0ROW0=0]="COL0ROW0",s[s.COL0ROW1=1]="COL0ROW1",s[s.COL0ROW2=2]="COL0ROW2",s[s.COL0ROW3=3]="COL0ROW3",s[s.COL1ROW0=4]="COL1ROW0",s[s.COL1ROW1=5]="COL1ROW1",s[s.COL1ROW2=6]="COL1ROW2",s[s.COL1ROW3=7]="COL1ROW3",s[s.COL2ROW0=8]="COL2ROW0",s[s.COL2ROW1=9]="COL2ROW1",s[s.COL2ROW2=10]="COL2ROW2",s[s.COL2ROW3=11]="COL2ROW3",s[s.COL3ROW0=12]="COL3ROW0",s[s.COL3ROW1=13]="COL3ROW1",s[s.COL3ROW2=14]="COL3ROW2",s[s.COL3ROW3=15]="COL3ROW3"})(ike||(ike={}));IKt=45*Math.PI/180,DKt=1,tke=.1,nke=500,BKt=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),Of=class extends Zce{static get IDENTITY(){return NKt()}static get ZERO(){return OKt()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return ike}constructor(n){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(n)?this.copy(n):this.identity()}copy(n){return this[0]=n[0],this[1]=n[1],this[2]=n[2],this[3]=n[3],this[4]=n[4],this[5]=n[5],this[6]=n[6],this[7]=n[7],this[8]=n[8],this[9]=n[9],this[10]=n[10],this[11]=n[11],this[12]=n[12],this[13]=n[13],this[14]=n[14],this[15]=n[15],this.check()}set(n,r,c,u,d,b,w,_,x,T,M,L,I,D,F,O){return this[0]=n,this[1]=r,this[2]=c,this[3]=u,this[4]=d,this[5]=b,this[6]=w,this[7]=_,this[8]=x,this[9]=T,this[10]=M,this[11]=L,this[12]=I,this[13]=D,this[14]=F,this[15]=O,this.check()}setRowMajor(n,r,c,u,d,b,w,_,x,T,M,L,I,D,F,O){return this[0]=n,this[1]=d,this[2]=x,this[3]=I,this[4]=r,this[5]=b,this[6]=T,this[7]=D,this[8]=c,this[9]=w,this[10]=M,this[11]=F,this[12]=u,this[13]=_,this[14]=L,this[15]=O,this.check()}toRowMajor(n){return n[0]=this[0],n[1]=this[4],n[2]=this[8],n[3]=this[12],n[4]=this[1],n[5]=this[5],n[6]=this[9],n[7]=this[13],n[8]=this[2],n[9]=this[6],n[10]=this[10],n[11]=this[14],n[12]=this[3],n[13]=this[7],n[14]=this[11],n[15]=this[15],n}identity(){return this.copy(BKt)}fromObject(n){return this.check()}fromQuaternion(n){return W4e(this,n),this.check()}frustum(n){let{left:r,right:c,bottom:u,top:d,near:b=tke,far:w=nke}=n;return w===1/0?FKt(this,r,c,u,d,b):H4e(this,r,c,u,d,b,w),this.check()}lookAt(n){let{eye:r,center:c=[0,0,0],up:u=[0,1,0]}=n;return Y4e(this,r,c,u),this.check()}ortho(n){let{left:r,right:c,bottom:u,top:d,near:b=tke,far:w=nke}=n;return X4e(this,r,c,u,d,b,w),this.check()}orthographic(n){let{fovy:r=IKt,aspect:c=DKt,focalDistance:u=1,near:d=tke,far:b=nke}=n;agt(r);let w=r/2,_=u*Math.tan(w),x=_*c;return this.ortho({left:-x,right:x,bottom:-_,top:_,near:d,far:b})}perspective(n){let{fovy:r=45*Math.PI/180,aspect:c=1,near:u=.1,far:d=500}=n;return agt(r),q4e(this,r,c,u,d),this.check()}determinant(){return F4e(this)}getScale(n=[-0,-0,-0]){return n[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),n[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),n[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),n}getTranslation(n=[-0,-0,-0]){return n[0]=this[12],n[1]=this[13],n[2]=this[14],n}getRotation(n,r){n=n||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let c=this.getScale(r),u=1/c[0],d=1/c[1],b=1/c[2];return n[0]=this[0]*u,n[1]=this[1]*d,n[2]=this[2]*b,n[3]=0,n[4]=this[4]*u,n[5]=this[5]*d,n[6]=this[6]*b,n[7]=0,n[8]=this[8]*u,n[9]=this[9]*d,n[10]=this[10]*b,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}getRotationMatrix3(n,r){n=n||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let c=this.getScale(r),u=1/c[0],d=1/c[1],b=1/c[2];return n[0]=this[0]*u,n[1]=this[1]*d,n[2]=this[2]*b,n[3]=this[4]*u,n[4]=this[5]*d,n[5]=this[6]*b,n[6]=this[8]*u,n[7]=this[9]*d,n[8]=this[10]*b,n}transpose(){return O4e(this,this),this.check()}invert(){return N4e(this,this),this.check()}multiplyLeft(n){return F$(this,n,this),this.check()}multiplyRight(n){return F$(this,this,n),this.check()}rotateX(n){return j4e(this,this,n),this.check()}rotateY(n){return $4e(this,this,n),this.check()}rotateZ(n){return V4e(this,this,n),this.check()}rotateXYZ(n){return this.rotateX(n[0]).rotateY(n[1]).rotateZ(n[2])}rotateAxis(n,r){return G4e(this,this,n,r),this.check()}scale(n){return z4e(this,this,Array.isArray(n)?n:[n,n,n]),this.check()}translate(n){return U4e(this,this,n),this.check()}transform(n,r){return n.length===4?(r=eke(r||[-0,-0,-0,-0],n,this),Vce(r,4),r):this.transformAsPoint(n,r)}transformAsPoint(n,r){let{length:c}=n,u;switch(c){case 2:u=E4e(r||[-0,-0],n,this);break;case 3:u=O$(r||[-0,-0,-0],n,this);break;default:throw new Error("Illegal vector")}return Vce(u,n.length),u}transformAsVector(n,r){let c;switch(n.length){case 2:c=Cpt(r||[-0,-0],n,this);break;case 3:c=Hce(r||[-0,-0,-0],n,this);break;default:throw new Error("Illegal vector")}return Vce(c,n.length),c}transformPoint(n,r){return this.transformAsPoint(n,r)}transformVector(n,r){return this.transformAsPoint(n,r)}transformDirection(n,r){return this.transformAsVector(n,r)}makeRotationX(n){return this.identity().rotateX(n)}makeTranslation(n,r,c){return this.identity().translate([n,r,c])}}});function lgt(){let s=new Cc(4);return Cc!=Float32Array&&(s[0]=0,s[1]=0,s[2]=0),s[3]=1,s}function UKt(s,n,r){r=r*.5;let c=Math.sin(r);return s[0]=c*n[0],s[1]=c*n[1],s[2]=c*n[2],s[3]=Math.cos(r),s}function rke(s,n,r,c){let u=n[0],d=n[1],b=n[2],w=n[3],_=r[0],x=r[1],T=r[2],M=r[3],L,I,D,F,O;return L=u*_+d*x+b*T+w*M,L<0&&(L=-L,_=-_,x=-x,T=-T,M=-M),1-L>1e-6?(I=Math.acos(L),O=Math.sin(I),D=Math.sin((1-c)*I)/O,F=Math.sin(c*I)/O):(D=1-c,F=c),s[0]=D*u+F*_,s[1]=D*d+F*x,s[2]=D*b+F*T,s[3]=D*w+F*M,s}function zKt(s,n){let r=n[0]+n[4]+n[8],c;if(r>0)c=Math.sqrt(r+1),s[3]=.5*c,c=.5/c,s[0]=(n[5]-n[7])*c,s[1]=(n[6]-n[2])*c,s[2]=(n[1]-n[3])*c;else{let u=0;n[4]>n[0]&&(u=1),n[8]>n[u*3+u]&&(u=2);let d=(u+1)%3,b=(u+2)%3;c=Math.sqrt(n[u*3+u]-n[d*3+d]-n[b*3+b]+1),s[u]=.5*c,c=.5/c,s[3]=(n[d*3+b]-n[b*3+d])*c,s[d]=(n[d*3+u]+n[u*3+d])*c,s[b]=(n[b*3+u]+n[u*3+b])*c}return s}var ugt,Dzn,Bzn,Ozn,fgt=Ve(()=>{f4();B4e();N$();Kce();ugt=Q4e,Dzn=function(){let s=qce(),n=Xce(1,0,0),r=Xce(0,1,0);return function(c,u,d){let b=B$(u,d);return b<-.999999?(h4(s,n,u),I4e(s)<1e-6&&h4(s,r,u),T4e(s,s),UKt(c,s,Math.PI),c):b>.999999?(c[0]=0,c[1]=0,c[2]=0,c[3]=1,c):(h4(s,u,d),c[0]=s[0],c[1]=s[1],c[2]=s[2],c[3]=1+b,ugt(c,c))}}(),Bzn=function(){let s=lgt(),n=lgt();return function(r,c,u,d,b,w){return rke(s,c,b,w),rke(n,u,d,w),rke(r,s,n,2*w*(1-w)),r}}(),Ozn=function(){let s=Fpt();return function(n,r,c,u){return s[0]=c[0],s[3]=c[1],s[6]=c[2],s[1]=u[0],s[4]=u[1],s[7]=u[2],s[2]=-r[0],s[5]=-r[1],s[8]=-r[2],ugt(n,zKt(n,s))}}()});var Nzn,Fzn,Uzn,zzn,hgt=Ve(()=>{Nzn=Math.PI/2,Fzn=Math.PI/4,Uzn=Math.PI/6,zzn=Math.PI*2});var Nf=Ve(()=>{Opt();cgt();hgt();qD();B4e();Z4e();fgt();S4e();N$();Kce()});function ske(s,n=[],r=0){let c=Math.fround(s),u=s-c;return n[r]=c,n[r+1]=u,n}function dgt(s){return s-Math.fround(s)}function pgt(s){let n=new Float32Array(32);for(let r=0;r<4;++r)for(let c=0;c<4;++c){let u=r*4+c;ske(s[c*4+r],n,u*2)}return n}var ggt=Ve(()=>{});function ele(s,n=!0){return s??n}function oke(s=[0,0,0],n=!0){return n?s.map(r=>r/255):[...s]}function mgt(s,n=!0){let r=oke(s.slice(0,3),n),c=Number.isFinite(s[3]),u=c?s[3]:1;return[r[0],r[1],r[2],n&&c?u/255:u]}var ake=Ve(()=>{});var $Kt,VKt,d4,bgt=Ve(()=>{$Kt=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND -// All these functions are for substituting tan() function from Intel GPU only +// All these functions are for substituting tan() function from Int_el GPU only const float TWO_PI = 6.2831854820251465; const float PI_2 = 1.5707963705062866; const float PI_16 = 0.1963495463132858; @@ -2525,7 +2525,7 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3, position_worldspace } return lightColor; } -`});var aJt,ZD,Ggt=Ve(()=>{Agt();Bgt();Fgt();zgt();aJt=[38.25,38.25,38.25],ZD={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:Ngt.replace("phongMaterial","gouraudMaterial"),fs:Ogt.replace("phongMaterial","gouraudMaterial"),source:Ugt.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[Igt,Cgt],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:aJt},getUniforms(s){return{...ZD.defaultUniforms,...s}}}});var vm=Ve(()=>{ELe();Ddt();c4e();ppt();mpt();bgt();Egt();Pgt();Ggt()});function Qy(s="id"){Ike[s]=Ike[s]||1;let n=Ike[s]++;return`${s}-${n}`}var Ike,hB=Ve(()=>{Ike={}});function y4(s){switch(s){case"POSITION":return"positions";case"NORMAL":return"normals";case"TEXCOORD_0":return"texCoords";case"TEXCOORD_1":return"texCoords1";case"COLOR_0":return"colors";default:return s}}function ien(s){let n=[];for(let[r,c]of Object.entries(s)){if(!c)continue;let{value:u,size:d,normalized:b}=c;if(d===void 0)throw new Error(`Attribute ${r} is missing a size`);n.push({name:y4(r),format:hl.getVertexFormatFromAttribute(u,d,b)})}return n}var Lb,Sle=Ve(()=>{Vr();hB();Lb=class{id;topology;vertexCount;indices;attributes;bufferLayout;userData={};constructor(n){let{attributes:r={},indices:c=null,vertexCount:u=null}=n;this.id=n.id||Qy("geometry"),this.topology=n.topology,c&&(this.indices=ArrayBuffer.isView(c)?{value:c,size:1}:c),this.attributes={};for(let[d,b]of Object.entries(r)){let w=ArrayBuffer.isView(b)?{value:b}:b;if(!ArrayBuffer.isView(w.value))throw new Error(`${this._print(d)}: must be typed array or object with value as typed array`);if((d==="POSITION"||d==="positions")&&!w.size&&(w.size=3),d==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=w}else{let _=y4(d),x=Object.keys(this.attributes).find(T=>y4(T)===_);x&&delete this.attributes[x],this.attributes[d]=w}}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=u||this._calculateVertexCount(this.attributes,this.indices),this.bufferLayout=n.bufferLayout||ien(this.attributes)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(n){return`Geometry ${this.id} attribute ${n}`}_setAttributes(n,r){return this}_calculateVertexCount(n,r){if(r)return r.value.length;let c=1/0;for(let u of Object.values(n)){if(!u)continue;let{value:d,size:b,constant:w}=u;!w&&d&&b!==void 0&&b>=1&&(c=Math.min(c,d.length/b))}return c}}});function Omt(s,n={}){let r=n.bufferName||"geometry";if(ren(s,r))return s;let c=n.minAttributeAlignment||4,u=sen(s,n.attributes),d=[],b=0,w=1/0;for(let[T,M]of u){if(!M)continue;if(M.constant)throw new Error(`Attribute ${T} is constant`);let{value:L,size:I,normalized:D}=M;if(!ArrayBuffer.isView(L))throw new Error(`Attribute ${T} is missing typed array data`);if(I===void 0)throw new Error(`Attribute ${T} is missing a size`);let F=hl.getVertexFormatFromAttribute(L,I,D),O=hl.getVertexFormatInfo(F);b=Bmt(b,c),d.push({sourceName:T,attributeName:y4(T),value:L,size:I,format:F,byteOffset:b,byteLength:O.byteLength}),b+=O.byteLength;let z=L.length/I;if(!Number.isInteger(z))throw new Error(`Attribute ${T} length is not divisible by size`);w=Math.min(w,z)}if(d.length===0||!Number.isFinite(w))throw new Error(`Geometry ${s.id} has no interleavable attributes`);let _=Bmt(b,c),x=new ArrayBuffer(w*_);for(let T of d)oen(x,w,_,T);return new Lb({id:s.id,topology:s.topology||"triangle-list",vertexCount:s.vertexCount,indices:s.indices,attributes:{[r]:{value:new Uint8Array(x),size:_,byteStride:_}},bufferLayout:[{name:r,stepMode:"vertex",byteStride:_,attributes:d.map(T=>({attribute:T.attributeName,format:T.format,byteOffset:T.byteOffset}))}]})}function ren(s,n){if(s.bufferLayout.length!==1)return!1;let r=s.bufferLayout[0];return r.name===n&&!!r.attributes?.length&&!!s.attributes[n]}function sen(s,n){return n?n.map(r=>[r,s.attributes[r]]):Object.entries(s.attributes)}function oen(s,n,r,c){let u=c.value.constructor,d=u.BYTES_PER_ELEMENT;if(c.byteOffset%d!==0||r%d!==0)throw new Error(`Attribute ${c.sourceName} is not aligned to its component type`);let b=new u(s),w=c.value,_=c.byteOffset/d,x=r/d;for(let T=0;T{Vr();Sle()});var aen,cen,x4,Fmt=Ve(()=>{aen=1,cen=1,x4=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(n){let{delay:r=0,duration:c=Number.POSITIVE_INFINITY,rate:u=1,repeat:d=1}=n,b=aen++,w={time:0,delay:r,duration:c,rate:u,repeat:d};return this._setChannelTime(w,this.time),this.channels.set(b,w),b}removeChannel(n){this.channels.delete(n);for(let[r,c]of this.animations)c.channel===n&&this.detachAnimation(r)}isFinished(n){let r=this.channels.get(n);return r===void 0?!1:this.time>=r.delay+r.duration*r.repeat}getTime(n){if(n===void 0)return this.time;let r=this.channels.get(n);return r===void 0?-1:r.time}setTime(n){this.time=Math.max(0,n);let r=this.channels.values();for(let u of r)this._setChannelTime(u,this.time);let c=this.animations.values();for(let u of c){let{animation:d,channel:b}=u;d.setTime(this.getTime(b))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(n,r){let c=cen++;return this.animations.set(c,{animation:n,channel:r}),n.setTime(this.getTime(r)),c}detachAnimation(n){this.animations.delete(n)}update(n){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=n),this.setTime(this.time+(n-this.lastEngineTime)),this.lastEngineTime=n)}_setChannelTime(n,r){let c=r-n.delay,u=n.duration*n.repeat;c>=u?n.time=n.duration*n.rate:(n.time=Math.max(0,c)%n.duration,n.time*=n.rate)}}});function Umt(s){let n=typeof window<"u"?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame:null;return n?n.call(window,s):setTimeout(()=>s(typeof performance<"u"?performance.now():Date.now()),1e3/60)}function zmt(s){let n=typeof window<"u"?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame:null;if(n){n.call(window,s);return}clearTimeout(s)}var Gmt=Ve(()=>{});var len,uen,jmt,iV,$mt=Ve(()=>{Vr();Gmt();Kj();len=0,uen="Animation Loop",jmt={requestAnimationFrame:s=>Umt(s),cancelAnimationFrame:s=>zmt(s)},iV=class s{static defaultAnimationLoopProps={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:n=>{console.error(n)},stats:void 0,autoResizeViewport:!1,animationFrameProvider:jmt};device=null;canvas=null;props;animationProps=null;timeline=null;stats;sharedStats;cpuTime;gpuTime;frameRate;display;_needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;_lastFrameTime=0;constructor(n){if(this.props={...s.defaultAnimationLoopProps,...n},n=this.props,!n.device)throw new Error("No device provided");this.stats=n.stats||new xb({id:`animation-loop-${len++}`}),this.sharedStats=UD.stats.get(uen),this.frameRate=this.stats.get("Frame Rate"),this.frameRate.setSampleSize(1),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.setProps({autoResizeViewport:n.autoResizeViewport,animationFrameProvider:n.animationFrameProvider}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null),this.device?._disableDebugGPUTime()}delete(){this.destroy()}reportError(n){this._error=n,this.props.onError(n),this.props.onError===s.defaultAnimationLoopProps.onError&&typeof window<"u"&&typeof ErrorEvent<"u"&&window.dispatchEvent(new ErrorEvent("error",{error:n,message:n.message}))}setNeedsRedraw(n){return this._needsRedraw=this._needsRedraw||n,this}needsRedraw(){let n=this._needsRedraw;return this._needsRedraw=!1,n}setProps(n){if("autoResizeViewport"in n&&(this.props.autoResizeViewport=n.autoResizeViewport||!1),"animationFrameProvider"in n){let r=n.animationFrameProvider||jmt;if(r!==this.props.animationFrameProvider){let c=this._animationFrameId!==null;c&&this._cancelAnimationFrame(),this.props.animationFrameProvider=r,c&&this._requestAnimationFrame()}}return this}async start(){if(this._running)return this;this._running=!0;try{let n;if(!this._initialized){if(this._initialized=!0,await this._initDevice(),this._initialize(),!this._running)return null;await this.props.onInitialize(this._getAnimationProps())}return this._running?(n!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(n){let r=n instanceof Error?n:new Error("Unknown error");throw this.props.onError(r),r}}stop(){if(this._running){let n=this.animationProps;this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1,this._lastFrameTime=0,n&&this.props.onFinalize(n)}return this}redraw(n,r=null){return this.device?.isLost||this._error?this:(this._beginFrameTimers(n),this._setupFrame(),this.animationProps&&(this.animationProps.animationFrame=r),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(n){return this.timeline=n,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(n=>{this._resolveNextFrame=n})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeViewport(),this.device?._enableDebugGPUTime()}_setDisplay(n){this.display&&(this.display.destroy(),this.display.animationLoop=null),n&&(n.animationLoop=this),this.display=n}_requestAnimationFrame(){this._running&&(this._animationFrameId=this.props.animationFrameProvider.requestAnimationFrame(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(this.props.animationFrameProvider.cancelAnimationFrame(this._animationFrameId),this._animationFrameId=null)}_animationFrame(n,r){if(this._running)try{this.redraw(n,r??null),this._requestAnimationFrame()}catch(c){let u=c instanceof Error?c:new Error(String(c));this.reportError(u),this.stop()}}_renderFrame(n){if(this.display){this.display._renderFrame(n);return}let r=this.props.onRender(this._getAnimationProps());this.device&&r!==!1&&this.device.submit()}_clearNeedsRedraw(){this._needsRedraw=!1}_setupFrame(){this._resizeViewport()}_initializeAnimationProps(){let n=this.device?.getDefaultCanvasContext();if(!this.device||!n)throw new Error("loop");let r=n?.canvas,c=n.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:n,canvas:r,useDevicePixels:c,timeline:this.timeline,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,animationFrame:null,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:n,height:r,aspect:c}=this._getSizeAndAspect();(n!==this.animationProps.width||r!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),c!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=n,this.animationProps.height=r,this.animationProps.aspect=c,this.animationProps.needsRedraw=this._needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.getDefaultCanvasContext().canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let n=document.createElement("div");document.body.appendChild(n),n.style.position="relative";let r=document.createElement("div");r.style.position="absolute",r.style.left="10px",r.style.bottom="10px",r.style.width="300px",r.style.background="white",this.canvas instanceof HTMLCanvasElement&&n.appendChild(this.canvas),n.appendChild(r);let c=this.props.onAddHTML(r);c&&(r.innerHTML=c)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[n,r]=this.device.getDefaultCanvasContext().getDrawingBufferSize(),c=n>0&&r>0?n/r:1;return{width:n,height:r,aspect:c}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(n){let r=n??(typeof performance<"u"?performance.now():Date.now());if(this._lastFrameTime){let c=r-this._lastFrameTime;c>0&&this.frameRate.addTime(c)}this._lastFrameTime=r,this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeStart()}_endFrameTimers(){this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeEnd(),this._updateSharedStats()}_consumeEncodedGpuTime(){if(!this.device)return;let n=this.device.commandEncoder._gpuTimeMs;n!==void 0&&(this.gpuTime.addTime(n),this.device.commandEncoder._gpuTimeMs=void 0)}_updateSharedStats(){if(this.stats!==this.sharedStats){for(let n of Object.keys(this.sharedStats.stats))this.stats.stats[n]||delete this.sharedStats.stats[n];this.stats.forEach(n=>{let r=this.sharedStats.get(n.name,n.type);r.sampleSize=n.sampleSize,r.time=n.time,r.count=n.count,r.samples=n.samples,r.lastTiming=n.lastTiming,r.lastSampleTime=n.lastSampleTime,r.lastSampleCount=n.lastSampleCount,r._count=n._count,r._time=n._time,r._samples=n._samples,r._startTime=n._startTime,r._timerPending=n._timerPending})}}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(n){n instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[n.offsetX,n.offsetY])}_onMouseleave(n){this._getAnimationProps()._mousePosition=null}}});function Vmt(s,n){if(n instanceof Mle)return n;let r=Omt(n),c=fen(s,r),{attributes:u,bufferLayout:d}=hen(s,r);return new Mle({topology:r.topology||"triangle-list",bufferLayout:d,vertexCount:r.vertexCount,indices:c,attributes:u})}function fen(s,n){if(!n.indices)return;let r=n.indices.value;return s.createBuffer({usage:cs.INDEX,data:r})}function hen(s,n){let r={};for(let[c,u]of Object.entries(n.attributes)){let d=n.bufferLayout.find(b=>b.name===c)?.name||y4(c);u&&(r[d]=s.createBuffer({data:u.value,id:`${c}-buffer`}))}return{attributes:r,bufferLayout:n.bufferLayout,vertexCount:n.vertexCount}}var Mle,Wmt=Ve(()=>{Vr();Sle();Nmt();hB();Mle=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(n){if(this.id=n.id||Qy("geometry"),this.topology=n.topology,this.indices=n.indices||null,this.attributes=n.attributes,this.vertexCount=n.vertexCount,this.bufferLayout=n.bufferLayout||[],this.indices&&!(this.indices.usage&cs.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){this.indices?.destroy();for(let n of Object.values(this.attributes))n.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(n){return n.byteLength/12}}});function Hmt(s,n){let r={},c="Values";if(s.attributes.length===0&&!s.varyings?.length)return{"No attributes or varyings":{[c]:"N/A"}};for(let u of s.attributes)if(u){let d=`${u.location} ${u.name}: ${u.type}`;r[`in ${d}`]={[c]:u.stepMode||"vertex"}}for(let u of s.varyings||[]){let d=`${u.location} ${u.name}`;r[`out ${d}`]={[c]:JSON.stringify(u)}}return r}var qmt=Ve(()=>{});function Zmt(s,n,r){if(s.device.type!=="webgl")return;let c=gen(s.device);if(!c.flushing){if(ben(s)){den(s,r,c);return}n&&men(n)&&n.handle!==null&&(c.queuedFramebuffers.includes(n)||c.queuedFramebuffers.push(n))}}function den(s,n,r){if(r.queuedFramebuffers.length===0)return;let c=s.device,{gl:u}=c,d=u.getParameter(36010),b=u.getParameter(36006),[w,_]=s.device.getDefaultCanvasContext().getDrawingBufferSize(),x=Ymt(n.top,8),T=Ymt(n.left,8);r.flushing=!0;try{for(let M of r.queuedFramebuffers){let[L,I,D,F,O]=pen({framebuffer:M,targetWidth:w,targetHeight:_,topPx:x,leftPx:T,minimap:n.minimap});u.bindFramebuffer(36008,M.handle),u.bindFramebuffer(36009,null),u.blitFramebuffer(0,0,M.width,M.height,L,I,D,F,16384,9728),x+=O+8}}finally{u.bindFramebuffer(36008,d),u.bindFramebuffer(36009,b),r.flushing=!1}}function pen(s){let{framebuffer:n,targetWidth:r,targetHeight:c,topPx:u,leftPx:d,minimap:b}=s,w=b?Math.max(Math.floor(r/4),1):r,_=b?Math.max(Math.floor(c/4),1):c,x=Math.min(w/n.width,_/n.height),T=Math.max(Math.floor(n.width*x),1),M=Math.max(Math.floor(n.height*x),1),L=d,I=Math.max(c-u-M,0),D=L+T,F=I+M;return[L,I,D,F,M]}function gen(s){return s.userData[Xmt]||={flushing:!1,queuedFramebuffers:[]},s.userData[Xmt]}function men(s){return"colorAttachments"in s}function ben(s){let n=s.props.framebuffer;return!n||n.handle===null}function Ymt(s,n){if(!s)return n;let r=Number.parseInt(s,10);return Number.isFinite(r)?r:n}var Xmt,Kmt=Ve(()=>{Xmt="__debugFramebufferState"});function dB(s,n,r){if(s===n)return!0;if(!r||!s||!n)return!1;if(Array.isArray(s)){if(!Array.isArray(n)||s.length!==n.length)return!1;for(let c=0;c{});var pB,Qmt=Ve(()=>{Vr();pB=class{bufferLayouts;constructor(n){this.bufferLayouts=n}getBufferLayout(n){return this.bufferLayouts.find(r=>r.name===n)||null}getAttributeNamesForBuffer(n){return VD(n)}mergeBufferLayouts(n,r){let c=[...n];for(let u of r){let d=c.findIndex(b=>b.name===u.name);d<0?c.push(u):c[d]=u}return c}}});function e1t(s,n){let r=i4e(s),c=n.slice();return c.sort((u,d)=>{let b=Oce(VD(u).map(_=>r[_])),w=Oce(VD(d).map(_=>r[_]));return b-w}),c}var t1t=Ve(()=>{Vr()});function gB(s,n){if(!s||!n.some(c=>c.bindingLayout?.length))return s;let r={...s,bindings:s.bindings.map(c=>({...c}))};"attributes"in(s||{})&&(r.attributes=s?.attributes||[]);for(let c of n)for(let u of c.bindingLayout||[])for(let d of wen(u.name)){let b=r.bindings.find(w=>w.name===d);b?.group===0&&(b.group=u.group),b&&u.visibility!==void 0&&(b.visibility=u.visibility)}return r}function n1t(s,n,r=[]){return s?n?{...s,attributes:s.attributes.length?yen(s.attributes,n.attributes.filter(c=>r.includes(c.name))):n.attributes,bindings:_en(s.bindings,n.bindings)}:s:n}function rV(s){return!!(s.uniformTypes&&!ven(s.uniformTypes))}function i1t(s){let n=[];for(let r of s){let c=k$(r),u=new Set([r.vs,r.fs].flatMap(b=>b?R$(b).filter(w=>w.isStd140).map(w=>w.blockName):[])),d=u.has(c)?c:u.size===1?u.values().next().value:void 0;rV(r)&&d&&n.push({name:d,uniformTypes:r.uniformTypes})}return n}function Tle(s,n){let r=[],c=new Set;for(let u of[...s||[],...n||[]])c.has(u.name)||(c.add(u.name),r.push(u));return r}function wen(s){let n=new Set([s,`${s}Uniforms`]);return s.endsWith("Uniforms")||n.add(`${s}Sampler`),[...n]}function ven(s){for(let n in s)return!1;return!0}function _en(s,n){let r=s.map(d=>({...d})),c=new Set(s.map(d=>d.name)),u=new Set(s.map(d=>`${d.group}:${d.location}`));for(let d of n){let b=`${d.group}:${d.location}`;!c.has(d.name)&&!u.has(b)&&r.push({...d})}return r}function yen(s,n){let r=s.map(d=>({...d})),c=new Map(s.map(d=>[d.name,d])),u=new Map(s.map(d=>[d.location,d]));for(let d of n){let b=c.get(d.name);if(b){if(b.type!==d.type||b.location!==d.location)throw new Error(`Shader attribute "${d.name}" conflicts with its inferred type or location`);continue}let w=u.get(d.location);if(w)throw new Error(`Shader attributes "${w.name}" and "${d.name}" both use location ${d.location}`);r.push({...d})}return r}var Dke=Ve(()=>{vm()});function xen(s){return r$(s)||typeof s=="number"||typeof s=="boolean"}function r1t(s,n={}){let r={bindings:{},uniforms:{}};return Object.keys(s).forEach(c=>{let u=s[c];Object.prototype.hasOwnProperty.call(n,c)||xen(u)?r.uniforms[c]=u:r.bindings[c]=u}),r}var s1t=Ve(()=>{sLe()});function o1t(s={},n={},r={}){let c={...s};for(let[u,d]of Object.entries(n))d!==void 0&&(c[u]=Bke(s[u],d,r[u]));return c}function Bke(s,n,r){if(!r||typeof r=="string")return sV(n);if(Array.isArray(r)){if(Oke(n)||!Array.isArray(n))return sV(n);let b=Array.isArray(s)&&!Oke(s)?[...s]:[],w=b.slice();for(let _=0;_r===void 0?void 0:sV(r)):Nke(s)?Object.fromEntries(Object.entries(s).map(([n,r])=>[n,r===void 0?void 0:sV(r)])):s}function Oke(s){return ArrayBuffer.isView(s)||Array.isArray(s)&&(s.length===0||typeof s[0]=="number")}function Nke(s){return!!s&&typeof s=="object"&&!Array.isArray(s)&&!ArrayBuffer.isView(s)}function Een(s){return!!s?.dependencies}var mB,Fke=Ve(()=>{Vr();vm();s1t();mB=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;directBindings={};constructor(n,r){Object.assign(this.options,r);let c=ZL(Object.values(n).filter(Een));for(let u of c)n[u.name]=u;Qt.log(1,"Creating ShaderInputs with modules",Object.keys(n))(),this.modules=n,this.moduleUniforms={},this.moduleBindings={};for(let[u,d]of Object.entries(n))d&&(this._addModule(d),d.name&&u!==d.name&&!this.options.disableWarnings&&Qt.warn(`Module name: ${u} vs ${d.name}`)())}destroy(){}setProps(n){n.bindings&&Object.assign(this.directBindings,n.bindings);for(let r of Object.keys(n)){if(r==="bindings")continue;let c=r,u=n[c]||{},d=this.modules[c];if(!d)this.options.disableWarnings||Qt.warn(`Module ${r} not found`)();else{let b=this.moduleUniforms[c],w=this.moduleBindings[c],_=d.getUniforms?.(u,b)||u,{uniforms:x,bindings:T}=r1t(_,d.uniformTypes);this.moduleUniforms[c]=o1t(b,x,d.uniformTypes),this.moduleBindings[c]={...w,...T}}}}getModules(){return Object.values(this.modules)}addModules(n){let r=ZL(n);for(let c of r){let u=c.name;this.modules[u]||(this.modules[u]=c,this._addModule(c))}}getUniformValues(){return this.moduleUniforms}getBindingValues(){let n={};for(let r of Object.values(this.moduleBindings))Object.assign(n,r);return Object.assign(n,this.directBindings),n}getModuleBindingValues(n){let r=this.moduleBindings[n];return r?{...r}:{}}getDebugTable(){let n={};for(let[r,c]of Object.entries(this.moduleUniforms))for(let[u,d]of Object.entries(c))n[`${r}.${u}`]={type:this.modules[r].uniformTypes?.[u],value:String(d)};return n}_addModule(n){let r=n.name;this.moduleUniforms[r]=o1t({},n.defaultUniforms||{},n.uniformTypes),this.moduleBindings[r]={}}}});function Uke(s){return s!==null&&typeof s=="object"&&"buffer"in s}function Men(s){return s instanceof up?s.buffer:s}function a1t(s){return{buffer:Men(s.buffer),offset:s.offset,size:s.size}}var Sen,up,zke=Ve(()=>{Vr();hB();Sen=cs.DEBUG_DATA_MAX_LENGTH,up=class{device;id;ready;usage;props;isReady=!0;destroyed=!1;generation=0;updateTimestamp;debugData=new ArrayBuffer(0);_debugDataEnabled;_maxDebugDataByteLength;_ownsBuffer;_buffer;get buffer(){return this._buffer}get byteLength(){return this._buffer.byteLength}get[Symbol.toStringTag](){return"DynamicBuffer"}toString(){return`DynamicBuffer:"${this.id}":${this.byteLength}B`}toJSON(){return this.toString()}constructor(n,r){let{debugData:c=!1,buffer:u,ownsBuffer:d=!0,...b}=r;if(u&&u.device!==n)throw new Error("DynamicBuffer adopted buffers must belong to the supplied device");if(u&&(b.byteLength!==void 0||b.data!==void 0))throw new Error("DynamicBuffer cannot combine an adopted buffer with byteLength or data");let w=r.id||u?.id||Qy("dynamic-buffer"),_={...b,id:w,usage:b.usage??u?.usage,indexType:b.indexType??u?.indexType};(_.usage||0)&cs.INDEX&&!_.indexType&&(b.data instanceof Uint32Array?_.indexType="uint32":b.data instanceof Uint16Array?_.indexType="uint16":b.data instanceof Uint8Array&&(_.indexType="uint8")),delete _.data,delete _.byteOffset,this.device=n,this.id=w,this.props=_,this.usage=_.usage||0,this._debugDataEnabled=!!c,this._maxDebugDataByteLength=typeof c=="object"&&c.maxByteLength!==void 0?c.maxByteLength:Sen,this._ownsBuffer=d,this._buffer=u??this.device.createBuffer({...b,id:w}),this.ready=Promise.resolve(this._buffer),this.updateTimestamp=this._buffer.updateTimestamp,this._resetDebugData(this._buffer.byteLength),b.data&&this._writeDebugData(b.data,b.byteOffset||0)}write(n,r=0){this._buffer.write(n,r),this._touch(),this._writeDebugData(n,r)}async mapAndWriteAsync(n,r=0,c=this.byteLength-r){let u=null;await this._buffer.mapAndWriteAsync(async(d,b)=>{await n(d,b),u=new Uint8Array(d.slice(0,c))},r,c),this._touch(),u&&this._writeDebugData(u,r)}async readAsync(n=0,r=this.byteLength-n){let c=await this._buffer.readAsync(n,r);return this._writeDebugData(c,n)&&this._touch(),c}async mapAndReadAsync(n,r=0,c=this.byteLength-r){let u=null,d=await this._buffer.mapAndReadAsync(async(b,w)=>(u=new Uint8Array(b.slice(0)),await n(b,w)),r,c);return u&&this._writeDebugData(u,r)&&this._touch(),d}resize(n){let{byteLength:r,preserveData:c=!1}=n;if(r===this.byteLength)return!1;let u=Math.min(n.copyByteLength??Math.min(this.byteLength,r),this.byteLength,r),d=this._buffer,b=this.debugData.slice(0),{data:w,byteOffset:_,...x}=this.props,T=this.device.createBuffer({...x,byteLength:r});return c&&u>0&&this._copyBufferContents(d,T,u),this._buffer=T,this._resetDebugData(r),c&&b.byteLength>0&&this._writeDebugData(b,0),this._ownsBuffer&&d.destroy(),this._ownsBuffer=!0,this.generation++,this._touch(),!0}ensureSize(n,r){return n<=this.byteLength?!1:this.resize({byteLength:n,preserveData:r?.preserveData})}getBinding(n){return n?.offset===void 0&&n?.size===void 0?this._buffer:{buffer:this._buffer,offset:n?.offset,size:n?.size}}destroy(){this.destroyed||(this._ownsBuffer&&this._buffer.destroy(),this.destroyed=!0,this.debugData=new ArrayBuffer(0))}_copyBufferContents(n,r,c){let u=this.device.type==="webgpu"?Math.ceil(c/4)*4:c,d=this.device.createCommandEncoder();d.copyBufferToBuffer({sourceBuffer:n,destinationBuffer:r,size:u}),this.device.submit(d.finish())}_touch(){this.updateTimestamp=this.device.incrementTimestamp()}_resetDebugData(n){if(!this._debugDataEnabled){this.debugData=new ArrayBuffer(0);return}this.debugData=new ArrayBuffer(Math.min(n,this._maxDebugDataByteLength))}_writeDebugData(n,r){if(!this._debugDataEnabled||this.debugData.byteLength===0||r>=this.debugData.byteLength)return!1;let c=ArrayBuffer.isView(n)?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n),u=new Uint8Array(this.debugData),d=Math.min(c.byteLength,u.byteLength-r);return u.set(c.subarray(0,d),r),d>0}}});function oV(s){return s!==null&&typeof s=="object"&&"resolveTextureBinding"in s&&typeof s.resolveTextureBinding=="function"}function Ten(s){return s?.type==="texture"||s?.type==="external-texture"}function c1t(s,n,r){let c=Lce(s,n,{ignoreWarnings:!0});return Ten(c)?c:s.bindings.length===0&&r?.fallbackGroup!==void 0?{type:"texture",name:n,group:r.fallbackGroup,location:0}:null}var l1t=Ve(()=>{Vr()});function jke(s,n){return s.shaderLanguage!==void 0&&s.shaderLanguage!==n?!1:n==="glsl"?"assembleGLSLShaderPair"in s&&typeof s.assembleGLSLShaderPair=="function":"assembleWGSLShader"in s&&typeof s.assembleWGSLShader=="function"}function Pen(s,n){return!s||Object.keys(n).length===0?s:{...s,attributes:s.attributes.map(r=>{let c=r.name.startsWith("_luma_")?r.name.slice(6):null;return c&&n[c]?{...r,name:c}:r})}}function Len(s,n,r){if(oV(n)){let c=c1t(r,s,{fallbackGroup:0});return c?n.resolveTextureBinding(c):null}return n instanceof up?n.buffer:Uke(n)?a1t(n):n}function ken(s){return s&&!u1t(s)?s:null}function Ren(s){return s&&u1t(s)?s:void 0}function u1t(s){return Aen.includes(s)}function Ien(s){return{type:s.type,shaderLanguage:s.info.shadingLanguage,shaderLanguageVersion:s.info.shadingLanguageVersion,gpu:s.info.gpu,limits:s.limits,features:s.features}}var e2,Cen,Gke,Aen,Vh,$ke=Ve(()=>{Vr();vm();Wmt();qmt();Kmt();Jmt();Qmt();t1t();Dke();hB();Fke();zke();l1t();e2=2,Cen=1e4,Gke="render pipeline initialization failed",Aen=["stencil8","depth16unorm","depth24plus","depth24plus-stencil8","depth32float","depth32float-stencil8"],Vh=class s{static defaultProps={...Mb.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],plugins:[],geometry:null,indexBuffer:null,indexCount:void 0,firstVertex:0,firstIndex:0,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,material:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:Tb.getDefaultShaderAssembler("glsl"),debugShaders:void 0,disableWarnings:void 0};device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexCount;firstVertex;firstIndex;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;material=null;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_dynamicIndexBufferSource=null;_dynamicAttributeBufferSources={};_colorAttachmentFormats;_depthStencilAttachmentFormat;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_drawBlockedReason=!1;_destroyed=!1;_vertexCountSet=!1;_lastDrawTimestamp=-1;_bindingTable=[];get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(n,r){let c=s.defaultProps.shaderAssembler,u=r.vertexCount!==void 0;this.props={...s.defaultProps,...r,shaderAssembler:r.shaderAssembler??(jke(c,n.info.shadingLanguage)?c:Tb.getDefaultShaderAssembler(n.info.shadingLanguage))},this._vertexCountSet=u,r=this.props,this.id=r.id||Qy("model"),this.device=n,Object.assign(this.userData,r.userData),this.material=r.material||null;let d=Ien(n),b=P$(this.props.plugins,d.shaderLanguage),w=L$(this.props.modules,b.modules),_=Object.fromEntries(w.map(I=>[I.name,I])),x=r.shaderInputs||new mB(_,{disableWarnings:this.props.disableWarnings});r.shaderInputs&&b.modules.length>0&&x.addModules(b.modules),this.setShaderInputs(x);let T=Tle(this.props.modules,x.getModules()),M={...b.defines,...this.props.defines};if(this.device.type==="webgl"&&(this.props._uniformBlockLayouts=i1t(T)),this.props.shaderLayout=gB(this.props.shaderLayout,T)||null,this.device.type==="webgpu"&&this.props.source){let I=this.props.shaderAssembler;FM(jke(I,"wgsl"));let{source:D,getUniforms:F,bindingTable:O,shaderLayout:z}=I.assembleWGSLShader({platformInfo:d,...this.props,modules:T,defines:M,pluginInjections:b.injections,pluginVertexInputs:b.vertexInputs,pluginVaryings:b.varyings});this.source=D,this._getModuleUniforms=F,this._bindingTable=O;let Z=z??n.getShaderLayout?.(this.source),H=Pen(Z,b.vertexInputs),te=n1t(this.props.shaderLayout,H,Object.keys(b.vertexInputs));this.props.shaderLayout=gB(te||null,T)||null}else{let I=this.props.shaderAssembler;FM(jke(I,"glsl"));let{vs:D,fs:F,getUniforms:O}=I.assembleGLSLShaderPair({platformInfo:d,...this.props,modules:T,defines:M,pluginInjections:b.injections,pluginVertexInputs:b.vertexInputs,pluginVaryings:b.varyings});this.vs=D,this.fs=F,this._getModuleUniforms=O,this._bindingTable=[]}this.vertexCount=this.props.vertexCount,this.indexCount=this.props.indexCount,this.firstVertex=this.props.firstVertex,this.firstIndex=this.props.firstIndex,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,this._colorAttachmentFormats=this.props.colorAttachmentFormats,this._depthStencilAttachmentFormat=this.props.depthStencilAttachmentFormat,r.geometry&&this.setGeometry(r.geometry),this.pipelineFactory=r.pipelineFactory||i4.getDefaultPipelineFactory(this.device),this.shaderFactory=r.shaderFactory||r4.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=n.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in r&&(this.isInstanced=r.isInstanced),r.instanceCount&&this.setInstanceCount(r.instanceCount),r.vertexCount&&this.setVertexCount(r.vertexCount),r.indexBuffer&&this.setIndexBuffer(r.indexBuffer),r.attributes&&this.setAttributes(r.attributes),r.constantAttributes&&this.setConstantAttributes(r.constantAttributes),r.bindings&&this.setBindings(r.bindings),r.transformFeedback&&(this.transformFeedback=r.transformFeedback)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let n=this._needsRedraw;return this._needsRedraw=!1,n}setNeedsRedraw(n){this._needsRedraw||=n}getBindingDebugTable(){return this._bindingTable}predraw(n){this._syncDynamicBuffers(),this.updateShaderInputs(n),this.material?.updateShaderInputs(n),this.pipeline=this._updatePipeline()}draw(n){if(this._drawBlockedReason&&!this._pipelineNeedsUpdate)return Qt.info(e2,`>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)(),!1;let r=this._areBindingsLoading();if(r)return Qt.info(e2,`>>> DRAWING ABORTED ${this.id}: ${r} not loaded`)(),!1;this._syncAttachmentFormats(n);try{n.pushDebugGroup(`${this}.predraw(${n})`),this.device.type==="webgpu"?(this.updateShaderInputs(),this.material?.updateShaderInputs(),this._syncDynamicBuffers(),this.pipeline=this._updatePipeline()):this.predraw(this.device.commandEncoder)}finally{n.popDebugGroup()}let c,u=this.pipeline.isErrored;try{if(n.pushDebugGroup(`${this}.draw(${n})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline(),u=this.pipeline.isErrored,u)Qt.info(e2,`>>> DRAWING ABORTED ${this.id}: ${Gke}`)(),c=!1;else{let d=this.vertexArray.getDrawValidationError();if(d)Qt.info(e2,`>>> DRAWING ABORTED ${this.id}: ${d}`)(),this._drawBlockedReason=d,c=!1;else{let b=this._getCurrentShaderLayout(),w=this._getBindings(b),_=this._getBindGroups(b,w),{indexBuffer:x}=this.vertexArray,T=x?this.indexCount??(this._vertexCountSet?this.vertexCount:x.byteLength/(x.indexType==="uint32"?4:2)):void 0;n.setPipeline(this.pipeline),n.setBindings(_,{_bindGroupCacheKeys:this._getBindGroupCacheKeys()}),n.setVertexArray(this.vertexArray),c=this.isInstanced===!0&&this.instanceCount===0?!0:n.draw({isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.isInstanced?this.instanceCount:void 0,indexCount:T,firstVertex:this.firstVertex,firstIndex:this.firstIndex,transformFeedback:this.transformFeedback||void 0,uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}}}finally{n.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(n),c?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):u?(this._needsRedraw=Gke,this._drawBlockedReason=Gke):this._drawBlockedReason?this._needsRedraw=this._drawBlockedReason:this._needsRedraw="waiting for resource initialization",c}setGeometry(n){this._gpuGeometry?.destroy();let r=n&&Vmt(this.device,n);if(r){this.setTopology(r.topology||"triangle-list");let c=new pB(this.bufferLayout);this.bufferLayout=c.mergeBufferLayouts(r.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(r)}this._gpuGeometry=r}setTopology(n){n!==this.topology&&(this.topology=n,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(n){let r=new pB(this.bufferLayout),c=this._gpuGeometry?r.mergeBufferLayouts(n,this._gpuGeometry.bufferLayout):n;dB(c,this.bufferLayout,-1)||(this.bufferLayout=c,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry))}setParameters(n){dB(n,this.parameters,2)||(this.parameters=n,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(n){this.instanceCount=n,this.isInstanced===void 0&&n>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(n){this.vertexCount=n,this._vertexCountSet=!0,this.setNeedsRedraw("vertexCount")}setIndexCount(n){this.indexCount=n,this.setNeedsRedraw("indexCount")}setDrawOffsets({firstVertex:n,firstIndex:r}){this.firstVertex=n,this.firstIndex=r,this.setNeedsRedraw("drawOffsets")}setShaderInputs(n){this.shaderInputs=n,this._uniformStore=new a4(this.device,this.shaderInputs.modules);for(let[r,c]of Object.entries(this.shaderInputs.modules))if(rV(c)&&!this.material?.ownsModule(r)){let u=this._uniformStore.getManagedUniformBuffer(r);this.bindings[`${r}Uniforms`]=u}this.setNeedsRedraw("shaderInputs")}setMaterial(n){this.material=n,this.setNeedsRedraw("material")}updateShaderInputs(n){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),n),this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues())),this.setNeedsRedraw("shaderInputs")}setBindings(n){Object.assign(this.bindings,n),this.setNeedsRedraw("bindings")}setTransformFeedback(n){this.transformFeedback=n,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(n){let r=n instanceof up?n.buffer:n;this.indexBuffer=r,this._dynamicIndexBufferSource=n instanceof up?{source:n,generation:n.generation}:null,this.vertexArray.setIndexBuffer(r),this.setNeedsRedraw("indexBuffer")}setAttributes(n,r){this._drawBlockedReason=!1;let c=r?.disableWarnings??this.props.disableWarnings;n.indices&&Qt.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=e1t(this.pipeline.shaderLayout,this.bufferLayout);let u=new pB(this.bufferLayout);for(let[d,b]of Object.entries(n)){let w=b instanceof up?b.buffer:b,_=u.getBufferLayout(d);if(!_){c||Qt.warn(`Model(${this.id}): Missing layout for buffer "${d}".`)();continue}let x=u.getAttributeNamesForBuffer(_),T=!1;for(let M of x){let L=this._attributeInfos[M];if(L){let I=this.device.type==="webgpu"?this.vertexArray.getBufferSlot(L.bufferName):L.location;if(I===null){c||Qt.warn(`Model(${this.id}): Missing vertex array slot for buffer "${L.bufferName}".`)();continue}this.vertexArray.setBuffer(I,w),b instanceof up?this._dynamicAttributeBufferSources[I]={source:b,generation:b.generation}:delete this._dynamicAttributeBufferSources[I],T=!0}}!T&&!c&&Qt.warn(`Model(${this.id}): Ignoring buffer "${w.id}" for unknown attribute "${d}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(n,r){for(let[c,u]of Object.entries(n)){let d=this._attributeInfos[c];d?this.vertexArray.setConstantWebGL(d.location,u):(r?.disableWarnings??this.props.disableWarnings)||Qt.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${c}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(let n of Object.values(this.bindings))if(oV(n)&&!n.isReady)return n.id;for(let n of Object.values(this.material?.bindings||{}))if(oV(n)&&!n.isReady)return n.id;return!1}_getBindings(n=this._getCurrentShaderLayout()){let r={};for(let[c,u]of Object.entries(this.bindings)){let d=Len(c,u,n);d&&(r[c]=d)}return r}_getBindGroups(n=this._getCurrentShaderLayout(),r=this._getBindings(n)){let c=n.bindings.length?s4(n,r):{0:r};if(!this.material)return c;for(let[u,d]of Object.entries(this.material.getBindingsByGroup(n))){let b=Number(u);c[b]={...c[b]||{},...d}}return c}_getBindGroupCacheKeys(){let n=this.material?.getBindGroupCacheKey(3);return n?{3:n}:{}}_getBindingsUpdateTimestamp(){let n=0;this._dynamicIndexBufferSource&&(n=Math.max(n,this._dynamicIndexBufferSource.source.updateTimestamp));for(let r of Object.values(this._dynamicAttributeBufferSources))n=Math.max(n,r.source.updateTimestamp);for(let r of Object.values(this.bindings))r instanceof e4?n=Math.max(n,r.texture.updateTimestamp):r instanceof cs||r instanceof Pa||r instanceof b$||r instanceof up?n=Math.max(n,r.updateTimestamp):oV(r)?n=r.isReady?Math.max(n,r.updateTimestamp):1/0:Uke(r)&&(n=Math.max(n,(r.buffer instanceof up,r.buffer.updateTimestamp)));return Math.max(n,this.material?.getBindingsUpdateTimestamp()||0)}_setGeometryAttributes(n){let r={...n.attributes};for(let[c]of Object.entries(r))!this.pipeline.shaderLayout.attributes.find(u=>u.name===c)&&c!=="positions"&&delete r[c];this.vertexCount=n.vertexCount,this._vertexCountSet=!0,this.setIndexBuffer(n.indices||null),this.setAttributes(n.attributes,{disableWarnings:!0}),this.setAttributes(r,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(n){this._pipelineNeedsUpdate||=n,this._drawBlockedReason=!1,this.setNeedsRedraw(n)}_updatePipeline(){if(this._pipelineNeedsUpdate){let n=null,r=null;this.pipeline&&(Qt.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),n=this.pipeline.vs,r=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let c=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders}),u=null;this.source?u=c:this.fs&&(u=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bindings:void 0,bufferLayout:this.bufferLayout,colorAttachmentFormats:this._colorAttachmentFormats,depthStencilAttachmentFormat:this._depthStencilAttachmentFormat,topology:this.topology,parameters:this.parameters,bindGroups:void 0,vs:c,fs:u}),this._attributeInfos=A$(this.pipeline.shaderLayout,this.bufferLayout),n&&this.shaderFactory.release(n),r&&r!==n&&this.shaderFactory.release(r)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let n=Qt.level>3?0:Cen;Qt.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:Qt.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let n=Hmt(this.pipeline.shaderLayout,this.id);Qt.table(e2,n)();let r=this.shaderInputs.getDebugTable();Qt.table(e2,r)();let c=this._getAttributeDebugTable();Qt.table(e2,this._attributeInfos)(),Qt.table(e2,c)(),Qt.groupEnd(e2)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(n){let r=this.device.props.debugFramebuffers;if(this._drawCount++,!r)return;let c=n.props.framebuffer;Zmt(n,c,{id:c?.id||`${this.id}-framebuffer`,minimap:!0})}_getAttributeDebugTable(){let n={};for(let[r,c]of Object.entries(this._attributeInfos)){let u=this.vertexArray.attributes[c.location];n[c.location]={name:r,type:c.shaderType,values:u?this._getBufferOrConstantValues(u,c.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:r}=this.vertexArray,c=r.indexType==="uint32"?new Uint32Array(r.debugData):new Uint16Array(r.debugData);n.indices={name:"indices",type:r.indexType,values:c.toString()}}return n}_getBufferOrConstantValues(n,r){let c=Md.getTypedArrayConstructor(r);return(n instanceof cs?new c(n.debugData):n).toString()}_getNonMaterialBindings(n){if(!this.material)return n;let r={};for(let[c,u]of Object.entries(n))this.material.ownsBinding(c)||(r[c]=u);return r}_getCurrentShaderLayout(){return this.pipeline?.shaderLayout||this.props.shaderLayout||{bindings:[]}}_syncDynamicBuffers(){if(this._dynamicIndexBufferSource&&this._dynamicIndexBufferSource.generation!==this._dynamicIndexBufferSource.source.generation){let n=this._dynamicIndexBufferSource.source.buffer;this.indexBuffer=n,this.vertexArray.setIndexBuffer(n),this._dynamicIndexBufferSource.generation=this._dynamicIndexBufferSource.source.generation,this.setNeedsRedraw("dynamic index buffer")}for(let[n,r]of Object.entries(this._dynamicAttributeBufferSources))r.generation!==r.source.generation&&(this.vertexArray.setBuffer(Number(n),r.source.buffer),r.generation=r.source.generation,this.setNeedsRedraw("dynamic attribute buffer"))}_syncAttachmentFormats(n){if(this.device.type!=="webgpu")return;let r=n.framebuffer||n.props.framebuffer,c=n.props,u=c.colorAttachmentFormats??r?.colorAttachments?.map(b=>ken(b?.texture?.format)),d=c.depthStencilAttachmentFormat===!1?void 0:c.depthStencilAttachmentFormat??Ren(r?.depthStencilAttachment?.texture?.format);(!dB(this._colorAttachmentFormats,u,1)||this._depthStencilAttachmentFormat!==d)&&(this._colorAttachmentFormats=u,this._depthStencilAttachmentFormat=d,this._setPipelineNeedsUpdate("attachment formats"))}}});var Den,Ben,fp,f1t=Ve(()=>{Vr();vm();$ke();Den=35980,Ben=35981,fp=class s{device;model;transformFeedback;static defaultProps={...Vh.defaultProps,feedbackBufferMode:"separate",outputs:void 0,feedbackBuffers:void 0};static isSupported(n){return n?.info?.type==="webgl"}constructor(n,r=s.defaultProps){if(!s.isSupported(n))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=n,this.model=new Vh(this.device,{id:r.id||"buffer-transform-model",fs:r.fs||v4e(),topology:r.topology||"point-list",varyings:r.outputs||r.varyings,...r,bufferMode:r.bufferMode||(r.feedbackBufferMode==="interleaved"?Den:Ben)}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:r.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(n){n?.inputBuffers&&this.model.setAttributes(n.inputBuffers),n?.outputBuffers&&this.transformFeedback.setBuffers(n.outputBuffers);let r=this.device.beginRenderPass({discard:!0,...n});this.model.draw(r),r.end()}getBuffer(n){return this.transformFeedback.getBuffer(n)}readAsync(n){let r=this.getBuffer(n);if(!r)throw new Error("BufferTransform#getBuffer");if(r instanceof cs)return r.readAsync();let{buffer:c,byteOffset:u=0,byteLength:d=c.byteLength}=r;return c.readAsync(u,d)}}});function Nen(s){return{type:s.type,shaderLanguage:s.info.shadingLanguage,shaderLanguageVersion:s.info.shadingLanguageVersion,gpu:s.info.gpu,limits:s.limits,features:s.features}}var Vke,Oen,G1,h1t=Ve(()=>{Vr();vm();sLe();Fke();Dke();hB();Vke=2,Oen=1e4,G1=class s{static defaultProps={...GM.defaultProps,id:"unnamed",handle:void 0,userData:{},source:"",modules:[],defines:{},plugins:[],bindings:void 0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,shaderAssembler:Tb.getDefaultShaderAssembler("wgsl"),debugShaders:void 0};device;id;pipelineFactory;shaderFactory;userData={};bindings={};pipeline;source;shader;shaderInputs;_uniformStore;_pipelineNeedsUpdate="newly created";_getModuleUniforms;props;_destroyed=!1;constructor(n,r){if(n.type!=="webgpu")throw new Error("Computation is only supported in WebGPU");this.props={...s.defaultProps,...r},r=this.props,this.id=r.id||Qy("model"),this.device=n,Object.assign(this.userData,r.userData);let c=Nen(n),u=P$(this.props.plugins,c.shaderLanguage);if(Object.keys(u.vertexInputs).length>0||Object.keys(u.varyings).length>0)throw new Error("Computation does not support ShaderPlugin vertex inputs or varyings");let d=L$(this.props.modules,u.modules),b=Object.fromEntries(d.map(D=>[D.name,D]));this.shaderInputs=r.shaderInputs||new mB(b),r.shaderInputs&&u.modules.length>0&&this.shaderInputs.addModules(u.modules),this.setShaderInputs(this.shaderInputs);let w=Tle(this.props.modules,this.shaderInputs?.getModules()),_={...u.defines,...this.props.defines};this.props.shaderLayout=gB(this.props.shaderLayout,w)||null,this.pipelineFactory=r.pipelineFactory||i4.getDefaultPipelineFactory(this.device),this.shaderFactory=r.shaderFactory||r4.getDefaultShaderFactory(this.device);let x=this.props.shaderAssembler;FM(x instanceof $M);let{source:T,getUniforms:M,shaderLayout:L}=x.assembleWGSLShader({platformInfo:c,...this.props,modules:w,defines:_,scanVertexAttributes:!1,pluginInjections:u.injections});this.source=T,this._getModuleUniforms=M;let I=L??n.getShaderLayout?.(this.source,{scanVertexAttributes:!1});this.props.shaderLayout=gB(this.props.shaderLayout||I||null,w)||null,this.pipeline=this._updatePipeline(),r.bindings&&this.setBindings(r.bindings)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.shader),this._uniformStore.destroy(),this._destroyed=!0)}predraw(n){this.updateShaderInputs(n)}dispatch(n,r,c,u){try{this._logDrawCallStart(),this._setPipeline(n),n.dispatch(r,c,u)}finally{this._logDrawCallEnd()}}dispatchIndirect(n,r,c=0){try{this._logDrawCallStart(),this._setPipeline(n),n.dispatchIndirect(r,c)}finally{this._logDrawCallEnd()}}_setPipeline(n){this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings),n.setPipeline(this.pipeline),n.setBindings({})}setVertexCount(n){}setInstanceCount(n){}setShaderInputs(n){this.shaderInputs=n,this._uniformStore=new a4(this.device,this.shaderInputs.modules);for(let[r,c]of Object.entries(this.shaderInputs.modules))if(rV(c)){let u=this._uniformStore.getManagedUniformBuffer(r);this.bindings[`${r}Uniforms`]=u}}setShaderModuleProps(n){let r=this._getModuleUniforms(n),c=Object.keys(r).filter(d=>{let b=r[d];return!r$(b)&&typeof b!="number"&&typeof b!="boolean"}),u={};for(let d of c)u[d]=r[d],delete r[d]}updateShaderInputs(n){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),n)}setBindings(n){Object.assign(this.bindings,n)}_setPipelineNeedsUpdate(n){this._pipelineNeedsUpdate=this._pipelineNeedsUpdate||n}_updatePipeline(){if(this._pipelineNeedsUpdate){let n=null;this.pipeline&&(Qt.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),n=this.shader),this._pipelineNeedsUpdate=!1,this.shader=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"compute",source:this.source,debugShaders:this.props.debugShaders}),this.pipeline=this.pipelineFactory.createComputePipeline({...this.props,shader:this.shader}),n&&this.shaderFactory.release(n)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let n=Qt.level>3?0:Oen;Qt.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:Qt.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let n=this.shaderInputs.getDebugTable();Qt.table(Vke,n)(),Qt.groupEnd(Vke)(),this._logOpen=!1}}_drawCount=0;_getBufferOrConstantValues(n,r){let c=Md.getTypedArrayConstructor(r);return(n instanceof cs?new c(n.debugData):n).toString()}}});var Ql=Ve(()=>{Fmt();$mt();$ke();f1t();Sle();zke();h1t()});function C1t(s=!0){let n=HTMLCanvasElement.prototype;if(!s&&n.originalGetContext){n.getContext=n.originalGetContext,n.originalGetContext=void 0;return}n.originalGetContext=n.getContext,n.getContext=function(r,c){if(r==="webgl"||r==="experimental-webgl"){let u=this.originalGetContext("webgl2",c);return u instanceof HTMLElement&&ptn(u),u}return this.originalGetContext(r,c)}}function ptn(s){s.getExtension("EXT_color_buffer_float");let n={...utn,WEBGL_disjoint_timer_query:s.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:ftn(s),OES_vertex_array_object:htn(s),ANGLE_instanced_arrays:dtn(s)},r=s.getExtension.bind(s);s.getExtension=function(u){let d=r(u);return d||(u in n?n[u]:null)};let c=s.getSupportedExtensions;s.getSupportedExtensions=function(){return(c.apply(s)||[])?.concat(Object.keys(n))}}var utn,ftn,htn,dtn,A1t=Ve(()=>{utn={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},ftn=s=>({drawBuffersWEBGL(n){return s.drawBuffers(n)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),htn=s=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return s.createVertexArray()},deleteVertexArrayOES(n){return s.deleteVertexArray(n)},isVertexArrayOES(n){return s.isVertexArray(n)},bindVertexArrayOES(n){return s.bindVertexArray(n)}}),dtn=s=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...n){return s.drawArraysInstanced(...n)},drawElementsInstancedANGLE(...n){return s.drawElementsInstanced(...n)},vertexAttribDivisorANGLE(...n){return s.vertexAttribDivisor(...n)}})});async function L1t(){if(!Dle){tRe();return}await Dle.load()}function k1t(s,n){return Dle?Dle.makeDebugContext(s,n):(tRe(),s)}async function R1t(s){if(!eRe){tRe();return}await eRe.load(s)}function I1t(s){return eRe?.initialize(s)||null}function tRe(){P1t||(P1t=!0,Qt.warn("Import @luma.gl/webgl/debug before enabling WebGL debugging.")())}var Dle,eRe,P1t,nRe=Ve(()=>{Vr();Dle=null,eRe=null,P1t=!1});function iRe(s){return Array.isArray(s)||ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Iu(s,n,r){return n[s]!==void 0?n[s]:r[s]}var xV,Ff,D1t,j1,B1t,yV,O1t,N1t,rRe,r2,sRe,F1t,oRe=Ve(()=>{xV={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},Ff=(s,n,r)=>n?s.enable(r):s.disable(r),D1t=(s,n,r)=>s.hint(r,n),j1=(s,n,r)=>s.pixelStorei(r,n),B1t=(s,n,r)=>{let c=r===36006?36009:36008;return s.bindFramebuffer(c,n)},yV=(s,n,r)=>{let u={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[r];s.bindBuffer(u,n)};O1t={3042:Ff,32773:(s,n)=>s.blendColor(...n),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(s,n)=>s.clearColor(...n),3107:(s,n)=>s.colorMask(...n),2884:Ff,2885:(s,n)=>s.cullFace(n),2929:Ff,2931:(s,n)=>s.clearDepth(n),2932:(s,n)=>s.depthFunc(n),2928:(s,n)=>s.depthRange(...n),2930:(s,n)=>s.depthMask(n),3024:Ff,35723:D1t,35725:(s,n)=>s.useProgram(n),36007:(s,n)=>s.bindRenderbuffer(36161,n),36389:(s,n)=>s.bindTransformFeedback?.(36386,n),34229:(s,n)=>s.bindVertexArray(n),36006:B1t,36010:B1t,34964:yV,36662:yV,36663:yV,35053:yV,35055:yV,2886:(s,n)=>s.frontFace(n),33170:D1t,2849:(s,n)=>s.lineWidth(n),32823:Ff,32824:"polygonOffset",10752:"polygonOffset",35977:Ff,32926:Ff,32928:Ff,32938:"sampleCoverage",32939:"sampleCoverage",3089:Ff,3088:(s,n)=>s.scissor(...n),2960:Ff,2961:(s,n)=>s.clearStencil(n),2968:(s,n)=>s.stencilMaskSeparate(1028,n),36005:(s,n)=>s.stencilMaskSeparate(1029,n),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(s,n)=>s.viewport(...n),34383:Ff,10754:Ff,12288:Ff,12289:Ff,12290:Ff,12291:Ff,12292:Ff,12293:Ff,12294:Ff,12295:Ff,3333:j1,3317:j1,37440:j1,37441:j1,37443:j1,3330:j1,3332:j1,3331:j1,3314:j1,32878:j1,3316:j1,3315:j1,32877:j1,framebuffer:(s,n)=>{let r=n&&"handle"in n?n.handle:n;return s.bindFramebuffer(36160,r)},blend:(s,n)=>n?s.enable(3042):s.disable(3042),blendColor:(s,n)=>s.blendColor(...n),blendEquation:(s,n)=>{let r=typeof n=="number"?[n,n]:n;s.blendEquationSeparate(...r)},blendFunc:(s,n)=>{let r=n?.length===2?[...n,...n]:n;s.blendFuncSeparate(...r)},clearColor:(s,n)=>s.clearColor(...n),clearDepth:(s,n)=>s.clearDepth(n),clearStencil:(s,n)=>s.clearStencil(n),colorMask:(s,n)=>s.colorMask(...n),cull:(s,n)=>n?s.enable(2884):s.disable(2884),cullFace:(s,n)=>s.cullFace(n),depthTest:(s,n)=>n?s.enable(2929):s.disable(2929),depthFunc:(s,n)=>s.depthFunc(n),depthMask:(s,n)=>s.depthMask(n),depthRange:(s,n)=>s.depthRange(...n),dither:(s,n)=>n?s.enable(3024):s.disable(3024),derivativeHint:(s,n)=>{s.hint(35723,n)},frontFace:(s,n)=>s.frontFace(n),mipmapHint:(s,n)=>s.hint(33170,n),lineWidth:(s,n)=>s.lineWidth(n),polygonOffsetFill:(s,n)=>n?s.enable(32823):s.disable(32823),polygonOffset:(s,n)=>s.polygonOffset(...n),sampleCoverage:(s,n)=>s.sampleCoverage(n[0],n[1]||!1),scissorTest:(s,n)=>n?s.enable(3089):s.disable(3089),scissor:(s,n)=>s.scissor(...n),stencilTest:(s,n)=>n?s.enable(2960):s.disable(2960),stencilMask:(s,n)=>{n=iRe(n)?n:[n,n];let[r,c]=n;s.stencilMaskSeparate(1028,r),s.stencilMaskSeparate(1029,c)},stencilFunc:(s,n)=>{n=iRe(n)&&n.length===3?[...n,...n]:n;let[r,c,u,d,b,w]=n;s.stencilFuncSeparate(1028,r,c,u),s.stencilFuncSeparate(1029,d,b,w)},stencilOp:(s,n)=>{n=iRe(n)&&n.length===3?[...n,...n]:n;let[r,c,u,d,b,w]=n;s.stencilOpSeparate(1028,r,c,u),s.stencilOpSeparate(1029,d,b,w)},viewport:(s,n)=>s.viewport(...n)};N1t={blendEquation:(s,n,r)=>s.blendEquationSeparate(Iu(32777,n,r),Iu(34877,n,r)),blendFunc:(s,n,r)=>s.blendFuncSeparate(Iu(32969,n,r),Iu(32968,n,r),Iu(32971,n,r),Iu(32970,n,r)),polygonOffset:(s,n,r)=>s.polygonOffset(Iu(32824,n,r),Iu(10752,n,r)),sampleCoverage:(s,n,r)=>s.sampleCoverage(Iu(32938,n,r),Iu(32939,n,r)),stencilFuncFront:(s,n,r)=>s.stencilFuncSeparate(1028,Iu(2962,n,r),Iu(2967,n,r),Iu(2963,n,r)),stencilFuncBack:(s,n,r)=>s.stencilFuncSeparate(1029,Iu(34816,n,r),Iu(36003,n,r),Iu(36004,n,r)),stencilOpFront:(s,n,r)=>s.stencilOpSeparate(1028,Iu(2964,n,r),Iu(2965,n,r),Iu(2966,n,r)),stencilOpBack:(s,n,r)=>s.stencilOpSeparate(1029,Iu(34817,n,r),Iu(34818,n,r),Iu(34819,n,r))},rRe={enable:(s,n)=>s({[n]:!0}),disable:(s,n)=>s({[n]:!1}),pixelStorei:(s,n,r)=>s({[n]:r}),hint:(s,n,r)=>s({[n]:r}),useProgram:(s,n)=>s({35725:n}),bindRenderbuffer:(s,n,r)=>s({36007:r}),bindTransformFeedback:(s,n,r)=>s({36389:r}),bindVertexArray:(s,n)=>s({34229:n}),bindFramebuffer:(s,n,r)=>{switch(n){case 36160:return s({36006:r,36010:r});case 36009:return s({36006:r});case 36008:return s({36010:r});default:return null}},bindBuffer:(s,n,r)=>{let c={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[n];return c?s({[c]:r}):{valueChanged:!0}},blendColor:(s,n,r,c,u)=>s({32773:new Float32Array([n,r,c,u])}),blendEquation:(s,n)=>s({32777:n,34877:n}),blendEquationSeparate:(s,n,r)=>s({32777:n,34877:r}),blendFunc:(s,n,r)=>s({32969:n,32968:r,32971:n,32970:r}),blendFuncSeparate:(s,n,r,c,u)=>s({32969:n,32968:r,32971:c,32970:u}),clearColor:(s,n,r,c,u)=>s({3106:new Float32Array([n,r,c,u])}),clearDepth:(s,n)=>s({2931:n}),clearStencil:(s,n)=>s({2961:n}),colorMask:(s,n,r,c,u)=>s({3107:[n,r,c,u]}),cullFace:(s,n)=>s({2885:n}),depthFunc:(s,n)=>s({2932:n}),depthRange:(s,n,r)=>s({2928:new Float32Array([n,r])}),depthMask:(s,n)=>s({2930:n}),frontFace:(s,n)=>s({2886:n}),lineWidth:(s,n)=>s({2849:n}),polygonOffset:(s,n,r)=>s({32824:n,10752:r}),sampleCoverage:(s,n,r)=>s({32938:n,32939:r}),scissor:(s,n,r,c,u)=>s({3088:new Int32Array([n,r,c,u])}),stencilMask:(s,n)=>s({2968:n,36005:n}),stencilMaskSeparate:(s,n,r)=>s({[n===1028?2968:36005]:r}),stencilFunc:(s,n,r,c)=>s({2962:n,2967:r,2963:c,34816:n,36003:r,36004:c}),stencilFuncSeparate:(s,n,r,c,u)=>s({[n===1028?2962:34816]:r,[n===1028?2967:36003]:c,[n===1028?2963:36004]:u}),stencilOp:(s,n,r,c)=>s({2964:n,2965:r,2966:c,34817:n,34818:r,34819:c}),stencilOpSeparate:(s,n,r,c,u)=>s({[n===1028?2964:34817]:r,[n===1028?2965:34818]:c,[n===1028?2966:34819]:u}),viewport:(s,n,r,c,u)=>s({2978:[n,r,c,u]})},r2=(s,n)=>s.isEnabled(n),sRe={3042:r2,2884:r2,2929:r2,3024:r2,32823:r2,32926:r2,32928:r2,3089:r2,2960:r2,35977:r2},F1t=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068])});function bv(s,n){if(gtn(n))return;let r={};for(let u in n){let d=Number(u),b=O1t[u];b&&(typeof b=="string"?r[b]=!0:b(s,n[u],d))}let c=s.lumaState?.cache;if(c)for(let u in r){let d=N1t[u];d(s,n,c)}}function Ble(s,n=xV){if(typeof n=="number"){let u=n,d=sRe[u];return d?d(s,u):s.getParameter(u)}let r=Array.isArray(n)?n:Object.keys(n),c={};for(let u of r){let d=sRe[u];c[u]=d?d(s,Number(u)):s.getParameter(Number(u))}return c}function U1t(s){bv(s,xV)}function gtn(s){for(let n in s)return!1;return!0}var _B=Ve(()=>{oRe()});function G1t(s,n){if(s===n)return!0;if(z1t(s)&&z1t(n)&&s.length===n.length){for(let r=0;r{});function $1t(s,n){let r=s[n].bind(s);s[n]=function(u){if(u===void 0||F1t.has(u))return r(u);let d=wv.get(s);return u in d.cache||(d.cache[u]=r(u)),d.enable?d.cache[u]:r(u)},Object.defineProperty(s[n],"name",{value:`${n}-from-cache`,configurable:!1})}function mtn(s,n,r){if(!s[n])return;let c=s[n].bind(s);s[n]=function(...d){let b=wv.get(s),{valueChanged:w,oldValue:_}=r(b._updateCache,...d);return w&&c(...d),_},Object.defineProperty(s[n],"name",{value:`${n}-to-cache`,configurable:!1})}function btn(s){let n=s.useProgram.bind(s);s.useProgram=function(c){let u=wv.get(s);u.program!==c&&(n(c),u.program=c)}}var wv,aRe=Ve(()=>{_B();j1t();oRe();wv=class{static get(n){return n.lumaState}gl;program=null;stateStack=[];enable=!0;cache=null;log;initialized=!1;constructor(n,r){this.gl=n,this.log=r?.log||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(n={}){this.stateStack.push({})}pop(){let n=this.stateStack[this.stateStack.length-1];bv(this.gl,n),this.stateStack.pop()}trackState(n,r){if(this.cache=r?.copyState?Ble(n):Object.assign({},xV),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.lumaState=this,btn(n);for(let c in rRe){let u=rRe[c];mtn(n,c,u)}$1t(n,"getParameter"),$1t(n,"isEnabled")}_updateCache(n){let r=!1,c,u=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let d in n){let b=n[d],w=this.cache[d];G1t(b,w)||(r=!0,c=w,u&&!(d in u)&&(u[d]=w),this.cache[d]=b)}return{valueChanged:r,oldValue:c}}}});function EV(s){let n=s.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return n._polyfilled??=!1,n.extensions||={},s.luma=n,n}var cRe=Ve(()=>{});function V1t(s,n,r){let c="",u=_=>{let x=_.statusMessage;x&&(c||=x)};s.addEventListener("webglcontextcreationerror",u,!1);let d=r.failIfMajorPerformanceCaveat!==!0,b={preserveDrawingBuffer:!0,...r,failIfMajorPerformanceCaveat:!0},w=null;try{w||=s.getContext("webgl2",b),!w&&b.failIfMajorPerformanceCaveat&&(c||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.");let _=!1;if(!w&&d&&(b.failIfMajorPerformanceCaveat=!1,w=s.getContext("webgl2",b),_=!0),w||(w=s.getContext("webgl",{}),w&&(w=null,c||="Your browser only supports WebGL1")),!w)throw c||="Your browser does not support WebGL",new Error(`Failed to create WebGL context: ${c}`);let x=EV(w);x.softwareRenderer=_;let{onContextLost:T,onContextRestored:M}=n;return s.addEventListener("webglcontextlost",L=>T(L),!1),s.addEventListener("webglcontextrestored",L=>M(L),!1),w}finally{s.removeEventListener("webglcontextcreationerror",u,!1)}}var W1t=Ve(()=>{cRe()});function vv(s,n,r){return r[n]===void 0&&(r[n]=s.getExtension(n)||null),r[n]}var SV=Ve(()=>{});function H1t(s,n){let r=s.getParameter(7936),c=s.getParameter(7937);vv(s,"WEBGL_debug_renderer_info",n);let u=n.WEBGL_debug_renderer_info,d=s.getParameter(u?u.UNMASKED_VENDOR_WEBGL:7936),b=s.getParameter(u?u.UNMASKED_RENDERER_WEBGL:7937),w=d||r,_=b||c,x=s.getParameter(7938),T=q1t(w,_),M=wtn(w,_),L=vtn(w,_);return{type:"webgl",gpu:T,gpuType:L,gpuBackend:M,vendor:w,renderer:_,version:x,shadingLanguage:"glsl",shadingLanguageVersion:300}}function q1t(s,n){return/NVIDIA/i.exec(s)||/NVIDIA/i.exec(n)?"nvidia":/INTEL/i.exec(s)||/INTEL/i.exec(n)?"intel":/Apple/i.exec(s)||/Apple/i.exec(n)?"apple":/AMD/i.exec(s)||/AMD/i.exec(n)||/ATI/i.exec(s)||/ATI/i.exec(n)?"amd":/SwiftShader/i.exec(s)||/SwiftShader/i.exec(n)?"software":"unknown"}function wtn(s,n){return/Metal/i.exec(s)||/Metal/i.exec(n)?"metal":/ANGLE/i.exec(s)||/ANGLE/i.exec(n)?"opengl":"unknown"}function vtn(s,n){if(/SwiftShader/i.exec(s)||/SwiftShader/i.exec(n))return"cpu";switch(q1t(s,n)){case"apple":return _tn(s,n)?"integrated":"unknown";case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function _tn(s,n){return/Apple (M\d|A\d|GPU)/i.test(`${s} ${n}`)}var X1t=Ve(()=>{SV()});function Ole(s){switch(s){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(s))}var lRe=Ve(()=>{});function K1t(s){return s in Fle}function pRe(s,n,r){return J1t(s,n,r,new Set)}function J1t(s,n,r,c){let u=Fle[n];if(!u||c.has(n))return!1;c.add(n);let d=(u.features||[]).every(b=>J1t(s,b,r,c));return c.delete(n),d?(u.extensions||[]).every(b=>!!vv(s,b,r)):!1}function Q1t(s,n,r){let c=n.create,u=Ule[n.format];u?.gl===void 0&&(c=!1),u?.x&&(c=c&&!!vv(s,u.x,r)),n.format==="stencil8"&&(c=!1);let d=u?.r===!1?!1:u?.r===void 0||pRe(s,u.r,r),b=c&&n.render&&d&&Atn(s,n.format,r);return{format:n.format,create:c&&n.create,render:b,filter:c&&n.filter,blend:c&&n.blend,store:c&&n.store}}function Atn(s,n,r){let c=Ule[n],u=c?.gl;if(u===void 0||c?.x&&!vv(s,c.x,r))return!1;let d=s.getParameter(32873),b=s.getParameter(36006),w=s.createTexture(),_=s.createFramebuffer();if(!w||!_)return!1;let x=0,T=Number(s.getError());for(;T!==x;)T=s.getError();let M=!1;try{if(s.bindTexture(3553,w),s.texStorage2D(3553,1,u,1,1),Number(s.getError())!==x)return!1;s.bindFramebuffer(36160,_),s.framebufferTexture2D(36160,36064,3553,w,0),M=Number(s.checkFramebufferStatus(36160))===36053&&Number(s.getError())===x}finally{s.bindFramebuffer(36160,b),s.deleteFramebuffer(_),s.bindTexture(3553,d),s.deleteTexture(w)}return M}function zle(s){let n=Ule[s],r=Ltn(s),c=og.getInfo(s);return c.compressed&&(n.dataFormat=r),{internalFormat:r,format:n?.dataFormat||Ptn(c.channels,c.integer,c.normalized,r),type:c.dataType?Ole(c.dataType):n?.types?.[0]||5121,compressed:c.compressed||!1}}function e0t(s){switch(og.getInfo(s).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${s}`)}}function Ptn(s,n,r,c){if(c===6408||c===6407)return c;switch(s){case"r":return n&&!r?36244:6403;case"rg":return n&&!r?33320:33319;case"rgb":return n&&!r?36248:6407;case"rgba":return n&&!r?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function Ltn(s){let r=Ule[s]?.gl;if(r===void 0)throw new Error(`Unsupported texture format ${s}`);return r}var MV,TV,yB,xB,ytn,xtn,Etn,Stn,Mtn,Ttn,Y1t,Z1t,uRe,fRe,hRe,dRe,Nle,Ctn,Fle,Ule,EB=Ve(()=>{Vr();SV();lRe();MV="WEBGL_compressed_texture_s3tc",TV="WEBGL_compressed_texture_s3tc_srgb",yB="EXT_texture_compression_rgtc",xB="EXT_texture_compression_bptc",ytn="WEBGL_compressed_texture_etc",xtn="WEBGL_compressed_texture_astc",Etn="WEBGL_compressed_texture_etc1",Stn="WEBGL_compressed_texture_pvrtc",Mtn="WEBGL_compressed_texture_atc",Ttn="EXT_texture_norm16",Y1t="EXT_render_snorm",Z1t="EXT_color_buffer_float",uRe="snorm8-renderable-webgl",fRe="norm16-renderable-webgl",hRe="snorm16-renderable-webgl",dRe="float16-renderable-webgl",Nle="float32-renderable-webgl",Ctn="rgb9e5ufloat-renderable-webgl",Fle={"float32-renderable-webgl":{extensions:[Z1t]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[Y1t]},"norm16-webgl":{extensions:[Ttn]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[Y1t]},"float32-filterable":{extensions:["OES_texture_float_linear"]},"float16-filterable-webgl":{extensions:["OES_texture_half_float_linear"]},"texture-filterable-anisotropic-webgl":{extensions:["EXT_texture_filter_anisotropic"]},"texture-blend-float-webgl":{extensions:["EXT_float_blend"]},"texture-compression-bc":{extensions:[MV,TV,yB,xB]},"texture-compression-bc5-webgl":{extensions:[yB]},"texture-compression-bc7-webgl":{extensions:[xB]},"texture-compression-etc2":{extensions:[ytn]},"texture-compression-astc":{extensions:[xtn]},"texture-compression-etc1-webgl":{extensions:[Etn]},"texture-compression-pvrtc-webgl":{extensions:[Stn]},"texture-compression-atc-webgl":{extensions:[Mtn]}};Ule={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:uRe},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:uRe},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0,r:dRe},r16unorm:{gl:33322,rb:!0,r:fRe},r16snorm:{gl:36760,r:hRe},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759,r:uRe},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:dRe},rg16unorm:{gl:33324,r:fRe},rg16snorm:{gl:36761,r:hRe},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:Nle},rgb9e5ufloat:{gl:35901,r:Ctn},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852,r:!1},"rgb16snorm-webgl":{gl:36762,r:!1},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0,r:Nle},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:dRe},rgba16unorm:{gl:32859,rb:!0,r:fRe},rgba16snorm:{gl:36763,r:hRe},"rgb32float-webgl":{gl:34837,x:Z1t,r:Nle,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:Nle},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:MV},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:TV},"bc1-rgba-unorm":{gl:33777,x:MV},"bc1-rgba-unorm-srgb":{gl:35916,x:TV},"bc2-rgba-unorm":{gl:33778,x:MV},"bc2-rgba-unorm-srgb":{gl:35918,x:TV},"bc3-rgba-unorm":{gl:33779,x:MV},"bc3-rgba-unorm-srgb":{gl:35919,x:TV},"bc4-r-unorm":{gl:36283,x:yB},"bc4-r-snorm":{gl:36284,x:yB},"bc5-rg-unorm":{gl:36285,x:yB},"bc5-rg-snorm":{gl:36286,x:yB},"bc6h-rgb-ufloat":{gl:36495,x:xB},"bc6h-rgb-float":{gl:36494,x:xB},"bc7-rgba-unorm":{gl:36492,x:xB},"bc7-rgba-unorm-srgb":{gl:36493,x:xB},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37816},"astc-10x5-unorm-srgb":{gl:37848},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rgb2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}}});var t0t,Gle,n0t=Ve(()=>{Vr();SV();EB();t0t={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","html-in-canvas":s=>GLe()&&typeof s.texElementImage2D=="function","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},Gle=class extends p${gl;extensions;testedFeatures=new Set;constructor(n,r,c){super([],c),this.gl=n,this.extensions=r,vv(n,"EXT_color_buffer_float",r)}*[Symbol.iterator](){let n=this.getFeatures();for(let r of n)this.has(r)&&(yield r);return[]}has(n){return this.disabledFeatures?.[n]?!1:(this.testedFeatures.has(n)||(this.testedFeatures.add(n),K1t(n)&&pRe(this.gl,n,this.extensions)&&this.features.add(n),this.getWebGLFeature(n)&&this.features.add(n)),this.features.has(n))}initializeFeatures(){let n=this.getFeatures().filter(r=>r!=="polygon-mode-webgl");for(let r of n)this.has(r)}getFeatures(){return[...Object.keys(t0t),...Object.keys(Fle)]}getWebGLFeature(n){let r=t0t[n];return typeof r=="string"?!!vv(this.gl,r,this.extensions):typeof r=="function"?r(this.gl):!!r}}});var jle,i0t=Ve(()=>{Vr();jle=class extends d${get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxBindGroupsPlusVertexBuffers(){return 0}get maxBindingsPerBindGroup(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageBuffersInVertexStage(){return 0}get maxStorageBuffersInFragmentStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxStorageTexturesInVertexStage(){return 0}get maxStorageTexturesInFragmentStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get maxBufferSize(){return Number.MAX_SAFE_INTEGER}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxColorAttachments(){return this.getParameter(36063)}get maxColorAttachmentBytesPerSample(){return 0}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(n){super(),this.gl=n}getParameter(n){return this.limits[n]===void 0&&(this.limits[n]=this.gl.getParameter(n)),this.limits[n]||0}}});function ktn(s){return s<34069?s+34069:s}function Rtn(s){switch(s){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${s}`}}var s2,$le=Ve(()=>{Vr();EB();s2=class extends n4{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(n,r){super(n,r);let c=r.handle,u=c===null;this.device=n,this.gl=n.gl,this.handle=c||u?c:this.gl.createFramebuffer(),u||(n._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),r.handle||(this.autoCreateAttachmentTextures(),this.updateAttachments()))}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&!this.props.handle&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){let n=this.gl.bindFramebuffer(36160,this.handle);for(let r=0;r{Vr();$le();Vle=class extends g${device;handle=null;_framebuffer=null;get[Symbol.toStringTag](){return"WebGLCanvasContext"}constructor(n,r){super(r),this.device=n,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._configureDevice()}_configureDevice(){(this.drawingBufferWidth!==this._framebuffer?.width||this.drawingBufferHeight!==this._framebuffer?.height)&&this._framebuffer?.resize([this.drawingBufferWidth,this.drawingBufferHeight])}_getCurrentFramebuffer(){return this._framebuffer||=new s2(this.device,{id:"canvas-context-framebuffer",handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}}});var Wle,s0t=Ve(()=>{Vr();Wle=class extends m${device;handle=null;context2d;get[Symbol.toStringTag](){return"WebGLPresentationContext"}constructor(n,r={}){super(r),this.device=n;let c=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw new Error(`${c}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);let d=this.canvas.getContext("2d");if(!d)throw new Error(`${c}: Failed to create 2d presentation context`);this.context2d=d,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();let n=this.device.getDefaultCanvasContext(),[r,c]=n.getDrawingBufferSize();if(!(this.drawingBufferWidth===0||this.drawingBufferHeight===0||r===0||c===0||n.canvas.width===0||n.canvas.height===0)){if(r!==this.drawingBufferWidth||c!==this.drawingBufferHeight||n.canvas.width!==this.drawingBufferWidth||n.canvas.height!==this.drawingBufferHeight)throw new Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${r}x${c} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(n.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(n){let r=this.device.getDefaultCanvasContext();return r.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),r.getCurrentFramebuffer(n)}}});function o0t(s="id"){gRe[s]=gRe[s]||1;let n=gRe[s]++;return`${s}-${n}`}var gRe,a0t=Ve(()=>{gRe={}});function Itn(s){return s&cs.INDEX?34963:s&cs.VERTEX?34962:s&cs.UNIFORM?35345:34962}function Dtn(s){return s&cs.INDEX||s&cs.VERTEX?35044:s&cs.UNIFORM?35048:35044}var _v,Hle=Ve(()=>{Vr();_v=class extends cs{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength=0;bytesUsed=0;constructor(n,r={}){super(n,r),this.device=n,this.gl=this.device.gl;let c=typeof r=="object"?r.handle:void 0;this.handle=c||this.gl.createBuffer(),n._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=Itn(this.props.usage),this.glUsage=Dtn(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,r.data?this._initWithData(r.data,r.byteOffset,r.byteLength):this._initWithByteLength(r.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Buffer"):(this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle)),this.destroyed=!0,this.handle=null)}_initWithData(n,r=0,c=n.byteLength+r){let u=this.glTarget;this.gl.bindBuffer(u,this.handle),this.gl.bufferData(u,c,this.glUsage),this.gl.bufferSubData(u,r,n),this.gl.bindBuffer(u,null),this.bytesUsed=c,this.byteLength=c,this._setDebugData(n,r,c),this.props.handle?this.trackReferencedMemory(c,"Buffer"):this.trackAllocatedMemory(c)}_initWithByteLength(n){let r=n;n===0&&(r=new Float32Array(0));let c=this.glTarget;return this.gl.bindBuffer(c,this.handle),this.gl.bufferData(c,r,this.glUsage),this.gl.bindBuffer(c,null),this.bytesUsed=n,this.byteLength=n,this._setDebugData(null,0,n),this.props.handle?this.trackReferencedMemory(n,"Buffer"):this.trackAllocatedMemory(n),this}write(n,r=0){let c=ArrayBuffer.isView(n)?n:new Uint8Array(n),u=0,d=void 0,b=36663;this.gl.bindBuffer(b,this.handle),u!==0||d!==void 0?this.gl.bufferSubData(b,r,c,u,d):this.gl.bufferSubData(b,r,c),this.gl.bindBuffer(b,null),this._setDebugData(n,r,n.byteLength)}async mapAndWriteAsync(n,r=0,c=this.byteLength-r){let u=new ArrayBuffer(c);await n(u,"copied"),this.write(u,r)}async readAsync(n=0,r){return this.readSyncWebGL(n,r)}async mapAndReadAsync(n,r=0,c){let u=await this.readAsync(r,c);return await n(u.buffer,"copied")}readSyncWebGL(n=0,r){r=r??this.byteLength-n;let c=new Uint8Array(r),u=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,n,c,u,r),this.gl.bindBuffer(36662,null),this._setDebugData(c,n,r),c}}});function c0t(s){let n=s.split(/\r?\n/),r=[];for(let c of n){if(c.length<=1)continue;let u=c.trim(),d=c.split(":"),b=d[0]?.trim();if(d.length===2){let[I,D]=d;if(!I||!D){r.push({message:u,type:qle(b||"info"),lineNum:0,linePos:0});continue}r.push({message:D.trim(),type:qle(I),lineNum:0,linePos:0});continue}let[w,_,x,...T]=d;if(!w||!_||!x){r.push({message:d.slice(1).join(":").trim()||u,type:qle(b||"info"),lineNum:0,linePos:0});continue}let M=parseInt(x,10);Number.isNaN(M)&&(M=0);let L=parseInt(_,10);Number.isNaN(L)&&(L=0),r.push({message:T.join(":").trim(),type:qle(w),lineNum:M,linePos:L})}return r}function qle(s){let n=["warning","error","info"],r=s.toLowerCase();return n.includes(r)?r:"info"}var l0t=Ve(()=>{});function Btn(s){return s.split(/\r?\n/).find(n=>n.trim())?.trim()}var Xle,u0t=Ve(()=>{Vr();l0t();Xle=class extends t4{device;handle;_compilationInfoLog="";constructor(n,r){super(n,r),this.device=n;let c=this.props.handle;switch(this.props.stage){case"vertex":this.handle=c||this.device.gl.createShader(35633);break;case"fragment":this.handle=c||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}n._setWebGLDebugMetadata(this.handle,this,{spector:this.props});let u=this._compile(this.source);u&&typeof u.catch=="function"&&u.catch(()=>{this.compilationStatus="error"})}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let n=this._getCompilationInfoLog();return n?c0t(n):[]}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)||null}_compile(n){n=n.startsWith("#version ")?n:`#version 300 es +`});var aJt,ZD,Ggt=Ve(()=>{Agt();Bgt();Fgt();zgt();aJt=[38.25,38.25,38.25],ZD={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:Ngt.replace("phongMaterial","gouraudMaterial"),fs:Ogt.replace("phongMaterial","gouraudMaterial"),source:Ugt.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[Igt,Cgt],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:aJt},getUniforms(s){return{...ZD.defaultUniforms,...s}}}});var vm=Ve(()=>{ELe();Ddt();c4e();ppt();mpt();bgt();Egt();Pgt();Ggt()});function Qy(s="id"){Ike[s]=Ike[s]||1;let n=Ike[s]++;return`${s}-${n}`}var Ike,hB=Ve(()=>{Ike={}});function y4(s){switch(s){case"POSITION":return"positions";case"NORMAL":return"normals";case"TEXCOORD_0":return"texCoords";case"TEXCOORD_1":return"texCoords1";case"COLOR_0":return"colors";default:return s}}function ien(s){let n=[];for(let[r,c]of Object.entries(s)){if(!c)continue;let{value:u,size:d,normalized:b}=c;if(d===void 0)throw new Error(`Attribute ${r} is missing a size`);n.push({name:y4(r),format:hl.getVertexFormatFromAttribute(u,d,b)})}return n}var Lb,Sle=Ve(()=>{Vr();hB();Lb=class{id;topology;vertexCount;indices;attributes;bufferLayout;userData={};constructor(n){let{attributes:r={},indices:c=null,vertexCount:u=null}=n;this.id=n.id||Qy("geometry"),this.topology=n.topology,c&&(this.indices=ArrayBuffer.isView(c)?{value:c,size:1}:c),this.attributes={};for(let[d,b]of Object.entries(r)){let w=ArrayBuffer.isView(b)?{value:b}:b;if(!ArrayBuffer.isView(w.value))throw new Error(`${this._print(d)}: must be typed array or object with value as typed array`);if((d==="POSITION"||d==="positions")&&!w.size&&(w.size=3),d==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=w}else{let _=y4(d),x=Object.keys(this.attributes).find(T=>y4(T)===_);x&&delete this.attributes[x],this.attributes[d]=w}}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=u||this._calculateVertexCount(this.attributes,this.indices),this.bufferLayout=n.bufferLayout||ien(this.attributes)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(n){return`Geometry ${this.id} attribute ${n}`}_setAttributes(n,r){return this}_calculateVertexCount(n,r){if(r)return r.value.length;let c=1/0;for(let u of Object.values(n)){if(!u)continue;let{value:d,size:b,constant:w}=u;!w&&d&&b!==void 0&&b>=1&&(c=Math.min(c,d.length/b))}return c}}});function Omt(s,n={}){let r=n.bufferName||"geometry";if(ren(s,r))return s;let c=n.minAttributeAlignment||4,u=sen(s,n.attributes),d=[],b=0,w=1/0;for(let[T,M]of u){if(!M)continue;if(M.constant)throw new Error(`Attribute ${T} is constant`);let{value:L,size:I,normalized:D}=M;if(!ArrayBuffer.isView(L))throw new Error(`Attribute ${T} is missing typed array data`);if(I===void 0)throw new Error(`Attribute ${T} is missing a size`);let F=hl.getVertexFormatFromAttribute(L,I,D),O=hl.getVertexFormatInfo(F);b=Bmt(b,c),d.push({sourceName:T,attributeName:y4(T),value:L,size:I,format:F,byteOffset:b,byteLength:O.byteLength}),b+=O.byteLength;let z=L.length/I;if(!Number.isInteger(z))throw new Error(`Attribute ${T} length is not divisible by size`);w=Math.min(w,z)}if(d.length===0||!Number.isFinite(w))throw new Error(`Geometry ${s.id} has no interleavable attributes`);let _=Bmt(b,c),x=new ArrayBuffer(w*_);for(let T of d)oen(x,w,_,T);return new Lb({id:s.id,topology:s.topology||"triangle-list",vertexCount:s.vertexCount,indices:s.indices,attributes:{[r]:{value:new Uint8Array(x),size:_,byteStride:_}},bufferLayout:[{name:r,stepMode:"vertex",byteStride:_,attributes:d.map(T=>({attribute:T.attributeName,format:T.format,byteOffset:T.byteOffset}))}]})}function ren(s,n){if(s.bufferLayout.length!==1)return!1;let r=s.bufferLayout[0];return r.name===n&&!!r.attributes?.length&&!!s.attributes[n]}function sen(s,n){return n?n.map(r=>[r,s.attributes[r]]):Object.entries(s.attributes)}function oen(s,n,r,c){let u=c.value.constructor,d=u.BYTES_PER_ELEMENT;if(c.byteOffset%d!==0||r%d!==0)throw new Error(`Attribute ${c.sourceName} is not aligned to its component type`);let b=new u(s),w=c.value,_=c.byteOffset/d,x=r/d;for(let T=0;T{Vr();Sle()});var aen,cen,x4,Fmt=Ve(()=>{aen=1,cen=1,x4=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(n){let{delay:r=0,duration:c=Number.POSITIVE_INFINITY,rate:u=1,repeat:d=1}=n,b=aen++,w={time:0,delay:r,duration:c,rate:u,repeat:d};return this._setChannelTime(w,this.time),this.channels.set(b,w),b}removeChannel(n){this.channels.delete(n);for(let[r,c]of this.animations)c.channel===n&&this.detachAnimation(r)}isFinished(n){let r=this.channels.get(n);return r===void 0?!1:this.time>=r.delay+r.duration*r.repeat}getTime(n){if(n===void 0)return this.time;let r=this.channels.get(n);return r===void 0?-1:r.time}setTime(n){this.time=Math.max(0,n);let r=this.channels.values();for(let u of r)this._setChannelTime(u,this.time);let c=this.animations.values();for(let u of c){let{animation:d,channel:b}=u;d.setTime(this.getTime(b))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(n,r){let c=cen++;return this.animations.set(c,{animation:n,channel:r}),n.setTime(this.getTime(r)),c}detachAnimation(n){this.animations.delete(n)}update(n){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=n),this.setTime(this.time+(n-this.lastEngineTime)),this.lastEngineTime=n)}_setChannelTime(n,r){let c=r-n.delay,u=n.duration*n.repeat;c>=u?n.time=n.duration*n.rate:(n.time=Math.max(0,c)%n.duration,n.time*=n.rate)}}});function Umt(s){let n=typeof window<"u"?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame:null;return n?n.call(window,s):setTimeout(()=>s(typeof performance<"u"?performance.now():Date.now()),1e3/60)}function zmt(s){let n=typeof window<"u"?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame:null;if(n){n.call(window,s);return}clearTimeout(s)}var Gmt=Ve(()=>{});var len,uen,jmt,iV,$mt=Ve(()=>{Vr();Gmt();Kj();len=0,uen="Animation Loop",jmt={requestAnimationFrame:s=>Umt(s),cancelAnimationFrame:s=>zmt(s)},iV=class s{static defaultAnimationLoopProps={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:n=>{console.error(n)},stats:void 0,autoResizeViewport:!1,animationFrameProvider:jmt};device=null;canvas=null;props;animationProps=null;timeline=null;stats;sharedStats;cpuTime;gpuTime;frameRate;display;_needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;_lastFrameTime=0;constructor(n){if(this.props={...s.defaultAnimationLoopProps,...n},n=this.props,!n.device)throw new Error("No device provided");this.stats=n.stats||new xb({id:`animation-loop-${len++}`}),this.sharedStats=UD.stats.get(uen),this.frameRate=this.stats.get("Frame Rate"),this.frameRate.setSampleSize(1),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.setProps({autoResizeViewport:n.autoResizeViewport,animationFrameProvider:n.animationFrameProvider}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null),this.device?._disableDebugGPUTime()}delete(){this.destroy()}reportError(n){this._error=n,this.props.onError(n),this.props.onError===s.defaultAnimationLoopProps.onError&&typeof window<"u"&&typeof ErrorEvent<"u"&&window.dispatchEvent(new ErrorEvent("error",{error:n,message:n.message}))}setNeedsRedraw(n){return this._needsRedraw=this._needsRedraw||n,this}needsRedraw(){let n=this._needsRedraw;return this._needsRedraw=!1,n}setProps(n){if("autoResizeViewport"in n&&(this.props.autoResizeViewport=n.autoResizeViewport||!1),"animationFrameProvider"in n){let r=n.animationFrameProvider||jmt;if(r!==this.props.animationFrameProvider){let c=this._animationFrameId!==null;c&&this._cancelAnimationFrame(),this.props.animationFrameProvider=r,c&&this._requestAnimationFrame()}}return this}async start(){if(this._running)return this;this._running=!0;try{let n;if(!this._initialized){if(this._initialized=!0,await this._initDevice(),this._initialize(),!this._running)return null;await this.props.onInitialize(this._getAnimationProps())}return this._running?(n!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(n){let r=n instanceof Error?n:new Error("Unknown error");throw this.props.onError(r),r}}stop(){if(this._running){let n=this.animationProps;this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1,this._lastFrameTime=0,n&&this.props.onFinalize(n)}return this}redraw(n,r=null){return this.device?.isLost||this._error?this:(this._beginFrameTimers(n),this._setupFrame(),this.animationProps&&(this.animationProps.animationFrame=r),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(n){return this.timeline=n,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(n=>{this._resolveNextFrame=n})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeViewport(),this.device?._enableDebugGPUTime()}_setDisplay(n){this.display&&(this.display.destroy(),this.display.animationLoop=null),n&&(n.animationLoop=this),this.display=n}_requestAnimationFrame(){this._running&&(this._animationFrameId=this.props.animationFrameProvider.requestAnimationFrame(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(this.props.animationFrameProvider.cancelAnimationFrame(this._animationFrameId),this._animationFrameId=null)}_animationFrame(n,r){if(this._running)try{this.redraw(n,r??null),this._requestAnimationFrame()}catch(c){let u=c instanceof Error?c:new Error(String(c));this.reportError(u),this.stop()}}_renderFrame(n){if(this.display){this.display._renderFrame(n);return}let r=this.props.onRender(this._getAnimationProps());this.device&&r!==!1&&this.device.submit()}_clearNeedsRedraw(){this._needsRedraw=!1}_setupFrame(){this._resizeViewport()}_initializeAnimationProps(){let n=this.device?.getDefaultCanvasContext();if(!this.device||!n)throw new Error("loop");let r=n?.canvas,c=n.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:n,canvas:r,useDevicePixels:c,timeline:this.timeline,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,animationFrame:null,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:n,height:r,aspect:c}=this._getSizeAndAspect();(n!==this.animationProps.width||r!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),c!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=n,this.animationProps.height=r,this.animationProps.aspect=c,this.animationProps.needsRedraw=this._needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.getDefaultCanvasContext().canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let n=document.createElement("div");document.body.appendChild(n),n.style.position="relative";let r=document.createElement("div");r.style.position="absolute",r.style.left="10px",r.style.bottom="10px",r.style.width="300px",r.style.background="white",this.canvas instanceof HTMLCanvasElement&&n.appendChild(this.canvas),n.appendChild(r);let c=this.props.onAddHTML(r);c&&(r.innerHTML=c)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[n,r]=this.device.getDefaultCanvasContext().getDrawingBufferSize(),c=n>0&&r>0?n/r:1;return{width:n,height:r,aspect:c}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(n){let r=n??(typeof performance<"u"?performance.now():Date.now());if(this._lastFrameTime){let c=r-this._lastFrameTime;c>0&&this.frameRate.addTime(c)}this._lastFrameTime=r,this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeStart()}_endFrameTimers(){this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeEnd(),this._updateSharedStats()}_consumeEncodedGpuTime(){if(!this.device)return;let n=this.device.commandEncoder._gpuTimeMs;n!==void 0&&(this.gpuTime.addTime(n),this.device.commandEncoder._gpuTimeMs=void 0)}_updateSharedStats(){if(this.stats!==this.sharedStats){for(let n of Object.keys(this.sharedStats.stats))this.stats.stats[n]||delete this.sharedStats.stats[n];this.stats.forEach(n=>{let r=this.sharedStats.get(n.name,n.type);r.sampleSize=n.sampleSize,r.time=n.time,r.count=n.count,r.samples=n.samples,r.lastTiming=n.lastTiming,r.lastSampleTime=n.lastSampleTime,r.lastSampleCount=n.lastSampleCount,r._count=n._count,r._time=n._time,r._samples=n._samples,r._startTime=n._startTime,r._timerPending=n._timerPending})}}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(n){n instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[n.offsetX,n.offsetY])}_onMouseleave(n){this._getAnimationProps()._mousePosition=null}}});function Vmt(s,n){if(n instanceof Mle)return n;let r=Omt(n),c=fen(s,r),{attributes:u,bufferLayout:d}=hen(s,r);return new Mle({topology:r.topology||"triangle-list",bufferLayout:d,vertexCount:r.vertexCount,indices:c,attributes:u})}function fen(s,n){if(!n.indices)return;let r=n.indices.value;return s.createBuffer({usage:cs.INDEX,data:r})}function hen(s,n){let r={};for(let[c,u]of Object.entries(n.attributes)){let d=n.bufferLayout.find(b=>b.name===c)?.name||y4(c);u&&(r[d]=s.createBuffer({data:u.value,id:`${c}-buffer`}))}return{attributes:r,bufferLayout:n.bufferLayout,vertexCount:n.vertexCount}}var Mle,Wmt=Ve(()=>{Vr();Sle();Nmt();hB();Mle=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(n){if(this.id=n.id||Qy("geometry"),this.topology=n.topology,this.indices=n.indices||null,this.attributes=n.attributes,this.vertexCount=n.vertexCount,this.bufferLayout=n.bufferLayout||[],this.indices&&!(this.indices.usage&cs.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){this.indices?.destroy();for(let n of Object.values(this.attributes))n.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(n){return n.byteLength/12}}});function Hmt(s,n){let r={},c="Values";if(s.attributes.length===0&&!s.varyings?.length)return{"No attributes or varyings":{[c]:"N/A"}};for(let u of s.attributes)if(u){let d=`${u.location} ${u.name}: ${u.type}`;r[`in ${d}`]={[c]:u.stepMode||"vertex"}}for(let u of s.varyings||[]){let d=`${u.location} ${u.name}`;r[`out ${d}`]={[c]:JSON.stringify(u)}}return r}var qmt=Ve(()=>{});function Zmt(s,n,r){if(s.device.type!=="webgl")return;let c=gen(s.device);if(!c.flushing){if(ben(s)){den(s,r,c);return}n&&men(n)&&n.handle!==null&&(c.queuedFramebuffers.includes(n)||c.queuedFramebuffers.push(n))}}function den(s,n,r){if(r.queuedFramebuffers.length===0)return;let c=s.device,{gl:u}=c,d=u.getParameter(36010),b=u.getParameter(36006),[w,_]=s.device.getDefaultCanvasContext().getDrawingBufferSize(),x=Ymt(n.top,8),T=Ymt(n.left,8);r.flushing=!0;try{for(let M of r.queuedFramebuffers){let[L,I,D,F,O]=pen({framebuffer:M,targetWidth:w,targetHeight:_,topPx:x,leftPx:T,minimap:n.minimap});u.bindFramebuffer(36008,M.handle),u.bindFramebuffer(36009,null),u.blitFramebuffer(0,0,M.width,M.height,L,I,D,F,16384,9728),x+=O+8}}finally{u.bindFramebuffer(36008,d),u.bindFramebuffer(36009,b),r.flushing=!1}}function pen(s){let{framebuffer:n,targetWidth:r,targetHeight:c,topPx:u,leftPx:d,minimap:b}=s,w=b?Math.max(Math.floor(r/4),1):r,_=b?Math.max(Math.floor(c/4),1):c,x=Math.min(w/n.width,_/n.height),T=Math.max(Math.floor(n.width*x),1),M=Math.max(Math.floor(n.height*x),1),L=d,I=Math.max(c-u-M,0),D=L+T,F=I+M;return[L,I,D,F,M]}function gen(s){return s.userData[Xmt]||={flushing:!1,queuedFramebuffers:[]},s.userData[Xmt]}function men(s){return"colorAttachments"in s}function ben(s){let n=s.props.framebuffer;return!n||n.handle===null}function Ymt(s,n){if(!s)return n;let r=Number.parseInt(s,10);return Number.isFinite(r)?r:n}var Xmt,Kmt=Ve(()=>{Xmt="__debugFramebufferState"});function dB(s,n,r){if(s===n)return!0;if(!r||!s||!n)return!1;if(Array.isArray(s)){if(!Array.isArray(n)||s.length!==n.length)return!1;for(let c=0;c{});var pB,Qmt=Ve(()=>{Vr();pB=class{bufferLayouts;constructor(n){this.bufferLayouts=n}getBufferLayout(n){return this.bufferLayouts.find(r=>r.name===n)||null}getAttributeNamesForBuffer(n){return VD(n)}mergeBufferLayouts(n,r){let c=[...n];for(let u of r){let d=c.findIndex(b=>b.name===u.name);d<0?c.push(u):c[d]=u}return c}}});function e1t(s,n){let r=i4e(s),c=n.slice();return c.sort((u,d)=>{let b=Oce(VD(u).map(_=>r[_])),w=Oce(VD(d).map(_=>r[_]));return b-w}),c}var t1t=Ve(()=>{Vr()});function gB(s,n){if(!s||!n.some(c=>c.bindingLayout?.length))return s;let r={...s,bindings:s.bindings.map(c=>({...c}))};"attributes"in(s||{})&&(r.attributes=s?.attributes||[]);for(let c of n)for(let u of c.bindingLayout||[])for(let d of wen(u.name)){let b=r.bindings.find(w=>w.name===d);b?.group===0&&(b.group=u.group),b&&u.visibility!==void 0&&(b.visibility=u.visibility)}return r}function n1t(s,n,r=[]){return s?n?{...s,attributes:s.attributes.length?yen(s.attributes,n.attributes.filter(c=>r.includes(c.name))):n.attributes,bindings:_en(s.bindings,n.bindings)}:s:n}function rV(s){return!!(s.uniformTypes&&!ven(s.uniformTypes))}function i1t(s){let n=[];for(let r of s){let c=k$(r),u=new Set([r.vs,r.fs].flatMap(b=>b?R$(b).filter(w=>w.isStd140).map(w=>w.blockName):[])),d=u.has(c)?c:u.size===1?u.values().next().value:void 0;rV(r)&&d&&n.push({name:d,uniformTypes:r.uniformTypes})}return n}function Tle(s,n){let r=[],c=new Set;for(let u of[...s||[],...n||[]])c.has(u.name)||(c.add(u.name),r.push(u));return r}function wen(s){let n=new Set([s,`${s}Uniforms`]);return s.endsWith("Uniforms")||n.add(`${s}Sampler`),[...n]}function ven(s){for(let n in s)return!1;return!0}function _en(s,n){let r=s.map(d=>({...d})),c=new Set(s.map(d=>d.name)),u=new Set(s.map(d=>`${d.group}:${d.location}`));for(let d of n){let b=`${d.group}:${d.location}`;!c.has(d.name)&&!u.has(b)&&r.push({...d})}return r}function yen(s,n){let r=s.map(d=>({...d})),c=new Map(s.map(d=>[d.name,d])),u=new Map(s.map(d=>[d.location,d]));for(let d of n){let b=c.get(d.name);if(b){if(b.type!==d.type||b.location!==d.location)throw new Error(`Shader attribute "${d.name}" conflicts with its inferred type or location`);continue}let w=u.get(d.location);if(w)throw new Error(`Shader attributes "${w.name}" and "${d.name}" both use location ${d.location}`);r.push({...d})}return r}var Dke=Ve(()=>{vm()});function xen(s){return r$(s)||typeof s=="number"||typeof s=="boolean"}function r1t(s,n={}){let r={bindings:{},uniforms:{}};return Object.keys(s).forEach(c=>{let u=s[c];Object.prototype.hasOwnProperty.call(n,c)||xen(u)?r.uniforms[c]=u:r.bindings[c]=u}),r}var s1t=Ve(()=>{sLe()});function o1t(s={},n={},r={}){let c={...s};for(let[u,d]of Object.entries(n))d!==void 0&&(c[u]=Bke(s[u],d,r[u]));return c}function Bke(s,n,r){if(!r||typeof r=="string")return sV(n);if(Array.isArray(r)){if(Oke(n)||!Array.isArray(n))return sV(n);let b=Array.isArray(s)&&!Oke(s)?[...s]:[],w=b.slice();for(let _=0;_r===void 0?void 0:sV(r)):Nke(s)?Object.fromEntries(Object.entries(s).map(([n,r])=>[n,r===void 0?void 0:sV(r)])):s}function Oke(s){return ArrayBuffer.isView(s)||Array.isArray(s)&&(s.length===0||typeof s[0]=="number")}function Nke(s){return!!s&&typeof s=="object"&&!Array.isArray(s)&&!ArrayBuffer.isView(s)}function Een(s){return!!s?.dependencies}var mB,Fke=Ve(()=>{Vr();vm();s1t();mB=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;directBindings={};constructor(n,r){Object.assign(this.options,r);let c=ZL(Object.values(n).filter(Een));for(let u of c)n[u.name]=u;Qt.log(1,"Creating ShaderInputs with modules",Object.keys(n))(),this.modules=n,this.moduleUniforms={},this.moduleBindings={};for(let[u,d]of Object.entries(n))d&&(this._addModule(d),d.name&&u!==d.name&&!this.options.disableWarnings&&Qt.warn(`Module name: ${u} vs ${d.name}`)())}destroy(){}setProps(n){n.bindings&&Object.assign(this.directBindings,n.bindings);for(let r of Object.keys(n)){if(r==="bindings")continue;let c=r,u=n[c]||{},d=this.modules[c];if(!d)this.options.disableWarnings||Qt.warn(`Module ${r} not found`)();else{let b=this.moduleUniforms[c],w=this.moduleBindings[c],_=d.getUniforms?.(u,b)||u,{uniforms:x,bindings:T}=r1t(_,d.uniformTypes);this.moduleUniforms[c]=o1t(b,x,d.uniformTypes),this.moduleBindings[c]={...w,...T}}}}getModules(){return Object.values(this.modules)}addModules(n){let r=ZL(n);for(let c of r){let u=c.name;this.modules[u]||(this.modules[u]=c,this._addModule(c))}}getUniformValues(){return this.moduleUniforms}getBindingValues(){let n={};for(let r of Object.values(this.moduleBindings))Object.assign(n,r);return Object.assign(n,this.directBindings),n}getModuleBindingValues(n){let r=this.moduleBindings[n];return r?{...r}:{}}getDebugTable(){let n={};for(let[r,c]of Object.entries(this.moduleUniforms))for(let[u,d]of Object.entries(c))n[`${r}.${u}`]={type:this.modules[r].uniformTypes?.[u],value:String(d)};return n}_addModule(n){let r=n.name;this.moduleUniforms[r]=o1t({},n.defaultUniforms||{},n.uniformTypes),this.moduleBindings[r]={}}}});function Uke(s){return s!==null&&typeof s=="object"&&"buffer"in s}function Men(s){return s instanceof up?s.buffer:s}function a1t(s){return{buffer:Men(s.buffer),offset:s.offset,size:s.size}}var Sen,up,zke=Ve(()=>{Vr();hB();Sen=cs.DEBUG_DATA_MAX_LENGTH,up=class{device;id;ready;usage;props;isReady=!0;destroyed=!1;generation=0;updateTimestamp;debugData=new ArrayBuffer(0);_debugDataEnabled;_maxDebugDataByteLength;_ownsBuffer;_buffer;get buffer(){return this._buffer}get byteLength(){return this._buffer.byteLength}get[Symbol.toStringTag](){return"DynamicBuffer"}toString(){return`DynamicBuffer:"${this.id}":${this.byteLength}B`}toJSON(){return this.toString()}constructor(n,r){let{debugData:c=!1,buffer:u,ownsBuffer:d=!0,...b}=r;if(u&&u.device!==n)throw new Error("DynamicBuffer adopted buffers must belong to the supplied device");if(u&&(b.byteLength!==void 0||b.data!==void 0))throw new Error("DynamicBuffer cannot combine an adopted buffer with byteLength or data");let w=r.id||u?.id||Qy("dynamic-buffer"),_={...b,id:w,usage:b.usage??u?.usage,indexType:b.indexType??u?.indexType};(_.usage||0)&cs.INDEX&&!_.indexType&&(b.data instanceof Uint32Array?_.indexType="uint32":b.data instanceof Uint16Array?_.indexType="uint16":b.data instanceof Uint8Array&&(_.indexType="uint8")),delete _.data,delete _.byteOffset,this.device=n,this.id=w,this.props=_,this.usage=_.usage||0,this._debugDataEnabled=!!c,this._maxDebugDataByteLength=typeof c=="object"&&c.maxByteLength!==void 0?c.maxByteLength:Sen,this._ownsBuffer=d,this._buffer=u??this.device.createBuffer({...b,id:w}),this.ready=Promise.resolve(this._buffer),this.updateTimestamp=this._buffer.updateTimestamp,this._resetDebugData(this._buffer.byteLength),b.data&&this._writeDebugData(b.data,b.byteOffset||0)}write(n,r=0){this._buffer.write(n,r),this._touch(),this._writeDebugData(n,r)}async mapAndWriteAsync(n,r=0,c=this.byteLength-r){let u=null;await this._buffer.mapAndWriteAsync(async(d,b)=>{await n(d,b),u=new Uint8Array(d.slice(0,c))},r,c),this._touch(),u&&this._writeDebugData(u,r)}async readAsync(n=0,r=this.byteLength-n){let c=await this._buffer.readAsync(n,r);return this._writeDebugData(c,n)&&this._touch(),c}async mapAndReadAsync(n,r=0,c=this.byteLength-r){let u=null,d=await this._buffer.mapAndReadAsync(async(b,w)=>(u=new Uint8Array(b.slice(0)),await n(b,w)),r,c);return u&&this._writeDebugData(u,r)&&this._touch(),d}resize(n){let{byteLength:r,preserveData:c=!1}=n;if(r===this.byteLength)return!1;let u=Math.min(n.copyByteLength??Math.min(this.byteLength,r),this.byteLength,r),d=this._buffer,b=this.debugData.slice(0),{data:w,byteOffset:_,...x}=this.props,T=this.device.createBuffer({...x,byteLength:r});return c&&u>0&&this._copyBufferContents(d,T,u),this._buffer=T,this._resetDebugData(r),c&&b.byteLength>0&&this._writeDebugData(b,0),this._ownsBuffer&&d.destroy(),this._ownsBuffer=!0,this.generation++,this._touch(),!0}ensureSize(n,r){return n<=this.byteLength?!1:this.resize({byteLength:n,preserveData:r?.preserveData})}getBinding(n){return n?.offset===void 0&&n?.size===void 0?this._buffer:{buffer:this._buffer,offset:n?.offset,size:n?.size}}destroy(){this.destroyed||(this._ownsBuffer&&this._buffer.destroy(),this.destroyed=!0,this.debugData=new ArrayBuffer(0))}_copyBufferContents(n,r,c){let u=this.device.type==="webgpu"?Math.ceil(c/4)*4:c,d=this.device.createCommandEncoder();d.copyBufferToBuffer({sourceBuffer:n,destinationBuffer:r,size:u}),this.device.submit(d.finish())}_touch(){this.updateTimestamp=this.device.incrementTimestamp()}_resetDebugData(n){if(!this._debugDataEnabled){this.debugData=new ArrayBuffer(0);return}this.debugData=new ArrayBuffer(Math.min(n,this._maxDebugDataByteLength))}_writeDebugData(n,r){if(!this._debugDataEnabled||this.debugData.byteLength===0||r>=this.debugData.byteLength)return!1;let c=ArrayBuffer.isView(n)?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n),u=new Uint8Array(this.debugData),d=Math.min(c.byteLength,u.byteLength-r);return u.set(c.subarray(0,d),r),d>0}}});function oV(s){return s!==null&&typeof s=="object"&&"resolveTextureBinding"in s&&typeof s.resolveTextureBinding=="function"}function Ten(s){return s?.type==="texture"||s?.type==="external-texture"}function c1t(s,n,r){let c=Lce(s,n,{ignoreWarnings:!0});return Ten(c)?c:s.bindings.length===0&&r?.fallbackGroup!==void 0?{type:"texture",name:n,group:r.fallbackGroup,location:0}:null}var l1t=Ve(()=>{Vr()});function jke(s,n){return s.shaderLanguage!==void 0&&s.shaderLanguage!==n?!1:n==="glsl"?"assembleGLSLShaderPair"in s&&typeof s.assembleGLSLShaderPair=="function":"assembleWGSLShader"in s&&typeof s.assembleWGSLShader=="function"}function Pen(s,n){return!s||Object.keys(n).length===0?s:{...s,attributes:s.attributes.map(r=>{let c=r.name.startsWith("_luma_")?r.name.slice(6):null;return c&&n[c]?{...r,name:c}:r})}}function Len(s,n,r){if(oV(n)){let c=c1t(r,s,{fallbackGroup:0});return c?n.resolveTextureBinding(c):null}return n instanceof up?n.buffer:Uke(n)?a1t(n):n}function ken(s){return s&&!u1t(s)?s:null}function Ren(s){return s&&u1t(s)?s:void 0}function u1t(s){return Aen.includes(s)}function Ien(s){return{type:s.type,shaderLanguage:s.info.shadingLanguage,shaderLanguageVersion:s.info.shadingLanguageVersion,gpu:s.info.gpu,limits:s.limits,features:s.features}}var e2,Cen,Gke,Aen,Vh,$ke=Ve(()=>{Vr();vm();Wmt();qmt();Kmt();Jmt();Qmt();t1t();Dke();hB();Fke();zke();l1t();e2=2,Cen=1e4,Gke="render pipeline initialization failed",Aen=["stencil8","depth16unorm","depth24plus","depth24plus-stencil8","depth32float","depth32float-stencil8"],Vh=class s{static defaultProps={...Mb.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],plugins:[],geometry:null,indexBuffer:null,indexCount:void 0,firstVertex:0,firstIndex:0,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,material:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:Tb.getDefaultShaderAssembler("glsl"),debugShaders:void 0,disableWarnings:void 0};device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexCount;firstVertex;firstIndex;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;material=null;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_dynamicIndexBufferSource=null;_dynamicAttributeBufferSources={};_colorAttachmentFormats;_depthStencilAttachmentFormat;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_drawBlockedReason=!1;_destroyed=!1;_vertexCountSet=!1;_lastDrawTimestamp=-1;_bindingTable=[];get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(n,r){let c=s.defaultProps.shaderAssembler,u=r.vertexCount!==void 0;this.props={...s.defaultProps,...r,shaderAssembler:r.shaderAssembler??(jke(c,n.info.shadingLanguage)?c:Tb.getDefaultShaderAssembler(n.info.shadingLanguage))},this._vertexCountSet=u,r=this.props,this.id=r.id||Qy("model"),this.device=n,Object.assign(this.userData,r.userData),this.material=r.material||null;let d=Ien(n),b=P$(this.props.plugins,d.shaderLanguage),w=L$(this.props.modules,b.modules),_=Object.fromEntries(w.map(I=>[I.name,I])),x=r.shaderInputs||new mB(_,{disableWarnings:this.props.disableWarnings});r.shaderInputs&&b.modules.length>0&&x.addModules(b.modules),this.setShaderInputs(x);let T=Tle(this.props.modules,x.getModules()),M={...b.defines,...this.props.defines};if(this.device.type==="webgl"&&(this.props._uniformBlockLayouts=i1t(T)),this.props.shaderLayout=gB(this.props.shaderLayout,T)||null,this.device.type==="webgpu"&&this.props.source){let I=this.props.shaderAssembler;FM(jke(I,"wgsl"));let{source:D,getUniforms:F,bindingTable:O,shaderLayout:z}=I.assembleWGSLShader({platformInfo:d,...this.props,modules:T,defines:M,pluginInjections:b.injections,pluginVertexInputs:b.vertexInputs,pluginVaryings:b.varyings});this.source=D,this._getModuleUniforms=F,this._bindingTable=O;let Z=z??n.getShaderLayout?.(this.source),H=Pen(Z,b.vertexInputs),te=n1t(this.props.shaderLayout,H,Object.keys(b.vertexInputs));this.props.shaderLayout=gB(te||null,T)||null}else{let I=this.props.shaderAssembler;FM(jke(I,"glsl"));let{vs:D,fs:F,getUniforms:O}=I.assembleGLSLShaderPair({platformInfo:d,...this.props,modules:T,defines:M,pluginInjections:b.injections,pluginVertexInputs:b.vertexInputs,pluginVaryings:b.varyings});this.vs=D,this.fs=F,this._getModuleUniforms=O,this._bindingTable=[]}this.vertexCount=this.props.vertexCount,this.indexCount=this.props.indexCount,this.firstVertex=this.props.firstVertex,this.firstIndex=this.props.firstIndex,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,this._colorAttachmentFormats=this.props.colorAttachmentFormats,this._depthStencilAttachmentFormat=this.props.depthStencilAttachmentFormat,r.geometry&&this.setGeometry(r.geometry),this.pipelineFactory=r.pipelineFactory||i4.getDefaultPipelineFactory(this.device),this.shaderFactory=r.shaderFactory||r4.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=n.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in r&&(this.isInstanced=r.isInstanced),r.instanceCount&&this.setInstanceCount(r.instanceCount),r.vertexCount&&this.setVertexCount(r.vertexCount),r.indexBuffer&&this.setIndexBuffer(r.indexBuffer),r.attributes&&this.setAttributes(r.attributes),r.constantAttributes&&this.setConstantAttributes(r.constantAttributes),r.bindings&&this.setBindings(r.bindings),r.transformFeedback&&(this.transformFeedback=r.transformFeedback)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let n=this._needsRedraw;return this._needsRedraw=!1,n}setNeedsRedraw(n){this._needsRedraw||=n}getBindingDebugTable(){return this._bindingTable}predraw(n){this._syncDynamicBuffers(),this.updateShaderInputs(n),this.material?.updateShaderInputs(n),this.pipeline=this._updatePipeline()}draw(n){if(this._drawBlockedReason&&!this._pipelineNeedsUpdate)return Qt.info(e2,`>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)(),!1;let r=this._areBindingsLoading();if(r)return Qt.info(e2,`>>> DRAWING ABORTED ${this.id}: ${r} not loaded`)(),!1;this._syncAttachmentFormats(n);try{n.pushDebugGroup(`${this}.predraw(${n})`),this.device.type==="webgpu"?(this.updateShaderInputs(),this.material?.updateShaderInputs(),this._syncDynamicBuffers(),this.pipeline=this._updatePipeline()):this.predraw(this.device.commandEncoder)}finally{n.popDebugGroup()}let c,u=this.pipeline.isErrored;try{if(n.pushDebugGroup(`${this}.draw(${n})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline(),u=this.pipeline.isErrored,u)Qt.info(e2,`>>> DRAWING ABORTED ${this.id}: ${Gke}`)(),c=!1;else{let d=this.vertexArray.getDrawValidationError();if(d)Qt.info(e2,`>>> DRAWING ABORTED ${this.id}: ${d}`)(),this._drawBlockedReason=d,c=!1;else{let b=this._getCurrentShaderLayout(),w=this._getBindings(b),_=this._getBindGroups(b,w),{indexBuffer:x}=this.vertexArray,T=x?this.indexCount??(this._vertexCountSet?this.vertexCount:x.byteLength/(x.indexType==="uint32"?4:2)):void 0;n.setPipeline(this.pipeline),n.setBindings(_,{_bindGroupCacheKeys:this._getBindGroupCacheKeys()}),n.setVertexArray(this.vertexArray),c=this.isInstanced===!0&&this.instanceCount===0?!0:n.draw({isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.isInstanced?this.instanceCount:void 0,indexCount:T,firstVertex:this.firstVertex,firstIndex:this.firstIndex,transformFeedback:this.transformFeedback||void 0,uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}}}finally{n.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(n),c?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):u?(this._needsRedraw=Gke,this._drawBlockedReason=Gke):this._drawBlockedReason?this._needsRedraw=this._drawBlockedReason:this._needsRedraw="waiting for resource initialization",c}setGeometry(n){this._gpuGeometry?.destroy();let r=n&&Vmt(this.device,n);if(r){this.setTopology(r.topology||"triangle-list");let c=new pB(this.bufferLayout);this.bufferLayout=c.mergeBufferLayouts(r.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(r)}this._gpuGeometry=r}setTopology(n){n!==this.topology&&(this.topology=n,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(n){let r=new pB(this.bufferLayout),c=this._gpuGeometry?r.mergeBufferLayouts(n,this._gpuGeometry.bufferLayout):n;dB(c,this.bufferLayout,-1)||(this.bufferLayout=c,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry))}setParameters(n){dB(n,this.parameters,2)||(this.parameters=n,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(n){this.instanceCount=n,this.isInstanced===void 0&&n>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(n){this.vertexCount=n,this._vertexCountSet=!0,this.setNeedsRedraw("vertexCount")}setIndexCount(n){this.indexCount=n,this.setNeedsRedraw("indexCount")}setDrawOffsets({firstVertex:n,firstIndex:r}){this.firstVertex=n,this.firstIndex=r,this.setNeedsRedraw("drawOffsets")}setShaderInputs(n){this.shaderInputs=n,this._uniformStore=new a4(this.device,this.shaderInputs.modules);for(let[r,c]of Object.entries(this.shaderInputs.modules))if(rV(c)&&!this.material?.ownsModule(r)){let u=this._uniformStore.getManagedUniformBuffer(r);this.bindings[`${r}Uniforms`]=u}this.setNeedsRedraw("shaderInputs")}setMaterial(n){this.material=n,this.setNeedsRedraw("material")}updateShaderInputs(n){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),n),this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues())),this.setNeedsRedraw("shaderInputs")}setBindings(n){Object.assign(this.bindings,n),this.setNeedsRedraw("bindings")}setTransformFeedback(n){this.transformFeedback=n,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(n){let r=n instanceof up?n.buffer:n;this.indexBuffer=r,this._dynamicIndexBufferSource=n instanceof up?{source:n,generation:n.generation}:null,this.vertexArray.setIndexBuffer(r),this.setNeedsRedraw("indexBuffer")}setAttributes(n,r){this._drawBlockedReason=!1;let c=r?.disableWarnings??this.props.disableWarnings;n.indices&&Qt.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=e1t(this.pipeline.shaderLayout,this.bufferLayout);let u=new pB(this.bufferLayout);for(let[d,b]of Object.entries(n)){let w=b instanceof up?b.buffer:b,_=u.getBufferLayout(d);if(!_){c||Qt.warn(`Model(${this.id}): Missing layout for buffer "${d}".`)();continue}let x=u.getAttributeNamesForBuffer(_),T=!1;for(let M of x){let L=this._attributeInfos[M];if(L){let I=this.device.type==="webgpu"?this.vertexArray.getBufferSlot(L.bufferName):L.location;if(I===null){c||Qt.warn(`Model(${this.id}): Missing vertex array slot for buffer "${L.bufferName}".`)();continue}this.vertexArray.setBuffer(I,w),b instanceof up?this._dynamicAttributeBufferSources[I]={source:b,generation:b.generation}:delete this._dynamicAttributeBufferSources[I],T=!0}}!T&&!c&&Qt.warn(`Model(${this.id}): Ignoring buffer "${w.id}" for unknown attribute "${d}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(n,r){for(let[c,u]of Object.entries(n)){let d=this._attributeInfos[c];d?this.vertexArray.setConstantWebGL(d.location,u):(r?.disableWarnings??this.props.disableWarnings)||Qt.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${c}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(let n of Object.values(this.bindings))if(oV(n)&&!n.isReady)return n.id;for(let n of Object.values(this.material?.bindings||{}))if(oV(n)&&!n.isReady)return n.id;return!1}_getBindings(n=this._getCurrentShaderLayout()){let r={};for(let[c,u]of Object.entries(this.bindings)){let d=Len(c,u,n);d&&(r[c]=d)}return r}_getBindGroups(n=this._getCurrentShaderLayout(),r=this._getBindings(n)){let c=n.bindings.length?s4(n,r):{0:r};if(!this.material)return c;for(let[u,d]of Object.entries(this.material.getBindingsByGroup(n))){let b=Number(u);c[b]={...c[b]||{},...d}}return c}_getBindGroupCacheKeys(){let n=this.material?.getBindGroupCacheKey(3);return n?{3:n}:{}}_getBindingsUpdateTimestamp(){let n=0;this._dynamicIndexBufferSource&&(n=Math.max(n,this._dynamicIndexBufferSource.source.updateTimestamp));for(let r of Object.values(this._dynamicAttributeBufferSources))n=Math.max(n,r.source.updateTimestamp);for(let r of Object.values(this.bindings))r instanceof e4?n=Math.max(n,r.texture.updateTimestamp):r instanceof cs||r instanceof Pa||r instanceof b$||r instanceof up?n=Math.max(n,r.updateTimestamp):oV(r)?n=r.isReady?Math.max(n,r.updateTimestamp):1/0:Uke(r)&&(n=Math.max(n,(r.buffer instanceof up,r.buffer.updateTimestamp)));return Math.max(n,this.material?.getBindingsUpdateTimestamp()||0)}_setGeometryAttributes(n){let r={...n.attributes};for(let[c]of Object.entries(r))!this.pipeline.shaderLayout.attributes.find(u=>u.name===c)&&c!=="positions"&&delete r[c];this.vertexCount=n.vertexCount,this._vertexCountSet=!0,this.setIndexBuffer(n.indices||null),this.setAttributes(n.attributes,{disableWarnings:!0}),this.setAttributes(r,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(n){this._pipelineNeedsUpdate||=n,this._drawBlockedReason=!1,this.setNeedsRedraw(n)}_updatePipeline(){if(this._pipelineNeedsUpdate){let n=null,r=null;this.pipeline&&(Qt.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),n=this.pipeline.vs,r=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let c=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders}),u=null;this.source?u=c:this.fs&&(u=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bindings:void 0,bufferLayout:this.bufferLayout,colorAttachmentFormats:this._colorAttachmentFormats,depthStencilAttachmentFormat:this._depthStencilAttachmentFormat,topology:this.topology,parameters:this.parameters,bindGroups:void 0,vs:c,fs:u}),this._attributeInfos=A$(this.pipeline.shaderLayout,this.bufferLayout),n&&this.shaderFactory.release(n),r&&r!==n&&this.shaderFactory.release(r)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let n=Qt.level>3?0:Cen;Qt.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:Qt.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let n=Hmt(this.pipeline.shaderLayout,this.id);Qt.table(e2,n)();let r=this.shaderInputs.getDebugTable();Qt.table(e2,r)();let c=this._getAttributeDebugTable();Qt.table(e2,this._attributeInfos)(),Qt.table(e2,c)(),Qt.groupEnd(e2)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(n){let r=this.device.props.debugFramebuffers;if(this._drawCount++,!r)return;let c=n.props.framebuffer;Zmt(n,c,{id:c?.id||`${this.id}-framebuffer`,minimap:!0})}_getAttributeDebugTable(){let n={};for(let[r,c]of Object.entries(this._attributeInfos)){let u=this.vertexArray.attributes[c.location];n[c.location]={name:r,type:c.shaderType,values:u?this._getBufferOrConstantValues(u,c.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:r}=this.vertexArray,c=r.indexType==="uint32"?new Uint32Array(r.debugData):new Uint16Array(r.debugData);n.indices={name:"indices",type:r.indexType,values:c.toString()}}return n}_getBufferOrConstantValues(n,r){let c=Md.getTypedArrayConstructor(r);return(n instanceof cs?new c(n.debugData):n).toString()}_getNonMaterialBindings(n){if(!this.material)return n;let r={};for(let[c,u]of Object.entries(n))this.material.ownsBinding(c)||(r[c]=u);return r}_getCurrentShaderLayout(){return this.pipeline?.shaderLayout||this.props.shaderLayout||{bindings:[]}}_syncDynamicBuffers(){if(this._dynamicIndexBufferSource&&this._dynamicIndexBufferSource.generation!==this._dynamicIndexBufferSource.source.generation){let n=this._dynamicIndexBufferSource.source.buffer;this.indexBuffer=n,this.vertexArray.setIndexBuffer(n),this._dynamicIndexBufferSource.generation=this._dynamicIndexBufferSource.source.generation,this.setNeedsRedraw("dynamic index buffer")}for(let[n,r]of Object.entries(this._dynamicAttributeBufferSources))r.generation!==r.source.generation&&(this.vertexArray.setBuffer(Number(n),r.source.buffer),r.generation=r.source.generation,this.setNeedsRedraw("dynamic attribute buffer"))}_syncAttachmentFormats(n){if(this.device.type!=="webgpu")return;let r=n.framebuffer||n.props.framebuffer,c=n.props,u=c.colorAttachmentFormats??r?.colorAttachments?.map(b=>ken(b?.texture?.format)),d=c.depthStencilAttachmentFormat===!1?void 0:c.depthStencilAttachmentFormat??Ren(r?.depthStencilAttachment?.texture?.format);(!dB(this._colorAttachmentFormats,u,1)||this._depthStencilAttachmentFormat!==d)&&(this._colorAttachmentFormats=u,this._depthStencilAttachmentFormat=d,this._setPipelineNeedsUpdate("attachment formats"))}}});var Den,Ben,fp,f1t=Ve(()=>{Vr();vm();$ke();Den=35980,Ben=35981,fp=class s{device;model;transformFeedback;static defaultProps={...Vh.defaultProps,feedbackBufferMode:"separate",outputs:void 0,feedbackBuffers:void 0};static isSupported(n){return n?.info?.type==="webgl"}constructor(n,r=s.defaultProps){if(!s.isSupported(n))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=n,this.model=new Vh(this.device,{id:r.id||"buffer-transform-model",fs:r.fs||v4e(),topology:r.topology||"point-list",varyings:r.outputs||r.varyings,...r,bufferMode:r.bufferMode||(r.feedbackBufferMode==="interleaved"?Den:Ben)}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:r.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(n){n?.inputBuffers&&this.model.setAttributes(n.inputBuffers),n?.outputBuffers&&this.transformFeedback.setBuffers(n.outputBuffers);let r=this.device.beginRenderPass({discard:!0,...n});this.model.draw(r),r.end()}getBuffer(n){return this.transformFeedback.getBuffer(n)}readAsync(n){let r=this.getBuffer(n);if(!r)throw new Error("BufferTransform#getBuffer");if(r instanceof cs)return r.readAsync();let{buffer:c,byteOffset:u=0,byteLength:d=c.byteLength}=r;return c.readAsync(u,d)}}});function Nen(s){return{type:s.type,shaderLanguage:s.info.shadingLanguage,shaderLanguageVersion:s.info.shadingLanguageVersion,gpu:s.info.gpu,limits:s.limits,features:s.features}}var Vke,Oen,G1,h1t=Ve(()=>{Vr();vm();sLe();Fke();Dke();hB();Vke=2,Oen=1e4,G1=class s{static defaultProps={...GM.defaultProps,id:"unnamed",handle:void 0,userData:{},source:"",modules:[],defines:{},plugins:[],bindings:void 0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,shaderAssembler:Tb.getDefaultShaderAssembler("wgsl"),debugShaders:void 0};device;id;pipelineFactory;shaderFactory;userData={};bindings={};pipeline;source;shader;shaderInputs;_uniformStore;_pipelineNeedsUpdate="newly created";_getModuleUniforms;props;_destroyed=!1;constructor(n,r){if(n.type!=="webgpu")throw new Error("Computation is only supported in WebGPU");this.props={...s.defaultProps,...r},r=this.props,this.id=r.id||Qy("model"),this.device=n,Object.assign(this.userData,r.userData);let c=Nen(n),u=P$(this.props.plugins,c.shaderLanguage);if(Object.keys(u.vertexInputs).length>0||Object.keys(u.varyings).length>0)throw new Error("Computation does not support ShaderPlugin vertex inputs or varyings");let d=L$(this.props.modules,u.modules),b=Object.fromEntries(d.map(D=>[D.name,D]));this.shaderInputs=r.shaderInputs||new mB(b),r.shaderInputs&&u.modules.length>0&&this.shaderInputs.addModules(u.modules),this.setShaderInputs(this.shaderInputs);let w=Tle(this.props.modules,this.shaderInputs?.getModules()),_={...u.defines,...this.props.defines};this.props.shaderLayout=gB(this.props.shaderLayout,w)||null,this.pipelineFactory=r.pipelineFactory||i4.getDefaultPipelineFactory(this.device),this.shaderFactory=r.shaderFactory||r4.getDefaultShaderFactory(this.device);let x=this.props.shaderAssembler;FM(x instanceof $M);let{source:T,getUniforms:M,shaderLayout:L}=x.assembleWGSLShader({platformInfo:c,...this.props,modules:w,defines:_,scanVertexAttributes:!1,pluginInjections:u.injections});this.source=T,this._getModuleUniforms=M;let I=L??n.getShaderLayout?.(this.source,{scanVertexAttributes:!1});this.props.shaderLayout=gB(this.props.shaderLayout||I||null,w)||null,this.pipeline=this._updatePipeline(),r.bindings&&this.setBindings(r.bindings)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.shader),this._uniformStore.destroy(),this._destroyed=!0)}predraw(n){this.updateShaderInputs(n)}dispatch(n,r,c,u){try{this._logDrawCallStart(),this._setPipeline(n),n.dispatch(r,c,u)}finally{this._logDrawCallEnd()}}dispatchIndirect(n,r,c=0){try{this._logDrawCallStart(),this._setPipeline(n),n.dispatchIndirect(r,c)}finally{this._logDrawCallEnd()}}_setPipeline(n){this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings),n.setPipeline(this.pipeline),n.setBindings({})}setVertexCount(n){}setInstanceCount(n){}setShaderInputs(n){this.shaderInputs=n,this._uniformStore=new a4(this.device,this.shaderInputs.modules);for(let[r,c]of Object.entries(this.shaderInputs.modules))if(rV(c)){let u=this._uniformStore.getManagedUniformBuffer(r);this.bindings[`${r}Uniforms`]=u}}setShaderModuleProps(n){let r=this._getModuleUniforms(n),c=Object.keys(r).filter(d=>{let b=r[d];return!r$(b)&&typeof b!="number"&&typeof b!="boolean"}),u={};for(let d of c)u[d]=r[d],delete r[d]}updateShaderInputs(n){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),n)}setBindings(n){Object.assign(this.bindings,n)}_setPipelineNeedsUpdate(n){this._pipelineNeedsUpdate=this._pipelineNeedsUpdate||n}_updatePipeline(){if(this._pipelineNeedsUpdate){let n=null;this.pipeline&&(Qt.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),n=this.shader),this._pipelineNeedsUpdate=!1,this.shader=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"compute",source:this.source,debugShaders:this.props.debugShaders}),this.pipeline=this.pipelineFactory.createComputePipeline({...this.props,shader:this.shader}),n&&this.shaderFactory.release(n)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let n=Qt.level>3?0:Oen;Qt.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:Qt.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let n=this.shaderInputs.getDebugTable();Qt.table(Vke,n)(),Qt.groupEnd(Vke)(),this._logOpen=!1}}_drawCount=0;_getBufferOrConstantValues(n,r){let c=Md.getTypedArrayConstructor(r);return(n instanceof cs?new c(n.debugData):n).toString()}}});var Ql=Ve(()=>{Fmt();$mt();$ke();f1t();Sle();zke();h1t()});function C1t(s=!0){let n=HTMLCanvasElement.prototype;if(!s&&n.originalGetContext){n.getContext=n.originalGetContext,n.originalGetContext=void 0;return}n.originalGetContext=n.getContext,n.getContext=function(r,c){if(r==="webgl"||r==="experimental-webgl"){let u=this.originalGetContext("webgl2",c);return u instanceof HTMLElement&&ptn(u),u}return this.originalGetContext(r,c)}}function ptn(s){s.getExtension("EXT_color_buffer_float");let n={...utn,WEBGL_disjoint_timer_query:s.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:ftn(s),OES_vertex_array_object:htn(s),ANGLE_instanced_arrays:dtn(s)},r=s.getExtension.bind(s);s.getExtension=function(u){let d=r(u);return d||(u in n?n[u]:null)};let c=s.getSupportedExtensions;s.getSupportedExtensions=function(){return(c.apply(s)||[])?.concat(Object.keys(n))}}var utn,ftn,htn,dtn,A1t=Ve(()=>{utn={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},ftn=s=>({drawBuffersWEBGL(n){return s.drawBuffers(n)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),htn=s=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return s.createVertexArray()},deleteVertexArrayOES(n){return s.deleteVertexArray(n)},isVertexArrayOES(n){return s.isVertexArray(n)},bindVertexArrayOES(n){return s.bindVertexArray(n)}}),dtn=s=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...n){return s.drawArraysInstanced(...n)},drawElementsInstancedANGLE(...n){return s.drawElementsInstanced(...n)},vertexAttribDivisorANGLE(...n){return s.vertexAttribDivisor(...n)}})});async function L1t(){if(!Dle){tRe();return}await Dle.load()}function k1t(s,n){return Dle?Dle.makeDebugContext(s,n):(tRe(),s)}async function R1t(s){if(!eRe){tRe();return}await eRe.load(s)}function I1t(s){return eRe?.initialize(s)||null}function tRe(){P1t||(P1t=!0,Qt.warn("Import @luma.gl/webgl/debug before enabling WebGL debugging.")())}var Dle,eRe,P1t,nRe=Ve(()=>{Vr();Dle=null,eRe=null,P1t=!1});function iRe(s){return Array.isArray(s)||ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Iu(s,n,r){return n[s]!==void 0?n[s]:r[s]}var xV,Ff,D1t,j1,B1t,yV,O1t,N1t,rRe,r2,sRe,F1t,oRe=Ve(()=>{xV={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},Ff=(s,n,r)=>n?s.enable(r):s.disable(r),D1t=(s,n,r)=>s.hint(r,n),j1=(s,n,r)=>s.pixelStorei(r,n),B1t=(s,n,r)=>{let c=r===36006?36009:36008;return s.bindFramebuffer(c,n)},yV=(s,n,r)=>{let u={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[r];s.bindBuffer(u,n)};O1t={3042:Ff,32773:(s,n)=>s.blendColor(...n),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(s,n)=>s.clearColor(...n),3107:(s,n)=>s.colorMask(...n),2884:Ff,2885:(s,n)=>s.cullFace(n),2929:Ff,2931:(s,n)=>s.clearDepth(n),2932:(s,n)=>s.depthFunc(n),2928:(s,n)=>s.depthRange(...n),2930:(s,n)=>s.depthMask(n),3024:Ff,35723:D1t,35725:(s,n)=>s.useProgram(n),36007:(s,n)=>s.bindRenderbuffer(36161,n),36389:(s,n)=>s.bindTransformFeedback?.(36386,n),34229:(s,n)=>s.bindVertexArray(n),36006:B1t,36010:B1t,34964:yV,36662:yV,36663:yV,35053:yV,35055:yV,2886:(s,n)=>s.frontFace(n),33170:D1t,2849:(s,n)=>s.lineWidth(n),32823:Ff,32824:"polygonOffset",10752:"polygonOffset",35977:Ff,32926:Ff,32928:Ff,32938:"sampleCoverage",32939:"sampleCoverage",3089:Ff,3088:(s,n)=>s.scissor(...n),2960:Ff,2961:(s,n)=>s.clearStencil(n),2968:(s,n)=>s.stencilMaskSeparate(1028,n),36005:(s,n)=>s.stencilMaskSeparate(1029,n),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(s,n)=>s.viewport(...n),34383:Ff,10754:Ff,12288:Ff,12289:Ff,12290:Ff,12291:Ff,12292:Ff,12293:Ff,12294:Ff,12295:Ff,3333:j1,3317:j1,37440:j1,37441:j1,37443:j1,3330:j1,3332:j1,3331:j1,3314:j1,32878:j1,3316:j1,3315:j1,32877:j1,framebuffer:(s,n)=>{let r=n&&"handle"in n?n.handle:n;return s.bindFramebuffer(36160,r)},blend:(s,n)=>n?s.enable(3042):s.disable(3042),blendColor:(s,n)=>s.blendColor(...n),blendEquation:(s,n)=>{let r=typeof n=="number"?[n,n]:n;s.blendEquationSeparate(...r)},blendFunc:(s,n)=>{let r=n?.length===2?[...n,...n]:n;s.blendFuncSeparate(...r)},clearColor:(s,n)=>s.clearColor(...n),clearDepth:(s,n)=>s.clearDepth(n),clearStencil:(s,n)=>s.clearStencil(n),colorMask:(s,n)=>s.colorMask(...n),cull:(s,n)=>n?s.enable(2884):s.disable(2884),cullFace:(s,n)=>s.cullFace(n),depthTest:(s,n)=>n?s.enable(2929):s.disable(2929),depthFunc:(s,n)=>s.depthFunc(n),depthMask:(s,n)=>s.depthMask(n),depthRange:(s,n)=>s.depthRange(...n),dither:(s,n)=>n?s.enable(3024):s.disable(3024),derivativeHint:(s,n)=>{s.hint(35723,n)},frontFace:(s,n)=>s.frontFace(n),mipmapHint:(s,n)=>s.hint(33170,n),lineWidth:(s,n)=>s.lineWidth(n),polygonOffsetFill:(s,n)=>n?s.enable(32823):s.disable(32823),polygonOffset:(s,n)=>s.polygonOffset(...n),sampleCoverage:(s,n)=>s.sampleCoverage(n[0],n[1]||!1),scissorTest:(s,n)=>n?s.enable(3089):s.disable(3089),scissor:(s,n)=>s.scissor(...n),stencilTest:(s,n)=>n?s.enable(2960):s.disable(2960),stencilMask:(s,n)=>{n=iRe(n)?n:[n,n];let[r,c]=n;s.stencilMaskSeparate(1028,r),s.stencilMaskSeparate(1029,c)},stencilFunc:(s,n)=>{n=iRe(n)&&n.length===3?[...n,...n]:n;let[r,c,u,d,b,w]=n;s.stencilFuncSeparate(1028,r,c,u),s.stencilFuncSeparate(1029,d,b,w)},stencilOp:(s,n)=>{n=iRe(n)&&n.length===3?[...n,...n]:n;let[r,c,u,d,b,w]=n;s.stencilOpSeparate(1028,r,c,u),s.stencilOpSeparate(1029,d,b,w)},viewport:(s,n)=>s.viewport(...n)};N1t={blendEquation:(s,n,r)=>s.blendEquationSeparate(Iu(32777,n,r),Iu(34877,n,r)),blendFunc:(s,n,r)=>s.blendFuncSeparate(Iu(32969,n,r),Iu(32968,n,r),Iu(32971,n,r),Iu(32970,n,r)),polygonOffset:(s,n,r)=>s.polygonOffset(Iu(32824,n,r),Iu(10752,n,r)),sampleCoverage:(s,n,r)=>s.sampleCoverage(Iu(32938,n,r),Iu(32939,n,r)),stencilFuncFront:(s,n,r)=>s.stencilFuncSeparate(1028,Iu(2962,n,r),Iu(2967,n,r),Iu(2963,n,r)),stencilFuncBack:(s,n,r)=>s.stencilFuncSeparate(1029,Iu(34816,n,r),Iu(36003,n,r),Iu(36004,n,r)),stencilOpFront:(s,n,r)=>s.stencilOpSeparate(1028,Iu(2964,n,r),Iu(2965,n,r),Iu(2966,n,r)),stencilOpBack:(s,n,r)=>s.stencilOpSeparate(1029,Iu(34817,n,r),Iu(34818,n,r),Iu(34819,n,r))},rRe={enable:(s,n)=>s({[n]:!0}),disable:(s,n)=>s({[n]:!1}),pixelStorei:(s,n,r)=>s({[n]:r}),hint:(s,n,r)=>s({[n]:r}),useProgram:(s,n)=>s({35725:n}),bindRenderbuffer:(s,n,r)=>s({36007:r}),bindTransformFeedback:(s,n,r)=>s({36389:r}),bindVertexArray:(s,n)=>s({34229:n}),bindFramebuffer:(s,n,r)=>{switch(n){case 36160:return s({36006:r,36010:r});case 36009:return s({36006:r});case 36008:return s({36010:r});default:return null}},bindBuffer:(s,n,r)=>{let c={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[n];return c?s({[c]:r}):{valueChanged:!0}},blendColor:(s,n,r,c,u)=>s({32773:new Float32Array([n,r,c,u])}),blendEquation:(s,n)=>s({32777:n,34877:n}),blendEquationSeparate:(s,n,r)=>s({32777:n,34877:r}),blendFunc:(s,n,r)=>s({32969:n,32968:r,32971:n,32970:r}),blendFuncSeparate:(s,n,r,c,u)=>s({32969:n,32968:r,32971:c,32970:u}),clearColor:(s,n,r,c,u)=>s({3106:new Float32Array([n,r,c,u])}),clearDepth:(s,n)=>s({2931:n}),clearStencil:(s,n)=>s({2961:n}),colorMask:(s,n,r,c,u)=>s({3107:[n,r,c,u]}),cullFace:(s,n)=>s({2885:n}),depthFunc:(s,n)=>s({2932:n}),depthRange:(s,n,r)=>s({2928:new Float32Array([n,r])}),depthMask:(s,n)=>s({2930:n}),frontFace:(s,n)=>s({2886:n}),lineWidth:(s,n)=>s({2849:n}),polygonOffset:(s,n,r)=>s({32824:n,10752:r}),sampleCoverage:(s,n,r)=>s({32938:n,32939:r}),scissor:(s,n,r,c,u)=>s({3088:new Int32Array([n,r,c,u])}),stencilMask:(s,n)=>s({2968:n,36005:n}),stencilMaskSeparate:(s,n,r)=>s({[n===1028?2968:36005]:r}),stencilFunc:(s,n,r,c)=>s({2962:n,2967:r,2963:c,34816:n,36003:r,36004:c}),stencilFuncSeparate:(s,n,r,c,u)=>s({[n===1028?2962:34816]:r,[n===1028?2967:36003]:c,[n===1028?2963:36004]:u}),stencilOp:(s,n,r,c)=>s({2964:n,2965:r,2966:c,34817:n,34818:r,34819:c}),stencilOpSeparate:(s,n,r,c,u)=>s({[n===1028?2964:34817]:r,[n===1028?2965:34818]:c,[n===1028?2966:34819]:u}),viewport:(s,n,r,c,u)=>s({2978:[n,r,c,u]})},r2=(s,n)=>s.isEnabled(n),sRe={3042:r2,2884:r2,2929:r2,3024:r2,32823:r2,32926:r2,32928:r2,3089:r2,2960:r2,35977:r2},F1t=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068])});function bv(s,n){if(gtn(n))return;let r={};for(let u in n){let d=Number(u),b=O1t[u];b&&(typeof b=="string"?r[b]=!0:b(s,n[u],d))}let c=s.lumaState?.cache;if(c)for(let u in r){let d=N1t[u];d(s,n,c)}}function Ble(s,n=xV){if(typeof n=="number"){let u=n,d=sRe[u];return d?d(s,u):s.getParameter(u)}let r=Array.isArray(n)?n:Object.keys(n),c={};for(let u of r){let d=sRe[u];c[u]=d?d(s,Number(u)):s.getParameter(Number(u))}return c}function U1t(s){bv(s,xV)}function gtn(s){for(let n in s)return!1;return!0}var _B=Ve(()=>{oRe()});function G1t(s,n){if(s===n)return!0;if(z1t(s)&&z1t(n)&&s.length===n.length){for(let r=0;r{});function $1t(s,n){let r=s[n].bind(s);s[n]=function(u){if(u===void 0||F1t.has(u))return r(u);let d=wv.get(s);return u in d.cache||(d.cache[u]=r(u)),d.enable?d.cache[u]:r(u)},Object.defineProperty(s[n],"name",{value:`${n}-from-cache`,configurable:!1})}function mtn(s,n,r){if(!s[n])return;let c=s[n].bind(s);s[n]=function(...d){let b=wv.get(s),{valueChanged:w,oldValue:_}=r(b._updateCache,...d);return w&&c(...d),_},Object.defineProperty(s[n],"name",{value:`${n}-to-cache`,configurable:!1})}function btn(s){let n=s.useProgram.bind(s);s.useProgram=function(c){let u=wv.get(s);u.program!==c&&(n(c),u.program=c)}}var wv,aRe=Ve(()=>{_B();j1t();oRe();wv=class{static get(n){return n.lumaState}gl;program=null;stateStack=[];enable=!0;cache=null;log;initialized=!1;constructor(n,r){this.gl=n,this.log=r?.log||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(n={}){this.stateStack.push({})}pop(){let n=this.stateStack[this.stateStack.length-1];bv(this.gl,n),this.stateStack.pop()}trackState(n,r){if(this.cache=r?.copyState?Ble(n):Object.assign({},xV),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.lumaState=this,btn(n);for(let c in rRe){let u=rRe[c];mtn(n,c,u)}$1t(n,"getParameter"),$1t(n,"isEnabled")}_updateCache(n){let r=!1,c,u=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let d in n){let b=n[d],w=this.cache[d];G1t(b,w)||(r=!0,c=w,u&&!(d in u)&&(u[d]=w),this.cache[d]=b)}return{valueChanged:r,oldValue:c}}}});function EV(s){let n=s.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return n._polyfilled??=!1,n.extensions||={},s.luma=n,n}var cRe=Ve(()=>{});function V1t(s,n,r){let c="",u=_=>{let x=_.statusMessage;x&&(c||=x)};s.addEventListener("webglcontextcreationerror",u,!1);let d=r.failIfMajorPerformanceCaveat!==!0,b={preserveDrawingBuffer:!0,...r,failIfMajorPerformanceCaveat:!0},w=null;try{w||=s.getContext("webgl2",b),!w&&b.failIfMajorPerformanceCaveat&&(c||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.");let _=!1;if(!w&&d&&(b.failIfMajorPerformanceCaveat=!1,w=s.getContext("webgl2",b),_=!0),w||(w=s.getContext("webgl",{}),w&&(w=null,c||="Your browser only supports WebGL1")),!w)throw c||="Your browser does not support WebGL",new Error(`Failed to create WebGL context: ${c}`);let x=EV(w);x.softwareRenderer=_;let{onContextLost:T,onContextRestored:M}=n;return s.addEventListener("webglcontextlost",L=>T(L),!1),s.addEventListener("webglcontextrestored",L=>M(L),!1),w}finally{s.removeEventListener("webglcontextcreationerror",u,!1)}}var W1t=Ve(()=>{cRe()});function vv(s,n,r){return r[n]===void 0&&(r[n]=s.getExtension(n)||null),r[n]}var SV=Ve(()=>{});function H1t(s,n){let r=s.getParameter(7936),c=s.getParameter(7937);vv(s,"WEBGL_debug_renderer_info",n);let u=n.WEBGL_debug_renderer_info,d=s.getParameter(u?u.UNMASKED_VENDOR_WEBGL:7936),b=s.getParameter(u?u.UNMASKED_RENDERER_WEBGL:7937),w=d||r,_=b||c,x=s.getParameter(7938),T=q1t(w,_),M=wtn(w,_),L=vtn(w,_);return{type:"webgl",gpu:T,gpuType:L,gpuBackend:M,vendor:w,renderer:_,version:x,shadingLanguage:"glsl",shadingLanguageVersion:300}}function q1t(s,n){return/NVIDIA/i.exec(s)||/NVIDIA/i.exec(n)?"nvidia":/INT[E]L/i.exec(s)||/INT[E]L/i.exec(n)?"int_el":/Apple/i.exec(s)||/Apple/i.exec(n)?"apple":/AMD/i.exec(s)||/AMD/i.exec(n)||/ATI/i.exec(s)||/ATI/i.exec(n)?"amd":/SwiftShader/i.exec(s)||/SwiftShader/i.exec(n)?"software":"unknown"}function wtn(s,n){return/Metal/i.exec(s)||/Metal/i.exec(n)?"metal":/ANGLE/i.exec(s)||/ANGLE/i.exec(n)?"opengl":"unknown"}function vtn(s,n){if(/SwiftShader/i.exec(s)||/SwiftShader/i.exec(n))return"cpu";switch(q1t(s,n)){case"apple":return _tn(s,n)?"integrated":"unknown";case"int_el":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function _tn(s,n){return/Apple (M\d|A\d|GPU)/i.test(`${s} ${n}`)}var X1t=Ve(()=>{SV()});function Ole(s){switch(s){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(s))}var lRe=Ve(()=>{});function K1t(s){return s in Fle}function pRe(s,n,r){return J1t(s,n,r,new Set)}function J1t(s,n,r,c){let u=Fle[n];if(!u||c.has(n))return!1;c.add(n);let d=(u.features||[]).every(b=>J1t(s,b,r,c));return c.delete(n),d?(u.extensions||[]).every(b=>!!vv(s,b,r)):!1}function Q1t(s,n,r){let c=n.create,u=Ule[n.format];u?.gl===void 0&&(c=!1),u?.x&&(c=c&&!!vv(s,u.x,r)),n.format==="stencil8"&&(c=!1);let d=u?.r===!1?!1:u?.r===void 0||pRe(s,u.r,r),b=c&&n.render&&d&&Atn(s,n.format,r);return{format:n.format,create:c&&n.create,render:b,filter:c&&n.filter,blend:c&&n.blend,store:c&&n.store}}function Atn(s,n,r){let c=Ule[n],u=c?.gl;if(u===void 0||c?.x&&!vv(s,c.x,r))return!1;let d=s.getParameter(32873),b=s.getParameter(36006),w=s.createTexture(),_=s.createFramebuffer();if(!w||!_)return!1;let x=0,T=Number(s.getError());for(;T!==x;)T=s.getError();let M=!1;try{if(s.bindTexture(3553,w),s.texStorage2D(3553,1,u,1,1),Number(s.getError())!==x)return!1;s.bindFramebuffer(36160,_),s.framebufferTexture2D(36160,36064,3553,w,0),M=Number(s.checkFramebufferStatus(36160))===36053&&Number(s.getError())===x}finally{s.bindFramebuffer(36160,b),s.deleteFramebuffer(_),s.bindTexture(3553,d),s.deleteTexture(w)}return M}function zle(s){let n=Ule[s],r=Ltn(s),c=og.getInfo(s);return c.compressed&&(n.dataFormat=r),{internalFormat:r,format:n?.dataFormat||Ptn(c.channels,c.integer,c.normalized,r),type:c.dataType?Ole(c.dataType):n?.types?.[0]||5121,compressed:c.compressed||!1}}function e0t(s){switch(og.getInfo(s).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${s}`)}}function Ptn(s,n,r,c){if(c===6408||c===6407)return c;switch(s){case"r":return n&&!r?36244:6403;case"rg":return n&&!r?33320:33319;case"rgb":return n&&!r?36248:6407;case"rgba":return n&&!r?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function Ltn(s){let r=Ule[s]?.gl;if(r===void 0)throw new Error(`Unsupported texture format ${s}`);return r}var MV,TV,yB,xB,ytn,xtn,Etn,Stn,Mtn,Ttn,Y1t,Z1t,uRe,fRe,hRe,dRe,Nle,Ctn,Fle,Ule,EB=Ve(()=>{Vr();SV();lRe();MV="WEBGL_compressed_texture_s3tc",TV="WEBGL_compressed_texture_s3tc_srgb",yB="EXT_texture_compression_rgtc",xB="EXT_texture_compression_bptc",ytn="WEBGL_compressed_texture_etc",xtn="WEBGL_compressed_texture_astc",Etn="WEBGL_compressed_texture_etc1",Stn="WEBGL_compressed_texture_pvrtc",Mtn="WEBGL_compressed_texture_atc",Ttn="EXT_texture_norm16",Y1t="EXT_render_snorm",Z1t="EXT_color_buffer_float",uRe="snorm8-renderable-webgl",fRe="norm16-renderable-webgl",hRe="snorm16-renderable-webgl",dRe="float16-renderable-webgl",Nle="float32-renderable-webgl",Ctn="rgb9e5ufloat-renderable-webgl",Fle={"float32-renderable-webgl":{extensions:[Z1t]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[Y1t]},"norm16-webgl":{extensions:[Ttn]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[Y1t]},"float32-filterable":{extensions:["OES_texture_float_linear"]},"float16-filterable-webgl":{extensions:["OES_texture_half_float_linear"]},"texture-filterable-anisotropic-webgl":{extensions:["EXT_texture_filter_anisotropic"]},"texture-blend-float-webgl":{extensions:["EXT_float_blend"]},"texture-compression-bc":{extensions:[MV,TV,yB,xB]},"texture-compression-bc5-webgl":{extensions:[yB]},"texture-compression-bc7-webgl":{extensions:[xB]},"texture-compression-etc2":{extensions:[ytn]},"texture-compression-astc":{extensions:[xtn]},"texture-compression-etc1-webgl":{extensions:[Etn]},"texture-compression-pvrtc-webgl":{extensions:[Stn]},"texture-compression-atc-webgl":{extensions:[Mtn]}};Ule={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:uRe},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:uRe},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0,r:dRe},r16unorm:{gl:33322,rb:!0,r:fRe},r16snorm:{gl:36760,r:hRe},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759,r:uRe},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:dRe},rg16unorm:{gl:33324,r:fRe},rg16snorm:{gl:36761,r:hRe},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:Nle},rgb9e5ufloat:{gl:35901,r:Ctn},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852,r:!1},"rgb16snorm-webgl":{gl:36762,r:!1},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0,r:Nle},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:dRe},rgba16unorm:{gl:32859,rb:!0,r:fRe},rgba16snorm:{gl:36763,r:hRe},"rgb32float-webgl":{gl:34837,x:Z1t,r:Nle,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:Nle},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:MV},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:TV},"bc1-rgba-unorm":{gl:33777,x:MV},"bc1-rgba-unorm-srgb":{gl:35916,x:TV},"bc2-rgba-unorm":{gl:33778,x:MV},"bc2-rgba-unorm-srgb":{gl:35918,x:TV},"bc3-rgba-unorm":{gl:33779,x:MV},"bc3-rgba-unorm-srgb":{gl:35919,x:TV},"bc4-r-unorm":{gl:36283,x:yB},"bc4-r-snorm":{gl:36284,x:yB},"bc5-rg-unorm":{gl:36285,x:yB},"bc5-rg-snorm":{gl:36286,x:yB},"bc6h-rgb-ufloat":{gl:36495,x:xB},"bc6h-rgb-float":{gl:36494,x:xB},"bc7-rgba-unorm":{gl:36492,x:xB},"bc7-rgba-unorm-srgb":{gl:36493,x:xB},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37816},"astc-10x5-unorm-srgb":{gl:37848},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rgb2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}}});var t0t,Gle,n0t=Ve(()=>{Vr();SV();EB();t0t={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","html-in-canvas":s=>GLe()&&typeof s.texElementImage2D=="function","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},Gle=class extends p${gl;extensions;testedFeatures=new Set;constructor(n,r,c){super([],c),this.gl=n,this.extensions=r,vv(n,"EXT_color_buffer_float",r)}*[Symbol.iterator](){let n=this.getFeatures();for(let r of n)this.has(r)&&(yield r);return[]}has(n){return this.disabledFeatures?.[n]?!1:(this.testedFeatures.has(n)||(this.testedFeatures.add(n),K1t(n)&&pRe(this.gl,n,this.extensions)&&this.features.add(n),this.getWebGLFeature(n)&&this.features.add(n)),this.features.has(n))}initializeFeatures(){let n=this.getFeatures().filter(r=>r!=="polygon-mode-webgl");for(let r of n)this.has(r)}getFeatures(){return[...Object.keys(t0t),...Object.keys(Fle)]}getWebGLFeature(n){let r=t0t[n];return typeof r=="string"?!!vv(this.gl,r,this.extensions):typeof r=="function"?r(this.gl):!!r}}});var jle,i0t=Ve(()=>{Vr();jle=class extends d${get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxBindGroupsPlusVertexBuffers(){return 0}get maxBindingsPerBindGroup(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageBuffersInVertexStage(){return 0}get maxStorageBuffersInFragmentStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxStorageTexturesInVertexStage(){return 0}get maxStorageTexturesInFragmentStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get maxBufferSize(){return Number.MAX_SAFE_INTEGER}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxColorAttachments(){return this.getParameter(36063)}get maxColorAttachmentBytesPerSample(){return 0}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(n){super(),this.gl=n}getParameter(n){return this.limits[n]===void 0&&(this.limits[n]=this.gl.getParameter(n)),this.limits[n]||0}}});function ktn(s){return s<34069?s+34069:s}function Rtn(s){switch(s){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${s}`}}var s2,$le=Ve(()=>{Vr();EB();s2=class extends n4{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(n,r){super(n,r);let c=r.handle,u=c===null;this.device=n,this.gl=n.gl,this.handle=c||u?c:this.gl.createFramebuffer(),u||(n._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),r.handle||(this.autoCreateAttachmentTextures(),this.updateAttachments()))}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&!this.props.handle&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){let n=this.gl.bindFramebuffer(36160,this.handle);for(let r=0;r{Vr();$le();Vle=class extends g${device;handle=null;_framebuffer=null;get[Symbol.toStringTag](){return"WebGLCanvasContext"}constructor(n,r){super(r),this.device=n,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._configureDevice()}_configureDevice(){(this.drawingBufferWidth!==this._framebuffer?.width||this.drawingBufferHeight!==this._framebuffer?.height)&&this._framebuffer?.resize([this.drawingBufferWidth,this.drawingBufferHeight])}_getCurrentFramebuffer(){return this._framebuffer||=new s2(this.device,{id:"canvas-context-framebuffer",handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}}});var Wle,s0t=Ve(()=>{Vr();Wle=class extends m${device;handle=null;context2d;get[Symbol.toStringTag](){return"WebGLPresentationContext"}constructor(n,r={}){super(r),this.device=n;let c=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw new Error(`${c}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);let d=this.canvas.getContext("2d");if(!d)throw new Error(`${c}: Failed to create 2d presentation context`);this.context2d=d,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();let n=this.device.getDefaultCanvasContext(),[r,c]=n.getDrawingBufferSize();if(!(this.drawingBufferWidth===0||this.drawingBufferHeight===0||r===0||c===0||n.canvas.width===0||n.canvas.height===0)){if(r!==this.drawingBufferWidth||c!==this.drawingBufferHeight||n.canvas.width!==this.drawingBufferWidth||n.canvas.height!==this.drawingBufferHeight)throw new Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${r}x${c} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(n.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(n){let r=this.device.getDefaultCanvasContext();return r.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),r.getCurrentFramebuffer(n)}}});function o0t(s="id"){gRe[s]=gRe[s]||1;let n=gRe[s]++;return`${s}-${n}`}var gRe,a0t=Ve(()=>{gRe={}});function Itn(s){return s&cs.INDEX?34963:s&cs.VERTEX?34962:s&cs.UNIFORM?35345:34962}function Dtn(s){return s&cs.INDEX||s&cs.VERTEX?35044:s&cs.UNIFORM?35048:35044}var _v,Hle=Ve(()=>{Vr();_v=class extends cs{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength=0;bytesUsed=0;constructor(n,r={}){super(n,r),this.device=n,this.gl=this.device.gl;let c=typeof r=="object"?r.handle:void 0;this.handle=c||this.gl.createBuffer(),n._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=Itn(this.props.usage),this.glUsage=Dtn(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,r.data?this._initWithData(r.data,r.byteOffset,r.byteLength):this._initWithByteLength(r.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Buffer"):(this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle)),this.destroyed=!0,this.handle=null)}_initWithData(n,r=0,c=n.byteLength+r){let u=this.glTarget;this.gl.bindBuffer(u,this.handle),this.gl.bufferData(u,c,this.glUsage),this.gl.bufferSubData(u,r,n),this.gl.bindBuffer(u,null),this.bytesUsed=c,this.byteLength=c,this._setDebugData(n,r,c),this.props.handle?this.trackReferencedMemory(c,"Buffer"):this.trackAllocatedMemory(c)}_initWithByteLength(n){let r=n;n===0&&(r=new Float32Array(0));let c=this.glTarget;return this.gl.bindBuffer(c,this.handle),this.gl.bufferData(c,r,this.glUsage),this.gl.bindBuffer(c,null),this.bytesUsed=n,this.byteLength=n,this._setDebugData(null,0,n),this.props.handle?this.trackReferencedMemory(n,"Buffer"):this.trackAllocatedMemory(n),this}write(n,r=0){let c=ArrayBuffer.isView(n)?n:new Uint8Array(n),u=0,d=void 0,b=36663;this.gl.bindBuffer(b,this.handle),u!==0||d!==void 0?this.gl.bufferSubData(b,r,c,u,d):this.gl.bufferSubData(b,r,c),this.gl.bindBuffer(b,null),this._setDebugData(n,r,n.byteLength)}async mapAndWriteAsync(n,r=0,c=this.byteLength-r){let u=new ArrayBuffer(c);await n(u,"copied"),this.write(u,r)}async readAsync(n=0,r){return this.readSyncWebGL(n,r)}async mapAndReadAsync(n,r=0,c){let u=await this.readAsync(r,c);return await n(u.buffer,"copied")}readSyncWebGL(n=0,r){r=r??this.byteLength-n;let c=new Uint8Array(r),u=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,n,c,u,r),this.gl.bindBuffer(36662,null),this._setDebugData(c,n,r),c}}});function c0t(s){let n=s.split(/\r?\n/),r=[];for(let c of n){if(c.length<=1)continue;let u=c.trim(),d=c.split(":"),b=d[0]?.trim();if(d.length===2){let[I,D]=d;if(!I||!D){r.push({message:u,type:qle(b||"info"),lineNum:0,linePos:0});continue}r.push({message:D.trim(),type:qle(I),lineNum:0,linePos:0});continue}let[w,_,x,...T]=d;if(!w||!_||!x){r.push({message:d.slice(1).join(":").trim()||u,type:qle(b||"info"),lineNum:0,linePos:0});continue}let M=parseInt(x,10);Number.isNaN(M)&&(M=0);let L=parseInt(_,10);Number.isNaN(L)&&(L=0),r.push({message:T.join(":").trim(),type:qle(w),lineNum:M,linePos:L})}return r}function qle(s){let n=["warning","error","info"],r=s.toLowerCase();return n.includes(r)?r:"info"}var l0t=Ve(()=>{});function Btn(s){return s.split(/\r?\n/).find(n=>n.trim())?.trim()}var Xle,u0t=Ve(()=>{Vr();l0t();Xle=class extends t4{device;handle;_compilationInfoLog="";constructor(n,r){super(n,r),this.device=n;let c=this.props.handle;switch(this.props.stage){case"vertex":this.handle=c||this.device.gl.createShader(35633);break;case"fragment":this.handle=c||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}n._setWebGLDebugMetadata(this.handle,this,{spector:this.props});let u=this._compile(this.source);u&&typeof u.catch=="function"&&u.catch(()=>{this.compilationStatus="error"})}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let n=this._getCompilationInfoLog();return n?c0t(n):[]}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)||null}_compile(n){n=n.startsWith("#version ")?n:`#version 300 es ${n}`;let{gl:r}=this.device;if(r.shaderSource(this.handle,n),r.compileShader(this.handle),!this.device.props.debug){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus==="error")throw new Error(this._getCompilationErrorMessage(n));return}return Qt.once(1,"Shader compilation is asynchronous")(),this._waitForCompilationComplete().then(()=>{Qt.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()})}async _waitForCompilationComplete(){let n=async u=>await new Promise(d=>setTimeout(d,u));if(!this.device.features.has("compilation-status-async-webgl")){await n(10);return}let{gl:c}=this.device;for(;;){if(c.getShaderParameter(this.handle,37297))return;await n(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error",this.compilationStatus==="error"&&this._getCompilationInfoLog()}_getCompilationErrorMessage(n){let r=`${this.props.stage} shader ${this.props.id}`,c=Btn(this._getCompilationInfoLog()),u=this.getCompilationInfoSync(),d=u.find(T=>T.type==="error"&&T.message.trim())||u.find(T=>T.message.trim())||u.find(T=>T.type==="error")||u[0];if(!d)return c?`GLSL compilation errors in ${r}: ${c}`:`GLSL compilation errors in ${r}: WebGL did not provide a shader compiler log`;let b=d.lineNum?n.split(/\r?\n/)[d.lineNum-1]?.trim():void 0,w=d.lineNum?` line ${d.lineNum}`:"",_=b?` Source: ${b}`:"",x=d.message.trim()||c||"WebGL did not provide a shader compiler log";return`GLSL compilation errors in ${r}:${w}: ${x}${_}`}_getCompilationInfoLog(){let n=this.device.gl.getShaderInfoLog(this.handle)?.trim();return n&&(this._compilationInfoLog=n),this._compilationInfoLog}}});function h0t(s,n,r,c){if(Utn(n))return c(s);let u=s;u.pushState();try{return Otn(s,n),bv(u.gl,r),c(s)}finally{u.popState()}}function Otn(s,n){let r=s,{gl:c}=r;if(n.cullMode)switch(n.cullMode){case"none":c.disable(2884);break;case"front":c.enable(2884),c.cullFace(1028);break;case"back":c.enable(2884),c.cullFace(1029);break}if(n.frontFace&&c.frontFace(P4("frontFace",n.frontFace,{ccw:2305,cw:2304})),n.unclippedDepth&&s.features.has("depth-clip-control")&&c.enable(34383),n.depthBias!==void 0&&(c.enable(32823),c.polygonOffset(n.depthBias,n.depthBiasSlopeScale||0)),n.provokingVertex&&s.features.has("provoking-vertex-webgl")){let d=r.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,b=P4("provokingVertex",n.provokingVertex,{first:36429,last:36430});d?.provokingVertexWEBGL(b)}if((n.polygonMode||n.polygonOffsetLine)&&s.features.has("polygon-mode-webgl")){if(n.polygonMode){let d=r.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,b=P4("polygonMode",n.polygonMode,{fill:6914,line:6913});d?.polygonModeWEBGL(1028,b),d?.polygonModeWEBGL(1029,b)}n.polygonOffsetLine&&c.enable(10754)}if(s.features.has("shader-clip-cull-distance-webgl")&&(n.clipDistance0&&c.enable(12288),n.clipDistance1&&c.enable(12289),n.clipDistance2&&c.enable(12290),n.clipDistance3&&c.enable(12291),n.clipDistance4&&c.enable(12292),n.clipDistance5&&c.enable(12293),n.clipDistance6&&c.enable(12294),n.clipDistance7&&c.enable(12295)),n.depthWriteEnabled!==void 0&&c.depthMask(Ftn("depthWriteEnabled",n.depthWriteEnabled)),n.depthCompare&&(n.depthCompare!=="always"?c.enable(2929):c.disable(2929),c.depthFunc(Zle("depthCompare",n.depthCompare))),n.clearDepth!==void 0&&c.clearDepth(n.clearDepth),n.stencilWriteMask){let u=n.stencilWriteMask;c.stencilMaskSeparate(1028,u),c.stencilMaskSeparate(1029,u)}if(n.stencilReadMask&&Qt.warn("stencilReadMask not supported under WebGL"),n.stencilCompare){let u=n.stencilReadMask||4294967295,d=Zle("depthCompare",n.stencilCompare);n.stencilCompare!=="always"?c.enable(2960):c.disable(2960),c.stencilFuncSeparate(1028,d,0,u),c.stencilFuncSeparate(1029,d,0,u)}if(n.stencilPassOperation&&n.stencilFailOperation&&n.stencilDepthFailOperation){let u=mRe("stencilPassOperation",n.stencilPassOperation),d=mRe("stencilFailOperation",n.stencilFailOperation),b=mRe("stencilDepthFailOperation",n.stencilDepthFailOperation);c.stencilOpSeparate(1028,d,b,u),c.stencilOpSeparate(1029,d,b,u)}switch(n.blend){case!0:c.enable(3042);break;case!1:c.disable(3042);break;default:}if(n.blendColorOperation||n.blendAlphaOperation){let u=f0t("blendColorOperation",n.blendColorOperation||"add"),d=f0t("blendAlphaOperation",n.blendAlphaOperation||"add");c.blendEquationSeparate(u,d);let b=Yle("blendColorSrcFactor",n.blendColorSrcFactor||"one"),w=Yle("blendColorDstFactor",n.blendColorDstFactor||"zero"),_=Yle("blendAlphaSrcFactor",n.blendAlphaSrcFactor||"one"),x=Yle("blendAlphaDstFactor",n.blendAlphaDstFactor||"zero");c.blendFuncSeparate(b,w,_,x)}}function Zle(s,n){return P4(s,n,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function mRe(s,n){return P4(s,n,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function f0t(s,n){return P4(s,n,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function Yle(s,n,r="color"){return P4(s,n,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:r==="color"?32769:32771,"one-minus-constant":r==="color"?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function Ntn(s,n){return`Illegal parameter ${n} for ${s}`}function P4(s,n,r){if(!(n in r))throw new Error(Ntn(s,n));return r[n]}function Ftn(s,n){return n}function Utn(s){let n=!0;for(let r in s){n=!1;break}return n}var bRe=Ve(()=>{Vr();_B()});function Kle(s){let n={};return s.addressModeU&&(n[10242]=wRe(s.addressModeU)),s.addressModeV&&(n[10243]=wRe(s.addressModeV)),s.addressModeW&&(n[32882]=wRe(s.addressModeW)),s.magFilter&&(n[10240]=vRe(s.magFilter)),(s.minFilter||s.mipmapFilter)&&(n[10241]=ztn(s.minFilter||"linear",s.mipmapFilter)),s.lodMinClamp!==void 0&&(n[33082]=s.lodMinClamp),s.lodMaxClamp!==void 0&&(n[33083]=s.lodMaxClamp),s.type==="comparison-sampler"&&(n[34892]=34894),s.compare&&(n[34893]=Zle("compare",s.compare)),s.maxAnisotropy&&(n[34046]=s.maxAnisotropy),n}function wRe(s){switch(s){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function vRe(s){switch(s){case"nearest":return 9728;case"linear":return 9729}}function ztn(s,n="none"){if(!n)return vRe(s);switch(n){case"none":return vRe(s);case"nearest":switch(s){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(s){case"nearest":return 9986;case"linear":return 9987}}}var _Re=Ve(()=>{bRe()});var Jle,d0t=Ve(()=>{Vr();_Re();Jle=class extends QL{device;handle;parameters;constructor(n,r){super(n,r),this.device=n,this.parameters=Kle(r),this.handle=r.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(n){for(let[r,c]of Object.entries(n)){let u=Number(r);switch(u){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,u,c);break;default:this.device.gl.samplerParameteri(this.handle,u,c);break}}}}});function yv(s,n,r){if(Gtn(n))return r(s);let{nocatch:c=!0}=n,u=wv.get(s);u.push(),bv(s,n);let d;if(c)d=r(s),u.pop();else try{d=r(s)}finally{u.pop()}return d}function Gtn(s){for(let n in s)return!1;return!0}var Qle=Ve(()=>{_B();aRe()});var o2,yRe=Ve(()=>{Vr();o2=class extends e4{device;gl;handle;texture;constructor(n,r){super(n,{...Pa.defaultProps,...r}),this.device=n,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}}});function eue(s){return jtn[s]}var jtn,xRe=Ve(()=>{jtn={5124:"sint32",5125:"uint32",5122:"sint16",5123:"uint16",5120:"sint8",5121:"uint8",5126:"float32",5131:"float16",33635:"uint16",32819:"uint16",32820:"uint16",33640:"uint32",35899:"uint32",35902:"uint32",34042:"uint32",36269:"uint32"}});function $tn(s,n=0){return n?new s.constructor(s.buffer,s.byteOffset+n,(s.byteLength-n)/s.BYTES_PER_ELEMENT):s}function Vtn(s,n){if(n%s.BYTES_PER_ELEMENT!==0)throw new Error(`Texture byteOffset ${n} must align to typed array element size ${s.BYTES_PER_ELEMENT}`);return n/s.BYTES_PER_ELEMENT}function Wtn(s){switch(s){case"1d":break;case"2d":return 3553;case"3d":return 32879;case"cube":return 34067;case"2d-array":return 35866;case"cube-array":break}throw new Error(s)}function CV(s,n,r){return n==="cube"?34069+r:s}var a2,tue=Ve(()=>{Vr();EB();_Re();Qle();yRe();xRe();a2=class extends Pa{device;gl;handle;sampler=void 0;view;glTarget;glFormat;glType;glInternalFormat;compressed;_textureUnit=0;_framebuffer=null;_framebufferAttachmentKey=null;constructor(n,r){super(n,r,{byteAlignment:1}),this.device=n,this.gl=this.device.gl;let c=zle(this.props.format);if(this.glTarget=Wtn(this.props.dimension),this.glInternalFormat=c.internalFormat,this.glFormat=c.format,this.glType=c.type,this.compressed=c.compressed,this.isHandleBorrowed&&this.props.handle===void 0)throw new Error("Borrowed WebGL textures require a texture handle");if(this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),!this.isHandleBorrowed){this.gl.bindTexture(this.glTarget,this.handle);let{dimension:u,width:d,height:b,depth:w,mipLevels:_,glTarget:x,glInternalFormat:T}=this;if(!this.compressed)switch(u){case"2d":case"cube":this.gl.texStorage2D(x,_,T,d,b);break;case"2d-array":case"3d":this.gl.texStorage3D(x,_,T,d,b,w);break;default:throw new Error(u)}this.gl.bindTexture(this.glTarget,null),this._initializeData(r.data)}this.ownsHandle?this.trackAllocatedMemory(this.getAllocatedByteLength(),"Texture"):this.trackReferencedMemory(this.getAllocatedByteLength(),"Texture"),this.isHandleBorrowed||this.setSampler(this.props.sampler),this.view=new o2(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this._framebuffer?.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.ownsHandle?(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory("Texture")):this.trackDeallocatedReferencedMemory("Texture"),this.destroyed=!0)}createView(n){return new o2(this.device,{...n,texture:this})}clone(n){if(this.isHandleBorrowed&&n&&(n.width!==this.width||n.height!==this.height))throw new Error(`Cannot resize borrowed read-only ${this}`);return super.clone(n)}setSampler(n={}){this._assertWritable("set sampler parameters on"),super.setSampler(n);let r=Kle(this.sampler.props);this._setSamplerParameters(r)}copyExternalImage(n){this._assertWritable("copy external image data into");let r=this._normalizeCopyExternalImageOptions(n);if(r.sourceX||r.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");let{glFormat:c,glType:u}=this,{image:d,depth:b,mipLevel:w,x:_,y:x,z:T,width:M,height:L}=r,I=CV(this.glTarget,this.dimension,T),D=r.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),yv(this.gl,D,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(I,w,_,x,M,L,c,u,d);break;case"2d-array":case"3d":this.gl.texSubImage3D(I,w,_,x,T,M,L,b,c,u,d);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:r.width,height:r.height}}copyElementImage(n){this._assertWritable("copy element image data into");let r=this._normalizeCopyElementImageOptions(n),{glFormat:c}=this,{element:u,depth:d,mipLevel:b,sourceX:w,sourceY:_,sourceWidth:x,sourceHeight:T,x:M,y:L,z:I,width:D,height:F}=r,O=CV(this.glTarget,this.dimension,I),z=r.flipY?{37440:!0}:{},Z=this.gl;if(d!==1||this.dimension!=="2d"&&this.dimension!=="cube")throw new Error(`${this} copyElementImage only supports 2d and cube textures on WebGL`);if(b!==0||M!==0||L!==0)throw new Error(`${this} copyElementImage only supports full base-level uploads on WebGL`);if(typeof Z.texElementImage2D!="function")throw new Error(`${this} copyElementImage is not supported by this WebGL implementation`);return this.gl.bindTexture(this.glTarget,this.handle),yv(this.gl,z,()=>{Z.texElementImage2D?.(O,c,u,{sx:w,sy:_,swidth:x??D,sheight:T??F,width:D,height:F})}),this.gl.bindTexture(this.glTarget,null),{width:r.width,height:r.height}}copyImageData(n){super.copyImageData(n)}readBuffer(n={},r){if(!r)throw new Error(`${this} readBuffer requires a destination buffer`);let c=this._getSupportedColorReadOptions(n),u=n.byteOffset??0,d=this.computeMemoryLayout(c);if(r.byteLength{this.gl.readPixels(c.x,c.y,c.width,c.height,this.glFormat,this.glType,u+w)})}finally{this.gl.bindBuffer(35051,null)}return r}async readDataAsync(n={}){throw new Error(`${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`)}writeBuffer(n,r={}){this._assertWritable("write buffer data into");let c=this._normalizeTextureWriteOptions(r),{width:u,height:d,depthOrArrayLayers:b,mipLevel:w,byteOffset:_,x,y:T,z:M}=c,{glFormat:L,glType:I,compressed:D}=this,F=CV(this.glTarget,this.dimension,M);if(D)throw new Error("writeBuffer for compressed textures is not implemented in WebGL");let{bytesPerPixel:O}=this.device.getTextureFormatInfo(this.format),z=O?c.bytesPerRow/O:void 0,Z={3317:this.byteAlignment,...z!==void 0?{3314:z}:{},32878:c.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,n.handle),yv(this.gl,Z,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(F,w,x,T,u,d,L,I,_);break;case"2d-array":case"3d":this.gl.texSubImage3D(F,w,x,T,M,u,d,b,L,I,_);break;default:}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(n,r={}){this._assertWritable("write data into");let c=this._normalizeTextureWriteOptions(r),u=ArrayBuffer.isView(n)?n:new Uint8Array(n),{width:d,height:b,depthOrArrayLayers:w,mipLevel:_,x,y:T,z:M,byteOffset:L}=c,{glFormat:I,glType:D,compressed:F}=this,O=CV(this.glTarget,this.dimension,M),z;if(!F){let{bytesPerPixel:ue}=this.device.getTextureFormatInfo(this.format);ue&&(z=c.bytesPerRow/ue)}let Z=this.compressed?{}:{3317:this.byteAlignment,...z!==void 0?{3314:z}:{},32878:c.rowsPerImage},H=Vtn(u,L),te=F?$tn(u,L):u,oe=this._getMipLevelSize(_),ne=x===0&&T===0&&M===0&&d===oe.width&&b===oe.height&&w===oe.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),yv(this.gl,Z,()=>{switch(this.dimension){case"2d":case"cube":F?ne?this.gl.compressedTexImage2D(O,_,I,d,b,0,te):this.gl.compressedTexSubImage2D(O,_,x,T,d,b,I,te):this.gl.texSubImage2D(O,_,x,T,d,b,I,D,u,H);break;case"2d-array":case"3d":F?ne?this.gl.compressedTexImage3D(O,_,I,d,b,w,0,te):this.gl.compressedTexSubImage3D(O,_,x,T,M,d,b,w,I,te):this.gl.texSubImage3D(O,_,x,T,M,d,b,w,I,D,u,H);break;default:}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(n,r){return 1}_getFramebuffer(){return this._framebuffer||=this.device.createFramebuffer({id:`framebuffer-for-${this.id}`,width:this.width,height:this.height,colorAttachments:[this]}),this._framebuffer}readDataSyncWebGL(n={}){let r=this._getSupportedColorReadOptions(n),c=this.computeMemoryLayout(r),u=eue(this.glType),d=JL(u),b=new d(c.byteLength/d.BYTES_PER_ELEMENT);return this._readColorTextureLayers(r,c,w=>{let _=new d(b.buffer,b.byteOffset+w,c.bytesPerImage/d.BYTES_PER_ELEMENT);this.gl.readPixels(r.x,r.y,r.width,r.height,this.glFormat,this.glType,_)}),b.buffer}_readColorTextureLayers(n,r,c){let u=this._getFramebuffer(),d=r.bytesPerRow/r.bytesPerPixel,b={3333:this.byteAlignment,...d!==n.width?{3330:d}:{}},w=this.gl.getParameter(3074),_=this.gl.bindFramebuffer(36160,u.handle);try{this.gl.readBuffer(36064),yv(this.gl,b,()=>{for(let x=0;x=2&&Qt.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(n))(),this.gl.bindTexture(this.glTarget,this.handle);for(let[r,c]of Object.entries(n)){let u=Number(r),d=c;switch(u){case 33082:case 33083:this.gl.texParameterf(this.glTarget,u,d);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,u,d);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,u,d);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,u,d);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,u,d);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(n){let{gl:r}=this;return n!==void 0&&(this._textureUnit=n,r.activeTexture(33984+n)),r.bindTexture(this.glTarget,this.handle),n}_unbind(n){let{gl:r}=this;return n!==void 0&&(this._textureUnit=n,r.activeTexture(33984+n)),r.bindTexture(this.glTarget,null),n}_assertWritable(n){if(this.isHandleBorrowed)throw new Error(`Cannot ${n} borrowed read-only ${this}`)}}});function p0t(s,n,r,c){let u=s,d=c;d===!0&&(d=1),d===!1&&(d=0);let b=typeof d=="number"?[d]:d;switch(r){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof c!="number")throw new Error("samplers must be set to integers");return s.uniform1i(n,c);case 5126:return s.uniform1fv(n,b);case 35664:return s.uniform2fv(n,b);case 35665:return s.uniform3fv(n,b);case 35666:return s.uniform4fv(n,b);case 5124:return s.uniform1iv(n,b);case 35667:return s.uniform2iv(n,b);case 35668:return s.uniform3iv(n,b);case 35669:return s.uniform4iv(n,b);case 35670:return s.uniform1iv(n,b);case 35671:return s.uniform2iv(n,b);case 35672:return s.uniform3iv(n,b);case 35673:return s.uniform4iv(n,b);case 5125:return u.uniform1uiv(n,b,1);case 36294:return u.uniform2uiv(n,b,2);case 36295:return u.uniform3uiv(n,b,3);case 36296:return u.uniform4uiv(n,b,4);case 35674:return s.uniformMatrix2fv(n,!1,b);case 35675:return s.uniformMatrix3fv(n,!1,b);case 35676:return s.uniformMatrix4fv(n,!1,b);case 35685:return u.uniformMatrix2x3fv(n,!1,b);case 35686:return u.uniformMatrix2x4fv(n,!1,b);case 35687:return u.uniformMatrix3x2fv(n,!1,b);case 35688:return u.uniformMatrix3x4fv(n,!1,b);case 35689:return u.uniformMatrix4x2fv(n,!1,b);case 35690:return u.uniformMatrix4x3fv(n,!1,b)}throw new Error("Illegal uniform")}var g0t=Ve(()=>{});function m0t(s){return qtn[s]}function nue(s){return Htn[s]}function iue(s){return!!w0t[s]}function b0t(s){return w0t[s]}var Htn,w0t,qtn,rue=Ve(()=>{Htn={5126:"f32",35664:"vec2",35665:"vec3",35666:"vec4",5124:"i32",35667:"vec2",35668:"vec3",35669:"vec4",5125:"u32",36294:"vec2",36295:"vec3",36296:"vec4",35670:"f32",35671:"vec2",35672:"vec3",35673:"vec4",35674:"mat2x2",35685:"mat2x3",35686:"mat2x4",35687:"mat3x2",35675:"mat3x3",35688:"mat3x4",35689:"mat4x2",35690:"mat4x3",35676:"mat4x4"},w0t={35678:{viewDimension:"2d",sampleType:"float"},35680:{viewDimension:"cube",sampleType:"float"},35679:{viewDimension:"3d",sampleType:"float"},35682:{viewDimension:"3d",sampleType:"depth"},36289:{viewDimension:"2d-array",sampleType:"float"},36292:{viewDimension:"2d-array",sampleType:"depth"},36293:{viewDimension:"cube",sampleType:"float"},36298:{viewDimension:"2d",sampleType:"sint"},36299:{viewDimension:"3d",sampleType:"sint"},36300:{viewDimension:"cube",sampleType:"sint"},36303:{viewDimension:"2d-array",sampleType:"uint"},36306:{viewDimension:"2d",sampleType:"uint"},36307:{viewDimension:"3d",sampleType:"uint"},36308:{viewDimension:"cube",sampleType:"uint"},36311:{viewDimension:"2d-array",sampleType:"uint"}},qtn={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126}});function _0t(s,n,r={}){let c={attributes:[],bindings:[]};c.attributes=Xtn(s,n);let u=Ktn(s,n,r);for(let _ of u){let x=_.uniforms.map(T=>({name:T.name,format:T.format,byteOffset:T.byteOffset,byteStride:T.byteStride,arrayLength:T.arrayLength}));c.bindings.push({type:"uniform",name:_.name,group:0,location:_.location,visibility:(_.vertex?1:0)|(_.fragment?2:0),minBindingSize:_.byteLength,uniforms:x})}let d=Ztn(s,n),b=0;for(let _ of d)if(iue(_.type)){let{viewDimension:x,sampleType:T}=b0t(_.type);c.bindings.push({type:"texture",name:_.name,group:0,location:b,viewDimension:x,sampleType:T}),_.textureUnit=b,b+=1}d.length&&(c.uniforms=d);let w=Ytn(s,n);return w?.length&&(c.varyings=w),c}function Xtn(s,n){let r=[],c=s.getProgramParameter(n,35721);for(let u=0;u=0){let x=nue(w),T=/instance/i.test(b)?"instance":"vertex";r.push({name:b,location:_,stepMode:T,type:x})}}return r.sort((u,d)=>u.location-d.location),r}function Ytn(s,n){let r=[],c=s.getProgramParameter(n,35971);for(let u=0;uu.location-d.location),r}function Ztn(s,n){let r=[],c=s.getProgramParameter(n,35718);for(let u=0;u1)for(let I=0;Ib.location-w.location),c}function Jtn(s,n){for(let r of s.uniforms){let c=n.uniforms.find(u=>r.name===u.name||r.name.endsWith(`.${u.name}`));if(!c)throw new Error(`Failed to validate WebGL uniform block "${n.name}": reflected unexpected member "${r.name}"`);if(r.format!==c.format||r.arrayLength!==c.arrayLength||r.byteOffset!==c.byteOffset||r.byteStride!==c.byteStride)throw new Error(`Failed to validate WebGL uniform block "${n.name}": reflected layout for "${r.name}" does not match supplied std140 metadata`)}}function Qtn(s,n,r){let c=new Map;for(let d of r.uniformBlockLayouts||[])c.set(d.name,tnn(d));for(let d of r.shaderLayout?.bindings||[])inn(d)&&c.set(d.name,d);let u=new Map;for(let d of c.values()){let b=enn(s,n,d.name);if(!b)continue;let{blockIndex:w,blockName:_}=b;if(u.has(w))throw new Error(`Multiple supplied uniform block layouts resolve to active WebGL block "${_}"`);u.set(w,{name:_,location:w,byteLength:d.minBindingSize,vertex:!!(d.visibility&&d.visibility&1),fragment:!!(d.visibility&&d.visibility&2),uniformCount:d.uniforms.length,uniforms:d.uniforms.map(x=>({...x}))})}return u}function enn(s,n,r){let c=r.endsWith("Uniforms")?[r,r.slice(0,-8)]:[r,`${r}Uniforms`];for(let u of c){let d=s.getUniformBlockIndex(n,u);if(d!==4294967295){if(!Number.isInteger(d)||d<0)throw new Error(`Failed to resolve WebGL uniform block "${u}": getUniformBlockIndex returned ${String(d)}`);return{blockIndex:d,blockName:u}}}return null}function v0t(s,n,r,c){let u=c||s.getActiveUniformBlockName(n,r);if(!u)throw new Error(`Failed to reflect WebGL uniform block at index ${r}: missing block name`);let d=(H,te)=>{let oe=s.getActiveUniformBlockParameter(n,r,H);if(oe==null)throw new Error(`Failed to reflect WebGL uniform block "${u}": ${te} returned null`);return oe},b=L4(d(35391,"UNIFORM_BLOCK_BINDING"),u,"UNIFORM_BLOCK_BINDING",0),w=L4(d(35392,"UNIFORM_BLOCK_DATA_SIZE"),u,"UNIFORM_BLOCK_DATA_SIZE",0),_=L4(d(35394,"UNIFORM_BLOCK_ACTIVE_UNIFORMS"),u,"UNIFORM_BLOCK_ACTIVE_UNIFORMS",0),x=y0t(d(35395,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES"),u,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",_),T=AV(s,n,x,35383,"UNIFORM_TYPE",u,_),M=AV(s,n,x,35384,"UNIFORM_SIZE",u,_),L=AV(s,n,x,35386,"UNIFORM_BLOCK_INDEX",u,_),I=AV(s,n,x,35387,"UNIFORM_OFFSET",u,_),D=AV(s,n,x,35388,"UNIFORM_ARRAY_STRIDE",u,_),F=[];for(let H=0;H<_;H++){if(L[H]!==r)throw new Error(`Failed to reflect WebGL uniform block "${u}": active uniform index ${x[H]} belongs to block ${L[H]}, expected ${r}`);let te=x[H],oe=s.getActiveUniform(n,te);if(!oe)throw new Error(`Failed to reflect WebGL uniform block "${u}": getActiveUniform(${te}) returned null`);let ne=L4(T[H],u,`UNIFORM_TYPE[${H}]`,1),ue=L4(M[H],u,`UNIFORM_SIZE[${H}]`,1),Te=L4(I[H],u,`UNIFORM_OFFSET[${H}]`,0),Q=L4(D[H],u,`UNIFORM_ARRAY_STRIDE[${H}]`,0);if(oe.type!==ne||oe.size!==ue)throw new Error(`Failed to reflect WebGL uniform block "${u}": getActiveUniform(${te}) disagrees with getActiveUniforms`);F.push({name:oe.name,format:nue(ne),arrayLength:ue,byteOffset:Te,byteStride:Q})}let O={name:u,location:b,byteLength:w,vertex:!!d(35396,"UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER"),fragment:!!d(35398,"UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER"),uniformCount:_,uniforms:F},z=new Set(O.uniforms.map(H=>H.name.split(".")[0]).filter(H=>!!H)),Z=O.name.replace(/Uniforms$/,"");if(z.size===1&&!z.has(O.name)&&!z.has(Z)){let[H]=z;Qt.warn(`Uniform block "${O.name}" uses GLSL instance "${H}". luma.gl binds uniform buffers by block name ("${O.name}") and alias ("${Z}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}return O}function AV(s,n,r,c,u,d,b){let w=s.getActiveUniforms(n,r,c);if(w===null)throw new Error(`Failed to reflect WebGL uniform block "${d}": ${u} returned null`);return y0t(w,d,u,b)}function y0t(s,n,r,c){if(!Array.isArray(s)&&!ArrayBuffer.isView(s))throw new Error(`Failed to reflect WebGL uniform block "${n}": ${r} returned a non-array value`);let u=Array.from(s);if(u.length!==c||u.some(d=>!Number.isInteger(d)))throw new Error(`Failed to reflect WebGL uniform block "${n}": ${r} returned ${u.length} invalid values, expected ${c}`);return u}function L4(s,n,r,c){if(!Number.isInteger(s)||s{if(typeof b=="string"){let w=n[d];if(!w)throw new Error(`Missing std140 layout field ${d}`);r.push({name:d,format:w.shaderType,arrayLength:1,byteOffset:w.offset*4,byteStride:0});return}if(Array.isArray(b)){u(d,b[0],b[1]);return}for(let[w,_]of Object.entries(b))c(`${d}.${w}`,_)},u=(d,b,w)=>{if(typeof b=="string"){let _=n[`${d}[0]`],x=w>1?n[`${d}[1]`]:void 0;if(!_)throw new Error(`Missing std140 array layout field ${d}[0]`);r.push({name:`${d}[0]`,format:_.shaderType,arrayLength:w,byteOffset:_.offset*4,byteStride:x?(x.offset-_.offset)*4:0});return}if(Array.isArray(b))throw new Error(`Nested uniform arrays are not supported for ${d}`);for(let[_,x]of Object.entries(b)){if(typeof x!="string")throw new Error(`Composite uniform array members are not supported for ${d}`);let T=`${d}[0].${_}`,M=`${d}[1].${_}`,L=n[T],I=w>1?n[M]:void 0;if(!L)throw new Error(`Missing std140 array layout field ${T}`);r.push({name:T,format:L.shaderType,arrayLength:w,byteOffset:L.offset*4,byteStride:I?(I.offset-L.offset)*4:0})}};for(let[d,b]of Object.entries(s))c(d,b);return r}function inn(s){return s.type==="uniform"&&Number.isInteger(s.minBindingSize)&&s.minBindingSize>=0&&Array.isArray(s.uniforms)&&s.uniforms.every(n=>typeof n.name=="string"&&typeof n.format=="string"&&Number.isInteger(n.arrayLength)&&n.arrayLength>0&&Number.isInteger(n.byteOffset)&&n.byteOffset>=0&&Number.isInteger(n.byteStride)&&n.byteStride>=0)}function rnn(s){if(s[s.length-1]!=="]")return{name:s,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(s);return{name:UM(r?.[1],`Failed to parse GLSL uniform name ${s}`),length:r?.[2]?1:0,isArray:!!r?.[2]}}var x0t=Ve(()=>{Vr();rue()});function snn(s,n){let r={...s,attributes:s.attributes.map(c=>({...c})),bindings:s.bindings.map(c=>({...c}))};for(let c of n?.attributes||[]){let u=r.attributes.find(d=>d.name===c.name);u?(u.type=c.type||u.type,u.stepMode=c.stepMode||u.stepMode):Qt.warn(`shader layout attribute ${c.name} not present in shader`)}for(let c of n?.bindings||[]){let u=S0t(r,c.name);if(!u){Qt.warn(`shader layout binding ${c.name} not present in shader`);continue}Object.assign(u,c)}return r}function S0t(s,n){return s.bindings.find(r=>r.name===n||r.name===`${n}Uniforms`||`${r.name}Uniforms`===n)}function E0t(s,n){return s[n]||s[`${n}Uniforms`]||s[n.replace(/Uniforms$/,"")]}var sue,M0t=Ve(()=>{Vr();g0t();Hle();$le();tue();yRe();x0t();sue=class extends Mb{device;handle;vs;fs;introspectedLayout;bindings={};uniforms={};varyings=null;_uniformCount=0;_uniformSetters={};get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}constructor(n,r){super(n,r),this.device=n;let c=this.sharedRenderPipeline||this.device._createSharedRenderPipelineWebGL(r);this.sharedRenderPipeline=c,this.handle=c.handle,this.vs=c.vs,this.fs=c.fs,this.linkStatus=c.linkStatus,this.introspectedLayout=_0t(this.device.gl,this.handle,{uniformBlockLayouts:r._uniformBlockLayouts,shaderLayout:r.shaderLayout}),this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.shaderLayout=r.shaderLayout?snn(this.introspectedLayout,r.shaderLayout):this.introspectedLayout}destroy(){this.destroyed||(this.sharedRenderPipeline&&!this.props._sharedRenderPipeline&&this.sharedRenderPipeline.destroy(),this.destroyResource())}setBindings(n,r){let c=GD(s4(this.shaderLayout,n));for(let[u,d]of Object.entries(c)){let b=S0t(this.shaderLayout,u);if(b){switch(d||Qt.warn(`Unsetting binding "${u}" in render pipeline "${this.id}"`)(),b.type){case"uniform":if(!(d instanceof _v)&&!(d.buffer instanceof _v))throw new Error("buffer value");break;case"texture":if(!(d instanceof o2||d instanceof a2||d instanceof s2))throw new Error(`${this} Bad texture binding for ${u}`);break;case"sampler":Qt.warn(`Ignoring sampler ${u}`)();break;default:throw new Error(b.type)}this.bindings[u]=d}else{let w=this.shaderLayout.bindings.map(_=>`"${_.name}"`).join(", ");r?.disableWarnings||Qt.warn(`No binding "${u}" in render pipeline "${this.id}", expected one of ${w}`,d)()}}}draw(n){let r=n.renderPass,c=n.bindGroups?GD(n.bindGroups):n.bindings||this.bindings;return r.setPipeline(this),r.setBindings(c),r.setVertexArray(n.vertexArray),r.draw({parameters:n.parameters,topology:n.topology,isInstanced:n.isInstanced,vertexCount:n.vertexCount,indexCount:n.indexCount,instanceCount:n.instanceCount,firstVertex:n.firstVertex,firstIndex:n.firstIndex,firstInstance:n.firstInstance,baseVertex:n.baseVertex,transformFeedback:n.transformFeedback,uniforms:n.uniforms})}_areTexturesRenderable(n){let r=!0;for(let c of this.shaderLayout.bindings)E0t(n,c.name)||(Qt.warn(`Binding ${c.name} not found in ${this.id}`)(),r=!1);return r}_applyBindings(n,r){if(this._syncLinkStatus(),this.linkStatus!=="success")return;let{gl:c}=this.device;c.useProgram(this.handle);let u=0,d=0;for(let b of this.shaderLayout.bindings){let w=E0t(n,b.name);if(!w)throw new Error(`No value for binding ${b.name} in ${this.id}`);switch(b.type){case"uniform":let{name:_}=b,x=c.getUniformBlockIndex(this.handle,_);if(x===4294967295)throw new Error(`Invalid uniform block name ${_}`);if(c.uniformBlockBinding(this.handle,x,d),w instanceof _v)c.bindBufferBase(35345,d,w.handle);else{let M=w;c.bindBufferRange(35345,d,M.buffer.handle,M.offset||0,M.size||M.buffer.byteLength-(M.offset||0))}d+=1;break;case"texture":if(!(w instanceof o2||w instanceof a2||w instanceof s2))throw new Error("texture");let T;if(w instanceof o2)T=w.texture;else if(w instanceof a2)T=w;else if(w instanceof s2&&w.colorAttachments[0]instanceof o2)Qt.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),T=w.colorAttachments[0].texture;else throw new Error("No texture");c.activeTexture(33984+u),c.bindTexture(T.glTarget,T.handle),u+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${b.type}' not supported in WebGL`)}}}_applyUniforms(n){for(let r of this.shaderLayout.uniforms||[]){let{name:c,location:u,type:d,textureUnit:b}=r,w=n[c]??b;w!==void 0&&p0t(this.device.gl,u,d,w)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}}});var T0t,oue,C0t=Ve(()=>{Vr();rue();T0t=4,oue=class extends w${device;handle;vs;fs;linkStatus="pending";constructor(n,r){super(n,r),this.device=n,this.handle=r.handle||this.device.gl.createProgram(),this.vs=r.vs,this.fs=r.fs,r.varyings&&r.varyings.length>0&&this.device.gl.transformFeedbackVaryings(this.handle,r.varyings,r.bufferMode||35981),this._linkShaders()}destroy(){this.destroyed||(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.handle.destroyed=!0,this.destroyResource())}async _linkShaders(){let{gl:n}=this.device;if(n.attachShader(this.handle,this.vs.handle),n.attachShader(this.handle,this.fs.handle),Qt.time(T0t,`linkProgram for ${this.id}`)(),n.linkProgram(this.handle),Qt.timeEnd(T0t,`linkProgram for ${this.id}`)(),!this.device.features.has("compilation-status-async-webgl")){let c=this._getLinkStatus();this._reportLinkStatus(c);return}Qt.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),Qt.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let r=this._getLinkStatus();this._reportLinkStatus(r)}async _reportLinkStatus(n){switch(n){case"success":return;default:let r=n==="link-error"?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${r} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader();break;case"success":break}switch(this.fs?.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`${this} ${r} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader();break;case"success":break}let c=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${r} during ${n}: ${c}`),this)(),this.device.debug()}}_getLinkStatus(){let{gl:n}=this.device;return n.getProgramParameter(this.handle,35714)?(this._initializeSamplerUniforms(),n.validateProgram(this.handle),n.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}_initializeSamplerUniforms(){let{gl:n}=this.device;n.useProgram(this.handle);let r=0,c=n.getProgramParameter(this.handle,35718);for(let u=0;u1){let b=Int32Array.from({length:r.size},(w,_)=>u+_);return d.uniform1iv(n,b),u+r.size}return d.uniform1i(n,u),u+1}async _waitForLinkComplete(){let n=async u=>await new Promise(d=>setTimeout(d,u));if(!this.device.features.has("compilation-status-async-webgl")){await n(10);return}let{gl:c}=this.device;for(;;){if(c.getProgramParameter(this.handle,37297))return;await n(10)}}}});function onn(s,n){let r=n.sourceBuffer,c=n.destinationBuffer;s.gl.bindBuffer(36662,r.handle),s.gl.bindBuffer(36663,c.handle),s.gl.copyBufferSubData(36662,36663,n.sourceOffset??0,n.destinationOffset??0,n.size),s.gl.bindBuffer(36662,null),s.gl.bindBuffer(36663,null)}function ann(s,n){let{sourceBuffer:r,byteOffset:c=0,destinationTexture:u,mipLevel:d=0,origin:b=[0,0,0],aspect:w="all",bytesPerRow:_,rowsPerImage:x,size:T}=n;if(w!=="all")throw new Error("copyBufferToTexture aspect is not supported in WebGL");u.writeBuffer(r,{byteOffset:c,bytesPerRow:_,rowsPerImage:x,mipLevel:d,x:b[0]??0,y:b[1]??0,z:b[2]??0,width:T[0],height:T[1],depthOrArrayLayers:T[2]})}function cnn(s,n){let{sourceTexture:r,mipLevel:c=0,aspect:u="all",width:d=n.sourceTexture.width,height:b=n.sourceTexture.height,depthOrArrayLayers:w,origin:_=[0,0,0],destinationBuffer:x,byteOffset:T=0,bytesPerRow:M,rowsPerImage:L}=n;if(r instanceof Pa){r.readBuffer({x:_[0]??0,y:_[1]??0,z:_[2]??0,width:d,height:b,depthOrArrayLayers:w,mipLevel:c,aspect:u,byteOffset:T},x);return}if(u!=="all")throw new Error("aspect not supported in WebGL");if(c!==0||w!==void 0||M||L)throw new Error("not implemented");let{framebuffer:I,destroyFramebuffer:D}=A0t(r),F;try{let O=x,z=d||I.width,Z=b||I.height,H=UM(I.colorAttachments[0]),te=zle(H.texture.props.format),oe=te.format,ne=te.type;s.gl.bindBuffer(35051,O.handle),F=s.gl.bindFramebuffer(36160,I.handle),s.gl.readPixels(_[0],_[1],z,Z,oe,ne,T)}finally{s.gl.bindBuffer(35051,null),F!==void 0&&s.gl.bindFramebuffer(36160,F),D&&I.destroy()}}function lnn(s,n){let{sourceTexture:r,destinationMipLevel:c=0,origin:u=[0,0],destinationOrigin:d=[0,0,0],destinationTexture:b}=n,{width:w=n.destinationTexture.width,height:_=n.destinationTexture.height}=n,{framebuffer:x,destroyFramebuffer:T}=A0t(r),[M=0,L=0]=u,[I,D,F]=d,O=s.gl.bindFramebuffer(36160,x.handle),z,Z;if(b instanceof a2)z=b,w=Number.isFinite(w)?w:z.width,_=Number.isFinite(_)?_:z.height,z._bind(0),Z=z.glTarget;else throw new Error("invalid destination");switch(Z){case 3553:case 34067:s.gl.copyTexSubImage2D(Z,c,I,D,M,L,w,_);break;case 35866:case 32879:s.gl.copyTexSubImage3D(Z,c,I,D,F,M,L,w,_);break;default:}z&&z._unbind(),s.gl.bindFramebuffer(36160,O),T&&x.destroy()}function A0t(s){if(s instanceof Pa){let{width:n,height:r,id:c}=s;return{framebuffer:s.device.createFramebuffer({id:`framebuffer-for-${c}`,width:n,height:r,colorAttachments:[s]}),destroyFramebuffer:!0}}return{framebuffer:s,destroyFramebuffer:!1}}var aue,P0t=Ve(()=>{Vr();EB();tue();aue=class extends y${device;handle=null;commands=[];constructor(n,r={}){super(n,r),this.device=n}_executeCommands(n=this.commands){for(let r of n)switch(r.name){case"copy-buffer-to-buffer":onn(this.device,r.options);break;case"copy-buffer-to-texture":ann(this.device,r.options);break;case"copy-texture-to-buffer":cnn(this.device,r.options);break;case"copy-texture-to-texture":lnn(this.device,r.options);break;default:throw new Error(r.name)}}}});function L0t(s){switch(s){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"triangle-list":return 4;case"triangle-strip":return 5;default:throw new Error(s)}}function k0t(s){switch(s){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;default:throw new Error(s)}}var ERe=Ve(()=>{});var unn,cue,R0t=Ve(()=>{Vr();Qle();_B();ERe();bRe();unn=[1,2,4,8],cue=class extends v${device;handle=null;glParameters={};pipeline=null;bindings={};bindingsPipeline=null;vertexArray=null;constructor(n,r){super(n,r),this.device=n;let c=this.props.framebuffer,u=!c||c.handle===null;u&&n.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();let d;if(!r?.parameters?.viewport)if(!u&&c){let{width:b,height:w}=c;d=[0,0,b,w]}else{let[b,w]=n.getDefaultCanvasContext().getDrawingBufferSize();d=[0,0,b,w]}if(this.device.pushState(),this.setParameters({viewport:d,...this.props.parameters}),!u&&c?.colorAttachments.length){let b=c.colorAttachments.map((w,_)=>36064+_);this.device.gl.drawBuffers(b)}else u&&this.device.gl.drawBuffers([1029]);this.clear(),this.props.timestampQuerySet&&this.props.beginTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.beginTimestampIndex)}end(){this.destroyed||(this.props.timestampQuerySet&&this.props.endTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.endTimestampIndex),this.device.popState(),this.destroy())}pushDebugGroup(n){}popDebugGroup(){}insertDebugMarker(n){}executeBundles(n){throw new Error("Render bundles are only supported in WebGPU")}setParameters(n={}){let r={...this.glParameters};r.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(r.depthMask=!this.props.depthReadOnly),r.stencilMask=this.props.stencilReadOnly?0:1,r[35977]=this.props.discard,n.viewport&&(n.viewport.length>=6?(r.viewport=n.viewport.slice(0,4),r.depthRange=[n.viewport[4],n.viewport[5]]):r.viewport=n.viewport),n.scissorRect&&(r.scissorTest=!0,r.scissor=n.scissorRect),n.blendConstant&&(r.blendColor=n.blendConstant),n.stencilReference!==void 0&&(r[2967]=n.stencilReference,r[36003]=n.stencilReference),"colorMask"in n&&(r.colorMask=unn.map(c=>!!(c&n.colorMask))),this.glParameters=r,bv(this.device.gl,r)}setPipeline(n){this.pipeline=n}setBindings(n,r){if(!this.pipeline)throw new Error("RenderPass.setPipeline() must be called before setBindings()");this.bindings=GD(s4(this.pipeline.shaderLayout,n)),this.bindingsPipeline=this.pipeline}setVertexArray(n){this.vertexArray=n}draw(n){let r=this.pipeline,c=this.vertexArray;if(!r)throw new Error("RenderPass.setPipeline() must be called before draw()");if(!c)throw new Error("RenderPass.setVertexArray() must be called before draw()");if(r.shaderLayout.bindings.length>0&&this.bindingsPipeline!==r)throw new Error("RenderPass.setBindings() must be called after setPipeline() before draw()");r._syncLinkStatus();let{parameters:u=r.props.parameters,topology:d=r.props.topology,vertexCount:b,indexCount:w,instanceCount:_,isInstanced:x=!1,firstVertex:T=0,transformFeedback:M,uniforms:L=r.uniforms}=n,I=L0t(d),D=!!c.indexBuffer,F=c.indexBuffer?.glIndexType,O=w??b??0;if(r.linkStatus!=="success")return Qt.info(2,`RenderPipeline:${r.id}.draw() aborted - waiting for shader linking`)(),!1;if(!r._areTexturesRenderable(this.bindings))return Qt.info(2,`RenderPipeline:${r.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(r.handle),c.bindBeforeRender(this);let z=M;return z&&z.begin(r.props.topology),r._applyBindings(this.bindings,{disableWarnings:r.props.disableWarnings}),r._applyUniforms(L),h0t(this.device,u,this.glParameters,()=>{D&&x?this.device.gl.drawElementsInstanced(I,O,F,T,_||0):D?this.device.gl.drawElements(I,O,F,T):x?this.device.gl.drawArraysInstanced(I,T,b||0,_||0):this.device.gl.drawArrays(I,T,b||0),z&&z.end()}),c.unbindAfterRender(this),!0}drawIndirect(n,r=0){throw new Error("Indirect drawing is only supported in WebGPU")}drawIndexedIndirect(n,r=0){throw new Error("Indirect drawing is only supported in WebGPU")}beginOcclusionQuery(n){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let n={...this.glParameters},r=0;this.props.clearColors&&this.props.clearColors.forEach((c,u)=>{c&&this.clearColorBuffer(u,c)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(r|=16384,n.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=256,n.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=1024,n.clearStencil=this.props.clearStencil),r!==0&&yv(this.device.gl,n,()=>{this.device.gl.clear(r)})}clearColorBuffer(n=0,r=[0,0,0,0]){yv(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,n,r);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,n,r);break;case Float32Array:this.device.gl.clearBufferfv(6144,n,r);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}});var PV,I0t=Ve(()=>{Vr();P0t();R0t();PV=class extends _${device;handle=null;commandBuffer;constructor(n,r){super(n,r),this.device=n,this.commandBuffer=new aue(n,{id:this.id,userData:this.userData})}destroy(){this.destroyResource()}finish(){return this.destroy(),this.commandBuffer}beginRenderPass(n={}){return new cue(this.device,this._applyTimeProfilingToPassProps(n))}beginComputePass(n={}){throw new Error("ComputePass not supported in WebGL")}copyBufferToBuffer(n){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:n})}copyBufferToTexture(n){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:n})}copyTextureToBuffer(n){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:n})}copyTextureToTexture(n){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:n})}pushDebugGroup(n){}popDebugGroup(){}insertDebugMarker(n){}resolveQuerySet(n,r,c){throw new Error("resolveQuerySet is not supported in WebGL")}writeTimestamp(n,r){n.writeTimestamp(r)}}});function D0t(s){let{target:n,source:r,start:c=0,count:u=1}=s,d=r.length,b=u*d,w=0;for(let _=c;w{});function fnn(s){return Array.isArray(s)?new Float32Array(s):s}function hnn(s,n){if(!s||!n||s.length!==n.length||s.constructor!==n.constructor)return!1;for(let r=0;r{Vr();VL();lRe();B0t();lue=class s extends x${get[Symbol.toStringTag](){return"VertexArray"}device;handle;attributeInfosByLocation;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(n){return yPe()==="Chrome"}constructor(n,r){super(n,r),this.device=n,this.handle=this.device.gl.createVertexArray(),this.attributeInfosByLocation=new Array(this.maxVertexAttributes).fill(null);for(let c of Object.values(A$(r.shaderLayout,r.bufferLayout)))this.attributeInfosByLocation[c.location]=c}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(n){let r=n;if(r&&r.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,r?r.handle:null),this.indexBuffer=r,this.device.gl.bindVertexArray(null)}setBuffer(n,r){let c=r;if(c.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:u,type:d,stride:b,offset:w,normalized:_,integer:x,divisor:T}=this._getAccessor(n);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,c.handle),x?this.device.gl.vertexAttribIPointer(n,u,d,b,w):this.device.gl.vertexAttribPointer(n,u,d,_,b,w),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(n),this.device.gl.vertexAttribDivisor(n,T||0),this.attributes[n]=c,this.device.gl.bindVertexArray(null)}setConstantWebGL(n,r){this._enable(n,!1),this.attributes[n]=r}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let n=0;n{Vr();fue();ERe();uue=class extends E${device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(n,r){super(n,r),this.device=n,this.gl=n.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,r.buffers&&this.setBuffers(r.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(n="point-list"){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(k0t(n))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(n){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let[r,c]of Object.entries(n))this.setBuffer(r,c)})}setBuffer(n,r){let c=this._getVaryingIndex(n),{buffer:u,byteLength:d,byteOffset:b}=this._getBufferRange(r);if(c<0){this.unusedBuffers[n]=u,Qt.warn(`${this.id} unusedBuffers varying buffer ${n}`)();return}this.buffers[c]={buffer:u,byteLength:d,byteOffset:b},this.bindOnUse||this._bindBuffer(c,u,b,d)}getBuffer(n){if(N0t(n))return this.buffers[n]||null;let r=this._getVaryingIndex(n);return this.buffers[r]??null}bind(n=this.handle){if(typeof n!="function")return this.gl.bindTransformFeedback(36386,n),this;let r;return this._bound?r=n():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,r=n(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),r}unbind(){this.bind(null)}_getBufferRange(n){if(n instanceof _v)return{buffer:n,byteOffset:0,byteLength:n.byteLength};let{buffer:r,byteOffset:c=0,byteLength:u=n.buffer.byteLength}=n;return{buffer:r,byteOffset:c,byteLength:u}}_getVaryingIndex(n){if(N0t(n))return Number(n);for(let r of this.layout.varyings||[])if(n===r.name)return r.location;return-1}_bindBuffers(){for(let[n,r]of Object.entries(this.buffers)){let{buffer:c,byteLength:u,byteOffset:d}=this._getBufferRange(r);this._bindBuffer(Number(n),c,d,u)}}_unbindBuffers(){for(let n in this.buffers)this.gl.bindBufferBase(35982,Number(n),null)}_bindBuffer(n,r,c=0,u){let d=r&&r.handle;!d||u===void 0?this.gl.bindBufferBase(35982,n,d):this.gl.bindBufferRange(35982,n,d,c,u)}}});var hue,U0t=Ve(()=>{Vr();hue=class extends S${device;handle;_timestampPairs=[];_pendingReads=new Set;_occlusionQuery=null;_occlusionActive=!1;get[Symbol.toStringTag](){return"QuerySet"}constructor(n,r){if(super(n,r),this.device=n,r.type==="timestamp"){if(r.count<2)throw new Error("Timestamp QuerySet requires at least two query slots");this._timestampPairs=new Array(Math.ceil(r.count/2)).fill(null).map(()=>({activeQuery:null,completedQueries:[]})),this.handle=null}else{if(r.count>1)throw new Error("WebGL occlusion QuerySet can only have one value");let c=this.device.gl.createQuery();if(!c)throw new Error("WebGL query not supported");this.handle=c}Object.seal(this)}destroy(){if(!this.destroyed){this.handle&&this.device.gl.deleteQuery(this.handle);for(let n of this._timestampPairs){n.activeQuery&&(this._cancelPendingQuery(n.activeQuery),this.device.gl.deleteQuery(n.activeQuery.handle));for(let r of n.completedQueries)this._cancelPendingQuery(r),this.device.gl.deleteQuery(r.handle)}this._occlusionQuery&&(this._cancelPendingQuery(this._occlusionQuery),this.device.gl.deleteQuery(this._occlusionQuery.handle));for(let n of Array.from(this._pendingReads))this._cancelPendingQuery(n);this.destroyResource()}}isResultAvailable(n){return this.props.type==="timestamp"?n===void 0?this._timestampPairs.some((r,c)=>this._isTimestampPairAvailable(c)):this._isTimestampPairAvailable(this._getTimestampPairIndex(n)):this._occlusionQuery?this._pollQueryAvailability(this._occlusionQuery):!1}async readResults(n){let r=n?.firstQuery||0,c=n?.queryCount||this.props.count-r;if(this._validateRange(r,c),this.props.type==="timestamp"){let u=new Array(c).fill(0n),d=Math.floor(r/2),b=Math.floor((r+c-1)/2);for(let w=d;w<=b;w++){let _=await this._consumeTimestampPairResult(w),x=w*2,T=x+1;x>=r&&x=r&&T=this.props.count||r<=n)throw new Error("Timestamp duration range is out of bounds");if(n%2!==0||r!==n+1)throw new Error("WebGL timestamp durations require adjacent even/odd query indices");let c=await this._consumeTimestampPairResult(this._getTimestampPairIndex(n));return Number(c)/1e6}beginOcclusionQuery(){if(this.props.type!=="occlusion")throw new Error("Occlusion queries require an occlusion QuerySet");if(!this.handle)throw new Error("WebGL occlusion query is not available");if(this._occlusionActive)throw new Error("Occlusion query is already active");this.device.gl.beginQuery(35887,this.handle),this._occlusionQuery={handle:this.handle,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null},this._occlusionActive=!0}endOcclusionQuery(){if(!this._occlusionActive)throw new Error("Occlusion query is not active");this.device.gl.endQuery(35887),this._occlusionActive=!1}writeTimestamp(n){if(this.props.type!=="timestamp")throw new Error("Timestamp writes require a timestamp QuerySet");let r=this._getTimestampPairIndex(n),c=this._timestampPairs[r];if(n%2===0){if(c.activeQuery)throw new Error("Timestamp query pair is already active");let u=this.device.gl.createQuery();if(!u)throw new Error("WebGL query not supported");let d={handle:u,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null};this.device.gl.beginQuery(35007,u),c.activeQuery=d;return}if(!c.activeQuery)throw new Error("Timestamp query pair was ended before it was started");this.device.gl.endQuery(35007),c.completedQueries.push(c.activeQuery),c.activeQuery=null}_validateRange(n,r){if(n<0||r<0||n+r>this.props.count)throw new Error("Query read range is out of bounds")}_getTimestampPairIndex(n){if(n<0||n>=this.props.count)throw new Error("Query index is out of bounds");return Math.floor(n/2)}_isTimestampPairAvailable(n){let r=this._timestampPairs[n];return!r||r.completedQueries.length===0?!1:this._pollQueryAvailability(r.completedQueries[0])}_pollQueryAvailability(n){if(n.cancelled||this.destroyed)return n.result=0n,!0;if(n.result!==null||n.disjoint)return!0;if(!this.device.gl.getQueryParameter(n.handle,34919))return!1;let c=!!this.device.gl.getParameter(36795);return n.disjoint=c,n.result=c?0n:BigInt(this.device.gl.getQueryParameter(n.handle,34918)),!0}async _consumeTimestampPairResult(n){let r=this._timestampPairs[n];if(!r||r.completedQueries.length===0)throw new Error("Timestamp query pair has no completed result");let c=r.completedQueries.shift();try{return await this._consumeQueryResult(c)}finally{this.device.gl.deleteQuery(c.handle)}}_consumeQueryResult(n){return n.promise||(this._pendingReads.add(n),n.promise=new Promise((r,c)=>{n.resolve=r,n.reject=c;let u=()=>{if(n.pollRequestId=null,n.cancelled||this.destroyed){this._pendingReads.delete(n),n.promise=null,n.resolve=null,n.reject=null,r(0n);return}if(!this._pollQueryAvailability(n)){n.pollRequestId=this._requestAnimationFrame(u);return}this._pendingReads.delete(n),n.promise=null,n.resolve=null,n.reject=null,n.disjoint?c(new Error("GPU timestamp query was invalidated by a disjoint event")):r(n.result||0n)};u()})),n.promise}_cancelPendingQuery(n){if(this._pendingReads.delete(n),n.cancelled=!0,n.pollRequestId!==null&&(this._cancelAnimationFrame(n.pollRequestId),n.pollRequestId=null),n.resolve){let r=n.resolve;n.promise=null,n.resolve=null,n.reject=null,r(0n)}}_requestAnimationFrame(n){return requestAnimationFrame(n)}_cancelAnimationFrame(n){cancelAnimationFrame(n)}}});var due,z0t=Ve(()=>{Vr();due=class extends M${device;gl;handle;signaled;_signaled=!1;constructor(n,r={}){super(n,{}),this.device=n,this.gl=n.gl;let c=this.props.handle||this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE,0);if(!c)throw new Error("Failed to create WebGL fence");this.handle=c,this.signaled=new Promise(u=>{let d=()=>{let b=this.gl.clientWaitSync(this.handle,0,0);b===this.gl.ALREADY_SIGNALED||b===this.gl.CONDITION_SATISFIED?(this._signaled=!0,u()):setTimeout(d,1)};d()})}isSignaled(){if(this._signaled)return!0;let n=this.gl.getSyncParameter(this.handle,this.gl.SYNC_STATUS);return this._signaled=n===this.gl.SIGNALED,this._signaled}destroy(){this.destroyed||this.gl.deleteSync(this.handle)}}});function SRe(s){switch(s){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function G0t(s){switch(s){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}var j0t=Ve(()=>{});function $0t(s,n){let{sourceX:r=0,sourceY:c=0,sourceAttachment:u=0}=n||{},{target:d=null,sourceWidth:b,sourceHeight:w,sourceDepth:_,sourceFormat:x,sourceType:T}=n||{},{framebuffer:M,deleteFramebuffer:L}=W0t(s),{gl:I,handle:D}=M;b||=M.width,w||=M.height;let F=M.colorAttachments[u]?.texture;if(!F)throw new Error(`Invalid framebuffer attachment ${u}`);_=F?.depth||1,x||=F?.glFormat||6408,T||=F?.glType||5121,d=pnn(d,T,x,b,w,_);let O=Md.getDataType(d);T=T||m0t(O);let z=I.bindFramebuffer(36160,D);return I.readBuffer(36064+u),I.readPixels(r,c,b,w,x,T,d),I.readBuffer(36064),I.bindFramebuffer(36160,z||null),L&&M.destroy(),d}function V0t(s,n){let{target:r,sourceX:c=0,sourceY:u=0,sourceFormat:d=6408,targetByteOffset:b=0}=n||{},{sourceWidth:w,sourceHeight:_,sourceType:x}=n||{},{framebuffer:T,deleteFramebuffer:M}=W0t(s);w=w||T.width,_=_||T.height;let L=T;x=x||5121;let I=r;if(!I){let F=SRe(d),O=G0t(x),z=b+w*_*F*O;I=L.device.createBuffer({byteLength:z})}let D=s.device.createCommandEncoder();return D.copyTextureToBuffer({sourceTexture:s,width:w,height:_,origin:[c,u],destinationBuffer:I,byteOffset:b}),D.destroy(),M&&T.destroy(),I}function W0t(s){return s instanceof n4?{framebuffer:s,deleteFramebuffer:!1}:{framebuffer:dnn(s),deleteFramebuffer:!0}}function dnn(s,n){let{device:r,width:c,height:u,id:d}=s;return r.createFramebuffer({...n,id:`framebuffer-for-${d}`,width:c,height:u,colorAttachments:[s]})}function pnn(s,n,r,c,u,d){if(s)return s;n||=5121;let b=eue(n),w=Md.getTypedArrayConstructor(b),_=SRe(r);return new w(c*u*_)}var H0t=Ve(()=>{Vr();rue();j0t();xRe()});function q0t(s){let n=new Map;for(let r in s){let c=s[r];if(r<"a"){let u=n.get(c);n.set(c,u?`${u}, GL.${r}`:`GL.${r}`)}}return n}var X0t=Ve(()=>{});var MRe={};Oy(MRe,{WebGLDevice:()=>KM});function gnn(s,n,r){switch(r.length){case 1:s.gl.vertexAttrib1fv(n,r);break;case 2:s.gl.vertexAttrib2fv(n,r);break;case 3:s.gl.vertexAttrib3fv(n,r);break;case 4:s.gl.vertexAttrib4fv(n,r);break;default:}}function mnn(s,n,r){s.gl.vertexAttribI4iv(n,r)}function bnn(s,n,r){s.gl.vertexAttribI4uiv(n,r)}function wnn(s,n){if(!s||!n||s.length!==n.length||s.constructor!==n.constructor)return!1;for(let r=0;r{Vr();aRe();W1t();cRe();X1t();n0t();i0t();r0t();s0t();nRe();EB();a0t();Hle();u0t();d0t();tue();$le();M0t();C0t();I0t();O0t();F0t();U0t();z0t();H0t();_B();Qle();SV();X0t();KM=class s extends A3{static getDeviceFromContext(n){return n?n.luma?.device??null:null}type="webgl";handle;features;limits;info;canvasContext;preferredColorFormat="rgba8unorm";preferredDepthFormat="depth24plus";commandEncoder;lost;_resolveContextLost;_isLost=!1;gl;_glKeyByValue=null;_constants;extensions;_polyfilled=!1;spectorJS;get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(n){switch(n){case"unorm8x4-bgra":return!1;default:return!0}}constructor(n){super({...n,id:n.id||o0t("webgl-device")});let r=A3._getCanvasContextProps(n);if(!r)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let c=r.canvas?.gl??null,u=s.getDeviceFromContext(c);if(u)throw new Error(`WebGL context already attached to device ${u.id}`);this.canvasContext=new Vle(this,r),this.lost=new Promise(T=>{this._resolveContextLost=T});let d={...n.webgl};r.alphaMode==="premultiplied"&&(d.premultipliedAlpha=!0),n.powerPreference!==void 0&&(d.powerPreference=n.powerPreference),n.failIfMajorPerformanceCaveat!==void 0&&(d.failIfMajorPerformanceCaveat=n.failIfMajorPerformanceCaveat);let w=this.props._handle||V1t(this.canvasContext.canvas,{onContextLost:T=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."}),onContextRestored:T=>{console.log("WebGL context restored")}},d);if(!w)throw new Error("WebGL context creation failed");if(u=s.getDeviceFromContext(w),u){if(n._reuseDevices)return Qt.log(1,`Not creating a new Device, instead returning a reference to Device ${u.id} already attached to WebGL context`,u)(),this.canvasContext.destroy(),u._reused=!0,u;throw new Error(`WebGL context already attached to device ${u.id}`)}this.handle=w,this.gl=w,this.spectorJS=I1t({...this.props,gl:this.handle});let _=EV(this.handle);_.device=this,_.extensions||(_.extensions={}),this.extensions=_.extensions,this.info=H1t(this.gl,this.extensions),this.limits=new jle(this.gl),this.features=new Gle(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new wv(this.gl,{log:(...T)=>Qt.log(1,...T)()}).trackState(this.gl,{copyState:!1}),(n.debug||n.debugWebGL)&&(this.gl=k1t(this.gl,{debugWebGL:!0,traceWebGL:n.debugWebGL}),Qt.warn("WebGL debug mode activated. Performance reduced.")()),n.debugWebGL&&(Qt.level=Math.max(Qt.level,1)),this.commandEncoder=new PV(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}destroy(){if(!this.props._reuseDevices&&!this._reused){this._isLost=!0,this.commandEncoder?.destroy();let n=EV(this.handle);n.device=null}}get isLost(){return this._isLost||this.gl.isContextLost()}createCanvasContext(n){throw new Error("WebGL only supports a single canvas")}createPresentationContext(n){return new Wle(this,n||{})}createBuffer(n){let r=this._normalizeBufferProps(n);return new _v(this,r)}createTexture(n){return new a2(this,n)}createExternalTexture(n){throw new Error("ExternalTexture is not available on WebGL")}createSampler(n){return new Jle(this,n)}createShader(n){return new Xle(this,n)}createFramebuffer(n){return new s2(this,n)}createVertexArray(n){return new lue(this,n)}createTransformFeedback(n){return new uue(this,n)}createQuerySet(n){return new hue(this,n)}createFence(){return new due(this)}createRenderPipeline(n){return new sue(this,n)}_createSharedRenderPipelineWebGL(n){return new oue(this,n)}createComputePipeline(n){throw new Error("ComputePipeline not supported in WebGL")}createRenderBundleEncoder(n){throw new Error("Render bundles are only supported in WebGPU")}createCommandEncoder(n={}){return new PV(this,n)}submit(n){let r=null;n||({submittedCommandEncoder:r,commandBuffer:n}=this._finalizeDefaultCommandEncoderForSubmit());try{n._executeCommands(),r&&r.resolveTimeProfilingQuerySet().then(()=>{this.commandEncoder._gpuTimeMs=r._gpuTimeMs}).catch(()=>{})}finally{n.destroy()}}writeBufferViaCommandEncoder(n,r,c,u=0){r.write(c,u)}_finalizeDefaultCommandEncoderForSubmit(){let n=this.commandEncoder,r=n.finish();return this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:n.props.id,timeProfilingQuerySet:n.getTimeProfilingQuerySet()}),{submittedCommandEncoder:n,commandBuffer:r}}readPixelsToArrayWebGL(n,r){return $0t(n,r)}readPixelsToBufferWebGL(n,r){return V0t(n,r)}setParametersWebGL(n){bv(this.gl,n)}getParametersWebGL(n){return Ble(this.gl,n)}withParametersWebGL(n,r){return yv(this.gl,n,r)}resetWebGL(){Qt.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),U1t(this.gl)}_getDeviceSpecificTextureFormatCapabilities(n){return Q1t(this.gl,n,this.extensions)}loseDevice(){let n=!1,c=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return c&&(n=!0,c.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),n}pushState(){wv.get(this.gl).push()}popState(){wv.get(this.gl).pop()}getGLKey(n,r){let c=this._getGLKeyByValue().get(Number(n));return c||(r?.emptyIfUnknown?"":String(n))}getGLKeys(n){let r={emptyIfUnknown:!0};return Object.entries(n).reduce((c,[u,d])=>(c[`${u}:${this.getGLKey(u,r)}`]=`${d}:${this.getGLKey(d,r)}`,c),{})}_getGLKeyByValue(){return this._glKeyByValue??=q0t(this.gl),this._glKeyByValue}setConstantAttributeWebGL(n,r){let c=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(c).fill(null);let u=this._constants[n];switch(u&&wnn(u,r)&&Qt.info(1,`setConstantAttributeWebGL(${n}) could have been skipped, value unchanged`)(),this._constants[n]=r,r.constructor){case Float32Array:gnn(this,n,r);break;case Int32Array:mnn(this,n,r);break;case Uint32Array:bnn(this,n,r);break;default:throw new Error("constant")}}getExtension(n){return vv(this.gl,n,this.extensions),this.extensions}_setWebGLDebugMetadata(n,r,c){n.luma=r;let u={props:c.spector,id:c.spector.id};n.__SPECTOR_Metadata=u}}});function vnn(s){return typeof WebGL2RenderingContext<"u"&&s instanceof WebGL2RenderingContext?!0:!!(s&&typeof s.createVertexArray=="function")}function Y0t(s){return{...s,debug:s.debug??A3.defaultProps.debug,debugWebGL:s.debugWebGL??A3.defaultProps.debugWebGL,debugSpectorJS:s.debugSpectorJS??!!Qt.get("debug-spectorjs")}}async function Z0t(s){let n=[];(s.debugWebGL||s.debug)&&n.push(L1t()),s.debugSpectorJS&&n.push(R1t(s));let r=await Promise.allSettled(n);for(let c of r)c.status==="rejected"&&Qt.error(`Failed to initialize debug libraries ${c.reason}`)()}var LV,TRe,kV,K0t=Ve(()=>{Vr();A1t();nRe();LV=1,TRe=class extends u${type="webgl";enforceWebGL2(n){C1t(n)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(n){return typeof WebGL2RenderingContext<"u"&&n instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext&&Qt.warn("WebGL1 is not supported",n)(),!1)}async attach(n,r={}){let{WebGLDevice:c}=await Promise.resolve().then(()=>(pue(),MRe));if(n instanceof c)return n;let u=c.getDeviceFromContext(n);if(u)return u;if(!vnn(n))throw new Error("Invalid WebGL2RenderingContext");r=Y0t(r),await Z0t(r);let d=r.createCanvasContext===!0?{}:r.createCanvasContext;return new c({...r,_handle:n,createCanvasContext:{canvas:n.canvas,autoResize:!1,...d}})}async create(n={}){let{WebGLDevice:r}=await Promise.resolve().then(()=>(pue(),MRe));n=Y0t(n),await Z0t(n);try{let c=new r(n);Qt.groupCollapsed(LV,`WebGLDevice ${c.id} created`)();let u=`${c._reused?"Reusing":"Created"} device with WebGL2 ${c.props.debug?"debug ":""}context: ${c.info.vendor}, ${c.info.renderer} for canvas: ${c.canvasContext.id}`;return Qt.probe(LV,u)(),Qt.table(LV,c.info)(),c}finally{Qt.groupEnd(LV)(),Qt.info(LV,"%cWebGL call tracing: luma.log.set('debug-webgl') ","color: white; background: blue; padding: 2px 6px; border-radius: 3px;")()}}};kV=new TRe});var fue=Ve(()=>{K0t();pue();Hle()});function vue(s){return obt.test(s)}function _ue(s){return abt.test(s)}function cbt(s){let n=obt.exec(s),r=abt.exec(s),c=n?.[1]??r?.[1]??s;try{hl.getVertexFormatInfo(c)}catch{throw new Error(`Unsupported GPUVector format ${s}`)}return c}function O3(s){let n=cbt(s),r=vue(s),c=_ue(s),u=hl.getVertexFormatInfo(n),d=u.type,b=u.normalized,w=Snn(d,b);return{format:s,elementFormat:n,vertexList:r,valueList:c,type:d,signedDataType:Mnn(n,d),primitiveType:w,components:u.components,byteLength:u.byteLength,integer:u.integer,signed:u.signed,normalized:b,...u.webglOnly?{webglOnly:!0}:{}}}function Snn(s,n){if(n)return"f32";switch(s){case"float32":return"f32";case"float16":return"f16";case"uint8":case"uint16":case"uint32":return"u32";case"sint8":case"sint16":case"sint32":return"i32";default:throw new Error(`Unsupported GPUVector component type ${s}`)}}function Mnn(s,n){if(s==="unorm10-10-10-2")return"uint32";switch(n){case"unorm8":return"uint8";case"snorm8":return"sint8";case"unorm16":return"uint16";case"snorm16":return"sint16";default:return n}}var obt,abt,yue=Ve(()=>{Vr();obt=/^vertex-list<([^<>]+)>$/,abt=/^value-list<([^<>]+)>$/});function PRe(s,n){if(!Number.isSafeInteger(s)||s<0)throw new Error(`${n} must be a non-negative safe integer`)}var N3,LRe=Ve(()=>{Vr();N3=class{buffer;format;length;byteOffset;byteStride;constructor(n){let r=hl.getVertexFormatInfo(n.format).byteLength,c=n.byteOffset??0,u=n.byteStride??r;if(PRe(n.length,"GPUDataView length"),PRe(c,"GPUDataView byteOffset"),PRe(u,"GPUDataView byteStride"),un.buffer.byteLength)throw new Error("GPUDataView exceeds its backing buffer byte length");this.buffer=n.buffer,this.format=n.format,this.length=n.length,this.byteOffset=c,this.byteStride=u}get elementByteLength(){return hl.getVertexFormatInfo(this.format).byteLength}get byteLength(){return this.length===0?0:(this.length-1)*this.byteStride+this.elementByteLength}}});function Eue(s){return!!(s&&typeof s=="object"&&s.type==="struct")}function ubt(s,n){let r=Object.entries(s);if(r.length===0)throw new Error("GPUData struct format must declare at least one field");return n==="packed"?Tnn(r):Cnn(r)}function Tnn(s){let n=[],r=0,c=0;for(let[u,d]of s){let b=hl.getVertexFormatInfo(d);if(b.webglOnly)throw new Error(`Packed GPUData struct field "${u}" uses WebGL-only format ${d}`);r=lbt(r,Math.min(4,b.byteLength)),n.push([u,Object.freeze({format:d,byteOffset:r,byteLength:b.byteLength})]),r+=b.byteLength,c+=b.components}return Object.freeze({type:"struct",layout:"packed",fields:Object.freeze(Object.fromEntries(n)),components:c,byteStride:lbt(r,4),rowByteLength:r})}function Cnn(s){let n=Object.fromEntries(s.map(([b,w])=>[b,Ann(w)])),r=o4(n,{layout:"wgsl-storage"}),c=[],u=0,d=0;for(let[b,w]of s){let _=hl.getVertexFormatInfo(w),x=r.fields[b].offset*4;c.push([b,Object.freeze({format:w,byteOffset:x,byteLength:_.byteLength})]),u=Math.max(u,x+_.byteLength),d+=_.components}return Object.freeze({type:"struct",layout:"wgsl-storage",fields:Object.freeze(Object.fromEntries(c)),components:d,byteStride:r.byteLength,rowByteLength:u})}function Ann(s){let n=hl.getVertexFormatInfo(s);switch(n.type){case"float32":return xue("f32",n.components);case"sint32":return xue("i32",n.components);case"uint32":return xue("u32",n.components);default:{let r=Math.ceil(n.byteLength/4);return xue("u32",r)}}}function xue(s,n){return n===1?s:`vec${n}<${s}>`}function lbt(s,n){return Math.ceil(s/n)*n}var fbt=Ve(()=>{Vr()});var kRe,RRe,SB,IRe=Ve(()=>{LRe();fbt();yue();kRe=class{buffer;ownsDataBuffer;constructor(n,r){this.buffer=n,this.ownsDataBuffer=r}get ownsBuffer(){return this.ownsDataBuffer}transferBufferOwnership(n){if(n.buffer!==this.buffer)throw new Error("GPUData ownership can only be transferred to the same buffer");n.ownsDataBuffer=this.ownsDataBuffer,this.ownsDataBuffer=!1}destroy(){this.ownsDataBuffer&&(this.buffer.destroy(),this.ownsDataBuffer=!1)}},RRe=class extends kRe{dataType;format;length;valueLength;stride;byteOffset;byteStride;rowByteLength;readbackMetadata;valueOffsets;nullBitmap;valueByteLength;constructor(n){let{buffer:r,format:c,length:u,valueLength:d,stride:b,byteOffset:w=0,byteStride:_,rowByteLength:x,ownsBuffer:T=!1,readbackMetadata:M,valueOffsets:L,nullBitmap:I,valueByteLength:D,dataType:F}=n;super(r,T);let O;c?typeof c=="string"?O=c:O=ubt(c,n.layout??"wgsl-storage"):O=void 0;let z=Eue(O)?O:void 0,Z=typeof O=="string"?O3(O):void 0;if(this.dataType=F,this.format=O,this.length=u,this.valueLength=d??u,this.stride=b??Z?.components??z?.components??_??x??1,this.byteOffset=w,this.rowByteLength=x??z?.rowByteLength??Z?.byteLength??_??this.stride,this.byteStride=_??z?.byteStride??this.rowByteLength,z){if(this.rowByteLengthc.format!==n))throw new Error("GPUVector data chunks must share the declared format")}var c2,dbt=Ve(()=>{IRe();yue();c2=class{name;dataType;format;length;valueLength;stride;byteOffset;byteStride;rowByteLength;bufferLayout;data=[];device;bufferProps;isAppendable=!1;ownsDataChunks=!0;ownedVectors=[];appendableByteLength=0;constructor(n){switch(n.type){case"buffer":{let{name:r,buffer:c,format:u,length:d,valueLength:b=d,byteOffset:w=0,ownsBuffer:_=!1}=n,{stride:x,byteStride:T,rowByteLength:M}=hbt(n);this.name=r,this.dataType=n.dataType,this.format=u,this.length=d,this.valueLength=b,this.stride=x,this.byteOffset=w,this.byteStride=T,this.rowByteLength=M,this.data.push(new SB({buffer:c,format:u,length:d,valueLength:b,stride:x,byteOffset:w,byteStride:T,rowByteLength:M,ownsBuffer:_,dataType:n.dataType}));return}case"interleaved":{let{name:r,buffer:c,format:u,length:d,valueLength:b=d,byteOffset:w=0,byteStride:_,attributes:x,ownsBuffer:T=!1}=n;this.name=r,this.dataType=n.dataType,this.format=u,this.length=d,this.valueLength=b,this.stride=_,this.byteOffset=w,this.byteStride=_,this.rowByteLength=_,this.bufferLayout={name:r,byteStride:_,attributes:x},this.data.push(new SB({buffer:c,format:u,length:d,valueLength:b,stride:_,byteOffset:w,byteStride:_,rowByteLength:_,ownsBuffer:T,dataType:n.dataType}));return}case"data":{let r=n.format??Pnn(n.data),c=r?O3(r):void 0,{name:u,data:d,stride:b=d[0]?.stride??c?.components??1,valueLength:w=d.reduce((L,I)=>L+I.valueLength,0),byteStride:_=d[0]?.byteStride??c?.byteLength,rowByteLength:x=d[0]?.rowByteLength??c?.byteLength,bufferLayout:T,ownsData:M=!1}=n;if(_===void 0||x===void 0)throw new Error("GPUVector requires format or explicit byte layout metadata");r&&Lnn(d,r),this.name=u,this.dataType=n.dataType,this.format=r,this.length=d.reduce((L,I)=>L+I.length,0),this.valueLength=w,this.stride=b,this.byteOffset=d.length===1?d[0].byteOffset:0,this.byteStride=_,this.rowByteLength=x,this.bufferLayout=T,this.ownsDataChunks=M,this.data.push(...d);return}case"appendable":{let{name:r,device:c,format:u,valueLength:d=0,bufferProps:b}=n,{stride:w,byteStride:_,rowByteLength:x}=hbt(n);this.name=r,this.dataType=n.dataType,this.format=u,this.length=0,this.valueLength=d,this.stride=w,this.byteOffset=0,this.byteStride=_,this.rowByteLength=x,this.device=c,this.bufferProps=b,this.isAppendable=!0;return}}}get ownsBuffer(){return this.ownsDataChunks&&this.data.some(n=>n.ownsBuffer)||this.ownedVectors.some(n=>n.ownsBuffer)}get capacityRows(){return this.isAppendable?this.length:void 0}get appendedByteLength(){return this.appendableByteLength}addData(n){if(this.format&&n.format!==this.format)throw new Error("GPUVector.addData() requires matching formats");if(n.byteStride!==this.byteStride)throw new Error("GPUVector.addData() requires matching byteStride");if(n.rowByteLength!==this.rowByteLength)throw new Error("GPUVector.addData() requires matching rowByteLength");return this.data.push(n),this.length+=n.length,this.valueLength+=n.valueLength,this}appendDataChunk(n,r=this.appendableByteLength+n.buffer.byteLength){if(!this.isAppendable)throw new Error("GPUVector.appendDataChunk() requires appendable vector storage");if(this.format&&n.format!==this.format)throw new Error("GPUVector.appendDataChunk() requires matching formats");if(n.byteStride!==this.byteStride||n.rowByteLength!==this.rowByteLength)throw new Error("GPUVector.appendDataChunk() requires matching byte layout metadata");return this.data.push(n),this.length+=n.length,this.valueLength+=n.valueLength,this.appendableByteLength=r,this}resetLastBatch(){if(!this.isAppendable)throw new Error("GPUVector.resetLastBatch() requires appendable vector storage");for(let n of this.data.splice(0))n.destroy();return this.length=0,this.valueLength=0,this.appendableByteLength=0,this}retainOwnedVectors(n){return this.ownedVectors.push(...n),this}transferBufferOwnership(n){let r=this.data[0],c=n.data[0];if(!r||!c||r.buffer!==c.buffer)throw new Error("GPUVector ownership can only be transferred to the same buffer");r.transferBufferOwnership(c)}destroy(){if(this.ownsDataChunks)for(let n of this.data)n.destroy();for(let n of this.ownedVectors.splice(0))n.destroy()}}});var DRe=Ve(()=>{IRe();LRe();dbt();yue()});var BRe,lg,OV=Ve(()=>{Vr();BRe=class{poolSize=20;bufferPools;constructor(){this.bufferPools=new Map}createOrReuse(n,r){if(r>n.limits.maxBufferSize)throw new Error(`Buffer pool cannot allocate ${r} bytes: device.limits.maxBufferSize is ${n.limits.maxBufferSize}`);let c=this.bufferPools.get(n),u=c?c.findIndex(b=>b.byteLength>=r):-1;if(u<0)return n.createBuffer({usage:cs.VERTEX|cs.STORAGE|cs.COPY_DST|cs.COPY_SRC,byteLength:r});let[d]=c.splice(u,1);return d}recycle(n){let r=n.device;this.bufferPools.has(r)||this.bufferPools.set(r,[]);let c=this.bufferPools.get(r),u=c.findIndex(d=>d.byteLength>n.byteLength);u<0?c.push(n):c.splice(u,0,n),this.purge()}purge(){for(let[n,r]of this.bufferPools){let c=n.isLost?0:this.poolSize;for(;r.length>c;)r.shift().destroy();r.length===0&&this.bufferPools.delete(n)}}},lg=new BRe});function knn(s,n,r,c){let{ValueType:u,size:d,offset:b,stride:w}=s,_=w/u.BYTES_PER_ELEMENT,x=b/u.BYTES_PER_ELEMENT,T=c-r;if(_===d){let L=x+r*_;return n.subarray(L,L+T*d)}let M=new u(T*d);for(let L=0;L0)throw new Error(`GPUDataEvaluator requires exactly one GPUData chunk for "${s.name}"`);return n}function Dnn(s){let n=[];return gbt(s,n,{byteOffset:0}),n}function gbt(s,n,r){let c=s.source;if(c&&!(c instanceof fc)&&c.name==="interleave"){for(let u of Object.values(c.inputs))u instanceof fc&&gbt(u,n,r);return}n.push({attribute:s.id??s.toString(),format:mbt(s.type,s.size,s.normalized),byteOffset:r.byteOffset}),r.byteOffset+=s.ValueType.BYTES_PER_ELEMENT*s.size}function mbt(s,n,r=!1){if(n<1||n>4)throw new Error(`Cannot synthesize a GPUVector vertex format with ${n} components`);let c=s;if(r)switch(s){case"uint8":c="unorm8";break;case"sint8":c="snorm8";break;case"uint16":c="unorm16";break;case"sint16":c="snorm16";break;case"float32":c="float32";break;default:throw new Error(`Unsupported normalized vertex format for ${s}`)}return(c==="uint8"||c==="sint8"||c==="uint16"||c==="sint16"||c==="unorm8"||c==="snorm8"||c==="unorm16"||c==="snorm16")&&n===3?`${c}x3-webgl`:`${c}${n===1?"":`x${n}`}`}function Bnn(s,n,r=!1){return n>=1&&n<=4?mbt(s,n,r):void 0}var fc,F3=Ve(()=>{Vr();Ql();DRe();OV();fc=class s{static get bufferPoolSize(){return lg.poolSize}static set bufferPoolSize(n){if(!Number.isSafeInteger(n)||n<0)throw new Error("GPUDataEvaluator.bufferPoolSize must be a non-negative safe integer");lg.poolSize=n,lg.purge()}type;size;get offset(){return this._offset}get stride(){return this._stride}normalized;isConstant;length;get byteLength(){return this._byteLength}ValueType;source=null;format;_id;_destroyed=!1;_value;_offset;_stride;_byteLength;_gpuVector;_bufferOwnership="owned";_targetBuffer;static fromArray(n,{type:r,size:c=1,offset:u=0,stride:d=0,normalized:b=!1}){let w=r,_;if(Array.isArray(n)){w=w||"float32";let T=KL(w);_=new T(n)}else n instanceof Float64Array?(w="uint32",c*=2,u*=2,d*=2,_=new Uint32Array(n.buffer,n.byteOffset,n.byteLength/4)):(w=w||yce(n),_=n);let x=`<${w} * ${c}>`;return new s({id:x,type:w,size:c,offset:u,stride:d,normalized:b,value:_})}static fromConstant(n,r="float32"){let c=KL(r),u;return Array.isArray(n)?u=`[${n.join(",")}]`:(u=String(n),n=[n]),new s({id:u,isConstant:!0,type:r,size:n.length,value:new c(n)})}static fromGPUData(n,r={}){Rnn(n);let c=new N3({buffer:n.buffer,format:n.format,length:n.length,byteOffset:n.byteOffset,byteStride:n.byteStride});return new s({...pbt(c),id:r.id,gpuData:n})}static fromGPUDataView(n,r={}){return new s({...pbt(n),id:r.id,buffer:n.buffer})}constructor(n){let{id:r,value:c,buffer:u,gpuData:d,format:b,source:w=null,isConstant:_=!1}=n;if(!w&&!c&&!u&&!d)throw new Error("GPUDataEvaluator must have a value source");let{type:x,size:T,offset:M,stride:L,normalized:I,length:D}=n;if(w instanceof s?(x=x??w.type,T=T??w.size,M=M??w.offset,L=L??w.stride,I=I??w.normalized,D=D??w.length):(T=T??1,M=M??0,I=I??!1,D=_?1:D),!x)throw new Error("GPUDataEvaluator: type not defined");if(this._id=r,this.type=x,this.size=T,this.ValueType=KL(this.type),this._offset=M,this._stride=L||this.ValueType.BYTES_PER_ELEMENT*T,this.normalized=I,this.source=w,this.format=b,D===void 0)if(_)D=1;else{if(!c)throw new Error("GPUDataEvaluator: length not defined");D=Math.ceil(c.byteLength/this.stride)}this.isConstant=_,this.length=D;let F=this.ValueType.BYTES_PER_ELEMENT*this.size;this._byteLength=D===0?0:(D-1)*this.stride+F,this._value=c,this._bufferOwnership=w instanceof s||u||d?"borrowed":"owned",d?this._gpuVector=new c2({type:"data",name:this._id??"data",format:d.format,data:[d],stride:d.stride,byteStride:d.byteStride,rowByteLength:d.rowByteLength}):u&&(this._gpuVector=this.createGPUVectorView({buffer:u,name:this._id,format:this.format}))}get value(){return this._value||(this.source instanceof s?this.source.value:void 0)}get evaluated(){return!!this._gpuVector}get id(){return this._id}get gpuVector(){if(!this._gpuVector)throw new Error(`${this} not evaluated`);return this._gpuVector}get buffer(){return Sue(this.gpuVector)}setTargetBuffer({buffer:n,byteOffset:r=0,byteStride:c=this.stride}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)throw new Error(`GPUDataEvaluator ${this} already evaluated`);if(!this.source||this.source instanceof s)throw new Error("GPUDataEvaluator target buffers require a deferred operation source");this._targetBuffer={buffer:n,byteOffset:r,byteStride:c}}async evaluate(n,r={}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let c;if(this.source instanceof s){let u=await this.source.evaluate(n);return this._gpuVector=this.createGPUVectorView({...r,buffer:Sue(u)}),this._gpuVector}if(c=this._getEvaluationBuffer(n),this._value)c.write(this._value);else{let u=await this.source.execute(n,c);if(!u.success)throw u.error||new Error(`${this.source} evaluation failed`);u.value&&(this._value=u.value)}return this._gpuVector=this.createGPUVectorView({...r,buffer:c}),this._gpuVector}evaluateSync(n,r={}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let c;if(this.source instanceof s){let u=this.source.evaluateSync(n);return this._gpuVector=this.createGPUVectorView({...r,buffer:Sue(u)}),this._gpuVector}if(c=this._getEvaluationBuffer(n),this._value)c.write(this._value);else{let u=this.source.executeSync(n,c);if(!u.success)throw u.error||new Error(`${this.source} evaluation failed`);u.value&&(this._value=u.value)}return this._gpuVector=this.createGPUVectorView({...r,buffer:c}),this._gpuVector}createGPUVectorView(n){let r=n.name??this._id??"vector",c=n.format??this.format??Bnn(this.type,this.size,this.normalized);if(n.interleaved){let u=typeof n.interleaved=="object"&&n.interleaved.attributes?n.interleaved.attributes:Dnn(this);return new c2({type:"interleaved",name:r,buffer:n.buffer,format:n.format??this.format,length:this.length,byteOffset:this.offset,byteStride:this.stride,attributes:u,ownsBuffer:!1})}return new c2({type:"buffer",name:r,buffer:n.buffer,format:c,length:this.length,stride:this.size,byteOffset:this.offset,byteStride:this.stride,rowByteLength:this.ValueType.BYTES_PER_ELEMENT*this.size,ownsBuffer:!1})}_getEvaluationBuffer(n){let r=this._targetBuffer;if(!r)return lg.createOrReuse(n,this.byteLength);if(r.buffer.device!==n)throw new Error("GPUDataEvaluator target buffer belongs to a different device");let c=this.ValueType.BYTES_PER_ELEMENT*this.size,u=this.length===0?0:(this.length-1)*r.byteStride+c;if(r.byteOffset+u>r.buffer.byteLength)throw new Error("GPUDataEvaluator target buffer is too small for the output layout");return this._offset=r.byteOffset,this._stride=r.byteStride,this._byteLength=u,this._bufferOwnership="borrowed",this._targetBuffer=void 0,r.buffer}async readValue(n=0,r){let{ValueType:c}=this,{size:u,offset:d,stride:b,length:w}=this,_=c.BYTES_PER_ELEMENT*u;if(r=r??w,n=Math.max(0,Math.min(w,n)),r=Math.max(n,Math.min(w,r)),this._value)return knn(this,this._value,n,r);let x=r-n;if(x===0)return new c(0);let T=d+n*b,M=b===_?x*_:(x-1)*b+_,L=await this.buffer.readAsync(T,M),I=new c(L.buffer,L.byteOffset,L.byteLength/c.BYTES_PER_ELEMENT);if(b===_)return I;let D=new Uint8Array(_*x);for(let F=0;F{MB={add:{arity:2,symbol:"arithmetic_add"},subtract:{arity:2,symbol:"arithmetic_subtract"},multiply:{arity:2,symbol:"arithmetic_multiply"},divide:{arity:2,symbol:"arithmetic_divide"},pow:{arity:2,symbol:"pow"},sqrt:{arity:1,symbol:"sqrt"},abs:{arity:1,symbol:"abs"},sin:{arity:1,symbol:"sin"},cos:{arity:1,symbol:"cos"},tan:{arity:1,symbol:"arithmetic_tan"},exp:{arity:1,symbol:"exp"},log:{arity:1,symbol:"log"}}});function kbt(s,{operations:n,inputs:r}){switch(s.kind){case"input":if(!(s.name in r))throw new Error(`Unknown expression input '${s.name}'`);return;case"literal":if(Array.isArray(s.value)){for(let c of s.value)if(!Number.isFinite(c))throw new Error(`Expression literal array must contain only finite values, got ${c}`)}else if(!Number.isFinite(s.value))throw new Error(`Expression literal must be finite, got ${s.value}`);return;case"call":{let c=n[s.op];if(!c)throw new Error(`Unknown expression op '${s.op}'`);if(s.args.length!==c.arity)throw new Error(`Expression op '${s.op}' expects ${c.arity} args, got ${s.args.length}`);for(let u of s.args)kbt(u,{operations:n,inputs:r});return}default:{let c=s;throw new Error(`Unsupported expression node ${c.kind}`)}}}function Cue(s,n){return kbt(s,n),Rbt(s,n)}function Rbt(s,n){switch(s.kind){case"input":{let r=n.inputs[s.name];return n.laneIndexRbt(u,n));return n.formatCall(r.symbol,c)}default:{let r=s;throw new Error(`Unsupported expression node ${r.kind}`)}}}var URe=Ve(()=>{});function hp(s,n,r=!1){if(r)return n===1?"float":`vec${n}`;switch(s){case"uint8":case"uint16":case"uint32":return n===1?"uint":`uvec${n}`;case"sint8":case"sint16":case"sint32":return n===1?"int":`ivec${n}`;default:return n===1?"float":`vec${n}`}}function Aue(s,n,r=!1){let c;if(r)switch(s){case"uint8":c="unorm8";break;case"sint8":c="snorm8";break;case"uint16":c="unorm16";break;case"sint16":c="snorm16";break;case"float32":c="float32";break;default:throw new Error(`Unsupported normalized vertex format for ${s}`)}else c=s;return n===1?c:n===3&&!c.startsWith("float32")&&!c.endsWith("32")?`${c}x3-webgl`:`${c}x${n}`}function JM(s){switch(s[0]){case"u":return"0u";case"s":return"0";default:return"0."}}function Ibt(s,n){switch(s){case"uint8":case"uint16":case"uint32":return`${Math.trunc(n)}u`;case"sint8":case"sint16":case"sint32":return`${Math.trunc(n)}`;default:return Number.isInteger(n)?`${n}.0`:`${n}`}}function Dbt(s){switch(s){case"uint8":return"r8uint";case"sint8":return"r8sint";case"uint16":return"r16uint";case"sint16":return"r16sint";case"uint32":return"r32uint";case"sint32":return"r32sint";case"float32":return"r32float";default:throw new Error(`Unsupported WebGL gather texture format for ${s}`)}}function Bbt(s){switch(s){case"uint32":return"usampler2D";case"sint32":return"isampler2D";case"float32":return"sampler2D";default:throw new Error(`Unsupported WebGL gather sampler type for ${s}`)}}var CB=Ve(()=>{});function dp({module:s,elementWise:n=!1,expression:r,inputs:c,output:u,operationType:d=u.type,outputBuffer:b}){let w=b.device,_=R4("result",u.type,u.size,u.normalized),x=[s,_],T=[],M={},L=hp(u.type,1,u.normalized),I=hp(d,1,u.normalized),D="",F=null,O={TYPE:I,RESULT_LEN:u.size.toString()},z=Vnn(c);for(let[oe,ne]of z)x.push(zRe(oe,ne.type,ne.size,ne.normalized,d)),T.push(GRe(oe,ne)),ne instanceof fc?M[oe]=ne.buffer:(F=F||lg.createOrReuse(w,b.byteLength),M[oe]=F),D+=`TYPE ${oe}[${ne.size}]; get_${oe}(${oe}); `,O[`${oe.toUpperCase()}_LEN`]=ne.size.toString();let Z="";if(r)for(let oe=0;oeMath.max(e,Math.min(t,i)))}function fn(n,e,t){return vi(n)?n.map((i,r)=>fn(i,e[r],t)):t*e+(1-t)*n}function $n(n,e,t){let i=Ye.EPSILON;t&&(Ye.EPSILON=t);try{if(n===e)return!0;if(vi(n)&&vi(e)){if(n.length!==e.length)return!1;for(let r=0;r{tK=1/Math.PI*180,nK=1/180*Math.PI,UB={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...UB}};Ye=globalThis.mathgl.config});var Qs,mg=C(()=>{Ks();Qs=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,t=0){for(let i=0;i0?", ":"")+pg(this[i],e);return`${e.printTypes?this.constructor.name:""}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t{Ks()});function gg(n,e){if(!n)throw new Error(`math.gl assertion ${e}`)}var Zw=C(()=>{});var Qu,Xw=C(()=>{mg();Ya();Zw();Qu=class extends Qs{get x(){return this[0]}set x(e){this[0]=Je(e)}get y(){return this[1]}set y(e){this[1]=Je(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let t=0;t=0&&e=0&&e=0?Math.round(n):n%.5===0?Math.floor(n):Math.round(n)}var we,Gn,hK,$r=C(()=>{we=typeof Float32Array<"u"?Float32Array:Array,Gn=Math.random;hK=Math.PI/180});var dt={};mi(dt,{add:()=>ZB,angle:()=>pO,ceil:()=>XB,clone:()=>jB,copy:()=>YB,create:()=>Kw,cross:()=>aO,dist:()=>EO,distance:()=>tE,div:()=>wO,divide:()=>eE,dot:()=>oO,equals:()=>yO,exactEquals:()=>_O,floor:()=>KB,forEach:()=>CO,fromValues:()=>HB,inverse:()=>rO,len:()=>bO,length:()=>iE,lerp:()=>cO,max:()=>JB,min:()=>QB,mul:()=>xO,multiply:()=>Jw,negate:()=>iO,normalize:()=>sO,random:()=>lO,rotate:()=>hO,round:()=>eO,scale:()=>tO,scaleAndAdd:()=>nO,set:()=>qB,sqrDist:()=>SO,sqrLen:()=>PO,squaredDistance:()=>nE,squaredLength:()=>rE,str:()=>gO,sub:()=>vO,subtract:()=>Qw,transformMat2:()=>uO,transformMat2d:()=>fO,transformMat3:()=>dO,transformMat4:()=>_g,zero:()=>mO});function Kw(){let n=new we(2);return we!=Float32Array&&(n[0]=0,n[1]=0),n}function jB(n){let e=new we(2);return e[0]=n[0],e[1]=n[1],e}function HB(n,e){let t=new we(2);return t[0]=n,t[1]=e,t}function YB(n,e){return n[0]=e[0],n[1]=e[1],n}function qB(n,e,t){return n[0]=e,n[1]=t,n}function ZB(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n}function Qw(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n}function Jw(n,e,t){return n[0]=e[0]*t[0],n[1]=e[1]*t[1],n}function eE(n,e,t){return n[0]=e[0]/t[0],n[1]=e[1]/t[1],n}function XB(n,e){return n[0]=Math.ceil(e[0]),n[1]=Math.ceil(e[1]),n}function KB(n,e){return n[0]=Math.floor(e[0]),n[1]=Math.floor(e[1]),n}function QB(n,e,t){return n[0]=Math.min(e[0],t[0]),n[1]=Math.min(e[1],t[1]),n}function JB(n,e,t){return n[0]=Math.max(e[0],t[0]),n[1]=Math.max(e[1],t[1]),n}function eO(n,e){return n[0]=Kt(e[0]),n[1]=Kt(e[1]),n}function tO(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n}function nO(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n}function tE(n,e){let t=e[0]-n[0],i=e[1]-n[1];return Math.sqrt(t*t+i*i)}function nE(n,e){let t=e[0]-n[0],i=e[1]-n[1];return t*t+i*i}function iE(n){let e=n[0],t=n[1];return Math.sqrt(e*e+t*t)}function rE(n){let e=n[0],t=n[1];return e*e+t*t}function iO(n,e){return n[0]=-e[0],n[1]=-e[1],n}function rO(n,e){return n[0]=1/e[0],n[1]=1/e[1],n}function sO(n,e){let t=e[0],i=e[1],r=t*t+i*i;return r>0&&(r=1/Math.sqrt(r)),n[0]=e[0]*r,n[1]=e[1]*r,n}function oO(n,e){return n[0]*e[0]+n[1]*e[1]}function aO(n,e,t){let i=e[0]*t[1]-e[1]*t[0];return n[0]=n[1]=0,n[2]=i,n}function cO(n,e,t,i){let r=e[0],s=e[1];return n[0]=r+i*(t[0]-r),n[1]=s+i*(t[1]-s),n}function lO(n,e){e=e===void 0?1:e;let t=Gn()*2*Math.PI;return n[0]=Math.cos(t)*e,n[1]=Math.sin(t)*e,n}function uO(n,e,t){let i=e[0],r=e[1];return n[0]=t[0]*i+t[2]*r,n[1]=t[1]*i+t[3]*r,n}function fO(n,e,t){let i=e[0],r=e[1];return n[0]=t[0]*i+t[2]*r+t[4],n[1]=t[1]*i+t[3]*r+t[5],n}function dO(n,e,t){let i=e[0],r=e[1];return n[0]=t[0]*i+t[3]*r+t[6],n[1]=t[1]*i+t[4]*r+t[7],n}function _g(n,e,t){let i=e[0],r=e[1];return n[0]=t[0]*i+t[4]*r+t[12],n[1]=t[1]*i+t[5]*r+t[13],n}function hO(n,e,t,i){let r=e[0]-t[0],s=e[1]-t[1],o=Math.sin(i),a=Math.cos(i);return n[0]=r*a-s*o+t[0],n[1]=r*o+s*a+t[1],n}function pO(n,e){let t=n[0],i=n[1],r=e[0],s=e[1],o=Math.sqrt((t*t+i*i)*(r*r+s*s)),a=o&&(t*r+i*s)/o;return Math.acos(Math.min(Math.max(a,-1),1))}function mO(n){return n[0]=0,n[1]=0,n}function gO(n){return`vec2(${n[0]}, ${n[1]})`}function _O(n,e){return n[0]===e[0]&&n[1]===e[1]}function yO(n,e){let t=n[0],i=n[1],r=e[0],s=e[1];return Math.abs(t-r)<=1e-6*Math.max(1,Math.abs(t),Math.abs(r))&&Math.abs(i-s)<=1e-6*Math.max(1,Math.abs(i),Math.abs(s))}var bO,vO,xO,wO,EO,SO,PO,CO,yg=C(()=>{$r();bO=iE,vO=Qw,xO=Jw,wO=eE,EO=tE,SO=nE,PO=rE,CO=function(){let n=Kw();return function(e,t,i,r,s,o){let a,c;for(t||(t=2),i||(i=0),r?c=Math.min(r*t+i,e.length):c=e.length,a=i;a{});var bt={};mi(bt,{add:()=>AO,angle:()=>Cg,bezier:()=>VO,ceil:()=>kO,clone:()=>TO,copy:()=>LO,create:()=>ef,cross:()=>Gr,dist:()=>QO,distance:()=>fE,div:()=>KO,divide:()=>uE,dot:()=>qa,equals:()=>qO,exactEquals:()=>YO,floor:()=>RO,forEach:()=>tD,fromValues:()=>tf,hermite:()=>GO,inverse:()=>zO,len:()=>Tg,length:()=>aE,lerp:()=>UO,max:()=>BO,min:()=>IO,mul:()=>XO,multiply:()=>lE,negate:()=>FO,normalize:()=>vg,random:()=>WO,rotateX:()=>Eg,rotateY:()=>Sg,rotateZ:()=>Pg,round:()=>OO,scale:()=>DO,scaleAndAdd:()=>NO,set:()=>MO,slerp:()=>$O,sqrDist:()=>JO,sqrLen:()=>eD,squaredDistance:()=>dE,squaredLength:()=>hE,str:()=>HO,sub:()=>ZO,subtract:()=>cE,transformMat3:()=>xg,transformMat4:()=>Za,transformQuat:()=>wg,zero:()=>jO});function ef(){let n=new we(3);return we!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n}function TO(n){let e=new we(3);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e}function aE(n){let e=n[0],t=n[1],i=n[2];return Math.sqrt(e*e+t*t+i*i)}function tf(n,e,t){let i=new we(3);return i[0]=n,i[1]=e,i[2]=t,i}function LO(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n}function MO(n,e,t,i){return n[0]=e,n[1]=t,n[2]=i,n}function AO(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n}function cE(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n}function lE(n,e,t){return n[0]=e[0]*t[0],n[1]=e[1]*t[1],n[2]=e[2]*t[2],n}function uE(n,e,t){return n[0]=e[0]/t[0],n[1]=e[1]/t[1],n[2]=e[2]/t[2],n}function kO(n,e){return n[0]=Math.ceil(e[0]),n[1]=Math.ceil(e[1]),n[2]=Math.ceil(e[2]),n}function RO(n,e){return n[0]=Math.floor(e[0]),n[1]=Math.floor(e[1]),n[2]=Math.floor(e[2]),n}function IO(n,e,t){return n[0]=Math.min(e[0],t[0]),n[1]=Math.min(e[1],t[1]),n[2]=Math.min(e[2],t[2]),n}function BO(n,e,t){return n[0]=Math.max(e[0],t[0]),n[1]=Math.max(e[1],t[1]),n[2]=Math.max(e[2],t[2]),n}function OO(n,e){return n[0]=Kt(e[0]),n[1]=Kt(e[1]),n[2]=Kt(e[2]),n}function DO(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n}function NO(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n[2]=e[2]+t[2]*i,n}function fE(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2];return Math.sqrt(t*t+i*i+r*r)}function dE(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2];return t*t+i*i+r*r}function hE(n){let e=n[0],t=n[1],i=n[2];return e*e+t*t+i*i}function FO(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n}function zO(n,e){return n[0]=1/e[0],n[1]=1/e[1],n[2]=1/e[2],n}function vg(n,e){let t=e[0],i=e[1],r=e[2],s=t*t+i*i+r*r;return s>0&&(s=1/Math.sqrt(s)),n[0]=e[0]*s,n[1]=e[1]*s,n[2]=e[2]*s,n}function qa(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]}function Gr(n,e,t){let i=e[0],r=e[1],s=e[2],o=t[0],a=t[1],c=t[2];return n[0]=r*c-s*a,n[1]=s*o-i*c,n[2]=i*a-r*o,n}function UO(n,e,t,i){let r=e[0],s=e[1],o=e[2];return n[0]=r+i*(t[0]-r),n[1]=s+i*(t[1]-s),n[2]=o+i*(t[2]-o),n}function $O(n,e,t,i){let r=Math.acos(Math.min(Math.max(qa(e,t),-1),1)),s=Math.sin(r),o=Math.sin((1-i)*r)/s,a=Math.sin(i*r)/s;return n[0]=o*e[0]+a*t[0],n[1]=o*e[1]+a*t[1],n[2]=o*e[2]+a*t[2],n}function GO(n,e,t,i,r,s){let o=s*s,a=o*(2*s-3)+1,c=o*(s-2)+s,l=o*(s-1),u=o*(3-2*s);return n[0]=e[0]*a+t[0]*c+i[0]*l+r[0]*u,n[1]=e[1]*a+t[1]*c+i[1]*l+r[1]*u,n[2]=e[2]*a+t[2]*c+i[2]*l+r[2]*u,n}function VO(n,e,t,i,r,s){let o=1-s,a=o*o,c=s*s,l=a*o,u=3*s*a,f=3*c*o,d=c*s;return n[0]=e[0]*l+t[0]*u+i[0]*f+r[0]*d,n[1]=e[1]*l+t[1]*u+i[1]*f+r[1]*d,n[2]=e[2]*l+t[2]*u+i[2]*f+r[2]*d,n}function WO(n,e){e=e===void 0?1:e;let t=Gn()*2*Math.PI,i=Gn()*2-1,r=Math.sqrt(1-i*i)*e;return n[0]=Math.cos(t)*r,n[1]=Math.sin(t)*r,n[2]=i*e,n}function Za(n,e,t){let i=e[0],r=e[1],s=e[2],o=t[3]*i+t[7]*r+t[11]*s+t[15];return o=o||1,n[0]=(t[0]*i+t[4]*r+t[8]*s+t[12])/o,n[1]=(t[1]*i+t[5]*r+t[9]*s+t[13])/o,n[2]=(t[2]*i+t[6]*r+t[10]*s+t[14])/o,n}function xg(n,e,t){let i=e[0],r=e[1],s=e[2];return n[0]=i*t[0]+r*t[3]+s*t[6],n[1]=i*t[1]+r*t[4]+s*t[7],n[2]=i*t[2]+r*t[5]+s*t[8],n}function wg(n,e,t){let i=t[0],r=t[1],s=t[2],o=t[3],a=e[0],c=e[1],l=e[2],u=r*l-s*c,f=s*a-i*l,d=i*c-r*a,h=r*d-s*f,p=s*u-i*d,m=i*f-r*u,g=o*2;return u*=g,f*=g,d*=g,h*=2,p*=2,m*=2,n[0]=a+u+h,n[1]=c+f+p,n[2]=l+d+m,n}function Eg(n,e,t,i){let r=[],s=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],s[0]=r[0],s[1]=r[1]*Math.cos(i)-r[2]*Math.sin(i),s[2]=r[1]*Math.sin(i)+r[2]*Math.cos(i),n[0]=s[0]+t[0],n[1]=s[1]+t[1],n[2]=s[2]+t[2],n}function Sg(n,e,t,i){let r=[],s=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],s[0]=r[2]*Math.sin(i)+r[0]*Math.cos(i),s[1]=r[1],s[2]=r[2]*Math.cos(i)-r[0]*Math.sin(i),n[0]=s[0]+t[0],n[1]=s[1]+t[1],n[2]=s[2]+t[2],n}function Pg(n,e,t,i){let r=[],s=[];return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],s[0]=r[0]*Math.cos(i)-r[1]*Math.sin(i),s[1]=r[0]*Math.sin(i)+r[1]*Math.cos(i),s[2]=r[2],n[0]=s[0]+t[0],n[1]=s[1]+t[1],n[2]=s[2]+t[2],n}function Cg(n,e){let t=n[0],i=n[1],r=n[2],s=e[0],o=e[1],a=e[2],c=Math.sqrt((t*t+i*i+r*r)*(s*s+o*o+a*a)),l=c&&qa(n,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function jO(n){return n[0]=0,n[1]=0,n[2]=0,n}function HO(n){return`vec3(${n[0]}, ${n[1]}, ${n[2]})`}function YO(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]}function qO(n,e){let t=n[0],i=n[1],r=n[2],s=e[0],o=e[1],a=e[2];return Math.abs(t-s)<=1e-6*Math.max(1,Math.abs(t),Math.abs(s))&&Math.abs(i-o)<=1e-6*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(r-a)<=1e-6*Math.max(1,Math.abs(r),Math.abs(a))}var ZO,XO,KO,QO,JO,Tg,eD,tD,Xa=C(()=>{$r();ZO=cE,XO=lE,KO=uE,QO=fE,JO=dE,Tg=aE,eD=hE,tD=function(){let n=ef();return function(e,t,i,r,s,o){let a,c;for(t||(t=3),i||(i=0),r?c=Math.min(r*t+i,e.length):c=e.length,a=i;a{Xw();Ks();Ya();Xa();bg();Lg=[0,0,0],et=class n extends Qu{static get ZERO(){return nf||(nf=new n(0,0,0),Object.freeze(nf)),nf}constructor(e=0,t=0,i=0){super(-0,-0,-0),arguments.length===1&&vi(e)?this.copy(e):(Ye.debug&&(Je(e),Je(t),Je(i)),this[0]=e,this[1]=t,this[2]=i)}set(e,t,i){return this[0]=e,this[1]=t,this[2]=i,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return Ye.debug&&(Je(e.x),Je(e.y),Je(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=Je(e)}angle(e){return Cg(this,e)}cross(e){return Gr(this,this,e),this.check()}rotateX({radians:e,origin:t=Lg}){return Eg(this,this,t,e),this.check()}rotateY({radians:e,origin:t=Lg}){return Sg(this,this,t,e),this.check()}rotateZ({radians:e,origin:t=Lg}){return Pg(this,this,t,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return Za(this,this,e),this.check()}transformAsVector(e){return Ju(this,this,e),this.check()}transformByMatrix3(e){return xg(this,this,e),this.check()}transformByMatrix2(e){return oE(this,this,e),this.check()}transformByQuaternion(e){return wg(this,this,e),this.check()}}});var rf,mE=C(()=>{mg();Ya();Ks();rf=class extends Qs{toString(){let e="[";if(Ye.printRowMajor){e+="row-major:";for(let t=0;t{$r()});var We={};mi(We,{add:()=>CD,adjoint:()=>aD,clone:()=>iD,copy:()=>rD,create:()=>nD,decompose:()=>_D,determinant:()=>Rg,equals:()=>AD,exactEquals:()=>MD,frob:()=>PD,fromQuat:()=>zg,fromQuat2:()=>pD,fromRotation:()=>uD,fromRotationTranslation:()=>bE,fromRotationTranslationScale:()=>yD,fromRotationTranslationScaleOrigin:()=>bD,fromScaling:()=>lD,fromTranslation:()=>cD,fromValues:()=>sD,fromXRotation:()=>fD,fromYRotation:()=>dD,fromZRotation:()=>hD,frustum:()=>Ug,getRotation:()=>gD,getScaling:()=>vE,getTranslation:()=>mD,identity:()=>yE,invert:()=>kg,lookAt:()=>Vg,mul:()=>kD,multiply:()=>Ka,multiplyScalar:()=>TD,multiplyScalarAndAdd:()=>LD,ortho:()=>Gg,orthoNO:()=>wE,orthoZO:()=>wD,perspective:()=>$g,perspectiveFromFieldOfView:()=>xD,perspectiveNO:()=>xE,perspectiveZO:()=>vD,rotate:()=>Og,rotateX:()=>Dg,rotateY:()=>Ng,rotateZ:()=>Fg,scale:()=>Bg,set:()=>oD,str:()=>SD,sub:()=>RD,subtract:()=>EE,targetTo:()=>ED,translate:()=>Ig,transpose:()=>Ag});function nD(){let n=new we(16);return we!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0),n[0]=1,n[5]=1,n[10]=1,n[15]=1,n}function iD(n){let e=new we(16);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],e}function rD(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function sD(n,e,t,i,r,s,o,a,c,l,u,f,d,h,p,m){let g=new we(16);return g[0]=n,g[1]=e,g[2]=t,g[3]=i,g[4]=r,g[5]=s,g[6]=o,g[7]=a,g[8]=c,g[9]=l,g[10]=u,g[11]=f,g[12]=d,g[13]=h,g[14]=p,g[15]=m,g}function oD(n,e,t,i,r,s,o,a,c,l,u,f,d,h,p,m,g){return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n[4]=s,n[5]=o,n[6]=a,n[7]=c,n[8]=l,n[9]=u,n[10]=f,n[11]=d,n[12]=h,n[13]=p,n[14]=m,n[15]=g,n}function yE(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Ag(n,e){if(n===e){let t=e[1],i=e[2],r=e[3],s=e[6],o=e[7],a=e[11];n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=t,n[6]=e[9],n[7]=e[13],n[8]=i,n[9]=s,n[11]=e[14],n[12]=r,n[13]=o,n[14]=a}else n[0]=e[0],n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=e[1],n[5]=e[5],n[6]=e[9],n[7]=e[13],n[8]=e[2],n[9]=e[6],n[10]=e[10],n[11]=e[14],n[12]=e[3],n[13]=e[7],n[14]=e[11],n[15]=e[15];return n}function kg(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],d=e[10],h=e[11],p=e[12],m=e[13],g=e[14],v=e[15],y=t*a-i*o,b=t*c-r*o,x=t*l-s*o,E=i*c-r*a,w=i*l-s*a,T=r*l-s*c,R=u*m-f*p,F=u*g-d*p,O=u*v-h*p,j=f*g-d*m,V=f*v-h*m,G=d*v-h*g,q=y*G-b*V+x*j+E*O-w*F+T*R;return q?(q=1/q,n[0]=(a*G-c*V+l*j)*q,n[1]=(r*V-i*G-s*j)*q,n[2]=(m*T-g*w+v*E)*q,n[3]=(d*w-f*T-h*E)*q,n[4]=(c*O-o*G-l*F)*q,n[5]=(t*G-r*O+s*F)*q,n[6]=(g*x-p*T-v*b)*q,n[7]=(u*T-d*x+h*b)*q,n[8]=(o*V-a*O+l*R)*q,n[9]=(i*O-t*V-s*R)*q,n[10]=(p*w-m*x+v*y)*q,n[11]=(f*x-u*w-h*y)*q,n[12]=(a*F-o*j-c*R)*q,n[13]=(t*j-i*F+r*R)*q,n[14]=(m*b-p*E-g*y)*q,n[15]=(u*E-f*b+d*y)*q,n):null}function aD(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],d=e[10],h=e[11],p=e[12],m=e[13],g=e[14],v=e[15],y=t*a-i*o,b=t*c-r*o,x=t*l-s*o,E=i*c-r*a,w=i*l-s*a,T=r*l-s*c,R=u*m-f*p,F=u*g-d*p,O=u*v-h*p,j=f*g-d*m,V=f*v-h*m,G=d*v-h*g;return n[0]=a*G-c*V+l*j,n[1]=r*V-i*G-s*j,n[2]=m*T-g*w+v*E,n[3]=d*w-f*T-h*E,n[4]=c*O-o*G-l*F,n[5]=t*G-r*O+s*F,n[6]=g*x-p*T-v*b,n[7]=u*T-d*x+h*b,n[8]=o*V-a*O+l*R,n[9]=i*O-t*V-s*R,n[10]=p*w-m*x+v*y,n[11]=f*x-u*w-h*y,n[12]=a*F-o*j-c*R,n[13]=t*j-i*F+r*R,n[14]=m*b-p*E-g*y,n[15]=u*E-f*b+d*y,n}function Rg(n){let e=n[0],t=n[1],i=n[2],r=n[3],s=n[4],o=n[5],a=n[6],c=n[7],l=n[8],u=n[9],f=n[10],d=n[11],h=n[12],p=n[13],m=n[14],g=n[15],v=e*o-t*s,y=e*a-i*s,b=t*a-i*o,x=l*p-u*h,E=l*m-f*h,w=u*m-f*p,T=e*w-t*E+i*x,R=s*w-o*E+a*x,F=l*b-u*y+f*v,O=h*b-p*y+m*v;return c*T-r*R+g*F-d*O}function Ka(n,e,t){let i=e[0],r=e[1],s=e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=e[8],d=e[9],h=e[10],p=e[11],m=e[12],g=e[13],v=e[14],y=e[15],b=t[0],x=t[1],E=t[2],w=t[3];return n[0]=b*i+x*a+E*f+w*m,n[1]=b*r+x*c+E*d+w*g,n[2]=b*s+x*l+E*h+w*v,n[3]=b*o+x*u+E*p+w*y,b=t[4],x=t[5],E=t[6],w=t[7],n[4]=b*i+x*a+E*f+w*m,n[5]=b*r+x*c+E*d+w*g,n[6]=b*s+x*l+E*h+w*v,n[7]=b*o+x*u+E*p+w*y,b=t[8],x=t[9],E=t[10],w=t[11],n[8]=b*i+x*a+E*f+w*m,n[9]=b*r+x*c+E*d+w*g,n[10]=b*s+x*l+E*h+w*v,n[11]=b*o+x*u+E*p+w*y,b=t[12],x=t[13],E=t[14],w=t[15],n[12]=b*i+x*a+E*f+w*m,n[13]=b*r+x*c+E*d+w*g,n[14]=b*s+x*l+E*h+w*v,n[15]=b*o+x*u+E*p+w*y,n}function Ig(n,e,t){let i=t[0],r=t[1],s=t[2],o,a,c,l,u,f,d,h,p,m,g,v;return e===n?(n[12]=e[0]*i+e[4]*r+e[8]*s+e[12],n[13]=e[1]*i+e[5]*r+e[9]*s+e[13],n[14]=e[2]*i+e[6]*r+e[10]*s+e[14],n[15]=e[3]*i+e[7]*r+e[11]*s+e[15]):(o=e[0],a=e[1],c=e[2],l=e[3],u=e[4],f=e[5],d=e[6],h=e[7],p=e[8],m=e[9],g=e[10],v=e[11],n[0]=o,n[1]=a,n[2]=c,n[3]=l,n[4]=u,n[5]=f,n[6]=d,n[7]=h,n[8]=p,n[9]=m,n[10]=g,n[11]=v,n[12]=o*i+u*r+p*s+e[12],n[13]=a*i+f*r+m*s+e[13],n[14]=c*i+d*r+g*s+e[14],n[15]=l*i+h*r+v*s+e[15]),n}function Bg(n,e,t){let i=t[0],r=t[1],s=t[2];return n[0]=e[0]*i,n[1]=e[1]*i,n[2]=e[2]*i,n[3]=e[3]*i,n[4]=e[4]*r,n[5]=e[5]*r,n[6]=e[6]*r,n[7]=e[7]*r,n[8]=e[8]*s,n[9]=e[9]*s,n[10]=e[10]*s,n[11]=e[11]*s,n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function Og(n,e,t,i){let r=i[0],s=i[1],o=i[2],a=Math.sqrt(r*r+s*s+o*o),c,l,u,f,d,h,p,m,g,v,y,b,x,E,w,T,R,F,O,j,V,G,q,X;return a<1e-6?null:(a=1/a,r*=a,s*=a,o*=a,l=Math.sin(t),c=Math.cos(t),u=1-c,f=e[0],d=e[1],h=e[2],p=e[3],m=e[4],g=e[5],v=e[6],y=e[7],b=e[8],x=e[9],E=e[10],w=e[11],T=r*r*u+c,R=s*r*u+o*l,F=o*r*u-s*l,O=r*s*u-o*l,j=s*s*u+c,V=o*s*u+r*l,G=r*o*u+s*l,q=s*o*u-r*l,X=o*o*u+c,n[0]=f*T+m*R+b*F,n[1]=d*T+g*R+x*F,n[2]=h*T+v*R+E*F,n[3]=p*T+y*R+w*F,n[4]=f*O+m*j+b*V,n[5]=d*O+g*j+x*V,n[6]=h*O+v*j+E*V,n[7]=p*O+y*j+w*V,n[8]=f*G+m*q+b*X,n[9]=d*G+g*q+x*X,n[10]=h*G+v*q+E*X,n[11]=p*G+y*q+w*X,e!==n&&(n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n)}function Dg(n,e,t){let i=Math.sin(t),r=Math.cos(t),s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],f=e[10],d=e[11];return e!==n&&(n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[4]=s*r+l*i,n[5]=o*r+u*i,n[6]=a*r+f*i,n[7]=c*r+d*i,n[8]=l*r-s*i,n[9]=u*r-o*i,n[10]=f*r-a*i,n[11]=d*r-c*i,n}function Ng(n,e,t){let i=Math.sin(t),r=Math.cos(t),s=e[0],o=e[1],a=e[2],c=e[3],l=e[8],u=e[9],f=e[10],d=e[11];return e!==n&&(n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=s*r-l*i,n[1]=o*r-u*i,n[2]=a*r-f*i,n[3]=c*r-d*i,n[8]=s*i+l*r,n[9]=o*i+u*r,n[10]=a*i+f*r,n[11]=c*i+d*r,n}function Fg(n,e,t){let i=Math.sin(t),r=Math.cos(t),s=e[0],o=e[1],a=e[2],c=e[3],l=e[4],u=e[5],f=e[6],d=e[7];return e!==n&&(n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=s*r+l*i,n[1]=o*r+u*i,n[2]=a*r+f*i,n[3]=c*r+d*i,n[4]=l*r-s*i,n[5]=u*r-o*i,n[6]=f*r-a*i,n[7]=d*r-c*i,n}function cD(n,e){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=e[0],n[13]=e[1],n[14]=e[2],n[15]=1,n}function lD(n,e){return n[0]=e[0],n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=e[1],n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=e[2],n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function uD(n,e,t){let i=t[0],r=t[1],s=t[2],o=Math.sqrt(i*i+r*r+s*s),a,c,l;return o<1e-6?null:(o=1/o,i*=o,r*=o,s*=o,c=Math.sin(e),a=Math.cos(e),l=1-a,n[0]=i*i*l+a,n[1]=r*i*l+s*c,n[2]=s*i*l-r*c,n[3]=0,n[4]=i*r*l-s*c,n[5]=r*r*l+a,n[6]=s*r*l+i*c,n[7]=0,n[8]=i*s*l+r*c,n[9]=r*s*l-i*c,n[10]=s*s*l+a,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n)}function fD(n,e){let t=Math.sin(e),i=Math.cos(e);return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i,n[6]=t,n[7]=0,n[8]=0,n[9]=-t,n[10]=i,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function dD(n,e){let t=Math.sin(e),i=Math.cos(e);return n[0]=i,n[1]=0,n[2]=-t,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=t,n[9]=0,n[10]=i,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function hD(n,e){let t=Math.sin(e),i=Math.cos(e);return n[0]=i,n[1]=t,n[2]=0,n[3]=0,n[4]=-t,n[5]=i,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function bE(n,e,t){let i=e[0],r=e[1],s=e[2],o=e[3],a=i+i,c=r+r,l=s+s,u=i*a,f=i*c,d=i*l,h=r*c,p=r*l,m=s*l,g=o*a,v=o*c,y=o*l;return n[0]=1-(h+m),n[1]=f+y,n[2]=d-v,n[3]=0,n[4]=f-y,n[5]=1-(u+m),n[6]=p+g,n[7]=0,n[8]=d+v,n[9]=p-g,n[10]=1-(u+h),n[11]=0,n[12]=t[0],n[13]=t[1],n[14]=t[2],n[15]=1,n}function pD(n,e){let t=new we(3),i=-e[0],r=-e[1],s=-e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=i*i+r*r+s*s+o*o;return f>0?(t[0]=(a*o+u*i+c*s-l*r)*2/f,t[1]=(c*o+u*r+l*i-a*s)*2/f,t[2]=(l*o+u*s+a*r-c*i)*2/f):(t[0]=(a*o+u*i+c*s-l*r)*2,t[1]=(c*o+u*r+l*i-a*s)*2,t[2]=(l*o+u*s+a*r-c*i)*2),bE(n,e,t),n}function mD(n,e){return n[0]=e[12],n[1]=e[13],n[2]=e[14],n}function vE(n,e){let t=e[0],i=e[1],r=e[2],s=e[4],o=e[5],a=e[6],c=e[8],l=e[9],u=e[10];return n[0]=Math.sqrt(t*t+i*i+r*r),n[1]=Math.sqrt(s*s+o*o+a*a),n[2]=Math.sqrt(c*c+l*l+u*u),n}function gD(n,e){let t=new we(3);vE(t,e);let i=1/t[0],r=1/t[1],s=1/t[2],o=e[0]*i,a=e[1]*r,c=e[2]*s,l=e[4]*i,u=e[5]*r,f=e[6]*s,d=e[8]*i,h=e[9]*r,p=e[10]*s,m=o+u+p,g=0;return m>0?(g=Math.sqrt(m+1)*2,n[3]=.25*g,n[0]=(f-h)/g,n[1]=(d-c)/g,n[2]=(a-l)/g):o>u&&o>p?(g=Math.sqrt(1+o-u-p)*2,n[3]=(f-h)/g,n[0]=.25*g,n[1]=(a+l)/g,n[2]=(d+c)/g):u>p?(g=Math.sqrt(1+u-o-p)*2,n[3]=(d-c)/g,n[0]=(a+l)/g,n[1]=.25*g,n[2]=(f+h)/g):(g=Math.sqrt(1+p-o-u)*2,n[3]=(a-l)/g,n[0]=(d+c)/g,n[1]=(f+h)/g,n[2]=.25*g),n}function _D(n,e,t,i){e[0]=i[12],e[1]=i[13],e[2]=i[14];let r=i[0],s=i[1],o=i[2],a=i[4],c=i[5],l=i[6],u=i[8],f=i[9],d=i[10];t[0]=Math.sqrt(r*r+s*s+o*o),t[1]=Math.sqrt(a*a+c*c+l*l),t[2]=Math.sqrt(u*u+f*f+d*d);let h=1/t[0],p=1/t[1],m=1/t[2],g=r*h,v=s*p,y=o*m,b=a*h,x=c*p,E=l*m,w=u*h,T=f*p,R=d*m,F=g+x+R,O=0;return F>0?(O=Math.sqrt(F+1)*2,n[3]=.25*O,n[0]=(E-T)/O,n[1]=(w-y)/O,n[2]=(v-b)/O):g>x&&g>R?(O=Math.sqrt(1+g-x-R)*2,n[3]=(E-T)/O,n[0]=.25*O,n[1]=(v+b)/O,n[2]=(w+y)/O):x>R?(O=Math.sqrt(1+x-g-R)*2,n[3]=(w-y)/O,n[0]=(v+b)/O,n[1]=.25*O,n[2]=(E+T)/O):(O=Math.sqrt(1+R-g-x)*2,n[3]=(v-b)/O,n[0]=(w+y)/O,n[1]=(E+T)/O,n[2]=.25*O),n}function yD(n,e,t,i){let r=e[0],s=e[1],o=e[2],a=e[3],c=r+r,l=s+s,u=o+o,f=r*c,d=r*l,h=r*u,p=s*l,m=s*u,g=o*u,v=a*c,y=a*l,b=a*u,x=i[0],E=i[1],w=i[2];return n[0]=(1-(p+g))*x,n[1]=(d+b)*x,n[2]=(h-y)*x,n[3]=0,n[4]=(d-b)*E,n[5]=(1-(f+g))*E,n[6]=(m+v)*E,n[7]=0,n[8]=(h+y)*w,n[9]=(m-v)*w,n[10]=(1-(f+p))*w,n[11]=0,n[12]=t[0],n[13]=t[1],n[14]=t[2],n[15]=1,n}function bD(n,e,t,i,r){let s=e[0],o=e[1],a=e[2],c=e[3],l=s+s,u=o+o,f=a+a,d=s*l,h=s*u,p=s*f,m=o*u,g=o*f,v=a*f,y=c*l,b=c*u,x=c*f,E=i[0],w=i[1],T=i[2],R=r[0],F=r[1],O=r[2],j=(1-(m+v))*E,V=(h+x)*E,G=(p-b)*E,q=(h-x)*w,X=(1-(d+v))*w,se=(g+y)*w,le=(p+b)*T,he=(g-y)*T,at=(1-(d+m))*T;return n[0]=j,n[1]=V,n[2]=G,n[3]=0,n[4]=q,n[5]=X,n[6]=se,n[7]=0,n[8]=le,n[9]=he,n[10]=at,n[11]=0,n[12]=t[0]+R-(j*R+q*F+le*O),n[13]=t[1]+F-(V*R+X*F+he*O),n[14]=t[2]+O-(G*R+se*F+at*O),n[15]=1,n}function zg(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],o=t+t,a=i+i,c=r+r,l=t*o,u=i*o,f=i*a,d=r*o,h=r*a,p=r*c,m=s*o,g=s*a,v=s*c;return n[0]=1-f-p,n[1]=u+v,n[2]=d-g,n[3]=0,n[4]=u-v,n[5]=1-l-p,n[6]=h+m,n[7]=0,n[8]=d+g,n[9]=h-m,n[10]=1-l-f,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Ug(n,e,t,i,r,s,o){let a=1/(t-e),c=1/(r-i),l=1/(s-o);return n[0]=s*2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=s*2*c,n[6]=0,n[7]=0,n[8]=(t+e)*a,n[9]=(r+i)*c,n[10]=(o+s)*l,n[11]=-1,n[12]=0,n[13]=0,n[14]=o*s*2*l,n[15]=0,n}function xE(n,e,t,i,r){let s=1/Math.tan(e/2);if(n[0]=s/t,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=s,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,r!=null&&r!==1/0){let o=1/(i-r);n[10]=(r+i)*o,n[14]=2*r*i*o}else n[10]=-1,n[14]=-2*i;return n}function vD(n,e,t,i,r){let s=1/Math.tan(e/2);if(n[0]=s/t,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=s,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,r!=null&&r!==1/0){let o=1/(i-r);n[10]=r*o,n[14]=r*i*o}else n[10]=-1,n[14]=-i;return n}function xD(n,e,t,i){let r=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),o=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),c=2/(o+a),l=2/(r+s);return n[0]=c,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=l,n[6]=0,n[7]=0,n[8]=-((o-a)*c*.5),n[9]=(r-s)*l*.5,n[10]=i/(t-i),n[11]=-1,n[12]=0,n[13]=0,n[14]=i*t/(t-i),n[15]=0,n}function wE(n,e,t,i,r,s,o){let a=1/(e-t),c=1/(i-r),l=1/(s-o);return n[0]=-2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*c,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*l,n[11]=0,n[12]=(e+t)*a,n[13]=(r+i)*c,n[14]=(o+s)*l,n[15]=1,n}function wD(n,e,t,i,r,s,o){let a=1/(e-t),c=1/(i-r),l=1/(s-o);return n[0]=-2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*c,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=l,n[11]=0,n[12]=(e+t)*a,n[13]=(r+i)*c,n[14]=s*l,n[15]=1,n}function Vg(n,e,t,i){let r,s,o,a,c,l,u,f,d,h,p=e[0],m=e[1],g=e[2],v=i[0],y=i[1],b=i[2],x=t[0],E=t[1],w=t[2];return Math.abs(p-x)<1e-6&&Math.abs(m-E)<1e-6&&Math.abs(g-w)<1e-6?yE(n):(f=p-x,d=m-E,h=g-w,r=1/Math.sqrt(f*f+d*d+h*h),f*=r,d*=r,h*=r,s=y*h-b*d,o=b*f-v*h,a=v*d-y*f,r=Math.sqrt(s*s+o*o+a*a),r?(r=1/r,s*=r,o*=r,a*=r):(s=0,o=0,a=0),c=d*a-h*o,l=h*s-f*a,u=f*o-d*s,r=Math.sqrt(c*c+l*l+u*u),r?(r=1/r,c*=r,l*=r,u*=r):(c=0,l=0,u=0),n[0]=s,n[1]=c,n[2]=f,n[3]=0,n[4]=o,n[5]=l,n[6]=d,n[7]=0,n[8]=a,n[9]=u,n[10]=h,n[11]=0,n[12]=-(s*p+o*m+a*g),n[13]=-(c*p+l*m+u*g),n[14]=-(f*p+d*m+h*g),n[15]=1,n)}function ED(n,e,t,i){let r=e[0],s=e[1],o=e[2],a=i[0],c=i[1],l=i[2],u=r-t[0],f=s-t[1],d=o-t[2],h=u*u+f*f+d*d;h>0&&(h=1/Math.sqrt(h),u*=h,f*=h,d*=h);let p=c*d-l*f,m=l*u-a*d,g=a*f-c*u;return h=p*p+m*m+g*g,h>0&&(h=1/Math.sqrt(h),p*=h,m*=h,g*=h),n[0]=p,n[1]=m,n[2]=g,n[3]=0,n[4]=f*g-d*m,n[5]=d*p-u*g,n[6]=u*m-f*p,n[7]=0,n[8]=u,n[9]=f,n[10]=d,n[11]=0,n[12]=r,n[13]=s,n[14]=o,n[15]=1,n}function SD(n){return`mat4(${n[0]}, ${n[1]}, ${n[2]}, ${n[3]}, ${n[4]}, ${n[5]}, ${n[6]}, ${n[7]}, ${n[8]}, ${n[9]}, ${n[10]}, ${n[11]}, ${n[12]}, ${n[13]}, ${n[14]}, ${n[15]})`}function PD(n){return Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]+n[3]*n[3]+n[4]*n[4]+n[5]*n[5]+n[6]*n[6]+n[7]*n[7]+n[8]*n[8]+n[9]*n[9]+n[10]*n[10]+n[11]*n[11]+n[12]*n[12]+n[13]*n[13]+n[14]*n[14]+n[15]*n[15])}function CD(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n[3]=e[3]+t[3],n[4]=e[4]+t[4],n[5]=e[5]+t[5],n[6]=e[6]+t[6],n[7]=e[7]+t[7],n[8]=e[8]+t[8],n[9]=e[9]+t[9],n[10]=e[10]+t[10],n[11]=e[11]+t[11],n[12]=e[12]+t[12],n[13]=e[13]+t[13],n[14]=e[14]+t[14],n[15]=e[15]+t[15],n}function EE(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n[3]=e[3]-t[3],n[4]=e[4]-t[4],n[5]=e[5]-t[5],n[6]=e[6]-t[6],n[7]=e[7]-t[7],n[8]=e[8]-t[8],n[9]=e[9]-t[9],n[10]=e[10]-t[10],n[11]=e[11]-t[11],n[12]=e[12]-t[12],n[13]=e[13]-t[13],n[14]=e[14]-t[14],n[15]=e[15]-t[15],n}function TD(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n[3]=e[3]*t,n[4]=e[4]*t,n[5]=e[5]*t,n[6]=e[6]*t,n[7]=e[7]*t,n[8]=e[8]*t,n[9]=e[9]*t,n[10]=e[10]*t,n[11]=e[11]*t,n[12]=e[12]*t,n[13]=e[13]*t,n[14]=e[14]*t,n[15]=e[15]*t,n}function LD(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n[2]=e[2]+t[2]*i,n[3]=e[3]+t[3]*i,n[4]=e[4]+t[4]*i,n[5]=e[5]+t[5]*i,n[6]=e[6]+t[6]*i,n[7]=e[7]+t[7]*i,n[8]=e[8]+t[8]*i,n[9]=e[9]+t[9]*i,n[10]=e[10]+t[10]*i,n[11]=e[11]+t[11]*i,n[12]=e[12]+t[12]*i,n[13]=e[13]+t[13]*i,n[14]=e[14]+t[14]*i,n[15]=e[15]+t[15]*i,n}function MD(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]&&n[3]===e[3]&&n[4]===e[4]&&n[5]===e[5]&&n[6]===e[6]&&n[7]===e[7]&&n[8]===e[8]&&n[9]===e[9]&&n[10]===e[10]&&n[11]===e[11]&&n[12]===e[12]&&n[13]===e[13]&&n[14]===e[14]&&n[15]===e[15]}function AD(n,e){let t=n[0],i=n[1],r=n[2],s=n[3],o=n[4],a=n[5],c=n[6],l=n[7],u=n[8],f=n[9],d=n[10],h=n[11],p=n[12],m=n[13],g=n[14],v=n[15],y=e[0],b=e[1],x=e[2],E=e[3],w=e[4],T=e[5],R=e[6],F=e[7],O=e[8],j=e[9],V=e[10],G=e[11],q=e[12],X=e[13],se=e[14],le=e[15];return Math.abs(t-y)<=1e-6*Math.max(1,Math.abs(t),Math.abs(y))&&Math.abs(i-b)<=1e-6*Math.max(1,Math.abs(i),Math.abs(b))&&Math.abs(r-x)<=1e-6*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(s-E)<=1e-6*Math.max(1,Math.abs(s),Math.abs(E))&&Math.abs(o-w)<=1e-6*Math.max(1,Math.abs(o),Math.abs(w))&&Math.abs(a-T)<=1e-6*Math.max(1,Math.abs(a),Math.abs(T))&&Math.abs(c-R)<=1e-6*Math.max(1,Math.abs(c),Math.abs(R))&&Math.abs(l-F)<=1e-6*Math.max(1,Math.abs(l),Math.abs(F))&&Math.abs(u-O)<=1e-6*Math.max(1,Math.abs(u),Math.abs(O))&&Math.abs(f-j)<=1e-6*Math.max(1,Math.abs(f),Math.abs(j))&&Math.abs(d-V)<=1e-6*Math.max(1,Math.abs(d),Math.abs(V))&&Math.abs(h-G)<=1e-6*Math.max(1,Math.abs(h),Math.abs(G))&&Math.abs(p-q)<=1e-6*Math.max(1,Math.abs(p),Math.abs(q))&&Math.abs(m-X)<=1e-6*Math.max(1,Math.abs(m),Math.abs(X))&&Math.abs(g-se)<=1e-6*Math.max(1,Math.abs(g),Math.abs(se))&&Math.abs(v-le)<=1e-6*Math.max(1,Math.abs(v),Math.abs(le))}var $g,Gg,kD,RD,Wg=C(()=>{$r();$g=xE;Gg=wE;kD=Ka,RD=EE});var Rt={};mi(Rt,{add:()=>ME,ceil:()=>ID,clone:()=>PE,copy:()=>TE,create:()=>SE,cross:()=>$D,dist:()=>XD,distance:()=>BE,div:()=>ZD,divide:()=>RE,dot:()=>DE,equals:()=>HD,exactEquals:()=>FE,floor:()=>BD,forEach:()=>e4,fromValues:()=>CE,inverse:()=>UD,len:()=>QD,length:()=>jg,lerp:()=>NE,max:()=>DD,min:()=>OD,mul:()=>qD,multiply:()=>kE,negate:()=>zD,normalize:()=>Yg,random:()=>GD,round:()=>ND,scale:()=>IE,scaleAndAdd:()=>FD,set:()=>LE,sqrDist:()=>KD,sqrLen:()=>JD,squaredDistance:()=>OE,squaredLength:()=>Hg,str:()=>jD,sub:()=>YD,subtract:()=>AE,transformMat4:()=>qg,transformQuat:()=>VD,zero:()=>WD});function SE(){let n=new we(4);return we!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0,n[3]=0),n}function PE(n){let e=new we(4);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e}function CE(n,e,t,i){let r=new we(4);return r[0]=n,r[1]=e,r[2]=t,r[3]=i,r}function TE(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n}function LE(n,e,t,i,r){return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n}function ME(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n[3]=e[3]+t[3],n}function AE(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n[3]=e[3]-t[3],n}function kE(n,e,t){return n[0]=e[0]*t[0],n[1]=e[1]*t[1],n[2]=e[2]*t[2],n[3]=e[3]*t[3],n}function RE(n,e,t){return n[0]=e[0]/t[0],n[1]=e[1]/t[1],n[2]=e[2]/t[2],n[3]=e[3]/t[3],n}function ID(n,e){return n[0]=Math.ceil(e[0]),n[1]=Math.ceil(e[1]),n[2]=Math.ceil(e[2]),n[3]=Math.ceil(e[3]),n}function BD(n,e){return n[0]=Math.floor(e[0]),n[1]=Math.floor(e[1]),n[2]=Math.floor(e[2]),n[3]=Math.floor(e[3]),n}function OD(n,e,t){return n[0]=Math.min(e[0],t[0]),n[1]=Math.min(e[1],t[1]),n[2]=Math.min(e[2],t[2]),n[3]=Math.min(e[3],t[3]),n}function DD(n,e,t){return n[0]=Math.max(e[0],t[0]),n[1]=Math.max(e[1],t[1]),n[2]=Math.max(e[2],t[2]),n[3]=Math.max(e[3],t[3]),n}function ND(n,e){return n[0]=Kt(e[0]),n[1]=Kt(e[1]),n[2]=Kt(e[2]),n[3]=Kt(e[3]),n}function IE(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n[3]=e[3]*t,n}function FD(n,e,t,i){return n[0]=e[0]+t[0]*i,n[1]=e[1]+t[1]*i,n[2]=e[2]+t[2]*i,n[3]=e[3]+t[3]*i,n}function BE(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2],s=e[3]-n[3];return Math.sqrt(t*t+i*i+r*r+s*s)}function OE(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2],s=e[3]-n[3];return t*t+i*i+r*r+s*s}function jg(n){let e=n[0],t=n[1],i=n[2],r=n[3];return Math.sqrt(e*e+t*t+i*i+r*r)}function Hg(n){let e=n[0],t=n[1],i=n[2],r=n[3];return e*e+t*t+i*i+r*r}function zD(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n[3]=-e[3],n}function UD(n,e){return n[0]=1/e[0],n[1]=1/e[1],n[2]=1/e[2],n[3]=1/e[3],n}function Yg(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],o=t*t+i*i+r*r+s*s;return o>0&&(o=1/Math.sqrt(o)),n[0]=t*o,n[1]=i*o,n[2]=r*o,n[3]=s*o,n}function DE(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]+n[3]*e[3]}function $D(n,e,t,i){let r=t[0]*i[1]-t[1]*i[0],s=t[0]*i[2]-t[2]*i[0],o=t[0]*i[3]-t[3]*i[0],a=t[1]*i[2]-t[2]*i[1],c=t[1]*i[3]-t[3]*i[1],l=t[2]*i[3]-t[3]*i[2],u=e[0],f=e[1],d=e[2],h=e[3];return n[0]=f*l-d*c+h*a,n[1]=-(u*l)+d*o-h*s,n[2]=u*c-f*o+h*r,n[3]=-(u*a)+f*s-d*r,n}function NE(n,e,t,i){let r=e[0],s=e[1],o=e[2],a=e[3];return n[0]=r+i*(t[0]-r),n[1]=s+i*(t[1]-s),n[2]=o+i*(t[2]-o),n[3]=a+i*(t[3]-a),n}function GD(n,e){e=e===void 0?1:e;let t,i,r,s,o,a;do t=Gn()*2-1,i=Gn()*2-1,o=t*t+i*i;while(o>=1);do r=Gn()*2-1,s=Gn()*2-1,a=r*r+s*s;while(a>=1);let c=Math.sqrt((1-o)/a);return n[0]=e*t,n[1]=e*i,n[2]=e*r*c,n[3]=e*s*c,n}function qg(n,e,t){let i=e[0],r=e[1],s=e[2],o=e[3];return n[0]=t[0]*i+t[4]*r+t[8]*s+t[12]*o,n[1]=t[1]*i+t[5]*r+t[9]*s+t[13]*o,n[2]=t[2]*i+t[6]*r+t[10]*s+t[14]*o,n[3]=t[3]*i+t[7]*r+t[11]*s+t[15]*o,n}function VD(n,e,t){let i=e[0],r=e[1],s=e[2],o=t[0],a=t[1],c=t[2],l=t[3],u=l*i+a*s-c*r,f=l*r+c*i-o*s,d=l*s+o*r-a*i,h=-o*i-a*r-c*s;return n[0]=u*l+h*-o+f*-c-d*-a,n[1]=f*l+h*-a+d*-o-u*-c,n[2]=d*l+h*-c+u*-a-f*-o,n[3]=e[3],n}function WD(n){return n[0]=0,n[1]=0,n[2]=0,n[3]=0,n}function jD(n){return`vec4(${n[0]}, ${n[1]}, ${n[2]}, ${n[3]})`}function FE(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]&&n[3]===e[3]}function HD(n,e){let t=n[0],i=n[1],r=n[2],s=n[3],o=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(t-o)<=1e-6*Math.max(1,Math.abs(t),Math.abs(o))&&Math.abs(i-a)<=1e-6*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(r-c)<=1e-6*Math.max(1,Math.abs(r),Math.abs(c))&&Math.abs(s-l)<=1e-6*Math.max(1,Math.abs(s),Math.abs(l))}var YD,qD,ZD,XD,KD,QD,JD,e4,sf=C(()=>{$r();YD=AE,qD=kE,ZD=RE,XD=BE,KD=OE,QD=jg,JD=Hg,e4=function(){let n=SE();return function(e,t,i,r,s,o){let a,c;for(t||(t=4),i||(i=0),r?c=Math.min(r*t+i,e.length):c=e.length,a=i;aMath.PI*2)throw Error("expected radians")}function o4(n,e,t,i,r,s){let o=2*s/(t-e),a=2*s/(r-i),c=(t+e)/(t-e),l=(r+i)/(r-i),u=-1,f=-1,d=-2*s;return n[0]=o,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=a,n[6]=0,n[7]=0,n[8]=c,n[9]=l,n[10]=u,n[11]=f,n[12]=0,n[13]=0,n[14]=d,n[15]=0,n}var Kg,t4,n4,Zg,Xg,i4,ze,of,af,UE=C(()=>{mE();Ya();bg();Wg();yg();Xa();sf();(function(n){n[n.COL0ROW0=0]="COL0ROW0",n[n.COL0ROW1=1]="COL0ROW1",n[n.COL0ROW2=2]="COL0ROW2",n[n.COL0ROW3=3]="COL0ROW3",n[n.COL1ROW0=4]="COL1ROW0",n[n.COL1ROW1=5]="COL1ROW1",n[n.COL1ROW2=6]="COL1ROW2",n[n.COL1ROW3=7]="COL1ROW3",n[n.COL2ROW0=8]="COL2ROW0",n[n.COL2ROW1=9]="COL2ROW1",n[n.COL2ROW2=10]="COL2ROW2",n[n.COL2ROW3=11]="COL2ROW3",n[n.COL3ROW0=12]="COL3ROW0",n[n.COL3ROW1=13]="COL3ROW1",n[n.COL3ROW2=14]="COL3ROW2",n[n.COL3ROW3=15]="COL3ROW3"})(Kg||(Kg={}));t4=45*Math.PI/180,n4=1,Zg=.1,Xg=500,i4=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),ze=class extends rf{static get IDENTITY(){return s4()}static get ZERO(){return r4()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Kg}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,i,r,s,o,a,c,l,u,f,d,h,p,m,g){return this[0]=e,this[1]=t,this[2]=i,this[3]=r,this[4]=s,this[5]=o,this[6]=a,this[7]=c,this[8]=l,this[9]=u,this[10]=f,this[11]=d,this[12]=h,this[13]=p,this[14]=m,this[15]=g,this.check()}setRowMajor(e,t,i,r,s,o,a,c,l,u,f,d,h,p,m,g){return this[0]=e,this[1]=s,this[2]=l,this[3]=h,this[4]=t,this[5]=o,this[6]=u,this[7]=p,this[8]=i,this[9]=a,this[10]=f,this[11]=m,this[12]=r,this[13]=c,this[14]=d,this[15]=g,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(i4)}fromObject(e){return this.check()}fromQuaternion(e){return zg(this,e),this.check()}frustum(e){let{left:t,right:i,bottom:r,top:s,near:o=Zg,far:a=Xg}=e;return a===1/0?o4(this,t,i,r,s,o):Ug(this,t,i,r,s,o,a),this.check()}lookAt(e){let{eye:t,center:i=[0,0,0],up:r=[0,1,0]}=e;return Vg(this,t,i,r),this.check()}ortho(e){let{left:t,right:i,bottom:r,top:s,near:o=Zg,far:a=Xg}=e;return Gg(this,t,i,r,s,o,a),this.check()}orthographic(e){let{fovy:t=t4,aspect:i=n4,focalDistance:r=1,near:s=Zg,far:o=Xg}=e;zE(t);let a=t/2,c=r*Math.tan(a),l=c*i;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:s,far:o})}perspective(e){let{fovy:t=45*Math.PI/180,aspect:i=1,near:r=.1,far:s=500}=e;return zE(t),$g(this,t,i,r,s),this.check()}determinant(){return Rg(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let i=this.getScale(t),r=1/i[0],s=1/i[1],o=1/i[2];return e[0]=this[0]*r,e[1]=this[1]*s,e[2]=this[2]*o,e[3]=0,e[4]=this[4]*r,e[5]=this[5]*s,e[6]=this[6]*o,e[7]=0,e[8]=this[8]*r,e[9]=this[9]*s,e[10]=this[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let i=this.getScale(t),r=1/i[0],s=1/i[1],o=1/i[2];return e[0]=this[0]*r,e[1]=this[1]*s,e[2]=this[2]*o,e[3]=this[4]*r,e[4]=this[5]*s,e[5]=this[6]*o,e[6]=this[8]*r,e[7]=this[9]*s,e[8]=this[10]*o,e}transpose(){return Ag(this,this),this.check()}invert(){return kg(this,this),this.check()}multiplyLeft(e){return Ka(this,e,this),this.check()}multiplyRight(e){return Ka(this,this,e),this.check()}rotateX(e){return Dg(this,this,e),this.check()}rotateY(e){return Ng(this,this,e),this.check()}rotateZ(e){return Fg(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return Og(this,this,e,t),this.check()}scale(e){return Bg(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return Ig(this,this,e),this.check()}transform(e,t){return e.length===4?(t=qg(t||[-0,-0,-0,-0],e,this),Ku(t,4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){let{length:i}=e,r;switch(i){case 2:r=_g(t||[-0,-0],e,this);break;case 3:r=Za(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Ku(r,e.length),r}transformAsVector(e,t){let i;switch(e.length){case 2:i=sE(t||[-0,-0],e,this);break;case 3:i=Ju(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Ku(i,e.length),i}transformPoint(e,t){return this.transformAsPoint(e,t)}transformVector(e,t){return this.transformAsPoint(e,t)}transformDirection(e,t){return this.transformAsVector(e,t)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,i){return this.identity().translate([e,t,i])}}});function $E(){let n=new we(4);return we!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n[3]=1,n}function a4(n,e,t){t=t*.5;let i=Math.sin(t);return n[0]=i*e[0],n[1]=i*e[1],n[2]=i*e[2],n[3]=Math.cos(t),n}function Qg(n,e,t,i){let r=e[0],s=e[1],o=e[2],a=e[3],c=t[0],l=t[1],u=t[2],f=t[3],d,h,p,m,g;return d=r*c+s*l+o*u+a*f,d<0&&(d=-d,c=-c,l=-l,u=-u,f=-f),1-d>1e-6?(h=Math.acos(d),g=Math.sin(h),p=Math.sin((1-i)*h)/g,m=Math.sin(i*h)/g):(p=1-i,m=i),n[0]=p*r+m*c,n[1]=p*s+m*l,n[2]=p*o+m*u,n[3]=p*a+m*f,n}function c4(n,e){let t=e[0]+e[4]+e[8],i;if(t>0)i=Math.sqrt(t+1),n[3]=.5*i,i=.5/i,n[0]=(e[5]-e[7])*i,n[1]=(e[6]-e[2])*i,n[2]=(e[1]-e[3])*i;else{let r=0;e[4]>e[0]&&(r=1),e[8]>e[r*3+r]&&(r=2);let s=(r+1)%3,o=(r+2)%3;i=Math.sqrt(e[r*3+r]-e[s*3+s]-e[o*3+o]+1),n[r]=.5*i,i=.5/i,n[3]=(e[s*3+o]-e[o*3+s])*i,n[s]=(e[s*3+r]+e[r*3+s])*i,n[o]=(e[o*3+r]+e[r*3+o])*i}return n}var GE,IK,BK,OK,VE=C(()=>{$r();Mg();Xa();sf();GE=Yg,IK=function(){let n=ef(),e=tf(1,0,0),t=tf(0,1,0);return function(i,r,s){let o=qa(r,s);return o<-.999999?(Gr(n,e,r),Tg(n)<1e-6&&Gr(n,t,r),vg(n,n),a4(i,n,Math.PI),i):o>.999999?(i[0]=0,i[1]=0,i[2]=0,i[3]=1,i):(Gr(n,r,s),i[0]=n[0],i[1]=n[1],i[2]=n[2],i[3]=1+o,GE(i,i))}}(),BK=function(){let n=$E(),e=$E();return function(t,i,r,s,o,a){return Qg(n,i,o,a),Qg(e,r,s,a),Qg(t,n,e,2*a*(1-a)),t}}(),OK=function(){let n=gE();return function(e,t,i,r){return n[0]=i[0],n[3]=i[1],n[6]=i[2],n[1]=r[0],n[4]=r[1],n[7]=r[2],n[2]=-t[0],n[5]=-t[1],n[8]=-t[2],GE(e,c4(e,n))}}()});var DK,NK,FK,zK,WE=C(()=>{DK=Math.PI/2,NK=Math.PI/4,FK=Math.PI/6,zK=Math.PI*2});var Ue=C(()=>{pE();UE();WE();Ks();Mg();Wg();VE();yg();Xa();sf()});function Jg(n,e=[],t=0){let i=Math.fround(n),r=n-i;return e[t]=i,e[t+1]=r,e}function jE(n){return n-Math.fround(n)}function HE(n){let e=new Float32Array(32);for(let t=0;t<4;++t)for(let i=0;i<4;++i){let r=t*4+i;Jg(n[i*4+t],e,r*2)}return e}var YE=C(()=>{});function cf(n,e=!0){return n??e}function e_(n=[0,0,0],e=!0){return e?n.map(t=>t/255):[...n]}function qE(n,e=!0){let t=e_(n.slice(0,3),e),i=Number.isFinite(n[3]),r=i?n[3]:1;return[t[0],t[1],t[2],e&&i?r/255:r]}var t_=C(()=>{});var f4,d4,Vr,ZE=C(()=>{f4=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND -// All these functions are for substituting tan() function from Intel GPU only +// All these functions are for substituting tan() function from Int_el GPU only const float TWO_PI = 6.2831854820251465; const float PI_2 = 1.5707963705062866; const float PI_16 = 0.1963495463132858; @@ -2525,7 +2525,7 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3, position_worldspace } return lightColor; } -`});var M4,eo,bS=C(()=>{oS();hS();gS();yS();M4=[38.25,38.25,38.25],eo={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:mS.replace("phongMaterial","gouraudMaterial"),fs:pS.replace("phongMaterial","gouraudMaterial"),source:_S.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[fS,sS],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:M4},getUniforms(n){return{...eo.defaultUniforms,...n}}}});var vt=C(()=>{_m();dw();ng();Hw();qw();ZE();tS();aS();bS()});function Zn(n="id"){T_[n]=T_[n]||1;let e=T_[n]++;return`${n}-${e}`}var T_,_o=C(()=>{T_={}});function Kr(n){switch(n){case"POSITION":return"positions";case"NORMAL":return"normals";case"TEXCOORD_0":return"texCoords";case"TEXCOORD_1":return"texCoords1";case"COLOR_0":return"colors";default:return n}}function PF(n){let e=[];for(let[t,i]of Object.entries(n)){if(!i)continue;let{value:r,size:s,normalized:o}=i;if(s===void 0)throw new Error(`Attribute ${t} is missing a size`);e.push({name:Kr(t),format:Pe.getVertexFormatFromAttribute(r,s,o)})}return e}var en,Rf=C(()=>{J();_o();en=class{id;topology;vertexCount;indices;attributes;bufferLayout;userData={};constructor(e){let{attributes:t={},indices:i=null,vertexCount:r=null}=e;this.id=e.id||Zn("geometry"),this.topology=e.topology,i&&(this.indices=ArrayBuffer.isView(i)?{value:i,size:1}:i),this.attributes={};for(let[s,o]of Object.entries(t)){let a=ArrayBuffer.isView(o)?{value:o}:o;if(!ArrayBuffer.isView(a.value))throw new Error(`${this._print(s)}: must be typed array or object with value as typed array`);if((s==="POSITION"||s==="positions")&&!a.size&&(a.size=3),s==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=a}else{let c=Kr(s),l=Object.keys(this.attributes).find(u=>Kr(u)===c);l&&delete this.attributes[l],this.attributes[s]=a}}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=r||this._calculateVertexCount(this.attributes,this.indices),this.bufferLayout=e.bufferLayout||PF(this.attributes)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,t){return this}_calculateVertexCount(e,t){if(t)return t.value.length;let i=1/0;for(let r of Object.values(e)){if(!r)continue;let{value:s,size:o,constant:a}=r;!a&&s&&o!==void 0&&o>=1&&(i=Math.min(i,s.length/o))}return i}}});function p1(n,e={}){let t=e.bufferName||"geometry";if(CF(n,t))return n;let i=e.minAttributeAlignment||4,r=TF(n,e.attributes),s=[],o=0,a=1/0;for(let[u,f]of r){if(!f)continue;if(f.constant)throw new Error(`Attribute ${u} is constant`);let{value:d,size:h,normalized:p}=f;if(!ArrayBuffer.isView(d))throw new Error(`Attribute ${u} is missing typed array data`);if(h===void 0)throw new Error(`Attribute ${u} is missing a size`);let m=Pe.getVertexFormatFromAttribute(d,h,p),g=Pe.getVertexFormatInfo(m);o=h1(o,i),s.push({sourceName:u,attributeName:Kr(u),value:d,size:h,format:m,byteOffset:o,byteLength:g.byteLength}),o+=g.byteLength;let v=d.length/h;if(!Number.isInteger(v))throw new Error(`Attribute ${u} length is not divisible by size`);a=Math.min(a,v)}if(s.length===0||!Number.isFinite(a))throw new Error(`Geometry ${n.id} has no interleavable attributes`);let c=h1(o,i),l=new ArrayBuffer(a*c);for(let u of s)LF(l,a,c,u);return new en({id:n.id,topology:n.topology||"triangle-list",vertexCount:n.vertexCount,indices:n.indices,attributes:{[t]:{value:new Uint8Array(l),size:c,byteStride:c}},bufferLayout:[{name:t,stepMode:"vertex",byteStride:c,attributes:s.map(u=>({attribute:u.attributeName,format:u.format,byteOffset:u.byteOffset}))}]})}function CF(n,e){if(n.bufferLayout.length!==1)return!1;let t=n.bufferLayout[0];return t.name===e&&!!t.attributes?.length&&!!n.attributes[e]}function TF(n,e){return e?e.map(t=>[t,n.attributes[t]]):Object.entries(n.attributes)}function LF(n,e,t,i){let r=i.value.constructor,s=r.BYTES_PER_ELEMENT;if(i.byteOffset%s!==0||t%s!==0)throw new Error(`Attribute ${i.sourceName} is not aligned to its component type`);let o=new r(n),a=i.value,c=i.byteOffset/s,l=t/s;for(let u=0;u{J();Rf()});var MF,AF,Qr,g1=C(()=>{MF=1,AF=1,Qr=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){let{delay:t=0,duration:i=Number.POSITIVE_INFINITY,rate:r=1,repeat:s=1}=e,o=MF++,a={time:0,delay:t,duration:i,rate:r,repeat:s};return this._setChannelTime(a,this.time),this.channels.set(o,a),o}removeChannel(e){this.channels.delete(e);for(let[t,i]of this.animations)i.channel===e&&this.detachAnimation(t)}isFinished(e){let t=this.channels.get(e);return t===void 0?!1:this.time>=t.delay+t.duration*t.repeat}getTime(e){if(e===void 0)return this.time;let t=this.channels.get(e);return t===void 0?-1:t.time}setTime(e){this.time=Math.max(0,e);let t=this.channels.values();for(let r of t)this._setChannelTime(r,this.time);let i=this.animations.values();for(let r of i){let{animation:s,channel:o}=r;s.setTime(this.getTime(o))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,t){let i=AF++;return this.animations.set(i,{animation:e,channel:t}),e.setTime(this.getTime(t)),i}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,t){let i=t-e.delay,r=e.duration*e.repeat;i>=r?e.time=e.duration*e.rate:(e.time=Math.max(0,i)%e.duration,e.time*=e.rate)}}});function _1(n){let e=typeof window<"u"?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame:null;return e?e.call(window,n):setTimeout(()=>n(typeof performance<"u"?performance.now():Date.now()),1e3/60)}function y1(n){let e=typeof window<"u"?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame:null;if(e){e.call(window,n);return}clearTimeout(n)}var b1=C(()=>{});var kF,RF,v1,gc,x1=C(()=>{J();b1();ua();kF=0,RF="Animation Loop",v1={requestAnimationFrame:n=>_1(n),cancelAnimationFrame:n=>y1(n)},gc=class n{static defaultAnimationLoopProps={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>{console.error(e)},stats:void 0,autoResizeViewport:!1,animationFrameProvider:v1};device=null;canvas=null;props;animationProps=null;timeline=null;stats;sharedStats;cpuTime;gpuTime;frameRate;display;_needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;_lastFrameTime=0;constructor(e){if(this.props={...n.defaultAnimationLoopProps,...e},e=this.props,!e.device)throw new Error("No device provided");this.stats=e.stats||new Ht({id:`animation-loop-${kF++}`}),this.sharedStats=Vs.stats.get(RF),this.frameRate=this.stats.get("Frame Rate"),this.frameRate.setSampleSize(1),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.setProps({autoResizeViewport:e.autoResizeViewport,animationFrameProvider:e.animationFrameProvider}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null),this.device?._disableDebugGPUTime()}delete(){this.destroy()}reportError(e){this._error=e,this.props.onError(e),this.props.onError===n.defaultAnimationLoopProps.onError&&typeof window<"u"&&typeof ErrorEvent<"u"&&window.dispatchEvent(new ErrorEvent("error",{error:e,message:e.message}))}setNeedsRedraw(e){return this._needsRedraw=this._needsRedraw||e,this}needsRedraw(){let e=this._needsRedraw;return this._needsRedraw=!1,e}setProps(e){if("autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),"animationFrameProvider"in e){let t=e.animationFrameProvider||v1;if(t!==this.props.animationFrameProvider){let i=this._animationFrameId!==null;i&&this._cancelAnimationFrame(),this.props.animationFrameProvider=t,i&&this._requestAnimationFrame()}}return this}async start(){if(this._running)return this;this._running=!0;try{let e;if(!this._initialized){if(this._initialized=!0,await this._initDevice(),this._initialize(),!this._running)return null;await this.props.onInitialize(this._getAnimationProps())}return this._running?(e!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){let t=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(t),t}}stop(){if(this._running){let e=this.animationProps;this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1,this._lastFrameTime=0,e&&this.props.onFinalize(e)}return this}redraw(e,t=null){return this.device?.isLost||this._error?this:(this._beginFrameTimers(e),this._setupFrame(),this.animationProps&&(this.animationProps.animationFrame=t),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeViewport(),this.device?._enableDebugGPUTime()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=this.props.animationFrameProvider.requestAnimationFrame(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(this.props.animationFrameProvider.cancelAnimationFrame(this._animationFrameId),this._animationFrameId=null)}_animationFrame(e,t){if(this._running)try{this.redraw(e,t??null),this._requestAnimationFrame()}catch(i){let r=i instanceof Error?i:new Error(String(i));this.reportError(r),this.stop()}}_renderFrame(e){if(this.display){this.display._renderFrame(e);return}let t=this.props.onRender(this._getAnimationProps());this.device&&t!==!1&&this.device.submit()}_clearNeedsRedraw(){this._needsRedraw=!1}_setupFrame(){this._resizeViewport()}_initializeAnimationProps(){let e=this.device?.getDefaultCanvasContext();if(!this.device||!e)throw new Error("loop");let t=e?.canvas,i=e.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:e,canvas:t,useDevicePixels:i,timeline:this.timeline,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,animationFrame:null,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:e,height:t,aspect:i}=this._getSizeAndAspect();(e!==this.animationProps.width||t!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),i!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=t,this.animationProps.aspect=i,this.animationProps.needsRedraw=this._needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.getDefaultCanvasContext().canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";let t=document.createElement("div");t.style.position="absolute",t.style.left="10px",t.style.bottom="10px",t.style.width="300px",t.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(t);let i=this.props.onAddHTML(t);i&&(t.innerHTML=i)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[e,t]=this.device.getDefaultCanvasContext().getDrawingBufferSize(),i=e>0&&t>0?e/t:1;return{width:e,height:t,aspect:i}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(e){let t=e??(typeof performance<"u"?performance.now():Date.now());if(this._lastFrameTime){let i=t-this._lastFrameTime;i>0&&this.frameRate.addTime(i)}this._lastFrameTime=t,this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeStart()}_endFrameTimers(){this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeEnd(),this._updateSharedStats()}_consumeEncodedGpuTime(){if(!this.device)return;let e=this.device.commandEncoder._gpuTimeMs;e!==void 0&&(this.gpuTime.addTime(e),this.device.commandEncoder._gpuTimeMs=void 0)}_updateSharedStats(){if(this.stats!==this.sharedStats){for(let e of Object.keys(this.sharedStats.stats))this.stats.stats[e]||delete this.sharedStats.stats[e];this.stats.forEach(e=>{let t=this.sharedStats.get(e.name,e.type);t.sampleSize=e.sampleSize,t.time=e.time,t.count=e.count,t.samples=e.samples,t.lastTiming=e.lastTiming,t.lastSampleTime=e.lastSampleTime,t.lastSampleCount=e.lastSampleCount,t._count=e._count,t._time=e._time,t._samples=e._samples,t._startTime=e._startTime,t._timerPending=e._timerPending})}}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}}});function w1(n,e){if(e instanceof If)return e;let t=p1(e),i=IF(n,t),{attributes:r,bufferLayout:s}=BF(n,t);return new If({topology:t.topology||"triangle-list",bufferLayout:s,vertexCount:t.vertexCount,indices:i,attributes:r})}function IF(n,e){if(!e.indices)return;let t=e.indices.value;return n.createBuffer({usage:ie.INDEX,data:t})}function BF(n,e){let t={};for(let[i,r]of Object.entries(e.attributes)){let s=e.bufferLayout.find(o=>o.name===i)?.name||Kr(i);r&&(t[s]=n.createBuffer({data:r.value,id:`${i}-buffer`}))}return{attributes:t,bufferLayout:e.bufferLayout,vertexCount:e.vertexCount}}var If,E1=C(()=>{J();Rf();m1();_o();If=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){if(this.id=e.id||Zn("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&!(this.indices.usage&ie.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){this.indices?.destroy();for(let e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(e){return e.byteLength/12}}});function S1(n,e){let t={},i="Values";if(n.attributes.length===0&&!n.varyings?.length)return{"No attributes or varyings":{[i]:"N/A"}};for(let r of n.attributes)if(r){let s=`${r.location} ${r.name}: ${r.type}`;t[`in ${s}`]={[i]:r.stepMode||"vertex"}}for(let r of n.varyings||[]){let s=`${r.location} ${r.name}`;t[`out ${s}`]={[i]:JSON.stringify(r)}}return t}var P1=C(()=>{});function L1(n,e,t){if(n.device.type!=="webgl")return;let i=NF(n.device);if(!i.flushing){if(zF(n)){OF(n,t,i);return}e&&FF(e)&&e.handle!==null&&(i.queuedFramebuffers.includes(e)||i.queuedFramebuffers.push(e))}}function OF(n,e,t){if(t.queuedFramebuffers.length===0)return;let i=n.device,{gl:r}=i,s=r.getParameter(36010),o=r.getParameter(36006),[a,c]=n.device.getDefaultCanvasContext().getDrawingBufferSize(),l=T1(e.top,8),u=T1(e.left,8);t.flushing=!0;try{for(let f of t.queuedFramebuffers){let[d,h,p,m,g]=DF({framebuffer:f,targetWidth:a,targetHeight:c,topPx:l,leftPx:u,minimap:e.minimap});r.bindFramebuffer(36008,f.handle),r.bindFramebuffer(36009,null),r.blitFramebuffer(0,0,f.width,f.height,d,h,p,m,16384,9728),l+=g+8}}finally{r.bindFramebuffer(36008,s),r.bindFramebuffer(36009,o),t.flushing=!1}}function DF(n){let{framebuffer:e,targetWidth:t,targetHeight:i,topPx:r,leftPx:s,minimap:o}=n,a=o?Math.max(Math.floor(t/4),1):t,c=o?Math.max(Math.floor(i/4),1):i,l=Math.min(a/e.width,c/e.height),u=Math.max(Math.floor(e.width*l),1),f=Math.max(Math.floor(e.height*l),1),d=s,h=Math.max(i-r-f,0),p=d+u,m=h+f;return[d,h,p,m,f]}function NF(n){return n.userData[C1]||={flushing:!1,queuedFramebuffers:[]},n.userData[C1]}function FF(n){return"colorAttachments"in n}function zF(n){let e=n.props.framebuffer;return!e||e.handle===null}function T1(n,e){if(!n)return e;let t=Number.parseInt(n,10);return Number.isFinite(t)?t:e}var C1,M1=C(()=>{C1="__debugFramebufferState"});function yo(n,e,t){if(n===e)return!0;if(!t||!n||!e)return!1;if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let i=0;i{});var bo,k1=C(()=>{J();bo=class{bufferLayouts;constructor(e){this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(t=>t.name===e)||null}getAttributeNamesForBuffer(e){return qs(e)}mergeBufferLayouts(e,t){let i=[...e];for(let r of t){let s=i.findIndex(o=>o.name===r.name);s<0?i.push(r):i[s]=r}return i}}});function R1(n,e){let t=Km(n),i=e.slice();return i.sort((r,s)=>{let o=Vu(qs(r).map(c=>t[c])),a=Vu(qs(s).map(c=>t[c]));return o-a}),i}var I1=C(()=>{J()});function vo(n,e){if(!n||!e.some(i=>i.bindingLayout?.length))return n;let t={...n,bindings:n.bindings.map(i=>({...i}))};"attributes"in(n||{})&&(t.attributes=n?.attributes||[]);for(let i of e)for(let r of i.bindingLayout||[])for(let s of UF(r.name)){let o=t.bindings.find(a=>a.name===s);o?.group===0&&(o.group=r.group),o&&r.visibility!==void 0&&(o.visibility=r.visibility)}return t}function B1(n,e,t=[]){return n?e?{...n,attributes:n.attributes.length?VF(n.attributes,e.attributes.filter(i=>t.includes(i.name))):e.attributes,bindings:GF(n.bindings,e.bindings)}:n:e}function _c(n){return!!(n.uniformTypes&&!$F(n.uniformTypes))}function O1(n){let e=[];for(let t of n){let i=Wa(t),r=new Set([t.vs,t.fs].flatMap(o=>o?ja(o).filter(a=>a.isStd140).map(a=>a.blockName):[])),s=r.has(i)?i:r.size===1?r.values().next().value:void 0;_c(t)&&s&&e.push({name:s,uniformTypes:t.uniformTypes})}return e}function Bf(n,e){let t=[],i=new Set;for(let r of[...n||[],...e||[]])i.has(r.name)||(i.add(r.name),t.push(r));return t}function UF(n){let e=new Set([n,`${n}Uniforms`]);return n.endsWith("Uniforms")||e.add(`${n}Sampler`),[...e]}function $F(n){for(let e in n)return!1;return!0}function GF(n,e){let t=n.map(s=>({...s})),i=new Set(n.map(s=>s.name)),r=new Set(n.map(s=>`${s.group}:${s.location}`));for(let s of e){let o=`${s.group}:${s.location}`;!i.has(s.name)&&!r.has(o)&&t.push({...s})}return t}function VF(n,e){let t=n.map(s=>({...s})),i=new Map(n.map(s=>[s.name,s])),r=new Map(n.map(s=>[s.location,s]));for(let s of e){let o=i.get(s.name);if(o){if(o.type!==s.type||o.location!==s.location)throw new Error(`Shader attribute "${s.name}" conflicts with its inferred type or location`);continue}let a=r.get(s.location);if(a)throw new Error(`Shader attributes "${a.name}" and "${s.name}" both use location ${s.location}`);t.push({...s})}return t}var L_=C(()=>{vt()});function WF(n){return _a(n)||typeof n=="number"||typeof n=="boolean"}function D1(n,e={}){let t={bindings:{},uniforms:{}};return Object.keys(n).forEach(i=>{let r=n[i];Object.prototype.hasOwnProperty.call(e,i)||WF(r)?t.uniforms[i]=r:t.bindings[i]=r}),t}var N1=C(()=>{Jp()});function F1(n={},e={},t={}){let i={...n};for(let[r,s]of Object.entries(e))s!==void 0&&(i[r]=M_(n[r],s,t[r]));return i}function M_(n,e,t){if(!t||typeof t=="string")return yc(e);if(Array.isArray(t)){if(A_(e)||!Array.isArray(e))return yc(e);let o=Array.isArray(n)&&!A_(n)?[...n]:[],a=o.slice();for(let c=0;ct===void 0?void 0:yc(t)):k_(n)?Object.fromEntries(Object.entries(n).map(([e,t])=>[e,t===void 0?void 0:yc(t)])):n}function A_(n){return ArrayBuffer.isView(n)||Array.isArray(n)&&(n.length===0||typeof n[0]=="number")}function k_(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&!ArrayBuffer.isView(n)}function jF(n){return!!n?.dependencies}var xo,R_=C(()=>{J();vt();N1();xo=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;directBindings={};constructor(e,t){Object.assign(this.options,t);let i=Cr(Object.values(e).filter(jF));for(let r of i)e[r.name]=r;N.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(let[r,s]of Object.entries(e))s&&(this._addModule(s),s.name&&r!==s.name&&!this.options.disableWarnings&&N.warn(`Module name: ${r} vs ${s.name}`)())}destroy(){}setProps(e){e.bindings&&Object.assign(this.directBindings,e.bindings);for(let t of Object.keys(e)){if(t==="bindings")continue;let i=t,r=e[i]||{},s=this.modules[i];if(!s)this.options.disableWarnings||N.warn(`Module ${t} not found`)();else{let o=this.moduleUniforms[i],a=this.moduleBindings[i],c=s.getUniforms?.(r,o)||r,{uniforms:l,bindings:u}=D1(c,s.uniformTypes);this.moduleUniforms[i]=F1(o,l,s.uniformTypes),this.moduleBindings[i]={...a,...u}}}}getModules(){return Object.values(this.modules)}addModules(e){let t=Cr(e);for(let i of t){let r=i.name;this.modules[r]||(this.modules[r]=i,this._addModule(i))}}getUniformValues(){return this.moduleUniforms}getBindingValues(){let e={};for(let t of Object.values(this.moduleBindings))Object.assign(e,t);return Object.assign(e,this.directBindings),e}getModuleBindingValues(e){let t=this.moduleBindings[e];return t?{...t}:{}}getDebugTable(){let e={};for(let[t,i]of Object.entries(this.moduleUniforms))for(let[r,s]of Object.entries(i))e[`${t}.${r}`]={type:this.modules[t].uniformTypes?.[r],value:String(s)};return e}_addModule(e){let t=e.name;this.moduleUniforms[t]=F1({},e.defaultUniforms||{},e.uniformTypes),this.moduleBindings[t]={}}}});function I_(n){return n!==null&&typeof n=="object"&&"buffer"in n}function YF(n){return n instanceof tt?n.buffer:n}function z1(n){return{buffer:YF(n.buffer),offset:n.offset,size:n.size}}var HF,tt,B_=C(()=>{J();_o();HF=ie.DEBUG_DATA_MAX_LENGTH,tt=class{device;id;ready;usage;props;isReady=!0;destroyed=!1;generation=0;updateTimestamp;debugData=new ArrayBuffer(0);_debugDataEnabled;_maxDebugDataByteLength;_ownsBuffer;_buffer;get buffer(){return this._buffer}get byteLength(){return this._buffer.byteLength}get[Symbol.toStringTag](){return"DynamicBuffer"}toString(){return`DynamicBuffer:"${this.id}":${this.byteLength}B`}toJSON(){return this.toString()}constructor(e,t){let{debugData:i=!1,buffer:r,ownsBuffer:s=!0,...o}=t;if(r&&r.device!==e)throw new Error("DynamicBuffer adopted buffers must belong to the supplied device");if(r&&(o.byteLength!==void 0||o.data!==void 0))throw new Error("DynamicBuffer cannot combine an adopted buffer with byteLength or data");let a=t.id||r?.id||Zn("dynamic-buffer"),c={...o,id:a,usage:o.usage??r?.usage,indexType:o.indexType??r?.indexType};(c.usage||0)&ie.INDEX&&!c.indexType&&(o.data instanceof Uint32Array?c.indexType="uint32":o.data instanceof Uint16Array?c.indexType="uint16":o.data instanceof Uint8Array&&(c.indexType="uint8")),delete c.data,delete c.byteOffset,this.device=e,this.id=a,this.props=c,this.usage=c.usage||0,this._debugDataEnabled=!!i,this._maxDebugDataByteLength=typeof i=="object"&&i.maxByteLength!==void 0?i.maxByteLength:HF,this._ownsBuffer=s,this._buffer=r??this.device.createBuffer({...o,id:a}),this.ready=Promise.resolve(this._buffer),this.updateTimestamp=this._buffer.updateTimestamp,this._resetDebugData(this._buffer.byteLength),o.data&&this._writeDebugData(o.data,o.byteOffset||0)}write(e,t=0){this._buffer.write(e,t),this._touch(),this._writeDebugData(e,t)}async mapAndWriteAsync(e,t=0,i=this.byteLength-t){let r=null;await this._buffer.mapAndWriteAsync(async(s,o)=>{await e(s,o),r=new Uint8Array(s.slice(0,i))},t,i),this._touch(),r&&this._writeDebugData(r,t)}async readAsync(e=0,t=this.byteLength-e){let i=await this._buffer.readAsync(e,t);return this._writeDebugData(i,e)&&this._touch(),i}async mapAndReadAsync(e,t=0,i=this.byteLength-t){let r=null,s=await this._buffer.mapAndReadAsync(async(o,a)=>(r=new Uint8Array(o.slice(0)),await e(o,a)),t,i);return r&&this._writeDebugData(r,t)&&this._touch(),s}resize(e){let{byteLength:t,preserveData:i=!1}=e;if(t===this.byteLength)return!1;let r=Math.min(e.copyByteLength??Math.min(this.byteLength,t),this.byteLength,t),s=this._buffer,o=this.debugData.slice(0),{data:a,byteOffset:c,...l}=this.props,u=this.device.createBuffer({...l,byteLength:t});return i&&r>0&&this._copyBufferContents(s,u,r),this._buffer=u,this._resetDebugData(t),i&&o.byteLength>0&&this._writeDebugData(o,0),this._ownsBuffer&&s.destroy(),this._ownsBuffer=!0,this.generation++,this._touch(),!0}ensureSize(e,t){return e<=this.byteLength?!1:this.resize({byteLength:e,preserveData:t?.preserveData})}getBinding(e){return e?.offset===void 0&&e?.size===void 0?this._buffer:{buffer:this._buffer,offset:e?.offset,size:e?.size}}destroy(){this.destroyed||(this._ownsBuffer&&this._buffer.destroy(),this.destroyed=!0,this.debugData=new ArrayBuffer(0))}_copyBufferContents(e,t,i){let r=this.device.type==="webgpu"?Math.ceil(i/4)*4:i,s=this.device.createCommandEncoder();s.copyBufferToBuffer({sourceBuffer:e,destinationBuffer:t,size:r}),this.device.submit(s.finish())}_touch(){this.updateTimestamp=this.device.incrementTimestamp()}_resetDebugData(e){if(!this._debugDataEnabled){this.debugData=new ArrayBuffer(0);return}this.debugData=new ArrayBuffer(Math.min(e,this._maxDebugDataByteLength))}_writeDebugData(e,t){if(!this._debugDataEnabled||this.debugData.byteLength===0||t>=this.debugData.byteLength)return!1;let i=ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),r=new Uint8Array(this.debugData),s=Math.min(i.byteLength,r.byteLength-t);return r.set(i.subarray(0,s),t),s>0}}});function bc(n){return n!==null&&typeof n=="object"&&"resolveTextureBinding"in n&&typeof n.resolveTextureBinding=="function"}function qF(n){return n?.type==="texture"||n?.type==="external-texture"}function U1(n,e,t){let i=Nu(n,e,{ignoreWarnings:!0});return qF(i)?i:n.bindings.length===0&&t?.fallbackGroup!==void 0?{type:"texture",name:e,group:t.fallbackGroup,location:0}:null}var $1=C(()=>{J()});function D_(n,e){return n.shaderLanguage!==void 0&&n.shaderLanguage!==e?!1:e==="glsl"?"assembleGLSLShaderPair"in n&&typeof n.assembleGLSLShaderPair=="function":"assembleWGSLShader"in n&&typeof n.assembleWGSLShader=="function"}function KF(n,e){return!n||Object.keys(e).length===0?n:{...n,attributes:n.attributes.map(t=>{let i=t.name.startsWith("_luma_")?t.name.slice(6):null;return i&&e[i]?{...t,name:i}:t})}}function QF(n,e,t){if(bc(e)){let i=U1(t,n,{fallbackGroup:0});return i?e.resolveTextureBinding(i):null}return e instanceof tt?e.buffer:I_(e)?z1(e):e}function JF(n){return n&&!G1(n)?n:null}function e6(n){return n&&G1(n)?n:void 0}function G1(n){return XF.includes(n)}function t6(n){return{type:n.type,shaderLanguage:n.info.shadingLanguage,shaderLanguageVersion:n.info.shadingLanguageVersion,gpu:n.info.gpu,limits:n.limits,features:n.features}}var Xn,ZF,O_,XF,Ze,N_=C(()=>{J();vt();E1();P1();M1();A1();k1();I1();L_();_o();R_();B_();$1();Xn=2,ZF=1e4,O_="render pipeline initialization failed",XF=["stencil8","depth16unorm","depth24plus","depth24plus-stencil8","depth32float","depth32float-stencil8"],Ze=class n{static defaultProps={...Zt.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],plugins:[],geometry:null,indexBuffer:null,indexCount:void 0,firstVertex:0,firstIndex:0,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,material:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:Xt.getDefaultShaderAssembler("glsl"),debugShaders:void 0,disableWarnings:void 0};device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexCount;firstVertex;firstIndex;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;material=null;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_dynamicIndexBufferSource=null;_dynamicAttributeBufferSources={};_colorAttachmentFormats;_depthStencilAttachmentFormat;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_drawBlockedReason=!1;_destroyed=!1;_vertexCountSet=!1;_lastDrawTimestamp=-1;_bindingTable=[];get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(e,t){let i=n.defaultProps.shaderAssembler,r=t.vertexCount!==void 0;this.props={...n.defaultProps,...t,shaderAssembler:t.shaderAssembler??(D_(i,e.info.shadingLanguage)?i:Xt.getDefaultShaderAssembler(e.info.shadingLanguage))},this._vertexCountSet=r,t=this.props,this.id=t.id||Zn("model"),this.device=e,Object.assign(this.userData,t.userData),this.material=t.material||null;let s=t6(e),o=Ga(this.props.plugins,s.shaderLanguage),a=Va(this.props.modules,o.modules),c=Object.fromEntries(a.map(h=>[h.name,h])),l=t.shaderInputs||new xo(c,{disableWarnings:this.props.disableWarnings});t.shaderInputs&&o.modules.length>0&&l.addModules(o.modules),this.setShaderInputs(l);let u=Bf(this.props.modules,l.getModules()),f={...o.defines,...this.props.defines};if(this.device.type==="webgl"&&(this.props._uniformBlockLayouts=O1(u)),this.props.shaderLayout=vo(this.props.shaderLayout,u)||null,this.device.type==="webgpu"&&this.props.source){let h=this.props.shaderAssembler;Vi(D_(h,"wgsl"));let{source:p,getUniforms:m,bindingTable:g,shaderLayout:v}=h.assembleWGSLShader({platformInfo:s,...this.props,modules:u,defines:f,pluginInjections:o.injections,pluginVertexInputs:o.vertexInputs,pluginVaryings:o.varyings});this.source=p,this._getModuleUniforms=m,this._bindingTable=g;let y=v??e.getShaderLayout?.(this.source),b=KF(y,o.vertexInputs),x=B1(this.props.shaderLayout,b,Object.keys(o.vertexInputs));this.props.shaderLayout=vo(x||null,u)||null}else{let h=this.props.shaderAssembler;Vi(D_(h,"glsl"));let{vs:p,fs:m,getUniforms:g}=h.assembleGLSLShaderPair({platformInfo:s,...this.props,modules:u,defines:f,pluginInjections:o.injections,pluginVertexInputs:o.vertexInputs,pluginVaryings:o.varyings});this.vs=p,this.fs=m,this._getModuleUniforms=g,this._bindingTable=[]}this.vertexCount=this.props.vertexCount,this.indexCount=this.props.indexCount,this.firstVertex=this.props.firstVertex,this.firstIndex=this.props.firstIndex,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,this._colorAttachmentFormats=this.props.colorAttachmentFormats,this._depthStencilAttachmentFormat=this.props.depthStencilAttachmentFormat,t.geometry&&this.setGeometry(t.geometry),this.pipelineFactory=t.pipelineFactory||Ir.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||Br.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in t&&(this.isInstanced=t.isInstanced),t.instanceCount&&this.setInstanceCount(t.instanceCount),t.vertexCount&&this.setVertexCount(t.vertexCount),t.indexBuffer&&this.setIndexBuffer(t.indexBuffer),t.attributes&&this.setAttributes(t.attributes),t.constantAttributes&&this.setConstantAttributes(t.constantAttributes),t.bindings&&this.setBindings(t.bindings),t.transformFeedback&&(this.transformFeedback=t.transformFeedback)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}getBindingDebugTable(){return this._bindingTable}predraw(e){this._syncDynamicBuffers(),this.updateShaderInputs(e),this.material?.updateShaderInputs(e),this.pipeline=this._updatePipeline()}draw(e){if(this._drawBlockedReason&&!this._pipelineNeedsUpdate)return N.info(Xn,`>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)(),!1;let t=this._areBindingsLoading();if(t)return N.info(Xn,`>>> DRAWING ABORTED ${this.id}: ${t} not loaded`)(),!1;this._syncAttachmentFormats(e);try{e.pushDebugGroup(`${this}.predraw(${e})`),this.device.type==="webgpu"?(this.updateShaderInputs(),this.material?.updateShaderInputs(),this._syncDynamicBuffers(),this.pipeline=this._updatePipeline()):this.predraw(this.device.commandEncoder)}finally{e.popDebugGroup()}let i,r=this.pipeline.isErrored;try{if(e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline(),r=this.pipeline.isErrored,r)N.info(Xn,`>>> DRAWING ABORTED ${this.id}: ${O_}`)(),i=!1;else{let s=this.vertexArray.getDrawValidationError();if(s)N.info(Xn,`>>> DRAWING ABORTED ${this.id}: ${s}`)(),this._drawBlockedReason=s,i=!1;else{let o=this._getCurrentShaderLayout(),a=this._getBindings(o),c=this._getBindGroups(o,a),{indexBuffer:l}=this.vertexArray,u=l?this.indexCount??(this._vertexCountSet?this.vertexCount:l.byteLength/(l.indexType==="uint32"?4:2)):void 0;e.setPipeline(this.pipeline),e.setBindings(c,{_bindGroupCacheKeys:this._getBindGroupCacheKeys()}),e.setVertexArray(this.vertexArray),i=this.isInstanced===!0&&this.instanceCount===0?!0:e.draw({isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.isInstanced?this.instanceCount:void 0,indexCount:u,firstVertex:this.firstVertex,firstIndex:this.firstIndex,transformFeedback:this.transformFeedback||void 0,uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}}}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),i?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):r?(this._needsRedraw=O_,this._drawBlockedReason=O_):this._drawBlockedReason?this._needsRedraw=this._drawBlockedReason:this._needsRedraw="waiting for resource initialization",i}setGeometry(e){this._gpuGeometry?.destroy();let t=e&&w1(this.device,e);if(t){this.setTopology(t.topology||"triangle-list");let i=new bo(this.bufferLayout);this.bufferLayout=i.mergeBufferLayouts(t.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(t)}this._gpuGeometry=t}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){let t=new bo(this.bufferLayout),i=this._gpuGeometry?t.mergeBufferLayouts(e,this._gpuGeometry.bufferLayout):e;yo(i,this.bufferLayout,-1)||(this.bufferLayout=i,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry))}setParameters(e){yo(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,this.isInstanced===void 0&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this._vertexCountSet=!0,this.setNeedsRedraw("vertexCount")}setIndexCount(e){this.indexCount=e,this.setNeedsRedraw("indexCount")}setDrawOffsets({firstVertex:e,firstIndex:t}){this.firstVertex=e,this.firstIndex=t,this.setNeedsRedraw("drawOffsets")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new Nr(this.device,this.shaderInputs.modules);for(let[t,i]of Object.entries(this.shaderInputs.modules))if(_c(i)&&!this.material?.ownsModule(t)){let r=this._uniformStore.getManagedUniformBuffer(t);this.bindings[`${t}Uniforms`]=r}this.setNeedsRedraw("shaderInputs")}setMaterial(e){this.material=e,this.setNeedsRedraw("material")}updateShaderInputs(e){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),e),this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues())),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){let t=e instanceof tt?e.buffer:e;this.indexBuffer=t,this._dynamicIndexBufferSource=e instanceof tt?{source:e,generation:e.generation}:null,this.vertexArray.setIndexBuffer(t),this.setNeedsRedraw("indexBuffer")}setAttributes(e,t){this._drawBlockedReason=!1;let i=t?.disableWarnings??this.props.disableWarnings;e.indices&&N.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=R1(this.pipeline.shaderLayout,this.bufferLayout);let r=new bo(this.bufferLayout);for(let[s,o]of Object.entries(e)){let a=o instanceof tt?o.buffer:o,c=r.getBufferLayout(s);if(!c){i||N.warn(`Model(${this.id}): Missing layout for buffer "${s}".`)();continue}let l=r.getAttributeNamesForBuffer(c),u=!1;for(let f of l){let d=this._attributeInfos[f];if(d){let h=this.device.type==="webgpu"?this.vertexArray.getBufferSlot(d.bufferName):d.location;if(h===null){i||N.warn(`Model(${this.id}): Missing vertex array slot for buffer "${d.bufferName}".`)();continue}this.vertexArray.setBuffer(h,a),o instanceof tt?this._dynamicAttributeBufferSources[h]={source:o,generation:o.generation}:delete this._dynamicAttributeBufferSources[h],u=!0}}!u&&!i&&N.warn(`Model(${this.id}): Ignoring buffer "${a.id}" for unknown attribute "${s}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,t){for(let[i,r]of Object.entries(e)){let s=this._attributeInfos[i];s?this.vertexArray.setConstantWebGL(s.location,r):(t?.disableWarnings??this.props.disableWarnings)||N.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(let e of Object.values(this.bindings))if(bc(e)&&!e.isReady)return e.id;for(let e of Object.values(this.material?.bindings||{}))if(bc(e)&&!e.isReady)return e.id;return!1}_getBindings(e=this._getCurrentShaderLayout()){let t={};for(let[i,r]of Object.entries(this.bindings)){let s=QF(i,r,e);s&&(t[i]=s)}return t}_getBindGroups(e=this._getCurrentShaderLayout(),t=this._getBindings(e)){let i=e.bindings.length?Or(e,t):{0:t};if(!this.material)return i;for(let[r,s]of Object.entries(this.material.getBindingsByGroup(e))){let o=Number(r);i[o]={...i[o]||{},...s}}return i}_getBindGroupCacheKeys(){let e=this.material?.getBindGroupCacheKey(3);return e?{3:e}:{}}_getBindingsUpdateTimestamp(){let e=0;this._dynamicIndexBufferSource&&(e=Math.max(e,this._dynamicIndexBufferSource.source.updateTimestamp));for(let t of Object.values(this._dynamicAttributeBufferSources))e=Math.max(e,t.source.updateTimestamp);for(let t of Object.values(this.bindings))t instanceof Ar?e=Math.max(e,t.texture.updateTimestamp):t instanceof ie||t instanceof me||t instanceof Aa||t instanceof tt?e=Math.max(e,t.updateTimestamp):bc(t)?e=t.isReady?Math.max(e,t.updateTimestamp):1/0:I_(t)&&(e=Math.max(e,(t.buffer instanceof tt,t.buffer.updateTimestamp)));return Math.max(e,this.material?.getBindingsUpdateTimestamp()||0)}_setGeometryAttributes(e){let t={...e.attributes};for(let[i]of Object.entries(t))!this.pipeline.shaderLayout.attributes.find(r=>r.name===i)&&i!=="positions"&&delete t[i];this.vertexCount=e.vertexCount,this._vertexCountSet=!0,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(t,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this._drawBlockedReason=!1,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,t=null;this.pipeline&&(N.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,t=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let i=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders}),r=null;this.source?r=i:this.fs&&(r=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bindings:void 0,bufferLayout:this.bufferLayout,colorAttachmentFormats:this._colorAttachmentFormats,depthStencilAttachmentFormat:this._depthStencilAttachmentFormat,topology:this.topology,parameters:this.parameters,bindGroups:void 0,vs:i,fs:r}),this._attributeInfos=$a(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&t!==e&&this.shaderFactory.release(t)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=N.level>3?0:ZF;N.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:N.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=S1(this.pipeline.shaderLayout,this.id);N.table(Xn,e)();let t=this.shaderInputs.getDebugTable();N.table(Xn,t)();let i=this._getAttributeDebugTable();N.table(Xn,this._attributeInfos)(),N.table(Xn,i)(),N.groupEnd(Xn)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){let t=this.device.props.debugFramebuffers;if(this._drawCount++,!t)return;let i=e.props.framebuffer;L1(e,i,{id:i?.id||`${this.id}-framebuffer`,minimap:!0})}_getAttributeDebugTable(){let e={};for(let[t,i]of Object.entries(this._attributeInfos)){let r=this.vertexArray.attributes[i.location];e[i.location]={name:t,type:i.shaderType,values:r?this._getBufferOrConstantValues(r,i.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:t}=this.vertexArray,i=t.indexType==="uint32"?new Uint32Array(t.debugData):new Uint16Array(t.debugData);e.indices={name:"indices",type:t.indexType,values:i.toString()}}return e}_getBufferOrConstantValues(e,t){let i=Xe.getTypedArrayConstructor(t);return(e instanceof ie?new i(e.debugData):e).toString()}_getNonMaterialBindings(e){if(!this.material)return e;let t={};for(let[i,r]of Object.entries(e))this.material.ownsBinding(i)||(t[i]=r);return t}_getCurrentShaderLayout(){return this.pipeline?.shaderLayout||this.props.shaderLayout||{bindings:[]}}_syncDynamicBuffers(){if(this._dynamicIndexBufferSource&&this._dynamicIndexBufferSource.generation!==this._dynamicIndexBufferSource.source.generation){let e=this._dynamicIndexBufferSource.source.buffer;this.indexBuffer=e,this.vertexArray.setIndexBuffer(e),this._dynamicIndexBufferSource.generation=this._dynamicIndexBufferSource.source.generation,this.setNeedsRedraw("dynamic index buffer")}for(let[e,t]of Object.entries(this._dynamicAttributeBufferSources))t.generation!==t.source.generation&&(this.vertexArray.setBuffer(Number(e),t.source.buffer),t.generation=t.source.generation,this.setNeedsRedraw("dynamic attribute buffer"))}_syncAttachmentFormats(e){if(this.device.type!=="webgpu")return;let t=e.framebuffer||e.props.framebuffer,i=e.props,r=i.colorAttachmentFormats??t?.colorAttachments?.map(o=>JF(o?.texture?.format)),s=i.depthStencilAttachmentFormat===!1?void 0:i.depthStencilAttachmentFormat??e6(t?.depthStencilAttachment?.texture?.format);(!yo(this._colorAttachmentFormats,r,1)||this._depthStencilAttachmentFormat!==s)&&(this._colorAttachmentFormats=r,this._depthStencilAttachmentFormat=s,this._setPipelineNeedsUpdate("attachment formats"))}}});var n6,i6,nt,V1=C(()=>{J();vt();N_();n6=35980,i6=35981,nt=class n{device;model;transformFeedback;static defaultProps={...Ze.defaultProps,feedbackBufferMode:"separate",outputs:void 0,feedbackBuffers:void 0};static isSupported(e){return e?.info?.type==="webgl"}constructor(e,t=n.defaultProps){if(!n.isSupported(e))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=e,this.model=new Ze(this.device,{id:t.id||"buffer-transform-model",fs:t.fs||hg(),topology:t.topology||"point-list",varyings:t.outputs||t.varyings,...t,bufferMode:t.bufferMode||(t.feedbackBufferMode==="interleaved"?n6:i6)}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:t.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){e?.inputBuffers&&this.model.setAttributes(e.inputBuffers),e?.outputBuffers&&this.transformFeedback.setBuffers(e.outputBuffers);let t=this.device.beginRenderPass({discard:!0,...e});this.model.draw(t),t.end()}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){let t=this.getBuffer(e);if(!t)throw new Error("BufferTransform#getBuffer");if(t instanceof ie)return t.readAsync();let{buffer:i,byteOffset:r=0,byteLength:s=i.byteLength}=t;return i.readAsync(r,s)}}});function s6(n){return{type:n.type,shaderLanguage:n.info.shadingLanguage,shaderLanguageVersion:n.info.shadingLanguageVersion,gpu:n.info.gpu,limits:n.limits,features:n.features}}var F_,r6,Bt,W1=C(()=>{J();vt();Jp();R_();L_();_o();F_=2,r6=1e4,Bt=class n{static defaultProps={...Hi.defaultProps,id:"unnamed",handle:void 0,userData:{},source:"",modules:[],defines:{},plugins:[],bindings:void 0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,shaderAssembler:Xt.getDefaultShaderAssembler("wgsl"),debugShaders:void 0};device;id;pipelineFactory;shaderFactory;userData={};bindings={};pipeline;source;shader;shaderInputs;_uniformStore;_pipelineNeedsUpdate="newly created";_getModuleUniforms;props;_destroyed=!1;constructor(e,t){if(e.type!=="webgpu")throw new Error("Computation is only supported in WebGPU");this.props={...n.defaultProps,...t},t=this.props,this.id=t.id||Zn("model"),this.device=e,Object.assign(this.userData,t.userData);let i=s6(e),r=Ga(this.props.plugins,i.shaderLanguage);if(Object.keys(r.vertexInputs).length>0||Object.keys(r.varyings).length>0)throw new Error("Computation does not support ShaderPlugin vertex inputs or varyings");let s=Va(this.props.modules,r.modules),o=Object.fromEntries(s.map(p=>[p.name,p]));this.shaderInputs=t.shaderInputs||new xo(o),t.shaderInputs&&r.modules.length>0&&this.shaderInputs.addModules(r.modules),this.setShaderInputs(this.shaderInputs);let a=Bf(this.props.modules,this.shaderInputs?.getModules()),c={...r.defines,...this.props.defines};this.props.shaderLayout=vo(this.props.shaderLayout,a)||null,this.pipelineFactory=t.pipelineFactory||Ir.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||Br.getDefaultShaderFactory(this.device);let l=this.props.shaderAssembler;Vi(l instanceof qi);let{source:u,getUniforms:f,shaderLayout:d}=l.assembleWGSLShader({platformInfo:i,...this.props,modules:a,defines:c,scanVertexAttributes:!1,pluginInjections:r.injections});this.source=u,this._getModuleUniforms=f;let h=d??e.getShaderLayout?.(this.source,{scanVertexAttributes:!1});this.props.shaderLayout=vo(this.props.shaderLayout||h||null,a)||null,this.pipeline=this._updatePipeline(),t.bindings&&this.setBindings(t.bindings)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.shader),this._uniformStore.destroy(),this._destroyed=!0)}predraw(e){this.updateShaderInputs(e)}dispatch(e,t,i,r){try{this._logDrawCallStart(),this._setPipeline(e),e.dispatch(t,i,r)}finally{this._logDrawCallEnd()}}dispatchIndirect(e,t,i=0){try{this._logDrawCallStart(),this._setPipeline(e),e.dispatchIndirect(t,i)}finally{this._logDrawCallEnd()}}_setPipeline(e){this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings),e.setPipeline(this.pipeline),e.setBindings({})}setVertexCount(e){}setInstanceCount(e){}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new Nr(this.device,this.shaderInputs.modules);for(let[t,i]of Object.entries(this.shaderInputs.modules))if(_c(i)){let r=this._uniformStore.getManagedUniformBuffer(t);this.bindings[`${t}Uniforms`]=r}}setShaderModuleProps(e){let t=this._getModuleUniforms(e),i=Object.keys(t).filter(s=>{let o=t[s];return!_a(o)&&typeof o!="number"&&typeof o!="boolean"}),r={};for(let s of i)r[s]=t[s],delete t[s]}updateShaderInputs(e){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),e)}setBindings(e){Object.assign(this.bindings,e)}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate=this._pipelineNeedsUpdate||e}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null;this.pipeline&&(N.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.shader),this._pipelineNeedsUpdate=!1,this.shader=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"compute",source:this.source,debugShaders:this.props.debugShaders}),this.pipeline=this.pipelineFactory.createComputePipeline({...this.props,shader:this.shader}),e&&this.shaderFactory.release(e)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=N.level>3?0:r6;N.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:N.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=this.shaderInputs.getDebugTable();N.table(F_,e)(),N.groupEnd(F_)(),this._logOpen=!1}}_drawCount=0;_getBufferOrConstantValues(e,t){let i=Xe.getTypedArrayConstructor(t);return(e instanceof ie?new i(e.debugData):e).toString()}}});var Me=C(()=>{g1();x1();N_();V1();Rf();B_();W1()});function s2(n=!0){let e=HTMLCanvasElement.prototype;if(!n&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(t,i){if(t==="webgl"||t==="experimental-webgl"){let r=this.originalGetContext("webgl2",i);return r instanceof HTMLElement&&D6(r),r}return this.originalGetContext(t,i)}}function D6(n){n.getExtension("EXT_color_buffer_float");let e={...R6,WEBGL_disjoint_timer_query:n.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:I6(n),OES_vertex_array_object:B6(n),ANGLE_instanced_arrays:O6(n)},t=n.getExtension.bind(n);n.getExtension=function(r){let s=t(r);return s||(r in e?e[r]:null)};let i=n.getSupportedExtensions;n.getSupportedExtensions=function(){return(i.apply(n)||[])?.concat(Object.keys(e))}}var R6,I6,B6,O6,o2=C(()=>{R6={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},I6=n=>({drawBuffersWEBGL(e){return n.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),B6=n=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return n.createVertexArray()},deleteVertexArrayOES(e){return n.deleteVertexArray(e)},isVertexArrayOES(e){return n.isVertexArray(e)},bindVertexArrayOES(e){return n.bindVertexArray(e)}}),O6=n=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return n.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return n.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return n.vertexAttribDivisor(...e)}})});async function c2(){if(!Gf){Z_();return}await Gf.load()}function l2(n,e){return Gf?Gf.makeDebugContext(n,e):(Z_(),n)}async function u2(n){if(!q_){Z_();return}await q_.load(n)}function f2(n){return q_?.initialize(n)||null}function Z_(){a2||(a2=!0,N.warn("Import @luma.gl/webgl/debug before enabling WebGL debugging.")())}var Gf,q_,a2,X_=C(()=>{J();Gf=null,q_=null,a2=!1});function K_(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Ie(n,e,t){return e[n]!==void 0?e[n]:t[n]}var Oc,$e,d2,Ot,h2,Bc,p2,m2,Q_,ei,J_,g2,ey=C(()=>{Oc={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},$e=(n,e,t)=>e?n.enable(t):n.disable(t),d2=(n,e,t)=>n.hint(t,e),Ot=(n,e,t)=>n.pixelStorei(t,e),h2=(n,e,t)=>{let i=t===36006?36009:36008;return n.bindFramebuffer(i,e)},Bc=(n,e,t)=>{let r={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[t];n.bindBuffer(r,e)};p2={3042:$e,32773:(n,e)=>n.blendColor(...e),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(n,e)=>n.clearColor(...e),3107:(n,e)=>n.colorMask(...e),2884:$e,2885:(n,e)=>n.cullFace(e),2929:$e,2931:(n,e)=>n.clearDepth(e),2932:(n,e)=>n.depthFunc(e),2928:(n,e)=>n.depthRange(...e),2930:(n,e)=>n.depthMask(e),3024:$e,35723:d2,35725:(n,e)=>n.useProgram(e),36007:(n,e)=>n.bindRenderbuffer(36161,e),36389:(n,e)=>n.bindTransformFeedback?.(36386,e),34229:(n,e)=>n.bindVertexArray(e),36006:h2,36010:h2,34964:Bc,36662:Bc,36663:Bc,35053:Bc,35055:Bc,2886:(n,e)=>n.frontFace(e),33170:d2,2849:(n,e)=>n.lineWidth(e),32823:$e,32824:"polygonOffset",10752:"polygonOffset",35977:$e,32926:$e,32928:$e,32938:"sampleCoverage",32939:"sampleCoverage",3089:$e,3088:(n,e)=>n.scissor(...e),2960:$e,2961:(n,e)=>n.clearStencil(e),2968:(n,e)=>n.stencilMaskSeparate(1028,e),36005:(n,e)=>n.stencilMaskSeparate(1029,e),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(n,e)=>n.viewport(...e),34383:$e,10754:$e,12288:$e,12289:$e,12290:$e,12291:$e,12292:$e,12293:$e,12294:$e,12295:$e,3333:Ot,3317:Ot,37440:Ot,37441:Ot,37443:Ot,3330:Ot,3332:Ot,3331:Ot,3314:Ot,32878:Ot,3316:Ot,3315:Ot,32877:Ot,framebuffer:(n,e)=>{let t=e&&"handle"in e?e.handle:e;return n.bindFramebuffer(36160,t)},blend:(n,e)=>e?n.enable(3042):n.disable(3042),blendColor:(n,e)=>n.blendColor(...e),blendEquation:(n,e)=>{let t=typeof e=="number"?[e,e]:e;n.blendEquationSeparate(...t)},blendFunc:(n,e)=>{let t=e?.length===2?[...e,...e]:e;n.blendFuncSeparate(...t)},clearColor:(n,e)=>n.clearColor(...e),clearDepth:(n,e)=>n.clearDepth(e),clearStencil:(n,e)=>n.clearStencil(e),colorMask:(n,e)=>n.colorMask(...e),cull:(n,e)=>e?n.enable(2884):n.disable(2884),cullFace:(n,e)=>n.cullFace(e),depthTest:(n,e)=>e?n.enable(2929):n.disable(2929),depthFunc:(n,e)=>n.depthFunc(e),depthMask:(n,e)=>n.depthMask(e),depthRange:(n,e)=>n.depthRange(...e),dither:(n,e)=>e?n.enable(3024):n.disable(3024),derivativeHint:(n,e)=>{n.hint(35723,e)},frontFace:(n,e)=>n.frontFace(e),mipmapHint:(n,e)=>n.hint(33170,e),lineWidth:(n,e)=>n.lineWidth(e),polygonOffsetFill:(n,e)=>e?n.enable(32823):n.disable(32823),polygonOffset:(n,e)=>n.polygonOffset(...e),sampleCoverage:(n,e)=>n.sampleCoverage(e[0],e[1]||!1),scissorTest:(n,e)=>e?n.enable(3089):n.disable(3089),scissor:(n,e)=>n.scissor(...e),stencilTest:(n,e)=>e?n.enable(2960):n.disable(2960),stencilMask:(n,e)=>{e=K_(e)?e:[e,e];let[t,i]=e;n.stencilMaskSeparate(1028,t),n.stencilMaskSeparate(1029,i)},stencilFunc:(n,e)=>{e=K_(e)&&e.length===3?[...e,...e]:e;let[t,i,r,s,o,a]=e;n.stencilFuncSeparate(1028,t,i,r),n.stencilFuncSeparate(1029,s,o,a)},stencilOp:(n,e)=>{e=K_(e)&&e.length===3?[...e,...e]:e;let[t,i,r,s,o,a]=e;n.stencilOpSeparate(1028,t,i,r),n.stencilOpSeparate(1029,s,o,a)},viewport:(n,e)=>n.viewport(...e)};m2={blendEquation:(n,e,t)=>n.blendEquationSeparate(Ie(32777,e,t),Ie(34877,e,t)),blendFunc:(n,e,t)=>n.blendFuncSeparate(Ie(32969,e,t),Ie(32968,e,t),Ie(32971,e,t),Ie(32970,e,t)),polygonOffset:(n,e,t)=>n.polygonOffset(Ie(32824,e,t),Ie(10752,e,t)),sampleCoverage:(n,e,t)=>n.sampleCoverage(Ie(32938,e,t),Ie(32939,e,t)),stencilFuncFront:(n,e,t)=>n.stencilFuncSeparate(1028,Ie(2962,e,t),Ie(2967,e,t),Ie(2963,e,t)),stencilFuncBack:(n,e,t)=>n.stencilFuncSeparate(1029,Ie(34816,e,t),Ie(36003,e,t),Ie(36004,e,t)),stencilOpFront:(n,e,t)=>n.stencilOpSeparate(1028,Ie(2964,e,t),Ie(2965,e,t),Ie(2966,e,t)),stencilOpBack:(n,e,t)=>n.stencilOpSeparate(1029,Ie(34817,e,t),Ie(34818,e,t),Ie(34819,e,t))},Q_={enable:(n,e)=>n({[e]:!0}),disable:(n,e)=>n({[e]:!1}),pixelStorei:(n,e,t)=>n({[e]:t}),hint:(n,e,t)=>n({[e]:t}),useProgram:(n,e)=>n({35725:e}),bindRenderbuffer:(n,e,t)=>n({36007:t}),bindTransformFeedback:(n,e,t)=>n({36389:t}),bindVertexArray:(n,e)=>n({34229:e}),bindFramebuffer:(n,e,t)=>{switch(e){case 36160:return n({36006:t,36010:t});case 36009:return n({36006:t});case 36008:return n({36010:t});default:return null}},bindBuffer:(n,e,t)=>{let i={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[e];return i?n({[i]:t}):{valueChanged:!0}},blendColor:(n,e,t,i,r)=>n({32773:new Float32Array([e,t,i,r])}),blendEquation:(n,e)=>n({32777:e,34877:e}),blendEquationSeparate:(n,e,t)=>n({32777:e,34877:t}),blendFunc:(n,e,t)=>n({32969:e,32968:t,32971:e,32970:t}),blendFuncSeparate:(n,e,t,i,r)=>n({32969:e,32968:t,32971:i,32970:r}),clearColor:(n,e,t,i,r)=>n({3106:new Float32Array([e,t,i,r])}),clearDepth:(n,e)=>n({2931:e}),clearStencil:(n,e)=>n({2961:e}),colorMask:(n,e,t,i,r)=>n({3107:[e,t,i,r]}),cullFace:(n,e)=>n({2885:e}),depthFunc:(n,e)=>n({2932:e}),depthRange:(n,e,t)=>n({2928:new Float32Array([e,t])}),depthMask:(n,e)=>n({2930:e}),frontFace:(n,e)=>n({2886:e}),lineWidth:(n,e)=>n({2849:e}),polygonOffset:(n,e,t)=>n({32824:e,10752:t}),sampleCoverage:(n,e,t)=>n({32938:e,32939:t}),scissor:(n,e,t,i,r)=>n({3088:new Int32Array([e,t,i,r])}),stencilMask:(n,e)=>n({2968:e,36005:e}),stencilMaskSeparate:(n,e,t)=>n({[e===1028?2968:36005]:t}),stencilFunc:(n,e,t,i)=>n({2962:e,2967:t,2963:i,34816:e,36003:t,36004:i}),stencilFuncSeparate:(n,e,t,i,r)=>n({[e===1028?2962:34816]:t,[e===1028?2967:36003]:i,[e===1028?2963:36004]:r}),stencilOp:(n,e,t,i)=>n({2964:e,2965:t,2966:i,34817:e,34818:t,34819:i}),stencilOpSeparate:(n,e,t,i,r)=>n({[e===1028?2964:34817]:t,[e===1028?2965:34818]:i,[e===1028?2966:34819]:r}),viewport:(n,e,t,i,r)=>n({2978:[e,t,i,r]})},ei=(n,e)=>n.isEnabled(e),J_={3042:ei,2884:ei,2929:ei,3024:ei,32823:ei,32926:ei,32928:ei,3089:ei,2960:ei,35977:ei},g2=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068])});function bn(n,e){if(N6(e))return;let t={};for(let r in e){let s=Number(r),o=p2[r];o&&(typeof o=="string"?t[o]=!0:o(n,e[r],s))}let i=n.lumaState?.cache;if(i)for(let r in t){let s=m2[r];s(n,e,i)}}function Vf(n,e=Oc){if(typeof e=="number"){let r=e,s=J_[r];return s?s(n,r):n.getParameter(r)}let t=Array.isArray(e)?e:Object.keys(e),i={};for(let r of t){let s=J_[r];i[r]=s?s(n,Number(r)):n.getParameter(Number(r))}return i}function _2(n){bn(n,Oc)}function N6(n){for(let e in n)return!1;return!0}var Po=C(()=>{ey()});function b2(n,e){if(n===e)return!0;if(y2(n)&&y2(e)&&n.length===e.length){for(let t=0;t{});function x2(n,e){let t=n[e].bind(n);n[e]=function(r){if(r===void 0||g2.has(r))return t(r);let s=vn.get(n);return r in s.cache||(s.cache[r]=t(r)),s.enable?s.cache[r]:t(r)},Object.defineProperty(n[e],"name",{value:`${e}-from-cache`,configurable:!1})}function F6(n,e,t){if(!n[e])return;let i=n[e].bind(n);n[e]=function(...s){let o=vn.get(n),{valueChanged:a,oldValue:c}=t(o._updateCache,...s);return a&&i(...s),c},Object.defineProperty(n[e],"name",{value:`${e}-to-cache`,configurable:!1})}function z6(n){let e=n.useProgram.bind(n);n.useProgram=function(i){let r=vn.get(n);r.program!==i&&(e(i),r.program=i)}}var vn,ty=C(()=>{Po();v2();ey();vn=class{static get(e){return e.lumaState}gl;program=null;stateStack=[];enable=!0;cache=null;log;initialized=!1;constructor(e,t){this.gl=e,this.log=t?.log||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){let e=this.stateStack[this.stateStack.length-1];bn(this.gl,e),this.stateStack.pop()}trackState(e,t){if(this.cache=t?.copyState?Vf(e):Object.assign({},Oc),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.lumaState=this,z6(e);for(let i in Q_){let r=Q_[i];F6(e,i,r)}x2(e,"getParameter"),x2(e,"isEnabled")}_updateCache(e){let t=!1,i,r=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let s in e){let o=e[s],a=this.cache[s];b2(o,a)||(t=!0,i=a,r&&!(s in r)&&(r[s]=a),this.cache[s]=o)}return{valueChanged:t,oldValue:i}}}});function Dc(n){let e=n.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return e._polyfilled??=!1,e.extensions||={},n.luma=e,e}var ny=C(()=>{});function w2(n,e,t){let i="",r=c=>{let l=c.statusMessage;l&&(i||=l)};n.addEventListener("webglcontextcreationerror",r,!1);let s=t.failIfMajorPerformanceCaveat!==!0,o={preserveDrawingBuffer:!0,...t,failIfMajorPerformanceCaveat:!0},a=null;try{a||=n.getContext("webgl2",o),!a&&o.failIfMajorPerformanceCaveat&&(i||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.");let c=!1;if(!a&&s&&(o.failIfMajorPerformanceCaveat=!1,a=n.getContext("webgl2",o),c=!0),a||(a=n.getContext("webgl",{}),a&&(a=null,i||="Your browser only supports WebGL1")),!a)throw i||="Your browser does not support WebGL",new Error(`Failed to create WebGL context: ${i}`);let l=Dc(a);l.softwareRenderer=c;let{onContextLost:u,onContextRestored:f}=e;return n.addEventListener("webglcontextlost",d=>u(d),!1),n.addEventListener("webglcontextrestored",d=>f(d),!1),a}finally{n.removeEventListener("webglcontextcreationerror",r,!1)}}var E2=C(()=>{ny()});function xn(n,e,t){return t[e]===void 0&&(t[e]=n.getExtension(e)||null),t[e]}var Nc=C(()=>{});function S2(n,e){let t=n.getParameter(7936),i=n.getParameter(7937);xn(n,"WEBGL_debug_renderer_info",e);let r=e.WEBGL_debug_renderer_info,s=n.getParameter(r?r.UNMASKED_VENDOR_WEBGL:7936),o=n.getParameter(r?r.UNMASKED_RENDERER_WEBGL:7937),a=s||t,c=o||i,l=n.getParameter(7938),u=P2(a,c),f=U6(a,c),d=$6(a,c);return{type:"webgl",gpu:u,gpuType:d,gpuBackend:f,vendor:a,renderer:c,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function P2(n,e){return/NVIDIA/i.exec(n)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(n)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(n)||/Apple/i.exec(e)?"apple":/AMD/i.exec(n)||/AMD/i.exec(e)||/ATI/i.exec(n)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(n)||/SwiftShader/i.exec(e)?"software":"unknown"}function U6(n,e){return/Metal/i.exec(n)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(n)||/ANGLE/i.exec(e)?"opengl":"unknown"}function $6(n,e){if(/SwiftShader/i.exec(n)||/SwiftShader/i.exec(e))return"cpu";switch(P2(n,e)){case"apple":return G6(n,e)?"integrated":"unknown";case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function G6(n,e){return/Apple (M\d|A\d|GPU)/i.test(`${n} ${e}`)}var C2=C(()=>{Nc()});function Wf(n){switch(n){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(n))}var iy=C(()=>{});function M2(n){return n in Hf}function cy(n,e,t){return A2(n,e,t,new Set)}function A2(n,e,t,i){let r=Hf[e];if(!r||i.has(e))return!1;i.add(e);let s=(r.features||[]).every(o=>A2(n,o,t,i));return i.delete(e),s?(r.extensions||[]).every(o=>!!xn(n,o,t)):!1}function k2(n,e,t){let i=e.create,r=Yf[e.format];r?.gl===void 0&&(i=!1),r?.x&&(i=i&&!!xn(n,r.x,t)),e.format==="stencil8"&&(i=!1);let s=r?.r===!1?!1:r?.r===void 0||cy(n,r.r,t),o=i&&e.render&&s&&X6(n,e.format,t);return{format:e.format,create:i&&e.create,render:o,filter:i&&e.filter,blend:i&&e.blend,store:i&&e.store}}function X6(n,e,t){let i=Yf[e],r=i?.gl;if(r===void 0||i?.x&&!xn(n,i.x,t))return!1;let s=n.getParameter(32873),o=n.getParameter(36006),a=n.createTexture(),c=n.createFramebuffer();if(!a||!c)return!1;let l=0,u=Number(n.getError());for(;u!==l;)u=n.getError();let f=!1;try{if(n.bindTexture(3553,a),n.texStorage2D(3553,1,r,1,1),Number(n.getError())!==l)return!1;n.bindFramebuffer(36160,c),n.framebufferTexture2D(36160,36064,3553,a,0),f=Number(n.checkFramebufferStatus(36160))===36053&&Number(n.getError())===l}finally{n.bindFramebuffer(36160,o),n.deleteFramebuffer(c),n.bindTexture(3553,s),n.deleteTexture(a)}return f}function qf(n){let e=Yf[n],t=Q6(n),i=ft.getInfo(n);return i.compressed&&(e.dataFormat=t),{internalFormat:t,format:e?.dataFormat||K6(i.channels,i.integer,i.normalized,t),type:i.dataType?Wf(i.dataType):e?.types?.[0]||5121,compressed:i.compressed||!1}}function R2(n){switch(ft.getInfo(n).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${n}`)}}function K6(n,e,t,i){if(i===6408||i===6407)return i;switch(n){case"r":return e&&!t?36244:6403;case"rg":return e&&!t?33320:33319;case"rgb":return e&&!t?36248:6407;case"rgba":return e&&!t?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function Q6(n){let t=Yf[n]?.gl;if(t===void 0)throw new Error(`Unsupported texture format ${n}`);return t}var Fc,zc,Co,To,V6,W6,j6,H6,Y6,q6,T2,L2,ry,sy,oy,ay,jf,Z6,Hf,Yf,Lo=C(()=>{J();Nc();iy();Fc="WEBGL_compressed_texture_s3tc",zc="WEBGL_compressed_texture_s3tc_srgb",Co="EXT_texture_compression_rgtc",To="EXT_texture_compression_bptc",V6="WEBGL_compressed_texture_etc",W6="WEBGL_compressed_texture_astc",j6="WEBGL_compressed_texture_etc1",H6="WEBGL_compressed_texture_pvrtc",Y6="WEBGL_compressed_texture_atc",q6="EXT_texture_norm16",T2="EXT_render_snorm",L2="EXT_color_buffer_float",ry="snorm8-renderable-webgl",sy="norm16-renderable-webgl",oy="snorm16-renderable-webgl",ay="float16-renderable-webgl",jf="float32-renderable-webgl",Z6="rgb9e5ufloat-renderable-webgl",Hf={"float32-renderable-webgl":{extensions:[L2]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[T2]},"norm16-webgl":{extensions:[q6]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[T2]},"float32-filterable":{extensions:["OES_texture_float_linear"]},"float16-filterable-webgl":{extensions:["OES_texture_half_float_linear"]},"texture-filterable-anisotropic-webgl":{extensions:["EXT_texture_filter_anisotropic"]},"texture-blend-float-webgl":{extensions:["EXT_float_blend"]},"texture-compression-bc":{extensions:[Fc,zc,Co,To]},"texture-compression-bc5-webgl":{extensions:[Co]},"texture-compression-bc7-webgl":{extensions:[To]},"texture-compression-etc2":{extensions:[V6]},"texture-compression-astc":{extensions:[W6]},"texture-compression-etc1-webgl":{extensions:[j6]},"texture-compression-pvrtc-webgl":{extensions:[H6]},"texture-compression-atc-webgl":{extensions:[Y6]}};Yf={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:ry},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:ry},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0,r:ay},r16unorm:{gl:33322,rb:!0,r:sy},r16snorm:{gl:36760,r:oy},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759,r:ry},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:ay},rg16unorm:{gl:33324,r:sy},rg16snorm:{gl:36761,r:oy},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:jf},rgb9e5ufloat:{gl:35901,r:Z6},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852,r:!1},"rgb16snorm-webgl":{gl:36762,r:!1},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0,r:jf},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:ay},rgba16unorm:{gl:32859,rb:!0,r:sy},rgba16snorm:{gl:36763,r:oy},"rgb32float-webgl":{gl:34837,x:L2,r:jf,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:jf},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:Fc},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:zc},"bc1-rgba-unorm":{gl:33777,x:Fc},"bc1-rgba-unorm-srgb":{gl:35916,x:zc},"bc2-rgba-unorm":{gl:33778,x:Fc},"bc2-rgba-unorm-srgb":{gl:35918,x:zc},"bc3-rgba-unorm":{gl:33779,x:Fc},"bc3-rgba-unorm-srgb":{gl:35919,x:zc},"bc4-r-unorm":{gl:36283,x:Co},"bc4-r-snorm":{gl:36284,x:Co},"bc5-rg-unorm":{gl:36285,x:Co},"bc5-rg-snorm":{gl:36286,x:Co},"bc6h-rgb-ufloat":{gl:36495,x:To},"bc6h-rgb-float":{gl:36494,x:To},"bc7-rgba-unorm":{gl:36492,x:To},"bc7-rgba-unorm-srgb":{gl:36493,x:To},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37816},"astc-10x5-unorm-srgb":{gl:37848},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rgb2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}}});var I2,Zf,B2=C(()=>{J();Nc();Lo();I2={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","html-in-canvas":n=>Om()&&typeof n.texElementImage2D=="function","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},Zf=class extends Ta{gl;extensions;testedFeatures=new Set;constructor(e,t,i){super([],i),this.gl=e,this.extensions=t,xn(e,"EXT_color_buffer_float",t)}*[Symbol.iterator](){let e=this.getFeatures();for(let t of e)this.has(t)&&(yield t);return[]}has(e){return this.disabledFeatures?.[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),M2(e)&&cy(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){let e=this.getFeatures().filter(t=>t!=="polygon-mode-webgl");for(let t of e)this.has(t)}getFeatures(){return[...Object.keys(I2),...Object.keys(Hf)]}getWebGLFeature(e){let t=I2[e];return typeof t=="string"?!!xn(this.gl,t,this.extensions):typeof t=="function"?t(this.gl):!!t}}});var Xf,O2=C(()=>{J();Xf=class extends Ca{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxBindGroupsPlusVertexBuffers(){return 0}get maxBindingsPerBindGroup(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageBuffersInVertexStage(){return 0}get maxStorageBuffersInFragmentStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxStorageTexturesInVertexStage(){return 0}get maxStorageTexturesInFragmentStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get maxBufferSize(){return Number.MAX_SAFE_INTEGER}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxColorAttachments(){return this.getParameter(36063)}get maxColorAttachmentBytesPerSample(){return 0}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]||0}}});function J6(n){return n<34069?n+34069:n}function ez(n){switch(n){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${n}`}}var ti,Kf=C(()=>{J();Lo();ti=class extends Rr{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(e,t){super(e,t);let i=t.handle,r=i===null;this.device=e,this.gl=e.gl,this.handle=i||r?i:this.gl.createFramebuffer(),r||(e._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),t.handle||(this.autoCreateAttachmentTextures(),this.updateAttachments()))}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&!this.props.handle&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){let e=this.gl.bindFramebuffer(36160,this.handle);for(let t=0;t{J();Kf();Qf=class extends La{device;handle=null;_framebuffer=null;get[Symbol.toStringTag](){return"WebGLCanvasContext"}constructor(e,t){super(t),this.device=e,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._configureDevice()}_configureDevice(){(this.drawingBufferWidth!==this._framebuffer?.width||this.drawingBufferHeight!==this._framebuffer?.height)&&this._framebuffer?.resize([this.drawingBufferWidth,this.drawingBufferHeight])}_getCurrentFramebuffer(){return this._framebuffer||=new ti(this.device,{id:"canvas-context-framebuffer",handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}}});var Jf,N2=C(()=>{J();Jf=class extends Ma{device;handle=null;context2d;get[Symbol.toStringTag](){return"WebGLPresentationContext"}constructor(e,t={}){super(t),this.device=e;let i=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw new Error(`${i}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);let s=this.canvas.getContext("2d");if(!s)throw new Error(`${i}: Failed to create 2d presentation context`);this.context2d=s,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();let e=this.device.getDefaultCanvasContext(),[t,i]=e.getDrawingBufferSize();if(!(this.drawingBufferWidth===0||this.drawingBufferHeight===0||t===0||i===0||e.canvas.width===0||e.canvas.height===0)){if(t!==this.drawingBufferWidth||i!==this.drawingBufferHeight||e.canvas.width!==this.drawingBufferWidth||e.canvas.height!==this.drawingBufferHeight)throw new Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${t}x${i} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(e.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(e){let t=this.device.getDefaultCanvasContext();return t.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),t.getCurrentFramebuffer(e)}}});function F2(n="id"){ly[n]=ly[n]||1;let e=ly[n]++;return`${n}-${e}`}var ly,z2=C(()=>{ly={}});function tz(n){return n&ie.INDEX?34963:n&ie.VERTEX?34962:n&ie.UNIFORM?35345:34962}function nz(n){return n&ie.INDEX||n&ie.VERTEX?35044:n&ie.UNIFORM?35048:35044}var wn,ed=C(()=>{J();wn=class extends ie{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength=0;bytesUsed=0;constructor(e,t={}){super(e,t),this.device=e,this.gl=this.device.gl;let i=typeof t=="object"?t.handle:void 0;this.handle=i||this.gl.createBuffer(),e._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=tz(this.props.usage),this.glUsage=nz(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,t.data?this._initWithData(t.data,t.byteOffset,t.byteLength):this._initWithByteLength(t.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Buffer"):(this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle)),this.destroyed=!0,this.handle=null)}_initWithData(e,t=0,i=e.byteLength+t){let r=this.glTarget;this.gl.bindBuffer(r,this.handle),this.gl.bufferData(r,i,this.glUsage),this.gl.bufferSubData(r,t,e),this.gl.bindBuffer(r,null),this.bytesUsed=i,this.byteLength=i,this._setDebugData(e,t,i),this.props.handle?this.trackReferencedMemory(i,"Buffer"):this.trackAllocatedMemory(i)}_initWithByteLength(e){let t=e;e===0&&(t=new Float32Array(0));let i=this.glTarget;return this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,t,this.glUsage),this.gl.bindBuffer(i,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.props.handle?this.trackReferencedMemory(e,"Buffer"):this.trackAllocatedMemory(e),this}write(e,t=0){let i=ArrayBuffer.isView(e)?e:new Uint8Array(e),r=0,s=void 0,o=36663;this.gl.bindBuffer(o,this.handle),r!==0||s!==void 0?this.gl.bufferSubData(o,t,i,r,s):this.gl.bufferSubData(o,t,i),this.gl.bindBuffer(o,null),this._setDebugData(e,t,e.byteLength)}async mapAndWriteAsync(e,t=0,i=this.byteLength-t){let r=new ArrayBuffer(i);await e(r,"copied"),this.write(r,t)}async readAsync(e=0,t){return this.readSyncWebGL(e,t)}async mapAndReadAsync(e,t=0,i){let r=await this.readAsync(t,i);return await e(r.buffer,"copied")}readSyncWebGL(e=0,t){t=t??this.byteLength-e;let i=new Uint8Array(t),r=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,i,r,t),this.gl.bindBuffer(36662,null),this._setDebugData(i,e,t),i}}});function U2(n){let e=n.split(/\r?\n/),t=[];for(let i of e){if(i.length<=1)continue;let r=i.trim(),s=i.split(":"),o=s[0]?.trim();if(s.length===2){let[h,p]=s;if(!h||!p){t.push({message:r,type:td(o||"info"),lineNum:0,linePos:0});continue}t.push({message:p.trim(),type:td(h),lineNum:0,linePos:0});continue}let[a,c,l,...u]=s;if(!a||!c||!l){t.push({message:s.slice(1).join(":").trim()||r,type:td(o||"info"),lineNum:0,linePos:0});continue}let f=parseInt(l,10);Number.isNaN(f)&&(f=0);let d=parseInt(c,10);Number.isNaN(d)&&(d=0),t.push({message:u.join(":").trim(),type:td(a),lineNum:f,linePos:d})}return t}function td(n){let e=["warning","error","info"],t=n.toLowerCase();return e.includes(t)?t:"info"}var $2=C(()=>{});function iz(n){return n.split(/\r?\n/).find(e=>e.trim())?.trim()}var nd,G2=C(()=>{J();$2();nd=class extends kr{device;handle;_compilationInfoLog="";constructor(e,t){super(e,t),this.device=e;let i=this.props.handle;switch(this.props.stage){case"vertex":this.handle=i||this.device.gl.createShader(35633);break;case"fragment":this.handle=i||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}e._setWebGLDebugMetadata(this.handle,this,{spector:this.props});let r=this._compile(this.source);r&&typeof r.catch=="function"&&r.catch(()=>{this.compilationStatus="error"})}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this._getCompilationInfoLog();return e?U2(e):[]}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)||null}_compile(e){e=e.startsWith("#version ")?e:`#version 300 es +`});var M4,eo,bS=C(()=>{oS();hS();gS();yS();M4=[38.25,38.25,38.25],eo={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:mS.replace("phongMaterial","gouraudMaterial"),fs:pS.replace("phongMaterial","gouraudMaterial"),source:_S.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[fS,sS],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:M4},getUniforms(n){return{...eo.defaultUniforms,...n}}}});var vt=C(()=>{_m();dw();ng();Hw();qw();ZE();tS();aS();bS()});function Zn(n="id"){T_[n]=T_[n]||1;let e=T_[n]++;return`${n}-${e}`}var T_,_o=C(()=>{T_={}});function Kr(n){switch(n){case"POSITION":return"positions";case"NORMAL":return"normals";case"TEXCOORD_0":return"texCoords";case"TEXCOORD_1":return"texCoords1";case"COLOR_0":return"colors";default:return n}}function PF(n){let e=[];for(let[t,i]of Object.entries(n)){if(!i)continue;let{value:r,size:s,normalized:o}=i;if(s===void 0)throw new Error(`Attribute ${t} is missing a size`);e.push({name:Kr(t),format:Pe.getVertexFormatFromAttribute(r,s,o)})}return e}var en,Rf=C(()=>{J();_o();en=class{id;topology;vertexCount;indices;attributes;bufferLayout;userData={};constructor(e){let{attributes:t={},indices:i=null,vertexCount:r=null}=e;this.id=e.id||Zn("geometry"),this.topology=e.topology,i&&(this.indices=ArrayBuffer.isView(i)?{value:i,size:1}:i),this.attributes={};for(let[s,o]of Object.entries(t)){let a=ArrayBuffer.isView(o)?{value:o}:o;if(!ArrayBuffer.isView(a.value))throw new Error(`${this._print(s)}: must be typed array or object with value as typed array`);if((s==="POSITION"||s==="positions")&&!a.size&&(a.size=3),s==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=a}else{let c=Kr(s),l=Object.keys(this.attributes).find(u=>Kr(u)===c);l&&delete this.attributes[l],this.attributes[s]=a}}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=r||this._calculateVertexCount(this.attributes,this.indices),this.bufferLayout=e.bufferLayout||PF(this.attributes)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,t){return this}_calculateVertexCount(e,t){if(t)return t.value.length;let i=1/0;for(let r of Object.values(e)){if(!r)continue;let{value:s,size:o,constant:a}=r;!a&&s&&o!==void 0&&o>=1&&(i=Math.min(i,s.length/o))}return i}}});function p1(n,e={}){let t=e.bufferName||"geometry";if(CF(n,t))return n;let i=e.minAttributeAlignment||4,r=TF(n,e.attributes),s=[],o=0,a=1/0;for(let[u,f]of r){if(!f)continue;if(f.constant)throw new Error(`Attribute ${u} is constant`);let{value:d,size:h,normalized:p}=f;if(!ArrayBuffer.isView(d))throw new Error(`Attribute ${u} is missing typed array data`);if(h===void 0)throw new Error(`Attribute ${u} is missing a size`);let m=Pe.getVertexFormatFromAttribute(d,h,p),g=Pe.getVertexFormatInfo(m);o=h1(o,i),s.push({sourceName:u,attributeName:Kr(u),value:d,size:h,format:m,byteOffset:o,byteLength:g.byteLength}),o+=g.byteLength;let v=d.length/h;if(!Number.isInteger(v))throw new Error(`Attribute ${u} length is not divisible by size`);a=Math.min(a,v)}if(s.length===0||!Number.isFinite(a))throw new Error(`Geometry ${n.id} has no interleavable attributes`);let c=h1(o,i),l=new ArrayBuffer(a*c);for(let u of s)LF(l,a,c,u);return new en({id:n.id,topology:n.topology||"triangle-list",vertexCount:n.vertexCount,indices:n.indices,attributes:{[t]:{value:new Uint8Array(l),size:c,byteStride:c}},bufferLayout:[{name:t,stepMode:"vertex",byteStride:c,attributes:s.map(u=>({attribute:u.attributeName,format:u.format,byteOffset:u.byteOffset}))}]})}function CF(n,e){if(n.bufferLayout.length!==1)return!1;let t=n.bufferLayout[0];return t.name===e&&!!t.attributes?.length&&!!n.attributes[e]}function TF(n,e){return e?e.map(t=>[t,n.attributes[t]]):Object.entries(n.attributes)}function LF(n,e,t,i){let r=i.value.constructor,s=r.BYTES_PER_ELEMENT;if(i.byteOffset%s!==0||t%s!==0)throw new Error(`Attribute ${i.sourceName} is not aligned to its component type`);let o=new r(n),a=i.value,c=i.byteOffset/s,l=t/s;for(let u=0;u{J();Rf()});var MF,AF,Qr,g1=C(()=>{MF=1,AF=1,Qr=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){let{delay:t=0,duration:i=Number.POSITIVE_INFINITY,rate:r=1,repeat:s=1}=e,o=MF++,a={time:0,delay:t,duration:i,rate:r,repeat:s};return this._setChannelTime(a,this.time),this.channels.set(o,a),o}removeChannel(e){this.channels.delete(e);for(let[t,i]of this.animations)i.channel===e&&this.detachAnimation(t)}isFinished(e){let t=this.channels.get(e);return t===void 0?!1:this.time>=t.delay+t.duration*t.repeat}getTime(e){if(e===void 0)return this.time;let t=this.channels.get(e);return t===void 0?-1:t.time}setTime(e){this.time=Math.max(0,e);let t=this.channels.values();for(let r of t)this._setChannelTime(r,this.time);let i=this.animations.values();for(let r of i){let{animation:s,channel:o}=r;s.setTime(this.getTime(o))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,t){let i=AF++;return this.animations.set(i,{animation:e,channel:t}),e.setTime(this.getTime(t)),i}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,t){let i=t-e.delay,r=e.duration*e.repeat;i>=r?e.time=e.duration*e.rate:(e.time=Math.max(0,i)%e.duration,e.time*=e.rate)}}});function _1(n){let e=typeof window<"u"?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame:null;return e?e.call(window,n):setTimeout(()=>n(typeof performance<"u"?performance.now():Date.now()),1e3/60)}function y1(n){let e=typeof window<"u"?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame:null;if(e){e.call(window,n);return}clearTimeout(n)}var b1=C(()=>{});var kF,RF,v1,gc,x1=C(()=>{J();b1();ua();kF=0,RF="Animation Loop",v1={requestAnimationFrame:n=>_1(n),cancelAnimationFrame:n=>y1(n)},gc=class n{static defaultAnimationLoopProps={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>{console.error(e)},stats:void 0,autoResizeViewport:!1,animationFrameProvider:v1};device=null;canvas=null;props;animationProps=null;timeline=null;stats;sharedStats;cpuTime;gpuTime;frameRate;display;_needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;_lastFrameTime=0;constructor(e){if(this.props={...n.defaultAnimationLoopProps,...e},e=this.props,!e.device)throw new Error("No device provided");this.stats=e.stats||new Ht({id:`animation-loop-${kF++}`}),this.sharedStats=Vs.stats.get(RF),this.frameRate=this.stats.get("Frame Rate"),this.frameRate.setSampleSize(1),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.setProps({autoResizeViewport:e.autoResizeViewport,animationFrameProvider:e.animationFrameProvider}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null),this.device?._disableDebugGPUTime()}delete(){this.destroy()}reportError(e){this._error=e,this.props.onError(e),this.props.onError===n.defaultAnimationLoopProps.onError&&typeof window<"u"&&typeof ErrorEvent<"u"&&window.dispatchEvent(new ErrorEvent("error",{error:e,message:e.message}))}setNeedsRedraw(e){return this._needsRedraw=this._needsRedraw||e,this}needsRedraw(){let e=this._needsRedraw;return this._needsRedraw=!1,e}setProps(e){if("autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),"animationFrameProvider"in e){let t=e.animationFrameProvider||v1;if(t!==this.props.animationFrameProvider){let i=this._animationFrameId!==null;i&&this._cancelAnimationFrame(),this.props.animationFrameProvider=t,i&&this._requestAnimationFrame()}}return this}async start(){if(this._running)return this;this._running=!0;try{let e;if(!this._initialized){if(this._initialized=!0,await this._initDevice(),this._initialize(),!this._running)return null;await this.props.onInitialize(this._getAnimationProps())}return this._running?(e!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){let t=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(t),t}}stop(){if(this._running){let e=this.animationProps;this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1,this._lastFrameTime=0,e&&this.props.onFinalize(e)}return this}redraw(e,t=null){return this.device?.isLost||this._error?this:(this._beginFrameTimers(e),this._setupFrame(),this.animationProps&&(this.animationProps.animationFrame=t),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeViewport(),this.device?._enableDebugGPUTime()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=this.props.animationFrameProvider.requestAnimationFrame(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(this.props.animationFrameProvider.cancelAnimationFrame(this._animationFrameId),this._animationFrameId=null)}_animationFrame(e,t){if(this._running)try{this.redraw(e,t??null),this._requestAnimationFrame()}catch(i){let r=i instanceof Error?i:new Error(String(i));this.reportError(r),this.stop()}}_renderFrame(e){if(this.display){this.display._renderFrame(e);return}let t=this.props.onRender(this._getAnimationProps());this.device&&t!==!1&&this.device.submit()}_clearNeedsRedraw(){this._needsRedraw=!1}_setupFrame(){this._resizeViewport()}_initializeAnimationProps(){let e=this.device?.getDefaultCanvasContext();if(!this.device||!e)throw new Error("loop");let t=e?.canvas,i=e.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:e,canvas:t,useDevicePixels:i,timeline:this.timeline,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,animationFrame:null,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:e,height:t,aspect:i}=this._getSizeAndAspect();(e!==this.animationProps.width||t!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),i!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=t,this.animationProps.aspect=i,this.animationProps.needsRedraw=this._needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.getDefaultCanvasContext().canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";let t=document.createElement("div");t.style.position="absolute",t.style.left="10px",t.style.bottom="10px",t.style.width="300px",t.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(t);let i=this.props.onAddHTML(t);i&&(t.innerHTML=i)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[e,t]=this.device.getDefaultCanvasContext().getDrawingBufferSize(),i=e>0&&t>0?e/t:1;return{width:e,height:t,aspect:i}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(e){let t=e??(typeof performance<"u"?performance.now():Date.now());if(this._lastFrameTime){let i=t-this._lastFrameTime;i>0&&this.frameRate.addTime(i)}this._lastFrameTime=t,this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeStart()}_endFrameTimers(){this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeEnd(),this._updateSharedStats()}_consumeEncodedGpuTime(){if(!this.device)return;let e=this.device.commandEncoder._gpuTimeMs;e!==void 0&&(this.gpuTime.addTime(e),this.device.commandEncoder._gpuTimeMs=void 0)}_updateSharedStats(){if(this.stats!==this.sharedStats){for(let e of Object.keys(this.sharedStats.stats))this.stats.stats[e]||delete this.sharedStats.stats[e];this.stats.forEach(e=>{let t=this.sharedStats.get(e.name,e.type);t.sampleSize=e.sampleSize,t.time=e.time,t.count=e.count,t.samples=e.samples,t.lastTiming=e.lastTiming,t.lastSampleTime=e.lastSampleTime,t.lastSampleCount=e.lastSampleCount,t._count=e._count,t._time=e._time,t._samples=e._samples,t._startTime=e._startTime,t._timerPending=e._timerPending})}}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}}});function w1(n,e){if(e instanceof If)return e;let t=p1(e),i=IF(n,t),{attributes:r,bufferLayout:s}=BF(n,t);return new If({topology:t.topology||"triangle-list",bufferLayout:s,vertexCount:t.vertexCount,indices:i,attributes:r})}function IF(n,e){if(!e.indices)return;let t=e.indices.value;return n.createBuffer({usage:ie.INDEX,data:t})}function BF(n,e){let t={};for(let[i,r]of Object.entries(e.attributes)){let s=e.bufferLayout.find(o=>o.name===i)?.name||Kr(i);r&&(t[s]=n.createBuffer({data:r.value,id:`${i}-buffer`}))}return{attributes:t,bufferLayout:e.bufferLayout,vertexCount:e.vertexCount}}var If,E1=C(()=>{J();Rf();m1();_o();If=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){if(this.id=e.id||Zn("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&!(this.indices.usage&ie.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){this.indices?.destroy();for(let e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(e){return e.byteLength/12}}});function S1(n,e){let t={},i="Values";if(n.attributes.length===0&&!n.varyings?.length)return{"No attributes or varyings":{[i]:"N/A"}};for(let r of n.attributes)if(r){let s=`${r.location} ${r.name}: ${r.type}`;t[`in ${s}`]={[i]:r.stepMode||"vertex"}}for(let r of n.varyings||[]){let s=`${r.location} ${r.name}`;t[`out ${s}`]={[i]:JSON.stringify(r)}}return t}var P1=C(()=>{});function L1(n,e,t){if(n.device.type!=="webgl")return;let i=NF(n.device);if(!i.flushing){if(zF(n)){OF(n,t,i);return}e&&FF(e)&&e.handle!==null&&(i.queuedFramebuffers.includes(e)||i.queuedFramebuffers.push(e))}}function OF(n,e,t){if(t.queuedFramebuffers.length===0)return;let i=n.device,{gl:r}=i,s=r.getParameter(36010),o=r.getParameter(36006),[a,c]=n.device.getDefaultCanvasContext().getDrawingBufferSize(),l=T1(e.top,8),u=T1(e.left,8);t.flushing=!0;try{for(let f of t.queuedFramebuffers){let[d,h,p,m,g]=DF({framebuffer:f,targetWidth:a,targetHeight:c,topPx:l,leftPx:u,minimap:e.minimap});r.bindFramebuffer(36008,f.handle),r.bindFramebuffer(36009,null),r.blitFramebuffer(0,0,f.width,f.height,d,h,p,m,16384,9728),l+=g+8}}finally{r.bindFramebuffer(36008,s),r.bindFramebuffer(36009,o),t.flushing=!1}}function DF(n){let{framebuffer:e,targetWidth:t,targetHeight:i,topPx:r,leftPx:s,minimap:o}=n,a=o?Math.max(Math.floor(t/4),1):t,c=o?Math.max(Math.floor(i/4),1):i,l=Math.min(a/e.width,c/e.height),u=Math.max(Math.floor(e.width*l),1),f=Math.max(Math.floor(e.height*l),1),d=s,h=Math.max(i-r-f,0),p=d+u,m=h+f;return[d,h,p,m,f]}function NF(n){return n.userData[C1]||={flushing:!1,queuedFramebuffers:[]},n.userData[C1]}function FF(n){return"colorAttachments"in n}function zF(n){let e=n.props.framebuffer;return!e||e.handle===null}function T1(n,e){if(!n)return e;let t=Number.parseInt(n,10);return Number.isFinite(t)?t:e}var C1,M1=C(()=>{C1="__debugFramebufferState"});function yo(n,e,t){if(n===e)return!0;if(!t||!n||!e)return!1;if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let i=0;i{});var bo,k1=C(()=>{J();bo=class{bufferLayouts;constructor(e){this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(t=>t.name===e)||null}getAttributeNamesForBuffer(e){return qs(e)}mergeBufferLayouts(e,t){let i=[...e];for(let r of t){let s=i.findIndex(o=>o.name===r.name);s<0?i.push(r):i[s]=r}return i}}});function R1(n,e){let t=Km(n),i=e.slice();return i.sort((r,s)=>{let o=Vu(qs(r).map(c=>t[c])),a=Vu(qs(s).map(c=>t[c]));return o-a}),i}var I1=C(()=>{J()});function vo(n,e){if(!n||!e.some(i=>i.bindingLayout?.length))return n;let t={...n,bindings:n.bindings.map(i=>({...i}))};"attributes"in(n||{})&&(t.attributes=n?.attributes||[]);for(let i of e)for(let r of i.bindingLayout||[])for(let s of UF(r.name)){let o=t.bindings.find(a=>a.name===s);o?.group===0&&(o.group=r.group),o&&r.visibility!==void 0&&(o.visibility=r.visibility)}return t}function B1(n,e,t=[]){return n?e?{...n,attributes:n.attributes.length?VF(n.attributes,e.attributes.filter(i=>t.includes(i.name))):e.attributes,bindings:GF(n.bindings,e.bindings)}:n:e}function _c(n){return!!(n.uniformTypes&&!$F(n.uniformTypes))}function O1(n){let e=[];for(let t of n){let i=Wa(t),r=new Set([t.vs,t.fs].flatMap(o=>o?ja(o).filter(a=>a.isStd140).map(a=>a.blockName):[])),s=r.has(i)?i:r.size===1?r.values().next().value:void 0;_c(t)&&s&&e.push({name:s,uniformTypes:t.uniformTypes})}return e}function Bf(n,e){let t=[],i=new Set;for(let r of[...n||[],...e||[]])i.has(r.name)||(i.add(r.name),t.push(r));return t}function UF(n){let e=new Set([n,`${n}Uniforms`]);return n.endsWith("Uniforms")||e.add(`${n}Sampler`),[...e]}function $F(n){for(let e in n)return!1;return!0}function GF(n,e){let t=n.map(s=>({...s})),i=new Set(n.map(s=>s.name)),r=new Set(n.map(s=>`${s.group}:${s.location}`));for(let s of e){let o=`${s.group}:${s.location}`;!i.has(s.name)&&!r.has(o)&&t.push({...s})}return t}function VF(n,e){let t=n.map(s=>({...s})),i=new Map(n.map(s=>[s.name,s])),r=new Map(n.map(s=>[s.location,s]));for(let s of e){let o=i.get(s.name);if(o){if(o.type!==s.type||o.location!==s.location)throw new Error(`Shader attribute "${s.name}" conflicts with its inferred type or location`);continue}let a=r.get(s.location);if(a)throw new Error(`Shader attributes "${a.name}" and "${s.name}" both use location ${s.location}`);t.push({...s})}return t}var L_=C(()=>{vt()});function WF(n){return _a(n)||typeof n=="number"||typeof n=="boolean"}function D1(n,e={}){let t={bindings:{},uniforms:{}};return Object.keys(n).forEach(i=>{let r=n[i];Object.prototype.hasOwnProperty.call(e,i)||WF(r)?t.uniforms[i]=r:t.bindings[i]=r}),t}var N1=C(()=>{Jp()});function F1(n={},e={},t={}){let i={...n};for(let[r,s]of Object.entries(e))s!==void 0&&(i[r]=M_(n[r],s,t[r]));return i}function M_(n,e,t){if(!t||typeof t=="string")return yc(e);if(Array.isArray(t)){if(A_(e)||!Array.isArray(e))return yc(e);let o=Array.isArray(n)&&!A_(n)?[...n]:[],a=o.slice();for(let c=0;ct===void 0?void 0:yc(t)):k_(n)?Object.fromEntries(Object.entries(n).map(([e,t])=>[e,t===void 0?void 0:yc(t)])):n}function A_(n){return ArrayBuffer.isView(n)||Array.isArray(n)&&(n.length===0||typeof n[0]=="number")}function k_(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&!ArrayBuffer.isView(n)}function jF(n){return!!n?.dependencies}var xo,R_=C(()=>{J();vt();N1();xo=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;directBindings={};constructor(e,t){Object.assign(this.options,t);let i=Cr(Object.values(e).filter(jF));for(let r of i)e[r.name]=r;N.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(let[r,s]of Object.entries(e))s&&(this._addModule(s),s.name&&r!==s.name&&!this.options.disableWarnings&&N.warn(`Module name: ${r} vs ${s.name}`)())}destroy(){}setProps(e){e.bindings&&Object.assign(this.directBindings,e.bindings);for(let t of Object.keys(e)){if(t==="bindings")continue;let i=t,r=e[i]||{},s=this.modules[i];if(!s)this.options.disableWarnings||N.warn(`Module ${t} not found`)();else{let o=this.moduleUniforms[i],a=this.moduleBindings[i],c=s.getUniforms?.(r,o)||r,{uniforms:l,bindings:u}=D1(c,s.uniformTypes);this.moduleUniforms[i]=F1(o,l,s.uniformTypes),this.moduleBindings[i]={...a,...u}}}}getModules(){return Object.values(this.modules)}addModules(e){let t=Cr(e);for(let i of t){let r=i.name;this.modules[r]||(this.modules[r]=i,this._addModule(i))}}getUniformValues(){return this.moduleUniforms}getBindingValues(){let e={};for(let t of Object.values(this.moduleBindings))Object.assign(e,t);return Object.assign(e,this.directBindings),e}getModuleBindingValues(e){let t=this.moduleBindings[e];return t?{...t}:{}}getDebugTable(){let e={};for(let[t,i]of Object.entries(this.moduleUniforms))for(let[r,s]of Object.entries(i))e[`${t}.${r}`]={type:this.modules[t].uniformTypes?.[r],value:String(s)};return e}_addModule(e){let t=e.name;this.moduleUniforms[t]=F1({},e.defaultUniforms||{},e.uniformTypes),this.moduleBindings[t]={}}}});function I_(n){return n!==null&&typeof n=="object"&&"buffer"in n}function YF(n){return n instanceof tt?n.buffer:n}function z1(n){return{buffer:YF(n.buffer),offset:n.offset,size:n.size}}var HF,tt,B_=C(()=>{J();_o();HF=ie.DEBUG_DATA_MAX_LENGTH,tt=class{device;id;ready;usage;props;isReady=!0;destroyed=!1;generation=0;updateTimestamp;debugData=new ArrayBuffer(0);_debugDataEnabled;_maxDebugDataByteLength;_ownsBuffer;_buffer;get buffer(){return this._buffer}get byteLength(){return this._buffer.byteLength}get[Symbol.toStringTag](){return"DynamicBuffer"}toString(){return`DynamicBuffer:"${this.id}":${this.byteLength}B`}toJSON(){return this.toString()}constructor(e,t){let{debugData:i=!1,buffer:r,ownsBuffer:s=!0,...o}=t;if(r&&r.device!==e)throw new Error("DynamicBuffer adopted buffers must belong to the supplied device");if(r&&(o.byteLength!==void 0||o.data!==void 0))throw new Error("DynamicBuffer cannot combine an adopted buffer with byteLength or data");let a=t.id||r?.id||Zn("dynamic-buffer"),c={...o,id:a,usage:o.usage??r?.usage,indexType:o.indexType??r?.indexType};(c.usage||0)&ie.INDEX&&!c.indexType&&(o.data instanceof Uint32Array?c.indexType="uint32":o.data instanceof Uint16Array?c.indexType="uint16":o.data instanceof Uint8Array&&(c.indexType="uint8")),delete c.data,delete c.byteOffset,this.device=e,this.id=a,this.props=c,this.usage=c.usage||0,this._debugDataEnabled=!!i,this._maxDebugDataByteLength=typeof i=="object"&&i.maxByteLength!==void 0?i.maxByteLength:HF,this._ownsBuffer=s,this._buffer=r??this.device.createBuffer({...o,id:a}),this.ready=Promise.resolve(this._buffer),this.updateTimestamp=this._buffer.updateTimestamp,this._resetDebugData(this._buffer.byteLength),o.data&&this._writeDebugData(o.data,o.byteOffset||0)}write(e,t=0){this._buffer.write(e,t),this._touch(),this._writeDebugData(e,t)}async mapAndWriteAsync(e,t=0,i=this.byteLength-t){let r=null;await this._buffer.mapAndWriteAsync(async(s,o)=>{await e(s,o),r=new Uint8Array(s.slice(0,i))},t,i),this._touch(),r&&this._writeDebugData(r,t)}async readAsync(e=0,t=this.byteLength-e){let i=await this._buffer.readAsync(e,t);return this._writeDebugData(i,e)&&this._touch(),i}async mapAndReadAsync(e,t=0,i=this.byteLength-t){let r=null,s=await this._buffer.mapAndReadAsync(async(o,a)=>(r=new Uint8Array(o.slice(0)),await e(o,a)),t,i);return r&&this._writeDebugData(r,t)&&this._touch(),s}resize(e){let{byteLength:t,preserveData:i=!1}=e;if(t===this.byteLength)return!1;let r=Math.min(e.copyByteLength??Math.min(this.byteLength,t),this.byteLength,t),s=this._buffer,o=this.debugData.slice(0),{data:a,byteOffset:c,...l}=this.props,u=this.device.createBuffer({...l,byteLength:t});return i&&r>0&&this._copyBufferContents(s,u,r),this._buffer=u,this._resetDebugData(t),i&&o.byteLength>0&&this._writeDebugData(o,0),this._ownsBuffer&&s.destroy(),this._ownsBuffer=!0,this.generation++,this._touch(),!0}ensureSize(e,t){return e<=this.byteLength?!1:this.resize({byteLength:e,preserveData:t?.preserveData})}getBinding(e){return e?.offset===void 0&&e?.size===void 0?this._buffer:{buffer:this._buffer,offset:e?.offset,size:e?.size}}destroy(){this.destroyed||(this._ownsBuffer&&this._buffer.destroy(),this.destroyed=!0,this.debugData=new ArrayBuffer(0))}_copyBufferContents(e,t,i){let r=this.device.type==="webgpu"?Math.ceil(i/4)*4:i,s=this.device.createCommandEncoder();s.copyBufferToBuffer({sourceBuffer:e,destinationBuffer:t,size:r}),this.device.submit(s.finish())}_touch(){this.updateTimestamp=this.device.incrementTimestamp()}_resetDebugData(e){if(!this._debugDataEnabled){this.debugData=new ArrayBuffer(0);return}this.debugData=new ArrayBuffer(Math.min(e,this._maxDebugDataByteLength))}_writeDebugData(e,t){if(!this._debugDataEnabled||this.debugData.byteLength===0||t>=this.debugData.byteLength)return!1;let i=ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),r=new Uint8Array(this.debugData),s=Math.min(i.byteLength,r.byteLength-t);return r.set(i.subarray(0,s),t),s>0}}});function bc(n){return n!==null&&typeof n=="object"&&"resolveTextureBinding"in n&&typeof n.resolveTextureBinding=="function"}function qF(n){return n?.type==="texture"||n?.type==="external-texture"}function U1(n,e,t){let i=Nu(n,e,{ignoreWarnings:!0});return qF(i)?i:n.bindings.length===0&&t?.fallbackGroup!==void 0?{type:"texture",name:e,group:t.fallbackGroup,location:0}:null}var $1=C(()=>{J()});function D_(n,e){return n.shaderLanguage!==void 0&&n.shaderLanguage!==e?!1:e==="glsl"?"assembleGLSLShaderPair"in n&&typeof n.assembleGLSLShaderPair=="function":"assembleWGSLShader"in n&&typeof n.assembleWGSLShader=="function"}function KF(n,e){return!n||Object.keys(e).length===0?n:{...n,attributes:n.attributes.map(t=>{let i=t.name.startsWith("_luma_")?t.name.slice(6):null;return i&&e[i]?{...t,name:i}:t})}}function QF(n,e,t){if(bc(e)){let i=U1(t,n,{fallbackGroup:0});return i?e.resolveTextureBinding(i):null}return e instanceof tt?e.buffer:I_(e)?z1(e):e}function JF(n){return n&&!G1(n)?n:null}function e6(n){return n&&G1(n)?n:void 0}function G1(n){return XF.includes(n)}function t6(n){return{type:n.type,shaderLanguage:n.info.shadingLanguage,shaderLanguageVersion:n.info.shadingLanguageVersion,gpu:n.info.gpu,limits:n.limits,features:n.features}}var Xn,ZF,O_,XF,Ze,N_=C(()=>{J();vt();E1();P1();M1();A1();k1();I1();L_();_o();R_();B_();$1();Xn=2,ZF=1e4,O_="render pipeline initialization failed",XF=["stencil8","depth16unorm","depth24plus","depth24plus-stencil8","depth32float","depth32float-stencil8"],Ze=class n{static defaultProps={...Zt.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],plugins:[],geometry:null,indexBuffer:null,indexCount:void 0,firstVertex:0,firstIndex:0,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,material:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:Xt.getDefaultShaderAssembler("glsl"),debugShaders:void 0,disableWarnings:void 0};device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexCount;firstVertex;firstIndex;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;material=null;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_dynamicIndexBufferSource=null;_dynamicAttributeBufferSources={};_colorAttachmentFormats;_depthStencilAttachmentFormat;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_drawBlockedReason=!1;_destroyed=!1;_vertexCountSet=!1;_lastDrawTimestamp=-1;_bindingTable=[];get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(e,t){let i=n.defaultProps.shaderAssembler,r=t.vertexCount!==void 0;this.props={...n.defaultProps,...t,shaderAssembler:t.shaderAssembler??(D_(i,e.info.shadingLanguage)?i:Xt.getDefaultShaderAssembler(e.info.shadingLanguage))},this._vertexCountSet=r,t=this.props,this.id=t.id||Zn("model"),this.device=e,Object.assign(this.userData,t.userData),this.material=t.material||null;let s=t6(e),o=Ga(this.props.plugins,s.shaderLanguage),a=Va(this.props.modules,o.modules),c=Object.fromEntries(a.map(h=>[h.name,h])),l=t.shaderInputs||new xo(c,{disableWarnings:this.props.disableWarnings});t.shaderInputs&&o.modules.length>0&&l.addModules(o.modules),this.setShaderInputs(l);let u=Bf(this.props.modules,l.getModules()),f={...o.defines,...this.props.defines};if(this.device.type==="webgl"&&(this.props._uniformBlockLayouts=O1(u)),this.props.shaderLayout=vo(this.props.shaderLayout,u)||null,this.device.type==="webgpu"&&this.props.source){let h=this.props.shaderAssembler;Vi(D_(h,"wgsl"));let{source:p,getUniforms:m,bindingTable:g,shaderLayout:v}=h.assembleWGSLShader({platformInfo:s,...this.props,modules:u,defines:f,pluginInjections:o.injections,pluginVertexInputs:o.vertexInputs,pluginVaryings:o.varyings});this.source=p,this._getModuleUniforms=m,this._bindingTable=g;let y=v??e.getShaderLayout?.(this.source),b=KF(y,o.vertexInputs),x=B1(this.props.shaderLayout,b,Object.keys(o.vertexInputs));this.props.shaderLayout=vo(x||null,u)||null}else{let h=this.props.shaderAssembler;Vi(D_(h,"glsl"));let{vs:p,fs:m,getUniforms:g}=h.assembleGLSLShaderPair({platformInfo:s,...this.props,modules:u,defines:f,pluginInjections:o.injections,pluginVertexInputs:o.vertexInputs,pluginVaryings:o.varyings});this.vs=p,this.fs=m,this._getModuleUniforms=g,this._bindingTable=[]}this.vertexCount=this.props.vertexCount,this.indexCount=this.props.indexCount,this.firstVertex=this.props.firstVertex,this.firstIndex=this.props.firstIndex,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,this._colorAttachmentFormats=this.props.colorAttachmentFormats,this._depthStencilAttachmentFormat=this.props.depthStencilAttachmentFormat,t.geometry&&this.setGeometry(t.geometry),this.pipelineFactory=t.pipelineFactory||Ir.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||Br.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in t&&(this.isInstanced=t.isInstanced),t.instanceCount&&this.setInstanceCount(t.instanceCount),t.vertexCount&&this.setVertexCount(t.vertexCount),t.indexBuffer&&this.setIndexBuffer(t.indexBuffer),t.attributes&&this.setAttributes(t.attributes),t.constantAttributes&&this.setConstantAttributes(t.constantAttributes),t.bindings&&this.setBindings(t.bindings),t.transformFeedback&&(this.transformFeedback=t.transformFeedback)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}getBindingDebugTable(){return this._bindingTable}predraw(e){this._syncDynamicBuffers(),this.updateShaderInputs(e),this.material?.updateShaderInputs(e),this.pipeline=this._updatePipeline()}draw(e){if(this._drawBlockedReason&&!this._pipelineNeedsUpdate)return N.info(Xn,`>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)(),!1;let t=this._areBindingsLoading();if(t)return N.info(Xn,`>>> DRAWING ABORTED ${this.id}: ${t} not loaded`)(),!1;this._syncAttachmentFormats(e);try{e.pushDebugGroup(`${this}.predraw(${e})`),this.device.type==="webgpu"?(this.updateShaderInputs(),this.material?.updateShaderInputs(),this._syncDynamicBuffers(),this.pipeline=this._updatePipeline()):this.predraw(this.device.commandEncoder)}finally{e.popDebugGroup()}let i,r=this.pipeline.isErrored;try{if(e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline(),r=this.pipeline.isErrored,r)N.info(Xn,`>>> DRAWING ABORTED ${this.id}: ${O_}`)(),i=!1;else{let s=this.vertexArray.getDrawValidationError();if(s)N.info(Xn,`>>> DRAWING ABORTED ${this.id}: ${s}`)(),this._drawBlockedReason=s,i=!1;else{let o=this._getCurrentShaderLayout(),a=this._getBindings(o),c=this._getBindGroups(o,a),{indexBuffer:l}=this.vertexArray,u=l?this.indexCount??(this._vertexCountSet?this.vertexCount:l.byteLength/(l.indexType==="uint32"?4:2)):void 0;e.setPipeline(this.pipeline),e.setBindings(c,{_bindGroupCacheKeys:this._getBindGroupCacheKeys()}),e.setVertexArray(this.vertexArray),i=this.isInstanced===!0&&this.instanceCount===0?!0:e.draw({isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.isInstanced?this.instanceCount:void 0,indexCount:u,firstVertex:this.firstVertex,firstIndex:this.firstIndex,transformFeedback:this.transformFeedback||void 0,uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}}}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),i?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):r?(this._needsRedraw=O_,this._drawBlockedReason=O_):this._drawBlockedReason?this._needsRedraw=this._drawBlockedReason:this._needsRedraw="waiting for resource initialization",i}setGeometry(e){this._gpuGeometry?.destroy();let t=e&&w1(this.device,e);if(t){this.setTopology(t.topology||"triangle-list");let i=new bo(this.bufferLayout);this.bufferLayout=i.mergeBufferLayouts(t.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(t)}this._gpuGeometry=t}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){let t=new bo(this.bufferLayout),i=this._gpuGeometry?t.mergeBufferLayouts(e,this._gpuGeometry.bufferLayout):e;yo(i,this.bufferLayout,-1)||(this.bufferLayout=i,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry))}setParameters(e){yo(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,this.isInstanced===void 0&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this._vertexCountSet=!0,this.setNeedsRedraw("vertexCount")}setIndexCount(e){this.indexCount=e,this.setNeedsRedraw("indexCount")}setDrawOffsets({firstVertex:e,firstIndex:t}){this.firstVertex=e,this.firstIndex=t,this.setNeedsRedraw("drawOffsets")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new Nr(this.device,this.shaderInputs.modules);for(let[t,i]of Object.entries(this.shaderInputs.modules))if(_c(i)&&!this.material?.ownsModule(t)){let r=this._uniformStore.getManagedUniformBuffer(t);this.bindings[`${t}Uniforms`]=r}this.setNeedsRedraw("shaderInputs")}setMaterial(e){this.material=e,this.setNeedsRedraw("material")}updateShaderInputs(e){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),e),this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues())),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){let t=e instanceof tt?e.buffer:e;this.indexBuffer=t,this._dynamicIndexBufferSource=e instanceof tt?{source:e,generation:e.generation}:null,this.vertexArray.setIndexBuffer(t),this.setNeedsRedraw("indexBuffer")}setAttributes(e,t){this._drawBlockedReason=!1;let i=t?.disableWarnings??this.props.disableWarnings;e.indices&&N.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=R1(this.pipeline.shaderLayout,this.bufferLayout);let r=new bo(this.bufferLayout);for(let[s,o]of Object.entries(e)){let a=o instanceof tt?o.buffer:o,c=r.getBufferLayout(s);if(!c){i||N.warn(`Model(${this.id}): Missing layout for buffer "${s}".`)();continue}let l=r.getAttributeNamesForBuffer(c),u=!1;for(let f of l){let d=this._attributeInfos[f];if(d){let h=this.device.type==="webgpu"?this.vertexArray.getBufferSlot(d.bufferName):d.location;if(h===null){i||N.warn(`Model(${this.id}): Missing vertex array slot for buffer "${d.bufferName}".`)();continue}this.vertexArray.setBuffer(h,a),o instanceof tt?this._dynamicAttributeBufferSources[h]={source:o,generation:o.generation}:delete this._dynamicAttributeBufferSources[h],u=!0}}!u&&!i&&N.warn(`Model(${this.id}): Ignoring buffer "${a.id}" for unknown attribute "${s}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,t){for(let[i,r]of Object.entries(e)){let s=this._attributeInfos[i];s?this.vertexArray.setConstantWebGL(s.location,r):(t?.disableWarnings??this.props.disableWarnings)||N.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(let e of Object.values(this.bindings))if(bc(e)&&!e.isReady)return e.id;for(let e of Object.values(this.material?.bindings||{}))if(bc(e)&&!e.isReady)return e.id;return!1}_getBindings(e=this._getCurrentShaderLayout()){let t={};for(let[i,r]of Object.entries(this.bindings)){let s=QF(i,r,e);s&&(t[i]=s)}return t}_getBindGroups(e=this._getCurrentShaderLayout(),t=this._getBindings(e)){let i=e.bindings.length?Or(e,t):{0:t};if(!this.material)return i;for(let[r,s]of Object.entries(this.material.getBindingsByGroup(e))){let o=Number(r);i[o]={...i[o]||{},...s}}return i}_getBindGroupCacheKeys(){let e=this.material?.getBindGroupCacheKey(3);return e?{3:e}:{}}_getBindingsUpdateTimestamp(){let e=0;this._dynamicIndexBufferSource&&(e=Math.max(e,this._dynamicIndexBufferSource.source.updateTimestamp));for(let t of Object.values(this._dynamicAttributeBufferSources))e=Math.max(e,t.source.updateTimestamp);for(let t of Object.values(this.bindings))t instanceof Ar?e=Math.max(e,t.texture.updateTimestamp):t instanceof ie||t instanceof me||t instanceof Aa||t instanceof tt?e=Math.max(e,t.updateTimestamp):bc(t)?e=t.isReady?Math.max(e,t.updateTimestamp):1/0:I_(t)&&(e=Math.max(e,(t.buffer instanceof tt,t.buffer.updateTimestamp)));return Math.max(e,this.material?.getBindingsUpdateTimestamp()||0)}_setGeometryAttributes(e){let t={...e.attributes};for(let[i]of Object.entries(t))!this.pipeline.shaderLayout.attributes.find(r=>r.name===i)&&i!=="positions"&&delete t[i];this.vertexCount=e.vertexCount,this._vertexCountSet=!0,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(t,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this._drawBlockedReason=!1,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,t=null;this.pipeline&&(N.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,t=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let i=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders}),r=null;this.source?r=i:this.fs&&(r=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bindings:void 0,bufferLayout:this.bufferLayout,colorAttachmentFormats:this._colorAttachmentFormats,depthStencilAttachmentFormat:this._depthStencilAttachmentFormat,topology:this.topology,parameters:this.parameters,bindGroups:void 0,vs:i,fs:r}),this._attributeInfos=$a(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&t!==e&&this.shaderFactory.release(t)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=N.level>3?0:ZF;N.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:N.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=S1(this.pipeline.shaderLayout,this.id);N.table(Xn,e)();let t=this.shaderInputs.getDebugTable();N.table(Xn,t)();let i=this._getAttributeDebugTable();N.table(Xn,this._attributeInfos)(),N.table(Xn,i)(),N.groupEnd(Xn)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){let t=this.device.props.debugFramebuffers;if(this._drawCount++,!t)return;let i=e.props.framebuffer;L1(e,i,{id:i?.id||`${this.id}-framebuffer`,minimap:!0})}_getAttributeDebugTable(){let e={};for(let[t,i]of Object.entries(this._attributeInfos)){let r=this.vertexArray.attributes[i.location];e[i.location]={name:t,type:i.shaderType,values:r?this._getBufferOrConstantValues(r,i.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:t}=this.vertexArray,i=t.indexType==="uint32"?new Uint32Array(t.debugData):new Uint16Array(t.debugData);e.indices={name:"indices",type:t.indexType,values:i.toString()}}return e}_getBufferOrConstantValues(e,t){let i=Xe.getTypedArrayConstructor(t);return(e instanceof ie?new i(e.debugData):e).toString()}_getNonMaterialBindings(e){if(!this.material)return e;let t={};for(let[i,r]of Object.entries(e))this.material.ownsBinding(i)||(t[i]=r);return t}_getCurrentShaderLayout(){return this.pipeline?.shaderLayout||this.props.shaderLayout||{bindings:[]}}_syncDynamicBuffers(){if(this._dynamicIndexBufferSource&&this._dynamicIndexBufferSource.generation!==this._dynamicIndexBufferSource.source.generation){let e=this._dynamicIndexBufferSource.source.buffer;this.indexBuffer=e,this.vertexArray.setIndexBuffer(e),this._dynamicIndexBufferSource.generation=this._dynamicIndexBufferSource.source.generation,this.setNeedsRedraw("dynamic index buffer")}for(let[e,t]of Object.entries(this._dynamicAttributeBufferSources))t.generation!==t.source.generation&&(this.vertexArray.setBuffer(Number(e),t.source.buffer),t.generation=t.source.generation,this.setNeedsRedraw("dynamic attribute buffer"))}_syncAttachmentFormats(e){if(this.device.type!=="webgpu")return;let t=e.framebuffer||e.props.framebuffer,i=e.props,r=i.colorAttachmentFormats??t?.colorAttachments?.map(o=>JF(o?.texture?.format)),s=i.depthStencilAttachmentFormat===!1?void 0:i.depthStencilAttachmentFormat??e6(t?.depthStencilAttachment?.texture?.format);(!yo(this._colorAttachmentFormats,r,1)||this._depthStencilAttachmentFormat!==s)&&(this._colorAttachmentFormats=r,this._depthStencilAttachmentFormat=s,this._setPipelineNeedsUpdate("attachment formats"))}}});var n6,i6,nt,V1=C(()=>{J();vt();N_();n6=35980,i6=35981,nt=class n{device;model;transformFeedback;static defaultProps={...Ze.defaultProps,feedbackBufferMode:"separate",outputs:void 0,feedbackBuffers:void 0};static isSupported(e){return e?.info?.type==="webgl"}constructor(e,t=n.defaultProps){if(!n.isSupported(e))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=e,this.model=new Ze(this.device,{id:t.id||"buffer-transform-model",fs:t.fs||hg(),topology:t.topology||"point-list",varyings:t.outputs||t.varyings,...t,bufferMode:t.bufferMode||(t.feedbackBufferMode==="interleaved"?n6:i6)}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:t.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){e?.inputBuffers&&this.model.setAttributes(e.inputBuffers),e?.outputBuffers&&this.transformFeedback.setBuffers(e.outputBuffers);let t=this.device.beginRenderPass({discard:!0,...e});this.model.draw(t),t.end()}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){let t=this.getBuffer(e);if(!t)throw new Error("BufferTransform#getBuffer");if(t instanceof ie)return t.readAsync();let{buffer:i,byteOffset:r=0,byteLength:s=i.byteLength}=t;return i.readAsync(r,s)}}});function s6(n){return{type:n.type,shaderLanguage:n.info.shadingLanguage,shaderLanguageVersion:n.info.shadingLanguageVersion,gpu:n.info.gpu,limits:n.limits,features:n.features}}var F_,r6,Bt,W1=C(()=>{J();vt();Jp();R_();L_();_o();F_=2,r6=1e4,Bt=class n{static defaultProps={...Hi.defaultProps,id:"unnamed",handle:void 0,userData:{},source:"",modules:[],defines:{},plugins:[],bindings:void 0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,shaderAssembler:Xt.getDefaultShaderAssembler("wgsl"),debugShaders:void 0};device;id;pipelineFactory;shaderFactory;userData={};bindings={};pipeline;source;shader;shaderInputs;_uniformStore;_pipelineNeedsUpdate="newly created";_getModuleUniforms;props;_destroyed=!1;constructor(e,t){if(e.type!=="webgpu")throw new Error("Computation is only supported in WebGPU");this.props={...n.defaultProps,...t},t=this.props,this.id=t.id||Zn("model"),this.device=e,Object.assign(this.userData,t.userData);let i=s6(e),r=Ga(this.props.plugins,i.shaderLanguage);if(Object.keys(r.vertexInputs).length>0||Object.keys(r.varyings).length>0)throw new Error("Computation does not support ShaderPlugin vertex inputs or varyings");let s=Va(this.props.modules,r.modules),o=Object.fromEntries(s.map(p=>[p.name,p]));this.shaderInputs=t.shaderInputs||new xo(o),t.shaderInputs&&r.modules.length>0&&this.shaderInputs.addModules(r.modules),this.setShaderInputs(this.shaderInputs);let a=Bf(this.props.modules,this.shaderInputs?.getModules()),c={...r.defines,...this.props.defines};this.props.shaderLayout=vo(this.props.shaderLayout,a)||null,this.pipelineFactory=t.pipelineFactory||Ir.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||Br.getDefaultShaderFactory(this.device);let l=this.props.shaderAssembler;Vi(l instanceof qi);let{source:u,getUniforms:f,shaderLayout:d}=l.assembleWGSLShader({platformInfo:i,...this.props,modules:a,defines:c,scanVertexAttributes:!1,pluginInjections:r.injections});this.source=u,this._getModuleUniforms=f;let h=d??e.getShaderLayout?.(this.source,{scanVertexAttributes:!1});this.props.shaderLayout=vo(this.props.shaderLayout||h||null,a)||null,this.pipeline=this._updatePipeline(),t.bindings&&this.setBindings(t.bindings)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.shader),this._uniformStore.destroy(),this._destroyed=!0)}predraw(e){this.updateShaderInputs(e)}dispatch(e,t,i,r){try{this._logDrawCallStart(),this._setPipeline(e),e.dispatch(t,i,r)}finally{this._logDrawCallEnd()}}dispatchIndirect(e,t,i=0){try{this._logDrawCallStart(),this._setPipeline(e),e.dispatchIndirect(t,i)}finally{this._logDrawCallEnd()}}_setPipeline(e){this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings),e.setPipeline(this.pipeline),e.setBindings({})}setVertexCount(e){}setInstanceCount(e){}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new Nr(this.device,this.shaderInputs.modules);for(let[t,i]of Object.entries(this.shaderInputs.modules))if(_c(i)){let r=this._uniformStore.getManagedUniformBuffer(t);this.bindings[`${t}Uniforms`]=r}}setShaderModuleProps(e){let t=this._getModuleUniforms(e),i=Object.keys(t).filter(s=>{let o=t[s];return!_a(o)&&typeof o!="number"&&typeof o!="boolean"}),r={};for(let s of i)r[s]=t[s],delete t[s]}updateShaderInputs(e){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(),e)}setBindings(e){Object.assign(this.bindings,e)}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate=this._pipelineNeedsUpdate||e}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null;this.pipeline&&(N.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.shader),this._pipelineNeedsUpdate=!1,this.shader=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"compute",source:this.source,debugShaders:this.props.debugShaders}),this.pipeline=this.pipelineFactory.createComputePipeline({...this.props,shader:this.shader}),e&&this.shaderFactory.release(e)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=N.level>3?0:r6;N.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:N.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=this.shaderInputs.getDebugTable();N.table(F_,e)(),N.groupEnd(F_)(),this._logOpen=!1}}_drawCount=0;_getBufferOrConstantValues(e,t){let i=Xe.getTypedArrayConstructor(t);return(e instanceof ie?new i(e.debugData):e).toString()}}});var Me=C(()=>{g1();x1();N_();V1();Rf();B_();W1()});function s2(n=!0){let e=HTMLCanvasElement.prototype;if(!n&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(t,i){if(t==="webgl"||t==="experimental-webgl"){let r=this.originalGetContext("webgl2",i);return r instanceof HTMLElement&&D6(r),r}return this.originalGetContext(t,i)}}function D6(n){n.getExtension("EXT_color_buffer_float");let e={...R6,WEBGL_disjoint_timer_query:n.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:I6(n),OES_vertex_array_object:B6(n),ANGLE_instanced_arrays:O6(n)},t=n.getExtension.bind(n);n.getExtension=function(r){let s=t(r);return s||(r in e?e[r]:null)};let i=n.getSupportedExtensions;n.getSupportedExtensions=function(){return(i.apply(n)||[])?.concat(Object.keys(e))}}var R6,I6,B6,O6,o2=C(()=>{R6={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},I6=n=>({drawBuffersWEBGL(e){return n.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),B6=n=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return n.createVertexArray()},deleteVertexArrayOES(e){return n.deleteVertexArray(e)},isVertexArrayOES(e){return n.isVertexArray(e)},bindVertexArrayOES(e){return n.bindVertexArray(e)}}),O6=n=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return n.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return n.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return n.vertexAttribDivisor(...e)}})});async function c2(){if(!Gf){Z_();return}await Gf.load()}function l2(n,e){return Gf?Gf.makeDebugContext(n,e):(Z_(),n)}async function u2(n){if(!q_){Z_();return}await q_.load(n)}function f2(n){return q_?.initialize(n)||null}function Z_(){a2||(a2=!0,N.warn("Import @luma.gl/webgl/debug before enabling WebGL debugging.")())}var Gf,q_,a2,X_=C(()=>{J();Gf=null,q_=null,a2=!1});function K_(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Ie(n,e,t){return e[n]!==void 0?e[n]:t[n]}var Oc,$e,d2,Ot,h2,Bc,p2,m2,Q_,ei,J_,g2,ey=C(()=>{Oc={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},$e=(n,e,t)=>e?n.enable(t):n.disable(t),d2=(n,e,t)=>n.hint(t,e),Ot=(n,e,t)=>n.pixelStorei(t,e),h2=(n,e,t)=>{let i=t===36006?36009:36008;return n.bindFramebuffer(i,e)},Bc=(n,e,t)=>{let r={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[t];n.bindBuffer(r,e)};p2={3042:$e,32773:(n,e)=>n.blendColor(...e),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(n,e)=>n.clearColor(...e),3107:(n,e)=>n.colorMask(...e),2884:$e,2885:(n,e)=>n.cullFace(e),2929:$e,2931:(n,e)=>n.clearDepth(e),2932:(n,e)=>n.depthFunc(e),2928:(n,e)=>n.depthRange(...e),2930:(n,e)=>n.depthMask(e),3024:$e,35723:d2,35725:(n,e)=>n.useProgram(e),36007:(n,e)=>n.bindRenderbuffer(36161,e),36389:(n,e)=>n.bindTransformFeedback?.(36386,e),34229:(n,e)=>n.bindVertexArray(e),36006:h2,36010:h2,34964:Bc,36662:Bc,36663:Bc,35053:Bc,35055:Bc,2886:(n,e)=>n.frontFace(e),33170:d2,2849:(n,e)=>n.lineWidth(e),32823:$e,32824:"polygonOffset",10752:"polygonOffset",35977:$e,32926:$e,32928:$e,32938:"sampleCoverage",32939:"sampleCoverage",3089:$e,3088:(n,e)=>n.scissor(...e),2960:$e,2961:(n,e)=>n.clearStencil(e),2968:(n,e)=>n.stencilMaskSeparate(1028,e),36005:(n,e)=>n.stencilMaskSeparate(1029,e),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(n,e)=>n.viewport(...e),34383:$e,10754:$e,12288:$e,12289:$e,12290:$e,12291:$e,12292:$e,12293:$e,12294:$e,12295:$e,3333:Ot,3317:Ot,37440:Ot,37441:Ot,37443:Ot,3330:Ot,3332:Ot,3331:Ot,3314:Ot,32878:Ot,3316:Ot,3315:Ot,32877:Ot,framebuffer:(n,e)=>{let t=e&&"handle"in e?e.handle:e;return n.bindFramebuffer(36160,t)},blend:(n,e)=>e?n.enable(3042):n.disable(3042),blendColor:(n,e)=>n.blendColor(...e),blendEquation:(n,e)=>{let t=typeof e=="number"?[e,e]:e;n.blendEquationSeparate(...t)},blendFunc:(n,e)=>{let t=e?.length===2?[...e,...e]:e;n.blendFuncSeparate(...t)},clearColor:(n,e)=>n.clearColor(...e),clearDepth:(n,e)=>n.clearDepth(e),clearStencil:(n,e)=>n.clearStencil(e),colorMask:(n,e)=>n.colorMask(...e),cull:(n,e)=>e?n.enable(2884):n.disable(2884),cullFace:(n,e)=>n.cullFace(e),depthTest:(n,e)=>e?n.enable(2929):n.disable(2929),depthFunc:(n,e)=>n.depthFunc(e),depthMask:(n,e)=>n.depthMask(e),depthRange:(n,e)=>n.depthRange(...e),dither:(n,e)=>e?n.enable(3024):n.disable(3024),derivativeHint:(n,e)=>{n.hint(35723,e)},frontFace:(n,e)=>n.frontFace(e),mipmapHint:(n,e)=>n.hint(33170,e),lineWidth:(n,e)=>n.lineWidth(e),polygonOffsetFill:(n,e)=>e?n.enable(32823):n.disable(32823),polygonOffset:(n,e)=>n.polygonOffset(...e),sampleCoverage:(n,e)=>n.sampleCoverage(e[0],e[1]||!1),scissorTest:(n,e)=>e?n.enable(3089):n.disable(3089),scissor:(n,e)=>n.scissor(...e),stencilTest:(n,e)=>e?n.enable(2960):n.disable(2960),stencilMask:(n,e)=>{e=K_(e)?e:[e,e];let[t,i]=e;n.stencilMaskSeparate(1028,t),n.stencilMaskSeparate(1029,i)},stencilFunc:(n,e)=>{e=K_(e)&&e.length===3?[...e,...e]:e;let[t,i,r,s,o,a]=e;n.stencilFuncSeparate(1028,t,i,r),n.stencilFuncSeparate(1029,s,o,a)},stencilOp:(n,e)=>{e=K_(e)&&e.length===3?[...e,...e]:e;let[t,i,r,s,o,a]=e;n.stencilOpSeparate(1028,t,i,r),n.stencilOpSeparate(1029,s,o,a)},viewport:(n,e)=>n.viewport(...e)};m2={blendEquation:(n,e,t)=>n.blendEquationSeparate(Ie(32777,e,t),Ie(34877,e,t)),blendFunc:(n,e,t)=>n.blendFuncSeparate(Ie(32969,e,t),Ie(32968,e,t),Ie(32971,e,t),Ie(32970,e,t)),polygonOffset:(n,e,t)=>n.polygonOffset(Ie(32824,e,t),Ie(10752,e,t)),sampleCoverage:(n,e,t)=>n.sampleCoverage(Ie(32938,e,t),Ie(32939,e,t)),stencilFuncFront:(n,e,t)=>n.stencilFuncSeparate(1028,Ie(2962,e,t),Ie(2967,e,t),Ie(2963,e,t)),stencilFuncBack:(n,e,t)=>n.stencilFuncSeparate(1029,Ie(34816,e,t),Ie(36003,e,t),Ie(36004,e,t)),stencilOpFront:(n,e,t)=>n.stencilOpSeparate(1028,Ie(2964,e,t),Ie(2965,e,t),Ie(2966,e,t)),stencilOpBack:(n,e,t)=>n.stencilOpSeparate(1029,Ie(34817,e,t),Ie(34818,e,t),Ie(34819,e,t))},Q_={enable:(n,e)=>n({[e]:!0}),disable:(n,e)=>n({[e]:!1}),pixelStorei:(n,e,t)=>n({[e]:t}),hint:(n,e,t)=>n({[e]:t}),useProgram:(n,e)=>n({35725:e}),bindRenderbuffer:(n,e,t)=>n({36007:t}),bindTransformFeedback:(n,e,t)=>n({36389:t}),bindVertexArray:(n,e)=>n({34229:e}),bindFramebuffer:(n,e,t)=>{switch(e){case 36160:return n({36006:t,36010:t});case 36009:return n({36006:t});case 36008:return n({36010:t});default:return null}},bindBuffer:(n,e,t)=>{let i={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[e];return i?n({[i]:t}):{valueChanged:!0}},blendColor:(n,e,t,i,r)=>n({32773:new Float32Array([e,t,i,r])}),blendEquation:(n,e)=>n({32777:e,34877:e}),blendEquationSeparate:(n,e,t)=>n({32777:e,34877:t}),blendFunc:(n,e,t)=>n({32969:e,32968:t,32971:e,32970:t}),blendFuncSeparate:(n,e,t,i,r)=>n({32969:e,32968:t,32971:i,32970:r}),clearColor:(n,e,t,i,r)=>n({3106:new Float32Array([e,t,i,r])}),clearDepth:(n,e)=>n({2931:e}),clearStencil:(n,e)=>n({2961:e}),colorMask:(n,e,t,i,r)=>n({3107:[e,t,i,r]}),cullFace:(n,e)=>n({2885:e}),depthFunc:(n,e)=>n({2932:e}),depthRange:(n,e,t)=>n({2928:new Float32Array([e,t])}),depthMask:(n,e)=>n({2930:e}),frontFace:(n,e)=>n({2886:e}),lineWidth:(n,e)=>n({2849:e}),polygonOffset:(n,e,t)=>n({32824:e,10752:t}),sampleCoverage:(n,e,t)=>n({32938:e,32939:t}),scissor:(n,e,t,i,r)=>n({3088:new Int32Array([e,t,i,r])}),stencilMask:(n,e)=>n({2968:e,36005:e}),stencilMaskSeparate:(n,e,t)=>n({[e===1028?2968:36005]:t}),stencilFunc:(n,e,t,i)=>n({2962:e,2967:t,2963:i,34816:e,36003:t,36004:i}),stencilFuncSeparate:(n,e,t,i,r)=>n({[e===1028?2962:34816]:t,[e===1028?2967:36003]:i,[e===1028?2963:36004]:r}),stencilOp:(n,e,t,i)=>n({2964:e,2965:t,2966:i,34817:e,34818:t,34819:i}),stencilOpSeparate:(n,e,t,i,r)=>n({[e===1028?2964:34817]:t,[e===1028?2965:34818]:i,[e===1028?2966:34819]:r}),viewport:(n,e,t,i,r)=>n({2978:[e,t,i,r]})},ei=(n,e)=>n.isEnabled(e),J_={3042:ei,2884:ei,2929:ei,3024:ei,32823:ei,32926:ei,32928:ei,3089:ei,2960:ei,35977:ei},g2=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068])});function bn(n,e){if(N6(e))return;let t={};for(let r in e){let s=Number(r),o=p2[r];o&&(typeof o=="string"?t[o]=!0:o(n,e[r],s))}let i=n.lumaState?.cache;if(i)for(let r in t){let s=m2[r];s(n,e,i)}}function Vf(n,e=Oc){if(typeof e=="number"){let r=e,s=J_[r];return s?s(n,r):n.getParameter(r)}let t=Array.isArray(e)?e:Object.keys(e),i={};for(let r of t){let s=J_[r];i[r]=s?s(n,Number(r)):n.getParameter(Number(r))}return i}function _2(n){bn(n,Oc)}function N6(n){for(let e in n)return!1;return!0}var Po=C(()=>{ey()});function b2(n,e){if(n===e)return!0;if(y2(n)&&y2(e)&&n.length===e.length){for(let t=0;t{});function x2(n,e){let t=n[e].bind(n);n[e]=function(r){if(r===void 0||g2.has(r))return t(r);let s=vn.get(n);return r in s.cache||(s.cache[r]=t(r)),s.enable?s.cache[r]:t(r)},Object.defineProperty(n[e],"name",{value:`${e}-from-cache`,configurable:!1})}function F6(n,e,t){if(!n[e])return;let i=n[e].bind(n);n[e]=function(...s){let o=vn.get(n),{valueChanged:a,oldValue:c}=t(o._updateCache,...s);return a&&i(...s),c},Object.defineProperty(n[e],"name",{value:`${e}-to-cache`,configurable:!1})}function z6(n){let e=n.useProgram.bind(n);n.useProgram=function(i){let r=vn.get(n);r.program!==i&&(e(i),r.program=i)}}var vn,ty=C(()=>{Po();v2();ey();vn=class{static get(e){return e.lumaState}gl;program=null;stateStack=[];enable=!0;cache=null;log;initialized=!1;constructor(e,t){this.gl=e,this.log=t?.log||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){let e=this.stateStack[this.stateStack.length-1];bn(this.gl,e),this.stateStack.pop()}trackState(e,t){if(this.cache=t?.copyState?Vf(e):Object.assign({},Oc),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.lumaState=this,z6(e);for(let i in Q_){let r=Q_[i];F6(e,i,r)}x2(e,"getParameter"),x2(e,"isEnabled")}_updateCache(e){let t=!1,i,r=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let s in e){let o=e[s],a=this.cache[s];b2(o,a)||(t=!0,i=a,r&&!(s in r)&&(r[s]=a),this.cache[s]=o)}return{valueChanged:t,oldValue:i}}}});function Dc(n){let e=n.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return e._polyfilled??=!1,e.extensions||={},n.luma=e,e}var ny=C(()=>{});function w2(n,e,t){let i="",r=c=>{let l=c.statusMessage;l&&(i||=l)};n.addEventListener("webglcontextcreationerror",r,!1);let s=t.failIfMajorPerformanceCaveat!==!0,o={preserveDrawingBuffer:!0,...t,failIfMajorPerformanceCaveat:!0},a=null;try{a||=n.getContext("webgl2",o),!a&&o.failIfMajorPerformanceCaveat&&(i||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.");let c=!1;if(!a&&s&&(o.failIfMajorPerformanceCaveat=!1,a=n.getContext("webgl2",o),c=!0),a||(a=n.getContext("webgl",{}),a&&(a=null,i||="Your browser only supports WebGL1")),!a)throw i||="Your browser does not support WebGL",new Error(`Failed to create WebGL context: ${i}`);let l=Dc(a);l.softwareRenderer=c;let{onContextLost:u,onContextRestored:f}=e;return n.addEventListener("webglcontextlost",d=>u(d),!1),n.addEventListener("webglcontextrestored",d=>f(d),!1),a}finally{n.removeEventListener("webglcontextcreationerror",r,!1)}}var E2=C(()=>{ny()});function xn(n,e,t){return t[e]===void 0&&(t[e]=n.getExtension(e)||null),t[e]}var Nc=C(()=>{});function S2(n,e){let t=n.getParameter(7936),i=n.getParameter(7937);xn(n,"WEBGL_debug_renderer_info",e);let r=e.WEBGL_debug_renderer_info,s=n.getParameter(r?r.UNMASKED_VENDOR_WEBGL:7936),o=n.getParameter(r?r.UNMASKED_RENDERER_WEBGL:7937),a=s||t,c=o||i,l=n.getParameter(7938),u=P2(a,c),f=U6(a,c),d=$6(a,c);return{type:"webgl",gpu:u,gpuType:d,gpuBackend:f,vendor:a,renderer:c,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function P2(n,e){return/NVIDIA/i.exec(n)||/NVIDIA/i.exec(e)?"nvidia":/INT[E]L/i.exec(n)||/INT[E]L/i.exec(e)?"int_el":/Apple/i.exec(n)||/Apple/i.exec(e)?"apple":/AMD/i.exec(n)||/AMD/i.exec(e)||/ATI/i.exec(n)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(n)||/SwiftShader/i.exec(e)?"software":"unknown"}function U6(n,e){return/Metal/i.exec(n)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(n)||/ANGLE/i.exec(e)?"opengl":"unknown"}function $6(n,e){if(/SwiftShader/i.exec(n)||/SwiftShader/i.exec(e))return"cpu";switch(P2(n,e)){case"apple":return G6(n,e)?"integrated":"unknown";case"int_el":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function G6(n,e){return/Apple (M\d|A\d|GPU)/i.test(`${n} ${e}`)}var C2=C(()=>{Nc()});function Wf(n){switch(n){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(n))}var iy=C(()=>{});function M2(n){return n in Hf}function cy(n,e,t){return A2(n,e,t,new Set)}function A2(n,e,t,i){let r=Hf[e];if(!r||i.has(e))return!1;i.add(e);let s=(r.features||[]).every(o=>A2(n,o,t,i));return i.delete(e),s?(r.extensions||[]).every(o=>!!xn(n,o,t)):!1}function k2(n,e,t){let i=e.create,r=Yf[e.format];r?.gl===void 0&&(i=!1),r?.x&&(i=i&&!!xn(n,r.x,t)),e.format==="stencil8"&&(i=!1);let s=r?.r===!1?!1:r?.r===void 0||cy(n,r.r,t),o=i&&e.render&&s&&X6(n,e.format,t);return{format:e.format,create:i&&e.create,render:o,filter:i&&e.filter,blend:i&&e.blend,store:i&&e.store}}function X6(n,e,t){let i=Yf[e],r=i?.gl;if(r===void 0||i?.x&&!xn(n,i.x,t))return!1;let s=n.getParameter(32873),o=n.getParameter(36006),a=n.createTexture(),c=n.createFramebuffer();if(!a||!c)return!1;let l=0,u=Number(n.getError());for(;u!==l;)u=n.getError();let f=!1;try{if(n.bindTexture(3553,a),n.texStorage2D(3553,1,r,1,1),Number(n.getError())!==l)return!1;n.bindFramebuffer(36160,c),n.framebufferTexture2D(36160,36064,3553,a,0),f=Number(n.checkFramebufferStatus(36160))===36053&&Number(n.getError())===l}finally{n.bindFramebuffer(36160,o),n.deleteFramebuffer(c),n.bindTexture(3553,s),n.deleteTexture(a)}return f}function qf(n){let e=Yf[n],t=Q6(n),i=ft.getInfo(n);return i.compressed&&(e.dataFormat=t),{internalFormat:t,format:e?.dataFormat||K6(i.channels,i.integer,i.normalized,t),type:i.dataType?Wf(i.dataType):e?.types?.[0]||5121,compressed:i.compressed||!1}}function R2(n){switch(ft.getInfo(n).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${n}`)}}function K6(n,e,t,i){if(i===6408||i===6407)return i;switch(n){case"r":return e&&!t?36244:6403;case"rg":return e&&!t?33320:33319;case"rgb":return e&&!t?36248:6407;case"rgba":return e&&!t?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function Q6(n){let t=Yf[n]?.gl;if(t===void 0)throw new Error(`Unsupported texture format ${n}`);return t}var Fc,zc,Co,To,V6,W6,j6,H6,Y6,q6,T2,L2,ry,sy,oy,ay,jf,Z6,Hf,Yf,Lo=C(()=>{J();Nc();iy();Fc="WEBGL_compressed_texture_s3tc",zc="WEBGL_compressed_texture_s3tc_srgb",Co="EXT_texture_compression_rgtc",To="EXT_texture_compression_bptc",V6="WEBGL_compressed_texture_etc",W6="WEBGL_compressed_texture_astc",j6="WEBGL_compressed_texture_etc1",H6="WEBGL_compressed_texture_pvrtc",Y6="WEBGL_compressed_texture_atc",q6="EXT_texture_norm16",T2="EXT_render_snorm",L2="EXT_color_buffer_float",ry="snorm8-renderable-webgl",sy="norm16-renderable-webgl",oy="snorm16-renderable-webgl",ay="float16-renderable-webgl",jf="float32-renderable-webgl",Z6="rgb9e5ufloat-renderable-webgl",Hf={"float32-renderable-webgl":{extensions:[L2]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[T2]},"norm16-webgl":{extensions:[q6]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[T2]},"float32-filterable":{extensions:["OES_texture_float_linear"]},"float16-filterable-webgl":{extensions:["OES_texture_half_float_linear"]},"texture-filterable-anisotropic-webgl":{extensions:["EXT_texture_filter_anisotropic"]},"texture-blend-float-webgl":{extensions:["EXT_float_blend"]},"texture-compression-bc":{extensions:[Fc,zc,Co,To]},"texture-compression-bc5-webgl":{extensions:[Co]},"texture-compression-bc7-webgl":{extensions:[To]},"texture-compression-etc2":{extensions:[V6]},"texture-compression-astc":{extensions:[W6]},"texture-compression-etc1-webgl":{extensions:[j6]},"texture-compression-pvrtc-webgl":{extensions:[H6]},"texture-compression-atc-webgl":{extensions:[Y6]}};Yf={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:ry},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:ry},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0,r:ay},r16unorm:{gl:33322,rb:!0,r:sy},r16snorm:{gl:36760,r:oy},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759,r:ry},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:ay},rg16unorm:{gl:33324,r:sy},rg16snorm:{gl:36761,r:oy},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:jf},rgb9e5ufloat:{gl:35901,r:Z6},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852,r:!1},"rgb16snorm-webgl":{gl:36762,r:!1},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0,r:jf},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:ay},rgba16unorm:{gl:32859,rb:!0,r:sy},rgba16snorm:{gl:36763,r:oy},"rgb32float-webgl":{gl:34837,x:L2,r:jf,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:jf},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:Fc},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:zc},"bc1-rgba-unorm":{gl:33777,x:Fc},"bc1-rgba-unorm-srgb":{gl:35916,x:zc},"bc2-rgba-unorm":{gl:33778,x:Fc},"bc2-rgba-unorm-srgb":{gl:35918,x:zc},"bc3-rgba-unorm":{gl:33779,x:Fc},"bc3-rgba-unorm-srgb":{gl:35919,x:zc},"bc4-r-unorm":{gl:36283,x:Co},"bc4-r-snorm":{gl:36284,x:Co},"bc5-rg-unorm":{gl:36285,x:Co},"bc5-rg-snorm":{gl:36286,x:Co},"bc6h-rgb-ufloat":{gl:36495,x:To},"bc6h-rgb-float":{gl:36494,x:To},"bc7-rgba-unorm":{gl:36492,x:To},"bc7-rgba-unorm-srgb":{gl:36493,x:To},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37816},"astc-10x5-unorm-srgb":{gl:37848},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rgb2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}}});var I2,Zf,B2=C(()=>{J();Nc();Lo();I2={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","html-in-canvas":n=>Om()&&typeof n.texElementImage2D=="function","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},Zf=class extends Ta{gl;extensions;testedFeatures=new Set;constructor(e,t,i){super([],i),this.gl=e,this.extensions=t,xn(e,"EXT_color_buffer_float",t)}*[Symbol.iterator](){let e=this.getFeatures();for(let t of e)this.has(t)&&(yield t);return[]}has(e){return this.disabledFeatures?.[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),M2(e)&&cy(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){let e=this.getFeatures().filter(t=>t!=="polygon-mode-webgl");for(let t of e)this.has(t)}getFeatures(){return[...Object.keys(I2),...Object.keys(Hf)]}getWebGLFeature(e){let t=I2[e];return typeof t=="string"?!!xn(this.gl,t,this.extensions):typeof t=="function"?t(this.gl):!!t}}});var Xf,O2=C(()=>{J();Xf=class extends Ca{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxBindGroupsPlusVertexBuffers(){return 0}get maxBindingsPerBindGroup(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageBuffersInVertexStage(){return 0}get maxStorageBuffersInFragmentStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxStorageTexturesInVertexStage(){return 0}get maxStorageTexturesInFragmentStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get maxBufferSize(){return Number.MAX_SAFE_INTEGER}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxColorAttachments(){return this.getParameter(36063)}get maxColorAttachmentBytesPerSample(){return 0}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]||0}}});function J6(n){return n<34069?n+34069:n}function ez(n){switch(n){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${n}`}}var ti,Kf=C(()=>{J();Lo();ti=class extends Rr{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(e,t){super(e,t);let i=t.handle,r=i===null;this.device=e,this.gl=e.gl,this.handle=i||r?i:this.gl.createFramebuffer(),r||(e._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),t.handle||(this.autoCreateAttachmentTextures(),this.updateAttachments()))}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&!this.props.handle&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){let e=this.gl.bindFramebuffer(36160,this.handle);for(let t=0;t{J();Kf();Qf=class extends La{device;handle=null;_framebuffer=null;get[Symbol.toStringTag](){return"WebGLCanvasContext"}constructor(e,t){super(t),this.device=e,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._configureDevice()}_configureDevice(){(this.drawingBufferWidth!==this._framebuffer?.width||this.drawingBufferHeight!==this._framebuffer?.height)&&this._framebuffer?.resize([this.drawingBufferWidth,this.drawingBufferHeight])}_getCurrentFramebuffer(){return this._framebuffer||=new ti(this.device,{id:"canvas-context-framebuffer",handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}}});var Jf,N2=C(()=>{J();Jf=class extends Ma{device;handle=null;context2d;get[Symbol.toStringTag](){return"WebGLPresentationContext"}constructor(e,t={}){super(t),this.device=e;let i=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw new Error(`${i}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);let s=this.canvas.getContext("2d");if(!s)throw new Error(`${i}: Failed to create 2d presentation context`);this.context2d=s,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();let e=this.device.getDefaultCanvasContext(),[t,i]=e.getDrawingBufferSize();if(!(this.drawingBufferWidth===0||this.drawingBufferHeight===0||t===0||i===0||e.canvas.width===0||e.canvas.height===0)){if(t!==this.drawingBufferWidth||i!==this.drawingBufferHeight||e.canvas.width!==this.drawingBufferWidth||e.canvas.height!==this.drawingBufferHeight)throw new Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${t}x${i} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(e.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(e){let t=this.device.getDefaultCanvasContext();return t.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),t.getCurrentFramebuffer(e)}}});function F2(n="id"){ly[n]=ly[n]||1;let e=ly[n]++;return`${n}-${e}`}var ly,z2=C(()=>{ly={}});function tz(n){return n&ie.INDEX?34963:n&ie.VERTEX?34962:n&ie.UNIFORM?35345:34962}function nz(n){return n&ie.INDEX||n&ie.VERTEX?35044:n&ie.UNIFORM?35048:35044}var wn,ed=C(()=>{J();wn=class extends ie{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength=0;bytesUsed=0;constructor(e,t={}){super(e,t),this.device=e,this.gl=this.device.gl;let i=typeof t=="object"?t.handle:void 0;this.handle=i||this.gl.createBuffer(),e._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=tz(this.props.usage),this.glUsage=nz(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,t.data?this._initWithData(t.data,t.byteOffset,t.byteLength):this._initWithByteLength(t.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Buffer"):(this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle)),this.destroyed=!0,this.handle=null)}_initWithData(e,t=0,i=e.byteLength+t){let r=this.glTarget;this.gl.bindBuffer(r,this.handle),this.gl.bufferData(r,i,this.glUsage),this.gl.bufferSubData(r,t,e),this.gl.bindBuffer(r,null),this.bytesUsed=i,this.byteLength=i,this._setDebugData(e,t,i),this.props.handle?this.trackReferencedMemory(i,"Buffer"):this.trackAllocatedMemory(i)}_initWithByteLength(e){let t=e;e===0&&(t=new Float32Array(0));let i=this.glTarget;return this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,t,this.glUsage),this.gl.bindBuffer(i,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.props.handle?this.trackReferencedMemory(e,"Buffer"):this.trackAllocatedMemory(e),this}write(e,t=0){let i=ArrayBuffer.isView(e)?e:new Uint8Array(e),r=0,s=void 0,o=36663;this.gl.bindBuffer(o,this.handle),r!==0||s!==void 0?this.gl.bufferSubData(o,t,i,r,s):this.gl.bufferSubData(o,t,i),this.gl.bindBuffer(o,null),this._setDebugData(e,t,e.byteLength)}async mapAndWriteAsync(e,t=0,i=this.byteLength-t){let r=new ArrayBuffer(i);await e(r,"copied"),this.write(r,t)}async readAsync(e=0,t){return this.readSyncWebGL(e,t)}async mapAndReadAsync(e,t=0,i){let r=await this.readAsync(t,i);return await e(r.buffer,"copied")}readSyncWebGL(e=0,t){t=t??this.byteLength-e;let i=new Uint8Array(t),r=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,i,r,t),this.gl.bindBuffer(36662,null),this._setDebugData(i,e,t),i}}});function U2(n){let e=n.split(/\r?\n/),t=[];for(let i of e){if(i.length<=1)continue;let r=i.trim(),s=i.split(":"),o=s[0]?.trim();if(s.length===2){let[h,p]=s;if(!h||!p){t.push({message:r,type:td(o||"info"),lineNum:0,linePos:0});continue}t.push({message:p.trim(),type:td(h),lineNum:0,linePos:0});continue}let[a,c,l,...u]=s;if(!a||!c||!l){t.push({message:s.slice(1).join(":").trim()||r,type:td(o||"info"),lineNum:0,linePos:0});continue}let f=parseInt(l,10);Number.isNaN(f)&&(f=0);let d=parseInt(c,10);Number.isNaN(d)&&(d=0),t.push({message:u.join(":").trim(),type:td(a),lineNum:f,linePos:d})}return t}function td(n){let e=["warning","error","info"],t=n.toLowerCase();return e.includes(t)?t:"info"}var $2=C(()=>{});function iz(n){return n.split(/\r?\n/).find(e=>e.trim())?.trim()}var nd,G2=C(()=>{J();$2();nd=class extends kr{device;handle;_compilationInfoLog="";constructor(e,t){super(e,t),this.device=e;let i=this.props.handle;switch(this.props.stage){case"vertex":this.handle=i||this.device.gl.createShader(35633);break;case"fragment":this.handle=i||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}e._setWebGLDebugMetadata(this.handle,this,{spector:this.props});let r=this._compile(this.source);r&&typeof r.catch=="function"&&r.catch(()=>{this.compilationStatus="error"})}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this._getCompilationInfoLog();return e?U2(e):[]}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)||null}_compile(e){e=e.startsWith("#version ")?e:`#version 300 es ${e}`;let{gl:t}=this.device;if(t.shaderSource(this.handle,e),t.compileShader(this.handle),!this.device.props.debug){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus==="error")throw new Error(this._getCompilationErrorMessage(e));return}return N.once(1,"Shader compilation is asynchronous")(),this._waitForCompilationComplete().then(()=>{N.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()})}async _waitForCompilationComplete(){let e=async r=>await new Promise(s=>setTimeout(s,r));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error",this.compilationStatus==="error"&&this._getCompilationInfoLog()}_getCompilationErrorMessage(e){let t=`${this.props.stage} shader ${this.props.id}`,i=iz(this._getCompilationInfoLog()),r=this.getCompilationInfoSync(),s=r.find(u=>u.type==="error"&&u.message.trim())||r.find(u=>u.message.trim())||r.find(u=>u.type==="error")||r[0];if(!s)return i?`GLSL compilation errors in ${t}: ${i}`:`GLSL compilation errors in ${t}: WebGL did not provide a shader compiler log`;let o=s.lineNum?e.split(/\r?\n/)[s.lineNum-1]?.trim():void 0,a=s.lineNum?` line ${s.lineNum}`:"",c=o?` Source: ${o}`:"",l=s.message.trim()||i||"WebGL did not provide a shader compiler log";return`GLSL compilation errors in ${t}:${a}: ${l}${c}`}_getCompilationInfoLog(){let e=this.device.gl.getShaderInfoLog(this.handle)?.trim();return e&&(this._compilationInfoLog=e),this._compilationInfoLog}}});function W2(n,e,t,i){if(az(e))return i(n);let r=n;r.pushState();try{return rz(n,e),bn(r.gl,t),i(n)}finally{r.popState()}}function rz(n,e){let t=n,{gl:i}=t;if(e.cullMode)switch(e.cullMode){case"none":i.disable(2884);break;case"front":i.enable(2884),i.cullFace(1028);break;case"back":i.enable(2884),i.cullFace(1029);break}if(e.frontFace&&i.frontFace(ss("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&n.features.has("depth-clip-control")&&i.enable(34383),e.depthBias!==void 0&&(i.enable(32823),i.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&n.features.has("provoking-vertex-webgl")){let s=t.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,o=ss("provokingVertex",e.provokingVertex,{first:36429,last:36430});s?.provokingVertexWEBGL(o)}if((e.polygonMode||e.polygonOffsetLine)&&n.features.has("polygon-mode-webgl")){if(e.polygonMode){let s=t.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,o=ss("polygonMode",e.polygonMode,{fill:6914,line:6913});s?.polygonModeWEBGL(1028,o),s?.polygonModeWEBGL(1029,o)}e.polygonOffsetLine&&i.enable(10754)}if(n.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&i.enable(12288),e.clipDistance1&&i.enable(12289),e.clipDistance2&&i.enable(12290),e.clipDistance3&&i.enable(12291),e.clipDistance4&&i.enable(12292),e.clipDistance5&&i.enable(12293),e.clipDistance6&&i.enable(12294),e.clipDistance7&&i.enable(12295)),e.depthWriteEnabled!==void 0&&i.depthMask(oz("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?i.enable(2929):i.disable(2929),i.depthFunc(rd("depthCompare",e.depthCompare))),e.clearDepth!==void 0&&i.clearDepth(e.clearDepth),e.stencilWriteMask){let r=e.stencilWriteMask;i.stencilMaskSeparate(1028,r),i.stencilMaskSeparate(1029,r)}if(e.stencilReadMask&&N.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){let r=e.stencilReadMask||4294967295,s=rd("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?i.enable(2960):i.disable(2960),i.stencilFuncSeparate(1028,s,0,r),i.stencilFuncSeparate(1029,s,0,r)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){let r=uy("stencilPassOperation",e.stencilPassOperation),s=uy("stencilFailOperation",e.stencilFailOperation),o=uy("stencilDepthFailOperation",e.stencilDepthFailOperation);i.stencilOpSeparate(1028,s,o,r),i.stencilOpSeparate(1029,s,o,r)}switch(e.blend){case!0:i.enable(3042);break;case!1:i.disable(3042);break;default:}if(e.blendColorOperation||e.blendAlphaOperation){let r=V2("blendColorOperation",e.blendColorOperation||"add"),s=V2("blendAlphaOperation",e.blendAlphaOperation||"add");i.blendEquationSeparate(r,s);let o=id("blendColorSrcFactor",e.blendColorSrcFactor||"one"),a=id("blendColorDstFactor",e.blendColorDstFactor||"zero"),c=id("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),l=id("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");i.blendFuncSeparate(o,a,c,l)}}function rd(n,e){return ss(n,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function uy(n,e){return ss(n,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function V2(n,e){return ss(n,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function id(n,e,t="color"){return ss(n,e,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:t==="color"?32769:32771,"one-minus-constant":t==="color"?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function sz(n,e){return`Illegal parameter ${e} for ${n}`}function ss(n,e,t){if(!(e in t))throw new Error(sz(n,e));return t[e]}function oz(n,e){return e}function az(n){let e=!0;for(let t in n){e=!1;break}return e}var fy=C(()=>{J();Po()});function sd(n){let e={};return n.addressModeU&&(e[10242]=dy(n.addressModeU)),n.addressModeV&&(e[10243]=dy(n.addressModeV)),n.addressModeW&&(e[32882]=dy(n.addressModeW)),n.magFilter&&(e[10240]=hy(n.magFilter)),(n.minFilter||n.mipmapFilter)&&(e[10241]=cz(n.minFilter||"linear",n.mipmapFilter)),n.lodMinClamp!==void 0&&(e[33082]=n.lodMinClamp),n.lodMaxClamp!==void 0&&(e[33083]=n.lodMaxClamp),n.type==="comparison-sampler"&&(e[34892]=34894),n.compare&&(e[34893]=rd("compare",n.compare)),n.maxAnisotropy&&(e[34046]=n.maxAnisotropy),e}function dy(n){switch(n){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function hy(n){switch(n){case"nearest":return 9728;case"linear":return 9729}}function cz(n,e="none"){if(!e)return hy(n);switch(e){case"none":return hy(n);case"nearest":switch(n){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(n){case"nearest":return 9986;case"linear":return 9987}}}var py=C(()=>{fy()});var od,j2=C(()=>{J();py();od=class extends Mr{device;handle;parameters;constructor(e,t){super(e,t),this.device=e,this.parameters=sd(t),this.handle=t.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(let[t,i]of Object.entries(e)){let r=Number(t);switch(r){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,r,i);break;default:this.device.gl.samplerParameteri(this.handle,r,i);break}}}}});function En(n,e,t){if(lz(e))return t(n);let{nocatch:i=!0}=e,r=vn.get(n);r.push(),bn(n,e);let s;if(i)s=t(n),r.pop();else try{s=t(n)}finally{r.pop()}return s}function lz(n){for(let e in n)return!1;return!0}var ad=C(()=>{Po();ty()});var ni,my=C(()=>{J();ni=class extends Ar{device;gl;handle;texture;constructor(e,t){super(e,{...me.defaultProps,...t}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=t.texture}}});function cd(n){return uz[n]}var uz,gy=C(()=>{uz={5124:"sint32",5125:"uint32",5122:"sint16",5123:"uint16",5120:"sint8",5121:"uint8",5126:"float32",5131:"float16",33635:"uint16",32819:"uint16",32820:"uint16",33640:"uint32",35899:"uint32",35902:"uint32",34042:"uint32",36269:"uint32"}});function fz(n,e=0){return e?new n.constructor(n.buffer,n.byteOffset+e,(n.byteLength-e)/n.BYTES_PER_ELEMENT):n}function dz(n,e){if(e%n.BYTES_PER_ELEMENT!==0)throw new Error(`Texture byteOffset ${e} must align to typed array element size ${n.BYTES_PER_ELEMENT}`);return e/n.BYTES_PER_ELEMENT}function hz(n){switch(n){case"1d":break;case"2d":return 3553;case"3d":return 32879;case"cube":return 34067;case"2d-array":return 35866;case"cube-array":break}throw new Error(n)}function Uc(n,e,t){return e==="cube"?34069+t:n}var ii,ld=C(()=>{J();Lo();py();ad();my();gy();ii=class extends me{device;gl;handle;sampler=void 0;view;glTarget;glFormat;glType;glInternalFormat;compressed;_textureUnit=0;_framebuffer=null;_framebufferAttachmentKey=null;constructor(e,t){super(e,t,{byteAlignment:1}),this.device=e,this.gl=this.device.gl;let i=qf(this.props.format);if(this.glTarget=hz(this.props.dimension),this.glInternalFormat=i.internalFormat,this.glFormat=i.format,this.glType=i.type,this.compressed=i.compressed,this.isHandleBorrowed&&this.props.handle===void 0)throw new Error("Borrowed WebGL textures require a texture handle");if(this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),!this.isHandleBorrowed){this.gl.bindTexture(this.glTarget,this.handle);let{dimension:r,width:s,height:o,depth:a,mipLevels:c,glTarget:l,glInternalFormat:u}=this;if(!this.compressed)switch(r){case"2d":case"cube":this.gl.texStorage2D(l,c,u,s,o);break;case"2d-array":case"3d":this.gl.texStorage3D(l,c,u,s,o,a);break;default:throw new Error(r)}this.gl.bindTexture(this.glTarget,null),this._initializeData(t.data)}this.ownsHandle?this.trackAllocatedMemory(this.getAllocatedByteLength(),"Texture"):this.trackReferencedMemory(this.getAllocatedByteLength(),"Texture"),this.isHandleBorrowed||this.setSampler(this.props.sampler),this.view=new ni(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this._framebuffer?.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.ownsHandle?(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory("Texture")):this.trackDeallocatedReferencedMemory("Texture"),this.destroyed=!0)}createView(e){return new ni(this.device,{...e,texture:this})}clone(e){if(this.isHandleBorrowed&&e&&(e.width!==this.width||e.height!==this.height))throw new Error(`Cannot resize borrowed read-only ${this}`);return super.clone(e)}setSampler(e={}){this._assertWritable("set sampler parameters on"),super.setSampler(e);let t=sd(this.sampler.props);this._setSamplerParameters(t)}copyExternalImage(e){this._assertWritable("copy external image data into");let t=this._normalizeCopyExternalImageOptions(e);if(t.sourceX||t.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");let{glFormat:i,glType:r}=this,{image:s,depth:o,mipLevel:a,x:c,y:l,z:u,width:f,height:d}=t,h=Uc(this.glTarget,this.dimension,u),p=t.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),En(this.gl,p,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(h,a,c,l,f,d,i,r,s);break;case"2d-array":case"3d":this.gl.texSubImage3D(h,a,c,l,u,f,d,o,i,r,s);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:t.width,height:t.height}}copyElementImage(e){this._assertWritable("copy element image data into");let t=this._normalizeCopyElementImageOptions(e),{glFormat:i}=this,{element:r,depth:s,mipLevel:o,sourceX:a,sourceY:c,sourceWidth:l,sourceHeight:u,x:f,y:d,z:h,width:p,height:m}=t,g=Uc(this.glTarget,this.dimension,h),v=t.flipY?{37440:!0}:{},y=this.gl;if(s!==1||this.dimension!=="2d"&&this.dimension!=="cube")throw new Error(`${this} copyElementImage only supports 2d and cube textures on WebGL`);if(o!==0||f!==0||d!==0)throw new Error(`${this} copyElementImage only supports full base-level uploads on WebGL`);if(typeof y.texElementImage2D!="function")throw new Error(`${this} copyElementImage is not supported by this WebGL implementation`);return this.gl.bindTexture(this.glTarget,this.handle),En(this.gl,v,()=>{y.texElementImage2D?.(g,i,r,{sx:a,sy:c,swidth:l??p,sheight:u??m,width:p,height:m})}),this.gl.bindTexture(this.glTarget,null),{width:t.width,height:t.height}}copyImageData(e){super.copyImageData(e)}readBuffer(e={},t){if(!t)throw new Error(`${this} readBuffer requires a destination buffer`);let i=this._getSupportedColorReadOptions(e),r=e.byteOffset??0,s=this.computeMemoryLayout(i);if(t.byteLength{this.gl.readPixels(i.x,i.y,i.width,i.height,this.glFormat,this.glType,r+a)})}finally{this.gl.bindBuffer(35051,null)}return t}async readDataAsync(e={}){throw new Error(`${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`)}writeBuffer(e,t={}){this._assertWritable("write buffer data into");let i=this._normalizeTextureWriteOptions(t),{width:r,height:s,depthOrArrayLayers:o,mipLevel:a,byteOffset:c,x:l,y:u,z:f}=i,{glFormat:d,glType:h,compressed:p}=this,m=Uc(this.glTarget,this.dimension,f);if(p)throw new Error("writeBuffer for compressed textures is not implemented in WebGL");let{bytesPerPixel:g}=this.device.getTextureFormatInfo(this.format),v=g?i.bytesPerRow/g:void 0,y={3317:this.byteAlignment,...v!==void 0?{3314:v}:{},32878:i.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,e.handle),En(this.gl,y,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(m,a,l,u,r,s,d,h,c);break;case"2d-array":case"3d":this.gl.texSubImage3D(m,a,l,u,f,r,s,o,d,h,c);break;default:}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(e,t={}){this._assertWritable("write data into");let i=this._normalizeTextureWriteOptions(t),r=ArrayBuffer.isView(e)?e:new Uint8Array(e),{width:s,height:o,depthOrArrayLayers:a,mipLevel:c,x:l,y:u,z:f,byteOffset:d}=i,{glFormat:h,glType:p,compressed:m}=this,g=Uc(this.glTarget,this.dimension,f),v;if(!m){let{bytesPerPixel:T}=this.device.getTextureFormatInfo(this.format);T&&(v=i.bytesPerRow/T)}let y=this.compressed?{}:{3317:this.byteAlignment,...v!==void 0?{3314:v}:{},32878:i.rowsPerImage},b=dz(r,d),x=m?fz(r,d):r,E=this._getMipLevelSize(c),w=l===0&&u===0&&f===0&&s===E.width&&o===E.height&&a===E.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),En(this.gl,y,()=>{switch(this.dimension){case"2d":case"cube":m?w?this.gl.compressedTexImage2D(g,c,h,s,o,0,x):this.gl.compressedTexSubImage2D(g,c,l,u,s,o,h,x):this.gl.texSubImage2D(g,c,l,u,s,o,h,p,r,b);break;case"2d-array":case"3d":m?w?this.gl.compressedTexImage3D(g,c,h,s,o,a,0,x):this.gl.compressedTexSubImage3D(g,c,l,u,f,s,o,a,h,x):this.gl.texSubImage3D(g,c,l,u,f,s,o,a,h,p,r,b);break;default:}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(e,t){return 1}_getFramebuffer(){return this._framebuffer||=this.device.createFramebuffer({id:`framebuffer-for-${this.id}`,width:this.width,height:this.height,colorAttachments:[this]}),this._framebuffer}readDataSyncWebGL(e={}){let t=this._getSupportedColorReadOptions(e),i=this.computeMemoryLayout(t),r=cd(this.glType),s=Lr(r),o=new s(i.byteLength/s.BYTES_PER_ELEMENT);return this._readColorTextureLayers(t,i,a=>{let c=new s(o.buffer,o.byteOffset+a,i.bytesPerImage/s.BYTES_PER_ELEMENT);this.gl.readPixels(t.x,t.y,t.width,t.height,this.glFormat,this.glType,c)}),o.buffer}_readColorTextureLayers(e,t,i){let r=this._getFramebuffer(),s=t.bytesPerRow/t.bytesPerPixel,o={3333:this.byteAlignment,...s!==e.width?{3330:s}:{}},a=this.gl.getParameter(3074),c=this.gl.bindFramebuffer(36160,r.handle);try{this.gl.readBuffer(36064),En(this.gl,o,()=>{for(let l=0;l=2&&N.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(e))(),this.gl.bindTexture(this.glTarget,this.handle);for(let[t,i]of Object.entries(e)){let r=Number(t),s=i;switch(r){case 33082:case 33083:this.gl.texParameterf(this.glTarget,r,s);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,r,s);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,r,s);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,r,s);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,r,s);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(e){let{gl:t}=this;return e!==void 0&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,this.handle),e}_unbind(e){let{gl:t}=this;return e!==void 0&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,null),e}_assertWritable(e){if(this.isHandleBorrowed)throw new Error(`Cannot ${e} borrowed read-only ${this}`)}}});function H2(n,e,t,i){let r=n,s=i;s===!0&&(s=1),s===!1&&(s=0);let o=typeof s=="number"?[s]:s;switch(t){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof i!="number")throw new Error("samplers must be set to integers");return n.uniform1i(e,i);case 5126:return n.uniform1fv(e,o);case 35664:return n.uniform2fv(e,o);case 35665:return n.uniform3fv(e,o);case 35666:return n.uniform4fv(e,o);case 5124:return n.uniform1iv(e,o);case 35667:return n.uniform2iv(e,o);case 35668:return n.uniform3iv(e,o);case 35669:return n.uniform4iv(e,o);case 35670:return n.uniform1iv(e,o);case 35671:return n.uniform2iv(e,o);case 35672:return n.uniform3iv(e,o);case 35673:return n.uniform4iv(e,o);case 5125:return r.uniform1uiv(e,o,1);case 36294:return r.uniform2uiv(e,o,2);case 36295:return r.uniform3uiv(e,o,3);case 36296:return r.uniform4uiv(e,o,4);case 35674:return n.uniformMatrix2fv(e,!1,o);case 35675:return n.uniformMatrix3fv(e,!1,o);case 35676:return n.uniformMatrix4fv(e,!1,o);case 35685:return r.uniformMatrix2x3fv(e,!1,o);case 35686:return r.uniformMatrix2x4fv(e,!1,o);case 35687:return r.uniformMatrix3x2fv(e,!1,o);case 35688:return r.uniformMatrix3x4fv(e,!1,o);case 35689:return r.uniformMatrix4x2fv(e,!1,o);case 35690:return r.uniformMatrix4x3fv(e,!1,o)}throw new Error("Illegal uniform")}var Y2=C(()=>{});function q2(n){return mz[n]}function ud(n){return pz[n]}function fd(n){return!!X2[n]}function Z2(n){return X2[n]}var pz,X2,mz,dd=C(()=>{pz={5126:"f32",35664:"vec2",35665:"vec3",35666:"vec4",5124:"i32",35667:"vec2",35668:"vec3",35669:"vec4",5125:"u32",36294:"vec2",36295:"vec3",36296:"vec4",35670:"f32",35671:"vec2",35672:"vec3",35673:"vec4",35674:"mat2x2",35685:"mat2x3",35686:"mat2x4",35687:"mat3x2",35675:"mat3x3",35688:"mat3x4",35689:"mat4x2",35690:"mat4x3",35676:"mat4x4"},X2={35678:{viewDimension:"2d",sampleType:"float"},35680:{viewDimension:"cube",sampleType:"float"},35679:{viewDimension:"3d",sampleType:"float"},35682:{viewDimension:"3d",sampleType:"depth"},36289:{viewDimension:"2d-array",sampleType:"float"},36292:{viewDimension:"2d-array",sampleType:"depth"},36293:{viewDimension:"cube",sampleType:"float"},36298:{viewDimension:"2d",sampleType:"sint"},36299:{viewDimension:"3d",sampleType:"sint"},36300:{viewDimension:"cube",sampleType:"sint"},36303:{viewDimension:"2d-array",sampleType:"uint"},36306:{viewDimension:"2d",sampleType:"uint"},36307:{viewDimension:"3d",sampleType:"uint"},36308:{viewDimension:"cube",sampleType:"uint"},36311:{viewDimension:"2d-array",sampleType:"uint"}},mz={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126}});function Q2(n,e,t={}){let i={attributes:[],bindings:[]};i.attributes=gz(n,e);let r=bz(n,e,t);for(let c of r){let l=c.uniforms.map(u=>({name:u.name,format:u.format,byteOffset:u.byteOffset,byteStride:u.byteStride,arrayLength:u.arrayLength}));i.bindings.push({type:"uniform",name:c.name,group:0,location:c.location,visibility:(c.vertex?1:0)|(c.fragment?2:0),minBindingSize:c.byteLength,uniforms:l})}let s=yz(n,e),o=0;for(let c of s)if(fd(c.type)){let{viewDimension:l,sampleType:u}=Z2(c.type);i.bindings.push({type:"texture",name:c.name,group:0,location:o,viewDimension:l,sampleType:u}),c.textureUnit=o,o+=1}s.length&&(i.uniforms=s);let a=_z(n,e);return a?.length&&(i.varyings=a),i}function gz(n,e){let t=[],i=n.getProgramParameter(e,35721);for(let r=0;r=0){let l=ud(a),u=/instance/i.test(o)?"instance":"vertex";t.push({name:o,location:c,stepMode:u,type:l})}}return t.sort((r,s)=>r.location-s.location),t}function _z(n,e){let t=[],i=n.getProgramParameter(e,35971);for(let r=0;rr.location-s.location),t}function yz(n,e){let t=[],i=n.getProgramParameter(e,35718);for(let r=0;r1)for(let h=0;ho.location-a.location),i}function vz(n,e){for(let t of n.uniforms){let i=e.uniforms.find(r=>t.name===r.name||t.name.endsWith(`.${r.name}`));if(!i)throw new Error(`Failed to validate WebGL uniform block "${e.name}": reflected unexpected member "${t.name}"`);if(t.format!==i.format||t.arrayLength!==i.arrayLength||t.byteOffset!==i.byteOffset||t.byteStride!==i.byteStride)throw new Error(`Failed to validate WebGL uniform block "${e.name}": reflected layout for "${t.name}" does not match supplied std140 metadata`)}}function xz(n,e,t){let i=new Map;for(let s of t.uniformBlockLayouts||[])i.set(s.name,Ez(s));for(let s of t.shaderLayout?.bindings||[])Pz(s)&&i.set(s.name,s);let r=new Map;for(let s of i.values()){let o=wz(n,e,s.name);if(!o)continue;let{blockIndex:a,blockName:c}=o;if(r.has(a))throw new Error(`Multiple supplied uniform block layouts resolve to active WebGL block "${c}"`);r.set(a,{name:c,location:a,byteLength:s.minBindingSize,vertex:!!(s.visibility&&s.visibility&1),fragment:!!(s.visibility&&s.visibility&2),uniformCount:s.uniforms.length,uniforms:s.uniforms.map(l=>({...l}))})}return r}function wz(n,e,t){let i=t.endsWith("Uniforms")?[t,t.slice(0,-8)]:[t,`${t}Uniforms`];for(let r of i){let s=n.getUniformBlockIndex(e,r);if(s!==4294967295){if(!Number.isInteger(s)||s<0)throw new Error(`Failed to resolve WebGL uniform block "${r}": getUniformBlockIndex returned ${String(s)}`);return{blockIndex:s,blockName:r}}}return null}function K2(n,e,t,i){let r=i||n.getActiveUniformBlockName(e,t);if(!r)throw new Error(`Failed to reflect WebGL uniform block at index ${t}: missing block name`);let s=(b,x)=>{let E=n.getActiveUniformBlockParameter(e,t,b);if(E==null)throw new Error(`Failed to reflect WebGL uniform block "${r}": ${x} returned null`);return E},o=os(s(35391,"UNIFORM_BLOCK_BINDING"),r,"UNIFORM_BLOCK_BINDING",0),a=os(s(35392,"UNIFORM_BLOCK_DATA_SIZE"),r,"UNIFORM_BLOCK_DATA_SIZE",0),c=os(s(35394,"UNIFORM_BLOCK_ACTIVE_UNIFORMS"),r,"UNIFORM_BLOCK_ACTIVE_UNIFORMS",0),l=J2(s(35395,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES"),r,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",c),u=$c(n,e,l,35383,"UNIFORM_TYPE",r,c),f=$c(n,e,l,35384,"UNIFORM_SIZE",r,c),d=$c(n,e,l,35386,"UNIFORM_BLOCK_INDEX",r,c),h=$c(n,e,l,35387,"UNIFORM_OFFSET",r,c),p=$c(n,e,l,35388,"UNIFORM_ARRAY_STRIDE",r,c),m=[];for(let b=0;bb.name.split(".")[0]).filter(b=>!!b)),y=g.name.replace(/Uniforms$/,"");if(v.size===1&&!v.has(g.name)&&!v.has(y)){let[b]=v;N.warn(`Uniform block "${g.name}" uses GLSL instance "${b}". luma.gl binds uniform buffers by block name ("${g.name}") and alias ("${y}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}return g}function $c(n,e,t,i,r,s,o){let a=n.getActiveUniforms(e,t,i);if(a===null)throw new Error(`Failed to reflect WebGL uniform block "${s}": ${r} returned null`);return J2(a,s,r,o)}function J2(n,e,t,i){if(!Array.isArray(n)&&!ArrayBuffer.isView(n))throw new Error(`Failed to reflect WebGL uniform block "${e}": ${t} returned a non-array value`);let r=Array.from(n);if(r.length!==i||r.some(s=>!Number.isInteger(s)))throw new Error(`Failed to reflect WebGL uniform block "${e}": ${t} returned ${r.length} invalid values, expected ${i}`);return r}function os(n,e,t,i){if(!Number.isInteger(n)||n{if(typeof o=="string"){let a=e[s];if(!a)throw new Error(`Missing std140 layout field ${s}`);t.push({name:s,format:a.shaderType,arrayLength:1,byteOffset:a.offset*4,byteStride:0});return}if(Array.isArray(o)){r(s,o[0],o[1]);return}for(let[a,c]of Object.entries(o))i(`${s}.${a}`,c)},r=(s,o,a)=>{if(typeof o=="string"){let c=e[`${s}[0]`],l=a>1?e[`${s}[1]`]:void 0;if(!c)throw new Error(`Missing std140 array layout field ${s}[0]`);t.push({name:`${s}[0]`,format:c.shaderType,arrayLength:a,byteOffset:c.offset*4,byteStride:l?(l.offset-c.offset)*4:0});return}if(Array.isArray(o))throw new Error(`Nested uniform arrays are not supported for ${s}`);for(let[c,l]of Object.entries(o)){if(typeof l!="string")throw new Error(`Composite uniform array members are not supported for ${s}`);let u=`${s}[0].${c}`,f=`${s}[1].${c}`,d=e[u],h=a>1?e[f]:void 0;if(!d)throw new Error(`Missing std140 array layout field ${u}`);t.push({name:u,format:d.shaderType,arrayLength:a,byteOffset:d.offset*4,byteStride:h?(h.offset-d.offset)*4:0})}};for(let[s,o]of Object.entries(n))i(s,o);return t}function Pz(n){return n.type==="uniform"&&Number.isInteger(n.minBindingSize)&&n.minBindingSize>=0&&Array.isArray(n.uniforms)&&n.uniforms.every(e=>typeof e.name=="string"&&typeof e.format=="string"&&Number.isInteger(e.arrayLength)&&e.arrayLength>0&&Number.isInteger(e.byteOffset)&&e.byteOffset>=0&&Number.isInteger(e.byteStride)&&e.byteStride>=0)}function Cz(n){if(n[n.length-1]!=="]")return{name:n,length:1,isArray:!1};let t=/([^[]*)(\[[0-9]+\])?/.exec(n);return{name:Wi(t?.[1],`Failed to parse GLSL uniform name ${n}`),length:t?.[2]?1:0,isArray:!!t?.[2]}}var eP=C(()=>{J();dd()});function Tz(n,e){let t={...n,attributes:n.attributes.map(i=>({...i})),bindings:n.bindings.map(i=>({...i}))};for(let i of e?.attributes||[]){let r=t.attributes.find(s=>s.name===i.name);r?(r.type=i.type||r.type,r.stepMode=i.stepMode||r.stepMode):N.warn(`shader layout attribute ${i.name} not present in shader`)}for(let i of e?.bindings||[]){let r=nP(t,i.name);if(!r){N.warn(`shader layout binding ${i.name} not present in shader`);continue}Object.assign(r,i)}return t}function nP(n,e){return n.bindings.find(t=>t.name===e||t.name===`${e}Uniforms`||`${t.name}Uniforms`===e)}function tP(n,e){return n[e]||n[`${e}Uniforms`]||n[e.replace(/Uniforms$/,"")]}var hd,iP=C(()=>{J();Y2();ed();Kf();ld();my();eP();hd=class extends Zt{device;handle;vs;fs;introspectedLayout;bindings={};uniforms={};varyings=null;_uniformCount=0;_uniformSetters={};get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}constructor(e,t){super(e,t),this.device=e;let i=this.sharedRenderPipeline||this.device._createSharedRenderPipelineWebGL(t);this.sharedRenderPipeline=i,this.handle=i.handle,this.vs=i.vs,this.fs=i.fs,this.linkStatus=i.linkStatus,this.introspectedLayout=Q2(this.device.gl,this.handle,{uniformBlockLayouts:t._uniformBlockLayouts,shaderLayout:t.shaderLayout}),this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.shaderLayout=t.shaderLayout?Tz(this.introspectedLayout,t.shaderLayout):this.introspectedLayout}destroy(){this.destroyed||(this.sharedRenderPipeline&&!this.props._sharedRenderPipeline&&this.sharedRenderPipeline.destroy(),this.destroyResource())}setBindings(e,t){let i=js(Or(this.shaderLayout,e));for(let[r,s]of Object.entries(i)){let o=nP(this.shaderLayout,r);if(o){switch(s||N.warn(`Unsetting binding "${r}" in render pipeline "${this.id}"`)(),o.type){case"uniform":if(!(s instanceof wn)&&!(s.buffer instanceof wn))throw new Error("buffer value");break;case"texture":if(!(s instanceof ni||s instanceof ii||s instanceof ti))throw new Error(`${this} Bad texture binding for ${r}`);break;case"sampler":N.warn(`Ignoring sampler ${r}`)();break;default:throw new Error(o.type)}this.bindings[r]=s}else{let a=this.shaderLayout.bindings.map(c=>`"${c.name}"`).join(", ");t?.disableWarnings||N.warn(`No binding "${r}" in render pipeline "${this.id}", expected one of ${a}`,s)()}}}draw(e){let t=e.renderPass,i=e.bindGroups?js(e.bindGroups):e.bindings||this.bindings;return t.setPipeline(this),t.setBindings(i),t.setVertexArray(e.vertexArray),t.draw({parameters:e.parameters,topology:e.topology,isInstanced:e.isInstanced,vertexCount:e.vertexCount,indexCount:e.indexCount,instanceCount:e.instanceCount,firstVertex:e.firstVertex,firstIndex:e.firstIndex,firstInstance:e.firstInstance,baseVertex:e.baseVertex,transformFeedback:e.transformFeedback,uniforms:e.uniforms})}_areTexturesRenderable(e){let t=!0;for(let i of this.shaderLayout.bindings)tP(e,i.name)||(N.warn(`Binding ${i.name} not found in ${this.id}`)(),t=!1);return t}_applyBindings(e,t){if(this._syncLinkStatus(),this.linkStatus!=="success")return;let{gl:i}=this.device;i.useProgram(this.handle);let r=0,s=0;for(let o of this.shaderLayout.bindings){let a=tP(e,o.name);if(!a)throw new Error(`No value for binding ${o.name} in ${this.id}`);switch(o.type){case"uniform":let{name:c}=o,l=i.getUniformBlockIndex(this.handle,c);if(l===4294967295)throw new Error(`Invalid uniform block name ${c}`);if(i.uniformBlockBinding(this.handle,l,s),a instanceof wn)i.bindBufferBase(35345,s,a.handle);else{let f=a;i.bindBufferRange(35345,s,f.buffer.handle,f.offset||0,f.size||f.buffer.byteLength-(f.offset||0))}s+=1;break;case"texture":if(!(a instanceof ni||a instanceof ii||a instanceof ti))throw new Error("texture");let u;if(a instanceof ni)u=a.texture;else if(a instanceof ii)u=a;else if(a instanceof ti&&a.colorAttachments[0]instanceof ni)N.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),u=a.colorAttachments[0].texture;else throw new Error("No texture");i.activeTexture(33984+r),i.bindTexture(u.glTarget,u.handle),r+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${o.type}' not supported in WebGL`)}}}_applyUniforms(e){for(let t of this.shaderLayout.uniforms||[]){let{name:i,location:r,type:s,textureUnit:o}=t,a=e[i]??o;a!==void 0&&H2(this.device.gl,r,s,a)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}}});var rP,pd,sP=C(()=>{J();dd();rP=4,pd=class extends ka{device;handle;vs;fs;linkStatus="pending";constructor(e,t){super(e,t),this.device=e,this.handle=t.handle||this.device.gl.createProgram(),this.vs=t.vs,this.fs=t.fs,t.varyings&&t.varyings.length>0&&this.device.gl.transformFeedbackVaryings(this.handle,t.varyings,t.bufferMode||35981),this._linkShaders()}destroy(){this.destroyed||(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.handle.destroyed=!0,this.destroyResource())}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),N.time(rP,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),N.timeEnd(rP,`linkProgram for ${this.id}`)(),!this.device.features.has("compilation-status-async-webgl")){let i=this._getLinkStatus();this._reportLinkStatus(i);return}N.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),N.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let t=this._getLinkStatus();this._reportLinkStatus(t)}async _reportLinkStatus(e){switch(e){case"success":return;default:let t=e==="link-error"?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${t} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader();break;case"success":break}switch(this.fs?.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`${this} ${t} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader();break;case"success":break}let i=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${t} during ${e}: ${i}`),this)(),this.device.debug()}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(this._initializeSamplerUniforms(),e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}_initializeSamplerUniforms(){let{gl:e}=this.device;e.useProgram(this.handle);let t=0,i=e.getProgramParameter(this.handle,35718);for(let r=0;r1){let o=Int32Array.from({length:t.size},(a,c)=>r+c);return s.uniform1iv(e,o),r+t.size}return s.uniform1i(e,r),r+1}async _waitForLinkComplete(){let e=async r=>await new Promise(s=>setTimeout(s,r));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getProgramParameter(this.handle,37297))return;await e(10)}}}});function Lz(n,e){let t=e.sourceBuffer,i=e.destinationBuffer;n.gl.bindBuffer(36662,t.handle),n.gl.bindBuffer(36663,i.handle),n.gl.copyBufferSubData(36662,36663,e.sourceOffset??0,e.destinationOffset??0,e.size),n.gl.bindBuffer(36662,null),n.gl.bindBuffer(36663,null)}function Mz(n,e){let{sourceBuffer:t,byteOffset:i=0,destinationTexture:r,mipLevel:s=0,origin:o=[0,0,0],aspect:a="all",bytesPerRow:c,rowsPerImage:l,size:u}=e;if(a!=="all")throw new Error("copyBufferToTexture aspect is not supported in WebGL");r.writeBuffer(t,{byteOffset:i,bytesPerRow:c,rowsPerImage:l,mipLevel:s,x:o[0]??0,y:o[1]??0,z:o[2]??0,width:u[0],height:u[1],depthOrArrayLayers:u[2]})}function Az(n,e){let{sourceTexture:t,mipLevel:i=0,aspect:r="all",width:s=e.sourceTexture.width,height:o=e.sourceTexture.height,depthOrArrayLayers:a,origin:c=[0,0,0],destinationBuffer:l,byteOffset:u=0,bytesPerRow:f,rowsPerImage:d}=e;if(t instanceof me){t.readBuffer({x:c[0]??0,y:c[1]??0,z:c[2]??0,width:s,height:o,depthOrArrayLayers:a,mipLevel:i,aspect:r,byteOffset:u},l);return}if(r!=="all")throw new Error("aspect not supported in WebGL");if(i!==0||a!==void 0||f||d)throw new Error("not implemented");let{framebuffer:h,destroyFramebuffer:p}=oP(t),m;try{let g=l,v=s||h.width,y=o||h.height,b=Wi(h.colorAttachments[0]),x=qf(b.texture.props.format),E=x.format,w=x.type;n.gl.bindBuffer(35051,g.handle),m=n.gl.bindFramebuffer(36160,h.handle),n.gl.readPixels(c[0],c[1],v,y,E,w,u)}finally{n.gl.bindBuffer(35051,null),m!==void 0&&n.gl.bindFramebuffer(36160,m),p&&h.destroy()}}function kz(n,e){let{sourceTexture:t,destinationMipLevel:i=0,origin:r=[0,0],destinationOrigin:s=[0,0,0],destinationTexture:o}=e,{width:a=e.destinationTexture.width,height:c=e.destinationTexture.height}=e,{framebuffer:l,destroyFramebuffer:u}=oP(t),[f=0,d=0]=r,[h,p,m]=s,g=n.gl.bindFramebuffer(36160,l.handle),v,y;if(o instanceof ii)v=o,a=Number.isFinite(a)?a:v.width,c=Number.isFinite(c)?c:v.height,v._bind(0),y=v.glTarget;else throw new Error("invalid destination");switch(y){case 3553:case 34067:n.gl.copyTexSubImage2D(y,i,h,p,f,d,a,c);break;case 35866:case 32879:n.gl.copyTexSubImage3D(y,i,h,p,m,f,d,a,c);break;default:}v&&v._unbind(),n.gl.bindFramebuffer(36160,g),u&&l.destroy()}function oP(n){if(n instanceof me){let{width:e,height:t,id:i}=n;return{framebuffer:n.device.createFramebuffer({id:`framebuffer-for-${i}`,width:e,height:t,colorAttachments:[n]}),destroyFramebuffer:!0}}return{framebuffer:n,destroyFramebuffer:!1}}var md,aP=C(()=>{J();Lo();ld();md=class extends Ba{device;handle=null;commands=[];constructor(e,t={}){super(e,t),this.device=e}_executeCommands(e=this.commands){for(let t of e)switch(t.name){case"copy-buffer-to-buffer":Lz(this.device,t.options);break;case"copy-buffer-to-texture":Mz(this.device,t.options);break;case"copy-texture-to-buffer":Az(this.device,t.options);break;case"copy-texture-to-texture":kz(this.device,t.options);break;default:throw new Error(t.name)}}}});function cP(n){switch(n){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"triangle-list":return 4;case"triangle-strip":return 5;default:throw new Error(n)}}function lP(n){switch(n){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;default:throw new Error(n)}}var _y=C(()=>{});var Rz,gd,uP=C(()=>{J();ad();Po();_y();fy();Rz=[1,2,4,8],gd=class extends Ra{device;handle=null;glParameters={};pipeline=null;bindings={};bindingsPipeline=null;vertexArray=null;constructor(e,t){super(e,t),this.device=e;let i=this.props.framebuffer,r=!i||i.handle===null;r&&e.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();let s;if(!t?.parameters?.viewport)if(!r&&i){let{width:o,height:a}=i;s=[0,0,o,a]}else{let[o,a]=e.getDefaultCanvasContext().getDrawingBufferSize();s=[0,0,o,a]}if(this.device.pushState(),this.setParameters({viewport:s,...this.props.parameters}),!r&&i?.colorAttachments.length){let o=i.colorAttachments.map((a,c)=>36064+c);this.device.gl.drawBuffers(o)}else r&&this.device.gl.drawBuffers([1029]);this.clear(),this.props.timestampQuerySet&&this.props.beginTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.beginTimestampIndex)}end(){this.destroyed||(this.props.timestampQuerySet&&this.props.endTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.endTimestampIndex),this.device.popState(),this.destroy())}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}executeBundles(e){throw new Error("Render bundles are only supported in WebGPU")}setParameters(e={}){let t={...this.glParameters};t.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(t.depthMask=!this.props.depthReadOnly),t.stencilMask=this.props.stencilReadOnly?0:1,t[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(t.viewport=e.viewport.slice(0,4),t.depthRange=[e.viewport[4],e.viewport[5]]):t.viewport=e.viewport),e.scissorRect&&(t.scissorTest=!0,t.scissor=e.scissorRect),e.blendConstant&&(t.blendColor=e.blendConstant),e.stencilReference!==void 0&&(t[2967]=e.stencilReference,t[36003]=e.stencilReference),"colorMask"in e&&(t.colorMask=Rz.map(i=>!!(i&e.colorMask))),this.glParameters=t,bn(this.device.gl,t)}setPipeline(e){this.pipeline=e}setBindings(e,t){if(!this.pipeline)throw new Error("RenderPass.setPipeline() must be called before setBindings()");this.bindings=js(Or(this.pipeline.shaderLayout,e)),this.bindingsPipeline=this.pipeline}setVertexArray(e){this.vertexArray=e}draw(e){let t=this.pipeline,i=this.vertexArray;if(!t)throw new Error("RenderPass.setPipeline() must be called before draw()");if(!i)throw new Error("RenderPass.setVertexArray() must be called before draw()");if(t.shaderLayout.bindings.length>0&&this.bindingsPipeline!==t)throw new Error("RenderPass.setBindings() must be called after setPipeline() before draw()");t._syncLinkStatus();let{parameters:r=t.props.parameters,topology:s=t.props.topology,vertexCount:o,indexCount:a,instanceCount:c,isInstanced:l=!1,firstVertex:u=0,transformFeedback:f,uniforms:d=t.uniforms}=e,h=cP(s),p=!!i.indexBuffer,m=i.indexBuffer?.glIndexType,g=a??o??0;if(t.linkStatus!=="success")return N.info(2,`RenderPipeline:${t.id}.draw() aborted - waiting for shader linking`)(),!1;if(!t._areTexturesRenderable(this.bindings))return N.info(2,`RenderPipeline:${t.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(t.handle),i.bindBeforeRender(this);let v=f;return v&&v.begin(t.props.topology),t._applyBindings(this.bindings,{disableWarnings:t.props.disableWarnings}),t._applyUniforms(d),W2(this.device,r,this.glParameters,()=>{p&&l?this.device.gl.drawElementsInstanced(h,g,m,u,c||0):p?this.device.gl.drawElements(h,g,m,u):l?this.device.gl.drawArraysInstanced(h,u,o||0,c||0):this.device.gl.drawArrays(h,u,o||0),v&&v.end()}),i.unbindAfterRender(this),!0}drawIndirect(e,t=0){throw new Error("Indirect drawing is only supported in WebGPU")}drawIndexedIndirect(e,t=0){throw new Error("Indirect drawing is only supported in WebGPU")}beginOcclusionQuery(e){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let e={...this.glParameters},t=0;this.props.clearColors&&this.props.clearColors.forEach((i,r)=>{i&&this.clearColorBuffer(r,i)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(t|=16384,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(t|=256,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(t|=1024,e.clearStencil=this.props.clearStencil),t!==0&&En(this.device.gl,e,()=>{this.device.gl.clear(t)})}clearColorBuffer(e=0,t=[0,0,0,0]){En(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,e,t);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,e,t);break;case Float32Array:this.device.gl.clearBufferfv(6144,e,t);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}});var Gc,fP=C(()=>{J();aP();uP();Gc=class extends Ia{device;handle=null;commandBuffer;constructor(e,t){super(e,t),this.device=e,this.commandBuffer=new md(e,{id:this.id,userData:this.userData})}destroy(){this.destroyResource()}finish(){return this.destroy(),this.commandBuffer}beginRenderPass(e={}){return new gd(this.device,this._applyTimeProfilingToPassProps(e))}beginComputePass(e={}){throw new Error("ComputePass not supported in WebGL")}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,t,i){throw new Error("resolveQuerySet is not supported in WebGL")}writeTimestamp(e,t){e.writeTimestamp(t)}}});function dP(n){let{target:e,source:t,start:i=0,count:r=1}=n,s=t.length,o=r*s,a=0;for(let c=i;a{});function Iz(n){return Array.isArray(n)?new Float32Array(n):n}function Bz(n,e){if(!n||!e||n.length!==e.length||n.constructor!==e.constructor)return!1;for(let t=0;t{J();vr();iy();hP();_d=class n extends Oa{get[Symbol.toStringTag](){return"VertexArray"}device;handle;attributeInfosByLocation;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return mp()==="Chrome"}constructor(e,t){super(e,t),this.device=e,this.handle=this.device.gl.createVertexArray(),this.attributeInfosByLocation=new Array(this.maxVertexAttributes).fill(null);for(let i of Object.values($a(t.shaderLayout,t.bufferLayout)))this.attributeInfosByLocation[i.location]=i}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){let t=e;if(t&&t.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,t?t.handle:null),this.indexBuffer=t,this.device.gl.bindVertexArray(null)}setBuffer(e,t){let i=t;if(i.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:r,type:s,stride:o,offset:a,normalized:c,integer:l,divisor:u}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,i.handle),l?this.device.gl.vertexAttribIPointer(e,r,s,o,a):this.device.gl.vertexAttribPointer(e,r,s,c,o,a),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,u||0),this.attributes[e]=i,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,t){this._enable(e,!1),this.attributes[e]=t}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e{J();bd();_y();yd=class extends Da{device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(e,t){super(e,t),this.device=e,this.gl=e.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,t.buffers&&this.setBuffers(t.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(e="point-list"){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(lP(e))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(e){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let[t,i]of Object.entries(e))this.setBuffer(t,i)})}setBuffer(e,t){let i=this._getVaryingIndex(e),{buffer:r,byteLength:s,byteOffset:o}=this._getBufferRange(t);if(i<0){this.unusedBuffers[e]=r,N.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[i]={buffer:r,byteLength:s,byteOffset:o},this.bindOnUse||this._bindBuffer(i,r,o,s)}getBuffer(e){if(mP(e))return this.buffers[e]||null;let t=this._getVaryingIndex(e);return this.buffers[t]??null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(36386,e),this;let t;return this._bound?t=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,t=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),t}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof wn)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:t,byteOffset:i=0,byteLength:r=e.buffer.byteLength}=e;return{buffer:t,byteOffset:i,byteLength:r}}_getVaryingIndex(e){if(mP(e))return Number(e);for(let t of this.layout.varyings||[])if(e===t.name)return t.location;return-1}_bindBuffers(){for(let[e,t]of Object.entries(this.buffers)){let{buffer:i,byteLength:r,byteOffset:s}=this._getBufferRange(t);this._bindBuffer(Number(e),i,s,r)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,t,i=0,r){let s=t&&t.handle;!s||r===void 0?this.gl.bindBufferBase(35982,e,s):this.gl.bindBufferRange(35982,e,s,i,r)}}});var vd,_P=C(()=>{J();vd=class extends Na{device;handle;_timestampPairs=[];_pendingReads=new Set;_occlusionQuery=null;_occlusionActive=!1;get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){if(super(e,t),this.device=e,t.type==="timestamp"){if(t.count<2)throw new Error("Timestamp QuerySet requires at least two query slots");this._timestampPairs=new Array(Math.ceil(t.count/2)).fill(null).map(()=>({activeQuery:null,completedQueries:[]})),this.handle=null}else{if(t.count>1)throw new Error("WebGL occlusion QuerySet can only have one value");let i=this.device.gl.createQuery();if(!i)throw new Error("WebGL query not supported");this.handle=i}Object.seal(this)}destroy(){if(!this.destroyed){this.handle&&this.device.gl.deleteQuery(this.handle);for(let e of this._timestampPairs){e.activeQuery&&(this._cancelPendingQuery(e.activeQuery),this.device.gl.deleteQuery(e.activeQuery.handle));for(let t of e.completedQueries)this._cancelPendingQuery(t),this.device.gl.deleteQuery(t.handle)}this._occlusionQuery&&(this._cancelPendingQuery(this._occlusionQuery),this.device.gl.deleteQuery(this._occlusionQuery.handle));for(let e of Array.from(this._pendingReads))this._cancelPendingQuery(e);this.destroyResource()}}isResultAvailable(e){return this.props.type==="timestamp"?e===void 0?this._timestampPairs.some((t,i)=>this._isTimestampPairAvailable(i)):this._isTimestampPairAvailable(this._getTimestampPairIndex(e)):this._occlusionQuery?this._pollQueryAvailability(this._occlusionQuery):!1}async readResults(e){let t=e?.firstQuery||0,i=e?.queryCount||this.props.count-t;if(this._validateRange(t,i),this.props.type==="timestamp"){let r=new Array(i).fill(0n),s=Math.floor(t/2),o=Math.floor((t+i-1)/2);for(let a=s;a<=o;a++){let c=await this._consumeTimestampPairResult(a),l=a*2,u=l+1;l>=t&&l=t&&u=this.props.count||t<=e)throw new Error("Timestamp duration range is out of bounds");if(e%2!==0||t!==e+1)throw new Error("WebGL timestamp durations require adjacent even/odd query indices");let i=await this._consumeTimestampPairResult(this._getTimestampPairIndex(e));return Number(i)/1e6}beginOcclusionQuery(){if(this.props.type!=="occlusion")throw new Error("Occlusion queries require an occlusion QuerySet");if(!this.handle)throw new Error("WebGL occlusion query is not available");if(this._occlusionActive)throw new Error("Occlusion query is already active");this.device.gl.beginQuery(35887,this.handle),this._occlusionQuery={handle:this.handle,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null},this._occlusionActive=!0}endOcclusionQuery(){if(!this._occlusionActive)throw new Error("Occlusion query is not active");this.device.gl.endQuery(35887),this._occlusionActive=!1}writeTimestamp(e){if(this.props.type!=="timestamp")throw new Error("Timestamp writes require a timestamp QuerySet");let t=this._getTimestampPairIndex(e),i=this._timestampPairs[t];if(e%2===0){if(i.activeQuery)throw new Error("Timestamp query pair is already active");let r=this.device.gl.createQuery();if(!r)throw new Error("WebGL query not supported");let s={handle:r,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null};this.device.gl.beginQuery(35007,r),i.activeQuery=s;return}if(!i.activeQuery)throw new Error("Timestamp query pair was ended before it was started");this.device.gl.endQuery(35007),i.completedQueries.push(i.activeQuery),i.activeQuery=null}_validateRange(e,t){if(e<0||t<0||e+t>this.props.count)throw new Error("Query read range is out of bounds")}_getTimestampPairIndex(e){if(e<0||e>=this.props.count)throw new Error("Query index is out of bounds");return Math.floor(e/2)}_isTimestampPairAvailable(e){let t=this._timestampPairs[e];return!t||t.completedQueries.length===0?!1:this._pollQueryAvailability(t.completedQueries[0])}_pollQueryAvailability(e){if(e.cancelled||this.destroyed)return e.result=0n,!0;if(e.result!==null||e.disjoint)return!0;if(!this.device.gl.getQueryParameter(e.handle,34919))return!1;let i=!!this.device.gl.getParameter(36795);return e.disjoint=i,e.result=i?0n:BigInt(this.device.gl.getQueryParameter(e.handle,34918)),!0}async _consumeTimestampPairResult(e){let t=this._timestampPairs[e];if(!t||t.completedQueries.length===0)throw new Error("Timestamp query pair has no completed result");let i=t.completedQueries.shift();try{return await this._consumeQueryResult(i)}finally{this.device.gl.deleteQuery(i.handle)}}_consumeQueryResult(e){return e.promise||(this._pendingReads.add(e),e.promise=new Promise((t,i)=>{e.resolve=t,e.reject=i;let r=()=>{if(e.pollRequestId=null,e.cancelled||this.destroyed){this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,t(0n);return}if(!this._pollQueryAvailability(e)){e.pollRequestId=this._requestAnimationFrame(r);return}this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,e.disjoint?i(new Error("GPU timestamp query was invalidated by a disjoint event")):t(e.result||0n)};r()})),e.promise}_cancelPendingQuery(e){if(this._pendingReads.delete(e),e.cancelled=!0,e.pollRequestId!==null&&(this._cancelAnimationFrame(e.pollRequestId),e.pollRequestId=null),e.resolve){let t=e.resolve;e.promise=null,e.resolve=null,e.reject=null,t(0n)}}_requestAnimationFrame(e){return requestAnimationFrame(e)}_cancelAnimationFrame(e){cancelAnimationFrame(e)}}});var xd,yP=C(()=>{J();xd=class extends Fa{device;gl;handle;signaled;_signaled=!1;constructor(e,t={}){super(e,{}),this.device=e,this.gl=e.gl;let i=this.props.handle||this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE,0);if(!i)throw new Error("Failed to create WebGL fence");this.handle=i,this.signaled=new Promise(r=>{let s=()=>{let o=this.gl.clientWaitSync(this.handle,0,0);o===this.gl.ALREADY_SIGNALED||o===this.gl.CONDITION_SATISFIED?(this._signaled=!0,r()):setTimeout(s,1)};s()})}isSignaled(){if(this._signaled)return!0;let e=this.gl.getSyncParameter(this.handle,this.gl.SYNC_STATUS);return this._signaled=e===this.gl.SIGNALED,this._signaled}destroy(){this.destroyed||this.gl.deleteSync(this.handle)}}});function yy(n){switch(n){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function bP(n){switch(n){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}var vP=C(()=>{});function xP(n,e){let{sourceX:t=0,sourceY:i=0,sourceAttachment:r=0}=e||{},{target:s=null,sourceWidth:o,sourceHeight:a,sourceDepth:c,sourceFormat:l,sourceType:u}=e||{},{framebuffer:f,deleteFramebuffer:d}=EP(n),{gl:h,handle:p}=f;o||=f.width,a||=f.height;let m=f.colorAttachments[r]?.texture;if(!m)throw new Error(`Invalid framebuffer attachment ${r}`);c=m?.depth||1,l||=m?.glFormat||6408,u||=m?.glType||5121,s=Dz(s,u,l,o,a,c);let g=Xe.getDataType(s);u=u||q2(g);let v=h.bindFramebuffer(36160,p);return h.readBuffer(36064+r),h.readPixels(t,i,o,a,l,u,s),h.readBuffer(36064),h.bindFramebuffer(36160,v||null),d&&f.destroy(),s}function wP(n,e){let{target:t,sourceX:i=0,sourceY:r=0,sourceFormat:s=6408,targetByteOffset:o=0}=e||{},{sourceWidth:a,sourceHeight:c,sourceType:l}=e||{},{framebuffer:u,deleteFramebuffer:f}=EP(n);a=a||u.width,c=c||u.height;let d=u;l=l||5121;let h=t;if(!h){let m=yy(s),g=bP(l),v=o+a*c*m*g;h=d.device.createBuffer({byteLength:v})}let p=n.device.createCommandEncoder();return p.copyTextureToBuffer({sourceTexture:n,width:a,height:c,origin:[i,r],destinationBuffer:h,byteOffset:o}),p.destroy(),f&&u.destroy(),h}function EP(n){return n instanceof Rr?{framebuffer:n,deleteFramebuffer:!1}:{framebuffer:Oz(n),deleteFramebuffer:!0}}function Oz(n,e){let{device:t,width:i,height:r,id:s}=n;return t.createFramebuffer({...e,id:`framebuffer-for-${s}`,width:i,height:r,colorAttachments:[n]})}function Dz(n,e,t,i,r,s){if(n)return n;e||=5121;let o=cd(e),a=Xe.getTypedArrayConstructor(o),c=yy(t);return new a(i*r*c)}var SP=C(()=>{J();dd();vP();gy()});function PP(n){let e=new Map;for(let t in n){let i=n[t];if(t<"a"){let r=e.get(i);e.set(i,r?`${r}, GL.${t}`:`GL.${t}`)}}return e}var CP=C(()=>{});var by={};mi(by,{WebGLDevice:()=>nr});function Nz(n,e,t){switch(t.length){case 1:n.gl.vertexAttrib1fv(e,t);break;case 2:n.gl.vertexAttrib2fv(e,t);break;case 3:n.gl.vertexAttrib3fv(e,t);break;case 4:n.gl.vertexAttrib4fv(e,t);break;default:}}function Fz(n,e,t){n.gl.vertexAttribI4iv(e,t)}function zz(n,e,t){n.gl.vertexAttribI4uiv(e,t)}function Uz(n,e){if(!n||!e||n.length!==e.length||n.constructor!==e.constructor)return!1;for(let t=0;t{J();ty();E2();ny();C2();B2();O2();D2();N2();X_();Lo();z2();ed();G2();j2();ld();Kf();iP();sP();fP();pP();gP();_P();yP();SP();Po();ad();Nc();CP();nr=class n extends bi{static getDeviceFromContext(e){return e?e.luma?.device??null:null}type="webgl";handle;features;limits;info;canvasContext;preferredColorFormat="rgba8unorm";preferredDepthFormat="depth24plus";commandEncoder;lost;_resolveContextLost;_isLost=!1;gl;_glKeyByValue=null;_constants;extensions;_polyfilled=!1;spectorJS;get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(e){switch(e){case"unorm8x4-bgra":return!1;default:return!0}}constructor(e){super({...e,id:e.id||F2("webgl-device")});let t=bi._getCanvasContextProps(e);if(!t)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let i=t.canvas?.gl??null,r=n.getDeviceFromContext(i);if(r)throw new Error(`WebGL context already attached to device ${r.id}`);this.canvasContext=new Qf(this,t),this.lost=new Promise(u=>{this._resolveContextLost=u});let s={...e.webgl};t.alphaMode==="premultiplied"&&(s.premultipliedAlpha=!0),e.powerPreference!==void 0&&(s.powerPreference=e.powerPreference),e.failIfMajorPerformanceCaveat!==void 0&&(s.failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat);let a=this.props._handle||w2(this.canvasContext.canvas,{onContextLost:u=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."}),onContextRestored:u=>{console.log("WebGL context restored")}},s);if(!a)throw new Error("WebGL context creation failed");if(r=n.getDeviceFromContext(a),r){if(e._reuseDevices)return N.log(1,`Not creating a new Device, instead returning a reference to Device ${r.id} already attached to WebGL context`,r)(),this.canvasContext.destroy(),r._reused=!0,r;throw new Error(`WebGL context already attached to device ${r.id}`)}this.handle=a,this.gl=a,this.spectorJS=f2({...this.props,gl:this.handle});let c=Dc(this.handle);c.device=this,c.extensions||(c.extensions={}),this.extensions=c.extensions,this.info=S2(this.gl,this.extensions),this.limits=new Xf(this.gl),this.features=new Zf(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new vn(this.gl,{log:(...u)=>N.log(1,...u)()}).trackState(this.gl,{copyState:!1}),(e.debug||e.debugWebGL)&&(this.gl=l2(this.gl,{debugWebGL:!0,traceWebGL:e.debugWebGL}),N.warn("WebGL debug mode activated. Performance reduced.")()),e.debugWebGL&&(N.level=Math.max(N.level,1)),this.commandEncoder=new Gc(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}destroy(){if(!this.props._reuseDevices&&!this._reused){this._isLost=!0,this.commandEncoder?.destroy();let e=Dc(this.handle);e.device=null}}get isLost(){return this._isLost||this.gl.isContextLost()}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createPresentationContext(e){return new Jf(this,e||{})}createBuffer(e){let t=this._normalizeBufferProps(e);return new wn(this,t)}createTexture(e){return new ii(this,e)}createExternalTexture(e){throw new Error("ExternalTexture is not available on WebGL")}createSampler(e){return new od(this,e)}createShader(e){return new nd(this,e)}createFramebuffer(e){return new ti(this,e)}createVertexArray(e){return new _d(this,e)}createTransformFeedback(e){return new yd(this,e)}createQuerySet(e){return new vd(this,e)}createFence(){return new xd(this)}createRenderPipeline(e){return new hd(this,e)}_createSharedRenderPipelineWebGL(e){return new pd(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}createRenderBundleEncoder(e){throw new Error("Render bundles are only supported in WebGPU")}createCommandEncoder(e={}){return new Gc(this,e)}submit(e){let t=null;e||({submittedCommandEncoder:t,commandBuffer:e}=this._finalizeDefaultCommandEncoderForSubmit());try{e._executeCommands(),t&&t.resolveTimeProfilingQuerySet().then(()=>{this.commandEncoder._gpuTimeMs=t._gpuTimeMs}).catch(()=>{})}finally{e.destroy()}}writeBufferViaCommandEncoder(e,t,i,r=0){t.write(i,r)}_finalizeDefaultCommandEncoderForSubmit(){let e=this.commandEncoder,t=e.finish();return this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:e.props.id,timeProfilingQuerySet:e.getTimeProfilingQuerySet()}),{submittedCommandEncoder:e,commandBuffer:t}}readPixelsToArrayWebGL(e,t){return xP(e,t)}readPixelsToBufferWebGL(e,t){return wP(e,t)}setParametersWebGL(e){bn(this.gl,e)}getParametersWebGL(e){return Vf(this.gl,e)}withParametersWebGL(e,t){return En(this.gl,e,t)}resetWebGL(){N.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),_2(this.gl)}_getDeviceSpecificTextureFormatCapabilities(e){return k2(this.gl,e,this.extensions)}loseDevice(){let e=!1,i=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return i&&(e=!0,i.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){vn.get(this.gl).push()}popState(){vn.get(this.gl).pop()}getGLKey(e,t){let i=this._getGLKeyByValue().get(Number(e));return i||(t?.emptyIfUnknown?"":String(e))}getGLKeys(e){let t={emptyIfUnknown:!0};return Object.entries(e).reduce((i,[r,s])=>(i[`${r}:${this.getGLKey(r,t)}`]=`${s}:${this.getGLKey(s,t)}`,i),{})}_getGLKeyByValue(){return this._glKeyByValue??=PP(this.gl),this._glKeyByValue}setConstantAttributeWebGL(e,t){let i=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(i).fill(null);let r=this._constants[e];switch(r&&Uz(r,t)&&N.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=t,t.constructor){case Float32Array:Nz(this,e,t);break;case Int32Array:Fz(this,e,t);break;case Uint32Array:zz(this,e,t);break;default:throw new Error("constant")}}getExtension(e){return xn(this.gl,e,this.extensions),this.extensions}_setWebGLDebugMetadata(e,t,i){e.luma=t;let r={props:i.spector,id:i.spector.id};e.__SPECTOR_Metadata=r}}});function $z(n){return typeof WebGL2RenderingContext<"u"&&n instanceof WebGL2RenderingContext?!0:!!(n&&typeof n.createVertexArray=="function")}function TP(n){return{...n,debug:n.debug??bi.defaultProps.debug,debugWebGL:n.debugWebGL??bi.defaultProps.debugWebGL,debugSpectorJS:n.debugSpectorJS??!!N.get("debug-spectorjs")}}async function LP(n){let e=[];(n.debugWebGL||n.debug)&&e.push(c2()),n.debugSpectorJS&&e.push(u2(n));let t=await Promise.allSettled(e);for(let i of t)i.status==="rejected"&&N.error(`Failed to initialize debug libraries ${i.reason}`)()}var Vc,vy,Wc,MP=C(()=>{J();o2();X_();Vc=1,vy=class extends Ea{type="webgl";enforceWebGL2(e){s2(e)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext&&N.warn("WebGL1 is not supported",e)(),!1)}async attach(e,t={}){let{WebGLDevice:i}=await Promise.resolve().then(()=>(wd(),by));if(e instanceof i)return e;let r=i.getDeviceFromContext(e);if(r)return r;if(!$z(e))throw new Error("Invalid WebGL2RenderingContext");t=TP(t),await LP(t);let s=t.createCanvasContext===!0?{}:t.createCanvasContext;return new i({...t,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...s}})}async create(e={}){let{WebGLDevice:t}=await Promise.resolve().then(()=>(wd(),by));e=TP(e),await LP(e);try{let i=new t(e);N.groupCollapsed(Vc,`WebGLDevice ${i.id} created`)();let r=`${i._reused?"Reusing":"Created"} device with WebGL2 ${i.props.debug?"debug ":""}context: ${i.info.vendor}, ${i.info.renderer} for canvas: ${i.canvasContext.id}`;return N.probe(Vc,r)(),N.table(Vc,i.info)(),i}finally{N.groupEnd(Vc)(),N.info(Vc,"%cWebGL call tracing: luma.log.set('debug-webgl') ","color: white; background: blue; padding: 2px 6px; border-radius: 3px;")()}}};Wc=new vy});var bd=C(()=>{MP();wd();ed()});function Td(n){return FP.test(n)}function Ld(n){return zP.test(n)}function UP(n){let e=FP.exec(n),t=zP.exec(n),i=e?.[1]??t?.[1]??n;try{Pe.getVertexFormatInfo(i)}catch{throw new Error(`Unsupported GPUVector format ${n}`)}return i}function Ti(n){let e=UP(n),t=Td(n),i=Ld(n),r=Pe.getVertexFormatInfo(e),s=r.type,o=r.normalized,a=Hz(s,o);return{format:n,elementFormat:e,vertexList:t,valueList:i,type:s,signedDataType:Yz(e,s),primitiveType:a,components:r.components,byteLength:r.byteLength,integer:r.integer,signed:r.signed,normalized:o,...r.webglOnly?{webglOnly:!0}:{}}}function Hz(n,e){if(e)return"f32";switch(n){case"float32":return"f32";case"float16":return"f16";case"uint8":case"uint16":case"uint32":return"u32";case"sint8":case"sint16":case"sint32":return"i32";default:throw new Error(`Unsupported GPUVector component type ${n}`)}}function Yz(n,e){if(n==="unorm10-10-10-2")return"uint32";switch(e){case"unorm8":return"uint8";case"snorm8":return"sint8";case"unorm16":return"uint16";case"snorm16":return"sint16";default:return e}}var FP,zP,Md=C(()=>{J();FP=/^vertex-list<([^<>]+)>$/,zP=/^value-list<([^<>]+)>$/});function Ey(n,e){if(!Number.isSafeInteger(n)||n<0)throw new Error(`${e} must be a non-negative safe integer`)}var Li,Sy=C(()=>{J();Li=class{buffer;format;length;byteOffset;byteStride;constructor(e){let t=Pe.getVertexFormatInfo(e.format).byteLength,i=e.byteOffset??0,r=e.byteStride??t;if(Ey(e.length,"GPUDataView length"),Ey(i,"GPUDataView byteOffset"),Ey(r,"GPUDataView byteStride"),re.buffer.byteLength)throw new Error("GPUDataView exceeds its backing buffer byte length");this.buffer=e.buffer,this.format=e.format,this.length=e.length,this.byteOffset=i,this.byteStride=r}get elementByteLength(){return Pe.getVertexFormatInfo(this.format).byteLength}get byteLength(){return this.length===0?0:(this.length-1)*this.byteStride+this.elementByteLength}}});function kd(n){return!!(n&&typeof n=="object"&&n.type==="struct")}function GP(n,e){let t=Object.entries(n);if(t.length===0)throw new Error("GPUData struct format must declare at least one field");return e==="packed"?qz(t):Zz(t)}function qz(n){let e=[],t=0,i=0;for(let[r,s]of n){let o=Pe.getVertexFormatInfo(s);if(o.webglOnly)throw new Error(`Packed GPUData struct field "${r}" uses WebGL-only format ${s}`);t=$P(t,Math.min(4,o.byteLength)),e.push([r,Object.freeze({format:s,byteOffset:t,byteLength:o.byteLength})]),t+=o.byteLength,i+=o.components}return Object.freeze({type:"struct",layout:"packed",fields:Object.freeze(Object.fromEntries(e)),components:i,byteStride:$P(t,4),rowByteLength:t})}function Zz(n){let e=Object.fromEntries(n.map(([o,a])=>[o,Xz(a)])),t=Dr(e,{layout:"wgsl-storage"}),i=[],r=0,s=0;for(let[o,a]of n){let c=Pe.getVertexFormatInfo(a),l=t.fields[o].offset*4;i.push([o,Object.freeze({format:a,byteOffset:l,byteLength:c.byteLength})]),r=Math.max(r,l+c.byteLength),s+=c.components}return Object.freeze({type:"struct",layout:"wgsl-storage",fields:Object.freeze(Object.fromEntries(i)),components:s,byteStride:t.byteLength,rowByteLength:r})}function Xz(n){let e=Pe.getVertexFormatInfo(n);switch(e.type){case"float32":return Ad("f32",e.components);case"sint32":return Ad("i32",e.components);case"uint32":return Ad("u32",e.components);default:{let t=Math.ceil(e.byteLength/4);return Ad("u32",t)}}}function Ad(n,e){return e===1?n:`vec${e}<${n}>`}function $P(n,e){return Math.ceil(n/e)*e}var VP=C(()=>{J()});var Py,Cy,Mo,Ty=C(()=>{Sy();VP();Md();Py=class{buffer;ownsDataBuffer;constructor(e,t){this.buffer=e,this.ownsDataBuffer=t}get ownsBuffer(){return this.ownsDataBuffer}transferBufferOwnership(e){if(e.buffer!==this.buffer)throw new Error("GPUData ownership can only be transferred to the same buffer");e.ownsDataBuffer=this.ownsDataBuffer,this.ownsDataBuffer=!1}destroy(){this.ownsDataBuffer&&(this.buffer.destroy(),this.ownsDataBuffer=!1)}},Cy=class extends Py{dataType;format;length;valueLength;stride;byteOffset;byteStride;rowByteLength;readbackMetadata;valueOffsets;nullBitmap;valueByteLength;constructor(e){let{buffer:t,format:i,length:r,valueLength:s,stride:o,byteOffset:a=0,byteStride:c,rowByteLength:l,ownsBuffer:u=!1,readbackMetadata:f,valueOffsets:d,nullBitmap:h,valueByteLength:p,dataType:m}=e;super(t,u);let g;i?typeof i=="string"?g=i:g=GP(i,e.layout??"wgsl-storage"):g=void 0;let v=kd(g)?g:void 0,y=typeof g=="string"?Ti(g):void 0;if(this.dataType=m,this.format=g,this.length=r,this.valueLength=s??r,this.stride=o??y?.components??v?.components??c??l??1,this.byteOffset=a,this.rowByteLength=l??v?.rowByteLength??y?.byteLength??c??this.stride,this.byteStride=c??v?.byteStride??this.rowByteLength,v){if(this.rowByteLengthi.format!==e))throw new Error("GPUVector data chunks must share the declared format")}var ri,jP=C(()=>{Ty();Md();ri=class{name;dataType;format;length;valueLength;stride;byteOffset;byteStride;rowByteLength;bufferLayout;data=[];device;bufferProps;isAppendable=!1;ownsDataChunks=!0;ownedVectors=[];appendableByteLength=0;constructor(e){switch(e.type){case"buffer":{let{name:t,buffer:i,format:r,length:s,valueLength:o=s,byteOffset:a=0,ownsBuffer:c=!1}=e,{stride:l,byteStride:u,rowByteLength:f}=WP(e);this.name=t,this.dataType=e.dataType,this.format=r,this.length=s,this.valueLength=o,this.stride=l,this.byteOffset=a,this.byteStride=u,this.rowByteLength=f,this.data.push(new Mo({buffer:i,format:r,length:s,valueLength:o,stride:l,byteOffset:a,byteStride:u,rowByteLength:f,ownsBuffer:c,dataType:e.dataType}));return}case"interleaved":{let{name:t,buffer:i,format:r,length:s,valueLength:o=s,byteOffset:a=0,byteStride:c,attributes:l,ownsBuffer:u=!1}=e;this.name=t,this.dataType=e.dataType,this.format=r,this.length=s,this.valueLength=o,this.stride=c,this.byteOffset=a,this.byteStride=c,this.rowByteLength=c,this.bufferLayout={name:t,byteStride:c,attributes:l},this.data.push(new Mo({buffer:i,format:r,length:s,valueLength:o,stride:c,byteOffset:a,byteStride:c,rowByteLength:c,ownsBuffer:u,dataType:e.dataType}));return}case"data":{let t=e.format??Kz(e.data),i=t?Ti(t):void 0,{name:r,data:s,stride:o=s[0]?.stride??i?.components??1,valueLength:a=s.reduce((d,h)=>d+h.valueLength,0),byteStride:c=s[0]?.byteStride??i?.byteLength,rowByteLength:l=s[0]?.rowByteLength??i?.byteLength,bufferLayout:u,ownsData:f=!1}=e;if(c===void 0||l===void 0)throw new Error("GPUVector requires format or explicit byte layout metadata");t&&Qz(s,t),this.name=r,this.dataType=e.dataType,this.format=t,this.length=s.reduce((d,h)=>d+h.length,0),this.valueLength=a,this.stride=o,this.byteOffset=s.length===1?s[0].byteOffset:0,this.byteStride=c,this.rowByteLength=l,this.bufferLayout=u,this.ownsDataChunks=f,this.data.push(...s);return}case"appendable":{let{name:t,device:i,format:r,valueLength:s=0,bufferProps:o}=e,{stride:a,byteStride:c,rowByteLength:l}=WP(e);this.name=t,this.dataType=e.dataType,this.format=r,this.length=0,this.valueLength=s,this.stride=a,this.byteOffset=0,this.byteStride=c,this.rowByteLength=l,this.device=i,this.bufferProps=o,this.isAppendable=!0;return}}}get ownsBuffer(){return this.ownsDataChunks&&this.data.some(e=>e.ownsBuffer)||this.ownedVectors.some(e=>e.ownsBuffer)}get capacityRows(){return this.isAppendable?this.length:void 0}get appendedByteLength(){return this.appendableByteLength}addData(e){if(this.format&&e.format!==this.format)throw new Error("GPUVector.addData() requires matching formats");if(e.byteStride!==this.byteStride)throw new Error("GPUVector.addData() requires matching byteStride");if(e.rowByteLength!==this.rowByteLength)throw new Error("GPUVector.addData() requires matching rowByteLength");return this.data.push(e),this.length+=e.length,this.valueLength+=e.valueLength,this}appendDataChunk(e,t=this.appendableByteLength+e.buffer.byteLength){if(!this.isAppendable)throw new Error("GPUVector.appendDataChunk() requires appendable vector storage");if(this.format&&e.format!==this.format)throw new Error("GPUVector.appendDataChunk() requires matching formats");if(e.byteStride!==this.byteStride||e.rowByteLength!==this.rowByteLength)throw new Error("GPUVector.appendDataChunk() requires matching byte layout metadata");return this.data.push(e),this.length+=e.length,this.valueLength+=e.valueLength,this.appendableByteLength=t,this}resetLastBatch(){if(!this.isAppendable)throw new Error("GPUVector.resetLastBatch() requires appendable vector storage");for(let e of this.data.splice(0))e.destroy();return this.length=0,this.valueLength=0,this.appendableByteLength=0,this}retainOwnedVectors(e){return this.ownedVectors.push(...e),this}transferBufferOwnership(e){let t=this.data[0],i=e.data[0];if(!t||!i||t.buffer!==i.buffer)throw new Error("GPUVector ownership can only be transferred to the same buffer");t.transferBufferOwnership(i)}destroy(){if(this.ownsDataChunks)for(let e of this.data)e.destroy();for(let e of this.ownedVectors.splice(0))e.destroy()}}});var Ly=C(()=>{Ty();Sy();jP();Md()});var My,pt,Zc=C(()=>{J();My=class{poolSize=20;bufferPools;constructor(){this.bufferPools=new Map}createOrReuse(e,t){if(t>e.limits.maxBufferSize)throw new Error(`Buffer pool cannot allocate ${t} bytes: device.limits.maxBufferSize is ${e.limits.maxBufferSize}`);let i=this.bufferPools.get(e),r=i?i.findIndex(o=>o.byteLength>=t):-1;if(r<0)return e.createBuffer({usage:ie.VERTEX|ie.STORAGE|ie.COPY_DST|ie.COPY_SRC,byteLength:t});let[s]=i.splice(r,1);return s}recycle(e){let t=e.device;this.bufferPools.has(t)||this.bufferPools.set(t,[]);let i=this.bufferPools.get(t),r=i.findIndex(s=>s.byteLength>e.byteLength);r<0?i.push(e):i.splice(r,0,e),this.purge()}purge(){for(let[e,t]of this.bufferPools){let i=e.isLost?0:this.poolSize;for(;t.length>i;)t.shift().destroy();t.length===0&&this.bufferPools.delete(e)}}},pt=new My});function Jz(n,e,t,i){let{ValueType:r,size:s,offset:o,stride:a}=n,c=a/r.BYTES_PER_ELEMENT,l=o/r.BYTES_PER_ELEMENT,u=i-t;if(c===s){let d=l+t*c;return e.subarray(d,d+u*s)}let f=new r(u*s);for(let d=0;d0)throw new Error(`GPUDataEvaluator requires exactly one GPUData chunk for "${n.name}"`);return e}function nU(n){let e=[];return YP(n,e,{byteOffset:0}),e}function YP(n,e,t){let i=n.source;if(i&&!(i instanceof ve)&&i.name==="interleave"){for(let r of Object.values(i.inputs))r instanceof ve&&YP(r,e,t);return}e.push({attribute:n.id??n.toString(),format:qP(n.type,n.size,n.normalized),byteOffset:t.byteOffset}),t.byteOffset+=n.ValueType.BYTES_PER_ELEMENT*n.size}function qP(n,e,t=!1){if(e<1||e>4)throw new Error(`Cannot synthesize a GPUVector vertex format with ${e} components`);let i=n;if(t)switch(n){case"uint8":i="unorm8";break;case"sint8":i="snorm8";break;case"uint16":i="unorm16";break;case"sint16":i="snorm16";break;case"float32":i="float32";break;default:throw new Error(`Unsupported normalized vertex format for ${n}`)}return(i==="uint8"||i==="sint8"||i==="uint16"||i==="sint16"||i==="unorm8"||i==="snorm8"||i==="unorm16"||i==="snorm16")&&e===3?`${i}x3-webgl`:`${i}${e===1?"":`x${e}`}`}function iU(n,e,t=!1){return e>=1&&e<=4?qP(n,e,t):void 0}var ve,Mi=C(()=>{J();Me();Ly();Zc();ve=class n{static get bufferPoolSize(){return pt.poolSize}static set bufferPoolSize(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("GPUDataEvaluator.bufferPoolSize must be a non-negative safe integer");pt.poolSize=e,pt.purge()}type;size;get offset(){return this._offset}get stride(){return this._stride}normalized;isConstant;length;get byteLength(){return this._byteLength}ValueType;source=null;format;_id;_destroyed=!1;_value;_offset;_stride;_byteLength;_gpuVector;_bufferOwnership="owned";_targetBuffer;static fromArray(e,{type:t,size:i=1,offset:r=0,stride:s=0,normalized:o=!1}){let a=t,c;if(Array.isArray(e)){a=a||"float32";let u=Tr(a);c=new u(e)}else e instanceof Float64Array?(a="uint32",i*=2,r*=2,s*=2,c=new Uint32Array(e.buffer,e.byteOffset,e.byteLength/4)):(a=a||Lu(e),c=e);let l=`<${a} * ${i}>`;return new n({id:l,type:a,size:i,offset:r,stride:s,normalized:o,value:c})}static fromConstant(e,t="float32"){let i=Tr(t),r;return Array.isArray(e)?r=`[${e.join(",")}]`:(r=String(e),e=[e]),new n({id:r,isConstant:!0,type:t,size:e.length,value:new i(e)})}static fromGPUData(e,t={}){eU(e);let i=new Li({buffer:e.buffer,format:e.format,length:e.length,byteOffset:e.byteOffset,byteStride:e.byteStride});return new n({...HP(i),id:t.id,gpuData:e})}static fromGPUDataView(e,t={}){return new n({...HP(e),id:t.id,buffer:e.buffer})}constructor(e){let{id:t,value:i,buffer:r,gpuData:s,format:o,source:a=null,isConstant:c=!1}=e;if(!a&&!i&&!r&&!s)throw new Error("GPUDataEvaluator must have a value source");let{type:l,size:u,offset:f,stride:d,normalized:h,length:p}=e;if(a instanceof n?(l=l??a.type,u=u??a.size,f=f??a.offset,d=d??a.stride,h=h??a.normalized,p=p??a.length):(u=u??1,f=f??0,h=h??!1,p=c?1:p),!l)throw new Error("GPUDataEvaluator: type not defined");if(this._id=t,this.type=l,this.size=u,this.ValueType=Tr(this.type),this._offset=f,this._stride=d||this.ValueType.BYTES_PER_ELEMENT*u,this.normalized=h,this.source=a,this.format=o,p===void 0)if(c)p=1;else{if(!i)throw new Error("GPUDataEvaluator: length not defined");p=Math.ceil(i.byteLength/this.stride)}this.isConstant=c,this.length=p;let m=this.ValueType.BYTES_PER_ELEMENT*this.size;this._byteLength=p===0?0:(p-1)*this.stride+m,this._value=i,this._bufferOwnership=a instanceof n||r||s?"borrowed":"owned",s?this._gpuVector=new ri({type:"data",name:this._id??"data",format:s.format,data:[s],stride:s.stride,byteStride:s.byteStride,rowByteLength:s.rowByteLength}):r&&(this._gpuVector=this.createGPUVectorView({buffer:r,name:this._id,format:this.format}))}get value(){return this._value||(this.source instanceof n?this.source.value:void 0)}get evaluated(){return!!this._gpuVector}get id(){return this._id}get gpuVector(){if(!this._gpuVector)throw new Error(`${this} not evaluated`);return this._gpuVector}get buffer(){return Rd(this.gpuVector)}setTargetBuffer({buffer:e,byteOffset:t=0,byteStride:i=this.stride}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)throw new Error(`GPUDataEvaluator ${this} already evaluated`);if(!this.source||this.source instanceof n)throw new Error("GPUDataEvaluator target buffers require a deferred operation source");this._targetBuffer={buffer:e,byteOffset:t,byteStride:i}}async evaluate(e,t={}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let i;if(this.source instanceof n){let r=await this.source.evaluate(e);return this._gpuVector=this.createGPUVectorView({...t,buffer:Rd(r)}),this._gpuVector}if(i=this._getEvaluationBuffer(e),this._value)i.write(this._value);else{let r=await this.source.execute(e,i);if(!r.success)throw r.error||new Error(`${this.source} evaluation failed`);r.value&&(this._value=r.value)}return this._gpuVector=this.createGPUVectorView({...t,buffer:i}),this._gpuVector}evaluateSync(e,t={}){if(this._destroyed)throw new Error(`GPUDataEvaluator ${this} already destroyed`);if(this._gpuVector)return this._gpuVector;let i;if(this.source instanceof n){let r=this.source.evaluateSync(e);return this._gpuVector=this.createGPUVectorView({...t,buffer:Rd(r)}),this._gpuVector}if(i=this._getEvaluationBuffer(e),this._value)i.write(this._value);else{let r=this.source.executeSync(e,i);if(!r.success)throw r.error||new Error(`${this.source} evaluation failed`);r.value&&(this._value=r.value)}return this._gpuVector=this.createGPUVectorView({...t,buffer:i}),this._gpuVector}createGPUVectorView(e){let t=e.name??this._id??"vector",i=e.format??this.format??iU(this.type,this.size,this.normalized);if(e.interleaved){let r=typeof e.interleaved=="object"&&e.interleaved.attributes?e.interleaved.attributes:nU(this);return new ri({type:"interleaved",name:t,buffer:e.buffer,format:e.format??this.format,length:this.length,byteOffset:this.offset,byteStride:this.stride,attributes:r,ownsBuffer:!1})}return new ri({type:"buffer",name:t,buffer:e.buffer,format:i,length:this.length,stride:this.size,byteOffset:this.offset,byteStride:this.stride,rowByteLength:this.ValueType.BYTES_PER_ELEMENT*this.size,ownsBuffer:!1})}_getEvaluationBuffer(e){let t=this._targetBuffer;if(!t)return pt.createOrReuse(e,this.byteLength);if(t.buffer.device!==e)throw new Error("GPUDataEvaluator target buffer belongs to a different device");let i=this.ValueType.BYTES_PER_ELEMENT*this.size,r=this.length===0?0:(this.length-1)*t.byteStride+i;if(t.byteOffset+r>t.buffer.byteLength)throw new Error("GPUDataEvaluator target buffer is too small for the output layout");return this._offset=t.byteOffset,this._stride=t.byteStride,this._byteLength=r,this._bufferOwnership="borrowed",this._targetBuffer=void 0,t.buffer}async readValue(e=0,t){let{ValueType:i}=this,{size:r,offset:s,stride:o,length:a}=this,c=i.BYTES_PER_ELEMENT*r;if(t=t??a,e=Math.max(0,Math.min(a,e)),t=Math.max(e,Math.min(a,t)),this._value)return Jz(this,this._value,e,t);let l=t-e;if(l===0)return new i(0);let u=s+e*o,f=o===c?l*c:(l-1)*o+c,d=await this.buffer.readAsync(u,f),h=new i(d.buffer,d.byteOffset,d.byteLength/i.BYTES_PER_ELEMENT);if(o===c)return h;let p=new Uint8Array(c*l);for(let m=0;m{Ao={add:{arity:2,symbol:"arithmetic_add"},subtract:{arity:2,symbol:"arithmetic_subtract"},multiply:{arity:2,symbol:"arithmetic_multiply"},divide:{arity:2,symbol:"arithmetic_divide"},pow:{arity:2,symbol:"pow"},sqrt:{arity:1,symbol:"sqrt"},abs:{arity:1,symbol:"abs"},sin:{arity:1,symbol:"sin"},cos:{arity:1,symbol:"cos"},tan:{arity:1,symbol:"arithmetic_tan"},exp:{arity:1,symbol:"exp"},log:{arity:1,symbol:"log"}}});function lC(n,{operations:e,inputs:t}){switch(n.kind){case"input":if(!(n.name in t))throw new Error(`Unknown expression input '${n.name}'`);return;case"literal":if(Array.isArray(n.value)){for(let i of n.value)if(!Number.isFinite(i))throw new Error(`Expression literal array must contain only finite values, got ${i}`)}else if(!Number.isFinite(n.value))throw new Error(`Expression literal must be finite, got ${n.value}`);return;case"call":{let i=e[n.op];if(!i)throw new Error(`Unknown expression op '${n.op}'`);if(n.args.length!==i.arity)throw new Error(`Expression op '${n.op}' expects ${i.arity} args, got ${n.args.length}`);for(let r of n.args)lC(r,{operations:e,inputs:t});return}default:{let i=n;throw new Error(`Unsupported expression node ${i.kind}`)}}}function Od(n,e){return lC(n,e),uC(n,e)}function uC(n,e){switch(n.kind){case"input":{let t=e.inputs[n.name];return e.laneIndexuC(r,e));return e.formatCall(t.symbol,i)}default:{let t=n;throw new Error(`Unsupported expression node ${t.kind}`)}}}var Iy=C(()=>{});function it(n,e,t=!1){if(t)return e===1?"float":`vec${e}`;switch(n){case"uint8":case"uint16":case"uint32":return e===1?"uint":`uvec${e}`;case"sint8":case"sint16":case"sint32":return e===1?"int":`ivec${e}`;default:return e===1?"float":`vec${e}`}}function Dd(n,e,t=!1){let i;if(t)switch(n){case"uint8":i="unorm8";break;case"sint8":i="snorm8";break;case"uint16":i="unorm16";break;case"sint16":i="snorm16";break;case"float32":i="float32";break;default:throw new Error(`Unsupported normalized vertex format for ${n}`)}else i=n;return e===1?i:e===3&&!i.startsWith("float32")&&!i.endsWith("32")?`${i}x3-webgl`:`${i}x${e}`}function ir(n){switch(n[0]){case"u":return"0u";case"s":return"0";default:return"0."}}function fC(n,e){switch(n){case"uint8":case"uint16":case"uint32":return`${Math.trunc(e)}u`;case"sint8":case"sint16":case"sint32":return`${Math.trunc(e)}`;default:return Number.isInteger(e)?`${e}.0`:`${e}`}}function dC(n){switch(n){case"uint8":return"r8uint";case"sint8":return"r8sint";case"uint16":return"r16uint";case"sint16":return"r16sint";case"uint32":return"r32uint";case"sint32":return"r32sint";case"float32":return"r32float";default:throw new Error(`Unsupported WebGL gather texture format for ${n}`)}}function hC(n){switch(n){case"uint32":return"usampler2D";case"sint32":return"isampler2D";case"float32":return"sampler2D";default:throw new Error(`Unsupported WebGL gather sampler type for ${n}`)}}var Ro=C(()=>{});function rt({module:n,elementWise:e=!1,expression:t,inputs:i,output:r,operationType:s=r.type,outputBuffer:o}){let a=o.device,c=cs("result",r.type,r.size,r.normalized),l=[n,c],u=[],f={},d=it(r.type,1,r.normalized),h=it(s,1,r.normalized),p="",m=null,g={TYPE:h,RESULT_LEN:r.size.toString()},v=dU(i);for(let[E,w]of v)l.push(By(E,w.type,w.size,w.normalized,s)),u.push(Oy(E,w)),w instanceof ve?f[E]=w.buffer:(m=m||pt.createOrReuse(a,o.byteLength),f[E]=m),p+=`TYPE ${E}[${w.size}]; get_${E}(${E}); `,g[`${E.toUpperCase()}_LEN`]=w.size.toString();let y="";if(t)for(let E=0;E `${name.slice(0, 3)}_${name.slice(3)}`); +} + +const noFoundryNames = { + name: 'no-foundry-names', + setup(build) { + build.onLoad({ filter: /[\\/]@luma\.gl[\\/].*\.js$/ }, async ({ path }) => { + const text = await readFile(path, 'utf8'); + const hidden = hideFoundryNames(text); + return hidden === text ? undefined : { contents: hidden, loader: 'js' }; + }); + }, +}; + export default { // iife: one self-contained script whose top-level names stay out of the // page's global scope, however the page loads it. @@ -64,5 +90,5 @@ export default { // url(); inlined, the page needs no file besides the bundles. '.png': 'dataurl', }, - plugins: [compactSvg, elkBrowserBuild, noLoadersCdn], + plugins: [compactSvg, elkBrowserBuild, noLoadersCdn, noFoundryNames], }; diff --git a/src/web/test/BUILD b/src/web/test/BUILD index 3c5022ffee4..c47c0cd4f83 100644 --- a/src/web/test/BUILD +++ b/src/web/test/BUILD @@ -110,6 +110,13 @@ js_test( no_copy_to_bin = JS_FILES, ) +js_test( + name = "esbuild_config_test", + data = ["//src/web:esbuild.config.mjs"], + entry_point = "js/test-esbuild-config.js", + no_copy_to_bin = ["//src/web:esbuild.config.mjs"], +) + js_test( name = "schematic_pins_test", data = [ diff --git a/src/web/test/bundle_test.py b/src/web/test/bundle_test.py index 6642ed39c04..28d1cbdea55 100644 --- a/src/web/test/bundle_test.py +++ b/src/web/test/bundle_test.py @@ -157,6 +157,20 @@ def test_ships_the_bundled_licences(self): self.assertIn("\nSource: https://github.com/OpenKieler/elkjs\n", text) +class FoundryNames(unittest.TestCase): + # The private repository's security hook rejects the name, which luma.gl + # spells; esbuild.config.mjs renames it. Spelled in two parts because the + # hook reads this file too. + _NAME = re.compile("int" "el(?!l)", re.I) + + def test_bundles_do_not_spell_it(self): + for name, path in [("app.min.js", _PAGE["app.min.js"]), ("report.min.js", _REPORT_JS)]: + text = _read(path) + self.assertIsNone(self._NAME.search(text), name) + # luma.gl still tells that GPU maker apart. + self.assertIn("/INT[E]L/i", text, name) + + class Entries(unittest.TestCase): # main.js builds the panels as it loads; the globals they read come first. def test_import_main_last(self): diff --git a/src/web/test/js/test-esbuild-config.js b/src/web/test/js/test-esbuild-config.js new file mode 100644 index 00000000000..5667c708d6b --- /dev/null +++ b/src/web/test/js/test-esbuild-config.js @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: BSD-3-Clause +// Copyright (c) 2026, The OpenROAD Authors + +// hideFoundryNames rewrites luma.gl without changing what it does. The name +// is spelled in two parts because the security hook reads this file too. + +import { describe, it } from 'node:test'; +import assert from 'node:assert/strict'; +import { hideFoundryNames } from '../../esbuild.config.mjs'; + +const name = 'Int' + 'el'; +const blocked = new RegExp(`${name}(?!l)`, 'i'); + +describe('hideFoundryNames', () => { + it('keeps the GPU detection matching what browsers report', () => { + const source = `if (/${name.toUpperCase()}/i.exec(vendor)) {`; + const hidden = hideFoundryNames(source); + assert.equal(hidden, 'if (/INT[E]L/i.exec(vendor)) {'); + const regex = /\/(.*)\/i\.exec/.exec(hidden)[1]; + for (const reported of [`${name}`, `Mesa ${name}(R) UHD Graphics 630`, + `ANGLE (${name}, ${name}(R) Iris(R) Xe)`]) { + assert.ok(new RegExp(regex, 'i').test(reported), reported); + } + }); + + it('renames the vendor value, macros and comments the same way', () => { + const lower = name.toLowerCase(); + const upper = name.toUpperCase(); + const source = [ + `return '${lower}';`, + `case '${lower}':`, + `#define ${upper}_GPU`, + `#if defined(${upper}_FP64_WORKAROUND)`, + `// ${name} GPU doesn't have full 32 bits precision`, + ].join('\n'); + const hidden = hideFoundryNames(source); + assert.doesNotMatch(hidden, blocked); + assert.deepEqual(hidden.split('\n'), [ + "return 'int_el';", + "case 'int_el':", + '#define INT_EL_GPU', + '#if defined(INT_EL_FP64_WORKAROUND)', + "// Int_el GPU doesn't have full 32 bits precision", + ]); + }); + + it('leaves words that only start the same alone', () => { + const text = `${name}ligent ${name.toLowerCase()}lisense`; + assert.equal(hideFoundryNames(text), text); + }); +}); diff --git a/src/web/test/js/test-ui-utils.js b/src/web/test/js/test-ui-utils.js index 01c893f383e..6c87e78b0f1 100644 --- a/src/web/test/js/test-ui-utils.js +++ b/src/web/test/js/test-ui-utils.js @@ -456,7 +456,8 @@ describe('renderingWarning', () => { for (const [vendor, renderer] of [ ['Google Inc. (NVIDIA)', 'ANGLE (NVIDIA, NVIDIA GeForce RTX 3080 Direct3D11 vs_5_0 ps_5_0)'], - ['Intel', 'Mesa Intel(R) UHD Graphics 630 (CFL GT2)'], + ['Google Inc. (AMD)', 'ANGLE (AMD, AMD Radeon RX 6800 (radeonsi, ' + + 'navi21, LLVM 15.0.7), OpenGL 4.6 (Core Profile) Mesa 23.2.1)'], ['AMD', 'AMD Radeon RX 6800 (radeonsi, navi21, LLVM 15.0.7)'], ['Google Inc. (Apple)', 'ANGLE (Apple, Apple M2, OpenGL 4.1)'], ]) { From 49284a74aa70c30c754372cd1ec44b81dadc7d75 Mon Sep 17 00:00:00 2001 From: Jorge Ferreira Date: Thu, 22 Oct 2026 00:28:09 +0000 Subject: [PATCH 5/8] web: format bundle_test.py with black Signed-off-by: Jorge Ferreira --- src/web/test/bundle_test.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/web/test/bundle_test.py b/src/web/test/bundle_test.py index 28d1cbdea55..dce07154185 100644 --- a/src/web/test/bundle_test.py +++ b/src/web/test/bundle_test.py @@ -164,7 +164,10 @@ class FoundryNames(unittest.TestCase): _NAME = re.compile("int" "el(?!l)", re.I) def test_bundles_do_not_spell_it(self): - for name, path in [("app.min.js", _PAGE["app.min.js"]), ("report.min.js", _REPORT_JS)]: + for name, path in [ + ("app.min.js", _PAGE["app.min.js"]), + ("report.min.js", _REPORT_JS), + ]: text = _read(path) self.assertIsNone(self._NAME.search(text), name) # luma.gl still tells that GPU maker apart. From b0b19404c72d8348c56c1cc24833dc41682adedc Mon Sep 17 00:00:00 2001 From: Jorge Ferreira Date: Tue, 17 Nov 2026 01:10:49 +0000 Subject: [PATCH 6/8] web: fix viewer review findings and drop dead code Fixes stale tiles in saved reports, jumps in anchored zooms, label-mode clicks and tiles requested before the per-die state is restored. Signed-off-by: Jorge Ferreira --- MODULE.bazel | 8 +- src/web/README.md | 6 +- src/web/docs/server-api.md | 34 ++-- src/web/src/clusters-widget.js | 5 +- src/web/src/context-menu.js | 35 ++-- src/web/src/display-controls.js | 68 +++---- src/web/src/display-state.js | 2 +- src/web/src/hierarchy-browser.js | 5 +- src/web/src/hierarchy-panel.js | 9 +- src/web/src/inspector.js | 12 +- src/web/src/label-manager.js | 16 +- src/web/src/layout-view.js | 50 +++-- src/web/src/main.js | 51 ++---- src/web/src/menu-bar.js | 2 +- src/web/src/request_handler.cpp | 3 - src/web/src/request_handler.h | 6 +- src/web/src/ruler.js | 10 +- src/web/src/search-nav.js | 25 ++- src/web/src/tile-grid.js | 24 +-- src/web/src/tile-merge.js | 105 +++-------- src/web/src/tile-request.js | 12 +- src/web/src/tile-sources.js | 6 +- src/web/src/tile_generator.cpp | 44 ++--- src/web/src/tile_generator.h | 43 ++--- src/web/src/ui-utils.js | 7 +- src/web/src/view-input.js | 19 ++ src/web/src/view-math.js | 5 +- src/web/src/web.cpp | 14 +- src/web/src/websocket-manager.js | 33 ++-- src/web/src/zoom-swap.js | 19 +- src/web/test/bundle_test.py | 8 +- src/web/test/cpp/TestRequestHandler.cpp | 33 +--- src/web/test/cpp/TestSaveImage.cpp | 6 +- src/web/test/cpp/TestTileGenerator.cpp | 84 +++------ src/web/test/js/fake-view.js | 52 +----- src/web/test/js/test-capture.js | 6 +- src/web/test/js/test-clusters-widget.js | 1 - src/web/test/js/test-context-menu.js | 30 ++- src/web/test/js/test-coordinates.js | 6 - src/web/test/js/test-display-controls.js | 114 ++++++------ src/web/test/js/test-display-state.js | 2 +- src/web/test/js/test-dpr.js | 213 ++++++++++++++-------- src/web/test/js/test-drc-widget.js | 2 +- src/web/test/js/test-hierarchy-panel.js | 1 - src/web/test/js/test-inspector.js | 39 +++- src/web/test/js/test-label-manager.js | 48 ++++- src/web/test/js/test-layout-view.js | 126 +++++++++++-- src/web/test/js/test-menu-bar.js | 9 +- src/web/test/js/test-ruler.js | 53 +++++- src/web/test/js/test-search-nav.js | 21 ++- src/web/test/js/test-tile-grid.js | 55 +++++- src/web/test/js/test-tile-merge.js | 139 +------------- src/web/test/js/test-tile-sources.js | 25 +-- src/web/test/js/test-ui-utils.js | 5 +- src/web/test/js/test-view-input.js | 45 ++++- src/web/test/js/test-view-math.js | 16 +- src/web/test/js/test-websocket-manager.js | 24 +-- src/web/test/js/test-zoom-swap.js | 19 +- 58 files changed, 992 insertions(+), 868 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 5160a73ba45..a7a69b23e5c 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -425,12 +425,16 @@ npm_web.npm_translate_lock( pnpm_lock = "//src/web:pnpm-lock.yaml", ) -# sax ships its licence as LICENSE.md, which the default "basic" preset strips -# with every other *.md; //src/web:third_party_licenses needs it. +# sax and gl-matrix ship their license as LICENSE.md, which the default "basic" +# preset strips with every other *.md; //src/web:third_party_licenses needs it. npm_web.npm_exclude_package_contents( package = "sax", presets = [], ) +npm_web.npm_exclude_package_contents( + package = "gl-matrix", + presets = [], +) use_repo(npm_web, "npm_web") # Regenerate //src/web:pnpm-lock.yaml after editing //src/web:package.json: diff --git a/src/web/README.md b/src/web/README.md index 822e901afdc..2f6b733ef63 100644 --- a/src/web/README.md +++ b/src/web/README.md @@ -687,9 +687,9 @@ The module has two parts: Tiles are rendered from ODB geometry and encoded as PNG using lodepng. - **JavaScript frontend** (`src/main.js`, `src/index.html`, `src/style.css`) — - A single-page application using deck.gl (WebGL) for the layout view and - GoldenLayout for resizable panels. Communicates with the server over a binary WebSocket - protocol. + A single-page application using deck.gl (WebGL) for the layout view and lit + components for the panels. Communicates with the server over a binary + WebSocket protocol. ## Browser libraries diff --git a/src/web/docs/server-api.md b/src/web/docs/server-api.md index d1386ef68d0..fe3600a9af7 100644 --- a/src/web/docs/server-api.md +++ b/src/web/docs/server-api.md @@ -172,7 +172,7 @@ simply listening on the WebSocket; there's no opt-in. | `type` field | Trigger | Body | | -------------- | ----------------------------------------------------------------------- | ------------------------------- | | `config` | Once per connection, before any reply to a request. | `{"type":"config","max_in_flight":16}` | -| `refresh` | Initial spatial-index build finished after a connection / `web_server`. | `{"type":"refresh"}` | +| `refresh` | A connection's init finished, or the design was edited: redraw. | `{"type":"refresh"}` | | `log` | Buffered server log lines being flushed to clients. | `{"type":"log","text":""}` | | `debug_paused` | The graphics-debug pause hook entered (e.g. placer breakpoint). | `{"type":"debug_paused"}` | | `debug_resumed`| Pause hook exited. | `{"type":"debug_resumed"}` | @@ -207,13 +207,15 @@ Render a single 256×256 PNG tile of the layout. | Field | Type | Required | Description | | ---------------- | -------- | :------: | ----------- | -| `layer` | `string` | ✓ | Layer name (`metal1`, `metal2`, …) or one of the synthetic layers `_instances`, `_modules`, `_clusters`, `_pins`, or `_overlay`. | +| `layer` | `string` | ✓ | Layer name (`metal1`, `metal2`, …) or a synthetic layer: `_instances`, `_pins`, `_modules`, `_clusters`, or one of the overlays the `tech` response lists. | | `z` | `int` | ✓ | Tile zoom level (0 = whole design). | | `x` | `int` | ✓ | Tile column at zoom `z`. | | `y` | `int` | ✓ | Tile row at zoom `z`. | | `visible_layers` | `string[]` | ✓ | Tech layers currently visible, the union over the dies; an empty array hides them all. Read only by `_pins` and by the overlays whose `layers_by` group is on (see `tech`); every other tile ignores it, and it is left out of their cache key. | | `chiplet` | `string` | — | Chiplet path (as in the `tech` response's `chiplets[].path`) of the die a tech-layer tile draws. Two dies can share a layer name; omitted draws every visible chiplet. | | `chiplet_hidden_layers` | `object` | — | `{ "": ["", …] }`: layers hidden on that die only, while `visible_layers` still lists them. Read by the same tiles as `visible_layers`; a tech-layer tile names its die with `chiplet` instead. | +| `visible_chiplets` | `string[]` | — | Chiplet paths currently shown; a chiplet not listed is not drawn. Omitted draws every chiplet. | +| `renderer_host` | `bool` | — | Default `false`. On a tile that names its die with `chiplet`, also draw the debug renderers' pass for this layer name; the client sets it on one row per name. | | *visibility flags* | `bool` | per-flag default | See *TileVisibility flags* below. Any flag may be omitted to take the default. | | `site_` | `bool` | — | Per-row-site visibility. Only consulted when `rows == true`. | | `pattern` | `int` | — | Fill pattern for the layer's shapes: `0` none, `1` solid (default), `2` diagonal, `3` cross, `4` dots. Out-of-range values mean solid. | @@ -222,13 +224,14 @@ Render a single 256×256 PNG tile of the layout. when the layer has nothing to draw in this tile. **Caching:** the server caches the response under the tile, the rendered -`dpr` and `tile_px`, the design revision, and the parsed fields that can -change this layer's pixels. Selectability fields, keys the server does not -parse, and flags that only another layer draws (for example `pin_markers` -outside `_pins`, or `visible_layers` outside `_pins`, `_access_points` and, -while pin names are shown, `_inst_labels`) do not split the cache. -Tiles that depend on per-session state (module colors, focused nets, debug -renderers) are not cached. +`dpr` and `tile_px`, the design and chiplet revisions, and the parsed fields +that can change this layer's pixels. Selectability fields, keys the server +does not parse, and fields that only another layer reads (for example +`pin_markers` outside `_pins`, or `visible_layers` outside `_pins`, +`_access_points` and, while pin names are shown, `_inst_labels`) do not split +the cache. Tiles that depend on per-session state (a session's own module or +group colors, focused nets, debug renderers) are not cached; the default +color palette is. ### `overlay_tile` @@ -249,6 +252,7 @@ layer's geometry. | `focused_nets_guides` | `bool` | — | Default `false`. Draw route guides for the focused nets. | | `draw_labels` | `bool` | — | Default `true`. Draw user labels (`add_label`). | | `debug_renderers` | `bool` | — | Default `false`. Debug renderers are active, so the highlight must be re-derived every frame to track instances that move between them. | +| `poly_decomp` | `bool` | — | Default `false`. The Options > "Show polygon decomposition" setting, which changes the shapes an ITerm/MTerm highlight draws. A change re-derives the highlights, as with `flywires_only`. | **Response:** PNG image (frame type `1`), or frame type `3` with no body when nothing is highlighted in this tile — which is the usual case, since @@ -275,15 +279,17 @@ No request fields beyond the envelope. ```json { "bounds": [[yMin, xMin], [yMax, xMax]], + "fit_bounds": [[yMin, xMin], [yMax, xMax]], "shapes_ready": true, "pin_max_size": 200 } ``` -`bounds` is in DBU. `shapes_ready` indicates whether the spatial index -finished building (the `refresh` push fires when this flips to true). -`pin_max_size` is the largest BPin dimension in DBU, used by the client -to size the pin-marker overlay. +`bounds` is in DBU and georeferences the tile grid; `fit_bounds` is the +rect to zoom to fit, `bounds` without the pin-label margin. `shapes_ready` +indicates whether the spatial index finished building (the `refresh` push +fires when this flips to true). `pin_max_size` is the largest BPin dimension +in DBU, used by the client to size the pin-marker overlay. ### `layer_extents` @@ -390,7 +396,7 @@ No request fields. `overlays` lists the self-painting pseudo layers this design can draw (an overlay with nothing to draw, such as `_regions` in a design without regions, -is left out), each a `tile` layer of its own: `z_index` is its pane order +is left out), each a `tile` layer of its own: `z_index` is its draw order against the tech layers (`3` upwards), `_instances` (`0`) and `_pins` (`1`). `shown_by` and `layers_by` are groups of `tile` visibility keys, on when every key of any one group is on: the overlay draws anything when `shown_by` is on, diff --git a/src/web/src/clusters-widget.js b/src/web/src/clusters-widget.js index 57a1e423d39..d0ef7a751e6 100644 --- a/src/web/src/clusters-widget.js +++ b/src/web/src/clusters-widget.js @@ -295,9 +295,8 @@ export class ClustersWidget { console.error('set_group_colors failed:', err); return; } - // Only the cluster overlay reads these colors, so refresh that layer - // instead of every mounted one — a full redraw re-requests every metal - // layer's grid for a color they ignore. + // Only the cluster overlay reads these colors, so refresh the slot + // that draws it instead of every slot. if (this._app.clustersLayer) { this._app.clustersLayer.refreshTiles(); } else { diff --git a/src/web/src/context-menu.js b/src/web/src/context-menu.js index d8141c54a1f..e4fb4b4ceee 100644 --- a/src/web/src/context-menu.js +++ b/src/web/src/context-menu.js @@ -235,15 +235,11 @@ export class ContextMenu { } // Bring the client back in step with the selection/highlight state the - // action just changed server-side. - // - // redrawAllLayers is not enough on its own: focus nets and route guides - // feed the BASE tiles, so clearing them needs the full redraw, but that - // path calls the bare overlay refresh. The Selection Highlight panel and - // the Inspector are driven by app.refreshOverlay / app.refreshInspector — - // the same hooks the menu bar's "Clear Highlights" and the panel's own - // toolbar use — so without them the panel keeps listing objects the - // server no longer has selected or highlighted. + // action just changed server-side. Focus nets feed the base tiles and + // need the full redraw; the rest, route guides included, is overlay only. + // The Selection Highlight panel and the Inspector follow + // app.refreshOverlay / app.refreshInspector, the hooks the menu bar's + // "Clear Highlights" uses too. _syncAfterAction(action) { const app = this._app; // The Inspector's Focus and Route Guides buttons read these @@ -254,11 +250,11 @@ export class ContextMenu { if (action === 'clear_route_guides' || action === 'clear_all') { app.routeGuideNets?.clear(); } - // Base tiles only carry focus nets and route guides; every other - // action lives entirely in the overlay. - if ((action === 'clear_focus_nets' || action === 'clear_route_guides' - || action === 'clear_all') - && typeof app.redrawAllLayers === 'function') { + // Of these, only focus nets reach the base tiles; route guides and + // every other action live entirely in the overlay. + const redrawn = (action === 'clear_focus_nets' || action === 'clear_all') + && typeof app.redrawAllLayers === 'function'; + if (redrawn) { app.redrawAllLayers(); } // The selection itself is gone: reset the client-side pieces of it @@ -268,14 +264,17 @@ export class ContextMenu { app.updateInspector?.(null); app.stopSelectionAnimation?.(); app.clearSelectionOutline?.(); - app.lastSelectionBounds = null; } else { // Selection count/index and the highlight-group badge changed. app.refreshInspector?.(); } - // Refreshes the overlay tiles AND schedules the Selection Highlight - // panel refresh; must run last so it sees the cleanup above. - app.refreshOverlay?.(); + // Last, so it sees the cleanup above: the overlay hook also refreshes + // the Selection Highlight panel, and a full redraw already did the tiles. + if (redrawn) { + app.selectionBrowser?.scheduleRefresh(); + } else { + app.refreshOverlay?.(); + } } } diff --git a/src/web/src/display-controls.js b/src/web/src/display-controls.js index a19125bf102..dba8ab8f470 100644 --- a/src/web/src/display-controls.js +++ b/src/web/src/display-controls.js @@ -119,9 +119,6 @@ export function populateDisplayControls(app, visibility, selectability, // // Two slots, the layout and the layers over the highlight overlay, each // composited into one image per tile: every drawn tile costs CPU a frame. - for (const slot of app.allLayers || []) { - slot.remove(); - } app.allLayers = []; app.baseSlot = null; app.topSlot = null; @@ -201,7 +198,7 @@ export function populateDisplayControls(app, visibility, selectability, // module coloring. const underItems = [ pseudoItem('_instances', null, null), - pseudoItem('_pins', 'pinsLayer', 'pins'), + pseudoItem('_pins', null, 'pins'), pseudoItem('_modules', 'modulesLayer', 'module_view'), ]; // Cluster coloring goes above the routing layers and below the heat map. @@ -216,12 +213,12 @@ export function populateDisplayControls(app, visibility, selectability, // them; the rest go over the highlight overlay and the heat map, in the // GUI paint order. const topItems = []; - app.overlayLayers = ((techData && techData.overlays) || []).map((def) => ({ + const overlayLayers = (techData?.overlays || []).map((def) => ({ def, layer: pseudoItem(def.name, null, def.shown_by), under: def.z_index < kTechLayerZBase, })); - for (const { layer, under } of [...app.overlayLayers].sort( + for (const { layer, under } of [...overlayLayers].sort( (a, b) => a.def.z_index - b.def.z_index)) { (under ? underItems : topItems).push(layer); } @@ -491,12 +488,6 @@ export function populateDisplayControls(app, visibility, selectability, slot.items = items; // the draw list, bottom-most first return slot; } - app.baseSlot = compositeSlot( - 'base', DRAW_ORDER.base, - [...underItems, ...routingLayers, clustersItem]); - app.topSlot = compositeSlot('top', DRAW_ORDER.top, topItems); - // What redrawAllLayers() refreshes. - app.allLayers = [app.baseSlot, app.topSlot]; // Parallel selectability model with the same node ids as layerSpec so // syncLayerSelDom() and buildLayerDOM() can pair each visibility node @@ -624,13 +615,19 @@ export function populateDisplayControls(app, visibility, selectability, // some routing entry flips, and so do the overlays that draw by them // under the current visibility. if (app.baseSlot && dirtySlots.has(app.baseSlot)) { - for (const { def, under } of app.overlayLayers) { + for (const { def, under } of overlayLayers) { if (anyGroupOn(def.layers_by, visibility)) { dirtySlots.add(under ? app.baseSlot : app.topSlot); } } } - flushDirtySlots(); + // A die leaving the visible chiplets: the chiplet mirror below redraws + // every slot. + if (visibilityChangedAny) { + dirtySlots.clear(); + } else { + flushDirtySlots(); + } // Visibility off ⇒ selectability disabled — refresh selectability DOM. syncLayerSelDom(); @@ -1144,7 +1141,7 @@ export function populateDisplayControls(app, visibility, selectability, // Sanity check (debug aid): the two trees are expected to // describe the same set of chiplet paths because they share // origin in tile_generator.cpp's serializeTechResponse. If - // that invariant ever breaks, mirrorStates / mirrorChipletToLayers + // that invariant ever breaks, mirrorStates / checkChiplet // would silently drop the orphan paths — surfacing a warning // here makes the drift visible without breaking anything. if (typeof console !== 'undefined' && console.warn) { @@ -1189,16 +1186,15 @@ export function populateDisplayControls(app, visibility, selectability, } }); - // Cascade a chiplet toggle down into the layerModel so the - // Layers panel checkboxes (and the tiles, and the - // or_hidden_layers cookie) follow. cascadeQuiet skips the - // layerModel's onChange; we fire it ourselves so the standard - // sync path runs exactly once. No loop with the chipletModel - // mirror logic — the layerModel callback observes that the - // chipletModel state already matches and emits nothing back. - function mirrorChipletToLayers(chipletPath, checked) { - const ln = layerNodeByChipletPath.get(chipletPath); - if (!ln) return; + // A chiplet toggle goes through the Layers tree, whose onChange + // mirrors it back here and redraws once. A chiplet with no node + // there is checked directly. + function checkChiplet(id, chipletPath, checked) { + const ln = chipletPath && layerNodeByChipletPath.get(chipletPath); + if (!ln) { + chipletModel.check(id, checked); + return; + } layerModel.cascadeQuiet(ln.id, checked); layerModel.onChange(); } @@ -1265,11 +1261,8 @@ export function populateDisplayControls(app, visibility, selectability, rootNode.cb = parentCb; parentCb.addEventListener('change', (e) => { e.stopPropagation(); - chipletModel.check(rootId, parentCb.checked); - if (rootNode.data && rootNode.data.path) { - mirrorChipletToLayers(rootNode.data.path, - parentCb.checked); - } + checkChiplet(rootId, rootNode.data && rootNode.data.path, + parentCb.checked); }); chipletHeader.appendChild(parentCb); } @@ -1298,8 +1291,7 @@ export function populateDisplayControls(app, visibility, selectability, checkbox.indeterminate = node.indeterminate; node.cb = checkbox; checkbox.addEventListener('change', () => { - chipletModel.check(node.id, checkbox.checked); - mirrorChipletToLayers(c.path, checkbox.checked); + checkChiplet(node.id, c.path, checkbox.checked); }); label.appendChild(checkbox); label.appendChild(makeSelSpacer()); @@ -1328,8 +1320,7 @@ export function populateDisplayControls(app, visibility, selectability, // the Qt GUI's selectability column (see displayControls.cpp). // The Hierarchy view checkbox governs two flags, and which one it turns on // depends on the tab's source. Derive only: redrawAllLayers repaints the - // two overlay layers along with everything else (they are in allLayers), - // and this runs on every checkbox in the tree, not just that one. + // base slot, which draws both overlays. const applyHierarchyOverlay = () => { // Only when a flag actually moved: this runs for every checkbox in the // tree, and the panel work below walks the whole tree of the view it @@ -1473,6 +1464,15 @@ export function populateDisplayControls(app, visibility, selectability, // so the restored Hierarchy view checkbox needs its flags derived once here. applyHierarchyOverlay(); + // A new slot requests its tiles at once, so it comes after every saved + // state that shapes them. + app.baseSlot = compositeSlot( + 'base', DRAW_ORDER.base, + [...underItems, ...routingLayers, clustersItem]); + app.topSlot = compositeSlot('top', DRAW_ORDER.top, topItems); + // What redrawAllLayers() refreshes. + app.allLayers = [app.baseSlot, app.topSlot]; + // ─── Per-renderer display controls ────────────────────────────────────── // The rows Qt's DisplayControls builds from Renderer::getDisplayControls() // (registerRenderer): one top-level group per renderer group name, with diff --git a/src/web/src/display-state.js b/src/web/src/display-state.js index f3257463622..946158d8811 100644 --- a/src/web/src/display-state.js +++ b/src/web/src/display-state.js @@ -56,7 +56,7 @@ const DISPLAY_STATE_KEYS = [ { key: 'or_defer_tile_updates', store: 'cookie' }, ]; -// The rendering preferences (#11340) from their cookies. +// The rendering preferences from their cookies. export function renderPrefs(getCookie) { return { // Animated zoom and pan, and drag inertia. Off by default, so diff --git a/src/web/src/hierarchy-browser.js b/src/web/src/hierarchy-browser.js index 2a63e7fbd56..538db130c7e 100644 --- a/src/web/src/hierarchy-browser.js +++ b/src/web/src/hierarchy-browser.js @@ -266,9 +266,8 @@ export class HierarchyBrowser { console.error('set_module_colors failed:', err); return; } - // Only the module overlay reads these colors, so refresh that layer - // instead of every mounted one — a full redraw re-requests every metal - // layer's grid for a color they ignore. + // Only the module overlay reads these colors, so refresh the slot that + // draws it instead of every slot. if (this._app.modulesLayer) { this._app.modulesLayer.refreshTiles(); } else { diff --git a/src/web/src/hierarchy-panel.js b/src/web/src/hierarchy-panel.js index 6cf4c46326f..98ae9cb6e85 100644 --- a/src/web/src/hierarchy-panel.js +++ b/src/web/src/hierarchy-panel.js @@ -173,11 +173,10 @@ export class HierarchyPanel { } } - // Move the overlay to the view now on screen. Repaints only the two - // pseudo-layers, and only when a flag actually moved: nothing else reads - // these flags, so a full redraw would re-request every metal layer's grid - // for a change they ignore. Display Controls does its own redraw, so it - // calls refreshActiveStatus() instead of this. + // Move the overlay to the view now on screen. Refreshes only the slot + // that draws the two pseudo-layers, and only when a flag actually moved. + // Display Controls does its own redraw, so it calls refreshActiveStatus() + // instead of this. syncOverlay() { const app = this._app; if (!app || !app.visibility) return; diff --git a/src/web/src/inspector.js b/src/web/src/inspector.js index e465989fe31..7010f35af95 100644 --- a/src/web/src/inspector.js +++ b/src/web/src/inspector.js @@ -89,7 +89,6 @@ const BUFFER_SVG = ''; export function createInspectorPanel(app, redrawAllLayers, refreshOverlay) { - refreshOverlay = refreshOverlay || redrawAllLayers; let lastInspectData = null; let pendingInspectId = null; let pendingHoverId = null; @@ -369,7 +368,7 @@ export function createInspectorPanel(app, redrawAllLayers, refreshOverlay) { } // Run `draw(t)` every frame for `cycles` of `cycleMs`, then `done()`. - // Reduced motion jumps to the end, as the stylesheet's rule did. + // Reduced motion skips straight to the end. function runKeyframes(cycleMs, cycles, draw, done) { if (prefersReducedMotion() || typeof requestAnimationFrame !== 'function') { @@ -487,6 +486,11 @@ export function createInspectorPanel(app, redrawAllLayers, refreshOverlay) { }); }); el.addEventListener('mouseleave', () => { + // A reply still on its way would draw the hover after the leave. + if (pendingHoverId !== null) { + app.websocketManager.cancel(pendingHoverId); + pendingHoverId = null; + } clearHoverHighlight(); refreshOverlay(); }); @@ -535,8 +539,8 @@ export function createInspectorPanel(app, redrawAllLayers, refreshOverlay) { pulseHighlight(data.bbox, data.type); } } - // Redraw tiles to restore selection-set highlights. - redrawAllLayers(); + // The selection-set highlights are drawn on the overlay. + refreshOverlay(); }) .catch(err => { pendingInspectId = null; diff --git a/src/web/src/label-manager.js b/src/web/src/label-manager.js index 6550bdd5ba8..f588d0d40fb 100644 --- a/src/web/src/label-manager.js +++ b/src/web/src/label-manager.js @@ -92,12 +92,15 @@ export class LabelManager { // selection if the label it pointed at is gone, or the Inspector would go // on showing a label that no longer exists. applyRemoteLabels(labels) { - this._applyLabels(labels); - if (this._selectedName - && !this._labels.some(l => l.name === this._selectedName)) { + // Dropped before the repaint, so the handles are drawn once. + const gone = this._selectedName + && !(labels || []).some(l => l.name === this._selectedName); + if (gone) { this._selectedName = null; + } + this._applyLabels(labels); + if (gone) { this._updateInspector(null); - this._renderHandles(); } this._app.refreshOverlay(); } @@ -305,7 +308,10 @@ export class LabelManager { anchor: patch.anchor, color: label.color, }); this._refresh(res); - this._select(label.name); + // Something else may have taken the selection while it was sent. + if (this._selectedName === label.name) { + this.refreshInspector(label.name); + } } catch (err) { console.error('edit label failed:', err); } diff --git a/src/web/src/layout-view.js b/src/web/src/layout-view.js index 11d40b66da0..85dc1723495 100644 --- a/src/web/src/layout-view.js +++ b/src/web/src/layout-view.js @@ -33,7 +33,8 @@ export const DRAW_ORDER = Object.freeze({ const noDepth = { depthCompare: 'always', depthWriteEnabled: false }; const ANIMATION_MS = 250; // zoom and pan duration -const kMaxAnimatedZoomDelta = 4; // larger jumps are not animated +const kSettleTimeoutMs = 6000; // whenTilesSettled gives up after +const kMaxAnimatedZoomDelta = 4; // larger jumps cut, or fly (curve) const kInertiaMs = 300; // The level above is kept loaded this many views around the view, so a zoom // out around any point finds its tiles there. @@ -100,7 +101,8 @@ function deviceInfo(d) { // prefs { smooth(), doubleBuffer(), defer() }, read live // tileSize() CSS px of a tile; dpr() the device pixel ratio // isStatic a saved report: no touch zoom -// raf, now injectable for tests +// preserveDrawingBuffer keep the canvas readable between frames (probes) +// raf, now, copyCanvas injectable for tests export function createLayoutView(container, opts = {}) { const deckApi = opts.deckApi !== undefined ? opts.deckApi : globalThis.deck; const copyCanvas = opts.copyCanvas || copyToCanvas2d; @@ -116,7 +118,7 @@ export function createLayoutView(container, opts = {}) { const vs = { target: [0, 0], zoom: 0, width: 1, height: 1 }; const limits = { minZoom: -Infinity, maxZoom: MAX_TILE_ZOOM }; - let anim = null; // { from, to, anchor, start, ms } + let anim = null; // the move in progress, see animateTo() let interacting = false; // a drag or pinch from the controller let gesturing = false; // a wheel or trackpad gesture (setGesture) let afterFrame = []; // called once deck has drawn its next frame @@ -327,7 +329,6 @@ export function createLayoutView(container, opts = {}) { if (zoomChanged) { events.emit('zoom'); } - events.emit('move'); if (tiles) { updateTiles(); } @@ -411,9 +412,6 @@ export function createLayoutView(container, opts = {}) { ms = flight ? flight.ms : animationMs(to); } startMove(); - if (to.zoom !== vs.zoom) { - events.emit('zoomstart'); - } if (ms <= 0) { anim = null; // settleView updates the tiles once, at rest: an update while @@ -544,15 +542,16 @@ export function createLayoutView(container, opts = {}) { // At rest only: it is background work and must not compete with the // view while it moves. const extra = []; + const apex = flightApex(); if (!anim && !interacting && !moving && swap.pendingZ === null) { prefetchZ = z > 0 ? z - 1 : null; - if (prefetchZ !== null) { + // A landed flight's level already covers the view. + if (prefetchZ !== null && prefetchZ !== apex?.z) { extra.push({ z: prefetchZ, range: tileRange( growRect(viewWorldRect(dest), kPrefetchMargin), prefetchZ, tileSize()) }); } } - const apex = flightApex(); if (apex) { extra.push({ ...apex, background: false }); } @@ -653,7 +652,6 @@ export function createLayoutView(container, opts = {}) { slots.set(id, slot); updateTiles(); return { - id, setVisible(v) { if (slot.visible === !!v) { return; @@ -671,11 +669,6 @@ export function createLayoutView(container, opts = {}) { scheduleRender(); } }, - remove() { - slot.grid.clear(); - slots.delete(id); - scheduleRender(); - }, }; } @@ -788,7 +781,7 @@ export function createLayoutView(container, opts = {}) { // While hidden levels load, their tiles fill what the shown levels do not // cover, such as the new edges of a zoom out. A mask in the background - // colour keeps them from showing through the shown tiles' clear pixels. + // color keeps them from showing through the shown tiles' clear pixels. function underlay(slot, zs, levels, view, flash) { const out = []; for (const z of zs) { @@ -818,8 +811,10 @@ export function createLayoutView(container, opts = {}) { const pad = 1 / Math.pow(2, vs.zoom); const masks = []; for (const tile of slot.grid.tiles.values()) { + // A tile that failed with no image hides nothing under it. if (!zs.includes(tile.z) - || (tile.loading && (settledOnly || !tile.drawable))) { + || (tile.loading && (settledOnly || !tile.drawable)) + || (tile.failed && !tile.drawable)) { continue; } const bounds = boundsOf(tile); @@ -864,7 +859,7 @@ export function createLayoutView(container, opts = {}) { fills.push({ polygon: pts, color: s.fill }); } if (s.stroke) { - const closed = s.kind === 'rect' || s.closed; + const closed = s.kind === 'rect'; strokes.push({ path: closed ? [...pts, pts[0]] : pts, color: s.stroke, width: s.width || 1, dash: s.dash || null }); @@ -952,12 +947,13 @@ export function createLayoutView(container, opts = {}) { if (tiles.animate) { scheduleRender(); } - events.emit('render'); } // Share of the view inside the tile grid that shows a settled base tile // of a level being drawn: the browser probes' blank metric. - function coverage(nx = 32, ny = 20) { + function coverage() { + const nx = 32; + const ny = 20; const slot = slots.get('base'); if (!slot) { return null; @@ -1061,12 +1057,13 @@ export function createLayoutView(container, opts = {}) { }, // Zoom by `delta` levels from the level an animation is heading to, - // keeping the point under `screenPt` still (the centre when null). + // keeping the point under `screenPt` still (the center when null). // `settle: false` (with `animate: false`) keeps a fractional zoom for // a gesture still under way; a later call settles it. zoomAround(screenPt, delta, { animate, settle = true } = {}) { const zoom = clampZoom(view.getTargetZoom() + delta, limits); - const base = tileView(); + // An anchor holds what is under it now, as stepAnimation does. + const base = screenPt ? vs : tileView(); const pt = screenPt || [vs.width / 2, vs.height / 2]; const target = zoomAroundTarget(base, pt, zoom); animateTo({ target, zoom }, @@ -1126,7 +1123,7 @@ export function createLayoutView(container, opts = {}) { }, // A DOM element pinned to a world point: its top-left corner, or its - // centre with `center`. + // center with `center`. addMarker(group, id, world, el, { center = false } = {}) { const g = markerGroup(group); const old = g.items.get(id); @@ -1184,9 +1181,10 @@ export function createLayoutView(container, opts = {}) { }, // Resolves once every visible slot has loaded what is on screen and - // no level change or animation is in progress. - whenTilesSettled({ timeoutMs = 6000 } = {}) { - const deadline = now() + timeoutMs; + // no level change or animation is in progress, or after + // kSettleTimeoutMs. + whenTilesSettled() { + const deadline = now() + kSettleTimeoutMs; return new Promise((resolve) => { const poll = () => { if ((allSettled() && swap.isIdle() && !anim && !moving) diff --git a/src/web/src/main.js b/src/web/src/main.js index 7ccd4335e36..0377dd18847 100644 --- a/src/web/src/main.js +++ b/src/web/src/main.js @@ -5,7 +5,7 @@ import { GridLayoutManager } from './grid-layout.js'; import { dbuToWorld, dbuRectToWorldRect, worldToDbu } from './coordinates.js'; import { WebSocketManager } from './websocket-manager.js'; import { createLayoutView, DRAW_ORDER } from './layout-view.js'; -import { installViewInput } from './view-input.js'; +import { installViewInput, placementClicks } from './view-input.js'; import { buildHeatmapRequest, buildOverlayRequest, createImageSource, } from './tile-sources.js'; @@ -21,7 +21,7 @@ import { createInspectorPanel } from './inspector.js'; import { SelectionBrowser } from './selection-browser.js'; import { applySelectionFlags, beginSelection, boundsEqual, buildVisibilityFlags, clampArrowStep, computeBoundsTransforms, - computeScaleBar, decorateTabIcons, fittedTileSizeCss, formatDbu, + computeScaleBar, fittedTileSizeCss, formatDbu, formatDistance, isCurrentSelection, isStaticMode, maxUsefulZoom, parseDbu, rafCoalesce, renderingWarning, showCornerWarning, showToast, unitLabel, websocketUrlFrom } @@ -155,7 +155,6 @@ const app = { // added (computeBoundsTransforms). Anything wanting the design's own // extent has to work from the DBU rects, not from this. fitRect: null, - lastSelectionBounds: null, // DBU rect of the last selected object selHasInst: false, // selection contains any instance selHasNet: false, // selection contains any net displayControlsEl: null, @@ -172,9 +171,6 @@ const app = { // Draw-list items of the pseudo layers (display-controls.js). modulesLayer: null, clustersLayer: null, - pinsLayer: null, - // [{ def, layer }] per overlay the tech response lists. - overlayLayers: [], focusNets: new Set(), routeGuideNets: new Set(), visibleLayers: new Set(), @@ -208,7 +204,7 @@ const app = { wheelZoom: getCookie('or_wheel_zoom') !== '0', // Qt's "Arrow keys scroll step", in CSS px. arrowStep: clampArrowStep(getCookie('or_arrow_step')), - // Rendering preferences (#11340): smoothing, double buffering, defer. + // Rendering preferences: smoothing, double buffering, defer. ...renderPrefs(getCookie), // Qt's "Application font", split into the CSS family and a percentage // scale over the stylesheet's authored sizes. Empty family = the @@ -564,7 +560,7 @@ function applyDisplayState(state) { const entries = state.entries; if (!entries || typeof entries !== 'object') return; applyDisplayStateEntries(entries); - // Preserve the current view so restoring controls doesn't move the map. + // Preserve the current view so restoring controls doesn't move the view. // Kept in DBU: the world scale follows the tile size, which may change. try { if (app.view && app.designScale && typeof sessionStorage !== 'undefined') { @@ -734,16 +730,7 @@ function createLayoutViewer(container) { isStatic: () => isStaticMode(app), wheelZoom: () => app.wheelZoom, arrowStep: () => app.arrowStep, - contextEnabled: () => !(app.rulerManager && app.rulerManager.isActive()), - onClick: (world, e) => { - if (app.rulerManager && app.rulerManager.isActive()) { - app.rulerManager.handleMapClick(world, e); - } else if (app.rulerManager?.handleRulerClick(world)) { - // A ruler line took the click. - } else if (app.onMapClick) { - app.onMapClick(world, e); - } - }, + ...placementClicks(app), onContextClick: (world, e) => { if (app.onMapContextClick) { app.onMapContextClick(world, e); @@ -834,8 +821,7 @@ function createLayoutViewer(container) { // Coalesce updates during continuous zoom gestures so the bar tracks // the animation instead of only snapping at gesture end. Pan doesn't - // change the bar (geometry depends only on zoom and container width), - // so 'move'/'moveend' are deliberately not listened to. + // change the bar (geometry depends only on zoom and container width). const scheduleUpdateScaleBar = rafCoalesce(updateScaleBar); app.view.on('zoom zoomend resize', scheduleUpdateScaleBar); app.updateScaleBar = updateScaleBar; @@ -1200,8 +1186,8 @@ app.goldenLayout.registerComponentFactoryFunction('SelectHighlight', createSelec const staticCache = window.__STATIC_CACHE__ || null; if (staticCache) { - // Before any layer or the map scale is built: a report's tiles are baked at - // a fixed size and cannot be re-rendered to fit a different box. + // Before any layer or the view scale is built: a report's tiles are baked + // at a fixed size and cannot be re-rendered to fit a different box. useStaticTileSize(); app.websocketManager = WebSocketManager.fromCache(staticCache, scheduleUpdateStatus); @@ -1298,7 +1284,7 @@ app.toggleWheelZoom = function() { scheduleSyncDisplayState(); }; -// ── Rendering preferences (#11340) ── +// ── Rendering preferences ── // // The view reads all three live; double buffering and defer also re-plan the // tiles at once, so a level held back by them is not left waiting. @@ -1467,7 +1453,7 @@ function ensureDebugContinueButton() { // `designBounds` georeferences the tile grid; `fitRect` is what Fit frames. // They differ by the pin-label margin the server adds to the former. function applyBounds(designBounds, fitRect) { - // The map's whole coordinate system is defined in units of one tile, so + // The view's whole coordinate system is defined in units of one tile, so // this must be the size the layers actually use. const t = computeBoundsTransforms(designBounds, tileSizeCss(), fitRect); if (!t) return false; @@ -1763,7 +1749,7 @@ app.websocketManager.readyPromise.then(async () => { const fitRect = boundsData.fit_bounds; // Size the tiles so the fit below lands on an integer zoom level. - // Must precede applyBounds, which derives the map's coordinate scale + // Must precede applyBounds, which derives the view's coordinate scale // from the tile size, and populateDisplayControls, which builds the // layers with it. Static reports are pre-rasterized at a fixed size // (useStaticTileSize above), so they are not free to choose. @@ -1830,14 +1816,14 @@ app.websocketManager.readyPromise.then(async () => { document.getElementById('loading-overlay').style.display = 'none'; } // Shared select-at-point logic used by left-click and right-click. - // Returns the server response (or null). `focusInspector` switches the + // Resolves once the reply is handled. `focusInspector` switches the // panel to the Inspector (left-click); right-click keeps the current // panel and only updates the selection so the context menu can reflect // the object under the cursor. function selectAtWorld(world, opts = {}) { const { addToSelection = false, focusInspector = true, context = false, showConnectivity = false } = opts; - if (!app.designScale) return Promise.resolve(null); + if (!app.designScale) return Promise.resolve(); const { dbuX: dbu_x, dbuY: dbu_y } = worldToDbu( world[0], world[1], app.designScale, app.designOriginX, app.designOriginY); @@ -1846,7 +1832,7 @@ app.websocketManager.readyPromise.then(async () => { // instead of selecting (2.12). if (app.labelManager && app.labelManager.isActive()) { app.labelManager.handleMapClick(dbu_x, dbu_y); - return Promise.resolve(null); + return Promise.resolve(); } const vf = buildVisibilityFlags(visibility, selectability); @@ -1889,7 +1875,6 @@ app.websocketManager.readyPromise.then(async () => { // this response describes a selection that no longer // exists, so it must not drive the Inspector. if (!isCurrentSelection(app, token)) return; - console.log('Select response:', data, 'at dbu', dbu_x, dbu_y); // Type flags so the context menu can enable items by type. applySelectionFlags(app, data); if (data.selected && data.selected.length > 0) { @@ -1918,8 +1903,6 @@ app.websocketManager.readyPromise.then(async () => { highlightBBox(data.bbox[0], data.bbox[1], data.bbox[2], data.bbox[3], data.type); pulseHighlight(data.bbox, data.type); - // Remember bounds for "Zoom to Selection". - app.lastSelectionBounds = data.bbox.slice(0, 4); } if (selectRequest.show_connectivity && data.connected_added > 0) { @@ -1932,17 +1915,13 @@ app.websocketManager.readyPromise.then(async () => { // right-click (context) keeps the current selection. updateInspector(null); if (app.clearSelectionOutline) app.clearSelectionOutline(); - app.lastSelectionBounds = null; } scheduleRefreshOverlay(); - return data; }) .catch(err => { console.error('Select failed:', err); - return null; }); } - app.selectAtWorld = selectAtWorld; if (!staticCache) { app.onMapClick = (world, e) => selectAtWorld(world, { @@ -2043,7 +2022,7 @@ document.addEventListener('keydown', (e) => { } else if (key === 'f' && !e.ctrlKey && !e.metaKey && app.fitRect) { app.view.fitWorldRect(app.fitRect); } else if (key === 'z' && !e.ctrlKey && app.view) { - // Around the pointer when it is over the layout, else the centre. + // Around the pointer when it is over the layout, else the center. const delta = e.shiftKey ? -1 : 1; app.view.zoomAround(app.lastMouseWorld ? app.view.project(app.lastMouseWorld) : null, delta); diff --git a/src/web/src/menu-bar.js b/src/web/src/menu-bar.js index 3f15a85f7dd..265e1dbb9a8 100644 --- a/src/web/src/menu-bar.js +++ b/src/web/src/menu-bar.js @@ -133,7 +133,7 @@ export function createMenuBar(app) { { label: 'Application font...', action: () => app.showAppFontDialog() }, { type: 'separator' }, - // Rendering preferences (#11340). Web-only: Qt has no smoothing + // Rendering preferences. Web-only: Qt has no smoothing // to turn off and already draws off-screen. { label: 'Smooth zoom and pan', action: () => app.toggleControlSmoothing(), diff --git a/src/web/src/request_handler.cpp b/src/web/src/request_handler.cpp index c24322f4c2a..bc6ecc2795b 100644 --- a/src/web/src/request_handler.cpp +++ b/src/web/src/request_handler.cpp @@ -5216,9 +5216,6 @@ WebSocketResponse SelectHandler::handleGet3DData(const WebSocketRequest& req) boost::json::object root; boost::json::array chiplets; std::map chiplet_indices; - // Held, not borrowed: the cached list is replaced when another thread - // notices a chip placement edit, and the bump and net walks below take a - // while. const auto node_list = gen_->chiplets(); const std::vector& nodes = *node_list; diff --git a/src/web/src/request_handler.h b/src/web/src/request_handler.h index 4af32a2b7eb..3f769ef93f2 100644 --- a/src/web/src/request_handler.h +++ b/src/web/src/request_handler.h @@ -551,9 +551,9 @@ struct SessionState // Map an HTTP request target onto an embedded asset path. // // Strips the query string and fragment, which the asset lookup must not see: -// the viewer's options are passed as query parameters (?mergetiles=0 and -// friends), and matching "/?mergetiles=0" against the asset table simply fails, -// so the whole page 404s. Also maps "/" onto the index document. +// the viewer's options are passed as query parameters (?preservebuffer=1 and +// friends), and matching "/?preservebuffer=1" against the asset table simply +// fails, so the whole page 404s. Also maps "/" onto the index document. std::string assetPathFromTarget(std::string_view target); // Join `t`, or detach it when called from `t` itself, where a join throws diff --git a/src/web/src/ruler.js b/src/web/src/ruler.js index fba4600c364..e0fee6c7ad5 100644 --- a/src/web/src/ruler.js +++ b/src/web/src/ruler.js @@ -83,6 +83,8 @@ export class RulerManager { } cancelRulerBuild() { + clearTimeout(this._snapTimer); + this._snapTimer = null; this._state = IDLE; this._pt0 = null; this._lastSnapResult = null; @@ -187,7 +189,7 @@ export class RulerManager { const zoom = app.view.getZoom(); const numTiles = Math.pow(2, Math.max(0, zoom)); // designScale is CSS px per DBU at zoom 0, so it already carries the - // tile size the map was built with -- which is not a constant. + // tile size the view was built with -- which is not a constant. const dbuPerPixel = 1 / (app.designScale * numTiles); const pointThreshold = Math.max(Math.round(10 * dbuPerPixel), 10); @@ -228,6 +230,10 @@ export class RulerManager { ...vf, }); + // Cancelled while the reply was on its way. + if (this._state === IDLE) { + return; + } this._lastSnapResult = result; this._updateSnapIndicator(result); this._updatePreview(dbuX, dbuY); @@ -539,7 +545,7 @@ export class RulerManager { break; } this._renderAll(); - this._selectRuler(ruler.id); + this.refreshInspector(); }, }; diff --git a/src/web/src/search-nav.js b/src/web/src/search-nav.js index 927926f2f9f..f2a70800880 100644 --- a/src/web/src/search-nav.js +++ b/src/web/src/search-nav.js @@ -6,9 +6,9 @@ // - Go to position: jump the view to x,y in microns (mirrors Qt GotoDialog). // Both reuse the .modal-overlay/.modal-dialog pattern from menu-bar.js. -import { dbuRectToWorldRect, dbuToWorld, worldToDbu } from './coordinates.js'; -import { applySelectionFlags, beginSelection, buildModal, isCurrentSelection } - from './ui-utils.js'; +import { dbuToWorld, worldToDbu } from './coordinates.js'; +import { applySelectionFlags, beginSelection, buildModal, isCurrentSelection, + zoomToBBox } from './ui-utils.js'; // The .search-nav-dialog rules size these two dialogs' rows; every caller here // passes it so buildModal itself stays dialog-agnostic. @@ -79,22 +79,20 @@ export function showFindDialog(app) { return; } beginSelection(app); + // The outline is the last clicked object's; Find replaced it. + app.clearSelectionOutline?.(); applySelectionFlags(app, resp); // Auto-zoom to the matched objects — an improvement over the Qt // Find dialog, which only selects without centering. if (Array.isArray(resp.bbox)) { - app.lastSelectionBounds = resp.bbox.slice(0, 4); - app.view.fitWorldRect(dbuRectToWorldRect( - ...app.lastSelectionBounds, app.designScale, - app.designOriginX, app.designOriginY)); + zoomToBBox(app, resp.bbox, 0); } if (typeof app.updateInspector === 'function') { app.updateInspector(resp); } - if (typeof app.redrawAllLayers === 'function') { - app.redrawAllLayers(); - } - app.selectionBrowser?.scheduleRefresh(); + // The selection is drawn on the overlay only; this also + // refreshes the Select Highlight panel. + app.refreshOverlay?.(); const shown = resp.selection_count || count; showError(resp.truncated ? `${count} found (showing first ${shown}).` @@ -157,9 +155,8 @@ export function showGotoDialog(app) { const sizeDbu = sizeVal ? parse(sizeVal) : null; if (sizeDbu !== null && sizeDbu > 0) { const half = sizeDbu / 2; - app.view.fitWorldRect(dbuRectToWorldRect( - dbuX - half, dbuY - half, dbuX + half, dbuY + half, - app.designScale, app.designOriginX, app.designOriginY)); + zoomToBBox(app, [dbuX - half, dbuY - half, dbuX + half, dbuY + half], + 0); } else { app.view.setView(dbuToWorld(dbuX, dbuY, app.designScale, app.designOriginX, app.designOriginY), diff --git a/src/web/src/tile-grid.js b/src/web/src/tile-grid.js index 222612f54d4..4ae0d4b1e6c 100644 --- a/src/web/src/tile-grid.js +++ b/src/web/src/tile-grid.js @@ -60,10 +60,6 @@ export class TileGrid { } continue; } - // Kept from before a refresh: fetch again once it is in the ring. - if (this._stale(tile) && inRange(ring, tile.x, tile.y)) { - this._load(tile, !inRange(range, tile.x, tile.y)); - } if (inRange(ring, tile.x, tile.y)) { if (tile.loading && tile.background && inRange(range, tile.x, tile.y)) { @@ -72,19 +68,23 @@ export class TileGrid { } continue; } - if (tile.loading || !(this._inKeepBuffer(tile) + // A view off the grid keeps what it had, for when it pans back. + if (tile.loading || !(range === null || this._inKeepBuffer(tile) || (hold && inRange(hold, tile.x, tile.y)))) { this._drop(tile); } } - // On-screen tiles go out first, nearest the centre first. + // On-screen tiles go out first, nearest the center first. const wanted = [...rangeTiles(range), ...rangeTiles(ring).filter( (t) => !inRange(range, t.x, t.y))]; for (const { x, y } of wanted) { - if (!this.tiles.has(tileKey(z, x, y))) { - this._load(this._newTile(z, x, y), - !inRange(range, x, y)); + const tile = this.tiles.get(tileKey(z, x, y)); + if (!tile) { + this._load(this._newTile(z, x, y), !inRange(range, x, y)); + } else if (this._stale(tile)) { + // Kept from before a refresh. + this._load(tile, !inRange(range, x, y)); } } for (const e of this.extra) { @@ -200,8 +200,8 @@ export class TileGrid { _newTile(z, x, y) { const tile = { z, x, y, key: tileKey(z, x, y), drawable: null, - loading: false, background: false, handle: null, - generation: -1 }; + loading: false, failed: false, background: false, + handle: null, generation: -1 }; this.tiles.set(tile.key, tile); return tile; } @@ -238,6 +238,7 @@ export class TileGrid { this._setDrawable(tile, drawable); } tile.loading = false; + tile.failed = false; tile.handle = null; this.onChange(tile); }, () => { @@ -246,6 +247,7 @@ export class TileGrid { return; } tile.loading = false; + tile.failed = true; tile.handle = null; this.onChange(tile); }); diff --git a/src/web/src/tile-merge.js b/src/web/src/tile-merge.js index d00a128f29f..06b6be9b317 100644 --- a/src/web/src/tile-merge.js +++ b/src/web/src/tile-merge.js @@ -3,21 +3,11 @@ // Client-side tile merging: composite the visible layout layers of one tile // into a single image, so the view holds and draws one texture per tile -// instead of one per layer. +// instead of one per layer. The server keeps one cached tile per layer, which +// a layer toggle reuses. // -// WHY THE MERGE IS ON THE CLIENT -// -// The client already knows the exact stacking order and per-layer opacity, so -// merging here is one rasterization instead of K live layers, and the server -// keeps one cached tile per layer, which a layer toggle reuses. -// -// The mechanism that makes it work is `ImageBitmap.close()`: an gives no -// control over when its decoded bitmap is released, which is the whole problem. -// createImageBitmap + close() makes the lifetime explicit — decode K sources, -// draw them, release them immediately, and keep only the merged result. -// -// What it does NOT buy: bandwidth. The same K images are still fetched per -// tile. +// The sources are ImageBitmaps, closed as soon as the tile is complete: an +// gives no control over when its decoded bitmap is released. // Set a draw item's visibility, returning whether it actually changed. // @@ -46,25 +36,17 @@ export function setItemVisible(item, visible) { // Draw `sources` onto a 2D context in order, each at its own opacity. // // Straight src-over at the given alpha, which is what stacking the layers -// would do. Not bit-identical to GPU compositing — colour-space and rounding +// would do. Not bit-identical to GPU compositing — color-space and rounding // details differ — so assert on visual equivalence, never on byte equality. // // `sources` is [{ image, opacity }], bottom-most first. A null image is skipped // rather than throwing: one layer failing to decode must not lose the whole // group, which would turn a single missing layer into a blank tile. export function mergeOntoContext(ctx, sources, size) { - if (!ctx || !(size > 0)) { - return 0; - } ctx.clearRect(0, 0, size, size); let drawn = 0; - for (const source of sources || []) { - const image = source ? source.image : null; - if (!image) { - continue; - } - const opacity = source.opacity === undefined ? 1 : source.opacity; - if (!(opacity > 0)) { + for (const { image, opacity = 1 } of sources) { + if (!image || !(opacity > 0)) { continue; } ctx.globalAlpha = Math.min(1, opacity); @@ -129,58 +111,30 @@ export function closeAll(images) { // ─── Rendering one merged tile ────────────────────────────────────────────── // -// The orchestration, with every browser dependency injected so it can be tested -// without a DOM: `request` fetches one item's tile, `decode` turns a payload -// into something drawable, `draw` composites, `release` frees the decodes. -// -// Ordering: the K requests go out together, because they are independent and -// serialising them would multiply latency by K. The canvas is recomposited -// from scratch on every arrival, always walking the item list in order, so the -// stacking cannot depend on the order responses happen to land in. -// -// Incremental (the default): the tile paints as soon as anything arrives rather -// than waiting for the slowest of its K layers, and keeps repainting as the rest -// land. A request that never settles therefore costs one missing layer instead -// of a blank tile; waiting for the whole group would blank the whole tile. +// Every browser dependency is injected: `request` fetches one item's tile, +// `decode` turns a payload into something drawable and `draw` composites. +// `items` is never empty; the source skips such a tile. // -// `incremental: false` (Options > "Double buffering") paints once, after every -// request has settled, so a refreshed tile swaps whole, not layer by layer. +// The requests go out together, and every arrival recomposites the list in +// order, so the stacking does not depend on the order the replies land in. // -// Lifetime: every decoded image is released in a finally, including on a draw -// failure or a stale abort. Explicit release is the entire reason for -// ImageBitmap over ; leaking here would reintroduce exactly the unbounded -// decoded-image growth this exists to bound. That rests on `request` always -// settling: a cancelled request has to reject rather than stay pending, or the -// finally never runs and the group's decodes are stranded (see -// WebSocketManager.cancel, which rejects both the queued and the sent case). +// Incremental (the default) paints as soon as anything arrives, so a request +// that never settles costs one layer, not the tile. `incremental: false` +// (Options > "Double buffering") paints once, after every request settled. // -// Partial failure is survivable by design: one item that fails to arrive or -// decode is skipped and the rest of the group still paints. Blanking the whole -// tile because one layer failed would turn a single dropped request into the -// symptom being fixed. +// Every decode is closed in a finally, so `request` must always settle: a +// cancelled request rejects (WebSocketManager.cancel). An item that fails to +// arrive or decode is skipped and the rest still paints. export async function renderMergedTile({ items, request, decode, draw, - release = closeAll, isStale = () => false, incremental = true, -} = {}) { - const list = Array.isArray(items) ? items : []; - const stats = { requested: list.length, arrived: 0, decoded: 0, drawn: 0, - paints: 0, failed: 0, stale: false }; - if (list.length === 0) { - // An empty group still has to paint: the canvas is reused across - // refreshes, so skipping the draw would leave the previous content. - // Guarded only so a no-argument call is harmless — a real caller that - // forgets `draw` with a non-empty group still fails loudly below, - // which is what you want for a missing required dependency. - if (typeof draw === 'function') { - draw([]); - } - return stats; - } +}) { + const stats = { requested: items.length, arrived: 0, decoded: 0, drawn: 0, + failed: 0, stale: false }; // A slot that has not arrived yet is drawn as nothing. That is exact, not // an approximation: transparent is the identity for src-over, so @@ -189,24 +143,21 @@ export async function renderMergedTile({ // what lets the tile paint before every layer is in without any risk of // getting the stacking wrong — the list is still walked in order every // time, so there is no prefix pointer or gap handling to get wrong. - const images = new Array(list.length).fill(null); - let painted = false; + const images = new Array(items.length).fill(null); function paint() { if (isStale()) { stats.stale = true; return; } - stats.drawn = draw(list.map((item, i) => ({ + stats.drawn = draw(items.map((item, i) => ({ image: images[i], opacity: item.opacity, }))) || 0; - stats.paints++; - painted = true; } try { - await Promise.all(list.map(async (item, i) => { + await Promise.all(items.map(async (item, i) => { let payload = null; try { payload = await request(item); @@ -236,10 +187,8 @@ export async function renderMergedTile({ } })); - // The only paint when buffering; otherwise the case where nothing - // arrived at all, so the tile resolves as blank rather than staying - // invisible forever. - if (!painted) { + // Buffered: the one paint, once every request settled. + if (!incremental) { paint(); } } finally { @@ -247,7 +196,7 @@ export async function renderMergedTile({ // later arrival belongs UNDERNEATH layers already drawn, so the canvas // is recomposited from scratch each time and every source has to still // be available. - release(images); + closeAll(images); } return stats; } diff --git a/src/web/src/tile-request.js b/src/web/src/tile-request.js index 6a80dea9bcd..7fef691b4df 100644 --- a/src/web/src/tile-request.js +++ b/src/web/src/tile-request.js @@ -110,7 +110,7 @@ export function isDeviceExactTileSize(size, dpr) { // Adopt a tile size picked to make zoom-to-fit land on an integer zoom level // (see fittedTileSizeCss). Like the two setters above this must run before any -// layer is built: the map's coordinate scale is derived from it. +// layer is built: the view's coordinate scale is derived from it. // // Safe because the tile grid is indexed by zoom alone — tile (z,x,y) covers // maxDXDY/2^z DBU whatever its pixel size — so this changes the resolution the @@ -155,7 +155,7 @@ export function nativeDpr() { // browser, so all three have to be rendered at the same pixel count and land on // the same grid; an overlay half a pixel off, or an image the browser has to // rescale, shows up as a blurred or misregistered highlight. -export function tileSizeFields(dpr, tileSize = tileSizeCss()) { +export function tileSizeFields(dpr, tileSize) { return { // Rounded here and nowhere else: this field feeds the server's cache // key and its CSS-authored sizes (fonts, pen widths), both of which @@ -188,7 +188,7 @@ export function hasEntries(map) { // `row` is the Display Controls row asking: `chiplet` is the die it draws (two // dies can share a layer name), `rowId` keys its fill pattern and // `rendererHost` marks the row that carries the renderers' layer pass. -export function tileRequestBuilder(coords, ctx, dpr, tileSize = tileSizeCss()) { +export function tileRequestBuilder(coords, ctx, dpr, tileSize) { const { visibility, selectability, visibleLayers, selectableLayers, app } = ctx; const shared = { @@ -203,14 +203,16 @@ export function tileRequestBuilder(coords, ctx, dpr, tileSize = tileSizeCss()) { if (app && app.visibleChiplets instanceof Set) { shared.visible_chiplets = [...app.visibleChiplets]; } + const hiddenPerDie = app && hasEntries(app.chipletHiddenLayers) + ? app.chipletHiddenLayers : null; return (layerName, row = {}) => { const req = { type: 'tile', layer: layerName, ...shared }; // A row is only requested while it is checked, so a die's exceptions // cannot change its pixels; leaving them out keeps its cache key stable. if (row.chiplet) { req.chiplet = row.chiplet; - } else if (app && hasEntries(app.chipletHiddenLayers)) { - req.chiplet_hidden_layers = app.chipletHiddenLayers; + } else if (hiddenPerDie) { + req.chiplet_hidden_layers = hiddenPerDie; } // Debug tiles skip the cache, so this flag cannot fragment it. if (row.rendererHost && shared.debug_renderers) { diff --git a/src/web/src/tile-sources.js b/src/web/src/tile-sources.js index 22abaf29ae3..c8db5288244 100644 --- a/src/web/src/tile-sources.js +++ b/src/web/src/tile-sources.js @@ -13,7 +13,7 @@ import { closeAll, mergeOntoContext, renderMergedTile } from './tile-merge.js'; import { tileMayHaveContent } from './layer-extents.js'; // Decode a tile payload: a Blob from the server, or a data URI from a saved -// report. Straight alpha and no colour conversion, so the pixels reach the +// report. Straight alpha and no color conversion, so the pixels reach the // GPU as the server wrote them. function decodeTilePayload(payload) { if (payload == null) { @@ -122,7 +122,7 @@ function loadHandle(wm, ids, promise, onCancel) { }, promote() { for (const id of ids) { - wm.promote?.(id); + wm.promote(id); } }, }; @@ -177,7 +177,7 @@ export function createCompositeSource({ g = canvas.getContext('2d'); } const drawn = mergeOntoContext(g, sources, px); - if (progressive && drawn > 0 && !cancelled) { + if (progressive && drawn > 0) { onPartial(snapshot(canvas)); } return drawn; diff --git a/src/web/src/tile_generator.cpp b/src/web/src/tile_generator.cpp index 78dc00fcd7a..5248ceb7f89 100644 --- a/src/web/src/tile_generator.cpp +++ b/src/web/src/tile_generator.cpp @@ -1696,7 +1696,7 @@ TileGenerator::TileGenerator(odb::dbDatabase* db, TileGenerator::~TileGenerator() = default; -void TileGenerator::ensureInit() +void TileGenerator::ensureInit(const bool fresh_cache) { std::lock_guard lock(init_mutex_); // Read first: a load landing during the init brings on the next one. @@ -1708,13 +1708,13 @@ void TileGenerator::ensureInit() init_chip_ = db_->getChip(); return; } - // No reindex, but nothing cached from before: an edit ODB does not report - // leaves no stale tile behind. const int margin = pin_label_margin_dbu_; computePinLabelMargin(); if (pin_label_margin_dbu_ != margin) { onDesignChanged(); // a new margin moves every tile - } else { + } else if (fresh_cache) { + // A new session starts clean: an edit ODB does not report leaves no + // stale tile behind. clearTileCache(); } } @@ -1993,11 +1993,8 @@ std::shared_ptr> TileGenerator::chiplets() const void TileGenerator::refreshChipletsLocked() const { - // ODB itself is not thread-safe, so callers serialize web requests - // against design mutations. The fingerprint check (root pointer + - // chiplet placement hash) only needs to detect *sequential* Tcl mutations - // — taking the lock before reading root/hash keeps the fingerprint - // and the cached values consistent with each other. + // ODB itself is not thread-safe, so callers serialize web requests against + // design mutations. odb::dbChip* root = db_->getChip(); const size_t inst_hash = hashChipInsts(root); if (!chiplets_cache_ || chiplets_cache_root_ != root @@ -4580,17 +4577,9 @@ std::vector TileGenerator::saveImageLayerOrder( const TileVisibility& vis, const std::vector& tech_layers) { - // Bottom to top, by the SAME z order the client stacks the layers in on - // screen (the draw lists in display-controls.js): the view paints in - // that order, so a PNG composited in any other order is not the view - // the user saw. Compositing in registry order — every pseudo layer last — - // put the manufacturing grid over the routing and the pin markers over the - // tech layers. These three mirror the client's non-pseudo values; - // PseudoLayerDef::z_index carries the overlays'. - // - // `tech_layers` arrives already in the client's paint order — see - // paintOrderLayers(), which is where a face-down die's reversal happens. - // This function only interleaves the pseudo layers with it. + // Bottom to top in the client's draw order (display-controls.js), so the + // PNG is the view. `tech_layers` is already in it (paintOrderLayers()). + // The client's z values; PseudoLayerDef::z_index has the overlays'. constexpr int kInstancesZ = 0; constexpr int kPinsZ = 1; constexpr int kTechLayerZBase = 3; @@ -4603,7 +4592,7 @@ std::vector TileGenerator::saveImageLayerOrder( ordered.emplace_back(kPinsZ, PaintLayer{.layer = "_pins", .chiplet = ""}); } // One z for every row, which the stable sort keeps in order: however many - // rows there are, they stay under the overlays, as the merged panes do. + // rows there are, they stay under the overlays, as in the client's draw list. for (const PaintLayer& entry : tech_layers) { if (!vis.isLayerShown(entry.layer) || vis.isLayerHiddenOn(entry.chiplet, entry.layer)) { @@ -4618,8 +4607,8 @@ std::vector TileGenerator::saveImageLayerOrder( } } // The "color by owner" overlays stack by the same rule; saveImage() drops the - // ones whose color map comes out empty. _modules goes under the routing, - // like the client's zIndex 2; _clusters over it, so metal does not cover the + // ones whose color map comes out empty. _modules goes under the routing, as + // in the client's base slot; _clusters over it, so metal does not cover the // partition, but below the Misc overlays, which start at 1000. if (vis.module_view) { ordered.emplace_back(2, PaintLayer{.layer = "_modules", .chiplet = ""}); @@ -4641,10 +4630,9 @@ const std::array& TileGenerator::pseudoLayerDefs() { // z_index mirrors the client's draw lists in display-controls.js (see - // saveImageLayerOrder); that order in turn follows the GUI's paint order - // (renderThread.cpp:1201-1298), where the manufacturing grid goes down before - // the routing layers, the instance names right after them, and access - // points, regions and the gcell grid on top. + // saveImageLayerOrder), which follow the GUI's paint order: the + // manufacturing grid before the routing layers, the instance names right + // after them, and access points, regions and the gcell grid on top. static const std::array defs = {{ {.name = "_access_points", .shown_by = {{"access_points"}}, @@ -8911,7 +8899,7 @@ boost::json::object serializeTechResponse(const TileGenerator& gen) out["has_liberty"] = gen.hasSta(); // The self-painting overlays this design can draw, from which the client - // builds its panes: name, pane order and when each shows. + // builds its draw lists: name, draw order and when each shows. const auto groups_json = [](const auto& groups) { boost::json::array arr; for (const auto& group : groups) { diff --git a/src/web/src/tile_generator.h b/src/web/src/tile_generator.h index 1d6cbc7aff9..3c74cef58e9 100644 --- a/src/web/src/tile_generator.h +++ b/src/web/src/tile_generator.h @@ -218,19 +218,12 @@ struct PaintLayer // Walk the chiplet hierarchy and return a flat list with each chiplet's // accumulated world transform. // -// Leaves come from ODB's unfolded model (dbUnfoldedChipInst), which already -// composes the dbChipInst transforms top-down — the web does not redo that -// arithmetic. The unfolded model holds leaves only: dbUnfoldedBuilder skips -// ChipType::HIER chips, which own no dbBlock and so have no geometry. Those -// intermediate nodes still group the UI trees, so they are synthesized here -// from the prefixes of each leaf's getChipInstPath(), as is the root (the -// unfolded model has no entry for the top chip). -// -// With use_unfolded_model=false, or when the model is empty (single-chip -// designs, load paths that never build it), the hierarchy is walked instead -// and the transforms composed here. Both routes produce the same nodes; the -// walk is what a caller uses when the model may be out of date, since ODB -// does not refresh it on edits and refreshing it from a read path is not safe. +// With use_unfolded_model=false, or when the model is empty, the hierarchy is +// walked and the transforms composed here; TileGenerator::chiplets() always +// walks, since ODB builds the unfolded model at load and never refreshes it. +// Otherwise leaves come from the model (dbUnfoldedChipInst), which holds leaves +// only, and the HIER nodes and the root are synthesized from the prefixes of +// each leaf's getChipInstPath(). Both routes produce the same nodes. // // Related Qt code: `LayoutViewer::getChips()` returns a flat // (dbChipInst → dbChip) PtrMap with no transform composition — this @@ -506,7 +499,7 @@ struct TileVisibility // TileGenerator::tileCacheKey(). void parseFromJson(const boost::json::object& json); - // JSON keys of every visibility flag parseFromJson reads. + // JSON keys of every visibility flag parseFromJson reads; for tests. static std::vector flagKeys(); bool isNetVisible(odb::dbNet* net) const; @@ -534,8 +527,9 @@ class TileGenerator ~TileGenerator(); void eagerInit(); - // eagerInit() after a design load; otherwise only an empty tile cache. - void ensureInit(); + // eagerInit() after a design load; otherwise the pin-label margin check, and + // with `fresh_cache` an empty tile cache. + void ensureInit(bool fresh_cache = false); bool shapesReady() const; bool hasSta() const { return sta_ != nullptr; } @@ -573,9 +567,9 @@ class TileGenerator std::vector getSites() const; - // Per-layer colors matching web::DisplayControls layer palette. Computed - // lazily and cached; the cache is rebuilt only if the tech changes. Shared, - // so eagerInit() can't free a map a renderer is still reading. + // Per-layer colors matching web::DisplayControls layer palette, built per + // tech on first use and dropped by eagerInit(). Shared, so that reset can't + // free a map a renderer is still reading. std::shared_ptr> getLayerColorMap( odb::dbTech* tech = nullptr) const; @@ -916,11 +910,11 @@ class TileGenerator // -> painter -> paint order. Single source of truth for the // renderTileBuffer dispatch, the pseudo-layer guard, saveImage's // layers_to_render and the overlays the tech response publishes, from which - // the client builds its panes. + // the client builds its draw lists. // // `shown_by` and `layers_by` are TileVisibility JSON keys in groups, read by // anyGroupOn(): on when every key of any one group is. `z_index` is the - // client's pane order, which saveImageLayerOrder() composites in. + // client's draw order, which saveImageLayerOrder() composites in. struct PseudoLayerDef { const char* name; @@ -1012,8 +1006,8 @@ class TileGenerator // 256*dpr*S is expensive, so pan/zoom-back and visibility toggles reuse // the cached bytes. LRU eviction at kTileCacheCap entries or // kTileCacheBytesCap bytes, whichever comes first; cleared on design - // reload via eagerInit() and on edits via onDesignChanged(). Thread-safe - // (mirrors chiplets_mutex_). + // reload via eagerInit(), on edits via onDesignChanged() and for a new + // session by ensureInit(true). Thread-safe (mirrors chiplets_mutex_). bool tileCacheGet(const std::string& key, std::vector& out) const; // `epoch` is tileCacheEpoch() from before the render: a tile rendered @@ -1244,7 +1238,8 @@ class TileGenerator utl::Logger* logger_; int num_threads_ = 0; std::unique_ptr search_; - // Cached by computePinLabelMargin(), which eagerInit() runs under readers. + // Cached by computePinLabelMargin(), which eagerInit() and ensureInit() run + // under readers. std::atomic pin_label_margin_dbu_{0}; // Cached layer-color map keyed by tech (see getLayerColorMap). Each tech is diff --git a/src/web/src/ui-utils.js b/src/web/src/ui-utils.js index d71f263c56c..cb06b92a26c 100644 --- a/src/web/src/ui-utils.js +++ b/src/web/src/ui-utils.js @@ -215,7 +215,7 @@ function bloatRect([[yMin, xMin], [yMax, xMax]], fraction) { // ([[yMin, xMin], [yMax, xMax]], the tile-grid georeference). Pure so it // can be unit-tested; returns null when the design is empty. // -// `fitRect`, in the same wire order, is what the map zooms to fit: the design +// `fitRect`, in the same wire order, is what the view zooms to fit: the design // without the pin-label margin the georeference rect carries. Framing on the // georeference rect instead leaves that margin as dead space around the design // (issue #11338). Omitted, the georeference rect is fitted, as before. @@ -231,7 +231,6 @@ export function computeBoundsTransforms(designBounds, tileSize = 256, const [[fitYMin, fitXMin], [fitYMax, fitXMax]] = bloatRect(fit, kZoomMargin); return { scale, - maxDXDY, originX: minX, originY: minY, // World rect [minX, minY, maxX, maxY] (layout-view.js). @@ -397,7 +396,7 @@ export function attachGroupCollapse(header, arrow, children, collapsed) { // Left unbounded the zoom keeps climbing past any useful magnification until // the arithmetic gives out: // the server's tile span (maxDXDY / 2^z) underflows to zero, so tiles come back -// empty and the design appears to vanish, and the map's own 2^z factors reach +// empty and the design appears to vanish, and the view's own 2^z factors reach // Infinity, which JSON.stringify writes as `null` in the tile request. // // The cap is where one DBU already covers `maxPxPerDbu` screen pixels: a DBU is @@ -455,7 +454,7 @@ export function maxUsefulZoom(designScale, maxPxPerDbu = 8) { // window resize detunes it until the next reload, which costs at worst the // level the fit loses today. export function fittedTileSizeCss({ designBounds, fitRect, viewW, viewH }) { - // The framed box, margin and fit-rect fallback included, in the map units + // The framed box, margin and fit-rect fallback included, in the view's units // TILE_SIZE_CSS defines -- so this cannot drift from what the fit sees. const t = computeBoundsTransforms(designBounds, TILE_SIZE_CSS, fitRect); const finitePositive = (v) => Number.isFinite(v) && v > 0; diff --git a/src/web/src/view-input.js b/src/web/src/view-input.js index fd9780a8274..a7be684dc55 100644 --- a/src/web/src/view-input.js +++ b/src/web/src/view-input.js @@ -56,6 +56,25 @@ export function arrowPanOffset(key, step, shift) { // onClick(world, event), onContextClick(world, event) // onMove(world, event), onLeave(event) // contextEnabled() false while a ruler is being placed +// gestureIdleMs the pause that ends a trackpad gesture (tests) +// installViewInput's click options for the app: a ruler or a label being +// placed takes left clicks and turns off the context menu. +export function placementClicks(app) { + return { + contextEnabled: () => !(app.rulerManager?.isActive() + || app.labelManager?.isActive()), + onClick(world, e) { + if (app.rulerManager?.isActive()) { + app.rulerManager.handleMapClick(world, e); + } else if (app.labelManager?.isActive() + || !app.rulerManager?.handleRulerClick(world)) { + // In label mode this places the label. + app.onMapClick?.(world, e); + } + }, + }; +} + export function installViewInput(view, opts = {}) { const container = view.getContainer(); const isStatic = opts.isStatic || (() => false); diff --git a/src/web/src/view-math.js b/src/web/src/view-math.js index c3d55115249..e1a02470692 100644 --- a/src/web/src/view-math.js +++ b/src/web/src/view-math.js @@ -40,7 +40,7 @@ export function clampZoom(zoom, { minZoom = -Infinity, maxZoom = Infinity } = {} // The view that fits world `rect` with `padding` px on every side: the zoom is // floored to a whole level after rounding to 1/100 of a level, and the rect is -// centred. +// centered. export function fitView(rect, vs, { padding = [0, 0], minZoom, maxZoom } = {}) { const w = Math.max(1, vs.width - 2 * padding[0]); const h = Math.max(1, vs.height - 2 * padding[1]); @@ -109,7 +109,7 @@ export function inRange(range, x, y) { && y >= range.y0 && y <= range.y1; } -// Tiles of `range`, nearest the range centre first. +// Tiles of `range`, nearest the range center first. export function rangeTiles(range) { if (!range) { return []; @@ -200,7 +200,6 @@ export function easeOutQuad(t) { return 1 - (1 - t) * (1 - t); } -// Close to cubic-bezier(0, 0, 0.25, 1). export function easeOutCubic(t) { return 1 - Math.pow(1 - t, 3); } diff --git a/src/web/src/web.cpp b/src/web/src/web.cpp index 612e868ac84..dc535abc57c 100644 --- a/src/web/src/web.cpp +++ b/src/web/src/web.cpp @@ -1123,18 +1123,18 @@ void WebSocketSession::on_accept(beast::error_code ec) queue_response(cfg); } - // Build search indices in the background; tiles render without shapes - // until ready, then a "refresh" push notification triggers a redraw. + // In the background: index a newly loaded design and empty the tile cache; + // a "refresh" push then redraws. init_thread_ = std::thread([self = shared_from_this()]() { { const ScriptGateScope gate(self->tcl_eval_->script_gate, /*wait=*/true); if (!gate.entered()) { return; } - self->generator_->ensureInit(); + self->generator_->ensureInit(/*fresh_cache=*/true); } - // Refresh only when there is a design to draw. The gate is the dbChip, - // not the dbBlock: a 3DBlox top chip is HIER and has no block. + // Refresh only when there is a design to draw. The check is on the + // dbChip, not the dbBlock: a 3DBlox top chip is HIER and has no block. if (!self->generator_->getChip()) { return; } @@ -2737,8 +2737,8 @@ void WebServer::gifAddFrame(std::optional key, return; } - // Create generator on demand (server may not be running), and init it on the - // first frame only: ensureInit() empties the tile cache the browsers share. + // Create generator on demand (server may not be running); the design is + // static across a GIF's frames, so init it on the first one only. ensureGenerator(); if (gif->frame_count == 0) { generator_->ensureInit(); diff --git a/src/web/src/websocket-manager.js b/src/web/src/websocket-manager.js index 85db845c203..62e7dc244c4 100644 --- a/src/web/src/websocket-manager.js +++ b/src/web/src/websocket-manager.js @@ -18,9 +18,8 @@ // send rate to the server's actual response rate. // // The effective limit is announced by the server on connect (a {type:"config", -// max_in_flight} push, scaled to the machine size) so it isn't a magic client -// constant and can grow if the server becomes multi-threaded. This is only the -// fallback used until that message arrives. +// max_in_flight} push, scaled to the server's threads) so it isn't a magic +// client constant. This is only the fallback used until that message arrives. const DEFAULT_MAX_IN_FLIGHT = 48; // Hard backpressure cap: don't push more while this much is still unsent. With // the in-flight cap this should rarely bind. @@ -194,7 +193,7 @@ export class WebSocketManager { this.pending.clear(); this._bgSent.clear(); // Drop anything still queued — it never reached the wire. Reject so - // callers settle; tile callers .catch() and re-request on reconnect. + // callers settle; the server's refresh push redraws on reconnect. for (const queue of [this._queue, this._bgQueue]) { for (const [id, entry] of queue) { entry.reject(new Error('WebSocket closed')); @@ -295,7 +294,7 @@ export class WebSocketManager { console.error('Failed to parse server push JSON:', e); return; } - // The server announces the in-flight window sized to its machine. + // The server announces the in-flight window, from its thread count. // Consume it here rather than forwarding to onPush. if (msg && msg.type === 'config') { if (Number.isFinite(msg.max_in_flight)) { @@ -348,7 +347,7 @@ export class WebSocketManager { // tile consumer already treats a null payload as "draw nothing". handler.resolve(null); } else { - // An unrecognised payload type must still settle the promise, or + // An unrecognized payload type must still settle the promise, or // the tile it belongs to hangs unresolved forever and the view // never reveals it. A server newer than this client lands here. // @@ -457,18 +456,10 @@ export class WebSocketManager { return; } - // Already sent: stop tracking the reply, but do NOT free the wire slot - // or pump — the server still has to process those bytes, and the slot - // frees only when its (now stale) reply arrives. Freeing it here would - // let cancellation churn re-flood the socket. - // - // The promise is rejected as well, for the same reason as the queued - // branch: dropping the handler without settling leaves the caller - // awaiting forever, and a caller with a `finally` never runs it. - // renderMergedTile frees its decoded ImageBitmaps there, so a silent - // drop here means every pruned or refreshed tile keeps its decodes - // alive — the unbounded decoded-image growth the merge exists to bound. - // The stale reply is still ignored: the handler is gone from `pending`. + // Already sent: stop tracking the reply, but keep the wire slot until + // the stale reply arrives, or cancellation churn would re-flood the + // socket. The promise is rejected, so a caller's `finally` (where + // renderMergedTile frees its decodes) still runs. const sent = this.pending.get(id); const had = this.pending.delete(id); this._bgSent.delete(id); @@ -577,10 +568,8 @@ export class WebSocketManager { const key = (msg.chiplet ? msg.chiplet + '|' : '') + msg.layer + '/' + msg.z + '/' + msg.x + '/' + msg.y; const b64 = this._cache.tiles && this._cache.tiles[key]; - if (b64) { - return Promise.resolve('data:image/png;base64,' + b64); - } - return Promise.reject(new Error('Tile not cached: ' + key)); + // The report saves only tiles with content: a missing one is empty. + return Promise.resolve(b64 ? 'data:image/png;base64,' + b64 : null); } // Timing highlight — drive the overlay image. diff --git a/src/web/src/zoom-swap.js b/src/web/src/zoom-swap.js index 19fbd17eea1..c659980a2c2 100644 --- a/src/web/src/zoom-swap.js +++ b/src/web/src/zoom-swap.js @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright (c) 2026, The OpenROAD Authors -// Which tile levels the layout view draws while the zoom changes (#11340). +// Which tile levels the layout view draws while the zoom changes. // // Shared by every tile slot so they all change level together. With double // buffering the new level stays hidden, under the old one scaled, until every @@ -26,15 +26,14 @@ export class ZoomSwap { setTimer = (fn, ms) => setTimeout(fn, ms), clearTimer = (id) => clearTimeout(id), timeoutMs = ATOMIC_ZOOM_TIMEOUT_MS, - fadeMs = ZOOM_FADE_MS, onChange = () => {}, } = {}) { Object.assign(this, { isEnabled, isSmooth, reducedMotion, now, setTimer, - clearTimer, timeoutMs, fadeMs, onChange }); + clearTimer, timeoutMs, onChange }); this.shownZ = null; // level drawn as complete this.pendingZ = null; // level loading behind it (double buffering) this.under = []; // old levels kept under a progressive one - this.fade = null; // { fromZ, toZ, start, ms } + this.fade = null; // { fromZ, toZ, start } this._timer = null; } @@ -112,9 +111,9 @@ export class ZoomSwap { this.under = [...this.under.filter( (u) => u !== from && u !== this.shownZ), from].slice(-kMaxUnder); } - const ms = this.isSmooth() && !this.reducedMotion() ? this.fadeMs : 0; - this.fade = (ms > 0 && from !== null) - ? { fromZ: from, toZ: this.shownZ, start: this.now(), ms } + const fades = this.isSmooth() && !this.reducedMotion(); + this.fade = (fades && from !== null) + ? { fromZ: from, toZ: this.shownZ, start: this.now() } : null; this.onChange(); } @@ -129,7 +128,7 @@ export class ZoomSwap { // What to draw now, bottom first. plan(now = this.now()) { if (this.fade) { - const t = (now - this.fade.start) / this.fade.ms; + const t = (now - this.fade.start) / ZOOM_FADE_MS; if (t < 1) { return { draw: [{ z: this.fade.fromZ, opacity: 1 }, @@ -151,9 +150,9 @@ export class ZoomSwap { } // Nothing is waiting to be shown or fading in. - isIdle(now = this.now()) { + isIdle() { return this.pendingZ === null && this.under.length === 0 - && !this.plan(now).fading; + && !this.plan(this.now()).fading; } _clearTimer() { diff --git a/src/web/test/bundle_test.py b/src/web/test/bundle_test.py index 90b3666745c..aebbf0b6f7e 100644 --- a/src/web/test/bundle_test.py +++ b/src/web/test/bundle_test.py @@ -39,10 +39,6 @@ "https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733", # The namespace netlistsvg stamps into the SVG it produces. "https://github.com/nturley/netlistsvg", - # Links in the comments of luma.gl's shader sources. - "https://en.wikipedia.org/wiki/find_first_set", - "https://en.wikipedia.org/wiki/single-precision_floating-point_format", - "https://en.wikipedia.org/wiki/double-precision_floating-point_format", # The bare schemes loaders.gl tests a path against. "http://", "https://", @@ -160,6 +156,10 @@ def test_ships_the_bundled_licences(self): # EPL-1.0 asks where elkjs's source can be obtained; every entry says. self.assertEqual(text.count("\nSource: https://"), text.count("=" * 78) // 2) self.assertIn("\nSource: https://github.com/OpenKieler/elkjs\n", text) + # gl-matrix ships its license as LICENSE.md, which rules_js strips + # unless MODULE.bazel keeps it. + body = text.split("\ngl-matrix ", 1)[1].split("=" * 78)[1] + self.assertIn("Permission is hereby granted", body) class FoundryNames(unittest.TestCase): diff --git a/src/web/test/cpp/TestRequestHandler.cpp b/src/web/test/cpp/TestRequestHandler.cpp index 645650ea8b6..b4582da02d8 100644 --- a/src/web/test/cpp/TestRequestHandler.cpp +++ b/src/web/test/cpp/TestRequestHandler.cpp @@ -707,20 +707,16 @@ TEST_F(TileHandlerTest, TechIncludesHighlightPalette) EXPECT_EQ(first[3].as_int64(), 100); } -// A new connection starts from an empty tile cache, without a reindex. -TEST_F(TileHandlerTest, EnsureInitEmptiesTheTileCache) +// A new session's ensureInit(true) empties the tile cache; a non-session +// ensureInit() keeps it. +TEST_F(TileHandlerTest, OnlyANewSessionEmptiesTheTileCache) { gen_->ensureInit(); - const auto colors = gen_->getLayerColorMap(); - WebSocketRequest req; - req.id = 1; - req.type = WebSocketRequest::kTile; - req.json = parseObj(R"({"layer":"metal1","z":0,"x":0,"y":0})"); - handler_->handleTile(req, state_); - ASSERT_EQ(gen_->tileCacheSize(), 1u); + ASSERT_EQ(cachedAfterTile(R"({"layer":"metal1","z":0,"x":0,"y":0})"), 1u); gen_->ensureInit(); + EXPECT_EQ(gen_->tileCacheSize(), 1u); + gen_->ensureInit(/*fresh_cache=*/true); EXPECT_EQ(gen_->tileCacheSize(), 0u); - EXPECT_EQ(gen_->getLayerColorMap().get(), colors.get()); } // PNG dimensions live in the IHDR chunk: 8-byte signature, 4-byte length, @@ -1540,8 +1536,8 @@ TEST(AuthRedirectTarget, SwapsTheTicketForTheToken) TEST(AuthRedirectTarget, KeepsTheViewerOptionsAroundIt) { - // ?mergetiles=0 and friends are how the viewer is A/B tested; losing them - // in the redirect would silently ignore what the user asked for. + // The viewer's query options (e.g. ?preservebuffer=1); losing them in the + // redirect would silently ignore what the user asked for. EXPECT_EQ(authRedirectTarget("/?ticket=abc&mergetiles=0", "tok"), "/?token=tok&mergetiles=0"); EXPECT_EQ( @@ -1842,7 +1838,7 @@ TEST_F(TileHandlerTest, ScopedTileCacheIgnoresOtherChiplets) // Like visible_layers, the per-die exceptions key only the tiles that read // them. -TEST_F(TileHandlerTest, HiddenLayersPerDieOnlyKeyThePinsLayer) +TEST_F(TileHandlerTest, HiddenLayersPerDieKeyOnlyTheTilesThatReadThem) { const auto cached_after = [&](const std::string& layer, const std::string& hidden) { @@ -1857,17 +1853,6 @@ TEST_F(TileHandlerTest, HiddenLayersPerDieOnlyKeyThePinsLayer) EXPECT_EQ(cached_after("_pins", die0), after_pins + 1); } -TEST_F(TileHandlerTest, ClientOnlyKeysHitTheCache) -{ - // The client sends its display options (scale bar, rulers...) with every - // tile; they draw nothing on the server and must not split the cache. - const size_t first = cachedAfterTile( - R"({"layer":"metal1","z":0,"x":0,"y":0,"scale_bar":true})"); - EXPECT_EQ(cachedAfterTile(R"({"layer":"metal1","z":0,"x":0,"y":0,)" - R"("scale_bar":false,"rulers":true})"), - first); -} - TEST_F(TileHandlerTest, AnEditOnAnUnbuiltIndexStillMissesTheCache) { // No row index is built yet, so this edit clears no cache; the revision in diff --git a/src/web/test/cpp/TestSaveImage.cpp b/src/web/test/cpp/TestSaveImage.cpp index 33738031b01..b3b098a0a17 100644 --- a/src/web/test/cpp/TestSaveImage.cpp +++ b/src/web/test/cpp/TestSaveImage.cpp @@ -853,7 +853,7 @@ std::vector namesOf(const std::vector& order) // Asserted on the layer list rather than on pixels: every layer here is // semi-transparent, so a dot drawn over the routing still blends with it and no // pixel test can tell the two orders apart reliably. -TEST_F(SaveImageTest, LayerCompositionOrderMatchesClientZIndex) +TEST_F(SaveImageTest, LayerCompositionOrderMatchesClientDrawOrder) { const std::vector tech_layers = rowsOf({"metal1", "metal2"}); TileVisibility vis; @@ -865,7 +865,7 @@ TEST_F(SaveImageTest, LayerCompositionOrderMatchesClientZIndex) vis.rudy = true; vis.routing_congestion = true; - // zIndex on screen: _instances 0, _pins 1, _mfg_grid 2, tech layers 3.., then + // z on screen: _instances 0, _pins 1, _mfg_grid 2, tech layers 3.., then // _inst_labels 999, _access_points 1000, _regions 1001, _gcell_grid 1002, // _rudy 1003, _routing_congestion 1004. const std::vector expected = {"_instances", @@ -1105,7 +1105,7 @@ TEST_F(SaveImageTest, LayerCompositionOrderHonorsPerDieHiddenLayers) } // However many rows the dies bring, they all stay under the overlays, as the -// merged panes keep them on screen. +// client keeps them on screen. TEST_F(SaveImageTest, LayerCompositionOrderKeepsOverlaysAboveManyRows) { std::vector names; diff --git a/src/web/test/cpp/TestTileGenerator.cpp b/src/web/test/cpp/TestTileGenerator.cpp index 6cf0960282a..eb9c51b3e5a 100644 --- a/src/web/test/cpp/TestTileGenerator.cpp +++ b/src/web/test/cpp/TestTileGenerator.cpp @@ -1886,26 +1886,10 @@ TEST_F(TileGeneratorTest, GetLayerColorMapIsCached) EXPECT_EQ(first.get(), second.get()); } -TEST_F(TileGeneratorTest, EagerInitClearsLayerColorCache) -{ - makeTileGen(); - // Prime the cache. - tile_gen_->getLayerColorMap(); - // eagerInit must drop cached entries so a reloaded design with a new - // dbTech allocated at the same address can't read stale colors. - tile_gen_->eagerInit(); - // Recomputing still produces correct values. - const auto colors = tile_gen_->getLayerColorMap(); - odb::dbTechLayer* metal1 = getDb()->getTech()->findLayer("metal1"); - ASSERT_NE(metal1, nullptr); - EXPECT_EQ(colors->at(metal1).r, 0); - EXPECT_EQ(colors->at(metal1).g, 0); - EXPECT_EQ(colors->at(metal1).b, 254); -} - -// A renderer reading the map keeps it through the eagerInit() of a session -// that connects meanwhile. -TEST_F(TileGeneratorTest, LayerColorsOutliveACacheReset) +// eagerInit() drops the cached colors, so a reloaded design with a new dbTech +// at the same address can't read stale ones; a renderer still holding the old +// map keeps it. +TEST_F(TileGeneratorTest, EagerInitRebuildsLayerColorsHeldMapsSurvive) { makeTileGen(); const auto colors = tile_gen_->getLayerColorMap(); @@ -2593,11 +2577,9 @@ const ChipletNode* findChiplet(const std::vector& chiplets, return at == chiplets.end() ? nullptr : &*at; } -// The web builds its chiplet list from ODB's unfolded model, but keeps the -// recursive walk for designs whose model was never built. The two have to -// agree on paths: a path is the key of the per-chiplet visibility filter and -// of the or_hidden_chiplets cookie, so a mismatch would silently drop a user's -// saved state on designs that take the other route. +// The viewer walks the hierarchy and search.cpp reads the unfolded model; the +// two have to agree on paths, which key the per-chiplet visibility filter and +// the or_hidden_chiplets cookie. TEST_F(TileGeneratorTest, CollectChipletsAgreesWithTheUnfoldedModel) { odb::dbChip* root = makeSharedChipletRoot(getDb(), chip_, /*num_insts=*/2); @@ -2701,34 +2683,12 @@ TEST_F(TileGeneratorTest, ChipletCacheNoticesAReorient) << "the chiplet cache did not notice setOrient, so the viewer keeps " "drawing the die face-up"; - // The unfolded model is a load-time snapshot and this read path must not - // rebuild it (that would free objects a concurrent reader is walking), so - // the edit has to stay visible on later calls too — not just the one that - // detected it. + // And stays visible on later calls, not just the one that detected it. const auto later_list = tile_gen_->chiplets(); const ChipletNode* later = findChiplet(*later_list, "root/" + die0->getName()); ASSERT_NE(later, nullptr); - EXPECT_TRUE(later->isFlipped()) - << "the reorient was reported once and then lost, which means a stale " - "unfolded model was read back"; -} - -// A reconnect after a move keeps the chiplet where it was moved. -TEST_F(TileGeneratorTest, EnsureInitKeepsAMovedChipletWhereItWasMoved) -{ - odb::dbChip* root = makeSharedChipletRoot(getDb(), chip_, /*num_insts=*/1); - odb::dbChipInst* die0 = *root->getChipInsts().begin(); - getDb()->constructUnfoldedModel(); - makeTileGen(); - tile_gen_->ensureInit(); - - die0->setOrient(odb::dbOrientType3D("MZ")); - tile_gen_->ensureInit(); - const auto nodes = tile_gen_->chiplets(); - const ChipletNode* node = findChiplet(*nodes, "root/" + die0->getName()); - ASSERT_NE(node, nullptr); - EXPECT_TRUE(node->isFlipped()); + EXPECT_TRUE(later->isFlipped()) << "the reorient was reported only once"; } // The unfolded model is the load's: a move made before the first init, or @@ -2821,12 +2781,8 @@ odb::dbChip* makeNestedChipletRoot(odb::dbDatabase* db, return root; } -// Regression for the PR #11429 review: a HIER wrapper's z was decided one way -// when read off the unfolded model (lowest leaf it contains) and another way -// when walked (the wrapper's own degenerate cuboid). The two agree only when -// the lowest child sits at local z 0; with real offsets they diverge, and since -// global_z is the sort key, sibling wrappers can swap order the moment an edit -// switches the cache to the walked route. +// A HIER wrapper's z, read off the unfolded model (lowest leaf it contains) or +// walked (its own cuboid), must agree: global_z orders sibling wrappers. TEST_F(TileGeneratorTest, NestedHierGroupsGetTheSameZFromBothRoutes) { odb::dbChip* root = makeNestedChipletRoot(getDb(), @@ -2840,9 +2796,8 @@ TEST_F(TileGeneratorTest, NestedHierGroupsGetTheSameZFromBothRoutes) collectChiplets(root, /*use_unfolded_model=*/false)); } -// Reading the model is opt-out precisely so an edited hierarchy can be walked -// instead of rebuilt. Both routes have to agree, or that fallback silently -// changes what the viewer shows. +// After a reorient, the walk has to match a model rebuilt from the edited +// hierarchy, flipped transforms included. TEST_F(TileGeneratorTest, WalkingMatchesTheUnfoldedModelAfterAReorient) { odb::dbChip* root = makeSharedChipletRoot(getDb(), chip_, /*num_insts=*/2); @@ -2978,8 +2933,7 @@ class SideBySideDiesTest : public TileGeneratorTest }; // Each Display Controls row asks for its own die. A metal1 tile drawing both -// dies is why hiding one die's row changed nothing, and why the topmost metal1 -// pane painted both dies in its own die's order (#11886). +// dies would ignore one die's hidden row and stack both dies in one order. TEST_F(SideBySideDiesTest, ScopedTileDrawsOnlyItsOwnDie) { addM1Stripe(10000, 40000, 90000, 60000); @@ -4505,8 +4459,8 @@ TEST_F(TileGeneratorTest, LabelsNeverLeaveTheirBox) EXPECT_EQ(pixelsOutside(px, tile_gen_->getBounds(), w, h, pin), 0); } -// The tech response lists the overlays the client builds its panes from, each -// with its pane order and when it shows, in keys the tile request knows. +// The tech response lists the overlays the client builds its draw lists from, +// each with its draw order and when it shows, in keys the tile request knows. TEST_F(TileGeneratorTest, TechResponsePublishesOverlays) { makeTileGen(); @@ -8471,6 +8425,11 @@ TEST_F(TileGeneratorTest, FieldsLeftOutOfTheCacheKeyDoNotChangeTheTile) changes.emplace_back(with({{"pattern", 1}}), with({{"pattern", 3}})); changes.emplace_back(with({{"site_FreePDK45_38x28_10R_NP_162NW_34O", false}}), with({})); + const std::string die = tile_gen_->chiplets()->front().path; + const std::string hidden_m1 + = with({{"chiplet_hidden_layers", + boost::json::object{{die, boost::json::array{"metal1"}}}}}); + changes.emplace_back(hidden_m1, with({})); const std::string_view layers[] = {"metal1", "metal3", @@ -8513,6 +8472,7 @@ TEST_F(TileGeneratorTest, FieldsLeftOutOfTheCacheKeyDoNotChangeTheTile) } } EXPECT_NE(render("_pins", m1), render("_pins", m5)); + EXPECT_NE(render("_pins", hidden_m1), render("_pins", with({}))); } } // namespace diff --git a/src/web/test/js/fake-view.js b/src/web/test/js/fake-view.js index 426dc0fdf24..5bed55f1fc4 100644 --- a/src/web/test/js/fake-view.js +++ b/src/web/test/js/fake-view.js @@ -1,8 +1,9 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright (c) 2026, The OpenROAD Authors -// A stand-in for layout-view.js: the same API, no renderer. Records what the -// modules under test ask of the view. Needs a DOM (setup-dom.js). +// A stand-in for layout-view.js: the part of its API the modules under test +// use, with no renderer. Records what they ask of the view. Needs a DOM +// (setup-dom.js). import { project, unproject } from '../../src/view-math.js'; @@ -11,22 +12,16 @@ export function makeFakeView({ width = 1000, height = 800, zoom = 0, const container = document.createElement('div'); const listeners = new Map(); const vs = { width, height, zoom, target: [...target] }; - const limits = { minZoom: 0, maxZoom: 20 }; const view = { - vs, - calls: [], // [name, ...args] of every navigation call - overlays: new Map(), // id -> { shapes, order } - images: new Map(), + calls: [], // [name, ...args] of every recorded call + overlays: new Map(), // id -> shapes markers: new Map(), // group -> { visible, items: Map id -> m } cursorModes: new Set(), - slots: [], flashes: 0, getContainer: () => container, - getSize: () => ({ width: vs.width, height: vs.height }), getZoom: () => vs.zoom, - getTargetZoom: () => vs.zoom, getCenter: () => [...vs.target], project: (w) => project(w, vs), unproject: (p) => unproject(p, vs), @@ -52,11 +47,6 @@ export function makeFakeView({ width = 1000, height = 800, zoom = 0, } }, - setLimits(l) { - Object.assign(limits, l); - view.calls.push(['setLimits', { ...l }]); - }, - getLimits: () => ({ ...limits }), setView(center, z = vs.zoom, opts) { view.calls.push(['setView', [...center], z, opts]); vs.target = [...center]; @@ -64,61 +54,38 @@ export function makeFakeView({ width = 1000, height = 800, zoom = 0, vs.zoom = z; view.emit('zoom'); } - view.emit('move'); }, fitWorldRect(rect, opts) { view.calls.push(['fitWorldRect', [...rect], opts]); }, - zoomAround(pt, delta, opts) { - view.calls.push(['zoomAround', pt, delta, opts]); - }, zoomIn() { view.calls.push(['zoomIn']); }, zoomOut() { view.calls.push(['zoomOut']); }, - panByPx(dx, dy, opts) { - view.calls.push(['panByPx', dx, dy, opts]); - }, // Change the zoom as a user would, firing the view's events. setZoomForTest(z) { vs.zoom = z; view.emit('zoom'); }, - invalidateSize() {}, - applyPrefs() {}, - setGesture(on) { - view.gesture = !!on; - }, addTileSlot(id, opts = {}) { const slot = { - id, opts, visible: opts.visible !== false, refreshes: 0, - setVisible(v) { slot.visible = !!v; }, - isVisible: () => slot.visible, + opts, refreshes: 0, refresh() { slot.refreshes++; }, - remove() { slot.removed = true; }, }; - view.slots.push(slot); return slot; }, - setOverlay(id, shapes, { order = 0 } = {}) { + setOverlay(id, shapes) { if (!shapes || shapes.length === 0) { view.overlays.delete(id); } else { - view.overlays.set(id, { shapes, order }); - } - }, - shapes: (id) => view.overlays.get(id)?.shapes || [], - setImageOverlay(id, img, { order = 0 } = {}) { - if (!img) { - view.images.delete(id); - } else { - view.images.set(id, { ...img, order }); + view.overlays.set(id, shapes); } }, + shapes: (id) => view.overlays.get(id) || [], addMarker(group, id, world, el, { center = false } = {}) { const g = markerGroup(group); @@ -164,7 +131,6 @@ export function makeFakeView({ width = 1000, height = 800, zoom = 0, captureCanvas: async () => (view.canvas ? { image: view.canvas, rect: view.canvas.getBoundingClientRect() } : null), - debugSnapshot: () => ({ zoom: vs.zoom, target: [...vs.target] }), }; function markerGroup(group) { diff --git a/src/web/test/js/test-capture.js b/src/web/test/js/test-capture.js index c0872a15769..97f3c468246 100644 --- a/src/web/test/js/test-capture.js +++ b/src/web/test/js/test-capture.js @@ -108,7 +108,7 @@ describe('captureLayout includes the HTML ruler labels', () => { const label = document.createElement('div'); label.className = 'ruler-label'; label.textContent = text; - // 30px right and 40px down from the map's top-left corner. + // 30px right and 40px down from the view's top-left corner. stubRect(label, 30, 40, 70, 16); pane.appendChild(label); return app; @@ -128,7 +128,7 @@ describe('captureLayout includes the HTML ruler labels', () => { assert.equal(text[0][3], 48); // And a box behind it, so the text stays readable over the layout. - // The first fillRect is the map background; the label's is the second. + // The first fillRect is the view background; the label's is the second. const rects = ops.filter((o) => o[0] === 'fillRect'); assert.equal(rects.length, 2, 'background + one label box'); assert.deepEqual(rects[1].slice(1), [30, 40, 70, 16]); @@ -140,6 +140,6 @@ describe('captureLayout includes the HTML ruler labels', () => { () => captureLayout(appWithLabel(''), { entire: false }), ops); assert.equal(ops.filter((o) => o[0] === 'fillText').length, 0); assert.equal(ops.filter((o) => o[0] === 'fillRect').length, 1, - 'only the map background'); + 'only the view background'); }); }); diff --git a/src/web/test/js/test-clusters-widget.js b/src/web/test/js/test-clusters-widget.js index aa309a37f62..0245aa7511e 100644 --- a/src/web/test/js/test-clusters-widget.js +++ b/src/web/test/js/test-clusters-widget.js @@ -50,7 +50,6 @@ function createMockApp({ ...overrides } = {}) { }, }, designScale: 1, - designMaxDXDY: 1000, designOriginX: 0, designOriginY: 0, showDbu: false, diff --git a/src/web/test/js/test-context-menu.js b/src/web/test/js/test-context-menu.js index e193ff3c53f..be6f93722d3 100644 --- a/src/web/test/js/test-context-menu.js +++ b/src/web/test/js/test-context-menu.js @@ -14,8 +14,6 @@ function makeApp(overrides = {}) { const app = { view, fitRect: [0, 0, 10, 10], - lastSelectionBounds: [1, 1, 2, 2], - hasSelection: true, selHasInst: true, selHasNet: true, ...overrides, @@ -143,7 +141,7 @@ describe('ContextMenu Clear submenu', () => { // app.refreshOverlay is the hook that also refreshes the Selection Highlight // panel (main.js pairs it with selectionBrowser.scheduleRefresh). Calling // only redrawAllLayers leaves the panel listing objects the server has -// already dropped, so every context action has to go through it. +// already dropped, so an action that redraws refreshes the panel itself. describe('ContextMenu refreshes the panels after a server action', () => { function appWithHooks(overrides = {}) { const hooks = []; @@ -153,6 +151,9 @@ describe('ContextMenu refreshes the panels after a server action', () => { refreshOverlay: () => hooks.push('refreshOverlay'), refreshInspector: () => hooks.push('refreshInspector'), redrawAllLayers: () => hooks.push('redrawAllLayers'), + selectionBrowser: { + scheduleRefresh: () => hooks.push('panelRefresh'), + }, updateInspector: (d) => hooks.push(['updateInspector', d]), stopSelectionAnimation: () => hooks.push('stopSelectionAnimation'), ...overrides, @@ -186,7 +187,6 @@ describe('ContextMenu refreshes the panels after a server action', () => { assert.ok(hooks.includes('stopSelectionAnimation')); assert.ok(hooks.includes('refreshOverlay')); assert.equal(cleared, 1, 'selection outline removed'); - assert.equal(app.lastSelectionBounds, null); }); it('Focus nets redraws the base tiles it feeds', async () => { @@ -195,7 +195,29 @@ describe('ContextMenu refreshes the panels after a server action', () => { clickItem('Focus nets'); await settle(); assert.ok(hooks.includes('redrawAllLayers'), 'base tiles redrawn'); + assert.ok(hooks.includes('panelRefresh')); + assert.ok(!hooks.includes('refreshOverlay'), + 'the redraw already refreshed the overlay'); + }); + + it('All redraws, resets the inspector and refreshes the panel once', + async () => { + const { app, hooks } = appWithHooks(); + openMenu(app); + clickItem('All'); + await settle(); + assert.deepEqual(hooks, ['redrawAllLayers', ['updateInspector', null], + 'stopSelectionAnimation', 'panelRefresh']); + }); + + // Route guides are drawn on the overlay tiles only. + it('Route Guides refreshes the overlay, not the base tiles', async () => { + const { app, hooks } = appWithHooks(); + openMenu(app); + clickItem('Route Guides'); + await settle(); assert.ok(hooks.includes('refreshOverlay')); + assert.ok(!hooks.includes('redrawAllLayers')); }); it('clearing focus nets or route guides empties their client copies', diff --git a/src/web/test/js/test-coordinates.js b/src/web/test/js/test-coordinates.js index c17e9bde67b..1100621f92d 100644 --- a/src/web/test/js/test-coordinates.js +++ b/src/web/test/js/test-coordinates.js @@ -15,12 +15,6 @@ describe('dbuToWorld / worldToDbu', () => { assert.deepEqual(dbuToWorld(1500, 1700, scale, 500, 700), [240, 240]); }); - it('round-trips to whole DBU', () => { - const [wx, wy] = dbuToWorld(1234, 567, scale, 100, 50); - assert.deepEqual(worldToDbu(wx, wy, scale, 100, 50), - { dbuX: 1234, dbuY: 567 }); - }); - it('turns two corners in any order into [minX, minY, maxX, maxY]', () => { assert.deepEqual(dbuRectToWorldRect(1000, 0, 0, 500, scale), [0, 0, 240, 120]); diff --git a/src/web/test/js/test-display-controls.js b/src/web/test/js/test-display-controls.js index ee1304521e2..e45cb593271 100644 --- a/src/web/test/js/test-display-controls.js +++ b/src/web/test/js/test-display-controls.js @@ -11,7 +11,6 @@ const { } = await import('../../src/display-controls.js'); const { beginSelection } = await import('../../src/ui-utils.js'); const { makeFakeView } = await import('./fake-view.js'); -const { gateOpen } = await import('../../src/tile-sources.js'); // 10 layers: Metal1, Via1, Metal2, Via2, ... Metal5, Via5 const COUNT = 10; @@ -122,7 +121,6 @@ describe('layer row selection', () => { window.sessionStorage.clear(); app = { displayControlsEl: document.createElement('div'), - allLayers: [], visibleLayers: new Set(), visibleLayerNames: new Set(), selectableLayers: new Set(), @@ -281,20 +279,6 @@ describe('layer row selection', () => { layers_by: [['inst_pins', 'inst_pin_names']] }, ]; - it('puts each listed overlay in the slot its paint order picks', () => { - techData.overlays = [ - ...OVERLAYS, - { name: '_mfg_grid', z_index: 2, - shown_by: [['mfg_grid']], layers_by: [] }, - ]; - render(); - // Under every routing layer, which follow it. - assert.deepEqual(app.baseSlot.items.slice(0, 4).map((i) => i.layer), - ['_instances', '_pins', '_modules', '_mfg_grid']); - assert.deepEqual(app.topSlot.items.map((i) => i.layer), - ['_inst_labels', '_access_points', '_gcell_grid']); - }); - // A layer toggle refreshes the top slot when an overlay in it draws by the // visible layers under the current visibility: always the access points, // the names only while pin names are shown, never the gcell grid. @@ -518,7 +502,6 @@ describe('overlay layer toggles', () => { window.sessionStorage.clear(); app = { displayControlsEl: document.createElement('div'), - allLayers: [], visibleLayers: new Set(), visibleLayerNames: new Set(), selectableLayers: new Set(), @@ -571,18 +554,11 @@ describe('overlay layer toggles', () => { return cb; } - it('puts each pseudo layer in a slot once, up front', () => { - for (const name of ['_modules', '_clusters', '_pins', '_instances']) { - assert.equal(allItems().filter(i => i.layer === name).length, 1, - name); - } - }); - // A switchable pseudo layer needs a gate: without one it would request tiles // forever, and gated on a flag that does not exist it would go blank. The - // client-mounted ones carry a flag name; those the server lists carry its + // client's own ones carry a flag name; those the server lists carry its // `shown_by` verbatim. - it('gates every switchable pseudo layer instead of unmounting it', () => { + it('gates every switchable pseudo layer instead of removing it', () => { const expected = { _pins: 'pins', _modules: 'module_view', @@ -642,7 +618,7 @@ describe('overlay layer toggles', () => { assert.equal(visibility.ui_hierarchy_view, !before, 'flag flips on toggle ' + i); assert.equal(redraws, i + 1, 'redraw requested on toggle ' + i); - // The regression: no draw item may come or go here. + // No draw item may come or go here. assert.deepEqual(allItems(), items, 'toggle must not touch the draw lists'); } @@ -708,7 +684,6 @@ describe('routing layer opacity', () => { window.sessionStorage.clear(); app = { displayControlsEl: document.createElement('div'), - allLayers: [], visibleLayers: new Set(), visibleLayerNames: new Set(), selectableLayers: new Set(), @@ -758,7 +733,7 @@ describe('routing layer opacity', () => { render(); const routing = app.baseSlot.items.filter( (i) => i.layer.startsWith('metal')); - assert.equal(routing.length, 2, 'metal layers should reach the merge'); + assert.equal(routing.length, 2, 'metal layers should reach the draw list'); for (const item of routing) { assert.equal(item.opacity, 1, item.layer); } @@ -774,29 +749,6 @@ describe('routing layer opacity', () => { assert.ok(app.baseSlot.opts.order < app.topSlot.opts.order); assert.deepEqual(app.allLayers, [app.baseSlot, app.topSlot]); }); - - // The restored visibility drives them from the first tile on: each item - // is gated on its flags, read on every request. - it('gates the pseudo layers on the restored visibility', () => { - const visibility = { pins: true, module_view: false, - gcell_grid: true }; - render(visibility); - const shown = (item) => gateOpen(item.gate, visibility); - assert.equal(shown(app.pinsLayer), true); - assert.equal(shown(app.modulesLayer), false); - const overlay = (name) => app.overlayLayers.find( - ({ def }) => def.name === name).layer; - assert.equal(shown(overlay('_gcell_grid')), true); - assert.equal(shown(overlay('_access_points')), false); - }); - - it('replaces its slots when the panel is rebuilt', () => { - render(); - const first = app.baseSlot; - render(); - assert.equal(first.removed, true); - assert.notEqual(app.baseSlot, first); - }); }); // ─── Per-renderer display controls ────────────────────────────────────────── @@ -823,7 +775,6 @@ describe('renderer display controls', () => { const requests = []; const app = { displayControlsEl: document.createElement('div'), - allLayers: [], visibleLayers: new Set(), visibleLayerNames: new Set(), selectableLayers: new Set(), @@ -1078,7 +1029,6 @@ describe('flipped chiplet layer order', () => { window.sessionStorage.clear(); app = { displayControlsEl: document.createElement('div'), - allLayers: [], visibleLayers: new Set(), visibleLayerNames: new Set(), selectableLayers: new Set(), @@ -1241,7 +1191,6 @@ describe('dies sharing a layer name', () => { window.sessionStorage.clear(); app = { displayControlsEl: document.createElement('div'), - allLayers: [], visibleLayers: new Set(), visibleLayerNames: new Set(), selectableLayers: new Set(), @@ -1337,6 +1286,37 @@ describe('dies sharing a layer name', () => { 'a name no die shows needs no exception'); }); + // Hiding a whole die also takes it out of the visible chiplets, which + // redraws every slot; the row changes must not refresh the slot before. + it('refreshes the base slot once when a die is hidden', () => { + populateDisplayControls(app, {}, {}, techData(), () => { + for (const slot of app.allLayers) { + slot.refresh(); + } + }, null); + const before = app.baseSlot.refreshes; + app.layerModel.check('layers_parent/die0', false); + assert.equal(item('die0', 'metal1').visible, false); + assert.equal(app.baseSlot.refreshes, before + 1); + }); + + it('refreshes the base slot once for a die hidden in Chiplets', () => { + populateDisplayControls(app, {}, {}, techData(), () => { + for (const slot of app.allLayers) { + slot.refresh(); + } + }, null); + const before = app.baseSlot.refreshes; + const cb = [...app.displayControlsEl.querySelectorAll('.vis-leaf')] + .find((el) => el.title === 'top/die0') + .querySelector('.vis-cb'); + cb.checked = false; + cb.dispatchEvent(new dom.window.Event('change')); + assert.equal(item('die0', 'metal1').visible, false); + assert.ok(!app.visibleChiplets.has('top/die0')); + assert.equal(app.baseSlot.refreshes, before + 1); + }); + it('restores a die\'s hidden row from the session', () => { window.sessionStorage.setItem( 'or_hidden_layers', JSON.stringify([rowId('die0', 'metal1')])); @@ -1345,6 +1325,30 @@ describe('dies sharing a layer name', () => { assert.deepEqual(app.chipletHiddenLayers, { 'top/die0': ['metal1'] }); }); + it('restores the dies before the slots ask for tiles', () => { + window.sessionStorage.setItem( + 'or_hidden_layers', JSON.stringify([rowId('die0', 'metal1')])); + document.cookie = 'or_hidden_chiplets=' + encodeURIComponent( + JSON.stringify({ blk: ['top/die1'] })) + '; path=/'; + const seen = []; + const addTileSlot = app.view.addTileSlot; + app.view.addTileSlot = (id, opts) => { + seen.push([[...app.visibleChiplets], app.chipletHiddenLayers]); + return addTileSlot(id, opts); + }; + try { + populateDisplayControls(app, {}, {}, + { ...techData(), block_name: 'blk' }, + () => {}, null); + } finally { + document.cookie = 'or_hidden_chiplets=; path=/; max-age=0'; + } + assert.ok(!app.visibleChiplets.has('top/die1')); + assert.deepEqual(app.chipletHiddenLayers['top/die0'], ['metal1']); + const now = [[...app.visibleChiplets], app.chipletHiddenLayers]; + assert.deepEqual(seen, [now, now]); + }); + it('makes a row unselectable on its own die only', () => { render(); const sel = rowEl('die0', 'metal1').querySelector('.vis-sel-cb'); diff --git a/src/web/test/js/test-display-state.js b/src/web/test/js/test-display-state.js index a313ea620c7..8325b615a9d 100644 --- a/src/web/test/js/test-display-state.js +++ b/src/web/test/js/test-display-state.js @@ -130,7 +130,7 @@ describe('applyDisplayStateEntries', () => { or_arrow_step: '120', or_font_family: 'monospace', or_font_scale: '125', - // Rendering preferences (#11340). + // Rendering preferences. or_control_smoothing: '1', or_double_buffer: '0', or_defer_tile_updates: '0', diff --git a/src/web/test/js/test-dpr.js b/src/web/test/js/test-dpr.js index 10abea2b419..7e064c6e4c5 100644 --- a/src/web/test/js/test-dpr.js +++ b/src/web/test/js/test-dpr.js @@ -24,10 +24,12 @@ import { describe, it } from 'node:test'; import assert from 'node:assert/strict'; import { - TILE_SIZE_CSS, STATIC_TILE_SIZE_CSS, quantizeDpr, tileDevicePx, + TILE_SIZE_CSS, STATIC_TILE_SIZE_CSS, nativeDpr, quantizeDpr, tileDevicePx, tileSizeCss, useStaticTileSize, useDeviceExactTileSize, - tileRequestBuilder, tileSizeFields, + tileRequestBuilder, tileSizeFields, watchDevicePixelRatio, } from '../../src/tile-request.js'; +import { buildHeatmapRequest, buildOverlayRequest, createCompositeSource } + from '../../src/tile-sources.js'; import { project, snapTarget } from '../../src/view-math.js'; // What browsers report. 1.6666666269302368 is verbatim from the display this @@ -67,38 +69,11 @@ describe('dpr contract: the tile pitch is whole at every ratio', () => { } }); - it('holds for every boundary across a screenful of tiles', () => { - for (const dpr of RATIOS) { - for (const k of [1, 2, 3, 7, 12]) { - assertWhole(k * TILE_SIZE_CSS * dpr, `tile ${k} @${dpr}`); - } - } - }); - - it('did NOT hold at 256, which is the reported bug', () => { - // Kept as a test so the tile size cannot drift back to a value that - // looks tidier and reintroduces the seams. - const broken = RATIOS.filter( - (dpr) => Math.abs(256 * dpr - Math.round(256 * dpr)) >= LAYOUT_UNIT); - assert.deepEqual(broken, [1.1, 1.2, 1.3333333333333333, - 1.6666666269302368, 1.8333333333333333]); - }); }); describe('dpr contract: the image is exactly the box it goes in', () => { // Failure 2. The request states the pixel count; nothing downstream may // re-derive it from the rounded dpr. - it('asks for the pixel count the tile will occupy', () => { - for (const dpr of RATIOS) { - const req = tileRequestBuilder( - { x: 1, y: 2, z: 3 }, { visibility: {} }, dpr, - TILE_SIZE_CSS)('metal1'); - assert.equal(req.tile_px, Math.round(TILE_SIZE_CSS * dpr), - `dpr ${dpr}`); - assert.ok(Number.isInteger(req.tile_px)); - } - }); - it('asks for a count that fills the box to within a layout unit', () => { for (const dpr of RATIOS) { const boxDevicePx = TILE_SIZE_CSS * dpr; @@ -107,28 +82,6 @@ describe('dpr contract: the image is exactly the box it goes in', () => { `dpr ${dpr}: asked ${asked} for a ${boxDevicePx} box`); } }); - - it('would have asked for the wrong size via the old 256*quantized-dpr', () => { - // 1.6666666 -> 1.67 -> 428 px into a 426.67 px box: the 0.3% resample - // that softened every tile edge. - const dpr = 1.6666666269302368; - const old = Math.round(256 * quantizeDpr(dpr)); - assert.equal(old, 428); - assert.ok(Math.abs(old - 256 * dpr) > 1); - }); - - it('keeps the merged canvas backing store equal to what it requested', () => { - // The merged path sizes its canvas with tileDevicePx and requests with - // tileDevicePx; if those ever diverge, drawImage resamples every tile - // into the wrong backing store. - for (const dpr of RATIOS) { - const requested = tileRequestBuilder( - { x: 0, y: 0, z: 0 }, { visibility: {} }, dpr, - TILE_SIZE_CSS)('metal1').tile_px; - assert.equal(tileDevicePx(TILE_SIZE_CSS, dpr), requested, - `dpr ${dpr}`); - } - }); }); describe('dpr contract: all three tile kinds are sized alike', () => { @@ -140,13 +93,20 @@ describe('dpr contract: all three tile kinds are sized alike', () => { it('gives every kind the same count at every ratio', () => { for (const dpr of RATIOS) { const fields = tileSizeFields(dpr, TILE_SIZE_CSS); - const layer = tileRequestBuilder( - { x: 1, y: 2, z: 3 }, { visibility: {} }, dpr, - TILE_SIZE_CSS)('metal1'); + const c = { x: 1, y: 2, z: 3 }; + const kinds = { + layer: tileRequestBuilder(c, { visibility: {} }, dpr, + TILE_SIZE_CSS)('metal1'), + overlay: buildOverlayRequest(c, dpr, TILE_SIZE_CSS, {}, null), + 'heat map': buildHeatmapRequest(c, dpr, TILE_SIZE_CSS, + { activeHeatMap: 'Placement' }), + }; assert.equal(fields.tile_px, Math.round(TILE_SIZE_CSS * dpr), `dpr ${dpr}`); - assert.equal(layer.tile_px, fields.tile_px, `layer @${dpr}`); - assert.equal(layer.dpr, fields.dpr, `layer dpr @${dpr}`); + for (const [kind, req] of Object.entries(kinds)) { + assert.equal(req.tile_px, fields.tile_px, `${kind} @${dpr}`); + assert.equal(req.dpr, fields.dpr, `${kind} dpr @${dpr}`); + } } }); @@ -175,10 +135,22 @@ describe('dpr contract: quantizeDpr matches the server', () => { assert.equal(quantizeDpr(0.5), 1); assert.equal(quantizeDpr(4), 3); assert.equal(quantizeDpr(2.555), 2.56); + assert.equal(quantizeDpr(4 / 3), 1.33); + assert.equal(quantizeDpr(1.005), 1.0); + assert.equal(quantizeDpr(3.0001), 3); + assert.equal(quantizeDpr(0), 1); + assert.equal(quantizeDpr(-2), 1); assert.equal(quantizeDpr(NaN), 1); assert.equal(quantizeDpr(undefined), 1); }); + // 1.75 and 2.5 are ordinary display scale factors. + it('keeps the display ratio instead of snapping to a ladder', () => { + for (const d of [1, 1.25, 1.5, 1.75, 2, 2.5, 3]) { + assert.equal(quantizeDpr(d), d); + } + }); + it('rounds the field but never the pixel count', () => { // The whole point of tile_px. Rounding the ratio first and multiplying // after cannot land on the box: 1.6666666 -> 1.67 asks for 401 px to @@ -195,20 +167,6 @@ describe('dpr contract: quantizeDpr matches the server', () => { `dpr ${dpr}: count vs box`); } }); - - it('is what a quantized ratio would have got wrong', () => { - // Regression guard for the flaw the matrix caught: tile_px derived from - // the rounded ratio is one pixel off at 5/3 and at 4/3. - for (const dpr of [1.6666666269302368, 1.3333333333333333]) { - const fromRounded = Math.round(TILE_SIZE_CSS * quantizeDpr(dpr)); - const fromReal = Math.round(TILE_SIZE_CSS * dpr); - assert.notEqual(fromRounded, fromReal, `dpr ${dpr}`); - const req = tileRequestBuilder( - { x: 0, y: 0, z: 0 }, { visibility: {} }, dpr, - TILE_SIZE_CSS)('metal1'); - assert.equal(req.tile_px, fromReal); - } - }); }); describe('dpr contract: the residual phase is removable', () => { @@ -240,14 +198,121 @@ describe('dpr contract: static reports keep their baked size', () => { useStaticTileSize(); try { assert.equal(tileSizeCss(), STATIC_TILE_SIZE_CSS); - // The request takes it from here, so the baked image is asked for + // The source takes it from here, so the baked image is asked for // at its own size rather than the live one. - const req = tileRequestBuilder( - { x: 0, y: 0, z: 0 }, { visibility: {} }, 1)('metal1'); - assert.equal(req.tile_px, STATIC_TILE_SIZE_CSS); + const sent = []; + const wm = { + request(msg) { + sent.push(msg); + return new Promise(() => {}); + }, + }; + createCompositeSource({ + wm, ctx: { visibility: {} }, dpr: () => 1, + getItems: () => [{ layer: 'metal1', opacity: 1 }], + }).load({ z: 0, x: 0, y: 0 }); + assert.equal(sent[0].tile_px, STATIC_TILE_SIZE_CSS); } finally { // Module state: restore it so test order cannot matter. useDeviceExactTileSize(); } }); }); + +describe('watchDevicePixelRatio', () => { + function fakeWindow(dpr) { + const queries = []; + return { + devicePixelRatio: dpr, + queries, + matchMedia(query) { + const mql = { query, handlers: [], removed: [] }; + mql.addEventListener = (name, fn) => { + assert.equal(name, 'change'); + mql.handlers.push(fn); + }; + mql.removeEventListener = (name, fn) => { + assert.equal(name, 'change'); + mql.removed.push(fn); + }; + queries.push(mql); + return mql; + }, + }; + } + + function withWindow(win, fn) { + const saved = globalThis.window; + globalThis.window = win; + try { + return fn(); + } finally { + globalThis.window = saved; + } + } + + it('watches the ratio in force', () => { + const win = fakeWindow(1.25); + withWindow(win, () => watchDevicePixelRatio(() => {})); + assert.equal(win.queries.length, 1); + assert.ok(win.queries[0].query.includes('1.25dppx')); + }); + + it('reports the new ratio and watches for the next one', () => { + const win = fakeWindow(1.25); + const seen = []; + withWindow(win, () => { + watchDevicePixelRatio((dpr) => seen.push(dpr)); + win.devicePixelRatio = 1.6666666269302368; + win.queries[0].handlers[0](); + }); + assert.deepEqual(seen, [1.6666666269302368]); + // A new query: the old one only ever matches the old ratio. + assert.equal(win.queries.length, 2); + assert.ok(win.queries[1].query.includes('1.6666666269302368dppx')); + }); + + it('stops reporting and detaches its listener once unsubscribed', () => { + const win = fakeWindow(1.25); + const seen = []; + withWindow(win, () => { + const stop = watchDevicePixelRatio((dpr) => seen.push(dpr)); + stop(); + win.queries[0].handlers[0](); + }); + assert.deepEqual(seen, []); + assert.deepEqual(win.queries[0].removed, [win.queries[0].handlers[0]]); + }); + + it('is a no-op where matchMedia is unavailable', () => { + withWindow({ devicePixelRatio: 2 }, () => { + assert.equal(typeof watchDevicePixelRatio(() => {}), 'function'); + }); + }); +}); + +describe('nativeDpr', () => { + function withDpr(value) { + const saved = globalThis.window; + globalThis.window = value === undefined ? {} : { devicePixelRatio: value }; + try { + return nativeDpr(); + } finally { + globalThis.window = saved; + } + } + + // Sizes are computed from it, so it is not rounded. + it('keeps the ratio exact', () => { + assert.equal(withDpr(2), 2); + assert.equal(withDpr(1.75), 1.75); + assert.equal(withDpr(1.6666666269302368), 1.6666666269302368); + }); + + // A tile is rendered at about (tileSize*dpr)^2 * 4 bytes. + it('clamps to [1, 3], and is 1 without a ratio', () => { + assert.equal(withDpr(8), 3); + assert.equal(withDpr(0.5), 1); + assert.equal(withDpr(undefined), 1); + }); +}); diff --git a/src/web/test/js/test-drc-widget.js b/src/web/test/js/test-drc-widget.js index f68a80e34ab..3d1fef02234 100644 --- a/src/web/test/js/test-drc-widget.js +++ b/src/web/test/js/test-drc-widget.js @@ -2,7 +2,7 @@ // Copyright (c) 2026, The OpenROAD Authors import './setup-dom.js'; -import { describe, it, beforeEach } from 'node:test'; +import { describe, it } from 'node:test'; import assert from 'node:assert/strict'; import { DrcWidget } from '../../src/drc-widget.js'; import { makeFakeView } from './fake-view.js'; diff --git a/src/web/test/js/test-hierarchy-panel.js b/src/web/test/js/test-hierarchy-panel.js index 3518f9034ba..7f23102d667 100644 --- a/src/web/test/js/test-hierarchy-panel.js +++ b/src/web/test/js/test-hierarchy-panel.js @@ -45,7 +45,6 @@ function createMockApp() { }, }, designScale: 1, - designMaxDXDY: 1000, designOriginX: 0, designOriginY: 0, showDbu: false, diff --git a/src/web/test/js/test-inspector.js b/src/web/test/js/test-inspector.js index d16f5d28fa5..9cf62c3cb85 100644 --- a/src/web/test/js/test-inspector.js +++ b/src/web/test/js/test-inspector.js @@ -21,7 +21,6 @@ function makeApp() { focusNets: new Set(), routeGuideNets: new Set(), inspectorEl: document.createElement('div'), - hoverRects: [], view: null, designScale: null, websocketManager: { @@ -59,12 +58,14 @@ function instData(name) { } describe('Inspector focus nets', () => { - let app, panel, redraws; + let app, panel, redraws, overlays; beforeEach(() => { app = makeApp(); redraws = 0; - panel = createInspectorPanel(app, () => { redraws++; }); + overlays = 0; + panel = createInspectorPanel(app, () => { redraws++; }, + () => { overlays++; }); }); describe('updateInspector toolbar buttons', () => { @@ -261,7 +262,9 @@ describe('Inspector focus nets', () => { assert.equal(app._requests[0].type, 'select_next'); assert.equal(app.selectedInstanceName, 'buf2'); assert.equal(schematicRefreshes, 1); - assert.equal(redraws, 1); + // Only the selection moved, and it lives on the overlay. + assert.equal(redraws, 0); + assert.equal(overlays, 1); }); it('label shows correct 1-indexed position', () => { @@ -1009,6 +1012,34 @@ describe('selection outline and hover on the view', () => { app.view.setZoomForTest(3); assert.ok(near(rect(), [99.875, 200, 101.125, 260]), String(rect())); }); + + it('cancels a hover still on its way when the pointer leaves', async () => { + const cancelled = []; + const rejects = new Map(); + app.websocketManager.request = (msg) => { + const id = app.websocketManager._nextId++; + const p = msg.type === 'hover' && msg.select_id !== -1 + ? new Promise((_, reject) => rejects.set(id, reject)) + : Promise.resolve({}); + p.requestId = id; + return p; + }; + app.websocketManager.cancel = (id) => { + cancelled.push(id); + rejects.get(id)?.(new Error('Request cancelled')); + }; + panel.updateInspector({ + type: 'Inst', name: 'i1', bbox: [0, 0, 10, 10], + properties: [{ name: 'Master', value: 'BUF_X1', + value_select_id: 3 }], + }); + const link = app.inspectorEl.querySelector('.inspector-link'); + link.dispatchEvent(new dom.window.Event('mouseenter')); + link.dispatchEvent(new dom.window.Event('mouseleave')); + await new Promise((r) => setTimeout(r, 0)); + assert.equal(cancelled.length, 1); + assert.equal(app.view.overlays.has('hover'), false); + }); }); // Rulers and labels are client-side as far as the Inspector goes: refreshing diff --git a/src/web/test/js/test-label-manager.js b/src/web/test/js/test-label-manager.js index d1f3ac2e5d2..d115e8aa0fa 100644 --- a/src/web/test/js/test-label-manager.js +++ b/src/web/test/js/test-label-manager.js @@ -228,6 +228,19 @@ describe('LabelManager', () => { assert.equal(inspected, null); }); + it('applyRemoteLabels draws the handles once when the selection goes', + () => { + const { mgr } = makeManager(); + mgr._applyLabels([{ name: 'L0', x: 1, y: 2, text: 'a' }]); + mgr._select('L0'); + let renders = 0; + const render = mgr._renderHandles.bind(mgr); + mgr._renderHandles = () => { renders++; render(); }; + mgr.applyRemoteLabels([]); + assert.equal(mgr._selectedName, null); + assert.equal(renders, 1); + }); + it('applyRemoteLabels keeps a selection that survived the push', async () => { const { mgr } = makeManager(); @@ -271,6 +284,39 @@ describe('LabelManager', () => { assert.equal(requests.filter(r => r.type === 'add_label').length, 0); }); + // An edit made in the Inspector redraws the handles once and shows the + // label again, without taking the selection back. + it('_edit keeps the selection and draws once', async () => { + const labels = [{ name: 'L0', x: 5, y: 6, text: 'new' }]; + const { mgr, app } = makeManager({ update_label: { labels } }); + mgr._applyLabels([{ name: 'L0', x: 5, y: 6, text: 'old' }]); + mgr._select('L0'); + const token = app.selectionToken; + let renders = 0; + const render = mgr._renderHandles.bind(mgr); + mgr._renderHandles = () => { renders++; render(); }; + await mgr._edit(mgr._labels[0], { text: 'new', size: 0, + anchor: 'center' }); + assert.equal(renders, 1); + assert.equal(app.selectionToken, token); + assert.equal(mgr._selectedName, 'L0'); + }); + + it('_edit leaves the Inspector to a selection made while it was sent', + async () => { + const labels = [{ name: 'L0', x: 5, y: 6, text: 'new' }]; + const { mgr, app } = makeManager({ update_label: { labels } }); + mgr._applyLabels([{ name: 'L0', x: 5, y: 6, text: 'old' }]); + mgr._select('L0'); + let shown = 0; + mgr._updateInspector = () => { shown++; }; + const edit = mgr._edit(mgr._labels[0], { text: 'new', size: 0, + anchor: 'center' }); + beginSelection(app); + await edit; + assert.equal(shown, 0); + }); + it('_edit sends a single atomic update_label with the patched fields', async () => { const { mgr, requests } = makeManager(); @@ -309,7 +355,7 @@ async function makeHandleManager(labels) { } describe('LabelManager handles', () => { - it('pins a centred handle at each label position', async () => { + it('pins a centered handle at each label position', async () => { const { app } = await makeHandleManager([ { name: 'L0', x: 500000, y: 250000, text: 'a' }]); const [h] = app.view.markersIn('label-handles'); diff --git a/src/web/test/js/test-layout-view.js b/src/web/test/js/test-layout-view.js index afa1bc4896e..880cf32466f 100644 --- a/src/web/test/js/test-layout-view.js +++ b/src/web/test/js/test-layout-view.js @@ -27,9 +27,13 @@ function makeSource() { loads, load(c, { background }) { let resolve; - const promise = new Promise((res) => { resolve = res; }); + let reject; + const promise = new Promise((res, rej) => { + resolve = res; + reject = rej; + }); const key = `${c.z}/${c.x}/${c.y}`; - loads.set(key, { ...c, background, resolve }); + loads.set(key, { ...c, background, resolve, reject }); return { promise, cancel() { loads.delete(key); }, promote() {} }; }, release() {}, @@ -72,7 +76,7 @@ describe('LayoutView view state', () => { it('drives the deck view state and reports the move', () => { const { view, deck, frames } = setup(); const events = []; - for (const e of ['movestart', 'moveend', 'zoomstart', 'zoom', 'zoomend']) { + for (const e of ['movestart', 'moveend', 'zoom', 'zoomend']) { view.on(e, () => events.push(e)); } view.setView([120, 120], 2); @@ -81,8 +85,7 @@ describe('LayoutView view state', () => { assert.deepEqual(deck.decks[0].props.viewState.target.slice(0, 2), view.getCenter()); assert.equal(deck.decks[0].props.viewState.zoom, 2); - assert.deepEqual(events, ['movestart', 'zoomstart', 'zoom', 'moveend', - 'zoomend']); + assert.deepEqual(events, ['movestart', 'zoom', 'moveend', 'zoomend']); }); it('uses an orthographic view with y up and no wheel zoom of its own', () => { @@ -91,6 +94,8 @@ describe('LayoutView view state', () => { assert.equal(viewProps.flipY, false); assert.equal(viewProps.controller.scrollZoom, false); assert.equal(viewProps.controller.dragPan, true); + // deck's inertia only runs if its transition props come back through + // the controlled viewState; left on, a release never ended the move. assert.equal(viewProps.controller.inertia, false); }); @@ -115,6 +120,26 @@ describe('LayoutView view state', () => { assert.ok(Math.abs(before[1] - after[1]) < 1e-9); }); + // The pointer moved since the zoom under way began. + it('keeps the point under the cursor through a zoom mid-animation', () => { + const { view, frames } = setup({ smooth: true }); + view.setView([120, 120], 1, { animate: false }); + view.zoomAround([700, 100], 1); + frames.flush(100); + const pt = [100, 500]; + const before = view.unproject(pt); + view.zoomAround(pt, 1); + frames.flush(100); + const mid = view.unproject(pt); + frames.flush(400); + assert.equal(view.getZoom(), 3); + // Within a pixel: the view rests on whole device pixels. + for (const p of [mid, view.unproject(pt)]) { + assert.ok(Math.abs(p[0] - before[0]) < 1 / 8); + assert.ok(Math.abs(p[1] - before[1]) < 1 / 8); + } + }); + it('animates over 250 ms with smoothing and rests on the target', () => { const { view, frames } = setup({ smooth: true }); view.setView([120, 120], 1, { animate: false }); @@ -151,7 +176,7 @@ describe('LayoutView view state', () => { assert.deepEqual(view.getCenter(), [130, 140]); }); - it('honours the zoom limits', () => { + it('honors the zoom limits', () => { const { view, frames } = setup(); view.setLimits({ minZoom: 0, maxZoom: 3 }); view.setView([0, 0], 9); @@ -252,7 +277,7 @@ describe('LayoutView tiles', () => { assert.deepEqual(tileIds(deck), ['base:0/0/0', 'top:0/0/0']); }); - // Double buffering across the whole view (#11340). + // Double buffering across the whole view. it('keeps the old level until the new one is complete', async () => { const { view, deck, frames } = setup(); const source = makeSource(); @@ -302,6 +327,32 @@ describe('LayoutView tiles', () => { || l.id === 'base:mask')); }); + // A tile that failed has nothing to hide the loading level with. + it('leaves a failed tile of the old level unmasked', async () => { + const { view, deck, frames } = setup(); + const source = makeSource(); + view.setView([120, 120], 2); + view.addTileSlot('base', { order: DRAW_ORDER.base, source }); + const [failedKey, failed] = [...source.loads].find(([, l]) => l.z === 2); + source.loads.delete(failedKey); + failed.reject(new Error('Tile requests failed')); + source.settle(2); + await tick(); + view.setView([120, 120], 1); + const [key, first] = [...source.loads].find(([, l]) => l.z === 1); + source.loads.delete(key); + first.resolve({ image: { key }, width: 480, height: 480 }); + await tick(); + frames.flush(); + const mask = deck.layers().find((l) => l.id === 'base:mask'); + const [x0, y0, x1, y1] = tileWorldBounds(2, failed.x, failed.y, T); + const center = [(x0 + x1) / 2, (y0 + y1) / 2]; + assert.ok(mask.props.data.length > 0); + assert.ok(!mask.props.data.some( + (p) => p[0][0] < center[0] && center[0] < p[2][0] + && p[0][1] < center[1] && center[1] < p[2][1])); + }); + it('fades the new level in when smoothing is on', async () => { const { view, deck, frames } = setup({ smooth: true }); const source = makeSource(); @@ -759,7 +810,7 @@ describe('LayoutView flights', () => { assert.equal(view.getZoom(), 5); }); - // A jump at the same level used to drop what was on screen while waiting. + // A jump at the same level keeps what is on screen while it waits. it('keeps the view drawn while it waits to set off', async () => { const { view, source, frames } = flying(); source.settle(5); @@ -812,6 +863,31 @@ describe('LayoutView flights', () => { 'gone once the destination shows'); }); + // A zoom out of more than kMaxAnimatedZoomDelta that flies can pull out + // to the level the prefetch wants once it lands. + it('leaves the level above to a landed flight that pulled out to it', + async () => { + const { view, source, requested, frames } = flying(); + view.setView([40, 40], 10, { animate: false }); + source.settle(10); + await tick(); + frames.flush(); + view.setView([60, 40], 5); + assert.ok(requested.some((r) => r.z === 4 && !r.background), + 'the flight pulls out to level 4'); + source.settle(4); + await tick(); + frames.flush(16); + frames.flush(2000); + frames.flush(16); + assert.ok(!view.debugSnapshot().animating, 'landed'); + const before = requested.length; + source.settle(5); + await tick(); + await tick(); + assert.deepEqual(requested.slice(before).filter((r) => r.z === 4), []); + }); + it('sets off anyway when the pulled-out level is slow', () => { const { view, frames } = flying(); view.setView([200, 200], 5); @@ -864,13 +940,6 @@ describe('LayoutView drag and inertia', () => { return events; } - // deck's inertia only runs if its transition props come back through the - // controlled viewState; left on, a release never ended the move. - it("keeps deck's own inertia off even with smoothing", () => { - const { deck } = setup({ smooth: true }); - assert.equal(deck.decks[0].props.views.props.controller.inertia, false); - }); - it('glides on after a fast release with smoothing, then ends the move', async () => { const { view, deck, frames } = setup({ smooth: true }); view.setView([120, 120], 0, { animate: false }); @@ -950,6 +1019,29 @@ describe('LayoutView shapes, markers and capture', () => { assert.equal(deck.layers().length, 0); }); + // What the ruler draws: a solid line and a snap circle. + it('draws path overlays as solid strokes and circles as points', () => { + const { view, deck, frames } = setup(); + view.setOverlay('ruler', [ + { kind: 'path', points: [[0, 0], [10, 0]], + stroke: toRgba('#0ff'), width: 2 }, + { kind: 'circle', center: [5, 5], radius: 4, + stroke: toRgba('#fff'), width: 1 }, + ]); + frames.flush(); + const layers = deck.layers(); + const line = layers.find((l) => l instanceof deck.PathLayer); + const dot = layers.find((l) => l instanceof deck.ScatterplotLayer); + assert.ok(line && dot); + assert.equal(line.props.extensions, undefined, 'solid, not dashed'); + assert.deepEqual(line.props.getPath(line.props.data[0]), + [[0, 0], [10, 0]]); + assert.deepEqual(dot.props.getPosition(dot.props.data[0]), [5, 5]); + assert.equal(dot.props.getRadius(dot.props.data[0]), 4); + assert.deepEqual(dot.props.getFillColor(dot.props.data[0]), + [0, 0, 0, 0]); + }); + it('positions markers at their world point', () => { const { view, frames } = setup(); view.setView([120, 120], 1); @@ -964,7 +1056,7 @@ describe('LayoutView shapes, markers and capture', () => { assert.equal(el.parentNode, null); }); - it('converts colours to RGBA', () => { + it('converts colors to RGBA', () => { assert.deepEqual(toRgba('#ff0'), [255, 255, 0, 255]); assert.deepEqual(toRgba('#00ffff', 0.5), [0, 255, 255, 128]); assert.deepEqual(toRgba([1, 2, 3]), [1, 2, 3, 255]); @@ -1045,7 +1137,6 @@ describe('LayoutView shapes, markers and capture', () => { assert.ok(settled); }); - // A page whose CDN script failed still has a working view object. it('rebuilds the deck when the WebGL context is lost', async () => { const { view, deck, frames } = setup(); const source = makeSource(); @@ -1076,6 +1167,7 @@ describe('LayoutView shapes, markers and capture', () => { assert.equal(deck.decks.length, 3); }); + // A page without the deck namespace still has a working view object. it('keeps working without deck', async () => { const frames = makeFrames(); const view = createLayoutView(makeContainer(), { diff --git a/src/web/test/js/test-menu-bar.js b/src/web/test/js/test-menu-bar.js index f1270a534af..4d83419d8b7 100644 --- a/src/web/test/js/test-menu-bar.js +++ b/src/web/test/js/test-menu-bar.js @@ -303,10 +303,10 @@ function optionsApp(overrides = {}) { rulerStyle: 'euclidian', wheelZoom: true, polyDecomp: false, - // Rendering preferences (#11340), at their Qt-like defaults. + // Rendering preferences, at their Qt-like defaults. controlSmoothing: false, doubleBuffer: true, - deferTileUpdates: true, + deferTileUpdates: false, calls: [], toggleShowDbu() { this.calls.push('showDbu'); }, toggleRulerStyle() { this.calls.push('rulerStyle'); }, @@ -413,7 +413,7 @@ describe('Options menu', () => { assert.ok(row.classList.contains('disabled')); }); - // Rendering preferences (#11340). Web-only: Qt has no smoothing to switch + // Rendering preferences. Web-only: Qt has no smoothing to switch // off and already draws off-screen. it('offers the three rendering preferences, ticked from the app', () => { document.body.innerHTML = ''; @@ -424,7 +424,8 @@ describe('Options menu', () => { rowByLabel(rows, label).querySelector('.menu-check').textContent; assert.equal(tick('Smooth zoom and pan'), '', 'off by default'); assert.equal(tick('Double buffering'), '✓'); - assert.equal(tick('Defer tile updates while panning'), '✓'); + assert.equal(tick('Defer tile updates while panning'), '', + 'off by default'); rowByLabel(openMenu('Options'), 'Smooth zoom and pan').click(); rowByLabel(openMenu('Options'), 'Double buffering').click(); diff --git a/src/web/test/js/test-ruler.js b/src/web/test/js/test-ruler.js index 8bab076f4e9..69909dee797 100644 --- a/src/web/test/js/test-ruler.js +++ b/src/web/test/js/test-ruler.js @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright (c) 2026, The OpenROAD Authors -import { describe, it, beforeEach } from 'node:test'; +import { describe, it } from 'node:test'; import assert from 'node:assert/strict'; import { beginSelection, formatDbu, formatDistance, onSelectionReset, parseDbu } from '../../src/ui-utils.js'; @@ -23,7 +23,7 @@ function makeApp() { designScale: 1e-6, techData: { dbu_per_micron: 1000 }, showDbu: false, - visibleLayers: new Set(['metal1']), + visibleLayerNames: new Set(['metal1']), websocketManager: { request(msg) { requests.push(msg); @@ -491,6 +491,26 @@ describe('Ruler inspector data', () => { }); }); +// An edit made in the Inspector redraws the ruler once and shows it again, +// without taking the selection back from whoever holds it. +describe('Ruler edited in the Inspector', () => { + it('draws once and keeps the selection', () => { + const { mgr, app, inspectorData, focusCalls } = makeManager(); + mgr._createRuler({ x: 0, y: 0 }, { x: 100, y: 100 }); + mgr._selectRuler(0); + const token = app.selectionToken; + const focused = focusCalls.length; + let renders = 0; + const render = mgr._renderAll.bind(mgr); + mgr._renderAll = () => { renders++; render(); }; + inspectorData.at(-1).onPropertyChange('Point 1 - x', '0.2'); + assert.equal(renders, 1); + assert.equal(app.selectionToken, token); + assert.equal(focusCalls.length, focused); + assert.equal(mgr._rulers[0].pt1.x, 200); + }); +}); + // ─── Ruler naming ──────────────────────────────────────────────────────────── describe('Ruler naming', () => { @@ -528,7 +548,7 @@ describe('Ruler drawing', () => { assert.equal(shapes[0].width, 2); }); - it('colours the selected ruler yellow and the others cyan', () => { + it('colors the selected ruler yellow and the others cyan', () => { const { mgr, app } = makeDrawingManager(); mgr._createRuler({ x: 0, y: 0 }, { x: 100000, y: 0 }); mgr._createRuler({ x: 0, y: 200000 }, { x: 100000, y: 200000 }); @@ -646,6 +666,33 @@ describe('Ruler placement from view clicks', () => { assert.equal(app.view.markersIn('ruler-preview').length, 0); }); + // Escape while a snap is pending must not bring the indicator back. + it('drops a snap that arrives after the build was cancelled', async () => { + let reply; + const { mgr, app } = makeDrawingManager({ + websocketManager: { + request: () => new Promise((resolve) => { reply = resolve; }), + }, + }); + mgr.toggleRulerMode(); + const pending = mgr._requestSnap(0, 0); + mgr.cancelRulerBuild(); + reply({ found: true, is_point: true, edge: [[0, 0], [0, 0]] }); + await pending; + assert.equal(app.view.overlays.has('ruler-snap'), false); + assert.equal(mgr._lastSnapResult, null); + }); + + it('sends no snap request once the build was cancelled', () => { + const { mgr } = makeDrawingManager(); + mgr.toggleRulerMode(); + mgr.handleMouseMove([0, 0], { ctrlKey: false, metaKey: false, + shiftKey: false }); + assert.notEqual(mgr._snapTimer, null, 'a snap request is scheduled'); + mgr.cancelRulerBuild(); + assert.equal(mgr._snapTimer, null); + }); + it('draws the snap indicator as a circle for a point snap', () => { const { mgr, app } = makeDrawingManager(); mgr._updateSnapIndicator({ found: true, is_point: true, diff --git a/src/web/test/js/test-search-nav.js b/src/web/test/js/test-search-nav.js index 0ed49fa714b..4c413ca6620 100644 --- a/src/web/test/js/test-search-nav.js +++ b/src/web/test/js/test-search-nav.js @@ -167,7 +167,6 @@ describe('Find dialog', () => { const { app, calls } = makeApp({ websocketManager: { request(m) { sent.push(m); return Promise.resolve(response); } }, updateInspector() {}, - redrawAllLayers() {}, }); return { app, calls, sent }; } @@ -185,20 +184,22 @@ describe('Find dialog', () => { pattern: '_4*', match_case: false }]); const expected = dbuRectToWorldRect(0, 0, 3000, 4000, 1, 0, 0); assert.deepEqual(calls, [['fitWorldRect', expected]]); - assert.deepEqual(app.lastSelectionBounds, [0, 0, 3000, 4000]); assert.match(errorText(), /2 found/); }); - it('takes the selection from other panels', async () => { + it('takes the selection from other panels and the outline', async () => { document.body.innerHTML = ''; const { app } = findApp({ count: 1, selection_count: 1 }); let resets = 0; + let outlines = 0; onSelectionReset(app, () => resets++); + app.clearSelectionOutline = () => outlines++; showFindDialog(app); setInput('.sn-pattern', 'u1'); clickOk(); await wait(); assert.equal(resets, 1); + assert.equal(outlines, 1); assert.match(errorText(), /1 found/); }); @@ -212,7 +213,6 @@ describe('Find dialog', () => { beginSelection(app); // a click on the layout before the reply await wait(); assert.deepEqual(calls, []); - assert.equal(app.lastSelectionBounds, undefined); assert.match(errorText(), /2 found/); }); @@ -230,16 +230,21 @@ describe('Find dialog', () => { assert.equal(app.selectionToken, token); }); - it('brings the Select Highlight panel up to date', async () => { + // Only the selection changed, and it lives on the overlay; that hook also + // brings the Select Highlight panel up to date. + it('refreshes the overlay, not every layer', async () => { document.body.innerHTML = ''; const { app } = findApp({ count: 1, selection_count: 1 }); - let refreshes = 0; - app.selectionBrowser = { scheduleRefresh: () => refreshes++ }; + let overlays = 0; + let redraws = 0; + app.refreshOverlay = () => overlays++; + app.redrawAllLayers = () => redraws++; showFindDialog(app); setInput('.sn-pattern', 'u1'); clickOk(); await wait(); - assert.equal(refreshes, 1); + assert.equal(overlays, 1); + assert.equal(redraws, 0); }); it('reports when nothing is found and does not zoom', async () => { diff --git a/src/web/test/js/test-tile-grid.js b/src/web/test/js/test-tile-grid.js index 2e022952992..8e53ee41b66 100644 --- a/src/web/test/js/test-tile-grid.js +++ b/src/web/test/js/test-tile-grid.js @@ -46,7 +46,7 @@ const tick = () => new Promise((resolve) => setTimeout(resolve, 0)); const R = (x0, x1, y0, y1, z = 3) => ({ z, x0, x1, y0, y1 }); describe('TileGrid.update', () => { - it('loads the on-screen tiles first, nearest the centre first', () => { + it('loads the on-screen tiles first, nearest the center first', () => { const { source, loads } = makeSource(); const grid = new TileGrid({ source }); const range = R(2, 4, 2, 4); @@ -107,6 +107,21 @@ describe('TileGrid.update', () => { assert.deepEqual(released, [{ id: 'a' }]); }); + // Panned right off the design: nothing to load, but what was loaded is + // there again when the view comes back. + it('keeps its loaded tiles while the view is off the grid', async () => { + const { source, loads, released } = makeSource(); + const grid = new TileGrid({ source }); + grid.update({ z: 3, range: R(0, 0, 0, 0) }); + loads[0].resolve({ id: 'a' }); + await tick(); + grid.update({ z: 3, range: null }); + assert.ok(grid.tiles.has('3/0/0')); + assert.deepEqual(released, []); + grid.update({ z: 3, range: R(0, 0, 0, 0) }); + assert.equal(loads.length, 1, 'nothing asked for again'); + }); + it('drops loads of another level but keeps its loaded tiles', async () => { const { source, loads } = makeSource(); const grid = new TileGrid({ source }); @@ -154,6 +169,20 @@ describe('TileGrid loading results', () => { assert.ok(grid.isSettled()); }); + it('marks a failed tile until a load of it lands', async () => { + const { source, loads } = makeSource(); + const grid = new TileGrid({ source }); + const range = R(0, 0, 0, 0); + grid.update({ z: 3, range, ring: range }); + loads[0].reject(new Error('boom')); + await tick(); + assert.ok(grid.tiles.get('3/0/0').failed); + grid.refresh(); + loads[1].resolve(null); + await tick(); + assert.ok(!grid.tiles.get('3/0/0').failed); + }); + it('is settled while only ring tiles are loading', async () => { const { source, loads } = makeSource(); const grid = new TileGrid({ source }); @@ -376,6 +405,26 @@ describe('TileGrid.refresh off the ring', () => { assert.ok(kept.drawable, 'shown until the new one arrives'); }); + it('fetches the stale tiles of a returning level from its center out', + async () => { + const { source, loads } = makeSource(); + const grid = new TileGrid({ source, keepBuffer: 2 }); + const range3 = R(2, 4, 2, 4); + grid.update({ z: 3, range: range3, ring: growRange(range3) }); + for (const l of loads) { + l.resolve({ key: l.key }); + } + await tick(); + grid.update({ z: 4, range: R(4, 8, 4, 8, 4) }); + grid.refresh(); // level 3 goes stale + const before = loads.length; + const back = R(4, 6, 2, 4); + grid.update({ z: 3, range: back, ring: growRange(back) }); + const again = loads.slice(before).filter((l) => l.z === 3); + assert.equal(again[0].key, '3/5/3'); + assert.ok(!again[0].background); + }); + it('does not fetch stale tiles of a returning level off its ring', async () => { const { source, loads, released } = makeSource(); @@ -411,8 +460,10 @@ describe('TileGrid.prune', () => { assert.deepEqual(released, [{ id: 'old' }]); assert.ok(grid.tiles.has('4/0/0')); }); +}); - it('clear() cancels everything', () => { +describe('TileGrid.clear', () => { + it('cancels everything', () => { const { source, loads } = makeSource(); const grid = new TileGrid({ source }); grid.update({ z: 3, range: R(0, 1, 0, 1) }); diff --git a/src/web/test/js/test-tile-merge.js b/src/web/test/js/test-tile-merge.js index d6b2ba11b4b..b42a98183a6 100644 --- a/src/web/test/js/test-tile-merge.js +++ b/src/web/test/js/test-tile-merge.js @@ -49,30 +49,7 @@ function makeGates(layers) { }; } -describe('tile-merge is pure', () => { - it('exports plain functions with no DOM or renderer dependency', () => { - // Everything here is compositing rules with the canvas injected, so it - // stays testable without a browser. The view parts live in - // tile-sources.js. - for (const fn of [setItemVisible, mergeOntoContext, closeAll, - blendOver, compositeStack, renderMergedTile]) { - assert.equal(typeof fn, 'function'); - } - }); -}); - describe('mergeOntoContext', () => { - function fakeCtx() { - const calls = []; - return { - calls, - globalAlpha: 1, - clearRect: (...a) => calls.push(['clearRect', ...a]), - drawImage: (img, x, y, w, h) => calls.push( - ['drawImage', img.id, x, y, w, h, calls.ctxAlpha]), - }; - } - // drawImage must observe the alpha set immediately before it, so record it. function recordingCtx() { const drawn = []; @@ -129,7 +106,6 @@ describe('mergeOntoContext', () => { const n = mergeOntoContext(ctx, [ { image: { id: 'a' }, opacity: 1 }, { image: null, opacity: 1 }, - null, { image: { id: 'd' }, opacity: 1 }, ], 256); assert.equal(n, 2); @@ -148,14 +124,6 @@ describe('mergeOntoContext', () => { assert.equal(mergeOntoContext(ctx, [], 256), 0); assert.equal(ctx.cleared, 1); }); - - it('is a no-op without a context or a size', () => { - const { ctx } = recordingCtx(); - assert.equal(mergeOntoContext(null, [{ image: { id: 'a' } }], 256), 0); - assert.equal(mergeOntoContext(ctx, [{ image: { id: 'a' } }], 0), 0); - assert.equal(ctx.cleared, 0); - assert.equal(mergeOntoContext(ctx, null, 256), 0); - }); }); describe('closeAll', () => { @@ -401,18 +369,11 @@ describe('renderMergedTile', () => { } }); - it('carries each item its own opacity', async () => { - const h = harness({ items: ITEMS }); - await renderMergedTile(h.opts); - const last = h.drawnCalls[h.drawnCalls.length - 1]; - assert.deepEqual(last.map(d => d.opacity), [0.7, 0.7, 1]); - }); - it('issues the requests concurrently, not one after another', async () => { - // Serialising K requests would multiply tile latency by K. + // Serializing K requests would multiply tile latency by K. // // Asserted as "all K are in flight before any of them answers", which - // is the property itself: with every request held open, a serialised + // is the property itself: with every request held open, a serialized // implementation could not have issued the second. Timing the whole // render instead only inferred it, and inferred it from a wall clock // that a busy machine moves (see flush()). @@ -471,15 +432,6 @@ describe('renderMergedTile', () => { assert.deepEqual(h.released.sort(), ['_instances', 'metal2']); }); - it('paints an empty group rather than leaving stale pixels', async () => { - // The canvas is reused across refreshes, so an empty group must clear. - const h = harness({ items: [] }); - const stats = await renderMergedTile(h.opts); - assert.equal(stats.requested, 0); - assert.equal(h.drawnCalls.length, 1); - assert.deepEqual(h.drawnCalls[0], []); - }); - it('abandons a stale tile before drawing', async () => { const h = harness({ items: ITEMS, stale: () => true }); const stats = await renderMergedTile(h.opts); @@ -489,7 +441,7 @@ describe('renderMergedTile', () => { it('stops painting the moment it goes stale, and still frees the decodes', async () => { // A refresh or pan mid-flight must not keep painting the canvas with - // content the map has already moved past — but the bitmaps decoded + // content the view has already moved past — but the bitmaps decoded // before that point still have to be released. let stale = false; const h = harness({ items: ITEMS, stale: () => stale }); @@ -504,62 +456,6 @@ describe('renderMergedTile', () => { assert.equal(h.drawnCalls.length, 1, 'no painting after going stale'); assert.equal(h.released.length, 3, 'decoded images must still be freed'); }); - - it('tolerates being called with nothing', async () => { - const stats = await renderMergedTile(); - assert.equal(stats.requested, 0); - }); -}); - -describe('renderMergedTile: a missing draw is a loud failure, not a blank tile', () => { - it('throws when a non-empty group has no draw', async () => { - // The no-argument tolerance above must not turn a forgotten dependency - // into a silently blank tile. - await assert.rejects(renderMergedTile({ - items: [{ layer: 'metal1', opacity: 0.7 }], - request: async () => ({}), - decode: async () => ({ close() {} }), - }), TypeError); - }); -}); - -describe('dpr must match the server and honour the display', () => { - // The client sizes its merged canvas from this and the server renders from - // its own copy. If they disagree, every tile is drawn at the wrong size: - // it resamples (the moiré beat the pipeline avoids) and the memory budget - // reserves one bitmap size while holding another. - it('honours the display ratio instead of snapping to a ladder', async () => { - const { quantizeDpr } = await import('../../src/tile-request.js'); - // 1.75 and 2.5 are ordinary Windows scale factors. A 5-step ladder - // served them 1.5 and 2.0, i.e. tiles 17% and 25% too small, upscaled - // by the browser — exactly what the tile sizing exists to prevent. - assert.equal(quantizeDpr(1.75), 1.75); - assert.equal(quantizeDpr(2.5), 2.5); - for (const d of [1, 1.25, 1.5, 2, 3]) { - assert.equal(quantizeDpr(d), d); - } - }); - - it('rounds to two decimals to bound the cache key space', async () => { - // dpr is part of the server's tile-cache key, so an unrounded - // 1.3333333 would fork its own set of cached tiles. - const { quantizeDpr } = await import('../../src/tile-request.js'); - assert.equal(quantizeDpr(4 / 3), 1.33); - assert.equal(quantizeDpr(1.666666), 1.67); - assert.equal(quantizeDpr(1.005), 1.0); - }); - - it('clamps and degrades exactly as the server does', async () => { - const { quantizeDpr } = await import('../../src/tile-request.js'); - assert.equal(quantizeDpr(8), 3); - assert.equal(quantizeDpr(3.0001), 3); - assert.equal(quantizeDpr(1), 1); - assert.equal(quantizeDpr(0.5), 1); - assert.equal(quantizeDpr(0), 1); - assert.equal(quantizeDpr(-2), 1); - assert.equal(quantizeDpr(NaN), 1); - assert.equal(quantizeDpr(undefined), 1); - }); }); describe('setItemVisible: only a real change may dirty a slot', () => { @@ -652,9 +548,9 @@ describe('renderMergedTile: incremental painting', () => { await h.arrive('b'); await h.arrive('c'); - const stats = await done; - assert.equal(stats.paints, 3, 'one paint per arrival'); - // Each paint is a full composite of what has arrived so far, in order. + await done; + // One paint per arrival, each a full composite of what has arrived so + // far, in order. assert.deepEqual(h.drawnCalls, [ ['a', null, null], ['a', 'b', null], @@ -688,18 +584,6 @@ describe('renderMergedTile: incremental painting', () => { assert.deepEqual(last, ['a', null, 'c']); }); - it('paints an all-blank composite when nothing arrives', async () => { - // Otherwise a tile whose every layer failed would never settle, and - // the view would wait on it forever. - const h = incHarness(ITEMS3); - h.opts.request = async () => { throw new Error('cancelled'); }; - const stats = await renderMergedTile(h.opts); - assert.equal(stats.arrived, 0); - assert.equal(stats.failed, 3); - assert.equal(stats.paints, 1); - assert.deepEqual(h.drawnCalls[0], [null, null, null]); - }); - it('holds the decodes until the tile is complete, then frees them all', async () => { // A late arrival belongs UNDERNEATH layers already drawn, so the canvas // is recomposited from scratch and every source must still be around. @@ -721,7 +605,7 @@ describe('renderMergedTile: incremental painting', () => { assert.deepEqual(h.released.sort(), ['a', 'b', 'c']); }); - // ── Options > "Double buffering" (#11340) ── + // ── Options > "Double buffering" ── // // Every paint clears the canvas first, so repainting a tile that is already // on screen shows the group being rebuilt layer by layer. One composite, @@ -737,8 +621,7 @@ describe('renderMergedTile: incremental painting', () => { assert.deepEqual(h.drawnCalls, [], 'nothing painted mid-flight'); await h.arrive('c'); - const stats = await done; - assert.equal(stats.paints, 1); + await done; assert.deepEqual(h.drawnCalls, [['a', 'b', 'c']]); }); @@ -753,7 +636,7 @@ describe('renderMergedTile: incremental painting', () => { }); // The cost of buffering, stated in a test rather than in a comment: the - // tile now appears at the pace of its slowest layer, so a request that + // tile appears at the pace of its slowest layer, so a request that // never settles holds it hidden instead of costing one missing layer. That // rests on cancel() rejecting rather than leaving a request pending — see // WebSocketManager.cancel. @@ -773,9 +656,7 @@ describe('renderMergedTile: incremental painting', () => { async () => { const h = incHarness(ITEMS3); h.opts.request = async () => { throw new Error('cancelled'); }; - const stats = await renderMergedTile( - { ...h.opts, incremental: false }); - assert.equal(stats.paints, 1); + await renderMergedTile({ ...h.opts, incremental: false }); assert.deepEqual(h.drawnCalls, [[null, null, null]]); }); diff --git a/src/web/test/js/test-tile-sources.js b/src/web/test/js/test-tile-sources.js index baf650fe241..864729fff64 100644 --- a/src/web/test/js/test-tile-sources.js +++ b/src/web/test/js/test-tile-sources.js @@ -136,6 +136,17 @@ describe('createCompositeSource', () => { assert.equal(await handle.promise, null); }); + // A saved report keeps only tiles with content. + it('is blank in a saved report when no shown layer was saved', async () => { + const { WebSocketManager } = await import('../../src/websocket-manager.js'); + const wm = WebSocketManager.fromCache({ tiles: { 'metal2/3/0/0': 'aGk=' } }); + const source = createCompositeSource({ + wm, ctx, getItems: () => ITEMS, dpr: () => 2, tileSize: () => 240, + decode, + }); + assert.equal(await source.load({ z: 3, x: 0, y: 0 }).promise, null); + }); + it('sends a ring tile at background priority and can promote it', () => { const { wm, source } = composite(); const handle = source.load({ z: 3, x: 0, y: 0 }, { background: true }); @@ -174,14 +185,6 @@ describe('createCompositeSource', () => { assert.equal(partials.length, 2); }); - it('resolves an all-empty tile to null', async () => { - const { wm, source } = composite(); - const handle = source.load({ z: 3, x: 0, y: 0 }); - wm.reply('_instances', null); - wm.reply('metal1', null); - assert.equal(await handle.promise, null); - }); - it('allocates a canvas only once a layer has an image', async () => { const empty = composite(); const h1 = empty.source.load({ z: 3, x: 0, y: 0 }); @@ -271,8 +274,6 @@ describe('createCompositeSource with layers shared by dies', () => { }); }); -// The server's layer_extents bound where each layer has shapes; a tile outside -// a layer's box is not asked for that layer (layer-extents.js). // A gated item stays in its slot while its flag is off, but asks for nothing. describe('createCompositeSource with gated items', () => { const items = (gate) => [{ layer: '_clusters', opacity: 1, visible: true, @@ -321,6 +322,8 @@ describe('createCompositeSource with gated items', () => { }); }); +// The server's layer_extents bound where each layer has shapes; a tile outside +// a layer's box is not asked for that layer (layer-extents.js). describe('createCompositeSource with layer extents', () => { // metal1 lives in the top-left quarter of the zoom-0 grid only. function withExtents() { @@ -503,7 +506,7 @@ describe('tile requests', () => { assert.equal(build('metal1').pattern, undefined); }); - // Two dies can share a layer name (#11886); a row's tiles draw its die. + // Two dies can share a layer name; a row's tiles draw its die. it('scopes a row to its die and keys its pattern by row', () => { const rowCtx = { ...tctx, diff --git a/src/web/test/js/test-ui-utils.js b/src/web/test/js/test-ui-utils.js index f00346cc6b6..52c66737699 100644 --- a/src/web/test/js/test-ui-utils.js +++ b/src/web/test/js/test-ui-utils.js @@ -34,7 +34,6 @@ describe('computeBoundsTransforms', () => { [544908, 544908]]); assert.equal(t.originX, -63538); assert.equal(t.originY, -63538); - assert.equal(t.maxDXDY, 608446); assert.equal(t.scale, 256 / 608446); // With no fit rect the georeference rect is fitted, plus the margin, // as a world rect [minX, minY, maxX, maxY] with the origin at (0, 0). @@ -44,7 +43,6 @@ describe('computeBoundsTransforms', () => { it('uses the larger dimension for non-square designs', () => { const t = computeBoundsTransforms([[0, 0], [100, 400]]); - assert.equal(t.maxDXDY, 400); // The fit rect's top edge reflects the smaller height. const scale = 256 / 400; const padX = 400 * kZoomMargin * scale; @@ -59,7 +57,6 @@ describe('computeBoundsTransforms', () => { const fit = [[0, 0], [1000, 1000]]; const t = computeBoundsTransforms(geo, 256, fit); // The transforms still come from the georeference rect. - assert.equal(t.maxDXDY, 1200); assert.equal(t.originX, -100); const withFit = t.fitRect[2] - t.fitRect[0]; @@ -195,7 +192,7 @@ describe('fittedTileSizeCss', () => { { ...wide, designBounds: [[0, 0], [0, 0]] }, { ...wide, viewW: 0 }, { ...wide, viewH: NaN }, - // A viewport too small to reach zoom 0: the map is pinned at its + // A viewport too small to reach zoom 0: the view is pinned at its // minZoom and a bigger tile would only overflow it. { ...wide, viewW: 10, viewH: 10 }, ]; diff --git a/src/web/test/js/test-view-input.js b/src/web/test/js/test-view-input.js index a834b73d750..c585e4add2c 100644 --- a/src/web/test/js/test-view-input.js +++ b/src/web/test/js/test-view-input.js @@ -5,8 +5,8 @@ import './setup-dom.js'; import { describe, it } from 'node:test'; import assert from 'node:assert/strict'; -const { installViewInput, arrowPanOffset, isWheelNotch, gestureSteps } - = await import('../../src/view-input.js'); +const { installViewInput, placementClicks, arrowPanOffset, isWheelNotch, + gestureSteps } = await import('../../src/view-input.js'); // A view that records calls; world = screen / 2 so results are checkable. function makeView() { @@ -231,7 +231,7 @@ describe('keyboard', () => { assert.equal(calls.length, 0); }); - it('zooms on + and - about the centre, not in a saved report', () => { + it('zooms on + and - about the center, not in a saved report', () => { const { view, container, calls } = makeView(); let isStatic = false; installViewInput(view, { isStatic: () => isStatic }); @@ -468,3 +468,42 @@ describe('pointer tracking', () => { assert.equal(calls.length, 0); }); }); + +describe('placementClicks', () => { + function makeApp({ ruler = false, label = false, onLine = false } = {}) { + const calls = []; + return { + calls, + rulerManager: { + isActive: () => ruler, + handleMapClick: () => calls.push('ruler'), + handleRulerClick: () => { calls.push('line?'); return onLine; }, + }, + labelManager: { isActive: () => label }, + onMapClick: () => calls.push('map'), + }; + } + + it('selects a ruler line before the object under it', () => { + const app = makeApp({ onLine: true }); + placementClicks(app).onClick([0, 0], {}); + assert.deepEqual(app.calls, ['line?']); + assert.ok(placementClicks(app).contextEnabled()); + }); + + it('gives a ruler being placed the click and no context menu', () => { + const app = makeApp({ ruler: true }); + const clicks = placementClicks(app); + clicks.onClick([0, 0], {}); + assert.deepEqual(app.calls, ['ruler']); + assert.ok(!clicks.contextEnabled()); + }); + + it('places a label over a ruler line, with no context menu', () => { + const app = makeApp({ label: true, onLine: true }); + const clicks = placementClicks(app); + clicks.onClick([0, 0], {}); + assert.deepEqual(app.calls, ['map']); + assert.ok(!clicks.contextEnabled()); + }); +}); diff --git a/src/web/test/js/test-view-math.js b/src/web/test/js/test-view-math.js index 66f1a65af25..602a325ea2b 100644 --- a/src/web/test/js/test-view-math.js +++ b/src/web/test/js/test-view-math.js @@ -16,7 +16,7 @@ const vs = (over = {}) => ({ target: [120, 120], zoom: 0, width: 800, const close = (a, b, eps = 1e-9) => Math.abs(a - b) <= eps; describe('project / unproject', () => { - it('puts the target at the centre of the view', () => { + it('puts the target at the center of the view', () => { assert.deepEqual(project([120, 120], vs()), [400, 300]); }); @@ -43,7 +43,7 @@ describe('project / unproject', () => { describe('fitView', () => { // The view rests on whole levels, so the fitted zoom is floored. - it('floors to a whole zoom level and centres the rect', () => { + it('floors to a whole zoom level and centers the rect', () => { const fit = fitView([0, 0, 100, 100], vs()); assert.equal(fit.zoom, 2); // 600/100 = 6 -> log2 = 2.58 -> 2 assert.deepEqual(fit.target, [50, 50]); @@ -64,7 +64,7 @@ describe('fitView', () => { assert.equal(fitView(rect, vs({ height: 1e6 })).zoom, 2); }); - it('honours the zoom limits', () => { + it('honors the zoom limits', () => { assert.equal(fitView([0, 0, 1e-3, 1e-3], vs(), { maxZoom: 12 }).zoom, 12); assert.equal(fitView([0, 0, 1e6, 1e6], vs(), { minZoom: -2 }).zoom, -2); }); @@ -150,7 +150,7 @@ describe('growRange / inRange / rangeTiles', () => { assert.ok(!inRange(null, 1, 1)); }); - it('lists the range nearest the centre first', () => { + it('lists the range nearest the center first', () => { const tiles = rangeTiles({ z: 3, x0: 0, x1: 2, y0: 0, y1: 2 }); assert.equal(tiles.length, 9); assert.deepEqual(tiles[0], { z: 3, x: 1, y: 1 }); @@ -228,7 +228,7 @@ describe('flyPath', () => { assert.ok(near(p.S, 4 * Math.LN2 / Math.SQRT2, 1e-9)); }); - // A view zoomed in by its centre ends a sub-pixel away from the fit once + // A view zoomed in by its center ends a sub-pixel away from the fit once // snapTarget has run; the flight back must still be a number everywhere. it('stays finite for a tiny shift between far-apart zooms', () => { const view = { width: 1600, height: 1000 }; @@ -237,10 +237,10 @@ describe('flyPath', () => { { ...view, target: [120, 120], zoom: 2 }], ]; for (let k = 0; k < 20; k++) { - const centre = [100 + k * 3.7171, 80 + k * 2.3131]; - const zoomed = { ...view, target: centre, zoom: 10 }; + const center = [100 + k * 3.7171, 80 + k * 2.3131]; + const zoomed = { ...view, target: center, zoom: 10 }; cases.push([{ ...zoomed, target: snapTarget(zoomed, 1.5) }, - { ...view, target: centre, zoom: 1 }]); + { ...view, target: center, zoom: 1 }]); } for (const [from, to] of cases) { const p = flyPath(from, to); diff --git a/src/web/test/js/test-websocket-manager.js b/src/web/test/js/test-websocket-manager.js index c244603ee9b..901b28c2779 100644 --- a/src/web/test/js/test-websocket-manager.js +++ b/src/web/test/js/test-websocket-manager.js @@ -473,7 +473,7 @@ async function saturated() { return { mgr, first }; } -// Tiles prefetched around the view (#11340) must never delay one on screen. +// Tiles prefetched around the view must never delay one on screen. describe('WebSocketManager background requests', () => { it('go out only once the foreground queue is empty', async () => { const { mgr, first } = await saturated(); @@ -514,7 +514,10 @@ describe('WebSocketManager background requests', () => { await mgr.readyPromise; const bg = mgr.request({ type: 'tile', n: 0 }, { background: true }); bg.catch(() => {}); + assert.ok(mgr._bgSent.has(bg.requestId), 'on the wire'); mgr.cancel(bg.requestId); + assert.ok(!mgr.pending.has(bg.requestId)); + assert.ok(!mgr._bgSent.has(bg.requestId)); assert.equal(mgr.pendingCount, 0); }); @@ -865,12 +868,12 @@ describe('WebSocketManager.fromCache', () => { assert.ok(result.startsWith('data:image/png;base64,')); }); - it('rejects uncached tile', async () => { + it('answers an uncached tile as empty', async () => { const mgr = WebSocketManager.fromCache(makeCache()); - await assert.rejects( - mgr.request({ type: 'tile', layer: 'M1', z: 1, x: 9, y: 9 }), - { message: /Tile not cached/ } - ); + const result = await mgr.request({ + type: 'tile', layer: 'M1', z: 1, x: 9, y: 9 + }); + assert.equal(result, null); }); // Two dies can share a layer name; each row's tile is saved per die. @@ -882,12 +885,9 @@ describe('WebSocketManager.fromCache', () => { type: 'tile', layer: 'M1', chiplet: 'top/die0', z: 1, x: 0, y: 0 }); assert.equal(result, 'data:image/png;base64,aGk='); - await assert.rejects( - mgr.request({ - type: 'tile', layer: 'M1', chiplet: 'top/die1', z: 1, x: 0, - y: 0, - }), - { message: /Tile not cached/ }); + assert.equal(await mgr.request({ + type: 'tile', layer: 'M1', chiplet: 'top/die1', z: 1, x: 0, y: 0, + }), null); }); it('timing_highlight calls setPathOverlay with data URI', async () => { diff --git a/src/web/test/js/test-zoom-swap.js b/src/web/test/js/test-zoom-swap.js index efda2d34615..faac1b89e4f 100644 --- a/src/web/test/js/test-zoom-swap.js +++ b/src/web/test/js/test-zoom-swap.js @@ -141,14 +141,6 @@ describe('ZoomSwap with double buffering', () => { assert.deepEqual(levels(swap.plan()), [5]); assert.deepEqual(swap.under, []); }); - - it('drops the old level when the new one arrives complete', () => { - const { swap } = makeSwap(); - swap.setZoom(3); - swap.setZoom(4); - assert.equal(swap.check({ settled: true }), true); - assert.deepEqual(levels(swap.plan()), [4]); - }); }); describe('ZoomSwap fade', () => { @@ -264,4 +256,15 @@ describe('ZoomSwap.isIdle', () => { advance(ZOOM_FADE_MS + 1); assert.ok(swap.isIdle()); }); + + it('is false while an old level is kept under, without double buffering', + () => { + const { swap } = makeSwap({ isEnabled: () => false }); + swap.setZoom(3); + swap.setZoom(4); + assert.equal(swap.pendingZ, null); + assert.ok(!swap.isIdle()); + swap.check({ settled: true }); + assert.ok(swap.isIdle()); + }); }); From ac0659554b66a56de289aad498ac5e444a6d381f Mon Sep 17 00:00:00 2001 From: Jorge Ferreira Date: Tue, 17 Nov 2026 02:11:50 +0000 Subject: [PATCH 7/8] web: fix clang-tidy findings in the tile cache code Use std::scoped_lock, drop a nested conditional and add a trailing comma to the tile key initializer. Signed-off-by: Jorge Ferreira --- src/web/src/request_handler.cpp | 18 ++++++++++-------- src/web/src/tile_generator.cpp | 15 +++++++++------ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/web/src/request_handler.cpp b/src/web/src/request_handler.cpp index bc6ecc2795b..3e94948ae81 100644 --- a/src/web/src/request_handler.cpp +++ b/src/web/src/request_handler.cpp @@ -6293,14 +6293,16 @@ WebSocketResponse TileHandler::handleTile(const WebSocketRequest& req, cache_epoch = gen_->tileCacheEpoch(); // Key = what the render reads: the tile, its dpr and pixel count, the // design and chiplet revisions and the visibility this layer depends on. - boost::json::object tile_obj{{"layer", layer}, - {"z", z}, - {"x", x}, - {"y", y}, - {"dpr", dpr}, - {"tile_px", tile_px}, - {"rev", gen_->searchRevision()}, - {"chiplets", gen_->chipletsGeneration()}}; + boost::json::object tile_obj{ + {"layer", layer}, + {"z", z}, + {"x", x}, + {"y", y}, + {"dpr", dpr}, + {"tile_px", tile_px}, + {"rev", gen_->searchRevision()}, + {"chiplets", gen_->chipletsGeneration()}, + }; // Two cacheable states share everything else: painting the design's // default palette, and painting nothing because the session cleared every // row. Without this they collide on one key and the cleared view serves diff --git a/src/web/src/tile_generator.cpp b/src/web/src/tile_generator.cpp index 5248ceb7f89..2df9c9f9ff0 100644 --- a/src/web/src/tile_generator.cpp +++ b/src/web/src/tile_generator.cpp @@ -1698,7 +1698,7 @@ TileGenerator::~TileGenerator() = default; void TileGenerator::ensureInit(const bool fresh_cache) { - std::lock_guard lock(init_mutex_); + std::scoped_lock lock(init_mutex_); // Read first: a load landing during the init brings on the next one. const uint64_t loads = load_counter_.loads.load(); // A chip made without a load hook (dbChip::create) counts as a load too. @@ -1839,7 +1839,7 @@ bool TileGenerator::tileCacheGet(const std::string& key, uint64_t TileGenerator::tileCacheEpoch() const { - std::lock_guard lock(tile_cache_mutex_); + std::scoped_lock lock(tile_cache_mutex_); return tile_cache_epoch_; } @@ -1878,7 +1878,7 @@ void TileGenerator::tileCachePut(std::string key, void TileGenerator::clearTileCache() { - std::lock_guard lock(tile_cache_mutex_); + std::scoped_lock lock(tile_cache_mutex_); tile_cache_lru_.clear(); tile_cache_index_.clear(); tile_cache_bytes_ = 0; @@ -1893,7 +1893,7 @@ size_t TileGenerator::tileCacheSize() const size_t TileGenerator::tileCacheBytes() const { - std::lock_guard lock(tile_cache_mutex_); + std::scoped_lock lock(tile_cache_mutex_); return tile_cache_bytes_; } @@ -1904,8 +1904,11 @@ std::string TileGenerator::tileCacheKey(const TileVisibility& vis, std::string flags; flags.reserve(std::size(kVisibilityFields)); for (const BoolField& f : kVisibilityFields) { - const bool affects = f.owner == nullptr || layer == f.owner; - flags += !affects ? '-' : (vis.*(f.field) ? '1' : '0'); + if (f.owner != nullptr && layer != f.owner) { + flags += '-'; + } else { + flags += vis.*f.field ? '1' : '0'; + } } boost::json::object key; From 94f615f91509ee2a45be35d8c499bc84d97eb440 Mon Sep 17 00:00:00 2001 From: Jorge Ferreira Date: Sat, 28 Nov 2026 00:00:55 +0000 Subject: [PATCH 8/8] web: fix review findings in the viewer, tile cache, and smoke test Wheel and pointer input edge cases, stale tile loads, a per-flag tile cache key, the reload loop without a design, and the smoke test's CI job and cleanup. Signed-off-by: Jorge Ferreira --- .../github-actions-web-browser-smoke.yml | 15 +- openroad/web/docs/server-api.md | 18 +- openroad/web/esbuild.config.mjs | 4 +- openroad/web/include/web/web.h | 2 +- openroad/web/src/deck-global.js | 2 + openroad/web/src/display-controls.js | 10 + openroad/web/src/inspector.js | 31 ++- openroad/web/src/label-manager.js | 18 +- openroad/web/src/layout-view.js | 60 +++-- openroad/web/src/main.js | 39 ++-- openroad/web/src/ruler.js | 19 +- openroad/web/src/tile-grid.js | 15 +- openroad/web/src/tile_generator.cpp | 214 +++++++++++------- openroad/web/src/ui-utils.js | 7 +- openroad/web/src/view-input.js | 47 +++- openroad/web/test/browser_smoke_test.py | 32 ++- openroad/web/test/cpp/TestRequestHandler.cpp | 13 +- openroad/web/test/cpp/TestTileGenerator.cpp | 202 +++++++++++------ openroad/web/test/js/test-display-controls.js | 14 ++ openroad/web/test/js/test-inspector.js | 36 +++ openroad/web/test/js/test-label-manager.js | 14 +- openroad/web/test/js/test-layout-view.js | 70 +++++- openroad/web/test/js/test-ruler.js | 11 +- openroad/web/test/js/test-tile-grid.js | 44 ++++ openroad/web/test/js/test-view-input.js | 166 +++++++++++++- 25 files changed, 807 insertions(+), 296 deletions(-) diff --git a/.github/workflows/github-actions-web-browser-smoke.yml b/.github/workflows/github-actions-web-browser-smoke.yml index 32ba8249239..c93f0206a95 100644 --- a/.github/workflows/github-actions-web-browser-smoke.yml +++ b/.github/workflows/github-actions-web-browser-smoke.yml @@ -1,5 +1,4 @@ name: web-browser-smoke - # The web viewer's unit tests draw against a stand-in for deck.gl; this one # opens the live viewer and a saved report in Chrome and checks that a tile is # drawn (//openroad/web/test:browser_smoke_test, tagged manual). @@ -9,11 +8,15 @@ on: - master paths: - openroad/web/** + - MODULE.bazel + - MODULE.bazel.lock - .github/workflows/github-actions-web-browser-smoke.yml - permissions: contents: read - +# A new push to the PR cancels the run still building the last one. +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true jobs: Web-Browser-Smoke: runs-on: ${{ vars.USE_SELF_HOSTED == 'true' && 'self-hosted-ubuntu-26.04' || 'ubuntu-26.04' }} @@ -22,26 +25,24 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: submodules: recursive - - name: Set up bazel uses: bazel-contrib/setup-bazel@f34d6a05eae3c24acab7fa54587492daeaeffdab # 0.19.2 with: bazelisk-version: 1.x bazelisk-cache: true - - name: Install Chrome when the runner has none run: | if ! command -v google-chrome >/dev/null; then curl -fsSLo "${RUNNER_TEMP}/chrome.deb" \ https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb + sudo apt-get update sudo apt-get install -y "${RUNNER_TEMP}/chrome.deb" fi google-chrome --version - - name: Draw the layout in Chrome env: BAZEL_CACHE_LOGIN: ${{ secrets.BAZEL_CACHE_LOGIN }} - run: | + run: |- # Same remote cache as github-actions-clang-tidy-bazel.yml: authed # when the secret is there, the .bazelrc anonymous read otherwise. LOGIN="${BAZEL_CACHE_LOGIN}" diff --git a/openroad/web/docs/server-api.md b/openroad/web/docs/server-api.md index 6cbf8a96642..23f521bc2ac 100644 --- a/openroad/web/docs/server-api.md +++ b/openroad/web/docs/server-api.md @@ -223,15 +223,15 @@ Render a single 256×256 PNG tile of the layout. **Response:** PNG image (frame type `1`), or frame type `3` with no body when the layer has nothing to draw in this tile. -**Caching:** the server caches the response under the tile, the rendered -`dpr` and `tile_px`, the design and chiplet revisions, and the parsed fields -that can change this layer's pixels. Selectability fields, keys the server -does not parse, and fields that only another layer reads (for example -`pin_markers` outside `_pins`, or `visible_layers` outside `_pins`, -`_access_points` and, while pin names are shown, `_inst_labels`) do not split -the cache. Tiles that depend on per-session state (a session's own module or -group colors, focused nets, debug renderers) are not cached; the default -color palette is. +**Caching:** the server caches the response under the tile, the rendered `dpr` +and `tile_px`, the design and chiplet revisions, and the parsed fields that can +change this layer's pixels. Selectability fields, keys the server does not +parse, and fields this layer does not read (for example `pin_markers` outside +`_pins`, the routing flags and `pattern` outside the tech layers, or +`visible_layers` outside `_pins`, `_access_points`, and, while pin names are +shown, `_inst_labels`) do not split the cache. Tiles that depend on per-session state (a session's own +module or group colors, focused nets, debug renderers) are not cached; the +default color palette is. ### `overlay_tile` diff --git a/openroad/web/esbuild.config.mjs b/openroad/web/esbuild.config.mjs index 7c64089b6c7..075124f196e 100644 --- a/openroad/web/esbuild.config.mjs +++ b/openroad/web/esbuild.config.mjs @@ -32,8 +32,8 @@ const elkBrowserBuild = { }; // loaders.gl fetches worker scripts and codec libraries from unpkg when it has -// no copy of its own. The layout view hands deck.gl decoded images and never -// loads through it, so that fallback is pointed at nothing remote. +// no copy of its own, so that fallback is pointed at nothing remote. Only a +// saved report's path overlay loads through it: a data: URL, decoded in page. const kLoadersCdn = 'https://unpkg.com/@loaders.gl'; const noLoadersCdn = { name: 'no-loaders-cdn', diff --git a/openroad/web/include/web/web.h b/openroad/web/include/web/web.h index 2ef8a5f993d..12520b295f3 100644 --- a/openroad/web/include/web/web.h +++ b/openroad/web/include/web/web.h @@ -176,7 +176,7 @@ bool tokenAllowed(const std::map& params, bool requestTokenAllowed(std::string_view target, std::string_view expected); // The redirect for a redeemed ticket: the request's raw query with `ticket` -// swapped for `token`, so viewer options like ?mergetiles=0 survive. +// swapped for `token`, so viewer options like ?preservebuffer=1 survive. std::string authRedirectTarget(std::string_view target, std::string_view token); // What presenting a launch ticket got. kReused is the right ticket after it diff --git a/openroad/web/src/deck-global.js b/openroad/web/src/deck-global.js index 5a73e078e72..988ecea8fc7 100644 --- a/openroad/web/src/deck-global.js +++ b/openroad/web/src/deck-global.js @@ -10,7 +10,9 @@ import { PathStyleExtension } from '@deck.gl/extensions'; import { BitmapLayer, PathLayer, ScatterplotLayer, SolidPolygonLayer } from '@deck.gl/layers'; +// Spread: @deck.gl/core put its version and logger on the global already. window.deck = { + ...window.deck, BitmapLayer, Deck, OrthographicView, diff --git a/openroad/web/src/display-controls.js b/openroad/web/src/display-controls.js index dba8ab8f470..eb87186a210 100644 --- a/openroad/web/src/display-controls.js +++ b/openroad/web/src/display-controls.js @@ -544,6 +544,11 @@ export function populateDisplayControls(app, visibility, selectability, // rebuild-from-scratch pattern avoids incrementally dropping a // layer name still owned by a checked sibling in multi-tech // designs. + // Route guides draw only on the layers shown, so with some on screen a + // change of names redraws the overlay. + const guides = app.routeGuideNets?.size > 0 + || (visibility.focused_nets_guides && app.focusNets?.size > 0); + const namesBefore = guides ? new Set(app.visibleLayerNames) : null; app.visibleLayerNames.clear(); const allLayerIds = []; // Two-tier chiplet propagation: stateUpdates carries every @@ -621,6 +626,11 @@ export function populateDisplayControls(app, visibility, selectability, } } } + if (namesBefore && app.overlayLayer + && (namesBefore.size !== app.visibleLayerNames.size + || [...namesBefore].some((n) => !app.visibleLayerNames.has(n)))) { + dirtySlots.add(app.overlayLayer); + } // A die leaving the visible chiplets: the chiplet mirror below redraws // every slot. if (visibilityChangedAny) { diff --git a/openroad/web/src/inspector.js b/openroad/web/src/inspector.js index 7010f35af95..e667b645092 100644 --- a/openroad/web/src/inspector.js +++ b/openroad/web/src/inspector.js @@ -637,15 +637,20 @@ export function createInspectorPanel(app, redrawAllLayers, refreshOverlay) { // selected" toggle (Misc) is on, so turning it back on shows the current // selection's outline again (redrawAllLayers -> renderSelectionOutline). let selectionBBox = null; + // The toggle gates the outline, the pulse and the animation alike. + const highlightOff = () => app.visibility?.highlight_selected === false; function renderSelectionOutline() { - const show = selectionBBox && app.designScale - && !(app.visibility && app.visibility.highlight_selected === false); + const show = selectionBBox && app.designScale && !highlightOff(); setShapes('selection', show ? [{ kind: 'rect', rect: worldRect(...selectionBBox), stroke: toRgba('#ff0'), width: 2, dash: [6, 4], }] : null, DRAW_ORDER.selection); + if (highlightOff()) { + clearPulse(); + stopSelectionAnimation(); + } } function clearSelectionOutline() { @@ -683,8 +688,7 @@ export function createInspectorPanel(app, redrawAllLayers, refreshOverlay) { // while highlighting is off doesn't leave a stale pulse behind. if (animTimer !== null) stopSelectionAnimation(); clearPulse(); - // Honor the "Highlight selected" toggle (Misc). - if (app.visibility && app.visibility.highlight_selected === false) { + if (highlightOff()) { return; } // A net's bbox spans the whole net; don't pulse a giant rectangle. @@ -725,8 +729,10 @@ export function createInspectorPanel(app, redrawAllLayers, refreshOverlay) { setShapes('anim', null); } function animateSelection(bbox, { repeats = 6, intervalMs = 300 } = {}) { - if (!bbox || !app.view || !app.designScale) return; stopSelectionAnimation(); + if (!bbox || !app.view || !app.designScale || highlightOff()) { + return; + } if (prefersReducedMotion()) { pulseHighlight(bbox); return; @@ -745,9 +751,7 @@ export function createInspectorPanel(app, redrawAllLayers, refreshOverlay) { }, intervalMs); } - // Let redrawAllLayers cancel an in-flight pulse when the "Highlight - // selected" toggle is turned off, and keep the outline in step with it. - app.clearSelectionPulse = clearPulse; + // redrawAllLayers keeps the outline, and what the toggle stops, in step. app.renderSelectionOutline = renderSelectionOutline; app.clearSelectionOutline = clearSelectionOutline; @@ -1144,6 +1148,17 @@ export function createInspectorPanel(app, redrawAllLayers, refreshOverlay) { } } + // A client-side object (ruler, label) deletes itself, saved + // reports included. + if (data.onDelete) { + const btn = document.createElement('button'); + btn.className = 'or-btn or-btn-icon or-btn-danger-hover'; + btn.title = `Delete ${data.type.toLowerCase()}`; + btn.innerHTML = DELETE_SVG; + btn.addEventListener('click', () => data.onDelete()); + toolbar.appendChild(btn); + } + app.inspectorEl.appendChild(toolbar); } diff --git a/openroad/web/src/label-manager.js b/openroad/web/src/label-manager.js index f588d0d40fb..f3111306253 100644 --- a/openroad/web/src/label-manager.js +++ b/openroad/web/src/label-manager.js @@ -276,28 +276,12 @@ export class LabelManager { else if (propName === 'Anchor') patch.anchor = newValue.trim(); this._edit(label, patch); }, + onDelete: () => this.deleteLabel(name), }; this._updateInspector(data); if (focus) { this._focusComponent('Inspector'); } - - requestAnimationFrame(() => { - const toolbar - = this._app.inspectorEl?.querySelector('.inspector-toolbar'); - if (!toolbar) return; - // Avoid stacking duplicate delete buttons across re-selections. - if (toolbar.querySelector('.delete-label-btn')) return; - const btn = document.createElement('button'); - btn.className = 'or-btn or-btn-icon delete-label-btn'; - btn.title = 'Delete label'; - btn.innerHTML = - '' - + '' - + ''; - btn.addEventListener('click', () => this.deleteLabel(name)); - toolbar.appendChild(btn); - }); } // Apply an edit atomically, keeping the same name/position. diff --git a/openroad/web/src/layout-view.js b/openroad/web/src/layout-view.js index 57c5a6ffd13..69da5b702e5 100644 --- a/openroad/web/src/layout-view.js +++ b/openroad/web/src/layout-view.js @@ -180,6 +180,18 @@ export function createLayoutView(container, opts = {}) { return { target: [vs.target[0], vs.target[1], 0], zoom: vs.zoom, minZoom: limits.minZoom, maxZoom: limits.maxZoom }; } + // An error before onLoad means the device was never created: the browser + // gave no WebGL, or a lost context could not be restored. + function deckError(error) { + console.error('Layout view:', error); + if (restoring) { + restoring = false; + events.emit('contextfailed', error); + } else if (!rendererInfo) { + rendererInfo = { gpuType: 'none', renderer: '', vendor: '' }; + events.emit('renderer', rendererInfo); + } + } function createDeck() { return new deckApi.Deck({ parent: canvasWrap, @@ -242,18 +254,7 @@ export function createLayoutView(container, opts = {}) { } scheduleRender(); }, - // An error before onLoad means the device was never created: the - // browser gave no WebGL, and nothing will be drawn. - onError: (error) => { - console.error('Layout view:', error); - if (restoring) { - restoring = false; - events.emit('contextfailed', error); - } else if (!rendererInfo) { - rendererInfo = { gpuType: 'none', renderer: '', vendor: '' }; - events.emit('renderer', rendererInfo); - } - }, + onError: deckError, onAfterRender: () => { const waiting = afterFrame; afterFrame = []; @@ -285,15 +286,19 @@ export function createLayoutView(container, opts = {}) { restoring = true; deckgl = createDeck(); } catch (err) { - restoring = false; - events.emit('contextfailed', err); + deckError(err); } scheduleRender(); }); } if (deckApi && typeof deckApi.Deck === 'function') { - deckgl = createDeck(); + try { + deckgl = createDeck(); + } catch (err) { + // Once the caller is listening. + queueMicrotask(() => deckError(err)); + } } // ─── Size ─────────────────────────────────────────────────────────── @@ -510,7 +515,8 @@ export function createLayoutView(container, opts = {}) { const to = anim.to; flightTrail = anim.flight ? anim.flight.apex : null; anim = null; - setViewState(to.target, to.zoom); + // settleView updates the tiles at rest, as animateTo's cut does. + setViewState(to.target, to.zoom, { tiles: interacting }); settleView(); return; } @@ -1072,6 +1078,10 @@ export function createLayoutView(container, opts = {}) { // a gesture still under way; a later call settles it. zoomAround(screenPt, delta, { animate, settle = true } = {}) { const zoom = clampZoom(view.getTargetZoom() + delta, limits); + // At rest on a zoom limit there is nothing to move. + if (!anim && !moving && zoom === vs.zoom) { + return; + } // An anchor holds what is under it now, as stepAnimation does. const base = screenPt ? vs : tileView(); const pt = screenPt || [vs.width / 2, vs.height / 2]; @@ -1083,12 +1093,14 @@ export function createLayoutView(container, opts = {}) { zoomIn: () => view.zoomAround(null, 1), zoomOut: () => view.zoomAround(null, -1), - panByPx(dx, dy, { animate } = {}) { + // `settle: false` (with `animate: false`) leaves a gesture's + // fractional zoom for the gesture to settle. + panByPx(dx, dy, { animate, settle = true } = {}) { const base = tileView(); const s = Math.pow(2, base.zoom); const target = [base.target[0] + dx / s, base.target[1] - dy / s]; const ms = (animate === false || !prefs.smooth()) ? 0 : ANIMATION_MS; - animateTo({ target, zoom: base.zoom }, { ms }); + animateTo({ target, zoom: base.zoom }, { ms, settle }); }, invalidateSize, @@ -1113,7 +1125,10 @@ export function createLayoutView(container, opts = {}) { setOverlay(id, shapes, { order = DRAW_ORDER.selection } = {}) { if (!shapes || shapes.length === 0) { - overlays.delete(id); + // Clearing what is not there changes nothing on screen. + if (!overlays.delete(id)) { + return; + } } else { overlays.set(id, overlaySpecs(id, shapes, order)); } @@ -1215,9 +1230,7 @@ export function createLayoutView(container, opts = {}) { if (!deckgl?.getCanvas()) { return Promise.resolve(null); } - render(); return new Promise((resolve) => { - let timer = null; let finished = false; // The timeout's redraw may itself run done() through // onAfterRender; one copy is enough. @@ -1233,12 +1246,13 @@ export function createLayoutView(container, opts = {}) { rect: canvas.getBoundingClientRect() } : null); }; - afterFrame.push(done); // A hidden page gets no frames. - timer = setTimeout(() => { + const timer = setTimeout(() => { deckgl?.redraw('capture'); done(); }, timeoutMs); + afterFrame.push(done); + render(); }); }, diff --git a/openroad/web/src/main.js b/openroad/web/src/main.js index 0377dd18847..14e7f213e6e 100644 --- a/openroad/web/src/main.js +++ b/openroad/web/src/main.js @@ -110,8 +110,8 @@ function updateStatus() { setTileProgress(pendingCount); } -// Show the tile-request line while requests are outstanding. A no-op when the -// Layout panel is closed, which is the only place the line lives. +// Show the tile-request line while requests are outstanding. A no-op until +// the Layout panel, the only place the line lives, is built. function setTileProgress(pendingCount) { const el = app.tileProgressEl; if (!el) return; @@ -513,14 +513,11 @@ function redrawAllLayers() { app.heatMapLayer.refresh(); } // The client-side selection outline follows the "Highlight selected" - // toggle; the server-side highlight is gated by the overlay refresh below. - // An in-flight selection pulse is cancelled on off. + // toggle, and turning it off stops a pulse or animation in flight; the + // server-side highlight is gated by the overlay refresh below. if (app.renderSelectionOutline) { app.renderSelectionOutline(); } - if (!visibility.highlight_selected && app.clearSelectionPulse) { - app.clearSelectionPulse(); - } // Overlay layer must also refresh on structural changes (e.g. design // reload changes the coordinate space). refreshOverlay(); @@ -613,26 +610,12 @@ function createLayoutViewer(container) { // Tile requests in flight, as a line along the top of the canvas. Held on // app because updateStatus runs from the socket callbacks, which know - // nothing about this panel -- and the panel can be closed, so every write - // to it goes through setTileProgress below. + // nothing about this panel. const progress = document.createElement('div'); progress.className = 'or-progress'; mapDiv.appendChild(progress); app.tileProgressEl = progress; - // Closing the panel discards this DOM, so drop the references to it. Both - // readers null-check (setTileProgress here, updateHeatMapLegend in - // display-controls.js), and createLayoutViewer sets them again if the panel - // is reopened. - // - // app.view is deliberately left alone: many call sites reach it unguarded - // (the View menu's zoom items, the inspector's zoom-to, the rulers), and a - // detached view is harmless while the panel is closed. - container.on('destroy', () => { - app.tileProgressEl = null; - app.heatMapLegendEl = null; - }); - app.view = createLayoutView(mapDiv, { preserveDrawingBuffer: app.preserveBuffer, prefs: { @@ -1497,6 +1480,15 @@ async function resyncBounds(inlineBounds, inlineFitBounds, window.location.reload(); return true; } + // A page that booted with no design has no layer tree to redraw into; + // it reloads once there are bounds to place one on. + if (app.booted && !app.designScale) { + if (!computeBoundsTransforms(designBounds, tileSizeCss(), fitRect)) { + return false; + } + reloadKeepingConsole(); + return true; + } // Keep the DBU point at the center of the view where it is. const hadDesign = !!app.designScale; @@ -2021,7 +2013,8 @@ document.addEventListener('keydown', (e) => { if (app.labelManager) app.labelManager.toggleLabelMode(); } else if (key === 'f' && !e.ctrlKey && !e.metaKey && app.fitRect) { app.view.fitWorldRect(app.fitRect); - } else if (key === 'z' && !e.ctrlKey && app.view) { + } else if (key === 'z' && !e.ctrlKey && !e.metaKey && !e.altKey + && app.view) { // Around the pointer when it is over the layout, else the center. const delta = e.shiftKey ? -1 : 1; app.view.zoomAround(app.lastMouseWorld diff --git a/openroad/web/src/ruler.js b/openroad/web/src/ruler.js index e0fee6c7ad5..13fd9178c76 100644 --- a/openroad/web/src/ruler.js +++ b/openroad/web/src/ruler.js @@ -547,30 +547,13 @@ export class RulerManager { this._renderAll(); this.refreshInspector(); }, + onDelete: () => this.deleteRuler(rulerId), }; this._updateInspector(data); if (focus) { this._focusComponent('Inspector'); } - - // Add delete button after inspector renders - requestAnimationFrame(() => { - const toolbar = this._app.inspectorEl?.querySelector('.inspector-toolbar'); - if (!toolbar) return; - - const deleteBtn = document.createElement('button'); - deleteBtn.className = 'or-btn or-btn-icon'; - deleteBtn.title = 'Delete ruler'; - deleteBtn.innerHTML = - '' + - '' + - ''; - deleteBtn.addEventListener('click', () => { - this.deleteRuler(rulerId); - }); - toolbar.appendChild(deleteBtn); - }); } deleteRuler(rulerId) { diff --git a/openroad/web/src/tile-grid.js b/openroad/web/src/tile-grid.js index 4ae0d4b1e6c..3533ecd7e05 100644 --- a/openroad/web/src/tile-grid.js +++ b/openroad/web/src/tile-grid.js @@ -61,7 +61,8 @@ export class TileGrid { continue; } if (inRange(ring, tile.x, tile.y)) { - if (tile.loading && tile.background + // A stale load is replaced below, not promoted. + if (tile.loading && tile.background && !this._stale(tile) && inRange(range, tile.x, tile.y)) { tile.background = false; tile.handle?.promote?.(); @@ -110,7 +111,6 @@ export class TileGrid { continue; } if (inRange(r, tile.x, tile.y)) { - tile.handle?.cancel?.(); this._load(tile, e ? e.background !== false : !inRange(this.range, tile.x, tile.y)); } else if (tile.loading) { @@ -207,6 +207,7 @@ export class TileGrid { } _load(tile, background) { + this._cancelLoad(tile); const generation = this._generation; const current = () => this.tiles.get(tile.key) === tile && tile.generation === generation; @@ -260,19 +261,25 @@ export class TileGrid { tile.drawable = drawable || null; } + // From before a refresh, loading or not: a load still in flight asked for + // what the refresh replaced. _stale(tile) { - return !tile.loading && tile.generation !== this._generation; + return tile.generation !== this._generation; } _inKeepBuffer(tile, r = this.range) { return inRange(growRange(r, this.keepBuffer), tile.x, tile.y); } - _drop(tile) { + _cancelLoad(tile) { if (tile.loading) { this._cancels++; tile.handle?.cancel?.(); } + } + + _drop(tile) { + this._cancelLoad(tile); if (tile.drawable) { this.source.release?.(tile.drawable); } diff --git a/openroad/web/src/tile_generator.cpp b/openroad/web/src/tile_generator.cpp index 139d27084f0..73d0ad2f71d 100644 --- a/openroad/web/src/tile_generator.cpp +++ b/openroad/web/src/tile_generator.cpp @@ -1065,87 +1065,138 @@ inline int hairlineCss(const TileFrame& frame) return std::max(1, static_cast(std::lround(frame.px_per_css))); } +// The tiles a flag can change: the tech layers and each pseudo layer. +enum TileBit : uint32_t +{ + kTechTiles = 1U << 0, + kInstancesTile = 1U << 1, + kPinsTile = 1U << 2, + kInstLabelsTile = 1U << 3, + kAccessPointsTile = 1U << 4, + kRegionsTile = 1U << 5, + kMfgGridTile = 1U << 6, + kGcellGridTile = 1U << 7, + kRudyTile = 1U << 8, + kCongestionTile = 1U << 9, + kModulesTile = 1U << 10, + kClustersTile = 1U << 11, +}; +constexpr uint32_t kAllTiles = ~0U; +// What isInstVisible and isNetVisible are read by. +constexpr uint32_t kInstTiles = kTechTiles | kInstancesTile | kInstLabelsTile + | kModulesTile | kClustersTile; +constexpr uint32_t kNetTiles = kTechTiles | kPinsTile | kAccessPointsTile; +constexpr uint32_t kBTermTiles = kTechTiles | kPinsTile; +constexpr uint32_t kITermTiles + = kTechTiles | kInstLabelsTile | kAccessPointsTile; + +// The bit of a tile's layer. A pseudo layer missing here gets every bit, so +// every flag counts for it. +uint32_t tileBitOf(const std::string_view layer) +{ + if (!layer.starts_with('_')) { + return kTechTiles; + } + static const std::map kPseudoLayers = { + {"_instances", kInstancesTile}, + {"_pins", kPinsTile}, + {kInstLabelsLayer, kInstLabelsTile}, + {"_access_points", kAccessPointsTile}, + {"_regions", kRegionsTile}, + {"_mfg_grid", kMfgGridTile}, + {"_gcell_grid", kGcellGridTile}, + {"_rudy", kRudyTile}, + {"_routing_congestion", kCongestionTile}, + {"_modules", kModulesTile}, + {"_clusters", kClustersTile}, + }; + if (const auto it = kPseudoLayers.find(layer); it != kPseudoLayers.end()) { + return it->second; + } + return kAllTiles; +} + struct BoolField { const char* key; bool TileVisibility::* field; bool default_val; - // The one layer whose tiles the flag can change: null for every layer, "" - // for none. - const char* owner = nullptr; + // The tiles whose pixels the flag can change. + uint32_t tiles = kAllTiles; }; -// Every visibility flag a tile render reads, with its default and owner. +// Every visibility flag a tile render reads, with its default and the tiles it +// can change. // Parsing and the tile-cache key walk the same list. // clang-format off // NOLINTBEGIN(modernize-use-designated-initializers) const BoolField kVisibilityFields[] = { - {"stdcells", &TileVisibility::stdcells, true}, - {"macros", &TileVisibility::macros, true}, - {"pad_input", &TileVisibility::pad_input, true}, - {"pad_output", &TileVisibility::pad_output, true}, - {"pad_inout", &TileVisibility::pad_inout, true}, - {"pad_power", &TileVisibility::pad_power, true}, - {"pad_spacer", &TileVisibility::pad_spacer, true}, - {"pad_areaio", &TileVisibility::pad_areaio, true}, - {"pad_other", &TileVisibility::pad_other, true}, - {"phys_fill", &TileVisibility::phys_fill, true}, - {"phys_endcap", &TileVisibility::phys_endcap, true}, - {"phys_welltap", &TileVisibility::phys_welltap, true}, - {"phys_tie", &TileVisibility::phys_tie, true}, - {"phys_antenna", &TileVisibility::phys_antenna, true}, - {"phys_cover", &TileVisibility::phys_cover, true}, - {"phys_bump", &TileVisibility::phys_bump, true}, - {"phys_other", &TileVisibility::phys_other, true}, - {"std_bufinv", &TileVisibility::std_bufinv, true}, - {"std_bufinv_timing", &TileVisibility::std_bufinv_timing, true}, - {"std_clock_bufinv", &TileVisibility::std_clock_bufinv, true}, - {"std_clock_gate", &TileVisibility::std_clock_gate, true}, - {"std_level_shift", &TileVisibility::std_level_shift, true}, - {"std_sequential", &TileVisibility::std_sequential, true}, - {"std_combinational", &TileVisibility::std_combinational, true}, - {"std_physical", &TileVisibility::std_physical, true}, - {"std_other", &TileVisibility::std_other, true}, - {"net_signal", &TileVisibility::net_signal, true}, - {"net_power", &TileVisibility::net_power, true}, - {"net_ground", &TileVisibility::net_ground, true}, - {"net_clock", &TileVisibility::net_clock, true}, - {"net_reset", &TileVisibility::net_reset, true}, - {"net_tieoff", &TileVisibility::net_tieoff, true}, - {"net_scan", &TileVisibility::net_scan, true}, - {"net_analog", &TileVisibility::net_analog, true}, - {"routing", &TileVisibility::routing, true}, - {"routing_segments", &TileVisibility::routing_segments, true}, - {"routing_vias", &TileVisibility::routing_vias, true}, - {"special_nets", &TileVisibility::special_nets, true}, - {"srouting_segments", &TileVisibility::srouting_segments, true}, - {"srouting_vias", &TileVisibility::srouting_vias, true}, - {"labels", &TileVisibility::labels, true, ""}, // overlay tile - {"pins", &TileVisibility::pins, true}, - {"pin_markers", &TileVisibility::pin_markers, true, "_pins"}, - {"pin_names", &TileVisibility::pin_names, true, "_pins"}, - {"access_points", &TileVisibility::access_points, false, "_access_points"}, - {"regions", &TileVisibility::regions, true, "_regions"}, - {"mfg_grid", &TileVisibility::mfg_grid, false, "_mfg_grid"}, - {"gcell_grid", &TileVisibility::gcell_grid, false, "_gcell_grid"}, - {"rudy", &TileVisibility::rudy, false, "_rudy"}, - {"routing_congestion", &TileVisibility::routing_congestion, false, "_routing_congestion"}, - {"inst_names", &TileVisibility::inst_names, true, kInstLabelsLayer}, - {"inst_pins", &TileVisibility::inst_pins, true}, // cell pins on tech layers too - {"inst_pin_names", &TileVisibility::inst_pin_names, false, kInstLabelsLayer}, - {"blockages", &TileVisibility::blockages, true}, - {"placement_blockages", &TileVisibility::placement_blockages, true, "_instances"}, - {"routing_obstructions", &TileVisibility::routing_obstructions, true}, - {"fills", &TileVisibility::fills, false}, - {"rows", &TileVisibility::rows, false, "_instances"}, - {"tracks_pref", &TileVisibility::tracks_pref, false}, - {"tracks_non_pref", &TileVisibility::tracks_non_pref, false}, - {"detailed", &TileVisibility::detailed, false}, - {"module_view", &TileVisibility::module_view, false, "_modules"}, - {"cluster_view", &TileVisibility::cluster_view, false, "_clusters"}, - {"debug", &TileVisibility::debug, false}, - {"debug_renderers", &TileVisibility::debug_renderers, false}, - {"debug_live", &TileVisibility::debug_live, false}, + {"stdcells", &TileVisibility::stdcells, true, kInstTiles}, + {"macros", &TileVisibility::macros, true, kInstTiles}, + {"pad_input", &TileVisibility::pad_input, true, kInstTiles}, + {"pad_output", &TileVisibility::pad_output, true, kInstTiles}, + {"pad_inout", &TileVisibility::pad_inout, true, kInstTiles}, + {"pad_power", &TileVisibility::pad_power, true, kInstTiles}, + {"pad_spacer", &TileVisibility::pad_spacer, true, kInstTiles}, + {"pad_areaio", &TileVisibility::pad_areaio, true, kInstTiles}, + {"pad_other", &TileVisibility::pad_other, true, kInstTiles}, + {"phys_fill", &TileVisibility::phys_fill, true, kInstTiles}, + {"phys_endcap", &TileVisibility::phys_endcap, true, kInstTiles}, + {"phys_welltap", &TileVisibility::phys_welltap, true, kInstTiles}, + {"phys_tie", &TileVisibility::phys_tie, true, kInstTiles}, + {"phys_antenna", &TileVisibility::phys_antenna, true, kInstTiles}, + {"phys_cover", &TileVisibility::phys_cover, true, kInstTiles}, + {"phys_bump", &TileVisibility::phys_bump, true, kInstTiles}, + {"phys_other", &TileVisibility::phys_other, true, kInstTiles}, + {"std_bufinv", &TileVisibility::std_bufinv, true, kInstTiles}, + {"std_bufinv_timing", &TileVisibility::std_bufinv_timing, true, kInstTiles}, + {"std_clock_bufinv", &TileVisibility::std_clock_bufinv, true, kInstTiles}, + {"std_clock_gate", &TileVisibility::std_clock_gate, true, kInstTiles}, + {"std_level_shift", &TileVisibility::std_level_shift, true, kInstTiles}, + {"std_sequential", &TileVisibility::std_sequential, true, kInstTiles}, + {"std_combinational", &TileVisibility::std_combinational, true, kInstTiles}, + {"std_physical", &TileVisibility::std_physical, true, kInstTiles}, + {"std_other", &TileVisibility::std_other, true, kInstTiles}, + {"net_signal", &TileVisibility::net_signal, true, kNetTiles}, + {"net_power", &TileVisibility::net_power, true, kNetTiles}, + {"net_ground", &TileVisibility::net_ground, true, kNetTiles}, + {"net_clock", &TileVisibility::net_clock, true, kNetTiles}, + {"net_reset", &TileVisibility::net_reset, true, kNetTiles}, + {"net_tieoff", &TileVisibility::net_tieoff, true, kNetTiles}, + {"net_scan", &TileVisibility::net_scan, true, kNetTiles}, + {"net_analog", &TileVisibility::net_analog, true, kNetTiles}, + {"routing", &TileVisibility::routing, true, kTechTiles}, + {"routing_segments", &TileVisibility::routing_segments, true, kTechTiles}, + {"routing_vias", &TileVisibility::routing_vias, true, kTechTiles}, + {"special_nets", &TileVisibility::special_nets, true, kTechTiles}, + {"srouting_segments", &TileVisibility::srouting_segments, true, kTechTiles}, + {"srouting_vias", &TileVisibility::srouting_vias, true, kTechTiles}, + {"labels", &TileVisibility::labels, true, 0}, // overlay tile + {"pins", &TileVisibility::pins, true, kBTermTiles}, + {"pin_markers", &TileVisibility::pin_markers, true, kPinsTile}, + {"pin_names", &TileVisibility::pin_names, true, kPinsTile}, + {"access_points", &TileVisibility::access_points, false, kAccessPointsTile}, + {"regions", &TileVisibility::regions, true, kRegionsTile}, + {"mfg_grid", &TileVisibility::mfg_grid, false, kMfgGridTile}, + {"gcell_grid", &TileVisibility::gcell_grid, false, kGcellGridTile}, + {"rudy", &TileVisibility::rudy, false, kRudyTile}, + {"routing_congestion", &TileVisibility::routing_congestion, false, kCongestionTile}, + {"inst_names", &TileVisibility::inst_names, true, kInstLabelsTile}, + {"inst_pins", &TileVisibility::inst_pins, true, kITermTiles}, + {"inst_pin_names", &TileVisibility::inst_pin_names, false, kInstLabelsTile}, + {"blockages", &TileVisibility::blockages, true, kTechTiles}, + {"placement_blockages", &TileVisibility::placement_blockages, true, kInstancesTile}, + {"routing_obstructions",&TileVisibility::routing_obstructions, true, kTechTiles}, + {"fills", &TileVisibility::fills, false, kTechTiles}, + {"rows", &TileVisibility::rows, false, kInstancesTile}, + {"tracks_pref", &TileVisibility::tracks_pref, false, kTechTiles}, + {"tracks_non_pref", &TileVisibility::tracks_non_pref, false, kTechTiles}, + {"detailed", &TileVisibility::detailed, false}, + {"module_view", &TileVisibility::module_view, false, kModulesTile}, + {"cluster_view", &TileVisibility::cluster_view, false, kClustersTile}, + {"debug", &TileVisibility::debug, false}, + {"debug_renderers", &TileVisibility::debug_renderers, false}, + {"debug_live", &TileVisibility::debug_live, false}, }; // NOLINTEND(modernize-use-designated-initializers) // clang-format on @@ -1276,13 +1327,18 @@ void TileVisibility::assignFromJson(const boost::json::object& json) return; } --budget; - std::set& layers = out[std::string(path)]; + // Made on the first name: an empty list hides nothing, as no + // entry does. + std::set* layers = nullptr; for (const auto& name : names.as_array()) { if (budget == 0) { return; } --budget; - layers.emplace(name.as_string()); + if (!layers) { + layers = &out[std::string(path)]; + } + layers->emplace(name.as_string()); } } }; @@ -1887,7 +1943,7 @@ void TileGenerator::onDesignChanged() bool TileGenerator::tileCacheGet(const std::string& key, std::vector& out) const { - std::lock_guard lock(tile_cache_mutex_); + std::scoped_lock lock(tile_cache_mutex_); const auto it = tile_cache_index_.find(key); if (it == tile_cache_index_.end()) { return false; @@ -1912,7 +1968,7 @@ void TileGenerator::tileCachePut(std::string key, if (png.size() > kTileCacheBytesCap) { return; } - std::lock_guard lock(tile_cache_mutex_); + std::scoped_lock lock(tile_cache_mutex_); if (epoch != tile_cache_epoch_) { return; } @@ -1948,7 +2004,7 @@ void TileGenerator::clearTileCache() size_t TileGenerator::tileCacheSize() const { - std::lock_guard lock(tile_cache_mutex_); + std::scoped_lock lock(tile_cache_mutex_); return tile_cache_lru_.size(); } @@ -1962,10 +2018,11 @@ size_t TileGenerator::tileCacheBytes() const std::string TileGenerator::tileCacheKey(const TileVisibility& vis, const std::string_view layer) { + const uint32_t tile = tileBitOf(layer); std::string flags; flags.reserve(std::size(kVisibilityFields)); for (const BoolField& f : kVisibilityFields) { - if (f.owner != nullptr && layer != f.owner) { + if ((f.tiles & tile) == 0) { flags += '-'; } else { flags += vis.*f.field ? '1' : '0'; @@ -1974,7 +2031,10 @@ std::string TileGenerator::tileCacheKey(const TileVisibility& vis, boost::json::object key; key["v"] = flags; - key["p"] = static_cast(vis.fill_pattern); + // Only the tech layers fill shapes with the layer's pattern. + if ((tile & kTechTiles) != 0) { + key["p"] = static_cast(vis.fill_pattern); + } // A tile scoped to a die depends on that die being shown, not the others. if (!vis.chiplet.empty()) { key["d"] = vis.chiplet; diff --git a/openroad/web/src/ui-utils.js b/openroad/web/src/ui-utils.js index 50619283e57..57d89d5ff2c 100644 --- a/openroad/web/src/ui-utils.js +++ b/openroad/web/src/ui-utils.js @@ -13,11 +13,8 @@ export function isStaticMode(app) { } // Visibility keys that drive other keys here and never reach the wire, marked -// by name the way selectability keys are marked with `s_`. A list of them -// would be a fourth place to remember a new one, and forgetting is silent: -// the tile cache is keyed on the request JSON minus the flags the server -// recognizes (request_handler.cpp), so a key it has never heard of survives -// that subtraction and turns its own toggle into a full-screen cache miss. +// by name the way selectability keys are marked with `s_`, so a new one needs +// no list of its own. const CLIENT_ONLY_PREFIX = 'ui_'; // The one message both hierarchy views show when their overlay is switched diff --git a/openroad/web/src/view-input.js b/openroad/web/src/view-input.js index a7be684dc55..dbe20d1bd1f 100644 --- a/openroad/web/src/view-input.js +++ b/openroad/web/src/view-input.js @@ -103,7 +103,7 @@ export function installViewInput(view, opts = {}) { // The view holds deferred tile updates while a gesture streams in. let holding = false; - let panTimer; + let panTimer = null; function hold(on) { if (holding !== on) { holding = on; @@ -117,7 +117,8 @@ export function installViewInput(view, opts = {}) { function zoomGesture(pt, levels) { hold(true); if (!gesture) { - gesture = { z0: view.getZoom() }; + // Where an animation under way is heading, as zoomAround counts. + gesture = { z0: view.getTargetZoom() }; } gesture.pt = pt; clearTimeout(gesture.timer); @@ -133,8 +134,10 @@ export function installViewInput(view, opts = {}) { clearTimeout(g.timer); const z = view.getZoom(); view.zoomAround(g.pt, g.z0 + gestureSteps(z - g.z0) - z); - clearTimeout(panTimer); - hold(false); + // A scroll still under way keeps the view held until it pauses. + if (panTimer === null) { + hold(false); + } } listeners.push(() => { clearTimeout(gesture?.timer); @@ -148,22 +151,29 @@ export function installViewInput(view, opts = {}) { // A pinch always zooms. on(container, 'wheel', (e) => { e.preventDefault(); - if (isStatic()) { + if (isStatic() || (e.deltaX === 0 && e.deltaY === 0)) { return; } const notch = isWheelNotch(e); - if (!notch && e.ctrlKey) { + if (!notch && e.ctrlKey && e.deltaY !== 0) { // Chrome and Firefox send a pinch as ctrl+wheel with // deltaY = -100 ln(scale). zoomGesture(local(e), -e.deltaY / (100 * Math.LN2)); return; } - if (wheelZoom() === e.ctrlKey) { + // A sideways scroll pans, Ctrl or not, whatever the wheel does. A + // zoom gesture under way keeps going and settles once the fingers stop. + if (wheelZoom() === e.ctrlKey || e.deltaY === 0) { const [dx, dy] = wheelDeltaPx(e, () => container.clientHeight); hold(true); clearTimeout(panTimer); - panTimer = setTimeout(() => !gesture && hold(false), gestureIdleMs); - view.panByPx(dx, dy, { animate: false }); + panTimer = setTimeout(() => { + panTimer = null; + if (!gesture) { + hold(false); + } + }, gestureIdleMs); + view.panByPx(dx, dy, { animate: false, settle: !gesture }); return; } if (!notch) { @@ -199,11 +209,21 @@ export function installViewInput(view, opts = {}) { let press = null; let box = null; on(container, 'pointerdown', (e) => { + // A second finger makes it no click, wherever it lands. + if (e.isPrimary === false) { + if (press) { + press.moved = true; + } + return; + } if (e.button !== 0 || !onView(e)) { return; } + // A new first finger replaces a press whose release was lost, bands + // and all. + endDrags(); container.focus({ preventScroll: true }); - press = { x: e.clientX, y: e.clientY, moved: false, + press = { id: e.pointerId, x: e.clientX, y: e.clientY, moved: false, box: e.shiftKey && !isStatic() }; if (press.box) { e.stopPropagation(); // keep the renderer from panning @@ -211,7 +231,7 @@ export function installViewInput(view, opts = {}) { }, { capture: true }); on(window, 'pointermove', (e) => { - if (!press) { + if (!press || e.pointerId !== press.id) { return; } const dx = e.clientX - press.x; @@ -229,7 +249,7 @@ export function installViewInput(view, opts = {}) { }); on(window, 'pointerup', (e) => { - if (!press || e.button !== 0) { + if (!press || e.button !== 0 || e.pointerId !== press.id) { return; } const p = press; @@ -268,6 +288,9 @@ export function installViewInput(view, opts = {}) { return; } e.stopPropagation(); + // A new press replaces a band whose release was lost. + bandEl?.remove(); + bandEl = null; band = { x: e.clientX, y: e.clientY }; }, { capture: true }); on(window, 'pointermove', (e) => { diff --git a/openroad/web/test/browser_smoke_test.py b/openroad/web/test/browser_smoke_test.py index bd38881ff02..0302c0e9fee 100644 --- a/openroad/web/test/browser_smoke_test.py +++ b/openroad/web/test/browser_smoke_test.py @@ -12,6 +12,7 @@ # # usage: browser_smoke_test.py OPENROAD LIBERTY LEF DEF +import fcntl import json import os import pathlib @@ -25,6 +26,8 @@ import unittest _OPENROAD, _LIBERTY, _LEF, _DEF = (None,) * 4 +# Headless: nothing of the desktop session reaches Chrome. +_DESKTOP_VARS = ("DISPLAY", "WAYLAND_DISPLAY", "DBUS_SESSION_BUS_ADDRESS") # Pixels of the layout that differ from the view's background, once its tiles # have settled, and the tiles each slot holds. @@ -76,8 +79,14 @@ def __init__(self, profile): self._from_chrome, from_chrome_w = os.pipe() def pipes(): - os.dup2(to_chrome_r, 3) - os.dup2(from_chrome_w, 4) + # Above 4 first: dup2 onto its own number keeps O_CLOEXEC, and one + # end may already sit on 3 or 4. + ends = [ + fcntl.fcntl(fd, fcntl.F_DUPFD, 5) for fd in (to_chrome_r, from_chrome_w) + ] + for target, fd in zip((3, 4), ends): + os.dup2(fd, target) + os.close(fd) flags = [ "--headless=new", @@ -96,13 +105,15 @@ def pipes(): ] if os.geteuid() == 0: flags.append("--no-sandbox") + env = {k: v for k, v in os.environ.items() if k not in _DESKTOP_VARS} + env["HOME"] = profile self._proc = subprocess.Popen( [_chrome(), *flags, "about:blank"], preexec_fn=pipes, close_fds=False, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, - env={**os.environ, "HOME": profile}, + env=env, ) os.close(to_chrome_r) os.close(from_chrome_w) @@ -115,8 +126,17 @@ def pipes(): )["sessionId"] def close(self): - self._proc.kill() - self._proc.wait() + # A clean exit takes the child processes and Chrome's own temp files + # with it; a killed Chrome leaves both behind. + try: + self.send("Browser.close", timeout=10) + except (OSError, RuntimeError, TimeoutError): + pass + try: + self._proc.wait(timeout=10) + except subprocess.TimeoutExpired: + self._proc.kill() + self._proc.wait() os.close(self._to_chrome) os.close(self._from_chrome) @@ -182,6 +202,7 @@ def _free_port(): class LayoutViewDraws(unittest.TestCase): def setUp(self): self.tmp = pathlib.Path(tempfile.mkdtemp(dir=os.environ.get("TEST_TMPDIR"))) + self.addCleanup(shutil.rmtree, self.tmp, ignore_errors=True) self.browser = _Browser(str(self.tmp / "profile")) self.addCleanup(self.browser.close) self.browser.page("Runtime.enable") @@ -218,6 +239,7 @@ def test_live_viewer(self): stdout=out, stderr=subprocess.STDOUT, ) + self.addCleanup(server.stdin.close) self.addCleanup(server.wait) self.addCleanup(server.kill) deadline = time.monotonic() + 120 diff --git a/openroad/web/test/cpp/TestRequestHandler.cpp b/openroad/web/test/cpp/TestRequestHandler.cpp index a985502c4bd..4b3523cc43f 100644 --- a/openroad/web/test/cpp/TestRequestHandler.cpp +++ b/openroad/web/test/cpp/TestRequestHandler.cpp @@ -733,17 +733,8 @@ static uint32_t pngWidth(const std::vector& png) | static_cast(png[19]); } -// The device pixel ratio comes from the client — only the browser can know the -// display's ratio — and the server honours it rather than snapping it to a -// fixed ladder. A snapped ratio renders a tile of the wrong size that the -// browser then rescales, which is the moiré beat the tile pipeline exists to -// avoid, and 1.75 and 2.5 are ordinary Windows scale factors. -// -// The client mirrors this in quantizeDpr() in tile-request.js and sizes its -// merged canvas from its own copy, so a divergence here resamples every tile. // The viewer's options are query parameters, so the asset lookup must never -// see them. Without this the whole page 404s with "Resource not found." the -// moment any option is used -- which is how ?mergetiles=0 shipped unusable. +// see them; without this the page 404s with "Resource not found.". TEST(AssetPathFromTarget, StripsTheQueryString) { EXPECT_EQ(assetPathFromTarget("/?mergetiles=0"), "/index.html"); @@ -1658,6 +1649,8 @@ TEST(UrlDecode, ASignIsNotAHexDigit) EXPECT_EQ(urlDecode("%-1x"), "%-1x"); } +// The server keeps the client's dpr rather than snapping it to a ladder the +// browser would rescale; quantizeDpr() in tile-request.js mirrors the rounding. TEST_F(TileHandlerTest, HonoursTheClientReportedDpr) { struct Case diff --git a/openroad/web/test/cpp/TestTileGenerator.cpp b/openroad/web/test/cpp/TestTileGenerator.cpp index 1897f8ea986..b5f40b1902a 100644 --- a/openroad/web/test/cpp/TestTileGenerator.cpp +++ b/openroad/web/test/cpp/TestTileGenerator.cpp @@ -3007,15 +3007,16 @@ TEST_F(TileGeneratorTest, TileVisibilityParsesChipletScopeAndExceptions) EXPECT_TRUE(vis.isLayerShown("metal3")); vis.hidden_here = nullptr; - // The entry cap counts paths too, not only the names under them. + // The entry cap counts paths too, and running out on a name leaves no empty + // entry for its path. std::string many = R"({"chiplet_hidden_layers":{)"; - for (int i = 0; i < 20000; ++i) { - many += (i ? ",\"p" : "\"p") + std::to_string(i) + "\":[]"; + for (int i = 0; i < 9999; ++i) { + many += "\"p" + std::to_string(i) + "\":[],"; } - many += "}}"; + many += R"("last":["metal1"]}})"; TileVisibility capped; capped.parseFromJson(parseObj(many)); - EXPECT_LE(capped.chiplet_hidden_layers.size(), 10000u); + EXPECT_TRUE(capped.chiplet_hidden_layers.empty()); // A request without the fields leaves nothing behind from the last one. vis.parseFromJson(parseObj("{}")); @@ -8303,46 +8304,114 @@ bool keyCounts(const std::string& on, != TileGenerator::tileCacheKey(visWith(off), layer); } -// The flags only one layer draws, with that layer. -const std::pair kOwnedFlags[] - = {{"access_points", "_access_points"}, - {"regions", "_regions"}, - {"mfg_grid", "_mfg_grid"}, - {"gcell_grid", "_gcell_grid"}, - {"rudy", "_rudy"}, - {"routing_congestion", "_routing_congestion"}, - {"module_view", "_modules"}, - {"cluster_view", "_clusters"}, - {"inst_names", "_inst_labels"}, - {"inst_pin_names", "_inst_labels"}, - {"pin_markers", "_pins"}, - {"pin_names", "_pins"}, - {"rows", "_instances"}, - {"placement_blockages", "_instances"}}; - -// Pins the exclusions in TileGenerator::tileCacheKey: every other flag, a new -// one included, must count for a tech layer. -TEST(TileCacheKeyTest, EveryFlagCountsForATechLayerButTheExcludedOnes) -{ - std::set excluded = {"labels"}; - for (const auto& [flag, layer] : kOwnedFlags) { - excluded.insert(flag); +// One layer per kind of tile: metal1 for the tech layers, then each pseudo +// layer. +const std::string_view kTileLayers[] = {"metal1", + "_instances", + "_pins", + "_inst_labels", + "_access_points", + "_regions", + "_mfg_grid", + "_gcell_grid", + "_rudy", + "_routing_congestion", + "_modules", + "_clusters"}; + +// The tiles each flag can change, for the flags that leave some tile alone. +// Any other flag, a new one included, counts for every tile. +std::map> flagTiles() +{ + const std::set insts + = {"metal1", "_instances", "_inst_labels", "_modules", "_clusters"}; + const std::set nets = {"metal1", "_pins", "_access_points"}; + std::map> tiles + = {{"labels", {}}, + {"pins", {"metal1", "_pins"}}, + {"pin_markers", {"_pins"}}, + {"pin_names", {"_pins"}}, + {"access_points", {"_access_points"}}, + {"regions", {"_regions"}}, + {"mfg_grid", {"_mfg_grid"}}, + {"gcell_grid", {"_gcell_grid"}}, + {"rudy", {"_rudy"}}, + {"routing_congestion", {"_routing_congestion"}}, + {"inst_names", {"_inst_labels"}}, + {"inst_pins", {"metal1", "_inst_labels", "_access_points"}}, + {"inst_pin_names", {"_inst_labels"}}, + {"placement_blockages", {"_instances"}}, + {"rows", {"_instances"}}, + {"module_view", {"_modules"}}, + {"cluster_view", {"_clusters"}}}; + for (const std::string_view flag : + {"stdcells", "macros", "pad_input", + "pad_output", "pad_inout", "pad_power", + "pad_spacer", "pad_areaio", "pad_other", + "phys_fill", "phys_endcap", "phys_welltap", + "phys_tie", "phys_antenna", "phys_cover", + "phys_bump", "phys_other", "std_bufinv", + "std_bufinv_timing", "std_clock_bufinv", "std_clock_gate", + "std_level_shift", "std_sequential", "std_combinational", + "std_physical", "std_other"}) { + tiles[flag] = insts; + } + for (const std::string_view flag : {"net_signal", + "net_power", + "net_ground", + "net_clock", + "net_reset", + "net_tieoff", + "net_scan", + "net_analog"}) { + tiles[flag] = nets; + } + for (const std::string_view flag : {"routing", + "routing_segments", + "routing_vias", + "special_nets", + "srouting_segments", + "srouting_vias", + "blockages", + "routing_obstructions", + "fills", + "tracks_pref", + "tracks_non_pref"}) { + tiles[flag] = {"metal1"}; + } + return tiles; +} + +// Pins TileGenerator::tileCacheKey to the tiles that read each flag. +TEST(TileCacheKeyTest, EachFlagCountsForTheTilesThatReadIt) +{ + const auto tiles = flagTiles(); + for (const std::string_view flag : TileVisibility::flagKeys()) { + const auto it = tiles.find(flag); + for (const std::string_view layer : kTileLayers) { + EXPECT_EQ(keyCounts(flagJson(flag, true), flagJson(flag, false), layer), + it == tiles.end() || it->second.contains(layer)) + << flag << " on " << layer; + } } +} + +TEST(TileCacheKeyTest, APseudoLayerTheKeyDoesNotKnowCountsEveryFlag) +{ for (const std::string_view flag : TileVisibility::flagKeys()) { - EXPECT_EQ(keyCounts(flagJson(flag, true), flagJson(flag, false), "metal1"), - !excluded.contains(flag)) + EXPECT_EQ(keyCounts(flagJson(flag, true), flagJson(flag, false), "_new"), + flag != "labels") << flag; } } -TEST(TileCacheKeyTest, ExcludedFlagsCountForTheirOwnLayer) +TEST(TileCacheKeyTest, AnEmptyPerDieListIsNoList) { - for (const auto& [flag, layer] : kOwnedFlags) { - EXPECT_TRUE(keyCounts(flagJson(flag, true), flagJson(flag, false), layer)) - << flag << " on " << layer; - } - EXPECT_FALSE(keyCounts( - flagJson("regions", true), flagJson("regions", false), "_pins")); + const std::string pins = R"("visible_layers":["metal1"])"; + EXPECT_FALSE( + keyCounts("{" + pins + R"(,"chiplet_hidden_layers":{"top/die0":[]}})", + "{" + pins + "}", + "_pins")); } TEST(TileCacheKeyTest, VisibleLayersCountOnlyForPinsAndLayerOverlays) @@ -8368,7 +8437,12 @@ TEST(TileCacheKeyTest, VisibleLayersCountOnlyForPinsAndLayerOverlays) TEST(TileCacheKeyTest, PatternChipletsAndSitesCount) { - EXPECT_TRUE(keyCounts(R"({"pattern":1})", R"({"pattern":3})", "metal1")); + // The pattern, only on the tech layers. + for (const std::string_view layer : kTileLayers) { + EXPECT_EQ(keyCounts(R"({"pattern":1})", R"({"pattern":3})", layer), + layer == "metal1") + << layer; + } EXPECT_TRUE(keyCounts(R"({"visible_chiplets":["a"]})", R"({"visible_chiplets":["b"]})", "metal1")); @@ -8398,6 +8472,9 @@ TEST_F(TileGeneratorTest, FieldsLeftOutOfTheCacheKeyDoNotChangeTheTile) makeBTermAtEdge("pin_m1", "metal1", 0, 4000, 200, 200); makeBTermAtEdge("pin_m3", "metal3", 7800, 4000, 200, 200); ASSERT_NE(makeMetal1AccessPoint(), nullptr); + // Power and ground pins, so the net flags have something to change there. + block_->findNet("pin_m3")->setSigType(odb::dbSigType::POWER); + block_->findNet("ap_pin")->setSigType(odb::dbSigType::GROUND); odb::dbGCellGrid* grid = odb::dbGCellGrid::create(block_); ASSERT_NE(grid, nullptr); grid->addGridPatternX(0, 4, 2000); @@ -8455,19 +8532,9 @@ TEST_F(TileGeneratorTest, FieldsLeftOutOfTheCacheKeyDoNotChangeTheTile) boost::json::object{{die, boost::json::array{"metal1"}}}}}); changes.emplace_back(hidden_m1, with({})); - const std::string_view layers[] = {"metal1", - "metal3", - "_instances", - "_pins", - "_regions", - "_inst_labels", - "_access_points", - "_mfg_grid", - "_gcell_grid", - "_rudy", - "_routing_congestion", - "_modules", - "_clusters"}; + std::vector layers(std::begin(kTileLayers), + std::end(kTileLayers)); + layers.emplace_back("metal3"); for (const auto& [a, b] : changes) { for (const std::string_view layer : layers) { if (!keyCounts(a, b, layer)) { @@ -8477,23 +8544,28 @@ TEST_F(TileGeneratorTest, FieldsLeftOutOfTheCacheKeyDoNotChangeTheTile) } } - // The scene gives each exclusion something to switch on its own layer, but - // pin names need a closer zoom, no RUDY or congestion source is in this - // binary, and the color overlays draw only with owner colors. + // What the scene shows on a pseudo layer, so the check above has pixels to + // compare there. Pin names need a closer zoom, no RUDY or congestion source + // is in this binary, and the color overlays draw only with owner colors. const auto lit = [&](std::string_view layer, std::string_view flag) { return render(layer, with({{flag, true}})) != render(layer, with({{flag, false}})); }; - const std::set unlit = {"pin_names", - "inst_pin_names", - "rudy", - "routing_congestion", - "module_view", - "cluster_view"}; - for (const auto& [flag, layer] : kOwnedFlags) { - if (!unlit.contains(flag)) { - EXPECT_TRUE(lit(layer, flag)) << flag << " on " << layer; - } + const std::pair shown[] + = {{"access_points", "_access_points"}, + {"regions", "_regions"}, + {"mfg_grid", "_mfg_grid"}, + {"gcell_grid", "_gcell_grid"}, + {"inst_names", "_inst_labels"}, + {"pin_markers", "_pins"}, + {"rows", "_instances"}, + {"placement_blockages", "_instances"}, + {"pins", "_pins"}, + {"net_signal", "_pins"}, + {"net_power", "_pins"}, + {"net_ground", "_access_points"}}; + for (const auto& [flag, layer] : shown) { + EXPECT_TRUE(lit(layer, flag)) << flag << " on " << layer; } EXPECT_NE(render("_pins", m1), render("_pins", m5)); EXPECT_NE(render("_pins", hidden_m1), render("_pins", with({}))); diff --git a/openroad/web/test/js/test-display-controls.js b/openroad/web/test/js/test-display-controls.js index e45cb593271..699fd3a01c5 100644 --- a/openroad/web/test/js/test-display-controls.js +++ b/openroad/web/test/js/test-display-controls.js @@ -1317,6 +1317,20 @@ describe('dies sharing a layer name', () => { assert.equal(app.baseSlot.refreshes, before + 1); }); + it('refreshes the overlay when route guides lose a layer name', () => { + render(); + const overlay = app.view.addTileSlot('overlay'); + app.overlayLayer = overlay; + app.routeGuideNets = new Set([7]); + app.layerModel.check(rowId('die0', 'metal1'), false); + assert.equal(overlay.refreshes, 0, 'die1 still shows metal1'); + app.layerModel.check(rowId('die1', 'metal1'), false); + assert.equal(overlay.refreshes, 1); + app.routeGuideNets.clear(); + app.layerModel.check(rowId('die1', 'metal1'), true); + assert.equal(overlay.refreshes, 1, 'no route guides to redraw'); + }); + it('restores a die\'s hidden row from the session', () => { window.sessionStorage.setItem( 'or_hidden_layers', JSON.stringify([rowId('die0', 'metal1')])); diff --git a/openroad/web/test/js/test-inspector.js b/openroad/web/test/js/test-inspector.js index 9cf62c3cb85..448f92c9674 100644 --- a/openroad/web/test/js/test-inspector.js +++ b/openroad/web/test/js/test-inspector.js @@ -69,6 +69,18 @@ describe('Inspector focus nets', () => { }); describe('updateInspector toolbar buttons', () => { + it('lets a client-side object delete itself, in a saved report too', + () => { + app.websocketManager.isStaticMode = true; + let deleted = 0; + panel.updateInspector({ type: 'Ruler', name: 'R0', + properties: [{ name: 'Name', value: 'R0' }], + onDelete: () => deleted++ }); + app.inspectorEl.querySelector('button[title="Delete ruler"]') + .click(); + assert.equal(deleted, 1); + }); + it('shows focus button for Net type', () => { panel.updateInspector(netData('clk')); const btns = app.inspectorEl.querySelectorAll('.or-btn-icon'); @@ -881,6 +893,30 @@ describe('animateSelection', () => { const anim = () => app.view.shapes('anim')[0]; + it('stops the animation when Highlight selected is turned off', () => { + try { + panel.animateSelection([0, 0, 100, 100]); + assert.ok(app.view.overlays.has('anim')); + app.visibility = { highlight_selected: false }; + app.renderSelectionOutline(); + assert.equal(app.view.overlays.has('anim'), false); + assert.ok(timers.cleared > 0); + } finally { + restoreTimers(); + } + }); + + it('draws nothing while Highlight selected is off', () => { + try { + app.visibility = { highlight_selected: false }; + panel.animateSelection([0, 0, 100, 100]); + assert.equal(app.view.overlays.has('anim'), false); + assert.equal(timers.cb, null, 'no animation running'); + } finally { + restoreTimers(); + } + }); + it('draws the outline and cycles weight 1→2→3 with brush flash on 1', () => { try { panel.animateSelection([0, 0, 100, 100]); diff --git a/openroad/web/test/js/test-label-manager.js b/openroad/web/test/js/test-label-manager.js index d115e8aa0fa..0696541897f 100644 --- a/openroad/web/test/js/test-label-manager.js +++ b/openroad/web/test/js/test-label-manager.js @@ -7,8 +7,6 @@ import assert from 'node:assert/strict'; import './setup-dom.js'; import { makeFakeView } from './fake-view.js'; -globalThis.requestAnimationFrame = (cb) => setTimeout(cb, 0); - const { LabelManager } = await import('../../src/label-manager.js'); const { beginSelection, onSelectionReset } = await import('../../src/ui-utils.js'); @@ -317,6 +315,18 @@ describe('LabelManager', () => { assert.equal(shown, 0); }); + it('lets the Inspector delete the label', async () => { + const { mgr, requests } = makeManager(); + mgr._applyLabels([{ name: 'L0', x: 5, y: 6, text: 'a' }]); + let shown = null; + mgr._updateInspector = (data) => { shown = data; }; + mgr._select('L0'); + shown.onDelete(); + await flush(); + assert.ok(requests.some((r) => r.type === 'delete_label' + && r.name === 'L0')); + }); + it('_edit sends a single atomic update_label with the patched fields', async () => { const { mgr, requests } = makeManager(); diff --git a/openroad/web/test/js/test-layout-view.js b/openroad/web/test/js/test-layout-view.js index 4f45cb46d05..f8e01ced2a5 100644 --- a/openroad/web/test/js/test-layout-view.js +++ b/openroad/web/test/js/test-layout-view.js @@ -168,6 +168,17 @@ describe('LayoutView view state', () => { assert.deepEqual(events, [true, false]); }); + // A pan inside a trackpad zoom leaves the fractional level to it. + it('keeps a gesture fractional zoom through a pan that does not settle', + () => { + const { view } = setup(); + view.setView([120, 120], 3, { animate: false }); + view.zoomAround([100, 100], 0.4, { animate: false, settle: false }); + view.panByPx(10, 0, { animate: false, settle: false }); + assert.ok(Math.abs(view.getZoom() - 3.4) < 1e-9, String(view.getZoom())); + assert.ok(view.debugSnapshot().moving); + }); + it('pans by screen pixels', () => { const { view, frames } = setup(); view.setView([120, 120], 1); @@ -176,6 +187,19 @@ describe('LayoutView view state', () => { assert.deepEqual(view.getCenter(), [130, 140]); }); + it('does nothing when zooming past a limit at rest', () => { + const { view, frames } = setup({ smooth: true }); + view.setLimits({ minZoom: 0, maxZoom: 3 }); + view.setView([120, 120], 3, { animate: false }); + frames.flush(); + const events = []; + view.on('movestart moveend', () => events.push(1)); + view.zoomAround([100, 100], 1); + view.zoomAround(null, 1); + assert.deepEqual(events, []); + assert.ok(!view.debugSnapshot().animating); + }); + it('honors the zoom limits', () => { const { view, frames } = setup(); view.setLimits({ minZoom: 0, maxZoom: 3 }); @@ -596,7 +620,9 @@ describe('LayoutView prefetch of the level above', () => { await tick(); frames.flush(); assert.equal(builds, 0); - view.setOverlay('poke', []); // any change that renders + // Any change that renders. + view.setOverlay('poke', [{ kind: 'rect', rect: [0, 0, 1, 1], + stroke: [255, 255, 0, 255], width: 1 }]); frames.flush(); assert.equal(builds, 1); }); @@ -609,7 +635,9 @@ describe('LayoutView prefetch of the level above', () => { await tick(); frames.flush(); const tiles = view.debugSnapshot().slots[0].tiles; - view.setOverlay('poke', []); // any change that renders + // Any change that renders. + view.setOverlay('poke', [{ kind: 'rect', rect: [0, 0, 1, 1], + stroke: [255, 255, 0, 255], width: 1 }]); frames.flush(); assert.equal(view.debugSnapshot().slots[0].tiles, tiles); }); @@ -1115,6 +1143,27 @@ describe('LayoutView shapes, markers and capture', () => { assert.equal(copies, 1); }); + // A deck that draws as soon as it is given the layers. + it('copies the frame drawn by the capture render', async () => { + const deck = makeFakeDeck(); + const { view } = setup({ deck, copyCanvas: (c) => ({ of: c }) }); + await tick(); + const d = deck.decks[0]; + const setProps = d.setProps.bind(d); + d.setProps = (props) => { + setProps(props); + d.frame(); + }; + let timer; + const late = new Promise((resolve) => { + timer = setTimeout(resolve, 100, 'late'); + }); + const shot = await Promise.race([view.captureCanvas(), late]); + clearTimeout(timer); + assert.notEqual(shot, 'late'); + assert.equal(shot.image.of, d.canvas); + }); + it('keeps the drawing buffer only when asked to', () => { const webgl = (opts) => setup(opts).deck.decks[0] .props.deviceProps.webgl.preserveDrawingBuffer; @@ -1230,6 +1279,23 @@ describe('LayoutView renderer', () => { assert.deepEqual(seen.map((info) => info.gpuType), ['cpu', 'integrated']); }); + it('reports no renderer when the deck cannot even be made', async (t) => { + t.mock.method(console, 'error', () => {}); + const deck = makeFakeDeck(); + deck.Deck = class { + constructor() { + throw new Error('no canvas'); + } + }; + const { view } = setup({ deck }); + const seen = []; + view.on('renderer', (info) => seen.push(info.gpuType)); + await tick(); + assert.deepEqual(seen, ['none']); + view.setView([1, 2], 3, { animate: false }); + assert.equal(view.getZoom(), 3); + }); + it('reports a browser without WebGL as no renderer at all', async (t) => { t.mock.method(console, 'error', () => {}); const deck = makeFakeDeck(); diff --git a/openroad/web/test/js/test-ruler.js b/openroad/web/test/js/test-ruler.js index 69909dee797..e1a087784b0 100644 --- a/openroad/web/test/js/test-ruler.js +++ b/openroad/web/test/js/test-ruler.js @@ -9,9 +9,6 @@ import { beginSelection, formatDbu, formatDistance, onSelectionReset, parseDbu } import './setup-dom.js'; import { makeFakeView } from './fake-view.js'; -// Node.js doesn't have requestAnimationFrame. -globalThis.requestAnimationFrame = (cb) => setTimeout(cb, 0); - const { RulerManager } = await import('../../src/ruler.js'); // ─── Test helpers ──────────────────────────────────────────────────────────── @@ -397,6 +394,14 @@ describe('Ruler inspector data', () => { assert.equal(propMap['Euclidian'], 'True'); }); + it('lets the Inspector delete the ruler', () => { + const { mgr, inspectorData } = makeManager(); + mgr._createRuler({ x: 0, y: 0 }, { x: 1000, y: 0 }); + mgr._selectRuler(0); + inspectorData.at(-1).onDelete(); + assert.equal(mgr._rulers.length, 0); + }); + it('_selectRuler produces DBU values when showDbu is true', () => { const { mgr, app, inspectorData } = makeManager(); app.showDbu = true; diff --git a/openroad/web/test/js/test-tile-grid.js b/openroad/web/test/js/test-tile-grid.js index 8e53ee41b66..8b6e12d59e5 100644 --- a/openroad/web/test/js/test-tile-grid.js +++ b/openroad/web/test/js/test-tile-grid.js @@ -228,6 +228,50 @@ describe('TileGrid.refresh', () => { assert.deepEqual(released, [{ id: 'v1' }]); }); + // A load from before a second refresh, kept while another level was + // shown, is asked for again when its level comes back. + it('reloads a tile still loading from before the last refresh', async () => { + const { source, loads, released } = makeSource(); + const grid = new TileGrid({ source }); + grid.update({ z: 1, range: R(0, 0, 0, 0, 1) }); + loads[0].resolve({ id: 'gen0' }); + await tick(); + grid.refresh(); + const gen1 = loads.at(-1); + grid.update({ z: 2, range: R(0, 0, 0, 0, 2) }); + grid.refresh(); + grid.update({ z: 1, range: R(0, 0, 0, 0, 1) }); + assert.ok(gen1.cancelled, 'the stale load'); + const gen2 = loads.at(-1); + assert.deepEqual([gen2.z, gen2.x, gen2.y], [1, 0, 0]); + gen1.resolve({ id: 'gen1' }); + gen2.resolve({ id: 'gen2' }); + await tick(); + assert.deepEqual(grid.tiles.get('1/0/0').drawable, { id: 'gen2' }); + assert.ok(!released.some((d) => d && d.id === 'gen2')); + }); + + it('reloads a stale ring tile that comes on screen, without promoting it', + async () => { + const { source, loads } = makeSource(); + const grid = new TileGrid({ source }); + grid.update({ z: 1, range: R(0, 0, 0, 0, 1), ring: R(0, 1, 0, 0, 1) }); + for (const l of loads) { + l.resolve({ key: l.key }); + } + await tick(); + grid.refresh(); + const ring = loads.at(-1); + assert.deepEqual([ring.key, ring.background], ['1/1/0', true]); + grid.update({ z: 2, range: R(0, 0, 0, 0, 2) }); + grid.refresh(); // level 1 goes stale + grid.update({ z: 1, range: R(1, 1, 0, 0, 1) }); + assert.ok(ring.cancelled); + assert.ok(!ring.promoted); + const again = loads.at(-1); + assert.deepEqual([again.key, again.background], ['1/1/0', false]); + }); + it('discards a superseded result', async () => { const { source, loads, released } = makeSource(); const grid = new TileGrid({ source }); diff --git a/openroad/web/test/js/test-view-input.js b/openroad/web/test/js/test-view-input.js index c585e4add2c..a80eb7e5d67 100644 --- a/openroad/web/test/js/test-view-input.js +++ b/openroad/web/test/js/test-view-input.js @@ -23,11 +23,16 @@ function makeView() { getContainer: () => container, unproject: ([x, y]) => [x / 2, y / 2], zoom: 3, + // Where an animation under way is heading; null when at rest. + target: null, getZoom: () => view.zoom, + getTargetZoom: () => view.target ?? view.zoom, panByPx: (dx, dy, opts) => calls.push(['pan', dx, dy, opts]), + // From the level an animation is heading to, as layout-view does. zoomAround: (pt, delta, opts) => { calls.push(opts ? ['zoom', pt, delta, opts] : ['zoom', pt, delta]); - view.zoom += delta; + view.zoom = view.getTargetZoom() + delta; + view.target = null; }, fitWorldRect: (rect) => calls.push(['fit', rect]), setGesture: (on) => gestures.push([on, calls.length]), @@ -39,6 +44,12 @@ function fire(target, type, init = {}) { const Ctor = type === 'wheel' ? window.WheelEvent : type.startsWith('key') ? window.KeyboardEvent : window.MouseEvent; const event = new Ctor(type, { bubbles: true, cancelable: true, ...init }); + // jsdom has no PointerEvent: a touch sets these by hand. + for (const key of ['pointerId', 'isPrimary']) { + if (key in init) { + Object.defineProperty(event, key, { value: init[key] }); + } + } target.dispatchEvent(event); return event; } @@ -68,7 +79,21 @@ describe('wheel', () => { const { view, container, calls } = makeView(); installViewInput(view, { wheelZoom: () => false }); fire(container, 'wheel', { deltaX: 25, deltaY: 0 }); - assert.deepEqual(calls, [['pan', 25, 0, { animate: false }]]); + assert.deepEqual(calls, + [['pan', 25, 0, { animate: false, settle: true }]]); + }); + + // A pinch comes as deltaY: Ctrl with a sideways scroll is still a scroll. + it('pans a sideways scroll with Ctrl held, whatever the wheel does', () => { + for (const zoomPref of [true, false]) { + const { view, container, calls } = makeView(); + installViewInput(view, { wheelZoom: () => zoomPref }); + fire(container, 'wheel', { deltaX: 30, deltaY: 0, ctrlKey: true }); + fire(container, 'wheel', { deltaX: 3, deltaY: 0, deltaMode: 1, + ctrlKey: true }); + assert.deepEqual(calls.map((c) => c.slice(0, 3)), + [['pan', 30, 0], ['pan', 48, 0]], String(zoomPref)); + } }); it('does nothing in a saved report', () => { @@ -132,6 +157,53 @@ describe('trackpad', () => { assert.equal(Math.abs(gestureSteps(-0.1)), 0); }); + // A pinch that starts during an animation counts from where it heads. + it('ends a pinch begun mid-animation on the level past the target', + async () => { + const { view, container } = makeView(); + installViewInput(view, { gestureIdleMs: 20 }); + view.zoom = 3.49; + view.target = 4; + fire(container, 'wheel', { deltaY: -LEVEL / 4, ctrlKey: true, + clientX: 40, clientY: 20 }); + await wait(40); + assert.ok(Math.abs(view.zoom - 5) < 1e-9, String(view.zoom)); + }); + + it('pans a sideways scroll even when the wheel zooms', () => { + const { view, container, calls, gestures } = makeView(); + installViewInput(view, { wheelZoom: () => true }); + fire(container, 'wheel', { deltaX: 30, deltaY: 0 }); + assert.deepEqual(calls, + [['pan', 30, 0, { animate: false, settle: true }]]); + assert.ok(!calls.some((c) => c[0] === 'zoom')); + assert.deepEqual(gestures.map(([on]) => on), [true]); + }); + + // A scroll in the middle of a pinch leaves the zoom to the pinch, which + // settles at its own point once the fingers stop. + it('keeps a pinch going through a scroll', async () => { + const { view, container, calls } = makeView(); + installViewInput(view, { wheelZoom: () => false, gestureIdleMs: 20 }); + fire(container, 'wheel', { deltaY: -LEVEL / 2, ctrlKey: true, + clientX: 40, clientY: 20 }); + fire(container, 'wheel', { deltaY: 10.5, clientX: 40, clientY: 20 }); + assert.deepEqual(calls.map((c) => c[0]), ['zoom', 'pan']); + assert.deepEqual(calls[1][3], { animate: false, settle: false }); + await wait(40); + assert.deepEqual(calls[2].slice(0, 2), ['zoom', [40, 20]]); + assert.ok(Math.abs(view.zoom - 4) < 1e-9, String(view.zoom)); + }); + + it('ignores a wheel event that moves nothing', () => { + const { view, container, calls, gestures } = makeView(); + installViewInput(view, { wheelZoom: () => true }); + fire(container, 'wheel', { deltaX: 0, deltaY: 0 }); + fire(container, 'wheel', { deltaX: 0, deltaY: 0, deltaMode: 1 }); + assert.deepEqual(calls, []); + assert.deepEqual(gestures, []); + }); + it('zooms on a pinch even when the preference makes ctrl+wheel pan', async () => { const { view, container, calls } = makeView(); @@ -175,7 +247,8 @@ describe('trackpad', () => { const { view, container, calls } = makeView(); installViewInput(view, { wheelZoom: () => false }); fire(container, 'wheel', { deltaY: 12, deltaX: 5 }); - assert.deepEqual(calls, [['pan', 5, 12, { animate: false }]]); + assert.deepEqual(calls, + [['pan', 5, 12, { animate: false, settle: true }]]); }); it('holds the view through a scroll pan until it pauses', async () => { @@ -200,6 +273,21 @@ describe('trackpad', () => { assert.deepEqual(gestures, [[true, 0], [false, 3]]); }); + it('holds the view through a scroll that outlasts a pinch', (t) => { + t.mock.timers.enable({ apis: ['setTimeout'] }); + const { view, container, calls, gestures } = makeView(); + installViewInput(view, { wheelZoom: () => false, gestureIdleMs: 20 }); + fire(container, 'wheel', { deltaY: -LEVEL / 2, ctrlKey: true, + clientX: 40, clientY: 20 }); + t.mock.timers.tick(10); + fire(container, 'wheel', { deltaY: 10.5 }); + t.mock.timers.tick(15); // the pinch settles at 20 + assert.deepEqual(calls.map((c) => c[0]), ['zoom', 'pan', 'zoom']); + assert.deepEqual(gestures, [[true, 0]]); + t.mock.timers.tick(10); // the scroll pauses at 30 + assert.deepEqual(gestures, [[true, 0], [false, 3]]); + }); + it('settles a gesture before a mouse step', () => { const { view, container, calls } = makeView(); installViewInput(view, { wheelZoom: () => true, gestureIdleMs: 1000 }); @@ -255,6 +343,46 @@ describe('left button', () => { assert.deepEqual(clicks, [[[6, 5.5], true]]); }); + const touch = (target, type, pointerId, isPrimary, x) => fire( + target, type, { button: 0, clientX: x, clientY: 10, pointerId, + isPrimary }); + + it('makes a two-finger tap no click', () => { + const { view, container } = makeView(); + const clicks = []; + installViewInput(view, { onClick: () => clicks.push(1) }); + touch(container, 'pointerdown', 1, true, 10); + touch(container, 'pointerdown', 2, false, 60); + touch(window, 'pointerup', 2, false, 60); + touch(window, 'pointerup', 1, true, 10); + assert.deepEqual(clicks, []); + }); + + it('makes a two-finger tap no click when the second lands on a marker', + () => { + const { view, container } = makeView(); + const clicks = []; + installViewInput(view, { onClick: () => clicks.push(1) }); + const marker = document.createElement('div'); + marker.className = 'or-view-marker'; + container.appendChild(marker); + touch(container, 'pointerdown', 1, true, 10); + touch(marker, 'pointerdown', 2, false, 60); + touch(window, 'pointerup', 2, false, 60); + touch(window, 'pointerup', 1, true, 10); + assert.deepEqual(clicks, []); + }); + + it('lets a new touch click after a release that never came', () => { + const { view, container } = makeView(); + const clicks = []; + installViewInput(view, { onClick: () => clicks.push(1) }); + touch(container, 'pointerdown', 1, true, 10); + touch(container, 'pointerdown', 3, true, 20); + touch(window, 'pointerup', 3, true, 20); + assert.deepEqual(clicks, [1]); + }); + // A label handle or ruler label handles its own clicks and drags. it('ignores presses that start on a marker', () => { const { view, container, calls } = makeView(); @@ -360,6 +488,24 @@ describe('left button', () => { assert.deepEqual(clicks, [[[8, 5], true]]); }); + // A band left by a press whose release was lost does not turn the next + // click into a zoom. + it('drops the band of a press that never ended', () => { + const { view, container, calls } = makeView(); + const clicks = []; + installViewInput(view, { onClick: () => clicks.push(1) }); + const canvas = shiftCanvas(container); + fire(canvas, 'pointerdown', { button: 0, shiftKey: true, + clientX: 10, clientY: 10 }); + fire(window, 'pointermove', { clientX: 50, clientY: 30 }); + assert.ok(document.querySelector('.rubber-band')); + fire(canvas, 'pointerdown', { button: 0, clientX: 20, clientY: 20 }); + assert.equal(document.querySelector('.rubber-band'), null); + fire(window, 'pointerup', { button: 0, clientX: 20, clientY: 20 }); + assert.deepEqual(calls, []); + assert.deepEqual(clicks, [1]); + }); + it('does nothing for a long Shift+drag along one axis', () => { const { view, container, calls } = makeView(); const clicks = []; @@ -436,6 +582,20 @@ describe('right button', () => { assert.deepEqual(context, [[2.5, 1.5]]); }); + it('opens the context menu after a band whose release was lost', () => { + const { view, container, calls } = makeView(); + const context = []; + installViewInput(view, { onContextClick: (w) => context.push(w) }); + fire(container, 'pointerdown', { button: 2, clientX: 100, clientY: 80 }); + fire(window, 'pointermove', { clientX: 60, clientY: 20 }); + assert.ok(document.querySelector('.rubber-band')); + fire(container, 'pointerdown', { button: 2, clientX: 4, clientY: 2 }); + assert.equal(document.querySelector('.rubber-band'), null); + fire(window, 'pointerup', { button: 2, clientX: 4, clientY: 2 }); + assert.deepEqual(calls, []); + assert.deepEqual(context, [[2, 1]]); + }); + it('skips the context menu while a ruler is placed', () => { const { view, container } = makeView(); const context = [];